[
  {
    "path": ".gitignore",
    "content": "# Object files\n*.o\n*.lo\n*.obj\n\n# Compiled libraries\n*.so\n*.dll\n*.dylib\n*.a\n*.la\n*.lib\n\n# Executables\n*.exe\n*.out\n\n# Byte code\n*.pyc\n\n# Editors & Tools\n.idea/\n*.sublime-*\n*~\n\n# Folders\n.DS_Store\n/build*\n/gtest/**\n/gmock/**\n/harness/**\n/doc/html\n/doc/latex\n/mysql-server\n\n# Python\n*__pycache__*\nMANIFEST\n\n# Misc.\ncommit.txt\n*.patch\n*.diff\nlocal.cmake\npackages/rpm-*/*.spec\n"
  },
  {
    "path": "CMakeLists.txt",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\ncmake_minimum_required(VERSION 2.8.12)\n\ninclude(cmake/version.cmake)\nset(CMAKE_MODULE_PATH \"${CMAKE_CURRENT_SOURCE_DIR}/cmake\" ${CMAKE_MODULE_PATH})\n\nif(${CMAKE_VERSION} VERSION_GREATER \"3.0\")\n  cmake_policy(SET CMP0042 NEW)\n  cmake_policy(SET CMP0046 NEW)\n  cmake_policy(SET CMP0048 NEW)\n  if(${CMAKE_VERSION} VERSION_GREATER \"3.1\")\n    cmake_policy(SET CMP0054 NEW)\n  endif()\n  project(\"MySQLRouter\" VERSION ${PROJECT_VERSION_TEXT} LANGUAGES C CXX)\nelse()\n  project(\"MySQLRouter\")\nendif()\n\nSET(MySQLRouter_BINARY_STAGE_DIR ${MySQLRouter_BINARY_DIR}/stage CACHE INTERNAL \"STAGE_DIR\")\n\nif(EXISTS \"${CMAKE_SOURCE_DIR}/extra/rapidjson/\")\n  # prefer server-side rapidjson\n  SET(RAPIDJSON_INCLUDE_DIRS \"${CMAKE_SOURCE_DIR}/extra/rapidjson/include/\")\nelse()\n  SET(RAPIDJSON_INCLUDE_DIRS \"${MySQLRouter_SOURCE_DIR}/ext/rapidjson/include/\")\nendif()\n\nIF(CMAKE_SYSTEM_NAME STREQUAL \"SunOS\")\n  # disable rapidjson optimisation on Solaris as the it breaks\n  # shared objects that build with -fPIC\n  ADD_DEFINITIONS(-DRAPIDJSON_48BITPOINTER_OPTIMIZATION=0)\nENDIF()\n\nIF(EXISTS \"${CMAKE_SOURCE_DIR}/rapid/plugin/x/protocol/mysqlx.proto\")\n  # use the server's protobuf files, we they exist\n  SET(PROTOBUF_MYSQLX_DIR \"${CMAKE_SOURCE_DIR}/rapid/plugin/x/protocol/\")\nELSE()\n  SET(PROTOBUF_MYSQLX_DIR \"${MySQLRouter_SOURCE_DIR}/src/x_protocol/proto/\")\nENDIF()\n\nfind_package(LibEvent2 2.0 MODULE REQUIRED)\n\ninclude(cmake/settings.cmake)\n\nif(WITH_UNIT_TESTS)\n  set(ENABLE_TESTS 1)\nendif()\n\n# Load Internal\nif(EXISTS \"${PROJECT_SOURCE_DIR}/internal/\")\n  message(STATUS \"Loading internal repository\")\n  add_subdirectory(internal)\nendif()\n\n# SSL\n# Add bundled yassl/taocrypt or system openssl.\ninclude(cmake/ssl.cmake)\nif(NOT WITH_SSL)\n  set(WITH_SSL bundled)\nendif()\nMYSQL_CHECK_SSL()\nMESSAGE(STATUS \"SSL_LIBRARIES:    ${SSL_LIBRARIES}\")\nMESSAGE(STATUS \"SSL_DEFINES:      ${SSL_DEFINES}\")\nMESSAGE(STATUS \"SSL_INCLUDE_DIRS: ${SSL_INCLUDE_DIRS}\")\n\nIF(UNIX)\n  OPTION(WITH_VALGRIND \"Valgrind instrumentation\" OFF)\nENDIF()\n\n# Required tools, libraries, etc..\ninclude(cmake/testing.cmake)  # does not enable testing\ninclude(cmake/platform.cmake)\nif(EXISTS \"${CMAKE_CURRENT_SOURCE_DIR}/cmake/install_layout.cmake\")\n  include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/install_layout.cmake)\nelse()\n  include(cmake/install_layout.cmake)  # needs ARCH_64BIT\nendif()\ninclude(cmake/configure.cmake)\ninclude(Coverage)\n# Harness before Compiler.cmake (compiler flags), after configure.cmake because of compiler flags\ninclude(cmake/compiler.cmake)\nfind_package(Threads REQUIRED)\ninclude(cmake/docs.cmake)\nif(NOT EXISTS \"${CMAKE_SOURCE_DIR}/include/mysql.h\")\n  # if we are built as part of the server-tree, don't initiate our own packaging\n  include(cmake/packaging.cmake)\nendif()\n\nfind_package(MySQL 5.5 REQUIRED)\ninclude_directories(${PROJECT_BINARY_DIR}/include)\n\ninclude(cmake/compile_flags.cmake)\nif(NOT EXISTS \"${CMAKE_SOURCE_DIR}/include/mysql.h\")\n  # if we are build as part of the server-tree, use their protobuf\n  include(cmake/protobuf.cmake)\n  MYSQL_CHECK_PROTOBUF()\nendif()\n\n# Enable testing\nif(ENABLE_TESTS)\n  enable_testing()\n  add_subdirectory(tests)\nendif()\n\n# Load all modules, including plugins\nadd_subdirectory(src)\n"
  },
  {
    "path": "License.txt",
    "content": "Licensing Information User Manual\n\nMySQL Router 8.0\n     __________________________________________________________________\n\nIntroduction\n\n   This License Information User Manual contains Oracle's product license\n   and other licensing information, including licensing information for\n   third-party software which may be included in this distribution of\n   MySQL Router 8.0.\n\n   Last updated: February 2018.\n\nLicensing Information\n\n   This is a release of MySQL Router 8.0, brought to you by the MySQL team\n   at Oracle. This software is released under version 2 of the GNU General\n   Public License (GPLv2), as set forth below, with the following\n   additional permissions:\n\n   This distribution of MySQL Router 8.0 is distributed with certain\n   software (including but not limited to OpenSSL) that is licensed under\n   separate terms, as designated in a particular file or component or in\n   the license documentation. Without limiting your rights under the\n   GPLv2, the authors of MySQL hereby grant you an additional permission\n   to link the program and your derivative works with the separately\n   licensed software that they have included with the program.\n\n   Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights\n   reserved.\n\nElection of GPLv2\n\n   For the avoidance of doubt, except that if any license choice other\n   than GPL or LGPL is available it will apply instead, Oracle elects to\n   use only the General Public License version 2 (GPLv2) at this time for\n   any software where a choice of GPL license versions is made available\n   with the language indicating that GPLv2 or any later version may be\n   used, or where a choice of which version of the GPL is applied is\n   otherwise unspecified.\n\nGNU General Public License Version 2.0, June 1991\n\nThe following applies to all products licensed under the GNU General\nPublic License, Version 2.0: You may not use the identified files\nexcept in compliance with the GNU General Public License, Version\n2.0 (the \"License.\") You may obtain a copy of the License at\nhttp://www.gnu.org/licenses/gpl-2.0.txt. A copy of the license is\nalso reproduced below. Unless required by applicable law or agreed\nto in writing, software distributed under the License is distributed\non an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\neither express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n\nGNU GENERAL PUBLIC LICENSE\nVersion 2, June 1991\n\nCopyright (C) 1989, 1991 Free Software Foundation, Inc.,\n51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\nEveryone is permitted to copy and distribute verbatim\ncopies of this license document, but changing it is not\nallowed.\n\n                     Preamble\n\n  The licenses for most software are designed to take away your\nfreedom to share and change it.  By contrast, the GNU General Public\nLicense is intended to guarantee your freedom to share and change free\nsoftware--to make sure the software is free for all its users.  This\nGeneral Public License applies to most of the Free Software\nFoundation's software and to any other program whose authors commit to\nusing it.  (Some other Free Software Foundation software is covered by\nthe GNU Lesser General Public License instead.)  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthis service if you wish), that you receive source code or can get it\nif you want it, that you can change the software or use pieces of it\nin new free programs; and that you know you can do these things.\n\n  To protect your rights, we need to make restrictions that forbid\nanyone to deny you these rights or to ask you to surrender the rights.\nThese restrictions translate to certain responsibilities for you if you\ndistribute copies of the software, or if you modify it.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must give the recipients all the rights that\nyou have.  You must make sure that they, too, receive or can get the\nsource code.  And you must show them these terms so they know their\nrights.\n\n  We protect your rights with two steps: (1) copyright the software,\nand (2) offer you this license which gives you legal permission to\ncopy, distribute and/or modify the software.\n\n  Also, for each author's protection and ours, we want to make certain\nthat everyone understands that there is no warranty for this free\nsoftware.  If the software is modified by someone else and passed on,\nwe want its recipients to know that what they have is not the original,\nso that any problems introduced by others will not reflect on the\noriginal authors' reputations.\n\n  Finally, any free program is threatened constantly by software\npatents.  We wish to avoid the danger that redistributors of a free\nprogram will individually obtain patent licenses, in effect making the\nprogram proprietary.  To prevent this, we have made it clear that any\npatent must be licensed for everyone's free use or not licensed at all.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                    GNU GENERAL PUBLIC LICENSE\n   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n  0. This License applies to any program or other work which contains\na notice placed by the copyright holder saying it may be distributed\nunder the terms of this General Public License.  The \"Program\", below,\nrefers to any such program or work, and a \"work based on the Program\"\nmeans either the Program or any derivative work under copyright law:\nthat is to say, a work containing the Program or a portion of it,\neither verbatim or with modifications and/or translated into another\nlanguage.  (Hereinafter, translation is included without limitation in\nthe term \"modification\".)  Each licensee is addressed as \"you\".\n\nActivities other than copying, distribution and modification are not\ncovered by this License; they are outside its scope.  The act of\nrunning the Program is not restricted, and the output from the Program\nis covered only if its contents constitute a work based on the\nProgram (independent of having been made by running the Program).\nWhether that is true depends on what the Program does.\n\n\n  1. You may copy and distribute verbatim copies of the Program's\nsource code as you receive it, in any medium, provided that you\nconspicuously and appropriately publish on each copy an appropriate\ncopyright notice and disclaimer of warranty; keep intact all the\nnotices that refer to this License and to the absence of any warranty;\nand give any other recipients of the Program a copy of this License\nalong with the Program.\n\nYou may charge a fee for the physical act of transferring a copy, and\nyou may at your option offer warranty protection in exchange for a fee.\n\n\n  2. You may modify your copy or copies of the Program or any portion\nof it, thus forming a work based on the Program, and copy and\ndistribute such modifications or work under the terms of Section 1\nabove, provided that you also meet all of these conditions:\n\n    a) You must cause the modified files to carry prominent notices\n    stating that you changed the files and the date of any change.\n\n    b) You must cause any work that you distribute or publish, that in\n    whole or in part contains or is derived from the Program or any\n    part thereof, to be licensed as a whole at no charge to all third\n    parties under the terms of this License.\n\n    c) If the modified program normally reads commands interactively\n    when run, you must cause it, when started running for such\n    interactive use in the most ordinary way, to print or display an\n    announcement including an appropriate copyright notice and a\n    notice that there is no warranty (or else, saying that you provide\n    a warranty) and that users may redistribute the program under\n    these conditions, and telling the user how to view a copy of this\n    License.  (Exception: if the Program itself is interactive but\n    does not normally print such an announcement, your work based on\n    the Program is not required to print an announcement.)\n\nThese requirements apply to the modified work as a whole.  If\nidentifiable sections of that work are not derived from the Program,\nand can be reasonably considered independent and separate works in\nthemselves, then this License, and its terms, do not apply to those\nsections when you distribute them as separate works.  But when you\ndistribute the same sections as part of a whole which is a work based\non the Program, the distribution of the whole must be on the terms of\nthis License, whose permissions for other licensees extend to the\nentire whole, and thus to each and every part regardless of who wrote it.\n\nThus, it is not the intent of this section to claim rights or contest\nyour rights to work written entirely by you; rather, the intent is to\nexercise the right to control the distribution of derivative or\ncollective works based on the Program.\n\nIn addition, mere aggregation of another work not based on the Program\nwith the Program (or with a work based on the Program) on a volume of\na storage or distribution medium does not bring the other work under\nthe scope of this License.\n\n\n  3. You may copy and distribute the Program (or a work based on it,\nunder Section 2) in object code or executable form under the terms of\nSections 1 and 2 above provided that you also do one of the following:\n\n    a) Accompany it with the complete corresponding machine-readable\n    source code, which must be distributed under the terms of Sections\n    1 and 2 above on a medium customarily used for software\n    interchange; or,\n\n    b) Accompany it with a written offer, valid for at least three\n    years, to give any third party, for a charge no more than your\n    cost of physically performing source distribution, a complete\n    machine-readable copy of the corresponding source code, to be\n    distributed under the terms of Sections 1 and 2 above on a medium\n    customarily used for software interchange; or,\n\n    c) Accompany it with the information you received as to the offer\n    to distribute corresponding source code.  (This alternative is\n    allowed only for noncommercial distribution and only if you\n    received the program in object code or executable form with such\n    an offer, in accord with Subsection b above.)\n\nThe source code for a work means the preferred form of the work for\nmaking modifications to it.  For an executable work, complete source\ncode means all the source code for all modules it contains, plus any\nassociated interface definition files, plus the scripts used to\ncontrol compilation and installation of the executable.  However, as\na special exception, the source code distributed need not include\nanything that is normally distributed (in either source or binary\nform) with the major components (compiler, kernel, and so on) of the\noperating system on which the executable runs, unless that component\nitself accompanies the executable.\n\nIf distribution of executable or object code is made by offering\naccess to copy from a designated place, then offering equivalent\naccess to copy the source code from the same place counts as\ndistribution of the source code, even though third parties are not\ncompelled to copy the source along with the object code.\n\n\n  4. You may not copy, modify, sublicense, or distribute the Program\nexcept as expressly provided under this License.  Any attempt\notherwise to copy, modify, sublicense or distribute the Program is\nvoid, and will automatically terminate your rights under this License.\nHowever, parties who have received copies, or rights, from you under\nthis License will not have their licenses terminated so long as such\nparties remain in full compliance.\n\n\n  5. You are not required to accept this License, since you have not\nsigned it.  However, nothing else grants you permission to modify or\ndistribute the Program or its derivative works.  These actions are\nprohibited by law if you do not accept this License.  Therefore, by\nmodifying or distributing the Program (or any work based on the\nProgram), you indicate your acceptance of this License to do so, and\nall its terms and conditions for copying, distributing or modifying\nthe Program or works based on it.\n\n\n  6. Each time you redistribute the Program (or any work based on the\nProgram), the recipient automatically receives a license from the\noriginal licensor to copy, distribute or modify the Program subject to\nthese terms and conditions.  You may not impose any further\nrestrictions on the recipients' exercise of the rights granted herein.\nYou are not responsible for enforcing compliance by third parties to\nthis License.\n\n\n  7. If, as a consequence of a court judgment or allegation of patent\ninfringement or for any other reason (not limited to patent issues),\nconditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot\ndistribute so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you\nmay not distribute the Program at all.  For example, if a patent\nlicense would not permit royalty-free redistribution of the Program by\nall those who receive copies directly or indirectly through you, then\nthe only way you could satisfy both it and this License would be to\nrefrain entirely from distribution of the Program.\n\nIf any portion of this section is held invalid or unenforceable under\nany particular circumstance, the balance of the section is intended to\napply and the section as a whole is intended to apply in other\ncircumstances.\n\nIt is not the purpose of this section to induce you to infringe any\npatents or other property right claims or to contest validity of any\nsuch claims; this section has the sole purpose of protecting the\nintegrity of the free software distribution system, which is\nimplemented by public license practices.  Many people have made\ngenerous contributions to the wide range of software distributed\nthrough that system in reliance on consistent application of that\nsystem; it is up to the author/donor to decide if he or she is willing\nto distribute software through any other system and a licensee cannot\nimpose that choice.\n\nThis section is intended to make thoroughly clear what is believed to\nbe a consequence of the rest of this License.\n\n\n  8. If the distribution and/or use of the Program is restricted in\ncertain countries either by patents or by copyrighted interfaces, the\noriginal copyright holder who places the Program under this License\nmay add an explicit geographical distribution limitation excluding\nthose countries, so that distribution is permitted only in or among\ncountries not thus excluded.  In such case, this License incorporates\nthe limitation as if written in the body of this License.\n\n\n  9. The Free Software Foundation may publish revised and/or new\nversions of the General Public License from time to time.  Such new\nversions will be similar in spirit to the present version, but may\ndiffer in detail to address new problems or concerns.\n\nEach version is given a distinguishing version number.  If the Program\nspecifies a version number of this License which applies to it and\n\"any later version\", you have the option of following the terms and\nconditions either of that version or of any later version published by\nthe Free Software Foundation.  If the Program does not specify a\nversion number of this License, you may choose any version ever\npublished by the Free Software Foundation.\n\n  10. If you wish to incorporate parts of the Program into other free\nprograms whose distribution conditions are different, write to the\nauthor to ask for permission.  For software which is copyrighted by the\nFree Software Foundation, write to the Free Software Foundation; we\nsometimes make exceptions for this.  Our decision will be guided by the\ntwo goals of preserving the free status of all derivatives of our free\nsoftware and of promoting the sharing and reuse of software generally.\n\n                            NO WARRANTY\n\n  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO\nWARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.\nEXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR\nOTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND,\nEITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\nTHE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS\nWITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN\nWRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY\nAND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU\nFOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR\nCONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE\nPROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING\nRENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A\nFAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF\nSUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\nDAMAGES.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nconvey the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software; you can redistribute it and/or\n    modify it under the terms of the GNU General Public License as\n    published by the Free Software Foundation; either version 2 of\n\n    the License, or (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program; if not, write to the Free Software\n    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA\n    02110-1301 USA.\n\nAlso add information on how to contact you by electronic and paper mail.\n\nIf the program is interactive, make it output a short notice like this\nwhen it starts in an interactive mode:\n\n    Gnomovision version 69, Copyright (C) year name of author\n    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details\n    type 'show w'. This is free software, and you are welcome\n    to redistribute it under certain conditions; type 'show c'\n    for details.\n\nThe hypothetical commands 'show w' and 'show c' should show the\nappropriate parts of the General Public License.  Of course, the\ncommands you use may be called something other than 'show w' and\n'show c'; they could even be mouse-clicks or menu items--whatever\nsuits your program.\n\nYou should also get your employer (if you work as a programmer) or your\nschool, if any, to sign a \"copyright disclaimer\" for the program, if\nnecessary.  Here is a sample; alter the names:\n\n  Yoyodyne, Inc., hereby disclaims all copyright interest in the\n  program 'Gnomovision' (which makes passes at compilers) written\n  by James Hacker.\n\n  <signature of Ty Coon>, 1 April 1989\n  Ty Coon, President of Vice\n\nThis General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library,\nyou may consider it more useful to permit linking proprietary\napplications with the library.  If this is what you want to do, use\nthe GNU Lesser General Public License instead of this License.\n\nLicenses for Third-Party Components\n\n   The following sections contain licensing information for libraries that\n   we have included with the MySQL Router 8.0 source and components used\n   to test MySQL Router 8.0. We are thankful to all individuals that have\n   created these.\n\nGoogle C++ Mocking Framework (Google Mock)\n\n   This Oracle Product includes or references Gmock (including gtest),\n   which is licensed to Oracle under the following terms:\nCopyright 2008, Google Inc.\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this\nlist of conditions and the following disclaimer.\n* Redistributions in binary form must reproduce the above copyright notice,\nthis list of conditions and the following disclaimer in the documentation\nand/or other materials provided with the distribution.\n* Neither the name of Google Inc. nor the names of its contributors may be\nused to endorse or promote products derived from this software without\nspecific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\nLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\nINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\nCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.\n\nGoogle Protocol Buffers\n\n   The following software may be included in this product:\nCopyright 2014, Google Inc.\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the\nfollowing conditions are met:\n\n\n    * Redistributions of source code must retain the above copyright notice,\nthis list of conditions and the following disclaimer.\n\n    * Redistributions in binary form must reproduce the above copyright\nnotice, this list of conditions and the following disclaimer in the\ndocumentation and/or other materials provided with the distribution.\n\n    * Neither the name of Google Inc. nor the names of its contributors may\nbe used to endorse or promote products derived from this software without\nspecific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nCode generated by the Protocol Buffer compiler is owned by the owner  of the\ninput file used when generating it.  This code is not standalone and requires\na support library to be linked with it.  This support library is itself\ncovered by the above license.\n\nOpenSSL License\n\n   You are receiving a copy of OpenSSL as part of this product in object\n   code form. The terms of the Oracle license do NOT apply to OpenSSL.\n   OpenSSL is licensed under a double license, of the OpenSSL License and\n   the original SSLeay license, separate from the Oracle product. If you\n   do not wish to install this library, you may remove it, but the Oracle\n   program might not operate properly or at all without it.\n  LICENSE ISSUES\n  ==============\n\n  The OpenSSL toolkit stays under a double license, i.e. both the conditions of\n  the OpenSSL License and the original SSLeay license apply to the toolkit.\n  See below for the actual license texts. Actually both licenses are BSD-style\n  Open Source licenses. In case of any license issues related to OpenSSL\n  please contact openssl-core@openssl.org.\n\n  OpenSSL License\n  ---------------\n\n/* ====================================================================\n\n * Copyright (c) 1998-2017 The OpenSSL Project.  All rights reserved.\n *\n\n * Redistribution and use in source and binary forms, with or without\n\n * modification, are permitted provided that the following conditions\n\n * are met:\n *\n\n * 1. Redistributions of source code must retain the above copyright\n\n *    notice, this list of conditions and the following disclaimer.\n *\n\n * 2. Redistributions in binary form must reproduce the above copyright\n\n *    notice, this list of conditions and the following disclaimer in\n\n *    the documentation and/or other materials provided with the\n\n *    distribution.\n *\n\n * 3. All advertising materials mentioning features or use of this\n\n *    software must display the following acknowledgment:\n\n *    \"This product includes software developed by the OpenSSL Project\n\n *    for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n *\n\n * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n\n *    endorse or promote products derived from this software without\n\n *    prior written permission. For written permission, please contact\n\n *    openssl-core@openssl.org.\n *\n\n * 5. Products derived from this software may not be called \"OpenSSL\"\n\n *    nor may \"OpenSSL\" appear in their names without prior written\n\n *    permission of the OpenSSL Project.\n *\n\n * 6. Redistributions of any form whatsoever must retain the following\n\n *    acknowledgment:\n\n *    \"This product includes software developed by the OpenSSL Project\n\n *    for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n *\n\n * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n\n * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n\n * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\n\n * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n\n * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n\n * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n\n * OF THE POSSIBILITY OF SUCH DAMAGE.\n\n * ====================================================================\n *\n\n * This product includes cryptographic software written by Eric Young\n\n * (eay@cryptsoft.com).  This product includes software written by Tim\n\n * Hudson (tjh@cryptsoft.com).\n *\n */\n\n Original SSLeay License\n -----------------------\n\n/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)\n\n * All rights reserved.\n *\n\n * This package is an SSL implementation written\n\n * by Eric Young (eay@cryptsoft.com).\n\n * The implementation was written so as to conform with Netscapes SSL.\n *\n\n * This library is free for commercial and non-commercial use as long as\n\n * the following conditions are aheared to.  The following conditions\n\n * apply to all code found in this distribution, be it the RC4, RSA,\n\n * lhash, DES, etc., code; not just the SSL code.  The SSL documentation\n\n * included with this distribution is covered by the same copyright terms\n\n * except that the holder is Tim Hudson (tjh@cryptsoft.com).\n *\n\n * Copyright remains Eric Young's, and as such any Copyright notices in\n\n * the code are not to be removed.\n\n * If this package is used in a product, Eric Young should be given attribution\n\n * as the author of the parts of the library used.\n\n * This can be in the form of a textual message at program startup or\n\n * in documentation (online or textual) provided with the package.\n *\n\n * Redistribution and use in source and binary forms, with or without\n\n * modification, are permitted provided that the following conditions\n\n * are met:\n\n * 1. Redistributions of source code must retain the copyright\n\n *    notice, this list of conditions and the following disclaimer.\n\n * 2. Redistributions in binary form must reproduce the above copyright\n\n *    notice, this list of conditions and the following disclaimer in the\n\n *    documentation and/or other materials provided with the distribution.\n\n * 3. All advertising materials mentioning features or use of this software\n\n *    must display the following acknowledgement:\n\n *    \"This product includes cryptographic software written by\n\n *     Eric Young (eay@cryptsoft.com)\"\n\n *    The word 'cryptographic' can be left out if the rouines from the library\n\n *    being used are not cryptographic related :-).\n\n * 4. If you include any Windows specific code (or a derivative thereof) from\n\n *    the apps directory (application code) you must include an acknowledgement:\n\n *    \"This product includes software written by Tim Hudson (tjh@cryptsoft.com)\"\n *\n\n * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND\n\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n\n * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE\n\n * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n\n * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n\n * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n\n * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n\n * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n\n * SUCH DAMAGE.\n *\n\n * The licence and distribution terms for any publically available version or\n\n * derivative of this code cannot be changed.  i.e. this code cannot simply be\n\n * copied and put under another distribution licence\n\n * [including the GNU Public Licence.]\n */\n\nRapidJSON v1.1.0\n\n   The following software may be included in this product:\nCopyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.  All\nrights reserved.\n\nIf you have downloaded a copy of the RapidJSON binary from Tencent, please\nnote that the RapidJSON binary is licensed under the MIT License.\nIf you have downloaded a copy of the RapidJSON source code from Tencent,\nplease note that RapidJSON source code is licensed under the MIT License,\nexcept for the third-party components listed below which are subject to\ndifferent license terms.  Your integration of RapidJSON into your own\nprojects may require compliance with the MIT License, as well as the other\nlicenses applicable to the third-party components included within RapidJSON.\nTo avoid the problematic JSON license in your own projects, it's sufficient\nto exclude the bin/jsonchecker/ directory, as it's the only code under the\nJSON license.\nA copy of the MIT License is included in this file.\n\nOther dependencies and licenses:\n\nOpen Source Software Licensed Under the BSD License:\n--------------------------------------------------------------------\n\nThe msinttypes r29\nCopyright (c) 2006-2013 Alexander Chemeris\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this\nlist of conditions and the following disclaimer.\n* Redistributions in binary form must reproduce the above copyright notice,\nthis list of conditions and the following disclaimer in the documentation\nand/or other materials provided with the distribution.\n* Neither the name of  copyright holder nor the names of its contributors may\nbe used to endorse or promote products derived from this software without\nspecific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY\nEXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nOpen Source Software Licensed Under the JSON License:\n--------------------------------------------------------------------\n\njson.org\nCopyright (c) 2002 JSON.org\nAll Rights Reserved.\n\nJSON_checker\nCopyright (c) 2002 JSON.org\nAll Rights Reserved.\n\n\nTerms of the JSON License:\n---------------------------------------------------\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nThe Software shall be used for Good, not Evil.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n\nTerms of the MIT License:\n--------------------------------------------------------------------\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\nWritten Offer for Source Code\n\n   For any software that you receive from Oracle in binary form which is\n   licensed under an open source license that gives you the right to\n   receive the source code for that binary, you can obtain a copy of the\n   applicable source code by visiting\n   http://www.oracle.com/goto/opensourcecode. If the source code for the\n   binary was not provided to you with the binary, you can also receive a\n   copy of the source code on physical media by submitting a written\n   request to the address listed below or by sending an email to Oracle\n   using the following link:\n   http://www.oracle.com/goto/opensourcecode/request.\n  Oracle America, Inc.\n  Attn: Senior Vice President\n  Development and Engineering Legal\n  500 Oracle Parkway, 10th Floor\n  Redwood Shores, CA 94065\n\n   Your request should include:\n\n     * The name of the binary for which you are requesting the source code\n\n     * The name and version number of the Oracle product containing the\n       binary\n\n     * The date you received the Oracle product\n\n     * Your name\n\n     * Your company name (if applicable)\n\n     * Your return mailing address and email, and\n\n     * A telephone number in the event we need to reach you.\n\n   We may charge you a fee to cover the cost of physical media and\n   processing.\n\n   Your request must be sent\n    a. within three (3) years of the date you received the Oracle product\n       that included the binary that is the subject of your request, or\n    b. in the case of code licensed under the GPL v3 for as long as Oracle\n       offers spare parts or customer support for that product model.\n"
  },
  {
    "path": "README.txt",
    "content": "This repository is frozen\n=========================\n\nNewer versions of MySQL Router 8.0 can be found in the MySQL Server repository:\n\n* https://github.com/mysql/mysql-server/tree/8.0/router\n\n\n\n\nMySQL Router 8.0\n================\n\nThis is a release of MySQL Router.\n\nFor the avoidance of doubt, this particular copy of the software\nis released under the version 2 of the GNU General Public License.\nMySQL Router is brought to you by Oracle.\n\nCopyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\nDocumentation\n-------------\n\nFor further information about MySQL or additional documentation, see:\n\n* http://www.mysql.com\n* http://dev.mysql.com/doc/mysql-router/en/\n\nYou can browse the MySQL Router Reference Manual online or download it\nin any of several formats at the URL given earlier in this file.\nSource distributions include a local copy of the manual in the\nDocs directory.\n\nDeveloper documentation can be build when Doxygen 1.8.9 or greater\nhas been installed:\n\n    shell> cd build\n    shell> cmake ..\n    shell> make doc\n\nYou can then open the folder `doc/html/index.html` in your browser.\n\n\nCoverage information\n--------------------\n\nTo build so that coverage information is generated:\n\n    cmake <path-to-source> -DENABLE_COVERAGE=1\n\nTo get coverage information, just run the program or the unit tests\n(do not forget to enable the unit tests if you want to run them). Once\nyou have collected coverage information, you can generate an HTML\nreport in `<build-dir>/coverage/html` using:\n\n    make coverage-html\n\nThere are three variables to control where the information is\ncollected and where the reports are written:\n\n- `GCOV_BASE_DIR` is a cache variable with the full path to a base\n  directory for the coverage information.\n\n  It defaults to `${CMAKE_BUILD_DIR}/coverage`.\n\n- `GCOV_INFO_FILE` is a cache varible with the full path to the info\n  file for the collected coverage information.\n\n  It defaults to `${GCOV_BASE_DIR}/coverage.info`.\n\n- `GCOV_XML_FILE` is a cache varible with the full path to the XML\n  file for the collected coverage information.\n\n  It defaults to `${GCOV_BASE_DIR}/coverage.xml`.\n\n- `GCOV_HTML_DIR` is a cache variable with the full path to the\n  directory where the HTML coverage report will be generated.\n\n  It defaults to `${GCOV_BASE_DIR}/html`.\n\n\nLicense\n-------\n\nLicense information can be found in the License.txt file.\n\nThis distribution may include materials developed by third\nparties. For license and attribution notices for these\nmaterials, please refer to the documentation that accompanies\nthis distribution (see the \"Licenses for Third-Party Components\"\nappendix) or view the online documentation at\n<http://dev.mysql.com/doc/>.\n\nGPLv2 Disclaimer\nFor the avoidance of doubt, except that if any license choice\nother than GPL or LGPL is available it will apply instead,\nOracle elects to use only the General Public License version 2\n(GPLv2) at this time for any software where a choice of GPL\nlicense versions is made available with the language indicating\nthat GPLv2 or any later version may be used, or where a choice\nof which version of the GPL is applied is otherwise unspecified.\n\nLicenses for Third-Party Components\n-----------------------------------\n\n### GMock and GTest\n\nCopyright 2008, Google Inc.\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n    * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n    * Neither the name of Google Inc. nor the names of its\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n### Protobuf\n\nThis license applies to all parts of Protocol Buffers except the following:\n\n  - Atomicops support for generic gcc, located in\n    src/google/protobuf/stubs/atomicops_internals_generic_gcc.h.\n    This file is copyrighted by Red Hat Inc.\n\n  - Atomicops support for AIX/POWER, located in\n    src/google/protobuf/stubs/atomicops_internals_power.h.\n    This file is copyrighted by Bloomberg Finance LP.\n\nCopyright 2014, Google Inc.  All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n    * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n    * Neither the name of Google Inc. nor the names of its\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nCode generated by the Protocol Buffer compiler is owned by the owner\nof the input file used when generating it.  This code is not\nstandalone and requires a support library to be linked with it.  This\nsupport library is itself covered by the above license.\n\n### RapidJSON\n\nCopyright (C) 2011 Milo Yip\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "cmake/Coverage.cmake",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\noption(ENABLE_COVERAGE \"Enable code coverage support\")\n\nset(GCOV_BASE_DIR ${PROJECT_BINARY_DIR}/coverage CACHE PATH\n  \"GCov coverage base directory\")\nset(GCOV_HTML_DIR ${GCOV_BASE_DIR}/html CACHE PATH\n  \"GCov HTML report output directory\")\nset(GCOV_INFO_FILE ${GCOV_BASE_DIR}/coverage.info CACHE FILEPATH\n  \"GCov information file name\")\nset(GCOV_XML_FILE ${GCOV_BASE_DIR}/coverage.xml CACHE FILEPATH\n  \"GCov XML report file name\")\n\nset(LCOV_FLAGS -b ${PROJECT_BINARY_DIR} -d ${PROJECT_SOURCE_DIR} -q)\nset(GCOVR_FLAGS -r ${PROJECT_SOURCE_DIR})\n\ninclude(TextUtils)\n\nif(ENABLE_COVERAGE)\n  if(CMAKE_COMPILER_IS_GNUCXX)\n    find_program(GCOV gcov)\n    find_program(LCOV lcov)\n    find_program(GENHTML genhtml)\n    if(NOT (LCOV AND GCOV AND GENHTML))\n      set(_programs)\n      if(NOT LCOV)\n        list(APPEND _programs \"'lcov'\")\n      endif()\n      if(NOT GCOV)\n        list(APPEND _programs \"'gcov'\")\n      endif()\n      if(NOT GENHTML)\n        list(APPEND _programs \"'genhtml'\")\n      endif()\n      oxford_comma(_text ${_programs})\n      message(FATAL_ERROR \"Could not find ${_text}, please install.\")\n    endif()\n    add_definitions(-fprofile-arcs -ftest-coverage)\n    link_libraries(gcov)\n\n    message(STATUS \"Building with coverage information\")\n    message(STATUS \"Target coverage-clear added to clear coverage information\")\n    message(STATUS \"Target coverage-html added to generate HTML report\")\n    add_custom_target(coverage-clear\n      COMMAND ${LCOV} ${LCOV_FLAGS} -z\n      COMMENT \"Clearing coverage information\")\n    add_custom_target(coverage-info\n      COMMAND ${CMAKE_COMMAND} -E make_directory ${GCOV_BASE_DIR}\n      COMMAND ${LCOV} ${LCOV_FLAGS} -o ${GCOV_INFO_FILE} -c\n      COMMAND ${LCOV} ${LCOV_FLAGS} -o ${GCOV_INFO_FILE} -r ${GCOV_INFO_FILE}\n          '/usr/include/*' 'ext/*' '*/tests/*' '*/generated/*'\n      COMMENT \"Generating coverage info file ${GCOV_INFO_FILE}\")\n    add_custom_target(coverage-html\n      DEPENDS coverage-info\n      COMMAND ${CMAKE_COMMAND} -E make_directory ${GCOV_HTML_DIR}\n      COMMAND ${GENHTML} -o ${GCOV_HTML_DIR} ${GCOV_INFO_FILE}\n      COMMENT \"Generating HTML report on coverage in ${GCOV_HTML_DIR}\")\n\n    find_program(GCOVR gcovr)\n    if(GCOVR)\n      add_custom_target(coverage-xml\n        COMMAND ${CMAKE_COMMAND} -E make_directory ${GCOV_BASE_DIR}\n        COMMAND ${GCOVR} ${GCOVR_FLAGS} -o ${GCOV_XML_FILE} --xml\n            -e '/usr/include/.*' -e '.*/tests/.*' -e 'ext/.*' -e '.*/generated/.*'\n            ${PROJECT_BINARY_DIR})\n       message(STATUS \"Target coverage-xml added to generate XML report\")\n    else()\n      message(STATUS \"Target coverage-xml not built - gcovr not found\")\n    endif()\n  else()\n    message(FATAL_ERROR \"Coverage not supported for ${CMAKE_CXX_COMPILER}\")\n  endif()\nendif()\n"
  },
  {
    "path": "cmake/FindGMock.cmake",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n# Find the MySQL Client Libraries and related development files\n#\n#   GMOCK_FOUND           - TRUE if GMock was found\n#   GMOCK_INCLUDE_DIRS    - path which contains gmock.h\n#   GMOCK_LIBRARIES       - libgmock\n#   GMOCK_BOTH_LIBRARIES  - both libgmock and libgmock-main\n#   GMOCK_MAIN_LIBRARIES  - libgmock-main\n\nset(GMOCK_FOUND FALSE)\n\n# Can not use IS_ABSOLUTE as paths with ~ (home directory) are not starting with\nget_filename_component(GMOCK_ROOT ${GMOCK_ROOT} ABSOLUTE)\n\nfind_library(gmock_lib NAMES gmock PATHS ${GMOCK_ROOT})\nfind_path(gmock_inc_dir NAMES gmock/gmock.h PATHS ${GMOCK_ROOT}/include)\n# File containing version\nfind_path(gmock_configure NAMES configure PATHS ${GMOCK_ROOT})\n\nif(gmock_lib AND gmock_inc_dir AND gmock_configure)\n\n  # Not the greatest place for getting the version, but best we got\n  file(STRINGS \"${gmock_configure}/configure\"\n    version_line\n    REGEX \"^PACKAGE_VERSION='.*'\"\n  )\n  string(REGEX MATCH \"[0-9]+\\\\.[0-9]+\\\\.[0-9]+\" version_str ${version_line})\n  string(REPLACE \".\" \";\" version_list ${version_str})\n  list(GET version_list 0 GMOCK_VERSION_MAJOR)\n  list(GET version_list 1 GMOCK_VERSION_MINOR)\n  list(GET version_list 2 GMOCK_VERSION_PATCH)\n  set(GMOCK_VERSION \"${GMOCK_VERSION_MAJOR}.${GMOCK_VERSION_MINOR}.${GMOCK_VERSION_PATCH}\")\n\n  if(GMock_FIND_VERSION)\n    if(GMock_FIND_VERSION_EXACT AND (NOT GMOCK_VERSION VERSION_EQUAL GMock_FIND_VERSION))\n        message(FATAL_ERROR \"Exact GMock v${GMock_FIND_VERSION} is required; found v${GMOCK_VERSION}\")\n    elseif(GMOCK_VERSION VERSION_LESS GMock_FIND_VERSION)\n      message(FATAL_ERROR \"GMock v${GMock_FIND_VERSION} or later is required; found v${GMOCK_VERSION}\")\n    endif()\n  endif()\n\n  set(GMOCK_FOUND TRUE)\n  set(GMOCK_INCLUDE_DIRS ${gmock_inc_dir})\n  set(GMOCK_LIBRARIES ${gmock_lib})\n  find_library(GMOCK_MAIN_LIBRARIES NAMES gmock_main HINTS ${ENV_GMOCK_ROOT} ${GMOCK_ROOT})\n  set(GMOCK_BOTH_LIBRARIES ${GMOCK_MAIN_LIBRARIES} ${GMOCK_LIBRARIES})\n  message(STATUS \"Found GMock: ${gmock_lib}\")\nendif()\n\nif(GMock_FIND_REQUIRED AND NOT GMOCK_FOUND)\n  message(FATAL_ERROR \"Google C++ Mocking Framework not found under '${GMOCK_ROOT}'\")\nendif()\n"
  },
  {
    "path": "cmake/FindLibEvent2.cmake",
    "content": "# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nIF(NOT WITH_LIBEVENT)\n  SET(WITH_LIBEVENT system)\nENDIF()\n\nIF(WITH_LIBEVENT STREQUAL \"system\" OR WITH_LIBEVENT STREQUAL \"yes\")\n  IF(NOT WIN32)\n    SET(LIBEVENT2_INCLUDE_PATH /usr/local/include /opt/local/include)\n    SET(LIBEVENT2_LIB_PATHS /usr/local/lib /opt/local/lib)\n  ENDIF()\n\n  # use default paths\n  SET(HOW_TO_FIND)\nELSEIF(WITH_LIBEVENT STREQUAL \"bundled\")\n  MESSAGE(FATAL_ERROR \"bundled libevent isn't support\")\nELSE()\n  # make the users path for libevent absolute\n  GET_FILENAME_COMPONENT(LIBEVENT_ABS_DIR \"${WITH_LIBEVENT}\" ABSOLUTE)\n  SET(LIBEVENT2_INCLUDE_PATH ${LIBEVENT_ABS_DIR}/include)\n  SET(LIBEVENT2_LIB_PATHS ${LIBEVENT_ABS_DIR}/lib)\n\n  # if path specified, use that path only\n  SET(HOW_TO_FIND NO_DEFAULT_PATH)\nENDIF()\n\nFIND_PATH(LIBEVENT2_INCLUDE_DIR event2/event.h PATHS ${LIBEVENT2_INCLUDE_PATH} ${HOW_TO_FIND})\nIF(WIN32)\n  ## libevent-2.0.22 on windows is only 'event.lib' and 'event.dll'\n  FIND_LIBRARY(LIBEVENT2_CORE NAMES event PATHS ${LIBEVENT2_LIB_PATHS} ${HOW_TO_FIND})\n  SET(LIBEVENT2_EXTRA)\nELSE()\n  FIND_LIBRARY(LIBEVENT2_CORE NAMES event_core PATHS ${LIBEVENT2_LIB_PATHS} ${HOW_TO_FIND})\n  FIND_LIBRARY(LIBEVENT2_EXTRA NAMES event_extra PATHS ${LIBEVENT2_LIB_PATHS} ${HOW_TO_FIND})\nENDIF()\n\nIF (LIBEVENT2_INCLUDE_DIR AND LIBEVENT2_CORE)\n  SET(LibEvent2_FOUND TRUE)\nELSE()\n  SET(LibEvent2_FOUND FALSE)\nENDIF()\n\nIF(LibEvent2_FIND_VERSION)\n  IF(LibEvent2_FIND_VERSION_EXACT)\n    SET(LIBEVENT2_VERSION_REQUEST_STR \"requested == ${LibEvent2_FIND_VERSION}\")\n  ELSE()\n    SET(LIBEVENT2_VERSION_REQUEST_STR \"requested >= ${LibEvent2_FIND_VERSION}\")\n  ENDIF()\nELSE()\n  SET(LIBEVENT2_VERSION_REQUEST_STR \"requested any\")\nENDIF()\n\nIF (LibEvent2_FOUND)\n  # extract version number from event-config.h\n  #\n  # libevent-2.0 has _EVENT_VERSION\n  # libevent-2.1 has EVENT__VERSION\n  FILE(WRITE ${PROJECT_BINARY_DIR}/check-libevent-header-version.c\n    \"#include <event2/event.h>\n    #include <stdio.h>\n    int main() {\n    puts(LIBEVENT_VERSION);\n    return 0;\n    };\n    \")\n  TRY_RUN(LIBEVENT_VERSION_RUN_RES LIBEVENT_VERSION_COMPILE_RES\n    ${PROJECT_BINARY_DIR}\n    ${PROJECT_BINARY_DIR}/check-libevent-header-version.c\n    CMAKE_FLAGS \"-DINCLUDE_DIRECTORIES=${LIBEVENT2_INCLUDE_DIR}\"\n    COMPILE_OUTPUT_VARIABLE compile_output\n    RUN_OUTPUT_VARIABLE version_line\n    )\n\n  IF(NOT version_line)\n    ## debug output in case of compile/run failures\n    MESSAGE(STATUS \"compile-result: ${LIBEVENT_VERSION_COMPILE_RES}\")\n    MESSAGE(STATUS \"compile-output: ${compile_output}\")\n    MESSAGE(STATUS \"run-result: ${LIBEVENT_VERSION_RUN_RES}\")\n    MESSAGE(STATUS \"run-output: ${version_line}\")\n    MESSAGE(FATAL_ERROR \"Could NOT find version-line in ${LIBEVENT2_INCLUDE_DIR}/event2/event-config.h\")\n  ENDIF()\n\n  STRING(REGEX MATCH \"[0-9]+\\\\.[0-9]+\\\\.[0-9]+\" version_str ${version_line})\n  STRING(REPLACE \".\" \";\" version_list ${version_str})\n  LIST(GET version_list 0 LIBEVENT2_VERSION_MAJOR)\n  LIST(GET version_list 1 LIBEVENT2_VERSION_MINOR)\n  LIST(GET version_list 2 LIBEVENT2_VERSION_PATCH)\n  SET(LIBEVENT2_VERSION \"${LIBEVENT2_VERSION_MAJOR}.${LIBEVENT2_VERSION_MINOR}.${LIBEVENT2_VERSION_PATCH}\")\n\n  IF(LibEvent2_FIND_VERSION)\n    IF(LibEvent2_FIND_VERSION_EXACT)\n      IF(NOT LIBEVENT2_VERSION VERSION_EQUAL \"${LibEvent2_FIND_VERSION}\")\n        MESSAGE(FATAL_ERROR \"Found libevent 2.x: ${LIBEVENT2_CORE}, version=${LIBEVENT2_VERSION}, but ${LIBEVENT2_VERSION_REQUEST_STR}\")\n      ENDIF()\n    ELSE()\n      IF(LIBEVENT2_VERSION VERSION_LESS \"${LibEvent2_FIND_VERSION}\")\n        MESSAGE(FATAL_ERROR \"Found libevent 2.x: ${LIBEVENT2_CORE}, version=${LIBEVENT2_VERSION}, but ${LIBEVENT2_VERSION_REQUEST_STR}\")\n      ENDIF()\n    ENDIF()\n  ENDIF()\n\n  # we want 2.x and higher\n\n  IF(NOT LibEvent2_FIND_QUIETLY)\n    MESSAGE(STATUS \"Found libevent 2.x: ${LIBEVENT2_CORE}, version=${LIBEVENT2_VERSION} (${LIBEVENT2_VERSION_REQUEST_STR})\")\n  ENDIF()\nELSE()\n  IF(LibEvent2_FIND_REQUIRED)\n    MESSAGE(FATAL_ERROR \"Could NOT find libevent 2.x libs in ${LIBEVENT2_LIB_PATHS}, headers in ${LIBEVENT2_INCLUDE_PATH}. (${LIBEVENT2_VERSION_REQUEST_STR})\")\n  ENDIF()\nENDIF()\n\n# don't expose them in the cmake UI\nMARK_AS_ADVANCED(\n  LIBEVENT2_INCLUDE_DIR\n  LIBEVENT2_CORE\n  LIBEVENT2_EXTRA\n  LIBEVENT2_VERSION\n)\n"
  },
  {
    "path": "cmake/FindMySQL.cmake",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n# Find the MySQL Client Libraries and related development files\n#\n#   MySQL_FOUND           - TRUE if MySQL was found\n#   MySQL_INCLUDE_DIRS    - path which contains mysql.h\n#   MySQL_LIBRARIES       - libraries provided by the MySQL installation\n#   MySQL_VERSION         - version of the MySQL Client Libraries\n\n# In Windows we are linking against the .dll\nif(WIN32)\n  set(MySQL_CLIENT_LIBRARY libmysql)\nelse()\n  set(MySQL_CLIENT_LIBRARY mysqlclient)\nendif()\n\nif(WIN32)\n  if(CMAKE_SIZEOF_VOID_P EQUAL 8)\n    set(PROGRAMFILES_VAR \"PROGRAMW6432\")\n  else()\n    set(PROGRAMFILES_VAR \"PROGRAMFILES\")\n  endif()\n  set(WITH_MYSQL \"$ENV{${PROGRAMFILES_VAR}}/MySQL/MySQL Server*/\" CACHE PATH \"Installation path of MySQL Client Libraries\")\n  if(MYSQL_BUILD)\n    STRING(TOLOWER ${MYSQL_BUILD} MYSQL_BUILD)\n    set(MySQL_LIBRARY_PATHS\n      ${WITH_MYSQL}/lib\n      \"$ENV{${PROGRAMFILES_VAR}}/MySQL/MySQL Server*/lib\"\n    )\n  else()\n    set(MySQL_LIBRARY_PATHS\n      ${WITH_MYSQL}/lib\n      ${WITH_MYSQL}/lib/debug\n      \"$ENV{${PROGRAMFILES_VAR}}/MySQL/MySQL Server*/lib\"\n    )\n  endif()\n\n  set(MySQL_INCLUDE_PATHS\n    ${WITH_MYSQL}/include\n    \"$ENV{${PROGRAMFILES_VAR}}/MySQL/MySQL Server*/include\"\n  )\nelse()\n  set(WITH_MYSQL \"/usr/local/mysql\" CACHE PATH \"Installation path of MySQL Client Libraries\")\n  set(MySQL_LIBRARY_PATHS\n    ${CMAKE_BINARY_DIR}/../mysql-server/lib\n    ${WITH_MYSQL}/lib\n    /usr/local/mysql/lib\n    /usr/local/lib\n    /usr/lib/x86_64-linux-gnu\n    /usr/lib/i386-linux-gnu\n    /usr/lib64\n    /usr/lib\n  )\n  set(MySQL_INCLUDE_PATHS\n    ${CMAKE_BINARY_DIR}/../mysql-server/include\n    ${WITH_MYSQL}/include\n    /usr/local/mysql/include\n    /usr/local/include\n    /usr/include\n  )\nendif()\n\n# test if we are located in the mysql-server-tree\n\nIF(EXISTS \"${CMAKE_SOURCE_DIR}/include/mysql.h\")\n  # bundled build\n  SET(MySQL_CLIENT_LIB libmysql)\n  SET(MySQL_VERSION_HEADER ${CMAKE_BINARY_DIR}/include/mysql_version.h)\n  SET(MySQL_INCLUDES ${CMAKE_SOURCE_DIR}/include)\n  LIST(APPEND MySQL_INCLUDES ${CMAKE_SOURCE_DIR}/libbinlogevents/export)\n  LIST(APPEND MySQL_INCLUDES ${CMAKE_BINARY_DIR}/include)\nELSE()\n  # external mysql-server install\n  find_path(MySQL_INCLUDES mysql.h PATHS ${MySQL_INCLUDE_PATHS}\n            PATH_SUFFIXES mysql NO_DEFAULT_PATH)\n  if(WITH_STATIC AND NOT WIN32)\n    find_library(MySQL_CLIENT_LIB NAMES lib${MySQL_CLIENT_LIBRARY}.a\n                 PATHS ${MySQL_LIBRARY_PATHS} PATH_SUFFIXES mysql\n                 NO_DEFAULT_PATH)\n  else()\n    find_library(MySQL_CLIENT_LIB NAMES ${MySQL_CLIENT_LIBRARY}\n                 PATHS ${MySQL_LIBRARY_PATHS} PATH_SUFFIXES mysql\n                 NO_DEFAULT_PATH)\n    if(NOT WIN32)\n      find_library(LIBDL NAMES dl)\n    endif()\n  endif()\n  SET(MySQL_VERSION_HEADER ${MySQL_INCLUDES}/mysql_version.h)\nendif()\n\nif(MySQL_INCLUDES AND MySQL_CLIENT_LIB)\n  set(MySQL_FOUND TRUE)\n  set(MySQL_INCLUDE_DIRS ${MySQL_INCLUDES})\n  if(LIBDL)\n    set(MySQL_LIBRARIES ${MySQL_CLIENT_LIB} ${LIBDL})\n  else()\n    set(MySQL_LIBRARIES ${MySQL_CLIENT_LIB})\n  endif()\n  file(STRINGS \"${MySQL_VERSION_HEADER}\"\n    version_line\n    REGEX \"^#define[\\t ]+MYSQL_SERVER_VERSION.*\"\n  )\n  string(REGEX MATCH \"[0-9]+\\\\.[0-9]+\\\\.[0-9]+\" version_str ${version_line})\n  string(REPLACE \".\" \";\" version_list ${version_str})\n  list(GET version_list 0 MySQL_VERSION_MAJOR)\n  list(GET version_list 1 MySQL_VERSION_MINOR)\n  list(GET version_list 2 MySQL_VERSION_PATCH)\n  set(MySQL_VERSION \"${MySQL_VERSION_MAJOR}.${MySQL_VERSION_MINOR}.${MySQL_VERSION_PATCH}\")\n\n  if(MySQL_FIND_VERSION)\n    if(MySQL_FIND_VERSION_EXACT AND (NOT MySQL_VERSION VERSION_EQUAL MySQL_FIND_VERSION))\n      message(FATAL_ERROR \"Exact MySQL v${MySQL_FIND_VERSION} is required; found v${MySQL_VERSION}\")\n    elseif(MySQL_VERSION VERSION_LESS MySQL_FIND_VERSION)\n      message(FATAL_ERROR \"MySQL v${MySQL_FIND_VERSION} or later is required; found v${MySQL_VERSION}\")\n    endif()\n  endif()\n\nelse()\n  set(MySQL_FOUND FALSE)\nendif()\n\nif(MySQL_FOUND)\n  message(STATUS \"Found MySQL Libraries ${MySQL_VERSION}; using ${MySQL_LIBRARIES}\")\nelse()\n  if(MySQL_FIND_REQUIRED)\n    message(FATAL_ERROR \"Could not find MySQL libraries; used ${MySQL_LIBRARY_PATHS}\")\n  endif()\nendif()\n\nmark_as_advanced(MySQL_LIBRARY MySQL_INCLUDE_DIRS)\n"
  },
  {
    "path": "cmake/HarnessTesting.cmake",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nif(NOT CMAKE_CFG_INTDIR STREQUAL \".\")\n  function(CONFIGURE_HARNESS_TEST_FILE SOURCE DESTINATION)\n    set(HARNESS_PLUGIN_OUTPUT_DIRECTORY_orig ${HARNESS_PLUGIN_OUTPUT_DIRECTORY})\n    set(OUT_DIR ${PROJECT_BINARY_DIR}/tests/harness/${config_})\n    foreach(config_ ${CMAKE_CONFIGURATION_TYPES})\n      string(TOUPPER ${config_} config__)\n      set(HARNESS_PLUGIN_OUTPUT_DIRECTORY ${HARNESS_PLUGIN_OUTPUT_DIRECTORY_${config__}})\n      configure_file(${SOURCE} ${OUT_DIR}/${config_}/${DESTINATION})\n    endforeach()\n    set(HARNESS_PLUGIN_OUTPUT_DIRECTORY ${HARNESS_PLUGIN_OUTPUT_DIRECTORY_orig})\n  endfunction()\n\n  function(CREATE_HARNESS_TEST_DIRECTORY_POST_BUILD TARGET DIRECTORY_NAME)\n    set(OUT_DIR ${PROJECT_BINARY_DIR}/tests/harness/)\n    foreach(config_ ${CMAKE_CONFIGURATION_TYPES})\n      add_custom_command(TARGET ${TARGET} POST_BUILD\n        COMMAND ${CMAKE_COMMAND} -E make_directory ${OUT_DIR}/${config_}/var/log/${DIRECTORY_NAME})\n    endforeach()\n  endfunction()\nelse()\n  function(CONFIGURE_HARNESS_TEST_FILE SOURCE DESTINATION)\n    set(OUT_DIR \"${PROJECT_BINARY_DIR}/tests/harness\")\n    configure_file(${SOURCE} \"${OUT_DIR}/${DESTINATION}\")\n  endfunction()\n\n  function(CREATE_HARNESS_TEST_DIRECTORY_POST_BUILD TARGET DIRECTORY_NAME)\n    set(OUT_DIR \"${PROJECT_BINARY_DIR}/tests/harness\")\n    add_custom_command(TARGET ${TARGET} POST_BUILD\n      COMMAND ${CMAKE_COMMAND} -E make_directory \"${OUT_DIR}/var/log/${DIRECTORY_NAME}\")\n  endfunction()\nendif()\n"
  },
  {
    "path": "cmake/Plugin.cmake",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n# add_harness_plugin - Add a new plugin target and set install\n#                      location\n#\n# add_harness_plugin(name [NO_INSTALL]\n#                    LOG_DOMAIN domain\n#                    SOURCES file1 ...\n#                    INTERFACE directory\n#                    DESTINATION_SUFFIX string\n#                    REQUIRES plugin ...)\n#\n# The add_harness_plugin command will set up a new plugin target and\n# also set the install location of the target correctly.\n#\n# Plugins that are normally put under the \"lib\" directory of the build\n# root, but see the caveat in the next paragraph.\n#\n# If NO_INSTALL is provided, it will not be installed, which is useful\n# if the plugin is only for testing purposes. These plugins are also\n# left in their default location and not moved to the \"lib\"\n# directory. If you want to move the plugin to some specific\n# directory, you have to set the target property\n# LIBRARY_OUTPUT_DIRECTORY yourself.\n#\n# If LOG_DOMAIN is given, it will be used as the log domain for the\n# plugin. If no LOG_DOMAIN is given, the log domain will be the name\n# of the plugin.\n#\n# If DESTINATION_SUFFIX is provided, it will be appended to the\n# destination for install commands. DESTINATION_SUFFIX is optional and\n# default to ${HARNESS_NAME}.\n#\n# Files provided after the SOURCES keyword are the sources to build\n# the plugin from, while the files in the directory after INTERFACE\n# will be installed alongside the header files for the harness.\n#\n# For plugins, it is necessary to set the RPATH so that the plugin can\n# find other plugins when being loaded. This, unfortunately, means\n# that the plugin path need to be set at compile time and cannot be\n# changed after that.\n\nfunction(add_harness_plugin NAME)\n  set(_options NO_INSTALL)\n  set(_single_value LOG_DOMAIN INTERFACE DESTINATION_SUFFIX OUTPUT_NAME)\n  set(_multi_value SOURCES REQUIRES)\n  cmake_parse_arguments(_option\n    \"${_options}\" \"${_single_value}\" \"${_multi_value}\" ${ARGN})\n\n  if(_option_UNPARSED_ARGUMENTS)\n    message(AUTHOR_WARNING\n      \"Unrecognized arguments: ${_option_UNPARSED_ARGUMENTS}\")\n  endif()\n\n  # Set default values\n  if(NOT _option_DESTINATION_SUFFIX)\n    set(_option_DESTINATION_SUFFIX ${HARNESS_NAME})\n  endif()\n\n  # Set the log domain to the name of the plugin unless an explicit\n  # log domain was given.\n  if(NOT _option_LOG_DOMAIN)\n    set(_option_LOG_DOMAIN \"\\\"${NAME}\\\"\")\n  endif()\n\n  # Add the library and ensure that the name is good for the plugin\n  # system (no \"lib\" before). We are using SHARED libraries since we\n  # intend to link against it, which is something that MODULE does not\n  # allow. On OSX, this means that the suffix for the library becomes\n  # .dylib, which we do not want, so we reset it here.\n  add_library(${NAME} SHARED ${_option_SOURCES})\n  if(_option_OUTPUT_NAME)\n    set_target_properties(${NAME}\n      PROPERTIES OUTPUT_NAME ${_option_OUTPUT_NAME})\n  endif()\n  target_compile_definitions(${NAME} PRIVATE\n    MYSQL_ROUTER_LOG_DOMAIN=${_option_LOG_DOMAIN})\n  if(NOT WIN32)\n    set_target_properties(${NAME} PROPERTIES\n      PREFIX \"\"\n      SUFFIX \".so\")\n  endif()\n\n  # Declare the interface directory for this plugin, if present. It\n  # will be used both when compiling the plugin as well as as for any\n  # dependent targets.\n  if(_option_INTERFACE)\n    target_include_directories(${NAME}\n      PUBLIC ${_option_INTERFACE})\n    execute_process(\n      COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/${_option_INTERFACE} ${MySQLRouter_BINARY_DIR}/${INSTALL_INCLUDE_DIR})\n  endif()\n\n  # Add a dependencies on interfaces for other plugins this plugin\n  # requires.\n  target_link_libraries(${NAME}\n    PUBLIC harness-library\n    ${_option_REQUIRES})\n  # Need to be able to link plugins with each other\n  if(CMAKE_SYSTEM_NAME STREQUAL \"Darwin\")\n    set_target_properties(${NAME} PROPERTIES\n        LINK_FLAGS \"-undefined dynamic_lookup\")\n  endif()\n\n  # set library output (and runtime) directories\n  if(NOT CMAKE_CFG_INTDIR STREQUAL \".\")\n    foreach(config ${CMAKE_CONFIGURATION_TYPES})\n      string(TOUPPER ${config} config)\n      set_target_properties(${NAME} PROPERTIES\n        # [SEARCH TAGS] RUNTIME_OUTPUT_DIRECTORY, LIBRARY_OUTPUT_DIRECTORY\n        RUNTIME_OUTPUT_DIRECTORY_${config} ${HARNESS_PLUGIN_OUTPUT_DIRECTORY_${config}}\n        LIBRARY_OUTPUT_DIRECTORY_${config} ${HARNESS_PLUGIN_OUTPUT_DIRECTORY_${config}})\n    endforeach()\n  else()\n    set_target_properties(${NAME} PROPERTIES\n      LIBRARY_OUTPUT_DIRECTORY ${HARNESS_PLUGIN_OUTPUT_DIRECTORY}\n      RUNTIME_OUTPUT_DIRECTORY ${HARNESS_PLUGIN_OUTPUT_DIRECTORY}\n      )\n  endif()\n\n  # Add install rules to install the interface header files and the\n  # plugin correctly.\n  if(NOT _option_NO_INSTALL AND HARNESS_INSTALL_PLUGINS)\n    if(WIN32)\n      install(TARGETS ${NAME}\n        RUNTIME DESTINATION ${HARNESS_INSTALL_LIBRARY_DIR})\n      install(FILES $<TARGET_PDB_FILE:${NAME}>\n            DESTINATION ${HARNESS_INSTALL_LIBRARY_DIR})\n    else()\n      install(TARGETS ${NAME}\n        LIBRARY DESTINATION ${HARNESS_INSTALL_LIBRARY_DIR}/${_option_DESTINATION_SUFFIX})\n    endif()\n    if(_option_INTERFACE)\n      file(GLOB interface_files ${_option_INTERFACE}/*.h)\n      install(FILES ${interface_files}\n        DESTINATION ${HARNESS_INSTALL_INCLUDE_PREFIX}/${_option_DESTINATION_SUFFIX})\n    endif()\n  endif()\nendfunction(add_harness_plugin)\n"
  },
  {
    "path": "cmake/TextUtils.cmake",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nfunction(oxford_comma _var)\n  if(ARGC EQUAL 2)\n    set(${_var} \"${ARGV1}\" PARENT_SCOPE)\n  elseif(ARGC EQUAL 3)\n    set(${_var} \"${ARGV1} and ${ARGV2}\" PARENT_SCOPE)\n  else()\n    set(_count 3)\n    set(_glue)\n    set(_result)\n    foreach(_arg ${ARGN})\n      set(_result \"${_result}${_glue}${_arg}\")\n      if(_count LESS ARGC)\n        set(_glue \", \")\n      else()\n        set(_glue \", and \")\n      endif()\n      math(EXPR _count \"${_count}+1\")\n    endforeach()\n    set(${_var} \"${_result}\" PARENT_SCOPE)\n  endif()\nendfunction()\n"
  },
  {
    "path": "cmake/cmake_parse_arguments.cmake",
    "content": "\n# Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved.\n# \n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n# \n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n# \n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n# \n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n# Handy macro to parse macro arguments\nMACRO(MYSQL_PARSE_ARGUMENTS prefix arg_names option_names)\n  SET(DEFAULT_ARGS)\n  FOREACH(arg_name ${arg_names})    \n    SET(${prefix}_${arg_name})\n  ENDFOREACH(arg_name)\n  FOREACH(option ${option_names})\n    SET(${prefix}_${option} FALSE)\n  ENDFOREACH(option)\n\n  SET(current_arg_name DEFAULT_ARGS)\n  SET(current_arg_list)\n  FOREACH(arg ${ARGN})    \n    SET(larg_names ${arg_names})    \n    LIST(FIND larg_names \"${arg}\" is_arg_name)\n    IF (is_arg_name GREATER -1)\n      SET(${prefix}_${current_arg_name} ${current_arg_list})\n      SET(current_arg_name ${arg})\n      SET(current_arg_list)\n    ELSE (is_arg_name GREATER -1)\n      SET(loption_names ${option_names})    \n      LIST(FIND loption_names \"${arg}\" is_option)            \n      IF (is_option GREATER -1)\n      SET(${prefix}_${arg} TRUE)\n      ELSE (is_option GREATER -1)\n      SET(current_arg_list ${current_arg_list} ${arg})\n      ENDIF (is_option GREATER -1)\n    ENDIF (is_arg_name GREATER -1)\n  ENDFOREACH(arg)\n  SET(${prefix}_${current_arg_name} ${current_arg_list})\nENDMACRO()"
  },
  {
    "path": "cmake/compile_flags.cmake",
    "content": "# Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.\n# \n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n\n## ADD_COMPILE_FLAGS(<source files> COMPILE_FLAGS <flags>)\nMACRO(ADD_COMPILE_FLAGS)\n  SET(FILES \"\")\n  SET(FLAGS \"\")\n  SET(COMPILE_FLAGS_SEEN)\n  FOREACH(ARG ${ARGV})\n    IF(ARG STREQUAL \"COMPILE_FLAGS\")\n      SET(COMPILE_FLAGS_SEEN 1)\n    ELSEIF(COMPILE_FLAGS_SEEN)\n      LIST(APPEND FLAGS ${ARG})\n    ELSE()\n      LIST(APPEND FILES ${ARG})\n    ENDIF()\n  ENDFOREACH()\n  FOREACH(FILE ${FILES})\n    FOREACH(FLAG ${FLAGS})\n      GET_SOURCE_FILE_PROPERTY(PROP ${FILE} COMPILE_FLAGS)\n      IF(NOT PROP)\n        SET(PROP ${FLAG})\n      ELSE()\n        SET(PROP \"${PROP} ${FLAG}\")\n      ENDIF()\n      SET_SOURCE_FILES_PROPERTIES(\n        ${FILE} PROPERTIES COMPILE_FLAGS \"${PROP}\"\n        )\n    ENDFOREACH()\n  ENDFOREACH()\nENDMACRO()\n"
  },
  {
    "path": "cmake/compiler.cmake",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\ninclude(CheckCXXCompilerFlag)\n\n# Check for C++11 support\nfunction(CHECK_CXX11)\n  check_cxx_compiler_flag(\"-std=c++11\" support_11)\n\n  if(support_11)\n    set(CXX11_FLAG \"-std=c++11\" PARENT_SCOPE)\n  else()\n    message(FATAL_ERROR \"Compiler ${CMAKE_CXX_COMPILER} does not support C++11 standard\")\n  endif()\n  set(CMAKE_CXX_FLAGS ${CXX11_FLAG} PARENT_SCOPE)\nendfunction()\n\nif(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES \"Clang\")\n  check_cxx11()\n  set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Wconversion -Wshadow\")\n\n  check_cxx_compiler_flag(\"-Wpedantic\" COMPILER_HAS_WARNING_PEDANTIC)\n  if(COMPILER_HAS_WARNING_PEDANTIC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9)\n    # gcc 4.8 doesn't support -Wpedantic -Wno-pedantic to selectively disable\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-error=pedantic\")\n  endif()\n  # bring the options in sync with the server's\n\n  # GCC has this options, clang doesn't\n  check_cxx_compiler_flag(\"-Wformat-security\" COMPILER_HAS_WARNING_FORMAT_SECURITY)\n  if(COMPILER_HAS_WARNING_FORMAT_SECURITY)\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wformat-security\")\n  endif()\n\n  check_cxx_compiler_flag(\"-Wnon-virtual-dtor\" COMPILER_HAS_WARNING_NON_VIRTUAL_DTOR)\n  if(COMPILER_HAS_WARNING_NON_VIRTUAL_DTOR)\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor\")\n  endif()\n\n  # GCC/clang have this option\n  # clang doesn't have its sibling: -Wsuggest-attribute=format\n  check_cxx_compiler_flag(\"-Wmissing-format-attribute\" COMPILER_HAS_WARNING_MISSING_FORMAT_ATTRIBUTE)\n  if(COMPILER_HAS_WARNING_MISSING_FORMAT_ATTRIBUTE)\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wmissing-format-attribute\")\n  endif()\n\n  # GCC/clang have this option\n  #\n  # FIXME: as long as protobuf-3.0.0 and gmock 1.7.0 are used, we need to disable -Wundef as it is\n  # triggered all over the place in the headers. It should actually be enabled.\n  check_cxx_compiler_flag(\"-Wundef\" COMPILER_HAS_WARNING_UNDEF)\n  if(COMPILER_HAS_WARNING_UNDEF)\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-undef -Wno-conversion\")\n  endif()\n\n  # GCC/clang have this option\n  check_cxx_compiler_flag(\"-Wvla\" COMPILER_HAS_WARNING_VLA)\n  if(COMPILER_HAS_WARNING_VLA)\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wvla\")\n  endif()\n\n  set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} ${CXX11_FLAG}\")\n\nelseif(CMAKE_CXX_COMPILER_ID STREQUAL \"MSVC\")\n  # Overview of MSVC versions: http://www.cmake.org/cmake/help/v3.3/variable/MSVC_VERSION.html\n  if(\"${MSVC_VERSION}\" VERSION_LESS 1800)\n    message(FATAL_ERROR \"Need at least ${CMAKE_CXX_COMPILER} 12.0\")\n  endif()\n  # /TP is needed so .cc files are recognoized as C++ source files by MSVC\n  set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} /TP\")\n  add_definitions(-DWIN32_LEAN_AND_MEAN)\nelseif(CMAKE_CXX_COMPILER_ID STREQUAL \"SunPro\")\n  if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13.0)\n    message(FATAL_ERROR \"Compiler ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_VERSION} is too old; need at least SunPro 5.13.0 (aka Oracle Developer Studio 12.4)\")\n  endif()\n  set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -std=c++11\")\nelse()\n  message(FATAL_ERROR \"Compiler ${CMAKE_CXX_COMPILER} is not supported\")\nendif()\n\n"
  },
  {
    "path": "cmake/configure.cmake",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\ninclude(GNUInstallDirs)\n\n# installed executable location (used in config.h)\nif(IS_ABSOLUTE \"${INSTALL_BINDIR}\")\n  set(ROUTER_BINDIR ${INSTALL_BINDIR})\nelse()\n  set(ROUTER_BINDIR ${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR})\nendif()\n\n# Configuration folder (config_folder configuration option)\nif(CMAKE_SYSTEM_NAME STREQUAL \"Windows\")\n  set(_configdir \"ENV{APPDATA}\")\nelse()\n  if(IS_ABSOLUTE ${INSTALL_CONFIGDIR})\n    set(_configdir ${INSTALL_CONFIGDIR})\n  elseif(INSTALL_CONFIGDIR STREQUAL \".\")\n    # Current working directory\n    set(_configdir ${INSTALL_CONFIGDIR})\n  else()\n    set(_configdir ${CMAKE_INSTALL_PREFIX}/${INSTALL_CONFIGDIR})\n  endif()\nendif()\nset(ROUTER_CONFIGDIR ${_configdir} CACHE STRING \"Location of configuration file(s) (config_folder)\")\nunset(_configdir)\n\n# Logging folder (logging_folder configuration option)\nif(CMAKE_SYSTEM_NAME STREQUAL \"Windows\")\n  set(_logdir \"ENV{APPDATA}\\\\\\\\log\")\nelse()\n  # logging folder can be set to empty to log to console\n  if(IS_ABSOLUTE \"${INSTALL_LOGDIR}\")\n    set(_logdir ${INSTALL_LOGDIR})\n  elseif(NOT INSTALL_LOGDIR)\n    set(_logdir \"/var/log/mysqlrouter/\")\n  else()\n    set(_logdir ${CMAKE_INSTALL_PREFIX}/${INSTALL_LOGDIR})\n  endif()\nendif()\nset(ROUTER_LOGDIR ${_logdir} CACHE STRING \"Location of log files; empty is console (logging_folder)\")\nunset(_logdir)\n\n# Runtime folder (runtime_folder configuration option)\nif(CMAKE_SYSTEM_NAME STREQUAL \"Windows\")\n  set(_runtimedir \"ENV{APPDATA}\")\nelse()\n  if(IS_ABSOLUTE \"${INSTALL_RUNTIMEDIR}\")\n    set(_runtimedir ${INSTALL_RUNTIMEDIR})\n  elseif(NOT INSTALL_RUNTIMEDIR)\n    set(_logdir \"/var/run/mysqlrouter/\")\n  else()\n    set(_runtimedir ${CMAKE_INSTALL_PREFIX}/${INSTALL_RUNTIMEDIR})\n  endif()\nendif()\nset(ROUTER_RUNTIMEDIR ${_runtimedir} CACHE STRING \"Location runtime files such as PID file (runtime_folder)\")\nunset(_runtimedir)\n\n# Plugin folder (plugin_folder configuration option)\nif(IS_ABSOLUTE \"${INSTALL_PLUGINDIR}\")\n  set(_plugindir ${INSTALL_PLUGINDIR})\nelse()\n  set(_plugindir ${CMAKE_INSTALL_PREFIX}/${INSTALL_PLUGINDIR})\nendif()\nset(ROUTER_PLUGINDIR ${_plugindir} CACHE STRING \"Location MySQL Router plugins (plugin_folder)\")\nunset(_plugindir)\n\n# Data folder (data_folder configuration option)\nif(CMAKE_SYSTEM_NAME STREQUAL \"Windows\")\n  set(_datadir \"ENV{APPDATA}\\\\\\\\data\")\nelse()\n  if(IS_ABSOLUTE \"${INSTALL_DATADIR}\")\n    set(_datadir ${INSTALL_DATADIR})\n  elseif(NOT INSTALL_DATADIR)\n    set(_datadir \"/var/lib/mysqlrouter/\")\n  else()\n    set(_datadir \"${CMAKE_INSTALL_PREFIX}/${INSTALL_DATADIR}\")\n  endif()\nendif()\nset(ROUTER_DATADIR ${_datadir} CACHE STRING \"Location of data files such as keyring file\")\nunset(_datadir)\n\n\n# Generate the copyright string\nfunction(SET_COPYRIGHT TARGET)\n  string(TIMESTAMP curr_year \"%Y\" UTC)\n  set(start_year \"2015\")\n  set(years \"${start_year},\")\n  if(NOT curr_year STREQUAL ${start_year})\n    set(years \"${start_year}, ${curr_year},\")\n  endif()\n  set(${TARGET} \"Copyright (c) ${years} Oracle and/or its affiliates. All rights reserved.\" PARENT_SCOPE)\nendfunction()\n\nset_copyright(ORACLE_COPYRIGHT)\n\nif(INSTALL_LAYOUT STREQUAL \"STANDALONE\")\n  set(ROUTER_PLUGINDIR \"{origin}/../${INSTALL_PLUGINDIR_STANDALONE}\")\n  set(ROUTER_CONFIGDIR \"{origin}/../${INSTALL_CONFIGDIR_STANDALONE}\")\n  set(ROUTER_RUNTIMEDIR \"{origin}/../${INSTALL_RUNTIMEDIR_STANDALONE}\")\n  set(ROUTER_LOGDIR \"{origin}/../${INSTALL_LOGDIR_STANDALONE}\")\n  set(ROUTER_DATADIR \"{origin}/../${INSTALL_DATADIR_STANDALONE}\")\nendif()\n\n# Default configuration file locations (similar to MySQL Server)\nif(CMAKE_SYSTEM_NAME STREQUAL \"Windows\")\n  set(CONFIG_FILE_LOCATIONS\n      \"${ROUTER_CONFIGDIR}/${MYSQL_ROUTER_INI}\"\n      \"ENV{APPDATA}/${MYSQL_ROUTER_INI}\"\n      )\nelse()\n  set(CONFIG_FILE_LOCATIONS\n      \"${ROUTER_CONFIGDIR}/${MYSQL_ROUTER_INI}\"\n      \"ENV{HOME}/.${MYSQL_ROUTER_INI}\"\n      )\nendif()\nset(CONFIG_FILES ${CONFIG_FILE_LOCATIONS})\n\n# Platform/Compiler checks\nINCLUDE(TestBigEndian)\nTEST_BIG_ENDIAN(WORDS_BIGENDIAN)\n\nINCLUDE(CheckTypeSize)\nCHECK_TYPE_SIZE(\"void *\"    SIZEOF_VOIDP)\nCHECK_TYPE_SIZE(\"char *\"    SIZEOF_CHARP)\nCHECK_TYPE_SIZE(\"long\"      SIZEOF_LONG)\nCHECK_TYPE_SIZE(\"short\"     SIZEOF_SHORT)\nCHECK_TYPE_SIZE(\"int\"       SIZEOF_INT)\nCHECK_TYPE_SIZE(\"long long\" SIZEOF_LONG_LONG)\nCHECK_TYPE_SIZE(\"off_t\"     SIZEOF_OFF_T)\nCHECK_TYPE_SIZE(\"time_t\"    SIZEOF_TIME_T)\n\n# Platform/Compiler checks\nINCLUDE(TestBigEndian)\nTEST_BIG_ENDIAN(WORDS_BIGENDIAN)\n\n# Compiler specific features\nINCLUDE(CheckCSourceCompiles)\nCHECK_C_SOURCE_COMPILES(\"\nvoid test(const char *format, ...) __attribute__((format(printf, 1, 2)));\nint main() {\n  return 0;\n}\" HAVE_ATTRIBUTE_FORMAT)\n\nMACRO(DIRNAME IN OUT)\n  GET_FILENAME_COMPONENT(${OUT} ${IN} PATH)\nENDMACRO()\n\nMACRO(FIND_REAL_LIBRARY SOFTLINK_NAME REALNAME)\n  # We re-distribute libstdc++.so which is symlink.\n  # There is no 'readlink' on solaris, so we use perl to follow the link:\n  SET(PERLSCRIPT\n    \"my $link= $ARGV[0]; use Cwd qw(abs_path); my $file = abs_path($link); print $file;\")\n  EXECUTE_PROCESS(\n    COMMAND perl -e \"${PERLSCRIPT}\" ${SOFTLINK_NAME}\n    RESULT_VARIABLE result\n    OUTPUT_VARIABLE real_library\n    )\n  SET(REALNAME ${real_library})\nENDMACRO()\n\nMACRO(EXTEND_CXX_LINK_FLAGS LIBRARY_PATH)\n  # Using the $ORIGIN token with the -R option to locate the libraries\n  # on a path relative to the executable:\n  SET(CMAKE_CXX_LINK_FLAGS\n    \"${CMAKE_CXX_LINK_FLAGS} -R'\\$ORIGIN/../lib' -R${LIBRARY_PATH}\")\n  MESSAGE(STATUS \"CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS}\")\nENDMACRO()\n\nMACRO(EXTEND_C_LINK_FLAGS LIBRARY_PATH)\n  SET(CMAKE_C_LINK_FLAGS\n    \"${CMAKE_C_LINK_FLAGS} -R'\\$ORIGIN/../lib' -R${LIBRARY_PATH}\")\n  MESSAGE(STATUS \"CMAKE_C_LINK_FLAGS ${CMAKE_C_LINK_FLAGS}\")\n  SET(CMAKE_SHARED_LIBRARY_C_FLAGS\n    \"${CMAKE_SHARED_LIBRARY_C_FLAGS} -R'\\$ORIGIN/../lib' -R${LIBRARY_PATH}\")\nENDMACRO()\n\nIF(CMAKE_SYSTEM_NAME MATCHES \"SunOS\" AND CMAKE_COMPILER_IS_GNUCC)\n  DIRNAME(${CMAKE_CXX_COMPILER} CXX_PATH)\n  SET(LIB_SUFFIX \"lib\")\n  IF(SIZEOF_VOIDP EQUAL 8 AND CMAKE_SYSTEM_PROCESSOR MATCHES \"sparc\")\n    SET(LIB_SUFFIX \"lib/sparcv9\")\n  ENDIF()\n  IF(SIZEOF_VOIDP EQUAL 8 AND CMAKE_SYSTEM_PROCESSOR MATCHES \"i386\")\n    SET(LIB_SUFFIX \"lib/amd64\")\n  ENDIF()\n  FIND_LIBRARY(GPP_LIBRARY_NAME\n    NAMES \"stdc++\"\n    PATHS ${CXX_PATH}/../${LIB_SUFFIX}\n    NO_DEFAULT_PATH\n  )\n  MESSAGE(STATUS \"GPP_LIBRARY_NAME ${GPP_LIBRARY_NAME}\")\n  IF(GPP_LIBRARY_NAME)\n    DIRNAME(${GPP_LIBRARY_NAME} GPP_LIBRARY_PATH)\n    FIND_REAL_LIBRARY(${GPP_LIBRARY_NAME} real_library)\n    MESSAGE(STATUS \"INSTALL ${GPP_LIBRARY_NAME} ${real_library}\")\n    INSTALL(FILES ${GPP_LIBRARY_NAME} ${real_library}\n            DESTINATION ${INSTALL_LIBDIR} COMPONENT SharedLibraries)\n    EXTEND_CXX_LINK_FLAGS(${GPP_LIBRARY_PATH})\n    EXECUTE_PROCESS(\n      COMMAND sh -c \"elfdump ${real_library} | grep SONAME\"\n      RESULT_VARIABLE result\n      OUTPUT_VARIABLE sonameline\n    )\n    IF(NOT result)\n      STRING(REGEX MATCH \"libstdc.*[^\\n]\" soname ${sonameline})\n      MESSAGE(STATUS \"INSTALL ${GPP_LIBRARY_PATH}/${soname}\")\n      INSTALL(FILES \"${GPP_LIBRARY_PATH}/${soname}\"\n              DESTINATION ${INSTALL_LIBDIR} COMPONENT SharedLibraries)\n    ENDIF()\n  ENDIF()\n  FIND_LIBRARY(GCC_LIBRARY_NAME\n    NAMES \"gcc_s\"\n    PATHS ${CXX_PATH}/../${LIB_SUFFIX}\n    NO_DEFAULT_PATH\n  )\n  IF(GCC_LIBRARY_NAME)\n    DIRNAME(${GCC_LIBRARY_NAME} GCC_LIBRARY_PATH)\n    FIND_REAL_LIBRARY(${GCC_LIBRARY_NAME} real_library)\n    MESSAGE(STATUS \"INSTALL ${GCC_LIBRARY_NAME} ${real_library}\")\n    INSTALL(FILES ${GCC_LIBRARY_NAME} ${real_library}\n            DESTINATION ${INSTALL_LIBDIR} COMPONENT SharedLibraries)\n    EXTEND_C_LINK_FLAGS(${GCC_LIBRARY_PATH})\n  ENDIF()\nENDIF()\n\n# check if platform supports prlimit()\ninclude(CMakePushCheckState)\ncmake_push_check_state()\ncmake_reset_check_state()\ninclude(CheckSymbolExists)\nset(CMAKE_REQUIRED_FLAGS -D_GNU_SOURCE)\ncheck_symbol_exists(prlimit sys/resource.h HAVE_PRLIMIT)\ncmake_pop_check_state()\n\nconfigure_file(config.h.in router_config.h @ONLY)\ninclude_directories(${PROJECT_BINARY_DIR})\n"
  },
  {
    "path": "cmake/docs.cmake",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nfind_package(Doxygen)\n\nif (DOXYGEN_FOUND)\n  file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/doc)\n\n  configure_file(doc/doxygen.cfg.in ${PROJECT_BINARY_DIR}/doc/doxygen.cfg @ONLY)\n\n  foreach(f router_footer.html router_header.html router_doxygen.css)\n    file(COPY ${PROJECT_SOURCE_DIR}/doc/${f} DESTINATION ${PROJECT_BINARY_DIR}/doc)\n  endforeach()\n\n  add_custom_target(doc ${DOXYGEN_EXECUTABLE} doc/doxygen.cfg\n    COMMAND pwd\n    WORKING_DIRECTORY ${PROJECT_BINARY_DIR}\n    COMMENT \"Generate MySQL Router developer documentation\"\n    VERBATIM)\nendif()\n"
  },
  {
    "path": "cmake/gmocktest.cmake",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n# CMake module handling Google C++ Mocking & Testing Framework dependency\n\n# We do not add \"REQUIRED\" here so we can handle missing GTest\n# showing a better error message\nfind_package(GMock 1.7.0)\nset(GTEST_ROOT \"${GMOCK_ROOT}/gtest\")\nfind_package(GTest)\n\nif(NOT GTEST_FOUND OR NOT GMOCK_FOUND)\n  message(STATUS \"\")\n  message(STATUS \"GMock/GTest were not found in following folder\")\n  message(STATUS \"  ${GMOCK_ROOT}\")\n  message(STATUS \"\")\n  message(STATUS \"Please make sure that GMock was compiled in the above\")\n  message(STATUS \"mentioned folder as follows:\")\n  message(STATUS \"  shell> cd ${GMOCK_ROOT}\")\n  message(STATUS \"  shell> cmake .\")\n  message(STATUS \"  shell> make\")\n  message(STATUS \"Or set the CMake variable GMOCK_ROOT pointing\")\n  message(STATUS \"to the installation of GMock (which also includes GTest).\")\n  message(STATUS \"\")\n  message(STATUS \"GMock can be downloaded using following URL:\")\n  message(STATUS \"   ${GMOCK_DOWNLOAD_URL}\")\n  message(STATUS \"\")\n\n  message(FATAL_ERROR \"Please fix GMock and GTest installation (see above message)\")\nendif()\n"
  },
  {
    "path": "cmake/install_layout.cmake",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n# Originally part of MySQL Server and Adapted for MySQL Router.\n\n# The purpose of this file is to set the default installation layout.\n#\n# The current choices of installation layout are:\n#\n#  STANDALONE\n#    Build with prefix=/usr/local/mysql, create tarball with install prefix=\".\"\n#    and relative links.  Windows zip uses the same tarball layout but without\n#    the build prefix.\n#\n#  RPM, SLES\n#    Build as per default RPM layout, with prefix=/usr\n#    Note: The layout for ULN RPMs differs, see the \"RPM\" section.\n#\n#  DEB\n#    Build as per default Debian layout, with prefix=/usr\n#    Note: previous layout is now named DEBSRV4\n#\n#  DEBSRV4\n#    Build as per STANDALONE, prefix=/opt/mysql/mysql-router-$major.$minor\n#\n#  SVR4\n#    Solaris package layout suitable for pkg* tools, prefix=/opt/mysql/mysql-router\n#\n#  FREEBSD, GLIBC, OSX, TARGZ\n#    Build with prefix=/usr/local/mysql, create tarball with install prefix=\".\"\n#    and relative links.\n#\n#  WIN\n#     Windows zip : same as tarball layout but without the build prefix\n#\n# To force a directory layout, use -DINSTALL_LAYOUT=<layout>.\n#\n# The default is STANDALONE.\n#\n# Note : At present, RPM and SLES layouts are similar. This is also true\n#        for layouts like FREEBSD, GLIBC, OSX, TARGZ. However, they provide\n#        opportunity to fine-tune deployment for each platform without\n#        affecting all other types of deployment.\n#\n# There is the possibility to further fine-tune installation directories.\n# Several variables can be overwritten:\n#\n# - INSTALL_BINDIR          (directory with client executables and scripts)\n# - INSTALL_SBINDIR         (directory with mysqld)\n# - INSTALL_SCRIPTDIR       (several scripts, rarely used)\n#\n# - INSTALL_LIBDIR          (directory with client end embedded libraries)\n# - INSTALL_PLUGINDIR       (directory for plugins)\n#\n# - INSTALL_INCLUDEDIR      (directory for MySQL headers)\n#\n# - INSTALL_DOCDIR          (documentation)\n# - INSTALL_DOCREADMEDIR    (readme and similar)\n# - INSTALL_MANDIR          (man pages)\n# - INSTALL_INFODIR         (info pages)\n#\n# - INSTALL_SHAREDIR        (location of aclocal/mysql.m4)\n# - INSTALL_MYSQLSHAREDIR   (MySQL character sets and localized error messages)\n# - INSTALL_MYSQLTESTDIR    (mysqlrouter-test)\n# - INSTALL_SQLBENCHDIR     (sql-bench)\n# - INSTALL_SUPPORTFILESDIR (various extra support files)\n#\n# - INSTALL_MYSQLDATADIR    (data directory)\n# - INSTALL_SECURE_FILE_PRIVDIR (--secure-file-priv directory)\n#\n# When changing this page,  _please_ do not forget to update public Wiki\n# http://forge.mysql.com/wiki/CMake#Fine-tuning_installation_paths\n\nIF(NOT INSTALL_LAYOUT)\n  IF(WIN32)\n\tSET(DEFAULT_INSTALL_LAYOUT \"WIN\")\n  ELSE()\n\tSET(DEFAULT_INSTALL_LAYOUT \"DEFAULT\")\n  ENDIF()\nENDIF()\n\nif(NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)\n  SET(DEFAULT_INSTALL_LAYOUT \"STANDALONE\")\nendif()\n\nSET(INSTALL_LAYOUT \"${DEFAULT_INSTALL_LAYOUT}\"\nCACHE STRING \"Installation directory layout. Options are: TARGZ (as in tar.gz installer), WIN (as in zip installer), STANDALONE, RPM, DEB, DEBSRV4, SVR4, FREEBSD, GLIBC, OSX, SLES\")\n\nmessage(STATUS \"Installation layout set to ${DEFAULT_INSTALL_LAYOUT}\")\n\nIF(UNIX)\n  IF(INSTALL_LAYOUT STREQUAL \"RPM\" OR\n     INSTALL_LAYOUT STREQUAL \"SLES\" OR\n     INSTALL_LAYOUT STREQUAL \"DEB\")\n    SET(default_prefix \"/usr\")\n  ELSEIF(INSTALL_LAYOUT STREQUAL \"DEBSVR4\")\n    SET(default_prefix \"/opt/mysql/router-${PROJECT_VERSION}\")\n    # This is required to avoid \"cpack -GDEB\" default of prefix=/usr\n    SET(CPACK_SET_DESTDIR ON)\n  ELSEIF(INSTALL_LAYOUT STREQUAL \"SVR4\")\n    SET(default_prefix \"/opt/mysql/router\")\n  ELSE()\n    SET(default_prefix \"/usr/local\")\n  ENDIF()\n  IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)\n    SET(CMAKE_INSTALL_PREFIX ${default_prefix}\n      CACHE PATH \"install prefix\" FORCE)\n  ENDIF()\n  SET(VALID_INSTALL_LAYOUTS\n      \"RPM\" \"DEB\" \"DEBSVR4\" \"SVR4\" \"FREEBSD\" \"GLIBC\" \"OSX\" \"TARGZ\" \"SLES\" \"STANDALONE\" \"DEFAULT\")\n  LIST(FIND VALID_INSTALL_LAYOUTS \"${INSTALL_LAYOUT}\" ind)\n  IF(ind EQUAL -1)\n    MESSAGE(FATAL_ERROR \"Invalid INSTALL_LAYOUT parameter:${INSTALL_LAYOUT}.\"\n    \" Choose between ${VALID_INSTALL_LAYOUTS}\" )\n  ENDIF()\nENDIF()\n\nIF(WIN32)\n  SET(VALID_INSTALL_LAYOUTS \"TARGZ\" \"STANDALONE\" \"WIN\")\n  LIST(FIND VALID_INSTALL_LAYOUTS \"${INSTALL_LAYOUT}\" ind)\n  IF(ind EQUAL -1)\n    MESSAGE(FATAL_ERROR \"Invalid INSTALL_LAYOUT parameter:${INSTALL_LAYOUT}.\"\n    \" Choose between ${VALID_INSTALL_LAYOUTS}\" )\n  ENDIF()\nENDIF()\n\n#\n# DEFAULT_SECURE_FILE_PRIV_DIR\n#\nIF(INSTALL_LAYOUT STREQUAL \"STANDALONE\" OR INSTALL_LAYOUT STREQUAL \"DEFAULT\" OR\n   INSTALL_LAYOUT STREQUAL \"WIN\")\n  SET(secure_file_priv_path \"\")\nELSEIF(INSTALL_LAYOUT STREQUAL \"RPM\" OR\n       INSTALL_LAYOUT STREQUAL \"SLES\" OR\n       INSTALL_LAYOUT STREQUAL \"SVR4\" OR\n       INSTALL_LAYOUT STREQUAL \"DEB\" OR\n       INSTALL_LAYOUT STREQUAL \"DEBSVR4\")\n  SET(secure_file_priv_path \"/var/lib/mysqlrouter-files\")\nELSE()\n  SET(secure_file_priv_path \"${default_prefix}/mysqlrouter-files\")\nENDIF()\n\n#\n# STANDALONE layout\n#\nSET(INSTALL_BINDIR_STANDALONE           \"bin\")\nSET(INSTALL_SBINDIR_STANDALONE          \"bin\")\nSET(INSTALL_SCRIPTDIR_STANDALONE        \"scripts\")\nSET(INSTALL_LOGDIR_STANDALONE           \"\")\nSET(INSTALL_CONFIGDIR_STANDALONE        \".\")\nSET(INSTALL_RUNTIMEDIR_STANDALONE       \"run\")\nSET(INSTALL_DATADIR_STANDALONE          \"data\")\n#\nSET(INSTALL_LIBDIR_STANDALONE           \"lib\")\nif(WIN32)\n  SET(INSTALL_PLUGINDIR_STANDALONE        \"lib\")\nelse()\n  SET(INSTALL_PLUGINDIR_STANDALONE        \"lib/mysqlrouter\")\nendif()\n#\nSET(INSTALL_INCLUDEDIR_STANDALONE       \"include\")\n#\nSET(INSTALL_DOCDIR_STANDALONE           \"share/doc/mysqlrouter\")\nSET(INSTALL_DOCREADMEDIR_STANDALONE     \".\")\nSET(INSTALL_MANDIR_STANDALONE           \"man\")\nSET(INSTALL_INFODIR_STANDALONE          \"share/doc/mysqlrouter\")\n#\nSET(INSTALL_SHAREDIR_STANDALONE         \"share\")\nSET(INSTALL_MYSQLSHAREDIR_STANDALONE    \"share\")\nSET(INSTALL_MYSQLTESTDIR_STANDALONE     \"share/mysqlrouter/test\")\nSET(INSTALL_SQLBENCHDIR_STANDALONE      \".\")\nSET(INSTALL_SUPPORTFILESDIR_STANDALONE  \"share/mysqlrouter/support-files\")\n#\nSET(INSTALL_MYSQLDATADIR_STANDALONE     \"data\")\nSET(INSTALL_PLUGINTESTDIR_STANDALONE    ${plugin_tests})\nSET(INSTALL_SECURE_FILE_PRIVDIR_STANDALONE ${secure_file_priv_path})\n\n#\n# DEFAULT layout\n#\nSET(INSTALL_BINDIR_DEFAULT           \"bin\")\nSET(INSTALL_SBINDIR_DEFAULT          \"bin\")\nSET(INSTALL_SCRIPTDIR_DEFAULT        \"scripts\")\nSET(INSTALL_LOGDIR_DEFAULT           \"/var/local/mysqlrouter/log\")\nSET(INSTALL_CONFIGDIR_DEFAULT        \"etc/mysqlrouter\")\nSET(INSTALL_RUNTIMEDIR_DEFAULT       \"/var/local/mysqlrouter/run\")\nSET(INSTALL_DATADIR_DEFAULT          \"/var/local/mysqlrouter/data\")\n#\nSET(INSTALL_LIBDIR_DEFAULT           \"lib\")\nSET(INSTALL_PLUGINDIR_DEFAULT        \"lib/mysqlrouter\")\n#\nSET(INSTALL_INCLUDEDIR_DEFAULT       \"include\")\n#\nSET(INSTALL_DOCDIR_DEFAULT           \"share/doc/mysqlrouter\")\nSET(INSTALL_DOCREADMEDIR_DEFAULT     \".\")\nSET(INSTALL_MANDIR_DEFAULT           \"man\")\nSET(INSTALL_INFODIR_DEFAULT          \"share/doc/mysqlrouter\")\n#\nSET(INSTALL_SHAREDIR_DEFAULT         \"share\")\nSET(INSTALL_MYSQLSHAREDIR_DEFAULT    \"share\")\nSET(INSTALL_MYSQLTESTDIR_DEFAULT     \"share/mysqlrouter/test\")\nSET(INSTALL_SQLBENCHDIR_DEFAULT      \".\")\nSET(INSTALL_SUPPORTFILESDIR_DEFAULT  \"share/mysqlrouter/support-files\")\n#\nSET(INSTALL_MYSQLDATADIR_DEFAULT     \"data\")\nSET(INSTALL_PLUGINTESTDIR_DEFAULT    ${plugin_tests})\nSET(INSTALL_SECURE_FILE_PRIVDIR_DEFAULT ${secure_file_priv_path})\n\n#\n# WIN layout\n#\nSET(INSTALL_BINDIR_WIN           \"bin\")\nSET(INSTALL_SBINDIR_WIN          \"bin\")\nSET(INSTALL_SCRIPTDIR_WIN        \"scripts\")\nSET(INSTALL_LOGDIR_WIN           \"log/mysqlrouter\")\nSET(INSTALL_CONFIGDIR_WIN        \".\")\nSET(INSTALL_RUNTIMEDIR_WIN       \".\")\nSET(INSTALL_DATADIR_WIN          \".\")\n#\nSET(INSTALL_LIBDIR_WIN           \"lib\")\nSET(INSTALL_PLUGINDIR_WIN        \"lib\")\n#\nSET(INSTALL_INCLUDEDIR_WIN       \"include\")\n#\nSET(INSTALL_DOCDIR_WIN           \"docs\")\nSET(INSTALL_DOCREADMEDIR_WIN     \".\")\nSET(INSTALL_MANDIR_WIN           \"man\")\nSET(INSTALL_INFODIR_WIN          \"docs\")\n#\nSET(INSTALL_SHAREDIR_WIN         \"share\")\nSET(INSTALL_MYSQLSHAREDIR_WIN    \"share\")\nSET(INSTALL_MYSQLTESTDIR_WIN     \"mysqlrouter-test\")\nSET(INSTALL_SQLBENCHDIR_WIN      \".\")\nSET(INSTALL_SUPPORTFILESDIR_WIN  \"support-files\")\n#\nSET(INSTALL_MYSQLDATADIR_WIN     \"data\")\nSET(INSTALL_PLUGINTESTDIR_WIN    ${plugin_tests})\nSET(INSTALL_SECURE_FILE_PRIVDIR_WIN ${secure_file_priv_path})\n\n#\n# FREEBSD layout\n#\nSET(INSTALL_BINDIR_FREEBSD           \"bin\")\nSET(INSTALL_SBINDIR_FREEBSD          \"bin\")\nSET(INSTALL_SCRIPTDIR_FREEBSD        \"scripts\")\nSET(INSTALL_LOGDIR_FREEBSD           \"/var/log/mysqlrouter\")\nSET(INSTALL_CONFIGDIR_FREEBSD        \"/etc/mysqlrouter\")\nSET(INSTALL_RUNTIMEDIR_FREEBSD       \"/var/run/mysqlrouter\")\nSET(INSTALL_DATADIR_FREEBSD          \"/var/lib/mysqlrouter\")\n#\nSET(INSTALL_LIBDIR_FREEBSD           \"lib\")\nSET(INSTALL_PLUGINDIR_FREEBSD        \"lib/mysqlrouter\")\n#\nSET(INSTALL_INCLUDEDIR_FREEBSD       \"include\")\n#\nSET(INSTALL_DOCDIR_FREEBSD           \"docs\")\nSET(INSTALL_DOCREADMEDIR_FREEBSD     \".\")\nSET(INSTALL_MANDIR_FREEBSD           \"man\")\nSET(INSTALL_INFODIR_FREEBSD          \"docs\")\n#\nSET(INSTALL_SHAREDIR_FREEBSD         \"share\")\nSET(INSTALL_MYSQLSHAREDIR_FREEBSD    \"share\")\nSET(INSTALL_MYSQLTESTDIR_FREEBSD     \"mysqlrouter-test\")\nSET(INSTALL_SQLBENCHDIR_FREEBSD      \".\")\nSET(INSTALL_SUPPORTFILESDIR_FREEBSD  \"support-files\")\n#\nSET(INSTALL_MYSQLDATADIR_FREEBSD     \"data\")\nSET(INSTALL_PLUGINTESTDIR_FREEBSD    ${plugin_tests})\nSET(INSTALL_SECURE_FILE_PRIVDIR_FREEBSD ${secure_file_priv_path})\n\n#\n# GLIBC layout\n#\nSET(INSTALL_BINDIR_GLIBC           \"bin\")\nSET(INSTALL_SBINDIR_GLIBC          \"bin\")\nSET(INSTALL_SCRIPTDIR_GLIBC        \"scripts\")\nSET(INSTALL_LOGDIR_GLIBC           \"/var/log/mysqlrouter\")\nSET(INSTALL_CONFIGDIR_GLIBC        \"/etc/mysqlrouter\")\nSET(INSTALL_RUNTIMEDIR_GLIBC       \"/var/run/mysqlrouter\")\nSET(INSTALL_DATADIR_GLIBC          \"/var/lib/mysqlrouter\")\n#\nSET(INSTALL_LIBDIR_GLIBC           \"lib\")\nSET(INSTALL_PLUGINDIR_GLIBC        \"lib/mysqlrouter\")\n#\nSET(INSTALL_INCLUDEDIR_GLIBC       \"include\")\n#\nSET(INSTALL_DOCDIR_GLIBC           \"docs\")\nSET(INSTALL_DOCREADMEDIR_GLIBC     \".\")\nSET(INSTALL_MANDIR_GLIBC           \"man\")\nSET(INSTALL_INFODIR_GLIBC          \"docs\")\n#\nSET(INSTALL_SHAREDIR_GLIBC         \"share\")\nSET(INSTALL_MYSQLSHAREDIR_GLIBC    \"share\")\nSET(INSTALL_MYSQLTESTDIR_GLIBC     \"mysqlrouter-test\")\nSET(INSTALL_SQLBENCHDIR_GLIBC      \".\")\nSET(INSTALL_SUPPORTFILESDIR_GLIBC  \"support-files\")\n#\nSET(INSTALL_MYSQLDATADIR_GLIBC     \"data\")\nSET(INSTALL_PLUGINTESTDIR_GLIBC    ${plugin_tests})\nSET(INSTALL_SECURE_FILE_PRIVDIR_GLIBC ${secure_file_priv_path})\n\n#\n# OSX layout\n#\nSET(INSTALL_BINDIR_OSX           \"bin\")\nSET(INSTALL_SBINDIR_OSX          \"bin\")\nSET(INSTALL_SCRIPTDIR_OSX        \"scripts\")\nSET(INSTALL_LOGDIR_OSX           \"/var/log/mysqlrouter\")\nSET(INSTALL_CONFIGDIR_OSX        \"/etc/mysqlrouter\")\nSET(INSTALL_RUNTIMEDIR_OSX       \"/var/run/mysqlrouter\")\nSET(INSTALL_DATADIR_OSX          \"/var/lib/mysqlrouter\")\n\n#\nSET(INSTALL_LIBDIR_OSX           \"lib\")\nSET(INSTALL_PLUGINDIR_OSX        \"lib/mysqlrouter\")\n#\nSET(INSTALL_INCLUDEDIR_OSX       \"include\")\n#\nSET(INSTALL_DOCDIR_OSX           \"docs\")\nSET(INSTALL_DOCREADMEDIR_OSX     \".\")\nSET(INSTALL_MANDIR_OSX           \"man\")\nSET(INSTALL_INFODIR_OSX          \"docs\")\n#\nSET(INSTALL_SHAREDIR_OSX         \"share\")\nSET(INSTALL_MYSQLSHAREDIR_OSX    \"share\")\nSET(INSTALL_MYSQLTESTDIR_OSX     \"mysqlrouter-test\")\nSET(INSTALL_SQLBENCHDIR_OSX      \".\")\nSET(INSTALL_SUPPORTFILESDIR_OSX  \"support-files\")\n#\nSET(INSTALL_MYSQLDATADIR_OSX     \"data\")\nSET(INSTALL_PLUGINTESTDIR_OSX    ${plugin_tests})\nSET(INSTALL_SECURE_FILE_PRIVDIR_OSX ${secure_file_priv_path})\n\n#\n# TARGZ layout\n#\nSET(INSTALL_BINDIR_TARGZ           \"bin\")\nSET(INSTALL_SBINDIR_TARGZ          \"bin\")\nSET(INSTALL_SCRIPTDIR_TARGZ        \"scripts\")\nSET(INSTALL_LOGDIR_TARGZ           \"\")\nSET(INSTALL_CONFIGDIR_TARGZ        \"/etc/mysqlrouter\")\nSET(INSTALL_RUNTIMEDIR_TARGZ       \"/var/run/mysqlrouter\")\nSET(INSTALL_DATADIR_TARGZ          \"/var/lib/mysqlrouter\")\n#\nSET(INSTALL_LIBDIR_TARGZ           \"lib\")\nSET(INSTALL_PLUGINDIR_TARGZ        \"lib/mysqlrouter\")\n#\nSET(INSTALL_INCLUDEDIR_TARGZ       \"include\")\n#\nSET(INSTALL_DOCDIR_TARGZ           \"docs\")\nSET(INSTALL_DOCREADMEDIR_TARGZ     \".\")\nSET(INSTALL_MANDIR_TARGZ           \"man\")\nSET(INSTALL_INFODIR_TARGZ          \"docs\")\n#\nSET(INSTALL_SHAREDIR_TARGZ         \"share\")\nSET(INSTALL_MYSQLSHAREDIR_TARGZ    \"share\")\nSET(INSTALL_MYSQLTESTDIR_TARGZ     \"mysqlrouter-test\")\nSET(INSTALL_SQLBENCHDIR_TARGZ      \".\")\nSET(INSTALL_SUPPORTFILESDIR_TARGZ  \"support-files\")\n#\nSET(INSTALL_MYSQLDATADIR_TARGZ     \"data\")\nSET(INSTALL_PLUGINTESTDIR_TARGZ    ${plugin_tests})\nSET(INSTALL_SECURE_FILE_PRIVDIR_TARGZ ${secure_file_priv_path})\n\n#\n# RPM layout\n#\n# See \"packaging/rpm-uln/mysql-5.5-libdir.patch\" for the differences\n# which apply to RPMs in ULN (Oracle Linux), that patch file will\n# be applied at build time via \"rpmbuild\".\n#\nSET(INSTALL_BINDIR_RPM                  \"bin\")\nSET(INSTALL_SBINDIR_RPM                 \"sbin\")\nSET(INSTALL_SCRIPTDIR_RPM               \"bin\")\nSET(INSTALL_LOGDIR_RPM                  \"/var/log/mysqlrouter\")\nSET(INSTALL_CONFIGDIR_RPM               \"/etc/mysqlrouter\")\nSET(INSTALL_RUNTIMEDIR_RPM              \"/var/run/mysqlrouter\")\nSET(INSTALL_DATADIR_RPM                 \"/var/lib/mysqlrouter\")\n#\nIF(ARCH_64BIT)\n  SET(INSTALL_LIBDIR_RPM                \"lib64\")\n  SET(INSTALL_PLUGINDIR_RPM             \"lib64/mysqlrouter\")\nELSE()\n  SET(INSTALL_LIBDIR_RPM                \"lib\")\n  SET(INSTALL_PLUGINDIR_RPM             \"lib/mysqlrouter\")\nENDIF()\n#\nSET(INSTALL_INCLUDEDIR_RPM              \"include/mysql\")\n#\n#SET(INSTALL_DOCDIR_RPM                 unset - installed directly by RPM)\n#SET(INSTALL_DOCREADMEDIR_RPM           unset - installed directly by RPM)\nSET(INSTALL_INFODIR_RPM                 \"share/info\")\nSET(INSTALL_MANDIR_RPM                  \"share/man\")\n#\nSET(INSTALL_SHAREDIR_RPM                \"share\")\nSET(INSTALL_MYSQLSHAREDIR_RPM           \"share/mysql-router\")\nSET(INSTALL_MYSQLTESTDIR_RPM            \"share/mysql-router-test\")\nSET(INSTALL_SQLBENCHDIR_RPM             \"\")\nSET(INSTALL_SUPPORTFILESDIR_RPM         \"share/mysql-router\")\n#\nSET(INSTALL_MYSQLDATADIR_RPM            \"/var/lib/mysqlrouter\")\nSET(INSTALL_PLUGINTESTDIR_RPM           ${plugin_tests})\nSET(INSTALL_SECURE_FILE_PRIVDIR_RPM     ${secure_file_priv_path})\n\n#\n# SLES layout\n#\nSET(INSTALL_BINDIR_SLES                  \"bin\")\nSET(INSTALL_SBINDIR_SLES                 \"sbin\")\nSET(INSTALL_SCRIPTDIR_SLES               \"bin\")\nSET(INSTALL_LOGDIR_SLES                  \"/var/log/mysqlrouter\")\nSET(INSTALL_CONFIGDIR_SLES               \"/etc/mysqlrouter\")\nSET(INSTALL_RUNTIMEDIR_SLES              \"/var/run/mysqlrouter\")\nSET(INSTALL_DATADIR_SLES                 \"/var/lib/mysqlrouter\")\n#\nIF(ARCH_64BIT)\n  SET(INSTALL_LIBDIR_SLES                \"lib64\")\n  SET(INSTALL_PLUGINDIR_SLES             \"lib64/mysqlrouter\")\nELSE()\n  SET(INSTALL_LIBDIR_SLES                \"lib\")\n  SET(INSTALL_PLUGINDIR_SLES             \"lib/mysqlrouter\")\nENDIF()\n#\nSET(INSTALL_INCLUDEDIR_SLES              \"include/mysqlrouter\")\n#\n#SET(INSTALL_DOCDIR_SLES                 unset - installed directly by SLES)\n#SET(INSTALL_DOCREADMEDIR_SLES           unset - installed directly by SLES)\nSET(INSTALL_INFODIR_SLES                 \"share/info\")\nSET(INSTALL_MANDIR_SLES                  \"share/man\")\n#\nSET(INSTALL_SHAREDIR_SLES                \"share\")\nSET(INSTALL_MYSQLSHAREDIR_SLES           \"share/mysql-router\")\nSET(INSTALL_MYSQLTESTDIR_SLES            \"share/mysqlrouter-test\")\nSET(INSTALL_SQLBENCHDIR_SLES             \"\")\nSET(INSTALL_SUPPORTFILESDIR_SLES         \"share/mysql\")\n#\nSET(INSTALL_MYSQLDATADIR_SLES            \"/var/lib/mysqlrouter\")\nSET(INSTALL_PLUGINTESTDIR_SLES           ${plugin_tests})\nSET(INSTALL_SECURE_FILE_PRIVDIR_SLES     ${secure_file_priv_path})\n\n#\n# DEB layout\n#\nSET(INSTALL_BINDIR_DEB                  \"bin\")\nSET(INSTALL_SBINDIR_DEB                 \"sbin\")\nSET(INSTALL_SCRIPTDIR_DEB               \"bin\")\nSET(INSTALL_LOGDIR_DEB                  \"/var/log/mysqlrouter\")\nSET(INSTALL_CONFIGDIR_DEB               \"/etc/mysqlrouter\")\nSET(INSTALL_RUNTIMEDIR_DEB              \"/var/run/mysqlrouter\")\nSET(INSTALL_DATADIR_DEB                 \"/var/lib/mysqlrouter\")\n#\nIF(ARCH_64BIT)\n  SET(INSTALL_LIBDIR_DEB                \"lib/x86_64-linux-gnu\")\n  SET(INSTALL_PLUGINDIR_DEB             \"lib/x86_64-linux-gnu/mysqlrouter\")\nELSE()\n  SET(INSTALL_LIBDIR_DEB                \"lib/i386-linux-gnu\")\n  SET(INSTALL_PLUGINDIR_DEB             \"lib/i386-linux-gnu/mysqlrouter\")\nENDIF()\n#\nSET(INSTALL_INCLUDEDIR_DEB              \"include/mysql/router\")\n#\nSET(INSTALL_DOCDIR_DEB                  \"share/mysql-router/docs\")\nSET(INSTALL_DOCREADMEDIR_DEB            \"share/mysql-router/docs\")\nSET(INSTALL_MANDIR_DEB                  \"share/man\")\nSET(INSTALL_INFODIR_DEB                 \"share/mysql-router/docs\")\n#\nSET(INSTALL_SHAREDIR_DEB                \"share\")\nSET(INSTALL_MYSQLSHAREDIR_DEB           \"share/mysql-router\")\nSET(INSTALL_MYSQLTESTDIR_DEB            \"lib/mysql-router-test\")\nSET(INSTALL_SQLBENCHDIR_DEB             \"lib/mysql-router\")\nSET(INSTALL_SUPPORTFILESDIR_DEB         \"share/mysql-router\")\n#\nSET(INSTALL_MYSQLDATADIR_DEB            \"/var/lib/mysqlrouter\")\nSET(INSTALL_PLUGINTESTDIR_DEB           ${plugin_tests})\nSET(INSTALL_SECURE_FILE_PRIVDIR_DEB     ${secure_file_priv_path})\n\n#\n# DEBSVR4 layout\n#\nSET(INSTALL_BINDIR_DEBSVR4              \"bin\")\nSET(INSTALL_SBINDIR_DEBSVR4             \"bin\")\nSET(INSTALL_SCRIPTDIR_DEBSVR4           \"scripts\")\nSET(INSTALL_LOGDIR_DEBSVR4              \"/var/opt/mysqlrouter\")\nSET(INSTALL_CONFIGDIR_DEBSVR4           \"/etc/opt/mysqlrouter\")\nSET(INSTALL_RUNTIMEDIR_DEBSVR4          \"/var/opt/mysqlrouter\")\nSET(INSTALL_DATADIR_DEBSVR4             \"/var/opt/mysqlrouter\")\n#\nSET(INSTALL_LIBDIR_DEBSVR4              \"lib\")\nSET(INSTALL_PLUGINDIR_DEBSVR4           \"lib/mysqlrouter\")\n#\nSET(INSTALL_INCLUDEDIR_DEBSVR4          \"include\")\n#\nSET(INSTALL_DOCDIR_DEBSVR4              \"docs\")\nSET(INSTALL_DOCREADMEDIR_DEBSVR4        \".\")\nSET(INSTALL_MANDIR_DEBSVR4              \"man\")\nSET(INSTALL_INFODIR_DEBSVR4             \"docs\")\n#\nSET(INSTALL_SHAREDIR_DEBSVR4            \"share\")\nSET(INSTALL_MYSQLSHAREDIR_DEBSVR4       \"share\")\nSET(INSTALL_MYSQLTESTDIR_DEBSVR4        \"mysqlrouter-test\")\nSET(INSTALL_SQLBENCHDIR_DEBSVR4         \".\")\nSET(INSTALL_SUPPORTFILESDIR_DEBSVR4     \"support-files\")\n#\nSET(INSTALL_MYSQLDATADIR_DEBSVR4        \"/var/lib/mysqlrouter\")\nSET(INSTALL_PLUGINTESTDIR_DEBSVR4       ${plugin_tests})\nSET(INSTALL_SECURE_FILE_PRIVDIR_DEBSVR4 ${secure_file_priv_path})\n\n#\n# SVR4 layout\n#\nSET(INSTALL_BINDIR_SVR4                 \"bin\")\nSET(INSTALL_SBINDIR_SVR4                \"bin\")\nSET(INSTALL_SCRIPTDIR_SVR4              \"scripts\")\nSET(INSTALL_LOGDIR_SVR4                 \"/var/opt/mysqlrouter\")\nSET(INSTALL_CONFIGDIR_SVR4              \"/etc/opt/mysqlrouter\")\nSET(INSTALL_RUNTIMEDIR_SVR4             \"/var/opt/mysqlrouter\")\nSET(INSTALL_DATADIR_SVR4                \"/var/opt/mysqlrouter\")\n#\nSET(INSTALL_LIBDIR_SVR4                 \"lib\")\nSET(INSTALL_PLUGINDIR_SVR4              \"lib/mysqlrouter\")\n#\nSET(INSTALL_INCLUDEDIR_SVR4             \"include\")\n#\nSET(INSTALL_DOCDIR_SVR4                 \"docs\")\nSET(INSTALL_DOCREADMEDIR_SVR4           \".\")\nSET(INSTALL_MANDIR_SVR4                 \"man\")\nSET(INSTALL_INFODIR_SVR4                \"docs\")\n#\nSET(INSTALL_SHAREDIR_SVR4               \"share\")\nSET(INSTALL_MYSQLSHAREDIR_SVR4          \"share\")\nSET(INSTALL_MYSQLTESTDIR_SVR4           \"mysqlrouter-test\")\nSET(INSTALL_SQLBENCHDIR_SVR4            \".\")\nSET(INSTALL_SUPPORTFILESDIR_SVR4        \"support-files\")\n#\nSET(INSTALL_MYSQLDATADIR_SVR4           \"/var/lib/mysqlrouter\")\nSET(INSTALL_PLUGINTESTDIR_SVR4          ${plugin_tests})\nSET(INSTALL_SECURE_FILE_PRIVDIR_SVR4    ${secure_file_priv_path})\n\n\n# Clear cached variables if install layout was changed\nIF(OLD_INSTALL_LAYOUT)\n  IF(NOT OLD_INSTALL_LAYOUT STREQUAL INSTALL_LAYOUT)\n    SET(FORCE FORCE)\n  ENDIF()\nENDIF()\nSET(OLD_INSTALL_LAYOUT ${INSTALL_LAYOUT} CACHE INTERNAL \"\")\n\n# Set INSTALL_FOODIR variables for chosen layout (for example, INSTALL_BINDIR\n# will be defined  as ${INSTALL_BINDIR_STANDALONE} by default if STANDALONE\n# layout is chosen)\nFOREACH(var BIN SBIN LIB MYSQLSHARE SHARE PLUGIN INCLUDE SCRIPT DOC MAN\n  INFO MYSQLTEST SQLBENCH DOCREADME SUPPORTFILES MYSQLDATA PLUGINTEST\n  SECURE_FILE_PRIV LOG CONFIG RUNTIME DATA)\n  SET(INSTALL_${var}DIR  ${INSTALL_${var}DIR_${INSTALL_LAYOUT}}\n  CACHE STRING \"${var} installation directory\" ${FORCE})\n  MARK_AS_ADVANCED(INSTALL_${var}DIR)\nENDFOREACH()\n\n# Set up the rpath correctly based on the information provided.\n# This set a relative rpath for when using install layouts that\n# require this. The default is to use absolute paths, which are used\n# for all other layouts.\n\nSET(CMAKE_INSTALL_RPATH)\nif(INSTALL_LAYOUT STREQUAL \"STANDALONE\" OR INSTALL_LAYOUT STREQUAL \"DEFAULT\" OR\n   INSTALL_LAYOUT STREQUAL \"WIN\")\n  # rpath for lib/mysqlrouter/ plugins that want to find lib/\n  set(RPATH_PLUGIN_TO_LIB \"${RPATH_ORIGIN}/../\")\n  set(RPATH_PLUGIN_TO_PLUGIN \"${RPATH_ORIGIN}/\")\n  # rpath for lib/ libraries that want to find other libs in lib/\n  set(RPATH_LIBRARY_TO_LIB \"${RPATH_ORIGIN}/\")\n  # rpath for bin/ binaries that want to find other libs in lib/\n  set(RPATH_BINARY_TO_LIB \"${RPATH_ORIGIN}/../${INSTALL_LIBDIR}/\")\n\nelse()\n  # rpath for lib/mysqlrouter/ plugins that want to find lib/\n  set(RPATH_PLUGIN_TO_LIB \"${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}\")\n  set(RPATH_PLUGIN_TO_PLUGIN \"${CMAKE_INSTALL_PREFIX}/${INSTALL_PLUGINDIR}\")\n  # rpath for lib/ libraries that want to find other libs in lib/\n  set(RPATH_LIBRARY_TO_LIB \"${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}\")\n  # rpath for bin/ binaries that want to find other libs in lib/\n  set(RPATH_BINARY_TO_LIB \"${CMAKE_INSTALL_PREFIX}/${INSTALL_LIBDIR}\")\n\nendif()\n\n# plugins may depend on other plugins\n# plugins may depend on libs in lib/\n# executables may depend on libs in lib/\nLIST(APPEND CMAKE_INSTALL_RPATH\n  ${RPATH_PLUGIN_TO_LIB}\n  ${RPATH_PLUGIN_TO_PLUGIN}\n  ${RPATH_LIBRARY_TO_LIB}\n  ${RPATH_BINARY_TO_LIB})\n\nLIST(REMOVE_DUPLICATES CMAKE_INSTALL_RPATH)\n\nset(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)\nset(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)\n\n#\n# Set DEFAULT_SECURE_FILE_PRIV_DIR\n# This is used as default value for --secure-file-priv\n#\nIF(INSTALL_SECURE_FILE_PRIVDIR)\n  SET(DEFAULT_SECURE_FILE_PRIV_DIR \"\\\"${INSTALL_SECURE_FILE_PRIVDIR}\\\"\"\n      CACHE INTERNAL \"default --secure-file-priv directory\" FORCE)\nELSE()\n  SET(DEFAULT_SECURE_FILE_PRIV_DIR \\\"\\\"\n      CACHE INTERNAL \"default --secure-file-priv directory\" FORCE)\nENDIF()\n"
  },
  {
    "path": "cmake/libutils.cmake",
    "content": "# Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA \n\n\n# This file exports macros that emulate some functionality found  in GNU libtool\n# on Unix systems. One such feature is convenience libraries. In this context,\n# convenience library is a static library that can be linked to shared library\n# On systems that force position-independent code, linking into shared library\n# normally requires compilation with a special flag (often -fPIC). To enable \n# linking static libraries to shared, we compile source files that come into \n# static library with the PIC flag (${CMAKE_SHARED_LIBRARY_C_FLAGS} in CMake)\n# Some systems, like Windows or OSX do not need special compilation (Windows \n# never uses PIC and OSX always uses it). \n#\n# The intention behind convenience libraries is simplify the build and to reduce\n# excessive recompiles.\n\n# Except for convenience libraries, this file provides macros to merge static \n# libraries (we need it for mysqlclient) and to create shared library out of \n# convenience libraries(again, for mysqlclient)\n\n# Following macros are exported\n# - ADD_CONVENIENCE_LIBRARY(target source1...sourceN)\n# This macro creates convenience library. The functionality is similar to \n# ADD_LIBRARY(target STATIC source1...sourceN), the difference is that resulting \n# library can always be linked to shared library\n# \n# - MERGE_LIBRARIES(target [STATIC|SHARED|MODULE]  [linklib1 .... linklibN]\n#  [EXPORTS exported_func1 .... exported_func_N]\n#  [OUTPUT_NAME output_name]\n# This macro merges several static libraries into a single one or creates a shared\n# library from several convenience libraries\n\n# Important global flags \n# - WITH_PIC : If set, it is assumed that everything is compiled as position\n# independent code (that is CFLAGS/CMAKE_C_FLAGS contain -fPIC or equivalent)\n# If defined, ADD_CONVENIENCE_LIBRARY does not add PIC flag to compile flags\n#\n# - DISABLE_SHARED: If set, it is assumed that shared libraries are not produced\n# during the build. ADD_CONVENIENCE_LIBRARY does not add anything to compile flags\n\n\nINCLUDE(CheckCCompilerFlag)\n\nGET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)\nIF(WIN32 OR APPLE OR WITH_PIC OR DISABLE_SHARED OR NOT CMAKE_SHARED_LIBRARY_C_FLAGS)\n SET(_SKIP_PIC 1)\nENDIF()\n\nINCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/cmake_parse_arguments.cmake)\n# CREATE_EXPORT_FILE (VAR target api_functions)\n# Internal macro, used to create source file for shared libraries that \n# otherwise consists entirely of \"convenience\" libraries. On Windows, \n# also exports API functions as dllexport. On unix, creates a dummy file \n# that references all exports and this prevents linker from creating an \n# empty library(there are unportable alternatives, --whole-archive)\nMACRO(CREATE_EXPORT_FILE VAR TARGET API_FUNCTIONS)\n  IF(WIN32)\n    SET(DUMMY ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_dummy.c)\n    SET(EXPORTS ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_exports.def)\n    CONFIGURE_FILE_CONTENT(\"\" ${DUMMY})\n    SET(CONTENT \"EXPORTS\\n\")\n    FOREACH(FUNC ${API_FUNCTIONS})\n      SET(CONTENT \"${CONTENT} ${FUNC}\\n\")\n    ENDFOREACH()\n    CONFIGURE_FILE_CONTENT(${CONTENT} ${EXPORTS})\n    SET(${VAR} ${DUMMY} ${EXPORTS})\n  ELSE()\n    SET(EXPORTS ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_exports_file.cc)\n    SET(CONTENT)\n    FOREACH(FUNC ${API_FUNCTIONS})\n      SET(CONTENT \"${CONTENT} extern void* ${FUNC}\\;\\n\")\n    ENDFOREACH()\n    SET(CONTENT \"${CONTENT} void *${TARGET}_api_funcs[] = {\\n\")\n    FOREACH(FUNC ${API_FUNCTIONS})\n     SET(CONTENT \"${CONTENT} &${FUNC},\\n\")\n    ENDFOREACH()\n    SET(CONTENT \"${CONTENT} (void *)0\\n}\\;\")\n    CONFIGURE_FILE_CONTENT(${CONTENT} ${EXPORTS})\n    SET(${VAR} ${EXPORTS})\n  ENDIF()\nENDMACRO()\n\n\n# MYSQL_ADD_CONVENIENCE_LIBRARY(name source1...sourceN)\n# Create static library that can be linked to shared library.\n# On systems that force position-independent code, adds -fPIC or \n# equivalent flag to compile flags.\nMACRO(ADD_CONVENIENCE_LIBRARY)\n  SET(TARGET ${ARGV0})\n  SET(SOURCES ${ARGN})\n  LIST(REMOVE_AT SOURCES 0)\n  ADD_LIBRARY(${TARGET} STATIC ${SOURCES})\n  IF(NOT _SKIP_PIC)\n    SET_TARGET_PROPERTIES(${TARGET} PROPERTIES  COMPILE_FLAGS\n    \"${CMAKE_SHARED_LIBRARY_C_FLAGS}\")\n  ENDIF()\nENDMACRO()\n\n\nMACRO(ADD_CONVENIENCE_LIBRARY_DLL)\n  SET(TARGET ${ARGV0})\n  SET(SOURCES ${ARGN})\n  LIST(REMOVE_AT SOURCES 0)\n  ADD_LIBRARY(${TARGET} SHARED ${SOURCES})\n  IF(NOT _SKIP_PIC)\n    SET_TARGET_PROPERTIES(${TARGET} PROPERTIES  COMPILE_FLAGS\n    \"${CMAKE_SHARED_LIBRARY_C_FLAGS}\")\n  ENDIF()\nENDMACRO()\n\n# Write content to file, using CONFIGURE_FILE\n# The advantage compared to FILE(WRITE) is that timestamp\n# does not change if file already has the same content\nMACRO(CONFIGURE_FILE_CONTENT content file)\n SET(CMAKE_CONFIGURABLE_FILE_CONTENT \n  \"${content}\\n\")\n CONFIGURE_FILE(\n  ${MYSQL_CMAKE_SCRIPT_DIR}/configurable_file_content.in\n  ${file}\n  @ONLY)\nENDMACRO()\n\n# Merge static libraries into a big static lib. The resulting library \n# should not not have dependencies on other static libraries.\n# We use it in MySQL to merge mysys,dbug,vio etc into mysqlclient\n\nMACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE)\n  # To produce a library we need at least one source file.\n  # It is created by ADD_CUSTOM_COMMAND below and will\n  # also help to track dependencies.\n  SET(SOURCE_FILE ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_depends.cpp)\n  ADD_LIBRARY(${TARGET} STATIC ${SOURCE_FILE})\n  SET_TARGET_PROPERTIES(${TARGET} PROPERTIES OUTPUT_NAME ${OUTPUT_NAME})\n\n  SET(OSLIBS)\n  FOREACH(LIB ${LIBS_TO_MERGE})\n    GET_TARGET_PROPERTY(LIB_LOCATION ${LIB} LOCATION)\n    GET_TARGET_PROPERTY(LIB_TYPE ${LIB} TYPE)\n    IF(NOT LIB_LOCATION)\n       # 3rd party library like libz.so. Make sure that everything\n       # that links to our library links to this one as well.\n       LIST(APPEND OSLIBS ${LIB})\n    ELSE()\n      # This is a target in current project\n      # (can be a static or shared lib)\n      IF(LIB_TYPE STREQUAL \"STATIC_LIBRARY\")\n        SET(STATIC_LIBS ${STATIC_LIBS} ${LIB_LOCATION})\n        ADD_DEPENDENCIES(${TARGET} ${LIB})\n        # Extract dependend OS libraries\n        GET_DEPENDEND_OS_LIBS(${LIB} LIB_OSLIBS)\n        LIST(APPEND OSLIBS ${LIB_OSLIBS})\n      ELSE()\n        # This is a shared library our static lib depends on.\n        LIST(APPEND OSLIBS ${LIB})\n      ENDIF()\n    ENDIF()\n  ENDFOREACH()\n\n  IF(OSLIBS)\n    LIST(REMOVE_DUPLICATES OSLIBS)\n    TARGET_LINK_LIBRARIES(${TARGET} ${OSLIBS})\n    MESSAGE(STATUS \"Library ${TARGET} depends on OSLIBS ${OSLIBS}\")\n  ENDIF()\n\n  IF(STATIC_LIBS)\n    LIST(REMOVE_DUPLICATES STATIC_LIBS)\n  ENDIF()\n\n  # Make the generated dummy source file depended on all static input\n  # libs. If input lib changes,the source file is touched\n  # which causes the desired effect (relink).\n  ADD_CUSTOM_COMMAND( \n    OUTPUT  ${SOURCE_FILE}\n    COMMAND ${CMAKE_COMMAND}  -E touch ${SOURCE_FILE}\n    DEPENDS ${STATIC_LIBS})\n\n  IF(MSVC)\n    # To merge libs, just pass them to lib.exe command line.\n    SET(LINKER_EXTRA_FLAGS \"\")\n    FOREACH(LIB ${STATIC_LIBS})\n      SET(LINKER_EXTRA_FLAGS \"${LINKER_EXTRA_FLAGS} ${LIB}\")\n    ENDFOREACH()\n    SET_TARGET_PROPERTIES(${TARGET} PROPERTIES STATIC_LIBRARY_FLAGS \n      \"${LINKER_EXTRA_FLAGS}\")\n  ELSE()\n    GET_TARGET_PROPERTY(TARGET_LOCATION ${TARGET} LOCATION)  \n    IF(APPLE)\n      # Use OSX's libtool to merge archives (ihandles universal \n      # binaries properly)\n      ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD\n        COMMAND rm ${TARGET_LOCATION}\n        COMMAND /usr/bin/libtool -static -o ${TARGET_LOCATION} \n        ${STATIC_LIBS}\n      )  \n    ELSE()\n      # Generic Unix or MinGW. In post-build step, call\n      # script, that extracts objects from archives with \"ar x\" \n      # and repacks them with \"ar r\"\n      SET(TARGET ${TARGET})\n      CONFIGURE_FILE(\n        ${MYSQL_CMAKE_SCRIPT_DIR}/merge_archives_unix.cmake.in\n        ${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${TARGET}.cmake \n        @ONLY\n      )\n      ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD\n        COMMAND rm ${TARGET_LOCATION}\n        COMMAND ${CMAKE_COMMAND} -P \n        ${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${TARGET}.cmake\n      )\n    ENDIF()\n  ENDIF()\nENDMACRO()\n\n# Create libs from libs.\n# Merges static libraries, creates shared libraries out of convenience libraries.\n# MERGE_LIBRARIES(target [STATIC|SHARED|MODULE] \n#  [linklib1 .... linklibN]\n#  [EXPORTS exported_func1 .... exportedFuncN]\n#  [OUTPUT_NAME output_name]\n#)\nMACRO(MERGE_LIBRARIES)\n  MYSQL_PARSE_ARGUMENTS(ARG\n    \"EXPORTS;OUTPUT_NAME;COMPONENT\"\n    \"STATIC;SHARED;MODULE;NOINSTALL\"\n    ${ARGN}\n  )\n  LIST(GET ARG_DEFAULT_ARGS 0 TARGET) \n  SET(LIBS ${ARG_DEFAULT_ARGS})\n  LIST(REMOVE_AT LIBS 0)\n  IF(ARG_STATIC)\n    IF (NOT ARG_OUTPUT_NAME)\n      SET(ARG_OUTPUT_NAME ${TARGET})\n    ENDIF()\n    MERGE_STATIC_LIBS(${TARGET} ${ARG_OUTPUT_NAME} \"${LIBS}\") \n  ELSEIF(ARG_SHARED OR ARG_MODULE)\n    IF(ARG_SHARED)\n      SET(LIBTYPE SHARED)\n    ELSE()\n      SET(LIBTYPE MODULE)\n    ENDIF()\n    # check for non-PIC libraries\n    IF(NOT _SKIP_PIC)\n      FOREACH(LIB ${LIBS})\n        GET_TARGET_PROPERTY(${LIB} TYPE LIBTYPE)\n        IF(LIBTYPE STREQUAL \"STATIC_LIBRARY\")\n          GET_TARGET_PROPERTY(LIB COMPILE_FLAGS LIB_COMPILE_FLAGS)\n          STRING(REPLACE \"${CMAKE_SHARED_LIBRARY_C_FLAGS}\" \n          \"<PIC_FLAG>\" LIB_COMPILE_FLAGS ${LIB_COMPILE_FLAG})\n          IF(NOT LIB_COMPILE_FLAGS MATCHES \"<PIC_FLAG>\")\n            MESSAGE(FATAL_ERROR \n            \"Attempted to link non-PIC static library ${LIB} to shared library ${TARGET}\\n\"\n            \"Please use ADD_CONVENIENCE_LIBRARY, instead of ADD_LIBRARY for ${LIB}\"\n            )\n          ENDIF()\n        ENDIF()\n      ENDFOREACH()\n    ENDIF()\n    CREATE_EXPORT_FILE(SRC ${TARGET} \"${ARG_EXPORTS}\")\n    IF(NOT ARG_NOINSTALL)\n      ADD_VERSION_INFO(${TARGET} SHARED SRC)\n    ENDIF()\n    ADD_LIBRARY(${TARGET} ${LIBTYPE} ${SRC})\n    TARGET_LINK_LIBRARIES(${TARGET} ${LIBS})\n    IF(ARG_OUTPUT_NAME)\n      SET_TARGET_PROPERTIES(${TARGET} PROPERTIES OUTPUT_NAME \"${ARG_OUTPUT_NAME}\")\n    ENDIF()\n  ELSE()\n    MESSAGE(FATAL_ERROR \"Unknown library type\")\n  ENDIF()\n  IF(NOT ARG_NOINSTALL)\n    IF(ARG_COMPONENT)\n      SET(COMP COMPONENT ${ARG_COMPONENT}) \n    ENDIF()\n    MYSQL_INSTALL_TARGETS(${TARGET} DESTINATION \"${INSTALL_LIBDIR}\" ${COMP})\n  ENDIF()\n  SET_TARGET_PROPERTIES(${TARGET} PROPERTIES LINK_INTERFACE_LIBRARIES \"\")\nENDMACRO()\n\nFUNCTION(GET_DEPENDEND_OS_LIBS target result)\n  SET(deps ${${target}_LIB_DEPENDS})\n  IF(deps)\n   FOREACH(lib ${deps})\n    # Filter out keywords for used for debug vs optimized builds\n    IF(NOT lib MATCHES \"general\" AND NOT lib MATCHES \"debug\" AND NOT lib MATCHES \"optimized\")\n      GET_TARGET_PROPERTY(lib_location ${lib} LOCATION)\n      IF(NOT lib_location)\n        SET(ret ${ret} ${lib})\n      ENDIF()\n    ENDIF()\n   ENDFOREACH()\n  ENDIF()\n  SET(${result} ${ret} PARENT_SCOPE)\nENDFUNCTION()\n\n# We try to hide the symbols in yassl/zlib to avoid name clashes with\n# other libraries like openssl.\nFUNCTION(RESTRICT_SYMBOL_EXPORTS target)\n  IF(CMAKE_COMPILER_IS_GNUCXX AND UNIX)\n    SET(CMAKE_REQUIRED_FLAGS \"${CMAKE_REQUIRED_FLAGS} -Werror\")\n    CHECK_C_COMPILER_FLAG(\"-fvisibility=hidden\" HAVE_VISIBILITY_HIDDEN)\n    IF(HAVE_VISIBILITY_HIDDEN)\n      GET_TARGET_PROPERTY(COMPILE_FLAGS ${target} COMPILE_FLAGS)\n      IF(NOT COMPILE_FLAGS)\n        # Avoid COMPILE_FLAGS-NOTFOUND\n        SET(COMPILE_FLAGS)\n      ENDIF()\n      SET_TARGET_PROPERTIES(${target} PROPERTIES \n        COMPILE_FLAGS \"${COMPILE_FLAGS} -fvisibility=hidden\")\n    ENDIF()\n  ENDIF()\nENDFUNCTION()\n"
  },
  {
    "path": "cmake/mysqlx_protobuf.cmake",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nIF(MSVC)\n  SET(MYSQLX_PROTOBUF_MSVC_DISABLED_WARNINGS \"/wd4267 /wd4244\")\nENDIF()\n\n# Standard PROTOBUF_GENERATE_CPP modified to generate both\n# protobuf and protobuf-lite C++ files.\nFUNCTION(MYSQLX_PROTOBUF_GENERATE_CPP SRCS HDRS)\n  IF(NOT ARGN)\n    MESSAGE(SEND_ERROR\n      \"Error: MYSQLX_PROTOBUF_GENERATE_CPP() called without any proto files\")\n    RETURN()\n  ENDIF()\n\n  SET(${SRCS})\n  SET(${HDRS})\n  FOREACH(FIL ${ARGN})\n    GET_FILENAME_COMPONENT(ABS_FIL ${FIL} ABSOLUTE)\n    GET_FILENAME_COMPONENT(FIL_WE ${FIL} NAME_WE)\n\n    LIST(APPEND ${SRCS} \"${PROJECT_BINARY_DIR}/generated/protobuf/${FIL_WE}.pb.cc\")\n    LIST(APPEND ${HDRS} \"${PROJECT_BINARY_DIR}/generated/protobuf/${FIL_WE}.pb.h\")\n\n    ADD_CUSTOM_COMMAND(\n      OUTPUT \"${PROJECT_BINARY_DIR}/generated/protobuf/${FIL_WE}.pb.cc\"\n             \"${PROJECT_BINARY_DIR}/generated/protobuf/${FIL_WE}.pb.h\"\n      COMMAND ${CMAKE_COMMAND}\n              -E make_directory \"${PROJECT_BINARY_DIR}/generated/protobuf\"\n      COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}\n      ARGS --cpp_out=dllexport_decl=X_PROTOCOL_API:${PROJECT_BINARY_DIR}/generated/protobuf\n              -I \"${PROTOBUF_MYSQLX_DIR}\" -I \"${PROTOBUF_INCLUDE_DIR}\" ${ABS_FIL}\n      DEPENDS ${ABS_FIL} ${PROTOBUF_PROTOC_EXECUTABLE}\n      COMMENT \"Running C++ protocol buffer compiler on ${FIL}\"\n      VERBATIM)\n  ENDFOREACH()\n\n  SET_SOURCE_FILES_PROPERTIES(\n    ${${SRCS}} ${${HDRS}}\n    PROPERTIES GENERATED TRUE)\n\n  IF(MSVC)\n    ADD_COMPILE_FLAGS(${${SRCS}}\n      COMPILE_FLAGS ${MYSQLX_PROTOBUF_MSVC_DISABLED_WARNINGS})\n  ENDIF()\n\n  SET(${SRCS} ${${SRCS}} PARENT_SCOPE)\n  SET(${HDRS} ${${HDRS}} PARENT_SCOPE)\nENDFUNCTION()\n\n"
  },
  {
    "path": "cmake/packaging.cmake",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n\nif(NOT WIN32)\n  set(CPACK_PACKAGE_NAME \"mysql-router\")\nelse()\n  set(CPACK_PACKAGE_NAME \"MySQL Router\")\nendif()\n\n\nif(NOT GPL)\n  MakeNonGPLPackageName(CPACK_PACKAGE_NAME)\nendif()\nset(CPACK_PACKAGE_VENDOR \"Oracle\")\nset(CPACK_PACKAGE_CONTACT \"MySQL Release Engineering <mysql-build@oss.oracle.com>\")\n\nset(CPACK_PACKAGE_VERSION ${PROJECT_VERSION_TEXT})\nset(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})\nset(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})\nset(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})\n\nset(EXTRA_NAME_SUFFIX \"\" CACHE STRING \"Extra text in package name\")\n\nif(WIN32)\n  include(CheckTypeSize)\n  if(CMAKE_SIZEOF_VOID_P MATCHES 8)\n    set(CPACK_SYSTEM_NAME \"windows-x86-64bit\")\n  else()\n    set(CPACK_SYSTEM_NAME \"windows-x86-32bit\")\n  endif()\n  set(CPACK_PACKAGE_FILE_NAME \"mysql-router${EXTRA_NAME_SUFFIX}-${CPACK_PACKAGE_VERSION}${PROJECT_PACKAGE_EXTRAS}-${CPACK_SYSTEM_NAME}\")\nendif()\n\n#\n# Source Distribution\n#\nset(CPACK_RESOURCE_FILE_LICENSE \"${CMAKE_CURRENT_SOURCE_DIR}/License.txt\")\nset(CPACK_RESOURCE_FILE_README \"${CMAKE_CURRENT_SOURCE_DIR}/README.txt\")\nset(CPACK_SOURCE_GENERATOR \"ZIP;TGZ\")\nset(CPACK_SOURCE_PACKAGE_FILE_NAME \"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}${PROJECT_PACKAGE_EXTRAS}\")\n\n# We ignore all files in the root of the repository and then\n# exclude from the list which we want to keep.\nfile(GLOB cpack_source_ignore_files \"${PROJECT_SOURCE_DIR}/*\")\nset(src_dir ${PROJECT_SOURCE_DIR})\nset(source_include\n  \"${src_dir}/cmake\"\n  \"${src_dir}/include\"\n  \"${src_dir}/doc\"\n  \"${src_dir}/ext\"\n  \"${src_dir}/src\"\n  \"${src_dir}/tests\"\n  \"${src_dir}/tools\"\n  \"${src_dir}/packaging\"\n  \"${src_dir}/CMakeLists.txt\"\n  \"${src_dir}/config.h.in\"\n  \"${src_dir}/README.txt\"\n  \"${src_dir}/License.txt\")\nlist(REMOVE_ITEM cpack_source_ignore_files ${source_include})\nlist(APPEND cpack_source_ignore_files \"${src_dir}/harness/.gitignore\")\n\n# We need to escape the dots\nstring(REPLACE \".\" \"\\\\\\\\.\" cpack_source_ignore_files \"${cpack_source_ignore_files}\")\n\nset(CPACK_SOURCE_IGNORE_FILES \"${cpack_source_ignore_files}\")\n\ninclude(CPack)\n\n#\n# RPM-based\n#\nif(CMAKE_SYSTEM_NAME STREQUAL \"Linux\")\n  add_subdirectory(\"${PROJECT_SOURCE_DIR}/packaging/rpm-oel\")\nendif()\n\n#\n# MSI for Windows\n#\nif(CMAKE_SYSTEM_NAME STREQUAL \"Windows\")\n  add_subdirectory(\"${PROJECT_SOURCE_DIR}/packaging/WiX\")\nendif()\n"
  },
  {
    "path": "cmake/platform.cmake",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n# Figure out a nice name for Platform and Architecture\nif(CMAKE_SYSTEM_NAME STREQUAL \"Darwin\")\n  string(SUBSTRING ${CMAKE_SYSTEM} 7 2 DARWIN_VERSION)\n  if(DARWIN_VERSION STREQUAL \"17\")\n    set(PLATFORM_NAME \"OS X v10.13\")\n  elseif(DARWIN_VERSION STREQUAL \"16\")\n    set(PLATFORM_NAME \"OS X v10.12\")\n  elseif(DARWIN_VERSION STREQUAL \"15\")\n    set(PLATFORM_NAME \"OS X v10.11\")\n  elseif(DARWIN_VERSION STREQUAL \"14\")\n    set(PLATFORM_NAME \"OS X v10.10\")\n  elseif(DARWIN_VERSION STREQUAL \"13\")\n    set(PLATFORM_NAME \"OS X v10.9\")\n  else()\n    message(FATAL_ERROR \"Unsupported version of MacOS X\")\n  endif()\n  set(RPATH_ORIGIN \"@loader_path\")\n  set(CMAKE_INSTALL_NAME_DIR \"@rpath\")\nelseif(CMAKE_SYSTEM_NAME STREQUAL \"CYGWIN\")\n  set(RPATH_ORIGIN \"\\$ORIGIN\")\n  set(PLATFORM_NAME \"Windows/Cygwin\")\nelse()\n  set(RPATH_ORIGIN \"\\$ORIGIN\")\n  set(PLATFORM_NAME ${CMAKE_SYSTEM_NAME})\nendif()\n\n# Whether we deal with 32 or 64 CPU architecture/compiler\nif(CMAKE_SIZEOF_VOID_P EQUAL 8)\n  set(ARCH_64BIT 1)\nelse()\n  set(ARCH_64BIT 0)\nendif()\n"
  },
  {
    "path": "cmake/protobuf.cmake",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n#\n# Usage:\n#\n#  cmake -DWITH_PROTOBUF=\"bundled\"|\"system\"\n#\n#  Default is \"bundled\"\n#  Other values will be ignored, and we fall back to \"bundled\"\n#\n\nMACRO(RESET_PROTOBUF_VARIABLES)\n  UNSET(PROTOBUF_INCLUDE_DIR CACHE)\n  UNSET(PROTOBUF_INCLUDE_DIR)\n  UNSET(PROTOBUF_INCLUDE_DIRS CACHE)\n  UNSET(PROTOBUF_INCLUDE_DIRS)\n  UNSET(PROTOBUF_LIBRARIES CACHE)\n  UNSET(PROTOBUF_LIBRARIES)\n  UNSET(PROTOBUF_LIBRARY CACHE)\n  UNSET(PROTOBUF_LIBRARY)\n  UNSET(PROTOBUF_LITE_LIBRARY CACHE)\n  UNSET(PROTOBUF_LITE_LIBRARY)\n  UNSET(PROTOBUF_PROTOC_EXECUTABLE CACHE)\n  UNSET(PROTOBUF_PROTOC_EXECUTABLE)\nENDMACRO()\n\nMACRO(ECHO_PROTOBUF_VARIABLES)\n  MESSAGE(STATUS \"PROTOBUF_INCLUDE_DIR ${PROTOBUF_INCLUDE_DIR}\")\n  MESSAGE(STATUS \"PROTOBUF_LIBRARY ${PROTOBUF_LIBRARY}\")\n  MESSAGE(STATUS \"PROTOBUF_PROTOC_EXECUTABLE ${PROTOBUF_PROTOC_EXECUTABLE}\")\nENDMACRO()\n\nMACRO(COULD_NOT_FIND_PROTOBUF)\n  ECHO_PROTOBUF_VARIABLES()\n  MESSAGE(STATUS \"Could not find (the correct version of) protobuf.\")\n  MESSAGE(STATUS \"MySQL currently requires at least protobuf version 2.5\")\n  MESSAGE(FATAL_ERROR\n    \"You can build with the bundled sources\"\n    )\nENDMACRO()\n\nSET(BUNDLED_PROTO_SRCDIR ${MySQLRouter_SOURCE_DIR}/ext/protobuf/protobuf-3.0.0/src)\n\nMACRO(MYSQL_USE_BUNDLED_PROTOBUF)\n  SET(WITH_PROTOBUF \"bundled\" CACHE INTERNAL\n    \"Bundled protoc and protobuf library\")\n  # Set the same variables as FindProtobuf.cmake\n  SET(PROTOBUF_FOUND 1 CACHE INTERNAL \"\")\n  SET(PROTOBUF_INCLUDE_DIR ${BUNDLED_PROTO_SRCDIR} CACHE INTERNAL \"\")\n  SET(PROTOBUF_INCLUDE_DIRS ${BUNDLED_PROTO_SRCDIR} CACHE INTERNAL \"\")\n  SET(PROTOBUF_LIBRARY libprotobuf_3_0 CACHE INTERNAL \"\")\n  SET(PROTOBUF_LIBRARIES libprotobuf_3_0 CACHE INTERNAL \"\")\n  SET(PROTOBUF_PROTOC_EXECUTABLE protoc_3_0 CACHE INTERNAL \"\")\n  SET(PROTOBUF_PROTOC_LIBRARY protoclib_3_0 CACHE INTERNAL \"\")\n  SET(PROTOBUF_LITE_LIBRARY protobuf-lite CACHE INTERNAL \"\")\n  ADD_SUBDIRECTORY(ext/protobuf)\nENDMACRO()\n\nMACRO(MYSQL_CHECK_PROTOBUF)\n  IF (NOT WITH_PROTOBUF OR\n      NOT WITH_PROTOBUF STREQUAL \"system\")\n    SET(WITH_PROTOBUF \"bundled\")\n  ENDIF()\n  MESSAGE(STATUS \"WITH_PROTOBUF=${WITH_PROTOBUF}\")\n  IF(WITH_PROTOBUF STREQUAL \"bundled\")\n    MYSQL_USE_BUNDLED_PROTOBUF()\n  ELSE()\n    FIND_PACKAGE(Protobuf)\n  ENDIF()\n\n  IF(NOT PROTOBUF_FOUND)\n    MESSAGE(WARNING \"Protobuf could not be found\")\n  ENDIF()\n\n  IF(PROTOBUF_FOUND)\n    # Verify protobuf version number. Version information looks like:\n    # // The current version, represented as a single integer to make comparison\n    # // easier:  major * 10^6 + minor * 10^3 + micro\n    # #define GOOGLE_PROTOBUF_VERSION 3000000\n    FILE(STRINGS \"${PROTOBUF_INCLUDE_DIR}/google/protobuf/stubs/common.h\"\n      PROTOBUF_VERSION_NUMBER\n      REGEX \"^#define[\\t ]+GOOGLE_PROTOBUF_VERSION[\\t ][0-9]+.*\"\n      )\n    STRING(REGEX REPLACE\n      \"^.*GOOGLE_PROTOBUF_VERSION[\\t ]([0-9])[0-9][0-9]([0-9])[0-9][0-9].*$\"\n      \"\\\\1\"\n      PROTOBUF_MAJOR_VERSION \"${PROTOBUF_VERSION_NUMBER}\")\n    STRING(REGEX REPLACE\n      \"^.*GOOGLE_PROTOBUF_VERSION[\\t ]([0-9])[0-9][0-9]([0-9])[0-9][0-9].*$\"\n      \"\\\\2\"\n      PROTOBUF_MINOR_VERSION \"${PROTOBUF_VERSION_NUMBER}\")\n\n    MESSAGE(STATUS\n      \"protobuf version is ${PROTOBUF_MAJOR_VERSION}.${PROTOBUF_MINOR_VERSION}\")\n\n    IF(\"${PROTOBUF_MAJOR_VERSION}.${PROTOBUF_MINOR_VERSION}\" VERSION_LESS \"2.5\")\n      COULD_NOT_FIND_PROTOBUF()\n    ENDIF()\n  ENDIF()\nENDMACRO()\n"
  },
  {
    "path": "cmake/settings.cmake",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n# Settings for building MySQL Router\n\n# General\nset(MYSQL_ROUTER_TARGET \"mysqlrouter\"\n  CACHE STRING \"Name of the MySQL Router application\")  # Also used in CMAKE_INSTALL_PREFIX\nset(MYSQL_ROUTER_NAME \"MySQL Router\"\n  CACHE STRING \"MySQL Router project name\")\nset(MYSQL_ROUTER_INI \"mysqlrouter.conf\"\n  CACHE STRING \"Name of default configuration file\")\n\n# Command line options for CMake\noption(ENABLE_TESTS \"Enable Tests\" NO)\noption(WITH_STATIC \"Enable static linkage of external libraries\" NO)\noption(GPL \"Produce GNU GPLv2 source and binaries\" YES)\n\nIF(MYSQL_SERVER_SUFFIX STREQUAL \"-enterprise-commercial-advanced\" OR DEB_PRODUCT STREQUAL \"commercial\")\n  # if the server's cmake options for 'commercial' builds are set, use them.\n  SET(GPL 0)\nENDIF()\n\n# MySQL Harness\nset(HARNESS_NAME \"mysqlrouter\" CACHE STRING \"Name of Harness\")\n"
  },
  {
    "path": "cmake/ssl.cmake",
    "content": "# Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n# We support different versions of SSL:\n# - \"bundled\" uses source code in <source dir>/ext/yassl\n# - \"system\"  (typically) uses headers/libraries in /usr/lib and /usr/lib64\n# - a custom installation of openssl can be used like this\n#     - cmake -DCMAKE_PREFIX_PATH=</path/to/custom/openssl> -DWITH_SSL=\"system\"\n#   or\n#     - cmake -DWITH_SSL=</path/to/custom/openssl>\n#\n# The default value for WITH_SSL is \"bundled\"\n# set in cmake/build_configurations/feature_set.cmake\n#\n# For custom build/install of openssl, see the accompanying README and\n# INSTALL* files. When building with gcc, you must build the shared libraries\n# (in addition to the static ones):\n#   ./config --prefix=</path/to/custom/openssl> --shared; make; make install\n# On some platforms (mac) you need to choose 32/64 bit architecture.\n# Build/Install of openssl on windows is slightly different: you need to run\n# perl and nmake. You might also need to\n#   'set path=</path/to/custom/openssl>\\bin;%PATH%\n# in order to find the .dll files at runtime.\n\nSET(WITH_SSL_DOC \"bundled (use yassl)\")\nSET(WITH_SSL_DOC\n  \"${WITH_SSL_DOC}, yes (prefer os library if present, otherwise use bundled)\")\nSET(WITH_SSL_DOC\n  \"${WITH_SSL_DOC}, system (use os library)\")\nSET(WITH_SSL_DOC\n  \"${WITH_SSL_DOC}, </path/to/custom/installation>\")\n\nMACRO (CHANGE_SSL_SETTINGS string)\n  SET(WITH_SSL ${string} CACHE STRING ${WITH_SSL_DOC} FORCE)\nENDMACRO()\n\nMACRO (MYSQL_USE_BUNDLED_SSL)\n  IF (NOT TARGET yassl)\n    SET(INC_DIRS\n      ${PROJECT_SOURCE_DIR}/ext/yassl/include\n      ${PROJECT_SOURCE_DIR}/ext/yassl/taocrypt/include\n    )\n    SET(SSL_LIBRARIES  router_yassl router_taocrypt)\n    IF(CMAKE_SYSTEM_NAME MATCHES \"SunOS\")\n      SET(SSL_LIBRARIES ${SSL_LIBRARIES} ${LIBSOCKET})\n    ENDIF()\n    SET(SSL_INCLUDE_DIRS ${INC_DIRS})\n    SET(SSL_INTERNAL_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/ext/yassl/taocrypt/mySTL)\n    SET(SSL_DEFINES \"-DHAVE_YASSL -DYASSL_PREFIX -DHAVE_OPENSSL -DMULTI_THREADED\")\n    CHANGE_SSL_SETTINGS(\"bundled\")\n    ADD_SUBDIRECTORY(${PROJECT_SOURCE_DIR}/ext/yassl)\n    GET_TARGET_PROPERTY(src router_yassl SOURCES)\n    FOREACH(file ${src})\n      SET(SSL_SOURCES ${SSL_SOURCES} ${PROJECT_SOURCE_DIR}/ext/yassl/${file})\n    ENDFOREACH()\n    GET_TARGET_PROPERTY(src router_taocrypt SOURCES)\n    FOREACH(file ${src})\n      SET(SSL_SOURCES ${SSL_SOURCES}\n        ${PROJECT_SOURCE_DIR}/ext/yassl/taocrypt/${file})\n    ENDFOREACH()\n  ENDIF()\nENDMACRO()\n\n# MYSQL_CHECK_SSL\n#\n# Provides the following configure options:\n# WITH_SSL=[yes|bundled|system|<path/to/custom/installation>]\nMACRO (MYSQL_CHECK_SSL)\n  IF(NOT WITH_SSL)\n   IF(WIN32)\n     CHANGE_SSL_SETTINGS(\"bundled\")\n   ENDIF()\n  ENDIF()\n\n  # See if WITH_SSL is of the form </path/to/custom/installation>\n  FILE(GLOB WITH_SSL_HEADER ${WITH_SSL}/include/openssl/ssl.h)\n  IF (WITH_SSL_HEADER)\n    SET(WITH_SSL_PATH ${WITH_SSL} CACHE PATH \"path to custom SSL installation\")\n  ENDIF()\n\n  IF(WITH_SSL STREQUAL \"bundled\")\n    MYSQL_USE_BUNDLED_SSL()\n    # Reset some variables, in case we switch from /path/to/ssl to \"bundled\".\n    IF (WITH_SSL_PATH)\n      UNSET(WITH_SSL_PATH)\n      UNSET(WITH_SSL_PATH CACHE)\n    ENDIF()\n    IF (OPENSSL_ROOT_DIR)\n      UNSET(OPENSSL_ROOT_DIR)\n      UNSET(OPENSSL_ROOT_DIR CACHE)\n    ENDIF()\n    IF (OPENSSL_INCLUDE_DIR)\n      UNSET(OPENSSL_INCLUDE_DIR)\n      UNSET(OPENSSL_INCLUDE_DIR CACHE)\n    ENDIF()\n    IF (WIN32 AND OPENSSL_APPLINK_C)\n      UNSET(OPENSSL_APPLINK_C)\n      UNSET(OPENSSL_APPLINK_C CACHE)\n    ENDIF()\n    IF (OPENSSL_LIBRARY)\n      UNSET(OPENSSL_LIBRARY)\n      UNSET(OPENSSL_LIBRARY CACHE)\n    ENDIF()\n    IF (CRYPTO_LIBRARY)\n      UNSET(CRYPTO_LIBRARY)\n      UNSET(CRYPTO_LIBRARY CACHE)\n    ENDIF()\n  ELSEIF(WITH_SSL STREQUAL \"system\" OR\n         WITH_SSL STREQUAL \"yes\" OR\n         WITH_SSL_PATH\n         )\n    # First search in WITH_SSL_PATH.\n    FIND_PATH(OPENSSL_ROOT_DIR\n      NAMES include/openssl/ssl.h\n      NO_CMAKE_PATH\n      NO_CMAKE_ENVIRONMENT_PATH\n      HINTS ${WITH_SSL_PATH}\n    )\n    # Then search in standard places (if not found above).\n    FIND_PATH(OPENSSL_ROOT_DIR\n      NAMES include/openssl/ssl.h\n    )\n\n    FIND_PATH(OPENSSL_INCLUDE_DIR\n      NAMES openssl/ssl.h\n      HINTS ${OPENSSL_ROOT_DIR}/include\n    )\n\n    IF (WIN32)\n      FIND_FILE(OPENSSL_APPLINK_C\n        NAMES openssl/applink.c\n        HINTS ${OPENSSL_ROOT_DIR}/include\n      )\n      MESSAGE(STATUS \"OPENSSL_APPLINK_C ${OPENSSL_APPLINK_C}\")\n    ENDIF()\n\n    # On mac this list is <.dylib;.so;.a>\n    # We prefer static libraries, so we revert it here.\n    IF (WITH_SSL_PATH)\n      LIST(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES)\n      MESSAGE(STATUS \"suffixes <${CMAKE_FIND_LIBRARY_SUFFIXES}>\")\n    ENDIF()\n    FIND_LIBRARY(OPENSSL_LIBRARY\n                 NAMES ssl ssleay32 ssleay32MD\n                 HINTS ${OPENSSL_ROOT_DIR}/lib)\n    FIND_LIBRARY(CRYPTO_LIBRARY\n                 NAMES crypto libeay32\n                 HINTS ${OPENSSL_ROOT_DIR}/lib)\n    IF (WITH_SSL_PATH)\n      LIST(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES)\n    ENDIF()\n\n    # Verify version number. Version information looks like:\n    #   #define OPENSSL_VERSION_NUMBER 0x1000103fL\n    # Encoded as MNNFFPPS: major minor fix patch status\n    FILE(STRINGS \"${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h\"\n      OPENSSL_VERSION_NUMBER\n      REGEX \"^#[ ]*define[\\t ]+OPENSSL_VERSION_NUMBER[\\t ]+0x[0-9].*\"\n    )\n    STRING(REGEX REPLACE\n      \"^.*OPENSSL_VERSION_NUMBER[\\t ]+0x([0-9]).*$\" \"\\\\1\"\n      OPENSSL_MAJOR_VERSION \"${OPENSSL_VERSION_NUMBER}\"\n    )\n\n    IF(OPENSSL_INCLUDE_DIR AND\n       OPENSSL_LIBRARY   AND\n       CRYPTO_LIBRARY      AND\n       OPENSSL_MAJOR_VERSION STREQUAL \"1\"\n      )\n      SET(OPENSSL_FOUND TRUE)\n    ELSE()\n      SET(OPENSSL_FOUND FALSE)\n    ENDIF()\n\n    # If we are invoked with -DWITH_SSL=/path/to/custom/openssl\n    # and we have found static libraries, then link them statically\n    # into our executables and libraries.\n    # Adding IMPORTED_LOCATION allows MERGE_STATIC_LIBS\n    # to get LOCATION and do correct dependency analysis.\n    SET(MY_CRYPTO_LIBRARY \"${CRYPTO_LIBRARY}\")\n    SET(MY_OPENSSL_LIBRARY \"${OPENSSL_LIBRARY}\")\n    IF (WITH_SSL_PATH AND NOT TARGET imported_crypto)\n      GET_FILENAME_COMPONENT(CRYPTO_EXT \"${CRYPTO_LIBRARY}\" EXT)\n      GET_FILENAME_COMPONENT(OPENSSL_EXT \"${OPENSSL_LIBRARY}\" EXT)\n      IF (CRYPTO_EXT STREQUAL \".a\")\n        SET(MY_CRYPTO_LIBRARY imported_crypto)\n        ADD_LIBRARY(imported_crypto STATIC IMPORTED)\n        SET_TARGET_PROPERTIES(imported_crypto\n          PROPERTIES IMPORTED_LOCATION \"${CRYPTO_LIBRARY}\")\n      ENDIF()\n      IF (OPENSSL_EXT STREQUAL \".a\")\n        SET(MY_OPENSSL_LIBRARY imported_openssl)\n        ADD_LIBRARY(imported_openssl STATIC IMPORTED)\n        SET_TARGET_PROPERTIES(imported_openssl\n          PROPERTIES IMPORTED_LOCATION \"${OPENSSL_LIBRARY}\")\n      ENDIF()\n    ENDIF()\n\n    MESSAGE(STATUS \"OPENSSL_INCLUDE_DIR = ${OPENSSL_INCLUDE_DIR}\")\n    MESSAGE(STATUS \"OPENSSL_LIBRARY = ${OPENSSL_LIBRARY}\")\n    MESSAGE(STATUS \"CRYPTO_LIBRARY = ${CRYPTO_LIBRARY}\")\n    MESSAGE(STATUS \"OPENSSL_MAJOR_VERSION = ${OPENSSL_MAJOR_VERSION}\")\n\n    INCLUDE(CheckSymbolExists)\n    SET(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})\n    CHECK_SYMBOL_EXISTS(SHA512_DIGEST_LENGTH \"openssl/sha.h\"\n                        HAVE_SHA512_DIGEST_LENGTH)\n    IF(OPENSSL_FOUND AND HAVE_SHA512_DIGEST_LENGTH)\n      SET(SSL_SOURCES \"\")\n      SET(SSL_LIBRARIES ${MY_OPENSSL_LIBRARY} ${MY_CRYPTO_LIBRARY})\n      IF(CMAKE_SYSTEM_NAME MATCHES \"SunOS\")\n        SET(SSL_LIBRARIES ${SSL_LIBRARIES} ${LIBSOCKET})\n      ENDIF()\n      IF(CMAKE_SYSTEM_NAME MATCHES \"Linux\")\n        SET(SSL_LIBRARIES ${SSL_LIBRARIES})\n        SET(SSL_LIBRARIES_DL ${LIBDL})\n      ENDIF()\n      MESSAGE(STATUS \"SSL_LIBRARIES = ${SSL_LIBRARIES}\")\n      SET(SSL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})\n      SET(SSL_INTERNAL_INCLUDE_DIRS \"\")\n      SET(SSL_DEFINES \"-DHAVE_OPENSSL\")\n    ELSE()\n\n      UNSET(WITH_SSL_PATH)\n      UNSET(WITH_SSL_PATH CACHE)\n      UNSET(OPENSSL_ROOT_DIR)\n      UNSET(OPENSSL_ROOT_DIR CACHE)\n      UNSET(OPENSSL_INCLUDE_DIR)\n      UNSET(OPENSSL_INCLUDE_DIR CACHE)\n      UNSET(OPENSSL_APPLINK_C)\n      UNSET(OPENSSL_APPLINK_C CACHE)\n      UNSET(OPENSSL_LIBRARY)\n      UNSET(OPENSSL_LIBRARY CACHE)\n      UNSET(CRYPTO_LIBRARY)\n      UNSET(CRYPTO_LIBRARY CACHE)\n\n      MESSAGE(SEND_ERROR\n        \"Cannot find appropriate system libraries for SSL. \"\n        \"Make sure you've specified a supported SSL version. \"\n        \"Consult the documentation for WITH_SSL alternatives\")\n    ENDIF()\n  ELSE()\n    MESSAGE(SEND_ERROR\n      \"Wrong option or path for WITH_SSL. \"\n      \"Valid options are : ${WITH_SSL_DOC}\")\n  ENDIF()\nENDMACRO()\n\n\n# Many executables will depend on libeay32.dll and ssleay32.dll at runtime.\n# In order to ensure we find the right version(s), we copy them into\n# the same directory as the executables.\n# NOTE: Using dlls will likely crash in malloc/free,\n#       see INSTALL.W32 which comes with the openssl sources.\n# So we should be linking static versions of the libraries.\nMACRO (COPY_OPENSSL_DLLS target_name out_dir)\n  IF (WIN32 AND WITH_SSL_PATH)\n    GET_FILENAME_COMPONENT(CRYPTO_NAME \"${CRYPTO_LIBRARY}\" NAME_WE)\n    GET_FILENAME_COMPONENT(OPENSSL_NAME \"${OPENSSL_LIBRARY}\" NAME_WE)\n    FILE(GLOB HAVE_CRYPTO_DLL \"${WITH_SSL_PATH}/bin/${CRYPTO_NAME}.dll\")\n    FILE(GLOB HAVE_OPENSSL_DLL \"${WITH_SSL_PATH}/bin/${OPENSSL_NAME}.dll\")\n    IF (HAVE_CRYPTO_DLL AND HAVE_OPENSSL_DLL)\n      ADD_CUSTOM_COMMAND(TARGET ${target_name} PRE_BUILD\n        COMMAND ${CMAKE_COMMAND} -E copy_if_different\n          \"${WITH_SSL_PATH}/bin/${CRYPTO_NAME}.dll\"\n          \"${out_dir}/${CRYPTO_NAME}.dll\"\n        COMMAND ${CMAKE_COMMAND} -E copy_if_different\n          \"${WITH_SSL_PATH}/bin/${OPENSSL_NAME}.dll\"\n          \"${out_dir}/${OPENSSL_NAME}.dll\"\n        )\n    ENDIF()\n  ENDIF()\nENDMACRO()\n"
  },
  {
    "path": "cmake/testing.cmake",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nset(_TEST_RUNTIME_DIR ${PROJECT_BINARY_DIR}/tests)\n\n# We include GMock without touching the compile flags. GMock can\n# handle that itself. It will also indirectly create targets for gmock\n# and gtest.\n#\n# Two alternatives for locating GMock *source code*:\n# 1. If WITH_GMOCK is given, this is expected to be the location of\n#    the *source code*.\n# 2. If WITH_GMOCK is not given, it will look in the 'ext' directory\n#    in the source root.\nif(ENABLE_TESTS)\n  if(TARGET gmock)\n    # don't build gmock, if the parent already built it\n\n    # copying from unittest/gunit/CMakeFiles.txt\n    # this should all be global-variables or a cmake/ file\n    if(NOT DOWNLOAD_ROOT)\n      set(DOWNLOAD_ROOT ${CMAKE_SOURCE_DIR}/source_downloads)\n    endif()\n\n    # We want googletest version 1.8, which also contains googlemock.\n    set(GMOCK_PACKAGE_NAME \"release-1.8.0\")\n\n    if(DEFINED ENV{WITH_GMOCK} AND NOT DEFINED WITH_GMOCK)\n      file(TO_CMAKE_PATH \"$ENV{WITH_GMOCK}\" WITH_GMOCK)\n    ENDIF()\n\n    if(LOCAL_GMOCK_ZIP\n       AND NOT ${LOCAL_GMOCK_ZIP} MATCHES \".*${GMOCK_PACKAGE_NAME}\\\\.zip\")\n     set(LOCAL_GMOCK_ZIP 0)\n    endif()\n\n    if(WITH_GMOCK)\n      ## Did we get a full path name, including file name?\n      if(${WITH_GMOCK} MATCHES \".*\\\\.zip\")\n        GET_FILENAME_COMPONENT(GMOCK_DIR ${WITH_GMOCK} PATH)\n        GET_FILENAME_COMPONENT(GMOCK_ZIP ${WITH_GMOCK} NAME)\n        FIND_FILE(LOCAL_GMOCK_ZIP\n                  NAMES ${GMOCK_ZIP}\n                  PATHS ${GMOCK_DIR}\n                  NO_DEFAULT_PATH\n                 )\n      else()\n        ## Did we get a path name to the directory of the .zip file?\n        ## Check for both release-x.y.z.zip and googletest-release-x.y.z.zip\n        FIND_FILE(LOCAL_GMOCK_ZIP\n                  NAMES \"${GMOCK_PACKAGE_NAME}.zip\" \"googletest-${GMOCK_PACKAGE_NAME}.zip\"\n                  PATHS ${WITH_GMOCK}\n                  NO_DEFAULT_PATH\n                  )\n        ## If WITH_GMOCK is a directory, use it for download.\n        set(DOWNLOAD_ROOT ${WITH_GMOCK})\n      endif()\n      MESSAGE(STATUS \"Local gmock zip ${LOCAL_GMOCK_ZIP}\")\n    endif()\n\n    set(GMOCK_SOURCE_DIR ${DOWNLOAD_ROOT}/googletest-${GMOCK_PACKAGE_NAME}/googlemock)\n    set(GTEST_SOURCE_DIR ${DOWNLOAD_ROOT}/googletest-${GMOCK_PACKAGE_NAME}/googletest)\n\n    # introduce some compat\n    set(GTEST_INCLUDE_DIRS ${GMOCK_INCLUDE_DIRS})\n    message(\"yyy seting GTEST_INCLUDE_DIRS to ${GTEST_INCLUDE_DIRS}\")\n\n    ADD_LIBRARY(gmock_main STATIC ${GMOCK_SOURCE_DIR}/src/gmock_main.cc)\n    target_link_libraries(gmock_main gmock)\n    target_include_directories(gmock_main\n      PUBLIC ${GMOCK_INCLUDE_DIRS})\n    ADD_LIBRARY(gtest_main STATIC ${GTEST_SOURCE_DIR}/src/gtest_main.cc)\n    target_include_directories(gtest_main\n      PUBLIC ${GMOCK_INCLUDE_DIRS})\n\n    if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL \"Clang\")\n      set_target_properties(gtest_main gmock_main\n        PROPERTIES\n        COMPILE_FLAGS \"-Wno-undef -Wno-conversion\")\n    endif()\n\n    set(TEST_LIBRARIES gmock gtest gmock_main gtest_main)\n  else()\n    if(WITH_GMOCK)\n\n      # There is a known gtest/gmock bug that surfaces with the gcc-6.x causing tests crashes:\n      # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=833450\n      # We have a patch for it in the gmock we bundle but if the user wants to use\n      # it's own gtest/gmock we need to prevent it if the gcc-6.x is used\n      if ((CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\")\n        AND (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL \"6.0\" OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER \"6.0\"))\n        message(FATAL_ERROR \"Parameter WITH_GMOCK is not supported for gcc-6 or greater.\"\n          \"You need to either disable the tests or use the bundled gmock (removing WITH_GMOCK parameter).\")\n      endif()\n\n      set(_gmock_root ${WITH_GMOCK})\n      set(_gtest_root ${WITH_GMOCK}/gtest)\n    elseif(EXISTS \"${CMAKE_SOURCE_DIR}/ext/gmock/CMakeLists.txt\")\n      if(NOT EXISTS \"${CMAKE_SOURCE_DIR}/ext/gtest/CMakeLists.txt\")\n        message(FATAL_ERROR \"Cannot find GTest repository under ${CMAKE_SOURCE_DIR}/ext/gtest\")\n      endif()\n      set(_gmock_root \"${CMAKE_SOURCE_DIR}/ext/gmock\")\n      set(_gtest_root \"${CMAKE_SOURCE_DIR}/ext/gtest\")\n    elseif(GMOCK_SOURCE_DIR)\n      # means we are part of the server and GMOCK was downloaded\n      set(_gmock_root ${GMOCK_SOURCE_DIR})\n      set(_gtest_root ${GMOCK_SOURCE_DIR}/gtest)\n    else()\n      # means we are part of the server and GMOCK is missing\n      # act as other server components, disable the tests\n      SET (ENABLE_TESTS 0)\n      SET (ENABLE_TESTS 0 PARENT_SCOPE)\n    endif()\n\n    if (ENABLE_TESTS)\n      if(NOT EXISTS \"${_gmock_root}/CMakeLists.txt\")\n        message(WARNING\n          \"Unable to find GMock source, not possible to build tests. Either \"\n          \"disable tests with ENABLE_TESTS=no or download the source code \"\n          \"for GMock (available at https://github.com/google/googlemock) and \"\n          \"set WITH_GMOCK to the directory of the unpacked source code.\")\n      endif()\n\n      message(STATUS \"Found GMock source under ${_gmock_root}\")\n      add_subdirectory(${_gmock_root} ext/gmock)\n\n      # Setting variables that are normally discovered using FindXXX.cmake\n      set(GTEST_INCLUDE_DIRS ${_gtest_root}/include)\n      message(\"yyy seting GTEST_INCLUDE_DIRS to ${GTEST_INCLUDE_DIRS}\")\n      set(GTEST_LIBRARIES gtest)\n      set(GTEST_MAIN_LIBRARIES gtest_main)\n      set(GTEST_BOTH_LIBRARIES ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES})\n\n      set(GMOCK_INCLUDE_DIRS ${_gmock_root}/include)\n      set(GMOCK_LIBRARIES gmock)\n      set(GMOCK_MAIN_LIBRARIES gmock_main)\n      set(GMOCK_BOTH_LIBRARIES ${GMOCK_LIBRARIES} ${GMOCK_MAIN_LIBRARIES})\n\n      set(TEST_LIBRARIES ${GMOCK_BOTH_LIBRARIES} ${GTEST_BOTH_LIBRARIES})\n\n      # Since GMock and GTest do not set\n      # INTERFACE_SYSTEM_INCLUDE_DIRECTORIES, we do that here. This means\n      # that any targets that reference one of these libraries will\n      # \"automatically\" have the include directories for these libraries\n      # added to their build flags.  We cannot use \"SYSTEM\" since that is\n      # not available in 2.8.9 (it was introduced in 2.8.12).\n      target_include_directories(gmock PUBLIC ${GMOCK_INCLUDE_DIRS})\n      target_include_directories(gmock_main PUBLIC ${GMOCK_INCLUDE_DIRS})\n      target_include_directories(gtest PUBLIC ${GTEST_INCLUDE_DIRS})\n      target_include_directories(gtest_main PUBLIC ${GTEST_INCLUDE_DIRS})\n\n      if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL \"Clang\")\n\n        set (comp_flags_ \"-Wno-undef -Wno-missing-field-initializers\")\n        if(COMPILER_HAS_WARNING_MISSING_FORMAT_ATTRIBUTE)\n          set(comp_flags_ \"${comp_flags_} -Wno-missing-format-attribute\")\n        endif()\n\n        set_target_properties(gtest gtest_main gmock gmock_main\n          PROPERTIES\n          COMPILE_FLAGS \"${comp_flags_}\")\n      endif()\n    endif()\n  endif()\nendif()\n\n# Set {RUNTIME,LIBRARY}_OUTPUT_DIRECTORY properties of a target to the stage dir.\n# On unix platforms this is just one directory, but on Windows it's per build-type,\n# e.g. build/stage/Debug/lib, build/stage/Release/lib, etc\nfunction(set_target_output_directory target target_output_directory dirname)\n  if(NOT CMAKE_CFG_INTDIR STREQUAL \".\")\n    foreach(config_ ${CMAKE_CONFIGURATION_TYPES})\n      string(TOUPPER ${config_} config__)\n      set_property(TARGET ${target} PROPERTY\n        ${target_output_directory}_${config__} ${MySQLRouter_BINARY_STAGE_DIR}/${config_}/${dirname})\n    endforeach()\n  else()\n    set_property(TARGET ${target} PROPERTY\n      ${target_output_directory} ${MySQLRouter_BINARY_STAGE_DIR}/${dirname})\n  endif()\nendfunction()\n\n# Prepare staging area\nforeach(dir etc;run;log;bin;lib)\n  if(NOT CMAKE_CFG_INTDIR STREQUAL \".\")\n    foreach(config_ ${CMAKE_CONFIGURATION_TYPES})\n      file(MAKE_DIRECTORY ${MySQLRouter_BINARY_STAGE_DIR}/${config_}/${dir})\n    endforeach()\n  else()\n    file(MAKE_DIRECTORY ${MySQLRouter_BINARY_STAGE_DIR}/${dir})\n  endif()\nendforeach()\n\nfunction(add_test_file FILE)\n  set(one_value_args MODULE LABEL ENVIRONMENT)\n  set(multi_value_args LIB_DEPENDS INCLUDE_DIRS)\n  cmake_parse_arguments(TEST \"\" \"${one_value_args}\" \"${multi_value_args}\" ${ARGN})\n\n  if(NOT TEST_MODULE)\n    message(FATAL_ERROR \"Module name missing for test file ${FILE}\")\n  endif()\n\n  get_filename_component(test_ext ${FILE} EXT)\n  get_filename_component(runtime_dir ${FILE} PATH)  # Not using DIRECTORY because of CMake >=2.8.11 requirement\n\n  set(runtime_dir ${PROJECT_BINARY_DIR}/tests/${TEST_MODULE})\n\n  if(test_ext STREQUAL \".cc\")\n    # Tests written in C++\n    get_filename_component(test_target ${FILE} NAME_WE)\n    string(REGEX REPLACE \"^test_\" \"\" test_target ${test_target})\n    set(test_target \"test_${TEST_MODULE}_${test_target}\")\n    set(test_name \"tests/${TEST_MODULE}/${test_target}\")\n    add_executable(${test_target} ${FILE})\n    target_link_libraries(${test_target}\n      gtest gtest_main gmock gmock_main routertest_helpers\n      router_lib harness-library\n      ${CMAKE_THREAD_LIBS_INIT})\n    foreach(libtarget ${TEST_LIB_DEPENDS})\n      #add_dependencies(${test_target} ${libtarget})\n      target_link_libraries(${test_target} ${libtarget})\n    endforeach()\n    foreach(include_dir ${TEST_INCLUDE_DIRS})\n      target_include_directories(${test_target} PUBLIC ${include_dir})\n    endforeach()\n    set_target_properties(${test_target}\n      PROPERTIES\n      RUNTIME_OUTPUT_DIRECTORY ${runtime_dir}/)\n    if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL \"Clang\")\n      # silence undefined use of macro-vars in gtest.\n      # we can't use #pragma's due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431 to\n      # supress it locally.\n      set_target_properties(\n        ${test_target}\n        PROPERTIES\n        COMPILE_FLAGS \"-Wno-undef -Wno-conversion\")\n    endif()\n\n    if(WITH_VALGRIND)\n      FIND_PROGRAM(VALGRIND valgrind)\n      SET(TEST_WRAPPER ${VALGRIND} --error-exitcode=1)\n    endif()\n\n    add_test(NAME ${test_name}\n      COMMAND ${TEST_WRAPPER} $<TARGET_FILE:${test_target}> --gtest_output=xml:${runtime_dir}/${test_target}.xml)\n\n    SET(TEST_ENV_PREFIX \"STAGE_DIR=${MySQLRouter_BINARY_STAGE_DIR};CMAKE_SOURCE_DIR=${MySQLRouter_SOURCE_DIR};CMAKE_BINARY_DIR=${MySQLRouter_BINARY_DIR}\")\n    if(WITH_VALGRIND)\n      SET(TEST_ENV_PREFIX \"${TEST_ENV_PREFIX};WITH_VALGRIND=1\")\n    endif()\n\n    if (WIN32)\n      # PATH's separator \";\" needs to be escaped as CMAKE's test-env is also separated by ; ...\n      STRING(REPLACE \";\" \"\\\\;\" ESC_ENV_PATH \"$ENV{PATH}\")\n\n      ## win32 has single and multi-configuration builds\n      set_tests_properties(${test_name} PROPERTIES\n        ENVIRONMENT\n        \"${TEST_ENV_PREFIX};PATH=$<TARGET_FILE_DIR:harness-library>\\;$<TARGET_FILE_DIR:mysqlrouter>\\;$<TARGET_FILE_DIR:mysql_protocol>\\;$<TARGET_FILE_DIR:http_common>\\;$<TARGET_FILE_DIR:duktape>\\;${ESC_ENV_PATH};${TEST_ENVIRONMENT}\")\n    else()\n      set_tests_properties(${test_name} PROPERTIES\n        ENVIRONMENT\n        \"${TEST_ENV_PREFIX};LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH};DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH};${TEST_ENVIRONMENT}\")\n    endif()\n  else()\n    message(ERROR \"Unknown test type; file '${FILE}'\")\n  endif()\n\nendfunction(add_test_file)\n\nfunction(add_test_dir DIR_NAME)\n  set(one_value_args MODULE ENVIRONMENT)\n  set(multi_value_args LIB_DEPENDS INCLUDE_DIRS)\n  cmake_parse_arguments(TEST \"\" \"${one_value_args}\" \"${multi_value_args}\" ${ARGN})\n\n  if(NOT TEST_MODULE)\n    message(FATAL_ERROR \"Module name missing for test folder ${DIR_NAME}\")\n  endif()\n\n  get_filename_component(abs_path ${DIR_NAME} ABSOLUTE)\n\n  file(GLOB test_files RELATIVE ${abs_path}\n    ${abs_path}/*.cc)\n\n  foreach(test_file ${test_files})\n    if(NOT ${test_file} MATCHES \"^helper\")\n      add_test_file(${abs_path}/${test_file}\n        MODULE ${TEST_MODULE}\n        ENVIRONMENT ${TEST_ENVIRONMENT}\n        LIB_DEPENDS ${TEST_LIB_DEPENDS}\n        INCLUDE_DIRS ${TEST_INCLUDE_DIRS}\n        )\n    endif()\n  endforeach(test_file)\n\nendfunction(add_test_dir)\n"
  },
  {
    "path": "cmake/version.cmake",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n# Version information of MySQL Router\n\n# Project version, has to be an X.Y.Z number since it is used with the\n# \"project\" CMake command\nset(PROJECT_VERSION_TEXT \"8.0.12\")\n\n# Can be arbitrary test that is added to the package file names after\n# the version, but before the extensions.\nset(PROJECT_PACKAGE_EXTRAS \"\")\n\nset(PROJECT_EDITION \"GPL community edition\" CACHE STRING\n  \"Edition of MySQL Router\")\n\n# create a string that is allowed in a RPM spec \"release\" field\nset(RPM_EXTRA_VERSION \"${PROJECT_PACKAGE_EXTRAS}\")\nif(RPM_EXTRA_VERSION)\n  string(REGEX REPLACE \"[^A-Za-z0-9]\" \"\" RPM_EXTRA_VERSION \"${RPM_EXTRA_VERSION}\")\n  set(RPM_EXTRA_VERSION \".${RPM_EXTRA_VERSION}\")\nendif()\n\n# Nothing below this line needs change when releasing\n\n# Older CMake version do not set PROJECT_VERSION\nif(${CMAKE_VERSION} VERSION_LESS \"3.0\")\n  # We can not use project() to set version information\n  string(REPLACE \".\" \";\" version_list ${PROJECT_VERSION_TEXT})\n  list(GET version_list 0 major)\n  list(GET version_list 1 minor)\n  list(GET version_list 2 patch)\n  set(MySQLRouter_VERSION_MAJOR ${major})\n  set(MySQLRouter_VERSION_MINOR ${minor})\n  set(MySQLRouter_VERSION_PATCH ${patch})\n  set(PROJECT_VERSION_MAJOR ${major})\n  set(PROJECT_VERSION_MINOR ${minor})\n  set(PROJECT_VERSION_PATCH ${patch})\n  set(MySQLRouter_VERSION ${PROJECT_VERSION_TEXT})\n  set(PROJECT_VERSION ${PROJECT_VERSION_TEXT})\nendif()\n"
  },
  {
    "path": "config.h.in",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n// Generated from config.h.in\n\n// MySQL Router version\n#define MYSQL_ROUTER_VERSION \"@MySQLRouter_VERSION@\"\n#define MYSQL_ROUTER_VERSION_MAJOR @MySQLRouter_VERSION_MAJOR@\n#define MYSQL_ROUTER_VERSION_MINOR @MySQLRouter_VERSION_MINOR@\n#define MYSQL_ROUTER_VERSION_PATCH @MySQLRouter_VERSION_PATCH@\n#define MYSQL_ROUTER_VERSION_EDITION \"@PROJECT_EDITION@\"\n\n// Package information\n#define MYSQL_ROUTER_PACKAGE_NAME \"@MYSQL_ROUTER_NAME@\"\n#define MYSQL_ROUTER_PACKAGE_PLATFORM \"@PLATFORM_NAME@\"\n#define MYSQL_ROUTER_PACKAGE_ARCH_CPU \"@CMAKE_SYSTEM_PROCESSOR@\"\n#define MYSQL_ROUTER_PACKAGE_ARCH_64BIT @ARCH_64BIT@\n\n// Legal\n#define COPYRIGHT \"@ORACLE_COPYRIGHT@\"\n#define WELCOME \\\n    \"@ORACLE_COPYRIGHT@\"\\\n    \"\\n\\n\"\\\n    \"Oracle is a registered trademark of Oracle Corporation and/or its\\n\"\\\n    \"affiliates. Other names may be trademarks of their respective\\n\"\\\n    \"owners.\\n\\n\"\\\n    \"Start MySQL Router.\\n\"\n\n// Compiler features\n#ifdef _MSC_VER\n#if (_MSC_VER < 1700)\n#define noexcept\n#endif\n#endif\n\n// Defaults\n#define CONFIG_FILES R\"cfg(@CONFIG_FILES@)cfg\"\n#define MYSQL_ROUTER_BINARY_FOLDER \"@ROUTER_BINDIR@\"\n#define MYSQL_ROUTER_PLUGIN_FOLDER \"@ROUTER_PLUGINDIR@\"\n#define MYSQL_ROUTER_CONFIG_FOLDER \"@ROUTER_CONFIGDIR@\"\n#define MYSQL_ROUTER_RUNTIME_FOLDER \"@ROUTER_RUNTIMEDIR@\"\n#define MYSQL_ROUTER_LOGGING_FOLDER \"@ROUTER_LOGDIR@\"\n#define MYSQL_ROUTER_DATA_FOLDER \"@ROUTER_DATADIR@\"\n\n// Plaform specific\n#cmakedefine SIZEOF_VOIDP     @SIZEOF_VOIDP@\n#cmakedefine SIZEOF_CHARP     @SIZEOF_CHARP@\n#cmakedefine SIZEOF_LONG      @SIZEOF_LONG@\n#cmakedefine SIZEOF_SHORT     @SIZEOF_SHORT@\n#cmakedefine SIZEOF_INT       @SIZEOF_INT@\n#cmakedefine SIZEOF_LONG_LONG @SIZEOF_LONG_LONG@\n#cmakedefine SIZEOF_OFF_T     @SIZEOF_OFF_T@\n#cmakedefine SIZEOF_TIME_T    @SIZEOF_TIME_T@\n\n/* Endianess */\n#cmakedefine WORDS_BIGENDIAN 1\n\n#cmakedefine ENABLE_TESTS\n\n/* Compiler specific features */\n#cmakedefine HAVE_ATTRIBUTE_FORMAT 1\n\n// Platform specific libraries\n#cmakedefine HAVE_PRLIMIT 1\n"
  },
  {
    "path": "doc/doxygen.cfg.in",
    "content": "# Generated from doc/doxygen.cfg.in\n\n# This file describes the settings to be used by Doxygen for MySQL Router.\n\nDOXYFILE_ENCODING      = UTF-8\nPROJECT_NAME           = \"MySQL Router\"\nPROJECT_NUMBER         =\nPROJECT_BRIEF          = \"Route MySQL connections\"\nPROJECT_LOGO           =\n\nOUTPUT_DIRECTORY       = doc\nOUTPUT_LANGUAGE        = English\nGENERATE_LATEX         = NO\nBRIEF_MEMBER_DESC      = YES\nREPEAT_BRIEF           = NO\nOPTIMIZE_OUTPUT_FOR_C  = NO\nEXTENSION_MAPPING      = cc=C++\n\nMARKDOWN_SUPPORT       = YES\nAUTOLINK_SUPPORT       = YES\n\nBUILTIN_STL_SUPPORT    = YES\n\nEXTRACT_PRIVATE        = YES\nINTERNAL_DOCS          = YES\nCASE_SENSE_NAMES       = NO\n\nRECURSIVE              = YES\nINPUT                  = @MySQLRouter_SOURCE_DIR@/README.md @MySQLRouter_SOURCE_DIR@/\nSTRIP_FROM_PATH        = @MySQLRouter_SOURCE_DIR@/\nEXCLUDE               += @MySQLRouter_SOURCE_DIR@/ext\nEXCLUDE               += @MySQLRouter_SOURCE_DIR@/packaging\nEXCLUDE               += @MySQLRouter_SOURCE_DIR@/cmake\nEXCLUDE_PATTERNS       =\nEXCLUDE_PATTERNS      += *.txt\nUSE_MDFILE_AS_MAINPAGE = @MySQLRouter_SOURCE_DIR@/README.md\n\nHTML_HEADER            = @MySQLRouter_SOURCE_DIR@/doc/router_header.html\nHTML_FOOTER            = @MySQLRouter_SOURCE_DIR@/doc/router_footer.html\nHTML_EXTRA_STYLESHEET  = @MySQLRouter_SOURCE_DIR@/doc/router_doxygen.css\n\nALIASES               += devnote=\"<div class=\\\"devnote\\\">\\n\\internal \\n\"\nALIASES               += enddevnote=\"\\endinternal \\n</div>\"\n\nWARN_IF_UNDOCUMENTED   = NO\nWARN_AS_ERROR          = YES\nENABLE_PREPROCESSING   = YES\nMACRO_EXPANSION        = YES\nPREDEFINED             = DOXYGEN_SHOULD_SKIP_THIS\n\n# allow to include every file\nEXAMPLE_PATH           = @PROJECT_SOURCE_DIR@\n"
  },
  {
    "path": "doc/router_doxygen.css",
    "content": ".fragment {\n  font-size: 80% !important;\n}\n\n.textblock, .memitem {\n  width: 600px !important;\n}\n\n.memdoc p {\n}\n\n.devnote h6 {\n  font-color: orange;\n  font-weight: bold;\n  font-size: inherit;\n  margin: 0;\n  padding: 0;\n}\n\n.devnote p {\n  margin: 0;\n}\n\n.devnote {\n  border-left: solid 3px orange;\n  padding-left: 3px;\n  margin-bottom: 5px;\n}"
  },
  {
    "path": "doc/router_footer.html",
    "content": "<!-- HTML footer for doxygen 1.8.9.1-->\n<!-- start footer part -->\n<!--BEGIN GENERATE_TREEVIEW-->\n<div id=\"nav-path\" class=\"navpath\"><!-- id is needed for treeview function! -->\n  <ul>\n    $navpath\n    <li class=\"footer\">$generatedby\n    <a href=\"http://www.doxygen.org/index.html\">\n    <img class=\"footer\" src=\"$relpath^doxygen.png\" alt=\"doxygen\"/></a> $doxygenversion </li>\n  </ul>\n</div>\n<!--END GENERATE_TREEVIEW-->\n<!--BEGIN !GENERATE_TREEVIEW-->\n<hr class=\"footer\"/><address class=\"footer\"><small>\n$generatedby &#160;<a href=\"http://www.doxygen.org/index.html\">doxygen</a> $doxygenversion\n</small></address>\n<!--END !GENERATE_TREEVIEW-->\n</body>\n</html>\n"
  },
  {
    "path": "doc/router_header.html",
    "content": "<!-- HTML header for doxygen 1.8.9.1-->\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/xhtml;charset=UTF-8\"/>\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=9\"/>\n<meta name=\"generator\" content=\"Doxygen $doxygenversion\"/>\n<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME-->\n<!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME-->\n<link href=\"$relpath^tabs.css\" rel=\"stylesheet\" type=\"text/css\"/>\n<script type=\"text/javascript\" src=\"$relpath^jquery.js\"></script>\n<script type=\"text/javascript\" src=\"$relpath^dynsections.js\"></script>\n$treeview\n$search\n$mathjax\n<link href=\"$relpath^$stylesheet\" rel=\"stylesheet\" type=\"text/css\" />\n$extrastylesheet\n</head>\n<body>\n<div id=\"top\"><!-- do not remove this div, it is closed by doxygen! -->\n\n<!--BEGIN TITLEAREA-->\n<div id=\"titlearea\">\n<table cellspacing=\"0\" cellpadding=\"0\">\n <tbody>\n <tr style=\"height: 56px;\">\n  <!--BEGIN PROJECT_LOGO-->\n  <td id=\"projectlogo\"><img alt=\"Logo\" src=\"$relpath^$projectlogo\"/></td>\n  <!--END PROJECT_LOGO-->\n  <!--BEGIN PROJECT_NAME-->\n  <td style=\"padding-left: 0.5em;\">\n   <div id=\"projectname\">$projectname\n   <!--BEGIN PROJECT_NUMBER-->&#160;<span id=\"projectnumber\">$projectnumber</span><!--END PROJECT_NUMBER-->\n   </div>\n   <!--BEGIN PROJECT_BRIEF--><div id=\"projectbrief\">$projectbrief</div><!--END PROJECT_BRIEF-->\n  </td>\n  <!--END PROJECT_NAME-->\n  <!--BEGIN !PROJECT_NAME-->\n   <!--BEGIN PROJECT_BRIEF-->\n    <td style=\"padding-left: 0.5em;\">\n    <div id=\"projectbrief\">$projectbrief</div>\n    </td>\n   <!--END PROJECT_BRIEF-->\n  <!--END !PROJECT_NAME-->\n  <!--BEGIN DISABLE_INDEX-->\n   <!--BEGIN SEARCHENGINE-->\n   <td>$searchbox</td>\n   <!--END SEARCHENGINE-->\n  <!--END DISABLE_INDEX-->\n </tr>\n </tbody>\n</table>\n</div>\n<!--END TITLEAREA-->\n<!-- end header part -->\n"
  },
  {
    "path": "doc/sample_mysqlrouter.conf",
    "content": "\n# MySQL Router sample configuration\n#\n# The following is a sample configuration file which shows\n# most of the plugins available and most of their options.\n#\n# The paths used are defaults and should be adapted based\n# on how MySQL Router was installed, for example, using the\n# CMake option CMAKE_INSTALL_PREFIX\n#\n# The logging_folder is kept empty so message go to the\n# console.\n#\n\n#[DEFAULT]\n#logging_folder =\n#plugin_folder = /usr/local/lib/mysqlrouter\n#config_folder = /etc/mysql\n#runtime_folder = /var/run\n#data_folder = /var/lib\n#keyring_path = /var/lib/keyring-data\n#master_key_path = /var/lib/keyring-key\n\n#[logger]\n#level = INFO\n\n#[routing:basic_failover]\n# To be more transparent, use MySQL Server port 3306\n#bind_port = 7001\n#routing_strategy = first-available\n#mode = read-write\n#destinations = mysql-server1:3306,mysql-server2\n\n# If no plugin is configured which starts a service, keepalive\n# will make sure MySQL Router will not immediately exit. It is\n# safe to remove once Router is configured.\n[keepalive]\ninterval = 60\n"
  },
  {
    "path": "ext/RAPIDJSON-README",
    "content": "Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.\n\nThis program is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License, version 2.0,\nas published by the Free Software Foundation.\n\nThis program is also distributed with certain software (including\nbut not limited to OpenSSL) that is licensed under separate terms,\nas designated in a particular file or component or in included license\ndocumentation.  The authors of MySQL hereby grant you an additional\npermission to link the program and your derivative works with the\nseparately licensed software that they have included with MySQL.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License, version 2.0, for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA\n\n----\n\nThe rapidjson library included in this directory is based on\nhttps://github.com/miloyip/rapidjson, version 1.1.0.\n\nThe folder lib/jsonchecker is removed so that we don't include any code licensed\nunder the JSON License."
  },
  {
    "path": "ext/duktape/duktape-2.1.0/LICENSE.txt",
    "content": "===============\nDuktape license\n===============\n\n(http://opensource.org/licenses/MIT)\n\nCopyright (c) 2013-2017 by Duktape authors (see AUTHORS.rst)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/README.rst",
    "content": "=======\nDuktape\n=======\n\nDuktape is a small and portable Ecmascript E5/E5.1 implementation.  It is\nintended to be easily embeddable into C programs, with a C API similar in\nspirit to Lua's.\n\nDuktape supports the full E5/E5.1 feature set (with some semantics updated\nfrom ES2015+) including errors, Unicode strings, and regular expressions,\na subset of Ecmascript 2015 (E6) and Ecmascript 2016 (E7) features (e.g.\ncomputed property names, Proxy objects, exponentiation operator, Reflect),\nES2015 ArrayBuffer/TypedView, Node.js Buffer, and WHATWG Encoding API\nliving standard.\n\nDuktape also provides a number of custom features such as error tracebacks,\nadditional data types for better C integration, combined reference counting\nand mark-and sweep garbage collector, object finalizers, co-operative\nthreads a.k.a. coroutines, tail calls, a built-in debugger protocol, function\nbytecode dump/load, and so on.  Bundled extra modules provide functionality\nsuch as CommonJS module loading and a logging framework.\n\nYou can browse Duktape programmer's API and other documentation at:\n\n* http://duktape.org/\n\nIn particular, you should read the getting started section:\n\n* http://duktape.org/guide.html#gettingstarted\n\nMore examples and how-to articles are in the Duktape Wiki:\n\n* http://wiki.duktape.org/\n\nTo build an example command line tool with interactive evaluation (REPL) and\nthe ability to run script files::\n\n  $ cd <dist_root>\n  $ make -f Makefile.cmdline\n  [...]\n\n  $ ./duk\n  ((o) Duktape\n  duk> print('Hello world!');\n  Hello world!\n  = undefined\n\n  $ ./duk mandel.js\n  [...]\n\nTo integrate Duktape into your program:\n\n* Use ``tools/configure.py`` to prepare Duktape source and header files\n  for build::\n\n      # Duktape options can be customized via command line options.\n      # In this example, enable \"fastint\" support and disable ES2015\n      # Proxy support\n\n      $ python2 tools/configure.py --output-directory duktape-src \\\n            -DDUK_USE_FASTINT -UDUK_USE_ES6_PROXY\n\n* The output directory (duktape-src) will then contain ``duktape.c``,\n  ``duktape.h``, and ``duk_config.h`` which you include in your build.\n\nFor more details, see:\n\n* http://duktape.org/guide.html#compiling\n\n* http://wiki.duktape.org/Configuring.html\n\nThis distributable contains:\n\n* Pre-configured Duktape header and source files using the Duktape default\n  configuration:\n\n  * ``src/``: main Duktape library in a \"single source file\" format (duktape.c,\n    duktape.h, and duk_config.h).\n\n  * ``src-noline/``: contains a variant of ``src/duktape.c`` with no ``#line``\n    directives which is preferable for some users.  See discussion in\n    https://github.com/svaarala/duktape/pull/363.\n\n  * ``src-separate/``: main Duktape library in multiple files format.\n\n* ``src-input/``: raw input source files used by ``configure.py`` which\n  recreates the combined/separate prepared sources with specific options.\n\n* ``tools/``: various Python tools, such as ``configure.py`` for preparing\n  a ``duk_config.h`` header and Duktape source files for compilation, see\n  http://wiki.duktape.org/Configuring.html.\n\n* ``config/``: configuration metadata for ``configure.py``.\n\n* ``examples/``: further examples for using Duktape.  Although Duktape\n  itself is widely portable, some of the examples are Linux only.\n  For instance the ``eventloop`` example illustrates how ``setTimeout()``\n  and other standard timer functions could be implemented on Unix/Linux.\n\n* ``extras/``: utilities and modules which don't comfortably fit into the\n  main Duktape library because of footprint or portability concerns.\n  Extras are maintained and bug fixed code, but don't have the same version\n  guarantees as the main Duktape library.\n\n* ``polyfills/``: a few replacement suggestions for non-standard Javascript\n  functions provided by other implementations.\n\n* ``debugger/``: a debugger with a web UI, see ``debugger/README.rst`` and\n  https://github.com/svaarala/duktape/blob/master/doc/debugger.rst for\n  details on Duktape debugger support.  Also contains a JSON debug proxy\n  (one written in Node.js and another in DukLuv) to make talking to the\n  debug target easier.\n\n* ``licenses/``: licensing information.\n\nYou can find release notes at:\n\n* https://github.com/svaarala/duktape/blob/master/RELEASES.rst\n  (summary of all versions)\n\n* https://github.com/svaarala/duktape/blob/master/doc/release-notes-v2-1.rst\n  (more detailed notes for this version)\n\nThis distributable contains Duktape version 2.1.0, created from git\ncommit 1f1f51a4f9595ffe8def0e9ba45b20f14679393a (v2.1.0).\n\nDuktape is copyrighted by its authors (see ``AUTHORS.rst``) and licensed\nunder the MIT license (see ``LICENSE.txt``).  String hashing algorithms are\nbased on the algorithm from Lua (MIT license), djb2 hash, and Murmurhash2\n(MIT license).  Pseudorandom number generator algorithms are based on\nAdi Shamir's three-op algorithm, xoroshiro128+ (public domain), and SplitMix64\n(public domain).  Duktape module loader is based on the CommonJS module\nloading specification (without sharing any code), CommonJS is under the MIT\nlicense.\n\nHave fun!\n\nSami Vaarala (sami.vaarala@iki.fi)\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/README.rst",
    "content": "==============\nDuktape extras\n==============\n\nExtra modules and utilities.  Extras provide functionality that doesn't\ncomfortably fit into the main Duktape library, perhaps for footprint or\nportability reasons, but are still useful for most users.\n\nExtras are maintained and will be bug fixed.  However, they don't have the\nsame semantic versioning guarantees like the main Duktape library.  Extras\nmay be dropped without warning as Duktape is versioned.  For instance, if\nan extra breaks due to Duktape changes and there is no time to fix it, the\nmissing extra won't block a release and will be dropped.\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/alloc-pool/Makefile",
    "content": "# For manual testing; say 'make' in extras/alloc-pool and run ./test.\n\nDEFS=\n#DEFS+='-DDUK_ALLOC_POOL_DEBUG'\n\n.PHONY: test\ntest:\n\trm -rf ./prep\n\techo 'DUK_USE_FATAL_HANDLER:' > opts.yaml\n\techo '  verbatim: \"#define DUK_USE_FATAL_HANDLER(udata,msg) my_fatal((msg))\"' >> opts.yaml\n\tpython2 ../../tools/configure.py \\\n\t\t--output-directory ./prep \\\n\t\t--option-file ./opts.yaml \\\n\t\t--fixup-line 'extern void my_fatal(const char *msg);'\n\tgcc -std=c99 -Wall -Wextra -m32 -Os -otest \\\n\t\t-I./prep ./prep/duktape.c \\\n\t\t$(DEFS) \\\n\t\tduk_alloc_pool.c test.c \\\n\t\t-lm\n\t./test 'print(\"foo\", \"bar\", 1, 2, 3)'\n\t./test 'alert(\"foo\", \"bar\", 1, 2, 3)'\n\n.PHONY: ptrcomptest\nptrcomptest:\n\trm -rf ./prep\n\techo 'DUK_USE_FATAL_HANDLER:' > opts.yaml\n\techo '  verbatim: \"#define DUK_USE_FATAL_HANDLER(udata,msg) my_fatal((msg))\"' >> opts.yaml\n\tpython2 ../../tools/configure.py \\\n\t\t--output-directory ./prep \\\n\t\t--option-file ./opts.yaml \\\n\t\t--fixup-line 'extern void my_fatal(const char *msg);' \\\n\t\t--option-file ../../config/examples/low_memory.yaml \\\n\t\t--option-file ptrcomp.yaml \\\n\t\t--fixup-file ptrcomp_fixup.h\n\tgcc -std=c99 -Wall -Wextra -m32 -Os -optrcomptest \\\n\t\t-I. -I./prep ./prep/duktape.c \\\n\t\t$(DEFS) \\\n\t\tduk_alloc_pool.c test.c \\\n\t\t-lm\n\t./ptrcomptest 'print(\"foo\", \"bar\", 1, 2, 3)'\n\t./ptrcomptest 'alert(\"foo\", \"bar\", 1, 2, 3)'\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/alloc-pool/README.rst",
    "content": "=====================================\nPool allocator for low memory targets\n=====================================\n\nA simple pool allocator which satisfies allocations from preallocated pools\ncontaining blocks of a certain size.  The caller provides a continuous memory\nregion and a pool configuration when initializing the allocator.\n\nThe pool configuration specifies the block sizes used, and parameters to\ncontrol how many entries are allocated for each block size.  The parameters\nare specified with respect to an arbitrary floating point scaling parameter\n``t`` as follows::\n\n    bytes = A*t + B\n    count = floor(bytes / block_size)\n          = floor((A*t + B) / block_size)\n\n    A: constant which indicates how quickly more bytes are assigned for this\n       block size as the total allocation grows\n\n    B: constant which indicates the base allocation for this block size, i.e.\n       the allocated needed by Duktape initialization\n\nPool initialization finds the largest floating point ``t`` which still fits in\nthe memory region provided.  Any leftover bytes are sprinkled to the pools to\nminimize wasted space.\n\nA pool configuration can be written manually (by trial and error) or using\nsome automatic tooling such as ``pool_simulator.py``.\n\nWhen using pointer compression only a single global pool is supported.  This\nreduces code footprint and is usually sufficient in low memory targets.\n\nPointer compression functions are defined as inline functions in\n``duk_alloc_pool.h`` to allow the compiler to inline pointer compression when\nappropriate.  As a side effect ``duk_config.h`` must include\n``duk_alloc_pool.h`` so that the declarations are visible when compiling\nDuktape.\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/alloc-pool/duk_alloc_pool.c",
    "content": "/*\n *  Pool allocator for low memory targets.\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdint.h>\n#include <stdarg.h>\n#include \"duktape.h\"\n#include \"duk_alloc_pool.h\"\n\n/* Define to enable some debug printfs. */\n/* #define DUK_ALLOC_POOL_DEBUG */\n\n#if defined(DUK_ALLOC_POOL_ROMPTR_COMPRESSION)\n#if 0  /* This extern declaration is provided by duktape.h, array provided by duktape.c. */\nextern const void * const duk_rom_compressed_pointers[];\n#endif\nconst void *duk_alloc_pool_romptr_low = NULL;\nconst void *duk_alloc_pool_romptr_high = NULL;\nstatic void duk__alloc_pool_romptr_init(void);\n#endif\n\n#if defined(DUK_USE_HEAPPTR16)\nvoid *duk_alloc_pool_ptrcomp_base = NULL;\n#endif\n\n#if defined(DUK_ALLOC_POOL_DEBUG)\nstatic void duk__alloc_pool_dprintf(const char *fmt, ...) {\n\tva_list ap;\n\tva_start(ap, fmt);\n\tvfprintf(stderr, fmt, ap);\n\tva_end(ap);\n}\n#endif\n\n/*\n *  Pool initialization\n */\n\nvoid *duk_alloc_pool_init(char *buffer,\n                          size_t size,\n                          const duk_pool_config *configs,\n                          duk_pool_state *states,\n                          int num_pools,\n                          duk_pool_global *global) {\n\tdouble t_min, t_max, t_curr, x;\n\tint step, i, j, n;\n\tsize_t total;\n\tchar *p;\n\n\t/* XXX: check that 'size' is not too large when using pointer\n\t * compression.\n\t */\n\n\t/* To optimize pool counts first come up with a 't' which still allows\n\t * total pool size to fit within user provided region.  After that\n\t * sprinkle any remaining bytes to the counts.  Binary search with a\n\t * fixed step count; last round uses 't_min' as 't_curr' to ensure it\n\t * succeeds.\n\t */\n\n\tt_min = 0.0;  /* Unless config is insane, this should always be \"good\". */\n\tt_max = 1e6;\n\n\tfor (step = 0; ; step++) {\n\t\tif (step >= 100) {\n\t\t\t/* Force \"known good\", rerun config, and break out.\n\t\t\t * Deals with rounding corner cases where t_curr is\n\t\t\t * persistently \"bad\" even though t_min is a valid\n\t\t\t * solution.\n\t\t\t */\n\t\t\tt_curr = t_min;\n\t\t} else {\n\t\t\tt_curr = (t_min + t_max) / 2.0;\n\t\t}\n\n\t\tfor (i = 0, total = 0; i < num_pools; i++) {\n\t\t\tstates[i].size = configs[i].size;\n\n\t\t\t/* Target bytes = A*t + B ==> target count = (A*t + B) / block_size.\n\t\t\t * Rely on A and B being small enough so that 'x' won't wrap.\n\t\t\t */\n\t\t\tx = ((double) configs[i].a * t_curr + (double) configs[i].b) / (double) configs[i].size;\n\n\t\t\tstates[i].count = (unsigned int) x;\n\t\t\ttotal += (size_t) states[i].size * (size_t) states[i].count;\n\t\t\tif (total > size) {\n\t\t\t\tgoto bad;\n\t\t\t}\n\t\t}\n\n\t\t/* t_curr is good. */\n#if defined(DUK_ALLOC_POOL_DEBUG)\n\t\tduk__alloc_pool_dprintf(\"duk_alloc_pool_init: step=%d, t=[%lf %lf %lf] -> total %ld/%ld (good)\\n\",\n\t\t                        step, t_min, t_curr, t_max, (long) total, (long) size);\n#endif\n\t\tif (step >= 100) {\n\t\t\t/* Keep state[] initialization state.  The state was\n\t\t\t * created using the highest 't_min'.\n\t\t\t */\n\t\t\tbreak;\n\t\t}\n\t\tt_min = t_curr;\n\t\tcontinue;\n\n\t bad:\n\t\t/* t_curr is bad. */\n#if defined(DUK_ALLOC_POOL_DEBUG)\n\t\tduk__alloc_pool_dprintf(\"duk_alloc_pool_init: step=%d, t=[%lf %lf %lf] -> total %ld/%ld (bad)\\n\",\n\t\t                        step, t_min, t_curr, t_max, (long) total, (long) size);\n#endif\n\n\t\tif (step >= 1000) {\n\t\t\t/* Cannot find any good solution; shouldn't happen\n\t\t\t * unless config is bad or 'size' is so small that\n\t\t\t * even a baseline allocation won't fit.\n\t\t\t */\n\t\t\treturn NULL;\n\t\t}\n\t\tt_max = t_curr;\n\t\t/* continue */\n\t}\n\n\t/* The base configuration is now good; sprinkle any leftovers to\n\t * pools in descending order.  Note that for good t_curr, 'total'\n\t * indicates allocated bytes so far and 'size - total' indicates\n\t * leftovers.\n\t */\n\tfor (i = num_pools - 1; i >= 0; i--) {\n\t\twhile (size - total >= states[i].size) {\n\t\t\t/* Ignore potential wrapping of states[i].count as the count\n\t\t\t * is 32 bits and shouldn't wrap in practice.\n\t\t\t */\n\t\t\tstates[i].count++;\n\t\t\ttotal += states[i].size;\n#if defined(DUK_ALLOC_POOL_DEBUG)\n\t\t\tduk__alloc_pool_dprintf(\"duk_alloc_pool_init: sprinkle %ld bytes (%ld left after)\\n\",\n\t\t\t                        (long) states[i].size, (long) (size - total));\n#endif\n\t\t}\n\t}\n\n\t/* Pool counts are final.  Allocate the user supplied region based\n\t * on the final counts, initialize free lists for each block size,\n\t * and otherwise finalize 'state' for use.\n\t */\n\tp = buffer;\n\tglobal->states = states;\n\tglobal->num_pools = num_pools;\n\n#if defined(DUK_USE_HEAPPTR16)\n\t/* Register global base value for pointer compression, assumes\n\t * a single active pool  -4 allows a single subtract to be used and\n\t * still ensures no non-NULL pointer encodes to zero.\n\t */\n\tduk_alloc_pool_ptrcomp_base = (void *) (p - 4);\n#endif\n\n\tfor (i = 0; i < num_pools; i++) {\n\t\tn = states[i].count;\n\t\tif (n > 0) {\n\t\t\tstates[i].first = (duk_pool_free *) p;\n\t\t\tfor (j = 0; j < n; j++) {\n\t\t\t\tchar *p_next = p + states[i].size;\n\t\t\t\t((duk_pool_free *) p)->next =\n\t\t\t\t\t(j == n - 1) ? (duk_pool_free *) NULL : (duk_pool_free *) p_next;\n\t\t\t\tp = p_next;\n\t\t\t}\n\t\t} else {\n\t\t\tstates[i].first = (duk_pool_free *) NULL;\n\t\t}\n\t\tstates[i].alloc_end = p;  /* All members of 'state' now initialized. */\n\n#if defined(DUK_ALLOC_POOL_DEBUG)\n\t\tduk__alloc_pool_dprintf(\"duk_alloc_pool_init: block size %5ld, count %5ld, %8ld total bytes, \"\n\t\t                        \"end %p\\n\",\n\t\t                        (long) states[i].size, (long) states[i].count,\n\t\t                        (long) states[i].size * (long) states[i].count,\n\t\t                        (void *) states[i].alloc_end);\n#endif\n\t}\n\n#if defined(DUK_ALLOC_POOL_ROMPTR_COMPRESSION)\n\t/* ROM pointer compression precomputation.  Assumes a single active\n\t * pool.\n\t */\n\tduk__alloc_pool_romptr_init();\n#endif\n\n\t/* Use 'global' as udata. */\n\treturn (void *) global;\n}\n\n/*\n *  Allocation providers\n */\n\nvoid *duk_alloc_pool(void *udata, duk_size_t size) {\n\tduk_pool_global *g = (duk_pool_global *) udata;\n\tint i, n;\n\n#if defined(DUK_ALLOC_POOL_DEBUG)\n\tduk__alloc_pool_dprintf(\"duk_alloc_pool: %p %ld\\n\", udata, (long) size);\n#endif\n\n\tif (size == 0) {\n\t\treturn NULL;\n\t}\n\n\tfor (i = 0, n = g->num_pools; i < n; i++) {\n\t\tduk_pool_state *st = g->states + i;\n\n\t\tif (size <= st->size && st->first != NULL) {\n\t\t\tduk_pool_free *res = st->first;\n\t\t\tst->first = res->next;\n\t\t\treturn (void *) res;\n\t\t}\n\n\t\t/* Allocation doesn't fit or no free entries, try to borrow\n\t\t * from the next block size.  There's no support for preventing\n\t\t * a borrow at present.\n\t\t */\n\t}\n\n\treturn NULL;\n}\n\nvoid *duk_realloc_pool(void *udata, void *ptr, duk_size_t size) {\n\tduk_pool_global *g = (duk_pool_global *) udata;\n\tint i, j, n;\n\n#if defined(DUK_ALLOC_POOL_DEBUG)\n\tduk__alloc_pool_dprintf(\"duk_realloc_pool: %p %p %ld\\n\", udata, ptr, (long) size);\n#endif\n\n\tif (ptr == NULL) {\n\t\treturn duk_alloc_pool(udata, size);\n\t}\n\tif (size == 0) {\n\t\tduk_free_pool(udata, ptr);\n\t\treturn NULL;\n\t}\n\n\t/* Non-NULL pointers are necessarily from the pool so we should\n\t * always be able to find the allocation.\n\t */\n\n\tfor (i = 0, n = g->num_pools; i < n; i++) {\n\t\tduk_pool_state *st = g->states + i;\n\t\tchar *new_ptr;\n\n\t\t/* Because 'ptr' is assumed to be in the pool and pools are\n\t\t * allocated in sequence, it suffices to check for end pointer\n\t\t * only.\n\t\t */\n\t\tif ((char *) ptr >= st->alloc_end) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (size <= st->size) {\n\t\t\t/* Allocation still fits existing allocation.  Check if\n\t\t\t * we can shrink the allocation to a smaller block size\n\t\t\t * (smallest possible).\n\t\t\t */\n\t\t\tfor (j = 0; j < i; j++) {\n\t\t\t\tduk_pool_state *st2 = g->states + j;\n\n\t\t\t\tif (size <= st2->size && st2->first != NULL) {\n#if defined(DUK_ALLOC_POOL_DEBUG)\n\t\t\t\t\tduk__alloc_pool_dprintf(\"duk_realloc_pool: shrink, block size %ld -> %ld\\n\",\n\t\t\t\t\t                        (long) st->size, (long) st2->size);\n#endif\n\t\t\t\t\tnew_ptr = (char *) st2->first;\n\t\t\t\t\tst2->first = ((duk_pool_free *) new_ptr)->next;\n\t\t\t\t\tmemcpy((void *) new_ptr, (const void *) ptr, (size_t) size);\n\t\t\t\t\t((duk_pool_free *) ptr)->next = st->first;\n\t\t\t\t\tst->first = (duk_pool_free *) ptr;\n\t\t\t\t\treturn (void *) new_ptr;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/* Failed to shrink; return existing pointer. */\n\t\t\treturn ptr;\n\t\t}\n\n\t\t/* Find first free larger block. */\n\t\tfor (j = i + 1; j < n; j++) {\n\t\t\tduk_pool_state *st2 = g->states + j;\n\n\t\t\tif (size <= st2->size && st2->first != NULL) {\n\t\t\t\tnew_ptr = (char *) st2->first;\n\t\t\t\tst2->first = ((duk_pool_free *) new_ptr)->next;\n\t\t\t\tmemcpy((void *) new_ptr, (const void *) ptr, (size_t) st->size);\n\t\t\t\t((duk_pool_free *) ptr)->next = st->first;\n\t\t\t\tst->first = (duk_pool_free *) ptr;\n\t\t\t\treturn (void *) new_ptr;\n\t\t\t}\n\t\t}\n\n\t\t/* Failed to resize. */\n\t\treturn NULL;\n\t}\n\n\t/* We should never be here because 'ptr' should be a valid pool\n\t * entry and thus always found above.\n\t */\n\treturn NULL;\n}\n\nvoid duk_free_pool(void *udata, void *ptr) {\n\tduk_pool_global *g = (duk_pool_global *) udata;\n\tint i, n;\n\n#if defined(DUK_ALLOC_POOL_DEBUG)\n\tduk__alloc_pool_dprintf(\"duk_free_pool: %p %p\\n\", udata, ptr);\n#endif\n\n\tif (ptr == NULL) {\n\t\treturn;\n\t}\n\n\tfor (i = 0, n = g->num_pools; i < n; i++) {\n\t\tduk_pool_state *st = g->states + i;\n\n\t\t/* Enough to check end address only. */\n\t\tif ((char *) ptr >= st->alloc_end) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t((duk_pool_free *) ptr)->next = st->first;\n\t\tst->first = (duk_pool_free *) ptr;\n\t\treturn;\n\t}\n\n\t/* We should never be here because 'ptr' should be a valid pool\n\t * entry and thus always found above.\n\t */\n}\n\n/*\n *  Pointer compression\n */\n\n#if defined(DUK_ALLOC_POOL_ROMPTR_COMPRESSION)\nstatic void duk__alloc_pool_romptr_init(void) {\n\t/* Scan ROM pointer range for faster detection of \"is 'p' a ROM pointer\"\n\t * later on.\n\t */\n\tconst void * const * ptrs = (const void * const *) duk_rom_compressed_pointers;\n\tduk_alloc_pool_romptr_low = duk_alloc_pool_romptr_high = (const void *) *ptrs;\n\twhile (*ptrs) {\n\t\tif (*ptrs > duk_alloc_pool_romptr_high) {\n\t\t\tduk_alloc_pool_romptr_high = (const void *) *ptrs;\n\t\t}\n\t\tif (*ptrs < duk_alloc_pool_romptr_low) {\n\t\t\tduk_alloc_pool_romptr_low = (const void *) *ptrs;\n\t\t}\n\t\tptrs++;\n\t}\n}\n#endif\n\n/* Encode/decode functions are defined in the header to allow inlining. */\n\n#if defined(DUK_ALLOC_POOL_ROMPTR_COMPRESSION)\nduk_uint16_t duk_alloc_pool_enc16_rom(void *ptr) {\n\t/* The if-condition should be the fastest possible check\n\t * for \"is 'ptr' in ROM?\".  If pointer is in ROM, we'd like\n\t * to compress it quickly.  Here we just scan a ~1K array\n\t * which is very bad for performance.\n\t */\n\tconst void * const * ptrs = duk_rom_compressed_pointers;\n\twhile (*ptrs) {\n\t\tif (*ptrs == ptr) {\n\t\t\treturn DUK_ALLOC_POOL_ROMPTR_FIRST + (duk_uint16_t) (ptrs - duk_rom_compressed_pointers);\n\t\t}\n\t\tptrs++;\n\t}\n\n\t/* We should really never be here: Duktape should only be\n\t * compressing pointers which are in the ROM compressed\n\t * pointers list, which are known at 'make dist' time.\n\t * We go on, causing a pointer compression error.\n\t */\n\treturn 0;\n}\n#endif\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/alloc-pool/duk_alloc_pool.h",
    "content": "#if !defined(DUK_ALLOC_POOL_H_INCLUDED)\n#define DUK_ALLOC_POOL_H_INCLUDED\n\n#include \"duktape.h\"\n\n/* Pointer compression with ROM strings/objects:\n *\n * For now, use DUK_USE_ROM_OBJECTS to signal the need for compressed ROM\n * pointers.  DUK_USE_ROM_PTRCOMP_FIRST is provided for the ROM pointer\n * compression range minimum to avoid duplication in user code.\n */\n#if defined(DUK_USE_ROM_OBJECTS) && defined(DUK_USE_HEAPPTR16)\n#define DUK_ALLOC_POOL_ROMPTR_COMPRESSION\n#define DUK_ALLOC_POOL_ROMPTR_FIRST DUK_USE_ROM_PTRCOMP_FIRST\n\n/* This extern declaration is provided by duktape.h, array provided by duktape.c.\n * Because duk_config.h may include this file (to get the inline functions) we\n * need to forward declare this also here.\n */\nextern const void * const duk_rom_compressed_pointers[];\n#endif\n\n/* Pool configuration for a certain block size. */\ntypedef struct {\n\tunsigned int size;\n\tunsigned int a;  /* bytes (not count) to allocate: a*t + b, t is an arbitrary scale parameter */\n\tunsigned int b;\n} duk_pool_config;\n\n/* Freelist entry, must fit into the smallest block size. */\nstruct duk_pool_free;\ntypedef struct duk_pool_free duk_pool_free;\nstruct duk_pool_free {\n\tduk_pool_free *next;\n};\n\n/* Pool state for a certain block size. */\ntypedef struct {\n\tduk_pool_free *first;\n\tchar *alloc_end;\n\tunsigned int size;\n\tunsigned int count;\n} duk_pool_state;\n\n/* Top level state for all pools.  Pointer to this struct is used as the allocator\n * userdata pointer.\n */\ntypedef struct {\n\tint num_pools;\n\tduk_pool_state *states;\n} duk_pool_global;\n\n/* Initialize a pool allocator, arguments:\n *   - buffer and size: continuous region to use for pool\n *   - config: configuration for pools in ascending block size\n *   - state: state for pools, matches config order\n *   - num_pools: number of entries in 'config' and 'state'\n *   - global: global state structure\n *\n * The 'config', 'state', and 'global' pointers must be valid beyond the init\n * call, as long as the pool is used.\n *\n * Returns a void pointer to be used as userdata for the allocator functions.\n * Concretely the return value will be \"(void *) global\", i.e. the global\n * state struct.  If pool init fails, the return value will be NULL.\n */\nvoid *duk_alloc_pool_init(char *buffer,\n                          size_t size,\n                          const duk_pool_config *configs,\n                          duk_pool_state *states,\n                          int num_pools,\n                          duk_pool_global *global);\n\n/* Duktape allocation providers.  Typing matches Duktape requirements. */\nvoid *duk_alloc_pool(void *udata, duk_size_t size);\nvoid *duk_realloc_pool(void *udata, void *ptr, duk_size_t size);\nvoid duk_free_pool(void *udata, void *ptr);\n\n/* Duktape pointer compression global state (assumes single pool). */\n#if defined(DUK_USE_ROM_OBJECTS) && defined(DUK_USE_HEAPPTR16)\nextern const void *duk_alloc_pool_romptr_low;\nextern const void *duk_alloc_pool_romptr_high;\nduk_uint16_t duk_alloc_pool_enc16_rom(void *ptr);\n#endif\n#if defined(DUK_USE_HEAPPTR16)\nextern void *duk_alloc_pool_ptrcomp_base;\n#endif\n\n#if 0\nduk_uint16_t duk_alloc_pool_enc16(void *ptr);\nvoid *duk_alloc_pool_dec16(duk_uint16_t val);\n#endif\n\n/* Inlined pointer compression functions.  Gcc and clang -Os won't in\n * practice inline these because it's more size efficient (by about\n * 3kB) to use explicit calls instead.  Having these defined inline\n * here allows performance optimized builds to inline pointer compression\n * operations.\n *\n * Pointer compression assumes there's a single globally registered memory\n * pool which makes pointer compression more efficient.  This would be easy\n * to fix by adding a userdata pointer to the compression functions and\n * plumbing the heap userdata from the compression/decompression macros.\n */\n\n#if defined(DUK_USE_HEAPPTR16)\nstatic inline duk_uint16_t duk_alloc_pool_enc16(void *ptr) {\n\tif (ptr == NULL) {\n\t\t/* With 'return 0' gcc and clang -Os generate inefficient code.\n\t\t * For example, gcc -Os generates:\n\t\t *\n\t\t *   0804911d <duk_alloc_pool_enc16>:\n\t\t *    804911d:       55                      push   %ebp\n\t\t *    804911e:       85 c0                   test   %eax,%eax\n\t\t *    8049120:       89 e5                   mov    %esp,%ebp\n\t\t *    8049122:       74 0b                   je     804912f <duk_alloc_pool_enc16+0x12>\n\t\t *    8049124:       2b 05 e4 90 07 08       sub    0x80790e4,%eax\n\t\t *    804912a:       c1 e8 02                shr    $0x2,%eax\n\t\t *    804912d:       eb 02                   jmp    8049131 <duk_alloc_pool_enc16+0x14>\n\t\t *    804912f:       31 c0                   xor    %eax,%eax\n\t\t *    8049131:       5d                      pop    %ebp\n\t\t *    8049132:       c3                      ret\n\t\t *\n\t\t * The NULL path checks %eax for zero; if it is zero, a zero\n\t\t * is unnecessarily loaded into %eax again.  The non-zero path\n\t\t * has an unnecessary jump as a side effect of this.\n\t\t *\n\t\t * Using 'return (duk_uint16_t) (intptr_t) ptr;' generates similarly\n\t\t * inefficient code; not sure how to make the result better.\n\t\t */\n\t\treturn 0;\n\t}\n#if defined(DUK_ALLOC_POOL_ROMPTR_COMPRESSION)\n\tif (ptr >= duk_alloc_pool_romptr_low && ptr <= duk_alloc_pool_romptr_high) {\n\t\t/* This is complex enough now to need a separate function. */\n\t\treturn duk_alloc_pool_enc16_rom(ptr);\n\t}\n#endif\n\treturn (duk_uint16_t) (((size_t) ((char *) ptr - (char *) duk_alloc_pool_ptrcomp_base)) >> 2);\n}\n\nstatic inline void *duk_alloc_pool_dec16(duk_uint16_t val) {\n\tif (val == 0) {\n\t\t/* As with enc16 the gcc and clang -Os output is inefficient,\n\t\t * e.g. gcc -Os:\n\t\t *\n\t\t *   08049133 <duk_alloc_pool_dec16>:\n\t\t *    8049133:       55                      push   %ebp\n\t\t *    8049134:       66 85 c0                test   %ax,%ax\n\t\t *    8049137:       89 e5                   mov    %esp,%ebp\n\t\t *    8049139:       74 0e                   je     8049149 <duk_alloc_pool_dec16+0x16>\n\t\t *    804913b:       8b 15 e4 90 07 08       mov    0x80790e4,%edx\n\t\t *    8049141:       0f b7 c0                movzwl %ax,%eax\n\t\t *    8049144:       8d 04 82                lea    (%edx,%eax,4),%eax\n\t\t *    8049147:       eb 02                   jmp    804914b <duk_alloc_pool_dec16+0x18>\n\t\t *    8049149:       31 c0                   xor    %eax,%eax\n\t\t *    804914b:       5d                      pop    %ebp\n\t\t *    804914c:       c3                      ret\n\t\t */\n\t\treturn NULL;\n\t}\n#if defined(DUK_ALLOC_POOL_ROMPTR_COMPRESSION)\n\tif (val >= DUK_ALLOC_POOL_ROMPTR_FIRST) {\n\t\t/* This is a blind lookup, could check index validity.\n\t\t * Duktape should never decompress a pointer which would\n\t\t * be out-of-bounds here.\n\t\t */\n\t\treturn (void *) (intptr_t) (duk_rom_compressed_pointers[val - DUK_ALLOC_POOL_ROMPTR_FIRST]);\n\t}\n#endif\n\treturn (void *) ((char *) duk_alloc_pool_ptrcomp_base + (((size_t) val) << 2));\n}\n#endif\n\n#endif  /* DUK_ALLOC_POOL_H_INCLUDED */\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/alloc-pool/ptrcomp.yaml",
    "content": "DUK_USE_REFCOUNT16: true\nDUK_USE_STRHASH16: true\nDUK_USE_STRLEN16: true\nDUK_USE_BUFLEN16: true\nDUK_USE_OBJSIZES16: true\nDUK_USE_HSTRING_CLEN: false\nDUK_USE_HOBJECT_HASH_PART: false\nDUK_USE_HEAPPTR16: true\nDUK_USE_HEAPPTR_ENC16:\n  verbatim: \"#define DUK_USE_HEAPPTR_ENC16(ud,p) duk_alloc_pool_enc16((p))\"\nDUK_USE_HEAPPTR_DEC16:\n  verbatim: \"#define DUK_USE_HEAPPTR_DEC16(ud,p) duk_alloc_pool_dec16((p))\"\n\n#DUK_USE_ROM_OBJECTS: true\n#DUK_USE_ROM_STRINGS: true\n#DUK_USE_ROM_GLOBAL_INHERIT: true\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/alloc-pool/ptrcomp_fixup.h",
    "content": "/* To provide declarations for inline pointer compression functions. */\n#include \"duk_alloc_pool.h\"\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/alloc-pool/test.c",
    "content": "#include <stdio.h>\n#include <stdlib.h>\n#include \"duktape.h\"\n#include \"duk_alloc_pool.h\"\n\nvoid my_fatal(const char *msg) {\n\tfprintf(stderr, \"*** FATAL: %s\\n\", msg ? msg : \"no message\");\n\tfflush(stderr);\n\tabort();\n}\n\nstatic duk_ret_t my_print(duk_context *ctx) {\n\tduk_push_string(ctx, \" \");\n\tduk_insert(ctx, 0);\n\tduk_join(ctx, duk_get_top(ctx) - 1);\n\tprintf(\"%s\\n\", duk_safe_to_string(ctx, -1));\n\treturn 1;\n}\n\nstatic void dump_pool_state(duk_pool_global *g) {\n\tint i;\n\tlong total_size = 0;\n\tlong total_used = 0;\n\n\tfor (i = 0; i < g->num_pools; i++) {\n\t\tduk_pool_state *st = g->states + i;\n\t\tint free, used;\n\t\tduk_pool_free *f;\n\n\t\tfor (free = 0, f = st->first; f; f = f->next) {\n\t\t\tfree++;\n\t\t}\n\t\tused = st->count - free;\n\t\tprintf(\"Pool %2d: block size %5d, count %4d/%4d, bytes %6d/%6d\\n\",\n\t\t       i, (int) st->size, used, (int) st->count,\n\t\t       (int) st->size * used, (int) st->size * (int) st->count);\n\n\t\ttotal_size += (long) st->size * (long) st->count;\n\t\ttotal_used += (long) st->size * (long) used;\n\t}\n\tprintf(\"=== Total: %ld/%ld, free %ld\\n\",\n\t       (long) total_used, (long) total_size, (long) (total_size - total_used));\n}\n\nint main(int argc, char *argv[]) {\n\tduk_context *ctx;\n\tint i;\n\tint exitcode = 0;\n\n\t/* NOTE! This pool configuration is NOT a good pool configuration\n\t * for practical use (and is not intended to be one).  A production\n\t * pool configuration should be created using measurements.\n\t */\n\tconst duk_pool_config pool_configs[15] = {\n\t\t{ 16, 20, 200 },\n\t\t{ 20, 40, 100 },\n\t\t{ 24, 40, 100 },\n\t\t{ 32, 60, 50 },\n\t\t{ 40, 60, 50 },\n\t\t{ 48, 60, 50 },\n\t\t{ 56, 60, 50 },\n\t\t{ 64, 60, 50 },\n\t\t{ 80, 60, 50 },\n\t\t{ 256, 100, 10 },\n\t\t{ 1024, 20, 2 },\n\t\t{ 2048, 20, 2 },\n\t\t{ 4096, 100, 2 },\n\t\t{ 6144, 60, 2 },\n\t\t{ 8192, 100, 2 },\n\t};\n\tduk_pool_state pool_states[15];  /* Count must match pool_configs[]. */\n\tduk_pool_global pool_global;\n\n\tchar buffer[200000];\n\tvoid *pool_udata;\n\n\tpool_udata = duk_alloc_pool_init(buffer, sizeof(buffer), pool_configs, pool_states, sizeof(pool_configs) / sizeof(duk_pool_config), &pool_global);\n\tif (!pool_udata) {\n\t\treturn 1;\n\t}\n\n\tprintf(\"Pool after pool init:\\n\");\n\tdump_pool_state(&pool_global);\n\n\tctx = duk_create_heap(duk_alloc_pool, duk_realloc_pool, duk_free_pool, pool_udata, NULL);\n\tif (!ctx) {\n\t\treturn 1;\n\t}\n\n\tprintf(\"Pool after Duktape heap creation:\\n\");\n\tdump_pool_state(&pool_global);\n\n\tduk_push_c_function(ctx, my_print, DUK_VARARGS);\n\tduk_put_global_string(ctx, \"print\");\n\tduk_push_c_function(ctx, my_print, DUK_VARARGS);\n\tduk_put_global_string(ctx, \"alert\");\n\tprintf(\"top after init: %ld\\n\", (long) duk_get_top(ctx));\n\n\tfor (i = 1; i < argc; i++) {\n\t\tprintf(\"Evaling: %s\\n\", argv[i]);\n\t\tif (duk_peval_string(ctx, argv[i]) != 0) {\n\t\t\texitcode = 1;\n\t\t}\n\t\tprintf(\"--> %s\\n\", duk_safe_to_string(ctx, -1));\n\t\tduk_pop(ctx);\n\t}\n\n\tprintf(\"Pool after evaling code:\\n\");\n\tdump_pool_state(&pool_global);\n\n\tprintf(\"Done\\n\");\n\tduk_destroy_heap(ctx);\n\treturn exitcode;\n}\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/console/Makefile",
    "content": "# For manual testing; say 'make' in extras/print-alert and run ./test.\n\n.PHONY: test\ntest:\n\tgcc -std=c99 -Wall -Wextra -o $@ -I../../src/ -I. ../../src/duktape.c duk_console.c test.c -lm\n\t./test 'console.assert(true, \"not shown\");'\n\t./test 'console.assert(false, \"shown\", { foo: 123 });'\n\t./test 'console.log(1, 2, 3, { foo: \"bar\" });'\n\t./test 'a={}; b={}; a.ref=b; console.log(a,b); b.ref=a; console.log(a,b)'  # circular ref\n\t./test 'console.trace(1, 2, 3)'\n\t./test 'console.dir({ foo: 123, bar: [ \"foo\", \"bar\" ]});'\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/console/README.rst",
    "content": "=========================\nMinimal 'console' binding\n=========================\n\nDuktape doesn't provide a ``console`` binding (for example ``console.log``)\nby default because it would be a portability issue for some targets.  Instead,\nan application should provide its own ``console`` binding.  This directory\ncontains an example binding:\n\n* Add ``duk_console.c`` to list of C sources to compile.\n\n* Ensure ``duk_console.h`` is in the include path.\n\n* Include the extra header in calling code and initialize the bindings::\n\n      #include \"duktape.h\"\n      #include \"duk_console.h\"\n\n      /* After initializing the Duktape heap or when creating a new\n       * thread with a new global environment:\n       */\n      duk_console_init(ctx, 0 /*flags*/);\n\n  Use the ``DUK_CONSOLE_PROXY_WRAPPER`` to enable a Proxy wrapper for the\n  console object.  The wrapper allows all undefined methods (for example,\n  ``console.foo``) to be handled as no-ops instead of throwing an error.\n  See ``duk_console.h`` for full flags list.\n\n* After these steps, ``console`` will be registered to the global object\n  and is ready to use.\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/console/duk_console.c",
    "content": "/*\n *  Minimal 'console' binding.\n *\n *  https://github.com/DeveloperToolsWG/console-object/blob/master/api.md\n *  https://developers.google.com/web/tools/chrome-devtools/debug/console/console-reference\n *  https://developer.mozilla.org/en/docs/Web/API/console\n */\n\n#include <stdio.h>\n#include <stdarg.h>\n#include \"duktape.h\"\n#include \"duk_console.h\"\n\n/* XXX: Add some form of log level filtering. */\n\n/* XXX: For now logs everything to stdout, V8/Node.js logs debug/info level\n * to stdout, warn and above to stderr.  Should this extra do the same?\n */\n\n/* XXX: Should all output be written via e.g. console.write(formattedMsg)?\n * This would make it easier for user code to redirect all console output\n * to a custom backend.\n */\n\n/* XXX: For now output is not flushed, add a flush flag, or maybe add flush\n * to info level and above only.\n */\n\n/* XXX: Init console object using duk_def_prop() when that call is available. */\n\nstatic duk_ret_t duk__console_log_helper(duk_context *ctx, const char *error_name) {\n\tduk_idx_t i, n;\n\n\tn = duk_get_top(ctx);\n\n\tduk_get_global_string(ctx, \"console\");\n\tduk_get_prop_string(ctx, -1, \"format\");\n\n\tfor (i = 0; i < n; i++) {\n\t\tif (duk_check_type_mask(ctx, i, DUK_TYPE_MASK_OBJECT)) {\n\t\t\t/* Slow path formatting. */\n\t\t\tduk_dup(ctx, -1);  /* console.format */\n\t\t\tduk_dup(ctx, i);\n\t\t\tduk_call(ctx, 1);\n\t\t\tduk_replace(ctx, i);  /* arg[i] = console.format(arg[i]); */\n\t\t}\n\t}\n\n\tduk_pop_2(ctx);\n\n\tduk_push_string(ctx, \" \");\n\tduk_insert(ctx, 0);\n\tduk_join(ctx, n);\n\n\tif (error_name) {\n\t\tduk_push_error_object(ctx, DUK_ERR_ERROR, \"%s\", duk_require_string(ctx, -1));\n\t\tduk_push_string(ctx, \"name\");\n\t\tduk_push_string(ctx, error_name);\n\t\tduk_def_prop(ctx, -3, DUK_DEFPROP_FORCE | DUK_DEFPROP_HAVE_VALUE);  /* to get e.g. 'Trace: 1 2 3' */\n\t\tduk_get_prop_string(ctx, -1, \"stack\");\n\t}\n\n\tprintf(\"%s\\n\", duk_to_string(ctx, -1));\n\treturn 0;\n}\n\nstatic duk_ret_t duk__console_assert(duk_context *ctx) {\n\tif (duk_to_boolean(ctx, 0)) {\n\t\treturn 0;\n\t}\n\tduk_remove(ctx, 0);\n\n\treturn duk__console_log_helper(ctx, \"AssertionError\");\n}\n\nstatic duk_ret_t duk__console_log(duk_context *ctx) {\n\treturn duk__console_log_helper(ctx, NULL);\n}\n\nstatic duk_ret_t duk__console_trace(duk_context *ctx) {\n\treturn duk__console_log_helper(ctx, \"Trace\");\n}\n\nstatic duk_ret_t duk__console_info(duk_context *ctx) {\n\treturn duk__console_log_helper(ctx, NULL);\n}\n\nstatic duk_ret_t duk__console_warn(duk_context *ctx) {\n\treturn duk__console_log_helper(ctx, NULL);\n}\n\nstatic duk_ret_t duk__console_error(duk_context *ctx) {\n\treturn duk__console_log_helper(ctx, \"Error\");\n}\n\nstatic duk_ret_t duk__console_dir(duk_context *ctx) {\n\t/* For now, just share the formatting of .log() */\n\treturn duk__console_log_helper(ctx, 0);\n}\n\nstatic void duk__console_reg_vararg_func(duk_context *ctx, duk_c_function func, const char *name) {\n\tduk_push_c_function(ctx, func, DUK_VARARGS);\n\tduk_push_string(ctx, \"name\");\n\tduk_push_string(ctx, name);\n\tduk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_FORCE);  /* Improve stacktraces by displaying function name */\n\tduk_put_prop_string(ctx, -2, name);\n}\n\nvoid duk_console_init(duk_context *ctx, duk_uint_t flags) {\n\tduk_push_object(ctx);\n\n\t/* Custom function to format objects; user can replace.\n\t * For now, try JX-formatting and if that fails, fall back\n\t * to ToString(v).\n\t */\n\tduk_eval_string(ctx,\n\t\t\"(function (E) {\"\n\t\t    \"return function format(v){\"\n\t\t        \"try{\"\n\t\t            \"return E('jx',v);\"\n\t\t        \"}catch(e){\"\n\t\t            \"return String(v);\"  /* String() allows symbols, ToString() internal algorithm doesn't. */\n\t\t        \"}\"\n\t\t    \"};\"\n\t\t\"})(Duktape.enc)\");\n\tduk_put_prop_string(ctx, -2, \"format\");\n\n\tduk__console_reg_vararg_func(ctx, duk__console_assert, \"assert\");\n\tduk__console_reg_vararg_func(ctx, duk__console_log, \"log\");\n\tduk__console_reg_vararg_func(ctx, duk__console_log, \"debug\");  /* alias to console.log */\n\tduk__console_reg_vararg_func(ctx, duk__console_trace, \"trace\");\n\tduk__console_reg_vararg_func(ctx, duk__console_info, \"info\");\n\tduk__console_reg_vararg_func(ctx, duk__console_warn, \"warn\");\n\tduk__console_reg_vararg_func(ctx, duk__console_error, \"error\");\n\tduk__console_reg_vararg_func(ctx, duk__console_error, \"exception\");  /* alias to console.error */\n\tduk__console_reg_vararg_func(ctx, duk__console_dir, \"dir\");\n\n\tduk_put_global_string(ctx, \"console\");\n\n\t/* Proxy wrapping: ensures any undefined console method calls are\n\t * ignored silently.  This is required specifically by the\n\t * DeveloperToolsWG proposal (and is implemented also by Firefox:\n\t * https://bugzilla.mozilla.org/show_bug.cgi?id=629607).\n\t */\n\n\tif (flags & DUK_CONSOLE_PROXY_WRAPPER) {\n\t\t/* Tolerate errors: Proxy may be disabled. */\n\t\tduk_peval_string_noresult(ctx,\n\t\t\t\"(function(){\"\n\t\t\t    \"var D=function(){};\"\n\t\t\t    \"console=new Proxy(console,{\"\n\t\t\t        \"get:function(t,k){\"\n\t\t\t            \"var v=t[k];\"\n\t\t\t            \"return typeof v==='function'?v:D;\"\n\t\t\t        \"}\"\n\t\t\t    \"});\"\n\t\t\t\"})();\"\n\t\t);\n\t}\n}\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/console/duk_console.h",
    "content": "#if !defined(DUK_CONSOLE_H_INCLUDED)\n#define DUK_CONSOLE_H_INCLUDED\n\n#include \"duktape.h\"\n\n/* Use a proxy wrapper to make undefined methods (console.foo()) no-ops. */\n#define DUK_CONSOLE_PROXY_WRAPPER  (1 << 0)\n\nextern void duk_console_init(duk_context *ctx, duk_uint_t flags);\n\n#endif  /* DUK_CONSOLE_H_INCLUDED */\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/console/test.c",
    "content": "#include <stdio.h>\n#include \"duktape.h\"\n#include \"duk_console.h\"\n\nint main(int argc, char *argv[]) {\n\tduk_context *ctx;\n\tint i;\n\tint exitcode = 0;\n\n\tctx = duk_create_heap_default();\n\tif (!ctx) {\n\t\treturn 1;\n\t}\n\n\tduk_console_init(ctx, DUK_CONSOLE_PROXY_WRAPPER /*flags*/);\n\tprintf(\"top after init: %ld\\n\", (long) duk_get_top(ctx));\n\n\tfor (i = 1; i < argc; i++) {\n\t\tprintf(\"Evaling: %s\\n\", argv[i]);\n\t\tif (duk_peval_string(ctx, argv[i]) != 0) {\n\t\t\texitcode = 1;\n\t\t}\n\t\tprintf(\"--> %s\\n\", duk_safe_to_string(ctx, -1));\n\t\tduk_pop(ctx);\n\t}\n\n\tprintf(\"Done\\n\");\n\tduk_destroy_heap(ctx);\n\treturn exitcode;\n}\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/duk-v1-compat/Makefile",
    "content": "# For manual testing; say 'make' in extras/duk-v1-compat and run ./test.\n\n.PHONY: test\ntest:\n\tgcc -std=c99 -Wall -Wextra -o $@ -I../../src/ -I. ../../src/duktape.c duk_v1_compat.c test.c -lm\n\t./test\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/duk-v1-compat/README.rst",
    "content": "================================\nDuktape V1 compatibility helpers\n================================\n\nProvides helpers for migrating from Duktape 1.x to 2.x:\n\n* Add ``duk_v1_compat.c`` to list of C sources to compile.\n\n* Ensure ``duk_v1_compat.h`` is in the include path.\n\n* Include the extra header in calling code::\n\n      #include \"duktape.h\"\n      #include \"duk_v1_compat.h\"\n\n      /* ... */\n\n      duk_dump_context_stdout(ctx);  /* Removed in Duktape 2.x. */\n\nThe helpers don't restore full 1.x compatibility because some API calls such\nas ``duk_safe_call()`` have changed in an incompatible manner.\n\nThe old APIs are documented in:\n\n* http://duktape.org/1.5.0/api.html\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/duk-v1-compat/duk_v1_compat.c",
    "content": "#include <stdio.h>\n#include \"duktape.h\"\n#include \"duk_v1_compat.h\"\n\n/*\n *  duk_dump_context_{stdout,stderr}()\n */\n\nvoid duk_dump_context_stdout(duk_context *ctx) {\n\tduk_push_context_dump(ctx);\n\tfprintf(stdout, \"%s\\n\", duk_safe_to_string(ctx, -1));\n\tduk_pop(ctx);\n}\n\nvoid duk_dump_context_stderr(duk_context *ctx) {\n\tduk_push_context_dump(ctx);\n\tfprintf(stderr, \"%s\\n\", duk_safe_to_string(ctx, -1));\n\tduk_pop(ctx);\n}\n\n/*\n *  duk_push_string_file() and duk_push_string_file_raw()\n */\n\nconst char *duk_push_string_file_raw(duk_context *ctx, const char *path, duk_uint_t flags) {\n\tFILE *f = NULL;\n\tchar *buf;\n\tlong sz;  /* ANSI C typing */\n\n\tif (!path) {\n\t\tgoto fail;\n\t}\n\tf = fopen(path, \"rb\");\n\tif (!f) {\n\t\tgoto fail;\n\t}\n\tif (fseek(f, 0, SEEK_END) < 0) {\n\t\tgoto fail;\n\t}\n\tsz = ftell(f);\n\tif (sz < 0) {\n\t\tgoto fail;\n\t}\n\tif (fseek(f, 0, SEEK_SET) < 0) {\n\t\tgoto fail;\n\t}\n\tbuf = (char *) duk_push_fixed_buffer(ctx, (duk_size_t) sz);\n\tif ((size_t) fread(buf, 1, (size_t) sz, f) != (size_t) sz) {\n\t\tduk_pop(ctx);\n\t\tgoto fail;\n\t}\n\t(void) fclose(f);  /* ignore fclose() error */\n\treturn duk_buffer_to_string(ctx, -1);\n\n fail:\n\tif (f) {\n\t\t(void) fclose(f);  /* ignore fclose() error */\n\t}\n\n\tif (flags & DUK_STRING_PUSH_SAFE) {\n\t\tduk_push_undefined(ctx);\n\t} else {\n\t\tduk_error(ctx, DUK_ERR_TYPE_ERROR, \"read file error\");\n\t}\n\treturn NULL;\n}\n\n/*\n *  duk_eval_file(), duk_compile_file(), and their variants\n */\n\nvoid duk_eval_file(duk_context *ctx, const char *path) {\n\tduk_push_string_file_raw(ctx, path, 0);\n\tduk_push_string(ctx, path);\n\tduk_compile(ctx, DUK_COMPILE_EVAL);\n\tduk_push_global_object(ctx);  /* 'this' binding */\n\tduk_call_method(ctx, 0);\n}\n\nvoid duk_eval_file_noresult(duk_context *ctx, const char *path) {\n\tduk_eval_file(ctx, path);\n\tduk_pop(ctx);\n}\n\nduk_int_t duk_peval_file(duk_context *ctx, const char *path) {\n\tduk_int_t rc;\n\n\tduk_push_string_file_raw(ctx, path, DUK_STRING_PUSH_SAFE);\n\tduk_push_string(ctx, path);\n\trc = duk_pcompile(ctx, DUK_COMPILE_EVAL);\n\tif (rc != 0) {\n\t\treturn rc;\n\t}\n\tduk_push_global_object(ctx);  /* 'this' binding */\n\trc = duk_pcall_method(ctx, 0);\n\treturn rc;\n}\n\nduk_int_t duk_peval_file_noresult(duk_context *ctx, const char *path) {\n\tduk_int_t rc;\n\n\trc = duk_peval_file(ctx, path);\n\tduk_pop(ctx);\n\treturn rc;\n}\n\nvoid duk_compile_file(duk_context *ctx, duk_uint_t flags, const char *path) {\n\tduk_push_string_file_raw(ctx, path, 0);\n\tduk_push_string(ctx, path);\n\tduk_compile(ctx, flags);\n}\n\nduk_int_t duk_pcompile_file(duk_context *ctx, duk_uint_t flags, const char *path) {\n\tduk_int_t rc;\n\n\tduk_push_string_file_raw(ctx, path, DUK_STRING_PUSH_SAFE);\n\tduk_push_string(ctx, path);\n\trc = duk_pcompile(ctx, flags);\n\treturn rc;\n}\n\n/*\n *  duk_to_defaultvalue()\n */\n\nvoid duk_to_defaultvalue(duk_context *ctx, duk_idx_t idx, duk_int_t hint) {\n\tduk_require_type_mask(ctx, idx, DUK_TYPE_MASK_OBJECT |\n\t                                DUK_TYPE_MASK_BUFFER |\n\t                                DUK_TYPE_MASK_LIGHTFUNC);\n\tduk_to_primitive(ctx, idx, hint);\n}\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/duk-v1-compat/duk_v1_compat.h",
    "content": "#if !defined(DUK_V1_COMPAT_INCLUDED)\n#define DUK_V1_COMPAT_INCLUDED\n\n#include \"duktape.h\"\n\n/* Straight flag rename */\n#if !defined(DUK_ENUM_INCLUDE_INTERNAL)\n#define DUK_ENUM_INCLUDE_INTERNAL DUK_ENUM_INCLUDE_HIDDEN\n#endif\n\n/* Flags for duk_push_string_file_raw() */\n#define DUK_STRING_PUSH_SAFE              (1 << 0)    /* no error if file does not exist */\n\nextern void duk_dump_context_stdout(duk_context *ctx);\nextern void duk_dump_context_stderr(duk_context *ctx);\nextern const char *duk_push_string_file_raw(duk_context *ctx, const char *path, duk_uint_t flags);\nextern void duk_eval_file(duk_context *ctx, const char *path);\nextern void duk_eval_file_noresult(duk_context *ctx, const char *path);\nextern duk_int_t duk_peval_file(duk_context *ctx, const char *path);\nextern duk_int_t duk_peval_file_noresult(duk_context *ctx, const char *path);\nextern void duk_compile_file(duk_context *ctx, duk_uint_t flags, const char *path);\nextern duk_int_t duk_pcompile_file(duk_context *ctx, duk_uint_t flags, const char *path);\nextern void duk_to_defaultvalue(duk_context *ctx, duk_idx_t idx, duk_int_t hint);\n\n#define duk_push_string_file(ctx,path) \\\n\tduk_push_string_file_raw((ctx), (path), 0)\n\n#endif  /* DUK_V1_COMPAT_INCLUDED */\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/duk-v1-compat/test.c",
    "content": "#include <stdio.h>\n#include \"duktape.h\"\n#include \"duk_v1_compat.h\"\n\nstatic duk_ret_t my_print(duk_context *ctx) {\n\tduk_push_string(ctx, \" \");\n\tduk_insert(ctx, 0);\n\tduk_join(ctx, duk_get_top(ctx) - 1);\n\tprintf(\"%s\\n\", duk_to_string(ctx, -1));\n\tfflush(stdout);\n\treturn 0;\n}\n\nint main(int argc, char *argv[]) {\n\tduk_context *ctx;\n\tint i;\n\tduk_int_t rc;\n\n\tctx = duk_create_heap_default();\n\tif (!ctx) {\n\t\treturn 1;\n\t}\n\n\t/* Minimal print() provider. */\n\tduk_push_c_function(ctx, my_print, DUK_VARARGS);\n\tduk_put_global_string(ctx, \"print\");\n\n\tprintf(\"top after init: %ld\\n\", (long) duk_get_top(ctx));\n\n\tfor (i = 1; i < argc; i++) {\n\t\tprintf(\"Evaling: %s\\n\", argv[i]);\n\t\t(void) duk_peval_string(ctx, argv[i]);\n\t\tprintf(\"--> %s\\n\", duk_safe_to_string(ctx, -1));\n\t\tduk_pop(ctx);\n\t}\n\n\t/* Test duk_dump_context_{stdout,stderr}() */\n\n\tduk_push_string(ctx, \"dump to stdout\");\n\tduk_dump_context_stdout(ctx);\n\tduk_pop(ctx);\n\n\tduk_push_string(ctx, \"dump to stderr\");\n\tduk_dump_context_stderr(ctx);\n\tduk_pop(ctx);\n\n\t/* Test duk_eval_file() and related. */\n\n\tprintf(\"top before duk_eval_file(): %ld\\n\", (long) duk_get_top(ctx));\n\tduk_eval_file(ctx, \"test_eval1.js\");\n\tprintf(\"top after duk_eval_file(): %ld\\n\", (long) duk_get_top(ctx));\n\tprintf(\" --> %s\\n\", duk_safe_to_string(ctx, -1));\n\tduk_pop(ctx);\n\n\tprintf(\"top before duk_eval_file_noresult(): %ld\\n\", (long) duk_get_top(ctx));\n\tduk_eval_file_noresult(ctx, \"test_eval1.js\");\n\tprintf(\"top after duk_eval_file_noresult(): %ld\\n\", (long) duk_get_top(ctx));\n\n\tprintf(\"top before duk_peval_file(): %ld\\n\", (long) duk_get_top(ctx));\n\trc = duk_peval_file(ctx, \"test_eval1.js\");\n\tprintf(\"top after duk_peval_file(): %ld\\n\", (long) duk_get_top(ctx));\n\tprintf(\" --> %ld, %s\\n\", (long) rc, duk_safe_to_string(ctx, -1));\n\tduk_pop(ctx);\n\n\tprintf(\"top before duk_peval_file(): %ld\\n\", (long) duk_get_top(ctx));\n\trc = duk_peval_file(ctx, \"test_eval2.js\");\n\tprintf(\"top after duk_peval_file(): %ld\\n\", (long) duk_get_top(ctx));\n\tprintf(\" --> %ld, %s\\n\", (long) rc, duk_safe_to_string(ctx, -1));\n\tduk_pop(ctx);\n\n\tprintf(\"top before duk_peval_file_noresult(): %ld\\n\", (long) duk_get_top(ctx));\n\trc = duk_peval_file_noresult(ctx, \"test_eval1.js\");\n\tprintf(\"top after duk_peval_file_noresult(): %ld\\n\", (long) duk_get_top(ctx));\n\tprintf(\" --> %ld\\n\", (long) rc);\n\n\tprintf(\"top before duk_peval_file_noresult(): %ld\\n\", (long) duk_get_top(ctx));\n\trc = duk_peval_file_noresult(ctx, \"test_eval2.js\");\n\tprintf(\"top after duk_peval_file_noresult(): %ld\\n\", (long) duk_get_top(ctx));\n\tprintf(\" --> %ld\\n\", (long) rc);\n\n\t/* Test duk_compile_file() and related. */\n\n\tprintf(\"top before duk_compile_file(): %ld\\n\", (long) duk_get_top(ctx));\n\tduk_compile_file(ctx, 0, \"test_compile1.js\");\n\tprintf(\"top after duk_compile_file(): %ld\\n\", (long) duk_get_top(ctx));\n\tduk_call(ctx, 0);\n\tduk_pop(ctx);\n\n\tprintf(\"top before duk_pcompile_file(): %ld\\n\", (long) duk_get_top(ctx));\n\trc = duk_pcompile_file(ctx, 0, \"test_compile1.js\");\n\tprintf(\"top after duk_pcompile_file(): %ld\\n\", (long) duk_get_top(ctx));\n\tprintf(\" --> %ld: %s\\n\", (long) rc, duk_safe_to_string(ctx, -1));\n\tduk_pop(ctx);\n\n\tprintf(\"top before duk_pcompile_file(): %ld\\n\", (long) duk_get_top(ctx));\n\trc = duk_pcompile_file(ctx, 0, \"test_compile2.js\");\n\tprintf(\"top after duk_pcompile_file(): %ld\\n\", (long) duk_get_top(ctx));\n\tprintf(\" --> %ld: %s\\n\", (long) rc, duk_safe_to_string(ctx, -1));\n\tduk_pop(ctx);\n\n\tprintf(\"Done\\n\");\n\tduk_destroy_heap(ctx);\n\treturn 0;\n}\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/duk-v1-compat/test_compile1.js",
    "content": "// File to compile, no error\nprint('Hello from test_compile1.js');\nprint(new Error('test error for traceback (shows filename)').stack);\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/duk-v1-compat/test_compile2.js",
    "content": "// File to compile, syntax error\nprint('Hello from test_compile2.js');\n= y +;\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/duk-v1-compat/test_eval1.js",
    "content": "// File to eval, no error\nprint('Hello from test_eval1.js');\nprint(new Error('test error for traceback (shows filename)').stack);\n123;\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/duk-v1-compat/test_eval2.js",
    "content": "// File to eval, throws error\nprint('Hello from test_eval2.js');\nprint(new Error('test error for traceback (shows filename)').stack);\nthrow new Error('aiee');\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/logging/Makefile",
    "content": "# For manual testing; say 'make' in extras/logging and run ./test.\n.PHONY: test\ntest:\n\tgcc -std=c99 -Wall -Wextra -otest -I../../src ../../src/duktape.c duk_logging.c test.c -lm\n\t./test 'L = new Duktape.Logger(); L.trace(\"testing\"); L.l = 0; L.trace(\"testing 2\");'\n\t./test 'L = new Duktape.Logger(); L.debug(\"testing\"); L.l = 1; L.debug(\"testing 2\");'\n\t./test 'L = new Duktape.Logger(); L.info(\"testing\");'\n\t./test 'L = new Duktape.Logger(); L.warn(\"testing\");'\n\t./test 'L = new Duktape.Logger(); L.error(\"testing\");'\n\t./test 'L = new Duktape.Logger(); L.fatal(\"testing\");'\n\t./test 'L = new Duktape.Logger(); L.info(\"testing\"); L.n = \"loggerName\"; L.info(\"new name\");'\n\t./test 'L = new Duktape.Logger(\"argname\"); L.info(\"testing\");'\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/logging/README.rst",
    "content": "========================================\nDuktape 1.x compatible logging framework\n========================================\n\nThe default ``Duktape.Logger`` object and the logging related C API calls\n(``duk_log()``, ``duk_log_va()``) were removed in Duktape 2.x because they\ndepended on stdout/stderr and were thus a portability issue for some targets\n(there were also other issues, such as the logging framework not always\nmatching user expectations).  This directory contains Duktape 1.x compatible\n``Duktape.Logger`` object and logging API calls:\n\n* Add ``duk_logging.c`` to list of C sources to compile.\n\n* Ensure ``duk_logging.h`` is in the include path.\n\n* Include the extra header in calling code and initialize the bindings::\n\n      #include \"duktape.h\"\n      #include \"duk_logging.h\"\n\n      /* After initializing the Duktape heap or when creating a new\n       * thread with a new global environment:\n       */\n      duk_logging_init(ctx, 0 /*flags*/);\n\n  See ``duk_logging.h`` for available flags.\n\n* After these steps, ``Duktape.Logger`` will be registered to the ``Duktape``\n  object and is ready to use.\n\nSee https://github.com/svaarala/duktape/blob/master/doc/logging.rst and\nhttp://wiki.duktape.org/HowtoLogging.html for more information on the\nlogging framework design and functionality.\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/logging/duk_logging.c",
    "content": "/*\n *  Logging support\n */\n\n#include <stdio.h>\n#include <string.h>\n#include <stdarg.h>\n#include \"duktape.h\"\n#include \"duk_logging.h\"\n\n/* XXX: uses stderr always for now, configurable? */\n\n#define DUK_LOGGING_FLUSH  /* Duktape 1.x: flush stderr */\n\n/* 3-letter log level strings. */\nstatic const char duk__log_level_strings[] = {\n\t'T', 'R', 'C', 'D', 'B', 'G', 'I', 'N', 'F',\n\t'W', 'R', 'N', 'E', 'R', 'R', 'F', 'T', 'L'\n};\n\n/* Log method names. */\nstatic const char *duk__log_method_names[] = {\n\t\"trace\", \"debug\", \"info\", \"warn\", \"error\", \"fatal\"\n};\n\n/* Constructor. */\nstatic duk_ret_t duk__logger_constructor(duk_context *ctx) {\n\tduk_idx_t nargs;\n\n\t/* Calling as a non-constructor is not meaningful. */\n\tif (!duk_is_constructor_call(ctx)) {\n\t\treturn DUK_RET_TYPE_ERROR;\n\t}\n\n\tnargs = duk_get_top(ctx);\n\tduk_set_top(ctx, 1);\n\n\tduk_push_this(ctx);\n\n\t/* [ name this ] */\n\n\tif (nargs == 0) {\n\t\t/* Automatic defaulting of logger name from caller.  This\n\t\t * would work poorly with tail calls, but constructor calls\n\t\t * are currently never tail calls, so tail calls are not an\n\t\t * issue now.\n\t\t */\n\n\t\tduk_inspect_callstack_entry(ctx, -2);\n\t\tif (duk_is_object(ctx, -1)) {\n\t\t\tif (duk_get_prop_string(ctx, -1, \"function\")) {\n\t\t\t\tif (duk_get_prop_string(ctx, -1, \"fileName\")) {\n\t\t\t\t\tif (duk_is_string(ctx, -1)) {\n\t\t\t\t\t\tduk_replace(ctx, 0);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t/* Leave values on stack on purpose, ignored below. */\n\n\t\t/* Stripping the filename might be a good idea\n\t\t * (\"/foo/bar/quux.js\" -> logger name \"quux\"),\n\t\t * but now used verbatim.\n\t\t */\n\t}\n\t/* The stack is unbalanced here on purpose; we only rely on the\n\t * initial two values: [ name this ].\n\t */\n\n\tif (duk_is_string(ctx, 0)) {\n\t\tduk_dup(ctx, 0);\n\t\tduk_put_prop_string(ctx, 1, \"n\");\n\t} else {\n\t\t/* don't set 'n' at all, inherited value is used as name */\n\t}\n\n\tduk_compact(ctx, 1);\n\n\treturn 0;  /* keep default instance */\n}\n\n/* Default function to format objects.  Tries to use toLogString() but falls\n * back to toString().  Any errors are propagated out without catching.\n */\nstatic duk_ret_t duk__logger_prototype_fmt(duk_context *ctx) {\n\tif (duk_get_prop_string(ctx, 0, \"toLogString\")) {\n\t\t/* [ arg toLogString ] */\n\n\t\tduk_dup(ctx, 0);\n\t\tduk_call_method(ctx, 0);\n\n\t\t/* [ arg result ] */\n\t\treturn 1;\n\t}\n\n\t/* [ arg undefined ] */\n\tduk_pop(ctx);\n\tduk_to_string(ctx, 0);\n\treturn 1;\n}\n\n/* Default function to write a formatted log line.  Writes to stderr,\n * appending a newline to the log line.\n *\n * The argument is a buffer; avoid coercing the buffer to a string to\n * avoid string table traffic.\n */\nstatic duk_ret_t duk__logger_prototype_raw(duk_context *ctx) {\n\tconst char *data;\n\tduk_size_t data_len;\n\n\tdata = (const char *) duk_require_buffer(ctx, 0, &data_len);\n\tfwrite((const void *) data, 1, data_len, stderr);\n\tfputc((int) '\\n', stderr);\n#if defined(DUK_LOGGING_FLUSH)\n\tfflush(stderr);\n#endif\n\treturn 0;\n}\n\n/* Log frontend shared helper, magic value indicates log level.  Provides\n * frontend functions: trace(), debug(), info(), warn(), error(), fatal().\n * This needs to have small footprint, reasonable performance, minimal\n * memory churn, etc.\n */\nstatic duk_ret_t duk__logger_prototype_log_shared(duk_context *ctx) {\n\tduk_double_t now;\n\tduk_time_components comp;\n\tduk_small_int_t entry_lev;\n\tduk_small_int_t logger_lev;\n\tduk_int_t nargs;\n\tduk_int_t i;\n\tduk_size_t tot_len;\n\tconst duk_uint8_t *arg_str;\n\tduk_size_t arg_len;\n\tduk_uint8_t *buf, *p;\n\tconst duk_uint8_t *q;\n\tduk_uint8_t date_buf[32];  /* maximum format length is 24+1 (NUL), round up. */\n\tduk_size_t date_len;\n\tduk_small_int_t rc;\n\n\t/* XXX: sanitize to printable (and maybe ASCII) */\n\t/* XXX: better multiline */\n\n\t/*\n\t *  Logger arguments are:\n\t *\n\t *    magic: log level (0-5)\n\t *    this: logger\n\t *    stack: plain log args\n\t *\n\t *  We want to minimize memory churn so a two-pass approach\n\t *  is used: first pass formats arguments and computes final\n\t *  string length, second pass copies strings into a buffer\n\t *  allocated directly with the correct size.  If the backend\n\t *  function plays nice, it won't coerce the buffer to a string\n\t *  (and thus intern it).\n\t */\n\n\tentry_lev = duk_get_current_magic(ctx);\n\tif (entry_lev < DUK_LOG_TRACE || entry_lev > DUK_LOG_FATAL) {\n\t\t/* Should never happen, check just in case. */\n\t\treturn 0;\n\t}\n\tnargs = duk_get_top(ctx);\n\n\t/* [ arg1 ... argN this ] */\n\n\t/*\n\t *  Log level check\n\t */\n\n\tduk_push_this(ctx);\n\n\tduk_get_prop_string(ctx, -1, \"l\");\n\tlogger_lev = (duk_small_int_t) duk_get_int(ctx, -1);\n\tif (entry_lev < logger_lev) {\n\t\treturn 0;\n\t}\n\t/* log level could be popped but that's not necessary */\n\n\tnow = duk_get_now(ctx);\n\tduk_time_to_components(ctx, now, &comp);\n\tsprintf((char *) date_buf, \"%04d-%02d-%02dT%02d:%02d:%02d.%03dZ\",\n\t        (int) comp.year, (int) comp.month + 1, (int) comp.day,\n\t        (int) comp.hours, (int) comp.minutes, (int) comp.seconds,\n\t        (int) comp.milliseconds);\n\n\tdate_len = strlen((const char *) date_buf);\n\n\tduk_get_prop_string(ctx, -2, \"n\");\n\tduk_to_string(ctx, -1);\n\n\t/* [ arg1 ... argN this loggerLevel loggerName ] */\n\n\t/*\n\t *  Pass 1\n\t */\n\n\t/* Line format: <time> <entryLev> <loggerName>: <msg> */\n\n\ttot_len = 0;\n\ttot_len += 3 +  /* separators: space, space, colon */\n\t           3 +  /* level string */\n\t           date_len +  /* time */\n\t           duk_get_length(ctx, -1);  /* loggerName */\n\n\tfor (i = 0; i < nargs; i++) {\n\t\t/* When formatting an argument to a string, errors may happen from multiple\n\t\t * causes.  In general we want to catch obvious errors like a toLogString()\n\t\t * throwing an error, but we don't currently try to catch every possible\n\t\t * error.  In particular, internal errors (like out of memory or stack) are\n\t\t * not caught.  Also, we expect Error toString() to not throw an error.\n\t\t */\n\t\tif (duk_is_object(ctx, i)) {\n\t\t\t/* duk_pcall_prop() may itself throw an error, but we're content\n\t\t\t * in catching the obvious errors (like toLogString() throwing an\n\t\t\t * error).\n\t\t\t */\n\t\t\tduk_push_string(ctx, \"fmt\");\n\t\t\tduk_dup(ctx, i);\n\t\t\t/* [ arg1 ... argN this loggerLevel loggerName 'fmt' arg ] */\n\t\t\t/* call: this.fmt(arg) */\n\t\t\trc = duk_pcall_prop(ctx, -5 /*obj_index*/, 1 /*nargs*/);\n\t\t\tif (rc) {\n\t\t\t\t/* Keep the error as the result (coercing it might fail below,\n\t\t\t\t * but we don't catch that now).\n\t\t\t\t */\n\t\t\t\t;\n\t\t\t}\n\t\t\tduk_replace(ctx, i);\n\t\t}\n\t\t(void) duk_to_lstring(ctx, i, &arg_len);\n\t\ttot_len++;  /* sep (even before first one) */\n\t\ttot_len += arg_len;\n\t}\n\n\t/*\n\t *  Pass 2\n\t */\n\n\t/* XXX: Here it'd be nice if we didn't need to allocate a new fixed\n\t * buffer for every write.  This would be possible if raw() took a\n\t * buffer and a length.  We could then use a preallocated buffer for\n\t * most log writes and request raw() to write a partial buffer.\n\t */\n\n\tbuf = (duk_uint8_t *) duk_push_fixed_buffer(ctx, tot_len);\n\tp = buf;\n\n\tmemcpy((void *) p, (const void *) date_buf, (size_t) date_len);\n\tp += date_len;\n\t*p++ = (duk_uint8_t) ' ';\n\n\tq = (const duk_uint8_t *) duk__log_level_strings + (entry_lev * 3);\n\tmemcpy((void *) p, (const void *) q, (size_t) 3);\n\tp += 3;\n\n\t*p++ = (duk_uint8_t) ' ';\n\n\targ_str = (const duk_uint8_t *) duk_get_lstring(ctx, -2, &arg_len);\n\tmemcpy((void *) p, (const void *) arg_str, (size_t) arg_len);\n\tp += arg_len;\n\n\t*p++ = (duk_uint8_t) ':';\n\n\tfor (i = 0; i < nargs; i++) {\n\t\t*p++ = (duk_uint8_t) ' ';\n\n\t\targ_str = (const duk_uint8_t *) duk_get_lstring(ctx, i, &arg_len);\n\t\tmemcpy((void *) p, (const void *) arg_str, (size_t) arg_len);\n\t\tp += arg_len;\n\t}\n\n\t/* [ arg1 ... argN this loggerLevel loggerName buffer ] */\n\n\t/* Call this.raw(msg); look up through the instance allows user to override\n\t * the raw() function in the instance or in the prototype for maximum\n\t * flexibility.\n\t */\n\tduk_push_string(ctx, \"raw\");\n\tduk_dup(ctx, -2);\n\t/* [ arg1 ... argN this loggerLevel loggerName buffer 'raw' buffer ] */\n\tduk_call_prop(ctx, -6, 1);  /* this.raw(buffer) */\n\n\treturn 0;\n}\n\nvoid duk_log_va(duk_context *ctx, duk_int_t level, const char *fmt, va_list ap) {\n\tif (level < 0) {\n\t\tlevel = 0;\n\t} else if (level > (int) (sizeof(duk__log_method_names) / sizeof(const char *)) - 1) {\n\t\tlevel = (int) (sizeof(duk__log_method_names) / sizeof(const char *)) - 1;\n\t}\n\n\tduk_push_global_stash(ctx);\n\tduk_get_prop_string(ctx, -1, \"\\xff\" \"logger:constructor\");  /* fixed at init time */\n\tduk_get_prop_string(ctx, -1, \"clog\");\n\tduk_get_prop_string(ctx, -1, duk__log_method_names[level]);\n\tduk_dup(ctx, -2);\n\tduk_push_vsprintf(ctx, fmt, ap);\n\n\t/* [ ... stash Logger clog logfunc clog(=this) msg ] */\n\n\tduk_call_method(ctx, 1 /*nargs*/);\n\n\t/* [ ... stash Logger clog res ] */\n\n\tduk_pop_n(ctx, 4);\n}\n\nvoid duk_log(duk_context *ctx, duk_int_t level, const char *fmt, ...) {\n\tva_list ap;\n\n\tva_start(ap, fmt);\n\tduk_log_va(ctx, level, fmt, ap);\n\tva_end(ap);\n}\n\nvoid duk_logging_init(duk_context *ctx, duk_uint_t flags) {\n\t/* XXX: Add .name property for logger functions (useful for stack traces if they throw). */\n\n\t(void) flags;\n\n\tduk_eval_string(ctx,\n\t\t\"(function(cons,prot){\"\n\t\t\"Object.defineProperty(Duktape,'Logger',{value:cons,writable:true,configurable:true});\"\n\t\t\"Object.defineProperty(cons,'prototype',{value:prot});\"\n\t\t\"Object.defineProperty(cons,'clog',{value:new Duktape.Logger('C'),writable:true,configurable:true});\"\n\t\t\"});\");\n\n\tduk_push_c_function(ctx, duk__logger_constructor, DUK_VARARGS /*nargs*/);  /* Duktape.Logger */\n\tduk_push_object(ctx);  /* Duktape.Logger.prototype */\n\n\t/* [ ... func Duktape.Logger Duktape.Logger.prototype ] */\n\n\tduk_push_string(ctx, \"name\");\n\tduk_push_string(ctx, \"Logger\");\n\tduk_def_prop(ctx, -4, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_FORCE);\n\n\tduk_dup_top(ctx);\n\tduk_put_prop_string(ctx, -2, \"constructor\");\n\tduk_push_int(ctx, 2);\n\tduk_put_prop_string(ctx, -2, \"l\");\n\tduk_push_string(ctx, \"anon\");\n\tduk_put_prop_string(ctx, -2, \"n\");\n\tduk_push_c_function(ctx, duk__logger_prototype_fmt, 1 /*nargs*/);\n\tduk_put_prop_string(ctx, -2, \"fmt\");\n\tduk_push_c_function(ctx, duk__logger_prototype_raw, 1 /*nargs*/);\n\tduk_put_prop_string(ctx, -2, \"raw\");\n\tduk_push_c_function(ctx, duk__logger_prototype_log_shared, DUK_VARARGS /*nargs*/);\n\tduk_set_magic(ctx, -1, 0);  /* magic=0: trace */\n\tduk_put_prop_string(ctx, -2, \"trace\");\n\tduk_push_c_function(ctx, duk__logger_prototype_log_shared, DUK_VARARGS /*nargs*/);\n\tduk_set_magic(ctx, -1, 1);  /* magic=1: debug */\n\tduk_put_prop_string(ctx, -2, \"debug\");\n\tduk_push_c_function(ctx, duk__logger_prototype_log_shared, DUK_VARARGS /*nargs*/);\n\tduk_set_magic(ctx, -1, 2);  /* magic=2: info */\n\tduk_put_prop_string(ctx, -2, \"info\");\n\tduk_push_c_function(ctx, duk__logger_prototype_log_shared, DUK_VARARGS /*nargs*/);\n\tduk_set_magic(ctx, -1, 3);  /* magic=3: warn */\n\tduk_put_prop_string(ctx, -2, \"warn\");\n\tduk_push_c_function(ctx, duk__logger_prototype_log_shared, DUK_VARARGS /*nargs*/);\n\tduk_set_magic(ctx, -1, 4);  /* magic=4: error */\n\tduk_put_prop_string(ctx, -2, \"error\");\n\tduk_push_c_function(ctx, duk__logger_prototype_log_shared, DUK_VARARGS /*nargs*/);\n\tduk_set_magic(ctx, -1, 5);  /* magic=5: fatal */\n\tduk_put_prop_string(ctx, -2, \"fatal\");\n\n\t/* [ ... func Duktape.Logger Duktape.Logger.prototype ] */\n\n\t/* XXX: when using ROM built-ins, \"Duktape\" is read-only by default so\n\t * setting Duktape.Logger will now fail.\n\t */\n\n\t/* [ ... func Duktape.Logger Duktape.Logger.prototype ] */\n\n\tduk_call(ctx, 2);\n\tduk_pop(ctx);\n}\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/logging/duk_logging.h",
    "content": "#if !defined(DUK_LOGGING_H_INCLUDED)\n#define DUK_LOGGING_H_INCLUDED\n\n#include \"duktape.h\"\n\n/* Log levels */\n#define DUK_LOG_TRACE                     0\n#define DUK_LOG_DEBUG                     1\n#define DUK_LOG_INFO                      2\n#define DUK_LOG_WARN                      3\n#define DUK_LOG_ERROR                     4\n#define DUK_LOG_FATAL                     5\n\n/* No flags at the moment. */\n\nextern void duk_logging_init(duk_context *ctx, duk_uint_t flags);\nextern void duk_log_va(duk_context *ctx, duk_int_t level, const char *fmt, va_list ap);\nextern void duk_log(duk_context *ctx, duk_int_t level, const char *fmt, ...);\n\n#endif  /* DUK_LOGGING_H_INCLUDED */\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/logging/test.c",
    "content": "#include <stdio.h>\n#include \"duktape.h\"\n#include \"duk_logging.h\"\n\nstatic duk_ret_t init_logging(duk_context *ctx, void *udata) {\n\t(void) udata;\n\tduk_logging_init(ctx, 0 /*flags*/);\n\tprintf(\"top after init: %ld\\n\", (long) duk_get_top(ctx));\n\n\t/* C API test */\n\tduk_eval_string_noresult(ctx, \"Duktape.Logger.clog.l = 0;\");\n\tduk_log(ctx, DUK_LOG_TRACE, \"c logger test: %d\", 123);\n\tduk_log(ctx, DUK_LOG_DEBUG, \"c logger test: %d\", 123);\n\tduk_log(ctx, DUK_LOG_INFO, \"c logger test: %d\", 123);\n\tduk_log(ctx, DUK_LOG_WARN, \"c logger test: %d\", 123);\n\tduk_log(ctx, DUK_LOG_ERROR, \"c logger test: %d\", 123);\n\tduk_log(ctx, DUK_LOG_FATAL, \"c logger test: %d\", 123);\n\tduk_log(ctx, -1, \"negative level: %s %d 0x%08lx\", \"arg string\", -123, 0xdeadbeefUL);\n\tduk_log(ctx, 6, \"level too large: %s %d 0x%08lx\", \"arg string\", 123, 0x1234abcdUL);\n\n\treturn 0;\n}\n\nint main(int argc, char *argv[]) {\n\tduk_context *ctx;\n\tint i;\n\tint exitcode = 0;\n\n\tctx = duk_create_heap_default();\n\tif (!ctx) {\n\t\treturn 1;\n\t}\n\n\t(void) duk_safe_call(ctx, init_logging, NULL, 0, 1);\n\tprintf(\"logging init: %s\\n\", duk_safe_to_string(ctx, -1));\n\tduk_pop(ctx);\n\n\tfor (i = 1; i < argc; i++) {\n\t\tprintf(\"Evaling: %s\\n\", argv[i]);\n\t\tduk_push_string(ctx, argv[i]);\n\t\tduk_push_string(ctx, \"evalCodeFileName\");  /* for automatic logger name testing */\n\t\tif (duk_pcompile(ctx, DUK_COMPILE_EVAL) != 0) {\n\t\t\texitcode = 1;\n\t\t} else {\n\t\t\tif (duk_pcall(ctx, 0) != 0) {\n\t\t\t\texitcode = 1;\n\t\t\t}\n\t\t}\n\t\tprintf(\"--> %s\\n\", duk_safe_to_string(ctx, -1));\n\t\tduk_pop(ctx);\n\t}\n\n\tprintf(\"Done\\n\");\n\tduk_destroy_heap(ctx);\n\treturn exitcode;\n}\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/minimal-printf/Makefile",
    "content": "# Just for manual testing\n.PHONY: test\ntest: duk_minimal_printf.c\n\tgcc -std=c99 -Wall -Wextra -fno-stack-protector -m32 -Os -fomit-frame-pointer -otest duk_minimal_printf.c test.c\n\t./test\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/minimal-printf/README.rst",
    "content": "==============================================\nMinimal sprintf/sscanf replacement for Duktape\n==============================================\n\nThe ``duk_minimal_printf.c`` provides a portable provider for sprintf()/scanf()\nwith a feature set matching minimally what Duktape internals need.  The provider\ncompiles to less than 1kB.  The functions provided are::\n\n    sprintf()\n    snprintf()\n    vsnprintf()\n    sscanf()\n\nIn addition to Duktape internals, the set of supported formats affects the\n``duk_push_(v)sprintf()`` call which may have an impact on user code.\n\nAssumptions:\n\n* ``sizeof(void *) <= sizeof(long)``\n\n* ``sizeof(long) <= 8``\n\nNote that these assumptions don't hold e.g. on 64-bit Windows.  This printf\nprovider is mostly useful for low memory targets where these assumptions are\ntypically not an issue.  The limitations are easy to fix if one relies more\non platform typing.\n\nSupported formatting\n====================\n\nsprintf()\n---------\n\nDuktape relies on a ``sprintf()`` provider which supports at least the\nfollowing (this list is from Duktape 1.5.0)::\n\n    %c\n    %s\n    %p\n\n    %02d\n    %03d\n    %ld\n    %lld    (JSON fast path only)\n\n    %lu\n\n    %lx\n    %02lx\n    %08lx\n\nThis minimal provider supports the following slightly different, wider set.\n\n* Character format ``%c``.\n\n* String format ``%s``.\n\n* Pointer format ``%p``.\n\n* Integer formats ``%d``, ``%ld``, ``%lu`` with optional padding and\n  length modifiers.\n\n* Hex formats ``%x``, ``%lx`` with optional padding and length modifiers.\n\nThe wider set is useful to make ``duk_push_(v)sprintf()`` behave reasonably\nfor any user code call sites.\n\nThe ``%lld`` format is not supported to avoid depending on the ``long long``\ntype; this makes the replacement incompatible with the JSON fast path which\nmust thus be disabled.\n\nsscanf()\n--------\n\nThere's only one call site for ``sscanf()``, for JX parsing of pointers::\n\n    duk_bi_json.c:        (void) DUK_SSCANF((const char *) js_ctx->p, DUK_STR_FMT_PTR, &voidptr);\n\nThe exact format string here is ``%p`` and nothing else needs to be supported.\nFurther, when the minimal printf/scanf providers are used together we only\nneed to parse what we produce.  In particular:\n\n* Pointer prefix is ``0x``, no need to match ``0X`` for example.\n\n* All digits are ``[0-9a-f]`` with no need to match uppercase.\n\nBuilding \"duk\" with minimal printf/scanf\n========================================\n\nThe necessary defines in ``duk_config.h`` can be given to genconfig, but you\ncan also just make the following manual additions to the bottom of the config\nfile::\n\n    #include \"duk_minimal_printf.h\"\n\n    #undef DUK_SPRINTF\n    #define DUK_SPRINTF duk_minimal_sprintf\n    #undef DUK_SNPRINTF\n    #define DUK_SNPRINTF duk_minimal_snprintf\n    #undef DUK_VSNPRINTF\n    #define DUK_VSNPRINTF duk_minimal_vsnprintf\n    #undef DUK_SSCANF\n    #define DUK_SSCANF duk_minimal_sscanf\n\nThen just add ``duk_minimal_printf.c`` to build and compile the application.\n\nFuture work\n===========\n\n* Add support for ``%lld`` (maybe conditional) to allow JSON fast path to\n  be supported.\n\n* Add support for platforms such as 64-bit Windows where\n  ``sizeof(long) < sizeof(void *)``.  This can be achieved by using a few\n  typedefs internally; typedef an integer type large enough to hold all\n  formatted types.\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/minimal-printf/duk_minimal_printf.c",
    "content": "/*\n *  Minimal vsnprintf(), snprintf(), sprintf(), and sscanf() for Duktape.\n *  The supported conversion formats narrowly match what Duktape needs.\n */\n\n#include <stdarg.h>  /* va_list etc */\n#include <stddef.h>  /* size_t */\n#include <stdint.h>  /* SIZE_MAX */\n\n/* Write character with bound checking.  Offset 'off' is updated regardless\n * of whether an actual write is made.  This is necessary to satisfy snprintf()\n * return value semantics.\n */\n#define DUK__WRITE_CHAR(c) do { \\\n\t\tif (off < size) { \\\n\t\t\tstr[off] = (char) c; \\\n\t\t} \\\n\t\toff++; \\\n\t} while (0)\n\n/* Digits up to radix 16. */\nstatic const char duk__format_digits[16] = {\n\t'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'\n};\n\n/* Format an unsigned long with various options.  An unsigned long is large\n * enough for formatting all supported types.\n */\nstatic size_t duk__format_long(char *str,\n                               size_t size,\n                               size_t off,\n                               int fixed_length,\n                               char pad,\n                               int radix,\n                               int neg_sign,\n                               unsigned long v) {\n\tchar buf[24];  /* 2^64 = 18446744073709552000, length 20 */\n\tchar *required;\n\tchar *p;\n\tint i;\n\n\t/* Format in reverse order first.  Ensure at least one digit is output\n\t * to handle '0' correctly.  Note that space padding and zero padding\n\t * handle negative sign differently:\n\t *\n\t *     %9d and -321  => '     -321'\n\t *     %09d and -321 => '-00000321'\n\t */\n\n\tfor (i = 0; i < (int) sizeof(buf); i++) {\n\t\tbuf[i] = pad;  /* compiles into memset() equivalent, avoid memset() dependency */\n\t}\n\n\tp = buf;\n\tdo {\n\t\t*p++ = duk__format_digits[v % radix];\n\t\tv /= radix;\n\t} while (v != 0);\n\n\trequired = buf + fixed_length;\n\tif (p < required && pad == (char) '0') {\n\t\t/* Zero padding and we didn't reach maximum length: place\n\t\t * negative sign at the last position.  We can't get here\n\t\t * with fixed_length == 0 so that required[-1] is safe.\n\t\t *\n\t\t * Technically we should only do this for 'neg_sign == 1',\n\t\t * but it's OK to advance the pointer even when that's not\n\t\t * the case.\n\t\t */\n\t\tp = required - 1;\n\t}\n\tif (neg_sign) {\n\t\t*p++ = (char) '-';\n\t}\n\tif (p < required) {\n\t\tp = required;\n\t}\n\n\t/* Now [buf,p[ contains the result in reverse; copy into place. */\n\n\twhile (p > buf) {\n\t\tp--;\n\t\tDUK__WRITE_CHAR(*p);\n\t}\n\n\treturn off;\n}\n\n/* Parse a pointer.  Must parse whatever is produced by '%p' in sprintf(). */\nstatic int duk__parse_pointer(const char *str, void **out) {\n\tconst unsigned char *p;\n\tunsigned char ch;\n\tint count;\n\tint limit;\n\tlong val;  /* assume void * fits into long */\n\n\t/* We only need to parse what our minimal printf() produces, so that\n\t * we can check for a '0x' prefix, and assume all hex digits are\n\t * lowercase.\n\t */\n\n\tp = (const unsigned char *) str;\n\tif (p[0] != (unsigned char) '0' || p[1] != (unsigned char) 'x') {\n\t\treturn 0;\n\t}\n\tp += 2;\n\n\tfor (val = 0, count = 0, limit = sizeof(void *) * 2; count < limit; count++) {\n\t\tch = *p++;\n\n\t\tval <<= 4;\n\t\tif (ch >= (unsigned char) '0' && ch <= (unsigned char) '9') {\n\t\t\tval += ch - (unsigned char) '0';\n\t\t} else if (ch >= (unsigned char) 'a' && ch <= (unsigned char) 'f') {\n\t\t\tval += ch - (unsigned char) 'a' + 0x0a;\n\t\t} else {\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\t/* The input may end at a NUL or garbage may follow.  As long as we\n\t * parse the '%p' correctly, garbage is allowed to follow, and the\n\t * JX pointer parsing also relies on that.\n\t */\n\n\t*out = (void *) val;\n\treturn 1;\n}\n\n/* Minimal vsnprintf() entry point. */\nint duk_minimal_vsnprintf(char *str, size_t size, const char *format, va_list ap) {\n\tsize_t off = 0;\n\tconst char *p;\n#if 0\n\tconst char *p_tmp;\n\tconst char *p_fmt_start;\n#endif\n\tchar c;\n\tchar pad;\n\tint fixed_length;\n\tint is_long;\n\n\t/* Assume str != NULL unless size == 0.\n\t * Assume format != NULL.\n\t */\n\n\tp = format;\n\tfor (;;) {\n\t\tc = *p++;\n\t\tif (c == (char) 0) {\n\t\t\tbreak;\n\t\t}\n\t\tif (c != (char) '%') {\n\t\t\tDUK__WRITE_CHAR(c);\n\t\t\tcontinue;\n\t\t}\n\n\t\t/* Start format sequence.  Scan flags and format specifier. */\n\n#if 0\n\t\tp_fmt_start = p - 1;\n#endif\n\t\tis_long = 0;\n\t\tpad = ' ';\n\t\tfixed_length = 0;\n\t\tfor (;;) {\n\t\t\tc = *p++;\n\t\t\tif (c == (char) 'l') {\n\t\t\t\tis_long = 1;\n\t\t\t} else if (c == (char) '0') {\n\t\t\t\t/* Only support pad character '0'. */\n\t\t\t\tpad = '0';\n\t\t\t} else if (c >= (char) '1' && c <= (char) '9') {\n\t\t\t\t/* Only support fixed lengths 1-9. */\n\t\t\t\tfixed_length = (int) (c - (char) '0');\n\t\t\t} else if (c == (char) 'd') {\n\t\t\t\tlong v;\n\t\t\t\tint neg_sign = 0;\n\t\t\t\tif (is_long) {\n\t\t\t\t\tv = va_arg(ap, long);\n\t\t\t\t} else {\n\t\t\t\t\tv = (long) va_arg(ap, int);\n\t\t\t\t}\n\t\t\t\tif (v < 0) {\n\t\t\t\t\tneg_sign = 1;\n\t\t\t\t\tv = -v;\n\t\t\t\t}\n\t\t\t\toff = duk__format_long(str, size, off, fixed_length, pad, 10, neg_sign, (unsigned long) v);\n\t\t\t\tbreak;\n\t\t\t} else if (c == (char) 'u') {\n\t\t\t\tunsigned long v;\n\t\t\t\tif (is_long) {\n\t\t\t\t\tv = va_arg(ap, unsigned long);\n\t\t\t\t} else {\n\t\t\t\t\tv = (unsigned long) va_arg(ap, unsigned int);\n\t\t\t\t}\n\t\t\t\toff = duk__format_long(str, size, off, fixed_length, pad, 10, 0, v);\n\t\t\t\tbreak;\n\t\t\t} else if (c == (char) 'x') {\n\t\t\t\tunsigned long v;\n\t\t\t\tif (is_long) {\n\t\t\t\t\tv = va_arg(ap, unsigned long);\n\t\t\t\t} else {\n\t\t\t\t\tv = (unsigned long) va_arg(ap, unsigned int);\n\t\t\t\t}\n\t\t\t\toff = duk__format_long(str, size, off, fixed_length, pad, 16, 0, v);\n\t\t\t\tbreak;\n\t\t\t} else if (c == (char) 'c') {\n\t\t\t\tchar v;\n\t\t\t\tv = (char) va_arg(ap, int);  /* intentionally not 'char' */\n\t\t\t\tDUK__WRITE_CHAR(v);\n\t\t\t\tbreak;\n\t\t\t} else if (c == (char) 's') {\n\t\t\t\tconst char *v;\n\t\t\t\tchar c_tmp;\n\t\t\t\tv = va_arg(ap, const char *);\n\t\t\t\tif (v) {\n\t\t\t\t\tfor (;;) {\n\t\t\t\t\t\tc_tmp = *v++;\n\t\t\t\t\t\tif (c_tmp) {\n\t\t\t\t\t\t\tDUK__WRITE_CHAR(c_tmp);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t} else if (c == (char) 'p') {\n\t\t\t\t/* Assume a void * can be represented by 'long'.  This is not\n\t\t\t\t * always the case.  NULL pointer is printed out as 0x0000...\n\t\t\t\t */\n\t\t\t\tvoid *v;\n\t\t\t\tv = va_arg(ap, void *);\n\t\t\t\tDUK__WRITE_CHAR('0');\n\t\t\t\tDUK__WRITE_CHAR('x');\n\t\t\t\toff = duk__format_long(str, size, off, sizeof(void *) * 2, '0', 16, 0, (unsigned long) v);\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\t/* Unrecognized, bail out early.  We could also emit the format\n\t\t\t\t * specifier verbatim, but it'd be a waste of footprint because\n\t\t\t\t * this case should never happen in practice.\n\t\t\t\t */\n#if 0\n\t\t\t\tDUK__WRITE_CHAR('!');\n#endif\n#if 0\n\t\t\t\tfor (p_tmp = p_fmt_start; p_tmp != p; p_tmp++) {\n\t\t\t\t\tDUK__WRITE_CHAR(*p_tmp);\n\t\t\t\t}\n\t\t\t\tbreak;\n#endif\n\t\t\t\tgoto finish;\n\t\t\t}\n\t\t}\n\t}\n\n finish:\n\tif (off < size) {\n\t\tstr[off] = (char) 0;  /* No increment for 'off', not counted in return value. */\n\t} else if (size > 0) {\n\t\t/* Forced termination. */\n\t\tstr[size - 1] = 0;\n\t}\n\n\treturn (int) off;\n}\n\n/* Minimal snprintf() entry point. */\nint duk_minimal_snprintf(char *str, size_t size, const char *format, ...) {\n\tva_list ap;\n\tint ret;\n\n\tva_start(ap, format);\n\tret = duk_minimal_vsnprintf(str, size, format, ap);\n\tva_end(ap);\n\n\treturn ret;\n}\n\n/* Minimal sprintf() entry point. */\nint duk_minimal_sprintf(char *str, const char *format, ...) {\n\tva_list ap;\n\tint ret;\n\n\tva_start(ap, format);\n\tret = duk_minimal_vsnprintf(str, SIZE_MAX, format, ap);\n\tva_end(ap);\n\n\treturn ret;\n}\n\n/* Minimal sscanf() entry point. */\nint duk_minimal_sscanf(const char *str, const char *format, ...) {\n\tva_list ap;\n\tint ret;\n\tvoid **out;\n\n\t/* Only the exact \"%p\" format is supported. */\n\tif (format[0] != (char) '%' ||\n\t    format[1] != (char) 'p' ||\n\t    format[2] != (char) 0) {\n\t}\n\n\tva_start(ap, format);\n\tout = va_arg(ap, void **);\n\tret = duk__parse_pointer(str, out);\n\tva_end(ap);\n\n\treturn ret;\n}\n\n#undef DUK__WRITE_CHAR\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/minimal-printf/duk_minimal_printf.h",
    "content": "#if !defined(DUK_MINIMAL_PRINTF_H_INCLUDED)\n#define DUK_MINIMAL_PRINTF_H_INCLUDED\n\n#include <stdarg.h>  /* va_list etc */\n#include <stddef.h>  /* size_t */\n\nextern int duk_minimal_sprintf(char *str, const char *format, ...);\nextern int duk_minimal_snprintf(char *str, size_t size, const char *format, ...);\nextern int duk_minimal_vsnprintf(char *str, size_t size, const char *format, va_list ap);\nextern int duk_minimal_sscanf(const char *str, const char *format, ...);\n\n#endif  /* DUK_MINIMAL_PRINTF_H_INCLUDED */\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/minimal-printf/test.c",
    "content": "#include <stdio.h>\n#include <string.h>\n#include \"duk_minimal_printf.h\"\n\nchar buffer[32];\n\nstatic void init_buffer(void) {\n\tint i;\n\n\tfor (i = 0; i < (int) sizeof(buffer); i++) {\n\t\tbuffer[i] = 0xff;\n\t}\n}\n\nstatic void dump_buffer(void) {\n\tint i;\n\tunsigned char c;\n\n\tprintf(\"Buffer: '\");\n\tfor (i = 0; i < (int) sizeof(buffer); i++) {\n\t\tc = (unsigned char) buffer[i];\n\t\tif (c < 0x20 || c >= 0x7e) {\n\t\t\tprintf(\"<%02x>\", (unsigned int) c);\n\t\t} else {\n\t\t\tprintf(\"%c\", (int) c);\n\t\t}\n\t}\n\tprintf(\"'\");\n#if 0\n\tprintf(\" -> \");\n\tprintf(\"Buffer:\");\n\tfor (i = 0; i < sizeof(buffer); i++) {\n\t\tc = (unsigned char) buffer[i];\n\t\tif (c <= 0x20 || c >= 0x7e) {\n\t\t\tprintf(\" <%02x>\", (unsigned int) c);\n\t\t} else {\n\t\t\tprintf(\" %c\", (char) c);\n\t\t}\n\t}\n#endif\n\tprintf(\"\\n\");\n}\n\nint main(int argc, char *argv[]) {\n\tint ret;\n\tvoid *voidptr;\n\tint i;\n\n\t(void) argc; (void) argv;\n\n\t/* Char format. */\n\tinit_buffer();\n\tduk_minimal_snprintf(buffer, sizeof(buffer), \"foo %c bar\", 'Z');\n\tdump_buffer();\n\n\t/* Signed long format. */\n\tinit_buffer();\n\tduk_minimal_snprintf(buffer, sizeof(buffer), \"%ld %9ld\", (long) 123, (long) 4321);\n\tdump_buffer();\n\n\t/* Signed long with zero padding. */\n\tinit_buffer();\n\tduk_minimal_snprintf(buffer, sizeof(buffer), \"%09ld\", (long) 4321);\n\tdump_buffer();\n\tinit_buffer();\n\tduk_minimal_snprintf(buffer, sizeof(buffer), \"%03ld %03ld %03ld\", (long) -4321, (long) -432, (long) -43);\n\tdump_buffer();\n\n\t/* Unsigned long with zero padding. */\n\tinit_buffer();\n\tduk_minimal_snprintf(buffer, sizeof(buffer), \"%03lu %03lu %03lu\", (long) -4321, (long) -432, (long) -43);\n\tdump_buffer();\n\n\t/* Signed integer. */\n\tinit_buffer();\n\tduk_minimal_snprintf(buffer, sizeof(buffer), \"%d %9d\", (int) 0, (int) 4321);\n\tdump_buffer();\n\n\t/* Signed negative integer, fixed field width. */\n\tinit_buffer();\n\tduk_minimal_snprintf(buffer, sizeof(buffer), \"%9d\", (int) -321);\n\tdump_buffer();\n\tinit_buffer();\n\tduk_minimal_snprintf(buffer, sizeof(buffer), \"%09d\", (int) -321);\n\tdump_buffer();\n\tprintf(\"  -- printf comparison: %9d %09d\\n\", -321, -321);\n\n\t/* Hex formatting. */\n\tinit_buffer();\n\tduk_minimal_snprintf(buffer, sizeof(buffer), \"%03x %03lx 0x%08lx\", (int) 510, (long) 5105, (long) 0xdeadbeef);\n\tdump_buffer();\n\n\t/* Pointer formatting, NULL and non-NULL. */\n\tinit_buffer();\n\tduk_minimal_snprintf(buffer, sizeof(buffer), \"%p %p\", (void *) NULL, (void *) buffer);\n\tdump_buffer();\n\n\t/* File/line like format test. */\n\tinit_buffer();\n\tduk_minimal_snprintf(buffer, sizeof(buffer), \"%s:%d\", \"foo bar quux\", 123);\n\tdump_buffer();\n\n\t/* Zero size output buffer. */\n\tinit_buffer();\n\tduk_minimal_snprintf(buffer, 0, \"%s:%d\", \"foo bar quux\", 123);\n\tdump_buffer();\n\tinit_buffer();\n\tduk_minimal_snprintf(buffer, 0, \"\");\n\tdump_buffer();\n\n\t/* NUL terminator boundary test. */\n\tinit_buffer();\n\tduk_minimal_snprintf(buffer, 7, \"foo: %s\", \"bar\");\n\tdump_buffer();\n\tinit_buffer();\n\tduk_minimal_snprintf(buffer, 8, \"foo: %s\", \"bar\");\n\tdump_buffer();\n\tinit_buffer();\n\tduk_minimal_snprintf(buffer, 9, \"foo: %s\", \"bar\");\n\tdump_buffer();\n\n\t/* sprintf() binding, uses SIZE_MAX internally. */\n\tinit_buffer();\n\tduk_minimal_sprintf(buffer, \"unbounded print %s\", \"foo\");\n\tdump_buffer();\n\n\t/* Pointer formatting; non-NULL and NULL. */\n\tinit_buffer();\n\tduk_minimal_snprintf(buffer, sizeof(buffer), \"%p %p\", (void *) NULL, (void *) 0xdeadbeef);\n\tdump_buffer();\n\n\t/* Pointer parsing, non-NULL (32-bit) pointer. */\n\tvoidptr = (void *) 123;\n\tret = duk_minimal_sscanf(\"0xdeadbeef\", \"%p\", &voidptr);\n\tprintf(\"ret=%d, void pointer: %p\\n\", ret, voidptr);\n\n\t/* Pointer parsing, NULL (32-bit) pointer. */\n\tvoidptr = (void *) 123;\n\tret = duk_minimal_sscanf(\"0x00000000\", \"%p\", &voidptr);\n\tprintf(\"ret=%d, void pointer: %p\\n\", ret, voidptr);\n\n\t/* Pointer parsing, non-NULL (32-bit) pointer but garbage follows. */\n\tvoidptr = (void *) 123;\n\tret = duk_minimal_sscanf(\"0xdeadbeefx\", \"%p\", &voidptr);\n\tprintf(\"ret=%d, void pointer: %p\\n\", ret, voidptr);\n\n\t/* Fixed width test over a range of widths. */\n\tfor (i = 0; i <= 9; i++) {\n\t\tchar fmtbuf[16];\n\n\t\tprintf(\"--- pos/neg fixed width test, i=%d\\n\", i);\n\n\t\t/* %0<i>d. %00d makes no sense, but tested anyway. */\n\t\tmemset((void *) fmtbuf, 0, sizeof(fmtbuf));\n\t\tfmtbuf[0] = (char) '%';\n\t\tfmtbuf[1] = (char) '0';\n\t\tfmtbuf[2] = (char) ('0' + i);\n\t\tfmtbuf[3] = 'd';\n\t\tinit_buffer();\n\t\tduk_minimal_sprintf(buffer, (const char *) fmtbuf, 321);\n\t\tdump_buffer();\n\t\tinit_buffer();\n\t\tduk_minimal_sprintf(buffer, (const char *) fmtbuf, -321);\n\t\tdump_buffer();\n\t\tprintf(\"  ==> printf: |\");\n\t\tprintf((const char *) fmtbuf, 321);\n\t\tprintf(\"| |\");\n\t\tprintf((const char *) fmtbuf, -321);\n\t\tprintf(\"|\\n\");\n\n\t\t/* %<i>d. */\n\t\tmemset((void *) fmtbuf, 0, sizeof(fmtbuf));\n\t\tfmtbuf[0] = (char) '%';\n\t\tfmtbuf[1] = (char) ('0' + i);\n\t\tfmtbuf[2] = 'd';\n\t\tinit_buffer();\n\t\tduk_minimal_sprintf(buffer, (const char *) fmtbuf, 321);\n\t\tdump_buffer();\n\t\tinit_buffer();\n\t\tduk_minimal_sprintf(buffer, (const char *) fmtbuf, -321);\n\t\tdump_buffer();\n\t\tprintf(\"  ==> printf: |\");\n\t\tprintf((const char *) fmtbuf, 321);\n\t\tprintf(\"| |\");\n\t\tprintf((const char *) fmtbuf, -321);\n\t\tprintf(\"|\\n\");\n\t}\n\n\treturn 0;\n}\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/module-duktape/Makefile",
    "content": "# For manual testing; say 'make' in extras/module-duktape and run ./test.\n# There's test coverage in tests/ecmascript, so tests here are very simple.\n\n.PHONY: test\ntest:\n\tgcc -std=c99 -Wall -Wextra -o $@ -I../../src/ -I. ../../src/duktape.c duk_module_duktape.c test.c -lm\n\t@printf '\\n'\n\t./test 'assert(typeof require === \"function\");'\n\t./test 'assert(require.name === \"require\");'\n\t./test 'assert(typeof Duktape.modLoaded === \"object\");'\n\t./test 'assert(typeof Duktape.modSearch === \"undefined\");'\n\t./test 'Duktape.modSearch = function myModSearch(id) { return \"exports.foo = 123;\" }; assert(require(\"dummy\").foo === 123);'\n\t./test 'Duktape.modSearch = function myModSearch(id) { return \"exports.foo = 234;\" }; delete Duktape; assert(typeof Duktape === \"undefined\"); assert(require(\"dummy\").foo === 234);'\n\t./test 'Duktape.modSearch = function myModSearch(id) { return \"exports.foo = 234; // comment\" }; delete Duktape; assert(typeof Duktape === \"undefined\"); assert(require(\"dummy\").foo === 234);'\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/module-duktape/README.rst",
    "content": "===============================================\nDuktape 1.x compatible module loading framework\n===============================================\n\nThe default built-in module loading framework was removed in Duktape 2.x\nbecause more flexibility was needed for module loading.  This directory\ncontains a Duktape 1.x compatible module loading framework which you can\nadd to your build:\n\n* Add ``duk_module_duktape.c`` to list of C sources to compile.\n\n* Ensure ``duk_module_duktape.h`` is in the include path.\n\n* Include the extra header in calling code and initialize the bindings::\n\n      #include \"duktape.h\"\n      #include \"duk_module_duktape.h\"\n\n      /* After initializing the Duktape heap or when creating a new\n       * thread with a new global environment:\n       */\n      duk_module_duktape_init(ctx);\n\n  Don't call ``duk_module_duktape_init()`` more than once for the same global\n  environment.\n\n* As usual in Duktape 1.x, you should define ``Duktape.modSearch()`` to provide\n  environment specific module lookups.\n\n* After these steps, ``require()`` will be registered to the global object and\n  the module system is ready to use.\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/module-duktape/duk_module_duktape.c",
    "content": "/*\n *  Duktape 1.x compatible module loading framework\n */\n\n#include \"duktape.h\"\n#include \"duk_module_duktape.h\"\n\n/* (v)snprintf() is missing before MSVC 2015.  Note that _(v)snprintf() does\n * NOT NUL terminate on truncation, but that's OK here.\n * http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010\n */\n#if defined(_MSC_VER) && (_MSC_VER < 1900)\n#define snprintf _snprintf\n#endif\n\n#if 0  /* Enable manually */\n#define DUK__ASSERT(x) do { \\\n\t\tif (!(x)) { \\\n\t\t\tfprintf(stderr, \"ASSERTION FAILED at %s:%d: \" #x \"\\n\", __FILE__, __LINE__); \\\n\t\t\tfflush(stderr);  \\\n\t\t} \\\n\t} while (0)\n#define DUK__ASSERT_TOP(ctx,val) do { \\\n\t\tDUK__ASSERT(duk_get_top((ctx)) == (val)); \\\n\t} while (0)\n#else\n#define DUK__ASSERT(x) do { (void) (x); } while (0)\n#define DUK__ASSERT_TOP(ctx,val) do { (void) ctx; (void) (val); } while (0)\n#endif\n\nstatic void duk__resolve_module_id(duk_context *ctx, const char *req_id, const char *mod_id) {\n\tduk_uint8_t buf[DUK_COMMONJS_MODULE_ID_LIMIT];\n\tduk_uint8_t *p;\n\tduk_uint8_t *q;\n\tduk_uint8_t *q_last;  /* last component */\n\tduk_int_t int_rc;\n\n\tDUK__ASSERT(req_id != NULL);\n\t/* mod_id may be NULL */\n\n\t/*\n\t *  A few notes on the algorithm:\n\t *\n\t *    - Terms are not allowed to begin with a period unless the term\n\t *      is either '.' or '..'.  This simplifies implementation (and\n\t *      is within CommonJS modules specification).\n\t *\n\t *    - There are few output bound checks here.  This is on purpose:\n\t *      the resolution input is length checked and the output is never\n\t *      longer than the input.  The resolved output is written directly\n\t *      over the input because it's never longer than the input at any\n\t *      point in the algorithm.\n\t *\n\t *    - Non-ASCII characters are processed as individual bytes and\n\t *      need no special treatment.  However, U+0000 terminates the\n\t *      algorithm; this is not an issue because U+0000 is not a\n\t *      desirable term character anyway.\n\t */\n\n\t/*\n\t *  Set up the resolution input which is the requested ID directly\n\t *  (if absolute or no current module path) or with current module\n\t *  ID prepended (if relative and current module path exists).\n\t *\n\t *  Suppose current module is 'foo/bar' and relative path is './quux'.\n\t *  The 'bar' component must be replaced so the initial input here is\n\t *  'foo/bar/.././quux'.\n\t */\n\n\tif (mod_id != NULL && req_id[0] == '.') {\n\t\tint_rc = snprintf((char *) buf, sizeof(buf), \"%s/../%s\", mod_id, req_id);\n\t} else {\n\t\tint_rc = snprintf((char *) buf, sizeof(buf), \"%s\", req_id);\n\t}\n\tif (int_rc >= (duk_int_t) sizeof(buf) || int_rc < 0) {\n\t\t/* Potentially truncated, NUL not guaranteed in any case.\n\t\t * The (int_rc < 0) case should not occur in practice.\n\t\t */\n\t\tgoto resolve_error;\n\t}\n\tDUK__ASSERT(strlen((const char *) buf) < sizeof(buf));  /* at most sizeof(buf) - 1 */\n\n\t/*\n\t *  Resolution loop.  At the top of the loop we're expecting a valid\n\t *  term: '.', '..', or a non-empty identifier not starting with a period.\n\t */\n\n\tp = buf;\n\tq = buf;\n\tfor (;;) {\n\t\tduk_uint_fast8_t c;\n\n\t\t/* Here 'p' always points to the start of a term.\n\t\t *\n\t\t * We can also unconditionally reset q_last here: if this is\n\t\t * the last (non-empty) term q_last will have the right value\n\t\t * on loop exit.\n\t\t */\n\n\t\tDUK__ASSERT(p >= q);  /* output is never longer than input during resolution */\n\n\t\tq_last = q;\n\n\t\tc = *p++;\n\t\tif (c == 0) {\n\t\t\tgoto resolve_error;\n\t\t} else if (c == '.') {\n\t\t\tc = *p++;\n\t\t\tif (c == '/') {\n\t\t\t\t/* Term was '.' and is eaten entirely (including dup slashes). */\n\t\t\t\tgoto eat_dup_slashes;\n\t\t\t}\n\t\t\tif (c == '.' && *p == '/') {\n\t\t\t\t/* Term was '..', backtrack resolved name by one component.\n\t\t\t\t *  q[-1] = previous slash (or beyond start of buffer)\n\t\t\t\t *  q[-2] = last char of previous component (or beyond start of buffer)\n\t\t\t\t */\n\t\t\t\tp++;  /* eat (first) input slash */\n\t\t\t\tDUK__ASSERT(q >= buf);\n\t\t\t\tif (q == buf) {\n\t\t\t\t\tgoto resolve_error;\n\t\t\t\t}\n\t\t\t\tDUK__ASSERT(*(q - 1) == '/');\n\t\t\t\tq--;  /* Backtrack to last output slash (dups already eliminated). */\n\t\t\t\tfor (;;) {\n\t\t\t\t\t/* Backtrack to previous slash or start of buffer. */\n\t\t\t\t\tDUK__ASSERT(q >= buf);\n\t\t\t\t\tif (q == buf) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif (*(q - 1) == '/') {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tq--;\n\t\t\t\t}\n\t\t\t\tgoto eat_dup_slashes;\n\t\t\t}\n\t\t\tgoto resolve_error;\n\t\t} else if (c == '/') {\n\t\t\t/* e.g. require('/foo'), empty terms not allowed */\n\t\t\tgoto resolve_error;\n\t\t} else {\n\t\t\tfor (;;) {\n\t\t\t\t/* Copy term name until end or '/'. */\n\t\t\t\t*q++ = c;\n\t\t\t\tc = *p++;\n\t\t\t\tif (c == 0) {\n\t\t\t\t\t/* This was the last term, and q_last was\n\t\t\t\t\t * updated to match this term at loop top.\n\t\t\t\t\t */\n\t\t\t\t\tgoto loop_done;\n\t\t\t\t} else if (c == '/') {\n\t\t\t\t\t*q++ = '/';\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\t/* write on next loop */\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t eat_dup_slashes:\n\t\tfor (;;) {\n\t\t\t/* eat dup slashes */\n\t\t\tc = *p;\n\t\t\tif (c != '/') {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tp++;\n\t\t}\n\t}\n loop_done:\n\t/* Output #1: resolved absolute name. */\n\tDUK__ASSERT(q >= buf);\n\tduk_push_lstring(ctx, (const char *) buf, (size_t) (q - buf));\n\n\t/* Output #2: last component name. */\n\tDUK__ASSERT(q >= q_last);\n\tDUK__ASSERT(q_last >= buf);\n\tduk_push_lstring(ctx, (const char *) q_last, (size_t) (q - q_last));\n\treturn;\n\n resolve_error:\n\tduk_error(ctx, DUK_ERR_TYPE_ERROR, \"cannot resolve module id: %s\", (const char *) req_id);\n}\n\n/* Stack indices for better readability. */\n#define DUK__IDX_REQUESTED_ID   0   /* module id requested */\n#define DUK__IDX_REQUIRE        1   /* current require() function */\n#define DUK__IDX_REQUIRE_ID     2   /* the base ID of the current require() function, resolution base */\n#define DUK__IDX_RESOLVED_ID    3   /* resolved, normalized absolute module ID */\n#define DUK__IDX_LASTCOMP       4   /* last component name in resolved path */\n#define DUK__IDX_DUKTAPE        5   /* Duktape object */\n#define DUK__IDX_MODLOADED      6   /* Duktape.modLoaded[] module cache */\n#define DUK__IDX_UNDEFINED      7   /* 'undefined', artifact of lookup */\n#define DUK__IDX_FRESH_REQUIRE  8   /* new require() function for module, updated resolution base */\n#define DUK__IDX_EXPORTS        9   /* default exports table */\n#define DUK__IDX_MODULE         10  /* module object containing module.exports, etc */\n\nstatic duk_ret_t duk__require(duk_context *ctx) {\n\tconst char *str_req_id;  /* requested identifier */\n\tconst char *str_mod_id;  /* require.id of current module */\n\tduk_int_t pcall_rc;\n\n\t/* NOTE: we try to minimize code size by avoiding unnecessary pops,\n\t * so the stack looks a bit cluttered in this function.  DUK__ASSERT_TOP()\n\t * assertions are used to ensure stack configuration is correct at each\n\t * step.\n\t */\n\n\t/*\n\t *  Resolve module identifier into canonical absolute form.\n\t */\n\n\tstr_req_id = duk_require_string(ctx, DUK__IDX_REQUESTED_ID);\n\tduk_push_current_function(ctx);\n\tduk_get_prop_string(ctx, -1, \"id\");\n\tstr_mod_id = duk_get_string(ctx, DUK__IDX_REQUIRE_ID);  /* ignore non-strings */\n\tduk__resolve_module_id(ctx, str_req_id, str_mod_id);\n\tstr_req_id = NULL;\n\tstr_mod_id = NULL;\n\n\t/* [ requested_id require require.id resolved_id last_comp ] */\n\tDUK__ASSERT_TOP(ctx, DUK__IDX_LASTCOMP + 1);\n\n\t/*\n\t *  Cached module check.\n\t *\n\t *  If module has been loaded or its loading has already begun without\n\t *  finishing, return the same cached value (module.exports).  The\n\t *  value is registered when module load starts so that circular\n\t *  references can be supported to some extent.\n\t */\n\n\tduk_push_global_stash(ctx);\n\tduk_get_prop_string(ctx, -1, \"\\xff\" \"module:Duktape\");\n\tduk_remove(ctx, -2);  /* Lookup stashed, original 'Duktape' object. */\n\tduk_get_prop_string(ctx, DUK__IDX_DUKTAPE, \"modLoaded\");  /* Duktape.modLoaded */\n\tduk_require_type_mask(ctx, DUK__IDX_MODLOADED, DUK_TYPE_MASK_OBJECT);\n\tDUK__ASSERT_TOP(ctx, DUK__IDX_MODLOADED + 1);\n\n\tduk_dup(ctx, DUK__IDX_RESOLVED_ID);\n\tif (duk_get_prop(ctx, DUK__IDX_MODLOADED)) {\n\t\t/* [ requested_id require require.id resolved_id last_comp Duktape Duktape.modLoaded Duktape.modLoaded[id] ] */\n\t\tduk_get_prop_string(ctx, -1, \"exports\");  /* return module.exports */\n\t\treturn 1;\n\t}\n\tDUK__ASSERT_TOP(ctx, DUK__IDX_UNDEFINED + 1);\n\n\t/* [ requested_id require require.id resolved_id last_comp Duktape Duktape.modLoaded undefined ] */\n\n\t/*\n\t *  Module not loaded (and loading not started previously).\n\t *\n\t *  Create a new require() function with 'id' set to resolved ID\n\t *  of module being loaded.  Also create 'exports' and 'module'\n\t *  tables but don't register exports to the loaded table yet.\n\t *  We don't want to do that unless the user module search callbacks\n\t *  succeeds in finding the module.\n\t */\n\n\t/* Fresh require: require.id is left configurable (but not writable)\n\t * so that is not easy to accidentally tweak it, but it can still be\n\t * done with Object.defineProperty().\n\t *\n\t * XXX: require.id could also be just made non-configurable, as there\n\t * is no practical reason to touch it (at least from Ecmascript code).\n\t */\n\tduk_push_c_function(ctx, duk__require, 1 /*nargs*/);\n\tduk_push_string(ctx, \"name\");\n\tduk_push_string(ctx, \"require\");\n\tduk_def_prop(ctx, DUK__IDX_FRESH_REQUIRE, DUK_DEFPROP_HAVE_VALUE);  /* not writable, not enumerable, not configurable */\n\tduk_push_string(ctx, \"id\");\n\tduk_dup(ctx, DUK__IDX_RESOLVED_ID);\n\tduk_def_prop(ctx, DUK__IDX_FRESH_REQUIRE, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_SET_CONFIGURABLE);  /* a fresh require() with require.id = resolved target module id */\n\n\t/* Module table:\n\t * - module.exports: initial exports table (may be replaced by user)\n\t * - module.id is non-writable and non-configurable, as the CommonJS\n\t *   spec suggests this if possible\n\t * - module.filename: not set, defaults to resolved ID if not explicitly\n\t *   set by modSearch() (note capitalization, not .fileName, matches Node.js)\n\t * - module.name: not set, defaults to last component of resolved ID if\n\t *   not explicitly set by modSearch()\n\t */\n\tduk_push_object(ctx);  /* exports */\n\tduk_push_object(ctx);  /* module */\n\tduk_push_string(ctx, \"exports\");\n\tduk_dup(ctx, DUK__IDX_EXPORTS);\n\tduk_def_prop(ctx, DUK__IDX_MODULE, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_SET_WRITABLE | DUK_DEFPROP_SET_CONFIGURABLE);  /* module.exports = exports */\n\tduk_push_string(ctx, \"id\");\n\tduk_dup(ctx, DUK__IDX_RESOLVED_ID);  /* resolved id: require(id) must return this same module */\n\tduk_def_prop(ctx, DUK__IDX_MODULE, DUK_DEFPROP_HAVE_VALUE);  /* module.id = resolved_id; not writable, not enumerable, not configurable */\n\tduk_compact(ctx, DUK__IDX_MODULE);  /* module table remains registered to modLoaded, minimize its size */\n\tDUK__ASSERT_TOP(ctx, DUK__IDX_MODULE + 1);\n\n\t/* [ requested_id require require.id resolved_id last_comp Duktape Duktape.modLoaded undefined fresh_require exports module ] */\n\n\t/* Register the module table early to modLoaded[] so that we can\n\t * support circular references even in modSearch().  If an error\n\t * is thrown, we'll delete the reference.\n\t */\n\tduk_dup(ctx, DUK__IDX_RESOLVED_ID);\n\tduk_dup(ctx, DUK__IDX_MODULE);\n\tduk_put_prop(ctx, DUK__IDX_MODLOADED);  /* Duktape.modLoaded[resolved_id] = module */\n\n\t/*\n\t *  Call user provided module search function and build the wrapped\n\t *  module source code (if necessary).  The module search function\n\t *  can be used to implement pure Ecmacsript, pure C, and mixed\n\t *  Ecmascript/C modules.\n\t *\n\t *  The module search function can operate on the exports table directly\n\t *  (e.g. DLL code can register values to it).  It can also return a\n\t *  string which is interpreted as module source code (if a non-string\n\t *  is returned the module is assumed to be a pure C one).  If a module\n\t *  cannot be found, an error must be thrown by the user callback.\n\t *\n\t *  Because Duktape.modLoaded[] already contains the module being\n\t *  loaded, circular references for C modules should also work\n\t *  (although expected to be quite rare).\n\t */\n\n\tduk_push_string(ctx, \"(function(require,exports,module){\");\n\n\t/* Duktape.modSearch(resolved_id, fresh_require, exports, module). */\n\tduk_get_prop_string(ctx, DUK__IDX_DUKTAPE, \"modSearch\");  /* Duktape.modSearch */\n\tduk_dup(ctx, DUK__IDX_RESOLVED_ID);\n\tduk_dup(ctx, DUK__IDX_FRESH_REQUIRE);\n\tduk_dup(ctx, DUK__IDX_EXPORTS);\n\tduk_dup(ctx, DUK__IDX_MODULE);  /* [ ... Duktape.modSearch resolved_id last_comp fresh_require exports module ] */\n\tpcall_rc = duk_pcall(ctx, 4 /*nargs*/);  /* -> [ ... source ] */\n\tDUK__ASSERT_TOP(ctx, DUK__IDX_MODULE + 3);\n\n\tif (pcall_rc != DUK_EXEC_SUCCESS) {\n\t\t/* Delete entry in Duktape.modLoaded[] and rethrow. */\n\t\tgoto delete_rethrow;\n\t}\n\n\t/* If user callback did not return source code, module loading\n\t * is finished (user callback initialized exports table directly).\n\t */\n\tif (!duk_is_string(ctx, -1)) {\n\t\t/* User callback did not return source code, so module loading\n\t\t * is finished: just update modLoaded with final module.exports\n\t\t * and we're done.\n\t\t */\n\t\tgoto return_exports;\n\t}\n\n\t/* Finish the wrapped module source.  Force module.filename as the\n\t * function .fileName so it gets set for functions defined within a\n\t * module.  This also ensures loggers created within the module get\n\t * the module ID (or overridden filename) as their default logger name.\n\t * (Note capitalization: .filename matches Node.js while .fileName is\n\t * used elsewhere in Duktape.)\n\t */\n\tduk_push_string(ctx, \"\\n})\");  /* Newline allows module last line to contain a // comment. */\n\tduk_concat(ctx, 3);\n\tif (!duk_get_prop_string(ctx, DUK__IDX_MODULE, \"filename\")) {\n\t\t/* module.filename for .fileName, default to resolved ID if\n\t\t * not present.\n\t\t */\n\t\tduk_pop(ctx);\n\t\tduk_dup(ctx, DUK__IDX_RESOLVED_ID);\n\t}\n\tpcall_rc = duk_pcompile(ctx, DUK_COMPILE_EVAL);\n\tif (pcall_rc != DUK_EXEC_SUCCESS) {\n\t\tgoto delete_rethrow;\n\t}\n\tpcall_rc = duk_pcall(ctx, 0);  /* -> eval'd function wrapper (not called yet) */\n\tif (pcall_rc != DUK_EXEC_SUCCESS) {\n\t\tgoto delete_rethrow;\n\t}\n\n\t/* Module has now evaluated to a wrapped module function.  Force its\n\t * .name to match module.name (defaults to last component of resolved\n\t * ID) so that it is shown in stack traces too.  Note that we must not\n\t * introduce an actual name binding into the function scope (which is\n\t * usually the case with a named function) because it would affect the\n\t * scope seen by the module and shadow accesses to globals of the same name.\n\t * This is now done by compiling the function as anonymous and then forcing\n\t * its .name without setting a \"has name binding\" flag.\n\t */\n\n\tduk_push_string(ctx, \"name\");\n\tif (!duk_get_prop_string(ctx, DUK__IDX_MODULE, \"name\")) {\n\t\t/* module.name for .name, default to last component if\n\t\t * not present.\n\t\t */\n\t\tduk_pop(ctx);\n\t\tduk_dup(ctx, DUK__IDX_LASTCOMP);\n\t}\n\tduk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_FORCE);\n\n\t/*\n\t *  Call the wrapped module function.\n\t *\n\t *  Use a protected call so that we can update Duktape.modLoaded[resolved_id]\n\t *  even if the module throws an error.\n\t */\n\n\t/* [ requested_id require require.id resolved_id last_comp Duktape Duktape.modLoaded undefined fresh_require exports module mod_func ] */\n\tDUK__ASSERT_TOP(ctx, DUK__IDX_MODULE + 2);\n\n\tduk_dup(ctx, DUK__IDX_EXPORTS);  /* exports (this binding) */\n\tduk_dup(ctx, DUK__IDX_FRESH_REQUIRE);  /* fresh require (argument) */\n\tduk_get_prop_string(ctx, DUK__IDX_MODULE, \"exports\");  /* relookup exports from module.exports in case it was changed by modSearch */\n\tduk_dup(ctx, DUK__IDX_MODULE);  /* module (argument) */\n\tDUK__ASSERT_TOP(ctx, DUK__IDX_MODULE + 6);\n\n\t/* [ requested_id require require.id resolved_id last_comp Duktape Duktape.modLoaded undefined fresh_require exports module mod_func exports fresh_require exports module ] */\n\n\tpcall_rc = duk_pcall_method(ctx, 3 /*nargs*/);\n\tif (pcall_rc != DUK_EXEC_SUCCESS) {\n\t\t/* Module loading failed.  Node.js will forget the module\n\t\t * registration so that another require() will try to load\n\t\t * the module again.  Mimic that behavior.\n\t\t */\n\t\tgoto delete_rethrow;\n\t}\n\n\t/* [ requested_id require require.id resolved_id last_comp Duktape Duktape.modLoaded undefined fresh_require exports module result(ignored) ] */\n\tDUK__ASSERT_TOP(ctx, DUK__IDX_MODULE + 2);\n\n\t/* fall through */\n\n return_exports:\n\tduk_get_prop_string(ctx, DUK__IDX_MODULE, \"exports\");\n\tduk_compact(ctx, -1);  /* compact the exports table */\n\treturn 1;  /* return module.exports */\n\n delete_rethrow:\n\tduk_dup(ctx, DUK__IDX_RESOLVED_ID);\n\tduk_del_prop(ctx, DUK__IDX_MODLOADED);  /* delete Duktape.modLoaded[resolved_id] */\n\tduk_throw(ctx);  /* rethrow original error */\n\treturn 0;  /* not reachable */\n}\n\nvoid duk_module_duktape_init(duk_context *ctx) {\n\t/* Stash 'Duktape' in case it's modified. */\n\tduk_push_global_stash(ctx);\n\tduk_get_global_string(ctx, \"Duktape\");\n\tduk_put_prop_string(ctx, -2, \"\\xff\" \"module:Duktape\");\n\tduk_pop(ctx);\n\n\t/* Register `require` as a global function. */\n\tduk_eval_string(ctx,\n\t\t\"(function(req){\"\n\t\t\"var D=Object.defineProperty;\"\n\t\t\"D(req,'name',{value:'require'});\"\n\t\t\"D(this,'require',{value:req,writable:true,configurable:true});\"\n\t\t\"D(Duktape,'modLoaded',{value:Object.create(null),writable:true,configurable:true});\"\n\t\t\"})\");\n\tduk_push_c_function(ctx, duk__require, 1 /*nargs*/);\n\tduk_call(ctx, 1);\n\tduk_pop(ctx);\n}\n\n#undef DUK__ASSERT\n#undef DUK__ASSERT_TOP\n#undef DUK__IDX_REQUESTED_ID\n#undef DUK__IDX_REQUIRE\n#undef DUK__IDX_REQUIRE_ID\n#undef DUK__IDX_RESOLVED_ID\n#undef DUK__IDX_LASTCOMP\n#undef DUK__IDX_DUKTAPE\n#undef DUK__IDX_MODLOADED\n#undef DUK__IDX_UNDEFINED\n#undef DUK__IDX_FRESH_REQUIRE\n#undef DUK__IDX_EXPORTS\n#undef DUK__IDX_MODULE\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/module-duktape/duk_module_duktape.h",
    "content": "#if !defined(DUK_MODULE_DUKTAPE_H_INCLUDED)\n#define DUK_MODULE_DUKTAPE_H_INCLUDED\n\n#include \"duktape.h\"\n\n/* Maximum length of CommonJS module identifier to resolve.  Length includes\n * both current module ID, requested (possibly relative) module ID, and a\n * slash in between.\n */\n#define  DUK_COMMONJS_MODULE_ID_LIMIT  256\n\nextern void duk_module_duktape_init(duk_context *ctx);\n\n#endif  /* DUK_MODULE_DUKTAPE_H_INCLUDED */\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/module-duktape/test.c",
    "content": "#include <stdio.h>\n#include <string.h>\n#include \"duktape.h\"\n#include \"duk_module_duktape.h\"\n\nstatic duk_ret_t handle_print(duk_context *ctx) {\n\tprintf(\"%s\\n\", duk_safe_to_string(ctx, 0));\n\treturn 0;\n}\n\nstatic duk_ret_t handle_assert(duk_context *ctx) {\n\tif (duk_to_boolean(ctx, 0)) {\n\t\treturn 0;\n\t}\n\tduk_error(ctx, DUK_ERR_ERROR, \"assertion failed: %s\", duk_safe_to_string(ctx, 1));\n\treturn 0;\n}\n\n\nint main(int argc, char *argv[]) {\n\tduk_context *ctx;\n\tint i;\n\tint exitcode = 0;\n\n\tctx = duk_create_heap_default();\n\tif (!ctx) {\n\t\treturn 1;\n\t}\n\n\tduk_push_c_function(ctx, handle_print, 1);\n\tduk_put_global_string(ctx, \"print\");\n\tduk_push_c_function(ctx, handle_assert, 2);\n\tduk_put_global_string(ctx, \"assert\");\n\n\tduk_module_duktape_init(ctx);\n\tprintf(\"top after init: %ld\\n\", (long) duk_get_top(ctx));\n\n\tfor (i = 1; i < argc; i++) {\n\t\tprintf(\"Evaling: %s\\n\", argv[i]);\n\t\tif (duk_peval_string(ctx, argv[i]) != 0) {\n\t\t\tif (duk_get_prop_string(ctx, -1, \"stack\")) {\n\t\t\t\tduk_replace(ctx, -2);\n\t\t\t} else {\n\t\t\t\tduk_pop(ctx);\n\t\t\t}\n\t\t\texitcode = 1;\n\t\t}\n\t\tprintf(\"--> %s\\n\", duk_safe_to_string(ctx, -1));\n\t\tduk_pop(ctx);\n\t}\n\n\tprintf(\"Done\\n\");\n\tduk_destroy_heap(ctx);\n\treturn exitcode;\n}\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/module-node/Makefile",
    "content": "# For manual testing; say 'make' in extras/module-node and run ./test.\n\n.PHONY: test\ntest:\n\tgcc -std=c99 -Wall -Wextra -o $@ -I../../src/ -I. ../../src/duktape.c duk_module_node.c test.c -lm\n\t@printf '\\n'\n\t./test 'assert(typeof require(\"pig\") === \"string\", \"basic require()\");'\n\t./test 'assert(require(\"cow\").indexOf(\"pig\") !== -1, \"nested require()\");'\n\t./test 'var ape1 = require(\"ape\"); var ape2 = require(\"ape\"); assert(ape1 === ape2, \"caching\");'\n\t./test 'var ape1 = require(\"ape\"); var inCache = \"ape.js\" in require.cache; delete require.cache[\"ape.js\"]; var ape2 = require(\"ape\"); assert(inCache && ape2 !== ape1, \"require.cache\");'\n\t./test 'var ape = require(\"ape\"); assert(typeof ape.module.require === \"function\", \"module.require()\");'\n\t./test 'var ape = require(\"ape\"); assert(ape.module.exports === ape, \"module.exports\");'\n\t./test 'var ape = require(\"ape\"); assert(ape.module.id === \"ape.js\" && ape.module.id === ape.module.filename, \"module.id\");'\n\t./test 'var ape = require(\"ape\"); assert(ape.module.filename === \"ape.js\", \"module.filename\");'\n\t./test 'var ape = require(\"ape\"); assert(ape.module.loaded === true && ape.wasLoaded === false, \"module.loaded\");'\n\t./test 'var ape = require(\"ape\"); assert(ape.__filename === \"ape.js\", \"__filename\");'\n\t./test 'var badger = require(\"badger\"); assert(badger.foo === 123 && badger.bar === 234, \"exports.foo assignment\");'\n\t./test 'var comment = require(\"comment\"); assert(comment.foo === 123 && comment.bar === 234, \"last line with // comment\");'\n\t./test 'var shebang = require(\"shebang\"); assert(shebang.foo === 123 && shebang.bar === 234, \"shebang\");'\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/module-node/README.rst",
    "content": "=====================================\nNode.js-like module loading framework\n=====================================\n\nThis directory contains an example module resolution and loading framework and\n``require()`` implementation based on the Node.js module system:\n\n* https://nodejs.org/api/modules.html\n\nThe application needs only to provide the module resolution and loading logic:\n\n* Add ``duk_module_node.c`` to list of C sources to compile.\n\n* Ensure ``duk_module_node.h`` is in the include path.\n\n* Include the extra header in calling code and initialize the bindings::\n\n      #include \"duktape.h\"\n      #include \"duk_module_node.h\"\n\n      /* After initializing the Duktape heap or when creating a new\n       * thread with a new global environment:\n       */\n      duk_push_object(ctx);\n      duk_push_c_function(ctx, cb_resolve_module, DUK_VARARGS);\n      duk_put_prop_string(ctx, -2, \"resolve\");\n      duk_push_c_function(ctx, cb_load_module, DUK_VARARGS);\n      duk_put_prop_string(ctx, -2, \"load\");\n      duk_module_node_init(ctx);\n\n  Do not call ``duk_module_node_init()`` more than once for the same global\n  environment.  Doing so is undefined behavior and may put the module system\n  in an inconsistent state.\n  \n  It is possible to replace the callbacks after initialization by setting the\n  following internal properties on the global stash:\n  \n  - ``\\xffmodResolve``\n  \n  - ``\\xffmodLoad``\n\n* The resolve callback is a Duktape/C function which takes the string passed\n  to ``require()`` and resolves it to a canonical module ID (for Node.js this\n  is usually the fully resolved filename of the module)::\n\n      duk_ret_t cb_resolve_module(duk_context *ctx) {\n          /*\n           *  Entry stack: [ requested_id parent_id ]\n           */\n\n          const char *requested_id = duk_get_string(ctx, 0);\n          const char *parent_id = duk_get_string(ctx, 1);  /* calling module */\n          const char *resolved_id;\n\n          /* Arrive at the canonical module ID somehow. */\n\n          duk_push_string(ctx, resolved_id);\n          return 1;  /*nrets*/\n      }\n\n  If the module ID cannot be resolved, the resolve callback should throw an\n  error, which will propagate out of the ``require()`` call.  Note also that\n  when the global ``require()`` is called, the parent ID is an empty string.\n\n* The load callback is a Duktape/C function which takes the resolved module ID\n  and: (1) returns the Ecmascript source code for the module or ``undefined``\n  if there's no source code, e.g. for pure C modules, (2) can populate\n  ``module.exports`` itself, and (3) can replace ``module.exports``::\n\n      duk_ret_t cb_load_module(duk_context *ctx) {\n          /*\n           *  Entry stack: [ resolved_id exports module ]\n           */\n\n          /* Arrive at the JS source code for the module somehow. */\n\n          duk_push_string(ctx, module_source);\n          return 1;  /*nrets*/\n      }\n\n  As with the resolve callback, the load callback should throw an error if the\n  module cannot be loaded for any reason.\n\n* After these steps, ``require()`` will be registered to the global object and\n  the module system is ready to use.\n\n* The main module (file being evaluated) should be loaded using\n  ``duk_module_node_peval_main()``.  This function registers the module in\n  ``require.main`` and thus should only be called once.\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/module-node/duk_module_node.c",
    "content": "/*\n *  Node.js-like module loading framework for Duktape\n *\n *  https://nodejs.org/api/modules.html\n */\n\n#include \"duktape.h\"\n#include \"duk_module_node.h\"\n\n#if DUK_VERSION >= 19999\nstatic duk_int_t duk__eval_module_source(duk_context *ctx, void *udata);\n#else\nstatic duk_int_t duk__eval_module_source(duk_context *ctx);\n#endif\nstatic void duk__push_module_object(duk_context *ctx, const char *id, duk_bool_t main);\n\nstatic duk_bool_t duk__get_cached_module(duk_context *ctx, const char *id) {\n\tduk_push_global_stash(ctx);\n\t(void) duk_get_prop_string(ctx, -1, \"\\xff\" \"requireCache\");\n\tif (duk_get_prop_string(ctx, -1, id)) {\n\t\tduk_remove(ctx, -2);\n\t\tduk_remove(ctx, -2);\n\t\treturn 1;\n\t} else {\n\t\tduk_pop_3(ctx);\n\t\treturn 0;\n\t}\n}\n\n/* Place a `module` object on the top of the value stack into the require cache\n * based on its `.id` property.  As a convenience to the caller, leave the\n * object on top of the value stack afterwards.\n */\nstatic void duk__put_cached_module(duk_context *ctx) {\n\t/* [ ... module ] */\n\n\tduk_push_global_stash(ctx);\n\t(void) duk_get_prop_string(ctx, -1, \"\\xff\" \"requireCache\");\n\tduk_dup(ctx, -3);\n\n\t/* [ ... module stash req_cache module ] */\n\n\t(void) duk_get_prop_string(ctx, -1, \"id\");\n\tduk_dup(ctx, -2);\n\tduk_put_prop(ctx, -4);\n\n\tduk_pop_3(ctx);  /* [ ... module ] */\n}\n\nstatic void duk__del_cached_module(duk_context *ctx, const char *id) {\n\tduk_push_global_stash(ctx);\n\t(void) duk_get_prop_string(ctx, -1, \"\\xff\" \"requireCache\");\n\tduk_del_prop_string(ctx, -1, id);\n\tduk_pop_2(ctx);\n}\n\nstatic duk_ret_t duk__handle_require(duk_context *ctx) {\n\t/*\n\t *  Value stack handling here is a bit sloppy but should be correct.\n\t *  Call handling will clean up any extra garbage for us.\n\t */\n\n\tconst char *id;\n\tconst char *parent_id;\n\tduk_idx_t module_idx;\n\tduk_idx_t stash_idx;\n\tduk_int_t ret;\n\n\tduk_push_global_stash(ctx);\n\tstash_idx = duk_normalize_index(ctx, -1);\n\n\tduk_push_current_function(ctx);\n\t(void) duk_get_prop_string(ctx, -1, \"\\xff\" \"moduleId\");\n\tparent_id = duk_require_string(ctx, -1);\n\t(void) parent_id;  /* not used directly; suppress warning */\n\n\t/* [ id stash require parent_id ] */\n\n\tid = duk_require_string(ctx, 0);\n\n\t(void) duk_get_prop_string(ctx, stash_idx, \"\\xff\" \"modResolve\");\n\tduk_dup(ctx, 0);   /* module ID */\n\tduk_dup(ctx, -3);  /* parent ID */\n\tduk_call(ctx, 2);\n\n\t/* [ ... stash ... resolved_id ] */\n\n\tid = duk_require_string(ctx, -1);\n\n\tif (duk__get_cached_module(ctx, id)) {\n\t\tgoto have_module;  /* use the cached module */\n\t}\n\n\tduk__push_module_object(ctx, id, 0 /*main*/);\n\tduk__put_cached_module(ctx);  /* module remains on stack */\n\n\t/*\n\t *  From here on out, we have to be careful not to throw.  If it can't be\n\t *  avoided, the error must be caught and the module removed from the\n\t *  require cache before rethrowing.  This allows the application to\n\t *  reattempt loading the module.\n\t */\n\n\tmodule_idx = duk_normalize_index(ctx, -1);\n\n\t/* [ ... stash ... resolved_id module ] */\n\n\t(void) duk_get_prop_string(ctx, stash_idx, \"\\xff\" \"modLoad\");\n\tduk_dup(ctx, -3);  /* resolved ID */\n\t(void) duk_get_prop_string(ctx, module_idx, \"exports\");\n\tduk_dup(ctx, module_idx);\n\tret = duk_pcall(ctx, 3);\n\tif (ret != DUK_EXEC_SUCCESS) {\n\t\tduk__del_cached_module(ctx, id);\n\t\tduk_throw(ctx);  /* rethrow */\n\t}\n\n\tif (duk_is_string(ctx, -1)) {\n\t\tduk_int_t ret;\n\n\t\t/* [ ... module source ] */\n\n#if DUK_VERSION >= 19999\n\t\tret = duk_safe_call(ctx, duk__eval_module_source, NULL, 2, 1);\n#else\n\t\tret = duk_safe_call(ctx, duk__eval_module_source, 2, 1);\n#endif\n\t\tif (ret != DUK_EXEC_SUCCESS) {\n\t\t\tduk__del_cached_module(ctx, id);\n\t\t\tduk_throw(ctx);  /* rethrow */\n\t\t}\n\t} else if (duk_is_undefined(ctx, -1)) {\n\t\tduk_pop(ctx);\n\t} else {\n\t\tduk__del_cached_module(ctx, id);\n\t\tduk_error(ctx, DUK_ERR_TYPE_ERROR, \"invalid module load callback return value\");\n\t}\n\n\t/* fall through */\n\n have_module:\n\t/* [ ... module ] */\n\n\t(void) duk_get_prop_string(ctx, -1, \"exports\");\n\treturn 1;\n}\n\nstatic void duk__push_require_function(duk_context *ctx, const char *id) {\n\tduk_push_c_function(ctx, duk__handle_require, 1);\n\tduk_push_string(ctx, \"name\");\n\tduk_push_string(ctx, \"require\");\n\tduk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE);\n\tduk_push_string(ctx, id);\n\tduk_put_prop_string(ctx, -2, \"\\xff\" \"moduleId\");\n\n\t/* require.cache */\n\tduk_push_global_stash(ctx);\n\t(void) duk_get_prop_string(ctx, -1, \"\\xff\" \"requireCache\");\n\tduk_put_prop_string(ctx, -3, \"cache\");\n\tduk_pop(ctx);\n\n\t/* require.main */\n\tduk_push_global_stash(ctx);\n\t(void) duk_get_prop_string(ctx, -1, \"\\xff\" \"mainModule\");\n\tduk_put_prop_string(ctx, -3, \"main\");\n\tduk_pop(ctx);\n}\n\nstatic void duk__push_module_object(duk_context *ctx, const char *id, duk_bool_t main) {\n\tduk_push_object(ctx);\n\n\t/* Set this as the main module, if requested */\n\tif (main) {\n\t\tduk_push_global_stash(ctx);\n\t\tduk_dup(ctx, -2);\n\t\tduk_put_prop_string(ctx, -2, \"\\xff\" \"mainModule\");\n\t\tduk_pop(ctx);\n\t}\n\n\t/* Node.js uses the canonicalized filename of a module for both module.id\n\t * and module.filename.  We have no concept of a file system here, so just\n\t * use the module ID for both values.\n\t */\n\tduk_push_string(ctx, id);\n\tduk_dup(ctx, -1);\n\tduk_put_prop_string(ctx, -3, \"filename\");\n\tduk_put_prop_string(ctx, -2, \"id\");\n\n\t/* module.exports = {} */\n\tduk_push_object(ctx);\n\tduk_put_prop_string(ctx, -2, \"exports\");\n\n\t/* module.loaded = false */\n\tduk_push_false(ctx);\n\tduk_put_prop_string(ctx, -2, \"loaded\");\n\n\t/* module.require */\n\tduk__push_require_function(ctx, id);\n\tduk_put_prop_string(ctx, -2, \"require\");\n}\n\n#if DUK_VERSION >= 19999\nstatic duk_int_t duk__eval_module_source(duk_context *ctx, void *udata) {\n#else\nstatic duk_int_t duk__eval_module_source(duk_context *ctx) {\n#endif\n\tconst char *src;\n\n\t/*\n\t *  Stack: [ ... module source ]\n\t */\n\n#if DUK_VERSION >= 19999\n\t(void) udata;\n#endif\n\n\t/* Wrap the module code in a function expression.  This is the simplest\n\t * way to implement CommonJS closure semantics and matches the behavior of\n\t * e.g. Node.js.\n\t */\n\tduk_push_string(ctx, \"(function(exports,require,module,__filename,__dirname){\");\n\tsrc = duk_require_string(ctx, -2);\n\tduk_push_string(ctx, (src[0] == '#' && src[1] == '!') ? \"//\" : \"\");  /* Shebang support. */\n\tduk_dup(ctx, -3);  /* source */\n\tduk_push_string(ctx, \"\\n})\");  /* Newline allows module last line to contain a // comment. */\n\tduk_concat(ctx, 4);\n\n\t/* [ ... module source func_src ] */\n\n\t(void) duk_get_prop_string(ctx, -3, \"filename\");\n\tduk_compile(ctx, DUK_COMPILE_EVAL);\n\tduk_call(ctx, 0);\n\n\t/* [ ... module source func ] */\n\n\t/* Set name for the wrapper function. */\n\tduk_push_string(ctx, \"name\");\n\tduk_push_string(ctx, \"main\");\n\tduk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_FORCE);\n\n\t/* call the function wrapper */\n\t(void) duk_get_prop_string(ctx, -3, \"exports\");   /* exports */\n\t(void) duk_get_prop_string(ctx, -4, \"require\");   /* require */\n\tduk_dup(ctx, -5);                                 /* module */\n\t(void) duk_get_prop_string(ctx, -6, \"filename\");  /* __filename */\n\tduk_push_undefined(ctx);                          /* __dirname */\n\tduk_call(ctx, 5);\n\n\t/* [ ... module source result(ignore) ] */\n\n\t/* module.loaded = true */\n\tduk_push_true(ctx);\n\tduk_put_prop_string(ctx, -4, \"loaded\");\n\n\t/* [ ... module source retval ] */\n\n\tduk_pop_2(ctx);\n\n\t/* [ ... module ] */\n\n\treturn 1;\n}\n\n/* Load a module as the 'main' module. */\nduk_ret_t duk_module_node_peval_main(duk_context *ctx, const char *path) {\n\t/*\n\t *  Stack: [ ... source ]\n\t */\n\n\tduk__push_module_object(ctx, path, 1 /*main*/);\n\t/* [ ... source module ] */\n\n\tduk_dup(ctx, 0);\n\t/* [ ... source module source ] */\n\n#if DUK_VERSION >= 19999\n\treturn duk_safe_call(ctx, duk__eval_module_source, NULL, 2, 1);\n#else\n\treturn duk_safe_call(ctx, duk__eval_module_source, 2, 1);\n#endif\n}\n\nvoid duk_module_node_init(duk_context *ctx) {\n\t/*\n\t *  Stack: [ ... options ] => [ ... ]\n\t */\n\n\tduk_idx_t options_idx;\n\n\tduk_require_object_coercible(ctx, -1);  /* error before setting up requireCache */\n\toptions_idx = duk_require_normalize_index(ctx, -1);\n\n\t/* Initialize the require cache to a fresh object. */\n\tduk_push_global_stash(ctx);\n\tduk_push_bare_object(ctx);\n\tduk_put_prop_string(ctx, -2, \"\\xff\" \"requireCache\");\n\tduk_pop(ctx);\n\n\t/* Stash callbacks for later use.  User code can overwrite them later\n\t * on directly by accessing the global stash.\n\t */\n\tduk_push_global_stash(ctx);\n\tduk_get_prop_string(ctx, options_idx, \"resolve\");\n\tduk_require_function(ctx, -1);\n\tduk_put_prop_string(ctx, -2, \"\\xff\" \"modResolve\");\n\tduk_get_prop_string(ctx, options_idx, \"load\");\n\tduk_require_function(ctx, -1);\n\tduk_put_prop_string(ctx, -2, \"\\xff\" \"modLoad\");\n\tduk_pop(ctx);\n\n\t/* Stash main module. */\n\tduk_push_global_stash(ctx);\n\tduk_push_undefined(ctx);\n\tduk_put_prop_string(ctx, -2, \"\\xff\" \"mainModule\");\n\tduk_pop(ctx);\n\n\t/* register `require` as a global function. */\n\tduk_push_global_object(ctx);\n\tduk_push_string(ctx, \"require\");\n\tduk__push_require_function(ctx, \"\");\n\tduk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE |\n\t                      DUK_DEFPROP_SET_WRITABLE |\n\t                      DUK_DEFPROP_SET_CONFIGURABLE);\n\tduk_pop(ctx);\n\n\tduk_pop(ctx);  /* pop argument */\n}\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/module-node/duk_module_node.h",
    "content": "#if !defined(DUK_MODULE_NODE_H_INCLUDED)\n#define DUK_MODULE_NODE_H_INCLUDED\n\n#include \"duktape.h\"\n\nDUK_EXTERNAL_DECL duk_ret_t duk_module_node_peval_main(duk_context *ctx, const char *path);\nDUK_EXTERNAL_DECL void duk_module_node_init(duk_context *ctx);\n\n#endif  /* DUK_MODULE_NODE_H_INCLUDED */\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/module-node/test.c",
    "content": "#include <stdio.h>\n#include <string.h>\n#include \"duktape.h\"\n#include \"duk_module_node.h\"\n\nstatic duk_ret_t cb_resolve_module(duk_context *ctx) {\n\tconst char *module_id;\n\tconst char *parent_id;\n\n\tmodule_id = duk_require_string(ctx, 0);\n\tparent_id = duk_require_string(ctx, 1);\n\n\tduk_push_sprintf(ctx, \"%s.js\", module_id);\n\tprintf(\"resolve_cb: id:'%s', parent-id:'%s', resolve-to:'%s'\\n\",\n\t\tmodule_id, parent_id, duk_get_string(ctx, -1));\n\n\treturn 1;\n}\n\nstatic duk_ret_t cb_load_module(duk_context *ctx) {\n\tconst char *filename;\n\tconst char *module_id;\n\n\tmodule_id = duk_require_string(ctx, 0);\n\tduk_get_prop_string(ctx, 2, \"filename\");\n\tfilename = duk_require_string(ctx, -1);\n\n\tprintf(\"load_cb: id:'%s', filename:'%s'\\n\", module_id, filename);\n\n\tif (strcmp(module_id, \"pig.js\") == 0) {\n\t\tduk_push_sprintf(ctx, \"module.exports = 'you\\\\'re about to get eaten by %s';\",\n\t\t\tmodule_id);\n\t} else if (strcmp(module_id, \"cow.js\") == 0) {\n\t\tduk_push_string(ctx, \"module.exports = require('pig');\");\n\t} else if (strcmp(module_id, \"ape.js\") == 0) {\n\t\tduk_push_string(ctx, \"module.exports = { module: module, __filename: __filename, wasLoaded: module.loaded };\");\n\t} else if (strcmp(module_id, \"badger.js\") == 0) {\n\t\tduk_push_string(ctx, \"exports.foo = 123; exports.bar = 234;\");\n\t} else if (strcmp(module_id, \"comment.js\") == 0) {\n\t\tduk_push_string(ctx, \"exports.foo = 123; exports.bar = 234; // comment\");\n\t} else if (strcmp(module_id, \"shebang.js\") == 0) {\n\t\tduk_push_string(ctx, \"#!ignored\\nexports.foo = 123; exports.bar = 234;\");\n\t} else {\n\t\tduk_error(ctx, DUK_ERR_TYPE_ERROR, \"cannot find module: %s\", module_id);\n\t}\n\n\treturn 1;\n}\n\nstatic duk_ret_t handle_print(duk_context *ctx) {\n\tprintf(\"%s\\n\", duk_safe_to_string(ctx, 0));\n\treturn 0;\n}\n\nstatic duk_ret_t handle_assert(duk_context *ctx) {\n\tif (duk_to_boolean(ctx, 0)) {\n\t\treturn 0;\n\t}\n\tduk_error(ctx, DUK_ERR_ERROR, \"assertion failed: %s\", duk_safe_to_string(ctx, 1));\n\treturn 0;\n}\n\nint main(int argc, char *argv[]) {\n\tduk_context *ctx;\n\tint i;\n\tint exitcode = 0;\n\n\tctx = duk_create_heap_default();\n\tif (!ctx) {\n\t\treturn 1;\n\t}\n\n\tduk_push_c_function(ctx, handle_print, 1);\n\tduk_put_global_string(ctx, \"print\");\n\tduk_push_c_function(ctx, handle_assert, 2);\n\tduk_put_global_string(ctx, \"assert\");\n\n\tduk_push_object(ctx);\n\tduk_push_c_function(ctx, cb_resolve_module, DUK_VARARGS);\n\tduk_put_prop_string(ctx, -2, \"resolve\");\n\tduk_push_c_function(ctx, cb_load_module, DUK_VARARGS);\n\tduk_put_prop_string(ctx, -2, \"load\");\n\tduk_module_node_init(ctx);\n\tprintf(\"top after init: %ld\\n\", (long) duk_get_top(ctx));\n\n\tfor (i = 1; i < argc; i++) {\n\t\tprintf(\"Evaling: %s\\n\", argv[i]);\n\t\tif (duk_peval_string(ctx, argv[i]) != 0) {\n\t\t\tif (duk_get_prop_string(ctx, -1, \"stack\")) {\n\t\t\t\tduk_replace(ctx, -2);\n\t\t\t} else {\n\t\t\t\tduk_pop(ctx);\n\t\t\t}\n\t\t\texitcode = 1;\n\t\t}\n\t\tprintf(\"--> %s\\n\", duk_safe_to_string(ctx, -1));\n\t\tduk_pop(ctx);\n\t}\n\n\tprintf(\"Done\\n\");\n\tduk_destroy_heap(ctx);\n\treturn exitcode;\n}\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/print-alert/Makefile",
    "content": "# For manual testing; say 'make' in extras/print-alert and run ./test.\n.PHONY: test\ntest:\n\tgcc -std=c99 -Wall -Wextra -otest -I../../src ../../src/duktape.c duk_print_alert.c test.c -lm\n\t./test 'print(\"foo\", \"bar\", 1, 2, 3)'\n\t./test 'alert(\"foo\", \"bar\", 1, 2, 3)'\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/print-alert/README.rst",
    "content": "===================================================\nDuktape 1.x compatible print() and alert() bindings\n===================================================\n\nThe default ``print()`` and ``alert()`` built-ins were removed in Duktape 2.x\nbecause they depended on stdout/stderr and were thus a portability issue for\nsome targets.  This directory contains Duktape 1.x compatible optional\nprint() and alert() bindings:\n\n* Add ``duk_print_alert.c`` to list of C sources to compile.\n\n* Ensure ``duk_print_alert.h`` is in the include path.\n\n* Include the extra header in calling code and initialize the bindings::\n\n      #include \"duktape.h\"\n      #include \"duk_print_alert.h\"\n\n      /* After initializing the Duktape heap or when creating a new\n       * thread with a new global environment:\n       */\n      duk_print_alert_init(ctx, 0 /*flags*/);\n\n  See ``duk_print_alert.h`` for available flags.\n\n* After these steps, ``print()`` and ``alert()`` will be registered to the\n  global object and are ready to use.\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/print-alert/duk_print_alert.c",
    "content": "/*\n *  Duktape 1.x compatible print() and alert() bindings.\n */\n\n#include <stdio.h>\n#include <string.h>\n#include \"duktape.h\"\n#include \"duk_print_alert.h\"\n\n#define DUK_PRINT_ALERT_FLUSH   /* Flush after stdout/stderr write (Duktape 1.x: yes) */\n#undef DUK_PRINT_ALERT_SMALL    /* Prefer smaller footprint (but slower and more memory churn) */\n\n#if defined(DUK_PRINT_ALERT_SMALL)\nstatic duk_ret_t duk__print_alert_helper(duk_context *ctx, FILE *fh) {\n\tduk_idx_t nargs;\n\n\tnargs = duk_get_top(ctx);\n\n\t/* If argument count is 1 and first argument is a buffer, write the buffer\n\t * as raw data into the file without a newline; this allows exact control\n\t * over stdout/stderr without an additional entrypoint (useful for now).\n\t * Otherwise current print/alert semantics are to ToString() coerce\n\t * arguments, join them with a single space, and append a newline.\n\t */\n\n\tif (nargs == 1 && duk_is_buffer(ctx, 0)) {\n\t\tbuf = (const duk_uint8_t *) duk_get_buffer(ctx, 0, &sz_buf);\n\t\tfwrite((const void *) buf, 1, (size_t) sz_buf, fh);\n\t} else {\n\t\tduk_push_string(ctx, \" \");\n\t\tduk_insert(ctx, 0);\n\t\tduk_concat(ctx, nargs);\n\t\tfprintf(fh, \"%s\\n\", duk_require_string(ctx, -1));\n\t}\n\n#if defined(DUK_PRINT_ALERT_FLUSH)\n\tfflush(fh);\n#endif\n\n\treturn 0;\n}\n#else\n/* Faster, less churn, higher footprint option. */\nstatic duk_ret_t duk__print_alert_helper(duk_context *ctx, FILE *fh) {\n\tduk_idx_t nargs;\n\tconst duk_uint8_t *buf;\n\tduk_size_t sz_buf;\n\tconst char nl = (const char) '\\n';\n\tduk_uint8_t buf_stack[256];\n\n\tnargs = duk_get_top(ctx);\n\n\t/* If argument count is 1 and first argument is a buffer, write the buffer\n\t * as raw data into the file without a newline; this allows exact control\n\t * over stdout/stderr without an additional entrypoint (useful for now).\n\t * Otherwise current print/alert semantics are to ToString() coerce\n\t * arguments, join them with a single space, and append a newline.\n\t */\n\n\tif (nargs == 1 && duk_is_buffer(ctx, 0)) {\n\t\tbuf = (const duk_uint8_t *) duk_get_buffer(ctx, 0, &sz_buf);\n\t} else if (nargs > 0) {\n\t\tduk_idx_t i;\n\t\tduk_size_t sz_str;\n\t\tconst duk_uint8_t *p_str;\n\t\tduk_uint8_t *p;\n\n\t\tsz_buf = (duk_size_t) nargs;  /* spaces (nargs - 1) + newline */\n\t\tfor (i = 0; i < nargs; i++) {\n\t\t\t(void) duk_to_lstring(ctx, i, &sz_str);\n\t\t\tsz_buf += sz_str;\n\t\t}\n\n\t\tif (sz_buf <= sizeof(buf_stack)) {\n\t\t\tp = (duk_uint8_t *) buf_stack;\n\t\t} else {\n\t\t\tp = (duk_uint8_t *) duk_push_fixed_buffer(ctx, sz_buf);\n\t\t}\n\n\t\tbuf = (const duk_uint8_t *) p;\n\t\tfor (i = 0; i < nargs; i++) {\n\t\t\tp_str = (const duk_uint8_t *) duk_get_lstring(ctx, i, &sz_str);\n\t\t\tmemcpy((void *) p, (const void *) p_str, sz_str);\n\t\t\tp += sz_str;\n\t\t\t*p++ = (duk_uint8_t) (i == nargs - 1 ? '\\n' : ' ');\n\t\t}\n\t} else {\n\t\tbuf = (const duk_uint8_t *) &nl;\n\t\tsz_buf = 1;\n\t}\n\n\t/* 'buf' contains the string to write, 'sz_buf' contains the length\n\t * (which may be zero).\n\t */\n\n\tif (sz_buf > 0) {\n\t\tfwrite((const void *) buf, 1, (size_t) sz_buf, fh);\n#if defined(DUK_PRINT_ALERT_FLUSH)\n\t\tfflush(fh);\n#endif\n\t}\n\n\treturn 0;\n}\n#endif\n\nstatic duk_ret_t duk__print(duk_context *ctx) {\n\treturn duk__print_alert_helper(ctx, stdout);\n}\n\nstatic duk_ret_t duk__alert(duk_context *ctx) {\n\treturn duk__print_alert_helper(ctx, stderr);\n}\n\nvoid duk_print_alert_init(duk_context *ctx, duk_uint_t flags) {\n\t(void) flags;  /* unused at the moment */\n\n\t/* XXX: use duk_def_prop_list(). */\n\tduk_push_global_object(ctx);\n\tduk_push_string(ctx, \"print\");\n\tduk_push_c_function(ctx, duk__print, DUK_VARARGS);\n\tduk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_SET_WRITABLE | DUK_DEFPROP_SET_CONFIGURABLE);\n\tduk_push_string(ctx, \"alert\");\n\tduk_push_c_function(ctx, duk__alert, DUK_VARARGS);\n\tduk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_SET_WRITABLE | DUK_DEFPROP_SET_CONFIGURABLE);\n\tduk_pop(ctx);\n}\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/print-alert/duk_print_alert.h",
    "content": "#if !defined(DUK_PRINT_ALERT_H_INCLUDED)\n#define DUK_PRINT_ALERT_H_INCLUDED\n\n#include \"duktape.h\"\n\n/* No flags at the moment. */\n\nextern void duk_print_alert_init(duk_context *ctx, duk_uint_t flags);\n\n#endif /* DUK_PRINT_ALERT_H_INCLUDED */\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/extras/print-alert/test.c",
    "content": "#include <stdio.h>\n#include \"duktape.h\"\n#include \"duk_print_alert.h\"\n\nint main(int argc, char *argv[]) {\n\tduk_context *ctx;\n\tint i;\n\tint exitcode = 0;\n\n\tctx = duk_create_heap_default();\n\tif (!ctx) {\n\t\treturn 1;\n\t}\n\n\tduk_print_alert_init(ctx, 0 /*flags*/);\n\tprintf(\"top after init: %ld\\n\", (long) duk_get_top(ctx));\n\n\tfor (i = 1; i < argc; i++) {\n\t\tprintf(\"Evaling: %s\\n\", argv[i]);\n\t\tif (duk_peval_string(ctx, argv[i]) != 0) {\n\t\t\texitcode = 1;\n\t\t}\n\t\tprintf(\"--> %s\\n\", duk_safe_to_string(ctx, -1));\n\t\tduk_pop(ctx);\n\t}\n\n\tprintf(\"Done\\n\");\n\tduk_destroy_heap(ctx);\n\treturn exitcode;\n}\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/licenses/commonjs.txt",
    "content": "CommonJS specification snapshots are included in the references/\ndirectory.  CommonJS is under the MIT license: http://www.commonjs.org/.\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/licenses/lua.txt",
    "content": "Lua is under the MIT license: http://www.lua.org/license.html.\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/licenses/murmurhash2.txt",
    "content": "The MIT License\n\nCopyright (c) <year> <copyright holders>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/licenses/splitmix64.txt",
    "content": "/*  Written in 2015 by Sebastiano Vigna (vigna@acm.org)\n\nTo the extent possible under law, the author has dedicated all copyright\nand related and neighboring rights to this software to the public domain\nworldwide. This software is distributed without any warranty.\n\nSee <http://creativecommons.org/publicdomain/zero/1.0/>. */\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/licenses/xoroshiro128plus.txt",
    "content": "/*  Written in 2016 by David Blackman and Sebastiano Vigna (vigna@acm.org)\n\nTo the extent possible under law, the author has dedicated all copyright\nand related and neighboring rights to this software to the public domain\nworldwide. This software is distributed without any warranty.\n\nSee <http://creativecommons.org/publicdomain/zero/1.0/>. */\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/src/duk_config.h",
    "content": "/*\n *  duk_config.h configuration header generated by genconfig.py.\n *\n *  Git commit: 1f1f51a4f9595ffe8def0e9ba45b20f14679393a\n *  Git describe: v2.1.0\n *  Git branch: master\n *\n *  Supported platforms:\n *      - Mac OSX, iPhone, Darwin\n *      - Orbis\n *      - OpenBSD\n *      - Generic BSD\n *      - Atari ST TOS\n *      - AmigaOS\n *      - Durango (XboxOne)\n *      - Windows\n *      - Flashplayer (Crossbridge)\n *      - QNX\n *      - TI-Nspire\n *      - Emscripten\n *      - Linux\n *      - Solaris\n *      - AIX\n *      - HPUX\n *      - Generic POSIX\n *      - Cygwin\n *      - Generic UNIX\n *      - Generic fallback\n *\n *  Supported architectures:\n *      - x86\n *      - x64\n *      - x32\n *      - ARM 32-bit\n *      - ARM 64-bit\n *      - MIPS 32-bit\n *      - MIPS 64-bit\n *      - PowerPC 32-bit\n *      - PowerPC 64-bit\n *      - SPARC 32-bit\n *      - SPARC 64-bit\n *      - SuperH\n *      - Motorola 68k\n *      - Emscripten\n *      - Generic\n *\n *  Supported compilers:\n *      - Clang\n *      - GCC\n *      - MSVC\n *      - Emscripten\n *      - TinyC\n *      - VBCC\n *      - Bruce's C compiler\n *      - Generic\n *\n */\n\n#if !defined(DUK_CONFIG_H_INCLUDED)\n#define DUK_CONFIG_H_INCLUDED\n\n/*\n *  Intermediate helper defines\n */\n\n/* DLL build detection */\n#ifdef duktape_EXPORTS\n#define DUK_F_DLL_BUILD\n#else\n/* not configured for DLL build */\n#undef DUK_F_DLL_BUILD\n#endif\n\n/* Apple OSX, iOS */\n#if defined(__APPLE__)\n#define DUK_F_APPLE\n#endif\n\n/* FreeBSD */\n#if defined(__FreeBSD__) || defined(__FreeBSD)\n#define DUK_F_FREEBSD\n#endif\n\n/* Orbis (PS4) variant */\n#if defined(DUK_F_FREEBSD) && defined(__ORBIS__)\n#define DUK_F_ORBIS\n#endif\n\n/* OpenBSD */\n#if defined(__OpenBSD__) || defined(__OpenBSD)\n#define DUK_F_OPENBSD\n#endif\n\n/* NetBSD */\n#if defined(__NetBSD__) || defined(__NetBSD)\n#define DUK_F_NETBSD\n#endif\n\n/* BSD variant */\n#if defined(DUK_F_FREEBSD) || defined(DUK_F_NETBSD) || defined(DUK_F_OPENBSD) || \\\n    defined(__bsdi__) || defined(__DragonFly__)\n#define DUK_F_BSD\n#endif\n\n/* Atari ST TOS.  __TOS__ defined by PureC.  No platform define in VBCC\n * apparently, so to use with VBCC user must define __TOS__ manually.\n  */\n#if defined(__TOS__)\n#define DUK_F_TOS\n#endif\n\n/* Motorola 68K.  Not defined by VBCC, so user must define one of these\n * manually when using VBCC.\n */\n#if defined(__m68k__) || defined(M68000) || defined(__MC68K__)\n#define DUK_F_M68K\n#endif\n\n/* AmigaOS.  Neither AMIGA nor __amigaos__ is defined on VBCC, so user must\n * define 'AMIGA' manually when using VBCC.\n */\n#if defined(AMIGA) || defined(__amigaos__)\n#define DUK_F_AMIGAOS\n#endif\n\n/* PowerPC */\n#if defined(__powerpc) || defined(__powerpc__) || defined(__PPC__)\n#define DUK_F_PPC\n#if defined(__PPC64__) || defined(__LP64__) || defined(_LP64)\n#define DUK_F_PPC64\n#else\n#define DUK_F_PPC32\n#endif\n#endif\n\n/* Durango (Xbox One) */\n#if defined(_DURANGO) || defined(_XBOX_ONE)\n#define DUK_F_DURANGO\n#endif\n\n/* Windows, both 32-bit and 64-bit */\n#if defined(_WIN32) || defined(WIN32) || defined(_WIN64) || defined(WIN64) || \\\n    defined(__WIN32__) || defined(__TOS_WIN__) || defined(__WINDOWS__)\n#define DUK_F_WINDOWS\n#if defined(_WIN64) || defined(WIN64)\n#define DUK_F_WIN64\n#else\n#define DUK_F_WIN32\n#endif\n#endif\n\n/* Flash player (e.g. Crossbridge) */\n#if defined(__FLASHPLAYER__)\n#define DUK_F_FLASHPLAYER\n#endif\n\n/* QNX */\n#if defined(__QNX__)\n#define DUK_F_QNX\n#endif\n\n/* TI-Nspire (using Ndless) */\n#if defined(_TINSPIRE)\n#define DUK_F_TINSPIRE\n#endif\n\n/* Emscripten (provided explicitly by user), improve if possible */\n#if defined(EMSCRIPTEN)\n#define DUK_F_EMSCRIPTEN\n#endif\n\n/* BCC (Bruce's C compiler): this is a \"torture target\" for compilation */\n#if defined(__BCC__) || defined(__BCC_VERSION__)\n#define DUK_F_BCC\n#endif\n\n/* Linux */\n#if defined(__linux) || defined(__linux__) || defined(linux)\n#define DUK_F_LINUX\n#endif\n\n/* illumos / Solaris */\n#if defined(__sun) && defined(__SVR4)\n#define DUK_F_SUN\n#if defined(__SUNPRO_C) && (__SUNPRO_C < 0x550)\n#define DUK_F_OLD_SOLARIS\n/* Defines _ILP32 / _LP64 required by DUK_F_X86/DUK_F_X64.  Platforms\n * are processed before architectures, so this happens before the\n * DUK_F_X86/DUK_F_X64 detection is emitted.\n */\n#include <sys/isa_defs.h>\n#endif\n#endif\n\n/* AIX */\n#if defined(_AIX)\n/* defined(__xlc__) || defined(__IBMC__): works but too wide */\n#define DUK_F_AIX\n#endif\n\n/* HPUX */\n#if defined(__hpux)\n#define DUK_F_HPUX\n#if defined(__ia64)\n#define DUK_F_HPUX_ITANIUM\n#endif\n#endif\n\n/* POSIX */\n#if defined(__posix)\n#define DUK_F_POSIX\n#endif\n\n/* Cygwin */\n#if defined(__CYGWIN__)\n#define DUK_F_CYGWIN\n#endif\n\n/* Generic Unix (includes Cygwin) */\n#if defined(__unix) || defined(__unix__) || defined(unix) || \\\n    defined(DUK_F_LINUX) || defined(DUK_F_BSD)\n#define DUK_F_UNIX\n#endif\n\n/* C++ */\n#undef DUK_F_CPP\n#if defined(__cplusplus)\n#define DUK_F_CPP\n#endif\n\n/* Intel x86 (32-bit), x64 (64-bit) or x32 (64-bit but 32-bit pointers),\n * define only one of DUK_F_X86, DUK_F_X64, DUK_F_X32.\n * https://sites.google.com/site/x32abi/\n *\n * With DUK_F_OLD_SOLARIS the <sys/isa_defs.h> header must be included\n * before this.\n */\n#if defined(__amd64__) || defined(__amd64) || \\\n    defined(__x86_64__) || defined(__x86_64) || \\\n    defined(_M_X64) || defined(_M_AMD64)\n#if defined(__ILP32__) || defined(_ILP32)\n#define DUK_F_X32\n#else\n#define DUK_F_X64\n#endif\n#elif defined(i386) || defined(__i386) || defined(__i386__) || \\\n      defined(__i486__) || defined(__i586__) || defined(__i686__) || \\\n      defined(__IA32__) || defined(_M_IX86) || defined(__X86__) || \\\n      defined(_X86_) || defined(__THW_INTEL__) || defined(__I86__)\n#if defined(__LP64__) || defined(_LP64)\n/* This should not really happen, but would indicate x64. */\n#define DUK_F_X64\n#else\n#define DUK_F_X86\n#endif\n#endif\n\n/* ARM */\n#if defined(__arm__) || defined(__thumb__) || defined(_ARM) || defined(_M_ARM) || defined(__aarch64__)\n#define DUK_F_ARM\n#if defined(__LP64__) || defined(_LP64) || defined(__arm64) || defined(__arm64__) || defined(__aarch64__)\n#define DUK_F_ARM64\n#else\n#define DUK_F_ARM32\n#endif\n#endif\n\n/* MIPS.  Related defines: __MIPSEB__, __MIPSEL__, __mips_isa_rev, __LP64__ */\n#if defined(__mips__) || defined(mips) || defined(_MIPS_ISA) || \\\n    defined(_R3000) || defined(_R4000) || defined(_R5900) || \\\n    defined(_MIPS_ISA_MIPS1) || defined(_MIPS_ISA_MIPS2) || \\\n    defined(_MIPS_ISA_MIPS3) || defined(_MIPS_ISA_MIPS4) || \\\n    defined(__mips) || defined(__MIPS__)\n#define DUK_F_MIPS\n#if defined(__LP64__) || defined(_LP64) || defined(__mips64) || \\\n    defined(__mips64__) || defined(__mips_n64)\n#define DUK_F_MIPS64\n#else\n#define DUK_F_MIPS32\n#endif\n#endif\n\n/* SPARC */\n#if defined(sparc) || defined(__sparc) || defined(__sparc__)\n#define DUK_F_SPARC\n#if defined(__LP64__) || defined(_LP64)\n#define DUK_F_SPARC64\n#else\n#define DUK_F_SPARC32\n#endif\n#endif\n\n/* SuperH */\n#if defined(__sh__) || \\\n    defined(__sh1__) || defined(__SH1__) || \\\n    defined(__sh2__) || defined(__SH2__) || \\\n    defined(__sh3__) || defined(__SH3__) || \\\n    defined(__sh4__) || defined(__SH4__) || \\\n    defined(__sh5__) || defined(__SH5__)\n#define DUK_F_SUPERH\n#endif\n\n/* Clang */\n#if defined(__clang__)\n#define DUK_F_CLANG\n#endif\n\n/* C99 or above */\n#undef DUK_F_C99\n#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)\n#define DUK_F_C99\n#endif\n\n/* C++11 or above */\n#undef DUK_F_CPP11\n#if defined(__cplusplus) && (__cplusplus >= 201103L)\n#define DUK_F_CPP11\n#endif\n\n/* GCC.  Clang also defines __GNUC__ so don't detect GCC if using Clang. */\n#if defined(__GNUC__) && !defined(__clang__) && !defined(DUK_F_CLANG)\n#define DUK_F_GCC\n#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)\n/* Convenience, e.g. gcc 4.5.1 == 40501; http://stackoverflow.com/questions/6031819/emulating-gccs-builtin-unreachable */\n#define DUK_F_GCC_VERSION  (__GNUC__ * 10000L + __GNUC_MINOR__ * 100L + __GNUC_PATCHLEVEL__)\n#else\n#error cannot figure out gcc version\n#endif\n#endif\n\n/* MinGW.  Also GCC flags (DUK_F_GCC) are enabled now. */\n#if defined(__MINGW32__) || defined(__MINGW64__)\n#define DUK_F_MINGW\n#endif\n\n/* MSVC */\n#if defined(_MSC_VER)\n/* MSVC preprocessor defines: http://msdn.microsoft.com/en-us/library/b0084kay.aspx\n * _MSC_FULL_VER includes the build number, but it has at least two formats, see e.g.\n * BOOST_MSVC_FULL_VER in http://www.boost.org/doc/libs/1_52_0/boost/config/compiler/visualc.hpp\n */\n#define DUK_F_MSVC\n#if defined(_MSC_FULL_VER)\n#if (_MSC_FULL_VER > 100000000)\n#define DUK_F_MSVC_FULL_VER _MSC_FULL_VER\n#else\n#define DUK_F_MSCV_FULL_VER (_MSC_FULL_VER * 10)\n#endif\n#endif\n#endif  /* _MSC_VER */\n\n/* TinyC */\n#if defined(__TINYC__)\n/* http://bellard.org/tcc/tcc-doc.html#SEC9 */\n#define DUK_F_TINYC\n#endif\n\n/* VBCC */\n#if defined(__VBCC__)\n#define DUK_F_VBCC\n#endif\n\n#if defined(ANDROID) || defined(__ANDROID__)\n#define DUK_F_ANDROID\n#endif\n\n/* Atari Mint */\n#if defined(__MINT__)\n#define DUK_F_MINT\n#endif\n\n/*\n *  Platform autodetection\n */\n\n/* Workaround for older C++ compilers before including <inttypes.h>,\n * see e.g.: https://sourceware.org/bugzilla/show_bug.cgi?id=15366\n */\n#if defined(__cplusplus) && !defined(__STDC_LIMIT_MACROS)\n#define __STDC_LIMIT_MACROS\n#endif\n#if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS)\n#define __STDC_CONSTANT_MACROS\n#endif\n\n#if defined(DUK_F_APPLE)\n/* --- Mac OSX, iPhone, Darwin --- */\n#define DUK_USE_DATE_NOW_GETTIMEOFDAY\n#define DUK_USE_DATE_TZO_GMTIME_R\n#define DUK_USE_DATE_PRS_STRPTIME\n#define DUK_USE_DATE_FMT_STRFTIME\n#include <TargetConditionals.h>\n#include <architecture/byte_order.h>\n#include <sys/param.h>\n#include <sys/time.h>\n#include <time.h>\n\n/* http://stackoverflow.com/questions/5919996/how-to-detect-reliably-mac-os-x-ios-linux-windows-in-c-preprocessor */\n#if TARGET_IPHONE_SIMULATOR\n#define DUK_USE_OS_STRING \"iphone-sim\"\n#elif TARGET_OS_IPHONE\n#define DUK_USE_OS_STRING \"iphone\"\n#elif TARGET_OS_MAC\n#define DUK_USE_OS_STRING \"osx\"\n#else\n#define DUK_USE_OS_STRING \"osx-unknown\"\n#endif\n\n/* Use _setjmp() on Apple by default, see GH-55. */\n#define DUK_JMPBUF_TYPE       jmp_buf\n#define DUK_SETJMP(jb)        _setjmp((jb))\n#define DUK_LONGJMP(jb)       _longjmp((jb), 1)\n#elif defined(DUK_F_ORBIS)\n/* --- Orbis --- */\n/* Orbis = PS4 */\n#define DUK_USE_DATE_NOW_GETTIMEOFDAY\n#define DUK_USE_DATE_TZO_GMTIME_S\n/* no parsing (not an error) */\n#define DUK_USE_DATE_FMT_STRFTIME\n#include <sys/types.h>\n#include <machine/endian.h>\n#include <sys/param.h>\n#include <sys/time.h>\n#include <time.h>\n\n#define DUK_USE_OS_STRING  \"orbis\"\n#elif defined(DUK_F_OPENBSD)\n/* --- OpenBSD --- */\n/* http://www.monkey.org/openbsd/archive/ports/0401/msg00089.html */\n#define DUK_USE_DATE_NOW_GETTIMEOFDAY\n#define DUK_USE_DATE_TZO_GMTIME_R\n#define DUK_USE_DATE_PRS_STRPTIME\n#define DUK_USE_DATE_FMT_STRFTIME\n#include <sys/types.h>\n#include <sys/endian.h>\n#include <sys/param.h>\n#include <sys/time.h>\n#include <time.h>\n\n#define DUK_USE_OS_STRING  \"openbsd\"\n#elif defined(DUK_F_BSD)\n/* --- Generic BSD --- */\n#define DUK_USE_DATE_NOW_GETTIMEOFDAY\n#define DUK_USE_DATE_TZO_GMTIME_R\n#define DUK_USE_DATE_PRS_STRPTIME\n#define DUK_USE_DATE_FMT_STRFTIME\n#include <sys/types.h>\n#include <sys/endian.h>\n#include <sys/param.h>\n#include <sys/time.h>\n#include <time.h>\n\n#define DUK_USE_OS_STRING  \"bsd\"\n#elif defined(DUK_F_TOS)\n/* --- Atari ST TOS --- */\n#define DUK_USE_DATE_NOW_TIME\n#define DUK_USE_DATE_TZO_GMTIME\n/* no parsing (not an error) */\n#define DUK_USE_DATE_FMT_STRFTIME\n#include <time.h>\n\n#define DUK_USE_OS_STRING  \"tos\"\n\n/* TOS on M68K is always big endian. */\n#if !defined(DUK_USE_BYTEORDER) && defined(DUK_F_M68K)\n#define DUK_USE_BYTEORDER 3\n#endif\n#elif defined(DUK_F_AMIGAOS)\n/* --- AmigaOS --- */\n#if defined(DUK_F_M68K)\n/* AmigaOS on M68k */\n#define DUK_USE_DATE_NOW_TIME\n#define DUK_USE_DATE_TZO_GMTIME\n/* no parsing (not an error) */\n#define DUK_USE_DATE_FMT_STRFTIME\n#include <time.h>\n#elif defined(DUK_F_PPC)\n#define DUK_USE_DATE_NOW_GETTIMEOFDAY\n#define DUK_USE_DATE_TZO_GMTIME_R\n#define DUK_USE_DATE_PRS_STRPTIME\n#define DUK_USE_DATE_FMT_STRFTIME\n#include <time.h>\n#if !defined(UINTPTR_MAX)\n#define UINTPTR_MAX UINT_MAX\n#endif\n#else\n#error AmigaOS but not M68K/PPC, not supported now\n#endif\n\n#define DUK_USE_OS_STRING \"amigaos\"\n\n/* AmigaOS on M68K or PPC is always big endian. */\n#if !defined(DUK_USE_BYTEORDER) && (defined(DUK_F_M68K) || defined(DUK_F_PPC))\n#define DUK_USE_BYTEORDER 3\n#endif\n#elif defined(DUK_F_DURANGO)\n/* --- Durango (XboxOne) --- */\n/* Durango = XboxOne\n * Configuration is nearly identical to Windows, except for\n * DUK_USE_DATE_TZO_WINDOWS.\n */\n\n/* Initial fix: disable secure CRT related warnings when compiling Duktape\n * itself (must be defined before including Windows headers).  Don't define\n * for user code including duktape.h.\n */\n#if defined(DUK_COMPILING_DUKTAPE) && !defined(_CRT_SECURE_NO_WARNINGS)\n#define _CRT_SECURE_NO_WARNINGS\n#endif\n\n/* MSVC does not have sys/param.h */\n#define DUK_USE_DATE_NOW_WINDOWS\n#define DUK_USE_DATE_TZO_WINDOWS_NO_DST\n/* Note: PRS and FMT are intentionally left undefined for now.  This means\n * there is no platform specific date parsing/formatting but there is still\n * the ISO 8601 standard format.\n */\n#if defined(DUK_COMPILING_DUKTAPE)\n/* Only include when compiling Duktape to avoid polluting application build\n * with a lot of unnecessary defines.\n */\n#include <windows.h>\n#endif\n\n#define DUK_USE_OS_STRING \"durango\"\n\n#if !defined(DUK_USE_BYTEORDER)\n#define DUK_USE_BYTEORDER 1\n#endif\n#elif defined(DUK_F_WINDOWS)\n/* --- Windows --- */\n/* Initial fix: disable secure CRT related warnings when compiling Duktape\n * itself (must be defined before including Windows headers).  Don't define\n * for user code including duktape.h.\n */\n#if defined(DUK_COMPILING_DUKTAPE) && !defined(_CRT_SECURE_NO_WARNINGS)\n#define _CRT_SECURE_NO_WARNINGS\n#endif\n\n/* Windows 32-bit and 64-bit are currently the same. */\n/* MSVC does not have sys/param.h */\n#define DUK_USE_DATE_NOW_WINDOWS\n#define DUK_USE_DATE_TZO_WINDOWS\n/* Note: PRS and FMT are intentionally left undefined for now.  This means\n * there is no platform specific date parsing/formatting but there is still\n * the ISO 8601 standard format.\n */\n#if defined(DUK_COMPILING_DUKTAPE)\n/* Only include when compiling Duktape to avoid polluting application build\n * with a lot of unnecessary defines.\n */\n#include <windows.h>\n#endif\n\n#define DUK_USE_OS_STRING \"windows\"\n\n/* On Windows, assume we're little endian.  Even Itanium which has a\n * configurable endianness runs little endian in Windows.\n */\n#if !defined(DUK_USE_BYTEORDER)\n#define DUK_USE_BYTEORDER 1\n#endif\n#elif defined(DUK_F_FLASHPLAYER)\n/* --- Flashplayer (Crossbridge) --- */\n#define DUK_USE_DATE_NOW_GETTIMEOFDAY\n#define DUK_USE_DATE_TZO_GMTIME_R\n#define DUK_USE_DATE_PRS_STRPTIME\n#define DUK_USE_DATE_FMT_STRFTIME\n#include <endian.h>\n#include <sys/param.h>\n#include <sys/time.h>\n#include <time.h>\n\n#define DUK_USE_OS_STRING \"flashplayer\"\n\n#if !defined(DUK_USE_BYTEORDER) && defined(DUK_F_FLASHPLAYER)\n#define DUK_USE_BYTEORDER 1\n#endif\n#elif defined(DUK_F_QNX)\n/* --- QNX --- */\n#if defined(DUK_F_QNX) && defined(DUK_COMPILING_DUKTAPE)\n/* See: /opt/qnx650/target/qnx6/usr/include/sys/platform.h */\n#define _XOPEN_SOURCE    600\n#define _POSIX_C_SOURCE  200112L\n#endif\n\n#define DUK_USE_DATE_NOW_GETTIMEOFDAY\n#define DUK_USE_DATE_TZO_GMTIME_R\n#define DUK_USE_DATE_PRS_STRPTIME\n#define DUK_USE_DATE_FMT_STRFTIME\n#include <sys/types.h>\n#include <sys/param.h>\n#include <sys/time.h>\n#include <time.h>\n\n#define DUK_USE_OS_STRING \"qnx\"\n#elif defined(DUK_F_TINSPIRE)\n/* --- TI-Nspire --- */\n#if defined(DUK_COMPILING_DUKTAPE) && !defined(_XOPEN_SOURCE)\n#define _XOPEN_SOURCE    /* e.g. strptime */\n#endif\n\n#define DUK_USE_DATE_NOW_GETTIMEOFDAY\n#define DUK_USE_DATE_TZO_GMTIME_R\n#define DUK_USE_DATE_PRS_STRPTIME\n#define DUK_USE_DATE_FMT_STRFTIME\n#include <sys/types.h>\n#include <sys/param.h>\n#include <sys/time.h>\n#include <time.h>\n\n#define DUK_USE_OS_STRING \"tinspire\"\n#elif defined(DUK_F_EMSCRIPTEN)\n/* --- Emscripten --- */\n#if defined(DUK_COMPILING_DUKTAPE)\n#if !defined(_POSIX_C_SOURCE)\n#define _POSIX_C_SOURCE  200809L\n#endif\n#if !defined(_GNU_SOURCE)\n#define _GNU_SOURCE      /* e.g. getdate_r */\n#endif\n#if !defined(_XOPEN_SOURCE)\n#define _XOPEN_SOURCE    /* e.g. strptime */\n#endif\n#endif  /* DUK_COMPILING_DUKTAPE */\n\n#include <sys/types.h>\n#if defined(DUK_F_BCC)\n/* no endian.h */\n#else\n#include <endian.h>\n#endif  /* DUK_F_BCC */\n#include <sys/param.h>\n#include <sys/time.h>\n#include <time.h>\n#include <stdint.h>\n\n#define DUK_USE_DATE_NOW_GETTIMEOFDAY\n#define DUK_USE_DATE_TZO_GMTIME_R\n#define DUK_USE_DATE_PRS_STRPTIME\n#define DUK_USE_DATE_FMT_STRFTIME\n\n#define DUK_USE_OS_STRING \"emscripten\"\n#elif defined(DUK_F_LINUX)\n/* --- Linux --- */\n#if defined(DUK_COMPILING_DUKTAPE)\n#if !defined(_POSIX_C_SOURCE)\n#define _POSIX_C_SOURCE  200809L\n#endif\n#if !defined(_GNU_SOURCE)\n#define _GNU_SOURCE      /* e.g. getdate_r */\n#endif\n#if !defined(_XOPEN_SOURCE)\n#define _XOPEN_SOURCE    /* e.g. strptime */\n#endif\n#endif  /* DUK_COMPILING_DUKTAPE */\n\n#include <sys/types.h>\n#if defined(DUK_F_BCC)\n/* no endian.h or stdint.h */\n#else\n#include <endian.h>\n#include <stdint.h>\n#endif  /* DUK_F_BCC */\n#include <sys/param.h>\n#include <sys/time.h>\n#include <time.h>\n\n#define DUK_USE_DATE_NOW_GETTIMEOFDAY\n#define DUK_USE_DATE_TZO_GMTIME_R\n#define DUK_USE_DATE_PRS_STRPTIME\n#define DUK_USE_DATE_FMT_STRFTIME\n\n#define DUK_USE_OS_STRING \"linux\"\n#elif defined(DUK_F_SUN)\n/* --- Solaris --- */\n#define DUK_USE_DATE_NOW_GETTIMEOFDAY\n#define DUK_USE_DATE_TZO_GMTIME_R\n#define DUK_USE_DATE_PRS_STRPTIME\n#define DUK_USE_DATE_FMT_STRFTIME\n\n#include <sys/types.h>\n#if defined(DUK_F_OLD_SOLARIS)\n/* Old Solaris with no endian.h, stdint.h */\n#define DUK_F_NO_STDINT_H\n#if !defined(DUK_USE_BYTEORDER)\n#define DUK_USE_BYTEORDER 3\n#endif\n#else  /* DUK_F_OLD_SOLARIS */\n// no ast/endian.h, but isa_defs.h is already included, right?\n#include <sys/isa_defs.h>\n// #include <ast/endian.h>\n#endif  /* DUK_F_OLD_SOLARIS */\n\n#include <sys/param.h>\n#include <sys/time.h>\n#include <time.h>\n\n#define DUK_USE_OS_STRING \"solaris\"\n#elif defined(DUK_F_AIX)\n/* --- AIX --- */\n#if !defined(DUK_USE_BYTEORDER)\n#define DUK_USE_BYTEORDER 3\n#endif\n#define DUK_USE_DATE_NOW_GETTIMEOFDAY\n#define DUK_USE_DATE_TZO_GMTIME_R\n#define DUK_USE_DATE_PRS_STRPTIME\n#define DUK_USE_DATE_FMT_STRFTIME\n#include <sys/param.h>\n#include <sys/time.h>\n#include <time.h>\n\n#define DUK_USE_OS_STRING \"aix\"\n#elif defined(DUK_F_HPUX)\n/* --- HPUX --- */\n#define DUK_F_NO_STDINT_H\n#if !defined(DUK_USE_BYTEORDER)\n#define DUK_USE_BYTEORDER 3\n#endif\n#define DUK_USE_DATE_NOW_GETTIMEOFDAY\n#define DUK_USE_DATE_TZO_GMTIME_R\n#define DUK_USE_DATE_PRS_STRPTIME\n#define DUK_USE_DATE_FMT_STRFTIME\n#include <sys/param.h>\n#include <sys/time.h>\n#include <time.h>\n\n#define DUK_USE_OS_STRING \"hpux\"\n#elif defined(DUK_F_POSIX)\n/* --- Generic POSIX --- */\n#define DUK_USE_DATE_NOW_GETTIMEOFDAY\n#define DUK_USE_DATE_TZO_GMTIME_R\n#define DUK_USE_DATE_PRS_STRPTIME\n#define DUK_USE_DATE_FMT_STRFTIME\n#include <sys/types.h>\n#include <endian.h>\n#include <sys/param.h>\n#include <sys/time.h>\n#include <time.h>\n\n#define DUK_USE_OS_STRING \"posix\"\n#elif defined(DUK_F_CYGWIN)\n/* --- Cygwin --- */\n/* don't use strptime() for now */\n#define DUK_USE_DATE_NOW_GETTIMEOFDAY\n#define DUK_USE_DATE_TZO_GMTIME_R\n#define DUK_USE_DATE_FMT_STRFTIME\n#include <sys/types.h>\n#include <endian.h>\n#include <sys/param.h>\n#include <sys/time.h>\n#include <time.h>\n\n#define DUK_JMPBUF_TYPE       jmp_buf\n#define DUK_SETJMP(jb)        _setjmp((jb))\n#define DUK_LONGJMP(jb)       _longjmp((jb), 1)\n\n#define DUK_USE_OS_STRING \"windows\"\n#elif defined(DUK_F_UNIX)\n/* --- Generic UNIX --- */\n#define DUK_USE_DATE_NOW_GETTIMEOFDAY\n#define DUK_USE_DATE_TZO_GMTIME_R\n#define DUK_USE_DATE_PRS_STRPTIME\n#define DUK_USE_DATE_FMT_STRFTIME\n#include <time.h>\n#include <sys/time.h>\n#define DUK_USE_OS_STRING \"unknown\"\n#else\n/* --- Generic fallback --- */\n/* The most portable current time provider is time(), but it only has a\n * one second resolution.\n */\n#define DUK_USE_DATE_NOW_TIME\n\n/* The most portable way to figure out local time offset is gmtime(),\n * but it's not thread safe so use with caution.\n */\n#define DUK_USE_DATE_TZO_GMTIME\n\n/* Avoid custom date parsing and formatting for portability. */\n#undef DUK_USE_DATE_PRS_STRPTIME\n#undef DUK_USE_DATE_FMT_STRFTIME\n\n/* Rely on C89 headers only; time.h must be here. */\n#include <time.h>\n\n#define DUK_USE_OS_STRING \"unknown\"\n#endif  /* autodetect platform */\n\n/* Shared includes: C89 */\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <stdarg.h>  /* varargs */\n#include <setjmp.h>\n#include <stddef.h>  /* e.g. ptrdiff_t */\n#include <math.h>\n#include <limits.h>\n\n/* date.h is omitted, and included per platform */\n\n/* Shared includes: stdint.h is C99 */\n#if defined(DUK_F_NO_STDINT_H)\n/* stdint.h not available */\n#else\n/* Technically C99 (C++11) but found in many systems.  On some systems\n * __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS must be defined before\n * including stdint.h (see above).\n */\n#include <stdint.h>\n#endif\n\n#if defined(DUK_F_CPP)\n#include <exception>  /* std::exception */\n#endif\n\n/*\n *  Architecture autodetection\n */\n\n#if defined(DUK_F_X86)\n/* --- x86 --- */\n#define DUK_USE_ARCH_STRING \"x86\"\n#if !defined(DUK_USE_BYTEORDER)\n#define DUK_USE_BYTEORDER 1\n#endif\n/* XXX: This is technically not guaranteed because it's possible to configure\n * an x86 to require aligned accesses with Alignment Check (AC) flag.\n */\n#if !defined(DUK_USE_ALIGN_BY)\n#define DUK_USE_ALIGN_BY 1\n#endif\n#define DUK_USE_PACKED_TVAL\n#define DUK_F_PACKED_TVAL_PROVIDED\n#elif defined(DUK_F_X64)\n/* --- x64 --- */\n#define DUK_USE_ARCH_STRING \"x64\"\n#if !defined(DUK_USE_BYTEORDER)\n#define DUK_USE_BYTEORDER 1\n#endif\n/* XXX: This is technically not guaranteed because it's possible to configure\n * an x86 to require aligned accesses with Alignment Check (AC) flag.\n */\n#if !defined(DUK_USE_ALIGN_BY)\n#define DUK_USE_ALIGN_BY 1\n#endif\n#undef DUK_USE_PACKED_TVAL\n#define DUK_F_PACKED_TVAL_PROVIDED\n#elif defined(DUK_F_X32)\n/* --- x32 --- */\n#define DUK_USE_ARCH_STRING \"x32\"\n#if !defined(DUK_USE_BYTEORDER)\n#define DUK_USE_BYTEORDER 1\n#endif\n/* XXX: This is technically not guaranteed because it's possible to configure\n * an x86 to require aligned accesses with Alignment Check (AC) flag.\n */\n#if !defined(DUK_USE_ALIGN_BY)\n#define DUK_USE_ALIGN_BY 1\n#endif\n#define DUK_USE_PACKED_TVAL\n#define DUK_F_PACKED_TVAL_PROVIDED\n#elif defined(DUK_F_ARM32)\n/* --- ARM 32-bit --- */\n#define DUK_USE_ARCH_STRING \"arm32\"\n/* Byte order varies, so rely on autodetect. */\n#if !defined(DUK_USE_ALIGN_BY)\n#define DUK_USE_ALIGN_BY 4\n#endif\n#define DUK_USE_PACKED_TVAL\n#define DUK_F_PACKED_TVAL_PROVIDED\n#elif defined(DUK_F_ARM64)\n/* --- ARM 64-bit --- */\n#define DUK_USE_ARCH_STRING \"arm64\"\n/* Byte order varies, so rely on autodetect. */\n#if !defined(DUK_USE_ALIGN_BY)\n#define DUK_USE_ALIGN_BY 8\n#endif\n#undef DUK_USE_PACKED_TVAL\n#define DUK_F_PACKED_TVAL_PROVIDED\n#elif defined(DUK_F_MIPS32)\n/* --- MIPS 32-bit --- */\n#define DUK_USE_ARCH_STRING \"mips32\"\n/* MIPS byte order varies so rely on autodetection. */\n#if !defined(DUK_USE_ALIGN_BY)\n#define DUK_USE_ALIGN_BY 8\n#endif\n#define DUK_USE_PACKED_TVAL\n#define DUK_F_PACKED_TVAL_PROVIDED\n#elif defined(DUK_F_MIPS64)\n/* --- MIPS 64-bit --- */\n#define DUK_USE_ARCH_STRING \"mips64\"\n/* MIPS byte order varies so rely on autodetection. */\n#if !defined(DUK_USE_ALIGN_BY)\n#define DUK_USE_ALIGN_BY 8\n#endif\n#undef DUK_USE_PACKED_TVAL\n#define DUK_F_PACKED_TVAL_PROVIDED\n#elif defined(DUK_F_PPC32)\n/* --- PowerPC 32-bit --- */\n#define DUK_USE_ARCH_STRING \"ppc32\"\n#if !defined(DUK_USE_BYTEORDER)\n#define DUK_USE_BYTEORDER 3\n#endif\n#if !defined(DUK_USE_ALIGN_BY)\n#define DUK_USE_ALIGN_BY 8\n#endif\n#define DUK_USE_PACKED_TVAL\n#define DUK_F_PACKED_TVAL_PROVIDED\n#elif defined(DUK_F_PPC64)\n/* --- PowerPC 64-bit --- */\n#define DUK_USE_ARCH_STRING \"ppc64\"\n#if !defined(DUK_USE_BYTEORDER)\n#define DUK_USE_BYTEORDER 3\n#endif\n#if !defined(DUK_USE_ALIGN_BY)\n#define DUK_USE_ALIGN_BY 8\n#endif\n#undef DUK_USE_PACKED_TVAL\n#define DUK_F_PACKED_TVAL_PROVIDED\n#elif defined(DUK_F_SPARC32)\n/* --- SPARC 32-bit --- */\n#define DUK_USE_ARCH_STRING \"sparc32\"\n/* SPARC byte order varies so rely on autodetection. */\n#if !defined(DUK_USE_ALIGN_BY)\n#define DUK_USE_ALIGN_BY 8\n#endif\n#define DUK_USE_PACKED_TVAL\n#define DUK_F_PACKED_TVAL_PROVIDED\n#elif defined(DUK_F_SPARC64)\n/* --- SPARC 64-bit --- */\n#define DUK_USE_ARCH_STRING \"sparc64\"\n/* SPARC byte order varies so rely on autodetection. */\n#if !defined(DUK_USE_ALIGN_BY)\n#define DUK_USE_ALIGN_BY 8\n#endif\n#undef DUK_USE_PACKED_TVAL\n#define DUK_F_PACKED_TVAL_PROVIDED\n#elif defined(DUK_F_SUPERH)\n/* --- SuperH --- */\n#define DUK_USE_ARCH_STRING \"sh\"\n/* Byte order varies, rely on autodetection. */\n/* Based on 'make checkalign' there are no alignment requirements on\n * Linux SH4, but align by 4 is probably a good basic default.\n */\n#if !defined(DUK_USE_ALIGN_BY)\n#define DUK_USE_ALIGN_BY 4\n#endif\n#define DUK_USE_PACKED_TVAL\n#define DUK_F_PACKED_TVAL_PROVIDED\n#elif defined(DUK_F_M68K)\n/* --- Motorola 68k --- */\n#define DUK_USE_ARCH_STRING \"m68k\"\n#if !defined(DUK_USE_BYTEORDER)\n#define DUK_USE_BYTEORDER 3\n#endif\n#if !defined(DUK_USE_ALIGN_BY)\n#define DUK_USE_ALIGN_BY 8\n#endif\n#define DUK_USE_PACKED_TVAL\n#define DUK_F_PACKED_TVAL_PROVIDED\n#elif defined(DUK_F_EMSCRIPTEN)\n/* --- Emscripten --- */\n#define DUK_USE_ARCH_STRING \"emscripten\"\n#if !defined(DUK_USE_BYTEORDER)\n#define DUK_USE_BYTEORDER 1\n#endif\n#if !defined(DUK_USE_ALIGN_BY)\n#define DUK_USE_ALIGN_BY 8\n#endif\n#undef DUK_USE_PACKED_TVAL\n#define DUK_F_PACKED_TVAL_PROVIDED\n#else\n/* --- Generic --- */\n/* These are necessary wild guesses. */\n#define DUK_USE_ARCH_STRING \"generic\"\n/* Rely on autodetection for byte order, alignment, and packed tval. */\n#endif  /* autodetect architecture */\n\n/*\n *  Compiler autodetection\n */\n\n#if defined(DUK_F_CLANG)\n/* --- Clang --- */\n#if defined(DUK_F_C99) || defined(DUK_F_CPP11)\n/* C99 / C++11 and above: rely on va_copy() which is required. */\n#define DUK_VA_COPY(dest,src) va_copy(dest,src)\n#else\n/* Clang: assume we have __va_copy() in non-C99 mode. */\n#define DUK_VA_COPY(dest,src) __va_copy(dest,src)\n#endif\n\n#define DUK_NORETURN(decl)  decl __attribute__((noreturn))\n\n#if defined(__clang__) && defined(__has_builtin)\n#if __has_builtin(__builtin_unreachable)\n#define DUK_UNREACHABLE()  do { __builtin_unreachable(); } while (0)\n#endif\n#endif\n\n#define DUK_USE_BRANCH_HINTS\n#define DUK_LIKELY(x)    __builtin_expect((x), 1)\n#define DUK_UNLIKELY(x)  __builtin_expect((x), 0)\n#if defined(__clang__) && defined(__has_builtin)\n#if __has_builtin(__builtin_unpredictable)\n#define DUK_UNPREDICTABLE(x)  __builtin_unpredictable((x))\n#endif\n#endif\n\n#if defined(DUK_F_C99) || defined(DUK_F_CPP11)\n#define DUK_NOINLINE        __attribute__((noinline))\n#define DUK_INLINE          inline\n#define DUK_ALWAYS_INLINE   inline __attribute__((always_inline))\n#endif\n\n/* DUK_HOT */\n/* DUK_COLD */\n\n#if defined(DUK_F_DLL_BUILD) && defined(DUK_F_WINDOWS)\n/* MSVC dllexport/dllimport: appropriate __declspec depends on whether we're\n * compiling Duktape or the application.\n */\n#if defined(DUK_COMPILING_DUKTAPE)\n#define DUK_EXTERNAL_DECL  extern __declspec(dllexport)\n#define DUK_EXTERNAL       __declspec(dllexport)\n#else\n#define DUK_EXTERNAL_DECL  extern __declspec(dllimport)\n#define DUK_EXTERNAL       should_not_happen\n#endif\n#if defined(DUK_SINGLE_FILE)\n#define DUK_INTERNAL_DECL  static\n#define DUK_INTERNAL       static\n#else\n#define DUK_INTERNAL_DECL  extern\n#define DUK_INTERNAL       /*empty*/\n#endif\n#define DUK_LOCAL_DECL     static\n#define DUK_LOCAL          static\n#else\n#define DUK_EXTERNAL_DECL  __attribute__ ((visibility(\"default\"))) extern\n#define DUK_EXTERNAL       __attribute__ ((visibility(\"default\")))\n#if defined(DUK_SINGLE_FILE)\n#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)\n/* Minimize warnings for unused internal functions with GCC >= 3.1.1 and\n * Clang.  Based on documentation it should suffice to have the attribute\n * in the declaration only, but in practice some warnings are generated unless\n * the attribute is also applied to the definition.\n */\n#define DUK_INTERNAL_DECL  static __attribute__ ((unused))\n#define DUK_INTERNAL       static __attribute__ ((unused))\n#else\n#define DUK_INTERNAL_DECL  static\n#define DUK_INTERNAL       static\n#endif\n#else\n#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)\n#define DUK_INTERNAL_DECL  __attribute__ ((visibility(\"hidden\"))) __attribute__ ((unused)) extern\n#define DUK_INTERNAL       __attribute__ ((visibility(\"hidden\"))) __attribute__ ((unused))\n#else\n#define DUK_INTERNAL_DECL  __attribute__ ((visibility(\"hidden\"))) extern\n#define DUK_INTERNAL       __attribute__ ((visibility(\"hidden\")))\n#endif\n#endif\n#define DUK_LOCAL_DECL     static\n#define DUK_LOCAL          static\n#endif\n\n#if defined(DUK_F_CPP)\n#define DUK_USE_COMPILER_STRING \"clang\"\n#else\n#define DUK_USE_COMPILER_STRING \"clang\"\n#endif\n\n#undef DUK_USE_VARIADIC_MACROS\n#if defined(DUK_F_C99) || defined(DUK_F_CPP11)\n#define DUK_USE_VARIADIC_MACROS\n#endif\n\n#define DUK_USE_UNION_INITIALIZERS\n\n#undef DUK_USE_FLEX_C99\n#undef DUK_USE_FLEX_ZEROSIZE\n#undef DUK_USE_FLEX_ONESIZE\n#if defined(DUK_F_C99)\n#define DUK_USE_FLEX_C99\n#else\n#define DUK_USE_FLEX_ZEROSIZE\n#endif\n\n#undef DUK_USE_GCC_PRAGMAS\n#define DUK_USE_PACK_CLANG_ATTR\n#elif defined(DUK_F_GCC)\n/* --- GCC --- */\n#if defined(DUK_F_C99) || defined(DUK_F_CPP11)\n/* C99 / C++11 and above: rely on va_copy() which is required. */\n#define DUK_VA_COPY(dest,src) va_copy(dest,src)\n#else\n/* GCC: assume we have __va_copy() in non-C99 mode. */\n#define DUK_VA_COPY(dest,src) __va_copy(dest,src)\n#endif\n\n#if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 20500L)\n/* since gcc-2.5 */\n#define DUK_NORETURN(decl)  decl __attribute__((noreturn))\n#endif\n\n#if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40500L)\n/* since gcc-4.5 */\n#define DUK_UNREACHABLE()  do { __builtin_unreachable(); } while (0)\n#endif\n\n#define DUK_USE_BRANCH_HINTS\n#if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40500L)\n/* GCC: test not very accurate; enable only in relatively recent builds\n * because of bugs in gcc-4.4 (http://lists.debian.org/debian-gcc/2010/04/msg00000.html)\n */\n#define DUK_LIKELY(x)    __builtin_expect((x), 1)\n#define DUK_UNLIKELY(x)  __builtin_expect((x), 0)\n#endif\n/* XXX: equivalent of clang __builtin_unpredictable? */\n\n#if (defined(DUK_F_C99) || defined(DUK_F_CPP11)) && \\\n    defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 30101)\n#define DUK_NOINLINE        __attribute__((noinline))\n#define DUK_INLINE          inline\n#define DUK_ALWAYS_INLINE   inline __attribute__((always_inline))\n#endif\n\n#if (defined(DUK_F_C99) || defined(DUK_F_CPP11)) && \\\n    defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40300)\n#define DUK_HOT             __attribute__((hot))\n#define DUK_COLD            __attribute__((cold))\n#endif\n\n#if defined(DUK_F_DLL_BUILD) && defined(DUK_F_WINDOWS)\n/* MSVC dllexport/dllimport: appropriate __declspec depends on whether we're\n * compiling Duktape or the application.\n */\n#if defined(DUK_COMPILING_DUKTAPE)\n#define DUK_EXTERNAL_DECL  extern __declspec(dllexport)\n#define DUK_EXTERNAL       __declspec(dllexport)\n#else\n#define DUK_EXTERNAL_DECL  extern __declspec(dllimport)\n#define DUK_EXTERNAL       should_not_happen\n#endif\n#if defined(DUK_SINGLE_FILE)\n#define DUK_INTERNAL_DECL  static\n#define DUK_INTERNAL       static\n#else\n#define DUK_INTERNAL_DECL  extern\n#define DUK_INTERNAL       /*empty*/\n#endif\n#define DUK_LOCAL_DECL     static\n#define DUK_LOCAL          static\n#elif defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40000)\n#define DUK_EXTERNAL_DECL  __attribute__ ((visibility(\"default\"))) extern\n#define DUK_EXTERNAL       __attribute__ ((visibility(\"default\")))\n#if defined(DUK_SINGLE_FILE)\n#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)\n/* Minimize warnings for unused internal functions with GCC >= 3.1.1 and\n * Clang.  Based on documentation it should suffice to have the attribute\n * in the declaration only, but in practice some warnings are generated unless\n * the attribute is also applied to the definition.\n */\n#define DUK_INTERNAL_DECL  static __attribute__ ((unused))\n#define DUK_INTERNAL       static __attribute__ ((unused))\n#else\n#define DUK_INTERNAL_DECL  static\n#define DUK_INTERNAL       static\n#endif\n#else\n#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)\n#define DUK_INTERNAL_DECL  __attribute__ ((visibility(\"hidden\"))) __attribute__ ((unused)) extern\n#define DUK_INTERNAL       __attribute__ ((visibility(\"hidden\"))) __attribute__ ((unused))\n#else\n#define DUK_INTERNAL_DECL  __attribute__ ((visibility(\"hidden\"))) extern\n#define DUK_INTERNAL       __attribute__ ((visibility(\"hidden\")))\n#endif\n#endif\n#define DUK_LOCAL_DECL     static\n#define DUK_LOCAL          static\n#endif\n\n#if defined(DUK_F_MINGW)\n#if defined(DUK_F_CPP)\n#define DUK_USE_COMPILER_STRING \"mingw++\"\n#else\n#define DUK_USE_COMPILER_STRING \"mingw\"\n#endif\n#else\n#if defined(DUK_F_CPP)\n#define DUK_USE_COMPILER_STRING \"g++\"\n#else\n#define DUK_USE_COMPILER_STRING \"gcc\"\n#endif\n#endif\n\n#undef DUK_USE_VARIADIC_MACROS\n#if defined(DUK_F_C99) || (defined(DUK_F_CPP11) && defined(__GNUC__))\n#define DUK_USE_VARIADIC_MACROS\n#endif\n\n#define DUK_USE_UNION_INITIALIZERS\n\n#undef DUK_USE_FLEX_C99\n#undef DUK_USE_FLEX_ZEROSIZE\n#undef DUK_USE_FLEX_ONESIZE\n#if defined(DUK_F_C99)\n#define DUK_USE_FLEX_C99\n#else\n#define DUK_USE_FLEX_ZEROSIZE\n#endif\n\n#if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION >= 40600)\n#define DUK_USE_GCC_PRAGMAS\n#else\n#undef DUK_USE_GCC_PRAGMAS\n#endif\n\n#define DUK_USE_PACK_GCC_ATTR\n#elif defined(DUK_F_MSVC)\n/* --- MSVC --- */\n/* http://msdn.microsoft.com/en-us/library/aa235362(VS.60).aspx */\n#define DUK_NORETURN(decl)  __declspec(noreturn) decl\n\n/* XXX: DUK_UNREACHABLE for msvc? */\n\n#undef DUK_USE_BRANCH_HINTS\n\n/* XXX: DUK_LIKELY, DUK_UNLIKELY for msvc? */\n/* XXX: DUK_NOINLINE, DUK_INLINE, DUK_ALWAYS_INLINE for msvc? */\n\n#if defined(DUK_F_DLL_BUILD) && defined(DUK_F_WINDOWS)\n/* MSVC dllexport/dllimport: appropriate __declspec depends on whether we're\n * compiling Duktape or the application.\n */\n#if defined(DUK_COMPILING_DUKTAPE)\n#define DUK_EXTERNAL_DECL  extern __declspec(dllexport)\n#define DUK_EXTERNAL       __declspec(dllexport)\n#else\n#define DUK_EXTERNAL_DECL  extern __declspec(dllimport)\n#define DUK_EXTERNAL       should_not_happen\n#endif\n#if defined(DUK_SINGLE_FILE)\n#define DUK_INTERNAL_DECL  static\n#define DUK_INTERNAL       static\n#else\n#define DUK_INTERNAL_DECL  extern\n#define DUK_INTERNAL       /*empty*/\n#endif\n#define DUK_LOCAL_DECL     static\n#define DUK_LOCAL          static\n#endif\n\n#if defined(DUK_F_CPP)\n#define DUK_USE_COMPILER_STRING \"msvc++\"\n#else\n#define DUK_USE_COMPILER_STRING \"msvc\"\n#endif\n\n#undef DUK_USE_VARIADIC_MACROS\n#if defined(DUK_F_C99)\n#define DUK_USE_VARIADIC_MACROS\n#elif defined(_MSC_VER) && (_MSC_VER >= 1400)\n/* VS2005+ should have variadic macros even when they're not C99. */\n#define DUK_USE_VARIADIC_MACROS\n#endif\n\n#undef DUK_USE_UNION_INITIALIZERS\n#if defined(_MSC_VER) && (_MSC_VER >= 1800)\n/* VS2013+ supports union initializers but there's a bug involving union-inside-struct:\n * https://connect.microsoft.com/VisualStudio/feedback/details/805981\n * The bug was fixed (at least) in VS2015 so check for VS2015 for now:\n * https://blogs.msdn.microsoft.com/vcblog/2015/07/01/c-compiler-front-end-fixes-in-vs2015/\n * Manually tested using VS2013, CL reports 18.00.31101, so enable for VS2013 too.\n */\n#define DUK_USE_UNION_INITIALIZERS\n#endif\n\n#undef DUK_USE_FLEX_C99\n#undef DUK_USE_FLEX_ZEROSIZE\n#undef DUK_USE_FLEX_ONESIZE\n#if defined(DUK_F_C99)\n#define DUK_USE_FLEX_C99\n#else\n#define DUK_USE_FLEX_ZEROSIZE\n#endif\n\n#undef DUK_USE_GCC_PRAGMAS\n\n#define DUK_USE_PACK_MSVC_PRAGMA\n\n/* These have been tested from VS2008 onwards; may work in older VS versions\n * too but not enabled by default.\n */\n#if defined(_MSC_VER) && (_MSC_VER >= 1500)\n#define DUK_NOINLINE        __declspec(noinline)\n#define DUK_INLINE          __inline\n#define DUK_ALWAYS_INLINE   __forceinline\n#endif\n\n#if defined(_MSC_VER) && (_MSC_VER >= 1900)\n#define DUK_SNPRINTF     snprintf\n#define DUK_VSNPRINTF    vsnprintf\n#else\n/* (v)snprintf() is missing before MSVC 2015.  Note that _(v)snprintf() does\n * NOT NUL terminate on truncation, but Duktape code never assumes that.\n * http://stackoverflow.com/questions/2915672/snprintf-and-visual-studio-2010\n */\n#define DUK_SNPRINTF     _snprintf\n#define DUK_VSNPRINTF    _vsnprintf\n#endif\n\n/* Avoid warning when doing DUK_UNREF(some_function). */\n#define DUK_UNREF(x)  do { __pragma(warning(suppress:4100 4101 4550 4551)) (x); } while (0)\n#elif defined(DUK_F_EMSCRIPTEN)\n/* --- Emscripten --- */\n#define DUK_NORETURN(decl)  decl __attribute__((noreturn))\n\n#if defined(__clang__) && defined(__has_builtin)\n#if __has_builtin(__builtin_unreachable)\n#define DUK_UNREACHABLE()  do { __builtin_unreachable(); } while (0)\n#endif\n#endif\n\n#define DUK_USE_BRANCH_HINTS\n#define DUK_LIKELY(x)    __builtin_expect((x), 1)\n#define DUK_UNLIKELY(x)  __builtin_expect((x), 0)\n#if defined(__clang__) && defined(__has_builtin)\n#if __has_builtin(__builtin_unpredictable)\n#define DUK_UNPREDICTABLE(x)  __builtin_unpredictable((x))\n#endif\n#endif\n\n#if defined(DUK_F_C99) || defined(DUK_F_CPP11)\n#define DUK_NOINLINE        __attribute__((noinline))\n#define DUK_INLINE          inline\n#define DUK_ALWAYS_INLINE   inline __attribute__((always_inline))\n#endif\n\n#define DUK_EXTERNAL_DECL  __attribute__ ((visibility(\"default\"))) extern\n#define DUK_EXTERNAL       __attribute__ ((visibility(\"default\")))\n#if defined(DUK_SINGLE_FILE)\n#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)\n/* Minimize warnings for unused internal functions with GCC >= 3.1.1 and\n * Clang.  Based on documentation it should suffice to have the attribute\n * in the declaration only, but in practice some warnings are generated unless\n * the attribute is also applied to the definition.\n */\n#define DUK_INTERNAL_DECL  static __attribute__ ((unused))\n#define DUK_INTERNAL       static __attribute__ ((unused))\n#else\n#define DUK_INTERNAL_DECL  static\n#define DUK_INTERNAL       static\n#endif\n#else\n#if (defined(DUK_F_GCC_VERSION) && DUK_F_GCC_VERSION >= 30101) || defined(DUK_F_CLANG)\n#define DUK_INTERNAL_DECL  __attribute__ ((visibility(\"hidden\"))) __attribute__ ((unused)) extern\n#define DUK_INTERNAL       __attribute__ ((visibility(\"hidden\"))) __attribute__ ((unused))\n#else\n#define DUK_INTERNAL_DECL  __attribute__ ((visibility(\"hidden\"))) extern\n#define DUK_INTERNAL       __attribute__ ((visibility(\"hidden\")))\n#endif\n#endif\n#define DUK_LOCAL_DECL     static\n#define DUK_LOCAL          static\n\n#define DUK_USE_COMPILER_STRING \"emscripten\"\n\n#undef DUK_USE_VARIADIC_MACROS\n#if defined(DUK_F_C99) || defined(DUK_F_CPP11)\n#define DUK_USE_VARIADIC_MACROS\n#endif\n\n#define DUK_USE_UNION_INITIALIZERS\n\n#undef DUK_USE_FLEX_C99\n#undef DUK_USE_FLEX_ZEROSIZE\n#undef DUK_USE_FLEX_ONESIZE\n#if defined(DUK_F_C99)\n#define DUK_USE_FLEX_C99\n#else\n#define DUK_USE_FLEX_ZEROSIZE\n#endif\n\n#undef DUK_USE_GCC_PRAGMAS\n#define DUK_USE_PACK_CLANG_ATTR\n#elif defined(DUK_F_TINYC)\n/* --- TinyC --- */\n#undef DUK_USE_BRANCH_HINTS\n\n#if defined(DUK_F_CPP)\n#define DUK_USE_COMPILER_STRING \"tinyc++\"\n#else\n#define DUK_USE_COMPILER_STRING \"tinyc\"\n#endif\n\n/* http://bellard.org/tcc/tcc-doc.html#SEC7 */\n#define DUK_USE_VARIADIC_MACROS\n\n#define DUK_USE_UNION_INITIALIZERS\n\n/* Most portable, wastes space */\n#define DUK_USE_FLEX_ONESIZE\n\n/* Most portable, potentially wastes space */\n#define DUK_USE_PACK_DUMMY_MEMBER\n#elif defined(DUK_F_VBCC)\n/* --- VBCC --- */\n#undef DUK_USE_BRANCH_HINTS\n\n#if defined(DUK_F_CPP)\n#define DUK_USE_COMPILER_STRING \"vbcc-c++\"\n#else\n#define DUK_USE_COMPILER_STRING \"vbcc\"\n#endif\n\n#undef DUK_USE_VARIADIC_MACROS\n#if defined(DUK_F_C99) || defined(DUK_F_CPP11)\n#define DUK_USE_VARIADIC_MACROS\n#endif\n\n/* VBCC supports C99 so check only for C99 for union initializer support.\n * Designated union initializers would possibly work even without a C99 check.\n */\n#undef DUK_USE_UNION_INITIALIZERS\n#if defined(DUK_F_C99)\n#define DUK_USE_UNION_INITIALIZERS\n#endif\n\n#define DUK_USE_FLEX_ZEROSIZE\n#define DUK_USE_PACK_DUMMY_MEMBER\n#elif defined(DUK_F_BCC)\n/* --- Bruce's C compiler --- */\n#undef DUK_USE_BRANCH_HINTS\n\n#if defined(DUK_F_CPP)\n#define DUK_USE_COMPILER_STRING \"bcc++\"\n#else\n#define DUK_USE_COMPILER_STRING \"bcc\"\n#endif\n\n/* Most portable */\n#undef DUK_USE_VARIADIC_MACROS\n\n/* Most portable, wastes space */\n#undef DUK_USE_UNION_INITIALIZERS\n\n/* Most portable, wastes space */\n#define DUK_USE_FLEX_ONESIZE\n\n/* Most portable, potentially wastes space */\n#define DUK_USE_PACK_DUMMY_MEMBER\n\n/* BCC, assume we're on x86. */\n#if !defined(DUK_USE_BYTEORDER)\n#define DUK_USE_BYTEORDER 1\n#endif\n#else\n/* --- Generic --- */\n#undef DUK_USE_BRANCH_HINTS\n\n#if defined(DUK_F_CPP)\n#define DUK_USE_COMPILER_STRING \"generic-c++\"\n#else\n#define DUK_USE_COMPILER_STRING \"generic\"\n#endif\n\n#undef DUK_USE_VARIADIC_MACROS\n#if defined(DUK_F_C99) || defined(DUK_F_CPP11)\n#define DUK_USE_VARIADIC_MACROS\n#endif\n\n/* C++ doesn't have standard designated union initializers ({ .foo = 1 }). */\n#undef DUK_USE_UNION_INITIALIZERS\n#if defined(DUK_F_C99)\n#define DUK_USE_UNION_INITIALIZERS\n#endif\n\n/* Most portable, wastes space */\n#define DUK_USE_FLEX_ONESIZE\n\n/* Most portable, potentially wastes space */\n#define DUK_USE_PACK_DUMMY_MEMBER\n#endif  /* autodetect compiler */\n\n/* uclibc */\n#if defined(__UCLIBC__)\n#define DUK_F_UCLIBC\n#endif\n\n/*\n *  Wrapper typedefs and constants for integer types, also sanity check types.\n *\n *  C99 typedefs are quite good but not always available, and we want to avoid\n *  forcibly redefining the C99 typedefs.  So, there are Duktape wrappers for\n *  all C99 typedefs and Duktape code should only use these typedefs.  Type\n *  detection when C99 is not supported is best effort and may end up detecting\n *  some types incorrectly.\n *\n *  Pointer sizes are a portability problem: pointers to different types may\n *  have a different size and function pointers are very difficult to manage\n *  portably.\n *\n *  http://en.wikipedia.org/wiki/C_data_types#Fixed-width_integer_types\n *\n *  Note: there's an interesting corner case when trying to define minimum\n *  signed integer value constants which leads to the current workaround of\n *  defining e.g. -0x80000000 as (-0x7fffffffL - 1L).  See doc/code-issues.txt\n *  for a longer discussion.\n *\n *  Note: avoid typecasts and computations in macro integer constants as they\n *  can then no longer be used in macro relational expressions (such as\n *  #if DUK_SIZE_MAX < 0xffffffffUL).  There is internal code which relies on\n *  being able to compare DUK_SIZE_MAX against a limit.\n */\n\n/* XXX: add feature options to force basic types from outside? */\n\n#if !defined(INT_MAX)\n#error INT_MAX not defined\n#endif\n\n/* Check that architecture is two's complement, standard C allows e.g.\n * INT_MIN to be -2**31+1 (instead of -2**31).\n */\n#if defined(INT_MAX) && defined(INT_MIN)\n#if INT_MAX != -(INT_MIN + 1)\n#error platform does not seem complement of two\n#endif\n#else\n#error cannot check complement of two\n#endif\n\n/* Pointer size determination based on __WORDSIZE or architecture when\n * that's not available.\n */\n#if defined(DUK_F_X86) || defined(DUK_F_X32) || \\\n    defined(DUK_F_M68K) || defined(DUK_F_PPC32) || \\\n    defined(DUK_F_BCC) || \\\n    (defined(__WORDSIZE) && (__WORDSIZE == 32)) || \\\n    ((defined(DUK_F_OLD_SOLARIS) || defined(DUK_F_AIX) || \\\n      defined(DUK_F_HPUX)) && defined(_ILP32))\n#define DUK_F_32BIT_PTRS\n#elif defined(DUK_F_X64) || \\\n      (defined(__WORDSIZE) && (__WORDSIZE == 64)) || \\\n   ((defined(DUK_F_OLD_SOLARIS) || defined(DUK_F_AIX) || \\\n     defined(DUK_F_HPUX)) && defined(_LP64))\n#define DUK_F_64BIT_PTRS\n#else\n/* not sure, not needed with C99 anyway */\n#endif\n\n/* Intermediate define for 'have inttypes.h' */\n#undef DUK_F_HAVE_INTTYPES\n#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \\\n    !(defined(DUK_F_AMIGAOS) && defined(DUK_F_VBCC))\n/* vbcc + AmigaOS has C99 but no inttypes.h */\n#define DUK_F_HAVE_INTTYPES\n#elif defined(__cplusplus) && (__cplusplus >= 201103L)\n/* C++11 apparently ratified stdint.h */\n#define DUK_F_HAVE_INTTYPES\n#endif\n\n/* Basic integer typedefs and limits, preferably from inttypes.h, otherwise\n * through automatic detection.\n */\n#if defined(DUK_F_HAVE_INTTYPES)\n/* C99 or compatible */\n\n#define DUK_F_HAVE_64BIT\n#include <inttypes.h>\n\ntypedef uint8_t duk_uint8_t;\ntypedef int8_t duk_int8_t;\ntypedef uint16_t duk_uint16_t;\ntypedef int16_t duk_int16_t;\ntypedef uint32_t duk_uint32_t;\ntypedef int32_t duk_int32_t;\ntypedef uint64_t duk_uint64_t;\ntypedef int64_t duk_int64_t;\ntypedef uint_least8_t duk_uint_least8_t;\ntypedef int_least8_t duk_int_least8_t;\ntypedef uint_least16_t duk_uint_least16_t;\ntypedef int_least16_t duk_int_least16_t;\ntypedef uint_least32_t duk_uint_least32_t;\ntypedef int_least32_t duk_int_least32_t;\ntypedef uint_least64_t duk_uint_least64_t;\ntypedef int_least64_t duk_int_least64_t;\ntypedef uint_fast8_t duk_uint_fast8_t;\ntypedef int_fast8_t duk_int_fast8_t;\ntypedef uint_fast16_t duk_uint_fast16_t;\ntypedef int_fast16_t duk_int_fast16_t;\ntypedef uint_fast32_t duk_uint_fast32_t;\ntypedef int_fast32_t duk_int_fast32_t;\ntypedef uint_fast64_t duk_uint_fast64_t;\ntypedef int_fast64_t duk_int_fast64_t;\ntypedef uintptr_t duk_uintptr_t;\ntypedef intptr_t duk_intptr_t;\ntypedef uintmax_t duk_uintmax_t;\ntypedef intmax_t duk_intmax_t;\n\n#define DUK_UINT8_MIN         0\n#define DUK_UINT8_MAX         UINT8_MAX\n#define DUK_INT8_MIN          INT8_MIN\n#define DUK_INT8_MAX          INT8_MAX\n#define DUK_UINT_LEAST8_MIN   0\n#define DUK_UINT_LEAST8_MAX   UINT_LEAST8_MAX\n#define DUK_INT_LEAST8_MIN    INT_LEAST8_MIN\n#define DUK_INT_LEAST8_MAX    INT_LEAST8_MAX\n#define DUK_UINT_FAST8_MIN    0\n#define DUK_UINT_FAST8_MAX    UINT_FAST8_MAX\n#define DUK_INT_FAST8_MIN     INT_FAST8_MIN\n#define DUK_INT_FAST8_MAX     INT_FAST8_MAX\n#define DUK_UINT16_MIN        0\n#define DUK_UINT16_MAX        UINT16_MAX\n#define DUK_INT16_MIN         INT16_MIN\n#define DUK_INT16_MAX         INT16_MAX\n#define DUK_UINT_LEAST16_MIN  0\n#define DUK_UINT_LEAST16_MAX  UINT_LEAST16_MAX\n#define DUK_INT_LEAST16_MIN   INT_LEAST16_MIN\n#define DUK_INT_LEAST16_MAX   INT_LEAST16_MAX\n#define DUK_UINT_FAST16_MIN   0\n#define DUK_UINT_FAST16_MAX   UINT_FAST16_MAX\n#define DUK_INT_FAST16_MIN    INT_FAST16_MIN\n#define DUK_INT_FAST16_MAX    INT_FAST16_MAX\n#define DUK_UINT32_MIN        0\n#define DUK_UINT32_MAX        UINT32_MAX\n#define DUK_INT32_MIN         INT32_MIN\n#define DUK_INT32_MAX         INT32_MAX\n#define DUK_UINT_LEAST32_MIN  0\n#define DUK_UINT_LEAST32_MAX  UINT_LEAST32_MAX\n#define DUK_INT_LEAST32_MIN   INT_LEAST32_MIN\n#define DUK_INT_LEAST32_MAX   INT_LEAST32_MAX\n#define DUK_UINT_FAST32_MIN   0\n#define DUK_UINT_FAST32_MAX   UINT_FAST32_MAX\n#define DUK_INT_FAST32_MIN    INT_FAST32_MIN\n#define DUK_INT_FAST32_MAX    INT_FAST32_MAX\n#define DUK_UINT64_MIN        0\n#define DUK_UINT64_MAX        UINT64_MAX\n#define DUK_INT64_MIN         INT64_MIN\n#define DUK_INT64_MAX         INT64_MAX\n#define DUK_UINT_LEAST64_MIN  0\n#define DUK_UINT_LEAST64_MAX  UINT_LEAST64_MAX\n#define DUK_INT_LEAST64_MIN   INT_LEAST64_MIN\n#define DUK_INT_LEAST64_MAX   INT_LEAST64_MAX\n#define DUK_UINT_FAST64_MIN   0\n#define DUK_UINT_FAST64_MAX   UINT_FAST64_MAX\n#define DUK_INT_FAST64_MIN    INT_FAST64_MIN\n#define DUK_INT_FAST64_MAX    INT_FAST64_MAX\n\n#define DUK_UINTPTR_MIN       0\n#define DUK_UINTPTR_MAX       UINTPTR_MAX\n#define DUK_INTPTR_MIN        INTPTR_MIN\n#define DUK_INTPTR_MAX        INTPTR_MAX\n\n#define DUK_UINTMAX_MIN       0\n#define DUK_UINTMAX_MAX       UINTMAX_MAX\n#define DUK_INTMAX_MIN        INTMAX_MIN\n#define DUK_INTMAX_MAX        INTMAX_MAX\n\n#define DUK_SIZE_MIN          0\n#define DUK_SIZE_MAX          SIZE_MAX\n#undef DUK_SIZE_MAX_COMPUTED\n\n#else  /* C99 types */\n\n/* When C99 types are not available, we use heuristic detection to get\n * the basic 8, 16, 32, and (possibly) 64 bit types.  The fast/least\n * types are then assumed to be exactly the same for now: these could\n * be improved per platform but C99 types are very often now available.\n * 64-bit types are not available on all platforms; this is OK at least\n * on 32-bit platforms.\n *\n * This detection code is necessarily a bit hacky and can provide typedefs\n * and defines that won't work correctly on some exotic platform.\n */\n\n#if (defined(CHAR_BIT) && (CHAR_BIT == 8)) || \\\n    (defined(UCHAR_MAX) && (UCHAR_MAX == 255))\ntypedef unsigned char duk_uint8_t;\ntypedef signed char duk_int8_t;\n#else\n#error cannot detect 8-bit type\n#endif\n\n#if defined(USHRT_MAX) && (USHRT_MAX == 65535UL)\ntypedef unsigned short duk_uint16_t;\ntypedef signed short duk_int16_t;\n#elif defined(UINT_MAX) && (UINT_MAX == 65535UL)\n/* On some platforms int is 16-bit but long is 32-bit (e.g. PureC) */\ntypedef unsigned int duk_uint16_t;\ntypedef signed int duk_int16_t;\n#else\n#error cannot detect 16-bit type\n#endif\n\n#if defined(UINT_MAX) && (UINT_MAX == 4294967295UL)\ntypedef unsigned int duk_uint32_t;\ntypedef signed int duk_int32_t;\n#elif defined(ULONG_MAX) && (ULONG_MAX == 4294967295UL)\n/* On some platforms int is 16-bit but long is 32-bit (e.g. PureC) */\ntypedef unsigned long duk_uint32_t;\ntypedef signed long duk_int32_t;\n#else\n#error cannot detect 32-bit type\n#endif\n\n/* 64-bit type detection is a bit tricky.\n *\n * ULLONG_MAX is a standard define.  __LONG_LONG_MAX__ and __ULONG_LONG_MAX__\n * are used by at least GCC (even if system headers don't provide ULLONG_MAX).\n * Some GCC variants may provide __LONG_LONG_MAX__ but not __ULONG_LONG_MAX__.\n *\n * ULL / LL constants are rejected / warned about by some compilers, even if\n * the compiler has a 64-bit type and the compiler/system headers provide an\n * unsupported constant (ULL/LL)!  Try to avoid using ULL / LL constants.\n * As a side effect we can only check that e.g. ULONG_MAX is larger than 32\n * bits but can't be sure it is exactly 64 bits.  Self tests will catch such\n * cases.\n */\n#undef DUK_F_HAVE_64BIT\n#if !defined(DUK_F_HAVE_64BIT) && defined(ULONG_MAX)\n#if (ULONG_MAX > 4294967295UL)\n#define DUK_F_HAVE_64BIT\ntypedef unsigned long duk_uint64_t;\ntypedef signed long duk_int64_t;\n#endif\n#endif\n#if !defined(DUK_F_HAVE_64BIT) && defined(ULLONG_MAX)\n#if (ULLONG_MAX > 4294967295UL)\n#define DUK_F_HAVE_64BIT\ntypedef unsigned long long duk_uint64_t;\ntypedef signed long long duk_int64_t;\n#endif\n#endif\n#if !defined(DUK_F_HAVE_64BIT) && defined(__ULONG_LONG_MAX__)\n#if (__ULONG_LONG_MAX__ > 4294967295UL)\n#define DUK_F_HAVE_64BIT\ntypedef unsigned long long duk_uint64_t;\ntypedef signed long long duk_int64_t;\n#endif\n#endif\n#if !defined(DUK_F_HAVE_64BIT) && defined(__LONG_LONG_MAX__)\n#if (__LONG_LONG_MAX__ > 2147483647L)\n#define DUK_F_HAVE_64BIT\ntypedef unsigned long long duk_uint64_t;\ntypedef signed long long duk_int64_t;\n#endif\n#endif\n#if !defined(DUK_F_HAVE_64BIT) && \\\n    (defined(DUK_F_MINGW) || defined(DUK_F_MSVC))\n/* Both MinGW and MSVC have a 64-bit type. */\n#define DUK_F_HAVE_64BIT\ntypedef unsigned long duk_uint64_t;\ntypedef signed long duk_int64_t;\n#endif\n#if !defined(DUK_F_HAVE_64BIT)\n/* cannot detect 64-bit type, not always needed so don't error */\n#endif\n\ntypedef duk_uint8_t duk_uint_least8_t;\ntypedef duk_int8_t duk_int_least8_t;\ntypedef duk_uint16_t duk_uint_least16_t;\ntypedef duk_int16_t duk_int_least16_t;\ntypedef duk_uint32_t duk_uint_least32_t;\ntypedef duk_int32_t duk_int_least32_t;\ntypedef duk_uint8_t duk_uint_fast8_t;\ntypedef duk_int8_t duk_int_fast8_t;\ntypedef duk_uint16_t duk_uint_fast16_t;\ntypedef duk_int16_t duk_int_fast16_t;\ntypedef duk_uint32_t duk_uint_fast32_t;\ntypedef duk_int32_t duk_int_fast32_t;\n#if defined(DUK_F_HAVE_64BIT)\ntypedef duk_uint64_t duk_uint_least64_t;\ntypedef duk_int64_t duk_int_least64_t;\ntypedef duk_uint64_t duk_uint_fast64_t;\ntypedef duk_int64_t duk_int_fast64_t;\n#endif\n#if defined(DUK_F_HAVE_64BIT)\ntypedef duk_uint64_t duk_uintmax_t;\ntypedef duk_int64_t duk_intmax_t;\n#else\ntypedef duk_uint32_t duk_uintmax_t;\ntypedef duk_int32_t duk_intmax_t;\n#endif\n\n/* Note: the funny looking computations for signed minimum 16-bit, 32-bit, and\n * 64-bit values are intentional as the obvious forms (e.g. -0x80000000L) are\n * -not- portable.  See code-issues.txt for a detailed discussion.\n */\n#define DUK_UINT8_MIN         0UL\n#define DUK_UINT8_MAX         0xffUL\n#define DUK_INT8_MIN          (-0x80L)\n#define DUK_INT8_MAX          0x7fL\n#define DUK_UINT_LEAST8_MIN   0UL\n#define DUK_UINT_LEAST8_MAX   0xffUL\n#define DUK_INT_LEAST8_MIN    (-0x80L)\n#define DUK_INT_LEAST8_MAX    0x7fL\n#define DUK_UINT_FAST8_MIN    0UL\n#define DUK_UINT_FAST8_MAX    0xffUL\n#define DUK_INT_FAST8_MIN     (-0x80L)\n#define DUK_INT_FAST8_MAX     0x7fL\n#define DUK_UINT16_MIN        0UL\n#define DUK_UINT16_MAX        0xffffUL\n#define DUK_INT16_MIN         (-0x7fffL - 1L)\n#define DUK_INT16_MAX         0x7fffL\n#define DUK_UINT_LEAST16_MIN  0UL\n#define DUK_UINT_LEAST16_MAX  0xffffUL\n#define DUK_INT_LEAST16_MIN   (-0x7fffL - 1L)\n#define DUK_INT_LEAST16_MAX   0x7fffL\n#define DUK_UINT_FAST16_MIN   0UL\n#define DUK_UINT_FAST16_MAX   0xffffUL\n#define DUK_INT_FAST16_MIN    (-0x7fffL - 1L)\n#define DUK_INT_FAST16_MAX    0x7fffL\n#define DUK_UINT32_MIN        0UL\n#define DUK_UINT32_MAX        0xffffffffUL\n#define DUK_INT32_MIN         (-0x7fffffffL - 1L)\n#define DUK_INT32_MAX         0x7fffffffL\n#define DUK_UINT_LEAST32_MIN  0UL\n#define DUK_UINT_LEAST32_MAX  0xffffffffUL\n#define DUK_INT_LEAST32_MIN   (-0x7fffffffL - 1L)\n#define DUK_INT_LEAST32_MAX   0x7fffffffL\n#define DUK_UINT_FAST32_MIN   0UL\n#define DUK_UINT_FAST32_MAX   0xffffffffUL\n#define DUK_INT_FAST32_MIN    (-0x7fffffffL - 1L)\n#define DUK_INT_FAST32_MAX    0x7fffffffL\n\n/* 64-bit constants.  Since LL / ULL constants are not always available,\n * use computed values.  These values can't be used in preprocessor\n * comparisons; flag them as such.\n */\n#if defined(DUK_F_HAVE_64BIT)\n#define DUK_UINT64_MIN        ((duk_uint64_t) 0)\n#define DUK_UINT64_MAX        ((duk_uint64_t) -1)\n#define DUK_INT64_MIN         ((duk_int64_t) (~(DUK_UINT64_MAX >> 1)))\n#define DUK_INT64_MAX         ((duk_int64_t) (DUK_UINT64_MAX >> 1))\n#define DUK_UINT_LEAST64_MIN  DUK_UINT64_MIN\n#define DUK_UINT_LEAST64_MAX  DUK_UINT64_MAX\n#define DUK_INT_LEAST64_MIN   DUK_INT64_MIN\n#define DUK_INT_LEAST64_MAX   DUK_INT64_MAX\n#define DUK_UINT_FAST64_MIN   DUK_UINT64_MIN\n#define DUK_UINT_FAST64_MAX   DUK_UINT64_MAX\n#define DUK_INT_FAST64_MIN    DUK_INT64_MIN\n#define DUK_INT_FAST64_MAX    DUK_INT64_MAX\n#define DUK_UINT64_MIN_COMPUTED\n#define DUK_UINT64_MAX_COMPUTED\n#define DUK_INT64_MIN_COMPUTED\n#define DUK_INT64_MAX_COMPUTED\n#define DUK_UINT_LEAST64_MIN_COMPUTED\n#define DUK_UINT_LEAST64_MAX_COMPUTED\n#define DUK_INT_LEAST64_MIN_COMPUTED\n#define DUK_INT_LEAST64_MAX_COMPUTED\n#define DUK_UINT_FAST64_MIN_COMPUTED\n#define DUK_UINT_FAST64_MAX_COMPUTED\n#define DUK_INT_FAST64_MIN_COMPUTED\n#define DUK_INT_FAST64_MAX_COMPUTED\n#endif\n\n#if defined(DUK_F_HAVE_64BIT)\n#define DUK_UINTMAX_MIN       DUK_UINT64_MIN\n#define DUK_UINTMAX_MAX       DUK_UINT64_MAX\n#define DUK_INTMAX_MIN        DUK_INT64_MIN\n#define DUK_INTMAX_MAX        DUK_INT64_MAX\n#define DUK_UINTMAX_MIN_COMPUTED\n#define DUK_UINTMAX_MAX_COMPUTED\n#define DUK_INTMAX_MIN_COMPUTED\n#define DUK_INTMAX_MAX_COMPUTED\n#else\n#define DUK_UINTMAX_MIN       0UL\n#define DUK_UINTMAX_MAX       0xffffffffUL\n#define DUK_INTMAX_MIN        (-0x7fffffffL - 1L)\n#define DUK_INTMAX_MAX        0x7fffffffL\n#endif\n\n/* This detection is not very reliable. */\n#if defined(DUK_F_32BIT_PTRS)\ntypedef duk_int32_t duk_intptr_t;\ntypedef duk_uint32_t duk_uintptr_t;\n#define DUK_UINTPTR_MIN       DUK_UINT32_MIN\n#define DUK_UINTPTR_MAX       DUK_UINT32_MAX\n#define DUK_INTPTR_MIN        DUK_INT32_MIN\n#define DUK_INTPTR_MAX        DUK_INT32_MAX\n#elif defined(DUK_F_64BIT_PTRS) && defined(DUK_F_HAVE_64BIT)\ntypedef duk_int64_t duk_intptr_t;\ntypedef duk_uint64_t duk_uintptr_t;\n#define DUK_UINTPTR_MIN       DUK_UINT64_MIN\n#define DUK_UINTPTR_MAX       DUK_UINT64_MAX\n#define DUK_INTPTR_MIN        DUK_INT64_MIN\n#define DUK_INTPTR_MAX        DUK_INT64_MAX\n#define DUK_UINTPTR_MIN_COMPUTED\n#define DUK_UINTPTR_MAX_COMPUTED\n#define DUK_INTPTR_MIN_COMPUTED\n#define DUK_INTPTR_MAX_COMPUTED\n#else\n#error cannot determine intptr type\n#endif\n\n/* SIZE_MAX may be missing so use an approximate value for it. */\n#undef DUK_SIZE_MAX_COMPUTED\n#if !defined(SIZE_MAX)\n#define DUK_SIZE_MAX_COMPUTED\n#define SIZE_MAX              ((size_t) (-1))\n#endif\n#define DUK_SIZE_MIN          0\n#define DUK_SIZE_MAX          SIZE_MAX\n\n#endif  /* C99 types */\n\n/* A few types are assumed to always exist. */\ntypedef size_t duk_size_t;\ntypedef ptrdiff_t duk_ptrdiff_t;\n\n/* The best type for an \"all around int\" in Duktape internals is \"at least\n * 32 bit signed integer\" which is most convenient.  Same for unsigned type.\n * Prefer 'int' when large enough, as it is almost always a convenient type.\n */\n#if defined(UINT_MAX) && (UINT_MAX >= 0xffffffffUL)\ntypedef int duk_int_t;\ntypedef unsigned int duk_uint_t;\n#define DUK_INT_MIN           INT_MIN\n#define DUK_INT_MAX           INT_MAX\n#define DUK_UINT_MIN          0\n#define DUK_UINT_MAX          UINT_MAX\n#else\ntypedef duk_int_fast32_t duk_int_t;\ntypedef duk_uint_fast32_t duk_uint_t;\n#define DUK_INT_MIN           DUK_INT_FAST32_MIN\n#define DUK_INT_MAX           DUK_INT_FAST32_MAX\n#define DUK_UINT_MIN          DUK_UINT_FAST32_MIN\n#define DUK_UINT_MAX          DUK_UINT_FAST32_MAX\n#endif\n\n/* Same as 'duk_int_t' but guaranteed to be a 'fast' variant if this\n * distinction matters for the CPU.  These types are used mainly in the\n * executor where it might really matter.\n */\ntypedef duk_int_fast32_t duk_int_fast_t;\ntypedef duk_uint_fast32_t duk_uint_fast_t;\n#define DUK_INT_FAST_MIN      DUK_INT_FAST32_MIN\n#define DUK_INT_FAST_MAX      DUK_INT_FAST32_MAX\n#define DUK_UINT_FAST_MIN     DUK_UINT_FAST32_MIN\n#define DUK_UINT_FAST_MAX     DUK_UINT_FAST32_MAX\n\n/* Small integers (16 bits or more) can fall back to the 'int' type, but\n * have a typedef so they are marked \"small\" explicitly.\n */\ntypedef int duk_small_int_t;\ntypedef unsigned int duk_small_uint_t;\n#define DUK_SMALL_INT_MIN     INT_MIN\n#define DUK_SMALL_INT_MAX     INT_MAX\n#define DUK_SMALL_UINT_MIN    0\n#define DUK_SMALL_UINT_MAX    UINT_MAX\n\n/* Fast variants of small integers, again for really fast paths like the\n * executor.\n */\ntypedef duk_int_fast16_t duk_small_int_fast_t;\ntypedef duk_uint_fast16_t duk_small_uint_fast_t;\n#define DUK_SMALL_INT_FAST_MIN    DUK_INT_FAST16_MIN\n#define DUK_SMALL_INT_FAST_MAX    DUK_INT_FAST16_MAX\n#define DUK_SMALL_UINT_FAST_MIN   DUK_UINT_FAST16_MIN\n#define DUK_SMALL_UINT_FAST_MAX   DUK_UINT_FAST16_MAX\n\n/* Boolean values are represented with the platform 'int'. */\ntypedef duk_small_int_t duk_bool_t;\n#define DUK_BOOL_MIN              DUK_SMALL_INT_MIN\n#define DUK_BOOL_MAX              DUK_SMALL_INT_MAX\n\n/* Index values must have at least 32-bit signed range. */\ntypedef duk_int_t duk_idx_t;\n#define DUK_IDX_MIN               DUK_INT_MIN\n#define DUK_IDX_MAX               DUK_INT_MAX\n\n/* Unsigned index variant. */\ntypedef duk_uint_t duk_uidx_t;\n#define DUK_UIDX_MIN              DUK_UINT_MIN\n#define DUK_UIDX_MAX              DUK_UINT_MAX\n\n/* Array index values, could be exact 32 bits.\n * Currently no need for signed duk_arridx_t.\n */\ntypedef duk_uint_t duk_uarridx_t;\n#define DUK_UARRIDX_MIN           DUK_UINT_MIN\n#define DUK_UARRIDX_MAX           DUK_UINT_MAX\n\n/* Duktape/C function return value, platform int is enough for now to\n * represent 0, 1, or negative error code.  Must be compatible with\n * assigning truth values (e.g. duk_ret_t rc = (foo == bar);).\n */\ntypedef duk_small_int_t duk_ret_t;\n#define DUK_RET_MIN               DUK_SMALL_INT_MIN\n#define DUK_RET_MAX               DUK_SMALL_INT_MAX\n\n/* Error codes are represented with platform int.  High bits are used\n * for flags and such, so 32 bits are needed.\n */\ntypedef duk_int_t duk_errcode_t;\n#define DUK_ERRCODE_MIN           DUK_INT_MIN\n#define DUK_ERRCODE_MAX           DUK_INT_MAX\n\n/* Codepoint type.  Must be 32 bits or more because it is used also for\n * internal codepoints.  The type is signed because negative codepoints\n * are used as internal markers (e.g. to mark EOF or missing argument).\n * (X)UTF-8/CESU-8 encode/decode take and return an unsigned variant to\n * ensure duk_uint32_t casts back and forth nicely.  Almost everything\n * else uses the signed one.\n */\ntypedef duk_int_t duk_codepoint_t;\ntypedef duk_uint_t duk_ucodepoint_t;\n#define DUK_CODEPOINT_MIN         DUK_INT_MIN\n#define DUK_CODEPOINT_MAX         DUK_INT_MAX\n#define DUK_UCODEPOINT_MIN        DUK_UINT_MIN\n#define DUK_UCODEPOINT_MAX        DUK_UINT_MAX\n\n/* IEEE float/double typedef. */\ntypedef float duk_float_t;\ntypedef double duk_double_t;\n\n/* We're generally assuming that we're working on a platform with a 32-bit\n * address space.  If DUK_SIZE_MAX is a typecast value (which is necessary\n * if SIZE_MAX is missing), the check must be avoided because the\n * preprocessor can't do a comparison.\n */\n#if !defined(DUK_SIZE_MAX)\n#error DUK_SIZE_MAX is undefined, probably missing SIZE_MAX\n#elif !defined(DUK_SIZE_MAX_COMPUTED)\n#if DUK_SIZE_MAX < 0xffffffffUL\n/* On some systems SIZE_MAX can be smaller than max unsigned 32-bit value\n * which seems incorrect if size_t is (at least) an unsigned 32-bit type.\n * However, it doesn't seem useful to error out compilation if this is the\n * case.\n */\n#endif\n#endif\n\n/* Type for public API calls. */\ntypedef struct duk_hthread duk_context;\n\n/* Check whether we should use 64-bit integers or not.\n *\n * Quite incomplete now.  Use 64-bit types if detected (C99 or other detection)\n * unless they are known to be unreliable.  For instance, 64-bit types are\n * available on VBCC but seem to misbehave.\n */\n#if defined(DUK_F_HAVE_64BIT) && !defined(DUK_F_VBCC)\n#define DUK_USE_64BIT_OPS\n#else\n#undef DUK_USE_64BIT_OPS\n#endif\n\n/*\n *  Fill-ins for platform, architecture, and compiler\n */\n\n/* An abort()-like primitive is needed by the default fatal error handler. */\n#if !defined(DUK_ABORT)\n#define DUK_ABORT             abort\n#endif\n\n#if !defined(DUK_SETJMP)\n#define DUK_JMPBUF_TYPE       jmp_buf\n#define DUK_SETJMP(jb)        setjmp((jb))\n#define DUK_LONGJMP(jb)       longjmp((jb), 1)\n#endif\n\n#if 0\n/* sigsetjmp() alternative */\n#define DUK_JMPBUF_TYPE       sigjmp_buf\n#define DUK_SETJMP(jb)        sigsetjmp((jb))\n#define DUK_LONGJMP(jb)       siglongjmp((jb), 1)\n#endif\n\n/* Special naming to avoid conflict with e.g. DUK_FREE() in duk_heap.h\n * (which is unfortunately named).  May sometimes need replacement, e.g.\n * some compilers don't handle zero length or NULL correctly in realloc().\n */\n#if !defined(DUK_ANSI_MALLOC)\n#define DUK_ANSI_MALLOC      malloc\n#endif\n#if !defined(DUK_ANSI_REALLOC)\n#define DUK_ANSI_REALLOC     realloc\n#endif\n#if !defined(DUK_ANSI_CALLOC)\n#define DUK_ANSI_CALLOC      calloc\n#endif\n#if !defined(DUK_ANSI_FREE)\n#define DUK_ANSI_FREE        free\n#endif\n\n/* ANSI C (various versions) and some implementations require that the\n * pointer arguments to memset(), memcpy(), and memmove() be valid values\n * even when byte size is 0 (even a NULL pointer is considered invalid in\n * this context).  Zero-size operations as such are allowed, as long as their\n * pointer arguments point to a valid memory area.  The DUK_MEMSET(),\n * DUK_MEMCPY(), and DUK_MEMMOVE() macros require this same behavior, i.e.:\n * (1) pointers must be valid and non-NULL, (2) zero size must otherwise be\n * allowed.  If these are not fulfilled, a macro wrapper is needed.\n *\n *   http://stackoverflow.com/questions/5243012/is-it-guaranteed-to-be-safe-to-perform-memcpy0-0-0\n *   http://lists.cs.uiuc.edu/pipermail/llvmdev/2007-October/011065.html\n *\n * Not sure what's the required behavior when a pointer points just past the\n * end of a buffer, which often happens in practice (e.g. zero size memmoves).\n * For example, if allocation size is 3, the following pointer would not\n * technically point to a valid memory byte:\n *\n *   <-- alloc -->\n *   | 0 | 1 | 2 | .....\n *                 ^-- p=3, points after last valid byte (2)\n */\n#if !defined(DUK_MEMCPY)\n#if defined(DUK_F_UCLIBC)\n/* Old uclibcs have a broken memcpy so use memmove instead (this is overly wide\n * now on purpose): http://lists.uclibc.org/pipermail/uclibc-cvs/2008-October/025511.html\n */\n#define DUK_MEMCPY       memmove\n#else\n#define DUK_MEMCPY       memcpy\n#endif\n#endif\n#if !defined(DUK_MEMMOVE)\n#define DUK_MEMMOVE      memmove\n#endif\n#if !defined(DUK_MEMCMP)\n#define DUK_MEMCMP       memcmp\n#endif\n#if !defined(DUK_MEMSET)\n#define DUK_MEMSET       memset\n#endif\n#if !defined(DUK_STRLEN)\n#define DUK_STRLEN       strlen\n#endif\n#if !defined(DUK_STRCMP)\n#define DUK_STRCMP       strcmp\n#endif\n#if !defined(DUK_STRNCMP)\n#define DUK_STRNCMP      strncmp\n#endif\n#if !defined(DUK_SPRINTF)\n#define DUK_SPRINTF      sprintf\n#endif\n#if !defined(DUK_SNPRINTF)\n/* snprintf() is technically not part of C89 but usually available. */\n#define DUK_SNPRINTF     snprintf\n#endif\n#if !defined(DUK_VSPRINTF)\n#define DUK_VSPRINTF     vsprintf\n#endif\n#if !defined(DUK_VSNPRINTF)\n/* vsnprintf() is technically not part of C89 but usually available. */\n#define DUK_VSNPRINTF    vsnprintf\n#endif\n#if !defined(DUK_SSCANF)\n#define DUK_SSCANF       sscanf\n#endif\n#if !defined(DUK_VSSCANF)\n#define DUK_VSSCANF      vsscanf\n#endif\n#if !defined(DUK_MEMZERO)\n#define DUK_MEMZERO(p,n) DUK_MEMSET((p), 0, (n))\n#endif\n\n#if !defined(DUK_DOUBLE_INFINITY)\n#undef DUK_USE_COMPUTED_INFINITY\n#if defined(DUK_F_GCC_VERSION) && (DUK_F_GCC_VERSION < 40600)\n/* GCC older than 4.6: avoid overflow warnings related to using INFINITY */\n#define DUK_DOUBLE_INFINITY  (__builtin_inf())\n#elif defined(INFINITY)\n#define DUK_DOUBLE_INFINITY  ((double) INFINITY)\n#elif !defined(DUK_F_VBCC) && !defined(DUK_F_MSVC) && !defined(DUK_F_BCC) && \\\n      !defined(DUK_F_OLD_SOLARIS) && !defined(DUK_F_AIX)\n#define DUK_DOUBLE_INFINITY  (1.0 / 0.0)\n#else\n/* In VBCC (1.0 / 0.0) results in a warning and 0.0 instead of infinity.\n * Use a computed infinity (initialized when a heap is created at the\n * latest).\n */\n#define DUK_USE_COMPUTED_INFINITY\n#define DUK_DOUBLE_INFINITY  duk_computed_infinity\n#endif\n#endif\n\n#if !defined(DUK_DOUBLE_NAN)\n#undef DUK_USE_COMPUTED_NAN\n#if defined(NAN)\n#define DUK_DOUBLE_NAN       NAN\n#elif !defined(DUK_F_VBCC) && !defined(DUK_F_MSVC) && !defined(DUK_F_BCC) && \\\n      !defined(DUK_F_OLD_SOLARIS) && !defined(DUK_F_AIX)\n#define DUK_DOUBLE_NAN       (0.0 / 0.0)\n#else\n/* In VBCC (0.0 / 0.0) results in a warning and 0.0 instead of NaN.\n * In MSVC (VS2010 Express) (0.0 / 0.0) results in a compile error.\n * Use a computed NaN (initialized when a heap is created at the\n * latest).\n */\n#define DUK_USE_COMPUTED_NAN\n#define DUK_DOUBLE_NAN       duk_computed_nan\n#endif\n#endif\n\n/* Many platforms are missing fpclassify() and friends, so use replacements\n * if necessary.  The replacement constants (FP_NAN etc) can be anything but\n * match Linux constants now.\n */\n#undef DUK_USE_REPL_FPCLASSIFY\n#undef DUK_USE_REPL_SIGNBIT\n#undef DUK_USE_REPL_ISFINITE\n#undef DUK_USE_REPL_ISNAN\n#undef DUK_USE_REPL_ISINF\n\n/* Complex condition broken into separate parts. */\n#undef DUK_F_USE_REPL_ALL\n#if !(defined(FP_NAN) && defined(FP_INFINITE) && defined(FP_ZERO) && \\\n      defined(FP_SUBNORMAL) && defined(FP_NORMAL))\n/* Missing some obvious constants. */\n#define DUK_F_USE_REPL_ALL\n#elif defined(DUK_F_AMIGAOS) && defined(DUK_F_VBCC)\n/* VBCC is missing the built-ins even in C99 mode (perhaps a header issue). */\n#define DUK_F_USE_REPL_ALL\n#elif defined(DUK_F_AMIGAOS) && defined(DUK_F_M68K)\n/* AmigaOS + M68K seems to have math issues even when using GCC cross\n * compilation.  Use replacements for all AmigaOS versions on M68K\n * regardless of compiler.\n */\n#define DUK_F_USE_REPL_ALL\n#elif defined(DUK_F_FREEBSD) && defined(DUK_F_CLANG)\n/* Placeholder fix for (detection is wider than necessary):\n * http://llvm.org/bugs/show_bug.cgi?id=17788\n */\n#define DUK_F_USE_REPL_ALL\n#elif defined(DUK_F_UCLIBC)\n/* At least some uclibc versions have broken floating point math.  For\n * example, fpclassify() can incorrectly classify certain NaN formats.\n * To be safe, use replacements.\n */\n#define DUK_F_USE_REPL_ALL\n#elif defined(DUK_F_AIX)\n/* Older versions may be missing isnan(), etc. */\n#define DUK_F_USE_REPL_ALL\n#endif\n\n#if defined(DUK_F_USE_REPL_ALL)\n#define DUK_USE_REPL_FPCLASSIFY\n#define DUK_USE_REPL_SIGNBIT\n#define DUK_USE_REPL_ISFINITE\n#define DUK_USE_REPL_ISNAN\n#define DUK_USE_REPL_ISINF\n#define DUK_FPCLASSIFY       duk_repl_fpclassify\n#define DUK_SIGNBIT          duk_repl_signbit\n#define DUK_ISFINITE         duk_repl_isfinite\n#define DUK_ISNAN            duk_repl_isnan\n#define DUK_ISINF            duk_repl_isinf\n#define DUK_FP_NAN           0\n#define DUK_FP_INFINITE      1\n#define DUK_FP_ZERO          2\n#define DUK_FP_SUBNORMAL     3\n#define DUK_FP_NORMAL        4\n#else\n#define DUK_FPCLASSIFY       fpclassify\n#define DUK_SIGNBIT          signbit\n#define DUK_ISFINITE         isfinite\n#define DUK_ISNAN            isnan\n#define DUK_ISINF            isinf\n#define DUK_FP_NAN           FP_NAN\n#define DUK_FP_INFINITE      FP_INFINITE\n#define DUK_FP_ZERO          FP_ZERO\n#define DUK_FP_SUBNORMAL     FP_SUBNORMAL\n#define DUK_FP_NORMAL        FP_NORMAL\n#endif\n\n#if defined(DUK_F_USE_REPL_ALL)\n#undef DUK_F_USE_REPL_ALL\n#endif\n\n/* These functions don't currently need replacement but are wrapped for\n * completeness.  Because these are used as function pointers, they need\n * to be defined as concrete C functions (not macros).\n */\n#if !defined(DUK_FABS)\n#define DUK_FABS             fabs\n#endif\n#if !defined(DUK_FLOOR)\n#define DUK_FLOOR            floor\n#endif\n#if !defined(DUK_CEIL)\n#define DUK_CEIL             ceil\n#endif\n#if !defined(DUK_FMOD)\n#define DUK_FMOD             fmod\n#endif\n#if !defined(DUK_POW)\n#define DUK_POW              pow\n#endif\n#if !defined(DUK_ACOS)\n#define DUK_ACOS             acos\n#endif\n#if !defined(DUK_ASIN)\n#define DUK_ASIN             asin\n#endif\n#if !defined(DUK_ATAN)\n#define DUK_ATAN             atan\n#endif\n#if !defined(DUK_ATAN2)\n#define DUK_ATAN2            atan2\n#endif\n#if !defined(DUK_SIN)\n#define DUK_SIN              sin\n#endif\n#if !defined(DUK_COS)\n#define DUK_COS              cos\n#endif\n#if !defined(DUK_TAN)\n#define DUK_TAN              tan\n#endif\n#if !defined(DUK_EXP)\n#define DUK_EXP              exp\n#endif\n#if !defined(DUK_LOG)\n#define DUK_LOG              log\n#endif\n#if !defined(DUK_SQRT)\n#define DUK_SQRT             sqrt\n#endif\n\n/* The functions below exist only in C99/C++11 or later and need a workaround\n * for platforms that don't include them.  MSVC isn't detected as C99, but\n * these functions also exist in MSVC 2013 and later so include a clause for\n * that too.  Android doesn't have log2; disable all of these for Android.\n */\n#if (defined(DUK_F_C99) || defined(DUK_F_CPP11) || (defined(_MSC_VER) && (_MSC_VER >= 1800))) && \\\n    !defined(DUK_F_ANDROID) && !defined(DUK_F_MINT)\n#if !defined(DUK_CBRT)\n#define DUK_CBRT             cbrt\n#endif\n#if !defined(DUK_LOG2)\n#define DUK_LOG2             log2\n#endif\n#if !defined(DUK_LOG10)\n#define DUK_LOG10            log10\n#endif\n#if !defined(DUK_TRUNC)\n#define DUK_TRUNC            trunc\n#endif\n#endif  /* DUK_F_C99 etc */\n\n/* NetBSD 6.0 x86 (at least) has a few problems with pow() semantics,\n * see test-bug-netbsd-math-pow.js.  MinGW has similar (but different)\n * issues, see test-bug-mingw-math-issues.js.  Enable pow() workarounds\n * for these targets.\n */\n#undef DUK_USE_POW_WORKAROUNDS\n#if defined(DUK_F_NETBSD) || defined(DUK_F_MINGW)\n#define DUK_USE_POW_WORKAROUNDS\n#endif\n\n/* Similar workarounds for atan2() semantics issues.  MinGW issues are\n * documented in test-bug-mingw-math-issues.js.\n */\n#undef DUK_USE_ATAN2_WORKAROUNDS\n#if defined(DUK_F_MINGW)\n#define DUK_USE_ATAN2_WORKAROUNDS\n#endif\n\n/* Rely as little as possible on compiler behavior for NaN comparison,\n * signed zero handling, etc.  Currently never activated but may be needed\n * for broken compilers.\n */\n#undef DUK_USE_PARANOID_MATH\n\n/* There was a curious bug where test-bi-date-canceling.js would fail e.g.\n * on 64-bit Ubuntu, gcc-4.8.1, -m32, and no -std=c99.  Some date computations\n * using doubles would be optimized which then broke some corner case tests.\n * The problem goes away by adding 'volatile' to the datetime computations.\n * Not sure what the actual triggering conditions are, but using this on\n * non-C99 systems solves the known issues and has relatively little cost\n * on other platforms.\n */\n#undef DUK_USE_PARANOID_DATE_COMPUTATION\n#if !defined(DUK_F_C99)\n#define DUK_USE_PARANOID_DATE_COMPUTATION\n#endif\n\n/*\n *  Byte order and double memory layout detection\n *\n *  Endianness detection is a major portability hassle because the macros\n *  and headers are not standardized.  There's even variance across UNIX\n *  platforms.  Even with \"standard\" headers, details like underscore count\n *  varies between platforms, e.g. both __BYTE_ORDER and _BYTE_ORDER are used\n *  (Crossbridge has a single underscore, for instance).\n *\n *  The checks below are structured with this in mind: several approaches are\n *  used, and at the end we check if any of them worked.  This allows generic\n *  approaches to be tried first, and platform/compiler specific hacks tried\n *  last.  As a last resort, the user can force a specific endianness, as it's\n *  not likely that automatic detection will work on the most exotic platforms.\n *\n *  Duktape supports little and big endian machines.  There's also support\n *  for a hybrid used by some ARM machines where integers are little endian\n *  but IEEE double values use a mixed order (12345678 -> 43218765).  This\n *  byte order for doubles is referred to as \"mixed endian\".\n */\n\n/* GCC and Clang provide endianness defines as built-in predefines, with\n * leading and trailing double underscores (e.g. __BYTE_ORDER__).  See\n * output of \"make gccpredefs\" and \"make clangpredefs\".  Clang doesn't\n * seem to provide __FLOAT_WORD_ORDER__; assume not mixed endian for clang.\n * http://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html\n */\n#if !defined(DUK_USE_BYTEORDER) && defined(__BYTE_ORDER__)\n#if defined(__ORDER_LITTLE_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)\n#if defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && (__FLOAT_WORD_ORDER__ == __ORDER_LITTLE_ENDIAN__)\n#define DUK_USE_BYTEORDER 1\n#elif defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__)\n#define DUK_USE_BYTEORDER 2\n#elif !defined(__FLOAT_WORD_ORDER__)\n/* Float word order not known, assume not a hybrid. */\n#define DUK_USE_BYTEORDER 1\n#else\n/* Byte order is little endian but cannot determine IEEE double word order. */\n#endif  /* float word order */\n#elif defined(__ORDER_BIG_ENDIAN__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)\n#if defined(__FLOAT_WORD_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__)\n#define DUK_USE_BYTEORDER 3\n#elif !defined(__FLOAT_WORD_ORDER__)\n/* Float word order not known, assume not a hybrid. */\n#define DUK_USE_BYTEORDER 3\n#else\n/* Byte order is big endian but cannot determine IEEE double word order. */\n#endif  /* float word order */\n#else\n/* Cannot determine byte order; __ORDER_PDP_ENDIAN__ is related to 32-bit\n * integer ordering and is not relevant.\n */\n#endif  /* integer byte order */\n#endif  /* !defined(DUK_USE_BYTEORDER) && defined(__BYTE_ORDER__) */\n\n/* More or less standard endianness predefines provided by header files.\n * The ARM hybrid case is detected by assuming that __FLOAT_WORD_ORDER\n * will be big endian, see: http://lists.mysql.com/internals/443.\n * On some platforms some defines may be present with an empty value which\n * causes comparisons to fail: https://github.com/svaarala/duktape/issues/453.\n */\n#if !defined(DUK_USE_BYTEORDER)\n#if defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && (__BYTE_ORDER == __LITTLE_ENDIAN) || \\\n    defined(_BYTE_ORDER) && defined(_LITTLE_ENDIAN) && (_BYTE_ORDER == _LITTLE_ENDIAN) || \\\n    defined(__LITTLE_ENDIAN__)\n#if defined(__FLOAT_WORD_ORDER) && defined(__LITTLE_ENDIAN) && (__FLOAT_WORD_ORDER == __LITTLE_ENDIAN) || \\\n    defined(_FLOAT_WORD_ORDER) && defined(_LITTLE_ENDIAN) && (_FLOAT_WORD_ORDER == _LITTLE_ENDIAN)\n#define DUK_USE_BYTEORDER 1\n#elif defined(__FLOAT_WORD_ORDER) && defined(__BIG_ENDIAN) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) || \\\n      defined(_FLOAT_WORD_ORDER) && defined(_BIG_ENDIAN) && (_FLOAT_WORD_ORDER == _BIG_ENDIAN)\n#define DUK_USE_BYTEORDER 2\n#elif !defined(__FLOAT_WORD_ORDER) && !defined(_FLOAT_WORD_ORDER)\n/* Float word order not known, assume not a hybrid. */\n#define DUK_USE_BYTEORDER 1\n#else\n/* Byte order is little endian but cannot determine IEEE double word order. */\n#endif  /* float word order */\n#elif defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && (__BYTE_ORDER == __BIG_ENDIAN) || \\\n      defined(_BYTE_ORDER) && defined(_BIG_ENDIAN) && (_BYTE_ORDER == _BIG_ENDIAN) || \\\n      defined(__BIG_ENDIAN__)\n#if defined(__FLOAT_WORD_ORDER) && defined(__BIG_ENDIAN) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) || \\\n    defined(_FLOAT_WORD_ORDER) && defined(_BIG_ENDIAN) && (_FLOAT_WORD_ORDER == _BIG_ENDIAN)\n#define DUK_USE_BYTEORDER 3\n#elif !defined(__FLOAT_WORD_ORDER) && !defined(_FLOAT_WORD_ORDER)\n/* Float word order not known, assume not a hybrid. */\n#define DUK_USE_BYTEORDER 3\n#else\n/* Byte order is big endian but cannot determine IEEE double word order. */\n#endif  /* float word order */\n#else\n/* Cannot determine byte order. */\n#endif  /* integer byte order */\n#endif  /* !defined(DUK_USE_BYTEORDER) */\n\n/* QNX gcc cross compiler seems to define e.g. __LITTLEENDIAN__ or __BIGENDIAN__:\n *  $ /opt/qnx650/host/linux/x86/usr/bin/i486-pc-nto-qnx6.5.0-gcc -dM -E - </dev/null | grep -ni endian\n *  67:#define __LITTLEENDIAN__ 1\n *  $ /opt/qnx650/host/linux/x86/usr/bin/mips-unknown-nto-qnx6.5.0-gcc -dM -E - </dev/null | grep -ni endian\n *  81:#define __BIGENDIAN__ 1\n *  $ /opt/qnx650/host/linux/x86/usr/bin/arm-unknown-nto-qnx6.5.0-gcc -dM -E - </dev/null | grep -ni endian\n *  70:#define __LITTLEENDIAN__ 1\n */\n#if !defined(DUK_USE_BYTEORDER)\n#if defined(__LITTLEENDIAN__)\n#define DUK_USE_BYTEORDER 1\n#elif defined(__BIGENDIAN__)\n#define DUK_USE_BYTEORDER 3\n#endif\n#endif\n\n/*\n *  Alignment requirement and support for unaligned accesses\n *\n *  Assume unaligned accesses are not supported unless specifically allowed\n *  in the target platform.  Some platforms may support unaligned accesses\n *  but alignment to 4 or 8 may still be desirable.\n */\n\n/* If not provided, use safe default for alignment. */\n#if !defined(DUK_USE_ALIGN_BY)\n#define DUK_USE_ALIGN_BY 8\n#endif\n\n/* Compiler specific hackery needed to force struct size to match aligment,\n * see e.g. duk_hbuffer.h.\n *\n * http://stackoverflow.com/questions/11130109/c-struct-size-alignment\n * http://stackoverflow.com/questions/10951039/specifying-64-bit-alignment\n */\n#if !(defined(DUK_USE_PACK_MSVC_PRAGMA) || defined(DUK_USE_PACK_GCC_ATTR) || \\\n      defined(DUK_USE_PACK_CLANG_ATTR) || defined(DUK_USE_PACK_DUMMY_MEMBER))\n#define DUK_USE_PACK_DUMMY_MEMBER\n#endif\n\n#if !defined(DUK_VA_COPY)\n/* We need va_copy() which is defined in C99 / C++11, so an awkward\n * replacement is needed for pre-C99 / pre-C++11 environments.  This\n * will quite likely need portability hacks for some non-C99\n * environments.\n */\n#if defined(DUK_F_C99) || defined(DUK_F_CPP11)\n/* C99 / C++11 and above: rely on va_copy() which is required.\n * Omit parenthesis on macro right side on purpose to minimize differences\n * to direct use.\n */\n#define DUK_VA_COPY(dest,src) va_copy(dest,src)\n#else\n/* Pre-C99: va_list type is implementation dependent.  This replacement\n * assumes it is a plain value so that a simple assignment will work.\n * This is not the case on all platforms (it may be a single-array element,\n * for instance).\n */\n#define DUK_VA_COPY(dest,src) do { (dest) = (src); } while (0)\n#endif\n#endif\n\n#if !defined(DUK_MACRO_STRINGIFY)\n/* Macro hackery to convert e.g. __LINE__ to a string without formatting,\n * see: http://stackoverflow.com/questions/240353/convert-a-preprocessor-token-to-a-string\n */\n#define DUK_MACRO_STRINGIFY_HELPER(x)  #x\n#define DUK_MACRO_STRINGIFY(x)  DUK_MACRO_STRINGIFY_HELPER(x)\n#endif\n\n#if !defined(DUK_CAUSE_SEGFAULT)\n/* This can be used for testing; valgrind will then indicate the C call stack\n * leading to the call site.\n */\n#define DUK_CAUSE_SEGFAULT()  do { *((volatile duk_uint32_t *) NULL) = (duk_uint32_t) 0xdeadbeefUL; } while (0)\n#endif\n#if !defined(DUK_UNREF)\n/* Macro for suppressing warnings for potentially unreferenced variables.\n * The variables can be actually unreferenced or unreferenced in some\n * specific cases only; for instance, if a variable is only debug printed,\n * it is unreferenced when debug printing is disabled.  May cause warnings\n * for volatile arguments.\n */\n#define DUK_UNREF(x)  do { (void) (x); } while (0)\n#endif\n#if !defined(DUK_NORETURN)\n#define DUK_NORETURN(decl)  decl\n#endif\n#if !defined(DUK_UNREACHABLE)\n/* Don't know how to declare unreachable point, so don't do it; this\n * may cause some spurious compilation warnings (e.g. \"variable used\n * uninitialized\").\n */\n#define DUK_UNREACHABLE()  do { } while (0)\n#endif\n#if !defined(DUK_LOSE_CONST)\n/* Convert any input pointer into a \"void *\", losing a const qualifier.\n * This is not fully portable because casting through duk_uintptr_t may\n * not work on all architectures (e.g. those with long, segmented pointers).\n */\n#define DUK_LOSE_CONST(src) ((void *) (duk_uintptr_t) (src))\n#endif\n\n#if !defined(DUK_LIKELY)\n#define DUK_LIKELY(x)    (x)\n#endif\n#if !defined(DUK_UNLIKELY)\n#define DUK_UNLIKELY(x)  (x)\n#endif\n#if !defined(DUK_UNPREDICTABLE)\n#define DUK_UNPREDICTABLE(x)  (x)\n#endif\n\n#if !defined(DUK_NOINLINE)\n#define DUK_NOINLINE       /*nop*/\n#endif\n#if !defined(DUK_INLINE)\n#define DUK_INLINE         /*nop*/\n#endif\n#if !defined(DUK_ALWAYS_INLINE)\n#define DUK_ALWAYS_INLINE  /*nop*/\n#endif\n\n#if !defined(DUK_HOT)\n#define DUK_HOT            /*nop*/\n#endif\n#if !defined(DUK_COLD)\n#define DUK_COLD           /*nop*/\n#endif\n\n#if !defined(DUK_EXTERNAL_DECL)\n#define DUK_EXTERNAL_DECL  extern\n#endif\n#if !defined(DUK_EXTERNAL)\n#define DUK_EXTERNAL       /*empty*/\n#endif\n#if !defined(DUK_INTERNAL_DECL)\n#if defined(DUK_SINGLE_FILE)\n#define DUK_INTERNAL_DECL  static\n#else\n#define DUK_INTERNAL_DECL  extern\n#endif\n#endif\n#if !defined(DUK_INTERNAL)\n#if defined(DUK_SINGLE_FILE)\n#define DUK_INTERNAL       static\n#else\n#define DUK_INTERNAL       /*empty*/\n#endif\n#endif\n#if !defined(DUK_LOCAL_DECL)\n#define DUK_LOCAL_DECL     static\n#endif\n#if !defined(DUK_LOCAL)\n#define DUK_LOCAL          static\n#endif\n\n#if !defined(DUK_FILE_MACRO)\n#define DUK_FILE_MACRO  __FILE__\n#endif\n#if !defined(DUK_LINE_MACRO)\n#define DUK_LINE_MACRO  __LINE__\n#endif\n#if !defined(DUK_FUNC_MACRO)\n#if defined(DUK_F_C99) || defined(DUK_F_CPP11)\n#define DUK_FUNC_MACRO  __func__\n#elif defined(__FUNCTION__)\n#define DUK_FUNC_MACRO  __FUNCTION__\n#else\n#define DUK_FUNC_MACRO  \"unknown\"\n#endif\n#endif\n\n#if !defined(DUK_BSWAP32)\n#define DUK_BSWAP32(x) \\\n\t((((duk_uint32_t) (x)) >> 24) | \\\n\t ((((duk_uint32_t) (x)) >> 8) & 0xff00UL) | \\\n\t ((((duk_uint32_t) (x)) << 8) & 0xff0000UL) | \\\n\t (((duk_uint32_t) (x)) << 24))\n#endif\n#if !defined(DUK_BSWAP16)\n#define DUK_BSWAP16(x) \\\n\t((duk_uint16_t) (x) >> 8) | \\\n\t((duk_uint16_t) (x) << 8)\n#endif\n\n/* DUK_USE_VARIADIC_MACROS: required from compilers, so no fill-in. */\n/* DUK_USE_UNION_INITIALIZERS: required from compilers, so no fill-in. */\n\n#if !(defined(DUK_USE_FLEX_C99) || defined(DUK_USE_FLEX_ZEROSIZE) || defined(DUK_USE_FLEX_ONESIZE))\n#if defined(DUK_F_C99)\n#define DUK_USE_FLEX_C99\n#else\n#define DUK_USE_FLEX_ZEROSIZE  /* Not standard but common enough */\n#endif\n#endif\n\n#if !(defined(DUK_USE_PACK_GCC_ATTR) || defined(DUK_USE_PACK_CLANG_ATTR) || \\\n      defined(DUK_USE_PACK_MSVC_PRAGMA) || defined(DUK_USE_PACK_DUMMY_MEMBER))\n#define DUK_USE_PACK_DUMMY_MEMBER\n#endif\n\n#if 0  /* not defined by default */\n#undef DUK_USE_GCC_PRAGMAS\n#endif\n\n/* Workaround for GH-323: avoid inlining control when compiling from\n * multiple sources, as it causes compiler portability trouble.\n */\n#if !defined(DUK_SINGLE_FILE)\n#undef DUK_NOINLINE\n#undef DUK_INLINE\n#undef DUK_ALWAYS_INLINE\n#define DUK_NOINLINE       /*nop*/\n#define DUK_INLINE         /*nop*/\n#define DUK_ALWAYS_INLINE  /*nop*/\n#endif\n\n/*\n *  Check whether or not a packed duk_tval representation is possible.\n *  What's basically required is that pointers are 32-bit values\n *  (sizeof(void *) == 4).  Best effort check, not always accurate.\n *  If guess goes wrong, crashes may result; self tests also verify\n *  the guess.\n */\n\n/* Explicit marker needed; may be 'defined', 'undefined, 'or 'not provided'. */\n#if !defined(DUK_F_PACKED_TVAL_PROVIDED)\n#undef DUK_F_PACKED_TVAL_POSSIBLE\n\n/* Strict C99 case: DUK_UINTPTR_MAX (= UINTPTR_MAX) should be very reliable */\n#if !defined(DUK_F_PACKED_TVAL_POSSIBLE) && defined(DUK_UINTPTR_MAX)\n#if (DUK_UINTPTR_MAX <= 0xffffffffUL)\n#define DUK_F_PACKED_TVAL_POSSIBLE\n#endif\n#endif\n\n/* Non-C99 case, still relying on DUK_UINTPTR_MAX, as long as it is not a computed value */\n#if !defined(DUK_F_PACKED_TVAL_POSSIBLE) && defined(DUK_UINTPTR_MAX) && !defined(DUK_UINTPTR_MAX_COMPUTED)\n#if (DUK_UINTPTR_MAX <= 0xffffffffUL)\n#define DUK_F_PACKED_TVAL_POSSIBLE\n#endif\n#endif\n\n/* DUK_SIZE_MAX (= SIZE_MAX) is often reliable */\n#if !defined(DUK_F_PACKED_TVAL_POSSIBLE) && defined(DUK_SIZE_MAX) && !defined(DUK_SIZE_MAX_COMPUTED)\n#if (DUK_SIZE_MAX <= 0xffffffffUL)\n#define DUK_F_PACKED_TVAL_POSSIBLE\n#endif\n#endif\n\n#undef DUK_USE_PACKED_TVAL\n#if defined(DUK_F_PACKED_TVAL_POSSIBLE)\n#define DUK_USE_PACKED_TVAL\n#endif\n\n#undef DUK_F_PACKED_TVAL_POSSIBLE\n#endif  /* DUK_F_PACKED_TVAL_PROVIDED */\n/* Object property allocation layout has implications for memory and code\n * footprint and generated code size/speed.  The best layout also depends\n * on whether the platform has alignment requirements or benefits from\n * having mostly aligned accesses.\n */\n#undef DUK_USE_HOBJECT_LAYOUT_1\n#undef DUK_USE_HOBJECT_LAYOUT_2\n#undef DUK_USE_HOBJECT_LAYOUT_3\n#if (DUK_USE_ALIGN_BY == 1)\n/* On platforms without any alignment issues, layout 1 is preferable\n * because it compiles to slightly less code and provides direct access\n * to property keys.\n */\n#define DUK_USE_HOBJECT_LAYOUT_1\n#else\n/* On other platforms use layout 2, which requires some padding but\n * is a bit more natural than layout 3 in ordering the entries.  Layout\n * 3 is currently not used.\n */\n#define DUK_USE_HOBJECT_LAYOUT_2\n#endif\n\n/* GCC/clang inaccurate math would break compliance and probably duk_tval,\n * so refuse to compile.  Relax this if -ffast-math is tested to work.\n */\n#if defined(__FAST_MATH__)\n#error __FAST_MATH__ defined, refusing to compile\n#endif\n\n/*\n *  Autogenerated defaults\n */\n\n#define DUK_USE_ARRAY_BUILTIN\n#define DUK_USE_ARRAY_FASTPATH\n#define DUK_USE_ARRAY_PROP_FASTPATH\n#undef DUK_USE_ASSERTIONS\n#define DUK_USE_AUGMENT_ERROR_CREATE\n#define DUK_USE_AUGMENT_ERROR_THROW\n#define DUK_USE_AVOID_PLATFORM_FUNCPTRS\n#define DUK_USE_BASE64_FASTPATH\n#define DUK_USE_BOOLEAN_BUILTIN\n#define DUK_USE_BUFFEROBJECT_SUPPORT\n#undef DUK_USE_BUFLEN16\n#define DUK_USE_BYTECODE_DUMP_SUPPORT\n#define DUK_USE_COMMONJS_MODULES\n#define DUK_USE_COMPILER_RECLIMIT 2500\n#define DUK_USE_COROUTINE_SUPPORT\n#undef DUK_USE_CPP_EXCEPTIONS\n#undef DUK_USE_DATAPTR16\n#undef DUK_USE_DATAPTR_DEC16\n#undef DUK_USE_DATAPTR_ENC16\n#define DUK_USE_DATE_BUILTIN\n#undef DUK_USE_DATE_FORMAT_STRING\n#undef DUK_USE_DATE_GET_LOCAL_TZOFFSET\n#undef DUK_USE_DATE_GET_NOW\n#undef DUK_USE_DATE_PARSE_STRING\n#undef DUK_USE_DATE_PRS_GETDATE\n#undef DUK_USE_DEBUG\n#undef DUK_USE_DEBUGGER_DUMPHEAP\n#undef DUK_USE_DEBUGGER_INSPECT\n#undef DUK_USE_DEBUGGER_PAUSE_UNCAUGHT\n#undef DUK_USE_DEBUGGER_SUPPORT\n#define DUK_USE_DEBUGGER_THROW_NOTIFY\n#undef DUK_USE_DEBUGGER_TRANSPORT_TORTURE\n#define DUK_USE_DEBUG_BUFSIZE 65536L\n#define DUK_USE_DEBUG_LEVEL 0\n#undef DUK_USE_DEBUG_WRITE\n#define DUK_USE_DOUBLE_LINKED_HEAP\n#define DUK_USE_DUKTAPE_BUILTIN\n#define DUK_USE_ENCODING_BUILTINS\n#define DUK_USE_ERRCREATE\n#define DUK_USE_ERRTHROW\n#define DUK_USE_ES6\n#define DUK_USE_ES6_OBJECT_PROTO_PROPERTY\n#define DUK_USE_ES6_OBJECT_SETPROTOTYPEOF\n#define DUK_USE_ES6_PROXY\n#define DUK_USE_ES6_REGEXP_SYNTAX\n#define DUK_USE_ES6_UNICODE_ESCAPE\n#define DUK_USE_ES7_EXP_OPERATOR\n#define DUK_USE_ESBC_LIMITS\n#define DUK_USE_ESBC_MAX_BYTES 2147418112L\n#define DUK_USE_ESBC_MAX_LINENUMBER 2147418112L\n#undef DUK_USE_EXEC_FUN_LOCAL\n#undef DUK_USE_EXEC_INDIRECT_BOUND_CHECK\n#undef DUK_USE_EXEC_PREFER_SIZE\n#define DUK_USE_EXEC_REGCONST_OPTIMIZE\n#undef DUK_USE_EXEC_TIMEOUT_CHECK\n#undef DUK_USE_EXPLICIT_NULL_INIT\n#undef DUK_USE_EXTSTR_FREE\n#undef DUK_USE_EXTSTR_INTERN_CHECK\n#undef DUK_USE_FASTINT\n#define DUK_USE_FAST_REFCOUNT_DEFAULT\n#undef DUK_USE_FATAL_HANDLER\n#define DUK_USE_FINALIZER_SUPPORT\n#undef DUK_USE_FINALIZER_TORTURE\n#undef DUK_USE_FUNCPTR16\n#undef DUK_USE_FUNCPTR_DEC16\n#undef DUK_USE_FUNCPTR_ENC16\n#define DUK_USE_FUNCTION_BUILTIN\n#define DUK_USE_FUNC_FILENAME_PROPERTY\n#define DUK_USE_FUNC_NAME_PROPERTY\n#undef DUK_USE_GC_TORTURE\n#undef DUK_USE_GET_RANDOM_DOUBLE\n#undef DUK_USE_GLOBAL_BINDING\n#define DUK_USE_GLOBAL_BUILTIN\n#undef DUK_USE_HEAPPTR16\n#undef DUK_USE_HEAPPTR_DEC16\n#undef DUK_USE_HEAPPTR_ENC16\n#define DUK_USE_HEX_FASTPATH\n#define DUK_USE_HOBJECT_ARRAY_ABANDON_LIMIT 2\n#define DUK_USE_HOBJECT_ARRAY_FAST_RESIZE_LIMIT 9\n#define DUK_USE_HOBJECT_ARRAY_MINGROW_ADD 16\n#define DUK_USE_HOBJECT_ARRAY_MINGROW_DIVISOR 8\n#define DUK_USE_HOBJECT_ENTRY_MINGROW_ADD 16\n#define DUK_USE_HOBJECT_ENTRY_MINGROW_DIVISOR 8\n#define DUK_USE_HOBJECT_HASH_PART\n#define DUK_USE_HOBJECT_HASH_PROP_LIMIT 8\n#define DUK_USE_HSTRING_ARRIDX\n#define DUK_USE_HSTRING_CLEN\n#undef DUK_USE_HSTRING_EXTDATA\n#define DUK_USE_HTML_COMMENTS\n#define DUK_USE_IDCHAR_FASTPATH\n#undef DUK_USE_INJECT_HEAP_ALLOC_ERROR\n#undef DUK_USE_INTERRUPT_COUNTER\n#undef DUK_USE_INTERRUPT_DEBUG_FIXUP\n#define DUK_USE_JC\n#define DUK_USE_JSON_BUILTIN\n#define DUK_USE_JSON_DECNUMBER_FASTPATH\n#define DUK_USE_JSON_DECSTRING_FASTPATH\n#define DUK_USE_JSON_DEC_RECLIMIT 1000\n#define DUK_USE_JSON_EATWHITE_FASTPATH\n#define DUK_USE_JSON_ENC_RECLIMIT 1000\n#define DUK_USE_JSON_QUOTESTRING_FASTPATH\n#undef DUK_USE_JSON_STRINGIFY_FASTPATH\n#define DUK_USE_JSON_SUPPORT\n#define DUK_USE_JX\n#define DUK_USE_LEXER_SLIDING_WINDOW\n#undef DUK_USE_LIGHTFUNC_BUILTINS\n#define DUK_USE_MARK_AND_SWEEP_RECLIMIT 256\n#define DUK_USE_MATH_BUILTIN\n#define DUK_USE_NATIVE_CALL_RECLIMIT 1000\n#define DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER\n#define DUK_USE_NONSTD_ARRAY_MAP_TRAILER\n#define DUK_USE_NONSTD_ARRAY_SPLICE_DELCOUNT\n#undef DUK_USE_NONSTD_FUNC_CALLER_PROPERTY\n#undef DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY\n#define DUK_USE_NONSTD_FUNC_STMT\n#define DUK_USE_NONSTD_GETTER_KEY_ARGUMENT\n#define DUK_USE_NONSTD_JSON_ESC_U2028_U2029\n#define DUK_USE_NONSTD_SETTER_KEY_ARGUMENT\n#define DUK_USE_NONSTD_STRING_FROMCHARCODE_32BIT\n#define DUK_USE_NUMBER_BUILTIN\n#define DUK_USE_OBJECT_BUILTIN\n#undef DUK_USE_OBJSIZES16\n#undef DUK_USE_PARANOID_ERRORS\n#define DUK_USE_PC2LINE\n#undef DUK_USE_PREFER_SIZE\n#define DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS\n#undef DUK_USE_REFCOUNT16\n#define DUK_USE_REFCOUNT32\n#define DUK_USE_REFERENCE_COUNTING\n#define DUK_USE_REFLECT_BUILTIN\n#undef DUK_USE_REGEXP_CANON_WORKAROUND\n#define DUK_USE_REGEXP_COMPILER_RECLIMIT 10000\n#define DUK_USE_REGEXP_EXECUTOR_RECLIMIT 10000\n#define DUK_USE_REGEXP_SUPPORT\n#undef DUK_USE_ROM_GLOBAL_CLONE\n#undef DUK_USE_ROM_GLOBAL_INHERIT\n#undef DUK_USE_ROM_OBJECTS\n#define DUK_USE_ROM_PTRCOMP_FIRST 63488L\n#undef DUK_USE_ROM_STRINGS\n#define DUK_USE_SECTION_B\n#undef DUK_USE_SELF_TESTS\n#define DUK_USE_SHEBANG_COMMENTS\n#undef DUK_USE_SHUFFLE_TORTURE\n#define DUK_USE_SOURCE_NONBMP\n#undef DUK_USE_STRHASH16\n#undef DUK_USE_STRHASH_DENSE\n#define DUK_USE_STRHASH_SKIP_SHIFT 5\n#define DUK_USE_STRICT_DECL\n#undef DUK_USE_STRICT_UTF8_SOURCE\n#define DUK_USE_STRING_BUILTIN\n#undef DUK_USE_STRLEN16\n#define DUK_USE_STRTAB_GROW_LIMIT 17\n#define DUK_USE_STRTAB_MAXSIZE 268435456L\n#define DUK_USE_STRTAB_MINSIZE 1024\n#undef DUK_USE_STRTAB_PTRCOMP\n#define DUK_USE_STRTAB_RESIZE_CHECK_MASK 255\n#define DUK_USE_STRTAB_SHRINK_LIMIT 6\n#undef DUK_USE_STRTAB_TORTURE\n#undef DUK_USE_SYMBOL_BUILTIN\n#define DUK_USE_TAILCALL\n#define DUK_USE_TARGET_INFO \"unknown\"\n#define DUK_USE_TRACEBACKS\n#define DUK_USE_TRACEBACK_DEPTH 10\n#define DUK_USE_USER_DECLARE() /* no user declarations */\n#undef DUK_USE_VALSTACK_UNSAFE\n#define DUK_USE_VERBOSE_ERRORS\n#define DUK_USE_VERBOSE_EXECUTOR_ERRORS\n#define DUK_USE_VOLUNTARY_GC\n#define DUK_USE_ZERO_BUFFER_DATA\n\n/*\n *  You may add overriding #define/#undef directives below for\n *  customization.  You of course cannot un-#include or un-typedef\n *  anything; these require direct changes above.\n */\n\n/* __OVERRIDE_DEFINES__ */\n\n/*\n *  Date provider selection\n *\n *  User may define DUK_USE_DATE_GET_NOW() etc directly, in which case we'll\n *  rely on an external provider.  If this is not done, revert to previous\n *  behavior and use Unix/Windows built-in provider.\n */\n\n#if defined(DUK_COMPILING_DUKTAPE)\n\n#if defined(DUK_USE_DATE_GET_NOW)\n/* External provider already defined. */\n#elif defined(DUK_USE_DATE_NOW_GETTIMEOFDAY)\n#define DUK_USE_DATE_GET_NOW(ctx)            duk_bi_date_get_now_gettimeofday((ctx))\n#elif defined(DUK_USE_DATE_NOW_TIME)\n#define DUK_USE_DATE_GET_NOW(ctx)            duk_bi_date_get_now_time((ctx))\n#elif defined(DUK_USE_DATE_NOW_WINDOWS)\n#define DUK_USE_DATE_GET_NOW(ctx)            duk_bi_date_get_now_windows((ctx))\n#else\n#error no provider for DUK_USE_DATE_GET_NOW()\n#endif\n\n#if defined(DUK_USE_DATE_GET_LOCAL_TZOFFSET)\n/* External provider already defined. */\n#elif defined(DUK_USE_DATE_TZO_GMTIME_R) || defined(DUK_USE_DATE_TZO_GMTIME_S) || defined(DUK_USE_DATE_TZO_GMTIME)\n#define DUK_USE_DATE_GET_LOCAL_TZOFFSET(d)   duk_bi_date_get_local_tzoffset_gmtime((d))\n#elif defined(DUK_USE_DATE_TZO_WINDOWS)\n#define DUK_USE_DATE_GET_LOCAL_TZOFFSET(d)   duk_bi_date_get_local_tzoffset_windows((d))\n#elif defined(DUK_USE_DATE_TZO_WINDOWS_NO_DST)\n#define DUK_USE_DATE_GET_LOCAL_TZOFFSET(d)   duk_bi_date_get_local_tzoffset_windows_no_dst((d))\n#else\n#error no provider for DUK_USE_DATE_GET_LOCAL_TZOFFSET()\n#endif\n\n#if defined(DUK_USE_DATE_PARSE_STRING)\n/* External provider already defined. */\n#elif defined(DUK_USE_DATE_PRS_STRPTIME)\n#define DUK_USE_DATE_PARSE_STRING(ctx,str)   duk_bi_date_parse_string_strptime((ctx), (str))\n#elif defined(DUK_USE_DATE_PRS_GETDATE)\n#define DUK_USE_DATE_PARSE_STRING(ctx,str)   duk_bi_date_parse_string_getdate((ctx), (str))\n#else\n/* No provider for DUK_USE_DATE_PARSE_STRING(), fall back to ISO 8601 only. */\n#endif\n\n#if defined(DUK_USE_DATE_FORMAT_STRING)\n/* External provider already defined. */\n#elif defined(DUK_USE_DATE_FMT_STRFTIME)\n#define DUK_USE_DATE_FORMAT_STRING(ctx,parts,tzoffset,flags) \\\n\tduk_bi_date_format_parts_strftime((ctx), (parts), (tzoffset), (flags))\n#else\n/* No provider for DUK_USE_DATE_FORMAT_STRING(), fall back to ISO 8601 only. */\n#endif\n\n#endif  /* DUK_COMPILING_DUKTAPE */\n\n/*\n *  Checks for legacy feature options (DUK_OPT_xxx)\n */\n\n#if defined(DUK_OPT_ASSERTIONS)\n#error unsupported legacy feature option DUK_OPT_ASSERTIONS used\n#endif\n#if defined(DUK_OPT_BUFFEROBJECT_SUPPORT)\n#error unsupported legacy feature option DUK_OPT_BUFFEROBJECT_SUPPORT used\n#endif\n#if defined(DUK_OPT_BUFLEN16)\n#error unsupported legacy feature option DUK_OPT_BUFLEN16 used\n#endif\n#if defined(DUK_OPT_DATAPTR16)\n#error unsupported legacy feature option DUK_OPT_DATAPTR16 used\n#endif\n#if defined(DUK_OPT_DATAPTR_DEC16)\n#error unsupported legacy feature option DUK_OPT_DATAPTR_DEC16 used\n#endif\n#if defined(DUK_OPT_DATAPTR_ENC16)\n#error unsupported legacy feature option DUK_OPT_DATAPTR_ENC16 used\n#endif\n#if defined(DUK_OPT_DDDPRINT)\n#error unsupported legacy feature option DUK_OPT_DDDPRINT used\n#endif\n#if defined(DUK_OPT_DDPRINT)\n#error unsupported legacy feature option DUK_OPT_DDPRINT used\n#endif\n#if defined(DUK_OPT_DEBUG)\n#error unsupported legacy feature option DUK_OPT_DEBUG used\n#endif\n#if defined(DUK_OPT_DEBUGGER_DUMPHEAP)\n#error unsupported legacy feature option DUK_OPT_DEBUGGER_DUMPHEAP used\n#endif\n#if defined(DUK_OPT_DEBUGGER_FWD_LOGGING)\n#error unsupported legacy feature option DUK_OPT_DEBUGGER_FWD_LOGGING used\n#endif\n#if defined(DUK_OPT_DEBUGGER_FWD_PRINTALERT)\n#error unsupported legacy feature option DUK_OPT_DEBUGGER_FWD_PRINTALERT used\n#endif\n#if defined(DUK_OPT_DEBUGGER_SUPPORT)\n#error unsupported legacy feature option DUK_OPT_DEBUGGER_SUPPORT used\n#endif\n#if defined(DUK_OPT_DEBUGGER_TRANSPORT_TORTURE)\n#error unsupported legacy feature option DUK_OPT_DEBUGGER_TRANSPORT_TORTURE used\n#endif\n#if defined(DUK_OPT_DEBUG_BUFSIZE)\n#error unsupported legacy feature option DUK_OPT_DEBUG_BUFSIZE used\n#endif\n#if defined(DUK_OPT_DECLARE)\n#error unsupported legacy feature option DUK_OPT_DECLARE used\n#endif\n#if defined(DUK_OPT_DEEP_C_STACK)\n#error unsupported legacy feature option DUK_OPT_DEEP_C_STACK used\n#endif\n#if defined(DUK_OPT_DLL_BUILD)\n#error unsupported legacy feature option DUK_OPT_DLL_BUILD used\n#endif\n#if defined(DUK_OPT_DPRINT)\n#error unsupported legacy feature option DUK_OPT_DPRINT used\n#endif\n#if defined(DUK_OPT_DPRINT_COLORS)\n#error unsupported legacy feature option DUK_OPT_DPRINT_COLORS used\n#endif\n#if defined(DUK_OPT_DPRINT_RDTSC)\n#error unsupported legacy feature option DUK_OPT_DPRINT_RDTSC used\n#endif\n#if defined(DUK_OPT_EXEC_TIMEOUT_CHECK)\n#error unsupported legacy feature option DUK_OPT_EXEC_TIMEOUT_CHECK used\n#endif\n#if defined(DUK_OPT_EXTERNAL_STRINGS)\n#error unsupported legacy feature option DUK_OPT_EXTERNAL_STRINGS used\n#endif\n#if defined(DUK_OPT_EXTSTR_FREE)\n#error unsupported legacy feature option DUK_OPT_EXTSTR_FREE used\n#endif\n#if defined(DUK_OPT_EXTSTR_INTERN_CHECK)\n#error unsupported legacy feature option DUK_OPT_EXTSTR_INTERN_CHECK used\n#endif\n#if defined(DUK_OPT_FASTINT)\n#error unsupported legacy feature option DUK_OPT_FASTINT used\n#endif\n#if defined(DUK_OPT_FORCE_ALIGN)\n#error unsupported legacy feature option DUK_OPT_FORCE_ALIGN used\n#endif\n#if defined(DUK_OPT_FORCE_BYTEORDER)\n#error unsupported legacy feature option DUK_OPT_FORCE_BYTEORDER used\n#endif\n#if defined(DUK_OPT_FUNCPTR16)\n#error unsupported legacy feature option DUK_OPT_FUNCPTR16 used\n#endif\n#if defined(DUK_OPT_FUNCPTR_DEC16)\n#error unsupported legacy feature option DUK_OPT_FUNCPTR_DEC16 used\n#endif\n#if defined(DUK_OPT_FUNCPTR_ENC16)\n#error unsupported legacy feature option DUK_OPT_FUNCPTR_ENC16 used\n#endif\n#if defined(DUK_OPT_FUNC_NONSTD_CALLER_PROPERTY)\n#error unsupported legacy feature option DUK_OPT_FUNC_NONSTD_CALLER_PROPERTY used\n#endif\n#if defined(DUK_OPT_FUNC_NONSTD_SOURCE_PROPERTY)\n#error unsupported legacy feature option DUK_OPT_FUNC_NONSTD_SOURCE_PROPERTY used\n#endif\n#if defined(DUK_OPT_GC_TORTURE)\n#error unsupported legacy feature option DUK_OPT_GC_TORTURE used\n#endif\n#if defined(DUK_OPT_HAVE_CUSTOM_H)\n#error unsupported legacy feature option DUK_OPT_HAVE_CUSTOM_H used\n#endif\n#if defined(DUK_OPT_HEAPPTR16)\n#error unsupported legacy feature option DUK_OPT_HEAPPTR16 used\n#endif\n#if defined(DUK_OPT_HEAPPTR_DEC16)\n#error unsupported legacy feature option DUK_OPT_HEAPPTR_DEC16 used\n#endif\n#if defined(DUK_OPT_HEAPPTR_ENC16)\n#error unsupported legacy feature option DUK_OPT_HEAPPTR_ENC16 used\n#endif\n#if defined(DUK_OPT_INTERRUPT_COUNTER)\n#error unsupported legacy feature option DUK_OPT_INTERRUPT_COUNTER used\n#endif\n#if defined(DUK_OPT_JSON_STRINGIFY_FASTPATH)\n#error unsupported legacy feature option DUK_OPT_JSON_STRINGIFY_FASTPATH used\n#endif\n#if defined(DUK_OPT_LIGHTFUNC_BUILTINS)\n#error unsupported legacy feature option DUK_OPT_LIGHTFUNC_BUILTINS used\n#endif\n#if defined(DUK_OPT_NONSTD_FUNC_CALLER_PROPERTY)\n#error unsupported legacy feature option DUK_OPT_NONSTD_FUNC_CALLER_PROPERTY used\n#endif\n#if defined(DUK_OPT_NONSTD_FUNC_SOURCE_PROPERTY)\n#error unsupported legacy feature option DUK_OPT_NONSTD_FUNC_SOURCE_PROPERTY used\n#endif\n#if defined(DUK_OPT_NO_ARRAY_SPLICE_NONSTD_DELCOUNT)\n#error unsupported legacy feature option DUK_OPT_NO_ARRAY_SPLICE_NONSTD_DELCOUNT used\n#endif\n#if defined(DUK_OPT_NO_AUGMENT_ERRORS)\n#error unsupported legacy feature option DUK_OPT_NO_AUGMENT_ERRORS used\n#endif\n#if defined(DUK_OPT_NO_BROWSER_LIKE)\n#error unsupported legacy feature option DUK_OPT_NO_BROWSER_LIKE used\n#endif\n#if defined(DUK_OPT_NO_BUFFEROBJECT_SUPPORT)\n#error unsupported legacy feature option DUK_OPT_NO_BUFFEROBJECT_SUPPORT used\n#endif\n#if defined(DUK_OPT_NO_BYTECODE_DUMP_SUPPORT)\n#error unsupported legacy feature option DUK_OPT_NO_BYTECODE_DUMP_SUPPORT used\n#endif\n#if defined(DUK_OPT_NO_COMMONJS_MODULES)\n#error unsupported legacy feature option DUK_OPT_NO_COMMONJS_MODULES used\n#endif\n#if defined(DUK_OPT_NO_ES6_OBJECT_PROTO_PROPERTY)\n#error unsupported legacy feature option DUK_OPT_NO_ES6_OBJECT_PROTO_PROPERTY used\n#endif\n#if defined(DUK_OPT_NO_ES6_OBJECT_SETPROTOTYPEOF)\n#error unsupported legacy feature option DUK_OPT_NO_ES6_OBJECT_SETPROTOTYPEOF used\n#endif\n#if defined(DUK_OPT_NO_ES6_PROXY)\n#error unsupported legacy feature option DUK_OPT_NO_ES6_PROXY used\n#endif\n#if defined(DUK_OPT_NO_FILE_IO)\n#error unsupported legacy feature option DUK_OPT_NO_FILE_IO used\n#endif\n#if defined(DUK_OPT_NO_FUNC_STMT)\n#error unsupported legacy feature option DUK_OPT_NO_FUNC_STMT used\n#endif\n#if defined(DUK_OPT_NO_JC)\n#error unsupported legacy feature option DUK_OPT_NO_JC used\n#endif\n#if defined(DUK_OPT_NO_JSONC)\n#error unsupported legacy feature option DUK_OPT_NO_JSONC used\n#endif\n#if defined(DUK_OPT_NO_JSONX)\n#error unsupported legacy feature option DUK_OPT_NO_JSONX used\n#endif\n#if defined(DUK_OPT_NO_JX)\n#error unsupported legacy feature option DUK_OPT_NO_JX used\n#endif\n#if defined(DUK_OPT_NO_MARK_AND_SWEEP)\n#error unsupported legacy feature option DUK_OPT_NO_MARK_AND_SWEEP used\n#endif\n#if defined(DUK_OPT_NO_MS_STRINGTABLE_RESIZE)\n#error unsupported legacy feature option DUK_OPT_NO_MS_STRINGTABLE_RESIZE used\n#endif\n#if defined(DUK_OPT_NO_NONSTD_ACCESSOR_KEY_ARGUMENT)\n#error unsupported legacy feature option DUK_OPT_NO_NONSTD_ACCESSOR_KEY_ARGUMENT used\n#endif\n#if defined(DUK_OPT_NO_NONSTD_ARRAY_CONCAT_TRAILER)\n#error unsupported legacy feature option DUK_OPT_NO_NONSTD_ARRAY_CONCAT_TRAILER used\n#endif\n#if defined(DUK_OPT_NO_NONSTD_ARRAY_MAP_TRAILER)\n#error unsupported legacy feature option DUK_OPT_NO_NONSTD_ARRAY_MAP_TRAILER used\n#endif\n#if defined(DUK_OPT_NO_NONSTD_ARRAY_SPLICE_DELCOUNT)\n#error unsupported legacy feature option DUK_OPT_NO_NONSTD_ARRAY_SPLICE_DELCOUNT used\n#endif\n#if defined(DUK_OPT_NO_NONSTD_FUNC_STMT)\n#error unsupported legacy feature option DUK_OPT_NO_NONSTD_FUNC_STMT used\n#endif\n#if defined(DUK_OPT_NO_NONSTD_JSON_ESC_U2028_U2029)\n#error unsupported legacy feature option DUK_OPT_NO_NONSTD_JSON_ESC_U2028_U2029 used\n#endif\n#if defined(DUK_OPT_NO_NONSTD_STRING_FROMCHARCODE_32BIT)\n#error unsupported legacy feature option DUK_OPT_NO_NONSTD_STRING_FROMCHARCODE_32BIT used\n#endif\n#if defined(DUK_OPT_NO_OBJECT_ES6_PROTO_PROPERTY)\n#error unsupported legacy feature option DUK_OPT_NO_OBJECT_ES6_PROTO_PROPERTY used\n#endif\n#if defined(DUK_OPT_NO_OBJECT_ES6_SETPROTOTYPEOF)\n#error unsupported legacy feature option DUK_OPT_NO_OBJECT_ES6_SETPROTOTYPEOF used\n#endif\n#if defined(DUK_OPT_NO_OCTAL_SUPPORT)\n#error unsupported legacy feature option DUK_OPT_NO_OCTAL_SUPPORT used\n#endif\n#if defined(DUK_OPT_NO_PACKED_TVAL)\n#error unsupported legacy feature option DUK_OPT_NO_PACKED_TVAL used\n#endif\n#if defined(DUK_OPT_NO_PC2LINE)\n#error unsupported legacy feature option DUK_OPT_NO_PC2LINE used\n#endif\n#if defined(DUK_OPT_NO_REFERENCE_COUNTING)\n#error unsupported legacy feature option DUK_OPT_NO_REFERENCE_COUNTING used\n#endif\n#if defined(DUK_OPT_NO_REGEXP_SUPPORT)\n#error unsupported legacy feature option DUK_OPT_NO_REGEXP_SUPPORT used\n#endif\n#if defined(DUK_OPT_NO_SECTION_B)\n#error unsupported legacy feature option DUK_OPT_NO_SECTION_B used\n#endif\n#if defined(DUK_OPT_NO_SOURCE_NONBMP)\n#error unsupported legacy feature option DUK_OPT_NO_SOURCE_NONBMP used\n#endif\n#if defined(DUK_OPT_NO_STRICT_DECL)\n#error unsupported legacy feature option DUK_OPT_NO_STRICT_DECL used\n#endif\n#if defined(DUK_OPT_NO_TRACEBACKS)\n#error unsupported legacy feature option DUK_OPT_NO_TRACEBACKS used\n#endif\n#if defined(DUK_OPT_NO_VERBOSE_ERRORS)\n#error unsupported legacy feature option DUK_OPT_NO_VERBOSE_ERRORS used\n#endif\n#if defined(DUK_OPT_NO_VOLUNTARY_GC)\n#error unsupported legacy feature option DUK_OPT_NO_VOLUNTARY_GC used\n#endif\n#if defined(DUK_OPT_NO_ZERO_BUFFER_DATA)\n#error unsupported legacy feature option DUK_OPT_NO_ZERO_BUFFER_DATA used\n#endif\n#if defined(DUK_OPT_OBJSIZES16)\n#error unsupported legacy feature option DUK_OPT_OBJSIZES16 used\n#endif\n#if defined(DUK_OPT_PANIC_HANDLER)\n#error unsupported legacy feature option DUK_OPT_PANIC_HANDLER used\n#endif\n#if defined(DUK_OPT_REFCOUNT16)\n#error unsupported legacy feature option DUK_OPT_REFCOUNT16 used\n#endif\n#if defined(DUK_OPT_SEGFAULT_ON_PANIC)\n#error unsupported legacy feature option DUK_OPT_SEGFAULT_ON_PANIC used\n#endif\n#if defined(DUK_OPT_SELF_TESTS)\n#error unsupported legacy feature option DUK_OPT_SELF_TESTS used\n#endif\n#if defined(DUK_OPT_SETJMP)\n#error unsupported legacy feature option DUK_OPT_SETJMP used\n#endif\n#if defined(DUK_OPT_SHUFFLE_TORTURE)\n#error unsupported legacy feature option DUK_OPT_SHUFFLE_TORTURE used\n#endif\n#if defined(DUK_OPT_SIGSETJMP)\n#error unsupported legacy feature option DUK_OPT_SIGSETJMP used\n#endif\n#if defined(DUK_OPT_STRHASH16)\n#error unsupported legacy feature option DUK_OPT_STRHASH16 used\n#endif\n#if defined(DUK_OPT_STRICT_UTF8_SOURCE)\n#error unsupported legacy feature option DUK_OPT_STRICT_UTF8_SOURCE used\n#endif\n#if defined(DUK_OPT_STRLEN16)\n#error unsupported legacy feature option DUK_OPT_STRLEN16 used\n#endif\n#if defined(DUK_OPT_STRTAB_CHAIN)\n#error unsupported legacy feature option DUK_OPT_STRTAB_CHAIN used\n#endif\n#if defined(DUK_OPT_STRTAB_CHAIN_SIZE)\n#error unsupported legacy feature option DUK_OPT_STRTAB_CHAIN_SIZE used\n#endif\n#if defined(DUK_OPT_TARGET_INFO)\n#error unsupported legacy feature option DUK_OPT_TARGET_INFO used\n#endif\n#if defined(DUK_OPT_TRACEBACK_DEPTH)\n#error unsupported legacy feature option DUK_OPT_TRACEBACK_DEPTH used\n#endif\n#if defined(DUK_OPT_UNDERSCORE_SETJMP)\n#error unsupported legacy feature option DUK_OPT_UNDERSCORE_SETJMP used\n#endif\n#if defined(DUK_OPT_USER_INITJS)\n#error unsupported legacy feature option DUK_OPT_USER_INITJS used\n#endif\n\n/*\n *  Checks for config option consistency (DUK_USE_xxx)\n */\n\n#if defined(DUK_USE_32BIT_PTRS)\n#error unsupported config option used (option has been removed): DUK_USE_32BIT_PTRS\n#endif\n#if defined(DUK_USE_ALIGN_4)\n#error unsupported config option used (option has been removed): DUK_USE_ALIGN_4\n#endif\n#if defined(DUK_USE_ALIGN_8)\n#error unsupported config option used (option has been removed): DUK_USE_ALIGN_8\n#endif\n#if defined(DUK_USE_BROWSER_LIKE)\n#error unsupported config option used (option has been removed): DUK_USE_BROWSER_LIKE\n#endif\n#if defined(DUK_USE_BUILTIN_INITJS)\n#error unsupported config option used (option has been removed): DUK_USE_BUILTIN_INITJS\n#endif\n#if defined(DUK_USE_BYTEORDER_FORCED)\n#error unsupported config option used (option has been removed): DUK_USE_BYTEORDER_FORCED\n#endif\n#if defined(DUK_USE_DATAPTR_DEC16) && !defined(DUK_USE_DATAPTR16)\n#error config option DUK_USE_DATAPTR_DEC16 requires option DUK_USE_DATAPTR16 (which is missing)\n#endif\n#if defined(DUK_USE_DATAPTR_ENC16) && !defined(DUK_USE_DATAPTR16)\n#error config option DUK_USE_DATAPTR_ENC16 requires option DUK_USE_DATAPTR16 (which is missing)\n#endif\n#if defined(DUK_USE_DDDPRINT)\n#error unsupported config option used (option has been removed): DUK_USE_DDDPRINT\n#endif\n#if defined(DUK_USE_DDPRINT)\n#error unsupported config option used (option has been removed): DUK_USE_DDPRINT\n#endif\n#if defined(DUK_USE_DEBUGGER_FWD_LOGGING)\n#error unsupported config option used (option has been removed): DUK_USE_DEBUGGER_FWD_LOGGING\n#endif\n#if defined(DUK_USE_DEBUGGER_FWD_PRINTALERT)\n#error unsupported config option used (option has been removed): DUK_USE_DEBUGGER_FWD_PRINTALERT\n#endif\n#if defined(DUK_USE_DEBUGGER_SUPPORT) && !defined(DUK_USE_INTERRUPT_COUNTER)\n#error config option DUK_USE_DEBUGGER_SUPPORT requires option DUK_USE_INTERRUPT_COUNTER (which is missing)\n#endif\n#if defined(DUK_USE_DEEP_C_STACK)\n#error unsupported config option used (option has been removed): DUK_USE_DEEP_C_STACK\n#endif\n#if defined(DUK_USE_DOUBLE_BE)\n#error unsupported config option used (option has been removed): DUK_USE_DOUBLE_BE\n#endif\n#if defined(DUK_USE_DOUBLE_BE) && defined(DUK_USE_DOUBLE_LE)\n#error config option DUK_USE_DOUBLE_BE conflicts with option DUK_USE_DOUBLE_LE (which is also defined)\n#endif\n#if defined(DUK_USE_DOUBLE_BE) && defined(DUK_USE_DOUBLE_ME)\n#error config option DUK_USE_DOUBLE_BE conflicts with option DUK_USE_DOUBLE_ME (which is also defined)\n#endif\n#if defined(DUK_USE_DOUBLE_LE)\n#error unsupported config option used (option has been removed): DUK_USE_DOUBLE_LE\n#endif\n#if defined(DUK_USE_DOUBLE_LE) && defined(DUK_USE_DOUBLE_BE)\n#error config option DUK_USE_DOUBLE_LE conflicts with option DUK_USE_DOUBLE_BE (which is also defined)\n#endif\n#if defined(DUK_USE_DOUBLE_LE) && defined(DUK_USE_DOUBLE_ME)\n#error config option DUK_USE_DOUBLE_LE conflicts with option DUK_USE_DOUBLE_ME (which is also defined)\n#endif\n#if defined(DUK_USE_DOUBLE_ME)\n#error unsupported config option used (option has been removed): DUK_USE_DOUBLE_ME\n#endif\n#if defined(DUK_USE_DOUBLE_ME) && defined(DUK_USE_DOUBLE_LE)\n#error config option DUK_USE_DOUBLE_ME conflicts with option DUK_USE_DOUBLE_LE (which is also defined)\n#endif\n#if defined(DUK_USE_DOUBLE_ME) && defined(DUK_USE_DOUBLE_BE)\n#error config option DUK_USE_DOUBLE_ME conflicts with option DUK_USE_DOUBLE_BE (which is also defined)\n#endif\n#if defined(DUK_USE_DPRINT)\n#error unsupported config option used (option has been removed): DUK_USE_DPRINT\n#endif\n#if defined(DUK_USE_DPRINT) && !defined(DUK_USE_DEBUG)\n#error config option DUK_USE_DPRINT requires option DUK_USE_DEBUG (which is missing)\n#endif\n#if defined(DUK_USE_DPRINT_COLORS)\n#error unsupported config option used (option has been removed): DUK_USE_DPRINT_COLORS\n#endif\n#if defined(DUK_USE_DPRINT_RDTSC)\n#error unsupported config option used (option has been removed): DUK_USE_DPRINT_RDTSC\n#endif\n#if defined(DUK_USE_ES6_REGEXP_BRACES)\n#error unsupported config option used (option has been removed): DUK_USE_ES6_REGEXP_BRACES\n#endif\n#if defined(DUK_USE_ESBC_MAX_BYTES) && !defined(DUK_USE_ESBC_LIMITS)\n#error config option DUK_USE_ESBC_MAX_BYTES requires option DUK_USE_ESBC_LIMITS (which is missing)\n#endif\n#if defined(DUK_USE_ESBC_MAX_LINENUMBER) && !defined(DUK_USE_ESBC_LIMITS)\n#error config option DUK_USE_ESBC_MAX_LINENUMBER requires option DUK_USE_ESBC_LIMITS (which is missing)\n#endif\n#if defined(DUK_USE_EXEC_TIMEOUT_CHECK) && !defined(DUK_USE_INTERRUPT_COUNTER)\n#error config option DUK_USE_EXEC_TIMEOUT_CHECK requires option DUK_USE_INTERRUPT_COUNTER (which is missing)\n#endif\n#if defined(DUK_USE_EXTSTR_FREE) && !defined(DUK_USE_HSTRING_EXTDATA)\n#error config option DUK_USE_EXTSTR_FREE requires option DUK_USE_HSTRING_EXTDATA (which is missing)\n#endif\n#if defined(DUK_USE_EXTSTR_INTERN_CHECK) && !defined(DUK_USE_HSTRING_EXTDATA)\n#error config option DUK_USE_EXTSTR_INTERN_CHECK requires option DUK_USE_HSTRING_EXTDATA (which is missing)\n#endif\n#if defined(DUK_USE_FASTINT) && !defined(DUK_USE_64BIT_OPS)\n#error config option DUK_USE_FASTINT requires option DUK_USE_64BIT_OPS (which is missing)\n#endif\n#if defined(DUK_USE_FILE_IO)\n#error unsupported config option used (option has been removed): DUK_USE_FILE_IO\n#endif\n#if defined(DUK_USE_FULL_TVAL)\n#error unsupported config option used (option has been removed): DUK_USE_FULL_TVAL\n#endif\n#if defined(DUK_USE_FUNCPTR_DEC16) && !defined(DUK_USE_FUNCPTR16)\n#error config option DUK_USE_FUNCPTR_DEC16 requires option DUK_USE_FUNCPTR16 (which is missing)\n#endif\n#if defined(DUK_USE_FUNCPTR_ENC16) && !defined(DUK_USE_FUNCPTR16)\n#error config option DUK_USE_FUNCPTR_ENC16 requires option DUK_USE_FUNCPTR16 (which is missing)\n#endif\n#if defined(DUK_USE_HASHBYTES_UNALIGNED_U32_ACCESS)\n#error unsupported config option used (option has been removed): DUK_USE_HASHBYTES_UNALIGNED_U32_ACCESS\n#endif\n#if defined(DUK_USE_HEAPPTR16) && defined(DUK_USE_DEBUG)\n#error config option DUK_USE_HEAPPTR16 conflicts with option DUK_USE_DEBUG (which is also defined)\n#endif\n#if defined(DUK_USE_HEAPPTR_DEC16) && !defined(DUK_USE_HEAPPTR16)\n#error config option DUK_USE_HEAPPTR_DEC16 requires option DUK_USE_HEAPPTR16 (which is missing)\n#endif\n#if defined(DUK_USE_HEAPPTR_ENC16) && !defined(DUK_USE_HEAPPTR16)\n#error config option DUK_USE_HEAPPTR_ENC16 requires option DUK_USE_HEAPPTR16 (which is missing)\n#endif\n#if defined(DUK_USE_INTEGER_BE)\n#error unsupported config option used (option has been removed): DUK_USE_INTEGER_BE\n#endif\n#if defined(DUK_USE_INTEGER_BE) && defined(DUK_USE_INTEGER_LE)\n#error config option DUK_USE_INTEGER_BE conflicts with option DUK_USE_INTEGER_LE (which is also defined)\n#endif\n#if defined(DUK_USE_INTEGER_BE) && defined(DUK_USE_INTEGER_ME)\n#error config option DUK_USE_INTEGER_BE conflicts with option DUK_USE_INTEGER_ME (which is also defined)\n#endif\n#if defined(DUK_USE_INTEGER_LE)\n#error unsupported config option used (option has been removed): DUK_USE_INTEGER_LE\n#endif\n#if defined(DUK_USE_INTEGER_LE) && defined(DUK_USE_INTEGER_BE)\n#error config option DUK_USE_INTEGER_LE conflicts with option DUK_USE_INTEGER_BE (which is also defined)\n#endif\n#if defined(DUK_USE_INTEGER_LE) && defined(DUK_USE_INTEGER_ME)\n#error config option DUK_USE_INTEGER_LE conflicts with option DUK_USE_INTEGER_ME (which is also defined)\n#endif\n#if defined(DUK_USE_INTEGER_ME)\n#error unsupported config option used (option has been removed): DUK_USE_INTEGER_ME\n#endif\n#if defined(DUK_USE_INTEGER_ME) && defined(DUK_USE_INTEGER_LE)\n#error config option DUK_USE_INTEGER_ME conflicts with option DUK_USE_INTEGER_LE (which is also defined)\n#endif\n#if defined(DUK_USE_INTEGER_ME) && defined(DUK_USE_INTEGER_BE)\n#error config option DUK_USE_INTEGER_ME conflicts with option DUK_USE_INTEGER_BE (which is also defined)\n#endif\n#if defined(DUK_USE_MARKANDSWEEP_FINALIZER_TORTURE)\n#error unsupported config option used (option has been removed): DUK_USE_MARKANDSWEEP_FINALIZER_TORTURE\n#endif\n#if defined(DUK_USE_MARK_AND_SWEEP)\n#error unsupported config option used (option has been removed): DUK_USE_MARK_AND_SWEEP\n#endif\n#if defined(DUK_USE_MATH_FMAX)\n#error unsupported config option used (option has been removed): DUK_USE_MATH_FMAX\n#endif\n#if defined(DUK_USE_MATH_FMIN)\n#error unsupported config option used (option has been removed): DUK_USE_MATH_FMIN\n#endif\n#if defined(DUK_USE_MATH_ROUND)\n#error unsupported config option used (option has been removed): DUK_USE_MATH_ROUND\n#endif\n#if defined(DUK_USE_MS_STRINGTABLE_RESIZE)\n#error unsupported config option used (option has been removed): DUK_USE_MS_STRINGTABLE_RESIZE\n#endif\n#if defined(DUK_USE_NONSTD_REGEXP_DOLLAR_ESCAPE)\n#error unsupported config option used (option has been removed): DUK_USE_NONSTD_REGEXP_DOLLAR_ESCAPE\n#endif\n#if defined(DUK_USE_NO_DOUBLE_ALIASING_SELFTEST)\n#error unsupported config option used (option has been removed): DUK_USE_NO_DOUBLE_ALIASING_SELFTEST\n#endif\n#if defined(DUK_USE_OCTAL_SUPPORT)\n#error unsupported config option used (option has been removed): DUK_USE_OCTAL_SUPPORT\n#endif\n#if defined(DUK_USE_PACKED_TVAL_POSSIBLE)\n#error unsupported config option used (option has been removed): DUK_USE_PACKED_TVAL_POSSIBLE\n#endif\n#if defined(DUK_USE_PANIC_ABORT)\n#error unsupported config option used (option has been removed): DUK_USE_PANIC_ABORT\n#endif\n#if defined(DUK_USE_PANIC_EXIT)\n#error unsupported config option used (option has been removed): DUK_USE_PANIC_EXIT\n#endif\n#if defined(DUK_USE_PANIC_HANDLER)\n#error unsupported config option used (option has been removed): DUK_USE_PANIC_HANDLER\n#endif\n#if defined(DUK_USE_PANIC_SEGFAULT)\n#error unsupported config option used (option has been removed): DUK_USE_PANIC_SEGFAULT\n#endif\n#if defined(DUK_USE_POW_NETBSD_WORKAROUND)\n#error unsupported config option used (option has been removed): DUK_USE_POW_NETBSD_WORKAROUND\n#endif\n#if defined(DUK_USE_RDTSC)\n#error unsupported config option used (option has been removed): DUK_USE_RDTSC\n#endif\n#if defined(DUK_USE_REFZERO_FINALIZER_TORTURE)\n#error unsupported config option used (option has been removed): DUK_USE_REFZERO_FINALIZER_TORTURE\n#endif\n#if defined(DUK_USE_ROM_GLOBAL_CLONE) && !defined(DUK_USE_ROM_STRINGS)\n#error config option DUK_USE_ROM_GLOBAL_CLONE requires option DUK_USE_ROM_STRINGS (which is missing)\n#endif\n#if defined(DUK_USE_ROM_GLOBAL_CLONE) && !defined(DUK_USE_ROM_OBJECTS)\n#error config option DUK_USE_ROM_GLOBAL_CLONE requires option DUK_USE_ROM_OBJECTS (which is missing)\n#endif\n#if defined(DUK_USE_ROM_GLOBAL_CLONE) && defined(DUK_USE_ROM_GLOBAL_INHERIT)\n#error config option DUK_USE_ROM_GLOBAL_CLONE conflicts with option DUK_USE_ROM_GLOBAL_INHERIT (which is also defined)\n#endif\n#if defined(DUK_USE_ROM_GLOBAL_INHERIT) && !defined(DUK_USE_ROM_STRINGS)\n#error config option DUK_USE_ROM_GLOBAL_INHERIT requires option DUK_USE_ROM_STRINGS (which is missing)\n#endif\n#if defined(DUK_USE_ROM_GLOBAL_INHERIT) && !defined(DUK_USE_ROM_OBJECTS)\n#error config option DUK_USE_ROM_GLOBAL_INHERIT requires option DUK_USE_ROM_OBJECTS (which is missing)\n#endif\n#if defined(DUK_USE_ROM_GLOBAL_INHERIT) && defined(DUK_USE_ROM_GLOBAL_CLONE)\n#error config option DUK_USE_ROM_GLOBAL_INHERIT conflicts with option DUK_USE_ROM_GLOBAL_CLONE (which is also defined)\n#endif\n#if defined(DUK_USE_ROM_OBJECTS) && !defined(DUK_USE_ROM_STRINGS)\n#error config option DUK_USE_ROM_OBJECTS requires option DUK_USE_ROM_STRINGS (which is missing)\n#endif\n#if defined(DUK_USE_ROM_STRINGS) && !defined(DUK_USE_ROM_OBJECTS)\n#error config option DUK_USE_ROM_STRINGS requires option DUK_USE_ROM_OBJECTS (which is missing)\n#endif\n#if defined(DUK_USE_SETJMP)\n#error unsupported config option used (option has been removed): DUK_USE_SETJMP\n#endif\n#if defined(DUK_USE_SIGSETJMP)\n#error unsupported config option used (option has been removed): DUK_USE_SIGSETJMP\n#endif\n#if defined(DUK_USE_STRTAB_CHAIN)\n#error unsupported config option used (option has been removed): DUK_USE_STRTAB_CHAIN\n#endif\n#if defined(DUK_USE_STRTAB_CHAIN_SIZE)\n#error unsupported config option used (option has been removed): DUK_USE_STRTAB_CHAIN_SIZE\n#endif\n#if defined(DUK_USE_STRTAB_CHAIN_SIZE) && !defined(DUK_USE_STRTAB_CHAIN)\n#error config option DUK_USE_STRTAB_CHAIN_SIZE requires option DUK_USE_STRTAB_CHAIN (which is missing)\n#endif\n#if defined(DUK_USE_STRTAB_PROBE)\n#error unsupported config option used (option has been removed): DUK_USE_STRTAB_PROBE\n#endif\n#if defined(DUK_USE_STRTAB_PTRCOMP) && !defined(DUK_USE_HEAPPTR16)\n#error config option DUK_USE_STRTAB_PTRCOMP requires option DUK_USE_HEAPPTR16 (which is missing)\n#endif\n#if defined(DUK_USE_TAILCALL) && defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)\n#error config option DUK_USE_TAILCALL conflicts with option DUK_USE_NONSTD_FUNC_CALLER_PROPERTY (which is also defined)\n#endif\n#if defined(DUK_USE_UNALIGNED_ACCESSES_POSSIBLE)\n#error unsupported config option used (option has been removed): DUK_USE_UNALIGNED_ACCESSES_POSSIBLE\n#endif\n#if defined(DUK_USE_UNDERSCORE_SETJMP)\n#error unsupported config option used (option has been removed): DUK_USE_UNDERSCORE_SETJMP\n#endif\n#if defined(DUK_USE_USER_INITJS)\n#error unsupported config option used (option has been removed): DUK_USE_USER_INITJS\n#endif\n\n#if defined(DUK_USE_CPP_EXCEPTIONS) && !defined(__cplusplus)\n#error DUK_USE_CPP_EXCEPTIONS enabled but not compiling with a C++ compiler\n#endif\n\n/*\n *  Convert DUK_USE_BYTEORDER, from whatever source, into currently used\n *  internal defines.  If detection failed, #error out.\n */\n\n#if defined(DUK_USE_BYTEORDER)\n#if (DUK_USE_BYTEORDER == 1)\n#define DUK_USE_INTEGER_LE\n#define DUK_USE_DOUBLE_LE\n#elif (DUK_USE_BYTEORDER == 2)\n#define DUK_USE_INTEGER_LE  /* integer endianness is little on purpose */\n#define DUK_USE_DOUBLE_ME\n#elif (DUK_USE_BYTEORDER == 3)\n#define DUK_USE_INTEGER_BE\n#define DUK_USE_DOUBLE_BE\n#else\n#error unsupported: byte order invalid\n#endif  /* byte order */\n#else\n#error unsupported: byte order detection failed\n#endif  /* defined(DUK_USE_BYTEORDER) */\n\n#endif  /* DUK_CONFIG_H_INCLUDED */\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/src/duk_source_meta.json",
    "content": "{\n    \"comment\": \"Metadata for Duktape sources\", \n    \"duk_version_string\": \"2.1.0\", \n    \"type\": \"duk_source_meta\", \n    \"line_map\": [\n        {\n            \"original_line\": 1, \n            \"combined_line\": 131, \n            \"original_file\": \"duk_replacements.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 141, \n            \"original_file\": \"duk_internal.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 186, \n            \"original_file\": \"duk_dblunion.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 611, \n            \"original_file\": \"duk_replacements.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 642, \n            \"original_file\": \"duk_jmpbuf.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 668, \n            \"original_file\": \"duk_exception.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 688, \n            \"original_file\": \"duk_forwdecl.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 818, \n            \"original_file\": \"duk_tval.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 1452, \n            \"original_file\": \"duk_builtins.h\"\n        }, \n        {\n            \"original_line\": 51, \n            \"combined_line\": 2239, \n            \"original_file\": \"duk_internal.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 2242, \n            \"original_file\": \"duk_util.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 2803, \n            \"original_file\": \"duk_strings.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 2965, \n            \"original_file\": \"duk_js_bytecode.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 3438, \n            \"original_file\": \"duk_lexer.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 3876, \n            \"original_file\": \"duk_js_compiler.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 4105, \n            \"original_file\": \"duk_regexp.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 4191, \n            \"original_file\": \"duk_heaphdr.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 4498, \n            \"original_file\": \"duk_refcount.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 5198, \n            \"original_file\": \"duk_api_internal.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 5512, \n            \"original_file\": \"duk_hstring.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 5740, \n            \"original_file\": \"duk_hobject.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 6696, \n            \"original_file\": \"duk_hcompfunc.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 6961, \n            \"original_file\": \"duk_hnatfunc.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 6995, \n            \"original_file\": \"duk_hbufobj.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 7139, \n            \"original_file\": \"duk_hthread.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 7547, \n            \"original_file\": \"duk_harray.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 7596, \n            \"original_file\": \"duk_henv.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 7646, \n            \"original_file\": \"duk_hbuffer.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 7976, \n            \"original_file\": \"duk_heap.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 8584, \n            \"original_file\": \"duk_debugger.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 8737, \n            \"original_file\": \"duk_debug.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 8923, \n            \"original_file\": \"duk_error.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 9410, \n            \"original_file\": \"duk_unicode.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 9690, \n            \"original_file\": \"duk_json.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 9760, \n            \"original_file\": \"duk_js.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 9868, \n            \"original_file\": \"duk_numconv.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 9970, \n            \"original_file\": \"duk_bi_protos.h\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 10043, \n            \"original_file\": \"duk_selftest.h\"\n        }, \n        {\n            \"original_line\": 80, \n            \"combined_line\": 10059, \n            \"original_file\": \"duk_internal.h\"\n        }, \n        {\n            \"original_line\": 10, \n            \"combined_line\": 10062, \n            \"original_file\": \"duk_replacements.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 10136, \n            \"original_file\": \"duk_debug_macros.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 10228, \n            \"original_file\": \"duk_builtins.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 11008, \n            \"original_file\": \"duk_error_macros.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 11145, \n            \"original_file\": \"duk_unicode_support.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 12329, \n            \"original_file\": \"duk_util_misc.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 12735, \n            \"original_file\": \"duk_hobject_class.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 12865, \n            \"original_file\": \"duk_alloc_default.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 12900, \n            \"original_file\": \"duk_api_buffer.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 12974, \n            \"original_file\": \"duk_api_bytecode.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 13757, \n            \"original_file\": \"duk_api_call.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 14371, \n            \"original_file\": \"duk_api_codec.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 15030, \n            \"original_file\": \"duk_api_compile.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 15203, \n            \"original_file\": \"duk_api_debug.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 15477, \n            \"original_file\": \"duk_api_heap.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 15687, \n            \"original_file\": \"duk_api_inspect.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 15935, \n            \"original_file\": \"duk_api_memory.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 16030, \n            \"original_file\": \"duk_api_object.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 16784, \n            \"original_file\": \"duk_api_stack.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 22622, \n            \"original_file\": \"duk_api_string.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 22961, \n            \"original_file\": \"duk_api_time.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 23032, \n            \"original_file\": \"duk_bi_array.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 24651, \n            \"original_file\": \"duk_bi_boolean.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 24724, \n            \"original_file\": \"duk_bi_buffer.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 27716, \n            \"original_file\": \"duk_bi_date.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 29480, \n            \"original_file\": \"duk_bi_date_unix.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 29794, \n            \"original_file\": \"duk_bi_date_windows.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 29925, \n            \"original_file\": \"duk_bi_duktape.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 30091, \n            \"original_file\": \"duk_bi_encoding.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 30628, \n            \"original_file\": \"duk_bi_error.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 31026, \n            \"original_file\": \"duk_bi_function.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 31449, \n            \"original_file\": \"duk_bi_global.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 32179, \n            \"original_file\": \"duk_bi_json.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 35453, \n            \"original_file\": \"duk_bi_math.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 35879, \n            \"original_file\": \"duk_bi_number.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 36123, \n            \"original_file\": \"duk_bi_object.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 36932, \n            \"original_file\": \"duk_bi_pointer.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 37008, \n            \"original_file\": \"duk_bi_proxy.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 37159, \n            \"original_file\": \"duk_bi_reflect.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 37265, \n            \"original_file\": \"duk_bi_regexp.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 37494, \n            \"original_file\": \"duk_bi_string.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 39057, \n            \"original_file\": \"duk_bi_symbol.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 39231, \n            \"original_file\": \"duk_bi_thread.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 39543, \n            \"original_file\": \"duk_bi_thrower.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 39553, \n            \"original_file\": \"duk_debug_fixedbuffer.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 39623, \n            \"original_file\": \"duk_debug_vsnprintf.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 40663, \n            \"original_file\": \"duk_debugger.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 43513, \n            \"original_file\": \"duk_error_augment.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 44103, \n            \"original_file\": \"duk_error_longjmp.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 44210, \n            \"original_file\": \"duk_error_misc.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 44388, \n            \"original_file\": \"duk_error_throw.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 44564, \n            \"original_file\": \"duk_hbuffer_alloc.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 44697, \n            \"original_file\": \"duk_hbuffer_ops.c\"\n        }, \n        {\n            \"original_line\": 2, \n            \"combined_line\": 44781, \n            \"original_file\": \"duk_hbufobj_misc.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 44801, \n            \"original_file\": \"duk_heap_alloc.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 45914, \n            \"original_file\": \"duk_heap_finalize.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 46364, \n            \"original_file\": \"duk_heap_hashstring.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 46486, \n            \"original_file\": \"duk_heap_markandsweep.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 47723, \n            \"original_file\": \"duk_heap_memory.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 48085, \n            \"original_file\": \"duk_heap_misc.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 48267, \n            \"original_file\": \"duk_heap_refcount.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 49083, \n            \"original_file\": \"duk_heap_stringcache.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 49393, \n            \"original_file\": \"duk_heap_stringtable.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 50369, \n            \"original_file\": \"duk_hobject_alloc.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 50609, \n            \"original_file\": \"duk_hobject_enum.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 51386, \n            \"original_file\": \"duk_hobject_misc.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 51439, \n            \"original_file\": \"duk_hobject_pc2line.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 51689, \n            \"original_file\": \"duk_hobject_props.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 57781, \n            \"original_file\": \"duk_hstring_misc.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 57920, \n            \"original_file\": \"duk_hthread_alloc.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 58018, \n            \"original_file\": \"duk_hthread_builtins.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 58863, \n            \"original_file\": \"duk_hthread_misc.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 58965, \n            \"original_file\": \"duk_hthread_stacks.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 59547, \n            \"original_file\": \"duk_js_arith.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 59685, \n            \"original_file\": \"duk_js_call.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 62458, \n            \"original_file\": \"duk_js_compiler.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 70416, \n            \"original_file\": \"duk_js_executor.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 75598, \n            \"original_file\": \"duk_js_ops.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 77024, \n            \"original_file\": \"duk_js_var.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 78782, \n            \"original_file\": \"duk_lexer.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 81242, \n            \"original_file\": \"duk_numconv.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 83520, \n            \"original_file\": \"duk_regexp_compiler.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 84664, \n            \"original_file\": \"duk_regexp_executor.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 85691, \n            \"original_file\": \"duk_selftest.c\"\n        }, \n        {\n            \"original_line\": 2, \n            \"combined_line\": 86320, \n            \"original_file\": \"duk_tval.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 86462, \n            \"original_file\": \"duk_unicode_tables.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 92604, \n            \"original_file\": \"duk_util_bitdecoder.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 92771, \n            \"original_file\": \"duk_util_bitencoder.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 92815, \n            \"original_file\": \"duk_util_bufwriter.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 93176, \n            \"original_file\": \"duk_util_hashbytes.c\"\n        }, \n        {\n            \"original_line\": 1, \n            \"combined_line\": 93238, \n            \"original_file\": \"duk_util_tinyrandom.c\"\n        }\n    ], \n    \"duk_version\": 20100, \n    \"git_branch\": \"master\", \n    \"git_commit\": \"1f1f51a4f9595ffe8def0e9ba45b20f14679393a\", \n    \"builtin_strings_info\": [\n        {\n            \"plain\": \"Undefined\", \n            \"base64\": \"VW5kZWZpbmVk\", \n            \"define\": \"DUK_STRIDX_UC_UNDEFINED\"\n        }, \n        {\n            \"plain\": \"Null\", \n            \"base64\": \"TnVsbA==\", \n            \"define\": \"DUK_STRIDX_UC_NULL\"\n        }, \n        {\n            \"plain\": \"Symbol\", \n            \"base64\": \"U3ltYm9s\", \n            \"define\": \"DUK_STRIDX_UC_SYMBOL\"\n        }, \n        {\n            \"plain\": \"Arguments\", \n            \"base64\": \"QXJndW1lbnRz\", \n            \"define\": \"DUK_STRIDX_UC_ARGUMENTS\"\n        }, \n        {\n            \"plain\": \"Object\", \n            \"base64\": \"T2JqZWN0\", \n            \"define\": \"DUK_STRIDX_UC_OBJECT\"\n        }, \n        {\n            \"plain\": \"Function\", \n            \"base64\": \"RnVuY3Rpb24=\", \n            \"define\": \"DUK_STRIDX_UC_FUNCTION\"\n        }, \n        {\n            \"plain\": \"Array\", \n            \"base64\": \"QXJyYXk=\", \n            \"define\": \"DUK_STRIDX_ARRAY\"\n        }, \n        {\n            \"plain\": \"String\", \n            \"base64\": \"U3RyaW5n\", \n            \"define\": \"DUK_STRIDX_UC_STRING\"\n        }, \n        {\n            \"plain\": \"Boolean\", \n            \"base64\": \"Qm9vbGVhbg==\", \n            \"define\": \"DUK_STRIDX_UC_BOOLEAN\"\n        }, \n        {\n            \"plain\": \"Number\", \n            \"base64\": \"TnVtYmVy\", \n            \"define\": \"DUK_STRIDX_UC_NUMBER\"\n        }, \n        {\n            \"plain\": \"Date\", \n            \"base64\": \"RGF0ZQ==\", \n            \"define\": \"DUK_STRIDX_DATE\"\n        }, \n        {\n            \"plain\": \"RegExp\", \n            \"base64\": \"UmVnRXhw\", \n            \"define\": \"DUK_STRIDX_REG_EXP\"\n        }, \n        {\n            \"plain\": \"Error\", \n            \"base64\": \"RXJyb3I=\", \n            \"define\": \"DUK_STRIDX_UC_ERROR\"\n        }, \n        {\n            \"plain\": \"Math\", \n            \"base64\": \"TWF0aA==\", \n            \"define\": \"DUK_STRIDX_MATH\"\n        }, \n        {\n            \"plain\": \"JSON\", \n            \"base64\": \"SlNPTg==\", \n            \"define\": \"DUK_STRIDX_JSON\"\n        }, \n        {\n            \"plain\": \"\", \n            \"base64\": \"\", \n            \"define\": \"DUK_STRIDX_EMPTY_STRING\"\n        }, \n        {\n            \"plain\": \"ArrayBuffer\", \n            \"base64\": \"QXJyYXlCdWZmZXI=\", \n            \"define\": \"DUK_STRIDX_ARRAY_BUFFER\"\n        }, \n        {\n            \"plain\": \"DataView\", \n            \"base64\": \"RGF0YVZpZXc=\", \n            \"define\": \"DUK_STRIDX_DATA_VIEW\"\n        }, \n        {\n            \"plain\": \"Int8Array\", \n            \"base64\": \"SW50OEFycmF5\", \n            \"define\": \"DUK_STRIDX_INT8_ARRAY\"\n        }, \n        {\n            \"plain\": \"Uint8Array\", \n            \"base64\": \"VWludDhBcnJheQ==\", \n            \"define\": \"DUK_STRIDX_UINT8_ARRAY\"\n        }, \n        {\n            \"plain\": \"Uint8ClampedArray\", \n            \"base64\": \"VWludDhDbGFtcGVkQXJyYXk=\", \n            \"define\": \"DUK_STRIDX_UINT8_CLAMPED_ARRAY\"\n        }, \n        {\n            \"plain\": \"Int16Array\", \n            \"base64\": \"SW50MTZBcnJheQ==\", \n            \"define\": \"DUK_STRIDX_INT16_ARRAY\"\n        }, \n        {\n            \"plain\": \"Uint16Array\", \n            \"base64\": \"VWludDE2QXJyYXk=\", \n            \"define\": \"DUK_STRIDX_UINT16_ARRAY\"\n        }, \n        {\n            \"plain\": \"Int32Array\", \n            \"base64\": \"SW50MzJBcnJheQ==\", \n            \"define\": \"DUK_STRIDX_INT32_ARRAY\"\n        }, \n        {\n            \"plain\": \"Uint32Array\", \n            \"base64\": \"VWludDMyQXJyYXk=\", \n            \"define\": \"DUK_STRIDX_UINT32_ARRAY\"\n        }, \n        {\n            \"plain\": \"Float32Array\", \n            \"base64\": \"RmxvYXQzMkFycmF5\", \n            \"define\": \"DUK_STRIDX_FLOAT32_ARRAY\"\n        }, \n        {\n            \"plain\": \"Float64Array\", \n            \"base64\": \"RmxvYXQ2NEFycmF5\", \n            \"define\": \"DUK_STRIDX_FLOAT64_ARRAY\"\n        }, \n        {\n            \"plain\": \"global\", \n            \"base64\": \"Z2xvYmFs\", \n            \"define\": \"DUK_STRIDX_GLOBAL\"\n        }, \n        {\n            \"plain\": \"ObjEnv\", \n            \"base64\": \"T2JqRW52\", \n            \"define\": \"DUK_STRIDX_OBJ_ENV\"\n        }, \n        {\n            \"plain\": \"DecEnv\", \n            \"base64\": \"RGVjRW52\", \n            \"define\": \"DUK_STRIDX_DEC_ENV\"\n        }, \n        {\n            \"plain\": \"Buffer\", \n            \"base64\": \"QnVmZmVy\", \n            \"define\": \"DUK_STRIDX_UC_BUFFER\"\n        }, \n        {\n            \"plain\": \"Pointer\", \n            \"base64\": \"UG9pbnRlcg==\", \n            \"define\": \"DUK_STRIDX_UC_POINTER\"\n        }, \n        {\n            \"plain\": \"Thread\", \n            \"base64\": \"VGhyZWFk\", \n            \"define\": \"DUK_STRIDX_UC_THREAD\"\n        }, \n        {\n            \"plain\": \"eval\", \n            \"base64\": \"ZXZhbA==\", \n            \"define\": \"DUK_STRIDX_EVAL\"\n        }, \n        {\n            \"plain\": \"value\", \n            \"base64\": \"dmFsdWU=\", \n            \"define\": \"DUK_STRIDX_VALUE\"\n        }, \n        {\n            \"plain\": \"writable\", \n            \"base64\": \"d3JpdGFibGU=\", \n            \"define\": \"DUK_STRIDX_WRITABLE\"\n        }, \n        {\n            \"plain\": \"configurable\", \n            \"base64\": \"Y29uZmlndXJhYmxl\", \n            \"define\": \"DUK_STRIDX_CONFIGURABLE\"\n        }, \n        {\n            \"plain\": \"enumerable\", \n            \"base64\": \"ZW51bWVyYWJsZQ==\", \n            \"define\": \"DUK_STRIDX_ENUMERABLE\"\n        }, \n        {\n            \"plain\": \"join\", \n            \"base64\": \"am9pbg==\", \n            \"define\": \"DUK_STRIDX_JOIN\"\n        }, \n        {\n            \"plain\": \"toLocaleString\", \n            \"base64\": \"dG9Mb2NhbGVTdHJpbmc=\", \n            \"define\": \"DUK_STRIDX_TO_LOCALE_STRING\"\n        }, \n        {\n            \"plain\": \"valueOf\", \n            \"base64\": \"dmFsdWVPZg==\", \n            \"define\": \"DUK_STRIDX_VALUE_OF\"\n        }, \n        {\n            \"plain\": \"toUTCString\", \n            \"base64\": \"dG9VVENTdHJpbmc=\", \n            \"define\": \"DUK_STRIDX_TO_UTC_STRING\"\n        }, \n        {\n            \"plain\": \"toISOString\", \n            \"base64\": \"dG9JU09TdHJpbmc=\", \n            \"define\": \"DUK_STRIDX_TO_ISO_STRING\"\n        }, \n        {\n            \"plain\": \"toGMTString\", \n            \"base64\": \"dG9HTVRTdHJpbmc=\", \n            \"define\": \"DUK_STRIDX_TO_GMT_STRING\"\n        }, \n        {\n            \"plain\": \"source\", \n            \"base64\": \"c291cmNl\", \n            \"define\": \"DUK_STRIDX_SOURCE\"\n        }, \n        {\n            \"plain\": \"ignoreCase\", \n            \"base64\": \"aWdub3JlQ2FzZQ==\", \n            \"define\": \"DUK_STRIDX_IGNORE_CASE\"\n        }, \n        {\n            \"plain\": \"multiline\", \n            \"base64\": \"bXVsdGlsaW5l\", \n            \"define\": \"DUK_STRIDX_MULTILINE\"\n        }, \n        {\n            \"plain\": \"lastIndex\", \n            \"base64\": \"bGFzdEluZGV4\", \n            \"define\": \"DUK_STRIDX_LAST_INDEX\"\n        }, \n        {\n            \"plain\": \"flags\", \n            \"base64\": \"ZmxhZ3M=\", \n            \"define\": \"DUK_STRIDX_FLAGS\"\n        }, \n        {\n            \"plain\": \"index\", \n            \"base64\": \"aW5kZXg=\", \n            \"define\": \"DUK_STRIDX_INDEX\"\n        }, \n        {\n            \"plain\": \"prototype\", \n            \"base64\": \"cHJvdG90eXBl\", \n            \"define\": \"DUK_STRIDX_PROTOTYPE\"\n        }, \n        {\n            \"plain\": \"constructor\", \n            \"base64\": \"Y29uc3RydWN0b3I=\", \n            \"define\": \"DUK_STRIDX_CONSTRUCTOR\"\n        }, \n        {\n            \"plain\": \"message\", \n            \"base64\": \"bWVzc2FnZQ==\", \n            \"define\": \"DUK_STRIDX_MESSAGE\"\n        }, \n        {\n            \"plain\": \"boolean\", \n            \"base64\": \"Ym9vbGVhbg==\", \n            \"define\": \"DUK_STRIDX_LC_BOOLEAN\"\n        }, \n        {\n            \"plain\": \"number\", \n            \"base64\": \"bnVtYmVy\", \n            \"define\": \"DUK_STRIDX_LC_NUMBER\"\n        }, \n        {\n            \"plain\": \"string\", \n            \"base64\": \"c3RyaW5n\", \n            \"define\": \"DUK_STRIDX_LC_STRING\"\n        }, \n        {\n            \"plain\": \"symbol\", \n            \"base64\": \"c3ltYm9s\", \n            \"define\": \"DUK_STRIDX_LC_SYMBOL\"\n        }, \n        {\n            \"plain\": \"object\", \n            \"base64\": \"b2JqZWN0\", \n            \"define\": \"DUK_STRIDX_LC_OBJECT\"\n        }, \n        {\n            \"plain\": \"undefined\", \n            \"base64\": \"dW5kZWZpbmVk\", \n            \"define\": \"DUK_STRIDX_LC_UNDEFINED\"\n        }, \n        {\n            \"plain\": \"NaN\", \n            \"base64\": \"TmFO\", \n            \"define\": \"DUK_STRIDX_NAN\"\n        }, \n        {\n            \"plain\": \"Infinity\", \n            \"base64\": \"SW5maW5pdHk=\", \n            \"define\": \"DUK_STRIDX_INFINITY\"\n        }, \n        {\n            \"plain\": \"-Infinity\", \n            \"base64\": \"LUluZmluaXR5\", \n            \"define\": \"DUK_STRIDX_MINUS_INFINITY\"\n        }, \n        {\n            \"plain\": \"-0\", \n            \"base64\": \"LTA=\", \n            \"define\": \"DUK_STRIDX_MINUS_ZERO\"\n        }, \n        {\n            \"plain\": \",\", \n            \"base64\": \"LA==\", \n            \"define\": \"DUK_STRIDX_COMMA\"\n        }, \n        {\n            \"plain\": \"\\n    \", \n            \"base64\": \"CiAgICA=\", \n            \"define\": \"DUK_STRIDX_NEWLINE_4SPACE\"\n        }, \n        {\n            \"plain\": \"[...]\", \n            \"base64\": \"Wy4uLl0=\", \n            \"define\": \"DUK_STRIDX_BRACKETED_ELLIPSIS\"\n        }, \n        {\n            \"plain\": \"Invalid Date\", \n            \"base64\": \"SW52YWxpZCBEYXRl\", \n            \"define\": \"DUK_STRIDX_INVALID_DATE\"\n        }, \n        {\n            \"plain\": \"arguments\", \n            \"base64\": \"YXJndW1lbnRz\", \n            \"define\": \"DUK_STRIDX_LC_ARGUMENTS\"\n        }, \n        {\n            \"plain\": \"callee\", \n            \"base64\": \"Y2FsbGVl\", \n            \"define\": \"DUK_STRIDX_CALLEE\"\n        }, \n        {\n            \"plain\": \"caller\", \n            \"base64\": \"Y2FsbGVy\", \n            \"define\": \"DUK_STRIDX_CALLER\"\n        }, \n        {\n            \"plain\": \"deleteProperty\", \n            \"base64\": \"ZGVsZXRlUHJvcGVydHk=\", \n            \"define\": \"DUK_STRIDX_DELETE_PROPERTY\"\n        }, \n        {\n            \"plain\": \"get\", \n            \"base64\": \"Z2V0\", \n            \"define\": \"DUK_STRIDX_GET\"\n        }, \n        {\n            \"plain\": \"has\", \n            \"base64\": \"aGFz\", \n            \"define\": \"DUK_STRIDX_HAS\"\n        }, \n        {\n            \"plain\": \"ownKeys\", \n            \"base64\": \"b3duS2V5cw==\", \n            \"define\": \"DUK_STRIDX_OWN_KEYS\"\n        }, \n        {\n            \"plain\": \"setPrototypeOf\", \n            \"base64\": \"c2V0UHJvdG90eXBlT2Y=\", \n            \"define\": \"DUK_STRIDX_SET_PROTOTYPE_OF\"\n        }, \n        {\n            \"plain\": \"__proto__\", \n            \"base64\": \"X19wcm90b19f\", \n            \"define\": \"DUK_STRIDX___PROTO__\"\n        }, \n        {\n            \"plain\": \"toString\", \n            \"base64\": \"dG9TdHJpbmc=\", \n            \"define\": \"DUK_STRIDX_TO_STRING\"\n        }, \n        {\n            \"plain\": \"toJSON\", \n            \"base64\": \"dG9KU09O\", \n            \"define\": \"DUK_STRIDX_TO_JSON\"\n        }, \n        {\n            \"plain\": \"type\", \n            \"base64\": \"dHlwZQ==\", \n            \"define\": \"DUK_STRIDX_TYPE\"\n        }, \n        {\n            \"plain\": \"data\", \n            \"base64\": \"ZGF0YQ==\", \n            \"define\": \"DUK_STRIDX_DATA\"\n        }, \n        {\n            \"plain\": \"length\", \n            \"base64\": \"bGVuZ3Ro\", \n            \"define\": \"DUK_STRIDX_LENGTH\"\n        }, \n        {\n            \"plain\": \"set\", \n            \"base64\": \"c2V0\", \n            \"define\": \"DUK_STRIDX_SET\"\n        }, \n        {\n            \"plain\": \"stack\", \n            \"base64\": \"c3RhY2s=\", \n            \"define\": \"DUK_STRIDX_STACK\"\n        }, \n        {\n            \"plain\": \"pc\", \n            \"base64\": \"cGM=\", \n            \"define\": \"DUK_STRIDX_PC\"\n        }, \n        {\n            \"plain\": \"lineNumber\", \n            \"base64\": \"bGluZU51bWJlcg==\", \n            \"define\": \"DUK_STRIDX_LINE_NUMBER\"\n        }, \n        {\n            \"plain\": \"\\u00ffTracedata\", \n            \"base64\": \"/1RyYWNlZGF0YQ==\", \n            \"define\": \"DUK_STRIDX_INT_TRACEDATA\"\n        }, \n        {\n            \"plain\": \"name\", \n            \"base64\": \"bmFtZQ==\", \n            \"define\": \"DUK_STRIDX_NAME\"\n        }, \n        {\n            \"plain\": \"fileName\", \n            \"base64\": \"ZmlsZU5hbWU=\", \n            \"define\": \"DUK_STRIDX_FILE_NAME\"\n        }, \n        {\n            \"plain\": \"pointer\", \n            \"base64\": \"cG9pbnRlcg==\", \n            \"define\": \"DUK_STRIDX_LC_POINTER\"\n        }, \n        {\n            \"plain\": \"\\u00ffValue\", \n            \"base64\": \"/1ZhbHVl\", \n            \"define\": \"DUK_STRIDX_INT_VALUE\"\n        }, \n        {\n            \"plain\": \"\\u00ffNext\", \n            \"base64\": \"/05leHQ=\", \n            \"define\": \"DUK_STRIDX_INT_NEXT\"\n        }, \n        {\n            \"plain\": \"\\u00ffBytecode\", \n            \"base64\": \"/0J5dGVjb2Rl\", \n            \"define\": \"DUK_STRIDX_INT_BYTECODE\"\n        }, \n        {\n            \"plain\": \"\\u00ffFormals\", \n            \"base64\": \"/0Zvcm1hbHM=\", \n            \"define\": \"DUK_STRIDX_INT_FORMALS\"\n        }, \n        {\n            \"plain\": \"\\u00ffVarmap\", \n            \"base64\": \"/1Zhcm1hcA==\", \n            \"define\": \"DUK_STRIDX_INT_VARMAP\"\n        }, \n        {\n            \"plain\": \"\\u00ffSource\", \n            \"base64\": \"/1NvdXJjZQ==\", \n            \"define\": \"DUK_STRIDX_INT_SOURCE\"\n        }, \n        {\n            \"plain\": \"\\u00ffPc2line\", \n            \"base64\": \"/1BjMmxpbmU=\", \n            \"define\": \"DUK_STRIDX_INT_PC2LINE\"\n        }, \n        {\n            \"plain\": \"\\u00ffThis\", \n            \"base64\": \"/1RoaXM=\", \n            \"define\": \"DUK_STRIDX_INT_THIS\"\n        }, \n        {\n            \"plain\": \"\\u00ffArgs\", \n            \"base64\": \"/0FyZ3M=\", \n            \"define\": \"DUK_STRIDX_INT_ARGS\"\n        }, \n        {\n            \"plain\": \"\\u00ffMap\", \n            \"base64\": \"/01hcA==\", \n            \"define\": \"DUK_STRIDX_INT_MAP\"\n        }, \n        {\n            \"plain\": \"\\u00ffVarenv\", \n            \"base64\": \"/1ZhcmVudg==\", \n            \"define\": \"DUK_STRIDX_INT_VARENV\"\n        }, \n        {\n            \"plain\": \"\\u00ffFinalizer\", \n            \"base64\": \"/0ZpbmFsaXplcg==\", \n            \"define\": \"DUK_STRIDX_INT_FINALIZER\"\n        }, \n        {\n            \"plain\": \"\\u00ffTarget\", \n            \"base64\": \"/1RhcmdldA==\", \n            \"define\": \"DUK_STRIDX_INT_TARGET\"\n        }, \n        {\n            \"plain\": \"\\u00ffHandler\", \n            \"base64\": \"/0hhbmRsZXI=\", \n            \"define\": \"DUK_STRIDX_INT_HANDLER\"\n        }, \n        {\n            \"plain\": \"compile\", \n            \"base64\": \"Y29tcGlsZQ==\", \n            \"define\": \"DUK_STRIDX_COMPILE\"\n        }, \n        {\n            \"plain\": \"input\", \n            \"base64\": \"aW5wdXQ=\", \n            \"define\": \"DUK_STRIDX_INPUT\"\n        }, \n        {\n            \"plain\": \"errCreate\", \n            \"base64\": \"ZXJyQ3JlYXRl\", \n            \"define\": \"DUK_STRIDX_ERR_CREATE\"\n        }, \n        {\n            \"plain\": \"errThrow\", \n            \"base64\": \"ZXJyVGhyb3c=\", \n            \"define\": \"DUK_STRIDX_ERR_THROW\"\n        }, \n        {\n            \"plain\": \"env\", \n            \"base64\": \"ZW52\", \n            \"define\": \"DUK_STRIDX_ENV\"\n        }, \n        {\n            \"plain\": \"hex\", \n            \"base64\": \"aGV4\", \n            \"define\": \"DUK_STRIDX_HEX\"\n        }, \n        {\n            \"plain\": \"base64\", \n            \"base64\": \"YmFzZTY0\", \n            \"define\": \"DUK_STRIDX_BASE64\"\n        }, \n        {\n            \"plain\": \"jx\", \n            \"base64\": \"ang=\", \n            \"define\": \"DUK_STRIDX_JX\"\n        }, \n        {\n            \"plain\": \"jc\", \n            \"base64\": \"amM=\", \n            \"define\": \"DUK_STRIDX_JC\"\n        }, \n        {\n            \"plain\": \"resume\", \n            \"base64\": \"cmVzdW1l\", \n            \"define\": \"DUK_STRIDX_RESUME\"\n        }, \n        {\n            \"plain\": \"{\\\"_undef\\\":true}\", \n            \"base64\": \"eyJfdW5kZWYiOnRydWV9\", \n            \"define\": \"DUK_STRIDX_JSON_EXT_UNDEFINED\"\n        }, \n        {\n            \"plain\": \"{\\\"_nan\\\":true}\", \n            \"base64\": \"eyJfbmFuIjp0cnVlfQ==\", \n            \"define\": \"DUK_STRIDX_JSON_EXT_NAN\"\n        }, \n        {\n            \"plain\": \"{\\\"_inf\\\":true}\", \n            \"base64\": \"eyJfaW5mIjp0cnVlfQ==\", \n            \"define\": \"DUK_STRIDX_JSON_EXT_POSINF\"\n        }, \n        {\n            \"plain\": \"{\\\"_ninf\\\":true}\", \n            \"base64\": \"eyJfbmluZiI6dHJ1ZX0=\", \n            \"define\": \"DUK_STRIDX_JSON_EXT_NEGINF\"\n        }, \n        {\n            \"plain\": \"{\\\"_func\\\":true}\", \n            \"base64\": \"eyJfZnVuYyI6dHJ1ZX0=\", \n            \"define\": \"DUK_STRIDX_JSON_EXT_FUNCTION1\"\n        }, \n        {\n            \"plain\": \"{_func:true}\", \n            \"base64\": \"e19mdW5jOnRydWV9\", \n            \"define\": \"DUK_STRIDX_JSON_EXT_FUNCTION2\"\n        }, \n        {\n            \"plain\": \"break\", \n            \"base64\": \"YnJlYWs=\", \n            \"define\": \"DUK_STRIDX_BREAK\"\n        }, \n        {\n            \"plain\": \"case\", \n            \"base64\": \"Y2FzZQ==\", \n            \"define\": \"DUK_STRIDX_CASE\"\n        }, \n        {\n            \"plain\": \"catch\", \n            \"base64\": \"Y2F0Y2g=\", \n            \"define\": \"DUK_STRIDX_CATCH\"\n        }, \n        {\n            \"plain\": \"continue\", \n            \"base64\": \"Y29udGludWU=\", \n            \"define\": \"DUK_STRIDX_CONTINUE\"\n        }, \n        {\n            \"plain\": \"debugger\", \n            \"base64\": \"ZGVidWdnZXI=\", \n            \"define\": \"DUK_STRIDX_DEBUGGER\"\n        }, \n        {\n            \"plain\": \"default\", \n            \"base64\": \"ZGVmYXVsdA==\", \n            \"define\": \"DUK_STRIDX_DEFAULT\"\n        }, \n        {\n            \"plain\": \"delete\", \n            \"base64\": \"ZGVsZXRl\", \n            \"define\": \"DUK_STRIDX_DELETE\"\n        }, \n        {\n            \"plain\": \"do\", \n            \"base64\": \"ZG8=\", \n            \"define\": \"DUK_STRIDX_DO\"\n        }, \n        {\n            \"plain\": \"else\", \n            \"base64\": \"ZWxzZQ==\", \n            \"define\": \"DUK_STRIDX_ELSE\"\n        }, \n        {\n            \"plain\": \"finally\", \n            \"base64\": \"ZmluYWxseQ==\", \n            \"define\": \"DUK_STRIDX_FINALLY\"\n        }, \n        {\n            \"plain\": \"for\", \n            \"base64\": \"Zm9y\", \n            \"define\": \"DUK_STRIDX_FOR\"\n        }, \n        {\n            \"plain\": \"function\", \n            \"base64\": \"ZnVuY3Rpb24=\", \n            \"define\": \"DUK_STRIDX_LC_FUNCTION\"\n        }, \n        {\n            \"plain\": \"if\", \n            \"base64\": \"aWY=\", \n            \"define\": \"DUK_STRIDX_IF\"\n        }, \n        {\n            \"plain\": \"in\", \n            \"base64\": \"aW4=\", \n            \"define\": \"DUK_STRIDX_IN\"\n        }, \n        {\n            \"plain\": \"instanceof\", \n            \"base64\": \"aW5zdGFuY2VvZg==\", \n            \"define\": \"DUK_STRIDX_INSTANCEOF\"\n        }, \n        {\n            \"plain\": \"new\", \n            \"base64\": \"bmV3\", \n            \"define\": \"DUK_STRIDX_NEW\"\n        }, \n        {\n            \"plain\": \"return\", \n            \"base64\": \"cmV0dXJu\", \n            \"define\": \"DUK_STRIDX_RETURN\"\n        }, \n        {\n            \"plain\": \"switch\", \n            \"base64\": \"c3dpdGNo\", \n            \"define\": \"DUK_STRIDX_SWITCH\"\n        }, \n        {\n            \"plain\": \"this\", \n            \"base64\": \"dGhpcw==\", \n            \"define\": \"DUK_STRIDX_THIS\"\n        }, \n        {\n            \"plain\": \"throw\", \n            \"base64\": \"dGhyb3c=\", \n            \"define\": \"DUK_STRIDX_THROW\"\n        }, \n        {\n            \"plain\": \"try\", \n            \"base64\": \"dHJ5\", \n            \"define\": \"DUK_STRIDX_TRY\"\n        }, \n        {\n            \"plain\": \"typeof\", \n            \"base64\": \"dHlwZW9m\", \n            \"define\": \"DUK_STRIDX_TYPEOF\"\n        }, \n        {\n            \"plain\": \"var\", \n            \"base64\": \"dmFy\", \n            \"define\": \"DUK_STRIDX_VAR\"\n        }, \n        {\n            \"plain\": \"const\", \n            \"base64\": \"Y29uc3Q=\", \n            \"define\": \"DUK_STRIDX_CONST\"\n        }, \n        {\n            \"plain\": \"void\", \n            \"base64\": \"dm9pZA==\", \n            \"define\": \"DUK_STRIDX_VOID\"\n        }, \n        {\n            \"plain\": \"while\", \n            \"base64\": \"d2hpbGU=\", \n            \"define\": \"DUK_STRIDX_WHILE\"\n        }, \n        {\n            \"plain\": \"with\", \n            \"base64\": \"d2l0aA==\", \n            \"define\": \"DUK_STRIDX_WITH\"\n        }, \n        {\n            \"plain\": \"class\", \n            \"base64\": \"Y2xhc3M=\", \n            \"define\": \"DUK_STRIDX_CLASS\"\n        }, \n        {\n            \"plain\": \"enum\", \n            \"base64\": \"ZW51bQ==\", \n            \"define\": \"DUK_STRIDX_ENUM\"\n        }, \n        {\n            \"plain\": \"export\", \n            \"base64\": \"ZXhwb3J0\", \n            \"define\": \"DUK_STRIDX_EXPORT\"\n        }, \n        {\n            \"plain\": \"extends\", \n            \"base64\": \"ZXh0ZW5kcw==\", \n            \"define\": \"DUK_STRIDX_EXTENDS\"\n        }, \n        {\n            \"plain\": \"import\", \n            \"base64\": \"aW1wb3J0\", \n            \"define\": \"DUK_STRIDX_IMPORT\"\n        }, \n        {\n            \"plain\": \"super\", \n            \"base64\": \"c3VwZXI=\", \n            \"define\": \"DUK_STRIDX_SUPER\"\n        }, \n        {\n            \"plain\": \"null\", \n            \"base64\": \"bnVsbA==\", \n            \"define\": \"DUK_STRIDX_LC_NULL\"\n        }, \n        {\n            \"plain\": \"true\", \n            \"base64\": \"dHJ1ZQ==\", \n            \"define\": \"DUK_STRIDX_TRUE\"\n        }, \n        {\n            \"plain\": \"false\", \n            \"base64\": \"ZmFsc2U=\", \n            \"define\": \"DUK_STRIDX_FALSE\"\n        }, \n        {\n            \"plain\": \"implements\", \n            \"base64\": \"aW1wbGVtZW50cw==\", \n            \"define\": \"DUK_STRIDX_IMPLEMENTS\"\n        }, \n        {\n            \"plain\": \"interface\", \n            \"base64\": \"aW50ZXJmYWNl\", \n            \"define\": \"DUK_STRIDX_INTERFACE\"\n        }, \n        {\n            \"plain\": \"let\", \n            \"base64\": \"bGV0\", \n            \"define\": \"DUK_STRIDX_LET\"\n        }, \n        {\n            \"plain\": \"package\", \n            \"base64\": \"cGFja2FnZQ==\", \n            \"define\": \"DUK_STRIDX_PACKAGE\"\n        }, \n        {\n            \"plain\": \"private\", \n            \"base64\": \"cHJpdmF0ZQ==\", \n            \"define\": \"DUK_STRIDX_PRIVATE\"\n        }, \n        {\n            \"plain\": \"protected\", \n            \"base64\": \"cHJvdGVjdGVk\", \n            \"define\": \"DUK_STRIDX_PROTECTED\"\n        }, \n        {\n            \"plain\": \"public\", \n            \"base64\": \"cHVibGlj\", \n            \"define\": \"DUK_STRIDX_PUBLIC\"\n        }, \n        {\n            \"plain\": \"static\", \n            \"base64\": \"c3RhdGlj\", \n            \"define\": \"DUK_STRIDX_STATIC\"\n        }, \n        {\n            \"plain\": \"yield\", \n            \"base64\": \"eWllbGQ=\", \n            \"define\": \"DUK_STRIDX_YIELD\"\n        }\n    ], \n    \"builtin_strings_base64\": [\n        \"VW5kZWZpbmVk\", \n        \"TnVsbA==\", \n        \"U3ltYm9s\", \n        \"QXJndW1lbnRz\", \n        \"T2JqZWN0\", \n        \"RnVuY3Rpb24=\", \n        \"QXJyYXk=\", \n        \"U3RyaW5n\", \n        \"Qm9vbGVhbg==\", \n        \"TnVtYmVy\", \n        \"RGF0ZQ==\", \n        \"UmVnRXhw\", \n        \"RXJyb3I=\", \n        \"TWF0aA==\", \n        \"SlNPTg==\", \n        \"\", \n        \"QXJyYXlCdWZmZXI=\", \n        \"RGF0YVZpZXc=\", \n        \"SW50OEFycmF5\", \n        \"VWludDhBcnJheQ==\", \n        \"VWludDhDbGFtcGVkQXJyYXk=\", \n        \"SW50MTZBcnJheQ==\", \n        \"VWludDE2QXJyYXk=\", \n        \"SW50MzJBcnJheQ==\", \n        \"VWludDMyQXJyYXk=\", \n        \"RmxvYXQzMkFycmF5\", \n        \"RmxvYXQ2NEFycmF5\", \n        \"Z2xvYmFs\", \n        \"T2JqRW52\", \n        \"RGVjRW52\", \n        \"QnVmZmVy\", \n        \"UG9pbnRlcg==\", \n        \"VGhyZWFk\", \n        \"ZXZhbA==\", \n        \"dmFsdWU=\", \n        \"d3JpdGFibGU=\", \n        \"Y29uZmlndXJhYmxl\", \n        \"ZW51bWVyYWJsZQ==\", \n        \"am9pbg==\", \n        \"dG9Mb2NhbGVTdHJpbmc=\", \n        \"dmFsdWVPZg==\", \n        \"dG9VVENTdHJpbmc=\", \n        \"dG9JU09TdHJpbmc=\", \n        \"dG9HTVRTdHJpbmc=\", \n        \"c291cmNl\", \n        \"aWdub3JlQ2FzZQ==\", \n        \"bXVsdGlsaW5l\", \n        \"bGFzdEluZGV4\", \n        \"ZmxhZ3M=\", \n        \"aW5kZXg=\", \n        \"cHJvdG90eXBl\", \n        \"Y29uc3RydWN0b3I=\", \n        \"bWVzc2FnZQ==\", \n        \"Ym9vbGVhbg==\", \n        \"bnVtYmVy\", \n        \"c3RyaW5n\", \n        \"c3ltYm9s\", \n        \"b2JqZWN0\", \n        \"dW5kZWZpbmVk\", \n        \"TmFO\", \n        \"SW5maW5pdHk=\", \n        \"LUluZmluaXR5\", \n        \"LTA=\", \n        \"LA==\", \n        \"CiAgICA=\", \n        \"Wy4uLl0=\", \n        \"SW52YWxpZCBEYXRl\", \n        \"YXJndW1lbnRz\", \n        \"Y2FsbGVl\", \n        \"Y2FsbGVy\", \n        \"ZGVsZXRlUHJvcGVydHk=\", \n        \"Z2V0\", \n        \"aGFz\", \n        \"b3duS2V5cw==\", \n        \"c2V0UHJvdG90eXBlT2Y=\", \n        \"X19wcm90b19f\", \n        \"dG9TdHJpbmc=\", \n        \"dG9KU09O\", \n        \"dHlwZQ==\", \n        \"ZGF0YQ==\", \n        \"bGVuZ3Ro\", \n        \"c2V0\", \n        \"c3RhY2s=\", \n        \"cGM=\", \n        \"bGluZU51bWJlcg==\", \n        \"/1RyYWNlZGF0YQ==\", \n        \"bmFtZQ==\", \n        \"ZmlsZU5hbWU=\", \n        \"cG9pbnRlcg==\", \n        \"/1ZhbHVl\", \n        \"/05leHQ=\", \n        \"/0J5dGVjb2Rl\", \n        \"/0Zvcm1hbHM=\", \n        \"/1Zhcm1hcA==\", \n        \"/1NvdXJjZQ==\", \n        \"/1BjMmxpbmU=\", \n        \"/1RoaXM=\", \n        \"/0FyZ3M=\", \n        \"/01hcA==\", \n        \"/1ZhcmVudg==\", \n        \"/0ZpbmFsaXplcg==\", \n        \"/1RhcmdldA==\", \n        \"/0hhbmRsZXI=\", \n        \"Y29tcGlsZQ==\", \n        \"aW5wdXQ=\", \n        \"ZXJyQ3JlYXRl\", \n        \"ZXJyVGhyb3c=\", \n        \"ZW52\", \n        \"aGV4\", \n        \"YmFzZTY0\", \n        \"ang=\", \n        \"amM=\", \n        \"cmVzdW1l\", \n        \"eyJfdW5kZWYiOnRydWV9\", \n        \"eyJfbmFuIjp0cnVlfQ==\", \n        \"eyJfaW5mIjp0cnVlfQ==\", \n        \"eyJfbmluZiI6dHJ1ZX0=\", \n        \"eyJfZnVuYyI6dHJ1ZX0=\", \n        \"e19mdW5jOnRydWV9\", \n        \"YnJlYWs=\", \n        \"Y2FzZQ==\", \n        \"Y2F0Y2g=\", \n        \"Y29udGludWU=\", \n        \"ZGVidWdnZXI=\", \n        \"ZGVmYXVsdA==\", \n        \"ZGVsZXRl\", \n        \"ZG8=\", \n        \"ZWxzZQ==\", \n        \"ZmluYWxseQ==\", \n        \"Zm9y\", \n        \"ZnVuY3Rpb24=\", \n        \"aWY=\", \n        \"aW4=\", \n        \"aW5zdGFuY2VvZg==\", \n        \"bmV3\", \n        \"cmV0dXJu\", \n        \"c3dpdGNo\", \n        \"dGhpcw==\", \n        \"dGhyb3c=\", \n        \"dHJ5\", \n        \"dHlwZW9m\", \n        \"dmFy\", \n        \"Y29uc3Q=\", \n        \"dm9pZA==\", \n        \"d2hpbGU=\", \n        \"d2l0aA==\", \n        \"Y2xhc3M=\", \n        \"ZW51bQ==\", \n        \"ZXhwb3J0\", \n        \"ZXh0ZW5kcw==\", \n        \"aW1wb3J0\", \n        \"c3VwZXI=\", \n        \"bnVsbA==\", \n        \"dHJ1ZQ==\", \n        \"ZmFsc2U=\", \n        \"aW1wbGVtZW50cw==\", \n        \"aW50ZXJmYWNl\", \n        \"bGV0\", \n        \"cGFja2FnZQ==\", \n        \"cHJpdmF0ZQ==\", \n        \"cHJvdGVjdGVk\", \n        \"cHVibGlj\", \n        \"c3RhdGlj\", \n        \"eWllbGQ=\"\n    ], \n    \"git_describe\": \"v2.1.0\", \n    \"builtin_strings\": [\n        \"Undefined\", \n        \"Null\", \n        \"Symbol\", \n        \"Arguments\", \n        \"Object\", \n        \"Function\", \n        \"Array\", \n        \"String\", \n        \"Boolean\", \n        \"Number\", \n        \"Date\", \n        \"RegExp\", \n        \"Error\", \n        \"Math\", \n        \"JSON\", \n        \"\", \n        \"ArrayBuffer\", \n        \"DataView\", \n        \"Int8Array\", \n        \"Uint8Array\", \n        \"Uint8ClampedArray\", \n        \"Int16Array\", \n        \"Uint16Array\", \n        \"Int32Array\", \n        \"Uint32Array\", \n        \"Float32Array\", \n        \"Float64Array\", \n        \"global\", \n        \"ObjEnv\", \n        \"DecEnv\", \n        \"Buffer\", \n        \"Pointer\", \n        \"Thread\", \n        \"eval\", \n        \"value\", \n        \"writable\", \n        \"configurable\", \n        \"enumerable\", \n        \"join\", \n        \"toLocaleString\", \n        \"valueOf\", \n        \"toUTCString\", \n        \"toISOString\", \n        \"toGMTString\", \n        \"source\", \n        \"ignoreCase\", \n        \"multiline\", \n        \"lastIndex\", \n        \"flags\", \n        \"index\", \n        \"prototype\", \n        \"constructor\", \n        \"message\", \n        \"boolean\", \n        \"number\", \n        \"string\", \n        \"symbol\", \n        \"object\", \n        \"undefined\", \n        \"NaN\", \n        \"Infinity\", \n        \"-Infinity\", \n        \"-0\", \n        \",\", \n        \"\\n    \", \n        \"[...]\", \n        \"Invalid Date\", \n        \"arguments\", \n        \"callee\", \n        \"caller\", \n        \"deleteProperty\", \n        \"get\", \n        \"has\", \n        \"ownKeys\", \n        \"setPrototypeOf\", \n        \"__proto__\", \n        \"toString\", \n        \"toJSON\", \n        \"type\", \n        \"data\", \n        \"length\", \n        \"set\", \n        \"stack\", \n        \"pc\", \n        \"lineNumber\", \n        \"\\u00ffTracedata\", \n        \"name\", \n        \"fileName\", \n        \"pointer\", \n        \"\\u00ffValue\", \n        \"\\u00ffNext\", \n        \"\\u00ffBytecode\", \n        \"\\u00ffFormals\", \n        \"\\u00ffVarmap\", \n        \"\\u00ffSource\", \n        \"\\u00ffPc2line\", \n        \"\\u00ffThis\", \n        \"\\u00ffArgs\", \n        \"\\u00ffMap\", \n        \"\\u00ffVarenv\", \n        \"\\u00ffFinalizer\", \n        \"\\u00ffTarget\", \n        \"\\u00ffHandler\", \n        \"compile\", \n        \"input\", \n        \"errCreate\", \n        \"errThrow\", \n        \"env\", \n        \"hex\", \n        \"base64\", \n        \"jx\", \n        \"jc\", \n        \"resume\", \n        \"{\\\"_undef\\\":true}\", \n        \"{\\\"_nan\\\":true}\", \n        \"{\\\"_inf\\\":true}\", \n        \"{\\\"_ninf\\\":true}\", \n        \"{\\\"_func\\\":true}\", \n        \"{_func:true}\", \n        \"break\", \n        \"case\", \n        \"catch\", \n        \"continue\", \n        \"debugger\", \n        \"default\", \n        \"delete\", \n        \"do\", \n        \"else\", \n        \"finally\", \n        \"for\", \n        \"function\", \n        \"if\", \n        \"in\", \n        \"instanceof\", \n        \"new\", \n        \"return\", \n        \"switch\", \n        \"this\", \n        \"throw\", \n        \"try\", \n        \"typeof\", \n        \"var\", \n        \"const\", \n        \"void\", \n        \"while\", \n        \"with\", \n        \"class\", \n        \"enum\", \n        \"export\", \n        \"extends\", \n        \"import\", \n        \"super\", \n        \"null\", \n        \"true\", \n        \"false\", \n        \"implements\", \n        \"interface\", \n        \"let\", \n        \"package\", \n        \"private\", \n        \"protected\", \n        \"public\", \n        \"static\", \n        \"yield\"\n    ]\n}"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/src/duktape.c",
    "content": "/*\n *  Single source autogenerated distributable for Duktape 2.1.0.\n *\n *  Git commit 1f1f51a4f9595ffe8def0e9ba45b20f14679393a (v2.1.0).\n *  Git branch master.\n *\n *  See Duktape AUTHORS.rst and LICENSE.txt for copyright and\n *  licensing information.\n */\n\n/* LICENSE.txt */\n/*\n*  ===============\n*  Duktape license\n*  ===============\n*\n*  (http://opensource.org/licenses/MIT)\n*\n*  Copyright (c) 2013-2017 by Duktape authors (see AUTHORS.rst)\n*\n*  Permission is hereby granted, free of charge, to any person obtaining a copy\n*  of this software and associated documentation files (the \"Software\"), to deal\n*  in the Software without restriction, including without limitation the rights\n*  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n*  copies of the Software, and to permit persons to whom the Software is\n*  furnished to do so, subject to the following conditions:\n*\n*  The above copyright notice and this permission notice shall be included in\n*  all copies or substantial portions of the Software.\n*\n*  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n*  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n*  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n*  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n*  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n*  THE SOFTWARE.\n*/\n\n/* AUTHORS.rst */\n/*\n*  ===============\n*  Duktape authors\n*  ===============\n*\n*  Copyright\n*  =========\n*\n*  Duktape copyrights are held by its authors.  Each author has a copyright\n*  to their contribution, and agrees to irrevocably license the contribution\n*  under the Duktape ``LICENSE.txt``.\n*\n*  Authors\n*  =======\n*\n*  Please include an e-mail address, a link to your GitHub profile, or something\n*  similar to allow your contribution to be identified accurately.\n*\n*  The following people have contributed code, website contents, or Wiki contents,\n*  and agreed to irrevocably license their contributions under the Duktape\n*  ``LICENSE.txt`` (in order of appearance):\n*\n*  * Sami Vaarala <sami.vaarala@iki.fi>\n*  * Niki Dobrev\n*  * Andreas \\u00d6man <andreas@lonelycoder.com>\n*  * L\\u00e1szl\\u00f3 Lang\\u00f3 <llango.u-szeged@partner.samsung.com>\n*  * Legimet <legimet.calc@gmail.com>\n*  * Karl Skomski <karl@skomski.com>\n*  * Bruce Pascoe <fatcerberus1@gmail.com>\n*  * Ren\\u00e9 Hollander <rene@rene8888.at>\n*  * Julien Hamaide (https://github.com/crazyjul)\n*  * Sebastian G\\u00f6tte (https://github.com/jaseg)\n*  * Tomasz Magulski (https://github.com/magul)\n*  * \\D. Bohdan (https://github.com/dbohdan)\n*  * Ond\\u0159ej Jirman (https://github.com/megous)\n*  * Sa\\u00fal Ibarra Corretg\\u00e9 <saghul@gmail.com>\n*  * Jeremy HU <huxingyi@msn.com>\n*  * Ole Andr\\u00e9 Vadla Ravn\\u00e5s (https://github.com/oleavr)\n*  * Harold Brenes (https://github.com/harold-b)\n*  * Oliver Crow (https://github.com/ocrow)\n*  * Jakub Ch\\u0142api\\u0144ski (https://github.com/jchlapinski)\n*  * Brett Vickers (https://github.com/beevik)\n*  * Dominik Okwieka (https://github.com/okitec)\n*  * Remko Tron\\u00e7on (https://el-tramo.be)\n*  * Romero Malaquias (rbsm@ic.ufal.br)\n*  * Michael Drake <michael.drake@codethink.co.uk>\n*\n*  Other contributions\n*  ===================\n*\n*  The following people have contributed something other than code (e.g. reported\n*  bugs, provided ideas, etc; roughly in order of appearance):\n*\n*  * Greg Burns\n*  * Anthony Rabine\n*  * Carlos Costa\n*  * Aur\\u00e9lien Bouilland\n*  * Preet Desai (Pris Matic)\n*  * judofyr (http://www.reddit.com/user/judofyr)\n*  * Jason Woofenden\n*  * Micha\\u0142 Przyby\\u015b\n*  * Anthony Howe\n*  * Conrad Pankoff\n*  * Jim Schimpf\n*  * Rajaran Gaunker (https://github.com/zimbabao)\n*  * Andreas \\u00d6man\n*  * Doug Sanden\n*  * Josh Engebretson (https://github.com/JoshEngebretson)\n*  * Remo Eichenberger (https://github.com/remoe)\n*  * Mamod Mehyar (https://github.com/mamod)\n*  * David Demelier (https://github.com/markand)\n*  * Tim Caswell (https://github.com/creationix)\n*  * Mitchell Blank Jr (https://github.com/mitchblank)\n*  * https://github.com/yushli\n*  * Seo Sanghyeon (https://github.com/sanxiyn)\n*  * Han ChoongWoo (https://github.com/tunz)\n*  * Joshua Peek (https://github.com/josh)\n*  * Bruce E. Pascoe (https://github.com/fatcerberus)\n*  * https://github.com/Kelledin\n*  * https://github.com/sstruchtrup\n*  * Michael Drake (https://github.com/tlsa)\n*  * https://github.com/chris-y\n*  * Laurent Zubiaur (https://github.com/lzubiaur)\n*  * Neil Kolban (https://github.com/nkolban)\n*\n*  If you are accidentally missing from this list, send me an e-mail\n*  (``sami.vaarala@iki.fi``) and I'll fix the omission.\n*/\n\n/*\n *  Replacements for missing platform functions.\n *\n *  Unlike the originals, fpclassify() and signbit() replacements don't\n *  work on any floating point types, only doubles.  The C typing here\n *  mimics the standard prototypes.\n */\n\n/* #include duk_internal.h */\n/*\n *  Top-level include file to be used for all (internal) source files.\n *\n *  Source files should not include individual header files, as they\n *  have not been designed to be individually included.\n */\n\n#if !defined(DUK_INTERNAL_H_INCLUDED)\n#define DUK_INTERNAL_H_INCLUDED\n\n/*\n *  The 'duktape.h' header provides the public API, but also handles all\n *  compiler and platform specific feature detection, Duktape feature\n *  resolution, inclusion of system headers, etc.  These have been merged\n *  because the public API is also dependent on e.g. detecting appropriate\n *  C types which is quite platform/compiler specific especially for a non-C99\n *  build.  The public API is also dependent on the resolved feature set.\n *\n *  Some actions taken by the merged header (such as including system headers)\n *  are not appropriate for building a user application.  The define\n *  DUK_COMPILING_DUKTAPE allows the merged header to skip/include some\n *  sections depending on what is being built.\n */\n\n#define DUK_COMPILING_DUKTAPE\n#include \"duktape.h\"\n\n/*\n *  User declarations, e.g. prototypes for user functions used by Duktape\n *  macros.\n */\n\nDUK_USE_USER_DECLARE()\n\n/*\n *  Duktape includes (other than duk_features.h)\n *\n *  The header files expect to be included in an order which satisfies header\n *  dependencies correctly (the headers themselves don't include any other\n *  includes).  Forward declarations are used to break circular struct/typedef\n *  dependencies.\n */\n\n/* #include duk_dblunion.h */\n/*\n *  Union to access IEEE double memory representation, indexes for double\n *  memory representation, and some macros for double manipulation.\n *\n *  Also used by packed duk_tval.  Use a union for bit manipulation to\n *  minimize aliasing issues in practice.  The C99 standard does not\n *  guarantee that this should work, but it's a very widely supported\n *  practice for low level manipulation.\n *\n *  IEEE double format summary:\n *\n *    seeeeeee eeeeffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff\n *       A        B        C        D        E        F        G        H\n *\n *    s       sign bit\n *    eee...  exponent field\n *    fff...  fraction\n *\n *  See http://en.wikipedia.org/wiki/Double_precision_floating-point_format.\n *\n *  NaNs are represented as exponent 0x7ff and mantissa != 0.  The NaN is a\n *  signaling NaN when the highest bit of the mantissa is zero, and a quiet\n *  NaN when the highest bit is set.\n *\n *  At least three memory layouts are relevant here:\n *\n *    A B C D E F G H    Big endian (e.g. 68k)           DUK_USE_DOUBLE_BE\n *    H G F E D C B A    Little endian (e.g. x86)        DUK_USE_DOUBLE_LE\n *    D C B A H G F E    Mixed/cross endian (e.g. ARM)   DUK_USE_DOUBLE_ME\n *\n *  ARM is a special case: ARM double values are in mixed/cross endian\n *  format while ARM duk_uint64_t values are in standard little endian\n *  format (H G F E D C B A).  When a double is read as a duk_uint64_t\n *  from memory, the register will contain the (logical) value\n *  E F G H A B C D.  This requires some special handling below.\n *\n *  Indexes of various types (8-bit, 16-bit, 32-bit) in memory relative to\n *  the logical (big endian) order:\n *\n *  byte order      duk_uint8_t    duk_uint16_t     duk_uint32_t\n *    BE             01234567         0123               01\n *    LE             76543210         3210               10\n *    ME (ARM)       32107654         1032               01\n *\n *  Some processors may alter NaN values in a floating point load+store.\n *  For instance, on X86 a FLD + FSTP may convert a signaling NaN to a\n *  quiet one.  This is catastrophic when NaN space is used in packed\n *  duk_tval values.  See: misc/clang_aliasing.c.\n */\n\n#if !defined(DUK_DBLUNION_H_INCLUDED)\n#define DUK_DBLUNION_H_INCLUDED\n\n/*\n *  Union for accessing double parts, also serves as packed duk_tval\n */\n\nunion duk_double_union {\n\tdouble d;\n\tfloat f[2];\n#if defined(DUK_USE_64BIT_OPS)\n\tduk_uint64_t ull[1];\n#endif\n\tduk_uint32_t ui[2];\n\tduk_uint16_t us[4];\n\tduk_uint8_t uc[8];\n#if defined(DUK_USE_PACKED_TVAL)\n\tvoid *vp[2];  /* used by packed duk_tval, assumes sizeof(void *) == 4 */\n#endif\n};\n\ntypedef union duk_double_union duk_double_union;\n\n/*\n *  Indexes of various types with respect to big endian (logical) layout\n */\n\n#if defined(DUK_USE_DOUBLE_LE)\n#if defined(DUK_USE_64BIT_OPS)\n#define DUK_DBL_IDX_ULL0   0\n#endif\n#define DUK_DBL_IDX_UI0    1\n#define DUK_DBL_IDX_UI1    0\n#define DUK_DBL_IDX_US0    3\n#define DUK_DBL_IDX_US1    2\n#define DUK_DBL_IDX_US2    1\n#define DUK_DBL_IDX_US3    0\n#define DUK_DBL_IDX_UC0    7\n#define DUK_DBL_IDX_UC1    6\n#define DUK_DBL_IDX_UC2    5\n#define DUK_DBL_IDX_UC3    4\n#define DUK_DBL_IDX_UC4    3\n#define DUK_DBL_IDX_UC5    2\n#define DUK_DBL_IDX_UC6    1\n#define DUK_DBL_IDX_UC7    0\n#define DUK_DBL_IDX_VP0    DUK_DBL_IDX_UI0  /* packed tval */\n#define DUK_DBL_IDX_VP1    DUK_DBL_IDX_UI1  /* packed tval */\n#elif defined(DUK_USE_DOUBLE_BE)\n#if defined(DUK_USE_64BIT_OPS)\n#define DUK_DBL_IDX_ULL0   0\n#endif\n#define DUK_DBL_IDX_UI0    0\n#define DUK_DBL_IDX_UI1    1\n#define DUK_DBL_IDX_US0    0\n#define DUK_DBL_IDX_US1    1\n#define DUK_DBL_IDX_US2    2\n#define DUK_DBL_IDX_US3    3\n#define DUK_DBL_IDX_UC0    0\n#define DUK_DBL_IDX_UC1    1\n#define DUK_DBL_IDX_UC2    2\n#define DUK_DBL_IDX_UC3    3\n#define DUK_DBL_IDX_UC4    4\n#define DUK_DBL_IDX_UC5    5\n#define DUK_DBL_IDX_UC6    6\n#define DUK_DBL_IDX_UC7    7\n#define DUK_DBL_IDX_VP0    DUK_DBL_IDX_UI0  /* packed tval */\n#define DUK_DBL_IDX_VP1    DUK_DBL_IDX_UI1  /* packed tval */\n#elif defined(DUK_USE_DOUBLE_ME)\n#if defined(DUK_USE_64BIT_OPS)\n#define DUK_DBL_IDX_ULL0   0  /* not directly applicable, byte order differs from a double */\n#endif\n#define DUK_DBL_IDX_UI0    0\n#define DUK_DBL_IDX_UI1    1\n#define DUK_DBL_IDX_US0    1\n#define DUK_DBL_IDX_US1    0\n#define DUK_DBL_IDX_US2    3\n#define DUK_DBL_IDX_US3    2\n#define DUK_DBL_IDX_UC0    3\n#define DUK_DBL_IDX_UC1    2\n#define DUK_DBL_IDX_UC2    1\n#define DUK_DBL_IDX_UC3    0\n#define DUK_DBL_IDX_UC4    7\n#define DUK_DBL_IDX_UC5    6\n#define DUK_DBL_IDX_UC6    5\n#define DUK_DBL_IDX_UC7    4\n#define DUK_DBL_IDX_VP0    DUK_DBL_IDX_UI0  /* packed tval */\n#define DUK_DBL_IDX_VP1    DUK_DBL_IDX_UI1  /* packed tval */\n#else\n#error internal error\n#endif\n\n/*\n *  Helper macros for reading/writing memory representation parts, used\n *  by duk_numconv.c and duk_tval.h.\n */\n\n#define DUK_DBLUNION_SET_DOUBLE(u,v)  do {  \\\n\t\t(u)->d = (v); \\\n\t} while (0)\n\n#define DUK_DBLUNION_SET_HIGH32(u,v)  do {  \\\n\t\t(u)->ui[DUK_DBL_IDX_UI0] = (duk_uint32_t) (v); \\\n\t} while (0)\n\n#if defined(DUK_USE_64BIT_OPS)\n#if defined(DUK_USE_DOUBLE_ME)\n#define DUK_DBLUNION_SET_HIGH32_ZERO_LOW32(u,v)  do { \\\n\t\t(u)->ull[DUK_DBL_IDX_ULL0] = (duk_uint64_t) (v); \\\n\t} while (0)\n#else\n#define DUK_DBLUNION_SET_HIGH32_ZERO_LOW32(u,v)  do { \\\n\t\t(u)->ull[DUK_DBL_IDX_ULL0] = ((duk_uint64_t) (v)) << 32; \\\n\t} while (0)\n#endif\n#else  /* DUK_USE_64BIT_OPS */\n#define DUK_DBLUNION_SET_HIGH32_ZERO_LOW32(u,v)  do { \\\n\t\t(u)->ui[DUK_DBL_IDX_UI0] = (duk_uint32_t) (v); \\\n\t\t(u)->ui[DUK_DBL_IDX_UI1] = (duk_uint32_t) 0; \\\n\t} while (0)\n#endif  /* DUK_USE_64BIT_OPS */\n\n#define DUK_DBLUNION_SET_LOW32(u,v)  do {  \\\n\t\t(u)->ui[DUK_DBL_IDX_UI1] = (duk_uint32_t) (v); \\\n\t} while (0)\n\n#define DUK_DBLUNION_GET_DOUBLE(u)  ((u)->d)\n#define DUK_DBLUNION_GET_HIGH32(u)  ((u)->ui[DUK_DBL_IDX_UI0])\n#define DUK_DBLUNION_GET_LOW32(u)   ((u)->ui[DUK_DBL_IDX_UI1])\n\n#if defined(DUK_USE_64BIT_OPS)\n#if defined(DUK_USE_DOUBLE_ME)\n#define DUK_DBLUNION_SET_UINT64(u,v)  do { \\\n\t\t(u)->ui[DUK_DBL_IDX_UI0] = (duk_uint32_t) ((v) >> 32); \\\n\t\t(u)->ui[DUK_DBL_IDX_UI1] = (duk_uint32_t) (v); \\\n\t} while (0)\n#define DUK_DBLUNION_GET_UINT64(u) \\\n\t((((duk_uint64_t) (u)->ui[DUK_DBL_IDX_UI0]) << 32) | \\\n\t ((duk_uint64_t) (u)->ui[DUK_DBL_IDX_UI1]))\n#else\n#define DUK_DBLUNION_SET_UINT64(u,v)  do { \\\n\t\t(u)->ull[DUK_DBL_IDX_ULL0] = (duk_uint64_t) (v); \\\n\t} while (0)\n#define DUK_DBLUNION_GET_UINT64(u)  ((u)->ull[DUK_DBL_IDX_ULL0])\n#endif\n#define DUK_DBLUNION_SET_INT64(u,v) DUK_DBLUNION_SET_UINT64((u), (duk_uint64_t) (v))\n#define DUK_DBLUNION_GET_INT64(u)   ((duk_int64_t) DUK_DBLUNION_GET_UINT64((u)))\n#endif  /* DUK_USE_64BIT_OPS */\n\n/*\n *  Double NaN manipulation macros related to NaN normalization needed when\n *  using the packed duk_tval representation.  NaN normalization is necessary\n *  to keep double values compatible with the duk_tval format.\n *\n *  When packed duk_tval is used, the NaN space is used to store pointers\n *  and other tagged values in addition to NaNs.  Actual NaNs are normalized\n *  to a specific quiet NaN.  The macros below are used by the implementation\n *  to check and normalize NaN values when they might be created.  The macros\n *  are essentially NOPs when the non-packed duk_tval representation is used.\n *\n *  A FULL check is exact and checks all bits.  A NOTFULL check is used by\n *  the packed duk_tval and works correctly for all NaNs except those that\n *  begin with 0x7ff0.  Since the 'normalized NaN' values used with packed\n *  duk_tval begin with 0x7ff8, the partial check is reliable when packed\n *  duk_tval is used.  The 0x7ff8 prefix means the normalized NaN will be a\n *  quiet NaN regardless of its remaining lower bits.\n *\n *  The ME variant below is specifically for ARM byte order, which has the\n *  feature that while doubles have a mixed byte order (32107654), unsigned\n *  long long values has a little endian byte order (76543210).  When writing\n *  a logical double value through a ULL pointer, the 32-bit words need to be\n *  swapped; hence the #if defined()s below for ULL writes with DUK_USE_DOUBLE_ME.\n *  This is not full ARM support but suffices for some environments.\n */\n\n#if defined(DUK_USE_64BIT_OPS)\n#if defined(DUK_USE_DOUBLE_ME)\n/* Macros for 64-bit ops + mixed endian doubles. */\n#define DUK__DBLUNION_SET_NAN_FULL(u)  do { \\\n\t\t(u)->ull[DUK_DBL_IDX_ULL0] = 0x000000007ff80000ULL; \\\n\t} while (0)\n#define DUK__DBLUNION_IS_NAN_FULL(u) \\\n\t((((u)->ull[DUK_DBL_IDX_ULL0] & 0x000000007ff00000ULL) == 0x000000007ff00000ULL) && \\\n\t ((((u)->ull[DUK_DBL_IDX_ULL0]) & 0xffffffff000fffffULL) != 0))\n#define DUK__DBLUNION_IS_NORMALIZED_NAN_FULL(u) \\\n\t((u)->ull[DUK_DBL_IDX_ULL0] == 0x000000007ff80000ULL)\n#define DUK__DBLUNION_IS_ANYINF(u) \\\n\t(((u)->ull[DUK_DBL_IDX_ULL0] & 0xffffffff7fffffffULL) == 0x000000007ff00000ULL)\n#define DUK__DBLUNION_IS_POSINF(u) \\\n\t((u)->ull[DUK_DBL_IDX_ULL0] == 0x000000007ff00000ULL)\n#define DUK__DBLUNION_IS_NEGINF(u) \\\n\t((u)->ull[DUK_DBL_IDX_ULL0] == 0x00000000fff00000ULL)\n#define DUK__DBLUNION_IS_ANYZERO(u) \\\n\t(((u)->ull[DUK_DBL_IDX_ULL0] & 0xffffffff7fffffffULL) == 0x0000000000000000ULL)\n#define DUK__DBLUNION_IS_POSZERO(u) \\\n\t((u)->ull[DUK_DBL_IDX_ULL0] == 0x0000000000000000ULL)\n#define DUK__DBLUNION_IS_NEGZERO(u) \\\n\t((u)->ull[DUK_DBL_IDX_ULL0] == 0x0000000080000000ULL)\n#else\n/* Macros for 64-bit ops + big/little endian doubles. */\n#define DUK__DBLUNION_SET_NAN_FULL(u)  do { \\\n\t\t(u)->ull[DUK_DBL_IDX_ULL0] = 0x7ff8000000000000ULL; \\\n\t} while (0)\n#define DUK__DBLUNION_IS_NAN_FULL(u) \\\n\t((((u)->ull[DUK_DBL_IDX_ULL0] & 0x7ff0000000000000ULL) == 0x7ff0000000000000UL) && \\\n\t ((((u)->ull[DUK_DBL_IDX_ULL0]) & 0x000fffffffffffffULL) != 0))\n#define DUK__DBLUNION_IS_NORMALIZED_NAN_FULL(u) \\\n\t((u)->ull[DUK_DBL_IDX_ULL0] == 0x7ff8000000000000ULL)\n#define DUK__DBLUNION_IS_ANYINF(u) \\\n\t(((u)->ull[DUK_DBL_IDX_ULL0] & 0x7fffffffffffffffULL) == 0x7ff0000000000000ULL)\n#define DUK__DBLUNION_IS_POSINF(u) \\\n\t((u)->ull[DUK_DBL_IDX_ULL0] == 0x7ff0000000000000ULL)\n#define DUK__DBLUNION_IS_NEGINF(u) \\\n\t((u)->ull[DUK_DBL_IDX_ULL0] == 0xfff0000000000000ULL)\n#define DUK__DBLUNION_IS_ANYZERO(u) \\\n\t(((u)->ull[DUK_DBL_IDX_ULL0] & 0x7fffffffffffffffULL) == 0x0000000000000000ULL)\n#define DUK__DBLUNION_IS_POSZERO(u) \\\n\t((u)->ull[DUK_DBL_IDX_ULL0] == 0x0000000000000000ULL)\n#define DUK__DBLUNION_IS_NEGZERO(u) \\\n\t((u)->ull[DUK_DBL_IDX_ULL0] == 0x8000000000000000ULL)\n#endif\n#else  /* DUK_USE_64BIT_OPS */\n/* Macros for no 64-bit ops, any endianness. */\n#define DUK__DBLUNION_SET_NAN_FULL(u)  do { \\\n\t\t(u)->ui[DUK_DBL_IDX_UI0] = (duk_uint32_t) 0x7ff80000UL; \\\n\t\t(u)->ui[DUK_DBL_IDX_UI1] = (duk_uint32_t) 0x00000000UL; \\\n\t} while (0)\n#define DUK__DBLUNION_IS_NAN_FULL(u) \\\n\t((((u)->ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL) == 0x7ff00000UL) && \\\n\t (((u)->ui[DUK_DBL_IDX_UI0] & 0x000fffffUL) != 0 || \\\n          (u)->ui[DUK_DBL_IDX_UI1] != 0))\n#define DUK__DBLUNION_IS_NORMALIZED_NAN_FULL(u) \\\n\t(((u)->ui[DUK_DBL_IDX_UI0] == 0x7ff80000UL) && \\\n\t ((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))\n#define DUK__DBLUNION_IS_ANYINF(u) \\\n\t((((u)->ui[DUK_DBL_IDX_UI0] & 0x7fffffffUL) == 0x7ff00000UL) && \\\n\t ((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))\n#define DUK__DBLUNION_IS_POSINF(u) \\\n\t(((u)->ui[DUK_DBL_IDX_UI0] == 0x7ff00000UL) && \\\n\t ((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))\n#define DUK__DBLUNION_IS_NEGINF(u) \\\n\t(((u)->ui[DUK_DBL_IDX_UI0] == 0xfff00000UL) && \\\n\t ((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))\n#define DUK__DBLUNION_IS_ANYZERO(u) \\\n\t((((u)->ui[DUK_DBL_IDX_UI0] & 0x7fffffffUL) == 0x00000000UL) && \\\n\t ((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))\n#define DUK__DBLUNION_IS_POSZERO(u) \\\n\t(((u)->ui[DUK_DBL_IDX_UI0] == 0x00000000UL) && \\\n\t ((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))\n#define DUK__DBLUNION_IS_NEGZERO(u) \\\n\t(((u)->ui[DUK_DBL_IDX_UI0] == 0x80000000UL) && \\\n\t ((u)->ui[DUK_DBL_IDX_UI1] == 0x00000000UL))\n#endif  /* DUK_USE_64BIT_OPS */\n\n#define DUK__DBLUNION_SET_NAN_NOTFULL(u)  do { \\\n\t\t(u)->us[DUK_DBL_IDX_US0] = 0x7ff8UL; \\\n\t} while (0)\n\n#define DUK__DBLUNION_IS_NAN_NOTFULL(u) \\\n\t/* E == 0x7ff, topmost four bits of F != 0 => assume NaN */ \\\n\t((((u)->us[DUK_DBL_IDX_US0] & 0x7ff0UL) == 0x7ff0UL) && \\\n\t (((u)->us[DUK_DBL_IDX_US0] & 0x000fUL) != 0x0000UL))\n\n#define DUK__DBLUNION_IS_NORMALIZED_NAN_NOTFULL(u) \\\n\t/* E == 0x7ff, F == 8 => normalized NaN */ \\\n\t((u)->us[DUK_DBL_IDX_US0] == 0x7ff8UL)\n\n#define DUK__DBLUNION_NORMALIZE_NAN_CHECK_FULL(u)  do { \\\n\t\tif (DUK__DBLUNION_IS_NAN_FULL((u))) { \\\n\t\t\tDUK__DBLUNION_SET_NAN_FULL((u)); \\\n\t\t} \\\n\t} while (0)\n\n#define DUK__DBLUNION_NORMALIZE_NAN_CHECK_NOTFULL(u)  do { \\\n\t\tif (DUK__DBLUNION_IS_NAN_NOTFULL((u))) { \\\n\t\t\tDUK__DBLUNION_SET_NAN_NOTFULL((u)); \\\n\t\t} \\\n\t} while (0)\n\n/* Concrete macros for NaN handling used by the implementation internals.\n * Chosen so that they match the duk_tval representation: with a packed\n * duk_tval, ensure NaNs are properly normalized; with a non-packed duk_tval\n * these are essentially NOPs.\n */\n\n#if defined(DUK_USE_PACKED_TVAL)\n#if defined(DUK_USE_FULL_TVAL)\n#define DUK_DBLUNION_NORMALIZE_NAN_CHECK(u)  DUK__DBLUNION_NORMALIZE_NAN_CHECK_FULL((u))\n#define DUK_DBLUNION_IS_NAN(u)               DUK__DBLUNION_IS_NAN_FULL((u))\n#define DUK_DBLUNION_IS_NORMALIZED_NAN(u)    DUK__DBLUNION_IS_NORMALIZED_NAN_FULL((u))\n#define DUK_DBLUNION_SET_NAN(d)              DUK__DBLUNION_SET_NAN_FULL((d))\n#else\n#define DUK_DBLUNION_NORMALIZE_NAN_CHECK(u)  DUK__DBLUNION_NORMALIZE_NAN_CHECK_NOTFULL((u))\n#define DUK_DBLUNION_IS_NAN(u)               DUK__DBLUNION_IS_NAN_NOTFULL((u))\n#define DUK_DBLUNION_IS_NORMALIZED_NAN(u)    DUK__DBLUNION_IS_NORMALIZED_NAN_NOTFULL((u))\n#define DUK_DBLUNION_SET_NAN(d)              DUK__DBLUNION_SET_NAN_NOTFULL((d))\n#endif\n#define DUK_DBLUNION_IS_NORMALIZED(u) \\\n\t(!DUK_DBLUNION_IS_NAN((u)) ||  /* either not a NaN */ \\\n\t DUK_DBLUNION_IS_NORMALIZED_NAN((u)))  /* or is a normalized NaN */\n#else  /* DUK_USE_PACKED_TVAL */\n#define DUK_DBLUNION_NORMALIZE_NAN_CHECK(u)  /* nop: no need to normalize */\n#define DUK_DBLUNION_IS_NAN(u)               DUK__DBLUNION_IS_NAN_FULL((u))  /* (DUK_ISNAN((u)->d)) */\n#define DUK_DBLUNION_IS_NORMALIZED_NAN(u)    DUK__DBLUNION_IS_NAN_FULL((u))  /* (DUK_ISNAN((u)->d)) */\n#define DUK_DBLUNION_IS_NORMALIZED(u)        1  /* all doubles are considered normalized */\n#define DUK_DBLUNION_SET_NAN(u)  do { \\\n\t\t/* in non-packed representation we don't care about which NaN is used */ \\\n\t\t(u)->d = DUK_DOUBLE_NAN; \\\n\t} while (0)\n#endif  /* DUK_USE_PACKED_TVAL */\n\n#define DUK_DBLUNION_IS_ANYINF(u) DUK__DBLUNION_IS_ANYINF((u))\n#define DUK_DBLUNION_IS_POSINF(u) DUK__DBLUNION_IS_POSINF((u))\n#define DUK_DBLUNION_IS_NEGINF(u) DUK__DBLUNION_IS_NEGINF((u))\n\n#define DUK_DBLUNION_IS_ANYZERO(u) DUK__DBLUNION_IS_ANYZERO((u))\n#define DUK_DBLUNION_IS_POSZERO(u) DUK__DBLUNION_IS_POSZERO((u))\n#define DUK_DBLUNION_IS_NEGZERO(u) DUK__DBLUNION_IS_NEGZERO((u))\n\n/* XXX: native 64-bit byteswaps when available */\n\n/* 64-bit byteswap, same operation independent of target endianness. */\n#define DUK_DBLUNION_BSWAP64(u) do { \\\n\t\tduk_uint32_t duk__bswaptmp1, duk__bswaptmp2; \\\n\t\tduk__bswaptmp1 = (u)->ui[0]; \\\n\t\tduk__bswaptmp2 = (u)->ui[1]; \\\n\t\tduk__bswaptmp1 = DUK_BSWAP32(duk__bswaptmp1); \\\n\t\tduk__bswaptmp2 = DUK_BSWAP32(duk__bswaptmp2); \\\n\t\t(u)->ui[0] = duk__bswaptmp2; \\\n\t\t(u)->ui[1] = duk__bswaptmp1; \\\n\t} while (0)\n\n/* Byteswap an IEEE double in the duk_double_union from host to network\n * order.  For a big endian target this is a no-op.\n */\n#if defined(DUK_USE_DOUBLE_LE)\n#define DUK_DBLUNION_DOUBLE_HTON(u) do { \\\n\t\tduk_uint32_t duk__bswaptmp1, duk__bswaptmp2; \\\n\t\tduk__bswaptmp1 = (u)->ui[0]; \\\n\t\tduk__bswaptmp2 = (u)->ui[1]; \\\n\t\tduk__bswaptmp1 = DUK_BSWAP32(duk__bswaptmp1); \\\n\t\tduk__bswaptmp2 = DUK_BSWAP32(duk__bswaptmp2); \\\n\t\t(u)->ui[0] = duk__bswaptmp2; \\\n\t\t(u)->ui[1] = duk__bswaptmp1; \\\n\t} while (0)\n#elif defined(DUK_USE_DOUBLE_ME)\n#define DUK_DBLUNION_DOUBLE_HTON(u) do { \\\n\t\tduk_uint32_t duk__bswaptmp1, duk__bswaptmp2; \\\n\t\tduk__bswaptmp1 = (u)->ui[0]; \\\n\t\tduk__bswaptmp2 = (u)->ui[1]; \\\n\t\tduk__bswaptmp1 = DUK_BSWAP32(duk__bswaptmp1); \\\n\t\tduk__bswaptmp2 = DUK_BSWAP32(duk__bswaptmp2); \\\n\t\t(u)->ui[0] = duk__bswaptmp1; \\\n\t\t(u)->ui[1] = duk__bswaptmp2; \\\n\t} while (0)\n#elif defined(DUK_USE_DOUBLE_BE)\n#define DUK_DBLUNION_DOUBLE_HTON(u) do { } while (0)\n#else\n#error internal error, double endianness insane\n#endif\n\n/* Reverse operation is the same. */\n#define DUK_DBLUNION_DOUBLE_NTOH(u) DUK_DBLUNION_DOUBLE_HTON((u))\n\n/* Some sign bit helpers. */\n#if defined(DUK_USE_64BIT_OPS)\n#define DUK_DBLUNION_HAS_SIGNBIT(u) (((u)->ull[DUK_DBL_IDX_ULL0] & 0x8000000000000000ULL) != 0)\n#define DUK_DBLUNION_GET_SIGNBIT(u) (((u)->ull[DUK_DBL_IDX_ULL0] >> 63U))\n#else\n#define DUK_DBLUNION_HAS_SIGNBIT(u) (((u)->ui[DUK_DBL_IDX_UI0] & 0x80000000UL) != 0)\n#define DUK_DBLUNION_GET_SIGNBIT(u) (((u)->ui[DUK_DBL_IDX_UI0] >> 31U))\n#endif\n\n#endif  /* DUK_DBLUNION_H_INCLUDED */\n/* #include duk_replacements.h */\n#if !defined(DUK_REPLACEMENTS_H_INCLUDED)\n#define DUK_REPLACEMENTS_H_INCLUDED\n\n#if !defined(DUK_SINGLE_FILE)\n#if defined(DUK_USE_COMPUTED_INFINITY)\nDUK_INTERNAL_DECL double duk_computed_infinity;\n#endif\n#if defined(DUK_USE_COMPUTED_NAN)\nDUK_INTERNAL_DECL double duk_computed_nan;\n#endif\n#endif  /* !DUK_SINGLE_FILE */\n\n#if defined(DUK_USE_REPL_FPCLASSIFY)\nDUK_INTERNAL_DECL int duk_repl_fpclassify(double x);\n#endif\n#if defined(DUK_USE_REPL_SIGNBIT)\nDUK_INTERNAL_DECL int duk_repl_signbit(double x);\n#endif\n#if defined(DUK_USE_REPL_ISFINITE)\nDUK_INTERNAL_DECL int duk_repl_isfinite(double x);\n#endif\n#if defined(DUK_USE_REPL_ISNAN)\nDUK_INTERNAL_DECL int duk_repl_isnan(double x);\n#endif\n#if defined(DUK_USE_REPL_ISINF)\nDUK_INTERNAL_DECL int duk_repl_isinf(double x);\n#endif\n\n#endif  /* DUK_REPLACEMENTS_H_INCLUDED */\n/* #include duk_jmpbuf.h */\n/*\n *  Wrapper for jmp_buf.\n *\n *  This is used because jmp_buf is an array type for backward compatibility.\n *  Wrapping jmp_buf in a struct makes pointer references, sizeof, etc,\n *  behave more intuitively.\n *\n *  http://en.wikipedia.org/wiki/Setjmp.h#Member_types\n */\n\n#if !defined(DUK_JMPBUF_H_INCLUDED)\n#define DUK_JMPBUF_H_INCLUDED\n\n#if defined(DUK_USE_CPP_EXCEPTIONS)\nstruct duk_jmpbuf {\n\tduk_small_int_t dummy;  /* unused */\n};\n#else\nstruct duk_jmpbuf {\n\tDUK_JMPBUF_TYPE jb;\n};\n#endif\n\n#endif  /* DUK_JMPBUF_H_INCLUDED */\n/* #include duk_exception.h */\n/*\n *  Exception for Duktape internal throws when C++ exceptions are used\n *  for long control transfers.\n *\n *  Doesn't inherit from any exception base class to minimize the chance\n *  that user code would accidentally catch this exception.\n */\n\n#if !defined(DUK_EXCEPTION_H_INCLUDED)\n#define DUK_EXCEPTION_H_INCLUDED\n\n#if defined(DUK_USE_CPP_EXCEPTIONS)\nclass duk_internal_exception {\n\t/* intentionally empty */\n};\n#endif\n\n#endif  /* DUK_EXCEPTION_H_INCLUDED */\n/* #include duk_forwdecl.h */\n/*\n *  Forward declarations for all Duktape structures.\n */\n\n#if !defined(DUK_FORWDECL_H_INCLUDED)\n#define DUK_FORWDECL_H_INCLUDED\n\n/*\n *  Forward declarations\n */\n\n#if defined(DUK_USE_CPP_EXCEPTIONS)\nclass duk_internal_exception;\n#else\nstruct duk_jmpbuf;\n#endif\n\n/* duk_tval intentionally skipped */\nstruct duk_heaphdr;\nstruct duk_heaphdr_string;\nstruct duk_harray;\nstruct duk_hstring;\nstruct duk_hstring_external;\nstruct duk_hobject;\nstruct duk_hcompfunc;\nstruct duk_hnatfunc;\nstruct duk_hthread;\nstruct duk_hbufobj;\nstruct duk_hdecenv;\nstruct duk_hobjenv;\nstruct duk_hbuffer;\nstruct duk_hbuffer_fixed;\nstruct duk_hbuffer_dynamic;\nstruct duk_hbuffer_external;\n\nstruct duk_propaccessor;\nunion duk_propvalue;\nstruct duk_propdesc;\n\nstruct duk_heap;\nstruct duk_breakpoint;\n\nstruct duk_activation;\nstruct duk_catcher;\nstruct duk_strcache;\nstruct duk_ljstate;\nstruct duk_strtab_entry;\n\n#if defined(DUK_USE_DEBUG)\nstruct duk_fixedbuffer;\n#endif\n\nstruct duk_bitdecoder_ctx;\nstruct duk_bitencoder_ctx;\nstruct duk_bufwriter_ctx;\n\nstruct duk_token;\nstruct duk_re_token;\nstruct duk_lexer_point;\nstruct duk_lexer_ctx;\nstruct duk_lexer_codepoint;\n\nstruct duk_compiler_instr;\nstruct duk_compiler_func;\nstruct duk_compiler_ctx;\n\nstruct duk_re_matcher_ctx;\nstruct duk_re_compiler_ctx;\n\n#if defined(DUK_USE_CPP_EXCEPTIONS)\n/* no typedef */\n#else\ntypedef struct duk_jmpbuf duk_jmpbuf;\n#endif\n\n/* duk_tval intentionally skipped */\ntypedef struct duk_heaphdr duk_heaphdr;\ntypedef struct duk_heaphdr_string duk_heaphdr_string;\ntypedef struct duk_harray duk_harray;\ntypedef struct duk_hstring duk_hstring;\ntypedef struct duk_hstring_external duk_hstring_external;\ntypedef struct duk_hobject duk_hobject;\ntypedef struct duk_hcompfunc duk_hcompfunc;\ntypedef struct duk_hnatfunc duk_hnatfunc;\ntypedef struct duk_hthread duk_hthread;\ntypedef struct duk_hbufobj duk_hbufobj;\ntypedef struct duk_hdecenv duk_hdecenv;\ntypedef struct duk_hobjenv duk_hobjenv;\ntypedef struct duk_hbuffer duk_hbuffer;\ntypedef struct duk_hbuffer_fixed duk_hbuffer_fixed;\ntypedef struct duk_hbuffer_dynamic duk_hbuffer_dynamic;\ntypedef struct duk_hbuffer_external duk_hbuffer_external;\n\ntypedef struct duk_propaccessor duk_propaccessor;\ntypedef union duk_propvalue duk_propvalue;\ntypedef struct duk_propdesc duk_propdesc;\n\ntypedef struct duk_heap duk_heap;\ntypedef struct duk_breakpoint duk_breakpoint;\n\ntypedef struct duk_activation duk_activation;\ntypedef struct duk_catcher duk_catcher;\ntypedef struct duk_strcache duk_strcache;\ntypedef struct duk_ljstate duk_ljstate;\ntypedef struct duk_strtab_entry duk_strtab_entry;\n\n#if defined(DUK_USE_DEBUG)\ntypedef struct duk_fixedbuffer duk_fixedbuffer;\n#endif\n\ntypedef struct duk_bitdecoder_ctx duk_bitdecoder_ctx;\ntypedef struct duk_bitencoder_ctx duk_bitencoder_ctx;\ntypedef struct duk_bufwriter_ctx duk_bufwriter_ctx;\n\ntypedef struct duk_token duk_token;\ntypedef struct duk_re_token duk_re_token;\ntypedef struct duk_lexer_point duk_lexer_point;\ntypedef struct duk_lexer_ctx duk_lexer_ctx;\ntypedef struct duk_lexer_codepoint duk_lexer_codepoint;\n\ntypedef struct duk_compiler_instr duk_compiler_instr;\ntypedef struct duk_compiler_func duk_compiler_func;\ntypedef struct duk_compiler_ctx duk_compiler_ctx;\n\ntypedef struct duk_re_matcher_ctx duk_re_matcher_ctx;\ntypedef struct duk_re_compiler_ctx duk_re_compiler_ctx;\n\n#endif  /* DUK_FORWDECL_H_INCLUDED */\n/* #include duk_tval.h */\n/*\n *  Tagged type definition (duk_tval) and accessor macros.\n *\n *  Access all fields through the accessor macros, as the representation\n *  is quite tricky.\n *\n *  There are two packed type alternatives: an 8-byte representation\n *  based on an IEEE double (preferred for compactness), and a 12-byte\n *  representation (portability).  The latter is needed also in e.g.\n *  64-bit environments (it usually pads to 16 bytes per value).\n *\n *  Selecting the tagged type format involves many trade-offs (memory\n *  use, size and performance of generated code, portability, etc).\n *\n *  NB: because macro arguments are often expressions, macros should\n *  avoid evaluating their argument more than once.\n */\n\n#if !defined(DUK_TVAL_H_INCLUDED)\n#define DUK_TVAL_H_INCLUDED\n\n/* sanity */\n#if !defined(DUK_USE_DOUBLE_LE) && !defined(DUK_USE_DOUBLE_ME) && !defined(DUK_USE_DOUBLE_BE)\n#error unsupported: cannot determine byte order variant\n#endif\n\n#if defined(DUK_USE_PACKED_TVAL)\n/* ======================================================================== */\n\n/*\n *  Packed 8-byte representation\n */\n\n/* use duk_double_union as duk_tval directly */\ntypedef union duk_double_union duk_tval;\ntypedef struct {\n\tduk_uint16_t a;\n\tduk_uint16_t b;\n\tduk_uint16_t c;\n\tduk_uint16_t d;\n} duk_tval_unused;\n\n/* tags */\n#define DUK_TAG_NORMALIZED_NAN    0x7ff8UL   /* the NaN variant we use */\n/* avoid tag 0xfff0, no risk of confusion with negative infinity */\n#define DUK_TAG_MIN               0xfff1UL\n#if defined(DUK_USE_FASTINT)\n#define DUK_TAG_FASTINT           0xfff1UL   /* embed: integer value */\n#endif\n#define DUK_TAG_UNUSED            0xfff2UL   /* marker; not actual tagged value */\n#define DUK_TAG_UNDEFINED         0xfff3UL   /* embed: nothing */\n#define DUK_TAG_NULL              0xfff4UL   /* embed: nothing */\n#define DUK_TAG_BOOLEAN           0xfff5UL   /* embed: 0 or 1 (false or true) */\n/* DUK_TAG_NUMBER would logically go here, but it has multiple 'tags' */\n#define DUK_TAG_POINTER           0xfff6UL   /* embed: void ptr */\n#define DUK_TAG_LIGHTFUNC         0xfff7UL   /* embed: func ptr */\n#define DUK_TAG_STRING            0xfff8UL   /* embed: duk_hstring ptr */\n#define DUK_TAG_OBJECT            0xfff9UL   /* embed: duk_hobject ptr */\n#define DUK_TAG_BUFFER            0xfffaUL   /* embed: duk_hbuffer ptr */\n#define DUK_TAG_MAX               0xfffaUL\n\n/* for convenience */\n#define DUK_XTAG_BOOLEAN_FALSE    0xfff50000UL\n#define DUK_XTAG_BOOLEAN_TRUE     0xfff50001UL\n\n#define DUK_TVAL_IS_VALID_TAG(tv) \\\n\t(DUK_TVAL_GET_TAG((tv)) - DUK_TAG_MIN <= DUK_TAG_MAX - DUK_TAG_MIN)\n\n/* DUK_TVAL_UNUSED initializer for duk_tval_unused, works for any endianness. */\n#define DUK_TVAL_UNUSED_INITIALIZER() \\\n\t{ DUK_TAG_UNUSED, DUK_TAG_UNUSED, DUK_TAG_UNUSED, DUK_TAG_UNUSED }\n\n/* two casts to avoid gcc warning: \"warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]\" */\n#if defined(DUK_USE_64BIT_OPS)\n#if defined(DUK_USE_DOUBLE_ME)\n#define DUK__TVAL_SET_TAGGEDPOINTER(tv,h,tag)  do { \\\n\t\t(tv)->ull[DUK_DBL_IDX_ULL0] = (((duk_uint64_t) (tag)) << 16) | (((duk_uint64_t) (duk_uint32_t) (h)) << 32); \\\n\t} while (0)\n#else\n#define DUK__TVAL_SET_TAGGEDPOINTER(tv,h,tag)  do { \\\n\t\t(tv)->ull[DUK_DBL_IDX_ULL0] = (((duk_uint64_t) (tag)) << 48) | ((duk_uint64_t) (duk_uint32_t) (h)); \\\n\t} while (0)\n#endif\n#else  /* DUK_USE_64BIT_OPS */\n#define DUK__TVAL_SET_TAGGEDPOINTER(tv,h,tag)  do { \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk__tv = (tv); \\\n\t\tduk__tv->ui[DUK_DBL_IDX_UI0] = ((duk_uint32_t) (tag)) << 16; \\\n\t\tduk__tv->ui[DUK_DBL_IDX_UI1] = (duk_uint32_t) (h); \\\n\t} while (0)\n#endif  /* DUK_USE_64BIT_OPS */\n\n#if defined(DUK_USE_64BIT_OPS)\n/* Double casting for pointer to avoid gcc warning (cast from pointer to integer of different size) */\n#if defined(DUK_USE_DOUBLE_ME)\n#define DUK__TVAL_SET_LIGHTFUNC(tv,fp,flags)  do { \\\n\t\t(tv)->ull[DUK_DBL_IDX_ULL0] = (((duk_uint64_t) DUK_TAG_LIGHTFUNC) << 16) | \\\n\t\t                              ((duk_uint64_t) (flags)) | \\\n\t\t                              (((duk_uint64_t) (duk_uint32_t) (fp)) << 32); \\\n\t} while (0)\n#else\n#define DUK__TVAL_SET_LIGHTFUNC(tv,fp,flags)  do { \\\n\t\t(tv)->ull[DUK_DBL_IDX_ULL0] = (((duk_uint64_t) DUK_TAG_LIGHTFUNC) << 48) | \\\n\t\t                              (((duk_uint64_t) (flags)) << 32) | \\\n\t\t                              ((duk_uint64_t) (duk_uint32_t) (fp)); \\\n\t} while (0)\n#endif\n#else  /* DUK_USE_64BIT_OPS */\n#define DUK__TVAL_SET_LIGHTFUNC(tv,fp,flags)  do { \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk__tv = (tv); \\\n\t\tduk__tv->ui[DUK_DBL_IDX_UI0] = (((duk_uint32_t) DUK_TAG_LIGHTFUNC) << 16) | ((duk_uint32_t) (flags)); \\\n\t\tduk__tv->ui[DUK_DBL_IDX_UI1] = (duk_uint32_t) (fp); \\\n\t} while (0)\n#endif  /* DUK_USE_64BIT_OPS */\n\n#if defined(DUK_USE_FASTINT)\n/* Note: masking is done for 'i' to deal with negative numbers correctly */\n#if defined(DUK_USE_DOUBLE_ME)\n#define DUK__TVAL_SET_I48(tv,i)  do { \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk__tv = (tv); \\\n\t\tduk__tv->ui[DUK_DBL_IDX_UI0] = ((duk_uint32_t) DUK_TAG_FASTINT) << 16 | (((duk_uint32_t) ((i) >> 32)) & 0x0000ffffUL); \\\n\t\tduk__tv->ui[DUK_DBL_IDX_UI1] = (duk_uint32_t) (i); \\\n\t} while (0)\n#define DUK__TVAL_SET_U32(tv,i)  do { \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk__tv = (tv); \\\n\t\tduk__tv->ui[DUK_DBL_IDX_UI0] = ((duk_uint32_t) DUK_TAG_FASTINT) << 16; \\\n\t\tduk__tv->ui[DUK_DBL_IDX_UI1] = (duk_uint32_t) (i); \\\n\t} while (0)\n#else\n#define DUK__TVAL_SET_I48(tv,i)  do { \\\n\t\t(tv)->ull[DUK_DBL_IDX_ULL0] = (((duk_uint64_t) DUK_TAG_FASTINT) << 48) | (((duk_uint64_t) (i)) & 0x0000ffffffffffffULL); \\\n\t} while (0)\n#define DUK__TVAL_SET_U32(tv,i)  do { \\\n\t\t(tv)->ull[DUK_DBL_IDX_ULL0] = (((duk_uint64_t) DUK_TAG_FASTINT) << 48) | (duk_uint64_t) (i); \\\n\t} while (0)\n#endif\n\n/* This needs to go through a cast because sign extension is needed. */\n#define DUK__TVAL_SET_I32(tv,i)  do { \\\n\t\tduk_int64_t duk__tmp = (duk_int64_t) (i); \\\n\t\tDUK_TVAL_SET_I48((tv), duk__tmp); \\\n\t} while (0)\n\n/* XXX: Clumsy sign extend and masking of 16 topmost bits. */\n#if defined(DUK_USE_DOUBLE_ME)\n#define DUK__TVAL_GET_FASTINT(tv)      (((duk_int64_t) ((((duk_uint64_t) (tv)->ui[DUK_DBL_IDX_UI0]) << 32) | ((duk_uint64_t) (tv)->ui[DUK_DBL_IDX_UI1]))) << 16 >> 16)\n#else\n#define DUK__TVAL_GET_FASTINT(tv)      ((((duk_int64_t) (tv)->ull[DUK_DBL_IDX_ULL0]) << 16) >> 16)\n#endif\n#define DUK__TVAL_GET_FASTINT_U32(tv)  ((tv)->ui[DUK_DBL_IDX_UI1])\n#define DUK__TVAL_GET_FASTINT_I32(tv)  ((duk_int32_t) (tv)->ui[DUK_DBL_IDX_UI1])\n#endif  /* DUK_USE_FASTINT */\n\n#define DUK_TVAL_SET_UNDEFINED(tv)  do { \\\n\t\t(tv)->us[DUK_DBL_IDX_US0] = (duk_uint16_t) DUK_TAG_UNDEFINED; \\\n\t} while (0)\n#define DUK_TVAL_SET_UNUSED(tv)  do { \\\n\t\t(tv)->us[DUK_DBL_IDX_US0] = (duk_uint16_t) DUK_TAG_UNUSED; \\\n\t} while (0)\n#define DUK_TVAL_SET_NULL(tv)  do { \\\n\t\t(tv)->us[DUK_DBL_IDX_US0] = (duk_uint16_t) DUK_TAG_NULL; \\\n\t} while (0)\n\n#define DUK_TVAL_SET_BOOLEAN(tv,val)         DUK_DBLUNION_SET_HIGH32((tv), (((duk_uint32_t) DUK_TAG_BOOLEAN) << 16) | ((duk_uint32_t) (val)))\n\n#define DUK_TVAL_SET_NAN(tv)                 DUK_DBLUNION_SET_NAN_FULL((tv))\n\n/* Assumes that caller has normalized NaNs, otherwise trouble ahead. */\n#if defined(DUK_USE_FASTINT)\n#define DUK_TVAL_SET_DOUBLE(tv,d)  do { \\\n\t\tduk_double_t duk__dblval; \\\n\t\tduk__dblval = (d); \\\n\t\tDUK_ASSERT_DOUBLE_IS_NORMALIZED(duk__dblval); \\\n\t\tDUK_DBLUNION_SET_DOUBLE((tv), duk__dblval); \\\n\t} while (0)\n#define DUK_TVAL_SET_I48(tv,i)               DUK__TVAL_SET_I48((tv), (i))\n#define DUK_TVAL_SET_I32(tv,i)               DUK__TVAL_SET_I32((tv), (i))\n#define DUK_TVAL_SET_U32(tv,i)               DUK__TVAL_SET_U32((tv), (i))\n#define DUK_TVAL_SET_NUMBER_CHKFAST_FAST(tv,d)  duk_tval_set_number_chkfast_fast((tv), (d))\n#define DUK_TVAL_SET_NUMBER_CHKFAST_SLOW(tv,d)  duk_tval_set_number_chkfast_slow((tv), (d))\n#define DUK_TVAL_SET_NUMBER(tv,d)            DUK_TVAL_SET_DOUBLE((tv), (d))\n#define DUK_TVAL_CHKFAST_INPLACE_FAST(tv)  do { \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk_double_t duk__d; \\\n\t\tduk__tv = (tv); \\\n\t\tif (DUK_TVAL_IS_DOUBLE(duk__tv)) { \\\n\t\t\tduk__d = DUK_TVAL_GET_DOUBLE(duk__tv); \\\n\t\t\tDUK_TVAL_SET_NUMBER_CHKFAST_FAST(duk__tv, duk__d); \\\n\t\t} \\\n\t} while (0)\n#define DUK_TVAL_CHKFAST_INPLACE_SLOW(tv)  do { \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk_double_t duk__d; \\\n\t\tduk__tv = (tv); \\\n\t\tif (DUK_TVAL_IS_DOUBLE(duk__tv)) { \\\n\t\t\tduk__d = DUK_TVAL_GET_DOUBLE(duk__tv); \\\n\t\t\tDUK_TVAL_SET_NUMBER_CHKFAST_SLOW(duk__tv, duk__d); \\\n\t\t} \\\n\t} while (0)\n#else  /* DUK_USE_FASTINT */\n#define DUK_TVAL_SET_DOUBLE(tv,d)  do { \\\n\t\tduk_double_t duk__dblval; \\\n\t\tduk__dblval = (d); \\\n\t\tDUK_ASSERT_DOUBLE_IS_NORMALIZED(duk__dblval); \\\n\t\tDUK_DBLUNION_SET_DOUBLE((tv), duk__dblval); \\\n\t} while (0)\n#define DUK_TVAL_SET_I48(tv,i)               DUK_TVAL_SET_DOUBLE((tv), (duk_double_t) (i))  /* XXX: fast int-to-double */\n#define DUK_TVAL_SET_I32(tv,i)               DUK_TVAL_SET_DOUBLE((tv), (duk_double_t) (i))\n#define DUK_TVAL_SET_U32(tv,i)               DUK_TVAL_SET_DOUBLE((tv), (duk_double_t) (i))\n#define DUK_TVAL_SET_NUMBER_CHKFAST_FAST(tv,d)    DUK_TVAL_SET_DOUBLE((tv), (d))\n#define DUK_TVAL_SET_NUMBER_CHKFAST_SLOW(tv,d)    DUK_TVAL_SET_DOUBLE((tv), (d))\n#define DUK_TVAL_SET_NUMBER(tv,d)            DUK_TVAL_SET_DOUBLE((tv), (d))\n#define DUK_TVAL_CHKFAST_INPLACE_FAST(tv)  do { } while (0)\n#define DUK_TVAL_CHKFAST_INPLACE_SLOW(tv)  do { } while (0)\n#endif  /* DUK_USE_FASTINT */\n\n#define DUK_TVAL_SET_FASTINT(tv,i)           DUK_TVAL_SET_I48((tv), (i))  /* alias */\n\n#define DUK_TVAL_SET_LIGHTFUNC(tv,fp,flags)  DUK__TVAL_SET_LIGHTFUNC((tv), (fp), (flags))\n#define DUK_TVAL_SET_STRING(tv,h)            DUK__TVAL_SET_TAGGEDPOINTER((tv), (h), DUK_TAG_STRING)\n#define DUK_TVAL_SET_OBJECT(tv,h)            DUK__TVAL_SET_TAGGEDPOINTER((tv), (h), DUK_TAG_OBJECT)\n#define DUK_TVAL_SET_BUFFER(tv,h)            DUK__TVAL_SET_TAGGEDPOINTER((tv), (h), DUK_TAG_BUFFER)\n#define DUK_TVAL_SET_POINTER(tv,p)           DUK__TVAL_SET_TAGGEDPOINTER((tv), (p), DUK_TAG_POINTER)\n\n#define DUK_TVAL_SET_TVAL(tv,x)              do { *(tv) = *(x); } while (0)\n\n/* getters */\n#define DUK_TVAL_GET_BOOLEAN(tv)             ((duk_small_int_t) (tv)->us[DUK_DBL_IDX_US1])\n#if defined(DUK_USE_FASTINT)\n#define DUK_TVAL_GET_DOUBLE(tv)              ((tv)->d)\n#define DUK_TVAL_GET_FASTINT(tv)             DUK__TVAL_GET_FASTINT((tv))\n#define DUK_TVAL_GET_FASTINT_U32(tv)         DUK__TVAL_GET_FASTINT_U32((tv))\n#define DUK_TVAL_GET_FASTINT_I32(tv)         DUK__TVAL_GET_FASTINT_I32((tv))\n#define DUK_TVAL_GET_NUMBER(tv)              duk_tval_get_number_packed((tv))\n#else\n#define DUK_TVAL_GET_NUMBER(tv)              ((tv)->d)\n#define DUK_TVAL_GET_DOUBLE(tv)              ((tv)->d)\n#endif\n#define DUK_TVAL_GET_LIGHTFUNC(tv,out_fp,out_flags)  do { \\\n\t\t(out_flags) = (tv)->ui[DUK_DBL_IDX_UI0] & 0xffffUL; \\\n\t\t(out_fp) = (duk_c_function) (tv)->ui[DUK_DBL_IDX_UI1]; \\\n\t} while (0)\n#define DUK_TVAL_GET_LIGHTFUNC_FUNCPTR(tv)   ((duk_c_function) ((tv)->ui[DUK_DBL_IDX_UI1]))\n#define DUK_TVAL_GET_LIGHTFUNC_FLAGS(tv)     (((duk_small_int_t) (tv)->ui[DUK_DBL_IDX_UI0]) & 0xffffUL)\n#define DUK_TVAL_GET_STRING(tv)              ((duk_hstring *) (tv)->vp[DUK_DBL_IDX_VP1])\n#define DUK_TVAL_GET_OBJECT(tv)              ((duk_hobject *) (tv)->vp[DUK_DBL_IDX_VP1])\n#define DUK_TVAL_GET_BUFFER(tv)              ((duk_hbuffer *) (tv)->vp[DUK_DBL_IDX_VP1])\n#define DUK_TVAL_GET_POINTER(tv)             ((void *) (tv)->vp[DUK_DBL_IDX_VP1])\n#define DUK_TVAL_GET_HEAPHDR(tv)             ((duk_heaphdr *) (tv)->vp[DUK_DBL_IDX_VP1])\n\n/* decoding */\n#define DUK_TVAL_GET_TAG(tv)                 ((duk_small_uint_t) (tv)->us[DUK_DBL_IDX_US0])\n\n#define DUK_TVAL_IS_UNDEFINED(tv)            (DUK_TVAL_GET_TAG((tv)) == DUK_TAG_UNDEFINED)\n#define DUK_TVAL_IS_UNUSED(tv)               (DUK_TVAL_GET_TAG((tv)) == DUK_TAG_UNUSED)\n#define DUK_TVAL_IS_NULL(tv)                 (DUK_TVAL_GET_TAG((tv)) == DUK_TAG_NULL)\n#define DUK_TVAL_IS_BOOLEAN(tv)              (DUK_TVAL_GET_TAG((tv)) == DUK_TAG_BOOLEAN)\n#define DUK_TVAL_IS_BOOLEAN_TRUE(tv)         ((tv)->ui[DUK_DBL_IDX_UI0] == DUK_XTAG_BOOLEAN_TRUE)\n#define DUK_TVAL_IS_BOOLEAN_FALSE(tv)        ((tv)->ui[DUK_DBL_IDX_UI0] == DUK_XTAG_BOOLEAN_FALSE)\n#define DUK_TVAL_IS_LIGHTFUNC(tv)            (DUK_TVAL_GET_TAG((tv)) == DUK_TAG_LIGHTFUNC)\n#define DUK_TVAL_IS_STRING(tv)               (DUK_TVAL_GET_TAG((tv)) == DUK_TAG_STRING)\n#define DUK_TVAL_IS_OBJECT(tv)               (DUK_TVAL_GET_TAG((tv)) == DUK_TAG_OBJECT)\n#define DUK_TVAL_IS_BUFFER(tv)               (DUK_TVAL_GET_TAG((tv)) == DUK_TAG_BUFFER)\n#define DUK_TVAL_IS_POINTER(tv)              (DUK_TVAL_GET_TAG((tv)) == DUK_TAG_POINTER)\n#if defined(DUK_USE_FASTINT)\n/* 0xfff0 is -Infinity */\n#define DUK_TVAL_IS_DOUBLE(tv)               (DUK_TVAL_GET_TAG((tv)) <= 0xfff0UL)\n#define DUK_TVAL_IS_FASTINT(tv)              (DUK_TVAL_GET_TAG((tv)) == DUK_TAG_FASTINT)\n#define DUK_TVAL_IS_NUMBER(tv)               (DUK_TVAL_GET_TAG((tv)) <= 0xfff1UL)\n#else\n#define DUK_TVAL_IS_NUMBER(tv)               (DUK_TVAL_GET_TAG((tv)) <= 0xfff0UL)\n#define DUK_TVAL_IS_DOUBLE(tv)               DUK_TVAL_IS_NUMBER((tv))\n#endif\n\n/* This is performance critical because it appears in every DECREF. */\n#define DUK_TVAL_IS_HEAP_ALLOCATED(tv)       (DUK_TVAL_GET_TAG((tv)) >= DUK_TAG_STRING)\n\n#if defined(DUK_USE_FASTINT)\nDUK_INTERNAL_DECL duk_double_t duk_tval_get_number_packed(duk_tval *tv);\n#endif\n\n#else  /* DUK_USE_PACKED_TVAL */\n/* ======================================================================== */\n\n/*\n *  Portable 12-byte representation\n */\n\n/* Note: not initializing all bytes is normally not an issue: Duktape won't\n * read or use the uninitialized bytes so valgrind won't issue warnings.\n * In some special cases a harmless valgrind warning may be issued though.\n * For example, the DumpHeap debugger command writes out a compiled function's\n * 'data' area as is, including any uninitialized bytes, which causes a\n * valgrind warning.\n */\n\ntypedef struct duk_tval_struct duk_tval;\n\nstruct duk_tval_struct {\n\tduk_small_uint_t t;\n\tduk_small_uint_t v_extra;\n\tunion {\n\t\tduk_double_t d;\n\t\tduk_small_int_t i;\n#if defined(DUK_USE_FASTINT)\n\t\tduk_int64_t fi;  /* if present, forces 16-byte duk_tval */\n#endif\n\t\tvoid *voidptr;\n\t\tduk_hstring *hstring;\n\t\tduk_hobject *hobject;\n\t\tduk_hcompfunc *hcompfunc;\n\t\tduk_hnatfunc *hnatfunc;\n\t\tduk_hthread *hthread;\n\t\tduk_hbuffer *hbuffer;\n\t\tduk_heaphdr *heaphdr;\n\t\tduk_c_function lightfunc;\n\t} v;\n};\n\ntypedef struct {\n\tduk_small_uint_t t;\n\tduk_small_uint_t v_extra;\n\t/* The rest of the fields don't matter except for debug dumps and such\n\t * for which a partial initializer may trigger out-ot-bounds memory\n\t * reads.  Include a double field which is usually as large or larger\n\t * than pointers (not always however).\n\t */\n\tduk_double_t d;\n} duk_tval_unused;\n\n#define DUK_TVAL_UNUSED_INITIALIZER() \\\n\t{ DUK_TAG_UNUSED, 0, 0.0 }\n\n#define DUK_TAG_MIN                   0\n#define DUK_TAG_NUMBER                0  /* DUK_TAG_NUMBER only defined for non-packed duk_tval */\n#if defined(DUK_USE_FASTINT)\n#define DUK_TAG_FASTINT               1\n#endif\n#define DUK_TAG_UNDEFINED             2\n#define DUK_TAG_NULL                  3\n#define DUK_TAG_BOOLEAN               4\n#define DUK_TAG_POINTER               5\n#define DUK_TAG_LIGHTFUNC             6\n#define DUK_TAG_UNUSED                7  /* marker; not actual tagged type */\n#define DUK_TAG_STRING                8  /* first heap allocated, match bit boundary */\n#define DUK_TAG_OBJECT                9\n#define DUK_TAG_BUFFER                10\n#define DUK_TAG_MAX                   10\n\n#define DUK_TVAL_IS_VALID_TAG(tv) \\\n\t(DUK_TVAL_GET_TAG((tv)) - DUK_TAG_MIN <= DUK_TAG_MAX - DUK_TAG_MIN)\n\n/* DUK_TAG_NUMBER is intentionally first, as it is the default clause in code\n * to support the 8-byte representation.  Further, it is a non-heap-allocated\n * type so it should come before DUK_TAG_STRING.  Finally, it should not break\n * the tag value ranges covered by case-clauses in a switch-case.\n */\n\n/* setters */\n#define DUK_TVAL_SET_UNDEFINED(tv)  do { \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk__tv = (tv); \\\n\t\tduk__tv->t = DUK_TAG_UNDEFINED; \\\n\t} while (0)\n\n#define DUK_TVAL_SET_UNUSED(tv)  do { \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk__tv = (tv); \\\n\t\tduk__tv->t = DUK_TAG_UNUSED; \\\n\t} while (0)\n\n#define DUK_TVAL_SET_NULL(tv)  do { \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk__tv = (tv); \\\n\t\tduk__tv->t = DUK_TAG_NULL; \\\n\t} while (0)\n\n#define DUK_TVAL_SET_BOOLEAN(tv,val)  do { \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk__tv = (tv); \\\n\t\tduk__tv->t = DUK_TAG_BOOLEAN; \\\n\t\tduk__tv->v.i = (val); \\\n\t} while (0)\n\n#if defined(DUK_USE_FASTINT)\n#define DUK_TVAL_SET_DOUBLE(tv,val)  do { \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk_double_t duk__dblval; \\\n\t\tduk__dblval = (val); \\\n\t\tDUK_ASSERT_DOUBLE_IS_NORMALIZED(duk__dblval); /* nop for unpacked duk_tval */ \\\n\t\tduk__tv = (tv); \\\n\t\tduk__tv->t = DUK_TAG_NUMBER; \\\n\t\tduk__tv->v.d = duk__dblval; \\\n\t} while (0)\n#define DUK_TVAL_SET_I48(tv,val)  do { \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk__tv = (tv); \\\n\t\tduk__tv->t = DUK_TAG_FASTINT; \\\n\t\tduk__tv->v.fi = (val); \\\n\t} while (0)\n#define DUK_TVAL_SET_U32(tv,val)  do { \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk__tv = (tv); \\\n\t\tduk__tv->t = DUK_TAG_FASTINT; \\\n\t\tduk__tv->v.fi = (duk_int64_t) (val); \\\n\t} while (0)\n#define DUK_TVAL_SET_I32(tv,val)  do { \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk__tv = (tv); \\\n\t\tduk__tv->t = DUK_TAG_FASTINT; \\\n\t\tduk__tv->v.fi = (duk_int64_t) (val); \\\n\t} while (0)\n#define DUK_TVAL_SET_NUMBER_CHKFAST_FAST(tv,d) \\\n\tduk_tval_set_number_chkfast_fast((tv), (d))\n#define DUK_TVAL_SET_NUMBER_CHKFAST_SLOW(tv,d) \\\n\tduk_tval_set_number_chkfast_slow((tv), (d))\n#define DUK_TVAL_SET_NUMBER(tv,val) \\\n\tDUK_TVAL_SET_DOUBLE((tv), (val))\n#define DUK_TVAL_CHKFAST_INPLACE_FAST(tv)  do { \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk_double_t duk__d; \\\n\t\tduk__tv = (tv); \\\n\t\tif (DUK_TVAL_IS_DOUBLE(duk__tv)) { \\\n\t\t\tduk__d = DUK_TVAL_GET_DOUBLE(duk__tv); \\\n\t\t\tDUK_TVAL_SET_NUMBER_CHKFAST_FAST(duk__tv, duk__d); \\\n\t\t} \\\n\t} while (0)\n#define DUK_TVAL_CHKFAST_INPLACE_SLOW(tv)  do { \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk_double_t duk__d; \\\n\t\tduk__tv = (tv); \\\n\t\tif (DUK_TVAL_IS_DOUBLE(duk__tv)) { \\\n\t\t\tduk__d = DUK_TVAL_GET_DOUBLE(duk__tv); \\\n\t\t\tDUK_TVAL_SET_NUMBER_CHKFAST_SLOW(duk__tv, duk__d); \\\n\t\t} \\\n\t} while (0)\n#else  /* DUK_USE_FASTINT */\n#define DUK_TVAL_SET_DOUBLE(tv,d) \\\n\tDUK_TVAL_SET_NUMBER((tv), (d))\n#define DUK_TVAL_SET_I48(tv,val) \\\n\tDUK_TVAL_SET_NUMBER((tv), (duk_double_t) (val))  /* XXX: fast int-to-double */\n#define DUK_TVAL_SET_U32(tv,val) \\\n\tDUK_TVAL_SET_NUMBER((tv), (duk_double_t) (val))\n#define DUK_TVAL_SET_I32(tv,val) \\\n\tDUK_TVAL_SET_NUMBER((tv), (duk_double_t) (val))\n#define DUK_TVAL_SET_NUMBER(tv,val)  do { \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk_double_t duk__dblval; \\\n\t\tduk__dblval = (val); \\\n\t\tDUK_ASSERT_DOUBLE_IS_NORMALIZED(duk__dblval); /* nop for unpacked duk_tval */ \\\n\t\tduk__tv = (tv); \\\n\t\tduk__tv->t = DUK_TAG_NUMBER; \\\n\t\tduk__tv->v.d = duk__dblval; \\\n\t} while (0)\n#define DUK_TVAL_SET_NUMBER_CHKFAST_FAST(tv,d) \\\n\tDUK_TVAL_SET_NUMBER((tv), (d))\n#define DUK_TVAL_SET_NUMBER_CHKFAST_SLOW(tv,d) \\\n\tDUK_TVAL_SET_NUMBER((tv), (d))\n#define DUK_TVAL_CHKFAST_INPLACE_FAST(tv)  do { } while (0)\n#define DUK_TVAL_CHKFAST_INPLACE_SLOW(tv)  do { } while (0)\n#endif  /* DUK_USE_FASTINT */\n\n#define DUK_TVAL_SET_FASTINT(tv,i) \\\n\tDUK_TVAL_SET_I48((tv), (i))  /* alias */\n\n#define DUK_TVAL_SET_POINTER(tv,hptr)  do { \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk__tv = (tv); \\\n\t\tduk__tv->t = DUK_TAG_POINTER; \\\n\t\tduk__tv->v.voidptr = (hptr); \\\n\t} while (0)\n\n#define DUK_TVAL_SET_LIGHTFUNC(tv,fp,flags)  do { \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk__tv = (tv); \\\n\t\tduk__tv->t = DUK_TAG_LIGHTFUNC; \\\n\t\tduk__tv->v_extra = (flags); \\\n\t\tduk__tv->v.lightfunc = (duk_c_function) (fp); \\\n\t} while (0)\n\n#define DUK_TVAL_SET_STRING(tv,hptr)  do { \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk__tv = (tv); \\\n\t\tduk__tv->t = DUK_TAG_STRING; \\\n\t\tduk__tv->v.hstring = (hptr); \\\n\t} while (0)\n\n#define DUK_TVAL_SET_OBJECT(tv,hptr)  do { \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk__tv = (tv); \\\n\t\tduk__tv->t = DUK_TAG_OBJECT; \\\n\t\tduk__tv->v.hobject = (hptr); \\\n\t} while (0)\n\n#define DUK_TVAL_SET_BUFFER(tv,hptr)  do { \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk__tv = (tv); \\\n\t\tduk__tv->t = DUK_TAG_BUFFER; \\\n\t\tduk__tv->v.hbuffer = (hptr); \\\n\t} while (0)\n\n#define DUK_TVAL_SET_NAN(tv)  do { \\\n\t\t/* in non-packed representation we don't care about which NaN is used */ \\\n\t\tduk_tval *duk__tv; \\\n\t\tduk__tv = (tv); \\\n\t\tduk__tv->t = DUK_TAG_NUMBER; \\\n\t\tduk__tv->v.d = DUK_DOUBLE_NAN; \\\n\t} while (0)\n\n#define DUK_TVAL_SET_TVAL(tv,x)            do { *(tv) = *(x); } while (0)\n\n/* getters */\n#define DUK_TVAL_GET_BOOLEAN(tv)           ((tv)->v.i)\n#if defined(DUK_USE_FASTINT)\n#define DUK_TVAL_GET_DOUBLE(tv)            ((tv)->v.d)\n#define DUK_TVAL_GET_FASTINT(tv)           ((tv)->v.fi)\n#define DUK_TVAL_GET_FASTINT_U32(tv)       ((duk_uint32_t) ((tv)->v.fi))\n#define DUK_TVAL_GET_FASTINT_I32(tv)       ((duk_int32_t) ((tv)->v.fi))\n#if 0\n#define DUK_TVAL_GET_NUMBER(tv)            (DUK_TVAL_IS_FASTINT((tv)) ? \\\n                                               (duk_double_t) DUK_TVAL_GET_FASTINT((tv)) : \\\n                                               DUK_TVAL_GET_DOUBLE((tv)))\n#define DUK_TVAL_GET_NUMBER(tv)            duk_tval_get_number_unpacked((tv))\n#else\n/* This seems reasonable overall. */\n#define DUK_TVAL_GET_NUMBER(tv)            (DUK_TVAL_IS_FASTINT((tv)) ? \\\n                                               duk_tval_get_number_unpacked_fastint((tv)) : \\\n                                               DUK_TVAL_GET_DOUBLE((tv)))\n#endif\n#else\n#define DUK_TVAL_GET_NUMBER(tv)            ((tv)->v.d)\n#define DUK_TVAL_GET_DOUBLE(tv)            ((tv)->v.d)\n#endif  /* DUK_USE_FASTINT */\n#define DUK_TVAL_GET_POINTER(tv)           ((tv)->v.voidptr)\n#define DUK_TVAL_GET_LIGHTFUNC(tv,out_fp,out_flags)  do { \\\n\t\t(out_flags) = (duk_uint32_t) (tv)->v_extra; \\\n\t\t(out_fp) = (tv)->v.lightfunc; \\\n\t} while (0)\n#define DUK_TVAL_GET_LIGHTFUNC_FUNCPTR(tv) ((tv)->v.lightfunc)\n#define DUK_TVAL_GET_LIGHTFUNC_FLAGS(tv)   ((duk_uint32_t) ((tv)->v_extra))\n#define DUK_TVAL_GET_STRING(tv)            ((tv)->v.hstring)\n#define DUK_TVAL_GET_OBJECT(tv)            ((tv)->v.hobject)\n#define DUK_TVAL_GET_BUFFER(tv)            ((tv)->v.hbuffer)\n#define DUK_TVAL_GET_HEAPHDR(tv)           ((tv)->v.heaphdr)\n\n/* decoding */\n#define DUK_TVAL_GET_TAG(tv)               ((tv)->t)\n#define DUK_TVAL_IS_UNDEFINED(tv)          ((tv)->t == DUK_TAG_UNDEFINED)\n#define DUK_TVAL_IS_UNUSED(tv)             ((tv)->t == DUK_TAG_UNUSED)\n#define DUK_TVAL_IS_NULL(tv)               ((tv)->t == DUK_TAG_NULL)\n#define DUK_TVAL_IS_BOOLEAN(tv)            ((tv)->t == DUK_TAG_BOOLEAN)\n#define DUK_TVAL_IS_BOOLEAN_TRUE(tv)       (((tv)->t == DUK_TAG_BOOLEAN) && ((tv)->v.i != 0))\n#define DUK_TVAL_IS_BOOLEAN_FALSE(tv)      (((tv)->t == DUK_TAG_BOOLEAN) && ((tv)->v.i == 0))\n#if defined(DUK_USE_FASTINT)\n#define DUK_TVAL_IS_DOUBLE(tv)             ((tv)->t == DUK_TAG_NUMBER)\n#define DUK_TVAL_IS_FASTINT(tv)            ((tv)->t == DUK_TAG_FASTINT)\n#define DUK_TVAL_IS_NUMBER(tv)             ((tv)->t == DUK_TAG_NUMBER || \\\n                                            (tv)->t == DUK_TAG_FASTINT)\n#else\n#define DUK_TVAL_IS_NUMBER(tv)             ((tv)->t == DUK_TAG_NUMBER)\n#define DUK_TVAL_IS_DOUBLE(tv)             DUK_TVAL_IS_NUMBER((tv))\n#endif  /* DUK_USE_FASTINT */\n#define DUK_TVAL_IS_POINTER(tv)            ((tv)->t == DUK_TAG_POINTER)\n#define DUK_TVAL_IS_LIGHTFUNC(tv)          ((tv)->t == DUK_TAG_LIGHTFUNC)\n#define DUK_TVAL_IS_STRING(tv)             ((tv)->t == DUK_TAG_STRING)\n#define DUK_TVAL_IS_OBJECT(tv)             ((tv)->t == DUK_TAG_OBJECT)\n#define DUK_TVAL_IS_BUFFER(tv)             ((tv)->t == DUK_TAG_BUFFER)\n\n/* This is performance critical because it's needed for every DECREF.\n * Take advantage of the fact that the first heap allocated tag is 8,\n * so that bit 3 is set for all heap allocated tags (and never set for\n * non-heap-allocated tags).\n */\n#if 0\n#define DUK_TVAL_IS_HEAP_ALLOCATED(tv)     ((tv)->t >= DUK_TAG_STRING)\n#endif\n#define DUK_TVAL_IS_HEAP_ALLOCATED(tv)     ((tv)->t & 0x08)\n\n#if defined(DUK_USE_FASTINT)\n#if 0\nDUK_INTERNAL_DECL duk_double_t duk_tval_get_number_unpacked(duk_tval *tv);\n#endif\nDUK_INTERNAL_DECL duk_double_t duk_tval_get_number_unpacked_fastint(duk_tval *tv);\n#endif\n\n#endif  /* DUK_USE_PACKED_TVAL */\n\n/*\n *  Convenience (independent of representation)\n */\n\n#define DUK_TVAL_SET_BOOLEAN_TRUE(tv)        DUK_TVAL_SET_BOOLEAN((tv), 1)\n#define DUK_TVAL_SET_BOOLEAN_FALSE(tv)       DUK_TVAL_SET_BOOLEAN((tv), 0)\n\n#define DUK_TVAL_STRING_IS_SYMBOL(tv) \\\n\tDUK_HSTRING_HAS_SYMBOL(DUK_TVAL_GET_STRING((tv)))\n\n/* Lightfunc flags packing and unpacking. */\n/* Sign extend: 0x0000##00 -> 0x##000000 -> sign extend to 0xssssss##.\n * Avoid signed shifts due to portability limitations.\n */\n#define DUK_LFUNC_FLAGS_GET_MAGIC(lf_flags) \\\n\t((duk_int32_t) (duk_int8_t) (((duk_uint16_t) (lf_flags)) >> 8))\n#define DUK_LFUNC_FLAGS_GET_LENGTH(lf_flags) \\\n\t(((lf_flags) >> 4) & 0x0f)\n#define DUK_LFUNC_FLAGS_GET_NARGS(lf_flags) \\\n\t((lf_flags) & 0x0f)\n#define DUK_LFUNC_FLAGS_PACK(magic,length,nargs) \\\n\t(((magic) & 0xff) << 8) | ((length) << 4) | (nargs)\n\n#define DUK_LFUNC_NARGS_VARARGS             0x0f   /* varargs marker */\n#define DUK_LFUNC_NARGS_MIN                 0x00\n#define DUK_LFUNC_NARGS_MAX                 0x0e   /* max, excl. varargs marker */\n#define DUK_LFUNC_LENGTH_MIN                0x00\n#define DUK_LFUNC_LENGTH_MAX                0x0f\n#define DUK_LFUNC_MAGIC_MIN                 (-0x80)\n#define DUK_LFUNC_MAGIC_MAX                 0x7f\n\n/* fastint constants etc */\n#if defined(DUK_USE_FASTINT)\n#define DUK_FASTINT_MIN           (-0x800000000000LL)\n#define DUK_FASTINT_MAX           0x7fffffffffffLL\n#define DUK_FASTINT_BITS          48\n\nDUK_INTERNAL_DECL void duk_tval_set_number_chkfast_fast(duk_tval *tv, duk_double_t x);\nDUK_INTERNAL_DECL void duk_tval_set_number_chkfast_slow(duk_tval *tv, duk_double_t x);\n#endif\n\n#endif  /* DUK_TVAL_H_INCLUDED */\n/* #include duk_builtins.h */\n/*\n *  Automatically generated by genbuiltins.py, do not edit!\n */\n\n#if !defined(DUK_BUILTINS_H_INCLUDED)\n#define DUK_BUILTINS_H_INCLUDED\n\n#if defined(DUK_USE_ROM_STRINGS)\n#error ROM support not enabled, rerun configure.py with --rom-support\n#else  /* DUK_USE_ROM_STRINGS */\n#define DUK_STRIDX_UC_UNDEFINED                                       0                              /* 'Undefined' */\n#define DUK_HEAP_STRING_UC_UNDEFINED(heap)                            DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_UNDEFINED)\n#define DUK_HTHREAD_STRING_UC_UNDEFINED(thr)                          DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_UNDEFINED)\n#define DUK_STRIDX_UC_NULL                                            1                              /* 'Null' */\n#define DUK_HEAP_STRING_UC_NULL(heap)                                 DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_NULL)\n#define DUK_HTHREAD_STRING_UC_NULL(thr)                               DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_NULL)\n#define DUK_STRIDX_UC_SYMBOL                                          2                              /* 'Symbol' */\n#define DUK_HEAP_STRING_UC_SYMBOL(heap)                               DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_SYMBOL)\n#define DUK_HTHREAD_STRING_UC_SYMBOL(thr)                             DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_SYMBOL)\n#define DUK_STRIDX_UC_ARGUMENTS                                       3                              /* 'Arguments' */\n#define DUK_HEAP_STRING_UC_ARGUMENTS(heap)                            DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_ARGUMENTS)\n#define DUK_HTHREAD_STRING_UC_ARGUMENTS(thr)                          DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_ARGUMENTS)\n#define DUK_STRIDX_UC_OBJECT                                          4                              /* 'Object' */\n#define DUK_HEAP_STRING_UC_OBJECT(heap)                               DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_OBJECT)\n#define DUK_HTHREAD_STRING_UC_OBJECT(thr)                             DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_OBJECT)\n#define DUK_STRIDX_UC_FUNCTION                                        5                              /* 'Function' */\n#define DUK_HEAP_STRING_UC_FUNCTION(heap)                             DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_FUNCTION)\n#define DUK_HTHREAD_STRING_UC_FUNCTION(thr)                           DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_FUNCTION)\n#define DUK_STRIDX_ARRAY                                              6                              /* 'Array' */\n#define DUK_HEAP_STRING_ARRAY(heap)                                   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ARRAY)\n#define DUK_HTHREAD_STRING_ARRAY(thr)                                 DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ARRAY)\n#define DUK_STRIDX_UC_STRING                                          7                              /* 'String' */\n#define DUK_HEAP_STRING_UC_STRING(heap)                               DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_STRING)\n#define DUK_HTHREAD_STRING_UC_STRING(thr)                             DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_STRING)\n#define DUK_STRIDX_UC_BOOLEAN                                         8                              /* 'Boolean' */\n#define DUK_HEAP_STRING_UC_BOOLEAN(heap)                              DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_BOOLEAN)\n#define DUK_HTHREAD_STRING_UC_BOOLEAN(thr)                            DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_BOOLEAN)\n#define DUK_STRIDX_UC_NUMBER                                          9                              /* 'Number' */\n#define DUK_HEAP_STRING_UC_NUMBER(heap)                               DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_NUMBER)\n#define DUK_HTHREAD_STRING_UC_NUMBER(thr)                             DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_NUMBER)\n#define DUK_STRIDX_DATE                                               10                             /* 'Date' */\n#define DUK_HEAP_STRING_DATE(heap)                                    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DATE)\n#define DUK_HTHREAD_STRING_DATE(thr)                                  DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DATE)\n#define DUK_STRIDX_REG_EXP                                            11                             /* 'RegExp' */\n#define DUK_HEAP_STRING_REG_EXP(heap)                                 DUK_HEAP_GET_STRING((heap),DUK_STRIDX_REG_EXP)\n#define DUK_HTHREAD_STRING_REG_EXP(thr)                               DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_REG_EXP)\n#define DUK_STRIDX_UC_ERROR                                           12                             /* 'Error' */\n#define DUK_HEAP_STRING_UC_ERROR(heap)                                DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_ERROR)\n#define DUK_HTHREAD_STRING_UC_ERROR(thr)                              DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_ERROR)\n#define DUK_STRIDX_MATH                                               13                             /* 'Math' */\n#define DUK_HEAP_STRING_MATH(heap)                                    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_MATH)\n#define DUK_HTHREAD_STRING_MATH(thr)                                  DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_MATH)\n#define DUK_STRIDX_JSON                                               14                             /* 'JSON' */\n#define DUK_HEAP_STRING_JSON(heap)                                    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON)\n#define DUK_HTHREAD_STRING_JSON(thr)                                  DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON)\n#define DUK_STRIDX_EMPTY_STRING                                       15                             /* '' */\n#define DUK_HEAP_STRING_EMPTY_STRING(heap)                            DUK_HEAP_GET_STRING((heap),DUK_STRIDX_EMPTY_STRING)\n#define DUK_HTHREAD_STRING_EMPTY_STRING(thr)                          DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_EMPTY_STRING)\n#define DUK_STRIDX_ARRAY_BUFFER                                       16                             /* 'ArrayBuffer' */\n#define DUK_HEAP_STRING_ARRAY_BUFFER(heap)                            DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ARRAY_BUFFER)\n#define DUK_HTHREAD_STRING_ARRAY_BUFFER(thr)                          DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ARRAY_BUFFER)\n#define DUK_STRIDX_DATA_VIEW                                          17                             /* 'DataView' */\n#define DUK_HEAP_STRING_DATA_VIEW(heap)                               DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DATA_VIEW)\n#define DUK_HTHREAD_STRING_DATA_VIEW(thr)                             DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DATA_VIEW)\n#define DUK_STRIDX_INT8_ARRAY                                         18                             /* 'Int8Array' */\n#define DUK_HEAP_STRING_INT8_ARRAY(heap)                              DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT8_ARRAY)\n#define DUK_HTHREAD_STRING_INT8_ARRAY(thr)                            DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT8_ARRAY)\n#define DUK_STRIDX_UINT8_ARRAY                                        19                             /* 'Uint8Array' */\n#define DUK_HEAP_STRING_UINT8_ARRAY(heap)                             DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UINT8_ARRAY)\n#define DUK_HTHREAD_STRING_UINT8_ARRAY(thr)                           DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UINT8_ARRAY)\n#define DUK_STRIDX_UINT8_CLAMPED_ARRAY                                20                             /* 'Uint8ClampedArray' */\n#define DUK_HEAP_STRING_UINT8_CLAMPED_ARRAY(heap)                     DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UINT8_CLAMPED_ARRAY)\n#define DUK_HTHREAD_STRING_UINT8_CLAMPED_ARRAY(thr)                   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UINT8_CLAMPED_ARRAY)\n#define DUK_STRIDX_INT16_ARRAY                                        21                             /* 'Int16Array' */\n#define DUK_HEAP_STRING_INT16_ARRAY(heap)                             DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT16_ARRAY)\n#define DUK_HTHREAD_STRING_INT16_ARRAY(thr)                           DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT16_ARRAY)\n#define DUK_STRIDX_UINT16_ARRAY                                       22                             /* 'Uint16Array' */\n#define DUK_HEAP_STRING_UINT16_ARRAY(heap)                            DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UINT16_ARRAY)\n#define DUK_HTHREAD_STRING_UINT16_ARRAY(thr)                          DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UINT16_ARRAY)\n#define DUK_STRIDX_INT32_ARRAY                                        23                             /* 'Int32Array' */\n#define DUK_HEAP_STRING_INT32_ARRAY(heap)                             DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT32_ARRAY)\n#define DUK_HTHREAD_STRING_INT32_ARRAY(thr)                           DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT32_ARRAY)\n#define DUK_STRIDX_UINT32_ARRAY                                       24                             /* 'Uint32Array' */\n#define DUK_HEAP_STRING_UINT32_ARRAY(heap)                            DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UINT32_ARRAY)\n#define DUK_HTHREAD_STRING_UINT32_ARRAY(thr)                          DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UINT32_ARRAY)\n#define DUK_STRIDX_FLOAT32_ARRAY                                      25                             /* 'Float32Array' */\n#define DUK_HEAP_STRING_FLOAT32_ARRAY(heap)                           DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FLOAT32_ARRAY)\n#define DUK_HTHREAD_STRING_FLOAT32_ARRAY(thr)                         DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FLOAT32_ARRAY)\n#define DUK_STRIDX_FLOAT64_ARRAY                                      26                             /* 'Float64Array' */\n#define DUK_HEAP_STRING_FLOAT64_ARRAY(heap)                           DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FLOAT64_ARRAY)\n#define DUK_HTHREAD_STRING_FLOAT64_ARRAY(thr)                         DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FLOAT64_ARRAY)\n#define DUK_STRIDX_GLOBAL                                             27                             /* 'global' */\n#define DUK_HEAP_STRING_GLOBAL(heap)                                  DUK_HEAP_GET_STRING((heap),DUK_STRIDX_GLOBAL)\n#define DUK_HTHREAD_STRING_GLOBAL(thr)                                DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_GLOBAL)\n#define DUK_STRIDX_OBJ_ENV                                            28                             /* 'ObjEnv' */\n#define DUK_HEAP_STRING_OBJ_ENV(heap)                                 DUK_HEAP_GET_STRING((heap),DUK_STRIDX_OBJ_ENV)\n#define DUK_HTHREAD_STRING_OBJ_ENV(thr)                               DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_OBJ_ENV)\n#define DUK_STRIDX_DEC_ENV                                            29                             /* 'DecEnv' */\n#define DUK_HEAP_STRING_DEC_ENV(heap)                                 DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DEC_ENV)\n#define DUK_HTHREAD_STRING_DEC_ENV(thr)                               DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DEC_ENV)\n#define DUK_STRIDX_UC_BUFFER                                          30                             /* 'Buffer' */\n#define DUK_HEAP_STRING_UC_BUFFER(heap)                               DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_BUFFER)\n#define DUK_HTHREAD_STRING_UC_BUFFER(thr)                             DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_BUFFER)\n#define DUK_STRIDX_UC_POINTER                                         31                             /* 'Pointer' */\n#define DUK_HEAP_STRING_UC_POINTER(heap)                              DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_POINTER)\n#define DUK_HTHREAD_STRING_UC_POINTER(thr)                            DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_POINTER)\n#define DUK_STRIDX_UC_THREAD                                          32                             /* 'Thread' */\n#define DUK_HEAP_STRING_UC_THREAD(heap)                               DUK_HEAP_GET_STRING((heap),DUK_STRIDX_UC_THREAD)\n#define DUK_HTHREAD_STRING_UC_THREAD(thr)                             DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_UC_THREAD)\n#define DUK_STRIDX_EVAL                                               33                             /* 'eval' */\n#define DUK_HEAP_STRING_EVAL(heap)                                    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_EVAL)\n#define DUK_HTHREAD_STRING_EVAL(thr)                                  DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_EVAL)\n#define DUK_STRIDX_VALUE                                              34                             /* 'value' */\n#define DUK_HEAP_STRING_VALUE(heap)                                   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_VALUE)\n#define DUK_HTHREAD_STRING_VALUE(thr)                                 DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_VALUE)\n#define DUK_STRIDX_WRITABLE                                           35                             /* 'writable' */\n#define DUK_HEAP_STRING_WRITABLE(heap)                                DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WRITABLE)\n#define DUK_HTHREAD_STRING_WRITABLE(thr)                              DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WRITABLE)\n#define DUK_STRIDX_CONFIGURABLE                                       36                             /* 'configurable' */\n#define DUK_HEAP_STRING_CONFIGURABLE(heap)                            DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CONFIGURABLE)\n#define DUK_HTHREAD_STRING_CONFIGURABLE(thr)                          DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CONFIGURABLE)\n#define DUK_STRIDX_ENUMERABLE                                         37                             /* 'enumerable' */\n#define DUK_HEAP_STRING_ENUMERABLE(heap)                              DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ENUMERABLE)\n#define DUK_HTHREAD_STRING_ENUMERABLE(thr)                            DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ENUMERABLE)\n#define DUK_STRIDX_JOIN                                               38                             /* 'join' */\n#define DUK_HEAP_STRING_JOIN(heap)                                    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JOIN)\n#define DUK_HTHREAD_STRING_JOIN(thr)                                  DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JOIN)\n#define DUK_STRIDX_TO_LOCALE_STRING                                   39                             /* 'toLocaleString' */\n#define DUK_HEAP_STRING_TO_LOCALE_STRING(heap)                        DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_LOCALE_STRING)\n#define DUK_HTHREAD_STRING_TO_LOCALE_STRING(thr)                      DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_LOCALE_STRING)\n#define DUK_STRIDX_VALUE_OF                                           40                             /* 'valueOf' */\n#define DUK_HEAP_STRING_VALUE_OF(heap)                                DUK_HEAP_GET_STRING((heap),DUK_STRIDX_VALUE_OF)\n#define DUK_HTHREAD_STRING_VALUE_OF(thr)                              DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_VALUE_OF)\n#define DUK_STRIDX_TO_UTC_STRING                                      41                             /* 'toUTCString' */\n#define DUK_HEAP_STRING_TO_UTC_STRING(heap)                           DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_UTC_STRING)\n#define DUK_HTHREAD_STRING_TO_UTC_STRING(thr)                         DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_UTC_STRING)\n#define DUK_STRIDX_TO_ISO_STRING                                      42                             /* 'toISOString' */\n#define DUK_HEAP_STRING_TO_ISO_STRING(heap)                           DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_ISO_STRING)\n#define DUK_HTHREAD_STRING_TO_ISO_STRING(thr)                         DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_ISO_STRING)\n#define DUK_STRIDX_TO_GMT_STRING                                      43                             /* 'toGMTString' */\n#define DUK_HEAP_STRING_TO_GMT_STRING(heap)                           DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_GMT_STRING)\n#define DUK_HTHREAD_STRING_TO_GMT_STRING(thr)                         DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_GMT_STRING)\n#define DUK_STRIDX_SOURCE                                             44                             /* 'source' */\n#define DUK_HEAP_STRING_SOURCE(heap)                                  DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SOURCE)\n#define DUK_HTHREAD_STRING_SOURCE(thr)                                DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SOURCE)\n#define DUK_STRIDX_IGNORE_CASE                                        45                             /* 'ignoreCase' */\n#define DUK_HEAP_STRING_IGNORE_CASE(heap)                             DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IGNORE_CASE)\n#define DUK_HTHREAD_STRING_IGNORE_CASE(thr)                           DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IGNORE_CASE)\n#define DUK_STRIDX_MULTILINE                                          46                             /* 'multiline' */\n#define DUK_HEAP_STRING_MULTILINE(heap)                               DUK_HEAP_GET_STRING((heap),DUK_STRIDX_MULTILINE)\n#define DUK_HTHREAD_STRING_MULTILINE(thr)                             DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_MULTILINE)\n#define DUK_STRIDX_LAST_INDEX                                         47                             /* 'lastIndex' */\n#define DUK_HEAP_STRING_LAST_INDEX(heap)                              DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LAST_INDEX)\n#define DUK_HTHREAD_STRING_LAST_INDEX(thr)                            DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LAST_INDEX)\n#define DUK_STRIDX_FLAGS                                              48                             /* 'flags' */\n#define DUK_HEAP_STRING_FLAGS(heap)                                   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FLAGS)\n#define DUK_HTHREAD_STRING_FLAGS(thr)                                 DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FLAGS)\n#define DUK_STRIDX_INDEX                                              49                             /* 'index' */\n#define DUK_HEAP_STRING_INDEX(heap)                                   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INDEX)\n#define DUK_HTHREAD_STRING_INDEX(thr)                                 DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INDEX)\n#define DUK_STRIDX_PROTOTYPE                                          50                             /* 'prototype' */\n#define DUK_HEAP_STRING_PROTOTYPE(heap)                               DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PROTOTYPE)\n#define DUK_HTHREAD_STRING_PROTOTYPE(thr)                             DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PROTOTYPE)\n#define DUK_STRIDX_CONSTRUCTOR                                        51                             /* 'constructor' */\n#define DUK_HEAP_STRING_CONSTRUCTOR(heap)                             DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CONSTRUCTOR)\n#define DUK_HTHREAD_STRING_CONSTRUCTOR(thr)                           DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CONSTRUCTOR)\n#define DUK_STRIDX_MESSAGE                                            52                             /* 'message' */\n#define DUK_HEAP_STRING_MESSAGE(heap)                                 DUK_HEAP_GET_STRING((heap),DUK_STRIDX_MESSAGE)\n#define DUK_HTHREAD_STRING_MESSAGE(thr)                               DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_MESSAGE)\n#define DUK_STRIDX_LC_BOOLEAN                                         53                             /* 'boolean' */\n#define DUK_HEAP_STRING_LC_BOOLEAN(heap)                              DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_BOOLEAN)\n#define DUK_HTHREAD_STRING_LC_BOOLEAN(thr)                            DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_BOOLEAN)\n#define DUK_STRIDX_LC_NUMBER                                          54                             /* 'number' */\n#define DUK_HEAP_STRING_LC_NUMBER(heap)                               DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_NUMBER)\n#define DUK_HTHREAD_STRING_LC_NUMBER(thr)                             DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_NUMBER)\n#define DUK_STRIDX_LC_STRING                                          55                             /* 'string' */\n#define DUK_HEAP_STRING_LC_STRING(heap)                               DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_STRING)\n#define DUK_HTHREAD_STRING_LC_STRING(thr)                             DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_STRING)\n#define DUK_STRIDX_LC_SYMBOL                                          56                             /* 'symbol' */\n#define DUK_HEAP_STRING_LC_SYMBOL(heap)                               DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_SYMBOL)\n#define DUK_HTHREAD_STRING_LC_SYMBOL(thr)                             DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_SYMBOL)\n#define DUK_STRIDX_LC_OBJECT                                          57                             /* 'object' */\n#define DUK_HEAP_STRING_LC_OBJECT(heap)                               DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_OBJECT)\n#define DUK_HTHREAD_STRING_LC_OBJECT(thr)                             DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_OBJECT)\n#define DUK_STRIDX_LC_UNDEFINED                                       58                             /* 'undefined' */\n#define DUK_HEAP_STRING_LC_UNDEFINED(heap)                            DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_UNDEFINED)\n#define DUK_HTHREAD_STRING_LC_UNDEFINED(thr)                          DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_UNDEFINED)\n#define DUK_STRIDX_NAN                                                59                             /* 'NaN' */\n#define DUK_HEAP_STRING_NAN(heap)                                     DUK_HEAP_GET_STRING((heap),DUK_STRIDX_NAN)\n#define DUK_HTHREAD_STRING_NAN(thr)                                   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_NAN)\n#define DUK_STRIDX_INFINITY                                           60                             /* 'Infinity' */\n#define DUK_HEAP_STRING_INFINITY(heap)                                DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INFINITY)\n#define DUK_HTHREAD_STRING_INFINITY(thr)                              DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INFINITY)\n#define DUK_STRIDX_MINUS_INFINITY                                     61                             /* '-Infinity' */\n#define DUK_HEAP_STRING_MINUS_INFINITY(heap)                          DUK_HEAP_GET_STRING((heap),DUK_STRIDX_MINUS_INFINITY)\n#define DUK_HTHREAD_STRING_MINUS_INFINITY(thr)                        DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_MINUS_INFINITY)\n#define DUK_STRIDX_MINUS_ZERO                                         62                             /* '-0' */\n#define DUK_HEAP_STRING_MINUS_ZERO(heap)                              DUK_HEAP_GET_STRING((heap),DUK_STRIDX_MINUS_ZERO)\n#define DUK_HTHREAD_STRING_MINUS_ZERO(thr)                            DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_MINUS_ZERO)\n#define DUK_STRIDX_COMMA                                              63                             /* ',' */\n#define DUK_HEAP_STRING_COMMA(heap)                                   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_COMMA)\n#define DUK_HTHREAD_STRING_COMMA(thr)                                 DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_COMMA)\n#define DUK_STRIDX_NEWLINE_4SPACE                                     64                             /* '\\n    ' */\n#define DUK_HEAP_STRING_NEWLINE_4SPACE(heap)                          DUK_HEAP_GET_STRING((heap),DUK_STRIDX_NEWLINE_4SPACE)\n#define DUK_HTHREAD_STRING_NEWLINE_4SPACE(thr)                        DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_NEWLINE_4SPACE)\n#define DUK_STRIDX_BRACKETED_ELLIPSIS                                 65                             /* '[...]' */\n#define DUK_HEAP_STRING_BRACKETED_ELLIPSIS(heap)                      DUK_HEAP_GET_STRING((heap),DUK_STRIDX_BRACKETED_ELLIPSIS)\n#define DUK_HTHREAD_STRING_BRACKETED_ELLIPSIS(thr)                    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_BRACKETED_ELLIPSIS)\n#define DUK_STRIDX_INVALID_DATE                                       66                             /* 'Invalid Date' */\n#define DUK_HEAP_STRING_INVALID_DATE(heap)                            DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INVALID_DATE)\n#define DUK_HTHREAD_STRING_INVALID_DATE(thr)                          DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INVALID_DATE)\n#define DUK_STRIDX_LC_ARGUMENTS                                       67                             /* 'arguments' */\n#define DUK_HEAP_STRING_LC_ARGUMENTS(heap)                            DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_ARGUMENTS)\n#define DUK_HTHREAD_STRING_LC_ARGUMENTS(thr)                          DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_ARGUMENTS)\n#define DUK_STRIDX_CALLEE                                             68                             /* 'callee' */\n#define DUK_HEAP_STRING_CALLEE(heap)                                  DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CALLEE)\n#define DUK_HTHREAD_STRING_CALLEE(thr)                                DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CALLEE)\n#define DUK_STRIDX_CALLER                                             69                             /* 'caller' */\n#define DUK_HEAP_STRING_CALLER(heap)                                  DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CALLER)\n#define DUK_HTHREAD_STRING_CALLER(thr)                                DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CALLER)\n#define DUK_STRIDX_DELETE_PROPERTY                                    70                             /* 'deleteProperty' */\n#define DUK_HEAP_STRING_DELETE_PROPERTY(heap)                         DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DELETE_PROPERTY)\n#define DUK_HTHREAD_STRING_DELETE_PROPERTY(thr)                       DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DELETE_PROPERTY)\n#define DUK_STRIDX_GET                                                71                             /* 'get' */\n#define DUK_HEAP_STRING_GET(heap)                                     DUK_HEAP_GET_STRING((heap),DUK_STRIDX_GET)\n#define DUK_HTHREAD_STRING_GET(thr)                                   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_GET)\n#define DUK_STRIDX_HAS                                                72                             /* 'has' */\n#define DUK_HEAP_STRING_HAS(heap)                                     DUK_HEAP_GET_STRING((heap),DUK_STRIDX_HAS)\n#define DUK_HTHREAD_STRING_HAS(thr)                                   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_HAS)\n#define DUK_STRIDX_OWN_KEYS                                           73                             /* 'ownKeys' */\n#define DUK_HEAP_STRING_OWN_KEYS(heap)                                DUK_HEAP_GET_STRING((heap),DUK_STRIDX_OWN_KEYS)\n#define DUK_HTHREAD_STRING_OWN_KEYS(thr)                              DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_OWN_KEYS)\n#define DUK_STRIDX_SET_PROTOTYPE_OF                                   74                             /* 'setPrototypeOf' */\n#define DUK_HEAP_STRING_SET_PROTOTYPE_OF(heap)                        DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SET_PROTOTYPE_OF)\n#define DUK_HTHREAD_STRING_SET_PROTOTYPE_OF(thr)                      DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SET_PROTOTYPE_OF)\n#define DUK_STRIDX___PROTO__                                          75                             /* '__proto__' */\n#define DUK_HEAP_STRING___PROTO__(heap)                               DUK_HEAP_GET_STRING((heap),DUK_STRIDX___PROTO__)\n#define DUK_HTHREAD_STRING___PROTO__(thr)                             DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX___PROTO__)\n#define DUK_STRIDX_TO_STRING                                          76                             /* 'toString' */\n#define DUK_HEAP_STRING_TO_STRING(heap)                               DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_STRING)\n#define DUK_HTHREAD_STRING_TO_STRING(thr)                             DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_STRING)\n#define DUK_STRIDX_TO_JSON                                            77                             /* 'toJSON' */\n#define DUK_HEAP_STRING_TO_JSON(heap)                                 DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TO_JSON)\n#define DUK_HTHREAD_STRING_TO_JSON(thr)                               DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TO_JSON)\n#define DUK_STRIDX_TYPE                                               78                             /* 'type' */\n#define DUK_HEAP_STRING_TYPE(heap)                                    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TYPE)\n#define DUK_HTHREAD_STRING_TYPE(thr)                                  DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TYPE)\n#define DUK_STRIDX_DATA                                               79                             /* 'data' */\n#define DUK_HEAP_STRING_DATA(heap)                                    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DATA)\n#define DUK_HTHREAD_STRING_DATA(thr)                                  DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DATA)\n#define DUK_STRIDX_LENGTH                                             80                             /* 'length' */\n#define DUK_HEAP_STRING_LENGTH(heap)                                  DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LENGTH)\n#define DUK_HTHREAD_STRING_LENGTH(thr)                                DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LENGTH)\n#define DUK_STRIDX_SET                                                81                             /* 'set' */\n#define DUK_HEAP_STRING_SET(heap)                                     DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SET)\n#define DUK_HTHREAD_STRING_SET(thr)                                   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SET)\n#define DUK_STRIDX_STACK                                              82                             /* 'stack' */\n#define DUK_HEAP_STRING_STACK(heap)                                   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_STACK)\n#define DUK_HTHREAD_STRING_STACK(thr)                                 DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_STACK)\n#define DUK_STRIDX_PC                                                 83                             /* 'pc' */\n#define DUK_HEAP_STRING_PC(heap)                                      DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PC)\n#define DUK_HTHREAD_STRING_PC(thr)                                    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PC)\n#define DUK_STRIDX_LINE_NUMBER                                        84                             /* 'lineNumber' */\n#define DUK_HEAP_STRING_LINE_NUMBER(heap)                             DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LINE_NUMBER)\n#define DUK_HTHREAD_STRING_LINE_NUMBER(thr)                           DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LINE_NUMBER)\n#define DUK_STRIDX_INT_TRACEDATA                                      85                             /* '\\xffTracedata' */\n#define DUK_HEAP_STRING_INT_TRACEDATA(heap)                           DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_TRACEDATA)\n#define DUK_HTHREAD_STRING_INT_TRACEDATA(thr)                         DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_TRACEDATA)\n#define DUK_STRIDX_NAME                                               86                             /* 'name' */\n#define DUK_HEAP_STRING_NAME(heap)                                    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_NAME)\n#define DUK_HTHREAD_STRING_NAME(thr)                                  DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_NAME)\n#define DUK_STRIDX_FILE_NAME                                          87                             /* 'fileName' */\n#define DUK_HEAP_STRING_FILE_NAME(heap)                               DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FILE_NAME)\n#define DUK_HTHREAD_STRING_FILE_NAME(thr)                             DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FILE_NAME)\n#define DUK_STRIDX_LC_POINTER                                         88                             /* 'pointer' */\n#define DUK_HEAP_STRING_LC_POINTER(heap)                              DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_POINTER)\n#define DUK_HTHREAD_STRING_LC_POINTER(thr)                            DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_POINTER)\n#define DUK_STRIDX_INT_VALUE                                          89                             /* '\\xffValue' */\n#define DUK_HEAP_STRING_INT_VALUE(heap)                               DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_VALUE)\n#define DUK_HTHREAD_STRING_INT_VALUE(thr)                             DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_VALUE)\n#define DUK_STRIDX_INT_NEXT                                           90                             /* '\\xffNext' */\n#define DUK_HEAP_STRING_INT_NEXT(heap)                                DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_NEXT)\n#define DUK_HTHREAD_STRING_INT_NEXT(thr)                              DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_NEXT)\n#define DUK_STRIDX_INT_BYTECODE                                       91                             /* '\\xffBytecode' */\n#define DUK_HEAP_STRING_INT_BYTECODE(heap)                            DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_BYTECODE)\n#define DUK_HTHREAD_STRING_INT_BYTECODE(thr)                          DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_BYTECODE)\n#define DUK_STRIDX_INT_FORMALS                                        92                             /* '\\xffFormals' */\n#define DUK_HEAP_STRING_INT_FORMALS(heap)                             DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_FORMALS)\n#define DUK_HTHREAD_STRING_INT_FORMALS(thr)                           DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_FORMALS)\n#define DUK_STRIDX_INT_VARMAP                                         93                             /* '\\xffVarmap' */\n#define DUK_HEAP_STRING_INT_VARMAP(heap)                              DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_VARMAP)\n#define DUK_HTHREAD_STRING_INT_VARMAP(thr)                            DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_VARMAP)\n#define DUK_STRIDX_INT_SOURCE                                         94                             /* '\\xffSource' */\n#define DUK_HEAP_STRING_INT_SOURCE(heap)                              DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_SOURCE)\n#define DUK_HTHREAD_STRING_INT_SOURCE(thr)                            DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_SOURCE)\n#define DUK_STRIDX_INT_PC2LINE                                        95                             /* '\\xffPc2line' */\n#define DUK_HEAP_STRING_INT_PC2LINE(heap)                             DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_PC2LINE)\n#define DUK_HTHREAD_STRING_INT_PC2LINE(thr)                           DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_PC2LINE)\n#define DUK_STRIDX_INT_THIS                                           96                             /* '\\xffThis' */\n#define DUK_HEAP_STRING_INT_THIS(heap)                                DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_THIS)\n#define DUK_HTHREAD_STRING_INT_THIS(thr)                              DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_THIS)\n#define DUK_STRIDX_INT_ARGS                                           97                             /* '\\xffArgs' */\n#define DUK_HEAP_STRING_INT_ARGS(heap)                                DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_ARGS)\n#define DUK_HTHREAD_STRING_INT_ARGS(thr)                              DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_ARGS)\n#define DUK_STRIDX_INT_MAP                                            98                             /* '\\xffMap' */\n#define DUK_HEAP_STRING_INT_MAP(heap)                                 DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_MAP)\n#define DUK_HTHREAD_STRING_INT_MAP(thr)                               DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_MAP)\n#define DUK_STRIDX_INT_VARENV                                         99                             /* '\\xffVarenv' */\n#define DUK_HEAP_STRING_INT_VARENV(heap)                              DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_VARENV)\n#define DUK_HTHREAD_STRING_INT_VARENV(thr)                            DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_VARENV)\n#define DUK_STRIDX_INT_FINALIZER                                      100                            /* '\\xffFinalizer' */\n#define DUK_HEAP_STRING_INT_FINALIZER(heap)                           DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_FINALIZER)\n#define DUK_HTHREAD_STRING_INT_FINALIZER(thr)                         DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_FINALIZER)\n#define DUK_STRIDX_INT_TARGET                                         101                            /* '\\xffTarget' */\n#define DUK_HEAP_STRING_INT_TARGET(heap)                              DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_TARGET)\n#define DUK_HTHREAD_STRING_INT_TARGET(thr)                            DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_TARGET)\n#define DUK_STRIDX_INT_HANDLER                                        102                            /* '\\xffHandler' */\n#define DUK_HEAP_STRING_INT_HANDLER(heap)                             DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INT_HANDLER)\n#define DUK_HTHREAD_STRING_INT_HANDLER(thr)                           DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INT_HANDLER)\n#define DUK_STRIDX_COMPILE                                            103                            /* 'compile' */\n#define DUK_HEAP_STRING_COMPILE(heap)                                 DUK_HEAP_GET_STRING((heap),DUK_STRIDX_COMPILE)\n#define DUK_HTHREAD_STRING_COMPILE(thr)                               DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_COMPILE)\n#define DUK_STRIDX_INPUT                                              104                            /* 'input' */\n#define DUK_HEAP_STRING_INPUT(heap)                                   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INPUT)\n#define DUK_HTHREAD_STRING_INPUT(thr)                                 DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INPUT)\n#define DUK_STRIDX_ERR_CREATE                                         105                            /* 'errCreate' */\n#define DUK_HEAP_STRING_ERR_CREATE(heap)                              DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ERR_CREATE)\n#define DUK_HTHREAD_STRING_ERR_CREATE(thr)                            DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ERR_CREATE)\n#define DUK_STRIDX_ERR_THROW                                          106                            /* 'errThrow' */\n#define DUK_HEAP_STRING_ERR_THROW(heap)                               DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ERR_THROW)\n#define DUK_HTHREAD_STRING_ERR_THROW(thr)                             DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ERR_THROW)\n#define DUK_STRIDX_ENV                                                107                            /* 'env' */\n#define DUK_HEAP_STRING_ENV(heap)                                     DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ENV)\n#define DUK_HTHREAD_STRING_ENV(thr)                                   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ENV)\n#define DUK_STRIDX_HEX                                                108                            /* 'hex' */\n#define DUK_HEAP_STRING_HEX(heap)                                     DUK_HEAP_GET_STRING((heap),DUK_STRIDX_HEX)\n#define DUK_HTHREAD_STRING_HEX(thr)                                   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_HEX)\n#define DUK_STRIDX_BASE64                                             109                            /* 'base64' */\n#define DUK_HEAP_STRING_BASE64(heap)                                  DUK_HEAP_GET_STRING((heap),DUK_STRIDX_BASE64)\n#define DUK_HTHREAD_STRING_BASE64(thr)                                DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_BASE64)\n#define DUK_STRIDX_JX                                                 110                            /* 'jx' */\n#define DUK_HEAP_STRING_JX(heap)                                      DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JX)\n#define DUK_HTHREAD_STRING_JX(thr)                                    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JX)\n#define DUK_STRIDX_JC                                                 111                            /* 'jc' */\n#define DUK_HEAP_STRING_JC(heap)                                      DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JC)\n#define DUK_HTHREAD_STRING_JC(thr)                                    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JC)\n#define DUK_STRIDX_RESUME                                             112                            /* 'resume' */\n#define DUK_HEAP_STRING_RESUME(heap)                                  DUK_HEAP_GET_STRING((heap),DUK_STRIDX_RESUME)\n#define DUK_HTHREAD_STRING_RESUME(thr)                                DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_RESUME)\n#define DUK_STRIDX_JSON_EXT_UNDEFINED                                 113                            /* '{\"_undef\":true}' */\n#define DUK_HEAP_STRING_JSON_EXT_UNDEFINED(heap)                      DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_UNDEFINED)\n#define DUK_HTHREAD_STRING_JSON_EXT_UNDEFINED(thr)                    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_UNDEFINED)\n#define DUK_STRIDX_JSON_EXT_NAN                                       114                            /* '{\"_nan\":true}' */\n#define DUK_HEAP_STRING_JSON_EXT_NAN(heap)                            DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_NAN)\n#define DUK_HTHREAD_STRING_JSON_EXT_NAN(thr)                          DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_NAN)\n#define DUK_STRIDX_JSON_EXT_POSINF                                    115                            /* '{\"_inf\":true}' */\n#define DUK_HEAP_STRING_JSON_EXT_POSINF(heap)                         DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_POSINF)\n#define DUK_HTHREAD_STRING_JSON_EXT_POSINF(thr)                       DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_POSINF)\n#define DUK_STRIDX_JSON_EXT_NEGINF                                    116                            /* '{\"_ninf\":true}' */\n#define DUK_HEAP_STRING_JSON_EXT_NEGINF(heap)                         DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_NEGINF)\n#define DUK_HTHREAD_STRING_JSON_EXT_NEGINF(thr)                       DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_NEGINF)\n#define DUK_STRIDX_JSON_EXT_FUNCTION1                                 117                            /* '{\"_func\":true}' */\n#define DUK_HEAP_STRING_JSON_EXT_FUNCTION1(heap)                      DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_FUNCTION1)\n#define DUK_HTHREAD_STRING_JSON_EXT_FUNCTION1(thr)                    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_FUNCTION1)\n#define DUK_STRIDX_JSON_EXT_FUNCTION2                                 118                            /* '{_func:true}' */\n#define DUK_HEAP_STRING_JSON_EXT_FUNCTION2(heap)                      DUK_HEAP_GET_STRING((heap),DUK_STRIDX_JSON_EXT_FUNCTION2)\n#define DUK_HTHREAD_STRING_JSON_EXT_FUNCTION2(thr)                    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_JSON_EXT_FUNCTION2)\n#define DUK_STRIDX_BREAK                                              119                            /* 'break' */\n#define DUK_HEAP_STRING_BREAK(heap)                                   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_BREAK)\n#define DUK_HTHREAD_STRING_BREAK(thr)                                 DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_BREAK)\n#define DUK_STRIDX_CASE                                               120                            /* 'case' */\n#define DUK_HEAP_STRING_CASE(heap)                                    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CASE)\n#define DUK_HTHREAD_STRING_CASE(thr)                                  DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CASE)\n#define DUK_STRIDX_CATCH                                              121                            /* 'catch' */\n#define DUK_HEAP_STRING_CATCH(heap)                                   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CATCH)\n#define DUK_HTHREAD_STRING_CATCH(thr)                                 DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CATCH)\n#define DUK_STRIDX_CONTINUE                                           122                            /* 'continue' */\n#define DUK_HEAP_STRING_CONTINUE(heap)                                DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CONTINUE)\n#define DUK_HTHREAD_STRING_CONTINUE(thr)                              DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CONTINUE)\n#define DUK_STRIDX_DEBUGGER                                           123                            /* 'debugger' */\n#define DUK_HEAP_STRING_DEBUGGER(heap)                                DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DEBUGGER)\n#define DUK_HTHREAD_STRING_DEBUGGER(thr)                              DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DEBUGGER)\n#define DUK_STRIDX_DEFAULT                                            124                            /* 'default' */\n#define DUK_HEAP_STRING_DEFAULT(heap)                                 DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DEFAULT)\n#define DUK_HTHREAD_STRING_DEFAULT(thr)                               DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DEFAULT)\n#define DUK_STRIDX_DELETE                                             125                            /* 'delete' */\n#define DUK_HEAP_STRING_DELETE(heap)                                  DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DELETE)\n#define DUK_HTHREAD_STRING_DELETE(thr)                                DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DELETE)\n#define DUK_STRIDX_DO                                                 126                            /* 'do' */\n#define DUK_HEAP_STRING_DO(heap)                                      DUK_HEAP_GET_STRING((heap),DUK_STRIDX_DO)\n#define DUK_HTHREAD_STRING_DO(thr)                                    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_DO)\n#define DUK_STRIDX_ELSE                                               127                            /* 'else' */\n#define DUK_HEAP_STRING_ELSE(heap)                                    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ELSE)\n#define DUK_HTHREAD_STRING_ELSE(thr)                                  DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ELSE)\n#define DUK_STRIDX_FINALLY                                            128                            /* 'finally' */\n#define DUK_HEAP_STRING_FINALLY(heap)                                 DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FINALLY)\n#define DUK_HTHREAD_STRING_FINALLY(thr)                               DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FINALLY)\n#define DUK_STRIDX_FOR                                                129                            /* 'for' */\n#define DUK_HEAP_STRING_FOR(heap)                                     DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FOR)\n#define DUK_HTHREAD_STRING_FOR(thr)                                   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FOR)\n#define DUK_STRIDX_LC_FUNCTION                                        130                            /* 'function' */\n#define DUK_HEAP_STRING_LC_FUNCTION(heap)                             DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_FUNCTION)\n#define DUK_HTHREAD_STRING_LC_FUNCTION(thr)                           DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_FUNCTION)\n#define DUK_STRIDX_IF                                                 131                            /* 'if' */\n#define DUK_HEAP_STRING_IF(heap)                                      DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IF)\n#define DUK_HTHREAD_STRING_IF(thr)                                    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IF)\n#define DUK_STRIDX_IN                                                 132                            /* 'in' */\n#define DUK_HEAP_STRING_IN(heap)                                      DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IN)\n#define DUK_HTHREAD_STRING_IN(thr)                                    DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IN)\n#define DUK_STRIDX_INSTANCEOF                                         133                            /* 'instanceof' */\n#define DUK_HEAP_STRING_INSTANCEOF(heap)                              DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INSTANCEOF)\n#define DUK_HTHREAD_STRING_INSTANCEOF(thr)                            DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INSTANCEOF)\n#define DUK_STRIDX_NEW                                                134                            /* 'new' */\n#define DUK_HEAP_STRING_NEW(heap)                                     DUK_HEAP_GET_STRING((heap),DUK_STRIDX_NEW)\n#define DUK_HTHREAD_STRING_NEW(thr)                                   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_NEW)\n#define DUK_STRIDX_RETURN                                             135                            /* 'return' */\n#define DUK_HEAP_STRING_RETURN(heap)                                  DUK_HEAP_GET_STRING((heap),DUK_STRIDX_RETURN)\n#define DUK_HTHREAD_STRING_RETURN(thr)                                DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_RETURN)\n#define DUK_STRIDX_SWITCH                                             136                            /* 'switch' */\n#define DUK_HEAP_STRING_SWITCH(heap)                                  DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SWITCH)\n#define DUK_HTHREAD_STRING_SWITCH(thr)                                DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SWITCH)\n#define DUK_STRIDX_THIS                                               137                            /* 'this' */\n#define DUK_HEAP_STRING_THIS(heap)                                    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_THIS)\n#define DUK_HTHREAD_STRING_THIS(thr)                                  DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_THIS)\n#define DUK_STRIDX_THROW                                              138                            /* 'throw' */\n#define DUK_HEAP_STRING_THROW(heap)                                   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_THROW)\n#define DUK_HTHREAD_STRING_THROW(thr)                                 DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_THROW)\n#define DUK_STRIDX_TRY                                                139                            /* 'try' */\n#define DUK_HEAP_STRING_TRY(heap)                                     DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TRY)\n#define DUK_HTHREAD_STRING_TRY(thr)                                   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TRY)\n#define DUK_STRIDX_TYPEOF                                             140                            /* 'typeof' */\n#define DUK_HEAP_STRING_TYPEOF(heap)                                  DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TYPEOF)\n#define DUK_HTHREAD_STRING_TYPEOF(thr)                                DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TYPEOF)\n#define DUK_STRIDX_VAR                                                141                            /* 'var' */\n#define DUK_HEAP_STRING_VAR(heap)                                     DUK_HEAP_GET_STRING((heap),DUK_STRIDX_VAR)\n#define DUK_HTHREAD_STRING_VAR(thr)                                   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_VAR)\n#define DUK_STRIDX_CONST                                              142                            /* 'const' */\n#define DUK_HEAP_STRING_CONST(heap)                                   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CONST)\n#define DUK_HTHREAD_STRING_CONST(thr)                                 DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CONST)\n#define DUK_STRIDX_VOID                                               143                            /* 'void' */\n#define DUK_HEAP_STRING_VOID(heap)                                    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_VOID)\n#define DUK_HTHREAD_STRING_VOID(thr)                                  DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_VOID)\n#define DUK_STRIDX_WHILE                                              144                            /* 'while' */\n#define DUK_HEAP_STRING_WHILE(heap)                                   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WHILE)\n#define DUK_HTHREAD_STRING_WHILE(thr)                                 DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WHILE)\n#define DUK_STRIDX_WITH                                               145                            /* 'with' */\n#define DUK_HEAP_STRING_WITH(heap)                                    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_WITH)\n#define DUK_HTHREAD_STRING_WITH(thr)                                  DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_WITH)\n#define DUK_STRIDX_CLASS                                              146                            /* 'class' */\n#define DUK_HEAP_STRING_CLASS(heap)                                   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_CLASS)\n#define DUK_HTHREAD_STRING_CLASS(thr)                                 DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_CLASS)\n#define DUK_STRIDX_ENUM                                               147                            /* 'enum' */\n#define DUK_HEAP_STRING_ENUM(heap)                                    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_ENUM)\n#define DUK_HTHREAD_STRING_ENUM(thr)                                  DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_ENUM)\n#define DUK_STRIDX_EXPORT                                             148                            /* 'export' */\n#define DUK_HEAP_STRING_EXPORT(heap)                                  DUK_HEAP_GET_STRING((heap),DUK_STRIDX_EXPORT)\n#define DUK_HTHREAD_STRING_EXPORT(thr)                                DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_EXPORT)\n#define DUK_STRIDX_EXTENDS                                            149                            /* 'extends' */\n#define DUK_HEAP_STRING_EXTENDS(heap)                                 DUK_HEAP_GET_STRING((heap),DUK_STRIDX_EXTENDS)\n#define DUK_HTHREAD_STRING_EXTENDS(thr)                               DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_EXTENDS)\n#define DUK_STRIDX_IMPORT                                             150                            /* 'import' */\n#define DUK_HEAP_STRING_IMPORT(heap)                                  DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IMPORT)\n#define DUK_HTHREAD_STRING_IMPORT(thr)                                DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IMPORT)\n#define DUK_STRIDX_SUPER                                              151                            /* 'super' */\n#define DUK_HEAP_STRING_SUPER(heap)                                   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_SUPER)\n#define DUK_HTHREAD_STRING_SUPER(thr)                                 DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_SUPER)\n#define DUK_STRIDX_LC_NULL                                            152                            /* 'null' */\n#define DUK_HEAP_STRING_LC_NULL(heap)                                 DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LC_NULL)\n#define DUK_HTHREAD_STRING_LC_NULL(thr)                               DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LC_NULL)\n#define DUK_STRIDX_TRUE                                               153                            /* 'true' */\n#define DUK_HEAP_STRING_TRUE(heap)                                    DUK_HEAP_GET_STRING((heap),DUK_STRIDX_TRUE)\n#define DUK_HTHREAD_STRING_TRUE(thr)                                  DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_TRUE)\n#define DUK_STRIDX_FALSE                                              154                            /* 'false' */\n#define DUK_HEAP_STRING_FALSE(heap)                                   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_FALSE)\n#define DUK_HTHREAD_STRING_FALSE(thr)                                 DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_FALSE)\n#define DUK_STRIDX_IMPLEMENTS                                         155                            /* 'implements' */\n#define DUK_HEAP_STRING_IMPLEMENTS(heap)                              DUK_HEAP_GET_STRING((heap),DUK_STRIDX_IMPLEMENTS)\n#define DUK_HTHREAD_STRING_IMPLEMENTS(thr)                            DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_IMPLEMENTS)\n#define DUK_STRIDX_INTERFACE                                          156                            /* 'interface' */\n#define DUK_HEAP_STRING_INTERFACE(heap)                               DUK_HEAP_GET_STRING((heap),DUK_STRIDX_INTERFACE)\n#define DUK_HTHREAD_STRING_INTERFACE(thr)                             DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_INTERFACE)\n#define DUK_STRIDX_LET                                                157                            /* 'let' */\n#define DUK_HEAP_STRING_LET(heap)                                     DUK_HEAP_GET_STRING((heap),DUK_STRIDX_LET)\n#define DUK_HTHREAD_STRING_LET(thr)                                   DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_LET)\n#define DUK_STRIDX_PACKAGE                                            158                            /* 'package' */\n#define DUK_HEAP_STRING_PACKAGE(heap)                                 DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PACKAGE)\n#define DUK_HTHREAD_STRING_PACKAGE(thr)                               DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PACKAGE)\n#define DUK_STRIDX_PRIVATE                                            159                            /* 'private' */\n#define DUK_HEAP_STRING_PRIVATE(heap)                                 DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PRIVATE)\n#define DUK_HTHREAD_STRING_PRIVATE(thr)                               DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PRIVATE)\n#define DUK_STRIDX_PROTECTED                                          160                            /* 'protected' */\n#define DUK_HEAP_STRING_PROTECTED(heap)                               DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PROTECTED)\n#define DUK_HTHREAD_STRING_PROTECTED(thr)                             DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PROTECTED)\n#define DUK_STRIDX_PUBLIC                                             161                            /* 'public' */\n#define DUK_HEAP_STRING_PUBLIC(heap)                                  DUK_HEAP_GET_STRING((heap),DUK_STRIDX_PUBLIC)\n#define DUK_HTHREAD_STRING_PUBLIC(thr)                                DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_PUBLIC)\n#define DUK_STRIDX_STATIC                                             162                            /* 'static' */\n#define DUK_HEAP_STRING_STATIC(heap)                                  DUK_HEAP_GET_STRING((heap),DUK_STRIDX_STATIC)\n#define DUK_HTHREAD_STRING_STATIC(thr)                                DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_STATIC)\n#define DUK_STRIDX_YIELD                                              163                            /* 'yield' */\n#define DUK_HEAP_STRING_YIELD(heap)                                   DUK_HEAP_GET_STRING((heap),DUK_STRIDX_YIELD)\n#define DUK_HTHREAD_STRING_YIELD(thr)                                 DUK_HTHREAD_GET_STRING((thr),DUK_STRIDX_YIELD)\n\n#define DUK_HEAP_NUM_STRINGS                                          164\n#define DUK_STRIDX_START_RESERVED                                     119\n#define DUK_STRIDX_START_STRICT_RESERVED                              155\n#define DUK_STRIDX_END_RESERVED                                       164                            /* exclusive endpoint */\n\n/* To convert a heap stridx to a token number, subtract\n * DUK_STRIDX_START_RESERVED and add DUK_TOK_START_RESERVED.\n */\n#if !defined(DUK_SINGLE_FILE)\nDUK_INTERNAL_DECL const duk_uint8_t duk_strings_data[903];\n#endif  /* !DUK_SINGLE_FILE */\n#define DUK_STRDATA_MAX_STRLEN                                        17\n#define DUK_STRDATA_DATA_LENGTH                                       903\n#endif  /* DUK_USE_ROM_STRINGS */\n\n#if defined(DUK_USE_ROM_OBJECTS)\n#error RAM support not enabled, rerun configure.py with --ram-support\n#else  /* DUK_USE_ROM_OBJECTS */\nDUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_function_constructor(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_function_prototype(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_array_constructor(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_string_constructor(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_boolean_constructor(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_number_constructor(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_date_constructor(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_regexp_constructor(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_error_constructor_shared(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_type_error_thrower(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_thread_constructor(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_pointer_constructor(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_proxy_constructor(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_arraybuffer_constructor(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_dataview_constructor(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_typedarray_constructor(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_constructor(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_textencoder_constructor(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_textdecoder_constructor(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_eval(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_parse_int(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_parse_float(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_is_nan(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_is_finite(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_decode_uri(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_decode_uri_component(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_encode_uri(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_encode_uri_component(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_escape(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_global_object_unescape(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_object_getprototype_shared(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_object_setprototype_shared(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_get_own_property_descriptor(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_keys_shared(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_assign(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_create(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_define_property(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_define_properties(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_seal_freeze_shared(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_prevent_extensions(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_is_sealed_frozen_shared(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_is_extensible(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_object_constructor_is(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_to_string(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_to_locale_string(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_value_of(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_has_own_property(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_is_prototype_of(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_property_is_enumerable(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_function_prototype_to_string(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_function_prototype_apply(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_function_prototype_call(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_function_prototype_bind(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_array_constructor_is_array(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_to_string(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_join_shared(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_concat(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_pop(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_push(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_reverse(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_shift(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_slice(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_sort(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_splice(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_unshift(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_indexof_shared(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_iter_shared(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_array_prototype_reduce_shared(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_string_constructor_from_char_code(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_string_constructor_from_code_point(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_to_string(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_char_at(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_char_code_at(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_concat(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_indexof_shared(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_locale_compare(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_match(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_replace(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_search(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_slice(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_split(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_substring(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_caseconv_shared(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_trim(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_repeat(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_startswith_endswith(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_includes(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_string_prototype_substr(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_boolean_prototype_tostring_shared(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_string(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_locale_string(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_value_of(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_fixed(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_exponential(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_number_prototype_to_precision(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_date_constructor_parse(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_date_constructor_utc(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_date_constructor_now(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_tostring_shared(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_to_json(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_value_of(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_get_shared(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_get_timezone_offset(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_set_time(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_date_prototype_set_shared(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_regexp_prototype_exec(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_regexp_prototype_test(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_regexp_prototype_tostring(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_regexp_prototype_flags(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_regexp_prototype_shared_getter(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_stack_getter(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_stack_setter(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_filename_getter(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_filename_setter(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_linenumber_getter(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_linenumber_setter(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_error_prototype_to_string(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_math_object_onearg_shared(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_math_object_twoarg_shared(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_math_object_hypot(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_math_object_max(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_math_object_min(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_math_object_random(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_json_object_parse(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_json_object_stringify(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_info(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_act(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_gc(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_fin(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_enc(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_dec(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_duktape_object_compact(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_thread_yield(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_thread_resume(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_thread_current(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_pointer_prototype_tostring_shared(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_reflect_object_delete_property(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_reflect_object_get(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_reflect_object_has(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_reflect_object_set(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_arraybuffer_isview(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_typedarray_bytelength_getter(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_buffer_slice_shared(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_typedarray_byteoffset_getter(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_typedarray_buffer_getter(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_buffer_readfield(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_buffer_writefield(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_typedarray_set(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_uint8array_allocplain(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_uint8array_plainof(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_concat(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_is_encoding(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_is_buffer(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_byte_length(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_buffer_compare_shared(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_tostring(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_tojson(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_fill(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_copy(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_nodejs_buffer_write(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_textencoder_prototype_encoding_getter(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_textencoder_prototype_encode(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_textdecoder_prototype_shared_getter(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_textdecoder_prototype_decode(duk_context *ctx);\n#if !defined(DUK_SINGLE_FILE)\nDUK_INTERNAL_DECL const duk_c_function duk_bi_native_functions[166];\n#endif  /* !DUK_SINGLE_FILE */\n#define DUK_BIDX_GLOBAL                                               0\n#define DUK_BIDX_GLOBAL_ENV                                           1\n#define DUK_BIDX_OBJECT_CONSTRUCTOR                                   2\n#define DUK_BIDX_OBJECT_PROTOTYPE                                     3\n#define DUK_BIDX_FUNCTION_CONSTRUCTOR                                 4\n#define DUK_BIDX_FUNCTION_PROTOTYPE                                   5\n#define DUK_BIDX_ARRAY_CONSTRUCTOR                                    6\n#define DUK_BIDX_ARRAY_PROTOTYPE                                      7\n#define DUK_BIDX_STRING_CONSTRUCTOR                                   8\n#define DUK_BIDX_STRING_PROTOTYPE                                     9\n#define DUK_BIDX_BOOLEAN_CONSTRUCTOR                                  10\n#define DUK_BIDX_BOOLEAN_PROTOTYPE                                    11\n#define DUK_BIDX_NUMBER_CONSTRUCTOR                                   12\n#define DUK_BIDX_NUMBER_PROTOTYPE                                     13\n#define DUK_BIDX_DATE_CONSTRUCTOR                                     14\n#define DUK_BIDX_DATE_PROTOTYPE                                       15\n#define DUK_BIDX_REGEXP_CONSTRUCTOR                                   16\n#define DUK_BIDX_REGEXP_PROTOTYPE                                     17\n#define DUK_BIDX_ERROR_CONSTRUCTOR                                    18\n#define DUK_BIDX_ERROR_PROTOTYPE                                      19\n#define DUK_BIDX_EVAL_ERROR_CONSTRUCTOR                               20\n#define DUK_BIDX_EVAL_ERROR_PROTOTYPE                                 21\n#define DUK_BIDX_RANGE_ERROR_CONSTRUCTOR                              22\n#define DUK_BIDX_RANGE_ERROR_PROTOTYPE                                23\n#define DUK_BIDX_REFERENCE_ERROR_CONSTRUCTOR                          24\n#define DUK_BIDX_REFERENCE_ERROR_PROTOTYPE                            25\n#define DUK_BIDX_SYNTAX_ERROR_CONSTRUCTOR                             26\n#define DUK_BIDX_SYNTAX_ERROR_PROTOTYPE                               27\n#define DUK_BIDX_TYPE_ERROR_CONSTRUCTOR                               28\n#define DUK_BIDX_TYPE_ERROR_PROTOTYPE                                 29\n#define DUK_BIDX_URI_ERROR_CONSTRUCTOR                                30\n#define DUK_BIDX_URI_ERROR_PROTOTYPE                                  31\n#define DUK_BIDX_MATH                                                 32\n#define DUK_BIDX_JSON                                                 33\n#define DUK_BIDX_TYPE_ERROR_THROWER                                   34\n#define DUK_BIDX_DUKTAPE                                              35\n#define DUK_BIDX_THREAD_CONSTRUCTOR                                   36\n#define DUK_BIDX_THREAD_PROTOTYPE                                     37\n#define DUK_BIDX_POINTER_CONSTRUCTOR                                  38\n#define DUK_BIDX_POINTER_PROTOTYPE                                    39\n#define DUK_BIDX_DOUBLE_ERROR                                         40\n#define DUK_BIDX_PROXY_CONSTRUCTOR                                    41\n#define DUK_BIDX_REFLECT                                              42\n#define DUK_BIDX_SYMBOL_PROTOTYPE                                     43\n#define DUK_BIDX_ARRAYBUFFER_CONSTRUCTOR                              44\n#define DUK_BIDX_ARRAYBUFFER_PROTOTYPE                                45\n#define DUK_BIDX_DATAVIEW_CONSTRUCTOR                                 46\n#define DUK_BIDX_DATAVIEW_PROTOTYPE                                   47\n#define DUK_BIDX_TYPEDARRAY_CONSTRUCTOR                               48\n#define DUK_BIDX_TYPEDARRAY_PROTOTYPE                                 49\n#define DUK_BIDX_INT8ARRAY_CONSTRUCTOR                                50\n#define DUK_BIDX_INT8ARRAY_PROTOTYPE                                  51\n#define DUK_BIDX_UINT8ARRAY_CONSTRUCTOR                               52\n#define DUK_BIDX_UINT8ARRAY_PROTOTYPE                                 53\n#define DUK_BIDX_UINT8CLAMPEDARRAY_CONSTRUCTOR                        54\n#define DUK_BIDX_UINT8CLAMPEDARRAY_PROTOTYPE                          55\n#define DUK_BIDX_INT16ARRAY_CONSTRUCTOR                               56\n#define DUK_BIDX_INT16ARRAY_PROTOTYPE                                 57\n#define DUK_BIDX_UINT16ARRAY_CONSTRUCTOR                              58\n#define DUK_BIDX_UINT16ARRAY_PROTOTYPE                                59\n#define DUK_BIDX_INT32ARRAY_CONSTRUCTOR                               60\n#define DUK_BIDX_INT32ARRAY_PROTOTYPE                                 61\n#define DUK_BIDX_UINT32ARRAY_CONSTRUCTOR                              62\n#define DUK_BIDX_UINT32ARRAY_PROTOTYPE                                63\n#define DUK_BIDX_FLOAT32ARRAY_CONSTRUCTOR                             64\n#define DUK_BIDX_FLOAT32ARRAY_PROTOTYPE                               65\n#define DUK_BIDX_FLOAT64ARRAY_CONSTRUCTOR                             66\n#define DUK_BIDX_FLOAT64ARRAY_PROTOTYPE                               67\n#define DUK_BIDX_NODEJS_BUFFER_CONSTRUCTOR                            68\n#define DUK_BIDX_NODEJS_BUFFER_PROTOTYPE                              69\n#define DUK_BIDX_TEXTENCODER_CONSTRUCTOR                              70\n#define DUK_BIDX_TEXTENCODER_PROTOTYPE                                71\n#define DUK_BIDX_TEXTDECODER_CONSTRUCTOR                              72\n#define DUK_BIDX_TEXTDECODER_PROTOTYPE                                73\n#define DUK_NUM_BUILTINS                                              74\n#define DUK_NUM_BIDX_BUILTINS                                         74\n#define DUK_NUM_ALL_BUILTINS                                          74\n#if defined(DUK_USE_DOUBLE_LE)\n#if !defined(DUK_SINGLE_FILE)\nDUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[3819];\n#endif  /* !DUK_SINGLE_FILE */\n#define DUK_BUILTINS_DATA_LENGTH                                      3819\n#elif defined(DUK_USE_DOUBLE_BE)\n#if !defined(DUK_SINGLE_FILE)\nDUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[3819];\n#endif  /* !DUK_SINGLE_FILE */\n#define DUK_BUILTINS_DATA_LENGTH                                      3819\n#elif defined(DUK_USE_DOUBLE_ME)\n#if !defined(DUK_SINGLE_FILE)\nDUK_INTERNAL_DECL const duk_uint8_t duk_builtins_data[3819];\n#endif  /* !DUK_SINGLE_FILE */\n#define DUK_BUILTINS_DATA_LENGTH                                      3819\n#else\n#error invalid endianness defines\n#endif\n#endif  /* DUK_USE_ROM_OBJECTS */\n#endif  /* DUK_BUILTINS_H_INCLUDED */\n\n/* #include duk_util.h */\n/*\n *  Utilities\n */\n\n#if !defined(DUK_UTIL_H_INCLUDED)\n#define DUK_UTIL_H_INCLUDED\n\n#if defined(DUK_USE_GET_RANDOM_DOUBLE)\n#define DUK_UTIL_GET_RANDOM_DOUBLE(thr) DUK_USE_GET_RANDOM_DOUBLE((thr)->heap_udata)\n#else\n#define DUK_UTIL_GET_RANDOM_DOUBLE(thr) duk_util_tinyrandom_get_double(thr)\n#endif\n\n/*\n *  Some useful constants\n */\n\n#define DUK_DOUBLE_2TO32     4294967296.0\n#define DUK_DOUBLE_2TO31     2147483648.0\n#define DUK_DOUBLE_LOG2E     1.4426950408889634\n#define DUK_DOUBLE_LOG10E    0.4342944819032518\n\n/*\n *  Endian conversion\n */\n\n#if defined(DUK_USE_INTEGER_LE)\n#define DUK_HTON32(x) DUK_BSWAP32((x))\n#define DUK_NTOH32(x) DUK_BSWAP32((x))\n#define DUK_HTON16(x) DUK_BSWAP16((x))\n#define DUK_NTOH16(x) DUK_BSWAP16((x))\n#elif defined(DUK_USE_INTEGER_BE)\n#define DUK_HTON32(x) (x)\n#define DUK_NTOH32(x) (x)\n#define DUK_HTON16(x) (x)\n#define DUK_NTOH16(x) (x)\n#else\n#error internal error, endianness defines broken\n#endif\n\n/*\n *  Bitstream decoder\n */\n\nstruct duk_bitdecoder_ctx {\n\tconst duk_uint8_t *data;\n\tduk_size_t offset;\n\tduk_size_t length;\n\tduk_uint32_t currval;\n\tduk_small_int_t currbits;\n};\n\n#define DUK_BD_BITPACKED_STRING_MAXLEN 256\n\n/*\n *  Bitstream encoder\n */\n\nstruct duk_bitencoder_ctx {\n\tduk_uint8_t *data;\n\tduk_size_t offset;\n\tduk_size_t length;\n\tduk_uint32_t currval;\n\tduk_small_int_t currbits;\n\tduk_small_int_t truncated;\n};\n\n/*\n *  Raw write/read macros for big endian, unaligned basic values.\n *  Caller ensures there's enough space.  The macros update the pointer\n *  argument automatically on resizes.  The idiom seems a bit odd, but\n *  leads to compact code.\n */\n\n#define DUK_RAW_WRITE_U8(ptr,val)  do { \\\n\t\t*(ptr)++ = (duk_uint8_t) (val); \\\n\t} while (0)\n#define DUK_RAW_WRITE_U16_BE(ptr,val) duk_raw_write_u16_be(&(ptr), (duk_uint16_t) (val))\n#define DUK_RAW_WRITE_U32_BE(ptr,val) duk_raw_write_u32_be(&(ptr), (duk_uint32_t) (val))\n#define DUK_RAW_WRITE_DOUBLE_BE(ptr,val) duk_raw_write_double_be(&(ptr), (duk_double_t) (val))\n#define DUK_RAW_WRITE_XUTF8(ptr,val)  do { \\\n\t\t/* 'ptr' is evaluated both as LHS and RHS. */ \\\n\t\tduk_uint8_t *duk__ptr; \\\n\t\tduk_small_int_t duk__len; \\\n\t\tduk__ptr = (duk_uint8_t *) (ptr); \\\n\t\tduk__len = duk_unicode_encode_xutf8((duk_ucodepoint_t) (val), duk__ptr); \\\n\t\tduk__ptr += duk__len; \\\n\t\t(ptr) = duk__ptr; \\\n\t} while (0)\n#define DUK_RAW_WRITE_CESU8(ptr,val)  do { \\\n\t\t/* 'ptr' is evaluated both as LHS and RHS. */ \\\n\t\tduk_uint8_t *duk__ptr; \\\n\t\tduk_small_int_t duk__len; \\\n\t\tduk__ptr = (duk_uint8_t *) (ptr); \\\n\t\tduk__len = duk_unicode_encode_cesu8((duk_ucodepoint_t) (val), duk__ptr); \\\n\t\tduk__ptr += duk__len; \\\n\t\t(ptr) = duk__ptr; \\\n\t} while (0)\n\n#define DUK_RAW_READ_U8(ptr) ((duk_uint8_t) (*(ptr)++))\n#define DUK_RAW_READ_U16_BE(ptr) duk_raw_read_u16_be(&(ptr));\n#define DUK_RAW_READ_U32_BE(ptr) duk_raw_read_u32_be(&(ptr));\n#define DUK_RAW_READ_DOUBLE_BE(ptr) duk_raw_read_double_be(&(ptr));\n\n/*\n *  Buffer writer (dynamic buffer only)\n *\n *  Helper for writing to a dynamic buffer with a concept of a \"spare\" area\n *  to reduce resizes.  You can ensure there is enough space beforehand and\n *  then write for a while without further checks, relying on a stable data\n *  pointer.  Spare handling is automatic so call sites only indicate how\n *  much data they need right now.\n *\n *  There are several ways to write using bufwriter.  The best approach\n *  depends mainly on how much performance matters over code footprint.\n *  The key issues are (1) ensuring there is space and (2) keeping the\n *  pointers consistent.  Fast code should ensure space for multiple writes\n *  with one ensure call.  Fastest inner loop code can temporarily borrow\n *  the 'p' pointer but must write it back eventually.\n *\n *  Be careful to ensure all macro arguments (other than static pointers like\n *  'thr' and 'bw_ctx') are evaluated exactly once, using temporaries if\n *  necessary (if that's not possible, there should be a note near the macro).\n *  Buffer write arguments often contain arithmetic etc so this is\n *  particularly important here.\n */\n\n/* XXX: Migrate bufwriter and other read/write helpers to its own header? */\n\nstruct duk_bufwriter_ctx {\n\tduk_uint8_t *p;\n\tduk_uint8_t *p_base;\n\tduk_uint8_t *p_limit;\n\tduk_hbuffer_dynamic *buf;\n};\n\n#define DUK_BW_SPARE_ADD           64\n#define DUK_BW_SPARE_SHIFT         4    /* 2^4 -> 1/16 = 6.25% spare */\n\n/* Initialization and finalization (compaction), converting to other types. */\n\n#define DUK_BW_INIT_PUSHBUF(thr,bw_ctx,sz) do { \\\n\t\tduk_bw_init_pushbuf((thr), (bw_ctx), (sz)); \\\n\t} while (0)\n#define DUK_BW_INIT_WITHBUF(thr,bw_ctx,buf) do { \\\n\t\tduk_bw_init((thr), (bw_ctx), (buf)); \\\n\t} while (0)\n#define DUK_BW_COMPACT(thr,bw_ctx) do { \\\n\t\t/* Make underlying buffer compact to match DUK_BW_GET_SIZE(). */ \\\n\t\tduk_bw_compact((thr), (bw_ctx)); \\\n\t} while (0)\n#define DUK_BW_PUSH_AS_STRING(thr,bw_ctx) do { \\\n\t\tduk_push_lstring((duk_context *) (thr), \\\n\t\t                 (const char *) (bw_ctx)->p_base, \\\n\t\t                 (duk_size_t) ((bw_ctx)->p - (bw_ctx)->p_base)); \\\n\t} while (0)\n/* Pointers may be NULL for a while when 'buf' size is zero and before any\n * ENSURE calls have been made.  Once an ENSURE has been made, the pointers\n * are required to be non-NULL so that it's always valid to use memcpy() and\n * memmove(), even for zero size.\n */\n#define DUK_BW_ASSERT_VALID_EXPR(thr,bw_ctx) \\\n\tDUK_ASSERT_EXPR((bw_ctx) != NULL && \\\n\t                (bw_ctx)->buf != NULL && \\\n\t\t\t((DUK_HBUFFER_DYNAMIC_GET_SIZE((bw_ctx)->buf) == 0) || \\\n\t\t\t\t((bw_ctx)->p != NULL && \\\n\t\t                 (bw_ctx)->p_base != NULL && \\\n\t\t                 (bw_ctx)->p_limit != NULL && \\\n\t\t                 (bw_ctx)->p_limit >= (bw_ctx)->p_base && \\\n\t\t                 (bw_ctx)->p >= (bw_ctx)->p_base && \\\n\t\t                 (bw_ctx)->p <= (bw_ctx)->p_limit)))\n#define DUK_BW_ASSERT_VALID(thr,bw_ctx) do { \\\n\t\tDUK_BW_ASSERT_VALID_EXPR((thr), (bw_ctx)); \\\n\t} while (0)\n\n/* Working with the pointer and current size. */\n\n#define DUK_BW_GET_PTR(thr,bw_ctx) \\\n\t((bw_ctx)->p)\n#define DUK_BW_SET_PTR(thr,bw_ctx,ptr) do { \\\n\t\t(bw_ctx)->p = (ptr); \\\n\t} while (0)\n#define DUK_BW_ADD_PTR(thr,bw_ctx,delta) do { \\\n\t\t(bw_ctx)->p += (delta); \\\n\t} while (0)\n#define DUK_BW_GET_BASEPTR(thr,bw_ctx) \\\n\t((bw_ctx)->p_base)\n#define DUK_BW_GET_LIMITPTR(thr,bw_ctx) \\\n\t((bw_ctx)->p_limit)\n#define DUK_BW_GET_SIZE(thr,bw_ctx) \\\n\t((duk_size_t) ((bw_ctx)->p - (bw_ctx)->p_base))\n#define DUK_BW_SET_SIZE(thr,bw_ctx,sz) do { \\\n\t\tDUK_ASSERT((duk_size_t) (sz) <= (duk_size_t) ((bw_ctx)->p - (bw_ctx)->p_base)); \\\n\t\t(bw_ctx)->p = (bw_ctx)->p_base + (sz); \\\n\t} while (0)\n#define DUK_BW_RESET_SIZE(thr,bw_ctx) do { \\\n\t\t/* Reset to zero size, keep current limit. */ \\\n\t\t(bw_ctx)->p = (bw_ctx)->p_base; \\\n\t} while (0)\n#define DUK_BW_GET_BUFFER(thr,bw_ctx) \\\n\t((bw_ctx)->buf)\n\n/* Ensuring (reserving) space. */\n\n#define DUK_BW_ENSURE(thr,bw_ctx,sz) do { \\\n\t\tduk_size_t duk__sz, duk__space; \\\n\t\tDUK_BW_ASSERT_VALID((thr), (bw_ctx)); \\\n\t\tduk__sz = (sz); \\\n\t\tduk__space = (duk_size_t) ((bw_ctx)->p_limit - (bw_ctx)->p); \\\n\t\tif (duk__space < duk__sz) { \\\n\t\t\t(void) duk_bw_resize((thr), (bw_ctx), duk__sz); \\\n\t\t} \\\n\t} while (0)\n/* NOTE: Multiple evaluation of 'ptr' in this macro. */\n/* XXX: Rework to use an always-inline function? */\n#define DUK_BW_ENSURE_RAW(thr,bw_ctx,sz,ptr) \\\n\t(((duk_size_t) ((bw_ctx)->p_limit - (ptr)) >= (sz)) ? \\\n\t (ptr) : \\\n\t ((bw_ctx)->p = (ptr), duk_bw_resize((thr),(bw_ctx),(sz))))\n#define DUK_BW_ENSURE_GETPTR(thr,bw_ctx,sz) \\\n\tDUK_BW_ENSURE_RAW((thr), (bw_ctx), (sz), (bw_ctx)->p)\n#define DUK_BW_ASSERT_SPACE_EXPR(thr,bw_ctx,sz) \\\n\t(DUK_BW_ASSERT_VALID_EXPR((thr), (bw_ctx)), \\\n\t DUK_ASSERT_EXPR((duk_size_t) ((bw_ctx)->p_limit - (bw_ctx)->p) >= (duk_size_t) (sz)))\n#define DUK_BW_ASSERT_SPACE(thr,bw_ctx,sz) do { \\\n\t\tDUK_BW_ASSERT_SPACE_EXPR((thr), (bw_ctx), (sz)); \\\n\t} while (0)\n\n/* Miscellaneous. */\n\n#define DUK_BW_SETPTR_AND_COMPACT(thr,bw_ctx,ptr) do { \\\n\t\t(bw_ctx)->p = (ptr); \\\n\t\tduk_bw_compact((thr), (bw_ctx)); \\\n\t} while (0)\n\n/* Fast write calls which assume you control the spare beforehand.\n * Multibyte write variants exist and use a temporary write pointer\n * because byte writes alias with anything: with a stored pointer\n * explicit pointer load/stores get generated (e.g. gcc -Os).\n */\n\n#define DUK_BW_WRITE_RAW_U8(thr,bw_ctx,val) do { \\\n\t\tDUK_BW_ASSERT_SPACE((thr), (bw_ctx), 1); \\\n\t\t*(bw_ctx)->p++ = (duk_uint8_t) (val); \\\n\t} while (0)\n#define DUK_BW_WRITE_RAW_U8_2(thr,bw_ctx,val1,val2) do { \\\n\t\tduk_uint8_t *duk__p; \\\n\t\tDUK_BW_ASSERT_SPACE((thr), (bw_ctx), 2); \\\n\t\tduk__p = (bw_ctx)->p; \\\n\t\t*duk__p++ = (duk_uint8_t) (val1); \\\n\t\t*duk__p++ = (duk_uint8_t) (val2); \\\n\t\t(bw_ctx)->p = duk__p; \\\n\t} while (0)\n#define DUK_BW_WRITE_RAW_U8_3(thr,bw_ctx,val1,val2,val3) do { \\\n\t\tduk_uint8_t *duk__p; \\\n\t\tDUK_BW_ASSERT_SPACE((thr), (bw_ctx), 3); \\\n\t\tduk__p = (bw_ctx)->p; \\\n\t\t*duk__p++ = (duk_uint8_t) (val1); \\\n\t\t*duk__p++ = (duk_uint8_t) (val2); \\\n\t\t*duk__p++ = (duk_uint8_t) (val3); \\\n\t\t(bw_ctx)->p = duk__p; \\\n\t} while (0)\n#define DUK_BW_WRITE_RAW_U8_4(thr,bw_ctx,val1,val2,val3,val4) do { \\\n\t\tduk_uint8_t *duk__p; \\\n\t\tDUK_BW_ASSERT_SPACE((thr), (bw_ctx), 4); \\\n\t\tduk__p = (bw_ctx)->p; \\\n\t\t*duk__p++ = (duk_uint8_t) (val1); \\\n\t\t*duk__p++ = (duk_uint8_t) (val2); \\\n\t\t*duk__p++ = (duk_uint8_t) (val3); \\\n\t\t*duk__p++ = (duk_uint8_t) (val4); \\\n\t\t(bw_ctx)->p = duk__p; \\\n\t} while (0)\n#define DUK_BW_WRITE_RAW_U8_5(thr,bw_ctx,val1,val2,val3,val4,val5) do { \\\n\t\tduk_uint8_t *duk__p; \\\n\t\tDUK_BW_ASSERT_SPACE((thr), (bw_ctx), 5); \\\n\t\tduk__p = (bw_ctx)->p; \\\n\t\t*duk__p++ = (duk_uint8_t) (val1); \\\n\t\t*duk__p++ = (duk_uint8_t) (val2); \\\n\t\t*duk__p++ = (duk_uint8_t) (val3); \\\n\t\t*duk__p++ = (duk_uint8_t) (val4); \\\n\t\t*duk__p++ = (duk_uint8_t) (val5); \\\n\t\t(bw_ctx)->p = duk__p; \\\n\t} while (0)\n#define DUK_BW_WRITE_RAW_U8_6(thr,bw_ctx,val1,val2,val3,val4,val5,val6) do { \\\n\t\tduk_uint8_t *duk__p; \\\n\t\tDUK_BW_ASSERT_SPACE((thr), (bw_ctx), 6); \\\n\t\tduk__p = (bw_ctx)->p; \\\n\t\t*duk__p++ = (duk_uint8_t) (val1); \\\n\t\t*duk__p++ = (duk_uint8_t) (val2); \\\n\t\t*duk__p++ = (duk_uint8_t) (val3); \\\n\t\t*duk__p++ = (duk_uint8_t) (val4); \\\n\t\t*duk__p++ = (duk_uint8_t) (val5); \\\n\t\t*duk__p++ = (duk_uint8_t) (val6); \\\n\t\t(bw_ctx)->p = duk__p; \\\n\t} while (0)\n#define DUK_BW_WRITE_RAW_XUTF8(thr,bw_ctx,cp) do { \\\n\t\tduk_ucodepoint_t duk__cp; \\\n\t\tduk_small_int_t duk__enc_len; \\\n\t\tduk__cp = (cp); \\\n\t\tDUK_BW_ASSERT_SPACE((thr), (bw_ctx), duk_unicode_get_xutf8_length(duk__cp)); \\\n\t\tduk__enc_len = duk_unicode_encode_xutf8(duk__cp, (bw_ctx)->p); \\\n\t\t(bw_ctx)->p += duk__enc_len; \\\n\t} while (0)\n#define DUK_BW_WRITE_RAW_CESU8(thr,bw_ctx,cp) do { \\\n\t\tduk_ucodepoint_t duk__cp; \\\n\t\tduk_small_int_t duk__enc_len; \\\n\t\tduk__cp = (duk_ucodepoint_t) (cp); \\\n\t\tDUK_BW_ASSERT_SPACE((thr), (bw_ctx), duk_unicode_get_cesu8_length(duk__cp)); \\\n\t\tduk__enc_len = duk_unicode_encode_cesu8(duk__cp, (bw_ctx)->p); \\\n\t\t(bw_ctx)->p += duk__enc_len; \\\n\t} while (0)\n/* XXX: add temporary duk__p pointer here too; sharing */\n#define DUK_BW_WRITE_RAW_BYTES(thr,bw_ctx,valptr,valsz) do { \\\n\t\tconst void *duk__valptr; \\\n\t\tduk_size_t duk__valsz; \\\n\t\tduk__valptr = (const void *) (valptr); \\\n\t\tduk__valsz = (duk_size_t) (valsz); \\\n\t\tDUK_MEMCPY((void *) ((bw_ctx)->p), duk__valptr, duk__valsz); \\\n\t\t(bw_ctx)->p += duk__valsz; \\\n\t} while (0)\n#define DUK_BW_WRITE_RAW_CSTRING(thr,bw_ctx,val) do { \\\n\t\tconst duk_uint8_t *duk__val; \\\n\t\tduk_size_t duk__val_len; \\\n\t\tduk__val = (const duk_uint8_t *) (val); \\\n\t\tduk__val_len = DUK_STRLEN((const char *) duk__val); \\\n\t\tDUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) duk__val, duk__val_len); \\\n\t\t(bw_ctx)->p += duk__val_len; \\\n\t} while (0)\n#define DUK_BW_WRITE_RAW_HSTRING(thr,bw_ctx,val) do { \\\n\t\tduk_size_t duk__val_len; \\\n\t\tduk__val_len = DUK_HSTRING_GET_BYTELEN((val)); \\\n\t\tDUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HSTRING_GET_DATA((val)), duk__val_len); \\\n\t\t(bw_ctx)->p += duk__val_len; \\\n\t} while (0)\n#define DUK_BW_WRITE_RAW_HBUFFER(thr,bw_ctx,val) do { \\\n\t\tduk_size_t duk__val_len; \\\n\t\tduk__val_len = DUK_HBUFFER_GET_SIZE((val)); \\\n\t\tDUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \\\n\t\t(bw_ctx)->p += duk__val_len; \\\n\t} while (0)\n#define DUK_BW_WRITE_RAW_HBUFFER_FIXED(thr,bw_ctx,val) do { \\\n\t\tduk_size_t duk__val_len; \\\n\t\tduk__val_len = DUK_HBUFFER_FIXED_GET_SIZE((val)); \\\n\t\tDUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_FIXED_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \\\n\t\t(bw_ctx)->p += duk__val_len; \\\n\t} while (0)\n#define DUK_BW_WRITE_RAW_HBUFFER_DYNAMIC(thr,bw_ctx,val) do { \\\n\t\tduk_size_t duk__val_len; \\\n\t\tduk__val_len = DUK_HBUFFER_DYNAMIC_GET_SIZE((val)); \\\n\t\tDUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \\\n\t\t(bw_ctx)->p += duk__val_len; \\\n\t} while (0)\n\n/* Append bytes from a slice already in the buffer. */\n#define DUK_BW_WRITE_RAW_SLICE(thr,bw,dst_off,dst_len) \\\n\tduk_bw_write_raw_slice((thr), (bw), (dst_off), (dst_len))\n\n/* Insert bytes in the middle of the buffer from an external buffer. */\n#define DUK_BW_INSERT_RAW_BYTES(thr,bw,dst_off,buf,len) \\\n\tduk_bw_insert_raw_bytes((thr), (bw), (dst_off), (buf), (len))\n\n/* Insert bytes in the middle of the buffer from a slice already\n * in the buffer.  Source offset is interpreted \"before\" the operation.\n */\n#define DUK_BW_INSERT_RAW_SLICE(thr,bw,dst_off,src_off,len) \\\n\tduk_bw_insert_raw_slice((thr), (bw), (dst_off), (src_off), (len))\n\n/* Insert a reserved area somewhere in the buffer; caller fills it.\n * Evaluates to a (duk_uint_t *) pointing to the start of the reserved\n * area for convenience.\n */\n#define DUK_BW_INSERT_RAW_AREA(thr,bw,off,len) \\\n\tduk_bw_insert_raw_area((thr), (bw), (off), (len))\n\n/* Remove a slice from inside buffer. */\n#define DUK_BW_REMOVE_RAW_SLICE(thr,bw,off,len) \\\n\tduk_bw_remove_raw_slice((thr), (bw), (off), (len))\n\n/* Safe write calls which will ensure space first. */\n\n#define DUK_BW_WRITE_ENSURE_U8(thr,bw_ctx,val) do { \\\n\t\tDUK_BW_ENSURE((thr), (bw_ctx), 1); \\\n\t\tDUK_BW_WRITE_RAW_U8((thr), (bw_ctx), (val)); \\\n\t} while (0)\n#define DUK_BW_WRITE_ENSURE_U8_2(thr,bw_ctx,val1,val2) do { \\\n\t\tDUK_BW_ENSURE((thr), (bw_ctx), 2); \\\n\t\tDUK_BW_WRITE_RAW_U8_2((thr), (bw_ctx), (val1), (val2)); \\\n\t} while (0)\n#define DUK_BW_WRITE_ENSURE_U8_3(thr,bw_ctx,val1,val2,val3) do { \\\n\t\tDUK_BW_ENSURE((thr), (bw_ctx), 3); \\\n\t\tDUK_BW_WRITE_RAW_U8_3((thr), (bw_ctx), (val1), (val2), (val3)); \\\n\t} while (0)\n#define DUK_BW_WRITE_ENSURE_U8_4(thr,bw_ctx,val1,val2,val3,val4) do { \\\n\t\tDUK_BW_ENSURE((thr), (bw_ctx), 4); \\\n\t\tDUK_BW_WRITE_RAW_U8_4((thr), (bw_ctx), (val1), (val2), (val3), (val4)); \\\n\t} while (0)\n#define DUK_BW_WRITE_ENSURE_U8_5(thr,bw_ctx,val1,val2,val3,val4,val5) do { \\\n\t\tDUK_BW_ENSURE((thr), (bw_ctx), 5); \\\n\t\tDUK_BW_WRITE_RAW_U8_5((thr), (bw_ctx), (val1), (val2), (val3), (val4), (val5)); \\\n\t} while (0)\n#define DUK_BW_WRITE_ENSURE_U8_6(thr,bw_ctx,val1,val2,val3,val4,val5,val6) do { \\\n\t\tDUK_BW_ENSURE((thr), (bw_ctx), 6); \\\n\t\tDUK_BW_WRITE_RAW_U8_6((thr), (bw_ctx), (val1), (val2), (val3), (val4), (val5), (val6)); \\\n\t} while (0)\n#define DUK_BW_WRITE_ENSURE_XUTF8(thr,bw_ctx,cp) do { \\\n\t\tDUK_BW_ENSURE((thr), (bw_ctx), DUK_UNICODE_MAX_XUTF8_LENGTH); \\\n\t\tDUK_BW_WRITE_RAW_XUTF8((thr), (bw_ctx), (cp)); \\\n\t} while (0)\n#define DUK_BW_WRITE_ENSURE_CESU8(thr,bw_ctx,cp) do { \\\n\t\tDUK_BW_ENSURE((thr), (bw_ctx), DUK_UNICODE_MAX_CESU8_LENGTH); \\\n\t\tDUK_BW_WRITE_RAW_CESU8((thr), (bw_ctx), (cp)); \\\n\t} while (0)\n/* XXX: add temporary duk__p pointer here too; sharing */\n#define DUK_BW_WRITE_ENSURE_BYTES(thr,bw_ctx,valptr,valsz) do { \\\n\t\tconst void *duk__valptr; \\\n\t\tduk_size_t duk__valsz; \\\n\t\tduk__valptr = (const void *) (valptr); \\\n\t\tduk__valsz = (duk_size_t) (valsz); \\\n\t\tDUK_BW_ENSURE((thr), (bw_ctx), duk__valsz); \\\n\t\tDUK_MEMCPY((void *) ((bw_ctx)->p), duk__valptr, duk__valsz); \\\n\t\t(bw_ctx)->p += duk__valsz; \\\n\t} while (0)\n#define DUK_BW_WRITE_ENSURE_CSTRING(thr,bw_ctx,val) do { \\\n\t\tconst duk_uint8_t *duk__val; \\\n\t\tduk_size_t duk__val_len; \\\n\t\tduk__val = (const duk_uint8_t *) (val); \\\n\t\tduk__val_len = DUK_STRLEN((const char *) duk__val); \\\n\t\tDUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \\\n\t\tDUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) duk__val, duk__val_len); \\\n\t\t(bw_ctx)->p += duk__val_len; \\\n\t} while (0)\n#define DUK_BW_WRITE_ENSURE_HSTRING(thr,bw_ctx,val) do { \\\n\t\tduk_size_t duk__val_len; \\\n\t\tduk__val_len = DUK_HSTRING_GET_BYTELEN((val)); \\\n\t\tDUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \\\n\t\tDUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HSTRING_GET_DATA((val)), duk__val_len); \\\n\t\t(bw_ctx)->p += duk__val_len; \\\n\t} while (0)\n#define DUK_BW_WRITE_ENSURE_HBUFFER(thr,bw_ctx,val) do { \\\n\t\tduk_size_t duk__val_len; \\\n\t\tduk__val_len = DUK_HBUFFER_GET_SIZE((val)); \\\n\t\tDUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \\\n\t\tDUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \\\n\t\t(bw_ctx)->p += duk__val_len; \\\n\t} while (0)\n#define DUK_BW_WRITE_ENSURE_HBUFFER_FIXED(thr,bw_ctx,val) do { \\\n\t\tduk_size_t duk__val_len; \\\n\t\tduk__val_len = DUK_HBUFFER_FIXED_GET_SIZE((val)); \\\n\t\tDUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \\\n\t\tDUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_FIXED_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \\\n\t\t(bw_ctx)->p += duk__val_len; \\\n\t} while (0)\n#define DUK_BW_WRITE_ENSURE_HBUFFER_DYNAMIC(thr,bw_ctx,val) do { \\\n\t\tduk_size_t duk__val_len; \\\n\t\tduk__val_len = DUK_HBUFFER_DYNAMIC_GET_SIZE((val)); \\\n\t\tDUK_BW_ENSURE((thr), (bw_ctx), duk__val_len); \\\n\t\tDUK_MEMCPY((void *) ((bw_ctx)->p), (const void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR((thr)->heap, (val)), duk__val_len); \\\n\t\t(bw_ctx)->p += duk__val_len; \\\n\t} while (0)\n\n#define DUK_BW_WRITE_ENSURE_SLICE(thr,bw,dst_off,dst_len) \\\n\tduk_bw_write_ensure_slice((thr), (bw), (dst_off), (dst_len))\n#define DUK_BW_INSERT_ENSURE_BYTES(thr,bw,dst_off,buf,len) \\\n\tduk_bw_insert_ensure_bytes((thr), (bw), (dst_off), (buf), (len))\n#define DUK_BW_INSERT_ENSURE_SLICE(thr,bw,dst_off,src_off,len) \\\n\tduk_bw_insert_ensure_slice((thr), (bw), (dst_off), (src_off), (len))\n#define DUK_BW_INSERT_ENSURE_AREA(thr,bw,off,len) \\\n\t/* Evaluates to (duk_uint8_t *) pointing to start of area. */ \\\n\tduk_bw_insert_ensure_area((thr), (bw), (off), (len))\n#define DUK_BW_REMOVE_ENSURE_SLICE(thr,bw,off,len) \\\n\t/* No difference between raw/ensure because the buffer shrinks. */ \\\n\tDUK_BW_REMOVE_RAW_SLICE((thr), (bw), (off), (len))\n\n/*\n *  Externs and prototypes\n */\n\n#if !defined(DUK_SINGLE_FILE)\nDUK_INTERNAL_DECL const duk_uint8_t duk_lc_digits[36];\nDUK_INTERNAL_DECL const duk_uint8_t duk_uc_nybbles[16];\nDUK_INTERNAL_DECL const duk_int8_t duk_hex_dectab[256];\n#if defined(DUK_USE_HEX_FASTPATH)\nDUK_INTERNAL_DECL const duk_int16_t duk_hex_dectab_shift4[256];\nDUK_INTERNAL_DECL const duk_uint16_t duk_hex_enctab[256];\n#endif\n#if defined(DUK_USE_BASE64_FASTPATH)\nDUK_INTERNAL_DECL const duk_uint8_t duk_base64_enctab[64];\nDUK_INTERNAL_DECL const duk_int8_t duk_base64_dectab[256];\n#endif\n#endif  /* !DUK_SINGLE_FILE */\n\n/* Note: assumes that duk_util_probe_steps size is 32 */\n#if defined(DUK_USE_HOBJECT_HASH_PART)\n#if !defined(DUK_SINGLE_FILE)\nDUK_INTERNAL_DECL duk_uint8_t duk_util_probe_steps[32];\n#endif  /* !DUK_SINGLE_FILE */\n#endif\n\n#if defined(DUK_USE_STRHASH_DENSE)\nDUK_INTERNAL_DECL duk_uint32_t duk_util_hashbytes(const duk_uint8_t *data, duk_size_t len, duk_uint32_t seed);\n#endif\n\nDUK_INTERNAL_DECL duk_uint32_t duk_bd_decode(duk_bitdecoder_ctx *ctx, duk_small_int_t bits);\nDUK_INTERNAL_DECL duk_small_uint_t duk_bd_decode_flag(duk_bitdecoder_ctx *ctx);\nDUK_INTERNAL_DECL duk_uint32_t duk_bd_decode_flagged(duk_bitdecoder_ctx *ctx, duk_small_int_t bits, duk_uint32_t def_value);\nDUK_INTERNAL_DECL duk_int32_t duk_bd_decode_flagged_signed(duk_bitdecoder_ctx *ctx, duk_small_int_t bits, duk_int32_t def_value);\nDUK_INTERNAL_DECL duk_uint32_t duk_bd_decode_varuint(duk_bitdecoder_ctx *ctx);\nDUK_INTERNAL_DECL duk_small_uint_t duk_bd_decode_bitpacked_string(duk_bitdecoder_ctx *bd, duk_uint8_t *out);\n\nDUK_INTERNAL_DECL void duk_be_encode(duk_bitencoder_ctx *ctx, duk_uint32_t data, duk_small_int_t bits);\nDUK_INTERNAL_DECL void duk_be_finish(duk_bitencoder_ctx *ctx);\n\n#if !defined(DUK_USE_GET_RANDOM_DOUBLE)\nDUK_INTERNAL_DECL duk_double_t duk_util_tinyrandom_get_double(duk_hthread *thr);\nDUK_INTERNAL_DECL void duk_util_tinyrandom_prepare_seed(duk_hthread *thr);\n#endif\n\nDUK_INTERNAL_DECL void duk_bw_init(duk_hthread *thr, duk_bufwriter_ctx *bw_ctx, duk_hbuffer_dynamic *h_buf);\nDUK_INTERNAL_DECL void duk_bw_init_pushbuf(duk_hthread *thr, duk_bufwriter_ctx *bw_ctx, duk_size_t buf_size);\nDUK_INTERNAL_DECL duk_uint8_t *duk_bw_resize(duk_hthread *thr, duk_bufwriter_ctx *bw_ctx, duk_size_t sz);\nDUK_INTERNAL_DECL void duk_bw_compact(duk_hthread *thr, duk_bufwriter_ctx *bw_ctx);\nDUK_INTERNAL_DECL void duk_bw_write_raw_slice(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t src_off, duk_size_t len);\nDUK_INTERNAL_DECL void duk_bw_write_ensure_slice(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t src_off, duk_size_t len);\nDUK_INTERNAL_DECL void duk_bw_insert_raw_bytes(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t dst_off, const duk_uint8_t *buf, duk_size_t len);\nDUK_INTERNAL_DECL void duk_bw_insert_ensure_bytes(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t dst_off, const duk_uint8_t *buf, duk_size_t len);\nDUK_INTERNAL_DECL void duk_bw_insert_raw_slice(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t dst_off, duk_size_t src_off, duk_size_t len);\nDUK_INTERNAL_DECL void duk_bw_insert_ensure_slice(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t dst_off, duk_size_t src_off, duk_size_t len);\nDUK_INTERNAL_DECL duk_uint8_t *duk_bw_insert_raw_area(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t off, duk_size_t len);\nDUK_INTERNAL_DECL duk_uint8_t *duk_bw_insert_ensure_area(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t off, duk_size_t len);\nDUK_INTERNAL_DECL void duk_bw_remove_raw_slice(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t off, duk_size_t len);\n/* No duk_bw_remove_ensure_slice(), functionality would be identical. */\n\nDUK_INTERNAL_DECL duk_uint16_t duk_raw_read_u16_be(duk_uint8_t **p);\nDUK_INTERNAL_DECL duk_uint32_t duk_raw_read_u32_be(duk_uint8_t **p);\nDUK_INTERNAL_DECL duk_double_t duk_raw_read_double_be(duk_uint8_t **p);\nDUK_INTERNAL_DECL void duk_raw_write_u16_be(duk_uint8_t **p, duk_uint16_t val);\nDUK_INTERNAL_DECL void duk_raw_write_u32_be(duk_uint8_t **p, duk_uint32_t val);\nDUK_INTERNAL_DECL void duk_raw_write_double_be(duk_uint8_t **p, duk_double_t val);\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT)  /* For now only needed by the debugger. */\nDUK_INTERNAL_DECL void duk_byteswap_bytes(duk_uint8_t *p, duk_small_uint_t len);\n#endif\n\nDUK_INTERNAL_DECL duk_bool_t duk_is_whole_get_int32_nonegzero(duk_double_t x, duk_int32_t *ival);\nDUK_INTERNAL_DECL duk_bool_t duk_is_whole_get_int32(duk_double_t x, duk_int32_t *ival);\nDUK_INTERNAL_DECL duk_bool_t duk_double_is_anyinf(duk_double_t x);\nDUK_INTERNAL_DECL duk_bool_t duk_double_is_posinf(duk_double_t x);\nDUK_INTERNAL_DECL duk_bool_t duk_double_is_neginf(duk_double_t x);\nDUK_INTERNAL_DECL duk_bool_t duk_double_is_nan(duk_double_t x);\nDUK_INTERNAL_DECL duk_bool_t duk_double_is_nan_or_zero(duk_double_t x);\nDUK_INTERNAL_DECL duk_bool_t duk_double_is_nan_or_inf(duk_double_t x);\nDUK_INTERNAL_DECL duk_bool_t duk_double_is_nan_zero_inf(duk_double_t x);\nDUK_INTERNAL_DECL duk_small_uint_t duk_double_signbit(duk_double_t x);\nDUK_INTERNAL_DECL duk_double_t duk_double_trunc_towards_zero(duk_double_t x);\nDUK_INTERNAL_DECL duk_bool_t duk_double_same_sign(duk_double_t x, duk_double_t y);\nDUK_INTERNAL_DECL duk_double_t duk_double_fmin(duk_double_t x, duk_double_t y);\nDUK_INTERNAL_DECL duk_double_t duk_double_fmax(duk_double_t x, duk_double_t y);\n\n#endif  /* DUK_UTIL_H_INCLUDED */\n/* #include duk_strings.h */\n/*\n *  Shared string macros.\n *\n *  Using shared macros helps minimize strings data size because it's easy\n *  to check if an existing string could be used.  String constants don't\n *  need to be all defined here; defining a string here makes sense if there's\n *  a high chance the string could be reused.  Also, using macros allows\n *  a call site express the exact string needed, but the macro may map to an\n *  approximate string to reduce unique string count.  Macros can also be\n *  more easily tuned for low memory targets than #if defined()s throughout\n *  the code base.\n *\n *  Because format strings behave differently in the call site (they need to\n *  be followed by format arguments), they use a special prefix DUK_STR_FMT_.\n *\n *  On some compilers using explicit shared strings is preferable; on others\n *  it may be better to use straight literals because the compiler will combine\n *  them anyway, and such strings won't end up unnecessarily in a symbol table.\n */\n\n#if !defined(DUK_ERRMSG_H_INCLUDED)\n#define DUK_ERRMSG_H_INCLUDED\n\n/* Mostly API and built-in method related */\n#define DUK_STR_INTERNAL_ERROR                   \"internal error\"\n#define DUK_STR_UNSUPPORTED                      \"unsupported\"\n#define DUK_STR_INVALID_COUNT                    \"invalid count\"\n#define DUK_STR_INVALID_ARGS                     \"invalid args\"\n#define DUK_STR_INVALID_STATE                    \"invalid state\"\n#define DUK_STR_INVALID_INPUT                    \"invalid input\"\n#define DUK_STR_INVALID_LENGTH                   \"invalid length\"\n#define DUK_STR_NOT_CONSTRUCTABLE                \"not constructable\"\n#define DUK_STR_CONSTRUCT_ONLY                   \"constructor requires 'new'\"\n#define DUK_STR_NOT_CALLABLE                     \"not callable\"\n#define DUK_STR_NOT_EXTENSIBLE                   \"not extensible\"\n#define DUK_STR_NOT_WRITABLE                     \"not writable\"\n#define DUK_STR_NOT_CONFIGURABLE                 \"not configurable\"\n#define DUK_STR_INVALID_CONTEXT                  \"invalid context\"\n#define DUK_STR_INVALID_INDEX                    \"invalid args\"\n#define DUK_STR_PUSH_BEYOND_ALLOC_STACK          \"cannot push beyond allocated stack\"\n#define DUK_STR_NOT_UNDEFINED                    \"unexpected type\"\n#define DUK_STR_NOT_NULL                         \"unexpected type\"\n#define DUK_STR_NOT_BOOLEAN                      \"unexpected type\"\n#define DUK_STR_NOT_NUMBER                       \"unexpected type\"\n#define DUK_STR_NOT_STRING                       \"unexpected type\"\n#define DUK_STR_NOT_OBJECT                       \"unexpected type\"\n#define DUK_STR_NOT_POINTER                      \"unexpected type\"\n#define DUK_STR_NOT_BUFFER                       \"not buffer\"  /* still in use with verbose messages */\n#define DUK_STR_UNEXPECTED_TYPE                  \"unexpected type\"\n#define DUK_STR_NOT_THREAD                       \"unexpected type\"\n#define DUK_STR_NOT_COMPFUNC                     \"unexpected type\"\n#define DUK_STR_NOT_NATFUNC                      \"unexpected type\"\n#define DUK_STR_NOT_C_FUNCTION                   \"unexpected type\"\n#define DUK_STR_NOT_FUNCTION                     \"unexpected type\"\n#define DUK_STR_NOT_REGEXP                       \"unexpected type\"\n#define DUK_STR_TOPRIMITIVE_FAILED               \"coercion to primitive failed\"\n#define DUK_STR_NUMBER_OUTSIDE_RANGE             \"number outside range\"\n#define DUK_STR_NOT_OBJECT_COERCIBLE             \"not object coercible\"\n#define DUK_STR_CANNOT_NUMBER_COERCE_SYMBOL      \"cannot number coerce Symbol\"\n#define DUK_STR_CANNOT_STRING_COERCE_SYMBOL      \"cannot string coerce Symbol\"\n#define DUK_STR_STRING_TOO_LONG                  \"string too long\"\n#define DUK_STR_BUFFER_TOO_LONG                  \"buffer too long\"\n#define DUK_STR_ALLOC_FAILED                     \"alloc failed\"\n#define DUK_STR_WRONG_BUFFER_TYPE                \"wrong buffer type\"\n#define DUK_STR_ENCODE_FAILED                    \"encode failed\"\n#define DUK_STR_DECODE_FAILED                    \"decode failed\"\n#define DUK_STR_NO_SOURCECODE                    \"no sourcecode\"\n#define DUK_STR_RESULT_TOO_LONG                  \"result too long\"\n\n/* JSON */\n#define DUK_STR_FMT_PTR                          \"%p\"\n#define DUK_STR_FMT_INVALID_JSON                 \"invalid json (at offset %ld)\"\n#define DUK_STR_JSONDEC_RECLIMIT                 \"json decode recursion limit\"\n#define DUK_STR_JSONENC_RECLIMIT                 \"json encode recursion limit\"\n#define DUK_STR_CYCLIC_INPUT                     \"cyclic input\"\n\n/* Object property access */\n#define DUK_STR_PROXY_REVOKED                    \"proxy revoked\"\n#define DUK_STR_INVALID_BASE                     \"invalid base value\"\n#define DUK_STR_STRICT_CALLER_READ               \"cannot read strict 'caller'\"\n#define DUK_STR_PROXY_REJECTED                   \"proxy rejected\"\n#define DUK_STR_INVALID_ARRAY_LENGTH             \"invalid array length\"\n#define DUK_STR_SETTER_UNDEFINED                 \"setter undefined\"\n#define DUK_STR_INVALID_DESCRIPTOR               \"invalid descriptor\"\n\n/* Proxy */\n#define DUK_STR_INVALID_TRAP_RESULT              \"invalid trap result\"\n\n/* Variables */\n\n/* Lexer */\n#define DUK_STR_INVALID_ESCAPE                   \"invalid escape\"\n#define DUK_STR_UNTERMINATED_STRING              \"unterminated string\"\n#define DUK_STR_UNTERMINATED_COMMENT             \"unterminated comment\"\n#define DUK_STR_UNTERMINATED_REGEXP              \"unterminated regexp\"\n#define DUK_STR_TOKEN_LIMIT                      \"token limit\"\n#define DUK_STR_REGEXP_SUPPORT_DISABLED          \"regexp support disabled\"\n#define DUK_STR_INVALID_NUMBER_LITERAL           \"invalid number literal\"\n#define DUK_STR_INVALID_TOKEN                    \"invalid token\"\n\n/* Compiler */\n#define DUK_STR_PARSE_ERROR                      \"parse error\"\n#define DUK_STR_DUPLICATE_LABEL                  \"duplicate label\"\n#define DUK_STR_INVALID_LABEL                    \"invalid label\"\n#define DUK_STR_INVALID_ARRAY_LITERAL            \"invalid array literal\"\n#define DUK_STR_INVALID_OBJECT_LITERAL           \"invalid object literal\"\n#define DUK_STR_INVALID_VAR_DECLARATION          \"invalid variable declaration\"\n#define DUK_STR_CANNOT_DELETE_IDENTIFIER         \"cannot delete identifier\"\n#define DUK_STR_INVALID_EXPRESSION               \"invalid expression\"\n#define DUK_STR_INVALID_LVALUE                   \"invalid lvalue\"\n#define DUK_STR_EXPECTED_IDENTIFIER              \"expected identifier\"\n#define DUK_STR_EMPTY_EXPR_NOT_ALLOWED           \"empty expression not allowed\"\n#define DUK_STR_INVALID_FOR                      \"invalid for statement\"\n#define DUK_STR_INVALID_SWITCH                   \"invalid switch statement\"\n#define DUK_STR_INVALID_BREAK_CONT_LABEL         \"invalid break/continue label\"\n#define DUK_STR_INVALID_RETURN                   \"invalid return\"\n#define DUK_STR_INVALID_TRY                      \"invalid try\"\n#define DUK_STR_INVALID_THROW                    \"invalid throw\"\n#define DUK_STR_WITH_IN_STRICT_MODE              \"with in strict mode\"\n#define DUK_STR_FUNC_STMT_NOT_ALLOWED            \"function statement not allowed\"\n#define DUK_STR_UNTERMINATED_STMT                \"unterminated statement\"\n#define DUK_STR_INVALID_ARG_NAME                 \"invalid argument name\"\n#define DUK_STR_INVALID_FUNC_NAME                \"invalid function name\"\n#define DUK_STR_INVALID_GETSET_NAME              \"invalid getter/setter name\"\n#define DUK_STR_FUNC_NAME_REQUIRED               \"function name required\"\n\n/* Regexp */\n#define DUK_STR_INVALID_QUANTIFIER               \"invalid regexp quantifier\"\n#define DUK_STR_INVALID_QUANTIFIER_NO_ATOM       \"quantifier without preceding atom\"\n#define DUK_STR_INVALID_QUANTIFIER_VALUES        \"quantifier values invalid (qmin > qmax)\"\n#define DUK_STR_QUANTIFIER_TOO_MANY_COPIES       \"quantifier requires too many atom copies\"\n#define DUK_STR_UNEXPECTED_CLOSING_PAREN         \"unexpected closing parenthesis\"\n#define DUK_STR_UNEXPECTED_END_OF_PATTERN        \"unexpected end of pattern\"\n#define DUK_STR_UNEXPECTED_REGEXP_TOKEN          \"unexpected token in regexp\"\n#define DUK_STR_INVALID_REGEXP_FLAGS             \"invalid regexp flags\"\n#define DUK_STR_INVALID_REGEXP_ESCAPE            \"invalid regexp escape\"\n#define DUK_STR_INVALID_BACKREFS                 \"invalid backreference(s)\"\n#define DUK_STR_INVALID_REGEXP_CHARACTER         \"invalid regexp character\"\n#define DUK_STR_INVALID_REGEXP_GROUP             \"invalid regexp group\"\n#define DUK_STR_UNTERMINATED_CHARCLASS           \"unterminated character class\"\n#define DUK_STR_INVALID_RANGE                    \"invalid range\"\n\n/* Limits */\n#define DUK_STR_VALSTACK_LIMIT                   \"valstack limit\"\n#define DUK_STR_CALLSTACK_LIMIT                  \"callstack limit\"\n#define DUK_STR_CATCHSTACK_LIMIT                 \"catchstack limit\"\n#define DUK_STR_PROTOTYPE_CHAIN_LIMIT            \"prototype chain limit\"\n#define DUK_STR_BOUND_CHAIN_LIMIT                \"function call bound chain limit\"\n#define DUK_STR_C_CALLSTACK_LIMIT                \"C call stack depth limit\"\n#define DUK_STR_COMPILER_RECURSION_LIMIT         \"compiler recursion limit\"\n#define DUK_STR_BYTECODE_LIMIT                   \"bytecode limit\"\n#define DUK_STR_REG_LIMIT                        \"register limit\"\n#define DUK_STR_TEMP_LIMIT                       \"temp limit\"\n#define DUK_STR_CONST_LIMIT                      \"const limit\"\n#define DUK_STR_FUNC_LIMIT                       \"function limit\"\n#define DUK_STR_REGEXP_COMPILER_RECURSION_LIMIT  \"regexp compiler recursion limit\"\n#define DUK_STR_REGEXP_EXECUTOR_RECURSION_LIMIT  \"regexp executor recursion limit\"\n#define DUK_STR_REGEXP_EXECUTOR_STEP_LIMIT       \"regexp step limit\"\n\n#endif  /* DUK_ERRMSG_H_INCLUDED */\n/* #include duk_js_bytecode.h */\n/*\n *  Ecmascript bytecode\n */\n\n#if !defined(DUK_JS_BYTECODE_H_INCLUDED)\n#define DUK_JS_BYTECODE_H_INCLUDED\n\n/*\n *  Bytecode instruction layout\n *  ===========================\n *\n *  Instructions are unsigned 32-bit integers divided as follows:\n *\n *  !3!3!2!2!2!2!2!2!2!2!2!2!1!1!1!1!1!1!1!1!1!1! ! ! ! ! ! ! ! ! ! !\n *  !1!0!9!8!7!6!5!4!3!2!1!0!9!8!7!6!5!4!3!2!1!0!9!8!7!6!5!4!3!2!1!0!\n *  +-----------------------------------------------+---------------+\n *  !       C       !       B       !       A       !       OP      !\n *  +-----------------------------------------------+---------------+\n *\n *  OP (8 bits):  opcode (DUK_OP_*), access should be fastest\n *                consecutive opcodes allocated when opcode needs flags\n *   A (8 bits):  typically a target register number\n *   B (8 bits):  typically first source register/constant number\n *   C (8 bits):  typically second source register/constant number\n *\n *  Some instructions combine BC or ABC together for larger parameter values.\n *  Signed integers (e.g. jump offsets) are encoded as unsigned, with an\n *  opcode specific bias.\n *\n *  Some opcodes have flags which are handled by allocating consecutive\n *  opcodes to make space for 1-N flags.  Flags can also be e.g. in the 'A'\n *  field when there's room for the specific opcode.\n *\n *  For example, if three flags were needed, they could be allocated from\n *  the opcode field as follows:\n *\n *  !3!3!2!2!2!2!2!2!2!2!2!2!1!1!1!1!1!1!1!1!1!1! ! ! ! ! ! ! ! ! ! !\n *  !1!0!9!8!7!6!5!4!3!2!1!0!9!8!7!6!5!4!3!2!1!0!9!8!7!6!5!4!3!2!1!0!\n *  +-----------------------------------------------+---------------+\n *  !       C       !       B       !       A       !    OP   !Z!Y!X!\n *  +-----------------------------------------------+---------------+\n *\n *  Some opcodes accept a reg/const argument which is handled by allocating\n *  flags in the OP field, see DUK_BC_ISREG() and DUK_BC_ISCONST().  The\n *  following convention is shared by most opcodes, so that the compiler\n *  can handle reg/const flagging without opcode specific code paths:\n *\n *  !3!3!2!2!2!2!2!2!2!2!2!2!1!1!1!1!1!1!1!1!1!1! ! ! ! ! ! ! ! ! ! !\n *  !1!0!9!8!7!6!5!4!3!2!1!0!9!8!7!6!5!4!3!2!1!0!9!8!7!6!5!4!3!2!1!0!\n *  +-----------------------------------------------+---------------+\n *  !       C       !       B       !       A       !     OP    !Y!X!\n *  +-----------------------------------------------+---------------+\n *\n *    X  1=B is const, 0=B is reg\n *    Y  1=C is const, 0=C is reg\n *\n *    In effect OP, OP + 1, OP + 2, and OP + 3 are allocated from the\n *    8-bit opcode space for a single logical opcode.  The base opcode\n *    number should be divisible by 4.  If the opcode is called 'FOO'\n *    the following opcode constants would be defined:\n *\n *      DUK_OP_FOO     100       // base opcode number\n *      DUK_OP_FOO_RR  100       // FOO, B=reg, C=reg\n *      DUK_OP_FOO_CR  101       // FOO, B=const, C=reg\n *      DUK_OP_FOO_RC  102       // FOO, B=reg, C=const\n *      DUK_OP_FOO_CC  103       // FOO, B=const, C=const\n *\n *  If only B or C is a reg/const, the unused opcode combinations can be\n *  used for other opcodes (which take no reg/const argument).  However,\n *  such opcode values are initially reserved, at least while opcode space\n *  is available.  For example, if 'BAR' uses B for a register field and\n *  C is a reg/const:\n *\n *      DUK_OP_BAR            116    // base opcode number\n *      DUK_OP_BAR_RR         116    // BAR, B=reg, C=reg\n *      DUK_OP_BAR_CR_UNUSED  117    // unused, could be repurposed\n *      DUK_OP_BAR_RC         118    // BAR, B=reg, C=const\n *      DUK_OP_BAR_CC_UNUSED  119    // unused, could be repurposed\n *\n *  Macro naming is a bit misleading, e.g. \"ABC\" in macro name but the\n *  field layout is concretely \"CBA\" in the register.\n */\n\ntypedef duk_uint32_t duk_instr_t;\n\n#define DUK_BC_SHIFT_OP             0\n#define DUK_BC_SHIFT_A              8\n#define DUK_BC_SHIFT_B              16\n#define DUK_BC_SHIFT_C              24\n#define DUK_BC_SHIFT_BC             DUK_BC_SHIFT_B\n#define DUK_BC_SHIFT_ABC            DUK_BC_SHIFT_A\n\n#define DUK_BC_UNSHIFTED_MASK_OP    0xffUL\n#define DUK_BC_UNSHIFTED_MASK_A     0xffUL\n#define DUK_BC_UNSHIFTED_MASK_B     0xffUL\n#define DUK_BC_UNSHIFTED_MASK_C     0xffUL\n#define DUK_BC_UNSHIFTED_MASK_BC    0xffffUL\n#define DUK_BC_UNSHIFTED_MASK_ABC   0xffffffUL\n\n#define DUK_BC_SHIFTED_MASK_OP      (DUK_BC_UNSHIFTED_MASK_OP << DUK_BC_SHIFT_OP)\n#define DUK_BC_SHIFTED_MASK_A       (DUK_BC_UNSHIFTED_MASK_A << DUK_BC_SHIFT_A)\n#define DUK_BC_SHIFTED_MASK_B       (DUK_BC_UNSHIFTED_MASK_B << DUK_BC_SHIFT_B)\n#define DUK_BC_SHIFTED_MASK_C       (DUK_BC_UNSHIFTED_MASK_C << DUK_BC_SHIFT_C)\n#define DUK_BC_SHIFTED_MASK_BC      (DUK_BC_UNSHIFTED_MASK_BC << DUK_BC_SHIFT_BC)\n#define DUK_BC_SHIFTED_MASK_ABC     (DUK_BC_UNSHIFTED_MASK_ABC << DUK_BC_SHIFT_ABC)\n\n#define DUK_DEC_OP(x)               ((x) & 0xffUL)\n#define DUK_DEC_A(x)                (((x) >> 8) & 0xffUL)\n#define DUK_DEC_B(x)                (((x) >> 16) & 0xffUL)\n#define DUK_DEC_C(x)                (((x) >> 24) & 0xffUL)\n#define DUK_DEC_BC(x)               (((x) >> 16) & 0xffffUL)\n#define DUK_DEC_ABC(x)              (((x) >> 8) & 0xffffffUL)\n\n#define DUK_ENC_OP(op)              ((duk_instr_t) (op))\n#define DUK_ENC_OP_ABC(op,abc)      ((duk_instr_t) ( \\\n                                        (((duk_instr_t) (abc)) << 8) | \\\n                                        ((duk_instr_t) (op)) \\\n                                    ))\n#define DUK_ENC_OP_A_BC(op,a,bc)    ((duk_instr_t) ( \\\n                                        (((duk_instr_t) (bc)) << 16) | \\\n                                        (((duk_instr_t) (a)) << 8) | \\\n                                        ((duk_instr_t) (op)) \\\n                                    ))\n#define DUK_ENC_OP_A_B_C(op,a,b,c)  ((duk_instr_t) ( \\\n                                        (((duk_instr_t) (c)) << 24) | \\\n                                        (((duk_instr_t) (b)) << 16) | \\\n                                        (((duk_instr_t) (a)) << 8) | \\\n                                        ((duk_instr_t) (op)) \\\n                                    ))\n#define DUK_ENC_OP_A_B(op,a,b)      DUK_ENC_OP_A_B_C((op),(a),(b),0)\n#define DUK_ENC_OP_A(op,a)          DUK_ENC_OP_A_B_C((op),(a),0,0)\n#define DUK_ENC_OP_BC(op,bc)        DUK_ENC_OP_A_BC((op),0,(bc))\n\n/* Get opcode base value with B/C reg/const flags cleared. */\n#define DUK_BC_NOREGCONST_OP(op)    ((op) & 0xfc)\n\n/* Constants should be signed so that signed arithmetic involving them\n * won't cause values to be coerced accidentally to unsigned.\n */\n#define DUK_BC_OP_MIN               0\n#define DUK_BC_OP_MAX               0xffL\n#define DUK_BC_A_MIN                0\n#define DUK_BC_A_MAX                0xffL\n#define DUK_BC_B_MIN                0\n#define DUK_BC_B_MAX                0xffL\n#define DUK_BC_C_MIN                0\n#define DUK_BC_C_MAX                0xffL\n#define DUK_BC_BC_MIN               0\n#define DUK_BC_BC_MAX               0xffffL\n#define DUK_BC_ABC_MIN              0\n#define DUK_BC_ABC_MAX              0xffffffL\n\n/* Masks for B/C reg/const indicator in opcode field. */\n#define DUK_BC_REGCONST_B           (0x01UL)\n#define DUK_BC_REGCONST_C           (0x02UL)\n\n/* Misc. masks for opcode field. */\n#define DUK_BC_INCDECP_FLAG_DEC     (0x04UL)\n#define DUK_BC_INCDECP_FLAG_POST    (0x08UL)\n\n/* Opcodes. */\n#define DUK_OP_LDREG                0\n#define DUK_OP_STREG                1\n#define DUK_OP_LDCONST              2\n#define DUK_OP_LDINT                3\n#define DUK_OP_LDINTX               4\n#define DUK_OP_LDTHIS               5\n#define DUK_OP_LDUNDEF              6\n#define DUK_OP_LDNULL               7\n#define DUK_OP_LDTRUE               8\n#define DUK_OP_LDFALSE              9\n#define DUK_OP_BNOT                 10\n#define DUK_OP_LNOT                 11\n#define DUK_OP_UNM                  12\n#define DUK_OP_UNP                  13\n#define DUK_OP_TYPEOF               14\n#define DUK_OP_TYPEOFID             15\n#define DUK_OP_EQ                   16\n#define DUK_OP_EQ_RR                16\n#define DUK_OP_EQ_CR                17\n#define DUK_OP_EQ_RC                18\n#define DUK_OP_EQ_CC                19\n#define DUK_OP_NEQ                  20\n#define DUK_OP_NEQ_RR               20\n#define DUK_OP_NEQ_CR               21\n#define DUK_OP_NEQ_RC               22\n#define DUK_OP_NEQ_CC               23\n#define DUK_OP_SEQ                  24\n#define DUK_OP_SEQ_RR               24\n#define DUK_OP_SEQ_CR               25\n#define DUK_OP_SEQ_RC               26\n#define DUK_OP_SEQ_CC               27\n#define DUK_OP_SNEQ                 28\n#define DUK_OP_SNEQ_RR              28\n#define DUK_OP_SNEQ_CR              29\n#define DUK_OP_SNEQ_RC              30\n#define DUK_OP_SNEQ_CC              31\n#define DUK_OP_GT                   32\n#define DUK_OP_GT_RR                32\n#define DUK_OP_GT_CR                33\n#define DUK_OP_GT_RC                34\n#define DUK_OP_GT_CC                35\n#define DUK_OP_GE                   36\n#define DUK_OP_GE_RR                36\n#define DUK_OP_GE_CR                37\n#define DUK_OP_GE_RC                38\n#define DUK_OP_GE_CC                39\n#define DUK_OP_LT                   40\n#define DUK_OP_LT_RR                40\n#define DUK_OP_LT_CR                41\n#define DUK_OP_LT_RC                42\n#define DUK_OP_LT_CC                43\n#define DUK_OP_LE                   44\n#define DUK_OP_LE_RR                44\n#define DUK_OP_LE_CR                45\n#define DUK_OP_LE_RC                46\n#define DUK_OP_LE_CC                47\n#define DUK_OP_IFTRUE               48\n#define DUK_OP_IFTRUE_R             48\n#define DUK_OP_IFTRUE_C             49\n#define DUK_OP_IFFALSE              50\n#define DUK_OP_IFFALSE_R            50\n#define DUK_OP_IFFALSE_C            51\n#define DUK_OP_ADD                  52\n#define DUK_OP_ADD_RR               52\n#define DUK_OP_ADD_CR               53\n#define DUK_OP_ADD_RC               54\n#define DUK_OP_ADD_CC               55\n#define DUK_OP_SUB                  56\n#define DUK_OP_SUB_RR               56\n#define DUK_OP_SUB_CR               57\n#define DUK_OP_SUB_RC               58\n#define DUK_OP_SUB_CC               59\n#define DUK_OP_MUL                  60\n#define DUK_OP_MUL_RR               60\n#define DUK_OP_MUL_CR               61\n#define DUK_OP_MUL_RC               62\n#define DUK_OP_MUL_CC               63\n#define DUK_OP_DIV                  64\n#define DUK_OP_DIV_RR               64\n#define DUK_OP_DIV_CR               65\n#define DUK_OP_DIV_RC               66\n#define DUK_OP_DIV_CC               67\n#define DUK_OP_MOD                  68\n#define DUK_OP_MOD_RR               68\n#define DUK_OP_MOD_CR               69\n#define DUK_OP_MOD_RC               70\n#define DUK_OP_MOD_CC               71\n#define DUK_OP_EXP                  72\n#define DUK_OP_EXP_RR               72\n#define DUK_OP_EXP_CR               73\n#define DUK_OP_EXP_RC               74\n#define DUK_OP_EXP_CC               75\n#define DUK_OP_BAND                 76\n#define DUK_OP_BAND_RR              76\n#define DUK_OP_BAND_CR              77\n#define DUK_OP_BAND_RC              78\n#define DUK_OP_BAND_CC              79\n#define DUK_OP_BOR                  80\n#define DUK_OP_BOR_RR               80\n#define DUK_OP_BOR_CR               81\n#define DUK_OP_BOR_RC               82\n#define DUK_OP_BOR_CC               83\n#define DUK_OP_BXOR                 84\n#define DUK_OP_BXOR_RR              84\n#define DUK_OP_BXOR_CR              85\n#define DUK_OP_BXOR_RC              86\n#define DUK_OP_BXOR_CC              87\n#define DUK_OP_BASL                 88\n#define DUK_OP_BASL_RR              88\n#define DUK_OP_BASL_CR              89\n#define DUK_OP_BASL_RC              90\n#define DUK_OP_BASL_CC              91\n#define DUK_OP_BLSR                 92\n#define DUK_OP_BLSR_RR              92\n#define DUK_OP_BLSR_CR              93\n#define DUK_OP_BLSR_RC              94\n#define DUK_OP_BLSR_CC              95\n#define DUK_OP_BASR                 96\n#define DUK_OP_BASR_RR              96\n#define DUK_OP_BASR_CR              97\n#define DUK_OP_BASR_RC              98\n#define DUK_OP_BASR_CC              99\n#define DUK_OP_INSTOF               100\n#define DUK_OP_INSTOF_RR            100\n#define DUK_OP_INSTOF_CR            101\n#define DUK_OP_INSTOF_RC            102\n#define DUK_OP_INSTOF_CC            103\n#define DUK_OP_IN                   104\n#define DUK_OP_IN_RR                104\n#define DUK_OP_IN_CR                105\n#define DUK_OP_IN_RC                106\n#define DUK_OP_IN_CC                107\n#define DUK_OP_GETPROP              108\n#define DUK_OP_GETPROP_RR           108\n#define DUK_OP_GETPROP_CR           109\n#define DUK_OP_GETPROP_RC           110\n#define DUK_OP_GETPROP_CC           111\n#define DUK_OP_PUTPROP              112\n#define DUK_OP_PUTPROP_RR           112\n#define DUK_OP_PUTPROP_CR           113\n#define DUK_OP_PUTPROP_RC           114\n#define DUK_OP_PUTPROP_CC           115\n#define DUK_OP_DELPROP              116\n#define DUK_OP_DELPROP_RR           116\n#define DUK_OP_DELPROP_CR_UNUSED    117  /* unused now */\n#define DUK_OP_DELPROP_RC           118\n#define DUK_OP_DELPROP_CC_UNUSED    119  /* unused now */\n#define DUK_OP_PREINCR              120  /* pre/post opcode values have constraints, */\n#define DUK_OP_PREDECR              121  /* see duk_js_executor.c and duk_js_compiler.c. */\n#define DUK_OP_POSTINCR             122\n#define DUK_OP_POSTDECR             123\n#define DUK_OP_PREINCV              124\n#define DUK_OP_PREDECV              125\n#define DUK_OP_POSTINCV             126\n#define DUK_OP_POSTDECV             127\n#define DUK_OP_PREINCP              128  /* pre/post inc/dec prop opcodes have constraints */\n#define DUK_OP_PREINCP_RR           128\n#define DUK_OP_PREINCP_CR           129\n#define DUK_OP_PREINCP_RC           130\n#define DUK_OP_PREINCP_CC           131\n#define DUK_OP_PREDECP              132\n#define DUK_OP_PREDECP_RR           132\n#define DUK_OP_PREDECP_CR           133\n#define DUK_OP_PREDECP_RC           134\n#define DUK_OP_PREDECP_CC           135\n#define DUK_OP_POSTINCP             136\n#define DUK_OP_POSTINCP_RR          136\n#define DUK_OP_POSTINCP_CR          137\n#define DUK_OP_POSTINCP_RC          138\n#define DUK_OP_POSTINCP_CC          139\n#define DUK_OP_POSTDECP             140\n#define DUK_OP_POSTDECP_RR          140\n#define DUK_OP_POSTDECP_CR          141\n#define DUK_OP_POSTDECP_RC          142\n#define DUK_OP_POSTDECP_CC          143\n#define DUK_OP_DECLVAR              144\n#define DUK_OP_DECLVAR_RR           144\n#define DUK_OP_DECLVAR_CR           145\n#define DUK_OP_DECLVAR_RC           146\n#define DUK_OP_DECLVAR_CC           147\n#define DUK_OP_REGEXP               148\n#define DUK_OP_REGEXP_RR            148\n#define DUK_OP_REGEXP_CR            149\n#define DUK_OP_REGEXP_RC            150\n#define DUK_OP_REGEXP_CC            151\n#define DUK_OP_CSVAR                152\n#define DUK_OP_CSVAR_RR             152\n#define DUK_OP_CSVAR_CR             153\n#define DUK_OP_CSVAR_RC             154\n#define DUK_OP_CSVAR_CC             155\n#define DUK_OP_CLOSURE              156\n#define DUK_OP_GETVAR               157\n#define DUK_OP_PUTVAR               158\n#define DUK_OP_DELVAR               159\n#define DUK_OP_JUMP                 160\n#define DUK_OP_RETREG               161\n#define DUK_OP_RETUNDEF             162\n#define DUK_OP_RETCONST             163\n#define DUK_OP_RETCONSTN            164  /* return const without incref (e.g. number) */\n#define DUK_OP_LABEL                165\n#define DUK_OP_ENDLABEL             166\n#define DUK_OP_BREAK                167\n#define DUK_OP_CONTINUE             168\n#define DUK_OP_TRYCATCH             169\n#define DUK_OP_ENDTRY               170\n#define DUK_OP_ENDCATCH             171\n#define DUK_OP_ENDFIN               172\n#define DUK_OP_THROW                173\n#define DUK_OP_CSREG                174\n#define DUK_OP_EVALCALL             175\n#define DUK_OP_CALL                 176  /* must be even */\n#define DUK_OP_TAILCALL             177  /* must be odd */\n#define DUK_OP_NEW                  178\n#define DUK_OP_NEWOBJ               179\n#define DUK_OP_NEWARR               180\n#define DUK_OP_MPUTOBJ              181\n#define DUK_OP_MPUTOBJI             182\n#define DUK_OP_INITSET              183\n#define DUK_OP_INITGET              184\n#define DUK_OP_MPUTARR              185\n#define DUK_OP_MPUTARRI             186\n#define DUK_OP_SETALEN              187\n#define DUK_OP_INITENUM             188\n#define DUK_OP_NEXTENUM             189\n#define DUK_OP_INVLHS               190\n#define DUK_OP_DEBUGGER             191\n#define DUK_OP_NOP                  192\n#define DUK_OP_INVALID              193\n#define DUK_OP_UNUSED194            194\n#define DUK_OP_UNUSED195            195\n#define DUK_OP_UNUSED196            196\n#define DUK_OP_UNUSED197            197\n#define DUK_OP_UNUSED198            198\n#define DUK_OP_UNUSED199            199\n#define DUK_OP_UNUSED200            200\n#define DUK_OP_UNUSED201            201\n#define DUK_OP_UNUSED202            202\n#define DUK_OP_UNUSED203            203\n#define DUK_OP_UNUSED204            204\n#define DUK_OP_UNUSED205            205\n#define DUK_OP_UNUSED206            206\n#define DUK_OP_UNUSED207            207\n#define DUK_OP_UNUSED208            208\n#define DUK_OP_UNUSED209            209\n#define DUK_OP_UNUSED210            210\n#define DUK_OP_UNUSED211            211\n#define DUK_OP_UNUSED212            212\n#define DUK_OP_UNUSED213            213\n#define DUK_OP_UNUSED214            214\n#define DUK_OP_UNUSED215            215\n#define DUK_OP_UNUSED216            216\n#define DUK_OP_UNUSED217            217\n#define DUK_OP_UNUSED218            218\n#define DUK_OP_UNUSED219            219\n#define DUK_OP_UNUSED220            220\n#define DUK_OP_UNUSED221            221\n#define DUK_OP_UNUSED222            222\n#define DUK_OP_UNUSED223            223\n#define DUK_OP_UNUSED224            224\n#define DUK_OP_UNUSED225            225\n#define DUK_OP_UNUSED226            226\n#define DUK_OP_UNUSED227            227\n#define DUK_OP_UNUSED228            228\n#define DUK_OP_UNUSED229            229\n#define DUK_OP_UNUSED230            230\n#define DUK_OP_UNUSED231            231\n#define DUK_OP_UNUSED232            232\n#define DUK_OP_UNUSED233            233\n#define DUK_OP_UNUSED234            234\n#define DUK_OP_UNUSED235            235\n#define DUK_OP_UNUSED236            236\n#define DUK_OP_UNUSED237            237\n#define DUK_OP_UNUSED238            238\n#define DUK_OP_UNUSED239            239\n#define DUK_OP_UNUSED240            240\n#define DUK_OP_UNUSED241            241\n#define DUK_OP_UNUSED242            242\n#define DUK_OP_UNUSED243            243\n#define DUK_OP_UNUSED244            244\n#define DUK_OP_UNUSED245            245\n#define DUK_OP_UNUSED246            246\n#define DUK_OP_UNUSED247            247\n#define DUK_OP_UNUSED248            248\n#define DUK_OP_UNUSED249            249\n#define DUK_OP_UNUSED250            250\n#define DUK_OP_UNUSED251            251\n#define DUK_OP_UNUSED252            252\n#define DUK_OP_UNUSED253            253\n#define DUK_OP_UNUSED254            254\n#define DUK_OP_UNUSED255            255\n#define DUK_OP_NONE                 256  /* dummy value used as marker (doesn't fit in 8-bit field) */\n\n/* XXX: Allocate flags from opcode field?  Would take 16 opcode slots\n * but avoids shuffling in more cases.  Maybe not worth it.\n */\n/* DUK_OP_TRYCATCH flags in A */\n#define DUK_BC_TRYCATCH_FLAG_HAVE_CATCH     (1 << 0)\n#define DUK_BC_TRYCATCH_FLAG_HAVE_FINALLY   (1 << 1)\n#define DUK_BC_TRYCATCH_FLAG_CATCH_BINDING  (1 << 2)\n#define DUK_BC_TRYCATCH_FLAG_WITH_BINDING   (1 << 3)\n\n/* DUK_OP_DECLVAR flags in A; bottom bits are reserved for propdesc flags (DUK_PROPDESC_FLAG_XXX) */\n#define DUK_BC_DECLVAR_FLAG_FUNC_DECL       (1 << 4)  /* function declaration */\n\n/* Misc constants and helper macros. */\n#define DUK_BC_LDINT_BIAS           (1L << 15)\n#define DUK_BC_LDINTX_SHIFT         16\n#define DUK_BC_JUMP_BIAS            (1L << 23)\n\n#endif  /* DUK_JS_BYTECODE_H_INCLUDED */\n/* #include duk_lexer.h */\n/*\n *  Lexer defines.\n */\n\n#if !defined(DUK_LEXER_H_INCLUDED)\n#define DUK_LEXER_H_INCLUDED\n\ntypedef void (*duk_re_range_callback)(void *user, duk_codepoint_t r1, duk_codepoint_t r2, duk_bool_t direct);\n\n/*\n *  A token is interpreted as any possible production of InputElementDiv\n *  and InputElementRegExp, see E5 Section 7 in its entirety.  Note that\n *  the E5 \"Token\" production does not cover all actual tokens of the\n *  language (which is explicitly stated in the specification, Section 7.5).\n *  Null and boolean literals are defined as part of both ReservedWord\n *  (E5 Section 7.6.1) and Literal (E5 Section 7.8) productions.  Here,\n *  null and boolean values have literal tokens, and are not reserved\n *  words.\n *\n *  Decimal literal negative/positive sign is -not- part of DUK_TOK_NUMBER.\n *  The number tokens always have a non-negative value.  The unary minus\n *  operator in \"-1.0\" is optimized during compilation to yield a single\n *  negative constant.\n *\n *  Token numbering is free except that reserved words are required to be\n *  in a continuous range and in a particular order.  See genstrings.py.\n */\n\n#define DUK_LEXER_INITCTX(ctx)        duk_lexer_initctx((ctx))\n\n#define DUK_LEXER_SETPOINT(ctx,pt)    duk_lexer_setpoint((ctx), (pt))\n\n#define DUK_LEXER_GETPOINT(ctx,pt)    duk_lexer_getpoint((ctx), (pt))\n\n/* Currently 6 characters of lookup are actually needed (duk_lexer.c). */\n#define DUK_LEXER_WINDOW_SIZE                     6\n#if defined(DUK_USE_LEXER_SLIDING_WINDOW)\n#define DUK_LEXER_BUFFER_SIZE                     64\n#endif\n\n#define DUK_TOK_MINVAL                            0\n\n/* returned after EOF (infinite amount) */\n#define DUK_TOK_EOF                               0\n\n/* identifier names (E5 Section 7.6) */\n#define DUK_TOK_IDENTIFIER                        1\n\n/* reserved words: keywords */\n#define DUK_TOK_START_RESERVED                    2\n#define DUK_TOK_BREAK                             2\n#define DUK_TOK_CASE                              3\n#define DUK_TOK_CATCH                             4\n#define DUK_TOK_CONTINUE                          5\n#define DUK_TOK_DEBUGGER                          6\n#define DUK_TOK_DEFAULT                           7\n#define DUK_TOK_DELETE                            8\n#define DUK_TOK_DO                                9\n#define DUK_TOK_ELSE                              10\n#define DUK_TOK_FINALLY                           11\n#define DUK_TOK_FOR                               12\n#define DUK_TOK_FUNCTION                          13\n#define DUK_TOK_IF                                14\n#define DUK_TOK_IN                                15\n#define DUK_TOK_INSTANCEOF                        16\n#define DUK_TOK_NEW                               17\n#define DUK_TOK_RETURN                            18\n#define DUK_TOK_SWITCH                            19\n#define DUK_TOK_THIS                              20\n#define DUK_TOK_THROW                             21\n#define DUK_TOK_TRY                               22\n#define DUK_TOK_TYPEOF                            23\n#define DUK_TOK_VAR                               24\n#define DUK_TOK_CONST                             25\n#define DUK_TOK_VOID                              26\n#define DUK_TOK_WHILE                             27\n#define DUK_TOK_WITH                              28\n\n/* reserved words: future reserved words */\n#define DUK_TOK_CLASS                             29\n#define DUK_TOK_ENUM                              30\n#define DUK_TOK_EXPORT                            31\n#define DUK_TOK_EXTENDS                           32\n#define DUK_TOK_IMPORT                            33\n#define DUK_TOK_SUPER                             34\n\n/* \"null\", \"true\", and \"false\" are always reserved words.\n * Note that \"get\" and \"set\" are not!\n */\n#define DUK_TOK_NULL                              35\n#define DUK_TOK_TRUE                              36\n#define DUK_TOK_FALSE                             37\n\n/* reserved words: additional future reserved words in strict mode */\n#define DUK_TOK_START_STRICT_RESERVED             38  /* inclusive */\n#define DUK_TOK_IMPLEMENTS                        38\n#define DUK_TOK_INTERFACE                         39\n#define DUK_TOK_LET                               40\n#define DUK_TOK_PACKAGE                           41\n#define DUK_TOK_PRIVATE                           42\n#define DUK_TOK_PROTECTED                         43\n#define DUK_TOK_PUBLIC                            44\n#define DUK_TOK_STATIC                            45\n#define DUK_TOK_YIELD                             46\n\n#define DUK_TOK_END_RESERVED                      47  /* exclusive */\n\n/* \"get\" and \"set\" are tokens but NOT ReservedWords.  They are currently\n * parsed and identifiers and these defines are actually now unused.\n */\n#define DUK_TOK_GET                               47\n#define DUK_TOK_SET                               48\n\n/* punctuators (unlike the spec, also includes \"/\" and \"/=\") */\n#define DUK_TOK_LCURLY                            49\n#define DUK_TOK_RCURLY                            50\n#define DUK_TOK_LBRACKET                          51\n#define DUK_TOK_RBRACKET                          52\n#define DUK_TOK_LPAREN                            53\n#define DUK_TOK_RPAREN                            54\n#define DUK_TOK_PERIOD                            55\n#define DUK_TOK_SEMICOLON                         56\n#define DUK_TOK_COMMA                             57\n#define DUK_TOK_LT                                58\n#define DUK_TOK_GT                                59\n#define DUK_TOK_LE                                60\n#define DUK_TOK_GE                                61\n#define DUK_TOK_EQ                                62\n#define DUK_TOK_NEQ                               63\n#define DUK_TOK_SEQ                               64\n#define DUK_TOK_SNEQ                              65\n#define DUK_TOK_ADD                               66\n#define DUK_TOK_SUB                               67\n#define DUK_TOK_MUL                               68\n#define DUK_TOK_DIV                               69\n#define DUK_TOK_MOD                               70\n#define DUK_TOK_EXP                               71\n#define DUK_TOK_INCREMENT                         72\n#define DUK_TOK_DECREMENT                         73\n#define DUK_TOK_ALSHIFT                           74   /* named \"arithmetic\" because result is signed */\n#define DUK_TOK_ARSHIFT                           75\n#define DUK_TOK_RSHIFT                            76\n#define DUK_TOK_BAND                              77\n#define DUK_TOK_BOR                               78\n#define DUK_TOK_BXOR                              79\n#define DUK_TOK_LNOT                              80\n#define DUK_TOK_BNOT                              81\n#define DUK_TOK_LAND                              82\n#define DUK_TOK_LOR                               83\n#define DUK_TOK_QUESTION                          84\n#define DUK_TOK_COLON                             85\n#define DUK_TOK_EQUALSIGN                         86\n#define DUK_TOK_ADD_EQ                            87\n#define DUK_TOK_SUB_EQ                            88\n#define DUK_TOK_MUL_EQ                            89\n#define DUK_TOK_DIV_EQ                            90\n#define DUK_TOK_MOD_EQ                            91\n#define DUK_TOK_EXP_EQ                            92\n#define DUK_TOK_ALSHIFT_EQ                        93\n#define DUK_TOK_ARSHIFT_EQ                        94\n#define DUK_TOK_RSHIFT_EQ                         95\n#define DUK_TOK_BAND_EQ                           96\n#define DUK_TOK_BOR_EQ                            97\n#define DUK_TOK_BXOR_EQ                           98\n\n/* literals (E5 Section 7.8), except null, true, false, which are treated\n * like reserved words (above).\n */\n#define DUK_TOK_NUMBER                            99\n#define DUK_TOK_STRING                            100\n#define DUK_TOK_REGEXP                            101\n\n#define DUK_TOK_MAXVAL                            101  /* inclusive */\n\n/* Convert heap string index to a token (reserved words) */\n#define DUK_STRIDX_TO_TOK(x)                        ((x) - DUK_STRIDX_START_RESERVED + DUK_TOK_START_RESERVED)\n\n/* Sanity check */\n#if (DUK_TOK_MAXVAL > 255)\n#error DUK_TOK_MAXVAL too large, code assumes it fits into 8 bits\n#endif\n\n/* Sanity checks for string and token defines */\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_BREAK) != DUK_TOK_BREAK)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_CASE) != DUK_TOK_CASE)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_CATCH) != DUK_TOK_CATCH)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_CONTINUE) != DUK_TOK_CONTINUE)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_DEBUGGER) != DUK_TOK_DEBUGGER)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_DEFAULT) != DUK_TOK_DEFAULT)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_DELETE) != DUK_TOK_DELETE)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_DO) != DUK_TOK_DO)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_ELSE) != DUK_TOK_ELSE)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_FINALLY) != DUK_TOK_FINALLY)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_FOR) != DUK_TOK_FOR)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_LC_FUNCTION) != DUK_TOK_FUNCTION)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_IF) != DUK_TOK_IF)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_IN) != DUK_TOK_IN)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_INSTANCEOF) != DUK_TOK_INSTANCEOF)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_NEW) != DUK_TOK_NEW)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_RETURN) != DUK_TOK_RETURN)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_SWITCH) != DUK_TOK_SWITCH)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_THIS) != DUK_TOK_THIS)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_THROW) != DUK_TOK_THROW)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_TRY) != DUK_TOK_TRY)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_TYPEOF) != DUK_TOK_TYPEOF)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_VAR) != DUK_TOK_VAR)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_VOID) != DUK_TOK_VOID)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_WHILE) != DUK_TOK_WHILE)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_WITH) != DUK_TOK_WITH)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_CLASS) != DUK_TOK_CLASS)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_CONST) != DUK_TOK_CONST)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_ENUM) != DUK_TOK_ENUM)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_EXPORT) != DUK_TOK_EXPORT)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_EXTENDS) != DUK_TOK_EXTENDS)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_IMPORT) != DUK_TOK_IMPORT)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_SUPER) != DUK_TOK_SUPER)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_LC_NULL) != DUK_TOK_NULL)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_TRUE) != DUK_TOK_TRUE)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_FALSE) != DUK_TOK_FALSE)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_IMPLEMENTS) != DUK_TOK_IMPLEMENTS)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_INTERFACE) != DUK_TOK_INTERFACE)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_LET) != DUK_TOK_LET)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_PACKAGE) != DUK_TOK_PACKAGE)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_PRIVATE) != DUK_TOK_PRIVATE)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_PROTECTED) != DUK_TOK_PROTECTED)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_PUBLIC) != DUK_TOK_PUBLIC)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_STATIC) != DUK_TOK_STATIC)\n#error mismatch in token defines\n#endif\n#if (DUK_STRIDX_TO_TOK(DUK_STRIDX_YIELD) != DUK_TOK_YIELD)\n#error mismatch in token defines\n#endif\n\n/* Regexp tokens */\n#define DUK_RETOK_EOF                              0\n#define DUK_RETOK_DISJUNCTION                      1\n#define DUK_RETOK_QUANTIFIER                       2\n#define DUK_RETOK_ASSERT_START                     3\n#define DUK_RETOK_ASSERT_END                       4\n#define DUK_RETOK_ASSERT_WORD_BOUNDARY             5\n#define DUK_RETOK_ASSERT_NOT_WORD_BOUNDARY         6\n#define DUK_RETOK_ASSERT_START_POS_LOOKAHEAD       7\n#define DUK_RETOK_ASSERT_START_NEG_LOOKAHEAD       8\n#define DUK_RETOK_ATOM_PERIOD                      9\n#define DUK_RETOK_ATOM_CHAR                        10\n#define DUK_RETOK_ATOM_DIGIT                       11  /* assumptions in regexp compiler */\n#define DUK_RETOK_ATOM_NOT_DIGIT                   12  /* -\"\"- */\n#define DUK_RETOK_ATOM_WHITE                       13  /* -\"\"- */\n#define DUK_RETOK_ATOM_NOT_WHITE                   14  /* -\"\"- */\n#define DUK_RETOK_ATOM_WORD_CHAR                   15  /* -\"\"- */\n#define DUK_RETOK_ATOM_NOT_WORD_CHAR               16  /* -\"\"- */\n#define DUK_RETOK_ATOM_BACKREFERENCE               17\n#define DUK_RETOK_ATOM_START_CAPTURE_GROUP         18\n#define DUK_RETOK_ATOM_START_NONCAPTURE_GROUP      19\n#define DUK_RETOK_ATOM_START_CHARCLASS             20\n#define DUK_RETOK_ATOM_START_CHARCLASS_INVERTED    21\n#define DUK_RETOK_ATOM_END_GROUP                   22\n\n/* Constants for duk_lexer_ctx.buf. */\n#define DUK_LEXER_TEMP_BUF_LIMIT                   256\n\n/* A token value.  Can be memcpy()'d, but note that slot1/slot2 values are on the valstack.\n * Some fields (like num, str1, str2) are only valid for specific token types and may have\n * stale values otherwise.\n */\nstruct duk_token {\n\tduk_small_int_t t;            /* token type (with reserved word identification) */\n\tduk_small_int_t t_nores;      /* token type (with reserved words as DUK_TOK_IDENTIFER) */\n\tduk_double_t num;             /* numeric value of token */\n\tduk_hstring *str1;            /* string 1 of token (borrowed, stored to ctx->slot1_idx) */\n\tduk_hstring *str2;            /* string 2 of token (borrowed, stored to ctx->slot2_idx) */\n\tduk_size_t start_offset;      /* start byte offset of token in lexer input */\n\tduk_int_t start_line;         /* start line of token (first char) */\n\tduk_int_t num_escapes;        /* number of escapes and line continuations (for directive prologue) */\n\tduk_bool_t lineterm;          /* token was preceded by a lineterm */\n\tduk_bool_t allow_auto_semi;   /* token allows automatic semicolon insertion (eof or preceded by newline) */\n};\n\n#define DUK_RE_QUANTIFIER_INFINITE         ((duk_uint32_t) 0xffffffffUL)\n\n/* A regexp token value. */\nstruct duk_re_token {\n\tduk_small_int_t t;           /* token type */\n\tduk_small_int_t greedy;\n\tduk_uint_fast32_t num;       /* numeric value (character, count) */\n\tduk_uint_fast32_t qmin;\n\tduk_uint_fast32_t qmax;\n};\n\n/* A structure for 'snapshotting' a point for rewinding */\nstruct duk_lexer_point {\n\tduk_size_t offset;\n\tduk_int_t line;\n};\n\n/* Lexer codepoint with additional info like offset/line number */\nstruct duk_lexer_codepoint {\n\tduk_codepoint_t codepoint;\n\tduk_size_t offset;\n\tduk_int_t line;\n};\n\n/* Lexer context.  Same context is used for Ecmascript and Regexp parsing. */\nstruct duk_lexer_ctx {\n#if defined(DUK_USE_LEXER_SLIDING_WINDOW)\n\tduk_lexer_codepoint *window; /* unicode code points, window[0] is always next, points to 'buffer' */\n\tduk_lexer_codepoint buffer[DUK_LEXER_BUFFER_SIZE];\n#else\n\tduk_lexer_codepoint window[DUK_LEXER_WINDOW_SIZE]; /* unicode code points, window[0] is always next */\n#endif\n\n\tduk_hthread *thr;                              /* thread; minimizes argument passing */\n\n\tconst duk_uint8_t *input;                      /* input string (may be a user pointer) */\n\tduk_size_t input_length;                       /* input byte length */\n\tduk_size_t input_offset;                       /* input offset for window leading edge (not window[0]) */\n\tduk_int_t input_line;                          /* input linenumber at input_offset (not window[0]), init to 1 */\n\n\tduk_idx_t slot1_idx;                           /* valstack slot for 1st token value */\n\tduk_idx_t slot2_idx;                           /* valstack slot for 2nd token value */\n\tduk_idx_t buf_idx;                             /* valstack slot for temp buffer */\n\tduk_hbuffer_dynamic *buf;                      /* temp accumulation buffer */\n\tduk_bufwriter_ctx bw;                          /* bufwriter for temp accumulation */\n\n\tduk_int_t token_count;                         /* number of tokens parsed */\n\tduk_int_t token_limit;                         /* maximum token count before error (sanity backstop) */\n\n\tduk_small_uint_t flags;                        /* lexer flags, use compiler flag defines for now */\n};\n\n/*\n *  Prototypes\n */\n\nDUK_INTERNAL_DECL void duk_lexer_initctx(duk_lexer_ctx *lex_ctx);\n\nDUK_INTERNAL_DECL void duk_lexer_getpoint(duk_lexer_ctx *lex_ctx, duk_lexer_point *pt);\nDUK_INTERNAL_DECL void duk_lexer_setpoint(duk_lexer_ctx *lex_ctx, duk_lexer_point *pt);\n\nDUK_INTERNAL_DECL\nvoid duk_lexer_parse_js_input_element(duk_lexer_ctx *lex_ctx,\n                                      duk_token *out_token,\n                                      duk_bool_t strict_mode,\n                                      duk_bool_t regexp_mode);\n#if defined(DUK_USE_REGEXP_SUPPORT)\nDUK_INTERNAL_DECL void duk_lexer_parse_re_token(duk_lexer_ctx *lex_ctx, duk_re_token *out_token);\nDUK_INTERNAL_DECL void duk_lexer_parse_re_ranges(duk_lexer_ctx *lex_ctx, duk_re_range_callback gen_range, void *userdata);\n#endif  /* DUK_USE_REGEXP_SUPPORT */\n\n#endif  /* DUK_LEXER_H_INCLUDED */\n/* #include duk_js_compiler.h */\n/*\n *  Ecmascript compiler.\n */\n\n#if !defined(DUK_JS_COMPILER_H_INCLUDED)\n#define DUK_JS_COMPILER_H_INCLUDED\n\n/* ecmascript compiler limits */\n#define DUK_COMPILER_TOKEN_LIMIT           100000000L  /* 1e8: protects against deeply nested inner functions */\n\n/* maximum loopcount for peephole optimization */\n#define DUK_COMPILER_PEEPHOLE_MAXITER      3\n\n/* maximum bytecode length in instructions */\n#define DUK_COMPILER_MAX_BYTECODE_LENGTH   (256L * 1024L * 1024L)  /* 1 GB */\n\n/*\n *  Compiler intermediate values\n *\n *  Intermediate values describe either plain values (e.g. strings or\n *  numbers) or binary operations which have not yet been coerced into\n *  either a left-hand-side or right-hand-side role (e.g. object property).\n */\n\n#define DUK_IVAL_NONE          0   /* no value */\n#define DUK_IVAL_PLAIN         1   /* register, constant, or value */\n#define DUK_IVAL_ARITH         2   /* binary arithmetic; DUK_OP_ADD, DUK_OP_EQ, other binary ops */\n#define DUK_IVAL_PROP          3   /* property access */\n#define DUK_IVAL_VAR           4   /* variable access */\n\n#define DUK_ISPEC_NONE         0   /* no value */\n#define DUK_ISPEC_VALUE        1   /* value resides in 'valstack_idx' */\n#define DUK_ISPEC_REGCONST     2   /* value resides in a register or constant */\n\n/* Bit mask which indicates that a regconst is a constant instead of a register.\n * Chosen so that when a regconst is cast to duk_int32_t, all consts are\n * negative values.\n */\n#define DUK_REGCONST_CONST_MARKER    0x80000000UL\n\n/* type to represent a reg/const reference during compilation */\ntypedef duk_uint32_t duk_regconst_t;\n\n/* type to represent a straight register reference, with <0 indicating none */\ntypedef duk_int32_t duk_reg_t;\n\ntypedef struct {\n\tduk_small_uint_t t;          /* DUK_ISPEC_XXX */\n\tduk_regconst_t regconst;\n\tduk_idx_t valstack_idx;      /* always set; points to a reserved valstack slot */\n} duk_ispec;\n\ntypedef struct {\n\t/*\n\t *  PLAIN: x1\n\t *  ARITH: x1 <op> x2\n\t *  PROP: x1.x2\n\t *  VAR: x1 (name)\n\t */\n\n\t/* XXX: can be optimized for smaller footprint esp. on 32-bit environments */\n\tduk_small_uint_t t;          /* DUK_IVAL_XXX */\n\tduk_small_uint_t op;         /* bytecode opcode for binary ops */\n\tduk_ispec x1;\n\tduk_ispec x2;\n} duk_ivalue;\n\n/*\n *  Bytecode instruction representation during compilation\n *\n *  Contains the actual instruction and (optionally) debug info.\n */\n\nstruct duk_compiler_instr {\n\tduk_instr_t ins;\n#if defined(DUK_USE_PC2LINE)\n\tduk_uint32_t line;\n#endif\n};\n\n/*\n *  Compiler state\n */\n\n#define DUK_LABEL_FLAG_ALLOW_BREAK       (1 << 0)\n#define DUK_LABEL_FLAG_ALLOW_CONTINUE    (1 << 1)\n\n#define DUK_DECL_TYPE_VAR                0\n#define DUK_DECL_TYPE_FUNC               1\n\n/* XXX: optimize to 16 bytes */\ntypedef struct {\n\tduk_small_uint_t flags;\n\tduk_int_t label_id;          /* numeric label_id (-1 reserved as marker) */\n\tduk_hstring *h_label;        /* borrowed label name */\n\tduk_int_t catch_depth;       /* catch depth at point of definition */\n\tduk_int_t pc_label;          /* pc of label statement:\n\t                              * pc+1: break jump site\n\t                              * pc+2: continue jump site\n\t                              */\n\n\t/* Fast jumps (which avoid longjmp) jump directly to the jump sites\n\t * which are always known even while the iteration/switch statement\n\t * is still being parsed.  A final peephole pass \"straightens out\"\n\t * the jumps.\n\t */\n} duk_labelinfo;\n\n/* Compiling state of one function, eventually converted to duk_hcompfunc */\nstruct duk_compiler_func {\n\t/* These pointers are at the start of the struct so that they pack\n\t * nicely.  Mixing pointers and integer values is bad on some\n\t * platforms (e.g. if int is 32 bits and pointers are 64 bits).\n\t */\n\n\tduk_bufwriter_ctx bw_code;          /* bufwriter for code */\n\n\tduk_hstring *h_name;                /* function name (borrowed reference), ends up in _name */\n\t/* h_code: held in bw_code */\n\tduk_hobject *h_consts;              /* array */\n\tduk_hobject *h_funcs;               /* array of function templates: [func1, offset1, line1, func2, offset2, line2]\n\t                                     * offset/line points to closing brace to allow skipping on pass 2\n\t                                     */\n\tduk_hobject *h_decls;               /* array of declarations: [ name1, val1, name2, val2, ... ]\n\t                                     * valN = (typeN) | (fnum << 8), where fnum is inner func number (0 for vars)\n\t                                     * record function and variable declarations in pass 1\n\t                                     */\n\tduk_hobject *h_labelnames;          /* array of active label names */\n\tduk_hbuffer_dynamic *h_labelinfos;  /* C array of duk_labelinfo */\n\tduk_hobject *h_argnames;            /* array of formal argument names (-> _Formals) */\n\tduk_hobject *h_varmap;              /* variable map for pass 2 (identifier -> register number or null (unmapped)) */\n\n\t/* Value stack indices for tracking objects. */\n\t/* code_idx: not needed */\n\tduk_idx_t consts_idx;\n\tduk_idx_t funcs_idx;\n\tduk_idx_t decls_idx;\n\tduk_idx_t labelnames_idx;\n\tduk_idx_t labelinfos_idx;\n\tduk_idx_t argnames_idx;\n\tduk_idx_t varmap_idx;\n\n\t/* Temp reg handling. */\n\tduk_reg_t temp_first;               /* first register that is a temporary (below: variables) */\n\tduk_reg_t temp_next;                /* next temporary register to allocate */\n\tduk_reg_t temp_max;                 /* highest value of temp_reg (temp_max - 1 is highest used reg) */\n\n\t/* Shuffle registers if large number of regs/consts. */\n\tduk_reg_t shuffle1;\n\tduk_reg_t shuffle2;\n\tduk_reg_t shuffle3;\n\n\t/* Stats for current expression being parsed. */\n\tduk_int_t nud_count;\n\tduk_int_t led_count;\n\tduk_int_t paren_level;              /* parenthesis count, 0 = top level */\n\tduk_bool_t expr_lhs;                /* expression is left-hand-side compatible */\n\tduk_bool_t allow_in;                /* current paren level allows 'in' token */\n\n\t/* Misc. */\n\tduk_int_t stmt_next;                /* statement id allocation (running counter) */\n\tduk_int_t label_next;               /* label id allocation (running counter) */\n\tduk_int_t catch_depth;              /* catch stack depth */\n\tduk_int_t with_depth;               /* with stack depth (affects identifier lookups) */\n\tduk_int_t fnum_next;                /* inner function numbering */\n\tduk_int_t num_formals;              /* number of formal arguments */\n\tduk_reg_t reg_stmt_value;           /* register for writing value of 'non-empty' statements (global or eval code), -1 is marker */\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\tduk_int_t min_line;                 /* XXX: typing (duk_hcompfunc has duk_uint32_t) */\n\tduk_int_t max_line;\n#endif\n\n\t/* Status booleans. */\n\tduk_uint8_t is_function;             /* is an actual function (not global/eval code) */\n\tduk_uint8_t is_eval;                 /* is eval code */\n\tduk_uint8_t is_global;               /* is global code */\n\tduk_uint8_t is_namebinding;          /* needs a name binding */\n\tduk_uint8_t is_constructable;        /* result is constructable */\n\tduk_uint8_t is_setget;               /* is a setter/getter */\n\tduk_uint8_t is_strict;               /* function is strict */\n\tduk_uint8_t is_notail;               /* function must not be tail called */\n\tduk_uint8_t in_directive_prologue;   /* parsing in \"directive prologue\", recognize directives */\n\tduk_uint8_t in_scanning;             /* parsing in \"scanning\" phase (first pass) */\n\tduk_uint8_t may_direct_eval;         /* function may call direct eval */\n\tduk_uint8_t id_access_arguments;     /* function refers to 'arguments' identifier */\n\tduk_uint8_t id_access_slow;          /* function makes one or more slow path accesses that won't match own static variables */\n\tduk_uint8_t id_access_slow_own;      /* function makes one or more slow path accesses that may match own static variables */\n\tduk_uint8_t is_arguments_shadowed;   /* argument/function declaration shadows 'arguments' */\n\tduk_uint8_t needs_shuffle;           /* function needs shuffle registers */\n\tduk_uint8_t reject_regexp_in_adv;    /* reject RegExp literal on next advance() call; needed for handling IdentifierName productions */\n};\n\nstruct duk_compiler_ctx {\n\tduk_hthread *thr;\n\n\t/* filename being compiled (ends up in functions' '_filename' property) */\n\tduk_hstring *h_filename;            /* borrowed reference */\n\n\t/* lexing (tokenization) state (contains two valstack slot indices) */\n\tduk_lexer_ctx lex;\n\n\t/* current and previous token for parsing */\n\tduk_token prev_token;\n\tduk_token curr_token;\n\tduk_idx_t tok11_idx;                /* curr_token slot1 (matches 'lex' slot1_idx) */\n\tduk_idx_t tok12_idx;                /* curr_token slot2 (matches 'lex' slot2_idx) */\n\tduk_idx_t tok21_idx;                /* prev_token slot1 */\n\tduk_idx_t tok22_idx;                /* prev_token slot2 */\n\n\t/* recursion limit */\n\tduk_int_t recursion_depth;\n\tduk_int_t recursion_limit;\n\n\t/* code emission temporary */\n\tduk_int_t emit_jumpslot_pc;\n\n\t/* current function being compiled (embedded instead of pointer for more compact access) */\n\tduk_compiler_func curr_func;\n};\n\n/*\n *  Prototypes\n */\n\nDUK_INTERNAL_DECL void duk_js_compile(duk_hthread *thr, const duk_uint8_t *src_buffer, duk_size_t src_length, duk_small_uint_t flags);\n\n#endif  /* DUK_JS_COMPILER_H_INCLUDED */\n/* #include duk_regexp.h */\n/*\n *  Regular expression structs, constants, and bytecode defines.\n */\n\n#if !defined(DUK_REGEXP_H_INCLUDED)\n#define DUK_REGEXP_H_INCLUDED\n\n/* maximum bytecode copies for {n,m} quantifiers */\n#define DUK_RE_MAX_ATOM_COPIES             1000\n\n/* regexp compilation limits */\n#define DUK_RE_COMPILE_TOKEN_LIMIT         100000000L   /* 1e8 */\n\n/* regexp execution limits */\n#define DUK_RE_EXECUTE_STEPS_LIMIT         1000000000L  /* 1e9 */\n\n/* regexp opcodes */\n#define DUK_REOP_MATCH                     1\n#define DUK_REOP_CHAR                      2\n#define DUK_REOP_PERIOD                    3\n#define DUK_REOP_RANGES                    4\n#define DUK_REOP_INVRANGES                 5\n#define DUK_REOP_JUMP                      6\n#define DUK_REOP_SPLIT1                    7\n#define DUK_REOP_SPLIT2                    8\n#define DUK_REOP_SQMINIMAL                 9\n#define DUK_REOP_SQGREEDY                  10\n#define DUK_REOP_SAVE                      11\n#define DUK_REOP_WIPERANGE                 12\n#define DUK_REOP_LOOKPOS                   13\n#define DUK_REOP_LOOKNEG                   14\n#define DUK_REOP_BACKREFERENCE             15\n#define DUK_REOP_ASSERT_START              16\n#define DUK_REOP_ASSERT_END                17\n#define DUK_REOP_ASSERT_WORD_BOUNDARY      18\n#define DUK_REOP_ASSERT_NOT_WORD_BOUNDARY  19\n\n/* flags */\n#define DUK_RE_FLAG_GLOBAL                 (1 << 0)\n#define DUK_RE_FLAG_IGNORE_CASE            (1 << 1)\n#define DUK_RE_FLAG_MULTILINE              (1 << 2)\n\nstruct duk_re_matcher_ctx {\n\tduk_hthread *thr;\n\n\tduk_uint32_t re_flags;\n\tconst duk_uint8_t *input;\n\tconst duk_uint8_t *input_end;\n\tconst duk_uint8_t *bytecode;\n\tconst duk_uint8_t *bytecode_end;\n\tconst duk_uint8_t **saved;  /* allocated from valstack (fixed buffer) */\n\tduk_uint32_t nsaved;\n\tduk_uint32_t recursion_depth;\n\tduk_uint32_t recursion_limit;\n\tduk_uint32_t steps_count;\n\tduk_uint32_t steps_limit;\n};\n\nstruct duk_re_compiler_ctx {\n\tduk_hthread *thr;\n\n\tduk_uint32_t re_flags;\n\tduk_lexer_ctx lex;\n\tduk_re_token curr_token;\n\tduk_bufwriter_ctx bw;\n\tduk_uint32_t captures;  /* highest capture number emitted so far (used as: ++captures) */\n\tduk_uint32_t highest_backref;\n\tduk_uint32_t recursion_depth;\n\tduk_uint32_t recursion_limit;\n\tduk_uint32_t nranges;  /* internal temporary value, used for char classes */\n};\n\n/*\n *  Prototypes\n */\n\n#if defined(DUK_USE_REGEXP_SUPPORT)\nDUK_INTERNAL_DECL void duk_regexp_compile(duk_hthread *thr);\nDUK_INTERNAL_DECL void duk_regexp_create_instance(duk_hthread *thr);\nDUK_INTERNAL_DECL void duk_regexp_match(duk_hthread *thr);\nDUK_INTERNAL_DECL void duk_regexp_match_force_global(duk_hthread *thr);  /* hacky helper for String.prototype.split() */\n#endif\n\n#endif  /* DUK_REGEXP_H_INCLUDED */\n/* #include duk_heaphdr.h */\n/*\n *  Heap header definition and assorted macros, including ref counting.\n *  Access all fields through the accessor macros.\n */\n\n#if !defined(DUK_HEAPHDR_H_INCLUDED)\n#define DUK_HEAPHDR_H_INCLUDED\n\n/*\n *  Common heap header\n *\n *  All heap objects share the same flags and refcount fields.  Objects other\n *  than strings also need to have a single or double linked list pointers\n *  for insertion into the \"heap allocated\" list.  Strings have single linked\n *  list pointers for string table chaining.\n *\n *  Technically, 'h_refcount' must be wide enough to guarantee that it cannot\n *  wrap; otherwise objects might be freed incorrectly after wrapping.  The\n *  default refcount field is 32 bits even on 64-bit systems: while that's in\n *  theory incorrect, the Duktape heap needs to be larger than 64GB for the\n *  count to actually wrap (assuming 16-byte duk_tvals).  This is very unlikely\n *  to ever be an issue, but if it is, disabling DUK_USE_REFCOUNT32 causes\n *  Duktape to use size_t for refcounts which should always be safe.\n *\n *  Heap header size on 32-bit platforms: 8 bytes without reference counting,\n *  16 bytes with reference counting.\n *\n *  Note that 'raw' macros such as DUK_HEAPHDR_GET_REFCOUNT() are not\n *  defined without DUK_USE_REFERENCE_COUNTING, so caller must #if defined()\n *  around them.\n */\n\n/* XXX: macro for shared header fields (avoids some padding issues) */\n\nstruct duk_heaphdr {\n\tduk_uint32_t h_flags;\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n#if defined(DUK_USE_ASSERTIONS)\n\t/* When assertions enabled, used by mark-and-sweep for refcount\n\t * validation.  Largest reasonable type; also detects overflows.\n\t */\n\tduk_size_t h_assert_refcount;\n#endif\n#if defined(DUK_USE_REFCOUNT16)\n\tduk_uint16_t h_refcount;\n#elif defined(DUK_USE_REFCOUNT32)\n\tduk_uint32_t h_refcount;\n#else\n\tduk_size_t h_refcount;\n#endif\n#endif  /* DUK_USE_REFERENCE_COUNTING */\n\n#if defined(DUK_USE_HEAPPTR16)\n\tduk_uint16_t h_next16;\n#else\n\tduk_heaphdr *h_next;\n#endif\n\n#if defined(DUK_USE_DOUBLE_LINKED_HEAP)\n\t/* refcounting requires direct heap frees, which in turn requires a dual linked heap */\n#if defined(DUK_USE_HEAPPTR16)\n\tduk_uint16_t h_prev16;\n#else\n\tduk_heaphdr *h_prev;\n#endif\n#endif\n\n\t/* When DUK_USE_HEAPPTR16 (and DUK_USE_REFCOUNT16) is in use, the\n\t * struct won't align nicely to 4 bytes.  This 16-bit extra field\n\t * is added to make the alignment clean; the field can be used by\n\t * heap objects when 16-bit packing is used.  This field is now\n\t * conditional to DUK_USE_HEAPPTR16 only, but it is intended to be\n\t * used with DUK_USE_REFCOUNT16 and DUK_USE_DOUBLE_LINKED_HEAP;\n\t * this only matter to low memory environments anyway.\n\t */\n#if defined(DUK_USE_HEAPPTR16)\n\tduk_uint16_t h_extra16;\n#endif\n};\n\nstruct duk_heaphdr_string {\n\t/* 16 bits would be enough for shared heaphdr flags and duk_hstring\n\t * flags.  The initial parts of duk_heaphdr_string and duk_heaphdr\n\t * must match so changing the flags field size here would be quite\n\t * awkward.  However, to minimize struct size, we can pack at least\n\t * 16 bits of duk_hstring data into the flags field.\n\t */\n\tduk_uint32_t h_flags;\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n#if defined(DUK_USE_ASSERTIONS)\n\t/* When assertions enabled, used by mark-and-sweep for refcount\n\t * validation.  Largest reasonable type; also detects overflows.\n\t */\n\tduk_size_t h_assert_refcount;\n#endif\n#if defined(DUK_USE_REFCOUNT16)\n\tduk_uint16_t h_refcount;\n\tduk_uint16_t h_strextra16;  /* round out to 8 bytes */\n#elif defined(DUK_USE_REFCOUNT32)\n\tduk_uint32_t h_refcount;\n#else\n\tduk_size_t h_refcount;\n#endif\n#else\n\tduk_uint16_t h_strextra16;\n#endif  /* DUK_USE_REFERENCE_COUNTING */\n\n\tduk_hstring *h_next;\n\t/* No 'h_prev' pointer for strings. */\n};\n\n#define DUK_HEAPHDR_FLAGS_TYPE_MASK      0x00000003UL\n#define DUK_HEAPHDR_FLAGS_FLAG_MASK      (~DUK_HEAPHDR_FLAGS_TYPE_MASK)\n\n                                             /* 2 bits for heap type */\n#define DUK_HEAPHDR_FLAGS_HEAP_START     2   /* 5 heap flags */\n#define DUK_HEAPHDR_FLAGS_USER_START     7   /* 25 user flags */\n\n#define DUK_HEAPHDR_HEAP_FLAG_NUMBER(n)  (DUK_HEAPHDR_FLAGS_HEAP_START + (n))\n#define DUK_HEAPHDR_USER_FLAG_NUMBER(n)  (DUK_HEAPHDR_FLAGS_USER_START + (n))\n#define DUK_HEAPHDR_HEAP_FLAG(n)         (1UL << (DUK_HEAPHDR_FLAGS_HEAP_START + (n)))\n#define DUK_HEAPHDR_USER_FLAG(n)         (1UL << (DUK_HEAPHDR_FLAGS_USER_START + (n)))\n\n#define DUK_HEAPHDR_FLAG_REACHABLE       DUK_HEAPHDR_HEAP_FLAG(0)  /* mark-and-sweep: reachable */\n#define DUK_HEAPHDR_FLAG_TEMPROOT        DUK_HEAPHDR_HEAP_FLAG(1)  /* mark-and-sweep: children not processed */\n#define DUK_HEAPHDR_FLAG_FINALIZABLE     DUK_HEAPHDR_HEAP_FLAG(2)  /* mark-and-sweep: finalizable (on current pass) */\n#define DUK_HEAPHDR_FLAG_FINALIZED       DUK_HEAPHDR_HEAP_FLAG(3)  /* mark-and-sweep: finalized (on previous pass) */\n#define DUK_HEAPHDR_FLAG_READONLY        DUK_HEAPHDR_HEAP_FLAG(4)  /* read-only object, in code section */\n\n#define DUK_HTYPE_MIN                    0\n#define DUK_HTYPE_STRING                 0\n#define DUK_HTYPE_OBJECT                 1\n#define DUK_HTYPE_BUFFER                 2\n#define DUK_HTYPE_MAX                    2\n\n#if defined(DUK_USE_HEAPPTR16)\n#define DUK_HEAPHDR_GET_NEXT(heap,h) \\\n\t((duk_heaphdr *) DUK_USE_HEAPPTR_DEC16((heap)->heap_udata, (h)->h_next16))\n#define DUK_HEAPHDR_SET_NEXT(heap,h,val)   do { \\\n\t\t(h)->h_next16 = DUK_USE_HEAPPTR_ENC16((heap)->heap_udata, (void *) val); \\\n\t} while (0)\n#else\n#define DUK_HEAPHDR_GET_NEXT(heap,h)  ((h)->h_next)\n#define DUK_HEAPHDR_SET_NEXT(heap,h,val)   do { \\\n\t\t(h)->h_next = (val); \\\n\t} while (0)\n#endif\n\n#if defined(DUK_USE_DOUBLE_LINKED_HEAP)\n#if defined(DUK_USE_HEAPPTR16)\n#define DUK_HEAPHDR_GET_PREV(heap,h) \\\n\t((duk_heaphdr *) DUK_USE_HEAPPTR_DEC16((heap)->heap_udata, (h)->h_prev16))\n#define DUK_HEAPHDR_SET_PREV(heap,h,val)   do { \\\n\t\t(h)->h_prev16 = DUK_USE_HEAPPTR_ENC16((heap)->heap_udata, (void *) (val)); \\\n\t} while (0)\n#else\n#define DUK_HEAPHDR_GET_PREV(heap,h)       ((h)->h_prev)\n#define DUK_HEAPHDR_SET_PREV(heap,h,val)   do { \\\n\t\t(h)->h_prev = (val); \\\n\t} while (0)\n#endif\n#endif\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n#define DUK_HEAPHDR_GET_REFCOUNT(h)   ((h)->h_refcount)\n#define DUK_HEAPHDR_SET_REFCOUNT(h,val)  do { \\\n\t\t(h)->h_refcount = (val); \\\n\t\tDUK_ASSERT((h)->h_refcount == (val));  /* No truncation. */ \\\n\t} while (0)\n#define DUK_HEAPHDR_PREINC_REFCOUNT(h)  (++(h)->h_refcount)  /* result: updated refcount */\n#define DUK_HEAPHDR_PREDEC_REFCOUNT(h)  (--(h)->h_refcount)  /* result: updated refcount */\n#else\n/* refcount macros not defined without refcounting, caller must #if defined() now */\n#endif  /* DUK_USE_REFERENCE_COUNTING */\n\n/*\n *  Note: type is treated as a field separate from flags, so some masking is\n *  involved in the macros below.\n */\n\n#define DUK_HEAPHDR_GET_FLAGS_RAW(h)  ((h)->h_flags)\n#define DUK_HEAPHDR_SET_FLAGS_RAW(h,val)  do { \\\n\t\t(h)->h_flags = (val); } \\\n\t}\n#define DUK_HEAPHDR_GET_FLAGS(h)      ((h)->h_flags & DUK_HEAPHDR_FLAGS_FLAG_MASK)\n#define DUK_HEAPHDR_SET_FLAGS(h,val)  do { \\\n\t\t(h)->h_flags = ((h)->h_flags & ~(DUK_HEAPHDR_FLAGS_FLAG_MASK)) | (val); \\\n\t} while (0)\n#define DUK_HEAPHDR_GET_TYPE(h)       ((h)->h_flags & DUK_HEAPHDR_FLAGS_TYPE_MASK)\n#define DUK_HEAPHDR_SET_TYPE(h,val)   do { \\\n\t\t(h)->h_flags = ((h)->h_flags & ~(DUK_HEAPHDR_FLAGS_TYPE_MASK)) | (val); \\\n\t} while (0)\n\n/* Comparison for type >= DUK_HTYPE_MIN skipped; because DUK_HTYPE_MIN is zero\n * and the comparison is unsigned, it's always true and generates warnings.\n */\n#define DUK_HEAPHDR_HTYPE_VALID(h)    ( \\\n\tDUK_HEAPHDR_GET_TYPE((h)) <= DUK_HTYPE_MAX \\\n\t)\n\n#define DUK_HEAPHDR_SET_TYPE_AND_FLAGS(h,tval,fval)  do { \\\n\t\t(h)->h_flags = ((tval) & DUK_HEAPHDR_FLAGS_TYPE_MASK) | \\\n\t\t               ((fval) & DUK_HEAPHDR_FLAGS_FLAG_MASK); \\\n\t} while (0)\n\n#define DUK_HEAPHDR_SET_FLAG_BITS(h,bits)  do { \\\n\t\tDUK_ASSERT(((bits) & ~(DUK_HEAPHDR_FLAGS_FLAG_MASK)) == 0); \\\n\t\t(h)->h_flags |= (bits); \\\n\t} while (0)\n\n#define DUK_HEAPHDR_CLEAR_FLAG_BITS(h,bits)  do { \\\n\t\tDUK_ASSERT(((bits) & ~(DUK_HEAPHDR_FLAGS_FLAG_MASK)) == 0); \\\n\t\t(h)->h_flags &= ~((bits)); \\\n\t} while (0)\n\n#define DUK_HEAPHDR_CHECK_FLAG_BITS(h,bits)  (((h)->h_flags & (bits)) != 0)\n\n#define DUK_HEAPHDR_SET_REACHABLE(h)      DUK_HEAPHDR_SET_FLAG_BITS((h),DUK_HEAPHDR_FLAG_REACHABLE)\n#define DUK_HEAPHDR_CLEAR_REACHABLE(h)    DUK_HEAPHDR_CLEAR_FLAG_BITS((h),DUK_HEAPHDR_FLAG_REACHABLE)\n#define DUK_HEAPHDR_HAS_REACHABLE(h)      DUK_HEAPHDR_CHECK_FLAG_BITS((h),DUK_HEAPHDR_FLAG_REACHABLE)\n\n#define DUK_HEAPHDR_SET_TEMPROOT(h)       DUK_HEAPHDR_SET_FLAG_BITS((h),DUK_HEAPHDR_FLAG_TEMPROOT)\n#define DUK_HEAPHDR_CLEAR_TEMPROOT(h)     DUK_HEAPHDR_CLEAR_FLAG_BITS((h),DUK_HEAPHDR_FLAG_TEMPROOT)\n#define DUK_HEAPHDR_HAS_TEMPROOT(h)       DUK_HEAPHDR_CHECK_FLAG_BITS((h),DUK_HEAPHDR_FLAG_TEMPROOT)\n\n#define DUK_HEAPHDR_SET_FINALIZABLE(h)    DUK_HEAPHDR_SET_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZABLE)\n#define DUK_HEAPHDR_CLEAR_FINALIZABLE(h)  DUK_HEAPHDR_CLEAR_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZABLE)\n#define DUK_HEAPHDR_HAS_FINALIZABLE(h)    DUK_HEAPHDR_CHECK_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZABLE)\n\n#define DUK_HEAPHDR_SET_FINALIZED(h)      DUK_HEAPHDR_SET_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZED)\n#define DUK_HEAPHDR_CLEAR_FINALIZED(h)    DUK_HEAPHDR_CLEAR_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZED)\n#define DUK_HEAPHDR_HAS_FINALIZED(h)      DUK_HEAPHDR_CHECK_FLAG_BITS((h),DUK_HEAPHDR_FLAG_FINALIZED)\n\n#define DUK_HEAPHDR_SET_READONLY(h)       DUK_HEAPHDR_SET_FLAG_BITS((h),DUK_HEAPHDR_FLAG_READONLY)\n#define DUK_HEAPHDR_CLEAR_READONLY(h)     DUK_HEAPHDR_CLEAR_FLAG_BITS((h),DUK_HEAPHDR_FLAG_READONLY)\n#define DUK_HEAPHDR_HAS_READONLY(h)       DUK_HEAPHDR_CHECK_FLAG_BITS((h),DUK_HEAPHDR_FLAG_READONLY)\n\n/* get or set a range of flags; m=first bit number, n=number of bits */\n#define DUK_HEAPHDR_GET_FLAG_RANGE(h,m,n)  (((h)->h_flags >> (m)) & ((1UL << (n)) - 1UL))\n\n#define DUK_HEAPHDR_SET_FLAG_RANGE(h,m,n,v)  do { \\\n\t\t(h)->h_flags = \\\n\t\t\t((h)->h_flags & (~(((1UL << (n)) - 1UL) << (m)))) \\\n\t\t\t| ((v) << (m)); \\\n\t} while (0)\n\n/* init pointer fields to null */\n#if defined(DUK_USE_DOUBLE_LINKED_HEAP)\n#define DUK_HEAPHDR_INIT_NULLS(h)       do { \\\n\t\tDUK_HEAPHDR_SET_NEXT((h), (void *) NULL); \\\n\t\tDUK_HEAPHDR_SET_PREV((h), (void *) NULL); \\\n\t} while (0)\n#else\n#define DUK_HEAPHDR_INIT_NULLS(h)       do { \\\n\t\tDUK_HEAPHDR_SET_NEXT((h), (void *) NULL); \\\n\t} while (0)\n#endif\n\n#define DUK_HEAPHDR_STRING_INIT_NULLS(h)  do { \\\n\t\t(h)->h_next = NULL; \\\n\t} while (0)\n\n/*\n *  Type tests\n */\n\n/* Take advantage of the fact that for DUK_HTYPE_xxx numbers the lowest bit\n * is only set for DUK_HTYPE_OBJECT (= 1).\n */\n#if 0\n#define DUK_HEAPHDR_IS_OBJECT(h) (DUK_HEAPHDR_GET_TYPE((h)) == DUK_HTYPE_OBJECT)\n#endif\n#define DUK_HEAPHDR_IS_OBJECT(h) ((h)->h_flags & 0x01UL)\n#define DUK_HEAPHDR_IS_STRING(h) (DUK_HEAPHDR_GET_TYPE((h)) == DUK_HTYPE_STRING)\n#define DUK_HEAPHDR_IS_BUFFER(h) (DUK_HEAPHDR_GET_TYPE((h)) == DUK_HTYPE_BUFFER)\n\n/*\n *  Assert helpers\n */\n\n/* Check that prev/next links are consistent: if e.g. h->prev is != NULL,\n * h->prev->next should point back to h.\n */\n#if defined(DUK_USE_DOUBLE_LINKED_HEAP) && defined(DUK_USE_ASSERTIONS)\n#define DUK_ASSERT_HEAPHDR_LINKS(heap,h) do { \\\n\t\tif ((h) != NULL) { \\\n\t\t\tduk_heaphdr *h__prev, *h__next; \\\n\t\t\th__prev = DUK_HEAPHDR_GET_PREV((heap), (h)); \\\n\t\t\th__next = DUK_HEAPHDR_GET_NEXT((heap), (h)); \\\n\t\t\tDUK_ASSERT(h__prev == NULL || (DUK_HEAPHDR_GET_NEXT((heap), h__prev) == (h))); \\\n\t\t\tDUK_ASSERT(h__next == NULL || (DUK_HEAPHDR_GET_PREV((heap), h__next) == (h))); \\\n\t\t} \\\n\t} while (0)\n#else\n#define DUK_ASSERT_HEAPHDR_LINKS(heap,h) do {} while (0)\n#endif\n\n#define DUK_ASSERT_HEAPHDR_VALID(h) do { \\\n\t\tDUK_ASSERT((h) != NULL); \\\n\t\tDUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID((h))); \\\n\t} while (0)\n\n#endif  /* DUK_HEAPHDR_H_INCLUDED */\n/* #include duk_refcount.h */\n/*\n *  Reference counting helper macros.  The macros take a thread argument\n *  and must thus always be executed in a specific thread context.  The\n *  thread argument is not really needed anymore: DECREF can operate with\n *  a heap pointer only, and INCREF needs neither.\n */\n\n#if !defined(DUK_REFCOUNT_H_INCLUDED)\n#define DUK_REFCOUNT_H_INCLUDED\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\n#if defined(DUK_USE_ROM_OBJECTS)\n/* With ROM objects \"needs refcount update\" is true when the value is\n * heap allocated and is not a ROM object.\n */\n/* XXX: double evaluation for 'tv' argument. */\n#define DUK_TVAL_NEEDS_REFCOUNT_UPDATE(tv) \\\n\t(DUK_TVAL_IS_HEAP_ALLOCATED((tv)) && !DUK_HEAPHDR_HAS_READONLY(DUK_TVAL_GET_HEAPHDR((tv))))\n#define DUK_HEAPHDR_NEEDS_REFCOUNT_UPDATE(h)  (!DUK_HEAPHDR_HAS_READONLY((h)))\n#else  /* DUK_USE_ROM_OBJECTS */\n/* Without ROM objects \"needs refcount update\" == is heap allocated. */\n#define DUK_TVAL_NEEDS_REFCOUNT_UPDATE(tv)    DUK_TVAL_IS_HEAP_ALLOCATED((tv))\n#define DUK_HEAPHDR_NEEDS_REFCOUNT_UPDATE(h)  1\n#endif  /* DUK_USE_ROM_OBJECTS */\n\n/* Fast variants, inline refcount operations except for refzero handling.\n * Can be used explicitly when speed is always more important than size.\n * For a good compiler and a single file build, these are basically the\n * same as a forced inline.\n */\n#define DUK_TVAL_INCREF_FAST(thr,tv) do { \\\n\t\tduk_tval *duk__tv = (tv); \\\n\t\tDUK_ASSERT(duk__tv != NULL); \\\n\t\tif (DUK_TVAL_NEEDS_REFCOUNT_UPDATE(duk__tv)) { \\\n\t\t\tduk_heaphdr *duk__h = DUK_TVAL_GET_HEAPHDR(duk__tv); \\\n\t\t\tDUK_ASSERT(duk__h != NULL); \\\n\t\t\tDUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID(duk__h)); \\\n\t\t\tDUK_HEAPHDR_PREINC_REFCOUNT(duk__h); \\\n\t\t\tDUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT(duk__h) != 0);  /* No wrapping. */ \\\n\t\t} \\\n\t} while (0)\n#define DUK_TVAL_DECREF_FAST(thr,tv) do { \\\n\t\tduk_tval *duk__tv = (tv); \\\n\t\tDUK_ASSERT(duk__tv != NULL); \\\n\t\tif (DUK_TVAL_NEEDS_REFCOUNT_UPDATE(duk__tv)) { \\\n\t\t\tduk_heaphdr *duk__h = DUK_TVAL_GET_HEAPHDR(duk__tv); \\\n\t\t\tDUK_ASSERT(duk__h != NULL); \\\n\t\t\tDUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID(duk__h)); \\\n\t\t\tDUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT(duk__h) > 0); \\\n\t\t\tif (DUK_HEAPHDR_PREDEC_REFCOUNT(duk__h) == 0) { \\\n\t\t\t\tduk_heaphdr_refzero((thr), duk__h); \\\n\t\t\t} \\\n\t\t} \\\n\t} while (0)\n#define DUK_TVAL_DECREF_NORZ_FAST(thr,tv) do { \\\n\t\tduk_tval *duk__tv = (tv); \\\n\t\tDUK_ASSERT(duk__tv != NULL); \\\n\t\tif (DUK_TVAL_NEEDS_REFCOUNT_UPDATE(duk__tv)) { \\\n\t\t\tduk_heaphdr *duk__h = DUK_TVAL_GET_HEAPHDR(duk__tv); \\\n\t\t\tDUK_ASSERT(duk__h != NULL); \\\n\t\t\tDUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID(duk__h)); \\\n\t\t\tDUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT(duk__h) > 0); \\\n\t\t\tif (DUK_HEAPHDR_PREDEC_REFCOUNT(duk__h) == 0) { \\\n\t\t\t\tduk_heaphdr_refzero_norz((thr), duk__h); \\\n\t\t\t} \\\n\t\t} \\\n\t} while (0)\n#define DUK_HEAPHDR_INCREF_FAST(thr,h) do { \\\n\t\tduk_heaphdr *duk__h = (duk_heaphdr *) (h); \\\n\t\tDUK_ASSERT(duk__h != NULL); \\\n\t\tDUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID(duk__h)); \\\n\t\tif (DUK_HEAPHDR_NEEDS_REFCOUNT_UPDATE(duk__h)) { \\\n\t\t\tDUK_HEAPHDR_PREINC_REFCOUNT(duk__h); \\\n\t\t\tDUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT(duk__h) != 0);  /* No wrapping. */ \\\n\t\t} \\\n\t} while (0)\n#define DUK_HEAPHDR_DECREF_FAST_RAW(thr,h,rzcall,rzcast) do { \\\n\t\tduk_heaphdr *duk__h = (duk_heaphdr *) (h); \\\n\t\tDUK_ASSERT(duk__h != NULL); \\\n\t\tDUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID(duk__h)); \\\n\t\tDUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT(duk__h) > 0); \\\n\t\tif (DUK_HEAPHDR_NEEDS_REFCOUNT_UPDATE(duk__h)) { \\\n\t\t\tif (DUK_HEAPHDR_PREDEC_REFCOUNT(duk__h) == 0) { \\\n\t\t\t\t(rzcall)((thr), (rzcast) duk__h); \\\n\t\t\t} \\\n\t\t} \\\n\t} while (0)\n#define DUK_HEAPHDR_DECREF_FAST(thr,h) \\\n\tDUK_HEAPHDR_DECREF_FAST_RAW((thr),(h),duk_heaphdr_refzero,duk_heaphdr *)\n#define DUK_HEAPHDR_DECREF_NORZ_FAST(thr,h) \\\n\tDUK_HEAPHDR_DECREF_FAST_RAW((thr),(h),duk_heaphdr_refzero_norz,duk_heaphdr *)\n\n/* Slow variants, call to a helper to reduce code size.\n * Can be used explicitly when size is always more important than speed.\n */\n#define DUK_TVAL_INCREF_SLOW(thr,tv)         do { duk_tval_incref((tv)); } while (0)\n#define DUK_TVAL_DECREF_SLOW(thr,tv)         do { duk_tval_decref((thr), (tv)); } while (0)\n#define DUK_TVAL_DECREF_NORZ_SLOW(thr,tv)    do { duk_tval_decref_norz((thr), (tv)); } while (0)\n#define DUK_HEAPHDR_INCREF_SLOW(thr,h)       do { duk_heaphdr_incref((duk_heaphdr *) (h)); } while (0)\n#define DUK_HEAPHDR_DECREF_SLOW(thr,h)       do { duk_heaphdr_decref((thr), (duk_heaphdr *) (h)); } while (0)\n#define DUK_HEAPHDR_DECREF_NORZ_SLOW(thr,h)  do { duk_heaphdr_decref_norz((thr), (duk_heaphdr *) (h)); } while (0)\n#define DUK_HSTRING_INCREF_SLOW(thr,h)       do { duk_heaphdr_incref((duk_heaphdr *) (h)); } while (0)\n#define DUK_HSTRING_DECREF_SLOW(thr,h)       do { duk_heaphdr_decref((thr), (duk_heaphdr *) (h)); } while (0)\n#define DUK_HSTRING_DECREF_NORZ_SLOW(thr,h)  do { duk_heaphdr_decref_norz((thr), (duk_heaphdr *) (h)); } while (0)\n#define DUK_HBUFFER_INCREF_SLOW(thr,h)       do { duk_heaphdr_incref((duk_heaphdr *) (h)); } while (0)\n#define DUK_HBUFFER_DECREF_SLOW(thr,h)       do { duk_heaphdr_decref((thr), (duk_heaphdr *) (h)); } while (0)\n#define DUK_HBUFFER_DECREF_NORZ_SLOW(thr,h)  do { duk_heaphdr_decref_norz((thr), (duk_heaphdr *) (h)); } while (0)\n#define DUK_HOBJECT_INCREF_SLOW(thr,h)       do { duk_heaphdr_incref((duk_heaphdr *) (h)); } while (0)\n#define DUK_HOBJECT_DECREF_SLOW(thr,h)       do { duk_heaphdr_decref((thr), (duk_heaphdr *) (h)); } while (0)\n#define DUK_HOBJECT_DECREF_NORZ_SLOW(thr,h)  do { duk_heaphdr_decref_norz((thr), (duk_heaphdr *) (h)); } while (0)\n\n/* Default variants.  Selection depends on speed/size preference.\n * Concretely: with gcc 4.8.1 -Os x64 the difference in final binary\n * is about +1kB for _FAST variants.\n */\n#if defined(DUK_USE_FAST_REFCOUNT_DEFAULT)\n/* XXX: It would be nice to specialize for specific duk_hobject subtypes\n * but current refzero queue handling prevents that.\n */\n#define DUK_TVAL_INCREF(thr,tv)                DUK_TVAL_INCREF_FAST((thr),(tv))\n#define DUK_TVAL_DECREF(thr,tv)                DUK_TVAL_DECREF_FAST((thr),(tv))\n#define DUK_TVAL_DECREF_NORZ(thr,tv)           DUK_TVAL_DECREF_NORZ_FAST((thr),(tv))\n#define DUK_HEAPHDR_INCREF(thr,h)              DUK_HEAPHDR_INCREF_FAST((thr),(h))\n#define DUK_HEAPHDR_DECREF(thr,h)              DUK_HEAPHDR_DECREF_FAST_RAW((thr),(h),duk_heaphdr_refzero,duk_heaphdr *)\n#define DUK_HEAPHDR_DECREF_NORZ(thr,h)         DUK_HEAPHDR_DECREF_FAST_RAW((thr),(h),duk_heaphdr_refzero_norz,duk_heaphdr *)\n#define DUK_HSTRING_INCREF(thr,h)              DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))\n#define DUK_HSTRING_DECREF(thr,h)              DUK_HEAPHDR_DECREF_FAST_RAW((thr),(h),duk_hstring_refzero,duk_hstring *)\n#define DUK_HSTRING_DECREF_NORZ(thr,h)         DUK_HEAPHDR_DECREF_FAST_RAW((thr),(h),duk_hstring_refzero,duk_hstring *)  /* no 'norz' variant */\n#define DUK_HOBJECT_INCREF(thr,h)              DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))\n#define DUK_HOBJECT_DECREF(thr,h)              DUK_HEAPHDR_DECREF_FAST_RAW((thr),(h),duk_hobject_refzero,duk_hobject *)\n#define DUK_HOBJECT_DECREF_NORZ(thr,h)         DUK_HEAPHDR_DECREF_FAST_RAW((thr),(h),duk_hobject_refzero_norz,duk_hobject *)\n#define DUK_HBUFFER_INCREF(thr,h)              DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))\n#define DUK_HBUFFER_DECREF(thr,h)              DUK_HEAPHDR_DECREF_FAST_RAW((thr),(h),duk_hbuffer_refzero,duk_hbuffer *)\n#define DUK_HBUFFER_DECREF_NORZ(thr,h)         DUK_HEAPHDR_DECREF_FAST_RAW((thr),(h),duk_hbuffer_refzero,duk_hbuffer *)  /* no 'norz' variant */\n#define DUK_HCOMPFUNC_INCREF(thr,h)            DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)\n#define DUK_HCOMPFUNC_DECREF(thr,h)            DUK_HEAPHDR_DECREF_FAST_RAW((thr),(h),duk_hobject_refzero,duk_hobject *)\n#define DUK_HCOMPFUNC_DECREF_NORZ(thr,h)       DUK_HEAPHDR_DECREF_FAST_RAW((thr),(h),duk_hobject_refzero_norz,duk_hobject *)\n#define DUK_HNATFUNC_INCREF(thr,h)             DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)\n#define DUK_HNATFUNC_DECREF(thr,h)             DUK_HEAPHDR_DECREF_FAST_RAW((thr),(h),duk_hobject_refzero,duk_hobject *)\n#define DUK_HNATFUNC_DECREF_NORZ(thr,h)        DUK_HEAPHDR_DECREF_FAST_RAW((thr),(h),duk_hobject_refzero_norz,duk_hobject *)\n#define DUK_HBUFOBJ_INCREF(thr,h)              DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)\n#define DUK_HBUFOBJ_DECREF(thr,h)              DUK_HEAPHDR_DECREF_FAST_RAW((thr),(h),duk_hobject_refzero,duk_hobject *)\n#define DUK_HBUFOBJ_DECREF_NORZ(thr,h)         DUK_HEAPHDR_DECREF_FAST_RAW((thr),(h),duk_hobject_refzero_norz,duk_hobject *)\n#define DUK_HTHREAD_INCREF(thr,h)              DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)\n#define DUK_HTHREAD_DECREF(thr,h)              DUK_HEAPHDR_DECREF_FAST_RAW((thr),(h),duk_hobject_refzero,duk_hobject *)\n#define DUK_HTHREAD_DECREF_NORZ(thr,h)         DUK_HEAPHDR_DECREF_FAST_RAW((thr),(h),duk_hobject_refzero_norz,duk_hobject *)\n#else\n#define DUK_TVAL_INCREF(thr,tv)                DUK_TVAL_INCREF_SLOW((thr),(tv))\n#define DUK_TVAL_DECREF(thr,tv)                DUK_TVAL_DECREF_SLOW((thr),(tv))\n#define DUK_TVAL_DECREF_NORZ(thr,tv)           DUK_TVAL_DECREF_NORZ_SLOW((thr),(tv))\n#define DUK_HEAPHDR_INCREF(thr,h)              DUK_HEAPHDR_INCREF_SLOW((thr),(h))\n#define DUK_HEAPHDR_DECREF(thr,h)              DUK_HEAPHDR_DECREF_SLOW((thr),(h))\n#define DUK_HEAPHDR_DECREF_NORZ(thr,h)         DUK_HEAPHDR_DECREF_NORZ_SLOW((thr),(h))\n#define DUK_HSTRING_INCREF(thr,h)              DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))\n#define DUK_HSTRING_DECREF(thr,h)              DUK_HSTRING_DECREF_SLOW((thr),(h))\n#define DUK_HSTRING_DECREF_NORZ(thr,h)         DUK_HSTRING_DECREF_NORZ_SLOW((thr),(h))\n#define DUK_HOBJECT_INCREF(thr,h)              DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))\n#define DUK_HOBJECT_DECREF(thr,h)              DUK_HOBJECT_DECREF_SLOW((thr),(h))\n#define DUK_HOBJECT_DECREF_NORZ(thr,h)         DUK_HOBJECT_DECREF_NORZ_SLOW((thr),(h))\n#define DUK_HBUFFER_INCREF(thr,h)              DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))\n#define DUK_HBUFFER_DECREF(thr,h)              DUK_HBUFFER_DECREF_SLOW((thr),(h))\n#define DUK_HBUFFER_DECREF_NORZ(thr,h)         DUK_HBUFFER_DECREF_NORZ_SLOW((thr),(h))\n#define DUK_HCOMPFUNC_INCREF(thr,h)            DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)\n#define DUK_HCOMPFUNC_DECREF(thr,h)            DUK_HOBJECT_DECREF_SLOW((thr),(duk_hobject *) &(h)->obj)\n#define DUK_HCOMPFUNC_DECREF_NORZ(thr,h)       DUK_HOBJECT_DECREF_NORZ_SLOW((thr),(duk_hobject *) &(h)->obj)\n#define DUK_HNATFUNC_INCREF(thr,h)             DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)\n#define DUK_HNATFUNC_DECREF(thr,h)             DUK_HOBJECT_DECREF_SLOW((thr),(duk_hobject *) &(h)->obj)\n#define DUK_HNATFUNC_DECREF_NORZ(thr,h)        DUK_HOBJECT_DECREF_NORZ_SLOW((thr),(duk_hobject *) &(h)->obj)\n#define DUK_HBUFOBJ_INCREF(thr,h)              DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)\n#define DUK_HBUFOBJ_DECREF(thr,h)              DUK_HOBJECT_DECREF_SLOW((thr),(duk_hobject *) &(h)->obj)\n#define DUK_HBUFOB_DECREF_NORZ(thr,h)          DUK_HOBJECT_DECREF_NORZ_SLOW((thr),(duk_hobject *) &(h)->obj)\n#define DUK_HTHREAD_INCREF(thr,h)              DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)\n#define DUK_HTHREAD_DECREF(thr,h)              DUK_HOBJECT_DECREF_SLOW((thr),(duk_hobject *) &(h)->obj)\n#define DUK_HTHREAD_DECREF_NORZ(thr,h)         DUK_HOBJECT_DECREF_NORZ_SLOW((thr),(duk_hobject *) &(h)->obj)\n#endif\n\n/* Convenience for some situations; the above macros don't allow NULLs\n * for performance reasons.  Macros cover only actually needed cases.\n */\n#define DUK_HEAPHDR_INCREF_ALLOWNULL(thr,h) do { \\\n\t\tif ((h) != NULL) { \\\n\t\t\tDUK_HEAPHDR_INCREF((thr), (duk_heaphdr *) (h)); \\\n\t\t} \\\n\t} while (0)\n#define DUK_HEAPHDR_DECREF_ALLOWNULL(thr,h) do { \\\n\t\tif ((h) != NULL) { \\\n\t\t\tDUK_HEAPHDR_DECREF((thr), (duk_heaphdr *) (h)); \\\n\t\t} \\\n\t} while (0)\n#define DUK_HEAPHDR_DECREF_NORZ_ALLOWNULL(thr,h) do { \\\n\t\tif ((h) != NULL) { \\\n\t\t\tDUK_HEAPHDR_DECREF_NORZ((thr), (duk_heaphdr *) (h)); \\\n\t\t} \\\n\t} while (0)\n#define DUK_HOBJECT_INCREF_ALLOWNULL(thr,h) do { \\\n\t\tif ((h) != NULL) { \\\n\t\t\tDUK_HOBJECT_INCREF((thr), (h)); \\\n\t\t} \\\n\t} while (0)\n#define DUK_HOBJECT_DECREF_ALLOWNULL(thr,h) do { \\\n\t\tif ((h) != NULL) { \\\n\t\t\tDUK_HOBJECT_DECREF((thr), (h)); \\\n\t\t} \\\n\t} while (0)\n#define DUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr,h) do { \\\n\t\tif ((h) != NULL) { \\\n\t\t\tDUK_HOBJECT_DECREF_NORZ((thr), (h)); \\\n\t\t} \\\n\t} while (0)\n#define DUK_HBUFFER_INCREF_ALLOWNULL(thr,h) do { \\\n\t\tif ((h) != NULL) { \\\n\t\t\tDUK_HBUFFER_INCREF((thr), (h)); \\\n\t\t} \\\n\t} while (0)\n#define DUK_HBUFFER_DECREF_ALLOWNULL(thr,h) do { \\\n\t\tif ((h) != NULL) { \\\n\t\t\tDUK_HBUFFER_DECREF((thr), (h)); \\\n\t\t} \\\n\t} while (0)\n#define DUK_HBUFFER_DECREF_NORZ_ALLOWNULL(thr,h) do { \\\n\t\tif ((h) != NULL) { \\\n\t\t\tDUK_HBUFFER_DECREF_NORZ((thr), (h)); \\\n\t\t} \\\n\t} while (0)\n#define DUK_HTHREAD_INCREF_ALLOWNULL(thr,h) do { \\\n\t\tif ((h) != NULL) { \\\n\t\t\tDUK_HTHREAD_INCREF((thr), (h)); \\\n\t\t} \\\n\t} while (0)\n#define DUK_HTHREAD_DECREF_ALLOWNULL(thr,h) do { \\\n\t\tif ((h) != NULL) { \\\n\t\t\tDUK_HTHREAD_DECREF((thr), (h)); \\\n\t\t} \\\n\t} while (0)\n#define DUK_HTHREAD_DECREF_NORZ_ALLOWNULL(thr,h) do { \\\n\t\tif ((h) != NULL) { \\\n\t\t\tDUK_HTHREAD_DECREF_NORZ((thr), (h)); \\\n\t\t} \\\n\t} while (0)\n\n/* Called after one or more DECREF NORZ calls to handle pending side effects.\n * At present DECREF NORZ does freeing inline but doesn't execute finalizers,\n * so these macros check for pending finalizers and execute them.  The FAST\n * variant is performance critical.\n */\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n#define DUK_REFZERO_CHECK_FAST(thr) do { \\\n\t\tduk_refzero_check_fast((thr)); \\\n\t} while (0)\n#define DUK_REFZERO_CHECK_SLOW(thr) do { \\\n\t\tduk_refzero_check_slow((thr)); \\\n\t} while (0)\n#else  /* DUK_USE_FINALIZER_SUPPORT */\n#define DUK_REFZERO_CHECK_FAST(thr) do { } while (0)\n#define DUK_REFZERO_CHECK_SLOW(thr) do { } while (0)\n#endif  /* DUK_USE_FINALIZER_SUPPORT */\n\n/*\n *  Macros to set a duk_tval and update refcount of the target (decref the\n *  old value and incref the new value if necessary).  This is both performance\n *  and footprint critical; any changes made should be measured for size/speed.\n */\n\n#define DUK_TVAL_SET_UNDEFINED_UPDREF_ALT0(thr,tvptr_dst) do { \\\n\t\tduk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \\\n\t\tDUK_TVAL_SET_UNDEFINED(tv__dst); \\\n\t\tDUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \\\n\t} while (0)\n\n#define DUK_TVAL_SET_UNDEFINED_UPDREF_NORZ_ALT0(thr,tvptr_dst) do { \\\n\t\tduk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \\\n\t\tDUK_TVAL_SET_UNDEFINED(tv__dst); \\\n\t\tDUK_TVAL_DECREF_NORZ((thr), &tv__tmp); \\\n\t} while (0)\n\n#define DUK_TVAL_SET_UNUSED_UPDREF_ALT0(thr,tvptr_dst) do { \\\n\t\tduk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \\\n\t\tDUK_TVAL_SET_UNUSED(tv__dst); \\\n\t\tDUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \\\n\t} while (0)\n\n#define DUK_TVAL_SET_NULL_UPDREF_ALT0(thr,tvptr_dst) do { \\\n\t\tduk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \\\n\t\tDUK_TVAL_SET_NULL(tv__dst); \\\n\t\tDUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \\\n\t} while (0)\n\n#define DUK_TVAL_SET_BOOLEAN_UPDREF_ALT0(thr,tvptr_dst,newval) do { \\\n\t\tduk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \\\n\t\tDUK_TVAL_SET_BOOLEAN(tv__dst, (newval)); \\\n\t\tDUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \\\n\t} while (0)\n\n#define DUK_TVAL_SET_NUMBER_UPDREF_ALT0(thr,tvptr_dst,newval) do { \\\n\t\tduk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \\\n\t\tDUK_TVAL_SET_NUMBER(tv__dst, (newval)); \\\n\t\tDUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \\\n\t} while (0)\n#define DUK_TVAL_SET_NUMBER_CHKFAST_UPDREF_ALT0(thr,tvptr_dst,newval) do { \\\n\t\tduk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \\\n\t\tDUK_TVAL_SET_NUMBER_CHKFAST_FAST(tv__dst, (newval)); \\\n\t\tDUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \\\n\t} while (0)\n#define DUK_TVAL_SET_DOUBLE_UPDREF_ALT0(thr,tvptr_dst,newval) do { \\\n\t\tduk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \\\n\t\tDUK_TVAL_SET_DOUBLE(tv__dst, (newval)); \\\n\t\tDUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \\\n\t} while (0)\n#define DUK_TVAL_SET_NAN_UPDREF_ALT0(thr,tvptr_dst) do { \\\n\t\tduk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \\\n\t\tDUK_TVAL_SET_NAN(tv__dst); \\\n\t\tDUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \\\n\t} while (0)\n#if defined(DUK_USE_FASTINT)\n#define DUK_TVAL_SET_I48_UPDREF_ALT0(thr,tvptr_dst,newval) do { \\\n\t\tduk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \\\n\t\tDUK_TVAL_SET_I48(tv__dst, (newval)); \\\n\t\tDUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \\\n\t} while (0)\n#define DUK_TVAL_SET_I32_UPDREF_ALT0(thr,tvptr_dst,newval) do { \\\n\t\tduk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \\\n\t\tDUK_TVAL_SET_I32(tv__dst, (newval)); \\\n\t\tDUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \\\n\t} while (0)\n#define DUK_TVAL_SET_U32_UPDREF_ALT0(thr,tvptr_dst,newval) do { \\\n\t\tduk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \\\n\t\tDUK_TVAL_SET_U32(tv__dst, (newval)); \\\n\t\tDUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \\\n\t} while (0)\n#else\n#define DUK_TVAL_SET_DOUBLE_CAST_UPDREF(thr,tvptr_dst,newval) \\\n\tDUK_TVAL_SET_DOUBLE_UPDREF((thr), (tvptr_dst), (duk_double_t) (newval))\n#endif  /* DUK_USE_FASTINT */\n\n#define DUK_TVAL_SET_LIGHTFUNC_UPDREF_ALT0(thr,tvptr_dst,lf_v,lf_fp,lf_flags) do { \\\n\t\tduk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \\\n\t\tDUK_TVAL_SET_LIGHTFUNC(tv__dst, (lf_v), (lf_fp), (lf_flags)); \\\n\t\tDUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \\\n\t} while (0)\n\n#define DUK_TVAL_SET_STRING_UPDREF_ALT0(thr,tvptr_dst,newval) do { \\\n\t\tduk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \\\n\t\tDUK_TVAL_SET_STRING(tv__dst, (newval)); \\\n\t\tDUK_HSTRING_INCREF((thr), (newval)); \\\n\t\tDUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \\\n\t} while (0)\n\n#define DUK_TVAL_SET_OBJECT_UPDREF_ALT0(thr,tvptr_dst,newval) do { \\\n\t\tduk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \\\n\t\tDUK_TVAL_SET_OBJECT(tv__dst, (newval)); \\\n\t\tDUK_HOBJECT_INCREF((thr), (newval)); \\\n\t\tDUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \\\n\t} while (0)\n\n#define DUK_TVAL_SET_BUFFER_UPDREF_ALT0(thr,tvptr_dst,newval) do { \\\n\t\tduk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \\\n\t\tDUK_TVAL_SET_BUFFER(tv__dst, (newval)); \\\n\t\tDUK_HBUFFER_INCREF((thr), (newval)); \\\n\t\tDUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \\\n\t} while (0)\n\n#define DUK_TVAL_SET_POINTER_UPDREF_ALT0(thr,tvptr_dst,newval) do { \\\n\t\tduk_tval *tv__dst; duk_tval tv__tmp; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \\\n\t\tDUK_TVAL_SET_POINTER(tv__dst, (newval)); \\\n\t\tDUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \\\n\t} while (0)\n\n/* DUK_TVAL_SET_TVAL_UPDREF() is used a lot in executor, property lookups,\n * etc, so it's very important for performance.  Measure when changing.\n *\n * NOTE: the source and destination duk_tval pointers may be the same, and\n * the macros MUST deal with that correctly.\n */\n\n/* Original idiom used, minimal code size. */\n#define DUK_TVAL_SET_TVAL_UPDREF_ALT0(thr,tvptr_dst,tvptr_src) do { \\\n\t\tduk_tval *tv__dst, *tv__src; duk_tval tv__tmp; \\\n\t\ttv__dst = (tvptr_dst); tv__src = (tvptr_src); \\\n\t\tDUK_TVAL_SET_TVAL(&tv__tmp, tv__dst); \\\n\t\tDUK_TVAL_SET_TVAL(tv__dst, tv__src); \\\n\t\tDUK_TVAL_INCREF((thr), tv__src); \\\n\t\tDUK_TVAL_DECREF((thr), &tv__tmp);  /* side effects */ \\\n\t} while (0)\n\n/* Faster alternative: avoid making a temporary copy of tvptr_dst and use\n * fast incref/decref macros.\n */\n#define DUK_TVAL_SET_TVAL_UPDREF_ALT1(thr,tvptr_dst,tvptr_src) do { \\\n\t\tduk_tval *tv__dst, *tv__src; duk_heaphdr *h__obj; \\\n\t\ttv__dst = (tvptr_dst); tv__src = (tvptr_src); \\\n\t\tDUK_TVAL_INCREF_FAST((thr), tv__src); \\\n\t\tif (DUK_TVAL_NEEDS_REFCOUNT_UPDATE(tv__dst)) { \\\n\t\t\th__obj = DUK_TVAL_GET_HEAPHDR(tv__dst); \\\n\t\t\tDUK_ASSERT(h__obj != NULL); \\\n\t\t\tDUK_TVAL_SET_TVAL(tv__dst, tv__src); \\\n\t\t\tDUK_HEAPHDR_DECREF_FAST((thr), h__obj);  /* side effects */ \\\n\t\t} else { \\\n\t\t\tDUK_TVAL_SET_TVAL(tv__dst, tv__src); \\\n\t\t} \\\n\t} while (0)\n\n/* XXX: no optimized variants yet */\n#define DUK_TVAL_SET_UNDEFINED_UPDREF         DUK_TVAL_SET_UNDEFINED_UPDREF_ALT0\n#define DUK_TVAL_SET_UNDEFINED_UPDREF_NORZ    DUK_TVAL_SET_UNDEFINED_UPDREF_NORZ_ALT0\n#define DUK_TVAL_SET_UNUSED_UPDREF            DUK_TVAL_SET_UNUSED_UPDREF_ALT0\n#define DUK_TVAL_SET_NULL_UPDREF              DUK_TVAL_SET_NULL_UPDREF_ALT0\n#define DUK_TVAL_SET_BOOLEAN_UPDREF           DUK_TVAL_SET_BOOLEAN_UPDREF_ALT0\n#define DUK_TVAL_SET_NUMBER_UPDREF            DUK_TVAL_SET_NUMBER_UPDREF_ALT0\n#define DUK_TVAL_SET_NUMBER_CHKFAST_UPDREF    DUK_TVAL_SET_NUMBER_CHKFAST_UPDREF_ALT0\n#define DUK_TVAL_SET_DOUBLE_UPDREF            DUK_TVAL_SET_DOUBLE_UPDREF_ALT0\n#define DUK_TVAL_SET_NAN_UPDREF               DUK_TVAL_SET_NAN_UPDREF_ALT0\n#if defined(DUK_USE_FASTINT)\n#define DUK_TVAL_SET_I48_UPDREF               DUK_TVAL_SET_I48_UPDREF_ALT0\n#define DUK_TVAL_SET_I32_UPDREF               DUK_TVAL_SET_I32_UPDREF_ALT0\n#define DUK_TVAL_SET_U32_UPDREF               DUK_TVAL_SET_U32_UPDREF_ALT0\n#else\n#define DUK_TVAL_SET_I48_UPDREF               DUK_TVAL_SET_DOUBLE_CAST_UPDREF  /* XXX: fast int-to-double */\n#define DUK_TVAL_SET_I32_UPDREF               DUK_TVAL_SET_DOUBLE_CAST_UPDREF\n#define DUK_TVAL_SET_U32_UPDREF               DUK_TVAL_SET_DOUBLE_CAST_UPDREF\n#endif  /* DUK_USE_FASTINT */\n#define DUK_TVAL_SET_FASTINT_UPDREF           DUK_TVAL_SET_I48_UPDREF  /* convenience */\n#define DUK_TVAL_SET_LIGHTFUNC_UPDREF         DUK_TVAL_SET_LIGHTFUNC_UPDREF_ALT0\n#define DUK_TVAL_SET_STRING_UPDREF            DUK_TVAL_SET_STRING_UPDREF_ALT0\n#define DUK_TVAL_SET_OBJECT_UPDREF            DUK_TVAL_SET_OBJECT_UPDREF_ALT0\n#define DUK_TVAL_SET_BUFFER_UPDREF            DUK_TVAL_SET_BUFFER_UPDREF_ALT0\n#define DUK_TVAL_SET_POINTER_UPDREF           DUK_TVAL_SET_POINTER_UPDREF_ALT0\n\n#if defined(DUK_USE_FAST_REFCOUNT_DEFAULT)\n/* Optimized for speed. */\n#define DUK_TVAL_SET_TVAL_UPDREF              DUK_TVAL_SET_TVAL_UPDREF_ALT1\n#define DUK_TVAL_SET_TVAL_UPDREF_FAST         DUK_TVAL_SET_TVAL_UPDREF_ALT1\n#define DUK_TVAL_SET_TVAL_UPDREF_SLOW         DUK_TVAL_SET_TVAL_UPDREF_ALT0\n#else\n/* Optimized for size. */\n#define DUK_TVAL_SET_TVAL_UPDREF              DUK_TVAL_SET_TVAL_UPDREF_ALT0\n#define DUK_TVAL_SET_TVAL_UPDREF_FAST         DUK_TVAL_SET_TVAL_UPDREF_ALT0\n#define DUK_TVAL_SET_TVAL_UPDREF_SLOW         DUK_TVAL_SET_TVAL_UPDREF_ALT0\n#endif\n\n#else  /* DUK_USE_REFERENCE_COUNTING */\n\n#define DUK_TVAL_NEEDS_REFCOUNT_UPDATE(tv)     0\n#define DUK_HEAPHDR_NEEDS_REFCOUNT_UPDATE(h)   0\n\n#define DUK_TVAL_INCREF_FAST(thr,v)            do {} while (0) /* nop */\n#define DUK_TVAL_DECREF_FAST(thr,v)            do {} while (0) /* nop */\n#define DUK_TVAL_DECREF_NORZ_FAST(thr,v)       do {} while (0) /* nop */\n#define DUK_TVAL_INCREF_SLOW(thr,v)            do {} while (0) /* nop */\n#define DUK_TVAL_DECREF_SLOW(thr,v)            do {} while (0) /* nop */\n#define DUK_TVAL_DECREF_NORZ_SLOW(thr,v)       do {} while (0) /* nop */\n#define DUK_TVAL_INCREF(thr,v)                 do {} while (0) /* nop */\n#define DUK_TVAL_DECREF(thr,v)                 do {} while (0) /* nop */\n#define DUK_TVAL_DECREF_NORZ(thr,v)            do {} while (0) /* nop */\n#define DUK_HEAPHDR_INCREF_FAST(thr,h)         do {} while (0) /* nop */\n#define DUK_HEAPHDR_DECREF_FAST(thr,h)         do {} while (0) /* nop */\n#define DUK_HEAPHDR_DECREF_NORZ_FAST(thr,h)    do {} while (0) /* nop */\n#define DUK_HEAPHDR_INCREF_SLOW(thr,h)         do {} while (0) /* nop */\n#define DUK_HEAPHDR_DECREF_SLOW(thr,h)         do {} while (0) /* nop */\n#define DUK_HEAPHDR_DECREF_NORZ_SLOW(thr,h)    do {} while (0) /* nop */\n#define DUK_HEAPHDR_INCREF(thr,h)              do {} while (0) /* nop */\n#define DUK_HEAPHDR_DECREF(thr,h)              do {} while (0) /* nop */\n#define DUK_HEAPHDR_DECREF_NORZ(thr,h)         do {} while (0) /* nop */\n#define DUK_HSTRING_INCREF_FAST(thr,h)         do {} while (0) /* nop */\n#define DUK_HSTRING_DECREF_FAST(thr,h)         do {} while (0) /* nop */\n#define DUK_HSTRING_DECREF_NORZ_FAST(thr,h)    do {} while (0) /* nop */\n#define DUK_HSTRING_INCREF_SLOW(thr,h)         do {} while (0) /* nop */\n#define DUK_HSTRING_DECREF_SLOW(thr,h)         do {} while (0) /* nop */\n#define DUK_HSTRING_DECREF_NORZ_SLOW(thr,h)    do {} while (0) /* nop */\n#define DUK_HSTRING_INCREF(thr,h)              do {} while (0) /* nop */\n#define DUK_HSTRING_DECREF(thr,h)              do {} while (0) /* nop */\n#define DUK_HSTRING_DECREF_NORZ(thr,h)         do {} while (0) /* nop */\n#define DUK_HOBJECT_INCREF_FAST(thr,h)         do {} while (0) /* nop */\n#define DUK_HOBJECT_DECREF_FAST(thr,h)         do {} while (0) /* nop */\n#define DUK_HOBJECT_DECREF_NORZ_FAST(thr,h)    do {} while (0) /* nop */\n#define DUK_HOBJECT_INCREF_SLOW(thr,h)         do {} while (0) /* nop */\n#define DUK_HOBJECT_DECREF_SLOW(thr,h)         do {} while (0) /* nop */\n#define DUK_HOBJECT_DECREF_NORZ_SLOW(thr,h)    do {} while (0) /* nop */\n#define DUK_HOBJECT_INCREF(thr,h)              do {} while (0) /* nop */\n#define DUK_HOBJECT_DECREF(thr,h)              do {} while (0) /* nop */\n#define DUK_HOBJECT_DECREF_NORZ(thr,h)         do {} while (0) /* nop */\n#define DUK_HBUFFER_INCREF_FAST(thr,h)         do {} while (0) /* nop */\n#define DUK_HBUFFER_DECREF_FAST(thr,h)         do {} while (0) /* nop */\n#define DUK_HBUFFER_DECREF_NORZ_FAST(thr,h)    do {} while (0) /* nop */\n#define DUK_HBUFFER_INCREF_SLOW(thr,h)         do {} while (0) /* nop */\n#define DUK_HBUFFER_DECREF_SLOW(thr,h)         do {} while (0) /* nop */\n#define DUK_HBUFFER_DECREF_NORZ_SLOW(thr,h)    do {} while (0) /* nop */\n#define DUK_HBUFFER_INCREF(thr,h)              do {} while (0) /* nop */\n#define DUK_HBUFFER_DECREF(thr,h)              do {} while (0) /* nop */\n#define DUK_HBUFFER_DECREF_NORZ(thr,h)         do {} while (0) /* nop */\n\n#define DUK_HCOMPFUNC_INCREF(thr,h)            do {} while (0) /* nop */\n#define DUK_HCOMPFUNC_DECREF(thr,h)            do {} while (0) /* nop */\n#define DUK_HCOMPFUNC_DECREF_NORZ(thr,h)       do {} while (0) /* nop */\n#define DUK_HNATFUNC_INCREF(thr,h)             do {} while (0) /* nop */\n#define DUK_HNATFUNC_DECREF(thr,h)             do {} while (0) /* nop */\n#define DUK_HNATFUNC_DECREF_NORZ(thr,h)        do {} while (0) /* nop */\n#define DUK_HBUFOBJ_INCREF(thr,h)              do {} while (0) /* nop */\n#define DUK_HBUFOBJ_DECREF(thr,h)              do {} while (0) /* nop */\n#define DUK_HBUFOBJ_DECREF_NORZ(thr,h)         do {} while (0) /* nop */\n#define DUK_HTHREAD_INCREF(thr,h)              do {} while (0) /* nop */\n#define DUK_HTHREAD_DECREF(thr,h)              do {} while (0) /* nop */\n#define DUK_HTHREAD_DECREF_NORZ(thr,h)         do {} while (0) /* nop */\n#define DUK_HOBJECT_INCREF_ALLOWNULL(thr,h)    do {} while (0) /* nop */\n#define DUK_HOBJECT_DECREF_ALLOWNULL(thr,h)    do {} while (0) /* nop */\n#define DUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr,h)  do {} while (0) /* nop */\n#define DUK_HBUFFER_INCREF_ALLOWNULL(thr,h)    do {} while (0) /* nop */\n#define DUK_HBUFFER_DECREF_ALLOWNULL(thr,h)    do {} while (0) /* nop */\n#define DUK_HBUFFER_DECREF_NORZ_ALLOWNULL(thr,h)  do {} while (0) /* nop */\n\n#define DUK_REFZERO_CHECK_FAST(thr)            do {} while (0) /* nop */\n#define DUK_REFZERO_CHECK_SLOW(thr)            do {} while (0) /* nop */\n\n#define DUK_TVAL_SET_UNDEFINED_UPDREF_ALT0(thr,tvptr_dst) do { \\\n\t\tduk_tval *tv__dst; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_UNDEFINED(tv__dst); \\\n\t\tDUK_UNREF((thr)); \\\n\t} while (0)\n\n#define DUK_TVAL_SET_UNUSED_UPDREF_ALT0(thr,tvptr_dst) do { \\\n\t\tduk_tval *tv__dst; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_UNUSED(tv__dst); \\\n\t\tDUK_UNREF((thr)); \\\n\t} while (0)\n\n#define DUK_TVAL_SET_NULL_UPDREF_ALT0(thr,tvptr_dst) do { \\\n\t\tduk_tval *tv__dst; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_NULL(tv__dst); \\\n\t\tDUK_UNREF((thr)); \\\n\t} while (0)\n\n#define DUK_TVAL_SET_BOOLEAN_UPDREF_ALT0(thr,tvptr_dst,newval) do { \\\n\t\tduk_tval *tv__dst; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_BOOLEAN(tv__dst, (newval)); \\\n\t\tDUK_UNREF((thr)); \\\n\t} while (0)\n\n#define DUK_TVAL_SET_NUMBER_UPDREF_ALT0(thr,tvptr_dst,newval) do { \\\n\t\tduk_tval *tv__dst; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_NUMBER(tv__dst, (newval)); \\\n\t\tDUK_UNREF((thr)); \\\n\t} while (0)\n#define DUK_TVAL_SET_NUMBER_CHKFAST_UPDREF_ALT0(thr,tvptr_dst,newval) do { \\\n\t\tduk_tval *tv__dst; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_NUMBER_CHKFAST_FAST(tv__dst, (newval)); \\\n\t\tDUK_UNREF((thr)); \\\n\t} while (0)\n#define DUK_TVAL_SET_DOUBLE_UPDREF_ALT0(thr,tvptr_dst,newval) do { \\\n\t\tduk_tval *tv__dst; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_DOUBLE(tv__dst, (newval)); \\\n\t\tDUK_UNREF((thr)); \\\n\t} while (0)\n#define DUK_TVAL_SET_NAN_UPDREF_ALT0(thr,tvptr_dst) do { \\\n\t\tduk_tval *tv__dst; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_NAN(tv__dst); \\\n\t\tDUK_UNREF((thr)); \\\n\t} while (0)\n#if defined(DUK_USE_FASTINT)\n#define DUK_TVAL_SET_I48_UPDREF_ALT0(thr,tvptr_dst,newval) do { \\\n\t\tduk_tval *tv__dst; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_I48(tv__dst, (newval)); \\\n\t\tDUK_UNREF((thr)); \\\n\t} while (0)\n#define DUK_TVAL_SET_I32_UPDREF_ALT0(thr,tvptr_dst,newval) do { \\\n\t\tduk_tval *tv__dst; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_I32(tv__dst, (newval)); \\\n\t\tDUK_UNREF((thr)); \\\n\t} while (0)\n#define DUK_TVAL_SET_U32_UPDREF_ALT0(thr,tvptr_dst,newval) do { \\\n\t\tduk_tval *tv__dst; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_U32(tv__dst, (newval)); \\\n\t\tDUK_UNREF((thr)); \\\n\t} while (0)\n#else\n#define DUK_TVAL_SET_DOUBLE_CAST_UPDREF(thr,tvptr_dst,newval) \\\n\tDUK_TVAL_SET_DOUBLE_UPDREF((thr), (tvptr_dst), (duk_double_t) (newval))\n#endif  /* DUK_USE_FASTINT */\n\n#define DUK_TVAL_SET_LIGHTFUNC_UPDREF_ALT0(thr,tvptr_dst,lf_v,lf_fp,lf_flags) do { \\\n\t\tduk_tval *tv__dst; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_LIGHTFUNC(tv__dst, (lf_v), (lf_fp), (lf_flags)); \\\n\t\tDUK_UNREF((thr)); \\\n\t} while (0)\n\n#define DUK_TVAL_SET_STRING_UPDREF_ALT0(thr,tvptr_dst,newval) do { \\\n\t\tduk_tval *tv__dst; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_STRING(tv__dst, (newval)); \\\n\t\tDUK_UNREF((thr)); \\\n\t} while (0)\n\n#define DUK_TVAL_SET_OBJECT_UPDREF_ALT0(thr,tvptr_dst,newval) do { \\\n\t\tduk_tval *tv__dst; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_OBJECT(tv__dst, (newval)); \\\n\t\tDUK_UNREF((thr)); \\\n\t} while (0)\n\n#define DUK_TVAL_SET_BUFFER_UPDREF_ALT0(thr,tvptr_dst,newval) do { \\\n\t\tduk_tval *tv__dst; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_BUFFER(tv__dst, (newval)); \\\n\t\tDUK_UNREF((thr)); \\\n\t} while (0)\n\n#define DUK_TVAL_SET_POINTER_UPDREF_ALT0(thr,tvptr_dst,newval) do { \\\n\t\tduk_tval *tv__dst; tv__dst = (tvptr_dst); \\\n\t\tDUK_TVAL_SET_POINTER(tv__dst, (newval)); \\\n\t\tDUK_UNREF((thr)); \\\n\t} while (0)\n\n#define DUK_TVAL_SET_TVAL_UPDREF_ALT0(thr,tvptr_dst,tvptr_src) do { \\\n\t\tduk_tval *tv__dst, *tv__src; \\\n\t\ttv__dst = (tvptr_dst); tv__src = (tvptr_src); \\\n\t\tDUK_TVAL_SET_TVAL(tv__dst, tv__src); \\\n\t\tDUK_UNREF((thr)); \\\n\t} while (0)\n\n#define DUK_TVAL_SET_UNDEFINED_UPDREF         DUK_TVAL_SET_UNDEFINED_UPDREF_ALT0\n#define DUK_TVAL_SET_UNDEFINED_UPDREF_NORZ    DUK_TVAL_SET_UNDEFINED_UPDREF_ALT0\n#define DUK_TVAL_SET_UNUSED_UPDREF            DUK_TVAL_SET_UNUSED_UPDREF_ALT0\n#define DUK_TVAL_SET_NULL_UPDREF              DUK_TVAL_SET_NULL_UPDREF_ALT0\n#define DUK_TVAL_SET_BOOLEAN_UPDREF           DUK_TVAL_SET_BOOLEAN_UPDREF_ALT0\n#define DUK_TVAL_SET_NUMBER_UPDREF            DUK_TVAL_SET_NUMBER_UPDREF_ALT0\n#define DUK_TVAL_SET_NUMBER_CHKFAST_UPDREF    DUK_TVAL_SET_NUMBER_CHKFAST_UPDREF_ALT0\n#define DUK_TVAL_SET_DOUBLE_UPDREF            DUK_TVAL_SET_DOUBLE_UPDREF_ALT0\n#define DUK_TVAL_SET_NAN_UPDREF               DUK_TVAL_SET_NAN_UPDREF_ALT0\n#if defined(DUK_USE_FASTINT)\n#define DUK_TVAL_SET_I48_UPDREF               DUK_TVAL_SET_I48_UPDREF_ALT0\n#define DUK_TVAL_SET_I32_UPDREF               DUK_TVAL_SET_I32_UPDREF_ALT0\n#define DUK_TVAL_SET_U32_UPDREF               DUK_TVAL_SET_U32_UPDREF_ALT0\n#else\n#define DUK_TVAL_SET_I48_UPDREF               DUK_TVAL_SET_DOUBLE_CAST_UPDREF  /* XXX: fast-int-to-double */\n#define DUK_TVAL_SET_I32_UPDREF               DUK_TVAL_SET_DOUBLE_CAST_UPDREF\n#define DUK_TVAL_SET_U32_UPDREF               DUK_TVAL_SET_DOUBLE_CAST_UPDREF\n#endif  /* DUK_USE_FASTINT */\n#define DUK_TVAL_SET_FASTINT_UPDREF           DUK_TVAL_SET_I48_UPDREF  /* convenience */\n#define DUK_TVAL_SET_LIGHTFUNC_UPDREF         DUK_TVAL_SET_LIGHTFUNC_UPDREF_ALT0\n#define DUK_TVAL_SET_STRING_UPDREF            DUK_TVAL_SET_STRING_UPDREF_ALT0\n#define DUK_TVAL_SET_OBJECT_UPDREF            DUK_TVAL_SET_OBJECT_UPDREF_ALT0\n#define DUK_TVAL_SET_BUFFER_UPDREF            DUK_TVAL_SET_BUFFER_UPDREF_ALT0\n#define DUK_TVAL_SET_POINTER_UPDREF           DUK_TVAL_SET_POINTER_UPDREF_ALT0\n\n#define DUK_TVAL_SET_TVAL_UPDREF              DUK_TVAL_SET_TVAL_UPDREF_ALT0\n#define DUK_TVAL_SET_TVAL_UPDREF_FAST         DUK_TVAL_SET_TVAL_UPDREF_ALT0\n#define DUK_TVAL_SET_TVAL_UPDREF_SLOW         DUK_TVAL_SET_TVAL_UPDREF_ALT0\n\n#endif  /* DUK_USE_REFERENCE_COUNTING */\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n#if defined(DUK_USE_FINALIZER_SUPPORT)\nDUK_INTERNAL_DECL void duk_refzero_check_slow(duk_hthread *thr);\nDUK_INTERNAL_DECL void duk_refzero_check_fast(duk_hthread *thr);\n#endif\nDUK_INTERNAL_DECL void duk_heaphdr_refcount_finalize_norz(duk_heap *heap, duk_heaphdr *hdr);\nDUK_INTERNAL_DECL void duk_hobject_refcount_finalize_norz(duk_heap *heap, duk_hobject *h);\n#if 0  /* Not needed: fast path handles inline; slow path uses duk_heaphdr_decref() which is needed anyway. */\nDUK_INTERNAL_DECL void duk_hstring_decref(duk_hthread *thr, duk_hstring *h);\nDUK_INTERNAL_DECL void duk_hstring_decref_norz(duk_hthread *thr, duk_hstring *h);\nDUK_INTERNAL_DECL void duk_hbuffer_decref(duk_hthread *thr, duk_hbuffer *h);\nDUK_INTERNAL_DECL void duk_hbuffer_decref_norz(duk_hthread *thr, duk_hbuffer *h);\nDUK_INTERNAL_DECL void duk_hobject_decref(duk_hthread *thr, duk_hobject *h);\nDUK_INTERNAL_DECL void duk_hobject_decref_norz(duk_hthread *thr, duk_hobject *h);\n#endif\nDUK_INTERNAL_DECL void duk_heaphdr_refzero(duk_hthread *thr, duk_heaphdr *h);\nDUK_INTERNAL_DECL void duk_heaphdr_refzero_norz(duk_hthread *thr, duk_heaphdr *h);\n#if defined(DUK_USE_FAST_REFCOUNT_DEFAULT)\nDUK_INTERNAL_DECL void duk_hstring_refzero(duk_hthread *thr, duk_hstring *h);  /* no 'norz' variant */\nDUK_INTERNAL_DECL void duk_hbuffer_refzero(duk_hthread *thr, duk_hbuffer *h);  /* no 'norz' variant */\nDUK_INTERNAL_DECL void duk_hobject_refzero(duk_hthread *thr, duk_hobject *h);\nDUK_INTERNAL_DECL void duk_hobject_refzero_norz(duk_hthread *thr, duk_hobject *h);\n#else\nDUK_INTERNAL_DECL void duk_tval_incref(duk_tval *tv);\nDUK_INTERNAL_DECL void duk_tval_decref(duk_hthread *thr, duk_tval *tv);\nDUK_INTERNAL_DECL void duk_tval_decref_norz(duk_hthread *thr, duk_tval *tv);\nDUK_INTERNAL_DECL void duk_heaphdr_incref(duk_heaphdr *h);\nDUK_INTERNAL_DECL void duk_heaphdr_decref(duk_hthread *thr, duk_heaphdr *h);\nDUK_INTERNAL_DECL void duk_heaphdr_decref_norz(duk_hthread *thr, duk_heaphdr *h);\n#endif\n#else  /* DUK_USE_REFERENCE_COUNTING */\n/* no refcounting */\n#endif  /* DUK_USE_REFERENCE_COUNTING */\n\n#endif  /* DUK_REFCOUNT_H_INCLUDED */\n/* #include duk_api_internal.h */\n/*\n *  Internal API calls which have (stack and other) semantics similar\n *  to the public API.\n */\n\n#if !defined(DUK_API_INTERNAL_H_INCLUDED)\n#define DUK_API_INTERNAL_H_INCLUDED\n\n/* duk_push_sprintf constants */\n#define DUK_PUSH_SPRINTF_INITIAL_SIZE  256L\n#define DUK_PUSH_SPRINTF_SANITY_LIMIT  (1L * 1024L * 1024L * 1024L)\n\n/* Flag ORed to err_code to indicate __FILE__ / __LINE__ is not\n * blamed as source of error for error fileName / lineNumber.\n */\n#define DUK_ERRCODE_FLAG_NOBLAME_FILELINE  (1L << 24)\n\n/* Valstack resize flags */\n#define DUK_VSRESIZE_FLAG_SHRINK           (1 << 0)\n#define DUK_VSRESIZE_FLAG_COMPACT          (1 << 1)\n#define DUK_VSRESIZE_FLAG_THROW            (1 << 2)\n\n/* Current convention is to use duk_size_t for value stack sizes and global indices,\n * and duk_idx_t for local frame indices.\n */\nDUK_INTERNAL_DECL\nduk_bool_t duk_valstack_resize_raw(duk_context *ctx,\n                                   duk_size_t min_new_size,\n                                   duk_small_uint_t flags);\n\nDUK_INTERNAL_DECL void duk_dup_0(duk_context *ctx);\nDUK_INTERNAL_DECL void duk_dup_1(duk_context *ctx);\nDUK_INTERNAL_DECL void duk_dup_2(duk_context *ctx);\n/* duk_dup_m1() would be same as duk_dup_top() */\nDUK_INTERNAL_DECL void duk_dup_m2(duk_context *ctx);\nDUK_INTERNAL_DECL void duk_dup_m3(duk_context *ctx);\nDUK_INTERNAL_DECL void duk_dup_m4(duk_context *ctx);\n\nDUK_INTERNAL_DECL void duk_remove_m2(duk_context *ctx);\n\nDUK_INTERNAL_DECL duk_int_t duk_get_type_tval(duk_tval *tv);\nDUK_INTERNAL_DECL duk_uint_t duk_get_type_mask_tval(duk_tval *tv);\n\n#if defined(DUK_USE_VERBOSE_ERRORS) && defined(DUK_USE_PARANOID_ERRORS)\nDUK_INTERNAL_DECL const char *duk_get_type_name(duk_context *ctx, duk_idx_t idx);\n#endif\nDUK_INTERNAL_DECL duk_small_uint_t duk_get_class_number(duk_context *ctx, duk_idx_t idx);\n\nDUK_INTERNAL_DECL duk_tval *duk_get_tval(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL duk_tval *duk_get_tval_or_unused(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL duk_tval *duk_require_tval(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL void duk_push_tval(duk_context *ctx, duk_tval *tv);\n\n/* Push the current 'this' binding; throw TypeError if binding is not object\n * coercible (CheckObjectCoercible).\n */\nDUK_INTERNAL_DECL void duk_push_this_check_object_coercible(duk_context *ctx);\n\n/* duk_push_this() + CheckObjectCoercible() + duk_to_object() */\nDUK_INTERNAL_DECL duk_hobject *duk_push_this_coercible_to_object(duk_context *ctx);\n\n/* duk_push_this() + CheckObjectCoercible() + duk_to_string() */\nDUK_INTERNAL_DECL duk_hstring *duk_push_this_coercible_to_string(duk_context *ctx);\n\nDUK_INTERNAL_DECL duk_hstring *duk_push_uint_to_hstring(duk_context *ctx, duk_uint_t i);\n\n/* Get a borrowed duk_tval pointer to the current 'this' binding.  Caller must\n * make sure there's an active callstack entry.  Note that the returned pointer\n * is unstable with regards to side effects.\n */\nDUK_INTERNAL_DECL duk_tval *duk_get_borrowed_this_tval(duk_context *ctx);\n\n/* XXX: add fastint support? */\n#define duk_push_u64(ctx,val) \\\n\tduk_push_number((ctx), (duk_double_t) (val))\n#define duk_push_i64(ctx,val) \\\n\tduk_push_number((ctx), (duk_double_t) (val))\n\n/* duk_push_(u)int() is guaranteed to support at least (un)signed 32-bit range */\n#define duk_push_u32(ctx,val) \\\n\tduk_push_uint((ctx), (duk_uint_t) (val))\n#define duk_push_i32(ctx,val) \\\n\tduk_push_int((ctx), (duk_int_t) (val))\n\n/* sometimes stack and array indices need to go on the stack */\n#define duk_push_idx(ctx,val) \\\n\tduk_push_int((ctx), (duk_int_t) (val))\n#define duk_push_uarridx(ctx,val) \\\n\tduk_push_uint((ctx), (duk_uint_t) (val))\n#define duk_push_size_t(ctx,val) \\\n\tduk_push_uint((ctx), (duk_uint_t) (val))  /* XXX: assumed to fit for now */\n\nDUK_INTERNAL_DECL duk_bool_t duk_is_string_notsymbol(duk_context *ctx, duk_idx_t idx);\n\nDUK_INTERNAL_DECL duk_hstring *duk_get_hstring(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL duk_hstring *duk_get_hstring_notsymbol(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL const char *duk_get_string_notsymbol(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL duk_hobject *duk_get_hobject(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL duk_hbuffer *duk_get_hbuffer(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL duk_hthread *duk_get_hthread(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL duk_hcompfunc *duk_get_hcompfunc(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL duk_hnatfunc *duk_get_hnatfunc(duk_context *ctx, duk_idx_t idx);\n\nDUK_INTERNAL_DECL void *duk_get_buffer_data_raw(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size, void *def_ptr, duk_size_t def_len, duk_bool_t throw_flag, duk_bool_t *out_isbuffer);\n\nDUK_INTERNAL_DECL duk_hobject *duk_get_hobject_with_class(duk_context *ctx, duk_idx_t idx, duk_small_uint_t classnum);\n\nDUK_INTERNAL_DECL duk_hobject *duk_get_hobject_promote_mask(duk_context *ctx, duk_idx_t idx, duk_uint_t type_mask);\nDUK_INTERNAL_DECL duk_hobject *duk_require_hobject_promote_mask(duk_context *ctx, duk_idx_t idx, duk_uint_t type_mask);\nDUK_INTERNAL_DECL duk_hobject *duk_require_hobject_accept_mask(duk_context *ctx, duk_idx_t idx, duk_uint_t type_mask);\n#define duk_require_hobject_promote_lfunc(ctx,idx) \\\n\tduk_require_hobject_promote_mask((ctx), (idx), DUK_TYPE_MASK_LIGHTFUNC)\n#define duk_get_hobject_promote_lfunc(ctx,idx) \\\n\tduk_get_hobject_promote_mask((ctx), (idx), DUK_TYPE_MASK_LIGHTFUNC)\n\n#if 0  /*unused*/\nDUK_INTERNAL_DECL void *duk_get_voidptr(duk_context *ctx, duk_idx_t idx);\n#endif\n\nDUK_INTERNAL_DECL duk_hstring *duk_known_hstring(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL duk_hobject *duk_known_hobject(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL duk_hbuffer *duk_known_hbuffer(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL duk_hcompfunc *duk_known_hcompfunc(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL duk_hnatfunc *duk_known_hnatfunc(duk_context *ctx, duk_idx_t idx);\n\nDUK_INTERNAL_DECL duk_double_t duk_to_number_tval(duk_context *ctx, duk_tval *tv);\n\nDUK_INTERNAL_DECL duk_hstring *duk_to_hstring(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL duk_hstring *duk_to_hstring_m1(duk_context *ctx);\nDUK_INTERNAL_DECL duk_hstring *duk_to_hstring_acceptsymbol(duk_context *ctx, duk_idx_t idx);\n\nDUK_INTERNAL_DECL duk_hobject *duk_to_hobject(duk_context *ctx, duk_idx_t idx);\n\nDUK_INTERNAL_DECL duk_double_t duk_to_number_m1(duk_context *ctx);\nDUK_INTERNAL_DECL duk_double_t duk_to_number_m2(duk_context *ctx);\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT)  /* only needed by debugger for now */\nDUK_INTERNAL_DECL duk_hstring *duk_safe_to_hstring(duk_context *ctx, duk_idx_t idx);\n#endif\nDUK_INTERNAL_DECL void duk_push_class_string_tval(duk_context *ctx, duk_tval *tv);\n\nDUK_INTERNAL_DECL duk_int_t duk_to_int_clamped_raw(duk_context *ctx, duk_idx_t idx, duk_int_t minval, duk_int_t maxval, duk_bool_t *out_clamped);  /* out_clamped=NULL, RangeError if outside range */\nDUK_INTERNAL_DECL duk_int_t duk_to_int_clamped(duk_context *ctx, duk_idx_t idx, duk_int_t minval, duk_int_t maxval);\nDUK_INTERNAL_DECL duk_int_t duk_to_int_check_range(duk_context *ctx, duk_idx_t idx, duk_int_t minval, duk_int_t maxval);\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL_DECL duk_uint8_t duk_to_uint8clamped(duk_context *ctx, duk_idx_t idx);\n#endif\nDUK_INTERNAL_DECL duk_hstring *duk_to_property_key_hstring(duk_context *ctx, duk_idx_t idx);\n\nDUK_INTERNAL_DECL duk_hstring *duk_require_hstring(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL duk_hstring *duk_require_hstring_notsymbol(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL const char *duk_require_lstring_notsymbol(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len);\nDUK_INTERNAL_DECL const char *duk_require_string_notsymbol(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL duk_hobject *duk_require_hobject(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL duk_hbuffer *duk_require_hbuffer(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL duk_hthread *duk_require_hthread(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL duk_hcompfunc *duk_require_hcompfunc(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL duk_hnatfunc *duk_require_hnatfunc(duk_context *ctx, duk_idx_t idx);\n\nDUK_INTERNAL_DECL duk_hobject *duk_require_hobject_with_class(duk_context *ctx, duk_idx_t idx, duk_small_uint_t classnum);\n\nDUK_INTERNAL_DECL void duk_push_hstring(duk_context *ctx, duk_hstring *h);\nDUK_INTERNAL_DECL void duk_push_hstring_stridx(duk_context *ctx, duk_small_uint_t stridx);\nDUK_INTERNAL_DECL void duk_push_hstring_empty(duk_context *ctx);\nDUK_INTERNAL_DECL void duk_push_hobject(duk_context *ctx, duk_hobject *h);\nDUK_INTERNAL_DECL void duk_push_hbuffer(duk_context *ctx, duk_hbuffer *h);\n#define duk_push_hthread(ctx,h) \\\n\tduk_push_hobject((ctx), (duk_hobject *) (h))\n#define duk_push_hnatfunc(ctx,h) \\\n\tduk_push_hobject((ctx), (duk_hobject *) (h))\nDUK_INTERNAL_DECL void duk_push_hobject_bidx(duk_context *ctx, duk_small_int_t builtin_idx);\nDUK_INTERNAL_DECL duk_hobject *duk_push_object_helper(duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_small_int_t prototype_bidx);\nDUK_INTERNAL_DECL duk_hobject *duk_push_object_helper_proto(duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_hobject *proto);\nDUK_INTERNAL_DECL duk_hcompfunc *duk_push_hcompfunc(duk_context *ctx);\nDUK_INTERNAL_DECL void duk_push_c_function_noexotic(duk_context *ctx, duk_c_function func, duk_int_t nargs);\nDUK_INTERNAL_DECL void duk_push_c_function_noconstruct_noexotic(duk_context *ctx, duk_c_function func, duk_int_t nargs);\n\n/* XXX: duk_push_harray() and duk_push_hcompfunc() are inconsistent with\n * duk_push_hobject() etc which don't create a new value.\n */\nDUK_INTERNAL_DECL duk_harray *duk_push_harray(duk_context *ctx);\nDUK_INTERNAL_DECL duk_harray *duk_push_harray_with_size(duk_context *ctx, duk_uint32_t size);\n\nDUK_INTERNAL_DECL void duk_push_string_funcptr(duk_context *ctx, duk_uint8_t *ptr, duk_size_t sz);\nDUK_INTERNAL_DECL void duk_push_lightfunc_name_raw(duk_context *ctx, duk_c_function func, duk_small_uint_t lf_flags);\nDUK_INTERNAL_DECL void duk_push_lightfunc_name(duk_context *ctx, duk_tval *tv);\nDUK_INTERNAL_DECL void duk_push_lightfunc_tostring(duk_context *ctx, duk_tval *tv);\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL_DECL duk_hbufobj *duk_push_bufobj_raw(duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_small_int_t prototype_bidx);\n#endif\n\nDUK_INTERNAL_DECL void *duk_push_fixed_buffer_nozero(duk_context *ctx, duk_size_t len);\nDUK_INTERNAL_DECL void *duk_push_fixed_buffer_zero(duk_context *ctx, duk_size_t len);\n\nDUK_INTERNAL_DECL const char *duk_push_string_readable(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL const char *duk_push_string_tval_readable(duk_context *ctx, duk_tval *tv);\nDUK_INTERNAL_DECL const char *duk_push_string_tval_readable_error(duk_context *ctx, duk_tval *tv);\n\n/* The duk_xxx_prop_stridx_short() variants expect their arguments to be short\n * enough to be packed into a single 32-bit integer argument.  Argument limits\n * vary per call; typically 16 bits are assigned to the signed value stack index\n * and the stridx.  In practice these work well for footprint with constant\n * arguments and such call sites are also easiest to verify to be correct.\n */\n\nDUK_INTERNAL_DECL duk_bool_t duk_get_prop_stridx(duk_context *ctx, duk_idx_t obj_idx, duk_small_uint_t stridx);     /* [] -> [val] */\nDUK_INTERNAL_DECL duk_bool_t duk_get_prop_stridx_short_raw(duk_context *ctx, duk_uint_t packed_args);\n#define duk_get_prop_stridx_short(ctx,obj_idx,stridx) \\\n\t(DUK_ASSERT_EXPR((duk_int_t) (obj_idx) >= -0x8000L && (duk_int_t) (obj_idx) <= 0x7fffL), \\\n\t DUK_ASSERT_EXPR((duk_int_t) (stridx) >= 0 && (duk_int_t) (stridx) <= 0xffffL), \\\n\t duk_get_prop_stridx_short_raw((ctx), (((duk_uint_t) (obj_idx)) << 16) + ((duk_uint_t) (stridx))))\nDUK_INTERNAL_DECL duk_bool_t duk_get_prop_stridx_boolean(duk_context *ctx, duk_idx_t obj_idx, duk_small_uint_t stridx, duk_bool_t *out_has_prop);  /* [] -> [] */\n\nDUK_INTERNAL_DECL duk_bool_t duk_put_prop_stridx(duk_context *ctx, duk_idx_t obj_idx, duk_small_uint_t stridx);     /* [val] -> [] */\nDUK_INTERNAL_DECL duk_bool_t duk_put_prop_stridx_short_raw(duk_context *ctx, duk_uint_t packed_args);\n#define duk_put_prop_stridx_short(ctx,obj_idx,stridx) \\\n\t(DUK_ASSERT_EXPR((duk_int_t) (obj_idx) >= -0x8000L && (duk_int_t) (obj_idx) <= 0x7fffL), \\\n\t DUK_ASSERT_EXPR((duk_int_t) (stridx) >= 0 && (duk_int_t) (stridx) <= 0xffffL), \\\n\t duk_put_prop_stridx_short_raw((ctx), (((duk_uint_t) (obj_idx)) << 16) + ((duk_uint_t) (stridx))))\n\nDUK_INTERNAL_DECL duk_bool_t duk_del_prop_stridx(duk_context *ctx, duk_idx_t obj_idx, duk_small_uint_t stridx);     /* [] -> [] */\n#if 0  /* Too few call sites to be useful. */\nDUK_INTERNAL_DECL duk_bool_t duk_del_prop_stridx_short_raw(duk_context *ctx, duk_uint_t packed_args);\n#define duk_del_prop_stridx_short(ctx,obj_idx,stridx) \\\n\t(DUK_ASSERT_EXPR((obj_idx) >= -0x8000L && (obj_idx) <= 0x7fffL), \\\n\t DUK_ASSERT_EXPR((stridx) >= 0 && (stridx) <= 0xffffL), \\\n\t duk_del_prop_stridx_short_raw((ctx), (((duk_uint_t) (obj_idx)) << 16) + ((duk_uint_t) (stridx))))\n#endif\n#define duk_del_prop_stridx_short(ctx,obj_idx,stridx) \\\n\tduk_del_prop_stridx((ctx), (obj_idx), (stridx))\n\nDUK_INTERNAL_DECL duk_bool_t duk_has_prop_stridx(duk_context *ctx, duk_idx_t obj_idx, duk_small_uint_t stridx);     /* [] -> [] */\n#if 0  /* Too few call sites to be useful. */\nDUK_INTERNAL_DECL duk_bool_t duk_has_prop_stridx_short_raw(duk_context *ctx, duk_uint_t packed_args);\n#define duk_has_prop_stridx_short(ctx,obj_idx,stridx) \\\n\t(DUK_ASSERT_EXPR((obj_idx) >= -0x8000L && (obj_idx) <= 0x7fffL), \\\n\t DUK_ASSERT_EXPR((stridx) >= 0 && (stridx) <= 0xffffL), \\\n\t duk_has_prop_stridx_short_raw((ctx), (((duk_uint_t) (obj_idx)) << 16) + ((duk_uint_t) (stridx))))\n#endif\n#define duk_has_prop_stridx_short(ctx,obj_idx,stridx) \\\n\tduk_has_prop_stridx((ctx), (obj_idx), (stridx))\n\nDUK_INTERNAL_DECL void duk_xdef_prop(duk_context *ctx, duk_idx_t obj_idx, duk_small_uint_t desc_flags);  /* [key val] -> [] */\n\nDUK_INTERNAL_DECL void duk_xdef_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx, duk_small_uint_t desc_flags);  /* [val] -> [] */\n\n/* XXX: Because stridx and desc_flags have a limited range, this call could\n * always pack stridx and desc_flags into a single argument.\n */\nDUK_INTERNAL_DECL void duk_xdef_prop_stridx(duk_context *ctx, duk_idx_t obj_idx, duk_small_uint_t stridx, duk_small_uint_t desc_flags);  /* [val] -> [] */\nDUK_INTERNAL_DECL void duk_xdef_prop_stridx_short_raw(duk_context *ctx, duk_uint_t packed_args);\n#define duk_xdef_prop_stridx_short(ctx,obj_idx,stridx,desc_flags) \\\n\t(DUK_ASSERT_EXPR((duk_int_t) (obj_idx) >= -0x80L && (duk_int_t) (obj_idx) <= 0x7fL), \\\n\t DUK_ASSERT_EXPR((duk_int_t) (stridx) >= 0 && (duk_int_t) (stridx) <= 0xffffL), \\\n\t DUK_ASSERT_EXPR((duk_int_t) (desc_flags) >= 0 && (duk_int_t) (desc_flags) <= 0xffL), \\\n\t duk_xdef_prop_stridx_short_raw((ctx), (((duk_uint_t) (obj_idx)) << 24) + (((duk_uint_t) (stridx)) << 8) + (duk_uint_t) (desc_flags)))\n\n#define duk_xdef_prop_wec(ctx,obj_idx) \\\n\tduk_xdef_prop((ctx), (obj_idx), DUK_PROPDESC_FLAGS_WEC)\n#define duk_xdef_prop_index_wec(ctx,obj_idx,arr_idx) \\\n\tduk_xdef_prop_index((ctx), (obj_idx), (arr_idx), DUK_PROPDESC_FLAGS_WEC)\n#define duk_xdef_prop_stridx_wec(ctx,obj_idx,stridx) \\\n\tduk_xdef_prop_stridx((ctx), (obj_idx), (stridx), DUK_PROPDESC_FLAGS_WEC)\n#define duk_xdef_prop_stridx_short_wec(ctx,obj_idx,stridx) \\\n\tduk_xdef_prop_stridx_short((ctx), (obj_idx), (stridx), DUK_PROPDESC_FLAGS_WEC)\n\nDUK_INTERNAL_DECL void duk_xdef_prop_stridx_builtin(duk_context *ctx, duk_idx_t obj_idx, duk_small_uint_t stridx, duk_small_int_t builtin_idx, duk_small_uint_t desc_flags);  /* [] -> [] */\n\nDUK_INTERNAL_DECL void duk_xdef_prop_stridx_thrower(duk_context *ctx, duk_idx_t obj_idx, duk_small_uint_t stridx);  /* [] -> [] */\n\nDUK_INTERNAL_DECL void duk_pack(duk_context *ctx, duk_idx_t count);\n#if 0\nDUK_INTERNAL_DECL void duk_unpack(duk_context *ctx);\n#endif\n\nDUK_INTERNAL_DECL void duk_require_constructor_call(duk_context *ctx);\nDUK_INTERNAL_DECL void duk_require_constructable(duk_context *ctx, duk_idx_t idx);\nDUK_INTERNAL_DECL void duk_push_symbol_descriptive_string(duk_context *ctx, duk_hstring *h);\n\nDUK_INTERNAL_DECL void duk_resolve_nonbound_function(duk_context *ctx);\n\nDUK_INTERNAL_DECL duk_idx_t duk_get_top_require_min(duk_context *ctx, duk_idx_t min_top);\nDUK_INTERNAL_DECL duk_idx_t duk_get_top_index_unsafe(duk_context *ctx);\nDUK_INTERNAL_DECL void duk_pop_n_unsafe(duk_context *ctx, duk_idx_t count);\nDUK_INTERNAL_DECL void duk_pop_n_nodecref_unsafe(duk_context *ctx, duk_idx_t count);\nDUK_INTERNAL_DECL void duk_pop_unsafe(duk_context *ctx);\n\nDUK_INTERNAL_DECL void duk_compact_m1(duk_context *ctx);\n\n/* Raw internal valstack access macros: access is unsafe so call site\n * must have a guarantee that the index is valid.  When that is the case,\n * using these macro results in faster and smaller code than duk_get_tval().\n * Both 'ctx' and 'idx' are evaluted multiple times, but only for asserts.\n */\n#define DUK_ASSERT_VALID_NEGIDX(ctx,idx) \\\n\t(DUK_ASSERT_EXPR((duk_int_t) (idx) < 0), DUK_ASSERT_EXPR(duk_is_valid_index((ctx), (idx))))\n#define DUK_ASSERT_VALID_POSIDX(ctx,idx) \\\n\t(DUK_ASSERT_EXPR((duk_int_t) (idx) >= 0), DUK_ASSERT_EXPR(duk_is_valid_index((ctx), (idx))))\n#define DUK_GET_TVAL_NEGIDX(ctx,idx) \\\n\t(DUK_ASSERT_VALID_NEGIDX((ctx),(idx)), ((duk_hthread *) (ctx))->valstack_top + (idx))\n#define DUK_GET_TVAL_POSIDX(ctx,idx) \\\n\t(DUK_ASSERT_VALID_POSIDX((ctx),(idx)), ((duk_hthread *) (ctx))->valstack_bottom + (idx))\n#define DUK_GET_HOBJECT_NEGIDX(ctx,idx) \\\n\t(DUK_ASSERT_VALID_NEGIDX((ctx),(idx)), DUK_TVAL_GET_OBJECT(((duk_hthread *) (ctx))->valstack_top + (idx)))\n#define DUK_GET_HOBJECT_POSIDX(ctx,idx) \\\n\t(DUK_ASSERT_VALID_POSIDX((ctx),(idx)), DUK_TVAL_GET_OBJECT(((duk_hthread *) (ctx))->valstack_bottom + (idx)))\n\n#define DUK_GET_THIS_TVAL_PTR(thr) \\\n\t(DUK_ASSERT_EXPR((thr)->valstack_bottom > (thr)->valstack), \\\n\t (thr)->valstack_bottom - 1)\n\n#endif  /* DUK_API_INTERNAL_H_INCLUDED */\n/* #include duk_hstring.h */\n/*\n *  Heap string representation.\n *\n *  Strings are byte sequences ordinarily stored in extended UTF-8 format,\n *  allowing values larger than the official UTF-8 range (used internally)\n *  and also allowing UTF-8 encoding of surrogate pairs (CESU-8 format).\n *  Strings may also be invalid UTF-8 altogether which is the case e.g. with\n *  strings used as internal property names and raw buffers converted to\n *  strings.  In such cases the 'clen' field contains an inaccurate value.\n *\n *  Ecmascript requires support for 32-bit long strings.  However, since each\n *  16-bit codepoint can take 3 bytes in CESU-8, this representation can only\n *  support about 1.4G codepoint long strings in extreme cases.  This is not\n *  really a practical issue.\n */\n\n#if !defined(DUK_HSTRING_H_INCLUDED)\n#define DUK_HSTRING_H_INCLUDED\n\n/* Impose a maximum string length for now.  Restricted artificially to\n * ensure adding a heap header length won't overflow size_t.  The limit\n * should be synchronized with DUK_HBUFFER_MAX_BYTELEN.\n *\n * E5.1 makes provisions to support strings longer than 4G characters.\n * This limit should be eliminated on 64-bit platforms (and increased\n * closer to maximum support on 32-bit platforms).\n */\n\n#if defined(DUK_USE_STRLEN16)\n#define DUK_HSTRING_MAX_BYTELEN                     (0x0000ffffUL)\n#else\n#define DUK_HSTRING_MAX_BYTELEN                     (0x7fffffffUL)\n#endif\n\n/* XXX: could add flags for \"is valid CESU-8\" (Ecmascript compatible strings),\n * \"is valid UTF-8\", \"is valid extended UTF-8\" (internal strings are not,\n * regexp bytecode is), and \"contains non-BMP characters\".  These are not\n * needed right now.\n */\n\n#define DUK_HSTRING_FLAG_ASCII                      DUK_HEAPHDR_USER_FLAG(0)  /* string is ASCII, clen == blen */\n#define DUK_HSTRING_FLAG_ARRIDX                     DUK_HEAPHDR_USER_FLAG(1)  /* string is a valid array index */\n#define DUK_HSTRING_FLAG_SYMBOL                     DUK_HEAPHDR_USER_FLAG(2)  /* string is a symbol (invalid utf-8) */\n#define DUK_HSTRING_FLAG_HIDDEN                     DUK_HEAPHDR_USER_FLAG(3)  /* string is a hidden symbol (implies symbol, Duktape 1.x internal string) */\n#define DUK_HSTRING_FLAG_RESERVED_WORD              DUK_HEAPHDR_USER_FLAG(4)  /* string is a reserved word (non-strict) */\n#define DUK_HSTRING_FLAG_STRICT_RESERVED_WORD       DUK_HEAPHDR_USER_FLAG(5)  /* string is a reserved word (strict) */\n#define DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS          DUK_HEAPHDR_USER_FLAG(6)  /* string is 'eval' or 'arguments' */\n#define DUK_HSTRING_FLAG_EXTDATA                    DUK_HEAPHDR_USER_FLAG(7)  /* string data is external (duk_hstring_external) */\n\n#define DUK_HSTRING_HAS_ASCII(x)                    DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII)\n#define DUK_HSTRING_HAS_ARRIDX(x)                   DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX)\n#define DUK_HSTRING_HAS_SYMBOL(x)                   DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_SYMBOL)\n#define DUK_HSTRING_HAS_HIDDEN(x)                   DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_HIDDEN)\n#define DUK_HSTRING_HAS_RESERVED_WORD(x)            DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_RESERVED_WORD)\n#define DUK_HSTRING_HAS_STRICT_RESERVED_WORD(x)     DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD)\n#define DUK_HSTRING_HAS_EVAL_OR_ARGUMENTS(x)        DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS)\n#define DUK_HSTRING_HAS_EXTDATA(x)                  DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA)\n\n#define DUK_HSTRING_SET_ASCII(x)                    DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII)\n#define DUK_HSTRING_SET_ARRIDX(x)                   DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX)\n#define DUK_HSTRING_SET_SYMBOL(x)                   DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_SYMBOL)\n#define DUK_HSTRING_SET_HIDDEN(x)                   DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_HIDDEN)\n#define DUK_HSTRING_SET_RESERVED_WORD(x)            DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_RESERVED_WORD)\n#define DUK_HSTRING_SET_STRICT_RESERVED_WORD(x)     DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD)\n#define DUK_HSTRING_SET_EVAL_OR_ARGUMENTS(x)        DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS)\n#define DUK_HSTRING_SET_EXTDATA(x)                  DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA)\n\n#define DUK_HSTRING_CLEAR_ASCII(x)                  DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ASCII)\n#define DUK_HSTRING_CLEAR_ARRIDX(x)                 DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_ARRIDX)\n#define DUK_HSTRING_CLEAR_SYMBOL(x)                 DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_SYMBOL)\n#define DUK_HSTRING_CLEAR_HIDDEN(x)                 DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_HIDDEN)\n#define DUK_HSTRING_CLEAR_RESERVED_WORD(x)          DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_RESERVED_WORD)\n#define DUK_HSTRING_CLEAR_STRICT_RESERVED_WORD(x)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_STRICT_RESERVED_WORD)\n#define DUK_HSTRING_CLEAR_EVAL_OR_ARGUMENTS(x)      DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS)\n#define DUK_HSTRING_CLEAR_EXTDATA(x)                DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HSTRING_FLAG_EXTDATA)\n\n#if 0  /* Slightly smaller code without explicit flag, but explicit flag\n        * is very useful when 'clen' is dropped.\n        */\n#define DUK_HSTRING_IS_ASCII(x)                     (DUK_HSTRING_GET_BYTELEN((x)) == DUK_HSTRING_GET_CHARLEN((x)))\n#endif\n#define DUK_HSTRING_IS_ASCII(x)                     DUK_HSTRING_HAS_ASCII((x))  /* lazily set! */\n#define DUK_HSTRING_IS_EMPTY(x)                     (DUK_HSTRING_GET_BYTELEN((x)) == 0)\n\n#if defined(DUK_USE_STRHASH16)\n#define DUK_HSTRING_GET_HASH(x)                     ((x)->hdr.h_flags >> 16)\n#define DUK_HSTRING_SET_HASH(x,v) do { \\\n\t\t(x)->hdr.h_flags = ((x)->hdr.h_flags & 0x0000ffffUL) | ((v) << 16); \\\n\t} while (0)\n#else\n#define DUK_HSTRING_GET_HASH(x)                     ((x)->hash)\n#define DUK_HSTRING_SET_HASH(x,v) do { \\\n\t\t(x)->hash = (v); \\\n\t} while (0)\n#endif\n\n#if defined(DUK_USE_STRLEN16)\n#define DUK_HSTRING_GET_BYTELEN(x)                  ((x)->hdr.h_strextra16)\n#define DUK_HSTRING_SET_BYTELEN(x,v) do { \\\n\t\t(x)->hdr.h_strextra16 = (v); \\\n\t} while (0)\n#if defined(DUK_USE_HSTRING_CLEN)\n#define DUK_HSTRING_GET_CHARLEN(x)                  duk_hstring_get_charlen((x))\n#define DUK_HSTRING_SET_CHARLEN(x,v) do { \\\n\t\t(x)->clen16 = (v); \\\n\t} while (0)\n#else\n#define DUK_HSTRING_GET_CHARLEN(x)                  duk_hstring_get_charlen((x))\n#define DUK_HSTRING_SET_CHARLEN(x,v) do { \\\n\t\tDUK_ASSERT(0);  /* should never be called */ \\\n\t} while (0)\n#endif\n#else\n#define DUK_HSTRING_GET_BYTELEN(x)                  ((x)->blen)\n#define DUK_HSTRING_SET_BYTELEN(x,v) do { \\\n\t\t(x)->blen = (v); \\\n\t} while (0)\n#define DUK_HSTRING_GET_CHARLEN(x)                  duk_hstring_get_charlen((x))\n#define DUK_HSTRING_SET_CHARLEN(x,v) do { \\\n\t\t(x)->clen = (v); \\\n\t} while (0)\n#endif\n\n#if defined(DUK_USE_HSTRING_EXTDATA)\n#define DUK_HSTRING_GET_EXTDATA(x) \\\n\t((x)->extdata)\n#define DUK_HSTRING_GET_DATA(x) \\\n\t(DUK_HSTRING_HAS_EXTDATA((x)) ? \\\n\t\tDUK_HSTRING_GET_EXTDATA((const duk_hstring_external *) (x)) : ((const duk_uint8_t *) ((x) + 1)))\n#else\n#define DUK_HSTRING_GET_DATA(x) \\\n\t((const duk_uint8_t *) ((x) + 1))\n#endif\n\n#define DUK_HSTRING_GET_DATA_END(x) \\\n\t(DUK_HSTRING_GET_DATA((x)) + (x)->blen)\n\n/* marker value; in E5 2^32-1 is not a valid array index (2^32-2 is highest valid) */\n#define DUK_HSTRING_NO_ARRAY_INDEX  (0xffffffffUL)\n\n#if defined(DUK_USE_HSTRING_ARRIDX)\n#define DUK_HSTRING_GET_ARRIDX_FAST(h)  ((h)->arridx)\n#define DUK_HSTRING_GET_ARRIDX_SLOW(h)  ((h)->arridx)\n#else\n/* Get array index related to string (or return DUK_HSTRING_NO_ARRAY_INDEX);\n * avoids helper call if string has no array index value.\n */\n#define DUK_HSTRING_GET_ARRIDX_FAST(h)  \\\n\t(DUK_HSTRING_HAS_ARRIDX((h)) ? duk_js_to_arrayindex_hstring_fast_known((h)) : DUK_HSTRING_NO_ARRAY_INDEX)\n\n/* Slower but more compact variant. */\n#define DUK_HSTRING_GET_ARRIDX_SLOW(h)  \\\n\t(duk_js_to_arrayindex_hstring_fast((h)))\n#endif\n\n/*\n *  Misc\n */\n\nstruct duk_hstring {\n\t/* Smaller heaphdr than for other objects, because strings are held\n\t * in string intern table which requires no link pointers.  Much of\n\t * the 32-bit flags field is unused by flags, so we can stuff a 16-bit\n\t * field in there.\n\t */\n\tduk_heaphdr_string hdr;\n\n\t/* String hash. */\n#if defined(DUK_USE_STRHASH16)\n\t/* If 16-bit hash is in use, stuff it into duk_heaphdr_string flags. */\n#else\n\tduk_uint32_t hash;\n#endif\n\n\t/* Precomputed array index (or DUK_HSTRING_NO_ARRAY_INDEX). */\n#if defined(DUK_USE_HSTRING_ARRIDX)\n\tduk_uarridx_t arridx;\n#endif\n\n\t/* Length in bytes (not counting NUL term). */\n#if defined(DUK_USE_STRLEN16)\n\t/* placed in duk_heaphdr_string */\n#else\n\tduk_uint32_t blen;\n#endif\n\n\t/* Length in codepoints (must be E5 compatible). */\n#if defined(DUK_USE_STRLEN16)\n#if defined(DUK_USE_HSTRING_CLEN)\n\tduk_uint16_t clen16;\n#else\n\t/* computed live */\n#endif\n#else\n\tduk_uint32_t clen;\n#endif\n\n\t/*\n\t *  String data of 'blen+1' bytes follows (+1 for NUL termination\n\t *  convenience for C API).  No alignment needs to be guaranteed\n\t *  for strings, but fields above should guarantee alignment-by-4\n\t *  (but not alignment-by-8).\n\t */\n};\n\n/* The external string struct is defined even when the feature is inactive. */\nstruct duk_hstring_external {\n\tduk_hstring str;\n\n\t/*\n\t *  For an external string, the NUL-terminated string data is stored\n\t *  externally.  The user must guarantee that data behind this pointer\n\t *  doesn't change while it's used.\n\t */\n\n\tconst duk_uint8_t *extdata;\n};\n\n/*\n *  Prototypes\n */\n\nDUK_INTERNAL_DECL duk_ucodepoint_t duk_hstring_char_code_at_raw(duk_hthread *thr, duk_hstring *h, duk_uint_t pos, duk_bool_t surrogate_aware);\nDUK_INTERNAL_DECL duk_size_t duk_hstring_get_charlen(duk_hstring *h);\n\n#endif  /* DUK_HSTRING_H_INCLUDED */\n/* #include duk_hobject.h */\n/*\n *  Heap object representation.\n *\n *  Heap objects are used for Ecmascript objects, arrays, and functions,\n *  but also for internal control like declarative and object environment\n *  records.  Compiled functions, native functions, and threads are also\n *  objects but with an extended C struct.\n *\n *  Objects provide the required Ecmascript semantics and exotic behaviors\n *  especially for property access.\n *\n *  Properties are stored in three conceptual parts:\n *\n *    1. A linear 'entry part' contains ordered key-value-attributes triples\n *       and is the main method of string properties.\n *\n *    2. An optional linear 'array part' is used for array objects to store a\n *       (dense) range of [0,N[ array indexed entries with default attributes\n *       (writable, enumerable, configurable).  If the array part would become\n *       sparse or non-default attributes are required, the array part is\n *       abandoned and moved to the 'entry part'.\n *\n *    3. An optional 'hash part' is used to optimize lookups of the entry\n *       part; it is used only for objects with sufficiently many properties\n *       and can be abandoned without loss of information.\n *\n *  These three conceptual parts are stored in a single memory allocated area.\n *  This minimizes memory allocation overhead but also means that all three\n *  parts are resized together, and makes property access a bit complicated.\n */\n\n#if !defined(DUK_HOBJECT_H_INCLUDED)\n#define DUK_HOBJECT_H_INCLUDED\n\n/* Object flags.  Make sure this stays in sync with debugger object\n * inspection code.\n */\n\n/* XXX: some flags are object subtype specific (e.g. common to all function\n * subtypes, duk_harray, etc) and could be reused for different subtypes.\n */\n#define DUK_HOBJECT_FLAG_EXTENSIBLE            DUK_HEAPHDR_USER_FLAG(0)   /* object is extensible */\n#define DUK_HOBJECT_FLAG_CONSTRUCTABLE         DUK_HEAPHDR_USER_FLAG(1)   /* object is constructable */\n#define DUK_HOBJECT_FLAG_BOUNDFUNC             DUK_HEAPHDR_USER_FLAG(2)   /* object established using Function.prototype.bind() */\n#define DUK_HOBJECT_FLAG_COMPFUNC              DUK_HEAPHDR_USER_FLAG(4)   /* object is a compiled function (duk_hcompfunc) */\n#define DUK_HOBJECT_FLAG_NATFUNC               DUK_HEAPHDR_USER_FLAG(5)   /* object is a native function (duk_hnatfunc) */\n#define DUK_HOBJECT_FLAG_BUFOBJ                DUK_HEAPHDR_USER_FLAG(6)   /* object is a buffer object (duk_hbufobj) (always exotic) */\n#define DUK_HOBJECT_FLAG_FASTREFS              DUK_HEAPHDR_USER_FLAG(7)   /* object has no fields needing DECREF/marking beyond base duk_hobject header */\n#define DUK_HOBJECT_FLAG_ARRAY_PART            DUK_HEAPHDR_USER_FLAG(8)   /* object has an array part (a_size may still be 0) */\n#define DUK_HOBJECT_FLAG_STRICT                DUK_HEAPHDR_USER_FLAG(9)   /* function: function object is strict */\n#define DUK_HOBJECT_FLAG_NOTAIL                DUK_HEAPHDR_USER_FLAG(10)  /* function: function must not be tail called */\n#define DUK_HOBJECT_FLAG_NEWENV                DUK_HEAPHDR_USER_FLAG(11)  /* function: create new environment when called (see duk_hcompfunc) */\n#define DUK_HOBJECT_FLAG_NAMEBINDING           DUK_HEAPHDR_USER_FLAG(12)  /* function: create binding for func name (function templates only, used for named function expressions) */\n#define DUK_HOBJECT_FLAG_CREATEARGS            DUK_HEAPHDR_USER_FLAG(13)  /* function: create an arguments object on function call */\n#define DUK_HOBJECT_FLAG_HAVE_FINALIZER        DUK_HEAPHDR_USER_FLAG(14)  /* object has a callable finalizer property */\n#define DUK_HOBJECT_FLAG_EXOTIC_ARRAY          DUK_HEAPHDR_USER_FLAG(15)  /* 'Array' object, array length and index exotic behavior */\n#define DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ      DUK_HEAPHDR_USER_FLAG(16)  /* 'String' object, array index exotic behavior */\n#define DUK_HOBJECT_FLAG_EXOTIC_ARGUMENTS      DUK_HEAPHDR_USER_FLAG(17)  /* 'Arguments' object and has arguments exotic behavior (non-strict callee) */\n#define DUK_HOBJECT_FLAG_EXOTIC_DUKFUNC        DUK_HEAPHDR_USER_FLAG(18)  /* Duktape/C (nativefunction) object, exotic 'length' */\n#define DUK_HOBJECT_FLAG_EXOTIC_PROXYOBJ       DUK_HEAPHDR_USER_FLAG(19)  /* 'Proxy' object */\n\n#define DUK_HOBJECT_FLAG_CLASS_BASE            DUK_HEAPHDR_USER_FLAG_NUMBER(20)\n#define DUK_HOBJECT_FLAG_CLASS_BITS            5\n\n#define DUK_HOBJECT_GET_CLASS_NUMBER(h)        \\\n\tDUK_HEAPHDR_GET_FLAG_RANGE(&(h)->hdr, DUK_HOBJECT_FLAG_CLASS_BASE, DUK_HOBJECT_FLAG_CLASS_BITS)\n#define DUK_HOBJECT_SET_CLASS_NUMBER(h,v)      \\\n\tDUK_HEAPHDR_SET_FLAG_RANGE(&(h)->hdr, DUK_HOBJECT_FLAG_CLASS_BASE, DUK_HOBJECT_FLAG_CLASS_BITS, (v))\n\n#define DUK_HOBJECT_GET_CLASS_MASK(h)          \\\n\t(1UL << DUK_HEAPHDR_GET_FLAG_RANGE(&(h)->hdr, DUK_HOBJECT_FLAG_CLASS_BASE, DUK_HOBJECT_FLAG_CLASS_BITS))\n\n/* Macro for creating flag initializer from a class number.\n * Unsigned type cast is needed to avoid warnings about coercing\n * a signed integer to an unsigned one; the largest class values\n * have the highest bit (bit 31) set which causes this.\n */\n#define DUK_HOBJECT_CLASS_AS_FLAGS(v)          (((duk_uint_t) (v)) << DUK_HOBJECT_FLAG_CLASS_BASE)\n\n/* E5 Section 8.6.2 + custom classes */\n#define DUK_HOBJECT_CLASS_NONE                 0\n#define DUK_HOBJECT_CLASS_OBJECT               1\n#define DUK_HOBJECT_CLASS_ARRAY                2\n#define DUK_HOBJECT_CLASS_FUNCTION             3\n#define DUK_HOBJECT_CLASS_ARGUMENTS            4\n#define DUK_HOBJECT_CLASS_BOOLEAN              5\n#define DUK_HOBJECT_CLASS_DATE                 6\n#define DUK_HOBJECT_CLASS_ERROR                7\n#define DUK_HOBJECT_CLASS_JSON                 8\n#define DUK_HOBJECT_CLASS_MATH                 9\n#define DUK_HOBJECT_CLASS_NUMBER               10\n#define DUK_HOBJECT_CLASS_REGEXP               11\n#define DUK_HOBJECT_CLASS_STRING               12\n#define DUK_HOBJECT_CLASS_GLOBAL               13\n#define DUK_HOBJECT_CLASS_SYMBOL               14\n#define DUK_HOBJECT_CLASS_OBJENV               15  /* custom */\n#define DUK_HOBJECT_CLASS_DECENV               16  /* custom */\n#define DUK_HOBJECT_CLASS_POINTER              17  /* custom */\n#define DUK_HOBJECT_CLASS_THREAD               18  /* custom; implies DUK_HOBJECT_IS_THREAD */\n#define DUK_HOBJECT_CLASS_BUFOBJ_MIN           19\n#define DUK_HOBJECT_CLASS_ARRAYBUFFER          19  /* implies DUK_HOBJECT_IS_BUFOBJ */\n#define DUK_HOBJECT_CLASS_DATAVIEW             20\n#define DUK_HOBJECT_CLASS_INT8ARRAY            21\n#define DUK_HOBJECT_CLASS_UINT8ARRAY           22\n#define DUK_HOBJECT_CLASS_UINT8CLAMPEDARRAY    23\n#define DUK_HOBJECT_CLASS_INT16ARRAY           24\n#define DUK_HOBJECT_CLASS_UINT16ARRAY          25\n#define DUK_HOBJECT_CLASS_INT32ARRAY           26\n#define DUK_HOBJECT_CLASS_UINT32ARRAY          27\n#define DUK_HOBJECT_CLASS_FLOAT32ARRAY         28\n#define DUK_HOBJECT_CLASS_FLOAT64ARRAY         29\n#define DUK_HOBJECT_CLASS_BUFOBJ_MAX           29\n#define DUK_HOBJECT_CLASS_MAX                  29\n\n/* Class masks. */\n#define DUK_HOBJECT_CMASK_ALL                  ((1UL << (DUK_HOBJECT_CLASS_MAX + 1)) - 1UL)\n#define DUK_HOBJECT_CMASK_NONE                 (1UL << DUK_HOBJECT_CLASS_NONE)\n#define DUK_HOBJECT_CMASK_ARGUMENTS            (1UL << DUK_HOBJECT_CLASS_ARGUMENTS)\n#define DUK_HOBJECT_CMASK_ARRAY                (1UL << DUK_HOBJECT_CLASS_ARRAY)\n#define DUK_HOBJECT_CMASK_BOOLEAN              (1UL << DUK_HOBJECT_CLASS_BOOLEAN)\n#define DUK_HOBJECT_CMASK_DATE                 (1UL << DUK_HOBJECT_CLASS_DATE)\n#define DUK_HOBJECT_CMASK_ERROR                (1UL << DUK_HOBJECT_CLASS_ERROR)\n#define DUK_HOBJECT_CMASK_FUNCTION             (1UL << DUK_HOBJECT_CLASS_FUNCTION)\n#define DUK_HOBJECT_CMASK_JSON                 (1UL << DUK_HOBJECT_CLASS_JSON)\n#define DUK_HOBJECT_CMASK_MATH                 (1UL << DUK_HOBJECT_CLASS_MATH)\n#define DUK_HOBJECT_CMASK_NUMBER               (1UL << DUK_HOBJECT_CLASS_NUMBER)\n#define DUK_HOBJECT_CMASK_OBJECT               (1UL << DUK_HOBJECT_CLASS_OBJECT)\n#define DUK_HOBJECT_CMASK_REGEXP               (1UL << DUK_HOBJECT_CLASS_REGEXP)\n#define DUK_HOBJECT_CMASK_STRING               (1UL << DUK_HOBJECT_CLASS_STRING)\n#define DUK_HOBJECT_CMASK_GLOBAL               (1UL << DUK_HOBJECT_CLASS_GLOBAL)\n#define DUK_HOBJECT_CMASK_SYMBOL               (1UL << DUK_HOBJECT_CLASS_SYMBOL)\n#define DUK_HOBJECT_CMASK_OBJENV               (1UL << DUK_HOBJECT_CLASS_OBJENV)\n#define DUK_HOBJECT_CMASK_DECENV               (1UL << DUK_HOBJECT_CLASS_DECENV)\n#define DUK_HOBJECT_CMASK_POINTER              (1UL << DUK_HOBJECT_CLASS_POINTER)\n#define DUK_HOBJECT_CMASK_ARRAYBUFFER          (1UL << DUK_HOBJECT_CLASS_ARRAYBUFFER)\n#define DUK_HOBJECT_CMASK_DATAVIEW             (1UL << DUK_HOBJECT_CLASS_DATAVIEW)\n#define DUK_HOBJECT_CMASK_INT8ARRAY            (1UL << DUK_HOBJECT_CLASS_INT8ARRAY)\n#define DUK_HOBJECT_CMASK_UINT8ARRAY           (1UL << DUK_HOBJECT_CLASS_UINT8ARRAY)\n#define DUK_HOBJECT_CMASK_UINT8CLAMPEDARRAY    (1UL << DUK_HOBJECT_CLASS_UINT8CLAMPEDARRAY)\n#define DUK_HOBJECT_CMASK_INT16ARRAY           (1UL << DUK_HOBJECT_CLASS_INT16ARRAY)\n#define DUK_HOBJECT_CMASK_UINT16ARRAY          (1UL << DUK_HOBJECT_CLASS_UINT16ARRAY)\n#define DUK_HOBJECT_CMASK_INT32ARRAY           (1UL << DUK_HOBJECT_CLASS_INT32ARRAY)\n#define DUK_HOBJECT_CMASK_UINT32ARRAY          (1UL << DUK_HOBJECT_CLASS_UINT32ARRAY)\n#define DUK_HOBJECT_CMASK_FLOAT32ARRAY         (1UL << DUK_HOBJECT_CLASS_FLOAT32ARRAY)\n#define DUK_HOBJECT_CMASK_FLOAT64ARRAY         (1UL << DUK_HOBJECT_CLASS_FLOAT64ARRAY)\n\n#define DUK_HOBJECT_CMASK_ALL_BUFOBJS \\\n\t(DUK_HOBJECT_CMASK_ARRAYBUFFER | \\\n\t DUK_HOBJECT_CMASK_DATAVIEW | \\\n\t DUK_HOBJECT_CMASK_INT8ARRAY | \\\n\t DUK_HOBJECT_CMASK_UINT8ARRAY | \\\n\t DUK_HOBJECT_CMASK_UINT8CLAMPEDARRAY | \\\n\t DUK_HOBJECT_CMASK_INT16ARRAY | \\\n\t DUK_HOBJECT_CMASK_UINT16ARRAY | \\\n\t DUK_HOBJECT_CMASK_INT32ARRAY | \\\n\t DUK_HOBJECT_CMASK_UINT32ARRAY | \\\n\t DUK_HOBJECT_CMASK_FLOAT32ARRAY | \\\n\t DUK_HOBJECT_CMASK_FLOAT64ARRAY)\n\n#define DUK_HOBJECT_IS_OBJENV(h)               (DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_OBJENV)\n#define DUK_HOBJECT_IS_DECENV(h)               (DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_DECENV)\n#define DUK_HOBJECT_IS_ENV(h)                  (DUK_HOBJECT_IS_OBJENV((h)) || DUK_HOBJECT_IS_DECENV((h)))\n#define DUK_HOBJECT_IS_ARRAY(h)                DUK_HOBJECT_HAS_EXOTIC_ARRAY((h))  /* Rely on class Array <=> exotic Array */\n#define DUK_HOBJECT_IS_BOUNDFUNC(h)            DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_BOUNDFUNC)\n#define DUK_HOBJECT_IS_COMPFUNC(h)             DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_COMPFUNC)\n#define DUK_HOBJECT_IS_NATFUNC(h)              DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NATFUNC)\n#define DUK_HOBJECT_IS_BUFOBJ(h)               DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_BUFOBJ)\n#define DUK_HOBJECT_IS_THREAD(h)               (DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_THREAD)\n\n#define DUK_HOBJECT_IS_NONBOUND_FUNCTION(h)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, \\\n                                                        DUK_HOBJECT_FLAG_COMPFUNC | \\\n                                                        DUK_HOBJECT_FLAG_NATFUNC)\n\n#define DUK_HOBJECT_IS_FUNCTION(h)             DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, \\\n                                                        DUK_HOBJECT_FLAG_BOUNDFUNC | \\\n                                                        DUK_HOBJECT_FLAG_COMPFUNC | \\\n                                                        DUK_HOBJECT_FLAG_NATFUNC)\n\n#define DUK_HOBJECT_IS_CALLABLE(h)             DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, \\\n                                                        DUK_HOBJECT_FLAG_BOUNDFUNC | \\\n                                                        DUK_HOBJECT_FLAG_COMPFUNC | \\\n                                                        DUK_HOBJECT_FLAG_NATFUNC)\n\n/* Object has any exotic behavior(s). */\n#define DUK_HOBJECT_EXOTIC_BEHAVIOR_FLAGS      (DUK_HOBJECT_FLAG_EXOTIC_ARRAY | \\\n                                                DUK_HOBJECT_FLAG_EXOTIC_ARGUMENTS | \\\n                                                DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ | \\\n                                                DUK_HOBJECT_FLAG_EXOTIC_DUKFUNC | \\\n                                                DUK_HOBJECT_FLAG_BUFOBJ | \\\n                                                DUK_HOBJECT_FLAG_EXOTIC_PROXYOBJ)\n#define DUK_HOBJECT_HAS_EXOTIC_BEHAVIOR(h)     DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_EXOTIC_BEHAVIOR_FLAGS)\n\n/* Object has any virtual properties (not counting Proxy behavior). */\n#define DUK_HOBJECT_VIRTUAL_PROPERTY_FLAGS     (DUK_HOBJECT_FLAG_EXOTIC_ARRAY | \\\n                                                DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ | \\\n                                                DUK_HOBJECT_FLAG_EXOTIC_DUKFUNC | \\\n                                                DUK_HOBJECT_FLAG_BUFOBJ)\n#define DUK_HOBJECT_HAS_VIRTUAL_PROPERTIES(h)  DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_VIRTUAL_PROPERTY_FLAGS)\n\n#define DUK_HOBJECT_HAS_EXTENSIBLE(h)          DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXTENSIBLE)\n#define DUK_HOBJECT_HAS_CONSTRUCTABLE(h)       DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_CONSTRUCTABLE)\n#define DUK_HOBJECT_HAS_BOUNDFUNC(h)           DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_BOUNDFUNC)\n#define DUK_HOBJECT_HAS_COMPFUNC(h)            DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_COMPFUNC)\n#define DUK_HOBJECT_HAS_NATFUNC(h)             DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NATFUNC)\n#define DUK_HOBJECT_HAS_BUFOBJ(h)              DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_BUFOBJ)\n#define DUK_HOBJECT_HAS_FASTREFS(h)            DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_FASTREFS)\n#define DUK_HOBJECT_HAS_ARRAY_PART(h)          DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_ARRAY_PART)\n#define DUK_HOBJECT_HAS_STRICT(h)              DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_STRICT)\n#define DUK_HOBJECT_HAS_NOTAIL(h)              DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NOTAIL)\n#define DUK_HOBJECT_HAS_NEWENV(h)              DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NEWENV)\n#define DUK_HOBJECT_HAS_NAMEBINDING(h)         DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NAMEBINDING)\n#define DUK_HOBJECT_HAS_CREATEARGS(h)          DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_CREATEARGS)\n#define DUK_HOBJECT_HAS_HAVE_FINALIZER(h)      DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_HAVE_FINALIZER)\n#define DUK_HOBJECT_HAS_EXOTIC_ARRAY(h)        DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_ARRAY)\n#define DUK_HOBJECT_HAS_EXOTIC_STRINGOBJ(h)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ)\n#define DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS(h)    DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_ARGUMENTS)\n#define DUK_HOBJECT_HAS_EXOTIC_DUKFUNC(h)      DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_DUKFUNC)\n#define DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(h)     DUK_HEAPHDR_CHECK_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_PROXYOBJ)\n\n#define DUK_HOBJECT_SET_EXTENSIBLE(h)          DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXTENSIBLE)\n#define DUK_HOBJECT_SET_CONSTRUCTABLE(h)       DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_CONSTRUCTABLE)\n#define DUK_HOBJECT_SET_BOUNDFUNC(h)           DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_BOUNDFUNC)\n#define DUK_HOBJECT_SET_COMPFUNC(h)            DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_COMPFUNC)\n#define DUK_HOBJECT_SET_NATFUNC(h)             DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NATFUNC)\n#define DUK_HOBJECT_SET_BUFOBJ(h)              DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_BUFOBJ)\n#define DUK_HOBJECT_SET_FASTREFS(h)            DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_FASTREFS)\n#define DUK_HOBJECT_SET_ARRAY_PART(h)          DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_ARRAY_PART)\n#define DUK_HOBJECT_SET_STRICT(h)              DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_STRICT)\n#define DUK_HOBJECT_SET_NOTAIL(h)              DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NOTAIL)\n#define DUK_HOBJECT_SET_NEWENV(h)              DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NEWENV)\n#define DUK_HOBJECT_SET_NAMEBINDING(h)         DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NAMEBINDING)\n#define DUK_HOBJECT_SET_CREATEARGS(h)          DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_CREATEARGS)\n#define DUK_HOBJECT_SET_HAVE_FINALIZER(h)      DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_HAVE_FINALIZER)\n#define DUK_HOBJECT_SET_EXOTIC_ARRAY(h)        DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_ARRAY)\n#define DUK_HOBJECT_SET_EXOTIC_STRINGOBJ(h)    DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ)\n#define DUK_HOBJECT_SET_EXOTIC_ARGUMENTS(h)    DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_ARGUMENTS)\n#define DUK_HOBJECT_SET_EXOTIC_DUKFUNC(h)      DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_DUKFUNC)\n#define DUK_HOBJECT_SET_EXOTIC_PROXYOBJ(h)     DUK_HEAPHDR_SET_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_PROXYOBJ)\n\n#define DUK_HOBJECT_CLEAR_EXTENSIBLE(h)        DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXTENSIBLE)\n#define DUK_HOBJECT_CLEAR_CONSTRUCTABLE(h)     DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_CONSTRUCTABLE)\n#define DUK_HOBJECT_CLEAR_BOUNDFUNC(h)         DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_BOUNDFUNC)\n#define DUK_HOBJECT_CLEAR_COMPFUNC(h)          DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_COMPFUNC)\n#define DUK_HOBJECT_CLEAR_NATFUNC(h)           DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NATFUNC)\n#define DUK_HOBJECT_CLEAR_BUFOBJ(h)            DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_BUFOBJ)\n#define DUK_HOBJECT_CLEAR_FASTREFS(h)          DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_FASTREFS)\n#define DUK_HOBJECT_CLEAR_ARRAY_PART(h)        DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_ARRAY_PART)\n#define DUK_HOBJECT_CLEAR_STRICT(h)            DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_STRICT)\n#define DUK_HOBJECT_CLEAR_NOTAIL(h)            DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NOTAIL)\n#define DUK_HOBJECT_CLEAR_NEWENV(h)            DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NEWENV)\n#define DUK_HOBJECT_CLEAR_NAMEBINDING(h)       DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_NAMEBINDING)\n#define DUK_HOBJECT_CLEAR_CREATEARGS(h)        DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_CREATEARGS)\n#define DUK_HOBJECT_CLEAR_HAVE_FINALIZER(h)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_HAVE_FINALIZER)\n#define DUK_HOBJECT_CLEAR_EXOTIC_ARRAY(h)      DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_ARRAY)\n#define DUK_HOBJECT_CLEAR_EXOTIC_STRINGOBJ(h)  DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ)\n#define DUK_HOBJECT_CLEAR_EXOTIC_ARGUMENTS(h)  DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_ARGUMENTS)\n#define DUK_HOBJECT_CLEAR_EXOTIC_DUKFUNC(h)    DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_DUKFUNC)\n#define DUK_HOBJECT_CLEAR_EXOTIC_PROXYOBJ(h)   DUK_HEAPHDR_CLEAR_FLAG_BITS(&(h)->hdr, DUK_HOBJECT_FLAG_EXOTIC_PROXYOBJ)\n\n/* Object can/cannot use FASTREFS, i.e. has no strong reference fields beyond\n * duk_hobject base header.\n */\n#define DUK_HOBJECT_PROHIBITS_FASTREFS(h) \\\n\t(DUK_HOBJECT_IS_COMPFUNC((h)) || DUK_HOBJECT_IS_DECENV((h)) || DUK_HOBJECT_IS_OBJENV((h)) || \\\n\t DUK_HOBJECT_IS_BUFOBJ((h)) || DUK_HOBJECT_IS_THREAD((h)))\n#define DUK_HOBJECT_ALLOWS_FASTREFS(h) (!DUK_HOBJECT_PROHIBITS_FASTREFS((h)))\n\n/* Flags used for property attributes in duk_propdesc and packed flags.\n * Must fit into 8 bits.\n */\n#define DUK_PROPDESC_FLAG_WRITABLE              (1 << 0)    /* E5 Section 8.6.1 */\n#define DUK_PROPDESC_FLAG_ENUMERABLE            (1 << 1)    /* E5 Section 8.6.1 */\n#define DUK_PROPDESC_FLAG_CONFIGURABLE          (1 << 2)    /* E5 Section 8.6.1 */\n#define DUK_PROPDESC_FLAG_ACCESSOR              (1 << 3)    /* accessor */\n#define DUK_PROPDESC_FLAG_VIRTUAL               (1 << 4)    /* property is virtual: used in duk_propdesc, never stored\n                                                             * (used by e.g. buffer virtual properties)\n                                                             */\n#define DUK_PROPDESC_FLAGS_MASK                 (DUK_PROPDESC_FLAG_WRITABLE | \\\n                                                 DUK_PROPDESC_FLAG_ENUMERABLE | \\\n                                                 DUK_PROPDESC_FLAG_CONFIGURABLE | \\\n                                                 DUK_PROPDESC_FLAG_ACCESSOR)\n\n/* Additional flags which are passed in the same flags argument as property\n * flags but are not stored in object properties.\n */\n#define DUK_PROPDESC_FLAG_NO_OVERWRITE          (1 << 4)    /* internal define property: skip write silently if exists */\n\n/* Convenience defines for property attributes. */\n#define DUK_PROPDESC_FLAGS_NONE                 0\n#define DUK_PROPDESC_FLAGS_W                    (DUK_PROPDESC_FLAG_WRITABLE)\n#define DUK_PROPDESC_FLAGS_E                    (DUK_PROPDESC_FLAG_ENUMERABLE)\n#define DUK_PROPDESC_FLAGS_C                    (DUK_PROPDESC_FLAG_CONFIGURABLE)\n#define DUK_PROPDESC_FLAGS_WE                   (DUK_PROPDESC_FLAG_WRITABLE | DUK_PROPDESC_FLAG_ENUMERABLE)\n#define DUK_PROPDESC_FLAGS_WC                   (DUK_PROPDESC_FLAG_WRITABLE | DUK_PROPDESC_FLAG_CONFIGURABLE)\n#define DUK_PROPDESC_FLAGS_EC                   (DUK_PROPDESC_FLAG_ENUMERABLE | DUK_PROPDESC_FLAG_CONFIGURABLE)\n#define DUK_PROPDESC_FLAGS_WEC                  (DUK_PROPDESC_FLAG_WRITABLE | \\\n                                                 DUK_PROPDESC_FLAG_ENUMERABLE | \\\n                                                 DUK_PROPDESC_FLAG_CONFIGURABLE)\n\n/* Flags for duk_hobject_get_own_propdesc() and variants. */\n#define DUK_GETDESC_FLAG_PUSH_VALUE          (1 << 0)  /* push value to stack */\n#define DUK_GETDESC_FLAG_IGNORE_PROTOLOOP    (1 << 1)  /* don't throw for prototype loop */\n\n/*\n *  Macro for object validity check\n *\n *  Assert for currently guaranteed relations between flags, for instance.\n */\n\n#define DUK_ASSERT_HOBJECT_VALID(h) do { \\\n\t\tDUK_ASSERT((h) != NULL); \\\n\t\tDUK_ASSERT(!DUK_HOBJECT_IS_CALLABLE((h)) || \\\n\t\t           DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_FUNCTION); \\\n\t\tDUK_ASSERT(!DUK_HOBJECT_IS_BUFOBJ((h)) || \\\n\t\t           (DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_ARRAYBUFFER || \\\n\t\t            DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_DATAVIEW || \\\n\t\t            DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_INT8ARRAY || \\\n\t\t            DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_UINT8ARRAY || \\\n\t\t            DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_UINT8CLAMPEDARRAY || \\\n\t\t            DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_INT16ARRAY || \\\n\t\t            DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_UINT16ARRAY || \\\n\t\t            DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_INT32ARRAY || \\\n\t\t            DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_UINT32ARRAY || \\\n\t\t            DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_FLOAT32ARRAY || \\\n\t\t            DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_FLOAT64ARRAY)); \\\n\t\t/* Object is an Array <=> object has exotic array behavior */ \\\n\t\tDUK_ASSERT((DUK_HOBJECT_GET_CLASS_NUMBER((h)) == DUK_HOBJECT_CLASS_ARRAY && DUK_HOBJECT_HAS_EXOTIC_ARRAY((h))) || \\\n\t\t           (DUK_HOBJECT_GET_CLASS_NUMBER((h)) != DUK_HOBJECT_CLASS_ARRAY && !DUK_HOBJECT_HAS_EXOTIC_ARRAY((h)))); \\\n\t} while (0)\n\n/*\n *  Macros to access the 'props' allocation.\n */\n\n#if defined(DUK_USE_HEAPPTR16)\n#define DUK_HOBJECT_GET_PROPS(heap,h) \\\n\t((duk_uint8_t *) DUK_USE_HEAPPTR_DEC16((heap)->heap_udata, ((duk_heaphdr *) (h))->h_extra16))\n#define DUK_HOBJECT_SET_PROPS(heap,h,x) do { \\\n\t\t((duk_heaphdr *) (h))->h_extra16 = DUK_USE_HEAPPTR_ENC16((heap)->heap_udata, (void *) (x)); \\\n\t} while (0)\n#else\n#define DUK_HOBJECT_GET_PROPS(heap,h) \\\n\t((h)->props)\n#define DUK_HOBJECT_SET_PROPS(heap,h,x) do { \\\n\t\t(h)->props = (duk_uint8_t *) (x); \\\n\t} while (0)\n#endif\n\n#if defined(DUK_USE_HOBJECT_LAYOUT_1)\n/* LAYOUT 1 */\n#define DUK_HOBJECT_E_GET_KEY_BASE(heap,h) \\\n\t((duk_hstring **) (void *) ( \\\n\t\tDUK_HOBJECT_GET_PROPS((heap), (h)) \\\n\t))\n#define DUK_HOBJECT_E_GET_VALUE_BASE(heap,h) \\\n\t((duk_propvalue *) (void *) ( \\\n\t\tDUK_HOBJECT_GET_PROPS((heap), (h)) + \\\n\t\t\tDUK_HOBJECT_GET_ESIZE((h)) * sizeof(duk_hstring *) \\\n\t))\n#define DUK_HOBJECT_E_GET_FLAGS_BASE(heap,h) \\\n\t((duk_uint8_t *) (void *) ( \\\n\t\tDUK_HOBJECT_GET_PROPS((heap), (h)) + DUK_HOBJECT_GET_ESIZE((h)) * (sizeof(duk_hstring *) + sizeof(duk_propvalue)) \\\n\t))\n#define DUK_HOBJECT_A_GET_BASE(heap,h) \\\n\t((duk_tval *) (void *) ( \\\n\t\tDUK_HOBJECT_GET_PROPS((heap), (h)) + \\\n\t\t\tDUK_HOBJECT_GET_ESIZE((h)) * (sizeof(duk_hstring *) + sizeof(duk_propvalue) + sizeof(duk_uint8_t)) \\\n\t))\n#define DUK_HOBJECT_H_GET_BASE(heap,h) \\\n\t((duk_uint32_t *) (void *) ( \\\n\t\tDUK_HOBJECT_GET_PROPS((heap), (h)) + \\\n\t\t\tDUK_HOBJECT_GET_ESIZE((h)) * (sizeof(duk_hstring *) + sizeof(duk_propvalue) + sizeof(duk_uint8_t)) + \\\n\t\t\tDUK_HOBJECT_GET_ASIZE((h)) * sizeof(duk_tval) \\\n\t))\n#define DUK_HOBJECT_P_COMPUTE_SIZE(n_ent,n_arr,n_hash) \\\n\t( \\\n\t\t(n_ent) * (sizeof(duk_hstring *) + sizeof(duk_propvalue) + sizeof(duk_uint8_t)) + \\\n\t\t(n_arr) * sizeof(duk_tval) + \\\n\t\t(n_hash) * sizeof(duk_uint32_t) \\\n\t)\n#define DUK_HOBJECT_P_SET_REALLOC_PTRS(p_base,set_e_k,set_e_pv,set_e_f,set_a,set_h,n_ent,n_arr,n_hash)  do { \\\n\t\t(set_e_k) = (duk_hstring **) (void *) (p_base); \\\n\t\t(set_e_pv) = (duk_propvalue *) (void *) ((set_e_k) + (n_ent)); \\\n\t\t(set_e_f) = (duk_uint8_t *) (void *) ((set_e_pv) + (n_ent)); \\\n\t\t(set_a) = (duk_tval *) (void *) ((set_e_f) + (n_ent)); \\\n\t\t(set_h) = (duk_uint32_t *) (void *) ((set_a) + (n_arr)); \\\n\t} while (0)\n#elif defined(DUK_USE_HOBJECT_LAYOUT_2)\n/* LAYOUT 2 */\n#if (DUK_USE_ALIGN_BY == 4)\n#define DUK_HOBJECT_E_FLAG_PADDING(e_sz) ((4 - (e_sz)) & 0x03)\n#elif (DUK_USE_ALIGN_BY == 8)\n#define DUK_HOBJECT_E_FLAG_PADDING(e_sz) ((8 - (e_sz)) & 0x07)\n#elif (DUK_USE_ALIGN_BY == 1)\n#define DUK_HOBJECT_E_FLAG_PADDING(e_sz) 0\n#else\n#error invalid DUK_USE_ALIGN_BY\n#endif\n#define DUK_HOBJECT_E_GET_KEY_BASE(heap,h) \\\n\t((duk_hstring **) (void *) ( \\\n\t\tDUK_HOBJECT_GET_PROPS((heap), (h)) + \\\n\t\t\tDUK_HOBJECT_GET_ESIZE((h)) * sizeof(duk_propvalue) \\\n\t))\n#define DUK_HOBJECT_E_GET_VALUE_BASE(heap,h) \\\n\t((duk_propvalue *) (void *) ( \\\n\t\tDUK_HOBJECT_GET_PROPS((heap), (h)) \\\n\t))\n#define DUK_HOBJECT_E_GET_FLAGS_BASE(heap,h) \\\n\t((duk_uint8_t *) (void *) ( \\\n\t\tDUK_HOBJECT_GET_PROPS((heap), (h)) + DUK_HOBJECT_GET_ESIZE((h)) * (sizeof(duk_hstring *) + sizeof(duk_propvalue)) \\\n\t))\n#define DUK_HOBJECT_A_GET_BASE(heap,h) \\\n\t((duk_tval *) (void *) ( \\\n\t\tDUK_HOBJECT_GET_PROPS((heap), (h)) + \\\n\t\t\tDUK_HOBJECT_GET_ESIZE((h)) * (sizeof(duk_hstring *) + sizeof(duk_propvalue) + sizeof(duk_uint8_t)) + \\\n\t\t\tDUK_HOBJECT_E_FLAG_PADDING(DUK_HOBJECT_GET_ESIZE((h))) \\\n\t))\n#define DUK_HOBJECT_H_GET_BASE(heap,h) \\\n\t((duk_uint32_t *) (void *) ( \\\n\t\tDUK_HOBJECT_GET_PROPS((heap), (h)) + \\\n\t\t\tDUK_HOBJECT_GET_ESIZE((h)) * (sizeof(duk_hstring *) + sizeof(duk_propvalue) + sizeof(duk_uint8_t)) + \\\n\t\t\tDUK_HOBJECT_E_FLAG_PADDING(DUK_HOBJECT_GET_ESIZE((h))) + \\\n\t\t\tDUK_HOBJECT_GET_ASIZE((h)) * sizeof(duk_tval) \\\n\t))\n#define DUK_HOBJECT_P_COMPUTE_SIZE(n_ent,n_arr,n_hash) \\\n\t( \\\n\t\t(n_ent) * (sizeof(duk_hstring *) + sizeof(duk_propvalue) + sizeof(duk_uint8_t)) + \\\n\t\tDUK_HOBJECT_E_FLAG_PADDING((n_ent)) + \\\n\t\t(n_arr) * sizeof(duk_tval) + \\\n\t\t(n_hash) * sizeof(duk_uint32_t) \\\n\t)\n#define DUK_HOBJECT_P_SET_REALLOC_PTRS(p_base,set_e_k,set_e_pv,set_e_f,set_a,set_h,n_ent,n_arr,n_hash)  do { \\\n\t\t(set_e_pv) = (duk_propvalue *) (void *) (p_base); \\\n\t\t(set_e_k) = (duk_hstring **) (void *) ((set_e_pv) + (n_ent)); \\\n\t\t(set_e_f) = (duk_uint8_t *) (void *) ((set_e_k) + (n_ent)); \\\n\t\t(set_a) = (duk_tval *) (void *) (((duk_uint8_t *) (set_e_f)) + \\\n\t\t                                 sizeof(duk_uint8_t) * (n_ent) + \\\n\t\t                                 DUK_HOBJECT_E_FLAG_PADDING((n_ent))); \\\n\t\t(set_h) = (duk_uint32_t *) (void *) ((set_a) + (n_arr)); \\\n\t} while (0)\n#elif defined(DUK_USE_HOBJECT_LAYOUT_3)\n/* LAYOUT 3 */\n#define DUK_HOBJECT_E_GET_KEY_BASE(heap,h) \\\n\t((duk_hstring **) (void *) ( \\\n\t\tDUK_HOBJECT_GET_PROPS((heap), (h)) + \\\n\t\t\tDUK_HOBJECT_GET_ESIZE((h)) * sizeof(duk_propvalue) + \\\n\t\t\tDUK_HOBJECT_GET_ASIZE((h)) * sizeof(duk_tval) \\\n\t))\n#define DUK_HOBJECT_E_GET_VALUE_BASE(heap,h) \\\n\t((duk_propvalue *) (void *) ( \\\n\t\tDUK_HOBJECT_GET_PROPS((heap), (h)) \\\n\t))\n#define DUK_HOBJECT_E_GET_FLAGS_BASE(heap,h) \\\n\t((duk_uint8_t *) (void *) ( \\\n\t\tDUK_HOBJECT_GET_PROPS((heap), (h)) + \\\n\t\t\tDUK_HOBJECT_GET_ESIZE((h)) * (sizeof(duk_propvalue) + sizeof(duk_hstring *)) + \\\n\t\t\tDUK_HOBJECT_GET_ASIZE((h)) * sizeof(duk_tval) + \\\n\t\t\tDUK_HOBJECT_GET_HSIZE((h)) * sizeof(duk_uint32_t) \\\n\t))\n#define DUK_HOBJECT_A_GET_BASE(heap,h) \\\n\t((duk_tval *) (void *) ( \\\n\t\tDUK_HOBJECT_GET_PROPS((heap), (h)) + \\\n\t\t\tDUK_HOBJECT_GET_ESIZE((h)) * sizeof(duk_propvalue) \\\n\t))\n#define DUK_HOBJECT_H_GET_BASE(heap,h) \\\n\t((duk_uint32_t *) (void *) ( \\\n\t\tDUK_HOBJECT_GET_PROPS((heap), (h)) + \\\n\t\t\tDUK_HOBJECT_GET_ESIZE((h)) * (sizeof(duk_propvalue) + sizeof(duk_hstring *)) + \\\n\t\t\tDUK_HOBJECT_GET_ASIZE((h)) * sizeof(duk_tval) \\\n\t))\n#define DUK_HOBJECT_P_COMPUTE_SIZE(n_ent,n_arr,n_hash) \\\n\t( \\\n\t\t(n_ent) * (sizeof(duk_propvalue) + sizeof(duk_hstring *) + sizeof(duk_uint8_t)) + \\\n\t\t(n_arr) * sizeof(duk_tval) + \\\n\t\t(n_hash) * sizeof(duk_uint32_t) \\\n\t)\n#define DUK_HOBJECT_P_SET_REALLOC_PTRS(p_base,set_e_k,set_e_pv,set_e_f,set_a,set_h,n_ent,n_arr,n_hash)  do { \\\n\t\t(set_e_pv) = (duk_propvalue *) (void *) (p_base); \\\n\t\t(set_a) = (duk_tval *) (void *) ((set_e_pv) + (n_ent)); \\\n\t\t(set_e_k) = (duk_hstring **) (void *) ((set_a) + (n_arr)); \\\n\t\t(set_h) = (duk_uint32_t *) (void *) ((set_e_k) + (n_ent)); \\\n\t\t(set_e_f) = (duk_uint8_t *) (void *) ((set_h) + (n_hash)); \\\n\t} while (0)\n#else\n#error invalid hobject layout defines\n#endif  /* hobject property layout */\n\n#define DUK_HOBJECT_P_ALLOC_SIZE(h) \\\n\tDUK_HOBJECT_P_COMPUTE_SIZE(DUK_HOBJECT_GET_ESIZE((h)), DUK_HOBJECT_GET_ASIZE((h)), DUK_HOBJECT_GET_HSIZE((h)))\n\n#define DUK_HOBJECT_E_GET_KEY(heap,h,i)              (DUK_HOBJECT_E_GET_KEY_BASE((heap), (h))[(i)])\n#define DUK_HOBJECT_E_GET_KEY_PTR(heap,h,i)          (&DUK_HOBJECT_E_GET_KEY_BASE((heap), (h))[(i)])\n#define DUK_HOBJECT_E_GET_VALUE(heap,h,i)            (DUK_HOBJECT_E_GET_VALUE_BASE((heap), (h))[(i)])\n#define DUK_HOBJECT_E_GET_VALUE_PTR(heap,h,i)        (&DUK_HOBJECT_E_GET_VALUE_BASE((heap), (h))[(i)])\n#define DUK_HOBJECT_E_GET_VALUE_TVAL(heap,h,i)       (DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).v)\n#define DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(heap,h,i)   (&DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).v)\n#define DUK_HOBJECT_E_GET_VALUE_GETTER(heap,h,i)     (DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).a.get)\n#define DUK_HOBJECT_E_GET_VALUE_GETTER_PTR(heap,h,i) (&DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).a.get)\n#define DUK_HOBJECT_E_GET_VALUE_SETTER(heap,h,i)     (DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).a.set)\n#define DUK_HOBJECT_E_GET_VALUE_SETTER_PTR(heap,h,i) (&DUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).a.set)\n#define DUK_HOBJECT_E_GET_FLAGS(heap,h,i)            (DUK_HOBJECT_E_GET_FLAGS_BASE((heap), (h))[(i)])\n#define DUK_HOBJECT_E_GET_FLAGS_PTR(heap,h,i)        (&DUK_HOBJECT_E_GET_FLAGS_BASE((heap), (h))[(i)])\n#define DUK_HOBJECT_A_GET_VALUE(heap,h,i)            (DUK_HOBJECT_A_GET_BASE((heap), (h))[(i)])\n#define DUK_HOBJECT_A_GET_VALUE_PTR(heap,h,i)        (&DUK_HOBJECT_A_GET_BASE((heap), (h))[(i)])\n#define DUK_HOBJECT_H_GET_INDEX(heap,h,i)            (DUK_HOBJECT_H_GET_BASE((heap), (h))[(i)])\n#define DUK_HOBJECT_H_GET_INDEX_PTR(heap,h,i)        (&DUK_HOBJECT_H_GET_BASE((heap), (h))[(i)])\n\n#define DUK_HOBJECT_E_SET_KEY(heap,h,i,k)  do { \\\n\t\tDUK_HOBJECT_E_GET_KEY((heap), (h), (i)) = (k); \\\n\t} while (0)\n#define DUK_HOBJECT_E_SET_VALUE(heap,h,i,v)  do { \\\n\t\tDUK_HOBJECT_E_GET_VALUE((heap), (h), (i)) = (v); \\\n\t} while (0)\n#define DUK_HOBJECT_E_SET_VALUE_TVAL(heap,h,i,v)  do { \\\n\t\tDUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).v = (v); \\\n\t} while (0)\n#define DUK_HOBJECT_E_SET_VALUE_GETTER(heap,h,i,v)  do { \\\n\t\tDUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).a.get = (v); \\\n\t} while (0)\n#define DUK_HOBJECT_E_SET_VALUE_SETTER(heap,h,i,v)  do { \\\n\t\tDUK_HOBJECT_E_GET_VALUE((heap), (h), (i)).a.set = (v); \\\n\t} while (0)\n#define DUK_HOBJECT_E_SET_FLAGS(heap,h,i,f)  do { \\\n\t\tDUK_HOBJECT_E_GET_FLAGS((heap), (h), (i)) = (duk_uint8_t) (f); \\\n\t} while (0)\n#define DUK_HOBJECT_A_SET_VALUE(heap,h,i,v)  do { \\\n\t\tDUK_HOBJECT_A_GET_VALUE((heap), (h), (i)) = (v); \\\n\t} while (0)\n#define DUK_HOBJECT_A_SET_VALUE_TVAL(heap,h,i,v) \\\n\tDUK_HOBJECT_A_SET_VALUE((heap), (h), (i), (v))  /* alias for above */\n#define DUK_HOBJECT_H_SET_INDEX(heap,h,i,v)  do { \\\n\t\tDUK_HOBJECT_H_GET_INDEX((heap), (h), (i)) = (v); \\\n\t} while (0)\n\n#define DUK_HOBJECT_E_SET_FLAG_BITS(heap,h,i,mask)  do { \\\n\t\tDUK_HOBJECT_E_GET_FLAGS_BASE((heap), (h))[(i)] |= (mask); \\\n\t} while (0)\n\n#define DUK_HOBJECT_E_CLEAR_FLAG_BITS(heap,h,i,mask)  do { \\\n\t\tDUK_HOBJECT_E_GET_FLAGS_BASE((heap), (h))[(i)] &= ~(mask); \\\n\t} while (0)\n\n#define DUK_HOBJECT_E_SLOT_IS_WRITABLE(heap,h,i)     ((DUK_HOBJECT_E_GET_FLAGS((heap), (h), (i)) & DUK_PROPDESC_FLAG_WRITABLE) != 0)\n#define DUK_HOBJECT_E_SLOT_IS_ENUMERABLE(heap,h,i)   ((DUK_HOBJECT_E_GET_FLAGS((heap), (h), (i)) & DUK_PROPDESC_FLAG_ENUMERABLE) != 0)\n#define DUK_HOBJECT_E_SLOT_IS_CONFIGURABLE(heap,h,i) ((DUK_HOBJECT_E_GET_FLAGS((heap), (h), (i)) & DUK_PROPDESC_FLAG_CONFIGURABLE) != 0)\n#define DUK_HOBJECT_E_SLOT_IS_ACCESSOR(heap,h,i)     ((DUK_HOBJECT_E_GET_FLAGS((heap), (h), (i)) & DUK_PROPDESC_FLAG_ACCESSOR) != 0)\n\n#define DUK_HOBJECT_E_SLOT_SET_WRITABLE(heap,h,i)        DUK_HOBJECT_E_SET_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_WRITABLE)\n#define DUK_HOBJECT_E_SLOT_SET_ENUMERABLE(heap,h,i)      DUK_HOBJECT_E_SET_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_ENUMERABLE)\n#define DUK_HOBJECT_E_SLOT_SET_CONFIGURABLE(heap,h,i)    DUK_HOBJECT_E_SET_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_CONFIGURABLE)\n#define DUK_HOBJECT_E_SLOT_SET_ACCESSOR(heap,h,i)        DUK_HOBJECT_E_SET_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_ACCESSOR)\n\n#define DUK_HOBJECT_E_SLOT_CLEAR_WRITABLE(heap,h,i)      DUK_HOBJECT_E_CLEAR_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_WRITABLE)\n#define DUK_HOBJECT_E_SLOT_CLEAR_ENUMERABLE(heap,h,i)    DUK_HOBJECT_E_CLEAR_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_ENUMERABLE)\n#define DUK_HOBJECT_E_SLOT_CLEAR_CONFIGURABLE(heap,h,i)  DUK_HOBJECT_E_CLEAR_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_CONFIGURABLE)\n#define DUK_HOBJECT_E_SLOT_CLEAR_ACCESSOR(heap,h,i)      DUK_HOBJECT_E_CLEAR_FLAG_BITS((heap), (h), (i),DUK_PROPDESC_FLAG_ACCESSOR)\n\n#define DUK_PROPDESC_IS_WRITABLE(p)             (((p)->flags & DUK_PROPDESC_FLAG_WRITABLE) != 0)\n#define DUK_PROPDESC_IS_ENUMERABLE(p)           (((p)->flags & DUK_PROPDESC_FLAG_ENUMERABLE) != 0)\n#define DUK_PROPDESC_IS_CONFIGURABLE(p)         (((p)->flags & DUK_PROPDESC_FLAG_CONFIGURABLE) != 0)\n#define DUK_PROPDESC_IS_ACCESSOR(p)             (((p)->flags & DUK_PROPDESC_FLAG_ACCESSOR) != 0)\n\n#define DUK_HOBJECT_HASHIDX_UNUSED              0xffffffffUL\n#define DUK_HOBJECT_HASHIDX_DELETED             0xfffffffeUL\n\n/*\n *  Macros for accessing size fields\n */\n\n#if defined(DUK_USE_OBJSIZES16)\n#define DUK_HOBJECT_GET_ESIZE(h) ((h)->e_size16)\n#define DUK_HOBJECT_SET_ESIZE(h,v) do { (h)->e_size16 = (v); } while (0)\n#define DUK_HOBJECT_GET_ENEXT(h) ((h)->e_next16)\n#define DUK_HOBJECT_SET_ENEXT(h,v) do { (h)->e_next16 = (v); } while (0)\n#define DUK_HOBJECT_POSTINC_ENEXT(h) ((h)->e_next16++)\n#define DUK_HOBJECT_GET_ASIZE(h) ((h)->a_size16)\n#define DUK_HOBJECT_SET_ASIZE(h,v) do { (h)->a_size16 = (v); } while (0)\n#if defined(DUK_USE_HOBJECT_HASH_PART)\n#define DUK_HOBJECT_GET_HSIZE(h) ((h)->h_size16)\n#define DUK_HOBJECT_SET_HSIZE(h,v) do { (h)->h_size16 = (v); } while (0)\n#else\n#define DUK_HOBJECT_GET_HSIZE(h) 0\n#define DUK_HOBJECT_SET_HSIZE(h,v) do { DUK_ASSERT((v) == 0); } while (0)\n#endif\n#else\n#define DUK_HOBJECT_GET_ESIZE(h) ((h)->e_size)\n#define DUK_HOBJECT_SET_ESIZE(h,v) do { (h)->e_size = (v); } while (0)\n#define DUK_HOBJECT_GET_ENEXT(h) ((h)->e_next)\n#define DUK_HOBJECT_SET_ENEXT(h,v) do { (h)->e_next = (v); } while (0)\n#define DUK_HOBJECT_POSTINC_ENEXT(h) ((h)->e_next++)\n#define DUK_HOBJECT_GET_ASIZE(h) ((h)->a_size)\n#define DUK_HOBJECT_SET_ASIZE(h,v) do { (h)->a_size = (v); } while (0)\n#if defined(DUK_USE_HOBJECT_HASH_PART)\n#define DUK_HOBJECT_GET_HSIZE(h) ((h)->h_size)\n#define DUK_HOBJECT_SET_HSIZE(h,v) do { (h)->h_size = (v); } while (0)\n#else\n#define DUK_HOBJECT_GET_HSIZE(h) 0\n#define DUK_HOBJECT_SET_HSIZE(h,v) do { DUK_ASSERT((v) == 0); } while (0)\n#endif\n#endif\n\n/*\n *  Misc\n */\n\n/* Maximum prototype traversal depth.  Sanity limit which handles e.g.\n * prototype loops (even complex ones like 1->2->3->4->2->3->4->2->3->4).\n */\n#define DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY      10000L\n\n/* Maximum traversal depth for \"bound function\" chains. */\n#define DUK_HOBJECT_BOUND_CHAIN_SANITY          10000L\n\n/*\n *  Ecmascript [[Class]]\n */\n\n/* range check not necessary because all 4-bit values are mapped */\n#define DUK_HOBJECT_CLASS_NUMBER_TO_STRIDX(n)  duk_class_number_to_stridx[(n)]\n\n#define DUK_HOBJECT_GET_CLASS_STRING(heap,h)          \\\n\tDUK_HEAP_GET_STRING( \\\n\t\t(heap), \\\n\t\tDUK_HOBJECT_CLASS_NUMBER_TO_STRIDX(DUK_HOBJECT_GET_CLASS_NUMBER((h))) \\\n\t)\n\n/*\n *  Macros for property handling\n */\n\n#if defined(DUK_USE_HEAPPTR16)\n#define DUK_HOBJECT_GET_PROTOTYPE(heap,h) \\\n\t((duk_hobject *) DUK_USE_HEAPPTR_DEC16((heap)->heap_udata, (h)->prototype16))\n#define DUK_HOBJECT_SET_PROTOTYPE(heap,h,x) do { \\\n\t\t(h)->prototype16 = DUK_USE_HEAPPTR_ENC16((heap)->heap_udata, (void *) (x)); \\\n\t} while (0)\n#else\n#define DUK_HOBJECT_GET_PROTOTYPE(heap,h) \\\n\t((h)->prototype)\n#define DUK_HOBJECT_SET_PROTOTYPE(heap,h,x) do { \\\n\t\t(h)->prototype = (x); \\\n\t} while (0)\n#endif\n\n/* note: this updates refcounts */\n#define DUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr,h,p)       duk_hobject_set_prototype_updref((thr), (h), (p))\n\n/*\n *  Finalizer check\n */\n\n#if defined(DUK_USE_HEAPPTR16)\n#define DUK_HOBJECT_HAS_FINALIZER_FAST(heap,h) duk_hobject_has_finalizer_fast_raw((heap), (h))\n#else\n#define DUK_HOBJECT_HAS_FINALIZER_FAST(heap,h) duk_hobject_has_finalizer_fast_raw((h))\n#endif\n\n/*\n *  Resizing and hash behavior\n */\n\n/* Sanity limit on max number of properties (allocated, not necessarily used).\n * This is somewhat arbitrary, but if we're close to 2**32 properties some\n * algorithms will fail (e.g. hash size selection, next prime selection).\n * Also, we use negative array/entry table indices to indicate 'not found',\n * so anything above 0x80000000 will cause trouble now.\n */\n#if defined(DUK_USE_OBJSIZES16)\n#define DUK_HOBJECT_MAX_PROPERTIES       0x0000ffffUL\n#else\n#define DUK_HOBJECT_MAX_PROPERTIES       0x3fffffffUL   /* 2**30-1 ~= 1G properties */\n#endif\n\n/* internal align target for props allocation, must be 2*n for some n */\n#if (DUK_USE_ALIGN_BY == 4)\n#define DUK_HOBJECT_ALIGN_TARGET         4\n#elif (DUK_USE_ALIGN_BY == 8)\n#define DUK_HOBJECT_ALIGN_TARGET         8\n#elif (DUK_USE_ALIGN_BY == 1)\n#define DUK_HOBJECT_ALIGN_TARGET         1\n#else\n#error invalid DUK_USE_ALIGN_BY\n#endif\n\n/*\n *  PC-to-line constants\n */\n\n#define DUK_PC2LINE_SKIP    64\n\n/* maximum length for a SKIP-1 diffstream: 35 bits per entry, rounded up to bytes */\n#define DUK_PC2LINE_MAX_DIFF_LENGTH    (((DUK_PC2LINE_SKIP - 1) * 35 + 7) / 8)\n\n/*\n *  Struct defs\n */\n\nstruct duk_propaccessor {\n\tduk_hobject *get;\n\tduk_hobject *set;\n};\n\nunion duk_propvalue {\n\t/* The get/set pointers could be 16-bit pointer compressed but it\n\t * would make no difference on 32-bit platforms because duk_tval is\n\t * 8 bytes or more anyway.\n\t */\n\tduk_tval v;\n\tduk_propaccessor a;\n};\n\nstruct duk_propdesc {\n\t/* read-only values 'lifted' for ease of use */\n\tduk_small_uint_t flags;\n\tduk_hobject *get;\n\tduk_hobject *set;\n\n\t/* for updating (all are set to < 0 for virtual properties) */\n\tduk_int_t e_idx;  /* prop index in 'entry part', < 0 if not there */\n\tduk_int_t h_idx;  /* prop index in 'hash part', < 0 if not there */\n\tduk_int_t a_idx;  /* prop index in 'array part', < 0 if not there */\n};\n\nstruct duk_hobject {\n\tduk_heaphdr hdr;\n\n\t/*\n\t *  'props' contains {key,value,flags} entries, optional array entries, and\n\t *  an optional hash lookup table for non-array entries in a single 'sliced'\n\t *  allocation.  There are several layout options, which differ slightly in\n\t *  generated code size/speed and alignment/padding; duk_features.h selects\n\t *  the layout used.\n\t *\n\t *  Layout 1 (DUK_USE_HOBJECT_LAYOUT_1):\n\t *\n\t *    e_size * sizeof(duk_hstring *)         bytes of   entry keys (e_next gc reachable)\n\t *    e_size * sizeof(duk_propvalue)         bytes of   entry values (e_next gc reachable)\n\t *    e_size * sizeof(duk_uint8_t)           bytes of   entry flags (e_next gc reachable)\n\t *    a_size * sizeof(duk_tval)              bytes of   (opt) array values (plain only) (all gc reachable)\n\t *    h_size * sizeof(duk_uint32_t)          bytes of   (opt) hash indexes to entries (e_size),\n\t *                                                      0xffffffffUL = unused, 0xfffffffeUL = deleted\n\t *\n\t *  Layout 2 (DUK_USE_HOBJECT_LAYOUT_2):\n\t *\n\t *    e_size * sizeof(duk_propvalue)         bytes of   entry values (e_next gc reachable)\n\t *    e_size * sizeof(duk_hstring *)         bytes of   entry keys (e_next gc reachable)\n\t *    e_size * sizeof(duk_uint8_t) + pad     bytes of   entry flags (e_next gc reachable)\n\t *    a_size * sizeof(duk_tval)              bytes of   (opt) array values (plain only) (all gc reachable)\n\t *    h_size * sizeof(duk_uint32_t)          bytes of   (opt) hash indexes to entries (e_size),\n\t *                                                      0xffffffffUL = unused, 0xfffffffeUL = deleted\n\t *\n\t *  Layout 3 (DUK_USE_HOBJECT_LAYOUT_3):\n\t *\n\t *    e_size * sizeof(duk_propvalue)         bytes of   entry values (e_next gc reachable)\n\t *    a_size * sizeof(duk_tval)              bytes of   (opt) array values (plain only) (all gc reachable)\n\t *    e_size * sizeof(duk_hstring *)         bytes of   entry keys (e_next gc reachable)\n\t *    h_size * sizeof(duk_uint32_t)          bytes of   (opt) hash indexes to entries (e_size),\n\t *                                                      0xffffffffUL = unused, 0xfffffffeUL = deleted\n\t *    e_size * sizeof(duk_uint8_t)           bytes of   entry flags (e_next gc reachable)\n\t *\n\t *  In layout 1, the 'e_next' count is rounded to 4 or 8 on platforms\n\t *  requiring 4 or 8 byte alignment.  This ensures proper alignment\n\t *  for the entries, at the cost of memory footprint.  However, it's\n\t *  probably preferable to use another layout on such platforms instead.\n\t *\n\t *  In layout 2, the key and value parts are swapped to avoid padding\n\t *  the key array on platforms requiring alignment by 8.  The flags part\n\t *  is padded to get alignment for array entries.  The 'e_next' count does\n\t *  not need to be rounded as in layout 1.\n\t *\n\t *  In layout 3, entry values and array values are always aligned properly,\n\t *  and assuming pointers are at most 8 bytes, so are the entry keys.  Hash\n\t *  indices will be properly aligned (assuming pointers are at least 4 bytes).\n\t *  Finally, flags don't need additional alignment.  This layout provides\n\t *  compact allocations without padding (even on platforms with alignment\n\t *  requirements) at the cost of a bit slower lookups.\n\t *\n\t *  Objects with few keys don't have a hash index; keys are looked up linearly,\n\t *  which is cache efficient because the keys are consecutive.  Larger objects\n\t *  have a hash index part which contains integer indexes to the entries part.\n\t *\n\t *  A single allocation reduces memory allocation overhead but requires more\n\t *  work when any part needs to be resized.  A sliced allocation for entries\n\t *  makes linear key matching faster on most platforms (more locality) and\n\t *  skimps on flags size (which would be followed by 3 bytes of padding in\n\t *  most architectures if entries were placed in a struct).\n\t *\n\t *  'props' also contains internal properties distinguished with a non-BMP\n\t *  prefix.  Often used properties should be placed early in 'props' whenever\n\t *  possible to make accessing them as fast a possible.\n\t */\n\n#if defined(DUK_USE_HEAPPTR16)\n\t/* Located in duk_heaphdr h_extra16.  Subclasses of duk_hobject (like\n\t * duk_hcompfunc) are not free to use h_extra16 for this reason.\n\t */\n#else\n\tduk_uint8_t *props;\n#endif\n\n\t/* prototype: the only internal property lifted outside 'e' as it is so central */\n#if defined(DUK_USE_HEAPPTR16)\n\tduk_uint16_t prototype16;\n#else\n\tduk_hobject *prototype;\n#endif\n\n#if defined(DUK_USE_OBJSIZES16)\n\tduk_uint16_t e_size16;\n\tduk_uint16_t e_next16;\n\tduk_uint16_t a_size16;\n#if defined(DUK_USE_HOBJECT_HASH_PART)\n\tduk_uint16_t h_size16;\n#endif\n#else\n\tduk_uint32_t e_size;  /* entry part size */\n\tduk_uint32_t e_next;  /* index for next new key ([0,e_next[ are gc reachable) */\n\tduk_uint32_t a_size;  /* array part size (entirely gc reachable) */\n#if defined(DUK_USE_HOBJECT_HASH_PART)\n\tduk_uint32_t h_size;  /* hash part size or 0 if unused */\n#endif\n#endif\n};\n\n/*\n *  Exposed data\n */\n\n#if !defined(DUK_SINGLE_FILE)\nDUK_INTERNAL_DECL duk_uint8_t duk_class_number_to_stridx[32];\n#endif  /* !DUK_SINGLE_FILE */\n\n/*\n *  Prototypes\n */\n\n/* alloc and init */\nDUK_INTERNAL_DECL duk_hobject *duk_hobject_alloc_unchecked(duk_heap *heap, duk_uint_t hobject_flags);\nDUK_INTERNAL_DECL duk_hobject *duk_hobject_alloc(duk_hthread *thr, duk_uint_t hobject_flags);\nDUK_INTERNAL_DECL duk_harray *duk_harray_alloc(duk_hthread *thr, duk_uint_t hobject_flags);\nDUK_INTERNAL_DECL duk_hcompfunc *duk_hcompfunc_alloc(duk_hthread *thr, duk_uint_t hobject_flags);\nDUK_INTERNAL_DECL duk_hnatfunc *duk_hnatfunc_alloc(duk_hthread *thr, duk_uint_t hobject_flags);\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL_DECL duk_hbufobj *duk_hbufobj_alloc(duk_hthread *thr, duk_uint_t hobject_flags);\n#endif\nDUK_INTERNAL_DECL duk_hthread *duk_hthread_alloc_unchecked(duk_heap *heap, duk_uint_t hobject_flags);\nDUK_INTERNAL_DECL duk_hthread *duk_hthread_alloc(duk_hthread *thr, duk_uint_t hobject_flags);\nDUK_INTERNAL_DECL duk_hdecenv *duk_hdecenv_alloc(duk_hthread *thr, duk_uint_t hobject_flags);\nDUK_INTERNAL_DECL duk_hobjenv *duk_hobjenv_alloc(duk_hthread *thr, duk_uint_t hobject_flags);\n\n/* resize */\nDUK_INTERNAL_DECL void duk_hobject_realloc_props(duk_hthread *thr,\n                                                 duk_hobject *obj,\n                                                 duk_uint32_t new_e_size,\n                                                 duk_uint32_t new_a_size,\n                                                 duk_uint32_t new_h_size,\n                                                 duk_bool_t abandon_array);\n\n/* low-level property functions */\nDUK_INTERNAL_DECL void duk_hobject_find_existing_entry(duk_heap *heap, duk_hobject *obj, duk_hstring *key, duk_int_t *e_idx, duk_int_t *h_idx);\nDUK_INTERNAL_DECL duk_tval *duk_hobject_find_existing_entry_tval_ptr(duk_heap *heap, duk_hobject *obj, duk_hstring *key);\nDUK_INTERNAL_DECL duk_tval *duk_hobject_find_existing_entry_tval_ptr_and_attrs(duk_heap *heap, duk_hobject *obj, duk_hstring *key, duk_int_t *out_attrs);\nDUK_INTERNAL_DECL duk_tval *duk_hobject_find_existing_array_entry_tval_ptr(duk_heap *heap, duk_hobject *obj, duk_uarridx_t i);\nDUK_INTERNAL_DECL duk_bool_t duk_hobject_get_own_propdesc(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *out_desc, duk_small_uint_t flags);\n\n/* XXX: when optimizing for guaranteed property slots, use a guaranteed\n * slot for internal value; this call can then access it directly.\n */\n#define duk_hobject_get_internal_value_tval_ptr(heap,obj) \\\n\tduk_hobject_find_existing_entry_tval_ptr((heap), (obj), DUK_HEAP_STRING_INT_VALUE((heap)))\n\n/* core property functions */\nDUK_INTERNAL_DECL duk_bool_t duk_hobject_getprop(duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key);\nDUK_INTERNAL_DECL duk_bool_t duk_hobject_putprop(duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key, duk_tval *tv_val, duk_bool_t throw_flag);\nDUK_INTERNAL_DECL duk_bool_t duk_hobject_delprop(duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key, duk_bool_t throw_flag);\nDUK_INTERNAL_DECL duk_bool_t duk_hobject_hasprop(duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key);\n\n/* internal property functions */\n#define DUK_DELPROP_FLAG_THROW  (1 << 0)\n#define DUK_DELPROP_FLAG_FORCE  (1 << 1)\nDUK_INTERNAL_DECL duk_bool_t duk_hobject_delprop_raw(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_small_uint_t flags);\nDUK_INTERNAL_DECL duk_bool_t duk_hobject_hasprop_raw(duk_hthread *thr, duk_hobject *obj, duk_hstring *key);\nDUK_INTERNAL_DECL void duk_hobject_define_property_internal(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_small_uint_t flags);\nDUK_INTERNAL_DECL void duk_hobject_define_property_internal_arridx(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t arr_idx, duk_small_uint_t flags);\nDUK_INTERNAL_DECL duk_size_t duk_hobject_get_length(duk_hthread *thr, duk_hobject *obj);\n#if defined(DUK_USE_HEAPPTR16)\nDUK_INTERNAL_DECL duk_bool_t duk_hobject_has_finalizer_fast_raw(duk_heap *heap, duk_hobject *obj);\n#else\nDUK_INTERNAL_DECL duk_bool_t duk_hobject_has_finalizer_fast_raw(duk_hobject *obj);\n#endif\n\n/* helpers for defineProperty() and defineProperties() */\nDUK_INTERNAL_DECL\nvoid duk_hobject_prepare_property_descriptor(duk_context *ctx,\n                                             duk_idx_t idx_in,\n                                             duk_uint_t *out_defprop_flags,\n                                             duk_idx_t *out_idx_value,\n                                             duk_hobject **out_getter,\n                                             duk_hobject **out_setter);\nDUK_INTERNAL_DECL\nduk_bool_t duk_hobject_define_property_helper(duk_context *ctx,\n                                              duk_uint_t defprop_flags,\n                                              duk_hobject *obj,\n                                              duk_hstring *key,\n                                              duk_idx_t idx_value,\n                                              duk_hobject *get,\n                                              duk_hobject *set,\n                                              duk_bool_t throw_flag);\n\n/* Object built-in methods */\nDUK_INTERNAL_DECL void duk_hobject_object_get_own_property_descriptor(duk_context *ctx, duk_idx_t obj_idx);\nDUK_INTERNAL_DECL void duk_hobject_object_seal_freeze_helper(duk_hthread *thr, duk_hobject *obj, duk_bool_t is_freeze);\nDUK_INTERNAL_DECL duk_bool_t duk_hobject_object_is_sealed_frozen_helper(duk_hthread *thr, duk_hobject *obj, duk_bool_t is_frozen);\nDUK_INTERNAL_DECL duk_bool_t duk_hobject_object_ownprop_helper(duk_context *ctx, duk_small_uint_t required_desc_flags);\n\n/* internal properties */\nDUK_INTERNAL_DECL duk_bool_t duk_hobject_get_internal_value(duk_heap *heap, duk_hobject *obj, duk_tval *tv);\nDUK_INTERNAL_DECL duk_hstring *duk_hobject_get_internal_value_string(duk_heap *heap, duk_hobject *obj);\n\n/* hobject management functions */\nDUK_INTERNAL_DECL void duk_hobject_compact_props(duk_hthread *thr, duk_hobject *obj);\n\n/* ES2015 proxy */\n#if defined(DUK_USE_ES6_PROXY)\nDUK_INTERNAL_DECL duk_bool_t duk_hobject_proxy_check(duk_hthread *thr, duk_hobject *obj, duk_hobject **out_target, duk_hobject **out_handler);\nDUK_INTERNAL_DECL duk_hobject *duk_hobject_resolve_proxy_target(duk_hthread *thr, duk_hobject *obj);\n#endif\n\n/* enumeration */\nDUK_INTERNAL_DECL void duk_hobject_enumerator_create(duk_context *ctx, duk_small_uint_t enum_flags);\nDUK_INTERNAL_DECL duk_ret_t duk_hobject_get_enumerated_keys(duk_context *ctx, duk_small_uint_t enum_flags);\nDUK_INTERNAL_DECL duk_bool_t duk_hobject_enumerator_next(duk_context *ctx, duk_bool_t get_value);\n\n/* macros */\nDUK_INTERNAL_DECL void duk_hobject_set_prototype_updref(duk_hthread *thr, duk_hobject *h, duk_hobject *p);\n\n/* pc2line */\n#if defined(DUK_USE_PC2LINE)\nDUK_INTERNAL_DECL void duk_hobject_pc2line_pack(duk_hthread *thr, duk_compiler_instr *instrs, duk_uint_fast32_t length);\nDUK_INTERNAL_DECL duk_uint_fast32_t duk_hobject_pc2line_query(duk_context *ctx, duk_idx_t idx_func, duk_uint_fast32_t pc);\n#endif\n\n/* misc */\nDUK_INTERNAL_DECL duk_bool_t duk_hobject_prototype_chain_contains(duk_hthread *thr, duk_hobject *h, duk_hobject *p, duk_bool_t ignore_loop);\n\n#if !defined(DUK_USE_OBJECT_BUILTIN)\n/* These declarations are needed when related built-in is disabled and\n * genbuiltins.py won't automatically emit the declerations.\n */\nDUK_INTERNAL_DECL duk_ret_t duk_bi_object_prototype_to_string(duk_context *ctx);\nDUK_INTERNAL_DECL duk_ret_t duk_bi_function_prototype(duk_context *ctx);\n#endif\n\n#endif  /* DUK_HOBJECT_H_INCLUDED */\n/* #include duk_hcompfunc.h */\n/*\n *  Heap compiled function (Ecmascript function) representation.\n *\n *  There is a single data buffer containing the Ecmascript function's\n *  bytecode, constants, and inner functions.\n */\n\n#if !defined(DUK_HCOMPFUNC_H_INCLUDED)\n#define DUK_HCOMPFUNC_H_INCLUDED\n\n/*\n *  Field accessor macros\n */\n\n/* XXX: casts could be improved, especially for GET/SET DATA */\n\n#if defined(DUK_USE_HEAPPTR16)\n#define DUK_HCOMPFUNC_GET_DATA(heap,h) \\\n\t((duk_hbuffer_fixed *) (void *) DUK_USE_HEAPPTR_DEC16((heap)->heap_udata, (h)->data16))\n#define DUK_HCOMPFUNC_SET_DATA(heap,h,v) do { \\\n\t\t(h)->data16 = DUK_USE_HEAPPTR_ENC16((heap)->heap_udata, (void *) (v)); \\\n\t} while (0)\n#define DUK_HCOMPFUNC_GET_FUNCS(heap,h)  \\\n\t((duk_hobject **) (void *) (DUK_USE_HEAPPTR_DEC16((heap)->heap_udata, (h)->funcs16)))\n#define DUK_HCOMPFUNC_SET_FUNCS(heap,h,v)  do { \\\n\t\t(h)->funcs16 = DUK_USE_HEAPPTR_ENC16((heap)->heap_udata, (void *) (v)); \\\n\t} while (0)\n#define DUK_HCOMPFUNC_GET_BYTECODE(heap,h)  \\\n\t((duk_instr_t *) (void *) (DUK_USE_HEAPPTR_DEC16((heap)->heap_udata, (h)->bytecode16)))\n#define DUK_HCOMPFUNC_SET_BYTECODE(heap,h,v)  do { \\\n\t\t(h)->bytecode16 = DUK_USE_HEAPPTR_ENC16((heap)->heap_udata, (void *) (v)); \\\n\t} while (0)\n#define DUK_HCOMPFUNC_GET_LEXENV(heap,h)  \\\n\t((duk_hobject *) (void *) (DUK_USE_HEAPPTR_DEC16((heap)->heap_udata, (h)->lex_env16)))\n#define DUK_HCOMPFUNC_SET_LEXENV(heap,h,v)  do { \\\n\t\t(h)->lex_env16 = DUK_USE_HEAPPTR_ENC16((heap)->heap_udata, (void *) (v)); \\\n\t} while (0)\n#define DUK_HCOMPFUNC_GET_VARENV(heap,h)  \\\n\t((duk_hobject *) (void *) (DUK_USE_HEAPPTR_DEC16((heap)->heap_udata, (h)->var_env16)))\n#define DUK_HCOMPFUNC_SET_VARENV(heap,h,v)  do { \\\n\t\t(h)->var_env16 = DUK_USE_HEAPPTR_ENC16((heap)->heap_udata, (void *) (v)); \\\n\t} while (0)\n#else\n#define DUK_HCOMPFUNC_GET_DATA(heap,h)  ((duk_hbuffer_fixed *) (void *) (h)->data)\n#define DUK_HCOMPFUNC_SET_DATA(heap,h,v) do { \\\n\t\t(h)->data = (duk_hbuffer *) (v); \\\n\t} while (0)\n#define DUK_HCOMPFUNC_GET_FUNCS(heap,h)  ((h)->funcs)\n#define DUK_HCOMPFUNC_SET_FUNCS(heap,h,v)  do { \\\n\t\t(h)->funcs = (v); \\\n\t} while (0)\n#define DUK_HCOMPFUNC_GET_BYTECODE(heap,h)  ((h)->bytecode)\n#define DUK_HCOMPFUNC_SET_BYTECODE(heap,h,v)  do { \\\n\t\t(h)->bytecode = (v); \\\n\t} while (0)\n#define DUK_HCOMPFUNC_GET_LEXENV(heap,h)  ((h)->lex_env)\n#define DUK_HCOMPFUNC_SET_LEXENV(heap,h,v)  do { \\\n\t\t(h)->lex_env = (v); \\\n\t} while (0)\n#define DUK_HCOMPFUNC_GET_VARENV(heap,h)  ((h)->var_env)\n#define DUK_HCOMPFUNC_SET_VARENV(heap,h,v)  do { \\\n\t\t(h)->var_env = (v); \\\n\t} while (0)\n#endif\n\n/*\n *  Accessor macros for function specific data areas\n */\n\n/* Note: assumes 'data' is always a fixed buffer */\n#define DUK_HCOMPFUNC_GET_BUFFER_BASE(heap,h)  \\\n\tDUK_HBUFFER_FIXED_GET_DATA_PTR((heap), DUK_HCOMPFUNC_GET_DATA((heap), (h)))\n\n#define DUK_HCOMPFUNC_GET_CONSTS_BASE(heap,h)  \\\n\t((duk_tval *) (void *) DUK_HCOMPFUNC_GET_BUFFER_BASE((heap), (h)))\n\n#define DUK_HCOMPFUNC_GET_FUNCS_BASE(heap,h)  \\\n\tDUK_HCOMPFUNC_GET_FUNCS((heap), (h))\n\n#define DUK_HCOMPFUNC_GET_CODE_BASE(heap,h)  \\\n\tDUK_HCOMPFUNC_GET_BYTECODE((heap), (h))\n\n#define DUK_HCOMPFUNC_GET_CONSTS_END(heap,h)  \\\n\t((duk_tval *) (void *) DUK_HCOMPFUNC_GET_FUNCS((heap), (h)))\n\n#define DUK_HCOMPFUNC_GET_FUNCS_END(heap,h)  \\\n\t((duk_hobject **) (void *) DUK_HCOMPFUNC_GET_BYTECODE((heap), (h)))\n\n/* XXX: double evaluation of DUK_HCOMPFUNC_GET_DATA() */\n#define DUK_HCOMPFUNC_GET_CODE_END(heap,h)  \\\n\t((duk_instr_t *) (void *) (DUK_HBUFFER_FIXED_GET_DATA_PTR((heap), DUK_HCOMPFUNC_GET_DATA((heap), (h))) + \\\n\t                DUK_HBUFFER_GET_SIZE((duk_hbuffer *) DUK_HCOMPFUNC_GET_DATA((heap), h))))\n\n#define DUK_HCOMPFUNC_GET_CONSTS_SIZE(heap,h)  \\\n\t( \\\n\t (duk_size_t) \\\n\t ( \\\n\t   ((const duk_uint8_t *) DUK_HCOMPFUNC_GET_CONSTS_END((heap), (h))) - \\\n\t   ((const duk_uint8_t *) DUK_HCOMPFUNC_GET_CONSTS_BASE((heap), (h))) \\\n\t ) \\\n\t)\n\n#define DUK_HCOMPFUNC_GET_FUNCS_SIZE(heap,h)  \\\n\t( \\\n\t (duk_size_t) \\\n\t ( \\\n\t   ((const duk_uint8_t *) DUK_HCOMPFUNC_GET_FUNCS_END((heap), (h))) - \\\n\t   ((const duk_uint8_t *) DUK_HCOMPFUNC_GET_FUNCS_BASE((heap), (h))) \\\n\t ) \\\n\t)\n\n#define DUK_HCOMPFUNC_GET_CODE_SIZE(heap,h)  \\\n\t( \\\n\t (duk_size_t) \\\n\t ( \\\n\t   ((const duk_uint8_t *) DUK_HCOMPFUNC_GET_CODE_END((heap),(h))) - \\\n\t   ((const duk_uint8_t *) DUK_HCOMPFUNC_GET_CODE_BASE((heap),(h))) \\\n\t ) \\\n\t)\n\n#define DUK_HCOMPFUNC_GET_CONSTS_COUNT(heap,h)  \\\n\t((duk_size_t) (DUK_HCOMPFUNC_GET_CONSTS_SIZE((heap), (h)) / sizeof(duk_tval)))\n\n#define DUK_HCOMPFUNC_GET_FUNCS_COUNT(heap,h)  \\\n\t((duk_size_t) (DUK_HCOMPFUNC_GET_FUNCS_SIZE((heap), (h)) / sizeof(duk_hobject *)))\n\n#define DUK_HCOMPFUNC_GET_CODE_COUNT(heap,h)  \\\n\t((duk_size_t) (DUK_HCOMPFUNC_GET_CODE_SIZE((heap), (h)) / sizeof(duk_instr_t)))\n\n\n/*\n *  Main struct\n */\n\nstruct duk_hcompfunc {\n\t/* shared object part */\n\tduk_hobject obj;\n\n\t/*\n\t *  Pointers to function data area for faster access.  Function\n\t *  data is a buffer shared between all closures of the same\n\t *  \"template\" function.  The data buffer is always fixed (non-\n\t *  dynamic, hence stable), with a layout as follows:\n\t *\n\t *    constants (duk_tval)\n\t *    inner functions (duk_hobject *)\n\t *    bytecode (duk_instr_t)\n\t *\n\t *  Note: bytecode end address can be computed from 'data' buffer\n\t *  size.  It is not strictly necessary functionally, assuming\n\t *  bytecode never jumps outside its allocated area.  However,\n\t *  it's a safety/robustness feature for avoiding the chance of\n\t *  executing random data as bytecode due to a compiler error.\n\t *\n\t *  Note: values in the data buffer must be incref'd (they will\n\t *  be decref'd on release) for every compiledfunction referring\n\t *  to the 'data' element.\n\t */\n\n\t/* Data area, fixed allocation, stable data ptrs. */\n#if defined(DUK_USE_HEAPPTR16)\n\tduk_uint16_t data16;\n#else\n\tduk_hbuffer *data;\n#endif\n\n\t/* No need for constants pointer (= same as data).\n\t *\n\t * When using 16-bit packing alignment to 4 is nice.  'funcs' will be\n\t * 4-byte aligned because 'constants' are duk_tvals.  For now the\n\t * inner function pointers are not compressed, so that 'bytecode' will\n\t * also be 4-byte aligned.\n\t */\n#if defined(DUK_USE_HEAPPTR16)\n\tduk_uint16_t funcs16;\n\tduk_uint16_t bytecode16;\n#else\n\tduk_hobject **funcs;\n\tduk_instr_t *bytecode;\n#endif\n\n\t/* Lexenv: lexical environment of closure, NULL for templates.\n\t * Varenv: variable environment of closure, NULL for templates.\n\t */\n#if defined(DUK_USE_HEAPPTR16)\n\tduk_uint16_t lex_env16;\n\tduk_uint16_t var_env16;\n#else\n\tduk_hobject *lex_env;\n\tduk_hobject *var_env;\n#endif\n\n\t/*\n\t *  'nregs' registers are allocated on function entry, at most 'nargs'\n\t *  are initialized to arguments, and the rest to undefined.  Arguments\n\t *  above 'nregs' are not mapped to registers.  All registers in the\n\t *  active stack range must be initialized because they are GC reachable.\n\t *  'nargs' is needed so that if the function is given more than 'nargs'\n\t *  arguments, the additional arguments do not 'clobber' registers\n\t *  beyond 'nregs' which must be consistently initialized to undefined.\n\t *\n\t *  Usually there is no need to know which registers are mapped to\n\t *  local variables.  Registers may be allocated to variable in any\n\t *  way (even including gaps).  However, a register-variable mapping\n\t *  must be the same for the duration of the function execution and\n\t *  the register cannot be used for anything else.\n\t *\n\t *  When looking up variables by name, the '_Varmap' map is used.\n\t *  When an activation closes, registers mapped to arguments are\n\t *  copied into the environment record based on the same map.  The\n\t *  reverse map (from register to variable) is not currently needed\n\t *  at run time, except for debugging, so it is not maintained.\n\t */\n\n\tduk_uint16_t nregs;                /* regs to allocate */\n\tduk_uint16_t nargs;                /* number of arguments allocated to regs */\n\n\t/*\n\t *  Additional control information is placed into the object itself\n\t *  as internal properties to avoid unnecessary fields for the\n\t *  majority of functions.  The compiler tries to omit internal\n\t *  control fields when possible.\n\t *\n\t *  Function templates:\n\t *\n\t *    {\n\t *      name: \"func\",    // declaration, named function expressions\n\t *      fileName: <debug info for creating nice errors>\n\t *      _Varmap: { \"arg1\": 0, \"arg2\": 1, \"varname\": 2 },\n\t *      _Formals: [ \"arg1\", \"arg2\" ],\n\t *      _Source: \"function func(arg1, arg2) { ... }\",\n\t *      _Pc2line: <debug info for pc-to-line mapping>,\n\t *    }\n\t *\n\t *  Function instances:\n\t *\n\t *    {\n\t *      length: 2,\n\t *      prototype: { constructor: <func> },\n\t *      caller: <thrower>,\n\t *      arguments: <thrower>,\n\t *      name: \"func\",    // declaration, named function expressions\n\t *      fileName: <debug info for creating nice errors>\n\t *      _Varmap: { \"arg1\": 0, \"arg2\": 1, \"varname\": 2 },\n\t *      _Formals: [ \"arg1\", \"arg2\" ],\n\t *      _Source: \"function func(arg1, arg2) { ... }\",\n\t *      _Pc2line: <debug info for pc-to-line mapping>,\n\t *    }\n\t *\n\t *  More detailed description of these properties can be found\n\t *  in the documentation.\n\t */\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\t/* Line number range for function.  Needed during debugging to\n\t * determine active breakpoints.\n\t */\n\tduk_uint32_t start_line;\n\tduk_uint32_t end_line;\n#endif\n};\n\n#endif  /* DUK_HCOMPFUNC_H_INCLUDED */\n/* #include duk_hnatfunc.h */\n/*\n *  Heap native function representation.\n */\n\n#if !defined(DUK_HNATFUNC_H_INCLUDED)\n#define DUK_HNATFUNC_H_INCLUDED\n\n#define DUK_HNATFUNC_NARGS_VARARGS  ((duk_int16_t) -1)\n#define DUK_HNATFUNC_NARGS_MAX      ((duk_int16_t) 0x7fff)\n\nstruct duk_hnatfunc {\n\t/* shared object part */\n\tduk_hobject obj;\n\n\tduk_c_function func;\n\tduk_int16_t nargs;\n\tduk_int16_t magic;\n\n\t/* The 'magic' field allows an opaque 16-bit field to be accessed by the\n\t * Duktape/C function.  This allows, for instance, the same native function\n\t * to be used for a set of very similar functions, with the 'magic' field\n\t * providing the necessary non-argument flags / values to guide the behavior\n\t * of the native function.  The value is signed on purpose: it is easier to\n\t * convert a signed value to unsigned (simply AND with 0xffff) than vice\n\t * versa.\n\t *\n\t * Note: cannot place nargs/magic into the heaphdr flags, because\n\t * duk_hobject takes almost all flags already (and needs the spare).\n\t */\n};\n\n#endif  /* DUK_HNATFUNC_H_INCLUDED */\n/* #include duk_hbufobj.h */\n/*\n *  Heap Buffer object representation.  Used for all Buffer variants.\n */\n\n#if !defined(DUK_HBUFOBJ_H_INCLUDED)\n#define DUK_HBUFOBJ_H_INCLUDED\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n\n/* All element accessors are host endian now (driven by TypedArray spec). */\n#define DUK_HBUFOBJ_ELEM_UINT8           0\n#define DUK_HBUFOBJ_ELEM_UINT8CLAMPED    1\n#define DUK_HBUFOBJ_ELEM_INT8            2\n#define DUK_HBUFOBJ_ELEM_UINT16          3\n#define DUK_HBUFOBJ_ELEM_INT16           4\n#define DUK_HBUFOBJ_ELEM_UINT32          5\n#define DUK_HBUFOBJ_ELEM_INT32           6\n#define DUK_HBUFOBJ_ELEM_FLOAT32         7\n#define DUK_HBUFOBJ_ELEM_FLOAT64         8\n#define DUK_HBUFOBJ_ELEM_MAX             8\n\n#define DUK_ASSERT_HBUFOBJ_VALID(h) do { \\\n\t\tDUK_ASSERT((h) != NULL); \\\n\t\tDUK_ASSERT((h)->shift <= 3); \\\n\t\tDUK_ASSERT((h)->elem_type <= DUK_HBUFOBJ_ELEM_MAX); \\\n\t\tDUK_ASSERT(((h)->shift == 0 && (h)->elem_type == DUK_HBUFOBJ_ELEM_UINT8) || \\\n\t\t           ((h)->shift == 0 && (h)->elem_type == DUK_HBUFOBJ_ELEM_UINT8CLAMPED) || \\\n\t\t           ((h)->shift == 0 && (h)->elem_type == DUK_HBUFOBJ_ELEM_INT8) || \\\n\t\t           ((h)->shift == 1 && (h)->elem_type == DUK_HBUFOBJ_ELEM_UINT16) || \\\n\t\t           ((h)->shift == 1 && (h)->elem_type == DUK_HBUFOBJ_ELEM_INT16) || \\\n\t\t           ((h)->shift == 2 && (h)->elem_type == DUK_HBUFOBJ_ELEM_UINT32) || \\\n\t\t           ((h)->shift == 2 && (h)->elem_type == DUK_HBUFOBJ_ELEM_INT32) || \\\n\t\t           ((h)->shift == 2 && (h)->elem_type == DUK_HBUFOBJ_ELEM_FLOAT32) || \\\n\t\t           ((h)->shift == 3 && (h)->elem_type == DUK_HBUFOBJ_ELEM_FLOAT64)); \\\n\t\tDUK_ASSERT((h)->is_typedarray == 0 || (h)->is_typedarray == 1); \\\n\t\tDUK_ASSERT(DUK_HOBJECT_IS_BUFOBJ((duk_hobject *) (h))); \\\n\t\tif ((h)->buf == NULL) { \\\n\t\t\tDUK_ASSERT((h)->offset == 0); \\\n\t\t\tDUK_ASSERT((h)->length == 0); \\\n\t\t} else { \\\n\t\t\t/* No assertions for offset or length; in particular, \\\n\t\t\t * it's OK for length to be longer than underlying \\\n\t\t\t * buffer.  Just ensure they don't wrap when added. \\\n\t\t\t */ \\\n\t\t\tDUK_ASSERT((h)->offset + (h)->length >= (h)->offset); \\\n\t\t} \\\n\t} while (0)\n\n/* Get the current data pointer (caller must ensure buf != NULL) as a\n * duk_uint8_t ptr.\n */\n#define DUK_HBUFOBJ_GET_SLICE_BASE(heap,h) \\\n\t(DUK_ASSERT_EXPR((h) != NULL), DUK_ASSERT_EXPR((h)->buf != NULL), \\\n\t(((duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR((heap), (h)->buf)) + (h)->offset))\n\n/* True if slice is full, i.e. offset is zero and length covers the entire\n * buffer.  This status may change independently of the duk_hbufobj if\n * the underlying buffer is dynamic and changes without the hbufobj\n * being changed.\n */\n#define DUK_HBUFOBJ_FULL_SLICE(h) \\\n\t(DUK_ASSERT_EXPR((h) != NULL), DUK_ASSERT_EXPR((h)->buf != NULL), \\\n\t((h)->offset == 0 && (h)->length == DUK_HBUFFER_GET_SIZE((h)->buf)))\n\n/* Validate that the whole slice [0,length[ is contained in the underlying\n * buffer.  Caller must ensure 'buf' != NULL.\n */\n#define DUK_HBUFOBJ_VALID_SLICE(h) \\\n\t(DUK_ASSERT_EXPR((h) != NULL), DUK_ASSERT_EXPR((h)->buf != NULL), \\\n\t((h)->offset + (h)->length <= DUK_HBUFFER_GET_SIZE((h)->buf)))\n\n/* Validate byte read/write for virtual 'offset', i.e. check that the\n * offset, taking into account h->offset, is within the underlying\n * buffer size.  This is a safety check which is needed to ensure\n * that even a misconfigured duk_hbufobj never causes memory unsafe\n * behavior (e.g. if an underlying dynamic buffer changes after being\n * setup).  Caller must ensure 'buf' != NULL.\n */\n#define DUK_HBUFOBJ_VALID_BYTEOFFSET_INCL(h,off) \\\n\t(DUK_ASSERT_EXPR((h) != NULL), DUK_ASSERT_EXPR((h)->buf != NULL), \\\n\t((h)->offset + (off) < DUK_HBUFFER_GET_SIZE((h)->buf)))\n\n#define DUK_HBUFOBJ_VALID_BYTEOFFSET_EXCL(h,off) \\\n\t(DUK_ASSERT_EXPR((h) != NULL), DUK_ASSERT_EXPR((h)->buf != NULL), \\\n\t((h)->offset + (off) <= DUK_HBUFFER_GET_SIZE((h)->buf)))\n\n/* Clamp an input byte length (already assumed to be within the nominal\n * duk_hbufobj 'length') to the current dynamic buffer limits to yield\n * a byte length limit that's safe for memory accesses.  This value can\n * be invalidated by any side effect because it may trigger a user\n * callback that resizes the underlying buffer.\n */\n#define DUK_HBUFOBJ_CLAMP_BYTELENGTH(h,len) \\\n\t(DUK_ASSERT_EXPR((h) != NULL), \\\n\tduk_hbufobj_clamp_bytelength((h), (len)))\n\n/* Typed arrays have virtual indices, ArrayBuffer and DataView do not. */\n#define DUK_HBUFOBJ_HAS_VIRTUAL_INDICES(h)  ((h)->is_typedarray)\n\nstruct duk_hbufobj {\n\t/* Shared object part. */\n\tduk_hobject obj;\n\n\t/* Underlying buffer (refcounted), may be NULL. */\n\tduk_hbuffer *buf;\n\n\t/* .buffer reference to an ArrayBuffer, may be NULL. */\n\tduk_hobject *buf_prop;\n\n\t/* Slice and accessor information.\n\t *\n\t * Because the underlying buffer may be dynamic, these may be\n\t * invalidated by the buffer being modified so that both offset\n\t * and length should be validated before every access.  Behavior\n\t * when the underlying buffer has changed doesn't need to be clean:\n\t * virtual 'length' doesn't need to be affected, reads can return\n\t * zero/NaN, and writes can be ignored.\n\t *\n\t * Note that a data pointer cannot be precomputed because 'buf' may\n\t * be dynamic and its pointer unstable.\n\t */\n\n\tduk_uint_t offset;       /* byte offset to buf */\n\tduk_uint_t length;       /* byte index limit for element access, exclusive */\n\tduk_uint8_t shift;       /* element size shift:\n\t                          *   0 = u8/i8\n\t                          *   1 = u16/i16\n\t                          *   2 = u32/i32/float\n\t                          *   3 = double\n\t                          */\n\tduk_uint8_t elem_type;   /* element type */\n\tduk_uint8_t is_typedarray;\n};\n\nDUK_INTERNAL_DECL duk_uint_t duk_hbufobj_clamp_bytelength(duk_hbufobj *h_bufobj, duk_uint_t len);\nDUK_INTERNAL_DECL void duk_hbufobj_push_uint8array_from_plain(duk_hthread *thr, duk_hbuffer *h_buf);\nDUK_INTERNAL_DECL void duk_hbufobj_push_validated_read(duk_context *ctx, duk_hbufobj *h_bufobj, duk_uint8_t *p, duk_small_uint_t elem_size);\nDUK_INTERNAL_DECL void duk_hbufobj_validated_write(duk_context *ctx, duk_hbufobj *h_bufobj, duk_uint8_t *p, duk_small_uint_t elem_size);\nDUK_INTERNAL_DECL void duk_hbufobj_promote_plain(duk_context *ctx, duk_idx_t idx);\n\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n#endif  /* DUK_HBUFOBJ_H_INCLUDED */\n/* #include duk_hthread.h */\n/*\n *  Heap thread object representation.\n *\n *  duk_hthread is also the 'context' (duk_context) for exposed APIs\n *  which mostly operate on the topmost frame of the value stack.\n */\n\n#if !defined(DUK_HTHREAD_H_INCLUDED)\n#define DUK_HTHREAD_H_INCLUDED\n\n/*\n *  Stack constants\n */\n\n#define DUK_VALSTACK_GROW_STEP          128     /* roughly 1 kiB */\n#define DUK_VALSTACK_SHRINK_THRESHOLD   256     /* roughly 2 kiB */\n#define DUK_VALSTACK_SHRINK_SPARE       64      /* roughly 0.5 kiB */\n#define DUK_VALSTACK_INITIAL_SIZE       128     /* roughly 1.0 kiB -> but rounds up to DUK_VALSTACK_GROW_STEP in practice */\n#define DUK_VALSTACK_INTERNAL_EXTRA     64      /* internal extra elements assumed on function entry,\n                                                 * always added to user-defined 'extra' for e.g. the\n                                                 * duk_check_stack() call.\n                                                 */\n#define DUK_VALSTACK_API_ENTRY_MINIMUM  DUK_API_ENTRY_STACK\n                                                /* number of elements guaranteed to be user accessible\n                                                 * (in addition to call arguments) on Duktape/C function entry.\n                                                 */\n\n/* Note: DUK_VALSTACK_INITIAL_SIZE must be >= DUK_VALSTACK_API_ENTRY_MINIMUM\n * + DUK_VALSTACK_INTERNAL_EXTRA so that the initial stack conforms to spare\n * requirements.\n */\n\n#define DUK_VALSTACK_DEFAULT_MAX        1000000L\n\n#define DUK_CALLSTACK_GROW_STEP         8       /* roughly 256 bytes */\n#define DUK_CALLSTACK_SHRINK_THRESHOLD  16      /* roughly 512 bytes */\n#define DUK_CALLSTACK_SHRINK_SPARE      8       /* roughly 256 bytes */\n#define DUK_CALLSTACK_INITIAL_SIZE      8\n#define DUK_CALLSTACK_DEFAULT_MAX       10000L\n\n#define DUK_CATCHSTACK_GROW_STEP         4      /* roughly 64 bytes */\n#define DUK_CATCHSTACK_SHRINK_THRESHOLD  8      /* roughly 128 bytes */\n#define DUK_CATCHSTACK_SHRINK_SPARE      4      /* roughly 64 bytes */\n#define DUK_CATCHSTACK_INITIAL_SIZE      4\n#define DUK_CATCHSTACK_DEFAULT_MAX       10000L\n\n/*\n *  Activation defines\n */\n\n#define DUK_ACT_FLAG_STRICT             (1 << 0)  /* function executes in strict mode */\n#define DUK_ACT_FLAG_TAILCALLED         (1 << 1)  /* activation has tail called one or more times */\n#define DUK_ACT_FLAG_CONSTRUCT          (1 << 2)  /* function executes as a constructor (called via \"new\") */\n#define DUK_ACT_FLAG_PREVENT_YIELD      (1 << 3)  /* activation prevents yield (native call or \"new\") */\n#define DUK_ACT_FLAG_DIRECT_EVAL        (1 << 4)  /* activation is a direct eval call */\n#define DUK_ACT_FLAG_BREAKPOINT_ACTIVE  (1 << 5)  /* activation has active breakpoint(s) */\n\n#define DUK_ACT_GET_FUNC(act)        ((act)->func)\n\n/*\n *  Flags for __FILE__ / __LINE__ registered into tracedata\n */\n\n#define DUK_TB_FLAG_NOBLAME_FILELINE   (1 << 0)  /* don't report __FILE__ / __LINE__ as fileName/lineNumber */\n\n/*\n *  Catcher defines\n */\n\n/* flags field: LLLLLLFT, L = label (24 bits), F = flags (4 bits), T = type (4 bits) */\n#define DUK_CAT_TYPE_MASK            0x0000000fUL\n#define DUK_CAT_TYPE_BITS            4\n#define DUK_CAT_LABEL_MASK           0xffffff00UL\n#define DUK_CAT_LABEL_BITS           24\n#define DUK_CAT_LABEL_SHIFT          8\n\n#define DUK_CAT_FLAG_CATCH_ENABLED          (1 << 4)   /* catch part will catch */\n#define DUK_CAT_FLAG_FINALLY_ENABLED        (1 << 5)   /* finally part will catch */\n#define DUK_CAT_FLAG_CATCH_BINDING_ENABLED  (1 << 6)   /* request to create catch binding */\n#define DUK_CAT_FLAG_LEXENV_ACTIVE          (1 << 7)   /* catch or with binding is currently active */\n\n#define DUK_CAT_TYPE_UNKNOWN         0\n#define DUK_CAT_TYPE_TCF             1\n#define DUK_CAT_TYPE_LABEL           2\n\n#define DUK_CAT_GET_TYPE(c)          ((c)->flags & DUK_CAT_TYPE_MASK)\n#define DUK_CAT_GET_LABEL(c)         (((c)->flags & DUK_CAT_LABEL_MASK) >> DUK_CAT_LABEL_SHIFT)\n\n#define DUK_CAT_HAS_CATCH_ENABLED(c)           ((c)->flags & DUK_CAT_FLAG_CATCH_ENABLED)\n#define DUK_CAT_HAS_FINALLY_ENABLED(c)         ((c)->flags & DUK_CAT_FLAG_FINALLY_ENABLED)\n#define DUK_CAT_HAS_CATCH_BINDING_ENABLED(c)   ((c)->flags & DUK_CAT_FLAG_CATCH_BINDING_ENABLED)\n#define DUK_CAT_HAS_LEXENV_ACTIVE(c)           ((c)->flags & DUK_CAT_FLAG_LEXENV_ACTIVE)\n\n#define DUK_CAT_SET_CATCH_ENABLED(c)    do { \\\n\t\t(c)->flags |= DUK_CAT_FLAG_CATCH_ENABLED; \\\n\t} while (0)\n#define DUK_CAT_SET_FINALLY_ENABLED(c)  do { \\\n\t\t(c)->flags |= DUK_CAT_FLAG_FINALLY_ENABLED; \\\n\t} while (0)\n#define DUK_CAT_SET_CATCH_BINDING_ENABLED(c)    do { \\\n\t\t(c)->flags |= DUK_CAT_FLAG_CATCH_BINDING_ENABLED; \\\n\t} while (0)\n#define DUK_CAT_SET_LEXENV_ACTIVE(c)    do { \\\n\t\t(c)->flags |= DUK_CAT_FLAG_LEXENV_ACTIVE; \\\n\t} while (0)\n\n#define DUK_CAT_CLEAR_CATCH_ENABLED(c)    do { \\\n\t\t(c)->flags &= ~DUK_CAT_FLAG_CATCH_ENABLED; \\\n\t} while (0)\n#define DUK_CAT_CLEAR_FINALLY_ENABLED(c)  do { \\\n\t\t(c)->flags &= ~DUK_CAT_FLAG_FINALLY_ENABLED; \\\n\t} while (0)\n#define DUK_CAT_CLEAR_CATCH_BINDING_ENABLED(c)    do { \\\n\t\t(c)->flags &= ~DUK_CAT_FLAG_CATCH_BINDING_ENABLED; \\\n\t} while (0)\n#define DUK_CAT_CLEAR_LEXENV_ACTIVE(c)    do { \\\n\t\t(c)->flags &= ~DUK_CAT_FLAG_LEXENV_ACTIVE; \\\n\t} while (0)\n\n/*\n *  Thread defines\n */\n\n#if defined(DUK_USE_ROM_STRINGS)\n#define DUK_HTHREAD_GET_STRING(thr,idx) \\\n\t((duk_hstring *) DUK_LOSE_CONST(duk_rom_strings_stridx[(idx)]))\n#else  /* DUK_USE_ROM_STRINGS */\n#if defined(DUK_USE_HEAPPTR16)\n#define DUK_HTHREAD_GET_STRING(thr,idx) \\\n\t((duk_hstring *) DUK_USE_HEAPPTR_DEC16((thr)->heap->heap_udata, (thr)->strs16[(idx)]))\n#else\n#define DUK_HTHREAD_GET_STRING(thr,idx) \\\n\t((thr)->strs[(idx)])\n#endif\n#endif  /* DUK_USE_ROM_STRINGS */\n\n/* values for the state field */\n#define DUK_HTHREAD_STATE_INACTIVE     1   /* thread not currently running */\n#define DUK_HTHREAD_STATE_RUNNING      2   /* thread currently running (only one at a time) */\n#define DUK_HTHREAD_STATE_RESUMED      3   /* thread resumed another thread (active but not running) */\n#define DUK_HTHREAD_STATE_YIELDED      4   /* thread has yielded */\n#define DUK_HTHREAD_STATE_TERMINATED   5   /* thread has terminated */\n\n/* Executor interrupt default interval when nothing else requires a\n * smaller value.  The default interval must be small enough to allow\n * for reasonable execution timeout checking but large enough to keep\n * impact on execution performance low.\n */\n#if defined(DUK_USE_INTERRUPT_COUNTER)\n#define DUK_HTHREAD_INTCTR_DEFAULT     (256L * 1024L)\n#endif\n\n/*\n *  Assert context is valid: non-NULL pointer, fields look sane.\n *\n *  This is used by public API call entrypoints to catch invalid 'ctx' pointers\n *  as early as possible; invalid 'ctx' pointers cause very odd and difficult to\n *  diagnose behavior so it's worth checking even when the check is not 100%.\n */\n\n#if defined(DUK_USE_PREFER_SIZE)\n#define DUK_ASSERT_CTX_VSSIZE(ctx)  /*nop*/\n#else\n#define DUK_ASSERT_CTX_VSSIZE(ctx) \\\n\tDUK_ASSERT((duk_size_t) (((duk_hthread *) (ctx))->valstack_end - ((duk_hthread *) (ctx))->valstack) == \\\n\t\t((duk_hthread *) (ctx))->valstack_size)\n#endif\n#define DUK_ASSERT_CTX_VALID(ctx) do { \\\n\t\tDUK_ASSERT((ctx) != NULL); \\\n\t\tDUK_ASSERT(DUK_HEAPHDR_GET_TYPE((duk_heaphdr *) (ctx)) == DUK_HTYPE_OBJECT); \\\n\t\tDUK_ASSERT(DUK_HOBJECT_IS_THREAD((duk_hobject *) (ctx))); \\\n\t\tDUK_ASSERT(((duk_hthread *) (ctx))->unused1 == 0); \\\n\t\tDUK_ASSERT(((duk_hthread *) (ctx))->unused2 == 0); \\\n\t\tDUK_ASSERT(((duk_hthread *) (ctx))->valstack != NULL); \\\n\t\tDUK_ASSERT(((duk_hthread *) (ctx))->valstack_end >= ((duk_hthread *) (ctx))->valstack); \\\n\t\tDUK_ASSERT(((duk_hthread *) (ctx))->valstack_top >= ((duk_hthread *) (ctx))->valstack); \\\n\t\tDUK_ASSERT(((duk_hthread *) (ctx))->valstack_top >= ((duk_hthread *) (ctx))->valstack_bottom); \\\n\t\tDUK_ASSERT(((duk_hthread *) (ctx))->valstack_end >= ((duk_hthread *) (ctx))->valstack_top); \\\n\t\tDUK_ASSERT_CTX_VSSIZE((ctx)); \\\n\t} while (0)\n\n/*\n *  Assertion helpers.\n */\n\n#define DUK_ASSERT_STRIDX_VALID(val) \\\n\tDUK_ASSERT((duk_uint_t) (val) < DUK_HEAP_NUM_STRINGS)\n\n#define DUK_ASSERT_BIDX_VALID(val) \\\n\tDUK_ASSERT((duk_uint_t) (val) < DUK_NUM_BUILTINS)\n\n/*\n *  Misc\n */\n\n/* Fast access to 'this' binding.  Assumes there's a call in progress. */\n#define DUK_HTHREAD_THIS_PTR(thr) \\\n\t(DUK_ASSERT_EXPR((thr) != NULL), \\\n\t DUK_ASSERT_EXPR((thr)->valstack_bottom > (thr)->valstack), \\\n\t (thr)->valstack_bottom - 1)\n\n/*\n *  Struct defines\n */\n\n/* XXX: for a memory-code tradeoff, remove 'func' and make it's access either a function\n * or a macro.  This would make the activation 32 bytes long on 32-bit platforms again.\n */\n\n/* Note: it's nice if size is 2^N (at least for 32-bit platforms). */\nstruct duk_activation {\n\tduk_tval tv_func;       /* borrowed: full duk_tval for function being executed; for lightfuncs */\n\tduk_hobject *func;      /* borrowed: function being executed; for bound function calls, this is the final, real function, NULL for lightfuncs */\n\tduk_hobject *var_env;   /* current variable environment (may be NULL if delayed) */\n\tduk_hobject *lex_env;   /* current lexical environment (may be NULL if delayed) */\n#if defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)\n\t/* Previous value of 'func' caller, restored when unwound.  Only in use\n\t * when 'func' is non-strict.\n\t */\n\tduk_hobject *prev_caller;\n#endif\n\n\tduk_instr_t *curr_pc;   /* next instruction to execute (points to 'func' bytecode, stable pointer), NULL for native calls */\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\tduk_uint32_t prev_line; /* needed for stepping */\n#endif\n\tduk_small_uint_t flags;\n\n\t/* idx_bottom and idx_retval are only used for book-keeping of\n\t * Ecmascript-initiated calls, to allow returning to an Ecmascript\n\t * function properly.  They are duk_size_t to match the convention\n\t * that value stack sizes are duk_size_t and local frame indices\n\t * are duk_idx_t.\n\t */\n\n\t/* Bottom of valstack for this activation, used to reset\n\t * valstack_bottom on return; index is absolute.  Note:\n\t * idx_top not needed because top is set to 'nregs' always\n\t * when returning to an Ecmascript activation.\n\t */\n\tduk_size_t idx_bottom;\n\n\t/* Return value when returning to this activation (points to caller\n\t * reg, not callee reg); index is absolute (only set if activation is\n\t * not topmost).\n\t *\n\t * Note: idx_bottom is always set, while idx_retval is only applicable\n\t * for activations below the topmost one.  Currently idx_retval for\n\t * the topmost activation is considered garbage (and it not initialized\n\t * on entry or cleared on return; may contain previous or garbage\n\t * values).\n\t */\n\tduk_size_t idx_retval;\n\n\t/* Current 'this' binding is the value just below idx_bottom.\n\t * Previously, 'this' binding was handled with an index to the\n\t * (calling) valstack.  This works for everything except tail\n\t * calls, which must not \"cumulate\" valstack temps.\n\t */\n};\n\n/* Note: it's nice if size is 2^N (not 4x4 = 16 bytes on 32 bit) */\nstruct duk_catcher {\n\tduk_hstring *h_varname;         /* borrowed reference to catch variable name (or NULL if none) */\n\t                                /* (reference is valid as long activation exists) */\n\tduk_instr_t *pc_base;           /* resume execution from pc_base or pc_base+1 (points to 'func' bytecode, stable pointer) */\n\tduk_size_t callstack_index;     /* callstack index of related activation */\n\tduk_size_t idx_base;            /* idx_base and idx_base+1 get completion value and type */\n\tduk_uint32_t flags;             /* type and control flags, label number */\n};\n\nstruct duk_hthread {\n\t/* Shared object part */\n\tduk_hobject obj;\n\n\t/* Pointer to bytecode executor's 'curr_pc' variable.  Used to copy\n\t * the current PC back into the topmost activation when activation\n\t * state is about to change (or \"syncing\" is otherwise needed).  This\n\t * is rather awkward but important for performance, see execution.rst.\n\t */\n\tduk_instr_t **ptr_curr_pc;\n\n\t/* Backpointers. */\n\tduk_heap *heap;\n\n\t/* Current strictness flag: affects API calls. */\n\tduk_uint8_t strict;\n\n\t/* Thread state. */\n\tduk_uint8_t state;\n\tduk_uint8_t unused1;\n\tduk_uint8_t unused2;\n\n\t/* Sanity limits for stack sizes. */\n\tduk_size_t valstack_max;\n\tduk_size_t callstack_max;\n\tduk_size_t catchstack_max;\n\n\t/* XXX: Valstack, callstack, and catchstack are currently assumed\n\t * to have non-NULL pointers.  Relaxing this would not lead to big\n\t * benefits (except perhaps for terminated threads).\n\t */\n\n\t/* Value stack: these are expressed as pointers for faster stack manipulation.\n\t * [valstack,valstack_top[ is GC-reachable, [valstack_top,valstack_end[ is\n\t * not GC-reachable but kept initialized as 'undefined'.\n\t */\n\tduk_tval *valstack;                     /* start of valstack allocation */\n\tduk_tval *valstack_end;                 /* end of valstack allocation (exclusive) */\n\tduk_tval *valstack_bottom;              /* bottom of current frame */\n\tduk_tval *valstack_top;                 /* top of current frame (exclusive) */\n#if !defined(DUK_USE_PREFER_SIZE)\n\tduk_size_t valstack_size;               /* cached: valstack_end - valstack (in entries, not bytes) */\n#endif\n\n\t/* Call stack.  [0,callstack_top[ is GC reachable. */\n\tduk_activation *callstack;\n\tduk_activation *callstack_curr;         /* current activation (or NULL if none) */\n\tduk_size_t callstack_size;              /* allocation size */\n\tduk_size_t callstack_top;               /* next to use, highest used is top - 1 (or none if top == 0) */\n\tduk_size_t callstack_preventcount;      /* number of activation records in callstack preventing a yield */\n\n\t/* Catch stack.  [0,catchstack_top[ is GC reachable. */\n\tduk_catcher *catchstack;\n\tduk_size_t catchstack_size;             /* allocation size */\n\tduk_size_t catchstack_top;              /* next to use, highest used is top - 1 */\n\n\t/* Yield/resume book-keeping. */\n\tduk_hthread *resumer;                   /* who resumed us (if any) */\n\n\t/* Current compiler state (if any), used for augmenting SyntaxErrors. */\n\tduk_compiler_ctx *compile_ctx;\n\n#if defined(DUK_USE_INTERRUPT_COUNTER)\n\t/* Interrupt counter for triggering a slow path check for execution\n\t * timeout, debugger interaction such as breakpoints, etc.  The value\n\t * is valid for the current running thread, and both the init and\n\t * counter values are copied whenever a thread switch occurs.  It's\n\t * important for the counter to be conveniently accessible for the\n\t * bytecode executor inner loop for performance reasons.\n\t */\n\tduk_int_t interrupt_counter;    /* countdown state */\n\tduk_int_t interrupt_init;       /* start value for current countdown */\n#endif\n\n\t/* Builtin-objects; may or may not be shared with other threads,\n\t * threads existing in different \"compartments\" will have different\n\t * built-ins.  Must be stored on a per-thread basis because there\n\t * is no intermediate structure for a thread group / compartment.\n\t * This takes quite a lot of space, currently 43x4 = 172 bytes on\n\t * 32-bit platforms.\n\t *\n\t * In some cases the builtins array could be ROM based, but it's\n\t * sometimes edited (e.g. for sandboxing) so it's better to keep\n\t * this array in RAM.\n\t */\n\tduk_hobject *builtins[DUK_NUM_BUILTINS];\n\n\t/* Convenience copies from heap/vm for faster access. */\n#if defined(DUK_USE_ROM_STRINGS)\n\t/* No field needed when strings are in ROM. */\n#else\n#if defined(DUK_USE_HEAPPTR16)\n\tduk_uint16_t *strs16;\n#else\n\tduk_hstring **strs;\n#endif\n#endif\n};\n\n/*\n *  Prototypes\n */\n\nDUK_INTERNAL_DECL void duk_hthread_copy_builtin_objects(duk_hthread *thr_from, duk_hthread *thr_to);\nDUK_INTERNAL_DECL void duk_hthread_create_builtin_objects(duk_hthread *thr);\nDUK_INTERNAL_DECL duk_bool_t duk_hthread_init_stacks(duk_heap *heap, duk_hthread *thr);\nDUK_INTERNAL_DECL void duk_hthread_terminate(duk_hthread *thr);\n\nDUK_INTERNAL_DECL void duk_hthread_callstack_grow(duk_hthread *thr);\nDUK_INTERNAL_DECL void duk_hthread_callstack_shrink_check(duk_hthread *thr);\nDUK_INTERNAL_DECL void duk_hthread_callstack_unwind_norz(duk_hthread *thr, duk_size_t new_top);\nDUK_INTERNAL_DECL void duk_hthread_callstack_unwind(duk_hthread *thr, duk_size_t new_top);\nDUK_INTERNAL_DECL void duk_hthread_catchstack_grow(duk_hthread *thr);\nDUK_INTERNAL_DECL void duk_hthread_catchstack_shrink_check(duk_hthread *thr);\nDUK_INTERNAL_DECL void duk_hthread_catchstack_unwind_norz(duk_hthread *thr, duk_size_t new_top);\nDUK_INTERNAL_DECL void duk_hthread_catchstack_unwind(duk_hthread *thr, duk_size_t new_top);\n\n#if defined(DUK_USE_FINALIZER_TORTURE)\nDUK_INTERNAL_DECL void duk_hthread_valstack_torture_realloc(duk_hthread *thr);\nDUK_INTERNAL_DECL void duk_hthread_callstack_torture_realloc(duk_hthread *thr);\nDUK_INTERNAL_DECL void duk_hthread_catchstack_torture_realloc(duk_hthread *thr);\n#endif\n\nDUK_INTERNAL_DECL void *duk_hthread_get_valstack_ptr(duk_heap *heap, void *ud);  /* indirect allocs */\nDUK_INTERNAL_DECL void *duk_hthread_get_callstack_ptr(duk_heap *heap, void *ud);  /* indirect allocs */\nDUK_INTERNAL_DECL void *duk_hthread_get_catchstack_ptr(duk_heap *heap, void *ud);  /* indirect allocs */\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\nDUK_INTERNAL_DECL duk_uint_fast32_t duk_hthread_get_act_curr_pc(duk_hthread *thr, duk_activation *act);\n#endif\nDUK_INTERNAL_DECL duk_uint_fast32_t duk_hthread_get_act_prev_pc(duk_hthread *thr, duk_activation *act);\nDUK_INTERNAL_DECL void duk_hthread_sync_currpc(duk_hthread *thr);\nDUK_INTERNAL_DECL void duk_hthread_sync_and_null_currpc(duk_hthread *thr);\n\n#endif  /* DUK_HTHREAD_H_INCLUDED */\n/* #include duk_harray.h */\n/*\n *  Heap Array object representation.  Used for actual Array instances.\n *\n *  All objects with the exotic array behavior (which must coincide with having\n *  internal class array) MUST be duk_harrays.  No other object can be a\n *  duk_harray.  However, duk_harrays may not always have an array part.\n */\n\n#if !defined(DUK_HARRAY_H_INCLUDED)\n#define DUK_HARRAY_H_INCLUDED\n\n#define DUK_ASSERT_HARRAY_VALID(h) do { \\\n\t\tDUK_ASSERT((h) != NULL); \\\n\t\tDUK_ASSERT(DUK_HOBJECT_IS_ARRAY((duk_hobject *) (h))); \\\n\t\tDUK_ASSERT(DUK_HOBJECT_HAS_EXOTIC_ARRAY((duk_hobject *) (h))); \\\n\t} while (0)\n\n#define DUK_HARRAY_LENGTH_WRITABLE(h)         (!(h)->length_nonwritable)\n#define DUK_HARRAY_LENGTH_NONWRITABLE(h)      ((h)->length_nonwritable)\n#define DUK_HARRAY_SET_LENGTH_WRITABLE(h)     do { (h)->length_nonwritable = 0; } while (0)\n#define DUK_HARRAY_SET_LENGTH_NONWRITABLE(h)  do { (h)->length_nonwritable = 1; } while (0)\n\nstruct duk_harray {\n\t/* Shared object part. */\n\tduk_hobject obj;\n\n\t/* Array .length.\n\t *\n\t * At present Array .length may be smaller, equal, or even larger\n\t * than the allocated underlying array part.  Fast path code must\n\t * always take this into account carefully.\n\t */\n\tduk_uint32_t length;\n\n\t/* Array .length property attributes.  The property is always\n\t * non-enumerable and non-configurable.  It's initially writable\n\t * but per Object.defineProperty() rules it can be made non-writable\n\t * even if it is non-configurable.  Thus we need to track the\n\t * writability explicitly.\n\t *\n\t * XXX: this field to be eliminated and moved into duk_hobject\n\t * flags field to save space.\n\t */\n\tduk_bool_t length_nonwritable;\n};\n\n#endif  /* DUK_HARRAY_H_INCLUDED */\n/* #include duk_henv.h */\n/*\n *  Environment object representation.\n */\n\n#if !defined(DUK_HENV_H_INCLUDED)\n#define DUK_HENV_H_INCLUDED\n\n#define DUK_ASSERT_HDECENV_VALID(h) do { \\\n\t\tDUK_ASSERT((h) != NULL); \\\n\t\tDUK_ASSERT(DUK_HOBJECT_IS_DECENV((duk_hobject *) (h))); \\\n\t\tDUK_ASSERT((h)->thread == NULL || (h)->varmap != NULL); \\\n\t} while (0)\n\n#define DUK_ASSERT_HOBJENV_VALID(h) do { \\\n\t\tDUK_ASSERT((h) != NULL); \\\n\t\tDUK_ASSERT(DUK_HOBJECT_IS_OBJENV((duk_hobject *) (h))); \\\n\t\tDUK_ASSERT((h)->target != NULL); \\\n\t\tDUK_ASSERT((h)->has_this == 0 || (h)->has_this == 1); \\\n\t} while (0)\n\nstruct duk_hdecenv {\n\t/* Shared object part. */\n\tduk_hobject obj;\n\n\t/* These control variables provide enough information to access live\n\t * variables for a closure that is still open.  If thread == NULL,\n\t * the record is closed and the identifiers are in the property table.\n\t */\n\tduk_hthread *thread;\n\tduk_hobject *varmap;\n\tduk_size_t regbase;\n};\n\nstruct duk_hobjenv {\n\t/* Shared object part. */\n\tduk_hobject obj;\n\n\t/* Target object and 'this' binding for object binding. */\n\tduk_hobject *target;\n\n\t/* The 'target' object is used as a this binding in only some object\n\t * environments.  For example, the global environment does not provide\n\t * a this binding, but a with statement does.\n\t */\n\tduk_bool_t has_this;\n};\n\n#endif  /* DUK_HENV_H_INCLUDED */\n/* #include duk_hbuffer.h */\n/*\n *  Heap buffer representation.\n *\n *  Heap allocated user data buffer which is either:\n *\n *    1. A fixed size buffer (data follows header statically)\n *    2. A dynamic size buffer (data pointer follows header)\n *\n *  The data pointer for a variable size buffer of zero size may be NULL.\n */\n\n#if !defined(DUK_HBUFFER_H_INCLUDED)\n#define DUK_HBUFFER_H_INCLUDED\n\n/*\n *  Flags\n *\n *  Fixed buffer:     0\n *  Dynamic buffer:   DUK_HBUFFER_FLAG_DYNAMIC\n *  External buffer:  DUK_HBUFFER_FLAG_DYNAMIC | DUK_HBUFFER_FLAG_EXTERNAL\n */\n\n#define DUK_HBUFFER_FLAG_DYNAMIC                  DUK_HEAPHDR_USER_FLAG(0)    /* buffer is behind a pointer, dynamic or external */\n#define DUK_HBUFFER_FLAG_EXTERNAL                 DUK_HEAPHDR_USER_FLAG(1)    /* buffer pointer is to an externally allocated buffer */\n\n#define DUK_HBUFFER_HAS_DYNAMIC(x)                DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HBUFFER_FLAG_DYNAMIC)\n#define DUK_HBUFFER_HAS_EXTERNAL(x)               DUK_HEAPHDR_CHECK_FLAG_BITS(&(x)->hdr, DUK_HBUFFER_FLAG_EXTERNAL)\n\n#define DUK_HBUFFER_SET_DYNAMIC(x)                DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HBUFFER_FLAG_DYNAMIC)\n#define DUK_HBUFFER_SET_EXTERNAL(x)               DUK_HEAPHDR_SET_FLAG_BITS(&(x)->hdr, DUK_HBUFFER_FLAG_EXTERNAL)\n\n#define DUK_HBUFFER_CLEAR_DYNAMIC(x)              DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HBUFFER_FLAG_DYNAMIC)\n#define DUK_HBUFFER_CLEAR_EXTERNAL(x)             DUK_HEAPHDR_CLEAR_FLAG_BITS(&(x)->hdr, DUK_HBUFFER_FLAG_EXTERNAL)\n\n/*\n *  Misc defines\n */\n\n/* Impose a maximum buffer length for now.  Restricted artificially to\n * ensure resize computations or adding a heap header length won't\n * overflow size_t and that a signed duk_int_t can hold a buffer\n * length.  The limit should be synchronized with DUK_HSTRING_MAX_BYTELEN.\n */\n\n#if defined(DUK_USE_BUFLEN16)\n#define DUK_HBUFFER_MAX_BYTELEN                   (0x0000ffffUL)\n#else\n/* Intentionally not 0x7fffffffUL; at least JSON code expects that\n * 2*len + 2 fits in 32 bits.\n */\n#define DUK_HBUFFER_MAX_BYTELEN                   (0x7ffffffeUL)\n#endif\n\n/*\n *  Field access\n */\n\n/* Get/set the current user visible size, without accounting for a dynamic\n * buffer's \"spare\" (= usable size).\n */\n#if defined(DUK_USE_BUFLEN16)\n/* size stored in duk_heaphdr unused flag bits */\n#define DUK_HBUFFER_GET_SIZE(x)     ((x)->hdr.h_flags >> 16)\n#define DUK_HBUFFER_SET_SIZE(x,v)   do { \\\n\t\tduk_size_t duk__v; \\\n\t\tduk__v = (v); \\\n\t\tDUK_ASSERT(duk__v <= 0xffffUL); \\\n\t\t(x)->hdr.h_flags = ((x)->hdr.h_flags & 0x0000ffffUL) | (((duk_uint32_t) duk__v) << 16); \\\n\t} while (0)\n#define DUK_HBUFFER_ADD_SIZE(x,dv)  do { \\\n\t\t(x)->hdr.h_flags += ((dv) << 16); \\\n\t} while (0)\n#define DUK_HBUFFER_SUB_SIZE(x,dv)  do { \\\n\t\t(x)->hdr.h_flags -= ((dv) << 16); \\\n\t} while (0)\n#else\n#define DUK_HBUFFER_GET_SIZE(x)     (((duk_hbuffer *) (x))->size)\n#define DUK_HBUFFER_SET_SIZE(x,v)   do { \\\n\t\t((duk_hbuffer *) (x))->size = (v); \\\n\t} while (0)\n#define DUK_HBUFFER_ADD_SIZE(x,dv)  do { \\\n\t\t(x)->size += (dv); \\\n\t} while (0)\n#define DUK_HBUFFER_SUB_SIZE(x,dv)  do { \\\n\t\t(x)->size -= (dv); \\\n\t} while (0)\n#endif\n\n#define DUK_HBUFFER_FIXED_GET_SIZE(x)       DUK_HBUFFER_GET_SIZE((duk_hbuffer *) (x))\n#define DUK_HBUFFER_FIXED_SET_SIZE(x,v)     DUK_HBUFFER_SET_SIZE((duk_hbuffer *) (x))\n\n#define DUK_HBUFFER_DYNAMIC_GET_SIZE(x)     DUK_HBUFFER_GET_SIZE((duk_hbuffer *) (x))\n#define DUK_HBUFFER_DYNAMIC_SET_SIZE(x,v)   DUK_HBUFFER_SET_SIZE((duk_hbuffer *) (x), (v))\n#define DUK_HBUFFER_DYNAMIC_ADD_SIZE(x,dv)  DUK_HBUFFER_ADD_SIZE((duk_hbuffer *) (x), (dv))\n#define DUK_HBUFFER_DYNAMIC_SUB_SIZE(x,dv)  DUK_HBUFFER_SUB_SIZE((duk_hbuffer *) (x), (dv))\n\n#define DUK_HBUFFER_EXTERNAL_GET_SIZE(x)    DUK_HBUFFER_GET_SIZE((duk_hbuffer *) (x))\n#define DUK_HBUFFER_EXTERNAL_SET_SIZE(x,v)  DUK_HBUFFER_SET_SIZE((duk_hbuffer *) (x), (v))\n\n#define DUK_HBUFFER_FIXED_GET_DATA_PTR(heap,x)    ((duk_uint8_t *) (((duk_hbuffer_fixed *) (x)) + 1))\n\n#if defined(DUK_USE_HEAPPTR16)\n#define DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(heap,x) \\\n\t((void *) DUK_USE_HEAPPTR_DEC16((heap)->heap_udata, ((duk_heaphdr *) (x))->h_extra16))\n#define DUK_HBUFFER_DYNAMIC_SET_DATA_PTR(heap,x,v)     do { \\\n\t\t((duk_heaphdr *) (x))->h_extra16 = DUK_USE_HEAPPTR_ENC16((heap)->heap_udata, (void *) (v)); \\\n\t} while (0)\n#define DUK_HBUFFER_DYNAMIC_SET_DATA_PTR_NULL(heap,x)  do { \\\n\t\t((duk_heaphdr *) (x))->h_extra16 = 0;  /* assume 0 <=> NULL */ \\\n\t} while (0)\n#else\n#define DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(heap,x)       ((x)->curr_alloc)\n#define DUK_HBUFFER_DYNAMIC_SET_DATA_PTR(heap,x,v)     do { \\\n\t\t(x)->curr_alloc = (void *) (v); \\\n\t} while (0)\n#define DUK_HBUFFER_DYNAMIC_SET_DATA_PTR_NULL(heap,x)  do { \\\n\t\t(x)->curr_alloc = (void *) NULL; \\\n\t} while (0)\n#endif\n\n/* No pointer compression because pointer is potentially outside of\n * Duktape heap.\n */\n#if defined(DUK_USE_HEAPPTR16)\n#define DUK_HBUFFER_EXTERNAL_GET_DATA_PTR(heap,x) \\\n\t((void *) (x)->curr_alloc)\n#define DUK_HBUFFER_EXTERNAL_SET_DATA_PTR(heap,x,v)     do { \\\n\t\t(x)->curr_alloc = (void *) (v); \\\n\t} while (0)\n#define DUK_HBUFFER_EXTERNAL_SET_DATA_PTR_NULL(heap,x)  do { \\\n\t\t(x)->curr_alloc = (void *) NULL; \\\n\t} while (0)\n#else\n#define DUK_HBUFFER_EXTERNAL_GET_DATA_PTR(heap,x) \\\n\t((void *) (x)->curr_alloc)\n#define DUK_HBUFFER_EXTERNAL_SET_DATA_PTR(heap,x,v)     do { \\\n\t\t(x)->curr_alloc = (void *) (v); \\\n\t} while (0)\n#define DUK_HBUFFER_EXTERNAL_SET_DATA_PTR_NULL(heap,x)  do { \\\n\t\t(x)->curr_alloc = (void *) NULL; \\\n\t} while (0)\n#endif\n\n/* Get a pointer to the current buffer contents (matching current allocation\n * size).  May be NULL for zero size dynamic/external buffer.\n */\n#if defined(DUK_USE_HEAPPTR16)\n#define DUK_HBUFFER_GET_DATA_PTR(heap,x)  ( \\\n\tDUK_HBUFFER_HAS_DYNAMIC((x)) ? \\\n\t\t( \\\n\t\t\tDUK_HBUFFER_HAS_EXTERNAL((x)) ? \\\n\t\t\t\tDUK_HBUFFER_EXTERNAL_GET_DATA_PTR((heap), (duk_hbuffer_external *) (x)) : \\\n\t\t\t\tDUK_HBUFFER_DYNAMIC_GET_DATA_PTR((heap), (duk_hbuffer_dynamic *) (x)) \\\n\t\t) : \\\n\t\tDUK_HBUFFER_FIXED_GET_DATA_PTR((heap), (duk_hbuffer_fixed *) (x)) \\\n\t)\n#else\n/* Without heap pointer compression duk_hbuffer_dynamic and duk_hbuffer_external\n * have the same layout so checking for fixed vs. dynamic (or external) is enough.\n */\n#define DUK_HBUFFER_GET_DATA_PTR(heap,x)  ( \\\n\tDUK_HBUFFER_HAS_DYNAMIC((x)) ? \\\n\t\tDUK_HBUFFER_DYNAMIC_GET_DATA_PTR((heap), (duk_hbuffer_dynamic *) (x)) : \\\n\t\tDUK_HBUFFER_FIXED_GET_DATA_PTR((heap), (duk_hbuffer_fixed *) (x)) \\\n\t)\n#endif\n\n/*\n *  Structs\n */\n\n/* Shared prefix for all buffer types. */\nstruct duk_hbuffer {\n\tduk_heaphdr hdr;\n\n\t/* It's not strictly necessary to track the current size, but\n\t * it is useful for writing robust native code.\n\t */\n\n\t/* Current size (not counting a dynamic buffer's \"spare\"). */\n#if defined(DUK_USE_BUFLEN16)\n\t/* Stored in duk_heaphdr unused flags. */\n#else\n\tduk_size_t size;\n#endif\n\n\t/*\n\t *  Data following the header depends on the DUK_HBUFFER_FLAG_DYNAMIC\n\t *  flag.\n\t *\n\t *  If the flag is clear (the buffer is a fixed size one), the buffer\n\t *  data follows the header directly, consisting of 'size' bytes.\n\t *\n\t *  If the flag is set, the actual buffer is allocated separately, and\n\t *  a few control fields follow the header.  Specifically:\n\t *\n\t *    - a \"void *\" pointing to the current allocation\n\t *    - a duk_size_t indicating the full allocated size (always >= 'size')\n\t *\n\t *  If DUK_HBUFFER_FLAG_EXTERNAL is set, the buffer has been allocated\n\t *  by user code, so that Duktape won't be able to resize it and won't\n\t *  free it.  This allows buffers to point to e.g. an externally\n\t *  allocated structure such as a frame buffer.\n\t *\n\t *  Unlike strings, no terminator byte (NUL) is guaranteed after the\n\t *  data.  This would be convenient, but would pad aligned user buffers\n\t *  unnecessarily upwards in size.  For instance, if user code requested\n\t *  a 64-byte dynamic buffer, 65 bytes would actually be allocated which\n\t *  would then potentially round upwards to perhaps 68 or 72 bytes.\n\t */\n};\n\n/* Fixed buffer; data follows struct, with proper alignment guaranteed by\n * struct size.\n */\n#if (DUK_USE_ALIGN_BY == 8) && defined(DUK_USE_PACK_MSVC_PRAGMA)\n#pragma pack(push, 8)\n#endif\nstruct duk_hbuffer_fixed {\n\t/* A union is used here as a portable struct size / alignment trick:\n\t * by adding a 32-bit or a 64-bit (unused) union member, the size of\n\t * the struct is effectively forced to be a multiple of 4 or 8 bytes\n\t * (respectively) without increasing the size of the struct unless\n\t * necessary.\n\t */\n\tunion {\n\t\tstruct {\n\t\t\tduk_heaphdr hdr;\n#if defined(DUK_USE_BUFLEN16)\n\t\t\t/* Stored in duk_heaphdr unused flags. */\n#else\n\t\t\tduk_size_t size;\n#endif\n\t\t} s;\n#if (DUK_USE_ALIGN_BY == 4)\n\t\tduk_uint32_t dummy_for_align4;\n#elif (DUK_USE_ALIGN_BY == 8)\n\t\tduk_double_t dummy_for_align8;\n#elif (DUK_USE_ALIGN_BY == 1)\n\t\t/* no extra padding */\n#else\n#error invalid DUK_USE_ALIGN_BY\n#endif\n\t} u;\n\n\t/*\n\t *  Data follows the struct header.  The struct size is padded by the\n\t *  compiler based on the struct members.  This guarantees that the\n\t *  buffer data will be aligned-by-4 but not necessarily aligned-by-8.\n\t *\n\t *  On platforms where alignment does not matter, the struct padding\n\t *  could be removed (if there is any).  On platforms where alignment\n\t *  by 8 is required, the struct size must be forced to be a multiple\n\t *  of 8 by some means.  Without it, some user code may break, and also\n\t *  Duktape itself breaks (e.g. the compiler stores duk_tvals in a\n\t *  dynamic buffer).\n\t */\n}\n#if (DUK_USE_ALIGN_BY == 8) && defined(DUK_USE_PACK_GCC_ATTR)\n__attribute__ ((aligned (8)))\n#elif (DUK_USE_ALIGN_BY == 8) && defined(DUK_USE_PACK_CLANG_ATTR)\n__attribute__ ((aligned (8)))\n#endif\n;\n#if (DUK_USE_ALIGN_BY == 8) && defined(DUK_USE_PACK_MSVC_PRAGMA)\n#pragma pack(pop)\n#endif\n\n/* Dynamic buffer with 'curr_alloc' pointing to a dynamic area allocated using\n * heap allocation primitives.  Also used for external buffers when low memory\n * options are not used.\n */\nstruct duk_hbuffer_dynamic {\n\tduk_heaphdr hdr;\n\n#if defined(DUK_USE_BUFLEN16)\n\t/* Stored in duk_heaphdr unused flags. */\n#else\n\tduk_size_t size;\n#endif\n\n#if defined(DUK_USE_HEAPPTR16)\n\t/* Stored in duk_heaphdr h_extra16. */\n#else\n\tvoid *curr_alloc;  /* may be NULL if alloc_size == 0 */\n#endif\n\n\t/*\n\t *  Allocation size for 'curr_alloc' is alloc_size.  There is no\n\t *  automatic NUL terminator for buffers (see above for rationale).\n\t *\n\t *  'curr_alloc' is explicitly allocated with heap allocation\n\t *  primitives and will thus always have alignment suitable for\n\t *  e.g. duk_tval and an IEEE double.\n\t */\n};\n\n/* External buffer with 'curr_alloc' managed by user code and pointing to an\n * arbitrary address.  When heap pointer compression is not used, this struct\n * has the same layout as duk_hbuffer_dynamic.\n */\nstruct duk_hbuffer_external {\n\tduk_heaphdr hdr;\n\n#if defined(DUK_USE_BUFLEN16)\n\t/* Stored in duk_heaphdr unused flags. */\n#else\n\tduk_size_t size;\n#endif\n\n\t/* Cannot be compressed as a heap pointer because may point to\n\t * an arbitrary address.\n\t */\n\tvoid *curr_alloc;  /* may be NULL if alloc_size == 0 */\n};\n\n/*\n *  Prototypes\n */\n\nDUK_INTERNAL_DECL duk_hbuffer *duk_hbuffer_alloc(duk_heap *heap, duk_size_t size, duk_small_uint_t flags, void **out_bufdata);\nDUK_INTERNAL_DECL void *duk_hbuffer_get_dynalloc_ptr(duk_heap *heap, void *ud);  /* indirect allocs */\n\n/* dynamic buffer ops */\nDUK_INTERNAL_DECL void duk_hbuffer_resize(duk_hthread *thr, duk_hbuffer_dynamic *buf, duk_size_t new_size);\nDUK_INTERNAL_DECL void duk_hbuffer_reset(duk_hthread *thr, duk_hbuffer_dynamic *buf);\n\n#endif  /* DUK_HBUFFER_H_INCLUDED */\n/* #include duk_heap.h */\n/*\n *  Heap structure.\n *\n *  Heap contains allocated heap objects, interned strings, and built-in\n *  strings for one or more threads.\n */\n\n#if !defined(DUK_HEAP_H_INCLUDED)\n#define DUK_HEAP_H_INCLUDED\n\n/* alloc function typedefs in duktape.h */\n\n/*\n *  Heap flags\n */\n\n#define DUK_HEAP_FLAG_MARKANDSWEEP_RECLIMIT_REACHED            (1 << 0)  /* mark-and-sweep marking reached a recursion limit and must use multi-pass marking */\n#define DUK_HEAP_FLAG_ERRHANDLER_RUNNING                       (1 << 1)  /* an error handler (user callback to augment/replace error) is running */\n#define DUK_HEAP_FLAG_INTERRUPT_RUNNING                        (1 << 2)  /* executor interrupt running (used to avoid nested interrupts) */\n#define DUK_HEAP_FLAG_FINALIZER_NORESCUE                       (1 << 3)  /* heap destruction ongoing, finalizer rescue no longer possible */\n#define DUK_HEAP_FLAG_DEBUGGER_PAUSED                          (1 << 4)  /* debugger is paused: talk with debug client until step/resume */\n\n#define DUK__HEAP_HAS_FLAGS(heap,bits)               ((heap)->flags & (bits))\n#define DUK__HEAP_SET_FLAGS(heap,bits)  do { \\\n\t\t(heap)->flags |= (bits); \\\n\t} while (0)\n#define DUK__HEAP_CLEAR_FLAGS(heap,bits)  do { \\\n\t\t(heap)->flags &= ~(bits); \\\n\t} while (0)\n\n#define DUK_HEAP_HAS_MARKANDSWEEP_RECLIMIT_REACHED(heap)   DUK__HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RECLIMIT_REACHED)\n#define DUK_HEAP_HAS_ERRHANDLER_RUNNING(heap)              DUK__HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_ERRHANDLER_RUNNING)\n#define DUK_HEAP_HAS_INTERRUPT_RUNNING(heap)               DUK__HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_INTERRUPT_RUNNING)\n#define DUK_HEAP_HAS_FINALIZER_NORESCUE(heap)              DUK__HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_FINALIZER_NORESCUE)\n#define DUK_HEAP_HAS_DEBUGGER_PAUSED(heap)                 DUK__HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_DEBUGGER_PAUSED)\n\n#define DUK_HEAP_SET_MARKANDSWEEP_RECLIMIT_REACHED(heap)   DUK__HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RECLIMIT_REACHED)\n#define DUK_HEAP_SET_ERRHANDLER_RUNNING(heap)              DUK__HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_ERRHANDLER_RUNNING)\n#define DUK_HEAP_SET_INTERRUPT_RUNNING(heap)               DUK__HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_INTERRUPT_RUNNING)\n#define DUK_HEAP_SET_FINALIZER_NORESCUE(heap)              DUK__HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_FINALIZER_NORESCUE)\n#define DUK_HEAP_SET_DEBUGGER_PAUSED(heap)                 DUK__HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_DEBUGGER_PAUSED)\n\n#define DUK_HEAP_CLEAR_MARKANDSWEEP_RECLIMIT_REACHED(heap) DUK__HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RECLIMIT_REACHED)\n#define DUK_HEAP_CLEAR_ERRHANDLER_RUNNING(heap)            DUK__HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_ERRHANDLER_RUNNING)\n#define DUK_HEAP_CLEAR_INTERRUPT_RUNNING(heap)             DUK__HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_INTERRUPT_RUNNING)\n#define DUK_HEAP_CLEAR_FINALIZER_NORESCUE(heap)            DUK__HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_FINALIZER_NORESCUE)\n#define DUK_HEAP_CLEAR_DEBUGGER_PAUSED(heap)               DUK__HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_DEBUGGER_PAUSED)\n\n/*\n *  Longjmp types, also double as identifying continuation type for a rethrow (in 'finally')\n */\n\n#define DUK_LJ_TYPE_UNKNOWN      0    /* unused */\n#define DUK_LJ_TYPE_THROW        1    /* value1 -> error object */\n#define DUK_LJ_TYPE_YIELD        2    /* value1 -> yield value, iserror -> error / normal */\n#define DUK_LJ_TYPE_RESUME       3    /* value1 -> resume value, value2 -> resumee thread, iserror -> error/normal */\n#define DUK_LJ_TYPE_BREAK        4    /* value1 -> label number, pseudo-type to indicate a break continuation (for ENDFIN) */\n#define DUK_LJ_TYPE_CONTINUE     5    /* value1 -> label number, pseudo-type to indicate a continue continuation (for ENDFIN) */\n#define DUK_LJ_TYPE_RETURN       6    /* value1 -> return value, pseudo-type to indicate a return continuation (for ENDFIN) */\n#define DUK_LJ_TYPE_NORMAL       7    /* no value, pseudo-type to indicate a normal continuation (for ENDFIN) */\n\n/*\n *  Mark-and-sweep flags\n *\n *  These are separate from heap level flags now but could be merged.\n *  The heap structure only contains a 'base mark-and-sweep flags'\n *  field and the GC caller can impose further flags.\n */\n\n/* Emergency mark-and-sweep: try extra hard, even at the cost of\n * performance.\n */\n#define DUK_MS_FLAG_EMERGENCY                (1 << 0)\n\n/* Voluntary mark-and-sweep: triggered periodically. */\n#define DUK_MS_FLAG_VOLUNTARY                (1 << 1)\n\n/* Postpone rescue decisions for reachable objects with FINALIZED set.\n * Used during finalize_list processing to avoid incorrect rescue\n * decisions due to finalize_list being a reachability root.\n */\n#define DUK_MS_FLAG_POSTPONE_RESCUE          (1 << 2)\n\n/* Don't compact objects; needed during object property table resize\n * to prevent a recursive resize.  It would suffice to protect only the\n * current object being resized, but this is not yet implemented.\n */\n#define DUK_MS_FLAG_NO_OBJECT_COMPACTION     (1 << 2)\n\n/*\n *  Thread switching\n *\n *  To switch heap->curr_thread, use the macro below so that interrupt counters\n *  get updated correctly.  The macro allows a NULL target thread because that\n *  happens e.g. in call handling.\n */\n\n#if defined(DUK_USE_INTERRUPT_COUNTER)\n#define DUK_HEAP_SWITCH_THREAD(heap,newthr)  duk_heap_switch_thread((heap), (newthr))\n#else\n#define DUK_HEAP_SWITCH_THREAD(heap,newthr)  do { \\\n\t\t(heap)->curr_thread = (newthr); \\\n\t} while (0)\n#endif\n\n/*\n *  Other heap related defines\n */\n\n/* Mark-and-sweep interval is relative to combined count of objects and\n * strings kept in the heap during the latest mark-and-sweep pass.\n * Fixed point .8 multiplier and .0 adder.  Trigger count (interval) is\n * decreased by each (re)allocation attempt (regardless of size), and each\n * refzero processed object.\n *\n * 'SKIP' indicates how many (re)allocations to wait until a retry if\n * GC is skipped because there is no thread do it with yet (happens\n * only during init phases).\n */\n#if defined(DUK_USE_REFERENCE_COUNTING)\n#define DUK_HEAP_MARK_AND_SWEEP_TRIGGER_MULT              12800L  /* 50x heap size */\n#define DUK_HEAP_MARK_AND_SWEEP_TRIGGER_ADD               1024L\n#define DUK_HEAP_MARK_AND_SWEEP_TRIGGER_SKIP              256L\n#else\n#define DUK_HEAP_MARK_AND_SWEEP_TRIGGER_MULT              256L    /* 1x heap size */\n#define DUK_HEAP_MARK_AND_SWEEP_TRIGGER_ADD               1024L\n#define DUK_HEAP_MARK_AND_SWEEP_TRIGGER_SKIP              256L\n#endif\n\n/* GC torture. */\n#if defined(DUK_USE_GC_TORTURE)\n#define DUK_GC_TORTURE(heap) do { duk_heap_mark_and_sweep((heap), 0); } while (0)\n#else\n#define DUK_GC_TORTURE(heap) do { } while (0)\n#endif\n\n/* Stringcache is used for speeding up char-offset-to-byte-offset\n * translations for non-ASCII strings.\n */\n#define DUK_HEAP_STRCACHE_SIZE                            4\n#define DUK_HEAP_STRINGCACHE_NOCACHE_LIMIT                16  /* strings up to the this length are not cached */\n\n/* Some list management macros. */\n#define DUK_HEAP_INSERT_INTO_HEAP_ALLOCATED(heap,hdr)     duk_heap_insert_into_heap_allocated((heap), (hdr))\n#if defined(DUK_USE_REFERENCE_COUNTING)\n#define DUK_HEAP_REMOVE_FROM_HEAP_ALLOCATED(heap,hdr)     duk_heap_remove_from_heap_allocated((heap), (hdr))\n#endif\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n#define DUK_HEAP_INSERT_INTO_FINALIZE_LIST(heap,hdr)      duk_heap_insert_into_finalize_list((heap), (hdr))\n#define DUK_HEAP_REMOVE_FROM_FINALIZE_LIST(heap,hdr)      duk_heap_remove_from_finalize_list((heap), (hdr))\n#endif\n\n/*\n *  Built-in strings\n */\n\n/* heap string indices are autogenerated in duk_strings.h */\n#if defined(DUK_USE_ROM_STRINGS)\n#define DUK_HEAP_GET_STRING(heap,idx) \\\n\t((duk_hstring *) DUK_LOSE_CONST(duk_rom_strings_stridx[(idx)]))\n#else  /* DUK_USE_ROM_STRINGS */\n#if defined(DUK_USE_HEAPPTR16)\n#define DUK_HEAP_GET_STRING(heap,idx) \\\n\t((duk_hstring *) DUK_USE_HEAPPTR_DEC16((heap)->heap_udata, (heap)->strs16[(idx)]))\n#else\n#define DUK_HEAP_GET_STRING(heap,idx) \\\n\t((heap)->strs[(idx)])\n#endif\n#endif  /* DUK_USE_ROM_STRINGS */\n\n/*\n *  Raw memory calls: relative to heap, but no GC interaction\n */\n\n#define DUK_ALLOC_RAW(heap,size) \\\n\t((heap)->alloc_func((heap)->heap_udata, (size)))\n\n#define DUK_REALLOC_RAW(heap,ptr,newsize) \\\n\t((heap)->realloc_func((heap)->heap_udata, (void *) (ptr), (newsize)))\n\n#define DUK_FREE_RAW(heap,ptr) \\\n\t((heap)->free_func((heap)->heap_udata, (void *) (ptr)))\n\n/*\n *  Memory calls: relative to heap, GC interaction, but no error throwing.\n *\n *  XXX: Currently a mark-and-sweep triggered by memory allocation will run\n *  using the heap->heap_thread.  This thread is also used for running\n *  mark-and-sweep finalization; this is not ideal because it breaks the\n *  isolation between multiple global environments.\n *\n *  Notes:\n *\n *    - DUK_FREE() is required to ignore NULL and any other possible return\n *      value of a zero-sized alloc/realloc (same as ANSI C free()).\n *\n *    - There is no DUK_REALLOC_ZEROED because we don't assume to know the\n *      old size.  Caller must zero the reallocated memory.\n *\n *    - DUK_REALLOC_INDIRECT() must be used when a mark-and-sweep triggered\n *      by an allocation failure might invalidate the original 'ptr', thus\n *      causing a realloc retry to use an invalid pointer.  Example: we're\n *      reallocating the value stack and a finalizer resizes the same value\n *      stack during mark-and-sweep.  The indirect variant requests for the\n *      current location of the pointer being reallocated using a callback\n *      right before every realloc attempt; this circuitous approach is used\n *      to avoid strict aliasing issues in a more straightforward indirect\n *      pointer (void **) approach.  Note: the pointer in the storage\n *      location is read but is NOT updated; the caller must do that.\n */\n\n/* callback for indirect reallocs, request for current pointer */\ntypedef void *(*duk_mem_getptr)(duk_heap *heap, void *ud);\n\n#define DUK_ALLOC(heap,size)                            duk_heap_mem_alloc((heap), (size))\n#define DUK_ALLOC_ZEROED(heap,size)                     duk_heap_mem_alloc_zeroed((heap), (size))\n#define DUK_REALLOC(heap,ptr,newsize)                   duk_heap_mem_realloc((heap), (ptr), (newsize))\n#define DUK_REALLOC_INDIRECT(heap,cb,ud,newsize)        duk_heap_mem_realloc_indirect((heap), (cb), (ud), (newsize))\n#define DUK_FREE(heap,ptr)                              duk_heap_mem_free((heap), (ptr))\n\n/*\n *  Checked allocation, relative to a thread\n */\n\n#define DUK_ALLOC_CHECKED(thr,size)                     duk_heap_mem_alloc_checked((thr), (size))\n#define DUK_ALLOC_CHECKED_ZEROED(thr,size)              duk_heap_mem_alloc_checked_zeroed((thr), (size))\n\n/*\n *  Memory constants\n */\n\n#define DUK_HEAP_ALLOC_FAIL_MARKANDSWEEP_LIMIT           10  /* Retry allocation after mark-and-sweep for this\n                                                              * many times.  A single mark-and-sweep round is\n                                                              * not guaranteed to free all unreferenced memory\n                                                              * because of finalization (in fact, ANY number of\n                                                              * rounds is strictly not enough).\n                                                              */\n\n#define DUK_HEAP_ALLOC_FAIL_MARKANDSWEEP_EMERGENCY_LIMIT  3  /* Starting from this round, use emergency mode\n                                                              * for mark-and-sweep.\n                                                              */\n\n/*\n *  Debugger support\n */\n\n/* Maximum number of breakpoints.  Only breakpoints that are set are\n * consulted so increasing this has no performance impact.\n */\n#define DUK_HEAP_MAX_BREAKPOINTS          16\n\n/* Opcode interval for a Date-based status/peek rate limit check.  Only\n * relevant when debugger is attached.  Requesting a timestamp may be a\n * slow operation on some platforms so this shouldn't be too low.  On the\n * other hand a high value makes Duktape react to a pause request slowly.\n */\n#define DUK_HEAP_DBG_RATELIMIT_OPCODES    4000\n\n/* Milliseconds between status notify and transport peeks. */\n#define DUK_HEAP_DBG_RATELIMIT_MILLISECS  200\n\n/* Step types */\n#define DUK_STEP_TYPE_NONE  0\n#define DUK_STEP_TYPE_INTO  1\n#define DUK_STEP_TYPE_OVER  2\n#define DUK_STEP_TYPE_OUT   3\n\nstruct duk_breakpoint {\n\tduk_hstring *filename;\n\tduk_uint32_t line;\n};\n\n/*\n *  String cache should ideally be at duk_hthread level, but that would\n *  cause string finalization to slow down relative to the number of\n *  threads; string finalization must check the string cache for \"weak\"\n *  references to the string being finalized to avoid dead pointers.\n *\n *  Thus, string caches are now at the heap level now.\n */\n\nstruct duk_strcache {\n\tduk_hstring *h;\n\tduk_uint32_t bidx;\n\tduk_uint32_t cidx;\n};\n\n/*\n *  Longjmp state, contains the information needed to perform a longjmp.\n *  Longjmp related values are written to value1, value2, and iserror.\n */\n\nstruct duk_ljstate {\n\tduk_jmpbuf *jmpbuf_ptr;   /* current setjmp() catchpoint */\n\tduk_small_uint_t type;    /* longjmp type */\n\tduk_bool_t iserror;       /* isError flag for yield */\n\tduk_tval value1;          /* 1st related value (type specific) */\n\tduk_tval value2;          /* 2nd related value (type specific) */\n};\n\n#define DUK_ASSERT_LJSTATE_UNSET(heap) do { \\\n\t\tDUK_ASSERT(heap != NULL); \\\n\t\tDUK_ASSERT(heap->lj.type == DUK_LJ_TYPE_UNKNOWN); \\\n\t\tDUK_ASSERT(heap->lj.iserror == 0); \\\n\t\tDUK_ASSERT(DUK_TVAL_IS_UNDEFINED(&heap->lj.value1)); \\\n\t\tDUK_ASSERT(DUK_TVAL_IS_UNDEFINED(&heap->lj.value2)); \\\n\t} while (0)\n#define DUK_ASSERT_LJSTATE_SET(heap) do { \\\n\t\tDUK_ASSERT(heap != NULL); \\\n\t\tDUK_ASSERT(heap->lj.type != DUK_LJ_TYPE_UNKNOWN); \\\n\t} while (0)\n\n/*\n *  Main heap structure\n */\n\nstruct duk_heap {\n\tduk_small_uint_t flags;\n\n\t/* Allocator functions. */\n\tduk_alloc_function alloc_func;\n\tduk_realloc_function realloc_func;\n\tduk_free_function free_func;\n\n\t/* Heap udata, used for allocator functions but also for other heap\n\t * level callbacks like fatal function, pointer compression, etc.\n\t */\n\tvoid *heap_udata;\n\n\t/* Fatal error handling, called e.g. when a longjmp() is needed but\n\t * lj.jmpbuf_ptr is NULL.  fatal_func must never return; it's not\n\t * declared as \"noreturn\" because doing that for typedefs is a bit\n\t * challenging portability-wise.\n\t */\n\tduk_fatal_function fatal_func;\n\n\t/* Main list of allocated heap objects.  Objects are either here,\n\t * in finalize_list waiting for processing, or in refzero_list\n\t * temporarily while a DECREF refzero cascade finishes.\n\t */\n\tduk_heaphdr *heap_allocated;\n\n\t/* Temporary work list for freeing a cascade of objects when a DECREF\n\t * (or DECREF_NORZ) encounters a zero refcount.  Using a work list\n\t * allows fixed C stack size when refcounts go to zero for a chain of\n\t * objects.  Outside of DECREF this is always a NULL because DECREF is\n\t * processed without side effects (only memory free calls).\n\t */\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tduk_heaphdr *refzero_list;\n#endif\n\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n\t/* Work list for objects to be finalized. */\n\tduk_heaphdr *finalize_list;\n#if defined(DUK_USE_ASSERTIONS)\n\t/* Object whose finalizer is executing right now (no nesting). */\n\tduk_heaphdr *currently_finalizing;\n#endif\n#endif\n\n\t/* Voluntary mark-and-sweep trigger counter.  Intentionally signed\n\t * because we continue decreasing the value when voluntary GC cannot\n\t * run.\n\t */\n#if defined(DUK_USE_VOLUNTARY_GC)\n\tduk_int_t ms_trigger_counter;\n#endif\n\n\t/* Mark-and-sweep recursion control: too deep recursion causes\n\t * multi-pass processing to avoid growing C stack without bound.\n\t */\n\tduk_uint_t ms_recursion_depth;\n\n\t/* Mark-and-sweep flags automatically active (used for critical sections). */\n\tduk_small_uint_t ms_base_flags;\n\n\t/* Mark-and-sweep running flag.  Prevents re-entry, and also causes\n\t * refzero events to be ignored (= objects won't be queued to refzero_list).\n\t */\n\tduk_uint_t ms_running;\n\n\t/* Mark-and-sweep prevent count, stacking.  Used to avoid M&S side\n\t * effects (besides finalizers which are controlled separately) such\n\t * as compacting the string table or object property tables.  This\n\t * is also bumped when ms_running is set to prevent recursive re-entry.\n\t * Can also be bumped when mark-and-sweep is not running.\n\t */\n\tduk_uint_t ms_prevent_count;\n\n\t/* Finalizer processing prevent count, stacking.  Bumped when finalizers\n\t * are processed to prevent recursive finalizer processing (first call site\n\t * processing finalizers handles all finalizers until the list is empty).\n\t * Can also be bumped explicitly to prevent finalizer execution.\n\t */\n\tduk_uint_t pf_prevent_count;\n\n\t/* When processing finalize_list, don't actually run finalizers but\n\t * queue finalizable objects back to heap_allocated as is.  This is\n\t * used during heap destruction to deal with finalizers that keep\n\t * on creating more finalizable garbage.\n\t */\n\tduk_uint_t pf_skip_finalizers;\n\n#if defined(DUK_USE_ASSERTIONS)\n\t/* Set when we're in a critical path where an error throw would cause\n\t * e.g. sandboxing/protected call violations or state corruption.  This\n\t * is just used for asserts.\n\t */\n\tduk_bool_t error_not_allowed;\n#endif\n\n#if defined(DUK_USE_ASSERTIONS)\n\t/* Set when heap is still being initialized, helps with writing\n\t * some assertions.\n\t */\n\tduk_bool_t heap_initializing;\n#endif\n\n\t/* Marker for detecting internal \"double faults\", errors thrown when\n\t * we're trying to create an error object, see duk_error_throw.c.\n\t */\n\tduk_bool_t creating_error;\n\n\t/* Longjmp state. */\n\tduk_ljstate lj;\n\n\t/* Heap thread, used internally and for finalization. */\n\tduk_hthread *heap_thread;\n\n\t/* Current running thread. */\n\tduk_hthread *curr_thread;\n\n\t/* Heap level \"stash\" object (e.g., various reachability roots). */\n\tduk_hobject *heap_object;\n\n\t/* duk_handle_call / duk_handle_safe_call recursion depth limiting */\n\tduk_int_t call_recursion_depth;\n\tduk_int_t call_recursion_limit;\n\n\t/* Mix-in value for computing string hashes; should be reasonably unpredictable. */\n\tduk_uint32_t hash_seed;\n\n\t/* Random number state for duk_util_tinyrandom.c. */\n#if !defined(DUK_USE_GET_RANDOM_DOUBLE)\n#if defined(DUK_USE_PREFER_SIZE) || !defined(DUK_USE_64BIT_OPS)\n\tduk_uint32_t rnd_state;  /* State for Shamir's three-op algorithm */\n#else\n\tduk_uint64_t rnd_state[2];  /* State for xoroshiro128+ */\n#endif\n#endif\n\n\t/* Counter for unique local symbol creation. */\n\t/* XXX: When 64-bit types are available, it would be more efficient to\n\t * use a duk_uint64_t at least for incrementing but maybe also for\n\t * string formatting in the Symbol constructor.\n\t */\n\tduk_uint32_t sym_counter[2];\n\n\t/* For manual debugging: instruction count based on executor and\n\t * interrupt counter book-keeping.  Inspect debug logs to see how\n\t * they match up.\n\t */\n#if defined(DUK_USE_INTERRUPT_COUNTER) && defined(DUK_USE_DEBUG)\n\tduk_int_t inst_count_exec;\n\tduk_int_t inst_count_interrupt;\n#endif\n\n\t/* Debugger state. */\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\t/* Callbacks and udata; dbg_read_cb != NULL is used to indicate attached state. */\n\tduk_debug_read_function dbg_read_cb;                /* required, NULL implies detached */\n\tduk_debug_write_function dbg_write_cb;              /* required */\n\tduk_debug_peek_function dbg_peek_cb;\n\tduk_debug_read_flush_function dbg_read_flush_cb;\n\tduk_debug_write_flush_function dbg_write_flush_cb;\n\tduk_debug_request_function dbg_request_cb;\n\tduk_debug_detached_function dbg_detached_cb;\n\tvoid *dbg_udata;\n\n\t/* The following are only relevant when debugger is attached. */\n\tduk_bool_t dbg_processing;              /* currently processing messages or breakpoints: don't enter message processing recursively (e.g. no breakpoints when processing debugger eval) */\n\tduk_bool_t dbg_state_dirty;             /* resend state next time executor is about to run */\n\tduk_bool_t dbg_force_restart;           /* force executor restart to recheck breakpoints; used to handle function returns (see GH-303) */\n\tduk_bool_t dbg_detaching;               /* debugger detaching; used to avoid calling detach handler recursively */\n\tduk_small_uint_t dbg_step_type;         /* step type: none, step into, step over, step out */\n\tduk_hthread *dbg_step_thread;           /* borrowed; NULL if no step state (NULLed in unwind) */\n\tduk_size_t dbg_step_csindex;            /* callstack index */\n\tduk_uint32_t dbg_step_startline;        /* starting line number */\n\tduk_breakpoint dbg_breakpoints[DUK_HEAP_MAX_BREAKPOINTS];  /* breakpoints: [0,breakpoint_count[ gc reachable */\n\tduk_small_uint_t dbg_breakpoint_count;\n\tduk_breakpoint *dbg_breakpoints_active[DUK_HEAP_MAX_BREAKPOINTS + 1];  /* currently active breakpoints: NULL term, borrowed pointers */\n\t/* XXX: make active breakpoints actual copies instead of pointers? */\n\n\t/* These are for rate limiting Status notifications and transport peeking. */\n\tduk_uint32_t dbg_exec_counter;          /* cumulative opcode execution count (overflows are OK) */\n\tduk_uint32_t dbg_last_counter;          /* value of dbg_exec_counter when we last did a Date-based check */\n\tduk_double_t dbg_last_time;             /* time when status/peek was last done (Date-based rate limit) */\n\n\t/* Used to support single-byte stream lookahead. */\n\tduk_bool_t dbg_have_next_byte;\n\tduk_uint8_t dbg_next_byte;\n#endif\n\n\t/* String intern table (weak refs). */\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\tduk_uint16_t *strtable16;\n#else\n\tduk_hstring **strtable;\n#endif\n\tduk_uint32_t st_mask;    /* mask for lookup, st_size - 1 */\n\tduk_uint32_t st_size;    /* stringtable size */\n#if (DUK_USE_STRTAB_MINSIZE != DUK_USE_STRTAB_MAXSIZE)\n\tduk_uint32_t st_count;   /* string count for resize load factor checks */\n#endif\n\tduk_bool_t st_resizing;  /* string table is being resized; avoid recursive resize */\n\n\t/* String access cache (codepoint offset -> byte offset) for fast string\n\t * character looping; 'weak' reference which needs special handling in GC.\n\t */\n\tduk_strcache strcache[DUK_HEAP_STRCACHE_SIZE];\n\n\t/* Built-in strings. */\n#if defined(DUK_USE_ROM_STRINGS)\n\t/* No field needed when strings are in ROM. */\n#else\n#if defined(DUK_USE_HEAPPTR16)\n\tduk_uint16_t strs16[DUK_HEAP_NUM_STRINGS];\n#else\n\tduk_hstring *strs[DUK_HEAP_NUM_STRINGS];\n#endif\n#endif\n};\n\n/*\n *  Prototypes\n */\n\nDUK_INTERNAL_DECL\nduk_heap *duk_heap_alloc(duk_alloc_function alloc_func,\n                         duk_realloc_function realloc_func,\n                         duk_free_function free_func,\n                         void *heap_udata,\n                         duk_fatal_function fatal_func);\nDUK_INTERNAL_DECL void duk_heap_free(duk_heap *heap);\nDUK_INTERNAL_DECL void duk_free_hobject(duk_heap *heap, duk_hobject *h);\nDUK_INTERNAL_DECL void duk_free_hbuffer(duk_heap *heap, duk_hbuffer *h);\nDUK_INTERNAL_DECL void duk_free_hstring(duk_heap *heap, duk_hstring *h);\nDUK_INTERNAL_DECL void duk_heap_free_heaphdr_raw(duk_heap *heap, duk_heaphdr *hdr);\n\nDUK_INTERNAL_DECL void duk_heap_insert_into_heap_allocated(duk_heap *heap, duk_heaphdr *hdr);\n#if defined(DUK_USE_REFERENCE_COUNTING)\nDUK_INTERNAL_DECL void duk_heap_remove_from_heap_allocated(duk_heap *heap, duk_heaphdr *hdr);\n#endif\n#if defined(DUK_USE_FINALIZER_SUPPORT)\nDUK_INTERNAL_DECL void duk_heap_insert_into_finalize_list(duk_heap *heap, duk_heaphdr *hdr);\nDUK_INTERNAL_DECL void duk_heap_remove_from_finalize_list(duk_heap *heap, duk_heaphdr *hdr);\n#endif\n#if defined(DUK_USE_ASSERTIONS)\nDUK_INTERNAL_DECL duk_bool_t duk_heap_in_heap_allocated(duk_heap *heap, duk_heaphdr *ptr);\n#endif\n#if defined(DUK_USE_INTERRUPT_COUNTER)\nDUK_INTERNAL_DECL void duk_heap_switch_thread(duk_heap *heap, duk_hthread *new_thr);\n#endif\n\nDUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern(duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen);\nDUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern_checked(duk_hthread *thr, const duk_uint8_t *str, duk_uint32_t len);\nDUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern_u32(duk_heap *heap, duk_uint32_t val);\nDUK_INTERNAL_DECL duk_hstring *duk_heap_strtable_intern_u32_checked(duk_hthread *thr, duk_uint32_t val);\n#if defined(DUK_USE_REFERENCE_COUNTING)\nDUK_INTERNAL_DECL void duk_heap_strtable_unlink(duk_heap *heap, duk_hstring *h);\n#endif\nDUK_INTERNAL_DECL void duk_heap_strtable_unlink_prev(duk_heap *heap, duk_hstring *h, duk_hstring *prev);\nDUK_INTERNAL_DECL void duk_heap_strtable_force_resize(duk_heap *heap);\nDUK_INTERNAL void duk_heap_strtable_free(duk_heap *heap);\n#if defined(DUK_USE_DEBUG)\nDUK_INTERNAL void duk_heap_strtable_dump(duk_heap *heap);\n#endif\n\nDUK_INTERNAL_DECL void duk_heap_strcache_string_remove(duk_heap *heap, duk_hstring *h);\nDUK_INTERNAL_DECL duk_uint_fast32_t duk_heap_strcache_offset_char2byte(duk_hthread *thr, duk_hstring *h, duk_uint_fast32_t char_offset);\n\n#if defined(DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS)\nDUK_INTERNAL_DECL void *duk_default_alloc_function(void *udata, duk_size_t size);\nDUK_INTERNAL_DECL void *duk_default_realloc_function(void *udata, void *ptr, duk_size_t newsize);\nDUK_INTERNAL_DECL void duk_default_free_function(void *udata, void *ptr);\n#endif\n\nDUK_INTERNAL_DECL void *duk_heap_mem_alloc(duk_heap *heap, duk_size_t size);\nDUK_INTERNAL_DECL void *duk_heap_mem_alloc_zeroed(duk_heap *heap, duk_size_t size);\nDUK_INTERNAL_DECL void *duk_heap_mem_alloc_checked(duk_hthread *thr, duk_size_t size);\nDUK_INTERNAL_DECL void *duk_heap_mem_alloc_checked_zeroed(duk_hthread *thr, duk_size_t size);\nDUK_INTERNAL_DECL void *duk_heap_mem_realloc(duk_heap *heap, void *ptr, duk_size_t newsize);\nDUK_INTERNAL_DECL void *duk_heap_mem_realloc_indirect(duk_heap *heap, duk_mem_getptr cb, void *ud, duk_size_t newsize);\nDUK_INTERNAL_DECL void duk_heap_mem_free(duk_heap *heap, void *ptr);\n\n#if defined(DUK_USE_FINALIZER_SUPPORT)\nDUK_INTERNAL_DECL void duk_heap_run_finalizer(duk_heap *heap, duk_hobject *obj);\nDUK_INTERNAL_DECL void duk_heap_process_finalize_list(duk_heap *heap);\n#endif  /* DUK_USE_FINALIZER_SUPPORT */\n\nDUK_INTERNAL_DECL void duk_heap_mark_and_sweep(duk_heap *heap, duk_small_uint_t flags);\n\nDUK_INTERNAL_DECL duk_uint32_t duk_heap_hashstring(duk_heap *heap, const duk_uint8_t *str, duk_size_t len);\n\n#endif  /* DUK_HEAP_H_INCLUDED */\n/* #include duk_debugger.h */\n#if !defined(DUK_DEBUGGER_H_INCLUDED)\n#define DUK_DEBUGGER_H_INCLUDED\n\n/* Debugger protocol version is defined in the public API header. */\n\n/* Initial bytes for markers. */\n#define DUK_DBG_IB_EOM                   0x00\n#define DUK_DBG_IB_REQUEST               0x01\n#define DUK_DBG_IB_REPLY                 0x02\n#define DUK_DBG_IB_ERROR                 0x03\n#define DUK_DBG_IB_NOTIFY                0x04\n\n/* Other initial bytes. */\n#define DUK_DBG_IB_INT4                  0x10\n#define DUK_DBG_IB_STR4                  0x11\n#define DUK_DBG_IB_STR2                  0x12\n#define DUK_DBG_IB_BUF4                  0x13\n#define DUK_DBG_IB_BUF2                  0x14\n#define DUK_DBG_IB_UNUSED                0x15\n#define DUK_DBG_IB_UNDEFINED             0x16\n#define DUK_DBG_IB_NULL                  0x17\n#define DUK_DBG_IB_TRUE                  0x18\n#define DUK_DBG_IB_FALSE                 0x19\n#define DUK_DBG_IB_NUMBER                0x1a\n#define DUK_DBG_IB_OBJECT                0x1b\n#define DUK_DBG_IB_POINTER               0x1c\n#define DUK_DBG_IB_LIGHTFUNC             0x1d\n#define DUK_DBG_IB_HEAPPTR               0x1e\n/* The short string/integer initial bytes starting from 0x60 don't have\n * defines now.\n */\n\n/* Error codes. */\n#define DUK_DBG_ERR_UNKNOWN              0x00\n#define DUK_DBG_ERR_UNSUPPORTED          0x01\n#define DUK_DBG_ERR_TOOMANY              0x02\n#define DUK_DBG_ERR_NOTFOUND             0x03\n#define DUK_DBG_ERR_APPLICATION          0x04\n\n/* Commands and notifys initiated by Duktape. */\n#define DUK_DBG_CMD_STATUS               0x01\n#define DUK_DBG_CMD_UNUSED_2             0x02  /* Duktape 1.x: print notify */\n#define DUK_DBG_CMD_UNUSED_3             0x03  /* Duktape 1.x: alert notify */\n#define DUK_DBG_CMD_UNUSED_4             0x04  /* Duktape 1.x: log notify */\n#define DUK_DBG_CMD_THROW                0x05\n#define DUK_DBG_CMD_DETACHING            0x06\n#define DUK_DBG_CMD_APPNOTIFY            0x07\n\n/* Commands initiated by debug client. */\n#define DUK_DBG_CMD_BASICINFO            0x10\n#define DUK_DBG_CMD_TRIGGERSTATUS        0x11\n#define DUK_DBG_CMD_PAUSE                0x12\n#define DUK_DBG_CMD_RESUME               0x13\n#define DUK_DBG_CMD_STEPINTO             0x14\n#define DUK_DBG_CMD_STEPOVER             0x15\n#define DUK_DBG_CMD_STEPOUT              0x16\n#define DUK_DBG_CMD_LISTBREAK            0x17\n#define DUK_DBG_CMD_ADDBREAK             0x18\n#define DUK_DBG_CMD_DELBREAK             0x19\n#define DUK_DBG_CMD_GETVAR               0x1a\n#define DUK_DBG_CMD_PUTVAR               0x1b\n#define DUK_DBG_CMD_GETCALLSTACK         0x1c\n#define DUK_DBG_CMD_GETLOCALS            0x1d\n#define DUK_DBG_CMD_EVAL                 0x1e\n#define DUK_DBG_CMD_DETACH               0x1f\n#define DUK_DBG_CMD_DUMPHEAP             0x20\n#define DUK_DBG_CMD_GETBYTECODE          0x21\n#define DUK_DBG_CMD_APPREQUEST           0x22\n#define DUK_DBG_CMD_GETHEAPOBJINFO       0x23\n#define DUK_DBG_CMD_GETOBJPROPDESC       0x24\n#define DUK_DBG_CMD_GETOBJPROPDESCRANGE  0x25\n\n/* The low 8 bits map directly to duk_hobject.h DUK_PROPDESC_FLAG_xxx.\n * The remaining flags are specific to the debugger.\n */\n#define DUK_DBG_PROPFLAG_SYMBOL          (1 << 8)\n#define DUK_DBG_PROPFLAG_HIDDEN          (1 << 9)\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\nDUK_INTERNAL_DECL void duk_debug_do_detach(duk_heap *heap);\n\nDUK_INTERNAL_DECL duk_bool_t duk_debug_read_peek(duk_hthread *thr);\nDUK_INTERNAL_DECL void duk_debug_write_flush(duk_hthread *thr);\n\nDUK_INTERNAL_DECL void duk_debug_skip_bytes(duk_hthread *thr, duk_size_t length);\nDUK_INTERNAL_DECL void duk_debug_skip_byte(duk_hthread *thr);\n\nDUK_INTERNAL_DECL void duk_debug_read_bytes(duk_hthread *thr, duk_uint8_t *data, duk_size_t length);\nDUK_INTERNAL_DECL duk_uint8_t duk_debug_read_byte(duk_hthread *thr);\nDUK_INTERNAL_DECL duk_int32_t duk_debug_read_int(duk_hthread *thr);\nDUK_INTERNAL_DECL duk_hstring *duk_debug_read_hstring(duk_hthread *thr);\n/* XXX: exposed duk_debug_read_pointer */\n/* XXX: exposed duk_debug_read_buffer */\n/* XXX: exposed duk_debug_read_hbuffer */\n#if 0\nDUK_INTERNAL_DECL duk_heaphdr *duk_debug_read_heapptr(duk_hthread *thr);\n#endif\n#if defined(DUK_USE_DEBUGGER_INSPECT)\nDUK_INTERNAL_DECL duk_heaphdr *duk_debug_read_any_ptr(duk_hthread *thr);\n#endif\nDUK_INTERNAL_DECL duk_tval *duk_debug_read_tval(duk_hthread *thr);\n\nDUK_INTERNAL_DECL void duk_debug_write_bytes(duk_hthread *thr, const duk_uint8_t *data, duk_size_t length);\nDUK_INTERNAL_DECL void duk_debug_write_byte(duk_hthread *thr, duk_uint8_t x);\nDUK_INTERNAL_DECL void duk_debug_write_unused(duk_hthread *thr);\nDUK_INTERNAL_DECL void duk_debug_write_undefined(duk_hthread *thr);\n#if defined(DUK_USE_DEBUGGER_INSPECT)\nDUK_INTERNAL_DECL void duk_debug_write_null(duk_hthread *thr);\n#endif\nDUK_INTERNAL_DECL void duk_debug_write_boolean(duk_hthread *thr, duk_uint_t val);\nDUK_INTERNAL_DECL void duk_debug_write_int(duk_hthread *thr, duk_int32_t x);\nDUK_INTERNAL_DECL void duk_debug_write_uint(duk_hthread *thr, duk_uint32_t x);\nDUK_INTERNAL_DECL void duk_debug_write_string(duk_hthread *thr, const char *data, duk_size_t length);\nDUK_INTERNAL_DECL void duk_debug_write_cstring(duk_hthread *thr, const char *data);\nDUK_INTERNAL_DECL void duk_debug_write_hstring(duk_hthread *thr, duk_hstring *h);\nDUK_INTERNAL_DECL void duk_debug_write_buffer(duk_hthread *thr, const char *data, duk_size_t length);\nDUK_INTERNAL_DECL void duk_debug_write_hbuffer(duk_hthread *thr, duk_hbuffer *h);\nDUK_INTERNAL_DECL void duk_debug_write_pointer(duk_hthread *thr, void *ptr);\n#if defined(DUK_USE_DEBUGGER_DUMPHEAP) || defined(DUK_USE_DEBUGGER_INSPECT)\nDUK_INTERNAL_DECL void duk_debug_write_heapptr(duk_hthread *thr, duk_heaphdr *h);\n#endif\nDUK_INTERNAL_DECL void duk_debug_write_hobject(duk_hthread *thr, duk_hobject *obj);\nDUK_INTERNAL_DECL void duk_debug_write_tval(duk_hthread *thr, duk_tval *tv);\n#if 0  /* unused */\nDUK_INTERNAL_DECL void duk_debug_write_request(duk_hthread *thr, duk_small_uint_t command);\n#endif\nDUK_INTERNAL_DECL void duk_debug_write_reply(duk_hthread *thr);\nDUK_INTERNAL_DECL void duk_debug_write_error_eom(duk_hthread *thr, duk_small_uint_t err_code, const char *msg);\nDUK_INTERNAL_DECL void duk_debug_write_notify(duk_hthread *thr, duk_small_uint_t command);\nDUK_INTERNAL_DECL void duk_debug_write_eom(duk_hthread *thr);\n\nDUK_INTERNAL_DECL duk_uint_fast32_t duk_debug_curr_line(duk_hthread *thr);\nDUK_INTERNAL_DECL void duk_debug_send_status(duk_hthread *thr);\n#if defined(DUK_USE_DEBUGGER_THROW_NOTIFY)\nDUK_INTERNAL_DECL void duk_debug_send_throw(duk_hthread *thr, duk_bool_t fatal);\n#endif\n\nDUK_INTERNAL_DECL void duk_debug_halt_execution(duk_hthread *thr, duk_bool_t use_prev_pc);\nDUK_INTERNAL_DECL duk_bool_t duk_debug_process_messages(duk_hthread *thr, duk_bool_t no_block);\n\nDUK_INTERNAL_DECL duk_small_int_t duk_debug_add_breakpoint(duk_hthread *thr, duk_hstring *filename, duk_uint32_t line);\nDUK_INTERNAL_DECL duk_bool_t duk_debug_remove_breakpoint(duk_hthread *thr, duk_small_uint_t breakpoint_index);\n\nDUK_INTERNAL_DECL duk_bool_t duk_debug_is_attached(duk_heap *heap);\nDUK_INTERNAL_DECL duk_bool_t duk_debug_is_paused(duk_heap *heap);\nDUK_INTERNAL_DECL void duk_debug_set_paused(duk_heap *heap);\nDUK_INTERNAL_DECL void duk_debug_clear_paused(duk_heap *heap);\nDUK_INTERNAL_DECL void duk_debug_clear_step_state(duk_heap *heap);\n#endif  /* DUK_USE_DEBUGGER_SUPPORT */\n\n#endif  /* DUK_DEBUGGER_H_INCLUDED */\n/* #include duk_debug.h */\n/*\n *  Debugging macros, DUK_DPRINT() and its variants in particular.\n *\n *  DUK_DPRINT() allows formatted debug prints, and supports standard\n *  and Duktape specific formatters.  See duk_debug_vsnprintf.c for details.\n *\n *  DUK_D(x), DUK_DD(x), and DUK_DDD(x) are used together with log macros\n *  for technical reasons.  They are concretely used to hide 'x' from the\n *  compiler when the corresponding log level is disabled.  This allows\n *  clean builds on non-C99 compilers, at the cost of more verbose code.\n *  Examples:\n *\n *    DUK_D(DUK_DPRINT(\"foo\"));\n *    DUK_DD(DUK_DDPRINT(\"foo\"));\n *    DUK_DDD(DUK_DDDPRINT(\"foo\"));\n *\n *  This approach is preferable to the old \"double parentheses\" hack because\n *  double parentheses make the C99 solution worse: __FILE__ and __LINE__ can\n *  no longer be added transparently without going through globals, which\n *  works poorly with threading.\n */\n\n#if !defined(DUK_DEBUG_H_INCLUDED)\n#define DUK_DEBUG_H_INCLUDED\n\n#if defined(DUK_USE_DEBUG)\n\n#if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 0)\n#define DUK_D(x) x\n#else\n#define DUK_D(x) do { } while (0) /* omit */\n#endif\n\n#if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 1)\n#define DUK_DD(x) x\n#else\n#define DUK_DD(x) do { } while (0) /* omit */\n#endif\n\n#if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 2)\n#define DUK_DDD(x) x\n#else\n#define DUK_DDD(x) do { } while (0) /* omit */\n#endif\n\n/*\n *  Exposed debug macros: debugging enabled\n */\n\n#if defined(DUK_USE_VARIADIC_MACROS)\n\n/* Note: combining __FILE__, __LINE__, and __func__ into fmt would be\n * possible compile time, but waste some space with shared function names.\n */\n#define DUK__DEBUG_LOG(lev,...)  duk_debug_log((duk_int_t) (lev), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO, DUK_FUNC_MACRO, __VA_ARGS__);\n\n#if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 0)\n#define DUK_DPRINT(...)          DUK__DEBUG_LOG(DUK_LEVEL_DEBUG, __VA_ARGS__)\n#else\n#define DUK_DPRINT(...)\n#endif\n\n#if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 1)\n#define DUK_DDPRINT(...)         DUK__DEBUG_LOG(DUK_LEVEL_DDEBUG, __VA_ARGS__)\n#else\n#define DUK_DDPRINT(...)\n#endif\n\n#if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 2)\n#define DUK_DDDPRINT(...)        DUK__DEBUG_LOG(DUK_LEVEL_DDDEBUG, __VA_ARGS__)\n#else\n#define DUK_DDDPRINT(...)\n#endif\n\n#else  /* DUK_USE_VARIADIC_MACROS */\n\n#define DUK__DEBUG_STASH(lev)    \\\n\t(void) DUK_SNPRINTF(duk_debug_file_stash, DUK_DEBUG_STASH_SIZE, \"%s\", (const char *) DUK_FILE_MACRO), \\\n\t(void) (duk_debug_file_stash[DUK_DEBUG_STASH_SIZE - 1] = (char) 0), \\\n\t(void) (duk_debug_line_stash = (duk_int_t) DUK_LINE_MACRO), \\\n\t(void) DUK_SNPRINTF(duk_debug_func_stash, DUK_DEBUG_STASH_SIZE, \"%s\", (const char *) DUK_FUNC_MACRO), \\\n\t(void) (duk_debug_func_stash[DUK_DEBUG_STASH_SIZE - 1] = (char) 0), \\\n\t(void) (duk_debug_level_stash = (lev))\n\n/* Without variadic macros resort to comma expression trickery to handle debug\n * prints.  This generates a lot of harmless warnings.  These hacks are not\n * needed normally because DUK_D() and friends will hide the entire debug log\n * statement from the compiler.\n */\n\n#if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 0)\n#define DUK_DPRINT  DUK__DEBUG_STASH(DUK_LEVEL_DEBUG), (void) duk_debug_log  /* args go here in parens */\n#else\n#define DUK_DPRINT  0 && /* args go here as a comma expression in parens */\n#endif\n\n#if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 1)\n#define DUK_DDPRINT  DUK__DEBUG_STASH(DUK_LEVEL_DDEBUG), (void) duk_debug_log  /* args go here in parens */\n#else\n#define DUK_DDPRINT  0 && /* args */\n#endif\n\n#if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 2)\n#define DUK_DDDPRINT  DUK__DEBUG_STASH(DUK_LEVEL_DDDEBUG), (void) duk_debug_log  /* args go here in parens */\n#else\n#define DUK_DDDPRINT  0 && /* args */\n#endif\n\n#endif  /* DUK_USE_VARIADIC_MACROS */\n\n#else  /* DUK_USE_DEBUG */\n\n/*\n *  Exposed debug macros: debugging disabled\n */\n\n#define DUK_D(x) do { } while (0) /* omit */\n#define DUK_DD(x) do { } while (0) /* omit */\n#define DUK_DDD(x) do { } while (0) /* omit */\n\n#if defined(DUK_USE_VARIADIC_MACROS)\n\n#define DUK_DPRINT(...)\n#define DUK_DDPRINT(...)\n#define DUK_DDDPRINT(...)\n\n#else  /* DUK_USE_VARIADIC_MACROS */\n\n#define DUK_DPRINT    0 && /* args go here as a comma expression in parens */\n#define DUK_DDPRINT   0 && /* args */\n#define DUK_DDDPRINT  0 && /* args */\n\n#endif  /* DUK_USE_VARIADIC_MACROS */\n\n#endif  /* DUK_USE_DEBUG */\n\n/*\n *  Structs\n */\n\n#if defined(DUK_USE_DEBUG)\nstruct duk_fixedbuffer {\n\tduk_uint8_t *buffer;\n\tduk_size_t length;\n\tduk_size_t offset;\n\tduk_bool_t truncated;\n};\n#endif\n\n/*\n *  Prototypes\n */\n\n#if defined(DUK_USE_DEBUG)\nDUK_INTERNAL_DECL duk_int_t duk_debug_vsnprintf(char *str, duk_size_t size, const char *format, va_list ap);\n#if 0  /*unused*/\nDUK_INTERNAL_DECL duk_int_t duk_debug_snprintf(char *str, duk_size_t size, const char *format, ...);\n#endif\nDUK_INTERNAL_DECL void duk_debug_format_funcptr(char *buf, duk_size_t buf_size, duk_uint8_t *fptr, duk_size_t fptr_size);\n\n#if defined(DUK_USE_VARIADIC_MACROS)\nDUK_INTERNAL_DECL void duk_debug_log(duk_int_t level, const char *file, duk_int_t line, const char *func, const char *fmt, ...);\n#else  /* DUK_USE_VARIADIC_MACROS */\n/* parameter passing, not thread safe */\n#define DUK_DEBUG_STASH_SIZE  128\n#if !defined(DUK_SINGLE_FILE)\nDUK_INTERNAL_DECL char duk_debug_file_stash[DUK_DEBUG_STASH_SIZE];\nDUK_INTERNAL_DECL duk_int_t duk_debug_line_stash;\nDUK_INTERNAL_DECL char duk_debug_func_stash[DUK_DEBUG_STASH_SIZE];\nDUK_INTERNAL_DECL duk_int_t duk_debug_level_stash;\n#endif\nDUK_INTERNAL_DECL void duk_debug_log(const char *fmt, ...);\n#endif  /* DUK_USE_VARIADIC_MACROS */\n\nDUK_INTERNAL_DECL void duk_fb_put_bytes(duk_fixedbuffer *fb, const duk_uint8_t *buffer, duk_size_t length);\nDUK_INTERNAL_DECL void duk_fb_put_byte(duk_fixedbuffer *fb, duk_uint8_t x);\nDUK_INTERNAL_DECL void duk_fb_put_cstring(duk_fixedbuffer *fb, const char *x);\nDUK_INTERNAL_DECL void duk_fb_sprintf(duk_fixedbuffer *fb, const char *fmt, ...);\nDUK_INTERNAL_DECL void duk_fb_put_funcptr(duk_fixedbuffer *fb, duk_uint8_t *fptr, duk_size_t fptr_size);\nDUK_INTERNAL_DECL duk_bool_t duk_fb_is_full(duk_fixedbuffer *fb);\n\n#endif  /* DUK_USE_DEBUG */\n\n#endif  /* DUK_DEBUG_H_INCLUDED */\n/* #include duk_error.h */\n/*\n *  Error handling macros, assertion macro, error codes.\n *\n *  There are three types of 'errors':\n *\n *    1. Ordinary errors relative to a thread, cause a longjmp, catchable.\n *    2. Fatal errors relative to a heap, cause fatal handler to be called.\n *    3. Fatal errors without context, cause the default (not heap specific)\n *       fatal handler to be called.\n *\n *  Fatal errors without context are used by debug code such as assertions.\n *  By providing a fatal error handler for a Duktape heap, user code can\n *  avoid fatal errors without context in non-debug builds.\n */\n\n#if !defined(DUK_ERROR_H_INCLUDED)\n#define DUK_ERROR_H_INCLUDED\n\n/*\n *  Error codes: defined in duktape.h\n *\n *  Error codes are used as a shorthand to throw exceptions from inside\n *  the implementation.  The appropriate Ecmascript object is constructed\n *  based on the code.  Ecmascript code throws objects directly.  The error\n *  codes are defined in the public API header because they are also used\n *  by calling code.\n */\n\n/*\n *  Normal error\n *\n *  Normal error is thrown with a longjmp() through the current setjmp()\n *  catchpoint record in the duk_heap.  The 'curr_thread' of the duk_heap\n *  identifies the throwing thread.\n *\n *  Error formatting is usually unnecessary.  The error macros provide a\n *  zero argument version (no formatting) and separate macros for small\n *  argument counts.  Variadic macros are not used to avoid portability\n *  issues and avoid the need for stash-based workarounds when they're not\n *  available.  Vararg calls are avoided for non-formatted error calls\n *  because vararg call sites are larger than normal, and there are a lot\n *  of call sites with no formatting.\n *\n *  Note that special formatting provided by debug macros is NOT available.\n *\n *  The _RAW variants allow the caller to specify file and line.  This makes\n *  it easier to write checked calls which want to use the call site of the\n *  checked function, not the error macro call inside the checked function.\n */\n\n#if defined(DUK_USE_VERBOSE_ERRORS)\n\n/* Because there are quite many call sites, pack error code (require at most\n * 8-bit) into a single argument.\n */\n#define DUK_ERROR(thr,err,msg) do { \\\n\t\tduk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) DUK_LINE_MACRO; \\\n\t\tDUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \\\n\t\tduk_err_handle_error((thr), DUK_FILE_MACRO, (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (msg)); \\\n\t} while (0)\n#define DUK_ERROR_RAW(thr,file,line,err,msg) do { \\\n\t\tduk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) (line); \\\n\t\tDUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \\\n\t\tduk_err_handle_error((thr), (file), (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (msg)); \\\n\t} while (0)\n\n#define DUK_ERROR_FMT1(thr,err,fmt,arg1) do { \\\n\t\tduk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) DUK_LINE_MACRO; \\\n\t\tDUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \\\n\t\tduk_err_handle_error_fmt((thr), DUK_FILE_MACRO, (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (fmt), (arg1)); \\\n\t} while (0)\n#define DUK_ERROR_RAW_FMT1(thr,file,line,err,fmt,arg1) do { \\\n\t\tduk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) (line); \\\n\t\tDUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \\\n\t\tduk_err_handle_error_fmt((thr), (file), (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (fmt), (arg1)); \\\n\t} while (0)\n\n#define DUK_ERROR_FMT2(thr,err,fmt,arg1,arg2) do { \\\n\t\tduk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) DUK_LINE_MACRO; \\\n\t\tDUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \\\n\t\tduk_err_handle_error_fmt((thr), DUK_FILE_MACRO, (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (fmt), (arg1), (arg2)); \\\n\t} while (0)\n#define DUK_ERROR_RAW_FMT2(thr,file,line,err,fmt,arg1,arg2) do { \\\n\t\tduk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) (line); \\\n\t\tDUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \\\n\t\tduk_err_handle_error_fmt((thr), (file), (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (fmt), (arg1), (arg2)); \\\n\t} while (0)\n\n#define DUK_ERROR_FMT3(thr,err,fmt,arg1,arg2,arg3) do { \\\n\t\tduk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) DUK_LINE_MACRO; \\\n\t\tDUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \\\n\t\tduk_err_handle_error_fmt((thr), DUK_FILE_MACRO, (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (fmt), (arg1), (arg2), (arg3)); \\\n\t} while (0)\n#define DUK_ERROR_RAW_FMT3(thr,file,line,err,fmt,arg1,arg2,arg3) do { \\\n\t\tduk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) (line); \\\n\t\tDUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \\\n\t\tduk_err_handle_error_fmt((thr), (file), (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (fmt), (arg1), (arg2), (arg3)); \\\n\t} while (0)\n\n#define DUK_ERROR_FMT4(thr,err,fmt,arg1,arg2,arg3,arg4) do { \\\n\t\tduk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) DUK_LINE_MACRO; \\\n\t\tDUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \\\n\t\tduk_err_handle_error_fmt((thr), DUK_FILE_MACRO, (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (fmt), (arg1), (arg2), (arg3), (arg4)); \\\n\t} while (0)\n#define DUK_ERROR_RAW_FMT4(thr,file,line,err,fmt,arg1,arg2,arg3,arg4) do { \\\n\t\tduk_errcode_t duk__err = (err); duk_int_t duk__line = (duk_int_t) (line); \\\n\t\tDUK_ASSERT(duk__err >= 0 && duk__err <= 0xff); DUK_ASSERT(duk__line >= 0 && duk__line <= 0x00ffffffL); \\\n\t\tduk_err_handle_error_fmt((thr), (file), (((duk_uint_t) duk__err) << 24) | ((duk_uint_t) duk__line), (fmt), (arg1), (arg2), (arg3), (arg4)); \\\n\t} while (0)\n\n#else  /* DUK_USE_VERBOSE_ERRORS */\n\n#define DUK_ERROR(thr,err,msg)                    duk_err_handle_error((thr), (err))\n#define DUK_ERROR_RAW(thr,file,line,err,msg)      duk_err_handle_error((thr), (err))\n\n#define DUK_ERROR_FMT1(thr,err,fmt,arg1) DUK_ERROR((thr),(err),(fmt))\n#define DUK_ERROR_RAW_FMT1(thr,file,line,err,fmt,arg1) DUK_ERROR_RAW((thr),(file),(line),(err),(fmt))\n\n#define DUK_ERROR_FMT2(thr,err,fmt,arg1,arg2) DUK_ERROR((thr),(err),(fmt))\n#define DUK_ERROR_RAW_FMT2(thr,file,line,err,fmt,arg1,arg2) DUK_ERROR_RAW((thr),(file),(line),(err),(fmt))\n\n#define DUK_ERROR_FMT3(thr,err,fmt,arg1,arg2,arg3) DUK_ERROR((thr),(err),(fmt))\n#define DUK_ERROR_RAW_FMT3(thr,file,line,err,fmt,arg1,arg2,arg3) DUK_ERROR_RAW((thr),(file),(line),(err),(fmt))\n\n#define DUK_ERROR_FMT4(thr,err,fmt,arg1,arg2,arg3,arg4) DUK_ERROR((thr),(err),(fmt))\n#define DUK_ERROR_RAW_FMT4(thr,file,line,err,fmt,arg1,arg2,arg3,arg4) DUK_ERROR_RAW((thr),(file),(line),(err),(fmt))\n\n#endif  /* DUK_USE_VERBOSE_ERRORS */\n\n/*\n *  Fatal error without context\n *\n *  The macro is an expression to make it compatible with DUK_ASSERT_EXPR().\n */\n\n#define DUK_FATAL_WITHOUT_CONTEXT(msg) \\\n\tduk_default_fatal_handler(NULL, (msg))\n\n/*\n *  Error throwing helpers\n *\n *  The goal is to provide verbose and configurable error messages.  Call\n *  sites should be clean in source code and compile to a small footprint.\n *  Small footprint is also useful for performance because small cold paths\n *  reduce code cache pressure.  Adding macros here only makes sense if there\n *  are enough call sites to get concrete benefits.\n *\n *  DUK_ERROR_xxx() macros are generic and can be used anywhere.\n *\n *  DUK_DCERROR_xxx() macros can only be used in Duktape/C functions where\n *  the \"return DUK_RET_xxx;\" shorthand is available for low memory targets.\n *  The DUK_DCERROR_xxx() macros always either throw or perform a\n *  'return DUK_RET_xxx' from the calling function.\n */\n\n#if defined(DUK_USE_VERBOSE_ERRORS)\n/* Verbose errors with key/value summaries (non-paranoid) or without key/value\n * summaries (paranoid, for some security sensitive environments), the paranoid\n * vs. non-paranoid distinction affects only a few specific errors.\n */\n#if defined(DUK_USE_PARANOID_ERRORS)\n#define DUK_ERROR_REQUIRE_TYPE_INDEX(thr,idx,expectname,lowmemstr) do { \\\n\t\tduk_err_require_type_index((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO, (idx), (expectname)); \\\n\t} while (0)\n#else  /* DUK_USE_PARANOID_ERRORS */\n#define DUK_ERROR_REQUIRE_TYPE_INDEX(thr,idx,expectname,lowmemstr) do { \\\n\t\tduk_err_require_type_index((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO, (idx), (expectname)); \\\n\t} while (0)\n#endif  /* DUK_USE_PARANOID_ERRORS */\n\n#define DUK_ERROR_INTERNAL(thr) do { \\\n\t\tduk_err_error_internal((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO); \\\n\t} while (0)\n#define DUK_ERROR_ALLOC_FAILED(thr) do { \\\n\t\tduk_err_error_alloc_failed((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO); \\\n\t} while (0)\n#define DUK_ERROR_UNSUPPORTED(thr) do { \\\n\t\tDUK_ERROR((thr), DUK_ERR_ERROR, DUK_STR_UNSUPPORTED); \\\n\t} while (0)\n#define DUK_ERROR_ERROR(thr,msg) do { \\\n\t\tduk_err_error((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO, (msg)); \\\n\t} while (0)\n#define DUK_ERROR_RANGE_INDEX(thr,idx) do { \\\n\t\tduk_err_range_index((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO, (idx)); \\\n\t} while (0)\n#define DUK_ERROR_RANGE_PUSH_BEYOND(thr) do { \\\n\t\tduk_err_range_push_beyond((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO); \\\n\t} while (0)\n#define DUK_ERROR_RANGE_INVALID_ARGS(thr) do { \\\n\t\tDUK_ERROR_RANGE((thr), DUK_STR_INVALID_ARGS); \\\n\t} while (0)\n#define DUK_DCERROR_RANGE_INVALID_ARGS(thr) do { \\\n\t\tDUK_ERROR_RANGE_INVALID_ARGS((thr)); \\\n\t\treturn 0; \\\n\t} while (0)\n#define DUK_ERROR_RANGE_INVALID_COUNT(thr) do { \\\n\t\tDUK_ERROR_RANGE((thr), DUK_STR_INVALID_COUNT); \\\n\t} while (0)\n#define DUK_ERROR_RANGE_INVALID_LENGTH(thr) do { \\\n\t\tDUK_ERROR_RANGE((thr), DUK_STR_INVALID_LENGTH); \\\n\t} while (0)\n#define DUK_DCERROR_RANGE_INVALID_LENGTH(thr) do { \\\n\t\tDUK_ERROR_RANGE_INVALID_LENGTH((thr)); \\\n\t\treturn 0; \\\n\t} while (0)\n#define DUK_ERROR_RANGE(thr,msg) do { \\\n\t\tduk_err_range((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO, (msg)); \\\n\t} while (0)\n#define DUK_ERROR_EVAL(thr,msg) do { \\\n\t\tDUK_ERROR((thr), DUK_ERR_EVAL_ERROR, (msg)); \\\n\t} while (0)\n#define DUK_ERROR_REFERENCE(thr,msg) do { \\\n\t\tDUK_ERROR((thr), DUK_ERR_REFERENCE_ERROR, (msg)); \\\n\t} while (0)\n#define DUK_ERROR_SYNTAX(thr,msg) do { \\\n\t\tDUK_ERROR((thr), DUK_ERR_SYNTAX_ERROR, (msg)); \\\n\t} while (0)\n#define DUK_ERROR_TYPE_INVALID_ARGS(thr) do { \\\n\t\tduk_err_type_invalid_args((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO); \\\n\t} while (0)\n#define DUK_DCERROR_TYPE_INVALID_ARGS(thr) do { \\\n\t\tDUK_ERROR_TYPE_INVALID_ARGS((thr)); \\\n\t\treturn 0; \\\n\t} while (0)\n#define DUK_ERROR_TYPE_INVALID_STATE(thr) do { \\\n\t\tduk_err_type_invalid_state((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO); \\\n\t} while (0)\n#define DUK_DCERROR_TYPE_INVALID_STATE(thr) do { \\\n\t\tDUK_ERROR_TYPE_INVALID_STATE((thr)); \\\n\t\treturn 0; \\\n\t} while (0)\n#define DUK_ERROR_TYPE_INVALID_TRAP_RESULT(thr) do { \\\n\t\tduk_err_type_invalid_trap_result((thr), DUK_FILE_MACRO, (duk_int_t) DUK_LINE_MACRO); \\\n\t} while (0)\n#define DUK_DCERROR_TYPE_INVALID_TRAP_RESULT(thr) do { \\\n\t\tDUK_ERROR_TYPE((thr), DUK_STR_INVALID_TRAP_RESULT); \\\n\t} while (0)\n#define DUK_ERROR_TYPE(thr,msg) do { \\\n\t\tDUK_ERROR((thr), DUK_ERR_TYPE_ERROR, (msg)); \\\n\t} while (0)\n#define DUK_ERROR_URI(thr,msg) do { \\\n\t\tDUK_ERROR((thr), DUK_ERR_URI_ERROR, (msg)); \\\n\t} while (0)\n#else  /* DUK_USE_VERBOSE_ERRORS */\n/* Non-verbose errors for low memory targets: no file, line, or message. */\n\n#define DUK_ERROR_REQUIRE_TYPE_INDEX(thr,idx,expectname,lowmemstr) do { \\\n\t\tduk_err_type((thr)); \\\n\t} while (0)\n\n#define DUK_ERROR_INTERNAL(thr) do { \\\n\t\tduk_err_error((thr)); \\\n\t} while (0)\n#define DUK_ERROR_ALLOC_FAILED(thr) do { \\\n\t\tduk_err_error((thr)); \\\n\t} while (0)\n#define DUK_ERROR_UNSUPPORTED(thr) do { \\\n\t\tduk_err_error((thr)); \\\n\t} while (0)\n#define DUK_ERROR_ERROR(thr,msg) do { \\\n\t\tduk_err_error((thr)); \\\n\t} while (0)\n#define DUK_ERROR_RANGE_INDEX(thr,idx) do { \\\n\t\tduk_err_range((thr)); \\\n\t} while (0)\n#define DUK_ERROR_RANGE_PUSH_BEYOND(thr) do { \\\n\t\tduk_err_range((thr)); \\\n\t} while (0)\n#define DUK_ERROR_RANGE_INVALID_ARGS(thr) do { \\\n\t\tduk_err_range((thr)); \\\n\t} while (0)\n#define DUK_DCERROR_RANGE_INVALID_ARGS(thr) do { \\\n\t\tDUK_UNREF((thr)); \\\n\t\treturn DUK_RET_RANGE_ERROR; \\\n\t} while (0)\n#define DUK_ERROR_RANGE_INVALID_COUNT(thr) do { \\\n\t\tduk_err_range((thr)); \\\n\t} while (0)\n#define DUK_ERROR_RANGE_INVALID_LENGTH(thr) do { \\\n\t\tduk_err_range((thr)); \\\n\t} while (0)\n#define DUK_DCERROR_RANGE_INVALID_LENGTH(thr) do { \\\n\t\tDUK_UNREF((thr)); \\\n\t\treturn DUK_RET_RANGE_ERROR; \\\n\t} while (0)\n#define DUK_ERROR_RANGE(thr,msg) do { \\\n\t\tduk_err_range((thr)); \\\n\t} while (0)\n#define DUK_ERROR_EVAL(thr,msg) do { \\\n\t\tduk_err_eval((thr)); \\\n\t} while (0)\n#define DUK_ERROR_REFERENCE(thr,msg) do { \\\n\t\tduk_err_reference((thr)); \\\n\t} while (0)\n#define DUK_ERROR_SYNTAX(thr,msg) do { \\\n\t\tduk_err_syntax((thr)); \\\n\t} while (0)\n#define DUK_ERROR_TYPE_INVALID_ARGS(thr) do { \\\n\t\tduk_err_type((thr)); \\\n\t} while (0)\n#define DUK_DCERROR_TYPE_INVALID_ARGS(thr) do { \\\n\t\tDUK_UNREF((thr)); \\\n\t\treturn DUK_RET_TYPE_ERROR; \\\n\t} while (0)\n#define DUK_ERROR_TYPE_INVALID_STATE(thr) do { \\\n\t\tduk_err_type((thr)); \\\n\t} while (0)\n#define DUK_DCERROR_TYPE_INVALID_STATE(thr) do { \\\n\t\tduk_err_type((thr)); \\\n\t} while (0)\n#define DUK_ERROR_TYPE_INVALID_TRAP_RESULT(thr) do { \\\n\t\tduk_err_type((thr)); \\\n\t} while (0)\n#define DUK_DCERROR_TYPE_INVALID_TRAP_RESULT(thr) do { \\\n\t\tDUK_UNREF((thr)); \\\n\t\treturn DUK_RET_TYPE_ERROR; \\\n\t} while (0)\n#define DUK_ERROR_TYPE_INVALID_TRAP_RESULT(thr) do { \\\n\t\tduk_err_type((thr)); \\\n\t} while (0)\n#define DUK_ERROR_TYPE(thr,msg) do { \\\n\t\tduk_err_type((thr)); \\\n\t} while (0)\n#define DUK_ERROR_URI(thr,msg) do { \\\n\t\tduk_err_uri((thr)); \\\n\t} while (0)\n#endif  /* DUK_USE_VERBOSE_ERRORS */\n\n/*\n *  Assert macro: failure causes a fatal error.\n *\n *  NOTE: since the assert macro doesn't take a heap/context argument, there's\n *  no way to look up a heap/context specific fatal error handler which may have\n *  been given by the application.  Instead, assertion failures always use the\n *  internal default fatal error handler; it can be replaced via duk_config.h\n *  and then applies to all Duktape heaps.\n */\n\n#if defined(DUK_USE_ASSERTIONS)\n\n/* The message should be a compile time constant without formatting (less risk);\n * we don't care about assertion text size because they're not used in production\n * builds.\n */\n#define DUK_ASSERT(x)  do { \\\n\tif (!(x)) { \\\n\t\tDUK_FATAL_WITHOUT_CONTEXT(\"assertion failed: \" #x \\\n\t\t\t\" (\" DUK_FILE_MACRO \":\" DUK_MACRO_STRINGIFY(DUK_LINE_MACRO) \")\"); \\\n\t} \\\n\t} while (0)\n\n/* Assertion compatible inside a comma expression, evaluates to void. */\n#define DUK_ASSERT_EXPR(x) \\\n\t((void) ((x) ? 0 : (DUK_FATAL_WITHOUT_CONTEXT(\"assertion failed: \" #x \\\n\t\t\t\t\" (\" DUK_FILE_MACRO \":\" DUK_MACRO_STRINGIFY(DUK_LINE_MACRO) \")\"), 0)))\n\n#else  /* DUK_USE_ASSERTIONS */\n\n#define DUK_ASSERT(x)  do { /* assertion omitted */ } while (0)\n\n#define DUK_ASSERT_EXPR(x)  ((void) 0)\n\n#endif  /* DUK_USE_ASSERTIONS */\n\n/* this variant is used when an assert would generate a compile warning by\n * being always true (e.g. >= 0 comparison for an unsigned value\n */\n#define DUK_ASSERT_DISABLE(x)  do { /* assertion disabled */ } while (0)\n\n/*\n *  Assertion helpers\n */\n\n#if defined(DUK_USE_ASSERTIONS) && defined(DUK_USE_REFERENCE_COUNTING)\n#define DUK_ASSERT_REFCOUNT_NONZERO_HEAPHDR(h)  do { \\\n\t\tDUK_ASSERT((h) == NULL || DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) (h)) > 0); \\\n\t} while (0)\n#define DUK_ASSERT_REFCOUNT_NONZERO_TVAL(tv)  do { \\\n\t\tif ((tv) != NULL && DUK_TVAL_IS_HEAP_ALLOCATED((tv))) { \\\n\t\t\tDUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT(DUK_TVAL_GET_HEAPHDR((tv))) > 0); \\\n\t\t} \\\n\t} while (0)\n#else\n#define DUK_ASSERT_REFCOUNT_NONZERO_HEAPHDR(h)  /* no refcount check */\n#define DUK_ASSERT_REFCOUNT_NONZERO_TVAL(tv)    /* no refcount check */\n#endif\n\n#define DUK_ASSERT_TOP(ctx,n)  DUK_ASSERT((duk_idx_t) duk_get_top((ctx)) == (duk_idx_t) (n))\n\n#if defined(DUK_USE_ASSERTIONS) && defined(DUK_USE_PACKED_TVAL)\n#define DUK_ASSERT_DOUBLE_IS_NORMALIZED(dval)  do { \\\n\t\tduk_double_union duk__assert_tmp_du; \\\n\t\tduk__assert_tmp_du.d = (dval); \\\n\t\tDUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&duk__assert_tmp_du)); \\\n\t} while (0)\n#else\n#define DUK_ASSERT_DOUBLE_IS_NORMALIZED(dval)  /* nop */\n#endif\n\n#define DUK_ASSERT_VS_SPACE(thr) \\\n\tDUK_ASSERT(thr->valstack_top < thr->valstack_end)\n\n/*\n *  Helper for valstack space\n *\n *  Caller of DUK_ASSERT_VALSTACK_SPACE() estimates the number of free stack entries\n *  required for its own use, and any child calls which are not (a) Duktape API calls\n *  or (b) Duktape calls which involve extending the valstack (e.g. getter call).\n */\n\n#define DUK_VALSTACK_ASSERT_EXTRA  5  /* this is added to checks to allow for Duktape\n                                       * API calls in addition to function's own use\n                                       */\n#if defined(DUK_USE_ASSERTIONS)\n#define DUK_ASSERT_VALSTACK_SPACE(thr,n)   do { \\\n\t\tDUK_ASSERT((thr) != NULL); \\\n\t\tDUK_ASSERT((thr)->valstack_end - (thr)->valstack_top >= (n) + DUK_VALSTACK_ASSERT_EXTRA); \\\n\t} while (0)\n#else\n#define DUK_ASSERT_VALSTACK_SPACE(thr,n)   /* no valstack space check */\n#endif\n\n/*\n *  Prototypes\n */\n\n#if defined(DUK_USE_VERBOSE_ERRORS)\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_handle_error(duk_hthread *thr, const char *filename, duk_uint_t line_and_code, const char *msg));\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_handle_error_fmt(duk_hthread *thr, const char *filename, duk_uint_t line_and_code, const char *fmt, ...));\n#else  /* DUK_USE_VERBOSE_ERRORS */\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_handle_error(duk_hthread *thr, duk_errcode_t code));\n#endif  /* DUK_USE_VERBOSE_ERRORS */\n\n#if defined(DUK_USE_VERBOSE_ERRORS)\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_create_and_throw(duk_hthread *thr, duk_errcode_t code, const char *msg, const char *filename, duk_int_t line));\n#else\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_create_and_throw(duk_hthread *thr, duk_errcode_t code));\n#endif\n\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_error_throw_from_negative_rc(duk_hthread *thr, duk_ret_t rc));\n\n#if defined(DUK_USE_AUGMENT_ERROR_CREATE)\nDUK_INTERNAL_DECL void duk_err_augment_error_create(duk_hthread *thr, duk_hthread *thr_callstack, const char *filename, duk_int_t line, duk_bool_t noblame_fileline);\n#endif\n#if defined(DUK_USE_AUGMENT_ERROR_THROW)\nDUK_INTERNAL_DECL void duk_err_augment_error_throw(duk_hthread *thr);\n#endif\n\n#if defined(DUK_USE_VERBOSE_ERRORS)\n#if defined(DUK_USE_PARANOID_ERRORS)\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_require_type_index(duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t idx, const char *expect_name));\n#else\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_require_type_index(duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t idx, const char *expect_name));\n#endif\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_error_internal(duk_hthread *thr, const char *filename, duk_int_t linenumber));\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_error_alloc_failed(duk_hthread *thr, const char *filename, duk_int_t linenumber));\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_error(duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message));\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_range_index(duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t idx));\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_range_push_beyond(duk_hthread *thr, const char *filename, duk_int_t linenumber));\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_range(duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message));\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_type_invalid_args(duk_hthread *thr, const char *filename, duk_int_t linenumber));\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_type_invalid_state(duk_hthread *thr, const char *filename, duk_int_t linenumber));\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_type_invalid_trap_result(duk_hthread *thr, const char *filename, duk_int_t linenumber));\n#else  /* DUK_VERBOSE_ERRORS */\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_error(duk_hthread *thr));\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_range(duk_hthread *thr));\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_eval(duk_hthread *thr));\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_reference(duk_hthread *thr));\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_syntax(duk_hthread *thr));\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_type(duk_hthread *thr));\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_uri(duk_hthread *thr));\n#endif /* DUK_VERBOSE_ERRORS */\n\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_err_longjmp(duk_hthread *thr));\n\nDUK_NORETURN(DUK_INTERNAL_DECL void duk_default_fatal_handler(void *udata, const char *msg));\n\nDUK_INTERNAL_DECL void duk_err_setup_ljstate1(duk_hthread *thr, duk_small_uint_t lj_type, duk_tval *tv_val);\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\nDUK_INTERNAL_DECL void duk_err_check_debugger_integration(duk_hthread *thr);\n#endif\n\nDUK_INTERNAL_DECL duk_hobject *duk_error_prototype_from_code(duk_hthread *thr, duk_errcode_t err_code);\n\n#endif  /* DUK_ERROR_H_INCLUDED */\n/* #include duk_unicode.h */\n/*\n *  Unicode helpers\n */\n\n#if !defined(DUK_UNICODE_H_INCLUDED)\n#define DUK_UNICODE_H_INCLUDED\n\n/*\n *  UTF-8 / XUTF-8 / CESU-8 constants\n */\n\n#define DUK_UNICODE_MAX_XUTF8_LENGTH      7   /* up to 36 bit codepoints */\n#define DUK_UNICODE_MAX_XUTF8_BMP_LENGTH  3   /* all codepoints up to U+FFFF */\n#define DUK_UNICODE_MAX_CESU8_LENGTH      6   /* all codepoints up to U+10FFFF */\n#define DUK_UNICODE_MAX_CESU8_BMP_LENGTH  3   /* all codepoints up to U+FFFF */\n\n/*\n *  Useful Unicode codepoints\n *\n *  Integer constants must be signed to avoid unexpected coercions\n *  in comparisons.\n */\n\n#define DUK_UNICODE_CP_ZWNJ                   0x200cL  /* zero-width non-joiner */\n#define DUK_UNICODE_CP_ZWJ                    0x200dL  /* zero-width joiner */\n#define DUK_UNICODE_CP_REPLACEMENT_CHARACTER  0xfffdL  /* http://en.wikipedia.org/wiki/Replacement_character#Replacement_character */\n\n/*\n *  ASCII character constants\n *\n *  C character literals like 'x' have a platform specific value and do\n *  not match ASCII (UTF-8) values on e.g. EBCDIC platforms.  So, use\n *  these (admittedly awkward) constants instead.  These constants must\n *  also have signed values to avoid unexpected coercions in comparisons.\n *\n *  http://en.wikipedia.org/wiki/ASCII\n */\n\n#define DUK_ASC_NUL              0x00\n#define DUK_ASC_SOH              0x01\n#define DUK_ASC_STX              0x02\n#define DUK_ASC_ETX              0x03\n#define DUK_ASC_EOT              0x04\n#define DUK_ASC_ENQ              0x05\n#define DUK_ASC_ACK              0x06\n#define DUK_ASC_BEL              0x07\n#define DUK_ASC_BS               0x08\n#define DUK_ASC_HT               0x09\n#define DUK_ASC_LF               0x0a\n#define DUK_ASC_VT               0x0b\n#define DUK_ASC_FF               0x0c\n#define DUK_ASC_CR               0x0d\n#define DUK_ASC_SO               0x0e\n#define DUK_ASC_SI               0x0f\n#define DUK_ASC_DLE              0x10\n#define DUK_ASC_DC1              0x11\n#define DUK_ASC_DC2              0x12\n#define DUK_ASC_DC3              0x13\n#define DUK_ASC_DC4              0x14\n#define DUK_ASC_NAK              0x15\n#define DUK_ASC_SYN              0x16\n#define DUK_ASC_ETB              0x17\n#define DUK_ASC_CAN              0x18\n#define DUK_ASC_EM               0x19\n#define DUK_ASC_SUB              0x1a\n#define DUK_ASC_ESC              0x1b\n#define DUK_ASC_FS               0x1c\n#define DUK_ASC_GS               0x1d\n#define DUK_ASC_RS               0x1e\n#define DUK_ASC_US               0x1f\n#define DUK_ASC_SPACE            0x20\n#define DUK_ASC_EXCLAMATION      0x21\n#define DUK_ASC_DOUBLEQUOTE      0x22\n#define DUK_ASC_HASH             0x23\n#define DUK_ASC_DOLLAR           0x24\n#define DUK_ASC_PERCENT          0x25\n#define DUK_ASC_AMP              0x26\n#define DUK_ASC_SINGLEQUOTE      0x27\n#define DUK_ASC_LPAREN           0x28\n#define DUK_ASC_RPAREN           0x29\n#define DUK_ASC_STAR             0x2a\n#define DUK_ASC_PLUS             0x2b\n#define DUK_ASC_COMMA            0x2c\n#define DUK_ASC_MINUS            0x2d\n#define DUK_ASC_PERIOD           0x2e\n#define DUK_ASC_SLASH            0x2f\n#define DUK_ASC_0                0x30\n#define DUK_ASC_1                0x31\n#define DUK_ASC_2                0x32\n#define DUK_ASC_3                0x33\n#define DUK_ASC_4                0x34\n#define DUK_ASC_5                0x35\n#define DUK_ASC_6                0x36\n#define DUK_ASC_7                0x37\n#define DUK_ASC_8                0x38\n#define DUK_ASC_9                0x39\n#define DUK_ASC_COLON            0x3a\n#define DUK_ASC_SEMICOLON        0x3b\n#define DUK_ASC_LANGLE           0x3c\n#define DUK_ASC_EQUALS           0x3d\n#define DUK_ASC_RANGLE           0x3e\n#define DUK_ASC_QUESTION         0x3f\n#define DUK_ASC_ATSIGN           0x40\n#define DUK_ASC_UC_A             0x41\n#define DUK_ASC_UC_B             0x42\n#define DUK_ASC_UC_C             0x43\n#define DUK_ASC_UC_D             0x44\n#define DUK_ASC_UC_E             0x45\n#define DUK_ASC_UC_F             0x46\n#define DUK_ASC_UC_G             0x47\n#define DUK_ASC_UC_H             0x48\n#define DUK_ASC_UC_I             0x49\n#define DUK_ASC_UC_J             0x4a\n#define DUK_ASC_UC_K             0x4b\n#define DUK_ASC_UC_L             0x4c\n#define DUK_ASC_UC_M             0x4d\n#define DUK_ASC_UC_N             0x4e\n#define DUK_ASC_UC_O             0x4f\n#define DUK_ASC_UC_P             0x50\n#define DUK_ASC_UC_Q             0x51\n#define DUK_ASC_UC_R             0x52\n#define DUK_ASC_UC_S             0x53\n#define DUK_ASC_UC_T             0x54\n#define DUK_ASC_UC_U             0x55\n#define DUK_ASC_UC_V             0x56\n#define DUK_ASC_UC_W             0x57\n#define DUK_ASC_UC_X             0x58\n#define DUK_ASC_UC_Y             0x59\n#define DUK_ASC_UC_Z             0x5a\n#define DUK_ASC_LBRACKET         0x5b\n#define DUK_ASC_BACKSLASH        0x5c\n#define DUK_ASC_RBRACKET         0x5d\n#define DUK_ASC_CARET            0x5e\n#define DUK_ASC_UNDERSCORE       0x5f\n#define DUK_ASC_GRAVE            0x60\n#define DUK_ASC_LC_A             0x61\n#define DUK_ASC_LC_B             0x62\n#define DUK_ASC_LC_C             0x63\n#define DUK_ASC_LC_D             0x64\n#define DUK_ASC_LC_E             0x65\n#define DUK_ASC_LC_F             0x66\n#define DUK_ASC_LC_G             0x67\n#define DUK_ASC_LC_H             0x68\n#define DUK_ASC_LC_I             0x69\n#define DUK_ASC_LC_J             0x6a\n#define DUK_ASC_LC_K             0x6b\n#define DUK_ASC_LC_L             0x6c\n#define DUK_ASC_LC_M             0x6d\n#define DUK_ASC_LC_N             0x6e\n#define DUK_ASC_LC_O             0x6f\n#define DUK_ASC_LC_P             0x70\n#define DUK_ASC_LC_Q             0x71\n#define DUK_ASC_LC_R             0x72\n#define DUK_ASC_LC_S             0x73\n#define DUK_ASC_LC_T             0x74\n#define DUK_ASC_LC_U             0x75\n#define DUK_ASC_LC_V             0x76\n#define DUK_ASC_LC_W             0x77\n#define DUK_ASC_LC_X             0x78\n#define DUK_ASC_LC_Y             0x79\n#define DUK_ASC_LC_Z             0x7a\n#define DUK_ASC_LCURLY           0x7b\n#define DUK_ASC_PIPE             0x7c\n#define DUK_ASC_RCURLY           0x7d\n#define DUK_ASC_TILDE            0x7e\n#define DUK_ASC_DEL              0x7f\n\n/*\n *  Miscellaneous\n */\n\n/* Uppercase A is 0x41, lowercase a is 0x61; OR 0x20 to convert uppercase\n * to lowercase.\n */\n#define DUK_LOWERCASE_CHAR_ASCII(x)  ((x) | 0x20)\n\n/*\n *  Unicode tables\n */\n\n#if defined(DUK_USE_SOURCE_NONBMP)\n/*\n *  Automatically generated by extract_chars.py, do not edit!\n */\n\nextern const duk_uint8_t duk_unicode_ids_noa[1036];\n#else\n/*\n *  Automatically generated by extract_chars.py, do not edit!\n */\n\nextern const duk_uint8_t duk_unicode_ids_noabmp[625];\n#endif\n\n#if defined(DUK_USE_SOURCE_NONBMP)\n/*\n *  Automatically generated by extract_chars.py, do not edit!\n */\n\nextern const duk_uint8_t duk_unicode_ids_m_let_noa[42];\n#else\n/*\n *  Automatically generated by extract_chars.py, do not edit!\n */\n\nextern const duk_uint8_t duk_unicode_ids_m_let_noabmp[24];\n#endif\n\n#if defined(DUK_USE_SOURCE_NONBMP)\n/*\n *  Automatically generated by extract_chars.py, do not edit!\n */\n\nextern const duk_uint8_t duk_unicode_idp_m_ids_noa[530];\n#else\n/*\n *  Automatically generated by extract_chars.py, do not edit!\n */\n\nextern const duk_uint8_t duk_unicode_idp_m_ids_noabmp[357];\n#endif\n\n/*\n *  Automatically generated by extract_caseconv.py, do not edit!\n */\n\nextern const duk_uint8_t duk_unicode_caseconv_uc[1386];\nextern const duk_uint8_t duk_unicode_caseconv_lc[680];\n\n#if defined(DUK_USE_REGEXP_CANON_WORKAROUND)\n/*\n *  Automatically generated by extract_caseconv.py, do not edit!\n */\n\nextern const duk_uint16_t duk_unicode_re_canon_lookup[65536];\n#endif\n\n/*\n *  Extern\n */\n\n/* duk_unicode_support.c */\n#if !defined(DUK_SINGLE_FILE)\nDUK_INTERNAL_DECL const duk_uint8_t duk_unicode_xutf8_markers[7];\nDUK_INTERNAL_DECL const duk_uint16_t duk_unicode_re_ranges_digit[2];\nDUK_INTERNAL_DECL const duk_uint16_t duk_unicode_re_ranges_white[22];\nDUK_INTERNAL_DECL const duk_uint16_t duk_unicode_re_ranges_wordchar[8];\nDUK_INTERNAL_DECL const duk_uint16_t duk_unicode_re_ranges_not_digit[4];\nDUK_INTERNAL_DECL const duk_uint16_t duk_unicode_re_ranges_not_white[24];\nDUK_INTERNAL_DECL const duk_uint16_t duk_unicode_re_ranges_not_wordchar[10];\nDUK_INTERNAL_DECL const duk_int8_t duk_is_idchar_tab[128];\n#endif  /* !DUK_SINGLE_FILE */\n\n/*\n *  Prototypes\n */\n\nDUK_INTERNAL_DECL duk_small_int_t duk_unicode_get_xutf8_length(duk_ucodepoint_t cp);\n#if defined(DUK_USE_ASSERTIONS)\nDUK_INTERNAL_DECL duk_small_int_t duk_unicode_get_cesu8_length(duk_ucodepoint_t cp);\n#endif\nDUK_INTERNAL_DECL duk_small_int_t duk_unicode_encode_xutf8(duk_ucodepoint_t cp, duk_uint8_t *out);\nDUK_INTERNAL_DECL duk_small_int_t duk_unicode_encode_cesu8(duk_ucodepoint_t cp, duk_uint8_t *out);\nDUK_INTERNAL_DECL duk_small_int_t duk_unicode_decode_xutf8(duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end, duk_ucodepoint_t *out_cp);\nDUK_INTERNAL_DECL duk_ucodepoint_t duk_unicode_decode_xutf8_checked(duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end);\nDUK_INTERNAL_DECL duk_size_t duk_unicode_unvalidated_utf8_length(const duk_uint8_t *data, duk_size_t blen);\nDUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_whitespace(duk_codepoint_t cp);\nDUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_line_terminator(duk_codepoint_t cp);\nDUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_identifier_start(duk_codepoint_t cp);\nDUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_identifier_part(duk_codepoint_t cp);\nDUK_INTERNAL_DECL duk_small_int_t duk_unicode_is_letter(duk_codepoint_t cp);\nDUK_INTERNAL_DECL void duk_unicode_case_convert_string(duk_hthread *thr, duk_bool_t uppercase);\n#if defined(DUK_USE_REGEXP_SUPPORT)\nDUK_INTERNAL_DECL duk_codepoint_t duk_unicode_re_canonicalize_char(duk_hthread *thr, duk_codepoint_t cp);\nDUK_INTERNAL_DECL duk_small_int_t duk_unicode_re_is_wordchar(duk_codepoint_t cp);\n#endif\n\n#endif  /* DUK_UNICODE_H_INCLUDED */\n/* #include duk_json.h */\n/*\n *  Defines for JSON, especially duk_bi_json.c.\n */\n\n#if !defined(DUK_JSON_H_INCLUDED)\n#define DUK_JSON_H_INCLUDED\n\n/* Encoding/decoding flags */\n#define DUK_JSON_FLAG_ASCII_ONLY              (1 << 0)  /* escape any non-ASCII characters */\n#define DUK_JSON_FLAG_AVOID_KEY_QUOTES        (1 << 1)  /* avoid key quotes when key is an ASCII Identifier */\n#define DUK_JSON_FLAG_EXT_CUSTOM              (1 << 2)  /* extended types: custom encoding */\n#define DUK_JSON_FLAG_EXT_COMPATIBLE          (1 << 3)  /* extended types: compatible encoding */\n\n/* How much stack to require on entry to object/array encode */\n#define DUK_JSON_ENC_REQSTACK                 32\n\n/* How much stack to require on entry to object/array decode */\n#define DUK_JSON_DEC_REQSTACK                 32\n\n/* How large a loop detection stack to use */\n#define DUK_JSON_ENC_LOOPARRAY                64\n\n/* Encoding state.  Heap object references are all borrowed. */\ntypedef struct {\n\tduk_hthread *thr;\n\tduk_bufwriter_ctx bw;        /* output bufwriter */\n\tduk_hobject *h_replacer;     /* replacer function */\n\tduk_hstring *h_gap;          /* gap (if empty string, NULL) */\n\tduk_idx_t idx_proplist;      /* explicit PropertyList */\n\tduk_idx_t idx_loop;          /* valstack index of loop detection object */\n\tduk_small_uint_t flags;\n\tduk_small_uint_t flag_ascii_only;\n\tduk_small_uint_t flag_avoid_key_quotes;\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n\tduk_small_uint_t flag_ext_custom;\n\tduk_small_uint_t flag_ext_compatible;\n\tduk_small_uint_t flag_ext_custom_or_compatible;\n#endif\n\tduk_int_t recursion_depth;\n\tduk_int_t recursion_limit;\n\tduk_uint_t mask_for_undefined;      /* type bit mask: types which certainly produce 'undefined' */\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n\tduk_small_uint_t stridx_custom_undefined;\n\tduk_small_uint_t stridx_custom_nan;\n\tduk_small_uint_t stridx_custom_neginf;\n\tduk_small_uint_t stridx_custom_posinf;\n\tduk_small_uint_t stridx_custom_function;\n#endif\n\tduk_hobject *visiting[DUK_JSON_ENC_LOOPARRAY];  /* indexed by recursion_depth */\n} duk_json_enc_ctx;\n\ntypedef struct {\n\tduk_hthread *thr;\n\tconst duk_uint8_t *p;\n\tconst duk_uint8_t *p_start;\n\tconst duk_uint8_t *p_end;\n\tduk_idx_t idx_reviver;\n\tduk_small_uint_t flags;\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n\tduk_small_uint_t flag_ext_custom;\n\tduk_small_uint_t flag_ext_compatible;\n\tduk_small_uint_t flag_ext_custom_or_compatible;\n#endif\n\tduk_int_t recursion_depth;\n\tduk_int_t recursion_limit;\n} duk_json_dec_ctx;\n\n#endif  /* DUK_JSON_H_INCLUDED */\n/* #include duk_js.h */\n/*\n *  Ecmascript execution, support primitives.\n */\n\n#if !defined(DUK_JS_H_INCLUDED)\n#define DUK_JS_H_INCLUDED\n\n/* Flags for call handling. */\n#define DUK_CALL_FLAG_IGNORE_RECLIMIT        (1 << 0)  /* duk_handle_call_xxx: call ignores C recursion limit (for errhandler calls) */\n#define DUK_CALL_FLAG_CONSTRUCTOR_CALL       (1 << 1)  /* duk_handle_call_xxx: constructor call (i.e. called as 'new Foo()') */\n#define DUK_CALL_FLAG_IS_RESUME              (1 << 2)  /* duk_handle_ecma_call_setup: setup for a resume() */\n#define DUK_CALL_FLAG_IS_TAILCALL            (1 << 3)  /* duk_handle_ecma_call_setup: setup for a tail call */\n#define DUK_CALL_FLAG_DIRECT_EVAL            (1 << 4)  /* call is a direct eval call */\n\n/* Flags for duk_js_equals_helper(). */\n#define DUK_EQUALS_FLAG_SAMEVALUE            (1 << 0)  /* use SameValue instead of non-strict equality */\n#define DUK_EQUALS_FLAG_STRICT               (1 << 1)  /* use strict equality instead of non-strict equality */\n\n/* Flags for duk_js_compare_helper(). */\n#define DUK_COMPARE_FLAG_NEGATE              (1 << 0)  /* negate result */\n#define DUK_COMPARE_FLAG_EVAL_LEFT_FIRST     (1 << 1)  /* eval left argument first */\n\n/* conversions, coercions, comparison, etc */\nDUK_INTERNAL_DECL duk_bool_t duk_js_toboolean(duk_tval *tv);\nDUK_INTERNAL_DECL duk_double_t duk_js_tonumber(duk_hthread *thr, duk_tval *tv);\nDUK_INTERNAL_DECL duk_double_t duk_js_tointeger_number(duk_double_t x);\nDUK_INTERNAL_DECL duk_double_t duk_js_tointeger(duk_hthread *thr, duk_tval *tv);\nDUK_INTERNAL_DECL duk_uint32_t duk_js_touint32(duk_hthread *thr, duk_tval *tv);\nDUK_INTERNAL_DECL duk_int32_t duk_js_toint32(duk_hthread *thr, duk_tval *tv);\nDUK_INTERNAL_DECL duk_uint16_t duk_js_touint16(duk_hthread *thr, duk_tval *tv);\nDUK_INTERNAL_DECL duk_uarridx_t duk_js_to_arrayindex_string(const duk_uint8_t *str, duk_uint32_t blen);\n#if !defined(DUK_USE_HSTRING_ARRIDX)\nDUK_INTERNAL_DECL duk_uarridx_t duk_js_to_arrayindex_hstring_fast_known(duk_hstring *h);\nDUK_INTERNAL_DECL duk_uarridx_t duk_js_to_arrayindex_hstring_fast(duk_hstring *h);\n#endif\nDUK_INTERNAL_DECL duk_bool_t duk_js_equals_helper(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_small_int_t flags);\nDUK_INTERNAL_DECL duk_small_int_t duk_js_data_compare(const duk_uint8_t *buf1, const duk_uint8_t *buf2, duk_size_t len1, duk_size_t len2);\nDUK_INTERNAL_DECL duk_small_int_t duk_js_string_compare(duk_hstring *h1, duk_hstring *h2);\n#if 0  /* unused */\nDUK_INTERNAL_DECL duk_small_int_t duk_js_buffer_compare(duk_heap *heap, duk_hbuffer *h1, duk_hbuffer *h2);\n#endif\nDUK_INTERNAL_DECL duk_bool_t duk_js_compare_helper(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_small_int_t flags);\nDUK_INTERNAL_DECL duk_bool_t duk_js_instanceof(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y);\nDUK_INTERNAL_DECL duk_bool_t duk_js_in(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y);\nDUK_INTERNAL_DECL duk_small_uint_t duk_js_typeof_stridx(duk_tval *tv_x);\n\n/* arithmetic */\nDUK_INTERNAL_DECL double duk_js_arith_pow(double x, double y);\nDUK_INTERNAL_DECL double duk_js_arith_mod(double x, double y);\n\n#define duk_js_equals(thr,tv_x,tv_y) \\\n\tduk_js_equals_helper((thr), (tv_x), (tv_y), 0)\n#define duk_js_strict_equals(tv_x,tv_y) \\\n\tduk_js_equals_helper(NULL, (tv_x), (tv_y), DUK_EQUALS_FLAG_STRICT)\n#define duk_js_samevalue(tv_x,tv_y) \\\n\tduk_js_equals_helper(NULL, (tv_x), (tv_y), DUK_EQUALS_FLAG_SAMEVALUE)\n\n/* E5 Sections 11.8.1, 11.8.5; x < y */\n#define duk_js_lessthan(thr,tv_x,tv_y) \\\n\tduk_js_compare_helper((thr), (tv_x), (tv_Y), DUK_COMPARE_FLAG_EVAL_LEFT_FIRST)\n\n/* E5 Sections 11.8.2, 11.8.5; x > y  -->  y < x */\n#define duk_js_greaterthan(thr,tv_x,tv_y) \\\n\tduk_js_compare_helper((thr), (tv_y), (tv_x), 0)\n\n/* E5 Sections 11.8.3, 11.8.5; x <= y  -->  not (x > y)  -->  not (y < x) */\n#define duk_js_lessthanorequal(thr,tv_x,tv_y) \\\n\tduk_js_compare_helper((thr), (tv_y), (tv_x), DUK_COMPARE_FLAG_NEGATE)\n\n/* E5 Sections 11.8.4, 11.8.5; x >= y  -->  not (x < y) */\n#define duk_js_greaterthanorequal(thr,tv_x,tv_y) \\\n\tduk_js_compare_helper((thr), (tv_x), (tv_y), DUK_COMPARE_FLAG_EVAL_LEFT_FIRST | DUK_COMPARE_FLAG_NEGATE)\n\n/* identifiers and environment handling */\n#if 0  /*unused*/\nDUK_INTERNAL duk_bool_t duk_js_hasvar_envrec(duk_hthread *thr, duk_hobject *env, duk_hstring *name);\n#endif\nDUK_INTERNAL_DECL duk_bool_t duk_js_getvar_envrec(duk_hthread *thr, duk_hobject *env, duk_hstring *name, duk_bool_t throw_flag);\nDUK_INTERNAL_DECL duk_bool_t duk_js_getvar_activation(duk_hthread *thr, duk_activation *act, duk_hstring *name, duk_bool_t throw_flag);\nDUK_INTERNAL_DECL void duk_js_putvar_envrec(duk_hthread *thr, duk_hobject *env, duk_hstring *name, duk_tval *val, duk_bool_t strict);\nDUK_INTERNAL_DECL void duk_js_putvar_activation(duk_hthread *thr, duk_activation *act, duk_hstring *name, duk_tval *val, duk_bool_t strict);\n#if 0  /*unused*/\nDUK_INTERNAL_DECL duk_bool_t duk_js_delvar_envrec(duk_hthread *thr, duk_hobject *env, duk_hstring *name);\n#endif\nDUK_INTERNAL_DECL duk_bool_t duk_js_delvar_activation(duk_hthread *thr, duk_activation *act, duk_hstring *name);\nDUK_INTERNAL_DECL duk_bool_t duk_js_declvar_activation(duk_hthread *thr, duk_activation *act, duk_hstring *name, duk_tval *val, duk_small_int_t prop_flags, duk_bool_t is_func_decl);\nDUK_INTERNAL_DECL void duk_js_init_activation_environment_records_delayed(duk_hthread *thr, duk_activation *act);\nDUK_INTERNAL_DECL void duk_js_close_environment_record(duk_hthread *thr, duk_hobject *env);\nDUK_INTERNAL_DECL duk_hobject *duk_create_activation_environment_record(duk_hthread *thr, duk_hobject *func, duk_size_t idx_bottom);\nDUK_INTERNAL_DECL\nvoid duk_js_push_closure(duk_hthread *thr,\n                         duk_hcompfunc *fun_temp,\n                         duk_hobject *outer_var_env,\n                         duk_hobject *outer_lex_env,\n                         duk_bool_t add_auto_proto);\n\n/* call handling */\nDUK_INTERNAL_DECL duk_int_t duk_handle_call_protected(duk_hthread *thr, duk_idx_t num_stack_args, duk_small_uint_t call_flags);\nDUK_INTERNAL_DECL void duk_handle_call_unprotected(duk_hthread *thr, duk_idx_t num_stack_args, duk_small_uint_t call_flags);\nDUK_INTERNAL_DECL duk_int_t duk_handle_safe_call(duk_hthread *thr, duk_safe_call_function func, void *udata, duk_idx_t num_stack_args, duk_idx_t num_stack_res);\nDUK_INTERNAL_DECL duk_bool_t duk_handle_ecma_call_setup(duk_hthread *thr, duk_idx_t num_stack_args, duk_small_uint_t call_flags);\n\n/* bytecode execution */\nDUK_INTERNAL_DECL void duk_js_execute_bytecode(duk_hthread *exec_thr);\n\n#endif  /* DUK_JS_H_INCLUDED */\n/* #include duk_numconv.h */\n/*\n *  Number-to-string conversion.  The semantics of these is very tightly\n *  bound with the Ecmascript semantics required for call sites.\n */\n\n#if !defined(DUK_NUMCONV_H_INCLUDED)\n#define DUK_NUMCONV_H_INCLUDED\n\n/* Output a specified number of digits instead of using the shortest\n * form.  Used for toPrecision() and toFixed().\n */\n#define DUK_N2S_FLAG_FIXED_FORMAT         (1 << 0)\n\n/* Force exponential format.  Used for toExponential(). */\n#define DUK_N2S_FLAG_FORCE_EXP            (1 << 1)\n\n/* If number would need zero padding (for whole number part), use\n * exponential format instead.  E.g. if input number is 12300, 3\n * digits are generated (\"123\"), output \"1.23e+4\" instead of \"12300\".\n * Used for toPrecision().\n */\n#define DUK_N2S_FLAG_NO_ZERO_PAD          (1 << 2)\n\n/* Digit count indicates number of fractions (i.e. an absolute\n * digit index instead of a relative one).  Used together with\n * DUK_N2S_FLAG_FIXED_FORMAT for toFixed().\n */\n#define DUK_N2S_FLAG_FRACTION_DIGITS      (1 << 3)\n\n/*\n *  String-to-number conversion\n */\n\n/* Maximum exponent value when parsing numbers.  This is not strictly\n * compliant as there should be no upper limit, but as we parse the\n * exponent without a bigint, impose some limit.\n */\n#define DUK_S2N_MAX_EXPONENT              1000000000\n\n/* Trim white space (= allow leading and trailing whitespace) */\n#define DUK_S2N_FLAG_TRIM_WHITE           (1 << 0)\n\n/* Allow exponent */\n#define DUK_S2N_FLAG_ALLOW_EXP            (1 << 1)\n\n/* Allow trailing garbage (e.g. treat \"123foo\" as \"123) */\n#define DUK_S2N_FLAG_ALLOW_GARBAGE        (1 << 2)\n\n/* Allow leading plus sign */\n#define DUK_S2N_FLAG_ALLOW_PLUS           (1 << 3)\n\n/* Allow leading minus sign */\n#define DUK_S2N_FLAG_ALLOW_MINUS          (1 << 4)\n\n/* Allow 'Infinity' */\n#define DUK_S2N_FLAG_ALLOW_INF            (1 << 5)\n\n/* Allow fraction part */\n#define DUK_S2N_FLAG_ALLOW_FRAC           (1 << 6)\n\n/* Allow naked fraction (e.g. \".123\") */\n#define DUK_S2N_FLAG_ALLOW_NAKED_FRAC     (1 << 7)\n\n/* Allow empty fraction (e.g. \"123.\") */\n#define DUK_S2N_FLAG_ALLOW_EMPTY_FRAC     (1 << 8)\n\n/* Allow empty string to be interpreted as 0 */\n#define DUK_S2N_FLAG_ALLOW_EMPTY_AS_ZERO  (1 << 9)\n\n/* Allow leading zeroes (e.g. \"0123\" -> \"123\") */\n#define DUK_S2N_FLAG_ALLOW_LEADING_ZERO   (1 << 10)\n\n/* Allow automatic detection of hex base (\"0x\" or \"0X\" prefix),\n * overrides radix argument and forces integer mode.\n */\n#define DUK_S2N_FLAG_ALLOW_AUTO_HEX_INT   (1 << 11)\n\n/* Allow automatic detection of legacy octal base (\"0n\"),\n * overrides radix argument and forces integer mode.\n */\n#define DUK_S2N_FLAG_ALLOW_AUTO_LEGACY_OCT_INT   (1 << 12)\n\n/* Allow automatic detection of ES2015 octal base (\"0o123\"),\n * overrides radix argument and forces integer mode.\n */\n#define DUK_S2N_FLAG_ALLOW_AUTO_OCT_INT   (1 << 13)\n\n/* Allow automatic detection of ES2015 binary base (\"0b10001\"),\n * overrides radix argument and forces integer mode.\n */\n#define DUK_S2N_FLAG_ALLOW_AUTO_BIN_INT   (1 << 14)\n\n/*\n *  Prototypes\n */\n\nDUK_INTERNAL_DECL void duk_numconv_stringify(duk_context *ctx, duk_small_int_t radix, duk_small_int_t digits, duk_small_uint_t flags);\nDUK_INTERNAL_DECL void duk_numconv_parse(duk_context *ctx, duk_small_int_t radix, duk_small_uint_t flags);\n\n#endif  /* DUK_NUMCONV_H_INCLUDED */\n/* #include duk_bi_protos.h */\n/*\n *  Prototypes for built-in functions not automatically covered by the\n *  header declarations emitted by genbuiltins.py.\n */\n\n#if !defined(DUK_BUILTIN_PROTOS_H_INCLUDED)\n#define DUK_BUILTIN_PROTOS_H_INCLUDED\n\n/* Buffer size needed for ISO 8601 formatting.\n * Accurate value is 32 + 1 for NUL termination:\n *   >>> len('+123456-01-23T12:34:56.123+12:34')\n *   32\n * Include additional space to be safe.\n */\n#define  DUK_BI_DATE_ISO8601_BUFSIZE  40\n\n/* Helpers exposed for internal use */\nDUK_INTERNAL_DECL void duk_bi_date_timeval_to_parts(duk_double_t d, duk_int_t *parts, duk_double_t *dparts, duk_small_uint_t flags);\nDUK_INTERNAL_DECL duk_double_t duk_bi_date_get_timeval_from_dparts(duk_double_t *dparts, duk_small_uint_t flags);\nDUK_INTERNAL_DECL duk_bool_t duk_bi_date_is_leap_year(duk_int_t year);\nDUK_INTERNAL_DECL duk_bool_t duk_bi_date_timeval_in_valid_range(duk_double_t x);\nDUK_INTERNAL_DECL duk_bool_t duk_bi_date_year_in_valid_range(duk_double_t year);\nDUK_INTERNAL_DECL duk_bool_t duk_bi_date_timeval_in_leeway_range(duk_double_t x);\n/* Built-in providers */\n#if defined(DUK_USE_DATE_NOW_GETTIMEOFDAY)\nDUK_INTERNAL_DECL duk_double_t duk_bi_date_get_now_gettimeofday(duk_context *ctx);\n#endif\n#if defined(DUK_USE_DATE_NOW_TIME)\nDUK_INTERNAL_DECL duk_double_t duk_bi_date_get_now_time(duk_context *ctx);\n#endif\n#if defined(DUK_USE_DATE_NOW_WINDOWS)\nDUK_INTERNAL_DECL duk_double_t duk_bi_date_get_now_windows(duk_context *ctx);\n#endif\n#if defined(DUK_USE_DATE_TZO_GMTIME_R) || defined(DUK_USE_DATE_TZO_GMTIME_S) || defined(DUK_USE_DATE_TZO_GMTIME)\nDUK_INTERNAL_DECL duk_int_t duk_bi_date_get_local_tzoffset_gmtime(duk_double_t d);\n#endif\n#if defined(DUK_USE_DATE_TZO_WINDOWS)\nDUK_INTERNAL_DECL duk_int_t duk_bi_date_get_local_tzoffset_windows(duk_double_t d);\n#endif\n#if defined(DUK_USE_DATE_TZO_WINDOWS_NO_DST)\nDUK_INTERNAL_DECL duk_int_t duk_bi_date_get_local_tzoffset_windows_no_dst(duk_double_t d);\n#endif\n#if defined(DUK_USE_DATE_PRS_STRPTIME)\nDUK_INTERNAL_DECL duk_bool_t duk_bi_date_parse_string_strptime(duk_context *ctx, const char *str);\n#endif\n#if defined(DUK_USE_DATE_PRS_GETDATE)\nDUK_INTERNAL_DECL duk_bool_t duk_bi_date_parse_string_getdate(duk_context *ctx, const char *str);\n#endif\n#if defined(DUK_USE_DATE_FMT_STRFTIME)\nDUK_INTERNAL_DECL duk_bool_t duk_bi_date_format_parts_strftime(duk_context *ctx, duk_int_t *parts, duk_int_t tzoffset, duk_small_uint_t flags);\n#endif\n\nDUK_INTERNAL_DECL\nvoid duk_bi_json_parse_helper(duk_context *ctx,\n                              duk_idx_t idx_value,\n                              duk_idx_t idx_reviver,\n                              duk_small_uint_t flags);\nDUK_INTERNAL_DECL\nvoid duk_bi_json_stringify_helper(duk_context *ctx,\n                                  duk_idx_t idx_value,\n                                  duk_idx_t idx_replacer,\n                                  duk_idx_t idx_space,\n                                  duk_small_uint_t flags);\n\nDUK_INTERNAL_DECL duk_ret_t duk_textdecoder_decode_utf8_nodejs(duk_context *ctx);\n\n#if defined(DUK_USE_ES6_PROXY)\nDUK_INTERNAL_DECL void duk_proxy_ownkeys_postprocess(duk_context *ctx, duk_hobject *h_proxy_target, duk_uint_t flags);\n#endif\n\n#endif  /* DUK_BUILTIN_PROTOS_H_INCLUDED */\n/* #include duk_selftest.h */\n/*\n *  Selftest code\n */\n\n#if !defined(DUK_SELFTEST_H_INCLUDED)\n#define DUK_SELFTEST_H_INCLUDED\n\n#if defined(DUK_USE_SELF_TESTS)\nDUK_INTERNAL_DECL duk_uint_t duk_selftest_run_tests(duk_alloc_function alloc_func,\n                                                    duk_realloc_function realloc_func,\n                                                    duk_free_function free_func,\n                                                    void *udata);\n#endif\n\n#endif  /* DUK_SELFTEST_H_INCLUDED */\n\n#endif  /* DUK_INTERNAL_H_INCLUDED */\n\n#if defined(DUK_USE_COMPUTED_NAN)\nDUK_INTERNAL double duk_computed_nan;\n#endif\n\n#if defined(DUK_USE_COMPUTED_INFINITY)\nDUK_INTERNAL double duk_computed_infinity;\n#endif\n\n#if defined(DUK_USE_REPL_FPCLASSIFY)\nDUK_INTERNAL int duk_repl_fpclassify(double x) {\n\tduk_double_union u;\n\tduk_uint_fast16_t expt;\n\tduk_small_int_t mzero;\n\n\tu.d = x;\n\texpt = (duk_uint_fast16_t) (u.us[DUK_DBL_IDX_US0] & 0x7ff0UL);\n\tif (expt > 0x0000UL && expt < 0x7ff0UL) {\n\t\t/* expt values [0x001,0x7fe] = normal */\n\t\treturn DUK_FP_NORMAL;\n\t}\n\n\tmzero = (u.ui[DUK_DBL_IDX_UI1] == 0 && (u.ui[DUK_DBL_IDX_UI0] & 0x000fffffUL) == 0);\n\tif (expt == 0x0000UL) {\n\t\t/* expt 0x000 is zero/subnormal */\n\t\tif (mzero) {\n\t\t\treturn DUK_FP_ZERO;\n\t\t} else {\n\t\t\treturn DUK_FP_SUBNORMAL;\n\t\t}\n\t} else {\n\t\t/* expt 0xfff is infinite/nan */\n\t\tif (mzero) {\n\t\t\treturn DUK_FP_INFINITE;\n\t\t} else {\n\t\t\treturn DUK_FP_NAN;\n\t\t}\n\t}\n}\n#endif\n\n#if defined(DUK_USE_REPL_SIGNBIT)\nDUK_INTERNAL int duk_repl_signbit(double x) {\n\tduk_double_union u;\n\tu.d = x;\n\treturn (int) (u.uc[DUK_DBL_IDX_UC0] & 0x80UL);\n}\n#endif\n\n#if defined(DUK_USE_REPL_ISFINITE)\nDUK_INTERNAL int duk_repl_isfinite(double x) {\n\tint c = DUK_FPCLASSIFY(x);\n\tif (c == DUK_FP_NAN || c == DUK_FP_INFINITE) {\n\t\treturn 0;\n\t} else {\n\t\treturn 1;\n\t}\n}\n#endif\n\n#if defined(DUK_USE_REPL_ISNAN)\nDUK_INTERNAL int duk_repl_isnan(double x) {\n\tint c = DUK_FPCLASSIFY(x);\n\treturn (c == DUK_FP_NAN);\n}\n#endif\n\n#if defined(DUK_USE_REPL_ISINF)\nDUK_INTERNAL int duk_repl_isinf(double x) {\n\tint c = DUK_FPCLASSIFY(x);\n\treturn (c == DUK_FP_INFINITE);\n}\n#endif\n/*\n *  Debugging macro calls.\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_DEBUG)\n\n/*\n *  Debugging enabled\n */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <stdarg.h>\n\n#if !defined(DUK_USE_DEBUG_WRITE)\n#error debugging enabled (DUK_USE_DEBUG) but DUK_USE_DEBUG_WRITE not defined\n#endif\n\n#define DUK__DEBUG_BUFSIZE  DUK_USE_DEBUG_BUFSIZE\n\n#if defined(DUK_USE_VARIADIC_MACROS)\n\nDUK_INTERNAL void duk_debug_log(duk_int_t level, const char *file, duk_int_t line, const char *func, const char *fmt, ...) {\n\tva_list ap;\n\tlong arg_level;\n\tconst char *arg_file;\n\tlong arg_line;\n\tconst char *arg_func;\n\tconst char *arg_msg;\n\tchar buf[DUK__DEBUG_BUFSIZE];\n\n\tva_start(ap, fmt);\n\n\tDUK_MEMZERO((void *) buf, (size_t) DUK__DEBUG_BUFSIZE);\n\tduk_debug_vsnprintf(buf, DUK__DEBUG_BUFSIZE - 1, fmt, ap);\n\n\targ_level = (long) level;\n\targ_file = (const char *) file;\n\targ_line = (long) line;\n\targ_func = (const char *) func;\n\targ_msg = (const char *) buf;\n\tDUK_USE_DEBUG_WRITE(arg_level, arg_file, arg_line, arg_func, arg_msg);\n\n\tva_end(ap);\n}\n\n#else  /* DUK_USE_VARIADIC_MACROS */\n\nDUK_INTERNAL char duk_debug_file_stash[DUK_DEBUG_STASH_SIZE];\nDUK_INTERNAL duk_int_t duk_debug_line_stash;\nDUK_INTERNAL char duk_debug_func_stash[DUK_DEBUG_STASH_SIZE];\nDUK_INTERNAL duk_int_t duk_debug_level_stash;\n\nDUK_INTERNAL void duk_debug_log(const char *fmt, ...) {\n\tva_list ap;\n\tlong arg_level;\n\tconst char *arg_file;\n\tlong arg_line;\n\tconst char *arg_func;\n\tconst char *arg_msg;\n\tchar buf[DUK__DEBUG_BUFSIZE];\n\n\tva_start(ap, fmt);\n\n\tDUK_MEMZERO((void *) buf, (size_t) DUK__DEBUG_BUFSIZE);\n\tduk_debug_vsnprintf(buf, DUK__DEBUG_BUFSIZE - 1, fmt, ap);\n\n\targ_level = (long) duk_debug_level_stash;\n\targ_file = (const char *) duk_debug_file_stash;\n\targ_line = (long) duk_debug_line_stash;\n\targ_func = (const char *) duk_debug_func_stash;\n\targ_msg = (const char *) buf;\n\tDUK_USE_DEBUG_WRITE(arg_level, arg_file, arg_line, arg_func, arg_msg);\n\n\tva_end(ap);\n}\n\n#endif  /* DUK_USE_VARIADIC_MACROS */\n\n#else  /* DUK_USE_DEBUG */\n\n/*\n *  Debugging disabled\n */\n\n#endif  /* DUK_USE_DEBUG */\n\n/* automatic undefs */\n#undef DUK__DEBUG_BUFSIZE\n/*\n *  Automatically generated by genbuiltins.py, do not edit!\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_ASSERTIONS)\n#define DUK__REFCINIT(refc) 0 /*h_assert_refcount*/, (refc) /*actual*/\n#else\n#define DUK__REFCINIT(refc) (refc) /*actual*/\n#endif\n\n#if defined(DUK_USE_ROM_STRINGS)\n#error ROM support not enabled, rerun configure.py with --rom-support\n#else  /* DUK_USE_ROM_STRINGS */\nDUK_INTERNAL const duk_uint8_t duk_strings_data[903] = {\n79,40,209,144,168,105,6,78,54,139,89,185,44,48,46,90,120,8,154,140,35,103,\n35,113,193,73,5,52,112,180,104,166,135,52,188,4,98,12,27,146,156,80,211,31,\n129,115,150,64,52,220,109,24,18,68,156,24,38,67,114,36,55,9,119,151,132,\n140,93,18,113,128,153,201,212,201,205,2,248,8,196,24,224,104,82,146,40,224,\n193,48,114,168,37,147,196,54,123,28,4,98,12,43,148,67,103,177,192,70,32,\n196,121,68,54,123,28,18,192,199,144,124,4,98,12,43,136,108,244,117,184,8,\n196,24,95,40,134,207,71,91,128,140,65,133,113,13,158,158,151,1,24,131,11,\n229,16,217,233,233,112,17,136,48,206,21,110,4,244,244,184,8,196,24,103,10,\n183,2,122,218,156,4,98,12,24,203,112,64,179,113,193,79,8,218,155,131,32,\n184,70,212,220,13,10,82,68,252,123,144,217,146,38,228,207,18,0,100,37,64,\n178,212,11,161,17,104,162,96,10,200,193,57,165,65,169,16,5,100,81,27,70,18,\n32,10,200,68,185,13,116,221,197,184,64,89,57,41,197,13,49,234,5,208,156,\n113,87,55,118,147,20,187,56,161,166,92,221,212,73,210,236,226,134,153,115,\n119,76,201,203,179,138,26,99,73,212,136,136,164,25,174,137,56,32,72,137,\n101,23,52,45,13,34,86,9,79,136,104,201,114,149,96,52,138,134,140,151,75,\n226,233,186,120,121,22,39,54,83,141,5,55,68,236,36,164,3,16,225,115,150,64,\n52,205,163,2,72,154,83,138,26,99,75,12,11,150,103,5,36,20,211,70,140,133,\n67,72,49,241,160,227,81,196,52,168,106,39,132,252,183,136,105,80,212,79,2,\n249,110,128,126,88,95,133,109,237,237,237,151,235,127,46,249,119,203,190,\n186,206,33,181,2,208,61,190,12,19,34,65,19,81,132,108,228,97,1,107,33,12,\n32,45,100,139,134,69,146,100,227,226,231,146,51,192,204,73,140,224,145,221,\n102,241,68,196,157,34,79,143,139,166,233,225,228,227,138,157,173,167,197,\n211,118,214,210,38,238,74,113,67,76,105,187,169,147,154,73,225,228,32,193,\n48,25,100,105,166,113,200,147,44,166,1,40,79,18,150,134,147,141,163,2,72,\n171,115,147,136,4,65,130,96,35,64,194,32,168,89,56,208,48,135,123,144,217,\n146,38,220,229,64,186,16,187,156,105,47,52,238,112,56,153,4,225,145,27,156,\n43,162,192,46,71,220,229,65,22,1,231,220,228,157,72,136,136,220,227,197,\n164,180,52,133,220,228,206,137,23,115,128,137,164,77,206,48,15,62,231,42,8,\n145,181,86,231,10,134,129,104,201,34,125,206,76,17,49,38,141,206,28,13,26,\n201,19,137,204,122,22,66,161,175,164,210,72,199,130,137,1,50,32,145,143,38,\n120,186,195,35,106,51,146,230,8,36,77,109,65,38,226,72,141,18,74,140,35,\n247,247,182,168,209,144,187,223,58,156,104,79,190,183,127,123,105,160,110,\n247,206,167,26,19,239,173,223,222,218,67,75,189,243,169,198,132,251,235,\n183,247,182,154,134,151,123,231,83,141,9,247,215,111,239,109,22,141,22,247,\n206,167,26,19,239,172,223,218,45,26,47,157,78,52,39,223,74,24,144,10,32,\n129,34,20,64,152,142,129,57,179,67,104,68,12,129,161,140,72,156,100,40,40,\n185,152,100,89,38,65,13,196,34,228,67,149,13,2,215,129,149,209,65,104,209,\n77,14,104,144,81,33,170,67,101,48,52,68,113,70,210,88,209,36,233,22,154,86,\n68,196,114,76,232,145,102,120,186,195,156,112,105,225,228,113,71,80,68,162,\n115,101,50,85,200,25,108,116,44,132,178,38,114,137,96,148,136,70,209,134,\n37,222,232,204,228,188,200,209,200,200,99,221,25,150,84,121,34,70,209,107,\n36,227,66,20,160,92,136,164,49,235,35,8,217,201,40,108,201,18,128,68,26,\n201,51,188,2,80,12,67,190,40,168,38,68,190,46,153,5,50,12,207,160,86,129,\n26,83,4,208,34,225,4,88,192,\n};\n#endif  /* DUK_USE_ROM_STRINGS */\n\n#if defined(DUK_USE_ROM_OBJECTS)\n#error ROM support not enabled, rerun configure.py with --rom-support\n#else  /* DUK_USE_ROM_OBJECTS */\n/* native functions: 166 */\nDUK_INTERNAL const duk_c_function duk_bi_native_functions[166] = {\n\tNULL,\n\tduk_bi_array_constructor,\n\tduk_bi_array_constructor_is_array,\n\tduk_bi_array_prototype_concat,\n\tduk_bi_array_prototype_indexof_shared,\n\tduk_bi_array_prototype_iter_shared,\n\tduk_bi_array_prototype_join_shared,\n\tduk_bi_array_prototype_pop,\n\tduk_bi_array_prototype_push,\n\tduk_bi_array_prototype_reduce_shared,\n\tduk_bi_array_prototype_reverse,\n\tduk_bi_array_prototype_shift,\n\tduk_bi_array_prototype_slice,\n\tduk_bi_array_prototype_sort,\n\tduk_bi_array_prototype_splice,\n\tduk_bi_array_prototype_to_string,\n\tduk_bi_array_prototype_unshift,\n\tduk_bi_arraybuffer_constructor,\n\tduk_bi_arraybuffer_isview,\n\tduk_bi_boolean_constructor,\n\tduk_bi_boolean_prototype_tostring_shared,\n\tduk_bi_buffer_compare_shared,\n\tduk_bi_buffer_readfield,\n\tduk_bi_buffer_slice_shared,\n\tduk_bi_buffer_writefield,\n\tduk_bi_dataview_constructor,\n\tduk_bi_date_constructor,\n\tduk_bi_date_constructor_now,\n\tduk_bi_date_constructor_parse,\n\tduk_bi_date_constructor_utc,\n\tduk_bi_date_prototype_get_shared,\n\tduk_bi_date_prototype_get_timezone_offset,\n\tduk_bi_date_prototype_set_shared,\n\tduk_bi_date_prototype_set_time,\n\tduk_bi_date_prototype_to_json,\n\tduk_bi_date_prototype_tostring_shared,\n\tduk_bi_date_prototype_value_of,\n\tduk_bi_duktape_object_act,\n\tduk_bi_duktape_object_compact,\n\tduk_bi_duktape_object_dec,\n\tduk_bi_duktape_object_enc,\n\tduk_bi_duktape_object_fin,\n\tduk_bi_duktape_object_gc,\n\tduk_bi_duktape_object_info,\n\tduk_bi_error_constructor_shared,\n\tduk_bi_error_prototype_filename_getter,\n\tduk_bi_error_prototype_filename_setter,\n\tduk_bi_error_prototype_linenumber_getter,\n\tduk_bi_error_prototype_linenumber_setter,\n\tduk_bi_error_prototype_stack_getter,\n\tduk_bi_error_prototype_stack_setter,\n\tduk_bi_error_prototype_to_string,\n\tduk_bi_function_constructor,\n\tduk_bi_function_prototype,\n\tduk_bi_function_prototype_apply,\n\tduk_bi_function_prototype_bind,\n\tduk_bi_function_prototype_call,\n\tduk_bi_function_prototype_to_string,\n\tduk_bi_global_object_decode_uri,\n\tduk_bi_global_object_decode_uri_component,\n\tduk_bi_global_object_encode_uri,\n\tduk_bi_global_object_encode_uri_component,\n\tduk_bi_global_object_escape,\n\tduk_bi_global_object_eval,\n\tduk_bi_global_object_is_finite,\n\tduk_bi_global_object_is_nan,\n\tduk_bi_global_object_parse_float,\n\tduk_bi_global_object_parse_int,\n\tduk_bi_global_object_unescape,\n\tduk_bi_json_object_parse,\n\tduk_bi_json_object_stringify,\n\tduk_bi_math_object_hypot,\n\tduk_bi_math_object_max,\n\tduk_bi_math_object_min,\n\tduk_bi_math_object_onearg_shared,\n\tduk_bi_math_object_random,\n\tduk_bi_math_object_twoarg_shared,\n\tduk_bi_nodejs_buffer_byte_length,\n\tduk_bi_nodejs_buffer_concat,\n\tduk_bi_nodejs_buffer_constructor,\n\tduk_bi_nodejs_buffer_copy,\n\tduk_bi_nodejs_buffer_fill,\n\tduk_bi_nodejs_buffer_is_buffer,\n\tduk_bi_nodejs_buffer_is_encoding,\n\tduk_bi_nodejs_buffer_tojson,\n\tduk_bi_nodejs_buffer_tostring,\n\tduk_bi_nodejs_buffer_write,\n\tduk_bi_number_constructor,\n\tduk_bi_number_prototype_to_exponential,\n\tduk_bi_number_prototype_to_fixed,\n\tduk_bi_number_prototype_to_locale_string,\n\tduk_bi_number_prototype_to_precision,\n\tduk_bi_number_prototype_to_string,\n\tduk_bi_number_prototype_value_of,\n\tduk_bi_object_constructor,\n\tduk_bi_object_constructor_assign,\n\tduk_bi_object_constructor_create,\n\tduk_bi_object_constructor_define_properties,\n\tduk_bi_object_constructor_define_property,\n\tduk_bi_object_constructor_get_own_property_descriptor,\n\tduk_bi_object_constructor_is,\n\tduk_bi_object_constructor_is_extensible,\n\tduk_bi_object_constructor_is_sealed_frozen_shared,\n\tduk_bi_object_constructor_keys_shared,\n\tduk_bi_object_constructor_prevent_extensions,\n\tduk_bi_object_constructor_seal_freeze_shared,\n\tduk_bi_object_getprototype_shared,\n\tduk_bi_object_prototype_has_own_property,\n\tduk_bi_object_prototype_is_prototype_of,\n\tduk_bi_object_prototype_property_is_enumerable,\n\tduk_bi_object_prototype_to_locale_string,\n\tduk_bi_object_prototype_to_string,\n\tduk_bi_object_prototype_value_of,\n\tduk_bi_object_setprototype_shared,\n\tduk_bi_pointer_constructor,\n\tduk_bi_pointer_prototype_tostring_shared,\n\tduk_bi_proxy_constructor,\n\tduk_bi_reflect_object_delete_property,\n\tduk_bi_reflect_object_get,\n\tduk_bi_reflect_object_has,\n\tduk_bi_reflect_object_set,\n\tduk_bi_regexp_constructor,\n\tduk_bi_regexp_prototype_exec,\n\tduk_bi_regexp_prototype_flags,\n\tduk_bi_regexp_prototype_shared_getter,\n\tduk_bi_regexp_prototype_test,\n\tduk_bi_regexp_prototype_tostring,\n\tduk_bi_string_constructor,\n\tduk_bi_string_constructor_from_char_code,\n\tduk_bi_string_constructor_from_code_point,\n\tduk_bi_string_prototype_caseconv_shared,\n\tduk_bi_string_prototype_char_at,\n\tduk_bi_string_prototype_char_code_at,\n\tduk_bi_string_prototype_concat,\n\tduk_bi_string_prototype_includes,\n\tduk_bi_string_prototype_indexof_shared,\n\tduk_bi_string_prototype_locale_compare,\n\tduk_bi_string_prototype_match,\n\tduk_bi_string_prototype_repeat,\n\tduk_bi_string_prototype_replace,\n\tduk_bi_string_prototype_search,\n\tduk_bi_string_prototype_slice,\n\tduk_bi_string_prototype_split,\n\tduk_bi_string_prototype_startswith_endswith,\n\tduk_bi_string_prototype_substr,\n\tduk_bi_string_prototype_substring,\n\tduk_bi_string_prototype_to_string,\n\tduk_bi_string_prototype_trim,\n\tduk_bi_textdecoder_constructor,\n\tduk_bi_textdecoder_prototype_decode,\n\tduk_bi_textdecoder_prototype_shared_getter,\n\tduk_bi_textencoder_constructor,\n\tduk_bi_textencoder_prototype_encode,\n\tduk_bi_textencoder_prototype_encoding_getter,\n\tduk_bi_thread_constructor,\n\tduk_bi_thread_current,\n\tduk_bi_thread_resume,\n\tduk_bi_thread_yield,\n\tduk_bi_type_error_thrower,\n\tduk_bi_typedarray_buffer_getter,\n\tduk_bi_typedarray_bytelength_getter,\n\tduk_bi_typedarray_byteoffset_getter,\n\tduk_bi_typedarray_constructor,\n\tduk_bi_typedarray_set,\n\tduk_bi_uint8array_allocplain,\n\tduk_bi_uint8array_plainof,\n};\n#if defined(DUK_USE_DOUBLE_LE)\nDUK_INTERNAL const duk_uint8_t duk_builtins_data[3819] = {\n144,148,105,221,32,68,52,228,62,12,104,200,165,134,148,248,81,77,61,191,\n135,35,154,103,34,72,6,157,159,197,145,77,245,126,52,130,106,234,163,196,\n52,226,18,51,161,26,113,1,60,37,64,190,18,49,116,116,33,26,113,1,92,136,26,\n98,112,145,139,163,165,8,211,136,14,228,72,82,68,141,17,56,72,197,209,212,\n132,105,196,5,242,88,108,193,126,18,49,116,117,161,26,113,1,60,158,30,78,\n18,49,116,118,33,26,113,1,29,164,80,78,198,46,142,212,36,68,51,71,232,59,\n147,60,93,110,79,15,39,9,24,186,33,13,63,111,185,16,211,206,251,114,98,17,\n171,160,11,199,197,215,196,66,26,102,38,68,53,212,77,136,104,255,5,114,120,\n121,7,192,70,32,192,67,95,249,59,13,13,127,228,248,134,191,242,133,208,215,\n254,81,204,67,95,249,75,33,13,127,229,61,84,53,255,149,52,80,215,254,85,\n217,67,95,249,91,121,13,90,181,168,134,143,152,95,38,75,207,132,104,156,50,\n70,33,163,225,66,249,50,94,124,25,4,225,146,49,14,24,28,196,0,0,0,0,0,0,15,\n135,252,204,0,0,0,0,0,0,15,7,252,188,72,6,176,77,225,28,24,103,14,33,197,\n138,113,227,28,152,231,46,65,205,19,194,84,11,225,35,23,68,231,138,228,64,\n211,19,132,140,93,19,162,59,145,33,73,18,52,68,225,35,23,68,233,139,228,\n176,217,130,252,36,98,232,157,81,60,158,30,78,18,49,116,78,184,142,210,40,\n39,99,23,68,236,201,59,114,142,224,126,14,138,152,30,67,188,23,143,139,175,\n131,194,135,228,72,85,144,83,60,53,163,208,76,60,68,211,197,78,60,116,243,\n200,80,60,149,19,202,82,60,181,51,204,84,60,213,83,206,86,60,240,190,76,\n151,159,8,209,56,100,137,232,133,242,100,188,248,50,9,195,36,79,73,26,238,\n108,129,15,4,100,78,33,179,207,160,41,224,140,137,194,173,192,158,120,128,\n168,151,26,14,55,58,64,132,75,133,67,81,50,103,8,18,50,9,195,39,105,20,101,\n136,36,50,9,195,39,105,20,11,174,99,220,210,54,121,114,4,145,162,112,201,\n218,69,25,130,9,17,162,112,201,218,69,2,235,152,247,52,141,158,100,128,196,\n144,128,242,102,136,17,70,146,66,3,201,160,32,0,130,225,48,113,137,62,62,\n46,155,167,135,147,142,47,24,147,79,205,68,48,98,79,142,179,120,248,185,\n228,140,241,193,146,66,138,31,55,71,126,129,51,18,124,117,155,199,197,207,\n36,103,142,52,12,36,184,100,129,129,41,32,205,221,175,3,10,36,4,201,188,64,\n112,200,84,52,156,124,92,242,70,120,223,48,64,100,42,26,78,62,46,121,35,52,\n18,91,212,2,72,128,95,20,128,197,137,9,146,113,73,8,190,36,169,27,62,18,\n243,35,100,135,54,92,66,4,34,92,145,0,178,15,132,64,132,75,133,139,178,70,\n240,137,6,34,92,37,230,70,201,1,89,56,36,4,81,49,46,25,5,76,73,241,214,111,\n31,23,60,145,158,57,44,48,46,92,184,100,160,145,46,2,0,201,168,207,198,230,\n144,117,60,176,48,156,160,48,188,192,7,28,18,227,172,222,62,46,121,35,60,\n113,200,26,137,113,241,116,221,60,60,156,113,121,4,20,124,92,242,70,120,\n226,37,194,54,140,36,64,21,147,146,68,24,32,57,0,125,78,84,0,160,123,215,\n140,146,1,4,5,175,40,124,8,20,52,121,51,228,24,96,129,209,46,2,49,6,20,135,\n33,20,53,50,128,194,65,4,12,39,52,64,155,31,48,112,72,6,247,62,16,1,31,73,\n30,25,240,60,73,82,70,68,138,0,89,29,5,156,96,2,201,104,17,35,160,18,78,\n140,228,16,26,79,90,4,73,43,192,244,108,142,130,206,89,240,58,26,50,95,142,\n43,159,65,107,4,167,196,52,100,191,28,87,63,128,15,255,240,164,169,35,136,\n6,128,146,115,9,0,210,7,43,163,194,0,71,128,105,65,176,15,128,105,131,21,\n11,153,35,0,211,134,137,7,65,18,33,244,23,18,14,130,39,34,131,30,113,15,\n224,3,255,254,12,80,81,133,139,153,193,28,17,224,156,50,119,15,131,75,23,\n51,130,112,201,199,185,13,159,116,248,228,68,219,66,149,83,83,238,3,11,238,\n0,48,142,8,240,19,239,144,40,71,4,120,39,12,156,4,252,4,11,19,134,78,61,\n200,108,248,9,248,9,3,9,205,16,39,225,62,7,67,70,75,241,197,241,154,5,172,\n18,159,16,209,146,252,113,124,102,144,106,220,32,44,156,19,152,240,68,158,\n66,2,176,19,17,252,164,7,137,30,176,8,158,116,3,72,128,136,143,232,32,44,\n150,129,19,210,128,89,61,104,159,169,1,50,160,101,56,161,166,246,160,46,\n110,226,221,98,71,130,4,137,222,0,140,221,197,184,64,89,56,183,88,145,224,\n129,34,119,128,23,55,114,143,121,35,193,2,68,239,2,17,155,184,183,8,11,39,\n40,247,146,60,16,36,78,240,32,73,197,12,247,128,26,36,121,1,63,49,2,165,48,\n70,114,229,145,51,250,205,2,8,209,203,150,68,207,235,52,130,16,209,46,131,\n36,188,70,128,210,160,101,56,251,16,131,28,7,35,38,218,50,234,103,130,97,\n103,129,6,73,0,79,88,11,237,84,11,161,32,127,255,255,255,255,255,247,191,\n137,235,16,221,170,129,116,36,0,16,0,0,0,0,0,0,12,196,0,0,0,0,0,0,15,135,\n242,61,123,164,137,162,164,218,67,74,134,162,120,128,0,0,0,0,0,1,224,254,\n71,173,33,129,52,84,155,72,105,80,212,79,16,0,0,0,0,0,0,60,63,199,36,38,\n218,0,0,0,0,0,0,0,0,4,29,78,224,140,38,216,140,46,228,0,243,119,10,139,144,\n123,82,6,205,220,37,222,230,145,179,64,23,180,32,92,221,199,196,130,68,144,\n230,237,200,131,44,24,43,193,25,18,185,0,251,73,138,199,240,27,93,106,192,\n57,41,54,210,0,0,0,0,0,0,62,31,241,58,155,192,12,155,184,48,76,156,148,226,\n134,154,240,32,201,187,147,67,9,201,78,40,105,175,2,225,47,3,18,155,184,\n183,8,11,39,6,9,147,146,156,80,211,94,7,37,55,113,110,16,22,78,77,12,39,37,\n56,161,166,188,16,48,215,130,14,30,240,66,213,93,35,11,124,0,230,36,249,52,\n48,151,192,22,98,79,133,162,215,204,16,17,178,16,199,24,147,237,38,34,246,\n139,95,48,64,70,200,68,16,98,79,140,115,102,123,33,20,89,137,62,210,98,103,\n92,217,158,200,70,14,98,79,131,4,201,100,35,138,49,39,218,76,67,232,38,75,\n33,32,49,137,62,12,24,178,18,68,152,147,237,38,33,244,24,178,18,132,24,147,\n225,221,72,202,200,75,22,98,79,180,152,143,215,82,50,178,19,5,24,147,227,\n16,218,76,146,178,19,70,152,147,237,38,38,117,13,164,201,43,33,56,81,137,\n62,72,130,115,71,43,33,60,105,137,62,210,98,151,72,39,52,114,178,20,7,152,\n147,227,16,181,162,68,19,154,57,89,10,36,140,73,246,147,19,58,133,173,18,\n32,156,209,202,200,82,34,98,79,147,67,9,151,52,156,113,75,34,78,208,1,228,\n73,242,104,97,46,16,62,68,159,24,133,173,18,32,156,209,202,217,83,37,34,79,\n180,152,153,212,45,104,145,4,230,142,86,202,160,169,18,124,145,4,230,142,\n86,215,213,27,34,79,180,152,165,210,9,205,28,173,175,172,42,68,159,24,134,\n210,100,149,183,245,198,200,147,237,38,38,117,13,164,201,43,111,236,8,145,\n39,195,186,145,149,185,246,69,200,147,237,38,35,245,212,140,173,207,180,30,\n68,159,6,9,146,217,91,21,34,79,180,152,135,208,76,150,202,224,137,18,124,\n99,155,51,219,95,116,92,137,62,210,98,103,92,217,158,218,251,194,228,73,\n240,180,90,249,130,2,54,223,223,29,34,79,180,152,139,218,45,124,193,1,27,\n111,240,33,204,73,243,4,4,108,134,8,60,137,62,96,128,141,178,193,193,154,3,\n147,32,227,36,0,0,0,0,0,0,0,0,99,115,245,195,19,159,176,75,175,159,176,24,\n172,253,129,49,121,251,2,176,66,92,130,235,16,18,100,148,251,36,106,123,64,\n65,158,3,147,160,108,202,62,68,165,107,243,227,113,198,211,62,39,20,108,\n115,226,241,130,106,113,224,78,162,4,242,130,236,197,60,37,64,190,18,49,\n116,114,37,40,157,76,9,229,37,217,138,185,16,52,196,225,35,23,71,34,82,137,\n213,64,158,84,93,152,187,145,33,73,18,52,68,225,35,23,71,34,82,137,213,192,\n158,86,93,152,175,146,195,102,11,240,145,139,163,145,41,68,235,32,79,44,46,\n204,83,201,225,228,225,35,23,71,34,82,137,214,192,158,90,93,152,163,180,\n138,9,216,197,209,200,148,161,194,32,30,18,3,74,184,164,88,85,248,42,0,78,\n173,186,58,16,5,149,109,110,236,90,192,144,1,245,109,210,129,222,115,245,\n252,132,93,204,126,23,171,113,180,137,3,250,8,173,149,28,87,220,252,55,86,\n227,104,232,18,0,119,41,48,171,222,94,217,248,46,189,16,6,11,81,21,62,200,\n66,80,3,246,80,140,244,118,180,160,102,157,191,179,79,80,115,31,133,236,\n161,25,233,64,205,59,127,102,158,160,246,63,41,248,30,75,12,11,151,242,233,\n187,146,156,80,211,114,96,54,230,41,20,129,128,50,211,16,16,2,116,180,196,\n129,1,36,55,76,74,16,19,3,116,196,193,65,48,55,75,80,128,65,6,51,211,20,\n128,130,34,23,166,39,6,39,75,76,80,1,146,239,211,20,16,165,91,157,29,49,66,\n10,124,61,211,209,175,1,173,198,211,20,48,139,113,180,180,197,36,42,220,\n109,29,13,49,74,6,192,95,72,188,6,196,55,74,188,6,247,91,80,136,26,32,104,\n220,205,56,1,98,234,52,122,98,136,14,72,110,152,162,132,148,35,61,49,70,7,\n48,55,76,81,194,206,52,104,180,197,45,192,80,175,4,100,77,10,2,101,56,161,\n166,65,113,162,98,8,3,131,7,169,35,36,57,176,0,0,0,0,0,40,116,208,45,158,\n10,225,223,132,17,13,43,176,228,3,0,167,129,32,17,133,134,32,25,80,220,40,\n240,25,26,44,32,240,24,200,44,24,240,56,156,199,128,83,193,17,7,4,13,128,0,\n10,79,202,28,223,195,1,197,72,196,141,159,220,7,48,33,7,8,3,152,49,117,60,\n240,76,47,60,9,224,187,56,43,224,221,64,172,156,36,98,232,228,96,220,145,\n139,163,182,134,237,146,49,116,118,206,6,141,104,105,136,32,14,4,128,160,\n123,215,140,147,32,145,57,178,156,104,41,228,151,168,225,144,168,105,56,\n248,185,228,140,241,190,100,209,244,80,210,116,151,134,12,73,241,214,111,\n31,23,60,145,158,56,50,72,81,67,230,232,239,209,7,24,147,227,226,233,186,\n120,121,56,226,241,137,116,189,52,6,34,92,37,230,70,201,1,89,56,36,154,110,\n25,49,23,196,149,35,103,194,94,100,108,144,230,203,136,73,174,234,63,52,\n252,212,87,0,131,138,4,12,137,114,168,37,166,144,230,37,5,7,19,39,22,70,\n154,103,143,252,4,11,37,160,68,164,139,7,24,3,152,182,20,28,76,156,89,26,\n105,158,63,240,5,7,19,39,28,82,200,147,143,253,0,193,161,74,72,199,253,132,\n176,230,36,248,134,207,98,138,99,4,24,147,229,16,217,236,81,75,98,12,73,\n241,13,158,142,181,20,198,137,49,39,202,33,179,209,214,162,151,4,24,147,\n226,27,61,61,42,41,142,18,98,79,148,67,103,167,165,69,46,138,49,39,194,173,\n192,158,158,149,20,188,40,196,159,10,183,2,122,218,148,82,248,121,18,124,\n67,103,177,77,177,130,36,73,242,136,108,246,41,181,177,18,36,248,134,207,\n71,90,155,99,68,200,147,229,16,217,232,235,83,107,130,36,73,241,13,158,158,\n149,54,199,9,145,39,202,33,179,211,210,166,215,69,72,147,225,86,224,79,79,\n74,155,94,21,34,79,133,91,129,61,109,74,109,126,14,56,7,6,20,28,76,156,89,\n26,105,158,63,240,5,7,19,39,28,82,200,147,143,253,0,193,161,74,72,199,253,\n130,235,191,232,8,149,2,8,196,24,164,137,141,200,8,71,161,196,201,45,167,\n146,59,68,89,24,70,206,0,0,0,0,0,0,7,129,249,142,49,232,71,161,196,201,45,\n167,146,59,68,89,24,70,206,0,0,0,0,0,0,7,129,249,141,201,8,71,161,196,201,\n45,167,146,59,68,89,24,70,206,0,0,0,0,0,0,7,129,250,138,2,214,225,113,235,\n2,27,128,0,10,66,3,189,96,67,120,226,224,0,2,148,140,113,145,66,61,14,38,\n73,109,60,145,218,34,200,194,54,112,0,0,0,0,0,0,60,15,204,110,80,66,61,14,\n38,73,109,60,145,218,34,200,194,54,112,0,0,0,0,0,0,60,15,204,113,147,66,61,\n14,38,73,109,60,145,218,34,200,194,54,112,0,0,0,0,0,0,60,15,204,110,88,66,\n61,14,38,73,109,60,145,218,34,200,194,54,112,0,0,0,0,0,0,0,16,12,113,149,\n66,61,14,38,73,109,60,145,218,34,200,194,54,112,0,0,0,0,0,0,0,16,12,110,96,\n66,61,14,38,73,109,60,145,218,34,200,194,54,112,0,0,0,0,0,0,0,16,12,113,\n151,66,61,14,38,73,109,60,145,218,34,200,194,54,112,0,0,0,0,0,0,0,16,12,\n110,104,66,61,14,38,73,109,60,145,218,34,200,194,54,112,0,0,0,0,0,0,4,16,\n12,113,153,66,61,14,38,73,109,60,145,218,34,200,194,54,112,0,0,0,0,0,0,4,\n16,12,110,112,66,61,14,38,73,109,60,145,218,34,200,194,54,112,0,0,0,0,0,0,\n4,16,12,113,155,66,61,14,38,73,109,60,145,218,34,200,194,54,112,0,0,0,0,0,\n0,4,16,12,110,120,66,61,14,38,73,109,60,145,218,34,200,194,54,112,0,0,0,0,\n0,0,4,16,12,113,157,66,61,14,38,73,109,60,145,218,34,200,194,54,112,0,0,0,\n0,0,0,4,16,12,110,128,66,61,14,38,73,109,60,145,218,34,200,194,54,112,0,0,\n0,0,0,0,8,16,12,113,159,66,61,14,38,73,109,60,145,218,34,200,194,54,112,0,\n0,0,0,0,0,8,16,8,58,32,128,24,78,104,129,61,82,2,145,46,17,162,112,208,211,\n107,200,16,137,112,52,41,73,29,113,2,131,137,147,139,35,77,51,234,80,14,39,\n49,224,137,40,35,100,141,9,136,19,18,0,125,162,58,217,236,81,64,68,72,1,\n241,13,158,197,20,150,50,36,0,251,68,117,179,209,214,234,201,69,16,100,72,\n1,246,136,235,103,163,173,208,146,138,68,23,18,0,124,67,103,163,173,213,\n146,138,76,23,18,0,124,67,103,163,173,208,146,138,84,25,18,0,125,162,58,\n217,233,233,117,100,162,138,50,36,0,251,68,117,179,211,210,232,73,69,34,\n139,137,0,62,33,179,211,210,234,201,69,38,139,137,0,62,33,179,211,210,232,\n73,69,42,139,137,0,62,21,110,4,250,178,81,70,23,18,0,124,42,220,9,244,36,\n162,145,134,68,128,31,6,234,5,100,234,201,69,28,100,72,1,240,110,160,86,78,\n132,148,82,56,168,144,3,237,17,214,207,171,37,22,128,42,36,0,251,68,117,\n179,232,73,69,164,9,137,0,62,33,179,234,201,69,168,9,137,0,62,33,179,232,\n73,69,172,10,180,81,50,118,136,235,103,177,77,129,54,138,38,78,33,179,216,\n166,210,198,218,40,153,59,68,117,179,209,214,234,201,77,144,109,162,137,\n147,180,71,91,61,29,110,132,148,218,32,203,69,19,39,16,217,232,235,117,100,\n166,211,6,90,40,153,56,134,207,71,91,161,37,54,168,54,209,68,201,218,35,\n173,158,158,151,86,74,108,163,109,20,76,157,162,58,217,233,233,116,36,166,\n209,70,90,40,153,56,134,207,79,75,171,37,54,154,50,209,68,201,196,54,122,\n122,93,9,41,181,81,150,138,38,78,21,110,4,250,178,83,102,25,104,162,100,\n225,86,224,79,161,37,54,140,54,209,68,201,193,186,129,89,58,178,83,103,27,\n104,162,100,224,221,64,172,157,9,41,180,113,118,138,38,78,209,29,108,250,\n178,83,136,2,237,20,76,157,162,58,217,244,36,167,18,5,90,40,153,56,134,207,\n171,37,56,160,42,209,68,201,196,54,125,9,41,197,141,78,197,141,86,192,0,\n133,66,215,173,96,49,33,64,46,84,8,14,39,49,224,137,40,18,4,19,159,141,100,\n1,100,180,8,148,146,0,91,69,19,38,202,8,58,64,28,209,160,130,52,78,26,26,\n110,255,80,64,196,104,156,50,125,4,144,116,192,57,165,97,4,104,156,52,52,\n221,254,64,20,160,152,23,223,228,32,148,25,174,137,58,23,51,191,200,84,12,\n50,9,195,39,196,80,\n};\n#elif defined(DUK_USE_DOUBLE_BE)\nDUK_INTERNAL const duk_uint8_t duk_builtins_data[3819] = {\n144,148,105,221,32,68,52,228,62,12,104,200,165,134,148,248,81,77,61,191,\n135,35,154,103,34,72,6,157,159,197,145,77,245,126,52,130,106,234,163,196,\n52,226,18,51,161,26,113,1,60,37,64,190,18,49,116,116,33,26,113,1,92,136,26,\n98,112,145,139,163,165,8,211,136,14,228,72,82,68,141,17,56,72,197,209,212,\n132,105,196,5,242,88,108,193,126,18,49,116,117,161,26,113,1,60,158,30,78,\n18,49,116,118,33,26,113,1,29,164,80,78,198,46,142,212,36,68,51,71,232,59,\n147,60,93,110,79,15,39,9,24,186,33,13,63,111,185,16,211,206,251,114,98,17,\n171,160,11,199,197,215,196,66,26,102,38,68,53,212,77,136,104,255,5,114,120,\n121,7,192,70,32,192,67,95,249,59,13,13,127,228,248,134,191,242,133,208,215,\n254,81,204,67,95,249,75,33,13,127,229,61,84,53,255,149,52,80,215,254,85,\n217,67,95,249,91,121,13,90,181,168,134,143,152,95,38,75,207,132,104,156,50,\n70,33,163,225,66,249,50,94,124,25,4,225,146,49,14,24,28,196,7,255,128,0,0,\n0,0,0,12,204,7,255,0,0,0,0,0,0,12,188,72,6,176,77,225,28,24,103,14,33,197,\n138,113,227,28,152,231,46,65,205,19,194,84,11,225,35,23,68,231,138,228,64,\n211,19,132,140,93,19,162,59,145,33,73,18,52,68,225,35,23,68,233,139,228,\n176,217,130,252,36,98,232,157,81,60,158,30,78,18,49,116,78,184,142,210,40,\n39,99,23,68,236,201,59,114,142,224,126,14,138,152,30,67,188,23,143,139,175,\n131,194,135,228,72,85,144,83,60,53,163,208,76,60,68,211,197,78,60,116,243,\n200,80,60,149,19,202,82,60,181,51,204,84,60,213,83,206,86,60,240,190,76,\n151,159,8,209,56,100,137,232,133,242,100,188,248,50,9,195,36,79,73,26,238,\n108,129,15,4,100,78,33,179,207,160,41,224,140,137,194,173,192,158,120,128,\n168,151,26,14,55,58,64,132,75,133,67,81,50,103,8,18,50,9,195,39,105,20,101,\n136,36,50,9,195,39,105,20,11,174,99,220,210,54,121,114,4,145,162,112,201,\n218,69,25,130,9,17,162,112,201,218,69,2,235,152,247,52,141,158,100,128,196,\n144,128,242,102,136,17,70,146,66,3,201,160,32,0,130,225,48,113,137,62,62,\n46,155,167,135,147,142,47,24,147,79,205,68,48,98,79,142,179,120,248,185,\n228,140,241,193,146,66,138,31,55,71,126,129,51,18,124,117,155,199,197,207,\n36,103,142,52,12,36,184,100,129,129,41,32,205,221,175,3,10,36,4,201,188,64,\n112,200,84,52,156,124,92,242,70,120,223,48,64,100,42,26,78,62,46,121,35,52,\n18,91,212,2,72,128,95,20,128,197,137,9,146,113,73,8,190,36,169,27,62,18,\n243,35,100,135,54,92,66,4,34,92,145,0,178,15,132,64,132,75,133,139,178,70,\n240,137,6,34,92,37,230,70,201,1,89,56,36,4,81,49,46,25,5,76,73,241,214,111,\n31,23,60,145,158,57,44,48,46,92,184,100,160,145,46,2,0,201,168,207,198,230,\n144,117,60,176,48,156,160,48,188,192,7,28,18,227,172,222,62,46,121,35,60,\n113,200,26,137,113,241,116,221,60,60,156,113,121,4,20,124,92,242,70,120,\n226,37,194,54,140,36,64,21,147,146,68,24,32,57,0,125,78,84,0,160,123,215,\n140,146,1,4,5,175,40,124,8,20,52,121,51,228,24,96,129,209,46,2,49,6,20,135,\n33,20,53,50,128,194,65,4,12,39,52,64,155,31,48,112,72,6,247,62,16,1,31,73,\n30,25,240,60,73,82,70,68,138,0,89,29,5,156,96,2,201,104,17,35,160,18,78,\n140,228,16,26,79,90,4,73,43,192,244,108,142,130,206,89,240,58,26,50,95,142,\n43,159,65,107,4,167,196,52,100,191,28,87,63,128,15,255,240,164,169,35,136,\n6,128,146,115,9,0,210,7,43,163,194,0,71,128,105,65,176,15,128,105,131,21,\n11,153,35,0,211,134,137,7,65,18,33,244,23,18,14,130,39,34,131,30,113,15,\n224,3,255,254,12,80,81,133,139,153,193,28,17,224,156,50,119,15,131,75,23,\n51,130,112,201,199,185,13,159,116,248,228,68,219,66,149,83,83,238,3,11,238,\n0,48,142,8,240,19,239,144,40,71,4,120,39,12,156,4,252,4,11,19,134,78,61,\n200,108,248,9,248,9,3,9,205,16,39,225,62,7,67,70,75,241,197,241,154,5,172,\n18,159,16,209,146,252,113,124,102,144,106,220,32,44,156,19,152,240,68,158,\n66,2,176,19,17,252,164,7,137,30,176,8,158,116,3,72,128,136,143,232,32,44,\n150,129,19,210,128,89,61,104,159,169,1,50,160,101,56,161,166,246,160,46,\n110,226,221,98,71,130,4,137,222,0,140,221,197,184,64,89,56,183,88,145,224,\n129,34,119,128,23,55,114,143,121,35,193,2,68,239,2,17,155,184,183,8,11,39,\n40,247,146,60,16,36,78,240,32,73,197,12,247,128,26,36,121,1,63,49,2,165,48,\n70,114,229,145,51,250,205,2,8,209,203,150,68,207,235,52,130,16,209,46,131,\n36,188,70,128,210,160,101,56,251,16,131,28,7,35,38,218,50,234,103,130,97,\n103,129,6,73,0,79,88,11,237,84,11,161,32,63,247,255,255,255,255,255,255,\n137,235,16,221,170,129,116,36,0,0,0,0,0,0,0,0,28,196,7,255,128,0,0,0,0,0,2,\n61,123,164,137,162,164,218,67,74,134,162,120,128,255,224,0,0,0,0,0,0,71,\n173,33,129,52,84,155,72,105,80,212,79,16,63,252,0,0,0,0,0,0,7,36,38,218,0,\n0,0,0,0,0,0,0,4,29,78,224,140,38,216,140,46,228,0,243,119,10,139,144,123,\n82,6,205,220,37,222,230,145,179,64,23,180,32,92,221,199,196,130,68,144,230,\n237,200,131,44,24,43,193,25,18,185,0,251,73,138,199,240,27,93,106,192,57,\n41,54,210,31,254,0,0,0,0,0,0,49,58,155,192,12,155,184,48,76,156,148,226,\n134,154,240,32,201,187,147,67,9,201,78,40,105,175,2,225,47,3,18,155,184,\n183,8,11,39,6,9,147,146,156,80,211,94,7,37,55,113,110,16,22,78,77,12,39,37,\n56,161,166,188,16,48,215,130,14,30,240,66,213,93,35,11,124,0,230,36,249,52,\n48,151,192,22,98,79,133,162,215,204,16,17,178,16,199,24,147,237,38,34,246,\n139,95,48,64,70,200,68,16,98,79,140,115,102,123,33,20,89,137,62,210,98,103,\n92,217,158,200,70,14,98,79,131,4,201,100,35,138,49,39,218,76,67,232,38,75,\n33,32,49,137,62,12,24,178,18,68,152,147,237,38,33,244,24,178,18,132,24,147,\n225,221,72,202,200,75,22,98,79,180,152,143,215,82,50,178,19,5,24,147,227,\n16,218,76,146,178,19,70,152,147,237,38,38,117,13,164,201,43,33,56,81,137,\n62,72,130,115,71,43,33,60,105,137,62,210,98,151,72,39,52,114,178,20,7,152,\n147,227,16,181,162,68,19,154,57,89,10,36,140,73,246,147,19,58,133,173,18,\n32,156,209,202,200,82,34,98,79,147,67,9,151,52,156,113,75,34,78,208,1,228,\n73,242,104,97,46,16,62,68,159,24,133,173,18,32,156,209,202,217,83,37,34,79,\n180,152,153,212,45,104,145,4,230,142,86,202,160,169,18,124,145,4,230,142,\n86,215,213,27,34,79,180,152,165,210,9,205,28,173,175,172,42,68,159,24,134,\n210,100,149,183,245,198,200,147,237,38,38,117,13,164,201,43,111,236,8,145,\n39,195,186,145,149,185,246,69,200,147,237,38,35,245,212,140,173,207,180,30,\n68,159,6,9,146,217,91,21,34,79,180,152,135,208,76,150,202,224,137,18,124,\n99,155,51,219,95,116,92,137,62,210,98,103,92,217,158,218,251,194,228,73,\n240,180,90,249,130,2,54,223,223,29,34,79,180,152,139,218,45,124,193,1,27,\n111,240,33,204,73,243,4,4,108,134,8,60,137,62,96,128,141,178,193,193,154,3,\n147,32,227,36,0,0,0,0,0,0,0,0,99,115,245,195,19,159,176,75,175,159,176,24,\n172,253,129,49,121,251,2,176,66,92,130,235,16,18,100,148,251,36,106,123,64,\n65,158,3,147,160,108,202,62,68,165,107,243,227,113,198,211,62,39,20,108,\n115,226,241,130,106,113,224,78,162,4,242,130,236,197,60,37,64,190,18,49,\n116,114,37,40,157,76,9,229,37,217,138,185,16,52,196,225,35,23,71,34,82,137,\n213,64,158,84,93,152,187,145,33,73,18,52,68,225,35,23,71,34,82,137,213,192,\n158,86,93,152,175,146,195,102,11,240,145,139,163,145,41,68,235,32,79,44,46,\n204,83,201,225,228,225,35,23,71,34,82,137,214,192,158,90,93,152,163,180,\n138,9,216,197,209,200,148,161,194,32,30,18,2,0,45,248,84,88,162,187,72,78,\n173,186,58,16,16,0,154,236,110,237,85,69,129,245,109,210,128,127,204,92,\n133,253,244,115,222,23,171,113,180,137,0,255,220,85,29,148,174,11,248,55,\n86,227,104,232,18,1,254,222,91,216,169,55,40,112,46,189,16,16,2,72,126,213,\n17,11,70,3,246,80,140,244,118,180,160,31,243,80,79,51,63,157,230,133,236,\n161,25,233,64,63,246,160,158,102,127,59,205,41,248,30,75,12,11,151,242,233,\n187,146,156,80,211,114,96,54,230,41,20,129,128,50,211,16,16,2,116,180,196,\n129,1,36,55,76,74,16,19,3,116,196,193,65,48,55,75,80,128,65,6,51,211,20,\n128,130,34,23,166,39,6,39,75,76,80,1,146,239,211,20,16,165,91,157,29,49,66,\n10,124,61,211,209,175,1,173,198,211,20,48,139,113,180,180,197,36,42,220,\n109,29,13,49,74,6,192,95,72,188,6,196,55,74,188,6,247,91,80,136,26,32,104,\n220,205,56,1,98,234,52,122,98,136,14,72,110,152,162,132,148,35,61,49,70,7,\n48,55,76,81,194,206,52,104,180,197,45,192,80,175,4,100,77,10,2,101,56,161,\n166,65,113,162,98,8,3,131,7,169,35,36,57,176,16,52,232,64,0,0,0,0,45,158,\n10,225,223,132,17,13,43,176,228,3,0,167,129,32,17,133,134,32,25,80,220,40,\n240,25,26,44,32,240,24,200,44,24,240,56,156,199,128,83,193,17,7,4,13,128,0,\n10,79,202,28,223,195,1,197,72,196,141,159,220,7,48,33,7,8,3,152,49,117,60,\n240,76,47,60,9,224,187,56,43,224,221,64,172,156,36,98,232,228,96,220,145,\n139,163,182,134,237,146,49,116,118,206,6,141,104,105,136,32,14,4,128,160,\n123,215,140,147,32,145,57,178,156,104,41,228,151,168,225,144,168,105,56,\n248,185,228,140,241,190,100,209,244,80,210,116,151,134,12,73,241,214,111,\n31,23,60,145,158,56,50,72,81,67,230,232,239,209,7,24,147,227,226,233,186,\n120,121,56,226,241,137,116,189,52,6,34,92,37,230,70,201,1,89,56,36,154,110,\n25,49,23,196,149,35,103,194,94,100,108,144,230,203,136,73,174,234,63,52,\n252,212,87,0,131,138,4,12,137,114,168,37,166,144,230,37,5,7,19,39,22,70,\n154,103,143,252,4,11,37,160,68,164,139,7,24,3,152,182,20,28,76,156,89,26,\n105,158,63,240,5,7,19,39,28,82,200,147,143,253,0,193,161,74,72,199,253,132,\n176,230,36,248,134,207,98,138,99,4,24,147,229,16,217,236,81,75,98,12,73,\n241,13,158,142,181,20,198,137,49,39,202,33,179,209,214,162,151,4,24,147,\n226,27,61,61,42,41,142,18,98,79,148,67,103,167,165,69,46,138,49,39,194,173,\n192,158,158,149,20,188,40,196,159,10,183,2,122,218,148,82,248,121,18,124,\n67,103,177,77,177,130,36,73,242,136,108,246,41,181,177,18,36,248,134,207,\n71,90,155,99,68,200,147,229,16,217,232,235,83,107,130,36,73,241,13,158,158,\n149,54,199,9,145,39,202,33,179,211,210,166,215,69,72,147,225,86,224,79,79,\n74,155,94,21,34,79,133,91,129,61,109,74,109,126,14,56,7,6,20,28,76,156,89,\n26,105,158,63,240,5,7,19,39,28,82,200,147,143,253,0,193,161,74,72,199,253,\n130,235,191,232,8,149,2,8,196,24,164,137,141,200,8,71,161,196,201,45,167,\n146,59,68,89,24,70,206,1,255,128,0,0,0,0,0,1,142,49,232,71,161,196,201,45,\n167,146,59,68,89,24,70,206,1,255,128,0,0,0,0,0,1,141,201,8,71,161,196,201,\n45,167,146,59,68,89,24,70,206,1,255,128,0,0,0,0,0,2,138,2,214,225,113,235,\n2,27,128,0,10,66,3,189,96,67,120,226,224,0,2,148,140,113,145,66,61,14,38,\n73,109,60,145,218,34,200,194,54,112,15,252,0,0,0,0,0,0,12,110,80,66,61,14,\n38,73,109,60,145,218,34,200,194,54,112,15,252,0,0,0,0,0,0,12,113,147,66,61,\n14,38,73,109,60,145,218,34,200,194,54,112,15,252,0,0,0,0,0,0,12,110,88,66,\n61,14,38,73,109,60,145,218,34,200,194,54,112,16,0,0,0,0,0,0,0,12,113,149,\n66,61,14,38,73,109,60,145,218,34,200,194,54,112,16,0,0,0,0,0,0,0,12,110,96,\n66,61,14,38,73,109,60,145,218,34,200,194,54,112,16,0,0,0,0,0,0,0,12,113,\n151,66,61,14,38,73,109,60,145,218,34,200,194,54,112,16,0,0,0,0,0,0,0,12,\n110,104,66,61,14,38,73,109,60,145,218,34,200,194,54,112,16,4,0,0,0,0,0,0,\n12,113,153,66,61,14,38,73,109,60,145,218,34,200,194,54,112,16,4,0,0,0,0,0,\n0,12,110,112,66,61,14,38,73,109,60,145,218,34,200,194,54,112,16,4,0,0,0,0,\n0,0,12,113,155,66,61,14,38,73,109,60,145,218,34,200,194,54,112,16,4,0,0,0,\n0,0,0,12,110,120,66,61,14,38,73,109,60,145,218,34,200,194,54,112,16,4,0,0,\n0,0,0,0,12,113,157,66,61,14,38,73,109,60,145,218,34,200,194,54,112,16,4,0,\n0,0,0,0,0,12,110,128,66,61,14,38,73,109,60,145,218,34,200,194,54,112,16,8,\n0,0,0,0,0,0,12,113,159,66,61,14,38,73,109,60,145,218,34,200,194,54,112,16,\n8,0,0,0,0,0,0,8,58,32,128,24,78,104,129,61,82,2,145,46,17,162,112,208,211,\n107,200,16,137,112,52,41,73,29,113,2,131,137,147,139,35,77,51,234,80,14,39,\n49,224,137,40,35,100,141,9,136,19,18,0,125,162,58,217,236,81,64,68,72,1,\n241,13,158,197,20,150,50,36,0,251,68,117,179,209,214,234,201,69,16,100,72,\n1,246,136,235,103,163,173,208,146,138,68,23,18,0,124,67,103,163,173,213,\n146,138,76,23,18,0,124,67,103,163,173,208,146,138,84,25,18,0,125,162,58,\n217,233,233,117,100,162,138,50,36,0,251,68,117,179,211,210,232,73,69,34,\n139,137,0,62,33,179,211,210,234,201,69,38,139,137,0,62,33,179,211,210,232,\n73,69,42,139,137,0,62,21,110,4,250,178,81,70,23,18,0,124,42,220,9,244,36,\n162,145,134,68,128,31,6,234,5,100,234,201,69,28,100,72,1,240,110,160,86,78,\n132,148,82,56,168,144,3,237,17,214,207,171,37,22,128,42,36,0,251,68,117,\n179,232,73,69,164,9,137,0,62,33,179,234,201,69,168,9,137,0,62,33,179,232,\n73,69,172,10,180,81,50,118,136,235,103,177,77,129,54,138,38,78,33,179,216,\n166,210,198,218,40,153,59,68,117,179,209,214,234,201,77,144,109,162,137,\n147,180,71,91,61,29,110,132,148,218,32,203,69,19,39,16,217,232,235,117,100,\n166,211,6,90,40,153,56,134,207,71,91,161,37,54,168,54,209,68,201,218,35,\n173,158,158,151,86,74,108,163,109,20,76,157,162,58,217,233,233,116,36,166,\n209,70,90,40,153,56,134,207,79,75,171,37,54,154,50,209,68,201,196,54,122,\n122,93,9,41,181,81,150,138,38,78,21,110,4,250,178,83,102,25,104,162,100,\n225,86,224,79,161,37,54,140,54,209,68,201,193,186,129,89,58,178,83,103,27,\n104,162,100,224,221,64,172,157,9,41,180,113,118,138,38,78,209,29,108,250,\n178,83,136,2,237,20,76,157,162,58,217,244,36,167,18,5,90,40,153,56,134,207,\n171,37,56,160,42,209,68,201,196,54,125,9,41,197,141,78,197,141,86,192,0,\n133,66,215,173,96,49,33,64,46,84,8,14,39,49,224,137,40,18,4,19,159,141,100,\n1,100,180,8,148,146,0,91,69,19,38,202,8,58,64,28,209,160,130,52,78,26,26,\n110,255,80,64,196,104,156,50,125,4,144,116,192,57,165,97,4,104,156,52,52,\n221,254,64,20,160,152,23,223,228,32,148,25,174,137,58,23,51,191,200,84,12,\n50,9,195,39,196,80,\n};\n#elif defined(DUK_USE_DOUBLE_ME)\nDUK_INTERNAL const duk_uint8_t duk_builtins_data[3819] = {\n144,148,105,221,32,68,52,228,62,12,104,200,165,134,148,248,81,77,61,191,\n135,35,154,103,34,72,6,157,159,197,145,77,245,126,52,130,106,234,163,196,\n52,226,18,51,161,26,113,1,60,37,64,190,18,49,116,116,33,26,113,1,92,136,26,\n98,112,145,139,163,165,8,211,136,14,228,72,82,68,141,17,56,72,197,209,212,\n132,105,196,5,242,88,108,193,126,18,49,116,117,161,26,113,1,60,158,30,78,\n18,49,116,118,33,26,113,1,29,164,80,78,198,46,142,212,36,68,51,71,232,59,\n147,60,93,110,79,15,39,9,24,186,33,13,63,111,185,16,211,206,251,114,98,17,\n171,160,11,199,197,215,196,66,26,102,38,68,53,212,77,136,104,255,5,114,120,\n121,7,192,70,32,192,67,95,249,59,13,13,127,228,248,134,191,242,133,208,215,\n254,81,204,67,95,249,75,33,13,127,229,61,84,53,255,149,52,80,215,254,85,\n217,67,95,249,91,121,13,90,181,168,134,143,152,95,38,75,207,132,104,156,50,\n70,33,163,225,66,249,50,94,124,25,4,225,146,49,14,24,28,196,0,0,15,135,240,\n0,0,0,12,204,0,0,15,7,240,0,0,0,12,188,72,6,176,77,225,28,24,103,14,33,197,\n138,113,227,28,152,231,46,65,205,19,194,84,11,225,35,23,68,231,138,228,64,\n211,19,132,140,93,19,162,59,145,33,73,18,52,68,225,35,23,68,233,139,228,\n176,217,130,252,36,98,232,157,81,60,158,30,78,18,49,116,78,184,142,210,40,\n39,99,23,68,236,201,59,114,142,224,126,14,138,152,30,67,188,23,143,139,175,\n131,194,135,228,72,85,144,83,60,53,163,208,76,60,68,211,197,78,60,116,243,\n200,80,60,149,19,202,82,60,181,51,204,84,60,213,83,206,86,60,240,190,76,\n151,159,8,209,56,100,137,232,133,242,100,188,248,50,9,195,36,79,73,26,238,\n108,129,15,4,100,78,33,179,207,160,41,224,140,137,194,173,192,158,120,128,\n168,151,26,14,55,58,64,132,75,133,67,81,50,103,8,18,50,9,195,39,105,20,101,\n136,36,50,9,195,39,105,20,11,174,99,220,210,54,121,114,4,145,162,112,201,\n218,69,25,130,9,17,162,112,201,218,69,2,235,152,247,52,141,158,100,128,196,\n144,128,242,102,136,17,70,146,66,3,201,160,32,0,130,225,48,113,137,62,62,\n46,155,167,135,147,142,47,24,147,79,205,68,48,98,79,142,179,120,248,185,\n228,140,241,193,146,66,138,31,55,71,126,129,51,18,124,117,155,199,197,207,\n36,103,142,52,12,36,184,100,129,129,41,32,205,221,175,3,10,36,4,201,188,64,\n112,200,84,52,156,124,92,242,70,120,223,48,64,100,42,26,78,62,46,121,35,52,\n18,91,212,2,72,128,95,20,128,197,137,9,146,113,73,8,190,36,169,27,62,18,\n243,35,100,135,54,92,66,4,34,92,145,0,178,15,132,64,132,75,133,139,178,70,\n240,137,6,34,92,37,230,70,201,1,89,56,36,4,81,49,46,25,5,76,73,241,214,111,\n31,23,60,145,158,57,44,48,46,92,184,100,160,145,46,2,0,201,168,207,198,230,\n144,117,60,176,48,156,160,48,188,192,7,28,18,227,172,222,62,46,121,35,60,\n113,200,26,137,113,241,116,221,60,60,156,113,121,4,20,124,92,242,70,120,\n226,37,194,54,140,36,64,21,147,146,68,24,32,57,0,125,78,84,0,160,123,215,\n140,146,1,4,5,175,40,124,8,20,52,121,51,228,24,96,129,209,46,2,49,6,20,135,\n33,20,53,50,128,194,65,4,12,39,52,64,155,31,48,112,72,6,247,62,16,1,31,73,\n30,25,240,60,73,82,70,68,138,0,89,29,5,156,96,2,201,104,17,35,160,18,78,\n140,228,16,26,79,90,4,73,43,192,244,108,142,130,206,89,240,58,26,50,95,142,\n43,159,65,107,4,167,196,52,100,191,28,87,63,128,15,255,240,164,169,35,136,\n6,128,146,115,9,0,210,7,43,163,194,0,71,128,105,65,176,15,128,105,131,21,\n11,153,35,0,211,134,137,7,65,18,33,244,23,18,14,130,39,34,131,30,113,15,\n224,3,255,254,12,80,81,133,139,153,193,28,17,224,156,50,119,15,131,75,23,\n51,130,112,201,199,185,13,159,116,248,228,68,219,66,149,83,83,238,3,11,238,\n0,48,142,8,240,19,239,144,40,71,4,120,39,12,156,4,252,4,11,19,134,78,61,\n200,108,248,9,248,9,3,9,205,16,39,225,62,7,67,70,75,241,197,241,154,5,172,\n18,159,16,209,146,252,113,124,102,144,106,220,32,44,156,19,152,240,68,158,\n66,2,176,19,17,252,164,7,137,30,176,8,158,116,3,72,128,136,143,232,32,44,\n150,129,19,210,128,89,61,104,159,169,1,50,160,101,56,161,166,246,160,46,\n110,226,221,98,71,130,4,137,222,0,140,221,197,184,64,89,56,183,88,145,224,\n129,34,119,128,23,55,114,143,121,35,193,2,68,239,2,17,155,184,183,8,11,39,\n40,247,146,60,16,36,78,240,32,73,197,12,247,128,26,36,121,1,63,49,2,165,48,\n70,114,229,145,51,250,205,2,8,209,203,150,68,207,235,52,130,16,209,46,131,\n36,188,70,128,210,160,101,56,251,16,131,28,7,35,38,218,50,234,103,130,97,\n103,129,6,73,0,79,88,11,237,84,11,161,32,127,255,247,191,255,255,255,255,\n137,235,16,221,170,129,116,36,0,0,0,0,0,16,0,0,12,196,0,0,15,135,240,0,0,0,\n2,61,123,164,137,162,164,218,67,74,134,162,120,128,0,1,224,254,0,0,0,0,71,\n173,33,129,52,84,155,72,105,80,212,79,16,0,0,60,63,192,0,0,0,7,36,38,218,0,\n0,0,0,0,0,0,0,4,29,78,224,140,38,216,140,46,228,0,243,119,10,139,144,123,\n82,6,205,220,37,222,230,145,179,64,23,180,32,92,221,199,196,130,68,144,230,\n237,200,131,44,24,43,193,25,18,185,0,251,73,138,199,240,27,93,106,192,57,\n41,54,210,0,0,62,31,192,0,0,0,49,58,155,192,12,155,184,48,76,156,148,226,\n134,154,240,32,201,187,147,67,9,201,78,40,105,175,2,225,47,3,18,155,184,\n183,8,11,39,6,9,147,146,156,80,211,94,7,37,55,113,110,16,22,78,77,12,39,37,\n56,161,166,188,16,48,215,130,14,30,240,66,213,93,35,11,124,0,230,36,249,52,\n48,151,192,22,98,79,133,162,215,204,16,17,178,16,199,24,147,237,38,34,246,\n139,95,48,64,70,200,68,16,98,79,140,115,102,123,33,20,89,137,62,210,98,103,\n92,217,158,200,70,14,98,79,131,4,201,100,35,138,49,39,218,76,67,232,38,75,\n33,32,49,137,62,12,24,178,18,68,152,147,237,38,33,244,24,178,18,132,24,147,\n225,221,72,202,200,75,22,98,79,180,152,143,215,82,50,178,19,5,24,147,227,\n16,218,76,146,178,19,70,152,147,237,38,38,117,13,164,201,43,33,56,81,137,\n62,72,130,115,71,43,33,60,105,137,62,210,98,151,72,39,52,114,178,20,7,152,\n147,227,16,181,162,68,19,154,57,89,10,36,140,73,246,147,19,58,133,173,18,\n32,156,209,202,200,82,34,98,79,147,67,9,151,52,156,113,75,34,78,208,1,228,\n73,242,104,97,46,16,62,68,159,24,133,173,18,32,156,209,202,217,83,37,34,79,\n180,152,153,212,45,104,145,4,230,142,86,202,160,169,18,124,145,4,230,142,\n86,215,213,27,34,79,180,152,165,210,9,205,28,173,175,172,42,68,159,24,134,\n210,100,149,183,245,198,200,147,237,38,38,117,13,164,201,43,111,236,8,145,\n39,195,186,145,149,185,246,69,200,147,237,38,35,245,212,140,173,207,180,30,\n68,159,6,9,146,217,91,21,34,79,180,152,135,208,76,150,202,224,137,18,124,\n99,155,51,219,95,116,92,137,62,210,98,103,92,217,158,218,251,194,228,73,\n240,180,90,249,130,2,54,223,223,29,34,79,180,152,139,218,45,124,193,1,27,\n111,240,33,204,73,243,4,4,108,134,8,60,137,62,96,128,141,178,193,193,154,3,\n147,32,227,36,0,0,0,0,0,0,0,0,99,115,245,195,19,159,176,75,175,159,176,24,\n172,253,129,49,121,251,2,176,66,92,130,235,16,18,100,148,251,36,106,123,64,\n65,158,3,147,160,108,202,62,68,165,107,243,227,113,198,211,62,39,20,108,\n115,226,241,130,106,113,224,78,162,4,242,130,236,197,60,37,64,190,18,49,\n116,114,37,40,157,76,9,229,37,217,138,185,16,52,196,225,35,23,71,34,82,137,\n213,64,158,84,93,152,187,145,33,73,18,52,68,225,35,23,71,34,82,137,213,192,\n158,86,93,152,175,146,195,102,11,240,145,139,163,145,41,68,235,32,79,44,46,\n204,83,201,225,228,225,35,23,71,34,82,137,214,192,158,90,93,152,163,180,\n138,9,216,197,209,200,148,161,194,32,30,18,0,85,248,42,3,74,184,164,88,78,\n173,186,58,16,44,90,192,144,5,149,109,110,193,245,109,210,128,132,93,204,\n127,222,115,245,252,23,171,113,180,137,1,28,87,220,255,250,8,173,148,55,86,\n227,104,232,18,3,222,94,217,248,119,41,48,168,46,189,16,62,200,66,80,6,11,\n81,21,3,246,80,140,244,118,180,160,79,80,115,31,230,157,191,179,5,236,161,\n25,233,64,158,160,246,63,205,59,127,102,41,248,30,75,12,11,151,242,233,187,\n146,156,80,211,114,96,54,230,41,20,129,128,50,211,16,16,2,116,180,196,129,\n1,36,55,76,74,16,19,3,116,196,193,65,48,55,75,80,128,65,6,51,211,20,128,\n130,34,23,166,39,6,39,75,76,80,1,146,239,211,20,16,165,91,157,29,49,66,10,\n124,61,211,209,175,1,173,198,211,20,48,139,113,180,180,197,36,42,220,109,\n29,13,49,74,6,192,95,72,188,6,196,55,74,188,6,247,91,80,136,26,32,104,220,\n205,56,1,98,234,52,122,98,136,14,72,110,152,162,132,148,35,61,49,70,7,48,\n55,76,81,194,206,52,104,180,197,45,192,80,175,4,100,77,10,2,101,56,161,166,\n65,113,162,98,8,3,131,7,169,35,36,57,176,0,40,116,208,0,0,0,0,45,158,10,\n225,223,132,17,13,43,176,228,3,0,167,129,32,17,133,134,32,25,80,220,40,240,\n25,26,44,32,240,24,200,44,24,240,56,156,199,128,83,193,17,7,4,13,128,0,10,\n79,202,28,223,195,1,197,72,196,141,159,220,7,48,33,7,8,3,152,49,117,60,240,\n76,47,60,9,224,187,56,43,224,221,64,172,156,36,98,232,228,96,220,145,139,\n163,182,134,237,146,49,116,118,206,6,141,104,105,136,32,14,4,128,160,123,\n215,140,147,32,145,57,178,156,104,41,228,151,168,225,144,168,105,56,248,\n185,228,140,241,190,100,209,244,80,210,116,151,134,12,73,241,214,111,31,23,\n60,145,158,56,50,72,81,67,230,232,239,209,7,24,147,227,226,233,186,120,121,\n56,226,241,137,116,189,52,6,34,92,37,230,70,201,1,89,56,36,154,110,25,49,\n23,196,149,35,103,194,94,100,108,144,230,203,136,73,174,234,63,52,252,212,\n87,0,131,138,4,12,137,114,168,37,166,144,230,37,5,7,19,39,22,70,154,103,\n143,252,4,11,37,160,68,164,139,7,24,3,152,182,20,28,76,156,89,26,105,158,\n63,240,5,7,19,39,28,82,200,147,143,253,0,193,161,74,72,199,253,132,176,230,\n36,248,134,207,98,138,99,4,24,147,229,16,217,236,81,75,98,12,73,241,13,158,\n142,181,20,198,137,49,39,202,33,179,209,214,162,151,4,24,147,226,27,61,61,\n42,41,142,18,98,79,148,67,103,167,165,69,46,138,49,39,194,173,192,158,158,\n149,20,188,40,196,159,10,183,2,122,218,148,82,248,121,18,124,67,103,177,77,\n177,130,36,73,242,136,108,246,41,181,177,18,36,248,134,207,71,90,155,99,68,\n200,147,229,16,217,232,235,83,107,130,36,73,241,13,158,158,149,54,199,9,\n145,39,202,33,179,211,210,166,215,69,72,147,225,86,224,79,79,74,155,94,21,\n34,79,133,91,129,61,109,74,109,126,14,56,7,6,20,28,76,156,89,26,105,158,63,\n240,5,7,19,39,28,82,200,147,143,253,0,193,161,74,72,199,253,130,235,191,\n232,8,149,2,8,196,24,164,137,141,200,8,71,161,196,201,45,167,146,59,68,89,\n24,70,206,0,0,7,129,248,0,0,0,1,142,49,232,71,161,196,201,45,167,146,59,68,\n89,24,70,206,0,0,7,129,248,0,0,0,1,141,201,8,71,161,196,201,45,167,146,59,\n68,89,24,70,206,0,0,7,129,248,0,0,0,2,138,2,214,225,113,235,2,27,128,0,10,\n66,3,189,96,67,120,226,224,0,2,148,140,113,145,66,61,14,38,73,109,60,145,\n218,34,200,194,54,112,0,0,60,15,192,0,0,0,12,110,80,66,61,14,38,73,109,60,\n145,218,34,200,194,54,112,0,0,60,15,192,0,0,0,12,113,147,66,61,14,38,73,\n109,60,145,218,34,200,194,54,112,0,0,60,15,192,0,0,0,12,110,88,66,61,14,38,\n73,109,60,145,218,34,200,194,54,112,0,0,0,16,0,0,0,0,12,113,149,66,61,14,\n38,73,109,60,145,218,34,200,194,54,112,0,0,0,16,0,0,0,0,12,110,96,66,61,14,\n38,73,109,60,145,218,34,200,194,54,112,0,0,0,16,0,0,0,0,12,113,151,66,61,\n14,38,73,109,60,145,218,34,200,194,54,112,0,0,0,16,0,0,0,0,12,110,104,66,\n61,14,38,73,109,60,145,218,34,200,194,54,112,0,0,4,16,0,0,0,0,12,113,153,\n66,61,14,38,73,109,60,145,218,34,200,194,54,112,0,0,4,16,0,0,0,0,12,110,\n112,66,61,14,38,73,109,60,145,218,34,200,194,54,112,0,0,4,16,0,0,0,0,12,\n113,155,66,61,14,38,73,109,60,145,218,34,200,194,54,112,0,0,4,16,0,0,0,0,\n12,110,120,66,61,14,38,73,109,60,145,218,34,200,194,54,112,0,0,4,16,0,0,0,\n0,12,113,157,66,61,14,38,73,109,60,145,218,34,200,194,54,112,0,0,4,16,0,0,\n0,0,12,110,128,66,61,14,38,73,109,60,145,218,34,200,194,54,112,0,0,8,16,0,\n0,0,0,12,113,159,66,61,14,38,73,109,60,145,218,34,200,194,54,112,0,0,8,16,\n0,0,0,0,8,58,32,128,24,78,104,129,61,82,2,145,46,17,162,112,208,211,107,\n200,16,137,112,52,41,73,29,113,2,131,137,147,139,35,77,51,234,80,14,39,49,\n224,137,40,35,100,141,9,136,19,18,0,125,162,58,217,236,81,64,68,72,1,241,\n13,158,197,20,150,50,36,0,251,68,117,179,209,214,234,201,69,16,100,72,1,\n246,136,235,103,163,173,208,146,138,68,23,18,0,124,67,103,163,173,213,146,\n138,76,23,18,0,124,67,103,163,173,208,146,138,84,25,18,0,125,162,58,217,\n233,233,117,100,162,138,50,36,0,251,68,117,179,211,210,232,73,69,34,139,\n137,0,62,33,179,211,210,234,201,69,38,139,137,0,62,33,179,211,210,232,73,\n69,42,139,137,0,62,21,110,4,250,178,81,70,23,18,0,124,42,220,9,244,36,162,\n145,134,68,128,31,6,234,5,100,234,201,69,28,100,72,1,240,110,160,86,78,132,\n148,82,56,168,144,3,237,17,214,207,171,37,22,128,42,36,0,251,68,117,179,\n232,73,69,164,9,137,0,62,33,179,234,201,69,168,9,137,0,62,33,179,232,73,69,\n172,10,180,81,50,118,136,235,103,177,77,129,54,138,38,78,33,179,216,166,\n210,198,218,40,153,59,68,117,179,209,214,234,201,77,144,109,162,137,147,\n180,71,91,61,29,110,132,148,218,32,203,69,19,39,16,217,232,235,117,100,166,\n211,6,90,40,153,56,134,207,71,91,161,37,54,168,54,209,68,201,218,35,173,\n158,158,151,86,74,108,163,109,20,76,157,162,58,217,233,233,116,36,166,209,\n70,90,40,153,56,134,207,79,75,171,37,54,154,50,209,68,201,196,54,122,122,\n93,9,41,181,81,150,138,38,78,21,110,4,250,178,83,102,25,104,162,100,225,86,\n224,79,161,37,54,140,54,209,68,201,193,186,129,89,58,178,83,103,27,104,162,\n100,224,221,64,172,157,9,41,180,113,118,138,38,78,209,29,108,250,178,83,\n136,2,237,20,76,157,162,58,217,244,36,167,18,5,90,40,153,56,134,207,171,37,\n56,160,42,209,68,201,196,54,125,9,41,197,141,78,197,141,86,192,0,133,66,\n215,173,96,49,33,64,46,84,8,14,39,49,224,137,40,18,4,19,159,141,100,1,100,\n180,8,148,146,0,91,69,19,38,202,8,58,64,28,209,160,130,52,78,26,26,110,255,\n80,64,196,104,156,50,125,4,144,116,192,57,165,97,4,104,156,52,52,221,254,\n64,20,160,152,23,223,228,32,148,25,174,137,58,23,51,191,200,84,12,50,9,195,\n39,196,80,\n};\n#else\n#error invalid endianness defines\n#endif\n#endif  /* DUK_USE_ROM_OBJECTS */\n\n/* automatic undefs */\n#undef DUK__REFCINIT\n/*\n *  Error and fatal handling.\n */\n\n/* #include duk_internal.h -> already included */\n\n#define DUK__ERRFMT_BUFSIZE  256  /* size for formatting buffers */\n\n#if defined(DUK_USE_VERBOSE_ERRORS)\n\nDUK_INTERNAL DUK_COLD void duk_err_handle_error_fmt(duk_hthread *thr, const char *filename, duk_uint_t line_and_code, const char *fmt, ...) {\n\tva_list ap;\n\tchar msg[DUK__ERRFMT_BUFSIZE];\n\tva_start(ap, fmt);\n\t(void) DUK_VSNPRINTF(msg, sizeof(msg), fmt, ap);\n\tmsg[sizeof(msg) - 1] = (char) 0;\n\tduk_err_create_and_throw(thr, (duk_errcode_t) (line_and_code >> 24), msg, filename, (duk_int_t) (line_and_code & 0x00ffffffL));\n\tva_end(ap);  /* dead code, but ensures portability (see Linux man page notes) */\n}\n\nDUK_INTERNAL DUK_COLD void duk_err_handle_error(duk_hthread *thr, const char *filename, duk_uint_t line_and_code, const char *msg) {\n\tduk_err_create_and_throw(thr, (duk_errcode_t) (line_and_code >> 24), msg, filename, (duk_int_t) (line_and_code & 0x00ffffffL));\n}\n\n#else  /* DUK_USE_VERBOSE_ERRORS */\n\nDUK_INTERNAL DUK_COLD void duk_err_handle_error(duk_hthread *thr, duk_errcode_t code) {\n\tduk_err_create_and_throw(thr, code);\n}\n\n#endif  /* DUK_USE_VERBOSE_ERRORS */\n\n/*\n *  Error throwing helpers\n */\n\n#if defined(DUK_USE_VERBOSE_ERRORS)\n#if defined(DUK_USE_PARANOID_ERRORS)\nDUK_INTERNAL DUK_COLD void duk_err_require_type_index(duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t idx, const char *expect_name) {\n\tDUK_ERROR_RAW_FMT3(thr, filename, linenumber, DUK_ERR_TYPE_ERROR, \"%s required, found %s (stack index %ld)\",\n\t                   expect_name, duk_get_type_name((duk_context *) thr, idx), (long) idx);\n}\n#else\nDUK_INTERNAL DUK_COLD void duk_err_require_type_index(duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t idx, const char *expect_name) {\n\tDUK_ERROR_RAW_FMT3(thr, filename, linenumber, DUK_ERR_TYPE_ERROR, \"%s required, found %s (stack index %ld)\",\n\t                   expect_name, duk_push_string_readable((duk_context *) thr, idx), (long) idx);\n}\n#endif\nDUK_INTERNAL DUK_COLD void duk_err_error_internal(duk_hthread *thr, const char *filename, duk_int_t linenumber) {\n\tDUK_ERROR_RAW(thr, filename, linenumber, DUK_ERR_ERROR, DUK_STR_INTERNAL_ERROR);\n}\nDUK_INTERNAL DUK_COLD void duk_err_error_alloc_failed(duk_hthread *thr, const char *filename, duk_int_t linenumber) {\n\tDUK_ERROR_RAW(thr, filename, linenumber, DUK_ERR_ERROR, DUK_STR_ALLOC_FAILED);\n}\nDUK_INTERNAL DUK_COLD void duk_err_error(duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message) {\n\tDUK_ERROR_RAW(thr, filename, linenumber, DUK_ERR_ERROR, message);\n}\nDUK_INTERNAL DUK_COLD void duk_err_range(duk_hthread *thr, const char *filename, duk_int_t linenumber, const char *message) {\n\tDUK_ERROR_RAW(thr, filename, linenumber, DUK_ERR_RANGE_ERROR, message);\n}\nDUK_INTERNAL DUK_COLD void duk_err_range_index(duk_hthread *thr, const char *filename, duk_int_t linenumber, duk_idx_t idx) {\n\tDUK_ERROR_RAW_FMT1(thr, filename, linenumber, DUK_ERR_RANGE_ERROR, \"invalid stack index %ld\", (long) (idx));\n}\nDUK_INTERNAL DUK_COLD void duk_err_range_push_beyond(duk_hthread *thr, const char *filename, duk_int_t linenumber) {\n\tDUK_ERROR_RAW(thr, filename, linenumber, DUK_ERR_RANGE_ERROR, DUK_STR_PUSH_BEYOND_ALLOC_STACK);\n}\nDUK_INTERNAL DUK_COLD void duk_err_type_invalid_args(duk_hthread *thr, const char *filename, duk_int_t linenumber) {\n\tDUK_ERROR_RAW(thr, filename, linenumber, DUK_ERR_TYPE_ERROR, DUK_STR_INVALID_ARGS);\n}\nDUK_INTERNAL DUK_COLD void duk_err_type_invalid_state(duk_hthread *thr, const char *filename, duk_int_t linenumber) {\n\tDUK_ERROR_RAW(thr, filename, linenumber, DUK_ERR_TYPE_ERROR, DUK_STR_INVALID_STATE);\n}\nDUK_INTERNAL DUK_COLD void duk_err_type_invalid_trap_result(duk_hthread *thr, const char *filename, duk_int_t linenumber) {\n\tDUK_ERROR_RAW(thr, filename, linenumber, DUK_ERR_TYPE_ERROR, DUK_STR_INVALID_TRAP_RESULT);\n}\n#else\n/* The file/line arguments are NULL and 0, they're ignored by DUK_ERROR_RAW()\n * when non-verbose errors are used.\n */\n\nDUK_NORETURN(DUK_LOCAL_DECL void duk__err_shared(duk_hthread *thr, duk_uint_t code));\nDUK_LOCAL void duk__err_shared(duk_hthread *thr, duk_uint_t code) {\n\tDUK_ERROR_RAW(thr, NULL, 0, code, NULL);\n}\nDUK_INTERNAL DUK_COLD void duk_err_error(duk_hthread *thr) {\n\tduk__err_shared(thr, DUK_ERR_ERROR);\n}\nDUK_INTERNAL DUK_COLD void duk_err_range(duk_hthread *thr) {\n\tduk__err_shared(thr, DUK_ERR_RANGE_ERROR);\n}\nDUK_INTERNAL DUK_COLD void duk_err_eval(duk_hthread *thr) {\n\tduk__err_shared(thr, DUK_ERR_EVAL_ERROR);\n}\nDUK_INTERNAL DUK_COLD void duk_err_reference(duk_hthread *thr) {\n\tduk__err_shared(thr, DUK_ERR_REFERENCE_ERROR);\n}\nDUK_INTERNAL DUK_COLD void duk_err_syntax(duk_hthread *thr) {\n\tduk__err_shared(thr, DUK_ERR_SYNTAX_ERROR);\n}\nDUK_INTERNAL DUK_COLD void duk_err_type(duk_hthread *thr) {\n\tduk__err_shared(thr, DUK_ERR_TYPE_ERROR);\n}\nDUK_INTERNAL DUK_COLD void duk_err_uri(duk_hthread *thr) {\n\tduk__err_shared(thr, DUK_ERR_URI_ERROR);\n}\n#endif\n\n/*\n *  Default fatal error handler\n */\n\nDUK_INTERNAL DUK_COLD void duk_default_fatal_handler(void *udata, const char *msg) {\n\tDUK_UNREF(udata);\n\tDUK_UNREF(msg);\n\n#if defined(DUK_USE_FATAL_HANDLER)\n\t/* duk_config.h provided a custom default fatal handler. */\n\tDUK_D(DUK_DPRINT(\"custom default fatal error handler called: %s\", msg ? msg : \"NULL\"));\n\tDUK_USE_FATAL_HANDLER(udata, msg);\n#else\n\t/* Default behavior is to abort() on error.  There's no printout\n\t * which makes this awkward, so it's always recommended to use an\n\t * explicit fatal error handler.\n\t */\n\tDUK_D(DUK_DPRINT(\"built-in default fatal error handler called: %s\", msg ? msg : \"NULL\"));\n\tDUK_ABORT();\n#endif\n\n\tDUK_D(DUK_DPRINT(\"fatal error handler returned, enter forever loop\"));\n\tfor (;;) {\n\t\t/* Loop forever to ensure we don't return. */\n\t}\n}\n\n/* automatic undefs */\n#undef DUK__ERRFMT_BUFSIZE\n/*\n *  Various Unicode help functions for character classification predicates,\n *  case conversion, decoding, etc.\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Fast path tables\n */\n\n#if defined(DUK_USE_IDCHAR_FASTPATH)\nDUK_INTERNAL const duk_int8_t duk_is_idchar_tab[128] = {\n\t/* 0: not IdentifierStart or IdentifierPart\n\t * 1: IdentifierStart and IdentifierPart\n\t * -1: IdentifierPart only\n\t */\n\t0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,   /* 0x00...0x0f */\n\t0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,   /* 0x10...0x1f */\n\t0,  0,  0,  0,  1,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,   /* 0x20...0x2f */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0,  0,  0,  0,  0,  0,   /* 0x30...0x3f */\n\t0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,   /* 0x40...0x4f */\n\t1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  1,   /* 0x50...0x5f */\n\t0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,   /* 0x60...0x6f */\n\t1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  0,  0,  0,  0,  0    /* 0x70...0x7f */\n};\n#endif\n\n/*\n *  XUTF-8 and CESU-8 encoding/decoding\n */\n\nDUK_INTERNAL duk_small_int_t duk_unicode_get_xutf8_length(duk_ucodepoint_t cp) {\n\tduk_uint_fast32_t x = (duk_uint_fast32_t) cp;\n\tif (x < 0x80UL) {\n\t\t/* 7 bits */\n\t\treturn 1;\n\t} else if (x < 0x800UL) {\n\t\t/* 11 bits */\n\t\treturn 2;\n\t} else if (x < 0x10000UL) {\n\t\t/* 16 bits */\n\t\treturn 3;\n\t} else if (x < 0x200000UL) {\n\t\t/* 21 bits */\n\t\treturn 4;\n\t} else if (x < 0x4000000UL) {\n\t\t/* 26 bits */\n\t\treturn 5;\n\t} else if (x < (duk_ucodepoint_t) 0x80000000UL) {\n\t\t/* 31 bits */\n\t\treturn 6;\n\t} else {\n\t\t/* 36 bits */\n\t\treturn 7;\n\t}\n}\n\n#if defined(DUK_USE_ASSERTIONS)\nDUK_INTERNAL duk_small_int_t duk_unicode_get_cesu8_length(duk_ucodepoint_t cp) {\n\tduk_uint_fast32_t x = (duk_uint_fast32_t) cp;\n\tif (x < 0x80UL) {\n\t\t/* 7 bits */\n\t\treturn 1;\n\t} else if (x < 0x800UL) {\n\t\t/* 11 bits */\n\t\treturn 2;\n\t} else if (x < 0x10000UL) {\n\t\t/* 16 bits */\n\t\treturn 3;\n\t} else {\n\t\t/* Encoded as surrogate pair, each encoding to 3 bytes for\n\t\t * 6 bytes total.  Codepoints above U+10FFFF encode as 6 bytes\n\t\t * too, see duk_unicode_encode_cesu8().\n\t\t  */\n\t\treturn 3 + 3;\n\t}\n}\n#endif  /* DUK_USE_ASSERTIONS */\n\nDUK_INTERNAL const duk_uint8_t duk_unicode_xutf8_markers[7] = {\n\t0x00, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe\n};\n\n/* Encode to extended UTF-8; 'out' must have space for at least\n * DUK_UNICODE_MAX_XUTF8_LENGTH bytes.  Allows encoding of any\n * 32-bit (unsigned) codepoint.\n */\nDUK_INTERNAL duk_small_int_t duk_unicode_encode_xutf8(duk_ucodepoint_t cp, duk_uint8_t *out) {\n\tduk_uint_fast32_t x = (duk_uint_fast32_t) cp;\n\tduk_small_int_t len;\n\tduk_uint8_t marker;\n\tduk_small_int_t i;\n\n\tlen = duk_unicode_get_xutf8_length(cp);\n\tDUK_ASSERT(len > 0);\n\n\tmarker = duk_unicode_xutf8_markers[len - 1];  /* 64-bit OK because always >= 0 */\n\n\ti = len;\n\tDUK_ASSERT(i > 0);\n\tdo {\n\t\ti--;\n\t\tif (i > 0) {\n\t\t\tout[i] = (duk_uint8_t) (0x80 + (x & 0x3f));\n\t\t\tx >>= 6;\n\t\t} else {\n\t\t\t/* Note: masking of 'x' is not necessary because of\n\t\t\t * range check and shifting -> no bits overlapping\n\t\t\t * the marker should be set.\n\t\t\t */\n\t\t\tout[0] = (duk_uint8_t) (marker + x);\n\t\t}\n\t} while (i > 0);\n\n\treturn len;\n}\n\n/* Encode to CESU-8; 'out' must have space for at least\n * DUK_UNICODE_MAX_CESU8_LENGTH bytes; codepoints above U+10FFFF\n * will encode to garbage but won't overwrite the output buffer.\n */\nDUK_INTERNAL duk_small_int_t duk_unicode_encode_cesu8(duk_ucodepoint_t cp, duk_uint8_t *out) {\n\tduk_uint_fast32_t x = (duk_uint_fast32_t) cp;\n\tduk_small_int_t len;\n\n\tif (x < 0x80UL) {\n\t\tout[0] = (duk_uint8_t) x;\n\t\tlen = 1;\n\t} else if (x < 0x800UL) {\n\t\tout[0] = (duk_uint8_t) (0xc0 + ((x >> 6) & 0x1f));\n\t\tout[1] = (duk_uint8_t) (0x80 + (x & 0x3f));\n\t\tlen = 2;\n\t} else if (x < 0x10000UL) {\n\t\t/* surrogate pairs get encoded here */\n\t\tout[0] = (duk_uint8_t) (0xe0 + ((x >> 12) & 0x0f));\n\t\tout[1] = (duk_uint8_t) (0x80 + ((x >> 6) & 0x3f));\n\t\tout[2] = (duk_uint8_t) (0x80 + (x & 0x3f));\n\t\tlen = 3;\n\t} else {\n\t\t/*\n\t\t *  Unicode codepoints above U+FFFF are encoded as surrogate\n\t\t *  pairs here.  This ensures that all CESU-8 codepoints are\n\t\t *  16-bit values as expected in Ecmascript.  The surrogate\n\t\t *  pairs always get a 3-byte encoding (each) in CESU-8.\n\t\t *  See: http://en.wikipedia.org/wiki/Surrogate_pair\n\t\t *\n\t\t *  20-bit codepoint, 10 bits (A and B) per surrogate pair:\n\t\t *\n\t\t *    x = 0b00000000 0000AAAA AAAAAABB BBBBBBBB\n\t\t *  sp1 = 0b110110AA AAAAAAAA  (0xd800 + ((x >> 10) & 0x3ff))\n\t\t *  sp2 = 0b110111BB BBBBBBBB  (0xdc00 + (x & 0x3ff))\n\t\t *\n\t\t *  Encoded into CESU-8:\n\t\t *\n\t\t *  sp1 -> 0b11101101  (0xe0 + ((sp1 >> 12) & 0x0f))\n\t\t *      -> 0b1010AAAA  (0x80 + ((sp1 >> 6) & 0x3f))\n\t\t *      -> 0b10AAAAAA  (0x80 + (sp1 & 0x3f))\n\t\t *  sp2 -> 0b11101101  (0xe0 + ((sp2 >> 12) & 0x0f))\n\t\t *      -> 0b1011BBBB  (0x80 + ((sp2 >> 6) & 0x3f))\n\t\t *      -> 0b10BBBBBB  (0x80 + (sp2 & 0x3f))\n\t\t *\n\t\t *  Note that 0x10000 must be subtracted first.  The code below\n\t\t *  avoids the sp1, sp2 temporaries which saves around 20 bytes\n\t\t *  of code.\n\t\t */\n\n\t\tx -= 0x10000UL;\n\n\t\tout[0] = (duk_uint8_t) (0xed);\n\t\tout[1] = (duk_uint8_t) (0xa0 + ((x >> 16) & 0x0f));\n\t\tout[2] = (duk_uint8_t) (0x80 + ((x >> 10) & 0x3f));\n\t\tout[3] = (duk_uint8_t) (0xed);\n\t\tout[4] = (duk_uint8_t) (0xb0 + ((x >> 6) & 0x0f));\n\t\tout[5] = (duk_uint8_t) (0x80 + (x & 0x3f));\n\t\tlen = 6;\n\t}\n\n\treturn len;\n}\n\n/* Decode helper.  Return zero on error. */\nDUK_INTERNAL duk_small_int_t duk_unicode_decode_xutf8(duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end, duk_ucodepoint_t *out_cp) {\n\tconst duk_uint8_t *p;\n\tduk_uint32_t res;\n\tduk_uint_fast8_t ch;\n\tduk_small_int_t n;\n\n\tDUK_UNREF(thr);\n\n\tp = *ptr;\n\tif (p < ptr_start || p >= ptr_end) {\n\t\tgoto fail;\n\t}\n\n\t/*\n\t *  UTF-8 decoder which accepts longer than standard byte sequences.\n\t *  This allows full 32-bit code points to be used.\n\t */\n\n\tch = (duk_uint_fast8_t) (*p++);\n\tif (ch < 0x80) {\n\t\t/* 0xxx xxxx   [7 bits] */\n\t\tres = (duk_uint32_t) (ch & 0x7f);\n\t\tn = 0;\n\t} else if (ch < 0xc0) {\n\t\t/* 10xx xxxx -> invalid */\n\t\tgoto fail;\n\t} else if (ch < 0xe0) {\n\t\t/* 110x xxxx   10xx xxxx   [11 bits] */\n\t\tres = (duk_uint32_t) (ch & 0x1f);\n\t\tn = 1;\n\t} else if (ch < 0xf0) {\n\t\t/* 1110 xxxx   10xx xxxx   10xx xxxx   [16 bits] */\n\t\tres = (duk_uint32_t) (ch & 0x0f);\n\t\tn = 2;\n\t} else if (ch < 0xf8) {\n\t\t/* 1111 0xxx   10xx xxxx   10xx xxxx   10xx xxxx   [21 bits] */\n\t\tres = (duk_uint32_t) (ch & 0x07);\n\t\tn = 3;\n\t} else if (ch < 0xfc) {\n\t\t/* 1111 10xx   10xx xxxx   10xx xxxx   10xx xxxx   10xx xxxx   [26 bits] */\n\t\tres = (duk_uint32_t) (ch & 0x03);\n\t\tn = 4;\n\t} else if (ch < 0xfe) {\n\t\t/* 1111 110x   10xx xxxx   10xx xxxx   10xx xxxx   10xx xxxx   10xx xxxx   [31 bits] */\n\t\tres = (duk_uint32_t) (ch & 0x01);\n\t\tn = 5;\n\t} else if (ch < 0xff) {\n\t\t/* 1111 1110   10xx xxxx   10xx xxxx   10xx xxxx   10xx xxxx   10xx xxxx   10xx xxxx   [36 bits] */\n\t\tres = (duk_uint32_t) (0);\n\t\tn = 6;\n\t} else {\n\t\t/* 8-byte format could be:\n\t\t * 1111 1111   10xx xxxx   10xx xxxx   10xx xxxx   10xx xxxx   10xx xxxx   10xx xxxx   10xx xxxx   [41 bits]\n\t\t *\n\t\t * However, this format would not have a zero bit following the\n\t\t * leading one bits and would not allow 0xFF to be used as an\n\t\t * \"invalid xutf-8\" marker for internal keys.  Further, 8-byte\n\t\t * encodings (up to 41 bit code points) are not currently needed.\n\t\t */\n\t\tgoto fail;\n\t}\n\n\tDUK_ASSERT(p >= ptr_start);  /* verified at beginning */\n\tif (p + n > ptr_end) {\n\t\t/* check pointer at end */\n\t\tgoto fail;\n\t}\n\n\twhile (n > 0) {\n\t\tDUK_ASSERT(p >= ptr_start && p < ptr_end);\n\t\tch = (duk_uint_fast8_t) (*p++);\n#if 0\n\t\tif (ch & 0xc0 != 0x80) {\n\t\t\t/* not a continuation byte */\n\t\t\tp--;\n\t\t\t*ptr = p;\n\t\t\t*out_cp = DUK_UNICODE_CP_REPLACEMENT_CHARACTER;\n\t\t\treturn 1;\n\t\t}\n#endif\n\t\tres = (res << 6) + (duk_uint32_t) (ch & 0x3f);\n\t\tn--;\n\t}\n\n\t*ptr = p;\n\t*out_cp = res;\n\treturn 1;\n\n fail:\n\treturn 0;\n}\n\n/* used by e.g. duk_regexp_executor.c, string built-ins */\nDUK_INTERNAL duk_ucodepoint_t duk_unicode_decode_xutf8_checked(duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end) {\n\tduk_ucodepoint_t cp;\n\n\tif (duk_unicode_decode_xutf8(thr, ptr, ptr_start, ptr_end, &cp)) {\n\t\treturn cp;\n\t}\n\tDUK_ERROR_INTERNAL(thr);\n\tDUK_UNREACHABLE();\n\treturn 0;\n}\n\n/* Compute (extended) utf-8 length without codepoint encoding validation,\n * used for string interning.\n *\n * NOTE: This algorithm is performance critical, more so than string hashing\n * in some cases.  It is needed when interning a string and needs to scan\n * every byte of the string with no skipping.  Having an ASCII fast path\n * is useful if possible in the algorithm.  The current algorithms were\n * chosen from several variants, based on x64 gcc -O2 testing.  See:\n * https://github.com/svaarala/duktape/pull/422\n *\n * NOTE: must match tools/dukutil.py:duk_unicode_unvalidated_utf8_length().\n */\n\n#if defined(DUK_USE_PREFER_SIZE)\n/* Small variant; roughly 150 bytes smaller than the fast variant. */\nDUK_INTERNAL duk_size_t duk_unicode_unvalidated_utf8_length(const duk_uint8_t *data, duk_size_t blen) {\n\tconst duk_uint8_t *p;\n\tconst duk_uint8_t *p_end;\n\tduk_size_t ncont;\n\tduk_size_t clen;\n\n\tp = data;\n\tp_end = data + blen;\n\tncont = 0;\n\twhile (p != p_end) {\n\t\tduk_uint8_t x;\n\t\tx = *p++;\n\t\tif (DUK_UNLIKELY(x >= 0x80 && x <= 0xbf)) {\n\t\t\tncont++;\n\t\t}\n\t}\n\n\tDUK_ASSERT(ncont <= blen);\n\tclen = blen - ncont;\n\tDUK_ASSERT(clen <= blen);\n\treturn clen;\n}\n#else  /* DUK_USE_PREFER_SIZE */\n/* This seems like a good overall approach.  Fast path for ASCII in 4 byte\n * blocks.\n */\nDUK_INTERNAL duk_size_t duk_unicode_unvalidated_utf8_length(const duk_uint8_t *data, duk_size_t blen) {\n\tconst duk_uint8_t *p;\n\tconst duk_uint8_t *p_end;\n\tconst duk_uint32_t *p32_end;\n\tconst duk_uint32_t *p32;\n\tduk_size_t ncont;\n\tduk_size_t clen;\n\n\tncont = 0;  /* number of continuation (non-initial) bytes in [0x80,0xbf] */\n\tp = data;\n\tp_end = data + blen;\n\tif (blen < 16) {\n\t\tgoto skip_fastpath;\n\t}\n\n\t/* Align 'p' to 4; the input data may have arbitrary alignment.\n\t * End of string check not needed because blen >= 16.\n\t */\n\twhile (((duk_size_t) (const void *) p) & 0x03U) {\n\t\tduk_uint8_t x;\n\t\tx = *p++;\n\t\tif (DUK_UNLIKELY(x >= 0x80 && x <= 0xbf)) {\n\t\t\tncont++;\n\t\t}\n\t}\n\n\t/* Full, aligned 4-byte reads. */\n\tp32_end = (const duk_uint32_t *) (const void *) (p + ((duk_size_t) (p_end - p) & (duk_size_t) (~0x03)));\n\tp32 = (const duk_uint32_t *) (const void *) p;\n\twhile (p32 != (const duk_uint32_t *) p32_end) {\n\t\tduk_uint32_t x;\n\t\tx = *p32++;\n\t\tif (DUK_LIKELY((x & 0x80808080UL) == 0)) {\n\t\t\t;  /* ASCII fast path */\n\t\t} else {\n\t\t\t/* Flip highest bit of each byte which changes\n\t\t\t * the bit pattern 10xxxxxx into 00xxxxxx which\n\t\t\t * allows an easy bit mask test.\n\t\t\t */\n\t\t\tx ^= 0x80808080UL;\n\t\t\tif (DUK_UNLIKELY(!(x & 0xc0000000UL))) {\n\t\t\t\tncont++;\n\t\t\t}\n\t\t\tif (DUK_UNLIKELY(!(x & 0x00c00000UL))) {\n\t\t\t\tncont++;\n\t\t\t}\n\t\t\tif (DUK_UNLIKELY(!(x & 0x0000c000UL))) {\n\t\t\t\tncont++;\n\t\t\t}\n\t\t\tif (DUK_UNLIKELY(!(x & 0x000000c0UL))) {\n\t\t\t\tncont++;\n\t\t\t}\n\t\t}\n\t}\n\tp = (const duk_uint8_t *) p32;\n\t/* Fall through to handle the rest. */\n\n skip_fastpath:\n\twhile (p != p_end) {\n\t\tduk_uint8_t x;\n\t\tx = *p++;\n\t\tif (DUK_UNLIKELY(x >= 0x80 && x <= 0xbf)) {\n\t\t\tncont++;\n\t\t}\n\t}\n\n\tDUK_ASSERT(ncont <= blen);\n\tclen = blen - ncont;\n\tDUK_ASSERT(clen <= blen);\n\treturn clen;\n}\n#endif  /* DUK_USE_PREFER_SIZE */\n\n/*\n *  Unicode range matcher\n *\n *  Matches a codepoint against a packed bitstream of character ranges.\n *  Used for slow path Unicode matching.\n */\n\n/* Must match tools/extract_chars.py, generate_match_table3(). */\nDUK_LOCAL duk_uint32_t duk__uni_decode_value(duk_bitdecoder_ctx *bd_ctx) {\n\tduk_uint32_t t;\n\n\tt = (duk_uint32_t) duk_bd_decode(bd_ctx, 4);\n\tif (t <= 0x0eU) {\n\t\treturn t;\n\t}\n\tt = (duk_uint32_t) duk_bd_decode(bd_ctx, 8);\n\tif (t <= 0xfdU) {\n\t\treturn t + 0x0f;\n\t}\n\tif (t == 0xfeU) {\n\t\tt = (duk_uint32_t) duk_bd_decode(bd_ctx, 12);\n\t\treturn t + 0x0fU + 0xfeU;\n\t} else {\n\t\tt = (duk_uint32_t) duk_bd_decode(bd_ctx, 24);\n\t\treturn t + 0x0fU + 0xfeU + 0x1000UL;\n\t}\n}\n\nDUK_LOCAL duk_small_int_t duk__uni_range_match(const duk_uint8_t *unitab, duk_size_t unilen, duk_codepoint_t cp) {\n\tduk_bitdecoder_ctx bd_ctx;\n\tduk_codepoint_t prev_re;\n\n\tDUK_MEMZERO(&bd_ctx, sizeof(bd_ctx));\n\tbd_ctx.data = (const duk_uint8_t *) unitab;\n\tbd_ctx.length = (duk_size_t) unilen;\n\n\tprev_re = 0;\n\tfor (;;) {\n\t\tduk_codepoint_t r1, r2;\n\t\tr1 = (duk_codepoint_t) duk__uni_decode_value(&bd_ctx);\n\t\tif (r1 == 0) {\n\t\t\tbreak;\n\t\t}\n\t\tr2 = (duk_codepoint_t) duk__uni_decode_value(&bd_ctx);\n\n\t\tr1 = prev_re + r1;\n\t\tr2 = r1 + r2;\n\t\tprev_re = r2;\n\n\t\t/* [r1,r2] is the range */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"duk__uni_range_match: cp=%06lx range=[0x%06lx,0x%06lx]\",\n\t\t                     (unsigned long) cp, (unsigned long) r1, (unsigned long) r2));\n\t\tif (cp >= r1 && cp <= r2) {\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\n/*\n *  \"WhiteSpace\" production check.\n */\n\nDUK_INTERNAL duk_small_int_t duk_unicode_is_whitespace(duk_codepoint_t cp) {\n\t/*\n\t *  E5 Section 7.2 specifies six characters specifically as\n\t *  white space:\n\t *\n\t *    0009;<control>;Cc;0;S;;;;;N;CHARACTER TABULATION;;;;\n\t *    000B;<control>;Cc;0;S;;;;;N;LINE TABULATION;;;;\n\t *    000C;<control>;Cc;0;WS;;;;;N;FORM FEED (FF);;;;\n\t *    0020;SPACE;Zs;0;WS;;;;;N;;;;;\n\t *    00A0;NO-BREAK SPACE;Zs;0;CS;<noBreak> 0020;;;;N;NON-BREAKING SPACE;;;;\n\t *    FEFF;ZERO WIDTH NO-BREAK SPACE;Cf;0;BN;;;;;N;BYTE ORDER MARK;;;;\n\t *\n\t *  It also specifies any Unicode category 'Zs' characters as white\n\t *  space.  These can be extracted with the \"tools/extract_chars.py\" script.\n\t *  Current result:\n\t *\n\t *    RAW OUTPUT:\n\t *    ===========\n\t *    0020;SPACE;Zs;0;WS;;;;;N;;;;;\n\t *    00A0;NO-BREAK SPACE;Zs;0;CS;<noBreak> 0020;;;;N;NON-BREAKING SPACE;;;;\n\t *    1680;OGHAM SPACE MARK;Zs;0;WS;;;;;N;;;;;\n\t *    180E;MONGOLIAN VOWEL SEPARATOR;Zs;0;WS;;;;;N;;;;;\n\t *    2000;EN QUAD;Zs;0;WS;2002;;;;N;;;;;\n\t *    2001;EM QUAD;Zs;0;WS;2003;;;;N;;;;;\n\t *    2002;EN SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;\n\t *    2003;EM SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;\n\t *    2004;THREE-PER-EM SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;\n\t *    2005;FOUR-PER-EM SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;\n\t *    2006;SIX-PER-EM SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;\n\t *    2007;FIGURE SPACE;Zs;0;WS;<noBreak> 0020;;;;N;;;;;\n\t *    2008;PUNCTUATION SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;\n\t *    2009;THIN SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;\n\t *    200A;HAIR SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;\n\t *    202F;NARROW NO-BREAK SPACE;Zs;0;CS;<noBreak> 0020;;;;N;;;;;\n\t *    205F;MEDIUM MATHEMATICAL SPACE;Zs;0;WS;<compat> 0020;;;;N;;;;;\n\t *    3000;IDEOGRAPHIC SPACE;Zs;0;WS;<wide> 0020;;;;N;;;;;\n\t *\n\t *    RANGES:\n\t *    =======\n\t *    0x0020\n\t *    0x00a0\n\t *    0x1680\n\t *    0x180e\n\t *    0x2000 ... 0x200a\n\t *    0x202f\n\t *    0x205f\n\t *    0x3000\n\t *\n\t *  A manual decoder (below) is probably most compact for this.\n\t */\n\n\tduk_uint_fast8_t lo;\n\tduk_uint_fast32_t hi;\n\n\t/* cp == -1 (EOF) never matches and causes return value 0 */\n\n\tlo = (duk_uint_fast8_t) (cp & 0xff);\n\thi = (duk_uint_fast32_t) (cp >> 8);  /* does not fit into an uchar */\n\n\tif (hi == 0x0000UL) {\n\t\tif (lo == 0x09U || lo == 0x0bU || lo == 0x0cU ||\n\t\t    lo == 0x20U || lo == 0xa0U) {\n\t\t\treturn 1;\n\t\t}\n\t} else if (hi == 0x0020UL) {\n\t\tif (lo <= 0x0aU || lo == 0x2fU || lo == 0x5fU) {\n\t\t\treturn 1;\n\t\t}\n\t} else if (cp == 0x1680L || cp == 0x180eL || cp == 0x3000L ||\n\t           cp == 0xfeffL) {\n\t\treturn 1;\n\t}\n\n\treturn 0;\n}\n\n/*\n *  \"LineTerminator\" production check.\n */\n\nDUK_INTERNAL duk_small_int_t duk_unicode_is_line_terminator(duk_codepoint_t cp) {\n\t/*\n\t *  E5 Section 7.3\n\t *\n\t *  A LineTerminatorSequence essentially merges <CR> <LF> sequences\n\t *  into a single line terminator.  This must be handled by the caller.\n\t */\n\n\tif (cp == 0x000aL || cp == 0x000dL || cp == 0x2028L ||\n\t    cp == 0x2029L) {\n\t\treturn 1;\n\t}\n\n\treturn 0;\n}\n\n/*\n *  \"IdentifierStart\" production check.\n */\n\nDUK_INTERNAL duk_small_int_t duk_unicode_is_identifier_start(duk_codepoint_t cp) {\n\t/*\n\t *  E5 Section 7.6:\n\t *\n\t *    IdentifierStart:\n\t *      UnicodeLetter\n\t *      $\n\t *      _\n\t *      \\ UnicodeEscapeSequence\n\t *\n\t *  IdentifierStart production has one multi-character production:\n\t *\n\t *    \\ UnicodeEscapeSequence\n\t *\n\t *  The '\\' character is -not- matched by this function.  Rather, the caller\n\t *  should decode the escape and then call this function to check whether the\n\t *  decoded character is acceptable (see discussion in E5 Section 7.6).\n\t *\n\t *  The \"UnicodeLetter\" alternative of the production allows letters\n\t *  from various Unicode categories.  These can be extracted with the\n\t *  \"tools/extract_chars.py\" script.\n\t *\n\t *  Because the result has hundreds of Unicode codepoint ranges, matching\n\t *  for any values >= 0x80 are done using a very slow range-by-range scan\n\t *  and a packed range format.\n\t *\n\t *  The ASCII portion (codepoints 0x00 ... 0x7f) is fast-pathed below because\n\t *  it matters the most.  The ASCII related ranges of IdentifierStart are:\n\t *\n\t *    0x0041 ... 0x005a     ['A' ... 'Z']\n\t *    0x0061 ... 0x007a     ['a' ... 'z']\n\t *    0x0024                ['$']\n\t *    0x005f                ['_']\n\t */\n\n\t/* ASCII (and EOF) fast path -- quick accept and reject */\n\tif (cp <= 0x7fL) {\n#if defined(DUK_USE_IDCHAR_FASTPATH)\n\t\treturn (cp >= 0) && (duk_is_idchar_tab[cp] > 0);\n#else\n\t\tif ((cp >= 'a' && cp <= 'z') ||\n\t\t    (cp >= 'A' && cp <= 'Z') ||\n\t\t    cp == '_' || cp == '$') {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n#endif\n\t}\n\n\t/* Non-ASCII slow path (range-by-range linear comparison), very slow */\n\n#if defined(DUK_USE_SOURCE_NONBMP)\n\tif (duk__uni_range_match(duk_unicode_ids_noa,\n\t                         (duk_size_t) sizeof(duk_unicode_ids_noa),\n\t                         (duk_codepoint_t) cp)) {\n\t\treturn 1;\n\t}\n\treturn 0;\n#else\n\tif (cp < 0x10000L) {\n\t\tif (duk__uni_range_match(duk_unicode_ids_noabmp,\n\t\t                         sizeof(duk_unicode_ids_noabmp),\n\t\t                         (duk_codepoint_t) cp)) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t} else {\n\t\t/* without explicit non-BMP support, assume non-BMP characters\n\t\t * are always accepted as identifier characters.\n\t\t */\n\t\treturn 1;\n\t}\n#endif\n}\n\n/*\n *  \"IdentifierPart\" production check.\n */\n\nDUK_INTERNAL duk_small_int_t duk_unicode_is_identifier_part(duk_codepoint_t cp) {\n\t/*\n\t *  E5 Section 7.6:\n\t *\n\t *    IdentifierPart:\n\t *      IdentifierStart\n\t *      UnicodeCombiningMark\n\t *      UnicodeDigit\n\t *      UnicodeConnectorPunctuation\n\t *      <ZWNJ>  [U+200C]\n\t *      <ZWJ>   [U+200D]\n\t *\n\t *  IdentifierPart production has one multi-character production\n\t *  as part of its IdentifierStart alternative.  The '\\' character\n\t *  of an escape sequence is not matched here, see discussion in\n\t *  duk_unicode_is_identifier_start().\n\t *\n\t *  To match non-ASCII characters (codepoints >= 0x80), a very slow\n\t *  linear range-by-range scan is used.  The codepoint is first compared\n\t *  to the IdentifierStart ranges, and if it doesn't match, then to a\n\t *  set consisting of code points in IdentifierPart but not in\n\t *  IdentifierStart.  This is done to keep the unicode range data small,\n\t *  at the expense of speed.\n\t *\n\t *  The ASCII fast path consists of:\n\t *\n\t *    0x0030 ... 0x0039     ['0' ... '9', UnicodeDigit]\n\t *    0x0041 ... 0x005a     ['A' ... 'Z', IdentifierStart]\n\t *    0x0061 ... 0x007a     ['a' ... 'z', IdentifierStart]\n\t *    0x0024                ['$', IdentifierStart]\n\t *    0x005f                ['_', IdentifierStart and\n\t *                                UnicodeConnectorPunctuation]\n\t *\n\t *  UnicodeCombiningMark has no code points <= 0x7f.\n\t *\n\t *  The matching code reuses the \"identifier start\" tables, and then\n\t *  consults a separate range set for characters in \"identifier part\"\n\t *  but not in \"identifier start\".  These can be extracted with the\n\t *  \"tools/extract_chars.py\" script.\n\t *\n\t *  UnicodeCombiningMark -> categories Mn, Mc\n\t *  UnicodeDigit -> categories Nd\n\t *  UnicodeConnectorPunctuation -> categories Pc\n\t */\n\n\t/* ASCII (and EOF) fast path -- quick accept and reject */\n\tif (cp <= 0x7fL) {\n#if defined(DUK_USE_IDCHAR_FASTPATH)\n\t\treturn (cp >= 0) && (duk_is_idchar_tab[cp] != 0);\n#else\n\t\tif ((cp >= 'a' && cp <= 'z') ||\n\t\t    (cp >= 'A' && cp <= 'Z') ||\n\t\t    (cp >= '0' && cp <= '9') ||\n\t\t    cp == '_' || cp == '$') {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n#endif\n\t}\n\n\t/* Non-ASCII slow path (range-by-range linear comparison), very slow */\n\n#if defined(DUK_USE_SOURCE_NONBMP)\n\tif (duk__uni_range_match(duk_unicode_ids_noa,\n\t                         sizeof(duk_unicode_ids_noa),\n\t                         (duk_codepoint_t) cp) ||\n\t    duk__uni_range_match(duk_unicode_idp_m_ids_noa,\n\t                         sizeof(duk_unicode_idp_m_ids_noa),\n\t                         (duk_codepoint_t) cp)) {\n\t\treturn 1;\n\t}\n\treturn 0;\n#else\n\tif (cp < 0x10000L) {\n\t\tif (duk__uni_range_match(duk_unicode_ids_noabmp,\n\t\t                         sizeof(duk_unicode_ids_noabmp),\n\t\t                         (duk_codepoint_t) cp) ||\n\t\t    duk__uni_range_match(duk_unicode_idp_m_ids_noabmp,\n\t\t                         sizeof(duk_unicode_idp_m_ids_noabmp),\n\t\t                         (duk_codepoint_t) cp)) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t} else {\n\t\t/* without explicit non-BMP support, assume non-BMP characters\n\t\t * are always accepted as identifier characters.\n\t\t */\n\t\treturn 1;\n\t}\n#endif\n}\n\n/*\n *  Unicode letter check.\n */\n\nDUK_INTERNAL duk_small_int_t duk_unicode_is_letter(duk_codepoint_t cp) {\n\t/*\n\t *  Unicode letter is now taken to be the categories:\n\t *\n\t *    Lu, Ll, Lt, Lm, Lo\n\t *\n\t *  (Not sure if this is exactly correct.)\n\t *\n\t *  The ASCII fast path consists of:\n\t *\n\t *    0x0041 ... 0x005a     ['A' ... 'Z']\n\t *    0x0061 ... 0x007a     ['a' ... 'z']\n\t */\n\n\t/* ASCII (and EOF) fast path -- quick accept and reject */\n\tif (cp <= 0x7fL) {\n\t\tif ((cp >= 'a' && cp <= 'z') ||\n\t\t    (cp >= 'A' && cp <= 'Z')) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t}\n\n\t/* Non-ASCII slow path (range-by-range linear comparison), very slow */\n\n#if defined(DUK_USE_SOURCE_NONBMP)\n\tif (duk__uni_range_match(duk_unicode_ids_noa,\n\t                         sizeof(duk_unicode_ids_noa),\n\t                         (duk_codepoint_t) cp) &&\n\t    !duk__uni_range_match(duk_unicode_ids_m_let_noa,\n\t                          sizeof(duk_unicode_ids_m_let_noa),\n\t                          (duk_codepoint_t) cp)) {\n\t\treturn 1;\n\t}\n\treturn 0;\n#else\n\tif (cp < 0x10000L) {\n\t\tif (duk__uni_range_match(duk_unicode_ids_noabmp,\n\t\t                         sizeof(duk_unicode_ids_noabmp),\n\t\t                         (duk_codepoint_t) cp) &&\n\t\t    !duk__uni_range_match(duk_unicode_ids_m_let_noabmp,\n\t\t                          sizeof(duk_unicode_ids_m_let_noabmp),\n\t\t                          (duk_codepoint_t) cp)) {\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t} else {\n\t\t/* without explicit non-BMP support, assume non-BMP characters\n\t\t * are always accepted as letters.\n\t\t */\n\t\treturn 1;\n\t}\n#endif\n}\n\n/*\n *  Complex case conversion helper which decodes a bit-packed conversion\n *  control stream generated by tools/extract_caseconv.py.  The conversion\n *  is very slow because it runs through the conversion data in a linear\n *  fashion to save space (which is why ASCII characters have a special\n *  fast path before arriving here).\n *\n *  The particular bit counts etc have been determined experimentally to\n *  be small but still sufficient, and must match the Python script\n *  (tools/extract_caseconv.py).\n *\n *  The return value is the case converted codepoint or -1 if the conversion\n *  results in multiple characters (this is useful for regexp Canonicalization\n *  operation).  If 'buf' is not NULL, the result codepoint(s) are also\n *  appended to the hbuffer.\n *\n *  Context and locale specific rules must be checked before consulting\n *  this function.\n */\n\nDUK_LOCAL\nduk_codepoint_t duk__slow_case_conversion(duk_hthread *thr,\n                                          duk_bufwriter_ctx *bw,\n                                          duk_codepoint_t cp,\n                                          duk_bitdecoder_ctx *bd_ctx) {\n\tduk_small_int_t skip = 0;\n\tduk_small_int_t n;\n\tduk_small_int_t t;\n\tduk_small_int_t count;\n\tduk_codepoint_t tmp_cp;\n\tduk_codepoint_t start_i;\n\tduk_codepoint_t start_o;\n\n\tDUK_UNREF(thr);\n\tDUK_ASSERT(bd_ctx != NULL);\n\n\tDUK_DDD(DUK_DDDPRINT(\"slow case conversion for codepoint: %ld\", (long) cp));\n\n\t/* range conversion with a \"skip\" */\n\tDUK_DDD(DUK_DDDPRINT(\"checking ranges\"));\n\tfor (;;) {\n\t\tskip++;\n\t\tn = (duk_small_int_t) duk_bd_decode(bd_ctx, 6);\n\t\tif (n == 0x3f) {\n\t\t\t/* end marker */\n\t\t\tbreak;\n\t\t}\n\t\tDUK_DDD(DUK_DDDPRINT(\"skip=%ld, n=%ld\", (long) skip, (long) n));\n\n\t\twhile (n--) {\n\t\t\tstart_i = (duk_codepoint_t) duk_bd_decode(bd_ctx, 16);\n\t\t\tstart_o = (duk_codepoint_t) duk_bd_decode(bd_ctx, 16);\n\t\t\tcount = (duk_small_int_t) duk_bd_decode(bd_ctx, 7);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"range: start_i=%ld, start_o=%ld, count=%ld, skip=%ld\",\n\t\t\t                     (long) start_i, (long) start_o, (long) count, (long) skip));\n\n\t\t\tif (cp >= start_i) {\n\t\t\t\ttmp_cp = cp - start_i;  /* always >= 0 */\n\t\t\t\tif (tmp_cp < (duk_codepoint_t) count * (duk_codepoint_t) skip &&\n\t\t\t\t    (tmp_cp % (duk_codepoint_t) skip) == 0) {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"range matches input codepoint\"));\n\t\t\t\t\tcp = start_o + tmp_cp;\n\t\t\t\t\tgoto single;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/* 1:1 conversion */\n\tn = (duk_small_int_t) duk_bd_decode(bd_ctx, 7);\n\tDUK_DDD(DUK_DDDPRINT(\"checking 1:1 conversions (count %ld)\", (long) n));\n\twhile (n--) {\n\t\tstart_i = (duk_codepoint_t) duk_bd_decode(bd_ctx, 16);\n\t\tstart_o = (duk_codepoint_t) duk_bd_decode(bd_ctx, 16);\n\t\tDUK_DDD(DUK_DDDPRINT(\"1:1 conversion %ld -> %ld\", (long) start_i, (long) start_o));\n\t\tif (cp == start_i) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"1:1 matches input codepoint\"));\n\t\t\tcp = start_o;\n\t\t\tgoto single;\n\t\t}\n\t}\n\n\t/* complex, multicharacter conversion */\n\tn = (duk_small_int_t) duk_bd_decode(bd_ctx, 7);\n\tDUK_DDD(DUK_DDDPRINT(\"checking 1:n conversions (count %ld)\", (long) n));\n\twhile (n--) {\n\t\tstart_i = (duk_codepoint_t) duk_bd_decode(bd_ctx, 16);\n\t\tt = (duk_small_int_t) duk_bd_decode(bd_ctx, 2);\n\t\tDUK_DDD(DUK_DDDPRINT(\"1:n conversion %ld -> %ld chars\", (long) start_i, (long) t));\n\t\tif (cp == start_i) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"1:n matches input codepoint\"));\n\t\t\tif (bw != NULL) {\n\t\t\t\twhile (t--) {\n\t\t\t\t\ttmp_cp = (duk_codepoint_t) duk_bd_decode(bd_ctx, 16);\n\t\t\t\t\tDUK_BW_WRITE_RAW_XUTF8(thr, bw, (duk_ucodepoint_t) tmp_cp);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn -1;\n\t\t} else {\n\t\t\twhile (t--) {\n\t\t\t\t(void) duk_bd_decode(bd_ctx, 16);\n\t\t\t}\n\t\t}\n\t}\n\n\t/* default: no change */\n\tDUK_DDD(DUK_DDDPRINT(\"no rule matches, output is same as input\"));\n\t/* fall through */\n\n single:\n\tif (bw != NULL) {\n\t\tDUK_BW_WRITE_RAW_XUTF8(thr, bw, (duk_ucodepoint_t) cp);\n\t}\n\treturn cp;\n}\n\n/*\n *  Case conversion helper, with context/local sensitivity.\n *  For proper case conversion, one needs to know the character\n *  and the preceding and following characters, as well as\n *  locale/language.\n */\n\n/* XXX: add 'language' argument when locale/language sensitive rule\n * support added.\n */\nDUK_LOCAL\nduk_codepoint_t duk__case_transform_helper(duk_hthread *thr,\n                                           duk_bufwriter_ctx *bw,\n                                           duk_codepoint_t cp,\n                                           duk_codepoint_t prev,\n                                           duk_codepoint_t next,\n                                           duk_bool_t uppercase) {\n\tduk_bitdecoder_ctx bd_ctx;\n\n\t/* fast path for ASCII */\n\tif (cp < 0x80L) {\n\t\t/* XXX: there are language sensitive rules for the ASCII range.\n\t\t * If/when language/locale support is implemented, they need to\n\t\t * be implemented here for the fast path.  There are no context\n\t\t * sensitive rules for ASCII range.\n\t\t */\n\n\t\tif (uppercase) {\n\t\t\tif (cp >= 'a' && cp <= 'z') {\n\t\t\t\tcp = cp - 'a' + 'A';\n\t\t\t}\n\t\t} else {\n\t\t\tif (cp >= 'A' && cp <= 'Z') {\n\t\t\t\tcp = cp - 'A' + 'a';\n\t\t\t}\n\t\t}\n\n\t\tif (bw != NULL) {\n\t\t\tDUK_BW_WRITE_RAW_U8(thr, bw, (duk_uint8_t) cp);\n\t\t}\n\t\treturn cp;\n\t}\n\n\t/* context and locale specific rules which cannot currently be represented\n\t * in the caseconv bitstream: hardcoded rules in C\n\t */\n\tif (uppercase) {\n\t\t/* XXX: turkish / azeri */\n\t} else {\n\t\t/*\n\t\t *  Final sigma context specific rule.  This is a rather tricky\n\t\t *  rule and this handling is probably not 100% correct now.\n\t\t *  The rule is not locale/language specific so it is supported.\n\t\t */\n\n\t\tif (cp == 0x03a3L &&    /* U+03A3 = GREEK CAPITAL LETTER SIGMA */\n\t\t    duk_unicode_is_letter(prev) &&        /* prev exists and is not a letter */\n\t\t    !duk_unicode_is_letter(next)) {       /* next does not exist or next is not a letter */\n\t\t\t/* Capital sigma occurred at \"end of word\", lowercase to\n\t\t\t * U+03C2 = GREEK SMALL LETTER FINAL SIGMA.  Otherwise\n\t\t\t * fall through and let the normal rules lowercase it to\n\t\t\t * U+03C3 = GREEK SMALL LETTER SIGMA.\n\t\t\t */\n\t\t\tcp = 0x03c2L;\n\t\t\tgoto singlechar;\n\t\t}\n\n\t\t/* XXX: lithuanian not implemented */\n\t\t/* XXX: lithuanian, explicit dot rules */\n\t\t/* XXX: turkish / azeri, lowercase rules */\n\t}\n\n\t/* 1:1 or special conversions, but not locale/context specific: script generated rules */\n\tDUK_MEMZERO(&bd_ctx, sizeof(bd_ctx));\n\tif (uppercase) {\n\t\tbd_ctx.data = (const duk_uint8_t *) duk_unicode_caseconv_uc;\n\t\tbd_ctx.length = (duk_size_t) sizeof(duk_unicode_caseconv_uc);\n\t} else {\n\t\tbd_ctx.data = (const duk_uint8_t *) duk_unicode_caseconv_lc;\n\t\tbd_ctx.length = (duk_size_t) sizeof(duk_unicode_caseconv_lc);\n\t}\n\treturn duk__slow_case_conversion(thr, bw, cp, &bd_ctx);\n\n singlechar:\n\tif (bw != NULL) {\n\t\tDUK_BW_WRITE_RAW_XUTF8(thr, bw, (duk_ucodepoint_t) cp);\n\t}\n\treturn cp;\n\n /* unused now, not needed until Turkish/Azeri */\n#if 0\n nochar:\n\treturn -1;\n#endif\n}\n\n/*\n *  Replace valstack top with case converted version.\n */\n\nDUK_INTERNAL void duk_unicode_case_convert_string(duk_hthread *thr, duk_small_int_t uppercase) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hstring *h_input;\n\tduk_bufwriter_ctx bw_alloc;\n\tduk_bufwriter_ctx *bw;\n\tconst duk_uint8_t *p, *p_start, *p_end;\n\tduk_codepoint_t prev, curr, next;\n\n\th_input = duk_require_hstring(ctx, -1);  /* Accept symbols. */\n\tDUK_ASSERT(h_input != NULL);\n\n\tbw = &bw_alloc;\n\tDUK_BW_INIT_PUSHBUF(thr, bw, DUK_HSTRING_GET_BYTELEN(h_input));\n\n\t/* [ ... input buffer ] */\n\n\tp_start = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_input);\n\tp_end = p_start + DUK_HSTRING_GET_BYTELEN(h_input);\n\tp = p_start;\n\n\tprev = -1; DUK_UNREF(prev);\n\tcurr = -1;\n\tnext = -1;\n\tfor (;;) {\n\t\tprev = curr;\n\t\tcurr = next;\n\t\tnext = -1;\n\t\tif (p < p_end) {\n\t\t\tnext = (duk_codepoint_t) duk_unicode_decode_xutf8_checked(thr, &p, p_start, p_end);\n\t\t} else {\n\t\t\t/* end of input and last char has been processed */\n\t\t\tif (curr < 0) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t/* on first round, skip */\n\t\tif (curr >= 0) {\n\t\t\t/* XXX: could add a fast path to process chunks of input codepoints,\n\t\t\t * but relative benefit would be quite small.\n\t\t\t */\n\n\t\t\t/* Ensure space for maximum multi-character result; estimate is overkill. */\n\t\t\tDUK_BW_ENSURE(thr, bw, 8 * DUK_UNICODE_MAX_XUTF8_LENGTH);\n\n\t\t\tduk__case_transform_helper(thr,\n\t\t\t                           bw,\n\t\t\t                           (duk_codepoint_t) curr,\n\t\t\t                           prev,\n\t\t\t                           next,\n\t\t\t                           uppercase);\n\t\t}\n\t}\n\n\tDUK_BW_COMPACT(thr, bw);\n\t(void) duk_buffer_to_string(ctx, -1);  /* Safe, output is encoded. */\n\t/* invalidates h_buf pointer */\n\tduk_remove_m2(ctx);\n}\n\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\n/*\n *  Canonicalize() abstract operation needed for canonicalization of individual\n *  codepoints during regexp compilation and execution, see E5 Section 15.10.2.8.\n *  Note that codepoints are canonicalized one character at a time, so no context\n *  specific rules can apply.  Locale specific rules can apply, though.\n */\n\nDUK_INTERNAL duk_codepoint_t duk_unicode_re_canonicalize_char(duk_hthread *thr, duk_codepoint_t cp) {\n#if defined(DUK_USE_REGEXP_CANON_WORKAROUND)\n\t/* Fast canonicalization lookup at the cost of 128kB footprint. */\n\tDUK_ASSERT(cp >= 0);\n\tDUK_UNREF(thr);\n\tif (DUK_LIKELY(cp < 0x10000L)) {\n\t\treturn (duk_codepoint_t) duk_unicode_re_canon_lookup[cp];\n\t}\n\treturn cp;\n#else  /* DUK_USE_REGEXP_CANON_WORKAROUND */\n\tduk_codepoint_t y;\n\n\ty = duk__case_transform_helper(thr,\n\t                               NULL,    /* NULL is allowed, no output */\n\t                               cp,      /* curr char */\n\t                               -1,      /* prev char */\n\t                               -1,      /* next char */\n\t                               1);      /* uppercase */\n\n\tif ((y < 0) || (cp >= 0x80 && y < 0x80)) {\n\t\t/* multiple codepoint conversion or non-ASCII mapped to ASCII\n\t\t * --> leave as is.\n\t\t */\n\t\treturn cp;\n\t}\n\n\treturn y;\n#endif  /* DUK_USE_REGEXP_CANON_WORKAROUND */\n}\n\n/*\n *  E5 Section 15.10.2.6 \"IsWordChar\" abstract operation.  Assume\n *  x < 0 for characters read outside the string.\n */\n\nDUK_INTERNAL duk_small_int_t duk_unicode_re_is_wordchar(duk_codepoint_t x) {\n\t/*\n\t *  Note: the description in E5 Section 15.10.2.6 has a typo, it\n\t *  contains 'A' twice and lacks 'a'; the intent is [0-9a-zA-Z_].\n\t */\n\tif ((x >= '0' && x <= '9') ||\n\t    (x >= 'a' && x <= 'z') ||\n\t    (x >= 'A' && x <= 'Z') ||\n\t    (x == '_')) {\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\n/*\n *  Regexp range tables\n */\n\n/* exposed because lexer needs these too */\nDUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_digit[2] = {\n\t(duk_uint16_t) 0x0030UL, (duk_uint16_t) 0x0039UL,\n};\nDUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_white[22] = {\n\t(duk_uint16_t) 0x0009UL, (duk_uint16_t) 0x000DUL,\n\t(duk_uint16_t) 0x0020UL, (duk_uint16_t) 0x0020UL,\n\t(duk_uint16_t) 0x00A0UL, (duk_uint16_t) 0x00A0UL,\n\t(duk_uint16_t) 0x1680UL, (duk_uint16_t) 0x1680UL,\n\t(duk_uint16_t) 0x180EUL, (duk_uint16_t) 0x180EUL,\n\t(duk_uint16_t) 0x2000UL, (duk_uint16_t) 0x200AUL,\n\t(duk_uint16_t) 0x2028UL, (duk_uint16_t) 0x2029UL,\n\t(duk_uint16_t) 0x202FUL, (duk_uint16_t) 0x202FUL,\n\t(duk_uint16_t) 0x205FUL, (duk_uint16_t) 0x205FUL,\n\t(duk_uint16_t) 0x3000UL, (duk_uint16_t) 0x3000UL,\n\t(duk_uint16_t) 0xFEFFUL, (duk_uint16_t) 0xFEFFUL,\n};\nDUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_wordchar[8] = {\n\t(duk_uint16_t) 0x0030UL, (duk_uint16_t) 0x0039UL,\n\t(duk_uint16_t) 0x0041UL, (duk_uint16_t) 0x005AUL,\n\t(duk_uint16_t) 0x005FUL, (duk_uint16_t) 0x005FUL,\n\t(duk_uint16_t) 0x0061UL, (duk_uint16_t) 0x007AUL,\n};\nDUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_not_digit[4] = {\n\t(duk_uint16_t) 0x0000UL, (duk_uint16_t) 0x002FUL,\n\t(duk_uint16_t) 0x003AUL, (duk_uint16_t) 0xFFFFUL,\n};\nDUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_not_white[24] = {\n\t(duk_uint16_t) 0x0000UL, (duk_uint16_t) 0x0008UL,\n\t(duk_uint16_t) 0x000EUL, (duk_uint16_t) 0x001FUL,\n\t(duk_uint16_t) 0x0021UL, (duk_uint16_t) 0x009FUL,\n\t(duk_uint16_t) 0x00A1UL, (duk_uint16_t) 0x167FUL,\n\t(duk_uint16_t) 0x1681UL, (duk_uint16_t) 0x180DUL,\n\t(duk_uint16_t) 0x180FUL, (duk_uint16_t) 0x1FFFUL,\n\t(duk_uint16_t) 0x200BUL, (duk_uint16_t) 0x2027UL,\n\t(duk_uint16_t) 0x202AUL, (duk_uint16_t) 0x202EUL,\n\t(duk_uint16_t) 0x2030UL, (duk_uint16_t) 0x205EUL,\n\t(duk_uint16_t) 0x2060UL, (duk_uint16_t) 0x2FFFUL,\n\t(duk_uint16_t) 0x3001UL, (duk_uint16_t) 0xFEFEUL,\n\t(duk_uint16_t) 0xFF00UL, (duk_uint16_t) 0xFFFFUL,\n};\nDUK_INTERNAL const duk_uint16_t duk_unicode_re_ranges_not_wordchar[10] = {\n\t(duk_uint16_t) 0x0000UL, (duk_uint16_t) 0x002FUL,\n\t(duk_uint16_t) 0x003AUL, (duk_uint16_t) 0x0040UL,\n\t(duk_uint16_t) 0x005BUL, (duk_uint16_t) 0x005EUL,\n\t(duk_uint16_t) 0x0060UL, (duk_uint16_t) 0x0060UL,\n\t(duk_uint16_t) 0x007BUL, (duk_uint16_t) 0xFFFFUL,\n};\n\n#endif  /* DUK_USE_REGEXP_SUPPORT */\n/*\n *  Misc util stuff\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Lowercase digits for radix values 2 to 36.  Also doubles as lowercase\n *  hex nybble table.\n */\n\nDUK_INTERNAL const duk_uint8_t duk_lc_digits[36] = {\n\tDUK_ASC_0, DUK_ASC_1, DUK_ASC_2, DUK_ASC_3,\n\tDUK_ASC_4, DUK_ASC_5, DUK_ASC_6, DUK_ASC_7,\n\tDUK_ASC_8, DUK_ASC_9, DUK_ASC_LC_A, DUK_ASC_LC_B,\n\tDUK_ASC_LC_C, DUK_ASC_LC_D, DUK_ASC_LC_E, DUK_ASC_LC_F,\n\tDUK_ASC_LC_G, DUK_ASC_LC_H, DUK_ASC_LC_I, DUK_ASC_LC_J,\n\tDUK_ASC_LC_K, DUK_ASC_LC_L, DUK_ASC_LC_M, DUK_ASC_LC_N,\n\tDUK_ASC_LC_O, DUK_ASC_LC_P, DUK_ASC_LC_Q, DUK_ASC_LC_R,\n\tDUK_ASC_LC_S, DUK_ASC_LC_T, DUK_ASC_LC_U, DUK_ASC_LC_V,\n\tDUK_ASC_LC_W, DUK_ASC_LC_X, DUK_ASC_LC_Y, DUK_ASC_LC_Z\n};\n\nDUK_INTERNAL const duk_uint8_t duk_uc_nybbles[16] = {\n\tDUK_ASC_0, DUK_ASC_1, DUK_ASC_2, DUK_ASC_3,\n\tDUK_ASC_4, DUK_ASC_5, DUK_ASC_6, DUK_ASC_7,\n\tDUK_ASC_8, DUK_ASC_9, DUK_ASC_UC_A, DUK_ASC_UC_B,\n\tDUK_ASC_UC_C, DUK_ASC_UC_D, DUK_ASC_UC_E, DUK_ASC_UC_F\n};\n\n/*\n *  Table for hex decoding ASCII hex digits\n */\n\nDUK_INTERNAL const duk_int8_t duk_hex_dectab[256] = {\n\t/* -1 if invalid */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  /* 0x00-0x0f */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  /* 0x10-0x1f */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  /* 0x20-0x2f */\n\t 0,  1,  2,  3,  4,  5,  6,  7,  8,  9, -1, -1, -1, -1, -1, -1,  /* 0x30-0x3f */\n\t-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,  /* 0x40-0x4f */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  /* 0x50-0x5f */\n\t-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,  /* 0x60-0x6f */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  /* 0x70-0x7f */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  /* 0x80-0x8f */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  /* 0x90-0x9f */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  /* 0xa0-0xaf */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  /* 0xb0-0xbf */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  /* 0xc0-0xcf */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  /* 0xd0-0xdf */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  /* 0xe0-0xef */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1   /* 0xf0-0xff */\n};\n\n#if defined(DUK_USE_HEX_FASTPATH)\n/* Preshifted << 4.  Must use 16-bit entry to allow negative value signaling. */\nDUK_INTERNAL const duk_int16_t duk_hex_dectab_shift4[256] = {\n\t  -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  /* 0x00-0x0f */\n\t  -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  /* 0x10-0x1f */\n\t  -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  /* 0x20-0x2f */\n\t0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90,   -1,   -1,   -1,   -1,   -1,   -1,  /* 0x30-0x3f */\n\t  -1, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  /* 0x40-0x4f */\n\t  -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  /* 0x50-0x5f */\n\t  -1, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  /* 0x60-0x6f */\n\t  -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  /* 0x70-0x7f */\n\t  -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  /* 0x80-0x8f */\n\t  -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  /* 0x90-0x9f */\n\t  -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  /* 0xa0-0xaf */\n\t  -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  /* 0xb0-0xbf */\n\t  -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  /* 0xc0-0xcf */\n\t  -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  /* 0xd0-0xdf */\n\t  -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  /* 0xe0-0xef */\n\t  -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1   /* 0xf0-0xff */\n};\n#endif\n\n/*\n *  Table for hex encoding bytes\n */\n\n#if defined(DUK_USE_HEX_FASTPATH)\n/* Lookup to encode one byte directly into 2 characters:\n *\n *   def genhextab(bswap):\n *       for i in xrange(256):\n *           t = chr(i).encode('hex')\n *           if bswap:\n *               t = t[1] + t[0]\n *           print('0x' + t.encode('hex') + 'U')\n *   print('big endian'); genhextab(False)\n *   print('little endian'); genhextab(True)\n*/\nDUK_INTERNAL const duk_uint16_t duk_hex_enctab[256] = {\n#if defined(DUK_USE_INTEGER_BE)\n\t0x3030U, 0x3031U, 0x3032U, 0x3033U, 0x3034U, 0x3035U, 0x3036U, 0x3037U,\n\t0x3038U, 0x3039U, 0x3061U, 0x3062U, 0x3063U, 0x3064U, 0x3065U, 0x3066U,\n\t0x3130U, 0x3131U, 0x3132U, 0x3133U, 0x3134U, 0x3135U, 0x3136U, 0x3137U,\n\t0x3138U, 0x3139U, 0x3161U, 0x3162U, 0x3163U, 0x3164U, 0x3165U, 0x3166U,\n\t0x3230U, 0x3231U, 0x3232U, 0x3233U, 0x3234U, 0x3235U, 0x3236U, 0x3237U,\n\t0x3238U, 0x3239U, 0x3261U, 0x3262U, 0x3263U, 0x3264U, 0x3265U, 0x3266U,\n\t0x3330U, 0x3331U, 0x3332U, 0x3333U, 0x3334U, 0x3335U, 0x3336U, 0x3337U,\n\t0x3338U, 0x3339U, 0x3361U, 0x3362U, 0x3363U, 0x3364U, 0x3365U, 0x3366U,\n\t0x3430U, 0x3431U, 0x3432U, 0x3433U, 0x3434U, 0x3435U, 0x3436U, 0x3437U,\n\t0x3438U, 0x3439U, 0x3461U, 0x3462U, 0x3463U, 0x3464U, 0x3465U, 0x3466U,\n\t0x3530U, 0x3531U, 0x3532U, 0x3533U, 0x3534U, 0x3535U, 0x3536U, 0x3537U,\n\t0x3538U, 0x3539U, 0x3561U, 0x3562U, 0x3563U, 0x3564U, 0x3565U, 0x3566U,\n\t0x3630U, 0x3631U, 0x3632U, 0x3633U, 0x3634U, 0x3635U, 0x3636U, 0x3637U,\n\t0x3638U, 0x3639U, 0x3661U, 0x3662U, 0x3663U, 0x3664U, 0x3665U, 0x3666U,\n\t0x3730U, 0x3731U, 0x3732U, 0x3733U, 0x3734U, 0x3735U, 0x3736U, 0x3737U,\n\t0x3738U, 0x3739U, 0x3761U, 0x3762U, 0x3763U, 0x3764U, 0x3765U, 0x3766U,\n\t0x3830U, 0x3831U, 0x3832U, 0x3833U, 0x3834U, 0x3835U, 0x3836U, 0x3837U,\n\t0x3838U, 0x3839U, 0x3861U, 0x3862U, 0x3863U, 0x3864U, 0x3865U, 0x3866U,\n\t0x3930U, 0x3931U, 0x3932U, 0x3933U, 0x3934U, 0x3935U, 0x3936U, 0x3937U,\n\t0x3938U, 0x3939U, 0x3961U, 0x3962U, 0x3963U, 0x3964U, 0x3965U, 0x3966U,\n\t0x6130U, 0x6131U, 0x6132U, 0x6133U, 0x6134U, 0x6135U, 0x6136U, 0x6137U,\n\t0x6138U, 0x6139U, 0x6161U, 0x6162U, 0x6163U, 0x6164U, 0x6165U, 0x6166U,\n\t0x6230U, 0x6231U, 0x6232U, 0x6233U, 0x6234U, 0x6235U, 0x6236U, 0x6237U,\n\t0x6238U, 0x6239U, 0x6261U, 0x6262U, 0x6263U, 0x6264U, 0x6265U, 0x6266U,\n\t0x6330U, 0x6331U, 0x6332U, 0x6333U, 0x6334U, 0x6335U, 0x6336U, 0x6337U,\n\t0x6338U, 0x6339U, 0x6361U, 0x6362U, 0x6363U, 0x6364U, 0x6365U, 0x6366U,\n\t0x6430U, 0x6431U, 0x6432U, 0x6433U, 0x6434U, 0x6435U, 0x6436U, 0x6437U,\n\t0x6438U, 0x6439U, 0x6461U, 0x6462U, 0x6463U, 0x6464U, 0x6465U, 0x6466U,\n\t0x6530U, 0x6531U, 0x6532U, 0x6533U, 0x6534U, 0x6535U, 0x6536U, 0x6537U,\n\t0x6538U, 0x6539U, 0x6561U, 0x6562U, 0x6563U, 0x6564U, 0x6565U, 0x6566U,\n\t0x6630U, 0x6631U, 0x6632U, 0x6633U, 0x6634U, 0x6635U, 0x6636U, 0x6637U,\n\t0x6638U, 0x6639U, 0x6661U, 0x6662U, 0x6663U, 0x6664U, 0x6665U, 0x6666U\n#else  /* DUK_USE_INTEGER_BE */\n\t0x3030U, 0x3130U, 0x3230U, 0x3330U, 0x3430U, 0x3530U, 0x3630U, 0x3730U,\n\t0x3830U, 0x3930U, 0x6130U, 0x6230U, 0x6330U, 0x6430U, 0x6530U, 0x6630U,\n\t0x3031U, 0x3131U, 0x3231U, 0x3331U, 0x3431U, 0x3531U, 0x3631U, 0x3731U,\n\t0x3831U, 0x3931U, 0x6131U, 0x6231U, 0x6331U, 0x6431U, 0x6531U, 0x6631U,\n\t0x3032U, 0x3132U, 0x3232U, 0x3332U, 0x3432U, 0x3532U, 0x3632U, 0x3732U,\n\t0x3832U, 0x3932U, 0x6132U, 0x6232U, 0x6332U, 0x6432U, 0x6532U, 0x6632U,\n\t0x3033U, 0x3133U, 0x3233U, 0x3333U, 0x3433U, 0x3533U, 0x3633U, 0x3733U,\n\t0x3833U, 0x3933U, 0x6133U, 0x6233U, 0x6333U, 0x6433U, 0x6533U, 0x6633U,\n\t0x3034U, 0x3134U, 0x3234U, 0x3334U, 0x3434U, 0x3534U, 0x3634U, 0x3734U,\n\t0x3834U, 0x3934U, 0x6134U, 0x6234U, 0x6334U, 0x6434U, 0x6534U, 0x6634U,\n\t0x3035U, 0x3135U, 0x3235U, 0x3335U, 0x3435U, 0x3535U, 0x3635U, 0x3735U,\n\t0x3835U, 0x3935U, 0x6135U, 0x6235U, 0x6335U, 0x6435U, 0x6535U, 0x6635U,\n\t0x3036U, 0x3136U, 0x3236U, 0x3336U, 0x3436U, 0x3536U, 0x3636U, 0x3736U,\n\t0x3836U, 0x3936U, 0x6136U, 0x6236U, 0x6336U, 0x6436U, 0x6536U, 0x6636U,\n\t0x3037U, 0x3137U, 0x3237U, 0x3337U, 0x3437U, 0x3537U, 0x3637U, 0x3737U,\n\t0x3837U, 0x3937U, 0x6137U, 0x6237U, 0x6337U, 0x6437U, 0x6537U, 0x6637U,\n\t0x3038U, 0x3138U, 0x3238U, 0x3338U, 0x3438U, 0x3538U, 0x3638U, 0x3738U,\n\t0x3838U, 0x3938U, 0x6138U, 0x6238U, 0x6338U, 0x6438U, 0x6538U, 0x6638U,\n\t0x3039U, 0x3139U, 0x3239U, 0x3339U, 0x3439U, 0x3539U, 0x3639U, 0x3739U,\n\t0x3839U, 0x3939U, 0x6139U, 0x6239U, 0x6339U, 0x6439U, 0x6539U, 0x6639U,\n\t0x3061U, 0x3161U, 0x3261U, 0x3361U, 0x3461U, 0x3561U, 0x3661U, 0x3761U,\n\t0x3861U, 0x3961U, 0x6161U, 0x6261U, 0x6361U, 0x6461U, 0x6561U, 0x6661U,\n\t0x3062U, 0x3162U, 0x3262U, 0x3362U, 0x3462U, 0x3562U, 0x3662U, 0x3762U,\n\t0x3862U, 0x3962U, 0x6162U, 0x6262U, 0x6362U, 0x6462U, 0x6562U, 0x6662U,\n\t0x3063U, 0x3163U, 0x3263U, 0x3363U, 0x3463U, 0x3563U, 0x3663U, 0x3763U,\n\t0x3863U, 0x3963U, 0x6163U, 0x6263U, 0x6363U, 0x6463U, 0x6563U, 0x6663U,\n\t0x3064U, 0x3164U, 0x3264U, 0x3364U, 0x3464U, 0x3564U, 0x3664U, 0x3764U,\n\t0x3864U, 0x3964U, 0x6164U, 0x6264U, 0x6364U, 0x6464U, 0x6564U, 0x6664U,\n\t0x3065U, 0x3165U, 0x3265U, 0x3365U, 0x3465U, 0x3565U, 0x3665U, 0x3765U,\n\t0x3865U, 0x3965U, 0x6165U, 0x6265U, 0x6365U, 0x6465U, 0x6565U, 0x6665U,\n\t0x3066U, 0x3166U, 0x3266U, 0x3366U, 0x3466U, 0x3566U, 0x3666U, 0x3766U,\n\t0x3866U, 0x3966U, 0x6166U, 0x6266U, 0x6366U, 0x6466U, 0x6566U, 0x6666U\n#endif  /* DUK_USE_INTEGER_BE */\n};\n#endif  /* DUK_USE_HEX_FASTPATH */\n\n/*\n *  Table for base-64 encoding\n */\n\n#if defined(DUK_USE_BASE64_FASTPATH)\nDUK_INTERNAL const duk_uint8_t duk_base64_enctab[64] = {\n\t0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,  /* A...P */\n\t0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,  /* Q...f */\n\t0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,  /* g...v */\n\t0x77, 0x78, 0x79, 0x7a, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2b, 0x2f   /* w.../ */\n};\n#endif  /* DUK_USE_BASE64_FASTPATH */\n\n/*\n *  Table for base-64 decoding\n */\n\n#if defined(DUK_USE_BASE64_FASTPATH)\nDUK_INTERNAL const duk_int8_t duk_base64_dectab[256] = {\n\t/* -1 = error, -2 = allowed whitespace, -3 = padding ('='), 0...63 decoded bytes */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -2, -2, -1, -1, -2, -1, -1,  /* 0x00...0x0f */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  /* 0x10...0x1f */\n\t-2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,  /* 0x20...0x2f */\n\t52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -3, -1, -1,  /* 0x30...0x3f */\n\t-1,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14,  /* 0x40...0x4f */\n\t15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,  /* 0x50...0x5f */\n\t-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,  /* 0x60...0x6f */\n\t41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,  /* 0x70...0x7f */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  /* 0x80...0x8f */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  /* 0x90...0x9f */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  /* 0xa0...0xaf */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  /* 0xb0...0xbf */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  /* 0xc0...0xcf */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  /* 0xd0...0xdf */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  /* 0xe0...0xef */\n\t-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1   /* 0xf0...0xff */\n};\n#endif  /* DUK_USE_BASE64_FASTPATH */\n\n/*\n *  Arbitrary byteswap for potentially unaligned values\n *\n *  Used to byteswap pointers e.g. in debugger code.\n */\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT)  /* For now only needed by the debugger. */\nDUK_INTERNAL void duk_byteswap_bytes(duk_uint8_t *p, duk_small_uint_t len) {\n\tduk_uint8_t tmp;\n\tduk_uint8_t *q = p + len - 1;\n\n\twhile (p - q < 0) {\n\t\ttmp = *p;\n\t\t*p = *q;\n\t\t*q = tmp;\n\t\tp++;\n\t\tq--;\n\t}\n}\n#endif\n\n/*\n *  Miscellaneous coercion / clamping helpers.\n */\n\n/* Check whether a duk_double_t is a whole number in the 32-bit range (reject\n * negative zero), and if so, return a duk_int32_t.\n * For compiler use: don't allow negative zero as it will cause trouble with\n * LDINT+LDINTX, positive zero is OK.\n */\nDUK_INTERNAL duk_bool_t duk_is_whole_get_int32_nonegzero(duk_double_t x, duk_int32_t *ival) {\n\tduk_int32_t t;\n\n\tt = (duk_int32_t) x;\n\tif (!((duk_double_t) t == x)) {\n\t\treturn 0;\n\t}\n\tif (t == 0) {\n\t\tduk_double_union du;\n\t\tdu.d = x;\n\t\tif (DUK_DBLUNION_HAS_SIGNBIT(&du)) {\n\t\t\treturn 0;\n\t\t}\n\t}\n\t*ival = t;\n\treturn 1;\n}\n\n/* Check whether a duk_double_t is a whole number in the 32-bit range, and if\n * so, return a duk_int32_t.\n */\nDUK_INTERNAL duk_bool_t duk_is_whole_get_int32(duk_double_t x, duk_int32_t *ival) {\n\tduk_int32_t t;\n\n\tt = (duk_int32_t) x;\n\tif (!((duk_double_t) t == x)) {\n\t\treturn 0;\n\t}\n\t*ival = t;\n\treturn 1;\n}\n\n/*\n *  IEEE double checks\n */\n\nDUK_INTERNAL duk_bool_t duk_double_is_anyinf(duk_double_t x) {\n\tduk_double_union du;\n\tdu.d = x;\n\treturn DUK_DBLUNION_IS_ANYINF(&du);\n}\n\nDUK_INTERNAL duk_bool_t duk_double_is_posinf(duk_double_t x) {\n\tduk_double_union du;\n\tdu.d = x;\n\treturn DUK_DBLUNION_IS_POSINF(&du);\n}\n\nDUK_INTERNAL duk_bool_t duk_double_is_neginf(duk_double_t x) {\n\tduk_double_union du;\n\tdu.d = x;\n\treturn DUK_DBLUNION_IS_NEGINF(&du);\n}\n\nDUK_INTERNAL duk_bool_t duk_double_is_nan(duk_double_t x) {\n\tduk_double_union du;\n\tdu.d = x;\n\t/* Assumes we're dealing with a Duktape internal NaN which is\n\t * NaN normalized if duk_tval requires it.\n\t */\n\tDUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du));\n\treturn DUK_DBLUNION_IS_NAN(&du);\n}\n\nDUK_INTERNAL duk_bool_t duk_double_is_nan_or_zero(duk_double_t x) {\n\tduk_double_union du;\n\tdu.d = x;\n\t/* Assumes we're dealing with a Duktape internal NaN which is\n\t * NaN normalized if duk_tval requires it.\n\t */\n\tDUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du));\n\treturn DUK_DBLUNION_IS_NAN(&du) || DUK_DBLUNION_IS_ANYZERO(&du);\n}\n\nDUK_INTERNAL duk_bool_t duk_double_is_nan_or_inf(duk_double_t x) {\n\tduk_double_union du;\n\tdu.d = x;\n\t/* If exponent is 0x7FF the argument is either a NaN or an\n\t * infinity.  We don't need to check any other fields.\n\t */\n#if defined(DUK_USE_64BIT_OPS)\n#if defined(DUK_USE_DOUBLE_ME)\n\treturn (du.ull[DUK_DBL_IDX_ULL0] & 0x000000007ff00000ULL) == 0x000000007ff00000ULL;\n#else\n\treturn (du.ull[DUK_DBL_IDX_ULL0] & 0x7ff0000000000000ULL) == 0x7ff0000000000000ULL;\n#endif\n#else\n\treturn (du.ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL) == 0x7ff00000UL;\n#endif\n}\n\nDUK_INTERNAL duk_bool_t duk_double_is_nan_zero_inf(duk_double_t x) {\n\tduk_double_union du;\n#if defined(DUK_USE_64BIT_OPS)\n\tduk_uint64_t t;\n#else\n\tduk_uint32_t t;\n#endif\n\tdu.d = x;\n#if defined(DUK_USE_64BIT_OPS)\n#if defined(DUK_USE_DOUBLE_ME)\n\tt = du.ull[DUK_DBL_IDX_ULL0] & 0x000000007ff00000ULL;\n\tif (t == 0x0000000000000000ULL) {\n\t\tt = du.ull[DUK_DBL_IDX_ULL0] & 0x0000000080000000ULL;\n\t\treturn t == 0;\n\t}\n\tif (t == 0x000000007ff00000UL) {\n\t\treturn 1;\n\t}\n#else\n\tt = du.ull[DUK_DBL_IDX_ULL0] & 0x7ff0000000000000ULL;\n\tif (t == 0x0000000000000000ULL) {\n\t\tt = du.ull[DUK_DBL_IDX_ULL0] & 0x8000000000000000ULL;\n\t\treturn t == 0;\n\t}\n\tif (t == 0x7ff0000000000000ULL) {\n\t\treturn 1;\n\t}\n#endif\n#else\n\tt = du.ui[DUK_DBL_IDX_UI0] & 0x7ff00000UL;\n\tif (t == 0x00000000UL) {\n\t\treturn DUK_DBLUNION_IS_ANYZERO(&du);\n\t}\n\tif (t == 0x7ff00000UL) {\n\t\treturn 1;\n\t}\n#endif\n\treturn 0;\n}\n\nDUK_INTERNAL duk_small_uint_t duk_double_signbit(duk_double_t x) {\n\tduk_double_union du;\n\tdu.d = x;\n\treturn (duk_small_uint_t) DUK_DBLUNION_GET_SIGNBIT(&du);\n}\n\nDUK_INTERNAL duk_double_t duk_double_trunc_towards_zero(duk_double_t x) {\n\t/* XXX: optimize */\n\tduk_small_int_t s = duk_double_signbit(x);\n\tx = DUK_FLOOR(DUK_FABS(x));  /* truncate towards zero */\n\tif (s) {\n\t\tx = -x;\n\t}\n\treturn x;\n}\n\nDUK_INTERNAL duk_bool_t duk_double_same_sign(duk_double_t x, duk_double_t y) {\n\tduk_double_union du1;\n\tduk_double_union du2;\n\tdu1.d = x;\n\tdu2.d = y;\n\n\treturn (((du1.ui[DUK_DBL_IDX_UI0] ^ du2.ui[DUK_DBL_IDX_UI0]) & 0x80000000UL) == 0);\n}\n\nDUK_INTERNAL duk_double_t duk_double_fmin(duk_double_t x, duk_double_t y) {\n\t/* Doesn't replicate fmin() behavior exactly: for fmin() if one\n\t * argument is a NaN, the other argument should be returned.\n\t * Duktape doesn't rely on this behavior so the replacement can\n\t * be simplified.\n\t */\n\treturn (x < y ? x : y);\n}\n\nDUK_INTERNAL duk_double_t duk_double_fmax(duk_double_t x, duk_double_t y) {\n\t/* Doesn't replicate fmax() behavior exactly: for fmax() if one\n\t * argument is a NaN, the other argument should be returned.\n\t * Duktape doesn't rely on this behavior so the replacement can\n\t * be simplified.\n\t */\n\treturn (x > y ? x : y);\n}\n/*\n *  Hobject Ecmascript [[Class]].\n */\n\n/* #include duk_internal.h -> already included */\n\n#if (DUK_STRIDX_UC_ARGUMENTS > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_ARRAY > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_UC_BOOLEAN > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_DATE > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_UC_ERROR > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_UC_FUNCTION > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_JSON > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_MATH > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_UC_NUMBER > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_UC_OBJECT > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_REG_EXP > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_UC_STRING > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_GLOBAL > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_OBJ_ENV > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_DEC_ENV > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_UC_POINTER > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_UC_THREAD > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_ARRAY_BUFFER > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_DATA_VIEW > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_INT8_ARRAY > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_UINT8_ARRAY > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_UINT8_CLAMPED_ARRAY > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_INT16_ARRAY > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_UINT16_ARRAY > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_INT32_ARRAY > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_UINT32_ARRAY > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_FLOAT32_ARRAY > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_FLOAT64_ARRAY > 255)\n#error constant too large\n#endif\n#if (DUK_STRIDX_EMPTY_STRING > 255)\n#error constant too large\n#endif\n\n/* Note: assumes that these string indexes are 8-bit, genstrings.py must ensure that */\nDUK_INTERNAL duk_uint8_t duk_class_number_to_stridx[32] = {\n\tDUK_STRIDX_EMPTY_STRING,  /* NONE, intentionally empty */\n\tDUK_STRIDX_UC_OBJECT,\n\tDUK_STRIDX_ARRAY,\n\tDUK_STRIDX_UC_FUNCTION,\n\tDUK_STRIDX_UC_ARGUMENTS,\n\tDUK_STRIDX_UC_BOOLEAN,\n\tDUK_STRIDX_DATE,\n\tDUK_STRIDX_UC_ERROR,\n\tDUK_STRIDX_JSON,\n\tDUK_STRIDX_MATH,\n\tDUK_STRIDX_UC_NUMBER,\n\tDUK_STRIDX_REG_EXP,\n\tDUK_STRIDX_UC_STRING,\n\tDUK_STRIDX_GLOBAL,\n\tDUK_STRIDX_UC_SYMBOL,\n\tDUK_STRIDX_OBJ_ENV,\n\tDUK_STRIDX_DEC_ENV,\n\tDUK_STRIDX_UC_POINTER,\n\tDUK_STRIDX_UC_THREAD,\n\tDUK_STRIDX_ARRAY_BUFFER,\n\tDUK_STRIDX_DATA_VIEW,\n\tDUK_STRIDX_INT8_ARRAY,\n\tDUK_STRIDX_UINT8_ARRAY,\n\tDUK_STRIDX_UINT8_CLAMPED_ARRAY,\n\tDUK_STRIDX_INT16_ARRAY,\n\tDUK_STRIDX_UINT16_ARRAY,\n\tDUK_STRIDX_INT32_ARRAY,\n\tDUK_STRIDX_UINT32_ARRAY,\n\tDUK_STRIDX_FLOAT32_ARRAY,\n\tDUK_STRIDX_FLOAT64_ARRAY,\n\tDUK_STRIDX_EMPTY_STRING,  /* UNUSED, intentionally empty */\n\tDUK_STRIDX_EMPTY_STRING,  /* UNUSED, intentionally empty */\n};\n/*\n *  Default allocation functions.\n *\n *  Assumes behavior such as malloc allowing zero size, yielding\n *  a NULL or a unique pointer which is a no-op for free.\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS)\nDUK_INTERNAL void *duk_default_alloc_function(void *udata, duk_size_t size) {\n\tvoid *res;\n\tDUK_UNREF(udata);\n\tres = DUK_ANSI_MALLOC(size);\n\tDUK_DDD(DUK_DDDPRINT(\"default alloc function: %lu -> %p\",\n\t                     (unsigned long) size, (void *) res));\n\treturn res;\n}\n\nDUK_INTERNAL void *duk_default_realloc_function(void *udata, void *ptr, duk_size_t newsize) {\n\tvoid *res;\n\tDUK_UNREF(udata);\n\tres = DUK_ANSI_REALLOC(ptr, newsize);\n\tDUK_DDD(DUK_DDDPRINT(\"default realloc function: %p %lu -> %p\",\n\t                     (void *) ptr, (unsigned long) newsize, (void *) res));\n\treturn res;\n}\n\nDUK_INTERNAL void duk_default_free_function(void *udata, void *ptr) {\n\tDUK_DDD(DUK_DDDPRINT(\"default free function: %p\", (void *) ptr));\n\tDUK_UNREF(udata);\n\tDUK_ANSI_FREE(ptr);\n}\n#endif  /* DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS */\n/*\n *  Buffer\n */\n\n/* #include duk_internal.h -> already included */\n\nDUK_EXTERNAL void *duk_resize_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t new_size) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hbuffer_dynamic *h;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\th = (duk_hbuffer_dynamic *) duk_require_hbuffer(ctx, idx);\n\tDUK_ASSERT(h != NULL);\n\n\tif (!(DUK_HBUFFER_HAS_DYNAMIC(h) && !DUK_HBUFFER_HAS_EXTERNAL(h))) {\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_WRONG_BUFFER_TYPE);\n\t}\n\n\t/* maximum size check is handled by callee */\n\tduk_hbuffer_resize(thr, h, new_size);\n\n\treturn DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, h);\n}\n\nDUK_EXTERNAL void *duk_steal_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hbuffer_dynamic *h;\n\tvoid *ptr;\n\tduk_size_t sz;\n\n\tDUK_ASSERT(ctx != NULL);\n\n\th = (duk_hbuffer_dynamic *) duk_require_hbuffer(ctx, idx);\n\tDUK_ASSERT(h != NULL);\n\n\tif (!(DUK_HBUFFER_HAS_DYNAMIC(h) && !DUK_HBUFFER_HAS_EXTERNAL(h))) {\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_WRONG_BUFFER_TYPE);\n\t}\n\n\t/* Forget the previous allocation, setting size to 0 and alloc to\n\t * NULL.  Caller is responsible for freeing the previous allocation.\n\t * Getting the allocation and clearing it is done in the same API\n\t * call to avoid any chance of a realloc.\n\t */\n\tptr = DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, h);\n\tsz = DUK_HBUFFER_DYNAMIC_GET_SIZE(h);\n\tif (out_size) {\n\t\t*out_size = sz;\n\t}\n\tDUK_HBUFFER_DYNAMIC_SET_DATA_PTR_NULL(thr->heap, h);\n\tDUK_HBUFFER_DYNAMIC_SET_SIZE(h, 0);\n\n\treturn ptr;\n}\n\nDUK_EXTERNAL void duk_config_buffer(duk_context *ctx, duk_idx_t idx, void *ptr, duk_size_t len) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hbuffer_external *h;\n\n\tDUK_ASSERT(ctx != NULL);\n\n\th = (duk_hbuffer_external *) duk_require_hbuffer(ctx, idx);\n\tDUK_ASSERT(h != NULL);\n\n\tif (!DUK_HBUFFER_HAS_EXTERNAL(h)) {\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_WRONG_BUFFER_TYPE);\n\t}\n\tDUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(h));\n\n\tDUK_HBUFFER_EXTERNAL_SET_DATA_PTR(thr->heap, h, ptr);\n\tDUK_HBUFFER_EXTERNAL_SET_SIZE(h, len);\n}\n/*\n *  Bytecode dump/load\n *\n *  The bytecode load primitive is more important performance-wise than the\n *  dump primitive.\n *\n *  Unlike most Duktape API calls, bytecode dump/load is not guaranteed to be\n *  memory safe for invalid arguments - caller beware!  There's little point\n *  in trying to achieve memory safety unless bytecode instructions are also\n *  validated which is not easy to do with indirect register references etc.\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_BYTECODE_DUMP_SUPPORT)\n\n#define DUK__SER_MARKER  0xff\n#define DUK__SER_VERSION 0x00\n#define DUK__SER_STRING  0x00\n#define DUK__SER_NUMBER  0x01\n#define DUK__BYTECODE_INITIAL_ALLOC 256\n\n/*\n *  Dump/load helpers, xxx_raw() helpers do no buffer checks\n */\n\nDUK_LOCAL duk_uint8_t *duk__load_string_raw(duk_context *ctx, duk_uint8_t *p) {\n\tduk_uint32_t len;\n\n\tlen = DUK_RAW_READ_U32_BE(p);\n\tduk_push_lstring(ctx, (const char *) p, len);\n\tp += len;\n\treturn p;\n}\n\nDUK_LOCAL duk_uint8_t *duk__load_buffer_raw(duk_context *ctx, duk_uint8_t *p) {\n\tduk_uint32_t len;\n\tduk_uint8_t *buf;\n\n\tlen = DUK_RAW_READ_U32_BE(p);\n\tbuf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(ctx, (duk_size_t) len);\n\tDUK_ASSERT(buf != NULL);\n\tDUK_MEMCPY((void *) buf, (const void *) p, (size_t) len);\n\tp += len;\n\treturn p;\n}\n\nDUK_LOCAL duk_uint8_t *duk__dump_hstring_raw(duk_uint8_t *p, duk_hstring *h) {\n\tduk_size_t len;\n\tduk_uint32_t tmp32;\n\n\tDUK_ASSERT(h != NULL);\n\n\tlen = DUK_HSTRING_GET_BYTELEN(h);\n\tDUK_ASSERT(len <= 0xffffffffUL);  /* string limits */\n\ttmp32 = (duk_uint32_t) len;\n\tDUK_RAW_WRITE_U32_BE(p, tmp32);\n\tDUK_MEMCPY((void *) p,\n\t           (const void *) DUK_HSTRING_GET_DATA(h),\n\t           len);\n\tp += len;\n\treturn p;\n}\n\nDUK_LOCAL duk_uint8_t *duk__dump_hbuffer_raw(duk_hthread *thr, duk_uint8_t *p, duk_hbuffer *h) {\n\tduk_size_t len;\n\tduk_uint32_t tmp32;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(h != NULL);\n\tDUK_UNREF(thr);\n\n\tlen = DUK_HBUFFER_GET_SIZE(h);\n\tDUK_ASSERT(len <= 0xffffffffUL);  /* buffer limits */\n\ttmp32 = (duk_uint32_t) len;\n\tDUK_RAW_WRITE_U32_BE(p, tmp32);\n\tDUK_MEMCPY((void *) p,\n\t           (const void *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h),\n\t           len);\n\tp += len;\n\treturn p;\n}\n\nDUK_LOCAL duk_uint8_t *duk__dump_string_prop(duk_hthread *thr, duk_uint8_t *p, duk_bufwriter_ctx *bw_ctx, duk_hobject *func, duk_small_uint_t stridx) {\n\tduk_hstring *h_str;\n\tduk_tval *tv;\n\n\ttv = duk_hobject_find_existing_entry_tval_ptr(thr->heap, (duk_hobject *) func, DUK_HTHREAD_GET_STRING(thr, stridx));\n\tif (tv != NULL && DUK_TVAL_IS_STRING(tv)) {\n\t\th_str = DUK_TVAL_GET_STRING(tv);\n\t\tDUK_ASSERT(h_str != NULL);\n\t} else {\n\t\th_str = DUK_HTHREAD_STRING_EMPTY_STRING(thr);\n\t\tDUK_ASSERT(h_str != NULL);\n\t}\n\tDUK_ASSERT(DUK_HSTRING_MAX_BYTELEN <= 0x7fffffffUL);  /* ensures no overflow */\n\tp = DUK_BW_ENSURE_RAW(thr, bw_ctx, 4 + DUK_HSTRING_GET_BYTELEN(h_str), p);\n\tp = duk__dump_hstring_raw(p, h_str);\n\treturn p;\n}\n\nDUK_LOCAL duk_uint8_t *duk__dump_buffer_prop(duk_hthread *thr, duk_uint8_t *p, duk_bufwriter_ctx *bw_ctx, duk_hobject *func, duk_small_uint_t stridx) {\n\tduk_tval *tv;\n\n\ttv = duk_hobject_find_existing_entry_tval_ptr(thr->heap, (duk_hobject *) func, DUK_HTHREAD_GET_STRING(thr, stridx));\n\tif (tv != NULL && DUK_TVAL_IS_BUFFER(tv)) {\n\t\tduk_hbuffer *h_buf;\n\t\th_buf = DUK_TVAL_GET_BUFFER(tv);\n\t\tDUK_ASSERT(h_buf != NULL);\n\t\tDUK_ASSERT(DUK_HBUFFER_MAX_BYTELEN <= 0x7fffffffUL);  /* ensures no overflow */\n\t\tp = DUK_BW_ENSURE_RAW(thr, bw_ctx, 4 + DUK_HBUFFER_GET_SIZE(h_buf), p);\n\t\tp = duk__dump_hbuffer_raw(thr, p, h_buf);\n\t} else {\n\t\tp = DUK_BW_ENSURE_RAW(thr, bw_ctx, 4, p);\n\t\tDUK_RAW_WRITE_U32_BE(p, 0);\n\t}\n\treturn p;\n}\n\nDUK_LOCAL duk_uint8_t *duk__dump_uint32_prop(duk_hthread *thr, duk_uint8_t *p, duk_bufwriter_ctx *bw_ctx, duk_hobject *func, duk_small_uint_t stridx, duk_uint32_t def_value) {\n\tduk_tval *tv;\n\tduk_uint32_t val;\n\n\ttv = duk_hobject_find_existing_entry_tval_ptr(thr->heap, (duk_hobject *) func, DUK_HTHREAD_GET_STRING(thr, stridx));\n\tif (tv != NULL && DUK_TVAL_IS_NUMBER(tv)) {\n\t\tval = (duk_uint32_t) DUK_TVAL_GET_NUMBER(tv);\n\t} else {\n\t\tval = def_value;\n\t}\n\tp = DUK_BW_ENSURE_RAW(thr, bw_ctx, 4, p);\n\tDUK_RAW_WRITE_U32_BE(p, val);\n\treturn p;\n}\n\nDUK_LOCAL duk_uint8_t *duk__dump_varmap(duk_hthread *thr, duk_uint8_t *p, duk_bufwriter_ctx *bw_ctx, duk_hobject *func) {\n\tduk_tval *tv;\n\n\ttv = duk_hobject_find_existing_entry_tval_ptr(thr->heap, (duk_hobject *) func, DUK_HTHREAD_STRING_INT_VARMAP(thr));\n\tif (tv != NULL && DUK_TVAL_IS_OBJECT(tv)) {\n\t\tduk_hobject *h;\n\t\tduk_uint_fast32_t i;\n\n\t\th = DUK_TVAL_GET_OBJECT(tv);\n\t\tDUK_ASSERT(h != NULL);\n\n\t\t/* We know _Varmap only has own properties so walk property\n\t\t * table directly.  We also know _Varmap is dense and all\n\t\t * values are numbers; assert for these.  GC and finalizers\n\t\t * shouldn't affect _Varmap so side effects should be fine.\n\t\t */\n\t\tfor (i = 0; i < (duk_uint_fast32_t) DUK_HOBJECT_GET_ENEXT(h); i++) {\n\t\t\tduk_hstring *key;\n\t\t\tduk_tval *tv_val;\n\t\t\tduk_uint32_t val;\n\n\t\t\tkey = DUK_HOBJECT_E_GET_KEY(thr->heap, h, i);\n\t\t\tDUK_ASSERT(key != NULL);  /* _Varmap is dense */\n\t\t\tDUK_ASSERT(!DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, h, i));\n\t\t\ttv_val = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, h, i);\n\t\t\tDUK_ASSERT(tv_val != NULL);\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv_val));  /* known to be number; in fact an integer */\n#if defined(DUK_USE_FASTINT)\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_FASTINT(tv_val));\n\t\t\tDUK_ASSERT(DUK_TVAL_GET_FASTINT(tv_val) == (duk_int64_t) DUK_TVAL_GET_FASTINT_U32(tv_val));  /* known to be 32-bit */\n\t\t\tval = DUK_TVAL_GET_FASTINT_U32(tv_val);\n#else\n\t\t\tval = (duk_uint32_t) DUK_TVAL_GET_NUMBER(tv_val);\n#endif\n\n\t\t\tDUK_ASSERT(DUK_HSTRING_MAX_BYTELEN <= 0x7fffffffUL);  /* ensures no overflow */\n\t\t\tp = DUK_BW_ENSURE_RAW(thr, bw_ctx, 4 + DUK_HSTRING_GET_BYTELEN(key) + 4, p);\n\t\t\tp = duk__dump_hstring_raw(p, key);\n\t\t\tDUK_RAW_WRITE_U32_BE(p, val);\n\t\t}\n\t}\n\tp = DUK_BW_ENSURE_RAW(thr, bw_ctx, 4, p);\n\tDUK_RAW_WRITE_U32_BE(p, 0);  /* end of _Varmap */\n\treturn p;\n}\n\nDUK_LOCAL duk_uint8_t *duk__dump_formals(duk_hthread *thr, duk_uint8_t *p, duk_bufwriter_ctx *bw_ctx, duk_hobject *func) {\n\tduk_tval *tv;\n\n\ttv = duk_hobject_find_existing_entry_tval_ptr(thr->heap, (duk_hobject *) func, DUK_HTHREAD_STRING_INT_FORMALS(thr));\n\tif (tv != NULL && DUK_TVAL_IS_OBJECT(tv)) {\n\t\tduk_hobject *h;\n\t\tduk_uint_fast32_t i;\n\n\t\th = DUK_TVAL_GET_OBJECT(tv);\n\t\tDUK_ASSERT(h != NULL);\n\n\t\t/* We know _Formals is dense and all entries will be in the\n\t\t * array part.  GC and finalizers shouldn't affect _Formals\n\t\t * so side effects should be fine.\n\t\t */\n\t\tfor (i = 0; i < (duk_uint_fast32_t) DUK_HOBJECT_GET_ASIZE(h); i++) {\n\t\t\tduk_tval *tv_val;\n\t\t\tduk_hstring *varname;\n\n\t\t\ttv_val = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, h, i);\n\t\t\tDUK_ASSERT(tv_val != NULL);\n\t\t\tif (DUK_TVAL_IS_STRING(tv_val)) {\n\t\t\t\t/* Array is dense and contains only strings, but ASIZE may\n\t\t\t\t * be larger than used part and there are UNUSED entries.\n\t\t\t\t */\n\t\t\t\tvarname = DUK_TVAL_GET_STRING(tv_val);\n\t\t\t\tDUK_ASSERT(varname != NULL);\n\t\t\t\tDUK_ASSERT(DUK_HSTRING_GET_BYTELEN(varname) >= 1);  /* won't be confused with terminator */\n\n\t\t\t\tDUK_ASSERT(DUK_HSTRING_MAX_BYTELEN <= 0x7fffffffUL);  /* ensures no overflow */\n\t\t\t\tp = DUK_BW_ENSURE_RAW(thr, bw_ctx, 4 + DUK_HSTRING_GET_BYTELEN(varname), p);\n\t\t\t\tp = duk__dump_hstring_raw(p, varname);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tDUK_DD(DUK_DDPRINT(\"dumping function without _Formals, emit empty list\"));\n\t}\n\tp = DUK_BW_ENSURE_RAW(thr, bw_ctx, 4, p);\n\tDUK_RAW_WRITE_U32_BE(p, 0);  /* end of _Formals */\n\treturn p;\n}\n\nstatic duk_uint8_t *duk__dump_func(duk_context *ctx, duk_hcompfunc *func, duk_bufwriter_ctx *bw_ctx, duk_uint8_t *p) {\n\tduk_hthread *thr;\n\tduk_tval *tv, *tv_end;\n\tduk_instr_t *ins, *ins_end;\n\tduk_hobject **fn, **fn_end;\n\tduk_hstring *h_str;\n\tduk_uint32_t count_instr;\n\tduk_uint32_t tmp32;\n\tduk_uint16_t tmp16;\n\tduk_double_t d;\n\n\tthr = (duk_hthread *) ctx;\n\tDUK_UNREF(ctx);\n\tDUK_UNREF(thr);\n\n\tDUK_DD(DUK_DDPRINT(\"dumping function %p to %p: \"\n\t                   \"consts=[%p,%p[ (%ld bytes, %ld items), \"\n\t                   \"funcs=[%p,%p[ (%ld bytes, %ld items), \"\n\t                   \"code=[%p,%p[ (%ld bytes, %ld items)\",\n\t                   (void *) func,\n\t                   (void *) p,\n\t                   (void *) DUK_HCOMPFUNC_GET_CONSTS_BASE(thr->heap, func),\n\t                   (void *) DUK_HCOMPFUNC_GET_CONSTS_END(thr->heap, func),\n\t                   (long) DUK_HCOMPFUNC_GET_CONSTS_SIZE(thr->heap, func),\n\t                   (long) DUK_HCOMPFUNC_GET_CONSTS_COUNT(thr->heap, func),\n\t                   (void *) DUK_HCOMPFUNC_GET_FUNCS_BASE(thr->heap, func),\n\t                   (void *) DUK_HCOMPFUNC_GET_FUNCS_END(thr->heap, func),\n\t                   (long) DUK_HCOMPFUNC_GET_FUNCS_SIZE(thr->heap, func),\n\t                   (long) DUK_HCOMPFUNC_GET_FUNCS_COUNT(thr->heap, func),\n\t                   (void *) DUK_HCOMPFUNC_GET_CODE_BASE(thr->heap, func),\n\t                   (void *) DUK_HCOMPFUNC_GET_CODE_END(thr->heap, func),\n\t                   (long) DUK_HCOMPFUNC_GET_CODE_SIZE(thr->heap, func),\n\t                   (long) DUK_HCOMPFUNC_GET_CODE_COUNT(thr->heap, func)));\n\n\tDUK_ASSERT(DUK_USE_ESBC_MAX_BYTES <= 0x7fffffffUL);  /* ensures no overflow */\n\tcount_instr = (duk_uint32_t) DUK_HCOMPFUNC_GET_CODE_COUNT(thr->heap, func);\n\tp = DUK_BW_ENSURE_RAW(thr, bw_ctx, 3 * 4 + 2 * 2 + 3 * 4 + count_instr * 4, p);\n\n\t/* Fixed header info. */\n\ttmp32 = count_instr;\n\tDUK_RAW_WRITE_U32_BE(p, tmp32);\n\ttmp32 = (duk_uint32_t) DUK_HCOMPFUNC_GET_CONSTS_COUNT(thr->heap, func);\n\tDUK_RAW_WRITE_U32_BE(p, tmp32);\n\ttmp32 = (duk_uint32_t) DUK_HCOMPFUNC_GET_FUNCS_COUNT(thr->heap, func);\n\tDUK_RAW_WRITE_U32_BE(p, tmp32);\n\ttmp16 = func->nregs;\n\tDUK_RAW_WRITE_U16_BE(p, tmp16);\n\ttmp16 = func->nargs;\n\tDUK_RAW_WRITE_U16_BE(p, tmp16);\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\ttmp32 = func->start_line;\n\tDUK_RAW_WRITE_U32_BE(p, tmp32);\n\ttmp32 = func->end_line;\n\tDUK_RAW_WRITE_U32_BE(p, tmp32);\n#else\n\tDUK_RAW_WRITE_U32_BE(p, 0);\n\tDUK_RAW_WRITE_U32_BE(p, 0);\n#endif\n\ttmp32 = DUK_HEAPHDR_GET_FLAGS((duk_heaphdr *) func);  /* masks flags, only duk_hobject flags */\n\ttmp32 &= ~(DUK_HOBJECT_FLAG_HAVE_FINALIZER);  /* finalizer flag is lost */\n\tDUK_RAW_WRITE_U32_BE(p, tmp32);\n\n\t/* Bytecode instructions: endian conversion needed unless\n\t * platform is big endian.\n\t */\n\tins = DUK_HCOMPFUNC_GET_CODE_BASE(thr->heap, func);\n\tins_end = DUK_HCOMPFUNC_GET_CODE_END(thr->heap, func);\n\tDUK_ASSERT((duk_size_t) (ins_end - ins) == (duk_size_t) count_instr);\n#if defined(DUK_USE_INTEGER_BE)\n\tDUK_MEMCPY((void *) p, (const void *) ins, (size_t) (ins_end - ins));\n\tp += (size_t) (ins_end - ins);\n#else\n\twhile (ins != ins_end) {\n\t\ttmp32 = (duk_uint32_t) (*ins);\n\t\tDUK_RAW_WRITE_U32_BE(p, tmp32);\n\t\tins++;\n\t}\n#endif\n\n\t/* Constants: variable size encoding. */\n\ttv = DUK_HCOMPFUNC_GET_CONSTS_BASE(thr->heap, func);\n\ttv_end = DUK_HCOMPFUNC_GET_CONSTS_END(thr->heap, func);\n\twhile (tv != tv_end) {\n\t\t/* constants are strings or numbers now */\n\t\tDUK_ASSERT(DUK_TVAL_IS_STRING(tv) ||\n\t\t           DUK_TVAL_IS_NUMBER(tv));\n\n\t\tif (DUK_TVAL_IS_STRING(tv)) {\n\t\t\th_str = DUK_TVAL_GET_STRING(tv);\n\t\t\tDUK_ASSERT(h_str != NULL);\n\t\t\tDUK_ASSERT(DUK_HSTRING_MAX_BYTELEN <= 0x7fffffffUL);  /* ensures no overflow */\n\t\t\tp = DUK_BW_ENSURE_RAW(thr, bw_ctx, 1 + 4 + DUK_HSTRING_GET_BYTELEN(h_str), p),\n\t\t\t*p++ = DUK__SER_STRING;\n\t\t\tp = duk__dump_hstring_raw(p, h_str);\n\t\t} else {\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv));\n\t\t\tp = DUK_BW_ENSURE_RAW(thr, bw_ctx, 1 + 8, p);\n\t\t\t*p++ = DUK__SER_NUMBER;\n\t\t\td = DUK_TVAL_GET_NUMBER(tv);\n\t\t\tDUK_RAW_WRITE_DOUBLE_BE(p, d);\n\t\t}\n\t\ttv++;\n\t}\n\n\t/* Inner functions recursively. */\n\tfn = (duk_hobject **) DUK_HCOMPFUNC_GET_FUNCS_BASE(thr->heap, func);\n\tfn_end = (duk_hobject **) DUK_HCOMPFUNC_GET_FUNCS_END(thr->heap, func);\n\twhile (fn != fn_end) {\n\t\t/* XXX: This causes recursion up to inner function depth\n\t\t * which is normally not an issue, e.g. mark-and-sweep uses\n\t\t * a recursion limiter to avoid C stack issues.  Avoiding\n\t\t * this would mean some sort of a work list or just refusing\n\t\t * to serialize deep functions.\n\t\t */\n\t\tDUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(*fn));\n\t\tp = duk__dump_func(ctx, (duk_hcompfunc *) *fn, bw_ctx, p);\n\t\tfn++;\n\t}\n\n\t/* Lexenv and varenv are not dumped. */\n\n\t/* Object extra properties.\n\t *\n\t * There are some difference between function templates and functions.\n\t * For example, function templates don't have .length and nargs is\n\t * normally used to instantiate the functions.\n\t */\n\n\tp = duk__dump_uint32_prop(thr, p, bw_ctx, (duk_hobject *) func, DUK_STRIDX_LENGTH, (duk_uint32_t) func->nargs);\n#if defined(DUK_USE_FUNC_NAME_PROPERTY)\n\tp = duk__dump_string_prop(thr, p, bw_ctx, (duk_hobject *) func, DUK_STRIDX_NAME);\n#endif\n#if defined(DUK_USE_FUNC_FILENAME_PROPERTY)\n\tp = duk__dump_string_prop(thr, p, bw_ctx, (duk_hobject *) func, DUK_STRIDX_FILE_NAME);\n#endif\n#if defined(DUK_USE_PC2LINE)\n\tp = duk__dump_buffer_prop(thr, p, bw_ctx, (duk_hobject *) func, DUK_STRIDX_INT_PC2LINE);\n#endif\n\tp = duk__dump_varmap(thr, p, bw_ctx, (duk_hobject *) func);\n\tp = duk__dump_formals(thr, p, bw_ctx, (duk_hobject *) func);\n\n\tDUK_DD(DUK_DDPRINT(\"serialized function %p -> final pointer %p\", (void *) func, (void *) p));\n\n\treturn p;\n}\n\n/* Load a function from bytecode.  The function object returned here must\n * match what is created by duk_js_push_closure() with respect to its flags,\n * properties, etc.\n *\n * NOTE: there are intentionally no input buffer length / bound checks.\n * Adding them would be easy but wouldn't ensure memory safety as untrusted\n * or broken bytecode is unsafe during execution unless the opcodes themselves\n * are validated (which is quite complex, especially for indirect opcodes).\n */\n\n#define DUK__ASSERT_LEFT(n) do { \\\n\t\tDUK_ASSERT((duk_size_t) (p_end - p) >= (duk_size_t) (n)); \\\n\t} while (0)\n\nstatic duk_uint8_t *duk__load_func(duk_context *ctx, duk_uint8_t *p, duk_uint8_t *p_end) {\n\tduk_hthread *thr;\n\tduk_hcompfunc *h_fun;\n\tduk_hbuffer *h_data;\n\tduk_size_t data_size;\n\tduk_uint32_t count_instr, count_const, count_funcs;\n\tduk_uint32_t n;\n\tduk_uint32_t tmp32;\n\tduk_small_uint_t const_type;\n\tduk_uint8_t *fun_data;\n\tduk_uint8_t *q;\n\tduk_idx_t idx_base;\n\tduk_tval *tv1;\n\tduk_uarridx_t arr_idx;\n\tduk_hobject *func_env;\n\tduk_bool_t need_pop;\n\n\t/* XXX: There's some overlap with duk_js_closure() here, but\n\t * seems difficult to share code.  Ensure that the final function\n\t * looks the same as created by duk_js_closure().\n\t */\n\n\tDUK_ASSERT(ctx != NULL);\n\tthr = (duk_hthread *) ctx;\n\n\tDUK_DD(DUK_DDPRINT(\"loading function, p=%p, p_end=%p\", (void *) p, (void *) p_end));\n\n\tDUK__ASSERT_LEFT(3 * 4);\n\tcount_instr = DUK_RAW_READ_U32_BE(p);\n\tcount_const = DUK_RAW_READ_U32_BE(p);\n\tcount_funcs = DUK_RAW_READ_U32_BE(p);\n\n\tdata_size = sizeof(duk_tval) * count_const +\n\t            sizeof(duk_hobject *) * count_funcs +\n\t            sizeof(duk_instr_t) * count_instr;\n\n\tDUK_DD(DUK_DDPRINT(\"instr=%ld, const=%ld, funcs=%ld, data_size=%ld\",\n\t                   (long) count_instr, (long) count_const,\n\t                   (long) count_const, (long) data_size));\n\n\t/* Value stack is used to ensure reachability of constants and\n\t * inner functions being loaded.  Require enough space to handle\n\t * large functions correctly.\n\t */\n\tduk_require_stack(ctx, 2 + count_const + count_funcs);\n\tidx_base = duk_get_top(ctx);\n\n\t/* Push function object, init flags etc.  This must match\n\t * duk_js_push_closure() quite carefully.\n\t */\n\th_fun = duk_push_hcompfunc(ctx);\n\tDUK_ASSERT(h_fun != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC((duk_hobject *) h_fun));\n\tDUK_ASSERT(DUK_HCOMPFUNC_GET_DATA(thr->heap, h_fun) == NULL);\n\tDUK_ASSERT(DUK_HCOMPFUNC_GET_FUNCS(thr->heap, h_fun) == NULL);\n\tDUK_ASSERT(DUK_HCOMPFUNC_GET_BYTECODE(thr->heap, h_fun) == NULL);\n\tDUK_ASSERT(DUK_HOBJECT_GET_PROTOTYPE(thr->heap, (duk_hobject *) h_fun) == thr->builtins[DUK_BIDX_FUNCTION_PROTOTYPE]);\n\n\th_fun->nregs = DUK_RAW_READ_U16_BE(p);\n\th_fun->nargs = DUK_RAW_READ_U16_BE(p);\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\th_fun->start_line = DUK_RAW_READ_U32_BE(p);\n\th_fun->end_line = DUK_RAW_READ_U32_BE(p);\n#else\n\tp += 8;  /* skip line info */\n#endif\n\n\t/* duk_hcompfunc flags; quite version specific */\n\ttmp32 = DUK_RAW_READ_U32_BE(p);\n\tDUK_HEAPHDR_SET_FLAGS((duk_heaphdr *) h_fun, tmp32);  /* masks flags to only change duk_hobject flags */\n\n\t/* standard prototype */\n\tDUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, &h_fun->obj, thr->builtins[DUK_BIDX_FUNCTION_PROTOTYPE]);\n\n\t/* assert just a few critical flags */\n\tDUK_ASSERT(DUK_HEAPHDR_GET_TYPE((duk_heaphdr *) h_fun) == DUK_HTYPE_OBJECT);\n\tDUK_ASSERT(!DUK_HOBJECT_HAS_BOUNDFUNC(&h_fun->obj));\n\tDUK_ASSERT(DUK_HOBJECT_HAS_COMPFUNC(&h_fun->obj));\n\tDUK_ASSERT(!DUK_HOBJECT_HAS_NATFUNC(&h_fun->obj));\n\tDUK_ASSERT(!DUK_HOBJECT_IS_THREAD(&h_fun->obj));\n\tDUK_ASSERT(!DUK_HOBJECT_HAS_EXOTIC_ARRAY(&h_fun->obj));\n\tDUK_ASSERT(!DUK_HOBJECT_HAS_EXOTIC_STRINGOBJ(&h_fun->obj));\n\tDUK_ASSERT(!DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS(&h_fun->obj));\n\n\t/* Create function 'data' buffer but don't attach it yet. */\n\tfun_data = (duk_uint8_t *) duk_push_fixed_buffer_nozero(ctx, data_size);\n\tDUK_ASSERT(fun_data != NULL);\n\n\t/* Load bytecode instructions. */\n\tDUK_ASSERT(sizeof(duk_instr_t) == 4);\n\tDUK__ASSERT_LEFT(count_instr * sizeof(duk_instr_t));\n#if defined(DUK_USE_INTEGER_BE)\n\tq = fun_data + sizeof(duk_tval) * count_const + sizeof(duk_hobject *) * count_funcs;\n\tDUK_MEMCPY((void *) q,\n\t           (const void *) p,\n\t           sizeof(duk_instr_t) * count_instr);\n\tp += sizeof(duk_instr_t) * count_instr;\n#else\n\tq = fun_data + sizeof(duk_tval) * count_const + sizeof(duk_hobject *) * count_funcs;\n\tfor (n = count_instr; n > 0; n--) {\n\t\t*((duk_instr_t *) (void *) q) = DUK_RAW_READ_U32_BE(p);\n\t\tq += sizeof(duk_instr_t);\n\t}\n#endif\n\n\t/* Load constants onto value stack but don't yet copy to buffer. */\n\tfor (n = count_const; n > 0; n--) {\n\t\tDUK__ASSERT_LEFT(1);\n\t\tconst_type = DUK_RAW_READ_U8(p);\n\t\tswitch (const_type) {\n\t\tcase DUK__SER_STRING: {\n\t\t\tp = duk__load_string_raw(ctx, p);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK__SER_NUMBER: {\n\t\t\t/* Important to do a fastint check so that constants are\n\t\t\t * properly read back as fastints.\n\t\t\t */\n\t\t\tduk_tval tv_tmp;\n\t\t\tduk_double_t val;\n\t\t\tDUK__ASSERT_LEFT(8);\n\t\t\tval = DUK_RAW_READ_DOUBLE_BE(p);\n\t\t\tDUK_TVAL_SET_NUMBER_CHKFAST_SLOW(&tv_tmp, val);\n\t\t\tduk_push_tval(ctx, &tv_tmp);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tgoto format_error;\n\t\t}\n\t\t}\n\t}\n\n\t/* Load inner functions to value stack, but don't yet copy to buffer. */\n\tfor (n = count_funcs; n > 0; n--) {\n\t\tp = duk__load_func(ctx, p, p_end);\n\t\tif (p == NULL) {\n\t\t\tgoto format_error;\n\t\t}\n\t}\n\n\t/* With constants and inner functions on value stack, we can now\n\t * atomically finish the function 'data' buffer, bump refcounts,\n\t * etc.\n\t *\n\t * Here we take advantage of the value stack being just a duk_tval\n\t * array: we can just memcpy() the constants as long as we incref\n\t * them afterwards.\n\t */\n\n\th_data = (duk_hbuffer *) duk_known_hbuffer(ctx, idx_base + 1);\n\tDUK_ASSERT(!DUK_HBUFFER_HAS_DYNAMIC(h_data));\n\tDUK_HCOMPFUNC_SET_DATA(thr->heap, h_fun, h_data);\n\tDUK_HBUFFER_INCREF(thr, h_data);\n\n\ttv1 = duk_get_tval(ctx, idx_base + 2);  /* may be NULL if no constants or inner funcs */\n\tDUK_ASSERT((count_const == 0 && count_funcs == 0) || tv1 != NULL);\n\n\tq = fun_data;\n\tif (count_const > 0) {\n\t\t/* Explicit zero size check to avoid NULL 'tv1'. */\n\t\tDUK_MEMCPY((void *) q, (const void *) tv1, sizeof(duk_tval) * count_const);\n\t\tfor (n = count_const; n > 0; n--) {\n\t\t\tDUK_TVAL_INCREF_FAST(thr, (duk_tval *) (void *) q);  /* no side effects */\n\t\t\tq += sizeof(duk_tval);\n\t\t}\n\t\ttv1 += count_const;\n\t}\n\n\tDUK_HCOMPFUNC_SET_FUNCS(thr->heap, h_fun, (duk_hobject **) (void *) q);\n\tfor (n = count_funcs; n > 0; n--) {\n\t\tduk_hobject *h_obj;\n\n\t\tDUK_ASSERT(DUK_TVAL_IS_OBJECT(tv1));\n\t\th_obj = DUK_TVAL_GET_OBJECT(tv1);\n\t\tDUK_ASSERT(h_obj != NULL);\n\t\ttv1++;\n\t\tDUK_HOBJECT_INCREF(thr, h_obj);\n\n\t\t*((duk_hobject **) (void *) q) = h_obj;\n\t\tq += sizeof(duk_hobject *);\n\t}\n\n\tDUK_HCOMPFUNC_SET_BYTECODE(thr->heap, h_fun, (duk_instr_t *) (void *) q);\n\n\t/* The function object is now reachable and refcounts are fine,\n\t * so we can pop off all the temporaries.\n\t */\n\tDUK_DDD(DUK_DDDPRINT(\"function is reachable, reset top; func: %!iT\", duk_get_tval(ctx, idx_base)));\n\tduk_set_top(ctx, idx_base + 1);\n\n\t/* Setup function properties. */\n\ttmp32 = DUK_RAW_READ_U32_BE(p);\n\tduk_push_u32(ctx, tmp32);\n\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_LENGTH, DUK_PROPDESC_FLAGS_C);\n\n#if defined(DUK_USE_FUNC_NAME_PROPERTY)\n\tp = duk__load_string_raw(ctx, p);  /* -> [ func funcname ] */\n\tfunc_env = thr->builtins[DUK_BIDX_GLOBAL_ENV];\n\tDUK_ASSERT(func_env != NULL);\n\tneed_pop = 0;\n\tif (DUK_HOBJECT_HAS_NAMEBINDING((duk_hobject *) h_fun)) {\n\t\t/* Original function instance/template had NAMEBINDING.\n\t\t * Must create a lexical environment on loading to allow\n\t\t * recursive functions like 'function foo() { foo(); }'.\n\t\t */\n\t\tduk_hdecenv *new_env;\n\n\t\tnew_env = duk_hdecenv_alloc(thr,\n\t\t                            DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t\t                            DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_DECENV));\n\t\tDUK_ASSERT(new_env != NULL);\n\t\tDUK_ASSERT(new_env->thread == NULL);  /* Closed. */\n\t\tDUK_ASSERT(new_env->varmap == NULL);\n\t\tDUK_ASSERT(new_env->regbase == 0);\n\t\tDUK_ASSERT_HDECENV_VALID(new_env);\n\t\tDUK_ASSERT(DUK_HOBJECT_GET_PROTOTYPE(thr->heap, (duk_hobject *) new_env) == NULL);\n\t\tDUK_HOBJECT_SET_PROTOTYPE(thr->heap, (duk_hobject *) new_env, func_env);\n\t\tDUK_HOBJECT_INCREF(thr, func_env);\n\n\t\tfunc_env = (duk_hobject *) new_env;\n\n\t\tduk_push_hobject(ctx, (duk_hobject *) new_env);\n\n\t\tduk_dup_m2(ctx);                                  /* -> [ func funcname env funcname ] */\n\t\tduk_dup(ctx, idx_base);                           /* -> [ func funcname env funcname func ] */\n\t\tduk_xdef_prop(ctx, -3, DUK_PROPDESC_FLAGS_NONE);  /* -> [ func funcname env ] */\n\n\t\tneed_pop = 1;  /* Need to pop env, but -after- updating h_fun and increfs. */\n\t}\n\tDUK_ASSERT(func_env != NULL);\n\tDUK_HCOMPFUNC_SET_LEXENV(thr->heap, h_fun, func_env);\n\tDUK_HCOMPFUNC_SET_VARENV(thr->heap, h_fun, func_env);\n\tDUK_HOBJECT_INCREF(thr, func_env);\n\tDUK_HOBJECT_INCREF(thr, func_env);\n\tif (need_pop) {\n\t\tduk_pop(ctx);\n\t}\n\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_NAME, DUK_PROPDESC_FLAGS_C);\n#endif  /* DUK_USE_FUNC_NAME_PROPERTY */\n\n#if defined(DUK_USE_FUNC_FILENAME_PROPERTY)\n\tp = duk__load_string_raw(ctx, p);\n\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_FILE_NAME, DUK_PROPDESC_FLAGS_C);\n#endif  /* DUK_USE_FUNC_FILENAME_PROPERTY */\n\n\tif (DUK_HOBJECT_HAS_CONSTRUCTABLE((duk_hobject *) h_fun)) {\n\t\t/* Restore empty external .prototype only for constructable\n\t\t * functions.\n\t\t */\n\t\tduk_push_object(ctx);\n\t\tduk_dup_m2(ctx);\n\t\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_CONSTRUCTOR, DUK_PROPDESC_FLAGS_WC);  /* func.prototype.constructor = func */\n\t\tduk_compact_m1(ctx);\n\t\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_PROTOTYPE, DUK_PROPDESC_FLAGS_W);\n\t}\n\n#if defined(DUK_USE_PC2LINE)\n\tp = duk__load_buffer_raw(ctx, p);\n\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_PC2LINE, DUK_PROPDESC_FLAGS_WC);\n#endif  /* DUK_USE_PC2LINE */\n\n\tduk_push_object(ctx);  /* _Varmap */\n\tfor (;;) {\n\t\t/* XXX: awkward */\n\t\tp = duk__load_string_raw(ctx, p);\n\t\tif (duk_get_length(ctx, -1) == 0) {\n\t\t\tduk_pop(ctx);\n\t\t\tbreak;\n\t\t}\n\t\ttmp32 = DUK_RAW_READ_U32_BE(p);\n\t\tduk_push_u32(ctx, tmp32);\n\t\tduk_put_prop(ctx, -3);\n\t}\n\tduk_compact_m1(ctx);\n\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_VARMAP, DUK_PROPDESC_FLAGS_NONE);\n\n\t/* If _Formals wasn't present in the original function, the list\n\t * here will be empty.  Same happens if _Formals was present but\n\t * had zero length.  We can omit _Formals from the result if its\n\t * length is zero and matches nargs.\n\t */\n\tduk_push_array(ctx);  /* _Formals */\n\tfor (arr_idx = 0; ; arr_idx++) {\n\t\t/* XXX: awkward */\n\t\tp = duk__load_string_raw(ctx, p);\n\t\tif (duk_get_length(ctx, -1) == 0) {\n\t\t\tduk_pop(ctx);\n\t\t\tbreak;\n\t\t}\n\t\tduk_put_prop_index(ctx, -2, arr_idx);\n\t}\n\tif (arr_idx == 0 && h_fun->nargs == 0) {\n\t\tduk_pop(ctx);\n\t} else {\n\t\tduk_compact_m1(ctx);\n\t\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_FORMALS, DUK_PROPDESC_FLAGS_NONE);\n\t}\n\n\t/* Return with final function pushed on stack top. */\n\tDUK_DD(DUK_DDPRINT(\"final loaded function: %!iT\", duk_get_tval(ctx, -1)));\n\tDUK_ASSERT_TOP(ctx, idx_base + 1);\n\treturn p;\n\n format_error:\n\treturn NULL;\n}\n\nDUK_EXTERNAL void duk_dump_function(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_hcompfunc *func;\n\tduk_bufwriter_ctx bw_ctx_alloc;\n\tduk_bufwriter_ctx *bw_ctx = &bw_ctx_alloc;\n\tduk_uint8_t *p;\n\n\tDUK_ASSERT(ctx != NULL);\n\tthr = (duk_hthread *) ctx;\n\n\t/* Bound functions don't have all properties so we'd either need to\n\t * lookup the non-bound target function or reject bound functions.\n\t * For now, bound functions are rejected.\n\t */\n\tfunc = duk_require_hcompfunc(ctx, -1);\n\tDUK_ASSERT(func != NULL);\n\tDUK_ASSERT(!DUK_HOBJECT_HAS_BOUNDFUNC(&func->obj));\n\n\t/* Estimating the result size beforehand would be costly, so\n\t * start with a reasonable size and extend as needed.\n\t */\n\tDUK_BW_INIT_PUSHBUF(thr, bw_ctx, DUK__BYTECODE_INITIAL_ALLOC);\n\tp = DUK_BW_GET_PTR(thr, bw_ctx);\n\t*p++ = DUK__SER_MARKER;\n\t*p++ = DUK__SER_VERSION;\n\tp = duk__dump_func(ctx, func, bw_ctx, p);\n\tDUK_BW_SET_PTR(thr, bw_ctx, p);\n\tDUK_BW_COMPACT(thr, bw_ctx);\n\n\tDUK_DD(DUK_DDPRINT(\"serialized result: %!T\", duk_get_tval(ctx, -1)));\n\n\tduk_remove_m2(ctx);  /* [ ... func buf ] -> [ ... buf ] */\n}\n\nDUK_EXTERNAL void duk_load_function(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_uint8_t *p_buf, *p, *p_end;\n\tduk_size_t sz;\n\n\tDUK_ASSERT(ctx != NULL);\n\tthr = (duk_hthread *) ctx;\n\tDUK_UNREF(ctx);\n\n\tp_buf = (duk_uint8_t *) duk_require_buffer(ctx, -1, &sz);\n\tDUK_ASSERT(p_buf != NULL);\n\n\t/* The caller is responsible for being sure that bytecode being loaded\n\t * is valid and trusted.  Invalid bytecode can cause memory unsafe\n\t * behavior directly during loading or later during bytecode execution\n\t * (instruction validation would be quite complex to implement).\n\t *\n\t * This signature check is the only sanity check for detecting\n\t * accidental invalid inputs.  The initial 0xFF byte ensures no\n\t * ordinary string will be accepted by accident.\n\t */\n\tp = p_buf;\n\tp_end = p_buf + sz;\n\tif (sz < 2 || p[0] != DUK__SER_MARKER || p[1] != DUK__SER_VERSION) {\n\t\tgoto format_error;\n\t}\n\tp += 2;\n\n\tp = duk__load_func(ctx, p, p_end);\n\tif (p == NULL) {\n\t\tgoto format_error;\n\t}\n\n\tduk_remove_m2(ctx);  /* [ ... buf func ] -> [ ... func ] */\n\treturn;\n\n format_error:\n\tDUK_ERROR_TYPE(thr, DUK_STR_DECODE_FAILED);\n}\n\n#else  /* DUK_USE_BYTECODE_DUMP_SUPPORT */\n\nDUK_EXTERNAL void duk_dump_function(duk_context *ctx) {\n\tDUK_ERROR_UNSUPPORTED((duk_hthread *) ctx);\n}\n\nDUK_EXTERNAL void duk_load_function(duk_context *ctx) {\n\tDUK_ERROR_UNSUPPORTED((duk_hthread *) ctx);\n}\n\n#endif  /* DUK_USE_BYTECODE_DUMP_SUPPORT */\n\n/* automatic undefs */\n#undef DUK__ASSERT_LEFT\n#undef DUK__BYTECODE_INITIAL_ALLOC\n#undef DUK__SER_MARKER\n#undef DUK__SER_NUMBER\n#undef DUK__SER_STRING\n#undef DUK__SER_VERSION\n/*\n *  Calls.\n *\n *  Protected variants should avoid ever throwing an error.\n */\n\n/* #include duk_internal.h -> already included */\n\n/* Prepare value stack for a method call through an object property.\n * May currently throw an error e.g. when getting the property.\n */\nDUK_LOCAL void duk__call_prop_prep_stack(duk_context *ctx, duk_idx_t normalized_obj_idx, duk_idx_t nargs) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tDUK_DDD(DUK_DDDPRINT(\"duk__call_prop_prep_stack, normalized_obj_idx=%ld, nargs=%ld, stacktop=%ld\",\n\t                     (long) normalized_obj_idx, (long) nargs, (long) duk_get_top(ctx)));\n\n\t/* [... key arg1 ... argN] */\n\n\t/* duplicate key */\n\tduk_dup(ctx, -nargs - 1);  /* Note: -nargs alone would fail for nargs == 0, this is OK */\n\tduk_get_prop(ctx, normalized_obj_idx);\n\n\tDUK_DDD(DUK_DDDPRINT(\"func: %!T\", (duk_tval *) duk_get_tval(ctx, -1)));\n\n\t/* [... key arg1 ... argN func] */\n\n\tduk_replace(ctx, -nargs - 2);\n\n\t/* [... func arg1 ... argN] */\n\n\tduk_dup(ctx, normalized_obj_idx);\n\tduk_insert(ctx, -nargs - 1);\n\n\t/* [... func this arg1 ... argN] */\n}\n\nDUK_EXTERNAL void duk_call(duk_context *ctx, duk_idx_t nargs) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_small_uint_t call_flags;\n\tduk_idx_t idx_func;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr != NULL);\n\n\tidx_func = duk_get_top(ctx) - nargs - 1;\n\tif (idx_func < 0 || nargs < 0) {\n\t\t/* note that we can't reliably pop anything here */\n\t\tDUK_ERROR_TYPE_INVALID_ARGS(thr);\n\t}\n\n\t/* XXX: awkward; we assume there is space for this, overwrite\n\t * directly instead?\n\t */\n\tduk_push_undefined(ctx);\n\tduk_insert(ctx, idx_func + 1);\n\n\tcall_flags = 0;  /* not protected, respect reclimit, not constructor */\n\n\tduk_handle_call_unprotected(thr,           /* thread */\n\t                            nargs,         /* num_stack_args */\n\t                            call_flags);   /* call_flags */\n}\n\nDUK_EXTERNAL void duk_call_method(duk_context *ctx, duk_idx_t nargs) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_small_uint_t call_flags;\n\tduk_idx_t idx_func;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr != NULL);\n\n\tidx_func = duk_get_top(ctx) - nargs - 2;  /* must work for nargs <= 0 */\n\tif (idx_func < 0 || nargs < 0) {\n\t\t/* note that we can't reliably pop anything here */\n\t\tDUK_ERROR_TYPE_INVALID_ARGS(thr);\n\t}\n\n\tcall_flags = 0;  /* not protected, respect reclimit, not constructor */\n\n\tduk_handle_call_unprotected(thr,           /* thread */\n\t                            nargs,         /* num_stack_args */\n\t                            call_flags);   /* call_flags */\n}\n\nDUK_EXTERNAL void duk_call_prop(duk_context *ctx, duk_idx_t obj_idx, duk_idx_t nargs) {\n\t/*\n\t *  XXX: if duk_handle_call() took values through indices, this could be\n\t *  made much more sensible.  However, duk_handle_call() needs to fudge\n\t *  the 'this' and 'func' values to handle bound function chains, which\n\t *  is now done \"in-place\", so this is not a trivial change.\n\t */\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tobj_idx = duk_require_normalize_index(ctx, obj_idx);  /* make absolute */\n\n\tduk__call_prop_prep_stack(ctx, obj_idx, nargs);\n\n\tduk_call_method(ctx, nargs);\n}\n\nDUK_EXTERNAL duk_int_t duk_pcall(duk_context *ctx, duk_idx_t nargs) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_small_uint_t call_flags;\n\tduk_idx_t idx_func;\n\tduk_int_t rc;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr != NULL);\n\n\tidx_func = duk_get_top(ctx) - nargs - 1;  /* must work for nargs <= 0 */\n\tif (idx_func < 0 || nargs < 0) {\n\t\t/* We can't reliably pop anything here because the stack input\n\t\t * shape is incorrect.  So we throw an error; if the caller has\n\t\t * no catch point for this, a fatal error will occur.  Another\n\t\t * alternative would be to just return an error.  But then the\n\t\t * stack would be in an unknown state which might cause some\n\t\t * very hard to diagnose problems later on.  Also note that even\n\t\t * if we did not throw an error here, the underlying call handler\n\t\t * might STILL throw an out-of-memory error or some other internal\n\t\t * fatal error.\n\t\t */\n\t\tDUK_ERROR_TYPE_INVALID_ARGS(thr);\n\t\treturn DUK_EXEC_ERROR;  /* unreachable */\n\t}\n\n\t/* awkward; we assume there is space for this */\n\tduk_push_undefined(ctx);\n\tduk_insert(ctx, idx_func + 1);\n\n\tcall_flags = 0;  /* respect reclimit, not constructor */\n\n\trc = duk_handle_call_protected(thr,           /* thread */\n\t                               nargs,         /* num_stack_args */\n\t                               call_flags);   /* call_flags */\n\n\treturn rc;\n}\n\nDUK_EXTERNAL duk_int_t duk_pcall_method(duk_context *ctx, duk_idx_t nargs) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_small_uint_t call_flags;\n\tduk_idx_t idx_func;\n\tduk_int_t rc;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr != NULL);\n\n\tidx_func = duk_get_top(ctx) - nargs - 2;  /* must work for nargs <= 0 */\n\tif (idx_func < 0 || nargs < 0) {\n\t\t/* See comments in duk_pcall(). */\n\t\tDUK_ERROR_TYPE_INVALID_ARGS(thr);\n\t\treturn DUK_EXEC_ERROR;  /* unreachable */\n\t}\n\n\tcall_flags = 0;  /* respect reclimit, not constructor */\n\n\trc = duk_handle_call_protected(thr,           /* thread */\n\t                               nargs,         /* num_stack_args */\n\t                               call_flags);   /* call_flags */\n\n\treturn rc;\n}\n\nstruct duk__pcall_prop_args {\n\tduk_idx_t obj_idx;\n\tduk_idx_t nargs;\n};\ntypedef struct duk__pcall_prop_args duk__pcall_prop_args;\n\nDUK_LOCAL duk_ret_t duk__pcall_prop_raw(duk_context *ctx, void *udata) {\n\tduk_idx_t obj_idx;\n\tduk_idx_t nargs;\n\tduk__pcall_prop_args *args;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(udata != NULL);\n\n\targs = (duk__pcall_prop_args *) udata;\n\tobj_idx = args->obj_idx;\n\tnargs = args->nargs;\n\n\tobj_idx = duk_require_normalize_index(ctx, obj_idx);  /* make absolute */\n\tduk__call_prop_prep_stack(ctx, obj_idx, nargs);\n\tduk_call_method(ctx, nargs);\n\treturn 1;\n}\n\nDUK_EXTERNAL duk_int_t duk_pcall_prop(duk_context *ctx, duk_idx_t obj_idx, duk_idx_t nargs) {\n\tduk__pcall_prop_args args;\n\n\t/*\n\t *  Must be careful to catch errors related to value stack manipulation\n\t *  and property lookup, not just the call itself.\n\t */\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\targs.obj_idx = obj_idx;\n\targs.nargs = nargs;\n\n\t/* Inputs: explicit arguments (nargs), +1 for key.  If the value stack\n\t * does not contain enough args, an error is thrown; this matches\n\t * behavior of the other protected call API functions.\n\t */\n\treturn duk_safe_call(ctx, duk__pcall_prop_raw, (void *) &args /*udata*/, nargs + 1 /*nargs*/, 1 /*nrets*/);\n}\n\nDUK_EXTERNAL duk_int_t duk_safe_call(duk_context *ctx, duk_safe_call_function func, void *udata, duk_idx_t nargs, duk_idx_t nrets) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_int_t rc;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr != NULL);\n\n\tif (duk_get_top(ctx) < nargs || nrets < 0) {\n\t\t/* See comments in duk_pcall(). */\n\t\tDUK_ERROR_TYPE_INVALID_ARGS(thr);\n\t\treturn DUK_EXEC_ERROR;  /* unreachable */\n\t}\n\n\trc = duk_handle_safe_call(thr,           /* thread */\n\t                          func,          /* func */\n\t                          udata,         /* udata */\n\t                          nargs,         /* num_stack_args */\n\t                          nrets);        /* num_stack_res */\n\n\treturn rc;\n}\n\nDUK_EXTERNAL void duk_new(duk_context *ctx, duk_idx_t nargs) {\n\t/*\n\t *  There are two [[Construct]] operations in the specification:\n\t *\n\t *    - E5 Section 13.2.2: for Function objects\n\t *    - E5 Section 15.3.4.5.2: for \"bound\" Function objects\n\t *\n\t *  The chain of bound functions is resolved in Section 15.3.4.5.2,\n\t *  with arguments \"piling up\" until the [[Construct]] internal\n\t *  method is called on the final, actual Function object.  Note\n\t *  that the \"prototype\" property is looked up *only* from the\n\t *  final object, *before* calling the constructor.\n\t *\n\t *  Currently we follow the bound function chain here to get the\n\t *  \"prototype\" property value from the final, non-bound function.\n\t *  However, we let duk_handle_call() handle the argument \"piling\"\n\t *  when the constructor is called.  The bound function chain is\n\t *  thus now processed twice.\n\t *\n\t *  When constructing new Array instances, an unnecessary object is\n\t *  created and discarded now: the standard [[Construct]] creates an\n\t *  object, and calls the Array constructor.  The Array constructor\n\t *  returns an Array instance, which is used as the result value for\n\t *  the \"new\" operation; the object created before the Array constructor\n\t *  call is discarded.\n\t *\n\t *  This would be easy to fix, e.g. by knowing that the Array constructor\n\t *  will always create a replacement object and skip creating the fallback\n\t *  object in that case.\n\t *\n\t *  Note: functions called via \"new\" need to know they are called as a\n\t *  constructor.  For instance, built-in constructors behave differently\n\t *  depending on how they are called.\n\t */\n\n\t/* XXX: merge this with duk_js_call.c, as this function implements\n\t * core semantics (or perhaps merge the two files altogether).\n\t */\n\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *proto;\n\tduk_hobject *cons;\n\tduk_hobject *fallback;\n\tduk_idx_t idx_cons;\n\tduk_small_uint_t call_flags;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t/* [... constructor arg1 ... argN] */\n\n\tidx_cons = duk_require_normalize_index(ctx, -nargs - 1);\n\n\tDUK_DDD(DUK_DDDPRINT(\"top=%ld, nargs=%ld, idx_cons=%ld\",\n\t                     (long) duk_get_top(ctx), (long) nargs, (long) idx_cons));\n\n\t/* XXX: code duplication */\n\n\t/*\n\t *  Figure out the final, non-bound constructor, to get \"prototype\"\n\t *  property.\n\t */\n\n\tduk_dup(ctx, idx_cons);\n\tfor (;;) {\n\t\tduk_tval *tv;\n\t\ttv = DUK_GET_TVAL_NEGIDX(ctx, -1);\n\t\tDUK_ASSERT(tv != NULL);\n\n\t\tif (DUK_TVAL_IS_OBJECT(tv)) {\n\t\t\tcons = DUK_TVAL_GET_OBJECT(tv);\n\t\t\tDUK_ASSERT(cons != NULL);\n\t\t\tif (!DUK_HOBJECT_IS_CALLABLE(cons) || !DUK_HOBJECT_HAS_CONSTRUCTABLE(cons)) {\n\t\t\t\t/* Checking callability of the immediate target\n\t\t\t\t * is important, same for constructability.\n\t\t\t\t * Checking it for functions down the bound\n\t\t\t\t * function chain is not strictly necessary\n\t\t\t\t * because .bind() should normally reject them.\n\t\t\t\t * But it's good to check anyway because it's\n\t\t\t\t * technically possible to edit the bound function\n\t\t\t\t * chain via internal keys.\n\t\t\t\t */\n\t\t\t\tgoto not_constructable;\n\t\t\t}\n\t\t\tif (!DUK_HOBJECT_HAS_BOUNDFUNC(cons)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else if (DUK_TVAL_IS_LIGHTFUNC(tv)) {\n\t\t\t/* Lightfuncs cannot be bound. */\n\t\t\tbreak;\n\t\t} else {\n\t\t\t/* Anything else is not constructable. */\n\t\t\tgoto not_constructable;\n\t\t}\n\t\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_INT_TARGET);  /* -> [... cons target] */\n\t\tduk_remove_m2(ctx);                                         /* -> [... target] */\n\t}\n\tDUK_ASSERT(duk_is_callable(ctx, -1));\n\tDUK_ASSERT(duk_is_lightfunc(ctx, -1) ||\n\t           (duk_get_hobject(ctx, -1) != NULL && !DUK_HOBJECT_HAS_BOUNDFUNC(duk_get_hobject(ctx, -1))));\n\n\t/* [... constructor arg1 ... argN final_cons] */\n\n\t/*\n\t *  Create \"fallback\" object to be used as the object instance,\n\t *  unless the constructor returns a replacement value.\n\t *  Its internal prototype needs to be set based on \"prototype\"\n\t *  property of the constructor.\n\t */\n\n\tduk_push_object(ctx);  /* class Object, extensible */\n\n\t/* [... constructor arg1 ... argN final_cons fallback] */\n\n\tduk_get_prop_stridx_short(ctx, -2, DUK_STRIDX_PROTOTYPE);\n\tproto = duk_get_hobject(ctx, -1);\n\tif (!proto) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"constructor has no 'prototype' property, or value not an object \"\n\t\t                     \"-> leave standard Object prototype as fallback prototype\"));\n\t} else {\n\t\tDUK_DDD(DUK_DDDPRINT(\"constructor has 'prototype' property with object value \"\n\t\t                     \"-> set fallback prototype to that value: %!iO\", (duk_heaphdr *) proto));\n\t\tfallback = duk_get_hobject(ctx, -2);\n\t\tDUK_ASSERT(fallback != NULL);\n\t\tDUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, fallback, proto);\n\t}\n\tduk_pop(ctx);\n\n\t/* [... constructor arg1 ... argN final_cons fallback] */\n\n\t/*\n\t *  Manipulate callstack for the call.\n\t */\n\n\tduk_dup_top(ctx);\n\tduk_insert(ctx, idx_cons + 1);  /* use fallback as 'this' value */\n\tduk_insert(ctx, idx_cons);      /* also stash it before constructor,\n\t                                 * in case we need it (as the fallback value)\n\t                                 */\n\tduk_pop(ctx);                   /* pop final_cons */\n\n\n\t/* [... fallback constructor fallback(this) arg1 ... argN];\n\t * Note: idx_cons points to first 'fallback', not 'constructor'.\n\t */\n\n\tDUK_DDD(DUK_DDDPRINT(\"before call, idx_cons+1 (constructor) -> %!T, idx_cons+2 (fallback/this) -> %!T, \"\n\t                     \"nargs=%ld, top=%ld\",\n\t                     (duk_tval *) duk_get_tval(ctx, idx_cons + 1),\n\t                     (duk_tval *) duk_get_tval(ctx, idx_cons + 2),\n\t                     (long) nargs,\n\t                     (long) duk_get_top(ctx)));\n\n\t/*\n\t *  Call the constructor function (called in \"constructor mode\").\n\t */\n\n\tcall_flags = DUK_CALL_FLAG_CONSTRUCTOR_CALL;  /* not protected, respect reclimit, is a constructor call */\n\n\tduk_handle_call_unprotected(thr,           /* thread */\n\t                            nargs,         /* num_stack_args */\n\t                            call_flags);   /* call_flags */\n\n\t/* [... fallback retval] */\n\n\tDUK_DDD(DUK_DDDPRINT(\"constructor call finished, fallback=%!iT, retval=%!iT\",\n\t                     (duk_tval *) duk_get_tval(ctx, -2),\n\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\n\t/*\n\t *  Determine whether to use the constructor return value as the created\n\t *  object instance or not.\n\t */\n\n\tif (duk_check_type_mask(ctx, -1, DUK_TYPE_MASK_OBJECT |\n\t                                 DUK_TYPE_MASK_BUFFER |\n\t                                 DUK_TYPE_MASK_LIGHTFUNC)) {\n\t\tduk_remove_m2(ctx);\n\t} else {\n\t\tduk_pop(ctx);\n\t}\n\n\t/*\n\t *  Augment created errors upon creation (not when they are thrown or\n\t *  rethrown).  __FILE__ and __LINE__ are not desirable here; the call\n\t *  stack reflects the caller which is correct.\n\t */\n\n#if defined(DUK_USE_AUGMENT_ERROR_CREATE)\n\tduk_hthread_sync_currpc(thr);\n\tduk_err_augment_error_create(thr, thr, NULL, 0, 1 /*noblame_fileline*/);\n#endif\n\n\t/* [... retval] */\n\n\treturn;\n\n not_constructable:\n#if defined(DUK_USE_VERBOSE_ERRORS)\n#if defined(DUK_USE_PARANOID_ERRORS)\n\tDUK_ERROR_FMT1(thr, DUK_ERR_TYPE_ERROR, \"%s not constructable\", duk_get_type_name(ctx, -1));\n#else\n\tDUK_ERROR_FMT1(thr, DUK_ERR_TYPE_ERROR, \"%s not constructable\", duk_push_string_readable(ctx, -1));\n#endif\n#else\n\tDUK_ERROR_TYPE(thr, \"not constructable\");\n#endif\n}\n\nDUK_LOCAL duk_ret_t duk__pnew_helper(duk_context *ctx, void *udata) {\n\tduk_idx_t nargs;\n\n\tDUK_ASSERT(udata != NULL);\n\tnargs = *((duk_idx_t *) udata);\n\n\tduk_new(ctx, nargs);\n\treturn 1;\n}\n\nDUK_EXTERNAL duk_int_t duk_pnew(duk_context *ctx, duk_idx_t nargs) {\n\tduk_int_t rc;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t/* For now, just use duk_safe_call() to wrap duk_new().  We can't\n\t * simply use a protected duk_handle_call() because there's post\n\t * processing which might throw.  It should be possible to ensure\n\t * the post processing never throws (except in internal errors and\n\t * out of memory etc which are always allowed) and then remove this\n\t * wrapper.\n\t */\n\n\trc = duk_safe_call(ctx, duk__pnew_helper, (void *) &nargs /*udata*/, nargs + 1 /*nargs*/, 1 /*nrets*/);\n\treturn rc;\n}\n\nDUK_EXTERNAL duk_bool_t duk_is_constructor_call(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_activation *act;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT_DISABLE(thr->callstack_top >= 0);\n\n\tact = thr->callstack_curr;\n\tif (act != NULL) {\n\t\treturn ((act->flags & DUK_ACT_FLAG_CONSTRUCT) != 0 ? 1 : 0);\n\t}\n\treturn 0;\n}\n\n/* XXX: Make this obsolete by adding a function flag for rejecting a\n * non-constructor call automatically?\n */\nDUK_INTERNAL void duk_require_constructor_call(duk_context *ctx) {\n\tif (!duk_is_constructor_call(ctx)) {\n\t\tDUK_ERROR_TYPE((duk_hthread *) ctx, DUK_STR_CONSTRUCT_ONLY);\n\t}\n}\n\nDUK_EXTERNAL duk_bool_t duk_is_strict_call(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_activation *act;\n\n\t/* For user code this could just return 1 (strict) always\n\t * because all Duktape/C functions are considered strict,\n\t * and strict is also the default when nothing is running.\n\t * However, Duktape may call this function internally when\n\t * the current activation is an Ecmascript function, so\n\t * this cannot be replaced by a 'return 1' without fixing\n\t * the internal call sites.\n\t */\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT_DISABLE(thr->callstack_top >= 0);\n\n\tact = thr->callstack_curr;\n\tif (act != NULL) {\n\t\treturn ((act->flags & DUK_ACT_FLAG_STRICT) != 0 ? 1 : 0);\n\t} else {\n\t\t/* Strict by default. */\n\t\treturn 1;\n\t}\n}\n\n/*\n *  Duktape/C function magic\n */\n\nDUK_EXTERNAL duk_int_t duk_get_current_magic(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_activation *act;\n\tduk_hobject *func;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT_DISABLE(thr->callstack_top >= 0);\n\n\tact = thr->callstack_curr;\n\tif (act) {\n\t\tfunc = DUK_ACT_GET_FUNC(act);\n\t\tif (!func) {\n\t\t\tduk_tval *tv = &act->tv_func;\n\t\t\tduk_small_uint_t lf_flags;\n\t\t\tlf_flags = DUK_TVAL_GET_LIGHTFUNC_FLAGS(tv);\n\t\t\treturn (duk_int_t) DUK_LFUNC_FLAGS_GET_MAGIC(lf_flags);\n\t\t}\n\t\tDUK_ASSERT(func != NULL);\n\n\t\tif (DUK_HOBJECT_IS_NATFUNC(func)) {\n\t\t\tduk_hnatfunc *nf = (duk_hnatfunc *) func;\n\t\t\treturn (duk_int_t) nf->magic;\n\t\t}\n\t}\n\treturn 0;\n}\n\nDUK_EXTERNAL duk_int_t duk_get_magic(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\tduk_hobject *h;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_require_tval(ctx, idx);\n\tif (DUK_TVAL_IS_OBJECT(tv)) {\n\t\th = DUK_TVAL_GET_OBJECT(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\tif (!DUK_HOBJECT_HAS_NATFUNC(h)) {\n\t\t\tgoto type_error;\n\t\t}\n\t\treturn (duk_int_t) ((duk_hnatfunc *) h)->magic;\n\t} else if (DUK_TVAL_IS_LIGHTFUNC(tv)) {\n\t\tduk_small_uint_t lf_flags = DUK_TVAL_GET_LIGHTFUNC_FLAGS(tv);\n\t\treturn (duk_int_t) DUK_LFUNC_FLAGS_GET_MAGIC(lf_flags);\n\t}\n\n\t/* fall through */\n type_error:\n\tDUK_ERROR_TYPE(thr, DUK_STR_UNEXPECTED_TYPE);\n\treturn 0;\n}\n\nDUK_EXTERNAL void duk_set_magic(duk_context *ctx, duk_idx_t idx, duk_int_t magic) {\n\tduk_hnatfunc *nf;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tnf = duk_require_hnatfunc(ctx, idx);\n\tDUK_ASSERT(nf != NULL);\n\tnf->magic = (duk_int16_t) magic;\n}\n\n/*\n *  Misc helpers\n */\n\nDUK_INTERNAL void duk_resolve_nonbound_function(duk_context *ctx) {\n\tduk_uint_t sanity;\n\tduk_tval *tv;\n\n\tsanity = DUK_HOBJECT_BOUND_CHAIN_SANITY;\n\tdo {\n\t\ttv = DUK_GET_TVAL_NEGIDX(ctx, -1);\n\t\tif (DUK_TVAL_IS_LIGHTFUNC(tv)) {\n\t\t\t/* Lightweight function: never bound, so terminate. */\n\t\t\tbreak;\n\t\t} else if (DUK_TVAL_IS_OBJECT(tv)) {\n\t\t\tduk_hobject *func;\n\n\t\t\tfunc = DUK_TVAL_GET_OBJECT(tv);\n\t\t\tDUK_ASSERT(func != NULL);\n\t\t\tif (!DUK_HOBJECT_IS_CALLABLE(func) || !DUK_HOBJECT_HAS_BOUNDFUNC(func)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_INT_TARGET);\n\t\t\tduk_replace(ctx, -2);\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t} while (--sanity > 0);\n}\n/*\n *  Encoding and decoding basic formats: hex, base64.\n *\n *  These are in-place operations which may allow an optimized implementation.\n *\n *  Base-64: https://tools.ietf.org/html/rfc4648#section-4\n */\n\n/* #include duk_internal.h -> already included */\n\n/* Shared handling for encode/decode argument.  Fast path handling for\n * buffer and string values because they're the most common.  In particular,\n * avoid creating a temporary string or buffer when possible.\n */\nDUK_LOCAL const duk_uint8_t *duk__prep_codec_arg(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len) {\n\tvoid *ptr;\n\tduk_bool_t isbuffer;\n\n\tDUK_ASSERT(duk_is_valid_index(ctx, idx));  /* checked by caller */\n\n\t/* XXX: with def_ptr set to a stack related pointer, isbuffer could\n\t * be removed from the helper?\n\t */\n\tptr = duk_get_buffer_data_raw(ctx, idx, out_len, NULL /*def_ptr*/, 0 /*def_size*/, 0 /*throw_flag*/, &isbuffer);\n\tif (isbuffer) {\n\t\tDUK_ASSERT(*out_len == 0 || ptr != NULL);\n\t\treturn (const duk_uint8_t *) ptr;\n\t}\n\treturn (const duk_uint8_t *) duk_to_lstring(ctx, idx, out_len);\n}\n\n#if defined(DUK_USE_BASE64_FASTPATH)\nDUK_LOCAL void duk__base64_encode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst) {\n\tduk_uint_t t;\n\tduk_size_t n_full, n_full3, n_final;\n\tconst duk_uint8_t *src_end_fast;\n\n\tn_full = srclen / 3;  /* full 3-byte -> 4-char conversions */\n\tn_full3 = n_full * 3;\n\tn_final = srclen - n_full3;\n\tDUK_ASSERT_DISABLE(n_final >= 0);\n\tDUK_ASSERT(n_final <= 2);\n\n\tsrc_end_fast = src + n_full3;\n\twhile (DUK_UNLIKELY(src != src_end_fast)) {\n\t\tt = (duk_uint_t) (*src++);\n\t\tt = (t << 8) + (duk_uint_t) (*src++);\n\t\tt = (t << 8) + (duk_uint_t) (*src++);\n\n\t\t*dst++ = duk_base64_enctab[t >> 18];\n\t\t*dst++ = duk_base64_enctab[(t >> 12) & 0x3f];\n\t\t*dst++ = duk_base64_enctab[(t >> 6) & 0x3f];\n\t\t*dst++ = duk_base64_enctab[t & 0x3f];\n\n#if 0  /* Tested: not faster on x64 */\n\t\t/* aaaaaabb bbbbcccc ccdddddd */\n\t\tdst[0] = duk_base64_enctab[(src[0] >> 2) & 0x3f];\n\t\tdst[1] = duk_base64_enctab[((src[0] << 4) & 0x30) | ((src[1] >> 4) & 0x0f)];\n\t\tdst[2] = duk_base64_enctab[((src[1] << 2) & 0x3f) | ((src[2] >> 6) & 0x03)];\n\t\tdst[3] = duk_base64_enctab[src[2] & 0x3f];\n\t\tsrc += 3; dst += 4;\n#endif\n\t}\n\n\tswitch (n_final) {\n\t/* case 0: nop */\n\tcase 1: {\n\t\t/* XX== */\n\t\tt = (duk_uint_t) (*src++);\n\t\t*dst++ = duk_base64_enctab[t >> 2];           /* XXXXXX-- */\n\t\t*dst++ = duk_base64_enctab[(t << 4) & 0x3f];  /* ------XX */\n\t\t*dst++ = DUK_ASC_EQUALS;\n\t\t*dst++ = DUK_ASC_EQUALS;\n\t\tbreak;\n\t}\n\tcase 2: {\n\t\t/* XXX= */\n\t\tt = (duk_uint_t) (*src++);\n\t\tt = (t << 8) + (duk_uint_t) (*src++);\n\t\t*dst++ = duk_base64_enctab[t >> 10];          /* XXXXXX-- -------- */\n\t\t*dst++ = duk_base64_enctab[(t >> 4) & 0x3f];  /* ------XX XXXX---- */\n\t\t*dst++ = duk_base64_enctab[(t << 2) & 0x3f];  /* -------- ----XXXX */\n\t\t*dst++ = DUK_ASC_EQUALS;\n\t\tbreak;\n\t}\n\t}\n}\n#else  /* DUK_USE_BASE64_FASTPATH */\nDUK_LOCAL void duk__base64_encode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst) {\n\tduk_small_uint_t i, snip;\n\tduk_uint_t t;\n\tduk_uint_fast8_t x, y;\n\tconst duk_uint8_t *src_end;\n\n\tsrc_end = src + srclen;\n\n\twhile (src < src_end) {\n\t\t/* read 3 bytes into 't', padded by zero */\n\t\tsnip = 4;\n\t\tt = 0;\n\t\tfor (i = 0; i < 3; i++) {\n\t\t\tt = t << 8;\n\t\t\tif (src >= src_end) {\n\t\t\t\tsnip--;\n\t\t\t} else {\n\t\t\t\tt += (duk_uint_t) (*src++);\n\t\t\t}\n\t\t}\n\n\t\t/*\n\t\t *  Missing bytes    snip     base64 example\n\t\t *    0               4         XXXX\n\t\t *    1               3         XXX=\n\t\t *    2               2         XX==\n\t\t */\n\n\t\tDUK_ASSERT(snip >= 2 && snip <= 4);\n\n\t\tfor (i = 0; i < 4; i++) {\n\t\t\tx = (duk_uint_fast8_t) ((t >> 18) & 0x3f);\n\t\t\tt = t << 6;\n\n\t\t\t/* A straightforward 64-byte lookup would be faster\n\t\t\t * and cleaner, but this is shorter.\n\t\t\t */\n\t\t\tif (i >= snip) {\n\t\t\t\ty = '=';\n\t\t\t} else if (x <= 25) {\n\t\t\t\ty = x + 'A';\n\t\t\t} else if (x <= 51) {\n\t\t\t\ty = x - 26 + 'a';\n\t\t\t} else if (x <= 61) {\n\t\t\t\ty = x - 52 + '0';\n\t\t\t} else if (x == 62) {\n\t\t\t\ty = '+';\n\t\t\t} else {\n\t\t\t\ty = '/';\n\t\t\t}\n\n\t\t\t*dst++ = (duk_uint8_t) y;\n\t\t}\n\t}\n}\n#endif  /* DUK_USE_BASE64_FASTPATH */\n\n#if defined(DUK_USE_BASE64_FASTPATH)\nDUK_LOCAL duk_bool_t duk__base64_decode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst, duk_uint8_t **out_dst_final) {\n\tduk_int_t x;\n\tduk_int_t t;\n\tduk_small_uint_t n_equal;\n\tduk_small_uint_t n_chars;\n\tconst duk_uint8_t *src_end;\n\tconst duk_uint8_t *src_end_safe;\n\n\tsrc_end = src + srclen;\n\tsrc_end_safe = src_end - 4;  /* if 'src < src_end_safe', safe to read 4 bytes */\n\n\t/* Innermost fast path processes 4 valid base-64 characters at a time\n\t * but bails out on whitespace, padding chars ('=') and invalid chars.\n\t * Once the slow path segment has been processed, we return to the\n\t * inner fast path again.  This handles e.g. base64 with newlines\n\t * reasonably well because the majority of a line is in the fast path.\n\t */\n\tfor (;;) {\n\t\t/* Fast path, handle units with just actual encoding characters. */\n\n\t\twhile (src <= src_end_safe) {\n\t\t\t/* The lookup byte is intentionally sign extended to (at least)\n\t\t\t * 32 bits and then ORed.  This ensures that is at least 1 byte\n\t\t\t * is negative, the highest bit of 't' will be set at the end\n\t\t\t * and we don't need to check every byte.\n\t\t\t */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"fast loop: src=%p, src_end_safe=%p, src_end=%p\",\n\t\t\t                     (const void *) src, (const void *) src_end_safe, (const void *) src_end));\n\n\t\t\tt = (duk_int_t) duk_base64_dectab[*src++];\n\t\t\tt = (t << 6) | (duk_int_t) duk_base64_dectab[*src++];\n\t\t\tt = (t << 6) | (duk_int_t) duk_base64_dectab[*src++];\n\t\t\tt = (t << 6) | (duk_int_t) duk_base64_dectab[*src++];\n\n\t\t\tif (DUK_UNLIKELY(t < 0)) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"fast loop unit was not clean, process one slow path unit\"));\n\t\t\t\tsrc -= 4;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tDUK_ASSERT(t <= 0xffffffL);\n\t\t\tDUK_ASSERT((t >> 24) == 0);\n\t\t\t*dst++ = (duk_uint8_t) (t >> 16);\n\t\t\t*dst++ = (duk_uint8_t) ((t >> 8) & 0xff);\n\t\t\t*dst++ = (duk_uint8_t) (t & 0xff);\n\t\t}\n\n\t\t/* Handle one slow path unit (or finish if we're done). */\n\n\t\tn_equal = 0;\n\t\tn_chars = 0;\n\t\tt = 0;\n\t\tfor (;;) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"slow loop: src=%p, src_end=%p, n_chars=%ld, n_equal=%ld, t=%ld\",\n\t\t\t                     (const void *) src, (const void *) src_end, (long) n_chars, (long) n_equal, (long) t));\n\n\t\t\tif (DUK_UNLIKELY(src >= src_end)) {\n\t\t\t\tgoto done;  /* two level break */\n\t\t\t}\n\n\t\t\tx = duk_base64_dectab[*src++];\n\t\t\tif (DUK_UNLIKELY(x < 0)) {\n\t\t\t\tif (x == -2) {\n\t\t\t\t\tcontinue;  /* allowed ascii whitespace */\n\t\t\t\t} else if (x == -3) {\n\t\t\t\t\tn_equal++;\n\t\t\t\t\tt <<= 6;\n\t\t\t\t} else {\n\t\t\t\t\tDUK_ASSERT(x == -1);\n\t\t\t\t\tgoto decode_error;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tDUK_ASSERT(x >= 0 && x <= 63);\n\t\t\t\tif (n_equal > 0) {\n\t\t\t\t\t/* Don't allow actual chars after equal sign. */\n\t\t\t\t\tgoto decode_error;\n\t\t\t\t}\n\t\t\t\tt = (t << 6) + x;\n\t\t\t}\n\n\t\t\tif (DUK_UNLIKELY(n_chars == 3)) {\n\t\t\t\t/* Emit 3 bytes and backtrack if there was padding.  There's\n\t\t\t\t * always space for the whole 3 bytes so no check needed.\n\t\t\t\t */\n\t\t\t\tDUK_ASSERT(t <= 0xffffffL);\n\t\t\t\tDUK_ASSERT((t >> 24) == 0);\n\t\t\t\t*dst++ = (duk_uint8_t) (t >> 16);\n\t\t\t\t*dst++ = (duk_uint8_t) ((t >> 8) & 0xff);\n\t\t\t\t*dst++ = (duk_uint8_t) (t & 0xff);\n\n\t\t\t\tif (DUK_UNLIKELY(n_equal > 0)) {\n\t\t\t\t\tDUK_ASSERT(n_equal <= 4);\n\n\t\t\t\t\t/* There may be whitespace between the equal signs. */\n\t\t\t\t\tif (n_equal == 1) {\n\t\t\t\t\t\t/* XXX= */\n\t\t\t\t\t\tdst -= 1;\n\t\t\t\t\t} else if (n_equal == 2) {\n\t\t\t\t\t\t/* XX== */\n\t\t\t\t\t\tdst -= 2;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tgoto decode_error;  /* invalid padding */\n\t\t\t\t\t}\n\n\t\t\t\t\t/* Continue parsing after padding, allows concatenated,\n\t\t\t\t\t * padded base64.\n\t\t\t\t\t */\n\t\t\t\t}\n\t\t\t\tbreak;  /* back to fast loop */\n\t\t\t} else {\n\t\t\t\tn_chars++;\n\t\t\t}\n\t\t}\n\t}\n done:\n\tDUK_DDD(DUK_DDDPRINT(\"done; src=%p, src_end=%p, n_chars=%ld\",\n\t                     (const void *) src, (const void *) src_end, (long) n_chars));\n\n\tDUK_ASSERT(src == src_end);\n\n\tif (n_chars != 0) {\n\t\t/* Here we'd have the option of decoding unpadded base64\n\t\t * (e.g. \"xxxxyy\" instead of \"xxxxyy==\".  Currently not\n\t\t * accepted.\n\t\t */\n\t\tgoto decode_error;\n\t}\n\n\t*out_dst_final = dst;\n\treturn 1;\n\n decode_error:\n\treturn 0;\n}\n#else  /* DUK_USE_BASE64_FASTPATH */\nDUK_LOCAL duk_bool_t duk__base64_decode_helper(const duk_uint8_t *src, duk_size_t srclen, duk_uint8_t *dst, duk_uint8_t **out_dst_final) {\n\tduk_uint_t t;\n\tduk_uint_fast8_t x, y;\n\tduk_small_uint_t group_idx;\n\tduk_small_uint_t n_equal;\n\tconst duk_uint8_t *src_end;\n\n\tsrc_end = src + srclen;\n\tt = 0;\n\tgroup_idx = 0;\n\tn_equal = 0;\n\n\twhile (src < src_end) {\n\t\tx = *src++;\n\n\t\tif (x >= 'A' && x <= 'Z') {\n\t\t\ty = x - 'A' + 0;\n\t\t} else if (x >= 'a' && x <= 'z') {\n\t\t\ty = x - 'a' + 26;\n\t\t} else if (x >= '0' && x <= '9') {\n\t\t\ty = x - '0' + 52;\n\t\t} else if (x == '+') {\n\t\t\ty = 62;\n\t\t} else if (x == '/') {\n\t\t\ty = 63;\n\t\t} else if (x == '=') {\n\t\t\t/* We don't check the zero padding bytes here right now\n\t\t\t * (that they're actually zero).  This seems to be common\n\t\t\t * behavior for base-64 decoders.\n\t\t\t */\n\n\t\t\tn_equal++;\n\t\t\tt <<= 6;  /* shift in zeroes */\n\t\t\tgoto skip_add;\n\t\t} else if (x == 0x09 || x == 0x0a || x == 0x0d || x == 0x20) {\n\t\t\t/* allow basic ASCII whitespace */\n\t\t\tcontinue;\n\t\t} else {\n\t\t\tgoto decode_error;\n\t\t}\n\n\t\tif (n_equal > 0) {\n\t\t\t/* Don't allow mixed padding and actual chars. */\n\t\t\tgoto decode_error;\n\t\t}\n\t\tt = (t << 6) + y;\n\t skip_add:\n\n\t\tif (group_idx == 3) {\n\t\t\t/* output 3 bytes from 't' */\n\t\t\t*dst++ = (duk_uint8_t) ((t >> 16) & 0xff);\n\t\t\t*dst++ = (duk_uint8_t) ((t >> 8) & 0xff);\n\t\t\t*dst++ = (duk_uint8_t) (t & 0xff);\n\n\t\t\tif (DUK_UNLIKELY(n_equal > 0)) {\n\t\t\t\t/* Backtrack. */\n\t\t\t\tDUK_ASSERT(n_equal <= 4);\n\t\t\t\tif (n_equal == 1) {\n\t\t\t\t\tdst -= 1;\n\t\t\t\t} else if (n_equal == 2) {\n\t\t\t\t\tdst -= 2;\n\t\t\t\t} else {\n\t\t\t\t\tgoto decode_error;  /* invalid padding */\n\t\t\t\t}\n\n\t\t\t\t/* Here we can choose either to end parsing and ignore\n\t\t\t\t * whatever follows, or to continue parsing in case\n\t\t\t\t * multiple (possibly padded) base64 strings have been\n\t\t\t\t * concatenated.  Currently, keep on parsing.\n\t\t\t\t */\n\t\t\t\tn_equal = 0;\n\t\t\t}\n\n\t\t\tt = 0;\n\t\t\tgroup_idx = 0;\n\t\t} else {\n\t\t\tgroup_idx++;\n\t\t}\n\t}\n\n\tif (group_idx != 0) {\n\t\t/* Here we'd have the option of decoding unpadded base64\n\t\t * (e.g. \"xxxxyy\" instead of \"xxxxyy==\".  Currently not\n\t\t * accepted.\n\t\t */\n\t\tgoto decode_error;\n\t}\n\n\t*out_dst_final = dst;\n\treturn 1;\n\n decode_error:\n\treturn 0;\n}\n#endif  /* DUK_USE_BASE64_FASTPATH */\n\nDUK_EXTERNAL const char *duk_base64_encode(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tconst duk_uint8_t *src;\n\tduk_size_t srclen;\n\tduk_size_t dstlen;\n\tduk_uint8_t *dst;\n\tconst char *ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t/* XXX: optimize for string inputs: no need to coerce to a buffer\n\t * which makes a copy of the input.\n\t */\n\n\tidx = duk_require_normalize_index(ctx, idx);\n\tsrc = duk__prep_codec_arg(ctx, idx, &srclen);\n\t/* Note: for srclen=0, src may be NULL */\n\n\t/* Computation must not wrap; this limit works for 32-bit size_t:\n\t * >>> srclen = 3221225469\n\t * >>> '%x' % ((srclen + 2) / 3 * 4)\n\t * 'fffffffc'\n\t */\n\tif (srclen > 3221225469UL) {\n\t\tgoto type_error;\n\t}\n\tdstlen = (srclen + 2) / 3 * 4;\n\tdst = (duk_uint8_t *) duk_push_fixed_buffer_nozero(ctx, dstlen);\n\n\tduk__base64_encode_helper((const duk_uint8_t *) src, srclen, dst);\n\n\tret = duk_buffer_to_string(ctx, -1);  /* Safe, result is ASCII. */\n\tduk_replace(ctx, idx);\n\treturn ret;\n\n type_error:\n\tDUK_ERROR_TYPE(thr, DUK_STR_ENCODE_FAILED);\n\treturn NULL;  /* never here */\n}\n\nDUK_EXTERNAL void duk_base64_decode(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tconst duk_uint8_t *src;\n\tduk_size_t srclen;\n\tduk_size_t dstlen;\n\tduk_uint8_t *dst;\n\tduk_uint8_t *dst_final;\n\tduk_bool_t retval;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t/* XXX: optimize for buffer inputs: no need to coerce to a string\n\t * which causes an unnecessary interning.\n\t */\n\n\tidx = duk_require_normalize_index(ctx, idx);\n\tsrc = duk__prep_codec_arg(ctx, idx, &srclen);\n\n\t/* Computation must not wrap, only srclen + 3 is at risk of\n\t * wrapping because after that the number gets smaller.\n\t * This limit works for 32-bit size_t:\n\t * 0x100000000 - 3 - 1 = 4294967292\n\t */\n\tif (srclen > 4294967292UL) {\n\t\tgoto type_error;\n\t}\n\tdstlen = (srclen + 3) / 4 * 3;  /* upper limit, assuming no whitespace etc */\n\tdst = (duk_uint8_t *) duk_push_dynamic_buffer(ctx, dstlen);\n\t/* Note: for dstlen=0, dst may be NULL */\n\n\tretval = duk__base64_decode_helper((const duk_uint8_t *) src, srclen, dst, &dst_final);\n\tif (!retval) {\n\t\tgoto type_error;\n\t}\n\n\t/* XXX: convert to fixed buffer? */\n\t(void) duk_resize_buffer(ctx, -1, (duk_size_t) (dst_final - dst));\n\tduk_replace(ctx, idx);\n\treturn;\n\n type_error:\n\tDUK_ERROR_TYPE(thr, DUK_STR_DECODE_FAILED);\n}\n\nDUK_EXTERNAL const char *duk_hex_encode(duk_context *ctx, duk_idx_t idx) {\n\tconst duk_uint8_t *inp;\n\tduk_size_t len;\n\tduk_size_t i;\n\tduk_uint8_t *buf;\n\tconst char *ret;\n#if defined(DUK_USE_HEX_FASTPATH)\n\tduk_size_t len_safe;\n\tduk_uint16_t *p16;\n#endif\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tidx = duk_require_normalize_index(ctx, idx);\n\tinp = duk__prep_codec_arg(ctx, idx, &len);\n\tDUK_ASSERT(inp != NULL || len == 0);\n\n\t/* Fixed buffer, no zeroing because we'll fill all the data. */\n\tbuf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(ctx, len * 2);\n\tDUK_ASSERT(buf != NULL);\n\n#if defined(DUK_USE_HEX_FASTPATH)\n\tDUK_ASSERT((((duk_size_t) buf) & 0x01U) == 0);   /* pointer is aligned, guaranteed for fixed buffer */\n\tp16 = (duk_uint16_t *) (void *) buf;\n\tlen_safe = len & ~0x03U;\n\tfor (i = 0; i < len_safe; i += 4) {\n\t\tp16[0] = duk_hex_enctab[inp[i]];\n\t\tp16[1] = duk_hex_enctab[inp[i + 1]];\n\t\tp16[2] = duk_hex_enctab[inp[i + 2]];\n\t\tp16[3] = duk_hex_enctab[inp[i + 3]];\n\t\tp16 += 4;\n\t}\n\tfor (; i < len; i++) {\n\t\t*p16++ = duk_hex_enctab[inp[i]];\n\t}\n#else  /* DUK_USE_HEX_FASTPATH */\n\tfor (i = 0; i < len; i++) {\n\t\tduk_small_uint_t t;\n\t\tt = (duk_small_uint_t) inp[i];\n\t\tbuf[i*2 + 0] = duk_lc_digits[t >> 4];\n\t\tbuf[i*2 + 1] = duk_lc_digits[t & 0x0f];\n\t}\n#endif  /* DUK_USE_HEX_FASTPATH */\n\n\t/* XXX: Using a string return value forces a string intern which is\n\t * not always necessary.  As a rough performance measure, hex encode\n\t * time for tests/perf/test-hex-encode.js dropped from ~35s to ~15s\n\t * without string coercion.  Change to returning a buffer and let the\n\t * caller coerce to string if necessary?\n\t */\n\n\tret = duk_buffer_to_string(ctx, -1);  /* Safe, result is ASCII. */\n\tduk_replace(ctx, idx);\n\treturn ret;\n}\n\nDUK_EXTERNAL void duk_hex_decode(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tconst duk_uint8_t *inp;\n\tduk_size_t len;\n\tduk_size_t i;\n\tduk_int_t t;\n\tduk_uint8_t *buf;\n#if defined(DUK_USE_HEX_FASTPATH)\n\tduk_int_t chk;\n\tduk_uint8_t *p;\n\tduk_size_t len_safe;\n#endif\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tidx = duk_require_normalize_index(ctx, idx);\n\tinp = duk__prep_codec_arg(ctx, idx, &len);\n\tDUK_ASSERT(inp != NULL || len == 0);\n\n\tif (len & 0x01) {\n\t\tgoto type_error;\n\t}\n\n\t/* Fixed buffer, no zeroing because we'll fill all the data. */\n\tbuf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(ctx, len / 2);\n\tDUK_ASSERT(buf != NULL);\n\n#if defined(DUK_USE_HEX_FASTPATH)\n\tp = buf;\n\tlen_safe = len & ~0x07U;\n\tfor (i = 0; i < len_safe; i += 8) {\n\t\tt = ((duk_int_t) duk_hex_dectab_shift4[inp[i]]) |\n\t\t    ((duk_int_t) duk_hex_dectab[inp[i + 1]]);\n\t\tchk = t;\n\t\tp[0] = (duk_uint8_t) t;\n\t\tt = ((duk_int_t) duk_hex_dectab_shift4[inp[i + 2]]) |\n\t\t    ((duk_int_t) duk_hex_dectab[inp[i + 3]]);\n\t\tchk |= t;\n\t\tp[1] = (duk_uint8_t) t;\n\t\tt = ((duk_int_t) duk_hex_dectab_shift4[inp[i + 4]]) |\n\t\t    ((duk_int_t) duk_hex_dectab[inp[i + 5]]);\n\t\tchk |= t;\n\t\tp[2] = (duk_uint8_t) t;\n\t\tt = ((duk_int_t) duk_hex_dectab_shift4[inp[i + 6]]) |\n\t\t    ((duk_int_t) duk_hex_dectab[inp[i + 7]]);\n\t\tchk |= t;\n\t\tp[3] = (duk_uint8_t) t;\n\t\tp += 4;\n\n\t\t/* Check if any lookup above had a negative result. */\n\t\tif (DUK_UNLIKELY(chk < 0)) {\n\t\t\tgoto type_error;\n\t\t}\n\t}\n\tfor (; i < len; i += 2) {\n\t\tt = (((duk_int_t) duk_hex_dectab[inp[i]]) << 4) |\n\t\t    ((duk_int_t) duk_hex_dectab[inp[i + 1]]);\n\t\tif (DUK_UNLIKELY(t < 0)) {\n\t\t\tgoto type_error;\n\t\t}\n\t\t*p++ = (duk_uint8_t) t;\n\t}\n#else  /* DUK_USE_HEX_FASTPATH */\n\tfor (i = 0; i < len; i += 2) {\n\t\t/* For invalid characters the value -1 gets extended to\n\t\t * at least 16 bits.  If either nybble is invalid, the\n\t\t * resulting 't' will be < 0.\n\t\t */\n\t\tt = (((duk_int_t) duk_hex_dectab[inp[i]]) << 4) |\n\t\t    ((duk_int_t) duk_hex_dectab[inp[i + 1]]);\n\t\tif (DUK_UNLIKELY(t < 0)) {\n\t\t\tgoto type_error;\n\t\t}\n\t\tbuf[i >> 1] = (duk_uint8_t) t;\n\t}\n#endif  /* DUK_USE_HEX_FASTPATH */\n\n\tduk_replace(ctx, idx);\n\treturn;\n\n type_error:\n\tDUK_ERROR_TYPE(thr, DUK_STR_DECODE_FAILED);\n}\n\n#if defined(DUK_USE_JSON_SUPPORT)\nDUK_EXTERNAL const char *duk_json_encode(duk_context *ctx, duk_idx_t idx) {\n#if defined(DUK_USE_ASSERTIONS)\n\tduk_idx_t top_at_entry;\n#endif\n\tconst char *ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n#if defined(DUK_USE_ASSERTIONS)\n\ttop_at_entry = duk_get_top(ctx);\n#endif\n\n\tidx = duk_require_normalize_index(ctx, idx);\n\tduk_bi_json_stringify_helper(ctx,\n\t                             idx /*idx_value*/,\n\t                             DUK_INVALID_INDEX /*idx_replacer*/,\n\t                             DUK_INVALID_INDEX /*idx_space*/,\n\t                             0 /*flags*/);\n\tDUK_ASSERT(duk_is_string(ctx, -1));\n\tduk_replace(ctx, idx);\n\tret = duk_get_string(ctx, idx);\n\n\tDUK_ASSERT(duk_get_top(ctx) == top_at_entry);\n\n\treturn ret;\n}\n\nDUK_EXTERNAL void duk_json_decode(duk_context *ctx, duk_idx_t idx) {\n#if defined(DUK_USE_ASSERTIONS)\n\tduk_idx_t top_at_entry;\n#endif\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n#if defined(DUK_USE_ASSERTIONS)\n\ttop_at_entry = duk_get_top(ctx);\n#endif\n\n\tidx = duk_require_normalize_index(ctx, idx);\n\tduk_bi_json_parse_helper(ctx,\n\t                         idx /*idx_value*/,\n\t                         DUK_INVALID_INDEX /*idx_reviver*/,\n\t                         0 /*flags*/);\n\tduk_replace(ctx, idx);\n\n\tDUK_ASSERT(duk_get_top(ctx) == top_at_entry);\n}\n#else  /* DUK_USE_JSON_SUPPORT */\nDUK_EXTERNAL const char *duk_json_encode(duk_context *ctx, duk_idx_t idx) {\n\tDUK_UNREF(idx);\n\tDUK_ERROR_UNSUPPORTED((duk_hthread *) ctx);\n}\n\nDUK_EXTERNAL void duk_json_decode(duk_context *ctx, duk_idx_t idx) {\n\tDUK_UNREF(idx);\n\tDUK_ERROR_UNSUPPORTED((duk_hthread *) ctx);\n}\n#endif  /* DUK_USE_JSON_SUPPORT */\n/*\n *  Compilation and evaluation\n */\n\n/* #include duk_internal.h -> already included */\n\ntypedef struct duk__compile_raw_args duk__compile_raw_args;\nstruct duk__compile_raw_args {\n\tduk_size_t src_length;  /* should be first on 64-bit platforms */\n\tconst duk_uint8_t *src_buffer;\n\tduk_uint_t flags;\n};\n\n/* Eval is just a wrapper now. */\nDUK_EXTERNAL duk_int_t duk_eval_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags) {\n\tduk_int_t rc;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t/* Note: strictness is *not* inherited from the current Duktape/C.\n\t * This would be confusing because the current strictness state\n\t * depends on whether we're running inside a Duktape/C activation\n\t * (= strict mode) or outside of any activation (= non-strict mode).\n\t * See tests/api/test-eval-strictness.c for more discussion.\n\t */\n\n\t/* [ ... source? filename? ] (depends on flags) */\n\n\trc = duk_compile_raw(ctx, src_buffer, src_length, flags | DUK_COMPILE_EVAL);  /* may be safe, or non-safe depending on flags */\n\n\t/* [ ... closure/error ] */\n\n\tif (rc != DUK_EXEC_SUCCESS) {\n\t\trc = DUK_EXEC_ERROR;\n\t\tgoto got_rc;\n\t}\n\n\tduk_push_global_object(ctx);  /* explicit 'this' binding, see GH-164 */\n\n\tif (flags & DUK_COMPILE_SAFE) {\n\t\trc = duk_pcall_method(ctx, 0);\n\t} else {\n\t\tduk_call_method(ctx, 0);\n\t\trc = DUK_EXEC_SUCCESS;\n\t}\n\n\t/* [ ... result/error ] */\n\n got_rc:\n\tif (flags & DUK_COMPILE_NORESULT) {\n\t\tduk_pop(ctx);\n\t}\n\n\treturn rc;\n}\n\n/* Helper which can be called both directly and with duk_safe_call(). */\nDUK_LOCAL duk_ret_t duk__do_compile(duk_context *ctx, void *udata) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk__compile_raw_args *comp_args;\n\tduk_uint_t flags;\n\tduk_hcompfunc *h_templ;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(udata != NULL);\n\n\t/* Note: strictness is not inherited from the current Duktape/C\n\t * context.  Otherwise it would not be possible to compile\n\t * non-strict code inside a Duktape/C activation (which is\n\t * always strict now).  See tests/api/test-eval-strictness.c\n\t * for discussion.\n\t */\n\n\t/* [ ... source? filename? ] (depends on flags) */\n\n\tcomp_args = (duk__compile_raw_args *) udata;\n\tflags = comp_args->flags;\n\n\tif (flags & DUK_COMPILE_NOFILENAME) {\n\t\t/* Automatic filename: 'eval' or 'input'. */\n\t\tduk_push_hstring_stridx(ctx, (flags & DUK_COMPILE_EVAL) ? DUK_STRIDX_EVAL : DUK_STRIDX_INPUT);\n\t}\n\n\t/* [ ... source? filename ] */\n\n\tif (!comp_args->src_buffer) {\n\t\tduk_hstring *h_sourcecode;\n\n\t\th_sourcecode = duk_get_hstring(ctx, -2);\n\t\tif ((flags & DUK_COMPILE_NOSOURCE) ||  /* args incorrect */\n\t\t    (h_sourcecode == NULL)) {          /* e.g. duk_push_string_file_raw() pushed undefined */\n\t\t\tDUK_ERROR_TYPE(thr, DUK_STR_NO_SOURCECODE);\n\t\t}\n\t\tDUK_ASSERT(h_sourcecode != NULL);\n\t\tcomp_args->src_buffer = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_sourcecode);\n\t\tcomp_args->src_length = (duk_size_t) DUK_HSTRING_GET_BYTELEN(h_sourcecode);\n\t}\n\tDUK_ASSERT(comp_args->src_buffer != NULL);\n\n\tif (flags & DUK_COMPILE_FUNCTION) {\n\t\tflags |= DUK_COMPILE_EVAL | DUK_COMPILE_FUNCEXPR;\n\t}\n\n\t/* [ ... source? filename ] */\n\n\tduk_js_compile(thr, comp_args->src_buffer, comp_args->src_length, flags);\n\n\t/* [ ... source? func_template ] */\n\n\tif (flags & DUK_COMPILE_NOSOURCE) {\n\t\t;\n\t} else {\n\t\tduk_remove_m2(ctx);\n\t}\n\n\t/* [ ... func_template ] */\n\n\th_templ = (duk_hcompfunc *) duk_known_hobject(ctx, -1);\n\tduk_js_push_closure(thr,\n\t                   h_templ,\n\t                   thr->builtins[DUK_BIDX_GLOBAL_ENV],\n\t                   thr->builtins[DUK_BIDX_GLOBAL_ENV],\n\t                   1 /*add_auto_proto*/);\n\tduk_remove_m2(ctx);   /* -> [ ... closure ] */\n\n\t/* [ ... closure ] */\n\n\treturn 1;\n}\n\nDUK_EXTERNAL duk_int_t duk_compile_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags) {\n\tduk__compile_raw_args comp_args_alloc;\n\tduk__compile_raw_args *comp_args = &comp_args_alloc;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tif ((flags & DUK_COMPILE_STRLEN) && (src_buffer != NULL)) {\n\t\t/* String length is computed here to avoid multiple evaluation\n\t\t * of a macro argument in the calling side.\n\t\t */\n\t\tsrc_length = DUK_STRLEN(src_buffer);\n\t}\n\n\tcomp_args->src_buffer = (const duk_uint8_t *) src_buffer;\n\tcomp_args->src_length = src_length;\n\tcomp_args->flags = flags;\n\n\t/* [ ... source? filename? ] (depends on flags) */\n\n\tif (flags & DUK_COMPILE_SAFE) {\n\t\tduk_int_t rc;\n\t\tduk_int_t nargs;\n\t\tduk_int_t nrets = 1;\n\n\t\t/* Arguments can be: [ source? filename? &comp_args] so that\n\t\t * nargs is 1 to 3.  Call site encodes the correct nargs count\n\t\t * directly into flags.\n\t\t */\n\t\tnargs = flags & 0x07;\n\t\tDUK_ASSERT(nargs == ((flags & DUK_COMPILE_NOSOURCE) ? 0 : 1) +\n\t\t                    ((flags & DUK_COMPILE_NOFILENAME) ? 0 : 1));\n\t\trc = duk_safe_call(ctx, duk__do_compile, (void *) comp_args, nargs, nrets);\n\n\t\t/* [ ... closure ] */\n\t\treturn rc;\n\t}\n\n\t(void) duk__do_compile(ctx, (void *) comp_args);\n\n\t/* [ ... closure ] */\n\treturn DUK_EXEC_SUCCESS;\n}\n/*\n *  Debugging related API calls\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_JSON_SUPPORT)\nDUK_EXTERNAL void duk_push_context_dump(duk_context *ctx) {\n\tduk_idx_t idx;\n\tduk_idx_t top;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t/* We don't duk_require_stack() here now, but rely on the caller having\n\t * enough space.\n\t */\n\n\ttop = duk_get_top(ctx);\n\tduk_push_array(ctx);\n\tfor (idx = 0; idx < top; idx++) {\n\t\tduk_dup(ctx, idx);\n\t\tduk_put_prop_index(ctx, -2, idx);\n\t}\n\n\t/* XXX: conversion errors should not propagate outwards.\n\t * Perhaps values need to be coerced individually?\n\t */\n\tduk_bi_json_stringify_helper(ctx,\n\t                             duk_get_top_index(ctx),  /*idx_value*/\n\t                             DUK_INVALID_INDEX,  /*idx_replacer*/\n\t                             DUK_INVALID_INDEX,  /*idx_space*/\n\t                             DUK_JSON_FLAG_EXT_CUSTOM |\n\t                             DUK_JSON_FLAG_ASCII_ONLY |\n\t                             DUK_JSON_FLAG_AVOID_KEY_QUOTES /*flags*/);\n\n\tduk_push_sprintf(ctx, \"ctx: top=%ld, stack=%s\", (long) top, (const char *) duk_safe_to_string(ctx, -1));\n\tduk_replace(ctx, -3);  /* [ ... arr jsonx(arr) res ] -> [ ... res jsonx(arr) ] */\n\tduk_pop(ctx);\n\tDUK_ASSERT(duk_is_string(ctx, -1));\n}\n#else  /* DUK_USE_JSON_SUPPORT */\nDUK_EXTERNAL void duk_push_context_dump(duk_context *ctx) {\n\tDUK_ERROR_UNSUPPORTED((duk_hthread *) ctx);\n}\n#endif  /* DUK_USE_JSON_SUPPORT */\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\nDUK_EXTERNAL void duk_debugger_attach(duk_context *ctx,\n                                      duk_debug_read_function read_cb,\n                                      duk_debug_write_function write_cb,\n                                      duk_debug_peek_function peek_cb,\n                                      duk_debug_read_flush_function read_flush_cb,\n                                      duk_debug_write_flush_function write_flush_cb,\n                                      duk_debug_request_function request_cb,\n                                      duk_debug_detached_function detached_cb,\n                                      void *udata) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_heap *heap;\n\tconst char *str;\n\tduk_size_t len;\n\n\t/* XXX: should there be an error or an automatic detach if\n\t * already attached?\n\t */\n\n\tDUK_D(DUK_DPRINT(\"application called duk_debugger_attach()\"));\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(read_cb != NULL);\n\tDUK_ASSERT(write_cb != NULL);\n\t/* Other callbacks are optional. */\n\n\theap = thr->heap;\n\theap->dbg_read_cb = read_cb;\n\theap->dbg_write_cb = write_cb;\n\theap->dbg_peek_cb = peek_cb;\n\theap->dbg_read_flush_cb = read_flush_cb;\n\theap->dbg_write_flush_cb = write_flush_cb;\n\theap->dbg_request_cb = request_cb;\n\theap->dbg_detached_cb = detached_cb;\n\theap->dbg_udata = udata;\n\theap->dbg_have_next_byte = 0;\n\n\t/* Start in paused state. */\n\theap->dbg_processing = 0;\n\theap->dbg_state_dirty = 0;\n\theap->dbg_force_restart = 0;\n\theap->dbg_step_type = DUK_STEP_TYPE_NONE;\n\theap->dbg_step_thread = NULL;\n\theap->dbg_step_csindex = 0;\n\theap->dbg_step_startline = 0;\n\theap->dbg_exec_counter = 0;\n\theap->dbg_last_counter = 0;\n\theap->dbg_last_time = 0.0;\n\tduk_debug_set_paused(heap);  /* XXX: overlap with fields above */\n\n\t/* Send version identification and flush right afterwards.  Note that\n\t * we must write raw, unframed bytes here.\n\t */\n\tduk_push_sprintf(ctx, \"%ld %ld %s %s\\n\",\n\t                 (long) DUK_DEBUG_PROTOCOL_VERSION,\n\t                 (long) DUK_VERSION,\n\t                 (const char *) DUK_GIT_DESCRIBE,\n\t                 (const char *) DUK_USE_TARGET_INFO);\n\tstr = duk_get_lstring(ctx, -1, &len);\n\tDUK_ASSERT(str != NULL);\n\tduk_debug_write_bytes(thr, (const duk_uint8_t *) str, len);\n\tduk_debug_write_flush(thr);\n\tduk_pop(ctx);\n}\n\nDUK_EXTERNAL void duk_debugger_detach(duk_context *ctx) {\n\tduk_hthread *thr;\n\n\tDUK_D(DUK_DPRINT(\"application called duk_debugger_detach()\"));\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\n\t/* Can be called multiple times with no harm. */\n\tduk_debug_do_detach(thr->heap);\n}\n\nDUK_EXTERNAL void duk_debugger_cooperate(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_bool_t processed_messages;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\n\tif (!duk_debug_is_attached(thr->heap)) {\n\t\treturn;\n\t}\n\tif (thr->callstack_top > 0 || thr->heap->dbg_processing) {\n\t\t/* Calling duk_debugger_cooperate() while Duktape is being\n\t\t * called into is not supported.  This is not a 100% check\n\t\t * but prevents any damage in most cases.\n\t\t */\n\t\treturn;\n\t}\n\n\tprocessed_messages = duk_debug_process_messages(thr, 1 /*no_block*/);\n\tDUK_UNREF(processed_messages);\n}\n\nDUK_EXTERNAL duk_bool_t duk_debugger_notify(duk_context *ctx, duk_idx_t nvalues) {\n\tduk_hthread *thr;\n\tduk_idx_t top;\n\tduk_idx_t idx;\n\tduk_bool_t ret = 0;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\n\tDUK_D(DUK_DPRINT(\"application called duk_debugger_notify() with nvalues=%ld\", (long) nvalues));\n\n\ttop = duk_get_top(ctx);\n\tif (top < nvalues) {\n\t\tDUK_ERROR_RANGE(thr, \"not enough stack values for notify\");\n\t\treturn ret;  /* unreachable */\n\t}\n\tif (duk_debug_is_attached(thr->heap)) {\n\t\tduk_debug_write_notify(thr, DUK_DBG_CMD_APPNOTIFY);\n\t\tfor (idx = top - nvalues; idx < top; idx++) {\n\t\t\tduk_tval *tv = DUK_GET_TVAL_POSIDX(ctx, idx);\n\t\t\tduk_debug_write_tval(thr, tv);\n\t\t}\n\t\tduk_debug_write_eom(thr);\n\n\t\t/* Return non-zero (true) if we have a good reason to believe\n\t\t * the notify was delivered; if we're still attached at least\n\t\t * a transport error was not indicated by the transport write\n\t\t * callback.  This is not a 100% guarantee of course.\n\t\t */\n\t\tif (duk_debug_is_attached(thr->heap)) {\n\t\t\tret = 1;\n\t\t}\n\t}\n\tduk_pop_n(ctx, nvalues);\n\treturn ret;\n}\n\nDUK_EXTERNAL void duk_debugger_pause(duk_context *ctx) {\n\tduk_hthread *thr;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\n\tDUK_D(DUK_DPRINT(\"application called duk_debugger_pause()\"));\n\n\t/* Treat like a debugger statement: ignore when not attached. */\n\tif (duk_debug_is_attached(thr->heap)) {\n\t\tif (duk_debug_is_paused(thr->heap)) {\n\t\t\tDUK_D(DUK_DPRINT(\"duk_debugger_pause() called when already paused; ignoring\"));\n\t\t} else {\n\t\t\tduk_debug_set_paused(thr->heap);\n\n\t\t\t/* Pause on the next opcode executed.  This is always safe to do even\n\t\t\t * inside the debugger message loop: the interrupt counter will be reset\n\t\t\t * to its proper value when the message loop exits.\n\t\t\t */\n\t\t\tthr->interrupt_init = 1;\n\t\t\tthr->interrupt_counter = 0;\n\t\t}\n\t}\n}\n\n#else  /* DUK_USE_DEBUGGER_SUPPORT */\n\nDUK_EXTERNAL void duk_debugger_attach(duk_context *ctx,\n                                      duk_debug_read_function read_cb,\n                                      duk_debug_write_function write_cb,\n                                      duk_debug_peek_function peek_cb,\n                                      duk_debug_read_flush_function read_flush_cb,\n                                      duk_debug_write_flush_function write_flush_cb,\n                                      duk_debug_request_function request_cb,\n                                      duk_debug_detached_function detached_cb,\n                                      void *udata) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_UNREF(read_cb);\n\tDUK_UNREF(write_cb);\n\tDUK_UNREF(peek_cb);\n\tDUK_UNREF(read_flush_cb);\n\tDUK_UNREF(write_flush_cb);\n\tDUK_UNREF(request_cb);\n\tDUK_UNREF(detached_cb);\n\tDUK_UNREF(udata);\n\tDUK_ERROR_TYPE((duk_hthread *) ctx, \"no debugger support\");\n}\n\nDUK_EXTERNAL void duk_debugger_detach(duk_context *ctx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ERROR_TYPE((duk_hthread *) ctx, \"no debugger support\");\n}\n\nDUK_EXTERNAL void duk_debugger_cooperate(duk_context *ctx) {\n\t/* nop */\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_UNREF(ctx);\n}\n\nDUK_EXTERNAL duk_bool_t duk_debugger_notify(duk_context *ctx, duk_idx_t nvalues) {\n\tduk_idx_t top;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttop = duk_get_top(ctx);\n\tif (top < nvalues) {\n\t\tDUK_ERROR_RANGE_INVALID_COUNT((duk_hthread *) ctx);\n\t\treturn 0;  /* unreachable */\n\t}\n\n\t/* No debugger support, just pop values. */\n\tduk_pop_n(ctx, nvalues);\n\treturn 0;\n}\n\nDUK_EXTERNAL void duk_debugger_pause(duk_context *ctx) {\n\t/* Treat like debugger statement: nop */\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_UNREF(ctx);\n}\n\n#endif  /* DUK_USE_DEBUGGER_SUPPORT */\n/*\n *  Heap creation and destruction\n */\n\n/* #include duk_internal.h -> already included */\n\ntypedef struct duk_internal_thread_state duk_internal_thread_state;\n\nstruct duk_internal_thread_state {\n\tduk_ljstate lj;\n\tduk_bool_t creating_error;\n\tduk_hthread *curr_thread;\n\tduk_int_t call_recursion_depth;\n};\n\nDUK_EXTERNAL\nduk_context *duk_create_heap(duk_alloc_function alloc_func,\n                             duk_realloc_function realloc_func,\n                             duk_free_function free_func,\n                             void *heap_udata,\n                             duk_fatal_function fatal_handler) {\n\tduk_heap *heap = NULL;\n\tduk_context *ctx;\n\n\t/* Assume that either all memory funcs are NULL or non-NULL, mixed\n\t * cases will now be unsafe.\n\t */\n\n\t/* XXX: just assert non-NULL values here and make caller arguments\n\t * do the defaulting to the default implementations (smaller code)?\n\t */\n\n\tif (!alloc_func) {\n\t\tDUK_ASSERT(realloc_func == NULL);\n\t\tDUK_ASSERT(free_func == NULL);\n#if defined(DUK_USE_PROVIDE_DEFAULT_ALLOC_FUNCTIONS)\n\t\talloc_func = duk_default_alloc_function;\n\t\trealloc_func = duk_default_realloc_function;\n\t\tfree_func = duk_default_free_function;\n#else\n\t\tDUK_D(DUK_DPRINT(\"no allocation functions given and no default providers\"));\n\t\treturn NULL;\n#endif\n\t} else {\n\t\tDUK_ASSERT(realloc_func != NULL);\n\t\tDUK_ASSERT(free_func != NULL);\n\t}\n\n\tif (!fatal_handler) {\n\t\tfatal_handler = duk_default_fatal_handler;\n\t}\n\n\tDUK_ASSERT(alloc_func != NULL);\n\tDUK_ASSERT(realloc_func != NULL);\n\tDUK_ASSERT(free_func != NULL);\n\tDUK_ASSERT(fatal_handler != NULL);\n\n\theap = duk_heap_alloc(alloc_func, realloc_func, free_func, heap_udata, fatal_handler);\n\tif (!heap) {\n\t\treturn NULL;\n\t}\n\tctx = (duk_context *) heap->heap_thread;\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(((duk_hthread *) ctx)->heap != NULL);\n\treturn ctx;\n}\n\nDUK_EXTERNAL void duk_destroy_heap(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_heap *heap;\n\n\tif (!ctx) {\n\t\treturn;\n\t}\n\theap = thr->heap;\n\tDUK_ASSERT(heap != NULL);\n\n\tduk_heap_free(heap);\n}\n\nDUK_EXTERNAL void duk_suspend(duk_context *ctx, duk_thread_state *state) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_internal_thread_state *snapshot = (duk_internal_thread_state *) (void *) state;\n\tduk_heap *heap;\n\tduk_ljstate *lj;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\tDUK_ASSERT(state != NULL);  /* unvalidated */\n\n\t/* Currently not supported when called from within a finalizer.\n\t * If that is done, the finalizer will remain running indefinitely,\n\t * preventing other finalizers from executing.  The assert is a bit\n\t * wider, checking that it would be OK to run pending finalizers.\n\t */\n\tDUK_ASSERT(thr->heap->pf_prevent_count == 0);\n\n\t/* Currently not supported to duk_suspend() from an errCreate()\n\t * call.\n\t */\n\tDUK_ASSERT(thr->heap->creating_error == 0);\n\n\theap = thr->heap;\n\tlj = &heap->lj;\n\n\tduk_push_tval(ctx, &lj->value1);\n\tduk_push_tval(ctx, &lj->value2);\n\n\t/* XXX: creating_error == 0 is asserted above, so no need to store. */\n\tDUK_MEMCPY((void *) &snapshot->lj, (const void *) lj, sizeof(duk_ljstate));\n\tsnapshot->creating_error = heap->creating_error;\n\tsnapshot->curr_thread = heap->curr_thread;\n\tsnapshot->call_recursion_depth = heap->call_recursion_depth;\n\n\tlj->jmpbuf_ptr = NULL;\n\tlj->type = DUK_LJ_TYPE_UNKNOWN;\n\tDUK_TVAL_SET_UNDEFINED(&lj->value1);\n\tDUK_TVAL_SET_UNDEFINED(&lj->value2);\n\theap->creating_error = 0;\n\theap->curr_thread = NULL;\n\theap->call_recursion_depth = 0;\n}\n\nDUK_EXTERNAL void duk_resume(duk_context *ctx, const duk_thread_state *state) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tconst duk_internal_thread_state *snapshot = (const duk_internal_thread_state *) (const void *) state;\n\tduk_heap *heap;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\tDUK_ASSERT(state != NULL);  /* unvalidated */\n\n\t/* Shouldn't be necessary if duk_suspend() is called before\n\t * duk_resume(), but assert in case API sequence is incorrect.\n\t */\n\tDUK_ASSERT(thr->heap->pf_prevent_count == 0);\n\tDUK_ASSERT(thr->heap->creating_error == 0);\n\n\theap = thr->heap;\n\n\tDUK_MEMCPY((void *) &heap->lj, (const void *) &snapshot->lj, sizeof(duk_ljstate));\n\theap->creating_error = snapshot->creating_error;\n\theap->curr_thread = snapshot->curr_thread;\n\theap->call_recursion_depth = snapshot->call_recursion_depth;\n\n\tduk_pop_2(ctx);\n}\n\n/* XXX: better place for this */\nDUK_EXTERNAL void duk_set_global_object(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *h_glob;\n\tduk_hobject *h_prev_glob;\n\tduk_hobjenv *h_env;\n\tduk_hobject *h_prev_env;\n\n\tDUK_D(DUK_DPRINT(\"replace global object with: %!T\", duk_get_tval(ctx, -1)));\n\n\th_glob = duk_require_hobject(ctx, -1);\n\tDUK_ASSERT(h_glob != NULL);\n\n\t/*\n\t *  Replace global object.\n\t */\n\n\th_prev_glob = thr->builtins[DUK_BIDX_GLOBAL];\n\tDUK_UNREF(h_prev_glob);\n\tthr->builtins[DUK_BIDX_GLOBAL] = h_glob;\n\tDUK_HOBJECT_INCREF(thr, h_glob);\n\tDUK_HOBJECT_DECREF_ALLOWNULL(thr, h_prev_glob);  /* side effects, in theory (referenced by global env) */\n\n\t/*\n\t *  Replace lexical environment for global scope\n\t *\n\t *  Create a new object environment for the global lexical scope.\n\t *  We can't just reset the _Target property of the current one,\n\t *  because the lexical scope is shared by other threads with the\n\t *  same (initial) built-ins.\n\t */\n\n\th_env = duk_hobjenv_alloc(thr,\n\t                          DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                          DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_OBJENV));\n\tDUK_ASSERT(h_env != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_GET_PROTOTYPE(thr->heap, (duk_hobject *) h_env) == NULL);\n\n\tDUK_ASSERT(h_env->target == NULL);\n\tDUK_ASSERT(h_glob != NULL);\n\th_env->target = h_glob;\n\tDUK_HOBJECT_INCREF(thr, h_glob);\n\tDUK_ASSERT(h_env->has_this == 0);\n\n\t/* [ ... new_glob ] */\n\n\th_prev_env = thr->builtins[DUK_BIDX_GLOBAL_ENV];\n\tthr->builtins[DUK_BIDX_GLOBAL_ENV] = (duk_hobject *) h_env;\n\tDUK_HOBJECT_INCREF(thr, (duk_hobject *) h_env);\n\tDUK_HOBJECT_DECREF_ALLOWNULL(thr, h_prev_env);  /* side effects */\n\tDUK_UNREF(h_env);  /* without refcounts */\n\tDUK_UNREF(h_prev_env);\n\n\t/* [ ... new_glob ] */\n\n\tduk_pop(ctx);\n\n\t/* [ ... ] */\n}\n/*\n *  Inspection\n */\n\n/* #include duk_internal.h -> already included */\n\n/* For footprint efficient multiple value setting: arrays are much better than\n * varargs, format string with parsing is often better than string pointer arrays.\n */\nDUK_LOCAL void duk__inspect_multiple_uint(duk_context *ctx, const char *fmt, duk_int_t *vals) {\n\tduk_int_t val;\n\tconst char *p;\n\tconst char *p_curr;\n\tduk_size_t len;\n\n\tfor (p = fmt;;) {\n\t\tlen = DUK_STRLEN(p);\n\t\tp_curr = p;\n\t\tp += len + 1;\n\t\tif (len == 0) {\n\t\t\t/* Double NUL (= empty key) terminates. */\n\t\t\tbreak;\n\t\t}\n\t\tval = *vals++;\n\t\tif (val >= 0) {\n\t\t\t/* Negative values are markers to skip key. */\n\t\t\tduk_push_string(ctx, p_curr);\n\t\t\tduk_push_uint(ctx, val);\n\t\t\tduk_put_prop(ctx, -3);\n\t\t}\n\t}\n}\n\n/* Raw helper to extract internal information / statistics about a value.\n * The return value is an object with properties that are version specific.\n * The properties must not expose anything that would lead to security\n * issues (e.g. exposing compiled function 'data' buffer might be an issue).\n * Currently only counts and sizes and such are given so there shouldn't\n * be security implications.\n */\n\n#define DUK__IDX_TYPE     0\n#define DUK__IDX_ITAG     1\n#define DUK__IDX_REFC     2\n#define DUK__IDX_HBYTES   3\n#define DUK__IDX_CLASS    4\n#define DUK__IDX_PBYTES   5\n#define DUK__IDX_ESIZE    6\n#define DUK__IDX_ENEXT    7\n#define DUK__IDX_ASIZE    8\n#define DUK__IDX_HSIZE    9\n#define DUK__IDX_BCBYTES  10\n#define DUK__IDX_DBYTES   11\n#define DUK__IDX_TSTATE   12\n#define DUK__IDX_VARIANT  13\n\nDUK_EXTERNAL void duk_inspect_value(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\tduk_heaphdr *h;\n\t/* The temporary values should be in an array rather than individual\n\t * variables which (in practice) ensures that the compiler won't map\n\t * them to registers and emit a lot of unnecessary shuffling code.\n\t */\n\tduk_int_t vals[14];\n\n\tDUK_UNREF(thr);\n\n\t/* Assume two's complement and set everything to -1. */\n\tDUK_MEMSET((void *) &vals, (int) 0xff, sizeof(vals));\n\tDUK_ASSERT(vals[DUK__IDX_TYPE] == -1);  /* spot check one */\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\th = (DUK_TVAL_IS_HEAP_ALLOCATED(tv) ? DUK_TVAL_GET_HEAPHDR(tv) : NULL);\n\n\tvals[DUK__IDX_TYPE] = duk_get_type_tval(tv);\n\tvals[DUK__IDX_ITAG] = (duk_uint_t) DUK_TVAL_GET_TAG(tv);\n\n\tduk_push_bare_object(ctx);  /* Invalidates 'tv'. */\n\ttv = NULL;\n\n\tif (h == NULL) {\n\t\tgoto finish;\n\t}\n\tduk_push_pointer(ctx, (void *) h);\n\tduk_put_prop_string(ctx, -2, \"hptr\");\n\n#if 0\n\t/* Covers a lot of information, e.g. buffer and string variants. */\n\tduk_push_uint(ctx, (duk_uint_t) DUK_HEAPHDR_GET_FLAGS(h));\n\tduk_put_prop_string(ctx, -2, \"hflags\");\n#endif\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tvals[DUK__IDX_REFC] = (duk_int_t) DUK_HEAPHDR_GET_REFCOUNT(h);\n#endif\n\tvals[DUK__IDX_VARIANT] = 0;\n\n\t/* Heaphdr size and additional allocation size, followed by\n\t * type specific stuff (with varying value count).\n\t */\n\tswitch ((duk_small_int_t) DUK_HEAPHDR_GET_TYPE(h)) {\n\tcase DUK_HTYPE_STRING: {\n\t\tduk_hstring *h_str = (duk_hstring *) h;\n\t\tvals[DUK__IDX_HBYTES] = (duk_int_t) (sizeof(duk_hstring) + DUK_HSTRING_GET_BYTELEN(h_str) + 1);\n#if defined(DUK_USE_HSTRING_EXTDATA)\n\t\tif (DUK_HSTRING_HAS_EXTDATA(h_str)) {\n\t\t\tvals[DUK__IDX_VARIANT] = 1;\n\t\t}\n#endif\n\t\tbreak;\n\t}\n\tcase DUK_HTYPE_OBJECT: {\n\t\tduk_hobject *h_obj = (duk_hobject *) h;\n\n\t\t/* XXX: variants here are maybe pointless; class is enough? */\n\t\tif (DUK_HOBJECT_IS_ARRAY(h_obj)) {\n\t\t\tvals[DUK__IDX_HBYTES] = sizeof(duk_harray);\n\t\t} else if (DUK_HOBJECT_IS_COMPFUNC(h_obj)) {\n\t\t\tvals[DUK__IDX_HBYTES] = sizeof(duk_hcompfunc);\n\t\t} else if (DUK_HOBJECT_IS_NATFUNC(h_obj)) {\n\t\t\tvals[DUK__IDX_HBYTES] = sizeof(duk_hnatfunc);\n\t\t} else if (DUK_HOBJECT_IS_THREAD(h_obj)) {\n\t\t\tvals[DUK__IDX_HBYTES] = sizeof(duk_hthread);\n\t\t\tvals[DUK__IDX_TSTATE] = ((duk_hthread *) h_obj)->state;\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n\t\t} else if (DUK_HOBJECT_IS_BUFOBJ(h_obj)) {\n\t\t\tvals[DUK__IDX_HBYTES] = sizeof(duk_hbufobj);\n\t\t\t/* XXX: some size information */\n#endif\n\t\t} else {\n\t\t\tvals[DUK__IDX_HBYTES] = (duk_small_uint_t) sizeof(duk_hobject);\n\t\t}\n\n\t\tvals[DUK__IDX_CLASS] = (duk_int_t) DUK_HOBJECT_GET_CLASS_NUMBER(h_obj);\n\t\tvals[DUK__IDX_PBYTES] = (duk_int_t) DUK_HOBJECT_P_ALLOC_SIZE(h_obj),\n\t\tvals[DUK__IDX_ESIZE] = (duk_int_t) DUK_HOBJECT_GET_ESIZE(h_obj);\n\t\tvals[DUK__IDX_ENEXT] = (duk_int_t) DUK_HOBJECT_GET_ENEXT(h_obj);\n\t\tvals[DUK__IDX_ASIZE] = (duk_int_t) DUK_HOBJECT_GET_ASIZE(h_obj);\n\t\tvals[DUK__IDX_HSIZE] = (duk_int_t) DUK_HOBJECT_GET_HSIZE(h_obj);\n\n\t\t/* Note: e_next indicates the number of gc-reachable entries\n\t\t * in the entry part, and also indicates the index where the\n\t\t * next new property would be inserted.  It does *not* indicate\n\t\t * the number of non-NULL keys present in the object.  That\n\t\t * value could be counted separately but requires a pass through\n\t\t * the key list.\n\t\t */\n\n\t\tif (DUK_HOBJECT_IS_COMPFUNC(h_obj)) {\n\t\t\tduk_hbuffer *h_data = (duk_hbuffer *) DUK_HCOMPFUNC_GET_DATA(thr->heap, (duk_hcompfunc *) h_obj);\n\t\t\tvals[DUK__IDX_BCBYTES] = (duk_int_t) (h_data ? DUK_HBUFFER_GET_SIZE(h_data) : 0);\n\t\t}\n\t\tbreak;\n\t}\n\tcase DUK_HTYPE_BUFFER: {\n\t\tduk_hbuffer *h_buf = (duk_hbuffer *) h;\n\n\t\tif (DUK_HBUFFER_HAS_DYNAMIC(h_buf)) {\n\t\t\tif (DUK_HBUFFER_HAS_EXTERNAL(h_buf)) {\n\t\t\t\tvals[DUK__IDX_VARIANT] = 2;  /* buffer variant 2: external */\n\t\t\t\tvals[DUK__IDX_HBYTES] = (duk_uint_t) (sizeof(duk_hbuffer_external));\n\t\t\t} else {\n\t\t\t\t/* When alloc_size == 0 the second allocation may not\n\t\t\t\t * actually exist.\n\t\t\t\t */\n\t\t\t\tvals[DUK__IDX_VARIANT] = 1;  /* buffer variant 1: dynamic */\n\t\t\t\tvals[DUK__IDX_HBYTES] = (duk_uint_t) (sizeof(duk_hbuffer_dynamic));\n\t\t\t}\n\t\t\tvals[DUK__IDX_DBYTES] = (duk_uint_t) (DUK_HBUFFER_GET_SIZE(h_buf));\n\t\t} else {\n\t\t\tDUK_ASSERT(vals[DUK__IDX_VARIANT] == 0);  /* buffer variant 0: fixed */\n\t\t\tvals[DUK__IDX_HBYTES] = (duk_uint_t) (sizeof(duk_hbuffer_fixed) + DUK_HBUFFER_GET_SIZE(h_buf));\n\t\t}\n\t\tbreak;\n\t}\n\t}\n\n finish:\n\tduk__inspect_multiple_uint(ctx,\n\t    \"type\" \"\\x00\" \"itag\" \"\\x00\" \"refc\" \"\\x00\" \"hbytes\" \"\\x00\" \"class\" \"\\x00\"\n\t    \"pbytes\" \"\\x00\" \"esize\" \"\\x00\" \"enext\" \"\\x00\" \"asize\" \"\\x00\" \"hsize\" \"\\x00\"\n\t    \"bcbytes\" \"\\x00\" \"dbytes\" \"\\x00\" \"tstate\" \"\\x00\" \"variant\" \"\\x00\" \"\\x00\",\n\t    (duk_int_t *) &vals);\n}\n\nDUK_EXTERNAL void duk_inspect_callstack_entry(duk_context *ctx, duk_int_t level) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_activation *act;\n\tduk_uint_fast32_t pc;\n\tduk_uint_fast32_t line;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t/* -1             = top callstack entry, callstack[callstack_top - 1]\n\t * -callstack_top = bottom callstack entry, callstack[0]\n\t */\n\tif (level >= 0 || -level > (duk_int_t) thr->callstack_top) {\n\t\tduk_push_undefined(ctx);\n\t\treturn;\n\t}\n\tduk_push_bare_object(ctx);\n\tDUK_ASSERT(level >= -((duk_int_t) thr->callstack_top) && level <= -1);\n\n\tact = thr->callstack + thr->callstack_top + level;\n\t/* Relevant PC is just before current one because PC is\n\t * post-incremented.  This should match what error augment\n\t * code does.\n\t */\n\tpc = duk_hthread_get_act_prev_pc(thr, act);\n\n\tduk_push_tval(ctx, &act->tv_func);\n\n\tduk_push_uint(ctx, (duk_uint_t) pc);\n\tduk_put_prop_stridx_short(ctx, -3, DUK_STRIDX_PC);\n\n#if defined(DUK_USE_PC2LINE)\n\tline = duk_hobject_pc2line_query(ctx, -1, pc);\n#else\n\tline = 0;\n#endif\n\tduk_push_uint(ctx, (duk_uint_t) line);\n\tduk_put_prop_stridx_short(ctx, -3, DUK_STRIDX_LINE_NUMBER);\n\n\tduk_put_prop_stridx_short(ctx, -2, DUK_STRIDX_LC_FUNCTION);\n\t/* Providing access to e.g. act->lex_env would be dangerous: these\n\t * internal structures must never be accessible to the application.\n\t * Duktape relies on them having consistent data, and this consistency\n\t * is only asserted for, not checked for.\n\t */\n}\n\n/* automatic undefs */\n#undef DUK__IDX_ASIZE\n#undef DUK__IDX_BCBYTES\n#undef DUK__IDX_CLASS\n#undef DUK__IDX_DBYTES\n#undef DUK__IDX_ENEXT\n#undef DUK__IDX_ESIZE\n#undef DUK__IDX_HBYTES\n#undef DUK__IDX_HSIZE\n#undef DUK__IDX_ITAG\n#undef DUK__IDX_PBYTES\n#undef DUK__IDX_REFC\n#undef DUK__IDX_TSTATE\n#undef DUK__IDX_TYPE\n#undef DUK__IDX_VARIANT\n/*\n *  Memory calls.\n */\n\n/* #include duk_internal.h -> already included */\n\nDUK_EXTERNAL void *duk_alloc_raw(duk_context *ctx, duk_size_t size) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\treturn DUK_ALLOC_RAW(thr->heap, size);\n}\n\nDUK_EXTERNAL void duk_free_raw(duk_context *ctx, void *ptr) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tDUK_FREE_RAW(thr->heap, ptr);\n}\n\nDUK_EXTERNAL void *duk_realloc_raw(duk_context *ctx, void *ptr, duk_size_t size) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\treturn DUK_REALLOC_RAW(thr->heap, ptr, size);\n}\n\nDUK_EXTERNAL void *duk_alloc(duk_context *ctx, duk_size_t size) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\treturn DUK_ALLOC(thr->heap, size);\n}\n\nDUK_EXTERNAL void duk_free(duk_context *ctx, void *ptr) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tDUK_FREE(thr->heap, ptr);\n}\n\nDUK_EXTERNAL void *duk_realloc(duk_context *ctx, void *ptr, duk_size_t size) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t/*\n\t *  Note: since this is an exposed API call, there should be\n\t *  no way a mark-and-sweep could have a side effect on the\n\t *  memory allocation behind 'ptr'; the pointer should never\n\t *  be something that Duktape wants to change.\n\t *\n\t *  Thus, no need to use DUK_REALLOC_INDIRECT (and we don't\n\t *  have the storage location here anyway).\n\t */\n\n\treturn DUK_REALLOC(thr->heap, ptr, size);\n}\n\nDUK_EXTERNAL void duk_get_memory_functions(duk_context *ctx, duk_memory_functions *out_funcs) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_heap *heap;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(out_funcs != NULL);\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\n\theap = thr->heap;\n\tout_funcs->alloc_func = heap->alloc_func;\n\tout_funcs->realloc_func = heap->realloc_func;\n\tout_funcs->free_func = heap->free_func;\n\tout_funcs->udata = heap->heap_udata;\n}\n\nDUK_EXTERNAL void duk_gc(duk_context *ctx, duk_uint_t flags) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_heap *heap;\n\tduk_small_uint_t ms_flags;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\theap = thr->heap;\n\tDUK_ASSERT(heap != NULL);\n\n\tDUK_D(DUK_DPRINT(\"mark-and-sweep requested by application\"));\n\tDUK_ASSERT(DUK_GC_COMPACT == DUK_MS_FLAG_EMERGENCY);  /* Compact flag is 1:1 with emergency flag which forces compaction. */\n\tms_flags = (duk_small_uint_t) flags;\n\tduk_heap_mark_and_sweep(heap, ms_flags);\n}\n/*\n *  Object handling: property access and other support functions.\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Property handling\n *\n *  The API exposes only the most common property handling functions.\n *  The caller can invoke Ecmascript built-ins for full control (e.g.\n *  defineProperty, getOwnPropertyDescriptor).\n */\n\nDUK_EXTERNAL duk_bool_t duk_get_prop(duk_context *ctx, duk_idx_t obj_idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv_obj;\n\tduk_tval *tv_key;\n\tduk_bool_t rc;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t/* Note: copying tv_obj and tv_key to locals to shield against a valstack\n\t * resize is not necessary for a property get right now.\n\t */\n\n\ttv_obj = duk_require_tval(ctx, obj_idx);\n\ttv_key = duk_require_tval(ctx, -1);\n\n\trc = duk_hobject_getprop(thr, tv_obj, tv_key);\n\tDUK_ASSERT(rc == 0 || rc == 1);\n\t/* a value is left on stack regardless of rc */\n\n\tduk_remove_m2(ctx);  /* remove key */\n\treturn rc;  /* 1 if property found, 0 otherwise */\n}\n\nDUK_EXTERNAL duk_bool_t duk_get_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(key != NULL);\n\n\tobj_idx = duk_require_normalize_index(ctx, obj_idx);\n\tduk_push_string(ctx, key);\n\treturn duk_get_prop(ctx, obj_idx);\n}\n\nDUK_EXTERNAL duk_bool_t duk_get_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(key != NULL);\n\n\tobj_idx = duk_require_normalize_index(ctx, obj_idx);\n\tduk_push_lstring(ctx, key, key_len);\n\treturn duk_get_prop(ctx, obj_idx);\n}\n\nDUK_EXTERNAL duk_bool_t duk_get_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tobj_idx = duk_require_normalize_index(ctx, obj_idx);\n\tduk_push_uarridx(ctx, arr_idx);\n\treturn duk_get_prop(ctx, obj_idx);\n}\n\nDUK_INTERNAL duk_bool_t duk_get_prop_stridx(duk_context *ctx, duk_idx_t obj_idx, duk_small_uint_t stridx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT_STRIDX_VALID(stridx);\n\tDUK_UNREF(thr);\n\n\tobj_idx = duk_require_normalize_index(ctx, obj_idx);\n\tduk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, stridx));\n\treturn duk_get_prop(ctx, obj_idx);\n}\n\nDUK_INTERNAL duk_bool_t duk_get_prop_stridx_short_raw(duk_context *ctx, duk_uint_t packed_args) {\n\treturn duk_get_prop_stridx(ctx, (duk_idx_t) (duk_int16_t) (packed_args >> 16),\n\t                                (duk_small_uint_t) (packed_args & 0xffffUL));\n}\n\nDUK_INTERNAL duk_bool_t duk_get_prop_stridx_boolean(duk_context *ctx, duk_idx_t obj_idx, duk_small_uint_t stridx, duk_bool_t *out_has_prop) {\n\tduk_bool_t rc;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT_STRIDX_VALID(stridx);\n\n\trc = duk_get_prop_stridx(ctx, obj_idx, stridx);\n\tif (out_has_prop) {\n\t\t*out_has_prop = rc;\n\t}\n\trc = duk_to_boolean(ctx, -1);\n\tDUK_ASSERT(rc == 0 || rc == 1);\n\tduk_pop(ctx);\n\treturn rc;\n}\n\nDUK_LOCAL duk_bool_t duk__put_prop_shared(duk_context *ctx, duk_idx_t obj_idx, duk_idx_t idx_key) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv_obj;\n\tduk_tval *tv_key;\n\tduk_tval *tv_val;\n\tduk_small_int_t throw_flag;\n\tduk_bool_t rc;\n\n\t/* Note: copying tv_obj and tv_key to locals to shield against a valstack\n\t * resize is not necessary for a property put right now (putprop protects\n\t * against it internally).\n\t */\n\n\t/* Key and value indices are either (-2, -1) or (-1, -2).  Given idx_key,\n\t * idx_val is always (idx_key ^ 0x01).\n\t */\n\tDUK_ASSERT((idx_key == -2 && (idx_key ^ 1) == -1) ||\n\t           (idx_key == -1 && (idx_key ^ 1) == -2));\n\t/* XXX: Direct access; faster validation. */\n\ttv_obj = duk_require_tval(ctx, obj_idx);\n\ttv_key = duk_require_tval(ctx, idx_key);\n\ttv_val = duk_require_tval(ctx, idx_key ^ 1);\n\tthrow_flag = duk_is_strict_call(ctx);\n\n\trc = duk_hobject_putprop(thr, tv_obj, tv_key, tv_val, throw_flag);\n\tDUK_ASSERT(rc == 0 || rc == 1);\n\n\tduk_pop_2(ctx);  /* remove key and value */\n\treturn rc;  /* 1 if property found, 0 otherwise */\n}\n\nDUK_EXTERNAL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\treturn duk__put_prop_shared(ctx, obj_idx, -2);\n}\n\nDUK_EXTERNAL duk_bool_t duk_put_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(key != NULL);\n\n\t/* Careful here and with other duk_put_prop_xxx() helpers: the\n\t * target object and the property value may be in the same value\n\t * stack slot (unusual, but still conceptually clear).\n\t */\n\tobj_idx = duk_normalize_index(ctx, obj_idx);\n\t(void) duk_push_string(ctx, key);\n\treturn duk__put_prop_shared(ctx, obj_idx, -1);\n}\n\nDUK_EXTERNAL duk_bool_t duk_put_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(key != NULL);\n\n\tobj_idx = duk_normalize_index(ctx, obj_idx);\n\t(void) duk_push_lstring(ctx, key, key_len);\n\treturn duk__put_prop_shared(ctx, obj_idx, -1);\n}\n\nDUK_EXTERNAL duk_bool_t duk_put_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tobj_idx = duk_require_normalize_index(ctx, obj_idx);\n\tduk_push_uarridx(ctx, arr_idx);\n\treturn duk__put_prop_shared(ctx, obj_idx, -1);\n}\n\nDUK_INTERNAL duk_bool_t duk_put_prop_stridx(duk_context *ctx, duk_idx_t obj_idx, duk_small_uint_t stridx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT_STRIDX_VALID(stridx);\n\tDUK_UNREF(thr);\n\n\tobj_idx = duk_require_normalize_index(ctx, obj_idx);\n\tduk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, stridx));\n\treturn duk__put_prop_shared(ctx, obj_idx, -1);\n}\n\nDUK_INTERNAL duk_bool_t duk_put_prop_stridx_short_raw(duk_context *ctx, duk_uint_t packed_args) {\n\treturn duk_put_prop_stridx(ctx, (duk_idx_t) (duk_int16_t) (packed_args >> 16),\n\t                                (duk_small_uint_t) (packed_args & 0xffffUL));\n}\n\nDUK_EXTERNAL duk_bool_t duk_del_prop(duk_context *ctx, duk_idx_t obj_idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv_obj;\n\tduk_tval *tv_key;\n\tduk_small_int_t throw_flag;\n\tduk_bool_t rc;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t/* Note: copying tv_obj and tv_key to locals to shield against a valstack\n\t * resize is not necessary for a property delete right now.\n\t */\n\n\ttv_obj = duk_require_tval(ctx, obj_idx);\n\ttv_key = duk_require_tval(ctx, -1);\n\tthrow_flag = duk_is_strict_call(ctx);\n\n\trc = duk_hobject_delprop(thr, tv_obj, tv_key, throw_flag);\n\tDUK_ASSERT(rc == 0 || rc == 1);\n\n\tduk_pop(ctx);  /* remove key */\n\treturn rc;\n}\n\nDUK_EXTERNAL duk_bool_t duk_del_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(key != NULL);\n\n\tobj_idx = duk_require_normalize_index(ctx, obj_idx);\n\tduk_push_string(ctx, key);\n\treturn duk_del_prop(ctx, obj_idx);\n}\n\nDUK_EXTERNAL duk_bool_t duk_del_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(key != NULL);\n\n\tobj_idx = duk_require_normalize_index(ctx, obj_idx);\n\tduk_push_lstring(ctx, key, key_len);\n\treturn duk_del_prop(ctx, obj_idx);\n}\n\nDUK_EXTERNAL duk_bool_t duk_del_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tobj_idx = duk_require_normalize_index(ctx, obj_idx);\n\tduk_push_uarridx(ctx, arr_idx);\n\treturn duk_del_prop(ctx, obj_idx);\n}\n\nDUK_INTERNAL duk_bool_t duk_del_prop_stridx(duk_context *ctx, duk_idx_t obj_idx, duk_small_uint_t stridx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT_STRIDX_VALID(stridx);\n\tDUK_UNREF(thr);\n\n\tobj_idx = duk_require_normalize_index(ctx, obj_idx);\n\tduk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, stridx));\n\treturn duk_del_prop(ctx, obj_idx);\n}\n\n#if 0\nDUK_INTERNAL duk_bool_t duk_del_prop_stridx_short_raw(duk_context *ctx, duk_uint_t packed_args) {\n\treturn duk_del_prop_stridx(ctx, (duk_idx_t) (duk_int16_t) (packed_args >> 16),\n\t                                (duk_small_uint_t) (packed_args & 0xffffUL));\n}\n#endif\n\nDUK_EXTERNAL duk_bool_t duk_has_prop(duk_context *ctx, duk_idx_t obj_idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv_obj;\n\tduk_tval *tv_key;\n\tduk_bool_t rc;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t/* Note: copying tv_obj and tv_key to locals to shield against a valstack\n\t * resize is not necessary for a property existence check right now.\n\t */\n\n\ttv_obj = duk_require_tval(ctx, obj_idx);\n\ttv_key = duk_require_tval(ctx, -1);\n\n\trc = duk_hobject_hasprop(thr, tv_obj, tv_key);\n\tDUK_ASSERT(rc == 0 || rc == 1);\n\n\tduk_pop(ctx);  /* remove key */\n\treturn rc;  /* 1 if property found, 0 otherwise */\n}\n\nDUK_EXTERNAL duk_bool_t duk_has_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(key != NULL);\n\n\tobj_idx = duk_require_normalize_index(ctx, obj_idx);\n\tduk_push_string(ctx, key);\n\treturn duk_has_prop(ctx, obj_idx);\n}\n\nDUK_EXTERNAL duk_bool_t duk_has_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(key != NULL);\n\n\tobj_idx = duk_require_normalize_index(ctx, obj_idx);\n\tduk_push_lstring(ctx, key, key_len);\n\treturn duk_has_prop(ctx, obj_idx);\n}\n\nDUK_EXTERNAL duk_bool_t duk_has_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tobj_idx = duk_require_normalize_index(ctx, obj_idx);\n\tduk_push_uarridx(ctx, arr_idx);\n\treturn duk_has_prop(ctx, obj_idx);\n}\n\nDUK_INTERNAL duk_bool_t duk_has_prop_stridx(duk_context *ctx, duk_idx_t obj_idx, duk_small_uint_t stridx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT_STRIDX_VALID(stridx);\n\tDUK_UNREF(thr);\n\n\tobj_idx = duk_require_normalize_index(ctx, obj_idx);\n\tduk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, stridx));\n\treturn duk_has_prop(ctx, obj_idx);\n}\n\n#if 0\nDUK_INTERNAL duk_bool_t duk_has_prop_stridx_short_raw(duk_context *ctx, duk_uint_t packed_args) {\n\treturn duk_has_prop_stridx(ctx, (duk_idx_t) (duk_int16_t) (packed_args >> 16),\n\t                                (duk_small_uint_t) (packed_args & 0xffffUL));\n}\n#endif\n\n/* Define own property without inheritance lookups and such.  This differs from\n * [[DefineOwnProperty]] because special behaviors (like Array 'length') are\n * not invoked by this method.  The caller must be careful to invoke any such\n * behaviors if necessary.\n */\nDUK_INTERNAL void duk_xdef_prop(duk_context *ctx, duk_idx_t obj_idx, duk_small_uint_t desc_flags) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *obj;\n\tduk_hstring *key;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tobj = duk_require_hobject(ctx, obj_idx);\n\tDUK_ASSERT(obj != NULL);\n\tkey = duk_to_property_key_hstring(ctx, -2);\n\tDUK_ASSERT(key != NULL);\n\tDUK_ASSERT(duk_require_tval(ctx, -1) != NULL);\n\n\tduk_hobject_define_property_internal(thr, obj, key, desc_flags);\n\n\tduk_pop(ctx);  /* pop key */\n}\n\nDUK_INTERNAL void duk_xdef_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx, duk_small_uint_t desc_flags) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *obj;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tobj = duk_require_hobject(ctx, obj_idx);\n\tDUK_ASSERT(obj != NULL);\n\n\tduk_hobject_define_property_internal_arridx(thr, obj, arr_idx, desc_flags);\n\t/* value popped by call */\n}\n\nDUK_INTERNAL void duk_xdef_prop_stridx(duk_context *ctx, duk_idx_t obj_idx, duk_small_uint_t stridx, duk_small_uint_t desc_flags) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *obj;\n\tduk_hstring *key;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT_STRIDX_VALID(stridx);\n\n\tobj = duk_require_hobject(ctx, obj_idx);\n\tDUK_ASSERT(obj != NULL);\n\tkey = DUK_HTHREAD_GET_STRING(thr, stridx);\n\tDUK_ASSERT(key != NULL);\n\tDUK_ASSERT(duk_require_tval(ctx, -1) != NULL);\n\n\tduk_hobject_define_property_internal(thr, obj, key, desc_flags);\n\t/* value popped by call */\n}\n\nDUK_INTERNAL void duk_xdef_prop_stridx_short_raw(duk_context *ctx, duk_uint_t packed_args) {\n\tduk_xdef_prop_stridx(ctx, (duk_idx_t) (duk_int8_t) (packed_args >> 24),\n\t                          (duk_small_uint_t) (packed_args >> 8) & 0xffffUL,\n\t                          (duk_small_uint_t) (packed_args & 0xffL));\n}\n\nDUK_INTERNAL void duk_xdef_prop_stridx_builtin(duk_context *ctx, duk_idx_t obj_idx, duk_small_uint_t stridx, duk_small_int_t builtin_idx, duk_small_uint_t desc_flags) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *obj;\n\tduk_hstring *key;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT_STRIDX_VALID(stridx);\n\tDUK_ASSERT_BIDX_VALID(builtin_idx);\n\n\tobj = duk_require_hobject(ctx, obj_idx);\n\tDUK_ASSERT(obj != NULL);\n\tkey = DUK_HTHREAD_GET_STRING(thr, stridx);\n\tDUK_ASSERT(key != NULL);\n\n\tduk_push_hobject(ctx, thr->builtins[builtin_idx]);\n\tduk_hobject_define_property_internal(thr, obj, key, desc_flags);\n\t/* value popped by call */\n}\n\n/* This is a rare property helper; it sets the global thrower (E5 Section 13.2.3)\n * setter/getter into an object property.  This is needed by the 'arguments'\n * object creation code, function instance creation code, and Function.prototype.bind().\n */\n\nDUK_INTERNAL void duk_xdef_prop_stridx_thrower(duk_context *ctx, duk_idx_t obj_idx, duk_small_uint_t stridx) {\n\tobj_idx = duk_require_normalize_index(ctx, obj_idx);\n\tduk_push_hstring_stridx(ctx, stridx);\n\tduk_push_hobject_bidx(ctx, DUK_BIDX_TYPE_ERROR_THROWER);\n\tduk_dup_top(ctx);\n\tduk_def_prop(ctx, obj_idx, DUK_DEFPROP_HAVE_SETTER | DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_FORCE);  /* attributes always 0 */\n}\n\n/* Object.getOwnPropertyDescriptor() equivalent C binding. */\nDUK_EXTERNAL void duk_get_prop_desc(duk_context *ctx, duk_idx_t obj_idx, duk_uint_t flags) {\n\tDUK_UNREF(flags);  /* no flags defined yet */\n\n\tduk_hobject_object_get_own_property_descriptor(ctx, obj_idx);  /* [ ... key ] -> [ ... desc ] */\n}\n\n/* Object.defineProperty() equivalent C binding. */\nDUK_EXTERNAL void duk_def_prop(duk_context *ctx, duk_idx_t obj_idx, duk_uint_t flags) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_idx_t idx_base;\n\tduk_hobject *obj;\n\tduk_hstring *key;\n\tduk_idx_t idx_value;\n\tduk_hobject *get;\n\tduk_hobject *set;\n\tduk_uint_t is_data_desc;\n\tduk_uint_t is_acc_desc;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tobj = duk_require_hobject(ctx, obj_idx);\n\n\tis_data_desc = flags & (DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE);\n\tis_acc_desc = flags & (DUK_DEFPROP_HAVE_GETTER | DUK_DEFPROP_HAVE_SETTER);\n\tif (is_data_desc && is_acc_desc) {\n\t\t/* \"Have\" flags must not be conflicting so that they would\n\t\t * apply to both a plain property and an accessor at the same\n\t\t * time.\n\t\t */\n\t\tgoto fail_invalid_desc;\n\t}\n\n\tidx_base = duk_get_top_index(ctx);\n\tif (flags & DUK_DEFPROP_HAVE_SETTER) {\n\t\tduk_require_type_mask(ctx, idx_base, DUK_TYPE_MASK_UNDEFINED |\n\t\t                                     DUK_TYPE_MASK_OBJECT |\n\t\t                                     DUK_TYPE_MASK_LIGHTFUNC);\n\t\tset = duk_get_hobject_promote_lfunc(ctx, idx_base);\n\t\tif (set != NULL && !DUK_HOBJECT_IS_CALLABLE(set)) {\n\t\t\tgoto fail_not_callable;\n\t\t}\n\t\tidx_base--;\n\t} else {\n\t\tset = NULL;\n\t}\n\tif (flags & DUK_DEFPROP_HAVE_GETTER) {\n\t\tduk_require_type_mask(ctx, idx_base, DUK_TYPE_MASK_UNDEFINED |\n\t\t                                     DUK_TYPE_MASK_OBJECT |\n\t\t                                     DUK_TYPE_MASK_LIGHTFUNC);\n\t\tget = duk_get_hobject_promote_lfunc(ctx, idx_base);\n\t\tif (get != NULL && !DUK_HOBJECT_IS_CALLABLE(get)) {\n\t\t\tgoto fail_not_callable;\n\t\t}\n\t\tidx_base--;\n\t} else {\n\t\tget = NULL;\n\t}\n\tif (flags & DUK_DEFPROP_HAVE_VALUE) {\n\t\tidx_value = idx_base;\n\t\tidx_base--;\n\t} else {\n\t\tidx_value = (duk_idx_t) -1;\n\t}\n\tkey = duk_to_property_key_hstring(ctx, idx_base);\n\tDUK_ASSERT(key != NULL);\n\n\tduk_require_valid_index(ctx, idx_base);\n\n\tduk_hobject_define_property_helper(ctx,\n\t                                   flags /*defprop_flags*/,\n\t                                   obj,\n\t                                   key,\n\t                                   idx_value,\n\t                                   get,\n\t                                   set,\n\t                                   1 /*throw_flag*/);\n\n\t/* Clean up stack */\n\n\tduk_set_top(ctx, idx_base);\n\n\t/* [ ... obj ... ] */\n\n\treturn;\n\n fail_invalid_desc:\n\tDUK_ERROR_TYPE(thr, DUK_STR_INVALID_DESCRIPTOR);\n\treturn;\n\n fail_not_callable:\n\tDUK_ERROR_TYPE(thr, DUK_STR_NOT_CALLABLE);\n\treturn;\n}\n\n/*\n *  Object related\n *\n *  Note: seal() and freeze() are accessible through Ecmascript bindings,\n *  and are not exposed through the API.\n */\n\nDUK_EXTERNAL void duk_compact(duk_context *ctx, duk_idx_t obj_idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *obj;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tobj = duk_get_hobject(ctx, obj_idx);\n\tif (obj) {\n\t\t/* Note: this may fail, caller should protect the call if necessary */\n\t\tduk_hobject_compact_props(thr, obj);\n\t}\n}\n\nDUK_INTERNAL void duk_compact_m1(duk_context *ctx) {\n\tduk_compact(ctx, -1);\n}\n\n/* XXX: the duk_hobject_enum.c stack APIs should be reworked */\n\nDUK_EXTERNAL void duk_enum(duk_context *ctx, duk_idx_t obj_idx, duk_uint_t enum_flags) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tduk_dup(ctx, obj_idx);\n\tduk_require_hobject_promote_mask(ctx, -1, DUK_TYPE_MASK_LIGHTFUNC | DUK_TYPE_MASK_BUFFER);\n\tduk_hobject_enumerator_create(ctx, enum_flags);   /* [target] -> [enum] */\n}\n\nDUK_EXTERNAL duk_bool_t duk_next(duk_context *ctx, duk_idx_t enum_index, duk_bool_t get_value) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tduk_require_hobject(ctx, enum_index);\n\tduk_dup(ctx, enum_index);\n\treturn duk_hobject_enumerator_next(ctx, get_value);\n}\n\n/*\n *  Helpers for writing multiple properties\n */\n\nDUK_EXTERNAL void duk_put_function_list(duk_context *ctx, duk_idx_t obj_idx, const duk_function_list_entry *funcs) {\n\tconst duk_function_list_entry *ent = funcs;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tobj_idx = duk_require_normalize_index(ctx, obj_idx);\n\tif (ent != NULL) {\n\t\twhile (ent->key != NULL) {\n\t\t\tduk_push_c_function(ctx, ent->value, ent->nargs);\n\t\t\tduk_put_prop_string(ctx, obj_idx, ent->key);\n\t\t\tent++;\n\t\t}\n\t}\n}\n\nDUK_EXTERNAL void duk_put_number_list(duk_context *ctx, duk_idx_t obj_idx, const duk_number_list_entry *numbers) {\n\tconst duk_number_list_entry *ent = numbers;\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tobj_idx = duk_require_normalize_index(ctx, obj_idx);\n\tif (ent != NULL) {\n\t\twhile (ent->key != NULL) {\n\t\t\ttv = ((duk_hthread *) ctx)->valstack_top++;\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_UNDEFINED(tv));  /* value stack init policy */\n\t\t\tDUK_TVAL_SET_NUMBER_CHKFAST_SLOW(tv, ent->value);  /* no need for decref/incref */\n\t\t\tduk_put_prop_string(ctx, obj_idx, ent->key);\n\t\t\tent++;\n\t\t}\n\t}\n}\n\n/*\n *  Shortcut for accessing global object properties\n */\n\nDUK_EXTERNAL duk_bool_t duk_get_global_string(duk_context *ctx, const char *key) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_bool_t ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL);\n\n\t/* XXX: direct implementation */\n\n\tduk_push_hobject(ctx, thr->builtins[DUK_BIDX_GLOBAL]);\n\tret = duk_get_prop_string(ctx, -1, key);\n\tduk_remove_m2(ctx);\n\treturn ret;\n}\n\nDUK_EXTERNAL duk_bool_t duk_get_global_lstring(duk_context *ctx, const char *key, duk_size_t key_len) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_bool_t ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL);\n\n\t/* XXX: direct implementation */\n\n\tduk_push_hobject(ctx, thr->builtins[DUK_BIDX_GLOBAL]);\n\tret = duk_get_prop_lstring(ctx, -1, key, key_len);\n\tduk_remove_m2(ctx);\n\treturn ret;\n}\n\nDUK_EXTERNAL duk_bool_t duk_put_global_string(duk_context *ctx, const char *key) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_bool_t ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL);\n\n\t/* XXX: direct implementation */\n\n\tduk_push_hobject(ctx, thr->builtins[DUK_BIDX_GLOBAL]);\n\tduk_insert(ctx, -2);\n\tret = duk_put_prop_string(ctx, -2, key);  /* [ ... global val ] -> [ ... global ] */\n\tduk_pop(ctx);\n\treturn ret;\n}\n\nDUK_EXTERNAL duk_bool_t duk_put_global_lstring(duk_context *ctx, const char *key, duk_size_t key_len) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_bool_t ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL);\n\n\t/* XXX: direct implementation */\n\n\tduk_push_hobject(ctx, thr->builtins[DUK_BIDX_GLOBAL]);\n\tduk_insert(ctx, -2);\n\tret = duk_put_prop_lstring(ctx, -2, key, key_len);  /* [ ... global val ] -> [ ... global ] */\n\tduk_pop(ctx);\n\treturn ret;\n}\n\n/*\n *  Object prototype\n */\n\nDUK_EXTERNAL void duk_get_prototype(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *obj;\n\tduk_hobject *proto;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_UNREF(thr);\n\n\tobj = duk_require_hobject(ctx, idx);\n\tDUK_ASSERT(obj != NULL);\n\n\t/* XXX: shared helper for duk_push_hobject_or_undefined()? */\n\tproto = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, obj);\n\tif (proto) {\n\t\tduk_push_hobject(ctx, proto);\n\t} else {\n\t\tduk_push_undefined(ctx);\n\t}\n}\n\nDUK_EXTERNAL void duk_set_prototype(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *obj;\n\tduk_hobject *proto;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tobj = duk_require_hobject(ctx, idx);\n\tDUK_ASSERT(obj != NULL);\n\tduk_require_type_mask(ctx, -1, DUK_TYPE_MASK_UNDEFINED |\n\t                               DUK_TYPE_MASK_OBJECT);\n\tproto = duk_get_hobject(ctx, -1);\n\t/* proto can also be NULL here (allowed explicitly) */\n\n#if defined(DUK_USE_ROM_OBJECTS)\n\tif (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj)) {\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE);  /* XXX: \"read only object\"? */\n\t\treturn;\n\t}\n#endif\n\n\tDUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, obj, proto);\n\n\tduk_pop(ctx);\n}\n\n/*\n *  Object finalizer\n */\n\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n/* XXX: these could be implemented as macros calling an internal function\n * directly.\n * XXX: same issue as with Duktape.fin: there's no way to delete the property\n * now (just set it to undefined).\n */\nDUK_EXTERNAL void duk_get_finalizer(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tduk_get_prop_stridx(ctx, idx, DUK_STRIDX_INT_FINALIZER);\n}\n\nDUK_EXTERNAL void duk_set_finalizer(duk_context *ctx, duk_idx_t idx) {\n\tduk_hobject *h;\n\tduk_bool_t callable;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\th = duk_require_hobject(ctx, idx);  /* Get before 'put' so that 'idx' is correct. */\n\tcallable = duk_is_callable(ctx, -1);\n\tduk_put_prop_stridx(ctx, idx, DUK_STRIDX_INT_FINALIZER);\n\n\t/* In addition to setting the finalizer property, keep a \"have\n\t * finalizer\" flag in duk_hobject in sync so that refzero can do\n\t * a very quick finalizer check by walking the prototype chain\n\t * and checking the flag alone.  (Note that this means that just\n\t * setting _Finalizer on an object won't affect finalizer checks.)\n\t *\n\t * NOTE: if the argument is a Proxy object, this flag will be set\n\t * on the Proxy, not the target.  As a result, the target won't get\n\t * a finalizer flag and the Proxy also won't be finalized as there's\n\t * an explicit Proxy check in finalization now.\n\t */\n\tif (callable) {\n\t\tDUK_HOBJECT_SET_HAVE_FINALIZER(h);\n\t} else {\n\t\tDUK_HOBJECT_CLEAR_HAVE_FINALIZER(h);\n\t}\n}\n#else  /* DUK_USE_FINALIZER_SUPPORT */\nDUK_EXTERNAL void duk_get_finalizer(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_UNREF(idx);\n\tDUK_ERROR_UNSUPPORTED((duk_hthread *) ctx);\n}\n\nDUK_EXTERNAL void duk_set_finalizer(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_UNREF(idx);\n\tDUK_ERROR_UNSUPPORTED((duk_hthread *) ctx);\n}\n#endif  /* DUK_USE_FINALIZER_SUPPORT */\n/*\n *  API calls related to general value stack manipulation: resizing the value\n *  stack, pushing and popping values, type checking and reading values,\n *  coercing values, etc.\n *\n *  Also contains internal functions (such as duk_get_tval()), defined\n *  in duk_api_internal.h, with semantics similar to the public API.\n */\n\n/* XXX: repetition of stack pre-checks -> helper or macro or inline */\n/* XXX: shared api error strings, and perhaps even throw code for rare cases? */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Forward declarations\n */\n\nDUK_LOCAL_DECL duk_idx_t duk__push_c_function_raw(duk_context *ctx, duk_c_function func, duk_idx_t nargs, duk_uint_t flags);\n\n/*\n *  Global state for working around missing variadic macros\n */\n\n#if !defined(DUK_USE_VARIADIC_MACROS)\nDUK_EXTERNAL const char *duk_api_global_filename = NULL;\nDUK_EXTERNAL duk_int_t duk_api_global_line = 0;\n#endif\n\n/*\n *  Misc helpers\n */\n\n#if !defined(DUK_USE_PACKED_TVAL)\nDUK_LOCAL const duk_uint_t duk__type_from_tag[] = {\n\tDUK_TYPE_NUMBER,\n\tDUK_TYPE_NUMBER,  /* fastint */\n\tDUK_TYPE_UNDEFINED,\n\tDUK_TYPE_NULL,\n\tDUK_TYPE_BOOLEAN,\n\tDUK_TYPE_POINTER,\n\tDUK_TYPE_LIGHTFUNC,\n\tDUK_TYPE_NONE,\n\tDUK_TYPE_STRING,\n\tDUK_TYPE_OBJECT,\n\tDUK_TYPE_BUFFER,\n};\nDUK_LOCAL const duk_uint_t duk__type_mask_from_tag[] = {\n\tDUK_TYPE_MASK_NUMBER,\n\tDUK_TYPE_MASK_NUMBER,  /* fastint */\n\tDUK_TYPE_MASK_UNDEFINED,\n\tDUK_TYPE_MASK_NULL,\n\tDUK_TYPE_MASK_BOOLEAN,\n\tDUK_TYPE_MASK_POINTER,\n\tDUK_TYPE_MASK_LIGHTFUNC,\n\tDUK_TYPE_MASK_NONE,\n\tDUK_TYPE_MASK_STRING,\n\tDUK_TYPE_MASK_OBJECT,\n\tDUK_TYPE_MASK_BUFFER,\n};\n#endif  /* !DUK_USE_PACKED_TVAL */\n\n/* Check that there's room to push one value. */\n#if defined(DUK_USE_VALSTACK_UNSAFE)\n/* Faster but value stack overruns are memory unsafe. */\n#define DUK__CHECK_SPACE() do { \\\n\t\tDUK_ASSERT(!(thr->valstack_top >= thr->valstack_end)); \\\n\t} while (0)\n#else\n#define DUK__CHECK_SPACE() do { \\\n\t\tif (DUK_UNLIKELY(thr->valstack_top >= thr->valstack_end)) { \\\n\t\t\tDUK_ERROR_RANGE_PUSH_BEYOND(thr); \\\n\t\t} \\\n\t} while (0)\n#endif\n\nDUK_LOCAL_DECL duk_heaphdr *duk__get_tagged_heaphdr_raw(duk_context *ctx, duk_idx_t idx, duk_uint_t tag);\n\nDUK_LOCAL duk_int_t duk__api_coerce_d2i(duk_context *ctx, duk_idx_t idx, duk_int_t def_value, duk_bool_t require) {\n\tduk_hthread *thr;\n\tduk_tval *tv;\n\tduk_small_int_t c;\n\tduk_double_t d;\n\n\tthr = (duk_hthread *) ctx;\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\n\t/*\n\t *  Special cases like NaN and +/- Infinity are handled explicitly\n\t *  because a plain C coercion from double to int handles these cases\n\t *  in undesirable ways.  For instance, NaN may coerce to INT_MIN\n\t *  (not zero), and INT_MAX + 1 may coerce to INT_MIN (not INT_MAX).\n\t *\n\t *  This double-to-int coercion differs from ToInteger() because it\n\t *  has a finite range (ToInteger() allows e.g. +/- Infinity).  It\n\t *  also differs from ToInt32() because the INT_MIN/INT_MAX clamping\n\t *  depends on the size of the int type on the platform.  In particular,\n\t *  on platforms with a 64-bit int type, the full range is allowed.\n\t */\n\n#if defined(DUK_USE_FASTINT)\n\tif (DUK_TVAL_IS_FASTINT(tv)) {\n\t\tduk_int64_t t = DUK_TVAL_GET_FASTINT(tv);\n#if (DUK_INT_MAX <= 0x7fffffffL)\n\t\t/* Clamping only necessary for 32-bit ints. */\n\t\tif (t < DUK_INT_MIN) {\n\t\t\tt = DUK_INT_MIN;\n\t\t} else if (t > DUK_INT_MAX) {\n\t\t\tt = DUK_INT_MAX;\n\t\t}\n#endif\n\t\treturn (duk_int_t) t;\n\t}\n#endif\n\n\tif (DUK_TVAL_IS_NUMBER(tv)) {\n\t\td = DUK_TVAL_GET_NUMBER(tv);\n\t\tc = (duk_small_int_t) DUK_FPCLASSIFY(d);\n\t\tif (c == DUK_FP_NAN) {\n\t\t\treturn 0;\n\t\t} else if (d < (duk_double_t) DUK_INT_MIN) {\n\t\t\t/* covers -Infinity */\n\t\t\treturn DUK_INT_MIN;\n\t\t} else if (d > (duk_double_t) DUK_INT_MAX) {\n\t\t\t/* covers +Infinity */\n\t\t\treturn DUK_INT_MAX;\n\t\t} else {\n\t\t\t/* coerce towards zero */\n\t\t\treturn (duk_int_t) d;\n\t\t}\n\t}\n\n\tif (require) {\n\t\tDUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, \"number\", DUK_STR_NOT_NUMBER);\n\t\t/* not reachable */\n\t}\n\n\treturn def_value;\n}\n\nDUK_LOCAL duk_uint_t duk__api_coerce_d2ui(duk_context *ctx, duk_idx_t idx, duk_uint_t def_value, duk_bool_t require) {\n\tduk_hthread *thr;\n\tduk_tval *tv;\n\tduk_small_int_t c;\n\tduk_double_t d;\n\n\t/* Same as above but for unsigned int range. */\n\n\tthr = (duk_hthread *) ctx;\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\n#if defined(DUK_USE_FASTINT)\n\tif (DUK_TVAL_IS_FASTINT(tv)) {\n\t\tduk_int64_t t = DUK_TVAL_GET_FASTINT(tv);\n\t\tif (t < 0) {\n\t\t\tt = 0;\n\t\t}\n#if (DUK_UINT_MAX <= 0xffffffffUL)\n\t\t/* Clamping only necessary for 32-bit ints. */\n\t\telse if (t > DUK_UINT_MAX) {\n\t\t\tt = DUK_UINT_MAX;\n\t\t}\n#endif\n\t\treturn (duk_uint_t) t;\n\t}\n#endif\n\n\tif (DUK_TVAL_IS_NUMBER(tv)) {\n\t\td = DUK_TVAL_GET_NUMBER(tv);\n\t\tc = (duk_small_int_t) DUK_FPCLASSIFY(d);\n\t\tif (c == DUK_FP_NAN) {\n\t\t\treturn 0;\n\t\t} else if (d < 0.0) {\n\t\t\t/* covers -Infinity */\n\t\t\treturn (duk_uint_t) 0;\n\t\t} else if (d > (duk_double_t) DUK_UINT_MAX) {\n\t\t\t/* covers +Infinity */\n\t\t\treturn (duk_uint_t) DUK_UINT_MAX;\n\t\t} else {\n\t\t\t/* coerce towards zero */\n\t\t\treturn (duk_uint_t) d;\n\t\t}\n\t}\n\n\tif (require) {\n\t\tDUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, \"number\", DUK_STR_NOT_NUMBER);\n\t\t/* not reachable */\n\t}\n\n\treturn def_value;\n}\n\n/*\n *  Stack index validation/normalization and getting a stack duk_tval ptr.\n *\n *  These are called by many API entrypoints so the implementations must be\n *  fast and \"inlined\".\n *\n *  There's some repetition because of this; keep the functions in sync.\n */\n\nDUK_EXTERNAL duk_idx_t duk_normalize_index(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_uidx_t vs_size;\n\tduk_uidx_t uidx;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(DUK_INVALID_INDEX < 0);\n\n\t/* Care must be taken to avoid pointer wrapping in the index\n\t * validation.  For instance, on a 32-bit platform with 8-byte\n\t * duk_tval the index 0x20000000UL would wrap the memory space\n\t * once.\n\t */\n\n\t/* Assume value stack sizes (in elements) fits into duk_idx_t. */\n\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n\tvs_size = (duk_uidx_t) (thr->valstack_top - thr->valstack_bottom);\n\tDUK_ASSERT_DISABLE(vs_size >= 0);  /* unsigned */\n\n\tif (idx < 0) {\n\t\tuidx = vs_size + (duk_uidx_t) idx;\n\t} else {\n\t\t/* since index non-negative */\n\t\tDUK_ASSERT(idx != DUK_INVALID_INDEX);\n\t\tuidx = (duk_uidx_t) idx;\n\t}\n\n\t/* DUK_INVALID_INDEX won't be accepted as a valid index. */\n\tDUK_ASSERT(vs_size + (duk_uidx_t) DUK_INVALID_INDEX >= vs_size);\n\n\tif (DUK_LIKELY(uidx < vs_size)) {\n\t\treturn (duk_idx_t) uidx;\n\t}\n\treturn DUK_INVALID_INDEX;\n}\n\nDUK_EXTERNAL duk_idx_t duk_require_normalize_index(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_uidx_t vs_size;\n\tduk_uidx_t uidx;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(DUK_INVALID_INDEX < 0);\n\n\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n\tvs_size = (duk_uidx_t) (thr->valstack_top - thr->valstack_bottom);\n\tDUK_ASSERT_DISABLE(vs_size >= 0);  /* unsigned */\n\n\tif (idx < 0) {\n\t\tuidx = vs_size + (duk_uidx_t) idx;\n\t} else {\n\t\tDUK_ASSERT(idx != DUK_INVALID_INDEX);\n\t\tuidx = (duk_uidx_t) idx;\n\t}\n\n\t/* DUK_INVALID_INDEX won't be accepted as a valid index. */\n\tDUK_ASSERT(vs_size + (duk_uidx_t) DUK_INVALID_INDEX >= vs_size);\n\n\tif (DUK_LIKELY(uidx < vs_size)) {\n\t\treturn (duk_idx_t) uidx;\n\t}\n\tDUK_ERROR_RANGE_INDEX(thr, idx);\n\treturn 0;  /* unreachable */\n}\n\nDUK_INTERNAL duk_tval *duk_get_tval(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_uidx_t vs_size;\n\tduk_uidx_t uidx;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(DUK_INVALID_INDEX < 0);\n\n\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n\tvs_size = (duk_uidx_t) (thr->valstack_top - thr->valstack_bottom);\n\tDUK_ASSERT_DISABLE(vs_size >= 0);  /* unsigned */\n\n\tif (idx < 0) {\n\t\tuidx = vs_size + (duk_uidx_t) idx;\n\t} else {\n\t\tDUK_ASSERT(idx != DUK_INVALID_INDEX);\n\t\tuidx = (duk_uidx_t) idx;\n\t}\n\n\t/* DUK_INVALID_INDEX won't be accepted as a valid index. */\n\tDUK_ASSERT(vs_size + (duk_uidx_t) DUK_INVALID_INDEX >= vs_size);\n\n\tif (DUK_LIKELY(uidx < vs_size)) {\n\t\treturn thr->valstack_bottom + uidx;\n\t}\n\treturn NULL;\n}\n\n/* Variant of duk_get_tval() which is guaranteed to return a valid duk_tval\n * pointer.  When duk_get_tval() would return NULL, this variant returns a\n * pointer to a duk_tval with tag DUK_TAG_UNUSED.  This allows the call site\n * to avoid an unnecessary NULL check which sometimes leads to better code.\n * The return duk_tval is read only (at least for the UNUSED value).\n */\nDUK_LOCAL const duk_tval_unused duk__const_tval_unused = DUK_TVAL_UNUSED_INITIALIZER();\n\nDUK_INTERNAL duk_tval *duk_get_tval_or_unused(duk_context *ctx, duk_idx_t idx) {\n\tduk_tval *tv;\n\ttv = duk_get_tval(ctx, idx);\n\tif (tv != NULL) {\n\t\treturn tv;\n\t}\n\treturn (duk_tval *) DUK_LOSE_CONST(&duk__const_tval_unused);\n}\n\nDUK_INTERNAL duk_tval *duk_require_tval(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_uidx_t vs_size;\n\tduk_uidx_t uidx;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(DUK_INVALID_INDEX < 0);\n\n\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n\tvs_size = (duk_uidx_t) (thr->valstack_top - thr->valstack_bottom);\n\tDUK_ASSERT_DISABLE(vs_size >= 0);  /* unsigned */\n\n\t/* Use unsigned arithmetic to optimize comparison. */\n\tif (idx < 0) {\n\t\tuidx = vs_size + (duk_uidx_t) idx;\n\t} else {\n\t\tDUK_ASSERT(idx != DUK_INVALID_INDEX);\n\t\tuidx = (duk_uidx_t) idx;\n\t}\n\n\t/* DUK_INVALID_INDEX won't be accepted as a valid index. */\n\tDUK_ASSERT(vs_size + (duk_uidx_t) DUK_INVALID_INDEX >= vs_size);\n\n\tif (DUK_LIKELY(uidx < vs_size)) {\n\t\treturn thr->valstack_bottom + uidx;\n\t}\n\tDUK_ERROR_RANGE_INDEX(thr, idx);\n\treturn NULL;\n}\n\n/* Non-critical. */\nDUK_EXTERNAL duk_bool_t duk_is_valid_index(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(DUK_INVALID_INDEX < 0);\n\n\treturn (duk_normalize_index(ctx, idx) >= 0);\n}\n\n/* Non-critical. */\nDUK_EXTERNAL void duk_require_valid_index(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(DUK_INVALID_INDEX < 0);\n\n\tif (DUK_UNLIKELY(duk_normalize_index(ctx, idx) < 0)) {\n\t\tDUK_ERROR_RANGE_INDEX(thr, idx);\n\t\treturn;  /* unreachable */\n\t}\n}\n\n/*\n *  Value stack top handling\n */\n\nDUK_EXTERNAL duk_idx_t duk_get_top(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\treturn (duk_idx_t) (thr->valstack_top - thr->valstack_bottom);\n}\n\n/* Internal helper to get current top but to require a minimum top value\n * (TypeError if not met).\n */\nDUK_INTERNAL duk_idx_t duk_get_top_require_min(duk_context *ctx, duk_idx_t min_top) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_idx_t ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tret = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom);\n\tif (DUK_UNLIKELY(ret < min_top)) {\n\t\tDUK_ERROR_TYPE_INVALID_ARGS(thr);\n\t}\n\treturn ret;\n}\n\n/* Set stack top within currently allocated range, but don't reallocate.\n * This is performance critical especially for call handling, so whenever\n * changing, profile and look at generated code.\n */\nDUK_EXTERNAL void duk_set_top(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_uidx_t vs_size;\n\tduk_uidx_t vs_limit;\n\tduk_uidx_t uidx;\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(DUK_INVALID_INDEX < 0);\n\n\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n\tDUK_ASSERT(thr->valstack_end >= thr->valstack_bottom);\n\tvs_size = (duk_uidx_t) (thr->valstack_top - thr->valstack_bottom);\n\tvs_limit = (duk_uidx_t) (thr->valstack_end - thr->valstack_bottom);\n\n\tif (idx < 0) {\n\t\t/* Negative indices are always within allocated stack but\n\t\t * must not go below zero index.\n\t\t */\n\t\tuidx = vs_size + (duk_uidx_t) idx;\n\t} else {\n\t\t/* Positive index can be higher than valstack top but must\n\t\t * not go above allocated stack (equality is OK).\n\t\t */\n\t\tuidx = (duk_uidx_t) idx;\n\t}\n\n\t/* DUK_INVALID_INDEX won't be accepted as a valid index. */\n\tDUK_ASSERT(vs_size + (duk_uidx_t) DUK_INVALID_INDEX >= vs_size);\n\tDUK_ASSERT(vs_size + (duk_uidx_t) DUK_INVALID_INDEX >= vs_limit);\n\n#if defined(DUK_USE_VALSTACK_UNSAFE)\n\tDUK_ASSERT(uidx <= vs_limit);\n\tDUK_UNREF(vs_limit);\n#else\n\tif (DUK_UNLIKELY(uidx > vs_limit)) {\n\t\tDUK_ERROR_RANGE_INDEX(thr, idx);\n\t\treturn;  /* unreachable */\n\t}\n#endif\n\tDUK_ASSERT(uidx <= vs_limit);\n\n\t/* Handle change in value stack top.  Respect value stack\n\t * initialization policy: 'undefined' above top.  Note that\n\t * DECREF may cause a side effect that reallocates valstack,\n\t * so must relookup after DECREF.\n\t */\n\n\tif (uidx >= vs_size) {\n\t\t/* Stack size increases or stays the same. */\n#if defined(DUK_USE_ASSERTIONS)\n\t\tduk_uidx_t count;\n\n\t\tcount = uidx - vs_size;\n\t\twhile (count != 0) {\n\t\t\tcount--;\n\t\t\ttv = thr->valstack_top + count;\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_UNDEFINED(tv));\n\t\t}\n#endif\n\t\tthr->valstack_top = thr->valstack_bottom + uidx;\n\t} else {\n\t\t/* Stack size decreases. */\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\t\tduk_uidx_t count;\n\t\tduk_tval *tv_end;\n\n\t\tcount = vs_size - uidx;\n\t\tDUK_ASSERT(count > 0);\n\t\ttv = thr->valstack_top;\n\t\ttv_end = tv - count;\n\t\tDUK_ASSERT(tv > tv_end);  /* Because count > 0. */\n\t\tdo {\n\t\t\ttv--;\n\t\t\tDUK_ASSERT(tv >= thr->valstack_bottom);\n\t\t\tDUK_TVAL_SET_UNDEFINED_UPDREF_NORZ(thr, tv);\n\t\t} while (tv != tv_end);\n\t\tthr->valstack_top = tv_end;\n\t\tDUK_REFZERO_CHECK_FAST(thr);\n#else  /* DUK_USE_REFERENCE_COUNTING */\n\t\tduk_uidx_t count;\n\t\tduk_tval *tv_end;\n\n\t\tcount = vs_size - uidx;\n\t\ttv = thr->valstack_top;\n\t\ttv_end = tv - count;\n\t\tDUK_ASSERT(tv > tv_end);\n\t\tdo {\n\t\t\ttv--;\n\t\t\tDUK_TVAL_SET_UNDEFINED(tv);\n\t\t} while (tv != tv_end);\n\t\tthr->valstack_top = tv_end;\n#endif  /* DUK_USE_REFERENCE_COUNTING */\n\t}\n}\n\nDUK_EXTERNAL duk_idx_t duk_get_top_index(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_idx_t ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tret = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom) - 1;\n\tif (DUK_UNLIKELY(ret < 0)) {\n\t\t/* Return invalid index; if caller uses this without checking\n\t\t * in another API call, the index won't map to a valid stack\n\t\t * entry.\n\t\t */\n\t\treturn DUK_INVALID_INDEX;\n\t}\n\treturn ret;\n}\n\n/* Internal variant: call assumes there is at least one element on the value\n * stack frame; this is only asserted for.\n */\nDUK_INTERNAL duk_idx_t duk_get_top_index_unsafe(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_idx_t ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tret = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom) - 1;\n\treturn ret;\n}\n\nDUK_EXTERNAL duk_idx_t duk_require_top_index(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_idx_t ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tret = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom) - 1;\n\tif (DUK_UNLIKELY(ret < 0)) {\n\t\tDUK_ERROR_RANGE_INDEX(thr, -1);\n\t\treturn 0;  /* unreachable */\n\t}\n\treturn ret;\n}\n\n/*\n *  Value stack resizing.\n *\n *  This resizing happens above the current \"top\": the value stack can be\n *  grown or shrunk, but the \"top\" is not affected.  The value stack cannot\n *  be resized to a size below the current \"top\".\n *\n *  The low level reallocation primitive must carefully recompute all value\n *  stack pointers, and must also work if ALL pointers are NULL.  The resize\n *  is quite tricky because the valstack realloc may cause a mark-and-sweep,\n *  which may run finalizers.  Running finalizers may resize the valstack\n *  recursively (the same value stack we're working on).  So, after realloc\n *  returns, we know that the valstack \"top\" should still be the same (there\n *  should not be live values above the \"top\"), but its underlying size and\n *  pointer may have changed.\n */\n\n/* XXX: perhaps refactor this to allow caller to specify some parameters, or\n * at least a 'compact' flag which skips any spare or round-up .. useful for\n * emergency gc.\n */\n\nDUK_LOCAL duk_bool_t duk__resize_valstack(duk_context *ctx, duk_size_t new_size) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_ptrdiff_t old_bottom_offset;\n\tduk_ptrdiff_t old_top_offset;\n\tduk_ptrdiff_t old_end_offset_post;\n#if defined(DUK_USE_DEBUG)\n\tduk_ptrdiff_t old_end_offset_pre;\n\tduk_tval *old_valstack_pre;\n\tduk_tval *old_valstack_post;\n#endif\n\tduk_tval *new_valstack;\n\tduk_size_t new_alloc_size;\n\tduk_tval *p;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->valstack_bottom >= thr->valstack);\n\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n\tDUK_ASSERT(thr->valstack_end >= thr->valstack_top);\n\tDUK_ASSERT((duk_size_t) (thr->valstack_top - thr->valstack) <= new_size);  /* can't resize below 'top' */\n\tDUK_ASSERT(new_size <= thr->valstack_max);  /* valstack limit caller has check, prevents wrapping */\n\tDUK_ASSERT(new_size <= DUK_SIZE_MAX / sizeof(duk_tval));  /* specific assert for wrapping */\n\n\t/* get pointer offsets for tweaking below */\n\told_bottom_offset = (((duk_uint8_t *) thr->valstack_bottom) - ((duk_uint8_t *) thr->valstack));\n\told_top_offset = (((duk_uint8_t *) thr->valstack_top) - ((duk_uint8_t *) thr->valstack));\n#if defined(DUK_USE_DEBUG)\n\told_end_offset_pre = (((duk_uint8_t *) thr->valstack_end) - ((duk_uint8_t *) thr->valstack));  /* not very useful, used for debugging */\n\told_valstack_pre = thr->valstack;\n#endif\n\n\t/* Allocate a new valstack.\n\t *\n\t * Note: cannot use a plain DUK_REALLOC() because a mark-and-sweep may\n\t * invalidate the original thr->valstack base pointer inside the realloc\n\t * process.  See doc/memory-management.rst.\n\t */\n\n\tnew_alloc_size = sizeof(duk_tval) * new_size;\n\tnew_valstack = (duk_tval *) DUK_REALLOC_INDIRECT(thr->heap, duk_hthread_get_valstack_ptr, (void *) thr, new_alloc_size);\n\tif (DUK_UNLIKELY(new_valstack == NULL)) {\n\t\t/* Because new_size != 0, if condition doesn't need to be\n\t\t * (new_valstack != NULL || new_size == 0).\n\t\t */\n\t\tDUK_ASSERT(new_size != 0);\n\t\tDUK_D(DUK_DPRINT(\"failed to resize valstack to %lu entries (%lu bytes)\",\n\t\t                 (unsigned long) new_size, (unsigned long) new_alloc_size));\n\t\treturn 0;\n\t}\n\n\t/* Note: the realloc may have triggered a mark-and-sweep which may\n\t * have resized our valstack internally.  However, the mark-and-sweep\n\t * MUST NOT leave the stack bottom/top in a different state.  Particular\n\t * assumptions and facts:\n\t *\n\t *   - The thr->valstack pointer may be different after realloc,\n\t *     and the offset between thr->valstack_end <-> thr->valstack\n\t *     may have changed.\n\t *   - The offset between thr->valstack_bottom <-> thr->valstack\n\t *     and thr->valstack_top <-> thr->valstack MUST NOT have changed,\n\t *     because mark-and-sweep must adhere to a strict stack policy.\n\t *     In other words, logical bottom and top MUST NOT have changed.\n\t *   - All values above the top are unreachable but are initialized\n\t *     to UNDEFINED, up to the post-realloc valstack_end.\n\t *   - 'old_end_offset' must be computed after realloc to be correct.\n\t */\n\n\tDUK_ASSERT((((duk_uint8_t *) thr->valstack_bottom) - ((duk_uint8_t *) thr->valstack)) == old_bottom_offset);\n\tDUK_ASSERT((((duk_uint8_t *) thr->valstack_top) - ((duk_uint8_t *) thr->valstack)) == old_top_offset);\n\n\t/* success, fixup pointers */\n\told_end_offset_post = (((duk_uint8_t *) thr->valstack_end) - ((duk_uint8_t *) thr->valstack));  /* must be computed after realloc */\n#if defined(DUK_USE_DEBUG)\n\told_valstack_post = thr->valstack;\n#endif\n\tthr->valstack = new_valstack;\n\tthr->valstack_end = new_valstack + new_size;\n#if !defined(DUK_USE_PREFER_SIZE)\n\tthr->valstack_size = new_size;\n#endif\n\tthr->valstack_bottom = (duk_tval *) (void *) ((duk_uint8_t *) new_valstack + old_bottom_offset);\n\tthr->valstack_top = (duk_tval *) (void *) ((duk_uint8_t *) new_valstack + old_top_offset);\n\n\tDUK_ASSERT(thr->valstack_bottom >= thr->valstack);\n\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n\tDUK_ASSERT(thr->valstack_end >= thr->valstack_top);\n\n\t/* useful for debugging */\n#if defined(DUK_USE_DEBUG)\n\tif (old_end_offset_pre != old_end_offset_post) {\n\t\tDUK_D(DUK_DPRINT(\"valstack was resized during valstack_resize(), probably by mark-and-sweep; \"\n\t\t                 \"end offset changed: %lu -> %lu\",\n\t\t                 (unsigned long) old_end_offset_pre,\n\t\t                 (unsigned long) old_end_offset_post));\n\t}\n\tif (old_valstack_pre != old_valstack_post) {\n\t\tDUK_D(DUK_DPRINT(\"valstack pointer changed during valstack_resize(), probably by mark-and-sweep: %p -> %p\",\n\t\t                 (void *) old_valstack_pre,\n\t\t                 (void *) old_valstack_post));\n\t}\n#endif\n\n\tDUK_DD(DUK_DDPRINT(\"resized valstack to %lu elements (%lu bytes), bottom=%ld, top=%ld, \"\n\t                   \"new pointers: start=%p end=%p bottom=%p top=%p\",\n\t                   (unsigned long) new_size, (unsigned long) new_alloc_size,\n\t                   (long) (thr->valstack_bottom - thr->valstack),\n\t                   (long) (thr->valstack_top - thr->valstack),\n\t                   (void *) thr->valstack, (void *) thr->valstack_end,\n\t                   (void *) thr->valstack_bottom, (void *) thr->valstack_top));\n\n\t/* Init newly allocated slots (only). */\n\tp = (duk_tval *) (void *) ((duk_uint8_t *) thr->valstack + old_end_offset_post);\n\twhile (p < thr->valstack_end) {\n\t\t/* Never executed if new size is smaller. */\n\t\tDUK_TVAL_SET_UNDEFINED(p);\n\t\tp++;\n\t}\n\n\t/* Assert for value stack initialization policy. */\n#if defined(DUK_USE_ASSERTIONS)\n\tp = thr->valstack_top;\n\twhile (p < thr->valstack_end) {\n\t\tDUK_ASSERT(DUK_TVAL_IS_UNDEFINED(p));\n\t\tp++;\n\t}\n#endif\n\n\treturn 1;\n}\n\nDUK_LOCAL DUK_COLD DUK_NOINLINE duk_bool_t duk__valstack_do_resize(duk_context *ctx,\n                                                                   duk_size_t min_new_size,\n                                                                   duk_small_uint_t flags) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_size_t old_size;\n\tduk_size_t new_size;\n\tduk_bool_t is_shrink;\n\tduk_small_uint_t compact_flag = (flags & DUK_VSRESIZE_FLAG_COMPACT);\n\tduk_small_uint_t throw_flag = (flags & DUK_VSRESIZE_FLAG_THROW);\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->valstack_bottom >= thr->valstack);\n\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n\tDUK_ASSERT(thr->valstack_end >= thr->valstack_top);\n\n#if defined(DUK_USE_PREFER_SIZE)\n\told_size = (duk_size_t) (thr->valstack_end - thr->valstack);\n#else\n\tDUK_ASSERT((duk_size_t) (thr->valstack_end - thr->valstack) == thr->valstack_size);\n\told_size = thr->valstack_size;\n#endif\n\n\tif (min_new_size <= old_size) {\n\t\tis_shrink = 1;\n\t} else {\n\t\tis_shrink = 0;\n\t}\n\n\tnew_size = min_new_size;\n\tif (!compact_flag) {\n\t\tif (is_shrink) {\n\t\t\t/* shrink case; leave some spare */\n\t\t\tnew_size += DUK_VALSTACK_SHRINK_SPARE;\n\t\t}\n\n\t\t/* round up roughly to next 'grow step' */\n\t\tnew_size = (new_size / DUK_VALSTACK_GROW_STEP + 1) * DUK_VALSTACK_GROW_STEP;\n\t}\n\n\tDUK_DD(DUK_DDPRINT(\"want to %s valstack: %lu -> %lu elements (min_new_size %lu)\",\n\t                   (const char *) (new_size > old_size ? \"grow\" : \"shrink\"),\n\t                   (unsigned long) old_size, (unsigned long) new_size,\n\t                   (unsigned long) min_new_size));\n\n\tif (DUK_UNLIKELY(new_size > thr->valstack_max)) {\n\t\t/* Note: may be triggered even if minimal new_size would not reach the limit,\n\t\t * plan limit accordingly (taking DUK_VALSTACK_GROW_STEP into account).\n\t\t */\n\t\tif (throw_flag) {\n\t\t\tDUK_ERROR_RANGE(thr, DUK_STR_VALSTACK_LIMIT);\n\t\t} else {\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\t/*\n\t *  When resizing the valstack, a mark-and-sweep may be triggered for\n\t *  the allocation of the new valstack.  If the mark-and-sweep needs\n\t *  to use our thread for something, it may cause *the same valstack*\n\t *  to be resized recursively.  This happens e.g. when mark-and-sweep\n\t *  finalizers are called.  This is taken into account carefully in\n\t *  duk__resize_valstack().\n\t *\n\t *  'new_size' is known to be <= valstack_max, which ensures that\n\t *  size_t and pointer arithmetic won't wrap in duk__resize_valstack().\n\t */\n\n\tif (DUK_UNLIKELY(!duk__resize_valstack(ctx, new_size))) {\n\t\tif (is_shrink) {\n\t\t\tDUK_DD(DUK_DDPRINT(\"valstack resize failed, but is a shrink, ignore\"));\n\t\t\treturn 1;\n\t\t}\n\n\t\tDUK_DD(DUK_DDPRINT(\"valstack resize failed\"));\n\n\t\tif (throw_flag) {\n\t\t\tDUK_ERROR_ALLOC_FAILED(thr);\n\t\t} else {\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"valstack resize successful\"));\n\treturn 1;\n}\n\nDUK_INTERNAL duk_bool_t duk_valstack_resize_raw(duk_context *ctx,\n                                                duk_size_t min_new_size,\n                                                duk_small_uint_t flags) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_size_t old_size;\n\n\tDUK_DDD(DUK_DDDPRINT(\"check valstack resize: min_new_size=%lu, curr_size=%ld, curr_top=%ld, \"\n\t                     \"curr_bottom=%ld, flags=%lx\",\n\t                     (unsigned long) min_new_size,\n\t                     (long) (thr->valstack_end - thr->valstack),\n\t                     (long) (thr->valstack_top - thr->valstack),\n\t                     (long) (thr->valstack_bottom - thr->valstack),\n\t                     (unsigned long) flags));\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->valstack_bottom >= thr->valstack);\n\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n\tDUK_ASSERT(thr->valstack_end >= thr->valstack_top);\n\n#if defined(DUK_USE_PREFER_SIZE)\n\told_size = (duk_size_t) (thr->valstack_end - thr->valstack);\n#else\n\tDUK_ASSERT((duk_size_t) (thr->valstack_end - thr->valstack) == thr->valstack_size);\n\told_size = thr->valstack_size;\n#endif\n\n\tif (DUK_LIKELY(min_new_size <= old_size)) {\n\t\tif (DUK_LIKELY((flags & DUK_VSRESIZE_FLAG_SHRINK) == 0 ||\n\t\t               old_size - min_new_size < DUK_VALSTACK_SHRINK_THRESHOLD)) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"no need to grow or shrink valstack\"));\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\treturn duk__valstack_do_resize(ctx, min_new_size, flags);\n}\n\nDUK_EXTERNAL duk_bool_t duk_check_stack(duk_context *ctx, duk_idx_t extra) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_size_t min_new_size;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr != NULL);\n\n\tif (DUK_UNLIKELY(extra < 0)) {\n\t\t/* Clamping to zero makes the API more robust to calling code\n\t\t * calculation errors.\n\t\t */\n\t\textra = 0;\n\t}\n\n\tmin_new_size = (thr->valstack_top - thr->valstack) + extra + DUK_VALSTACK_INTERNAL_EXTRA;\n\treturn duk_valstack_resize_raw(ctx,\n\t                               min_new_size,         /* min_new_size */\n\t                               0 /* no shrink */ |   /* flags */\n\t                               0 /* no compact */ |\n\t                               0 /* no throw */);\n}\n\nDUK_EXTERNAL void duk_require_stack(duk_context *ctx, duk_idx_t extra) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_size_t min_new_size;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr != NULL);\n\n\tif (DUK_UNLIKELY(extra < 0)) {\n\t\t/* Clamping to zero makes the API more robust to calling code\n\t\t * calculation errors.\n\t\t */\n\t\textra = 0;\n\t}\n\n\tmin_new_size = (thr->valstack_top - thr->valstack) + extra + DUK_VALSTACK_INTERNAL_EXTRA;\n\t(void) duk_valstack_resize_raw(ctx,\n\t                               min_new_size,  /* min_new_size */\n\t                               0 /* no shrink */ |   /* flags */\n\t                               0 /* no compact */ |\n\t                               DUK_VSRESIZE_FLAG_THROW);\n}\n\nDUK_EXTERNAL duk_bool_t duk_check_stack_top(duk_context *ctx, duk_idx_t top) {\n\tduk_size_t min_new_size;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tif (DUK_UNLIKELY(top < 0)) {\n\t\t/* Clamping to zero makes the API more robust to calling code\n\t\t * calculation errors.\n\t\t */\n\t\ttop = 0;\n\t}\n\n\tmin_new_size = top + DUK_VALSTACK_INTERNAL_EXTRA;\n\treturn duk_valstack_resize_raw(ctx,\n\t                               min_new_size,  /* min_new_size */\n\t                               0 /* no shrink */ |   /* flags */\n\t                               0 /* no compact */ |\n\t                               0 /* no throw */);\n}\n\nDUK_EXTERNAL void duk_require_stack_top(duk_context *ctx, duk_idx_t top) {\n\tduk_size_t min_new_size;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tif (DUK_UNLIKELY(top < 0)) {\n\t\t/* Clamping to zero makes the API more robust to calling code\n\t\t * calculation errors.\n\t\t */\n\t\ttop = 0;\n\t}\n\n\tmin_new_size = top + DUK_VALSTACK_INTERNAL_EXTRA;\n\t(void) duk_valstack_resize_raw(ctx,\n\t                               min_new_size,  /* min_new_size */\n\t                               0 /* no shrink */ |   /* flags */\n\t                               0 /* no compact */ |\n\t                               DUK_VSRESIZE_FLAG_THROW);\n}\n\n/*\n *  Basic stack manipulation: swap, dup, insert, replace, etc\n */\n\nDUK_EXTERNAL void duk_swap(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2) {\n\tduk_tval *tv1;\n\tduk_tval *tv2;\n\tduk_tval tv_tmp;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv1 = duk_require_tval(ctx, idx1);\n\tDUK_ASSERT(tv1 != NULL);\n\ttv2 = duk_require_tval(ctx, idx2);\n\tDUK_ASSERT(tv2 != NULL);\n\n\t/* If tv1==tv2 this is a NOP, no check is needed */\n\tDUK_TVAL_SET_TVAL(&tv_tmp, tv1);\n\tDUK_TVAL_SET_TVAL(tv1, tv2);\n\tDUK_TVAL_SET_TVAL(tv2, &tv_tmp);\n}\n\nDUK_EXTERNAL void duk_swap_top(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tduk_swap(ctx, idx, -1);\n}\n\nDUK_EXTERNAL void duk_dup(duk_context *ctx, duk_idx_t from_idx) {\n\tduk_hthread *thr;\n\tduk_tval *tv_from;\n\tduk_tval *tv_to;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\tDUK__CHECK_SPACE();\n\n\ttv_from = duk_require_tval(ctx, from_idx);\n\ttv_to = thr->valstack_top++;\n\tDUK_ASSERT(tv_from != NULL);\n\tDUK_ASSERT(tv_to != NULL);\n\tDUK_TVAL_SET_TVAL(tv_to, tv_from);\n\tDUK_TVAL_INCREF(thr, tv_to);  /* no side effects */\n}\n\nDUK_EXTERNAL void duk_dup_top(duk_context *ctx) {\n#if defined(DUK_USE_PREFER_SIZE)\n\tduk_dup(ctx, -1);\n#else\n\tduk_hthread *thr;\n\tduk_tval *tv_from;\n\tduk_tval *tv_to;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\tDUK__CHECK_SPACE();\n\n\tif (DUK_UNLIKELY(thr->valstack_top - thr->valstack_bottom <= 0)) {\n\t\tDUK_ERROR_RANGE_INDEX(thr, -1);\n\t\treturn;  /* unreachable */\n\t}\n\ttv_from = thr->valstack_top - 1;\n\ttv_to = thr->valstack_top++;\n\tDUK_ASSERT(tv_from != NULL);\n\tDUK_ASSERT(tv_to != NULL);\n\tDUK_TVAL_SET_TVAL(tv_to, tv_from);\n\tDUK_TVAL_INCREF(thr, tv_to);  /* no side effects */\n#endif\n}\n\nDUK_INTERNAL void duk_dup_0(duk_context *ctx) {\n\tduk_dup(ctx, 0);\n}\nDUK_INTERNAL void duk_dup_1(duk_context *ctx) {\n\tduk_dup(ctx, 1);\n}\nDUK_INTERNAL void duk_dup_2(duk_context *ctx) {\n\tduk_dup(ctx, 2);\n}\nDUK_INTERNAL void duk_dup_m2(duk_context *ctx) {\n\tduk_dup(ctx, -2);\n}\nDUK_INTERNAL void duk_dup_m3(duk_context *ctx) {\n\tduk_dup(ctx, -3);\n}\nDUK_INTERNAL void duk_dup_m4(duk_context *ctx) {\n\tduk_dup(ctx, -4);\n}\n\nDUK_EXTERNAL void duk_insert(duk_context *ctx, duk_idx_t to_idx) {\n\tduk_tval *p;\n\tduk_tval *q;\n\tduk_tval tv_tmp;\n\tduk_size_t nbytes;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tp = duk_require_tval(ctx, to_idx);\n\tDUK_ASSERT(p != NULL);\n\tq = duk_require_tval(ctx, -1);\n\tDUK_ASSERT(q != NULL);\n\n\tDUK_ASSERT(q >= p);\n\n\t/*              nbytes\n\t *           <--------->\n\t *    [ ... | p | x | x | q ]\n\t * => [ ... | q | p | x | x ]\n\t */\n\n\tnbytes = (duk_size_t) (((duk_uint8_t *) q) - ((duk_uint8_t *) p));  /* Note: 'q' is top-1 */\n\n\tDUK_DDD(DUK_DDDPRINT(\"duk_insert: to_idx=%ld, p=%p, q=%p, nbytes=%lu\",\n\t                     (long) to_idx, (void *) p, (void *) q, (unsigned long) nbytes));\n\n\t/* No net refcount changes. */\n\n\tif (nbytes > 0) {\n\t\tDUK_TVAL_SET_TVAL(&tv_tmp, q);\n\t\tDUK_ASSERT(nbytes > 0);\n\t\tDUK_MEMMOVE((void *) (p + 1), (const void *) p, (size_t) nbytes);\n\t\tDUK_TVAL_SET_TVAL(p, &tv_tmp);\n\t} else {\n\t\t/* nop: insert top to top */\n\t\tDUK_ASSERT(nbytes == 0);\n\t\tDUK_ASSERT(p == q);\n\t}\n}\n\nDUK_EXTERNAL void duk_replace(duk_context *ctx, duk_idx_t to_idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv1;\n\tduk_tval *tv2;\n\tduk_tval tv_tmp;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv1 = duk_require_tval(ctx, -1);\n\tDUK_ASSERT(tv1 != NULL);\n\ttv2 = duk_require_tval(ctx, to_idx);\n\tDUK_ASSERT(tv2 != NULL);\n\n\t/* For tv1 == tv2, both pointing to stack top, the end result\n\t * is same as duk_pop(ctx).\n\t */\n\tDUK_TVAL_SET_TVAL(&tv_tmp, tv2);\n\tDUK_TVAL_SET_TVAL(tv2, tv1);\n\tDUK_TVAL_SET_UNDEFINED(tv1);\n\tthr->valstack_top--;\n\tDUK_TVAL_DECREF(thr, &tv_tmp);  /* side effects */\n}\n\nDUK_EXTERNAL void duk_copy(duk_context *ctx, duk_idx_t from_idx, duk_idx_t to_idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv1;\n\tduk_tval *tv2;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_UNREF(thr);  /* w/o refcounting */\n\n\ttv1 = duk_require_tval(ctx, from_idx);\n\tDUK_ASSERT(tv1 != NULL);\n\ttv2 = duk_require_tval(ctx, to_idx);\n\tDUK_ASSERT(tv2 != NULL);\n\n\t/* For tv1 == tv2, this is a no-op (no explicit check needed). */\n\tDUK_TVAL_SET_TVAL_UPDREF(thr, tv2, tv1);  /* side effects */\n}\n\nDUK_EXTERNAL void duk_remove(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *p;\n\tduk_tval *q;\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tduk_tval tv_tmp;\n#endif\n\tduk_size_t nbytes;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tp = duk_require_tval(ctx, idx);\n\tDUK_ASSERT(p != NULL);\n\tq = duk_require_tval(ctx, -1);\n\tDUK_ASSERT(q != NULL);\n\n\tDUK_ASSERT(q >= p);\n\n\t/*              nbytes            zero size case\n\t *           <--------->\n\t *    [ ... | p | x | x | q ]     [ ... | p==q ]\n\t * => [ ... | x | x | q ]         [ ... ]\n\t */\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\t/* use a temp: decref only when valstack reachable values are correct */\n\tDUK_TVAL_SET_TVAL(&tv_tmp, p);\n#endif\n\n\tnbytes = (duk_size_t) (((duk_uint8_t *) q) - ((duk_uint8_t *) p));  /* Note: 'q' is top-1 */\n\tDUK_MEMMOVE((void *) p, (const void *) (p + 1), (size_t) nbytes);  /* zero size not an issue: pointers are valid */\n\n\tDUK_TVAL_SET_UNDEFINED(q);\n\tthr->valstack_top--;\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tDUK_TVAL_DECREF(thr, &tv_tmp);  /* side effects */\n#endif\n}\n\nDUK_INTERNAL_DECL void duk_remove_m2(duk_context *ctx) {\n\tduk_remove(ctx, -2);\n}\n\n/*\n *  Stack slice primitives\n */\n\nDUK_EXTERNAL void duk_xcopymove_raw(duk_context *to_ctx, duk_context *from_ctx, duk_idx_t count, duk_bool_t is_copy) {\n\tduk_hthread *to_thr = (duk_hthread *) to_ctx;\n\tduk_hthread *from_thr = (duk_hthread *) from_ctx;\n\tvoid *src;\n\tduk_size_t nbytes;\n\tduk_tval *p;\n\tduk_tval *q;\n\n\t/* XXX: several pointer comparison issues here */\n\n\tDUK_ASSERT_CTX_VALID(to_ctx);\n\tDUK_ASSERT_CTX_VALID(from_ctx);\n\tDUK_ASSERT(to_ctx != NULL);\n\tDUK_ASSERT(from_ctx != NULL);\n\n\tif (DUK_UNLIKELY(to_ctx == from_ctx)) {\n\t\tDUK_ERROR_TYPE(to_thr, DUK_STR_INVALID_CONTEXT);\n\t\treturn;\n\t}\n\tif (DUK_UNLIKELY((count < 0) ||\n\t                 (count > (duk_idx_t) to_thr->valstack_max))) {\n\t\t/* Maximum value check ensures 'nbytes' won't wrap below. */\n\t\tDUK_ERROR_RANGE_INVALID_COUNT(to_thr);\n\t\treturn;\n\t}\n\n\tnbytes = sizeof(duk_tval) * count;\n\tif (DUK_UNLIKELY(nbytes == 0)) {\n\t\treturn;\n\t}\n\tDUK_ASSERT(to_thr->valstack_top <= to_thr->valstack_end);\n\tif (DUK_UNLIKELY((duk_size_t) ((duk_uint8_t *) to_thr->valstack_end - (duk_uint8_t *) to_thr->valstack_top) < nbytes)) {\n\t\tDUK_ERROR_RANGE_PUSH_BEYOND(to_thr);\n\t}\n\tsrc = (void *) ((duk_uint8_t *) from_thr->valstack_top - nbytes);\n\tif (DUK_UNLIKELY(src < (void *) from_thr->valstack_bottom)) {\n\t\tDUK_ERROR_RANGE_INVALID_COUNT(to_thr);\n\t}\n\n\t/* copy values (no overlap even if to_ctx == from_ctx; that's not\n\t * allowed now anyway)\n\t */\n\tDUK_ASSERT(nbytes > 0);\n\tDUK_MEMCPY((void *) to_thr->valstack_top, (const void *) src, (size_t) nbytes);\n\n\tp = to_thr->valstack_top;\n\tto_thr->valstack_top = (duk_tval *) (void *) (((duk_uint8_t *) p) + nbytes);\n\n\tif (is_copy) {\n\t\t/* Incref copies, keep originals. */\n\t\tq = to_thr->valstack_top;\n\t\twhile (p < q) {\n\t\t\tDUK_TVAL_INCREF(to_thr, p);  /* no side effects */\n\t\t\tp++;\n\t\t}\n\t} else {\n\t\t/* No net refcount change. */\n\t\tp = from_thr->valstack_top;\n\t\tq = (duk_tval *) (void *) (((duk_uint8_t *) p) - nbytes);\n\t\tfrom_thr->valstack_top = q;\n\n\t\twhile (p > q) {\n\t\t\tp--;\n\t\t\tDUK_TVAL_SET_UNDEFINED(p);\n\t\t\t/* XXX: fast primitive to set a bunch of values to UNDEFINED */\n\t\t}\n\t}\n}\n\n/*\n *  Get/opt/require\n */\n\nDUK_EXTERNAL void duk_require_undefined(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tif (DUK_UNLIKELY(!DUK_TVAL_IS_UNDEFINED(tv))) {\n\t\tDUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, \"undefined\", DUK_STR_NOT_UNDEFINED);\n\t}\n}\n\nDUK_EXTERNAL void duk_require_null(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tif (DUK_UNLIKELY(!DUK_TVAL_IS_NULL(tv))) {\n\t\tDUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, \"null\", DUK_STR_NOT_NULL);\n\t}\n}\n\nDUK_LOCAL DUK_ALWAYS_INLINE duk_bool_t duk__get_boolean_raw(duk_context *ctx, duk_idx_t idx, duk_bool_t def_value) {\n\tduk_bool_t ret;\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tif (DUK_TVAL_IS_BOOLEAN(tv)) {\n\t\tret = DUK_TVAL_GET_BOOLEAN(tv);\n\t\tDUK_ASSERT(ret == 0 || ret == 1);\n\t} else {\n\t\tret = def_value;\n\t\t/* Not guaranteed to be 0 or 1. */\n\t}\n\n\treturn ret;\n}\n\nDUK_EXTERNAL duk_bool_t duk_get_boolean(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\treturn duk__get_boolean_raw(ctx, idx, 0);  /* default: false */\n}\n\nDUK_EXTERNAL duk_bool_t duk_get_boolean_default(duk_context *ctx, duk_idx_t idx, duk_bool_t def_value) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\treturn duk__get_boolean_raw(ctx, idx, def_value);\n}\n\nDUK_EXTERNAL duk_bool_t duk_require_boolean(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\tduk_bool_t ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tif (DUK_LIKELY(DUK_TVAL_IS_BOOLEAN(tv))) {\n\t\tret = DUK_TVAL_GET_BOOLEAN(tv);\n\t\tDUK_ASSERT(ret == 0 || ret == 1);\n\t\treturn ret;\n\t} else {\n\t\tDUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, \"boolean\", DUK_STR_NOT_BOOLEAN);\n\t}\n}\n\nDUK_EXTERNAL duk_bool_t duk_opt_boolean(duk_context *ctx, duk_idx_t idx, duk_bool_t def_value) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tif (duk_check_type_mask(ctx, idx, DUK_TYPE_MASK_NONE | DUK_TYPE_MASK_UNDEFINED)) {\n\t\treturn def_value;\n\t}\n\treturn duk_require_boolean(ctx, idx);\n}\n\nDUK_LOCAL DUK_ALWAYS_INLINE duk_double_t duk__get_number_raw(duk_context *ctx, duk_idx_t idx, duk_double_t def_value) {\n\tduk_double_union ret;\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n#if defined(DUK_USE_FASTINT)\n\tif (DUK_TVAL_IS_FASTINT(tv)) {\n\t\tret.d = (duk_double_t) DUK_TVAL_GET_FASTINT(tv);  /* XXX: cast trick */\n\t}\n\telse\n#endif\n\tif (DUK_TVAL_IS_DOUBLE(tv)) {\n\t\t/* When using packed duk_tval, number must be in NaN-normalized form\n\t\t * for it to be a duk_tval, so no need to normalize.  NOP for unpacked\n\t\t * duk_tval.\n\t\t */\n\t\tret.d = DUK_TVAL_GET_DOUBLE(tv);\n\t\tDUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&ret));\n\t} else {\n\t\tret.d = def_value;\n\t\t/* Default value (including NaN) may not be normalized. */\n\t}\n\n\treturn ret.d;\n}\n\nDUK_EXTERNAL duk_double_t duk_get_number(duk_context *ctx, duk_idx_t idx) {\n\treturn duk__get_number_raw(ctx, idx, DUK_DOUBLE_NAN);  /* default: NaN */\n}\n\nDUK_EXTERNAL duk_double_t duk_get_number_default(duk_context *ctx, duk_idx_t idx, duk_double_t def_value) {\n\treturn duk__get_number_raw(ctx, idx, def_value);\n}\n\nDUK_EXTERNAL duk_double_t duk_require_number(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\tduk_double_union ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tif (DUK_UNLIKELY(!DUK_TVAL_IS_NUMBER(tv))) {\n\t\tDUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, \"number\", DUK_STR_NOT_NUMBER);\n\t}\n\n\tret.d = DUK_TVAL_GET_NUMBER(tv);\n\n\t/* When using packed duk_tval, number must be in NaN-normalized form\n\t * for it to be a duk_tval, so no need to normalize.  NOP for unpacked\n\t * duk_tval.\n\t */\n\tDUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&ret));\n\treturn ret.d;\n}\n\nDUK_EXTERNAL duk_double_t duk_opt_number(duk_context *ctx, duk_idx_t idx, duk_double_t def_value) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tif (duk_check_type_mask(ctx, idx, DUK_TYPE_MASK_NONE | DUK_TYPE_MASK_UNDEFINED)) {\n\t\t/* User provided default is not NaN normalized. */\n\t\treturn def_value;\n\t}\n\treturn duk_require_number(ctx, idx);\n}\n\nDUK_EXTERNAL duk_int_t duk_get_int(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\treturn (duk_int_t) duk__api_coerce_d2i(ctx, idx, 0 /*def_value*/, 0 /*require*/);\n}\n\nDUK_EXTERNAL duk_uint_t duk_get_uint(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\treturn (duk_uint_t) duk__api_coerce_d2ui(ctx, idx, 0 /*def_value*/, 0 /*require*/);\n}\n\nDUK_EXTERNAL duk_int_t duk_get_int_default(duk_context *ctx, duk_idx_t idx, duk_int_t def_value) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\treturn (duk_int_t) duk__api_coerce_d2i(ctx, idx, def_value, 0 /*require*/);\n}\n\nDUK_EXTERNAL duk_uint_t duk_get_uint_default(duk_context *ctx, duk_idx_t idx, duk_uint_t def_value) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\treturn (duk_uint_t) duk__api_coerce_d2ui(ctx, idx, def_value, 0 /*require*/);\n}\n\nDUK_EXTERNAL duk_int_t duk_require_int(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\treturn (duk_int_t) duk__api_coerce_d2i(ctx, idx, 0 /*def_value*/, 1 /*require*/);\n}\n\nDUK_EXTERNAL duk_uint_t duk_require_uint(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\treturn (duk_uint_t) duk__api_coerce_d2ui(ctx, idx, 0 /*def_value*/, 1 /*require*/);\n}\n\nDUK_EXTERNAL duk_int_t duk_opt_int(duk_context *ctx, duk_idx_t idx, duk_int_t def_value) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tif (duk_check_type_mask(ctx, idx, DUK_TYPE_MASK_NONE | DUK_TYPE_MASK_UNDEFINED)) {\n\t\treturn def_value;\n\t}\n\treturn duk_require_int(ctx, idx);\n}\n\nDUK_EXTERNAL duk_uint_t duk_opt_uint(duk_context *ctx, duk_idx_t idx, duk_uint_t def_value) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tif (duk_check_type_mask(ctx, idx, DUK_TYPE_MASK_NONE | DUK_TYPE_MASK_UNDEFINED)) {\n\t\treturn def_value;\n\t}\n\treturn duk_require_uint(ctx, idx);\n}\n\nDUK_EXTERNAL const char *duk_get_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len) {\n\tduk_hstring *h;\n\tconst char *ret;\n\tduk_size_t len;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\th = duk_get_hstring(ctx, idx);\n\tif (h != NULL) {\n\t\tlen = DUK_HSTRING_GET_BYTELEN(h);\n\t\tret = (const char *) DUK_HSTRING_GET_DATA(h);\n\t} else {\n\t\tlen = 0;\n\t\tret = NULL;\n\t}\n\n\tif (out_len != NULL) {\n\t\t*out_len = len;\n\t}\n\treturn ret;\n}\n\nDUK_EXTERNAL const char *duk_require_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len) {\n\tduk_hstring *h;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\th = duk_require_hstring(ctx, idx);\n\tDUK_ASSERT(h != NULL);\n\tif (out_len) {\n\t\t*out_len = DUK_HSTRING_GET_BYTELEN(h);\n\t}\n\treturn (const char *) DUK_HSTRING_GET_DATA(h);\n}\n\nDUK_INTERNAL const char *duk_require_lstring_notsymbol(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len) {\n\tduk_hstring *h;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\th = duk_require_hstring_notsymbol(ctx, idx);\n\tDUK_ASSERT(h != NULL);\n\tif (out_len) {\n\t\t*out_len = DUK_HSTRING_GET_BYTELEN(h);\n\t}\n\treturn (const char *) DUK_HSTRING_GET_DATA(h);\n}\n\nDUK_EXTERNAL const char *duk_get_string(duk_context *ctx, duk_idx_t idx) {\n\tduk_hstring *h;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\th = duk_get_hstring(ctx, idx);\n\tif (h != NULL) {\n\t\treturn (const char *) DUK_HSTRING_GET_DATA(h);\n\t} else {\n\t\treturn NULL;\n\t}\n}\n\nDUK_EXTERNAL const char *duk_opt_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len, const char *def_ptr, duk_size_t def_len) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tif (duk_check_type_mask(ctx, idx, DUK_TYPE_MASK_NONE | DUK_TYPE_MASK_UNDEFINED)) {\n\t\tif (out_len != NULL) {\n\t\t\t*out_len = def_len;\n\t\t}\n\t\treturn def_ptr;\n\t}\n\treturn duk_require_lstring(ctx, idx, out_len);\n}\n\nDUK_EXTERNAL const char *duk_opt_string(duk_context *ctx, duk_idx_t idx, const char *def_ptr) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tif (duk_check_type_mask(ctx, idx, DUK_TYPE_MASK_NONE | DUK_TYPE_MASK_UNDEFINED)) {\n\t\treturn def_ptr;\n\t}\n\treturn duk_require_string(ctx, idx);\n}\n\nDUK_EXTERNAL const char *duk_get_lstring_default(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len, const char *def_ptr, duk_size_t def_len) {\n\tduk_hstring *h;\n\tconst char *ret;\n\tduk_size_t len;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\th = duk_get_hstring(ctx, idx);\n\tif (h != NULL) {\n\t\tlen = DUK_HSTRING_GET_BYTELEN(h);\n\t\tret = (const char *) DUK_HSTRING_GET_DATA(h);\n\t} else {\n\t\tlen = def_len;\n\t\tret = def_ptr;\n\t}\n\n\tif (out_len != NULL) {\n\t\t*out_len = len;\n\t}\n\treturn ret;\n}\n\nDUK_EXTERNAL const char *duk_get_string_default(duk_context *ctx, duk_idx_t idx, const char *def_value) {\n\tduk_hstring *h;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\th = duk_get_hstring(ctx, idx);\n\tif (h != NULL) {\n\t\treturn (const char *) DUK_HSTRING_GET_DATA(h);\n\t} else {\n\t\treturn def_value;\n\t}\n}\n\nDUK_INTERNAL const char *duk_get_string_notsymbol(duk_context *ctx, duk_idx_t idx) {\n\tduk_hstring *h;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\th = duk_get_hstring_notsymbol(ctx, idx);\n\tif (h) {\n\t\treturn (const char *) DUK_HSTRING_GET_DATA(h);\n\t} else {\n\t\treturn NULL;\n\t}\n}\n\nDUK_EXTERNAL const char *duk_require_string(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\treturn duk_require_lstring(ctx, idx, NULL);\n}\n\nDUK_INTERNAL const char *duk_require_string_notsymbol(duk_context *ctx, duk_idx_t idx) {\n\tduk_hstring *h;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\th = duk_require_hstring_notsymbol(ctx, idx);\n\tDUK_ASSERT(h != NULL);\n\treturn (const char *) DUK_HSTRING_GET_DATA(h);\n}\n\nDUK_LOCAL void *duk__get_pointer_raw(duk_context *ctx, duk_idx_t idx, void *def_value) {\n\tduk_tval *tv;\n\tvoid *p;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tif (!DUK_TVAL_IS_POINTER(tv)) {\n\t\treturn def_value;\n\t}\n\n\tp = DUK_TVAL_GET_POINTER(tv);  /* may be NULL */\n\treturn p;\n}\n\nDUK_EXTERNAL void *duk_get_pointer(duk_context *ctx, duk_idx_t idx) {\n\treturn duk__get_pointer_raw(ctx, idx, NULL /*def_value*/);\n}\n\nDUK_EXTERNAL void *duk_opt_pointer(duk_context *ctx, duk_idx_t idx, void *def_value) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tif (duk_check_type_mask(ctx, idx, DUK_TYPE_MASK_NONE | DUK_TYPE_MASK_UNDEFINED)) {\n\t\treturn def_value;\n\t}\n\treturn duk_require_pointer(ctx, idx);\n}\n\nDUK_EXTERNAL void *duk_get_pointer_default(duk_context *ctx, duk_idx_t idx, void *def_value) {\n\treturn duk__get_pointer_raw(ctx, idx, def_value);\n}\n\nDUK_EXTERNAL void *duk_require_pointer(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\tvoid *p;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t/* Note: here we must be wary of the fact that a pointer may be\n\t * valid and be a NULL.\n\t */\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tif (DUK_UNLIKELY(!DUK_TVAL_IS_POINTER(tv))) {\n\t\tDUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, \"pointer\", DUK_STR_NOT_POINTER);\n\t}\n\tp = DUK_TVAL_GET_POINTER(tv);  /* may be NULL */\n\treturn p;\n}\n\n#if 0  /*unused*/\nDUK_INTERNAL void *duk_get_voidptr(duk_context *ctx, duk_idx_t idx) {\n\tduk_tval *tv;\n\tduk_heaphdr *h;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tif (!DUK_TVAL_IS_HEAP_ALLOCATED(tv)) {\n\t\treturn NULL;\n\t}\n\n\th = DUK_TVAL_GET_HEAPHDR(tv);\n\tDUK_ASSERT(h != NULL);\n\treturn (void *) h;\n}\n#endif\n\nDUK_LOCAL void *duk__get_buffer_helper(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size, void *def_ptr, duk_size_t def_size, duk_bool_t throw_flag) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hbuffer *h;\n\tvoid *ret;\n\tduk_size_t len;\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_UNREF(thr);\n\n\tif (out_size != NULL) {\n\t\t*out_size = 0;\n\t}\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tif (DUK_LIKELY(DUK_TVAL_IS_BUFFER(tv))) {\n\t\th = DUK_TVAL_GET_BUFFER(tv);\n\t\tDUK_ASSERT(h != NULL);\n\n\t\tlen = DUK_HBUFFER_GET_SIZE(h);\n\t\tret = DUK_HBUFFER_GET_DATA_PTR(thr->heap, h);\n\t} else {\n\t\tif (throw_flag) {\n\t\t\tDUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, \"buffer\", DUK_STR_NOT_BUFFER);\n\t\t}\n\t\tlen = def_size;\n\t\tret = def_ptr;\n\t}\n\n\tif (out_size != NULL) {\n\t\t*out_size = len;\n\t}\n\treturn ret;\n}\n\nDUK_EXTERNAL void *duk_get_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\treturn duk__get_buffer_helper(ctx, idx, out_size, NULL /*def_ptr*/, 0 /*def_size*/, 0 /*throw_flag*/);\n}\n\nDUK_EXTERNAL void *duk_opt_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size, void *def_ptr, duk_size_t def_size) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tif (duk_check_type_mask(ctx, idx, DUK_TYPE_MASK_NONE | DUK_TYPE_MASK_UNDEFINED)) {\n\t\tif (out_size != NULL) {\n\t\t\t*out_size = def_size;\n\t\t}\n\t\treturn def_ptr;\n\t}\n\treturn duk_require_buffer(ctx, idx, out_size);\n}\n\nDUK_EXTERNAL void *duk_get_buffer_default(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size, void *def_ptr, duk_size_t def_len) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\treturn duk__get_buffer_helper(ctx, idx, out_size, def_ptr, def_len, 0 /*throw_flag*/);\n}\n\nDUK_EXTERNAL void *duk_require_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\treturn duk__get_buffer_helper(ctx, idx, out_size, NULL /*def_ptr*/, 0 /*def_size*/, 1 /*throw_flag*/);\n}\n\n/* Get the active buffer data area for a plain buffer or a buffer object.\n * Return NULL if the the value is not a buffer.  Note that a buffer may\n * have a NULL data pointer when its size is zero, the optional 'out_isbuffer'\n * argument allows caller to detect this reliably.\n */\nDUK_INTERNAL void *duk_get_buffer_data_raw(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size, void *def_ptr, duk_size_t def_size, duk_bool_t throw_flag, duk_bool_t *out_isbuffer) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_UNREF(thr);\n\n\tif (out_isbuffer != NULL) {\n\t\t*out_isbuffer = 0;\n\t}\n\tif (out_size != NULL) {\n\t\t*out_size = def_size;\n\t}\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\n\tif (DUK_TVAL_IS_BUFFER(tv)) {\n\t\tduk_hbuffer *h = DUK_TVAL_GET_BUFFER(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\tif (out_size != NULL) {\n\t\t\t*out_size = DUK_HBUFFER_GET_SIZE(h);\n\t\t}\n\t\tif (out_isbuffer != NULL) {\n\t\t\t*out_isbuffer = 1;\n\t\t}\n\t\treturn (void *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h);  /* may be NULL (but only if size is 0) */\n\t}\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n\telse if (DUK_TVAL_IS_OBJECT(tv)) {\n\t\tduk_hobject *h = DUK_TVAL_GET_OBJECT(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\tif (DUK_HOBJECT_IS_BUFOBJ(h)) {\n\t\t\t/* XXX: this is probably a useful shared helper: for a\n\t\t\t * duk_hbufobj, get a validated buffer pointer/length.\n\t\t\t */\n\t\t\tduk_hbufobj *h_bufobj = (duk_hbufobj *) h;\n\t\t\tDUK_ASSERT_HBUFOBJ_VALID(h_bufobj);\n\n\t\t\tif (h_bufobj->buf != NULL &&\n\t\t\t    DUK_HBUFOBJ_VALID_SLICE(h_bufobj)) {\n\t\t\t\tduk_uint8_t *p;\n\n\t\t\t\tp = (duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_bufobj->buf);\n\t\t\t\tif (out_size != NULL) {\n\t\t\t\t\t*out_size = (duk_size_t) h_bufobj->length;\n\t\t\t\t}\n\t\t\t\tif (out_isbuffer != NULL) {\n\t\t\t\t\t*out_isbuffer = 1;\n\t\t\t\t}\n\t\t\t\treturn (void *) (p + h_bufobj->offset);\n\t\t\t}\n\t\t\t/* if slice not fully valid, treat as error */\n\t\t}\n\t}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n\tif (throw_flag) {\n\t\tDUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, \"buffer\", DUK_STR_NOT_BUFFER);\n\t}\n\treturn def_ptr;\n}\n\nDUK_EXTERNAL void *duk_get_buffer_data(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size) {\n\treturn duk_get_buffer_data_raw(ctx, idx, out_size, NULL /*def_ptr*/, 0 /*def_size*/, 0 /*throw_flag*/, NULL);\n}\n\nDUK_EXTERNAL void *duk_get_buffer_data_default(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size, void *def_ptr, duk_size_t def_size) {\n\treturn duk_get_buffer_data_raw(ctx, idx, out_size, def_ptr, def_size, 0 /*throw_flag*/, NULL);\n}\n\nDUK_EXTERNAL void *duk_opt_buffer_data(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size, void *def_ptr, duk_size_t def_size) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tif (duk_check_type_mask(ctx, idx, DUK_TYPE_MASK_NONE | DUK_TYPE_MASK_UNDEFINED)) {\n\t\tif (out_size != NULL) {\n\t\t\t*out_size = def_size;\n\t\t}\n\t\treturn def_ptr;\n\t}\n\treturn duk_require_buffer_data(ctx, idx, out_size);\n}\n\nDUK_EXTERNAL void *duk_require_buffer_data(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size) {\n\treturn duk_get_buffer_data_raw(ctx, idx, out_size, NULL /*def_ptr*/, 0 /*def_size*/, 1 /*throw_flag*/, NULL);\n}\n\n/* Raw helper for getting a value from the stack, checking its tag.\n * The tag cannot be a number because numbers don't have an internal\n * tag in the packed representation.\n */\n\nDUK_LOCAL duk_heaphdr *duk__get_tagged_heaphdr_raw(duk_context *ctx, duk_idx_t idx, duk_uint_t tag) {\n\tduk_tval *tv;\n\tduk_heaphdr *ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tif (DUK_TVAL_GET_TAG(tv) != tag) {\n\t\treturn (duk_heaphdr *) NULL;\n\t}\n\n\tret = DUK_TVAL_GET_HEAPHDR(tv);\n\tDUK_ASSERT(ret != NULL);  /* tagged null pointers should never occur */\n\treturn ret;\n\n}\n\nDUK_INTERNAL duk_hstring *duk_get_hstring(duk_context *ctx, duk_idx_t idx) {\n\treturn (duk_hstring *) duk__get_tagged_heaphdr_raw(ctx, idx, DUK_TAG_STRING);\n}\n\nDUK_INTERNAL duk_hstring *duk_get_hstring_notsymbol(duk_context *ctx, duk_idx_t idx) {\n\tduk_hstring *res = (duk_hstring *) duk__get_tagged_heaphdr_raw(ctx, idx, DUK_TAG_STRING);\n\tif (DUK_UNLIKELY(res && DUK_HSTRING_HAS_SYMBOL(res))) {\n\t\treturn NULL;\n\t}\n\treturn res;\n}\n\nDUK_INTERNAL duk_hstring *duk_require_hstring(duk_context *ctx, duk_idx_t idx) {\n\tduk_hstring *h;\n\th = (duk_hstring *) duk__get_tagged_heaphdr_raw(ctx, idx, DUK_TAG_STRING);\n\tif (DUK_UNLIKELY(h == NULL)) {\n\t\tDUK_ERROR_REQUIRE_TYPE_INDEX(ctx, idx, \"string\", DUK_STR_NOT_STRING);\n\t}\n\treturn h;\n}\n\nDUK_INTERNAL duk_hstring *duk_require_hstring_notsymbol(duk_context *ctx, duk_idx_t idx) {\n\tduk_hstring *h;\n\th = (duk_hstring *) duk__get_tagged_heaphdr_raw(ctx, idx, DUK_TAG_STRING);\n\tif (DUK_UNLIKELY(h == NULL || DUK_HSTRING_HAS_SYMBOL(h))) {\n\t\tDUK_ERROR_REQUIRE_TYPE_INDEX(ctx, idx, \"string\", DUK_STR_NOT_STRING);\n\t}\n\treturn h;\n}\n\nDUK_INTERNAL duk_hobject *duk_get_hobject(duk_context *ctx, duk_idx_t idx) {\n\treturn (duk_hobject *) duk__get_tagged_heaphdr_raw(ctx, idx, DUK_TAG_OBJECT);\n}\n\nDUK_INTERNAL duk_hobject *duk_require_hobject(duk_context *ctx, duk_idx_t idx) {\n\tduk_hobject *h;\n\th = (duk_hobject *) duk__get_tagged_heaphdr_raw(ctx, idx, DUK_TAG_OBJECT);\n\tif (DUK_UNLIKELY(h == NULL)) {\n\t\tDUK_ERROR_REQUIRE_TYPE_INDEX(ctx, idx, \"object\", DUK_STR_NOT_OBJECT);\n\t}\n\treturn h;\n}\n\nDUK_INTERNAL duk_hbuffer *duk_get_hbuffer(duk_context *ctx, duk_idx_t idx) {\n\treturn (duk_hbuffer *) duk__get_tagged_heaphdr_raw(ctx, idx, DUK_TAG_BUFFER);\n}\n\nDUK_INTERNAL duk_hbuffer *duk_require_hbuffer(duk_context *ctx, duk_idx_t idx) {\n\tduk_hbuffer *h;\n\th = (duk_hbuffer *) duk__get_tagged_heaphdr_raw(ctx, idx, DUK_TAG_BUFFER);\n\tif (DUK_UNLIKELY(h == NULL)) {\n\t\tDUK_ERROR_REQUIRE_TYPE_INDEX(ctx, idx, \"buffer\", DUK_STR_NOT_BUFFER);\n\t}\n\treturn h;\n}\n\nDUK_INTERNAL duk_hthread *duk_get_hthread(duk_context *ctx, duk_idx_t idx) {\n\tduk_hobject *h = (duk_hobject *) duk__get_tagged_heaphdr_raw(ctx, idx, DUK_TAG_OBJECT);\n\tif (DUK_UNLIKELY(h != NULL && !DUK_HOBJECT_IS_THREAD(h))) {\n\t\th = NULL;\n\t}\n\treturn (duk_hthread *) h;\n}\n\nDUK_INTERNAL duk_hthread *duk_require_hthread(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *h = (duk_hobject *) duk__get_tagged_heaphdr_raw(ctx, idx, DUK_TAG_OBJECT);\n\tif (DUK_UNLIKELY(!(h != NULL && DUK_HOBJECT_IS_THREAD(h)))) {\n\t\tDUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, \"thread\", DUK_STR_NOT_THREAD);\n\t}\n\treturn (duk_hthread *) h;\n}\n\nDUK_INTERNAL duk_hcompfunc *duk_get_hcompfunc(duk_context *ctx, duk_idx_t idx) {\n\tduk_hobject *h = (duk_hobject *) duk__get_tagged_heaphdr_raw(ctx, idx, DUK_TAG_OBJECT);\n\tif (DUK_UNLIKELY(h != NULL && !DUK_HOBJECT_IS_COMPFUNC(h))) {\n\t\th = NULL;\n\t}\n\treturn (duk_hcompfunc *) h;\n}\n\nDUK_INTERNAL duk_hcompfunc *duk_require_hcompfunc(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *h = (duk_hobject *) duk__get_tagged_heaphdr_raw(ctx, idx, DUK_TAG_OBJECT);\n\tif (DUK_UNLIKELY(!(h != NULL && DUK_HOBJECT_IS_COMPFUNC(h)))) {\n\t\tDUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, \"compiledfunction\", DUK_STR_NOT_COMPFUNC);\n\t}\n\treturn (duk_hcompfunc *) h;\n}\n\nDUK_INTERNAL duk_hnatfunc *duk_get_hnatfunc(duk_context *ctx, duk_idx_t idx) {\n\tduk_hobject *h = (duk_hobject *) duk__get_tagged_heaphdr_raw(ctx, idx, DUK_TAG_OBJECT);\n\tif (DUK_UNLIKELY(h != NULL && !DUK_HOBJECT_IS_NATFUNC(h))) {\n\t\th = NULL;\n\t}\n\treturn (duk_hnatfunc *) h;\n}\n\nDUK_INTERNAL duk_hnatfunc *duk_require_hnatfunc(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *h = (duk_hobject *) duk__get_tagged_heaphdr_raw(ctx, idx, DUK_TAG_OBJECT);\n\tif (DUK_UNLIKELY(!(h != NULL && DUK_HOBJECT_IS_NATFUNC(h)))) {\n\t\tDUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, \"nativefunction\", DUK_STR_NOT_NATFUNC);\n\t}\n\treturn (duk_hnatfunc *) h;\n}\n\nDUK_EXTERNAL duk_c_function duk_get_c_function(duk_context *ctx, duk_idx_t idx) {\n\tduk_tval *tv;\n\tduk_hobject *h;\n\tduk_hnatfunc *f;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tif (DUK_UNLIKELY(!DUK_TVAL_IS_OBJECT(tv))) {\n\t\treturn NULL;\n\t}\n\th = DUK_TVAL_GET_OBJECT(tv);\n\tDUK_ASSERT(h != NULL);\n\n\tif (DUK_UNLIKELY(!DUK_HOBJECT_IS_NATFUNC(h))) {\n\t\treturn NULL;\n\t}\n\tDUK_ASSERT(DUK_HOBJECT_HAS_NATFUNC(h));\n\tf = (duk_hnatfunc *) h;\n\n\treturn f->func;\n}\n\nDUK_EXTERNAL duk_c_function duk_opt_c_function(duk_context *ctx, duk_idx_t idx, duk_c_function def_value) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tif (duk_check_type_mask(ctx, idx, DUK_TYPE_MASK_NONE | DUK_TYPE_MASK_UNDEFINED)) {\n\t\treturn def_value;\n\t}\n\treturn duk_require_c_function(ctx, idx);\n}\n\nDUK_EXTERNAL duk_c_function duk_get_c_function_default(duk_context *ctx, duk_idx_t idx, duk_c_function def_value) {\n\tduk_c_function ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tret = duk_get_c_function(ctx, idx);\n\tif (ret != NULL) {\n\t\treturn ret;\n\t}\n\n\treturn def_value;\n}\n\nDUK_EXTERNAL duk_c_function duk_require_c_function(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_c_function ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tret = duk_get_c_function(ctx, idx);\n\tif (DUK_UNLIKELY(!ret)) {\n\t\tDUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, \"nativefunction\", DUK_STR_NOT_NATFUNC);\n\t}\n\treturn ret;\n}\n\nDUK_EXTERNAL void duk_require_function(duk_context *ctx, duk_idx_t idx) {\n\tif (DUK_UNLIKELY(!duk_is_function(ctx, idx))) {\n\t\tDUK_ERROR_REQUIRE_TYPE_INDEX((duk_hthread *) ctx, idx, \"function\", DUK_STR_NOT_FUNCTION);\n\t}\n}\n\nDUK_INTERNAL_DECL void duk_require_constructable(duk_context *ctx, duk_idx_t idx) {\n\tduk_hobject *h;\n\n\th = duk_require_hobject_accept_mask(ctx, idx, DUK_TYPE_MASK_LIGHTFUNC);\n\tif (DUK_UNLIKELY(h != NULL && !DUK_HOBJECT_HAS_CONSTRUCTABLE(h))) {\n\t\tDUK_ERROR_REQUIRE_TYPE_INDEX((duk_hthread *) ctx, idx, \"constructable\", DUK_STR_NOT_CONSTRUCTABLE);\n\t}\n\t/* Lightfuncs (h == NULL) are constructable. */\n}\n\nDUK_EXTERNAL duk_context *duk_get_context(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\treturn (duk_context *) duk_get_hthread(ctx, idx);\n}\n\nDUK_EXTERNAL duk_context *duk_require_context(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\treturn (duk_context *) duk_require_hthread(ctx, idx);\n}\n\nDUK_EXTERNAL duk_context *duk_opt_context(duk_context *ctx, duk_idx_t idx, duk_context *def_value) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tif (duk_check_type_mask(ctx, idx, DUK_TYPE_MASK_NONE | DUK_TYPE_MASK_UNDEFINED)) {\n\t\treturn def_value;\n\t}\n\treturn duk_require_context(ctx, idx);\n}\n\nDUK_EXTERNAL_DECL duk_context *duk_get_context_default(duk_context *ctx, duk_idx_t idx, duk_context *def_value) {\n\tduk_context *ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tret = duk_get_context(ctx, idx);\n\tif (ret != NULL) {\n\t\treturn ret;\n\t}\n\n\treturn def_value;\n}\n\nDUK_EXTERNAL void *duk_get_heapptr(duk_context *ctx, duk_idx_t idx) {\n\tduk_tval *tv;\n\tvoid *ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tif (DUK_UNLIKELY(!DUK_TVAL_IS_HEAP_ALLOCATED(tv))) {\n\t\treturn (void *) NULL;\n\t}\n\n\tret = (void *) DUK_TVAL_GET_HEAPHDR(tv);\n\tDUK_ASSERT(ret != NULL);\n\treturn ret;\n}\n\nDUK_EXTERNAL void *duk_opt_heapptr(duk_context *ctx, duk_idx_t idx, void *def_value) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tif (duk_check_type_mask(ctx, idx, DUK_TYPE_MASK_NONE | DUK_TYPE_MASK_UNDEFINED)) {\n\t\treturn def_value;\n\t}\n\treturn duk_require_heapptr(ctx, idx);\n}\n\nDUK_EXTERNAL_DECL void *duk_get_heapptr_default(duk_context *ctx, duk_idx_t idx, void *def_value) {\n\tvoid *ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tret = duk_get_heapptr(ctx, idx);\n\tif (ret != NULL) {\n\t\treturn ret;\n\t}\n\n\treturn def_value;\n}\n\nDUK_EXTERNAL void *duk_require_heapptr(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\tvoid *ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tif (DUK_UNLIKELY(!DUK_TVAL_IS_HEAP_ALLOCATED(tv))) {\n\t\tDUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, \"heapobject\", DUK_STR_UNEXPECTED_TYPE);\n\t}\n\n\tret = (void *) DUK_TVAL_GET_HEAPHDR(tv);\n\tDUK_ASSERT(ret != NULL);\n\treturn ret;\n}\n\n/* Internal helper for getting/requiring a duk_hobject with possible promotion. */\nDUK_LOCAL duk_hobject *duk__get_hobject_promote_mask_raw(duk_context *ctx, duk_idx_t idx, duk_uint_t type_mask) {\n\tduk_uint_t val_mask;\n\tduk_hobject *res;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tres = duk_get_hobject(ctx, idx);  /* common case, not promoted */\n\tif (DUK_LIKELY(res != NULL)) {\n\t\tDUK_ASSERT(res != NULL);\n\t\treturn res;\n\t}\n\n\tval_mask = duk_get_type_mask(ctx, idx);\n\tif (val_mask & type_mask) {\n\t\tif (type_mask & DUK_TYPE_MASK_PROMOTE) {\n\t\t\tres = duk_to_hobject(ctx, idx);\n\t\t\tDUK_ASSERT(res != NULL);\n\t\t\treturn res;\n\t\t} else {\n\t\t\treturn NULL;  /* accept without promoting */\n\t\t}\n\t}\n\n\tif (type_mask & DUK_TYPE_MASK_THROW) {\n\t\tDUK_ERROR_REQUIRE_TYPE_INDEX((duk_hthread *) ctx, idx, \"object\", DUK_STR_NOT_OBJECT);\n\t}\n\treturn NULL;\n}\n\n/* Get a duk_hobject * at 'idx'; if the value is not an object but matches the\n * supplied 'type_mask', promote it to an object and return the duk_hobject *.\n * This is useful for call sites which want an object but also accept a plain\n * buffer and/or a lightfunc which gets automatically promoted to an object.\n * Return value is NULL if value is neither an object nor a plain type allowed\n * by the mask.\n */\nDUK_INTERNAL duk_hobject *duk_get_hobject_promote_mask(duk_context *ctx, duk_idx_t idx, duk_uint_t type_mask) {\n\treturn duk__get_hobject_promote_mask_raw(ctx, idx, type_mask | DUK_TYPE_MASK_PROMOTE);\n}\n\n/* Like duk_get_hobject_promote_mask() but throw a TypeError instead of\n * returning a NULL.\n */\nDUK_INTERNAL duk_hobject *duk_require_hobject_promote_mask(duk_context *ctx, duk_idx_t idx, duk_uint_t type_mask) {\n\treturn duk__get_hobject_promote_mask_raw(ctx, idx, type_mask | DUK_TYPE_MASK_THROW | DUK_TYPE_MASK_PROMOTE);\n}\n\n/* Require a duk_hobject * at 'idx'; if the value is not an object but matches the\n * supplied 'type_mask', return a NULL instead.  Otherwise throw a TypeError.\n */\nDUK_INTERNAL duk_hobject *duk_require_hobject_accept_mask(duk_context *ctx, duk_idx_t idx, duk_uint_t type_mask) {\n\treturn duk__get_hobject_promote_mask_raw(ctx, idx, type_mask | DUK_TYPE_MASK_THROW);\n}\n\nDUK_INTERNAL duk_hobject *duk_get_hobject_with_class(duk_context *ctx, duk_idx_t idx, duk_small_uint_t classnum) {\n\tduk_hobject *h;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT_DISABLE(classnum >= 0);  /* unsigned */\n\tDUK_ASSERT(classnum <= DUK_HOBJECT_CLASS_MAX);\n\n\th = (duk_hobject *) duk__get_tagged_heaphdr_raw(ctx, idx, DUK_TAG_OBJECT);\n\tif (DUK_UNLIKELY(h != NULL && DUK_HOBJECT_GET_CLASS_NUMBER(h) != classnum)) {\n\t\th = NULL;\n\t}\n\treturn h;\n}\n\nDUK_INTERNAL duk_hobject *duk_require_hobject_with_class(duk_context *ctx, duk_idx_t idx, duk_small_uint_t classnum) {\n\tduk_hthread *thr;\n\tduk_hobject *h;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT_DISABLE(classnum >= 0);  /* unsigned */\n\tDUK_ASSERT(classnum <= DUK_HOBJECT_CLASS_MAX);\n\tthr = (duk_hthread *) ctx;\n\n\th = (duk_hobject *) duk__get_tagged_heaphdr_raw(ctx, idx, DUK_TAG_OBJECT);\n\tif (DUK_UNLIKELY(!(h != NULL && DUK_HOBJECT_GET_CLASS_NUMBER(h) == classnum))) {\n\t\tduk_hstring *h_class;\n\t\th_class = DUK_HTHREAD_GET_STRING(thr, DUK_HOBJECT_CLASS_NUMBER_TO_STRIDX(classnum));\n\t\tDUK_UNREF(h_class);\n\n\t\tDUK_ERROR_REQUIRE_TYPE_INDEX(thr, idx, (const char *) DUK_HSTRING_GET_DATA(h_class), DUK_STR_UNEXPECTED_TYPE);\n\t}\n\treturn h;\n}\n\nDUK_EXTERNAL duk_size_t duk_get_length(duk_context *ctx, duk_idx_t idx) {\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\n\tswitch (DUK_TVAL_GET_TAG(tv)) {\n\tcase DUK_TAG_UNDEFINED:\n\tcase DUK_TAG_NULL:\n\tcase DUK_TAG_BOOLEAN:\n\tcase DUK_TAG_POINTER:\n\t\treturn 0;\n#if defined(DUK_USE_PREFER_SIZE)\n\t/* All of these types (besides object) have a virtual, non-configurable\n\t * .length property which is within size_t range so we can just look it\n\t * up without specific type checks.\n\t */\n\tcase DUK_TAG_STRING:\n\tcase DUK_TAG_BUFFER:\n\tcase DUK_TAG_LIGHTFUNC: {\n\t\tduk_size_t ret;\n\t\tduk_get_prop_stridx(ctx, idx, DUK_STRIDX_LENGTH);\n\t\tret = (duk_size_t) duk_to_number_m1(ctx);\n\t\tduk_pop(ctx);\n\t\treturn ret;\n\t}\n#else  /* DUK_USE_PREFER_SIZE */\n\tcase DUK_TAG_STRING: {\n\t\tduk_hstring *h = DUK_TVAL_GET_STRING(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\tif (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) {\n\t\t\treturn 0;\n\t\t}\n\t\treturn (duk_size_t) DUK_HSTRING_GET_CHARLEN(h);\n\t}\n\tcase DUK_TAG_BUFFER: {\n\t\tduk_hbuffer *h = DUK_TVAL_GET_BUFFER(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\treturn (duk_size_t) DUK_HBUFFER_GET_SIZE(h);\n\t}\n\tcase DUK_TAG_LIGHTFUNC: {\n\t\tduk_small_uint_t lf_flags;\n\t\tlf_flags = DUK_TVAL_GET_LIGHTFUNC_FLAGS(tv);\n\t\treturn (duk_size_t) DUK_LFUNC_FLAGS_GET_LENGTH(lf_flags);\n\t}\n#endif  /* DUK_USE_PREFER_SIZE */\n\tcase DUK_TAG_OBJECT: {\n\t\tduk_hobject *h = DUK_TVAL_GET_OBJECT(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\treturn (duk_size_t) duk_hobject_get_length((duk_hthread *) ctx, h);\n\t}\n#if defined(DUK_USE_FASTINT)\n\tcase DUK_TAG_FASTINT:\n#endif\n\tdefault:\n\t\t/* number or 'unused' */\n\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv) || DUK_TVAL_IS_UNUSED(tv));\n\t\treturn 0;\n\t}\n\n\tDUK_UNREACHABLE();\n}\n\n/*\n *  duk_known_xxx() helpers\n *\n *  Used internally when we're 100% sure that a certain index is valid and\n *  contains an object of a certain type.  For example, if we duk_push_object()\n *  we can then safely duk_known_hobject(ctx, -1).  These helpers just assert\n *  for the index and type, and if the assumptions are not valid, memory unsafe\n *  behavior happens.\n */\n\nDUK_LOCAL duk_heaphdr *duk__known_heaphdr(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\tduk_heaphdr *h;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tif (idx < 0) {\n\t\ttv = thr->valstack_top + idx;\n\t} else {\n\t\ttv = thr->valstack_bottom + idx;\n\t}\n\tDUK_ASSERT(tv >= thr->valstack_bottom);\n\tDUK_ASSERT(tv < thr->valstack_top);\n\th = DUK_TVAL_GET_HEAPHDR(tv);\n\tDUK_ASSERT(h != NULL);\n\treturn h;\n}\n\nDUK_INTERNAL duk_hstring *duk_known_hstring(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT(duk_get_hstring(ctx, idx) != NULL);\n\treturn (duk_hstring *) duk__known_heaphdr(ctx, idx);\n}\n\nDUK_INTERNAL duk_hobject *duk_known_hobject(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT(duk_get_hobject(ctx, idx) != NULL);\n\treturn (duk_hobject *) duk__known_heaphdr(ctx, idx);\n}\n\nDUK_INTERNAL duk_hbuffer *duk_known_hbuffer(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT(duk_get_hbuffer(ctx, idx) != NULL);\n\treturn (duk_hbuffer *) duk__known_heaphdr(ctx, idx);\n}\n\nDUK_INTERNAL duk_hcompfunc *duk_known_hcompfunc(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT(duk_get_hcompfunc(ctx, idx) != NULL);\n\treturn (duk_hcompfunc *) duk__known_heaphdr(ctx, idx);\n}\n\nDUK_INTERNAL duk_hnatfunc *duk_known_hnatfunc(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT(duk_get_hnatfunc(ctx, idx) != NULL);\n\treturn (duk_hnatfunc *) duk__known_heaphdr(ctx, idx);\n}\n\nDUK_EXTERNAL void duk_set_length(duk_context *ctx, duk_idx_t idx, duk_size_t len) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tidx = duk_normalize_index(ctx, idx);\n\tduk_push_uint(ctx, (duk_uint_t) len);\n\tduk_put_prop_stridx(ctx, idx, DUK_STRIDX_LENGTH);\n}\n\n/*\n *  Conversions and coercions\n *\n *  The conversion/coercions are in-place operations on the value stack.\n *  Some operations are implemented here directly, while others call a\n *  helper in duk_js_ops.c after validating arguments.\n */\n\n/* E5 Section 8.12.8 */\n\nDUK_LOCAL duk_bool_t duk__defaultvalue_coerce_attempt(duk_context *ctx, duk_idx_t idx, duk_small_int_t func_stridx) {\n\tif (duk_get_prop_stridx(ctx, idx, func_stridx)) {\n\t\t/* [ ... func ] */\n\t\tif (duk_is_callable(ctx, -1)) {\n\t\t\tduk_dup(ctx, idx);         /* -> [ ... func this ] */\n\t\t\tduk_call_method(ctx, 0);     /* -> [ ... retval ] */\n\t\t\tif (duk_is_primitive(ctx, -1)) {\n\t\t\t\tduk_replace(ctx, idx);\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\t/* [ ... retval ]; popped below */\n\t\t}\n\t}\n\tduk_pop(ctx);  /* [ ... func/retval ] -> [ ... ] */\n\treturn 0;\n}\n\nDUK_EXTERNAL void duk_to_undefined(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_UNREF(thr);\n\n\ttv = duk_require_tval(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tDUK_TVAL_SET_UNDEFINED_UPDREF(thr, tv);  /* side effects */\n}\n\nDUK_EXTERNAL void duk_to_null(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_UNREF(thr);\n\n\ttv = duk_require_tval(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tDUK_TVAL_SET_NULL_UPDREF(thr, tv);  /* side effects */\n}\n\n/* E5 Section 9.1 */\nDUK_EXTERNAL void duk_to_primitive(duk_context *ctx, duk_idx_t idx, duk_int_t hint) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\t/* inline initializer for coercers[] is not allowed by old compilers like BCC */\n\tduk_small_int_t coercers[2];\n\tduk_small_uint_t class_number;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(hint == DUK_HINT_NONE || hint == DUK_HINT_NUMBER || hint == DUK_HINT_STRING);\n\n\tidx = duk_require_normalize_index(ctx, idx);\n\n\tif (!duk_check_type_mask(ctx, idx, DUK_TYPE_MASK_OBJECT |\n\t                                   DUK_TYPE_MASK_LIGHTFUNC |\n\t                                   DUK_TYPE_MASK_BUFFER)) {\n\t\t/* Any other values stay as is. */\n\t\tDUK_ASSERT(!duk_is_buffer(ctx, idx));  /* duk_to_string() relies on this behavior */\n\t\treturn;\n\t}\n\n\tclass_number = duk_get_class_number(ctx, idx);\n\n\t/* XXX: Symbol objects normally coerce via the ES2015-revised ToPrimitive()\n\t * algorithm which consults value[@@toPrimitive] and avoids calling\n\t * .valueOf() and .toString().  Before that is implemented, special\n\t * case Symbol objects to behave as if they had the default @@toPrimitive\n\t * algorithm of E6 Section 19.4.3.4, i.e. return the plain symbol value\n\t * with no further side effects.\n\t */\n\n\tif (class_number == DUK_HOBJECT_CLASS_SYMBOL) {\n\t\tduk_hobject *h_obj;\n\t\tduk_hstring *h_str;\n\n\t\t/* XXX: pretty awkward, index based API for internal value access? */\n\t\th_obj = duk_known_hobject(ctx, idx);\n\t\th_str = duk_hobject_get_internal_value_string(thr->heap, h_obj);\n\t\tif (h_str) {\n\t\t\tduk_push_hstring(ctx, h_str);\n\t\t\tduk_replace(ctx, idx);\n\t\t\treturn;\n\t\t}\n\t}\n\n\n\t/* Objects are coerced based on E5 specification.\n\t * Lightfuncs are coerced because they behave like\n\t * objects even if they're internally a primitive\n\t * type.  Same applies to plain buffers, which behave\n\t * like ArrayBuffer objects since Duktape 2.x.\n\t */\n\n\tcoercers[0] = DUK_STRIDX_VALUE_OF;\n\tcoercers[1] = DUK_STRIDX_TO_STRING;\n\n\tif (hint == DUK_HINT_NONE) {\n\t\tif (class_number == DUK_HOBJECT_CLASS_DATE) {\n\t\t\thint = DUK_HINT_STRING;\n\t\t} else {\n\t\t\thint = DUK_HINT_NUMBER;\n\t\t}\n\t}\n\n\tif (hint == DUK_HINT_STRING) {\n\t\tcoercers[0] = DUK_STRIDX_TO_STRING;\n\t\tcoercers[1] = DUK_STRIDX_VALUE_OF;\n\t}\n\n\tif (duk__defaultvalue_coerce_attempt(ctx, idx, coercers[0])) {\n\t\tDUK_ASSERT(!duk_is_buffer(ctx, idx));  /* duk_to_string() relies on this behavior */\n\t\treturn;\n\t}\n\n\tif (duk__defaultvalue_coerce_attempt(ctx, idx, coercers[1])) {\n\t\tDUK_ASSERT(!duk_is_buffer(ctx, idx));  /* duk_to_string() relies on this behavior */\n\t\treturn;\n\t}\n\n\tDUK_ERROR_TYPE(thr, DUK_STR_TOPRIMITIVE_FAILED);\n}\n\n/* E5 Section 9.2 */\nDUK_EXTERNAL duk_bool_t duk_to_boolean(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\tduk_bool_t val;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_UNREF(thr);\n\n\tidx = duk_require_normalize_index(ctx, idx);\n\ttv = DUK_GET_TVAL_POSIDX(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\n\tval = duk_js_toboolean(tv);\n\tDUK_ASSERT(val == 0 || val == 1);\n\n\t/* Note: no need to re-lookup tv, conversion is side effect free. */\n\tDUK_ASSERT(tv != NULL);\n\tDUK_TVAL_SET_BOOLEAN_UPDREF(thr, tv, val);  /* side effects */\n\treturn val;\n}\n\nDUK_EXTERNAL duk_double_t duk_to_number(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\tduk_double_t d;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t/* XXX: No need to normalize; the whole operation could be inlined here to\n\t * avoid 'tv' re-lookup.\n\t */\n\tidx = duk_require_normalize_index(ctx, idx);\n\ttv = DUK_GET_TVAL_POSIDX(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\td = duk_js_tonumber(thr, tv);  /* XXX: fastint coercion? now result will always be a non-fastint */\n\n\t/* ToNumber() may have side effects so must relookup 'tv'. */\n\ttv = DUK_GET_TVAL_POSIDX(ctx, idx);\n\tDUK_TVAL_SET_NUMBER_UPDREF(thr, tv, d);  /* side effects */\n\treturn d;\n}\n\nDUK_INTERNAL duk_double_t duk_to_number_m1(duk_context *ctx) {\n\treturn duk_to_number(ctx, -1);\n}\nDUK_INTERNAL duk_double_t duk_to_number_m2(duk_context *ctx) {\n\treturn duk_to_number(ctx, -2);\n}\n\nDUK_INTERNAL duk_double_t duk_to_number_tval(duk_context *ctx, duk_tval *tv) {\n\tduk_double_t res;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tduk_push_tval(ctx, tv);\n\tres = duk_to_number(ctx, -1);\n\tduk_pop(ctx);\n\treturn res;\n}\n\n/* XXX: combine all the integer conversions: they share everything\n * but the helper function for coercion.\n */\n\ntypedef duk_double_t (*duk__toint_coercer)(duk_hthread *thr, duk_tval *tv);\n\nDUK_LOCAL duk_double_t duk__to_int_uint_helper(duk_context *ctx, duk_idx_t idx, duk__toint_coercer coerce_func) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\tduk_double_t d;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_require_tval(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\n#if defined(DUK_USE_FASTINT)\n\t/* If argument is a fastint, guarantee that it remains one.\n\t * There's no downgrade check for other cases.\n\t */\n\tif (DUK_TVAL_IS_FASTINT(tv)) {\n\t\t/* XXX: Unnecessary conversion back and forth. */\n\t\treturn (duk_double_t) DUK_TVAL_GET_FASTINT(tv);\n\t}\n#endif\n\td = coerce_func(thr, tv);\n\n\t/* XXX: fastint? */\n\n\t/* Relookup in case coerce_func() has side effects, e.g. ends up coercing an object */\n\ttv = duk_require_tval(ctx, idx);\n\tDUK_TVAL_SET_NUMBER_UPDREF(thr, tv, d);  /* side effects */\n\treturn d;\n}\n\nDUK_EXTERNAL duk_int_t duk_to_int(duk_context *ctx, duk_idx_t idx) {\n\t/* Value coercion (in stack): ToInteger(), E5 Section 9.4,\n\t * API return value coercion: custom.\n\t */\n\tDUK_ASSERT_CTX_VALID(ctx);\n\t(void) duk__to_int_uint_helper(ctx, idx, duk_js_tointeger);\n\treturn (duk_int_t) duk__api_coerce_d2i(ctx, idx, 0 /*def_value*/, 0 /*require*/);\n}\n\nDUK_EXTERNAL duk_uint_t duk_to_uint(duk_context *ctx, duk_idx_t idx) {\n\t/* Value coercion (in stack): ToInteger(), E5 Section 9.4,\n\t * API return value coercion: custom.\n\t */\n\tDUK_ASSERT_CTX_VALID(ctx);\n\t(void) duk__to_int_uint_helper(ctx, idx, duk_js_tointeger);\n\treturn (duk_uint_t) duk__api_coerce_d2ui(ctx, idx, 0 /*def_value*/, 0 /*require*/);\n}\n\nDUK_EXTERNAL duk_int32_t duk_to_int32(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\tduk_int32_t ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_require_tval(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tret = duk_js_toint32(thr, tv);\n\n\t/* Relookup in case coerce_func() has side effects, e.g. ends up coercing an object */\n\ttv = duk_require_tval(ctx, idx);\n\tDUK_TVAL_SET_I32_UPDREF(thr, tv, ret);  /* side effects */\n\treturn ret;\n}\n\nDUK_EXTERNAL duk_uint32_t duk_to_uint32(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\tduk_uint32_t ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_require_tval(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tret = duk_js_touint32(thr, tv);\n\n\t/* Relookup in case coerce_func() has side effects, e.g. ends up coercing an object */\n\ttv = duk_require_tval(ctx, idx);\n\tDUK_TVAL_SET_U32_UPDREF(thr, tv, ret);  /* side effects */\n\treturn ret;\n}\n\nDUK_EXTERNAL duk_uint16_t duk_to_uint16(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\tduk_uint16_t ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_require_tval(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tret = duk_js_touint16(thr, tv);\n\n\t/* Relookup in case coerce_func() has side effects, e.g. ends up coercing an object */\n\ttv = duk_require_tval(ctx, idx);\n\tDUK_TVAL_SET_U32_UPDREF(thr, tv, ret);  /* side effects */\n\treturn ret;\n}\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n/* Special coercion for Uint8ClampedArray. */\nDUK_INTERNAL duk_uint8_t duk_to_uint8clamped(duk_context *ctx, duk_idx_t idx) {\n\tduk_double_t d;\n\tduk_double_t t;\n\tduk_uint8_t ret;\n\n\t/* XXX: Simplify this algorithm, should be possible to come up with\n\t * a shorter and faster algorithm by inspecting IEEE representation\n\t * directly.\n\t */\n\n\td = duk_to_number(ctx, idx);\n\tif (d <= 0.0) {\n\t\treturn 0;\n\t} else if (d >= 255) {\n\t\treturn 255;\n\t} else if (DUK_ISNAN(d)) {\n\t\t/* Avoid NaN-to-integer coercion as it is compiler specific. */\n\t\treturn 0;\n\t}\n\n\tt = d - DUK_FLOOR(d);\n\tif (t == 0.5) {\n\t\t/* Exact halfway, round to even. */\n\t\tret = (duk_uint8_t) d;\n\t\tret = (ret + 1) & 0xfe;  /* Example: d=3.5, t=0.5 -> ret = (3 + 1) & 0xfe = 4 & 0xfe = 4\n\t\t                          * Example: d=4.5, t=0.5 -> ret = (4 + 1) & 0xfe = 5 & 0xfe = 4\n\t\t                          */\n\t} else {\n\t\t/* Not halfway, round to nearest. */\n\t\tret = (duk_uint8_t) (d + 0.5);\n\t}\n\treturn ret;\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\nDUK_EXTERNAL const char *duk_to_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t(void) duk_to_string(ctx, idx);\n\tDUK_ASSERT(duk_is_string(ctx, idx));\n\treturn duk_require_lstring(ctx, idx, out_len);\n}\n\nDUK_LOCAL duk_ret_t duk__safe_to_string_raw(duk_context *ctx, void *udata) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_UNREF(udata);\n\n\tduk_to_string(ctx, -1);\n\treturn 1;\n}\n\nDUK_EXTERNAL const char *duk_safe_to_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tidx = duk_require_normalize_index(ctx, idx);\n\n\t/* We intentionally ignore the duk_safe_call() return value and only\n\t * check the output type.  This way we don't also need to check that\n\t * the returned value is indeed a string in the success case.\n\t */\n\n\tduk_dup(ctx, idx);\n\t(void) duk_safe_call(ctx, duk__safe_to_string_raw, NULL /*udata*/, 1 /*nargs*/, 1 /*nrets*/);\n\tif (!duk_is_string(ctx, -1)) {\n\t\t/* Error: try coercing error to string once. */\n\t\t(void) duk_safe_call(ctx, duk__safe_to_string_raw, NULL /*udata*/, 1 /*nargs*/, 1 /*nrets*/);\n\t\tif (!duk_is_string(ctx, -1)) {\n\t\t\t/* Double error */\n\t\t\tduk_pop(ctx);\n\t\t\tduk_push_hstring_stridx(ctx, DUK_STRIDX_UC_ERROR);\n\t\t} else {\n\t\t\t;\n\t\t}\n\t} else {\n\t\t/* String; may be a symbol, accepted. */\n\t\t;\n\t}\n\tDUK_ASSERT(duk_is_string(ctx, -1));\n\n\tduk_replace(ctx, idx);\n\tDUK_ASSERT(duk_get_string(ctx, idx) != NULL);\n\treturn duk_get_lstring(ctx, idx, out_len);\n}\n\nDUK_INTERNAL duk_hstring *duk_to_property_key_hstring(duk_context *ctx, duk_idx_t idx) {\n\tduk_hstring *h;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tduk_to_primitive(ctx, idx, DUK_HINT_STRING);  /* needed for e.g. Symbol objects */\n\th = duk_get_hstring(ctx, idx);\n\tif (h == NULL) {\n\t\t/* The \"is string?\" check may seem unnecessary, but as things\n\t\t * are duk_to_hstring() invokes ToString() which fails for\n\t\t * symbols.  But since symbols are already strings for Duktape\n\t\t * C API, we check for that before doing the coercion.\n\t\t */\n\t\th = duk_to_hstring(ctx, idx);\n\t}\n\tDUK_ASSERT(h != NULL);\n\treturn h;\n}\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT)  /* only needed by debugger for now */\nDUK_INTERNAL duk_hstring *duk_safe_to_hstring(duk_context *ctx, duk_idx_t idx) {\n\t(void) duk_safe_to_string(ctx, idx);\n\tDUK_ASSERT(duk_is_string(ctx, idx));\n\tDUK_ASSERT(duk_get_hstring(ctx, idx) != NULL);\n\treturn duk_known_hstring(ctx, idx);\n}\n#endif\n\n/* Push Object.prototype.toString() output for 'tv'. */\nDUK_INTERNAL void duk_push_class_string_tval(duk_context *ctx, duk_tval *tv) {\n\tduk_hthread *thr;\n\tduk_small_uint_t stridx;\n\tduk_hstring *h_strclass;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\tDUK_UNREF(thr);\n\n\tswitch (DUK_TVAL_GET_TAG(tv)) {\n\tcase DUK_TAG_UNUSED:  /* Treat like 'undefined', shouldn't happen. */\n\tcase DUK_TAG_UNDEFINED: {\n\t\tstridx = DUK_STRIDX_UC_UNDEFINED;\n\t\tbreak;\n\t}\n\tcase DUK_TAG_NULL: {\n\t\tstridx = DUK_STRIDX_UC_NULL;\n\t\tbreak;\n\t}\n\tcase DUK_TAG_BOOLEAN: {\n\t\tstridx = DUK_STRIDX_UC_BOOLEAN;\n\t\tbreak;\n\t}\n\tcase DUK_TAG_POINTER: {\n\t\tstridx = DUK_STRIDX_UC_POINTER;\n\t\tbreak;\n\t}\n\tcase DUK_TAG_LIGHTFUNC: {\n\t\tstridx = DUK_STRIDX_UC_FUNCTION;\n\t\tbreak;\n\t}\n\tcase DUK_TAG_STRING: {\n\t\tduk_hstring *h;\n\t\th = DUK_TVAL_GET_STRING(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\tif (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) {\n\t\t\tstridx = DUK_STRIDX_UC_SYMBOL;\n\t\t} else {\n\t\t\tstridx = DUK_STRIDX_UC_STRING;\n\t\t}\n\t\tbreak;\n\t}\n\tcase DUK_TAG_OBJECT: {\n\t\tduk_hobject *h;\n\t\tduk_small_uint_t classnum;\n\n\t\th = DUK_TVAL_GET_OBJECT(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\tclassnum = DUK_HOBJECT_GET_CLASS_NUMBER(h);\n\t\tstridx = DUK_HOBJECT_CLASS_NUMBER_TO_STRIDX(classnum);\n\n\t\t/* XXX: This is not entirely correct anymore; in ES2015 the\n\t\t * default lookup should use @@toStringTag to come up with\n\t\t * e.g. [object Symbol], [object Uint8Array], etc.  See\n\t\t * ES2015 Section 19.1.3.6.  The downside of implementing that\n\t\t * directly is that the @@toStringTag lookup may have side\n\t\t * effects, so all call sites must be checked for that.\n\t\t * Some may need a side-effect free lookup, e.g. avoiding\n\t\t * getters which are not typical.\n\t\t */\n\t\tbreak;\n\t}\n\tcase DUK_TAG_BUFFER: {\n\t\tstridx = DUK_STRIDX_UINT8_ARRAY;\n\t\tbreak;\n\t}\n#if defined(DUK_USE_FASTINT)\n\tcase DUK_TAG_FASTINT:\n\t\t/* Fall through to generic number case. */\n#endif\n\tdefault: {\n\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv));  /* number (maybe fastint) */\n\t\tstridx = DUK_STRIDX_UC_NUMBER;\n\t\tbreak;\n\t}\n\t}\n\th_strclass = DUK_HTHREAD_GET_STRING(thr, stridx);\n\tDUK_ASSERT(h_strclass != NULL);\n\n\tduk_push_sprintf(ctx, \"[object %s]\", (const char *) DUK_HSTRING_GET_DATA(h_strclass));\n}\n\n/* XXX: other variants like uint, u32 etc */\nDUK_INTERNAL duk_int_t duk_to_int_clamped_raw(duk_context *ctx, duk_idx_t idx, duk_int_t minval, duk_int_t maxval, duk_bool_t *out_clamped) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\tduk_tval tv_tmp;\n\tduk_double_t d, dmin, dmax;\n\tduk_int_t res;\n\tduk_bool_t clamped = 0;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_require_tval(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\td = duk_js_tointeger(thr, tv);  /* E5 Section 9.4, ToInteger() */\n\n\tdmin = (duk_double_t) minval;\n\tdmax = (duk_double_t) maxval;\n\n\tif (d < dmin) {\n\t\tclamped = 1;\n\t\tres = minval;\n\t\td = dmin;\n\t} else if (d > dmax) {\n\t\tclamped = 1;\n\t\tres = maxval;\n\t\td = dmax;\n\t} else {\n\t\tres = (duk_int_t) d;\n\t}\n\tDUK_UNREF(d);  /* SCANBUILD: with suitable dmin/dmax limits 'd' is unused */\n\t/* 'd' and 'res' agree here */\n\n\t/* Relookup in case duk_js_tointeger() ends up e.g. coercing an object. */\n\ttv = duk_get_tval(ctx, idx);\n\tDUK_ASSERT(tv != NULL);  /* not popped by side effect */\n\tDUK_TVAL_SET_TVAL(&tv_tmp, tv);\n#if defined(DUK_USE_FASTINT)\n#if (DUK_INT_MAX <= 0x7fffffffL)\n\tDUK_TVAL_SET_I32(tv, res);\n#else\n\t/* Clamping needed if duk_int_t is 64 bits. */\n\tif (res >= DUK_FASTINT_MIN && res <= DUK_FASTINT_MAX) {\n\t\tDUK_TVAL_SET_FASTINT(tv, res);\n\t} else {\n\t\tDUK_TVAL_SET_NUMBER(tv, d);\n\t}\n#endif\n#else\n\tDUK_TVAL_SET_NUMBER(tv, d);  /* no need to incref */\n#endif\n\tDUK_TVAL_DECREF(thr, &tv_tmp);  /* side effects */\n\n\tif (out_clamped) {\n\t\t*out_clamped = clamped;\n\t} else {\n\t\t/* coerced value is updated to value stack even when RangeError thrown */\n\t\tif (clamped) {\n\t\t\tDUK_ERROR_RANGE(thr, DUK_STR_NUMBER_OUTSIDE_RANGE);\n\t\t}\n\t}\n\n\treturn res;\n}\n\nDUK_INTERNAL duk_int_t duk_to_int_clamped(duk_context *ctx, duk_idx_t idx, duk_idx_t minval, duk_idx_t maxval) {\n\tduk_bool_t dummy;\n\treturn duk_to_int_clamped_raw(ctx, idx, minval, maxval, &dummy);\n}\n\nDUK_INTERNAL duk_int_t duk_to_int_check_range(duk_context *ctx, duk_idx_t idx, duk_int_t minval, duk_int_t maxval) {\n\treturn duk_to_int_clamped_raw(ctx, idx, minval, maxval, NULL);  /* out_clamped==NULL -> RangeError if outside range */\n}\n\nDUK_EXTERNAL const char *duk_to_string(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_UNREF(thr);\n\n\tidx = duk_require_normalize_index(ctx, idx);\n\ttv = DUK_GET_TVAL_POSIDX(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\n\tswitch (DUK_TVAL_GET_TAG(tv)) {\n\tcase DUK_TAG_UNDEFINED: {\n\t\tduk_push_hstring_stridx(ctx, DUK_STRIDX_LC_UNDEFINED);\n\t\tbreak;\n\t}\n\tcase DUK_TAG_NULL: {\n\t\tduk_push_hstring_stridx(ctx, DUK_STRIDX_LC_NULL);\n\t\tbreak;\n\t}\n\tcase DUK_TAG_BOOLEAN: {\n\t\tif (DUK_TVAL_GET_BOOLEAN(tv)) {\n\t\t\tduk_push_hstring_stridx(ctx, DUK_STRIDX_TRUE);\n\t\t} else {\n\t\t\tduk_push_hstring_stridx(ctx, DUK_STRIDX_FALSE);\n\t\t}\n\t\tbreak;\n\t}\n\tcase DUK_TAG_STRING: {\n\t\t/* Nop for actual strings, TypeError for Symbols.\n\t\t * Because various internals rely on ToString() coercion of\n\t\t * internal strings, -allow- (NOP) string coercion for hidden\n\t\t * symbols.\n\t\t */\n#if 1\n\t\tduk_hstring *h;\n\t\th = DUK_TVAL_GET_STRING(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\tif (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) {\n\t\t\tDUK_ERROR_TYPE((duk_hthread *) ctx, DUK_STR_CANNOT_STRING_COERCE_SYMBOL);\n\t\t} else {\n\t\t\tgoto skip_replace;\n\t\t}\n#else\n\t\tgoto skip_replace;\n#endif\n\t}\n\tcase DUK_TAG_BUFFER: /* Go through Uint8Array.prototype.toString() for coercion. */\n\tcase DUK_TAG_OBJECT: {\n\t\t/* Plain buffers: go through ArrayBuffer.prototype.toString()\n\t\t * for coercion.\n\t\t *\n\t\t * Symbol objects: duk_to_primitive() results in a plain symbol\n\t\t * value, and duk_to_string() then causes a TypeError.\n\t\t */\n\t\tduk_to_primitive(ctx, idx, DUK_HINT_STRING);\n\t\tDUK_ASSERT(!duk_is_buffer(ctx, idx));  /* ToPrimitive() must guarantee */\n\t\tDUK_ASSERT(!duk_is_object(ctx, idx));\n\t\treturn duk_to_string(ctx, idx);  /* Note: recursive call */\n\t}\n\tcase DUK_TAG_POINTER: {\n\t\tvoid *ptr = DUK_TVAL_GET_POINTER(tv);\n\t\tif (ptr != NULL) {\n\t\t\tduk_push_sprintf(ctx, DUK_STR_FMT_PTR, (void *) ptr);\n\t\t} else {\n\t\t\t/* Represent a null pointer as 'null' to be consistent with\n\t\t\t * the JX format variant.  Native '%p' format for a NULL\n\t\t\t * pointer may be e.g. '(nil)'.\n\t\t\t */\n\t\t\tduk_push_hstring_stridx(ctx, DUK_STRIDX_LC_NULL);\n\t\t}\n\t\tbreak;\n\t}\n\tcase DUK_TAG_LIGHTFUNC: {\n\t\t/* Should match Function.prototype.toString() */\n\t\tduk_push_lightfunc_tostring(ctx, tv);\n\t\tbreak;\n\t}\n#if defined(DUK_USE_FASTINT)\n\tcase DUK_TAG_FASTINT:\n#endif\n\tdefault: {\n\t\t/* number */\n\t\tDUK_ASSERT(!DUK_TVAL_IS_UNUSED(tv));\n\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv));\n\t\tduk_push_tval(ctx, tv);\n\t\tduk_numconv_stringify(ctx,\n\t\t                      10 /*radix*/,\n\t\t                      0 /*precision:shortest*/,\n\t\t                      0 /*force_exponential*/);\n\t\tbreak;\n\t}\n\t}\n\n\tduk_replace(ctx, idx);\n\n skip_replace:\n\tDUK_ASSERT(duk_is_string(ctx, idx));\n\treturn duk_require_string(ctx, idx);\n}\n\nDUK_INTERNAL duk_hstring *duk_to_hstring(duk_context *ctx, duk_idx_t idx) {\n\tduk_hstring *ret;\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tduk_to_string(ctx, idx);\n\tret = duk_get_hstring(ctx, idx);\n\tDUK_ASSERT(ret != NULL);\n\treturn ret;\n}\n\nDUK_INTERNAL duk_hstring *duk_to_hstring_m1(duk_context *ctx) {\n\treturn duk_to_hstring(ctx, -1);\n}\n\nDUK_INTERNAL duk_hstring *duk_to_hstring_acceptsymbol(duk_context *ctx, duk_idx_t idx) {\n\tduk_hstring *ret;\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tret = duk_get_hstring(ctx, idx);\n\tif (DUK_UNLIKELY(ret && DUK_HSTRING_HAS_SYMBOL(ret))) {\n\t\treturn ret;\n\t}\n\treturn duk_to_hstring(ctx, idx);\n}\n\n/* Convert a plain buffer or any buffer object into a string, using the buffer\n * bytes 1:1 in the internal string representation.  For views the active byte\n * slice (not element slice interpreted as an initializer) is used.  This is\n * necessary in Duktape 2.x because ToString(plainBuffer) no longer creates a\n * string with the same bytes as in the buffer but rather (usually)\n * '[object ArrayBuffer]'.\n */\nDUK_EXTERNAL const char *duk_buffer_to_string(duk_context *ctx, duk_idx_t idx) {\n\tvoid *ptr_src;\n\tduk_size_t len;\n\tconst char *res;\n\n\tidx = duk_require_normalize_index(ctx, idx);\n\n\tptr_src = duk_require_buffer_data(ctx, idx, &len);\n\tDUK_ASSERT(ptr_src != NULL || len == 0);\n\n\tres = duk_push_lstring(ctx, (const char *) ptr_src, len);\n\tduk_replace(ctx, idx);\n\treturn res;\n}\n\nDUK_EXTERNAL void *duk_to_buffer_raw(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size, duk_uint_t mode) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hbuffer *h_buf;\n\tconst duk_uint8_t *src_data;\n\tduk_size_t src_size;\n\tduk_uint8_t *dst_data;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_UNREF(thr);\n\n\tidx = duk_require_normalize_index(ctx, idx);\n\n\th_buf = duk_get_hbuffer(ctx, idx);\n\tif (h_buf != NULL) {\n\t\t/* Buffer is kept as is, with the fixed/dynamic nature of the\n\t\t * buffer only changed if requested.  An external buffer\n\t\t * is converted into a non-external dynamic buffer in a\n\t\t * duk_to_dynamic_buffer() call.\n\t\t */\n\t\tduk_uint_t tmp;\n\t\tduk_uint8_t *tmp_ptr;\n\n\t\ttmp_ptr = (duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_buf);\n\t\tsrc_data = (const duk_uint8_t *) tmp_ptr;\n\t\tsrc_size = DUK_HBUFFER_GET_SIZE(h_buf);\n\n\t\ttmp = (DUK_HBUFFER_HAS_DYNAMIC(h_buf) ? DUK_BUF_MODE_DYNAMIC : DUK_BUF_MODE_FIXED);\n\t\tif ((tmp == mode && !DUK_HBUFFER_HAS_EXTERNAL(h_buf)) ||\n\t\t    mode == DUK_BUF_MODE_DONTCARE) {\n\t\t\t/* Note: src_data may be NULL if input is a zero-size\n\t\t\t * dynamic buffer.\n\t\t\t */\n\t\t\tdst_data = tmp_ptr;\n\t\t\tgoto skip_copy;\n\t\t}\n\t} else {\n\t\t/* Non-buffer value is first ToString() coerced, then converted\n\t\t * to a buffer (fixed buffer is used unless a dynamic buffer is\n\t\t * explicitly requested).  Symbols are rejected with a TypeError.\n\t\t * XXX: C API could maybe allow symbol-to-buffer coercion?\n\t\t */\n\t\tsrc_data = (const duk_uint8_t *) duk_to_lstring(ctx, idx, &src_size);\n\t}\n\n\tdst_data = (duk_uint8_t *) duk_push_buffer(ctx, src_size, (mode == DUK_BUF_MODE_DYNAMIC) /*dynamic*/);\n\tif (DUK_LIKELY(src_size > 0)) {\n\t\t/* When src_size == 0, src_data may be NULL (if source\n\t\t * buffer is dynamic), and dst_data may be NULL (if\n\t\t * target buffer is dynamic).  Avoid zero-size memcpy()\n\t\t * with an invalid pointer.\n\t\t */\n\t\tDUK_MEMCPY((void *) dst_data, (const void *) src_data, (size_t) src_size);\n\t}\n\tduk_replace(ctx, idx);\n skip_copy:\n\n\tif (out_size) {\n\t\t*out_size = src_size;\n\t}\n\treturn dst_data;\n}\n\nDUK_EXTERNAL void *duk_to_pointer(duk_context *ctx, duk_idx_t idx) {\n\tduk_tval *tv;\n\tvoid *res;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tidx = duk_require_normalize_index(ctx, idx);\n\ttv = DUK_GET_TVAL_POSIDX(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\n\tswitch (DUK_TVAL_GET_TAG(tv)) {\n\tcase DUK_TAG_UNDEFINED:\n\tcase DUK_TAG_NULL:\n\tcase DUK_TAG_BOOLEAN:\n\t\tres = NULL;\n\t\tbreak;\n\tcase DUK_TAG_POINTER:\n\t\tres = DUK_TVAL_GET_POINTER(tv);\n\t\tbreak;\n\tcase DUK_TAG_STRING:\n\tcase DUK_TAG_OBJECT:\n\tcase DUK_TAG_BUFFER:\n\t\t/* Heap allocated: return heap pointer which is NOT useful\n\t\t * for the caller, except for debugging.\n\t\t */\n\t\tres = (void *) DUK_TVAL_GET_HEAPHDR(tv);\n\t\tbreak;\n\tcase DUK_TAG_LIGHTFUNC:\n\t\t/* Function pointers do not always cast correctly to void *\n\t\t * (depends on memory and segmentation model for instance),\n\t\t * so they coerce to NULL.\n\t\t */\n\t\tres = NULL;\n\t\tbreak;\n#if defined(DUK_USE_FASTINT)\n\tcase DUK_TAG_FASTINT:\n#endif\n\tdefault:\n\t\t/* number */\n\t\tDUK_ASSERT(!DUK_TVAL_IS_UNUSED(tv));\n\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv));\n\t\tres = NULL;\n\t\tbreak;\n\t}\n\n\tduk_push_pointer(ctx, res);\n\tduk_replace(ctx, idx);\n\treturn res;\n}\n\nDUK_LOCAL void duk__push_func_from_lightfunc(duk_context *ctx, duk_c_function func, duk_small_uint_t lf_flags) {\n\tduk_idx_t nargs;\n\tduk_uint_t flags = 0;   /* shared flags for a subset of types */\n\tduk_small_uint_t lf_len;\n\tduk_hnatfunc *nf;\n\n\tnargs = (duk_idx_t) DUK_LFUNC_FLAGS_GET_NARGS(lf_flags);\n\tif (nargs == DUK_LFUNC_NARGS_VARARGS) {\n\t\tnargs = (duk_idx_t) DUK_VARARGS;\n\t}\n\n\tflags = DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t        DUK_HOBJECT_FLAG_CONSTRUCTABLE |\n\t        DUK_HOBJECT_FLAG_FASTREFS |\n\t        DUK_HOBJECT_FLAG_NATFUNC |\n\t        DUK_HOBJECT_FLAG_NEWENV |\n\t        DUK_HOBJECT_FLAG_STRICT |\n\t        DUK_HOBJECT_FLAG_NOTAIL |\n\t        /* DUK_HOBJECT_FLAG_EXOTIC_DUKFUNC: omitted here intentionally */\n\t        DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_FUNCTION);\n\t(void) duk__push_c_function_raw(ctx, func, nargs, flags);\n\n\tlf_len = DUK_LFUNC_FLAGS_GET_LENGTH(lf_flags);\n\tif ((duk_idx_t) lf_len != nargs) {\n\t\t/* Explicit length is only needed if it differs from 'nargs'. */\n\t\tduk_push_int(ctx, (duk_int_t) lf_len);\n\t\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_LENGTH, DUK_PROPDESC_FLAGS_NONE);\n\t}\n\n#if defined(DUK_USE_FUNC_NAME_PROPERTY)\n\tduk_push_lightfunc_name_raw(ctx, func, lf_flags);\n\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_NAME, DUK_PROPDESC_FLAGS_C);\n#endif\n\n\tnf = duk_known_hnatfunc(ctx, -1);\n\tnf->magic = (duk_int16_t) DUK_LFUNC_FLAGS_GET_MAGIC(lf_flags);\n\n\t/* Enable DUKFUNC exotic behavior once properties are set up. */\n\tDUK_HOBJECT_SET_EXOTIC_DUKFUNC((duk_hobject *) nf);\n}\n\nDUK_EXTERNAL void duk_to_object(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\tduk_uint_t flags = 0;   /* shared flags for a subset of types */\n\tduk_small_int_t proto = 0;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tidx = duk_require_normalize_index(ctx, idx);\n\ttv = DUK_GET_TVAL_POSIDX(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\n\tswitch (DUK_TVAL_GET_TAG(tv)) {\n#if !defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n\tcase DUK_TAG_BUFFER:  /* With no bufferobject support, don't object coerce. */\n#endif\n\tcase DUK_TAG_UNDEFINED:\n\tcase DUK_TAG_NULL: {\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_NOT_OBJECT_COERCIBLE);\n\t\tbreak;\n\t}\n\tcase DUK_TAG_BOOLEAN: {\n\t\tflags = DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t\t        DUK_HOBJECT_FLAG_FASTREFS |\n\t\t        DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_BOOLEAN);\n\t\tproto = DUK_BIDX_BOOLEAN_PROTOTYPE;\n\t\tgoto create_object;\n\t}\n\tcase DUK_TAG_STRING: {\n\t\tduk_hstring *h;\n\t\th = DUK_TVAL_GET_STRING(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\tif (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) {\n\t\t\tflags = DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t\t\t        DUK_HOBJECT_FLAG_FASTREFS |\n\t\t\t        DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_SYMBOL);\n\t\t\tproto = DUK_BIDX_SYMBOL_PROTOTYPE;\n\t\t} else {\n\t\t\tflags = DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t\t\t        DUK_HOBJECT_FLAG_FASTREFS |\n\t\t\t        DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ |\n\t\t\t        DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_STRING);\n\t\t\tproto = DUK_BIDX_STRING_PROTOTYPE;\n\t\t}\n\t\tgoto create_object;\n\t}\n\tcase DUK_TAG_OBJECT: {\n\t\t/* nop */\n\t\tbreak;\n\t}\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n\tcase DUK_TAG_BUFFER: {\n\t\t/* A plain buffer object coerces to a full ArrayBuffer which\n\t\t * is not fully transparent behavior (ToObject() should be a\n\t\t * nop for an object).  This behavior matches lightfuncs which\n\t\t * also coerce to an equivalent Function object.  There are\n\t\t * also downsides to defining ToObject(plainBuffer) as a no-op;\n\t\t * for example duk_to_hobject() could result in a NULL pointer.\n\t\t */\n\t\tduk_hbuffer *h_buf;\n\n\t\th_buf = DUK_TVAL_GET_BUFFER(tv);\n\t\tDUK_ASSERT(h_buf != NULL);\n\t\tduk_hbufobj_push_uint8array_from_plain(thr, h_buf);\n\t\tgoto replace_value;\n\t}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\tcase DUK_TAG_POINTER: {\n\t\tflags = DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t\t        DUK_HOBJECT_FLAG_FASTREFS |\n\t\t        DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_POINTER);\n\t\tproto = DUK_BIDX_POINTER_PROTOTYPE;\n\t\tgoto create_object;\n\t}\n\tcase DUK_TAG_LIGHTFUNC: {\n\t\t/* Lightfunc coerces to a Function instance with concrete\n\t\t * properties.  Since 'length' is virtual for Duktape/C\n\t\t * functions, don't need to define that.  The result is made\n\t\t * extensible to mimic what happens to strings in object\n\t\t * coercion:\n\t\t *\n\t\t *   > Object.isExtensible(Object('foo'))\n\t\t *   true\n\t\t */\n\t\tduk_small_uint_t lf_flags;\n\t\tduk_c_function func;\n\n\t\tDUK_TVAL_GET_LIGHTFUNC(tv, func, lf_flags);\n\t\tduk__push_func_from_lightfunc(ctx, func, lf_flags);\n\t\tgoto replace_value;\n\t}\n#if defined(DUK_USE_FASTINT)\n\tcase DUK_TAG_FASTINT:\n#endif\n\tdefault: {\n\t\tDUK_ASSERT(!DUK_TVAL_IS_UNUSED(tv));\n\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv));\n\t\tflags = DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t\t        DUK_HOBJECT_FLAG_FASTREFS |\n\t\t        DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_NUMBER);\n\t\tproto = DUK_BIDX_NUMBER_PROTOTYPE;\n\t\tgoto create_object;\n\t}\n\t}\n\tDUK_ASSERT(duk_is_object(ctx, idx));\n\treturn;\n\n create_object:\n\t(void) duk_push_object_helper(ctx, flags, proto);\n\n\t/* Note: Boolean prototype's internal value property is not writable,\n\t * but duk_xdef_prop_stridx() disregards the write protection.  Boolean\n\t * instances are immutable.\n\t *\n\t * String and buffer special behaviors are already enabled which is not\n\t * ideal, but a write to the internal value is not affected by them.\n\t */\n\tduk_dup(ctx, idx);\n\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_VALUE, DUK_PROPDESC_FLAGS_NONE);\n\n replace_value:\n\tduk_replace(ctx, idx);\n\tDUK_ASSERT(duk_is_object(ctx, idx));\n}\n\nDUK_INTERNAL duk_hobject *duk_to_hobject(duk_context *ctx, duk_idx_t idx) {\n\tduk_hobject *ret;\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tduk_to_object(ctx, idx);\n\tret = duk_known_hobject(ctx, idx);\n\treturn ret;\n}\n\n/*\n *  Type checking\n */\n\nDUK_LOCAL duk_bool_t duk__tag_check(duk_context *ctx, duk_idx_t idx, duk_small_uint_t tag) {\n\tduk_tval *tv;\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\treturn (DUK_TVAL_GET_TAG(tv) == tag);\n}\n\nDUK_LOCAL duk_bool_t duk__obj_flag_any_default_false(duk_context *ctx, duk_idx_t idx, duk_uint_t flag_mask) {\n\tduk_hobject *obj;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tobj = duk_get_hobject(ctx, idx);\n\tif (obj) {\n\t\treturn (DUK_HEAPHDR_CHECK_FLAG_BITS((duk_heaphdr *) obj, flag_mask) ? 1 : 0);\n\t}\n\treturn 0;\n}\n\nDUK_INTERNAL duk_int_t duk_get_type_tval(duk_tval *tv) {\n\tDUK_ASSERT(tv != NULL);\n\n#if defined(DUK_USE_PACKED_TVAL)\n\tswitch (DUK_TVAL_GET_TAG(tv)) {\n\tcase DUK_TAG_UNUSED:\n\t\treturn DUK_TYPE_NONE;\n\tcase DUK_TAG_UNDEFINED:\n\t\treturn DUK_TYPE_UNDEFINED;\n\tcase DUK_TAG_NULL:\n\t\treturn DUK_TYPE_NULL;\n\tcase DUK_TAG_BOOLEAN:\n\t\treturn DUK_TYPE_BOOLEAN;\n\tcase DUK_TAG_STRING:\n\t\treturn DUK_TYPE_STRING;\n\tcase DUK_TAG_OBJECT:\n\t\treturn DUK_TYPE_OBJECT;\n\tcase DUK_TAG_BUFFER:\n\t\treturn DUK_TYPE_BUFFER;\n\tcase DUK_TAG_POINTER:\n\t\treturn DUK_TYPE_POINTER;\n\tcase DUK_TAG_LIGHTFUNC:\n\t\treturn DUK_TYPE_LIGHTFUNC;\n#if defined(DUK_USE_FASTINT)\n\tcase DUK_TAG_FASTINT:\n#endif\n\tdefault:\n\t\t/* Note: number has no explicit tag (in 8-byte representation) */\n\t\tDUK_ASSERT(!DUK_TVAL_IS_UNUSED(tv));\n\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv));\n\t\treturn DUK_TYPE_NUMBER;\n\t}\n#else  /* DUK_USE_PACKED_TVAL */\n\tDUK_ASSERT(DUK_TVAL_IS_VALID_TAG(tv));\n\tDUK_ASSERT(sizeof(duk__type_from_tag) / sizeof(duk_uint_t) == DUK_TAG_MAX - DUK_TAG_MIN + 1);\n\treturn (duk_int_t) duk__type_from_tag[DUK_TVAL_GET_TAG(tv) - DUK_TAG_MIN];\n#endif  /* DUK_USE_PACKED_TVAL */\n}\n\nDUK_EXTERNAL duk_int_t duk_get_type(duk_context *ctx, duk_idx_t idx) {\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\n\treturn duk_get_type_tval(tv);\n}\n\n#if defined(DUK_USE_VERBOSE_ERRORS) && defined(DUK_USE_PARANOID_ERRORS)\nDUK_LOCAL const char *duk__type_names[] = {\n\t\"none\",\n\t\"undefined\",\n\t\"null\",\n\t\"boolean\",\n\t\"number\",\n\t\"string\",\n\t\"object\",\n\t\"buffer\",\n\t\"pointer\",\n\t\"lightfunc\"\n};\n\nDUK_INTERNAL const char *duk_get_type_name(duk_context *ctx, duk_idx_t idx) {\n\tduk_int_t type_tag;\n\n\ttype_tag = duk_get_type(ctx, idx);\n\tDUK_ASSERT(type_tag >= DUK_TYPE_MIN && type_tag <= DUK_TYPE_MAX);\n\tDUK_ASSERT(DUK_TYPE_MIN == 0 && sizeof(duk__type_names) / sizeof(const char *) == DUK_TYPE_MAX + 1);\n\n\treturn duk__type_names[type_tag];\n}\n#endif\n\nDUK_INTERNAL duk_small_uint_t duk_get_class_number(duk_context *ctx, duk_idx_t idx) {\n\tduk_tval *tv;\n\tduk_hobject *obj;\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\n\tswitch (DUK_TVAL_GET_TAG(tv)) {\n\tcase DUK_TAG_OBJECT:\n\t\tobj = DUK_TVAL_GET_OBJECT(tv);\n\t\tDUK_ASSERT(obj != NULL);\n\t\treturn DUK_HOBJECT_GET_CLASS_NUMBER(obj);\n\tcase DUK_TAG_BUFFER:\n\t\t/* Buffers behave like Uint8Array objects. */\n\t\treturn DUK_HOBJECT_CLASS_UINT8ARRAY;\n\tcase DUK_TAG_LIGHTFUNC:\n\t\t/* Lightfuncs behave like Function objects. */\n\t\treturn DUK_HOBJECT_CLASS_FUNCTION;\n\tdefault:\n\t\t/* Primitive or UNUSED, no class number. */\n\t\treturn DUK_HOBJECT_CLASS_NONE;\n\t}\n}\n\nDUK_EXTERNAL duk_bool_t duk_check_type(duk_context *ctx, duk_idx_t idx, duk_int_t type) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\treturn (duk_get_type(ctx, idx) == type) ? 1 : 0;\n}\n\nDUK_INTERNAL duk_uint_t duk_get_type_mask_tval(duk_tval *tv) {\n\tDUK_ASSERT(tv != NULL);\n\n#if defined(DUK_USE_PACKED_TVAL)\n\tswitch (DUK_TVAL_GET_TAG(tv)) {\n\tcase DUK_TAG_UNUSED:\n\t\treturn DUK_TYPE_MASK_NONE;\n\tcase DUK_TAG_UNDEFINED:\n\t\treturn DUK_TYPE_MASK_UNDEFINED;\n\tcase DUK_TAG_NULL:\n\t\treturn DUK_TYPE_MASK_NULL;\n\tcase DUK_TAG_BOOLEAN:\n\t\treturn DUK_TYPE_MASK_BOOLEAN;\n\tcase DUK_TAG_STRING:\n\t\treturn DUK_TYPE_MASK_STRING;\n\tcase DUK_TAG_OBJECT:\n\t\treturn DUK_TYPE_MASK_OBJECT;\n\tcase DUK_TAG_BUFFER:\n\t\treturn DUK_TYPE_MASK_BUFFER;\n\tcase DUK_TAG_POINTER:\n\t\treturn DUK_TYPE_MASK_POINTER;\n\tcase DUK_TAG_LIGHTFUNC:\n\t\treturn DUK_TYPE_MASK_LIGHTFUNC;\n#if defined(DUK_USE_FASTINT)\n\tcase DUK_TAG_FASTINT:\n#endif\n\tdefault:\n\t\t/* Note: number has no explicit tag (in 8-byte representation) */\n\t\tDUK_ASSERT(!DUK_TVAL_IS_UNUSED(tv));\n\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv));\n\t\treturn DUK_TYPE_MASK_NUMBER;\n\t}\n#else  /* DUK_USE_PACKED_TVAL */\n\tDUK_ASSERT(DUK_TVAL_IS_VALID_TAG(tv));\n\tDUK_ASSERT(sizeof(duk__type_mask_from_tag) / sizeof(duk_uint_t) == DUK_TAG_MAX - DUK_TAG_MIN + 1);\n\treturn (duk_int_t) duk__type_mask_from_tag[DUK_TVAL_GET_TAG(tv) - DUK_TAG_MIN];\n#endif  /* DUK_USE_PACKED_TVAL */\n}\n\nDUK_EXTERNAL duk_uint_t duk_get_type_mask(duk_context *ctx, duk_idx_t idx) {\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\n\treturn duk_get_type_mask_tval(tv);\n}\n\nDUK_EXTERNAL duk_bool_t duk_check_type_mask(duk_context *ctx, duk_idx_t idx, duk_uint_t mask) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tif (DUK_LIKELY(duk_get_type_mask(ctx, idx) & mask)) {\n\t\treturn 1;\n\t}\n\tif (mask & DUK_TYPE_MASK_THROW) {\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_UNEXPECTED_TYPE);\n\t\tDUK_UNREACHABLE();\n\t}\n\treturn 0;\n}\n\nDUK_EXTERNAL duk_bool_t duk_is_undefined(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\treturn duk__tag_check(ctx, idx, DUK_TAG_UNDEFINED);\n}\n\nDUK_EXTERNAL duk_bool_t duk_is_null(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\treturn duk__tag_check(ctx, idx, DUK_TAG_NULL);\n}\n\nDUK_EXTERNAL duk_bool_t duk_is_boolean(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\treturn duk__tag_check(ctx, idx, DUK_TAG_BOOLEAN);\n}\n\nDUK_EXTERNAL duk_bool_t duk_is_number(duk_context *ctx, duk_idx_t idx) {\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t/*\n\t *  Number is special because it doesn't have a specific\n\t *  tag in the 8-byte representation.\n\t */\n\n\t/* XXX: shorter version for unpacked representation? */\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\treturn DUK_TVAL_IS_NUMBER(tv);\n}\n\nDUK_EXTERNAL duk_bool_t duk_is_nan(duk_context *ctx, duk_idx_t idx) {\n\t/* XXX: This will now return false for non-numbers, even though they would\n\t * coerce to NaN (as a general rule).  In particular, duk_get_number()\n\t * returns a NaN for non-numbers, so should this function also return\n\t * true for non-numbers?\n\t */\n\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\n\t/* XXX: for packed duk_tval an explicit \"is number\" check is unnecessary */\n\tif (!DUK_TVAL_IS_NUMBER(tv)) {\n\t\treturn 0;\n\t}\n\treturn DUK_ISNAN(DUK_TVAL_GET_NUMBER(tv));\n}\n\nDUK_EXTERNAL duk_bool_t duk_is_string(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\treturn duk__tag_check(ctx, idx, DUK_TAG_STRING);\n}\n\nDUK_INTERNAL duk_bool_t duk_is_string_notsymbol(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\treturn duk_get_hstring_notsymbol(ctx, idx) != NULL;\n}\n\nDUK_EXTERNAL duk_bool_t duk_is_object(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\treturn duk__tag_check(ctx, idx, DUK_TAG_OBJECT);\n}\n\nDUK_EXTERNAL duk_bool_t duk_is_buffer(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\treturn duk__tag_check(ctx, idx, DUK_TAG_BUFFER);\n}\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_EXTERNAL duk_bool_t duk_is_buffer_data(duk_context *ctx, duk_idx_t idx) {\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tif (DUK_TVAL_IS_BUFFER(tv)) {\n\t\treturn 1;\n\t} else if (DUK_TVAL_IS_OBJECT(tv)) {\n\t\tduk_hobject *h = DUK_TVAL_GET_OBJECT(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\tif (DUK_HOBJECT_IS_BUFOBJ(h)) {\n\t\t\treturn 1;\n\t\t}\n\t}\n\treturn 0;\n}\n#else  /* DUK_USE_BUFFEROBJECT_SUPPORT */\nDUK_EXTERNAL duk_bool_t duk_is_buffer_data(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\treturn duk_is_buffer(ctx, idx);\n}\n\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\nDUK_EXTERNAL duk_bool_t duk_is_pointer(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\treturn duk__tag_check(ctx, idx, DUK_TAG_POINTER);\n}\n\nDUK_EXTERNAL duk_bool_t duk_is_lightfunc(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\treturn duk__tag_check(ctx, idx, DUK_TAG_LIGHTFUNC);\n}\n\nDUK_EXTERNAL duk_bool_t duk_is_symbol(duk_context *ctx, duk_idx_t idx) {\n\tduk_hstring *h;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\th = duk_get_hstring(ctx, idx);\n\t/* Use DUK_LIKELY() here because caller may be more likely to type\n\t * check an expected symbol than not.\n\t */\n\tif (DUK_LIKELY(h != NULL && DUK_HSTRING_HAS_SYMBOL(h))) {\n\t\treturn 1;\n\t}\n\treturn 0;\n}\n\nDUK_EXTERNAL duk_bool_t duk_is_array(duk_context *ctx, duk_idx_t idx) {\n\tduk_hobject *obj;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tobj = duk_get_hobject(ctx, idx);\n\tif (obj) {\n\t\treturn (DUK_HOBJECT_GET_CLASS_NUMBER(obj) == DUK_HOBJECT_CLASS_ARRAY ? 1 : 0);\n\t}\n\treturn 0;\n}\n\nDUK_EXTERNAL duk_bool_t duk_is_function(duk_context *ctx, duk_idx_t idx) {\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tif (DUK_TVAL_IS_LIGHTFUNC(tv)) {\n\t\treturn 1;\n\t}\n\treturn duk__obj_flag_any_default_false(ctx,\n\t                                       idx,\n\t                                       DUK_HOBJECT_FLAG_COMPFUNC |\n\t                                       DUK_HOBJECT_FLAG_NATFUNC |\n\t                                       DUK_HOBJECT_FLAG_BOUNDFUNC);\n}\n\nDUK_EXTERNAL duk_bool_t duk_is_c_function(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\treturn duk__obj_flag_any_default_false(ctx,\n\t                                       idx,\n\t                                       DUK_HOBJECT_FLAG_NATFUNC);\n}\n\nDUK_EXTERNAL duk_bool_t duk_is_ecmascript_function(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\treturn duk__obj_flag_any_default_false(ctx,\n\t                                       idx,\n\t                                       DUK_HOBJECT_FLAG_COMPFUNC);\n}\n\nDUK_EXTERNAL duk_bool_t duk_is_bound_function(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\treturn duk__obj_flag_any_default_false(ctx,\n\t                                       idx,\n\t                                       DUK_HOBJECT_FLAG_BOUNDFUNC);\n}\n\nDUK_EXTERNAL duk_bool_t duk_is_thread(duk_context *ctx, duk_idx_t idx) {\n\tduk_hobject *obj;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tobj = duk_get_hobject(ctx, idx);\n\tif (obj) {\n\t\treturn (DUK_HOBJECT_GET_CLASS_NUMBER(obj) == DUK_HOBJECT_CLASS_THREAD ? 1 : 0);\n\t}\n\treturn 0;\n}\n\nDUK_EXTERNAL duk_bool_t duk_is_fixed_buffer(duk_context *ctx, duk_idx_t idx) {\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tif (DUK_TVAL_IS_BUFFER(tv)) {\n\t\tduk_hbuffer *h = DUK_TVAL_GET_BUFFER(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\treturn (DUK_HBUFFER_HAS_DYNAMIC(h) ? 0 : 1);\n\t}\n\treturn 0;\n}\n\nDUK_EXTERNAL duk_bool_t duk_is_dynamic_buffer(duk_context *ctx, duk_idx_t idx) {\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tif (DUK_TVAL_IS_BUFFER(tv)) {\n\t\tduk_hbuffer *h = DUK_TVAL_GET_BUFFER(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\treturn (DUK_HBUFFER_HAS_DYNAMIC(h) && !DUK_HBUFFER_HAS_EXTERNAL(h) ? 1 : 0);\n\t}\n\treturn 0;\n}\n\nDUK_EXTERNAL duk_bool_t duk_is_external_buffer(duk_context *ctx, duk_idx_t idx) {\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv = duk_get_tval_or_unused(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tif (DUK_TVAL_IS_BUFFER(tv)) {\n\t\tduk_hbuffer *h = DUK_TVAL_GET_BUFFER(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\treturn (DUK_HBUFFER_HAS_DYNAMIC(h) && DUK_HBUFFER_HAS_EXTERNAL(h) ? 1 : 0);\n\t}\n\treturn 0;\n}\n\nDUK_EXTERNAL duk_errcode_t duk_get_error_code(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *h;\n\tduk_uint_t sanity;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\th = duk_get_hobject(ctx, idx);\n\n\tsanity = DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY;\n\tdo {\n\t\tif (!h) {\n\t\t\treturn DUK_ERR_NONE;\n\t\t}\n\t\tif (h == thr->builtins[DUK_BIDX_EVAL_ERROR_PROTOTYPE]) {\n\t\t\treturn DUK_ERR_EVAL_ERROR;\n\t\t}\n\t\tif (h == thr->builtins[DUK_BIDX_RANGE_ERROR_PROTOTYPE]) {\n\t\t\treturn DUK_ERR_RANGE_ERROR;\n\t\t}\n\t\tif (h == thr->builtins[DUK_BIDX_REFERENCE_ERROR_PROTOTYPE]) {\n\t\t\treturn DUK_ERR_REFERENCE_ERROR;\n\t\t}\n\t\tif (h == thr->builtins[DUK_BIDX_SYNTAX_ERROR_PROTOTYPE]) {\n\t\t\treturn DUK_ERR_SYNTAX_ERROR;\n\t\t}\n\t\tif (h == thr->builtins[DUK_BIDX_TYPE_ERROR_PROTOTYPE]) {\n\t\t\treturn DUK_ERR_TYPE_ERROR;\n\t\t}\n\t\tif (h == thr->builtins[DUK_BIDX_URI_ERROR_PROTOTYPE]) {\n\t\t\treturn DUK_ERR_URI_ERROR;\n\t\t}\n\t\tif (h == thr->builtins[DUK_BIDX_ERROR_PROTOTYPE]) {\n\t\t\treturn DUK_ERR_ERROR;\n\t\t}\n\n\t\th = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h);\n\t} while (--sanity > 0);\n\n\treturn DUK_ERR_NONE;\n}\n\n/*\n *  Pushers\n */\n\nDUK_INTERNAL void duk_push_tval(duk_context *ctx, duk_tval *tv) {\n\tduk_hthread *thr;\n\tduk_tval *tv_slot;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(tv != NULL);\n\tthr = (duk_hthread *) ctx;\n\tDUK__CHECK_SPACE();\n\ttv_slot = thr->valstack_top++;\n\tDUK_TVAL_SET_TVAL(tv_slot, tv);\n\tDUK_TVAL_INCREF(thr, tv);  /* no side effects */\n}\n\nDUK_EXTERNAL void duk_push_undefined(duk_context *ctx) {\n\tduk_hthread *thr;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\tDUK__CHECK_SPACE();\n\n\t/* Because value stack init policy is 'undefined above top',\n\t * we don't need to write, just assert.\n\t */\n\tthr->valstack_top++;\n\tDUK_ASSERT(DUK_TVAL_IS_UNDEFINED(thr->valstack_top - 1));\n}\n\nDUK_EXTERNAL void duk_push_null(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_tval *tv_slot;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\tDUK__CHECK_SPACE();\n\ttv_slot = thr->valstack_top++;\n\tDUK_TVAL_SET_NULL(tv_slot);\n}\n\nDUK_EXTERNAL void duk_push_boolean(duk_context *ctx, duk_bool_t val) {\n\tduk_hthread *thr;\n\tduk_tval *tv_slot;\n\tduk_small_int_t b;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\tDUK__CHECK_SPACE();\n\tb = (val ? 1 : 0);  /* ensure value is 1 or 0 (not other non-zero) */\n\ttv_slot = thr->valstack_top++;\n\tDUK_TVAL_SET_BOOLEAN(tv_slot, b);\n}\n\nDUK_EXTERNAL void duk_push_true(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_tval *tv_slot;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\tDUK__CHECK_SPACE();\n\ttv_slot = thr->valstack_top++;\n\tDUK_TVAL_SET_BOOLEAN_TRUE(tv_slot);\n}\n\nDUK_EXTERNAL void duk_push_false(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_tval *tv_slot;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\tDUK__CHECK_SPACE();\n\ttv_slot = thr->valstack_top++;\n\tDUK_TVAL_SET_BOOLEAN_FALSE(tv_slot);\n}\n\n/* normalize NaN which may not match our canonical internal NaN */\nDUK_EXTERNAL void duk_push_number(duk_context *ctx, duk_double_t val) {\n\tduk_hthread *thr;\n\tduk_tval *tv_slot;\n\tduk_double_union du;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\tDUK__CHECK_SPACE();\n\tdu.d = val;\n\tDUK_DBLUNION_NORMALIZE_NAN_CHECK(&du);\n\ttv_slot = thr->valstack_top++;\n\tDUK_TVAL_SET_NUMBER(tv_slot, du.d);\n}\n\nDUK_EXTERNAL void duk_push_int(duk_context *ctx, duk_int_t val) {\n#if defined(DUK_USE_FASTINT)\n\tduk_hthread *thr;\n\tduk_tval *tv_slot;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\tDUK__CHECK_SPACE();\n\ttv_slot = thr->valstack_top++;\n#if DUK_INT_MAX <= 0x7fffffffL\n\tDUK_TVAL_SET_I32(tv_slot, (duk_int32_t) val);\n#else\n\tif (val >= DUK_FASTINT_MIN && val <= DUK_FASTINT_MAX) {\n\t\tDUK_TVAL_SET_FASTINT(tv_slot, (duk_int64_t) val);\n\t} else {\n\t\tduk_double_t = (duk_double_t) val;\n\t\tDUK_TVAL_SET_NUMBER(tv_slot, d);\n\t}\n#endif\n#else  /* DUK_USE_FASTINT */\n\tduk_hthread *thr;\n\tduk_tval *tv_slot;\n\tduk_double_t d;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\tDUK__CHECK_SPACE();\n\td = (duk_double_t) val;\n\ttv_slot = thr->valstack_top++;\n\tDUK_TVAL_SET_NUMBER(tv_slot, d);\n#endif  /* DUK_USE_FASTINT */\n}\n\nDUK_EXTERNAL void duk_push_uint(duk_context *ctx, duk_uint_t val) {\n#if defined(DUK_USE_FASTINT)\n\tduk_hthread *thr;\n\tduk_tval *tv_slot;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\tDUK__CHECK_SPACE();\n\ttv_slot = thr->valstack_top++;\n#if DUK_UINT_MAX <= 0xffffffffUL\n\tDUK_TVAL_SET_U32(tv_slot, (duk_uint32_t) val);\n#else\n\tif (val <= DUK_FASTINT_MAX) {  /* val is unsigned so >= 0 */\n\t\t/* XXX: take advantage of val being unsigned, no need to mask */\n\t\tDUK_TVAL_SET_FASTINT(tv_slot, (duk_int64_t) val);\n\t} else {\n\t\tduk_double_t = (duk_double_t) val;\n\t\tDUK_TVAL_SET_NUMBER(tv_slot, d);\n\t}\n#endif\n#else  /* DUK_USE_FASTINT */\n\tduk_hthread *thr;\n\tduk_tval *tv_slot;\n\tduk_double_t d;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\tDUK__CHECK_SPACE();\n\td = (duk_double_t) val;\n\ttv_slot = thr->valstack_top++;\n\tDUK_TVAL_SET_NUMBER(tv_slot, d);\n#endif  /* DUK_USE_FASTINT */\n}\n\nDUK_EXTERNAL void duk_push_nan(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_tval *tv_slot;\n\tduk_double_union du;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\tDUK__CHECK_SPACE();\n\tDUK_DBLUNION_SET_NAN(&du);\n\tDUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du));\n\ttv_slot = thr->valstack_top++;\n\tDUK_TVAL_SET_NUMBER(tv_slot, du.d);\n}\n\nDUK_EXTERNAL const char *duk_push_lstring(duk_context *ctx, const char *str, duk_size_t len) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hstring *h;\n\tduk_tval *tv_slot;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t/* check stack before interning (avoid hanging temp) */\n\tDUK__CHECK_SPACE();\n\n\t/* NULL with zero length represents an empty string; NULL with higher\n\t * length is also now trated like an empty string although it is\n\t * a bit dubious.  This is unlike duk_push_string() which pushes a\n\t * 'null' if the input string is a NULL.\n\t */\n\tif (!str) {\n\t\tlen = 0;\n\t}\n\n\t/* Check for maximum string length */\n\tif (DUK_UNLIKELY(len > DUK_HSTRING_MAX_BYTELEN)) {\n\t\tDUK_ERROR_RANGE(thr, DUK_STR_STRING_TOO_LONG);\n\t}\n\n\th = duk_heap_strtable_intern_checked(thr, (const duk_uint8_t *) str, (duk_uint32_t) len);\n\tDUK_ASSERT(h != NULL);\n\n\ttv_slot = thr->valstack_top++;\n\tDUK_TVAL_SET_STRING(tv_slot, h);\n\tDUK_HSTRING_INCREF(thr, h);  /* no side effects */\n\n\treturn (const char *) DUK_HSTRING_GET_DATA(h);\n}\n\nDUK_EXTERNAL const char *duk_push_string(duk_context *ctx, const char *str) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tif (str) {\n\t\treturn duk_push_lstring(ctx, str, DUK_STRLEN(str));\n\t} else {\n\t\tduk_push_null(ctx);\n\t\treturn NULL;\n\t}\n}\n\nDUK_EXTERNAL void duk_push_pointer(duk_context *ctx, void *val) {\n\tduk_hthread *thr;\n\tduk_tval *tv_slot;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\tDUK__CHECK_SPACE();\n\ttv_slot = thr->valstack_top++;\n\tDUK_TVAL_SET_POINTER(tv_slot, val);\n}\n\nDUK_INTERNAL duk_hstring *duk_push_uint_to_hstring(duk_context *ctx, duk_uint_t i) {\n\tduk_hstring *h_tmp;\n\n\t/* XXX: this could be a direct DUK_SPRINTF to a buffer followed by duk_push_string() */\n\tduk_push_uint(ctx, (duk_uint_t) i);\n\th_tmp = duk_to_hstring_m1(ctx);\n\tDUK_ASSERT(h_tmp != NULL);\n\treturn h_tmp;\n}\n\nDUK_LOCAL void duk__push_this_helper(duk_context *ctx, duk_small_uint_t check_object_coercible) {\n\tduk_hthread *thr;\n\tduk_tval *tv_slot;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT_DISABLE(thr->callstack_top >= 0);  /* avoid warning (unsigned) */\n\tthr = (duk_hthread *) ctx;\n\tDUK_ASSERT(thr->callstack_top <= thr->callstack_size);\n\tDUK__CHECK_SPACE();\n\n\tDUK_ASSERT(DUK_TVAL_IS_UNDEFINED(thr->valstack_top));  /* because of valstack init policy */\n\ttv_slot = thr->valstack_top++;\n\n\tif (DUK_UNLIKELY(thr->callstack_top == 0)) {\n\t\tif (check_object_coercible) {\n\t\t\tgoto type_error;\n\t\t}\n\t\t/* 'undefined' already on stack top */\n\t} else {\n\t\tduk_tval *tv;\n\n\t\t/* 'this' binding is just before current activation's bottom */\n\t\tDUK_ASSERT(thr->valstack_bottom > thr->valstack);\n\t\ttv = thr->valstack_bottom - 1;\n\t\tif (check_object_coercible &&\n\t\t    (DUK_TVAL_IS_UNDEFINED(tv) || DUK_TVAL_IS_NULL(tv))) {\n\t\t\t/* XXX: better macro for DUK_TVAL_IS_UNDEFINED_OR_NULL(tv) */\n\t\t\tgoto type_error;\n\t\t}\n\n\t\tDUK_TVAL_SET_TVAL(tv_slot, tv);\n\t\tDUK_TVAL_INCREF(thr, tv);\n\t}\n\treturn;\n\n type_error:\n\tDUK_ERROR_TYPE(thr, DUK_STR_NOT_OBJECT_COERCIBLE);\n}\n\nDUK_EXTERNAL void duk_push_this(duk_context *ctx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tduk__push_this_helper(ctx, 0 /*check_object_coercible*/);\n}\n\nDUK_INTERNAL void duk_push_this_check_object_coercible(duk_context *ctx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tduk__push_this_helper(ctx, 1 /*check_object_coercible*/);\n}\n\nDUK_INTERNAL duk_hobject *duk_push_this_coercible_to_object(duk_context *ctx) {\n\tduk_hobject *h;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tduk__push_this_helper(ctx, 1 /*check_object_coercible*/);\n\th = duk_to_hobject(ctx, -1);\n\tDUK_ASSERT(h != NULL);\n\treturn h;\n}\n\nDUK_INTERNAL duk_hstring *duk_push_this_coercible_to_string(duk_context *ctx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tduk__push_this_helper(ctx, 1 /*check_object_coercible*/);\n\treturn duk_to_hstring_m1(ctx);  /* This will reject all Symbol values; accepts Symbol objects. */\n}\n\nDUK_INTERNAL duk_tval *duk_get_borrowed_this_tval(duk_context *ctx) {\n\tduk_hthread *thr;\n\n\tDUK_ASSERT(ctx != NULL);\n\tthr = (duk_hthread *) ctx;\n\n\tDUK_ASSERT(thr->callstack_top > 0);  /* caller required to know */\n\tDUK_ASSERT(thr->callstack_curr != NULL);\n\tDUK_ASSERT(thr->valstack_bottom > thr->valstack);  /* consequence of above */\n\tDUK_ASSERT(thr->valstack_bottom - 1 >= thr->valstack);  /* 'this' binding exists */\n\n\treturn thr->valstack_bottom - 1;\n}\n\nDUK_EXTERNAL void duk_push_current_function(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_activation *act;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT_DISABLE(thr->callstack_top >= 0);\n\tDUK_ASSERT(thr->callstack_top <= thr->callstack_size);\n\n\tact = thr->callstack_curr;\n\tif (act != NULL) {\n\t\tduk_push_tval(ctx, &act->tv_func);\n\t} else {\n\t\tduk_push_undefined(ctx);\n\t}\n}\n\nDUK_EXTERNAL void duk_push_current_thread(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr != NULL);\n\n\tif (thr->heap->curr_thread) {\n\t\tduk_push_hobject(ctx, (duk_hobject *) thr->heap->curr_thread);\n\t} else {\n\t\tduk_push_undefined(ctx);\n\t}\n}\n\nDUK_EXTERNAL void duk_push_global_object(duk_context *ctx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tduk_push_hobject_bidx(ctx, DUK_BIDX_GLOBAL);\n}\n\n/* XXX: size optimize */\nDUK_LOCAL void duk__push_stash(duk_context *ctx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tif (!duk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_INT_VALUE)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"creating heap/global/thread stash on first use\"));\n\t\tduk_pop(ctx);\n\t\tduk_push_bare_object(ctx);\n\t\tduk_dup_top(ctx);\n\t\tduk_xdef_prop_stridx_short(ctx, -3, DUK_STRIDX_INT_VALUE, DUK_PROPDESC_FLAGS_C);  /* [ ... parent stash stash ] -> [ ... parent stash ] */\n\t}\n\tduk_remove_m2(ctx);\n}\n\nDUK_EXTERNAL void duk_push_heap_stash(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_heap *heap;\n\tDUK_ASSERT_CTX_VALID(ctx);\n\theap = thr->heap;\n\tDUK_ASSERT(heap->heap_object != NULL);\n\tduk_push_hobject(ctx, heap->heap_object);\n\tduk__push_stash(ctx);\n}\n\nDUK_EXTERNAL void duk_push_global_stash(duk_context *ctx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tduk_push_global_object(ctx);\n\tduk__push_stash(ctx);\n}\n\nDUK_EXTERNAL void duk_push_thread_stash(duk_context *ctx, duk_context *target_ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tif (DUK_UNLIKELY(target_ctx == NULL)) {\n\t\tDUK_ERROR_TYPE_INVALID_ARGS(thr);\n\t\treturn;  /* not reached */\n\t}\n\tduk_push_hobject(ctx, (duk_hobject *) target_ctx);\n\tduk__push_stash(ctx);\n}\n\n/* XXX: duk_ssize_t would be useful here */\nDUK_LOCAL duk_int_t duk__try_push_vsprintf(duk_context *ctx, void *buf, duk_size_t sz, const char *fmt, va_list ap) {\n\tduk_int_t len;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_UNREF(ctx);\n\n\t/* NUL terminator handling doesn't matter here */\n\tlen = DUK_VSNPRINTF((char *) buf, sz, fmt, ap);\n\tif (len < (duk_int_t) sz) {\n\t\t/* Return value of 'sz' or more indicates output was (potentially)\n\t\t * truncated.\n\t\t */\n\t\treturn (duk_int_t) len;\n\t}\n\treturn -1;\n}\n\nDUK_EXTERNAL const char *duk_push_vsprintf(duk_context *ctx, const char *fmt, va_list ap) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_uint8_t stack_buf[DUK_PUSH_SPRINTF_INITIAL_SIZE];\n\tduk_size_t sz = DUK_PUSH_SPRINTF_INITIAL_SIZE;\n\tduk_bool_t pushed_buf = 0;\n\tvoid *buf;\n\tduk_int_t len;  /* XXX: duk_ssize_t */\n\tconst char *res;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t/* special handling of fmt==NULL */\n\tif (!fmt) {\n\t\tduk_hstring *h_str;\n\t\tduk_push_hstring_empty(ctx);\n\t\th_str = duk_known_hstring(ctx, -1);\n\t\treturn (const char *) DUK_HSTRING_GET_DATA(h_str);\n\t}\n\n\t/* initial estimate based on format string */\n\tsz = DUK_STRLEN(fmt) + 16;  /* format plus something to avoid just missing */\n\tif (sz < DUK_PUSH_SPRINTF_INITIAL_SIZE) {\n\t\tsz = DUK_PUSH_SPRINTF_INITIAL_SIZE;\n\t}\n\tDUK_ASSERT(sz > 0);\n\n\t/* Try to make do with a stack buffer to avoid allocating a temporary buffer.\n\t * This works 99% of the time which is quite nice.\n\t */\n\tfor (;;) {\n\t\tva_list ap_copy;  /* copied so that 'ap' can be reused */\n\n\t\tif (sz <= sizeof(stack_buf)) {\n\t\t\tbuf = stack_buf;\n\t\t} else if (!pushed_buf) {\n\t\t\tpushed_buf = 1;\n\t\t\tbuf = duk_push_dynamic_buffer(ctx, sz);\n\t\t} else {\n\t\t\tbuf = duk_resize_buffer(ctx, -1, sz);\n\t\t}\n\t\tDUK_ASSERT(buf != NULL);\n\n\t\tDUK_VA_COPY(ap_copy, ap);\n\t\tlen = duk__try_push_vsprintf(ctx, buf, sz, fmt, ap_copy);\n\t\tva_end(ap_copy);\n\t\tif (len >= 0) {\n\t\t\tbreak;\n\t\t}\n\n\t\t/* failed, resize and try again */\n\t\tsz = sz * 2;\n\t\tif (DUK_UNLIKELY(sz >= DUK_PUSH_SPRINTF_SANITY_LIMIT)) {\n\t\t\tDUK_ERROR_RANGE(thr, DUK_STR_RESULT_TOO_LONG);\n\t\t}\n\t}\n\n\t/* Cannot use duk_buffer_to_string() on the buffer because it is\n\t * usually larger than 'len'; 'buf' is also usually a stack buffer.\n\t */\n\tres = duk_push_lstring(ctx, (const char *) buf, (duk_size_t) len);  /* [ buf? res ] */\n\tif (pushed_buf) {\n\t\tduk_remove_m2(ctx);\n\t}\n\treturn res;\n}\n\nDUK_EXTERNAL const char *duk_push_sprintf(duk_context *ctx, const char *fmt, ...) {\n\tva_list ap;\n\tconst char *ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t/* allow fmt==NULL */\n\tva_start(ap, fmt);\n\tret = duk_push_vsprintf(ctx, fmt, ap);\n\tva_end(ap);\n\n\treturn ret;\n}\n\nDUK_INTERNAL duk_hobject *duk_push_object_helper(duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_small_int_t prototype_bidx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv_slot;\n\tduk_hobject *h;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(prototype_bidx == -1 ||\n\t           (prototype_bidx >= 0 && prototype_bidx < DUK_NUM_BUILTINS));\n\n\tDUK__CHECK_SPACE();\n\n\th = duk_hobject_alloc(thr, hobject_flags_and_class);\n\tDUK_ASSERT(h != NULL);\n\n\tDUK_DDD(DUK_DDDPRINT(\"created object with flags: 0x%08lx\", (unsigned long) h->hdr.h_flags));\n\n\ttv_slot = thr->valstack_top;\n\tDUK_TVAL_SET_OBJECT(tv_slot, h);\n\tDUK_HOBJECT_INCREF(thr, h);  /* no side effects */\n\tthr->valstack_top++;\n\n\t/* object is now reachable */\n\n\tif (prototype_bidx >= 0) {\n\t\tDUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, h, thr->builtins[prototype_bidx]);\n\t} else {\n\t\tDUK_ASSERT(prototype_bidx == -1);\n\t\tDUK_ASSERT(DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h) == NULL);\n\t}\n\n\treturn h;\n}\n\nDUK_INTERNAL duk_hobject *duk_push_object_helper_proto(duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_hobject *proto) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *h;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\th = duk_push_object_helper(ctx, hobject_flags_and_class, -1);\n\tDUK_ASSERT(h != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h) == NULL);\n\tDUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, h, proto);\n\treturn h;\n}\n\nDUK_EXTERNAL duk_idx_t duk_push_object(duk_context *ctx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t(void) duk_push_object_helper(ctx,\n\t                              DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                              DUK_HOBJECT_FLAG_FASTREFS |\n\t                              DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_OBJECT),\n\t                              DUK_BIDX_OBJECT_PROTOTYPE);\n\treturn duk_get_top_index_unsafe(ctx);\n}\n\nDUK_EXTERNAL duk_idx_t duk_push_array(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_uint_t flags;\n\tduk_harray *obj;\n\tduk_idx_t ret;\n\tduk_tval *tv_slot;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tflags = DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t        DUK_HOBJECT_FLAG_FASTREFS |\n\t        DUK_HOBJECT_FLAG_ARRAY_PART |\n\t        DUK_HOBJECT_FLAG_EXOTIC_ARRAY |\n\t        DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_ARRAY);\n\n\tobj = duk_harray_alloc(thr, flags);\n\tDUK_ASSERT(obj != NULL);\n\n\t/* XXX: since prototype is NULL, could save a check */\n\tDUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, (duk_hobject *) obj, thr->builtins[DUK_BIDX_ARRAY_PROTOTYPE]);\n\n\ttv_slot = thr->valstack_top;\n\tDUK_TVAL_SET_OBJECT(tv_slot, (duk_hobject *) obj);\n\tDUK_HOBJECT_INCREF(thr, obj);  /* XXX: could preallocate with refcount = 1 */\n\tret = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom);\n\tthr->valstack_top++;\n\n\tDUK_ASSERT(obj->length == 0);  /* Array .length starts at zero. */\n\treturn ret;\n}\n\nDUK_INTERNAL duk_harray *duk_push_harray(duk_context *ctx) {\n\t/* XXX: API call could do this directly, cast to void in API macro. */\n\tduk_hthread *thr;\n\tduk_harray *a;\n\n\tthr = (duk_hthread *) ctx;\n\t(void) duk_push_array(ctx);\n\tDUK_ASSERT(DUK_TVAL_IS_OBJECT(thr->valstack_top - 1));\n\ta = (duk_harray *) DUK_TVAL_GET_OBJECT(thr->valstack_top - 1);\n\tDUK_ASSERT(a != NULL);\n\treturn a;\n}\n\n/* Push a duk_harray with preallocated size (.length also set to match size).\n * Caller may then populate array part of the duk_harray directly.\n */\nDUK_INTERNAL duk_harray *duk_push_harray_with_size(duk_context *ctx, duk_uint32_t size) {\n\tduk_harray *a;\n\n\ta = duk_push_harray(ctx);\n\n\tduk_hobject_realloc_props((duk_hthread *) ctx,\n\t                          (duk_hobject *) a,\n\t                          0,\n\t                          size,\n\t                          0,\n\t                          0);\n\ta->length = size;\n\treturn a;\n}\n\nDUK_EXTERNAL duk_idx_t duk_push_thread_raw(duk_context *ctx, duk_uint_t flags) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hthread *obj;\n\tduk_idx_t ret;\n\tduk_tval *tv_slot;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tDUK__CHECK_SPACE();\n\n\tobj = duk_hthread_alloc(thr,\n\t                        DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                        DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_THREAD));\n\tDUK_ASSERT(obj != NULL);\n\tobj->state = DUK_HTHREAD_STATE_INACTIVE;\n#if defined(DUK_USE_ROM_STRINGS)\n\t/* Nothing to initialize, strs[] is in ROM. */\n#else\n#if defined(DUK_USE_HEAPPTR16)\n\tobj->strs16 = thr->strs16;\n#else\n\tobj->strs = thr->strs;\n#endif\n#endif\n\tDUK_DDD(DUK_DDDPRINT(\"created thread object with flags: 0x%08lx\", (unsigned long) obj->obj.hdr.h_flags));\n\n\t/* make the new thread reachable */\n\ttv_slot = thr->valstack_top;\n\tDUK_TVAL_SET_OBJECT(tv_slot, (duk_hobject *) obj);\n\tDUK_HTHREAD_INCREF(thr, obj);\n\tret = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom);\n\tthr->valstack_top++;\n\n\t/* important to do this *after* pushing, to make the thread reachable for gc */\n\tif (DUK_UNLIKELY(!duk_hthread_init_stacks(thr->heap, obj))) {\n\t\tDUK_ERROR_ALLOC_FAILED(thr);\n\t}\n\n\t/* initialize built-ins - either by copying or creating new ones */\n\tif (flags & DUK_THREAD_NEW_GLOBAL_ENV) {\n\t\tduk_hthread_create_builtin_objects(obj);\n\t} else {\n\t\tduk_hthread_copy_builtin_objects(thr, obj);\n\t}\n\n\t/* default prototype (Note: 'obj' must be reachable) */\n\t/* XXX: since prototype is NULL, could save a check */\n\tDUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, (duk_hobject *) obj, obj->builtins[DUK_BIDX_THREAD_PROTOTYPE]);\n\n\t/* Initial stack size satisfies the stack spare constraints so there\n\t * is no need to require stack here.\n\t */\n\tDUK_ASSERT(DUK_VALSTACK_INITIAL_SIZE >=\n\t           DUK_VALSTACK_API_ENTRY_MINIMUM + DUK_VALSTACK_INTERNAL_EXTRA);\n\n\treturn ret;\n}\n\nDUK_INTERNAL duk_hcompfunc *duk_push_hcompfunc(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hcompfunc *obj;\n\tduk_tval *tv_slot;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tDUK__CHECK_SPACE();\n\n\t/* Template functions are not strictly constructable (they don't\n\t * have a \"prototype\" property for instance), so leave the\n\t * DUK_HOBJECT_FLAG_CONSRUCTABLE flag cleared here.\n\t */\n\n\tobj = duk_hcompfunc_alloc(thr,\n\t                          DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                          DUK_HOBJECT_FLAG_COMPFUNC |\n\t                          DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_FUNCTION));\n\tif (DUK_UNLIKELY(obj == NULL)) {\n\t\tDUK_ERROR_ALLOC_FAILED(thr);\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"created compiled function object with flags: 0x%08lx\", (unsigned long) obj->obj.hdr.h_flags));\n\n\ttv_slot = thr->valstack_top;\n\tDUK_TVAL_SET_OBJECT(tv_slot, (duk_hobject *) obj);\n\tDUK_HOBJECT_INCREF(thr, obj);\n\tthr->valstack_top++;\n\n\tDUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, (duk_hobject *) obj, thr->builtins[DUK_BIDX_FUNCTION_PROTOTYPE]);\n\n\treturn obj;\n}\n\nDUK_LOCAL duk_idx_t duk__push_c_function_raw(duk_context *ctx, duk_c_function func, duk_idx_t nargs, duk_uint_t flags) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hnatfunc *obj;\n\tduk_idx_t ret;\n\tduk_tval *tv_slot;\n\tduk_int16_t func_nargs;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tDUK__CHECK_SPACE();\n\n\tif (DUK_UNLIKELY(func == NULL)) {\n\t\tgoto api_error;\n\t}\n\tif (nargs >= 0 && nargs < DUK_HNATFUNC_NARGS_MAX) {\n\t\tfunc_nargs = (duk_int16_t) nargs;\n\t} else if (nargs == DUK_VARARGS) {\n\t\tfunc_nargs = DUK_HNATFUNC_NARGS_VARARGS;\n\t} else {\n\t\tgoto api_error;\n\t}\n\n\tobj = duk_hnatfunc_alloc(thr, flags);\n\tDUK_ASSERT(obj != NULL);\n\n\tobj->func = func;\n\tobj->nargs = func_nargs;\n\n\tDUK_DDD(DUK_DDDPRINT(\"created native function object with flags: 0x%08lx, nargs=%ld\",\n\t                     (unsigned long) obj->obj.hdr.h_flags, (long) obj->nargs));\n\n\ttv_slot = thr->valstack_top;\n\tDUK_TVAL_SET_OBJECT(tv_slot, (duk_hobject *) obj);\n\tDUK_HOBJECT_INCREF(thr, obj);\n\tret = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom);\n\tthr->valstack_top++;\n\n\t/* default prototype (Note: 'obj' must be reachable) */\n\tDUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, (duk_hobject *) obj, thr->builtins[DUK_BIDX_FUNCTION_PROTOTYPE]);\n\n\treturn ret;\n\n api_error:\n\tDUK_ERROR_TYPE_INVALID_ARGS(thr);\n\treturn 0;  /* not reached */\n}\n\nDUK_EXTERNAL duk_idx_t duk_push_c_function(duk_context *ctx, duk_c_function func, duk_int_t nargs) {\n\tduk_uint_t flags;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tflags = DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t        DUK_HOBJECT_FLAG_CONSTRUCTABLE |\n\t        DUK_HOBJECT_FLAG_FASTREFS |\n\t        DUK_HOBJECT_FLAG_NATFUNC |\n\t        DUK_HOBJECT_FLAG_NEWENV |\n\t        DUK_HOBJECT_FLAG_STRICT |\n\t        DUK_HOBJECT_FLAG_NOTAIL |\n\t        DUK_HOBJECT_FLAG_EXOTIC_DUKFUNC |\n\t        DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_FUNCTION);\n\n\treturn duk__push_c_function_raw(ctx, func, nargs, flags);\n}\n\nDUK_INTERNAL void duk_push_c_function_noexotic(duk_context *ctx, duk_c_function func, duk_int_t nargs) {\n\tduk_uint_t flags;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tflags = DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t        DUK_HOBJECT_FLAG_CONSTRUCTABLE |\n\t        DUK_HOBJECT_FLAG_FASTREFS |\n\t        DUK_HOBJECT_FLAG_NATFUNC |\n\t        DUK_HOBJECT_FLAG_NEWENV |\n\t        DUK_HOBJECT_FLAG_STRICT |\n\t        DUK_HOBJECT_FLAG_NOTAIL |\n\t        DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_FUNCTION);\n\n\t(void) duk__push_c_function_raw(ctx, func, nargs, flags);\n}\n\nDUK_INTERNAL void duk_push_c_function_noconstruct_noexotic(duk_context *ctx, duk_c_function func, duk_int_t nargs) {\n\tduk_uint_t flags;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tflags = DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t        DUK_HOBJECT_FLAG_FASTREFS |\n\t        DUK_HOBJECT_FLAG_NATFUNC |\n\t        DUK_HOBJECT_FLAG_NEWENV |\n\t        DUK_HOBJECT_FLAG_STRICT |\n\t        DUK_HOBJECT_FLAG_NOTAIL |\n\t        DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_FUNCTION);\n\n\t(void) duk__push_c_function_raw(ctx, func, nargs, flags);\n}\n\nDUK_EXTERNAL duk_idx_t duk_push_c_lightfunc(duk_context *ctx, duk_c_function func, duk_idx_t nargs, duk_idx_t length, duk_int_t magic) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval tv_tmp;\n\tduk_small_uint_t lf_flags;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tDUK__CHECK_SPACE();\n\n\tif (nargs >= DUK_LFUNC_NARGS_MIN && nargs <= DUK_LFUNC_NARGS_MAX) {\n\t\t/* as is */\n\t} else if (nargs == DUK_VARARGS) {\n\t\tnargs = DUK_LFUNC_NARGS_VARARGS;\n\t} else {\n\t\tgoto api_error;\n\t}\n\tif (DUK_UNLIKELY(!(length >= DUK_LFUNC_LENGTH_MIN && length <= DUK_LFUNC_LENGTH_MAX))) {\n\t\tgoto api_error;\n\t}\n\tif (DUK_UNLIKELY(!(magic >= DUK_LFUNC_MAGIC_MIN && magic <= DUK_LFUNC_MAGIC_MAX))) {\n\t\tgoto api_error;\n\t}\n\n\tlf_flags = DUK_LFUNC_FLAGS_PACK(magic, length, nargs);\n\tDUK_TVAL_SET_LIGHTFUNC(&tv_tmp, func, lf_flags);\n\tduk_push_tval(ctx, &tv_tmp);  /* XXX: direct valstack write */\n\tDUK_ASSERT(thr->valstack_top != thr->valstack_bottom);\n\treturn ((duk_idx_t) (thr->valstack_top - thr->valstack_bottom)) - 1;\n\n api_error:\n\tDUK_ERROR_TYPE_INVALID_ARGS(thr);\n\treturn 0;  /* not reached */\n}\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL duk_hbufobj *duk_push_bufobj_raw(duk_context *ctx, duk_uint_t hobject_flags_and_class, duk_small_int_t prototype_bidx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hbufobj *obj;\n\tduk_tval *tv_slot;\n\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(prototype_bidx >= 0);\n\n\tDUK__CHECK_SPACE();\n\n\tobj = duk_hbufobj_alloc(thr, hobject_flags_and_class);\n\tDUK_ASSERT(obj != NULL);\n\n\tDUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, (duk_hobject *) obj, thr->builtins[prototype_bidx]);\n\tDUK_ASSERT_HBUFOBJ_VALID(obj);\n\n\ttv_slot = thr->valstack_top;\n\tDUK_TVAL_SET_OBJECT(tv_slot, (duk_hobject *) obj);\n\tDUK_HOBJECT_INCREF(thr, obj);\n\tthr->valstack_top++;\n\n\treturn obj;\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/* XXX: There's quite a bit of overlap with buffer creation handling in\n * duk_bi_buffer.c.  Look for overlap and refactor.\n */\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n#define DUK__PACK_ARGS(classnum,protobidx,elemtype,elemshift,istypedarray) \\\n\t(((classnum) << 24) | ((protobidx) << 16) | ((elemtype) << 8) | ((elemshift) << 4) | (istypedarray))\n\nstatic const duk_uint32_t duk__bufobj_flags_lookup[] = {\n\t/* Node.js Buffers are Uint8Array instances which inherit from Buffer.prototype. */\n\tDUK__PACK_ARGS(DUK_HOBJECT_CLASS_ARRAYBUFFER,       DUK_BIDX_ARRAYBUFFER_PROTOTYPE,       DUK_HBUFOBJ_ELEM_UINT8,        0, 0),  /* DUK_BUFOBJ_ARRAYBUFFER */\n\tDUK__PACK_ARGS(DUK_HOBJECT_CLASS_UINT8ARRAY,        DUK_BIDX_NODEJS_BUFFER_PROTOTYPE,     DUK_HBUFOBJ_ELEM_UINT8,        0, 1),  /* DUK_BUFOBJ_NODEJS_BUFFER */\n\tDUK__PACK_ARGS(DUK_HOBJECT_CLASS_DATAVIEW,          DUK_BIDX_DATAVIEW_PROTOTYPE,          DUK_HBUFOBJ_ELEM_UINT8,        0, 0),  /* DUK_BUFOBJ_DATAVIEW */\n\tDUK__PACK_ARGS(DUK_HOBJECT_CLASS_INT8ARRAY,         DUK_BIDX_INT8ARRAY_PROTOTYPE,         DUK_HBUFOBJ_ELEM_INT8,         0, 1),  /* DUK_BUFOBJ_INT8ARRAY */\n\tDUK__PACK_ARGS(DUK_HOBJECT_CLASS_UINT8ARRAY,        DUK_BIDX_UINT8ARRAY_PROTOTYPE,        DUK_HBUFOBJ_ELEM_UINT8,        0, 1),  /* DUK_BUFOBJ_UINT8ARRAY */\n\tDUK__PACK_ARGS(DUK_HOBJECT_CLASS_UINT8CLAMPEDARRAY, DUK_BIDX_UINT8CLAMPEDARRAY_PROTOTYPE, DUK_HBUFOBJ_ELEM_UINT8CLAMPED, 0, 1),  /* DUK_BUFOBJ_UINT8CLAMPEDARRAY */\n\tDUK__PACK_ARGS(DUK_HOBJECT_CLASS_INT16ARRAY,        DUK_BIDX_INT16ARRAY_PROTOTYPE,        DUK_HBUFOBJ_ELEM_INT16,        1, 1),  /* DUK_BUFOBJ_INT16ARRAY */\n\tDUK__PACK_ARGS(DUK_HOBJECT_CLASS_UINT16ARRAY,       DUK_BIDX_UINT16ARRAY_PROTOTYPE,       DUK_HBUFOBJ_ELEM_UINT16,       1, 1),  /* DUK_BUFOBJ_UINT16ARRAY */\n\tDUK__PACK_ARGS(DUK_HOBJECT_CLASS_INT32ARRAY,        DUK_BIDX_INT32ARRAY_PROTOTYPE,        DUK_HBUFOBJ_ELEM_INT32,        2, 1),  /* DUK_BUFOBJ_INT32ARRAY */\n\tDUK__PACK_ARGS(DUK_HOBJECT_CLASS_UINT32ARRAY,       DUK_BIDX_UINT32ARRAY_PROTOTYPE,       DUK_HBUFOBJ_ELEM_UINT32,       2, 1),  /* DUK_BUFOBJ_UINT32ARRAY */\n\tDUK__PACK_ARGS(DUK_HOBJECT_CLASS_FLOAT32ARRAY,      DUK_BIDX_FLOAT32ARRAY_PROTOTYPE,      DUK_HBUFOBJ_ELEM_FLOAT32,      2, 1),  /* DUK_BUFOBJ_FLOAT32ARRAY */\n\tDUK__PACK_ARGS(DUK_HOBJECT_CLASS_FLOAT64ARRAY,      DUK_BIDX_FLOAT64ARRAY_PROTOTYPE,      DUK_HBUFOBJ_ELEM_FLOAT64,      3, 1)   /* DUK_BUFOBJ_FLOAT64ARRAY */\n};\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_EXTERNAL void duk_push_buffer_object(duk_context *ctx, duk_idx_t idx_buffer, duk_size_t byte_offset, duk_size_t byte_length, duk_uint_t flags) {\n\tduk_hthread *thr;\n\tduk_hbufobj *h_bufobj;\n\tduk_hbuffer *h_val;\n\tduk_uint32_t tmp;\n\tduk_uint_t classnum;\n\tduk_uint_t protobidx;\n\tduk_uint_t lookupidx;\n\tduk_uint_t uint_offset, uint_length, uint_added;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\tDUK_UNREF(thr);\n\n\t/* The underlying types for offset/length in duk_hbufobj is\n\t * duk_uint_t; make sure argument values fit and that\n\t * offset + length does not wrap.\n\t */\n\tuint_offset = (duk_uint_t) byte_offset;\n\tuint_length = (duk_uint_t) byte_length;\n\tif (sizeof(duk_size_t) != sizeof(duk_uint_t)) {\n\t\tif (DUK_UNLIKELY((duk_size_t) uint_offset != byte_offset || (duk_size_t) uint_length != byte_length)) {\n\t\t\tgoto range_error;\n\t\t}\n\t}\n\tuint_added = uint_offset + uint_length;\n\tif (DUK_UNLIKELY(uint_added < uint_offset)) {\n\t\tgoto range_error;\n\t}\n\tDUK_ASSERT(uint_added >= uint_offset && uint_added >= uint_length);\n\n\tDUK_ASSERT_DISABLE(flags >= 0);  /* flags is unsigned */\n\tlookupidx = flags;\n\tif (DUK_UNLIKELY(lookupidx >= sizeof(duk__bufobj_flags_lookup) / sizeof(duk_uint32_t))) {\n\t\tgoto arg_error;\n\t}\n\ttmp = duk__bufobj_flags_lookup[lookupidx];\n\tclassnum = tmp >> 24;\n\tprotobidx = (tmp >> 16) & 0xff;\n\n\th_val = duk_require_hbuffer(ctx, idx_buffer);\n\tDUK_ASSERT(h_val != NULL);\n\n\th_bufobj = duk_push_bufobj_raw(ctx,\n\t                               DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                               DUK_HOBJECT_FLAG_BUFOBJ |\n\t                               DUK_HOBJECT_CLASS_AS_FLAGS(classnum),\n\t                               protobidx);\n\tDUK_ASSERT(h_bufobj != NULL);\n\n\th_bufobj->buf = h_val;\n\tDUK_HBUFFER_INCREF(thr, h_val);\n\th_bufobj->offset = uint_offset;\n\th_bufobj->length = uint_length;\n\th_bufobj->shift = (tmp >> 4) & 0x0f;\n\th_bufobj->elem_type = (tmp >> 8) & 0xff;\n\th_bufobj->is_typedarray = tmp & 0x0f;\n\tDUK_ASSERT_HBUFOBJ_VALID(h_bufobj);\n\n\t/* TypedArray views need an automatic ArrayBuffer which must be\n\t * provided as .buffer property of the view.  The ArrayBuffer is\n\t * referenced via duk_hbufobj->buf_prop and an inherited .buffer\n\t * accessor returns it.  The ArrayBuffer is created lazily on first\n\t * access so we don't need to do anything more here.\n\t */\n\treturn;\n\n range_error:\n\tDUK_ERROR_RANGE(thr, DUK_STR_INVALID_ARGS);\n\treturn;  /* not reached */\n\n arg_error:\n\tDUK_ERROR_TYPE(thr, DUK_STR_INVALID_ARGS);\n\treturn;  /* not reached */\n}\n#else  /* DUK_USE_BUFFEROBJECT_SUPPORT */\nDUK_EXTERNAL void duk_push_buffer_object(duk_context *ctx, duk_idx_t idx_buffer, duk_size_t byte_offset, duk_size_t byte_length, duk_uint_t flags) {\n\tDUK_UNREF(idx_buffer);\n\tDUK_UNREF(byte_offset);\n\tDUK_UNREF(byte_length);\n\tDUK_UNREF(flags);\n\tDUK_ERROR_UNSUPPORTED((duk_hthread *) ctx);\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\nDUK_EXTERNAL duk_idx_t duk_push_error_object_va_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, va_list ap) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *proto;\n#if defined(DUK_USE_AUGMENT_ERROR_CREATE)\n\tduk_bool_t noblame_fileline;\n#endif\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr != NULL);\n\tDUK_UNREF(filename);\n\tDUK_UNREF(line);\n\n\t/* Error code also packs a tracedata related flag. */\n#if defined(DUK_USE_AUGMENT_ERROR_CREATE)\n\tnoblame_fileline = err_code & DUK_ERRCODE_FLAG_NOBLAME_FILELINE;\n#endif\n\terr_code = err_code & (~DUK_ERRCODE_FLAG_NOBLAME_FILELINE);\n\n\t/* error gets its 'name' from the prototype */\n\tproto = duk_error_prototype_from_code(thr, err_code);\n\t(void) duk_push_object_helper_proto(ctx,\n\t                                    DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                                    DUK_HOBJECT_FLAG_FASTREFS |\n\t                                    DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_ERROR),\n\t                                    proto);\n\n\t/* ... and its 'message' from an instance property */\n\tif (fmt) {\n\t\tduk_push_vsprintf(ctx, fmt, ap);\n\t\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_MESSAGE, DUK_PROPDESC_FLAGS_WC);\n\t} else {\n\t\t/* If no explicit message given, put error code into message field\n\t\t * (as a number).  This is not fully in keeping with the Ecmascript\n\t\t * error model because messages are supposed to be strings (Error\n\t\t * constructors use ToString() on their argument).  However, it's\n\t\t * probably more useful than having a separate 'code' property.\n\t\t */\n\t\tduk_push_int(ctx, err_code);\n\t\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_MESSAGE, DUK_PROPDESC_FLAGS_WC);\n\t}\n\n\t/* XXX: .code = err_code disabled, not sure if useful */\n\n\t/* Creation time error augmentation */\n#if defined(DUK_USE_AUGMENT_ERROR_CREATE)\n\t/* filename may be NULL in which case file/line is not recorded */\n\tduk_err_augment_error_create(thr, thr, filename, line, noblame_fileline);  /* may throw an error */\n#endif\n\n\treturn duk_get_top_index_unsafe(ctx);\n}\n\nDUK_EXTERNAL duk_idx_t duk_push_error_object_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, ...) {\n\tva_list ap;\n\tduk_idx_t ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tva_start(ap, fmt);\n\tret = duk_push_error_object_va_raw(ctx, err_code, filename, line, fmt, ap);\n\tva_end(ap);\n\treturn ret;\n}\n\n#if !defined(DUK_USE_VARIADIC_MACROS)\nDUK_EXTERNAL duk_idx_t duk_push_error_object_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt, ...) {\n\tconst char *filename = duk_api_global_filename;\n\tduk_int_t line = duk_api_global_line;\n\tva_list ap;\n\tduk_idx_t ret;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tduk_api_global_filename = NULL;\n\tduk_api_global_line = 0;\n\tva_start(ap, fmt);\n\tret = duk_push_error_object_va_raw(ctx, err_code, filename, line, fmt, ap);\n\tva_end(ap);\n\treturn ret;\n}\n#endif  /* DUK_USE_VARIADIC_MACROS */\n\nDUK_EXTERNAL void *duk_push_buffer_raw(duk_context *ctx, duk_size_t size, duk_small_uint_t flags) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv_slot;\n\tduk_hbuffer *h;\n\tvoid *buf_data;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tDUK__CHECK_SPACE();\n\n\t/* Check for maximum buffer length. */\n\tif (DUK_UNLIKELY(size > DUK_HBUFFER_MAX_BYTELEN)) {\n\t\tDUK_ERROR_RANGE(thr, DUK_STR_BUFFER_TOO_LONG);\n\t}\n\n\th = duk_hbuffer_alloc(thr->heap, size, flags, &buf_data);\n\tif (DUK_UNLIKELY(h == NULL)) {\n\t\tDUK_ERROR_ALLOC_FAILED(thr);\n\t}\n\n\ttv_slot = thr->valstack_top;\n\tDUK_TVAL_SET_BUFFER(tv_slot, h);\n\tDUK_HBUFFER_INCREF(thr, h);\n\tthr->valstack_top++;\n\n\treturn (void *) buf_data;\n}\n\nDUK_INTERNAL void *duk_push_fixed_buffer_nozero(duk_context *ctx, duk_size_t len) {\n\treturn duk_push_buffer_raw(ctx, len, DUK_BUF_FLAG_NOZERO);\n}\n\nDUK_INTERNAL void *duk_push_fixed_buffer_zero(duk_context *ctx, duk_size_t len) {\n\tvoid *ptr;\n\tptr = duk_push_buffer_raw(ctx, len, 0);\n#if !defined(DUK_USE_ZERO_BUFFER_DATA)\n\t/* ES2015 requires zeroing even when DUK_USE_ZERO_BUFFER_DATA\n\t * is not set.\n\t */\n\tDUK_MEMZERO((void *) ptr, (size_t) len);\n#endif\n\treturn ptr;\n}\n\n#if defined(DUK_USE_ASSERTIONS)\nDUK_LOCAL void duk__validate_push_heapptr(duk_context *ctx, void *ptr) {\n\tduk_heaphdr *h;\n\tduk_heaphdr *curr;\n\tduk_hthread *thr;\n\tduk_bool_t found = 0;\n\n\tthr = (duk_hthread *) ctx;\n\th = (duk_heaphdr *) ptr;\n\tif (h == NULL) {\n\t\t/* Allowed. */\n\t\treturn;\n\t}\n\tDUK_ASSERT(h != NULL);\n\tDUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID(h));\n\n\t/* One particular problem case is where an object has been\n\t * queued for finalization but the finalizer hasn't yet been\n\t * executed.\n\t *\n\t * Corner case: we're running in a finalizer for object X, and\n\t * user code calls duk_push_heapptr() for X itself.  In this\n\t * case X will be in finalize_list, and we can detect the case\n\t * by seeing that X's FINALIZED flag is set (which is done before\n\t * the finalizer starts executing).\n\t */\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n\tfor (curr = thr->heap->finalize_list;\n\t     curr != NULL;\n\t     curr = DUK_HEAPHDR_GET_NEXT(thr->heap, curr)) {\n\t\t/* FINALIZABLE is set for all objects on finalize_list\n\t\t * except for an object being finalized right now.  So\n\t\t * can't assert here.\n\t\t */\n#if 0\n\t\tDUK_ASSERT(DUK_HEAPHDR_HAS_FINALIZABLE(curr));\n#endif\n\n\t\tif (curr == h) {\n\t\t\tif (DUK_HEAPHDR_HAS_FINALIZED((duk_heaphdr *) h)) {\n\t\t\t\t/* Object is currently being finalized. */\n\t\t\t\tDUK_ASSERT(found == 0);  /* Would indicate corrupted lists. */\n\t\t\t\tfound = 1;\n\t\t\t} else {\n\t\t\t\t/* Not being finalized but on finalize_list,\n\t\t\t\t * allowed since Duktape 2.1.\n\t\t\t\t */\n\t\t\t\tDUK_ASSERT(found == 0);  /* Would indicate corrupted lists. */\n\t\t\t\tfound = 1;\n\t\t\t}\n\t\t}\n\t}\n#endif  /* DUK_USE_FINALIZER_SUPPORT */\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\t/* Because refzero_list is now processed to completion inline with\n\t * no side effects, it's always empty here.\n\t */\n\tDUK_ASSERT(thr->heap->refzero_list == NULL);\n#endif\n\n\t/* If not present in finalize_list (or refzero_list), it\n\t * must be either in heap_allocated or the string table.\n\t */\n\tif (DUK_HEAPHDR_IS_STRING(h)) {\n\t\tduk_uint32_t i;\n\t\tduk_hstring *str;\n\t\tduk_heap *heap = thr->heap;\n\n\t\tDUK_ASSERT(found == 0);\n\t\tfor (i = 0; i < heap->st_size; i++) {\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\t\t\tstr = DUK_USE_HEAPPTR_DEC16((heap)->heap_udata, heap->strtable16[i]);\n#else\n\t\t\tstr = heap->strtable[i];\n#endif\n\t\t\twhile (str != NULL) {\n\t\t\t\tif (str == (duk_hstring *) h) {\n\t\t\t\t\tDUK_ASSERT(found == 0);  /* Would indicate corrupted lists. */\n\t\t\t\t\tfound = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tstr = str->hdr.h_next;\n\t\t\t}\n\t\t}\n\t\tDUK_ASSERT(found != 0);\n\t} else {\n\t\tfor (curr = thr->heap->heap_allocated;\n\t\t     curr != NULL;\n\t\t     curr = DUK_HEAPHDR_GET_NEXT(thr->heap, curr)) {\n\t\t\tif (curr == h) {\n\t\t\t\tDUK_ASSERT(found == 0);  /* Would indicate corrupted lists. */\n\t\t\t\tfound = 1;\n\t\t\t}\n\t\t}\n\t\tDUK_ASSERT(found != 0);\n\t}\n}\n#endif  /* DUK_USE_ASSERTIONS */\n\nDUK_EXTERNAL duk_idx_t duk_push_heapptr(duk_context *ctx, void *ptr) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_idx_t ret;\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t/* Reviving an object using a heap pointer is a dangerous API\n\t * operation: if the application doesn't guarantee that the\n\t * pointer target is always reachable, difficult-to-diagnose\n\t * problems may ensue.  Try to validate the 'ptr' argument to\n\t * the extent possible.\n\t */\n\n#if defined(DUK_USE_ASSERTIONS)\n\tduk__validate_push_heapptr(ctx, ptr);\n#endif\n\n\tDUK__CHECK_SPACE();\n\n\tret = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom);\n\ttv = thr->valstack_top++;\n\n\tif (ptr == NULL) {\n\t\tDUK_ASSERT(DUK_TVAL_IS_UNDEFINED(tv));\n\t\treturn ret;\n\t}\n\n\tDUK_ASSERT_HEAPHDR_VALID((duk_heaphdr *) ptr);\n\n\t/* If the argument is on finalize_list it has technically been\n\t * unreachable before duk_push_heapptr() but it's still safe to\n\t * push it.  Starting from Duktape 2.1 allow application code to\n\t * do so.  There are two main cases:\n\t *\n\t *   (1) The object is on the finalize_list and we're called by\n\t *       the finalizer for the object being finalized.  In this\n\t *       case do nothing: finalize_list handling will deal with\n\t *       the object queueing.  This is detected by the object not\n\t *       having a FINALIZABLE flag despite being on the finalize_list;\n\t *       the flag is cleared for the object being finalized only.\n\t *\n\t *   (2) The object is on the finalize_list but is not currently\n\t *       being processed.  In this case the object can be queued\n\t *       back to heap_allocated with a few flags cleared, in effect\n\t *       cancelling the finalizer.\n\t */\n\tif (DUK_UNLIKELY(DUK_HEAPHDR_HAS_FINALIZABLE((duk_heaphdr *) ptr))) {\n\t\tduk_heaphdr *curr;\n\n\t\tDUK_D(DUK_DPRINT(\"duk_push_heapptr() with a pointer on finalize_list, autorescue\"));\n\n\t\tcurr = (duk_heaphdr *) ptr;\n\t\tDUK_HEAPHDR_CLEAR_FINALIZABLE(curr);\n\n\t\t/* Because FINALIZED is set prior to finalizer call, it will\n\t\t * be set for the object being currently finalized, but not\n\t\t * for other objects on finalize_list.\n\t\t */\n\t\tDUK_HEAPHDR_CLEAR_FINALIZED(curr);\n\n\t\t/* Dequeue object from finalize_list and queue it back to\n\t\t * heap_allocated.\n\t\t */\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\t\tDUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT(curr) >= 1);  /* Preincremented on finalize_list insert. */\n\t\tDUK_HEAPHDR_PREDEC_REFCOUNT(curr);\n#endif\n\t\tDUK_HEAP_REMOVE_FROM_FINALIZE_LIST(thr->heap, curr);\n\t\tDUK_HEAP_INSERT_INTO_HEAP_ALLOCATED(thr->heap, curr);\n\n\t\t/* Continue with the rest. */\n\t}\n\n\tswitch (DUK_HEAPHDR_GET_TYPE((duk_heaphdr *) ptr)) {\n\tcase DUK_HTYPE_STRING:\n\t\tDUK_TVAL_SET_STRING(tv, (duk_hstring *) ptr);\n\t\tbreak;\n\tcase DUK_HTYPE_OBJECT:\n\t\tDUK_TVAL_SET_OBJECT(tv, (duk_hobject *) ptr);\n\t\tbreak;\n\tdefault:\n\t\tDUK_ASSERT(DUK_HEAPHDR_GET_TYPE((duk_heaphdr *) ptr) == DUK_HTYPE_BUFFER);\n\t\tDUK_TVAL_SET_BUFFER(tv, (duk_hbuffer *) ptr);\n\t\tbreak;\n\t}\n\n\tDUK_HEAPHDR_INCREF(thr, (duk_heaphdr *) ptr);\n\n\treturn ret;\n}\n\n/* Push object with no prototype, i.e. a \"bare\" object. */\nDUK_EXTERNAL duk_idx_t duk_push_bare_object(duk_context *ctx) {\n\t(void) duk_push_object_helper(ctx,\n\t                              DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                              DUK_HOBJECT_FLAG_FASTREFS |\n\t                              DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_OBJECT),\n\t                              -1);  /* no prototype */\n\treturn duk_get_top_index_unsafe(ctx);\n}\n\nDUK_INTERNAL void duk_push_hstring(duk_context *ctx, duk_hstring *h) {\n\tduk_tval tv;\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(h != NULL);\n\tDUK_TVAL_SET_STRING(&tv, h);\n\tduk_push_tval(ctx, &tv);\n}\n\nDUK_INTERNAL void duk_push_hstring_stridx(duk_context *ctx, duk_small_uint_t stridx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tDUK_UNREF(thr);\n\tDUK_ASSERT_STRIDX_VALID(stridx);\n\tduk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, stridx));\n}\n\nDUK_INTERNAL void duk_push_hstring_empty(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tDUK_UNREF(thr);\n\tduk_push_hstring(ctx, DUK_HTHREAD_GET_STRING(thr, DUK_STRIDX_EMPTY_STRING));\n}\n\nDUK_INTERNAL void duk_push_hobject(duk_context *ctx, duk_hobject *h) {\n\tduk_tval tv;\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(h != NULL);\n\tDUK_TVAL_SET_OBJECT(&tv, h);\n\tduk_push_tval(ctx, &tv);\n}\n\nDUK_INTERNAL void duk_push_hbuffer(duk_context *ctx, duk_hbuffer *h) {\n\tduk_tval tv;\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(h != NULL);\n\tDUK_TVAL_SET_BUFFER(&tv, h);\n\tduk_push_tval(ctx, &tv);\n}\n\nDUK_INTERNAL void duk_push_hobject_bidx(duk_context *ctx, duk_small_int_t builtin_idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(builtin_idx >= 0 && builtin_idx < DUK_NUM_BUILTINS);\n\tDUK_ASSERT(thr->builtins[builtin_idx] != NULL);\n\tduk_push_hobject(ctx, thr->builtins[builtin_idx]);\n}\n\n/*\n *  Poppers\n */\n\nDUK_EXTERNAL void duk_pop_n(duk_context *ctx, duk_idx_t count) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tduk_tval *tv_end;\n#endif\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n\n\tif (DUK_UNLIKELY(count < 0)) {\n\t\tDUK_ERROR_RANGE_INVALID_COUNT(thr);\n\t\treturn;\n\t}\n\n\tif (DUK_UNLIKELY((duk_size_t) (thr->valstack_top - thr->valstack_bottom) < (duk_size_t) count)) {\n\t\tDUK_ERROR_RANGE_INVALID_COUNT(thr);\n\t}\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\ttv = thr->valstack_top;\n\ttv_end = tv - count;\n\twhile (tv != tv_end) {\n\t\ttv--;\n\t\tDUK_ASSERT(tv >= thr->valstack_bottom);\n\t\tDUK_TVAL_SET_UNDEFINED_UPDREF_NORZ(thr, tv);\n\t}\n\tthr->valstack_top = tv;\n\tDUK_REFZERO_CHECK_FAST(thr);\n#else\n\ttv = thr->valstack_top;\n\twhile (count > 0) {\n\t\tcount--;\n\t\ttv--;\n\t\tDUK_ASSERT(tv >= thr->valstack_bottom);\n\t\tDUK_TVAL_SET_UNDEFINED(tv);\n\t}\n\tthr->valstack_top = tv;\n#endif\n\n\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n}\n\nDUK_INTERNAL void duk_pop_n_unsafe(duk_context *ctx, duk_idx_t count) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tduk_tval *tv_end;\n#endif\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(count >= 0);\n\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n\tDUK_ASSERT((duk_size_t) (thr->valstack_top - thr->valstack_bottom) >= (duk_size_t) count);\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\ttv = thr->valstack_top;\n\ttv_end = tv - count;\n\twhile (tv != tv_end) {\n\t\ttv--;\n\t\tDUK_ASSERT(tv >= thr->valstack_bottom);\n\t\tDUK_TVAL_SET_UNDEFINED_UPDREF_NORZ(thr, tv);\n\t}\n\tthr->valstack_top = tv;\n\tDUK_REFZERO_CHECK_FAST(thr);\n#else\n\ttv = thr->valstack_top;\n\twhile (count > 0) {\n\t\tcount--;\n\t\ttv--;\n\t\tDUK_ASSERT(tv >= thr->valstack_bottom);\n\t\tDUK_TVAL_SET_UNDEFINED(tv);\n\t}\n\tthr->valstack_top = tv;\n#endif\n\n\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n}\n\n/* Pop N elements without DECREF (in effect \"stealing\" the refcounts). */\n#if defined(DUK_USE_REFERENCE_COUNTING)\nDUK_INTERNAL void duk_pop_n_nodecref_unsafe(duk_context *ctx, duk_idx_t count) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(count >= 0);\n\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n\tDUK_ASSERT((duk_size_t) (thr->valstack_top - thr->valstack_bottom) >= (duk_size_t) count);\n\n\ttv = thr->valstack_top;\n\twhile (count > 0) {\n\t\tcount--;\n\t\ttv--;\n\t\tDUK_ASSERT(tv >= thr->valstack_bottom);\n\t\tDUK_TVAL_SET_UNDEFINED(tv);\n\t}\n\tthr->valstack_top = tv;\n\n\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n}\n#else  /* DUK_USE_REFERENCE_COUNTING */\nDUK_INTERNAL void duk_pop_n_nodecref_unsafe(duk_context *ctx, duk_idx_t count) {\n\tduk_pop_n_unsafe(ctx, count);\n}\n#endif  /* DUK_USE_REFERENCE_COUNTING */\n\n/* Popping one element is called so often that when footprint is not an issue,\n * compile a specialized function for it.\n */\n#if defined(DUK_USE_PREFER_SIZE)\nDUK_EXTERNAL void duk_pop(duk_context *ctx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tduk_pop_n(ctx, 1);\n}\n#else\nDUK_EXTERNAL void duk_pop(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n\tif (DUK_UNLIKELY(thr->valstack_top == thr->valstack_bottom)) {\n\t\tDUK_ERROR_RANGE_INVALID_COUNT(thr);\n\t}\n\n\ttv = --thr->valstack_top;  /* tv points to element just below prev top */\n\tDUK_ASSERT(tv >= thr->valstack_bottom);\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tDUK_TVAL_SET_UNDEFINED_UPDREF(thr, tv);  /* side effects */\n#else\n\tDUK_TVAL_SET_UNDEFINED(tv);\n#endif\n\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n}\n#endif  /* !DUK_USE_PREFER_SIZE */\n\n/* Unsafe internal variant which assumes there are enough values on the value\n * stack so that a top check can be skipped safely.\n */\n#if defined(DUK_USE_PREFER_SIZE)\nDUK_INTERNAL void duk_pop_unsafe(duk_context *ctx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tduk_pop_n_unsafe(ctx, 1);\n}\n#else\nDUK_INTERNAL void duk_pop_unsafe(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr->valstack_top != thr->valstack_bottom);\n\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n\tDUK_ASSERT((duk_size_t) (thr->valstack_top - thr->valstack_bottom) >= (duk_size_t) 1);\n\n\ttv = --thr->valstack_top;  /* tv points to element just below prev top */\n\tDUK_ASSERT(tv >= thr->valstack_bottom);\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tDUK_TVAL_SET_UNDEFINED_UPDREF(thr, tv);  /* side effects */\n#else\n\tDUK_TVAL_SET_UNDEFINED(tv);\n#endif\n\n\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n}\n#endif  /* !DUK_USE_PREFER_SIZE */\n\nDUK_EXTERNAL void duk_pop_2(duk_context *ctx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tduk_pop_n(ctx, 2);\n}\n\nDUK_EXTERNAL void duk_pop_3(duk_context *ctx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tduk_pop_n(ctx, 3);\n}\n\n/*\n *  Pack and unpack (pack value stack entries into an array and vice versa)\n */\n\n/* XXX: pack index range? array index offset? */\nDUK_INTERNAL void duk_pack(duk_context *ctx, duk_idx_t count) {\n\tduk_hthread *thr;\n\tduk_harray *a;\n\tduk_tval *tv_src;\n\tduk_tval *tv_dst;\n\tduk_tval *tv_curr;\n\tduk_tval *tv_limit;\n\tduk_idx_t top;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\n\ttop = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom);\n\tif (DUK_UNLIKELY(count < 0 || count > top)) {\n\t\tDUK_ERROR_RANGE_INVALID_COUNT(thr);\n\t\treturn;\n\t}\n\n\t/* Wrapping is controlled by the check above: value stack top can be\n\t * at most thr->valstack_max which is low enough so that multiplying\n\t * with sizeof(duk_tval) won't wrap.\n\t */\n\tDUK_ASSERT(count >= 0 && count <= (duk_idx_t) thr->valstack_max);\n\tDUK_ASSERT((duk_size_t) count <= DUK_SIZE_MAX / sizeof(duk_tval));  /* no wrapping */\n\n\ta = duk_push_harray_with_size(ctx, (duk_uint32_t) count);  /* XXX: uninitialized would be OK */\n\tDUK_ASSERT(a != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_GET_ASIZE((duk_hobject *) a) == (duk_uint32_t) count);\n\tDUK_ASSERT(count == 0 || DUK_HOBJECT_A_GET_BASE(thr->heap, (duk_hobject *) a) != NULL);\n\tDUK_ASSERT((duk_idx_t) a->length == count);\n\n\t/* Copy value stack values directly to the array part without\n\t * any refcount updates: net refcount changes are zero.\n\t */\n\n\ttv_src = thr->valstack_top - count - 1;\n\ttv_dst = DUK_HOBJECT_A_GET_BASE(thr->heap, (duk_hobject *) a);\n\tDUK_MEMCPY((void *) tv_dst, (const void *) tv_src, (size_t) count * sizeof(duk_tval));\n\n\t/* Overwrite result array to final value stack location and wipe\n\t * the rest; no refcount operations needed.\n\t */\n\n\ttv_dst = tv_src;  /* when count == 0, same as tv_src (OK) */\n\ttv_src = thr->valstack_top - 1;\n\tDUK_TVAL_SET_TVAL(tv_dst, tv_src);\n\n\t/* XXX: internal helper to wipe a value stack segment? */\n\ttv_curr = tv_dst + 1;\n\ttv_limit = thr->valstack_top;\n\twhile (tv_curr != tv_limit) {\n\t\t/* Wipe policy: keep as 'undefined'. */\n\t\tDUK_TVAL_SET_UNDEFINED(tv_curr);\n\t\ttv_curr++;\n\t}\n\tthr->valstack_top = tv_dst + 1;\n}\n\n#if 0\n/* XXX: unpack to position? */\nDUK_INTERNAL void duk_unpack(duk_context *ctx) {\n\t/* - dense with length <= a_part\n\t * - dense with length > a_part\n\t * - sparse\n\t * - array-like but not actually an array?\n\t * - how to deal with 'unused' values (gaps); inherit or ignore?\n\t */\n}\n#endif\n\n/*\n *  Error throwing\n */\n\nDUK_EXTERNAL void duk_throw_raw(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv_val;\n\n\tDUK_ASSERT(thr->valstack_bottom >= thr->valstack);\n\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n\tDUK_ASSERT(thr->valstack_end >= thr->valstack_top);\n\n\tif (DUK_UNLIKELY(thr->valstack_top == thr->valstack_bottom)) {\n\t\tDUK_ERROR_TYPE_INVALID_ARGS(thr);\n\t}\n\n\t/* Errors are augmented when they are created, not when they are\n\t * thrown or re-thrown.  The current error handler, however, runs\n\t * just before an error is thrown.\n\t */\n\n\t/* Sync so that augmentation sees up-to-date activations, NULL\n\t * thr->ptr_curr_pc so that it's not used if side effects occur\n\t * in augmentation or longjmp handling.\n\t */\n\tduk_hthread_sync_and_null_currpc(thr);\n\n#if defined(DUK_USE_AUGMENT_ERROR_THROW)\n\tDUK_DDD(DUK_DDDPRINT(\"THROW ERROR (API): %!dT (before throw augment)\", (duk_tval *) duk_get_tval(ctx, -1)));\n\tduk_err_augment_error_throw(thr);\n#endif\n\tDUK_DDD(DUK_DDDPRINT(\"THROW ERROR (API): %!dT (after throw augment)\", (duk_tval *) duk_get_tval(ctx, -1)));\n\n\ttv_val = DUK_GET_TVAL_NEGIDX(ctx, -1);\n\tduk_err_setup_ljstate1(thr, DUK_LJ_TYPE_THROW, tv_val);\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\tduk_err_check_debugger_integration(thr);\n#endif\n\n\t/* thr->heap->lj.jmpbuf_ptr is checked by duk_err_longjmp() so we don't\n\t * need to check that here.  If the value is NULL, a fatal error occurs\n\t * because we can't return.\n\t */\n\n\tduk_err_longjmp(thr);\n\tDUK_UNREACHABLE();\n}\n\nDUK_EXTERNAL void duk_fatal_raw(duk_context *ctx, const char *err_msg) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\tDUK_ASSERT(thr->heap->fatal_func != NULL);\n\n\tDUK_D(DUK_DPRINT(\"fatal error occurred: %s\", err_msg ? err_msg : \"NULL\"));\n\n\t/* fatal_func should be noreturn, but noreturn declarations on function\n\t * pointers has a very spotty support apparently so it's not currently\n\t * done.\n\t */\n\tthr->heap->fatal_func(thr->heap->heap_udata, err_msg);\n\n\t/* If the fatal handler returns, all bets are off.  It'd be nice to\n\t * print something here but since we don't want to depend on stdio,\n\t * there's no way to do so portably.\n\t */\n\tDUK_D(DUK_DPRINT(\"fatal error handler returned, all bets are off!\"));\n\tfor (;;) {\n\t\t/* loop forever, don't return (function marked noreturn) */\n\t}\n}\n\nDUK_EXTERNAL void duk_error_va_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, va_list ap) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tduk_push_error_object_va_raw(ctx, err_code, filename, line, fmt, ap);\n\t(void) duk_throw(ctx);\n}\n\nDUK_EXTERNAL void duk_error_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, ...) {\n\tva_list ap;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tva_start(ap, fmt);\n\tduk_push_error_object_va_raw(ctx, err_code, filename, line, fmt, ap);\n\tva_end(ap);\n\t(void) duk_throw(ctx);\n}\n\n#if !defined(DUK_USE_VARIADIC_MACROS)\nDUK_NORETURN(DUK_LOCAL_DECL void duk__throw_error_from_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt, va_list ap));\n\nDUK_LOCAL void duk__throw_error_from_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt, va_list ap) {\n\tconst char *filename;\n\tduk_int_t line;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tfilename = duk_api_global_filename;\n\tline = duk_api_global_line;\n\tduk_api_global_filename = NULL;\n\tduk_api_global_line = 0;\n\n\tduk_push_error_object_va_raw(ctx, err_code, filename, line, fmt, ap);\n\t(void) duk_throw(ctx);\n}\n\n#define DUK__ERROR_STASH_SHARED(code) do { \\\n\t\tva_list ap; \\\n\t\tva_start(ap, fmt); \\\n\t\tduk__throw_error_from_stash(ctx, (code), fmt, ap); \\\n\t\tva_end(ap); \\\n\t\t/* Never reached; if return 0 here, gcc/clang will complain. */ \\\n\t} while (0)\n\nDUK_EXTERNAL duk_ret_t duk_error_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt, ...) {\n\tDUK__ERROR_STASH_SHARED(err_code);\n}\nDUK_EXTERNAL duk_ret_t duk_generic_error_stash(duk_context *ctx, const char *fmt, ...) {\n\tDUK__ERROR_STASH_SHARED(DUK_ERR_ERROR);\n}\nDUK_EXTERNAL duk_ret_t duk_eval_error_stash(duk_context *ctx, const char *fmt, ...) {\n\tDUK__ERROR_STASH_SHARED(DUK_ERR_EVAL_ERROR);\n}\nDUK_EXTERNAL duk_ret_t duk_range_error_stash(duk_context *ctx, const char *fmt, ...) {\n\tDUK__ERROR_STASH_SHARED(DUK_ERR_RANGE_ERROR);\n}\nDUK_EXTERNAL duk_ret_t duk_reference_error_stash(duk_context *ctx, const char *fmt, ...) {\n\tDUK__ERROR_STASH_SHARED(DUK_ERR_REFERENCE_ERROR);\n}\nDUK_EXTERNAL duk_ret_t duk_syntax_error_stash(duk_context *ctx, const char *fmt, ...) {\n\tDUK__ERROR_STASH_SHARED(DUK_ERR_SYNTAX_ERROR);\n}\nDUK_EXTERNAL duk_ret_t duk_type_error_stash(duk_context *ctx, const char *fmt, ...) {\n\tDUK__ERROR_STASH_SHARED(DUK_ERR_TYPE_ERROR);\n}\nDUK_EXTERNAL duk_ret_t duk_uri_error_stash(duk_context *ctx, const char *fmt, ...) {\n\tDUK__ERROR_STASH_SHARED(DUK_ERR_URI_ERROR);\n}\n#endif  /* DUK_USE_VARIADIC_MACROS */\n\n/*\n *  Comparison\n */\n\nDUK_EXTERNAL duk_bool_t duk_equals(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv1, *tv2;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv1 = duk_get_tval(ctx, idx1);\n\ttv2 = duk_get_tval(ctx, idx2);\n\tif ((tv1 == NULL) || (tv2 == NULL)) {\n\t\treturn 0;\n\t}\n\n\t/* Coercion may be needed, the helper handles that by pushing the\n\t * tagged values to the stack.\n\t */\n\treturn duk_js_equals(thr, tv1, tv2);\n}\n\nDUK_EXTERNAL duk_bool_t duk_strict_equals(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2) {\n\tduk_tval *tv1, *tv2;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv1 = duk_get_tval(ctx, idx1);\n\ttv2 = duk_get_tval(ctx, idx2);\n\tif ((tv1 == NULL) || (tv2 == NULL)) {\n\t\treturn 0;\n\t}\n\n\t/* No coercions or other side effects, so safe */\n\treturn duk_js_strict_equals(tv1, tv2);\n}\n\nDUK_EXTERNAL duk_bool_t duk_samevalue(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2) {\n\tduk_tval *tv1, *tv2;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\ttv1 = duk_get_tval(ctx, idx1);\n\ttv2 = duk_get_tval(ctx, idx2);\n\tif ((tv1 == NULL) || (tv2 == NULL)) {\n\t\treturn 0;\n\t}\n\n\t/* No coercions or other side effects, so safe */\n\treturn duk_js_samevalue(tv1, tv2);\n}\n\n/*\n *  instanceof\n */\n\nDUK_EXTERNAL duk_bool_t duk_instanceof(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2) {\n\tduk_tval *tv1, *tv2;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t/* Index validation is strict, which differs from duk_equals().\n\t * The strict behavior mimics how instanceof itself works, e.g.\n\t * it is a TypeError if rval is not a -callable- object.  It would\n\t * be somewhat inconsistent if rval would be allowed to be\n\t * non-existent without a TypeError.\n\t */\n\ttv1 = duk_require_tval(ctx, idx1);\n\tDUK_ASSERT(tv1 != NULL);\n\ttv2 = duk_require_tval(ctx, idx2);\n\tDUK_ASSERT(tv2 != NULL);\n\n\treturn duk_js_instanceof((duk_hthread *) ctx, tv1, tv2);\n}\n\n/*\n *  Lightfunc\n */\n\nDUK_INTERNAL void duk_push_lightfunc_name_raw(duk_context *ctx, duk_c_function func, duk_small_uint_t lf_flags) {\n\t/* Lightfunc name, includes Duktape/C native function pointer, which\n\t * can often be used to locate the function from a symbol table.\n\t * The name also includes the 16-bit duk_tval flags field because it\n\t * includes the magic value.  Because a single native function often\n\t * provides different functionality depending on the magic value, it\n\t * seems reasonably to include it in the name.\n\t *\n\t * On the other hand, a complicated name increases string table\n\t * pressure in low memory environments (but only when function name\n\t * is accessed).\n\t */\n\n\tduk_push_sprintf(ctx, \"light_\");\n\tduk_push_string_funcptr(ctx, (duk_uint8_t *) &func, sizeof(func));\n\tduk_push_sprintf(ctx, \"_%04x\", (unsigned int) lf_flags);\n\tduk_concat(ctx, 3);\n}\n\nDUK_INTERNAL void duk_push_lightfunc_name(duk_context *ctx, duk_tval *tv) {\n\tduk_c_function func;\n\tduk_small_uint_t lf_flags;\n\n\tDUK_ASSERT(DUK_TVAL_IS_LIGHTFUNC(tv));\n\tDUK_TVAL_GET_LIGHTFUNC(tv, func, lf_flags);\n\tduk_push_lightfunc_name_raw(ctx, func, lf_flags);\n}\n\nDUK_INTERNAL void duk_push_lightfunc_tostring(duk_context *ctx, duk_tval *tv) {\n\tduk_c_function func;\n\tduk_small_uint_t lf_flags;\n\n\tDUK_ASSERT(DUK_TVAL_IS_LIGHTFUNC(tv));\n\tDUK_TVAL_GET_LIGHTFUNC(tv, func, lf_flags);  /* read before 'tv' potentially invalidated */\n\n\tduk_push_string(ctx, \"function \");\n\tduk_push_lightfunc_name_raw(ctx, func, lf_flags);\n\tduk_push_string(ctx, \"() { [lightfunc code] }\");\n\tduk_concat(ctx, 3);\n}\n\n/*\n *  Function pointers\n *\n *  Printing function pointers is non-portable, so we do that by hex printing\n *  bytes from memory.\n */\n\nDUK_INTERNAL void duk_push_string_funcptr(duk_context *ctx, duk_uint8_t *ptr, duk_size_t sz) {\n\tduk_uint8_t buf[32 * 2];\n\tduk_uint8_t *p, *q;\n\tduk_small_uint_t i;\n\tduk_small_uint_t t;\n\n\tDUK_ASSERT(sz <= 32);  /* sanity limit for function pointer size */\n\n\tp = buf;\n#if defined(DUK_USE_INTEGER_LE)\n\tq = ptr + sz;\n#else\n\tq = ptr;\n#endif\n\tfor (i = 0; i < sz; i++) {\n#if defined(DUK_USE_INTEGER_LE)\n\t\tt = *(--q);\n#else\n\t\tt = *(q++);\n#endif\n\t\t*p++ = duk_lc_digits[t >> 4];\n\t\t*p++ = duk_lc_digits[t & 0x0f];\n\t}\n\n\tduk_push_lstring(ctx, (const char *) buf, sz * 2);\n}\n\n/*\n *  Push readable string summarizing duk_tval.  The operation is side effect\n *  free and will only throw from internal errors (e.g. out of memory).\n *  This is used by e.g. property access code to summarize a key/base safely,\n *  and is not intended to be fast (but small and safe).\n */\n\n#define DUK__READABLE_STRING_MAXCHARS 32\n\n/* String sanitizer which escapes ASCII control characters and a few other\n * ASCII characters, passes Unicode as is, and replaces invalid UTF-8 with\n * question marks.  No errors are thrown for any input string, except in out\n * of memory situations.\n */\nDUK_LOCAL void duk__push_hstring_readable_unicode(duk_context *ctx, duk_hstring *h_input) {\n\tduk_hthread *thr;\n\tconst duk_uint8_t *p, *p_start, *p_end;\n\tduk_uint8_t buf[DUK_UNICODE_MAX_XUTF8_LENGTH * DUK__READABLE_STRING_MAXCHARS +\n\t                2 /*quotes*/ + 3 /*periods*/];\n\tduk_uint8_t *q;\n\tduk_ucodepoint_t cp;\n\tduk_small_uint_t nchars;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(h_input != NULL);\n\tthr = (duk_hthread *) ctx;\n\n\tp_start = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_input);\n\tp_end = p_start + DUK_HSTRING_GET_BYTELEN(h_input);\n\tp = p_start;\n\tq = buf;\n\n\tnchars = 0;\n\t*q++ = (duk_uint8_t) DUK_ASC_SINGLEQUOTE;\n\tfor (;;) {\n\t\tif (p >= p_end) {\n\t\t\tbreak;\n\t\t}\n\t\tif (nchars == DUK__READABLE_STRING_MAXCHARS) {\n\t\t\t*q++ = (duk_uint8_t) DUK_ASC_PERIOD;\n\t\t\t*q++ = (duk_uint8_t) DUK_ASC_PERIOD;\n\t\t\t*q++ = (duk_uint8_t) DUK_ASC_PERIOD;\n\t\t\tbreak;\n\t\t}\n\t\tif (duk_unicode_decode_xutf8(thr, &p, p_start, p_end, &cp)) {\n\t\t\tif (cp < 0x20 || cp == 0x7f || cp == DUK_ASC_SINGLEQUOTE || cp == DUK_ASC_BACKSLASH) {\n\t\t\t\tDUK_ASSERT(DUK_UNICODE_MAX_XUTF8_LENGTH >= 4);  /* estimate is valid */\n\t\t\t\tDUK_ASSERT((cp >> 4) <= 0x0f);\n\t\t\t\t*q++ = (duk_uint8_t) DUK_ASC_BACKSLASH;\n\t\t\t\t*q++ = (duk_uint8_t) DUK_ASC_LC_X;\n\t\t\t\t*q++ = (duk_uint8_t) duk_lc_digits[cp >> 4];\n\t\t\t\t*q++ = (duk_uint8_t) duk_lc_digits[cp & 0x0f];\n\t\t\t} else {\n\t\t\t\tq += duk_unicode_encode_xutf8(cp, q);\n\t\t\t}\n\t\t} else {\n\t\t\tp++;  /* advance manually */\n\t\t\t*q++ = (duk_uint8_t) DUK_ASC_QUESTION;\n\t\t}\n\t\tnchars++;\n\t}\n\t*q++ = (duk_uint8_t) DUK_ASC_SINGLEQUOTE;\n\n\tduk_push_lstring(ctx, (const char *) buf, (duk_size_t) (q - buf));\n}\n\nDUK_LOCAL const char *duk__push_string_tval_readable(duk_context *ctx, duk_tval *tv, duk_bool_t error_aware) {\n\tduk_hthread *thr;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\tDUK_UNREF(thr);\n\t/* 'tv' may be NULL */\n\n\tif (tv == NULL) {\n\t\tduk_push_string(ctx, \"none\");\n\t} else {\n\t\tswitch (DUK_TVAL_GET_TAG(tv)) {\n\t\tcase DUK_TAG_STRING: {\n\t\t\t/* XXX: symbol support (maybe in summary rework branch) */\n\t\t\tduk__push_hstring_readable_unicode(ctx, DUK_TVAL_GET_STRING(tv));\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_TAG_OBJECT: {\n\t\t\tduk_hobject *h = DUK_TVAL_GET_OBJECT(tv);\n\t\t\tDUK_ASSERT(h != NULL);\n\n\t\t\tif (error_aware &&\n\t\t\t    duk_hobject_prototype_chain_contains(thr, h, thr->builtins[DUK_BIDX_ERROR_PROTOTYPE], 1 /*ignore_loop*/)) {\n\t\t\t\t/* Get error message in a side effect free way if\n\t\t\t\t * possible; if not, summarize as a generic object.\n\t\t\t\t * Error message currently gets quoted.\n\t\t\t\t */\n\t\t\t\t/* XXX: better internal getprop call; get without side effects\n\t\t\t\t * but traverse inheritance chain.\n\t\t\t\t */\n\t\t\t\tduk_tval *tv_msg;\n\t\t\t\ttv_msg = duk_hobject_find_existing_entry_tval_ptr(thr->heap, h, DUK_HTHREAD_STRING_MESSAGE(thr));\n\t\t\t\tif (tv_msg) {\n\t\t\t\t\t/* It's important this summarization is\n\t\t\t\t\t * not error aware to avoid unlimited\n\t\t\t\t\t * recursion when the .message property\n\t\t\t\t\t * is e.g. another error.\n\t\t\t\t\t */\n\t\t\t\t\treturn duk_push_string_tval_readable(ctx, tv_msg);\n\t\t\t\t}\n\t\t\t}\n\t\t\tduk_push_class_string_tval(ctx, tv);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_TAG_BUFFER: {\n\t\t\t/* While plain buffers mimic Uint8Arrays, they summarize differently.\n\t\t\t * This is useful so that the summarized string accurately reflects the\n\t\t\t * internal type which may matter for figuring out bugs etc.\n\t\t\t */\n\t\t\t/* XXX: Hex encoded, length limited buffer summary here? */\n\t\t\tduk_hbuffer *h = DUK_TVAL_GET_BUFFER(tv);\n\t\t\tDUK_ASSERT(h != NULL);\n\t\t\tduk_push_sprintf(ctx, \"[buffer:%ld]\", (long) DUK_HBUFFER_GET_SIZE(h));\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_TAG_POINTER: {\n\t\t\t/* Surround with parentheses like in JX, ensures NULL pointer\n\t\t\t * is distinguishable from null value (\"(null)\" vs \"null\").\n\t\t\t */\n\t\t\tduk_push_tval(ctx, tv);\n\t\t\tduk_push_sprintf(ctx, \"(%s)\", duk_to_string(ctx, -1));\n\t\t\tduk_remove_m2(ctx);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tduk_push_tval(ctx, tv);\n\t\t\tbreak;\n\t\t}\n\t\t}\n\t}\n\n\treturn duk_to_string(ctx, -1);\n}\nDUK_INTERNAL const char *duk_push_string_tval_readable(duk_context *ctx, duk_tval *tv) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\treturn duk__push_string_tval_readable(ctx, tv, 0 /*error_aware*/);\n}\n\nDUK_INTERNAL const char *duk_push_string_readable(duk_context *ctx, duk_idx_t idx) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\treturn duk_push_string_tval_readable(ctx, duk_get_tval(ctx, idx));\n}\n\nDUK_INTERNAL const char *duk_push_string_tval_readable_error(duk_context *ctx, duk_tval *tv) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\treturn duk__push_string_tval_readable(ctx, tv, 1 /*error_aware*/);\n}\n\nDUK_INTERNAL void duk_push_symbol_descriptive_string(duk_context *ctx, duk_hstring *h) {\n\tconst duk_uint8_t *p;\n\tconst duk_uint8_t *p_end;\n\tconst duk_uint8_t *q;\n\n\t/* .toString() */\n\tduk_push_string(ctx, \"Symbol(\");\n\tp = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h);\n\tp_end = p + DUK_HSTRING_GET_BYTELEN(h);\n\tDUK_ASSERT(p[0] == 0xff || (p[0] & 0xc0) == 0x80);\n\tp++;\n\tfor (q = p; q < p_end; q++) {\n\t\tif (*q == 0xffU) {\n\t\t\t/* Terminate either at end-of-string (but NUL MUST\n\t\t\t * be accepted without terminating description) or\n\t\t\t * 0xFF, which is used to mark start of unique trailer\n\t\t\t * (and cannot occur in CESU-8 / extended UTF-8).\n\t\t\t */\n\t\t\tbreak;\n\t\t}\n\t}\n\tduk_push_lstring(ctx, (const char *) p, (duk_size_t) (q - p));\n\tduk_push_string(ctx, \")\");\n\tduk_concat(ctx, 3);\n}\n\n/* automatic undefs */\n#undef DUK__CHECK_SPACE\n#undef DUK__ERROR_STASH_SHARED\n#undef DUK__PACK_ARGS\n#undef DUK__READABLE_STRING_MAXCHARS\n/*\n *  String manipulation\n */\n\n/* #include duk_internal.h -> already included */\n\nDUK_LOCAL void duk__concat_and_join_helper(duk_context *ctx, duk_idx_t count_in, duk_bool_t is_join) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_uint_t count;\n\tduk_uint_t i;\n\tduk_size_t idx;\n\tduk_size_t len;\n\tduk_hstring *h;\n\tduk_uint8_t *buf;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tif (DUK_UNLIKELY(count_in <= 0)) {\n\t\tif (count_in < 0) {\n\t\t\tDUK_ERROR_RANGE_INVALID_COUNT(thr);\n\t\t\treturn;\n\t\t}\n\t\tDUK_ASSERT(count_in == 0);\n\t\tduk_push_hstring_empty(ctx);\n\t\treturn;\n\t}\n\tcount = (duk_uint_t) count_in;\n\n\tif (is_join) {\n\t\tduk_size_t t1, t2, limit;\n\t\th = duk_to_hstring(ctx, -((duk_idx_t) count) - 1);\n\t\tDUK_ASSERT(h != NULL);\n\n\t\t/* A bit tricky overflow test, see doc/code-issues.rst. */\n\t\tt1 = (duk_size_t) DUK_HSTRING_GET_BYTELEN(h);\n\t\tt2 = (duk_size_t) (count - 1);\n\t\tlimit = (duk_size_t) DUK_HSTRING_MAX_BYTELEN;\n\t\tif (DUK_UNLIKELY(t2 != 0 && t1 > limit / t2)) {\n\t\t\t/* Combined size of separators already overflows. */\n\t\t\tgoto error_overflow;\n\t\t}\n\t\tlen = (duk_size_t) (t1 * t2);\n\t} else {\n\t\tlen = (duk_size_t) 0;\n\t}\n\n\tfor (i = count; i >= 1; i--) {\n\t\tduk_size_t new_len;\n\t\th = duk_to_hstring(ctx, -((duk_idx_t) i));\n\t\tnew_len = len + (duk_size_t) DUK_HSTRING_GET_BYTELEN(h);\n\n\t\t/* Impose a string maximum length, need to handle overflow\n\t\t * correctly.\n\t\t */\n\t\tif (new_len < len ||  /* wrapped */\n\t\t    new_len > (duk_size_t) DUK_HSTRING_MAX_BYTELEN) {\n\t\t\tgoto error_overflow;\n\t\t}\n\t\tlen = new_len;\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"join/concat %lu strings, total length %lu bytes\",\n\t                     (unsigned long) count, (unsigned long) len));\n\n\t/* Use stack allocated buffer to ensure reachability in errors\n\t * (e.g. intern error).\n\t */\n\tbuf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(ctx, len);\n\tDUK_ASSERT(buf != NULL);\n\n\t/* [ ... (sep) str1 str2 ... strN buf ] */\n\n\tidx = 0;\n\tfor (i = count; i >= 1; i--) {\n\t\tif (is_join && i != count) {\n\t\t\th = duk_require_hstring(ctx, -((duk_idx_t) count) - 2);  /* extra -1 for buffer */\n\t\t\tDUK_MEMCPY(buf + idx, DUK_HSTRING_GET_DATA(h), DUK_HSTRING_GET_BYTELEN(h));\n\t\t\tidx += DUK_HSTRING_GET_BYTELEN(h);\n\t\t}\n\t\th = duk_require_hstring(ctx, -((duk_idx_t) i) - 1);  /* extra -1 for buffer */\n\t\tDUK_MEMCPY(buf + idx, DUK_HSTRING_GET_DATA(h), DUK_HSTRING_GET_BYTELEN(h));\n\t\tidx += DUK_HSTRING_GET_BYTELEN(h);\n\t}\n\n\tDUK_ASSERT(idx == len);\n\n\t/* [ ... (sep) str1 str2 ... strN buf ] */\n\n\t/* Get rid of the strings early to minimize memory use before intern. */\n\n\tif (is_join) {\n\t\tduk_replace(ctx, -((duk_idx_t) count) - 2);  /* overwrite sep */\n\t\tduk_pop_n(ctx, count);\n\t} else {\n\t\tduk_replace(ctx, -((duk_idx_t) count) - 1);  /* overwrite str1 */\n\t\tduk_pop_n(ctx, count-1);\n\t}\n\n\t/* [ ... buf ] */\n\n\t(void) duk_buffer_to_string(ctx, -1);  /* Safe if inputs are safe. */\n\n\t/* [ ... res ] */\n\treturn;\n\n error_overflow:\n\tDUK_ERROR_RANGE(thr, DUK_STR_RESULT_TOO_LONG);\n}\n\nDUK_EXTERNAL void duk_concat(duk_context *ctx, duk_idx_t count) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tduk__concat_and_join_helper(ctx, count, 0 /*is_join*/);\n}\n\nDUK_EXTERNAL void duk_join(duk_context *ctx, duk_idx_t count) {\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tduk__concat_and_join_helper(ctx, count, 1 /*is_join*/);\n}\n\n/* XXX: could map/decode be unified with duk_unicode_support.c code?\n * Case conversion needs also the character surroundings though.\n */\n\nDUK_EXTERNAL void duk_decode_string(duk_context *ctx, duk_idx_t idx, duk_decode_char_function callback, void *udata) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hstring *h_input;\n\tconst duk_uint8_t *p, *p_start, *p_end;\n\tduk_codepoint_t cp;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\th_input = duk_require_hstring(ctx, idx);  /* Accept symbols. */\n\tDUK_ASSERT(h_input != NULL);\n\n\tp_start = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_input);\n\tp_end = p_start + DUK_HSTRING_GET_BYTELEN(h_input);\n\tp = p_start;\n\n\tfor (;;) {\n\t\tif (p >= p_end) {\n\t\t\tbreak;\n\t\t}\n\t\tcp = (duk_codepoint_t) duk_unicode_decode_xutf8_checked(thr, &p, p_start, p_end);\n\t\tcallback(udata, cp);\n\t}\n}\n\nDUK_EXTERNAL void duk_map_string(duk_context *ctx, duk_idx_t idx, duk_map_char_function callback, void *udata) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hstring *h_input;\n\tduk_bufwriter_ctx bw_alloc;\n\tduk_bufwriter_ctx *bw;\n\tconst duk_uint8_t *p, *p_start, *p_end;\n\tduk_codepoint_t cp;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tidx = duk_normalize_index(ctx, idx);\n\n\th_input = duk_require_hstring(ctx, idx);  /* Accept symbols. */\n\tDUK_ASSERT(h_input != NULL);\n\n\tbw = &bw_alloc;\n\tDUK_BW_INIT_PUSHBUF(thr, bw, DUK_HSTRING_GET_BYTELEN(h_input));  /* Reasonable output estimate. */\n\n\tp_start = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_input);\n\tp_end = p_start + DUK_HSTRING_GET_BYTELEN(h_input);\n\tp = p_start;\n\n\tfor (;;) {\n\t\t/* XXX: could write output in chunks with fewer ensure calls,\n\t\t * but relative benefit would be small here.\n\t\t */\n\n\t\tif (p >= p_end) {\n\t\t\tbreak;\n\t\t}\n\t\tcp = (duk_codepoint_t) duk_unicode_decode_xutf8_checked(thr, &p, p_start, p_end);\n\t\tcp = callback(udata, cp);\n\n\t\tDUK_BW_WRITE_ENSURE_XUTF8(thr, bw, cp);\n\t}\n\n\tDUK_BW_COMPACT(thr, bw);\n\t(void) duk_buffer_to_string(ctx, -1);  /* Safe, extended UTF-8 encoded. */\n\tduk_replace(ctx, idx);\n}\n\nDUK_EXTERNAL void duk_substring(duk_context *ctx, duk_idx_t idx, duk_size_t start_offset, duk_size_t end_offset) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hstring *h;\n\tduk_hstring *res;\n\tduk_size_t start_byte_offset;\n\tduk_size_t end_byte_offset;\n\tduk_size_t charlen;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tidx = duk_require_normalize_index(ctx, idx);  /* Accept symbols. */\n\th = duk_require_hstring(ctx, idx);\n\tDUK_ASSERT(h != NULL);\n\n\tcharlen = DUK_HSTRING_GET_CHARLEN(h);\n\tif (end_offset >= charlen) {\n\t\tend_offset = charlen;\n\t}\n\tif (start_offset > end_offset) {\n\t\tstart_offset = end_offset;\n\t}\n\n\tDUK_ASSERT_DISABLE(start_offset >= 0);\n\tDUK_ASSERT(start_offset <= end_offset && start_offset <= DUK_HSTRING_GET_CHARLEN(h));\n\tDUK_ASSERT_DISABLE(end_offset >= 0);\n\tDUK_ASSERT(end_offset >= start_offset && end_offset <= DUK_HSTRING_GET_CHARLEN(h));\n\n\t/* Guaranteed by string limits. */\n\tDUK_ASSERT(start_offset <= DUK_UINT32_MAX);\n\tDUK_ASSERT(end_offset <= DUK_UINT32_MAX);\n\n\tstart_byte_offset = (duk_size_t) duk_heap_strcache_offset_char2byte(thr, h, (duk_uint_fast32_t) start_offset);\n\tend_byte_offset = (duk_size_t) duk_heap_strcache_offset_char2byte(thr, h, (duk_uint_fast32_t) end_offset);\n\n\tDUK_ASSERT(end_byte_offset >= start_byte_offset);\n\tDUK_ASSERT(end_byte_offset - start_byte_offset <= DUK_UINT32_MAX);  /* Guaranteed by string limits. */\n\n\t/* No size check is necessary. */\n\tres = duk_heap_strtable_intern_checked(thr,\n\t                                       DUK_HSTRING_GET_DATA(h) + start_byte_offset,\n\t                                       (duk_uint32_t) (end_byte_offset - start_byte_offset));\n\n\tduk_push_hstring(ctx, res);\n\tduk_replace(ctx, idx);\n}\n\n/* XXX: this is quite clunky.  Add Unicode helpers to scan backwards and\n * forwards with a callback to process codepoints?\n */\nDUK_EXTERNAL void duk_trim(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hstring *h;\n\tconst duk_uint8_t *p, *p_start, *p_end, *p_tmp1, *p_tmp2;  /* pointers for scanning */\n\tconst duk_uint8_t *q_start, *q_end;  /* start (incl) and end (excl) of trimmed part */\n\tduk_codepoint_t cp;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\tidx = duk_require_normalize_index(ctx, idx);  /* Accept symbols. */\n\th = duk_require_hstring(ctx, idx);\n\tDUK_ASSERT(h != NULL);\n\n\tp_start = DUK_HSTRING_GET_DATA(h);\n\tp_end = p_start + DUK_HSTRING_GET_BYTELEN(h);\n\n\tp = p_start;\n\twhile (p < p_end) {\n\t\tp_tmp1 = p;\n\t\tcp = (duk_codepoint_t) duk_unicode_decode_xutf8_checked(thr, &p_tmp1, p_start, p_end);\n\t\tif (!(duk_unicode_is_whitespace(cp) || duk_unicode_is_line_terminator(cp))) {\n\t\t\tbreak;\n\t\t}\n\t\tp = p_tmp1;\n\t}\n\tq_start = p;\n\tif (p == p_end) {\n\t\t/* Entire string is whitespace. */\n\t\tq_end = p;\n\t\tgoto scan_done;\n\t}\n\n\tp = p_end;\n\twhile (p > p_start) {\n\t\tp_tmp1 = p;\n\t\twhile (p > p_start) {\n\t\t\tp--;\n\t\t\tif (((*p) & 0xc0) != 0x80) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tp_tmp2 = p;\n\n\t\tcp = (duk_codepoint_t) duk_unicode_decode_xutf8_checked(thr, &p_tmp2, p_start, p_end);\n\t\tif (!(duk_unicode_is_whitespace(cp) || duk_unicode_is_line_terminator(cp))) {\n\t\t\tp = p_tmp1;\n\t\t\tbreak;\n\t\t}\n\t}\n\tq_end = p;\n\n scan_done:\n\t/* This may happen when forward and backward scanning disagree\n\t * (possible for non-extended-UTF-8 strings).\n\t */\n\tif (q_end < q_start) {\n\t\tq_end = q_start;\n\t}\n\n\tDUK_ASSERT(q_start >= p_start && q_start <= p_end);\n\tDUK_ASSERT(q_end >= p_start && q_end <= p_end);\n\tDUK_ASSERT(q_end >= q_start);\n\n\tDUK_DDD(DUK_DDDPRINT(\"trim: p_start=%p, p_end=%p, q_start=%p, q_end=%p\",\n\t                     (const void *) p_start, (const void *) p_end,\n\t                     (const void *) q_start, (const void *) q_end));\n\n\tif (q_start == p_start && q_end == p_end) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"nothing was trimmed: avoid interning (hashing etc)\"));\n\t\treturn;\n\t}\n\n\tduk_push_lstring(ctx, (const char *) q_start, (duk_size_t) (q_end - q_start));\n\tduk_replace(ctx, idx);\n}\n\nDUK_EXTERNAL duk_codepoint_t duk_char_code_at(duk_context *ctx, duk_idx_t idx, duk_size_t char_offset) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hstring *h;\n\tduk_ucodepoint_t cp;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t/* XXX: Share code with String.prototype.charCodeAt?  Main difference\n\t * is handling of clamped offsets.\n\t */\n\n\th = duk_require_hstring(ctx, idx);  /* Accept symbols. */\n\tDUK_ASSERT(h != NULL);\n\n\tDUK_ASSERT_DISABLE(char_offset >= 0);  /* Always true, arg is unsigned. */\n\tif (char_offset >= DUK_HSTRING_GET_CHARLEN(h)) {\n\t\treturn 0;\n\t}\n\n\tDUK_ASSERT(char_offset <= DUK_UINT_MAX);  /* Guaranteed by string limits. */\n\tcp = duk_hstring_char_code_at_raw(thr, h, (duk_uint_t) char_offset, 0 /*surrogate_aware*/);\n\treturn (duk_codepoint_t) cp;\n}\n/*\n *  Date/time.\n */\n\n/* #include duk_internal.h -> already included */\n\nDUK_EXTERNAL duk_double_t duk_get_now(duk_context *ctx) {\n\treturn ((duk_double_t) DUK_USE_DATE_GET_NOW((ctx)));\n}\n\nDUK_EXTERNAL void duk_time_to_components(duk_context *ctx, duk_double_t timeval, duk_time_components *comp) {\n\tduk_int_t parts[DUK_DATE_IDX_NUM_PARTS];\n\tduk_double_t dparts[DUK_DATE_IDX_NUM_PARTS];\n\tduk_uint_t flags;\n\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(comp != NULL);  /* XXX: or check? */\n\tDUK_UNREF(ctx);\n\n\t/* Convert as one-based, but change month to zero-based to match the\n\t * Ecmascript Date built-in behavior 1:1.\n\t */\n\tflags = DUK_DATE_FLAG_ONEBASED | DUK_DATE_FLAG_NAN_TO_ZERO;\n\n\tduk_bi_date_timeval_to_parts(timeval, parts, dparts, flags);\n\n\tDUK_ASSERT(dparts[DUK_DATE_IDX_MONTH] >= 1.0 && dparts[DUK_DATE_IDX_MONTH] <= 12.0);\n\tcomp->year = dparts[DUK_DATE_IDX_YEAR];\n\tcomp->month = dparts[DUK_DATE_IDX_MONTH] - 1.0;\n\tcomp->day = dparts[DUK_DATE_IDX_DAY];\n\tcomp->hours = dparts[DUK_DATE_IDX_HOUR];\n\tcomp->minutes = dparts[DUK_DATE_IDX_MINUTE];\n\tcomp->seconds = dparts[DUK_DATE_IDX_SECOND];\n\tcomp->milliseconds = dparts[DUK_DATE_IDX_MILLISECOND];\n\tcomp->weekday = dparts[DUK_DATE_IDX_WEEKDAY];\n}\n\nDUK_EXTERNAL duk_double_t duk_components_to_time(duk_context *ctx, duk_time_components *comp) {\n\tduk_double_t d;\n\tduk_double_t dparts[DUK_DATE_IDX_NUM_PARTS];\n\tduk_uint_t flags;\n\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(comp != NULL);  /* XXX: or check? */\n\tDUK_UNREF(ctx);\n\n\t/* Match Date constructor behavior (with UTC time).  Month is given\n\t * as zero-based.  Day-of-month is given as one-based so normalize\n\t * it to zero-based as the internal conversion helpers expects all\n\t * components to be zero-based.\n\t */\n\tflags = 0;\n\n\t/* XXX: expensive conversion; use array format in API instead, or unify\n\t * time provider and time API to use same struct?\n\t */\n\n\tdparts[DUK_DATE_IDX_YEAR] = comp->year;\n\tdparts[DUK_DATE_IDX_MONTH] = comp->month;\n\tdparts[DUK_DATE_IDX_DAY] = comp->day - 1.0;\n\tdparts[DUK_DATE_IDX_HOUR] = comp->hours;\n\tdparts[DUK_DATE_IDX_MINUTE] = comp->minutes;\n\tdparts[DUK_DATE_IDX_SECOND] = comp->seconds;\n\tdparts[DUK_DATE_IDX_MILLISECOND] = comp->milliseconds;\n\tdparts[DUK_DATE_IDX_WEEKDAY] = 0;  /* ignored */\n\n\td = duk_bi_date_get_timeval_from_dparts(dparts, flags);\n\n\treturn d;\n}\n/*\n *  Array built-ins\n *\n *  Most Array built-ins are intentionally generic in Ecmascript, and are\n *  intended to work even when the 'this' binding is not an Array instance.\n *  This Ecmascript feature is also used by much real world code.  For this\n *  reason the implementations here don't assume exotic Array behavior or\n *  e.g. presence of a .length property.  However, some algorithms have a\n *  fast path for duk_harray backed actual Array instances, enabled when\n *  footprint is not a concern.\n *\n *  XXX: the \"Throw\" flag should be set for (almost?) all [[Put]] and\n *  [[Delete]] operations, but it's currently false throughout.  Go through\n *  all put/delete cases and check throw flag use.  Need a new API primitive\n *  which allows throws flag to be specified.\n *\n *  XXX: array lengths above 2G won't work reliably.  There are many places\n *  where one needs a full signed 32-bit range ([-0xffffffff, 0xffffffff],\n *  i.e. -33- bits).  Although array 'length' cannot be written to be outside\n *  the unsigned 32-bit range (E5.1 Section 15.4.5.1 throws a RangeError if so)\n *  some intermediate values may be above 0xffffffff and this may not be always\n *  correctly handled now (duk_uint32_t is not enough for all algorithms).\n *  For instance, push() can legitimately write entries beyond length 0xffffffff\n *  and cause a RangeError only at the end.  To do this properly, the current\n *  push() implementation tracks the array index using a 'double' instead of a\n *  duk_uint32_t (which is somewhat awkward).  See test-bi-array-push-maxlen.js.\n *\n *  On using \"put\" vs. \"def\" prop\n *  =============================\n *\n *  Code below must be careful to use the appropriate primitive as it matters\n *  for compliance.  When using \"put\" there may be inherited properties in\n *  Array.prototype which cause side effects when values are written.  When\n *  using \"define\" there are no such side effects, and many test262 test cases\n *  check for this (for real world code, such side effects are very rare).\n *  Both \"put\" and \"define\" are used in the E5.1 specification; as a rule,\n *  \"put\" is used when modifying an existing array (or a non-array 'this'\n *  binding) and \"define\" for setting values into a fresh result array.\n */\n\n/* #include duk_internal.h -> already included */\n\n/* Perform an intermediate join when this many elements have been pushed\n * on the value stack.\n */\n#define  DUK__ARRAY_MID_JOIN_LIMIT  4096\n\n#if defined(DUK_USE_ARRAY_BUILTIN)\n\n/*\n *  Shared helpers.\n */\n\n/* Shared entry code for many Array built-ins: the 'this' binding is pushed\n * on the value stack and object coerced, and the current .length is returned.\n * Note that length is left on stack (it could be popped, but that's not\n * usually necessary because call handling will clean it up automatically).\n */\nDUK_LOCAL duk_uint32_t duk__push_this_obj_len_u32(duk_context *ctx) {\n\tduk_uint32_t len;\n\n\t/* XXX: push more directly? */\n\t(void) duk_push_this_coercible_to_object(ctx);\n\tDUK_ASSERT_HOBJECT_VALID(duk_get_hobject(ctx, -1));\n\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_LENGTH);\n\tlen = duk_to_uint32(ctx, -1);\n\n\t/* -> [ ... ToObject(this) ToUint32(length) ] */\n\treturn len;\n}\n\nDUK_LOCAL duk_uint32_t duk__push_this_obj_len_u32_limited(duk_context *ctx) {\n\t/* Range limited to [0, 0x7fffffff] range, i.e. range that can be\n\t * represented with duk_int32_t.  Use this when the method doesn't\n\t * handle the full 32-bit unsigned range correctly.\n\t */\n\tduk_uint32_t ret = duk__push_this_obj_len_u32(ctx);\n\tif (DUK_UNLIKELY(ret >= 0x80000000UL)) {\n\t\tDUK_ERROR_RANGE_INVALID_LENGTH((duk_hthread *) ctx);\n\t}\n\treturn ret;\n}\n\n#if defined(DUK_USE_ARRAY_FASTPATH)\n/* Check if 'this' binding is an Array instance (duk_harray) which satisfies\n * a few other guarantees for fast path operation.  The fast path doesn't\n * need to handle all operations, even for duk_harrays, but must handle a\n * significant fraction to improve performance.  Return a non-NULL duk_harray\n * pointer when all fast path criteria are met, NULL otherwise.\n */\nDUK_LOCAL duk_harray *duk__arraypart_fastpath_this(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_tval *tv;\n\tduk_hobject *h;\n\tduk_uint_t flags_mask, flags_bits, flags_value;\n\n\tthr = (duk_hthread *) ctx;\n\tDUK_ASSERT(thr->valstack_bottom > thr->valstack);  /* because call in progress */\n\ttv = DUK_GET_THIS_TVAL_PTR(thr);\n\n\t/* Fast path requires that 'this' is a duk_harray.  Read only arrays\n\t * (ROM backed) are also rejected for simplicity.\n\t */\n\tif (!DUK_TVAL_IS_OBJECT(tv)) {\n\t\tDUK_DD(DUK_DDPRINT(\"reject array fast path: not an object\"));\n\t\treturn NULL;\n\t}\n\th = DUK_TVAL_GET_OBJECT(tv);\n\tDUK_ASSERT(h != NULL);\n\tflags_mask = DUK_HOBJECT_FLAG_ARRAY_PART | \\\n\t             DUK_HOBJECT_FLAG_EXOTIC_ARRAY | \\\n\t             DUK_HEAPHDR_FLAG_READONLY;\n\tflags_bits = DUK_HOBJECT_FLAG_ARRAY_PART | \\\n\t             DUK_HOBJECT_FLAG_EXOTIC_ARRAY;\n\tflags_value = DUK_HEAPHDR_GET_FLAGS_RAW((duk_heaphdr *) h);\n\tif ((flags_value & flags_mask) != flags_bits) {\n\t\tDUK_DD(DUK_DDPRINT(\"reject array fast path: object flag check failed\"));\n\t\treturn NULL;\n\t}\n\n\t/* In some cases a duk_harray's 'length' may be larger than the\n\t * current array part allocation.  Avoid the fast path in these\n\t * cases, so that all fast path code can safely assume that all\n\t * items in the range [0,length[ are backed by the current array\n\t * part allocation.\n\t */\n\tif (((duk_harray *) h)->length > DUK_HOBJECT_GET_ASIZE(h)) {\n\t\tDUK_DD(DUK_DDPRINT(\"reject array fast path: length > array part size\"));\n\t\treturn NULL;\n\t}\n\n\t/* Guarantees for fast path. */\n\tDUK_ASSERT(h != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_GET_ASIZE(h) == 0 || DUK_HOBJECT_A_GET_BASE(thr->heap, h) != NULL);\n\tDUK_ASSERT(((duk_harray *) h)->length <= DUK_HOBJECT_GET_ASIZE(h));\n\n\tDUK_DD(DUK_DDPRINT(\"array fast path allowed for: %!O\", (duk_heaphdr *) h));\n\treturn (duk_harray *) h;\n}\n#endif  /* DUK_USE_ARRAY_FASTPATH */\n\n/*\n *  Constructor\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_array_constructor(duk_context *ctx) {\n\tduk_idx_t nargs;\n\tduk_harray *a;\n\tduk_double_t d;\n\tduk_uint32_t len;\n\tduk_uint32_t len_prealloc;\n\n\tnargs = duk_get_top(ctx);\n\n\tif (nargs == 1 && duk_is_number(ctx, 0)) {\n\t\t/* XXX: expensive check (also shared elsewhere - so add a shared internal API call?) */\n\t\td = duk_get_number(ctx, 0);\n\t\tlen = duk_to_uint32(ctx, 0);\n\t\tif (((duk_double_t) len) != d) {\n\t\t\tDUK_DCERROR_RANGE_INVALID_LENGTH((duk_hthread *) ctx);\n\t\t}\n\n\t\t/* For small lengths create a dense preallocated array.\n\t\t * For large arrays preallocate an initial part.\n\t\t */\n\t\tlen_prealloc = len < 64 ? len : 64;\n\t\ta = duk_push_harray_with_size(ctx, len_prealloc);\n\t\tDUK_ASSERT(a != NULL);\n\t\ta->length = len;\n\t\treturn 1;\n\t}\n\n\tduk_pack(ctx, nargs);\n\treturn 1;\n}\n\n/*\n *  isArray()\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_array_constructor_is_array(duk_context *ctx) {\n\tduk_hobject *h;\n\n\th = duk_get_hobject_with_class(ctx, 0, DUK_HOBJECT_CLASS_ARRAY);\n\tduk_push_boolean(ctx, (h != NULL));\n\treturn 1;\n}\n\n/*\n *  toString()\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_array_prototype_to_string(duk_context *ctx) {\n\t(void) duk_push_this_coercible_to_object(ctx);\n\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_JOIN);\n\n\t/* [ ... this func ] */\n\tif (!duk_is_callable(ctx, -1)) {\n\t\t/* Fall back to the initial (original) Object.toString().  We don't\n\t\t * currently have pointers to the built-in functions, only the top\n\t\t * level global objects (like \"Array\") so this is now done in a bit\n\t\t * of a hacky manner.  It would be cleaner to push the (original)\n\t\t * function and use duk_call_method().\n\t\t */\n\n\t\t/* XXX: 'this' will be ToObject() coerced twice, which is incorrect\n\t\t * but should have no visible side effects.\n\t\t */\n\t\tDUK_DDD(DUK_DDDPRINT(\"this.join is not callable, fall back to (original) Object.toString\"));\n\t\tduk_set_top(ctx, 0);\n\t\treturn duk_bi_object_prototype_to_string(ctx);  /* has access to 'this' binding */\n\t}\n\n\t/* [ ... this func ] */\n\n\tduk_insert(ctx, -2);\n\n\t/* [ ... func this ] */\n\n\tDUK_DDD(DUK_DDDPRINT(\"calling: func=%!iT, this=%!iT\",\n\t                     (duk_tval *) duk_get_tval(ctx, -2),\n\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\tduk_call_method(ctx, 0);\n\n\treturn 1;\n}\n\n/*\n *  concat()\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_array_prototype_concat(duk_context *ctx) {\n\tduk_idx_t i, n;\n\tduk_uarridx_t idx, idx_last;\n\tduk_uarridx_t j, len;\n\tduk_hobject *h;\n\n\t/* XXX: the insert here is a bit expensive if there are a lot of items.\n\t * It could also be special cased in the outermost for loop quite easily\n\t * (as the element is dup()'d anyway).\n\t */\n\n\t(void) duk_push_this_coercible_to_object(ctx);\n\tduk_insert(ctx, 0);\n\tn = duk_get_top(ctx);\n\tduk_push_array(ctx);  /* -> [ ToObject(this) item1 ... itemN arr ] */\n\n\t/* NOTE: The Array special behaviors are NOT invoked by duk_xdef_prop_index()\n\t * (which differs from the official algorithm).  If no error is thrown, this\n\t * doesn't matter as the length is updated at the end.  However, if an error\n\t * is thrown, the length will be unset.  That shouldn't matter because the\n\t * caller won't get a reference to the intermediate value.\n\t */\n\n\tidx = 0;\n\tidx_last = 0;\n\tfor (i = 0; i < n; i++) {\n\t\tDUK_ASSERT_TOP(ctx, n + 1);\n\n\t\t/* [ ToObject(this) item1 ... itemN arr ] */\n\n\t\tduk_dup(ctx, i);\n\t\th = duk_get_hobject_with_class(ctx, -1, DUK_HOBJECT_CLASS_ARRAY);\n\t\tif (!h) {\n\t\t\tduk_xdef_prop_index_wec(ctx, -2, idx++);\n\t\t\tidx_last = idx;\n\t\t\tcontinue;\n\t\t}\n\n\t\t/* [ ToObject(this) item1 ... itemN arr item(i) ] */\n\n\t\t/* XXX: an array can have length higher than 32 bits; this is not handled\n\t\t * correctly now.\n\t\t */\n\t\tlen = (duk_uarridx_t) duk_get_length(ctx, -1);\n\t\tfor (j = 0; j < len; j++) {\n\t\t\tif (duk_get_prop_index(ctx, -1, j)) {\n\t\t\t\t/* [ ToObject(this) item1 ... itemN arr item(i) item(i)[j] ] */\n\t\t\t\tduk_xdef_prop_index_wec(ctx, -3, idx++);\n\t\t\t\tidx_last = idx;\n\t\t\t} else {\n\t\t\t\tidx++;\n\t\t\t\tduk_pop(ctx);\n#if defined(DUK_USE_NONSTD_ARRAY_CONCAT_TRAILER)\n\t\t\t\t/* According to E5.1 Section 15.4.4.4 nonexistent trailing\n\t\t\t\t * elements do not affect 'length' of the result.  Test262\n\t\t\t\t * and other engines disagree, so update idx_last here too.\n\t\t\t\t */\n\t\t\t\tidx_last = idx;\n#else\n\t\t\t\t/* Strict standard behavior, ignore trailing elements for\n\t\t\t\t * result 'length'.\n\t\t\t\t */\n#endif\n\t\t\t}\n\t\t}\n\t\tduk_pop(ctx);\n\t}\n\n\t/* The E5.1 Section 15.4.4.4 algorithm doesn't set the length explicitly\n\t * in the end, but because we're operating with an internal value which\n\t * is known to be an array, this should be equivalent.\n\t */\n\tduk_push_uarridx(ctx, idx_last);\n\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_LENGTH, DUK_PROPDESC_FLAGS_W);\n\n\tDUK_ASSERT_TOP(ctx, n + 1);\n\treturn 1;\n}\n\n/*\n *  join(), toLocaleString()\n *\n *  Note: checking valstack is necessary, but only in the per-element loop.\n *\n *  Note: the trivial approach of pushing all the elements on the value stack\n *  and then calling duk_join() fails when the array contains a large number\n *  of elements.  This problem can't be offloaded to duk_join() because the\n *  elements to join must be handled here and have special handling.  Current\n *  approach is to do intermediate joins with very large number of elements.\n *  There is no fancy handling; the prefix gets re-joined multiple times.\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_array_prototype_join_shared(duk_context *ctx) {\n\tduk_uint32_t len, count;\n\tduk_uint32_t idx;\n\tduk_small_int_t to_locale_string = duk_get_current_magic(ctx);\n\tduk_idx_t valstack_required;\n\n\t/* For join(), nargs is 1.  For toLocaleString(), nargs is 0 and\n\t * setting the top essentially pushes an undefined to the stack,\n\t * thus defaulting to a comma separator.\n\t */\n\tduk_set_top(ctx, 1);\n\tif (duk_is_undefined(ctx, 0)) {\n\t\tduk_pop(ctx);\n\t\tduk_push_hstring_stridx(ctx, DUK_STRIDX_COMMA);\n\t} else {\n\t\tduk_to_string(ctx, 0);\n\t}\n\n\tlen = duk__push_this_obj_len_u32(ctx);\n\n\t/* [ sep ToObject(this) len ] */\n\n\tDUK_DDD(DUK_DDDPRINT(\"sep=%!T, this=%!T, len=%lu\",\n\t                     (duk_tval *) duk_get_tval(ctx, 0),\n\t                     (duk_tval *) duk_get_tval(ctx, 1),\n\t                     (unsigned long) len));\n\n\t/* The extra (+4) is tight. */\n\tvalstack_required = (len >= DUK__ARRAY_MID_JOIN_LIMIT ?\n\t                     DUK__ARRAY_MID_JOIN_LIMIT : len) + 4;\n\tduk_require_stack(ctx, valstack_required);\n\n\tduk_dup_0(ctx);\n\n\t/* [ sep ToObject(this) len sep ] */\n\n\tcount = 0;\n\tidx = 0;\n\tfor (;;) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"join idx=%ld\", (long) idx));\n\t\tif (count >= DUK__ARRAY_MID_JOIN_LIMIT ||   /* intermediate join to avoid valstack overflow */\n\t\t    idx >= len) { /* end of loop (careful with len==0) */\n\t\t\t/* [ sep ToObject(this) len sep str0 ... str(count-1) ] */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"mid/final join, count=%ld, idx=%ld, len=%ld\",\n\t\t\t                     (long) count, (long) idx, (long) len));\n\t\t\tduk_join(ctx, (duk_idx_t) count);  /* -> [ sep ToObject(this) len str ] */\n\t\t\tduk_dup_0(ctx);                    /* -> [ sep ToObject(this) len str sep ] */\n\t\t\tduk_insert(ctx, -2);               /* -> [ sep ToObject(this) len sep str ] */\n\t\t\tcount = 1;\n\t\t}\n\t\tif (idx >= len) {\n\t\t\t/* if true, the stack already contains the final result */\n\t\t\tbreak;\n\t\t}\n\n\t\tduk_get_prop_index(ctx, 1, (duk_uarridx_t) idx);\n\t\tif (duk_is_null_or_undefined(ctx, -1)) {\n\t\t\tduk_pop(ctx);\n\t\t\tduk_push_hstring_empty(ctx);\n\t\t} else {\n\t\t\tif (to_locale_string) {\n\t\t\t\tduk_to_object(ctx, -1);\n\t\t\t\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_TO_LOCALE_STRING);\n\t\t\t\tduk_insert(ctx, -2);  /* -> [ ... toLocaleString ToObject(val) ] */\n\t\t\t\tduk_call_method(ctx, 0);\n\t\t\t}\n\t\t\tduk_to_string(ctx, -1);\n\t\t}\n\n\t\tcount++;\n\t\tidx++;\n\t}\n\n\t/* [ sep ToObject(this) len sep result ] */\n\n\treturn 1;\n}\n\n/*\n *  pop(), push()\n */\n\n#if defined(DUK_USE_ARRAY_FASTPATH)\nDUK_LOCAL duk_ret_t duk__array_pop_fastpath(duk_context *ctx, duk_harray *h_arr) {\n\tduk_hthread *thr;\n\tduk_tval *tv_arraypart;\n\tduk_tval *tv_val;\n\tduk_uint32_t len;\n\n\tthr = (duk_hthread *) ctx;\n\n\ttv_arraypart = DUK_HOBJECT_A_GET_BASE(thr->heap, (duk_hobject *) h_arr);\n\tlen = h_arr->length;\n\tif (len <= 0) {\n\t\t/* nop, return undefined */\n\t\treturn 0;\n\t}\n\n\tlen--;\n\th_arr->length = len;\n\n\t/* Fast path doesn't check for an index property inherited from\n\t * Array.prototype.  This is quite often acceptable; if not,\n\t * disable fast path.\n\t */\n\tDUK_ASSERT_VS_SPACE(thr);\n\ttv_val = tv_arraypart + len;\n\tif (DUK_TVAL_IS_UNUSED(tv_val)) {\n\t\t/* No net refcount change.  Value stack already has\n\t\t * 'undefined' based on value stack init policy.\n\t\t */\n\t\tDUK_ASSERT(DUK_TVAL_IS_UNDEFINED(thr->valstack_top));\n\t\tDUK_ASSERT(DUK_TVAL_IS_UNUSED(tv_val));\n\t} else {\n\t\t/* No net refcount change. */\n\t\tDUK_TVAL_SET_TVAL(thr->valstack_top, tv_val);\n\t\tDUK_TVAL_SET_UNUSED(tv_val);\n\t}\n\tthr->valstack_top++;\n\n\t/* XXX: there's no shrink check in the fast path now */\n\n\treturn 1;\n}\n#endif  /* DUK_USE_ARRAY_FASTPATH */\n\nDUK_INTERNAL duk_ret_t duk_bi_array_prototype_pop(duk_context *ctx) {\n\tduk_uint32_t len;\n\tduk_uint32_t idx;\n#if defined(DUK_USE_ARRAY_FASTPATH)\n\tduk_harray *h_arr;\n#endif\n\n\tDUK_ASSERT_TOP(ctx, 0);\n\n#if defined(DUK_USE_ARRAY_FASTPATH)\n\th_arr = duk__arraypart_fastpath_this(ctx);\n\tif (h_arr) {\n\t\treturn duk__array_pop_fastpath(ctx, h_arr);\n\t}\n#endif\n\n\t/* XXX: Merge fastpath check into a related call (push this, coerce length, etc)? */\n\n\tlen = duk__push_this_obj_len_u32(ctx);\n\tif (len == 0) {\n\t\tduk_push_int(ctx, 0);\n\t\tduk_put_prop_stridx_short(ctx, 0, DUK_STRIDX_LENGTH);\n\t\treturn 0;\n\t}\n\tidx = len - 1;\n\n\tduk_get_prop_index(ctx, 0, (duk_uarridx_t) idx);\n\tduk_del_prop_index(ctx, 0, (duk_uarridx_t) idx);\n\tduk_push_u32(ctx, idx);\n\tduk_put_prop_stridx_short(ctx, 0, DUK_STRIDX_LENGTH);\n\treturn 1;\n}\n\n#if defined(DUK_USE_ARRAY_FASTPATH)\nDUK_LOCAL duk_ret_t duk__array_push_fastpath(duk_context *ctx, duk_harray *h_arr) {\n\tduk_hthread *thr;\n\tduk_tval *tv_arraypart;\n\tduk_tval *tv_src;\n\tduk_tval *tv_dst;\n\tduk_uint32_t len;\n\tduk_idx_t i, n;\n\n\tthr = (duk_hthread *) ctx;\n\n\tlen = h_arr->length;\n\ttv_arraypart = DUK_HOBJECT_A_GET_BASE(thr->heap, (duk_hobject *) h_arr);\n\n\tn = (duk_idx_t) (thr->valstack_top - thr->valstack_bottom);\n\tif (DUK_UNLIKELY(len + n < len)) {\n\t\tDUK_D(DUK_DPRINT(\"Array.prototype.push() would go beyond 32-bit length, throw\"));\n\t\tDUK_DCERROR_RANGE_INVALID_LENGTH(thr);  /* != 0 return value returned as is by caller */\n\t}\n\tif (len + n > DUK_HOBJECT_GET_ASIZE((duk_hobject *) h_arr)) {\n\t\t/* Array part would need to be extended.  Rely on slow path\n\t\t * for now.\n\t\t *\n\t\t * XXX: Rework hobject code a bit and add extend support.\n\t\t */\n\t\treturn 0;\n\t}\n\n\ttv_src = thr->valstack_bottom;\n\ttv_dst = tv_arraypart + len;\n\tfor (i = 0; i < n; i++) {\n\t\t/* No net refcount change; reset value stack values to\n\t\t * undefined to satisfy value stack init policy.\n\t\t */\n\t\tDUK_TVAL_SET_TVAL(tv_dst, tv_src);\n\t\tDUK_TVAL_SET_UNDEFINED(tv_src);\n\t\ttv_src++;\n\t\ttv_dst++;\n\t}\n\tthr->valstack_top = thr->valstack_bottom;\n\tlen += n;\n\th_arr->length = len;\n\n\tDUK_ASSERT((duk_uint_t) len == len);\n\tduk_push_uint(ctx, (duk_uint_t) len);\n\treturn 1;\n}\n#endif  /* DUK_USE_ARRAY_FASTPATH */\n\nDUK_INTERNAL duk_ret_t duk_bi_array_prototype_push(duk_context *ctx) {\n\t/* Note: 'this' is not necessarily an Array object.  The push()\n\t * algorithm is supposed to work for other kinds of objects too,\n\t * so the algorithm has e.g. an explicit update for the 'length'\n\t * property which is normally \"magical\" in arrays.\n\t */\n\n\tduk_uint32_t len;\n\tduk_idx_t i, n;\n#if defined(DUK_USE_ARRAY_FASTPATH)\n\tduk_harray *h_arr;\n#endif\n\n#if defined(DUK_USE_ARRAY_FASTPATH)\n\th_arr = duk__arraypart_fastpath_this(ctx);\n\tif (h_arr) {\n\t\tduk_ret_t rc;\n\t\trc = duk__array_push_fastpath(ctx, h_arr);\n\t\tif (rc != 0) {\n\t\t\treturn rc;\n\t\t}\n\t\tDUK_DD(DUK_DDPRINT(\"array push() fast path exited, resize case\"));\n\t}\n#endif\n\n\tn = duk_get_top(ctx);\n\tlen = duk__push_this_obj_len_u32(ctx);\n\n\t/* [ arg1 ... argN obj length ] */\n\n\t/* Technically Array.prototype.push() can create an Array with length\n\t * longer than 2^32-1, i.e. outside the 32-bit range.  The final length\n\t * is *not* wrapped to 32 bits in the specification.\n\t *\n\t * This implementation tracks length with a uint32 because it's much\n\t * more practical.\n\t *\n\t * See: test-bi-array-push-maxlen.js.\n\t */\n\n\tif (len + (duk_uint32_t) n < len) {\n\t\tDUK_D(DUK_DPRINT(\"Array.prototype.push() would go beyond 32-bit length, throw\"));\n\t\tDUK_DCERROR_RANGE_INVALID_LENGTH((duk_hthread *) ctx);\n\t}\n\n\tfor (i = 0; i < n; i++) {\n\t\tduk_dup(ctx, i);\n\t\tduk_put_prop_index(ctx, -3, len + i);\n\t}\n\tlen += n;\n\n\tduk_push_u32(ctx, len);\n\tduk_dup_top(ctx);\n\tduk_put_prop_stridx_short(ctx, -4, DUK_STRIDX_LENGTH);\n\n\t/* [ arg1 ... argN obj length new_length ] */\n\treturn 1;\n}\n\n/*\n *  sort()\n *\n *  Currently qsort with random pivot.  This is now really, really slow,\n *  because there is no fast path for array parts.\n *\n *  Signed indices are used because qsort() leaves and degenerate cases\n *  may use a negative offset.\n */\n\nDUK_LOCAL duk_small_int_t duk__array_sort_compare(duk_context *ctx, duk_int_t idx1, duk_int_t idx2) {\n\tduk_bool_t have1, have2;\n\tduk_bool_t undef1, undef2;\n\tduk_small_int_t ret;\n\tduk_idx_t idx_obj = 1;  /* fixed offsets in valstack */\n\tduk_idx_t idx_fn = 0;\n\tduk_hstring *h1, *h2;\n\n\t/* Fast exit if indices are identical.  This is valid for a non-existent property,\n\t * for an undefined value, and almost always for ToString() coerced comparison of\n\t * arbitrary values (corner cases where this is not the case include e.g. a an\n\t * object with varying ToString() coercion).\n\t *\n\t * The specification does not prohibit \"caching\" of values read from the array, so\n\t * assuming equality for comparing an index with itself falls into the category of\n\t * \"caching\".\n\t *\n\t * Also, compareFn may be inconsistent, so skipping a call to compareFn here may\n\t * have an effect on the final result.  The specification does not require any\n\t * specific behavior for inconsistent compare functions, so again, this fast path\n\t * is OK.\n\t */\n\n\tif (idx1 == idx2) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"duk__array_sort_compare: idx1=%ld, idx2=%ld -> indices identical, quick exit\",\n\t\t                     (long) idx1, (long) idx2));\n\t\treturn 0;\n\t}\n\n\thave1 = duk_get_prop_index(ctx, idx_obj, (duk_uarridx_t) idx1);\n\thave2 = duk_get_prop_index(ctx, idx_obj, (duk_uarridx_t) idx2);\n\n\tDUK_DDD(DUK_DDDPRINT(\"duk__array_sort_compare: idx1=%ld, idx2=%ld, have1=%ld, have2=%ld, val1=%!T, val2=%!T\",\n\t                     (long) idx1, (long) idx2, (long) have1, (long) have2,\n\t                     (duk_tval *) duk_get_tval(ctx, -2), (duk_tval *) duk_get_tval(ctx, -1)));\n\n\tif (have1) {\n\t\tif (have2) {\n\t\t\t;\n\t\t} else {\n\t\t\tret = -1;\n\t\t\tgoto pop_ret;\n\t\t}\n\t} else {\n\t\tif (have2) {\n\t\t\tret = 1;\n\t\t\tgoto pop_ret;\n\t\t} else {\n\t\t\tret = 0;\n\t\t\tgoto pop_ret;\n\t\t}\n\t}\n\n\tundef1 = duk_is_undefined(ctx, -2);\n\tundef2 = duk_is_undefined(ctx, -1);\n\tif (undef1) {\n\t\tif (undef2) {\n\t\t\tret = 0;\n\t\t\tgoto pop_ret;\n\t\t} else {\n\t\t\tret = 1;\n\t\t\tgoto pop_ret;\n\t\t}\n\t} else {\n\t\tif (undef2) {\n\t\t\tret = -1;\n\t\t\tgoto pop_ret;\n\t\t} else {\n\t\t\t;\n\t\t}\n\t}\n\n\tif (!duk_is_undefined(ctx, idx_fn)) {\n\t\tduk_double_t d;\n\n\t\t/* No need to check callable; duk_call() will do that. */\n\t\tduk_dup(ctx, idx_fn);    /* -> [ ... x y fn ] */\n\t\tduk_insert(ctx, -3);     /* -> [ ... fn x y ] */\n\t\tduk_call(ctx, 2);        /* -> [ ... res ] */\n\n\t\t/* ES5 is a bit vague about what to do if the return value is\n\t\t * not a number.  ES2015 provides a concrete description:\n\t\t * http://www.ecma-international.org/ecma-262/6.0/#sec-sortcompare.\n\t\t */\n\n\t\td = duk_to_number_m1(ctx);\n\t\tif (d < 0.0) {\n\t\t\tret = -1;\n\t\t} else if (d > 0.0) {\n\t\t\tret = 1;\n\t\t} else {\n\t\t\t/* Because NaN compares to false, NaN is handled here\n\t\t\t * without an explicit check above.\n\t\t\t */\n\t\t\tret = 0;\n\t\t}\n\n\t\tduk_pop(ctx);\n\t\tDUK_DDD(DUK_DDDPRINT(\"-> result %ld (from comparefn, after coercion)\", (long) ret));\n\t\treturn ret;\n\t}\n\n\t/* string compare is the default (a bit oddly) */\n\n\t/* XXX: any special handling for plain array; causes repeated coercion now? */\n\th1 = duk_to_hstring(ctx, -2);\n\th2 = duk_to_hstring_m1(ctx);\n\tDUK_ASSERT(h1 != NULL);\n\tDUK_ASSERT(h2 != NULL);\n\n\tret = duk_js_string_compare(h1, h2);  /* retval is directly usable */\n\tgoto pop_ret;\n\n pop_ret:\n\tduk_pop_2(ctx);\n\tDUK_DDD(DUK_DDDPRINT(\"-> result %ld\", (long) ret));\n\treturn ret;\n}\n\nDUK_LOCAL void duk__array_sort_swap(duk_context *ctx, duk_int_t l, duk_int_t r) {\n\tduk_bool_t have_l, have_r;\n\tduk_idx_t idx_obj = 1;  /* fixed offset in valstack */\n\n\tif (l == r) {\n\t\treturn;\n\t}\n\n\t/* swap elements; deal with non-existent elements correctly */\n\thave_l = duk_get_prop_index(ctx, idx_obj, (duk_uarridx_t) l);\n\thave_r = duk_get_prop_index(ctx, idx_obj, (duk_uarridx_t) r);\n\n\tif (have_r) {\n\t\t/* right exists, [[Put]] regardless whether or not left exists */\n\t\tduk_put_prop_index(ctx, idx_obj, (duk_uarridx_t) l);\n\t} else {\n\t\tduk_del_prop_index(ctx, idx_obj, (duk_uarridx_t) l);\n\t\tduk_pop(ctx);\n\t}\n\n\tif (have_l) {\n\t\tduk_put_prop_index(ctx, idx_obj, (duk_uarridx_t) r);\n\t} else {\n\t\tduk_del_prop_index(ctx, idx_obj, (duk_uarridx_t) r);\n\t\tduk_pop(ctx);\n\t}\n}\n\n#if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 2)\n/* Debug print which visualizes the qsort partitioning process. */\nDUK_LOCAL void duk__debuglog_qsort_state(duk_context *ctx, duk_int_t lo, duk_int_t hi, duk_int_t pivot) {\n\tchar buf[4096];\n\tchar *ptr = buf;\n\tduk_int_t i, n;\n\tn = (duk_int_t) duk_get_length(ctx, 1);\n\tif (n > 4000) {\n\t\tn = 4000;\n\t}\n\t*ptr++ = '[';\n\tfor (i = 0; i < n; i++) {\n\t\tif (i == pivot) {\n\t\t\t*ptr++ = '|';\n\t\t} else if (i == lo) {\n\t\t\t*ptr++ = '<';\n\t\t} else if (i == hi) {\n\t\t\t*ptr++ = '>';\n\t\t} else if (i >= lo && i <= hi) {\n\t\t\t*ptr++ = '-';\n\t\t} else {\n\t\t\t*ptr++ = ' ';\n\t\t}\n\t}\n\t*ptr++ = ']';\n\t*ptr++ = '\\0';\n\n\tDUK_DDD(DUK_DDDPRINT(\"%s   (lo=%ld, hi=%ld, pivot=%ld)\",\n\t                     (const char *) buf, (long) lo, (long) hi, (long) pivot));\n}\n#endif\n\nDUK_LOCAL void duk__array_qsort(duk_context *ctx, duk_int_t lo, duk_int_t hi) {\n\tduk_int_t p, l, r;\n\n\t/* The lo/hi indices may be crossed and hi < 0 is possible at entry. */\n\n\tDUK_DDD(DUK_DDDPRINT(\"duk__array_qsort: lo=%ld, hi=%ld, obj=%!T\",\n\t                     (long) lo, (long) hi, (duk_tval *) duk_get_tval(ctx, 1)));\n\n\tDUK_ASSERT_TOP(ctx, 3);\n\n\t/* In some cases it may be that lo > hi, or hi < 0; these\n\t * degenerate cases happen e.g. for empty arrays, and in\n\t * recursion leaves.\n\t */\n\n\t/* trivial cases */\n\tif (hi - lo < 1) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"degenerate case, return immediately\"));\n\t\treturn;\n\t}\n\tDUK_ASSERT(hi > lo);\n\tDUK_ASSERT(hi - lo + 1 >= 2);\n\n\t/* randomized pivot selection */\n\tp = lo + (duk_int_t) (DUK_UTIL_GET_RANDOM_DOUBLE((duk_hthread *) ctx) * (duk_double_t) (hi - lo + 1));\n\tDUK_ASSERT(p >= lo && p <= hi);\n\tDUK_DDD(DUK_DDDPRINT(\"lo=%ld, hi=%ld, chose pivot p=%ld\", (long) lo, (long) hi, (long) p));\n\n\t/* move pivot out of the way */\n\tduk__array_sort_swap(ctx, p, lo);\n\tp = lo;\n\tDUK_DDD(DUK_DDDPRINT(\"pivot moved out of the way: %!T\", (duk_tval *) duk_get_tval(ctx, 1)));\n\n\tl = lo + 1;\n\tr = hi;\n\tfor (;;) {\n\t\t/* find elements to swap */\n\t\tfor (;;) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"left scan: l=%ld, r=%ld, p=%ld\",\n\t\t\t                     (long) l, (long) r, (long) p));\n\t\t\tif (l >= hi) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (duk__array_sort_compare(ctx, l, p) >= 0) {  /* !(l < p) */\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tl++;\n\t\t}\n\t\tfor (;;) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"right scan: l=%ld, r=%ld, p=%ld\",\n\t\t\t                     (long) l, (long) r, (long) p));\n\t\t\tif (r <= lo) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (duk__array_sort_compare(ctx, p, r) >= 0) {  /* !(p < r) */\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tr--;\n\t\t}\n\t\tif (l >= r) {\n\t\t\tgoto done;\n\t\t}\n\t\tDUK_ASSERT(l < r);\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"swap %ld and %ld\", (long) l, (long) r));\n\n\t\tduk__array_sort_swap(ctx, l, r);\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"after swap: %!T\", (duk_tval *) duk_get_tval(ctx, 1)));\n\t\tl++;\n\t\tr--;\n\t}\n done:\n\t/* Note that 'l' and 'r' may cross, i.e. r < l */\n\tDUK_ASSERT(l >= lo && l <= hi);\n\tDUK_ASSERT(r >= lo && r <= hi);\n\n\t/* XXX: there's no explicit recursion bound here now.  For the average\n\t * qsort recursion depth O(log n) that's not really necessary: e.g. for\n\t * 2**32 recursion depth would be about 32 which is OK.  However, qsort\n\t * worst case recursion depth is O(n) which may be a problem.\n\t */\n\n\t/* move pivot to its final place */\n\tDUK_DDD(DUK_DDDPRINT(\"before final pivot swap: %!T\", (duk_tval *) duk_get_tval(ctx, 1)));\n\tduk__array_sort_swap(ctx, lo, r);\n\n#if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 2)\n\tduk__debuglog_qsort_state(ctx, lo, hi, r);\n#endif\n\n\tDUK_DDD(DUK_DDDPRINT(\"recurse: pivot=%ld, obj=%!T\", (long) r, (duk_tval *) duk_get_tval(ctx, 1)));\n\tduk__array_qsort(ctx, lo, r - 1);\n\tduk__array_qsort(ctx, r + 1, hi);\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_array_prototype_sort(duk_context *ctx) {\n\tduk_uint32_t len;\n\n\t/* XXX: len >= 0x80000000 won't work below because a signed type\n\t * is needed by qsort.\n\t */\n\tlen = duk__push_this_obj_len_u32_limited(ctx);\n\n\t/* stack[0] = compareFn\n\t * stack[1] = ToObject(this)\n\t * stack[2] = ToUint32(length)\n\t */\n\n\tif (len > 0) {\n\t\t/* avoid degenerate cases, so that (len - 1) won't underflow */\n\t\tduk__array_qsort(ctx, (duk_int_t) 0, (duk_int_t) (len - 1));\n\t}\n\n\tDUK_ASSERT_TOP(ctx, 3);\n\tduk_pop(ctx);\n\treturn 1;  /* return ToObject(this) */\n}\n\n/*\n *  splice()\n */\n\n/* XXX: this compiles to over 500 bytes now, even without special handling\n * for an array part.  Uses signed ints so does not handle full array range correctly.\n */\n\n/* XXX: can shift() / unshift() use the same helper?\n *   shift() is (close to?) <--> splice(0, 1)\n *   unshift is (close to?) <--> splice(0, 0, [items])?\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_array_prototype_splice(duk_context *ctx) {\n\tduk_idx_t nargs;\n\tduk_uint32_t len;\n\tduk_bool_t have_delcount;\n\tduk_int_t item_count;\n\tduk_int_t act_start;\n\tduk_int_t del_count;\n\tduk_int_t i, n;\n\n\tDUK_UNREF(have_delcount);\n\n\tnargs = duk_get_top(ctx);\n\tif (nargs < 2) {\n\t\tduk_set_top(ctx, 2);\n\t\tnargs = 2;\n\t\thave_delcount = 0;\n\t} else {\n\t\thave_delcount = 1;\n\t}\n\n\t/* XXX: len >= 0x80000000 won't work below because we need to be\n\t * able to represent -len.\n\t */\n\tlen = duk__push_this_obj_len_u32_limited(ctx);\n\n\tact_start = duk_to_int_clamped(ctx, 0, -((duk_int_t) len), (duk_int_t) len);\n\tif (act_start < 0) {\n\t\tact_start = len + act_start;\n\t}\n\tDUK_ASSERT(act_start >= 0 && act_start <= (duk_int_t) len);\n\n#if defined(DUK_USE_NONSTD_ARRAY_SPLICE_DELCOUNT)\n\tif (have_delcount) {\n#endif\n\t\tdel_count = duk_to_int_clamped(ctx, 1, 0, len - act_start);\n#if defined(DUK_USE_NONSTD_ARRAY_SPLICE_DELCOUNT)\n\t} else {\n\t\t/* E5.1 standard behavior when deleteCount is not given would be\n\t\t * to treat it just like if 'undefined' was given, which coerces\n\t\t * ultimately to 0.  Real world behavior is to splice to the end\n\t\t * of array, see test-bi-array-proto-splice-no-delcount.js.\n\t\t */\n\t\tdel_count = len - act_start;\n\t}\n#endif\n\n\tDUK_ASSERT(nargs >= 2);\n\titem_count = (duk_int_t) (nargs - 2);\n\n\tDUK_ASSERT(del_count >= 0 && del_count <= (duk_int_t) len - act_start);\n\tDUK_ASSERT(del_count + act_start <= (duk_int_t) len);\n\n\t/* For now, restrict result array into 32-bit length range. */\n\tif (((duk_double_t) len) - ((duk_double_t) del_count) + ((duk_double_t) item_count) > (duk_double_t) DUK_UINT32_MAX) {\n\t\tDUK_D(DUK_DPRINT(\"Array.prototype.splice() would go beyond 32-bit length, throw\"));\n\t\tDUK_DCERROR_RANGE_INVALID_LENGTH((duk_hthread *) ctx);\n\t}\n\n\tduk_push_array(ctx);\n\n\t/* stack[0] = start\n\t * stack[1] = deleteCount\n\t * stack[2...nargs-1] = items\n\t * stack[nargs] = ToObject(this)               -3\n\t * stack[nargs+1] = ToUint32(length)           -2\n\t * stack[nargs+2] = result array               -1\n\t */\n\n\tDUK_ASSERT_TOP(ctx, nargs + 3);\n\n\t/* Step 9: copy elements-to-be-deleted into the result array */\n\n\tfor (i = 0; i < del_count; i++) {\n\t\tif (duk_get_prop_index(ctx, -3, (duk_uarridx_t) (act_start + i))) {\n\t\t\tduk_xdef_prop_index_wec(ctx, -2, i);  /* throw flag irrelevant (false in std alg) */\n\t\t} else {\n\t\t\tduk_pop(ctx);\n\t\t}\n\t}\n\tduk_push_u32(ctx, (duk_uint32_t) del_count);\n\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_LENGTH, DUK_PROPDESC_FLAGS_W);\n\n\t/* Steps 12 and 13: reorganize elements to make room for itemCount elements */\n\n\tif (item_count < del_count) {\n\t\t/*    [ A B C D E F G H ]    rel_index = 2, del_count 3, item count 1\n\t\t * -> [ A B F G H ]          (conceptual intermediate step)\n\t\t * -> [ A B . F G H ]        (placeholder marked)\n\t\t *    [ A B C F G H ]        (actual result at this point, C will be replaced)\n\t\t */\n\n\t\tDUK_ASSERT_TOP(ctx, nargs + 3);\n\n\t\tn = len - del_count;\n\t\tfor (i = act_start; i < n; i++) {\n\t\t\tif (duk_get_prop_index(ctx, -3, (duk_uarridx_t) (i + del_count))) {\n\t\t\t\tduk_put_prop_index(ctx, -4, (duk_uarridx_t) (i + item_count));\n\t\t\t} else {\n\t\t\t\tduk_pop(ctx);\n\t\t\t\tduk_del_prop_index(ctx, -3, (duk_uarridx_t) (i + item_count));\n\t\t\t}\n\t\t}\n\n\t\tDUK_ASSERT_TOP(ctx, nargs + 3);\n\n\t\t/* loop iterator init and limit changed from standard algorithm */\n\t\tn = len - del_count + item_count;\n\t\tfor (i = len - 1; i >= n; i--) {\n\t\t\tduk_del_prop_index(ctx, -3, (duk_uarridx_t) i);\n\t\t}\n\n\t\tDUK_ASSERT_TOP(ctx, nargs + 3);\n\t} else if (item_count > del_count) {\n\t\t/*    [ A B C D E F G H ]    rel_index = 2, del_count 3, item count 4\n\t\t * -> [ A B F G H ]          (conceptual intermediate step)\n\t\t * -> [ A B . . . . F G H ]  (placeholder marked)\n\t\t *    [ A B C D E F F G H ]  (actual result at this point)\n\t\t */\n\n\t\tDUK_ASSERT_TOP(ctx, nargs + 3);\n\n\t\t/* loop iterator init and limit changed from standard algorithm */\n\t\tfor (i = len - del_count - 1; i >= act_start; i--) {\n\t\t\tif (duk_get_prop_index(ctx, -3, (duk_uarridx_t) (i + del_count))) {\n\t\t\t\tduk_put_prop_index(ctx, -4, (duk_uarridx_t) (i + item_count));\n\t\t\t} else {\n\t\t\t\tduk_pop(ctx);\n\t\t\t\tduk_del_prop_index(ctx, -3, (duk_uarridx_t) (i + item_count));\n\t\t\t}\n\t\t}\n\n\t\tDUK_ASSERT_TOP(ctx, nargs + 3);\n\t} else {\n\t\t/*    [ A B C D E F G H ]    rel_index = 2, del_count 3, item count 3\n\t\t * -> [ A B F G H ]          (conceptual intermediate step)\n\t\t * -> [ A B . . . F G H ]    (placeholder marked)\n\t\t *    [ A B C D E F G H ]    (actual result at this point)\n\t\t */\n\t}\n\tDUK_ASSERT_TOP(ctx, nargs + 3);\n\n\t/* Step 15: insert itemCount elements into the hole made above */\n\n\tfor (i = 0; i < item_count; i++) {\n\t\tduk_dup(ctx, i + 2);  /* args start at index 2 */\n\t\tduk_put_prop_index(ctx, -4, (duk_uarridx_t) (act_start + i));\n\t}\n\n\t/* Step 16: update length; note that the final length may be above 32 bit range\n\t * (but we checked above that this isn't the case here)\n\t */\n\n\tduk_push_u32(ctx, len - del_count + item_count);\n\tduk_put_prop_stridx_short(ctx, -4, DUK_STRIDX_LENGTH);\n\n\t/* result array is already at the top of stack */\n\tDUK_ASSERT_TOP(ctx, nargs + 3);\n\treturn 1;\n}\n\n/*\n *  reverse()\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_array_prototype_reverse(duk_context *ctx) {\n\tduk_uint32_t len;\n\tduk_uint32_t middle;\n\tduk_uint32_t lower, upper;\n\tduk_bool_t have_lower, have_upper;\n\n\tlen = duk__push_this_obj_len_u32(ctx);\n\tmiddle = len / 2;\n\n\t/* If len <= 1, middle will be 0 and for-loop bails out\n\t * immediately (0 < 0 -> false).\n\t */\n\n\tfor (lower = 0; lower < middle; lower++) {\n\t\tDUK_ASSERT(len >= 2);\n\t\tDUK_ASSERT_TOP(ctx, 2);\n\n\t\tDUK_ASSERT(len >= lower + 1);\n\t\tupper = len - lower - 1;\n\n\t\thave_lower = duk_get_prop_index(ctx, -2, (duk_uarridx_t) lower);\n\t\thave_upper = duk_get_prop_index(ctx, -3, (duk_uarridx_t) upper);\n\n\t\t/* [ ToObject(this) ToUint32(length) lowerValue upperValue ] */\n\n\t\tif (have_upper) {\n\t\t\tduk_put_prop_index(ctx, -4, (duk_uarridx_t) lower);\n\t\t} else {\n\t\t\tduk_del_prop_index(ctx, -4, (duk_uarridx_t) lower);\n\t\t\tduk_pop(ctx);\n\t\t}\n\n\t\tif (have_lower) {\n\t\t\tduk_put_prop_index(ctx, -3, (duk_uarridx_t) upper);\n\t\t} else {\n\t\t\tduk_del_prop_index(ctx, -3, (duk_uarridx_t) upper);\n\t\t\tduk_pop(ctx);\n\t\t}\n\n\t\tDUK_ASSERT_TOP(ctx, 2);\n\t}\n\n\tDUK_ASSERT_TOP(ctx, 2);\n\tduk_pop(ctx);  /* -> [ ToObject(this) ] */\n\treturn 1;\n}\n\n/*\n *  slice()\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_array_prototype_slice(duk_context *ctx) {\n\tduk_uint32_t len;\n\tduk_int_t start, end;\n\tduk_int_t i;\n\tduk_uarridx_t idx;\n\tduk_uint32_t res_length = 0;\n\n\t/* XXX: len >= 0x80000000 won't work below because we need to be\n\t * able to represent -len.\n\t */\n\tlen = duk__push_this_obj_len_u32_limited(ctx);\n\tduk_push_array(ctx);\n\n\t/* stack[0] = start\n\t * stack[1] = end\n\t * stack[2] = ToObject(this)\n\t * stack[3] = ToUint32(length)\n\t * stack[4] = result array\n\t */\n\n\tstart = duk_to_int_clamped(ctx, 0, -((duk_int_t) len), (duk_int_t) len);\n\tif (start < 0) {\n\t\tstart = len + start;\n\t}\n\t/* XXX: could duk_is_undefined() provide defaulting undefined to 'len'\n\t * (the upper limit)?\n\t */\n\tif (duk_is_undefined(ctx, 1)) {\n\t\tend = len;\n\t} else {\n\t\tend = duk_to_int_clamped(ctx, 1, -((duk_int_t) len), (duk_int_t) len);\n\t\tif (end < 0) {\n\t\t\tend = len + end;\n\t\t}\n\t}\n\tDUK_ASSERT(start >= 0 && (duk_uint32_t) start <= len);\n\tDUK_ASSERT(end >= 0 && (duk_uint32_t) end <= len);\n\n\tidx = 0;\n\tfor (i = start; i < end; i++) {\n\t\tDUK_ASSERT_TOP(ctx, 5);\n\t\tif (duk_get_prop_index(ctx, 2, (duk_uarridx_t) i)) {\n\t\t\tduk_xdef_prop_index_wec(ctx, 4, idx);\n\t\t\tres_length = idx + 1;\n\t\t} else {\n\t\t\tduk_pop(ctx);\n\t\t}\n\t\tidx++;\n\t\tDUK_ASSERT_TOP(ctx, 5);\n\t}\n\n\tduk_push_u32(ctx, res_length);\n\tduk_xdef_prop_stridx_short(ctx, 4, DUK_STRIDX_LENGTH, DUK_PROPDESC_FLAGS_W);\n\n\tDUK_ASSERT_TOP(ctx, 5);\n\treturn 1;\n}\n\n/*\n *  shift()\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_array_prototype_shift(duk_context *ctx) {\n\tduk_uint32_t len;\n\tduk_uint32_t i;\n\n\tlen = duk__push_this_obj_len_u32(ctx);\n\tif (len == 0) {\n\t\tduk_push_int(ctx, 0);\n\t\tduk_put_prop_stridx_short(ctx, 0, DUK_STRIDX_LENGTH);\n\t\treturn 0;\n\t}\n\n\tduk_get_prop_index(ctx, 0, 0);\n\n\t/* stack[0] = object (this)\n\t * stack[1] = ToUint32(length)\n\t * stack[2] = elem at index 0 (retval)\n\t */\n\n\tfor (i = 1; i < len; i++) {\n\t\tDUK_ASSERT_TOP(ctx, 3);\n\t\tif (duk_get_prop_index(ctx, 0, (duk_uarridx_t) i)) {\n\t\t\t/* fromPresent = true */\n\t\t\tduk_put_prop_index(ctx, 0, (duk_uarridx_t) (i - 1));\n\t\t} else {\n\t\t\t/* fromPresent = false */\n\t\t\tduk_del_prop_index(ctx, 0, (duk_uarridx_t) (i - 1));\n\t\t\tduk_pop(ctx);\n\t\t}\n\t}\n\tduk_del_prop_index(ctx, 0, (duk_uarridx_t) (len - 1));\n\n\tduk_push_u32(ctx, (duk_uint32_t) (len - 1));\n\tduk_put_prop_stridx_short(ctx, 0, DUK_STRIDX_LENGTH);\n\n\tDUK_ASSERT_TOP(ctx, 3);\n\treturn 1;\n}\n\n/*\n *  unshift()\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_array_prototype_unshift(duk_context *ctx) {\n\tduk_idx_t nargs;\n\tduk_uint32_t len;\n\tduk_uint32_t i;\n\n\tnargs = duk_get_top(ctx);\n\tlen = duk__push_this_obj_len_u32(ctx);\n\n\t/* stack[0...nargs-1] = unshift args (vararg)\n\t * stack[nargs] = ToObject(this)\n\t * stack[nargs+1] = ToUint32(length)\n\t */\n\n\tDUK_ASSERT_TOP(ctx, nargs + 2);\n\n\t/* Note: unshift() may operate on indices above unsigned 32-bit range\n\t * and the final length may be >= 2**32.  However, we restrict the\n\t * final result to 32-bit range for practicality.\n\t */\n\n\tif (len + (duk_uint32_t) nargs < len) {\n\t\tDUK_D(DUK_DPRINT(\"Array.prototype.unshift() would go beyond 32-bit length, throw\"));\n\t\tDUK_DCERROR_RANGE_INVALID_LENGTH((duk_hthread *) ctx);\n\t}\n\n\ti = len;\n\twhile (i > 0) {\n\t\tDUK_ASSERT_TOP(ctx, nargs + 2);\n\t\ti--;\n\t\t/* k+argCount-1; note that may be above 32-bit range */\n\n\t\tif (duk_get_prop_index(ctx, -2, (duk_uarridx_t) i)) {\n\t\t\t/* fromPresent = true */\n\t\t\t/* [ ... ToObject(this) ToUint32(length) val ] */\n\t\t\tduk_put_prop_index(ctx, -3, (duk_uarridx_t) (i + nargs));  /* -> [ ... ToObject(this) ToUint32(length) ] */\n\t\t} else {\n\t\t\t/* fromPresent = false */\n\t\t\t/* [ ... ToObject(this) ToUint32(length) val ] */\n\t\t\tduk_pop(ctx);\n\t\t\tduk_del_prop_index(ctx, -2, (duk_uarridx_t) (i + nargs));  /* -> [ ... ToObject(this) ToUint32(length) ] */\n\t\t}\n\t\tDUK_ASSERT_TOP(ctx, nargs + 2);\n\t}\n\n\tfor (i = 0; i < (duk_uint32_t) nargs; i++) {\n\t\tDUK_ASSERT_TOP(ctx, nargs + 2);\n\t\tduk_dup(ctx, i);  /* -> [ ... ToObject(this) ToUint32(length) arg[i] ] */\n\t\tduk_put_prop_index(ctx, -3, (duk_uarridx_t) i);\n\t\tDUK_ASSERT_TOP(ctx, nargs + 2);\n\t}\n\n\tDUK_ASSERT_TOP(ctx, nargs + 2);\n\tduk_push_u32(ctx, len + nargs);\n\tduk_dup_top(ctx);  /* -> [ ... ToObject(this) ToUint32(length) final_len final_len ] */\n\tduk_put_prop_stridx_short(ctx, -4, DUK_STRIDX_LENGTH);\n\treturn 1;\n}\n\n/*\n *  indexOf(), lastIndexOf()\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_array_prototype_indexof_shared(duk_context *ctx) {\n\tduk_idx_t nargs;\n\tduk_int_t i, len;\n\tduk_int_t from_idx;\n\tduk_small_int_t idx_step = duk_get_current_magic(ctx);  /* idx_step is +1 for indexOf, -1 for lastIndexOf */\n\n\t/* lastIndexOf() needs to be a vararg function because we must distinguish\n\t * between an undefined fromIndex and a \"not given\" fromIndex; indexOf() is\n\t * made vararg for symmetry although it doesn't strictly need to be.\n\t */\n\n\tnargs = duk_get_top(ctx);\n\tduk_set_top(ctx, 2);\n\n\t/* XXX: must be able to represent -len */\n\tlen = (duk_int_t) duk__push_this_obj_len_u32_limited(ctx);\n\tif (len == 0) {\n\t\tgoto not_found;\n\t}\n\n\t/* Index clamping is a bit tricky, we must ensure that we'll only iterate\n\t * through elements that exist and that the specific requirements from E5.1\n\t * Sections 15.4.4.14 and 15.4.4.15 are fulfilled; especially:\n\t *\n\t *   - indexOf: clamp to [-len,len], negative handling -> [0,len],\n\t *     if clamped result is len, for-loop bails out immediately\n\t *\n\t *   - lastIndexOf: clamp to [-len-1, len-1], negative handling -> [-1, len-1],\n\t *     if clamped result is -1, for-loop bails out immediately\n\t *\n\t * If fromIndex is not given, ToInteger(undefined) = 0, which is correct\n\t * for indexOf() but incorrect for lastIndexOf().  Hence special handling,\n\t * and why lastIndexOf() needs to be a vararg function.\n\t */\n\n\tif (nargs >= 2) {\n\t\t/* indexOf: clamp fromIndex to [-len, len]\n\t\t * (if fromIndex == len, for-loop terminates directly)\n\t\t *\n\t\t * lastIndexOf: clamp fromIndex to [-len - 1, len - 1]\n\t\t * (if clamped to -len-1 -> fromIndex becomes -1, terminates for-loop directly)\n\t\t */\n\t\tfrom_idx = duk_to_int_clamped(ctx,\n\t\t                              1,\n\t\t                              (idx_step > 0 ? -len : -len - 1),\n\t\t                              (idx_step > 0 ? len : len - 1));\n\t\tif (from_idx < 0) {\n\t\t\t/* for lastIndexOf, result may be -1 (mark immediate termination) */\n\t\t\tfrom_idx = len + from_idx;\n\t\t}\n\t} else {\n\t\t/* for indexOf, ToInteger(undefined) would be 0, i.e. correct, but\n\t\t * handle both indexOf and lastIndexOf specially here.\n\t\t */\n\t\tif (idx_step > 0) {\n\t\t\tfrom_idx = 0;\n\t\t} else {\n\t\t\tfrom_idx = len - 1;\n\t\t}\n\t}\n\n\t/* stack[0] = searchElement\n\t * stack[1] = fromIndex\n\t * stack[2] = object\n\t * stack[3] = length (not needed, but not popped above)\n\t */\n\n\tfor (i = from_idx; i >= 0 && i < len; i += idx_step) {\n\t\tDUK_ASSERT_TOP(ctx, 4);\n\n\t\tif (duk_get_prop_index(ctx, 2, (duk_uarridx_t) i)) {\n\t\t\tDUK_ASSERT_TOP(ctx, 5);\n\t\t\tif (duk_strict_equals(ctx, 0, 4)) {\n\t\t\t\tduk_push_int(ctx, i);\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\n\t\tduk_pop(ctx);\n\t}\n\n not_found:\n\tduk_push_int(ctx, -1);\n\treturn 1;\n}\n\n/*\n *  every(), some(), forEach(), map(), filter()\n */\n\n#define DUK__ITER_EVERY    0\n#define DUK__ITER_SOME     1\n#define DUK__ITER_FOREACH  2\n#define DUK__ITER_MAP      3\n#define DUK__ITER_FILTER   4\n\n/* XXX: This helper is a bit awkward because the handling for the different iteration\n * callers is quite different.  This now compiles to a bit less than 500 bytes, so with\n * 5 callers the net result is about 100 bytes / caller.\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_array_prototype_iter_shared(duk_context *ctx) {\n\tduk_uint32_t len;\n\tduk_uint32_t i;\n\tduk_uarridx_t k;\n\tduk_bool_t bval;\n\tduk_small_int_t iter_type = duk_get_current_magic(ctx);\n\tduk_uint32_t res_length = 0;\n\n\t/* each call this helper serves has nargs==2 */\n\tDUK_ASSERT_TOP(ctx, 2);\n\n\tlen = duk__push_this_obj_len_u32(ctx);\n\tduk_require_callable(ctx, 0);\n\t/* if thisArg not supplied, behave as if undefined was supplied */\n\n\tif (iter_type == DUK__ITER_MAP || iter_type == DUK__ITER_FILTER) {\n\t\tduk_push_array(ctx);\n\t} else {\n\t\tduk_push_undefined(ctx);\n\t}\n\n\t/* stack[0] = callback\n\t * stack[1] = thisArg\n\t * stack[2] = object\n\t * stack[3] = ToUint32(length)  (unused, but avoid unnecessary pop)\n\t * stack[4] = result array (or undefined)\n\t */\n\n\tk = 0;  /* result index for filter() */\n\tfor (i = 0; i < len; i++) {\n\t\tDUK_ASSERT_TOP(ctx, 5);\n\n\t\tif (!duk_get_prop_index(ctx, 2, (duk_uarridx_t) i)) {\n#if defined(DUK_USE_NONSTD_ARRAY_MAP_TRAILER)\n\t\t\t/* Real world behavior for map(): trailing non-existent\n\t\t\t * elements don't invoke the user callback, but are still\n\t\t\t * counted towards result 'length'.\n\t\t\t */\n\t\t\tif (iter_type == DUK__ITER_MAP) {\n\t\t\t\tres_length = i + 1;\n\t\t\t}\n#else\n\t\t\t/* Standard behavior for map(): trailing non-existent\n\t\t\t * elements don't invoke the user callback and are not\n\t\t\t * counted towards result 'length'.\n\t\t\t */\n#endif\n\t\t\tduk_pop(ctx);\n\t\t\tcontinue;\n\t\t}\n\n\t\t/* The original value needs to be preserved for filter(), hence\n\t\t * this funny order.  We can't re-get the value because of side\n\t\t * effects.\n\t\t */\n\n\t\tduk_dup_0(ctx);\n\t\tduk_dup_1(ctx);\n\t\tduk_dup_m3(ctx);\n\t\tduk_push_u32(ctx, i);\n\t\tduk_dup_2(ctx);  /* [ ... val callback thisArg val i obj ] */\n\t\tduk_call_method(ctx, 3); /* -> [ ... val retval ] */\n\n\t\tswitch (iter_type) {\n\t\tcase DUK__ITER_EVERY:\n\t\t\tbval = duk_to_boolean(ctx, -1);\n\t\t\tif (!bval) {\n\t\t\t\t/* stack top contains 'false' */\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase DUK__ITER_SOME:\n\t\t\tbval = duk_to_boolean(ctx, -1);\n\t\t\tif (bval) {\n\t\t\t\t/* stack top contains 'true' */\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase DUK__ITER_FOREACH:\n\t\t\t/* nop */\n\t\t\tbreak;\n\t\tcase DUK__ITER_MAP:\n\t\t\tduk_dup_top(ctx);\n\t\t\tduk_xdef_prop_index_wec(ctx, 4, (duk_uarridx_t) i);  /* retval to result[i] */\n\t\t\tres_length = i + 1;\n\t\t\tbreak;\n\t\tcase DUK__ITER_FILTER:\n\t\t\tbval = duk_to_boolean(ctx, -1);\n\t\t\tif (bval) {\n\t\t\t\tduk_dup_m2(ctx);  /* orig value */\n\t\t\t\tduk_xdef_prop_index_wec(ctx, 4, (duk_uarridx_t) k);\n\t\t\t\tk++;\n\t\t\t\tres_length = k;\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tDUK_UNREACHABLE();\n\t\t\tbreak;\n\t\t}\n\t\tduk_pop_2(ctx);\n\n\t\tDUK_ASSERT_TOP(ctx, 5);\n\t}\n\n\tswitch (iter_type) {\n\tcase DUK__ITER_EVERY:\n\t\tduk_push_true(ctx);\n\t\tbreak;\n\tcase DUK__ITER_SOME:\n\t\tduk_push_false(ctx);\n\t\tbreak;\n\tcase DUK__ITER_FOREACH:\n\t\tduk_push_undefined(ctx);\n\t\tbreak;\n\tcase DUK__ITER_MAP:\n\tcase DUK__ITER_FILTER:\n\t\tDUK_ASSERT_TOP(ctx, 5);\n\t\tDUK_ASSERT(duk_is_array(ctx, -1));  /* topmost element is the result array already */\n\t\tduk_push_u32(ctx, res_length);\n\t\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_LENGTH, DUK_PROPDESC_FLAGS_W);\n\t\tbreak;\n\tdefault:\n\t\tDUK_UNREACHABLE();\n\t\tbreak;\n\t}\n\n\treturn 1;\n}\n\n/*\n *  reduce(), reduceRight()\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_array_prototype_reduce_shared(duk_context *ctx) {\n\tduk_idx_t nargs;\n\tduk_bool_t have_acc;\n\tduk_uint32_t i, len;\n\tduk_small_int_t idx_step = duk_get_current_magic(ctx);  /* idx_step is +1 for reduce, -1 for reduceRight */\n\n\t/* We're a varargs function because we need to detect whether\n\t * initialValue was given or not.\n\t */\n\tnargs = duk_get_top(ctx);\n\tDUK_DDD(DUK_DDDPRINT(\"nargs=%ld\", (long) nargs));\n\n\tduk_set_top(ctx, 2);\n\tlen = duk__push_this_obj_len_u32(ctx);\n\tduk_require_callable(ctx, 0);\n\n\t/* stack[0] = callback fn\n\t * stack[1] = initialValue\n\t * stack[2] = object (coerced this)\n\t * stack[3] = length (not needed, but not popped above)\n\t * stack[4] = accumulator\n\t */\n\n\thave_acc = 0;\n\tif (nargs >= 2) {\n\t\tduk_dup_1(ctx);\n\t\thave_acc = 1;\n\t}\n\tDUK_DDD(DUK_DDDPRINT(\"have_acc=%ld, acc=%!T\",\n\t                     (long) have_acc, (duk_tval *) duk_get_tval(ctx, 3)));\n\n\t/* For len == 0, i is initialized to len - 1 which underflows.\n\t * The condition (i < len) will then exit the for-loop on the\n\t * first round which is correct.  Similarly, loop termination\n\t * happens by i underflowing.\n\t */\n\n\tfor (i = (idx_step >= 0 ? 0 : len - 1);\n\t     i < len;  /* i >= 0 would always be true */\n\t     i += idx_step) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"i=%ld, len=%ld, have_acc=%ld, top=%ld, acc=%!T\",\n\t\t                     (long) i, (long) len, (long) have_acc,\n\t\t                     (long) duk_get_top(ctx),\n\t\t                     (duk_tval *) duk_get_tval(ctx, 4)));\n\n\t\tDUK_ASSERT((have_acc && duk_get_top(ctx) == 5) ||\n\t\t           (!have_acc && duk_get_top(ctx) == 4));\n\n\t\tif (!duk_has_prop_index(ctx, 2, (duk_uarridx_t) i)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!have_acc) {\n\t\t\tDUK_ASSERT_TOP(ctx, 4);\n\t\t\tduk_get_prop_index(ctx, 2, (duk_uarridx_t) i);\n\t\t\thave_acc = 1;\n\t\t\tDUK_ASSERT_TOP(ctx, 5);\n\t\t} else {\n\t\t\tDUK_ASSERT_TOP(ctx, 5);\n\t\t\tduk_dup_0(ctx);\n\t\t\tduk_dup(ctx, 4);\n\t\t\tduk_get_prop_index(ctx, 2, (duk_uarridx_t) i);\n\t\t\tduk_push_u32(ctx, i);\n\t\t\tduk_dup_2(ctx);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"calling reduce function: func=%!T, prev=%!T, curr=%!T, idx=%!T, obj=%!T\",\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, -5), (duk_tval *) duk_get_tval(ctx, -4),\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, -3), (duk_tval *) duk_get_tval(ctx, -2),\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\t\t\tduk_call(ctx, 4);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> result: %!T\", (duk_tval *) duk_get_tval(ctx, -1)));\n\t\t\tduk_replace(ctx, 4);\n\t\t\tDUK_ASSERT_TOP(ctx, 5);\n\t\t}\n\t}\n\n\tif (!have_acc) {\n\t\tDUK_DCERROR_TYPE_INVALID_ARGS((duk_hthread *) ctx);\n\t}\n\n\tDUK_ASSERT_TOP(ctx, 5);\n\treturn 1;\n}\n\n#endif  /* DUK_USE_ARRAY_BUILTIN */\n\n/* automatic undefs */\n#undef DUK__ARRAY_MID_JOIN_LIMIT\n#undef DUK__ITER_EVERY\n#undef DUK__ITER_FILTER\n#undef DUK__ITER_FOREACH\n#undef DUK__ITER_MAP\n#undef DUK__ITER_SOME\n/*\n *  Boolean built-ins\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_BOOLEAN_BUILTIN)\n\n/* Shared helper to provide toString() and valueOf().  Checks 'this', gets\n * the primitive value to stack top, and optionally coerces with ToString().\n */\nDUK_INTERNAL duk_ret_t duk_bi_boolean_prototype_tostring_shared(duk_context *ctx) {\n\tduk_tval *tv;\n\tduk_hobject *h;\n\tduk_small_int_t coerce_tostring = duk_get_current_magic(ctx);\n\n\t/* XXX: there is room to use a shared helper here, many built-ins\n\t * check the 'this' type, and if it's an object, check its class,\n\t * then get its internal value, etc.\n\t */\n\n\tduk_push_this(ctx);\n\ttv = duk_get_tval(ctx, -1);\n\tDUK_ASSERT(tv != NULL);\n\n\tif (DUK_TVAL_IS_BOOLEAN(tv)) {\n\t\tgoto type_ok;\n\t} else if (DUK_TVAL_IS_OBJECT(tv)) {\n\t\th = DUK_TVAL_GET_OBJECT(tv);\n\t\tDUK_ASSERT(h != NULL);\n\n\t\tif (DUK_HOBJECT_GET_CLASS_NUMBER(h) == DUK_HOBJECT_CLASS_BOOLEAN) {\n\t\t\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_INT_VALUE);\n\t\t\tDUK_ASSERT(duk_is_boolean(ctx, -1));\n\t\t\tgoto type_ok;\n\t\t}\n\t}\n\n\tDUK_DCERROR_TYPE_INVALID_ARGS((duk_hthread *) ctx);\n\t/* never here */\n\n type_ok:\n\tif (coerce_tostring) {\n\t\tduk_to_string(ctx, -1);\n\t}\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_boolean_constructor(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *h_this;\n\n\tDUK_UNREF(thr);\n\n\tduk_to_boolean(ctx, 0);\n\n\tif (duk_is_constructor_call(ctx)) {\n\t\t/* XXX: helper; rely on Boolean.prototype as being non-writable, non-configurable */\n\t\tduk_push_this(ctx);\n\t\th_this = duk_known_hobject(ctx, -1);\n\t\tDUK_ASSERT(DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h_this) == thr->builtins[DUK_BIDX_BOOLEAN_PROTOTYPE]);\n\n\t\tDUK_HOBJECT_SET_CLASS_NUMBER(h_this, DUK_HOBJECT_CLASS_BOOLEAN);\n\n\t\tduk_dup_0(ctx);  /* -> [ val obj val ] */\n\t\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_VALUE, DUK_PROPDESC_FLAGS_NONE);  /* XXX: proper flags? */\n\t}  /* unbalanced stack */\n\n\treturn 1;\n}\n\n#endif  /* DUK_USE_BOOLEAN_BUILTIN */\n/*\n *  ES2015 TypedArray and Node.js Buffer built-ins\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Helpers for buffer handling, enabled with DUK_USE_BUFFEROBJECT_SUPPORT.\n */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n/* Map class number (minus DUK_HOBJECT_CLASS_BUFOBJ_MIN) to a bidx for the\n * default internal prototype.\n */\nstatic const duk_uint8_t duk__buffer_proto_from_classnum[] = {\n\tDUK_BIDX_ARRAYBUFFER_PROTOTYPE,\n\tDUK_BIDX_DATAVIEW_PROTOTYPE,\n\tDUK_BIDX_INT8ARRAY_PROTOTYPE,\n\tDUK_BIDX_UINT8ARRAY_PROTOTYPE,\n\tDUK_BIDX_UINT8CLAMPEDARRAY_PROTOTYPE,\n\tDUK_BIDX_INT16ARRAY_PROTOTYPE,\n\tDUK_BIDX_UINT16ARRAY_PROTOTYPE,\n\tDUK_BIDX_INT32ARRAY_PROTOTYPE,\n\tDUK_BIDX_UINT32ARRAY_PROTOTYPE,\n\tDUK_BIDX_FLOAT32ARRAY_PROTOTYPE,\n\tDUK_BIDX_FLOAT64ARRAY_PROTOTYPE\n};\n\n/* Map DUK_HBUFOBJ_ELEM_xxx to duk_hobject class number.\n * Sync with duk_hbufobj.h and duk_hobject.h.\n */\nstatic const duk_uint8_t duk__buffer_class_from_elemtype[9] = {\n\tDUK_HOBJECT_CLASS_UINT8ARRAY,\n\tDUK_HOBJECT_CLASS_UINT8CLAMPEDARRAY,\n\tDUK_HOBJECT_CLASS_INT8ARRAY,\n\tDUK_HOBJECT_CLASS_UINT16ARRAY,\n\tDUK_HOBJECT_CLASS_INT16ARRAY,\n\tDUK_HOBJECT_CLASS_UINT32ARRAY,\n\tDUK_HOBJECT_CLASS_INT32ARRAY,\n\tDUK_HOBJECT_CLASS_FLOAT32ARRAY,\n\tDUK_HOBJECT_CLASS_FLOAT64ARRAY\n};\n\n/* Map DUK_HBUFOBJ_ELEM_xxx to prototype object built-in index.\n * Sync with duk_hbufobj.h.\n */\nstatic const duk_uint8_t duk__buffer_proto_from_elemtype[9] = {\n\tDUK_BIDX_UINT8ARRAY_PROTOTYPE,\n\tDUK_BIDX_UINT8CLAMPEDARRAY_PROTOTYPE,\n\tDUK_BIDX_INT8ARRAY_PROTOTYPE,\n\tDUK_BIDX_UINT16ARRAY_PROTOTYPE,\n\tDUK_BIDX_INT16ARRAY_PROTOTYPE,\n\tDUK_BIDX_UINT32ARRAY_PROTOTYPE,\n\tDUK_BIDX_INT32ARRAY_PROTOTYPE,\n\tDUK_BIDX_FLOAT32ARRAY_PROTOTYPE,\n\tDUK_BIDX_FLOAT64ARRAY_PROTOTYPE\n};\n\n/* Map DUK__FLD_xxx to byte size. */\nstatic const duk_uint8_t duk__buffer_nbytes_from_fldtype[6] = {\n\t1,  /* DUK__FLD_8BIT */\n\t2,  /* DUK__FLD_16BIT */\n\t4,  /* DUK__FLD_32BIT */\n\t4,  /* DUK__FLD_FLOAT */\n\t8,  /* DUK__FLD_DOUBLE */\n\t0   /* DUK__FLD_VARINT; not relevant here */\n};\n\n/* Bitfield for each DUK_HBUFOBJ_ELEM_xxx indicating which element types\n * are compatible with a blind byte copy for the TypedArray set() method (also\n * used for TypedArray constructor).  Array index is target buffer elem type,\n * bitfield indicates compatible source types.  The types must have same byte\n * size and they must be coercion compatible.\n */\n#if !defined(DUK_USE_PREFER_SIZE)\nstatic duk_uint16_t duk__buffer_elemtype_copy_compatible[9] = {\n\t/* xxx -> DUK_HBUFOBJ_ELEM_UINT8 */\n\t(1U << DUK_HBUFOBJ_ELEM_UINT8) |\n\t\t(1U << DUK_HBUFOBJ_ELEM_UINT8CLAMPED) |\n\t\t(1U << DUK_HBUFOBJ_ELEM_INT8),\n\n\t/* xxx -> DUK_HBUFOBJ_ELEM_UINT8CLAMPED\n\t * Note: INT8 is -not- copy compatible, e.g. -1 would coerce to 0x00.\n\t */\n\t(1U << DUK_HBUFOBJ_ELEM_UINT8) |\n\t\t(1U << DUK_HBUFOBJ_ELEM_UINT8CLAMPED),\n\n\t/* xxx -> DUK_HBUFOBJ_ELEM_INT8 */\n\t(1U << DUK_HBUFOBJ_ELEM_UINT8) |\n\t\t(1U << DUK_HBUFOBJ_ELEM_UINT8CLAMPED) |\n\t\t(1U << DUK_HBUFOBJ_ELEM_INT8),\n\n\t/* xxx -> DUK_HBUFOBJ_ELEM_UINT16 */\n\t(1U << DUK_HBUFOBJ_ELEM_UINT16) |\n\t\t(1U << DUK_HBUFOBJ_ELEM_INT16),\n\n\t/* xxx -> DUK_HBUFOBJ_ELEM_INT16 */\n\t(1U << DUK_HBUFOBJ_ELEM_UINT16) |\n\t\t(1U << DUK_HBUFOBJ_ELEM_INT16),\n\n\t/* xxx -> DUK_HBUFOBJ_ELEM_UINT32 */\n\t(1U << DUK_HBUFOBJ_ELEM_UINT32) |\n\t\t(1U << DUK_HBUFOBJ_ELEM_INT32),\n\n\t/* xxx -> DUK_HBUFOBJ_ELEM_INT32 */\n\t(1U << DUK_HBUFOBJ_ELEM_UINT32) |\n\t\t(1U << DUK_HBUFOBJ_ELEM_INT32),\n\n\t/* xxx -> DUK_HBUFOBJ_ELEM_FLOAT32 */\n\t(1U << DUK_HBUFOBJ_ELEM_FLOAT32),\n\n\t/* xxx -> DUK_HBUFOBJ_ELEM_FLOAT64 */\n\t(1U << DUK_HBUFOBJ_ELEM_FLOAT64)\n};\n#endif  /* !DUK_USE_PREFER_SIZE */\n\nDUK_LOCAL duk_hbufobj *duk__hbufobj_promote_this(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_tval *tv_dst;\n\tduk_hbufobj *res;\n\n\tthr = (duk_hthread *) ctx;\n\tduk_push_this(ctx);\n\tDUK_ASSERT(duk_is_buffer(ctx, -1));\n\tres = (duk_hbufobj *) duk_to_hobject(ctx, -1);\n\tDUK_ASSERT_HBUFOBJ_VALID(res);\n\tDUK_DD(DUK_DDPRINT(\"promoted 'this' automatically to an ArrayBuffer: %!iT\", duk_get_tval(ctx, -1)));\n\n\ttv_dst = duk_get_borrowed_this_tval(ctx);\n\tDUK_TVAL_SET_OBJECT_UPDREF(thr, tv_dst, (duk_hobject *) res);\n\tduk_pop(ctx);\n\n\treturn res;\n}\n\n#define DUK__BUFOBJ_FLAG_THROW    (1 << 0)\n#define DUK__BUFOBJ_FLAG_PROMOTE  (1 << 1)\n\n/* Shared helper.  When DUK__BUFOBJ_FLAG_PROMOTE is given, the return value is\n * always a duk_hbufobj *.  Without the flag the return value can also be a\n * plain buffer, and the caller must check for it using DUK_HEAPHDR_IS_BUFFER().\n */\nDUK_LOCAL duk_heaphdr *duk__getrequire_bufobj_this(duk_context *ctx, duk_small_uint_t flags) {\n\tduk_hthread *thr;\n\tduk_tval *tv;\n\tduk_hbufobj *h_this;\n\n\tDUK_ASSERT(ctx != NULL);\n\tthr = (duk_hthread *) ctx;\n\n\ttv = duk_get_borrowed_this_tval(ctx);\n\tDUK_ASSERT(tv != NULL);\n\n\tif (DUK_TVAL_IS_OBJECT(tv)) {\n\t\th_this = (duk_hbufobj *) DUK_TVAL_GET_OBJECT(tv);\n\t\tDUK_ASSERT(h_this != NULL);\n\t\tif (DUK_HOBJECT_IS_BUFOBJ((duk_hobject *) h_this)) {\n\t\t\tDUK_ASSERT_HBUFOBJ_VALID(h_this);\n\t\t\treturn (duk_heaphdr *) h_this;\n\t\t}\n\t} else if (DUK_TVAL_IS_BUFFER(tv)) {\n\t\tif (flags & DUK__BUFOBJ_FLAG_PROMOTE) {\n\t\t\t/* Promote a plain buffer to a Uint8Array.  This is very\n\t\t\t * inefficient but allows plain buffer to be used wherever an\n\t\t\t * Uint8Array is used with very small cost; hot path functions\n\t\t\t * like index read/write calls should provide direct buffer\n\t\t\t * support to avoid promotion.\n\t\t\t */\n\t\t\t/* XXX: make this conditional to a flag if call sites need it? */\n\t\t\th_this = duk__hbufobj_promote_this(ctx);\n\t\t\tDUK_ASSERT(h_this != NULL);\n\t\t\tDUK_ASSERT_HBUFOBJ_VALID(h_this);\n\t\t\treturn (duk_heaphdr *) h_this;\n\t\t} else {\n\t\t\t/* XXX: ugly, share return pointer for duk_hbuffer. */\n\t\t\treturn (duk_heaphdr *) DUK_TVAL_GET_BUFFER(tv);\n\t\t}\n\t}\n\n\tif (flags & DUK__BUFOBJ_FLAG_THROW) {\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_NOT_BUFFER);\n\t}\n\treturn NULL;\n}\n\n/* Check that 'this' is a duk_hbufobj and return a pointer to it. */\nDUK_LOCAL duk_hbufobj *duk__get_bufobj_this(duk_context *ctx) {\n\treturn (duk_hbufobj *) duk__getrequire_bufobj_this(ctx, DUK__BUFOBJ_FLAG_PROMOTE);\n}\n\n/* Check that 'this' is a duk_hbufobj and return a pointer to it\n * (NULL if not).\n */\nDUK_LOCAL duk_hbufobj *duk__require_bufobj_this(duk_context *ctx) {\n\treturn (duk_hbufobj *) duk__getrequire_bufobj_this(ctx, DUK__BUFOBJ_FLAG_THROW | DUK__BUFOBJ_FLAG_PROMOTE);\n}\n\n/* Check that value is a duk_hbufobj and return a pointer to it. */\nDUK_LOCAL duk_hbufobj *duk__require_bufobj_value(duk_context *ctx, duk_idx_t idx) {\n\tduk_hthread *thr;\n\tduk_tval *tv;\n\tduk_hbufobj *h_obj;\n\n\tthr = (duk_hthread *) ctx;\n\n\t/* Don't accept relative indices now. */\n\tDUK_ASSERT(idx >= 0);\n\n\ttv = duk_require_tval(ctx, idx);\n\tDUK_ASSERT(tv != NULL);\n\tif (DUK_TVAL_IS_OBJECT(tv)) {\n\t\th_obj = (duk_hbufobj *) DUK_TVAL_GET_OBJECT(tv);\n\t\tDUK_ASSERT(h_obj != NULL);\n\t\tif (DUK_HOBJECT_IS_BUFOBJ((duk_hobject *) h_obj)) {\n\t\t\tDUK_ASSERT_HBUFOBJ_VALID(h_obj);\n\t\t\treturn h_obj;\n\t\t}\n\t} else if (DUK_TVAL_IS_BUFFER(tv)) {\n\t\th_obj = (duk_hbufobj *) duk_to_hobject(ctx, idx);\n\t\tDUK_ASSERT(h_obj != NULL);\n\t\tDUK_ASSERT_HBUFOBJ_VALID(h_obj);\n\t\treturn h_obj;\n\t}\n\n\tDUK_ERROR_TYPE(thr, DUK_STR_NOT_BUFFER);\n\treturn NULL;  /* not reachable */\n}\n\nDUK_LOCAL void duk__set_bufobj_buffer(duk_context *ctx, duk_hbufobj *h_bufobj, duk_hbuffer *h_val) {\n\tduk_hthread *thr;\n\n\tthr = (duk_hthread *) ctx;\n\tDUK_UNREF(thr);\n\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(h_bufobj != NULL);\n\tDUK_ASSERT(h_bufobj->buf == NULL);  /* no need to decref */\n\tDUK_ASSERT(h_val != NULL);\n\tDUK_ASSERT_HBUFOBJ_VALID(h_bufobj);\n\n\th_bufobj->buf = h_val;\n\tDUK_HBUFFER_INCREF(thr, h_val);\n\th_bufobj->length = (duk_uint_t) DUK_HBUFFER_GET_SIZE(h_val);\n\tDUK_ASSERT(h_bufobj->shift == 0);\n\tDUK_ASSERT(h_bufobj->elem_type == DUK_HBUFOBJ_ELEM_UINT8);\n\tDUK_ASSERT(h_bufobj->is_typedarray == 0);\n\n\tDUK_ASSERT_HBUFOBJ_VALID(h_bufobj);\n}\n\n/* Shared offset/length coercion helper. */\nDUK_LOCAL void duk__resolve_offset_opt_length(duk_context *ctx,\n                                              duk_hbufobj *h_bufarg,\n                                              duk_idx_t idx_offset,\n                                              duk_idx_t idx_length,\n                                              duk_uint_t *out_offset,\n                                              duk_uint_t *out_length,\n                                              duk_bool_t throw_flag) {\n\tduk_hthread *thr;\n\tduk_int_t offset_signed;\n\tduk_int_t length_signed;\n\tduk_uint_t offset;\n\tduk_uint_t length;\n\n\tthr = (duk_hthread *) ctx;\n\tDUK_UNREF(thr);\n\n\toffset_signed = duk_to_int(ctx, idx_offset);\n\tif (offset_signed < 0) {\n\t\tgoto fail_range;\n\t}\n\toffset = (duk_uint_t) offset_signed;\n\tif (offset > h_bufarg->length) {\n\t\tgoto fail_range;\n\t}\n\tDUK_ASSERT_DISABLE(offset >= 0);  /* unsigned */\n\tDUK_ASSERT(offset <= h_bufarg->length);\n\n\tif (duk_is_undefined(ctx, idx_length)) {\n\t\tDUK_ASSERT(h_bufarg->length >= offset);\n\t\tlength = h_bufarg->length - offset;  /* >= 0 */\n\t} else {\n\t\tlength_signed = duk_to_int(ctx, idx_length);\n\t\tif (length_signed < 0) {\n\t\t\tgoto fail_range;\n\t\t}\n\t\tlength = (duk_uint_t) length_signed;\n\t\tDUK_ASSERT(h_bufarg->length >= offset);\n\t\tif (length > h_bufarg->length - offset) {\n\t\t\t/* Unlike for negative arguments, some call sites\n\t\t\t * want length to be clamped if it's positive.\n\t\t\t */\n\t\t\tif (throw_flag) {\n\t\t\t\tgoto fail_range;\n\t\t\t} else {\n\t\t\t\tlength = h_bufarg->length - offset;\n\t\t\t}\n\t\t}\n\t}\n\tDUK_ASSERT_DISABLE(length >= 0);  /* unsigned */\n\tDUK_ASSERT(offset + length <= h_bufarg->length);\n\n\t*out_offset = offset;\n\t*out_length = length;\n\treturn;\n\n fail_range:\n\tDUK_ERROR_RANGE(thr, DUK_STR_INVALID_ARGS);\n}\n\n/* Shared lenient buffer length clamping helper.  No negative indices, no\n * element/byte shifting.\n */\nDUK_LOCAL void duk__clamp_startend_nonegidx_noshift(duk_context *ctx,\n                                                    duk_int_t buffer_length,\n                                                    duk_idx_t idx_start,\n                                                    duk_idx_t idx_end,\n                                                    duk_int_t *out_start_offset,\n                                                    duk_int_t *out_end_offset) {\n\tduk_int_t start_offset;\n\tduk_int_t end_offset;\n\n\tDUK_ASSERT(out_start_offset != NULL);\n\tDUK_ASSERT(out_end_offset != NULL);\n\n\t/* undefined coerces to zero which is correct */\n\tstart_offset = duk_to_int_clamped(ctx, idx_start, 0, buffer_length);\n\tif (duk_is_undefined(ctx, idx_end)) {\n\t\tend_offset = buffer_length;\n\t} else {\n\t\tend_offset = duk_to_int_clamped(ctx, idx_end, start_offset, buffer_length);\n\t}\n\n\tDUK_ASSERT(start_offset >= 0);\n\tDUK_ASSERT(start_offset <= buffer_length);\n\tDUK_ASSERT(end_offset >= 0);\n\tDUK_ASSERT(end_offset <= buffer_length);\n\tDUK_ASSERT(start_offset <= end_offset);\n\n\t*out_start_offset = start_offset;\n\t*out_end_offset = end_offset;\n}\n\n/* Shared lenient buffer length clamping helper.  Indices are treated as\n * element indices (though output values are byte offsets) which only\n * really matters for TypedArray views as other buffer object have a zero\n * shift.  Negative indices are counted from end of input slice; crossed\n * indices are clamped to zero length; and final indices are clamped\n * against input slice.  Used for e.g. ArrayBuffer slice().\n */\nDUK_LOCAL void duk__clamp_startend_negidx_shifted(duk_context *ctx,\n                                                  duk_int_t buffer_length,\n                                                  duk_uint8_t buffer_shift,\n                                                  duk_idx_t idx_start,\n                                                  duk_idx_t idx_end,\n                                                  duk_int_t *out_start_offset,\n                                                  duk_int_t *out_end_offset) {\n\tduk_int_t start_offset;\n\tduk_int_t end_offset;\n\n\tDUK_ASSERT(out_start_offset != NULL);\n\tDUK_ASSERT(out_end_offset != NULL);\n\n\tbuffer_length >>= buffer_shift;  /* as (full) elements */\n\n\t/* Resolve start/end offset as element indices first; arguments\n\t * at idx_start/idx_end are element offsets.  Working with element\n\t * indices first also avoids potential for wrapping.\n\t */\n\n\tstart_offset = duk_to_int(ctx, idx_start);\n\tif (start_offset < 0) {\n\t\tstart_offset = buffer_length + start_offset;\n\t}\n\tif (duk_is_undefined(ctx, idx_end)) {\n\t\tend_offset = buffer_length;\n\t} else {\n\t\tend_offset = duk_to_int(ctx, idx_end);\n\t\tif (end_offset < 0) {\n\t\t\tend_offset = buffer_length + end_offset;\n\t\t}\n\t}\n\t/* Note: start_offset/end_offset can still be < 0 here. */\n\n\tif (start_offset < 0) {\n\t\tstart_offset = 0;\n\t} else if (start_offset > buffer_length) {\n\t\tstart_offset = buffer_length;\n\t}\n\tif (end_offset < start_offset) {\n\t\tend_offset = start_offset;\n\t} else if (end_offset > buffer_length) {\n\t\tend_offset = buffer_length;\n\t}\n\tDUK_ASSERT(start_offset >= 0);\n\tDUK_ASSERT(start_offset <= buffer_length);\n\tDUK_ASSERT(end_offset >= 0);\n\tDUK_ASSERT(end_offset <= buffer_length);\n\tDUK_ASSERT(start_offset <= end_offset);\n\n\t/* Convert indices to byte offsets. */\n\tstart_offset <<= buffer_shift;\n\tend_offset <<= buffer_shift;\n\n\t*out_start_offset = start_offset;\n\t*out_end_offset = end_offset;\n}\n\nDUK_INTERNAL void duk_hbufobj_promote_plain(duk_context *ctx, duk_idx_t idx) {\n\tif (duk_is_buffer(ctx, idx)) {\n\t\tduk_to_object(ctx, idx);\n\t}\n}\n\nDUK_INTERNAL void duk_hbufobj_push_uint8array_from_plain(duk_hthread *thr, duk_hbuffer *h_buf) {\n\tduk_context *ctx;\n\n\tctx = (duk_context *) thr;\n\n\t/* Push Uint8Array which will share the same underlying buffer as\n\t * the plain buffer argument.  Also create an ArrayBuffer with the\n\t * same backing for the result .buffer property.\n\t */\n\n\tduk_push_hbuffer(ctx, h_buf);\n\tduk_push_buffer_object(ctx, -1, 0, (duk_size_t) DUK_HBUFFER_GET_SIZE(h_buf), DUK_BUFOBJ_UINT8ARRAY);\n\tduk_remove_m2(ctx);\n\n#if 0\n\t/* More verbose equivalent; maybe useful if e.g. .buffer is omitted. */\n\th_bufobj = duk_push_bufobj_raw(ctx,\n\t                               DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                               DUK_HOBJECT_FLAG_BUFOBJ |\n\t                               DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_UINT8ARRAY),\n\t                               DUK_BIDX_UINT8ARRAY_PROTOTYPE);\n\tDUK_ASSERT(h_bufobj != NULL);\n\tduk__set_bufobj_buffer(ctx, h_bufobj, h_buf);\n\th_bufobj->is_typedarray = 1;\n\tDUK_ASSERT_HBUFOBJ_VALID(h_bufobj);\n\n\th_arrbuf = duk_push_bufobj_raw(ctx,\n\t                               DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                               DUK_HOBJECT_FLAG_BUFOBJ |\n\t                               DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_ARRAYBUFFER),\n\t                               DUK_BIDX_ARRAYBUFFER_PROTOTYPE);\n\tDUK_ASSERT(h_arrbuf != NULL);\n\tduk__set_bufobj_buffer(ctx, h_arrbuf, h_buf);\n\tDUK_ASSERT(h_arrbuf->is_typedarray == 0);\n\tDUK_ASSERT_HBUFOBJ_VALID(h_arrbuf);\n\n\tDUK_ASSERT(h_bufobj->buf_prop == NULL);\n\th_bufobj->buf_prop = (duk_hobject *) h_arrbuf;\n\tDUK_ASSERT(h_arrbuf != NULL);\n\tDUK_HBUFOBJ_INCREF(thr, h_arrbuf);\n\tduk_pop(ctx);\n#endif\n}\n\n/* Indexed read helper for buffer objects, also called from outside this file. */\nDUK_INTERNAL void duk_hbufobj_push_validated_read(duk_context *ctx, duk_hbufobj *h_bufobj, duk_uint8_t *p, duk_small_uint_t elem_size) {\n\tduk_double_union du;\n\n\tDUK_MEMCPY((void *) du.uc, (const void *) p, (size_t) elem_size);\n\n\tswitch (h_bufobj->elem_type) {\n\tcase DUK_HBUFOBJ_ELEM_UINT8:\n\tcase DUK_HBUFOBJ_ELEM_UINT8CLAMPED:\n\t\tduk_push_uint(ctx, (duk_uint_t) du.uc[0]);\n\t\tbreak;\n\tcase DUK_HBUFOBJ_ELEM_INT8:\n\t\tduk_push_int(ctx, (duk_int_t) (duk_int8_t) du.uc[0]);\n\t\tbreak;\n\tcase DUK_HBUFOBJ_ELEM_UINT16:\n\t\tduk_push_uint(ctx, (duk_uint_t) du.us[0]);\n\t\tbreak;\n\tcase DUK_HBUFOBJ_ELEM_INT16:\n\t\tduk_push_int(ctx, (duk_int_t) (duk_int16_t) du.us[0]);\n\t\tbreak;\n\tcase DUK_HBUFOBJ_ELEM_UINT32:\n\t\tduk_push_uint(ctx, (duk_uint_t) du.ui[0]);\n\t\tbreak;\n\tcase DUK_HBUFOBJ_ELEM_INT32:\n\t\tduk_push_int(ctx, (duk_int_t) (duk_int32_t) du.ui[0]);\n\t\tbreak;\n\tcase DUK_HBUFOBJ_ELEM_FLOAT32:\n\t\tduk_push_number(ctx, (duk_double_t) du.f[0]);\n\t\tbreak;\n\tcase DUK_HBUFOBJ_ELEM_FLOAT64:\n\t\tduk_push_number(ctx, (duk_double_t) du.d);\n\t\tbreak;\n\tdefault:\n\t\tDUK_UNREACHABLE();\n\t}\n}\n\n/* Indexed write helper for buffer objects, also called from outside this file. */\nDUK_INTERNAL void duk_hbufobj_validated_write(duk_context *ctx, duk_hbufobj *h_bufobj, duk_uint8_t *p, duk_small_uint_t elem_size) {\n\tduk_double_union du;\n\n\t/* NOTE! Caller must ensure that any side effects from the\n\t * coercions below are safe.  If that cannot be guaranteed\n\t * (which is normally the case), caller must coerce the\n\t * argument using duk_to_number() before any pointer\n\t * validations; the result of duk_to_number() always coerces\n\t * without side effects here.\n\t */\n\n\tswitch (h_bufobj->elem_type) {\n\tcase DUK_HBUFOBJ_ELEM_UINT8:\n\t\tdu.uc[0] = (duk_uint8_t) duk_to_uint32(ctx, -1);\n\t\tbreak;\n\tcase DUK_HBUFOBJ_ELEM_UINT8CLAMPED:\n\t\tdu.uc[0] = (duk_uint8_t) duk_to_uint8clamped(ctx, -1);\n\t\tbreak;\n\tcase DUK_HBUFOBJ_ELEM_INT8:\n\t\tdu.uc[0] = (duk_uint8_t) duk_to_int32(ctx, -1);\n\t\tbreak;\n\tcase DUK_HBUFOBJ_ELEM_UINT16:\n\t\tdu.us[0] = (duk_uint16_t) duk_to_uint32(ctx, -1);\n\t\tbreak;\n\tcase DUK_HBUFOBJ_ELEM_INT16:\n\t\tdu.us[0] = (duk_uint16_t) duk_to_int32(ctx, -1);\n\t\tbreak;\n\tcase DUK_HBUFOBJ_ELEM_UINT32:\n\t\tdu.ui[0] = (duk_uint32_t) duk_to_uint32(ctx, -1);\n\t\tbreak;\n\tcase DUK_HBUFOBJ_ELEM_INT32:\n\t\tdu.ui[0] = (duk_uint32_t) duk_to_int32(ctx, -1);\n\t\tbreak;\n\tcase DUK_HBUFOBJ_ELEM_FLOAT32:\n\t\tdu.f[0] = (duk_float_t) duk_to_number_m1(ctx);\n\t\tbreak;\n\tcase DUK_HBUFOBJ_ELEM_FLOAT64:\n\t\tdu.d = (duk_double_t) duk_to_number_m1(ctx);\n\t\tbreak;\n\tdefault:\n\t\tDUK_UNREACHABLE();\n\t}\n\n\tDUK_MEMCPY((void *) p, (const void *) du.uc, (size_t) elem_size);\n}\n\n/* Helper to create a fixed buffer from argument value at index 0.\n * Node.js and allocPlain() compatible.\n */\nDUK_LOCAL duk_hbuffer *duk__hbufobj_fixed_from_argvalue(duk_context *ctx) {\n\tduk_int_t len;\n\tduk_int_t i;\n\tduk_size_t buf_size;\n\tduk_uint8_t *buf;\n\n\tswitch (duk_get_type(ctx, 0)) {\n\tcase DUK_TYPE_NUMBER: {\n\t\tlen = duk_to_int_clamped(ctx, 0, 0, DUK_INT_MAX);\n\t\t(void) duk_push_fixed_buffer_zero(ctx, (duk_size_t) len);\n\t\tbreak;\n\t}\n\tcase DUK_TYPE_BUFFER: { /* Treat like Uint8Array. */\n\t\tgoto slow_copy;\n\t}\n\tcase DUK_TYPE_OBJECT: {\n\t\tduk_hobject *h;\n\t\tduk_hbufobj *h_bufobj;\n\n\t\t/* For Node.js Buffers \"Passing an ArrayBuffer returns a Buffer\n\t\t * that shares allocated memory with the given ArrayBuffer.\"\n\t\t * https://nodejs.org/api/buffer.html#buffer_buffer_from_buffer_alloc_and_buffer_allocunsafe\n\t\t */\n\n\t\th = duk_known_hobject(ctx, 0);\n\t\tif (DUK_HOBJECT_GET_CLASS_NUMBER(h) == DUK_HOBJECT_CLASS_ARRAYBUFFER) {\n\t\t\tDUK_ASSERT(DUK_HOBJECT_IS_BUFOBJ(h));\n\t\t\th_bufobj = (duk_hbufobj *) h;\n\t\t\tif (DUK_UNLIKELY(h_bufobj->buf == NULL)) {\n\t\t\t\tDUK_ERROR_TYPE_INVALID_ARGS((duk_hthread *) ctx);\n\t\t\t}\n\t\t\tif (DUK_UNLIKELY(h_bufobj->offset != 0 || h_bufobj->length != DUK_HBUFFER_GET_SIZE(h_bufobj->buf))) {\n\t\t\t\t/* No support for ArrayBuffers with slice\n\t\t\t\t * offset/length.\n\t\t\t\t */\n\t\t\t\tDUK_ERROR_TYPE_INVALID_ARGS((duk_hthread *) ctx);\n\t\t\t}\n\t\t\tduk_push_hbuffer(ctx, h_bufobj->buf);\n\t\t\treturn h_bufobj->buf;\n\t\t}\n\t\tgoto slow_copy;\n\t}\n\tcase DUK_TYPE_STRING: {\n\t\t/* ignore encoding for now */\n\t\tduk_require_hstring_notsymbol(ctx, 0);\n\t\tduk_dup_0(ctx);\n\t\t(void) duk_to_buffer(ctx, -1, &buf_size);\n\t\tbreak;\n\t}\n\tdefault:\n\t\tDUK_ERROR_TYPE_INVALID_ARGS((duk_hthread *) ctx);\n\t}\n\n done:\n\tDUK_ASSERT(duk_is_buffer(ctx, -1));\n\treturn duk_known_hbuffer(ctx, -1);\n\n slow_copy:\n\t/* XXX: fast path for typed arrays and other buffer objects? */\n\n\t(void) duk_get_prop_stridx_short(ctx, 0, DUK_STRIDX_LENGTH);\n\tlen = duk_to_int_clamped(ctx, -1, 0, DUK_INT_MAX);\n\tduk_pop(ctx);\n\tbuf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(ctx, (duk_size_t) len);  /* no zeroing, all indices get initialized */\n\tfor (i = 0; i < len; i++) {\n\t\t/* XXX: fast path for array or buffer arguments? */\n\t\tduk_get_prop_index(ctx, 0, (duk_uarridx_t) i);\n\t\tbuf[i] = (duk_uint8_t) (duk_to_uint32(ctx, -1) & 0xffU);\n\t\tduk_pop(ctx);\n\t}\n\tgoto done;\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/*\n *  Node.js Buffer constructor\n *\n *  Node.js Buffers are just Uint8Arrays with internal prototype set to\n *  Buffer.prototype so they're handled otherwise the same as Uint8Array.\n *  However, the constructor arguments are very different so a separate\n *  constructor entry point is used.\n */\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_nodejs_buffer_constructor(duk_context *ctx) {\n\tduk_hbuffer *h_buf;\n\n\th_buf = duk__hbufobj_fixed_from_argvalue(ctx);\n\tDUK_ASSERT(h_buf != NULL);\n\n\tduk_push_buffer_object(ctx,\n\t                       -1,\n\t                       0,\n\t                       DUK_HBUFFER_FIXED_GET_SIZE((duk_hbuffer_fixed *) h_buf),\n\t                       DUK_BUFOBJ_UINT8ARRAY);\n\tduk_push_hobject_bidx(ctx, DUK_BIDX_NODEJS_BUFFER_PROTOTYPE);\n\tduk_set_prototype(ctx, -2);\n\n\t/* XXX: a more direct implementation */\n\n\treturn 1;\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/*\n *  ArrayBuffer, DataView, and TypedArray constructors\n */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_arraybuffer_constructor(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_hbufobj *h_bufobj;\n\tduk_hbuffer *h_val;\n\tduk_int_t len;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tthr = (duk_hthread *) ctx;\n\tDUK_UNREF(thr);\n\n\tduk_require_constructor_call(ctx);\n\n\tlen = duk_to_int(ctx, 0);\n\tif (len < 0) {\n\t\tgoto fail_length;\n\t}\n\t(void) duk_push_fixed_buffer_zero(ctx, (duk_size_t) len);\n\th_val = (duk_hbuffer *) duk_known_hbuffer(ctx, -1);\n\n\th_bufobj = duk_push_bufobj_raw(ctx,\n\t                               DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                               DUK_HOBJECT_FLAG_BUFOBJ |\n\t                               DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_ARRAYBUFFER),\n\t                               DUK_BIDX_ARRAYBUFFER_PROTOTYPE);\n\tDUK_ASSERT(h_bufobj != NULL);\n\n\tduk__set_bufobj_buffer(ctx, h_bufobj, h_val);\n\tDUK_ASSERT_HBUFOBJ_VALID(h_bufobj);\n\n\treturn 1;\n\n fail_length:\n\tDUK_DCERROR_RANGE_INVALID_LENGTH(thr);\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n\n/* Format of magic, bits:\n *   0...1: elem size shift (0-3)\n *   2...5: elem type (DUK_HBUFOBJ_ELEM_xxx)\n *\n * XXX: add prototype bidx explicitly to magic instead of using a mapping?\n */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_typedarray_constructor(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_tval *tv;\n\tduk_hobject *h_obj;\n\tduk_hbufobj *h_bufobj = NULL;\n\tduk_hbufobj *h_bufarg = NULL;\n\tduk_hbuffer *h_val;\n\tduk_small_uint_t magic;\n\tduk_small_uint_t shift;\n\tduk_small_uint_t elem_type;\n\tduk_small_uint_t elem_size;\n\tduk_small_uint_t class_num;\n\tduk_small_uint_t proto_bidx;\n\tduk_uint_t align_mask;\n\tduk_uint_t elem_length;\n\tduk_int_t elem_length_signed;\n\tduk_uint_t byte_length;\n\tduk_small_uint_t copy_mode;\n\n\tthr = (duk_hthread *) ctx;\n\tDUK_UNREF(thr);\n\n\t/* XXX: The same copy helpers could be shared with at least some\n\t * buffer functions.\n\t */\n\n\tduk_require_constructor_call(ctx);\n\n\t/* We could fit built-in index into magic but that'd make the magic\n\t * number dependent on built-in numbering (genbuiltins.py doesn't\n\t * handle that yet).  So map both class and prototype from the\n\t * element type.\n\t */\n\tmagic = duk_get_current_magic(ctx);\n\tshift = magic & 0x03;               /* bits 0...1: shift */\n\telem_type = (magic >> 2) & 0x0f;    /* bits 2...5: type */\n\telem_size = 1 << shift;\n\talign_mask = elem_size - 1;\n\tDUK_ASSERT(elem_type < sizeof(duk__buffer_proto_from_elemtype) / sizeof(duk_uint8_t));\n\tproto_bidx = duk__buffer_proto_from_elemtype[elem_type];\n\tDUK_ASSERT(proto_bidx < DUK_NUM_BUILTINS);\n\tDUK_ASSERT(elem_type < sizeof(duk__buffer_class_from_elemtype) / sizeof(duk_uint8_t));\n\tclass_num = duk__buffer_class_from_elemtype[elem_type];\n\n\tDUK_DD(DUK_DDPRINT(\"typedarray constructor, magic=%d, shift=%d, elem_type=%d, \"\n\t                   \"elem_size=%d, proto_bidx=%d, class_num=%d\",\n\t                   (int) magic, (int) shift, (int) elem_type, (int) elem_size,\n\t                   (int) proto_bidx, (int) class_num));\n\n\t/* Argument variants.  When the argument is an ArrayBuffer a view to\n\t * the same buffer is created; otherwise a new ArrayBuffer is always\n\t * created.\n\t */\n\n\t/* XXX: initial iteration to treat a plain buffer like an ArrayBuffer:\n\t * coerce to an ArrayBuffer object and use that as .buffer.  The underlying\n\t * buffer will be the same but result .buffer !== inputPlainBuffer.\n\t */\n\tduk_hbufobj_promote_plain(ctx, 0);\n\n\ttv = duk_get_tval(ctx, 0);\n\tDUK_ASSERT(tv != NULL);  /* arg count */\n\tif (DUK_TVAL_IS_OBJECT(tv)) {\n\t\th_obj = DUK_TVAL_GET_OBJECT(tv);\n\t\tDUK_ASSERT(h_obj != NULL);\n\n\t\tif (DUK_HOBJECT_GET_CLASS_NUMBER(h_obj) == DUK_HOBJECT_CLASS_ARRAYBUFFER) {\n\t\t\t/* ArrayBuffer: unlike any other argument variant, create\n\t\t\t * a view into the existing buffer.\n\t\t\t */\n\n\t\t\tduk_int_t byte_offset_signed;\n\t\t\tduk_uint_t byte_offset;\n\n\t\t\th_bufarg = (duk_hbufobj *) h_obj;\n\n\t\t\tbyte_offset_signed = duk_to_int(ctx, 1);\n\t\t\tif (byte_offset_signed < 0) {\n\t\t\t\tgoto fail_arguments;\n\t\t\t}\n\t\t\tbyte_offset = (duk_uint_t) byte_offset_signed;\n\t\t\tif (byte_offset > h_bufarg->length ||\n\t\t\t    (byte_offset & align_mask) != 0) {\n\t\t\t\t/* Must be >= 0 and multiple of element size. */\n\t\t\t\tgoto fail_arguments;\n\t\t\t}\n\t\t\tif (duk_is_undefined(ctx, 2)) {\n\t\t\t\tDUK_ASSERT(h_bufarg->length >= byte_offset);\n\t\t\t\tbyte_length = h_bufarg->length - byte_offset;\n\t\t\t\tif ((byte_length & align_mask) != 0) {\n\t\t\t\t\t/* Must be element size multiple from\n\t\t\t\t\t * start offset to end of buffer.\n\t\t\t\t\t */\n\t\t\t\t\tgoto fail_arguments;\n\t\t\t\t}\n\t\t\t\telem_length = (byte_length >> shift);\n\t\t\t} else {\n\t\t\t\telem_length_signed = duk_to_int(ctx, 2);\n\t\t\t\tif (elem_length_signed < 0) {\n\t\t\t\t\tgoto fail_arguments;\n\t\t\t\t}\n\t\t\t\telem_length = (duk_uint_t) elem_length_signed;\n\t\t\t\tbyte_length = elem_length << shift;\n\t\t\t\tif ((byte_length >> shift) != elem_length) {\n\t\t\t\t\t/* Byte length would overflow. */\n\t\t\t\t\t/* XXX: easier check with less code? */\n\t\t\t\t\tgoto fail_arguments;\n\t\t\t\t}\n\t\t\t\tDUK_ASSERT(h_bufarg->length >= byte_offset);\n\t\t\t\tif (byte_length > h_bufarg->length - byte_offset) {\n\t\t\t\t\t/* Not enough data. */\n\t\t\t\t\tgoto fail_arguments;\n\t\t\t\t}\n\t\t\t}\n\t\t\tDUK_UNREF(elem_length);\n\t\t\tDUK_ASSERT_DISABLE(byte_offset >= 0);\n\t\t\tDUK_ASSERT(byte_offset <= h_bufarg->length);\n\t\t\tDUK_ASSERT_DISABLE(byte_length >= 0);\n\t\t\tDUK_ASSERT(byte_offset + byte_length <= h_bufarg->length);\n\t\t\tDUK_ASSERT((elem_length << shift) == byte_length);\n\n\t\t\th_bufobj = duk_push_bufobj_raw(ctx,\n\t\t\t                               DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t\t\t                               DUK_HOBJECT_FLAG_BUFOBJ |\n\t\t\t                               DUK_HOBJECT_CLASS_AS_FLAGS(class_num),\n\t\t\t                               proto_bidx);\n\t\t\th_val = h_bufarg->buf;\n\t\t\tif (h_val == NULL) {\n\t\t\t\tDUK_DCERROR_TYPE_INVALID_ARGS(thr);\n\t\t\t}\n\t\t\th_bufobj->buf = h_val;\n\t\t\tDUK_HBUFFER_INCREF(thr, h_val);\n\t\t\th_bufobj->offset = h_bufarg->offset + byte_offset;\n\t\t\th_bufobj->length = byte_length;\n\t\t\th_bufobj->shift = (duk_uint8_t) shift;\n\t\t\th_bufobj->elem_type = (duk_uint8_t) elem_type;\n\t\t\th_bufobj->is_typedarray = 1;\n\t\t\tDUK_ASSERT_HBUFOBJ_VALID(h_bufobj);\n\n\t\t\t/* Set .buffer to the argument ArrayBuffer. */\n\t\t\tDUK_ASSERT(h_bufobj->buf_prop == NULL);\n\t\t\th_bufobj->buf_prop = (duk_hobject *) h_bufarg;\n\t\t\tDUK_ASSERT(h_bufarg != NULL);\n\t\t\tDUK_HBUFOBJ_INCREF(thr, h_bufarg);\n\t\t\treturn 1;\n\t\t} else if (DUK_HOBJECT_IS_BUFOBJ(h_obj)) {\n\t\t\t/* TypedArray (or other non-ArrayBuffer duk_hbufobj).\n\t\t\t * Conceptually same behavior as for an Array-like argument,\n\t\t\t * with a few fast paths.\n\t\t\t */\n\n\t\t\th_bufarg = (duk_hbufobj *) h_obj;\n\t\t\tDUK_ASSERT_HBUFOBJ_VALID(h_bufarg);\n\t\t\telem_length_signed = (duk_int_t) (h_bufarg->length >> h_bufarg->shift);\n\t\t\tif (h_bufarg->buf == NULL) {\n\t\t\t\tDUK_DCERROR_TYPE_INVALID_ARGS(thr);\n\t\t\t}\n\n\t\t\t/* Select copy mode.  Must take into account element\n\t\t\t * compatibility and validity of the underlying source\n\t\t\t * buffer.\n\t\t\t */\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"selecting copy mode for bufobj arg, \"\n\t\t\t                     \"src byte_length=%ld, src shift=%d, \"\n\t\t\t                     \"src/dst elem_length=%ld; \"\n\t\t\t                     \"dst shift=%d -> dst byte_length=%ld\",\n\t\t\t                     (long) h_bufarg->length, (int) h_bufarg->shift,\n\t\t\t                     (long) elem_length_signed, (int) shift,\n\t\t\t                     (long) (elem_length_signed << shift)));\n\n\t\t\tcopy_mode = 2;  /* default is explicit index read/write copy */\n#if !defined(DUK_USE_PREFER_SIZE)\n\t\t\t/* With a size optimized build copy_mode 2 is enough.\n\t\t\t * Modes 0 and 1 are faster but conceptually the same.\n\t\t\t */\n\t\t\tDUK_ASSERT(elem_type < sizeof(duk__buffer_elemtype_copy_compatible) / sizeof(duk_uint16_t));\n\t\t\tif (DUK_HBUFOBJ_VALID_SLICE(h_bufarg)) {\n\t\t\t\tif ((duk__buffer_elemtype_copy_compatible[elem_type] & (1 << h_bufarg->elem_type)) != 0) {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"source/target are copy compatible, memcpy\"));\n\t\t\t\t\tDUK_ASSERT(shift == h_bufarg->shift);  /* byte sizes will match */\n\t\t\t\t\tcopy_mode = 0;\n\t\t\t\t} else {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"source/target not copy compatible but valid, fast copy\"));\n\t\t\t\t\tcopy_mode = 1;\n\t\t\t\t}\n\t\t\t}\n#endif  /* !DUK_USE_PREFER_SIZE */\n\t\t} else {\n\t\t\t/* Array or Array-like */\n\t\t\telem_length_signed = (duk_int_t) duk_get_length(ctx, 0);\n\t\t\tcopy_mode = 2;\n\t\t}\n\t} else {\n\t\t/* Non-object argument is simply int coerced, matches\n\t\t * V8 behavior (except for \"null\", which we coerce to\n\t\t * 0 but V8 TypeErrors).\n\t\t */\n\t\telem_length_signed = duk_to_int(ctx, 0);\n\t\tcopy_mode = 3;\n\t}\n\tif (elem_length_signed < 0) {\n\t\tgoto fail_arguments;\n\t}\n\telem_length = (duk_uint_t) elem_length_signed;\n\tbyte_length = (duk_uint_t) (elem_length << shift);\n\tif ((byte_length >> shift) != elem_length) {\n\t\t/* Byte length would overflow. */\n\t\t/* XXX: easier check with less code? */\n\t\tgoto fail_arguments;\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"elem_length=%ld, byte_length=%ld\",\n\t                     (long) elem_length, (long) byte_length));\n\n\t/* ArrayBuffer argument is handled specially above; the rest of the\n\t * argument variants are handled by shared code below.\n\t *\n\t * ArrayBuffer in h_bufobj->buf_prop is intentionally left unset.\n\t * It will be automatically created by the .buffer accessor on\n\t * first access.\n\t */\n\n\t/* Push the resulting view object on top of a plain fixed buffer. */\n\t(void) duk_push_fixed_buffer(ctx, byte_length);\n\th_val = duk_known_hbuffer(ctx, -1);\n\tDUK_ASSERT(h_val != NULL);\n\n\th_bufobj = duk_push_bufobj_raw(ctx,\n\t                               DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                               DUK_HOBJECT_FLAG_BUFOBJ |\n\t                               DUK_HOBJECT_CLASS_AS_FLAGS(class_num),\n\t                               proto_bidx);\n\n\th_bufobj->buf = h_val;\n\tDUK_HBUFFER_INCREF(thr, h_val);\n\tDUK_ASSERT(h_bufobj->offset == 0);\n\th_bufobj->length = byte_length;\n\th_bufobj->shift = (duk_uint8_t) shift;\n\th_bufobj->elem_type = (duk_uint8_t) elem_type;\n\th_bufobj->is_typedarray = 1;\n\tDUK_ASSERT_HBUFOBJ_VALID(h_bufobj);\n\n\t/* Copy values, the copy method depends on the arguments.\n\t *\n\t * Copy mode decision may depend on the validity of the underlying\n\t * buffer of the source argument; there must be no harmful side effects\n\t * from there to here for copy_mode to still be valid.\n\t */\n\tDUK_DDD(DUK_DDDPRINT(\"copy mode: %d\", (int) copy_mode));\n\tswitch (copy_mode) {\n\t\t/* Copy modes 0 and 1 can be omitted in size optimized build,\n\t\t * copy mode 2 handles them (but more slowly).\n\t\t */\n#if !defined(DUK_USE_PREFER_SIZE)\n\tcase 0: {\n\t\t/* Use byte copy. */\n\n\t\tduk_uint8_t *p_src;\n\t\tduk_uint8_t *p_dst;\n\n\t\tDUK_ASSERT(h_bufobj != NULL);\n\t\tDUK_ASSERT(h_bufobj->buf != NULL);\n\t\tDUK_ASSERT(DUK_HBUFOBJ_VALID_SLICE(h_bufobj));\n\t\tDUK_ASSERT(h_bufarg != NULL);\n\t\tDUK_ASSERT(h_bufarg->buf != NULL);\n\t\tDUK_ASSERT(DUK_HBUFOBJ_VALID_SLICE(h_bufarg));\n\n\t\tp_dst = DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufobj);\n\t\tp_src = DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufarg);\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"using memcpy: p_src=%p, p_dst=%p, byte_length=%ld\",\n\t\t                     (void *) p_src, (void *) p_dst, (long) byte_length));\n\n\t\tDUK_MEMCPY((void *) p_dst, (const void *) p_src, (size_t) byte_length);\n\t\tbreak;\n\t}\n\tcase 1: {\n\t\t/* Copy values through direct validated reads and writes. */\n\n\t\tduk_small_uint_t src_elem_size;\n\t\tduk_small_uint_t dst_elem_size;\n\t\tduk_uint8_t *p_src;\n\t\tduk_uint8_t *p_src_end;\n\t\tduk_uint8_t *p_dst;\n\n\t\tDUK_ASSERT(h_bufobj != NULL);\n\t\tDUK_ASSERT(h_bufobj->buf != NULL);\n\t\tDUK_ASSERT(DUK_HBUFOBJ_VALID_SLICE(h_bufobj));\n\t\tDUK_ASSERT(h_bufarg != NULL);\n\t\tDUK_ASSERT(h_bufarg->buf != NULL);\n\t\tDUK_ASSERT(DUK_HBUFOBJ_VALID_SLICE(h_bufarg));\n\n\t\tsrc_elem_size = 1 << h_bufarg->shift;\n\t\tdst_elem_size = elem_size;\n\n\t\tp_src = DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufarg);\n\t\tp_dst = DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufobj);\n\t\tp_src_end = p_src + h_bufarg->length;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"using fast copy: p_src=%p, p_src_end=%p, p_dst=%p, \"\n\t\t                     \"src_elem_size=%d, dst_elem_size=%d\",\n\t\t                     (void *) p_src, (void *) p_src_end, (void *) p_dst,\n\t\t                     (int) src_elem_size, (int) dst_elem_size));\n\n\t\twhile (p_src != p_src_end) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"fast path per element copy loop: \"\n\t\t\t                     \"p_src=%p, p_src_end=%p, p_dst=%p\",\n\t\t\t                     (void *) p_src, (void *) p_src_end, (void *) p_dst));\n\t\t\t/* A validated read() is always a number, so it's write coercion\n\t\t\t * is always side effect free an won't invalidate pointers etc.\n\t\t\t */\n\t\t\tduk_hbufobj_push_validated_read(ctx, h_bufarg, p_src, src_elem_size);\n\t\t\tduk_hbufobj_validated_write(ctx, h_bufobj, p_dst, dst_elem_size);\n\t\t\tduk_pop(ctx);\n\t\t\tp_src += src_elem_size;\n\t\t\tp_dst += dst_elem_size;\n\t\t}\n\t\tbreak;\n\t}\n#endif  /* !DUK_USE_PREFER_SIZE */\n\tcase 2: {\n\t\t/* Copy values by index reads and writes.  Let virtual\n\t\t * property handling take care of coercion.\n\t\t */\n\t\tduk_uint_t i;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"using slow copy\"));\n\n\t\tfor (i = 0; i < elem_length; i++) {\n\t\t\tduk_get_prop_index(ctx, 0, (duk_uarridx_t) i);\n\t\t\tduk_put_prop_index(ctx, -2, (duk_uarridx_t) i);\n\t\t}\n\t\tbreak;\n\t}\n\tdefault:\n\tcase 3: {\n\t\t/* No copy, leave zero bytes in the buffer.  There's no\n\t\t * ambiguity with Float32/Float64 because zero bytes also\n\t\t * represent 0.0.\n\t\t */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"using no copy\"));\n\t\tbreak;\n\t}\n\t}\n\n\treturn 1;\n\n fail_arguments:\n\tDUK_DCERROR_RANGE_INVALID_ARGS(thr);\n}\n#else  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n/* When bufferobject support is disabled, new Uint8Array() could still be\n * supported to create a plain fixed buffer.  Disabled for now.\n */\n#if 0\nDUK_INTERNAL duk_ret_t duk_bi_typedarray_constructor(duk_context *ctx) {\n\tduk_int_t elem_length_signed;\n\tduk_uint_t byte_length;\n\n\t/* XXX: The same copy helpers could be shared with at least some\n\t * buffer functions.\n\t */\n\n\tduk_require_constructor_call(ctx);\n\n\telem_length_signed = duk_require_int(ctx, 0);\n\tif (elem_length_signed < 0) {\n\t\tgoto fail_arguments;\n\t}\n\tbyte_length = (duk_uint_t) elem_length_signed;\n\n\t(void) duk_push_fixed_buffer_zero(ctx, (duk_size_t) byte_length);\n\treturn 1;\n\n fail_arguments:\n\tDUK_DCERROR_RANGE_INVALID_ARGS((duk_hthread *) ctx);\n}\n#endif  /* 0 */\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_dataview_constructor(duk_context *ctx) {\n\tduk_hbufobj *h_bufarg;\n\tduk_hbufobj *h_bufobj;\n\tduk_hbuffer *h_val;\n\tduk_uint_t offset;\n\tduk_uint_t length;\n\n\tduk_require_constructor_call(ctx);\n\n\th_bufarg = duk__require_bufobj_value(ctx, 0);\n\tDUK_ASSERT(h_bufarg != NULL);\n\tif (DUK_HOBJECT_GET_CLASS_NUMBER((duk_hobject *) h_bufarg) != DUK_HOBJECT_CLASS_ARRAYBUFFER) {\n\t\tDUK_DCERROR_TYPE_INVALID_ARGS((duk_hthread *) ctx);\n\t}\n\n\tduk__resolve_offset_opt_length(ctx, h_bufarg, 1, 2, &offset, &length, 1 /*throw_flag*/);\n\tDUK_ASSERT(offset <= h_bufarg->length);\n\tDUK_ASSERT(offset + length <= h_bufarg->length);\n\n\th_bufobj = duk_push_bufobj_raw(ctx,\n\t                               DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                               DUK_HOBJECT_FLAG_BUFOBJ |\n\t                               DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_DATAVIEW),\n\t                               DUK_BIDX_DATAVIEW_PROTOTYPE);\n\n\th_val = h_bufarg->buf;\n\tif (h_val == NULL) {\n\t\tDUK_DCERROR_TYPE_INVALID_ARGS((duk_hthread *) ctx);\n\t}\n\th_bufobj->buf = h_val;\n\tDUK_HBUFFER_INCREF(thr, h_val);\n\th_bufobj->offset = h_bufarg->offset + offset;\n\th_bufobj->length = length;\n\tDUK_ASSERT(h_bufobj->shift == 0);\n\tDUK_ASSERT(h_bufobj->elem_type == DUK_HBUFOBJ_ELEM_UINT8);\n\tDUK_ASSERT(h_bufobj->is_typedarray == 0);\n\n\tDUK_ASSERT(h_bufobj->buf_prop == NULL);\n\th_bufobj->buf_prop = (duk_hobject *) h_bufarg;\n\tDUK_ASSERT(h_bufarg != NULL);\n\tDUK_HBUFOBJ_INCREF((duk_hthread *) ctx, h_bufarg);\n\n\tDUK_ASSERT_HBUFOBJ_VALID(h_bufobj);\n\treturn 1;\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/*\n *  ArrayBuffer.isView()\n */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_arraybuffer_isview(duk_context *ctx) {\n\tduk_hobject *h_obj;\n\tduk_bool_t ret = 0;\n\n\tif (duk_is_buffer(ctx, 0)) {\n\t\tret = 1;\n\t} else {\n\t\th_obj = duk_get_hobject(ctx, 0);\n\t\tif (h_obj != NULL && DUK_HOBJECT_IS_BUFOBJ(h_obj)) {\n\t\t\t/* DataView needs special casing: ArrayBuffer.isView() is\n\t\t\t * true, but ->is_typedarray is 0.\n\t\t\t */\n\t\t\tret = ((duk_hbufobj *) h_obj)->is_typedarray ||\n\t\t\t      (DUK_HOBJECT_GET_CLASS_NUMBER(h_obj) == DUK_HOBJECT_CLASS_DATAVIEW);\n\t\t}\n\t}\n\tduk_push_boolean(ctx, ret);\n\treturn 1;\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/*\n *  Uint8Array.allocPlain()\n */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_uint8array_allocplain(duk_context *ctx) {\n\tduk__hbufobj_fixed_from_argvalue(ctx);\n\treturn 1;\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/*\n *  Uint8Array.plainOf()\n */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_uint8array_plainof(duk_context *ctx) {\n\tduk_hbufobj *h_bufobj;\n\n#if !defined(DUK_USE_PREFER_SIZE)\n\t/* Avoid churn if argument is already a plain buffer. */\n\tif (duk_is_buffer(ctx, 0)) {\n\t\treturn 1;\n\t}\n#endif\n\n\t/* Promotes plain buffers to ArrayBuffers, so for a plain buffer\n\t * argument we'll create a pointless temporary (but still work\n\t * correctly).\n\t */\n\th_bufobj = duk__require_bufobj_value(ctx, 0);\n\tif (h_bufobj->buf == NULL) {\n\t\tduk_push_undefined(ctx);\n\t} else {\n\t\tduk_push_hbuffer(ctx, h_bufobj->buf);\n\t}\n\treturn 1;\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/*\n *  Node.js Buffer: toString([encoding], [start], [end])\n */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_nodejs_buffer_tostring(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_hbufobj *h_this;\n\tduk_int_t start_offset, end_offset;\n\tduk_uint8_t *buf_slice;\n\tduk_size_t slice_length;\n\n\tthr = (duk_hthread *) ctx;\n\tDUK_UNREF(thr);\n\n\th_this = duk__get_bufobj_this(ctx);\n\tif (h_this == NULL) {\n\t\t/* XXX: happens e.g. when evaluating: String(Buffer.prototype). */\n\t\tduk_push_string(ctx, \"[object Object]\");\n\t\treturn 1;\n\t}\n\tDUK_ASSERT_HBUFOBJ_VALID(h_this);\n\n\t/* Ignore encoding for now. */\n\n\tduk__clamp_startend_nonegidx_noshift(ctx,\n\t                                     (duk_int_t) h_this->length,\n\t                                     1 /*idx_start*/,\n\t                                     2 /*idx_end*/,\n\t                                     &start_offset,\n\t                                     &end_offset);\n\n\tslice_length = (duk_size_t) (end_offset - start_offset);\n\tbuf_slice = (duk_uint8_t *) duk_push_fixed_buffer_nozero(ctx, slice_length);  /* all bytes initialized below */\n\tDUK_ASSERT(buf_slice != NULL);\n\n\t/* Neutered or uncovered, TypeError. */\n\tif (h_this->buf == NULL ||\n\t    !DUK_HBUFOBJ_VALID_BYTEOFFSET_EXCL(h_this, start_offset + slice_length)) {\n\t\tDUK_DCERROR_TYPE_INVALID_ARGS(thr);\n\t}\n\n\t/* XXX: ideally we wouldn't make a copy but a view into the buffer for the\n\t * decoding process.  Or the decoding helper could be changed to accept\n\t * the slice info (a buffer pointer is NOT a good approach because guaranteeing\n\t * its stability is difficult).\n\t */\n\n\tDUK_ASSERT(DUK_HBUFOBJ_VALID_BYTEOFFSET_EXCL(h_this, start_offset + slice_length));\n\tDUK_MEMCPY((void *) buf_slice,\n\t           (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + start_offset),\n\t           (size_t) slice_length);\n\n\t/* Use the equivalent of: new TextEncoder().encode(this) to convert the\n\t * string.  Result will be valid UTF-8; non-CESU-8 inputs are currently\n\t * interpreted loosely.  Value stack convention is a bit odd for now.\n\t */\n\tduk_replace(ctx, 0);\n\tduk_set_top(ctx, 1);\n\treturn duk_textdecoder_decode_utf8_nodejs(ctx);\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/*\n *  Node.js Buffer.prototype: toJSON()\n */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_nodejs_buffer_tojson(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_hbufobj *h_this;\n\tduk_harray *h_arr;\n\tduk_uint8_t *buf;\n\tduk_uint_t i, n;\n\tduk_tval *tv;\n\n\tthr = (duk_hthread *) ctx;\n\tDUK_UNREF(thr);\n\n\th_this = duk__require_bufobj_this(ctx);\n\tDUK_ASSERT(h_this != NULL);\n\n\tif (h_this->buf == NULL || !DUK_HBUFOBJ_VALID_SLICE(h_this)) {\n\t\t/* Serialize uncovered backing buffer as a null; doesn't\n\t\t * really matter as long we're memory safe.\n\t\t */\n\t\tduk_push_null(ctx);\n\t\treturn 1;\n\t}\n\n\tduk_push_object(ctx);\n\tduk_push_hstring_stridx(ctx, DUK_STRIDX_UC_BUFFER);\n\tduk_put_prop_stridx_short(ctx, -2, DUK_STRIDX_TYPE);\n\n\tDUK_ASSERT_DISABLE((duk_size_t) h_this->length <= (duk_size_t) DUK_UINT32_MAX);\n\th_arr = duk_push_harray_with_size(ctx, (duk_uint32_t) h_this->length);  /* XXX: needs revision with >4G buffers */\n\tDUK_ASSERT(h_arr != NULL);\n\tDUK_ASSERT(h_arr->length == h_this->length);\n\ttv = DUK_HOBJECT_A_GET_BASE(thr->heap, (duk_hobject *) h_arr);\n\n\tDUK_ASSERT(h_this->buf != NULL);\n\tbuf = DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this);\n\tfor (i = 0, n = h_this->length; i < n; i++) {\n\t\tDUK_TVAL_SET_U32(tv + i, (duk_uint32_t) buf[i]);  /* no need for decref or incref */\n\t}\n\tduk_put_prop_stridx_short(ctx, -2, DUK_STRIDX_DATA);\n\n\treturn 1;\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/*\n *  Node.js Buffer.prototype.equals()\n *  Node.js Buffer.prototype.compare()\n *  Node.js Buffer.compare()\n */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_buffer_compare_shared(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_small_uint_t magic;\n\tduk_hbufobj *h_bufarg1;\n\tduk_hbufobj *h_bufarg2;\n\tduk_small_int_t comp_res;\n\n\tthr = (duk_hthread *) ctx;\n\tDUK_UNREF(thr);\n\n\t/* XXX: keep support for plain buffers and non-Node.js buffers? */\n\n\tmagic = duk_get_current_magic(ctx);\n\tif (magic & 0x02) {\n\t\t/* Static call style. */\n\t\th_bufarg1 = duk__require_bufobj_value(ctx, 0);\n\t\th_bufarg2 = duk__require_bufobj_value(ctx, 1);\n\t} else {\n\t\th_bufarg1 = duk__require_bufobj_this(ctx);\n\t\th_bufarg2 = duk__require_bufobj_value(ctx, 0);\n\t}\n\tDUK_ASSERT(h_bufarg1 != NULL);\n\tDUK_ASSERT(h_bufarg2 != NULL);\n\n\t/* We want to compare the slice/view areas of the arguments.\n\t * If either slice/view is invalid (underlying buffer is shorter)\n\t * ensure equals() is false, but otherwise the only thing that\n\t * matters is to be memory safe.\n\t */\n\n\tif (DUK_HBUFOBJ_VALID_SLICE(h_bufarg1) &&\n\t    DUK_HBUFOBJ_VALID_SLICE(h_bufarg2)) {\n\t\tcomp_res = duk_js_data_compare((const duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_bufarg1->buf) + h_bufarg1->offset,\n\t\t                               (const duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_bufarg2->buf) + h_bufarg2->offset,\n\t\t                               (duk_size_t) h_bufarg1->length,\n\t\t                               (duk_size_t) h_bufarg2->length);\n\t} else {\n\t\tcomp_res = -1;  /* either nonzero value is ok */\n\t}\n\n\tif (magic & 0x01) {\n\t\t/* compare: similar to string comparison but for buffer data. */\n\t\tduk_push_int(ctx, comp_res);\n\t} else {\n\t\t/* equals */\n\t\tduk_push_boolean(ctx, (comp_res == 0));\n\t}\n\n\treturn 1;\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/*\n *  Node.js Buffer.prototype.fill()\n */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_nodejs_buffer_fill(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_hbufobj *h_this;\n\tconst duk_uint8_t *fill_str_ptr;\n\tduk_size_t fill_str_len;\n\tduk_uint8_t fill_value;\n\tduk_int_t fill_offset;\n\tduk_int_t fill_end;\n\tduk_size_t fill_length;\n\tduk_uint8_t *p;\n\n\tthr = (duk_hthread *) ctx;\n\tDUK_UNREF(thr);\n\n\th_this = duk__require_bufobj_this(ctx);\n\tDUK_ASSERT(h_this != NULL);\n\tif (h_this->buf == NULL) {\n\t\tDUK_DCERROR_TYPE_INVALID_ARGS(thr);\n\t}\n\n\t/* [ value offset end ] */\n\n\tif (duk_is_string_notsymbol(ctx, 0)) {\n\t\tfill_str_ptr = (const duk_uint8_t *) duk_get_lstring(ctx, 0, &fill_str_len);\n\t\tDUK_ASSERT(fill_str_ptr != NULL);\n\t} else {\n\t\t/* Symbols get ToNumber() coerced and cause TypeError. */\n\t\tfill_value = (duk_uint8_t) duk_to_uint32(ctx, 0);\n\t\tfill_str_ptr = (const duk_uint8_t *) &fill_value;\n\t\tfill_str_len = 1;\n\t}\n\n\t/* Fill offset handling is more lenient than in Node.js. */\n\n\tduk__clamp_startend_nonegidx_noshift(ctx,\n\t                                     (duk_int_t) h_this->length,\n\t                                     1 /*idx_start*/,\n\t                                     2 /*idx_end*/,\n\t                                     &fill_offset,\n\t                                     &fill_end);\n\n\tDUK_DDD(DUK_DDDPRINT(\"fill: fill_value=%02x, fill_offset=%ld, fill_end=%ld, view length=%ld\",\n\t                     (unsigned int) fill_value, (long) fill_offset, (long) fill_end, (long) h_this->length));\n\n\tDUK_ASSERT(fill_end - fill_offset >= 0);\n\tDUK_ASSERT(h_this->buf != NULL);\n\n\tp = (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + fill_offset);\n\tfill_length = (duk_size_t) (fill_end - fill_offset);\n\tif (fill_str_len == 1) {\n\t\t/* Handle single character fills as memset() even when\n\t\t * the fill data comes from a one-char argument.\n\t\t */\n\t\tDUK_MEMSET((void *) p, (int) fill_str_ptr[0], (size_t) fill_length);\n\t} else if (fill_str_len > 1) {\n\t\tduk_size_t i, n, t;\n\n\t\tfor (i = 0, n = (fill_end - fill_offset), t = 0; i < n; i++) {\n\t\t\tp[i] = fill_str_ptr[t++];\n\t\t\tif (t >= fill_str_len) {\n\t\t\t\tt = 0;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tDUK_DDD(DUK_DDDPRINT(\"zero size fill pattern, ignore silently\"));\n\t}\n\n\t/* Return the Buffer to allow chaining: b.fill(0x11).fill(0x22, 3, 5).toString() */\n\tduk_push_this(ctx);\n\treturn 1;\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/*\n *  Node.js Buffer.prototype.write(string, [offset], [length], [encoding])\n */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_nodejs_buffer_write(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_hbufobj *h_this;\n\tduk_uint_t offset;\n\tduk_uint_t length;\n\tconst duk_uint8_t *str_data;\n\tduk_size_t str_len;\n\n\tthr = (duk_hthread *) ctx;\n\tDUK_UNREF(thr);\n\n\t/* XXX: very inefficient support for plain buffers */\n\th_this = duk__require_bufobj_this(ctx);\n\tDUK_ASSERT(h_this != NULL);\n\n\t/* Argument must be a string, e.g. a buffer is not allowed. */\n\tstr_data = (const duk_uint8_t *) duk_require_lstring_notsymbol(ctx, 0, &str_len);\n\n\tduk__resolve_offset_opt_length(ctx, h_this, 1, 2, &offset, &length, 0 /*throw_flag*/);\n\tDUK_ASSERT(offset <= h_this->length);\n\tDUK_ASSERT(offset + length <= h_this->length);\n\n\t/* XXX: encoding is ignored now. */\n\n\tif (length > str_len) {\n\t\tlength = (duk_uint_t) str_len;\n\t}\n\n\tif (DUK_HBUFOBJ_VALID_SLICE(h_this)) {\n\t\t/* Cannot overlap. */\n\t\tDUK_MEMCPY((void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + offset),\n\t\t           (const void *) str_data,\n\t\t           (size_t) length);\n\t} else {\n\t\tDUK_DDD(DUK_DDDPRINT(\"write() target buffer is not covered, silent ignore\"));\n\t}\n\n\tduk_push_uint(ctx, length);\n\treturn 1;\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/*\n *  Node.js Buffer.prototype.copy()\n */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_nodejs_buffer_copy(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_hbufobj *h_this;\n\tduk_hbufobj *h_bufarg;\n\tduk_int_t source_length;\n\tduk_int_t target_length;\n\tduk_int_t target_start, source_start, source_end;\n\tduk_uint_t target_ustart, source_ustart, source_uend;\n\tduk_uint_t copy_size = 0;\n\n\t/* [ targetBuffer targetStart sourceStart sourceEnd ] */\n\n\tthr = (duk_hthread *) ctx;\n\tDUK_UNREF(thr);\n\n\th_this = duk__require_bufobj_this(ctx);\n\th_bufarg = duk__require_bufobj_value(ctx, 0);\n\tDUK_ASSERT(h_this != NULL);\n\tDUK_ASSERT(h_bufarg != NULL);\n\tsource_length = (duk_int_t) h_this->length;\n\ttarget_length = (duk_int_t) h_bufarg->length;\n\n\ttarget_start = duk_to_int(ctx, 1);\n\tsource_start = duk_to_int(ctx, 2);\n\tif (duk_is_undefined(ctx, 3)) {\n\t\tsource_end = source_length;\n\t} else {\n\t\tsource_end = duk_to_int(ctx, 3);\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"checking copy args: target_start=%ld, target_length=%ld, \"\n\t                     \"source_start=%ld, source_end=%ld, source_length=%ld\",\n\t                     (long) target_start, (long) h_bufarg->length,\n\t                     (long) source_start, (long) source_end, (long) source_length));\n\n\t/* This behavior mostly mimics Node.js now. */\n\n\tif (source_start < 0 || source_end < 0 || target_start < 0) {\n\t\t/* Negative offsets cause a RangeError. */\n\t\tgoto fail_bounds;\n\t}\n\tsource_ustart = (duk_uint_t) source_start;\n\tsource_uend = (duk_uint_t) source_end;\n\ttarget_ustart = (duk_uint_t) target_start;\n\tif (source_ustart >= source_uend ||  /* crossed offsets or zero size */\n\t    source_ustart >= (duk_uint_t) source_length ||  /* source out-of-bounds (but positive) */\n\t    target_ustart >= (duk_uint_t) target_length) {  /* target out-of-bounds (but positive) */\n\t\tgoto silent_ignore;\n\t}\n\tif (source_uend >= (duk_uint_t) source_length) {\n\t\t/* Source end clamped silently to available length. */\n\t\tsource_uend = source_length;\n\t}\n\tcopy_size = source_uend - source_ustart;\n\tif (target_ustart + copy_size > (duk_uint_t) target_length) {\n\t\t/* Clamp to target's end if too long.\n\t\t *\n\t\t * NOTE: there's no overflow possibility in the comparison;\n\t\t * both target_ustart and copy_size are >= 0 and based on\n\t\t * values in duk_int_t range.  Adding them as duk_uint_t\n\t\t * values is then guaranteed not to overflow.\n\t\t */\n\t\tDUK_ASSERT(target_ustart + copy_size >= target_ustart);  /* no overflow */\n\t\tDUK_ASSERT(target_ustart + copy_size >= copy_size);  /* no overflow */\n\t\tcopy_size = (duk_uint_t) target_length - target_ustart;\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"making copy: target_ustart=%lu source_ustart=%lu copy_size=%lu\",\n\t                     (unsigned long) target_ustart, (unsigned long) source_ustart,\n\t                     (unsigned long) copy_size));\n\n\tDUK_ASSERT(copy_size >= 1);\n\tDUK_ASSERT(source_ustart <= (duk_uint_t) source_length);\n\tDUK_ASSERT(source_ustart + copy_size <= (duk_uint_t) source_length);\n\tDUK_ASSERT(target_ustart <= (duk_uint_t) target_length);\n\tDUK_ASSERT(target_ustart + copy_size <= (duk_uint_t) target_length);\n\n\t/* Ensure copy is covered by underlying buffers. */\n\tDUK_ASSERT(h_bufarg->buf != NULL);  /* length check */\n\tDUK_ASSERT(h_this->buf != NULL);    /* length check */\n\tif (DUK_HBUFOBJ_VALID_BYTEOFFSET_EXCL(h_bufarg, target_ustart + copy_size) &&\n\t    DUK_HBUFOBJ_VALID_BYTEOFFSET_EXCL(h_this, source_ustart + copy_size)) {\n\t\t/* Must use memmove() because copy area may overlap (source and target\n\t\t * buffer may be the same, or from different slices.\n\t\t */\n\t\tDUK_MEMMOVE((void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufarg) + target_ustart),\n\t\t            (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + source_ustart),\n\t\t            (size_t) copy_size);\n\t} else {\n\t\tDUK_DDD(DUK_DDDPRINT(\"buffer copy not covered by underlying buffer(s), ignoring\"));\n\t}\n\n silent_ignore:\n\t/* Return value is like write(), number of bytes written.\n\t * The return value matters because of code like:\n\t * \"off += buf.copy(...)\".\n         */\n\tduk_push_uint(ctx, copy_size);\n\treturn 1;\n\n fail_bounds:\n\tDUK_DCERROR_RANGE_INVALID_ARGS(thr);\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/*\n *  TypedArray.prototype.set()\n *\n *  TypedArray set() is pretty interesting to implement because:\n *\n *    - The source argument may be a plain array or a typedarray.  If the\n *      source is a TypedArray, values are decoded and re-encoded into the\n *      target (not as a plain byte copy).  This may happen even when the\n *      element byte size is the same, e.g. integer values may be re-encoded\n *      into floats.\n *\n *    - Source and target may refer to the same underlying buffer, so that\n *      the set() operation may overlap.  The specification requires that this\n *      must work as if a copy was made before the operation.  Note that this\n *      is NOT a simple memmove() situation because the source and target\n *      byte sizes may be different -- e.g. a 4-byte source (Int8Array) may\n *      expand to a 16-byte target (Uint32Array) so that the target overlaps\n *      the source both from beginning and the end (unlike in typical memmove).\n *\n *    - Even if 'buf' pointers of the source and target differ, there's no\n *      guarantee that their memory areas don't overlap.  This may be the\n *      case with external buffers.\n *\n *  Even so, it is nice to optimize for the common case:\n *\n *    - Source and target separate buffers or non-overlapping.\n *\n *    - Source and target have a compatible type so that a plain byte copy\n *      is possible.  Note that while e.g. uint8 and int8 are compatible\n *      (coercion one way or another doesn't change the byte representation),\n *      e.g. int8 and uint8clamped are NOT compatible when writing int8\n *      values into uint8clamped typedarray (-1 would clamp to 0 for instance).\n *\n *  See test-bi-typedarray-proto-set.js.\n */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_typedarray_set(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_hbufobj *h_this;\n\tduk_hobject *h_obj;\n\tduk_uarridx_t i, n;\n\tduk_int_t offset_signed;\n\tduk_uint_t offset_elems;\n\tduk_uint_t offset_bytes;\n\n\tthr = (duk_hthread *) ctx;\n\tDUK_UNREF(thr);\n\n\th_this = duk__require_bufobj_this(ctx);\n\tDUK_ASSERT(h_this != NULL);\n\tDUK_ASSERT_HBUFOBJ_VALID(h_this);\n\n\tif (h_this->buf == NULL) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"source neutered, skip copy\"));\n\t\treturn 0;\n\t}\n\n\tduk_hbufobj_promote_plain(ctx, 0);\n\th_obj = duk_require_hobject(ctx, 0);\n\n\t/* XXX: V8 throws a TypeError for negative values.  Would it\n\t * be more useful to interpret negative offsets here from the\n\t * end of the buffer too?\n\t */\n\toffset_signed = duk_to_int(ctx, 1);\n\tif (offset_signed < 0) {\n\t\t/* For some reason this is a TypeError (at least in V8). */\n\t\tDUK_DCERROR_TYPE_INVALID_ARGS(thr);\n\t}\n\toffset_elems = (duk_uint_t) offset_signed;\n\toffset_bytes = offset_elems << h_this->shift;\n\tif ((offset_bytes >> h_this->shift) != offset_elems) {\n\t\t/* Byte length would overflow. */\n\t\t/* XXX: easier check with less code? */\n\t\tgoto fail_args;\n\t}\n\tif (offset_bytes > h_this->length) {\n\t\t/* Equality may be OK but >length not.  Checking\n\t\t * this explicitly avoids some overflow cases\n\t\t * below.\n\t\t */\n\t\tgoto fail_args;\n\t}\n\tDUK_ASSERT(offset_bytes <= h_this->length);\n\n\t/* Fast path: source is a TypedArray (or any bufobj). */\n\n\tif (DUK_HOBJECT_IS_BUFOBJ(h_obj)) {\n\t\tduk_hbufobj *h_bufarg;\n#if !defined(DUK_USE_PREFER_SIZE)\n\t\tduk_uint16_t comp_mask;\n#endif\n\t\tduk_small_int_t no_overlap = 0;\n\t\tduk_uint_t src_length;\n\t\tduk_uint_t dst_length;\n\t\tduk_uint_t dst_length_elems;\n\t\tduk_uint8_t *p_src_base;\n\t\tduk_uint8_t *p_src_end;\n\t\tduk_uint8_t *p_src;\n\t\tduk_uint8_t *p_dst_base;\n\t\tduk_uint8_t *p_dst;\n\t\tduk_small_uint_t src_elem_size;\n\t\tduk_small_uint_t dst_elem_size;\n\n\t\th_bufarg = (duk_hbufobj *) h_obj;\n\t\tDUK_ASSERT_HBUFOBJ_VALID(h_bufarg);\n\n\t\tif (h_bufarg->buf == NULL) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"target neutered, skip copy\"));\n\t\t\treturn 0;\n\t\t}\n\n\t\t/* Nominal size check. */\n\t\tsrc_length = h_bufarg->length;  /* bytes in source */\n\t\tdst_length_elems = (src_length >> h_bufarg->shift);  /* elems in source and dest */\n\t\tdst_length = dst_length_elems << h_this->shift;  /* bytes in dest */\n\t\tif ((dst_length >> h_this->shift) != dst_length_elems) {\n\t\t\t/* Byte length would overflow. */\n\t\t\t/* XXX: easier check with less code? */\n\t\t\tgoto fail_args;\n\t\t}\n\t\tDUK_DDD(DUK_DDDPRINT(\"nominal size check: src_length=%ld, dst_length=%ld\",\n\t\t                     (long) src_length, (long) dst_length));\n\t\tDUK_ASSERT(offset_bytes <= h_this->length);\n\t\tif (dst_length > h_this->length - offset_bytes) {\n\t\t\t/* Overflow not an issue because subtraction is used on the right\n\t\t\t * side and guaranteed to be >= 0.\n\t\t\t */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"copy exceeds target buffer nominal length\"));\n\t\t\tgoto fail_args;\n\t\t}\n\t\tif (!DUK_HBUFOBJ_VALID_BYTEOFFSET_EXCL(h_this, offset_bytes + dst_length)) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"copy not covered by underlying target buffer, ignore\"));\n\t\t\treturn 0;\n\t\t}\n\n\t\tp_src_base = DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufarg);\n\t\tp_dst_base = DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + offset_bytes;\n\n\t\t/* Check actual underlying buffers for validity and that they\n\t\t * cover the copy.  No side effects are allowed after the check\n\t\t * so that the validity status doesn't change.\n\t\t */\n\t\tif (!DUK_HBUFOBJ_VALID_SLICE(h_this) ||\n\t\t    !DUK_HBUFOBJ_VALID_SLICE(h_bufarg)) {\n\t\t\t/* The condition could be more narrow and check for the\n\t\t\t * copy area only, but there's no need for fine grained\n\t\t\t * behavior when the underlying buffer is misconfigured.\n\t\t\t */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"source and/or target not covered by underlying buffer, skip copy\"));\n\t\t\treturn 0;\n\t\t}\n\n\t\t/* We want to do a straight memory copy if possible: this is\n\t\t * an important operation because .set() is the TypedArray\n\t\t * way to copy chunks of memory.  However, because set()\n\t\t * conceptually works in terms of elements, not all views are\n\t\t * compatible with direct byte copying.\n\t\t *\n\t\t * If we do manage a direct copy, the \"overlap issue\" handled\n\t\t * below can just be solved using memmove() because the source\n\t\t * and destination element sizes are necessarily equal.\n\t\t */\n\n#if !defined(DUK_USE_PREFER_SIZE)\n\t\tDUK_ASSERT(h_this->elem_type < sizeof(duk__buffer_elemtype_copy_compatible) / sizeof(duk_uint16_t));\n\t\tcomp_mask = duk__buffer_elemtype_copy_compatible[h_this->elem_type];\n\t\tif (comp_mask & (1 << h_bufarg->elem_type)) {\n\t\t\tDUK_ASSERT(src_length == dst_length);\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"fast path: able to use memmove() because views are compatible\"));\n\t\t\tDUK_MEMMOVE((void *) p_dst_base, (const void *) p_src_base, (size_t) dst_length);\n\t\t\treturn 0;\n\t\t}\n\t\tDUK_DDD(DUK_DDDPRINT(\"fast path: views are not compatible with a byte copy, copy by item\"));\n#endif  /* !DUK_USE_PREFER_SIZE */\n\n\t\t/* We want to avoid making a copy to process set() but that's\n\t\t * not always possible: the source and the target may overlap\n\t\t * and because element sizes are different, the overlap cannot\n\t\t * always be handled with a memmove() or choosing the copy\n\t\t * direction in a certain way.  For example, if source type is\n\t\t * uint8 and target type is uint32, the target area may exceed\n\t\t * the source area from both ends!\n\t\t *\n\t\t * Note that because external buffers may point to the same\n\t\t * memory areas, we must ultimately make this check using\n\t\t * pointers.\n\t\t *\n\t\t * NOTE: careful with side effects: any side effect may cause\n\t\t * a buffer resize (or external buffer pointer/length update)!\n\t\t */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"overlap check: p_src_base=%p, src_length=%ld, \"\n\t\t                     \"p_dst_base=%p, dst_length=%ld\",\n\t\t                     (void *) p_src_base, (long) src_length,\n\t\t                     (void *) p_dst_base, (long) dst_length));\n\n\t\tif (p_src_base >= p_dst_base + dst_length ||  /* source starts after dest ends */\n\t\t    p_src_base + src_length <= p_dst_base) {   /* source ends before dest starts */\n\t\t\tno_overlap = 1;\n\t\t}\n\n\t\tif (!no_overlap) {\n\t\t\t/* There's overlap: the desired end result is that\n\t\t\t * conceptually a copy is made to avoid \"trampling\"\n\t\t\t * of source data by destination writes.  We make\n\t\t\t * an actual temporary copy to handle this case.\n\t\t\t */\n\t\t\tduk_uint8_t *p_src_copy;\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"there is overlap, make a copy of the source\"));\n\t\t\tp_src_copy = (duk_uint8_t *) duk_push_fixed_buffer_nozero(ctx, src_length);\n\t\t\tDUK_ASSERT(p_src_copy != NULL);\n\t\t\tDUK_MEMCPY((void *) p_src_copy, (const void *) p_src_base, (size_t) src_length);\n\n\t\t\tp_src_base = p_src_copy;  /* use p_src_base from now on */\n\t\t}\n\t\t/* Value stack intentionally mixed size here. */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"after overlap check: p_src_base=%p, src_length=%ld, \"\n\t\t                     \"p_dst_base=%p, dst_length=%ld, valstack top=%ld\",\n\t\t                     (void *) p_src_base, (long) src_length,\n\t\t                     (void *) p_dst_base, (long) dst_length,\n\t\t                     (long) duk_get_top(ctx)));\n\n\t\t/* Ready to make the copy.  We must proceed element by element\n\t\t * and must avoid any side effects that might cause the buffer\n\t\t * validity check above to become invalid.\n\t\t *\n\t\t * Although we work through the value stack here, only plain\n\t\t * numbers are handled which should be side effect safe.\n\t\t */\n\n\t\tsrc_elem_size = 1 << h_bufarg->shift;\n\t\tdst_elem_size = 1 << h_this->shift;\n\t\tp_src = p_src_base;\n\t\tp_dst = p_dst_base;\n\t\tp_src_end = p_src_base + src_length;\n\n\t\twhile (p_src != p_src_end) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"fast path per element copy loop: \"\n\t\t\t                     \"p_src=%p, p_src_end=%p, p_dst=%p\",\n\t\t\t                     (void *) p_src, (void *) p_src_end, (void *) p_dst));\n\t\t\t/* A validated read() is always a number, so it's write coercion\n\t\t\t * is always side effect free an won't invalidate pointers etc.\n\t\t\t */\n\t\t\tduk_hbufobj_push_validated_read(ctx, h_bufarg, p_src, src_elem_size);\n\t\t\tduk_hbufobj_validated_write(ctx, h_this, p_dst, dst_elem_size);\n\t\t\tduk_pop(ctx);\n\t\t\tp_src += src_elem_size;\n\t\t\tp_dst += dst_elem_size;\n\t\t}\n\n\t\treturn 0;\n\t} else {\n\t\t/* Slow path: quite slow, but we save space by using the property code\n\t\t * to write coerce target values.  We don't need to worry about overlap\n\t\t * here because the source is not a TypedArray.\n\t\t *\n\t\t * We could use the bufobj write coercion helper but since the\n\t\t * property read may have arbitrary side effects, full validity checks\n\t\t * would be needed for every element anyway.\n\t\t */\n\n\t\tn = (duk_uarridx_t) duk_get_length(ctx, 0);\n\t\tDUK_ASSERT(offset_bytes <= h_this->length);\n\t\tif ((n << h_this->shift) > h_this->length - offset_bytes) {\n\t\t\t/* Overflow not an issue because subtraction is used on the right\n\t\t\t * side and guaranteed to be >= 0.\n\t\t\t */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"copy exceeds target buffer nominal length\"));\n\t\t\tgoto fail_args;\n\t\t}\n\n\t\t/* There's no need to check for buffer validity status for the\n\t\t * target here: the property access code will do that for each\n\t\t * element.  Moreover, if we did check the validity here, side\n\t\t * effects from reading the source argument might invalidate\n\t\t * the results anyway.\n\t\t */\n\n\t\tDUK_ASSERT_TOP(ctx, 2);\n\t\tduk_push_this(ctx);\n\n\t\tfor (i = 0; i < n; i++) {\n\t\t\tduk_get_prop_index(ctx, 0, i);\n\t\t\tduk_put_prop_index(ctx, 2, offset_elems + i);\n\t\t}\n\t}\n\n\treturn 0;\n\n fail_args:\n\tDUK_DCERROR_RANGE_INVALID_ARGS(thr);\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/*\n *  Node.js Buffer.prototype.slice([start], [end])\n *  ArrayBuffer.prototype.slice(begin, [end])\n *  TypedArray.prototype.subarray(begin, [end])\n *\n *  The API calls are almost identical; negative indices are counted from end\n *  of buffer, and final indices are clamped (allowing crossed indices).  Main\n *  differences:\n *\n *    - Copy/view behavior; Node.js .slice() and TypedArray .subarray() create\n *      views, ArrayBuffer .slice() creates a copy\n *\n *    - Resulting object has a different class and prototype depending on the\n *      call (or 'this' argument)\n *\n *    - TypedArray .subarray() arguments are element indices, not byte offsets\n *\n *    - Plain buffer argument creates a plain buffer slice\n */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_LOCAL void duk__arraybuffer_plain_slice(duk_context *ctx, duk_hbuffer *h_val) {\n\tduk_hthread *thr;\n\tduk_int_t start_offset, end_offset;\n\tduk_uint_t slice_length;\n\tduk_uint8_t *p_copy;\n\tduk_size_t copy_length;\n\n\tthr = (duk_hthread *) ctx;\n\tDUK_UNREF(thr);\n\n\tduk__clamp_startend_negidx_shifted(ctx,\n\t                                   (duk_int_t) DUK_HBUFFER_GET_SIZE(h_val),\n\t                                   0 /*buffer_shift*/,\n\t                                   0 /*idx_start*/,\n\t                                   1 /*idx_end*/,\n\t                                   &start_offset,\n\t                                   &end_offset);\n\tDUK_ASSERT(end_offset <= (duk_int_t) DUK_HBUFFER_GET_SIZE(h_val));\n\tDUK_ASSERT(start_offset >= 0);\n\tDUK_ASSERT(end_offset >= start_offset);\n\tslice_length = (duk_uint_t) (end_offset - start_offset);\n\n\tp_copy = (duk_uint8_t *) duk_push_fixed_buffer_nozero(ctx, (duk_size_t) slice_length);\n\tDUK_ASSERT(p_copy != NULL);\n\tcopy_length = slice_length;\n\n\tDUK_MEMCPY((void *) p_copy,\n\t           (const void *) ((duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_val) + start_offset),\n\t           copy_length);\n}\n#endif /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n/* Shared helper for slice/subarray operation.\n * Magic: 0x01=isView, 0x02=copy, 0x04=Node.js Buffer special handling.\n */\nDUK_INTERNAL duk_ret_t duk_bi_buffer_slice_shared(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_small_int_t magic;\n\tduk_small_uint_t res_class_num;\n\tduk_small_int_t res_proto_bidx;\n\tduk_hbufobj *h_this;\n\tduk_hbufobj *h_bufobj;\n\tduk_hbuffer *h_val;\n\tduk_int_t start_offset, end_offset;\n\tduk_uint_t slice_length;\n\tduk_tval *tv;\n\n\tthr = (duk_hthread *) ctx;\n\tDUK_UNREF(thr);\n\n\t/* [ start end ] */\n\n\tmagic = duk_get_current_magic(ctx);\n\n\ttv = duk_get_borrowed_this_tval(ctx);\n\tDUK_ASSERT(tv != NULL);\n\n\tif (DUK_TVAL_IS_BUFFER(tv)) {\n\t\t/* For plain buffers return a plain buffer slice. */\n\t\th_val = DUK_TVAL_GET_BUFFER(tv);\n\t\tDUK_ASSERT(h_val != NULL);\n\n\t\tif (magic & 0x02) {\n\t\t\t/* Make copy: ArrayBuffer.prototype.slice() uses this. */\n\t\t\tduk__arraybuffer_plain_slice(ctx, h_val);\n\t\t\treturn 1;\n\t\t} else {\n\t\t\t/* View into existing buffer: cannot be done if the\n\t\t\t * result is a plain buffer because there's no slice\n\t\t\t * info.  So return an ArrayBuffer instance; coerce\n\t\t\t * the 'this' binding into an object and behave as if\n\t\t\t * the original call was for an Object-coerced plain\n\t\t\t * buffer (handled automatically by duk__require_bufobj_this()).\n\t\t\t */\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"slice() doesn't handle view into plain buffer, coerce 'this' to ArrayBuffer object\"));\n\t\t\t/* fall through */\n\t\t}\n\t}\n\ttv = NULL;  /* No longer valid nor needed. */\n\n\th_this = duk__require_bufobj_this(ctx);\n\n\t/* Slice offsets are element (not byte) offsets, which only matters\n\t * for TypedArray views, Node.js Buffer and ArrayBuffer have shift\n\t * zero so byte and element offsets are the same.  Negative indices\n\t * are counted from end of slice, crossed indices are allowed (and\n\t * result in zero length result), and final values are clamped\n\t * against the current slice.  There's intentionally no check\n\t * against the underlying buffer here.\n\t */\n\n\tduk__clamp_startend_negidx_shifted(ctx,\n\t                                   (duk_int_t) h_this->length,\n\t                                   (duk_uint8_t) h_this->shift,\n\t                                   0 /*idx_start*/,\n\t                                   1 /*idx_end*/,\n\t                                   &start_offset,\n\t                                   &end_offset);\n\tDUK_ASSERT(end_offset >= start_offset);\n\tslice_length = (duk_uint_t) (end_offset - start_offset);\n\n\t/* The resulting buffer object gets the same class and prototype as\n\t * the buffer in 'this', e.g. if the input is a Uint8Array the\n\t * result is a Uint8Array; if the input is a Float32Array, the\n\t * result is a Float32Array.  The result internal prototype should\n\t * be the default prototype for the class (e.g. initial value of\n\t * Uint8Array.prototype), not copied from the argument (Duktape 1.x\n\t * did that).\n\t *\n\t * Node.js Buffers have special handling: they're Uint8Arrays as far\n\t * as the internal class is concerned, so the new Buffer should also\n\t * be an Uint8Array but inherit from Buffer.prototype.\n\t */\n\tres_class_num = DUK_HOBJECT_GET_CLASS_NUMBER((duk_hobject *) h_this);\n\tDUK_ASSERT(res_class_num >= DUK_HOBJECT_CLASS_BUFOBJ_MIN);  /* type check guarantees */\n\tDUK_ASSERT(res_class_num <= DUK_HOBJECT_CLASS_BUFOBJ_MAX);\n\tres_proto_bidx = duk__buffer_proto_from_classnum[res_class_num - DUK_HOBJECT_CLASS_BUFOBJ_MIN];\n\tif (magic & 0x04) {\n\t\tres_proto_bidx = DUK_BIDX_NODEJS_BUFFER_PROTOTYPE;\n\t}\n\th_bufobj = duk_push_bufobj_raw(ctx,\n\t                               DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                               DUK_HOBJECT_FLAG_BUFOBJ |\n\t                               DUK_HOBJECT_CLASS_AS_FLAGS(res_class_num),\n\t                               res_proto_bidx);\n\tDUK_ASSERT(h_bufobj != NULL);\n\n\th_bufobj->length = slice_length;\n\th_bufobj->shift = h_this->shift;  /* inherit */\n\th_bufobj->elem_type = h_this->elem_type;  /* inherit */\n\th_bufobj->is_typedarray = magic & 0x01;\n\tDUK_ASSERT(h_bufobj->is_typedarray == 0 || h_bufobj->is_typedarray == 1);\n\n\th_val = h_this->buf;\n\tif (h_val == NULL) {\n\t\tDUK_DCERROR_TYPE_INVALID_ARGS(thr);\n\t}\n\n\tif (magic & 0x02) {\n\t\t/* non-zero: make copy */\n\t\tduk_uint8_t *p_copy;\n\t\tduk_size_t copy_length;\n\n\t\tp_copy = (duk_uint8_t *) duk_push_fixed_buffer_zero(ctx, (duk_size_t) slice_length);  /* must be zeroed, not all bytes always copied */\n\t\tDUK_ASSERT(p_copy != NULL);\n\n\t\t/* Copy slice, respecting underlying buffer limits; remainder\n\t\t * is left as zero.\n\t\t */\n\t\tcopy_length = DUK_HBUFOBJ_CLAMP_BYTELENGTH(h_this, slice_length);\n\t\tDUK_MEMCPY((void *) p_copy,\n\t\t           (const void *) (DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this) + start_offset),\n\t\t           copy_length);\n\n\t\th_val = duk_known_hbuffer(ctx, -1);\n\n\t\th_bufobj->buf = h_val;\n\t\tDUK_HBUFFER_INCREF(thr, h_val);\n\t\tDUK_ASSERT(h_bufobj->offset == 0);\n\n\t\tduk_pop(ctx);  /* reachable so pop OK */\n\t} else {\n\t\th_bufobj->buf = h_val;\n\t\tDUK_HBUFFER_INCREF(thr, h_val);\n\t\th_bufobj->offset = (duk_uint_t) (h_this->offset + start_offset);\n\n\t\t/* Copy the .buffer property, needed for TypedArray.prototype.subarray().\n\t\t *\n\t\t * XXX: limit copy only for TypedArray classes specifically?\n\t\t */\n\n\t\tDUK_ASSERT(h_bufobj->buf_prop == NULL);\n\t\th_bufobj->buf_prop = h_this->buf_prop;  /* may be NULL */\n\t\tDUK_HOBJECT_INCREF_ALLOWNULL(thr, (duk_hobject *) h_bufobj->buf_prop);\n\t}\n\t/* unbalanced stack on purpose */\n\n\tDUK_ASSERT_HBUFOBJ_VALID(h_bufobj);\n\treturn 1;\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/*\n *  Node.js Buffer.isEncoding()\n */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_nodejs_buffer_is_encoding(duk_context *ctx) {\n\tconst char *encoding;\n\n\t/* only accept lowercase 'utf8' now. */\n\n\tencoding = duk_to_string(ctx, 0);\n\tDUK_ASSERT(duk_is_string(ctx, 0));  /* guaranteed by duk_to_string() */\n\tduk_push_boolean(ctx, DUK_STRCMP(encoding, \"utf8\") == 0);\n\treturn 1;\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/*\n *  Node.js Buffer.isBuffer()\n */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_nodejs_buffer_is_buffer(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_hobject *h;\n\tduk_hobject *h_proto;\n\tduk_bool_t ret = 0;\n\n\tthr = (duk_hthread *) ctx;\n\n\tDUK_ASSERT(duk_get_top(ctx) >= 1);  /* nargs */\n\th = duk_get_hobject(ctx, 0);\n\tif (h != NULL) {\n\t\th_proto = thr->builtins[DUK_BIDX_NODEJS_BUFFER_PROTOTYPE];\n\t\tDUK_ASSERT(h_proto != NULL);\n\n\t\th = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h);\n\t\tif (h != NULL) {\n\t\t\tret = duk_hobject_prototype_chain_contains(thr, h, h_proto, 0 /*ignore_loop*/);\n\t\t}\n\t}\n\n\tduk_push_boolean(ctx, ret);\n\treturn 1;\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/*\n *  Node.js Buffer.byteLength()\n */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_nodejs_buffer_byte_length(duk_context *ctx) {\n\tconst char *str;\n\tduk_size_t len;\n\n\t/* At the moment Buffer(<str>) will just use the string bytes as\n\t * is (ignoring encoding), so we return the string length here\n\t * unconditionally.\n\t */\n\n\t/* XXX: to be revised; Old Node.js behavior just coerces any buffer\n\t * values to string:\n\t * $ node\n\t * > Buffer.byteLength(new Uint32Array(10))\n\t * 20\n\t * > Buffer.byteLength(new Uint32Array(100))\n\t * 20\n\t * (The 20 comes from '[object Uint32Array]'.length\n\t */\n\n\tstr = duk_to_lstring(ctx, 0, &len);\n\tDUK_UNREF(str);\n\tduk_push_size_t(ctx, len);\n\treturn 1;\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/*\n *  Node.js Buffer.concat()\n */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_nodejs_buffer_concat(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_hobject *h_arg;\n\tduk_int_t total_length = 0;\n\tduk_hbufobj *h_bufobj;\n\tduk_hbufobj *h_bufres;\n\tduk_hbuffer *h_val;\n\tduk_uint_t i, n;\n\tduk_uint8_t *p;\n\tduk_size_t space_left;\n\tduk_size_t copy_size;\n\n\tthr = (duk_hthread *) ctx;\n\tDUK_UNREF(thr);\n\n\t/* Node.js accepts only actual Arrays. */\n\th_arg = duk_require_hobject(ctx, 0);\n\tif (DUK_HOBJECT_GET_CLASS_NUMBER(h_arg) != DUK_HOBJECT_CLASS_ARRAY) {\n\t\tDUK_DCERROR_TYPE_INVALID_ARGS(thr);\n\t}\n\n\t/* Compute result length and validate argument buffers. */\n\tn = (duk_uint_t) duk_get_length(ctx, 0);\n\tfor (i = 0; i < n; i++) {\n\t\t/* Neutered checks not necessary here: neutered buffers have\n\t\t * zero 'length' so we'll effectively skip them.\n\t\t */\n\t\tDUK_ASSERT_TOP(ctx, 2);  /* [ array totalLength ] */\n\t\tduk_get_prop_index(ctx, 0, (duk_uarridx_t) i);  /* -> [ array totalLength buf ] */\n\t\th_bufobj = duk__require_bufobj_value(ctx, 2);\n\t\tDUK_ASSERT(h_bufobj != NULL);\n\t\ttotal_length += h_bufobj->length;\n\t\tduk_pop(ctx);\n\t}\n\t/* In Node.js v0.12.1 a 1-element array is special and won't create a\n\t * copy, this was fixed later so an explicit check no longer needed.\n\t */\n\n\t/* User totalLength overrides a computed length, but we'll check\n\t * every copy in the copy loop.  Note that duk_to_uint() can\n\t * technically have arbitrary side effects so we need to recheck\n\t * the buffers in the copy loop.\n\t */\n\tif (!duk_is_undefined(ctx, 1) && n > 0) {\n\t\t/* For n == 0, Node.js ignores totalLength argument and\n\t\t * returns a zero length buffer.\n\t\t */\n\t\ttotal_length = duk_to_int(ctx, 1);\n\t}\n\tif (total_length < 0) {\n\t\tDUK_DCERROR_RANGE_INVALID_ARGS(thr);\n\t}\n\n\th_bufres = duk_push_bufobj_raw(ctx,\n\t                               DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                               DUK_HOBJECT_FLAG_BUFOBJ |\n\t                               DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_UINT8ARRAY),\n\t                               DUK_BIDX_NODEJS_BUFFER_PROTOTYPE);\n\tDUK_ASSERT(h_bufres != NULL);\n\n\tp = (duk_uint8_t *) duk_push_fixed_buffer_zero(ctx, total_length);  /* must be zeroed, all bytes not necessarily written over */\n\tDUK_ASSERT(p != NULL);\n\tspace_left = total_length;\n\n\tfor (i = 0; i < n; i++) {\n\t\tDUK_ASSERT_TOP(ctx, 4);  /* [ array totalLength bufres buf ] */\n\n\t\tduk_get_prop_index(ctx, 0, (duk_uarridx_t) i);\n\t\th_bufobj = duk__require_bufobj_value(ctx, 4);\n\t\tDUK_ASSERT(h_bufobj != NULL);\n\n\t\tcopy_size = h_bufobj->length;\n\t\tif (copy_size > space_left) {\n\t\t\tcopy_size = space_left;\n\t\t}\n\n\t\tif (h_bufobj->buf != NULL &&\n\t\t    DUK_HBUFOBJ_VALID_SLICE(h_bufobj)) {\n\t\t\tDUK_MEMCPY((void *) p,\n\t\t\t           (const void *) DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_bufobj),\n\t\t\t           copy_size);\n\t\t} else {\n\t\t\t/* Just skip, leaving zeroes in the result. */\n\t\t\t;\n\t\t}\n\t\tp += copy_size;\n\t\tspace_left -= copy_size;\n\n\t\tduk_pop(ctx);\n\t}\n\n\th_val = duk_known_hbuffer(ctx, -1);\n\n\tduk__set_bufobj_buffer(ctx, h_bufres, h_val);\n\th_bufres->is_typedarray = 1;\n\tDUK_ASSERT_HBUFOBJ_VALID(h_bufres);\n\n\tduk_pop(ctx);  /* pop plain buffer, now reachable through h_bufres */\n\n\treturn 1;  /* return h_bufres */\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/*\n *  Shared readfield and writefield methods\n *\n *  The readfield/writefield methods need support for endianness and field\n *  types.  All offsets are byte based so no offset shifting is needed.\n */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n/* Format of magic, bits:\n *   0...1: field type; 0=uint8, 1=uint16, 2=uint32, 3=float, 4=double, 5=unused, 6=unused, 7=unused\n *       3: endianness: 0=little, 1=big\n *       4: signed: 1=yes, 0=no\n *       5: typedarray: 1=yes, 0=no\n */\n#define  DUK__FLD_8BIT         0\n#define  DUK__FLD_16BIT        1\n#define  DUK__FLD_32BIT        2\n#define  DUK__FLD_FLOAT        3\n#define  DUK__FLD_DOUBLE       4\n#define  DUK__FLD_VARINT       5\n#define  DUK__FLD_BIGENDIAN    (1 << 3)\n#define  DUK__FLD_SIGNED       (1 << 4)\n#define  DUK__FLD_TYPEDARRAY   (1 << 5)\n\n/* XXX: split into separate functions for each field type? */\nDUK_INTERNAL duk_ret_t duk_bi_buffer_readfield(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_small_int_t magic = (duk_small_int_t) duk_get_current_magic(ctx);\n\tduk_small_int_t magic_ftype;\n\tduk_small_int_t magic_bigendian;\n\tduk_small_int_t magic_signed;\n\tduk_small_int_t magic_typedarray;\n\tduk_small_int_t endswap;\n\tduk_hbufobj *h_this;\n\tduk_bool_t no_assert;\n\tduk_int_t offset_signed;\n\tduk_uint_t offset;\n\tduk_uint_t buffer_length;\n\tduk_uint_t check_length;\n\tduk_uint8_t *buf;\n\tduk_double_union du;\n\n\tthr = (duk_hthread *) ctx;\n\tDUK_UNREF(thr);\n\n\tmagic_ftype = magic & 0x0007;\n\tmagic_bigendian = magic & 0x0008;\n\tmagic_signed = magic & 0x0010;\n\tmagic_typedarray = magic & 0x0020;\n\n\th_this = duk__require_bufobj_this(ctx);  /* XXX: very inefficient for plain buffers */\n\tDUK_ASSERT(h_this != NULL);\n\tbuffer_length = h_this->length;\n\n\t/* [ offset noAssert                 ], when ftype != DUK__FLD_VARINT */\n\t/* [ offset fieldByteLength noAssert ], when ftype == DUK__FLD_VARINT */\n\t/* [ offset littleEndian             ], when DUK__FLD_TYPEDARRAY (regardless of ftype) */\n\n\t/* Handle TypedArray vs. Node.js Buffer arg differences */\n\tif (magic_typedarray) {\n\t\tno_assert = 0;\n#if defined(DUK_USE_INTEGER_LE)\n\t\tendswap = !duk_to_boolean(ctx, 1);  /* 1=little endian */\n#else\n\t\tendswap = duk_to_boolean(ctx, 1);  /* 1=little endian */\n#endif\n\t} else {\n\t\tno_assert = duk_to_boolean(ctx, (magic_ftype == DUK__FLD_VARINT) ? 2 : 1);\n#if defined(DUK_USE_INTEGER_LE)\n\t\tendswap = magic_bigendian;\n#else\n\t\tendswap = !magic_bigendian;\n#endif\n\t}\n\n\t/* Offset is coerced first to signed integer range and then to unsigned.\n\t * This ensures we can add a small byte length (1-8) to the offset in\n\t * bound checks and not wrap.\n\t */\n\toffset_signed = duk_to_int(ctx, 0);\n\toffset = (duk_uint_t) offset_signed;\n\tif (offset_signed < 0) {\n\t\tgoto fail_bounds;\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"readfield, buffer_length=%ld, offset=%ld, no_assert=%d, \"\n\t                     \"magic=%04x, magic_fieldtype=%d, magic_bigendian=%d, magic_signed=%d, \"\n\t                     \"endswap=%d\",\n\t                     (long) buffer_length, (long) offset, (int) no_assert,\n\t                     (unsigned int) magic, (int) magic_ftype, (int) (magic_bigendian >> 3),\n\t                     (int) (magic_signed >> 4), (int) endswap));\n\n\t/* Update 'buffer_length' to be the effective, safe limit which\n\t * takes into account the underlying buffer.  This value will be\n\t * potentially invalidated by any side effect.\n\t */\n\tcheck_length = DUK_HBUFOBJ_CLAMP_BYTELENGTH(h_this, buffer_length);\n\tDUK_DDD(DUK_DDDPRINT(\"buffer_length=%ld, check_length=%ld\",\n\t                     (long) buffer_length, (long) check_length));\n\n\tif (h_this->buf) {\n\t\tbuf = DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this);\n\t} else {\n\t\t/* Neutered.  We could go into the switch-case safely with\n\t\t * buf == NULL because check_length == 0.  To avoid scanbuild\n\t\t * warnings, fail directly instead.\n\t\t */\n\t\tDUK_ASSERT(check_length == 0);\n\t\tgoto fail_neutered;\n\t}\n\tDUK_ASSERT(buf != NULL);\n\n\tswitch (magic_ftype) {\n\tcase DUK__FLD_8BIT: {\n\t\tduk_uint8_t tmp;\n\t\tif (offset + 1U > check_length) {\n\t\t\tgoto fail_bounds;\n\t\t}\n\t\ttmp = buf[offset];\n\t\tif (magic_signed) {\n\t\t\tduk_push_int(ctx, (duk_int_t) ((duk_int8_t) tmp));\n\t\t} else {\n\t\t\tduk_push_uint(ctx, (duk_uint_t) tmp);\n\t\t}\n\t\tbreak;\n\t}\n\tcase DUK__FLD_16BIT: {\n\t\tduk_uint16_t tmp;\n\t\tif (offset + 2U > check_length) {\n\t\t\tgoto fail_bounds;\n\t\t}\n\t\tDUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 2);\n\t\ttmp = du.us[0];\n\t\tif (endswap) {\n\t\t\ttmp = DUK_BSWAP16(tmp);\n\t\t}\n\t\tif (magic_signed) {\n\t\t\tduk_push_int(ctx, (duk_int_t) ((duk_int16_t) tmp));\n\t\t} else {\n\t\t\tduk_push_uint(ctx, (duk_uint_t) tmp);\n\t\t}\n\t\tbreak;\n\t}\n\tcase DUK__FLD_32BIT: {\n\t\tduk_uint32_t tmp;\n\t\tif (offset + 4U > check_length) {\n\t\t\tgoto fail_bounds;\n\t\t}\n\t\tDUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 4);\n\t\ttmp = du.ui[0];\n\t\tif (endswap) {\n\t\t\ttmp = DUK_BSWAP32(tmp);\n\t\t}\n\t\tif (magic_signed) {\n\t\t\tduk_push_int(ctx, (duk_int_t) ((duk_int32_t) tmp));\n\t\t} else {\n\t\t\tduk_push_uint(ctx, (duk_uint_t) tmp);\n\t\t}\n\t\tbreak;\n\t}\n\tcase DUK__FLD_FLOAT: {\n\t\tduk_uint32_t tmp;\n\t\tif (offset + 4U > check_length) {\n\t\t\tgoto fail_bounds;\n\t\t}\n\t\tDUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 4);\n\t\tif (endswap) {\n\t\t\ttmp = du.ui[0];\n\t\t\ttmp = DUK_BSWAP32(tmp);\n\t\t\tdu.ui[0] = tmp;\n\t\t}\n\t\tduk_push_number(ctx, (duk_double_t) du.f[0]);\n\t\tbreak;\n\t}\n\tcase DUK__FLD_DOUBLE: {\n\t\tif (offset + 8U > check_length) {\n\t\t\tgoto fail_bounds;\n\t\t}\n\t\tDUK_MEMCPY((void *) du.uc, (const void *) (buf + offset), 8);\n\t\tif (endswap) {\n\t\t\tDUK_DBLUNION_BSWAP64(&du);\n\t\t}\n\t\tduk_push_number(ctx, (duk_double_t) du.d);\n\t\tbreak;\n\t}\n\tcase DUK__FLD_VARINT: {\n\t\t/* Node.js Buffer variable width integer field.  We don't really\n\t\t * care about speed here, so aim for shortest algorithm.\n\t\t */\n\t\tduk_int_t field_bytelen;\n\t\tduk_int_t i, i_step, i_end;\n#if defined(DUK_USE_64BIT_OPS)\n\t\tduk_int64_t tmp;\n\t\tduk_small_uint_t shift_tmp;\n#else\n\t\tduk_double_t tmp;\n\t\tduk_small_int_t highbyte;\n#endif\n\t\tconst duk_uint8_t *p;\n\n\t\tfield_bytelen = duk_get_int(ctx, 1);  /* avoid side effects! */\n\t\tif (field_bytelen < 1 || field_bytelen > 6) {\n\t\t\tgoto fail_field_length;\n\t\t}\n\t\tif (offset + (duk_uint_t) field_bytelen > check_length) {\n\t\t\tgoto fail_bounds;\n\t\t}\n\t\tp = (const duk_uint8_t *) (buf + offset);\n\n\t\t/* Slow gathering of value using either 64-bit arithmetic\n\t\t * or IEEE doubles if 64-bit types not available.  Handling\n\t\t * of negative numbers is a bit non-obvious in both cases.\n\t\t */\n\n\t\tif (magic_bigendian) {\n\t\t\t/* Gather in big endian */\n\t\t\ti = 0;\n\t\t\ti_step = 1;\n\t\t\ti_end = field_bytelen;  /* one i_step over */\n\t\t} else {\n\t\t\t/* Gather in little endian */\n\t\t\ti = field_bytelen - 1;\n\t\t\ti_step = -1;\n\t\t\ti_end = -1;  /* one i_step over */\n\t\t}\n\n#if defined(DUK_USE_64BIT_OPS)\n\t\ttmp = 0;\n\t\tdo {\n\t\t\tDUK_ASSERT(i >= 0 && i < field_bytelen);\n\t\t\ttmp = (tmp << 8) + (duk_int64_t) p[i];\n\t\t\ti += i_step;\n\t\t} while (i != i_end);\n\n\t\tif (magic_signed) {\n\t\t\t/* Shift to sign extend. */\n\t\t\tshift_tmp = 64 - (field_bytelen * 8);\n\t\t\ttmp = (tmp << shift_tmp) >> shift_tmp;\n\t\t}\n\n\t\tduk_push_i64(ctx, tmp);\n#else\n\t\thighbyte = p[i];\n\t\tif (magic_signed && (highbyte & 0x80) != 0) {\n\t\t\t/* 0xff => 255 - 256 = -1; 0x80 => 128 - 256 = -128 */\n\t\t\ttmp = (duk_double_t) (highbyte - 256);\n\t\t} else {\n\t\t\ttmp = (duk_double_t) highbyte;\n\t\t}\n\t\tfor (;;) {\n\t\t\ti += i_step;\n\t\t\tif (i == i_end) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tDUK_ASSERT(i >= 0 && i < field_bytelen);\n\t\t\ttmp = (tmp * 256.0) + (duk_double_t) p[i];\n\t\t}\n\n\t\tduk_push_number(ctx, tmp);\n#endif\n\t\tbreak;\n\t}\n\tdefault: {  /* should never happen but default here */\n\t\tgoto fail_bounds;\n\t}\n\t}\n\n\treturn 1;\n\n fail_neutered:\n fail_field_length:\n fail_bounds:\n\tif (no_assert) {\n\t\t/* Node.js return value for noAssert out-of-bounds reads is\n\t\t * usually (but not always) NaN.  Return NaN consistently.\n\t\t */\n\t\tduk_push_nan(ctx);\n\t\treturn 1;\n\t}\n\tDUK_DCERROR_RANGE_INVALID_ARGS(thr);\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n/* XXX: split into separate functions for each field type? */\nDUK_INTERNAL duk_ret_t duk_bi_buffer_writefield(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_small_int_t magic = (duk_small_int_t) duk_get_current_magic(ctx);\n\tduk_small_int_t magic_ftype;\n\tduk_small_int_t magic_bigendian;\n\tduk_small_int_t magic_signed;\n\tduk_small_int_t magic_typedarray;\n\tduk_small_int_t endswap;\n\tduk_hbufobj *h_this;\n\tduk_bool_t no_assert;\n\tduk_int_t offset_signed;\n\tduk_uint_t offset;\n\tduk_uint_t buffer_length;\n\tduk_uint_t check_length;\n\tduk_uint8_t *buf;\n\tduk_double_union du;\n\tduk_int_t nbytes = 0;\n\n\tthr = (duk_hthread *) ctx;\n\tDUK_UNREF(thr);\n\n\tmagic_ftype = magic & 0x0007;\n\tmagic_bigendian = magic & 0x0008;\n\tmagic_signed = magic & 0x0010;\n\tmagic_typedarray = magic & 0x0020;\n\tDUK_UNREF(magic_signed);\n\n\th_this = duk__require_bufobj_this(ctx);  /* XXX: very inefficient for plain buffers */\n\tDUK_ASSERT(h_this != NULL);\n\tbuffer_length = h_this->length;\n\n\t/* [ value  offset noAssert                 ], when ftype != DUK__FLD_VARINT */\n\t/* [ value  offset fieldByteLength noAssert ], when ftype == DUK__FLD_VARINT */\n\t/* [ offset value  littleEndian             ], when DUK__FLD_TYPEDARRAY (regardless of ftype) */\n\n\t/* Handle TypedArray vs. Node.js Buffer arg differences */\n\tif (magic_typedarray) {\n\t\tno_assert = 0;\n#if defined(DUK_USE_INTEGER_LE)\n\t\tendswap = !duk_to_boolean(ctx, 2);  /* 1=little endian */\n#else\n\t\tendswap = duk_to_boolean(ctx, 2);  /* 1=little endian */\n#endif\n\t\tduk_swap(ctx, 0, 1);  /* offset/value order different from Node.js */\n\t} else {\n\t\tno_assert = duk_to_boolean(ctx, (magic_ftype == DUK__FLD_VARINT) ? 3 : 2);\n#if defined(DUK_USE_INTEGER_LE)\n\t\tendswap = magic_bigendian;\n#else\n\t\tendswap = !magic_bigendian;\n#endif\n\t}\n\n\t/* Offset is coerced first to signed integer range and then to unsigned.\n\t * This ensures we can add a small byte length (1-8) to the offset in\n\t * bound checks and not wrap.\n\t */\n\toffset_signed = duk_to_int(ctx, 1);\n\toffset = (duk_uint_t) offset_signed;\n\n\t/* We need 'nbytes' even for a failed offset; return value must be\n\t * (offset + nbytes) even when write fails due to invalid offset.\n\t */\n\tif (magic_ftype != DUK__FLD_VARINT) {\n\t\tDUK_ASSERT(magic_ftype >= 0 && magic_ftype < (duk_small_int_t) (sizeof(duk__buffer_nbytes_from_fldtype) / sizeof(duk_uint8_t)));\n\t\tnbytes = duk__buffer_nbytes_from_fldtype[magic_ftype];\n\t} else {\n\t\tnbytes = duk_get_int(ctx, 2);\n\t\tif (nbytes < 1 || nbytes > 6) {\n\t\t\tgoto fail_field_length;\n\t\t}\n\t}\n\tDUK_ASSERT(nbytes >= 1 && nbytes <= 8);\n\n\t/* Now we can check offset validity. */\n\tif (offset_signed < 0) {\n\t\tgoto fail_bounds;\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"writefield, value=%!T, buffer_length=%ld, offset=%ld, no_assert=%d, \"\n\t                     \"magic=%04x, magic_fieldtype=%d, magic_bigendian=%d, magic_signed=%d, \"\n\t                     \"endswap=%d\",\n\t                     duk_get_tval(ctx, 0), (long) buffer_length, (long) offset, (int) no_assert,\n\t                     (unsigned int) magic, (int) magic_ftype, (int) (magic_bigendian >> 3),\n\t                     (int) (magic_signed >> 4), (int) endswap));\n\n\t/* Coerce value to a number before computing check_length, so that\n\t * the field type specific coercion below can't have side effects\n\t * that would invalidate check_length.\n\t */\n\tduk_to_number(ctx, 0);\n\n\t/* Update 'buffer_length' to be the effective, safe limit which\n\t * takes into account the underlying buffer.  This value will be\n\t * potentially invalidated by any side effect.\n\t */\n\tcheck_length = DUK_HBUFOBJ_CLAMP_BYTELENGTH(h_this, buffer_length);\n\tDUK_DDD(DUK_DDDPRINT(\"buffer_length=%ld, check_length=%ld\",\n\t                     (long) buffer_length, (long) check_length));\n\n\tif (h_this->buf) {\n\t\tbuf = DUK_HBUFOBJ_GET_SLICE_BASE(thr->heap, h_this);\n\t} else {\n\t\t/* Neutered.  We could go into the switch-case safely with\n\t\t * buf == NULL because check_length == 0.  To avoid scanbuild\n\t\t * warnings, fail directly instead.\n\t\t */\n\t\tDUK_ASSERT(check_length == 0);\n\t\tgoto fail_neutered;\n\t}\n\tDUK_ASSERT(buf != NULL);\n\n\tswitch (magic_ftype) {\n\tcase DUK__FLD_8BIT: {\n\t\tif (offset + 1U > check_length) {\n\t\t\tgoto fail_bounds;\n\t\t}\n\t\t/* sign doesn't matter when writing */\n\t\tbuf[offset] = (duk_uint8_t) duk_to_uint32(ctx, 0);\n\t\tbreak;\n\t}\n\tcase DUK__FLD_16BIT: {\n\t\tduk_uint16_t tmp;\n\t\tif (offset + 2U > check_length) {\n\t\t\tgoto fail_bounds;\n\t\t}\n\t\ttmp = (duk_uint16_t) duk_to_uint32(ctx, 0);\n\t\tif (endswap) {\n\t\t\ttmp = DUK_BSWAP16(tmp);\n\t\t}\n\t\tdu.us[0] = tmp;\n\t\t/* sign doesn't matter when writing */\n\t\tDUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 2);\n\t\tbreak;\n\t}\n\tcase DUK__FLD_32BIT: {\n\t\tduk_uint32_t tmp;\n\t\tif (offset + 4U > check_length) {\n\t\t\tgoto fail_bounds;\n\t\t}\n\t\ttmp = (duk_uint32_t) duk_to_uint32(ctx, 0);\n\t\tif (endswap) {\n\t\t\ttmp = DUK_BSWAP32(tmp);\n\t\t}\n\t\tdu.ui[0] = tmp;\n\t\t/* sign doesn't matter when writing */\n\t\tDUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 4);\n\t\tbreak;\n\t}\n\tcase DUK__FLD_FLOAT: {\n\t\tduk_uint32_t tmp;\n\t\tif (offset + 4U > check_length) {\n\t\t\tgoto fail_bounds;\n\t\t}\n\t\tdu.f[0] = (duk_float_t) duk_to_number(ctx, 0);\n\t\tif (endswap) {\n\t\t\ttmp = du.ui[0];\n\t\t\ttmp = DUK_BSWAP32(tmp);\n\t\t\tdu.ui[0] = tmp;\n\t\t}\n\t\t/* sign doesn't matter when writing */\n\t\tDUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 4);\n\t\tbreak;\n\t}\n\tcase DUK__FLD_DOUBLE: {\n\t\tif (offset + 8U > check_length) {\n\t\t\tgoto fail_bounds;\n\t\t}\n\t\tdu.d = (duk_double_t) duk_to_number(ctx, 0);\n\t\tif (endswap) {\n\t\t\tDUK_DBLUNION_BSWAP64(&du);\n\t\t}\n\t\t/* sign doesn't matter when writing */\n\t\tDUK_MEMCPY((void *) (buf + offset), (const void *) du.uc, 8);\n\t\tbreak;\n\t}\n\tcase DUK__FLD_VARINT: {\n\t\t/* Node.js Buffer variable width integer field.  We don't really\n\t\t * care about speed here, so aim for shortest algorithm.\n\t\t */\n\t\tduk_int_t field_bytelen;\n\t\tduk_int_t i, i_step, i_end;\n#if defined(DUK_USE_64BIT_OPS)\n\t\tduk_int64_t tmp;\n#else\n\t\tduk_double_t tmp;\n#endif\n\t\tduk_uint8_t *p;\n\n\t\tfield_bytelen = (duk_int_t) nbytes;\n\t\tif (offset + (duk_uint_t) field_bytelen > check_length) {\n\t\t\tgoto fail_bounds;\n\t\t}\n\n\t\t/* Slow writing of value using either 64-bit arithmetic\n\t\t * or IEEE doubles if 64-bit types not available.  There's\n\t\t * no special sign handling when writing varints.\n\t\t */\n\n\t\tif (magic_bigendian) {\n\t\t\t/* Write in big endian */\n\t\t\ti = field_bytelen;  /* one i_step added at top of loop */\n\t\t\ti_step = -1;\n\t\t\ti_end = 0;\n\t\t} else {\n\t\t\t/* Write in little endian */\n\t\t\ti = -1;  /* one i_step added at top of loop */\n\t\t\ti_step = 1;\n\t\t\ti_end = field_bytelen - 1;\n\t\t}\n\n\t\t/* XXX: The duk_to_number() cast followed by integer coercion\n\t\t * is platform specific so NaN, +/- Infinity, and out-of-bounds\n\t\t * values result in platform specific output now.\n\t\t * See: test-bi-nodejs-buffer-proto-varint-special.js\n\t\t */\n\n#if defined(DUK_USE_64BIT_OPS)\n\t\ttmp = (duk_int64_t) duk_to_number(ctx, 0);\n\t\tp = (duk_uint8_t *) (buf + offset);\n\t\tdo {\n\t\t\ti += i_step;\n\t\t\tDUK_ASSERT(i >= 0 && i < field_bytelen);\n\t\t\tp[i] = (duk_uint8_t) (tmp & 0xff);\n\t\t\ttmp = tmp >> 8;  /* unnecessary shift for last byte */\n\t\t} while (i != i_end);\n#else\n\t\ttmp = duk_to_number(ctx, 0);\n\t\tp = (duk_uint8_t *) (buf + offset);\n\t\tdo {\n\t\t\ti += i_step;\n\t\t\ttmp = DUK_FLOOR(tmp);\n\t\t\tDUK_ASSERT(i >= 0 && i < field_bytelen);\n\t\t\tp[i] = (duk_uint8_t) (DUK_FMOD(tmp, 256.0));\n\t\t\ttmp = tmp / 256.0;  /* unnecessary div for last byte */\n\t\t} while (i != i_end);\n#endif\n\t\tbreak;\n\t}\n\tdefault: {  /* should never happen but default here */\n\t\tgoto fail_bounds;\n\t}\n\t}\n\n\t/* Node.js Buffer: return offset + #bytes written (i.e. next\n\t * write offset).\n\t */\n\tif (magic_typedarray) {\n\t\t/* For TypedArrays 'undefined' return value is specified\n\t\t * by ES2015 (matches V8).\n\t\t */\n\t\treturn 0;\n\t}\n\tduk_push_uint(ctx, offset + nbytes);\n\treturn 1;\n\n fail_neutered:\n fail_field_length:\n fail_bounds:\n\tif (no_assert) {\n\t\t/* Node.js return value for failed writes is offset + #bytes\n\t\t * that would have been written.\n\t\t */\n\t\t/* XXX: for negative input offsets, 'offset' will be a large\n\t\t * positive value so the result here is confusing.\n\t\t */\n\t\tif (magic_typedarray) {\n\t\t\treturn 0;\n\t\t}\n\t\tduk_push_uint(ctx, offset + nbytes);\n\t\treturn 1;\n\t}\n\tDUK_DCERROR_RANGE_INVALID_ARGS(thr);\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/*\n *  Accessors for .buffer, .byteLength, .byteOffset\n */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_LOCAL duk_hbufobj *duk__autospawn_arraybuffer(duk_context *ctx, duk_hbuffer *h_buf) {\n\tduk_hbufobj *h_res;\n\n\th_res = duk_push_bufobj_raw(ctx,\n\t                            DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                            DUK_HOBJECT_FLAG_BUFOBJ |\n\t                            DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_ARRAYBUFFER),\n\t                            DUK_BIDX_ARRAYBUFFER_PROTOTYPE);\n\tDUK_ASSERT(h_res != NULL);\n\tDUK_UNREF(h_res);\n\n\tduk__set_bufobj_buffer(ctx, h_res, h_buf);\n\tDUK_ASSERT_HBUFOBJ_VALID(h_res);\n\tDUK_ASSERT(h_res->buf_prop == NULL);\n\treturn h_res;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_typedarray_buffer_getter(duk_context *ctx) {\n\tduk_hbufobj *h_bufobj;\n\n\th_bufobj = (duk_hbufobj *) duk__getrequire_bufobj_this(ctx, DUK__BUFOBJ_FLAG_THROW /*flags*/);\n\tDUK_ASSERT(h_bufobj != NULL);\n\tif (DUK_HEAPHDR_IS_BUFFER((duk_heaphdr *) h_bufobj)) {\n\t\tDUK_DD(DUK_DDPRINT(\"autospawn ArrayBuffer for plain buffer\"));\n\t\t(void) duk__autospawn_arraybuffer(ctx, (duk_hbuffer *) h_bufobj);\n\t\treturn 1;\n\t} else {\n\t\tif (h_bufobj->buf_prop == NULL &&\n\t\t    DUK_HOBJECT_GET_CLASS_NUMBER((duk_hobject *) h_bufobj) != DUK_HOBJECT_CLASS_ARRAYBUFFER &&\n\t\t    h_bufobj->buf != NULL) {\n\t\t\tduk_hbufobj *h_arrbuf;\n\n\t\t\tDUK_DD(DUK_DDPRINT(\"autospawn ArrayBuffer for typed array or DataView\"));\n\t\t\th_arrbuf = duk__autospawn_arraybuffer(ctx, h_bufobj->buf);\n\n\t\t\tif (h_bufobj->buf_prop == NULL) {\n\t\t\t\t/* Must recheck buf_prop, in case ArrayBuffer\n\t\t\t\t * alloc had a side effect which already filled\n\t\t\t\t * it!\n\t\t\t\t */\n\n\t\t\t\t/* Set ArrayBuffer's .byteOffset and .byteLength based\n\t\t\t\t * on the view so that Arraybuffer[view.byteOffset]\n\t\t\t\t * matches view[0].\n\t\t\t\t */\n\t\t\t\th_arrbuf->offset = 0;\n\t\t\t\tDUK_ASSERT(h_bufobj->offset + h_bufobj->length >= h_bufobj->offset);  /* Wrap check on creation. */\n\t\t\t\th_arrbuf->length = h_bufobj->offset + h_bufobj->length;\n\t\t\t\tDUK_ASSERT(h_arrbuf->buf_prop == NULL);\n\n\t\t\t\tDUK_ASSERT(h_bufobj->buf_prop == NULL);\n\t\t\t\th_bufobj->buf_prop = (duk_hobject *) h_arrbuf;\n\t\t\t\tDUK_HBUFOBJ_INCREF(thr, h_arrbuf);  /* Now reachable and accounted for. */\n\t\t\t}\n\n\t\t\t/* Left on stack; pushed for the second time below (OK). */\n\t\t}\n\t\tif (h_bufobj->buf_prop) {\n\t\t\tduk_push_hobject(ctx, h_bufobj->buf_prop);\n\t\t\treturn 1;\n\t\t}\n\t}\n\treturn 0;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_typedarray_byteoffset_getter(duk_context *ctx) {\n\tduk_hbufobj *h_bufobj;\n\n\th_bufobj = (duk_hbufobj *) duk__getrequire_bufobj_this(ctx, DUK__BUFOBJ_FLAG_THROW /*flags*/);\n\tDUK_ASSERT(h_bufobj != NULL);\n\tif (DUK_HEAPHDR_IS_BUFFER((duk_heaphdr *) h_bufobj)) {\n\t\tduk_push_uint(ctx, 0);\n\t} else {\n\t\t/* If neutered must return 0; offset is zeroed during\n\t\t * neutering.\n\t\t */\n\t\tduk_push_uint(ctx, h_bufobj->offset);\n\t}\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_typedarray_bytelength_getter(duk_context *ctx) {\n\tduk_hbufobj *h_bufobj;\n\n\th_bufobj = (duk_hbufobj *) duk__getrequire_bufobj_this(ctx, DUK__BUFOBJ_FLAG_THROW /*flags*/);\n\tDUK_ASSERT(h_bufobj != NULL);\n\tif (DUK_HEAPHDR_IS_BUFFER((duk_heaphdr *) h_bufobj)) {\n\t\tduk_hbuffer *h_buf;\n\n\t\th_buf = (duk_hbuffer *) h_bufobj;\n\t\tDUK_ASSERT(DUK_HBUFFER_GET_SIZE(h_buf) <= DUK_UINT_MAX);  /* Buffer limits. */\n\t\tduk_push_uint(ctx, (duk_uint_t) DUK_HBUFFER_GET_SIZE(h_buf));\n\t} else {\n\t\t/* If neutered must return 0; length is zeroed during\n\t\t * neutering.\n\t\t */\n\t\tduk_push_uint(ctx, h_bufobj->length);\n\t}\n\treturn 1;\n}\n#else  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n/* No .buffer getter without ArrayBuffer support. */\n#if 0\nDUK_INTERNAL duk_ret_t duk_bi_typedarray_buffer_getter(duk_context *ctx) {\n\treturn 0;\n}\n#endif\n\nDUK_INTERNAL duk_ret_t duk_bi_typedarray_byteoffset_getter(duk_context *ctx) {\n\tduk_push_uint(ctx, 0);\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_typedarray_bytelength_getter(duk_context *ctx) {\n\tduk_hbuffer *h_buf;\n\n\t/* XXX: helper? */\n\tduk_push_this(ctx);\n\th_buf = duk_require_hbuffer(ctx, -1);\n\tduk_push_uint(ctx, DUK_HBUFFER_GET_SIZE(h_buf));\n\treturn 1;\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/* automatic undefs */\n#undef DUK__BUFOBJ_FLAG_PROMOTE\n#undef DUK__BUFOBJ_FLAG_THROW\n#undef DUK__FLD_16BIT\n#undef DUK__FLD_32BIT\n#undef DUK__FLD_8BIT\n#undef DUK__FLD_BIGENDIAN\n#undef DUK__FLD_DOUBLE\n#undef DUK__FLD_FLOAT\n#undef DUK__FLD_SIGNED\n#undef DUK__FLD_TYPEDARRAY\n#undef DUK__FLD_VARINT\n/*\n *  Date built-ins\n *\n *  Unlike most built-ins, Date has some platform dependencies for getting\n *  UTC time, converting between UTC and local time, and parsing and\n *  formatting time values.  These are all abstracted behind DUK_USE_xxx\n *  config options.  There are built-in platform specific providers for\n *  POSIX and Windows, but external providers can also be used.\n *\n *  See doc/datetime.rst.\n *\n */\n\n/* #include duk_internal.h -> already included */\n\n/* XXX: currently defines unnecessary symbols when DUK_USE_DATE_BUILTIN is disabled. */\n\n/*\n *  Forward declarations\n */\n\nDUK_LOCAL_DECL duk_double_t duk__push_this_get_timeval_tzoffset(duk_context *ctx, duk_small_uint_t flags, duk_int_t *out_tzoffset);\nDUK_LOCAL_DECL duk_double_t duk__push_this_get_timeval(duk_context *ctx, duk_small_uint_t flags);\nDUK_LOCAL_DECL void duk__twodigit_year_fixup(duk_context *ctx, duk_idx_t idx_val);\nDUK_LOCAL_DECL duk_ret_t duk__set_this_timeval_from_dparts(duk_context *ctx, duk_double_t *dparts, duk_small_uint_t flags);\n\n/*\n *  Other file level defines\n */\n\n/* Debug macro to print all parts and dparts (used manually because of debug level). */\n#define  DUK__DPRINT_PARTS_AND_DPARTS(parts,dparts)  do { \\\n\t\tDUK_D(DUK_DPRINT(\"parts: %ld %ld %ld %ld %ld %ld %ld %ld, dparts: %lf %lf %lf %lf %lf %lf %lf %lf\", \\\n\t\t                 (long) (parts)[0], (long) (parts)[1], \\\n\t\t                 (long) (parts)[2], (long) (parts)[3], \\\n\t\t                 (long) (parts)[4], (long) (parts)[5], \\\n\t\t                 (long) (parts)[6], (long) (parts)[7], \\\n\t\t                 (double) (dparts)[0], (double) (dparts)[1], \\\n\t\t                 (double) (dparts)[2], (double) (dparts)[3], \\\n\t\t                 (double) (dparts)[4], (double) (dparts)[5], \\\n\t\t                 (double) (dparts)[6], (double) (dparts)[7])); \\\n\t} while (0)\n#define  DUK__DPRINT_PARTS(parts)  do { \\\n\t\tDUK_D(DUK_DPRINT(\"parts: %ld %ld %ld %ld %ld %ld %ld %ld\", \\\n\t\t                 (long) (parts)[0], (long) (parts)[1], \\\n\t\t                 (long) (parts)[2], (long) (parts)[3], \\\n\t\t                 (long) (parts)[4], (long) (parts)[5], \\\n\t\t                 (long) (parts)[6], (long) (parts)[7])); \\\n\t} while (0)\n#define  DUK__DPRINT_DPARTS(dparts)  do { \\\n\t\tDUK_D(DUK_DPRINT(\"dparts: %lf %lf %lf %lf %lf %lf %lf %lf\", \\\n\t\t                 (double) (dparts)[0], (double) (dparts)[1], \\\n\t\t                 (double) (dparts)[2], (double) (dparts)[3], \\\n\t\t                 (double) (dparts)[4], (double) (dparts)[5], \\\n\t\t                 (double) (dparts)[6], (double) (dparts)[7])); \\\n\t} while (0)\n\n/* Equivalent year for DST calculations outside [1970,2038[ range, see\n * E5 Section 15.9.1.8.  Equivalent year has the same leap-year-ness and\n * starts with the same weekday on Jan 1.\n * https://bugzilla.mozilla.org/show_bug.cgi?id=351066\n */\n#define DUK__YEAR(x) ((duk_uint8_t) ((x) - 1970))\nDUK_LOCAL duk_uint8_t duk__date_equivyear[14] = {\n#if 1\n\t/* This is based on V8 EquivalentYear() algorithm (see util/genequivyear.py):\n\t * http://code.google.com/p/v8/source/browse/trunk/src/date.h#146\n\t */\n\n\t/* non-leap year: sunday, monday, ... */\n\tDUK__YEAR(2023), DUK__YEAR(2035), DUK__YEAR(2019), DUK__YEAR(2031),\n\tDUK__YEAR(2015), DUK__YEAR(2027), DUK__YEAR(2011),\n\n\t/* leap year: sunday, monday, ... */\n\tDUK__YEAR(2012), DUK__YEAR(2024), DUK__YEAR(2008), DUK__YEAR(2020),\n\tDUK__YEAR(2032), DUK__YEAR(2016), DUK__YEAR(2028)\n#endif\n\n#if 0\n\t/* This is based on Rhino EquivalentYear() algorithm:\n\t * https://github.com/mozilla/rhino/blob/f99cc11d616f0cdda2c42bde72b3484df6182947/src/org/mozilla/javascript/NativeDate.java\n\t */\n\n\t/* non-leap year: sunday, monday, ... */\n\tDUK__YEAR(1978), DUK__YEAR(1973), DUK__YEAR(1985), DUK__YEAR(1986),\n\tDUK__YEAR(1981), DUK__YEAR(1971), DUK__YEAR(1977),\n\n\t/* leap year: sunday, monday, ... */\n\tDUK__YEAR(1984), DUK__YEAR(1996), DUK__YEAR(1980), DUK__YEAR(1992),\n\tDUK__YEAR(1976), DUK__YEAR(1988), DUK__YEAR(1972)\n#endif\n};\n\n/*\n *  ISO 8601 subset parser.\n */\n\n/* Parser part count. */\n#define DUK__NUM_ISO8601_PARSER_PARTS  9\n\n/* Parser part indices. */\n#define DUK__PI_YEAR         0\n#define DUK__PI_MONTH        1\n#define DUK__PI_DAY          2\n#define DUK__PI_HOUR         3\n#define DUK__PI_MINUTE       4\n#define DUK__PI_SECOND       5\n#define DUK__PI_MILLISECOND  6\n#define DUK__PI_TZHOUR       7\n#define DUK__PI_TZMINUTE     8\n\n/* Parser part masks. */\n#define DUK__PM_YEAR         (1 << DUK__PI_YEAR)\n#define DUK__PM_MONTH        (1 << DUK__PI_MONTH)\n#define DUK__PM_DAY          (1 << DUK__PI_DAY)\n#define DUK__PM_HOUR         (1 << DUK__PI_HOUR)\n#define DUK__PM_MINUTE       (1 << DUK__PI_MINUTE)\n#define DUK__PM_SECOND       (1 << DUK__PI_SECOND)\n#define DUK__PM_MILLISECOND  (1 << DUK__PI_MILLISECOND)\n#define DUK__PM_TZHOUR       (1 << DUK__PI_TZHOUR)\n#define DUK__PM_TZMINUTE     (1 << DUK__PI_TZMINUTE)\n\n/* Parser separator indices. */\n#define DUK__SI_PLUS         0\n#define DUK__SI_MINUS        1\n#define DUK__SI_T            2\n#define DUK__SI_SPACE        3\n#define DUK__SI_COLON        4\n#define DUK__SI_PERIOD       5\n#define DUK__SI_Z            6\n#define DUK__SI_NUL          7\n\n/* Parser separator masks. */\n#define DUK__SM_PLUS         (1 << DUK__SI_PLUS)\n#define DUK__SM_MINUS        (1 << DUK__SI_MINUS)\n#define DUK__SM_T            (1 << DUK__SI_T)\n#define DUK__SM_SPACE        (1 << DUK__SI_SPACE)\n#define DUK__SM_COLON        (1 << DUK__SI_COLON)\n#define DUK__SM_PERIOD       (1 << DUK__SI_PERIOD)\n#define DUK__SM_Z            (1 << DUK__SI_Z)\n#define DUK__SM_NUL          (1 << DUK__SI_NUL)\n\n/* Rule control flags. */\n#define DUK__CF_NEG          (1 << 0)  /* continue matching, set neg_tzoffset flag */\n#define DUK__CF_ACCEPT       (1 << 1)  /* accept string */\n#define DUK__CF_ACCEPT_NUL   (1 << 2)  /* accept string if next char is NUL (otherwise reject) */\n\n#define DUK__PACK_RULE(partmask,sepmask,nextpart,flags)  \\\n\t((duk_uint32_t) (partmask) + \\\n\t (((duk_uint32_t) (sepmask)) << 9) + \\\n\t (((duk_uint32_t) (nextpart)) << 17) + \\\n\t (((duk_uint32_t) (flags)) << 21))\n\n#define DUK__UNPACK_RULE(rule,var_nextidx,var_flags)  do { \\\n\t\t(var_nextidx) = (duk_small_uint_t) (((rule) >> 17) & 0x0f); \\\n\t\t(var_flags) = (duk_small_uint_t) ((rule) >> 21); \\\n\t} while (0)\n\n#define DUK__RULE_MASK_PART_SEP  0x1ffffUL\n\n/* Matching separator index is used in the control table */\nDUK_LOCAL const duk_uint8_t duk__parse_iso8601_seps[] = {\n\tDUK_ASC_PLUS /*0*/, DUK_ASC_MINUS /*1*/, DUK_ASC_UC_T /*2*/, DUK_ASC_SPACE /*3*/,\n\tDUK_ASC_COLON /*4*/, DUK_ASC_PERIOD /*5*/, DUK_ASC_UC_Z /*6*/, DUK_ASC_NUL /*7*/\n};\n\n/* Rule table: first matching rule is used to determine what to do next. */\nDUK_LOCAL const duk_uint32_t duk__parse_iso8601_control[] = {\n\tDUK__PACK_RULE(DUK__PM_YEAR, DUK__SM_MINUS, DUK__PI_MONTH, 0),\n\tDUK__PACK_RULE(DUK__PM_MONTH, DUK__SM_MINUS, DUK__PI_DAY, 0),\n\tDUK__PACK_RULE(DUK__PM_YEAR | DUK__PM_MONTH | DUK__PM_DAY, DUK__SM_T | DUK__SM_SPACE, DUK__PI_HOUR, 0),\n\tDUK__PACK_RULE(DUK__PM_HOUR, DUK__SM_COLON, DUK__PI_MINUTE, 0),\n\tDUK__PACK_RULE(DUK__PM_MINUTE, DUK__SM_COLON, DUK__PI_SECOND, 0),\n\tDUK__PACK_RULE(DUK__PM_SECOND, DUK__SM_PERIOD, DUK__PI_MILLISECOND, 0),\n\tDUK__PACK_RULE(DUK__PM_TZHOUR, DUK__SM_COLON, DUK__PI_TZMINUTE, 0),\n\tDUK__PACK_RULE(DUK__PM_YEAR | DUK__PM_MONTH | DUK__PM_DAY | DUK__PM_HOUR /*Note1*/ | DUK__PM_MINUTE | DUK__PM_SECOND | DUK__PM_MILLISECOND, DUK__SM_PLUS, DUK__PI_TZHOUR, 0),\n\tDUK__PACK_RULE(DUK__PM_YEAR | DUK__PM_MONTH | DUK__PM_DAY | DUK__PM_HOUR /*Note1*/ | DUK__PM_MINUTE | DUK__PM_SECOND | DUK__PM_MILLISECOND, DUK__SM_MINUS, DUK__PI_TZHOUR, DUK__CF_NEG),\n\tDUK__PACK_RULE(DUK__PM_YEAR | DUK__PM_MONTH | DUK__PM_DAY | DUK__PM_HOUR /*Note1*/ | DUK__PM_MINUTE | DUK__PM_SECOND | DUK__PM_MILLISECOND, DUK__SM_Z, 0, DUK__CF_ACCEPT_NUL),\n\tDUK__PACK_RULE(DUK__PM_YEAR | DUK__PM_MONTH | DUK__PM_DAY | DUK__PM_HOUR /*Note1*/ | DUK__PM_MINUTE | DUK__PM_SECOND | DUK__PM_MILLISECOND | DUK__PM_TZHOUR /*Note2*/ | DUK__PM_TZMINUTE, DUK__SM_NUL, 0, DUK__CF_ACCEPT)\n\n\t/* Note1: the specification doesn't require matching a time form with\n\t *        just hours (\"HH\"), but we accept it here, e.g. \"2012-01-02T12Z\".\n\t *\n\t * Note2: the specification doesn't require matching a timezone offset\n\t *        with just hours (\"HH\"), but accept it here, e.g. \"2012-01-02T03:04:05+02\"\n\t */\n};\n\nDUK_LOCAL duk_bool_t duk__parse_string_iso8601_subset(duk_context *ctx, const char *str) {\n\tduk_int_t parts[DUK__NUM_ISO8601_PARSER_PARTS];\n\tduk_double_t dparts[DUK_DATE_IDX_NUM_PARTS];\n\tduk_double_t d;\n\tconst duk_uint8_t *p;\n\tduk_small_uint_t part_idx = 0;\n\tduk_int_t accum = 0;\n\tduk_small_uint_t ndigits = 0;\n\tduk_bool_t neg_year = 0;\n\tduk_bool_t neg_tzoffset = 0;\n\tduk_uint_fast8_t ch;\n\tduk_small_uint_t i;\n\n\t/* During parsing, month and day are one-based; set defaults here. */\n\tDUK_MEMZERO(parts, sizeof(parts));\n\tDUK_ASSERT(parts[DUK_DATE_IDX_YEAR] == 0);  /* don't care value, year is mandatory */\n\tparts[DUK_DATE_IDX_MONTH] = 1;\n\tparts[DUK_DATE_IDX_DAY] = 1;\n\n\t/* Special handling for year sign. */\n\tp = (const duk_uint8_t *) str;\n\tch = p[0];\n\tif (ch == DUK_ASC_PLUS) {\n\t\tp++;\n\t} else if (ch == DUK_ASC_MINUS) {\n\t\tneg_year = 1;\n\t\tp++;\n\t}\n\n\tfor (;;) {\n\t\tch = *p++;\n\t\tDUK_DDD(DUK_DDDPRINT(\"parsing, part_idx=%ld, char=%ld ('%c')\",\n\t\t                     (long) part_idx, (long) ch,\n\t\t                     (int) ((ch >= 0x20 && ch <= 0x7e) ? ch : DUK_ASC_QUESTION)));\n\n\t\tif (ch >= DUK_ASC_0 && ch <= DUK_ASC_9) {\n\t\t\tif (ndigits >= 9) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"too many digits -> reject\"));\n\t\t\t\tgoto reject;\n\t\t\t}\n\t\t\tif (part_idx == DUK__PI_MILLISECOND && ndigits >= 3) {\n\t\t\t\t/* ignore millisecond fractions after 3 */\n\t\t\t} else {\n\t\t\t\taccum = accum * 10 + ((duk_int_t) ch) - ((duk_int_t) DUK_ASC_0) + 0x00;\n\t\t\t\tndigits++;\n\t\t\t}\n\t\t} else {\n\t\t\tduk_uint_fast32_t match_val;\n\t\t\tduk_small_int_t sep_idx;\n\n\t\t\tif (ndigits <= 0) {\n\t\t\t\tgoto reject;\n\t\t\t}\n\t\t\tif (part_idx == DUK__PI_MILLISECOND) {\n\t\t\t\t/* complete the millisecond field */\n\t\t\t\twhile (ndigits < 3) {\n\t\t\t\t\taccum *= 10;\n\t\t\t\t\tndigits++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tparts[part_idx] = accum;\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"wrote part %ld -> value %ld\", (long) part_idx, (long) accum));\n\n\t\t\taccum = 0;\n\t\t\tndigits = 0;\n\n\t\t\tfor (i = 0; i < (duk_small_uint_t) (sizeof(duk__parse_iso8601_seps) / sizeof(duk_uint8_t)); i++) {\n\t\t\t\tif (duk__parse_iso8601_seps[i] == ch) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (i == (duk_small_uint_t) (sizeof(duk__parse_iso8601_seps) / sizeof(duk_uint8_t))) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"separator character doesn't match -> reject\"));\n\t\t\t\tgoto reject;\n\t\t\t}\n\n\t\t\tsep_idx = i;\n\t\t\tmatch_val = (1UL << part_idx) + (1UL << (sep_idx + 9));  /* match against rule part/sep bits */\n\n\t\t\tfor (i = 0; i < (duk_small_uint_t) (sizeof(duk__parse_iso8601_control) / sizeof(duk_uint32_t)); i++) {\n\t\t\t\tduk_uint_fast32_t rule = duk__parse_iso8601_control[i];\n\t\t\t\tduk_small_uint_t nextpart;\n\t\t\t\tduk_small_uint_t cflags;\n\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"part_idx=%ld, sep_idx=%ld, match_val=0x%08lx, considering rule=0x%08lx\",\n\t\t\t\t                     (long) part_idx, (long) sep_idx,\n\t\t\t\t                     (unsigned long) match_val, (unsigned long) rule));\n\n\t\t\t\tif ((rule & match_val) != match_val) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tDUK__UNPACK_RULE(rule, nextpart, cflags);\n\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"rule match -> part_idx=%ld, sep_idx=%ld, match_val=0x%08lx, \"\n\t\t\t\t                     \"rule=0x%08lx -> nextpart=%ld, cflags=0x%02lx\",\n\t\t\t\t                     (long) part_idx, (long) sep_idx,\n\t\t\t\t                     (unsigned long) match_val, (unsigned long) rule,\n\t\t\t\t                     (long) nextpart, (unsigned long) cflags));\n\n\t\t\t\tif (cflags & DUK__CF_NEG) {\n\t\t\t\t\tneg_tzoffset = 1;\n\t\t\t\t}\n\n\t\t\t\tif (cflags & DUK__CF_ACCEPT) {\n\t\t\t\t\tgoto accept;\n\t\t\t\t}\n\n\t\t\t\tif (cflags & DUK__CF_ACCEPT_NUL) {\n\t\t\t\t\tDUK_ASSERT(*(p - 1) != (char) 0);\n\t\t\t\t\tif (*p == DUK_ASC_NUL) {\n\t\t\t\t\t\tgoto accept;\n\t\t\t\t\t}\n\t\t\t\t\tgoto reject;\n\t\t\t\t}\n\n\t\t\t\tpart_idx = nextpart;\n\t\t\t\tbreak;\n\t\t\t}  /* rule match */\n\n\t\t\tif (i == (duk_small_uint_t) (sizeof(duk__parse_iso8601_control) / sizeof(duk_uint32_t))) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"no rule matches -> reject\"));\n\t\t\t\tgoto reject;\n\t\t\t}\n\n\t\t\tif (ch == 0) {\n\t\t\t\t/* This shouldn't be necessary, but check just in case\n\t\t\t\t * to avoid any chance of overruns.\n\t\t\t\t */\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"NUL after rule matching (should not happen) -> reject\"));\n\t\t\t\tgoto reject;\n\t\t\t}\n\t\t}  /* if-digit-else-ctrl */\n\t}  /* char loop */\n\n\t/* We should never exit the loop above. */\n\tDUK_UNREACHABLE();\n\n reject:\n\tDUK_DDD(DUK_DDDPRINT(\"reject\"));\n\treturn 0;\n\n accept:\n\tDUK_DDD(DUK_DDDPRINT(\"accept\"));\n\n\t/* Apply timezone offset to get the main parts in UTC */\n\tif (neg_year) {\n\t\tparts[DUK__PI_YEAR] = -parts[DUK__PI_YEAR];\n\t}\n\tif (neg_tzoffset) {\n\t\tparts[DUK__PI_HOUR] += parts[DUK__PI_TZHOUR];\n\t\tparts[DUK__PI_MINUTE] += parts[DUK__PI_TZMINUTE];\n\t} else {\n\t\tparts[DUK__PI_HOUR] -= parts[DUK__PI_TZHOUR];\n\t\tparts[DUK__PI_MINUTE] -= parts[DUK__PI_TZMINUTE];\n\t}\n\tparts[DUK__PI_MONTH] -= 1;  /* zero-based month */\n\tparts[DUK__PI_DAY] -= 1;  /* zero-based day */\n\n\t/* Use double parts, they tolerate unnormalized time.\n\t *\n\t * Note: DUK_DATE_IDX_WEEKDAY is initialized with a bogus value (DUK__PI_TZHOUR)\n\t * on purpose.  It won't be actually used by duk_bi_date_get_timeval_from_dparts(),\n\t * but will make the value initialized just in case, and avoid any\n\t * potential for Valgrind issues.\n\t */\n\tfor (i = 0; i < DUK_DATE_IDX_NUM_PARTS; i++) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"part[%ld] = %ld\", (long) i, (long) parts[i]));\n\t\tdparts[i] = parts[i];\n\t}\n\n\td = duk_bi_date_get_timeval_from_dparts(dparts, 0 /*flags*/);\n\tduk_push_number(ctx, d);\n\treturn 1;\n}\n\n/*\n *  Date/time parsing helper.\n *\n *  Parse a datetime string into a time value.  We must first try to parse\n *  the input according to the standard format in E5.1 Section 15.9.1.15.\n *  If that fails, we can try to parse using custom parsing, which can\n *  either be platform neutral (custom code) or platform specific (using\n *  existing platform API calls).\n *\n *  Note in particular that we must parse whatever toString(), toUTCString(),\n *  and toISOString() can produce; see E5.1 Section 15.9.4.2.\n *\n *  Returns 1 to allow tail calling.\n *\n *  There is much room for improvement here with respect to supporting\n *  alternative datetime formats.  For instance, V8 parses '2012-01-01' as\n *  UTC and '2012/01/01' as local time.\n */\n\nDUK_LOCAL duk_ret_t duk__parse_string(duk_context *ctx, const char *str) {\n\t/* XXX: there is a small risk here: because the ISO 8601 parser is\n\t * very loose, it may end up parsing some datetime values which\n\t * would be better parsed with a platform specific parser.\n\t */\n\n\tDUK_ASSERT(str != NULL);\n\tDUK_DDD(DUK_DDDPRINT(\"parse datetime from string '%s'\", (const char *) str));\n\n\tif (duk__parse_string_iso8601_subset(ctx, str) != 0) {\n\t\treturn 1;\n\t}\n\n#if defined(DUK_USE_DATE_PARSE_STRING)\n\t/* Contract, either:\n\t * - Push value on stack and return 1\n\t * - Don't push anything on stack and return 0\n\t */\n\n\tif (DUK_USE_DATE_PARSE_STRING(ctx, str) != 0) {\n\t\treturn 1;\n\t}\n#else\n\t/* No platform-specific parsing, this is not an error. */\n#endif\n\n\tduk_push_nan(ctx);\n\treturn 1;\n}\n\n/*\n *  Calendar helpers\n *\n *  Some helpers are used for getters and can operate on normalized values\n *  which can be represented with 32-bit signed integers.  Other helpers are\n *  needed by setters and operate on un-normalized double values, must watch\n *  out for non-finite numbers etc.\n */\n\nDUK_LOCAL duk_uint8_t duk__days_in_month[12] = {\n\t(duk_uint8_t) 31, (duk_uint8_t) 28, (duk_uint8_t) 31, (duk_uint8_t) 30,\n\t(duk_uint8_t) 31, (duk_uint8_t) 30, (duk_uint8_t) 31, (duk_uint8_t) 31,\n\t(duk_uint8_t) 30, (duk_uint8_t) 31, (duk_uint8_t) 30, (duk_uint8_t) 31\n};\n\n/* Maximum iteration count for computing UTC-to-local time offset when\n * creating an Ecmascript time value from local parts.\n */\n#define DUK__LOCAL_TZOFFSET_MAXITER   4\n\n/* Because 'day since epoch' can be negative and is used to compute weekday\n * using a modulo operation, add this multiple of 7 to avoid negative values\n * when year is below 1970 epoch.  Ecmascript time values are restricted to\n * +/- 100 million days from epoch, so this adder fits nicely into 32 bits.\n * Round to a multiple of 7 (= floor(100000000 / 7) * 7) and add margin.\n */\n#define DUK__WEEKDAY_MOD_ADDER  (20000000 * 7)  /* 0x08583b00 */\n\nDUK_INTERNAL duk_bool_t duk_bi_date_is_leap_year(duk_int_t year) {\n\tif ((year % 4) != 0) {\n\t\treturn 0;\n\t}\n\tif ((year % 100) != 0) {\n\t\treturn 1;\n\t}\n\tif ((year % 400) != 0) {\n\t\treturn 0;\n\t}\n\treturn 1;\n}\n\nDUK_INTERNAL duk_bool_t duk_bi_date_timeval_in_valid_range(duk_double_t x) {\n\treturn (x >= -DUK_DATE_MSEC_100M_DAYS && x <= DUK_DATE_MSEC_100M_DAYS);\n}\n\nDUK_INTERNAL duk_bool_t duk_bi_date_timeval_in_leeway_range(duk_double_t x) {\n\treturn (x >= -DUK_DATE_MSEC_100M_DAYS_LEEWAY && x <= DUK_DATE_MSEC_100M_DAYS_LEEWAY);\n}\n\nDUK_INTERNAL duk_bool_t duk_bi_date_year_in_valid_range(duk_double_t x) {\n\treturn (x >= DUK_DATE_MIN_ECMA_YEAR && x <= DUK_DATE_MAX_ECMA_YEAR);\n}\n\nDUK_LOCAL duk_double_t duk__timeclip(duk_double_t x) {\n\tif (!DUK_ISFINITE(x)) {\n\t\treturn DUK_DOUBLE_NAN;\n\t}\n\n\tif (!duk_bi_date_timeval_in_valid_range(x)) {\n\t\treturn DUK_DOUBLE_NAN;\n\t}\n\n\tx = duk_js_tointeger_number(x);\n\n\t/* Here we'd have the option to normalize -0 to +0. */\n\treturn x;\n}\n\n/* Integer division which floors also negative values correctly. */\nDUK_LOCAL duk_int_t duk__div_floor(duk_int_t a, duk_int_t b) {\n\tDUK_ASSERT(b > 0);\n\tif (a >= 0) {\n\t\treturn a / b;\n\t} else {\n\t\t/* e.g. a = -4, b = 5  -->  -4 - 5 + 1 / 5  -->  -8 / 5  -->  -1\n\t\t *      a = -5, b = 5  -->  -5 - 5 + 1 / 5  -->  -9 / 5  -->  -1\n\t\t *      a = -6, b = 5  -->  -6 - 5 + 1 / 5  -->  -10 / 5  -->  -2\n\t\t */\n\t\treturn (a - b + 1) / b;\n\t}\n}\n\n/* Compute day number of the first day of a given year. */\nDUK_LOCAL duk_int_t duk__day_from_year(duk_int_t year) {\n\t/* Note: in integer arithmetic, (x / 4) is same as floor(x / 4) for non-negative\n\t * values, but is incorrect for negative ones.\n\t */\n\treturn 365 * (year - 1970)\n\t       + duk__div_floor(year - 1969, 4)\n\t       - duk__div_floor(year - 1901, 100)\n\t       + duk__div_floor(year - 1601, 400);\n}\n\n/* Given a day number, determine year and day-within-year. */\nDUK_LOCAL duk_int_t duk__year_from_day(duk_int_t day, duk_small_int_t *out_day_within_year) {\n\tduk_int_t year;\n\tduk_int_t diff_days;\n\n\t/* estimate year upwards (towards positive infinity), then back down;\n\t * two iterations should be enough\n\t */\n\n\tif (day >= 0) {\n\t\tyear = 1970 + day / 365;\n\t} else {\n\t\tyear = 1970 + day / 366;\n\t}\n\n\tfor (;;) {\n\t\tdiff_days = duk__day_from_year(year) - day;\n\t\tDUK_DDD(DUK_DDDPRINT(\"year=%ld day=%ld, diff_days=%ld\", (long) year, (long) day, (long) diff_days));\n\t\tif (diff_days <= 0) {\n\t\t\tDUK_ASSERT(-diff_days < 366);  /* fits into duk_small_int_t */\n\t\t\t*out_day_within_year = -diff_days;\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"--> year=%ld, day-within-year=%ld\",\n\t\t\t                     (long) year, (long) *out_day_within_year));\n\t\t\tDUK_ASSERT(*out_day_within_year >= 0);\n\t\t\tDUK_ASSERT(*out_day_within_year < (duk_bi_date_is_leap_year(year) ? 366 : 365));\n\t\t\treturn year;\n\t\t}\n\n\t\t/* Note: this is very tricky; we must never 'overshoot' the\n\t\t * correction downwards.\n\t\t */\n\t\tyear -= 1 + (diff_days - 1) / 366;  /* conservative */\n\t}\n}\n\n/* Given a (year, month, day-within-month) triple, compute day number.\n * The input triple is un-normalized and may contain non-finite values.\n */\nDUK_LOCAL duk_double_t duk__make_day(duk_double_t year, duk_double_t month, duk_double_t day) {\n\tduk_int_t day_num;\n\tduk_bool_t is_leap;\n\tduk_small_int_t i, n;\n\n\t/* Assume that year, month, day are all coerced to whole numbers.\n\t * They may also be NaN or infinity, in which case this function\n\t * must return NaN or infinity to ensure time value becomes NaN.\n\t * If 'day' is NaN, the final return will end up returning a NaN,\n\t * so it doesn't need to be checked here.\n\t */\n\n\tif (!DUK_ISFINITE(year) || !DUK_ISFINITE(month)) {\n\t\treturn DUK_DOUBLE_NAN;\n\t}\n\n\tyear += DUK_FLOOR(month / 12.0);\n\n\tmonth = DUK_FMOD(month, 12.0);\n\tif (month < 0.0) {\n\t\t/* handle negative values */\n\t\tmonth += 12.0;\n\t}\n\n\t/* The algorithm in E5.1 Section 15.9.1.12 normalizes month, but\n\t * does not normalize the day-of-month (nor check whether or not\n\t * it is finite) because it's not necessary for finding the day\n\t * number which matches the (year,month) pair.\n\t *\n\t * We assume that duk__day_from_year() is exact here.\n\t *\n\t * Without an explicit infinity / NaN check in the beginning,\n\t * day_num would be a bogus integer here.\n\t *\n\t * It's possible for 'year' to be out of integer range here.\n\t * If so, we need to return NaN without integer overflow.\n\t * This fixes test-bug-setyear-overflow.js.\n\t */\n\n\tif (!duk_bi_date_year_in_valid_range(year)) {\n\t\tDUK_DD(DUK_DDPRINT(\"year not in ecmascript valid range, avoid integer overflow: %lf\", (double) year));\n\t\treturn DUK_DOUBLE_NAN;\n\t}\n\tday_num = duk__day_from_year((duk_int_t) year);\n\tis_leap = duk_bi_date_is_leap_year((duk_int_t) year);\n\n\tn = (duk_small_int_t) month;\n\tfor (i = 0; i < n; i++) {\n\t\tday_num += duk__days_in_month[i];\n\t\tif (i == 1 && is_leap) {\n\t\t\tday_num++;\n\t\t}\n\t}\n\n\t/* If 'day' is NaN, returns NaN. */\n\treturn (duk_double_t) day_num + day;\n}\n\n/* Split time value into parts.  The time value is assumed to be an internal\n * one, i.e. finite, no fractions.  Possible local time adjustment has already\n * been applied when reading the time value.\n */\nDUK_INTERNAL void duk_bi_date_timeval_to_parts(duk_double_t d, duk_int_t *parts, duk_double_t *dparts, duk_small_uint_t flags) {\n\tduk_double_t d1, d2;\n\tduk_int_t t1, t2;\n\tduk_int_t day_since_epoch;\n\tduk_int_t year;  /* does not fit into 16 bits */\n\tduk_small_int_t day_in_year;\n\tduk_small_int_t month;\n\tduk_small_int_t day;\n\tduk_small_int_t dim;\n\tduk_int_t jan1_since_epoch;\n\tduk_small_int_t jan1_weekday;\n\tduk_int_t equiv_year;\n\tduk_small_uint_t i;\n\tduk_bool_t is_leap;\n\tduk_small_int_t arridx;\n\n\tDUK_ASSERT(DUK_ISFINITE(d));    /* caller checks */\n\tDUK_ASSERT(DUK_FLOOR(d) == d);  /* no fractions in internal time */\n\n\t/* The timevalue must be in valid Ecmascript range, but since a local\n\t * time offset can be applied, we need to allow a +/- 24h leeway to\n\t * the value.  In other words, although the UTC time is within the\n\t * Ecmascript range, the local part values can be just outside of it.\n\t */\n\tDUK_UNREF(duk_bi_date_timeval_in_leeway_range);\n\tDUK_ASSERT(duk_bi_date_timeval_in_leeway_range(d));\n\n\t/* these computations are guaranteed to be exact for the valid\n\t * E5 time value range, assuming milliseconds without fractions.\n\t */\n\td1 = (duk_double_t) DUK_FMOD(d, (double) DUK_DATE_MSEC_DAY);\n\tif (d1 < 0.0) {\n\t\t/* deal with negative values */\n\t\td1 += (duk_double_t) DUK_DATE_MSEC_DAY;\n\t}\n\td2 = DUK_FLOOR((double) (d / (duk_double_t) DUK_DATE_MSEC_DAY));\n\tDUK_ASSERT(d2 * ((duk_double_t) DUK_DATE_MSEC_DAY) + d1 == d);\n\t/* now expected to fit into a 32-bit integer */\n\tt1 = (duk_int_t) d1;\n\tt2 = (duk_int_t) d2;\n\tday_since_epoch = t2;\n\tDUK_ASSERT((duk_double_t) t1 == d1);\n\tDUK_ASSERT((duk_double_t) t2 == d2);\n\n\t/* t1 = milliseconds within day (fits 32 bit)\n\t * t2 = day number from epoch (fits 32 bit, may be negative)\n\t */\n\n\tparts[DUK_DATE_IDX_MILLISECOND] = t1 % 1000; t1 /= 1000;\n\tparts[DUK_DATE_IDX_SECOND] = t1 % 60; t1 /= 60;\n\tparts[DUK_DATE_IDX_MINUTE] = t1 % 60; t1 /= 60;\n\tparts[DUK_DATE_IDX_HOUR] = t1;\n\tDUK_ASSERT(parts[DUK_DATE_IDX_MILLISECOND] >= 0 && parts[DUK_DATE_IDX_MILLISECOND] <= 999);\n\tDUK_ASSERT(parts[DUK_DATE_IDX_SECOND] >= 0 && parts[DUK_DATE_IDX_SECOND] <= 59);\n\tDUK_ASSERT(parts[DUK_DATE_IDX_MINUTE] >= 0 && parts[DUK_DATE_IDX_MINUTE] <= 59);\n\tDUK_ASSERT(parts[DUK_DATE_IDX_HOUR] >= 0 && parts[DUK_DATE_IDX_HOUR] <= 23);\n\n\tDUK_DDD(DUK_DDDPRINT(\"d=%lf, d1=%lf, d2=%lf, t1=%ld, t2=%ld, parts: hour=%ld min=%ld sec=%ld msec=%ld\",\n\t                     (double) d, (double) d1, (double) d2, (long) t1, (long) t2,\n\t                     (long) parts[DUK_DATE_IDX_HOUR],\n\t                     (long) parts[DUK_DATE_IDX_MINUTE],\n\t                     (long) parts[DUK_DATE_IDX_SECOND],\n\t                     (long) parts[DUK_DATE_IDX_MILLISECOND]));\n\n\t/* This assert depends on the input parts representing time inside\n\t * the Ecmascript range.\n\t */\n\tDUK_ASSERT(t2 + DUK__WEEKDAY_MOD_ADDER >= 0);\n\tparts[DUK_DATE_IDX_WEEKDAY] = (t2 + 4 + DUK__WEEKDAY_MOD_ADDER) % 7;  /* E5.1 Section 15.9.1.6 */\n\tDUK_ASSERT(parts[DUK_DATE_IDX_WEEKDAY] >= 0 && parts[DUK_DATE_IDX_WEEKDAY] <= 6);\n\n\tyear = duk__year_from_day(t2, &day_in_year);\n\tday = day_in_year;\n\tis_leap = duk_bi_date_is_leap_year(year);\n\tfor (month = 0; month < 12; month++) {\n\t\tdim = duk__days_in_month[month];\n\t\tif (month == 1 && is_leap) {\n\t\t\tdim++;\n\t\t}\n\t\tDUK_DDD(DUK_DDDPRINT(\"month=%ld, dim=%ld, day=%ld\",\n\t\t                     (long) month, (long) dim, (long) day));\n\t\tif (day < dim) {\n\t\t\tbreak;\n\t\t}\n\t\tday -= dim;\n\t}\n\tDUK_DDD(DUK_DDDPRINT(\"final month=%ld\", (long) month));\n\tDUK_ASSERT(month >= 0 && month <= 11);\n\tDUK_ASSERT(day >= 0 && day <= 31);\n\n\t/* Equivalent year mapping, used to avoid DST trouble when platform\n\t * may fail to provide reasonable DST answers for dates outside the\n\t * ordinary range (e.g. 1970-2038).  An equivalent year has the same\n\t * leap-year-ness as the original year and begins on the same weekday\n\t * (Jan 1).\n\t *\n\t * The year 2038 is avoided because there seem to be problems with it\n\t * on some platforms.  The year 1970 is also avoided as there were\n\t * practical problems with it; an equivalent year is used for it too,\n\t * which breaks some DST computations for 1970 right now, see e.g.\n\t * test-bi-date-tzoffset-brute-fi.js.\n\t */\n\tif ((flags & DUK_DATE_FLAG_EQUIVYEAR) && (year < 1971 || year > 2037)) {\n\t\tDUK_ASSERT(is_leap == 0 || is_leap == 1);\n\n\t\tjan1_since_epoch = day_since_epoch - day_in_year;  /* day number for Jan 1 since epoch */\n\t\tDUK_ASSERT(jan1_since_epoch + DUK__WEEKDAY_MOD_ADDER >= 0);\n\t\tjan1_weekday = (jan1_since_epoch + 4 + DUK__WEEKDAY_MOD_ADDER) % 7;  /* E5.1 Section 15.9.1.6 */\n\t\tDUK_ASSERT(jan1_weekday >= 0 && jan1_weekday <= 6);\n\t\tarridx = jan1_weekday;\n\t\tif (is_leap) {\n\t\t\tarridx += 7;\n\t\t}\n\t\tDUK_ASSERT(arridx >= 0 && arridx < (duk_small_int_t) (sizeof(duk__date_equivyear) / sizeof(duk_uint8_t)));\n\n\t\tequiv_year = (duk_int_t) duk__date_equivyear[arridx] + 1970;\n\t\tyear = equiv_year;\n\t\tDUK_DDD(DUK_DDDPRINT(\"equiv year mapping, year=%ld, day_in_year=%ld, day_since_epoch=%ld, \"\n\t\t                     \"jan1_since_epoch=%ld, jan1_weekday=%ld -> equiv year %ld\",\n\t\t                     (long) year, (long) day_in_year, (long) day_since_epoch,\n\t\t                     (long) jan1_since_epoch, (long) jan1_weekday, (long) equiv_year));\n\t}\n\n\tparts[DUK_DATE_IDX_YEAR] = year;\n\tparts[DUK_DATE_IDX_MONTH] = month;\n\tparts[DUK_DATE_IDX_DAY] = day;\n\n\tif (flags & DUK_DATE_FLAG_ONEBASED) {\n\t\tparts[DUK_DATE_IDX_MONTH]++;  /* zero-based -> one-based */\n\t\tparts[DUK_DATE_IDX_DAY]++;    /* -\"\"- */\n\t}\n\n\tif (dparts != NULL) {\n\t\tfor (i = 0; i < DUK_DATE_IDX_NUM_PARTS; i++) {\n\t\t\tdparts[i] = (duk_double_t) parts[i];\n\t\t}\n\t}\n}\n\n/* Compute time value from (double) parts.  The parts can be either UTC\n * or local time; if local, they need to be (conceptually) converted into\n * UTC time.  The parts may represent valid or invalid time, and may be\n * wildly out of range (but may cancel each other and still come out in\n * the valid Date range).\n */\nDUK_INTERNAL duk_double_t duk_bi_date_get_timeval_from_dparts(duk_double_t *dparts, duk_small_uint_t flags) {\n#if defined(DUK_USE_PARANOID_DATE_COMPUTATION)\n\t/* See comments below on MakeTime why these are volatile. */\n\tvolatile duk_double_t tmp_time;\n\tvolatile duk_double_t tmp_day;\n\tvolatile duk_double_t d;\n#else\n\tduk_double_t tmp_time;\n\tduk_double_t tmp_day;\n\tduk_double_t d;\n#endif\n\tduk_small_uint_t i;\n\tduk_int_t tzoff, tzoffprev1, tzoffprev2;\n\n\t/* Expects 'this' at top of stack on entry. */\n\n\t/* Coerce all finite parts with ToInteger().  ToInteger() must not\n\t * be called for NaN/Infinity because it will convert e.g. NaN to\n\t * zero.  If ToInteger() has already been called, this has no side\n\t * effects and is idempotent.\n\t *\n\t * Don't read dparts[DUK_DATE_IDX_WEEKDAY]; it will cause Valgrind\n\t * issues if the value is uninitialized.\n\t */\n\tfor (i = 0; i <= DUK_DATE_IDX_MILLISECOND; i++) {\n\t\t/* SCANBUILD: scan-build complains here about assigned value\n\t\t * being garbage or undefined.  This is correct but operating\n\t\t * on undefined values has no ill effect and is ignored by the\n\t\t * caller in the case where this happens.\n\t\t */\n\t\td = dparts[i];\n\t\tif (DUK_ISFINITE(d)) {\n\t\t\tdparts[i] = duk_js_tointeger_number(d);\n\t\t}\n\t}\n\n\t/* Use explicit steps in computation to try to ensure that\n\t * computation happens with intermediate results coerced to\n\t * double values (instead of using something more accurate).\n\t * E.g. E5.1 Section 15.9.1.11 requires use of IEEE 754\n\t * rules (= Ecmascript '+' and '*' operators).\n\t *\n\t * Without 'volatile' even this approach fails on some platform\n\t * and compiler combinations.  For instance, gcc 4.8.1 on Ubuntu\n\t * 64-bit, with -m32 and without -std=c99, test-bi-date-canceling.js\n\t * would fail because of some optimizations when computing tmp_time\n\t * (MakeTime below).  Adding 'volatile' to tmp_time solved this\n\t * particular problem (annoyingly, also adding debug prints or\n\t * running the executable under valgrind hides it).\n\t */\n\n\t/* MakeTime */\n\ttmp_time = 0.0;\n\ttmp_time += dparts[DUK_DATE_IDX_HOUR] * ((duk_double_t) DUK_DATE_MSEC_HOUR);\n\ttmp_time += dparts[DUK_DATE_IDX_MINUTE] * ((duk_double_t) DUK_DATE_MSEC_MINUTE);\n\ttmp_time += dparts[DUK_DATE_IDX_SECOND] * ((duk_double_t) DUK_DATE_MSEC_SECOND);\n\ttmp_time += dparts[DUK_DATE_IDX_MILLISECOND];\n\n\t/* MakeDay */\n\ttmp_day = duk__make_day(dparts[DUK_DATE_IDX_YEAR], dparts[DUK_DATE_IDX_MONTH], dparts[DUK_DATE_IDX_DAY]);\n\n\t/* MakeDate */\n\td = tmp_day * ((duk_double_t) DUK_DATE_MSEC_DAY) + tmp_time;\n\n\tDUK_DDD(DUK_DDDPRINT(\"time=%lf day=%lf --> timeval=%lf\",\n\t                     (double) tmp_time, (double) tmp_day, (double) d));\n\n\t/* Optional UTC conversion. */\n\tif (flags & DUK_DATE_FLAG_LOCALTIME) {\n\t\t/* DUK_USE_DATE_GET_LOCAL_TZOFFSET() needs to be called with a\n\t\t * time value computed from UTC parts.  At this point we only\n\t\t * have 'd' which is a time value computed from local parts, so\n\t\t * it is off by the UTC-to-local time offset which we don't know\n\t\t * yet.  The current solution for computing the UTC-to-local\n\t\t * time offset is to iterate a few times and detect a fixed\n\t\t * point or a two-cycle loop (or a sanity iteration limit),\n\t\t * see test-bi-date-local-parts.js and test-bi-date-tzoffset-basic-fi.js.\n\t\t *\n\t\t * E5.1 Section 15.9.1.9:\n\t\t * UTC(t) = t - LocalTZA - DaylightSavingTA(t - LocalTZA)\n\t\t *\n\t\t * For NaN/inf, DUK_USE_DATE_GET_LOCAL_TZOFFSET() returns 0.\n\t\t */\n\n#if 0\n\t\t/* Old solution: don't iterate, incorrect */\n\t\ttzoff = DUK_USE_DATE_GET_LOCAL_TZOFFSET(d);\n\t\tDUK_DDD(DUK_DDDPRINT(\"tzoffset w/o iteration, tzoff=%ld\", (long) tzoff));\n\t\td -= tzoff * 1000L;\n\t\tDUK_UNREF(tzoffprev1);\n\t\tDUK_UNREF(tzoffprev2);\n#endif\n\n\t\t/* Iteration solution */\n\t\ttzoff = 0;\n\t\ttzoffprev1 = 999999999L;  /* invalid value which never matches */\n\t\tfor (i = 0; i < DUK__LOCAL_TZOFFSET_MAXITER; i++) {\n\t\t\ttzoffprev2 = tzoffprev1;\n\t\t\ttzoffprev1 = tzoff;\n\t\t\ttzoff = DUK_USE_DATE_GET_LOCAL_TZOFFSET(d - tzoff * 1000L);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"tzoffset iteration, i=%d, tzoff=%ld, tzoffprev1=%ld tzoffprev2=%ld\",\n\t\t\t                     (int) i, (long) tzoff, (long) tzoffprev1, (long) tzoffprev2));\n\t\t\tif (tzoff == tzoffprev1) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"tzoffset iteration finished, i=%d, tzoff=%ld, tzoffprev1=%ld, tzoffprev2=%ld\",\n\t\t\t\t                     (int) i, (long) tzoff, (long) tzoffprev1, (long) tzoffprev2));\n\t\t\t\tbreak;\n\t\t\t} else if (tzoff == tzoffprev2) {\n\t\t\t\t/* Two value cycle, see e.g. test-bi-date-tzoffset-basic-fi.js.\n\t\t\t\t * In these cases, favor a higher tzoffset to get a consistent\n\t\t\t\t * result which is independent of iteration count.  Not sure if\n\t\t\t\t * this is a generically correct solution.\n\t\t\t\t */\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"tzoffset iteration two-value cycle, i=%d, tzoff=%ld, tzoffprev1=%ld, tzoffprev2=%ld\",\n\t\t\t\t                     (int) i, (long) tzoff, (long) tzoffprev1, (long) tzoffprev2));\n\t\t\t\tif (tzoffprev1 > tzoff) {\n\t\t\t\t\ttzoff = tzoffprev1;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tDUK_DDD(DUK_DDDPRINT(\"tzoffset iteration, tzoff=%ld\", (long) tzoff));\n\t\td -= tzoff * 1000L;\n\t}\n\n\t/* TimeClip(), which also handles Infinity -> NaN conversion */\n\td = duk__timeclip(d);\n\n\treturn d;\n}\n\n/*\n *  API oriented helpers\n */\n\n/* Push 'this' binding, check that it is a Date object; then push the\n * internal time value.  At the end, stack is: [ ... this timeval ].\n * Returns the time value.  Local time adjustment is done if requested.\n */\nDUK_LOCAL duk_double_t duk__push_this_get_timeval_tzoffset(duk_context *ctx, duk_small_uint_t flags, duk_int_t *out_tzoffset) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *h;\n\tduk_double_t d;\n\tduk_int_t tzoffset = 0;\n\n\tduk_push_this(ctx);\n\th = duk_get_hobject(ctx, -1);  /* XXX: getter with class check, useful in built-ins */\n\tif (h == NULL || DUK_HOBJECT_GET_CLASS_NUMBER(h) != DUK_HOBJECT_CLASS_DATE) {\n\t\tDUK_ERROR_TYPE(thr, \"expected Date\");\n\t}\n\n\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_INT_VALUE);\n\td = duk_to_number_m1(ctx);\n\tduk_pop(ctx);\n\n\tif (DUK_ISNAN(d)) {\n\t\tif (flags & DUK_DATE_FLAG_NAN_TO_ZERO) {\n\t\t\td = 0.0;\n\t\t}\n\t\tif (flags & DUK_DATE_FLAG_NAN_TO_RANGE_ERROR) {\n\t\t\tDUK_ERROR_RANGE(thr, \"Invalid Date\");\n\t\t}\n\t}\n\t/* if no NaN handling flag, may still be NaN here, but not Inf */\n\tDUK_ASSERT(!DUK_ISINF(d));\n\n\tif (flags & DUK_DATE_FLAG_LOCALTIME) {\n\t\t/* Note: DST adjustment is determined using UTC time.\n\t\t * If 'd' is NaN, tzoffset will be 0.\n\t\t */\n\t\ttzoffset = DUK_USE_DATE_GET_LOCAL_TZOFFSET(d);  /* seconds */\n\t\td += tzoffset * 1000L;\n\t}\n\tif (out_tzoffset) {\n\t\t*out_tzoffset = tzoffset;\n\t}\n\n\t/* [ ... this ] */\n\treturn d;\n}\n\nDUK_LOCAL duk_double_t duk__push_this_get_timeval(duk_context *ctx, duk_small_uint_t flags) {\n\treturn duk__push_this_get_timeval_tzoffset(ctx, flags, NULL);\n}\n\n/* Set timeval to 'this' from dparts, push the new time value onto the\n * value stack and return 1 (caller can then tail call us).  Expects\n * the value stack to contain 'this' on the stack top.\n */\nDUK_LOCAL duk_ret_t duk__set_this_timeval_from_dparts(duk_context *ctx, duk_double_t *dparts, duk_small_uint_t flags) {\n\tduk_double_t d;\n\n\t/* [ ... this ] */\n\n\td = duk_bi_date_get_timeval_from_dparts(dparts, flags);\n\tduk_push_number(ctx, d);  /* -> [ ... this timeval_new ] */\n\tduk_dup_top(ctx);         /* -> [ ... this timeval_new timeval_new ] */\n\tduk_put_prop_stridx_short(ctx, -3, DUK_STRIDX_INT_VALUE);\n\n\t/* stack top: new time value, return 1 to allow tail calls */\n\treturn 1;\n}\n\n/* 'out_buf' must be at least DUK_BI_DATE_ISO8601_BUFSIZE long. */\nDUK_LOCAL void duk__format_parts_iso8601(duk_int_t *parts, duk_int_t tzoffset, duk_small_uint_t flags, duk_uint8_t *out_buf) {\n\tchar yearstr[8];   /* \"-123456\\0\" */\n\tchar tzstr[8];     /* \"+11:22\\0\" */\n\tchar sep = (flags & DUK_DATE_FLAG_SEP_T) ? DUK_ASC_UC_T : DUK_ASC_SPACE;\n\n\tDUK_ASSERT(parts[DUK_DATE_IDX_MONTH] >= 1 && parts[DUK_DATE_IDX_MONTH] <= 12);\n\tDUK_ASSERT(parts[DUK_DATE_IDX_DAY] >= 1 && parts[DUK_DATE_IDX_DAY] <= 31);\n\tDUK_ASSERT(parts[DUK_DATE_IDX_YEAR] >= -999999 && parts[DUK_DATE_IDX_YEAR] <= 999999);\n\n\t/* Note: %06d for positive value, %07d for negative value to include\n\t * sign and 6 digits.\n\t */\n\tDUK_SNPRINTF(yearstr,\n\t             sizeof(yearstr),\n\t             (parts[DUK_DATE_IDX_YEAR] >= 0 && parts[DUK_DATE_IDX_YEAR] <= 9999) ? \"%04ld\" :\n\t                    ((parts[DUK_DATE_IDX_YEAR] >= 0) ? \"+%06ld\" : \"%07ld\"),\n\t             (long) parts[DUK_DATE_IDX_YEAR]);\n\tyearstr[sizeof(yearstr) - 1] = (char) 0;\n\n\tif (flags & DUK_DATE_FLAG_LOCALTIME) {\n\t\t/* tzoffset seconds are dropped; 16 bits suffice for\n\t\t * time offset in minutes\n\t\t */\n\t\tif (tzoffset >= 0) {\n\t\t\tduk_small_int_t tmp = tzoffset / 60;\n\t\t\tDUK_SNPRINTF(tzstr, sizeof(tzstr), \"+%02d:%02d\", (int) (tmp / 60), (int) (tmp % 60));\n\t\t} else {\n\t\t\tduk_small_int_t tmp = -tzoffset / 60;\n\t\t\tDUK_SNPRINTF(tzstr, sizeof(tzstr), \"-%02d:%02d\", (int) (tmp / 60), (int) (tmp % 60));\n\t\t}\n\t\ttzstr[sizeof(tzstr) - 1] = (char) 0;\n\t} else {\n\t\ttzstr[0] = DUK_ASC_UC_Z;\n\t\ttzstr[1] = (char) 0;\n\t}\n\n\t/* Unlike year, the other parts fit into 16 bits so %d format\n\t * is portable.\n\t */\n\tif ((flags & DUK_DATE_FLAG_TOSTRING_DATE) && (flags & DUK_DATE_FLAG_TOSTRING_TIME)) {\n\t\tDUK_SPRINTF((char *) out_buf, \"%s-%02d-%02d%c%02d:%02d:%02d.%03d%s\",\n\t\t            (const char *) yearstr, (int) parts[DUK_DATE_IDX_MONTH], (int) parts[DUK_DATE_IDX_DAY], (int) sep,\n\t\t            (int) parts[DUK_DATE_IDX_HOUR], (int) parts[DUK_DATE_IDX_MINUTE],\n\t\t            (int) parts[DUK_DATE_IDX_SECOND], (int) parts[DUK_DATE_IDX_MILLISECOND], (const char *) tzstr);\n\t} else if (flags & DUK_DATE_FLAG_TOSTRING_DATE) {\n\t\tDUK_SPRINTF((char *) out_buf, \"%s-%02d-%02d\",\n\t\t            (const char *) yearstr, (int) parts[DUK_DATE_IDX_MONTH], (int) parts[DUK_DATE_IDX_DAY]);\n\t} else {\n\t\tDUK_ASSERT(flags & DUK_DATE_FLAG_TOSTRING_TIME);\n\t\tDUK_SPRINTF((char *) out_buf, \"%02d:%02d:%02d.%03d%s\",\n\t\t            (int) parts[DUK_DATE_IDX_HOUR], (int) parts[DUK_DATE_IDX_MINUTE],\n\t\t            (int) parts[DUK_DATE_IDX_SECOND], (int) parts[DUK_DATE_IDX_MILLISECOND],\n\t\t            (const char *) tzstr);\n\t}\n}\n\n/* Helper for string conversion calls: check 'this' binding, get the\n * internal time value, and format date and/or time in a few formats.\n * Return value allows tail calls.\n */\nDUK_LOCAL duk_ret_t duk__to_string_helper(duk_context *ctx, duk_small_uint_t flags) {\n\tduk_double_t d;\n\tduk_int_t parts[DUK_DATE_IDX_NUM_PARTS];\n\tduk_int_t tzoffset;  /* seconds, doesn't fit into 16 bits */\n\tduk_bool_t rc;\n\tduk_uint8_t buf[DUK_BI_DATE_ISO8601_BUFSIZE];\n\n\tDUK_UNREF(rc);  /* unreferenced with some options */\n\n\td = duk__push_this_get_timeval_tzoffset(ctx, flags, &tzoffset);\n\tif (DUK_ISNAN(d)) {\n\t\tduk_push_hstring_stridx(ctx, DUK_STRIDX_INVALID_DATE);\n\t\treturn 1;\n\t}\n\tDUK_ASSERT(DUK_ISFINITE(d));\n\n\t/* formatters always get one-based month/day-of-month */\n\tduk_bi_date_timeval_to_parts(d, parts, NULL, DUK_DATE_FLAG_ONEBASED);\n\tDUK_ASSERT(parts[DUK_DATE_IDX_MONTH] >= 1 && parts[DUK_DATE_IDX_MONTH] <= 12);\n\tDUK_ASSERT(parts[DUK_DATE_IDX_DAY] >= 1 && parts[DUK_DATE_IDX_DAY] <= 31);\n\n\tif (flags & DUK_DATE_FLAG_TOSTRING_LOCALE) {\n\t\t/* try locale specific formatter; if it refuses to format the\n\t\t * string, fall back to an ISO 8601 formatted value in local\n\t\t * time.\n\t\t */\n#if defined(DUK_USE_DATE_FORMAT_STRING)\n\t\t/* Contract, either:\n\t\t * - Push string to value stack and return 1\n\t\t * - Don't push anything and return 0\n\t\t */\n\n\t\trc = DUK_USE_DATE_FORMAT_STRING(ctx, parts, tzoffset, flags);\n\t\tif (rc != 0) {\n\t\t\treturn 1;\n\t\t}\n#else\n\t\t/* No locale specific formatter; this is OK, we fall back\n\t\t * to ISO 8601.\n\t\t */\n#endif\n\t}\n\n\t/* Different calling convention than above used because the helper\n\t * is shared.\n\t */\n\tduk__format_parts_iso8601(parts, tzoffset, flags, buf);\n\tduk_push_string(ctx, (const char *) buf);\n\treturn 1;\n}\n\n/* Helper for component getter calls: check 'this' binding, get the\n * internal time value, split it into parts (either as UTC time or\n * local time), push a specified component as a return value to the\n * value stack and return 1 (caller can then tail call us).\n */\nDUK_LOCAL duk_ret_t duk__get_part_helper(duk_context *ctx, duk_small_uint_t flags_and_idx) {\n\tduk_double_t d;\n\tduk_int_t parts[DUK_DATE_IDX_NUM_PARTS];\n\tduk_small_uint_t idx_part = (duk_small_uint_t) (flags_and_idx >> DUK_DATE_FLAG_VALUE_SHIFT);  /* unpack args */\n\n\tDUK_ASSERT_DISABLE(idx_part >= 0);  /* unsigned */\n\tDUK_ASSERT(idx_part < DUK_DATE_IDX_NUM_PARTS);\n\n\td = duk__push_this_get_timeval(ctx, flags_and_idx);\n\tif (DUK_ISNAN(d)) {\n\t\tduk_push_nan(ctx);\n\t\treturn 1;\n\t}\n\tDUK_ASSERT(DUK_ISFINITE(d));\n\n\tduk_bi_date_timeval_to_parts(d, parts, NULL, flags_and_idx);  /* no need to mask idx portion */\n\n\t/* Setter APIs detect special year numbers (0...99) and apply a +1900\n\t * only in certain cases.  The legacy getYear() getter applies -1900\n\t * unconditionally.\n\t */\n\tduk_push_int(ctx, (flags_and_idx & DUK_DATE_FLAG_SUB1900) ? parts[idx_part] - 1900 : parts[idx_part]);\n\treturn 1;\n}\n\n/* Helper for component setter calls: check 'this' binding, get the\n * internal time value, split it into parts (either as UTC time or\n * local time), modify one or more components as specified, recompute\n * the time value, set it as the internal value.  Finally, push the\n * new time value as a return value to the value stack and return 1\n * (caller can then tail call us).\n */\nDUK_LOCAL duk_ret_t duk__set_part_helper(duk_context *ctx, duk_small_uint_t flags_and_maxnargs) {\n\tduk_double_t d;\n\tduk_int_t parts[DUK_DATE_IDX_NUM_PARTS];\n\tduk_double_t dparts[DUK_DATE_IDX_NUM_PARTS];\n\tduk_idx_t nargs;\n\tduk_small_uint_t maxnargs = (duk_small_uint_t) (flags_and_maxnargs >> DUK_DATE_FLAG_VALUE_SHIFT);  /* unpack args */\n\tduk_small_uint_t idx_first, idx;\n\tduk_small_uint_t i;\n\n\tnargs = duk_get_top(ctx);\n\td = duk__push_this_get_timeval(ctx, flags_and_maxnargs);\n\tDUK_ASSERT(DUK_ISFINITE(d) || DUK_ISNAN(d));\n\n\tif (DUK_ISFINITE(d)) {\n\t\tduk_bi_date_timeval_to_parts(d, parts, dparts, flags_and_maxnargs);\n\t} else {\n\t\t/* NaN timevalue: we need to coerce the arguments, but\n\t\t * the resulting internal timestamp needs to remain NaN.\n\t\t * This works but is not pretty: parts and dparts will\n\t\t * be partially uninitialized, but we only write to them.\n\t\t */\n\t}\n\n\t/*\n\t *  Determining which datetime components to overwrite based on\n\t *  stack arguments is a bit complicated, but important to factor\n\t *  out from setters themselves for compactness.\n\t *\n\t *  If DUK_DATE_FLAG_TIMESETTER, maxnargs indicates setter type:\n\t *\n\t *   1 -> millisecond\n\t *   2 -> second, [millisecond]\n\t *   3 -> minute, [second], [millisecond]\n\t *   4 -> hour, [minute], [second], [millisecond]\n\t *\n\t *  Else:\n\t *\n\t *   1 -> date\n\t *   2 -> month, [date]\n\t *   3 -> year, [month], [date]\n\t *\n\t *  By comparing nargs and maxnargs (and flags) we know which\n\t *  components to override.  We rely on part index ordering.\n\t */\n\n\tif (flags_and_maxnargs & DUK_DATE_FLAG_TIMESETTER) {\n\t\tDUK_ASSERT(maxnargs >= 1 && maxnargs <= 4);\n\t\tidx_first = DUK_DATE_IDX_MILLISECOND - (maxnargs - 1);\n\t} else {\n\t\tDUK_ASSERT(maxnargs >= 1 && maxnargs <= 3);\n\t\tidx_first = DUK_DATE_IDX_DAY - (maxnargs - 1);\n\t}\n\tDUK_ASSERT_DISABLE(idx_first >= 0);  /* unsigned */\n\tDUK_ASSERT(idx_first < DUK_DATE_IDX_NUM_PARTS);\n\n\tfor (i = 0; i < maxnargs; i++) {\n\t\tif ((duk_idx_t) i >= nargs) {\n\t\t\t/* no argument given -> leave components untouched */\n\t\t\tbreak;\n\t\t}\n\t\tidx = idx_first + i;\n\t\tDUK_ASSERT_DISABLE(idx >= 0);  /* unsigned */\n\t\tDUK_ASSERT(idx < DUK_DATE_IDX_NUM_PARTS);\n\n\t\tif (idx == DUK_DATE_IDX_YEAR && (flags_and_maxnargs & DUK_DATE_FLAG_YEAR_FIXUP)) {\n\t\t\tduk__twodigit_year_fixup(ctx, (duk_idx_t) i);\n\t\t}\n\n\t\tdparts[idx] = duk_to_number(ctx, i);\n\n\t\tif (idx == DUK_DATE_IDX_DAY) {\n\t\t\t/* Day-of-month is one-based in the API, but zero-based\n\t\t\t * internally, so fix here.  Note that month is zero-based\n\t\t\t * both in the API and internally.\n\t\t\t */\n\t\t\t/* SCANBUILD: complains about use of uninitialized values.\n\t\t\t * The complaint is correct, but operating in undefined\n\t\t\t * values here is intentional in some cases and the caller\n\t\t\t * ignores the results.\n\t\t\t */\n\t\t\tdparts[idx] -= 1.0;\n\t\t}\n\t}\n\n\t/* Leaves new timevalue on stack top and returns 1, which is correct\n\t * for part setters.\n\t */\n\tif (DUK_ISFINITE(d)) {\n\t\treturn duk__set_this_timeval_from_dparts(ctx, dparts, flags_and_maxnargs);\n\t} else {\n\t\t/* Internal timevalue is already NaN, so don't touch it. */\n\t\tduk_push_nan(ctx);\n\t\treturn 1;\n\t}\n}\n\n/* Apply ToNumber() to specified index; if ToInteger(val) in [0,99], add\n * 1900 and replace value at idx_val.\n */\nDUK_LOCAL void duk__twodigit_year_fixup(duk_context *ctx, duk_idx_t idx_val) {\n\tduk_double_t d;\n\n\t/* XXX: idx_val would fit into 16 bits, but using duk_small_uint_t\n\t * might not generate better code due to casting.\n\t */\n\n\t/* E5 Sections 15.9.3.1, B.2.4, B.2.5 */\n\tduk_to_number(ctx, idx_val);\n\tif (duk_is_nan(ctx, idx_val)) {\n\t\treturn;\n\t}\n\tduk_dup(ctx, idx_val);\n\tduk_to_int(ctx, -1);\n\td = duk_get_number(ctx, -1);  /* get as double to handle huge numbers correctly */\n\tif (d >= 0.0 && d <= 99.0) {\n\t\td += 1900.0;\n\t\tduk_push_number(ctx, d);\n\t\tduk_replace(ctx, idx_val);\n\t}\n\tduk_pop(ctx);\n}\n\n/* Set datetime parts from stack arguments, defaulting any missing values.\n * Day-of-week is not set; it is not required when setting the time value.\n */\nDUK_LOCAL void duk__set_parts_from_args(duk_context *ctx, duk_double_t *dparts, duk_idx_t nargs) {\n\tduk_double_t d;\n\tduk_small_uint_t i;\n\tduk_small_uint_t idx;\n\n\t/* Causes a ToNumber() coercion, but doesn't break coercion order since\n\t * year is coerced first anyway.\n\t */\n\tduk__twodigit_year_fixup(ctx, 0);\n\n\t/* There are at most 7 args, but we use 8 here so that also\n\t * DUK_DATE_IDX_WEEKDAY gets initialized (to zero) to avoid the potential\n\t * for any Valgrind gripes later.\n\t */\n\tfor (i = 0; i < 8; i++) {\n\t\t/* Note: rely on index ordering */\n\t\tidx = DUK_DATE_IDX_YEAR + i;\n\t\tif ((duk_idx_t) i < nargs) {\n\t\t\td = duk_to_number(ctx, (duk_idx_t) i);\n\t\t\tif (idx == DUK_DATE_IDX_DAY) {\n\t\t\t\t/* Convert day from one-based to zero-based (internal).  This may\n\t\t\t\t * cause the day part to be negative, which is OK.\n\t\t\t\t */\n\t\t\t\td -= 1.0;\n\t\t\t}\n\t\t} else {\n\t\t\t/* All components default to 0 except day-of-month which defaults\n\t\t\t * to 1.  However, because our internal day-of-month is zero-based,\n\t\t\t * it also defaults to zero here.\n\t\t\t */\n\t\t\td = 0.0;\n\t\t}\n\t\tdparts[idx] = d;\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"parts from args -> %lf %lf %lf %lf %lf %lf %lf %lf\",\n\t                     (double) dparts[0], (double) dparts[1],\n\t                     (double) dparts[2], (double) dparts[3],\n\t                     (double) dparts[4], (double) dparts[5],\n\t                     (double) dparts[6], (double) dparts[7]));\n}\n\n/*\n *  Indirect magic value lookup for Date methods.\n *\n *  Date methods don't put their control flags into the function magic value\n *  because they wouldn't fit into a LIGHTFUNC's magic field.  Instead, the\n *  magic value is set to an index pointing to the array of control flags\n *  below.\n *\n *  This must be kept in strict sync with genbuiltins.py!\n */\n\nstatic duk_uint16_t duk__date_magics[] = {\n\t/* 0: toString */\n\tDUK_DATE_FLAG_TOSTRING_DATE + DUK_DATE_FLAG_TOSTRING_TIME + DUK_DATE_FLAG_LOCALTIME,\n\n\t/* 1: toDateString */\n\tDUK_DATE_FLAG_TOSTRING_DATE + DUK_DATE_FLAG_LOCALTIME,\n\n\t/* 2: toTimeString */\n\tDUK_DATE_FLAG_TOSTRING_TIME + DUK_DATE_FLAG_LOCALTIME,\n\n\t/* 3: toLocaleString */\n\tDUK_DATE_FLAG_TOSTRING_DATE + DUK_DATE_FLAG_TOSTRING_TIME + DUK_DATE_FLAG_TOSTRING_LOCALE + DUK_DATE_FLAG_LOCALTIME,\n\n\t/* 4: toLocaleDateString */\n\tDUK_DATE_FLAG_TOSTRING_DATE + DUK_DATE_FLAG_TOSTRING_LOCALE + DUK_DATE_FLAG_LOCALTIME,\n\n\t/* 5: toLocaleTimeString */\n\tDUK_DATE_FLAG_TOSTRING_TIME + DUK_DATE_FLAG_TOSTRING_LOCALE + DUK_DATE_FLAG_LOCALTIME,\n\n\t/* 6: toUTCString */\n\tDUK_DATE_FLAG_TOSTRING_DATE + DUK_DATE_FLAG_TOSTRING_TIME,\n\n\t/* 7: toISOString */\n\tDUK_DATE_FLAG_TOSTRING_DATE + DUK_DATE_FLAG_TOSTRING_TIME + DUK_DATE_FLAG_NAN_TO_RANGE_ERROR + DUK_DATE_FLAG_SEP_T,\n\n\t/* 8: getFullYear */\n\tDUK_DATE_FLAG_LOCALTIME + (DUK_DATE_IDX_YEAR << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 9: getUTCFullYear */\n\t0 + (DUK_DATE_IDX_YEAR << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 10: getMonth */\n\tDUK_DATE_FLAG_LOCALTIME + (DUK_DATE_IDX_MONTH << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 11: getUTCMonth */\n\t0 + (DUK_DATE_IDX_MONTH << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 12: getDate */\n\tDUK_DATE_FLAG_ONEBASED + DUK_DATE_FLAG_LOCALTIME + (DUK_DATE_IDX_DAY << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 13: getUTCDate */\n\tDUK_DATE_FLAG_ONEBASED + (DUK_DATE_IDX_DAY << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 14: getDay */\n\tDUK_DATE_FLAG_LOCALTIME + (DUK_DATE_IDX_WEEKDAY << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 15: getUTCDay */\n\t0 + (DUK_DATE_IDX_WEEKDAY << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 16: getHours */\n\tDUK_DATE_FLAG_LOCALTIME + (DUK_DATE_IDX_HOUR << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 17: getUTCHours */\n\t0 + (DUK_DATE_IDX_HOUR << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 18: getMinutes */\n\tDUK_DATE_FLAG_LOCALTIME + (DUK_DATE_IDX_MINUTE << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 19: getUTCMinutes */\n\t0 + (DUK_DATE_IDX_MINUTE << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 20: getSeconds */\n\tDUK_DATE_FLAG_LOCALTIME + (DUK_DATE_IDX_SECOND << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 21: getUTCSeconds */\n\t0 + (DUK_DATE_IDX_SECOND << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 22: getMilliseconds */\n\tDUK_DATE_FLAG_LOCALTIME + (DUK_DATE_IDX_MILLISECOND << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 23: getUTCMilliseconds */\n\t0 + (DUK_DATE_IDX_MILLISECOND << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 24: setMilliseconds */\n\tDUK_DATE_FLAG_TIMESETTER + DUK_DATE_FLAG_LOCALTIME + (1 << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 25: setUTCMilliseconds */\n\tDUK_DATE_FLAG_TIMESETTER + (1 << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 26: setSeconds */\n\tDUK_DATE_FLAG_TIMESETTER + DUK_DATE_FLAG_LOCALTIME + (2 << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 27: setUTCSeconds */\n\tDUK_DATE_FLAG_TIMESETTER + (2 << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 28: setMinutes */\n\tDUK_DATE_FLAG_TIMESETTER + DUK_DATE_FLAG_LOCALTIME + (3 << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 29: setUTCMinutes */\n\tDUK_DATE_FLAG_TIMESETTER + (3 << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 30: setHours */\n\tDUK_DATE_FLAG_TIMESETTER + DUK_DATE_FLAG_LOCALTIME + (4 << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 31: setUTCHours */\n\tDUK_DATE_FLAG_TIMESETTER + (4 << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 32: setDate */\n\tDUK_DATE_FLAG_LOCALTIME + (1 << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 33: setUTCDate */\n\t0 + (1 << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 34: setMonth */\n\tDUK_DATE_FLAG_LOCALTIME + (2 << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 35: setUTCMonth */\n\t0 + (2 << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 36: setFullYear */\n\tDUK_DATE_FLAG_NAN_TO_ZERO + DUK_DATE_FLAG_LOCALTIME + (3 << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 37: setUTCFullYear */\n\tDUK_DATE_FLAG_NAN_TO_ZERO + (3 << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 38: getYear */\n\tDUK_DATE_FLAG_LOCALTIME + DUK_DATE_FLAG_SUB1900 + (DUK_DATE_IDX_YEAR << DUK_DATE_FLAG_VALUE_SHIFT),\n\n\t/* 39: setYear */\n\tDUK_DATE_FLAG_NAN_TO_ZERO + DUK_DATE_FLAG_YEAR_FIXUP + (3 << DUK_DATE_FLAG_VALUE_SHIFT),\n};\n\nDUK_LOCAL duk_small_uint_t duk__date_get_indirect_magic(duk_context *ctx) {\n\tduk_small_int_t magicidx = (duk_small_uint_t) duk_get_current_magic(ctx);\n\tDUK_ASSERT(magicidx >= 0 && magicidx < (duk_small_int_t) (sizeof(duk__date_magics) / sizeof(duk_uint16_t)));\n\treturn (duk_small_uint_t) duk__date_magics[magicidx];\n}\n\n#if defined(DUK_USE_DATE_BUILTIN)\n/*\n *  Constructor calls\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_date_constructor(duk_context *ctx) {\n\tduk_idx_t nargs = duk_get_top(ctx);\n\tduk_bool_t is_cons = duk_is_constructor_call(ctx);\n\tduk_double_t dparts[DUK_DATE_IDX_NUM_PARTS];\n\tduk_double_t d;\n\n\tDUK_DDD(DUK_DDDPRINT(\"Date constructor, nargs=%ld, is_cons=%ld\", (long) nargs, (long) is_cons));\n\n\t(void) duk_push_object_helper(ctx,\n\t                              DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                              DUK_HOBJECT_FLAG_FASTREFS |\n\t                              DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_DATE),\n\t                              DUK_BIDX_DATE_PROTOTYPE);\n\n\t/* Unlike most built-ins, the internal [[PrimitiveValue]] of a Date\n\t * is mutable.\n\t */\n\n\tif (nargs == 0 || !is_cons) {\n\t\td = duk__timeclip(DUK_USE_DATE_GET_NOW(ctx));\n\t\tduk_push_number(ctx, d);\n\t\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_VALUE, DUK_PROPDESC_FLAGS_W);\n\t\tif (!is_cons) {\n\t\t\t/* called as a normal function: return new Date().toString() */\n\t\t\tduk_to_string(ctx, -1);\n\t\t}\n\t\treturn 1;\n\t} else if (nargs == 1) {\n\t\tconst char *str;\n\t\tduk_to_primitive(ctx, 0, DUK_HINT_NONE);\n\t\tstr = duk_get_string_notsymbol(ctx, 0);\n\t\tif (str) {\n\t\t\tduk__parse_string(ctx, str);\n\t\t\tduk_replace(ctx, 0);  /* may be NaN */\n\t\t}\n\t\td = duk__timeclip(duk_to_number(ctx, 0));  /* symbols fail here */\n\t\tduk_push_number(ctx, d);\n\t\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_VALUE, DUK_PROPDESC_FLAGS_W);\n\t\treturn 1;\n\t}\n\n\tduk__set_parts_from_args(ctx, dparts, nargs);\n\n\t/* Parts are in local time, convert when setting. */\n\n\t(void) duk__set_this_timeval_from_dparts(ctx, dparts, DUK_DATE_FLAG_LOCALTIME /*flags*/);  /* -> [ ... this timeval ] */\n\tduk_pop(ctx);  /* -> [ ... this ] */\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_date_constructor_parse(duk_context *ctx) {\n\treturn duk__parse_string(ctx, duk_to_string(ctx, 0));\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_date_constructor_utc(duk_context *ctx) {\n\tduk_idx_t nargs = duk_get_top(ctx);\n\tduk_double_t dparts[DUK_DATE_IDX_NUM_PARTS];\n\tduk_double_t d;\n\n\t/* Behavior for nargs < 2 is implementation dependent: currently we'll\n\t * set a NaN time value (matching V8 behavior) in this case.\n\t */\n\n\tif (nargs < 2) {\n\t\tduk_push_nan(ctx);\n\t} else {\n\t\tduk__set_parts_from_args(ctx, dparts, nargs);\n\t\td = duk_bi_date_get_timeval_from_dparts(dparts, 0 /*flags*/);\n\t\tduk_push_number(ctx, d);\n\t}\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_date_constructor_now(duk_context *ctx) {\n\tduk_double_t d;\n\n\td = DUK_USE_DATE_GET_NOW(ctx);\n\tDUK_ASSERT(duk__timeclip(d) == d);  /* TimeClip() should never be necessary */\n\tduk_push_number(ctx, d);\n\treturn 1;\n}\n\n/*\n *  String/JSON conversions\n *\n *  Human readable conversions are now basically ISO 8601 with a space\n *  (instead of 'T') as the date/time separator.  This is a good baseline\n *  and is platform independent.\n *\n *  A shared native helper to provide many conversions.  Magic value contains\n *  a set of flags.  The helper provides:\n *\n *    toString()\n *    toDateString()\n *    toTimeString()\n *    toLocaleString()\n *    toLocaleDateString()\n *    toLocaleTimeString()\n *    toUTCString()\n *    toISOString()\n *\n *  Notes:\n *\n *    - Date.prototype.toGMTString() and Date.prototype.toUTCString() are\n *      required to be the same Ecmascript function object (!), so it is\n *      omitted from here.\n *\n *    - Date.prototype.toUTCString(): E5.1 specification does not require a\n *      specific format, but result should be human readable.  The\n *      specification suggests using ISO 8601 format with a space (instead\n *      of 'T') separator if a more human readable format is not available.\n *\n *    - Date.prototype.toISOString(): unlike other conversion functions,\n *      toISOString() requires a RangeError for invalid date values.\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_date_prototype_tostring_shared(duk_context *ctx) {\n\tduk_small_uint_t flags = duk__date_get_indirect_magic(ctx);\n\treturn duk__to_string_helper(ctx, flags);\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_date_prototype_value_of(duk_context *ctx) {\n\t/* This native function is also used for Date.prototype.getTime()\n\t * as their behavior is identical.\n\t */\n\n\tduk_double_t d = duk__push_this_get_timeval(ctx, 0 /*flags*/);  /* -> [ this ] */\n\tDUK_ASSERT(DUK_ISFINITE(d) || DUK_ISNAN(d));\n\tduk_push_number(ctx, d);\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_date_prototype_to_json(duk_context *ctx) {\n\t/* Note: toJSON() is a generic function which works even if 'this'\n\t * is not a Date.  The sole argument is ignored.\n\t */\n\n\tduk_push_this(ctx);\n\tduk_to_object(ctx, -1);\n\n\tduk_dup_top(ctx);\n\tduk_to_primitive(ctx, -1, DUK_HINT_NUMBER);\n\tif (duk_is_number(ctx, -1)) {\n\t\tduk_double_t d = duk_get_number(ctx, -1);\n\t\tif (!DUK_ISFINITE(d)) {\n\t\t\tduk_push_null(ctx);\n\t\t\treturn 1;\n\t\t}\n\t}\n\tduk_pop(ctx);\n\n\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_TO_ISO_STRING);\n\tduk_dup_m2(ctx);  /* -> [ O toIsoString O ] */\n\tduk_call_method(ctx, 0);\n\treturn 1;\n}\n\n/*\n *  Getters.\n *\n *  Implementing getters is quite easy.  The internal time value is either\n *  NaN, or represents milliseconds (without fractions) from Jan 1, 1970.\n *  The internal time value can be converted to integer parts, and each\n *  part will be normalized and will fit into a 32-bit signed integer.\n *\n *  A shared native helper to provide all getters.  Magic value contains\n *  a set of flags and also packs the date component index argument.  The\n *  helper provides:\n *\n *    getFullYear()\n *    getUTCFullYear()\n *    getMonth()\n *    getUTCMonth()\n *    getDate()\n *    getUTCDate()\n *    getDay()\n *    getUTCDay()\n *    getHours()\n *    getUTCHours()\n *    getMinutes()\n *    getUTCMinutes()\n *    getSeconds()\n *    getUTCSeconds()\n *    getMilliseconds()\n *    getUTCMilliseconds()\n *    getYear()\n *\n *  Notes:\n *\n *    - Date.prototype.getDate(): 'date' means day-of-month, and is\n *      zero-based in internal calculations but public API expects it to\n *      be one-based.\n *\n *    - Date.prototype.getTime() and Date.prototype.valueOf() have identical\n *      behavior.  They have separate function objects, but share the same C\n *      function (duk_bi_date_prototype_value_of).\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_date_prototype_get_shared(duk_context *ctx) {\n\tduk_small_uint_t flags_and_idx = duk__date_get_indirect_magic(ctx);\n\treturn duk__get_part_helper(ctx, flags_and_idx);\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_date_prototype_get_timezone_offset(duk_context *ctx) {\n\t/*\n\t *  Return (t - LocalTime(t)) in minutes:\n\t *\n\t *    t - LocalTime(t) = t - (t + LocalTZA + DaylightSavingTA(t))\n\t *                     = -(LocalTZA + DaylightSavingTA(t))\n\t *\n\t *  where DaylightSavingTA() is checked for time 't'.\n\t *\n\t *  Note that the sign of the result is opposite to common usage,\n\t *  e.g. for EE(S)T which normally is +2h or +3h from UTC, this\n\t *  function returns -120 or -180.\n\t *\n\t */\n\n\tduk_double_t d;\n\tduk_int_t tzoffset;\n\n\t/* Note: DST adjustment is determined using UTC time. */\n\td = duk__push_this_get_timeval(ctx, 0 /*flags*/);\n\tDUK_ASSERT(DUK_ISFINITE(d) || DUK_ISNAN(d));\n\tif (DUK_ISNAN(d)) {\n\t\tduk_push_nan(ctx);\n\t} else {\n\t\tDUK_ASSERT(DUK_ISFINITE(d));\n\t\ttzoffset = DUK_USE_DATE_GET_LOCAL_TZOFFSET(d);\n\t\tduk_push_int(ctx, -tzoffset / 60);\n\t}\n\treturn 1;\n}\n\n/*\n *  Setters.\n *\n *  Setters are a bit more complicated than getters.  Component setters\n *  break down the current time value into its (normalized) component\n *  parts, replace one or more components with -unnormalized- new values,\n *  and the components are then converted back into a time value.  As an\n *  example of using unnormalized values:\n *\n *    var d = new Date(1234567890);\n *\n *  is equivalent to:\n *\n *    var d = new Date(0);\n *    d.setUTCMilliseconds(1234567890);\n *\n *  A shared native helper to provide almost all setters.  Magic value\n *  contains a set of flags and also packs the \"maxnargs\" argument.  The\n *  helper provides:\n *\n *    setMilliseconds()\n *    setUTCMilliseconds()\n *    setSeconds()\n *    setUTCSeconds()\n *    setMinutes()\n *    setUTCMinutes()\n *    setHours()\n *    setUTCHours()\n *    setDate()\n *    setUTCDate()\n *    setMonth()\n *    setUTCMonth()\n *    setFullYear()\n *    setUTCFullYear()\n *    setYear()\n *\n *  Notes:\n *\n *    - Date.prototype.setYear() (Section B addition): special year check\n *      is omitted.  NaN / Infinity will just flow through and ultimately\n *      result in a NaN internal time value.\n *\n *    - Date.prototype.setYear() does not have optional arguments for\n *      setting month and day-in-month (like setFullYear()), but we indicate\n *      'maxnargs' to be 3 to get the year written to the correct component\n *      index in duk__set_part_helper().  The function has nargs == 1, so only\n *      the year will be set regardless of actual argument count.\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_date_prototype_set_shared(duk_context *ctx) {\n\tduk_small_uint_t flags_and_maxnargs = duk__date_get_indirect_magic(ctx);\n\treturn duk__set_part_helper(ctx, flags_and_maxnargs);\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_date_prototype_set_time(duk_context *ctx) {\n\tduk_double_t d;\n\n\t(void) duk__push_this_get_timeval(ctx, 0 /*flags*/); /* -> [ timeval this ] */\n\td = duk__timeclip(duk_to_number(ctx, 0));\n\tduk_push_number(ctx, d);\n\tduk_dup_top(ctx);\n\tduk_put_prop_stridx_short(ctx, -3, DUK_STRIDX_INT_VALUE); /* -> [ timeval this timeval ] */\n\n\treturn 1;\n}\n\n#endif  /* DUK_USE_DATE_BUILTIN */\n\n/* automatic undefs */\n#undef DUK__CF_ACCEPT\n#undef DUK__CF_ACCEPT_NUL\n#undef DUK__CF_NEG\n#undef DUK__DPRINT_DPARTS\n#undef DUK__DPRINT_PARTS\n#undef DUK__DPRINT_PARTS_AND_DPARTS\n#undef DUK__LOCAL_TZOFFSET_MAXITER\n#undef DUK__NUM_ISO8601_PARSER_PARTS\n#undef DUK__PACK_RULE\n#undef DUK__PI_DAY\n#undef DUK__PI_HOUR\n#undef DUK__PI_MILLISECOND\n#undef DUK__PI_MINUTE\n#undef DUK__PI_MONTH\n#undef DUK__PI_SECOND\n#undef DUK__PI_TZHOUR\n#undef DUK__PI_TZMINUTE\n#undef DUK__PI_YEAR\n#undef DUK__PM_DAY\n#undef DUK__PM_HOUR\n#undef DUK__PM_MILLISECOND\n#undef DUK__PM_MINUTE\n#undef DUK__PM_MONTH\n#undef DUK__PM_SECOND\n#undef DUK__PM_TZHOUR\n#undef DUK__PM_TZMINUTE\n#undef DUK__PM_YEAR\n#undef DUK__RULE_MASK_PART_SEP\n#undef DUK__SI_COLON\n#undef DUK__SI_MINUS\n#undef DUK__SI_NUL\n#undef DUK__SI_PERIOD\n#undef DUK__SI_PLUS\n#undef DUK__SI_SPACE\n#undef DUK__SI_T\n#undef DUK__SI_Z\n#undef DUK__SM_COLON\n#undef DUK__SM_MINUS\n#undef DUK__SM_NUL\n#undef DUK__SM_PERIOD\n#undef DUK__SM_PLUS\n#undef DUK__SM_SPACE\n#undef DUK__SM_T\n#undef DUK__SM_Z\n#undef DUK__UNPACK_RULE\n#undef DUK__WEEKDAY_MOD_ADDER\n#undef DUK__YEAR\n/*\n *  Unix-like Date providers\n *\n *  Generally useful Unix / POSIX / ANSI Date providers.\n */\n\n/* #include duk_internal.h -> already included */\n\n/* The necessary #includes are in place in duk_config.h. */\n\n/* Buffer sizes for some UNIX calls.  Larger than strictly necessary\n * to avoid Valgrind errors.\n */\n#define DUK__STRPTIME_BUF_SIZE  64\n#define DUK__STRFTIME_BUF_SIZE  64\n\n#if defined(DUK_USE_DATE_NOW_GETTIMEOFDAY)\n/* Get current Ecmascript time (= UNIX/Posix time, but in milliseconds). */\nDUK_INTERNAL duk_double_t duk_bi_date_get_now_gettimeofday(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tstruct timeval tv;\n\tduk_double_t d;\n\n\tif (gettimeofday(&tv, NULL) != 0) {\n\t\tDUK_ERROR_INTERNAL(thr);\n\t}\n\n\td = ((duk_double_t) tv.tv_sec) * 1000.0 +\n\t    ((duk_double_t) (tv.tv_usec / 1000));\n\tDUK_ASSERT(DUK_FLOOR(d) == d);  /* no fractions */\n\n\treturn d;\n}\n#endif  /* DUK_USE_DATE_NOW_GETTIMEOFDAY */\n\n#if defined(DUK_USE_DATE_NOW_TIME)\n/* Not a very good provider: only full seconds are available. */\nDUK_INTERNAL duk_double_t duk_bi_date_get_now_time(duk_context *ctx) {\n\ttime_t t;\n\n\tDUK_UNREF(ctx);\n\tt = time(NULL);\n\treturn ((duk_double_t) t) * 1000.0;\n}\n#endif  /* DUK_USE_DATE_NOW_TIME */\n\n#if defined(DUK_USE_DATE_TZO_GMTIME) || defined(DUK_USE_DATE_TZO_GMTIME_R) || defined(DUK_USE_DATE_TZO_GMTIME_S)\n/* Get local time offset (in seconds) for a certain (UTC) instant 'd'. */\nDUK_INTERNAL duk_int_t duk_bi_date_get_local_tzoffset_gmtime(duk_double_t d) {\n\ttime_t t, t1, t2;\n\tduk_int_t parts[DUK_DATE_IDX_NUM_PARTS];\n\tduk_double_t dparts[DUK_DATE_IDX_NUM_PARTS];\n\tstruct tm tms[2];\n#if defined(DUK_USE_DATE_TZO_GMTIME)\n\tstruct tm *tm_ptr;\n#endif\n\n\t/* For NaN/inf, the return value doesn't matter. */\n\tif (!DUK_ISFINITE(d)) {\n\t\treturn 0;\n\t}\n\n\t/* If not within Ecmascript range, some integer time calculations\n\t * won't work correctly (and some asserts will fail), so bail out\n\t * if so.  This fixes test-bug-date-insane-setyear.js.  There is\n\t * a +/- 24h leeway in this range check to avoid a test262 corner\n\t * case documented in test-bug-date-timeval-edges.js.\n\t */\n\tif (!duk_bi_date_timeval_in_leeway_range(d)) {\n\t\tDUK_DD(DUK_DDPRINT(\"timeval not within valid range, skip tzoffset computation to avoid integer overflows\"));\n\t\treturn 0;\n\t}\n\n\t/*\n\t *  This is a bit tricky to implement portably.  The result depends\n\t *  on the timestamp (specifically, DST depends on the timestamp).\n\t *  If e.g. UNIX APIs are used, they'll have portability issues with\n\t *  very small and very large years.\n\t *\n\t *  Current approach:\n\t *\n\t *  - Stay within portable UNIX limits by using equivalent year mapping.\n\t *    Avoid year 1970 and 2038 as some conversions start to fail, at\n\t *    least on some platforms.  Avoiding 1970 means that there are\n\t *    currently DST discrepancies for 1970.\n\t *\n\t *  - Create a UTC and local time breakdowns from 't'.  Then create\n\t *    a time_t using gmtime() and localtime() and compute the time\n\t *    difference between the two.\n\t *\n\t *  Equivalent year mapping (E5 Section 15.9.1.8):\n\t *\n\t *    If the host environment provides functionality for determining\n\t *    daylight saving time, the implementation of ECMAScript is free\n\t *    to map the year in question to an equivalent year (same\n\t *    leap-year-ness and same starting week day for the year) for which\n\t *    the host environment provides daylight saving time information.\n\t *    The only restriction is that all equivalent years should produce\n\t *    the same result.\n\t *\n\t *  This approach is quite reasonable but not entirely correct, e.g.\n\t *  the specification also states (E5 Section 15.9.1.8):\n\t *\n\t *    The implementation of ECMAScript should not try to determine\n\t *    whether the exact time was subject to daylight saving time, but\n\t *    just whether daylight saving time would have been in effect if\n\t *    the _current daylight saving time algorithm_ had been used at the\n\t *    time.  This avoids complications such as taking into account the\n\t *    years that the locale observed daylight saving time year round.\n\t *\n\t *  Since we rely on the platform APIs for conversions between local\n\t *  time and UTC, we can't guarantee the above.  Rather, if the platform\n\t *  has historical DST rules they will be applied.  This seems to be the\n\t *  general preferred direction in Ecmascript standardization (or at least\n\t *  implementations) anyway, and even the equivalent year mapping should\n\t *  be disabled if the platform is known to handle DST properly for the\n\t *  full Ecmascript range.\n\t *\n\t *  The following has useful discussion and links:\n\t *\n\t *    https://bugzilla.mozilla.org/show_bug.cgi?id=351066\n\t */\n\n\tduk_bi_date_timeval_to_parts(d, parts, dparts, DUK_DATE_FLAG_EQUIVYEAR /*flags*/);\n\tDUK_ASSERT(parts[DUK_DATE_IDX_YEAR] >= 1970 && parts[DUK_DATE_IDX_YEAR] <= 2038);\n\n\td = duk_bi_date_get_timeval_from_dparts(dparts, 0 /*flags*/);\n\tDUK_ASSERT(d >= 0 && d < 2147483648.0 * 1000.0);  /* unsigned 31-bit range */\n\tt = (time_t) (d / 1000.0);\n\tDUK_DDD(DUK_DDDPRINT(\"timeval: %lf -> time_t %ld\", (double) d, (long) t));\n\n\tDUK_MEMZERO((void *) tms, sizeof(struct tm) * 2);\n\n#if defined(DUK_USE_DATE_TZO_GMTIME_R)\n\t(void) gmtime_r(&t, &tms[0]);\n\t(void) localtime_r(&t, &tms[1]);\n#elif defined(DUK_USE_DATE_TZO_GMTIME_S)\n\t(void) gmtime_s(&t, &tms[0]);\n\t(void) localtime_s(&t, &tms[1]);\n#elif defined(DUK_USE_DATE_TZO_GMTIME)\n\ttm_ptr = gmtime(&t);\n\tDUK_MEMCPY((void *) &tms[0], tm_ptr, sizeof(struct tm));\n\ttm_ptr = localtime(&t);\n\tDUK_MEMCPY((void *) &tms[1], tm_ptr, sizeof(struct tm));\n#else\n#error internal error\n#endif\n\tDUK_DDD(DUK_DDDPRINT(\"gmtime result: tm={sec:%ld,min:%ld,hour:%ld,mday:%ld,mon:%ld,year:%ld,\"\n\t                     \"wday:%ld,yday:%ld,isdst:%ld}\",\n\t                     (long) tms[0].tm_sec, (long) tms[0].tm_min, (long) tms[0].tm_hour,\n\t                     (long) tms[0].tm_mday, (long) tms[0].tm_mon, (long) tms[0].tm_year,\n\t                     (long) tms[0].tm_wday, (long) tms[0].tm_yday, (long) tms[0].tm_isdst));\n\tDUK_DDD(DUK_DDDPRINT(\"localtime result: tm={sec:%ld,min:%ld,hour:%ld,mday:%ld,mon:%ld,year:%ld,\"\n\t                     \"wday:%ld,yday:%ld,isdst:%ld}\",\n\t                     (long) tms[1].tm_sec, (long) tms[1].tm_min, (long) tms[1].tm_hour,\n\t                     (long) tms[1].tm_mday, (long) tms[1].tm_mon, (long) tms[1].tm_year,\n\t                     (long) tms[1].tm_wday, (long) tms[1].tm_yday, (long) tms[1].tm_isdst));\n\n\t/* tm_isdst is both an input and an output to mktime(), use 0 to\n\t * avoid DST handling in mktime():\n\t * - https://github.com/svaarala/duktape/issues/406\n\t * - http://stackoverflow.com/questions/8558919/mktime-and-tm-isdst\n\t */\n\ttms[0].tm_isdst = 0;\n\ttms[1].tm_isdst = 0;\n\tt1 = mktime(&tms[0]);  /* UTC */\n\tt2 = mktime(&tms[1]);  /* local */\n\tif (t1 == (time_t) -1 || t2 == (time_t) -1) {\n\t\t/* This check used to be for (t < 0) but on some platforms\n\t\t * time_t is unsigned and apparently the proper way to detect\n\t\t * an mktime() error return is the cast above.  See e.g.:\n\t\t * http://pubs.opengroup.org/onlinepubs/009695299/functions/mktime.html\n\t\t */\n\t\tgoto mktime_error;\n\t}\n\tDUK_DDD(DUK_DDDPRINT(\"t1=%ld (utc), t2=%ld (local)\", (long) t1, (long) t2));\n\n\t/* Compute final offset in seconds, positive if local time ahead of\n\t * UTC (returned value is UTC-to-local offset).\n\t *\n\t * difftime() returns a double, so coercion to int generates quite\n\t * a lot of code.  Direct subtraction is not portable, however.\n\t * XXX: allow direct subtraction on known platforms.\n\t */\n#if 0\n\treturn (duk_int_t) (t2 - t1);\n#endif\n\treturn (duk_int_t) difftime(t2, t1);\n\n mktime_error:\n\t/* XXX: return something more useful, so that caller can throw? */\n\tDUK_D(DUK_DPRINT(\"mktime() failed, d=%lf\", (double) d));\n\treturn 0;\n}\n#endif  /* DUK_USE_DATE_TZO_GMTIME */\n\n#if defined(DUK_USE_DATE_PRS_STRPTIME)\nDUK_INTERNAL duk_bool_t duk_bi_date_parse_string_strptime(duk_context *ctx, const char *str) {\n\tstruct tm tm;\n\ttime_t t;\n\tchar buf[DUK__STRPTIME_BUF_SIZE];\n\n\t/* copy to buffer with spare to avoid Valgrind gripes from strptime */\n\tDUK_ASSERT(str != NULL);\n\tDUK_MEMZERO(buf, sizeof(buf));  /* valgrind whine without this */\n\tDUK_SNPRINTF(buf, sizeof(buf), \"%s\", (const char *) str);\n\tbuf[sizeof(buf) - 1] = (char) 0;\n\n\tDUK_DDD(DUK_DDDPRINT(\"parsing: '%s'\", (const char *) buf));\n\n\tDUK_MEMZERO(&tm, sizeof(tm));\n\tif (strptime((const char *) buf, \"%c\", &tm) != NULL) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"before mktime: tm={sec:%ld,min:%ld,hour:%ld,mday:%ld,mon:%ld,year:%ld,\"\n\t\t                     \"wday:%ld,yday:%ld,isdst:%ld}\",\n\t\t                     (long) tm.tm_sec, (long) tm.tm_min, (long) tm.tm_hour,\n\t\t                     (long) tm.tm_mday, (long) tm.tm_mon, (long) tm.tm_year,\n\t\t                     (long) tm.tm_wday, (long) tm.tm_yday, (long) tm.tm_isdst));\n\t\ttm.tm_isdst = -1;  /* negative: dst info not available */\n\n\t\tt = mktime(&tm);\n\t\tDUK_DDD(DUK_DDDPRINT(\"mktime() -> %ld\", (long) t));\n\t\tif (t >= 0) {\n\t\t\tduk_push_number(ctx, ((duk_double_t) t) * 1000.0);\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\treturn 0;\n}\n#endif  /* DUK_USE_DATE_PRS_STRPTIME */\n\n#if defined(DUK_USE_DATE_PRS_GETDATE)\nDUK_INTERNAL duk_bool_t duk_bi_date_parse_string_getdate(duk_context *ctx, const char *str) {\n\tstruct tm tm;\n\tduk_small_int_t rc;\n\ttime_t t;\n\n\t/* For this to work, DATEMSK must be set, so this is not very\n\t * convenient for an embeddable interpreter.\n\t */\n\n\tDUK_MEMZERO(&tm, sizeof(struct tm));\n\trc = (duk_small_int_t) getdate_r(str, &tm);\n\tDUK_DDD(DUK_DDDPRINT(\"getdate_r() -> %ld\", (long) rc));\n\n\tif (rc == 0) {\n\t\tt = mktime(&tm);\n\t\tDUK_DDD(DUK_DDDPRINT(\"mktime() -> %ld\", (long) t));\n\t\tif (t >= 0) {\n\t\t\tduk_push_number(ctx, (duk_double_t) t);\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\treturn 0;\n}\n#endif  /* DUK_USE_DATE_PRS_GETDATE */\n\n#if defined(DUK_USE_DATE_FMT_STRFTIME)\nDUK_INTERNAL duk_bool_t duk_bi_date_format_parts_strftime(duk_context *ctx, duk_int_t *parts, duk_int_t tzoffset, duk_small_uint_t flags) {\n\tchar buf[DUK__STRFTIME_BUF_SIZE];\n\tstruct tm tm;\n\tconst char *fmt;\n\n\tDUK_UNREF(tzoffset);\n\n\t/* If the platform doesn't support the entire Ecmascript range, we need\n\t * to return 0 so that the caller can fall back to the default formatter.\n\t *\n\t * For now, assume that if time_t is 8 bytes or more, the whole Ecmascript\n\t * range is supported.  For smaller time_t values (4 bytes in practice),\n\t * assumes that the signed 32-bit range is supported.\n\t *\n\t * XXX: detect this more correctly per platform.  The size of time_t is\n\t * probably not an accurate guarantee of strftime() supporting or not\n\t * supporting a large time range (the full Ecmascript range).\n\t */\n\tif (sizeof(time_t) < 8 &&\n\t    (parts[DUK_DATE_IDX_YEAR] < 1970 || parts[DUK_DATE_IDX_YEAR] > 2037)) {\n\t\t/* be paranoid for 32-bit time values (even avoiding negative ones) */\n\t\treturn 0;\n\t}\n\n\tDUK_MEMZERO(&tm, sizeof(tm));\n\ttm.tm_sec = parts[DUK_DATE_IDX_SECOND];\n\ttm.tm_min = parts[DUK_DATE_IDX_MINUTE];\n\ttm.tm_hour = parts[DUK_DATE_IDX_HOUR];\n\ttm.tm_mday = parts[DUK_DATE_IDX_DAY];       /* already one-based */\n\ttm.tm_mon = parts[DUK_DATE_IDX_MONTH] - 1;  /* one-based -> zero-based */\n\ttm.tm_year = parts[DUK_DATE_IDX_YEAR] - 1900;\n\ttm.tm_wday = parts[DUK_DATE_IDX_WEEKDAY];\n\ttm.tm_isdst = 0;\n\n\tDUK_MEMZERO(buf, sizeof(buf));\n\tif ((flags & DUK_DATE_FLAG_TOSTRING_DATE) && (flags & DUK_DATE_FLAG_TOSTRING_TIME)) {\n\t\tfmt = \"%c\";\n\t} else if (flags & DUK_DATE_FLAG_TOSTRING_DATE) {\n\t\tfmt = \"%x\";\n\t} else {\n\t\tDUK_ASSERT(flags & DUK_DATE_FLAG_TOSTRING_TIME);\n\t\tfmt = \"%X\";\n\t}\n\t(void) strftime(buf, sizeof(buf) - 1, fmt, &tm);\n\tDUK_ASSERT(buf[sizeof(buf) - 1] == 0);\n\n\tduk_push_string(ctx, buf);\n\treturn 1;\n}\n#endif  /* DUK_USE_DATE_FMT_STRFTIME */\n\n/* automatic undefs */\n#undef DUK__STRFTIME_BUF_SIZE\n#undef DUK__STRPTIME_BUF_SIZE\n/*\n *  Windows Date providers\n *\n *  Platform specific links:\n *\n *    - http://msdn.microsoft.com/en-us/library/windows/desktop/ms725473(v=vs.85).aspx\n */\n\n/* #include duk_internal.h -> already included */\n\n/* The necessary #includes are in place in duk_config.h. */\n\n#if defined(DUK_USE_DATE_NOW_WINDOWS) || defined(DUK_USE_DATE_TZO_WINDOWS)\n/* Shared Windows helpers. */\nDUK_LOCAL void duk__convert_systime_to_ularge(const SYSTEMTIME *st, ULARGE_INTEGER *res) {\n\tFILETIME ft;\n\tif (SystemTimeToFileTime(st, &ft) == 0) {\n\t\tDUK_D(DUK_DPRINT(\"SystemTimeToFileTime() failed, returning 0\"));\n\t\tres->QuadPart = 0;\n\t} else {\n\t\tres->LowPart = ft.dwLowDateTime;\n\t\tres->HighPart = ft.dwHighDateTime;\n\t}\n}\nDUK_LOCAL void duk__set_systime_jan1970(SYSTEMTIME *st) {\n\tDUK_MEMZERO((void *) st, sizeof(*st));\n\tst->wYear = 1970;\n\tst->wMonth = 1;\n\tst->wDayOfWeek = 4;  /* not sure whether or not needed; Thursday */\n\tst->wDay = 1;\n\tDUK_ASSERT(st->wHour == 0);\n\tDUK_ASSERT(st->wMinute == 0);\n\tDUK_ASSERT(st->wSecond == 0);\n\tDUK_ASSERT(st->wMilliseconds == 0);\n}\n#endif  /* defined(DUK_USE_DATE_NOW_WINDOWS) || defined(DUK_USE_DATE_TZO_WINDOWS) */\n\n#if defined(DUK_USE_DATE_NOW_WINDOWS)\nDUK_INTERNAL duk_double_t duk_bi_date_get_now_windows(duk_context *ctx) {\n\t/* Suggested step-by-step method from documentation of RtlTimeToSecondsSince1970:\n\t * http://msdn.microsoft.com/en-us/library/windows/desktop/ms724928(v=vs.85).aspx\n\t */\n\tSYSTEMTIME st1, st2;\n\tULARGE_INTEGER tmp1, tmp2;\n\n\tDUK_UNREF(ctx);\n\n\tGetSystemTime(&st1);\n\tduk__convert_systime_to_ularge((const SYSTEMTIME *) &st1, &tmp1);\n\n\tduk__set_systime_jan1970(&st2);\n\tduk__convert_systime_to_ularge((const SYSTEMTIME *) &st2, &tmp2);\n\n\t/* Difference is in 100ns units, convert to milliseconds w/o fractions */\n\treturn (duk_double_t) ((tmp1.QuadPart - tmp2.QuadPart) / 10000LL);\n}\n#endif  /* DUK_USE_DATE_NOW_WINDOWS */\n\n\n#if defined(DUK_USE_DATE_TZO_WINDOWS)\nDUK_INTERNAL_DECL duk_int_t duk_bi_date_get_local_tzoffset_windows(duk_double_t d) {\n\tSYSTEMTIME st1;\n\tSYSTEMTIME st2;\n\tSYSTEMTIME st3;\n\tULARGE_INTEGER tmp1;\n\tULARGE_INTEGER tmp2;\n\tULARGE_INTEGER tmp3;\n\tFILETIME ft1;\n\n\t/* XXX: handling of timestamps outside Windows supported range.\n\t * How does Windows deal with dates before 1600?  Does windows\n\t * support all Ecmascript years (like -200000 and +200000)?\n\t * Should equivalent year mapping be used here too?  If so, use\n\t * a shared helper (currently integrated into timeval-to-parts).\n\t */\n\n\t/* Use the approach described in \"Remarks\" of FileTimeToLocalFileTime:\n\t * http://msdn.microsoft.com/en-us/library/windows/desktop/ms724277(v=vs.85).aspx\n\t */\n\n\tduk__set_systime_jan1970(&st1);\n\tduk__convert_systime_to_ularge((const SYSTEMTIME *) &st1, &tmp1);\n\ttmp2.QuadPart = (ULONGLONG) (d * 10000.0);  /* millisec -> 100ns units since jan 1, 1970 */\n\ttmp2.QuadPart += tmp1.QuadPart;             /* input 'd' in Windows UTC, 100ns units */\n\n\tft1.dwLowDateTime = tmp2.LowPart;\n\tft1.dwHighDateTime = tmp2.HighPart;\n\tFileTimeToSystemTime((const FILETIME *) &ft1, &st2);\n\tif (SystemTimeToTzSpecificLocalTime((LPTIME_ZONE_INFORMATION) NULL, &st2, &st3) == 0) {\n\t\tDUK_D(DUK_DPRINT(\"SystemTimeToTzSpecificLocalTime() failed, return tzoffset 0\"));\n\t\treturn 0;\n\t}\n\tduk__convert_systime_to_ularge((const SYSTEMTIME *) &st3, &tmp3);\n\n\t/* Positive if local time ahead of UTC. */\n\treturn (duk_int_t) (((LONGLONG) tmp3.QuadPart - (LONGLONG) tmp2.QuadPart) / 10000000LL);  /* seconds */\n}\n#endif  /* DUK_USE_DATE_TZO_WINDOWS */\n\n#if defined(DUK_USE_DATE_TZO_WINDOWS_NO_DST)\nDUK_INTERNAL_DECL duk_int_t duk_bi_date_get_local_tzoffset_windows_no_dst(duk_double_t d) {\n\tSYSTEMTIME st1;\n\tSYSTEMTIME st2;\n\tFILETIME ft1;\n\tFILETIME ft2;\n\tULARGE_INTEGER tmp1;\n\tULARGE_INTEGER tmp2;\n\n\t/* Do a similar computation to duk_bi_date_get_local_tzoffset_windows\n\t * but without accounting for daylight savings time.  Use this on\n\t * Windows platforms (like Durango) that don't support the\n\t * SystemTimeToTzSpecificLocalTime() call.\n\t */\n\n\t/* current time not needed for this computation */\n\tDUK_UNREF(d);\n\n\tduk__set_systime_jan1970(&st1);\n\tduk__convert_systime_to_ularge((const SYSTEMTIME *) &st1, &tmp1);\n\n\tft1.dwLowDateTime = tmp1.LowPart;\n\tft1.dwHighDateTime = tmp1.HighPart;\n\tFileTimeToLocalFileTime((const FILETIME *) &ft1, &ft2);\n\n\tFileTimeToSystemTime((const FILETIME *) &ft2, &st2);\n\tduk__convert_systime_to_ularge((const SYSTEMTIME *) &st2, &tmp2);\n\n\treturn (duk_int_t) (((LONGLONG) tmp2.QuadPart - (LONGLONG) tmp1.QuadPart) / 10000000LL);  /* seconds */\n}\n#endif  /* DUK_USE_DATE_TZO_WINDOWS_NO_DST */\n/*\n *  Duktape built-ins\n *\n *  Size optimization note: it might seem that vararg multipurpose functions\n *  like fin(), enc(), and dec() are not very size optimal, but using a single\n *  user-visible Ecmascript function saves a lot of run-time footprint; each\n *  Function instance takes >100 bytes.  Using a shared native helper and a\n *  'magic' value won't save much if there are multiple Function instances\n *  anyway.\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_DUKTAPE_BUILTIN)\n\nDUK_INTERNAL duk_ret_t duk_bi_duktape_object_info(duk_context *ctx) {\n\tduk_inspect_value(ctx, -1);\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_duktape_object_act(duk_context *ctx) {\n\tduk_int_t level;\n\n\tlevel = duk_to_int(ctx, 0);\n\tduk_inspect_callstack_entry(ctx, level);\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_duktape_object_gc(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_small_uint_t flags;\n\n\tflags = (duk_small_uint_t) duk_get_uint(ctx, 0);\n\tduk_heap_mark_and_sweep(thr->heap, flags);\n\n\t/* XXX: Not sure what the best return value would be in the API.\n\t * Return true for now.\n\t */\n\tduk_push_true(ctx);\n\treturn 1;\n}\n\n#if defined(DUK_USE_FINALIZER_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_duktape_object_fin(duk_context *ctx) {\n\t(void) duk_require_hobject(ctx, 0);\n\tif (duk_get_top(ctx) >= 2) {\n\t\t/* Set: currently a finalizer is disabled by setting it to\n\t\t * undefined; this does not remove the property at the moment.\n\t\t * The value could be type checked to be either a function\n\t\t * or something else; if something else, the property could\n\t\t * be deleted.  Must use duk_set_finalizer() to keep\n\t\t * DUK_HOBJECT_FLAG_HAVE_FINALIZER in sync.\n\t\t */\n\t\tduk_set_top(ctx, 2);\n\t\tduk_set_finalizer(ctx, 0);\n\t\treturn 0;\n\t} else {\n\t\t/* Get. */\n\t\tDUK_ASSERT(duk_get_top(ctx) == 1);\n\t\tduk_get_finalizer(ctx, 0);\n\t\treturn 1;\n\t}\n}\n#endif  /* DUK_USE_FINALIZER_SUPPORT */\n\nDUK_INTERNAL duk_ret_t duk_bi_duktape_object_enc(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hstring *h_str;\n\n\tDUK_UNREF(thr);\n\n\t/* Vararg function: must be careful to check/require arguments.\n\t * The JSON helpers accept invalid indices and treat them like\n\t * non-existent optional parameters.\n\t */\n\n\th_str = duk_require_hstring(ctx, 0);  /* Could reject symbols, but no point: won't match comparisons. */\n\tduk_require_valid_index(ctx, 1);\n\n\tif (h_str == DUK_HTHREAD_STRING_HEX(thr)) {\n\t\tduk_set_top(ctx, 2);\n\t\tduk_hex_encode(ctx, 1);\n\t\tDUK_ASSERT_TOP(ctx, 2);\n\t} else if (h_str == DUK_HTHREAD_STRING_BASE64(thr)) {\n\t\tduk_set_top(ctx, 2);\n\t\tduk_base64_encode(ctx, 1);\n\t\tDUK_ASSERT_TOP(ctx, 2);\n#if defined(DUK_USE_JSON_SUPPORT) && defined(DUK_USE_JX)\n\t} else if (h_str == DUK_HTHREAD_STRING_JX(thr)) {\n\t\tduk_bi_json_stringify_helper(ctx,\n\t\t                             1 /*idx_value*/,\n\t\t                             2 /*idx_replacer*/,\n\t\t                             3 /*idx_space*/,\n\t\t                             DUK_JSON_FLAG_EXT_CUSTOM |\n\t\t                             DUK_JSON_FLAG_ASCII_ONLY |\n\t\t                             DUK_JSON_FLAG_AVOID_KEY_QUOTES /*flags*/);\n#endif\n#if defined(DUK_USE_JSON_SUPPORT) && defined(DUK_USE_JC)\n\t} else if (h_str == DUK_HTHREAD_STRING_JC(thr)) {\n\t\tduk_bi_json_stringify_helper(ctx,\n\t\t                             1 /*idx_value*/,\n\t\t                             2 /*idx_replacer*/,\n\t\t                             3 /*idx_space*/,\n\t\t                             DUK_JSON_FLAG_EXT_COMPATIBLE |\n\t\t                             DUK_JSON_FLAG_ASCII_ONLY /*flags*/);\n#endif\n\t} else {\n\t\tDUK_DCERROR_TYPE_INVALID_ARGS(thr);\n\t}\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_duktape_object_dec(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hstring *h_str;\n\n\tDUK_UNREF(thr);\n\n\t/* Vararg function: must be careful to check/require arguments.\n\t * The JSON helpers accept invalid indices and treat them like\n\t * non-existent optional parameters.\n\t */\n\n\th_str = duk_require_hstring(ctx, 0);  /* Could reject symbols, but no point: won't match comparisons */\n\tduk_require_valid_index(ctx, 1);\n\n\tif (h_str == DUK_HTHREAD_STRING_HEX(thr)) {\n\t\tduk_set_top(ctx, 2);\n\t\tduk_hex_decode(ctx, 1);\n\t\tDUK_ASSERT_TOP(ctx, 2);\n\t} else if (h_str == DUK_HTHREAD_STRING_BASE64(thr)) {\n\t\tduk_set_top(ctx, 2);\n\t\tduk_base64_decode(ctx, 1);\n\t\tDUK_ASSERT_TOP(ctx, 2);\n#if defined(DUK_USE_JSON_SUPPORT) && defined(DUK_USE_JX)\n\t} else if (h_str == DUK_HTHREAD_STRING_JX(thr)) {\n\t\tduk_bi_json_parse_helper(ctx,\n\t\t                         1 /*idx_value*/,\n\t\t                         2 /*idx_replacer*/,\n\t\t                         DUK_JSON_FLAG_EXT_CUSTOM /*flags*/);\n#endif\n#if defined(DUK_USE_JSON_SUPPORT) && defined(DUK_USE_JC)\n\t} else if (h_str == DUK_HTHREAD_STRING_JC(thr)) {\n\t\tduk_bi_json_parse_helper(ctx,\n\t\t                         1 /*idx_value*/,\n\t\t                         2 /*idx_replacer*/,\n\t\t                         DUK_JSON_FLAG_EXT_COMPATIBLE /*flags*/);\n#endif\n\t} else {\n\t\tDUK_DCERROR_TYPE_INVALID_ARGS(thr);\n\t}\n\treturn 1;\n}\n\n/*\n *  Compact an object\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_duktape_object_compact(duk_context *ctx) {\n\tDUK_ASSERT_TOP(ctx, 1);\n\tduk_compact(ctx, 0);\n\treturn 1;  /* return the argument object */\n}\n\n#endif  /* DUK_USE_DUKTAPE_BUILTIN */\n/*\n *  WHATWG Encoding API built-ins\n *\n *  API specification: https://encoding.spec.whatwg.org/#api\n *  Web IDL: https://www.w3.org/TR/WebIDL/\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Data structures for encoding/decoding\n */\n\ntypedef struct {\n\tduk_uint8_t *out;      /* where to write next byte(s) */\n\tduk_codepoint_t lead;  /* lead surrogate */\n} duk__encode_context;\n\ntypedef struct {\n\t/* UTF-8 decoding state */\n\tduk_codepoint_t codepoint;  /* built up incrementally */\n\tduk_uint8_t upper;          /* max value of next byte (decode error otherwise) */\n\tduk_uint8_t lower;          /* min value of next byte (ditto) */\n\tduk_uint8_t needed;         /* how many more bytes we need */\n\tduk_uint8_t bom_handled;    /* BOM seen or no longer expected */\n\n\t/* Decoder configuration */\n\tduk_uint8_t fatal;\n\tduk_uint8_t ignore_bom;\n} duk__decode_context;\n\n/* The signed duk_codepoint_t type is used to signal a decoded codepoint\n * (>= 0) or various other states using negative values.\n */\n#define DUK__CP_CONTINUE   (-1)  /* continue to next byte, no completed codepoint */\n#define DUK__CP_ERROR      (-2)  /* decoding error */\n#define DUK__CP_RETRY      (-3)  /* decoding error; retry last byte */\n\n/*\n *  Raw helpers for encoding/decoding\n */\n\n/* Emit UTF-8 (= CESU-8) encoded U+FFFD (replacement char), i.e. ef bf bd. */\nDUK_LOCAL duk_uint8_t *duk__utf8_emit_repl(duk_uint8_t *ptr) {\n\t*ptr++ = 0xef;\n\t*ptr++ = 0xbf;\n\t*ptr++ = 0xbd;\n\treturn ptr;\n}\n\nDUK_LOCAL void duk__utf8_decode_init(duk__decode_context *dec_ctx) {\n\t/* (Re)init the decoding state of 'dec_ctx' but leave decoder\n\t * configuration fields untouched.\n\t */\n\tdec_ctx->codepoint = 0x0000L;\n\tdec_ctx->upper = 0xbf;\n\tdec_ctx->lower = 0x80;\n\tdec_ctx->needed = 0;\n\tdec_ctx->bom_handled = 0;\n}\n\nDUK_LOCAL duk_codepoint_t duk__utf8_decode_next(duk__decode_context *dec_ctx, duk_uint8_t x) {\n\t/*\n\t *  UTF-8 algorithm based on the Encoding specification:\n\t *  https://encoding.spec.whatwg.org/#utf-8-decoder\n\t *\n\t *  Two main states: decoding initial byte vs. decoding continuation\n\t *  bytes.  Shortest length encoding is validated by restricting the\n\t *  allowed range of first continuation byte using 'lower' and 'upper'.\n\t */\n\n\tif (dec_ctx->needed == 0) {\n\t\t/* process initial byte */\n\t\tif (x <= 0x7f) {\n\t\t\t/* U+0000-U+007F, 1 byte (ASCII) */\n\t\t\treturn (duk_codepoint_t) x;\n\t\t} else if (x >= 0xc2 && x <= 0xdf) {\n\t\t\t/* U+0080-U+07FF, 2 bytes */\n\t\t\tdec_ctx->needed = 1;\n\t\t\tdec_ctx->codepoint = x & 0x1f;\n\t\t\tDUK_ASSERT(dec_ctx->lower == 0x80);\n\t\t\tDUK_ASSERT(dec_ctx->upper == 0xbf);\n\t\t\treturn DUK__CP_CONTINUE;\n\t\t} else if (x >= 0xe0 && x <= 0xef) {\n\t\t\t/* U+0800-U+FFFF, 3 bytes */\n\t\t\tif (x == 0xe0) {\n\t\t\t\tdec_ctx->lower = 0xa0;\n\t\t\t\tDUK_ASSERT(dec_ctx->upper == 0xbf);\n\t\t\t} else if (x == 0xed) {\n\t\t\t\tDUK_ASSERT(dec_ctx->lower == 0x80);\n\t\t\t\tdec_ctx->upper = 0x9f;\n\t\t\t}\n\t\t\tdec_ctx->needed = 2;\n\t\t\tdec_ctx->codepoint = x & 0x0f;\n\t\t\treturn DUK__CP_CONTINUE;\n\t\t} else if (x >= 0xf0 && x <= 0xf4) {\n\t\t\t/* U+010000-U+10FFFF, 4 bytes */\n\t\t\tif (x == 0xf0) {\n\t\t\t\tdec_ctx->lower = 0x90;\n\t\t\t\tDUK_ASSERT(dec_ctx->upper == 0xbf);\n\t\t\t} else if (x == 0xf4) {\n\t\t\t\tDUK_ASSERT(dec_ctx->lower == 0x80);\n\t\t\t\tdec_ctx->upper = 0x8f;\n\t\t\t}\n\t\t\tdec_ctx->needed = 3;\n\t\t\tdec_ctx->codepoint = x & 0x07;\n\t\t\treturn DUK__CP_CONTINUE;\n\t\t} else {\n\t\t\t/* not a legal initial byte */\n\t\t\treturn DUK__CP_ERROR;\n\t\t}\n\t} else {\n\t\t/* process continuation byte */\n\t\tif (x >= dec_ctx->lower && x <= dec_ctx->upper) {\n\t\t\tdec_ctx->lower = 0x80;\n\t\t\tdec_ctx->upper = 0xbf;\n\t\t\tdec_ctx->codepoint = (dec_ctx->codepoint << 6) | (x & 0x3f);\n\t\t\tif (--dec_ctx->needed > 0) {\n\t\t\t\t/* need more bytes */\n\t\t\t\treturn DUK__CP_CONTINUE;\n\t\t\t} else {\n\t\t\t\t/* got a codepoint */\n\t\t\t\tduk_codepoint_t ret;\n\t\t\t\tDUK_ASSERT(dec_ctx->codepoint <= 0x10ffffL);  /* Decoding rules guarantee. */\n\t\t\t\tret = dec_ctx->codepoint;\n\t\t\t\tdec_ctx->codepoint = 0x0000L;\n\t\t\t\tdec_ctx->needed = 0;\n\t\t\t\treturn ret;\n\t\t\t}\n\t\t} else {\n\t\t\t/* We just encountered an illegal UTF-8 continuation byte.  This might\n\t\t\t * be the initial byte of the next character; if we return a plain\n\t\t\t * error status and the decoder is in replacement mode, the character\n\t\t\t * will be masked.  We still need to alert the caller to the error\n\t\t\t * though.\n\t\t\t */\n\t\t\tdec_ctx->codepoint = 0x0000L;\n\t\t\tdec_ctx->needed = 0;\n\t\t\tdec_ctx->lower = 0x80;\n\t\t\tdec_ctx->upper = 0xbf;\n\t\t\treturn DUK__CP_RETRY;\n\t\t}\n\t}\n}\n\n#if defined(DUK_USE_ENCODING_BUILTINS)\nDUK_LOCAL void duk__utf8_encode_char(void *udata, duk_codepoint_t codepoint) {\n\tduk__encode_context *enc_ctx;\n\n\tDUK_ASSERT(codepoint >= 0);\n\tenc_ctx = (duk__encode_context *) udata;\n\tDUK_ASSERT(enc_ctx != NULL);\n\n#if !defined(DUK_USE_PREFER_SIZE)\n\tif (codepoint <= 0x7f && enc_ctx->lead == 0x0000L) {\n\t\t/* Fast path for ASCII. */\n\t\t*enc_ctx->out++ = (duk_uint8_t) codepoint;\n\t\treturn;\n\t}\n#endif\n\n\tif (DUK_UNLIKELY(codepoint > 0x10ffffL)) {\n\t\t/* cannot legally encode in UTF-8 */\n\t\tcodepoint = DUK_UNICODE_CP_REPLACEMENT_CHARACTER;\n\t} else if (codepoint >= 0xd800L && codepoint <= 0xdfffL) {\n\t\tif (codepoint <= 0xdbffL) {\n\t\t\t/* high surrogate */\n\t\t\tduk_codepoint_t prev_lead = enc_ctx->lead;\n\t\t\tenc_ctx->lead = codepoint;\n\t\t\tif (prev_lead == 0x0000L) {\n\t\t\t\t/* high surrogate, no output */\n\t\t\t\treturn;\n\t\t\t} else {\n\t\t\t\t/* consecutive high surrogates, consider first one unpaired */\n\t\t\t\tcodepoint = DUK_UNICODE_CP_REPLACEMENT_CHARACTER;\n\t\t\t}\n\t\t} else {\n\t\t\t/* low surrogate */\n\t\t\tif (enc_ctx->lead != 0x0000L) {\n\t\t\t\tcodepoint = 0x010000L + ((enc_ctx->lead - 0xd800L) << 10) + (codepoint - 0xdc00L);\n\t\t\t\tenc_ctx->lead = 0x0000L;\n\t\t\t} else {\n\t\t\t\t/* unpaired low surrogate */\n\t\t\t\tDUK_ASSERT(enc_ctx->lead == 0x0000L);\n\t\t\t\tcodepoint = DUK_UNICODE_CP_REPLACEMENT_CHARACTER;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif (enc_ctx->lead != 0x0000L) {\n\t\t\t/* unpaired high surrogate: emit replacement character and the input codepoint */\n\t\t\tenc_ctx->lead = 0x0000L;\n\t\t\tenc_ctx->out = duk__utf8_emit_repl(enc_ctx->out);\n\t\t}\n\t}\n\n\t/* Codepoint may be original input, a decoded surrogate pair, or may\n\t * have been replaced with U+FFFD.\n\t */\n\tenc_ctx->out += duk_unicode_encode_xutf8(codepoint, enc_ctx->out);\n}\n#endif  /* DUK_USE_ENCODING_BUILTINS */\n\n/* Shared helper for buffer-to-string using a TextDecoder() compatible UTF-8\n * decoder.\n */\nDUK_LOCAL duk_ret_t duk__decode_helper(duk_context *ctx, duk__decode_context *dec_ctx) {\n\tconst duk_uint8_t *input;\n\tduk_size_t len = 0;\n\tduk_size_t len_tmp;\n\tduk_bool_t stream = 0;\n\tduk_codepoint_t codepoint;\n\tduk_uint8_t *output;\n\tconst duk_uint8_t *in;\n\tduk_uint8_t *out;\n\n\tDUK_ASSERT(dec_ctx != NULL);\n\n\t/* Careful with input buffer pointer: any side effects involving\n\t * code execution (e.g. getters, coercion calls, and finalizers)\n\t * may cause a resize and invalidate a pointer we've read.  This\n\t * is why the pointer is actually looked up at the last minute.\n\t * Argument validation must still happen first to match WHATWG\n\t * required side effect order.\n\t */\n\n\tif (duk_is_undefined(ctx, 0)) {\n\t\tduk_push_fixed_buffer_nozero(ctx, 0);\n\t\tduk_replace(ctx, 0);\n\t}\n\t(void) duk_require_buffer_data(ctx, 0, &len);  /* Need 'len', avoid pointer. */\n\n\tif (duk_check_type_mask(ctx, 1, DUK_TYPE_MASK_UNDEFINED |\n\t                                DUK_TYPE_MASK_NULL |\n\t                                DUK_TYPE_MASK_NONE)) {\n\t\t/* Use defaults, treat missing value like undefined. */\n\t} else {\n\t\tduk_require_type_mask(ctx, 1, DUK_TYPE_MASK_UNDEFINED |\n\t                                      DUK_TYPE_MASK_NULL |\n\t                                      DUK_TYPE_MASK_LIGHTFUNC |\n\t                                      DUK_TYPE_MASK_BUFFER |\n\t\t                              DUK_TYPE_MASK_OBJECT);\n\t\tif (duk_get_prop_string(ctx, 1, \"stream\")) {\n\t\t\tstream = duk_to_boolean(ctx, -1);\n\t\t}\n\t}\n\n\t/* Allowance is 3*len in the general case because all bytes may potentially\n\t * become U+FFFD.  If the first byte completes a non-BMP codepoint it will\n\t * decode to a CESU-8 surrogate pair (6 bytes) so we allow 3 extra bytes to\n\t * compensate: (1*3)+3 = 6.  Non-BMP codepoints are safe otherwise because\n\t * the 4->6 expansion is well under the 3x allowance.\n\t *\n\t * XXX: As with TextEncoder, need a better buffer allocation strategy here.\n\t */\n\tif (len >= (DUK_HBUFFER_MAX_BYTELEN / 3) - 3) {\n\t\tDUK_ERROR_TYPE((duk_hthread *) ctx, DUK_STR_RESULT_TOO_LONG);\n\t}\n\toutput = (duk_uint8_t *) duk_push_fixed_buffer_nozero(ctx, 3 + (3 * len));  /* used parts will be always manually written over */\n\n\tinput = (const duk_uint8_t *) duk_get_buffer_data(ctx, 0, &len_tmp);\n\tDUK_ASSERT(input != NULL || len == 0);\n\tif (DUK_UNLIKELY(len != len_tmp)) {\n\t\t/* Very unlikely but possible: source buffer was resized by\n\t\t * a side effect when fixed buffer was pushed.  Output buffer\n\t\t * may not be large enough to hold output, so just fail if\n\t\t * length has changed.\n\t\t */\n\t\tDUK_D(DUK_DPRINT(\"input buffer resized by side effect, fail\"));\n\t\tgoto fail_type;\n\t}\n\n\t/* From this point onwards it's critical that no side effect occur\n\t * which may disturb 'input': finalizer execution, property accesses,\n\t * active coercions, etc.  Even an allocation related mark-and-sweep\n\t * may affect the pointer because it may trigger a pending finalizer.\n\t */\n\n\tin = input;\n\tout = output;\n\twhile (in < input + len) {\n\t\tcodepoint = duk__utf8_decode_next(dec_ctx, *in++);\n\t\tif (codepoint < 0) {\n\t\t\tif (codepoint == DUK__CP_CONTINUE) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t/* Decoding error with or without retry. */\n\t\t\tDUK_ASSERT(codepoint == DUK__CP_ERROR || codepoint == DUK__CP_RETRY);\n\t\t\tif (codepoint == DUK__CP_RETRY) {\n\t\t\t\t--in;  /* retry last byte */\n\t\t\t}\n\t\t\t/* replacement mode: replace with U+FFFD */\n\t\t\tcodepoint = DUK_UNICODE_CP_REPLACEMENT_CHARACTER;\n\t\t\tif (dec_ctx->fatal) {\n\t\t\t\t/* fatal mode: throw a TypeError */\n\t\t\t\tgoto fail_type;\n\t\t\t}\n\t\t\t/* Continue with 'codepoint', Unicode replacement. */\n\t\t}\n\t\tDUK_ASSERT(codepoint >= 0x0000L && codepoint <= 0x10ffffL);\n\n\t\tif (!dec_ctx->bom_handled) {\n\t\t\tdec_ctx->bom_handled = 1;\n\t\t\tif (codepoint == 0xfeffL && !dec_ctx->ignore_bom) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tout += duk_unicode_encode_cesu8(codepoint, out);\n\t\tDUK_ASSERT(out <= output + (3 + (3 * len)));\n\t}\n\n\tif (!stream) {\n\t\tif (dec_ctx->needed != 0) {\n\t\t\t/* truncated sequence at end of buffer */\n\t\t\tif (dec_ctx->fatal) {\n\t\t\t\tgoto fail_type;\n\t\t\t} else {\n\t\t\t\tout += duk_unicode_encode_cesu8(DUK_UNICODE_CP_REPLACEMENT_CHARACTER, out);\n\t\t\t\tDUK_ASSERT(out <= output + (3 + (3 * len)));\n\t\t\t}\n\t\t}\n\t\tduk__utf8_decode_init(dec_ctx);  /* Initialize decoding state for potential reuse. */\n\t}\n\n\t/* Output buffer is fixed and thus stable even if there had been\n\t * side effects (which there shouldn't be).\n\t */\n\tduk_push_lstring(ctx, (const char *) output, (duk_size_t) (out - output));\n\treturn 1;\n\n fail_type:\n\tDUK_ERROR_TYPE((duk_hthread *) ctx, DUK_STR_DECODE_FAILED);\n\tDUK_UNREACHABLE();\n}\n\n/*\n *  Built-in bindings\n */\n\n#if defined(DUK_USE_ENCODING_BUILTINS)\nDUK_INTERNAL duk_ret_t duk_bi_textencoder_constructor(duk_context *ctx) {\n\t/* TextEncoder currently requires no persistent state, so the constructor\n\t * does nothing on purpose.\n\t */\n\n\tduk_require_constructor_call(ctx);\n\treturn 0;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_textencoder_prototype_encoding_getter(duk_context *ctx) {\n\tduk_push_string(ctx, \"utf-8\");\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_textencoder_prototype_encode(duk_context *ctx) {\n\tduk__encode_context enc_ctx;\n\tduk_size_t len;\n\tduk_size_t final_len;\n\tduk_uint8_t *output;\n\n\tDUK_ASSERT_TOP(ctx, 1);\n\tif (duk_is_undefined(ctx, 0)) {\n\t\tlen = 0;\n\t} else {\n\t\tduk_hstring *h_input;\n\n\t\th_input = duk_to_hstring(ctx, 0);\n\t\tDUK_ASSERT(h_input != NULL);\n\n\t\tlen = (duk_size_t) DUK_HSTRING_GET_CHARLEN(h_input);\n\t\tif (len >= DUK_HBUFFER_MAX_BYTELEN / 3) {\n\t\t\tDUK_ERROR_TYPE((duk_hthread *) ctx, DUK_STR_RESULT_TOO_LONG);\n\t\t}\n\t}\n\n\t/* Allowance is 3*len because all bytes can potentially be replaced with\n\t * U+FFFD -- which rather inconveniently encodes to 3 bytes in UTF-8.\n\t * Rely on dynamic buffer data pointer stability: no other code has\n\t * access to the data pointer.\n\t *\n\t * XXX: The buffer allocation strategy used here is rather inefficient.\n\t * Maybe switch to a chunk-based strategy, or preprocess the string to\n\t * figure out the space needed ahead of time?\n\t */\n\tDUK_ASSERT(3 * len >= len);\n\toutput = (duk_uint8_t *) duk_push_dynamic_buffer(ctx, 3 * len);\n\n\tif (len > 0) {\n\t\tDUK_ASSERT(duk_is_string(ctx, 0));  /* True if len > 0. */\n\n\t\t/* XXX: duk_decode_string() is used to process the input\n\t\t * string.  For standard Ecmascript strings, represented\n\t\t * internally as CESU-8, this is fine.  However, behavior\n\t\t * beyond CESU-8 is not very strict: codepoints using an\n\t\t * extended form of UTF-8 are also accepted, and invalid\n\t\t * codepoint sequences (which are allowed in Duktape strings)\n\t\t * are not handled as well as they could (e.g. invalid\n\t\t * continuation bytes may mask following codepoints).\n\t\t * This is how Ecmascript code would also see such strings.\n\t\t * Maybe replace duk_decode_string() with an explicit strict\n\t\t * CESU-8 decoder here?\n\t\t */\n\t\tenc_ctx.lead = 0x0000L;\n\t\tenc_ctx.out = output;\n\t\tduk_decode_string(ctx, 0, duk__utf8_encode_char, (void *) &enc_ctx);\n\t\tif (enc_ctx.lead != 0x0000L) {\n\t\t\t/* unpaired high surrogate at end of string */\n\t\t\tenc_ctx.out = duk__utf8_emit_repl(enc_ctx.out);\n\t\t\tDUK_ASSERT(enc_ctx.out <= output + (3 * len));\n\t\t}\n\n\t\t/* The output buffer is usually very much oversized, so shrink it to\n\t\t * actually needed size.  Pointer stability assumed up to this point.\n\t\t */\n\t\tDUK_ASSERT_TOP(ctx, 2);\n\t\tDUK_ASSERT(output == (duk_uint8_t *) duk_get_buffer_data(ctx, -1, NULL));\n\n\t\tfinal_len = (duk_size_t) (enc_ctx.out - output);\n\t\tduk_resize_buffer(ctx, -1, final_len);\n\t\t/* 'output' and 'enc_ctx.out' are potentially invalidated by the resize. */\n\t} else {\n\t\tfinal_len = 0;\n\t}\n\n\t/* Standard WHATWG output is a Uint8Array.  Here the Uint8Array will\n\t * be backed by a dynamic buffer which differs from e.g. Uint8Arrays\n\t * created as 'new Uint8Array(N)'.  Ecmascript code won't see the\n\t * difference but C code will.  When bufferobjects are not supported,\n\t * returns a plain dynamic buffer.\n\t */\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n\tduk_push_buffer_object(ctx, -1, 0, final_len, DUK_BUFOBJ_UINT8ARRAY);\n#endif\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_textdecoder_constructor(duk_context *ctx) {\n\tduk__decode_context *dec_ctx;\n\tduk_bool_t fatal = 0;\n\tduk_bool_t ignore_bom = 0;\n\n\tDUK_ASSERT_TOP(ctx, 2);\n\tduk_require_constructor_call(ctx);\n\tif (!duk_is_undefined(ctx, 0)) {\n\t\t/* XXX: For now ignore 'label' (encoding identifier). */\n\t\tduk_to_string(ctx, 0);\n\t}\n\tif (!duk_is_null_or_undefined(ctx, 1)) {\n\t\tif (duk_get_prop_string(ctx, 1, \"fatal\")) {\n\t\t\tfatal = duk_to_boolean(ctx, -1);\n\t\t}\n\t\tif (duk_get_prop_string(ctx, 1, \"ignoreBOM\")) {\n\t\t\tignore_bom = duk_to_boolean(ctx, -1);\n\t\t}\n\t}\n\n\tduk_push_this(ctx);\n\n\t/* The decode context is not assumed to be zeroed; all fields are\n\t * initialized explicitly.\n\t */\n\tdec_ctx = (duk__decode_context *) duk_push_fixed_buffer(ctx, sizeof(duk__decode_context));\n\tdec_ctx->fatal = (duk_uint8_t) fatal;\n\tdec_ctx->ignore_bom = (duk_uint8_t) ignore_bom;\n\tduk__utf8_decode_init(dec_ctx);  /* Initializes remaining fields. */\n\n\tduk_put_prop_string(ctx, -2, \"\\xff\" \"Context\");\n\treturn 0;\n}\n\n/* Get TextDecoder context from 'this'; leaves garbage on stack. */\nDUK_LOCAL duk__decode_context *duk__get_textdecoder_context(duk_context *ctx) {\n\tduk__decode_context *dec_ctx;\n\tduk_push_this(ctx);\n\tduk_get_prop_string(ctx, -1, \"\\xff\" \"Context\");\n\tdec_ctx = (duk__decode_context *) duk_require_buffer(ctx, -1, NULL);\n\tDUK_ASSERT(dec_ctx != NULL);\n\treturn dec_ctx;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_textdecoder_prototype_shared_getter(duk_context *ctx) {\n\tduk__decode_context *dec_ctx;\n\tduk_int_t magic;\n\n\tdec_ctx = duk__get_textdecoder_context(ctx);\n\tmagic = duk_get_current_magic(ctx);\n\tswitch (magic) {\n\tcase 0:\n\t\t/* Encoding is now fixed, so _Context lookup is only needed to\n\t\t * validate the 'this' binding (TypeError if not TextDecoder-like).\n\t\t */\n\t\tduk_push_string(ctx, \"utf-8\");\n\t\tbreak;\n\tcase 1:\n\t\tduk_push_boolean(ctx, dec_ctx->fatal);\n\t\tbreak;\n\tdefault:\n\t\tduk_push_boolean(ctx, dec_ctx->ignore_bom);\n\t\tbreak;\n\t}\n\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_textdecoder_prototype_decode(duk_context *ctx) {\n\tduk__decode_context *dec_ctx;\n\n\tdec_ctx = duk__get_textdecoder_context(ctx);\n\treturn duk__decode_helper(ctx, dec_ctx);\n}\n#endif  /* DUK_USE_ENCODING_BUILTINS */\n\n/*\n *  Internal helper for Node.js Buffer\n */\n\n/* Internal helper used for Node.js Buffer .toString().  Value stack convention\n * is currently odd: it mimics TextDecoder .decode() so that argument must be at\n * index 0, and decode options (not present for Buffer) at index 1.  Return value\n * is a Duktape/C function return value.\n */\nDUK_INTERNAL duk_ret_t duk_textdecoder_decode_utf8_nodejs(duk_context *ctx) {\n\tduk__decode_context dec_ctx;\n\n\tdec_ctx.fatal = 0;  /* use replacement chars */\n\tdec_ctx.ignore_bom = 1;  /* ignore BOMs (matches Node.js Buffer .toString()) */\n\tduk__utf8_decode_init(&dec_ctx);\n\n\treturn duk__decode_helper(ctx, &dec_ctx);\n}\n\n/* automatic undefs */\n#undef DUK__CP_CONTINUE\n#undef DUK__CP_ERROR\n#undef DUK__CP_RETRY\n/*\n *  Error built-ins\n */\n\n/* #include duk_internal.h -> already included */\n\nDUK_INTERNAL duk_ret_t duk_bi_error_constructor_shared(duk_context *ctx) {\n\t/* Behavior for constructor and non-constructor call is\n\t * the same except for augmenting the created error.  When\n\t * called as a constructor, the caller (duk_new()) will handle\n\t * augmentation; when called as normal function, we need to do\n\t * it here.\n\t */\n\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_small_int_t bidx_prototype = duk_get_current_magic(ctx);\n\n\t/* same for both error and each subclass like TypeError */\n\tduk_uint_t flags_and_class = DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                             DUK_HOBJECT_FLAG_FASTREFS |\n\t                             DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_ERROR);\n\n\tDUK_UNREF(thr);\n\n\t(void) duk_push_object_helper(ctx, flags_and_class, bidx_prototype);\n\n\t/* If message is undefined, the own property 'message' is not set at\n\t * all to save property space.  An empty message is inherited anyway.\n\t */\n\tif (!duk_is_undefined(ctx, 0)) {\n\t\tduk_to_string(ctx, 0);\n\t\tduk_dup_0(ctx);  /* [ message error message ] */\n\t\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_MESSAGE, DUK_PROPDESC_FLAGS_WC);\n\t}\n\n\t/* Augment the error if called as a normal function.  __FILE__ and __LINE__\n\t * are not desirable in this case.\n\t */\n\n#if defined(DUK_USE_AUGMENT_ERROR_CREATE)\n\tif (!duk_is_constructor_call(ctx)) {\n\t\tduk_err_augment_error_create(thr, thr, NULL, 0, 1 /*noblame_fileline*/);\n\t}\n#endif\n\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_error_prototype_to_string(duk_context *ctx) {\n\t/* XXX: optimize with more direct internal access */\n\n\tduk_push_this(ctx);\n\t(void) duk_require_hobject_promote_mask(ctx, -1, DUK_TYPE_MASK_LIGHTFUNC | DUK_TYPE_MASK_BUFFER);\n\n\t/* [ ... this ] */\n\n\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_NAME);\n\tif (duk_is_undefined(ctx, -1)) {\n\t\tduk_pop(ctx);\n\t\tduk_push_string(ctx, \"Error\");\n\t} else {\n\t\tduk_to_string(ctx, -1);\n\t}\n\n\t/* [ ... this name ] */\n\n\t/* XXX: Are steps 6 and 7 in E5 Section 15.11.4.4 duplicated by\n\t * accident or are they actually needed?  The first ToString()\n\t * could conceivably return 'undefined'.\n\t */\n\tduk_get_prop_stridx_short(ctx, -2, DUK_STRIDX_MESSAGE);\n\tif (duk_is_undefined(ctx, -1)) {\n\t\tduk_pop(ctx);\n\t\tduk_push_hstring_empty(ctx);\n\t} else {\n\t\tduk_to_string(ctx, -1);\n\t}\n\n\t/* [ ... this name message ] */\n\n\tif (duk_get_length(ctx, -2) == 0) {\n\t\t/* name is empty -> return message */\n\t\treturn 1;\n\t}\n\tif (duk_get_length(ctx, -1) == 0) {\n\t\t/* message is empty -> return name */\n\t\tduk_pop(ctx);\n\t\treturn 1;\n\t}\n\tduk_push_string(ctx, \": \");\n\tduk_insert(ctx, -2);  /* ... name ': ' message */\n\tduk_concat(ctx, 3);\n\n\treturn 1;\n}\n\n#if defined(DUK_USE_TRACEBACKS)\n\n/*\n *  Traceback handling\n *\n *  The unified helper decodes the traceback and produces various requested\n *  outputs.  It should be optimized for size, and may leave garbage on stack,\n *  only the topmost return value matters.  For instance, traceback separator\n *  and decoded strings are pushed even when looking for filename only.\n *\n *  NOTE: although _Tracedata is an internal property, user code can currently\n *  write to the array (or replace it with something other than an array).\n *  The code below must tolerate arbitrary _Tracedata.  It can throw errors\n *  etc, but cannot cause a segfault or memory unsafe behavior.\n */\n\n/* constants arbitrary, chosen for small loads */\n#define DUK__OUTPUT_TYPE_TRACEBACK   (-1)\n#define DUK__OUTPUT_TYPE_FILENAME    0\n#define DUK__OUTPUT_TYPE_LINENUMBER  1\n\nDUK_LOCAL duk_ret_t duk__error_getter_helper(duk_context *ctx, duk_small_int_t output_type) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_idx_t idx_td;\n\tduk_small_int_t i;  /* traceback depth fits into 16 bits */\n\tduk_small_int_t t;  /* stack type fits into 16 bits */\n\tduk_small_int_t count_func = 0;  /* traceback depth ensures fits into 16 bits */\n\tconst char *str_tailcall = \" tailcall\";\n\tconst char *str_strict = \" strict\";\n\tconst char *str_construct = \" construct\";\n\tconst char *str_prevyield = \" preventsyield\";\n\tconst char *str_directeval = \" directeval\";\n\tconst char *str_empty = \"\";\n\n\tDUK_ASSERT_TOP(ctx, 0);  /* fixed arg count */\n\tDUK_UNREF(thr);\n\n\tduk_push_this(ctx);\n\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_INT_TRACEDATA);\n\tidx_td = duk_get_top_index(ctx);\n\n\tduk_push_hstring_stridx(ctx, DUK_STRIDX_NEWLINE_4SPACE);\n\tduk_push_this(ctx);\n\n\t/* [ ... this tracedata sep this ] */\n\n\t/* XXX: skip null filename? */\n\n\tif (duk_check_type(ctx, idx_td, DUK_TYPE_OBJECT)) {\n\t\t/* Current tracedata contains 2 entries per callstack entry. */\n\t\tfor (i = 0; ; i += 2) {\n\t\t\tduk_int_t pc;\n\t\t\tduk_int_t line;\n\t\t\tduk_int_t flags;\n\t\t\tduk_double_t d;\n\t\t\tconst char *funcname;\n\t\t\tconst char *filename;\n\t\t\tduk_hobject *h_func;\n\t\t\tduk_hstring *h_name;\n\n\t\t\tduk_require_stack(ctx, 5);\n\t\t\tduk_get_prop_index(ctx, idx_td, i);\n\t\t\tduk_get_prop_index(ctx, idx_td, i + 1);\n\t\t\td = duk_to_number_m1(ctx);\n\t\t\tpc = (duk_int_t) DUK_FMOD(d, DUK_DOUBLE_2TO32);\n\t\t\tflags = (duk_int_t) DUK_FLOOR(d / DUK_DOUBLE_2TO32);\n\t\t\tt = (duk_small_int_t) duk_get_type(ctx, -2);\n\n\t\t\tif (t == DUK_TYPE_OBJECT || t == DUK_TYPE_LIGHTFUNC) {\n\t\t\t\t/*\n\t\t\t\t *  Ecmascript/native function call or lightfunc call\n\t\t\t\t */\n\n\t\t\t\tcount_func++;\n\n\t\t\t\t/* [ ... v1(func) v2(pc+flags) ] */\n\n\t\t\t\th_func = duk_get_hobject(ctx, -2);  /* NULL for lightfunc */\n\n\t\t\t\t/* These may be systematically omitted by Duktape\n\t\t\t\t * with certain config options, but allow user to\n\t\t\t\t * set them on a case-by-case basis.\n\t\t\t\t */\n\t\t\t\tduk_get_prop_stridx_short(ctx, -2, DUK_STRIDX_NAME);\n\t\t\t\tduk_get_prop_stridx_short(ctx, -3, DUK_STRIDX_FILE_NAME);\n\n#if defined(DUK_USE_PC2LINE)\n\t\t\t\tline = duk_hobject_pc2line_query(ctx, -4, (duk_uint_fast32_t) pc);\n#else\n\t\t\t\tline = 0;\n#endif\n\n\t\t\t\t/* [ ... v1 v2 name filename ] */\n\n\t\t\t\t/* When looking for .fileName/.lineNumber, blame first\n\t\t\t\t * function which has a .fileName.\n\t\t\t\t */\n\t\t\t\tif (duk_is_string_notsymbol(ctx, -1)) {\n\t\t\t\t\tif (output_type == DUK__OUTPUT_TYPE_FILENAME) {\n\t\t\t\t\t\treturn 1;\n\t\t\t\t\t} else if (output_type == DUK__OUTPUT_TYPE_LINENUMBER) {\n\t\t\t\t\t\tduk_push_int(ctx, line);\n\t\t\t\t\t\treturn 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t/* XXX: Change 'anon' handling here too, to use empty string for anonymous functions? */\n\t\t\t\t/* XXX: Could be improved by coercing to a readable duk_tval (especially string escaping) */\n\t\t\t\th_name = duk_get_hstring_notsymbol(ctx, -2);  /* may be NULL */\n\t\t\t\tfuncname = (h_name == NULL || h_name == DUK_HTHREAD_STRING_EMPTY_STRING(thr)) ?\n\t\t\t\t           \"[anon]\" : (const char *) DUK_HSTRING_GET_DATA(h_name);\n\t\t\t\tfilename = duk_get_string_notsymbol(ctx, -1);\n\t\t\t\tfilename = filename ? filename : \"\";\n\t\t\t\tDUK_ASSERT(funcname != NULL);\n\t\t\t\tDUK_ASSERT(filename != NULL);\n\n\t\t\t\tif (h_func == NULL) {\n\t\t\t\t\tduk_push_sprintf(ctx, \"at %s light%s%s%s%s%s\",\n\t\t\t\t\t                 (const char *) funcname,\n\t\t\t\t\t                 (const char *) ((flags & DUK_ACT_FLAG_STRICT) ? str_strict : str_empty),\n\t\t\t\t\t                 (const char *) ((flags & DUK_ACT_FLAG_TAILCALLED) ? str_tailcall : str_empty),\n\t\t\t\t\t                 (const char *) ((flags & DUK_ACT_FLAG_CONSTRUCT) ? str_construct : str_empty),\n\t\t\t\t\t                 (const char *) ((flags & DUK_ACT_FLAG_DIRECT_EVAL) ? str_directeval : str_empty),\n\t\t\t\t\t                 (const char *) ((flags & DUK_ACT_FLAG_PREVENT_YIELD) ? str_prevyield : str_empty));\n\t\t\t\t} else if (DUK_HOBJECT_HAS_NATFUNC(h_func)) {\n\t\t\t\t\tduk_push_sprintf(ctx, \"at %s (%s) native%s%s%s%s%s\",\n\t\t\t\t\t                 (const char *) funcname,\n\t\t\t\t\t                 (const char *) filename,\n\t\t\t\t\t                 (const char *) ((flags & DUK_ACT_FLAG_STRICT) ? str_strict : str_empty),\n\t\t\t\t\t                 (const char *) ((flags & DUK_ACT_FLAG_TAILCALLED) ? str_tailcall : str_empty),\n\t\t\t\t\t                 (const char *) ((flags & DUK_ACT_FLAG_CONSTRUCT) ? str_construct : str_empty),\n\t\t\t\t\t                 (const char *) ((flags & DUK_ACT_FLAG_DIRECT_EVAL) ? str_directeval : str_empty),\n\t\t\t\t\t                 (const char *) ((flags & DUK_ACT_FLAG_PREVENT_YIELD) ? str_prevyield : str_empty));\n\t\t\t\t} else {\n\t\t\t\t\tduk_push_sprintf(ctx, \"at %s (%s:%ld)%s%s%s%s%s\",\n\t\t\t\t\t                 (const char *) funcname,\n\t\t\t\t\t                 (const char *) filename,\n\t\t\t\t\t                 (long) line,\n\t\t\t\t\t                 (const char *) ((flags & DUK_ACT_FLAG_STRICT) ? str_strict : str_empty),\n\t\t\t\t\t                 (const char *) ((flags & DUK_ACT_FLAG_TAILCALLED) ? str_tailcall : str_empty),\n\t\t\t\t\t                 (const char *) ((flags & DUK_ACT_FLAG_CONSTRUCT) ? str_construct : str_empty),\n\t\t\t\t\t                 (const char *) ((flags & DUK_ACT_FLAG_DIRECT_EVAL) ? str_directeval : str_empty),\n\t\t\t\t\t                 (const char *) ((flags & DUK_ACT_FLAG_PREVENT_YIELD) ? str_prevyield : str_empty));\n\t\t\t\t}\n\t\t\t\tduk_replace(ctx, -5);   /* [ ... v1 v2 name filename str ] -> [ ... str v2 name filename ] */\n\t\t\t\tduk_pop_3(ctx);         /* -> [ ... str ] */\n\t\t\t} else if (t == DUK_TYPE_STRING) {\n\t\t\t\tconst char *str_file;\n\n\t\t\t\t/*\n\t\t\t\t *  __FILE__ / __LINE__ entry, here 'pc' is line number directly.\n\t\t\t\t *  Sometimes __FILE__ / __LINE__ is reported as the source for\n\t\t\t\t *  the error (fileName, lineNumber), sometimes not.\n\t\t\t\t */\n\n\t\t\t\t/* [ ... v1(filename) v2(line+flags) ] */\n\n\t\t\t\t/* When looking for .fileName/.lineNumber, blame compilation\n\t\t\t\t * or C call site unless flagged not to do so.\n\t\t\t\t */\n\t\t\t\tif (!(flags & DUK_TB_FLAG_NOBLAME_FILELINE)) {\n\t\t\t\t\tif (output_type == DUK__OUTPUT_TYPE_FILENAME) {\n\t\t\t\t\t\tduk_pop(ctx);\n\t\t\t\t\t\treturn 1;\n\t\t\t\t\t} else if (output_type == DUK__OUTPUT_TYPE_LINENUMBER) {\n\t\t\t\t\t\tduk_push_int(ctx, pc);\n\t\t\t\t\t\treturn 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t/* Tracedata is trusted but avoid any risk of using a NULL\n\t\t\t\t * for %s format because it has undefined behavior.  Symbols\n\t\t\t\t * don't need to be explicitly rejected as they pose no memory\n\t\t\t\t * safety issues.\n\t\t\t\t */\n\t\t\t\tstr_file = (const char *) duk_get_string(ctx, -2);\n\t\t\t\tduk_push_sprintf(ctx, \"at [anon] (%s:%ld) internal\",\n\t\t\t\t                 (const char *) (str_file ? str_file : \"null\"), (long) pc);\n\t\t\t\tduk_replace(ctx, -3);  /* [ ... v1 v2 str ] -> [ ... str v2 ] */\n\t\t\t\tduk_pop(ctx);          /* -> [ ... str ] */\n\t\t\t} else {\n\t\t\t\t/* unknown, ignore */\n\t\t\t\tduk_pop_2(ctx);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (count_func >= DUK_USE_TRACEBACK_DEPTH) {\n\t\t\t/* Possibly truncated; there is no explicit truncation\n\t\t\t * marker so this is the best we can do.\n\t\t\t */\n\n\t\t\tduk_push_hstring_stridx(ctx, DUK_STRIDX_BRACKETED_ELLIPSIS);\n\t\t}\n\t}\n\n\t/* [ ... this tracedata sep this str1 ... strN ] */\n\n\tif (output_type != DUK__OUTPUT_TYPE_TRACEBACK) {\n\t\treturn 0;\n\t} else {\n\t\t/* The 'this' after 'sep' will get ToString() coerced by\n\t\t * duk_join() automatically.  We don't want to do that\n\t\t * coercion when providing .fileName or .lineNumber (GH-254).\n\t\t */\n\t\tduk_join(ctx, duk_get_top(ctx) - (idx_td + 2) /*count, not including sep*/);\n\t\treturn 1;\n\t}\n}\n\n/* XXX: Output type could be encoded into native function 'magic' value to\n * save space.  For setters the stridx could be encoded into 'magic'.\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_error_prototype_stack_getter(duk_context *ctx) {\n\treturn duk__error_getter_helper(ctx, DUK__OUTPUT_TYPE_TRACEBACK);\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_error_prototype_filename_getter(duk_context *ctx) {\n\treturn duk__error_getter_helper(ctx, DUK__OUTPUT_TYPE_FILENAME);\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_error_prototype_linenumber_getter(duk_context *ctx) {\n\treturn duk__error_getter_helper(ctx, DUK__OUTPUT_TYPE_LINENUMBER);\n}\n\n#else  /* DUK_USE_TRACEBACKS */\n\n/*\n *  Traceback handling when tracebacks disabled.\n *\n *  The fileName / lineNumber stubs are now necessary because built-in\n *  data will include the accessor properties in Error.prototype.  If those\n *  are removed for builds without tracebacks, these can also be removed.\n *  'stack' should still be present and produce a ToString() equivalent:\n *  this is useful for user code which prints a stacktrace and expects to\n *  see something useful.  A normal stacktrace also begins with a ToString()\n *  of the error so this makes sense.\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_error_prototype_stack_getter(duk_context *ctx) {\n\t/* XXX: remove this native function and map 'stack' accessor\n\t * to the toString() implementation directly.\n\t */\n\treturn duk_bi_error_prototype_to_string(ctx);\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_error_prototype_filename_getter(duk_context *ctx) {\n\tDUK_UNREF(ctx);\n\treturn 0;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_error_prototype_linenumber_getter(duk_context *ctx) {\n\tDUK_UNREF(ctx);\n\treturn 0;\n}\n\n#endif  /* DUK_USE_TRACEBACKS */\n\nDUK_LOCAL duk_ret_t duk__error_setter_helper(duk_context *ctx, duk_small_uint_t stridx_key) {\n\t/* Attempt to write 'stack', 'fileName', 'lineNumber' works as if\n\t * user code called Object.defineProperty() to create an overriding\n\t * own property.  This allows user code to overwrite .fileName etc\n\t * intuitively as e.g. \"err.fileName = 'dummy'\" as one might expect.\n\t * See https://github.com/svaarala/duktape/issues/387.\n\t */\n\n\tDUK_ASSERT_TOP(ctx, 1);  /* fixed arg count: value */\n\n\tduk_push_this(ctx);\n\tduk_push_hstring_stridx(ctx, (duk_small_int_t) stridx_key);\n\tduk_dup_0(ctx);\n\n\t/* [ ... obj key value ] */\n\n\tDUK_DD(DUK_DDPRINT(\"error setter: %!T %!T %!T\",\n\t                   duk_get_tval(ctx, -3), duk_get_tval(ctx, -2), duk_get_tval(ctx, -1)));\n\n\tduk_def_prop(ctx, -3, DUK_DEFPROP_HAVE_VALUE |\n\t                      DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_WRITABLE |\n\t                      DUK_DEFPROP_HAVE_ENUMERABLE | /*not enumerable*/\n\t                      DUK_DEFPROP_HAVE_CONFIGURABLE | DUK_DEFPROP_CONFIGURABLE);\n\treturn 0;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_error_prototype_stack_setter(duk_context *ctx) {\n\treturn duk__error_setter_helper(ctx, DUK_STRIDX_STACK);\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_error_prototype_filename_setter(duk_context *ctx) {\n\treturn duk__error_setter_helper(ctx, DUK_STRIDX_FILE_NAME);\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_error_prototype_linenumber_setter(duk_context *ctx) {\n\treturn duk__error_setter_helper(ctx, DUK_STRIDX_LINE_NUMBER);\n}\n\n/* automatic undefs */\n#undef DUK__OUTPUT_TYPE_FILENAME\n#undef DUK__OUTPUT_TYPE_LINENUMBER\n#undef DUK__OUTPUT_TYPE_TRACEBACK\n/*\n *  Function built-ins\n */\n\n/* #include duk_internal.h -> already included */\n\n/* Needed even when Function built-in is disabled. */\nDUK_INTERNAL duk_ret_t duk_bi_function_prototype(duk_context *ctx) {\n\t/* ignore arguments, return undefined (E5 Section 15.3.4) */\n\tDUK_UNREF(ctx);\n\treturn 0;\n}\n\n#if defined(DUK_USE_FUNCTION_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_function_constructor(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hstring *h_sourcecode;\n\tduk_idx_t nargs;\n\tduk_idx_t i;\n\tduk_small_uint_t comp_flags;\n\tduk_hcompfunc *func;\n\tduk_hobject *outer_lex_env;\n\tduk_hobject *outer_var_env;\n\n\t/* normal and constructor calls have identical semantics */\n\n\tnargs = duk_get_top(ctx);\n\tfor (i = 0; i < nargs; i++) {\n\t\tduk_to_string(ctx, i);  /* Rejects Symbols during coercion. */\n\t}\n\n\tif (nargs == 0) {\n\t\tduk_push_hstring_empty(ctx);\n\t\tduk_push_hstring_empty(ctx);\n\t} else if (nargs == 1) {\n\t\t/* XXX: cover this with the generic >1 case? */\n\t\tduk_push_hstring_empty(ctx);\n\t} else {\n\t\tduk_insert(ctx, 0);   /* [ arg1 ... argN-1 body] -> [body arg1 ... argN-1] */\n\t\tduk_push_string(ctx, \",\");\n\t\tduk_insert(ctx, 1);\n\t\tduk_join(ctx, nargs - 1);\n\t}\n\n\t/* [ body formals ], formals is comma separated list that needs to be parsed */\n\n\tDUK_ASSERT_TOP(ctx, 2);\n\n\t/* XXX: this placeholder is not always correct, but use for now.\n\t * It will fail in corner cases; see test-dev-func-cons-args.js.\n\t */\n\tduk_push_string(ctx, \"function(\");\n\tduk_dup_1(ctx);\n\tduk_push_string(ctx, \"){\");\n\tduk_dup_0(ctx);\n\tduk_push_string(ctx, \"}\");\n\tduk_concat(ctx, 5);\n\n\t/* [ body formals source ] */\n\n\tDUK_ASSERT_TOP(ctx, 3);\n\n\t/* strictness is not inherited, intentional */\n\tcomp_flags = DUK_COMPILE_FUNCEXPR;\n\n\tduk_push_hstring_stridx(ctx, DUK_STRIDX_COMPILE);  /* XXX: copy from caller? */  /* XXX: ignored now */\n\th_sourcecode = duk_require_hstring(ctx, -2);  /* no symbol check needed; -2 is concat'd code */\n\tduk_js_compile(thr,\n\t               (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_sourcecode),\n\t               (duk_size_t) DUK_HSTRING_GET_BYTELEN(h_sourcecode),\n\t               comp_flags);\n\n\t/* Force .name to 'anonymous' (ES2015). */\n\tduk_push_string(ctx, \"anonymous\");\n\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_NAME, DUK_PROPDESC_FLAGS_C);\n\n\tfunc = (duk_hcompfunc *) duk_known_hobject(ctx, -1);\n\tDUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC((duk_hobject *) func));\n\tDUK_ASSERT(DUK_HOBJECT_HAS_CONSTRUCTABLE((duk_hobject *) func));\n\n\t/* [ body formals source template ] */\n\n\t/* only outer_lex_env matters, as functions always get a new\n\t * variable declaration environment.\n\t */\n\n\touter_lex_env = thr->builtins[DUK_BIDX_GLOBAL_ENV];\n\touter_var_env = thr->builtins[DUK_BIDX_GLOBAL_ENV];\n\n\tduk_js_push_closure(thr, func, outer_var_env, outer_lex_env, 1 /*add_auto_proto*/);\n\n\t/* [ body formals source template closure ] */\n\n\treturn 1;\n}\n#endif  /* DUK_USE_FUNCTION_BUILTIN */\n\n#if defined(DUK_USE_FUNCTION_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_function_prototype_to_string(duk_context *ctx) {\n\tduk_tval *tv;\n\n\t/*\n\t *  E5 Section 15.3.4.2 places few requirements on the output of\n\t *  this function: the result is implementation dependent, must\n\t *  follow FunctionDeclaration syntax (in particular, must have a\n\t *  name even for anonymous functions or functions with empty name).\n\t *  The output does NOT need to compile into anything useful.\n\t *\n\t *  E6 Section 19.2.3.5 changes the requirements completely: the\n\t *  result must either eval() to a functionally equivalent object\n\t *  OR eval() to a SyntaxError.\n\t *\n\t *  We opt for the SyntaxError approach for now, with a syntax that\n\t *  mimics V8's native function syntax:\n\t *\n\t *      'function cos() { [native code] }'\n\t *\n\t *  but extended with [ecmascript code], [bound code], and\n\t *  [lightfunc code].\n\t */\n\n\tduk_push_this(ctx);\n\ttv = DUK_GET_TVAL_NEGIDX(ctx, -1);\n\tDUK_ASSERT(tv != NULL);\n\n\tif (DUK_TVAL_IS_OBJECT(tv)) {\n\t\tduk_hobject *obj = DUK_TVAL_GET_OBJECT(tv);\n\t\tconst char *func_name;\n\n\t\t/* Function name: missing/undefined is mapped to empty string,\n\t\t * otherwise coerce to string.  No handling for invalid identifier\n\t\t * characters or e.g. '{' in the function name.  This doesn't\n\t\t * really matter as long as a SyntaxError results.  Technically\n\t\t * if the name contained a suitable prefix followed by '//' it\n\t\t * might cause the result to parse without error.\n\t\t */\n\t\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_NAME);\n\t\tif (duk_is_undefined(ctx, -1)) {\n\t\t\tfunc_name = \"\";\n\t\t} else {\n\t\t\tfunc_name = duk_to_string(ctx, -1);\n\t\t\tDUK_ASSERT(func_name != NULL);\n\t\t}\n\n\t\tif (DUK_HOBJECT_IS_COMPFUNC(obj)) {\n\t\t\tduk_push_sprintf(ctx, \"function %s() { [ecmascript code] }\", (const char *) func_name);\n\t\t} else if (DUK_HOBJECT_IS_NATFUNC(obj)) {\n\t\t\tduk_push_sprintf(ctx, \"function %s() { [native code] }\", (const char *) func_name);\n\t\t} else if (DUK_HOBJECT_IS_BOUNDFUNC(obj)) {\n\t\t\tduk_push_sprintf(ctx, \"function %s() { [bound code] }\", (const char *) func_name);\n\t\t} else {\n\t\t\tgoto type_error;\n\t\t}\n\t} else if (DUK_TVAL_IS_LIGHTFUNC(tv)) {\n\t\tduk_push_lightfunc_tostring(ctx, tv);\n\t} else {\n\t\tgoto type_error;\n\t}\n\n\treturn 1;\n\n type_error:\n\tDUK_DCERROR_TYPE_INVALID_ARGS((duk_hthread *) ctx);\n}\n#endif\n\n#if defined(DUK_USE_FUNCTION_BUILTIN) || defined(DUK_USE_REFLECT_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_function_prototype_apply(duk_context *ctx) {\n\t/*\n\t *  magic = 0: Function.prototype.apply()\n\t *  magic = 1: Reflect.apply()\n\t *  magic = 2: Reflect.construct()\n\t */\n\n\tduk_idx_t idx_args;\n\tduk_idx_t len;\n\tduk_idx_t i;\n\tduk_int_t magic;\n\tduk_idx_t nargs;\n\tduk_uint_t mask;\n\n\tmagic = duk_get_current_magic(ctx);\n\tswitch (magic) {\n\tcase 0:  /* Function.prototype.apply() */\n\t\tDUK_ASSERT_TOP(ctx, 2);  /* not a vararg function */\n\t\tduk_push_this(ctx);\n\t\tduk_insert(ctx, 0);\n\t\t/* Fall through intentionally for shared handling. */\n\tcase 1:  /* Reflect.apply(); Function.prototype.apply() after 'this' fixup. */\n\t\tDUK_ASSERT_TOP(ctx, 3);  /* not a vararg function */\n\t\tidx_args = 2;\n\t\tduk_require_callable(ctx, 0);\n\t\tbreak;\n\tdefault:  /* Reflect.construct() */\n\t\tDUK_ASSERT(magic == 2);\n\t\tduk_require_constructable(ctx, 0);\n\t\tnargs = duk_get_top(ctx);\n\t\tif (nargs < 2) {\n\t\t\tDUK_DCERROR_TYPE_INVALID_ARGS((duk_hthread *) ctx);\n\t\t}\n\t\tif (nargs >= 3 && !duk_strict_equals(ctx, 0, 2)) {\n\t\t\t/* XXX: [[Construct]] newTarget currently unsupported */\n\t\t\tDUK_ERROR_UNSUPPORTED((duk_hthread *) ctx);\n\t\t}\n\t\tidx_args = 1;\n\t\tbreak;\n\t}\n\n\tif (magic != 2) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"func=%!iT, thisArg=%!iT, argArray=%!iT\",\n\t\t\t\t\t\t\t (duk_tval *) duk_get_tval(ctx, 0),\n\t\t\t\t\t\t\t (duk_tval *) duk_get_tval(ctx, 1),\n\t\t\t\t\t\t\t (duk_tval *) duk_get_tval(ctx, 2)));\n\t} else {\n\t\t/* thisArg is not applicable for Reflect.construct(). */\n\t\tDUK_DDD(DUK_DDDPRINT(\"func=%!iT, argArray=%!iT\",\n\t\t\t\t\t\t\t (duk_tval *) duk_get_tval(ctx, 0),\n\t\t\t\t\t\t\t (duk_tval *) duk_get_tval(ctx, 1)));\n\t}\n\n\t/* [ func thisArg? argArray ] */\n\n\tmask = duk_get_type_mask(ctx, idx_args);\n\tif (mask & (DUK_TYPE_MASK_NULL | DUK_TYPE_MASK_UNDEFINED)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"argArray is null/undefined, no args\"));\n\t\tlen = 0;\n\t} else if (mask & DUK_TYPE_MASK_OBJECT) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"argArray is an object\"));\n\n\t\t/* XXX: make this an internal helper */\n\t\tDUK_ASSERT(idx_args >= 0 && idx_args <= 0x7fffL);  /* short variants would work, but avoid shifting */\n\t\tduk_get_prop_stridx(ctx, idx_args, DUK_STRIDX_LENGTH);\n\t\tlen = (duk_idx_t) duk_to_uint32(ctx, -1);  /* ToUint32() coercion required */\n\t\tduk_pop(ctx);\n\n\t\tduk_require_stack(ctx, len);\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"argArray length is %ld\", (long) len));\n\t\tfor (i = 0; i < len; i++) {\n\t\t\tduk_get_prop_index(ctx, idx_args, i);\n\t\t}\n\t} else {\n\t\tgoto type_error;\n\t}\n\tduk_remove(ctx, idx_args);\n\tDUK_ASSERT_TOP(ctx, idx_args + len);\n\n\t/* [ func thisArg? arg1 ... argN ] */\n\n\tif (magic != 2) {\n\t\t/* Function.prototype.apply() or Reflect.apply() */\n\t\tDUK_DDD(DUK_DDDPRINT(\"apply, func=%!iT, thisArg=%!iT, len=%ld\",\n\t\t\t\t\t\t\t (duk_tval *) duk_get_tval(ctx, 0),\n\t\t\t\t\t\t\t (duk_tval *) duk_get_tval(ctx, 1),\n\t\t\t\t\t\t\t (long) len));\n\t\tduk_call_method(ctx, len);\n\t} else {\n\t\t/* Reflect.construct() */\n\t\tDUK_DDD(DUK_DDDPRINT(\"construct, func=%!iT, len=%ld\",\n\t\t\t\t\t\t\t (duk_tval *) duk_get_tval(ctx, 0),\n\t\t\t\t\t\t\t (long) len));\n\t\tduk_new(ctx, len);\n\t}\n\treturn 1;\n\n type_error:\n\tDUK_DCERROR_TYPE_INVALID_ARGS((duk_hthread *) ctx);\n}\n#endif\n\n#if defined(DUK_USE_FUNCTION_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_function_prototype_call(duk_context *ctx) {\n\tduk_idx_t nargs;\n\n\t/* Step 1 is not necessary because duk_call_method() will take\n\t * care of it.\n\t */\n\n\t/* vararg function, thisArg needs special handling */\n\tnargs = duk_get_top(ctx);  /* = 1 + arg count */\n\tif (nargs == 0) {\n\t\tduk_push_undefined(ctx);\n\t\tnargs++;\n\t}\n\tDUK_ASSERT(nargs >= 1);\n\n\t/* [ thisArg arg1 ... argN ] */\n\n\tduk_push_this(ctx);  /* 'func' in the algorithm */\n\tduk_insert(ctx, 0);\n\n\t/* [ func thisArg arg1 ... argN ] */\n\n\tDUK_DDD(DUK_DDDPRINT(\"func=%!iT, thisArg=%!iT, argcount=%ld, top=%ld\",\n\t                     (duk_tval *) duk_get_tval(ctx, 0),\n\t                     (duk_tval *) duk_get_tval(ctx, 1),\n\t                     (long) (nargs - 1),\n\t                     (long) duk_get_top(ctx)));\n\tduk_call_method(ctx, nargs - 1);\n\treturn 1;\n}\n#endif  /* DUK_USE_FUNCTION_BUILTIN */\n\n#if defined(DUK_USE_FUNCTION_BUILTIN)\n/* XXX: the implementation now assumes \"chained\" bound functions,\n * whereas \"collapsed\" bound functions (where there is ever only\n * one bound function which directly points to a non-bound, final\n * function) would require a \"collapsing\" implementation which\n * merges argument lists etc here.\n */\nDUK_INTERNAL duk_ret_t duk_bi_function_prototype_bind(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *h_bound;\n\tduk_hobject *h_target;\n\tduk_idx_t nargs;\n\tduk_idx_t i;\n\n\t/* vararg function, careful arg handling (e.g. thisArg may not be present) */\n\tnargs = duk_get_top(ctx);  /* = 1 + arg count */\n\tif (nargs == 0) {\n\t\tduk_push_undefined(ctx);\n\t\tnargs++;\n\t}\n\tDUK_ASSERT(nargs >= 1);\n\n\tduk_push_this(ctx);\n\tduk_require_callable(ctx, -1);\n\n\t/* [ thisArg arg1 ... argN func ]  (thisArg+args == nargs total) */\n\tDUK_ASSERT_TOP(ctx, nargs + 1);\n\n\t/* create bound function object */\n\th_bound = duk_push_object_helper(ctx,\n\t                                 DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                                 DUK_HOBJECT_FLAG_FASTREFS |\n\t                                 DUK_HOBJECT_FLAG_BOUNDFUNC |\n\t                                 DUK_HOBJECT_FLAG_CONSTRUCTABLE |\n\t                                 DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_FUNCTION),\n\t                                 DUK_BIDX_FUNCTION_PROTOTYPE);\n\tDUK_ASSERT(h_bound != NULL);\n\n\t/* [ thisArg arg1 ... argN func boundFunc ] */\n\tduk_dup_m2(ctx);  /* func */\n\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_TARGET, DUK_PROPDESC_FLAGS_NONE);\n\n\tduk_dup_0(ctx);   /* thisArg */\n\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_THIS, DUK_PROPDESC_FLAGS_NONE);\n\n\tduk_push_array(ctx);\n\n\t/* [ thisArg arg1 ... argN func boundFunc argArray ] */\n\n\tfor (i = 0; i < nargs - 1; i++) {\n\t\tduk_dup(ctx, 1 + i);\n\t\tduk_put_prop_index(ctx, -2, i);\n\t}\n\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_ARGS, DUK_PROPDESC_FLAGS_NONE);\n\n\t/* [ thisArg arg1 ... argN func boundFunc ] */\n\n\th_target = duk_get_hobject(ctx, -2);\n\n\t/* internal prototype must be copied from the target */\n\tif (h_target != NULL) {\n\t\t/* For lightfuncs Function.prototype is used and is already in place. */\n\t\tDUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, h_bound, DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h_target));\n\t}\n\n\t/* bound function 'length' property is interesting */\n\tif (h_target == NULL ||  /* lightfunc */\n\t    DUK_HOBJECT_GET_CLASS_NUMBER(h_target) == DUK_HOBJECT_CLASS_FUNCTION) {\n\t\t/* For lightfuncs, simply read the virtual property. */\n\t\tduk_int_t tmp;\n\t\tduk_get_prop_stridx_short(ctx, -2, DUK_STRIDX_LENGTH);\n\t\ttmp = duk_to_int(ctx, -1) - (nargs - 1);  /* step 15.a */\n\t\tduk_pop(ctx);\n\t\tduk_push_int(ctx, (tmp < 0 ? 0 : tmp));\n\t} else {\n\t\tduk_push_int(ctx, 0);\n\t}\n\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_LENGTH, DUK_PROPDESC_FLAGS_C);  /* attrs in E6 Section 9.2.4 */\n\n\t/* caller and arguments must use the same thrower, [[ThrowTypeError]] */\n\tduk_xdef_prop_stridx_thrower(ctx, -1, DUK_STRIDX_CALLER);\n\tduk_xdef_prop_stridx_thrower(ctx, -1, DUK_STRIDX_LC_ARGUMENTS);\n\n\t/* XXX: 'copy properties' API call? */\n#if defined(DUK_USE_FUNC_NAME_PROPERTY)\n\tduk_push_string(ctx, \"bound \");  /* ES2015 19.2.3.2. */\n\tduk_get_prop_stridx_short(ctx, -3, DUK_STRIDX_NAME);\n\tif (!duk_is_string_notsymbol(ctx, -1)) {\n\t\t/* ES2015 has requirement to check that .name of target is a string\n\t\t * (also must check for Symbol); if not, targetName should be the\n\t\t * empty string.  ES2015 19.2.3.2.\n\t\t */\n\t\tduk_pop(ctx);\n\t\tduk_push_hstring_empty(ctx);\n\t}\n\tduk_concat(ctx, 2);\n\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_NAME, DUK_PROPDESC_FLAGS_C);\n#endif\n#if defined(DUK_USE_FUNC_FILENAME_PROPERTY)\n\tduk_get_prop_stridx_short(ctx, -2, DUK_STRIDX_FILE_NAME);\n\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_FILE_NAME, DUK_PROPDESC_FLAGS_C);\n#endif\n\n\t/* The 'strict' flag is copied to get the special [[Get]] of E5.1\n\t * Section 15.3.5.4 to apply when a 'caller' value is a strict bound\n\t * function.  Not sure if this is correct, because the specification\n\t * is a bit ambiguous on this point but it would make sense.\n\t */\n\tif (h_target == NULL) {\n\t\t/* Lightfuncs are always strict. */\n\t\tDUK_HOBJECT_SET_STRICT(h_bound);\n\t} else if (DUK_HOBJECT_HAS_STRICT(h_target)) {\n\t\tDUK_HOBJECT_SET_STRICT(h_bound);\n\t}\n\tDUK_DDD(DUK_DDDPRINT(\"created bound function: %!iT\", (duk_tval *) duk_get_tval(ctx, -1)));\n\n\treturn 1;\n}\n#endif  /* DUK_USE_FUNCTION_BUILTIN */\n/*\n *  Global object built-ins\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Encoding/decoding helpers\n */\n\n/* XXX: Could add fast path (for each transform callback) with direct byte\n * lookups (no shifting) and no explicit check for x < 0x80 before table\n * lookup.\n */\n\n/* Macros for creating and checking bitmasks for character encoding.\n * Bit number is a bit counterintuitive, but minimizes code size.\n */\n#define DUK__MKBITS(a,b,c,d,e,f,g,h)  ((duk_uint8_t) ( \\\n\t((a) << 0) | ((b) << 1) | ((c) << 2) | ((d) << 3) | \\\n\t((e) << 4) | ((f) << 5) | ((g) << 6) | ((h) << 7) \\\n\t))\n#define DUK__CHECK_BITMASK(table,cp)  ((table)[(cp) >> 3] & (1 << ((cp) & 0x07)))\n\n/* E5.1 Section 15.1.3.3: uriReserved + uriUnescaped + '#' */\nDUK_LOCAL const duk_uint8_t duk__encode_uriunescaped_table[16] = {\n\tDUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),  /* 0x00-0x0f */\n\tDUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),  /* 0x10-0x1f */\n\tDUK__MKBITS(0, 1, 0, 1, 1, 0, 1, 1), DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1),  /* 0x20-0x2f */\n\tDUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 1, 0, 1, 0, 1),  /* 0x30-0x3f */\n\tDUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1),  /* 0x40-0x4f */\n\tDUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 0, 0, 0, 0, 1),  /* 0x50-0x5f */\n\tDUK__MKBITS(0, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1),  /* 0x60-0x6f */\n\tDUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 0, 0, 0, 1, 0),  /* 0x70-0x7f */\n};\n\n/* E5.1 Section 15.1.3.4: uriUnescaped */\nDUK_LOCAL const duk_uint8_t duk__encode_uricomponent_unescaped_table[16] = {\n\tDUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),  /* 0x00-0x0f */\n\tDUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),  /* 0x10-0x1f */\n\tDUK__MKBITS(0, 1, 0, 0, 0, 0, 0, 1), DUK__MKBITS(1, 1, 1, 0, 0, 1, 1, 0),  /* 0x20-0x2f */\n\tDUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 0, 0, 0, 0, 0, 0),  /* 0x30-0x3f */\n\tDUK__MKBITS(0, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1),  /* 0x40-0x4f */\n\tDUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 0, 0, 0, 0, 1),  /* 0x50-0x5f */\n\tDUK__MKBITS(0, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1),  /* 0x60-0x6f */\n\tDUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 0, 0, 0, 1, 0),  /* 0x70-0x7f */\n};\n\n/* E5.1 Section 15.1.3.1: uriReserved + '#' */\nDUK_LOCAL const duk_uint8_t duk__decode_uri_reserved_table[16] = {\n\tDUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),  /* 0x00-0x0f */\n\tDUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),  /* 0x10-0x1f */\n\tDUK__MKBITS(0, 0, 0, 1, 1, 0, 1, 0), DUK__MKBITS(0, 0, 0, 1, 1, 0, 0, 1),  /* 0x20-0x2f */\n\tDUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 1, 1, 0, 1, 0, 1),  /* 0x30-0x3f */\n\tDUK__MKBITS(1, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),  /* 0x40-0x4f */\n\tDUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),  /* 0x50-0x5f */\n\tDUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),  /* 0x60-0x6f */\n\tDUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),  /* 0x70-0x7f */\n};\n\n/* E5.1 Section 15.1.3.2: empty */\nDUK_LOCAL const duk_uint8_t duk__decode_uri_component_reserved_table[16] = {\n\tDUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),  /* 0x00-0x0f */\n\tDUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),  /* 0x10-0x1f */\n\tDUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),  /* 0x20-0x2f */\n\tDUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),  /* 0x30-0x3f */\n\tDUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),  /* 0x40-0x4f */\n\tDUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),  /* 0x50-0x5f */\n\tDUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),  /* 0x60-0x6f */\n\tDUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),  /* 0x70-0x7f */\n};\n\n#if defined(DUK_USE_SECTION_B)\n/* E5.1 Section B.2.2, step 7. */\nDUK_LOCAL const duk_uint8_t duk__escape_unescaped_table[16] = {\n\tDUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),  /* 0x00-0x0f */\n\tDUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0),  /* 0x10-0x1f */\n\tDUK__MKBITS(0, 0, 0, 0, 0, 0, 0, 0), DUK__MKBITS(0, 0, 1, 1, 0, 1, 1, 1),  /* 0x20-0x2f */\n\tDUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 0, 0, 0, 0, 0, 0),  /* 0x30-0x3f */\n\tDUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1),  /* 0x40-0x4f */\n\tDUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 0, 0, 0, 0, 1),  /* 0x50-0x5f */\n\tDUK__MKBITS(0, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1),  /* 0x60-0x6f */\n\tDUK__MKBITS(1, 1, 1, 1, 1, 1, 1, 1), DUK__MKBITS(1, 1, 1, 0, 0, 0, 0, 0)   /* 0x70-0x7f */\n};\n#endif  /* DUK_USE_SECTION_B */\n\ntypedef struct {\n\tduk_hthread *thr;\n\tduk_hstring *h_str;\n\tduk_bufwriter_ctx bw;\n\tconst duk_uint8_t *p;\n\tconst duk_uint8_t *p_start;\n\tconst duk_uint8_t *p_end;\n} duk__transform_context;\n\ntypedef void (*duk__transform_callback)(duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp);\n\n/* XXX: refactor and share with other code */\nDUK_LOCAL duk_small_int_t duk__decode_hex_escape(const duk_uint8_t *p, duk_small_int_t n) {\n\tduk_small_int_t ch;\n\tduk_small_int_t t = 0;\n\n\twhile (n > 0) {\n\t\tt = t * 16;\n\t\tch = (duk_small_int_t) duk_hex_dectab[*p++];\n\t\tif (DUK_LIKELY(ch >= 0)) {\n\t\t\tt += ch;\n\t\t} else {\n\t\t\treturn -1;\n\t\t}\n\t\tn--;\n\t}\n\treturn t;\n}\n\nDUK_LOCAL int duk__transform_helper(duk_context *ctx, duk__transform_callback callback, const void *udata) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk__transform_context tfm_ctx_alloc;\n\tduk__transform_context *tfm_ctx = &tfm_ctx_alloc;\n\tduk_codepoint_t cp;\n\n\ttfm_ctx->thr = thr;\n\n\ttfm_ctx->h_str = duk_to_hstring(ctx, 0);\n\tDUK_ASSERT(tfm_ctx->h_str != NULL);\n\n\tDUK_BW_INIT_PUSHBUF(thr, &tfm_ctx->bw, DUK_HSTRING_GET_BYTELEN(tfm_ctx->h_str));  /* initial size guess */\n\n\ttfm_ctx->p_start = DUK_HSTRING_GET_DATA(tfm_ctx->h_str);\n\ttfm_ctx->p_end = tfm_ctx->p_start + DUK_HSTRING_GET_BYTELEN(tfm_ctx->h_str);\n\ttfm_ctx->p = tfm_ctx->p_start;\n\n\twhile (tfm_ctx->p < tfm_ctx->p_end) {\n\t\tcp = (duk_codepoint_t) duk_unicode_decode_xutf8_checked(thr, &tfm_ctx->p, tfm_ctx->p_start, tfm_ctx->p_end);\n\t\tcallback(tfm_ctx, udata, cp);\n\t}\n\n\tDUK_BW_COMPACT(thr, &tfm_ctx->bw);\n\n\t(void) duk_buffer_to_string(ctx, -1);  /* Safe if transform is safe. */\n\treturn 1;\n}\n\nDUK_LOCAL void duk__transform_callback_encode_uri(duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp) {\n\tduk_uint8_t xutf8_buf[DUK_UNICODE_MAX_XUTF8_LENGTH];\n\tduk_small_int_t len;\n\tduk_codepoint_t cp1, cp2;\n\tduk_small_int_t i, t;\n\tconst duk_uint8_t *unescaped_table = (const duk_uint8_t *) udata;\n\n\t/* UTF-8 encoded bytes escaped as %xx%xx%xx... -> 3 * nbytes.\n\t * Codepoint range is restricted so this is a slightly too large\n\t * but doesn't matter.\n\t */\n\tDUK_BW_ENSURE(tfm_ctx->thr, &tfm_ctx->bw, 3 * DUK_UNICODE_MAX_XUTF8_LENGTH);\n\n\tif (cp < 0) {\n\t\tgoto uri_error;\n\t} else if ((cp < 0x80L) && DUK__CHECK_BITMASK(unescaped_table, cp)) {\n\t\tDUK_BW_WRITE_RAW_U8(tfm_ctx->thr, &tfm_ctx->bw, (duk_uint8_t) cp);\n\t\treturn;\n\t} else if (cp >= 0xdc00L && cp <= 0xdfffL) {\n\t\tgoto uri_error;\n\t} else if (cp >= 0xd800L && cp <= 0xdbffL) {\n\t\t/* Needs lookahead */\n\t\tif (duk_unicode_decode_xutf8(tfm_ctx->thr, &tfm_ctx->p, tfm_ctx->p_start, tfm_ctx->p_end, (duk_ucodepoint_t *) &cp2) == 0) {\n\t\t\tgoto uri_error;\n\t\t}\n\t\tif (!(cp2 >= 0xdc00L && cp2 <= 0xdfffL)) {\n\t\t\tgoto uri_error;\n\t\t}\n\t\tcp1 = cp;\n\t\tcp = ((cp1 - 0xd800L) << 10) + (cp2 - 0xdc00L) + 0x10000L;\n\t} else if (cp > 0x10ffffL) {\n\t\t/* Although we can allow non-BMP characters (they'll decode\n\t\t * back into surrogate pairs), we don't allow extended UTF-8\n\t\t * characters; they would encode to URIs which won't decode\n\t\t * back because of strict UTF-8 checks in URI decoding.\n\t\t * (However, we could just as well allow them here.)\n\t\t */\n\t\tgoto uri_error;\n\t} else {\n\t\t/* Non-BMP characters within valid UTF-8 range: encode as is.\n\t\t * They'll decode back into surrogate pairs if the escaped\n\t\t * output is decoded.\n\t\t */\n\t\t;\n\t}\n\n\tlen = duk_unicode_encode_xutf8((duk_ucodepoint_t) cp, xutf8_buf);\n\tfor (i = 0; i < len; i++) {\n\t\tt = (duk_small_int_t) xutf8_buf[i];\n\t\tDUK_BW_WRITE_RAW_U8_3(tfm_ctx->thr,\n\t\t                      &tfm_ctx->bw,\n\t\t                      DUK_ASC_PERCENT,\n\t\t                      (duk_uint8_t) duk_uc_nybbles[t >> 4],\n                                      (duk_uint8_t) duk_uc_nybbles[t & 0x0f]);\n\t}\n\n\treturn;\n\n uri_error:\n\tDUK_ERROR_URI(tfm_ctx->thr, DUK_STR_INVALID_INPUT);\n}\n\nDUK_LOCAL void duk__transform_callback_decode_uri(duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp) {\n\tconst duk_uint8_t *reserved_table = (const duk_uint8_t *) udata;\n\tduk_small_uint_t utf8_blen;\n\tduk_codepoint_t min_cp;\n\tduk_small_int_t t;  /* must be signed */\n\tduk_small_uint_t i;\n\n\t/* Maximum write size: XUTF8 path writes max DUK_UNICODE_MAX_XUTF8_LENGTH,\n\t * percent escape path writes max two times CESU-8 encoded BMP length.\n\t */\n\tDUK_BW_ENSURE(tfm_ctx->thr,\n\t              &tfm_ctx->bw,\n\t              (DUK_UNICODE_MAX_XUTF8_LENGTH >= 2 * DUK_UNICODE_MAX_CESU8_BMP_LENGTH ?\n\t              DUK_UNICODE_MAX_XUTF8_LENGTH : DUK_UNICODE_MAX_CESU8_BMP_LENGTH));\n\n\tif (cp == (duk_codepoint_t) '%') {\n\t\tconst duk_uint8_t *p = tfm_ctx->p;\n\t\tduk_size_t left = (duk_size_t) (tfm_ctx->p_end - p);  /* bytes left */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"percent encoding, left=%ld\", (long) left));\n\n\t\tif (left < 2) {\n\t\t\tgoto uri_error;\n\t\t}\n\n\t\tt = duk__decode_hex_escape(p, 2);\n\t\tDUK_DDD(DUK_DDDPRINT(\"first byte: %ld\", (long) t));\n\t\tif (t < 0) {\n\t\t\tgoto uri_error;\n\t\t}\n\n\t\tif (t < 0x80) {\n\t\t\tif (DUK__CHECK_BITMASK(reserved_table, t)) {\n\t\t\t\t/* decode '%xx' to '%xx' if decoded char in reserved set */\n\t\t\t\tDUK_ASSERT(tfm_ctx->p - 1 >= tfm_ctx->p_start);\n\t\t\t\tDUK_BW_WRITE_RAW_U8_3(tfm_ctx->thr,\n\t\t\t\t                      &tfm_ctx->bw,\n\t\t\t\t                      DUK_ASC_PERCENT,\n\t\t\t\t                      p[0],\n\t\t\t\t                      p[1]);\n\t\t\t} else {\n\t\t\t\tDUK_BW_WRITE_RAW_U8(tfm_ctx->thr, &tfm_ctx->bw, (duk_uint8_t) t);\n\t\t\t}\n\t\t\ttfm_ctx->p += 2;\n\t\t\treturn;\n\t\t}\n\n\t\t/* Decode UTF-8 codepoint from a sequence of hex escapes.  The\n\t\t * first byte of the sequence has been decoded to 't'.\n\t\t *\n\t\t * Note that UTF-8 validation must be strict according to the\n\t\t * specification: E5.1 Section 15.1.3, decode algorithm step\n\t\t * 4.d.vii.8.  URIError from non-shortest encodings is also\n\t\t * specifically noted in the spec.\n\t\t */\n\n\t\tDUK_ASSERT(t >= 0x80);\n\t\tif (t < 0xc0) {\n\t\t\t/* continuation byte */\n\t\t\tgoto uri_error;\n\t\t} else if (t < 0xe0) {\n\t\t\t/* 110x xxxx; 2 bytes */\n\t\t\tutf8_blen = 2;\n\t\t\tmin_cp = 0x80L;\n\t\t\tcp = t & 0x1f;\n\t\t} else if (t < 0xf0) {\n\t\t\t/* 1110 xxxx; 3 bytes */\n\t\t\tutf8_blen = 3;\n\t\t\tmin_cp = 0x800L;\n\t\t\tcp = t & 0x0f;\n\t\t} else if (t < 0xf8) {\n\t\t\t/* 1111 0xxx; 4 bytes */\n\t\t\tutf8_blen = 4;\n\t\t\tmin_cp = 0x10000L;\n\t\t\tcp = t & 0x07;\n\t\t} else {\n\t\t\t/* extended utf-8 not allowed for URIs */\n\t\t\tgoto uri_error;\n\t\t}\n\n\t\tif (left < utf8_blen * 3 - 1) {\n\t\t\t/* '%xx%xx...%xx', p points to char after first '%' */\n\t\t\tgoto uri_error;\n\t\t}\n\n\t\tp += 3;\n\t\tfor (i = 1; i < utf8_blen; i++) {\n\t\t\t/* p points to digit part ('%xy', p points to 'x') */\n\t\t\tt = duk__decode_hex_escape(p, 2);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"i=%ld utf8_blen=%ld cp=%ld t=0x%02lx\",\n\t\t\t                     (long) i, (long) utf8_blen, (long) cp, (unsigned long) t));\n\t\t\tif (t < 0) {\n\t\t\t\tgoto uri_error;\n\t\t\t}\n\t\t\tif ((t & 0xc0) != 0x80) {\n\t\t\t\tgoto uri_error;\n\t\t\t}\n\t\t\tcp = (cp << 6) + (t & 0x3f);\n\t\t\tp += 3;\n\t\t}\n\t\tp--;  /* p overshoots */\n\t\ttfm_ctx->p = p;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"final cp=%ld, min_cp=%ld\", (long) cp, (long) min_cp));\n\n\t\tif (cp < min_cp || cp > 0x10ffffL || (cp >= 0xd800L && cp <= 0xdfffL)) {\n\t\t\tgoto uri_error;\n\t\t}\n\n\t\t/* The E5.1 algorithm checks whether or not a decoded codepoint\n\t\t * is below 0x80 and perhaps may be in the \"reserved\" set.\n\t\t * This seems pointless because the single byte UTF-8 case is\n\t\t * handled separately, and non-shortest encodings are rejected.\n\t\t * So, 'cp' cannot be below 0x80 here, and thus cannot be in\n\t\t * the reserved set.\n\t\t */\n\n\t\t/* utf-8 validation ensures these */\n\t\tDUK_ASSERT(cp >= 0x80L && cp <= 0x10ffffL);\n\n\t\tif (cp >= 0x10000L) {\n\t\t\tcp -= 0x10000L;\n\t\t\tDUK_ASSERT(cp < 0x100000L);\n\n\t\t\tDUK_BW_WRITE_RAW_XUTF8(tfm_ctx->thr, &tfm_ctx->bw, ((cp >> 10) + 0xd800L));\n\t\t\tDUK_BW_WRITE_RAW_XUTF8(tfm_ctx->thr, &tfm_ctx->bw, ((cp & 0x03ffUL) + 0xdc00L));\n\t\t} else {\n\t\t\tDUK_BW_WRITE_RAW_XUTF8(tfm_ctx->thr, &tfm_ctx->bw, cp);\n\t\t}\n\t} else {\n\t\tDUK_BW_WRITE_RAW_XUTF8(tfm_ctx->thr, &tfm_ctx->bw, cp);\n\t}\n\treturn;\n\n uri_error:\n\tDUK_ERROR_URI(tfm_ctx->thr, DUK_STR_INVALID_INPUT);\n}\n\n#if defined(DUK_USE_SECTION_B)\nDUK_LOCAL void duk__transform_callback_escape(duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp) {\n\tDUK_UNREF(udata);\n\n\tDUK_BW_ENSURE(tfm_ctx->thr, &tfm_ctx->bw, 6);\n\n\tif (cp < 0) {\n\t\tgoto esc_error;\n\t} else if ((cp < 0x80L) && DUK__CHECK_BITMASK(duk__escape_unescaped_table, cp)) {\n\t\tDUK_BW_WRITE_RAW_U8(tfm_ctx->thr, &tfm_ctx->bw, (duk_uint8_t) cp);\n\t} else if (cp < 0x100L) {\n\t\tDUK_BW_WRITE_RAW_U8_3(tfm_ctx->thr,\n\t\t                      &tfm_ctx->bw,\n\t\t                      (duk_uint8_t) DUK_ASC_PERCENT,\n\t\t                      (duk_uint8_t) duk_uc_nybbles[cp >> 4],\n\t\t                      (duk_uint8_t) duk_uc_nybbles[cp & 0x0f]);\n\t} else if (cp < 0x10000L) {\n\t\tDUK_BW_WRITE_RAW_U8_6(tfm_ctx->thr,\n\t\t                      &tfm_ctx->bw,\n\t\t                      (duk_uint8_t) DUK_ASC_PERCENT,\n\t\t                      (duk_uint8_t) DUK_ASC_LC_U,\n\t\t                      (duk_uint8_t) duk_uc_nybbles[cp >> 12],\n\t\t                      (duk_uint8_t) duk_uc_nybbles[(cp >> 8) & 0x0f],\n\t\t                      (duk_uint8_t) duk_uc_nybbles[(cp >> 4) & 0x0f],\n\t\t                      (duk_uint8_t) duk_uc_nybbles[cp & 0x0f]);\n\t} else {\n\t\t/* Characters outside BMP cannot be escape()'d.  We could\n\t\t * encode them as surrogate pairs (for codepoints inside\n\t\t * valid UTF-8 range, but not extended UTF-8).  Because\n\t\t * escape() and unescape() are legacy functions, we don't.\n\t\t */\n\t\tgoto esc_error;\n\t}\n\n\treturn;\n\n esc_error:\n\tDUK_ERROR_TYPE(tfm_ctx->thr, DUK_STR_INVALID_INPUT);\n}\n\nDUK_LOCAL void duk__transform_callback_unescape(duk__transform_context *tfm_ctx, const void *udata, duk_codepoint_t cp) {\n\tduk_small_int_t t;\n\n\tDUK_UNREF(udata);\n\n\tif (cp == (duk_codepoint_t) '%') {\n\t\tconst duk_uint8_t *p = tfm_ctx->p;\n\t\tduk_size_t left = (duk_size_t) (tfm_ctx->p_end - p);  /* bytes left */\n\n\t\tif (left >= 5 && p[0] == 'u' &&\n\t\t    ((t = duk__decode_hex_escape(p + 1, 4)) >= 0)) {\n\t\t\tcp = (duk_codepoint_t) t;\n\t\t\ttfm_ctx->p += 5;\n\t\t} else if (left >= 2 &&\n\t\t           ((t = duk__decode_hex_escape(p, 2)) >= 0)) {\n\t\t\tcp = (duk_codepoint_t) t;\n\t\t\ttfm_ctx->p += 2;\n\t\t}\n\t}\n\n\tDUK_BW_WRITE_ENSURE_XUTF8(tfm_ctx->thr, &tfm_ctx->bw, cp);\n}\n#endif  /* DUK_USE_SECTION_B */\n\n/*\n *  Eval\n *\n *  Eval needs to handle both a \"direct eval\" and an \"indirect eval\".\n *  Direct eval handling needs access to the caller's activation so that its\n *  lexical environment can be accessed.  A direct eval is only possible from\n *  Ecmascript code; an indirect eval call is possible also from C code.\n *  When an indirect eval call is made from C code, there may not be a\n *  calling activation at all which needs careful handling.\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_global_object_eval(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hstring *h;\n\tduk_activation *act_caller;\n\tduk_activation *act_eval;\n\tduk_activation *act;\n\tduk_hcompfunc *func;\n\tduk_hobject *outer_lex_env;\n\tduk_hobject *outer_var_env;\n\tduk_bool_t this_to_global = 1;\n\tduk_small_uint_t comp_flags;\n\tduk_int_t level = -2;\n\n\tDUK_ASSERT(duk_get_top(ctx) == 1 || duk_get_top(ctx) == 2);  /* 2 when called by debugger */\n\tDUK_ASSERT(thr->callstack_top >= 1);  /* at least this function exists */\n\tDUK_ASSERT(thr->callstack_curr != NULL);\n\tDUK_ASSERT((thr->callstack_curr->flags & DUK_ACT_FLAG_DIRECT_EVAL) == 0 || /* indirect eval */\n\t           (thr->callstack_top >= 2));  /* if direct eval, calling activation must exist */\n\n\t/*\n\t *  callstack_top - 1 --> this function\n\t *  callstack_top - 2 --> caller (may not exist)\n\t *\n\t *  If called directly from C, callstack_top might be 1.  If calling\n\t *  activation doesn't exist, call must be indirect.\n\t */\n\n\th = duk_get_hstring_notsymbol(ctx, 0);\n\tif (!h) {\n\t\t/* Symbol must be returned as is, like any non-string values. */\n\t\treturn 1;  /* return arg as-is */\n\t}\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\t/* NOTE: level is used only by the debugger and should never be present\n\t * for an Ecmascript eval().\n\t */\n\tDUK_ASSERT(level == -2);  /* by default, use caller's environment */\n\tif (duk_get_top(ctx) >= 2 && duk_is_number(ctx, 1)) {\n\t\tlevel = duk_get_int(ctx, 1);\n\t}\n\tDUK_ASSERT(level <= -2);  /* This is guaranteed by debugger code. */\n#endif\n\n\t/* [ source ] */\n\n\tcomp_flags = DUK_COMPILE_EVAL;\n\tact_eval = thr->callstack_curr;  /* this function */\n\tDUK_ASSERT(act_eval != NULL);\n\tif (thr->callstack_top >= (duk_size_t) -level) {\n\t\t/* Have a calling activation, check for direct eval (otherwise\n\t\t * assume indirect eval.\n\t\t */\n\t\tact_caller = thr->callstack + thr->callstack_top + level;  /* caller */\n\t\tif ((act_caller->flags & DUK_ACT_FLAG_STRICT) &&\n\t\t    (act_eval->flags & DUK_ACT_FLAG_DIRECT_EVAL)) {\n\t\t\t/* Only direct eval inherits strictness from calling code\n\t\t\t * (E5.1 Section 10.1.1).\n\t\t\t */\n\t\t\tcomp_flags |= DUK_COMPILE_STRICT;\n\t\t}\n\t} else {\n\t\tDUK_ASSERT((act_eval->flags & DUK_ACT_FLAG_DIRECT_EVAL) == 0);\n\t}\n\tact_caller = NULL;  /* avoid dereference after potential callstack realloc */\n\tact_eval = NULL;\n\n\tduk_push_hstring_stridx(ctx, DUK_STRIDX_INPUT);  /* XXX: copy from caller? */\n\tduk_js_compile(thr,\n\t               (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h),\n\t               (duk_size_t) DUK_HSTRING_GET_BYTELEN(h),\n\t               comp_flags);\n\tfunc = (duk_hcompfunc *) duk_known_hobject(ctx, -1);\n\tDUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC((duk_hobject *) func));\n\n\t/* [ source template ] */\n\n\t/* E5 Section 10.4.2 */\n\tDUK_ASSERT(thr->callstack_top >= 1);\n\tact = thr->callstack_curr;  /* this function */\n\tif (act->flags & DUK_ACT_FLAG_DIRECT_EVAL) {\n\t\tDUK_ASSERT(thr->callstack_top >= 2);\n\t\tact = thr->callstack + thr->callstack_top + level;  /* caller */\n\t\tif (act->lex_env == NULL) {\n\t\t\tDUK_ASSERT(act->var_env == NULL);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"delayed environment initialization\"));\n\n\t\t\t/* this may have side effects, so re-lookup act */\n\t\t\tduk_js_init_activation_environment_records_delayed(thr, act);\n\t\t\tact = thr->callstack + thr->callstack_top + level;\n\t\t}\n\t\tDUK_ASSERT(act->lex_env != NULL);\n\t\tDUK_ASSERT(act->var_env != NULL);\n\n\t\tthis_to_global = 0;\n\n\t\tif (DUK_HOBJECT_HAS_STRICT((duk_hobject *) func)) {\n\t\t\tduk_hdecenv *new_env;\n\t\t\tduk_hobject *act_lex_env;\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"direct eval call to a strict function -> \"\n\t\t\t                     \"var_env and lex_env to a fresh env, \"\n\t\t\t                     \"this_binding to caller's this_binding\"));\n\n\t\t\tact_lex_env = act->lex_env;\n\t\t\tact = NULL;  /* invalidated */\n\n\t\t\tnew_env = duk_hdecenv_alloc(thr,\n\t\t\t                            DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t\t\t                            DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_DECENV));\n\t\t\tDUK_ASSERT(new_env != NULL);\n\t\t\tduk_push_hobject(ctx, (duk_hobject *) new_env);\n\n\t\t\tDUK_ASSERT(DUK_HOBJECT_GET_PROTOTYPE(thr->heap, (duk_hobject *) new_env) == NULL);\n\t\t\tDUK_HOBJECT_SET_PROTOTYPE(thr->heap, (duk_hobject *) new_env, act_lex_env);\n\t\t\tDUK_HOBJECT_INCREF_ALLOWNULL(thr, act_lex_env);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"new_env allocated: %!iO\", (duk_heaphdr *) new_env));\n\n\t\t\touter_lex_env = (duk_hobject *) new_env;\n\t\t\touter_var_env = (duk_hobject *) new_env;\n\n\t\t\tduk_insert(ctx, 0);  /* stash to bottom of value stack to keep new_env reachable for duration of eval */\n\n\t\t\t/* compiler's responsibility */\n\t\t\tDUK_ASSERT(DUK_HOBJECT_HAS_NEWENV((duk_hobject *) func));\n\t\t} else {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"direct eval call to a non-strict function -> \"\n\t\t\t                     \"var_env and lex_env to caller's envs, \"\n\t\t\t                     \"this_binding to caller's this_binding\"));\n\n\t\t\touter_lex_env = act->lex_env;\n\t\t\touter_var_env = act->var_env;\n\n\t\t\t/* compiler's responsibility */\n\t\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_NEWENV((duk_hobject *) func));\n\t\t}\n\t} else {\n\t\tDUK_DDD(DUK_DDDPRINT(\"indirect eval call -> var_env and lex_env to \"\n\t\t                     \"global object, this_binding to global object\"));\n\n\t\tthis_to_global = 1;\n\t\touter_lex_env = thr->builtins[DUK_BIDX_GLOBAL_ENV];\n\t\touter_var_env = thr->builtins[DUK_BIDX_GLOBAL_ENV];\n\t}\n\tact = NULL;\n\n\t/* Eval code doesn't need an automatic .prototype object. */\n\tduk_js_push_closure(thr, func, outer_var_env, outer_lex_env, 0 /*add_auto_proto*/);\n\n\t/* [ env? source template closure ] */\n\n\tif (this_to_global) {\n\t\tDUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL);\n\t\tduk_push_hobject_bidx(ctx, DUK_BIDX_GLOBAL);\n\t} else {\n\t\tduk_tval *tv;\n\t\tDUK_ASSERT(thr->callstack_top >= 2);\n\t\tact = thr->callstack + thr->callstack_top + level;  /* caller */\n\t\ttv = thr->valstack + act->idx_bottom - 1;  /* this is just beneath bottom */\n\t\tDUK_ASSERT(tv >= thr->valstack);\n\t\tduk_push_tval(ctx, tv);\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"eval -> lex_env=%!iO, var_env=%!iO, this_binding=%!T\",\n\t                     (duk_heaphdr *) outer_lex_env,\n\t                     (duk_heaphdr *) outer_var_env,\n\t                     duk_get_tval(ctx, -1)));\n\n\t/* [ env? source template closure this ] */\n\n\tduk_call_method(ctx, 0);\n\n\t/* [ env? source template result ] */\n\n\treturn 1;\n}\n\n/*\n *  Parsing of ints and floats\n */\n\n#if defined(DUK_USE_GLOBAL_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_global_object_parse_int(duk_context *ctx) {\n\tduk_int32_t radix;\n\tduk_small_uint_t s2n_flags;\n\n\tDUK_ASSERT_TOP(ctx, 2);\n\tduk_to_string(ctx, 0);  /* Reject symbols. */\n\n\tradix = duk_to_int32(ctx, 1);\n\n\t/* While parseInt() recognizes 0xdeadbeef, it doesn't recognize\n\t * ES2015 0o123 or 0b10001.\n\t */\n\ts2n_flags = DUK_S2N_FLAG_TRIM_WHITE |\n\t            DUK_S2N_FLAG_ALLOW_GARBAGE |\n\t            DUK_S2N_FLAG_ALLOW_PLUS |\n\t            DUK_S2N_FLAG_ALLOW_MINUS |\n\t            DUK_S2N_FLAG_ALLOW_LEADING_ZERO |\n\t            DUK_S2N_FLAG_ALLOW_AUTO_HEX_INT;\n\n\t/* Specification stripPrefix maps to DUK_S2N_FLAG_ALLOW_AUTO_HEX_INT.\n\t *\n\t * Don't autodetect octals (from leading zeroes), require user code to\n\t * provide an explicit radix 8 for parsing octal.  See write-up from Mozilla:\n\t * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt#ECMAScript_5_Removes_Octal_Interpretation\n\t */\n\n\tif (radix != 0) {\n\t\tif (radix < 2 || radix > 36) {\n\t\t\tgoto ret_nan;\n\t\t}\n\t\tif (radix != 16) {\n\t\t\ts2n_flags &= ~DUK_S2N_FLAG_ALLOW_AUTO_HEX_INT;\n\t\t}\n\t} else {\n\t\tradix = 10;\n\t}\n\n\tduk_dup_0(ctx);\n\tduk_numconv_parse(ctx, radix, s2n_flags);\n\treturn 1;\n\n ret_nan:\n\tduk_push_nan(ctx);\n\treturn 1;\n}\n#endif  /* DUK_USE_GLOBAL_BUILTIN */\n\n#if defined(DUK_USE_GLOBAL_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_global_object_parse_float(duk_context *ctx) {\n\tduk_small_uint_t s2n_flags;\n\tduk_int32_t radix;\n\n\tDUK_ASSERT_TOP(ctx, 1);\n\tduk_to_string(ctx, 0);  /* Reject symbols. */\n\n\tradix = 10;\n\n\t/* XXX: check flags */\n\ts2n_flags = DUK_S2N_FLAG_TRIM_WHITE |\n\t            DUK_S2N_FLAG_ALLOW_EXP |\n\t            DUK_S2N_FLAG_ALLOW_GARBAGE |\n\t            DUK_S2N_FLAG_ALLOW_PLUS |\n\t            DUK_S2N_FLAG_ALLOW_MINUS |\n\t            DUK_S2N_FLAG_ALLOW_INF |\n\t            DUK_S2N_FLAG_ALLOW_FRAC |\n\t            DUK_S2N_FLAG_ALLOW_NAKED_FRAC |\n\t            DUK_S2N_FLAG_ALLOW_EMPTY_FRAC |\n\t            DUK_S2N_FLAG_ALLOW_LEADING_ZERO;\n\n\tduk_numconv_parse(ctx, radix, s2n_flags);\n\treturn 1;\n}\n#endif  /* DUK_USE_GLOBAL_BUILTIN */\n\n/*\n *  Number checkers\n */\n\n#if defined(DUK_USE_GLOBAL_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_global_object_is_nan(duk_context *ctx) {\n\tduk_double_t d = duk_to_number(ctx, 0);\n\tduk_push_boolean(ctx, DUK_ISNAN(d));\n\treturn 1;\n}\n#endif  /* DUK_USE_GLOBAL_BUILTIN */\n\n#if defined(DUK_USE_GLOBAL_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_global_object_is_finite(duk_context *ctx) {\n\tduk_double_t d = duk_to_number(ctx, 0);\n\tduk_push_boolean(ctx, DUK_ISFINITE(d));\n\treturn 1;\n}\n#endif  /* DUK_USE_GLOBAL_BUILTIN */\n\n/*\n *  URI handling\n */\n\n#if defined(DUK_USE_GLOBAL_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_global_object_decode_uri(duk_context *ctx) {\n\treturn duk__transform_helper(ctx, duk__transform_callback_decode_uri, (const void *) duk__decode_uri_reserved_table);\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_global_object_decode_uri_component(duk_context *ctx) {\n\treturn duk__transform_helper(ctx, duk__transform_callback_decode_uri, (const void *) duk__decode_uri_component_reserved_table);\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_global_object_encode_uri(duk_context *ctx) {\n\treturn duk__transform_helper(ctx, duk__transform_callback_encode_uri, (const void *) duk__encode_uriunescaped_table);\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_global_object_encode_uri_component(duk_context *ctx) {\n\treturn duk__transform_helper(ctx, duk__transform_callback_encode_uri, (const void *) duk__encode_uricomponent_unescaped_table);\n}\n\n#if defined(DUK_USE_SECTION_B)\nDUK_INTERNAL duk_ret_t duk_bi_global_object_escape(duk_context *ctx) {\n\treturn duk__transform_helper(ctx, duk__transform_callback_escape, (const void *) NULL);\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_global_object_unescape(duk_context *ctx) {\n\treturn duk__transform_helper(ctx, duk__transform_callback_unescape, (const void *) NULL);\n}\n#endif  /* DUK_USE_SECTION_B */\n#endif  /* DUK_USE_GLOBAL_BUILTIN */\n\n/* automatic undefs */\n#undef DUK__CHECK_BITMASK\n#undef DUK__MKBITS\n/*\n *  JSON built-ins.\n *\n *  See doc/json.rst.\n *\n *  Codepoints are handled as duk_uint_fast32_t to ensure that the full\n *  unsigned 32-bit range is supported.  This matters to e.g. JX.\n *\n *  Input parsing doesn't do an explicit end-of-input check at all.  This is\n *  safe: input string data is always NUL-terminated (0x00) and valid JSON\n *  inputs never contain plain NUL characters, so that as long as syntax checks\n *  are correct, we'll never read past the NUL.  This approach reduces code size\n *  and improves parsing performance, but it's critical that syntax checks are\n *  indeed correct!\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_JSON_SUPPORT)\n\n/*\n *  Local defines and forward declarations.\n */\n\n#define DUK__JSON_DECSTR_BUFSIZE 128\n#define DUK__JSON_DECSTR_CHUNKSIZE 64\n#define DUK__JSON_ENCSTR_CHUNKSIZE 64\n#define DUK__JSON_STRINGIFY_BUFSIZE 128\n#define DUK__JSON_MAX_ESC_LEN 10  /* '\\Udeadbeef' */\n\nDUK_LOCAL_DECL void duk__dec_syntax_error(duk_json_dec_ctx *js_ctx);\nDUK_LOCAL_DECL void duk__dec_eat_white(duk_json_dec_ctx *js_ctx);\n#if defined(DUK_USE_JX)\nDUK_LOCAL_DECL duk_uint8_t duk__dec_peek(duk_json_dec_ctx *js_ctx);\n#endif\nDUK_LOCAL_DECL duk_uint8_t duk__dec_get(duk_json_dec_ctx *js_ctx);\nDUK_LOCAL_DECL duk_uint8_t duk__dec_get_nonwhite(duk_json_dec_ctx *js_ctx);\nDUK_LOCAL_DECL duk_uint_fast32_t duk__dec_decode_hex_escape(duk_json_dec_ctx *js_ctx, duk_small_uint_t n);\nDUK_LOCAL_DECL void duk__dec_req_stridx(duk_json_dec_ctx *js_ctx, duk_small_uint_t stridx);\nDUK_LOCAL_DECL void duk__dec_string(duk_json_dec_ctx *js_ctx);\n#if defined(DUK_USE_JX)\nDUK_LOCAL_DECL void duk__dec_plain_string(duk_json_dec_ctx *js_ctx);\nDUK_LOCAL_DECL void duk__dec_pointer(duk_json_dec_ctx *js_ctx);\nDUK_LOCAL_DECL void duk__dec_buffer(duk_json_dec_ctx *js_ctx);\n#endif\nDUK_LOCAL_DECL void duk__dec_number(duk_json_dec_ctx *js_ctx);\nDUK_LOCAL_DECL void duk__dec_objarr_entry(duk_json_dec_ctx *js_ctx);\nDUK_LOCAL_DECL void duk__dec_objarr_exit(duk_json_dec_ctx *js_ctx);\nDUK_LOCAL_DECL void duk__dec_object(duk_json_dec_ctx *js_ctx);\nDUK_LOCAL_DECL void duk__dec_array(duk_json_dec_ctx *js_ctx);\nDUK_LOCAL_DECL void duk__dec_value(duk_json_dec_ctx *js_ctx);\nDUK_LOCAL_DECL void duk__dec_reviver_walk(duk_json_dec_ctx *js_ctx);\n\nDUK_LOCAL_DECL void duk__emit_1(duk_json_enc_ctx *js_ctx, duk_uint_fast8_t ch);\nDUK_LOCAL_DECL void duk__emit_2(duk_json_enc_ctx *js_ctx, duk_uint_fast8_t ch1, duk_uint_fast8_t ch2);\nDUK_LOCAL_DECL void duk__unemit_1(duk_json_enc_ctx *js_ctx);\nDUK_LOCAL_DECL void duk__emit_hstring(duk_json_enc_ctx *js_ctx, duk_hstring *h);\n#if defined(DUK_USE_FASTINT)\nDUK_LOCAL_DECL void duk__emit_cstring(duk_json_enc_ctx *js_ctx, const char *p);\n#endif\nDUK_LOCAL_DECL void duk__emit_stridx(duk_json_enc_ctx *js_ctx, duk_small_uint_t stridx);\nDUK_LOCAL_DECL duk_uint8_t *duk__emit_esc_auto_fast(duk_json_enc_ctx *js_ctx, duk_uint_fast32_t cp, duk_uint8_t *q);\nDUK_LOCAL_DECL void duk__enc_key_autoquote(duk_json_enc_ctx *js_ctx, duk_hstring *k);\nDUK_LOCAL_DECL void duk__enc_quote_string(duk_json_enc_ctx *js_ctx, duk_hstring *h_str);\nDUK_LOCAL_DECL void duk__enc_objarr_entry(duk_json_enc_ctx *js_ctx, duk_idx_t *entry_top);\nDUK_LOCAL_DECL void duk__enc_objarr_exit(duk_json_enc_ctx *js_ctx, duk_idx_t *entry_top);\nDUK_LOCAL_DECL void duk__enc_object(duk_json_enc_ctx *js_ctx);\nDUK_LOCAL_DECL void duk__enc_array(duk_json_enc_ctx *js_ctx);\nDUK_LOCAL_DECL duk_bool_t duk__enc_value(duk_json_enc_ctx *js_ctx, duk_idx_t idx_holder);\nDUK_LOCAL_DECL duk_bool_t duk__enc_allow_into_proplist(duk_tval *tv);\nDUK_LOCAL_DECL void duk__enc_double(duk_json_enc_ctx *js_ctx);\n#if defined(DUK_USE_FASTINT)\nDUK_LOCAL_DECL void duk__enc_fastint_tval(duk_json_enc_ctx *js_ctx, duk_tval *tv);\n#endif\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\nDUK_LOCAL_DECL void duk__enc_buffer_jx_jc(duk_json_enc_ctx *js_ctx, duk_hbuffer *h);\nDUK_LOCAL_DECL void duk__enc_pointer(duk_json_enc_ctx *js_ctx, void *ptr);\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_LOCAL_DECL void duk__enc_bufobj(duk_json_enc_ctx *js_ctx, duk_hbufobj *h_bufobj);\n#endif\n#endif\n#if defined(DUK_USE_JSON_STRINGIFY_FASTPATH)\nDUK_LOCAL_DECL void duk__enc_buffer_json_fastpath(duk_json_enc_ctx *js_ctx, duk_hbuffer *h);\n#endif\nDUK_LOCAL_DECL void duk__enc_newline_indent(duk_json_enc_ctx *js_ctx, duk_int_t depth);\n\n/*\n *  Helper tables\n */\n\n#if defined(DUK_USE_JSON_QUOTESTRING_FASTPATH)\nDUK_LOCAL const duk_uint8_t duk__json_quotestr_lookup[256] = {\n\t/* 0x00 ... 0x7f: as is\n\t * 0x80: escape generically\n\t * 0x81: slow path\n\t * 0xa0 ... 0xff: backslash + one char\n\t */\n\n\t0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xe2, 0xf4, 0xee, 0x80, 0xe6, 0xf2, 0x80, 0x80,\n\t0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,\n\t0x20, 0x21, 0xa2, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,\n\t0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,\n\t0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,\n\t0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0xdc, 0x5d, 0x5e, 0x5f,\n\t0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,\n\t0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x81,\n\t0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,\n\t0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,\n\t0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,\n\t0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,\n\t0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,\n\t0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,\n\t0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81,\n\t0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81\n};\n#else  /* DUK_USE_JSON_QUOTESTRING_FASTPATH */\nDUK_LOCAL const duk_uint8_t duk__json_quotestr_esc[14] = {\n\tDUK_ASC_NUL, DUK_ASC_NUL, DUK_ASC_NUL, DUK_ASC_NUL,\n\tDUK_ASC_NUL, DUK_ASC_NUL, DUK_ASC_NUL, DUK_ASC_NUL,\n\tDUK_ASC_LC_B, DUK_ASC_LC_T, DUK_ASC_LC_N, DUK_ASC_NUL,\n\tDUK_ASC_LC_F, DUK_ASC_LC_R\n};\n#endif  /* DUK_USE_JSON_QUOTESTRING_FASTPATH */\n\n#if defined(DUK_USE_JSON_DECSTRING_FASTPATH)\nDUK_LOCAL const duk_uint8_t duk__json_decstr_lookup[256] = {\n\t/* 0x00: slow path\n\t * other: as is\n\t */\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x20, 0x21, 0x00, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,\n\t0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,\n\t0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,\n\t0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x00, 0x5d, 0x5e, 0x5f,\n\t0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,\n\t0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,\n\t0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,\n\t0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,\n\t0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,\n\t0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,\n\t0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,\n\t0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,\n\t0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,\n\t0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff\n};\n#endif  /* DUK_USE_JSON_DECSTRING_FASTPATH */\n\n#if defined(DUK_USE_JSON_EATWHITE_FASTPATH)\nDUK_LOCAL const duk_uint8_t duk__json_eatwhite_lookup[256] = {\n\t/* 0x00: finish (non-white)\n\t * 0x01: continue\n\t */\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\n};\n#endif  /* DUK_USE_JSON_EATWHITE_FASTPATH */\n\n#if defined(DUK_USE_JSON_DECNUMBER_FASTPATH)\nDUK_LOCAL const duk_uint8_t duk__json_decnumber_lookup[256] = {\n\t/* 0x00: finish (not part of number)\n\t * 0x01: continue\n\t */\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x00,\n\t0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n\t0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00\n};\n#endif  /* DUK_USE_JSON_DECNUMBER_FASTPATH */\n\n/*\n *  Parsing implementation.\n *\n *  JSON lexer is now separate from duk_lexer.c because there are numerous\n *  small differences making it difficult to share the lexer.\n *\n *  The parser here works with raw bytes directly; this works because all\n *  JSON delimiters are ASCII characters.  Invalid xUTF-8 encoded values\n *  inside strings will be passed on without normalization; this is not a\n *  compliance concern because compliant inputs will always be valid\n *  CESU-8 encodings.\n */\n\nDUK_LOCAL void duk__dec_syntax_error(duk_json_dec_ctx *js_ctx) {\n\t/* Shared handler to minimize parser size.  Cause will be\n\t * hidden, unfortunately, but we'll have an offset which\n\t * is often quite enough.\n\t */\n\tDUK_ERROR_FMT1(js_ctx->thr, DUK_ERR_SYNTAX_ERROR, DUK_STR_FMT_INVALID_JSON,\n\t               (long) (js_ctx->p - js_ctx->p_start));\n}\n\nDUK_LOCAL void duk__dec_eat_white(duk_json_dec_ctx *js_ctx) {\n\tconst duk_uint8_t *p;\n\tduk_uint8_t t;\n\n\tp = js_ctx->p;\n\tfor (;;) {\n\t\tDUK_ASSERT(p <= js_ctx->p_end);\n\t\tt = *p;\n\n#if defined(DUK_USE_JSON_EATWHITE_FASTPATH)\n\t\t/* This fast path is pretty marginal in practice.\n\t\t * XXX: candidate for removal.\n\t\t */\n\t\tDUK_ASSERT(duk__json_eatwhite_lookup[0x00] == 0x00);  /* end-of-input breaks */\n\t\tif (duk__json_eatwhite_lookup[t] == 0) {\n\t\t\tbreak;\n\t\t}\n#else  /* DUK_USE_JSON_EATWHITE_FASTPATH */\n\t\tif (!(t == 0x20 || t == 0x0a || t == 0x0d || t == 0x09)) {\n\t\t\t/* NUL also comes here.  Comparison order matters, 0x20\n\t\t\t * is most common whitespace.\n\t\t\t */\n\t\t\tbreak;\n\t\t}\n#endif  /* DUK_USE_JSON_EATWHITE_FASTPATH */\n\t\tp++;\n\t}\n\tjs_ctx->p = p;\n}\n\n#if defined(DUK_USE_JX)\nDUK_LOCAL duk_uint8_t duk__dec_peek(duk_json_dec_ctx *js_ctx) {\n\tDUK_ASSERT(js_ctx->p <= js_ctx->p_end);\n\treturn *js_ctx->p;\n}\n#endif\n\nDUK_LOCAL duk_uint8_t duk__dec_get(duk_json_dec_ctx *js_ctx) {\n\tDUK_ASSERT(js_ctx->p <= js_ctx->p_end);\n\treturn *js_ctx->p++;\n}\n\nDUK_LOCAL duk_uint8_t duk__dec_get_nonwhite(duk_json_dec_ctx *js_ctx) {\n\tduk__dec_eat_white(js_ctx);\n\treturn duk__dec_get(js_ctx);\n}\n\n/* For JX, expressing the whole unsigned 32-bit range matters. */\nDUK_LOCAL duk_uint_fast32_t duk__dec_decode_hex_escape(duk_json_dec_ctx *js_ctx, duk_small_uint_t n) {\n\tduk_small_uint_t i;\n\tduk_uint_fast32_t res = 0;\n\tduk_uint8_t x;\n\tduk_small_int_t t;\n\n\tfor (i = 0; i < n; i++) {\n\t\t/* XXX: share helper from lexer; duk_lexer.c / hexval(). */\n\n\t\tx = duk__dec_get(js_ctx);\n\t\tDUK_DDD(DUK_DDDPRINT(\"decode_hex_escape: i=%ld, n=%ld, res=%ld, x=%ld\",\n\t\t                     (long) i, (long) n, (long) res, (long) x));\n\n\t\t/* x == 0x00 (EOF) causes syntax_error */\n\t\tDUK_ASSERT(duk_hex_dectab[0] == -1);\n\t\tt = duk_hex_dectab[x & 0xff];\n\t\tif (DUK_LIKELY(t >= 0)) {\n\t\t\tres = (res * 16) + t;\n\t\t} else {\n\t\t\t/* catches EOF and invalid digits */\n\t\t\tgoto syntax_error;\n\t\t}\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"final hex decoded value: %ld\", (long) res));\n\treturn res;\n\n syntax_error:\n\tduk__dec_syntax_error(js_ctx);\n\tDUK_UNREACHABLE();\n\treturn 0;\n}\n\nDUK_LOCAL void duk__dec_req_stridx(duk_json_dec_ctx *js_ctx, duk_small_uint_t stridx) {\n\tduk_hstring *h;\n\tconst duk_uint8_t *p;\n\tduk_uint8_t x, y;\n\n\t/* First character has already been eaten and checked by the caller.\n\t * We can scan until a NUL in stridx string because no built-in strings\n\t * have internal NULs.\n\t */\n\n\tDUK_ASSERT_STRIDX_VALID(stridx);\n\th = DUK_HTHREAD_GET_STRING(js_ctx->thr, stridx);\n\tDUK_ASSERT(h != NULL);\n\n\tp = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h) + 1;\n\tDUK_ASSERT(*(js_ctx->p - 1) == *(p - 1));  /* first character has been matched */\n\n\tfor (;;) {\n\t\tx = *p;\n\t\tif (x == 0) {\n\t\t\tbreak;\n\t\t}\n\t\ty = duk__dec_get(js_ctx);\n\t\tif (x != y) {\n\t\t\t/* Catches EOF of JSON input. */\n\t\t\tgoto syntax_error;\n\t\t}\n\t\tp++;\n\t}\n\n\treturn;\n\n syntax_error:\n\tduk__dec_syntax_error(js_ctx);\n\tDUK_UNREACHABLE();\n}\n\nDUK_LOCAL duk_small_int_t duk__dec_string_escape(duk_json_dec_ctx *js_ctx, duk_uint8_t **ext_p) {\n\tduk_uint_fast32_t cp;\n\n\t/* EOF (-1) will be cast to an unsigned value first\n\t * and then re-cast for the switch.  In any case, it\n\t * will match the default case (syntax error).\n\t */\n\tcp = (duk_uint_fast32_t) duk__dec_get(js_ctx);\n\tswitch (cp) {\n\tcase DUK_ASC_BACKSLASH: break;\n\tcase DUK_ASC_DOUBLEQUOTE: break;\n\tcase DUK_ASC_SLASH: break;\n\tcase DUK_ASC_LC_T: cp = 0x09; break;\n\tcase DUK_ASC_LC_N: cp = 0x0a; break;\n\tcase DUK_ASC_LC_R: cp = 0x0d; break;\n\tcase DUK_ASC_LC_F: cp = 0x0c; break;\n\tcase DUK_ASC_LC_B: cp = 0x08; break;\n\tcase DUK_ASC_LC_U: {\n\t\tcp = duk__dec_decode_hex_escape(js_ctx, 4);\n\t\tbreak;\n\t}\n#if defined(DUK_USE_JX)\n\tcase DUK_ASC_UC_U: {\n\t\tif (js_ctx->flag_ext_custom) {\n\t\t\tcp = duk__dec_decode_hex_escape(js_ctx, 8);\n\t\t} else {\n\t\t\treturn 1;  /* syntax error */\n\t\t}\n\t\tbreak;\n\t}\n\tcase DUK_ASC_LC_X: {\n\t\tif (js_ctx->flag_ext_custom) {\n\t\t\tcp = duk__dec_decode_hex_escape(js_ctx, 2);\n\t\t} else {\n\t\t\treturn 1;  /* syntax error */\n\t\t}\n\t\tbreak;\n\t}\n#endif  /* DUK_USE_JX */\n\tdefault:\n\t\t/* catches EOF (0x00) */\n\t\treturn 1;  /* syntax error */\n\t}\n\n\tDUK_RAW_WRITE_XUTF8(*ext_p, cp);\n\n\treturn 0;\n}\n\nDUK_LOCAL void duk__dec_string(duk_json_dec_ctx *js_ctx) {\n\tduk_hthread *thr = js_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_bufwriter_ctx bw_alloc;\n\tduk_bufwriter_ctx *bw;\n\tduk_uint8_t *q;\n\n\t/* '\"' was eaten by caller */\n\n\t/* Note that we currently parse -bytes-, not codepoints.\n\t * All non-ASCII extended UTF-8 will encode to bytes >= 0x80,\n\t * so they'll simply pass through (valid UTF-8 or not).\n\t */\n\n\tbw = &bw_alloc;\n\tDUK_BW_INIT_PUSHBUF(js_ctx->thr, bw, DUK__JSON_DECSTR_BUFSIZE);\n\tq = DUK_BW_GET_PTR(js_ctx->thr, bw);\n\n#if defined(DUK_USE_JSON_DECSTRING_FASTPATH)\n\tfor (;;) {\n\t\tduk_small_uint_t safe;\n\t\tduk_uint8_t b, x;\n\t\tconst duk_uint8_t *p;\n\n\t\t/* Select a safe loop count where no output checks are\n\t\t * needed assuming we won't encounter escapes.  Input\n\t\t * bound checks are not necessary as a NUL (guaranteed)\n\t\t * will cause a SyntaxError before we read out of bounds.\n\t\t */\n\n\t\tsafe = DUK__JSON_DECSTR_CHUNKSIZE;\n\n\t\t/* Ensure space for 1:1 output plus one escape. */\n\t\tq = DUK_BW_ENSURE_RAW(js_ctx->thr, bw, safe + DUK_UNICODE_MAX_XUTF8_LENGTH, q);\n\n\t\tp = js_ctx->p;  /* temp copy, write back for next loop */\n\t\tfor (;;) {\n\t\t\tif (safe == 0) {\n\t\t\t\tjs_ctx->p = p;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tsafe--;\n\n\t\t\t/* End of input (NUL) goes through slow path and causes SyntaxError. */\n\t\t\tDUK_ASSERT(duk__json_decstr_lookup[0] == 0x00);\n\n\t\t\tb = *p++;\n\t\t\tx = (duk_small_int_t) duk__json_decstr_lookup[b];\n\t\t\tif (DUK_LIKELY(x != 0)) {\n\t\t\t\t/* Fast path, decode as is. */\n\t\t\t\t*q++ = b;\n\t\t\t} else if (b == DUK_ASC_DOUBLEQUOTE) {\n\t\t\t\tjs_ctx->p = p;\n\t\t\t\tgoto found_quote;\n\t\t\t} else if (b == DUK_ASC_BACKSLASH) {\n\t\t\t\t/* We've ensured space for one escaped input; then\n\t\t\t\t * bail out and recheck (this makes escape handling\n\t\t\t\t * quite slow but it's uncommon).\n\t\t\t\t */\n\t\t\t\tjs_ctx->p = p;\n\t\t\t\tif (duk__dec_string_escape(js_ctx, &q) != 0) {\n\t\t\t\t\tgoto syntax_error;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tjs_ctx->p = p;\n\t\t\t\tgoto syntax_error;\n\t\t\t}\n\t\t}\n\t}\n found_quote:\n#else  /* DUK_USE_JSON_DECSTRING_FASTPATH */\n\tfor (;;) {\n\t\tduk_uint8_t x;\n\n\t\tq = DUK_BW_ENSURE_RAW(js_ctx->thr, bw, DUK_UNICODE_MAX_XUTF8_LENGTH, q);\n\n\t\tx = duk__dec_get(js_ctx);\n\n\t\tif (x == DUK_ASC_DOUBLEQUOTE) {\n\t\t\tbreak;\n\t\t} else if (x == DUK_ASC_BACKSLASH) {\n\t\t\tif (duk__dec_string_escape(js_ctx, &q) != 0) {\n\t\t\t\tgoto syntax_error;\n\t\t\t}\n\t\t} else if (x < 0x20) {\n\t\t\t/* catches EOF (NUL) */\n\t\t\tgoto syntax_error;\n\t\t} else {\n\t\t\t*q++ = (duk_uint8_t) x;\n\t\t}\n\t}\n#endif  /* DUK_USE_JSON_DECSTRING_FASTPATH */\n\n\tDUK_BW_SETPTR_AND_COMPACT(js_ctx->thr, bw, q);\n\t(void) duk_buffer_to_string(ctx, -1);  /* Safe if input string is safe. */\n\n\t/* [ ... str ] */\n\n\treturn;\n\n syntax_error:\n\tduk__dec_syntax_error(js_ctx);\n\tDUK_UNREACHABLE();\n}\n\n#if defined(DUK_USE_JX)\n/* Decode a plain string consisting entirely of identifier characters.\n * Used to parse plain keys (e.g. \"foo: 123\").\n */\nDUK_LOCAL void duk__dec_plain_string(duk_json_dec_ctx *js_ctx) {\n\tduk_hthread *thr = js_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tconst duk_uint8_t *p;\n\tduk_small_int_t x;\n\n\t/* Caller has already eaten the first char so backtrack one byte. */\n\n\tjs_ctx->p--;  /* safe */\n\tp = js_ctx->p;\n\n\t/* Here again we parse bytes, and non-ASCII UTF-8 will cause end of\n\t * parsing (which is correct except if there are non-shortest encodings).\n\t * There is also no need to check explicitly for end of input buffer as\n\t * the input is NUL padded and NUL will exit the parsing loop.\n\t *\n\t * Because no unescaping takes place, we can just scan to the end of the\n\t * plain string and intern from the input buffer.\n\t */\n\n\tfor (;;) {\n\t\tx = *p;\n\n\t\t/* There is no need to check the first character specially here\n\t\t * (i.e. reject digits): the caller only accepts valid initial\n\t\t * characters and won't call us if the first character is a digit.\n\t\t * This also ensures that the plain string won't be empty.\n\t\t */\n\n\t\tif (!duk_unicode_is_identifier_part((duk_codepoint_t) x)) {\n\t\t\tbreak;\n\t\t}\n\t\tp++;\n\t}\n\n\tduk_push_lstring(ctx, (const char *) js_ctx->p, (duk_size_t) (p - js_ctx->p));\n\tjs_ctx->p = p;\n\n\t/* [ ... str ] */\n}\n#endif  /* DUK_USE_JX */\n\n#if defined(DUK_USE_JX)\nDUK_LOCAL void duk__dec_pointer(duk_json_dec_ctx *js_ctx) {\n\tduk_hthread *thr = js_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tconst duk_uint8_t *p;\n\tduk_small_int_t x;\n\tvoid *voidptr;\n\n\t/* Caller has already eaten the first character ('(') which we don't need. */\n\n\tp = js_ctx->p;\n\n\tfor (;;) {\n\t\tx = *p;\n\n\t\t/* Assume that the native representation never contains a closing\n\t\t * parenthesis.\n\t\t */\n\n\t\tif (x == DUK_ASC_RPAREN) {\n\t\t\tbreak;\n\t\t} else if (x <= 0) {\n\t\t\t/* NUL term or -1 (EOF), NUL check would suffice */\n\t\t\tgoto syntax_error;\n\t\t}\n\t\tp++;\n\t}\n\n\t/* There is no need to NUL delimit the sscanf() call: trailing garbage is\n\t * ignored and there is always a NUL terminator which will force an error\n\t * if no error is encountered before it.  It's possible that the scan\n\t * would scan further than between [js_ctx->p,p[ though and we'd advance\n\t * by less than the scanned value.\n\t *\n\t * Because pointers are platform specific, a failure to scan a pointer\n\t * results in a null pointer which is a better placeholder than a missing\n\t * value or an error.\n\t */\n\n\tvoidptr = NULL;\n\t(void) DUK_SSCANF((const char *) js_ctx->p, DUK_STR_FMT_PTR, &voidptr);\n\tduk_push_pointer(ctx, voidptr);\n\tjs_ctx->p = p + 1;  /* skip ')' */\n\n\t/* [ ... ptr ] */\n\n\treturn;\n\n syntax_error:\n\tduk__dec_syntax_error(js_ctx);\n\tDUK_UNREACHABLE();\n}\n#endif  /* DUK_USE_JX */\n\n#if defined(DUK_USE_JX)\nDUK_LOCAL void duk__dec_buffer(duk_json_dec_ctx *js_ctx) {\n\tduk_hthread *thr = js_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tconst duk_uint8_t *p;\n\tduk_uint8_t *buf;\n\tduk_size_t src_len;\n\tduk_small_int_t x;\n\n\t/* Caller has already eaten the first character ('|') which we don't need. */\n\n\tp = js_ctx->p;\n\n\t/* XXX: Would be nice to share the fast path loop from duk_hex_decode()\n\t * and avoid creating a temporary buffer.  However, there are some\n\t * differences which prevent trivial sharing:\n\t *\n\t *   - Pipe char detection\n\t *   - EOF detection\n\t *   - Unknown length of input and output\n\t *\n\t * The best approach here would be a bufwriter and a reasonaly sized\n\t * safe inner loop (e.g. 64 output bytes at a time).\n\t */\n\n\tfor (;;) {\n\t\tx = *p;\n\n\t\t/* This loop intentionally does not ensure characters are valid\n\t\t * ([0-9a-fA-F]) because the hex decode call below will do that.\n\t\t */\n\t\tif (x == DUK_ASC_PIPE) {\n\t\t\tbreak;\n\t\t} else if (x <= 0) {\n\t\t\t/* NUL term or -1 (EOF), NUL check would suffice */\n\t\t\tgoto syntax_error;\n\t\t}\n\t\tp++;\n\t}\n\n\t/* XXX: this is not very nice; unnecessary copy is made. */\n\tsrc_len = (duk_size_t) (p - js_ctx->p);\n\tbuf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(ctx, src_len);\n\tDUK_ASSERT(buf != NULL);\n\tDUK_MEMCPY((void *) buf, (const void *) js_ctx->p, src_len);\n\tduk_hex_decode(ctx, -1);\n\n\tjs_ctx->p = p + 1;  /* skip '|' */\n\n\t/* [ ... buf ] */\n\n\treturn;\n\n syntax_error:\n\tduk__dec_syntax_error(js_ctx);\n\tDUK_UNREACHABLE();\n}\n#endif  /* DUK_USE_JX */\n\n/* Parse a number, other than NaN or +/- Infinity */\nDUK_LOCAL void duk__dec_number(duk_json_dec_ctx *js_ctx) {\n\tduk_context *ctx = (duk_context *) js_ctx->thr;\n\tconst duk_uint8_t *p_start;\n\tconst duk_uint8_t *p;\n\tduk_uint8_t x;\n\tduk_small_uint_t s2n_flags;\n\n\tDUK_DDD(DUK_DDDPRINT(\"parse_number\"));\n\n\tp_start = js_ctx->p;\n\n\t/* First pass parse is very lenient (e.g. allows '1.2.3') and extracts a\n\t * string for strict number parsing.\n\t */\n\n\tp = js_ctx->p;\n\tfor (;;) {\n\t\tx = *p;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"parse_number: p_start=%p, p=%p, p_end=%p, x=%ld\",\n\t\t                     (const void *) p_start, (const void *) p,\n\t\t                     (const void *) js_ctx->p_end, (long) x));\n\n#if defined(DUK_USE_JSON_DECNUMBER_FASTPATH)\n\t\t/* This fast path is pretty marginal in practice.\n\t\t * XXX: candidate for removal.\n\t\t */\n\t\tDUK_ASSERT(duk__json_decnumber_lookup[0x00] == 0x00);  /* end-of-input breaks */\n\t\tif (duk__json_decnumber_lookup[x] == 0) {\n\t\t\tbreak;\n\t\t}\n#else  /* DUK_USE_JSON_DECNUMBER_FASTPATH */\n\t\tif (!((x >= DUK_ASC_0 && x <= DUK_ASC_9) ||\n\t\t      (x == DUK_ASC_PERIOD || x == DUK_ASC_LC_E ||\n\t\t       x == DUK_ASC_UC_E || x == DUK_ASC_MINUS || x == DUK_ASC_PLUS))) {\n\t\t\t/* Plus sign must be accepted for positive exponents\n\t\t\t * (e.g. '1.5e+2').  This clause catches NULs.\n\t\t\t */\n\t\t\tbreak;\n\t\t}\n#endif  /* DUK_USE_JSON_DECNUMBER_FASTPATH */\n\t\tp++;  /* safe, because matched (NUL causes a break) */\n\t}\n\tjs_ctx->p = p;\n\n\tDUK_ASSERT(js_ctx->p > p_start);\n\tduk_push_lstring(ctx, (const char *) p_start, (duk_size_t) (p - p_start));\n\n\ts2n_flags = DUK_S2N_FLAG_ALLOW_EXP |\n\t            DUK_S2N_FLAG_ALLOW_MINUS |  /* but don't allow leading plus */\n\t            DUK_S2N_FLAG_ALLOW_FRAC;\n\n\tDUK_DDD(DUK_DDDPRINT(\"parse_number: string before parsing: %!T\",\n\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\tduk_numconv_parse(ctx, 10 /*radix*/, s2n_flags);\n\tif (duk_is_nan(ctx, -1)) {\n\t\tduk__dec_syntax_error(js_ctx);\n\t}\n\tDUK_ASSERT(duk_is_number(ctx, -1));\n\tDUK_DDD(DUK_DDDPRINT(\"parse_number: final number: %!T\",\n\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\n\t/* [ ... num ] */\n}\n\nDUK_LOCAL void duk__dec_objarr_entry(duk_json_dec_ctx *js_ctx) {\n\tduk_context *ctx = (duk_context *) js_ctx->thr;\n\tduk_require_stack(ctx, DUK_JSON_DEC_REQSTACK);\n\n\t/* c recursion check */\n\n\tDUK_ASSERT(js_ctx->recursion_depth >= 0);\n\tDUK_ASSERT(js_ctx->recursion_depth <= js_ctx->recursion_limit);\n\tif (js_ctx->recursion_depth >= js_ctx->recursion_limit) {\n\t\tDUK_ERROR_RANGE((duk_hthread *) ctx, DUK_STR_JSONDEC_RECLIMIT);\n\t}\n\tjs_ctx->recursion_depth++;\n}\n\nDUK_LOCAL void duk__dec_objarr_exit(duk_json_dec_ctx *js_ctx) {\n\t/* c recursion check */\n\n\tDUK_ASSERT(js_ctx->recursion_depth > 0);\n\tDUK_ASSERT(js_ctx->recursion_depth <= js_ctx->recursion_limit);\n\tjs_ctx->recursion_depth--;\n}\n\nDUK_LOCAL void duk__dec_object(duk_json_dec_ctx *js_ctx) {\n\tduk_context *ctx = (duk_context *) js_ctx->thr;\n\tduk_int_t key_count;  /* XXX: a \"first\" flag would suffice */\n\tduk_uint8_t x;\n\n\tDUK_DDD(DUK_DDDPRINT(\"parse_object\"));\n\n\tduk__dec_objarr_entry(js_ctx);\n\n\tduk_push_object(ctx);\n\n\t/* Initial '{' has been checked and eaten by caller. */\n\n\tkey_count = 0;\n\tfor (;;) {\n\t\tx = duk__dec_get_nonwhite(js_ctx);\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"parse_object: obj=%!T, x=%ld, key_count=%ld\",\n\t\t                     (duk_tval *) duk_get_tval(ctx, -1),\n\t\t                     (long) x, (long) key_count));\n\n\t\t/* handle comma and closing brace */\n\n\t\tif (x == DUK_ASC_COMMA && key_count > 0) {\n\t\t\t/* accept comma, expect new value */\n\t\t\tx = duk__dec_get_nonwhite(js_ctx);\n\t\t} else if (x == DUK_ASC_RCURLY) {\n\t\t\t/* eat closing brace */\n\t\t\tbreak;\n\t\t} else if (key_count == 0) {\n\t\t\t/* accept anything, expect first value (EOF will be\n\t\t\t * caught by key parsing below.\n\t\t\t */\n\t\t\t;\n\t\t} else {\n\t\t\t/* catches EOF (NUL) and initial comma */\n\t\t\tgoto syntax_error;\n\t\t}\n\n\t\t/* parse key and value */\n\n\t\tif (x == DUK_ASC_DOUBLEQUOTE) {\n\t\t\tduk__dec_string(js_ctx);\n#if defined(DUK_USE_JX)\n\t\t} else if (js_ctx->flag_ext_custom &&\n\t\t           duk_unicode_is_identifier_start((duk_codepoint_t) x)) {\n\t\t\tduk__dec_plain_string(js_ctx);\n#endif\n\t\t} else {\n\t\t\tgoto syntax_error;\n\t\t}\n\n\t\t/* [ ... obj key ] */\n\n\t\tx = duk__dec_get_nonwhite(js_ctx);\n\t\tif (x != DUK_ASC_COLON) {\n\t\t\tgoto syntax_error;\n\t\t}\n\n\t\tduk__dec_value(js_ctx);\n\n\t\t/* [ ... obj key val ] */\n\n\t\tduk_xdef_prop_wec(ctx, -3);\n\n\t\t/* [ ... obj ] */\n\n\t\tkey_count++;\n\t}\n\n\t/* [ ... obj ] */\n\n\tDUK_DDD(DUK_DDDPRINT(\"parse_object: final object is %!T\",\n\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\n\tduk__dec_objarr_exit(js_ctx);\n\treturn;\n\n syntax_error:\n\tduk__dec_syntax_error(js_ctx);\n\tDUK_UNREACHABLE();\n}\n\nDUK_LOCAL void duk__dec_array(duk_json_dec_ctx *js_ctx) {\n\tduk_context *ctx = (duk_context *) js_ctx->thr;\n\tduk_uarridx_t arr_idx;\n\tduk_uint8_t x;\n\n\tDUK_DDD(DUK_DDDPRINT(\"parse_array\"));\n\n\tduk__dec_objarr_entry(js_ctx);\n\n\tduk_push_array(ctx);\n\n\t/* Initial '[' has been checked and eaten by caller. */\n\n\tarr_idx = 0;\n\tfor (;;) {\n\t\tx = duk__dec_get_nonwhite(js_ctx);\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"parse_array: arr=%!T, x=%ld, arr_idx=%ld\",\n\t\t                     (duk_tval *) duk_get_tval(ctx, -1),\n\t\t                     (long) x, (long) arr_idx));\n\n\t\t/* handle comma and closing bracket */\n\n\t\tif ((x == DUK_ASC_COMMA) && (arr_idx != 0)) {\n\t\t\t/* accept comma, expect new value */\n\t\t\t;\n\t\t} else if (x == DUK_ASC_RBRACKET) {\n\t\t\t/* eat closing bracket */\n\t\t\tbreak;\n\t\t} else if (arr_idx == 0) {\n\t\t\t/* accept anything, expect first value (EOF will be\n\t\t\t * caught by duk__dec_value() below.\n\t\t\t */\n\t\t\tjs_ctx->p--;  /* backtrack (safe) */\n\t\t} else {\n\t\t\t/* catches EOF (NUL) and initial comma */\n\t\t\tgoto syntax_error;\n\t\t}\n\n\t\t/* parse value */\n\n\t\tduk__dec_value(js_ctx);\n\n\t\t/* [ ... arr val ] */\n\n\t\tduk_xdef_prop_index_wec(ctx, -2, arr_idx);\n\t\tarr_idx++;\n\t}\n\n\t/* Must set 'length' explicitly when using duk_xdef_prop_xxx() to\n\t * set the values.\n\t */\n\n\tduk_set_length(ctx, -1, arr_idx);\n\n\t/* [ ... arr ] */\n\n\tDUK_DDD(DUK_DDDPRINT(\"parse_array: final array is %!T\",\n\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\n\tduk__dec_objarr_exit(js_ctx);\n\treturn;\n\n syntax_error:\n\tduk__dec_syntax_error(js_ctx);\n\tDUK_UNREACHABLE();\n}\n\nDUK_LOCAL void duk__dec_value(duk_json_dec_ctx *js_ctx) {\n\tduk_context *ctx = (duk_context *) js_ctx->thr;\n\tduk_uint8_t x;\n\n\tx = duk__dec_get_nonwhite(js_ctx);\n\n\tDUK_DDD(DUK_DDDPRINT(\"parse_value: initial x=%ld\", (long) x));\n\n\t/* Note: duk__dec_req_stridx() backtracks one char */\n\n\tif (x == DUK_ASC_DOUBLEQUOTE) {\n\t\tduk__dec_string(js_ctx);\n\t} else if ((x >= DUK_ASC_0 && x <= DUK_ASC_9) || (x == DUK_ASC_MINUS)) {\n#if defined(DUK_USE_JX)\n\t\tif (js_ctx->flag_ext_custom && x == DUK_ASC_MINUS && duk__dec_peek(js_ctx) == DUK_ASC_UC_I) {\n\t\t\tduk__dec_req_stridx(js_ctx, DUK_STRIDX_MINUS_INFINITY);  /* \"-Infinity\", '-' has been eaten */\n\t\t\tduk_push_number(ctx, -DUK_DOUBLE_INFINITY);\n\t\t} else {\n#else\n\t\t{  /* unconditional block */\n#endif\n\t\t\t/* We already ate 'x', so backup one byte. */\n\t\t\tjs_ctx->p--;  /* safe */\n\t\t\tduk__dec_number(js_ctx);\n\t\t}\n\t} else if (x == DUK_ASC_LC_T) {\n\t\tduk__dec_req_stridx(js_ctx, DUK_STRIDX_TRUE);\n\t\tduk_push_true(ctx);\n\t} else if (x == DUK_ASC_LC_F) {\n\t\tduk__dec_req_stridx(js_ctx, DUK_STRIDX_FALSE);\n\t\tduk_push_false(ctx);\n\t} else if (x == DUK_ASC_LC_N) {\n\t\tduk__dec_req_stridx(js_ctx, DUK_STRIDX_LC_NULL);\n\t\tduk_push_null(ctx);\n#if defined(DUK_USE_JX)\n\t} else if (js_ctx->flag_ext_custom && x == DUK_ASC_LC_U) {\n\t\tduk__dec_req_stridx(js_ctx, DUK_STRIDX_LC_UNDEFINED);\n\t\tduk_push_undefined(ctx);\n\t} else if (js_ctx->flag_ext_custom && x == DUK_ASC_UC_N) {\n\t\tduk__dec_req_stridx(js_ctx, DUK_STRIDX_NAN);\n\t\tduk_push_nan(ctx);\n\t} else if (js_ctx->flag_ext_custom && x == DUK_ASC_UC_I) {\n\t\tduk__dec_req_stridx(js_ctx, DUK_STRIDX_INFINITY);\n\t\tduk_push_number(ctx, DUK_DOUBLE_INFINITY);\n\t} else if (js_ctx->flag_ext_custom && x == DUK_ASC_LPAREN) {\n\t\tduk__dec_pointer(js_ctx);\n\t} else if (js_ctx->flag_ext_custom && x == DUK_ASC_PIPE) {\n\t\tduk__dec_buffer(js_ctx);\n#endif\n\t} else if (x == DUK_ASC_LCURLY) {\n\t\tduk__dec_object(js_ctx);\n\t} else if (x == DUK_ASC_LBRACKET) {\n\t\tduk__dec_array(js_ctx);\n\t} else {\n\t\t/* catches EOF (NUL) */\n\t\tgoto syntax_error;\n\t}\n\n\tduk__dec_eat_white(js_ctx);\n\n\t/* [ ... val ] */\n\treturn;\n\n syntax_error:\n\tduk__dec_syntax_error(js_ctx);\n\tDUK_UNREACHABLE();\n}\n\n/* Recursive value reviver, implements the Walk() algorithm.  No C recursion\n * check is done here because the initial parsing step will already ensure\n * there is a reasonable limit on C recursion depth and hence object depth.\n */\nDUK_LOCAL void duk__dec_reviver_walk(duk_json_dec_ctx *js_ctx) {\n\tduk_context *ctx = (duk_context *) js_ctx->thr;\n\tduk_hobject *h;\n\tduk_uarridx_t i, arr_len;\n\n\tDUK_DDD(DUK_DDDPRINT(\"walk: top=%ld, holder=%!T, name=%!T\",\n\t                     (long) duk_get_top(ctx),\n\t                     (duk_tval *) duk_get_tval(ctx, -2),\n\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\n\tduk_dup_top(ctx);\n\tduk_get_prop(ctx, -3);  /* -> [ ... holder name val ] */\n\n\th = duk_get_hobject(ctx, -1);\n\tif (h != NULL) {\n\t\tif (DUK_HOBJECT_GET_CLASS_NUMBER(h) == DUK_HOBJECT_CLASS_ARRAY) {\n\t\t\tarr_len = (duk_uarridx_t) duk_get_length(ctx, -1);\n\t\t\tfor (i = 0; i < arr_len; i++) {\n\t\t\t\t/* [ ... holder name val ] */\n\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"walk: array, top=%ld, i=%ld, arr_len=%ld, holder=%!T, name=%!T, val=%!T\",\n\t\t\t\t                     (long) duk_get_top(ctx), (long) i, (long) arr_len,\n\t\t\t\t                     (duk_tval *) duk_get_tval(ctx, -3), (duk_tval *) duk_get_tval(ctx, -2),\n\t\t\t\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\n\t\t\t\tduk_dup_top(ctx);\n\t\t\t\t(void) duk_push_uint_to_hstring(ctx, (duk_uint_t) i);  /* -> [ ... holder name val val ToString(i) ] */\n\t\t\t\tduk__dec_reviver_walk(js_ctx);  /* -> [ ... holder name val new_elem ] */\n\n\t\t\t\tif (duk_is_undefined(ctx, -1)) {\n\t\t\t\t\tduk_pop(ctx);\n\t\t\t\t\tduk_del_prop_index(ctx, -1, i);\n\t\t\t\t} else {\n\t\t\t\t\t/* XXX: duk_xdef_prop_index_wec() would be more appropriate\n\t\t\t\t\t * here but it currently makes some assumptions that might\n\t\t\t\t\t * not hold (e.g. that previous property is not an accessor).\n\t\t\t\t\t */\n\t\t\t\t\tduk_put_prop_index(ctx, -2, i);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t/* [ ... holder name val ] */\n\t\t\tduk_enum(ctx, -1, DUK_ENUM_OWN_PROPERTIES_ONLY /*flags*/);\n\t\t\twhile (duk_next(ctx, -1 /*enum_index*/, 0 /*get_value*/)) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"walk: object, top=%ld, holder=%!T, name=%!T, val=%!T, enum=%!iT, obj_key=%!T\",\n\t\t\t\t                     (long) duk_get_top(ctx), (duk_tval *) duk_get_tval(ctx, -5),\n\t\t\t\t                     (duk_tval *) duk_get_tval(ctx, -4), (duk_tval *) duk_get_tval(ctx, -3),\n\t\t\t\t                     (duk_tval *) duk_get_tval(ctx, -2), (duk_tval *) duk_get_tval(ctx, -1)));\n\n\t\t\t\t/* [ ... holder name val enum obj_key ] */\n\t\t\t\tduk_dup_m3(ctx);\n\t\t\t\tduk_dup_m2(ctx);\n\n\t\t\t\t/* [ ... holder name val enum obj_key val obj_key ] */\n\t\t\t\tduk__dec_reviver_walk(js_ctx);\n\n\t\t\t\t/* [ ... holder name val enum obj_key new_elem ] */\n\t\t\t\tif (duk_is_undefined(ctx, -1)) {\n\t\t\t\t\tduk_pop(ctx);\n\t\t\t\t\tduk_del_prop(ctx, -3);\n\t\t\t\t} else {\n\t\t\t\t\t/* XXX: duk_xdef_prop_index_wec() would be more appropriate\n\t\t\t\t\t * here but it currently makes some assumptions that might\n\t\t\t\t\t * not hold (e.g. that previous property is not an accessor).\n\t\t\t\t\t *\n\t\t\t\t\t * Using duk_put_prop() works incorrectly with '__proto__'\n\t\t\t\t\t * if the own property with that name has been deleted.  This\n\t\t\t\t\t * does not happen normally, but a clever reviver can trigger\n\t\t\t\t\t * that, see complex reviver case in: test-bug-json-parse-__proto__.js.\n\t\t\t\t\t */\n\t\t\t\t\tduk_put_prop(ctx, -4);\n\t\t\t\t}\n\t\t\t}\n\t\t\tduk_pop(ctx);  /* pop enum */\n\t\t}\n\t}\n\n\t/* [ ... holder name val ] */\n\n\tduk_dup(ctx, js_ctx->idx_reviver);\n\tduk_insert(ctx, -4);  /* -> [ ... reviver holder name val ] */\n\tduk_call_method(ctx, 2);  /* -> [ ... res ] */\n\n\tDUK_DDD(DUK_DDDPRINT(\"walk: top=%ld, result=%!T\",\n\t                     (long) duk_get_top(ctx), (duk_tval *) duk_get_tval(ctx, -1)));\n}\n\n/*\n *  Stringify implementation.\n */\n\n#define DUK__EMIT_1(js_ctx,ch)          duk__emit_1((js_ctx), (duk_uint_fast8_t) (ch))\n#define DUK__EMIT_2(js_ctx,ch1,ch2)     duk__emit_2((js_ctx), (duk_uint_fast8_t) (ch1), (duk_uint_fast8_t) (ch2))\n#define DUK__EMIT_HSTR(js_ctx,h)        duk__emit_hstring((js_ctx), (h))\n#if defined(DUK_USE_FASTINT) || defined(DUK_USE_JX) || defined(DUK_USE_JC)\n#define DUK__EMIT_CSTR(js_ctx,p)        duk__emit_cstring((js_ctx), (p))\n#endif\n#define DUK__EMIT_STRIDX(js_ctx,i)      duk__emit_stridx((js_ctx), (i))\n#define DUK__UNEMIT_1(js_ctx)           duk__unemit_1((js_ctx))\n\nDUK_LOCAL void duk__emit_1(duk_json_enc_ctx *js_ctx, duk_uint_fast8_t ch) {\n\tDUK_BW_WRITE_ENSURE_U8(js_ctx->thr, &js_ctx->bw, ch);\n}\n\nDUK_LOCAL void duk__emit_2(duk_json_enc_ctx *js_ctx, duk_uint_fast8_t ch1, duk_uint_fast8_t ch2) {\n\tDUK_BW_WRITE_ENSURE_U8_2(js_ctx->thr, &js_ctx->bw, ch1, ch2);\n}\n\nDUK_LOCAL void duk__emit_hstring(duk_json_enc_ctx *js_ctx, duk_hstring *h) {\n\tDUK_BW_WRITE_ENSURE_HSTRING(js_ctx->thr, &js_ctx->bw, h);\n}\n\n#if defined(DUK_USE_FASTINT) || defined(DUK_USE_JX) || defined(DUK_USE_JC)\nDUK_LOCAL void duk__emit_cstring(duk_json_enc_ctx *js_ctx, const char *str) {\n\tDUK_BW_WRITE_ENSURE_CSTRING(js_ctx->thr, &js_ctx->bw, str);\n}\n#endif\n\nDUK_LOCAL void duk__emit_stridx(duk_json_enc_ctx *js_ctx, duk_small_uint_t stridx) {\n\tduk_hstring *h;\n\n\tDUK_ASSERT_STRIDX_VALID(stridx);\n\th = DUK_HTHREAD_GET_STRING(js_ctx->thr, stridx);\n\tDUK_ASSERT(h != NULL);\n\n\tDUK_BW_WRITE_ENSURE_HSTRING(js_ctx->thr, &js_ctx->bw, h);\n}\n\nDUK_LOCAL void duk__unemit_1(duk_json_enc_ctx *js_ctx) {\n\tDUK_ASSERT(DUK_BW_GET_SIZE(js_ctx->thr, &js_ctx->bw) >= 1);\n\tDUK_BW_ADD_PTR(js_ctx->thr, &js_ctx->bw, -1);\n}\n\n#define DUK__MKESC(nybbles,esc1,esc2)  \\\n\t(((duk_uint_fast32_t) (nybbles)) << 16) | \\\n\t(((duk_uint_fast32_t) (esc1)) << 8) | \\\n\t((duk_uint_fast32_t) (esc2))\n\nDUK_LOCAL duk_uint8_t *duk__emit_esc_auto_fast(duk_json_enc_ctx *js_ctx, duk_uint_fast32_t cp, duk_uint8_t *q) {\n\tduk_uint_fast32_t tmp;\n\tduk_small_uint_t dig;\n\n\tDUK_UNREF(js_ctx);\n\n\t/* Caller ensures space for at least DUK__JSON_MAX_ESC_LEN. */\n\n\t/* Select appropriate escape format automatically, and set 'tmp' to a\n\t * value encoding both the escape format character and the nybble count:\n\t *\n\t *   (nybble_count << 16) | (escape_char1) | (escape_char2)\n\t */\n\n#if defined(DUK_USE_JX)\n\tif (DUK_LIKELY(cp < 0x100UL)) {\n\t\tif (DUK_UNLIKELY(js_ctx->flag_ext_custom)) {\n\t\t\ttmp = DUK__MKESC(2, DUK_ASC_BACKSLASH, DUK_ASC_LC_X);\n\t\t} else {\n\t\t\ttmp = DUK__MKESC(4, DUK_ASC_BACKSLASH, DUK_ASC_LC_U);\n\t\t}\n\t} else\n#endif\n\tif (DUK_LIKELY(cp < 0x10000UL)) {\n\t\ttmp = DUK__MKESC(4, DUK_ASC_BACKSLASH, DUK_ASC_LC_U);\n\t} else {\n#if defined(DUK_USE_JX)\n\t\tif (DUK_LIKELY(js_ctx->flag_ext_custom)) {\n\t\t\ttmp = DUK__MKESC(8, DUK_ASC_BACKSLASH, DUK_ASC_UC_U);\n\t\t} else\n#endif\n\t\t{\n\t\t\t/* In compatible mode and standard JSON mode, output\n\t\t\t * something useful for non-BMP characters.  This won't\n\t\t\t * roundtrip but will still be more or less readable and\n\t\t\t * more useful than an error.\n\t\t\t */\n\t\t\ttmp = DUK__MKESC(8, DUK_ASC_UC_U, DUK_ASC_PLUS);\n\t\t}\n\t}\n\n\t*q++ = (duk_uint8_t) ((tmp >> 8) & 0xff);\n\t*q++ = (duk_uint8_t) (tmp & 0xff);\n\n\ttmp = tmp >> 16;\n\twhile (tmp > 0) {\n\t\ttmp--;\n\t\tdig = (duk_small_uint_t) ((cp >> (4 * tmp)) & 0x0f);\n\t\t*q++ = duk_lc_digits[dig];\n\t}\n\n\treturn q;\n}\n\nDUK_LOCAL void duk__enc_key_autoquote(duk_json_enc_ctx *js_ctx, duk_hstring *k) {\n\tconst duk_int8_t *p, *p_start, *p_end;  /* Note: intentionally signed. */\n\tduk_size_t k_len;\n\tduk_codepoint_t cp;\n\n\tDUK_ASSERT(k != NULL);\n\n\t/* Accept ASCII strings which conform to identifier requirements\n\t * as being emitted without key quotes.  Since we only accept ASCII\n\t * there's no need for actual decoding: 'p' is intentionally signed\n\t * so that bytes >= 0x80 extend to negative values and are rejected\n\t * as invalid identifier codepoints.\n\t */\n\n\tif (js_ctx->flag_avoid_key_quotes) {\n\t\tk_len = DUK_HSTRING_GET_BYTELEN(k);\n\t\tp_start = (const duk_int8_t *) DUK_HSTRING_GET_DATA(k);\n\t\tp_end = p_start + k_len;\n\t\tp = p_start;\n\n\t\tif (p == p_end) {\n\t\t\t/* Zero length string is not accepted without quotes */\n\t\t\tgoto quote_normally;\n\t\t}\n\t\tcp = (duk_codepoint_t) (*p++);\n\t\tif (DUK_UNLIKELY(!duk_unicode_is_identifier_start(cp))) {\n\t\t\tgoto quote_normally;\n\t\t}\n\t\twhile (p < p_end) {\n\t\t\tcp = (duk_codepoint_t) (*p++);\n\t\t\tif (DUK_UNLIKELY(!duk_unicode_is_identifier_part(cp))) {\n\t\t\t\tgoto quote_normally;\n\t\t\t}\n\t\t}\n\n\t\t/* This seems faster than emitting bytes one at a time and\n\t\t * then potentially rewinding.\n\t\t */\n\t\tDUK__EMIT_HSTR(js_ctx, k);\n\t\treturn;\n\t}\n\n quote_normally:\n\tduk__enc_quote_string(js_ctx, k);\n}\n\n/* The Quote(value) operation: quote a string.\n *\n * Stack policy: [ ] -> [ ].\n */\n\nDUK_LOCAL void duk__enc_quote_string(duk_json_enc_ctx *js_ctx, duk_hstring *h_str) {\n\tduk_hthread *thr = js_ctx->thr;\n\tconst duk_uint8_t *p, *p_start, *p_end, *p_now, *p_tmp;\n\tduk_uint8_t *q;\n\tduk_ucodepoint_t cp;  /* typed for duk_unicode_decode_xutf8() */\n\n\tDUK_DDD(DUK_DDDPRINT(\"duk__enc_quote_string: h_str=%!O\", (duk_heaphdr *) h_str));\n\n\tDUK_ASSERT(h_str != NULL);\n\tp_start = DUK_HSTRING_GET_DATA(h_str);\n\tp_end = p_start + DUK_HSTRING_GET_BYTELEN(h_str);\n\tp = p_start;\n\n\tDUK__EMIT_1(js_ctx, DUK_ASC_DOUBLEQUOTE);\n\n\t/* Encode string in small chunks, estimating the maximum expansion so that\n\t * there's no need to ensure space while processing the chunk.\n\t */\n\n\twhile (p < p_end) {\n\t\tduk_size_t left, now, space;\n\n\t\tleft = (duk_size_t) (p_end - p);\n\t\tnow = (left > DUK__JSON_ENCSTR_CHUNKSIZE ?\n\t\t       DUK__JSON_ENCSTR_CHUNKSIZE : left);\n\n\t\t/* Maximum expansion per input byte is 6:\n\t\t *   - invalid UTF-8 byte causes \"\\uXXXX\" to be emitted (6/1 = 6).\n\t\t *   - 2-byte UTF-8 encodes as \"\\uXXXX\" (6/2 = 3).\n\t\t *   - 4-byte UTF-8 encodes as \"\\Uxxxxxxxx\" (10/4 = 2.5).\n\t\t */\n\t\tspace = now * 6;\n\t\tq = DUK_BW_ENSURE_GETPTR(thr, &js_ctx->bw, space);\n\n\t\tp_now = p + now;\n\n\t\twhile (p < p_now) {\n#if defined(DUK_USE_JSON_QUOTESTRING_FASTPATH)\n\t\t\tduk_uint8_t b;\n\n\t\t\tb = duk__json_quotestr_lookup[*p++];\n\t\t\tif (DUK_LIKELY(b < 0x80)) {\n\t\t\t\t/* Most input bytes go through here. */\n\t\t\t\t*q++ = b;\n\t\t\t} else if (b >= 0xa0) {\n\t\t\t\t*q++ = DUK_ASC_BACKSLASH;\n\t\t\t\t*q++ = (duk_uint8_t) (b - 0x80);\n\t\t\t} else if (b == 0x80) {\n\t\t\t\tcp = (duk_ucodepoint_t) (*(p - 1));\n\t\t\t\tq = duk__emit_esc_auto_fast(js_ctx, cp, q);\n\t\t\t} else if (b == 0x7f && js_ctx->flag_ascii_only) {\n\t\t\t\t/* 0x7F is special */\n\t\t\t\tDUK_ASSERT(b == 0x81);\n\t\t\t\tcp = (duk_ucodepoint_t) 0x7f;\n\t\t\t\tq = duk__emit_esc_auto_fast(js_ctx, cp, q);\n\t\t\t} else {\n\t\t\t\tDUK_ASSERT(b == 0x81);\n\t\t\t\tp--;\n\n\t\t\t\t/* slow path is shared */\n#else  /* DUK_USE_JSON_QUOTESTRING_FASTPATH */\n\t\t\tcp = *p;\n\n\t\t\tif (DUK_LIKELY(cp <= 0x7f)) {\n\t\t\t\t/* ascii fast path: avoid decoding utf-8 */\n\t\t\t\tp++;\n\t\t\t\tif (cp == 0x22 || cp == 0x5c) {\n\t\t\t\t\t/* double quote or backslash */\n\t\t\t\t\t*q++ = DUK_ASC_BACKSLASH;\n\t\t\t\t\t*q++ = (duk_uint8_t) cp;\n\t\t\t\t} else if (cp < 0x20) {\n\t\t\t\t\tduk_uint_fast8_t esc_char;\n\n\t\t\t\t\t/* This approach is a bit shorter than a straight\n\t\t\t\t\t * if-else-ladder and also a bit faster.\n\t\t\t\t\t */\n\t\t\t\t\tif (cp < (sizeof(duk__json_quotestr_esc) / sizeof(duk_uint8_t)) &&\n\t\t\t\t\t    (esc_char = duk__json_quotestr_esc[cp]) != 0) {\n\t\t\t\t\t\t*q++ = DUK_ASC_BACKSLASH;\n\t\t\t\t\t\t*q++ = (duk_uint8_t) esc_char;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tq = duk__emit_esc_auto_fast(js_ctx, cp, q);\n\t\t\t\t\t}\n\t\t\t\t} else if (cp == 0x7f && js_ctx->flag_ascii_only) {\n\t\t\t\t\tq = duk__emit_esc_auto_fast(js_ctx, cp, q);\n\t\t\t\t} else {\n\t\t\t\t\t/* any other printable -> as is */\n\t\t\t\t\t*q++ = (duk_uint8_t) cp;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t/* slow path is shared */\n#endif  /* DUK_USE_JSON_QUOTESTRING_FASTPATH */\n\n\t\t\t\t/* slow path decode */\n\n\t\t\t\t/* If XUTF-8 decoding fails, treat the offending byte as a codepoint directly\n\t\t\t\t * and go forward one byte.  This is of course very lossy, but allows some kind\n\t\t\t\t * of output to be produced even for internal strings which don't conform to\n\t\t\t\t * XUTF-8.  All standard Ecmascript strings are always CESU-8, so this behavior\n\t\t\t\t * does not violate the Ecmascript specification.  The behavior is applied to\n\t\t\t\t * all modes, including Ecmascript standard JSON.  Because the current XUTF-8\n\t\t\t\t * decoding is not very strict, this behavior only really affects initial bytes\n\t\t\t\t * and truncated codepoints.\n\t\t\t\t *\n\t\t\t\t * Another alternative would be to scan forwards to start of next codepoint\n\t\t\t\t * (or end of input) and emit just one replacement codepoint.\n\t\t\t\t */\n\n\t\t\t\tp_tmp = p;\n\t\t\t\tif (!duk_unicode_decode_xutf8(thr, &p, p_start, p_end, &cp)) {\n\t\t\t\t\t/* Decode failed. */\n\t\t\t\t\tcp = *p_tmp;\n\t\t\t\t\tp = p_tmp + 1;\n\t\t\t\t}\n\n#if defined(DUK_USE_NONSTD_JSON_ESC_U2028_U2029)\n\t\t\t\tif (js_ctx->flag_ascii_only || cp == 0x2028 || cp == 0x2029) {\n#else\n\t\t\t\tif (js_ctx->flag_ascii_only) {\n#endif\n\t\t\t\t\tq = duk__emit_esc_auto_fast(js_ctx, cp, q);\n\t\t\t\t} else {\n\t\t\t\t\t/* as is */\n\t\t\t\t\tDUK_RAW_WRITE_XUTF8(q, cp);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tDUK_BW_SET_PTR(thr, &js_ctx->bw, q);\n\t}\n\n\tDUK__EMIT_1(js_ctx, DUK_ASC_DOUBLEQUOTE);\n}\n\n/* Encode a double (checked by caller) from stack top.  Stack top may be\n * replaced by serialized string but is not popped (caller does that).\n */\nDUK_LOCAL void duk__enc_double(duk_json_enc_ctx *js_ctx) {\n\tduk_hthread *thr;\n\tduk_context *ctx;\n\tduk_tval *tv;\n\tduk_double_t d;\n\tduk_small_int_t c;\n\tduk_small_int_t s;\n\tduk_small_uint_t stridx;\n\tduk_small_uint_t n2s_flags;\n\tduk_hstring *h_str;\n\n\tDUK_ASSERT(js_ctx != NULL);\n\tthr = js_ctx->thr;\n\tDUK_ASSERT(thr != NULL);\n\tctx = (duk_context *) thr;\n\n\t/* Caller must ensure 'tv' is indeed a double and not a fastint! */\n\ttv = DUK_GET_TVAL_NEGIDX(ctx, -1);\n\tDUK_ASSERT(DUK_TVAL_IS_DOUBLE(tv));\n\td = DUK_TVAL_GET_DOUBLE(tv);\n\n\tc = (duk_small_int_t) DUK_FPCLASSIFY(d);\n\ts = (duk_small_int_t) DUK_SIGNBIT(d);\n\tDUK_UNREF(s);\n\n\tif (DUK_LIKELY(!(c == DUK_FP_INFINITE || c == DUK_FP_NAN))) {\n\t\tDUK_ASSERT(DUK_ISFINITE(d));\n\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n\t\t/* Negative zero needs special handling in JX/JC because\n\t\t * it would otherwise serialize to '0', not '-0'.\n\t\t */\n\t\tif (DUK_UNLIKELY(c == DUK_FP_ZERO && s != 0 &&\n\t\t                 (js_ctx->flag_ext_custom_or_compatible))) {\n\t\t\tduk_push_hstring_stridx(ctx, DUK_STRIDX_MINUS_ZERO);  /* '-0' */\n\t\t} else\n#endif  /* DUK_USE_JX || DUK_USE_JC */\n\t\t{\n\t\t\tn2s_flags = 0;\n\t\t\t/* [ ... number ] -> [ ... string ] */\n\t\t\tduk_numconv_stringify(ctx, 10 /*radix*/, 0 /*digits*/, n2s_flags);\n\t\t}\n\t\th_str = duk_known_hstring(ctx, -1);\n\t\tDUK__EMIT_HSTR(js_ctx, h_str);\n\t\treturn;\n\t}\n\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n\tif (!(js_ctx->flags & (DUK_JSON_FLAG_EXT_CUSTOM |\n\t                       DUK_JSON_FLAG_EXT_COMPATIBLE))) {\n\t\tstridx = DUK_STRIDX_LC_NULL;\n\t} else if (c == DUK_FP_NAN) {\n\t\tstridx = js_ctx->stridx_custom_nan;\n\t} else if (s == 0) {\n\t\tstridx = js_ctx->stridx_custom_posinf;\n\t} else {\n\t\tstridx = js_ctx->stridx_custom_neginf;\n\t}\n#else\n\tstridx = DUK_STRIDX_LC_NULL;\n#endif\n\tDUK__EMIT_STRIDX(js_ctx, stridx);\n}\n\n#if defined(DUK_USE_FASTINT)\n/* Encode a fastint from duk_tval ptr, no value stack effects. */\nDUK_LOCAL void duk__enc_fastint_tval(duk_json_enc_ctx *js_ctx, duk_tval *tv) {\n\tduk_int64_t v;\n\n\t/* Fastint range is signed 48-bit so longest value is -2^47 = -140737488355328\n\t * (16 chars long), longest signed 64-bit value is -2^63 = -9223372036854775808\n\t * (20 chars long).  Alloc space for 64-bit range to be safe.\n\t */\n\tduk_uint8_t buf[20 + 1];\n\n\t/* Caller must ensure 'tv' is indeed a fastint! */\n\tDUK_ASSERT(DUK_TVAL_IS_FASTINT(tv));\n\tv = DUK_TVAL_GET_FASTINT(tv);\n\n\t/* XXX: There are no format strings in duk_config.h yet, could add\n\t * one for formatting duk_int64_t.  For now, assumes \"%lld\" and that\n\t * \"long long\" type exists.  Could also rely on C99 directly but that\n\t * won't work for older MSVC.\n\t */\n\tDUK_SPRINTF((char *) buf, \"%lld\", (long long) v);\n\tDUK__EMIT_CSTR(js_ctx, (const char *) buf);\n}\n#endif\n\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n#if defined(DUK_USE_HEX_FASTPATH)\nDUK_LOCAL duk_uint8_t *duk__enc_buffer_data_hex(const duk_uint8_t *src, duk_size_t src_len, duk_uint8_t *dst) {\n\tduk_uint8_t *q;\n\tduk_uint16_t *q16;\n\tduk_small_uint_t x;\n\tduk_size_t i, len_safe;\n#if !defined(DUK_USE_UNALIGNED_ACCESSES_POSSIBLE)\n\tduk_bool_t shift_dst;\n#endif\n\n\t/* Unlike in duk_hex_encode() 'dst' is not necessarily aligned by 2.\n\t * For platforms where unaligned accesses are not allowed, shift 'dst'\n\t * ahead by 1 byte to get alignment and then DUK_MEMMOVE() the result\n\t * in place.  The faster encoding loop makes up the difference.\n\t * There's always space for one extra byte because a terminator always\n\t * follows the hex data and that's been accounted for by the caller.\n\t */\n\n#if defined(DUK_USE_UNALIGNED_ACCESSES_POSSIBLE)\n\tq16 = (duk_uint16_t *) (void *) dst;\n#else\n\tshift_dst = (duk_bool_t) (((duk_size_t) dst) & 0x01U);\n\tif (shift_dst) {\n\t\tDUK_DD(DUK_DDPRINT(\"unaligned accesses not possible, dst not aligned -> step to dst + 1\"));\n\t\tq16 = (duk_uint16_t *) (void *) (dst + 1);\n\t} else {\n\t\tDUK_DD(DUK_DDPRINT(\"unaligned accesses not possible, dst is aligned\"));\n\t\tq16 = (duk_uint16_t *) (void *) dst;\n\t}\n\tDUK_ASSERT((((duk_size_t) q16) & 0x01U) == 0);\n#endif\n\n\tlen_safe = src_len & ~0x03U;\n\tfor (i = 0; i < len_safe; i += 4) {\n\t\tq16[0] = duk_hex_enctab[src[i]];\n\t\tq16[1] = duk_hex_enctab[src[i + 1]];\n\t\tq16[2] = duk_hex_enctab[src[i + 2]];\n\t\tq16[3] = duk_hex_enctab[src[i + 3]];\n\t\tq16 += 4;\n\t}\n\tq = (duk_uint8_t *) q16;\n\n#if !defined(DUK_USE_UNALIGNED_ACCESSES_POSSIBLE)\n\tif (shift_dst) {\n\t\tq--;\n\t\tDUK_MEMMOVE((void *) dst, (const void *) (dst + 1), 2 * len_safe);\n\t\tDUK_ASSERT(dst + 2 * len_safe == q);\n\t}\n#endif\n\n\tfor (; i < src_len; i++) {\n\t\tx = src[i];\n\t\t*q++ = duk_lc_digits[x >> 4];\n\t\t*q++ = duk_lc_digits[x & 0x0f];\n\t}\n\n\treturn q;\n}\n#else  /* DUK_USE_HEX_FASTPATH */\nDUK_LOCAL duk_uint8_t *duk__enc_buffer_data_hex(const duk_uint8_t *src, duk_size_t src_len, duk_uint8_t *dst) {\n\tconst duk_uint8_t *p;\n\tconst duk_uint8_t *p_end;\n\tduk_uint8_t *q;\n\tduk_small_uint_t x;\n\n\tp = src;\n\tp_end = src + src_len;\n\tq = dst;\n\twhile (p != p_end) {\n\t\tx = *p++;\n\t\t*q++ = duk_lc_digits[x >> 4];\n\t\t*q++ = duk_lc_digits[x & 0x0f];\n\t}\n\n\treturn q;\n}\n#endif  /* DUK_USE_HEX_FASTPATH */\n\nDUK_LOCAL void duk__enc_buffer_data(duk_json_enc_ctx *js_ctx, duk_uint8_t *buf_data, duk_size_t buf_len) {\n\tduk_hthread *thr;\n\tduk_uint8_t *q;\n\tduk_size_t space;\n\n\tthr = js_ctx->thr;\n\n\tDUK_ASSERT(js_ctx->flag_ext_custom || js_ctx->flag_ext_compatible);  /* caller checks */\n\tDUK_ASSERT(js_ctx->flag_ext_custom_or_compatible);\n\n\t/* Buffer values are encoded in (lowercase) hex to make the\n\t * binary data readable.  Base64 or similar would be more\n\t * compact but less readable, and the point of JX/JC\n\t * variants is to be as useful to a programmer as possible.\n\t */\n\n\t/* The #if defined() clutter here needs to handle the three\n\t * cases: (1) JX+JC, (2) JX only, (3) JC only.\n\t */\n\n\t/* Note: space must cater for both JX and JC. */\n\tspace = 9 + buf_len * 2 + 2;\n\tDUK_ASSERT(DUK_HBUFFER_MAX_BYTELEN <= 0x7ffffffeUL);\n\tDUK_ASSERT((space - 2) / 2 >= buf_len);  /* overflow not possible, buffer limits */\n\tq = DUK_BW_ENSURE_GETPTR(thr, &js_ctx->bw, space);\n\n#if defined(DUK_USE_JX) && defined(DUK_USE_JC)\n\tif (js_ctx->flag_ext_custom)\n#endif\n#if defined(DUK_USE_JX)\n\t{\n\t\t*q++ = DUK_ASC_PIPE;\n\t\tq = duk__enc_buffer_data_hex(buf_data, buf_len, q);\n\t\t*q++ = DUK_ASC_PIPE;\n\n\t}\n#endif\n#if defined(DUK_USE_JX) && defined(DUK_USE_JC)\n\telse\n#endif\n#if defined(DUK_USE_JC)\n\t{\n\t\tDUK_ASSERT(js_ctx->flag_ext_compatible);\n\t\tDUK_MEMCPY((void *) q, (const void *) \"{\\\"_buf\\\":\\\"\", 9);  /* len: 9 */\n\t\tq += 9;\n\t\tq = duk__enc_buffer_data_hex(buf_data, buf_len, q);\n\t\t*q++ = DUK_ASC_DOUBLEQUOTE;\n\t\t*q++ = DUK_ASC_RCURLY;\n\t}\n#endif\n\n\tDUK_BW_SET_PTR(thr, &js_ctx->bw, q);\n}\n\nDUK_LOCAL void duk__enc_buffer_jx_jc(duk_json_enc_ctx *js_ctx, duk_hbuffer *h) {\n\tduk__enc_buffer_data(js_ctx,\n\t                     (duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(js_ctx->thr->heap, h),\n\t                     (duk_size_t) DUK_HBUFFER_GET_SIZE(h));\n}\n#endif  /* DUK_USE_JX || DUK_USE_JC */\n\n#if defined(DUK_USE_JSON_STRINGIFY_FASTPATH)\nDUK_LOCAL void duk__enc_buffer_json_fastpath(duk_json_enc_ctx *js_ctx, duk_hbuffer *h) {\n\tduk_size_t i, n;\n\tconst duk_uint8_t *buf;\n\tduk_uint8_t *q;\n\n\tn = DUK_HBUFFER_GET_SIZE(h);\n\tif (n == 0) {\n\t\tDUK__EMIT_2(js_ctx, DUK_ASC_LCURLY, DUK_ASC_RCURLY);\n\t\treturn;\n\t}\n\n\tDUK__EMIT_1(js_ctx, DUK_ASC_LCURLY);\n\n\t/* Maximum encoded length with 32-bit index: 1 + 10 + 2 + 3 + 1 + 1 = 18,\n\t * with 64-bit index: 1 + 20 + 2 + 3 + 1 + 1 = 28.  32 has some spare.\n\t *\n\t * Note that because the output buffer is reallocated from time to time,\n\t * side effects (such as finalizers) affecting the buffer 'h' must be\n\t * disabled.  This is the case in the JSON.stringify() fast path.\n\t */\n\n\tbuf = (const duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(js_ctx->thr->heap, h);\n\tif (DUK_UNLIKELY(js_ctx->h_gap != NULL)) {\n\t\tfor (i = 0; i < n; i++) {\n\t\t\tduk__enc_newline_indent(js_ctx, js_ctx->recursion_depth + 1);\n\t\t\tq = DUK_BW_ENSURE_GETPTR(js_ctx->thr, &js_ctx->bw, 32);\n\t\t\tq += DUK_SPRINTF((char *) q, \"\\\"%lu\\\": %u,\", (unsigned long) i, (unsigned int) buf[i]);\n\t\t\tDUK_BW_SET_PTR(js_ctx->thr, &js_ctx->bw, q);\n\t\t}\n\t} else {\n\t\tq = DUK_BW_GET_PTR(js_ctx->thr, &js_ctx->bw);\n\t\tfor (i = 0; i < n; i++) {\n\t\t\tq = DUK_BW_ENSURE_RAW(js_ctx->thr, &js_ctx->bw, 32, q);\n\t\t\tq += DUK_SPRINTF((char *) q, \"\\\"%lu\\\":%u,\", (unsigned long) i, (unsigned int) buf[i]);\n\t\t}\n\t\tDUK_BW_SET_PTR(js_ctx->thr, &js_ctx->bw, q);\n\t}\n\tDUK__UNEMIT_1(js_ctx);  /* eat trailing comma */\n\n\tif (DUK_UNLIKELY(js_ctx->h_gap != NULL)) {\n\t\tduk__enc_newline_indent(js_ctx, js_ctx->recursion_depth);\n\t}\n\tDUK__EMIT_1(js_ctx, DUK_ASC_RCURLY);\n}\n#endif  /* DUK_USE_JSON_STRINGIFY_FASTPATH */\n\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\nDUK_LOCAL void duk__enc_pointer(duk_json_enc_ctx *js_ctx, void *ptr) {\n\tchar buf[64];  /* XXX: how to figure correct size? */\n\tconst char *fmt;\n\n\tDUK_ASSERT(js_ctx->flag_ext_custom || js_ctx->flag_ext_compatible);  /* caller checks */\n\tDUK_ASSERT(js_ctx->flag_ext_custom_or_compatible);\n\n\tDUK_MEMZERO(buf, sizeof(buf));\n\n\t/* The #if defined() clutter here needs to handle the three\n\t * cases: (1) JX+JC, (2) JX only, (3) JC only.\n\t */\n#if defined(DUK_USE_JX) && defined(DUK_USE_JC)\n\tif (js_ctx->flag_ext_custom)\n#endif\n#if defined(DUK_USE_JX)\n\t{\n\t\tfmt = ptr ? \"(%p)\" : \"(null)\";\n\t}\n#endif\n#if defined(DUK_USE_JX) && defined(DUK_USE_JC)\n\telse\n#endif\n#if defined(DUK_USE_JC)\n\t{\n\t\tDUK_ASSERT(js_ctx->flag_ext_compatible);\n\t\tfmt = ptr ? \"{\\\"_ptr\\\":\\\"%p\\\"}\" : \"{\\\"_ptr\\\":\\\"null\\\"}\";\n\t}\n#endif\n\n\t/* When ptr == NULL, the format argument is unused. */\n\tDUK_SNPRINTF(buf, sizeof(buf) - 1, fmt, ptr);  /* must not truncate */\n\tDUK__EMIT_CSTR(js_ctx, buf);\n}\n#endif  /* DUK_USE_JX || DUK_USE_JC */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\nDUK_LOCAL void duk__enc_bufobj(duk_json_enc_ctx *js_ctx, duk_hbufobj *h_bufobj) {\n\tDUK_ASSERT_HBUFOBJ_VALID(h_bufobj);\n\n\tif (h_bufobj->buf == NULL || !DUK_HBUFOBJ_VALID_SLICE(h_bufobj)) {\n\t\tDUK__EMIT_STRIDX(js_ctx, DUK_STRIDX_LC_NULL);\n\t} else {\n\t\t/* Handle both full and partial slice (as long as covered). */\n\t\tduk__enc_buffer_data(js_ctx,\n\t\t                     (duk_uint8_t *) DUK_HBUFOBJ_GET_SLICE_BASE(js_ctx->thr->heap, h_bufobj),\n\t\t                     (duk_size_t) h_bufobj->length);\n\t}\n}\n#endif  /* DUK_USE_JX || DUK_USE_JC */\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/* Indent helper.  Calling code relies on js_ctx->recursion_depth also being\n * directly related to indent depth.\n */\n#if defined(DUK_USE_PREFER_SIZE)\nDUK_LOCAL void duk__enc_newline_indent(duk_json_enc_ctx *js_ctx, duk_int_t depth) {\n\tDUK_ASSERT(js_ctx->h_gap != NULL);\n\tDUK_ASSERT(DUK_HSTRING_GET_BYTELEN(js_ctx->h_gap) > 0);  /* caller guarantees */\n\n\tDUK__EMIT_1(js_ctx, 0x0a);\n\twhile (depth-- > 0) {\n\t\tDUK__EMIT_HSTR(js_ctx, js_ctx->h_gap);\n\t}\n}\n#else  /* DUK_USE_PREFER_SIZE */\nDUK_LOCAL void duk__enc_newline_indent(duk_json_enc_ctx *js_ctx, duk_int_t depth) {\n\tconst duk_uint8_t *gap_data;\n\tduk_size_t gap_len;\n\tduk_size_t avail_bytes;   /* bytes of indent available for copying */\n\tduk_size_t need_bytes;    /* bytes of indent still needed */\n\tduk_uint8_t *p_start;\n\tduk_uint8_t *p;\n\n\tDUK_ASSERT(js_ctx->h_gap != NULL);\n\tDUK_ASSERT(DUK_HSTRING_GET_BYTELEN(js_ctx->h_gap) > 0);  /* caller guarantees */\n\n\tDUK__EMIT_1(js_ctx, 0x0a);\n\tif (DUK_UNLIKELY(depth == 0)) {\n\t\treturn;\n\t}\n\n\t/* To handle deeper indents efficiently, make use of copies we've\n\t * already emitted.  In effect we can emit a sequence of 1, 2, 4,\n\t * 8, etc copies, and then finish the last run.  Byte counters\n\t * avoid multiply with gap_len on every loop.\n\t */\n\n\tgap_data = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(js_ctx->h_gap);\n\tgap_len = (duk_size_t) DUK_HSTRING_GET_BYTELEN(js_ctx->h_gap);\n\tDUK_ASSERT(gap_len > 0);\n\n\tneed_bytes = gap_len * depth;\n\tp = DUK_BW_ENSURE_GETPTR(js_ctx->thr, &js_ctx->bw, need_bytes);\n\tp_start = p;\n\n\tDUK_MEMCPY((void *) p, (const void *) gap_data, (size_t) gap_len);\n\tp += gap_len;\n\tavail_bytes = gap_len;\n\tDUK_ASSERT(need_bytes >= gap_len);\n\tneed_bytes -= gap_len;\n\n\twhile (need_bytes >= avail_bytes) {\n\t\tDUK_MEMCPY((void *) p, (const void *) p_start, (size_t) avail_bytes);\n\t\tp += avail_bytes;\n\t\tneed_bytes -= avail_bytes;\n\t\tavail_bytes <<= 1;\n\t}\n\n\tDUK_ASSERT(need_bytes < avail_bytes);  /* need_bytes may be zero */\n\tDUK_MEMCPY((void *) p, (const void *) p_start, (size_t) need_bytes);\n\tp += need_bytes;\n\t/*avail_bytes += need_bytes*/\n\n\tDUK_BW_SET_PTR(js_ctx->thr, &js_ctx->bw, p);\n}\n#endif  /* DUK_USE_PREFER_SIZE */\n\n/* Shared entry handling for object/array serialization. */\nDUK_LOCAL void duk__enc_objarr_entry(duk_json_enc_ctx *js_ctx, duk_idx_t *entry_top) {\n\tduk_context *ctx = (duk_context *) js_ctx->thr;\n\tduk_hobject *h_target;\n\tduk_uint_fast32_t i, n;\n\n\t*entry_top = duk_get_top(ctx);\n\n\tduk_require_stack(ctx, DUK_JSON_ENC_REQSTACK);\n\n\t/* Loop check using a hybrid approach: a fixed-size visited[] array\n\t * with overflow in a loop check object.\n\t */\n\n\th_target = duk_known_hobject(ctx, -1);  /* object or array */\n\n\tn = js_ctx->recursion_depth;\n\tif (DUK_UNLIKELY(n > DUK_JSON_ENC_LOOPARRAY)) {\n\t\tn = DUK_JSON_ENC_LOOPARRAY;\n\t}\n\tfor (i = 0; i < n; i++) {\n\t\tif (DUK_UNLIKELY(js_ctx->visiting[i] == h_target)) {\n\t\t\tDUK_DD(DUK_DDPRINT(\"slow path loop detect\"));\n\t\t\tDUK_ERROR_TYPE((duk_hthread *) ctx, DUK_STR_CYCLIC_INPUT);\n\t\t}\n\t}\n\tif (js_ctx->recursion_depth < DUK_JSON_ENC_LOOPARRAY) {\n\t\tjs_ctx->visiting[js_ctx->recursion_depth] = h_target;\n\t} else {\n\t\tduk_push_sprintf(ctx, DUK_STR_FMT_PTR, (void *) h_target);\n\t\tduk_dup_top(ctx);  /* -> [ ... voidp voidp ] */\n\t\tif (duk_has_prop(ctx, js_ctx->idx_loop)) {\n\t\t\tDUK_ERROR_TYPE((duk_hthread *) ctx, DUK_STR_CYCLIC_INPUT);\n\t\t}\n\t\tduk_push_true(ctx);  /* -> [ ... voidp true ] */\n\t\tduk_put_prop(ctx, js_ctx->idx_loop);  /* -> [ ... ] */\n\t}\n\n\t/* C recursion check. */\n\n\tDUK_ASSERT(js_ctx->recursion_depth >= 0);\n\tDUK_ASSERT(js_ctx->recursion_depth <= js_ctx->recursion_limit);\n\tif (js_ctx->recursion_depth >= js_ctx->recursion_limit) {\n\t\tDUK_ERROR_RANGE((duk_hthread *) ctx, DUK_STR_JSONENC_RECLIMIT);\n\t}\n\tjs_ctx->recursion_depth++;\n\n\tDUK_DDD(DUK_DDDPRINT(\"shared entry finished: top=%ld, loop=%!T\",\n\t                     (long) duk_get_top(ctx), (duk_tval *) duk_get_tval(ctx, js_ctx->idx_loop)));\n}\n\n/* Shared exit handling for object/array serialization. */\nDUK_LOCAL void duk__enc_objarr_exit(duk_json_enc_ctx *js_ctx, duk_idx_t *entry_top) {\n\tduk_context *ctx = (duk_context *) js_ctx->thr;\n\tduk_hobject *h_target;\n\n\t/* C recursion check. */\n\n\tDUK_ASSERT(js_ctx->recursion_depth > 0);\n\tDUK_ASSERT(js_ctx->recursion_depth <= js_ctx->recursion_limit);\n\tjs_ctx->recursion_depth--;\n\n\t/* Loop check. */\n\n\th_target = duk_known_hobject(ctx, *entry_top - 1);  /* original target at entry_top - 1 */\n\n\tif (js_ctx->recursion_depth < DUK_JSON_ENC_LOOPARRAY) {\n\t\t/* Previous entry was inside visited[], nothing to do. */\n\t} else {\n\t\tduk_push_sprintf(ctx, DUK_STR_FMT_PTR, (void *) h_target);\n\t\tduk_del_prop(ctx, js_ctx->idx_loop);  /* -> [ ... ] */\n\t}\n\n\t/* Restore stack top after unbalanced code paths. */\n\tduk_set_top(ctx, *entry_top);\n\n\tDUK_DDD(DUK_DDDPRINT(\"shared entry finished: top=%ld, loop=%!T\",\n\t                     (long) duk_get_top(ctx), (duk_tval *) duk_get_tval(ctx, js_ctx->idx_loop)));\n}\n\n/* The JO(value) operation: encode object.\n *\n * Stack policy: [ object ] -> [ object ].\n */\nDUK_LOCAL void duk__enc_object(duk_json_enc_ctx *js_ctx) {\n\tduk_context *ctx = (duk_context *) js_ctx->thr;\n\tduk_hstring *h_key;\n\tduk_idx_t entry_top;\n\tduk_idx_t idx_obj;\n\tduk_idx_t idx_keys;\n\tduk_bool_t emitted;\n\tduk_uarridx_t arr_len, i;\n\tduk_size_t prev_size;\n\n\tDUK_DDD(DUK_DDDPRINT(\"duk__enc_object: obj=%!T\", (duk_tval *) duk_get_tval(ctx, -1)));\n\n\tduk__enc_objarr_entry(js_ctx, &entry_top);\n\n\tidx_obj = entry_top - 1;\n\n\tif (js_ctx->idx_proplist >= 0) {\n\t\tidx_keys = js_ctx->idx_proplist;\n\t} else {\n\t\t/* XXX: would be nice to enumerate an object at specified index */\n\t\tduk_dup(ctx, idx_obj);\n\t\t(void) duk_hobject_get_enumerated_keys(ctx, DUK_ENUM_OWN_PROPERTIES_ONLY /*flags*/);  /* [ ... target ] -> [ ... target keys ] */\n\t\tidx_keys = duk_require_normalize_index(ctx, -1);\n\t\t/* leave stack unbalanced on purpose */\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"idx_keys=%ld, h_keys=%!T\",\n\t                     (long) idx_keys, (duk_tval *) duk_get_tval(ctx, idx_keys)));\n\n\t/* Steps 8-10 have been merged to avoid a \"partial\" variable. */\n\n\tDUK__EMIT_1(js_ctx, DUK_ASC_LCURLY);\n\n\t/* XXX: keys is an internal object with all keys to be processed\n\t * in its (gapless) array part.  Because nobody can touch the keys\n\t * object, we could iterate its array part directly (keeping in mind\n\t * that it can be reallocated).\n\t */\n\n\tarr_len = (duk_uarridx_t) duk_get_length(ctx, idx_keys);\n\temitted = 0;\n\tfor (i = 0; i < arr_len; i++) {\n\t\tduk_get_prop_index(ctx, idx_keys, i);  /* -> [ ... key ] */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"object property loop: holder=%!T, key=%!T\",\n\t\t                     (duk_tval *) duk_get_tval(ctx, idx_obj),\n\t\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\n\t\th_key = duk_known_hstring(ctx, -1);\n\t\tDUK_ASSERT(h_key != NULL);\n\t\tDUK_ASSERT(!DUK_HSTRING_HAS_SYMBOL(h_key));  /* proplist filtering; enum options */\n\n\t\tprev_size = DUK_BW_GET_SIZE(js_ctx->thr, &js_ctx->bw);\n\t\tif (DUK_UNLIKELY(js_ctx->h_gap != NULL)) {\n\t\t\tduk__enc_newline_indent(js_ctx, js_ctx->recursion_depth);\n\t\t\tduk__enc_key_autoquote(js_ctx, h_key);\n\t\t\tDUK__EMIT_2(js_ctx, DUK_ASC_COLON, DUK_ASC_SPACE);\n\t\t} else {\n\t\t\tduk__enc_key_autoquote(js_ctx, h_key);\n\t\t\tDUK__EMIT_1(js_ctx, DUK_ASC_COLON);\n\t\t}\n\n\t\t/* [ ... key ] */\n\n\t\tif (DUK_UNLIKELY(duk__enc_value(js_ctx, idx_obj) == 0)) {\n\t\t\t/* Value would yield 'undefined', so skip key altogether.\n\t\t\t * Side effects have already happened.\n\t\t\t */\n\t\t\tDUK_BW_SET_SIZE(js_ctx->thr, &js_ctx->bw, prev_size);\n\t\t} else {\n\t\t\tDUK__EMIT_1(js_ctx, DUK_ASC_COMMA);\n\t\t\temitted = 1;\n\t\t}\n\n\t\t/* [ ... ] */\n\t}\n\n\tif (emitted) {\n\t\tDUK_ASSERT(*((duk_uint8_t *) DUK_BW_GET_PTR(js_ctx->thr, &js_ctx->bw) - 1) == DUK_ASC_COMMA);\n\t\tDUK__UNEMIT_1(js_ctx);  /* eat trailing comma */\n\t\tif (DUK_UNLIKELY(js_ctx->h_gap != NULL)) {\n\t\t\tDUK_ASSERT(js_ctx->recursion_depth >= 1);\n\t\t\tduk__enc_newline_indent(js_ctx, js_ctx->recursion_depth - 1);\n\t\t}\n\t}\n\tDUK__EMIT_1(js_ctx, DUK_ASC_RCURLY);\n\n\tduk__enc_objarr_exit(js_ctx, &entry_top);\n\n\tDUK_ASSERT_TOP(ctx, entry_top);\n}\n\n/* The JA(value) operation: encode array.\n *\n * Stack policy: [ array ] -> [ array ].\n */\nDUK_LOCAL void duk__enc_array(duk_json_enc_ctx *js_ctx) {\n\tduk_context *ctx = (duk_context *) js_ctx->thr;\n\tduk_idx_t entry_top;\n\tduk_idx_t idx_arr;\n\tduk_bool_t emitted;\n\tduk_uarridx_t i, arr_len;\n\n\tDUK_DDD(DUK_DDDPRINT(\"duk__enc_array: array=%!T\",\n\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\n\tduk__enc_objarr_entry(js_ctx, &entry_top);\n\n\tidx_arr = entry_top - 1;\n\n\t/* Steps 8-10 have been merged to avoid a \"partial\" variable. */\n\n\tDUK__EMIT_1(js_ctx, DUK_ASC_LBRACKET);\n\n\tarr_len = (duk_uarridx_t) duk_get_length(ctx, idx_arr);\n\temitted = 0;\n\tfor (i = 0; i < arr_len; i++) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"array entry loop: array=%!T, index=%ld, arr_len=%ld\",\n\t\t                     (duk_tval *) duk_get_tval(ctx, idx_arr),\n\t\t                     (long) i, (long) arr_len));\n\n\t\tif (DUK_UNLIKELY(js_ctx->h_gap != NULL)) {\n\t\t\tDUK_ASSERT(js_ctx->recursion_depth >= 1);\n\t\t\tduk__enc_newline_indent(js_ctx, js_ctx->recursion_depth);\n\t\t}\n\n\t\t(void) duk_push_uint_to_hstring(ctx, (duk_uint_t) i);  /* -> [ ... key ] */\n\n\t\t/* [ ... key ] */\n\n\t\tif (DUK_UNLIKELY(duk__enc_value(js_ctx, idx_arr) == 0)) {\n\t\t\t/* Value would normally be omitted, replace with 'null'. */\n\t\t\tDUK__EMIT_STRIDX(js_ctx, DUK_STRIDX_LC_NULL);\n\t\t} else {\n\t\t\t;\n\t\t}\n\n\t\t/* [ ... ] */\n\n\t\tDUK__EMIT_1(js_ctx, DUK_ASC_COMMA);\n\t\temitted = 1;\n\t}\n\n\tif (emitted) {\n\t\tDUK_ASSERT(*((duk_uint8_t *) DUK_BW_GET_PTR(js_ctx->thr, &js_ctx->bw) - 1) == DUK_ASC_COMMA);\n\t\tDUK__UNEMIT_1(js_ctx);  /* eat trailing comma */\n\t\tif (DUK_UNLIKELY(js_ctx->h_gap != NULL)) {\n\t\t\tDUK_ASSERT(js_ctx->recursion_depth >= 1);\n\t\t\tduk__enc_newline_indent(js_ctx, js_ctx->recursion_depth - 1);\n\t\t}\n\t}\n\tDUK__EMIT_1(js_ctx, DUK_ASC_RBRACKET);\n\n\tduk__enc_objarr_exit(js_ctx, &entry_top);\n\n\tDUK_ASSERT_TOP(ctx, entry_top);\n}\n\n/* The Str(key, holder) operation.\n *\n * Stack policy: [ ... key ] -> [ ... ]\n */\nDUK_LOCAL duk_bool_t duk__enc_value(duk_json_enc_ctx *js_ctx, duk_idx_t idx_holder) {\n\tduk_context *ctx = (duk_context *) js_ctx->thr;\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv;\n\tduk_tval *tv_holder;\n\tduk_tval *tv_key;\n\tduk_small_int_t c;\n\n\tDUK_DDD(DUK_DDDPRINT(\"duk__enc_value: idx_holder=%ld, holder=%!T, key=%!T\",\n\t                     (long) idx_holder, (duk_tval *) duk_get_tval(ctx, idx_holder),\n\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\n\tDUK_UNREF(thr);\n\n\ttv_holder = DUK_GET_TVAL_POSIDX(ctx, idx_holder);\n\tDUK_ASSERT(DUK_TVAL_IS_OBJECT(tv_holder));\n\ttv_key = DUK_GET_TVAL_NEGIDX(ctx, -1);\n\tDUK_ASSERT(DUK_TVAL_IS_STRING(tv_key));\n\tDUK_ASSERT(!DUK_HSTRING_HAS_SYMBOL(DUK_TVAL_GET_STRING(tv_key)));  /* Caller responsible. */\n\t(void) duk_hobject_getprop(thr, tv_holder, tv_key);\n\n\t/* -> [ ... key val ] */\n\n\tDUK_DDD(DUK_DDDPRINT(\"value=%!T\", (duk_tval *) duk_get_tval(ctx, -1)));\n\n\t/* Standard JSON checks for .toJSON() only for actual objects; for\n\t * example, setting Number.prototype.toJSON and then serializing a\n\t * number won't invoke the .toJSON() method.  However, lightfuncs and\n\t * plain buffers mimic objects so we check for their .toJSON() method.\n\t */\n\tif (duk_check_type_mask(ctx, -1, DUK_TYPE_MASK_OBJECT |\n\t                                 DUK_TYPE_MASK_LIGHTFUNC |\n\t                                 DUK_TYPE_MASK_BUFFER)) {\n\t\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_TO_JSON);\n\t\tif (duk_is_callable(ctx, -1)) {  /* toJSON() can also be a lightfunc */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"value is object, has callable toJSON() -> call it\"));\n\t\t\t/* XXX: duk_dup_unvalidated(ctx, -2) etc. */\n\t\t\tduk_dup_m2(ctx);          /* -> [ ... key val toJSON val ] */\n\t\t\tduk_dup_m4(ctx);          /* -> [ ... key val toJSON val key ] */\n\t\t\tduk_call_method(ctx, 1);  /* -> [ ... key val val' ] */\n\t\t\tduk_remove_m2(ctx);       /* -> [ ... key val' ] */\n\t\t} else {\n\t\t\tduk_pop(ctx);             /* -> [ ... key val ] */\n\t\t}\n\t}\n\n\t/* [ ... key val ] */\n\n\tDUK_DDD(DUK_DDDPRINT(\"value=%!T\", (duk_tval *) duk_get_tval(ctx, -1)));\n\n\tif (js_ctx->h_replacer) {\n\t\t/* XXX: Here a \"slice copy\" would be useful. */\n\t\tDUK_DDD(DUK_DDDPRINT(\"replacer is set, call replacer\"));\n\t\tduk_push_hobject(ctx, js_ctx->h_replacer);  /* -> [ ... key val replacer ] */\n\t\tduk_dup(ctx, idx_holder);                   /* -> [ ... key val replacer holder ] */\n\t\tduk_dup_m4(ctx);                            /* -> [ ... key val replacer holder key ] */\n\t\tduk_dup_m4(ctx);                            /* -> [ ... key val replacer holder key val ] */\n\t\tduk_call_method(ctx, 2);                    /* -> [ ... key val val' ] */\n\t\tduk_remove_m2(ctx);                         /* -> [ ... key val' ] */\n\t}\n\n\t/* [ ... key val ] */\n\n\tDUK_DDD(DUK_DDDPRINT(\"value=%!T\", (duk_tval *) duk_get_tval(ctx, -1)));\n\n\ttv = DUK_GET_TVAL_NEGIDX(ctx, -1);\n\tif (DUK_TVAL_IS_OBJECT(tv)) {\n\t\tduk_hobject *h;\n\n\t\th = DUK_TVAL_GET_OBJECT(tv);\n\t\tDUK_ASSERT(h != NULL);\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n\t\tif (DUK_HOBJECT_IS_BUFOBJ(h) &&\n\t\t    js_ctx->flags & (DUK_JSON_FLAG_EXT_CUSTOM | DUK_JSON_FLAG_EXT_COMPATIBLE)) {\n\t\t\t/* With JX/JC a bufferobject gets serialized specially. */\n\t\t\tduk_hbufobj *h_bufobj;\n\t\t\th_bufobj = (duk_hbufobj *) h;\n\t\t\tDUK_ASSERT_HBUFOBJ_VALID(h_bufobj);\n\t\t\tduk__enc_bufobj(js_ctx, h_bufobj);\n\t\t\tgoto pop2_emitted;\n\t\t}\n\t\t/* Otherwise bufferobjects get serialized as normal objects. */\n#endif  /* JX || JC */\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\t\tc = (duk_small_int_t) DUK_HOBJECT_GET_CLASS_NUMBER(h);\n\t\tswitch (c) {\n\t\tcase DUK_HOBJECT_CLASS_NUMBER: {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"value is a Number object -> coerce with ToNumber()\"));\n\t\t\tduk_to_number_m1(ctx);\n\t\t\t/* The coercion potentially invokes user .valueOf() and .toString()\n\t\t\t * but can't result in a function value because ToPrimitive() would\n\t\t\t * reject such a result: test-dev-json-stringify-coercion-1.js.\n\t\t\t */\n\t\t\tDUK_ASSERT(!duk_is_callable(ctx, -1));\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_HOBJECT_CLASS_STRING: {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"value is a String object -> coerce with ToString()\"));\n\t\t\tduk_to_string(ctx, -1);\n\t\t\t/* Same coercion behavior as for Number. */\n\t\t\tDUK_ASSERT(!duk_is_callable(ctx, -1));\n\t\t\tbreak;\n\t\t}\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n\t\tcase DUK_HOBJECT_CLASS_POINTER:\n#endif\n\t\tcase DUK_HOBJECT_CLASS_BOOLEAN: {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"value is a Boolean/Buffer/Pointer object -> get internal value\"));\n\t\t\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_INT_VALUE);\n\t\t\tduk_remove_m2(ctx);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t/* Normal object which doesn't get automatically coerced to a\n\t\t\t * primitive value.  Functions are checked for specially.  The\n\t\t\t * primitive value coercions for Number, String, Pointer, and\n\t\t\t * Boolean can't result in functions so suffices to check here.\n\t\t\t * Symbol objects are handled like plain objects (their primitive\n\t\t\t * value is NOT looked up like for e.g. String objects).\n\t\t\t */\n\t\t\tDUK_ASSERT(h != NULL);\n\t\t\tif (DUK_HOBJECT_IS_CALLABLE(h)) {\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n\t\t\t\tif (js_ctx->flags & (DUK_JSON_FLAG_EXT_CUSTOM |\n\t\t\t\t                     DUK_JSON_FLAG_EXT_COMPATIBLE)) {\n\t\t\t\t\t/* We only get here when doing non-standard JSON encoding */\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> function allowed, serialize to custom format\"));\n\t\t\t\t\tDUK_ASSERT(js_ctx->flag_ext_custom || js_ctx->flag_ext_compatible);\n\t\t\t\t\tDUK__EMIT_STRIDX(js_ctx, js_ctx->stridx_custom_function);\n\t\t\t\t\tgoto pop2_emitted;\n\t\t\t\t} else {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> will result in undefined (function)\"));\n\t\t\t\t\tgoto pop2_undef;\n\t\t\t\t}\n#else  /* DUK_USE_JX || DUK_USE_JC */\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> will result in undefined (function)\"));\n\t\t\t\tgoto pop2_undef;\n#endif  /* DUK_USE_JX || DUK_USE_JC */\n\t\t\t}\n\t\t}\n\t\t}  /* end switch */\n\t}\n\n\t/* [ ... key val ] */\n\n\tDUK_DDD(DUK_DDDPRINT(\"value=%!T\", (duk_tval *) duk_get_tval(ctx, -1)));\n\n\tif (duk_check_type_mask(ctx, -1, js_ctx->mask_for_undefined)) {\n\t\t/* will result in undefined */\n\t\tDUK_DDD(DUK_DDDPRINT(\"-> will result in undefined (type mask check)\"));\n\t\tgoto pop2_undef;\n\t}\n\ttv = DUK_GET_TVAL_NEGIDX(ctx, -1);\n\n\tswitch (DUK_TVAL_GET_TAG(tv)) {\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n\t/* When JX/JC not in use, the type mask above will avoid this case if needed. */\n\tcase DUK_TAG_UNDEFINED: {\n\t\tDUK__EMIT_STRIDX(js_ctx, js_ctx->stridx_custom_undefined);\n\t\tbreak;\n\t}\n#endif\n\tcase DUK_TAG_NULL: {\n\t\tDUK__EMIT_STRIDX(js_ctx, DUK_STRIDX_LC_NULL);\n\t\tbreak;\n\t}\n\tcase DUK_TAG_BOOLEAN: {\n\t\tDUK__EMIT_STRIDX(js_ctx, DUK_TVAL_GET_BOOLEAN(tv) ?\n\t\t                 DUK_STRIDX_TRUE : DUK_STRIDX_FALSE);\n\t\tbreak;\n\t}\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n\t/* When JX/JC not in use, the type mask above will avoid this case if needed. */\n\tcase DUK_TAG_POINTER: {\n\t\tduk__enc_pointer(js_ctx, DUK_TVAL_GET_POINTER(tv));\n\t\tbreak;\n\t}\n#endif  /* DUK_USE_JX || DUK_USE_JC */\n\tcase DUK_TAG_STRING: {\n\t\tduk_hstring *h = DUK_TVAL_GET_STRING(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\tif (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) {\n\t\t\tgoto pop2_undef;\n\t\t}\n\t\tduk__enc_quote_string(js_ctx, h);\n\t\tbreak;\n\t}\n\tcase DUK_TAG_OBJECT: {\n\t\tduk_hobject *h = DUK_TVAL_GET_OBJECT(tv);\n\t\tDUK_ASSERT(h != NULL);\n\n\t\t/* Function values are handled completely above (including\n\t\t * coercion results):\n\t\t */\n\t\tDUK_ASSERT(!DUK_HOBJECT_IS_CALLABLE(h));\n\n\t\tif (DUK_HOBJECT_GET_CLASS_NUMBER(h) == DUK_HOBJECT_CLASS_ARRAY) {\n\t\t\tduk__enc_array(js_ctx);\n\t\t} else {\n\t\t\tduk__enc_object(js_ctx);\n\t\t}\n\t\tbreak;\n\t}\n\t/* Because plain buffers mimics Uint8Array, they have enumerable\n\t * index properties [0,byteLength[.  Because JSON only serializes\n\t * enumerable own properties, no properties can be serialized for\n\t * plain buffers (all virtual properties are non-enumerable).  However,\n\t * there may be a .toJSON() method which was already handled above.\n\t */\n\tcase DUK_TAG_BUFFER: {\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n\t\tif (js_ctx->flag_ext_custom_or_compatible) {\n\t\t\tduk__enc_buffer_jx_jc(js_ctx, DUK_TVAL_GET_BUFFER(tv));\n\t\t\tbreak;\n\t\t}\n#endif\n\n\t\t/* Could implement a fastpath, but the fast path would need\n\t\t * to handle realloc side effects correctly.\n\t\t */\n\t\tduk_to_object(ctx, -1);\n\t\tduk__enc_object(js_ctx);\n\t\tbreak;\n\t}\n\tcase DUK_TAG_LIGHTFUNC: {\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n\t\t/* We only get here when doing non-standard JSON encoding */\n\t\tDUK_ASSERT(js_ctx->flag_ext_custom || js_ctx->flag_ext_compatible);\n\t\tDUK__EMIT_STRIDX(js_ctx, js_ctx->stridx_custom_function);\n#else\n\t\t/* Standard JSON omits functions */\n\t\tDUK_UNREACHABLE();\n#endif\n\t\tbreak;\n\t}\n#if defined(DUK_USE_FASTINT)\n\tcase DUK_TAG_FASTINT:\n\t\t/* Number serialization has a significant impact relative to\n\t\t * other fast path code, so careful fast path for fastints.\n\t\t */\n\t\tduk__enc_fastint_tval(js_ctx, tv);\n\t\tbreak;\n#endif\n\tdefault: {\n\t\t/* number */\n\t\tDUK_ASSERT(!DUK_TVAL_IS_UNUSED(tv));\n\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv));\n\t\t/* XXX: A fast path for usual integers would be useful when\n\t\t * fastint support is not enabled.\n\t\t */\n\t\tduk__enc_double(js_ctx);\n\t\tbreak;\n\t}\n\t}\n\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n pop2_emitted:\n#endif\n\tduk_pop_2(ctx); /* [ ... key val ] -> [ ... ] */\n\treturn 1;  /* emitted */\n\n pop2_undef:\n\tduk_pop_2(ctx);  /* [ ... key val ] -> [ ... ] */\n\treturn 0;  /* not emitted */\n}\n\n/* E5 Section 15.12.3, main algorithm, step 4.b.ii steps 1-4. */\nDUK_LOCAL duk_bool_t duk__enc_allow_into_proplist(duk_tval *tv) {\n\tduk_small_int_t c;\n\n\t/* XXX: some kind of external internal type checker?\n\t * - type mask; symbol flag; class mask\n\t */\n\tDUK_ASSERT(tv != NULL);\n\tif (DUK_TVAL_IS_STRING(tv)) {\n\t\tduk_hstring *h;\n\t\th = DUK_TVAL_GET_STRING(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\tif (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) {\n\t\t\treturn 0;\n\t\t}\n\t\treturn 1;\n\t} else if (DUK_TVAL_IS_NUMBER(tv)) {\n\t\treturn 1;\n\t} else if (DUK_TVAL_IS_OBJECT(tv)) {\n\t\tduk_hobject *h;\n\t\th = DUK_TVAL_GET_OBJECT(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\tc = (duk_small_int_t) DUK_HOBJECT_GET_CLASS_NUMBER(h);\n\t\tif (c == DUK_HOBJECT_CLASS_STRING || c == DUK_HOBJECT_CLASS_NUMBER) {\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\n/*\n *  JSON.stringify() fast path\n *\n *  Otherwise supports full JSON, JX, and JC features, but bails out on any\n *  possible side effect which might change the value being serialized.  The\n *  fast path can take advantage of the fact that the value being serialized\n *  is unchanged so that we can walk directly through property tables etc.\n */\n\n#if defined(DUK_USE_JSON_STRINGIFY_FASTPATH)\nDUK_LOCAL duk_bool_t duk__json_stringify_fast_value(duk_json_enc_ctx *js_ctx, duk_tval *tv) {\n\tduk_uint_fast32_t i, n;\n\n\tDUK_DDD(DUK_DDDPRINT(\"stringify fast: %!T\", tv));\n\n\tDUK_ASSERT(js_ctx != NULL);\n\tDUK_ASSERT(js_ctx->thr != NULL);\n\n#if 0 /* disabled for now */\n restart_match:\n#endif\n\n\tDUK_ASSERT(tv != NULL);\n\n\tswitch (DUK_TVAL_GET_TAG(tv)) {\n\tcase DUK_TAG_UNDEFINED: {\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n\t\tif (js_ctx->flag_ext_custom || js_ctx->flag_ext_compatible) {\n\t\t\tDUK__EMIT_STRIDX(js_ctx, js_ctx->stridx_custom_undefined);\n\t\t\tbreak;\n\t\t} else {\n\t\t\tgoto emit_undefined;\n\t\t}\n#else\n\t\tgoto emit_undefined;\n#endif\n\t}\n\tcase DUK_TAG_NULL: {\n\t\tDUK__EMIT_STRIDX(js_ctx, DUK_STRIDX_LC_NULL);\n\t\tbreak;\n\t}\n\tcase DUK_TAG_BOOLEAN: {\n\t\tDUK__EMIT_STRIDX(js_ctx, DUK_TVAL_GET_BOOLEAN(tv) ?\n\t\t                 DUK_STRIDX_TRUE : DUK_STRIDX_FALSE);\n\t\tbreak;\n\t}\n\tcase DUK_TAG_STRING: {\n\t\tduk_hstring *h;\n\t\th = DUK_TVAL_GET_STRING(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\tif (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) {\n\t\t\tgoto emit_undefined;\n\t\t}\n\t\tduk__enc_quote_string(js_ctx, h);\n\t\tbreak;\n\t}\n\tcase DUK_TAG_OBJECT: {\n\t\tduk_hobject *obj;\n\t\tduk_tval *tv_val;\n\t\tduk_bool_t emitted = 0;\n\t\tduk_uint32_t c_bit, c_all, c_array, c_unbox, c_undef,\n\t\t             c_func, c_bufobj, c_object, c_abort;\n\n\t\t/* For objects JSON.stringify() only looks for own, enumerable\n\t\t * properties which is nice for the fast path here.\n\t\t *\n\t\t * For arrays JSON.stringify() uses [[Get]] so it will actually\n\t\t * inherit properties during serialization!  This fast path\n\t\t * supports gappy arrays as long as there's no actual inherited\n\t\t * property (which might be a getter etc).\n\t\t *\n\t\t * Since recursion only happens for objects, we can have both\n\t\t * recursion and loop checks here.  We use a simple, depth-limited\n\t\t * loop check in the fast path because the object-based tracking\n\t\t * is very slow (when tested, it accounted for 50% of fast path\n\t\t * execution time for input data with a lot of small objects!).\n\t\t */\n\n\t\t/* XXX: for real world code, could just ignore array inheritance\n\t\t * and only look at array own properties.\n\t\t */\n\n\t\t/* We rely on a few object flag / class number relationships here,\n\t\t * assert for them.\n\t\t */\n\n\t\tobj = DUK_TVAL_GET_OBJECT(tv);\n\t\tDUK_ASSERT(obj != NULL);\n\t\tDUK_ASSERT_HOBJECT_VALID(obj);\n\n\t\t/* Once recursion depth is increased, exit path must decrease\n\t\t * it (though it's OK to abort the fast path).\n\t\t */\n\n\t\tDUK_ASSERT(js_ctx->recursion_depth >= 0);\n\t\tDUK_ASSERT(js_ctx->recursion_depth <= js_ctx->recursion_limit);\n\t\tif (js_ctx->recursion_depth >= js_ctx->recursion_limit) {\n\t\t\tDUK_DD(DUK_DDPRINT(\"fast path recursion limit\"));\n\t\t\tDUK_ERROR_RANGE(js_ctx->thr, DUK_STR_JSONDEC_RECLIMIT);\n\t\t}\n\n\t\tfor (i = 0, n = (duk_uint_fast32_t) js_ctx->recursion_depth; i < n; i++) {\n\t\t\tif (DUK_UNLIKELY(js_ctx->visiting[i] == obj)) {\n\t\t\t\tDUK_DD(DUK_DDPRINT(\"fast path loop detect\"));\n\t\t\t\tDUK_ERROR_TYPE(js_ctx->thr, DUK_STR_CYCLIC_INPUT);\n\t\t\t}\n\t\t}\n\n\t\t/* Guaranteed by recursion_limit setup so we don't have to\n\t\t * check twice.\n\t\t */\n\t\tDUK_ASSERT(js_ctx->recursion_depth < DUK_JSON_ENC_LOOPARRAY);\n\t\tjs_ctx->visiting[js_ctx->recursion_depth] = obj;\n\t\tjs_ctx->recursion_depth++;\n\n\t\t/* If object has a .toJSON() property, we can't be certain\n\t\t * that it wouldn't mutate any value arbitrarily, so bail\n\t\t * out of the fast path.\n\t\t *\n\t\t * If an object is a Proxy we also can't avoid side effects\n\t\t * so abandon.\n\t\t */\n\t\t/* XXX: non-callable .toJSON() doesn't need to cause an abort\n\t\t * but does at the moment, probably not worth fixing.\n\t\t */\n\t\tif (duk_hobject_hasprop_raw(js_ctx->thr, obj, DUK_HTHREAD_STRING_TO_JSON(js_ctx->thr)) ||\n\t\t    DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(obj)) {\n\t\t\tDUK_DD(DUK_DDPRINT(\"object has a .toJSON property or object is a Proxy, abort fast path\"));\n\t\t\tgoto abort_fastpath;\n\t\t}\n\n\t\t/* We could use a switch-case for the class number but it turns out\n\t\t * a small if-else ladder on class masks is better.  The if-ladder\n\t\t * should be in order of relevancy.\n\t\t */\n\n\t\t/* XXX: move masks to js_ctx? they don't change during one\n\t\t * fast path invocation.\n\t\t */\n\t\tDUK_ASSERT(DUK_HOBJECT_CLASS_MAX <= 31);\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n\t\tif (js_ctx->flag_ext_custom_or_compatible) {\n\t\t\tc_all = DUK_HOBJECT_CMASK_ALL;\n\t\t\tc_array = DUK_HOBJECT_CMASK_ARRAY;\n\t\t\tc_unbox = DUK_HOBJECT_CMASK_NUMBER |\n\t\t\t          DUK_HOBJECT_CMASK_STRING |\n\t\t\t          DUK_HOBJECT_CMASK_BOOLEAN |\n\t\t\t          DUK_HOBJECT_CMASK_POINTER;  /* Symbols are not unboxed. */\n\t\t\tc_func = DUK_HOBJECT_CMASK_FUNCTION;\n\t\t\tc_bufobj = DUK_HOBJECT_CMASK_ALL_BUFOBJS;\n\t\t\tc_undef = 0;\n\t\t\tc_abort = 0;\n\t\t\tc_object = c_all & ~(c_array | c_unbox | c_func | c_bufobj | c_undef | c_abort);\n\t\t}\n\t\telse\n#endif\n\t\t{\n\t\t\tc_all = DUK_HOBJECT_CMASK_ALL;\n\t\t\tc_array = DUK_HOBJECT_CMASK_ARRAY;\n\t\t\tc_unbox = DUK_HOBJECT_CMASK_NUMBER |\n\t\t\t          DUK_HOBJECT_CMASK_STRING |\n\t\t\t          DUK_HOBJECT_CMASK_BOOLEAN;  /* Symbols are not unboxed. */\n\t\t\tc_func = 0;\n\t\t\tc_bufobj = 0;\n\t\t\tc_undef = DUK_HOBJECT_CMASK_FUNCTION |\n\t\t\t          DUK_HOBJECT_CMASK_POINTER;\n\t\t\t/* As the fast path doesn't currently properly support\n\t\t\t * duk_hbufobj virtual properties, abort fast path if\n\t\t\t * we encounter them in plain JSON mode.\n\t\t\t */\n\t\t\tc_abort = DUK_HOBJECT_CMASK_ALL_BUFOBJS;\n\t\t\tc_object = c_all & ~(c_array | c_unbox | c_func | c_bufobj | c_undef | c_abort);\n\t\t}\n\n\t\tc_bit = DUK_HOBJECT_GET_CLASS_MASK(obj);\n\t\tif (c_bit & c_object) {\n\t\t\t/* All other object types. */\n\t\t\tDUK__EMIT_1(js_ctx, DUK_ASC_LCURLY);\n\n\t\t\t/* A non-Array object should not have an array part in practice.\n\t\t\t * But since it is supported internally (and perhaps used at some\n\t\t\t * point), check and abandon if that's the case.\n\t\t\t */\n\t\t\tif (DUK_HOBJECT_HAS_ARRAY_PART(obj)) {\n\t\t\t\tDUK_DD(DUK_DDPRINT(\"non-Array object has array part, abort fast path\"));\n\t\t\t\tgoto abort_fastpath;\n\t\t\t}\n\n\t\t\tfor (i = 0; i < (duk_uint_fast32_t) DUK_HOBJECT_GET_ENEXT(obj); i++) {\n\t\t\t\tduk_hstring *k;\n\t\t\t\tduk_size_t prev_size;\n\n\t\t\t\tk = DUK_HOBJECT_E_GET_KEY(js_ctx->thr->heap, obj, i);\n\t\t\t\tif (!k) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (DUK_HSTRING_HAS_ARRIDX(k)) {\n\t\t\t\t\t/* If an object has array index keys we would need\n\t\t\t\t\t * to sort them into the ES2015 enumeration order to\n\t\t\t\t\t * be consistent with the slow path.  Abort the fast\n\t\t\t\t\t * path and handle in the slow path for now.\n\t\t\t\t\t */\n\t\t\t\t\tDUK_DD(DUK_DDPRINT(\"property key is an array index, abort fast path\"));\n\t\t\t\t\tgoto abort_fastpath;\n\t\t\t\t}\n\t\t\t\tif (!DUK_HOBJECT_E_SLOT_IS_ENUMERABLE(js_ctx->thr->heap, obj, i)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (DUK_HOBJECT_E_SLOT_IS_ACCESSOR(js_ctx->thr->heap, obj, i)) {\n\t\t\t\t\t/* Getter might have arbitrary side effects,\n\t\t\t\t\t * so bail out.\n\t\t\t\t\t */\n\t\t\t\t\tDUK_DD(DUK_DDPRINT(\"property is an accessor, abort fast path\"));\n\t\t\t\t\tgoto abort_fastpath;\n\t\t\t\t}\n\t\t\t\tif (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(k))) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\ttv_val = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(js_ctx->thr->heap, obj, i);\n\n\t\t\t\tprev_size = DUK_BW_GET_SIZE(js_ctx->thr, &js_ctx->bw);\n\t\t\t\tif (DUK_UNLIKELY(js_ctx->h_gap != NULL)) {\n\t\t\t\t\tduk__enc_newline_indent(js_ctx, js_ctx->recursion_depth);\n\t\t\t\t\tduk__enc_key_autoquote(js_ctx, k);\n\t\t\t\t\tDUK__EMIT_2(js_ctx, DUK_ASC_COLON, DUK_ASC_SPACE);\n\t\t\t\t} else {\n\t\t\t\t\tduk__enc_key_autoquote(js_ctx, k);\n\t\t\t\t\tDUK__EMIT_1(js_ctx, DUK_ASC_COLON);\n\t\t\t\t}\n\n\t\t\t\tif (duk__json_stringify_fast_value(js_ctx, tv_val) == 0) {\n\t\t\t\t\tDUK_DD(DUK_DDPRINT(\"prop value not supported, rewind key and colon\"));\n\t\t\t\t\tDUK_BW_SET_SIZE(js_ctx->thr, &js_ctx->bw, prev_size);\n\t\t\t\t} else {\n\t\t\t\t\tDUK__EMIT_1(js_ctx, DUK_ASC_COMMA);\n\t\t\t\t\temitted = 1;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/* If any non-Array value had enumerable virtual own\n\t\t\t * properties, they should be serialized here (actually,\n\t\t\t * before the explicit properties).  Standard types don't.\n\t\t\t */\n\n\t\t\tif (emitted) {\n\t\t\t\tDUK_ASSERT(*((duk_uint8_t *) DUK_BW_GET_PTR(js_ctx->thr, &js_ctx->bw) - 1) == DUK_ASC_COMMA);\n\t\t\t\tDUK__UNEMIT_1(js_ctx);  /* eat trailing comma */\n\t\t\t\tif (DUK_UNLIKELY(js_ctx->h_gap != NULL)) {\n\t\t\t\t\tDUK_ASSERT(js_ctx->recursion_depth >= 1);\n\t\t\t\t\tduk__enc_newline_indent(js_ctx, js_ctx->recursion_depth - 1);\n\t\t\t\t}\n\t\t\t}\n\t\t\tDUK__EMIT_1(js_ctx, DUK_ASC_RCURLY);\n\t\t} else if (c_bit & c_array) {\n\t\t\tduk_uint_fast32_t arr_len;\n\t\t\tduk_uint_fast32_t asize;\n\n\t\t\tDUK__EMIT_1(js_ctx, DUK_ASC_LBRACKET);\n\n\t\t\t/* Assume arrays are dense in the fast path. */\n\t\t\tif (!DUK_HOBJECT_HAS_ARRAY_PART(obj)) {\n\t\t\t\tDUK_DD(DUK_DDPRINT(\"Array object is sparse, abort fast path\"));\n\t\t\t\tgoto abort_fastpath;\n\t\t\t}\n\n\t\t\tarr_len = (duk_uint_fast32_t) ((duk_harray *) obj)->length;\n\t\t\tasize = (duk_uint_fast32_t) DUK_HOBJECT_GET_ASIZE(obj);\n\t\t\t/* Array part may be larger than 'length'; if so, iterate\n\t\t\t * only up to array 'length'.  Array part may also be smaller\n\t\t\t * than 'length' in some cases.\n\t\t\t */\n\t\t\tfor (i = 0; i < arr_len; i++) {\n\t\t\t\tduk_tval *tv_arrval;\n\t\t\t\tduk_hstring *h_tmp;\n\t\t\t\tduk_bool_t has_inherited;\n\n\t\t\t\tif (DUK_UNLIKELY(js_ctx->h_gap != NULL)) {\n\t\t\t\t\tduk__enc_newline_indent(js_ctx, js_ctx->recursion_depth);\n\t\t\t\t}\n\n\t\t\t\tif (DUK_LIKELY(i < asize)) {\n\t\t\t\t\ttv_arrval = DUK_HOBJECT_A_GET_VALUE_PTR(js_ctx->thr->heap, obj, i);\n\t\t\t\t\tif (DUK_LIKELY(!DUK_TVAL_IS_UNUSED(tv_arrval))) {\n\t\t\t\t\t\t/* Expected case: element is present. */\n\t\t\t\t\t\tif (duk__json_stringify_fast_value(js_ctx, tv_arrval) == 0) {\n\t\t\t\t\t\t\tDUK__EMIT_STRIDX(js_ctx, DUK_STRIDX_LC_NULL);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tgoto elem_done;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t/* Gap in array; check for inherited property,\n\t\t\t\t * bail out if one exists.  This should be enough\n\t\t\t\t * to support gappy arrays for all practical code.\n\t\t\t\t */\n\n\t\t\t\th_tmp = duk_push_uint_to_hstring((duk_context *) js_ctx->thr, (duk_uint_t) i);\n\t\t\t\thas_inherited = duk_hobject_hasprop_raw(js_ctx->thr, obj, h_tmp);\n\t\t\t\tduk_pop((duk_context *) js_ctx->thr);\n\t\t\t\tif (has_inherited) {\n\t\t\t\t\tDUK_D(DUK_DPRINT(\"gap in array, conflicting inherited property, abort fast path\"));\n\t\t\t\t\tgoto abort_fastpath;\n\t\t\t\t}\n\n\t\t\t\t/* Ordinary gap, undefined encodes to 'null' in\n\t\t\t\t * standard JSON, but JX/JC use their form for\n\t\t\t\t * undefined to better preserve the typing.\n\t\t\t\t */\n\t\t\t\tDUK_D(DUK_DPRINT(\"gap in array, no conflicting inherited property, remain on fast path\"));\n#if defined(DUK_USE_JX)\n\t\t\t\tDUK__EMIT_STRIDX(js_ctx, js_ctx->stridx_custom_undefined);\n#else\n\t\t\t\tDUK__EMIT_STRIDX(js_ctx, DUK_STRIDX_LC_NULL);\n#endif\n\t\t\t\t/* fall through */\n\n\t\t\t elem_done:\n\t\t\t\tDUK__EMIT_1(js_ctx, DUK_ASC_COMMA);\n\t\t\t\temitted = 1;\n\t\t\t}\n\n\t\t\tif (emitted) {\n\t\t\t\tDUK_ASSERT(*((duk_uint8_t *) DUK_BW_GET_PTR(js_ctx->thr, &js_ctx->bw) - 1) == DUK_ASC_COMMA);\n\t\t\t\tDUK__UNEMIT_1(js_ctx);  /* eat trailing comma */\n\t\t\t\tif (DUK_UNLIKELY(js_ctx->h_gap != NULL)) {\n\t\t\t\t\tDUK_ASSERT(js_ctx->recursion_depth >= 1);\n\t\t\t\t\tduk__enc_newline_indent(js_ctx, js_ctx->recursion_depth - 1);\n\t\t\t\t}\n\t\t\t}\n\t\t\tDUK__EMIT_1(js_ctx, DUK_ASC_RBRACKET);\n\t\t} else if (c_bit & c_unbox) {\n\t\t\t/* Certain boxed types are required to go through\n\t\t\t * automatic unboxing.  Rely on internal value being\n\t\t\t * sane (to avoid infinite recursion).\n\t\t\t */\n\t\t\tDUK_ASSERT((c_bit & DUK_HOBJECT_CMASK_SYMBOL) == 0);  /* Symbols are not unboxed. */\n\n#if 1\n\t\t\t/* The code below is incorrect if .toString() or .valueOf() have\n\t\t\t * have been overridden.  The correct approach would be to look up\n\t\t\t * the method(s) and if they resolve to the built-in function we\n\t\t\t * can safely bypass it and look up the internal value directly.\n\t\t\t * Unimplemented for now, abort fast path for boxed values.\n\t\t\t */\n\t\t\tgoto abort_fastpath;\n#else  /* disabled */\n\t\t\t/* Disabled until fixed, see above. */\n\t\t\tduk_tval *tv_internal;\n\n\t\t\tDUK_DD(DUK_DDPRINT(\"auto unboxing in fast path\"));\n\n\t\t\ttv_internal = duk_hobject_get_internal_value_tval_ptr(js_ctx->thr->heap, obj);\n\t\t\tDUK_ASSERT(tv_internal != NULL);\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_STRING(tv_internal) ||\n\t\t\t           DUK_TVAL_IS_NUMBER(tv_internal) ||\n\t\t\t           DUK_TVAL_IS_BOOLEAN(tv_internal) ||\n\t\t\t           DUK_TVAL_IS_POINTER(tv_internal));\n\n\t\t\ttv = tv_internal;\n\t\t\tDUK_ASSERT(js_ctx->recursion_depth > 0);\n\t\t\tjs_ctx->recursion_depth--;  /* required to keep recursion depth correct */\n\t\t\tgoto restart_match;\n#endif  /* disabled */\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n\t\t} else if (c_bit & c_func) {\n\t\t\tDUK__EMIT_STRIDX(js_ctx, js_ctx->stridx_custom_function);\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n\t\t} else if (c_bit & c_bufobj) {\n\t\t\tduk__enc_bufobj(js_ctx, (duk_hbufobj *) obj);\n#endif\n#endif\n\t\t} else if (c_bit & c_abort) {\n\t\t\tDUK_DD(DUK_DDPRINT(\"abort fast path for unsupported type\"));\n\t\t\tgoto abort_fastpath;\n\t\t} else {\n\t\t\tDUK_ASSERT((c_bit & c_undef) != 0);\n\n\t\t\t/* Must decrease recursion depth before returning. */\n\t\t\tDUK_ASSERT(js_ctx->recursion_depth > 0);\n\t\t\tDUK_ASSERT(js_ctx->recursion_depth <= js_ctx->recursion_limit);\n\t\t\tjs_ctx->recursion_depth--;\n\t\t\tgoto emit_undefined;\n\t\t}\n\n\t\tDUK_ASSERT(js_ctx->recursion_depth > 0);\n\t\tDUK_ASSERT(js_ctx->recursion_depth <= js_ctx->recursion_limit);\n\t\tjs_ctx->recursion_depth--;\n\t\tbreak;\n\t}\n\tcase DUK_TAG_BUFFER: {\n\t\t/* Plain buffers are treated like Uint8Arrays: they have\n\t\t * enumerable indices.  Other virtual properties are not\n\t\t * enumerable, and inherited properties are not serialized.\n\t\t * However, there can be a replacer (not relevant here) or\n\t\t * a .toJSON() method (which we need to check for explicitly).\n\t\t */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n\t\tif (duk_hobject_hasprop_raw(js_ctx->thr,\n\t\t                            js_ctx->thr->builtins[DUK_BIDX_UINT8ARRAY_PROTOTYPE],\n\t\t                            DUK_HTHREAD_STRING_TO_JSON(js_ctx->thr))) {\n\t\t\tDUK_DD(DUK_DDPRINT(\"value is a plain buffer and there's an inherited .toJSON, abort fast path\"));\n\t\t\tgoto abort_fastpath;\n\t\t}\n#endif\n\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n\t\tif (js_ctx->flag_ext_custom_or_compatible) {\n\t\t\tduk__enc_buffer_jx_jc(js_ctx, DUK_TVAL_GET_BUFFER(tv));\n\t\t\tbreak;\n\t\t}\n#endif\n\n\t\t/* Plain buffers mimic Uint8Arrays, and have enumerable index\n\t\t * properties.\n\t\t */\n\t\tduk__enc_buffer_json_fastpath(js_ctx, DUK_TVAL_GET_BUFFER(tv));\n\t\tbreak;\n\t}\n\tcase DUK_TAG_POINTER: {\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n\t\tif (js_ctx->flag_ext_custom_or_compatible) {\n\t\t\tduk__enc_pointer(js_ctx, DUK_TVAL_GET_POINTER(tv));\n\t\t\tbreak;\n\t\t} else {\n\t\t\tgoto emit_undefined;\n\t\t}\n#else\n\t\tgoto emit_undefined;\n#endif\n\t}\n\tcase DUK_TAG_LIGHTFUNC: {\n\t\t/* A lightfunc might also inherit a .toJSON() so just bail out. */\n\t\t/* XXX: Could just lookup .toJSON() and continue in fast path,\n\t\t * as it would almost never be defined.\n\t\t */\n\t\tDUK_DD(DUK_DDPRINT(\"value is a lightfunc, abort fast path\"));\n\t\tgoto abort_fastpath;\n\t}\n#if defined(DUK_USE_FASTINT)\n\tcase DUK_TAG_FASTINT: {\n\t\t/* Number serialization has a significant impact relative to\n\t\t * other fast path code, so careful fast path for fastints.\n\t\t */\n\t\tduk__enc_fastint_tval(js_ctx, tv);\n\t\tbreak;\n\t}\n#endif\n\tdefault: {\n\t\t/* XXX: A fast path for usual integers would be useful when\n\t\t * fastint support is not enabled.\n\t\t */\n\t\tDUK_ASSERT(!DUK_TVAL_IS_UNUSED(tv));\n\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv));\n\n\t\t/* XXX: Stack discipline is annoying, could be changed in numconv. */\n\t\tduk_push_tval((duk_context *) js_ctx->thr, tv);\n\t\tduk__enc_double(js_ctx);\n\t\tduk_pop((duk_context *) js_ctx->thr);\n\n#if 0\n\t\t/* Could also rely on native sprintf(), but it will handle\n\t\t * values like NaN, Infinity, -0, exponent notation etc in\n\t\t * a JSON-incompatible way.\n\t\t */\n\t\tduk_double_t d;\n\t\tchar buf[64];\n\n\t\tDUK_ASSERT(DUK_TVAL_IS_DOUBLE(tv));\n\t\td = DUK_TVAL_GET_DOUBLE(tv);\n\t\tDUK_SPRINTF(buf, \"%lg\", d);\n\t\tDUK__EMIT_CSTR(js_ctx, buf);\n#endif\n\t}\n\t}\n\treturn 1;  /* not undefined */\n\n emit_undefined:\n\treturn 0;  /* value was undefined/unsupported */\n\n abort_fastpath:\n\t/* Error message doesn't matter: the error is ignored anyway. */\n\tDUK_DD(DUK_DDPRINT(\"aborting fast path\"));\n\tDUK_ERROR_INTERNAL(js_ctx->thr);\n\treturn 0;  /* unreachable */\n}\n\nDUK_LOCAL duk_ret_t duk__json_stringify_fast(duk_context *ctx, void *udata) {\n\tduk_json_enc_ctx *js_ctx;\n\tduk_tval *tv;\n\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(udata != NULL);\n\n\tjs_ctx = (duk_json_enc_ctx *) udata;\n\tDUK_ASSERT(js_ctx != NULL);\n\n\ttv = DUK_GET_TVAL_NEGIDX(ctx, -1);\n\tif (duk__json_stringify_fast_value(js_ctx, tv) == 0) {\n\t\tDUK_DD(DUK_DDPRINT(\"top level value not supported, fail fast path\"));\n\t\tDUK_DCERROR_TYPE_INVALID_ARGS((duk_hthread *) ctx);  /* Error message is ignored, so doesn't matter. */\n\t}\n\n\treturn 0;\n}\n#endif  /* DUK_USE_JSON_STRINGIFY_FASTPATH */\n\n/*\n *  Top level wrappers\n */\n\nDUK_INTERNAL\nvoid duk_bi_json_parse_helper(duk_context *ctx,\n                              duk_idx_t idx_value,\n                              duk_idx_t idx_reviver,\n                              duk_small_uint_t flags) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_json_dec_ctx js_ctx_alloc;\n\tduk_json_dec_ctx *js_ctx = &js_ctx_alloc;\n\tduk_hstring *h_text;\n#if defined(DUK_USE_ASSERTIONS)\n\tduk_idx_t entry_top = duk_get_top(ctx);\n#endif\n\n\t/* negative top-relative indices not allowed now */\n\tDUK_ASSERT(idx_value == DUK_INVALID_INDEX || idx_value >= 0);\n\tDUK_ASSERT(idx_reviver == DUK_INVALID_INDEX || idx_reviver >= 0);\n\n\tDUK_DDD(DUK_DDDPRINT(\"JSON parse start: text=%!T, reviver=%!T, flags=0x%08lx, stack_top=%ld\",\n\t                     (duk_tval *) duk_get_tval(ctx, idx_value),\n\t                     (duk_tval *) duk_get_tval(ctx, idx_reviver),\n\t                     (unsigned long) flags,\n\t                     (long) duk_get_top(ctx)));\n\n\tDUK_MEMZERO(&js_ctx_alloc, sizeof(js_ctx_alloc));\n\tjs_ctx->thr = thr;\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n\t/* nothing now */\n#endif\n\tjs_ctx->recursion_limit = DUK_USE_JSON_DEC_RECLIMIT;\n\tDUK_ASSERT(js_ctx->recursion_depth == 0);\n\n\t/* Flag handling currently assumes that flags are consistent.  This is OK\n\t * because the call sites are now strictly controlled.\n\t */\n\n\tjs_ctx->flags = flags;\n#if defined(DUK_USE_JX)\n\tjs_ctx->flag_ext_custom = flags & DUK_JSON_FLAG_EXT_CUSTOM;\n#endif\n#if defined(DUK_USE_JC)\n\tjs_ctx->flag_ext_compatible = flags & DUK_JSON_FLAG_EXT_COMPATIBLE;\n#endif\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n\tjs_ctx->flag_ext_custom_or_compatible = flags & (DUK_JSON_FLAG_EXT_CUSTOM | DUK_JSON_FLAG_EXT_COMPATIBLE);\n#endif\n\n\th_text = duk_to_hstring(ctx, idx_value);  /* coerce in-place; rejects Symbols */\n\tDUK_ASSERT(h_text != NULL);\n\n\t/* JSON parsing code is allowed to read [p_start,p_end]: p_end is\n\t * valid and points to the string NUL terminator (which is always\n\t * guaranteed for duk_hstrings.\n\t */\n\tjs_ctx->p_start = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_text);\n\tjs_ctx->p = js_ctx->p_start;\n\tjs_ctx->p_end = ((const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_text)) +\n\t                DUK_HSTRING_GET_BYTELEN(h_text);\n\tDUK_ASSERT(*(js_ctx->p_end) == 0x00);\n\n\tduk__dec_value(js_ctx);  /* -> [ ... value ] */\n\n\t/* Trailing whitespace has been eaten by duk__dec_value(), so if\n\t * we're not at end of input here, it's a SyntaxError.\n\t */\n\n\tif (js_ctx->p != js_ctx->p_end) {\n\t\tduk__dec_syntax_error(js_ctx);\n\t}\n\n\tif (duk_is_callable(ctx, idx_reviver)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"applying reviver: %!T\",\n\t\t                     (duk_tval *) duk_get_tval(ctx, idx_reviver)));\n\n\t\tjs_ctx->idx_reviver = idx_reviver;\n\n\t\tduk_push_object(ctx);\n\t\tduk_dup_m2(ctx);  /* -> [ ... val root val ] */\n\t\tduk_put_prop_stridx_short(ctx, -2, DUK_STRIDX_EMPTY_STRING);  /* default attrs ok */\n\t\tduk_push_hstring_stridx(ctx, DUK_STRIDX_EMPTY_STRING);  /* -> [ ... val root \"\" ] */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"start reviver walk, root=%!T, name=%!T\",\n\t\t                     (duk_tval *) duk_get_tval(ctx, -2),\n\t\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\n\t\tduk__dec_reviver_walk(js_ctx);  /* [ ... val root \"\" ] -> [ ... val val' ] */\n\t\tduk_remove_m2(ctx);             /* -> [ ... val' ] */\n\t} else {\n\t\tDUK_DDD(DUK_DDDPRINT(\"reviver does not exist or is not callable: %!T\",\n\t\t                     (duk_tval *) duk_get_tval(ctx, idx_reviver)));\n\t}\n\n\t/* Final result is at stack top. */\n\n\tDUK_DDD(DUK_DDDPRINT(\"JSON parse end: text=%!T, reviver=%!T, flags=0x%08lx, result=%!T, stack_top=%ld\",\n\t                     (duk_tval *) duk_get_tval(ctx, idx_value),\n\t                     (duk_tval *) duk_get_tval(ctx, idx_reviver),\n\t                     (unsigned long) flags,\n\t                     (duk_tval *) duk_get_tval(ctx, -1),\n\t                     (long) duk_get_top(ctx)));\n\n\tDUK_ASSERT(duk_get_top(ctx) == entry_top + 1);\n}\n\nDUK_INTERNAL\nvoid duk_bi_json_stringify_helper(duk_context *ctx,\n                                  duk_idx_t idx_value,\n                                  duk_idx_t idx_replacer,\n                                  duk_idx_t idx_space,\n                                  duk_small_uint_t flags) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_json_enc_ctx js_ctx_alloc;\n\tduk_json_enc_ctx *js_ctx = &js_ctx_alloc;\n\tduk_hobject *h;\n\tduk_idx_t idx_holder;\n\tduk_idx_t entry_top;\n\n\t/* negative top-relative indices not allowed now */\n\tDUK_ASSERT(idx_value == DUK_INVALID_INDEX || idx_value >= 0);\n\tDUK_ASSERT(idx_replacer == DUK_INVALID_INDEX || idx_replacer >= 0);\n\tDUK_ASSERT(idx_space == DUK_INVALID_INDEX || idx_space >= 0);\n\n\tDUK_DDD(DUK_DDDPRINT(\"JSON stringify start: value=%!T, replacer=%!T, space=%!T, flags=0x%08lx, stack_top=%ld\",\n\t                     (duk_tval *) duk_get_tval(ctx, idx_value),\n\t                     (duk_tval *) duk_get_tval(ctx, idx_replacer),\n\t                     (duk_tval *) duk_get_tval(ctx, idx_space),\n\t                     (unsigned long) flags,\n\t                     (long) duk_get_top(ctx)));\n\n\tentry_top = duk_get_top(ctx);\n\n\t/*\n\t *  Context init\n\t */\n\n\tDUK_MEMZERO(&js_ctx_alloc, sizeof(js_ctx_alloc));\n\tjs_ctx->thr = thr;\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n\tjs_ctx->h_replacer = NULL;\n\tjs_ctx->h_gap = NULL;\n#endif\n\tjs_ctx->idx_proplist = -1;\n\n\t/* Flag handling currently assumes that flags are consistent.  This is OK\n\t * because the call sites are now strictly controlled.\n\t */\n\n\tjs_ctx->flags = flags;\n\tjs_ctx->flag_ascii_only = flags & DUK_JSON_FLAG_ASCII_ONLY;\n\tjs_ctx->flag_avoid_key_quotes = flags & DUK_JSON_FLAG_AVOID_KEY_QUOTES;\n#if defined(DUK_USE_JX)\n\tjs_ctx->flag_ext_custom = flags & DUK_JSON_FLAG_EXT_CUSTOM;\n#endif\n#if defined(DUK_USE_JC)\n\tjs_ctx->flag_ext_compatible = flags & DUK_JSON_FLAG_EXT_COMPATIBLE;\n#endif\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n\tjs_ctx->flag_ext_custom_or_compatible = flags & (DUK_JSON_FLAG_EXT_CUSTOM | DUK_JSON_FLAG_EXT_COMPATIBLE);\n#endif\n\n\t/* The #if defined() clutter here handles the JX/JC enable/disable\n\t * combinations properly.\n\t */\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n\tjs_ctx->stridx_custom_undefined = DUK_STRIDX_LC_NULL;  /* standard JSON; array gaps */\n#if defined(DUK_USE_JX)\n\tif (flags & DUK_JSON_FLAG_EXT_CUSTOM) {\n\t\tjs_ctx->stridx_custom_undefined = DUK_STRIDX_LC_UNDEFINED;\n\t\tjs_ctx->stridx_custom_nan = DUK_STRIDX_NAN;\n\t\tjs_ctx->stridx_custom_neginf = DUK_STRIDX_MINUS_INFINITY;\n\t\tjs_ctx->stridx_custom_posinf = DUK_STRIDX_INFINITY;\n\t\tjs_ctx->stridx_custom_function =\n\t\t        (flags & DUK_JSON_FLAG_AVOID_KEY_QUOTES) ?\n\t\t                DUK_STRIDX_JSON_EXT_FUNCTION2 :\n\t\t                DUK_STRIDX_JSON_EXT_FUNCTION1;\n\t}\n#endif  /* DUK_USE_JX */\n#if defined(DUK_USE_JX) && defined(DUK_USE_JC)\n\telse\n#endif  /* DUK_USE_JX && DUK_USE_JC */\n#if defined(DUK_USE_JC)\n\tif (js_ctx->flags & DUK_JSON_FLAG_EXT_COMPATIBLE) {\n\t\tjs_ctx->stridx_custom_undefined = DUK_STRIDX_JSON_EXT_UNDEFINED;\n\t\tjs_ctx->stridx_custom_nan = DUK_STRIDX_JSON_EXT_NAN;\n\t\tjs_ctx->stridx_custom_neginf = DUK_STRIDX_JSON_EXT_NEGINF;\n\t\tjs_ctx->stridx_custom_posinf = DUK_STRIDX_JSON_EXT_POSINF;\n\t\tjs_ctx->stridx_custom_function = DUK_STRIDX_JSON_EXT_FUNCTION1;\n\t}\n#endif  /* DUK_USE_JC */\n#endif  /* DUK_USE_JX || DUK_USE_JC */\n\n#if defined(DUK_USE_JX) || defined(DUK_USE_JC)\n\tif (js_ctx->flags & (DUK_JSON_FLAG_EXT_CUSTOM |\n\t                     DUK_JSON_FLAG_EXT_COMPATIBLE)) {\n\t\tDUK_ASSERT(js_ctx->mask_for_undefined == 0);  /* already zero */\n\t}\n\telse\n#endif  /* DUK_USE_JX || DUK_USE_JC */\n\t{\n\t\t/* Plain buffer is treated like ArrayBuffer and serialized.\n\t\t * Lightfuncs are treated like objects, but JSON explicitly\n\t\t * skips serializing Function objects so we can just reject\n\t\t * lightfuncs here.\n\t\t */\n\t\tjs_ctx->mask_for_undefined = DUK_TYPE_MASK_UNDEFINED |\n\t\t                             DUK_TYPE_MASK_POINTER |\n\t\t                             DUK_TYPE_MASK_LIGHTFUNC;\n\t}\n\n\tDUK_BW_INIT_PUSHBUF(thr, &js_ctx->bw, DUK__JSON_STRINGIFY_BUFSIZE);\n\n\tjs_ctx->idx_loop = duk_push_bare_object(ctx);\n\tDUK_ASSERT(js_ctx->idx_loop >= 0);\n\n\t/* [ ... buf loop ] */\n\n\t/*\n\t *  Process replacer/proplist (2nd argument to JSON.stringify)\n\t */\n\n\th = duk_get_hobject(ctx, idx_replacer);\n\tif (h != NULL) {\n\t\tif (DUK_HOBJECT_IS_CALLABLE(h)) {\n\t\t\tjs_ctx->h_replacer = h;\n\t\t} else if (DUK_HOBJECT_GET_CLASS_NUMBER(h) == DUK_HOBJECT_CLASS_ARRAY) {\n\t\t\t/* Here the specification requires correct array index enumeration\n\t\t\t * which is a bit tricky for sparse arrays (it is handled by the\n\t\t\t * enum setup code).  We now enumerate ancestors too, although the\n\t\t\t * specification is not very clear on whether that is required.\n\t\t\t */\n\n\t\t\tduk_uarridx_t plist_idx = 0;\n\t\t\tduk_small_uint_t enum_flags;\n\n\t\t\tjs_ctx->idx_proplist = duk_push_array(ctx);  /* XXX: array internal? */\n\n\t\t\tenum_flags = DUK_ENUM_ARRAY_INDICES_ONLY |\n\t\t\t             DUK_ENUM_SORT_ARRAY_INDICES;  /* expensive flag */\n\t\t\tduk_enum(ctx, idx_replacer, enum_flags);\n\t\t\twhile (duk_next(ctx, -1 /*enum_index*/, 1 /*get_value*/)) {\n\t\t\t\t/* [ ... proplist enum_obj key val ] */\n\t\t\t\tif (duk__enc_allow_into_proplist(duk_get_tval(ctx, -1))) {\n\t\t\t\t\t/* XXX: duplicates should be eliminated here */\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"proplist enum: key=%!T, val=%!T --> accept\",\n\t\t\t\t\t                     (duk_tval *) duk_get_tval(ctx, -2),\n\t\t\t\t\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\t\t\t\t\tduk_to_string(ctx, -1);  /* extra coercion of strings is OK */\n\t\t\t\t\tduk_put_prop_index(ctx, -4, plist_idx);  /* -> [ ... proplist enum_obj key ] */\n\t\t\t\t\tplist_idx++;\n\t\t\t\t\tduk_pop(ctx);\n\t\t\t\t} else {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"proplist enum: key=%!T, val=%!T --> reject\",\n\t\t\t\t\t                     (duk_tval *) duk_get_tval(ctx, -2),\n\t\t\t\t\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\t\t\t\t\tduk_pop_2(ctx);\n\t\t\t\t}\n                        }\n                        duk_pop(ctx);  /* pop enum */\n\n\t\t\t/* [ ... proplist ] */\n\t\t}\n\t}\n\n\t/* [ ... buf loop (proplist) ] */\n\n\t/*\n\t *  Process space (3rd argument to JSON.stringify)\n\t */\n\n\th = duk_get_hobject(ctx, idx_space);\n\tif (h != NULL) {\n\t\tint c = DUK_HOBJECT_GET_CLASS_NUMBER(h);\n\t\tif (c == DUK_HOBJECT_CLASS_NUMBER) {\n\t\t\tduk_to_number(ctx, idx_space);\n\t\t} else if (c == DUK_HOBJECT_CLASS_STRING) {\n\t\t\tduk_to_string(ctx, idx_space);\n\t\t}\n\t}\n\n\tif (duk_is_number(ctx, idx_space)) {\n\t\tduk_small_int_t nspace;\n\t\t/* spaces[] must be static to allow initializer with old compilers like BCC */\n\t\tstatic const char spaces[10] = {\n\t\t\tDUK_ASC_SPACE, DUK_ASC_SPACE, DUK_ASC_SPACE, DUK_ASC_SPACE,\n\t\t\tDUK_ASC_SPACE, DUK_ASC_SPACE, DUK_ASC_SPACE, DUK_ASC_SPACE,\n\t\t\tDUK_ASC_SPACE, DUK_ASC_SPACE\n\t\t};  /* XXX: helper */\n\n\t\t/* ToInteger() coercion; NaN -> 0, infinities are clamped to 0 and 10 */\n\t\tnspace = (duk_small_int_t) duk_to_int_clamped(ctx, idx_space, 0 /*minval*/, 10 /*maxval*/);\n\t\tDUK_ASSERT(nspace >= 0 && nspace <= 10);\n\n\t\tduk_push_lstring(ctx, spaces, (duk_size_t) nspace);\n\t\tjs_ctx->h_gap = duk_known_hstring(ctx, -1);\n\t\tDUK_ASSERT(js_ctx->h_gap != NULL);\n\t} else if (duk_is_string_notsymbol(ctx, idx_space)) {\n\t\tduk_dup(ctx, idx_space);\n\t\tduk_substring(ctx, -1, 0, 10);  /* clamp to 10 chars */\n\t\tjs_ctx->h_gap = duk_known_hstring(ctx, -1);\n\t} else {\n\t\t/* nop */\n\t}\n\n\tif (js_ctx->h_gap != NULL) {\n\t\t/* If gap is empty, behave as if not given at all.  Check\n\t\t * against byte length because character length is more\n\t\t * expensive.\n\t\t */\n\t\tif (DUK_HSTRING_GET_BYTELEN(js_ctx->h_gap) == 0) {\n\t\t\tjs_ctx->h_gap = NULL;\n\t\t}\n\t}\n\n\t/* [ ... buf loop (proplist) (gap) ] */\n\n\t/*\n\t *  Fast path: assume no mutation, iterate object property tables\n\t *  directly; bail out if that assumption doesn't hold.\n\t */\n\n#if defined(DUK_USE_JSON_STRINGIFY_FASTPATH)\n\tif (js_ctx->h_replacer == NULL &&  /* replacer is a mutation risk */\n\t    js_ctx->idx_proplist == -1) {  /* proplist is very rare */\n\t\tduk_int_t pcall_rc;\n\t\tduk_small_uint_t prev_ms_base_flags;\n\n\t\tDUK_DD(DUK_DDPRINT(\"try JSON.stringify() fast path\"));\n\n\t\t/* Use recursion_limit to ensure we don't overwrite js_ctx->visiting[]\n\t\t * array so we don't need two counter checks in the fast path.  The\n\t\t * slow path has a much larger recursion limit which we'll use if\n\t\t * necessary.\n\t\t */\n\t\tDUK_ASSERT(DUK_USE_JSON_ENC_RECLIMIT >= DUK_JSON_ENC_LOOPARRAY);\n\t\tjs_ctx->recursion_limit = DUK_JSON_ENC_LOOPARRAY;\n\t\tDUK_ASSERT(js_ctx->recursion_depth == 0);\n\n\t\t/* Execute the fast path in a protected call.  If any error is thrown,\n\t\t * fall back to the slow path.  This includes e.g. recursion limit\n\t\t * because the fast path has a smaller recursion limit (and simpler,\n\t\t * limited loop detection).\n\t\t */\n\n\t\tduk_dup(ctx, idx_value);\n\n\t\t/* Must prevent finalizers which may have arbitrary side effects. */\n\t\tprev_ms_base_flags = thr->heap->ms_base_flags;\n\t\tthr->heap->ms_base_flags |=\n\t\t        DUK_MS_FLAG_NO_OBJECT_COMPACTION;      /* Avoid attempt to compact any objects. */\n\t\tthr->heap->pf_prevent_count++;                 /* Prevent finalizers. */\n\t\tDUK_ASSERT(thr->heap->pf_prevent_count != 0);  /* Wrap. */\n\n\t\tpcall_rc = duk_safe_call(ctx, duk__json_stringify_fast, (void *) js_ctx /*udata*/, 1 /*nargs*/, 0 /*nret*/);\n\n\t\tDUK_ASSERT(thr->heap->pf_prevent_count > 0);\n\t\tthr->heap->pf_prevent_count--;\n\t\tthr->heap->ms_base_flags = prev_ms_base_flags;\n\n\t\tif (pcall_rc == DUK_EXEC_SUCCESS) {\n\t\t\tDUK_DD(DUK_DDPRINT(\"fast path successful\"));\n\t\t\tDUK_BW_PUSH_AS_STRING(thr, &js_ctx->bw);\n\t\t\tgoto replace_finished;\n\t\t}\n\n\t\t/* We come here for actual aborts (like encountering .toJSON())\n\t\t * but also for recursion/loop errors.  Bufwriter size can be\n\t\t * kept because we'll probably need at least as much as we've\n\t\t * allocated so far.\n\t\t */\n\t\tDUK_D(DUK_DPRINT(\"fast path failed, serialize using slow path instead\"));\n\t\tDUK_BW_RESET_SIZE(thr, &js_ctx->bw);\n\t\tjs_ctx->recursion_depth = 0;\n\t}\n#endif\n\n\t/*\n\t *  Create wrapper object and serialize\n\t */\n\n\tidx_holder = duk_push_object(ctx);\n\tduk_dup(ctx, idx_value);\n\tduk_put_prop_stridx_short(ctx, -2, DUK_STRIDX_EMPTY_STRING);\n\n\tDUK_DDD(DUK_DDDPRINT(\"before: flags=0x%08lx, loop=%!T, replacer=%!O, \"\n\t                     \"proplist=%!T, gap=%!O, holder=%!T\",\n\t                     (unsigned long) js_ctx->flags,\n\t                     (duk_tval *) duk_get_tval(ctx, js_ctx->idx_loop),\n\t                     (duk_heaphdr *) js_ctx->h_replacer,\n\t                     (duk_tval *) (js_ctx->idx_proplist >= 0 ? duk_get_tval(ctx, js_ctx->idx_proplist) : NULL),\n\t                     (duk_heaphdr *) js_ctx->h_gap,\n\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\n\t/* serialize the wrapper with empty string key */\n\n\tduk_push_hstring_empty(ctx);\n\n\t/* [ ... buf loop (proplist) (gap) holder \"\" ] */\n\n\tjs_ctx->recursion_limit = DUK_USE_JSON_ENC_RECLIMIT;\n\tDUK_ASSERT(js_ctx->recursion_depth == 0);\n\n\tif (DUK_UNLIKELY(duk__enc_value(js_ctx, idx_holder) == 0)) {  /* [ ... holder key ] -> [ ... holder ] */\n\t\t/* Result is undefined. */\n\t\tduk_push_undefined(ctx);\n\t} else {\n\t\t/* Convert buffer to result string. */\n\t\tDUK_BW_PUSH_AS_STRING(thr, &js_ctx->bw);\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"after: flags=0x%08lx, loop=%!T, replacer=%!O, \"\n\t                     \"proplist=%!T, gap=%!O, holder=%!T\",\n\t                     (unsigned long) js_ctx->flags,\n\t                     (duk_tval *) duk_get_tval(ctx, js_ctx->idx_loop),\n\t                     (duk_heaphdr *) js_ctx->h_replacer,\n\t                     (duk_tval *) (js_ctx->idx_proplist >= 0 ? duk_get_tval(ctx, js_ctx->idx_proplist) : NULL),\n\t                     (duk_heaphdr *) js_ctx->h_gap,\n\t                     (duk_tval *) duk_get_tval(ctx, idx_holder)));\n\n\t/* The stack has a variable shape here, so force it to the\n\t * desired one explicitly.\n\t */\n\n#if defined(DUK_USE_JSON_STRINGIFY_FASTPATH)\n replace_finished:\n#endif\n\tduk_replace(ctx, entry_top);\n\tduk_set_top(ctx, entry_top + 1);\n\n\tDUK_DDD(DUK_DDDPRINT(\"JSON stringify end: value=%!T, replacer=%!T, space=%!T, \"\n\t                     \"flags=0x%08lx, result=%!T, stack_top=%ld\",\n\t                     (duk_tval *) duk_get_tval(ctx, idx_value),\n\t                     (duk_tval *) duk_get_tval(ctx, idx_replacer),\n\t                     (duk_tval *) duk_get_tval(ctx, idx_space),\n\t                     (unsigned long) flags,\n\t                     (duk_tval *) duk_get_tval(ctx, -1),\n\t                     (long) duk_get_top(ctx)));\n\n\tDUK_ASSERT(duk_get_top(ctx) == entry_top + 1);\n}\n\n#if defined(DUK_USE_JSON_BUILTIN)\n\n/*\n *  Entry points\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_json_object_parse(duk_context *ctx) {\n\tduk_bi_json_parse_helper(ctx,\n\t                         0 /*idx_value*/,\n\t                         1 /*idx_replacer*/,\n\t                         0 /*flags*/);\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_json_object_stringify(duk_context *ctx) {\n\tduk_bi_json_stringify_helper(ctx,\n\t                             0 /*idx_value*/,\n\t                             1 /*idx_replacer*/,\n\t                             2 /*idx_space*/,\n\t                             0 /*flags*/);\n\treturn 1;\n}\n\n#endif  /* DUK_USE_JSON_BUILTIN */\n\n#endif  /* DUK_USE_JSON_SUPPORT */\n\n/* automatic undefs */\n#undef DUK__EMIT_1\n#undef DUK__EMIT_2\n#undef DUK__EMIT_CSTR\n#undef DUK__EMIT_HSTR\n#undef DUK__EMIT_STRIDX\n#undef DUK__JSON_DECSTR_BUFSIZE\n#undef DUK__JSON_DECSTR_CHUNKSIZE\n#undef DUK__JSON_ENCSTR_CHUNKSIZE\n#undef DUK__JSON_MAX_ESC_LEN\n#undef DUK__JSON_STRINGIFY_BUFSIZE\n#undef DUK__MKESC\n#undef DUK__UNEMIT_1\n/*\n *  Math built-ins\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_MATH_BUILTIN)\n\n/*\n *  Use static helpers which can work with math.h functions matching\n *  the following signatures. This is not portable if any of these math\n *  functions is actually a macro.\n *\n *  Typing here is intentionally 'double' wherever values interact with\n *  the standard library APIs.\n */\n\ntypedef double (*duk__one_arg_func)(double);\ntypedef double (*duk__two_arg_func)(double, double);\n\nDUK_LOCAL duk_ret_t duk__math_minmax(duk_context *ctx, duk_double_t initial, duk__two_arg_func min_max) {\n\tduk_idx_t n = duk_get_top(ctx);\n\tduk_idx_t i;\n\tduk_double_t res = initial;\n\tduk_double_t t;\n\n\t/*\n\t *  Note: fmax() does not match the E5 semantics.  E5 requires\n\t *  that if -any- input to Math.max() is a NaN, the result is a\n\t *  NaN.  fmax() will return a NaN only if -both- inputs are NaN.\n\t *  Same applies to fmin().\n\t *\n\t *  Note: every input value must be coerced with ToNumber(), even\n\t *  if we know the result will be a NaN anyway: ToNumber() may have\n\t *  side effects for which even order of evaluation matters.\n\t */\n\n\tfor (i = 0; i < n; i++) {\n\t\tt = duk_to_number(ctx, i);\n\t\tif (DUK_FPCLASSIFY(t) == DUK_FP_NAN || DUK_FPCLASSIFY(res) == DUK_FP_NAN) {\n\t\t\t/* Note: not normalized, but duk_push_number() will normalize */\n\t\t\tres = (duk_double_t) DUK_DOUBLE_NAN;\n\t\t} else {\n\t\t\tres = (duk_double_t) min_max(res, (double) t);\n\t\t}\n\t}\n\n\tduk_push_number(ctx, res);\n\treturn 1;\n}\n\nDUK_LOCAL double duk__fmin_fixed(double x, double y) {\n\t/* fmin() with args -0 and +0 is not guaranteed to return\n\t * -0 as Ecmascript requires.\n\t */\n\tif (x == 0 && y == 0) {\n\t\tduk_double_union du1, du2;\n\t\tdu1.d = x;\n\t\tdu2.d = y;\n\n\t\t/* Already checked to be zero so these must hold, and allow us\n\t\t * to check for \"x is -0 or y is -0\" by ORing the high parts\n\t\t * for comparison.\n\t\t */\n\t\tDUK_ASSERT(du1.ui[DUK_DBL_IDX_UI0] == 0 || du1.ui[DUK_DBL_IDX_UI0] == 0x80000000UL);\n\t\tDUK_ASSERT(du2.ui[DUK_DBL_IDX_UI0] == 0 || du2.ui[DUK_DBL_IDX_UI0] == 0x80000000UL);\n\n\t\t/* XXX: what's the safest way of creating a negative zero? */\n\t\tif ((du1.ui[DUK_DBL_IDX_UI0] | du2.ui[DUK_DBL_IDX_UI0]) != 0) {\n\t\t\t/* Enter here if either x or y (or both) is -0. */\n\t\t\treturn -0.0;\n\t\t} else {\n\t\t\treturn +0.0;\n\t\t}\n\t}\n\treturn duk_double_fmin(x, y);\n}\n\nDUK_LOCAL double duk__fmax_fixed(double x, double y) {\n\t/* fmax() with args -0 and +0 is not guaranteed to return\n\t * +0 as Ecmascript requires.\n\t */\n\tif (x == 0 && y == 0) {\n\t\tif (DUK_SIGNBIT(x) == 0 || DUK_SIGNBIT(y) == 0) {\n\t\t\treturn +0.0;\n\t\t} else {\n\t\t\treturn -0.0;\n\t\t}\n\t}\n\treturn duk_double_fmax(x, y);\n}\n\n#if defined(DUK_USE_ES6)\nDUK_LOCAL double duk__cbrt(double x) {\n\t/* cbrt() is C99.  To avoid hassling embedders with the need to provide a\n\t * cube root function, we can get by with pow().  The result is not\n\t * identical, but that's OK: ES2015 says it's implementation-dependent.\n\t */\n\n#if defined(DUK_CBRT)\n\t/* cbrt() matches ES2015 requirements. */\n\treturn DUK_CBRT(x);\n#else\n\tduk_small_int_t c = (duk_small_int_t) DUK_FPCLASSIFY(x);\n\n\t/* pow() does not, however. */\n\tif (c == DUK_FP_NAN || c == DUK_FP_INFINITE || c == DUK_FP_ZERO) {\n\t\treturn x;\n\t}\n\tif (DUK_SIGNBIT(x)) {\n\t\treturn -DUK_POW(-x, 1.0 / 3.0);\n\t} else {\n\t\treturn DUK_POW(x, 1.0 / 3.0);\n\t}\n#endif\n}\n\nDUK_LOCAL double duk__log2(double x) {\n#if defined(DUK_LOG2)\n\treturn DUK_LOG2(x);\n#else\n\treturn DUK_LOG(x) * DUK_DOUBLE_LOG2E;\n#endif\n}\n\nDUK_LOCAL double duk__log10(double x) {\n#if defined(DUK_LOG10)\n\treturn DUK_LOG10(x);\n#else\n\treturn DUK_LOG(x) * DUK_DOUBLE_LOG10E;\n#endif\n}\n\nDUK_LOCAL double duk__trunc(double x) {\n#if defined(DUK_TRUNC)\n\treturn DUK_TRUNC(x);\n#else\n\t/* Handles -0 correctly: -0.0 matches 'x >= 0.0' but floor()\n\t * is required to return -0 when the argument is -0.\n\t */\n\treturn x >= 0.0 ? DUK_FLOOR(x) : DUK_CEIL(x);\n#endif\n}\n#endif  /* DUK_USE_ES6 */\n\nDUK_LOCAL double duk__round_fixed(double x) {\n\t/* Numbers half-way between integers must be rounded towards +Infinity,\n\t * e.g. -3.5 must be rounded to -3 (not -4).  When rounded to zero, zero\n\t * sign must be set appropriately.  E5.1 Section 15.8.2.15.\n\t *\n\t * Note that ANSI C round() is \"round to nearest integer, away from zero\",\n\t * which is incorrect for negative values.  Here we make do with floor().\n\t */\n\n\tduk_small_int_t c = (duk_small_int_t) DUK_FPCLASSIFY(x);\n\tif (c == DUK_FP_NAN || c == DUK_FP_INFINITE || c == DUK_FP_ZERO) {\n\t\treturn x;\n\t}\n\n\t/*\n\t *  x is finite and non-zero\n\t *\n\t *  -1.6 -> floor(-1.1) -> -2\n\t *  -1.5 -> floor(-1.0) -> -1  (towards +Inf)\n\t *  -1.4 -> floor(-0.9) -> -1\n\t *  -0.5 -> -0.0               (special case)\n\t *  -0.1 -> -0.0               (special case)\n\t *  +0.1 -> +0.0               (special case)\n\t *  +0.5 -> floor(+1.0) -> 1   (towards +Inf)\n\t *  +1.4 -> floor(+1.9) -> 1\n\t *  +1.5 -> floor(+2.0) -> 2   (towards +Inf)\n\t *  +1.6 -> floor(+2.1) -> 2\n\t */\n\n\tif (x >= -0.5 && x < 0.5) {\n\t\t/* +0.5 is handled by floor, this is on purpose */\n\t\tif (x < 0.0) {\n\t\t\treturn -0.0;\n\t\t} else {\n\t\t\treturn +0.0;\n\t\t}\n\t}\n\n\treturn DUK_FLOOR(x + 0.5);\n}\n\n/* Wrappers for calling standard math library methods.  These may be required\n * on platforms where one or more of the math built-ins are defined as macros\n * or inline functions and are thus not suitable to be used as function pointers.\n */\n#if defined(DUK_USE_AVOID_PLATFORM_FUNCPTRS)\nDUK_LOCAL double duk__fabs(double x) {\n\treturn DUK_FABS(x);\n}\nDUK_LOCAL double duk__acos(double x) {\n\treturn DUK_ACOS(x);\n}\nDUK_LOCAL double duk__asin(double x) {\n\treturn DUK_ASIN(x);\n}\nDUK_LOCAL double duk__atan(double x) {\n\treturn DUK_ATAN(x);\n}\nDUK_LOCAL double duk__ceil(double x) {\n\treturn DUK_CEIL(x);\n}\nDUK_LOCAL double duk__cos(double x) {\n\treturn DUK_COS(x);\n}\nDUK_LOCAL double duk__exp(double x) {\n\treturn DUK_EXP(x);\n}\nDUK_LOCAL double duk__floor(double x) {\n\treturn DUK_FLOOR(x);\n}\nDUK_LOCAL double duk__log(double x) {\n\treturn DUK_LOG(x);\n}\nDUK_LOCAL double duk__sin(double x) {\n\treturn DUK_SIN(x);\n}\nDUK_LOCAL double duk__sqrt(double x) {\n\treturn DUK_SQRT(x);\n}\nDUK_LOCAL double duk__tan(double x) {\n\treturn DUK_TAN(x);\n}\nDUK_LOCAL double duk__atan2_fixed(double x, double y) {\n#if defined(DUK_USE_ATAN2_WORKAROUNDS)\n\t/* Specific fixes to common atan2() implementation issues:\n\t * - test-bug-mingw-math-issues.js\n\t */\n\tif (DUK_ISINF(x) && DUK_ISINF(y)) {\n\t\tif (DUK_SIGNBIT(x)) {\n\t\t\tif (DUK_SIGNBIT(y)) {\n\t\t\t\treturn -2.356194490192345;\n\t\t\t} else {\n\t\t\t\treturn -0.7853981633974483;\n\t\t\t}\n\t\t} else {\n\t\t\tif (DUK_SIGNBIT(y)) {\n\t\t\t\treturn 2.356194490192345;\n\t\t\t} else {\n\t\t\t\treturn 0.7853981633974483;\n\t\t\t}\n\t\t}\n\t}\n#else\n\t/* Some ISO C assumptions. */\n\tDUK_ASSERT(DUK_ATAN2(DUK_DOUBLE_INFINITY, DUK_DOUBLE_INFINITY) == 0.7853981633974483);\n\tDUK_ASSERT(DUK_ATAN2(-DUK_DOUBLE_INFINITY, DUK_DOUBLE_INFINITY) == -0.7853981633974483);\n\tDUK_ASSERT(DUK_ATAN2(DUK_DOUBLE_INFINITY, -DUK_DOUBLE_INFINITY) == 2.356194490192345);\n\tDUK_ASSERT(DUK_ATAN2(-DUK_DOUBLE_INFINITY, -DUK_DOUBLE_INFINITY) == -2.356194490192345);\n#endif\n\n\treturn DUK_ATAN2(x, y);\n}\n#endif  /* DUK_USE_AVOID_PLATFORM_FUNCPTRS */\n\n/* order must match constants in genbuiltins.py */\nDUK_LOCAL const duk__one_arg_func duk__one_arg_funcs[] = {\n#if defined(DUK_USE_AVOID_PLATFORM_FUNCPTRS)\n\tduk__fabs,\n\tduk__acos,\n\tduk__asin,\n\tduk__atan,\n\tduk__ceil,\n\tduk__cos,\n\tduk__exp,\n\tduk__floor,\n\tduk__log,\n\tduk__round_fixed,\n\tduk__sin,\n\tduk__sqrt,\n\tduk__tan,\n#if defined(DUK_USE_ES6)\n\tduk__cbrt,\n\tduk__log2,\n\tduk__log10,\n\tduk__trunc\n#endif\n#else  /* DUK_USE_AVOID_PLATFORM_FUNCPTRS */\n\tDUK_FABS,\n\tDUK_ACOS,\n\tDUK_ASIN,\n\tDUK_ATAN,\n\tDUK_CEIL,\n\tDUK_COS,\n\tDUK_EXP,\n\tDUK_FLOOR,\n\tDUK_LOG,\n\tduk__round_fixed,\n\tDUK_SIN,\n\tDUK_SQRT,\n\tDUK_TAN,\n#if defined(DUK_USE_ES6)\n\tduk__cbrt,\n\tduk__log2,\n\tduk__log10,\n\tduk__trunc\n#endif\n#endif  /* DUK_USE_AVOID_PLATFORM_FUNCPTRS */\n};\n\n/* order must match constants in genbuiltins.py */\nDUK_LOCAL const duk__two_arg_func duk__two_arg_funcs[] = {\n#if defined(DUK_USE_AVOID_PLATFORM_FUNCPTRS)\n\tduk__atan2_fixed,\n\tduk_js_arith_pow\n#else\n\tduk__atan2_fixed,\n\tduk_js_arith_pow\n#endif\n};\n\nDUK_INTERNAL duk_ret_t duk_bi_math_object_onearg_shared(duk_context *ctx) {\n\tduk_small_int_t fun_idx = duk_get_current_magic(ctx);\n\tduk__one_arg_func fun;\n\tduk_double_t arg1;\n\n\tDUK_ASSERT(fun_idx >= 0);\n\tDUK_ASSERT(fun_idx < (duk_small_int_t) (sizeof(duk__one_arg_funcs) / sizeof(duk__one_arg_func)));\n\targ1 = duk_to_number(ctx, 0);\n\tfun = duk__one_arg_funcs[fun_idx];\n\tduk_push_number(ctx, (duk_double_t) fun((double) arg1));\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_math_object_twoarg_shared(duk_context *ctx) {\n\tduk_small_int_t fun_idx = duk_get_current_magic(ctx);\n\tduk__two_arg_func fun;\n\tduk_double_t arg1;\n\tduk_double_t arg2;\n\n\tDUK_ASSERT(fun_idx >= 0);\n\tDUK_ASSERT(fun_idx < (duk_small_int_t) (sizeof(duk__two_arg_funcs) / sizeof(duk__two_arg_func)));\n\targ1 = duk_to_number(ctx, 0);  /* explicit ordered evaluation to match coercion semantics */\n\targ2 = duk_to_number(ctx, 1);\n\tfun = duk__two_arg_funcs[fun_idx];\n\tduk_push_number(ctx, (duk_double_t) fun((double) arg1, (double) arg2));\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_math_object_max(duk_context *ctx) {\n\treturn duk__math_minmax(ctx, -DUK_DOUBLE_INFINITY, duk__fmax_fixed);\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_math_object_min(duk_context *ctx) {\n\treturn duk__math_minmax(ctx, DUK_DOUBLE_INFINITY, duk__fmin_fixed);\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_math_object_random(duk_context *ctx) {\n\tduk_push_number(ctx, (duk_double_t) DUK_UTIL_GET_RANDOM_DOUBLE((duk_hthread *) ctx));\n\treturn 1;\n}\n\n#if defined(DUK_USE_ES6)\nDUK_INTERNAL duk_ret_t duk_bi_math_object_hypot(duk_context *ctx) {\n\t/*\n\t *  E6 Section 20.2.2.18: Math.hypot\n\t *\n\t *  - If no arguments are passed, the result is +0.\n\t *  - If any argument is +inf, the result is +inf.\n\t *  - If any argument is -inf, the result is +inf.\n\t *  - If no argument is +inf or -inf, and any argument is NaN, the result is\n\t *    NaN.\n\t *  - If all arguments are either +0 or -0, the result is +0.\n\t */\n\n\tduk_idx_t nargs;\n\tduk_idx_t i;\n\tduk_bool_t found_nan;\n\tduk_double_t max;\n\tduk_double_t sum, summand;\n\tduk_double_t comp, prelim;\n\tduk_double_t t;\n\n\tnargs = duk_get_top(ctx);\n\n\t/* Find the highest value.  Also ToNumber() coerces. */\n\tmax = 0.0;\n\tfound_nan = 0;\n\tfor (i = 0; i < nargs; i++) {\n\t\tt = DUK_FABS(duk_to_number(ctx, i));\n\t\tif (DUK_FPCLASSIFY(t) == DUK_FP_NAN) {\n\t\t\tfound_nan = 1;\n\t\t} else {\n\t\t\tmax = duk_double_fmax(max, t);\n\t\t}\n\t}\n\n\t/* Early return cases. */\n\tif (max == DUK_DOUBLE_INFINITY) {\n\t\tduk_push_number(ctx, DUK_DOUBLE_INFINITY);\n\t\treturn 1;\n\t} else if (found_nan) {\n\t\tduk_push_number(ctx, DUK_DOUBLE_NAN);\n\t\treturn 1;\n\t} else if (max == 0.0) {\n\t\tduk_push_number(ctx, 0.0);\n\t\t/* Otherwise we'd divide by zero. */\n\t\treturn 1;\n\t}\n\n\t/* Use Kahan summation and normalize to the highest value to minimize\n\t * floating point rounding error and avoid overflow.\n\t *\n\t * https://en.wikipedia.org/wiki/Kahan_summation_algorithm\n\t */\n\tsum = 0.0;\n\tcomp = 0.0;\n\tfor (i = 0; i < nargs; i++) {\n\t\tt = DUK_FABS(duk_get_number(ctx, i)) / max;\n\t\tsummand = (t * t) - comp;\n\t\tprelim = sum + summand;\n\t\tcomp = (prelim - sum) - summand;\n\t\tsum = prelim;\n\t}\n\n\tduk_push_number(ctx, (duk_double_t) DUK_SQRT(sum) * max);\n\treturn 1;\n}\n#endif  /* DUK_USE_ES6 */\n\n#endif  /* DUK_USE_MATH_BUILTIN */\n/*\n *  Number built-ins\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_NUMBER_BUILTIN)\n\nDUK_LOCAL duk_double_t duk__push_this_number_plain(duk_context *ctx) {\n\tduk_hobject *h;\n\n\t/* Number built-in accepts a plain number or a Number object (whose\n\t * internal value is operated on).  Other types cause TypeError.\n\t */\n\n\tduk_push_this(ctx);\n\tif (duk_is_number(ctx, -1)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"plain number value: %!T\", (duk_tval *) duk_get_tval(ctx, -1)));\n\t\tgoto done;\n\t}\n\th = duk_get_hobject(ctx, -1);\n\tif (!h ||\n\t    (DUK_HOBJECT_GET_CLASS_NUMBER(h) != DUK_HOBJECT_CLASS_NUMBER)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"unacceptable this value: %!T\", (duk_tval *) duk_get_tval(ctx, -1)));\n\t\tDUK_ERROR_TYPE((duk_hthread *) ctx, \"number expected\");\n\t}\n\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_INT_VALUE);\n\tDUK_ASSERT(duk_is_number(ctx, -1));\n\tDUK_DDD(DUK_DDDPRINT(\"number object: %!T, internal value: %!T\",\n\t                     (duk_tval *) duk_get_tval(ctx, -2), (duk_tval *) duk_get_tval(ctx, -1)));\n\tduk_remove_m2(ctx);\n\n done:\n\treturn duk_get_number(ctx, -1);\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_number_constructor(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_idx_t nargs;\n\tduk_hobject *h_this;\n\n\tDUK_UNREF(thr);\n\n\t/*\n\t *  The Number constructor uses ToNumber(arg) for number coercion\n\t *  (coercing an undefined argument to NaN).  However, if the\n\t *  argument is not given at all, +0 must be used instead.  To do\n\t *  this, a vararg function is used.\n\t */\n\n\tnargs = duk_get_top(ctx);\n\tif (nargs == 0) {\n\t\tduk_push_int(ctx, 0);\n\t}\n\tduk_to_number(ctx, 0);\n\tduk_set_top(ctx, 1);\n\tDUK_ASSERT_TOP(ctx, 1);\n\n\tif (!duk_is_constructor_call(ctx)) {\n\t\treturn 1;\n\t}\n\n\t/*\n\t *  E5 Section 15.7.2.1 requires that the constructed object\n\t *  must have the original Number.prototype as its internal\n\t *  prototype.  However, since Number.prototype is non-writable\n\t *  and non-configurable, this doesn't have to be enforced here:\n\t *  The default object (bound to 'this') is OK, though we have\n\t *  to change its class.\n\t *\n\t *  Internal value set to ToNumber(arg) or +0; if no arg given,\n\t *  ToNumber(undefined) = NaN, so special treatment is needed\n\t *  (above).  String internal value is immutable.\n\t */\n\n\t/* XXX: helper */\n\tduk_push_this(ctx);\n\th_this = duk_known_hobject(ctx, -1);\n\tDUK_HOBJECT_SET_CLASS_NUMBER(h_this, DUK_HOBJECT_CLASS_NUMBER);\n\n\tDUK_ASSERT(DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h_this) == thr->builtins[DUK_BIDX_NUMBER_PROTOTYPE]);\n\tDUK_ASSERT(DUK_HOBJECT_GET_CLASS_NUMBER(h_this) == DUK_HOBJECT_CLASS_NUMBER);\n\tDUK_ASSERT(DUK_HOBJECT_HAS_EXTENSIBLE(h_this));\n\n\tduk_dup_0(ctx);  /* -> [ val obj val ] */\n\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_VALUE, DUK_PROPDESC_FLAGS_NONE);\n\treturn 0;  /* no return value -> don't replace created value */\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_number_prototype_value_of(duk_context *ctx) {\n\t(void) duk__push_this_number_plain(ctx);\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_number_prototype_to_string(duk_context *ctx) {\n\tduk_small_int_t radix;\n\tduk_small_uint_t n2s_flags;\n\n\t(void) duk__push_this_number_plain(ctx);\n\tif (duk_is_undefined(ctx, 0)) {\n\t\tradix = 10;\n\t} else {\n\t\tradix = (duk_small_int_t) duk_to_int_check_range(ctx, 0, 2, 36);\n\t}\n\tDUK_DDD(DUK_DDDPRINT(\"radix=%ld\", (long) radix));\n\n\tn2s_flags = 0;\n\n\tduk_numconv_stringify(ctx,\n\t                      radix /*radix*/,\n\t                      0 /*digits*/,\n\t                      n2s_flags /*flags*/);\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_number_prototype_to_locale_string(duk_context *ctx) {\n\t/* XXX: just use toString() for now; permitted although not recommended.\n\t * nargs==1, so radix is passed to toString().\n\t */\n\treturn duk_bi_number_prototype_to_string(ctx);\n}\n\n/*\n *  toFixed(), toExponential(), toPrecision()\n */\n\n/* XXX: shared helper for toFixed(), toExponential(), toPrecision()? */\n\nDUK_INTERNAL duk_ret_t duk_bi_number_prototype_to_fixed(duk_context *ctx) {\n\tduk_small_int_t frac_digits;\n\tduk_double_t d;\n\tduk_small_int_t c;\n\tduk_small_uint_t n2s_flags;\n\n\tfrac_digits = (duk_small_int_t) duk_to_int_check_range(ctx, 0, 0, 20);\n\td = duk__push_this_number_plain(ctx);\n\n\tc = (duk_small_int_t) DUK_FPCLASSIFY(d);\n\tif (c == DUK_FP_NAN || c == DUK_FP_INFINITE) {\n\t\tgoto use_to_string;\n\t}\n\n\tif (d >= 1.0e21 || d <= -1.0e21) {\n\t\tgoto use_to_string;\n\t}\n\n\tn2s_flags = DUK_N2S_FLAG_FIXED_FORMAT |\n\t            DUK_N2S_FLAG_FRACTION_DIGITS;\n\n\tduk_numconv_stringify(ctx,\n\t                      10 /*radix*/,\n\t                      frac_digits /*digits*/,\n\t                      n2s_flags /*flags*/);\n\treturn 1;\n\n use_to_string:\n\tDUK_ASSERT_TOP(ctx, 2);\n\tduk_to_string(ctx, -1);\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_number_prototype_to_exponential(duk_context *ctx) {\n\tduk_bool_t frac_undefined;\n\tduk_small_int_t frac_digits;\n\tduk_double_t d;\n\tduk_small_int_t c;\n\tduk_small_uint_t n2s_flags;\n\n\td = duk__push_this_number_plain(ctx);\n\n\tfrac_undefined = duk_is_undefined(ctx, 0);\n\tduk_to_int(ctx, 0);  /* for side effects */\n\n\tc = (duk_small_int_t) DUK_FPCLASSIFY(d);\n\tif (c == DUK_FP_NAN || c == DUK_FP_INFINITE) {\n\t\tgoto use_to_string;\n\t}\n\n\tfrac_digits = (duk_small_int_t) duk_to_int_check_range(ctx, 0, 0, 20);\n\n\tn2s_flags = DUK_N2S_FLAG_FORCE_EXP |\n\t           (frac_undefined ? 0 : DUK_N2S_FLAG_FIXED_FORMAT);\n\n\tduk_numconv_stringify(ctx,\n\t                      10 /*radix*/,\n\t                      frac_digits + 1 /*leading digit + fractions*/,\n\t                      n2s_flags /*flags*/);\n\treturn 1;\n\n use_to_string:\n\tDUK_ASSERT_TOP(ctx, 2);\n\tduk_to_string(ctx, -1);\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_number_prototype_to_precision(duk_context *ctx) {\n\t/* The specification has quite awkward order of coercion and\n\t * checks for toPrecision().  The operations below are a bit\n\t * reordered, within constraints of observable side effects.\n\t */\n\n\tduk_double_t d;\n\tduk_small_int_t prec;\n\tduk_small_int_t c;\n\tduk_small_uint_t n2s_flags;\n\n\tDUK_ASSERT_TOP(ctx, 1);\n\n\td = duk__push_this_number_plain(ctx);\n\tif (duk_is_undefined(ctx, 0)) {\n\t\tgoto use_to_string;\n\t}\n\tDUK_ASSERT_TOP(ctx, 2);\n\n\tduk_to_int(ctx, 0);  /* for side effects */\n\n\tc = (duk_small_int_t) DUK_FPCLASSIFY(d);\n\tif (c == DUK_FP_NAN || c == DUK_FP_INFINITE) {\n\t\tgoto use_to_string;\n\t}\n\n\tprec = (duk_small_int_t) duk_to_int_check_range(ctx, 0, 1, 21);\n\n\tn2s_flags = DUK_N2S_FLAG_FIXED_FORMAT |\n\t            DUK_N2S_FLAG_NO_ZERO_PAD;\n\n\tduk_numconv_stringify(ctx,\n\t                      10 /*radix*/,\n\t                      prec /*digits*/,\n\t                      n2s_flags /*flags*/);\n\treturn 1;\n\n use_to_string:\n\t/* Used when precision is undefined; also used for NaN (-> \"NaN\"),\n\t * and +/- infinity (-> \"Infinity\", \"-Infinity\").\n\t */\n\n\tDUK_ASSERT_TOP(ctx, 2);\n\tduk_to_string(ctx, -1);\n\treturn 1;\n}\n\n#endif  /* DUK_USE_NUMBER_BUILTIN */\n/*\n *  Object built-ins\n */\n\n/* #include duk_internal.h -> already included */\n\n/* Needed even when Object built-in disabled. */\nDUK_INTERNAL duk_ret_t duk_bi_object_prototype_to_string(duk_context *ctx) {\n\tduk_tval *tv;\n\ttv = DUK_HTHREAD_THIS_PTR((duk_hthread *) ctx);\n\t/* XXX: This is not entirely correct anymore; in ES2015 the\n\t * default lookup should use @@toStringTag to come up with\n\t * e.g. [object Symbol].\n\t */\n\tduk_push_class_string_tval(ctx, tv);\n\treturn 1;\n}\n\n#if defined(DUK_USE_OBJECT_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_object_constructor(duk_context *ctx) {\n\tduk_uint_t arg_mask;\n\n\targ_mask = duk_get_type_mask(ctx, 0);\n\n\tif (!duk_is_constructor_call(ctx) &&  /* not a constructor call */\n\t    ((arg_mask & (DUK_TYPE_MASK_NULL | DUK_TYPE_MASK_UNDEFINED)) == 0)) {  /* and argument not null or undefined */\n\t\tduk_to_object(ctx, 0);\n\t\treturn 1;\n\t}\n\n\t/* Pointer and buffer primitive values are treated like other\n\t * primitives values which have a fully fledged object counterpart:\n\t * promote to an object value.  Lightfuncs and plain buffers are\n\t * coerced with ToObject() even they could also be returned as is.\n\t */\n\tif (arg_mask & (DUK_TYPE_MASK_OBJECT |\n\t                DUK_TYPE_MASK_STRING |\n\t                DUK_TYPE_MASK_BOOLEAN |\n\t                DUK_TYPE_MASK_NUMBER |\n\t                DUK_TYPE_MASK_POINTER |\n\t                DUK_TYPE_MASK_BUFFER |\n\t                DUK_TYPE_MASK_LIGHTFUNC)) {\n\t\t/* For DUK_TYPE_OBJECT the coercion is a no-op and could\n\t\t * be checked for explicitly, but Object(obj) calls are\n\t\t * not very common so opt for minimal footprint.\n\t\t */\n\t\tduk_to_object(ctx, 0);\n\t\treturn 1;\n\t}\n\n\t(void) duk_push_object_helper(ctx,\n\t                              DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                              DUK_HOBJECT_FLAG_FASTREFS |\n\t                              DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_OBJECT),\n\t                              DUK_BIDX_OBJECT_PROTOTYPE);\n\treturn 1;\n}\n#endif  /* DUK_USE_OBJECT_BUILTIN */\n\n#if defined(DUK_USE_OBJECT_BUILTIN) && defined(DUK_USE_ES6)\nDUK_INTERNAL duk_ret_t duk_bi_object_constructor_assign(duk_context *ctx) {\n\tduk_idx_t nargs;\n\tduk_int_t idx;\n\n\tnargs = duk_get_top_require_min(ctx, 1 /*min_top*/);\n\n\tduk_to_object(ctx, 0);\n\tfor (idx = 1; idx < nargs; idx++) {\n\t\t/* E7 19.1.2.1 (step 4a) */\n\t\tif (duk_is_null_or_undefined(ctx, idx)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t/* duk_enum() respects ES2015+ [[OwnPropertyKeys]] ordering, which is\n\t\t * convenient here.\n\t\t */\n\t\tduk_to_object(ctx, idx);\n\t\tduk_enum(ctx, idx, DUK_ENUM_OWN_PROPERTIES_ONLY);\n\t\twhile (duk_next(ctx, -1, 1 /*get_value*/)) {\n\t\t\t/* [ target ... enum key value ] */\n\t\t\tduk_put_prop(ctx, 0);\n\t\t\t/* [ target ... enum ] */\n\t\t}\n\t\t/* Could pop enumerator, but unnecessary because of duk_set_top()\n\t\t * below.\n\t\t */\n\t}\n\n\tduk_set_top(ctx, 1);\n\treturn 1;\n}\n#endif\n\n#if defined(DUK_USE_OBJECT_BUILTIN) && defined(DUK_USE_ES6)\nDUK_INTERNAL duk_ret_t duk_bi_object_constructor_is(duk_context *ctx) {\n\tDUK_ASSERT_TOP(ctx, 2);\n\tduk_push_boolean(ctx, duk_samevalue(ctx, 0, 1));\n\treturn 1;\n}\n#endif\n\n#if defined(DUK_USE_OBJECT_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_object_constructor_create(duk_context *ctx) {\n\tduk_hobject *proto;\n\n\tDUK_ASSERT_TOP(ctx, 2);\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n\tduk_hbufobj_promote_plain(ctx, 0);\n#endif\n\tproto = duk_require_hobject_accept_mask(ctx, 0, DUK_TYPE_MASK_NULL);\n\tDUK_ASSERT(proto != NULL || duk_is_null(ctx, 0));\n\n\t(void) duk_push_object_helper_proto(ctx,\n\t                                    DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                                    DUK_HOBJECT_FLAG_FASTREFS |\n\t                                    DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_OBJECT),\n\t                                    proto);\n\n\tif (!duk_is_undefined(ctx, 1)) {\n\t\t/* [ O Properties obj ] */\n\n\t\tduk_replace(ctx, 0);\n\n\t\t/* [ obj Properties ] */\n\n\t\t/* Just call the \"original\" Object.defineProperties() to\n\t\t * finish up.\n\t\t */\n\n\t\treturn duk_bi_object_constructor_define_properties(ctx);\n\t}\n\n\t/* [ O Properties obj ] */\n\n\treturn 1;\n}\n#endif  /* DUK_USE_OBJECT_BUILTIN */\n\n#if defined(DUK_USE_OBJECT_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_object_constructor_define_properties(duk_context *ctx) {\n\tduk_small_uint_t pass;\n\tduk_uint_t defprop_flags;\n\tduk_hobject *obj;\n\tduk_idx_t idx_value;\n\tduk_hobject *get;\n\tduk_hobject *set;\n\n\t/* Lightfunc and plain buffer handling by ToObject() coercion. */\n\tobj = duk_require_hobject_promote_mask(ctx, 0, DUK_TYPE_MASK_LIGHTFUNC | DUK_TYPE_MASK_BUFFER);\n\tDUK_ASSERT(obj != NULL);\n\n\tduk_to_object(ctx, 1);        /* properties object */\n\n\tDUK_DDD(DUK_DDDPRINT(\"target=%!iT, properties=%!iT\",\n\t                     (duk_tval *) duk_get_tval(ctx, 0),\n\t                     (duk_tval *) duk_get_tval(ctx, 1)));\n\n\t/*\n\t *  Two pass approach to processing the property descriptors.\n\t *  On first pass validate and normalize all descriptors before\n\t *  any changes are made to the target object.  On second pass\n\t *  make the actual modifications to the target object.\n\t *\n\t *  Right now we'll just use the same normalize/validate helper\n\t *  on both passes, ignoring its outputs on the first pass.\n\t */\n\n\tfor (pass = 0; pass < 2; pass++) {\n\t\tduk_set_top(ctx, 2);  /* -> [ hobject props ] */\n\t\tduk_enum(ctx, 1, DUK_ENUM_OWN_PROPERTIES_ONLY | DUK_ENUM_INCLUDE_SYMBOLS /*enum_flags*/);\n\n\t\tfor (;;) {\n\t\t\tduk_hstring *key;\n\n\t\t\t/* [ hobject props enum(props) ] */\n\n\t\t\tduk_set_top(ctx, 3);\n\n\t\t\tif (!duk_next(ctx, 2, 1 /*get_value*/)) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> key=%!iT, desc=%!iT\",\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, -2),\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\n\t\t\t/* [ hobject props enum(props) key desc ] */\n\n\t\t\tduk_hobject_prepare_property_descriptor(ctx,\n\t\t\t                                        4 /*idx_desc*/,\n\t\t\t                                        &defprop_flags,\n\t\t\t                                        &idx_value,\n\t\t\t                                        &get,\n\t\t\t                                        &set);\n\n\t\t\t/* [ hobject props enum(props) key desc [multiple values] ] */\n\n\t\t\tif (pass == 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t/* This allows symbols on purpose. */\n\t\t\tkey = duk_known_hstring(ctx, 3);\n\t\t\tDUK_ASSERT(key != NULL);\n\n\t\t\tduk_hobject_define_property_helper(ctx,\n\t\t\t                                   defprop_flags,\n\t\t\t                                   obj,\n\t\t\t                                   key,\n\t\t\t                                   idx_value,\n\t\t\t                                   get,\n\t\t\t                                   set,\n\t\t\t                                   1 /*throw_flag*/);\n\t\t}\n\t}\n\n\t/*\n\t *  Return target object\n\t */\n\n\tduk_dup_0(ctx);\n\treturn 1;\n}\n#endif  /* DUK_USE_OBJECT_BUILTIN */\n\n#if defined(DUK_USE_OBJECT_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_object_constructor_seal_freeze_shared(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *h;\n\tduk_bool_t is_freeze;\n\n\tDUK_ASSERT_TOP(ctx, 1);\n\n\tis_freeze = (duk_bool_t) duk_get_current_magic(ctx);\n\tif (duk_is_buffer(ctx, 0)) {\n\t\t/* Plain buffer: already sealed, but not frozen (and can't be frozen\n\t\t * because index properties can't be made non-writable.\n\t\t */\n\t\tif (is_freeze) {\n\t\t\tgoto fail_cannot_freeze;\n\t\t}\n\t\treturn 1;\n\t} else if (duk_is_lightfunc(ctx, 0)) {\n\t\t/* Lightfunc: already sealed and frozen, success. */\n\t\treturn 1;\n\t}\n#if 0\n\t/* Seal/freeze are quite rare in practice so it'd be nice to get the\n\t * correct behavior simply via automatic promotion (at the cost of some\n\t * memory churn).  However, the promoted objects don't behave the same,\n\t * e.g. promoted lightfuncs are extensible.\n\t */\n\th = duk_require_hobject_promote_mask(ctx, 0, DUK_TYPE_MASK_LIGHTFUNC | DUK_TYPE_MASK_BUFFER);\n#endif\n\n\th = duk_get_hobject(ctx, 0);\n\tif (h == NULL) {\n\t\t/* ES2015 Sections 19.1.2.5, 19.1.2.17 */\n\t\treturn 1;\n\t}\n\n\tif (is_freeze && DUK_HOBJECT_IS_BUFOBJ(h)) {\n\t\t/* Buffer objects cannot be frozen because there's no internal\n\t\t * support for making virtual array indices non-writable.\n\t\t */\n\t\tDUK_DD(DUK_DDPRINT(\"cannot freeze a buffer object\"));\n\t\tgoto fail_cannot_freeze;\n\t}\n\n\tduk_hobject_object_seal_freeze_helper(thr, h, is_freeze);\n\n\t/* Sealed and frozen objects cannot gain any more properties,\n\t * so this is a good time to compact them.\n\t */\n\tduk_hobject_compact_props(thr, h);\n\treturn 1;\n\n fail_cannot_freeze:\n\tDUK_DCERROR_TYPE_INVALID_ARGS(thr);  /* XXX: proper error message */\n}\n#endif  /* DUK_USE_OBJECT_BUILTIN */\n\n#if defined(DUK_USE_OBJECT_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_object_constructor_is_sealed_frozen_shared(duk_context *ctx) {\n\tduk_hobject *h;\n\tduk_bool_t is_frozen;\n\tduk_uint_t mask;\n\n\tis_frozen = duk_get_current_magic(ctx);\n\tmask = duk_get_type_mask(ctx, 0);\n\tif (mask & (DUK_TYPE_MASK_LIGHTFUNC | DUK_TYPE_MASK_BUFFER)) {\n\t\tDUK_ASSERT(is_frozen == 0 || is_frozen == 1);\n\t\tduk_push_boolean(ctx, (mask & DUK_TYPE_MASK_LIGHTFUNC) ?\n\t\t                          1 :               /* lightfunc always frozen and sealed */\n\t\t                          (is_frozen ^ 1)); /* buffer sealed but not frozen (index props writable) */\n\t} else {\n\t\t/* ES2015 Sections 19.1.2.12, 19.1.2.13: anything other than an object\n\t\t * is considered to be already sealed and frozen.\n\t\t */\n\t\th = duk_get_hobject(ctx, 0);\n\t\tduk_push_boolean(ctx, (h == NULL) ||\n\t\t                      duk_hobject_object_is_sealed_frozen_helper((duk_hthread *) ctx, h, is_frozen /*is_frozen*/));\n\t}\n\treturn 1;\n}\n#endif  /* DUK_USE_OBJECT_BUILTIN */\n\n#if defined(DUK_USE_OBJECT_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_object_prototype_to_locale_string(duk_context *ctx) {\n\tDUK_ASSERT_TOP(ctx, 0);\n\t(void) duk_push_this_coercible_to_object(ctx);\n\tduk_get_prop_stridx_short(ctx, 0, DUK_STRIDX_TO_STRING);\n#if 0  /* This is mentioned explicitly in the E5.1 spec, but duk_call_method() checks for it in practice. */\n\tduk_require_callable(ctx, 1);\n#endif\n\tduk_dup_0(ctx);  /* -> [ O toString O ] */\n\tduk_call_method(ctx, 0);  /* XXX: call method tail call? */\n\treturn 1;\n}\n#endif  /* DUK_USE_OBJECT_BUILTIN */\n\n#if defined(DUK_USE_OBJECT_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_object_prototype_value_of(duk_context *ctx) {\n\t/* For lightfuncs and plain buffers, returns Object() coerced. */\n\t(void) duk_push_this_coercible_to_object(ctx);\n\treturn 1;\n}\n#endif  /* DUK_USE_OBJECT_BUILTIN */\n\n#if defined(DUK_USE_OBJECT_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_object_prototype_is_prototype_of(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *h_v;\n\tduk_hobject *h_obj;\n\n\tDUK_ASSERT_TOP(ctx, 1);\n\n\th_v = duk_get_hobject(ctx, 0);\n\tif (!h_v) {\n\t\tduk_push_false(ctx);  /* XXX: tail call: return duk_push_false(ctx) */\n\t\treturn 1;\n\t}\n\n\th_obj = duk_push_this_coercible_to_object(ctx);\n\tDUK_ASSERT(h_obj != NULL);\n\n\t/* E5.1 Section 15.2.4.6, step 3.a, lookup proto once before compare.\n\t * Prototype loops should cause an error to be thrown.\n\t */\n\tduk_push_boolean(ctx, duk_hobject_prototype_chain_contains(thr, DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h_v), h_obj, 0 /*ignore_loop*/));\n\treturn 1;\n}\n#endif  /* DUK_USE_OBJECT_BUILTIN */\n\n#if defined(DUK_USE_OBJECT_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_object_prototype_has_own_property(duk_context *ctx) {\n\treturn duk_hobject_object_ownprop_helper(ctx, 0 /*required_desc_flags*/);\n}\n#endif  /* DUK_USE_OBJECT_BUILTIN */\n\n#if defined(DUK_USE_OBJECT_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_object_prototype_property_is_enumerable(duk_context *ctx) {\n\treturn duk_hobject_object_ownprop_helper(ctx, DUK_PROPDESC_FLAG_ENUMERABLE /*required_desc_flags*/);\n}\n#endif  /* DUK_USE_OBJECT_BUILTIN */\n\n#if defined(DUK_USE_OBJECT_BUILTIN) || defined(DUK_USE_REFLECT_BUILTIN)\n/* Shared helper to implement Object.getPrototypeOf,\n * Object.prototype.__proto__ getter, and Reflect.getPrototypeOf.\n *\n * http://www.ecma-international.org/ecma-262/6.0/index.html#sec-get-object.prototype.__proto__\n */\nDUK_INTERNAL duk_ret_t duk_bi_object_getprototype_shared(duk_context *ctx) {\n\t/*\n\t *  magic = 0: __proto__ getter\n\t *  magic = 1: Object.getPrototypeOf()\n\t *  magic = 2: Reflect.getPrototypeOf()\n\t */\n\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *h;\n\tduk_hobject *proto;\n\tduk_tval *tv;\n\tduk_int_t magic;\n\n\tmagic = duk_get_current_magic(ctx);\n\n\tif (magic == 0) {\n\t\tDUK_ASSERT_TOP(ctx, 0);\n\t\tduk_push_this_coercible_to_object(ctx);\n\t}\n\tDUK_ASSERT(duk_get_top(ctx) >= 1);\n\tif (magic < 2) {\n\t\t/* ES2015 Section 19.1.2.9, step 1 */\n\t\tduk_to_object(ctx, 0);\n\t}\n\ttv = DUK_GET_TVAL_POSIDX(ctx, 0);\n\n\tswitch (DUK_TVAL_GET_TAG(tv)) {\n\tcase DUK_TAG_BUFFER:\n\t\tproto = thr->builtins[DUK_BIDX_UINT8ARRAY_PROTOTYPE];\n\t\tbreak;\n\tcase DUK_TAG_LIGHTFUNC:\n\t\tproto = thr->builtins[DUK_BIDX_FUNCTION_PROTOTYPE];\n\t\tbreak;\n\tcase DUK_TAG_OBJECT:\n\t\th = DUK_TVAL_GET_OBJECT(tv);\n\t\tproto = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h);\n\t\tbreak;\n\tdefault:\n\t\t/* This implicitly handles CheckObjectCoercible() caused\n\t\t * TypeError.\n\t\t */\n\t\tDUK_DCERROR_TYPE_INVALID_ARGS(thr);\n\t}\n\tif (proto != NULL) {\n\t\tduk_push_hobject(ctx, proto);\n\t} else {\n\t\tduk_push_null(ctx);\n\t}\n\treturn 1;\n}\n#endif  /* DUK_USE_OBJECT_BUILTIN || DUK_USE_REFLECT_BUILTIN */\n\n#if defined(DUK_USE_OBJECT_BUILTIN) || defined(DUK_USE_REFLECT_BUILTIN)\n/* Shared helper to implement ES2015 Object.setPrototypeOf,\n * Object.prototype.__proto__ setter, and Reflect.setPrototypeOf.\n *\n * http://www.ecma-international.org/ecma-262/6.0/index.html#sec-get-object.prototype.__proto__\n * http://www.ecma-international.org/ecma-262/6.0/index.html#sec-object.setprototypeof\n */\nDUK_INTERNAL duk_ret_t duk_bi_object_setprototype_shared(duk_context *ctx) {\n\t/*\n\t *  magic = 0: __proto__ setter\n\t *  magic = 1: Object.setPrototypeOf()\n\t *  magic = 2: Reflect.setPrototypeOf()\n\t */\n\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *h_obj;\n\tduk_hobject *h_new_proto;\n\tduk_hobject *h_curr;\n\tduk_ret_t ret_success = 1;  /* retval for success path */\n\tduk_uint_t mask;\n\tduk_int_t magic;\n\n\t/* Preliminaries for __proto__ and setPrototypeOf (E6 19.1.2.18 steps 1-4). */\n\tmagic = duk_get_current_magic(ctx);\n\tif (magic == 0) {\n\t\tduk_push_this_check_object_coercible(ctx);\n\t\tduk_insert(ctx, 0);\n\t\tif (!duk_check_type_mask(ctx, 1, DUK_TYPE_MASK_NULL | DUK_TYPE_MASK_OBJECT)) {\n\t\t\treturn 0;\n\t\t}\n\n\t\t/* __proto__ setter returns 'undefined' on success unlike the\n\t\t * setPrototypeOf() call which returns the target object.\n\t\t */\n\t\tret_success = 0;\n\t} else {\n\t\tif (magic == 1) {\n\t\t\tduk_require_object_coercible(ctx, 0);\n\t\t} else {\n\t\t\tduk_require_hobject_accept_mask(ctx, 0,\n\t\t\t                                DUK_TYPE_MASK_LIGHTFUNC |\n\t\t\t                                DUK_TYPE_MASK_BUFFER);\n\t\t}\n\t\tduk_require_type_mask(ctx, 1, DUK_TYPE_MASK_NULL | DUK_TYPE_MASK_OBJECT);\n\t}\n\n\th_new_proto = duk_get_hobject(ctx, 1);\n\t/* h_new_proto may be NULL */\n\n\tmask = duk_get_type_mask(ctx, 0);\n\tif (mask & (DUK_TYPE_MASK_LIGHTFUNC | DUK_TYPE_MASK_BUFFER)) {\n\t\tduk_hobject *curr_proto;\n\t\tcurr_proto = thr->builtins[(mask & DUK_TYPE_MASK_LIGHTFUNC) ?\n\t\t                               DUK_BIDX_FUNCTION_PROTOTYPE :\n\t\t                               DUK_BIDX_UINT8ARRAY_PROTOTYPE];\n\t\tif (h_new_proto == curr_proto) {\n\t\t\tgoto skip;\n\t\t}\n\t\tgoto fail_nonextensible;\n\t}\n\th_obj = duk_get_hobject(ctx, 0);\n\tif (h_obj == NULL) {\n\t\tgoto skip;\n\t}\n\tDUK_ASSERT(h_obj != NULL);\n\n\t/* [[SetPrototypeOf]] standard behavior, E6 9.1.2. */\n\t/* TODO: implement Proxy object support here */\n\n\tif (h_new_proto == DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h_obj)) {\n\t\tgoto skip;\n\t}\n\tif (!DUK_HOBJECT_HAS_EXTENSIBLE(h_obj)) {\n\t\tgoto fail_nonextensible;\n\t}\n\tfor (h_curr = h_new_proto; h_curr != NULL; h_curr = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h_curr)) {\n\t\t/* Loop prevention. */\n\t\tif (h_curr == h_obj) {\n\t\t\tgoto fail_loop;\n\t\t}\n\t}\n\tDUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, h_obj, h_new_proto);\n\t/* fall thru */\n\n skip:\n\tduk_set_top(ctx, 1);\n\tif (magic == 2) {\n\t\tduk_push_true(ctx);\n\t}\n\treturn ret_success;\n\n fail_nonextensible:\n fail_loop:\n\tif (magic != 2) {\n\t\tDUK_DCERROR_TYPE_INVALID_ARGS(thr);\n\t} else {\n\t\tduk_push_false(ctx);\n\t\treturn 1;\n\t}\n}\n#endif  /* DUK_USE_OBJECT_BUILTIN || DUK_USE_REFLECT_BUILTIN */\n\n#if defined(DUK_USE_OBJECT_BUILTIN) || defined(DUK_USE_REFLECT_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_object_constructor_define_property(duk_context *ctx) {\n\t/*\n\t *  magic = 0: Object.defineProperty()\n\t *  magic = 1: Reflect.defineProperty()\n\t */\n\n\tduk_hobject *obj;\n\tduk_hstring *key;\n\tduk_hobject *get;\n\tduk_hobject *set;\n\tduk_idx_t idx_value;\n\tduk_uint_t defprop_flags;\n\tduk_int_t magic;\n\tduk_bool_t throw_flag;\n\tduk_bool_t ret;\n\n\tDUK_ASSERT(ctx != NULL);\n\n\tDUK_DDD(DUK_DDDPRINT(\"Object.defineProperty(): ctx=%p obj=%!T key=%!T desc=%!T\",\n\t                     (void *) ctx,\n\t                     (duk_tval *) duk_get_tval(ctx, 0),\n\t                     (duk_tval *) duk_get_tval(ctx, 1),\n\t                     (duk_tval *) duk_get_tval(ctx, 2)));\n\n\t/* [ obj key desc ] */\n\n\tmagic = duk_get_current_magic(ctx);\n\n\t/* Lightfuncs are currently supported by coercing to a temporary\n\t * Function object; changes will be allowed (the coerced value is\n\t * extensible) but will be lost.  Same for plain buffers.\n\t */\n\tobj = duk_require_hobject_promote_mask(ctx, 0, DUK_TYPE_MASK_LIGHTFUNC | DUK_TYPE_MASK_BUFFER);\n\tDUK_ASSERT(obj != NULL);\n\tkey = duk_to_property_key_hstring(ctx, 1);\n\t(void) duk_require_hobject(ctx, 2);\n\n\tDUK_ASSERT(obj != NULL);\n\tDUK_ASSERT(key != NULL);\n\tDUK_ASSERT(duk_get_hobject(ctx, 2) != NULL);\n\n\t/*\n\t *  Validate and convert argument property descriptor (an Ecmascript\n\t *  object) into a set of defprop_flags and possibly property value,\n\t *  getter, and/or setter values on the value stack.\n\t *\n\t *  Lightfunc set/get values are coerced to full Functions.\n\t */\n\n\tduk_hobject_prepare_property_descriptor(ctx,\n\t                                        2 /*idx_desc*/,\n\t                                        &defprop_flags,\n\t                                        &idx_value,\n\t                                        &get,\n\t                                        &set);\n\n\t/*\n\t *  Use Object.defineProperty() helper for the actual operation.\n\t */\n\n\tDUK_ASSERT(magic == 0 || magic == 1);\n\tthrow_flag = magic ^ 1;\n\tret = duk_hobject_define_property_helper(ctx,\n\t                                         defprop_flags,\n\t                                         obj,\n\t                                         key,\n\t                                         idx_value,\n\t                                         get,\n\t                                         set,\n\t                                         throw_flag);\n\n\t/* Ignore the normalize/validate helper outputs on the value stack,\n\t * they're popped automatically.\n\t */\n\n\tif (magic == 0) {\n\t\t/* Object.defineProperty(): return target object. */\n\t\tduk_push_hobject(ctx, obj);\n\t} else {\n\t\t/* Reflect.defineProperty(): return success/fail. */\n\t\tduk_push_boolean(ctx, ret);\n\t}\n\treturn 1;\n}\n#endif  /* DUK_USE_OBJECT_BUILTIN || DUK_USE_REFLECT_BUILTIN */\n\n#if defined(DUK_USE_OBJECT_BUILTIN) || defined(DUK_USE_REFLECT_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_object_constructor_get_own_property_descriptor(duk_context *ctx) {\n\tDUK_ASSERT_TOP(ctx, 2);\n\n\t/* ES2015 Section 19.1.2.6, step 1 */\n\tif (duk_get_current_magic(ctx) == 0) {\n\t\tduk_to_object(ctx, 0);\n\t}\n\n\t/* [ obj key ] */\n\n\tduk_hobject_object_get_own_property_descriptor(ctx, -2);\n\treturn 1;\n}\n#endif  /* DUK_USE_OBJECT_BUILTIN || DUK_USE_REFLECT_BUILTIN */\n\n#if defined(DUK_USE_OBJECT_BUILTIN) || defined(DUK_USE_REFLECT_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_object_constructor_is_extensible(duk_context *ctx) {\n\t/*\n\t *  magic = 0: Object.isExtensible()\n\t *  magic = 1: Reflect.isExtensible()\n\t */\n\n\tduk_hobject *h;\n\n\tif (duk_get_current_magic(ctx) == 0) {\n\t\th = duk_get_hobject(ctx, 0);\n\t} else {\n\t\t/* Reflect.isExtensible(): throw if non-object, but we accept lightfuncs\n\t\t * and plain buffers here because they pretend to be objects.\n\t\t */\n\t\th = duk_require_hobject_accept_mask(ctx, 0, DUK_TYPE_MASK_LIGHTFUNC | DUK_TYPE_MASK_BUFFER);\n\t}\n\n\tduk_push_boolean(ctx, (h != NULL) && DUK_HOBJECT_HAS_EXTENSIBLE(h));\n\treturn 1;\n}\n#endif  /* DUK_USE_OBJECT_BUILTIN || DUK_USE_REFLECT_BUILTIN */\n\n#if defined(DUK_USE_OBJECT_BUILTIN) || defined(DUK_USE_REFLECT_BUILTIN)\n/* Shared helper for various key/symbol listings, magic:\n * 0=Object.keys()\n * 1=Object.getOwnPropertyNames(),\n * 2=Object.getOwnPropertySymbols(),\n * 3=Reflect.ownKeys()\n */\nDUK_LOCAL const duk_small_uint_t duk__object_keys_enum_flags[4] = {\n\t/* Object.keys() */\n\tDUK_ENUM_OWN_PROPERTIES_ONLY |\n\t    DUK_ENUM_NO_PROXY_BEHAVIOR,\n\n\t/* Object.getOwnPropertyNames() */\n\tDUK_ENUM_INCLUDE_NONENUMERABLE |\n\t    DUK_ENUM_OWN_PROPERTIES_ONLY |\n\t    DUK_ENUM_NO_PROXY_BEHAVIOR,\n\n\t/* Object.getOwnPropertySymbols() */\n\tDUK_ENUM_INCLUDE_SYMBOLS |\n\t    DUK_ENUM_OWN_PROPERTIES_ONLY |\n\t    DUK_ENUM_EXCLUDE_STRINGS |\n\t    DUK_ENUM_INCLUDE_NONENUMERABLE |\n\t    DUK_ENUM_NO_PROXY_BEHAVIOR,\n\n\t/* Reflect.ownKeys() */\n\tDUK_ENUM_INCLUDE_SYMBOLS |\n\t    DUK_ENUM_OWN_PROPERTIES_ONLY |\n\t    DUK_ENUM_INCLUDE_NONENUMERABLE |\n\t    DUK_ENUM_NO_PROXY_BEHAVIOR\n};\n\nDUK_INTERNAL duk_ret_t duk_bi_object_constructor_keys_shared(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *obj;\n#if defined(DUK_USE_ES6_PROXY)\n\tduk_hobject *h_proxy_target;\n\tduk_hobject *h_proxy_handler;\n\tduk_hobject *h_trap_result;\n#endif\n\tduk_small_uint_t enum_flags;\n\tduk_int_t magic;\n\n\tDUK_ASSERT_TOP(ctx, 1);\n\tDUK_UNREF(thr);\n\n\tmagic = duk_get_current_magic(ctx);\n\tif (magic == 3) {\n\t\t/* ES2015 Section 26.1.11 requires a TypeError for non-objects.  Lightfuncs\n\t\t * and plain buffers pretend to be objects, so accept those too.\n\t\t */\n\t\tobj = duk_require_hobject_promote_mask(ctx, 0, DUK_TYPE_MASK_LIGHTFUNC | DUK_TYPE_MASK_BUFFER);\n\t} else {\n\t\t/* ES2015: ToObject coerce. */\n\t\tobj = duk_to_hobject(ctx, 0);\n\t}\n\tDUK_ASSERT(obj != NULL);\n\tDUK_UNREF(obj);\n\n\t/* XXX: proxy chains */\n\n#if defined(DUK_USE_ES6_PROXY)\n\t/* XXX: better sharing of code between proxy target call sites */\n\tif (DUK_LIKELY(!duk_hobject_proxy_check(thr,\n\t                                        obj,\n\t                                        &h_proxy_target,\n\t                                        &h_proxy_handler))) {\n\t\tgoto skip_proxy;\n\t}\n\n\tduk_push_hobject(ctx, h_proxy_handler);\n\tif (!duk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_OWN_KEYS)) {\n\t\t/* Careful with reachability here: don't pop 'obj' before pushing\n\t\t * proxy target.\n\t\t */\n\t\tDUK_DDD(DUK_DDDPRINT(\"no ownKeys trap, get keys of target instead\"));\n\t\tduk_pop_2(ctx);\n\t\tduk_push_hobject(ctx, h_proxy_target);\n\t\tduk_replace(ctx, 0);\n\t\tDUK_ASSERT_TOP(ctx, 1);\n\t\tgoto skip_proxy;\n\t}\n\n\t/* [ obj handler trap ] */\n\tduk_insert(ctx, -2);\n\tduk_push_hobject(ctx, h_proxy_target);  /* -> [ obj trap handler target ] */\n\tduk_call_method(ctx, 1 /*nargs*/);      /* -> [ obj trap_result ] */\n\th_trap_result = duk_require_hobject(ctx, -1);\n\tDUK_UNREF(h_trap_result);\n\n\tmagic = duk_get_current_magic(ctx);\n\tDUK_ASSERT(magic >= 0 && magic < (duk_int_t) (sizeof(duk__object_keys_enum_flags) / sizeof(duk_small_uint_t)));\n\tenum_flags = duk__object_keys_enum_flags[magic];\n\n\tduk_proxy_ownkeys_postprocess(ctx, h_proxy_target, enum_flags);\n\treturn 1;\n\n skip_proxy:\n#endif  /* DUK_USE_ES6_PROXY */\n\n\tDUK_ASSERT_TOP(ctx, 1);\n\tmagic = duk_get_current_magic(ctx);\n\tDUK_ASSERT(magic >= 0 && magic < (duk_int_t) (sizeof(duk__object_keys_enum_flags) / sizeof(duk_small_uint_t)));\n\tenum_flags = duk__object_keys_enum_flags[magic];\n\treturn duk_hobject_get_enumerated_keys(ctx, enum_flags);\n}\n#endif  /* DUK_USE_OBJECT_BUILTIN || DUK_USE_REFLECT_BUILTIN */\n\n#if defined(DUK_USE_OBJECT_BUILTIN) || defined(DUK_USE_REFLECT_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_object_constructor_prevent_extensions(duk_context *ctx) {\n\t/*\n\t *  magic = 0: Object.preventExtensions()\n\t *  magic = 1: Reflect.preventExtensions()\n\t */\n\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *h;\n\tduk_uint_t mask;\n\tduk_int_t magic;\n\n\tmagic = duk_get_current_magic(ctx);\n\n\t/* Silent success for lightfuncs and plain buffers always. */\n\tmask = DUK_TYPE_MASK_LIGHTFUNC | DUK_TYPE_MASK_BUFFER;\n\n\t/* Object.preventExtensions() silent success for non-object. */\n\tif (magic == 0) {\n\t\tmask |= DUK_TYPE_MASK_UNDEFINED |\n\t\t        DUK_TYPE_MASK_NULL |\n\t\t        DUK_TYPE_MASK_BOOLEAN |\n\t\t        DUK_TYPE_MASK_NUMBER |\n\t\t        DUK_TYPE_MASK_STRING |\n\t\t        DUK_TYPE_MASK_POINTER;\n\t}\n\n\tif (duk_check_type_mask(ctx, 0, mask)) {\n\t\t/* Not an object, already non-extensible so always success. */\n\t\tgoto done;\n\t}\n\th = duk_require_hobject(ctx, 0);\n\tDUK_ASSERT(h != NULL);\n\n\tDUK_HOBJECT_CLEAR_EXTENSIBLE(h);\n\n\t/* A non-extensible object cannot gain any more properties,\n\t * so this is a good time to compact.\n\t */\n\tduk_hobject_compact_props(thr, h);\n\n done:\n\tif (magic == 1) {\n\t\tduk_push_true(ctx);\n\t}\n\treturn 1;\n}\n#endif  /* DUK_USE_OBJECT_BUILTIN || DUK_USE_REFLECT_BUILTIN */\n/*\n *  Pointer built-ins\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Constructor\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_pointer_constructor(duk_context *ctx) {\n\t/* XXX: this behavior is quite useless now; it would be nice to be able\n\t * to create pointer values from e.g. numbers or strings.  Numbers are\n\t * problematic on 64-bit platforms though.  Hex encoded strings?\n\t */\n\tif (duk_get_top(ctx) == 0) {\n\t\tduk_push_pointer(ctx, NULL);\n\t} else {\n\t\tduk_to_pointer(ctx, 0);\n\t}\n\tDUK_ASSERT(duk_is_pointer(ctx, 0));\n\tduk_set_top(ctx, 1);\n\n\tif (duk_is_constructor_call(ctx)) {\n\t\t(void) duk_push_object_helper(ctx,\n\t\t                              DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t\t                              DUK_HOBJECT_FLAG_FASTREFS |\n\t\t                              DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_POINTER),\n\t\t                              DUK_BIDX_POINTER_PROTOTYPE);\n\n\t\t/* Pointer object internal value is immutable */\n\t\tduk_dup_0(ctx);\n\t\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_VALUE, DUK_PROPDESC_FLAGS_NONE);\n\t}\n\t/* Note: unbalanced stack on purpose */\n\n\treturn 1;\n}\n\n/*\n *  toString(), valueOf()\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_pointer_prototype_tostring_shared(duk_context *ctx) {\n\tduk_tval *tv;\n\tduk_small_int_t to_string = duk_get_current_magic(ctx);\n\n\tduk_push_this(ctx);\n\ttv = duk_require_tval(ctx, -1);\n\tDUK_ASSERT(tv != NULL);\n\n\tif (DUK_TVAL_IS_POINTER(tv)) {\n\t\t/* nop */\n\t} else if (DUK_TVAL_IS_OBJECT(tv)) {\n\t\tduk_hobject *h = DUK_TVAL_GET_OBJECT(tv);\n\t\tDUK_ASSERT(h != NULL);\n\n\t\t/* Must be a \"pointer object\", i.e. class \"Pointer\" */\n\t\tif (DUK_HOBJECT_GET_CLASS_NUMBER(h) != DUK_HOBJECT_CLASS_POINTER) {\n\t\t\tgoto type_error;\n\t\t}\n\n\t\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_INT_VALUE);\n\t} else {\n\t\tgoto type_error;\n\t}\n\n\tif (to_string) {\n\t\tduk_to_string(ctx, -1);\n\t}\n\treturn 1;\n\n type_error:\n\tDUK_DCERROR_TYPE_INVALID_ARGS((duk_hthread *) ctx);\n}\n/*\n *  Proxy built-in (ES2015)\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_ES6_PROXY)\n/* Post-process a Proxy ownKeys() result at stack top.  Push a cleaned up\n * array of valid result keys (strings or symbols).  TypeError for invalid\n * values.  Flags are shared with duk_enum().\n */\nDUK_INTERNAL void duk_proxy_ownkeys_postprocess(duk_context *ctx, duk_hobject *h_proxy_target, duk_uint_t flags) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_uarridx_t i, len, idx;\n\tduk_propdesc desc;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(h_proxy_target != NULL);\n\n\tlen = (duk_uarridx_t) duk_get_length(ctx, -1);\n\tidx = 0;\n\tduk_push_array(ctx);\n\t/* XXX: preallocated dense array, fill in directly */\n\tfor (i = 0; i < len; i++) {\n\t\tduk_hstring *h;\n\n\t\t/* [ obj trap_result res_arr ] */\n\t\t(void) duk_get_prop_index(ctx, -2, i);\n\t\th = duk_get_hstring(ctx, -1);\n\t\tif (h == NULL) {\n\t\t\tDUK_ERROR_TYPE_INVALID_TRAP_RESULT(thr);\n\t\t}\n\n\t\tif (!(flags & DUK_ENUM_INCLUDE_NONENUMERABLE)) {\n\t\t\t/* No support for 'getOwnPropertyDescriptor' trap yet,\n\t\t\t * so check enumerability always from target object\n\t\t\t * descriptor.\n\t\t\t */\n\t\t\tif (duk_hobject_get_own_propdesc(thr, h_proxy_target, duk_known_hstring(ctx, -1), &desc, 0 /*flags*/)) {\n\t\t\t\tif ((desc.flags & DUK_PROPDESC_FLAG_ENUMERABLE) == 0) {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"ignore non-enumerable property: %!T\", duk_get_tval(ctx, -1)));\n\t\t\t\t\tgoto skip_key;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"ignore non-existent property: %!T\", duk_get_tval(ctx, -1)));\n\t\t\t\tgoto skip_key;\n\t\t\t}\n\t\t}\n\t\tif (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) {\n\t\t\tif (!(flags & DUK_ENUM_INCLUDE_SYMBOLS)) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"ignore symbol property: %!T\", duk_get_tval(ctx, -1)));\n\t\t\t\tgoto skip_key;\n\t\t\t}\n\t\t\tif (DUK_HSTRING_HAS_HIDDEN(h) && !(flags & DUK_ENUM_INCLUDE_HIDDEN)) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"ignore hidden symbol property: %!T\", duk_get_tval(ctx, -1)));\n\t\t\t\tgoto skip_key;\n\t\t\t}\n\t\t} else {\n\t\t\tif (flags & DUK_ENUM_EXCLUDE_STRINGS) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"ignore string property: %!T\", duk_get_tval(ctx, -1)));\n\t\t\t\tgoto skip_key;\n\t\t\t}\n\t\t}\n\n\t\t/* [ obj trap_result res_arr propname ] */\n\t\tduk_put_prop_index(ctx, -2, idx++);\n\t\tcontinue;\n\n\t skip_key:\n\t\tduk_pop(ctx);\n\t\tcontinue;\n\t}\n\n\t/* XXX: Missing trap result validation for non-configurable target keys\n\t * (must be present), for non-extensible target all target keys must be\n\t * present and no extra keys can be present.\n\t * http://www.ecma-international.org/ecma-262/6.0/#sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys\n\t */\n\n\t/* XXX: The key enumerability check should trigger the \"getOwnPropertyDescriptor\"\n\t * trap which has not yet been implemented.  In the absence of such a trap,\n\t * the enumerability should be checked from the target object; this is\n\t * handled above.\n\t */\n}\n#endif  /* DUK_USE_ES6_PROXY */\n\n#if defined(DUK_USE_ES6_PROXY)\nDUK_INTERNAL duk_ret_t duk_bi_proxy_constructor(duk_context *ctx) {\n\tduk_hobject *h_target;\n\tduk_hobject *h_handler;\n\n\tduk_require_constructor_call(ctx);\n\n\t/* Reject a proxy object as the target because it would need\n\t * special handler in property lookups.  (ES2015 has no such restriction)\n\t */\n\th_target = duk_require_hobject_promote_mask(ctx, 0, DUK_TYPE_MASK_LIGHTFUNC | DUK_TYPE_MASK_BUFFER);\n\tDUK_ASSERT(h_target != NULL);\n\tif (DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(h_target)) {\n\t\tgoto fail_args;\n\t}\n\n\t/* Reject a proxy object as the handler because it would cause\n\t * potentially unbounded recursion.  (ES2015 has no such restriction)\n\t *\n\t * There's little practical reason to use a lightfunc or a plain\n\t * buffer as the handler table: one could only provide traps via\n\t * their prototype objects (Function.prototype and ArrayBuffer.prototype).\n\t * Even so, as lightfuncs and plain buffers mimic their object\n\t * counterparts, they're promoted and accepted here.\n\t */\n\th_handler = duk_require_hobject_promote_mask(ctx, 1, DUK_TYPE_MASK_LIGHTFUNC | DUK_TYPE_MASK_BUFFER);\n\tDUK_ASSERT(h_handler != NULL);\n\tif (DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(h_handler)) {\n\t\tgoto fail_args;\n\t}\n\n\t/* XXX: the returned value is exotic in ES2015, but we use a\n\t * simple object here with no prototype.  Without a prototype,\n\t * ToPrimitive() coercion fails which is a bit confusing.\n\t * No callable check/handling in the current Proxy subset.\n\t */\n\t(void) duk_push_object_helper_proto(ctx,\n\t                                    DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                                    DUK_HOBJECT_FLAG_FASTREFS |\n\t                                    DUK_HOBJECT_FLAG_EXOTIC_PROXYOBJ |\n\t                                    DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_OBJECT),\n\t                                    NULL);\n\tDUK_ASSERT_TOP(ctx, 3);\n\n\t/* Make _Target and _Handler non-configurable and non-writable.\n\t * They can still be forcibly changed by C code (both user and\n\t * Duktape internal), but not by Ecmascript code.\n\t */\n\n\t/* Proxy target */\n\tduk_dup_0(ctx);\n\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_TARGET, DUK_PROPDESC_FLAGS_NONE);\n\n\t/* Proxy handler */\n\tduk_dup_1(ctx);\n\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_HANDLER, DUK_PROPDESC_FLAGS_NONE);\n\n\treturn 1;  /* replacement handler */\n\n fail_args:\n\tDUK_DCERROR_TYPE_INVALID_ARGS((duk_hthread *) ctx);\n}\n#endif  /* DUK_USE_ES6_PROXY */\n/*\n *  'Reflect' built-in (ES2016 Section 26.1)\n *  http://www.ecma-international.org/ecma-262/7.0/#sec-reflect-object\n *\n *  Many Reflect built-in functions are provided by shared helpers in\n *  duk_bi_object.c or duk_bi_function.c.\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_REFLECT_BUILTIN)\nDUK_INTERNAL duk_ret_t duk_bi_reflect_object_delete_property(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_tval *tv_obj;\n\tduk_tval *tv_key;\n\tduk_bool_t ret;\n\n\tDUK_ASSERT_TOP(ctx, 2);\n\t(void) duk_require_hobject(ctx, 0);\n\t(void) duk_to_string(ctx, 1);\n\n\t/* [ target key ] */\n\n\tthr = (duk_hthread *) ctx;\n\tDUK_ASSERT(thr != NULL);\n\ttv_obj = DUK_GET_TVAL_POSIDX(ctx, 0);\n\ttv_key = DUK_GET_TVAL_POSIDX(ctx, 1);\n\tret = duk_hobject_delprop(thr, tv_obj, tv_key, 0 /*throw_flag*/);\n\tduk_push_boolean(ctx, ret);\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_reflect_object_get(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_tval *tv_obj;\n\tduk_tval *tv_key;\n\tduk_idx_t nargs;\n\n\tnargs = duk_get_top_require_min(ctx, 2 /*min_top*/);\n\t(void) duk_require_hobject(ctx, 0);\n\t(void) duk_to_string(ctx, 1);\n\tif (nargs >= 3 && !duk_strict_equals(ctx, 0, 2)) {\n\t\t/* XXX: [[Get]] receiver currently unsupported */\n\t\tDUK_ERROR_UNSUPPORTED((duk_hthread *) ctx);\n\t}\n\n\t/* [ target key receiver? ...? ] */\n\n\tthr = (duk_hthread *) ctx;\n\tDUK_ASSERT(thr != NULL);\n\ttv_obj = DUK_GET_TVAL_POSIDX(ctx, 0);\n\ttv_key = DUK_GET_TVAL_POSIDX(ctx, 1);\n\t(void) duk_hobject_getprop(thr, tv_obj, tv_key);  /* This could also be a duk_get_prop(). */\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_reflect_object_has(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_tval *tv_obj;\n\tduk_tval *tv_key;\n\tduk_bool_t ret;\n\n\tDUK_ASSERT_TOP(ctx, 2);\n\t(void) duk_require_hobject(ctx, 0);\n\t(void) duk_to_string(ctx, 1);\n\n\t/* [ target key ] */\n\n\tthr = (duk_hthread *) ctx;\n\tDUK_ASSERT(thr != NULL);\n\ttv_obj = DUK_GET_TVAL_POSIDX(ctx, 0);\n\ttv_key = DUK_GET_TVAL_POSIDX(ctx, 1);\n\tret = duk_hobject_hasprop(thr, tv_obj, tv_key);\n\tduk_push_boolean(ctx, ret);\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_reflect_object_set(duk_context *ctx) {\n\tduk_hthread *thr;\n\tduk_tval *tv_obj;\n\tduk_tval *tv_key;\n\tduk_tval *tv_val;\n\tduk_idx_t nargs;\n\tduk_bool_t ret;\n\n\tnargs = duk_get_top_require_min(ctx, 3 /*min_top*/);\n\t(void) duk_require_hobject(ctx, 0);\n\t(void) duk_to_string(ctx, 1);\n\tif (nargs >= 4 && !duk_strict_equals(ctx, 0, 3)) {\n\t\t/* XXX: [[Set]] receiver currently unsupported */\n\t\tDUK_ERROR_UNSUPPORTED((duk_hthread *) ctx);\n\t}\n\n\t/* [ target key value receiver? ...? ] */\n\n\tthr = (duk_hthread *) ctx;\n\tDUK_ASSERT(thr != NULL);\n\ttv_obj = DUK_GET_TVAL_POSIDX(ctx, 0);\n\ttv_key = DUK_GET_TVAL_POSIDX(ctx, 1);\n\ttv_val = DUK_GET_TVAL_POSIDX(ctx, 2);\n\tret = duk_hobject_putprop(thr, tv_obj, tv_key, tv_val, 0 /*throw_flag*/);\n\tduk_push_boolean(ctx, ret);\n\treturn 1;\n}\n#endif  /* DUK_USE_REFLECT_BUILTIN */\n/*\n *  RegExp built-ins\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\nDUK_LOCAL void duk__get_this_regexp(duk_context *ctx) {\n\tduk_hobject *h;\n\n\tduk_push_this(ctx);\n\th = duk_require_hobject_with_class(ctx, -1, DUK_HOBJECT_CLASS_REGEXP);\n\tDUK_ASSERT(h != NULL);\n\tDUK_UNREF(h);\n\tduk_insert(ctx, 0);  /* prepend regexp to valstack 0 index */\n}\n\n/* XXX: much to improve (code size) */\nDUK_INTERNAL duk_ret_t duk_bi_regexp_constructor(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *h_pattern;\n\n\tDUK_ASSERT_TOP(ctx, 2);\n\th_pattern = duk_get_hobject(ctx, 0);\n\n\tif (!duk_is_constructor_call(ctx) &&\n\t    h_pattern != NULL &&\n\t    DUK_HOBJECT_GET_CLASS_NUMBER(h_pattern) == DUK_HOBJECT_CLASS_REGEXP &&\n\t    duk_is_undefined(ctx, 1)) {\n\t\t/* Called as a function, pattern has [[Class]] \"RegExp\" and\n\t\t * flags is undefined -> return object as is.\n\t\t */\n\t\t/* XXX: ES2015 has a NewTarget SameValue() check which is not\n\t\t * yet implemented.\n\t\t */\n\t\tduk_dup_0(ctx);\n\t\treturn 1;\n\t}\n\n\t/* Else functionality is identical for function call and constructor\n\t * call.\n\t */\n\n\tif (h_pattern != NULL &&\n\t    DUK_HOBJECT_GET_CLASS_NUMBER(h_pattern) == DUK_HOBJECT_CLASS_REGEXP) {\n\t\tduk_get_prop_stridx_short(ctx, 0, DUK_STRIDX_SOURCE);\n\t\tif (duk_is_undefined(ctx, 1)) {\n\t\t\t/* In ES5 one would need to read the flags individually;\n\t\t\t * in ES2015 just read .flags.\n\t\t\t */\n\t\t\tduk_get_prop_stridx(ctx, 0, DUK_STRIDX_FLAGS);\n\t\t} else {\n\t\t\t/* In ES2015 allowed; overrides argument RegExp flags. */\n\t\t\tduk_dup_1(ctx);\n\t\t}\n\t} else {\n\t\tif (duk_is_undefined(ctx, 0)) {\n\t\t\tduk_push_hstring_empty(ctx);\n\t\t} else {\n\t\t\tduk_dup_0(ctx);\n\t\t\tduk_to_string(ctx, -1);  /* Rejects Symbols. */\n\t\t}\n\t\tif (duk_is_undefined(ctx, 1)) {\n\t\t\tduk_push_hstring_empty(ctx);\n\t\t} else {\n\t\t\tduk_dup_1(ctx);\n\t\t\tduk_to_string(ctx, -1);  /* Rejects Symbols. */\n\t\t}\n\n\t\t/* [ ... pattern flags ] */\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"RegExp constructor/function call, pattern=%!T, flags=%!T\",\n\t                     (duk_tval *) duk_get_tval(ctx, -2), (duk_tval *) duk_get_tval(ctx, -1)));\n\n\t/* [ ... pattern flags ] (both uncoerced) */\n\n\tduk_to_string(ctx, -2);\n\tduk_to_string(ctx, -1);\n\tduk_regexp_compile(thr);\n\n\t/* [ ... bytecode escaped_source ] */\n\n\tduk_regexp_create_instance(thr);\n\n\t/* [ ... RegExp ] */\n\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_regexp_prototype_exec(duk_context *ctx) {\n\tduk__get_this_regexp(ctx);\n\n\t/* [ regexp input ] */\n\n\tduk_regexp_match((duk_hthread *) ctx);\n\n\t/* [ result ] */\n\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_regexp_prototype_test(duk_context *ctx) {\n\tduk__get_this_regexp(ctx);\n\n\t/* [ regexp input ] */\n\n\t/* result object is created and discarded; wasteful but saves code space */\n\tduk_regexp_match((duk_hthread *) ctx);\n\n\t/* [ result ] */\n\n\tduk_push_boolean(ctx, (duk_is_null(ctx, -1) ? 0 : 1));\n\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_regexp_prototype_tostring(duk_context *ctx) {\n\t/* This must be generic in ES2015 and later. */\n\tDUK_ASSERT_TOP(ctx, 0);\n\tduk_push_this(ctx);\n\tduk_push_string(ctx, \"/\");\n\tduk_get_prop_stridx(ctx, 0, DUK_STRIDX_SOURCE);\n\tduk_dup_m2(ctx);  /* another \"/\" */\n\tduk_get_prop_stridx(ctx, 0, DUK_STRIDX_FLAGS);\n\tduk_concat(ctx, 4);\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_regexp_prototype_flags(duk_context *ctx) {\n\t/* .flags is ES2015 but present even when ES2015 bindings are\n\t * disabled because the constructor relies on it.\n\t */\n\tduk_uint8_t buf[8];  /* enough for all flags + NUL */\n\tduk_uint8_t *p = buf;\n\n\t/* .flags is generic and works on any object. */\n\tduk_push_this(ctx);\n\t(void) duk_require_hobject(ctx, -1);\n\tif (duk_get_prop_stridx_boolean(ctx, 0, DUK_STRIDX_GLOBAL, NULL)) {\n\t\t*p++ = DUK_ASC_LC_G;\n\t}\n\tif (duk_get_prop_stridx_boolean(ctx, 0, DUK_STRIDX_IGNORE_CASE, NULL)) {\n\t\t*p++ = DUK_ASC_LC_I;\n\t}\n\tif (duk_get_prop_stridx_boolean(ctx, 0, DUK_STRIDX_MULTILINE, NULL)) {\n\t\t*p++ = DUK_ASC_LC_M;\n\t}\n\t/* .unicode: to be added */\n\t/* .sticky: to be added */\n\t*p++ = DUK_ASC_NUL;\n\tDUK_ASSERT((duk_size_t) (p - buf) <= sizeof(buf));\n\n\tduk_push_string(ctx, (const char *) buf);\n\treturn 1;\n}\n\n/* Shared helper for providing .source, .global, .multiline, etc getters. */\nDUK_INTERNAL duk_ret_t duk_bi_regexp_prototype_shared_getter(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hstring *h_bc;\n\tduk_small_int_t re_flags;\n\tduk_hobject *h;\n\tduk_int_t magic;\n\n\tDUK_ASSERT_TOP(ctx, 0);\n\n\tduk_push_this(ctx);\n\th = duk_require_hobject(ctx, -1);\n\tmagic = duk_get_current_magic(ctx);\n\n\tif (DUK_HOBJECT_GET_CLASS_NUMBER(h) == DUK_HOBJECT_CLASS_REGEXP) {\n\t\tduk_get_prop_stridx_short(ctx, 0, DUK_STRIDX_INT_SOURCE);\n\t\tduk_get_prop_stridx_short(ctx, 0, DUK_STRIDX_INT_BYTECODE);\n\t\th_bc = duk_require_hstring(ctx, -1);\n\t\tre_flags = (duk_small_int_t) DUK_HSTRING_GET_DATA(h_bc)[0];  /* Safe even if h_bc length is 0 (= NUL) */\n\t\tduk_pop(ctx);\n\t} else if (h == thr->builtins[DUK_BIDX_REGEXP_PROTOTYPE]) {\n\t\t/* In ES2015 and ES2016 a TypeError would be thrown here.\n\t\t * However, this had real world issues so ES2017 draft\n\t\t * allows RegExp.prototype specifically, returning '(?:)'\n\t\t * for .source and undefined for all flags.\n\t\t */\n\t\tif (magic != 16 /* .source */) {\n\t\t\treturn 0;\n\t\t}\n\t\tduk_push_string(ctx, \"(?:)\");  /* .source handled by switch-case */\n\t\tre_flags = 0;\n\t} else {\n\t\tDUK_DCERROR_TYPE_INVALID_ARGS(thr);\n\t}\n\n\t/* [ regexp source ] */\n\n\tswitch (magic) {\n\tcase 0: {  /* global */\n\t\tduk_push_boolean(ctx, (re_flags & DUK_RE_FLAG_GLOBAL));\n\t\tbreak;\n\t}\n\tcase 1: {  /* ignoreCase */\n\t\tduk_push_boolean(ctx, (re_flags & DUK_RE_FLAG_IGNORE_CASE));\n\t\tbreak;\n\t}\n\tcase 2: {  /* multiline */\n\t\tduk_push_boolean(ctx, (re_flags & DUK_RE_FLAG_MULTILINE));\n\t\tbreak;\n\t}\n#if 0\n\t/* Don't provide until implemented to avoid interfering with feature\n\t * detection in user code.\n\t */\n\tcase 3:    /* sticky */\n\tcase 4: {  /* unicode */\n\t\tduk_push_false(ctx);\n\t\tbreak;\n\t}\n#endif\n\tdefault: {  /* source */\n\t\t/* leave 'source' on top */\n\t\tbreak;\n\t}\n\t}\n\n\treturn 1;\n}\n\n#endif  /* DUK_USE_REGEXP_SUPPORT */\n/*\n *  String built-ins\n *\n *  Most String built-ins must only accept strings (or String objects).\n *  Symbols, represented internally as strings, must be generally rejected.\n *  The duk_push_this_coercible_to_string() helper does this automatically.\n */\n\n/* XXX: There are several limitations in the current implementation for\n * strings with >= 0x80000000UL characters.  In some cases one would need\n * to be able to represent the range [-0xffffffff,0xffffffff] and so on.\n * Generally character and byte length are assumed to fit into signed 32\n * bits (< 0x80000000UL).  Places with issues are not marked explicitly\n * below in all cases, look for signed type usage (duk_int_t etc) for\n * offsets/lengths.\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_STRING_BUILTIN)\n\n/*\n *  Helpers\n */\n\nDUK_LOCAL duk_hstring *duk__str_tostring_notregexp(duk_context *ctx, duk_idx_t idx) {\n\tduk_hstring *h;\n\n\tif (duk_get_class_number(ctx, idx) == DUK_HOBJECT_CLASS_REGEXP) {\n\t\tDUK_ERROR_TYPE_INVALID_ARGS((duk_hthread *) ctx);\n\t}\n\th = duk_to_hstring(ctx, idx);\n\tDUK_ASSERT(h != NULL);\n\n\treturn h;\n}\n\nDUK_LOCAL duk_int_t duk__str_search_shared(duk_context *ctx, duk_hstring *h_this, duk_hstring *h_search, duk_int_t start_cpos, duk_bool_t backwards) {\n\tduk_int_t cpos;\n\tduk_int_t bpos;\n\tconst duk_uint8_t *p_start, *p_end, *p;\n\tconst duk_uint8_t *q_start;\n\tduk_int_t q_blen;\n\tduk_uint8_t firstbyte;\n\tduk_uint8_t t;\n\n\tcpos = start_cpos;\n\n\t/* Empty searchstring always matches; cpos must be clamped here.\n\t * (If q_blen were < 0 due to clamped coercion, it would also be\n\t * caught here.)\n\t */\n\tq_start = DUK_HSTRING_GET_DATA(h_search);\n\tq_blen = (duk_int_t) DUK_HSTRING_GET_BYTELEN(h_search);\n\tif (q_blen <= 0) {\n\t\treturn cpos;\n\t}\n\tDUK_ASSERT(q_blen > 0);\n\n\tbpos = (duk_int_t) duk_heap_strcache_offset_char2byte((duk_hthread *) ctx, h_this, (duk_uint32_t) cpos);\n\n\tp_start = DUK_HSTRING_GET_DATA(h_this);\n\tp_end = p_start + DUK_HSTRING_GET_BYTELEN(h_this);\n\tp = p_start + bpos;\n\n\t/* This loop is optimized for size.  For speed, there should be\n\t * two separate loops, and we should ensure that memcmp() can be\n\t * used without an extra \"will searchstring fit\" check.  Doing\n\t * the preconditioning for 'p' and 'p_end' is easy but cpos\n\t * must be updated if 'p' is wound back (backward scanning).\n\t */\n\n\tfirstbyte = q_start[0];  /* leading byte of match string */\n\twhile (p <= p_end && p >= p_start) {\n\t\tt = *p;\n\n\t\t/* For Ecmascript strings, this check can only match for\n\t\t * initial UTF-8 bytes (not continuation bytes).  For other\n\t\t * strings all bets are off.\n\t\t */\n\n\t\tif ((t == firstbyte) && ((duk_size_t) (p_end - p) >= (duk_size_t) q_blen)) {\n\t\t\tDUK_ASSERT(q_blen > 0);  /* no issues with memcmp() zero size, even if broken */\n\t\t\tif (DUK_MEMCMP((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) {\n\t\t\t\treturn cpos;\n\t\t\t}\n\t\t}\n\n\t\t/* track cpos while scanning */\n\t\tif (backwards) {\n\t\t\t/* when going backwards, we decrement cpos 'early';\n\t\t\t * 'p' may point to a continuation byte of the char\n\t\t\t * at offset 'cpos', but that's OK because we'll\n\t\t\t * backtrack all the way to the initial byte.\n\t\t\t */\n\t\t\tif ((t & 0xc0) != 0x80) {\n\t\t\t\tcpos--;\n\t\t\t}\n\t\t\tp--;\n\t\t} else {\n\t\t\tif ((t & 0xc0) != 0x80) {\n\t\t\t\tcpos++;\n\t\t\t}\n\t\t\tp++;\n\t\t}\n\t}\n\n\t/* Not found.  Empty string case is handled specially above. */\n\treturn -1;\n}\n\n/*\n *  Constructor\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_string_constructor(duk_context *ctx) {\n\tduk_hstring *h;\n\tduk_uint_t flags;\n\n\t/* String constructor needs to distinguish between an argument not given at all\n\t * vs. given as 'undefined'.  We're a vararg function to handle this properly.\n\t */\n\n\t/* XXX: copy current activation flags to thr, including current magic,\n\t * is_constructor_call etc.  This takes a few bytes in duk_hthread but\n\t * makes call sites smaller (there are >30 is_constructor_call and get\n\t * current magic call sites.\n\t */\n\n\tif (duk_get_top(ctx) == 0) {\n\t\tduk_push_hstring_empty(ctx);\n\t} else {\n\t\th = duk_to_hstring_acceptsymbol(ctx, 0);\n\t\tif (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h) && !duk_is_constructor_call(ctx))) {\n\t\t\tduk_push_symbol_descriptive_string(ctx, h);\n\t\t\tduk_replace(ctx, 0);\n\t\t}\n\t}\n\tduk_to_string(ctx, 0);  /* catches symbol argument for constructor call */\n\tDUK_ASSERT(duk_is_string(ctx, 0));\n\tduk_set_top(ctx, 1);  /* Top may be 1 or larger. */\n\n\tif (duk_is_constructor_call(ctx)) {\n\t\t/* String object internal value is immutable */\n\t\tflags = DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t\t        DUK_HOBJECT_FLAG_FASTREFS |\n\t\t        DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ |\n\t\t        DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_STRING);\n\t\tduk_push_object_helper(ctx, flags, DUK_BIDX_STRING_PROTOTYPE);\n\t\tduk_dup_0(ctx);\n\t\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_VALUE, DUK_PROPDESC_FLAGS_NONE);\n\t}\n\t/* Note: unbalanced stack on purpose */\n\n\treturn 1;\n}\n\nDUK_LOCAL duk_ret_t duk__construct_from_codepoints(duk_context *ctx, duk_bool_t nonbmp) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_bufwriter_ctx bw_alloc;\n\tduk_bufwriter_ctx *bw;\n\tduk_idx_t i, n;\n\tduk_ucodepoint_t cp;\n\n\t/* XXX: It would be nice to build the string directly but ToUint16()\n\t * coercion is needed so a generic helper would not be very\n\t * helpful (perhaps coerce the value stack first here and then\n\t * build a string from a duk_tval number sequence in one go?).\n\t */\n\n\tn = duk_get_top(ctx);\n\n\tbw = &bw_alloc;\n\tDUK_BW_INIT_PUSHBUF(thr, bw, n);  /* initial estimate for ASCII only codepoints */\n\n\tfor (i = 0; i < n; i++) {\n\t\t/* XXX: could improve bufwriter handling to write multiple codepoints\n\t\t * with one ensure call but the relative benefit would be quite small.\n\t\t */\n\n\t\tif (nonbmp) {\n\t\t\t/* ES2015 requires that (1) SameValue(cp, ToInteger(cp)) and\n\t\t\t * (2) cp >= 0 and cp <= 0x10ffff.  This check does not\n\t\t\t * implement the steps exactly but the outcome should be\n\t\t\t * the same.\n\t\t\t */\n\t\t\tduk_int32_t i32 = 0;\n\t\t\tif (!duk_is_whole_get_int32(duk_to_number(ctx, i), &i32) ||\n\t\t\t    i32 < 0 || i32 > 0x10ffffL) {\n\t\t\t\tDUK_DCERROR_RANGE_INVALID_ARGS((duk_hthread *) ctx);\n\t\t\t}\n\t\t\tDUK_ASSERT(i32 >= 0 && i32 <= 0x10ffffL);\n\t\t\tcp = (duk_ucodepoint_t) i32;\n\t\t\tDUK_BW_WRITE_ENSURE_CESU8(thr, bw, cp);\n\t\t} else {\n#if defined(DUK_USE_NONSTD_STRING_FROMCHARCODE_32BIT)\n\t\t\t/* ToUint16() coercion is mandatory in the E5.1 specification, but\n\t\t\t * this non-compliant behavior makes more sense because we support\n\t\t\t * non-BMP codepoints.  Don't use CESU-8 because that'd create\n\t\t\t * surrogate pairs.\n\t\t\t */\n\t\t\tcp = (duk_ucodepoint_t) duk_to_uint32(ctx, i);\n\t\t\tDUK_BW_WRITE_ENSURE_XUTF8(thr, bw, cp);\n#else\n\t\t\tcp = (duk_ucodepoint_t) duk_to_uint16(ctx, i);\n\t\t\tDUK_ASSERT(cp >= 0 && cp <= 0x10ffffL);\n\t\t\tDUK_BW_WRITE_ENSURE_CESU8(thr, bw, cp);\n#endif\n\t\t}\n\t}\n\n\tDUK_BW_COMPACT(thr, bw);\n\t(void) duk_buffer_to_string(ctx, -1);  /* Safe, extended UTF-8 or CESU-8 encoded. */\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_string_constructor_from_char_code(duk_context *ctx) {\n\treturn duk__construct_from_codepoints(ctx, 0 /*nonbmp*/);\n}\n\n#if defined(DUK_USE_ES6)\nDUK_INTERNAL duk_ret_t duk_bi_string_constructor_from_code_point(duk_context *ctx) {\n\treturn duk__construct_from_codepoints(ctx, 1 /*nonbmp*/);\n}\n#endif\n\n/*\n *  toString(), valueOf()\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_string_prototype_to_string(duk_context *ctx) {\n\tduk_tval *tv;\n\n\tduk_push_this(ctx);\n\ttv = duk_require_tval(ctx, -1);\n\tDUK_ASSERT(tv != NULL);\n\n\tif (DUK_TVAL_IS_STRING(tv)) {\n\t\t/* return as is */\n\t} else if (DUK_TVAL_IS_OBJECT(tv)) {\n\t\tduk_hobject *h = DUK_TVAL_GET_OBJECT(tv);\n\t\tDUK_ASSERT(h != NULL);\n\n\t\t/* Must be a \"string object\", i.e. class \"String\" */\n\t\tif (DUK_HOBJECT_GET_CLASS_NUMBER(h) != DUK_HOBJECT_CLASS_STRING) {\n\t\t\tgoto type_error;\n\t\t}\n\n\t\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_INT_VALUE);\n\t\tDUK_ASSERT(duk_is_string(ctx, -1));\n\t} else {\n\t\tgoto type_error;\n\t}\n\n\t(void) duk_require_hstring_notsymbol(ctx, -1);  /* Reject symbols (and wrapped symbols). */\n\treturn 1;\n\n type_error:\n\tDUK_DCERROR_TYPE_INVALID_ARGS((duk_hthread *) ctx);\n}\n\n/*\n *  Character and charcode access\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_string_prototype_char_at(duk_context *ctx) {\n\tduk_int_t pos;\n\n\t/* XXX: faster implementation */\n\n\t(void) duk_push_this_coercible_to_string(ctx);\n\tpos = duk_to_int(ctx, 0);\n\tduk_substring(ctx, -1, pos, pos + 1);\n\treturn 1;\n}\n\n/* Magic: 0=charCodeAt, 1=codePointAt */\nDUK_INTERNAL duk_ret_t duk_bi_string_prototype_char_code_at(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_int_t pos;\n\tduk_hstring *h;\n\tduk_bool_t clamped;\n\tduk_uint32_t cp;\n\tduk_int_t magic;\n\n\t/* XXX: faster implementation */\n\n\tDUK_DDD(DUK_DDDPRINT(\"arg=%!T\", (duk_tval *) duk_get_tval(ctx, 0)));\n\n\th = duk_push_this_coercible_to_string(ctx);\n\tDUK_ASSERT(h != NULL);\n\n\tpos = duk_to_int_clamped_raw(ctx,\n\t                             0 /*index*/,\n\t                             0 /*min(incl)*/,\n\t                             (duk_int_t) DUK_HSTRING_GET_CHARLEN(h) - 1 /*max(incl)*/,\n\t                             &clamped /*out_clamped*/);\n#if defined(DUK_USE_ES6)\n\tmagic = duk_get_current_magic(ctx);\n#else\n\tDUK_ASSERT(duk_get_current_magic(ctx) == 0);\n\tmagic = 0;\n#endif\n\tif (clamped) {\n\t\t/* For out-of-bounds indices .charCodeAt() returns NaN and\n\t\t * .codePointAt() returns undefined.\n\t\t */\n\t\tif (magic != 0) {\n\t\t\treturn 0;\n\t\t}\n\t\tduk_push_nan(ctx);\n\t} else {\n\t\tcp = (duk_uint32_t) duk_hstring_char_code_at_raw(thr, h, pos, (duk_bool_t) magic /*surrogate_aware*/);\n\t\tduk_push_u32(ctx, cp);\n\t}\n\treturn 1;\n}\n\n/*\n *  substring(), substr(), slice()\n */\n\n/* XXX: any chance of merging these three similar but still slightly\n * different algorithms so that footprint would be reduced?\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_string_prototype_substring(duk_context *ctx) {\n\tduk_hstring *h;\n\tduk_int_t start_pos, end_pos;\n\tduk_int_t len;\n\n\th = duk_push_this_coercible_to_string(ctx);\n\tDUK_ASSERT(h != NULL);\n\tlen = (duk_int_t) DUK_HSTRING_GET_CHARLEN(h);\n\n\t/* [ start end str ] */\n\n\tstart_pos = duk_to_int_clamped(ctx, 0, 0, len);\n\tif (duk_is_undefined(ctx, 1)) {\n\t\tend_pos = len;\n\t} else {\n\t\tend_pos = duk_to_int_clamped(ctx, 1, 0, len);\n\t}\n\tDUK_ASSERT(start_pos >= 0 && start_pos <= len);\n\tDUK_ASSERT(end_pos >= 0 && end_pos <= len);\n\n\tif (start_pos > end_pos) {\n\t\tduk_int_t tmp = start_pos;\n\t\tstart_pos = end_pos;\n\t\tend_pos = tmp;\n\t}\n\n\tDUK_ASSERT(end_pos >= start_pos);\n\n\tduk_substring(ctx, -1, (duk_size_t) start_pos, (duk_size_t) end_pos);\n\treturn 1;\n}\n\n#if defined(DUK_USE_SECTION_B)\nDUK_INTERNAL duk_ret_t duk_bi_string_prototype_substr(duk_context *ctx) {\n\tduk_hstring *h;\n\tduk_int_t start_pos, end_pos;\n\tduk_int_t len;\n\n\t/* Unlike non-obsolete String calls, substr() algorithm in E5.1\n\t * specification will happily coerce undefined and null to strings\n\t * (\"undefined\" and \"null\").\n\t */\n\tduk_push_this(ctx);\n\th = duk_to_hstring_m1(ctx);  /* Reject Symbols. */\n\tDUK_ASSERT(h != NULL);\n\tlen = (duk_int_t) DUK_HSTRING_GET_CHARLEN(h);\n\n\t/* [ start length str ] */\n\n\t/* The implementation for computing of start_pos and end_pos differs\n\t * from the standard algorithm, but is intended to result in the exactly\n\t * same behavior.  This is not always obvious.\n\t */\n\n\t/* combines steps 2 and 5; -len ensures max() not needed for step 5 */\n\tstart_pos = duk_to_int_clamped(ctx, 0, -len, len);\n\tif (start_pos < 0) {\n\t\tstart_pos = len + start_pos;\n\t}\n\tDUK_ASSERT(start_pos >= 0 && start_pos <= len);\n\n\t/* combines steps 3, 6; step 7 is not needed */\n\tif (duk_is_undefined(ctx, 1)) {\n\t\tend_pos = len;\n\t} else {\n\t\tDUK_ASSERT(start_pos <= len);\n\t\tend_pos = start_pos + duk_to_int_clamped(ctx, 1, 0, len - start_pos);\n\t}\n\tDUK_ASSERT(start_pos >= 0 && start_pos <= len);\n\tDUK_ASSERT(end_pos >= 0 && end_pos <= len);\n\tDUK_ASSERT(end_pos >= start_pos);\n\n\tduk_substring(ctx, -1, (duk_size_t) start_pos, (duk_size_t) end_pos);\n\treturn 1;\n}\n#endif  /* DUK_USE_SECTION_B */\n\nDUK_INTERNAL duk_ret_t duk_bi_string_prototype_slice(duk_context *ctx) {\n\tduk_hstring *h;\n\tduk_int_t start_pos, end_pos;\n\tduk_int_t len;\n\n\th = duk_push_this_coercible_to_string(ctx);\n\tDUK_ASSERT(h != NULL);\n\tlen = (duk_int_t) DUK_HSTRING_GET_CHARLEN(h);\n\n\t/* [ start end str ] */\n\n\tstart_pos = duk_to_int_clamped(ctx, 0, -len, len);\n\tif (start_pos < 0) {\n\t\tstart_pos = len + start_pos;\n\t}\n\tif (duk_is_undefined(ctx, 1)) {\n\t\tend_pos = len;\n\t} else {\n\t\tend_pos = duk_to_int_clamped(ctx, 1, -len, len);\n\t\tif (end_pos < 0) {\n\t\t\tend_pos = len + end_pos;\n\t\t}\n\t}\n\tDUK_ASSERT(start_pos >= 0 && start_pos <= len);\n\tDUK_ASSERT(end_pos >= 0 && end_pos <= len);\n\n\tif (end_pos < start_pos) {\n\t\tend_pos = start_pos;\n\t}\n\n\tDUK_ASSERT(end_pos >= start_pos);\n\n\tduk_substring(ctx, -1, (duk_size_t) start_pos, (duk_size_t) end_pos);\n\treturn 1;\n}\n\n/*\n *  Case conversion\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_string_prototype_caseconv_shared(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_small_int_t uppercase = duk_get_current_magic(ctx);\n\n\t(void) duk_push_this_coercible_to_string(ctx);\n\tduk_unicode_case_convert_string(thr, (duk_bool_t) uppercase);\n\treturn 1;\n}\n\n/*\n *  indexOf() and lastIndexOf()\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_string_prototype_indexof_shared(duk_context *ctx) {\n\tduk_hstring *h_this;\n\tduk_hstring *h_search;\n\tduk_int_t clen_this;\n\tduk_int_t cpos;\n\tduk_small_int_t is_lastindexof = duk_get_current_magic(ctx);  /* 0=indexOf, 1=lastIndexOf */\n\n\th_this = duk_push_this_coercible_to_string(ctx);\n\tDUK_ASSERT(h_this != NULL);\n\tclen_this = (duk_int_t) DUK_HSTRING_GET_CHARLEN(h_this);\n\n\th_search = duk_to_hstring(ctx, 0);\n\tDUK_ASSERT(h_search != NULL);\n\n\tduk_to_number(ctx, 1);\n\tif (duk_is_nan(ctx, 1) && is_lastindexof) {\n\t\t/* indexOf: NaN should cause pos to be zero.\n\t\t * lastIndexOf: NaN should cause pos to be +Infinity\n\t\t * (and later be clamped to len).\n\t\t */\n\t\tcpos = clen_this;\n\t} else {\n\t\tcpos = duk_to_int_clamped(ctx, 1, 0, clen_this);\n\t}\n\n\tcpos = duk__str_search_shared(ctx, h_this, h_search, cpos, is_lastindexof /*backwards*/);\n\tduk_push_int(ctx, cpos);\n\treturn 1;\n}\n\n/*\n *  replace()\n */\n\n/* XXX: the current implementation works but is quite clunky; it compiles\n * to almost 1,4kB of x86 code so it needs to be simplified (better approach,\n * shared helpers, etc).  Some ideas for refactoring:\n *\n * - a primitive to convert a string into a regexp matcher (reduces matching\n *   code at the cost of making matching much slower)\n * - use replace() as a basic helper for match() and split(), which are both\n *   much simpler\n * - API call to get_prop and to_boolean\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_string_prototype_replace(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hstring *h_input;\n\tduk_hstring *h_match;\n\tduk_hstring *h_search;\n\tduk_hobject *h_re;\n\tduk_bufwriter_ctx bw_alloc;\n\tduk_bufwriter_ctx *bw;\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\tduk_bool_t is_regexp;\n\tduk_bool_t is_global;\n#endif\n\tduk_bool_t is_repl_func;\n\tduk_uint32_t match_start_coff, match_start_boff;\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\tduk_int_t match_caps;\n#endif\n\tduk_uint32_t prev_match_end_boff;\n\tconst duk_uint8_t *r_start, *r_end, *r;   /* repl string scan */\n\tduk_size_t tmp_sz;\n\n\tDUK_ASSERT_TOP(ctx, 2);\n\th_input = duk_push_this_coercible_to_string(ctx);\n\tDUK_ASSERT(h_input != NULL);\n\n\tbw = &bw_alloc;\n\tDUK_BW_INIT_PUSHBUF(thr, bw, DUK_HSTRING_GET_BYTELEN(h_input));  /* input size is good output starting point */\n\n\tDUK_ASSERT_TOP(ctx, 4);\n\n\t/* stack[0] = search value\n\t * stack[1] = replace value\n\t * stack[2] = input string\n\t * stack[3] = result buffer\n\t */\n\n\th_re = duk_get_hobject_with_class(ctx, 0, DUK_HOBJECT_CLASS_REGEXP);\n\tif (h_re) {\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\t\tis_regexp = 1;\n\t\tis_global = duk_get_prop_stridx_boolean(ctx, 0, DUK_STRIDX_GLOBAL, NULL);\n\n\t\tif (is_global) {\n\t\t\t/* start match from beginning */\n\t\t\tduk_push_int(ctx, 0);\n\t\t\tduk_put_prop_stridx_short(ctx, 0, DUK_STRIDX_LAST_INDEX);\n\t\t}\n#else  /* DUK_USE_REGEXP_SUPPORT */\n\t\tDUK_DCERROR_UNSUPPORTED(thr);\n#endif  /* DUK_USE_REGEXP_SUPPORT */\n\t} else {\n\t\tduk_to_string(ctx, 0);  /* rejects symbols */\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\t\tis_regexp = 0;\n\t\tis_global = 0;\n#endif\n\t}\n\n\tif (duk_is_function(ctx, 1)) {\n\t\tis_repl_func = 1;\n\t\tr_start = NULL;\n\t\tr_end = NULL;\n\t} else {\n\t\tduk_hstring *h_repl;\n\n\t\tis_repl_func = 0;\n\t\th_repl = duk_to_hstring(ctx, 1);  /* reject symbols */\n\t\tDUK_ASSERT(h_repl != NULL);\n\t\tr_start = DUK_HSTRING_GET_DATA(h_repl);\n\t\tr_end = r_start + DUK_HSTRING_GET_BYTELEN(h_repl);\n\t}\n\n\tprev_match_end_boff = 0;\n\n\tfor (;;) {\n\t\t/*\n\t\t *  If matching with a regexp:\n\t\t *    - non-global RegExp: lastIndex not touched on a match, zeroed\n\t\t *      on a non-match\n\t\t *    - global RegExp: on match, lastIndex will be updated by regexp\n\t\t *      executor to point to next char after the matching part (so that\n\t\t *      characters in the matching part are not matched again)\n\t\t *\n\t\t *  If matching with a string:\n\t\t *    - always non-global match, find first occurrence\n\t\t *\n\t\t *  We need:\n\t\t *    - The character offset of start-of-match for the replacer function\n\t\t *    - The byte offsets for start-of-match and end-of-match to implement\n\t\t *      the replacement values $&, $`, and $', and to copy non-matching\n\t\t *      input string portions (including header and trailer) verbatim.\n\t\t *\n\t\t *  NOTE: the E5.1 specification is a bit vague how the RegExp should\n\t\t *  behave in the replacement process; e.g. is matching done first for\n\t\t *  all matches (in the global RegExp case) before any replacer calls\n\t\t *  are made?  See: test-bi-string-proto-replace.js for discussion.\n\t\t */\n\n\t\tDUK_ASSERT_TOP(ctx, 4);\n\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\t\tif (is_regexp) {\n\t\t\tduk_dup_0(ctx);\n\t\t\tduk_dup_2(ctx);\n\t\t\tduk_regexp_match(thr);  /* [ ... regexp input ] -> [ res_obj ] */\n\t\t\tif (!duk_is_object(ctx, -1)) {\n\t\t\t\tduk_pop(ctx);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_INDEX);\n\t\t\tDUK_ASSERT(duk_is_number(ctx, -1));\n\t\t\tmatch_start_coff = duk_get_int(ctx, -1);\n\t\t\tduk_pop(ctx);\n\n\t\t\tduk_get_prop_index(ctx, -1, 0);\n\t\t\tDUK_ASSERT(duk_is_string(ctx, -1));\n\t\t\th_match = duk_known_hstring(ctx, -1);\n\t\t\tduk_pop(ctx);  /* h_match is borrowed, remains reachable through match_obj */\n\n\t\t\tif (DUK_HSTRING_GET_BYTELEN(h_match) == 0) {\n\t\t\t\t/* This should be equivalent to match() algorithm step 8.f.iii.2:\n\t\t\t\t * detect an empty match and allow it, but don't allow it twice.\n\t\t\t\t */\n\t\t\t\tduk_uint32_t last_index;\n\n\t\t\t\tduk_get_prop_stridx_short(ctx, 0, DUK_STRIDX_LAST_INDEX);\n\t\t\t\tlast_index = (duk_uint32_t) duk_get_uint(ctx, -1);\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"empty match, bump lastIndex: %ld -> %ld\",\n\t\t\t\t                     (long) last_index, (long) (last_index + 1)));\n\t\t\t\tduk_pop(ctx);\n\t\t\t\tduk_push_int(ctx, last_index + 1);\n\t\t\t\tduk_put_prop_stridx_short(ctx, 0, DUK_STRIDX_LAST_INDEX);\n\t\t\t}\n\n\t\t\tDUK_ASSERT(duk_get_length(ctx, -1) <= DUK_INT_MAX);  /* string limits */\n\t\t\tmatch_caps = (duk_int_t) duk_get_length(ctx, -1);\n\t\t} else {\n#else  /* DUK_USE_REGEXP_SUPPORT */\n\t\t{  /* unconditionally */\n#endif  /* DUK_USE_REGEXP_SUPPORT */\n\t\t\tconst duk_uint8_t *p_start, *p_end, *p;   /* input string scan */\n\t\t\tconst duk_uint8_t *q_start;               /* match string */\n\t\t\tduk_size_t q_blen;\n\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\t\t\tDUK_ASSERT(!is_global);  /* single match always */\n#endif\n\n\t\t\tp_start = DUK_HSTRING_GET_DATA(h_input);\n\t\t\tp_end = p_start + DUK_HSTRING_GET_BYTELEN(h_input);\n\t\t\tp = p_start;\n\n\t\t\th_search = duk_known_hstring(ctx, 0);\n\t\t\tq_start = DUK_HSTRING_GET_DATA(h_search);\n\t\t\tq_blen = (duk_size_t) DUK_HSTRING_GET_BYTELEN(h_search);\n\n\t\t\tp_end -= q_blen;  /* ensure full memcmp() fits in while */\n\n\t\t\tmatch_start_coff = 0;\n\n\t\t\twhile (p <= p_end) {\n\t\t\t\tDUK_ASSERT(p + q_blen <= DUK_HSTRING_GET_DATA(h_input) + DUK_HSTRING_GET_BYTELEN(h_input));\n\t\t\t\tif (DUK_MEMCMP((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) {\n\t\t\t\t\tduk_dup_0(ctx);\n\t\t\t\t\th_match = duk_known_hstring(ctx, -1);\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\t\t\t\t\tmatch_caps = 0;\n#endif\n\t\t\t\t\tgoto found;\n\t\t\t\t}\n\n\t\t\t\t/* track utf-8 non-continuation bytes */\n\t\t\t\tif ((p[0] & 0xc0) != 0x80) {\n\t\t\t\t\tmatch_start_coff++;\n\t\t\t\t}\n\t\t\t\tp++;\n\t\t\t}\n\n\t\t\t/* not found */\n\t\t\tbreak;\n\t\t}\n\t found:\n\n\t\t/* stack[0] = search value\n\t\t * stack[1] = replace value\n\t\t * stack[2] = input string\n\t\t * stack[3] = result buffer\n\t\t * stack[4] = regexp match OR match string\n\t\t */\n\n\t\tmatch_start_boff = duk_heap_strcache_offset_char2byte(thr, h_input, match_start_coff);\n\n\t\ttmp_sz = (duk_size_t) (match_start_boff - prev_match_end_boff);\n\t\tDUK_BW_WRITE_ENSURE_BYTES(thr, bw, DUK_HSTRING_GET_DATA(h_input) + prev_match_end_boff, tmp_sz);\n\n\t\tprev_match_end_boff = match_start_boff + DUK_HSTRING_GET_BYTELEN(h_match);\n\n\t\tif (is_repl_func) {\n\t\t\tduk_idx_t idx_args;\n\t\t\tduk_hstring *h_repl;\n\n\t\t\t/* regexp res_obj is at index 4 */\n\n\t\t\tduk_dup_1(ctx);\n\t\t\tidx_args = duk_get_top(ctx);\n\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\t\t\tif (is_regexp) {\n\t\t\t\tduk_int_t idx;\n\t\t\t\tduk_require_stack(ctx, match_caps + 2);\n\t\t\t\tfor (idx = 0; idx < match_caps; idx++) {\n\t\t\t\t\t/* match followed by capture(s) */\n\t\t\t\t\tduk_get_prop_index(ctx, 4, idx);\n\t\t\t\t}\n\t\t\t} else {\n#else  /* DUK_USE_REGEXP_SUPPORT */\n\t\t\t{  /* unconditionally */\n#endif  /* DUK_USE_REGEXP_SUPPORT */\n\t\t\t\t/* match == search string, by definition */\n\t\t\t\tduk_dup_0(ctx);\n\t\t\t}\n\t\t\tduk_push_int(ctx, match_start_coff);\n\t\t\tduk_dup_2(ctx);\n\n\t\t\t/* [ ... replacer match [captures] match_char_offset input ] */\n\n\t\t\tduk_call(ctx, duk_get_top(ctx) - idx_args);\n\t\t\th_repl = duk_to_hstring_m1(ctx);  /* -> [ ... repl_value ] */\n\t\t\tDUK_ASSERT(h_repl != NULL);\n\n\t\t\tDUK_BW_WRITE_ENSURE_HSTRING(thr, bw, h_repl);\n\n\t\t\tduk_pop(ctx);  /* repl_value */\n\t\t} else {\n\t\t\tr = r_start;\n\n\t\t\twhile (r < r_end) {\n\t\t\t\tduk_int_t ch1;\n\t\t\t\tduk_int_t ch2;\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\t\t\t\tduk_int_t ch3;\n#endif\n\t\t\t\tduk_size_t left;\n\n\t\t\t\tch1 = *r++;\n\t\t\t\tif (ch1 != DUK_ASC_DOLLAR) {\n\t\t\t\t\tgoto repl_write;\n\t\t\t\t}\n\t\t\t\tleft = r_end - r;\n\n\t\t\t\tif (left <= 0) {\n\t\t\t\t\tgoto repl_write;\n\t\t\t\t}\n\n\t\t\t\tch2 = r[0];\n\t\t\t\tswitch (ch2) {\n\t\t\t\tcase DUK_ASC_DOLLAR: {\n\t\t\t\t\tch1 = (1 << 8) + DUK_ASC_DOLLAR;\n\t\t\t\t\tgoto repl_write;\n\t\t\t\t}\n\t\t\t\tcase DUK_ASC_AMP: {\n\t\t\t\t\tDUK_BW_WRITE_ENSURE_HSTRING(thr, bw, h_match);\n\t\t\t\t\tr++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase DUK_ASC_GRAVE: {\n\t\t\t\t\ttmp_sz = (duk_size_t) match_start_boff;\n\t\t\t\t\tDUK_BW_WRITE_ENSURE_BYTES(thr, bw, DUK_HSTRING_GET_DATA(h_input), tmp_sz);\n\t\t\t\t\tr++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tcase DUK_ASC_SINGLEQUOTE: {\n\t\t\t\t\tduk_uint32_t match_end_boff;\n\n\t\t\t\t\t/* Use match charlen instead of bytelen, just in case the input and\n\t\t\t\t\t * match codepoint encodings would have different lengths.\n\t\t\t\t\t */\n\t\t\t\t\t/* XXX: charlen computed here, and also in char2byte helper. */\n\t\t\t\t\tmatch_end_boff = duk_heap_strcache_offset_char2byte(thr,\n\t\t\t\t\t                                                    h_input,\n\t\t\t\t\t                                                    match_start_coff + (duk_uint_fast32_t) DUK_HSTRING_GET_CHARLEN(h_match));\n\n\t\t\t\t\ttmp_sz = (duk_size_t) (DUK_HSTRING_GET_BYTELEN(h_input) - match_end_boff);\n\t\t\t\t\tDUK_BW_WRITE_ENSURE_BYTES(thr, bw, DUK_HSTRING_GET_DATA(h_input) + match_end_boff, tmp_sz);\n\t\t\t\t\tr++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tdefault: {\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\t\t\t\t\tduk_int_t capnum, captmp, capadv;\n\t\t\t\t\t/* XXX: optional check, match_caps is zero if no regexp,\n\t\t\t\t\t * so dollar will be interpreted literally anyway.\n\t\t\t\t\t */\n\n\t\t\t\t\tif (!is_regexp) {\n\t\t\t\t\t\tgoto repl_write;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!(ch2 >= DUK_ASC_0 && ch2 <= DUK_ASC_9)) {\n\t\t\t\t\t\tgoto repl_write;\n\t\t\t\t\t}\n\t\t\t\t\tcapnum = ch2 - DUK_ASC_0;\n\t\t\t\t\tcapadv = 1;\n\n\t\t\t\t\tif (left >= 2) {\n\t\t\t\t\t\tch3 = r[1];\n\t\t\t\t\t\tif (ch3 >= DUK_ASC_0 && ch3 <= DUK_ASC_9) {\n\t\t\t\t\t\t\tcaptmp = capnum * 10 + (ch3 - DUK_ASC_0);\n\t\t\t\t\t\t\tif (captmp < match_caps) {\n\t\t\t\t\t\t\t\tcapnum = captmp;\n\t\t\t\t\t\t\t\tcapadv = 2;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (capnum > 0 && capnum < match_caps) {\n\t\t\t\t\t\tDUK_ASSERT(is_regexp != 0);  /* match_caps == 0 without regexps */\n\n\t\t\t\t\t\t/* regexp res_obj is at offset 4 */\n\t\t\t\t\t\tduk_get_prop_index(ctx, 4, (duk_uarridx_t) capnum);\n\t\t\t\t\t\tif (duk_is_string(ctx, -1)) {\n\t\t\t\t\t\t\tduk_hstring *h_tmp_str;\n\n\t\t\t\t\t\t\th_tmp_str = duk_known_hstring(ctx, -1);\n\n\t\t\t\t\t\t\tDUK_BW_WRITE_ENSURE_HSTRING(thr, bw, h_tmp_str);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t/* undefined -> skip (replaced with empty) */\n\t\t\t\t\t\t}\n\t\t\t\t\t\tduk_pop(ctx);\n\t\t\t\t\t\tr += capadv;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tgoto repl_write;\n\t\t\t\t\t}\n#else  /* DUK_USE_REGEXP_SUPPORT */\n\t\t\t\t\tgoto repl_write;  /* unconditionally */\n#endif  /* DUK_USE_REGEXP_SUPPORT */\n\t\t\t\t}  /* default case */\n\t\t\t\t}  /* switch (ch2) */\n\n\t\t\t repl_write:\n\t\t\t\t/* ch1 = (r_increment << 8) + byte */\n\n\t\t\t\tDUK_BW_WRITE_ENSURE_U8(thr, bw, (duk_uint8_t) (ch1 & 0xff));\n\t\t\t\tr += ch1 >> 8;\n\t\t\t}  /* while repl */\n\t\t}  /* if (is_repl_func) */\n\n\t\tduk_pop(ctx);  /* pop regexp res_obj or match string */\n\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\t\tif (!is_global) {\n#else\n\t\t{  /* unconditionally; is_global==0 */\n#endif\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t/* trailer */\n\ttmp_sz = (duk_size_t) (DUK_HSTRING_GET_BYTELEN(h_input) - prev_match_end_boff);\n\tDUK_BW_WRITE_ENSURE_BYTES(thr, bw, DUK_HSTRING_GET_DATA(h_input) + prev_match_end_boff, tmp_sz);\n\n\tDUK_ASSERT_TOP(ctx, 4);\n\tDUK_BW_COMPACT(thr, bw);\n\t(void) duk_buffer_to_string(ctx, -1);  /* Safe if inputs are safe. */\n\treturn 1;\n}\n\n/*\n *  split()\n */\n\n/* XXX: very messy now, but works; clean up, remove unused variables (nomimally\n * used so compiler doesn't complain).\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_string_prototype_split(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hstring *h_input;\n\tduk_hstring *h_sep;\n\tduk_uint32_t limit;\n\tduk_uint32_t arr_idx;\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\tduk_bool_t is_regexp;\n#endif\n\tduk_bool_t matched;  /* set to 1 if any match exists (needed for empty input special case) */\n\tduk_uint32_t prev_match_end_coff, prev_match_end_boff;\n\tduk_uint32_t match_start_boff, match_start_coff;\n\tduk_uint32_t match_end_boff, match_end_coff;\n\n\tDUK_UNREF(thr);\n\n\th_input = duk_push_this_coercible_to_string(ctx);\n\tDUK_ASSERT(h_input != NULL);\n\n\tduk_push_array(ctx);\n\n\tif (duk_is_undefined(ctx, 1)) {\n\t\tlimit = 0xffffffffUL;\n\t} else {\n\t\tlimit = duk_to_uint32(ctx, 1);\n\t}\n\n\tif (limit == 0) {\n\t\treturn 1;\n\t}\n\n\t/* If the separator is a RegExp, make a \"clone\" of it.  The specification\n\t * algorithm calls [[Match]] directly for specific indices; we emulate this\n\t * by tweaking lastIndex and using a \"force global\" variant of duk_regexp_match()\n\t * which will use global-style matching even when the RegExp itself is non-global.\n\t */\n\n\tif (duk_is_undefined(ctx, 0)) {\n\t\t/* The spec algorithm first does \"R = ToString(separator)\" before checking\n\t\t * whether separator is undefined.  Since this is side effect free, we can\n\t\t * skip the ToString() here.\n\t\t */\n\t\tduk_dup_2(ctx);\n\t\tduk_put_prop_index(ctx, 3, 0);\n\t\treturn 1;\n\t} else if (duk_get_hobject_with_class(ctx, 0, DUK_HOBJECT_CLASS_REGEXP) != NULL) {\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\t\tduk_push_hobject_bidx(ctx, DUK_BIDX_REGEXP_CONSTRUCTOR);\n\t\tduk_dup_0(ctx);\n\t\tduk_new(ctx, 1);  /* [ ... RegExp val ] -> [ ... res ] */\n\t\tduk_replace(ctx, 0);\n\t\t/* lastIndex is initialized to zero by new RegExp() */\n\t\tis_regexp = 1;\n#else\n\t\tDUK_DCERROR_UNSUPPORTED(thr);\n#endif\n\t} else {\n\t\tduk_to_string(ctx, 0);\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\t\tis_regexp = 0;\n#endif\n\t}\n\n\t/* stack[0] = separator (string or regexp)\n\t * stack[1] = limit\n\t * stack[2] = input string\n\t * stack[3] = result array\n\t */\n\n\tprev_match_end_boff = 0;\n\tprev_match_end_coff = 0;\n\tarr_idx = 0;\n\tmatched = 0;\n\n\tfor (;;) {\n\t\t/*\n\t\t *  The specification uses RegExp [[Match]] to attempt match at specific\n\t\t *  offsets.  We don't have such a primitive, so we use an actual RegExp\n\t\t *  and tweak lastIndex.  Since the RegExp may be non-global, we use a\n\t\t *  special variant which forces global-like behavior for matching.\n\t\t */\n\n\t\tDUK_ASSERT_TOP(ctx, 4);\n\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\t\tif (is_regexp) {\n\t\t\tduk_dup_0(ctx);\n\t\t\tduk_dup_2(ctx);\n\t\t\tduk_regexp_match_force_global(thr);  /* [ ... regexp input ] -> [ res_obj ] */\n\t\t\tif (!duk_is_object(ctx, -1)) {\n\t\t\t\tduk_pop(ctx);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tmatched = 1;\n\n\t\t\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_INDEX);\n\t\t\tDUK_ASSERT(duk_is_number(ctx, -1));\n\t\t\tmatch_start_coff = duk_get_int(ctx, -1);\n\t\t\tmatch_start_boff = duk_heap_strcache_offset_char2byte(thr, h_input, match_start_coff);\n\t\t\tduk_pop(ctx);\n\n\t\t\tif (match_start_coff == DUK_HSTRING_GET_CHARLEN(h_input)) {\n\t\t\t\t/* don't allow an empty match at the end of the string */\n\t\t\t\tduk_pop(ctx);\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tduk_get_prop_stridx_short(ctx, 0, DUK_STRIDX_LAST_INDEX);\n\t\t\tDUK_ASSERT(duk_is_number(ctx, -1));\n\t\t\tmatch_end_coff = duk_get_int(ctx, -1);\n\t\t\tmatch_end_boff = duk_heap_strcache_offset_char2byte(thr, h_input, match_end_coff);\n\t\t\tduk_pop(ctx);\n\n\t\t\t/* empty match -> bump and continue */\n\t\t\tif (prev_match_end_boff == match_end_boff) {\n\t\t\t\tduk_push_int(ctx, match_end_coff + 1);\n\t\t\t\tduk_put_prop_stridx_short(ctx, 0, DUK_STRIDX_LAST_INDEX);\n\t\t\t\tduk_pop(ctx);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else {\n#else  /* DUK_USE_REGEXP_SUPPORT */\n\t\t{  /* unconditionally */\n#endif  /* DUK_USE_REGEXP_SUPPORT */\n\t\t\tconst duk_uint8_t *p_start, *p_end, *p;   /* input string scan */\n\t\t\tconst duk_uint8_t *q_start;               /* match string */\n\t\t\tduk_size_t q_blen, q_clen;\n\n\t\t\tp_start = DUK_HSTRING_GET_DATA(h_input);\n\t\t\tp_end = p_start + DUK_HSTRING_GET_BYTELEN(h_input);\n\t\t\tp = p_start + prev_match_end_boff;\n\n\t\t\th_sep = duk_known_hstring(ctx, 0);  /* symbol already rejected above */\n\t\t\tq_start = DUK_HSTRING_GET_DATA(h_sep);\n\t\t\tq_blen = (duk_size_t) DUK_HSTRING_GET_BYTELEN(h_sep);\n\t\t\tq_clen = (duk_size_t) DUK_HSTRING_GET_CHARLEN(h_sep);\n\n\t\t\tp_end -= q_blen;  /* ensure full memcmp() fits in while */\n\n\t\t\tmatch_start_coff = prev_match_end_coff;\n\n\t\t\tif (q_blen == 0) {\n\t\t\t\t/* Handle empty separator case: it will always match, and always\n\t\t\t\t * triggers the check in step 13.c.iii initially.  Note that we\n\t\t\t\t * must skip to either end of string or start of first codepoint,\n\t\t\t\t * skipping over any continuation bytes!\n\t\t\t\t *\n\t\t\t\t * Don't allow an empty string to match at the end of the input.\n\t\t\t\t */\n\n\t\t\t\tmatched = 1;  /* empty separator can always match */\n\n\t\t\t\tmatch_start_coff++;\n\t\t\t\tp++;\n\t\t\t\twhile (p < p_end) {\n\t\t\t\t\tif ((p[0] & 0xc0) != 0x80) {\n\t\t\t\t\t\tgoto found;\n\t\t\t\t\t}\n\t\t\t\t\tp++;\n\t\t\t\t}\n\t\t\t\tgoto not_found;\n\t\t\t}\n\n\t\t\tDUK_ASSERT(q_blen > 0 && q_clen > 0);\n\t\t\twhile (p <= p_end) {\n\t\t\t\tDUK_ASSERT(p + q_blen <= DUK_HSTRING_GET_DATA(h_input) + DUK_HSTRING_GET_BYTELEN(h_input));\n\t\t\t\tDUK_ASSERT(q_blen > 0);  /* no issues with empty memcmp() */\n\t\t\t\tif (DUK_MEMCMP((const void *) p, (const void *) q_start, (size_t) q_blen) == 0) {\n\t\t\t\t\t/* never an empty match, so step 13.c.iii can't be triggered */\n\t\t\t\t\tgoto found;\n\t\t\t\t}\n\n\t\t\t\t/* track utf-8 non-continuation bytes */\n\t\t\t\tif ((p[0] & 0xc0) != 0x80) {\n\t\t\t\t\tmatch_start_coff++;\n\t\t\t\t}\n\t\t\t\tp++;\n\t\t\t}\n\n\t\t not_found:\n\t\t\t/* not found */\n\t\t\tbreak;\n\n\t\t found:\n\t\t\tmatched = 1;\n\t\t\tmatch_start_boff = (duk_uint32_t) (p - p_start);\n\t\t\tmatch_end_coff = (duk_uint32_t) (match_start_coff + q_clen);  /* constrained by string length */\n\t\t\tmatch_end_boff = (duk_uint32_t) (match_start_boff + q_blen);  /* ditto */\n\n\t\t\t/* empty match (may happen with empty separator) -> bump and continue */\n\t\t\tif (prev_match_end_boff == match_end_boff) {\n\t\t\t\tprev_match_end_boff++;\n\t\t\t\tprev_match_end_coff++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}  /* if (is_regexp) */\n\n\t\t/* stack[0] = separator (string or regexp)\n\t\t * stack[1] = limit\n\t\t * stack[2] = input string\n\t\t * stack[3] = result array\n\t\t * stack[4] = regexp res_obj (if is_regexp)\n\t\t */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"split; match_start b=%ld,c=%ld, match_end b=%ld,c=%ld, prev_end b=%ld,c=%ld\",\n\t\t                     (long) match_start_boff, (long) match_start_coff,\n\t\t                     (long) match_end_boff, (long) match_end_coff,\n\t\t                     (long) prev_match_end_boff, (long) prev_match_end_coff));\n\n\t\tduk_push_lstring(ctx,\n\t\t                 (const char *) (DUK_HSTRING_GET_DATA(h_input) + prev_match_end_boff),\n\t\t                 (duk_size_t) (match_start_boff - prev_match_end_boff));\n\t\tduk_put_prop_index(ctx, 3, arr_idx);\n\t\tarr_idx++;\n\t\tif (arr_idx >= limit) {\n\t\t\tgoto hit_limit;\n\t\t}\n\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\t\tif (is_regexp) {\n\t\t\tduk_size_t i, len;\n\n\t\t\tlen = duk_get_length(ctx, 4);\n\t\t\tfor (i = 1; i < len; i++) {\n\t\t\t\tDUK_ASSERT(i <= DUK_UARRIDX_MAX);  /* cannot have >4G captures */\n\t\t\t\tduk_get_prop_index(ctx, 4, (duk_uarridx_t) i);\n\t\t\t\tduk_put_prop_index(ctx, 3, arr_idx);\n\t\t\t\tarr_idx++;\n\t\t\t\tif (arr_idx >= limit) {\n\t\t\t\t\tgoto hit_limit;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tduk_pop(ctx);\n\t\t\t/* lastIndex already set up for next match */\n\t\t} else {\n#else  /* DUK_USE_REGEXP_SUPPORT */\n\t\t{  /* unconditionally */\n#endif  /* DUK_USE_REGEXP_SUPPORT */\n\t\t\t/* no action */\n\t\t}\n\n\t\tprev_match_end_boff = match_end_boff;\n\t\tprev_match_end_coff = match_end_coff;\n\t\tcontinue;\n\t}  /* for */\n\n\t/* Combined step 11 (empty string special case) and 14-15. */\n\n\tDUK_DDD(DUK_DDDPRINT(\"split trailer; prev_end b=%ld,c=%ld\",\n\t                     (long) prev_match_end_boff, (long) prev_match_end_coff));\n\n\tif (DUK_HSTRING_GET_BYTELEN(h_input) > 0 || !matched) {\n\t\t/* Add trailer if:\n\t\t *   a) non-empty input\n\t\t *   b) empty input and no (zero size) match found (step 11)\n\t\t */\n\n\t\tduk_push_lstring(ctx,\n\t\t                 (const char *) DUK_HSTRING_GET_DATA(h_input) + prev_match_end_boff,\n\t\t                 (duk_size_t) (DUK_HSTRING_GET_BYTELEN(h_input) - prev_match_end_boff));\n\t\tduk_put_prop_index(ctx, 3, arr_idx);\n\t\t/* No arr_idx update or limit check */\n\t}\n\n\treturn 1;\n\n hit_limit:\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\tif (is_regexp) {\n\t\tduk_pop(ctx);\n\t}\n#endif\n\n\treturn 1;\n}\n\n/*\n *  Various\n */\n\n#if defined(DUK_USE_REGEXP_SUPPORT)\nDUK_LOCAL void duk__to_regexp_helper(duk_context *ctx, duk_idx_t idx, duk_bool_t force_new) {\n\tduk_hobject *h;\n\n\t/* Shared helper for match() steps 3-4, search() steps 3-4. */\n\n\tDUK_ASSERT(idx >= 0);\n\n\tif (force_new) {\n\t\tgoto do_new;\n\t}\n\n\th = duk_get_hobject_with_class(ctx, idx, DUK_HOBJECT_CLASS_REGEXP);\n\tif (!h) {\n\t\tgoto do_new;\n\t}\n\treturn;\n\n do_new:\n\tduk_push_hobject_bidx(ctx, DUK_BIDX_REGEXP_CONSTRUCTOR);\n\tduk_dup(ctx, idx);\n\tduk_new(ctx, 1);  /* [ ... RegExp val ] -> [ ... res ] */\n\tduk_replace(ctx, idx);\n}\n#endif  /* DUK_USE_REGEXP_SUPPORT */\n\n#if defined(DUK_USE_REGEXP_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_string_prototype_search(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\n\t/* Easiest way to implement the search required by the specification\n\t * is to do a RegExp test() with lastIndex forced to zero.  To avoid\n\t * side effects on the argument, \"clone\" the RegExp if a RegExp was\n\t * given as input.\n\t *\n\t * The global flag of the RegExp should be ignored; setting lastIndex\n\t * to zero (which happens when \"cloning\" the RegExp) should have an\n\t * equivalent effect.\n\t */\n\n\tDUK_ASSERT_TOP(ctx, 1);\n\t(void) duk_push_this_coercible_to_string(ctx);  /* at index 1 */\n\tduk__to_regexp_helper(ctx, 0 /*index*/, 1 /*force_new*/);\n\n\t/* stack[0] = regexp\n\t * stack[1] = string\n\t */\n\n\t/* Avoid using RegExp.prototype methods, as they're writable and\n\t * configurable and may have been changed.\n\t */\n\n\tduk_dup_0(ctx);\n\tduk_dup_1(ctx);  /* [ ... re_obj input ] */\n\tduk_regexp_match(thr);  /* -> [ ... res_obj ] */\n\n\tif (!duk_is_object(ctx, -1)) {\n\t\tduk_push_int(ctx, -1);\n\t\treturn 1;\n\t}\n\n\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_INDEX);\n\tDUK_ASSERT(duk_is_number(ctx, -1));\n\treturn 1;\n}\n#endif  /* DUK_USE_REGEXP_SUPPORT */\n\n#if defined(DUK_USE_REGEXP_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_string_prototype_match(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_bool_t global;\n\tduk_int_t prev_last_index;\n\tduk_int_t this_index;\n\tduk_int_t arr_idx;\n\n\tDUK_ASSERT_TOP(ctx, 1);\n\t(void) duk_push_this_coercible_to_string(ctx);\n\tduk__to_regexp_helper(ctx, 0 /*index*/, 0 /*force_new*/);\n\tglobal = duk_get_prop_stridx_boolean(ctx, 0, DUK_STRIDX_GLOBAL, NULL);\n\tDUK_ASSERT_TOP(ctx, 2);\n\n\t/* stack[0] = regexp\n\t * stack[1] = string\n\t */\n\n\tif (!global) {\n\t\tduk_regexp_match(thr);  /* -> [ res_obj ] */\n\t\treturn 1;  /* return 'res_obj' */\n\t}\n\n\t/* Global case is more complex. */\n\n\t/* [ regexp string ] */\n\n\tduk_push_int(ctx, 0);\n\tduk_put_prop_stridx_short(ctx, 0, DUK_STRIDX_LAST_INDEX);\n\tduk_push_array(ctx);\n\n\t/* [ regexp string res_arr ] */\n\n\tprev_last_index = 0;\n\tarr_idx = 0;\n\n\tfor (;;) {\n\t\tDUK_ASSERT_TOP(ctx, 3);\n\n\t\tduk_dup_0(ctx);\n\t\tduk_dup_1(ctx);\n\t\tduk_regexp_match(thr);  /* -> [ ... regexp string ] -> [ ... res_obj ] */\n\n\t\tif (!duk_is_object(ctx, -1)) {\n\t\t\tduk_pop(ctx);\n\t\t\tbreak;\n\t\t}\n\n\t\tduk_get_prop_stridx_short(ctx, 0, DUK_STRIDX_LAST_INDEX);\n\t\tDUK_ASSERT(duk_is_number(ctx, -1));\n\t\tthis_index = duk_get_int(ctx, -1);\n\t\tduk_pop(ctx);\n\n\t\tif (this_index == prev_last_index) {\n\t\t\tthis_index++;\n\t\t\tduk_push_int(ctx, this_index);\n\t\t\tduk_put_prop_stridx_short(ctx, 0, DUK_STRIDX_LAST_INDEX);\n\t\t}\n\t\tprev_last_index = this_index;\n\n\t\tduk_get_prop_index(ctx, -1, 0);  /* match string */\n\t\tduk_put_prop_index(ctx, 2, arr_idx);\n\t\tarr_idx++;\n\t\tduk_pop(ctx);  /* res_obj */\n\t}\n\n\tif (arr_idx == 0) {\n\t\tduk_push_null(ctx);\n\t}\n\n\treturn 1;  /* return 'res_arr' or 'null' */\n}\n#endif  /* DUK_USE_REGEXP_SUPPORT */\n\nDUK_INTERNAL duk_ret_t duk_bi_string_prototype_concat(duk_context *ctx) {\n\t/* duk_concat() coerces arguments with ToString() in correct order */\n\t(void) duk_push_this_coercible_to_string(ctx);\n\tduk_insert(ctx, 0);  /* this is relatively expensive */\n\tduk_concat(ctx, duk_get_top(ctx));\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_string_prototype_trim(duk_context *ctx) {\n\tDUK_ASSERT_TOP(ctx, 0);\n\t(void) duk_push_this_coercible_to_string(ctx);\n\tduk_trim(ctx, 0);\n\tDUK_ASSERT_TOP(ctx, 1);\n\treturn 1;\n}\n\n#if defined(DUK_USE_ES6)\nDUK_INTERNAL duk_ret_t duk_bi_string_prototype_repeat(duk_context *ctx) {\n\tduk_hstring *h_input;\n\tduk_size_t input_blen;\n\tduk_size_t result_len;\n\tduk_int_t count_signed;\n\tduk_uint_t count;\n\tconst duk_uint8_t *src;\n\tduk_uint8_t *buf;\n\tduk_uint8_t *p;\n\tduk_double_t d;\n#if !defined(DUK_USE_PREFER_SIZE)\n\tduk_size_t copy_size;\n\tduk_uint8_t *p_end;\n#endif\n\n\tDUK_ASSERT_TOP(ctx, 1);\n\th_input = duk_push_this_coercible_to_string(ctx);\n\tDUK_ASSERT(h_input != NULL);\n\tinput_blen = DUK_HSTRING_GET_BYTELEN(h_input);\n\n\t/* Count is ToNumber() coerced; +Infinity must be always rejected\n\t * (even if input string is zero length), as well as negative values\n\t * and -Infinity.  -Infinity doesn't require an explicit check\n\t * because duk_get_int() clamps it to DUK_INT_MIN which gets rejected\n\t * as a negative value (regardless of input string length).\n\t */\n\td = duk_to_number(ctx, 0);\n\tif (duk_double_is_posinf(d)) {\n\t\tgoto fail_range;\n\t}\n\tcount_signed = duk_get_int(ctx, 0);\n\tif (count_signed < 0) {\n\t\tgoto fail_range;\n\t}\n\tcount = (duk_uint_t) count_signed;\n\n\t/* Overflow check for result length. */\n\tresult_len = count * input_blen;\n\tif (count != 0 && result_len / count != input_blen) {\n\t\tgoto fail_range;\n\t}\n\n\t/* Temporary fixed buffer, later converted to string. */\n\tbuf = (duk_uint8_t *) duk_push_fixed_buffer_nozero(ctx, result_len);\n\tsrc = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_input);\n\n#if defined(DUK_USE_PREFER_SIZE)\n\tp = buf;\n\twhile (count-- > 0) {\n\t\tDUK_MEMCPY((void *) p, (const void *) src, input_blen);  /* copy size may be zero */\n\t\tp += input_blen;\n\t}\n#else  /* DUK_USE_PREFER_SIZE */\n\t/* Take advantage of already copied pieces to speed up the process\n\t * especially for small repeated strings.\n\t */\n\tp = buf;\n\tp_end = p + result_len;\n\tcopy_size = input_blen;\n\tfor (;;) {\n\t\tduk_size_t remain = (duk_size_t) (p_end - p);\n\t\tDUK_DDD(DUK_DDDPRINT(\"remain=%ld, copy_size=%ld, input_blen=%ld, result_len=%ld\",\n\t\t                     (long) remain, (long) copy_size, (long) input_blen,\n\t\t                     (long) result_len));\n\t\tif (remain <= copy_size) {\n\t\t\t/* If result_len is zero, this case is taken and does\n\t\t\t * a zero size copy.\n\t\t\t */\n\t\t\tDUK_MEMCPY((void *) p, (const void *) src, remain);\n\t\t\tbreak;\n\t\t} else {\n\t\t\tDUK_MEMCPY((void *) p, (const void *) src, copy_size);\n\t\t\tp += copy_size;\n\t\t}\n\n\t\tsrc = (const duk_uint8_t *) buf;  /* Use buf as source for larger copies. */\n\t\tcopy_size = (duk_size_t) (p - buf);\n\t}\n#endif  /* DUK_USE_PREFER_SIZE */\n\n\t/* XXX: It would be useful to be able to create a duk_hstring with\n\t * a certain byte size whose data area wasn't initialized and which\n\t * wasn't in the string table yet.  This would allow a string to be\n\t * constructed directly without a buffer temporary and when it was\n\t * finished, it could be injected into the string table.  Currently\n\t * this isn't possible because duk_hstrings are only tracked by the\n\t * intern table (they are not in heap_allocated).\n\t */\n\n\tduk_buffer_to_string(ctx, -1);  /* Safe if input is safe. */\n\treturn 1;\n\n fail_range:\n\tDUK_DCERROR_RANGE_INVALID_ARGS((duk_hthread *) ctx);\n}\n#endif  /* DUK_USE_ES6 */\n\nDUK_INTERNAL duk_ret_t duk_bi_string_prototype_locale_compare(duk_context *ctx) {\n\tduk_hstring *h1;\n\tduk_hstring *h2;\n\tduk_size_t h1_len, h2_len, prefix_len;\n\tduk_small_int_t ret = 0;\n\tduk_small_int_t rc;\n\n\t/* The current implementation of localeCompare() is simply a codepoint\n\t * by codepoint comparison, implemented with a simple string compare\n\t * because UTF-8 should preserve codepoint ordering (assuming valid\n\t * shortest UTF-8 encoding).\n\t *\n\t * The specification requires that the return value must be related\n\t * to the sort order: e.g. negative means that 'this' comes before\n\t * 'that' in sort order.  We assume an ascending sort order.\n\t */\n\n\t/* XXX: could share code with duk_js_ops.c, duk_js_compare_helper */\n\n\th1 = duk_push_this_coercible_to_string(ctx);\n\tDUK_ASSERT(h1 != NULL);\n\n\th2 = duk_to_hstring(ctx, 0);\n\tDUK_ASSERT(h2 != NULL);\n\n\th1_len = (duk_size_t) DUK_HSTRING_GET_BYTELEN(h1);\n\th2_len = (duk_size_t) DUK_HSTRING_GET_BYTELEN(h2);\n\tprefix_len = (h1_len <= h2_len ? h1_len : h2_len);\n\n\t/* Zero size compare not an issue with DUK_MEMCMP. */\n\trc = (duk_small_int_t) DUK_MEMCMP((const void *) DUK_HSTRING_GET_DATA(h1),\n\t                                  (const void *) DUK_HSTRING_GET_DATA(h2),\n\t                                  (size_t) prefix_len);\n\n\tif (rc < 0) {\n\t\tret = -1;\n\t\tgoto done;\n\t} else if (rc > 0) {\n\t\tret = 1;\n\t\tgoto done;\n\t}\n\n\t/* prefix matches, lengths matter now */\n\tif (h1_len > h2_len) {\n\t\tret = 1;\n\t\tgoto done;\n\t} else if (h1_len == h2_len) {\n\t\tDUK_ASSERT(ret == 0);\n\t\tgoto done;\n\t}\n\tret = -1;\n\tgoto done;\n\n done:\n\tduk_push_int(ctx, (duk_int_t) ret);\n\treturn 1;\n}\n\n#if defined(DUK_USE_ES6)\nDUK_INTERNAL duk_ret_t duk_bi_string_prototype_startswith_endswith(duk_context *ctx) {\n\tduk_int_t magic;\n\tduk_hstring *h;\n\tduk_hstring *h_search;\n\tduk_size_t blen_search;\n\tconst duk_uint8_t *p_cmp_start;\n\tduk_bool_t result;\n\n\th = duk_push_this_coercible_to_string(ctx);\n\tDUK_ASSERT(h != NULL);\n\n\th_search = duk__str_tostring_notregexp(ctx, 0);\n\tDUK_ASSERT(h_search != NULL);\n\n\tmagic = duk_get_current_magic(ctx);\n\n\tp_cmp_start = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h);\n\tblen_search = DUK_HSTRING_GET_BYTELEN(h_search);\n\n\tif (duk_is_undefined(ctx, 1)) {\n\t\tif (magic) {\n\t\t\tp_cmp_start += DUK_HSTRING_GET_BYTELEN(h) - blen_search;\n\t\t} else {\n\t\t\t/* p_cmp_start already OK */\n\t\t}\n\t} else {\n\t\tduk_int_t len;\n\t\tduk_int_t pos;\n\n\t\tDUK_ASSERT(DUK_HSTRING_MAX_BYTELEN <= DUK_INT_MAX);\n\t\tlen = (duk_int_t) DUK_HSTRING_GET_CHARLEN(h);\n\t\tpos = duk_to_int_clamped(ctx, 1, 0, len);\n\t\tDUK_ASSERT(pos >= 0 && pos <= len);\n\n\t\tif (magic) {\n\t\t\tp_cmp_start -= blen_search;  /* Conceptually subtracted last, but do already here. */\n\t\t}\n\t\tDUK_ASSERT(pos >= 0 && pos <= len);\n\n\t\tp_cmp_start += duk_heap_strcache_offset_char2byte((duk_hthread *) ctx, h, pos);\n\t}\n\n\t/* The main comparison can be done using a memcmp() rather than\n\t * doing codepoint comparisons: for CESU-8 strings there is a\n\t * canonical representation for every codepoint.  But we do need\n\t * to deal with the char/byte offset translation to find the\n\t * comparison range.\n\t */\n\n\tresult = 0;\n\tif (p_cmp_start >= DUK_HSTRING_GET_DATA(h) &&\n\t    p_cmp_start - (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h) + blen_search <= DUK_HSTRING_GET_BYTELEN(h)) {\n\t\tif (DUK_MEMCMP((const void *) p_cmp_start,\n\t\t               (const void *) DUK_HSTRING_GET_DATA(h_search),\n\t\t               (size_t) blen_search) == 0) {\n\t\t\tresult = 1;\n\t\t}\n\t}\n\n\tduk_push_boolean(ctx, result);\n\treturn 1;\n}\n#endif  /* DUK_USE_ES6 */\n\n#if defined(DUK_USE_ES6)\nDUK_INTERNAL duk_ret_t duk_bi_string_prototype_includes(duk_context *ctx) {\n\tduk_hstring *h;\n\tduk_hstring *h_search;\n\tduk_int_t len;\n\tduk_int_t pos;\n\n\th = duk_push_this_coercible_to_string(ctx);\n\tDUK_ASSERT(h != NULL);\n\n\th_search = duk__str_tostring_notregexp(ctx, 0);\n\tDUK_ASSERT(h_search != NULL);\n\n\tlen = (duk_int_t) DUK_HSTRING_GET_CHARLEN(h);\n\tpos = duk_to_int_clamped(ctx, 1, 0, len);\n\tDUK_ASSERT(pos >= 0 && pos <= len);\n\n\tpos = duk__str_search_shared(ctx, h, h_search, pos, 0 /*backwards*/);\n\tduk_push_boolean(ctx, pos >= 0);\n\treturn 1;\n}\n#endif  /* DUK_USE_ES6 */\n#endif  /* DUK_USE_STRING_BUILTIN */\n/*\n *  Symbol built-in\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_SYMBOL_BUILTIN)\n\n/*\n *  Constructor\n */\n\nDUK_INTERNAL duk_ret_t duk_bi_symbol_constructor_shared(duk_context *ctx) {\n\tduk_hthread *thr;\n\tconst duk_uint8_t *desc;\n\tduk_size_t len;\n\tduk_uint8_t *buf;\n\tduk_uint8_t *p;\n\tduk_int_t magic;\n\n\tthr = (duk_hthread *) ctx;\n\n\tmagic = duk_get_current_magic(ctx);\n\tif (duk_is_undefined(ctx, 0) && (magic == 0)) {\n\t\t/* Symbol() accepts undefined and empty string, but they are\n\t\t * treated differently.\n\t\t */\n\t\tdesc = NULL;\n\t\tlen = 0;\n\t} else {\n\t\t/* Symbol.for() coerces undefined to 'undefined' */\n\t\tdesc = (const duk_uint8_t *) duk_to_lstring(ctx, 0, &len);\n\t}\n\n\t/* Maximum symbol data length:\n\t *   +1    initial byte (0x80 or 0x81)\n\t *   +len  description\n\t *   +1    0xff after description, before unique suffix\n\t *   +17   autogenerated unique suffix: 'ffffffff-ffffffff' is longest\n\t *   +1    0xff after unique suffix for symbols with undefined description\n\t */\n\tbuf = (duk_uint8_t *) duk_push_fixed_buffer(ctx, 1 + len + 1 + 17 + 1);\n\tp = buf + 1;\n\tDUK_ASSERT(desc != NULL || len == 0);  /* may be NULL if len is 0 */\n\tDUK_MEMCPY((void *) p, (const void *) desc, len);\n\tp += len;\n\tif (magic == 0) {\n\t\t/* Symbol(): create unique symbol.  Use two 32-bit values\n\t\t * to avoid dependency on 64-bit types and 64-bit integer\n\t\t * formatting (at least for now).\n\t\t */\n\t\tif (++thr->heap->sym_counter[0] == 0) {\n\t\t\tthr->heap->sym_counter[1]++;\n\t\t}\n\t\tp += DUK_SPRINTF((char *) p, \"\\xFF\" \"%lx-%lx\",\n\t\t                 (unsigned long) thr->heap->sym_counter[1],\n\t\t                 (unsigned long) thr->heap->sym_counter[0]);\n\t\tif (desc == NULL) {\n\t\t\t/* Special case for 'undefined' description, trailing\n\t\t\t * 0xff distinguishes from empty string description,\n\t\t\t * but needs minimal special case handling elsewhere.\n\t\t\t */\n\t\t\t*p++ = 0xff;\n\t\t}\n\t\tbuf[0] = 0x81;\n\t} else {\n\t\t/* Symbol.for(): create a global symbol */\n\t\tbuf[0] = 0x80;\n\t}\n\n\tduk_push_lstring(ctx, (const char *) buf, (duk_size_t) (p - buf));\n\tDUK_DDD(DUK_DDDPRINT(\"created symbol: %!T\", duk_get_tval(ctx, -1)));\n\treturn 1;\n}\n\nDUK_LOCAL duk_hstring *duk__auto_unbox_symbol(duk_context *ctx, duk_tval *tv_arg) {\n\tduk_tval *tv;\n\tduk_tval tv_val;\n\tduk_hobject *h_obj;\n\tduk_hstring *h_str;\n\n\tDUK_ASSERT(tv_arg != NULL);\n\n\t/* XXX: add internal helper: duk_auto_unbox_tval(ctx, tv, mask); */\n\t/* XXX: add internal helper: duk_auto_unbox(ctx, tv, idx); */\n\n\ttv = tv_arg;\n\tif (DUK_TVAL_IS_OBJECT(tv)) {\n\t\th_obj = DUK_TVAL_GET_OBJECT(tv);\n\t\tDUK_ASSERT(h_obj != NULL);\n\t\tif (DUK_HOBJECT_GET_CLASS_NUMBER(h_obj) == DUK_HOBJECT_CLASS_SYMBOL) {\n\t\t\tif (!duk_hobject_get_internal_value(((duk_hthread *) ctx)->heap, h_obj, &tv_val)) {\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\ttv = &tv_val;\n\t\t} else {\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n\tif (!DUK_TVAL_IS_STRING(tv)) {\n\t\treturn NULL;\n\t}\n\th_str = DUK_TVAL_GET_STRING(tv);\n\tDUK_ASSERT(h_str != NULL);\n\n\t/* Here symbol is more expected than not. */\n\tif (DUK_UNLIKELY(!DUK_HSTRING_HAS_SYMBOL(h_str))) {\n\t\treturn NULL;\n\t}\n\n\treturn h_str;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_symbol_tostring_shared(duk_context *ctx) {\n\tduk_hstring *h_str;\n\n\th_str = duk__auto_unbox_symbol(ctx, DUK_HTHREAD_THIS_PTR((duk_hthread *) ctx));\n\tif (h_str == NULL) {\n\t\treturn DUK_RET_TYPE_ERROR;\n\t}\n\n\tif (duk_get_current_magic(ctx) == 0) {\n\t\t/* .toString() */\n\t\tduk_push_symbol_descriptive_string(ctx, h_str);\n\t} else {\n\t\t/* .valueOf() */\n\t\tduk_push_hstring(ctx, h_str);\n\t}\n\treturn 1;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_symbol_key_for(duk_context *ctx) {\n\tduk_hstring *h;\n\tconst duk_uint8_t *p;\n\n\t/* Argument must be a symbol but not checked here.  The initial byte\n\t * check will catch non-symbol strings.\n\t */\n\th = duk_require_hstring(ctx, 0);\n\tDUK_ASSERT(h != NULL);\n\n\tp = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h);\n\tDUK_ASSERT(p != NULL);\n\n\t/* Even for zero length strings there's at least one NUL byte so\n\t * we can safely check the initial byte.\n\t */\n\tif (p[0] == 0x80) {\n\t\t/* Global symbol, return its key (bytes just after the initial byte). */\n\t\tduk_push_lstring(ctx, (const char *) (p + 1), DUK_HSTRING_GET_BYTELEN(h) - 1);\n\t\treturn 1;\n\t} else if (p[0] == 0x81 || p[0] == 0xff) {\n\t\t/* Local symbol or hidden symbol, return undefined. */\n\t\treturn 0;\n\t}\n\n\t/* Covers normal strings and unknown initial bytes. */\n\treturn DUK_RET_TYPE_ERROR;\n}\n\nDUK_INTERNAL duk_ret_t duk_bi_symbol_toprimitive(duk_context *ctx) {\n\tduk_hstring *h_str;\n\n\th_str = duk__auto_unbox_symbol(ctx, DUK_HTHREAD_THIS_PTR((duk_hthread *) ctx));\n\tif (h_str == NULL) {\n\t\treturn DUK_RET_TYPE_ERROR;\n\t}\n\tduk_push_hstring(ctx, h_str);\n\treturn 1;\n}\n\n#endif  /* DUK_USE_SYMBOL_BUILTIN */\n/*\n *  Thread builtins\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Constructor\n */\n\n#if defined(DUK_USE_COROUTINE_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_thread_constructor(duk_context *ctx) {\n\tduk_hthread *new_thr;\n\tduk_hobject *func;\n\n\t/* Check that the argument is callable; this is not 100% because we\n\t * don't allow native functions to be a thread's initial function.\n\t * Resume will reject such functions in any case.\n\t */\n\t/* XXX: need a duk_require_func_promote_lfunc() */\n\tfunc = duk_require_hobject_promote_lfunc(ctx, 0);\n\tDUK_ASSERT(func != NULL);\n\tduk_require_callable(ctx, 0);\n\n\tduk_push_thread(ctx);\n\tnew_thr = (duk_hthread *) duk_known_hobject(ctx, -1);\n\tnew_thr->state = DUK_HTHREAD_STATE_INACTIVE;\n\n\t/* push initial function call to new thread stack; this is\n\t * picked up by resume().\n\t */\n\tduk_push_hobject((duk_context *) new_thr, func);\n\n\treturn 1;  /* return thread */\n}\n#endif\n\n/*\n *  Resume a thread.\n *\n *  The thread must be in resumable state, either (a) new thread which hasn't\n *  yet started, or (b) a thread which has previously yielded.  This method\n *  must be called from an Ecmascript function.\n *\n *  Args:\n *    - thread\n *    - value\n *    - isError (defaults to false)\n *\n *  Note: yield and resume handling is currently asymmetric.\n */\n\n#if defined(DUK_USE_COROUTINE_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_thread_resume(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hthread *thr_resume;\n\tduk_hobject *caller_func;\n\tduk_small_int_t is_error;\n\n\tDUK_DDD(DUK_DDDPRINT(\"Duktape.Thread.resume(): thread=%!T, value=%!T, is_error=%!T\",\n\t                     (duk_tval *) duk_get_tval(ctx, 0),\n\t                     (duk_tval *) duk_get_tval(ctx, 1),\n\t                     (duk_tval *) duk_get_tval(ctx, 2)));\n\n\tDUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING);\n\tDUK_ASSERT(thr->heap->curr_thread == thr);\n\n\tthr_resume = duk_require_hthread(ctx, 0);\n\tis_error = (duk_small_int_t) duk_to_boolean(ctx, 2);\n\tduk_set_top(ctx, 2);\n\n\t/* [ thread value ] */\n\n\t/*\n\t *  Thread state and calling context checks\n\t */\n\n\tif (thr->callstack_top < 2) {\n\t\tDUK_DD(DUK_DDPRINT(\"resume state invalid: callstack should contain at least 2 entries (caller and Duktape.Thread.resume)\"));\n\t\tgoto state_error;\n\t}\n\tDUK_ASSERT(thr->callstack_curr != NULL);\n\tDUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack_curr) != NULL);  /* us */\n\tDUK_ASSERT(DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr)));\n\tDUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack_curr - 1) != NULL);  /* caller */\n\n\tcaller_func = DUK_ACT_GET_FUNC(thr->callstack_curr - 1);\n\tif (!DUK_HOBJECT_IS_COMPFUNC(caller_func)) {\n\t\tDUK_DD(DUK_DDPRINT(\"resume state invalid: caller must be Ecmascript code\"));\n\t\tgoto state_error;\n\t}\n\n\t/* Note: there is no requirement that: 'thr->callstack_preventcount == 1'\n\t * like for yield.\n\t */\n\n\tif (thr_resume->state != DUK_HTHREAD_STATE_INACTIVE &&\n\t    thr_resume->state != DUK_HTHREAD_STATE_YIELDED) {\n\t\tDUK_DD(DUK_DDPRINT(\"resume state invalid: target thread must be INACTIVE or YIELDED\"));\n\t\tgoto state_error;\n\t}\n\n\tDUK_ASSERT(thr_resume->state == DUK_HTHREAD_STATE_INACTIVE ||\n\t           thr_resume->state == DUK_HTHREAD_STATE_YIELDED);\n\n\t/* Further state-dependent pre-checks */\n\n\tif (thr_resume->state == DUK_HTHREAD_STATE_YIELDED) {\n\t\t/* no pre-checks now, assume a previous yield() has left things in\n\t\t * tip-top shape (longjmp handler will assert for these).\n\t\t */\n\t} else {\n\t\tduk_hobject *h_fun;\n\n\t\tDUK_ASSERT(thr_resume->state == DUK_HTHREAD_STATE_INACTIVE);\n\n\t\t/* The initial function must be an Ecmascript function (but\n\t\t * can be bound).  We must make sure of that before we longjmp\n\t\t * because an error in the RESUME handler call processing will\n\t\t * not be handled very cleanly.\n\t\t */\n\t\tif ((thr_resume->callstack_top != 0) ||\n\t\t    (thr_resume->valstack_top - thr_resume->valstack != 1)) {\n\t\t\tgoto state_error;\n\t\t}\n\n\t\tduk_push_tval(ctx, DUK_GET_TVAL_NEGIDX((duk_context *) thr_resume, -1));\n\t\tduk_resolve_nonbound_function(ctx);\n\t\th_fun = duk_require_hobject(ctx, -1);  /* reject lightfuncs on purpose */\n\t\tif (!DUK_HOBJECT_IS_CALLABLE(h_fun) || !DUK_HOBJECT_IS_COMPFUNC(h_fun)) {\n\t\t\tgoto state_error;\n\t\t}\n\t\tduk_pop(ctx);\n\t}\n\n\t/*\n\t *  The error object has been augmented with a traceback and other\n\t *  info from its creation point -- usually another thread.  The\n\t *  error handler is called here right before throwing, but it also\n\t *  runs in the resumer's thread.  It might be nice to get a traceback\n\t *  from the resumee but this is not the case now.\n\t */\n\n#if defined(DUK_USE_AUGMENT_ERROR_THROW)\n\tif (is_error) {\n\t\tDUK_ASSERT_TOP(ctx, 2);  /* value (error) is at stack top */\n\t\tduk_err_augment_error_throw(thr);  /* in resumer's context */\n\t}\n#endif\n\n#if defined(DUK_USE_DEBUG)\n\tif (is_error) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"RESUME ERROR: thread=%!T, value=%!T\",\n\t\t                     (duk_tval *) duk_get_tval(ctx, 0),\n\t\t                     (duk_tval *) duk_get_tval(ctx, 1)));\n\t} else if (thr_resume->state == DUK_HTHREAD_STATE_YIELDED) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"RESUME NORMAL: thread=%!T, value=%!T\",\n\t\t                     (duk_tval *) duk_get_tval(ctx, 0),\n\t\t                     (duk_tval *) duk_get_tval(ctx, 1)));\n\t} else {\n\t\tDUK_DDD(DUK_DDDPRINT(\"RESUME INITIAL: thread=%!T, value=%!T\",\n\t\t                     (duk_tval *) duk_get_tval(ctx, 0),\n\t\t                     (duk_tval *) duk_get_tval(ctx, 1)));\n\t}\n#endif\n\n\tthr->heap->lj.type = DUK_LJ_TYPE_RESUME;\n\n\t/* lj value2: thread */\n\tDUK_ASSERT(thr->valstack_bottom < thr->valstack_top);\n\tDUK_TVAL_SET_TVAL_UPDREF(thr, &thr->heap->lj.value2, &thr->valstack_bottom[0]);  /* side effects */\n\n\t/* lj value1: value */\n\tDUK_ASSERT(thr->valstack_bottom + 1 < thr->valstack_top);\n\tDUK_TVAL_SET_TVAL_UPDREF(thr, &thr->heap->lj.value1, &thr->valstack_bottom[1]);  /* side effects */\n\tDUK_TVAL_CHKFAST_INPLACE_SLOW(&thr->heap->lj.value1);\n\n\tthr->heap->lj.iserror = is_error;\n\n\tDUK_ASSERT(thr->heap->lj.jmpbuf_ptr != NULL);  /* call is from executor, so we know we have a jmpbuf */\n\tduk_err_longjmp(thr);  /* execution resumes in bytecode executor */\n\tDUK_UNREACHABLE();\n\t/* Never here, fall through to error (from compiler point of view). */\n\n state_error:\n\tDUK_DCERROR_TYPE_INVALID_STATE(thr);\n}\n#endif\n\n/*\n *  Yield the current thread.\n *\n *  The thread must be in yieldable state: it must have a resumer, and there\n *  must not be any yield-preventing calls (native calls and constructor calls,\n *  currently) in the thread's call stack (otherwise a resume would not be\n *  possible later).  This method must be called from an Ecmascript function.\n *\n *  Args:\n *    - value\n *    - isError (defaults to false)\n *\n *  Note: yield and resume handling is currently asymmetric.\n */\n\n#if defined(DUK_USE_COROUTINE_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_thread_yield(duk_context *ctx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *caller_func;\n\tduk_small_int_t is_error;\n\n\tDUK_DDD(DUK_DDDPRINT(\"Duktape.Thread.yield(): value=%!T, is_error=%!T\",\n\t                     (duk_tval *) duk_get_tval(ctx, 0),\n\t                     (duk_tval *) duk_get_tval(ctx, 1)));\n\n\tDUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING);\n\tDUK_ASSERT(thr->heap->curr_thread == thr);\n\n\tis_error = (duk_small_int_t) duk_to_boolean(ctx, 1);\n\tduk_set_top(ctx, 1);\n\n\t/* [ value ] */\n\n\t/*\n\t *  Thread state and calling context checks\n\t */\n\n\tif (!thr->resumer) {\n\t\tDUK_DD(DUK_DDPRINT(\"yield state invalid: current thread must have a resumer\"));\n\t\tgoto state_error;\n\t}\n\tDUK_ASSERT(thr->resumer->state == DUK_HTHREAD_STATE_RESUMED);\n\n\tif (thr->callstack_top < 2) {\n\t\tDUK_DD(DUK_DDPRINT(\"yield state invalid: callstack should contain at least 2 entries (caller and Duktape.Thread.yield)\"));\n\t\tgoto state_error;\n\t}\n\tDUK_ASSERT(thr->callstack_curr != NULL);\n\tDUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack_curr) != NULL);  /* us */\n\tDUK_ASSERT(DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr)));\n\tDUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack_curr - 1) != NULL);  /* caller */\n\n\tcaller_func = DUK_ACT_GET_FUNC(thr->callstack_curr - 1);\n\tif (!DUK_HOBJECT_IS_COMPFUNC(caller_func)) {\n\t\tDUK_DD(DUK_DDPRINT(\"yield state invalid: caller must be Ecmascript code\"));\n\t\tgoto state_error;\n\t}\n\n\tDUK_ASSERT(thr->callstack_preventcount >= 1);  /* should never be zero, because we (Duktape.Thread.yield) are on the stack */\n\tif (thr->callstack_preventcount != 1) {\n\t\t/* Note: the only yield-preventing call is Duktape.Thread.yield(), hence check for 1, not 0 */\n\t\tDUK_DD(DUK_DDPRINT(\"yield state invalid: there must be no yield-preventing calls in current thread callstack (preventcount is %ld)\",\n\t\t                   (long) thr->callstack_preventcount));\n\t\tgoto state_error;\n\t}\n\n\t/*\n\t *  The error object has been augmented with a traceback and other\n\t *  info from its creation point -- usually the current thread.\n\t *  The error handler, however, is called right before throwing\n\t *  and runs in the yielder's thread.\n\t */\n\n#if defined(DUK_USE_AUGMENT_ERROR_THROW)\n\tif (is_error) {\n\t\tDUK_ASSERT_TOP(ctx, 1);  /* value (error) is at stack top */\n\t\tduk_err_augment_error_throw(thr);  /* in yielder's context */\n\t}\n#endif\n\n#if defined(DUK_USE_DEBUG)\n\tif (is_error) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"YIELD ERROR: value=%!T\",\n\t\t                     (duk_tval *) duk_get_tval(ctx, 0)));\n\t} else {\n\t\tDUK_DDD(DUK_DDDPRINT(\"YIELD NORMAL: value=%!T\",\n\t\t                     (duk_tval *) duk_get_tval(ctx, 0)));\n\t}\n#endif\n\n\t/*\n\t *  Process yield\n\t *\n\t *  After longjmp(), processing continues in bytecode executor longjmp\n\t *  handler, which will e.g. update thr->resumer to NULL.\n\t */\n\n\tthr->heap->lj.type = DUK_LJ_TYPE_YIELD;\n\n\t/* lj value1: value */\n\tDUK_ASSERT(thr->valstack_bottom < thr->valstack_top);\n\tDUK_TVAL_SET_TVAL_UPDREF(thr, &thr->heap->lj.value1, &thr->valstack_bottom[0]);  /* side effects */\n\tDUK_TVAL_CHKFAST_INPLACE_SLOW(&thr->heap->lj.value1);\n\n\tthr->heap->lj.iserror = is_error;\n\n\tDUK_ASSERT(thr->heap->lj.jmpbuf_ptr != NULL);  /* call is from executor, so we know we have a jmpbuf */\n\tduk_err_longjmp(thr);  /* execution resumes in bytecode executor */\n\tDUK_UNREACHABLE();\n\t/* Never here, fall through to error (from compiler point of view). */\n\n state_error:\n\tDUK_DCERROR_TYPE_INVALID_STATE(thr);\n}\n#endif\n\n#if defined(DUK_USE_COROUTINE_SUPPORT)\nDUK_INTERNAL duk_ret_t duk_bi_thread_current(duk_context *ctx) {\n\tduk_push_current_thread(ctx);\n\treturn 1;\n}\n#endif\n/*\n *  Type error thrower, E5 Section 13.2.3.\n */\n\n/* #include duk_internal.h -> already included */\n\nDUK_INTERNAL duk_ret_t duk_bi_type_error_thrower(duk_context *ctx) {\n\tDUK_DCERROR_TYPE_INVALID_ARGS((duk_hthread *) ctx);\n}\n/*\n *  Fixed buffer helper useful for debugging, requires no allocation\n *  which is critical for debugging.\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_DEBUG)\n\nDUK_INTERNAL void duk_fb_put_bytes(duk_fixedbuffer *fb, const duk_uint8_t *buffer, duk_size_t length) {\n\tduk_size_t avail;\n\tduk_size_t copylen;\n\n\tavail = (fb->offset >= fb->length ? (duk_size_t) 0 : (duk_size_t) (fb->length - fb->offset));\n\tif (length > avail) {\n\t\tcopylen = avail;\n\t\tfb->truncated = 1;\n\t} else {\n\t\tcopylen = length;\n\t}\n\tDUK_MEMCPY(fb->buffer + fb->offset, buffer, copylen);\n\tfb->offset += copylen;\n}\n\nDUK_INTERNAL void duk_fb_put_byte(duk_fixedbuffer *fb, duk_uint8_t x) {\n\tduk_fb_put_bytes(fb, (const duk_uint8_t *) &x, 1);\n}\n\nDUK_INTERNAL void duk_fb_put_cstring(duk_fixedbuffer *fb, const char *x) {\n\tduk_fb_put_bytes(fb, (const duk_uint8_t *) x, (duk_size_t) DUK_STRLEN(x));\n}\n\nDUK_INTERNAL void duk_fb_sprintf(duk_fixedbuffer *fb, const char *fmt, ...) {\n\tduk_size_t avail;\n\tva_list ap;\n\n\tva_start(ap, fmt);\n\tavail = (fb->offset >= fb->length ? (duk_size_t) 0 : (duk_size_t) (fb->length - fb->offset));\n\tif (avail > 0) {\n\t\tduk_int_t res = (duk_int_t) DUK_VSNPRINTF((char *) (fb->buffer + fb->offset), avail, fmt, ap);\n\t\tif (res < 0) {\n\t\t\t/* error */\n\t\t} else if ((duk_size_t) res >= avail) {\n\t\t\t/* (maybe) truncated */\n\t\t\tfb->offset += avail;\n\t\t\tif ((duk_size_t) res > avail) {\n\t\t\t\t/* actual chars dropped (not just NUL term) */\n\t\t\t\tfb->truncated = 1;\n\t\t\t}\n\t\t} else {\n\t\t\t/* normal */\n\t\t\tfb->offset += res;\n\t\t}\n\t}\n\tva_end(ap);\n}\n\nDUK_INTERNAL void duk_fb_put_funcptr(duk_fixedbuffer *fb, duk_uint8_t *fptr, duk_size_t fptr_size) {\n\tchar buf[64+1];\n\tduk_debug_format_funcptr(buf, sizeof(buf), fptr, fptr_size);\n\tbuf[sizeof(buf) - 1] = (char) 0;\n\tduk_fb_put_cstring(fb, buf);\n}\n\nDUK_INTERNAL duk_bool_t duk_fb_is_full(duk_fixedbuffer *fb) {\n\treturn (fb->offset >= fb->length);\n}\n\n#endif  /* DUK_USE_DEBUG */\n/*\n *  Custom formatter for debug printing, allowing Duktape specific data\n *  structures (such as tagged values and heap objects) to be printed with\n *  a nice format string.  Because debug printing should not affect execution\n *  state, formatting here must be independent of execution (see implications\n *  below) and must not allocate memory.\n *\n *  Custom format tags begin with a '%!' to safely distinguish them from\n *  standard format tags.  The following conversions are supported:\n *\n *     %!T    tagged value (duk_tval *)\n *     %!O    heap object (duk_heaphdr *)\n *     %!I    decoded bytecode instruction\n *     %!C    bytecode instruction opcode name (arg is long)\n *\n *  Everything is serialized in a JSON-like manner.  The default depth is one\n *  level, internal prototype is not followed, and internal properties are not\n *  serialized.  The following modifiers change this behavior:\n *\n *     @      print pointers\n *     #      print binary representations (where applicable)\n *     d      deep traversal of own properties (not prototype)\n *     p      follow prototype chain (useless without 'd')\n *     i      include internal properties (other than prototype)\n *     x      hexdump buffers\n *     h      heavy formatting\n *\n *  For instance, the following serializes objects recursively, but does not\n *  follow the prototype chain nor print internal properties: \"%!dO\".\n *\n *  Notes:\n *\n *    * Standard snprintf return value semantics seem to vary.  This\n *      implementation returns the number of bytes it actually wrote\n *      (excluding the null terminator).  If retval == buffer size,\n *      output was truncated (except for corner cases).\n *\n *    * Output format is intentionally different from Ecmascript\n *      formatting requirements, as formatting here serves debugging\n *      of internals.\n *\n *    * Depth checking (and updating) is done in each type printer\n *      separately, to allow them to call each other freely.\n *\n *    * Some pathological structures might take ages to print (e.g.\n *      self recursion with 100 properties pointing to the object\n *      itself).  To guard against these, each printer also checks\n *      whether the output buffer is full; if so, early exit.\n *\n *    * Reference loops are detected using a loop stack.\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_DEBUG)\n\n/* #include stdio.h -> already included */\n/* #include stdarg.h -> already included */\n#include <string.h>\n\n/* list of conversion specifiers that terminate a format tag;\n * this is unfortunately guesswork.\n */\n#define DUK__ALLOWED_STANDARD_SPECIFIERS  \"diouxXeEfFgGaAcsCSpnm\"\n\n/* maximum length of standard format tag that we support */\n#define DUK__MAX_FORMAT_TAG_LENGTH  32\n\n/* heapobj recursion depth when deep printing is selected */\n#define DUK__DEEP_DEPTH_LIMIT  8\n\n/* maximum recursion depth for loop detection stacks */\n#define DUK__LOOP_STACK_DEPTH  256\n\n/* must match bytecode defines now; build autogenerate? */\nDUK_LOCAL const char *duk__bc_optab[256] = {\n\t\"LDREG\", \"STREG\", \"LDCONST\", \"LDINT\", \"LDINTX\", \"LDTHIS\", \"LDUNDEF\", \"LDNULL\",\n\t\"LDTRUE\", \"LDFALSE\", \"BNOT\", \"LNOT\", \"UNM\", \"UNP\", \"TYPEOF\", \"TYPEOFID\",\n\t\"EQ_RR\", \"EQ_CR\", \"EQ_RC\", \"EQ_CC\", \"NEQ_RR\", \"NEQ_CR\", \"NEQ_RC\", \"NEQ_CC\",\n\t\"SEQ_RR\", \"SEQ_CR\", \"SEQ_RC\", \"SEQ_CC\", \"SNEQ_RR\", \"SNEQ_CR\", \"SNEQ_RC\", \"SNEQ_CC\",\n\n\t\"GT_RR\", \"GT_CR\", \"GT_RC\", \"GT_CC\", \"GE_RR\", \"GE_CR\", \"GE_RC\", \"GE_CC\",\n\t\"LT_RR\", \"LT_CR\", \"LT_RC\", \"LT_CC\", \"LE_RR\", \"LE_CR\", \"LE_RC\", \"LE_CC\",\n\t\"IFTRUE_R\", \"IFTRUE_C\", \"IFFALSE_R\", \"IFFALSE_C\", \"ADD_RR\", \"ADD_CR\", \"ADD_RC\", \"ADD_CC\",\n\t\"SUB_RR\", \"SUB_CR\", \"SUB_RC\", \"SUB_CC\", \"MUL_RR\", \"MUL_CR\", \"MUL_RC\", \"MUL_CC\",\n\n\t\"DIV_RR\", \"DIV_CR\", \"DIV_RC\", \"DIV_CC\", \"MOD_RR\", \"MOD_CR\", \"MOD_RC\", \"MOD_CC\",\n\t\"BAND_RR\", \"BAND_CR\", \"BAND_RC\", \"BAND_CC\", \"BOR_RR\", \"BOR_CR\", \"BOR_RC\", \"BOR_CC\",\n\t\"BXOR_RR\", \"BXOR_CR\", \"BXOR_RC\", \"BXOR_CC\", \"BASL_RR\", \"BASL_CR\", \"BASL_RC\", \"BASL_CC\",\n\t\"BLSR_RR\", \"BLSR_CR\", \"BLSR_RC\", \"BLSR_CC\", \"BASR_RR\", \"BASR_CR\", \"BASR_RC\", \"BASR_CC\",\n\n\t\"INSTOF_RR\", \"INSTOF_CR\", \"INSTOF_RC\", \"INSTOF_CC\", \"IN_RR\", \"IN_CR\", \"IN_RC\", \"IN_CC\",\n\t\"PREINCR\", \"PREDECR\", \"POSTINCR\", \"POSTDECR\", \"PREINCV\", \"PREDECV\", \"POSTINCV\", \"POSTDECV\",\n\t\"PREINCP_RR\", \"PREINCP_CR\", \"PREINCP_RC\", \"PREINCP_CC\", \"PREDECP_RR\", \"PREDECP_CR\", \"PREDECP_RC\", \"PREDECP_CC\",\n\t\"POSTINCP_RR\", \"POSTINCP_CR\", \"POSTINCP_RC\", \"POSTINCP_CC\", \"POSTDECP_RR\", \"POSTDECP_CR\", \"POSTDECP_RC\", \"POSTDECP_CC\",\n\n\t\"GETPROP_RR\", \"GETPROP_CR\", \"GETPROP_RC\", \"GETPROP_CC\", \"PUTPROP_RR\", \"PUTPROP_CR\", \"PUTPROP_RC\", \"PUTPROP_CC\",\n\t\"DELPROP_RR\", \"DELPROP_CR\", \"DELPROP_RC\", \"DELPROP_CC\", \"DECLVAR_RR\", \"DECLVAR_CR\", \"DECLVAR_RC\", \"DECLVAR_CC\",\n\t\"REGEXP_RR\", \"REGEXP_RC\", \"REGEXP_CR\", \"REGEXP_CC\", \"CSVAR_RR\", \"CSVAR_CR\", \"CSVAR_RC\", \"CSVAR_CC\",\n\t\"CLOSURE\", \"GETVAR\", \"PUTVAR\", \"DELVAR\", \"JUMP\", \"RETREG\", \"RETUNDEF\", \"RETCONST\",\n\n\t\"RETCONSTN\", \"LABEL\", \"ENDLABEL\", \"BREAK\", \"CONTINUE\", \"TRYCATCH\", \"ENDTRY\", \"ENDCATCH\",\n\t\"ENDFIN\", \"THROW\", \"CSREG\", \"EVALCALL\", \"CALL\", \"TAILCALL\", \"NEW\", \"NEWOBJ\",\n\t\"NEWARR\", \"MPUTOBJ\", \"MPUTOBJI\", \"INITSET\", \"INITGET\", \"MPUTARR\", \"MPUTARRI\", \"SETALEN\",\n\t\"INITENUM\", \"NEXTENUM\", \"INVLHS\", \"DEBUGGER\", \"NOP\", \"INVALID\", \"UNUSED190\", \"UNUSED191\",\n\n\t\"UNUSED192\", \"UNUSED193\", \"UNUSED194\", \"UNUSED195\", \"UNUSED196\", \"UNUSED197\", \"UNUSED198\", \"UNUSED199\",\n\t\"UNUSED200\", \"UNUSED201\", \"UNUSED202\", \"UNUSED203\", \"UNUSED204\", \"UNUSED205\", \"UNUSED206\", \"UNUSED207\",\n\t\"UNUSED208\", \"UNUSED209\", \"UNUSED210\", \"UNUSED211\", \"UNUSED212\", \"UNUSED213\", \"UNUSED214\", \"UNUSED215\",\n\t\"UNUSED216\", \"UNUSED217\", \"UNUSED218\", \"UNUSED219\", \"UNUSED220\", \"UNUSED221\", \"UNUSED222\", \"UNUSED223\",\n\n\t\"UNUSED224\", \"UNUSED225\", \"UNUSED226\", \"UNUSED227\", \"UNUSED228\", \"UNUSED229\", \"UNUSED230\", \"UNUSED231\",\n\t\"UNUSED232\", \"UNUSED233\", \"UNUSED234\", \"UNUSED235\", \"UNUSED236\", \"UNUSED237\", \"UNUSED238\", \"UNUSED239\",\n\t\"UNUSED240\", \"UNUSED241\", \"UNUSED242\", \"UNUSED243\", \"UNUSED244\", \"UNUSED245\", \"UNUSED246\", \"UNUSED247\",\n\t\"UNUSED248\", \"UNUSED249\", \"UNUSED250\", \"UNUSED251\", \"UNUSED252\", \"UNUSED253\", \"UNUSED254\", \"UNUSED255\"\n};\n\ntypedef struct duk__dprint_state duk__dprint_state;\nstruct duk__dprint_state {\n\tduk_fixedbuffer *fb;\n\n\t/* loop_stack_index could be perhaps be replaced by 'depth', but it's nice\n\t * to not couple these two mechanisms unnecessarily.\n\t */\n\tduk_hobject *loop_stack[DUK__LOOP_STACK_DEPTH];\n\tduk_int_t loop_stack_index;\n\tduk_int_t loop_stack_limit;\n\n\tduk_int_t depth;\n\tduk_int_t depth_limit;\n\n\tduk_bool_t pointer;\n\tduk_bool_t heavy;\n\tduk_bool_t binary;\n\tduk_bool_t follow_proto;\n\tduk_bool_t internal;\n\tduk_bool_t hexdump;\n};\n\n/* helpers */\nDUK_LOCAL_DECL void duk__print_hstring(duk__dprint_state *st, duk_hstring *k, duk_bool_t quotes);\nDUK_LOCAL_DECL void duk__print_hobject(duk__dprint_state *st, duk_hobject *h);\nDUK_LOCAL_DECL void duk__print_hbuffer(duk__dprint_state *st, duk_hbuffer *h);\nDUK_LOCAL_DECL void duk__print_tval(duk__dprint_state *st, duk_tval *tv);\nDUK_LOCAL_DECL void duk__print_instr(duk__dprint_state *st, duk_instr_t ins);\nDUK_LOCAL_DECL void duk__print_heaphdr(duk__dprint_state *st, duk_heaphdr *h);\nDUK_LOCAL_DECL void duk__print_shared_heaphdr(duk__dprint_state *st, duk_heaphdr *h);\nDUK_LOCAL_DECL void duk__print_shared_heaphdr_string(duk__dprint_state *st, duk_heaphdr_string *h);\n\nDUK_LOCAL void duk__print_shared_heaphdr(duk__dprint_state *st, duk_heaphdr *h) {\n\tduk_fixedbuffer *fb = st->fb;\n\n\tif (st->heavy) {\n\t\tduk_fb_sprintf(fb, \"(%p)\", (void *) h);\n\t}\n\n\tif (!h) {\n\t\treturn;\n\t}\n\n\tif (st->binary) {\n\t\tduk_size_t i;\n\t\tduk_fb_put_byte(fb, (duk_uint8_t) DUK_ASC_LBRACKET);\n\t\tfor (i = 0; i < (duk_size_t) sizeof(*h); i++) {\n\t\t\tduk_fb_sprintf(fb, \"%02lx\", (unsigned long) ((duk_uint8_t *)h)[i]);\n\t\t}\n\t\tduk_fb_put_byte(fb, (duk_uint8_t) DUK_ASC_RBRACKET);\n\t}\n\n#if defined(DUK_USE_REFERENCE_COUNTING)  /* currently implicitly also DUK_USE_DOUBLE_LINKED_HEAP */\n\tif (st->heavy) {\n\t\tduk_fb_sprintf(fb, \"[h_next=%p,h_prev=%p,h_refcount=%lu,h_flags=%08lx,type=%ld,\"\n\t\t               \"reachable=%ld,temproot=%ld,finalizable=%ld,finalized=%ld]\",\n\t\t               (void *) DUK_HEAPHDR_GET_NEXT(NULL, h),\n\t\t               (void *) DUK_HEAPHDR_GET_PREV(NULL, h),\n\t\t               (unsigned long) DUK_HEAPHDR_GET_REFCOUNT(h),\n\t\t               (unsigned long) DUK_HEAPHDR_GET_FLAGS(h),\n\t\t               (long) DUK_HEAPHDR_GET_TYPE(h),\n\t\t               (long) (DUK_HEAPHDR_HAS_REACHABLE(h) ? 1 : 0),\n\t\t               (long) (DUK_HEAPHDR_HAS_TEMPROOT(h) ? 1 : 0),\n\t\t               (long) (DUK_HEAPHDR_HAS_FINALIZABLE(h) ? 1 : 0),\n\t\t               (long) (DUK_HEAPHDR_HAS_FINALIZED(h) ? 1 : 0));\n\t}\n#else\n\tif (st->heavy) {\n\t\tduk_fb_sprintf(fb, \"[h_next=%p,h_flags=%08lx,type=%ld,reachable=%ld,temproot=%ld,finalizable=%ld,finalized=%ld]\",\n\t\t               (void *) DUK_HEAPHDR_GET_NEXT(NULL, h),\n\t\t               (unsigned long) DUK_HEAPHDR_GET_FLAGS(h),\n\t\t               (long) DUK_HEAPHDR_GET_TYPE(h),\n\t\t               (long) (DUK_HEAPHDR_HAS_REACHABLE(h) ? 1 : 0),\n\t\t               (long) (DUK_HEAPHDR_HAS_TEMPROOT(h) ? 1 : 0),\n\t\t               (long) (DUK_HEAPHDR_HAS_FINALIZABLE(h) ? 1 : 0),\n\t\t               (long) (DUK_HEAPHDR_HAS_FINALIZED(h) ? 1 : 0));\n\t}\n#endif\n}\n\nDUK_LOCAL void duk__print_shared_heaphdr_string(duk__dprint_state *st, duk_heaphdr_string *h) {\n\tduk_fixedbuffer *fb = st->fb;\n\n\tif (st->heavy) {\n\t\tduk_fb_sprintf(fb, \"(%p)\", (void *) h);\n\t}\n\n\tif (!h) {\n\t\treturn;\n\t}\n\n\tif (st->binary) {\n\t\tduk_size_t i;\n\t\tduk_fb_put_byte(fb, (duk_uint8_t) DUK_ASC_LBRACKET);\n\t\tfor (i = 0; i < (duk_size_t) sizeof(*h); i++) {\n\t\t\tduk_fb_sprintf(fb, \"%02lx\", (unsigned long) ((duk_uint8_t *)h)[i]);\n\t\t}\n\t\tduk_fb_put_byte(fb, (duk_uint8_t) DUK_ASC_RBRACKET);\n\t}\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tif (st->heavy) {\n\t\tduk_fb_sprintf(fb, \"[h_refcount=%lu,h_flags=%08lx,type=%ld,reachable=%ld,temproot=%ld,finalizable=%ld,finalized=%ld]\",\n\t\t               (unsigned long) DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) h),\n\t\t               (unsigned long) DUK_HEAPHDR_GET_FLAGS((duk_heaphdr *) h),\n\t\t               (long) DUK_HEAPHDR_GET_TYPE((duk_heaphdr *) h),\n\t\t               (long) (DUK_HEAPHDR_HAS_REACHABLE((duk_heaphdr *) h) ? 1 : 0),\n\t\t               (long) (DUK_HEAPHDR_HAS_TEMPROOT((duk_heaphdr *) h) ? 1 : 0),\n\t\t               (long) (DUK_HEAPHDR_HAS_FINALIZABLE((duk_heaphdr *) h) ? 1 : 0),\n\t\t               (long) (DUK_HEAPHDR_HAS_FINALIZED((duk_heaphdr *) h) ? 1 : 0));\n\t}\n#else\n\tif (st->heavy) {\n\t\tduk_fb_sprintf(fb, \"[h_flags=%08lx,type=%ld,reachable=%ld,temproot=%ld,finalizable=%ld,finalized=%ld]\",\n\t\t               (unsigned long) DUK_HEAPHDR_GET_FLAGS((duk_heaphdr *) h),\n\t\t               (long) DUK_HEAPHDR_GET_TYPE((duk_heaphdr *) h),\n\t\t               (long) (DUK_HEAPHDR_HAS_REACHABLE((duk_heaphdr *) h) ? 1 : 0),\n\t\t               (long) (DUK_HEAPHDR_HAS_TEMPROOT((duk_heaphdr *) h) ? 1 : 0),\n\t\t               (long) (DUK_HEAPHDR_HAS_FINALIZABLE((duk_heaphdr *) h) ? 1 : 0),\n\t\t               (long) (DUK_HEAPHDR_HAS_FINALIZED((duk_heaphdr *) h) ? 1 : 0));\n\t}\n#endif\n}\n\nDUK_LOCAL void duk__print_hstring(duk__dprint_state *st, duk_hstring *h, duk_bool_t quotes) {\n\tduk_fixedbuffer *fb = st->fb;\n\tconst duk_uint8_t *p;\n\tconst duk_uint8_t *p_end;\n\n\t/* terminal type: no depth check */\n\n\tif (duk_fb_is_full(fb)) {\n\t\treturn;\n\t}\n\n\tduk__print_shared_heaphdr_string(st, &h->hdr);\n\n\tif (!h) {\n\t\tduk_fb_put_cstring(fb, \"NULL\");\n\t\treturn;\n\t}\n\n\tp = DUK_HSTRING_GET_DATA(h);\n\tp_end = p + DUK_HSTRING_GET_BYTELEN(h);\n\n\tif (p_end > p && p[0] == DUK_ASC_UNDERSCORE) {\n\t\t/* if property key begins with underscore, encode it with\n\t\t * forced quotes (e.g. \"_Foo\") to distinguish it from encoded\n\t\t * internal properties (e.g. \\xffBar -> _Bar).\n\t\t */\n\t\tquotes = 1;\n\t}\n\n\tif (quotes) {\n\t\tduk_fb_put_byte(fb, (duk_uint8_t) DUK_ASC_DOUBLEQUOTE);\n\t}\n\twhile (p < p_end) {\n\t\tduk_uint8_t ch = *p++;\n\n\t\t/* two special escapes: '\\' and '\"', other printables as is */\n\t\tif (ch == '\\\\') {\n\t\t\tduk_fb_sprintf(fb, \"\\\\\\\\\");\n\t\t} else if (ch == '\"') {\n\t\t\tduk_fb_sprintf(fb, \"\\\\\\\"\");\n\t\t} else if (ch >= 0x20 && ch <= 0x7e) {\n\t\t\tduk_fb_put_byte(fb, ch);\n\t\t} else if (ch == 0xff && !quotes) {\n\t\t\t/* encode \\xffBar as _Bar if no quotes are applied, this is for\n\t\t\t * readable internal keys.\n\t\t\t */\n\t\t\tduk_fb_put_byte(fb, (duk_uint8_t) DUK_ASC_UNDERSCORE);\n\t\t} else {\n\t\t\tduk_fb_sprintf(fb, \"\\\\x%02lx\", (unsigned long) ch);\n\t\t}\n\t}\n\tif (quotes) {\n\t\tduk_fb_put_byte(fb, (duk_uint8_t) DUK_ASC_DOUBLEQUOTE);\n\t}\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\t/* XXX: limit to quoted strings only, to save keys from being cluttered? */\n\tduk_fb_sprintf(fb, \"/%lu\", (unsigned long) DUK_HEAPHDR_GET_REFCOUNT(&h->hdr));\n#endif\n}\n\n#define DUK__COMMA()  do { \\\n\t\tif (first) { \\\n\t\t\tfirst = 0; \\\n\t\t} else { \\\n\t\t\tduk_fb_put_byte(fb, (duk_uint8_t) DUK_ASC_COMMA); \\\n\t\t} \\\n\t} while (0)\n\nDUK_LOCAL void duk__print_hobject(duk__dprint_state *st, duk_hobject *h) {\n\tduk_fixedbuffer *fb = st->fb;\n\tduk_uint_fast32_t i;\n\tduk_tval *tv;\n\tduk_hstring *key;\n\tduk_bool_t first = 1;\n\tconst char *brace1 = \"{\";\n\tconst char *brace2 = \"}\";\n\tduk_bool_t pushed_loopstack = 0;\n\n\tif (duk_fb_is_full(fb)) {\n\t\treturn;\n\t}\n\n\tduk__print_shared_heaphdr(st, &h->hdr);\n\n\tif (h && DUK_HOBJECT_HAS_ARRAY_PART(h)) {\n\t\tbrace1 = \"[\";\n\t\tbrace2 = \"]\";\n\t}\n\n\tif (!h) {\n\t\tduk_fb_put_cstring(fb, \"NULL\");\n\t\tgoto finished;\n\t}\n\n\tif (st->depth >= st->depth_limit) {\n\t\tconst char *subtype = \"generic\";\n\n\t\tif (DUK_HOBJECT_IS_COMPFUNC(h)) {\n\t\t\tsubtype = \"compfunc\";\n\t\t} else if (DUK_HOBJECT_IS_NATFUNC(h)) {\n\t\t\tsubtype = \"natfunc\";\n\t\t} else if (DUK_HOBJECT_IS_THREAD(h)) {\n\t\t\tsubtype = \"thread\";\n\t\t} else if (DUK_HOBJECT_IS_BUFOBJ(h)) {\n\t\t\tsubtype = \"bufobj\";\n\t\t} else if (DUK_HOBJECT_IS_ARRAY(h)) {\n\t\t\tsubtype = \"array\";\n\t\t}\n\t\tduk_fb_sprintf(fb, \"%sobject/%s %p%s\", (const char *) brace1, subtype, (void *) h, (const char *) brace2);\n\t\treturn;\n\t}\n\n\tfor (i = 0; i < (duk_uint_fast32_t) st->loop_stack_index; i++) {\n\t\tif (st->loop_stack[i] == h) {\n\t\t\tduk_fb_sprintf(fb, \"%sLOOP:%p%s\", (const char *) brace1, (void *) h, (const char *) brace2);\n\t\t\treturn;\n\t\t}\n\t}\n\n\t/* after this, return paths should 'goto finished' for decrement */\n\tst->depth++;\n\n\tif (st->loop_stack_index >= st->loop_stack_limit) {\n\t\tduk_fb_sprintf(fb, \"%sOUT-OF-LOOP-STACK%s\", (const char *) brace1, (const char *) brace2);\n\t\tgoto finished;\n\t}\n\tst->loop_stack[st->loop_stack_index++] = h;\n\tpushed_loopstack = 1;\n\n\t/*\n\t *  Notation: double underscore used for internal properties which are not\n\t *  stored in the property allocation (e.g. '__valstack').\n\t */\n\n\tduk_fb_put_cstring(fb, brace1);\n\n\tif (DUK_HOBJECT_GET_PROPS(NULL, h)) {\n\t\tduk_uint32_t a_limit;\n\n\t\ta_limit = DUK_HOBJECT_GET_ASIZE(h);\n\t\tif (st->internal) {\n\t\t\t/* dump all allocated entries, unused entries print as 'unused',\n\t\t\t * note that these may extend beyond current 'length' and look\n\t\t\t * a bit funny.\n\t\t\t */\n\t\t} else {\n\t\t\t/* leave out trailing 'unused' elements */\n\t\t\twhile (a_limit > 0) {\n\t\t\t\ttv = DUK_HOBJECT_A_GET_VALUE_PTR(NULL, h, a_limit - 1);\n\t\t\t\tif (!DUK_TVAL_IS_UNUSED(tv)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\ta_limit--;\n\t\t\t}\n\t\t}\n\n\t\tfor (i = 0; i < a_limit; i++) {\n\t\t\ttv = DUK_HOBJECT_A_GET_VALUE_PTR(NULL, h, i);\n\t\t\tDUK__COMMA();\n\t\t\tduk__print_tval(st, tv);\n\t\t}\n\t\tfor (i = 0; i < DUK_HOBJECT_GET_ENEXT(h); i++) {\n\t\t\tkey = DUK_HOBJECT_E_GET_KEY(NULL, h, i);\n\t\t\tif (!key) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!st->internal && DUK_HSTRING_HAS_HIDDEN(key)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tDUK__COMMA();\n\t\t\tduk__print_hstring(st, key, 0);\n\t\t\tduk_fb_put_byte(fb, (duk_uint8_t) DUK_ASC_COLON);\n\t\t\tif (DUK_HOBJECT_E_SLOT_IS_ACCESSOR(NULL, h, i)) {\n\t\t\t\tduk_fb_sprintf(fb, \"[get:%p,set:%p]\",\n\t\t\t\t               (void *) DUK_HOBJECT_E_GET_VALUE(NULL, h, i).a.get,\n\t\t\t\t               (void *) DUK_HOBJECT_E_GET_VALUE(NULL, h, i).a.set);\n\t\t\t} else {\n\t\t\t\ttv = &DUK_HOBJECT_E_GET_VALUE(NULL, h, i).v;\n\t\t\t\tduk__print_tval(st, tv);\n\t\t\t}\n\t\t\tif (st->heavy) {\n\t\t\t\tduk_fb_sprintf(fb, \"<%02lx>\", (unsigned long) DUK_HOBJECT_E_GET_FLAGS(NULL, h, i));\n\t\t\t}\n\t\t}\n\t}\n\tif (st->internal) {\n\t\tif (DUK_HOBJECT_IS_ARRAY(h)) {\n\t\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__array:true\");\n\t\t}\n\t\tif (DUK_HOBJECT_HAS_EXTENSIBLE(h)) {\n\t\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__extensible:true\");\n\t\t}\n\t\tif (DUK_HOBJECT_HAS_CONSTRUCTABLE(h)) {\n\t\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__constructable:true\");\n\t\t}\n\t\tif (DUK_HOBJECT_HAS_BOUNDFUNC(h)) {\n\t\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__boundfunc:true\");\n\t\t}\n\t\tif (DUK_HOBJECT_HAS_COMPFUNC(h)) {\n\t\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__compfunc:true\");\n\t\t}\n\t\tif (DUK_HOBJECT_HAS_NATFUNC(h)) {\n\t\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__natfunc:true\");\n\t\t}\n\t\tif (DUK_HOBJECT_HAS_BUFOBJ(h)) {\n\t\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__bufobj:true\");\n\t\t}\n\t\tif (DUK_HOBJECT_IS_THREAD(h)) {\n\t\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__thread:true\");\n\t\t}\n\t\tif (DUK_HOBJECT_HAS_ARRAY_PART(h)) {\n\t\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__array_part:true\");\n\t\t}\n\t\tif (DUK_HOBJECT_HAS_STRICT(h)) {\n\t\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__strict:true\");\n\t\t}\n\t\tif (DUK_HOBJECT_HAS_NOTAIL(h)) {\n\t\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__notail:true\");\n\t\t}\n\t\tif (DUK_HOBJECT_HAS_NEWENV(h)) {\n\t\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__newenv:true\");\n\t\t}\n\t\tif (DUK_HOBJECT_HAS_NAMEBINDING(h)) {\n\t\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__namebinding:true\");\n\t\t}\n\t\tif (DUK_HOBJECT_HAS_CREATEARGS(h)) {\n\t\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__createargs:true\");\n\t\t}\n\t\tif (DUK_HOBJECT_HAS_EXOTIC_ARRAY(h)) {\n\t\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__exotic_array:true\");\n\t\t}\n\t\tif (DUK_HOBJECT_HAS_EXOTIC_STRINGOBJ(h)) {\n\t\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__exotic_stringobj:true\");\n\t\t}\n\t\tif (DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS(h)) {\n\t\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__exotic_arguments:true\");\n\t\t}\n\t\tif (DUK_HOBJECT_HAS_EXOTIC_DUKFUNC(h)) {\n\t\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__exotic_dukfunc:true\");\n\t\t}\n\t\tif (DUK_HOBJECT_IS_BUFOBJ(h)) {\n\t\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__exotic_bufobj:true\");\n\t\t}\n\t\tif (DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(h)) {\n\t\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__exotic_proxyobj:true\");\n\t\t}\n\t}\n\n\tif (st->internal && DUK_HOBJECT_IS_ARRAY(h)) {\n\t\tduk_harray *a = (duk_harray *) h;\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__length:%ld\", (long) a->length);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__length_nonwritable:%ld\", (long) a->length_nonwritable);\n\t} else if (st->internal && DUK_HOBJECT_IS_COMPFUNC(h)) {\n\t\tduk_hcompfunc *f = (duk_hcompfunc *) h;\n\t\tDUK__COMMA(); duk_fb_put_cstring(fb, \"__data:\");\n\t\tduk__print_hbuffer(st, (duk_hbuffer *) DUK_HCOMPFUNC_GET_DATA(NULL, f));\n\t\tDUK__COMMA(); duk_fb_put_cstring(fb, \"__lexenv:\"); duk__print_hobject(st, DUK_HCOMPFUNC_GET_LEXENV(NULL, f));\n\t\tDUK__COMMA(); duk_fb_put_cstring(fb, \"__varenv:\"); duk__print_hobject(st, DUK_HCOMPFUNC_GET_VARENV(NULL, f));\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__nregs:%ld\", (long) f->nregs);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__nargs:%ld\", (long) f->nargs);\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__start_line:%ld\", (long) f->start_line);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__end_line:%ld\", (long) f->end_line);\n#endif\n\t\tDUK__COMMA(); duk_fb_put_cstring(fb, \"__data:\");\n\t\tduk__print_hbuffer(st, (duk_hbuffer *) DUK_HCOMPFUNC_GET_DATA(NULL, f));\n\t} else if (st->internal && DUK_HOBJECT_IS_NATFUNC(h)) {\n\t\tduk_hnatfunc *f = (duk_hnatfunc *) h;\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__func:\");\n\t\tduk_fb_put_funcptr(fb, (duk_uint8_t *) &f->func, sizeof(f->func));\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__nargs:%ld\", (long) f->nargs);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__magic:%ld\", (long) f->magic);\n\t} else if (st->internal && DUK_HOBJECT_IS_DECENV(h)) {\n\t\tduk_hdecenv *e = (duk_hdecenv *) h;\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__thread:\"); duk__print_hobject(st, (duk_hobject *) e->thread);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__varmap:\"); duk__print_hobject(st, (duk_hobject *) e->varmap);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__regbase:%ld\", (long) e->regbase);\n\t} else if (st->internal && DUK_HOBJECT_IS_OBJENV(h)) {\n\t\tduk_hobjenv *e = (duk_hobjenv *) h;\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__target:\"); duk__print_hobject(st, (duk_hobject *) e->target);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__has_this:%ld\", (long) e->has_this);\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n\t} else if (st->internal && DUK_HOBJECT_IS_BUFOBJ(h)) {\n\t\tduk_hbufobj *b = (duk_hbufobj *) h;\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__buf:\");\n\t\tduk__print_hbuffer(st, (duk_hbuffer *) b->buf);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__buf_prop:\");\n\t\tduk__print_hobject(st, (duk_hobject *) b->buf_prop);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__offset:%ld\", (long) b->offset);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__length:%ld\", (long) b->length);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__shift:%ld\", (long) b->shift);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__elemtype:%ld\", (long) b->elem_type);\n#endif\n\t} else if (st->internal && DUK_HOBJECT_IS_THREAD(h)) {\n\t\tduk_hthread *t = (duk_hthread *) h;\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__strict:%ld\", (long) t->strict);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__state:%ld\", (long) t->state);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__unused1:%ld\", (long) t->unused1);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__unused2:%ld\", (long) t->unused2);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__valstack_max:%ld\", (long) t->valstack_max);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__callstack_max:%ld\", (long) t->callstack_max);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__catchstack_max:%ld\", (long) t->catchstack_max);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__valstack:%p\", (void *) t->valstack);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__valstack_end:%p/%ld\", (void *) t->valstack_end, (long) (t->valstack_end - t->valstack));\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__valstack_bottom:%p/%ld\", (void *) t->valstack_bottom, (long) (t->valstack_bottom - t->valstack));\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__valstack_top:%p/%ld\", (void *) t->valstack_top, (long) (t->valstack_top - t->valstack));\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__catchstack:%p\", (void *) t->catchstack);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__catchstack_size:%ld\", (long) t->catchstack_size);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__catchstack_top:%ld\", (long) t->catchstack_top);\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__resumer:\"); duk__print_hobject(st, (duk_hobject *) t->resumer);\n\t\t/* XXX: print built-ins array? */\n\n\t}\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tif (st->internal) {\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__refcount:%lu\", (unsigned long) DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) h));\n\t}\n#endif\n\tif (st->internal) {\n\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__class:%ld\", (long) DUK_HOBJECT_GET_CLASS_NUMBER(h));\n\t}\n\n\tDUK__COMMA(); duk_fb_sprintf(fb, \"__heapptr:%p\", (void *) h);  /* own pointer */\n\n\t/* prototype should be last, for readability */\n\tif (DUK_HOBJECT_GET_PROTOTYPE(NULL, h)) {\n\t\tif (st->follow_proto) {\n\t\t\tDUK__COMMA(); duk_fb_put_cstring(fb, \"__prototype:\"); duk__print_hobject(st, DUK_HOBJECT_GET_PROTOTYPE(NULL, h));\n\t\t} else {\n\t\t\tDUK__COMMA(); duk_fb_sprintf(fb, \"__prototype:%p\", (void *) DUK_HOBJECT_GET_PROTOTYPE(NULL, h));\n\t\t}\n\t}\n\n\tduk_fb_put_cstring(fb, brace2);\n\n#if defined(DUK_USE_HOBJECT_HASH_PART)\n\tif (st->heavy && DUK_HOBJECT_GET_HSIZE(h) > 0) {\n\t\tduk_fb_put_byte(fb, (duk_uint8_t) DUK_ASC_LANGLE);\n\t\tfor (i = 0; i < DUK_HOBJECT_GET_HSIZE(h); i++) {\n\t\t\tduk_uint_t h_idx = DUK_HOBJECT_H_GET_INDEX(NULL, h, i);\n\t\t\tif (i > 0) {\n\t\t\t\tduk_fb_put_byte(fb, (duk_uint8_t) DUK_ASC_COMMA);\n\t\t\t}\n\t\t\tif (h_idx == DUK_HOBJECT_HASHIDX_UNUSED) {\n\t\t\t\tduk_fb_sprintf(fb, \"u\");\n\t\t\t} else if (h_idx == DUK_HOBJECT_HASHIDX_DELETED) {\n\t\t\t\tduk_fb_sprintf(fb, \"d\");\n\t\t\t} else {\n\t\t\t\tduk_fb_sprintf(fb, \"%ld\", (long) h_idx);\n\t\t\t}\n\t\t}\n\t\tduk_fb_put_byte(fb, (duk_uint8_t) DUK_ASC_RANGLE);\n\t}\n#endif\n\n finished:\n\tst->depth--;\n\tif (pushed_loopstack) {\n\t\tst->loop_stack_index--;\n\t\tst->loop_stack[st->loop_stack_index] = NULL;\n\t}\n}\n\nDUK_LOCAL void duk__print_hbuffer(duk__dprint_state *st, duk_hbuffer *h) {\n\tduk_fixedbuffer *fb = st->fb;\n\tduk_size_t i, n;\n\tduk_uint8_t *p;\n\n\tif (duk_fb_is_full(fb)) {\n\t\treturn;\n\t}\n\n\t/* terminal type: no depth check */\n\n\tif (!h) {\n\t\tduk_fb_put_cstring(fb, \"NULL\");\n\t\treturn;\n\t}\n\n\tif (DUK_HBUFFER_HAS_DYNAMIC(h)) {\n\t\tif (DUK_HBUFFER_HAS_EXTERNAL(h)) {\n\t\t\tduk_hbuffer_external *g = (duk_hbuffer_external *) h;\n\t\t\tduk_fb_sprintf(fb, \"buffer:external:%p:%ld\",\n\t\t\t               (void *) DUK_HBUFFER_EXTERNAL_GET_DATA_PTR(NULL, g),\n\t\t\t               (long) DUK_HBUFFER_EXTERNAL_GET_SIZE(g));\n\t\t} else {\n\t\t\tduk_hbuffer_dynamic *g = (duk_hbuffer_dynamic *) h;\n\t\t\tduk_fb_sprintf(fb, \"buffer:dynamic:%p:%ld\",\n\t\t\t               (void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(NULL, g),\n\t\t\t               (long) DUK_HBUFFER_DYNAMIC_GET_SIZE(g));\n\t\t}\n\t} else {\n\t\tduk_fb_sprintf(fb, \"buffer:fixed:%ld\", (long) DUK_HBUFFER_GET_SIZE(h));\n\t}\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tduk_fb_sprintf(fb, \"/%lu\", (unsigned long) DUK_HEAPHDR_GET_REFCOUNT(&h->hdr));\n#endif\n\n\tif (st->hexdump) {\n\t\tduk_fb_sprintf(fb, \"=[\");\n\t\tn = DUK_HBUFFER_GET_SIZE(h);\n\t\tp = (duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(NULL, h);\n\t\tfor (i = 0; i < n; i++) {\n\t\t\tduk_fb_sprintf(fb, \"%02lx\", (unsigned long) p[i]);\n\t\t}\n\t\tduk_fb_sprintf(fb, \"]\");\n\t}\n}\n\nDUK_LOCAL void duk__print_heaphdr(duk__dprint_state *st, duk_heaphdr *h) {\n\tduk_fixedbuffer *fb = st->fb;\n\n\tif (duk_fb_is_full(fb)) {\n\t\treturn;\n\t}\n\n\tif (!h) {\n\t\tduk_fb_put_cstring(fb, \"NULL\");\n\t\treturn;\n\t}\n\n\tswitch (DUK_HEAPHDR_GET_TYPE(h)) {\n\tcase DUK_HTYPE_STRING:\n\t\tduk__print_hstring(st, (duk_hstring *) h, 1);\n\t\tbreak;\n\tcase DUK_HTYPE_OBJECT:\n\t\tduk__print_hobject(st, (duk_hobject *) h);\n\t\tbreak;\n\tcase DUK_HTYPE_BUFFER:\n\t\tduk__print_hbuffer(st, (duk_hbuffer *) h);\n\t\tbreak;\n\tdefault:\n\t\tduk_fb_sprintf(fb, \"[unknown htype %ld]\", (long) DUK_HEAPHDR_GET_TYPE(h));\n\t\tbreak;\n\t}\n}\n\nDUK_LOCAL void duk__print_tval(duk__dprint_state *st, duk_tval *tv) {\n\tduk_fixedbuffer *fb = st->fb;\n\n\tif (duk_fb_is_full(fb)) {\n\t\treturn;\n\t}\n\n\t/* depth check is done when printing an actual type */\n\n\tif (st->heavy) {\n\t\tduk_fb_sprintf(fb, \"(%p)\", (void *) tv);\n\t}\n\n\tif (!tv) {\n\t\tduk_fb_put_cstring(fb, \"NULL\");\n\t\treturn;\n\t}\n\n\tif (st->binary) {\n\t\tduk_size_t i;\n\t\tduk_fb_put_byte(fb, (duk_uint8_t) DUK_ASC_LBRACKET);\n\t\tfor (i = 0; i < (duk_size_t) sizeof(*tv); i++) {\n\t\t\tduk_fb_sprintf(fb, \"%02lx\", (unsigned long) ((duk_uint8_t *)tv)[i]);\n\t\t}\n\t\tduk_fb_put_byte(fb, (duk_uint8_t) DUK_ASC_RBRACKET);\n\t}\n\n\tif (st->heavy) {\n\t\tduk_fb_put_byte(fb, (duk_uint8_t) DUK_ASC_LANGLE);\n\t}\n\tswitch (DUK_TVAL_GET_TAG(tv)) {\n\tcase DUK_TAG_UNDEFINED: {\n\t\tduk_fb_put_cstring(fb, \"undefined\");\n\t\tbreak;\n\t}\n\tcase DUK_TAG_UNUSED: {\n\t\tduk_fb_put_cstring(fb, \"unused\");\n\t\tbreak;\n\t}\n\tcase DUK_TAG_NULL: {\n\t\tduk_fb_put_cstring(fb, \"null\");\n\t\tbreak;\n\t}\n\tcase DUK_TAG_BOOLEAN: {\n\t\tduk_fb_put_cstring(fb, DUK_TVAL_GET_BOOLEAN(tv) ? \"true\" : \"false\");\n\t\tbreak;\n\t}\n\tcase DUK_TAG_STRING: {\n\t\t/* Note: string is a terminal heap object, so no depth check here */\n\t\tduk__print_hstring(st, DUK_TVAL_GET_STRING(tv), 1);\n\t\tbreak;\n\t}\n\tcase DUK_TAG_OBJECT: {\n\t\tduk__print_hobject(st, DUK_TVAL_GET_OBJECT(tv));\n\t\tbreak;\n\t}\n\tcase DUK_TAG_BUFFER: {\n\t\tduk__print_hbuffer(st, DUK_TVAL_GET_BUFFER(tv));\n\t\tbreak;\n\t}\n\tcase DUK_TAG_POINTER: {\n\t\tduk_fb_sprintf(fb, \"pointer:%p\", (void *) DUK_TVAL_GET_POINTER(tv));\n\t\tbreak;\n\t}\n\tcase DUK_TAG_LIGHTFUNC: {\n\t\tduk_c_function func;\n\t\tduk_small_uint_t lf_flags;\n\n\t\tDUK_TVAL_GET_LIGHTFUNC(tv, func, lf_flags);\n\t\tduk_fb_sprintf(fb, \"lightfunc:\");\n\t\tduk_fb_put_funcptr(fb, (duk_uint8_t *) &func, sizeof(func));\n\t\tduk_fb_sprintf(fb, \":%04lx\", (long) lf_flags);\n\t\tbreak;\n\t}\n#if defined(DUK_USE_FASTINT)\n\tcase DUK_TAG_FASTINT:\n\t\tDUK_ASSERT(!DUK_TVAL_IS_UNUSED(tv));\n\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv));\n\t\tduk_fb_sprintf(fb, \"%.18gF\", (double) DUK_TVAL_GET_NUMBER(tv));\n\t\tbreak;\n#endif\n\tdefault: {\n\t\t/* IEEE double is approximately 16 decimal digits; print a couple extra */\n\t\tDUK_ASSERT(!DUK_TVAL_IS_UNUSED(tv));\n\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv));\n\t\tduk_fb_sprintf(fb, \"%.18g\", (double) DUK_TVAL_GET_NUMBER(tv));\n\t\tbreak;\n\t}\n\t}\n\tif (st->heavy) {\n\t\tduk_fb_put_byte(fb, (duk_uint8_t) DUK_ASC_RANGLE);\n\t}\n}\n\nDUK_LOCAL void duk__print_instr(duk__dprint_state *st, duk_instr_t ins) {\n\tduk_fixedbuffer *fb = st->fb;\n\tduk_small_int_t op;\n\tconst char *op_name;\n\n\top = (duk_small_int_t) DUK_DEC_OP(ins);\n\top_name = duk__bc_optab[op];\n\n\t/* XXX: option to fix opcode length so it lines up nicely */\n\n\tif (op == DUK_OP_JUMP) {\n\t\tduk_int_t diff1 = DUK_DEC_ABC(ins) - DUK_BC_JUMP_BIAS;  /* from next pc */\n\t\tduk_int_t diff2 = diff1 + 1;                            /* from curr pc */\n\n\t\tduk_fb_sprintf(fb, \"%s %ld (to pc%c%ld)\",\n\t\t               (const char *) op_name, (long) diff1,\n\t\t               (int) (diff2 >= 0 ? '+' : '-'),  /* char format: use int */\n\t\t               (long) (diff2 >= 0 ? diff2 : -diff2));\n\t} else {\n\t\tduk_fb_sprintf(fb, \"%s %ld, %ld, %ld\",\n\t\t               (const char *) op_name, (long) DUK_DEC_A(ins),\n\t\t               (long) DUK_DEC_B(ins), (long) DUK_DEC_C(ins));\n\t}\n}\n\nDUK_LOCAL void duk__print_opcode(duk__dprint_state *st, duk_small_int_t opcode) {\n\tduk_fixedbuffer *fb = st->fb;\n\n\tif (opcode < DUK_BC_OP_MIN || opcode > DUK_BC_OP_MAX) {\n\t\tduk_fb_sprintf(fb, \"?(%ld)\", (long) opcode);\n\t} else {\n\t\tduk_fb_sprintf(fb, \"%s\", (const char *) duk__bc_optab[opcode]);\n\t}\n}\n\nDUK_INTERNAL duk_int_t duk_debug_vsnprintf(char *str, duk_size_t size, const char *format, va_list ap) {\n\tduk_fixedbuffer fb;\n\tconst char *p = format;\n\tconst char *p_end = p + DUK_STRLEN(format);\n\tduk_int_t retval;\n\n\tDUK_MEMZERO(&fb, sizeof(fb));\n\tfb.buffer = (duk_uint8_t *) str;\n\tfb.length = size;\n\tfb.offset = 0;\n\tfb.truncated = 0;\n\n\twhile (p < p_end) {\n\t\tchar ch = *p++;\n\t\tconst char *p_begfmt = NULL;\n\t\tduk_bool_t got_exclamation = 0;\n\t\tduk_bool_t got_long = 0;  /* %lf, %ld etc */\n\t\tduk__dprint_state st;\n\n\t\tif (ch != DUK_ASC_PERCENT) {\n\t\t\tduk_fb_put_byte(&fb, (duk_uint8_t) ch);\n\t\t\tcontinue;\n\t\t}\n\n\t\t/*\n\t\t *  Format tag parsing.  Since we don't understand all the\n\t\t *  possible format tags allowed, we just scan for a terminating\n\t\t *  specifier and keep track of relevant modifiers that we do\n\t\t *  understand.  See man 3 printf.\n\t\t */\n\n\t\tDUK_MEMZERO(&st, sizeof(st));\n\t\tst.fb = &fb;\n\t\tst.depth = 0;\n\t\tst.depth_limit = 1;\n\t\tst.loop_stack_index = 0;\n\t\tst.loop_stack_limit = DUK__LOOP_STACK_DEPTH;\n\n\t\tp_begfmt = p - 1;\n\t\twhile (p < p_end) {\n\t\t\tch = *p++;\n\n\t\t\tif (ch == DUK_ASC_STAR) {\n\t\t\t\t/* unsupported: would consume multiple args */\n\t\t\t\tgoto format_error;\n\t\t\t} else if (ch == DUK_ASC_PERCENT) {\n\t\t\t\tduk_fb_put_byte(&fb, (duk_uint8_t) DUK_ASC_PERCENT);\n\t\t\t\tbreak;\n\t\t\t} else if (ch == DUK_ASC_EXCLAMATION) {\n\t\t\t\tgot_exclamation = 1;\n\t\t\t} else if (!got_exclamation && ch == DUK_ASC_LC_L) {\n\t\t\t\tgot_long = 1;\n\t\t\t} else if (got_exclamation && ch == DUK_ASC_LC_D) {\n\t\t\t\tst.depth_limit = DUK__DEEP_DEPTH_LIMIT;\n\t\t\t} else if (got_exclamation && ch == DUK_ASC_LC_P) {\n\t\t\t\tst.follow_proto = 1;\n\t\t\t} else if (got_exclamation && ch == DUK_ASC_LC_I) {\n\t\t\t\tst.internal = 1;\n\t\t\t} else if (got_exclamation && ch == DUK_ASC_LC_X) {\n\t\t\t\tst.hexdump = 1;\n\t\t\t} else if (got_exclamation && ch == DUK_ASC_LC_H) {\n\t\t\t\tst.heavy = 1;\n\t\t\t} else if (got_exclamation && ch == DUK_ASC_ATSIGN) {\n\t\t\t\tst.pointer = 1;\n\t\t\t} else if (got_exclamation && ch == DUK_ASC_HASH) {\n\t\t\t\tst.binary = 1;\n\t\t\t} else if (got_exclamation && ch == DUK_ASC_UC_T) {\n\t\t\t\tduk_tval *t = va_arg(ap, duk_tval *);\n\t\t\t\tif (st.pointer && !st.heavy) {\n\t\t\t\t\tduk_fb_sprintf(&fb, \"(%p)\", (void *) t);\n\t\t\t\t}\n\t\t\t\tduk__print_tval(&st, t);\n\t\t\t\tbreak;\n\t\t\t} else if (got_exclamation && ch == DUK_ASC_UC_O) {\n\t\t\t\tduk_heaphdr *t = va_arg(ap, duk_heaphdr *);\n\t\t\t\tif (st.pointer && !st.heavy) {\n\t\t\t\t\tduk_fb_sprintf(&fb, \"(%p)\", (void *) t);\n\t\t\t\t}\n\t\t\t\tduk__print_heaphdr(&st, t);\n\t\t\t\tbreak;\n\t\t\t} else if (got_exclamation && ch == DUK_ASC_UC_I) {\n\t\t\t\tduk_instr_t t = va_arg(ap, duk_instr_t);\n\t\t\t\tduk__print_instr(&st, t);\n\t\t\t\tbreak;\n\t\t\t} else if (got_exclamation && ch == DUK_ASC_UC_C) {\n\t\t\t\tlong t = va_arg(ap, long);\n\t\t\t\tduk__print_opcode(&st, (duk_small_int_t) t);\n\t\t\t\tbreak;\n\t\t\t} else if (!got_exclamation && strchr(DUK__ALLOWED_STANDARD_SPECIFIERS, (int) ch)) {\n\t\t\t\tchar fmtbuf[DUK__MAX_FORMAT_TAG_LENGTH];\n\t\t\t\tduk_size_t fmtlen;\n\n\t\t\t\tDUK_ASSERT(p >= p_begfmt);\n\t\t\t\tfmtlen = (duk_size_t) (p - p_begfmt);\n\t\t\t\tif (fmtlen >= sizeof(fmtbuf)) {\n\t\t\t\t\t/* format is too large, abort */\n\t\t\t\t\tgoto format_error;\n\t\t\t\t}\n\t\t\t\tDUK_MEMZERO(fmtbuf, sizeof(fmtbuf));\n\t\t\t\tDUK_MEMCPY(fmtbuf, p_begfmt, fmtlen);\n\n\t\t\t\t/* assume exactly 1 arg, which is why '*' is forbidden; arg size still\n\t\t\t\t * depends on type though.\n\t\t\t\t */\n\n\t\t\t\tif (ch == DUK_ASC_LC_F || ch == DUK_ASC_LC_G || ch == DUK_ASC_LC_E) {\n\t\t\t\t\t/* %f and %lf both consume a 'long' */\n\t\t\t\t\tdouble arg = va_arg(ap, double);\n\t\t\t\t\tduk_fb_sprintf(&fb, fmtbuf, arg);\n\t\t\t\t} else if (ch == DUK_ASC_LC_D && got_long) {\n\t\t\t\t\t/* %ld */\n\t\t\t\t\tlong arg = va_arg(ap, long);\n\t\t\t\t\tduk_fb_sprintf(&fb, fmtbuf, arg);\n\t\t\t\t} else if (ch == DUK_ASC_LC_D) {\n\t\t\t\t\t/* %d; only 16 bits are guaranteed */\n\t\t\t\t\tint arg = va_arg(ap, int);\n\t\t\t\t\tduk_fb_sprintf(&fb, fmtbuf, arg);\n\t\t\t\t} else if (ch == DUK_ASC_LC_U && got_long) {\n\t\t\t\t\t/* %lu */\n\t\t\t\t\tunsigned long arg = va_arg(ap, unsigned long);\n\t\t\t\t\tduk_fb_sprintf(&fb, fmtbuf, arg);\n\t\t\t\t} else if (ch == DUK_ASC_LC_U) {\n\t\t\t\t\t/* %u; only 16 bits are guaranteed */\n\t\t\t\t\tunsigned int arg = va_arg(ap, unsigned int);\n\t\t\t\t\tduk_fb_sprintf(&fb, fmtbuf, arg);\n\t\t\t\t} else if (ch == DUK_ASC_LC_X && got_long) {\n\t\t\t\t\t/* %lx */\n\t\t\t\t\tunsigned long arg = va_arg(ap, unsigned long);\n\t\t\t\t\tduk_fb_sprintf(&fb, fmtbuf, arg);\n\t\t\t\t} else if (ch == DUK_ASC_LC_X) {\n\t\t\t\t\t/* %x; only 16 bits are guaranteed */\n\t\t\t\t\tunsigned int arg = va_arg(ap, unsigned int);\n\t\t\t\t\tduk_fb_sprintf(&fb, fmtbuf, arg);\n\t\t\t\t} else if (ch == DUK_ASC_LC_S) {\n\t\t\t\t\t/* %s */\n\t\t\t\t\tconst char *arg = va_arg(ap, const char *);\n\t\t\t\t\tif (arg == NULL) {\n\t\t\t\t\t\t/* '%s' and NULL is not portable, so special case\n\t\t\t\t\t\t * it for debug printing.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tduk_fb_sprintf(&fb, \"NULL\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tduk_fb_sprintf(&fb, fmtbuf, arg);\n\t\t\t\t\t}\n\t\t\t\t} else if (ch == DUK_ASC_LC_P) {\n\t\t\t\t\t/* %p */\n\t\t\t\t\tvoid *arg = va_arg(ap, void *);\n\t\t\t\t\tif (arg == NULL) {\n\t\t\t\t\t\t/* '%p' and NULL is portable, but special case it\n\t\t\t\t\t\t * anyway to get a standard NULL marker in logs.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tduk_fb_sprintf(&fb, \"NULL\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tduk_fb_sprintf(&fb, fmtbuf, arg);\n\t\t\t\t\t}\n\t\t\t\t} else if (ch == DUK_ASC_LC_C) {\n\t\t\t\t\t/* '%c', passed concretely as int */\n\t\t\t\t\tint arg = va_arg(ap, int);\n\t\t\t\t\tduk_fb_sprintf(&fb, fmtbuf, arg);\n\t\t\t\t} else {\n\t\t\t\t\t/* Should not happen. */\n\t\t\t\t\tduk_fb_sprintf(&fb, \"INVALID-FORMAT(%s)\", (const char *) fmtbuf);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\t/* ignore */\n\t\t\t}\n\t\t}\n\t}\n\tgoto done;\n\n format_error:\n\tduk_fb_put_cstring(&fb, \"FMTERR\");\n\t/* fall through */\n\n done:\n\tretval = (duk_int_t) fb.offset;\n\tduk_fb_put_byte(&fb, (duk_uint8_t) 0);\n\n\t/* return total chars written excluding terminator */\n\treturn retval;\n}\n\n#if 0  /*unused*/\nDUK_INTERNAL duk_int_t duk_debug_snprintf(char *str, duk_size_t size, const char *format, ...) {\n\tduk_int_t retval;\n\tva_list ap;\n\tva_start(ap, format);\n\tretval = duk_debug_vsnprintf(str, size, format, ap);\n\tva_end(ap);\n\treturn retval;\n}\n#endif\n\n/* Formatting function pointers is tricky: there is no standard pointer for\n * function pointers and the size of a function pointer may depend on the\n * specific pointer type.  This helper formats a function pointer based on\n * its memory layout to get something useful on most platforms.\n */\nDUK_INTERNAL void duk_debug_format_funcptr(char *buf, duk_size_t buf_size, duk_uint8_t *fptr, duk_size_t fptr_size) {\n\tduk_size_t i;\n\tduk_uint8_t *p = (duk_uint8_t *) buf;\n\tduk_uint8_t *p_end = (duk_uint8_t *) (buf + buf_size - 1);\n\n\tDUK_MEMZERO(buf, buf_size);\n\n\tfor (i = 0; i < fptr_size; i++) {\n\t\tduk_int_t left = (duk_int_t) (p_end - p);\n\t\tduk_uint8_t ch;\n\t\tif (left <= 0) {\n\t\t\tbreak;\n\t\t}\n\n\t\t/* Quite approximate but should be useful for little and big endian. */\n#if defined(DUK_USE_INTEGER_BE)\n\t\tch = fptr[i];\n#else\n\t\tch = fptr[fptr_size - 1 - i];\n#endif\n\t\tp += DUK_SNPRINTF((char *) p, left, \"%02lx\", (unsigned long) ch);\n\t}\n}\n\n#endif  /* DUK_USE_DEBUG */\n\n/* automatic undefs */\n#undef DUK__ALLOWED_STANDARD_SPECIFIERS\n#undef DUK__COMMA\n#undef DUK__DEEP_DEPTH_LIMIT\n#undef DUK__LOOP_STACK_DEPTH\n#undef DUK__MAX_FORMAT_TAG_LENGTH\n/*\n *  Duktape debugger\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\n/*\n *  Helper structs\n */\n\ntypedef union {\n\tvoid *p;\n\tduk_uint_t b[1];\n\t/* Use b[] to access the size of the union, which is strictly not\n\t * correct.  Can't use fixed size unless there's feature detection\n\t * for pointer byte size.\n\t */\n} duk__ptr_union;\n\n/*\n *  Detach handling\n */\n\n#define DUK__SET_CONN_BROKEN(thr,reason) do { \\\n\t\t/* For now shared handler is fine. */ \\\n\t\tduk__debug_do_detach1((thr)->heap, (reason)); \\\n\t} while (0)\n\nDUK_LOCAL void duk__debug_do_detach1(duk_heap *heap, duk_int_t reason) {\n\t/* Can be called multiple times with no harm.  Mark the transport\n\t * bad (dbg_read_cb == NULL) and clear state except for the detached\n\t * callback and the udata field.  The detached callback is delayed\n\t * to the message loop so that it can be called between messages;\n\t * this avoids corner cases related to immediate debugger reattach\n\t * inside the detached callback.\n\t */\n\n\tif (heap->dbg_detaching) {\n\t\tDUK_D(DUK_DPRINT(\"debugger already detaching, ignore detach1\"));\n\t\treturn;\n\t}\n\n\tDUK_D(DUK_DPRINT(\"debugger transport detaching, marking transport broken\"));\n\n\theap->dbg_detaching = 1;  /* prevent multiple in-progress detaches */\n\n\tif (heap->dbg_write_cb != NULL) {\n\t\tduk_hthread *thr;\n\n\t\tthr = heap->heap_thread;\n\t\tDUK_ASSERT(thr != NULL);\n\n\t\tduk_debug_write_notify(thr, DUK_DBG_CMD_DETACHING);\n\t\tduk_debug_write_int(thr, reason);\n\t\tduk_debug_write_eom(thr);\n\t}\n\n\theap->dbg_read_cb = NULL;\n\theap->dbg_write_cb = NULL;\n\theap->dbg_peek_cb = NULL;\n\theap->dbg_read_flush_cb = NULL;\n\theap->dbg_write_flush_cb = NULL;\n\theap->dbg_request_cb = NULL;\n\t/* heap->dbg_detached_cb: keep */\n\t/* heap->dbg_udata: keep */\n\t/* heap->dbg_processing: keep on purpose to avoid debugger re-entry in detaching state */\n\theap->dbg_state_dirty = 0;\n\theap->dbg_force_restart = 0;\n\theap->dbg_step_type = 0;\n\theap->dbg_step_thread = NULL;\n\theap->dbg_step_csindex = 0;\n\theap->dbg_step_startline = 0;\n\theap->dbg_have_next_byte = 0;\n\tduk_debug_clear_paused(heap);  /* XXX: some overlap with field inits above */\n\theap->dbg_state_dirty = 0;     /* XXX: clear_paused sets dirty; rework? */\n\n\t/* Ensure there are no stale active breakpoint pointers.\n\t * Breakpoint list is currently kept - we could empty it\n\t * here but we'd need to handle refcounts correctly, and\n\t * we'd need a 'thr' reference for that.\n\t *\n\t * XXX: clear breakpoint on either attach or detach?\n\t */\n\theap->dbg_breakpoints_active[0] = (duk_breakpoint *) NULL;\n}\n\nDUK_LOCAL void duk__debug_do_detach2(duk_heap *heap) {\n\tduk_debug_detached_function detached_cb;\n\tvoid *detached_udata;\n\tduk_hthread *thr;\n\tduk_context *ctx;\n\n\tthr = heap->heap_thread;\n\tif (thr == NULL) {\n\t\tDUK_ASSERT(heap->dbg_detached_cb == NULL);\n\t\treturn;\n\t}\n\tctx = (duk_context *) thr;\n\n\t/* Safe to call multiple times. */\n\n\tdetached_cb = heap->dbg_detached_cb;\n\tdetached_udata = heap->dbg_udata;\n\theap->dbg_detached_cb = NULL;\n\theap->dbg_udata = NULL;\n\n\tif (detached_cb) {\n\t\t/* Careful here: state must be wiped before the call\n\t\t * so that we can cleanly handle a re-attach from\n\t\t * inside the callback.\n\t\t */\n\t\tDUK_D(DUK_DPRINT(\"detached during message loop, delayed call to detached_cb\"));\n\t\tdetached_cb(ctx, detached_udata);\n\t}\n\n\theap->dbg_detaching = 0;\n}\n\nDUK_INTERNAL void duk_debug_do_detach(duk_heap *heap) {\n\tduk__debug_do_detach1(heap, 0);\n\tduk__debug_do_detach2(heap);\n}\n\n/* Called on a read/write error: NULL all callbacks except the detached\n * callback so that we never accidentally call them after a read/write\n * error has been indicated.  This is especially important for the transport\n * I/O callbacks to fulfill guaranteed callback semantics.\n */\nDUK_LOCAL void duk__debug_null_most_callbacks(duk_hthread *thr) {\n\tduk_heap *heap;\n\n\tDUK_ASSERT(thr != NULL);\n\n\theap = thr->heap;\n\tDUK_D(DUK_DPRINT(\"transport read/write error, NULL all callbacks expected detached\"));\n\theap->dbg_read_cb = NULL;\n\theap->dbg_write_cb = NULL;  /* this is especially critical to avoid another write call in detach1() */\n\theap->dbg_peek_cb = NULL;\n\theap->dbg_read_flush_cb = NULL;\n\theap->dbg_write_flush_cb = NULL;\n\theap->dbg_request_cb = NULL;\n\t/* keep heap->dbg_detached_cb */\n}\n\n/*\n *  Debug connection peek and flush primitives\n */\n\nDUK_INTERNAL duk_bool_t duk_debug_read_peek(duk_hthread *thr) {\n\tduk_heap *heap;\n\n\tDUK_ASSERT(thr != NULL);\n\theap = thr->heap;\n\tDUK_ASSERT(heap != NULL);\n\n\tif (heap->dbg_read_cb == NULL) {\n\t\tDUK_D(DUK_DPRINT(\"attempt to peek in detached state, return zero (= no data)\"));\n\t\treturn 0;\n\t}\n\tif (heap->dbg_peek_cb == NULL) {\n\t\tDUK_DD(DUK_DDPRINT(\"no peek callback, return zero (= no data)\"));\n\t\treturn 0;\n\t}\n\n\treturn (duk_bool_t) (heap->dbg_peek_cb(heap->dbg_udata) > 0);\n}\n\nDUK_INTERNAL void duk_debug_read_flush(duk_hthread *thr) {\n\tduk_heap *heap;\n\n\tDUK_ASSERT(thr != NULL);\n\theap = thr->heap;\n\tDUK_ASSERT(heap != NULL);\n\n\tif (heap->dbg_read_cb == NULL) {\n\t\tDUK_D(DUK_DPRINT(\"attempt to read flush in detached state, ignore\"));\n\t\treturn;\n\t}\n\tif (heap->dbg_read_flush_cb == NULL) {\n\t\tDUK_DD(DUK_DDPRINT(\"no read flush callback, ignore\"));\n\t\treturn;\n\t}\n\n\theap->dbg_read_flush_cb(heap->dbg_udata);\n}\n\nDUK_INTERNAL void duk_debug_write_flush(duk_hthread *thr) {\n\tduk_heap *heap;\n\n\tDUK_ASSERT(thr != NULL);\n\theap = thr->heap;\n\tDUK_ASSERT(heap != NULL);\n\n\tif (heap->dbg_read_cb == NULL) {\n\t\tDUK_D(DUK_DPRINT(\"attempt to write flush in detached state, ignore\"));\n\t\treturn;\n\t}\n\tif (heap->dbg_write_flush_cb == NULL) {\n\t\tDUK_DD(DUK_DDPRINT(\"no write flush callback, ignore\"));\n\t\treturn;\n\t}\n\n\theap->dbg_write_flush_cb(heap->dbg_udata);\n}\n\n/*\n *  Debug connection skip primitives\n */\n\n/* Skip fully. */\nDUK_INTERNAL void duk_debug_skip_bytes(duk_hthread *thr, duk_size_t length) {\n\tduk_uint8_t dummy[64];\n\tduk_size_t now;\n\n\tDUK_ASSERT(thr != NULL);\n\n\twhile (length > 0) {\n\t\tnow = (length > sizeof(dummy) ? sizeof(dummy) : length);\n\t\tduk_debug_read_bytes(thr, dummy, now);\n\t\tlength -= now;\n\t}\n}\n\nDUK_INTERNAL void duk_debug_skip_byte(duk_hthread *thr) {\n\tDUK_ASSERT(thr != NULL);\n\n\t(void) duk_debug_read_byte(thr);\n}\n\n/*\n *  Debug connection read primitives\n */\n\n/* Peek ahead in the stream one byte. */\nDUK_INTERNAL uint8_t duk_debug_peek_byte(duk_hthread *thr) {\n\t/* It is important not to call this if the last byte read was an EOM.\n\t * Reading ahead in this scenario would cause unnecessary blocking if\n\t * another message is not available.\n\t */\n\n\tduk_uint8_t x;\n\n\tx = duk_debug_read_byte(thr);\n\tthr->heap->dbg_have_next_byte = 1;\n\tthr->heap->dbg_next_byte = x;\n\treturn x;\n}\n\n/* Read fully. */\nDUK_INTERNAL void duk_debug_read_bytes(duk_hthread *thr, duk_uint8_t *data, duk_size_t length) {\n\tduk_heap *heap;\n\tduk_uint8_t *p;\n\tduk_size_t left;\n\tduk_size_t got;\n\n\tDUK_ASSERT(thr != NULL);\n\theap = thr->heap;\n\tDUK_ASSERT(heap != NULL);\n\n\tif (heap->dbg_read_cb == NULL) {\n\t\tDUK_D(DUK_DPRINT(\"attempt to read %ld bytes in detached state, return zero data\", (long) length));\n\t\tgoto fail;\n\t}\n\n\t/* NOTE: length may be zero */\n\tp = data;\n\tif (length >= 1 && heap->dbg_have_next_byte) {\n\t\theap->dbg_have_next_byte = 0;\n\t\t*p++ = heap->dbg_next_byte;\n\t}\n\tfor (;;) {\n\t\tleft = (duk_size_t) ((data + length) - p);\n\t\tif (left == 0) {\n\t\t\tbreak;\n\t\t}\n\t\tDUK_ASSERT(heap->dbg_read_cb != NULL);\n\t\tDUK_ASSERT(left >= 1);\n#if defined(DUK_USE_DEBUGGER_TRANSPORT_TORTURE)\n\t\tleft = 1;\n#endif\n\t\tgot = heap->dbg_read_cb(heap->dbg_udata, (char *) p, left);\n\t\tif (got == 0 || got > left) {\n\t\t\tDUK_D(DUK_DPRINT(\"connection error during read, return zero data\"));\n\t\t\tduk__debug_null_most_callbacks(thr);  /* avoid calling write callback in detach1() */\n\t\t\tDUK__SET_CONN_BROKEN(thr, 1);\n\t\t\tgoto fail;\n\t\t}\n\t\tp += got;\n\t}\n\treturn;\n\n fail:\n\tDUK_MEMZERO((void *) data, (size_t) length);\n}\n\nDUK_INTERNAL duk_uint8_t duk_debug_read_byte(duk_hthread *thr) {\n\tduk_uint8_t x;\n\n\tx = 0;  /* just in case callback is broken and won't write 'x' */\n\tduk_debug_read_bytes(thr, &x, 1);\n\treturn x;\n}\n\nDUK_LOCAL duk_uint32_t duk__debug_read_uint32_raw(duk_hthread *thr) {\n\tduk_uint8_t buf[4];\n\n\tDUK_ASSERT(thr != NULL);\n\n\tduk_debug_read_bytes(thr, buf, 4);\n\treturn ((duk_uint32_t) buf[0] << 24) |\n\t       ((duk_uint32_t) buf[1] << 16) |\n\t       ((duk_uint32_t) buf[2] << 8) |\n\t       (duk_uint32_t) buf[3];\n}\n\nDUK_LOCAL duk_uint32_t duk__debug_read_int32_raw(duk_hthread *thr) {\n\treturn (duk_int32_t) duk__debug_read_uint32_raw(thr);\n}\n\nDUK_LOCAL duk_uint16_t duk__debug_read_uint16_raw(duk_hthread *thr) {\n\tduk_uint8_t buf[2];\n\n\tDUK_ASSERT(thr != NULL);\n\n\tduk_debug_read_bytes(thr, buf, 2);\n\treturn ((duk_uint16_t) buf[0] << 8) |\n\t       (duk_uint16_t) buf[1];\n}\n\nDUK_INTERNAL duk_int32_t duk_debug_read_int(duk_hthread *thr) {\n\tduk_small_uint_t x;\n\tduk_small_uint_t t;\n\n\tDUK_ASSERT(thr != NULL);\n\n\tx = duk_debug_read_byte(thr);\n\tif (x >= 0xc0) {\n\t\tt = duk_debug_read_byte(thr);\n\t\treturn (duk_int32_t) (((x - 0xc0) << 8) + t);\n\t} else if (x >= 0x80) {\n\t\treturn (duk_int32_t) (x - 0x80);\n\t} else if (x == DUK_DBG_IB_INT4) {\n\t\treturn (duk_int32_t) duk__debug_read_uint32_raw(thr);\n\t}\n\n\tDUK_D(DUK_DPRINT(\"debug connection error: failed to decode int\"));\n\tDUK__SET_CONN_BROKEN(thr, 1);\n\treturn 0;\n}\n\nDUK_LOCAL duk_hstring *duk__debug_read_hstring_raw(duk_hthread *thr, duk_uint32_t len) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_uint8_t buf[31];\n\tduk_uint8_t *p;\n\n\tif (len <= sizeof(buf)) {\n\t\tduk_debug_read_bytes(thr, buf, (duk_size_t) len);\n\t\tduk_push_lstring(ctx, (const char *) buf, (duk_size_t) len);\n\t} else {\n\t\tp = (duk_uint8_t *) duk_push_fixed_buffer(ctx, (duk_size_t) len);  /* zero for paranoia */\n\t\tDUK_ASSERT(p != NULL);\n\t\tduk_debug_read_bytes(thr, p, (duk_size_t) len);\n\t\t(void) duk_buffer_to_string(ctx, -1);  /* Safety relies on debug client, which is OK. */\n\t}\n\n\treturn duk_require_hstring(ctx, -1);\n}\n\nDUK_INTERNAL duk_hstring *duk_debug_read_hstring(duk_hthread *thr) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_small_uint_t x;\n\tduk_uint32_t len;\n\n\tDUK_ASSERT(thr != NULL);\n\n\tx = duk_debug_read_byte(thr);\n\tif (x >= 0x60 && x <= 0x7f) {\n\t\t/* For short strings, use a fixed temp buffer. */\n\t\tlen = (duk_uint32_t) (x - 0x60);\n\t} else if (x == DUK_DBG_IB_STR2) {\n\t\tlen = (duk_uint32_t) duk__debug_read_uint16_raw(thr);\n\t} else if (x == DUK_DBG_IB_STR4) {\n\t\tlen = (duk_uint32_t) duk__debug_read_uint32_raw(thr);\n\t} else {\n\t\tgoto fail;\n\t}\n\n\treturn duk__debug_read_hstring_raw(thr, len);\n\n fail:\n\tDUK_D(DUK_DPRINT(\"debug connection error: failed to decode int\"));\n\tDUK__SET_CONN_BROKEN(thr, 1);\n\tduk_push_hstring_empty(ctx);  /* always push some string */\n\treturn duk_require_hstring(ctx, -1);\n}\n\nDUK_LOCAL duk_hbuffer *duk__debug_read_hbuffer_raw(duk_hthread *thr, duk_uint32_t len) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_uint8_t *p;\n\n\tp = (duk_uint8_t *) duk_push_fixed_buffer(ctx, (duk_size_t) len);  /* zero for paranoia */\n\tDUK_ASSERT(p != NULL);\n\tduk_debug_read_bytes(thr, p, (duk_size_t) len);\n\n\treturn duk_require_hbuffer(ctx, -1);\n}\n\nDUK_LOCAL void *duk__debug_read_pointer_raw(duk_hthread *thr) {\n\tduk_small_uint_t x;\n\tduk__ptr_union pu;\n\n\tDUK_ASSERT(thr != NULL);\n\n\tx = duk_debug_read_byte(thr);\n\tif (x != sizeof(pu)) {\n\t\tgoto fail;\n\t}\n\tduk_debug_read_bytes(thr, (duk_uint8_t *) &pu.p, sizeof(pu));\n#if defined(DUK_USE_INTEGER_LE)\n\tduk_byteswap_bytes((duk_uint8_t *) pu.b, sizeof(pu));\n#endif\n\treturn (void *) pu.p;\n\n fail:\n\tDUK_D(DUK_DPRINT(\"debug connection error: failed to decode pointer\"));\n\tDUK__SET_CONN_BROKEN(thr, 1);\n\treturn (void *) NULL;\n}\n\nDUK_LOCAL duk_double_t duk__debug_read_double_raw(duk_hthread *thr) {\n\tduk_double_union du;\n\n\tDUK_ASSERT(sizeof(du.uc) == 8);\n\tduk_debug_read_bytes(thr, (duk_uint8_t *) du.uc, sizeof(du.uc));\n\tDUK_DBLUNION_DOUBLE_NTOH(&du);\n\treturn du.d;\n}\n\n#if 0\nDUK_INTERNAL duk_heaphdr *duk_debug_read_heapptr(duk_hthread *thr) {\n\tduk_small_uint_t x;\n\n\tDUK_ASSERT(thr != NULL);\n\n\tx = duk_debug_read_byte(thr);\n\tif (x != DUK_DBG_IB_HEAPPTR) {\n\t\tgoto fail;\n\t}\n\n\treturn (duk_heaphdr *) duk__debug_read_pointer_raw(thr);\n\n fail:\n\tDUK_D(DUK_DPRINT(\"debug connection error: failed to decode heapptr\"));\n\tDUK__SET_CONN_BROKEN(thr, 1);\n\treturn NULL;\n}\n#endif\n\nDUK_INTERNAL duk_heaphdr *duk_debug_read_any_ptr(duk_hthread *thr) {\n\tduk_small_uint_t x;\n\n\tDUK_ASSERT(thr != NULL);\n\n\tx = duk_debug_read_byte(thr);\n\tswitch (x) {\n\tcase DUK_DBG_IB_OBJECT:\n\tcase DUK_DBG_IB_POINTER:\n\tcase DUK_DBG_IB_HEAPPTR:\n\t\t/* Accept any pointer-like value; for 'object' dvalue, read\n\t\t * and ignore the class number.\n\t\t */\n\t\tif (x == DUK_DBG_IB_OBJECT) {\n\t\t\tduk_debug_skip_byte(thr);\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tgoto fail;\n\t}\n\n\treturn (duk_heaphdr *) duk__debug_read_pointer_raw(thr);\n\n fail:\n\tDUK_D(DUK_DPRINT(\"debug connection error: failed to decode any pointer (object, pointer, heapptr)\"));\n\tDUK__SET_CONN_BROKEN(thr, 1);\n\treturn NULL;\n}\n\nDUK_INTERNAL duk_tval *duk_debug_read_tval(duk_hthread *thr) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_uint8_t x;\n\tduk_uint_t t;\n\tduk_uint32_t len;\n\n\tDUK_ASSERT(thr != NULL);\n\n\tx = duk_debug_read_byte(thr);\n\n\tif (x >= 0xc0) {\n\t\tt = (duk_uint_t) (x - 0xc0);\n\t\tt = (t << 8) + duk_debug_read_byte(thr);\n\t\tduk_push_uint(ctx, (duk_uint_t) t);\n\t\tgoto return_ptr;\n\t}\n\tif (x >= 0x80) {\n\t\tduk_push_uint(ctx, (duk_uint_t) (x - 0x80));\n\t\tgoto return_ptr;\n\t}\n\tif (x >= 0x60) {\n\t\tlen = (duk_uint32_t) (x - 0x60);\n\t\tduk__debug_read_hstring_raw(thr, len);\n\t\tgoto return_ptr;\n\t}\n\n\tswitch (x) {\n\tcase DUK_DBG_IB_INT4: {\n\t\tduk_int32_t i = duk__debug_read_int32_raw(thr);\n\t\tduk_push_i32(ctx, i);\n\t\tbreak;\n\t}\n\tcase DUK_DBG_IB_STR4: {\n\t\tlen = duk__debug_read_uint32_raw(thr);\n\t\tduk__debug_read_hstring_raw(thr, len);\n\t\tbreak;\n\t}\n\tcase DUK_DBG_IB_STR2: {\n\t\tlen = duk__debug_read_uint16_raw(thr);\n\t\tduk__debug_read_hstring_raw(thr, len);\n\t\tbreak;\n\t}\n\tcase DUK_DBG_IB_BUF4: {\n\t\tlen = duk__debug_read_uint32_raw(thr);\n\t\tduk__debug_read_hbuffer_raw(thr, len);\n\t\tbreak;\n\t}\n\tcase DUK_DBG_IB_BUF2: {\n\t\tlen = duk__debug_read_uint16_raw(thr);\n\t\tduk__debug_read_hbuffer_raw(thr, len);\n\t\tbreak;\n\t}\n\tcase DUK_DBG_IB_UNDEFINED: {\n\t\tduk_push_undefined(ctx);\n\t\tbreak;\n\t}\n\tcase DUK_DBG_IB_NULL: {\n\t\tduk_push_null(ctx);\n\t\tbreak;\n\t}\n\tcase DUK_DBG_IB_TRUE: {\n\t\tduk_push_true(ctx);\n\t\tbreak;\n\t}\n\tcase DUK_DBG_IB_FALSE: {\n\t\tduk_push_false(ctx);\n\t\tbreak;\n\t}\n\tcase DUK_DBG_IB_NUMBER: {\n\t\tduk_double_t d;\n\t\td = duk__debug_read_double_raw(thr);\n\t\tduk_push_number(ctx, d);\n\t\tbreak;\n\t}\n\tcase DUK_DBG_IB_OBJECT: {\n\t\tduk_heaphdr *h;\n\t\tduk_debug_skip_byte(thr);\n\t\th = (duk_heaphdr *) duk__debug_read_pointer_raw(thr);\n\t\tduk_push_heapptr(thr, (void *) h);\n\t\tbreak;\n\t}\n\tcase DUK_DBG_IB_POINTER: {\n\t\tvoid *ptr;\n\t\tptr = duk__debug_read_pointer_raw(thr);\n\t\tduk_push_pointer(thr, ptr);\n\t\tbreak;\n\t}\n\tcase DUK_DBG_IB_LIGHTFUNC: {\n\t\t/* XXX: Not needed for now, so not implemented.  Note that\n\t\t * function pointers may have different size/layout than\n\t\t * a void pointer.\n\t\t */\n\t\tDUK_D(DUK_DPRINT(\"reading lightfunc values unimplemented\"));\n\t\tgoto fail;\n\t}\n\tcase DUK_DBG_IB_HEAPPTR: {\n\t\tduk_heaphdr *h;\n\t\th = (duk_heaphdr *) duk__debug_read_pointer_raw(thr);\n\t\tduk_push_heapptr(thr, (void *) h);\n\t\tbreak;\n\t}\n\tcase DUK_DBG_IB_UNUSED:  /* unused: not accepted in inbound messages */\n\tdefault:\n\t\tgoto fail;\n\t}\n\n return_ptr:\n\treturn DUK_GET_TVAL_NEGIDX(thr, -1);\n\n fail:\n\tDUK_D(DUK_DPRINT(\"debug connection error: failed to decode tval\"));\n\tDUK__SET_CONN_BROKEN(thr, 1);\n\treturn NULL;\n}\n\n/*\n *  Debug connection write primitives\n */\n\n/* Write fully. */\nDUK_INTERNAL void duk_debug_write_bytes(duk_hthread *thr, const duk_uint8_t *data, duk_size_t length) {\n\tduk_heap *heap;\n\tconst duk_uint8_t *p;\n\tduk_size_t left;\n\tduk_size_t got;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(length == 0 || data != NULL);\n\theap = thr->heap;\n\tDUK_ASSERT(heap != NULL);\n\n\tif (heap->dbg_write_cb == NULL) {\n\t\tDUK_D(DUK_DPRINT(\"attempt to write %ld bytes in detached state, ignore\", (long) length));\n\t\treturn;\n\t}\n\tif (length == 0) {\n\t\t/* Avoid doing an actual write callback with length == 0,\n\t\t * because that's reserved for a write flush.\n\t\t */\n\t\treturn;\n\t}\n\tDUK_ASSERT(data != NULL);\n\n\tp = data;\n\tfor (;;) {\n\t\tleft = (duk_size_t) ((data + length) - p);\n\t\tif (left == 0) {\n\t\t\tbreak;\n\t\t}\n\t\tDUK_ASSERT(heap->dbg_write_cb != NULL);\n\t\tDUK_ASSERT(left >= 1);\n#if defined(DUK_USE_DEBUGGER_TRANSPORT_TORTURE)\n\t\tleft = 1;\n#endif\n\t\tgot = heap->dbg_write_cb(heap->dbg_udata, (const char *) p, left);\n\t\tif (got == 0 || got > left) {\n\t\t\tduk__debug_null_most_callbacks(thr);  /* avoid calling write callback in detach1() */\n\t\t\tDUK_D(DUK_DPRINT(\"connection error during write\"));\n\t\t\tDUK__SET_CONN_BROKEN(thr, 1);\n\t\t\treturn;\n\t\t}\n\t\tp += got;\n\t}\n}\n\nDUK_INTERNAL void duk_debug_write_byte(duk_hthread *thr, duk_uint8_t x) {\n\tduk_debug_write_bytes(thr, (const duk_uint8_t *) &x, 1);\n}\n\nDUK_INTERNAL void duk_debug_write_unused(duk_hthread *thr) {\n\tduk_debug_write_byte(thr, DUK_DBG_IB_UNUSED);\n}\n\nDUK_INTERNAL void duk_debug_write_undefined(duk_hthread *thr) {\n\tduk_debug_write_byte(thr, DUK_DBG_IB_UNDEFINED);\n}\n\n#if defined(DUK_USE_DEBUGGER_INSPECT)\nDUK_INTERNAL void duk_debug_write_null(duk_hthread *thr) {\n\tduk_debug_write_byte(thr, DUK_DBG_IB_NULL);\n}\n#endif\n\nDUK_INTERNAL void duk_debug_write_boolean(duk_hthread *thr, duk_uint_t val) {\n\tduk_debug_write_byte(thr, val ? DUK_DBG_IB_TRUE : DUK_DBG_IB_FALSE);\n}\n\n/* Write signed 32-bit integer. */\nDUK_INTERNAL void duk_debug_write_int(duk_hthread *thr, duk_int32_t x) {\n\tduk_uint8_t buf[5];\n\tduk_size_t len;\n\n\tDUK_ASSERT(thr != NULL);\n\n\tif (x >= 0 && x <= 0x3fL) {\n\t\tbuf[0] = (duk_uint8_t) (0x80 + x);\n\t\tlen = 1;\n\t} else if (x >= 0 && x <= 0x3fffL) {\n\t\tbuf[0] = (duk_uint8_t) (0xc0 + (x >> 8));\n\t\tbuf[1] = (duk_uint8_t) (x & 0xff);\n\t\tlen = 2;\n\t} else {\n\t\t/* Signed integers always map to 4 bytes now. */\n\t\tbuf[0] = (duk_uint8_t) DUK_DBG_IB_INT4;\n\t\tbuf[1] = (duk_uint8_t) ((x >> 24) & 0xff);\n\t\tbuf[2] = (duk_uint8_t) ((x >> 16) & 0xff);\n\t\tbuf[3] = (duk_uint8_t) ((x >> 8) & 0xff);\n\t\tbuf[4] = (duk_uint8_t) (x & 0xff);\n\t\tlen = 5;\n\t}\n\tduk_debug_write_bytes(thr, buf, len);\n}\n\n/* Write unsigned 32-bit integer. */\nDUK_INTERNAL void duk_debug_write_uint(duk_hthread *thr, duk_uint32_t x) {\n\t/* The debugger protocol doesn't support a plain integer encoding for\n\t * the full 32-bit unsigned range (only 32-bit signed).  For now,\n\t * unsigned 32-bit values simply written as signed ones.  This is not\n\t * a concrete issue except for 32-bit heaphdr fields.  Proper solutions\n\t * would be to (a) write such integers as IEEE doubles or (b) add an\n\t * unsigned 32-bit dvalue.\n\t */\n\tif (x >= 0x80000000UL) {\n\t\tDUK_D(DUK_DPRINT(\"writing unsigned integer 0x%08lx as signed integer\",\n\t\t                 (long) x));\n\t}\n\tduk_debug_write_int(thr, (duk_int32_t) x);\n}\n\nDUK_INTERNAL void duk_debug_write_strbuf(duk_hthread *thr, const char *data, duk_size_t length, duk_uint8_t marker_base) {\n\tduk_uint8_t buf[5];\n\tduk_size_t buflen;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(length == 0 || data != NULL);\n\n\tif (length <= 0x1fUL && marker_base == DUK_DBG_IB_STR4) {\n\t\t/* For strings, special form for short lengths. */\n\t\tbuf[0] = (duk_uint8_t) (0x60 + length);\n\t\tbuflen = 1;\n\t} else if (length <= 0xffffUL) {\n\t\tbuf[0] = (duk_uint8_t) (marker_base + 1);\n\t\tbuf[1] = (duk_uint8_t) (length >> 8);\n\t\tbuf[2] = (duk_uint8_t) (length & 0xff);\n\t\tbuflen = 3;\n\t} else {\n\t\tbuf[0] = (duk_uint8_t) marker_base;\n\t\tbuf[1] = (duk_uint8_t) (length >> 24);\n\t\tbuf[2] = (duk_uint8_t) ((length >> 16) & 0xff);\n\t\tbuf[3] = (duk_uint8_t) ((length >> 8) & 0xff);\n\t\tbuf[4] = (duk_uint8_t) (length & 0xff);\n\t\tbuflen = 5;\n\t}\n\n\tduk_debug_write_bytes(thr, (const duk_uint8_t *) buf, buflen);\n\tduk_debug_write_bytes(thr, (const duk_uint8_t *) data, length);\n}\n\nDUK_INTERNAL void duk_debug_write_string(duk_hthread *thr, const char *data, duk_size_t length) {\n\tduk_debug_write_strbuf(thr, data, length, DUK_DBG_IB_STR4);\n}\n\nDUK_INTERNAL void duk_debug_write_cstring(duk_hthread *thr, const char *data) {\n\tDUK_ASSERT(thr != NULL);\n\n\tduk_debug_write_string(thr,\n\t                       data,\n\t                       data ? DUK_STRLEN(data) : 0);\n}\n\nDUK_INTERNAL void duk_debug_write_hstring(duk_hthread *thr, duk_hstring *h) {\n\tDUK_ASSERT(thr != NULL);\n\n\t/* XXX: differentiate null pointer from empty string? */\n\tduk_debug_write_string(thr,\n\t                       (h != NULL ? (const char *) DUK_HSTRING_GET_DATA(h) : NULL),\n\t                       (h != NULL ? (duk_size_t) DUK_HSTRING_GET_BYTELEN(h) : 0));\n}\n\nDUK_LOCAL void duk__debug_write_hstring_safe_top(duk_hthread *thr) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_debug_write_hstring(thr, duk_safe_to_hstring(ctx, -1));\n}\n\nDUK_INTERNAL void duk_debug_write_buffer(duk_hthread *thr, const char *data, duk_size_t length) {\n\tduk_debug_write_strbuf(thr, data, length, DUK_DBG_IB_BUF4);\n}\n\nDUK_INTERNAL void duk_debug_write_hbuffer(duk_hthread *thr, duk_hbuffer *h) {\n\tDUK_ASSERT(thr != NULL);\n\n\tduk_debug_write_buffer(thr,\n\t                       (h != NULL ? (const char *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h) : NULL),\n\t                       (h != NULL ? (duk_size_t) DUK_HBUFFER_GET_SIZE(h) : 0));\n}\n\nDUK_LOCAL void duk__debug_write_pointer_raw(duk_hthread *thr, void *ptr, duk_uint8_t ibyte) {\n\tduk_uint8_t buf[2];\n\tduk__ptr_union pu;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(sizeof(ptr) >= 1 && sizeof(ptr) <= 16);\n\t/* ptr may be NULL */\n\n\tbuf[0] = ibyte;\n\tbuf[1] = sizeof(pu);\n\tduk_debug_write_bytes(thr, buf, 2);\n\tpu.p = (void *) ptr;\n#if defined(DUK_USE_INTEGER_LE)\n\tduk_byteswap_bytes((duk_uint8_t *) pu.b, sizeof(pu));\n#endif\n\tduk_debug_write_bytes(thr, (const duk_uint8_t *) &pu.p, (duk_size_t) sizeof(pu));\n}\n\nDUK_INTERNAL void duk_debug_write_pointer(duk_hthread *thr, void *ptr) {\n\tduk__debug_write_pointer_raw(thr, ptr, DUK_DBG_IB_POINTER);\n}\n\n#if defined(DUK_USE_DEBUGGER_DUMPHEAP) || defined(DUK_USE_DEBUGGER_INSPECT)\nDUK_INTERNAL void duk_debug_write_heapptr(duk_hthread *thr, duk_heaphdr *h) {\n\tduk__debug_write_pointer_raw(thr, (void *) h, DUK_DBG_IB_HEAPPTR);\n}\n#endif  /* DUK_USE_DEBUGGER_DUMPHEAP || DUK_USE_DEBUGGER_INSPECT */\n\nDUK_INTERNAL void duk_debug_write_hobject(duk_hthread *thr, duk_hobject *obj) {\n\tduk_uint8_t buf[3];\n\tduk__ptr_union pu;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(sizeof(obj) >= 1 && sizeof(obj) <= 16);\n\tDUK_ASSERT(obj != NULL);\n\n\tbuf[0] = DUK_DBG_IB_OBJECT;\n\tbuf[1] = (duk_uint8_t) DUK_HOBJECT_GET_CLASS_NUMBER(obj);\n\tbuf[2] = sizeof(pu);\n\tduk_debug_write_bytes(thr, buf, 3);\n\tpu.p = (void *) obj;\n#if defined(DUK_USE_INTEGER_LE)\n\tduk_byteswap_bytes((duk_uint8_t *) pu.b, sizeof(pu));\n#endif\n\tduk_debug_write_bytes(thr, (const duk_uint8_t *) &pu.p, (duk_size_t) sizeof(pu));\n}\n\nDUK_INTERNAL void duk_debug_write_tval(duk_hthread *thr, duk_tval *tv) {\n\tduk_c_function lf_func;\n\tduk_small_uint_t lf_flags;\n\tduk_uint8_t buf[4];\n\tduk_double_union du1;\n\tduk_double_union du2;\n\tduk_int32_t i32;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(tv != NULL);\n\n\tswitch (DUK_TVAL_GET_TAG(tv)) {\n\tcase DUK_TAG_UNDEFINED:\n\t\tduk_debug_write_byte(thr, DUK_DBG_IB_UNDEFINED);\n\t\tbreak;\n\tcase DUK_TAG_UNUSED:\n\t\tduk_debug_write_byte(thr, DUK_DBG_IB_UNUSED);\n\t\tbreak;\n\tcase DUK_TAG_NULL:\n\t\tduk_debug_write_byte(thr, DUK_DBG_IB_NULL);\n\t\tbreak;\n\tcase DUK_TAG_BOOLEAN:\n\t\tDUK_ASSERT(DUK_TVAL_GET_BOOLEAN(tv) == 0 ||\n\t\t           DUK_TVAL_GET_BOOLEAN(tv) == 1);\n\t\tduk_debug_write_boolean(thr, DUK_TVAL_GET_BOOLEAN(tv));\n\t\tbreak;\n\tcase DUK_TAG_POINTER:\n\t\tduk_debug_write_pointer(thr, (void *) DUK_TVAL_GET_POINTER(tv));\n\t\tbreak;\n\tcase DUK_TAG_LIGHTFUNC:\n\t\tDUK_TVAL_GET_LIGHTFUNC(tv, lf_func, lf_flags);\n\t\tbuf[0] = DUK_DBG_IB_LIGHTFUNC;\n\t\tbuf[1] = (duk_uint8_t) (lf_flags >> 8);\n\t\tbuf[2] = (duk_uint8_t) (lf_flags & 0xff);\n\t\tbuf[3] = sizeof(lf_func);\n\t\tduk_debug_write_bytes(thr, buf, 4);\n\t\tduk_debug_write_bytes(thr, (const duk_uint8_t *) &lf_func, sizeof(lf_func));\n\t\tbreak;\n\tcase DUK_TAG_STRING:\n\t\tduk_debug_write_hstring(thr, DUK_TVAL_GET_STRING(tv));\n\t\tbreak;\n\tcase DUK_TAG_OBJECT:\n\t\tduk_debug_write_hobject(thr, DUK_TVAL_GET_OBJECT(tv));\n\t\tbreak;\n\tcase DUK_TAG_BUFFER:\n\t\tduk_debug_write_hbuffer(thr, DUK_TVAL_GET_BUFFER(tv));\n\t\tbreak;\n#if defined(DUK_USE_FASTINT)\n\tcase DUK_TAG_FASTINT:\n#endif\n\tdefault:\n\t\t/* Numbers are normalized to big (network) endian.  We can\n\t\t * (but are not required) to use integer dvalues when there's\n\t\t * no loss of precision.\n\t\t *\n\t\t * XXX: share check with other code; this check is slow but\n\t\t * reliable and doesn't require careful exponent/mantissa\n\t\t * mask tricks as in the fastint downgrade code.\n\t\t */\n\t\tDUK_ASSERT(!DUK_TVAL_IS_UNUSED(tv));\n\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv));\n\t\tdu1.d = DUK_TVAL_GET_NUMBER(tv);\n\t\ti32 = (duk_int32_t) du1.d;\n\t\tdu2.d = (duk_double_t) i32;\n\n\t\tDUK_DD(DUK_DDPRINT(\"i32=%ld du1=%02x%02x%02x%02x%02x%02x%02x%02x \"\n\t\t                   \"du2=%02x%02x%02x%02x%02x%02x%02x%02x\",\n\t\t                   (long) i32,\n\t\t                   (unsigned int) du1.uc[0], (unsigned int) du1.uc[1],\n\t\t                   (unsigned int) du1.uc[2], (unsigned int) du1.uc[3],\n\t\t                   (unsigned int) du1.uc[4], (unsigned int) du1.uc[5],\n\t\t                   (unsigned int) du1.uc[6], (unsigned int) du1.uc[7],\n\t\t                   (unsigned int) du2.uc[0], (unsigned int) du2.uc[1],\n\t\t                   (unsigned int) du2.uc[2], (unsigned int) du2.uc[3],\n\t\t                   (unsigned int) du2.uc[4], (unsigned int) du2.uc[5],\n\t\t                   (unsigned int) du2.uc[6], (unsigned int) du2.uc[7]));\n\n\t\tif (DUK_MEMCMP((const void *) du1.uc, (const void *) du2.uc, sizeof(du1.uc)) == 0) {\n\t\t\tduk_debug_write_int(thr, i32);\n\t\t} else {\n\t\t\tDUK_DBLUNION_DOUBLE_HTON(&du1);\n\t\t\tduk_debug_write_byte(thr, DUK_DBG_IB_NUMBER);\n\t\t\tduk_debug_write_bytes(thr, (const duk_uint8_t *) du1.uc, sizeof(du1.uc));\n\t\t}\n\t}\n}\n\n#if defined(DUK_USE_DEBUGGER_DUMPHEAP)\n/* Variant for writing duk_tvals so that any heap allocated values are\n * written out as tagged heap pointers.\n */\nDUK_LOCAL void duk__debug_write_tval_heapptr(duk_hthread *thr, duk_tval *tv) {\n\tif (DUK_TVAL_IS_HEAP_ALLOCATED(tv)) {\n\t\tduk_heaphdr *h = DUK_TVAL_GET_HEAPHDR(tv);\n\t\tduk_debug_write_heapptr(thr, h);\n\t} else {\n\t\tduk_debug_write_tval(thr, tv);\n\t}\n}\n#endif  /* DUK_USE_DEBUGGER_DUMPHEAP */\n\n/*\n *  Debug connection message write helpers\n */\n\n#if 0  /* unused */\nDUK_INTERNAL void duk_debug_write_request(duk_hthread *thr, duk_small_uint_t command) {\n\tduk_debug_write_byte(thr, DUK_DBG_IB_REQUEST);\n\tduk_debug_write_int(thr, command);\n}\n#endif\n\nDUK_INTERNAL void duk_debug_write_reply(duk_hthread *thr) {\n\tduk_debug_write_byte(thr, DUK_DBG_IB_REPLY);\n}\n\nDUK_INTERNAL void duk_debug_write_error_eom(duk_hthread *thr, duk_small_uint_t err_code, const char *msg) {\n\t/* Allow NULL 'msg' */\n\tduk_debug_write_byte(thr, DUK_DBG_IB_ERROR);\n\tduk_debug_write_int(thr, (duk_int32_t) err_code);\n\tduk_debug_write_cstring(thr, msg);\n\tduk_debug_write_eom(thr);\n}\n\nDUK_INTERNAL void duk_debug_write_notify(duk_hthread *thr, duk_small_uint_t command) {\n\tduk_debug_write_byte(thr, DUK_DBG_IB_NOTIFY);\n\tduk_debug_write_int(thr, command);\n}\n\nDUK_INTERNAL void duk_debug_write_eom(duk_hthread *thr) {\n\tduk_debug_write_byte(thr, DUK_DBG_IB_EOM);\n\n\t/* As an initial implementation, write flush after every EOM (and the\n\t * version identifier).  A better implementation would flush only when\n\t * Duktape is finished processing messages so that a flush only happens\n\t * after all outbound messages are finished on that occasion.\n\t */\n\tduk_debug_write_flush(thr);\n}\n\n/*\n *  Status message and helpers\n */\n\nDUK_INTERNAL duk_uint_fast32_t duk_debug_curr_line(duk_hthread *thr) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_activation *act;\n\tduk_uint_fast32_t line;\n\tduk_uint_fast32_t pc;\n\n\tact = thr->callstack_curr;\n\tif (act == NULL) {\n\t\treturn 0;\n\t}\n\n\t/* We're conceptually between two opcodes; act->pc indicates the next\n\t * instruction to be executed.  This is usually the correct pc/line to\n\t * indicate in Status.  (For the 'debugger' statement this now reports\n\t * the pc/line after the debugger statement because the debugger opcode\n\t * has already been executed.)\n\t */\n\n\tpc = duk_hthread_get_act_curr_pc(thr, act);\n\n\t/* XXX: this should be optimized to be a raw query and avoid valstack\n\t * operations if possible.\n\t */\n\tduk_push_tval(ctx, &act->tv_func);\n\tline = duk_hobject_pc2line_query(ctx, -1, pc);\n\tduk_pop(ctx);\n\treturn line;\n}\n\nDUK_INTERNAL void duk_debug_send_status(duk_hthread *thr) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_activation *act;\n\n\tduk_debug_write_notify(thr, DUK_DBG_CMD_STATUS);\n\tduk_debug_write_int(thr, (DUK_HEAP_HAS_DEBUGGER_PAUSED(thr->heap) ? 1 : 0));\n\n\tDUK_ASSERT_DISABLE(thr->callstack_top >= 0);  /* unsigned */\n\tact = thr->callstack_curr;\n\tif (act == NULL) {\n\t\tduk_debug_write_undefined(thr);\n\t\tduk_debug_write_undefined(thr);\n\t\tduk_debug_write_int(thr, 0);\n\t\tduk_debug_write_int(thr, 0);\n\t} else {\n\t\tduk_push_tval(ctx, &act->tv_func);\n\t\tduk_get_prop_string(ctx, -1, \"fileName\");\n\t\tduk__debug_write_hstring_safe_top(thr);\n\t\tduk_get_prop_string(ctx, -2, \"name\");\n\t\tduk__debug_write_hstring_safe_top(thr);\n\t\tduk_pop_3(ctx);\n\t\t/* Report next pc/line to be executed. */\n\t\tduk_debug_write_uint(thr, (duk_uint32_t) duk_debug_curr_line(thr));\n\t\tact = thr->callstack_curr;\n\t\tduk_debug_write_uint(thr, (duk_uint32_t) duk_hthread_get_act_curr_pc(thr, act));\n\t}\n\n\tduk_debug_write_eom(thr);\n}\n\n#if defined(DUK_USE_DEBUGGER_THROW_NOTIFY)\nDUK_INTERNAL void duk_debug_send_throw(duk_hthread *thr, duk_bool_t fatal) {\n\t/*\n\t *  NFY <int: 5> <int: fatal> <str: msg> <str: filename> <int: linenumber> EOM\n\t */\n\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_activation *act;\n\tduk_uint32_t pc;\n\n\tDUK_ASSERT(thr->valstack_top > thr->valstack);  /* At least: ... [err] */\n\n\tduk_debug_write_notify(thr, DUK_DBG_CMD_THROW);\n\tduk_debug_write_int(thr, fatal);\n\n\t/* Report thrown value to client coerced to string */\n\tduk_dup_top(ctx);\n\tduk__debug_write_hstring_safe_top(thr);\n\tduk_pop(ctx);\n\n\tif (duk_is_error(ctx, -1)) {\n\t\t/* Error instance, use augmented error data directly */\n\t\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_FILE_NAME);\n\t\tduk__debug_write_hstring_safe_top(thr);\n\t\tduk_get_prop_stridx_short(ctx, -2, DUK_STRIDX_LINE_NUMBER);\n\t\tduk_debug_write_uint(thr, duk_get_uint(ctx, -1));\n\t\tduk_pop_2(ctx);\n\t} else {\n\t\t/* For anything other than an Error instance, we calculate the\n\t\t * error location directly from the current activation if one\n\t\t * exists.\n\t\t */\n\t\tact = thr->callstack_curr;\n\t\tif (act != NULL) {\n\t\t\tduk_push_tval(ctx, &act->tv_func);\n\t\t\tduk_get_prop_string(ctx, -1, \"fileName\");\n\t\t\tduk__debug_write_hstring_safe_top(thr);\n\t\t\tact = thr->callstack_curr;\n\t\t\tpc = duk_hthread_get_act_prev_pc(thr, act);\n\t\t\tduk_debug_write_uint(thr, (duk_uint32_t) duk_hobject_pc2line_query(ctx, -2, pc));\n\t\t\tduk_pop_2(ctx);\n\t\t} else {\n\t\t\t/* Can happen if duk_throw() is called on an empty\n\t\t\t * callstack.\n\t\t\t */\n\t\t\tduk_debug_write_cstring(thr, \"\");\n\t\t\tduk_debug_write_uint(thr, 0);\n\t\t}\n\t}\n\n\tduk_debug_write_eom(thr);\n}\n#endif  /* DUK_USE_DEBUGGER_THROW_NOTIFY */\n\n/*\n *  Debug message processing\n */\n\n/* Skip dvalue. */\nDUK_LOCAL duk_bool_t duk__debug_skip_dvalue(duk_hthread *thr) {\n\tduk_uint8_t x;\n\tduk_uint32_t len;\n\n\tx = duk_debug_read_byte(thr);\n\n\tif (x >= 0xc0) {\n\t\tduk_debug_skip_byte(thr);\n\t\treturn 0;\n\t}\n\tif (x >= 0x80) {\n\t\treturn 0;\n\t}\n\tif (x >= 0x60) {\n\t\tduk_debug_skip_bytes(thr, x - 0x60);\n\t\treturn 0;\n\t}\n\tswitch(x) {\n\tcase DUK_DBG_IB_EOM:\n\t\treturn 1;  /* Return 1: got EOM */\n\tcase DUK_DBG_IB_REQUEST:\n\tcase DUK_DBG_IB_REPLY:\n\tcase DUK_DBG_IB_ERROR:\n\tcase DUK_DBG_IB_NOTIFY:\n\t\tbreak;\n\tcase DUK_DBG_IB_INT4:\n\t\t(void) duk__debug_read_uint32_raw(thr);\n\t\tbreak;\n\tcase DUK_DBG_IB_STR4:\n\tcase DUK_DBG_IB_BUF4:\n\t\tlen = duk__debug_read_uint32_raw(thr);\n\t\tduk_debug_skip_bytes(thr, len);\n\t\tbreak;\n\tcase DUK_DBG_IB_STR2:\n\tcase DUK_DBG_IB_BUF2:\n\t\tlen = duk__debug_read_uint16_raw(thr);\n\t\tduk_debug_skip_bytes(thr, len);\n\t\tbreak;\n\tcase DUK_DBG_IB_UNUSED:\n\tcase DUK_DBG_IB_UNDEFINED:\n\tcase DUK_DBG_IB_NULL:\n\tcase DUK_DBG_IB_TRUE:\n\tcase DUK_DBG_IB_FALSE:\n\t\tbreak;\n\tcase DUK_DBG_IB_NUMBER:\n\t\tduk_debug_skip_bytes(thr, 8);\n\t\tbreak;\n\tcase DUK_DBG_IB_OBJECT:\n\t\tduk_debug_skip_byte(thr);\n\t\tlen = duk_debug_read_byte(thr);\n\t\tduk_debug_skip_bytes(thr, len);\n\t\tbreak;\n\tcase DUK_DBG_IB_POINTER:\n\tcase DUK_DBG_IB_HEAPPTR:\n\t\tlen = duk_debug_read_byte(thr);\n\t\tduk_debug_skip_bytes(thr, len);\n\t\tbreak;\n\tcase DUK_DBG_IB_LIGHTFUNC:\n\t\tduk_debug_skip_bytes(thr, 2);\n\t\tlen = duk_debug_read_byte(thr);\n\t\tduk_debug_skip_bytes(thr, len);\n\t\tbreak;\n\tdefault:\n\t\tgoto fail;\n\t}\n\n\treturn 0;\n\n fail:\n\tDUK__SET_CONN_BROKEN(thr, 1);\n\treturn 1;  /* Pretend like we got EOM */\n}\n\n/* Skip dvalues to EOM. */\nDUK_LOCAL void duk__debug_skip_to_eom(duk_hthread *thr) {\n\tfor (;;) {\n\t\tif (duk__debug_skip_dvalue(thr)) {\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\nDUK_LOCAL duk_int32_t duk__debug_read_validate_csindex(duk_hthread *thr) {\n\tduk_int32_t level;\n\tlevel = duk_debug_read_int(thr);\n\tif (level >= 0 || -level > (duk_int32_t) thr->callstack_top) {\n\t\tduk_debug_write_error_eom(thr, DUK_DBG_ERR_NOTFOUND, \"invalid callstack index\");\n\t\treturn 0;  /* zero indicates failure */\n\t}\n\treturn level;\n}\n\n/*\n *  Simple commands\n */\n\nDUK_LOCAL void duk__debug_handle_basic_info(duk_hthread *thr, duk_heap *heap) {\n\tDUK_UNREF(heap);\n\tDUK_D(DUK_DPRINT(\"debug command Version\"));\n\n\tduk_debug_write_reply(thr);\n\tduk_debug_write_int(thr, DUK_VERSION);\n\tduk_debug_write_cstring(thr, DUK_GIT_DESCRIBE);\n\tduk_debug_write_cstring(thr, DUK_USE_TARGET_INFO);\n#if defined(DUK_USE_DOUBLE_LE)\n\tduk_debug_write_int(thr, 1);\n#elif defined(DUK_USE_DOUBLE_ME)\n\tduk_debug_write_int(thr, 2);\n#elif defined(DUK_USE_DOUBLE_BE)\n\tduk_debug_write_int(thr, 3);\n#else\n\tduk_debug_write_int(thr, 0);\n#endif\n\tduk_debug_write_int(thr, (duk_int_t) sizeof(void *));\n\tduk_debug_write_eom(thr);\n}\n\nDUK_LOCAL void duk__debug_handle_trigger_status(duk_hthread *thr, duk_heap *heap) {\n\tDUK_UNREF(heap);\n\tDUK_D(DUK_DPRINT(\"debug command TriggerStatus\"));\n\n\tduk_debug_write_reply(thr);\n\tduk_debug_write_eom(thr);\n\theap->dbg_state_dirty = 1;\n}\n\nDUK_LOCAL void duk__debug_handle_pause(duk_hthread *thr, duk_heap *heap) {\n\tDUK_D(DUK_DPRINT(\"debug command Pause\"));\n\n\tif (duk_debug_is_paused(heap)) {\n\t\tDUK_D(DUK_DPRINT(\"Pause requested when already paused, ignore\"));\n\t} else {\n\t\tduk_debug_set_paused(heap);\n\t}\n\tduk_debug_write_reply(thr);\n\tduk_debug_write_eom(thr);\n}\n\nDUK_LOCAL void duk__debug_handle_resume(duk_hthread *thr, duk_heap *heap) {\n\tDUK_D(DUK_DPRINT(\"debug command Resume\"));\n\n\tduk_debug_clear_paused(heap);\n\tduk_debug_write_reply(thr);\n\tduk_debug_write_eom(thr);\n}\n\nDUK_LOCAL void duk__debug_handle_step(duk_hthread *thr, duk_heap *heap, duk_int32_t cmd) {\n\tduk_small_uint_t step_type;\n\tduk_uint_fast32_t line;\n\n\tDUK_D(DUK_DPRINT(\"debug command StepInto/StepOver/StepOut: %d\", (int) cmd));\n\n\tif (cmd == DUK_DBG_CMD_STEPINTO) {\n\t\tstep_type = DUK_STEP_TYPE_INTO;\n\t} else if (cmd == DUK_DBG_CMD_STEPOVER) {\n\t\tstep_type = DUK_STEP_TYPE_OVER;\n\t} else {\n\t\tDUK_ASSERT(cmd == DUK_DBG_CMD_STEPOUT);\n\t\tstep_type = DUK_STEP_TYPE_OUT;\n\t}\n\n\tline = duk_debug_curr_line(thr);\n\tif (line > 0) {\n\t\tduk_debug_clear_paused(heap);  /* XXX: overlap with fields below; separate macro/helper? */\n\t\theap->dbg_step_type = step_type;\n\t\theap->dbg_step_thread = thr;\n\t\theap->dbg_step_csindex = thr->callstack_top - 1;\n\t\theap->dbg_step_startline = line;\n\t\theap->dbg_state_dirty = 1;\n\t} else {\n\t\tDUK_D(DUK_DPRINT(\"cannot determine current line, stepinto/stepover/stepout ignored\"));\n\t}\n\tduk_debug_write_reply(thr);\n\tduk_debug_write_eom(thr);\n}\n\nDUK_LOCAL void duk__debug_handle_list_break(duk_hthread *thr, duk_heap *heap) {\n\tduk_small_int_t i;\n\n\tDUK_D(DUK_DPRINT(\"debug command ListBreak\"));\n\tduk_debug_write_reply(thr);\n\tfor (i = 0; i < (duk_small_int_t) heap->dbg_breakpoint_count; i++) {\n\t\tduk_debug_write_hstring(thr, heap->dbg_breakpoints[i].filename);\n\t\tduk_debug_write_uint(thr, (duk_uint32_t) heap->dbg_breakpoints[i].line);\n\t}\n\tduk_debug_write_eom(thr);\n}\n\nDUK_LOCAL void duk__debug_handle_add_break(duk_hthread *thr, duk_heap *heap) {\n\tduk_hstring *filename;\n\tduk_uint32_t linenumber;\n\tduk_small_int_t idx;\n\n\tDUK_UNREF(heap);\n\n\tfilename = duk_debug_read_hstring(thr);\n\tlinenumber = (duk_uint32_t) duk_debug_read_int(thr);\n\tDUK_D(DUK_DPRINT(\"debug command AddBreak: %!O:%ld\", (duk_hobject *) filename, (long) linenumber));\n\tidx = duk_debug_add_breakpoint(thr, filename, linenumber);\n\tif (idx >= 0) {\n\t\tduk_debug_write_reply(thr);\n\t\tduk_debug_write_int(thr, (duk_int32_t) idx);\n\t\tduk_debug_write_eom(thr);\n\t} else {\n\t\tduk_debug_write_error_eom(thr, DUK_DBG_ERR_TOOMANY, \"no space for breakpoint\");\n\t}\n}\n\nDUK_LOCAL void duk__debug_handle_del_break(duk_hthread *thr, duk_heap *heap) {\n\tduk_small_uint_t idx;\n\n\tDUK_UNREF(heap);\n\n\tDUK_D(DUK_DPRINT(\"debug command DelBreak\"));\n\tidx = (duk_small_uint_t) duk_debug_read_int(thr);\n\tif (duk_debug_remove_breakpoint(thr, idx)) {\n\t\tduk_debug_write_reply(thr);\n\t\tduk_debug_write_eom(thr);\n\t} else {\n\t\tduk_debug_write_error_eom(thr, DUK_DBG_ERR_NOTFOUND, \"invalid breakpoint index\");\n\t}\n}\n\nDUK_LOCAL void duk__debug_handle_get_var(duk_hthread *thr, duk_heap *heap) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hstring *str;\n\tduk_bool_t rc;\n\tduk_int32_t level;\n\n\tDUK_UNREF(heap);\n\tDUK_D(DUK_DPRINT(\"debug command GetVar\"));\n\n\tlevel = duk__debug_read_validate_csindex(thr);\n\tif (level == 0) {\n\t\treturn;\n\t}\n\tstr = duk_debug_read_hstring(thr);  /* push to stack */\n\tDUK_ASSERT(str != NULL);\n\n\tif (thr->callstack_top > 0) {\n\t\trc = duk_js_getvar_activation(thr,\n\t\t                              thr->callstack + thr->callstack_top + level,\n\t\t                              str,\n\t\t                              0);\n\t} else {\n\t\t/* No activation, no variable access.  Could also pretend\n\t\t * we're in the global program context and read stuff off\n\t\t * the global object.\n\t\t */\n\t\tDUK_D(DUK_DPRINT(\"callstack empty, no activation -> ignore getvar\"));\n\t\trc = 0;\n\t}\n\n\tduk_debug_write_reply(thr);\n\tif (rc) {\n\t\tduk_debug_write_int(thr, 1);\n\t\tDUK_ASSERT(duk_get_tval(ctx, -2) != NULL);\n\t\tduk_debug_write_tval(thr, duk_get_tval(ctx, -2));\n\t} else {\n\t\tduk_debug_write_int(thr, 0);\n\t\tduk_debug_write_unused(thr);\n\t}\n\tduk_debug_write_eom(thr);\n}\n\nDUK_LOCAL void duk__debug_handle_put_var(duk_hthread *thr, duk_heap *heap) {\n\tduk_hstring *str;\n\tduk_tval *tv;\n\tduk_int32_t level;\n\n\tDUK_UNREF(heap);\n\tDUK_D(DUK_DPRINT(\"debug command PutVar\"));\n\n\tlevel = duk__debug_read_validate_csindex(thr);\n\tif (level == 0) {\n\t\treturn;\n\t}\n\tstr = duk_debug_read_hstring(thr);  /* push to stack */\n\tDUK_ASSERT(str != NULL);\n\ttv = duk_debug_read_tval(thr);\n\tif (tv == NULL) {\n\t\t/* detached */\n\t\treturn;\n\t}\n\n\tif (thr->callstack_top > 0) {\n\t\tduk_js_putvar_activation(thr,\n\t\t                         thr->callstack + thr->callstack_top + level,\n\t\t                         str,\n\t\t                         tv,\n\t\t                         0);\n\t} else {\n\t\tDUK_D(DUK_DPRINT(\"callstack empty, no activation -> ignore putvar\"));\n\t}\n\n\t/* XXX: Current putvar implementation doesn't have a success flag,\n\t * add one and send to debug client?\n\t */\n\tduk_debug_write_reply(thr);\n\tduk_debug_write_eom(thr);\n}\n\nDUK_LOCAL void duk__debug_handle_get_call_stack(duk_hthread *thr, duk_heap *heap) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hthread *curr_thr = thr;\n\tduk_activation *curr_act;\n\tduk_uint_fast32_t pc;\n\tduk_uint_fast32_t line;\n\tduk_size_t i;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_UNREF(heap);\n\n\tduk_debug_write_reply(thr);\n\twhile (curr_thr != NULL) {\n\t\ti = curr_thr->callstack_top;\n\t\twhile (i > 0) {\n\t\t\ti--;\n\t\t\tcurr_act = curr_thr->callstack + i;\n\n\t\t\t/* PC/line semantics here are:\n\t\t\t *   - For callstack top we're conceptually between two\n\t\t\t *     opcodes and current PC indicates next line to\n\t\t\t *     execute, so report that (matches Status).\n\t\t\t *   - For other activations we're conceptually still\n\t\t\t *     executing the instruction at PC-1, so report that\n\t\t\t *     (matches error stacktrace behavior).\n\t\t\t *   - See: https://github.com/svaarala/duktape/issues/281\n\t\t\t */\n\n\t\t\t/* XXX: optimize to use direct reads, i.e. avoid\n\t\t\t * value stack operations.\n\t\t\t */\n\t\t\tduk_push_tval(ctx, &curr_act->tv_func);\n\t\t\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_FILE_NAME);\n\t\t\tduk__debug_write_hstring_safe_top(thr);\n\t\t\tduk_get_prop_stridx_short(ctx, -2, DUK_STRIDX_NAME);\n\t\t\tduk__debug_write_hstring_safe_top(thr);\n\t\t\tpc = duk_hthread_get_act_curr_pc(thr, curr_act);\n\t\t\tif (i != curr_thr->callstack_top - 1 && pc > 0) {\n\t\t\t\tpc--;\n\t\t\t}\n\t\t\tline = duk_hobject_pc2line_query(ctx, -3, pc);\n\t\t\tduk_debug_write_uint(thr, (duk_uint32_t) line);\n\t\t\tduk_debug_write_uint(thr, (duk_uint32_t) pc);\n\t\t\tduk_pop_3(ctx);\n\t\t}\n\t\tcurr_thr = curr_thr->resumer;\n\t}\n\t/* SCANBUILD: warning about 'thr' potentially being NULL here,\n\t * warning is incorrect because thr != NULL always here.\n\t */\n\tduk_debug_write_eom(thr);\n}\n\nDUK_LOCAL void duk__debug_handle_get_locals(duk_hthread *thr, duk_heap *heap) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_activation *curr_act;\n\tduk_int32_t level;\n\tduk_hstring *varname;\n\n\tDUK_UNREF(heap);\n\n\tlevel = duk__debug_read_validate_csindex(thr);\n\tif (level == 0) {\n\t\treturn;\n\t}\n\tduk_debug_write_reply(thr);\n\n\tcurr_act = thr->callstack + thr->callstack_top + level;\n\n\t/* XXX: several nice-to-have improvements here:\n\t *   - Use direct reads avoiding value stack operations\n\t *   - Avoid triggering getters, indicate getter values to debug client\n\t *   - If side effects are possible, add error catching\n\t */\n\n\tduk_push_tval(ctx, &curr_act->tv_func);\n\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_INT_VARMAP);\n\tif (duk_is_object(ctx, -1)) {\n\t\tduk_enum(ctx, -1, 0 /*enum_flags*/);\n\t\twhile (duk_next(ctx, -1 /*enum_index*/, 0 /*get_value*/)) {\n\t\t\tvarname = duk_known_hstring(ctx, -1);\n\n\t\t\tduk_js_getvar_activation(thr, curr_act, varname, 0 /*throw_flag*/);\n\t\t\t/* [ ... func varmap enum key value this ] */\n\t\t\tduk_debug_write_hstring(thr, duk_get_hstring(ctx, -3));\n\t\t\tduk_debug_write_tval(thr, duk_get_tval(ctx, -2));\n\t\t\tduk_pop_3(ctx);  /* -> [ ... func varmap enum ] */\n\t\t}\n\t} else {\n\t\tDUK_D(DUK_DPRINT(\"varmap is not an object in GetLocals, ignore\"));\n\t}\n\n\tduk_debug_write_eom(thr);\n}\n\nDUK_LOCAL void duk__debug_handle_eval(duk_hthread *thr, duk_heap *heap) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_small_uint_t call_flags;\n\tduk_int_t call_ret;\n\tduk_small_int_t eval_err;\n\tduk_int_t num_eval_args;\n\tduk_bool_t direct_eval;\n\tduk_int32_t level;\n\n\tDUK_UNREF(heap);\n\n\tDUK_D(DUK_DPRINT(\"debug command Eval\"));\n\n\t/* The eval code is executed within the lexical environment of a specified\n\t * activation.  For now, use global object eval() function, with the eval\n\t * considered a 'direct call to eval'.\n\t *\n\t * Callstack index for debug commands only affects scope -- the callstack\n\t * as seen by, e.g. Duktape.act() will be the same regardless.\n\t */\n\n\t/* nargs == 2 so we can pass a callstack index to eval(). */\n\tduk_push_c_function(ctx, duk_bi_global_object_eval, 2 /*nargs*/);\n\tduk_push_undefined(ctx);  /* 'this' binding shouldn't matter here */\n\n\t/* Read callstack index, if non-null. */\n\tif (duk_debug_peek_byte(thr) == DUK_DBG_IB_NULL) {\n\t\tdirect_eval = 0;\n\t\tlevel = -1;  /* Not needed, but silences warning. */\n\t\t(void) duk_debug_read_byte(thr);\n\t} else {\n\t\tdirect_eval = 1;\n\t\tlevel = duk__debug_read_validate_csindex(thr);\n\t\tif (level == 0) {\n\t\t\treturn;\n\t\t}\n\t}\n\n\tDUK_ASSERT(!direct_eval ||\n\t           (level < 0 && -level <= (duk_int32_t) thr->callstack_top));\n\n\t(void) duk_debug_read_hstring(thr);\n\tif (direct_eval) {\n\t\tnum_eval_args = 2;\n\t\tduk_push_int(ctx, level - 1);  /* compensate for eval() call */\n\t} else {\n\t\tnum_eval_args = 1;\n\t}\n\n\t/* [ ... eval \"eval\" eval_input level ] */\n\n\tcall_flags = 0;\n\tif (direct_eval && thr->callstack_top >= (duk_size_t) -level) {\n\t\tduk_activation *act;\n\t\tduk_hobject *fun;\n\n\t\tact = thr->callstack + thr->callstack_top + level;\n\t\tfun = DUK_ACT_GET_FUNC(act);\n\t\tif (fun != NULL && DUK_HOBJECT_IS_COMPFUNC(fun)) {\n\t\t\t/* Direct eval requires that there's a current\n\t\t\t * activation and it is an Ecmascript function.\n\t\t\t * When Eval is executed from e.g. cooperate API\n\t\t\t * call we'll need to do an indirect eval instead.\n\t\t\t */\n\t\t\tcall_flags |= DUK_CALL_FLAG_DIRECT_EVAL;\n\t\t}\n\t}\n\n\tcall_ret = duk_handle_call_protected(thr, num_eval_args, call_flags);\n\n\tif (call_ret == DUK_EXEC_SUCCESS) {\n\t\teval_err = 0;\n\t\t/* Use result value as is. */\n\t} else {\n\t\t/* For errors a string coerced result is most informative\n\t\t * right now, as the debug client doesn't have the capability\n\t\t * to traverse the error object.\n\t\t */\n\t\teval_err = 1;\n\t\tduk_safe_to_string(ctx, -1);\n\t}\n\n\t/* [ ... result ] */\n\n\tduk_debug_write_reply(thr);\n\tduk_debug_write_int(thr, (duk_int32_t) eval_err);\n\tDUK_ASSERT(duk_get_tval(ctx, -1) != NULL);\n\tduk_debug_write_tval(thr, duk_get_tval(ctx, -1));\n\tduk_debug_write_eom(thr);\n}\n\nDUK_LOCAL void duk__debug_handle_detach(duk_hthread *thr, duk_heap *heap) {\n\tDUK_UNREF(heap);\n\tDUK_D(DUK_DPRINT(\"debug command Detach\"));\n\n\tduk_debug_write_reply(thr);\n\tduk_debug_write_eom(thr);\n\n\tDUK_D(DUK_DPRINT(\"debug connection detached, mark broken\"));\n\tDUK__SET_CONN_BROKEN(thr, 0);  /* not an error */\n}\n\nDUK_LOCAL void duk__debug_handle_apprequest(duk_hthread *thr, duk_heap *heap) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_idx_t old_top;\n\n\tDUK_D(DUK_DPRINT(\"debug command AppRequest\"));\n\n\told_top = duk_get_top(ctx);  /* save stack top */\n\n\tif (heap->dbg_request_cb != NULL) {\n\t\tduk_idx_t nrets;\n\t\tduk_idx_t nvalues = 0;\n\t\tduk_idx_t top, idx;\n\n\t\t/* Read tvals from the message and push them onto the valstack,\n\t\t * then call the request callback to process the request.\n\t\t */\n\t\twhile (duk_debug_peek_byte(thr) != DUK_DBG_IB_EOM) {\n\t\t\tduk_tval *tv;\n\t\t\tif (!duk_check_stack(ctx, 1)) {\n\t\t\t\tDUK_D(DUK_DPRINT(\"failed to allocate space for request dvalue(s)\"));\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\ttv = duk_debug_read_tval(thr);  /* push to stack */\n\t\t\tif (tv == NULL) {\n\t\t\t\t/* detached */\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tnvalues++;\n\t\t}\n\t\tDUK_ASSERT(duk_get_top(ctx) == old_top + nvalues);\n\n\t\t/* Request callback should push values for reply to client onto valstack */\n\t\tDUK_D(DUK_DPRINT(\"calling into AppRequest request_cb with nvalues=%ld, old_top=%ld, top=%ld\",\n\t\t                 (long) nvalues, (long) old_top, (long) duk_get_top(ctx)));\n\t\tnrets = heap->dbg_request_cb(ctx, heap->dbg_udata, nvalues);\n\t\tDUK_D(DUK_DPRINT(\"returned from AppRequest request_cb; nvalues=%ld -> nrets=%ld, old_top=%ld, top=%ld\",\n\t\t                 (long) nvalues, (long) nrets, (long) old_top, (long) duk_get_top(ctx)));\n\t\tif (nrets >= 0) {\n\t\t\tDUK_ASSERT(duk_get_top(ctx) >= old_top + nrets);\n\t\t\tif (duk_get_top(ctx) < old_top + nrets) {\n\t\t\t\tDUK_D(DUK_DPRINT(\"AppRequest callback doesn't match value stack configuration, \"\n\t\t\t\t                 \"top=%ld < old_top=%ld + nrets=%ld; \"\n\t\t\t\t                 \"this might mean it's unsafe to continue!\",\n\t\t\t\t                 (long) duk_get_top(ctx), (long) old_top, (long) nrets));\n\t\t\t\tgoto fail;\n\t\t\t}\n\n\t\t\t/* Reply with tvals pushed by request callback */\n\t\t\tduk_debug_write_byte(thr, DUK_DBG_IB_REPLY);\n\t\t\ttop = duk_get_top(ctx);\n\t\t\tfor (idx = top - nrets; idx < top; idx++) {\n\t\t\t\tduk_debug_write_tval(thr, DUK_GET_TVAL_POSIDX(ctx, idx));\n\t\t\t}\n\t\t\tduk_debug_write_eom(thr);\n\t\t} else {\n\t\t\tDUK_ASSERT(duk_get_top(ctx) >= old_top + 1);\n\t\t\tif (duk_get_top(ctx) < old_top + 1) {\n\t\t\t\tDUK_D(DUK_DPRINT(\"request callback return value doesn't match value stack configuration\"));\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tduk_debug_write_error_eom(thr, DUK_DBG_ERR_APPLICATION, duk_get_string(ctx, -1));\n\t\t}\n\n\t\tduk_set_top(ctx, old_top);  /* restore stack top */\n\t} else {\n\t\tDUK_D(DUK_DPRINT(\"no request callback, treat AppRequest as unsupported\"));\n\t\tduk_debug_write_error_eom(thr, DUK_DBG_ERR_UNSUPPORTED, \"AppRequest unsupported by target\");\n\t}\n\n\treturn;\n\n fail:\n\tduk_set_top(ctx, old_top);  /* restore stack top */\n\tDUK__SET_CONN_BROKEN(thr, 1);\n}\n\n/*\n *  DumpHeap command\n */\n\n#if defined(DUK_USE_DEBUGGER_DUMPHEAP)\n/* XXX: this has some overlap with object inspection; remove this and make\n * DumpHeap return lists of heapptrs instead?\n */\nDUK_LOCAL void duk__debug_dump_heaphdr(duk_hthread *thr, duk_heap *heap, duk_heaphdr *hdr) {\n\tDUK_UNREF(heap);\n\n\tduk_debug_write_heapptr(thr, hdr);\n\tduk_debug_write_uint(thr, (duk_uint32_t) DUK_HEAPHDR_GET_TYPE(hdr));\n\tduk_debug_write_uint(thr, (duk_uint32_t) DUK_HEAPHDR_GET_FLAGS_RAW(hdr));\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tduk_debug_write_uint(thr, (duk_uint32_t) DUK_HEAPHDR_GET_REFCOUNT(hdr));\n#else\n\tduk_debug_write_int(thr, (duk_int32_t) -1);\n#endif\n\n\tswitch (DUK_HEAPHDR_GET_TYPE(hdr)) {\n\tcase DUK_HTYPE_STRING: {\n\t\tduk_hstring *h = (duk_hstring *) hdr;\n\n\t\tduk_debug_write_uint(thr, (duk_int32_t) DUK_HSTRING_GET_BYTELEN(h));\n\t\tduk_debug_write_uint(thr, (duk_int32_t) DUK_HSTRING_GET_CHARLEN(h));\n\t\tduk_debug_write_uint(thr, (duk_int32_t) DUK_HSTRING_GET_HASH(h));\n\t\tduk_debug_write_hstring(thr, h);\n\t\tbreak;\n\t}\n\tcase DUK_HTYPE_OBJECT: {\n\t\tduk_hobject *h = (duk_hobject *) hdr;\n\t\tduk_hstring *k;\n\t\tduk_uint_fast32_t i;\n\n\t\tduk_debug_write_uint(thr, (duk_uint32_t) DUK_HOBJECT_GET_CLASS_NUMBER(h));\n\t\tduk_debug_write_heapptr(thr, (duk_heaphdr *) DUK_HOBJECT_GET_PROTOTYPE(heap, h));\n\t\tduk_debug_write_uint(thr, (duk_uint32_t) DUK_HOBJECT_GET_ESIZE(h));\n\t\tduk_debug_write_uint(thr, (duk_uint32_t) DUK_HOBJECT_GET_ENEXT(h));\n\t\tduk_debug_write_uint(thr, (duk_uint32_t) DUK_HOBJECT_GET_ASIZE(h));\n\t\tduk_debug_write_uint(thr, (duk_uint32_t) DUK_HOBJECT_GET_HSIZE(h));\n\n\t\tfor (i = 0; i < (duk_uint_fast32_t) DUK_HOBJECT_GET_ENEXT(h); i++) {\n\t\t\tduk_debug_write_uint(thr, (duk_uint32_t) DUK_HOBJECT_E_GET_FLAGS(heap, h, i));\n\t\t\tk = DUK_HOBJECT_E_GET_KEY(heap, h, i);\n\t\t\tduk_debug_write_heapptr(thr, (duk_heaphdr *) k);\n\t\t\tif (k == NULL) {\n\t\t\t\tduk_debug_write_int(thr, 0);  /* isAccessor */\n\t\t\t\tduk_debug_write_unused(thr);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (DUK_HOBJECT_E_SLOT_IS_ACCESSOR(heap, h, i)) {\n\t\t\t\tduk_debug_write_int(thr, 1);  /* isAccessor */\n\t\t\t\tduk_debug_write_heapptr(thr, (duk_heaphdr *) DUK_HOBJECT_E_GET_VALUE_PTR(heap, h, i)->a.get);\n\t\t\t\tduk_debug_write_heapptr(thr, (duk_heaphdr *) DUK_HOBJECT_E_GET_VALUE_PTR(heap, h, i)->a.set);\n\t\t\t} else {\n\t\t\t\tduk_debug_write_int(thr, 0);  /* isAccessor */\n\n\t\t\t\tduk__debug_write_tval_heapptr(thr, &DUK_HOBJECT_E_GET_VALUE_PTR(heap, h, i)->v);\n\t\t\t}\n\t\t}\n\n\t\tfor (i = 0; i < (duk_uint_fast32_t) DUK_HOBJECT_GET_ASIZE(h); i++) {\n\t\t\t/* Note: array dump will include elements beyond\n\t\t\t * 'length'.\n\t\t\t */\n\t\t\tduk__debug_write_tval_heapptr(thr, DUK_HOBJECT_A_GET_VALUE_PTR(heap, h, i));\n\t\t}\n\t\tbreak;\n\t}\n\tcase DUK_HTYPE_BUFFER: {\n\t\tduk_hbuffer *h = (duk_hbuffer *) hdr;\n\n\t\tduk_debug_write_uint(thr, (duk_uint32_t) DUK_HBUFFER_GET_SIZE(h));\n\t\tduk_debug_write_buffer(thr, (const char *) DUK_HBUFFER_GET_DATA_PTR(heap, h), (duk_size_t) DUK_HBUFFER_GET_SIZE(h));\n\t\tbreak;\n\t}\n\tdefault: {\n\t\tDUK_D(DUK_DPRINT(\"invalid htype: %d\", (int) DUK_HEAPHDR_GET_TYPE(hdr)));\n\t}\n\t}\n}\n\nDUK_LOCAL void duk__debug_dump_heap_allocated(duk_hthread *thr, duk_heap *heap) {\n\tduk_heaphdr *hdr;\n\n\thdr = heap->heap_allocated;\n\twhile (hdr != NULL) {\n\t\tduk__debug_dump_heaphdr(thr, heap, hdr);\n\t\thdr = DUK_HEAPHDR_GET_NEXT(heap, hdr);\n\t}\n}\n\nDUK_LOCAL void duk__debug_dump_strtab(duk_hthread *thr, duk_heap *heap) {\n\tduk_uint32_t i;\n\tduk_hstring *h;\n\n\tfor (i = 0; i < heap->st_size; i++) {\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\t\th = DUK_USE_HEAPPTR_DEC16((heap)->heap_udata, heap->strtable16[i]);\n#else\n\t\th = heap->strtable[i];\n#endif\n\t\twhile (h != NULL) {\n\t\t\tduk__debug_dump_heaphdr(thr, heap, (duk_heaphdr *) h);\n\t\t\th = h->hdr.h_next;\n\t\t}\n\t}\n}\n\nDUK_LOCAL void duk__debug_handle_dump_heap(duk_hthread *thr, duk_heap *heap) {\n\tDUK_D(DUK_DPRINT(\"debug command DumpHeap\"));\n\n\tduk_debug_write_reply(thr);\n\tduk__debug_dump_heap_allocated(thr, heap);\n\tduk__debug_dump_strtab(thr, heap);\n\tduk_debug_write_eom(thr);\n}\n#endif  /* DUK_USE_DEBUGGER_DUMPHEAP */\n\nDUK_LOCAL void duk__debug_handle_get_bytecode(duk_hthread *thr, duk_heap *heap) {\n\tduk_activation *act;\n\tduk_hcompfunc *fun = NULL;\n\tduk_size_t i, n;\n\tduk_tval *tv;\n\tduk_hobject **fn;\n\tduk_int32_t level = -1;\n\tduk_uint8_t ibyte;\n\n\tDUK_UNREF(heap);\n\n\tDUK_D(DUK_DPRINT(\"debug command GetBytecode\"));\n\n\tibyte = duk_debug_peek_byte(thr);\n\tif (ibyte != DUK_DBG_IB_EOM) {\n\t\ttv = duk_debug_read_tval(thr);\n\t\tif (tv == NULL) {\n\t\t\t/* detached */\n\t\t\treturn;\n\t\t}\n\t\tif (DUK_TVAL_IS_OBJECT(tv)) {\n\t\t\t/* tentative, checked later */\n\t\t\tfun = (duk_hcompfunc *) DUK_TVAL_GET_OBJECT(tv);\n\t\t\tDUK_ASSERT(fun != NULL);\n\t\t} else if (DUK_TVAL_IS_NUMBER(tv)) {\n\t\t\tlevel = (duk_int32_t) DUK_TVAL_GET_NUMBER(tv);\n\t\t} else {\n\t\t\tDUK_D(DUK_DPRINT(\"invalid argument to GetBytecode: %!T\", tv));\n\t\t\tgoto fail_args;\n\t\t}\n\t}\n\n\tif (fun == NULL) {\n\t\tif (level >= 0 || -level > (duk_int32_t) thr->callstack_top) {\n\t\t\tDUK_D(DUK_DPRINT(\"invalid callstack index for GetBytecode\"));\n\t\t\tgoto fail_index;\n\t\t}\n\t\tact = thr->callstack + thr->callstack_top + level;\n\t\tfun = (duk_hcompfunc *) DUK_ACT_GET_FUNC(act);\n\t}\n\n\tif (fun == NULL || !DUK_HOBJECT_IS_COMPFUNC((duk_hobject *) fun)) {\n\t\tDUK_D(DUK_DPRINT(\"invalid argument to GetBytecode: %!O\", fun));\n\t\tgoto fail_args;\n\t}\n\tDUK_ASSERT(fun != NULL && DUK_HOBJECT_IS_COMPFUNC((duk_hobject *) fun));\n\n\tduk_debug_write_reply(thr);\n\tn = DUK_HCOMPFUNC_GET_CONSTS_COUNT(heap, fun);\n\tduk_debug_write_int(thr, (duk_int32_t) n);\n\ttv = DUK_HCOMPFUNC_GET_CONSTS_BASE(heap, fun);\n\tfor (i = 0; i < n; i++) {\n\t\tduk_debug_write_tval(thr, tv);\n\t\ttv++;\n\t}\n\tn = DUK_HCOMPFUNC_GET_FUNCS_COUNT(heap, fun);\n\tduk_debug_write_int(thr, (duk_int32_t) n);\n\tfn = DUK_HCOMPFUNC_GET_FUNCS_BASE(heap, fun);\n\tfor (i = 0; i < n; i++) {\n\t\tduk_debug_write_hobject(thr, *fn);\n\t\tfn++;\n\t}\n\tduk_debug_write_string(thr,\n\t                       (const char *) DUK_HCOMPFUNC_GET_CODE_BASE(heap, fun),\n\t                       (duk_size_t) DUK_HCOMPFUNC_GET_CODE_SIZE(heap, fun));\n\tduk_debug_write_eom(thr);\n\treturn;\n\n fail_args:\n\tduk_debug_write_error_eom(thr, DUK_DBG_ERR_UNKNOWN, \"invalid argument\");\n\treturn;\n\n fail_index:\n\tduk_debug_write_error_eom(thr, DUK_DBG_ERR_NOTFOUND, \"invalid callstack index\");\n\treturn;\n}\n\n/*\n *  Object inspection commands: GetHeapObjInfo, GetObjPropDesc,\n *  GetObjPropDescRange\n */\n\n#if defined(DUK_USE_DEBUGGER_INSPECT)\n\n#if 0 /* pruned */\nDUK_LOCAL const char * const duk__debug_getinfo_heaphdr_keys[] = {\n\t\"reachable\",\n\t\"temproot\",\n\t\"finalizable\",\n\t\"finalized\",\n\t\"readonly\"\n\t/* NULL not needed here */\n};\nDUK_LOCAL duk_uint_t duk__debug_getinfo_heaphdr_masks[] = {\n\tDUK_HEAPHDR_FLAG_REACHABLE,\n\tDUK_HEAPHDR_FLAG_TEMPROOT,\n\tDUK_HEAPHDR_FLAG_FINALIZABLE,\n\tDUK_HEAPHDR_FLAG_FINALIZED,\n\tDUK_HEAPHDR_FLAG_READONLY,\n\t0  /* terminator */\n};\n#endif\nDUK_LOCAL const char * const duk__debug_getinfo_hstring_keys[] = {\n#if 0\n\t\"arridx\",\n\t\"symbol\",\n\t\"hidden\",\n\t\"reserved_word\",\n\t\"strict_reserved_word\",\n\t\"eval_or_arguments\",\n#endif\n\t\"extdata\"\n\t/* NULL not needed here */\n};\nDUK_LOCAL duk_uint_t duk__debug_getinfo_hstring_masks[] = {\n#if 0\n\tDUK_HSTRING_FLAG_ARRIDX,\n\tDUK_HSTRING_FLAG_SYMBOL,\n\tDUK_HSTRING_FLAG_HIDDEN,\n\tDUK_HSTRING_FLAG_RESERVED_WORD,\n\tDUK_HSTRING_FLAG_STRICT_RESERVED_WORD,\n\tDUK_HSTRING_FLAG_EVAL_OR_ARGUMENTS,\n#endif\n\tDUK_HSTRING_FLAG_EXTDATA,\n\t0  /* terminator */\n};\nDUK_LOCAL const char * const duk__debug_getinfo_hobject_keys[] = {\n\t\"extensible\",\n\t\"constructable\",\n\t\"boundfunc\",\n\t\"compfunc\",\n\t\"natfunc\",\n\t\"bufobj\",\n\t\"fastrefs\",\n\t\"array_part\",\n\t\"strict\",\n\t\"notail\",\n\t\"newenv\",\n\t\"namebinding\",\n\t\"createargs\",\n\t\"have_finalizer\"\n\t\"exotic_array\",\n\t\"exotic_stringobj\",\n\t\"exotic_arguments\",\n\t\"exotic_dukfunc\",\n\t\"exotic_proxyobj\"\n\t/* NULL not needed here */\n};\nDUK_LOCAL duk_uint_t duk__debug_getinfo_hobject_masks[] = {\n\tDUK_HOBJECT_FLAG_EXTENSIBLE,\n\tDUK_HOBJECT_FLAG_CONSTRUCTABLE,\n\tDUK_HOBJECT_FLAG_BOUNDFUNC,\n\tDUK_HOBJECT_FLAG_COMPFUNC,\n\tDUK_HOBJECT_FLAG_NATFUNC,\n\tDUK_HOBJECT_FLAG_BUFOBJ,\n\tDUK_HOBJECT_FLAG_FASTREFS,\n\tDUK_HOBJECT_FLAG_ARRAY_PART,\n\tDUK_HOBJECT_FLAG_STRICT,\n\tDUK_HOBJECT_FLAG_NOTAIL,\n\tDUK_HOBJECT_FLAG_NEWENV,\n\tDUK_HOBJECT_FLAG_NAMEBINDING,\n\tDUK_HOBJECT_FLAG_CREATEARGS,\n\tDUK_HOBJECT_FLAG_HAVE_FINALIZER,\n\tDUK_HOBJECT_FLAG_EXOTIC_ARRAY,\n\tDUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ,\n\tDUK_HOBJECT_FLAG_EXOTIC_ARGUMENTS,\n\tDUK_HOBJECT_FLAG_EXOTIC_DUKFUNC,\n\tDUK_HOBJECT_FLAG_EXOTIC_PROXYOBJ,\n\t0  /* terminator */\n};\nDUK_LOCAL const char * const duk__debug_getinfo_hbuffer_keys[] = {\n\t\"dynamic\",\n\t\"external\"\n\t/* NULL not needed here */\n};\nDUK_LOCAL duk_uint_t duk__debug_getinfo_hbuffer_masks[] = {\n\tDUK_HBUFFER_FLAG_DYNAMIC,\n\tDUK_HBUFFER_FLAG_EXTERNAL,\n\t0  /* terminator */\n};\n\nDUK_LOCAL void duk__debug_getinfo_flags_key(duk_hthread *thr, const char *key) {\n\tduk_debug_write_uint(thr, 0);\n\tduk_debug_write_cstring(thr, key);\n}\n\nDUK_LOCAL void duk__debug_getinfo_prop_uint(duk_hthread *thr, const char *key, duk_uint_t val) {\n\tduk_debug_write_uint(thr, 0);\n\tduk_debug_write_cstring(thr, key);\n\tduk_debug_write_uint(thr, val);\n}\n\nDUK_LOCAL void duk__debug_getinfo_prop_int(duk_hthread *thr, const char *key, duk_int_t val) {\n\tduk_debug_write_uint(thr, 0);\n\tduk_debug_write_cstring(thr, key);\n\tduk_debug_write_int(thr, val);\n}\n\nDUK_LOCAL void duk__debug_getinfo_prop_bool(duk_hthread *thr, const char *key, duk_bool_t val) {\n\tduk_debug_write_uint(thr, 0);\n\tduk_debug_write_cstring(thr, key);\n\tduk_debug_write_boolean(thr, val);\n}\n\nDUK_LOCAL void duk__debug_getinfo_bitmask(duk_hthread *thr, const char * const * keys, duk_uint_t *masks, duk_uint_t flags) {\n\tconst char *key;\n\tduk_uint_t mask;\n\n\tfor (;;) {\n\t\tmask = *masks++;\n\t\tif (!mask) {\n\t\t\tbreak;\n\t\t}\n\t\tkey = *keys++;\n\t\tDUK_ASSERT(key != NULL);\n\n\t\tDUK_DD(DUK_DDPRINT(\"inspect bitmask: key=%s, mask=0x%08lx, flags=0x%08lx\", key, (unsigned long) mask, (unsigned long) flags));\n\t\tduk__debug_getinfo_prop_bool(thr, key, flags & mask);\n\t}\n}\n\n/* Inspect a property using a virtual index into a conceptual property list\n * consisting of (1) all array part items from [0,a_size[ (even when above\n * .length) and (2) all entry part items from [0,e_next[.  Unused slots are\n * indicated using dvalue 'unused'.\n */\nDUK_LOCAL duk_bool_t duk__debug_getprop_index(duk_hthread *thr, duk_heap *heap, duk_hobject *h_obj, duk_uint_t idx) {\n\tduk_uint_t a_size;\n\tduk_tval *tv;\n\tduk_hstring *h_key;\n\tduk_hobject *h_getset;\n\tduk_uint_t flags;\n\n\tDUK_UNREF(heap);\n\n\ta_size = DUK_HOBJECT_GET_ASIZE(h_obj);\n\tif (idx < a_size) {\n\t\tduk_debug_write_uint(thr, DUK_PROPDESC_FLAGS_WEC);\n\t\tduk_debug_write_uint(thr, idx);\n\t\ttv = DUK_HOBJECT_A_GET_VALUE_PTR(heap, h_obj, idx);\n\t\tduk_debug_write_tval(thr, tv);\n\t\treturn 1;\n\t}\n\n\tidx -= a_size;\n\tif (idx >= DUK_HOBJECT_GET_ENEXT(h_obj)) {\n\t\treturn 0;\n\t}\n\n\th_key = DUK_HOBJECT_E_GET_KEY(heap, h_obj, idx);\n\tif (h_key == NULL) {\n\t\tduk_debug_write_uint(thr, 0);\n\t\tduk_debug_write_null(thr);\n\t\tduk_debug_write_unused(thr);\n\t\treturn 1;\n\t}\n\n\tflags = DUK_HOBJECT_E_GET_FLAGS(heap, h_obj, idx);\n\tif (DUK_HSTRING_HAS_SYMBOL(h_key)) {\n\t\tflags |= DUK_DBG_PROPFLAG_SYMBOL;\n\t}\n\tif (DUK_HSTRING_HAS_HIDDEN(h_key)) {\n\t\tflags |= DUK_DBG_PROPFLAG_HIDDEN;\n\t}\n\tduk_debug_write_uint(thr, flags);\n\tduk_debug_write_hstring(thr, h_key);\n\tif (flags & DUK_PROPDESC_FLAG_ACCESSOR) {\n\t\th_getset = DUK_HOBJECT_E_GET_VALUE_GETTER(heap, h_obj, idx);\n\t\tif (h_getset) {\n\t\t\tduk_debug_write_hobject(thr, h_getset);\n\t\t} else {\n\t\t\tduk_debug_write_null(thr);\n\t\t}\n\t\th_getset = DUK_HOBJECT_E_GET_VALUE_SETTER(heap, h_obj, idx);\n\t\tif (h_getset) {\n\t\t\tduk_debug_write_hobject(thr, h_getset);\n\t\t} else {\n\t\t\tduk_debug_write_null(thr);\n\t\t}\n\t} else {\n\t\ttv = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(heap, h_obj, idx);\n\t\tduk_debug_write_tval(thr, tv);\n\t}\n\treturn 1;\n}\n\nDUK_LOCAL void duk__debug_handle_get_heap_obj_info(duk_hthread *thr, duk_heap *heap) {\n\tduk_heaphdr *h;\n\n\tDUK_D(DUK_DPRINT(\"debug command GetHeapObjInfo\"));\n\tDUK_UNREF(heap);\n\n\th = duk_debug_read_any_ptr(thr);\n\tif (!h) {\n\t\tduk_debug_write_error_eom(thr, DUK_DBG_ERR_UNKNOWN, \"invalid target\");\n\t\treturn;\n\t}\n\n\tduk_debug_write_reply(thr);\n\n\t/* As with all inspection code, we rely on the debug client providing\n\t * a valid, non-stale pointer: there's no portable way to safely\n\t * validate the pointer here.\n\t */\n\n\tduk__debug_getinfo_flags_key(thr, \"heapptr\");\n\tduk_debug_write_heapptr(thr, h);\n\n\t/* XXX: comes out as signed now */\n\tduk__debug_getinfo_prop_uint(thr, \"heaphdr_flags\", (duk_uint_t) DUK_HEAPHDR_GET_FLAGS(h));\n\tduk__debug_getinfo_prop_uint(thr, \"heaphdr_type\", (duk_uint_t) DUK_HEAPHDR_GET_TYPE(h));\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tduk__debug_getinfo_prop_uint(thr, \"refcount\", (duk_uint_t) DUK_HEAPHDR_GET_REFCOUNT(h));\n#endif\n#if 0 /* pruned */\n\tduk__debug_getinfo_bitmask(thr,\n\t                           duk__debug_getinfo_heaphdr_keys,\n\t                           duk__debug_getinfo_heaphdr_masks,\n\t                           DUK_HEAPHDR_GET_FLAGS_RAW(h));\n#endif\n\n\tswitch (DUK_HEAPHDR_GET_TYPE(h)) {\n\tcase DUK_HTYPE_STRING: {\n\t\tduk_hstring *h_str;\n\n\t\th_str = (duk_hstring *) h;\n\t\tduk__debug_getinfo_bitmask(thr,\n\t\t                           duk__debug_getinfo_hstring_keys,\n\t\t                           duk__debug_getinfo_hstring_masks,\n\t\t                           DUK_HEAPHDR_GET_FLAGS_RAW(h));\n\t\tduk__debug_getinfo_prop_uint(thr, \"bytelen\", (duk_uint_t) DUK_HSTRING_GET_BYTELEN(h_str));\n\t\tduk__debug_getinfo_prop_uint(thr, \"charlen\", (duk_uint_t) DUK_HSTRING_GET_CHARLEN(h_str));\n\t\tduk__debug_getinfo_prop_uint(thr, \"hash\", (duk_uint_t) DUK_HSTRING_GET_HASH(h_str));\n\t\tduk__debug_getinfo_flags_key(thr, \"data\");\n\t\tduk_debug_write_hstring(thr, h_str);\n\t\tbreak;\n\t}\n\tcase DUK_HTYPE_OBJECT: {\n\t\tduk_hobject *h_obj;\n\t\tduk_hobject *h_proto;\n\n\t\th_obj = (duk_hobject *) h;\n\t\th_proto = DUK_HOBJECT_GET_PROTOTYPE(heap, h_obj);\n\n\t\t/* duk_hobject specific fields. */\n\t\tduk__debug_getinfo_bitmask(thr,\n\t\t                           duk__debug_getinfo_hobject_keys,\n\t\t                           duk__debug_getinfo_hobject_masks,\n\t\t                           DUK_HEAPHDR_GET_FLAGS_RAW(h));\n\t\tduk__debug_getinfo_prop_uint(thr, \"class_number\", DUK_HOBJECT_GET_CLASS_NUMBER(h_obj));\n\t\tduk__debug_getinfo_flags_key(thr, \"class_name\");\n\t\tduk_debug_write_hstring(thr, DUK_HOBJECT_GET_CLASS_STRING(heap, h_obj));\n\t\tduk__debug_getinfo_flags_key(thr, \"prototype\");\n\t\tif (h_proto != NULL) {\n\t\t\tduk_debug_write_hobject(thr, h_proto);\n\t\t} else {\n\t\t\tduk_debug_write_null(thr);\n\t\t}\n\t\tduk__debug_getinfo_flags_key(thr, \"props\");\n\t\tduk_debug_write_pointer(thr, (void *) DUK_HOBJECT_GET_PROPS(heap, h_obj));\n\t\tduk__debug_getinfo_prop_uint(thr, \"e_size\", (duk_uint_t) DUK_HOBJECT_GET_ESIZE(h_obj));\n\t\tduk__debug_getinfo_prop_uint(thr, \"e_next\", (duk_uint_t) DUK_HOBJECT_GET_ENEXT(h_obj));\n\t\tduk__debug_getinfo_prop_uint(thr, \"a_size\", (duk_uint_t) DUK_HOBJECT_GET_ASIZE(h_obj));\n\t\tduk__debug_getinfo_prop_uint(thr, \"h_size\", (duk_uint_t) DUK_HOBJECT_GET_HSIZE(h_obj));\n\n\t\tif (DUK_HOBJECT_IS_ARRAY(h_obj)) {\n\t\t\tduk_harray *h_arr;\n\t\t\th_arr = (duk_harray *) h_obj;\n\n\t\t\tduk__debug_getinfo_prop_int(thr, \"length\", h_arr->length);\n\t\t\tduk__debug_getinfo_prop_bool(thr, \"length_nonwritable\", h_arr->length_nonwritable);\n\t\t}\n\n\t\tif (DUK_HOBJECT_IS_NATFUNC(h_obj)) {\n\t\t\tduk_hnatfunc *h_fun;\n\t\t\th_fun = (duk_hnatfunc *) h_obj;\n\n\t\t\tduk__debug_getinfo_prop_int(thr, \"nargs\", h_fun->nargs);\n\t\t\tduk__debug_getinfo_prop_int(thr, \"magic\", h_fun->magic);\n\t\t\tduk__debug_getinfo_prop_bool(thr, \"varargs\", h_fun->magic == DUK_HNATFUNC_NARGS_VARARGS);\n\t\t\t/* Native function pointer may be different from a void pointer,\n\t\t\t * and we serialize it from memory directly now (no byte swapping etc).\n\t\t\t */\n\t\t\tduk__debug_getinfo_flags_key(thr, \"funcptr\");\n\t\t\tduk_debug_write_buffer(thr, (const char *) &h_fun->func, sizeof(h_fun->func));\n\t\t}\n\n\t\tif (DUK_HOBJECT_IS_COMPFUNC(h_obj)) {\n\t\t\tduk_hcompfunc *h_fun;\n\t\t\tduk_hbuffer *h_buf;\n\t\t\tduk_hobject *h_lexenv;\n\t\t\tduk_hobject *h_varenv;\n\t\t\th_fun = (duk_hcompfunc *) h_obj;\n\n\t\t\tduk__debug_getinfo_prop_int(thr, \"nregs\", h_fun->nregs);\n\t\t\tduk__debug_getinfo_prop_int(thr, \"nargs\", h_fun->nargs);\n\n\t\t\tduk__debug_getinfo_flags_key(thr, \"lex_env\");\n\t\t\th_lexenv = DUK_HCOMPFUNC_GET_LEXENV(thr->heap, h_fun);\n\t\t\tif (h_lexenv != NULL) {\n\t\t\t\tduk_debug_write_hobject(thr, h_lexenv);\n\t\t\t} else {\n\t\t\t\tduk_debug_write_null(thr);\n\t\t\t}\n\t\t\tduk__debug_getinfo_flags_key(thr, \"var_env\");\n\t\t\th_varenv = DUK_HCOMPFUNC_GET_VARENV(thr->heap, h_fun);\n\t\t\tif (h_varenv != NULL) {\n\t\t\t\tduk_debug_write_hobject(thr, h_varenv);\n\t\t\t} else {\n\t\t\t\tduk_debug_write_null(thr);\n\t\t\t}\n\n\t\t\tduk__debug_getinfo_prop_uint(thr, \"start_line\", h_fun->start_line);\n\t\t\tduk__debug_getinfo_prop_uint(thr, \"end_line\", h_fun->end_line);\n\t\t\th_buf = (duk_hbuffer *) DUK_HCOMPFUNC_GET_DATA(thr->heap, h_fun);\n\t\t\tif (h_buf != NULL) {\n\t\t\t\tduk__debug_getinfo_flags_key(thr, \"data\");\n\t\t\t\tduk_debug_write_heapptr(thr, (duk_heaphdr *) h_buf);\n\t\t\t}\n\t\t}\n\n\t\tif (DUK_HOBJECT_IS_THREAD(h_obj)) {\n\t\t\t/* XXX: Currently no inspection of threads, e.g. value stack, call\n\t\t\t * stack, catch stack, etc.\n\t\t\t */\n\t\t\tduk_hthread *h_thr;\n\t\t\th_thr = (duk_hthread *) h_obj;\n\t\t\tDUK_UNREF(h_thr);\n\t\t}\n\n\t\tif (DUK_HOBJECT_IS_DECENV(h_obj)) {\n\t\t\tduk_hdecenv *h_env;\n\t\t\th_env = (duk_hdecenv *) h_obj;\n\n\t\t\tduk__debug_getinfo_flags_key(thr, \"thread\");\n\t\t\tduk_debug_write_heapptr(thr, (duk_heaphdr *) (h_env->thread));\n\t\t\tduk__debug_getinfo_flags_key(thr, \"varmap\");\n\t\t\tduk_debug_write_heapptr(thr, (duk_heaphdr *) (h_env->varmap));\n\t\t\tduk__debug_getinfo_prop_uint(thr, \"regbase\", (duk_uint_t) h_env->regbase);\n\t\t}\n\n\t\tif (DUK_HOBJECT_IS_OBJENV(h_obj)) {\n\t\t\tduk_hobjenv *h_env;\n\t\t\th_env = (duk_hobjenv *) h_obj;\n\n\t\t\tduk__debug_getinfo_flags_key(thr, \"target\");\n\t\t\tduk_debug_write_heapptr(thr, (duk_heaphdr *) (h_env->target));\n\t\t\tduk__debug_getinfo_prop_bool(thr, \"has_this\", h_env->has_this);\n\t\t}\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n\t\tif (DUK_HOBJECT_IS_BUFOBJ(h_obj)) {\n\t\t\tduk_hbufobj *h_bufobj;\n\t\t\th_bufobj = (duk_hbufobj *) h_obj;\n\n\t\t\tduk__debug_getinfo_prop_uint(thr, \"slice_offset\", h_bufobj->offset);\n\t\t\tduk__debug_getinfo_prop_uint(thr, \"slice_length\", h_bufobj->length);\n\t\t\tduk__debug_getinfo_prop_uint(thr, \"elem_shift\", (duk_uint_t) h_bufobj->shift);\n\t\t\tduk__debug_getinfo_prop_uint(thr, \"elem_type\", (duk_uint_t) h_bufobj->elem_type);\n\t\t\tduk__debug_getinfo_prop_bool(thr, \"is_typedarray\", (duk_uint_t) h_bufobj->is_typedarray);\n\t\t\tif (h_bufobj->buf != NULL) {\n\t\t\t\tduk__debug_getinfo_flags_key(thr, \"buffer\");\n\t\t\t\tduk_debug_write_heapptr(thr, (duk_heaphdr *) h_bufobj->buf);\n\t\t\t}\n\t\t}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\t\tbreak;\n\t}\n\tcase DUK_HTYPE_BUFFER: {\n\t\tduk_hbuffer *h_buf;\n\n\t\th_buf = (duk_hbuffer *) h;\n\t\tduk__debug_getinfo_bitmask(thr,\n\t\t                           duk__debug_getinfo_hbuffer_keys,\n\t\t                           duk__debug_getinfo_hbuffer_masks,\n\t\t                           DUK_HEAPHDR_GET_FLAGS_RAW(h));\n\t\tduk__debug_getinfo_prop_uint(thr, \"size\", (duk_uint_t) DUK_HBUFFER_GET_SIZE(h_buf));\n\t\tduk__debug_getinfo_flags_key(thr, \"dataptr\");\n\t\tduk_debug_write_pointer(thr, (void *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_buf));\n\t\tduk__debug_getinfo_flags_key(thr, \"data\");\n\t\tduk_debug_write_hbuffer(thr, h_buf);  /* tolerates NULL h_buf */\n\t\tbreak;\n\t}\n\tdefault: {\n\t\t/* Since we already started writing the reply, just emit nothing. */\n\t\tDUK_D(DUK_DPRINT(\"inspect target pointer has invalid heaphdr type\"));\n\t}\n\t}\n\n\tduk_debug_write_eom(thr);\n}\n\nDUK_LOCAL void duk__debug_handle_get_obj_prop_desc(duk_hthread *thr, duk_heap *heap) {\n\tduk_heaphdr *h;\n\tduk_hobject *h_obj;\n\tduk_hstring *h_key;\n\tduk_propdesc desc;\n\n\tDUK_D(DUK_DPRINT(\"debug command GetObjPropDesc\"));\n\tDUK_UNREF(heap);\n\n\th = duk_debug_read_any_ptr(thr);\n\tif (!h) {\n\t\tduk_debug_write_error_eom(thr, DUK_DBG_ERR_UNKNOWN, \"invalid target\");\n\t\treturn;\n\t}\n\th_key = duk_debug_read_hstring(thr);\n\tif (h == NULL || DUK_HEAPHDR_GET_TYPE(h) != DUK_HTYPE_OBJECT || h_key == NULL) {\n\t\tgoto fail_args;\n\t}\n\th_obj = (duk_hobject *) h;\n\n\tif (duk_hobject_get_own_propdesc(thr, h_obj, h_key, &desc, 0 /*flags*/)) {\n\t\tduk_int_t virtual_idx;\n\t\tduk_bool_t rc;\n\n\t\t/* To use the shared helper need the virtual index. */\n\t\tDUK_ASSERT(desc.e_idx >= 0 || desc.a_idx >= 0);\n\t\tvirtual_idx = (desc.a_idx >= 0 ? desc.a_idx :\n\t\t               (duk_int_t) DUK_HOBJECT_GET_ASIZE(h_obj) + desc.e_idx);\n\n\t\tduk_debug_write_reply(thr);\n\t\trc = duk__debug_getprop_index(thr, heap, h_obj, (duk_uint_t) virtual_idx);\n\t\tDUK_ASSERT(rc == 1);\n\t\tDUK_UNREF(rc);\n\t\tduk_debug_write_eom(thr);\n\t} else {\n\t\tduk_debug_write_error_eom(thr, DUK_DBG_ERR_NOTFOUND, \"not found\");\n\t}\n\treturn;\n\n fail_args:\n\tduk_debug_write_error_eom(thr, DUK_DBG_ERR_UNKNOWN, \"invalid args\");\n}\n\nDUK_LOCAL void duk__debug_handle_get_obj_prop_desc_range(duk_hthread *thr, duk_heap *heap) {\n\tduk_heaphdr *h;\n\tduk_hobject *h_obj;\n\tduk_uint_t idx, idx_start, idx_end;\n\n\tDUK_D(DUK_DPRINT(\"debug command GetObjPropDescRange\"));\n\tDUK_UNREF(heap);\n\n\th = duk_debug_read_any_ptr(thr);\n\tidx_start = duk_debug_read_int(thr);\n\tidx_end = duk_debug_read_int(thr);\n\tif (h == NULL || DUK_HEAPHDR_GET_TYPE(h) != DUK_HTYPE_OBJECT) {\n\t\tgoto fail_args;\n\t}\n\th_obj = (duk_hobject *) h;\n\n\t/* The index range space is conceptually the array part followed by the\n\t * entry part.  Unlike normal enumeration all slots are exposed here as\n\t * is and return 'unused' if the slots are not in active use.  In particular\n\t * the array part is included for the full a_size regardless of what the\n\t * array .length is.\n\t */\n\n\tduk_debug_write_reply(thr);\n\tfor (idx = idx_start; idx < idx_end; idx++) {\n\t\tif (!duk__debug_getprop_index(thr, heap, h_obj, idx)) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tduk_debug_write_eom(thr);\n\treturn;\n\n fail_args:\n\tduk_debug_write_error_eom(thr, DUK_DBG_ERR_UNKNOWN, \"invalid args\");\n}\n\n#endif  /* DUK_USE_DEBUGGER_INSPECT */\n\n/*\n *  Process incoming debug requests\n *\n *  Individual request handlers can push temporaries on the value stack and\n *  rely on duk__debug_process_message() to restore the value stack top\n *  automatically.\n */\n\n/* Process one debug message.  Automatically restore value stack top to its\n * entry value, so that individual message handlers don't need exact value\n * stack handling which is convenient.\n */\nDUK_LOCAL void duk__debug_process_message(duk_hthread *thr) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_heap *heap;\n\tduk_uint8_t x;\n\tduk_int32_t cmd;\n\tduk_idx_t entry_top;\n\n\tDUK_ASSERT(thr != NULL);\n\theap = thr->heap;\n\tDUK_ASSERT(heap != NULL);\n\tDUK_UNREF(ctx);\n\n\tentry_top = duk_get_top(ctx);\n\n\tx = duk_debug_read_byte(thr);\n\tswitch (x) {\n\tcase DUK_DBG_IB_REQUEST: {\n\t\tcmd = duk_debug_read_int(thr);\n\t\tswitch (cmd) {\n\t\tcase DUK_DBG_CMD_BASICINFO: {\n\t\t\tduk__debug_handle_basic_info(thr, heap);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_DBG_CMD_TRIGGERSTATUS: {\n\t\t\tduk__debug_handle_trigger_status(thr, heap);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_DBG_CMD_PAUSE: {\n\t\t\tduk__debug_handle_pause(thr, heap);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_DBG_CMD_RESUME: {\n\t\t\tduk__debug_handle_resume(thr, heap);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_DBG_CMD_STEPINTO:\n\t\tcase DUK_DBG_CMD_STEPOVER:\n\t\tcase DUK_DBG_CMD_STEPOUT: {\n\t\t\tduk__debug_handle_step(thr, heap, cmd);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_DBG_CMD_LISTBREAK: {\n\t\t\tduk__debug_handle_list_break(thr, heap);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_DBG_CMD_ADDBREAK: {\n\t\t\tduk__debug_handle_add_break(thr, heap);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_DBG_CMD_DELBREAK: {\n\t\t\tduk__debug_handle_del_break(thr, heap);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_DBG_CMD_GETVAR: {\n\t\t\tduk__debug_handle_get_var(thr, heap);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_DBG_CMD_PUTVAR: {\n\t\t\tduk__debug_handle_put_var(thr, heap);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_DBG_CMD_GETCALLSTACK: {\n\t\t\tduk__debug_handle_get_call_stack(thr, heap);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_DBG_CMD_GETLOCALS: {\n\t\t\tduk__debug_handle_get_locals(thr, heap);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_DBG_CMD_EVAL: {\n\t\t\tduk__debug_handle_eval(thr, heap);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_DBG_CMD_DETACH: {\n\t\t\t/* The actual detached_cb call is postponed to message loop so\n\t\t\t * we don't need any special precautions here (just skip to EOM\n\t\t\t * on the already closed connection).\n\t\t\t */\n\t\t\tduk__debug_handle_detach(thr, heap);\n\t\t\tbreak;\n\t\t}\n#if defined(DUK_USE_DEBUGGER_DUMPHEAP)\n\t\tcase DUK_DBG_CMD_DUMPHEAP: {\n\t\t\tduk__debug_handle_dump_heap(thr, heap);\n\t\t\tbreak;\n\t\t}\n#endif  /* DUK_USE_DEBUGGER_DUMPHEAP */\n\t\tcase DUK_DBG_CMD_GETBYTECODE: {\n\t\t\tduk__debug_handle_get_bytecode(thr, heap);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_DBG_CMD_APPREQUEST: {\n\t\t\tduk__debug_handle_apprequest(thr, heap);\n\t\t\tbreak;\n\t\t}\n#if defined(DUK_USE_DEBUGGER_INSPECT)\n\t\tcase DUK_DBG_CMD_GETHEAPOBJINFO: {\n\t\t\tduk__debug_handle_get_heap_obj_info(thr, heap);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_DBG_CMD_GETOBJPROPDESC: {\n\t\t\tduk__debug_handle_get_obj_prop_desc(thr, heap);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_DBG_CMD_GETOBJPROPDESCRANGE: {\n\t\t\tduk__debug_handle_get_obj_prop_desc_range(thr, heap);\n\t\t\tbreak;\n\t\t}\n#endif  /* DUK_USE_DEBUGGER_INSPECT */\n\t\tdefault: {\n\t\t\tDUK_D(DUK_DPRINT(\"debug command unsupported: %d\", (int) cmd));\n\t\t\tduk_debug_write_error_eom(thr, DUK_DBG_ERR_UNSUPPORTED, \"unsupported command\");\n\t\t}\n\t\t}  /* switch cmd */\n\t\tbreak;\n\t}\n\tcase DUK_DBG_IB_REPLY: {\n\t\tDUK_D(DUK_DPRINT(\"debug reply, skipping\"));\n\t\tbreak;\n\t}\n\tcase DUK_DBG_IB_ERROR: {\n\t\tDUK_D(DUK_DPRINT(\"debug error, skipping\"));\n\t\tbreak;\n\t}\n\tcase DUK_DBG_IB_NOTIFY: {\n\t\tDUK_D(DUK_DPRINT(\"debug notify, skipping\"));\n\t\tbreak;\n\t}\n\tdefault: {\n\t\tDUK_D(DUK_DPRINT(\"invalid initial byte, drop connection: %d\", (int) x));\n\t\tgoto fail;\n\t}\n\t}  /* switch initial byte */\n\n\tDUK_ASSERT(duk_get_top(ctx) >= entry_top);\n\tduk_set_top(ctx, entry_top);\n\tduk__debug_skip_to_eom(thr);\n\treturn;\n\n fail:\n\tDUK_ASSERT(duk_get_top(ctx) >= entry_top);\n\tduk_set_top(ctx, entry_top);\n\tDUK__SET_CONN_BROKEN(thr, 1);\n\treturn;\n}\n\nDUK_LOCAL void duk__check_resend_status(duk_hthread *thr) {\n\tif (thr->heap->dbg_read_cb != NULL && thr->heap->dbg_state_dirty) {\n\t\tduk_debug_send_status(thr);\n\t\tthr->heap->dbg_state_dirty = 0;\n\t}\n}\n\nDUK_INTERNAL duk_bool_t duk_debug_process_messages(duk_hthread *thr, duk_bool_t no_block) {\n\tduk_context *ctx = (duk_context *) thr;\n#if defined(DUK_USE_ASSERTIONS)\n\tduk_idx_t entry_top;\n#endif\n\tduk_bool_t retval = 0;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_UNREF(ctx);\n\tDUK_ASSERT(thr->heap != NULL);\n#if defined(DUK_USE_ASSERTIONS)\n\tentry_top = duk_get_top(ctx);\n#endif\n\n\tDUK_D(DUK_DPRINT(\"process debug messages: read_cb=%s, no_block=%ld, detaching=%ld, processing=%ld\",\n\t                 thr->heap->dbg_read_cb ? \"not NULL\" : \"NULL\", (long) no_block,\n\t                 (long) thr->heap->dbg_detaching, (long) thr->heap->dbg_processing));\n\tDUK_DD(DUK_DDPRINT(\"top at entry: %ld\", (long) duk_get_top(ctx)));\n\n\t/* thr->heap->dbg_detaching may be != 0 if a debugger write outside\n\t * the message loop caused a transport error and detach1() to run.\n\t */\n\tDUK_ASSERT(thr->heap->dbg_detaching == 0 || thr->heap->dbg_detaching == 1);\n\tDUK_ASSERT(thr->heap->dbg_processing == 0);\n\tthr->heap->dbg_processing = 1;\n\n\t/* Ensure dirty state causes a Status even if never process any\n\t * messages.  This is expected by the bytecode executor when in\n\t * the running state.\n\t */\n\tduk__check_resend_status(thr);\n\n\tfor (;;) {\n\t\t/* Process messages until we're no longer paused or we peek\n\t\t * and see there's nothing to read right now.\n\t\t */\n\t\tDUK_DD(DUK_DDPRINT(\"top at loop top: %ld\", (long) duk_get_top(ctx)));\n\t\tDUK_ASSERT(thr->heap->dbg_processing == 1);\n\n\t\twhile (thr->heap->dbg_read_cb == NULL && thr->heap->dbg_detaching) {\n\t\t\t/* Detach is pending; can be triggered from outside the\n\t\t\t * debugger loop (e.g. Status notify write error) or by\n\t\t\t * previous message handling.  Call detached callback\n\t\t\t * here, in a controlled state, to ensure a possible\n\t\t\t * reattach inside the detached_cb is handled correctly.\n\t\t\t *\n\t\t\t * Recheck for detach in a while loop: an immediate\n\t\t\t * reattach involves a call to duk_debugger_attach()\n\t\t\t * which writes a debugger handshake line immediately\n\t\t\t * inside the API call.  If the transport write fails\n\t\t\t * for that handshake, we can immediately end up in a\n\t\t\t * \"transport broken, detaching\" case several times here.\n\t\t\t * Loop back until we're either cleanly attached or\n\t\t\t * fully detached.\n\t\t\t *\n\t\t\t * NOTE: Reset dbg_processing = 1 forcibly, in case we\n\t\t\t * re-attached; duk_debugger_attach() sets dbg_processing\n\t\t\t * to 0 at the moment.\n\t\t\t */\n\n\t\t\tDUK_D(DUK_DPRINT(\"detach pending (dbg_read_cb == NULL, dbg_detaching != 0), call detach2\"));\n\n\t\t\tduk__debug_do_detach2(thr->heap);\n\t\t\tthr->heap->dbg_processing = 1;  /* may be set to 0 by duk_debugger_attach() inside callback */\n\n\t\t\tDUK_D(DUK_DPRINT(\"after detach2 (and possible reattach): dbg_read_cb=%s, dbg_detaching=%ld\",\n\t\t\t                 thr->heap->dbg_read_cb ? \"not NULL\" : \"NULL\", (long) thr->heap->dbg_detaching));\n\t\t}\n\t\tDUK_ASSERT(thr->heap->dbg_detaching == 0);  /* true even with reattach */\n\t\tDUK_ASSERT(thr->heap->dbg_processing == 1);  /* even after a detach and possible reattach */\n\n\t\tif (thr->heap->dbg_read_cb == NULL) {\n\t\t\tDUK_D(DUK_DPRINT(\"debug connection broken (and not detaching), stop processing messages\"));\n\t\t\tbreak;\n\t\t}\n\n\t\tif (!DUK_HEAP_HAS_DEBUGGER_PAUSED(thr->heap) || no_block) {\n\t\t\tif (!duk_debug_read_peek(thr)) {\n\t\t\t\t/* Note: peek cannot currently trigger a detach\n\t\t\t\t * so the dbg_detaching == 0 assert outside the\n\t\t\t\t * loop is correct.\n\t\t\t\t */\n\t\t\t\tDUK_D(DUK_DPRINT(\"processing debug message, peek indicated no data, stop processing messages\"));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tDUK_D(DUK_DPRINT(\"processing debug message, peek indicated there is data, handle it\"));\n\t\t} else {\n\t\t\tDUK_D(DUK_DPRINT(\"paused, process debug message, blocking if necessary\"));\n\t\t}\n\n\t\tduk__check_resend_status(thr);\n\t\tduk__debug_process_message(thr);\n\t\tduk__check_resend_status(thr);\n\n\t\tretval = 1;  /* processed one or more messages */\n\t}\n\n\tDUK_ASSERT(thr->heap->dbg_detaching == 0);\n\tDUK_ASSERT(thr->heap->dbg_processing == 1);\n\tthr->heap->dbg_processing = 0;\n\n\t/* As an initial implementation, read flush after exiting the message\n\t * loop.  If transport is broken, this is a no-op (with debug logs).\n\t */\n\tduk_debug_read_flush(thr);  /* this cannot initiate a detach */\n\tDUK_ASSERT(thr->heap->dbg_detaching == 0);\n\n\tDUK_DD(DUK_DDPRINT(\"top at exit: %ld\", (long) duk_get_top(ctx)));\n\n#if defined(DUK_USE_ASSERTIONS)\n\t/* Easy to get wrong, so assert for it. */\n\tDUK_ASSERT(entry_top == duk_get_top(ctx));\n#endif\n\n\treturn retval;\n}\n\n/*\n *  Halt execution helper\n */\n\n/* Halt execution and enter a debugger message loop until execution is resumed\n * by the client.  PC for the current activation may be temporarily decremented\n * so that the \"current\" instruction will be shown by the client.  This helper\n * is callable from anywhere, also outside bytecode executor.\n */\n\nDUK_INTERNAL void duk_debug_halt_execution(duk_hthread *thr, duk_bool_t use_prev_pc) {\n\tduk_activation *act;\n\tduk_hcompfunc *fun;\n\tduk_instr_t *old_pc = NULL;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\tDUK_ASSERT(duk_debug_is_attached(thr->heap));\n\tDUK_ASSERT(thr->heap->dbg_processing == 0);\n\tDUK_ASSERT(!duk_debug_is_paused(thr->heap));\n\n\tduk_debug_set_paused(thr->heap);\n\n\tact = thr->callstack_curr;\n\n\t/* NOTE: act may be NULL if an error is thrown outside of any activation,\n\t * which may happen in the case of, e.g. syntax errors.\n\t */\n\n\t/* Decrement PC if that was requested, this requires a PC sync. */\n\tif (act != NULL) {\n\t\tduk_hthread_sync_currpc(thr);\n\t\told_pc = act->curr_pc;\n\t\tfun = (duk_hcompfunc *) DUK_ACT_GET_FUNC(act);\n\n\t\t/* Short circuit if is safe: if act->curr_pc != NULL, 'fun' is\n\t\t * guaranteed to be a non-NULL Ecmascript function.\n\t\t */\n\t\tDUK_ASSERT(act->curr_pc == NULL ||\n\t\t           (fun != NULL && DUK_HOBJECT_IS_COMPFUNC((duk_hobject *) fun)));\n\t\tif (use_prev_pc &&\n\t\t    act->curr_pc != NULL &&\n\t\t    act->curr_pc > DUK_HCOMPFUNC_GET_CODE_BASE(thr->heap, fun)) {\n\t\t\tact->curr_pc--;\n\t\t}\n\t}\n\n\t/* Process debug messages until we are no longer paused. */\n\n\t/* NOTE: This is a bit fragile.  It's important to ensure that\n\t * duk_debug_process_messages() never throws an error or\n\t * act->curr_pc will never be reset.\n\t */\n\n\tthr->heap->dbg_state_dirty = 1;\n\twhile (DUK_HEAP_HAS_DEBUGGER_PAUSED(thr->heap)) {\n\t\tDUK_ASSERT(duk_debug_is_attached(thr->heap));\n\t\tDUK_ASSERT(thr->heap->dbg_processing == 0);\n\t\tduk_debug_process_messages(thr, 0 /*no_block*/);\n\t}\n\n\t/* XXX: Decrementing and restoring act->curr_pc works now, but if the\n\t * debugger message loop gains the ability to adjust the current PC\n\t * (e.g. a forced jump) restoring the PC here will break.  Another\n\t * approach would be to use a state flag for the \"decrement 1 from\n\t * topmost activation's PC\" and take it into account whenever dealing\n\t * with PC values.\n\t */\n\tif (act != NULL) {\n\t\tact->curr_pc = old_pc;  /* restore PC */\n\t}\n}\n\n/*\n *  Breakpoint management\n */\n\nDUK_INTERNAL duk_small_int_t duk_debug_add_breakpoint(duk_hthread *thr, duk_hstring *filename, duk_uint32_t line) {\n\tduk_heap *heap;\n\tduk_breakpoint *b;\n\n\t/* Caller must trigger recomputation of active breakpoint list.  To\n\t * ensure stale values are not used if that doesn't happen, clear the\n\t * active breakpoint list here.\n\t */\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(filename != NULL);\n\theap = thr->heap;\n\tDUK_ASSERT(heap != NULL);\n\n\tif (heap->dbg_breakpoint_count >= DUK_HEAP_MAX_BREAKPOINTS) {\n\t\tDUK_D(DUK_DPRINT(\"failed to add breakpoint for %O:%ld, all breakpoint slots used\",\n\t\t                 (duk_heaphdr *) filename, (long) line));\n\t\treturn -1;\n\t}\n\theap->dbg_breakpoints_active[0] = (duk_breakpoint *) NULL;\n\tb = heap->dbg_breakpoints + (heap->dbg_breakpoint_count++);\n\tb->filename = filename;\n\tb->line = line;\n\tDUK_HSTRING_INCREF(thr, filename);\n\n\treturn heap->dbg_breakpoint_count - 1;  /* index */\n}\n\nDUK_INTERNAL duk_bool_t duk_debug_remove_breakpoint(duk_hthread *thr, duk_small_uint_t breakpoint_index) {\n\tduk_heap *heap;\n\tduk_hstring *h;\n\tduk_breakpoint *b;\n\tduk_size_t move_size;\n\n\t/* Caller must trigger recomputation of active breakpoint list.  To\n\t * ensure stale values are not used if that doesn't happen, clear the\n\t * active breakpoint list here.\n\t */\n\n\tDUK_ASSERT(thr != NULL);\n\theap = thr->heap;\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT(duk_debug_is_attached(thr->heap));\n\tDUK_ASSERT_DISABLE(breakpoint_index >= 0);  /* unsigned */\n\n\tif (breakpoint_index >= heap->dbg_breakpoint_count) {\n\t\tDUK_D(DUK_DPRINT(\"invalid breakpoint index: %ld\", (long) breakpoint_index));\n\t\treturn 0;\n\t}\n\tb = heap->dbg_breakpoints + breakpoint_index;\n\n\th = b->filename;\n\tDUK_ASSERT(h != NULL);\n\n\tmove_size = sizeof(duk_breakpoint) * (heap->dbg_breakpoint_count - breakpoint_index - 1);\n\tif (move_size > 0) {\n\t\tDUK_MEMMOVE((void *) b,\n\t\t            (const void *) (b + 1),\n\t\t            (size_t) move_size);\n\t}\n\theap->dbg_breakpoint_count--;\n\theap->dbg_breakpoints_active[0] = (duk_breakpoint *) NULL;\n\n\tDUK_HSTRING_DECREF(thr, h);  /* side effects */\n\tDUK_UNREF(h);  /* w/o refcounting */\n\n\t/* Breakpoint entries above the used area are left as garbage. */\n\n\treturn 1;\n}\n\n/*\n *  Misc state management\n */\n\nDUK_INTERNAL duk_bool_t duk_debug_is_attached(duk_heap *heap) {\n\treturn (heap->dbg_read_cb != NULL);\n}\n\nDUK_INTERNAL duk_bool_t duk_debug_is_paused(duk_heap *heap) {\n\treturn (DUK_HEAP_HAS_DEBUGGER_PAUSED(heap) != 0);\n}\n\nDUK_INTERNAL void duk_debug_set_paused(duk_heap *heap) {\n\tif (duk_debug_is_paused(heap)) {\n\t\tDUK_D(DUK_DPRINT(\"trying to set paused state when already paused, ignoring\"));\n\t} else {\n\t\tDUK_HEAP_SET_DEBUGGER_PAUSED(heap);\n\t\theap->dbg_state_dirty = 1;\n\t\tduk_debug_clear_step_state(heap);\n\t\tDUK_ASSERT(heap->ms_running == 0);  /* debugger can't be triggered within mark-and-sweep */\n\t\theap->ms_running = 1;  /* prevent mark-and-sweep, prevent refzero queueing */\n\t\theap->ms_prevent_count++;\n\t\tDUK_ASSERT(heap->ms_prevent_count != 0);  /* Wrap. */\n\t\tDUK_ASSERT(heap->heap_thread != NULL);\n\t}\n}\n\nDUK_INTERNAL void duk_debug_clear_paused(duk_heap *heap) {\n\tif (duk_debug_is_paused(heap)) {\n\t\tDUK_HEAP_CLEAR_DEBUGGER_PAUSED(heap);\n\t\theap->dbg_state_dirty = 1;\n\t\tduk_debug_clear_step_state(heap);\n\t\tDUK_ASSERT(heap->ms_running == 1);\n\t\tDUK_ASSERT(heap->ms_prevent_count > 0);\n\t\theap->ms_prevent_count--;\n\t\theap->ms_running = 0;\n\t\tDUK_ASSERT(heap->heap_thread != NULL);\n\t} else {\n\t\tDUK_D(DUK_DPRINT(\"trying to clear paused state when not paused, ignoring\"));\n\t}\n}\n\nDUK_INTERNAL void duk_debug_clear_step_state(duk_heap *heap) {\n\theap->dbg_step_type = DUK_STEP_TYPE_NONE;\n\theap->dbg_step_thread = NULL;\n\theap->dbg_step_csindex = 0;\n\theap->dbg_step_startline = 0;\n}\n\n#else  /* DUK_USE_DEBUGGER_SUPPORT */\n\n/* No debugger support. */\n\n#endif  /* DUK_USE_DEBUGGER_SUPPORT */\n\n/* automatic undefs */\n#undef DUK__SET_CONN_BROKEN\n/*\n *  Augmenting errors at their creation site and their throw site.\n *\n *  When errors are created, traceback data is added by built-in code\n *  and a user error handler (if defined) can process or replace the\n *  error.  Similarly, when errors are thrown, a user error handler\n *  (if defined) can process or replace the error.\n *\n *  Augmentation and other processing at error creation time is nice\n *  because an error is only created once, but it may be thrown and\n *  rethrown multiple times.  User error handler registered for processing\n *  an error at its throw site must be careful to handle rethrowing in\n *  a useful manner.\n *\n *  Error augmentation may throw an internal error (e.g. alloc error).\n *\n *  Ecmascript allows throwing any values, so all values cannot be\n *  augmented.  Currently, the built-in augmentation at error creation\n *  only augments error values which are Error instances (= have the\n *  built-in Error.prototype in their prototype chain) and are also\n *  extensible.  User error handlers have no limitations in this respect.\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Helper for calling a user error handler.\n *\n *  'thr' must be the currently active thread; the error handler is called\n *  in its context.  The valstack of 'thr' must have the error value on\n *  top, and will be replaced by another error value based on the return\n *  value of the error handler.\n *\n *  The helper calls duk_handle_call() recursively in protected mode.\n *  Before that call happens, no longjmps should happen; as a consequence,\n *  we must assume that the valstack contains enough temporary space for\n *  arguments and such.\n *\n *  While the error handler runs, any errors thrown will not trigger a\n *  recursive error handler call (this is implemented using a heap level\n *  flag which will \"follow\" through any coroutines resumed inside the\n *  error handler).  If the error handler is not callable or throws an\n *  error, the resulting error replaces the original error (for Duktape\n *  internal errors, duk_error_throw.c further substitutes this error with\n *  a DoubleError which is not ideal).  This would be easy to change and\n *  even signal to the caller.\n *\n *  The user error handler is stored in 'Duktape.errCreate' or\n *  'Duktape.errThrow' depending on whether we're augmenting the error at\n *  creation or throw time.  There are several alternatives to this approach,\n *  see doc/error-objects.rst for discussion.\n *\n *  Note: since further longjmp()s may occur while calling the error handler\n *  (for many reasons, e.g. a labeled 'break' inside the handler), the\n *  caller can make no assumptions on the thr->heap->lj state after the\n *  call (this affects especially duk_error_throw.c).  This is not an issue\n *  as long as the caller writes to the lj state only after the error handler\n *  finishes.\n */\n\n#if defined(DUK_USE_ERRTHROW) || defined(DUK_USE_ERRCREATE)\nDUK_LOCAL void duk__err_augment_user(duk_hthread *thr, duk_small_uint_t stridx_cb) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_tval *tv_hnd;\n\tduk_small_uint_t call_flags;\n\tduk_int_t rc;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\tDUK_ASSERT_STRIDX_VALID(stridx_cb);\n\n\tif (DUK_HEAP_HAS_ERRHANDLER_RUNNING(thr->heap)) {\n\t\tDUK_DD(DUK_DDPRINT(\"recursive call to error handler, ignore\"));\n\t\treturn;\n\t}\n\n\t/*\n\t *  Check whether or not we have an error handler.\n\t *\n\t *  We must be careful of not triggering an error when looking up the\n\t *  property.  For instance, if the property is a getter, we don't want\n\t *  to call it, only plain values are allowed.  The value, if it exists,\n\t *  is not checked.  If the value is not a function, a TypeError happens\n\t *  when it is called and that error replaces the original one.\n\t */\n\n\tDUK_ASSERT_VALSTACK_SPACE(thr, 4);  /* 3 entries actually needed below */\n\n\t/* [ ... errval ] */\n\n\tif (thr->builtins[DUK_BIDX_DUKTAPE] == NULL) {\n\t\t/* When creating built-ins, some of the built-ins may not be set\n\t\t * and we want to tolerate that when throwing errors.\n\t\t */\n\t\tDUK_DD(DUK_DDPRINT(\"error occurred when DUK_BIDX_DUKTAPE is NULL, ignoring\"));\n\t\treturn;\n\t}\n\ttv_hnd = duk_hobject_find_existing_entry_tval_ptr(thr->heap,\n\t                                                  thr->builtins[DUK_BIDX_DUKTAPE],\n\t                                                  DUK_HTHREAD_GET_STRING(thr, stridx_cb));\n\tif (tv_hnd == NULL) {\n\t\tDUK_DD(DUK_DDPRINT(\"error handler does not exist or is not a plain value: %!T\",\n\t\t                   (duk_tval *) tv_hnd));\n\t\treturn;\n\t}\n\tDUK_DDD(DUK_DDDPRINT(\"error handler dump (callability not checked): %!T\",\n\t                     (duk_tval *) tv_hnd));\n\tduk_push_tval(ctx, tv_hnd);\n\n\t/* [ ... errval errhandler ] */\n\n\tduk_insert(ctx, -2);  /* -> [ ... errhandler errval ] */\n\tduk_push_undefined(ctx);\n\tduk_insert(ctx, -2);  /* -> [ ... errhandler undefined(= this) errval ] */\n\n\t/* [ ... errhandler undefined errval ] */\n\n\t/*\n\t *  DUK_CALL_FLAG_IGNORE_RECLIMIT causes duk_handle_call() to ignore C\n\t *  recursion depth limit (and won't increase it either).  This is\n\t *  dangerous, but useful because it allows the error handler to run\n\t *  even if the original error is caused by C recursion depth limit.\n\t *\n\t *  The heap level DUK_HEAP_FLAG_ERRHANDLER_RUNNING is set for the\n\t *  duration of the error handler and cleared afterwards.  This flag\n\t *  prevents the error handler from running recursively.  The flag is\n\t *  heap level so that the flag properly controls even coroutines\n\t *  launched by an error handler.  Since the flag is heap level, it is\n\t *  critical to restore it correctly.\n\t *\n\t *  We ignore errors now: a success return and an error value both\n\t *  replace the original error value.  (This would be easy to change.)\n\t */\n\n\tDUK_ASSERT(!DUK_HEAP_HAS_ERRHANDLER_RUNNING(thr->heap));  /* since no recursive error handler calls */\n\tDUK_HEAP_SET_ERRHANDLER_RUNNING(thr->heap);\n\n\tcall_flags = DUK_CALL_FLAG_IGNORE_RECLIMIT;  /* ignore reclimit, not constructor */\n\n\trc = duk_handle_call_protected(thr,\n\t                               1,            /* num args */\n\t                               call_flags);  /* call_flags */\n\tDUK_UNREF(rc);  /* no need to check now: both success and error are OK */\n\n\tDUK_ASSERT(DUK_HEAP_HAS_ERRHANDLER_RUNNING(thr->heap));\n\tDUK_HEAP_CLEAR_ERRHANDLER_RUNNING(thr->heap);\n\n\t/* [ ... errval ] */\n}\n#endif  /* DUK_USE_ERRTHROW || DUK_USE_ERRCREATE */\n\n/*\n *  Add ._Tracedata to an error on the stack top.\n */\n\n#if defined(DUK_USE_TRACEBACKS)\nDUK_LOCAL void duk__add_traceback(duk_hthread *thr, duk_hthread *thr_callstack, const char *c_filename, duk_int_t c_line, duk_bool_t noblame_fileline) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_small_uint_t depth;\n\tduk_int_t i, i_min;\n\tduk_int_t arr_size;\n\tduk_harray *a;\n\tduk_tval *tv;\n\tduk_hstring *s;\n\tduk_uint32_t u32;\n\tduk_double_t d;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr_callstack != NULL);\n\tDUK_ASSERT(ctx != NULL);\n\n\t/* [ ... error ] */\n\n\t/*\n\t *  The traceback format is pretty arcane in an attempt to keep it compact\n\t *  and cheap to create.  It may change arbitrarily from version to version.\n\t *  It should be decoded/accessed through version specific accessors only.\n\t *\n\t *  See doc/error-objects.rst.\n\t */\n\n\tDUK_DDD(DUK_DDDPRINT(\"adding traceback to object: %!T\",\n\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\n\t/* Preallocate array to correct size, so that we can just write out\n\t * the _Tracedata values into the array part.\n\t */\n\tdepth = DUK_USE_TRACEBACK_DEPTH;\n\tarr_size = (duk_int_t) (thr_callstack->callstack_top <= depth ? thr_callstack->callstack_top : depth) * 2;\n\tif (thr->compile_ctx != NULL && thr->compile_ctx->h_filename != NULL) {\n\t\tarr_size += 2;\n\t}\n\tif (c_filename) {\n\t\t/* We need the C filename to be interned before getting the\n\t\t * array part pointer to avoid any GC interference while the\n\t\t * array part is populated.\n\t\t */\n\t\tduk_push_string(ctx, c_filename);\n\t\tarr_size += 2;\n\t}\n\n\tDUK_D(DUK_DPRINT(\"preallocated _Tracedata to %ld items\", (long) arr_size));\n\ta = duk_push_harray_with_size(ctx, (duk_uint32_t) arr_size);  /* XXX: call which returns array part pointer directly */\n\tDUK_ASSERT(a != NULL);\n\ttv = DUK_HOBJECT_A_GET_BASE(thr->heap, (duk_hobject *) a);\n\tDUK_ASSERT(tv != NULL || arr_size == 0);\n\n\t/* Compiler SyntaxErrors (and other errors) come first, and are\n\t * blamed by default (not flagged \"noblame\").\n\t */\n\tif (thr->compile_ctx != NULL && thr->compile_ctx->h_filename != NULL) {\n\t\ts = thr->compile_ctx->h_filename;\n\t\tDUK_TVAL_SET_STRING(tv, s);\n\t\tDUK_HSTRING_INCREF(thr, s);\n\t\ttv++;\n\n\t\tu32 = (duk_uint32_t) thr->compile_ctx->curr_token.start_line;  /* (flags<<32) + (line), flags = 0 */\n\t\tDUK_TVAL_SET_U32(tv, u32);\n\t\ttv++;\n\t}\n\n\t/* Filename/line from C macros (__FILE__, __LINE__) are added as an\n\t * entry with a special format: (string, number).  The number contains\n\t * the line and flags.\n\t */\n\n\t/* [ ... error c_filename? arr ] */\n\n\tif (c_filename) {\n\t\tDUK_ASSERT(DUK_TVAL_IS_STRING(thr->valstack_top - 2));\n\t\ts = DUK_TVAL_GET_STRING(thr->valstack_top - 2);  /* interned c_filename */\n\t\tDUK_ASSERT(s != NULL);\n\t\tDUK_TVAL_SET_STRING(tv, s);\n\t\tDUK_HSTRING_INCREF(thr, s);\n\t\ttv++;\n\n\t\td = (noblame_fileline ? ((duk_double_t) DUK_TB_FLAG_NOBLAME_FILELINE) * DUK_DOUBLE_2TO32 : 0.0) +\n\t\t    (duk_double_t) c_line;\n\t\tDUK_TVAL_SET_DOUBLE(tv, d);\n\t\ttv++;\n\t}\n\n\t/* traceback depth doesn't take into account the filename/line\n\t * special handling above (intentional)\n\t */\n\tdepth = DUK_USE_TRACEBACK_DEPTH;\n\ti_min = (thr_callstack->callstack_top > (duk_size_t) depth ? (duk_int_t) (thr_callstack->callstack_top - depth) : 0);\n\tDUK_ASSERT(i_min >= 0);\n\n\t/* [ ... error c_filename? arr ] */\n\n\tDUK_ASSERT(thr_callstack->callstack_top <= DUK_INT_MAX);  /* callstack limits */\n\tfor (i = (duk_int_t) (thr_callstack->callstack_top - 1); i >= i_min; i--) {\n\t\tduk_uint32_t pc;\n\t\tduk_tval *tv_src;\n\n\t\t/*\n\t\t *  Note: each API operation potentially resizes the callstack,\n\t\t *  so be careful to re-lookup after every operation.  Currently\n\t\t *  these is no issue because we don't store a temporary 'act'\n\t\t *  pointer at all.  (This would be a non-issue if we operated\n\t\t *  directly on the array part.)\n\t\t */\n\n\t\t/* [... arr] */\n\n\t\tDUK_ASSERT_DISABLE(thr_callstack->callstack[i].pc >= 0);  /* unsigned */\n\n\t\t/* Add function object. */\n\t\ttv_src = &(thr_callstack->callstack + i)->tv_func;  /* object (function) or lightfunc */\n\t\tDUK_ASSERT(DUK_TVAL_IS_OBJECT(tv_src) || DUK_TVAL_IS_LIGHTFUNC(tv_src));\n\t\tDUK_TVAL_SET_TVAL(tv, tv_src);\n\t\tDUK_TVAL_INCREF(thr, tv);\n\t\ttv++;\n\n\t\t/* Add a number containing: pc, activation flags.\n\t\t *\n\t\t * PC points to next instruction, find offending PC.  Note that\n\t\t * PC == 0 for native code.\n\t\t */\n\t\tpc = duk_hthread_get_act_prev_pc(thr_callstack, thr_callstack->callstack + i);\n\t\tDUK_ASSERT_DISABLE(pc >= 0);  /* unsigned */\n\t\tDUK_ASSERT((duk_double_t) pc < DUK_DOUBLE_2TO32);  /* assume PC is at most 32 bits and non-negative */\n\t\td = ((duk_double_t) thr_callstack->callstack[i].flags) * DUK_DOUBLE_2TO32 + (duk_double_t) pc;\n\t\tDUK_TVAL_SET_DOUBLE(tv, d);\n\t\ttv++;\n\t}\n\n\tDUK_ASSERT((duk_uint32_t) (tv - DUK_HOBJECT_A_GET_BASE(thr->heap, (duk_hobject *) a)) == a->length);\n\tDUK_ASSERT(a->length == (duk_uint32_t) arr_size);\n\n\t/* [ ... error c_filename? arr ] */\n\n\tif (c_filename) {\n\t\tduk_remove_m2(ctx);\n\t}\n\n\t/* [ ... error arr ] */\n\n\tduk_xdef_prop_stridx_short_wec(ctx, -2, DUK_STRIDX_INT_TRACEDATA);  /* -> [ ... error ] */\n}\n#endif  /* DUK_USE_TRACEBACKS */\n\n/*\n *  Add .fileName and .lineNumber to an error on the stack top.\n */\n\n#if defined(DUK_USE_AUGMENT_ERROR_CREATE) && !defined(DUK_USE_TRACEBACKS)\nDUK_LOCAL void duk__add_fileline(duk_hthread *thr, duk_hthread *thr_callstack, const char *c_filename, duk_int_t c_line, duk_bool_t noblame_fileline) {\n\tduk_context *ctx;\n#if defined(DUK_USE_ASSERTIONS)\n\tduk_int_t entry_top;\n#endif\n\n\tctx = (duk_context *) thr;\n#if defined(DUK_USE_ASSERTIONS)\n\tentry_top = duk_get_top(ctx);\n#endif\n\n\t/*\n\t *  If tracebacks are disabled, 'fileName' and 'lineNumber' are added\n\t *  as plain own properties.  Since Error.prototype has accessors of\n\t *  the same name, we need to define own properties directly (cannot\n\t *  just use e.g. duk_put_prop_stridx).  Existing properties are not\n\t *  overwritten in case they already exist.\n\t */\n\n\tif (thr->compile_ctx != NULL && thr->compile_ctx->h_filename != NULL) {\n\t\t/* Compiler SyntaxError (or other error) gets the primary blame.\n\t\t * Currently no flag to prevent blaming.\n\t\t */\n\t\tduk_push_uint(ctx, (duk_uint_t) thr->compile_ctx->curr_token.start_line);\n\t\tduk_push_hstring(ctx, thr->compile_ctx->h_filename);\n\t} else if (c_filename && !noblame_fileline) {\n\t\t/* C call site gets blamed next, unless flagged not to do so.\n\t\t * XXX: file/line is disabled in minimal builds, so disable this\n\t\t * too when appropriate.\n\t\t */\n\t\tduk_push_int(ctx, c_line);\n\t\tduk_push_string(ctx, c_filename);\n\t} else {\n\t\t/* Finally, blame the innermost callstack entry which has a\n\t\t * .fileName property.\n\t\t */\n\t\tduk_small_uint_t depth;\n\t\tduk_int_t i, i_min;\n\t\tduk_uint32_t ecma_line;\n\n\t\tdepth = DUK_USE_TRACEBACK_DEPTH;\n\t\ti_min = (thr_callstack->callstack_top > (duk_size_t) depth ? (duk_int_t) (thr_callstack->callstack_top - depth) : 0);\n\t\tDUK_ASSERT(i_min >= 0);\n\n\t\tDUK_ASSERT(thr_callstack->callstack_top <= DUK_INT_MAX);  /* callstack limits */\n\t\tfor (i = (duk_int_t) (thr_callstack->callstack_top - 1); i >= i_min; i--) {\n\t\t\tduk_activation *act;\n\t\t\tduk_hobject *func;\n\t\t\tduk_uint32_t pc;\n\n\t\t\tDUK_UNREF(pc);\n\t\t\tact = thr_callstack->callstack + i;\n\t\t\tDUK_ASSERT(act >= thr_callstack->callstack && act < thr_callstack->callstack + thr_callstack->callstack_size);\n\n\t\t\tfunc = DUK_ACT_GET_FUNC(act);\n\t\t\tif (func == NULL) {\n\t\t\t\t/* Lightfunc, not blamed now. */\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t/* PC points to next instruction, find offending PC,\n\t\t\t * PC == 0 for native code.\n\t\t\t */\n\t\t\tpc = duk_hthread_get_act_prev_pc(thr, act);  /* thr argument only used for thr->heap, so specific thread doesn't matter */\n\t\t\tDUK_ASSERT_DISABLE(pc >= 0);  /* unsigned */\n\t\t\tDUK_ASSERT((duk_double_t) pc < DUK_DOUBLE_2TO32);  /* assume PC is at most 32 bits and non-negative */\n\t\t\tact = NULL;  /* invalidated by pushes, so get out of the way */\n\n\t\t\tduk_push_hobject(ctx, func);\n\n\t\t\t/* [ ... error func ] */\n\n\t\t\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_FILE_NAME);\n\t\t\tif (!duk_is_string_notsymbol(ctx, -1)) {\n\t\t\t\tduk_pop_2(ctx);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t/* [ ... error func fileName ] */\n\n\t\t\tecma_line = 0;\n#if defined(DUK_USE_PC2LINE)\n\t\t\tif (DUK_HOBJECT_IS_COMPFUNC(func)) {\n\t\t\t\tecma_line = duk_hobject_pc2line_query(ctx, -2, (duk_uint_fast32_t) pc);\n\t\t\t} else {\n\t\t\t\t/* Native function, no relevant lineNumber. */\n\t\t\t}\n#endif  /* DUK_USE_PC2LINE */\n\t\t\tduk_push_u32(ctx, ecma_line);\n\n\t\t\t/* [ ... error func fileName lineNumber ] */\n\n\t\t\tduk_replace(ctx, -3);\n\n\t\t\t/* [ ... error lineNumber fileName ] */\n\t\t\tgoto define_props;\n\t\t}\n\n\t\t/* No activation matches, use undefined for both .fileName and\n\t\t * .lineNumber (matches what we do with a _Tracedata based\n\t\t * no-match lookup.\n\t\t */\n\t\tduk_push_undefined(ctx);\n\t\tduk_push_undefined(ctx);\n\t}\n\n define_props:\n\t/* [ ... error lineNumber fileName ] */\n#if defined(DUK_USE_ASSERTIONS)\n\tDUK_ASSERT(duk_get_top(ctx) == entry_top + 2);\n#endif\n\tduk_xdef_prop_stridx_short(ctx, -3, DUK_STRIDX_FILE_NAME, DUK_PROPDESC_FLAGS_C | DUK_PROPDESC_FLAG_NO_OVERWRITE);\n\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_LINE_NUMBER, DUK_PROPDESC_FLAGS_C | DUK_PROPDESC_FLAG_NO_OVERWRITE);\n}\n#endif  /* DUK_USE_AUGMENT_ERROR_CREATE && !DUK_USE_TRACEBACKS */\n\n/*\n *  Add line number to a compiler error.\n */\n\n#if defined(DUK_USE_AUGMENT_ERROR_CREATE)\nDUK_LOCAL void duk__add_compiler_error_line(duk_hthread *thr) {\n\tduk_context *ctx;\n\n\t/* Append a \"(line NNN)\" to the \"message\" property of any error\n\t * thrown during compilation.  Usually compilation errors are\n\t * SyntaxErrors but they can also be out-of-memory errors and\n\t * the like.\n\t */\n\n\t/* [ ... error ] */\n\n\tctx = (duk_context *) thr;\n\tDUK_ASSERT(duk_is_object(ctx, -1));\n\n\tif (!(thr->compile_ctx != NULL && thr->compile_ctx->h_filename != NULL)) {\n\t\treturn;\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"compile error, before adding line info: %!T\",\n\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\n\tif (duk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_MESSAGE)) {\n\t\tduk_push_sprintf(ctx, \" (line %ld)\", (long) thr->compile_ctx->curr_token.start_line);\n\t\tduk_concat(ctx, 2);\n\t\tduk_put_prop_stridx_short(ctx, -2, DUK_STRIDX_MESSAGE);\n\t} else {\n\t\tduk_pop(ctx);\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"compile error, after adding line info: %!T\",\n\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n}\n#endif  /* DUK_USE_AUGMENT_ERROR_CREATE */\n\n/*\n *  Augment an error being created using Duktape specific properties\n *  like _Tracedata or .fileName/.lineNumber.\n */\n\n#if defined(DUK_USE_AUGMENT_ERROR_CREATE)\nDUK_LOCAL void duk__err_augment_builtin_create(duk_hthread *thr, duk_hthread *thr_callstack, const char *c_filename, duk_int_t c_line, duk_small_int_t noblame_fileline, duk_hobject *obj) {\n\tduk_context *ctx = (duk_context *) thr;\n#if defined(DUK_USE_ASSERTIONS)\n\tduk_int_t entry_top;\n#endif\n\n#if defined(DUK_USE_ASSERTIONS)\n\tentry_top = duk_get_top(ctx);\n#endif\n\tDUK_ASSERT(obj != NULL);\n\n\tDUK_UNREF(obj);  /* unreferenced w/o tracebacks */\n\tDUK_UNREF(ctx);  /* unreferenced w/o asserts */\n\n\tduk__add_compiler_error_line(thr);\n\n#if defined(DUK_USE_TRACEBACKS)\n\t/* If tracebacks are enabled, the '_Tracedata' property is the only\n\t * thing we need: 'fileName' and 'lineNumber' are virtual properties\n\t * which use '_Tracedata'.\n\t */\n\tif (duk_hobject_hasprop_raw(thr, obj, DUK_HTHREAD_STRING_INT_TRACEDATA(thr))) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"error value already has a '_Tracedata' property, not modifying it\"));\n\t} else {\n\t\tduk__add_traceback(thr, thr_callstack, c_filename, c_line, noblame_fileline);\n\t}\n#else\n\t/* Without tracebacks the concrete .fileName and .lineNumber need\n\t * to be added directly.\n\t */\n\tduk__add_fileline(thr, thr_callstack, c_filename, c_line, noblame_fileline);\n#endif\n\n#if defined(DUK_USE_ASSERTIONS)\n\tDUK_ASSERT(duk_get_top(ctx) == entry_top);\n#endif\n}\n#endif  /* DUK_USE_AUGMENT_ERROR_CREATE */\n\n/*\n *  Augment an error at creation time with _Tracedata/fileName/lineNumber\n *  and allow a user error handler (if defined) to process/replace the error.\n *  The error to be augmented is at the stack top.\n *\n *  thr: thread containing the error value\n *  thr_callstack: thread which should be used for generating callstack etc.\n *  c_filename: C __FILE__ related to the error\n *  c_line: C __LINE__ related to the error\n *  noblame_fileline: if true, don't fileName/line as error source, otherwise use traceback\n *                    (needed because user code filename/line are reported but internal ones\n *                    are not)\n *\n *  XXX: rename noblame_fileline to flags field; combine it to some existing\n *  field (there are only a few call sites so this may not be worth it).\n */\n\n#if defined(DUK_USE_AUGMENT_ERROR_CREATE)\nDUK_INTERNAL void duk_err_augment_error_create(duk_hthread *thr, duk_hthread *thr_callstack, const char *c_filename, duk_int_t c_line, duk_bool_t noblame_fileline) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hobject *obj;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr_callstack != NULL);\n\tDUK_ASSERT(ctx != NULL);\n\n\t/* [ ... error ] */\n\n\t/*\n\t *  Criteria for augmenting:\n\t *\n\t *   - augmentation enabled in build (naturally)\n\t *   - error value internal prototype chain contains the built-in\n\t *     Error prototype object (i.e. 'val instanceof Error')\n\t *\n\t *  Additional criteria for built-in augmenting:\n\t *\n\t *   - error value is an extensible object\n\t */\n\n\tobj = duk_get_hobject(ctx, -1);\n\tif (!obj) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"value is not an object, skip both built-in and user augment\"));\n\t\treturn;\n\t}\n\tif (!duk_hobject_prototype_chain_contains(thr, obj, thr->builtins[DUK_BIDX_ERROR_PROTOTYPE], 1 /*ignore_loop*/)) {\n\t\t/* If the value has a prototype loop, it's critical not to\n\t\t * throw here.  Instead, assume the value is not to be\n\t\t * augmented.\n\t\t */\n\t\tDUK_DDD(DUK_DDDPRINT(\"value is not an error instance, skip both built-in and user augment\"));\n\t\treturn;\n\t}\n\tif (DUK_HOBJECT_HAS_EXTENSIBLE(obj)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"error meets criteria, built-in augment\"));\n\t\tduk__err_augment_builtin_create(thr, thr_callstack, c_filename, c_line, noblame_fileline, obj);\n\t} else {\n\t\tDUK_DDD(DUK_DDDPRINT(\"error does not meet criteria, no built-in augment\"));\n\t}\n\n\t/* [ ... error ] */\n\n#if defined(DUK_USE_ERRCREATE)\n\tduk__err_augment_user(thr, DUK_STRIDX_ERR_CREATE);\n#endif\n}\n#endif  /* DUK_USE_AUGMENT_ERROR_CREATE */\n\n/*\n *  Augment an error at throw time; allow a user error handler (if defined)\n *  to process/replace the error.  The error to be augmented is at the\n *  stack top.\n */\n\n#if defined(DUK_USE_AUGMENT_ERROR_THROW)\nDUK_INTERNAL void duk_err_augment_error_throw(duk_hthread *thr) {\n#if defined(DUK_USE_ERRTHROW)\n\tduk__err_augment_user(thr, DUK_STRIDX_ERR_THROW);\n#endif  /* DUK_USE_ERRTHROW */\n}\n#endif  /* DUK_USE_AUGMENT_ERROR_THROW */\n/*\n *  Do a longjmp call, calling the fatal error handler if no\n *  catchpoint exists.\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_PREFER_SIZE)\nDUK_LOCAL void duk__uncaught_minimal(duk_hthread *thr) {\n\t(void) duk_fatal((duk_context *) thr, \"uncaught error\");\n}\n#endif\n\n#if 0\nDUK_LOCAL void duk__uncaught_readable(duk_hthread *thr) {\n\tconst char *summary;\n\tchar buf[64];\n\n\tsummary = duk_push_string_tval_readable((duk_context *) thr, &thr->heap->lj.value1);\n\tDUK_SNPRINTF(buf, sizeof(buf), \"uncaught: %s\", summary);\n\tbuf[sizeof(buf) - 1] = (char) 0;\n\t(void) duk_fatal((duk_context *) thr, (const char *) buf);\n}\n#endif\n\n#if !defined(DUK_USE_PREFER_SIZE)\nDUK_LOCAL void duk__uncaught_error_aware(duk_hthread *thr) {\n\tconst char *summary;\n\tchar buf[64];\n\n\tsummary = duk_push_string_tval_readable_error((duk_context *) thr, &thr->heap->lj.value1);\n\tDUK_ASSERT(summary != NULL);\n\tDUK_SNPRINTF(buf, sizeof(buf), \"uncaught: %s\", summary);\n\tbuf[sizeof(buf) - 1] = (char) 0;\n\t(void) duk_fatal((duk_context *) thr, (const char *) buf);\n}\n#endif\n\nDUK_INTERNAL void duk_err_longjmp(duk_hthread *thr) {\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\n\tDUK_DD(DUK_DDPRINT(\"longjmp error: type=%d iserror=%d value1=%!T value2=%!T\",\n\t                   (int) thr->heap->lj.type, (int) thr->heap->lj.iserror,\n\t                   &thr->heap->lj.value1, &thr->heap->lj.value2));\n\n\t/* Prevent finalizer execution during error handling.  All error\n\t * handling sites will process pending finalizers once error handling\n\t * is complete and we're ready for the side effects.  Does not prevent\n\t * refzero freeing or mark-and-sweep during error handling.\n\t *\n\t * NOTE: when we come here some calling code may have used DECREF\n\t * NORZ macros without an explicit DUK_REFZERO_CHECK_xxx() call.\n\t * We don't want to do it here because it would just check for\n\t * pending finalizers and we prevent that explicitly.  Instead,\n\t * the error catcher will run the finalizers once error handling\n\t * is complete.\n\t */\n\n\tDUK_ASSERT_LJSTATE_SET(thr->heap);\n\n\tthr->heap->pf_prevent_count++;\n\tDUK_ASSERT(thr->heap->pf_prevent_count != 0);  /* Wrap. */\n\n#if defined(DUK_USE_ASSERTIONS)\n\t/* XXX: set this immediately when longjmp state is set */\n\tDUK_ASSERT(thr->heap->error_not_allowed == 0);  /* Detect error within critical section. */\n\tthr->heap->error_not_allowed = 1;\n#endif\n\n\tDUK_DD(DUK_DDPRINT(\"about to longjmp, pf_prevent_count=%ld\", (long) thr->heap->pf_prevent_count));\n\n#if !defined(DUK_USE_CPP_EXCEPTIONS)\n\t/* If we don't have a jmpbuf_ptr, there is little we can do except\n\t * cause a fatal error.  The caller's expectation is that we never\n\t * return.\n\t *\n\t * With C++ exceptions we now just propagate an uncaught error\n\t * instead of invoking the fatal error handler.  Because there's\n\t * a dummy jmpbuf for C++ exceptions now, this could be changed.\n\t */\n\tif (!thr->heap->lj.jmpbuf_ptr) {\n\t\tDUK_D(DUK_DPRINT(\"uncaught error: type=%d iserror=%d value1=%!T value2=%!T\",\n\t\t                 (int) thr->heap->lj.type, (int) thr->heap->lj.iserror,\n\t\t                 &thr->heap->lj.value1, &thr->heap->lj.value2));\n\n#if defined(DUK_USE_PREFER_SIZE)\n\t\tduk__uncaught_minimal(thr);\n#else\n\t\tduk__uncaught_error_aware(thr);\n#endif\n\t\tDUK_UNREACHABLE();\n\t}\n#endif  /* DUK_USE_CPP_EXCEPTIONS */\n\n#if defined(DUK_USE_CPP_EXCEPTIONS)\n\t{\n\t\tduk_internal_exception exc;  /* dummy */\n\t\tthrow exc;\n\t}\n#else  /* DUK_USE_CPP_EXCEPTIONS */\n\tDUK_LONGJMP(thr->heap->lj.jmpbuf_ptr->jb);\n#endif  /* DUK_USE_CPP_EXCEPTIONS */\n\n\tDUK_UNREACHABLE();\n}\n/*\n *  Error helpers\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Helper to walk the thread chain and see if there is an active error\n *  catcher.  Protected calls or finally blocks aren't considered catching.\n */\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT) && \\\n    (defined(DUK_USE_DEBUGGER_THROW_NOTIFY) || defined(DUK_USE_DEBUGGER_PAUSE_UNCAUGHT))\nDUK_LOCAL duk_bool_t duk__have_active_catcher(duk_hthread *thr) {\n\t/*\n\t * XXX: As noted above, a protected API call won't be counted as a\n\t * catcher. This is usually convenient, e.g. in the case of a top-\n\t * level duk_pcall(), but may not always be desirable. Perhaps add an\n\t * argument to treat them as catchers?\n\t */\n\n\tduk_size_t i;\n\n\tDUK_ASSERT(thr != NULL);\n\n\twhile (thr != NULL) {\n\t\tfor (i = 0; i < thr->catchstack_top; i++) {\n\t\t\tduk_catcher *cat = thr->catchstack + i;\n\t\t\tif (DUK_CAT_HAS_CATCH_ENABLED(cat)) {\n\t\t\t\treturn 1;  /* all we need to know */\n\t\t\t}\n\t\t}\n\t\tthr = thr->resumer;\n\t}\n\treturn 0;\n}\n#endif  /* DUK_USE_DEBUGGER_SUPPORT && (DUK_USE_DEBUGGER_THROW_NOTIFY || DUK_USE_DEBUGGER_PAUSE_UNCAUGHT) */\n\n/*\n *  Get prototype object for an integer error code.\n */\n\nDUK_INTERNAL duk_hobject *duk_error_prototype_from_code(duk_hthread *thr, duk_errcode_t code) {\n\tswitch (code) {\n\tcase DUK_ERR_EVAL_ERROR:\n\t\treturn thr->builtins[DUK_BIDX_EVAL_ERROR_PROTOTYPE];\n\tcase DUK_ERR_RANGE_ERROR:\n\t\treturn thr->builtins[DUK_BIDX_RANGE_ERROR_PROTOTYPE];\n\tcase DUK_ERR_REFERENCE_ERROR:\n\t\treturn thr->builtins[DUK_BIDX_REFERENCE_ERROR_PROTOTYPE];\n\tcase DUK_ERR_SYNTAX_ERROR:\n\t\treturn thr->builtins[DUK_BIDX_SYNTAX_ERROR_PROTOTYPE];\n\tcase DUK_ERR_TYPE_ERROR:\n\t\treturn thr->builtins[DUK_BIDX_TYPE_ERROR_PROTOTYPE];\n\tcase DUK_ERR_URI_ERROR:\n\t\treturn thr->builtins[DUK_BIDX_URI_ERROR_PROTOTYPE];\n\tcase DUK_ERR_ERROR:\n\tdefault:\n\t\treturn thr->builtins[DUK_BIDX_ERROR_PROTOTYPE];\n\t}\n}\n\n/*\n *  Helper for debugger throw notify and pause-on-uncaught integration.\n */\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n#if defined(DUK_USE_DEBUGGER_THROW_NOTIFY) || defined(DUK_USE_DEBUGGER_PAUSE_UNCAUGHT)\nDUK_INTERNAL void duk_err_check_debugger_integration(duk_hthread *thr) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_bool_t fatal;\n\tduk_tval *tv_obj;\n\n\t/* If something is thrown with the debugger attached and nobody will\n\t * catch it, execution is paused before the longjmp, turning over\n\t * control to the debug client.  This allows local state to be examined\n\t * before the stack is unwound.  Errors are not intercepted when debug\n\t * message loop is active (e.g. for Eval).\n\t */\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\n\t/* XXX: Allow customizing the pause and notify behavior at runtime\n\t * using debugger runtime flags.  For now the behavior is fixed using\n\t * config options.\n\t */\n\n\tif (!duk_debug_is_attached(thr->heap) ||\n\t    thr->heap->dbg_processing ||\n\t    thr->heap->lj.type != DUK_LJ_TYPE_THROW ||\n\t    thr->heap->creating_error) {\n\t\tDUK_D(DUK_DPRINT(\"skip debugger error integration; not attached, debugger processing, not THROW, or error thrown while creating error\"));\n\t\treturn;\n\t}\n\n\t/* Don't intercept a DoubleError, we may have caused the initial double\n\t * fault and attempting to intercept it will cause us to be called\n\t * recursively and exhaust the C stack.  (This should no longer happen\n\t * for the initial throw because DoubleError path doesn't do a debugger\n\t * integration check, but it might happen for rethrows.)\n\t */\n\ttv_obj = &thr->heap->lj.value1;\n\tif (DUK_TVAL_IS_OBJECT(tv_obj) && DUK_TVAL_GET_OBJECT(tv_obj) == thr->builtins[DUK_BIDX_DOUBLE_ERROR]) {\n\t\tDUK_D(DUK_DPRINT(\"built-in DoubleError instance (re)thrown, not intercepting\"));\n\t\treturn;\n\t}\n\n\tfatal = !duk__have_active_catcher(thr);\n\n\t/* Debugger code expects the value at stack top.  This also serves\n\t * as a backup: we need to store/restore the longjmp state because\n\t * when the debugger is paused Eval commands may be executed and\n\t * they can arbitrarily clobber the longjmp state.\n\t */\n\tduk_push_tval(ctx, tv_obj);\n\n\t/* Store and reset longjmp state. */\n\tDUK_ASSERT_LJSTATE_SET(thr->heap);\n\tDUK_TVAL_DECREF_NORZ(thr, tv_obj);\n\tDUK_ASSERT(DUK_TVAL_IS_UNDEFINED(&thr->heap->lj.value2));  /* Always for THROW type. */\n\tDUK_TVAL_SET_UNDEFINED(tv_obj);\n\tthr->heap->lj.type = DUK_LJ_TYPE_UNKNOWN;\n\tDUK_ASSERT_LJSTATE_UNSET(thr->heap);\n\n#if defined(DUK_USE_DEBUGGER_THROW_NOTIFY)\n\t/* Report it to the debug client */\n\tDUK_D(DUK_DPRINT(\"throw with debugger attached, report to client\"));\n\tduk_debug_send_throw(thr, fatal);\n#endif\n\n#if defined(DUK_USE_DEBUGGER_PAUSE_UNCAUGHT)\n\tif (fatal) {\n\t\tDUK_D(DUK_DPRINT(\"throw will be fatal, halt before longjmp\"));\n\t\tduk_debug_halt_execution(thr, 1 /*use_prev_pc*/);\n\t}\n#endif\n\n\t/* Restore longjmp state. */\n\tDUK_ASSERT_LJSTATE_UNSET(thr->heap);\n\tthr->heap->lj.type = DUK_LJ_TYPE_THROW;\n\ttv_obj = DUK_GET_TVAL_NEGIDX(ctx, -1);\n\tDUK_ASSERT(DUK_TVAL_IS_UNDEFINED(&thr->heap->lj.value1));\n\tDUK_ASSERT(DUK_TVAL_IS_UNDEFINED(&thr->heap->lj.value2));\n\tDUK_TVAL_SET_TVAL(&thr->heap->lj.value1, tv_obj);\n\tDUK_TVAL_INCREF(thr, tv_obj);\n\tDUK_ASSERT_LJSTATE_SET(thr->heap);\n\n\tduk_pop(ctx);\n}\n#else  /* DUK_USE_DEBUGGER_THROW_NOTIFY || DUK_USE_DEBUGGER_PAUSE_UNCAUGHT */\nDUK_INTERNAL void duk_err_check_debugger_integration(duk_hthread *thr) {\n\tDUK_UNREF(thr);\n}\n#endif  /* DUK_USE_DEBUGGER_THROW_NOTIFY || DUK_USE_DEBUGGER_PAUSE_UNCAUGHT */\n#endif  /* DUK_USE_DEBUGGER_SUPPORT */\n\n/*\n *  Helpers for setting up heap longjmp state.\n */\n\nDUK_INTERNAL void duk_err_setup_ljstate1(duk_hthread *thr, duk_small_uint_t lj_type, duk_tval *tv_val) {\n\tduk_heap *heap;\n\n\tDUK_ASSERT(thr != NULL);\n\theap = thr->heap;\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT(tv_val != NULL);\n\n\tDUK_ASSERT_LJSTATE_UNSET(heap);\n\n\theap->lj.type = lj_type;\n\tDUK_TVAL_SET_TVAL(&heap->lj.value1, tv_val);\n\tDUK_TVAL_INCREF(thr, tv_val);\n\n\tDUK_ASSERT_LJSTATE_SET(heap);\n}\n/*\n *  Create and throw an Ecmascript error object based on a code and a message.\n *\n *  Used when we throw errors internally.  Ecmascript generated error objects\n *  are created by Ecmascript code, and the throwing is handled by the bytecode\n *  executor.\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Create and throw an error (originating from Duktape internally)\n *\n *  Push an error object on top of the stack, possibly throw augmenting\n *  the error, and finally longjmp.\n *\n *  If an error occurs while we're dealing with the current error, we might\n *  enter an infinite recursion loop.  This is prevented by detecting a\n *  \"double fault\" through the heap->creating_error flag; the recursion\n *  then stops at the second level.\n */\n\n#if defined(DUK_USE_VERBOSE_ERRORS)\nDUK_INTERNAL void duk_err_create_and_throw(duk_hthread *thr, duk_errcode_t code, const char *msg, const char *filename, duk_int_t line) {\n#else\nDUK_INTERNAL void duk_err_create_and_throw(duk_hthread *thr, duk_errcode_t code) {\n#endif\n\tduk_context *ctx = (duk_context *) thr;\n\n#if defined(DUK_USE_VERBOSE_ERRORS)\n\tDUK_DD(DUK_DDPRINT(\"duk_err_create_and_throw(): code=%ld, msg=%s, filename=%s, line=%ld\",\n\t                   (long) code, (const char *) msg,\n\t                   (const char *) filename, (long) line));\n#else\n\tDUK_DD(DUK_DDPRINT(\"duk_err_create_and_throw(): code=%ld\", (long) code));\n#endif\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(ctx != NULL);\n\n\t/* Even though nested call is possible because we throw an error when\n\t * trying to create an error, the potential errors must happen before\n\t * the longjmp state is configured.\n\t */\n\tDUK_ASSERT_LJSTATE_UNSET(thr->heap);\n\n\t/* Sync so that augmentation sees up-to-date activations, NULL\n\t * thr->ptr_curr_pc so that it's not used if side effects occur\n\t * in augmentation or longjmp handling.\n\t */\n\tduk_hthread_sync_and_null_currpc(thr);\n\n\t/*\n\t *  Create and push an error object onto the top of stack.\n\t *  The error is potentially augmented before throwing.\n\t *\n\t *  If a \"double error\" occurs, use a fixed error instance\n\t *  to avoid further trouble.\n\t */\n\n\tif (thr->heap->creating_error) {\n\t\tduk_tval tv_val;\n\t\tduk_hobject *h_err;\n\n#if 0  /* XXX: not always true because the second throw may come from a different coroutine */\n\t\tDUK_ASSERT(thr->callstack_max == DUK_CALLSTACK_DEFAULT_MAX + DUK_CALLSTACK_GROW_STEP + 11);\n#endif\n\t\tthr->callstack_max = DUK_CALLSTACK_DEFAULT_MAX;\n\t\tthr->heap->creating_error = 0;\n\n\t\th_err = thr->builtins[DUK_BIDX_DOUBLE_ERROR];\n\t\tif (h_err != NULL) {\n\t\t\tDUK_D(DUK_DPRINT(\"double fault detected -> use built-in fixed 'double error' instance\"));\n\t\t\tDUK_TVAL_SET_OBJECT(&tv_val, h_err);\n\t\t} else {\n\t\t\tDUK_D(DUK_DPRINT(\"double fault detected; there is no built-in fixed 'double error' instance \"\n\t\t\t                 \"-> use the error code as a number\"));\n\t\t\tDUK_TVAL_SET_I32(&tv_val, (duk_int32_t) code);\n\t\t}\n\n\t\tduk_err_setup_ljstate1(thr, DUK_LJ_TYPE_THROW, &tv_val);\n\n\t\t/* No augmentation to avoid any allocations or side effects. */\n\t} else {\n\t\t/* Allow headroom for calls during error handling (see GH-191).\n\t\t * We allow space for 10 additional recursions, with one extra\n\t\t * for, e.g. a print() call at the deepest level.\n\t\t */\n#if 0  /* XXX: not always true, second throw may come from a different coroutine */\n\t\tDUK_ASSERT(thr->callstack_max == DUK_CALLSTACK_DEFAULT_MAX);\n#endif\n\t\tthr->callstack_max = DUK_CALLSTACK_DEFAULT_MAX + DUK_CALLSTACK_GROW_STEP + 11;\n\t\tthr->heap->creating_error = 1;\n\n\t\tduk_require_stack(ctx, 1);\n\n\t\t/* XXX: usually unnecessary '%s' formatting here, but cannot\n\t\t * use 'msg' as a format string directly.\n\t\t */\n#if defined(DUK_USE_VERBOSE_ERRORS)\n\t\tduk_push_error_object_raw(ctx,\n\t\t                          code | DUK_ERRCODE_FLAG_NOBLAME_FILELINE,\n\t\t                          filename,\n\t\t                          line,\n\t\t                          \"%s\",\n\t\t                          (const char *) msg);\n#else\n\t\tduk_push_error_object_raw(ctx,\n\t\t                          code | DUK_ERRCODE_FLAG_NOBLAME_FILELINE,\n\t\t                          NULL,\n\t\t                          0,\n\t\t                          NULL);\n#endif\n\n\t\t/* Note that an alloc error may happen during error augmentation.\n\t\t * This may happen both when the original error is an alloc error\n\t\t * and when it's something else.  Because any error in augmentation\n\t\t * must be handled correctly anyway, there's no special check for\n\t\t * avoiding it for alloc errors (this differs from Duktape 1.x).\n\t\t */\n#if defined(DUK_USE_AUGMENT_ERROR_THROW)\n\t\tDUK_DDD(DUK_DDDPRINT(\"THROW ERROR (INTERNAL): %!iT (before throw augment)\",\n\t\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\t\tduk_err_augment_error_throw(thr);\n#endif\n\n\t\tduk_err_setup_ljstate1(thr, DUK_LJ_TYPE_THROW, DUK_GET_TVAL_NEGIDX(ctx, -1));\n\t\tthr->callstack_max = DUK_CALLSTACK_DEFAULT_MAX;\n\t\tthr->heap->creating_error = 0;\n\n\t\t/* Error is now created and we assume no errors can occur any\n\t\t * more.  Check for debugger Throw integration only when the\n\t\t * error is complete.  If we enter debugger message loop,\n\t\t * creating_error must be 0 so that errors can be thrown in\n\t\t * the paused state, e.g. in Eval commands.\n\t\t */\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\t\tduk_err_check_debugger_integration(thr);\n#endif\n\t}\n\n\t/*\n\t *  Finally, longjmp\n\t */\n\n\tDUK_DDD(DUK_DDDPRINT(\"THROW ERROR (INTERNAL): %!iT, %!iT (after throw augment)\",\n\t                     (duk_tval *) &thr->heap->lj.value1, (duk_tval *) &thr->heap->lj.value2));\n\n\tduk_err_longjmp(thr);\n\tDUK_UNREACHABLE();\n}\n\n/*\n *  Helper for C function call negative return values.\n */\n\nDUK_INTERNAL void duk_error_throw_from_negative_rc(duk_hthread *thr, duk_ret_t rc) {\n\tduk_context *ctx = (duk_context *) thr;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(rc < 0);\n\n\t/*\n\t *  The __FILE__ and __LINE__ information is intentionally not used in the\n\t *  creation of the error object, as it isn't useful in the tracedata.  The\n\t *  tracedata still contains the function which returned the negative return\n\t *  code, and having the file/line of this function isn't very useful.\n\t *\n\t *  The error messages for DUK_RET_xxx shorthand are intentionally very\n\t *  minimal: they're only really useful for low memory targets.\n\t */\n\n\tduk_error_raw(ctx, -rc, NULL, 0, \"error (rc %ld)\", (long) rc);\n\tDUK_UNREACHABLE();\n}\n/*\n *  duk_hbuffer allocation and freeing.\n */\n\n/* #include duk_internal.h -> already included */\n\n/* Allocate a new duk_hbuffer of a certain type and return a pointer to it\n * (NULL on error).  Write buffer data pointer to 'out_bufdata' (only if\n * allocation successful).\n */\nDUK_INTERNAL duk_hbuffer *duk_hbuffer_alloc(duk_heap *heap, duk_size_t size, duk_small_uint_t flags, void **out_bufdata) {\n\tduk_hbuffer *res = NULL;\n\tduk_size_t header_size;\n\tduk_size_t alloc_size;\n\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT(out_bufdata != NULL);\n\n\tDUK_DDD(DUK_DDDPRINT(\"allocate hbuffer\"));\n\n\t/* Size sanity check.  Should not be necessary because caller is\n\t * required to check this, but we don't want to cause a segfault\n\t * if the size wraps either in duk_size_t computation or when\n\t * storing the size in a 16-bit field.\n\t */\n\tif (size > DUK_HBUFFER_MAX_BYTELEN) {\n\t\tDUK_D(DUK_DPRINT(\"hbuffer alloc failed: size too large: %ld\", (long) size));\n\t\treturn NULL;  /* no need to write 'out_bufdata' */\n\t}\n\n\tif (flags & DUK_BUF_FLAG_EXTERNAL) {\n\t\theader_size = sizeof(duk_hbuffer_external);\n\t\talloc_size = sizeof(duk_hbuffer_external);\n\t} else if (flags & DUK_BUF_FLAG_DYNAMIC) {\n\t\theader_size = sizeof(duk_hbuffer_dynamic);\n\t\talloc_size = sizeof(duk_hbuffer_dynamic);\n\t} else {\n\t\theader_size = sizeof(duk_hbuffer_fixed);\n\t\talloc_size = sizeof(duk_hbuffer_fixed) + size;\n\t\tDUK_ASSERT(alloc_size >= sizeof(duk_hbuffer_fixed));  /* no wrapping */\n\t}\n\n\tres = (duk_hbuffer *) DUK_ALLOC(heap, alloc_size);\n\tif (DUK_UNLIKELY(res == NULL)) {\n\t\tgoto alloc_error;\n\t}\n\n\t/* zero everything unless requested not to do so */\n#if defined(DUK_USE_ZERO_BUFFER_DATA)\n\tDUK_MEMZERO((void *) res,\n\t            (flags & DUK_BUF_FLAG_NOZERO) ? header_size : alloc_size);\n#else\n\tDUK_MEMZERO((void *) res, header_size);\n#endif\n\n\tif (flags & DUK_BUF_FLAG_EXTERNAL) {\n\t\tduk_hbuffer_external *h;\n\t\th = (duk_hbuffer_external *) res;\n\t\tDUK_UNREF(h);\n\t\t*out_bufdata = NULL;\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n#if defined(DUK_USE_HEAPPTR16)\n/* the compressed pointer is zeroed which maps to NULL, so nothing to do. */\n#else\n\t\tDUK_HBUFFER_EXTERNAL_SET_DATA_PTR(heap, h, NULL);\n#endif\n#endif\n\t\tDUK_ASSERT(DUK_HBUFFER_EXTERNAL_GET_DATA_PTR(heap, h) == NULL);\n\t} else if (flags & DUK_BUF_FLAG_DYNAMIC) {\n\t\tduk_hbuffer_dynamic *h = (duk_hbuffer_dynamic *) res;\n\t\tvoid *ptr;\n\n\t\tif (size > 0) {\n\t\t\tDUK_ASSERT(!(flags & DUK_BUF_FLAG_EXTERNAL));  /* alloc external with size zero */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"dynamic buffer with nonzero size, alloc actual buffer\"));\n#if defined(DUK_USE_ZERO_BUFFER_DATA)\n\t\t\tptr = DUK_ALLOC_ZEROED(heap, size);\n#else\n\t\t\tptr = DUK_ALLOC(heap, size);\n#endif\n\t\t\tif (DUK_UNLIKELY(ptr == NULL)) {\n\t\t\t\t/* Because size > 0, NULL check is correct */\n\t\t\t\tgoto alloc_error;\n\t\t\t}\n\t\t\t*out_bufdata = ptr;\n\n\t\t\tDUK_HBUFFER_DYNAMIC_SET_DATA_PTR(heap, h, ptr);\n\t\t} else {\n\t\t\t*out_bufdata = NULL;\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n#if defined(DUK_USE_HEAPPTR16)\n/* the compressed pointer is zeroed which maps to NULL, so nothing to do. */\n#else\n\t\t\tDUK_HBUFFER_DYNAMIC_SET_DATA_PTR(heap, h, NULL);\n#endif\n#endif\n\t\t\tDUK_ASSERT(DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(heap, h) == NULL);\n\t\t}\n\t} else {\n\t\t*out_bufdata = (void *) ((duk_hbuffer_fixed *) res + 1);\n\t}\n\n\tDUK_HBUFFER_SET_SIZE(res, size);\n\n\tDUK_HEAPHDR_SET_TYPE(&res->hdr, DUK_HTYPE_BUFFER);\n\tif (flags & DUK_BUF_FLAG_DYNAMIC) {\n\t\tDUK_HBUFFER_SET_DYNAMIC(res);\n\t\tif (flags & DUK_BUF_FLAG_EXTERNAL) {\n\t\t\tDUK_HBUFFER_SET_EXTERNAL(res);\n\t\t}\n\t} else {\n\t\tDUK_ASSERT(!(flags & DUK_BUF_FLAG_EXTERNAL));\n\t}\n        DUK_HEAP_INSERT_INTO_HEAP_ALLOCATED(heap, &res->hdr);\n\n\tDUK_DDD(DUK_DDDPRINT(\"allocated hbuffer: %p\", (void *) res));\n\treturn res;\n\n alloc_error:\n\tDUK_DD(DUK_DDPRINT(\"hbuffer allocation failed\"));\n\n\tDUK_FREE(heap, res);\n\treturn NULL;  /* no need to write 'out_bufdata' */\n}\n\n/* For indirect allocs. */\n\nDUK_INTERNAL void *duk_hbuffer_get_dynalloc_ptr(duk_heap *heap, void *ud) {\n\tduk_hbuffer_dynamic *buf = (duk_hbuffer_dynamic *) ud;\n\tDUK_UNREF(heap);\n\treturn (void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(heap, buf);\n}\n/*\n *  duk_hbuffer operations such as resizing and inserting/appending data to\n *  a dynamic buffer.\n *\n *  Append operations append to the end of the buffer and they are relatively\n *  efficient: the buffer is grown with a \"spare\" part relative to the buffer\n *  size to minimize reallocations.  Insert operations need to move existing\n *  data forward in the buffer with memmove() and are not very efficient.\n *  They are used e.g. by the regexp compiler to \"backpatch\" regexp bytecode.\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Resizing\n */\n\nDUK_INTERNAL void duk_hbuffer_resize(duk_hthread *thr, duk_hbuffer_dynamic *buf, duk_size_t new_size) {\n\tvoid *res;\n\tduk_size_t prev_size;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(buf != NULL);\n\tDUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(buf));\n\tDUK_ASSERT(!DUK_HBUFFER_HAS_EXTERNAL(buf));\n\n\t/*\n\t *  Maximum size check\n\t */\n\n\tif (new_size > DUK_HBUFFER_MAX_BYTELEN) {\n\t\tDUK_ERROR_RANGE(thr, \"buffer too long\");\n\t}\n\n\t/*\n\t *  Note: use indirect realloc variant just in case mark-and-sweep\n\t *  (finalizers) might resize this same buffer during garbage\n\t *  collection.\n\t */\n\n\tres = DUK_REALLOC_INDIRECT(thr->heap, duk_hbuffer_get_dynalloc_ptr, (void *) buf, new_size);\n\tif (DUK_LIKELY(res != NULL || new_size == 0)) {\n\t\t/* 'res' may be NULL if new allocation size is 0. */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"resized dynamic buffer %p:%ld -> %p:%ld\",\n\t\t                     (void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, buf),\n\t\t                     (long) DUK_HBUFFER_DYNAMIC_GET_SIZE(buf),\n\t\t                     (void *) res,\n\t\t                     (long) new_size));\n\n\t\t/*\n\t\t *  The entire allocated buffer area, regardless of actual used\n\t\t *  size, is kept zeroed in resizes for simplicity.  If the buffer\n\t\t *  is grown, zero the new part.\n\t\t */\n\n\t\tprev_size = DUK_HBUFFER_DYNAMIC_GET_SIZE(buf);\n\t\tif (new_size > prev_size) {\n\t\t\tDUK_ASSERT(new_size - prev_size > 0);\n#if defined(DUK_USE_ZERO_BUFFER_DATA)\n\t\t\tDUK_MEMZERO((void *) ((char *) res + prev_size),\n\t\t\t            (duk_size_t) (new_size - prev_size));\n#endif\n\t\t}\n\n\t\tDUK_HBUFFER_DYNAMIC_SET_SIZE(buf, new_size);\n\t\tDUK_HBUFFER_DYNAMIC_SET_DATA_PTR(thr->heap, buf, res);\n\t} else {\n\t\tDUK_ERROR_ALLOC_FAILED(thr);\n\t}\n\n\tDUK_ASSERT(res != NULL || new_size == 0);\n}\n\nDUK_INTERNAL void duk_hbuffer_reset(duk_hthread *thr, duk_hbuffer_dynamic *buf) {\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(buf != NULL);\n\tDUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(buf));\n\tDUK_ASSERT(!DUK_HBUFFER_HAS_EXTERNAL(buf));\n\n\tduk_hbuffer_resize(thr, buf, 0);\n}\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL duk_uint_t duk_hbufobj_clamp_bytelength(duk_hbufobj *h_bufobj, duk_uint_t len) {\n\tduk_uint_t buf_size;\n\tduk_uint_t buf_avail;\n\n\tDUK_ASSERT(h_bufobj != NULL);\n\tDUK_ASSERT(h_bufobj->buf != NULL);\n\n\tbuf_size = (duk_uint_t) DUK_HBUFFER_GET_SIZE(h_bufobj->buf);\n\tif (h_bufobj->offset > buf_size) {\n\t\t/* Slice starting point is beyond current length. */\n\t\treturn 0;\n\t}\n\tbuf_avail = buf_size - h_bufobj->offset;\n\n\treturn buf_avail >= len ? len : buf_avail;\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n/*\n *  duk_heap allocation and freeing.\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_ROM_STRINGS)\n/* Fixed seed value used with ROM strings. */\n#define DUK__FIXED_HASH_SEED       0xabcd1234\n#endif\n\n/*\n *  Free a heap object.\n *\n *  Free heap object and its internal (non-heap) pointers.  Assumes that\n *  caller has removed the object from heap allocated list or the string\n *  intern table, and any weak references (which strings may have) have\n *  been already dealt with.\n */\n\nDUK_INTERNAL void duk_free_hobject(duk_heap *heap, duk_hobject *h) {\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT(h != NULL);\n\n\tDUK_FREE(heap, DUK_HOBJECT_GET_PROPS(heap, h));\n\n\tif (DUK_HOBJECT_IS_COMPFUNC(h)) {\n\t\tduk_hcompfunc *f = (duk_hcompfunc *) h;\n\t\tDUK_UNREF(f);\n\t\t/* Currently nothing to free; 'data' is a heap object */\n\t} else if (DUK_HOBJECT_IS_NATFUNC(h)) {\n\t\tduk_hnatfunc *f = (duk_hnatfunc *) h;\n\t\tDUK_UNREF(f);\n\t\t/* Currently nothing to free */\n\t} else if (DUK_HOBJECT_IS_THREAD(h)) {\n\t\tduk_hthread *t = (duk_hthread *) h;\n\t\tDUK_FREE(heap, t->valstack);\n\t\tDUK_FREE(heap, t->callstack);\n\t\tDUK_FREE(heap, t->catchstack);\n\t\t/* Don't free h->resumer because it exists in the heap.\n\t\t * Callstack entries also contain function pointers which\n\t\t * are not freed for the same reason.\n\t\t */\n\n\t\t/* XXX: with 'caller' property the callstack would need\n\t\t * to be unwound to update the 'caller' properties of\n\t\t * functions in the callstack.\n\t\t */\n\t}\n\tDUK_FREE(heap, (void *) h);\n}\n\nDUK_INTERNAL void duk_free_hbuffer(duk_heap *heap, duk_hbuffer *h) {\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT(h != NULL);\n\n\tif (DUK_HBUFFER_HAS_DYNAMIC(h) && !DUK_HBUFFER_HAS_EXTERNAL(h)) {\n\t\tduk_hbuffer_dynamic *g = (duk_hbuffer_dynamic *) h;\n\t\tDUK_DDD(DUK_DDDPRINT(\"free dynamic buffer %p\", (void *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(heap, g)));\n\t\tDUK_FREE(heap, DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(heap, g));\n\t}\n\tDUK_FREE(heap, (void *) h);\n}\n\nDUK_INTERNAL void duk_free_hstring(duk_heap *heap, duk_hstring *h) {\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT(h != NULL);\n\n\tDUK_UNREF(heap);\n\tDUK_UNREF(h);\n\n#if defined(DUK_USE_HSTRING_EXTDATA) && defined(DUK_USE_EXTSTR_FREE)\n\tif (DUK_HSTRING_HAS_EXTDATA(h)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"free extstr: hstring %!O, extdata: %p\",\n\t\t                     h, DUK_HSTRING_GET_EXTDATA((duk_hstring_external *) h)));\n\t\tDUK_USE_EXTSTR_FREE(heap->heap_udata, (const void *) DUK_HSTRING_GET_EXTDATA((duk_hstring_external *) h));\n\t}\n#endif\n\tDUK_FREE(heap, (void *) h);\n}\n\nDUK_INTERNAL void duk_heap_free_heaphdr_raw(duk_heap *heap, duk_heaphdr *hdr) {\n\tDUK_ASSERT(heap);\n\tDUK_ASSERT(hdr);\n\n\tDUK_DDD(DUK_DDDPRINT(\"free heaphdr %p, htype %ld\", (void *) hdr, (long) DUK_HEAPHDR_GET_TYPE(hdr)));\n\n\tswitch (DUK_HEAPHDR_GET_TYPE(hdr)) {\n\tcase DUK_HTYPE_STRING:\n\t\tduk_free_hstring(heap, (duk_hstring *) hdr);\n\t\tbreak;\n\tcase DUK_HTYPE_OBJECT:\n\t\tduk_free_hobject(heap, (duk_hobject *) hdr);\n\t\tbreak;\n\tdefault:\n\t\tDUK_ASSERT(DUK_HEAPHDR_GET_TYPE(hdr) == DUK_HTYPE_BUFFER);\n\t\tduk_free_hbuffer(heap, (duk_hbuffer *) hdr);\n\t}\n\n}\n\n/*\n *  Free the heap.\n *\n *  Frees heap-related non-heap-tracked allocations such as the\n *  string intern table; then frees the heap allocated objects;\n *  and finally frees the heap structure itself.  Reference counts\n *  and GC markers are ignored (and not updated) in this process,\n *  and finalizers won't be called.\n *\n *  The heap pointer and heap object pointers must not be used\n *  after this call.\n */\n\nDUK_LOCAL void duk__free_allocated(duk_heap *heap) {\n\tduk_heaphdr *curr;\n\tduk_heaphdr *next;\n\n\tcurr = heap->heap_allocated;\n\twhile (curr) {\n\t\t/* We don't log or warn about freeing zero refcount objects\n\t\t * because they may happen with finalizer processing.\n\t\t */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"FINALFREE (allocated): %!iO\",\n\t\t                     (duk_heaphdr *) curr));\n\t\tnext = DUK_HEAPHDR_GET_NEXT(heap, curr);\n\t\tduk_heap_free_heaphdr_raw(heap, curr);\n\t\tcurr = next;\n\t}\n}\n\n#if defined(DUK_USE_FINALIZER_SUPPORT)\nDUK_LOCAL void duk__free_finalize_list(duk_heap *heap) {\n\tduk_heaphdr *curr;\n\tduk_heaphdr *next;\n\n\tcurr = heap->finalize_list;\n\twhile (curr) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"FINALFREE (finalize_list): %!iO\",\n\t\t                     (duk_heaphdr *) curr));\n\t\tnext = DUK_HEAPHDR_GET_NEXT(heap, curr);\n\t\tduk_heap_free_heaphdr_raw(heap, curr);\n\t\tcurr = next;\n\t}\n}\n#endif  /* DUK_USE_FINALIZER_SUPPORT */\n\nDUK_LOCAL void duk__free_stringtable(duk_heap *heap) {\n\t/* strings are only tracked by stringtable */\n\tduk_heap_strtable_free(heap);\n}\n\n#if defined(DUK_USE_FINALIZER_SUPPORT)\nDUK_LOCAL void duk__free_run_finalizers(duk_heap *heap) {\n\tduk_heaphdr *curr;\n\tduk_uint_t round_no;\n\tduk_size_t count_all;\n\tduk_size_t count_finalized;\n\tduk_size_t curr_limit;\n\n\tDUK_ASSERT(heap != NULL);\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tDUK_ASSERT(heap->refzero_list == NULL);  /* refzero not running -> must be empty */\n#endif\n\tDUK_ASSERT(heap->finalize_list == NULL);  /* mark-and-sweep last pass */\n\n\tif (heap->heap_thread == NULL) {\n\t\t/* May happen when heap allocation fails right off.  There\n\t\t * cannot be any finalizable objects in this case.\n\t\t */\n\t\tDUK_D(DUK_DPRINT(\"no heap_thread in heap destruct, assume no finalizable objects\"));\n\t\treturn;\n\t}\n\n\t/* Prevent finalize_list processing and mark-and-sweep entirely.\n\t * Setting ms_running = 1 also prevents refzero handling from moving\n\t * objects away from the heap_allocated list (the flag name is a bit\n\t * misleading here).\n\t */\n\tDUK_ASSERT(heap->pf_prevent_count == 0);\n\theap->pf_prevent_count = 1;\n\tDUK_ASSERT(heap->ms_running == 0);\n\theap->ms_running = 1;\n\tDUK_ASSERT(heap->ms_prevent_count == 0);\n\theap->ms_prevent_count = 1;  /* Bump, because mark-and-sweep assumes it's bumped when ms_running is set. */\n\n\tcurr_limit = 0;  /* suppress warning, not used */\n\tfor (round_no = 0; ; round_no++) {\n\t\tcurr = heap->heap_allocated;\n\t\tcount_all = 0;\n\t\tcount_finalized = 0;\n\t\twhile (curr) {\n\t\t\tcount_all++;\n\t\t\tif (DUK_HEAPHDR_IS_OBJECT(curr)) {\n\t\t\t\t/* Only objects in heap_allocated may have finalizers.  Check that\n\t\t\t\t * the object itself has a _Finalizer property (own or inherited)\n\t\t\t\t * so that we don't execute finalizers for e.g. Proxy objects.\n\t\t\t\t */\n\t\t\t\tDUK_ASSERT(curr != NULL);\n\n\t\t\t\tif (DUK_HOBJECT_HAS_FINALIZER_FAST(heap, (duk_hobject *) curr)) {\n\t\t\t\t\tif (!DUK_HEAPHDR_HAS_FINALIZED((duk_heaphdr *) curr)) {\n\t\t\t\t\t\tDUK_ASSERT(DUK_HEAP_HAS_FINALIZER_NORESCUE(heap));  /* maps to finalizer 2nd argument */\n\t\t\t\t\t\tduk_heap_run_finalizer(heap, (duk_hobject *) curr);\n\t\t\t\t\t\tcount_finalized++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tcurr = DUK_HEAPHDR_GET_NEXT(heap, curr);\n\t\t}\n\n\t\t/* Each round of finalizer execution may spawn new finalizable objects\n\t\t * which is normal behavior for some applications.  Allow multiple\n\t\t * rounds of finalization, but use a shrinking limit based on the\n\t\t * first round to detect the case where a runaway finalizer creates\n\t\t * an unbounded amount of new finalizable objects.  Finalizer rescue\n\t\t * is not supported: the semantics are unclear because most of the\n\t\t * objects being finalized here are already reachable.  The finalizer\n\t\t * is given a boolean to indicate that rescue is not possible.\n\t\t *\n\t\t * See discussion in: https://github.com/svaarala/duktape/pull/473\n\t\t */\n\n\t\tif (round_no == 0) {\n\t\t\t/* Cannot wrap: each object is at least 8 bytes so count is\n\t\t\t * at most 1/8 of that.\n\t\t\t */\n\t\t\tcurr_limit = count_all * 2;\n\t\t} else {\n\t\t\tcurr_limit = (curr_limit * 3) / 4;   /* Decrease by 25% every round */\n\t\t}\n\t\tDUK_D(DUK_DPRINT(\"finalizer round %ld complete, %ld objects, tried to execute %ld finalizers, current limit is %ld\",\n\t\t                 (long) round_no, (long) count_all, (long) count_finalized, (long) curr_limit));\n\n\t\tif (count_finalized == 0) {\n\t\t\tDUK_D(DUK_DPRINT(\"no more finalizable objects, forced finalization finished\"));\n\t\t\tbreak;\n\t\t}\n\t\tif (count_finalized >= curr_limit) {\n\t\t\tDUK_D(DUK_DPRINT(\"finalizer count above limit, potentially runaway finalizer; skip remaining finalizers\"));\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tDUK_ASSERT(heap->ms_running == 1);\n\theap->ms_running = 0;\n\tDUK_ASSERT(heap->pf_prevent_count == 1);\n\theap->pf_prevent_count = 0;\n}\n#endif  /* DUK_USE_FINALIZER_SUPPORT */\n\nDUK_INTERNAL void duk_heap_free(duk_heap *heap) {\n\tDUK_D(DUK_DPRINT(\"free heap: %p\", (void *) heap));\n\n#if defined(DUK_USE_DEBUG)\n\tduk_heap_strtable_dump(heap);\n#endif\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\t/* Detach a debugger if attached (can be called multiple times)\n\t * safely.\n\t */\n\t/* XXX: Add a flag to reject an attempt to re-attach?  Otherwise\n\t * the detached callback may immediately reattach.\n\t */\n\tduk_debug_do_detach(heap);\n#endif\n\n\t/* Execute finalizers before freeing the heap, even for reachable\n\t * objects.  This gives finalizers the chance to free any native\n\t * resources like file handles, allocations made outside Duktape,\n\t * etc.  This is quite tricky to get right, so that all finalizer\n\t * guarantees are honored.\n\t *\n\t * Run mark-and-sweep a few times just in case (unreachable object\n\t * finalizers run already here).  The last round must rescue objects\n\t * from the previous round without running any more finalizers.  This\n\t * ensures rescued objects get their FINALIZED flag cleared so that\n\t * their finalizer is called once more in forced finalization to\n\t * satisfy finalizer guarantees.  However, we don't want to run any\n\t * more finalizers because that'd required one more loop, and so on.\n\t *\n\t * XXX: this perhaps requires an execution time limit.\n\t */\n\tDUK_D(DUK_DPRINT(\"execute finalizers before freeing heap\"));\n\tDUK_ASSERT(heap->pf_skip_finalizers == 0);\n\tDUK_D(DUK_DPRINT(\"forced gc #1 in heap destruction\"));\n\tduk_heap_mark_and_sweep(heap, 0);\n\tDUK_D(DUK_DPRINT(\"forced gc #2 in heap destruction\"));\n\tduk_heap_mark_and_sweep(heap, 0);\n\tDUK_D(DUK_DPRINT(\"forced gc #3 in heap destruction (don't run finalizers)\"));\n\theap->pf_skip_finalizers = 1;\n\tduk_heap_mark_and_sweep(heap, 0);  /* Skip finalizers; queue finalizable objects to heap_allocated. */\n\n\t/* There are never objects in refzero_list at this point, or at any\n\t * point beyond a DECREF (even a DECREF_NORZ).  Since Duktape 2.1\n\t * refzero_list processing is side effect free, so it is always\n\t * processed to completion by a DECREF initially triggering a zero\n\t * refcount.\n\t */\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tDUK_ASSERT(heap->refzero_list == NULL);  /* Always processed to completion inline. */\n#endif\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n\tDUK_ASSERT(heap->finalize_list == NULL);  /* Last mark-and-sweep with skip_finalizers. */\n#endif\n\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n\tDUK_D(DUK_DPRINT(\"run finalizers for remaining finalizable objects\"));\n\tDUK_HEAP_SET_FINALIZER_NORESCUE(heap);  /* Rescue no longer supported. */\n\tduk__free_run_finalizers(heap);\n#endif  /* DUK_USE_FINALIZER_SUPPORT */\n\n\t/* Note: heap->heap_thread, heap->curr_thread, and heap->heap_object\n\t * are on the heap allocated list.\n\t */\n\n\tDUK_D(DUK_DPRINT(\"freeing heap_allocated of heap: %p\", (void *) heap));\n\tduk__free_allocated(heap);\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tDUK_ASSERT(heap->refzero_list == NULL);  /* Always processed to completion inline. */\n#endif\n\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n\tDUK_D(DUK_DPRINT(\"freeing finalize_list of heap: %p\", (void *) heap));\n\tduk__free_finalize_list(heap);\n#endif\n\n\tDUK_D(DUK_DPRINT(\"freeing string table of heap: %p\", (void *) heap));\n\tduk__free_stringtable(heap);\n\n\tDUK_D(DUK_DPRINT(\"freeing heap structure: %p\", (void *) heap));\n\theap->free_func(heap->heap_udata, heap);\n}\n\n/*\n *  Allocate a heap.\n *\n *  String table is initialized with built-in strings from genbuiltins.py,\n *  either by dynamically creating the strings or by referring to ROM strings.\n */\n\n#if defined(DUK_USE_ROM_STRINGS)\nDUK_LOCAL duk_bool_t duk__init_heap_strings(duk_heap *heap) {\n#if defined(DUK_USE_ASSERTIONS)\n\tduk_small_uint_t i;\n#endif\n\n\tDUK_UNREF(heap);\n\n\t/* With ROM-based strings, heap->strs[] and thr->strs[] are omitted\n\t * so nothing to initialize for strs[].\n\t */\n\n#if defined(DUK_USE_ASSERTIONS)\n\tfor (i = 0; i < sizeof(duk_rom_strings_lookup) / sizeof(const duk_hstring *); i++) {\n\t\tconst duk_hstring *h;\n\t\tduk_uint32_t hash;\n\n\t\th = duk_rom_strings_lookup[i];\n\t\twhile (h != NULL) {\n\t\t\thash = duk_heap_hashstring(heap, (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h), DUK_HSTRING_GET_BYTELEN(h));\n\t\t\tDUK_DD(DUK_DDPRINT(\"duk_rom_strings_lookup[%d] -> hash 0x%08lx, computed 0x%08lx\",\n\t\t\t                   (int) i, (unsigned long) DUK_HSTRING_GET_HASH(h), (unsigned long) hash));\n\t\t\tDUK_ASSERT(hash == (duk_uint32_t) DUK_HSTRING_GET_HASH(h));\n\n\t\t\th = (const duk_hstring *) h->hdr.h_next;\n\t\t}\n\t}\n#endif\n\treturn 1;\n}\n#else  /* DUK_USE_ROM_STRINGS */\n\nDUK_LOCAL duk_bool_t duk__init_heap_strings(duk_heap *heap) {\n\tduk_bitdecoder_ctx bd_ctx;\n\tduk_bitdecoder_ctx *bd = &bd_ctx;  /* convenience */\n\tduk_small_uint_t i;\n\n\tDUK_MEMZERO(&bd_ctx, sizeof(bd_ctx));\n\tbd->data = (const duk_uint8_t *) duk_strings_data;\n\tbd->length = (duk_size_t) DUK_STRDATA_DATA_LENGTH;\n\n\tfor (i = 0; i < DUK_HEAP_NUM_STRINGS; i++) {\n\t\tduk_uint8_t tmp[DUK_STRDATA_MAX_STRLEN];\n\t\tduk_small_uint_t len;\n\t\tduk_hstring *h;\n\n\t\tlen = duk_bd_decode_bitpacked_string(bd, tmp);\n\n\t\t/* No need to length check string: it will never exceed even\n\t\t * the 16-bit length maximum.\n\t\t */\n\t\tDUK_ASSERT(len <= 0xffffUL);\n\t\tDUK_DDD(DUK_DDDPRINT(\"intern built-in string %ld\", (long) i));\n\t\th = duk_heap_strtable_intern(heap, tmp, len);\n\t\tif (!h) {\n\t\t\tgoto failed;\n\t\t}\n\t\tDUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) h));\n\n\t\t/* Special flags checks.  Since these strings are always\n\t\t * reachable and a string cannot appear twice in the string\n\t\t * table, there's no need to check/set these flags elsewhere.\n\t\t * The 'internal' flag is set by string intern code.\n\t\t */\n\t\tif (i == DUK_STRIDX_EVAL || i == DUK_STRIDX_LC_ARGUMENTS) {\n\t\t\tDUK_HSTRING_SET_EVAL_OR_ARGUMENTS(h);\n\t\t}\n\t\tif (i >= DUK_STRIDX_START_RESERVED && i < DUK_STRIDX_END_RESERVED) {\n\t\t\tDUK_HSTRING_SET_RESERVED_WORD(h);\n\t\t\tif (i >= DUK_STRIDX_START_STRICT_RESERVED) {\n\t\t\t\tDUK_HSTRING_SET_STRICT_RESERVED_WORD(h);\n\t\t\t}\n\t\t}\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"interned: %!O\", (duk_heaphdr *) h));\n\n\t\t/* XXX: The incref macro takes a thread pointer but doesn't\n\t\t * use it right now.\n\t\t */\n\t\tDUK_HSTRING_INCREF(_never_referenced_, h);\n\n#if defined(DUK_USE_HEAPPTR16)\n\t\theap->strs16[i] = DUK_USE_HEAPPTR_ENC16(heap->heap_udata, (void *) h);\n#else\n\t\theap->strs[i] = h;\n#endif\n\t}\n\n\treturn 1;\n\n failed:\n\treturn 0;\n}\n#endif  /* DUK_USE_ROM_STRINGS */\n\nDUK_LOCAL duk_bool_t duk__init_heap_thread(duk_heap *heap) {\n\tduk_hthread *thr;\n\n\tDUK_D(DUK_DPRINT(\"heap init: alloc heap thread\"));\n\tthr = duk_hthread_alloc_unchecked(heap,\n\t                                  DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                                  DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_THREAD));\n\tif (thr == NULL) {\n\t\tDUK_D(DUK_DPRINT(\"failed to alloc heap_thread\"));\n\t\treturn 0;\n\t}\n\tthr->state = DUK_HTHREAD_STATE_INACTIVE;\n#if defined(DUK_USE_ROM_STRINGS)\n\t/* No strs[] pointer. */\n#else  /* DUK_USE_ROM_STRINGS */\n#if defined(DUK_USE_HEAPPTR16)\n\tthr->strs16 = heap->strs16;\n#else\n\tthr->strs = heap->strs;\n#endif\n#endif  /* DUK_USE_ROM_STRINGS */\n\n\theap->heap_thread = thr;\n\tDUK_HTHREAD_INCREF(thr, thr);  /* Note: first argument not really used */\n\n\t/* 'thr' is now reachable */\n\n\tDUK_D(DUK_DPRINT(\"heap init: init heap thread stacks\"));\n\tif (!duk_hthread_init_stacks(heap, thr)) {\n\t\treturn 0;\n\t}\n\n\t/* XXX: this may now fail, and is not handled correctly */\n\tduk_hthread_create_builtin_objects(thr);\n\n\t/* default prototype (Note: 'thr' must be reachable) */\n\tDUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, (duk_hobject *) thr, thr->builtins[DUK_BIDX_THREAD_PROTOTYPE]);\n\n\treturn 1;\n}\n\n#if defined(DUK_USE_DEBUG)\n#define DUK__DUMPSZ(t)  do { \\\n\t\tDUK_D(DUK_DPRINT(\"\" #t \"=%ld\", (long) sizeof(t))); \\\n\t} while (0)\n\n/* These is not 100% because format would need to be non-portable \"long long\".\n * Also print out as doubles to catch cases where the \"long\" type is not wide\n * enough; the limits will then not be printed accurately but the magnitude\n * will be correct.\n */\n#define DUK__DUMPLM_SIGNED_RAW(t,a,b)  do { \\\n\t\tDUK_D(DUK_DPRINT(t \"=[%ld,%ld]=[%lf,%lf]\", \\\n\t\t                 (long) (a), (long) (b), \\\n\t\t                 (double) (a), (double) (b))); \\\n\t} while (0)\n#define DUK__DUMPLM_UNSIGNED_RAW(t,a,b)  do { \\\n\t\tDUK_D(DUK_DPRINT(t \"=[%lu,%lu]=[%lf,%lf]\", \\\n\t\t                 (unsigned long) (a), (unsigned long) (b), \\\n\t\t                 (double) (a), (double) (b))); \\\n\t} while (0)\n#define DUK__DUMPLM_SIGNED(t)  do { \\\n\t\tDUK__DUMPLM_SIGNED_RAW(\"DUK_\" #t \"_{MIN,MAX}\", DUK_##t##_MIN, DUK_##t##_MAX); \\\n\t} while (0)\n#define DUK__DUMPLM_UNSIGNED(t)  do { \\\n\t\tDUK__DUMPLM_UNSIGNED_RAW(\"DUK_\" #t \"_{MIN,MAX}\", DUK_##t##_MIN, DUK_##t##_MAX); \\\n\t} while (0)\n\nDUK_LOCAL void duk__dump_type_sizes(void) {\n\tDUK_D(DUK_DPRINT(\"sizeof()\"));\n\n\t/* basic platform types */\n\tDUK__DUMPSZ(char);\n\tDUK__DUMPSZ(short);\n\tDUK__DUMPSZ(int);\n\tDUK__DUMPSZ(long);\n\tDUK__DUMPSZ(double);\n\tDUK__DUMPSZ(void *);\n\tDUK__DUMPSZ(size_t);\n\n\t/* basic types from duk_features.h */\n\tDUK__DUMPSZ(duk_uint8_t);\n\tDUK__DUMPSZ(duk_int8_t);\n\tDUK__DUMPSZ(duk_uint16_t);\n\tDUK__DUMPSZ(duk_int16_t);\n\tDUK__DUMPSZ(duk_uint32_t);\n\tDUK__DUMPSZ(duk_int32_t);\n\tDUK__DUMPSZ(duk_uint64_t);\n\tDUK__DUMPSZ(duk_int64_t);\n\tDUK__DUMPSZ(duk_uint_least8_t);\n\tDUK__DUMPSZ(duk_int_least8_t);\n\tDUK__DUMPSZ(duk_uint_least16_t);\n\tDUK__DUMPSZ(duk_int_least16_t);\n\tDUK__DUMPSZ(duk_uint_least32_t);\n\tDUK__DUMPSZ(duk_int_least32_t);\n#if defined(DUK_USE_64BIT_OPS)\n\tDUK__DUMPSZ(duk_uint_least64_t);\n\tDUK__DUMPSZ(duk_int_least64_t);\n#endif\n\tDUK__DUMPSZ(duk_uint_fast8_t);\n\tDUK__DUMPSZ(duk_int_fast8_t);\n\tDUK__DUMPSZ(duk_uint_fast16_t);\n\tDUK__DUMPSZ(duk_int_fast16_t);\n\tDUK__DUMPSZ(duk_uint_fast32_t);\n\tDUK__DUMPSZ(duk_int_fast32_t);\n#if defined(DUK_USE_64BIT_OPS)\n\tDUK__DUMPSZ(duk_uint_fast64_t);\n\tDUK__DUMPSZ(duk_int_fast64_t);\n#endif\n\tDUK__DUMPSZ(duk_uintptr_t);\n\tDUK__DUMPSZ(duk_intptr_t);\n\tDUK__DUMPSZ(duk_uintmax_t);\n\tDUK__DUMPSZ(duk_intmax_t);\n\tDUK__DUMPSZ(duk_double_t);\n\n\t/* important chosen base types */\n\tDUK__DUMPSZ(duk_int_t);\n\tDUK__DUMPSZ(duk_uint_t);\n\tDUK__DUMPSZ(duk_int_fast_t);\n\tDUK__DUMPSZ(duk_uint_fast_t);\n\tDUK__DUMPSZ(duk_small_int_t);\n\tDUK__DUMPSZ(duk_small_uint_t);\n\tDUK__DUMPSZ(duk_small_int_fast_t);\n\tDUK__DUMPSZ(duk_small_uint_fast_t);\n\n\t/* some derived types */\n\tDUK__DUMPSZ(duk_codepoint_t);\n\tDUK__DUMPSZ(duk_ucodepoint_t);\n\tDUK__DUMPSZ(duk_idx_t);\n\tDUK__DUMPSZ(duk_errcode_t);\n\tDUK__DUMPSZ(duk_uarridx_t);\n\n\t/* tval */\n\tDUK__DUMPSZ(duk_double_union);\n\tDUK__DUMPSZ(duk_tval);\n\n\t/* structs from duk_forwdecl.h */\n\tDUK__DUMPSZ(duk_jmpbuf);  /* just one 'int' for C++ exceptions */\n\tDUK__DUMPSZ(duk_heaphdr);\n\tDUK__DUMPSZ(duk_heaphdr_string);\n\tDUK__DUMPSZ(duk_hstring);\n\tDUK__DUMPSZ(duk_hstring_external);\n\tDUK__DUMPSZ(duk_hobject);\n\tDUK__DUMPSZ(duk_harray);\n\tDUK__DUMPSZ(duk_hcompfunc);\n\tDUK__DUMPSZ(duk_hnatfunc);\n\tDUK__DUMPSZ(duk_hdecenv);\n\tDUK__DUMPSZ(duk_hobjenv);\n\tDUK__DUMPSZ(duk_hthread);\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n\tDUK__DUMPSZ(duk_hbufobj);\n#endif\n\tDUK__DUMPSZ(duk_hbuffer);\n\tDUK__DUMPSZ(duk_hbuffer_fixed);\n\tDUK__DUMPSZ(duk_hbuffer_dynamic);\n\tDUK__DUMPSZ(duk_hbuffer_external);\n\tDUK__DUMPSZ(duk_propaccessor);\n\tDUK__DUMPSZ(duk_propvalue);\n\tDUK__DUMPSZ(duk_propdesc);\n\tDUK__DUMPSZ(duk_heap);\n\tDUK__DUMPSZ(duk_activation);\n\tDUK__DUMPSZ(duk_catcher);\n\tDUK__DUMPSZ(duk_strcache);\n\tDUK__DUMPSZ(duk_ljstate);\n\tDUK__DUMPSZ(duk_fixedbuffer);\n\tDUK__DUMPSZ(duk_bitdecoder_ctx);\n\tDUK__DUMPSZ(duk_bitencoder_ctx);\n\tDUK__DUMPSZ(duk_token);\n\tDUK__DUMPSZ(duk_re_token);\n\tDUK__DUMPSZ(duk_lexer_point);\n\tDUK__DUMPSZ(duk_lexer_ctx);\n\tDUK__DUMPSZ(duk_compiler_instr);\n\tDUK__DUMPSZ(duk_compiler_func);\n\tDUK__DUMPSZ(duk_compiler_ctx);\n\tDUK__DUMPSZ(duk_re_matcher_ctx);\n\tDUK__DUMPSZ(duk_re_compiler_ctx);\n}\nDUK_LOCAL void duk__dump_type_limits(void) {\n\tDUK_D(DUK_DPRINT(\"limits\"));\n\n\t/* basic types */\n\tDUK__DUMPLM_SIGNED(INT8);\n\tDUK__DUMPLM_UNSIGNED(UINT8);\n\tDUK__DUMPLM_SIGNED(INT_FAST8);\n\tDUK__DUMPLM_UNSIGNED(UINT_FAST8);\n\tDUK__DUMPLM_SIGNED(INT_LEAST8);\n\tDUK__DUMPLM_UNSIGNED(UINT_LEAST8);\n\tDUK__DUMPLM_SIGNED(INT16);\n\tDUK__DUMPLM_UNSIGNED(UINT16);\n\tDUK__DUMPLM_SIGNED(INT_FAST16);\n\tDUK__DUMPLM_UNSIGNED(UINT_FAST16);\n\tDUK__DUMPLM_SIGNED(INT_LEAST16);\n\tDUK__DUMPLM_UNSIGNED(UINT_LEAST16);\n\tDUK__DUMPLM_SIGNED(INT32);\n\tDUK__DUMPLM_UNSIGNED(UINT32);\n\tDUK__DUMPLM_SIGNED(INT_FAST32);\n\tDUK__DUMPLM_UNSIGNED(UINT_FAST32);\n\tDUK__DUMPLM_SIGNED(INT_LEAST32);\n\tDUK__DUMPLM_UNSIGNED(UINT_LEAST32);\n#if defined(DUK_USE_64BIT_OPS)\n\tDUK__DUMPLM_SIGNED(INT64);\n\tDUK__DUMPLM_UNSIGNED(UINT64);\n\tDUK__DUMPLM_SIGNED(INT_FAST64);\n\tDUK__DUMPLM_UNSIGNED(UINT_FAST64);\n\tDUK__DUMPLM_SIGNED(INT_LEAST64);\n\tDUK__DUMPLM_UNSIGNED(UINT_LEAST64);\n#endif\n\tDUK__DUMPLM_SIGNED(INTPTR);\n\tDUK__DUMPLM_UNSIGNED(UINTPTR);\n\tDUK__DUMPLM_SIGNED(INTMAX);\n\tDUK__DUMPLM_UNSIGNED(UINTMAX);\n\n\t/* derived types */\n\tDUK__DUMPLM_SIGNED(INT);\n\tDUK__DUMPLM_UNSIGNED(UINT);\n\tDUK__DUMPLM_SIGNED(INT_FAST);\n\tDUK__DUMPLM_UNSIGNED(UINT_FAST);\n\tDUK__DUMPLM_SIGNED(SMALL_INT);\n\tDUK__DUMPLM_UNSIGNED(SMALL_UINT);\n\tDUK__DUMPLM_SIGNED(SMALL_INT_FAST);\n\tDUK__DUMPLM_UNSIGNED(SMALL_UINT_FAST);\n}\n\nDUK_LOCAL void duk__dump_misc_options(void) {\n\tDUK_D(DUK_DPRINT(\"DUK_VERSION: %ld\", (long) DUK_VERSION));\n\tDUK_D(DUK_DPRINT(\"DUK_GIT_DESCRIBE: %s\", DUK_GIT_DESCRIBE));\n\tDUK_D(DUK_DPRINT(\"OS string: %s\", DUK_USE_OS_STRING));\n\tDUK_D(DUK_DPRINT(\"architecture string: %s\", DUK_USE_ARCH_STRING));\n\tDUK_D(DUK_DPRINT(\"compiler string: %s\", DUK_USE_COMPILER_STRING));\n\tDUK_D(DUK_DPRINT(\"debug level: %ld\", (long) DUK_USE_DEBUG_LEVEL));\n#if defined(DUK_USE_PACKED_TVAL)\n\tDUK_D(DUK_DPRINT(\"DUK_USE_PACKED_TVAL: yes\"));\n#else\n\tDUK_D(DUK_DPRINT(\"DUK_USE_PACKED_TVAL: no\"));\n#endif\n#if defined(DUK_USE_VARIADIC_MACROS)\n\tDUK_D(DUK_DPRINT(\"DUK_USE_VARIADIC_MACROS: yes\"));\n#else\n\tDUK_D(DUK_DPRINT(\"DUK_USE_VARIADIC_MACROS: no\"));\n#endif\n#if defined(DUK_USE_INTEGER_LE)\n\tDUK_D(DUK_DPRINT(\"integer endianness: little\"));\n#elif defined(DUK_USE_INTEGER_ME)\n\tDUK_D(DUK_DPRINT(\"integer endianness: mixed\"));\n#elif defined(DUK_USE_INTEGER_BE)\n\tDUK_D(DUK_DPRINT(\"integer endianness: big\"));\n#else\n\tDUK_D(DUK_DPRINT(\"integer endianness: ???\"));\n#endif\n#if defined(DUK_USE_DOUBLE_LE)\n\tDUK_D(DUK_DPRINT(\"IEEE double endianness: little\"));\n#elif defined(DUK_USE_DOUBLE_ME)\n\tDUK_D(DUK_DPRINT(\"IEEE double endianness: mixed\"));\n#elif defined(DUK_USE_DOUBLE_BE)\n\tDUK_D(DUK_DPRINT(\"IEEE double endianness: big\"));\n#else\n\tDUK_D(DUK_DPRINT(\"IEEE double endianness: ???\"));\n#endif\n}\n#endif  /* DUK_USE_DEBUG */\n\nDUK_INTERNAL\nduk_heap *duk_heap_alloc(duk_alloc_function alloc_func,\n                         duk_realloc_function realloc_func,\n                         duk_free_function free_func,\n                         void *heap_udata,\n                         duk_fatal_function fatal_func) {\n\tduk_heap *res = NULL;\n\tduk_uint32_t st_initsize;\n\n\tDUK_D(DUK_DPRINT(\"allocate heap\"));\n\n\t/*\n\t *  Random config sanity asserts\n\t */\n\n\tDUK_ASSERT(DUK_USE_STRTAB_MINSIZE >= 64);\n\n\tDUK_ASSERT((DUK_HTYPE_STRING & 0x01U) == 0);\n\tDUK_ASSERT((DUK_HTYPE_BUFFER & 0x01U) == 0);\n\tDUK_ASSERT((DUK_HTYPE_OBJECT & 0x01U) == 1);  /* DUK_HEAPHDR_IS_OBJECT() relies ont his. */\n\n\t/*\n\t *  Debug dump type sizes\n\t */\n\n#if defined(DUK_USE_DEBUG)\n\tduk__dump_misc_options();\n\tduk__dump_type_sizes();\n\tduk__dump_type_limits();\n#endif\n\n\t/*\n\t *  If selftests enabled, run them as early as possible.\n\t */\n\n#if defined(DUK_USE_SELF_TESTS)\n\tDUK_D(DUK_DPRINT(\"run self tests\"));\n\tif (duk_selftest_run_tests(alloc_func, realloc_func, free_func, heap_udata) > 0) {\n\t\tfatal_func(heap_udata, \"self test(s) failed\");\n\t}\n\tDUK_D(DUK_DPRINT(\"self tests passed\"));\n#endif\n\n\t/*\n\t *  Important assert-like checks that should be enabled even\n\t *  when assertions are otherwise not enabled.\n\t */\n\n#if defined(DUK_USE_EXEC_REGCONST_OPTIMIZE)\n\t/* Can't check sizeof() using preprocessor so explicit check.\n\t * This will be optimized away in practice; unfortunately a\n\t * warning is generated on some compilers as a result.\n\t */\n#if defined(DUK_USE_PACKED_TVAL)\n\tif (sizeof(duk_tval) != 8) {\n#else\n\tif (sizeof(duk_tval) != 16) {\n#endif\n\t\tfatal_func(heap_udata, \"sizeof(duk_tval) not 8 or 16, cannot use DUK_USE_EXEC_REGCONST_OPTIMIZE option\");\n\t}\n#endif  /* DUK_USE_EXEC_REGCONST_OPTIMIZE */\n\n\t/*\n\t *  Computed values (e.g. INFINITY)\n\t */\n\n#if defined(DUK_USE_COMPUTED_NAN)\n\tdo {\n\t\t/* Workaround for some exotic platforms where NAN is missing\n\t\t * and the expression (0.0 / 0.0) does NOT result in a NaN.\n\t\t * Such platforms use the global 'duk_computed_nan' which must\n\t\t * be initialized at runtime.  Use 'volatile' to ensure that\n\t\t * the compiler will actually do the computation and not try\n\t\t * to do constant folding which might result in the original\n\t\t * problem.\n\t\t */\n\t\tvolatile double dbl1 = 0.0;\n\t\tvolatile double dbl2 = 0.0;\n\t\tduk_computed_nan = dbl1 / dbl2;\n\t} while (0);\n#endif\n\n#if defined(DUK_USE_COMPUTED_INFINITY)\n\tdo {\n\t\t/* Similar workaround for INFINITY. */\n\t\tvolatile double dbl1 = 1.0;\n\t\tvolatile double dbl2 = 0.0;\n\t\tduk_computed_infinity = dbl1 / dbl2;\n\t} while (0);\n#endif\n\n\t/*\n\t *  Allocate heap struct\n\t *\n\t *  Use a raw call, all macros expect the heap to be initialized\n\t */\n\n#if defined(DUK_USE_INJECT_HEAP_ALLOC_ERROR) && (DUK_USE_INJECT_HEAP_ALLOC_ERROR == 1)\n\tgoto failed;\n#endif\n\tDUK_D(DUK_DPRINT(\"alloc duk_heap object\"));\n\tres = (duk_heap *) alloc_func(heap_udata, sizeof(duk_heap));\n\tif (!res) {\n\t\tgoto failed;\n\t}\n\n\t/*\n\t *  Zero the struct, and start initializing roughly in order\n\t */\n\n\tDUK_MEMZERO(res, sizeof(*res));\n#if defined(DUK_USE_ASSERTIONS)\n\tres->heap_initializing = 1;\n#endif\n\n\t/* explicit NULL inits */\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n\tres->heap_udata = NULL;\n\tres->heap_allocated = NULL;\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tres->refzero_list = NULL;\n#endif\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n\tres->finalize_list = NULL;\n#if defined(DUK_USE_ASSERTIONS)\n\tres->currently_finalizing = NULL;\n#endif\n#endif\n\tres->heap_thread = NULL;\n\tres->curr_thread = NULL;\n\tres->heap_object = NULL;\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\tres->strtable16 = NULL;\n#else\n\tres->strtable = NULL;\n#endif\n#if defined(DUK_USE_ROM_STRINGS)\n\t/* no res->strs[] */\n#else  /* DUK_USE_ROM_STRINGS */\n#if defined(DUK_USE_HEAPPTR16)\n\t/* res->strs16[] is zeroed and zero decodes to NULL, so no NULL inits. */\n#else\n\t{\n\t\tduk_small_uint_t i;\n\t        for (i = 0; i < DUK_HEAP_NUM_STRINGS; i++) {\n\t\t\tres->strs[i] = NULL;\n\t        }\n\t}\n#endif\n#endif  /* DUK_USE_ROM_STRINGS */\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\tres->dbg_read_cb = NULL;\n\tres->dbg_write_cb = NULL;\n\tres->dbg_peek_cb = NULL;\n\tres->dbg_read_flush_cb = NULL;\n\tres->dbg_write_flush_cb = NULL;\n\tres->dbg_request_cb = NULL;\n\tres->dbg_udata = NULL;\n\tres->dbg_step_thread = NULL;\n#endif\n#endif  /* DUK_USE_EXPLICIT_NULL_INIT */\n\n\tres->alloc_func = alloc_func;\n\tres->realloc_func = realloc_func;\n\tres->free_func = free_func;\n\tres->heap_udata = heap_udata;\n\tres->fatal_func = fatal_func;\n\n\t/* XXX: for now there's a pointer packing zero assumption, i.e.\n\t * NULL <=> compressed pointer 0.  If this is removed, may need\n\t * to precompute e.g. null16 here.\n\t */\n\n\t/* res->ms_trigger_counter == 0 -> now causes immediate GC; which is OK */\n\n\t/* Prevent mark-and-sweep and finalizer execution until heap is completely\n\t * initialized.\n\t */\n\tDUK_ASSERT(res->ms_prevent_count == 0);\n\tDUK_ASSERT(res->pf_prevent_count == 0);\n\tres->ms_prevent_count = 1;\n\tres->pf_prevent_count = 1;\n\tDUK_ASSERT(res->ms_running == 0);\n\n\tres->call_recursion_depth = 0;\n\tres->call_recursion_limit = DUK_USE_NATIVE_CALL_RECLIMIT;\n\n\t/* XXX: use the pointer as a seed for now: mix in time at least */\n\n\t/* The casts through duk_intptr_t is to avoid the following GCC warning:\n\t *\n\t *   warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]\n\t *\n\t * This still generates a /Wp64 warning on VS2010 when compiling for x86.\n\t */\n#if defined(DUK_USE_ROM_STRINGS)\n\t/* XXX: make a common DUK_USE_ option, and allow custom fixed seed? */\n\tDUK_D(DUK_DPRINT(\"using rom strings, force heap hash_seed to fixed value 0x%08lx\", (long) DUK__FIXED_HASH_SEED));\n\tres->hash_seed = (duk_uint32_t) DUK__FIXED_HASH_SEED;\n#else  /* DUK_USE_ROM_STRINGS */\n\tres->hash_seed = (duk_uint32_t) (duk_intptr_t) res;\n#if !defined(DUK_USE_STRHASH_DENSE)\n\tres->hash_seed ^= 5381;  /* Bernstein hash init value is normally 5381; XOR it in in case pointer low bits are 0 */\n#endif\n#endif  /* DUK_USE_ROM_STRINGS */\n\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n\tres->lj.jmpbuf_ptr = NULL;\n#endif\n\tDUK_ASSERT(res->lj.type == DUK_LJ_TYPE_UNKNOWN);  /* zero */\n\tDUK_ASSERT(res->lj.iserror == 0);\n\tDUK_TVAL_SET_UNDEFINED(&res->lj.value1);\n\tDUK_TVAL_SET_UNDEFINED(&res->lj.value2);\n\n\tDUK_ASSERT_LJSTATE_UNSET(res);\n\n\t/*\n\t *  Init stringtable: fixed variant\n\t */\n\n\tst_initsize = DUK_USE_STRTAB_MINSIZE;\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\tres->strtable16 = (duk_uint16_t *) alloc_func(heap_udata, sizeof(duk_uint16_t) * st_initsize);\n\tif (res->strtable16 == NULL) {\n\t\tgoto failed;\n\t}\n#else\n\tres->strtable = (duk_hstring **) alloc_func(heap_udata, sizeof(duk_hstring *) * st_initsize);\n\tif (res->strtable == NULL) {\n\t\tgoto failed;\n\t}\n#endif\n\tres->st_size = st_initsize;\n\tres->st_mask = st_initsize - 1;\n#if (DUK_USE_STRTAB_MINSIZE != DUK_USE_STRTAB_MAXSIZE)\n\tDUK_ASSERT(res->st_count == 0);\n#endif\n\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\t/* zero assumption */\n\tDUK_MEMZERO(res->strtable16, sizeof(duk_uint16_t) * st_initsize);\n#else\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n\t{\n\t\tduk_small_uint_t i;\n\t        for (i = 0; i < st_initsize; i++) {\n\t\t\tres->strtable[i] = NULL;\n\t        }\n\t}\n#else\n\tDUK_MEMZERO(res->strtable, sizeof(duk_hstring *) * st_initsize);\n#endif  /* DUK_USE_EXPLICIT_NULL_INIT */\n#endif  /* DUK_USE_STRTAB_PTRCOMP */\n\n\t/*\n\t *  Init stringcache\n\t */\n\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n\t{\n\t\tduk_small_uint_t i;\n\t\tfor (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) {\n\t\t\tres->strcache[i].h = NULL;\n\t\t}\n\t}\n#endif\n\n\t/* XXX: error handling is incomplete.  It would be cleanest if\n\t * there was a setjmp catchpoint, so that all init code could\n\t * freely throw errors.  If that were the case, the return code\n\t * passing here could be removed.\n\t */\n\n\t/*\n\t *  Init built-in strings\n\t */\n\n#if defined(DUK_USE_INJECT_HEAP_ALLOC_ERROR) && (DUK_USE_INJECT_HEAP_ALLOC_ERROR == 2)\n\tgoto failed;\n#endif\n\tDUK_D(DUK_DPRINT(\"heap init: initialize heap strings\"));\n\tif (!duk__init_heap_strings(res)) {\n\t\tgoto failed;\n\t}\n\n\t/*\n\t *  Init the heap thread\n\t */\n\n#if defined(DUK_USE_INJECT_HEAP_ALLOC_ERROR) && (DUK_USE_INJECT_HEAP_ALLOC_ERROR == 3)\n\tgoto failed;\n#endif\n\tDUK_D(DUK_DPRINT(\"heap init: initialize heap thread\"));\n\tif (!duk__init_heap_thread(res)) {\n\t\tgoto failed;\n\t}\n\n\t/*\n\t *  Init the heap object\n\t */\n\n#if defined(DUK_USE_INJECT_HEAP_ALLOC_ERROR) && (DUK_USE_INJECT_HEAP_ALLOC_ERROR == 4)\n\tgoto failed;\n#endif\n\tDUK_D(DUK_DPRINT(\"heap init: initialize heap object\"));\n\tDUK_ASSERT(res->heap_thread != NULL);\n\tres->heap_object = duk_hobject_alloc_unchecked(res, DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                                                    DUK_HOBJECT_FLAG_FASTREFS |\n\t                                                    DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_OBJECT));\n\tif (res->heap_object == NULL) {\n\t\tgoto failed;\n\t}\n\tDUK_HOBJECT_INCREF(res->heap_thread, res->heap_object);\n\n\t/*\n\t *  Odds and ends depending on the heap thread\n\t */\n\n#if !defined(DUK_USE_GET_RANDOM_DOUBLE)\n#if defined(DUK_USE_PREFER_SIZE) || !defined(DUK_USE_64BIT_OPS)\n\tres->rnd_state = (duk_uint32_t) DUK_USE_DATE_GET_NOW((duk_context *) res->heap_thread);\n\tduk_util_tinyrandom_prepare_seed(res->heap_thread);\n#else\n\tres->rnd_state[0] = (duk_uint64_t) DUK_USE_DATE_GET_NOW((duk_context *) res->heap_thread);\n\tDUK_ASSERT(res->rnd_state[1] == 0);  /* Not filled here, filled in by seed preparation. */\n#if 0  /* Manual test values matching misc/xoroshiro128plus_test.c. */\n\tres->rnd_state[0] = 0xdeadbeef12345678ULL;\n\tres->rnd_state[1] = 0xcafed00d12345678ULL;\n#endif\n\tduk_util_tinyrandom_prepare_seed(res->heap_thread);\n\t/* Mix in heap pointer: this ensures that if two Duktape heaps are\n\t * created on the same millisecond, they get a different PRNG\n\t * sequence (unless e.g. virtual memory addresses cause also the\n\t * heap object pointer to be the same).\n\t */\n\t{\n\t\tduk_uint64_t tmp_u64;\n\t\ttmp_u64 = 0;\n\t\tDUK_MEMCPY((void *) &tmp_u64,\n\t\t           (const void *) &res,\n\t\t           (size_t) (sizeof(void *) >= sizeof(duk_uint64_t) ? sizeof(duk_uint64_t) : sizeof(void *)));\n\t\tres->rnd_state[1] ^= tmp_u64;\n\t}\n\tdo {\n\t\tduk_small_uint_t i;\n\t\tfor (i = 0; i < 10; i++) {\n\t\t\t/* Throw away a few initial random numbers just in\n\t\t\t * case.  Probably unnecessary due to SplitMix64\n\t\t\t * preparation.\n\t\t\t */\n\t\t\t(void) duk_util_tinyrandom_get_double(res->heap_thread);\n\t\t}\n\t} while (0);\n#endif\n#endif\n\n\t/*\n\t *  Allow finalizer and mark-and-sweep processing.\n\t */\n\n\tDUK_D(DUK_DPRINT(\"heap init: allow finalizer/mark-and-sweep processing\"));\n\tDUK_ASSERT(res->ms_prevent_count == 1);\n\tDUK_ASSERT(res->pf_prevent_count == 1);\n\tres->ms_prevent_count = 0;\n\tres->pf_prevent_count = 0;\n\tDUK_ASSERT(res->ms_running == 0);\n#if defined(DUK_USE_ASSERTIONS)\n\tres->heap_initializing = 0;\n#endif\n\n\t/*\n\t *  All done.\n\t */\n\n\tDUK_D(DUK_DPRINT(\"allocated heap: %p\", (void *) res));\n\treturn res;\n\n failed:\n\tDUK_D(DUK_DPRINT(\"heap allocation failed\"));\n\n\tif (res != NULL) {\n\t\t/* Assumes that allocated pointers and alloc funcs are valid\n\t\t * if res exists.\n\t\t */\n\t\tDUK_ASSERT(res->ms_prevent_count == 1);\n\t\tDUK_ASSERT(res->pf_prevent_count == 1);\n\t\tDUK_ASSERT(res->ms_running == 0);\n\t\tif (res->heap_thread != NULL) {\n\t\t\tres->ms_prevent_count = 0;\n\t\t\tres->pf_prevent_count = 0;\n\t\t}\n#if defined(DUK_USE_ASSERTIONS)\n\t\tres->heap_initializing = 0;\n#endif\n\n\t\tDUK_ASSERT(res->alloc_func != NULL);\n\t\tDUK_ASSERT(res->realloc_func != NULL);\n\t\tDUK_ASSERT(res->free_func != NULL);\n\t\tduk_heap_free(res);\n\t}\n\n\treturn NULL;\n}\n\n/* automatic undefs */\n#undef DUK__DUMPLM_SIGNED\n#undef DUK__DUMPLM_SIGNED_RAW\n#undef DUK__DUMPLM_UNSIGNED\n#undef DUK__DUMPLM_UNSIGNED_RAW\n#undef DUK__DUMPSZ\n#undef DUK__FIXED_HASH_SEED\n/*\n *  Finalizer handling.\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n\n/*\n *  Fake torture finalizer.\n */\n\n#if defined(DUK_USE_FINALIZER_TORTURE)\nDUK_LOCAL duk_ret_t duk__fake_global_finalizer(duk_context *ctx) {\n\tDUK_DD(DUK_DDPRINT(\"fake global torture finalizer executed\"));\n\n\t/* Require a lot of stack to force a value stack grow/shrink. */\n\tduk_require_stack(ctx, 100000);\n\n\t/* Force a reallocation with pointer change for value, call, and\n\t * catch stacks to maximize side effects.\n\t */\n\tduk_hthread_valstack_torture_realloc((duk_hthread *) ctx);\n\tduk_hthread_callstack_torture_realloc((duk_hthread *) ctx);\n\tduk_hthread_catchstack_torture_realloc((duk_hthread *) ctx);\n\n\t/* Inner function call, error throw. */\n\tduk_eval_string_noresult(ctx,\n\t\t\"(function dummy() {\\n\"\n\t\t\"    dummy.prototype = null;  /* break reference loop */\\n\"\n\t\t\"    try {\\n\"\n\t\t\"        throw 'fake-finalizer-dummy-error';\\n\"\n\t\t\"    } catch (e) {\\n\"\n\t\t\"        void e;\\n\"\n\t\t\"    }\\n\"\n\t\t\"})()\");\n\n\t/* The above creates garbage (e.g. a function instance).  Because\n\t * the function/prototype reference loop is broken, it gets collected\n\t * immediately by DECREF.  If Function.prototype has a _Finalizer\n\t * property (happens in some test cases), the garbage gets queued to\n\t * finalize_list.  This still won't cause an infinite loop because\n\t * the torture finalizer is called once per finalize_list run and\n\t * the garbage gets handled in the same run.  (If the garbage needs\n\t * mark-and-sweep collection, an infinite loop might ensue.)\n\t */\n\treturn 0;\n}\n\nDUK_LOCAL void duk__run_global_torture_finalizer(duk_hthread *thr) {\n\tDUK_ASSERT(thr != NULL);\n\n\t/* Avoid fake finalization when callstack limit has been reached.\n\t * Otherwise a callstack limit error will be created, then refzero'ed.\n\t */\n\tif (thr->heap->call_recursion_depth >= thr->heap->call_recursion_limit ||\n\t    thr->callstack_size + 2 * DUK_CALLSTACK_GROW_STEP >= thr->callstack_max /*approximate*/) {\n\t\tDUK_D(DUK_DPRINT(\"skip global torture finalizer because of call recursion or call stack size limit\"));\n\t\treturn;\n\t}\n\n\t/* Run fake finalizer.  Avoid creating unnecessary garbage. */\n\tduk_push_c_function((duk_context *) thr, duk__fake_global_finalizer, 0 /*nargs*/);\n\t(void) duk_pcall((duk_context *) thr, 0 /*nargs*/);\n\tduk_pop((duk_context *) thr);\n}\n#endif  /* DUK_USE_FINALIZER_TORTURE */\n\n/*\n *  Process the finalize_list to completion.\n *\n *  An object may be placed on finalize_list by either refcounting or\n *  mark-and-sweep.  The refcount of objects placed by refcounting will be\n *  zero; the refcount of objects placed by mark-and-sweep is > 0.  In both\n *  cases the refcount is bumped by 1 artificially so that a REFZERO event\n *  can never happen while an object is waiting for finalization.  Without\n *  this bump a REFZERO could now happen because user code may call\n *  duk_push_heapptr() and then pop a value even when it's on finalize_list.\n *\n *  List processing assumes refcounts are kept up-to-date at all times, so\n *  that once the finalizer returns, a zero refcount is a reliable reason to\n *  free the object immediately rather than place it back to the heap.  This\n *  is the case because we run outside of refzero_list processing so that\n *  DECREF cascades are handled fully inline.\n *\n *  For mark-and-sweep queued objects (had_zero_refcount false) the object\n *  may be freed immediately if its refcount is zero after the finalizer call\n *  (i.e. finalizer removed the reference loop for the object).  If not, the\n *  next mark-and-sweep will collect the object unless it has become reachable\n *  (i.e. rescued) by that time and its refcount hasn't fallen to zero before\n *  that.  Mark-and-sweep detects these objects because their FINALIZED flag\n *  is set.\n *\n *  There's an inherent limitation for mark-and-sweep finalizer rescuing: an\n *  object won't get refinalized if (1) it's rescued, but (2) becomes\n *  unreachable before mark-and-sweep has had time to notice it.  The next\n *  mark-and-sweep round simply doesn't have any information of whether the\n *  object has been unreachable the whole time or not (the only way to get\n *  that information would be a mark-and-sweep pass for *every finalized\n *  object*).  This is awkward for the application because the mark-and-sweep\n *  round is not generally visible or under full application control.\n *\n *  For refcount queued objects (had_zero_refcount true) the object is either\n *  immediately freed or rescued, and waiting for a mark-and-sweep round is not\n *  necessary (or desirable); FINALIZED is cleared when a rescued object is\n *  queued back to heap_allocated.  The object is eligible for finalization\n *  again (either via refcounting or mark-and-sweep) immediately after being\n *  rescued.  If a refcount finalized object is placed into an unreachable\n *  reference loop by its finalizer, it will get collected by mark-and-sweep\n *  and currently the finalizer will execute again.\n *\n *  There's a special case where:\n *\n *    - Mark-and-sweep queues an object to finalize_list for finalization.\n *    - The finalizer is executed, FINALIZED is set, and object is queued\n *      back to heap_allocated, waiting for a new mark-and-sweep round.\n *    - The object's refcount drops to zero before mark-and-sweep has a\n *      chance to run another round and make a rescue/free decision.\n *\n *  This is now handled by refzero code: if an object has a finalizer but\n *  FINALIZED is already set, the object is freed without finalizer processing.\n *  The outcome is the same as if mark-and-sweep was executed at that point;\n *  mark-and-sweep would also free the object without another finalizer run.\n *  This could also be changed so that the refzero-triggered finalizer *IS*\n *  executed: being refzero collected implies someone has operated on the\n *  object so it hasn't been totally unreachable the whole time.  This would\n *  risk a finalizer loop however.\n */\n\nDUK_INTERNAL void duk_heap_process_finalize_list(duk_heap *heap) {\n\tduk_heaphdr *curr;\n#if defined(DUK_USE_DEBUG)\n\tduk_size_t count = 0;\n#endif\n\n\tDUK_DDD(DUK_DDDPRINT(\"duk_heap_process_finalize_list: %p\", (void *) heap));\n\n\tif (heap->pf_prevent_count != 0) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"skip finalize_list processing: pf_prevent_count != 0\"));\n\t\treturn;\n\t}\n\n\t/* Heap alloc prevents mark-and-sweep before heap_thread is ready. */\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT(heap->heap_thread != NULL);\n\tDUK_ASSERT(heap->heap_thread->valstack != NULL);\n\tDUK_ASSERT(heap->heap_thread->callstack != NULL);\n\tDUK_ASSERT(heap->heap_thread->catchstack != NULL);\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tDUK_ASSERT(heap->refzero_list == NULL);\n#endif\n\n\tDUK_ASSERT(heap->pf_prevent_count == 0);\n\theap->pf_prevent_count = 1;\n\n\t/* Mark-and-sweep no longer needs to be prevented when running\n\t * finalizers: mark-and-sweep skips any rescue decisions if there\n\t * are any objects in finalize_list when mark-and-sweep is entered.\n\t * This protects finalized objects from incorrect rescue decisions\n\t * caused by finalize_list being a reachability root and only\n\t * partially processed.  Freeing decisions are not postponed.\n\t */\n\n\t/* When finalizer torture is enabled, make a fake finalizer call with\n\t * maximum side effects regardless of whether finalize_list is empty.\n\t */\n#if defined(DUK_USE_FINALIZER_TORTURE)\n\tduk__run_global_torture_finalizer(heap->heap_thread);\n#endif\n\n\t/* Process finalize_list until it becomes empty.  There's currently no\n\t * protection against a finalizer always creating more garbage.\n\t */\n\twhile ((curr = heap->finalize_list) != NULL) {\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\t\tduk_bool_t queue_back;\n#endif\n\n\t\tDUK_DD(DUK_DDPRINT(\"processing finalize_list entry: %p -> %!iO\", (void *) curr, curr));\n\n\t\tDUK_ASSERT(DUK_HEAPHDR_GET_TYPE(curr) == DUK_HTYPE_OBJECT);  /* Only objects have finalizers. */\n\t\tDUK_ASSERT(!DUK_HEAPHDR_HAS_REACHABLE(curr));\n\t\tDUK_ASSERT(!DUK_HEAPHDR_HAS_TEMPROOT(curr));\n\t\tDUK_ASSERT(DUK_HEAPHDR_HAS_FINALIZABLE(curr));  /* All objects on finalize_list will have this flag (except object being finalized right now). */\n\t\tDUK_ASSERT(!DUK_HEAPHDR_HAS_FINALIZED(curr));   /* Queueing code ensures. */\n\t\tDUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY(curr));  /* ROM objects never get freed (or finalized). */\n\n#if defined(DUK_USE_ASSERTIONS)\n\t\tDUK_ASSERT(heap->currently_finalizing == NULL);\n\t\theap->currently_finalizing = curr;\n#endif\n\n\t\t/* Clear FINALIZABLE for object being finalized, so that\n\t\t * duk_push_heapptr() can properly ignore the object.\n\t\t */\n\t\tDUK_HEAPHDR_CLEAR_FINALIZABLE(curr);\n\n\t\tif (DUK_LIKELY(!heap->pf_skip_finalizers)) {\n\t\t\t/* Run the finalizer, duk_heap_run_finalizer() sets\n\t\t\t * and checks for FINALIZED to prevent the finalizer\n\t\t\t * from executing multiple times per finalization cycle.\n\t\t\t * (This safeguard shouldn't be actually needed anymore).\n\t\t\t */\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\t\t\tduk_bool_t had_zero_refcount;\n#endif\n\n\t\t\t/* The object's refcount is >0 throughout so it won't be\n\t\t\t * refzero processed prematurely.\n\t\t\t */\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\t\t\tDUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT(curr) >= 1);\n\t\t\thad_zero_refcount = (DUK_HEAPHDR_GET_REFCOUNT(curr) == 1);  /* Preincremented on finalize_list insert. */\n#endif\n\n\t\t\tDUK_ASSERT(!DUK_HEAPHDR_HAS_FINALIZED(curr));\n\t\t\tduk_heap_run_finalizer(heap, (duk_hobject *) curr);  /* must never longjmp */\n\t\t\tDUK_ASSERT(DUK_HEAPHDR_HAS_FINALIZED(curr));\n\t\t\t/* XXX: assert that object is still in finalize_list\n\t\t\t * when duk_push_heapptr() allows automatic rescue.\n\t\t\t */\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\t\t\tDUK_DD(DUK_DDPRINT(\"refcount after finalizer (includes bump): %ld\", (long) DUK_HEAPHDR_GET_REFCOUNT(curr)));\n\t\t\tif (DUK_HEAPHDR_GET_REFCOUNT(curr) == 1) {  /* Only artificial bump in refcount? */\n#if defined(DUK_USE_DEBUG)\n\t\t\t\tif (had_zero_refcount) {\n\t\t\t\t\tDUK_DD(DUK_DDPRINT(\"finalized object's refcount is zero -> free immediately (refcount queued)\"));\n\t\t\t\t} else {\n\t\t\t\t\tDUK_DD(DUK_DDPRINT(\"finalized object's refcount is zero -> free immediately (mark-and-sweep queued)\"));\n\t\t\t\t}\n#endif\n\t\t\t\tqueue_back = 0;\n\t\t\t} else\n#endif\n\t\t\t{\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\t\t\t\tqueue_back = 1;\n\t\t\t\tif (had_zero_refcount) {\n\t\t\t\t\t/* When finalization is triggered\n\t\t\t\t\t * by refzero and we queue the object\n\t\t\t\t\t * back, clear FINALIZED right away\n\t\t\t\t\t * so that the object can be refinalized\n\t\t\t\t\t * immediately if necessary.\n\t\t\t\t\t */\n\t\t\t\t\tDUK_HEAPHDR_CLEAR_FINALIZED(curr);\n\t\t\t\t}\n#endif\n\t\t\t}\n\t\t} else {\n\t\t\t/* Used during heap destruction: don't actually run finalizers\n\t\t\t * because we're heading into forced finalization.  Instead,\n\t\t\t * queue finalizable objects back to the heap_allocated list.\n\t\t\t */\n\t\t\tDUK_D(DUK_DPRINT(\"skip finalizers flag set, queue object to heap_allocated without finalizing\"));\n\t\t\tDUK_ASSERT(!DUK_HEAPHDR_HAS_FINALIZED(curr));\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\t\t\tqueue_back = 1;\n#endif\n\t\t}\n\n\t\t/* Dequeue object from finalize_list.  Note that 'curr' may no\n\t\t * longer be finalize_list head because new objects may have\n\t\t * been queued to the list.  As a result we can't optimize for\n\t\t * the single-linked heap case and must scan the list for\n\t\t * removal, typically the scan is very short however.\n\t\t */\n\t\tDUK_HEAP_REMOVE_FROM_FINALIZE_LIST(heap, curr);\n\n\t\t/* Queue back to heap_allocated or free immediately. */\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\t\tif (queue_back) {\n\t\t\t/* FINALIZED is only cleared if object originally\n\t\t\t * queued for finalization by refcounting.  For\n\t\t\t * mark-and-sweep FINALIZED is left set, so that\n\t\t\t * next mark-and-sweep round can make a rescue/free\n\t\t\t * decision.\n\t\t\t */\n\t\t\tDUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT(curr) >= 1);\n\t\t\tDUK_HEAPHDR_PREDEC_REFCOUNT(curr);  /* Remove artificial refcount bump. */\n\t\t\tDUK_HEAPHDR_CLEAR_FINALIZABLE(curr);\n\t\t\tDUK_HEAP_INSERT_INTO_HEAP_ALLOCATED(heap, curr);\n\t\t} else {\n\t\t\t/* No need to remove the refcount bump here. */\n\t\t\tDUK_ASSERT(DUK_HEAPHDR_GET_TYPE(curr) == DUK_HTYPE_OBJECT);  /* currently, always the case */\n\t\t\tDUK_DD(DUK_DDPRINT(\"refcount finalize after finalizer call: %!O\", curr));\n\t\t\tduk_hobject_refcount_finalize_norz(heap, (duk_hobject *) curr);\n\t\t\tduk_free_hobject(heap, (duk_hobject *) curr);\n\t\t\tDUK_DD(DUK_DDPRINT(\"freed hobject after finalization: %p\", (void *) curr));\n\t\t}\n#else  /* DUK_USE_REFERENCE_COUNTING */\n\t\tDUK_HEAPHDR_CLEAR_FINALIZABLE(curr);\n\t\tDUK_HEAP_INSERT_INTO_HEAP_ALLOCATED(heap, curr);\n#endif  /* DUK_USE_REFERENCE_COUNTING */\n\n#if defined(DUK_USE_DEBUG)\n\t\tcount++;\n#endif\n\n#if defined(DUK_USE_ASSERTIONS)\n\t\tDUK_ASSERT(heap->currently_finalizing != NULL);\n\t\theap->currently_finalizing = NULL;\n#endif\n\t}\n\n\t/* finalize_list will always be processed completely. */\n\tDUK_ASSERT(heap->finalize_list == NULL);\n\n#if 0\n\t/* While NORZ macros are used above, this is unnecessary because the\n\t * only pending side effects are now finalizers, and finalize_list is\n\t * empty.\n\t */\n\tDUK_REFZERO_CHECK_SLOW(heap->heap_thread);\n#endif\n\n\t/* Prevent count may be bumped while finalizers run, but should always\n\t * be reliably unbumped by the time we get here.\n\t */\n\tDUK_ASSERT(heap->pf_prevent_count == 1);\n\theap->pf_prevent_count = 0;\n\n#if defined(DUK_USE_DEBUG)\n\tDUK_DD(DUK_DDPRINT(\"duk_heap_process_finalize_list: %ld finalizers called\", (long) count));\n#endif\n}\n\n/*\n *  Run an duk_hobject finalizer.  Must never throw an uncaught error\n *  (but may throw caught errors).\n *\n *  There is no return value.  Any return value or error thrown by\n *  the finalizer is ignored (although errors are debug logged).\n *\n *  Notes:\n *\n *    - The finalizer thread 'top' assertions are there because it is\n *      critical that strict stack policy is observed (i.e. no cruft\n *      left on the finalizer stack).\n */\n\nDUK_LOCAL duk_ret_t duk__finalize_helper(duk_context *ctx, void *udata) {\n\tduk_hthread *thr;\n\n\tDUK_ASSERT(ctx != NULL);\n\tthr = (duk_hthread *) ctx;\n\tDUK_UNREF(udata);\n\n\tDUK_DDD(DUK_DDDPRINT(\"protected finalization helper running\"));\n\n\t/* [... obj] */\n\n\t/* _Finalizer property is read without checking if the value is\n\t * callable or even exists.  This is intentional, and handled\n\t * by throwing an error which is caught by the safe call wrapper.\n\t *\n\t * XXX: Finalizer lookup should traverse the prototype chain (to allow\n\t * inherited finalizers) but should not invoke accessors or proxy object\n\t * behavior.  At the moment this lookup will invoke proxy behavior, so\n\t * caller must ensure that this function is not called if the target is\n\t * a Proxy.\n\t */\n\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_INT_FINALIZER);  /* -> [... obj finalizer] */\n\tduk_dup_m2(ctx);\n\tduk_push_boolean(ctx, DUK_HEAP_HAS_FINALIZER_NORESCUE(thr->heap));\n\tDUK_DDD(DUK_DDDPRINT(\"calling finalizer\"));\n\tduk_call(ctx, 2);  /* [ ... obj finalizer obj heapDestruct ]  -> [ ... obj retval ] */\n\tDUK_DDD(DUK_DDDPRINT(\"finalizer returned successfully\"));\n\treturn 0;\n\n\t/* Note: we rely on duk_safe_call() to fix up the stack for the caller,\n\t * so we don't need to pop stuff here.  There is no return value;\n\t * caller determines rescued status based on object refcount.\n\t */\n}\n\nDUK_INTERNAL void duk_heap_run_finalizer(duk_heap *heap, duk_hobject *obj) {\n\tduk_context *ctx;\n\tduk_ret_t rc;\n#if defined(DUK_USE_ASSERTIONS)\n\tduk_idx_t entry_top;\n#endif\n\n\tDUK_DD(DUK_DDPRINT(\"running duk_hobject finalizer for object: %p\", (void *) obj));\n\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT(heap->heap_thread != NULL);\n\tctx = (duk_context *) heap->heap_thread;\n\tDUK_ASSERT(obj != NULL);\n\tDUK_ASSERT_VALSTACK_SPACE(heap->heap_thread, 1);\n\n#if defined(DUK_USE_ASSERTIONS)\n\tentry_top = duk_get_top(ctx);\n#endif\n\t/*\n\t *  Get and call the finalizer.  All of this must be wrapped\n\t *  in a protected call, because even getting the finalizer\n\t *  may trigger an error (getter may throw one, for instance).\n\t */\n\n\t/* ROM objects could inherit a finalizer, but they are never deemed\n\t * unreachable by mark-and-sweep, and their refcount never falls to 0.\n\t */\n\tDUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj));\n\n\t/* Duktape 2.1: finalize_list never contains objects with FINALIZED\n\t * set, so no need to check here.\n\t */\n\tDUK_ASSERT(!DUK_HEAPHDR_HAS_FINALIZED((duk_heaphdr *) obj));\n#if 0\n\tif (DUK_HEAPHDR_HAS_FINALIZED((duk_heaphdr *) obj)) {\n\t\tDUK_D(DUK_DPRINT(\"object already finalized, avoid running finalizer twice: %!O\", obj));\n\t\treturn;\n\t}\n#endif\n\tDUK_HEAPHDR_SET_FINALIZED((duk_heaphdr *) obj);  /* ensure never re-entered until rescue cycle complete */\n\n\tif (DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(obj)) {\n\t\t/* This may happen if duk_set_finalizer() or Duktape.fin() is\n\t\t * called for a Proxy object.  In such cases the fast finalizer\n\t\t * flag will be set on the Proxy, not the target, and neither\n\t\t * will be finalized.\n\t\t */\n\t\tDUK_D(DUK_DPRINT(\"object is a proxy, skip finalizer call\"));\n\t\treturn;\n\t}\n\n\tduk_push_hobject(ctx, obj);  /* this also increases refcount by one */\n\trc = duk_safe_call(ctx, duk__finalize_helper, NULL /*udata*/, 0 /*nargs*/, 1 /*nrets*/);  /* -> [... obj retval/error] */\n\tDUK_ASSERT_TOP(ctx, entry_top + 2);  /* duk_safe_call discipline */\n\n\tif (rc != DUK_EXEC_SUCCESS) {\n\t\t/* Note: we ask for one return value from duk_safe_call to get this\n\t\t * error debugging here.\n\t\t */\n\t\tDUK_D(DUK_DPRINT(\"wrapped finalizer call failed for object %p (ignored); error: %!T\",\n\t\t                 (void *) obj, (duk_tval *) duk_get_tval(ctx, -1)));\n\t}\n\tduk_pop_2(ctx);  /* -> [...] */\n\n\tDUK_ASSERT_TOP(ctx, entry_top);\n}\n\n#else  /* DUK_USE_FINALIZER_SUPPORT */\n\n/* nothing */\n\n#endif  /* DUK_USE_FINALIZER_SUPPORT */\n/*\n *  String hash computation (interning).\n *\n *  String hashing is performance critical because a string hash is computed\n *  for all new strings which are candidates to be added to the string table.\n *  However, strings actually added to the string table go through a codepoint\n *  length calculation which dominates performance because it goes through\n *  every byte of the input string (but only for strings added).\n *\n *  The string hash algorithm should be fast, but on the other hand provide\n *  good enough hashes to ensure both string table and object property table\n *  hash tables work reasonably well (i.e., there aren't too many collisions\n *  with real world inputs).  Unless the hash is cryptographic, it's always\n *  possible to craft inputs with maximal hash collisions.\n *\n *  NOTE: The hash algorithms must match tools/dukutil.py:duk_heap_hashstring()\n *  for ROM string support!\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_STRHASH_DENSE)\n/* Constants for duk_hashstring(). */\n#define DUK__STRHASH_SHORTSTRING   4096L\n#define DUK__STRHASH_MEDIUMSTRING  (256L * 1024L)\n#define DUK__STRHASH_BLOCKSIZE     256L\n\nDUK_INTERNAL duk_uint32_t duk_heap_hashstring(duk_heap *heap, const duk_uint8_t *str, duk_size_t len) {\n\tduk_uint32_t hash;\n\n\t/* Use Murmurhash2 directly for short strings, and use \"block skipping\"\n\t * for long strings: hash an initial part and then sample the rest of\n\t * the string with reasonably sized chunks.  An initial offset for the\n\t * sampling is computed based on a hash of the initial part of the string;\n\t * this is done to (usually) avoid the case where all long strings have\n\t * certain offset ranges which are never sampled.\n\t *\n\t * Skip should depend on length and bound the total time to roughly\n\t * logarithmic.  With current values:\n\t *\n\t *   1M string => 256 * 241 = 61696 bytes (0.06M) of hashing\n\t *   1G string => 256 * 16321 = 4178176 bytes (3.98M) of hashing\n\t *\n\t * XXX: It would be better to compute the skip offset more \"smoothly\"\n\t * instead of having a few boundary values.\n\t */\n\n\t/* note: mixing len into seed improves hashing when skipping */\n\tduk_uint32_t str_seed = heap->hash_seed ^ ((duk_uint32_t) len);\n\n\tif (len <= DUK__STRHASH_SHORTSTRING) {\n\t\thash = duk_util_hashbytes(str, len, str_seed);\n\t} else {\n\t\tduk_size_t off;\n\t\tduk_size_t skip;\n\n\t\tif (len <= DUK__STRHASH_MEDIUMSTRING) {\n\t\t\tskip = (duk_size_t) (16 * DUK__STRHASH_BLOCKSIZE + DUK__STRHASH_BLOCKSIZE);\n\t\t} else {\n\t\t\tskip = (duk_size_t) (256 * DUK__STRHASH_BLOCKSIZE + DUK__STRHASH_BLOCKSIZE);\n\t\t}\n\n\t\thash = duk_util_hashbytes(str, (duk_size_t) DUK__STRHASH_SHORTSTRING, str_seed);\n\t\toff = DUK__STRHASH_SHORTSTRING + (skip * (hash % 256)) / 256;\n\n\t\t/* XXX: inefficient loop */\n\t\twhile (off < len) {\n\t\t\tduk_size_t left = len - off;\n\t\t\tduk_size_t now = (duk_size_t) (left > DUK__STRHASH_BLOCKSIZE ? DUK__STRHASH_BLOCKSIZE : left);\n\t\t\thash ^= duk_util_hashbytes(str + off, now, str_seed);\n\t\t\toff += skip;\n\t\t}\n\t}\n\n#if defined(DUK_USE_STRHASH16)\n\t/* Truncate to 16 bits here, so that a computed hash can be compared\n\t * against a hash stored in a 16-bit field.\n\t */\n\thash &= 0x0000ffffUL;\n#endif\n\treturn hash;\n}\n#else  /* DUK_USE_STRHASH_DENSE */\nDUK_INTERNAL duk_uint32_t duk_heap_hashstring(duk_heap *heap, const duk_uint8_t *str, duk_size_t len) {\n\tduk_uint32_t hash;\n\tduk_size_t step;\n\tduk_size_t off;\n\n\t/* Slightly modified \"Bernstein hash\" from:\n\t *\n\t *     http://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx\n\t *\n\t * Modifications: string skipping and reverse direction similar to\n\t * Lua 5.1.5, and different hash initializer.\n\t *\n\t * The reverse direction ensures last byte it always included in the\n\t * hash which is a good default as changing parts of the string are\n\t * more often in the suffix than in the prefix.\n\t */\n\n\thash = heap->hash_seed ^ ((duk_uint32_t) len);  /* Bernstein hash init value is normally 5381 */\n\tstep = (len >> DUK_USE_STRHASH_SKIP_SHIFT) + 1;\n\tfor (off = len; off >= step; off -= step) {\n\t\tDUK_ASSERT(off >= 1);  /* off >= step, and step >= 1 */\n\t\thash = (hash * 33) + str[off - 1];\n\t}\n\n#if defined(DUK_USE_STRHASH16)\n\t/* Truncate to 16 bits here, so that a computed hash can be compared\n\t * against a hash stored in a 16-bit field.\n\t */\n\thash &= 0x0000ffffUL;\n#endif\n\treturn hash;\n}\n#endif  /* DUK_USE_STRHASH_DENSE */\n\n/* automatic undefs */\n#undef DUK__STRHASH_BLOCKSIZE\n#undef DUK__STRHASH_MEDIUMSTRING\n#undef DUK__STRHASH_SHORTSTRING\n/*\n *  Mark-and-sweep garbage collection.\n */\n\n/* #include duk_internal.h -> already included */\n\nDUK_LOCAL_DECL void duk__mark_heaphdr(duk_heap *heap, duk_heaphdr *h);\nDUK_LOCAL_DECL void duk__mark_tval(duk_heap *heap, duk_tval *tv);\n\n/*\n *  Marking functions for heap types: mark children recursively.\n */\n\nDUK_LOCAL void duk__mark_hstring(duk_heap *heap, duk_hstring *h) {\n\tDUK_UNREF(heap);\n\tDUK_UNREF(h);\n\n\tDUK_DDD(DUK_DDDPRINT(\"duk__mark_hstring: %p\", (void *) h));\n\tDUK_ASSERT(h);\n\n\t/* nothing to process */\n}\n\nDUK_LOCAL void duk__mark_hobject(duk_heap *heap, duk_hobject *h) {\n\tduk_uint_fast32_t i;\n\n\tDUK_DDD(DUK_DDDPRINT(\"duk__mark_hobject: %p\", (void *) h));\n\n\tDUK_ASSERT(h);\n\n\t/* XXX: use advancing pointers instead of index macros -> faster and smaller? */\n\n\tfor (i = 0; i < (duk_uint_fast32_t) DUK_HOBJECT_GET_ENEXT(h); i++) {\n\t\tduk_hstring *key = DUK_HOBJECT_E_GET_KEY(heap, h, i);\n\t\tif (key == NULL) {\n\t\t\tcontinue;\n\t\t}\n\t\tduk__mark_heaphdr(heap, (duk_heaphdr *) key);\n\t\tif (DUK_HOBJECT_E_SLOT_IS_ACCESSOR(heap, h, i)) {\n\t\t\tduk__mark_heaphdr(heap, (duk_heaphdr *) DUK_HOBJECT_E_GET_VALUE_PTR(heap, h, i)->a.get);\n\t\t\tduk__mark_heaphdr(heap, (duk_heaphdr *) DUK_HOBJECT_E_GET_VALUE_PTR(heap, h, i)->a.set);\n\t\t} else {\n\t\t\tduk__mark_tval(heap, &DUK_HOBJECT_E_GET_VALUE_PTR(heap, h, i)->v);\n\t\t}\n\t}\n\n\tfor (i = 0; i < (duk_uint_fast32_t) DUK_HOBJECT_GET_ASIZE(h); i++) {\n\t\tduk__mark_tval(heap, DUK_HOBJECT_A_GET_VALUE_PTR(heap, h, i));\n\t}\n\n\t/* Hash part is a 'weak reference' and does not contribute. */\n\n\tduk__mark_heaphdr(heap, (duk_heaphdr *) DUK_HOBJECT_GET_PROTOTYPE(heap, h));\n\n\t/* Fast path for objects which don't have a subclass struct, or have a\n\t * subclass struct but nothing that needs marking in the subclass struct.\n\t */\n\tif (DUK_HOBJECT_HAS_FASTREFS(h)) {\n\t\tDUK_ASSERT(DUK_HOBJECT_ALLOWS_FASTREFS(h));\n\t\treturn;\n\t}\n\tDUK_ASSERT(DUK_HOBJECT_PROHIBITS_FASTREFS(h));\n\n\tif (DUK_HOBJECT_IS_COMPFUNC(h)) {\n\t\tduk_hcompfunc *f = (duk_hcompfunc *) h;\n\t\tduk_tval *tv, *tv_end;\n\t\tduk_hobject **fn, **fn_end;\n\n\t\t/* 'data' is reachable through every compiled function which\n\t\t * contains a reference.\n\t\t */\n\n\t\tduk__mark_heaphdr(heap, (duk_heaphdr *) DUK_HCOMPFUNC_GET_DATA(heap, f));\n\t\tduk__mark_heaphdr(heap, (duk_heaphdr *) DUK_HCOMPFUNC_GET_LEXENV(heap, f));\n\t\tduk__mark_heaphdr(heap, (duk_heaphdr *) DUK_HCOMPFUNC_GET_VARENV(heap, f));\n\n\t\tif (DUK_HCOMPFUNC_GET_DATA(heap, f) != NULL) {\n\t\t\ttv = DUK_HCOMPFUNC_GET_CONSTS_BASE(heap, f);\n\t\t\ttv_end = DUK_HCOMPFUNC_GET_CONSTS_END(heap, f);\n\t\t\twhile (tv < tv_end) {\n\t\t\t\tduk__mark_tval(heap, tv);\n\t\t\t\ttv++;\n\t\t\t}\n\n\t\t\tfn = DUK_HCOMPFUNC_GET_FUNCS_BASE(heap, f);\n\t\t\tfn_end = DUK_HCOMPFUNC_GET_FUNCS_END(heap, f);\n\t\t\twhile (fn < fn_end) {\n\t\t\t\tduk__mark_heaphdr(heap, (duk_heaphdr *) *fn);\n\t\t\t\tfn++;\n\t\t\t}\n\t\t} else {\n\t\t\t/* May happen in some out-of-memory corner cases. */\n\t\t\tDUK_D(DUK_DPRINT(\"duk_hcompfunc 'data' is NULL, skipping marking\"));\n\t\t}\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n\t} else if (DUK_HOBJECT_IS_BUFOBJ(h)) {\n\t\tduk_hbufobj *b = (duk_hbufobj *) h;\n\t\tduk__mark_heaphdr(heap, (duk_heaphdr *) b->buf);\n\t\tduk__mark_heaphdr(heap, (duk_heaphdr *) b->buf_prop);\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\t} else if (DUK_HOBJECT_IS_DECENV(h)) {\n\t\tduk_hdecenv *e = (duk_hdecenv *) h;\n\t\tDUK_ASSERT_HDECENV_VALID(e);\n\t\tduk__mark_heaphdr(heap, (duk_heaphdr *) e->thread);\n\t\tduk__mark_heaphdr(heap, (duk_heaphdr *) e->varmap);\n\t} else if (DUK_HOBJECT_IS_OBJENV(h)) {\n\t\tduk_hobjenv *e = (duk_hobjenv *) h;\n\t\tDUK_ASSERT_HOBJENV_VALID(e);\n\t\tduk__mark_heaphdr(heap, (duk_heaphdr *) e->target);\n\t} else if (DUK_HOBJECT_IS_THREAD(h)) {\n\t\tduk_hthread *t = (duk_hthread *) h;\n\t\tduk_tval *tv;\n\n\t\ttv = t->valstack;\n\t\twhile (tv < t->valstack_top) {\n\t\t\tduk__mark_tval(heap, tv);\n\t\t\ttv++;\n\t\t}\n\n\t\tfor (i = 0; i < (duk_uint_fast32_t) t->callstack_top; i++) {\n\t\t\tduk_activation *act = t->callstack + i;\n\t\t\tduk__mark_heaphdr(heap, (duk_heaphdr *) DUK_ACT_GET_FUNC(act));\n\t\t\tduk__mark_heaphdr(heap, (duk_heaphdr *) act->var_env);\n\t\t\tduk__mark_heaphdr(heap, (duk_heaphdr *) act->lex_env);\n#if defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)\n\t\t\tduk__mark_heaphdr(heap, (duk_heaphdr *) act->prev_caller);\n#endif\n\t\t}\n\n#if 0  /* nothing now */\n\t\tfor (i = 0; i < (duk_uint_fast32_t) t->catchstack_top; i++) {\n\t\t\tduk_catcher *cat = t->catchstack + i;\n\t\t}\n#endif\n\n\t\tduk__mark_heaphdr(heap, (duk_heaphdr *) t->resumer);\n\n\t\tfor (i = 0; i < DUK_NUM_BUILTINS; i++) {\n\t\t\tduk__mark_heaphdr(heap, (duk_heaphdr *) t->builtins[i]);\n\t\t}\n\t} else {\n\t\t/* We may come here if the object should have a FASTREFS flag\n\t\t * but it's missing for some reason.  Assert for never getting\n\t\t * here; however, other than performance, this is harmless.\n\t\t */\n\t\tDUK_D(DUK_DPRINT(\"missing FASTREFS flag for: %!iO\", h));\n\t\tDUK_ASSERT(0);\n\t}\n}\n\n/* Mark any duk_heaphdr type.  Recursion tracking happens only here. */\nDUK_LOCAL void duk__mark_heaphdr(duk_heap *heap, duk_heaphdr *h) {\n\tDUK_DDD(DUK_DDDPRINT(\"duk__mark_heaphdr %p, type %ld\",\n\t                     (void *) h,\n\t                     (h != NULL ? (long) DUK_HEAPHDR_GET_TYPE(h) : (long) -1)));\n\tif (h == NULL) {\n\t\treturn;\n\t}\n#if defined(DUK_USE_ROM_OBJECTS)\n\tif (DUK_HEAPHDR_HAS_READONLY(h)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"readonly object %p, skip\", (void *) h));\n\t\treturn;\n\t}\n#endif\n#if defined(DUK_USE_ASSERTIONS) && defined(DUK_USE_REFERENCE_COUNTING)\n\th->h_assert_refcount++;  /* Comparison refcount: bump even if already reachable. */\n#endif\n\tif (DUK_HEAPHDR_HAS_REACHABLE(h)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"already marked reachable, skip\"));\n\t\treturn;\n\t}\n\tDUK_HEAPHDR_SET_REACHABLE(h);\n\n\tif (heap->ms_recursion_depth >= DUK_USE_MARK_AND_SWEEP_RECLIMIT) {\n\t\tDUK_D(DUK_DPRINT(\"mark-and-sweep recursion limit reached, marking as temproot: %p\", (void *) h));\n\t\tDUK_HEAP_SET_MARKANDSWEEP_RECLIMIT_REACHED(heap);\n\t\tDUK_HEAPHDR_SET_TEMPROOT(h);\n\t\treturn;\n\t}\n\n\theap->ms_recursion_depth++;\n\tDUK_ASSERT(heap->ms_recursion_depth != 0);  /* Wrap. */\n\n\tswitch (DUK_HEAPHDR_GET_TYPE(h)) {\n\tcase DUK_HTYPE_STRING:\n\t\tduk__mark_hstring(heap, (duk_hstring *) h);\n\t\tbreak;\n\tcase DUK_HTYPE_OBJECT:\n\t\tduk__mark_hobject(heap, (duk_hobject *) h);\n\t\tbreak;\n\tcase DUK_HTYPE_BUFFER:\n\t\t/* nothing to mark */\n\t\tbreak;\n\tdefault:\n\t\tDUK_D(DUK_DPRINT(\"attempt to mark heaphdr %p with invalid htype %ld\", (void *) h, (long) DUK_HEAPHDR_GET_TYPE(h)));\n\t\tDUK_UNREACHABLE();\n\t}\n\n\tDUK_ASSERT(heap->ms_recursion_depth > 0);\n\theap->ms_recursion_depth--;\n}\n\nDUK_LOCAL void duk__mark_tval(duk_heap *heap, duk_tval *tv) {\n\tDUK_DDD(DUK_DDDPRINT(\"duk__mark_tval %p\", (void *) tv));\n\tif (tv == NULL) {\n\t\treturn;\n\t}\n\tif (DUK_TVAL_IS_HEAP_ALLOCATED(tv)) {\n\t\tduk__mark_heaphdr(heap, DUK_TVAL_GET_HEAPHDR(tv));\n\t}\n}\n\n/*\n *  Mark the heap.\n */\n\nDUK_LOCAL void duk__mark_roots_heap(duk_heap *heap) {\n\tduk_small_uint_t i;\n\n\tDUK_DD(DUK_DDPRINT(\"duk__mark_roots_heap: %p\", (void *) heap));\n\n\tduk__mark_heaphdr(heap, (duk_heaphdr *) heap->heap_thread);\n\tduk__mark_heaphdr(heap, (duk_heaphdr *) heap->heap_object);\n\n\tfor (i = 0; i < DUK_HEAP_NUM_STRINGS; i++) {\n\t\tduk_hstring *h = DUK_HEAP_GET_STRING(heap, i);\n\t\tduk__mark_heaphdr(heap, (duk_heaphdr *) h);\n\t}\n\n\tduk__mark_tval(heap, &heap->lj.value1);\n\tduk__mark_tval(heap, &heap->lj.value2);\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\tfor (i = 0; i < heap->dbg_breakpoint_count; i++) {\n\t\tduk__mark_heaphdr(heap, (duk_heaphdr *) heap->dbg_breakpoints[i].filename);\n\t}\n#endif\n}\n\n/*\n *  Mark unreachable, finalizable objects.\n *\n *  Such objects will be moved aside and their finalizers run later.  They\n *  have to be treated as reachability roots for their properties etc to\n *  remain allocated.  This marking is only done for unreachable values which\n *  would be swept later.\n *\n *  Objects are first marked FINALIZABLE and only then marked as reachability\n *  roots; otherwise circular references might be handled inconsistently.\n */\n\n#if defined(DUK_USE_FINALIZER_SUPPORT)\nDUK_LOCAL void duk__mark_finalizable(duk_heap *heap) {\n\tduk_heaphdr *hdr;\n\tduk_size_t count_finalizable = 0;\n\n\tDUK_DD(DUK_DDPRINT(\"duk__mark_finalizable: %p\", (void *) heap));\n\n\tDUK_ASSERT(heap->heap_thread != NULL);\n\n\thdr = heap->heap_allocated;\n\twhile (hdr != NULL) {\n\t\t/* A finalizer is looked up from the object and up its\n\t\t * prototype chain (which allows inherited finalizers).\n\t\t * The finalizer is checked for using a duk_hobject flag\n\t\t * which is kept in sync with the presence and callability\n\t\t * of a _Finalizer hidden symbol.\n\t\t */\n\n\t\tif (!DUK_HEAPHDR_HAS_REACHABLE(hdr) &&\n\t\t    DUK_HEAPHDR_IS_OBJECT(hdr) &&\n\t\t    !DUK_HEAPHDR_HAS_FINALIZED(hdr) &&\n\t\t    DUK_HOBJECT_HAS_FINALIZER_FAST(heap, (duk_hobject *) hdr)) {\n\t\t\t/* heaphdr:\n\t\t\t *  - is not reachable\n\t\t\t *  - is an object\n\t\t\t *  - is not a finalized object waiting for rescue/keep decision\n\t\t\t *  - has a finalizer\n\t\t\t */\n\n\t\t\tDUK_DD(DUK_DDPRINT(\"unreachable heap object will be \"\n\t\t\t                   \"finalized -> mark as finalizable \"\n\t\t\t                   \"and treat as a reachability root: %p\",\n\t\t\t                   (void *) hdr));\n\t\t\tDUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY(hdr));\n\t\t\tDUK_HEAPHDR_SET_FINALIZABLE(hdr);\n\t\t\tcount_finalizable++;\n\t\t}\n\n\t\thdr = DUK_HEAPHDR_GET_NEXT(heap, hdr);\n\t}\n\n\tif (count_finalizable == 0) {\n\t\treturn;\n\t}\n\n\tDUK_DD(DUK_DDPRINT(\"marked %ld heap objects as finalizable, now mark them reachable\",\n\t                   (long) count_finalizable));\n\n\thdr = heap->heap_allocated;\n\twhile (hdr != NULL) {\n\t\tif (DUK_HEAPHDR_HAS_FINALIZABLE(hdr)) {\n\t\t\tduk__mark_heaphdr(heap, hdr);\n\t\t}\n\n\t\thdr = DUK_HEAPHDR_GET_NEXT(heap, hdr);\n\t}\n\n\t/* Caller will finish the marking process if we hit a recursion limit. */\n}\n#endif  /* DUK_USE_FINALIZER_SUPPORT */\n\n/*\n *  Mark objects on finalize_list.\n */\n\n#if defined(DUK_USE_FINALIZER_SUPPORT)\nDUK_LOCAL void duk__mark_finalize_list(duk_heap *heap) {\n\tduk_heaphdr *hdr;\n#if defined(DUK_USE_DEBUG)\n\tduk_size_t count_finalize_list = 0;\n#endif\n\n\tDUK_DD(DUK_DDPRINT(\"duk__mark_finalize_list: %p\", (void *) heap));\n\n\thdr = heap->finalize_list;\n\twhile (hdr != NULL) {\n\t\tduk__mark_heaphdr(heap, hdr);\n\t\thdr = DUK_HEAPHDR_GET_NEXT(heap, hdr);\n#if defined(DUK_USE_DEBUG)\n\t\tcount_finalize_list++;\n#endif\n\t}\n\n#if defined(DUK_USE_DEBUG)\n\tif (count_finalize_list > 0) {\n\t\tDUK_D(DUK_DPRINT(\"marked %ld objects on the finalize_list as reachable (previous finalizer run skipped)\",\n\t\t                 (long) count_finalize_list));\n\t}\n#endif\n}\n#endif  /* DUK_USE_FINALIZER_SUPPORT */\n\n/*\n *  Fallback marking handler if recursion limit is reached.\n *\n *  Iterates 'temproots' until recursion limit is no longer hit.  Temproots\n *  can be in heap_allocated or finalize_list; refzero_list is now always\n *  empty for mark-and-sweep.  A temproot may occur in finalize_list now if\n *  there are objects on the finalize_list and user code creates a reference\n *  from an object in heap_allocated to the object in finalize_list (which is\n *  now allowed), and it happened to coincide with the recursion depth limit.\n *\n *  This is a slow scan, but guarantees that we finish with a bounded C stack.\n *\n *  Note that nodes may have been marked as temproots before this scan begun,\n *  OR they may have been marked during the scan (as we process nodes\n *  recursively also during the scan).  This is intended behavior.\n */\n\n#if defined(DUK_USE_DEBUG)\nDUK_LOCAL void duk__handle_temproot(duk_heap *heap, duk_heaphdr *hdr, duk_size_t *count) {\n#else\nDUK_LOCAL void duk__handle_temproot(duk_heap *heap, duk_heaphdr *hdr) {\n#endif\n\tif (!DUK_HEAPHDR_HAS_TEMPROOT(hdr)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"not a temp root: %p\", (void *) hdr));\n\t\treturn;\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"found a temp root: %p\", (void *) hdr));\n\tDUK_HEAPHDR_CLEAR_TEMPROOT(hdr);\n\tDUK_HEAPHDR_CLEAR_REACHABLE(hdr);  /* Done so that duk__mark_heaphdr() works correctly. */\n#if defined(DUK_USE_ASSERTIONS) && defined(DUK_USE_REFERENCE_COUNTING)\n\thdr->h_assert_refcount--;  /* Same node visited twice. */\n#endif\n\tduk__mark_heaphdr(heap, hdr);\n\n#if defined(DUK_USE_DEBUG)\n\t(*count)++;\n#endif\n}\n\nDUK_LOCAL void duk__mark_temproots_by_heap_scan(duk_heap *heap) {\n\tduk_heaphdr *hdr;\n#if defined(DUK_USE_DEBUG)\n\tduk_size_t count;\n#endif\n\n\tDUK_DD(DUK_DDPRINT(\"duk__mark_temproots_by_heap_scan: %p\", (void *) heap));\n\n\twhile (DUK_HEAP_HAS_MARKANDSWEEP_RECLIMIT_REACHED(heap)) {\n\t\tDUK_DD(DUK_DDPRINT(\"recursion limit reached, doing heap scan to continue from temproots\"));\n\n#if defined(DUK_USE_DEBUG)\n\t\tcount = 0;\n#endif\n\t\tDUK_HEAP_CLEAR_MARKANDSWEEP_RECLIMIT_REACHED(heap);\n\n\t\thdr = heap->heap_allocated;\n\t\twhile (hdr) {\n#if defined(DUK_USE_DEBUG)\n\t\t\tduk__handle_temproot(heap, hdr, &count);\n#else\n\t\t\tduk__handle_temproot(heap, hdr);\n#endif\n\t\t\thdr = DUK_HEAPHDR_GET_NEXT(heap, hdr);\n\t\t}\n\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n\t\thdr = heap->finalize_list;\n\t\twhile (hdr) {\n#if defined(DUK_USE_DEBUG)\n\t\t\tduk__handle_temproot(heap, hdr, &count);\n#else\n\t\t\tduk__handle_temproot(heap, hdr);\n#endif\n\t\t\thdr = DUK_HEAPHDR_GET_NEXT(heap, hdr);\n\t\t}\n#endif\n\n#if defined(DUK_USE_DEBUG)\n\t\tDUK_DD(DUK_DDPRINT(\"temproot mark heap scan processed %ld temp roots\", (long) count));\n#endif\n\t}\n}\n\n/*\n *  Finalize refcounts for heap elements just about to be freed.\n *  This must be done for all objects before freeing to avoid any\n *  stale pointer dereferences.\n *\n *  Note that this must deduce the set of objects to be freed\n *  identically to duk__sweep_heap().\n */\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\nDUK_LOCAL void duk__finalize_refcounts(duk_heap *heap) {\n\tduk_heaphdr *hdr;\n\n\tDUK_ASSERT(heap->heap_thread != NULL);\n\n\tDUK_DD(DUK_DDPRINT(\"duk__finalize_refcounts: heap=%p\", (void *) heap));\n\n\thdr = heap->heap_allocated;\n\twhile (hdr) {\n\t\tif (!DUK_HEAPHDR_HAS_REACHABLE(hdr)) {\n\t\t\t/*\n\t\t\t *  Unreachable object about to be swept.  Finalize target refcounts\n\t\t\t *  (objects which the unreachable object points to) without doing\n\t\t\t *  refzero processing.  Recursive decrefs are also prevented when\n\t\t\t *  refzero processing is disabled.\n\t\t\t *\n\t\t\t *  Value cannot be a finalizable object, as they have been made\n\t\t\t *  temporarily reachable for this round.\n\t\t\t */\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"unreachable object, refcount finalize before sweeping: %p\", (void *) hdr));\n\n\t\t\t/* Finalize using heap->heap_thread; DECREF has a\n\t\t\t * suppress check for mark-and-sweep which is based\n\t\t\t * on heap->ms_running.\n\t\t\t */\n\t\t\tduk_heaphdr_refcount_finalize_norz(heap, hdr);\n\t\t}\n\n\t\thdr = DUK_HEAPHDR_GET_NEXT(heap, hdr);\n\t}\n}\n#endif  /* DUK_USE_REFERENCE_COUNTING */\n\n/*\n *  Clear (reachable) flags of finalize_list.\n *\n *  We could mostly do in the sweep phase when we move objects from the\n *  heap into the finalize_list.  However, if a finalizer run is skipped\n *  during a mark-and-sweep, the objects on the finalize_list will be marked\n *  reachable during the next mark-and-sweep.  Since they're already on the\n *  finalize_list, no-one will be clearing their REACHABLE flag so we do it\n *  here.  (This now overlaps with the sweep handling in a harmless way.)\n */\n\n#if defined(DUK_USE_FINALIZER_SUPPORT)\nDUK_LOCAL void duk__clear_finalize_list_flags(duk_heap *heap) {\n\tduk_heaphdr *hdr;\n\n\tDUK_DD(DUK_DDPRINT(\"duk__clear_finalize_list_flags: %p\", (void *) heap));\n\n\thdr = heap->finalize_list;\n\twhile (hdr) {\n\t\tDUK_HEAPHDR_CLEAR_REACHABLE(hdr);\n#if defined(DUK_USE_ASSERTIONS)\n\t\tDUK_ASSERT(DUK_HEAPHDR_HAS_FINALIZABLE(hdr) || \\\n\t\t           (heap->currently_finalizing == hdr));\n#endif\n\t\t/* DUK_HEAPHDR_FLAG_FINALIZED may be set. */\n\t\tDUK_ASSERT(!DUK_HEAPHDR_HAS_TEMPROOT(hdr));\n\t\thdr = DUK_HEAPHDR_GET_NEXT(heap, hdr);\n\t}\n}\n#endif  /* DUK_USE_FINALIZER_SUPPORT */\n\n/*\n *  Sweep stringtable.\n */\n\nDUK_LOCAL void duk__sweep_stringtable(duk_heap *heap, duk_size_t *out_count_keep) {\n\tduk_hstring *h;\n\tduk_hstring *prev;\n\tduk_uint32_t i;\n#if defined(DUK_USE_DEBUG)\n\tduk_size_t count_free = 0;\n#endif\n\tduk_size_t count_keep = 0;\n\n\tDUK_DD(DUK_DDPRINT(\"duk__sweep_stringtable: %p\", (void *) heap));\n\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\tif (heap->strtable16 == NULL) {\n#else\n\tif (heap->strtable == NULL) {\n#endif\n\t\tgoto done;\n\t}\n\n\tfor (i = 0; i < heap->st_size; i++) {\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\t\th = DUK_USE_HEAPPTR_DEC16(heap->heap_udata, heap->strtable16[i]);\n#else\n\t\th = heap->strtable[i];\n#endif\n\t\tprev = NULL;\n\t\twhile (h != NULL) {\n\t\t\tduk_hstring *next;\n\t\t\tnext = h->hdr.h_next;\n\n\t\t\tif (DUK_HEAPHDR_HAS_REACHABLE((duk_heaphdr *) h)) {\n\t\t\t\tDUK_HEAPHDR_CLEAR_REACHABLE((duk_heaphdr *) h);\n\t\t\t\tcount_keep++;\n\t\t\t\tprev = h;\n\t\t\t} else {\n#if defined(DUK_USE_DEBUG)\n\t\t\t\tcount_free++;\n#endif\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\t\t\t\t/* Non-zero refcounts should not happen for unreachable strings,\n\t\t\t\t * because we refcount finalize all unreachable objects which\n\t\t\t\t * should have decreased unreachable string refcounts to zero\n\t\t\t\t * (even for cycles).\n\t\t\t\t */\n\t\t\t\tDUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) h) == 0);\n#endif\n\n\t\t\t\t/* Deal with weak references first. */\n\t\t\t\tduk_heap_strcache_string_remove(heap, (duk_hstring *) h);\n\n\t\t\t\t/* Remove the string from the string table. */\n\t\t\t\tduk_heap_strtable_unlink_prev(heap, (duk_hstring *) h, (duk_hstring *) prev);\n\n\t\t\t\t/* Free inner references (these exist e.g. when external\n\t\t\t\t * strings are enabled) and the struct itself.\n\t\t\t\t */\n\t\t\t\tduk_free_hstring(heap, (duk_hstring *) h);\n\n\t\t\t\t/* Don't update 'prev'; it should be last string kept. */\n\t\t\t}\n\n\t\t\th = next;\n\t\t}\n\t}\n\n done:\n#if defined(DUK_USE_DEBUG)\n\tDUK_D(DUK_DPRINT(\"mark-and-sweep sweep stringtable: %ld freed, %ld kept\",\n\t                 (long) count_free, (long) count_keep));\n#endif\n\t*out_count_keep = count_keep;\n}\n\n/*\n *  Sweep heap.\n */\n\nDUK_LOCAL void duk__sweep_heap(duk_heap *heap, duk_int_t flags, duk_size_t *out_count_keep) {\n\tduk_heaphdr *prev;  /* last element that was left in the heap */\n\tduk_heaphdr *curr;\n\tduk_heaphdr *next;\n#if defined(DUK_USE_DEBUG)\n\tduk_size_t count_free = 0;\n\tduk_size_t count_finalize = 0;\n\tduk_size_t count_rescue = 0;\n#endif\n\tduk_size_t count_keep = 0;\n\n\tDUK_UNREF(flags);\n\tDUK_DD(DUK_DDPRINT(\"duk__sweep_heap: %p\", (void *) heap));\n\n\tprev = NULL;\n\tcurr = heap->heap_allocated;\n\theap->heap_allocated = NULL;\n\twhile (curr) {\n\t\t/* Strings and ROM objects are never placed on the heap allocated list. */\n\t\tDUK_ASSERT(DUK_HEAPHDR_GET_TYPE(curr) != DUK_HTYPE_STRING);\n\t\tDUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY(curr));\n\n\t\tnext = DUK_HEAPHDR_GET_NEXT(heap, curr);\n\n\t\tif (DUK_HEAPHDR_HAS_REACHABLE(curr)) {\n\t\t\t/*\n\t\t\t *  Reachable object:\n\t\t\t *    - If FINALIZABLE -> actually unreachable (but marked\n\t\t\t *      artificially reachable), queue to finalize_list.\n\t\t\t *    - If !FINALIZABLE but FINALIZED -> rescued after\n\t\t\t *      finalizer execution.\n\t\t\t *    - Otherwise just a normal, reachable object.\n\t\t\t *\n\t\t\t *  Objects which are kept are queued to heap_allocated\n\t\t\t *  tail (we're essentially filtering heap_allocated in\n\t\t\t *  practice).\n\t\t\t */\n\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n\t\t\tif (DUK_UNLIKELY(DUK_HEAPHDR_HAS_FINALIZABLE(curr))) {\n\t\t\t\tDUK_ASSERT(!DUK_HEAPHDR_HAS_FINALIZED(curr));\n\t\t\t\tDUK_ASSERT(DUK_HEAPHDR_GET_TYPE(curr) == DUK_HTYPE_OBJECT);\n\t\t\t\tDUK_DD(DUK_DDPRINT(\"sweep; reachable, finalizable --> move to finalize_list: %p\", (void *) curr));\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\t\t\t\tDUK_HEAPHDR_PREINC_REFCOUNT(curr);  /* Bump refcount so that refzero never occurs when pending a finalizer call. */\n#endif\n\t\t\t\tDUK_HEAP_INSERT_INTO_FINALIZE_LIST(heap, curr);\n#if defined(DUK_USE_DEBUG)\n\t\t\t\tcount_finalize++;\n#endif\n\t\t\t}\n\t\t\telse\n#endif  /* DUK_USE_FINALIZER_SUPPORT */\n\t\t\t{\n\t\t\t\tif (DUK_UNLIKELY(DUK_HEAPHDR_HAS_FINALIZED(curr))) {\n\t\t\t\t\tDUK_ASSERT(!DUK_HEAPHDR_HAS_FINALIZABLE(curr));\n\t\t\t\t\tDUK_ASSERT(DUK_HEAPHDR_GET_TYPE(curr) == DUK_HTYPE_OBJECT);\n\n\t\t\t\t\tif (flags & DUK_MS_FLAG_POSTPONE_RESCUE) {\n\t\t\t\t\t\tDUK_DD(DUK_DDPRINT(\"sweep; reachable, finalized, but postponing rescue decisions --> keep object (with FINALIZED set): %!iO\", curr));\n\t\t\t\t\t\tcount_keep++;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tDUK_DD(DUK_DDPRINT(\"sweep; reachable, finalized --> rescued after finalization: %p\", (void *) curr));\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n\t\t\t\t\t\tDUK_HEAPHDR_CLEAR_FINALIZED(curr);\n#endif\n#if defined(DUK_USE_DEBUG)\n\t\t\t\t\t\tcount_rescue++;\n#endif\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tDUK_DD(DUK_DDPRINT(\"sweep; reachable --> keep: %!iO\", curr));\n\t\t\t\t\tcount_keep++;\n\t\t\t\t}\n\n\t\t\t\tif (prev != NULL) {\n\t\t\t\t\tDUK_ASSERT(heap->heap_allocated != NULL);\n\t\t\t\t\tDUK_HEAPHDR_SET_NEXT(heap, prev, curr);\n\t\t\t\t} else {\n\t\t\t\t\tDUK_ASSERT(heap->heap_allocated == NULL);\n\t\t\t\t\theap->heap_allocated = curr;\n\t\t\t\t}\n#if defined(DUK_USE_DOUBLE_LINKED_HEAP)\n\t\t\t\tDUK_HEAPHDR_SET_PREV(heap, curr, prev);\n#endif\n\t\t\t\tDUK_ASSERT_HEAPHDR_LINKS(heap, prev);\n\t\t\t\tDUK_ASSERT_HEAPHDR_LINKS(heap, curr);\n\t\t\t\tprev = curr;\n\t\t\t}\n\n\t\t\tDUK_HEAPHDR_CLEAR_REACHABLE(curr);\n\t\t\t/* Keep FINALIZED if set, used if rescue decisions are postponed. */\n\t\t\t/* Keep FINALIZABLE for objects on finalize_list. */\n\t\t\tDUK_ASSERT(!DUK_HEAPHDR_HAS_REACHABLE(curr));\n\t\t} else {\n\t\t\t/*\n\t\t\t *  Unreachable object:\n\t\t\t *    - If FINALIZED, object was finalized but not\n\t\t\t *      rescued.  This doesn't affect freeing.\n\t\t\t *    - Otherwise normal unreachable object.\n\t\t\t *\n\t\t\t *  There's no guard preventing a FINALIZED object\n\t\t\t *  from being freed while finalizers execute: the\n\t\t\t *  artificial finalize_list reachability roots can't\n\t\t\t *  cause an incorrect free decision (but can cause\n\t\t\t *  an incorrect rescue decision).\n\t\t\t */\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\t\t\t/* Non-zero refcounts should not happen because we refcount\n\t\t\t * finalize all unreachable objects which should cancel out\n\t\t\t * refcounts (even for cycles).\n\t\t\t */\n\t\t\tDUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT(curr) == 0);\n#endif\n\t\t\tDUK_ASSERT(!DUK_HEAPHDR_HAS_FINALIZABLE(curr));\n\n#if defined(DUK_USE_DEBUG)\n\t\t\tif (DUK_HEAPHDR_HAS_FINALIZED(curr)) {\n\t\t\t\tDUK_DD(DUK_DDPRINT(\"sweep; unreachable, finalized --> finalized object not rescued: %p\", (void *) curr));\n\t\t\t} else {\n\t\t\t\tDUK_DD(DUK_DDPRINT(\"sweep; not reachable --> free: %p\", (void *) curr));\n\t\t\t}\n\n#endif\n\n\t\t\t/* Note: object cannot be a finalizable unreachable object, as\n\t\t\t * they have been marked temporarily reachable for this round,\n\t\t\t * and are handled above.\n\t\t\t */\n\n#if defined(DUK_USE_DEBUG)\n\t\t\tcount_free++;\n#endif\n\n\t\t\t/* Weak refs should be handled here, but no weak refs for\n\t\t\t * any non-string objects exist right now.\n\t\t\t */\n\n\t\t\t/* Free object and all auxiliary (non-heap) allocs. */\n\t\t\tduk_heap_free_heaphdr_raw(heap, curr);\n\t\t}\n\n\t\tcurr = next;\n\t}\n\n\tif (prev != NULL) {\n\t\tDUK_HEAPHDR_SET_NEXT(heap, prev, NULL);\n\t}\n\tDUK_ASSERT_HEAPHDR_LINKS(heap, prev);\n\n#if defined(DUK_USE_DEBUG)\n\tDUK_D(DUK_DPRINT(\"mark-and-sweep sweep objects (non-string): %ld freed, %ld kept, %ld rescued, %ld queued for finalization\",\n\t                 (long) count_free, (long) count_keep, (long) count_rescue, (long) count_finalize));\n#endif\n\t*out_count_keep = count_keep;\n}\n\n/*\n *  Object compaction.\n *\n *  Compaction is assumed to never throw an error.\n */\n\nDUK_LOCAL int duk__protected_compact_object(duk_context *ctx, void *udata) {\n\tduk_hobject *obj;\n\t/* XXX: for threads, compact value stack, call stack, catch stack? */\n\n\tDUK_UNREF(udata);\n\tobj = duk_known_hobject(ctx, -1);\n\tduk_hobject_compact_props((duk_hthread *) ctx, obj);\n\treturn 0;\n}\n\n#if defined(DUK_USE_DEBUG)\nDUK_LOCAL void duk__compact_object_list(duk_heap *heap, duk_hthread *thr, duk_heaphdr *start, duk_size_t *p_count_check, duk_size_t *p_count_compact, duk_size_t *p_count_bytes_saved) {\n#else\nDUK_LOCAL void duk__compact_object_list(duk_heap *heap, duk_hthread *thr, duk_heaphdr *start) {\n#endif\n\tduk_heaphdr *curr;\n#if defined(DUK_USE_DEBUG)\n\tduk_size_t old_size, new_size;\n#endif\n\tduk_hobject *obj;\n\n\tDUK_UNREF(heap);\n\n\tcurr = start;\n\twhile (curr) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"mark-and-sweep compact: %p\", (void *) curr));\n\n\t\tif (DUK_HEAPHDR_GET_TYPE(curr) != DUK_HTYPE_OBJECT) {\n\t\t\tgoto next;\n\t\t}\n\t\tobj = (duk_hobject *) curr;\n\n#if defined(DUK_USE_DEBUG)\n\t\told_size = DUK_HOBJECT_P_COMPUTE_SIZE(DUK_HOBJECT_GET_ESIZE(obj),\n\t\t                                      DUK_HOBJECT_GET_ASIZE(obj),\n\t\t                                      DUK_HOBJECT_GET_HSIZE(obj));\n#endif\n\n\t\tDUK_DD(DUK_DDPRINT(\"compact object: %p\", (void *) obj));\n\t\tduk_push_hobject((duk_context *) thr, obj);\n\t\t/* XXX: disable error handlers for duration of compaction? */\n\t\tduk_safe_call((duk_context *) thr, duk__protected_compact_object, NULL, 1, 0);\n\n#if defined(DUK_USE_DEBUG)\n\t\tnew_size = DUK_HOBJECT_P_COMPUTE_SIZE(DUK_HOBJECT_GET_ESIZE(obj),\n\t\t                                      DUK_HOBJECT_GET_ASIZE(obj),\n\t\t                                      DUK_HOBJECT_GET_HSIZE(obj));\n#endif\n\n#if defined(DUK_USE_DEBUG)\n\t\t(*p_count_compact)++;\n\t\t(*p_count_bytes_saved) += (duk_size_t) (old_size - new_size);\n#endif\n\n\t next:\n\t\tcurr = DUK_HEAPHDR_GET_NEXT(heap, curr);\n#if defined(DUK_USE_DEBUG)\n\t\t(*p_count_check)++;\n#endif\n\t}\n}\n\nDUK_LOCAL void duk__compact_objects(duk_heap *heap) {\n\t/* XXX: which lists should participate?  to be finalized? */\n#if defined(DUK_USE_DEBUG)\n\tduk_size_t count_check = 0;\n\tduk_size_t count_compact = 0;\n\tduk_size_t count_bytes_saved = 0;\n#endif\n\n\tDUK_DD(DUK_DDPRINT(\"duk__compact_objects: %p\", (void *) heap));\n\n\tDUK_ASSERT(heap->heap_thread != NULL);\n\n#if defined(DUK_USE_DEBUG)\n\tduk__compact_object_list(heap, heap->heap_thread, heap->heap_allocated, &count_check, &count_compact, &count_bytes_saved);\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n\tduk__compact_object_list(heap, heap->heap_thread, heap->finalize_list, &count_check, &count_compact, &count_bytes_saved);\n#endif\n#else\n\tduk__compact_object_list(heap, heap->heap_thread, heap->heap_allocated);\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n\tduk__compact_object_list(heap, heap->heap_thread, heap->finalize_list);\n#endif\n#endif\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tDUK_ASSERT(heap->refzero_list == NULL);  /* Always handled to completion inline in DECREF. */\n#endif\n\n#if defined(DUK_USE_DEBUG)\n\tDUK_D(DUK_DPRINT(\"mark-and-sweep compact objects: %ld checked, %ld compaction attempts, %ld bytes saved by compaction\",\n\t                 (long) count_check, (long) count_compact, (long) count_bytes_saved));\n#endif\n}\n\n/*\n *  Assertion helpers.\n */\n\n#if defined(DUK_USE_ASSERTIONS)\nDUK_LOCAL void duk__assert_heaphdr_flags(duk_heap *heap) {\n\tduk_heaphdr *hdr;\n\n\thdr = heap->heap_allocated;\n\twhile (hdr) {\n\t\tDUK_ASSERT(!DUK_HEAPHDR_HAS_REACHABLE(hdr));\n\t\tDUK_ASSERT(!DUK_HEAPHDR_HAS_TEMPROOT(hdr));\n\t\tDUK_ASSERT(!DUK_HEAPHDR_HAS_FINALIZABLE(hdr));\n\t\t/* may have FINALIZED */\n\t\thdr = DUK_HEAPHDR_GET_NEXT(heap, hdr);\n\t}\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tDUK_ASSERT(heap->refzero_list == NULL);  /* Always handled to completion inline in DECREF. */\n#endif\n}\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\nDUK_LOCAL void duk__assert_valid_refcounts(duk_heap *heap) {\n\tduk_heaphdr *hdr = heap->heap_allocated;\n\twhile (hdr) {\n\t\t/* Cannot really assert much w.r.t. refcounts now. */\n\n\t\tif (DUK_HEAPHDR_GET_REFCOUNT(hdr) == 0 &&\n\t\t    DUK_HEAPHDR_HAS_FINALIZED(hdr)) {\n\t\t\t/* An object may be in heap_allocated list with a zero\n\t\t\t * refcount if it has just been finalized and is waiting\n\t\t\t * to be collected by the next cycle.\n\t\t\t * (This doesn't currently happen however.)\n\t\t\t */\n\t\t} else if (DUK_HEAPHDR_GET_REFCOUNT(hdr) == 0) {\n\t\t\t/* An object may be in heap_allocated list with a zero\n\t\t\t * refcount also if it is a temporary object created\n\t\t\t * during debugger paused state.  It will get collected\n\t\t\t * by mark-and-sweep based on its reachability status\n\t\t\t * (presumably not reachable because refcount is 0).\n\t\t\t */\n\t\t}\n\t\tDUK_ASSERT_DISABLE(DUK_HEAPHDR_GET_REFCOUNT(hdr) >= 0);  /* Unsigned. */\n\t\thdr = DUK_HEAPHDR_GET_NEXT(heap, hdr);\n\t}\n}\n\nDUK_LOCAL void duk__clear_assert_refcounts(duk_heap *heap) {\n\tduk_heaphdr *curr;\n\tduk_uint32_t i;\n\n\tfor (curr = heap->heap_allocated; curr != NULL; curr = DUK_HEAPHDR_GET_NEXT(heap, curr)) {\n\t\tcurr->h_assert_refcount = 0;\n\t}\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n\tfor (curr = heap->finalize_list; curr != NULL; curr = DUK_HEAPHDR_GET_NEXT(heap, curr)) {\n\t\tcurr->h_assert_refcount = 0;\n\t}\n#endif\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tfor (curr = heap->refzero_list; curr != NULL; curr = DUK_HEAPHDR_GET_NEXT(heap, curr)) {\n\t\tcurr->h_assert_refcount = 0;\n\t}\n#endif\n\n\tfor (i = 0; i < heap->st_size; i++) {\n\t\tduk_hstring *h;\n\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\t\th = DUK_USE_HEAPPTR_DEC16(heap->heap_udata, heap->strtable16[i]);\n#else\n\t\th = heap->strtable[i];\n#endif\n\t\twhile (h != NULL) {\n\t\t\t((duk_heaphdr *) h)->h_assert_refcount = 0;\n\t\t\th = h->hdr.h_next;\n\t\t}\n\t}\n}\n\nDUK_LOCAL void duk__check_refcount_heaphdr(duk_heaphdr *hdr) {\n\tduk_bool_t count_ok;\n\n\t/* The refcount check only makes sense for reachable objects on\n\t * heap_allocated or string table, after the sweep phase.  Prior to\n\t * sweep phase refcounts will include references that are not visible\n\t * via reachability roots.\n\t *\n\t * Because we're called after the sweep phase, all heap objects on\n\t * heap_allocated are reachable.  REACHABLE flags have already been\n\t * cleared so we can't check them.\n\t */\n\n\t/* ROM objects have intentionally incorrect refcount (1), but we won't\n\t * check them.\n\t */\n\tDUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY(hdr));\n\n\tcount_ok = ((duk_size_t) DUK_HEAPHDR_GET_REFCOUNT(hdr) == hdr->h_assert_refcount);\n\tif (!count_ok) {\n\t\tDUK_D(DUK_DPRINT(\"refcount mismatch for: %p: header=%ld counted=%ld --> %!iO\",\n\t\t                 (void *) hdr, (long) DUK_HEAPHDR_GET_REFCOUNT(hdr),\n\t\t                 (long) hdr->h_assert_refcount, hdr));\n\t\tDUK_ASSERT(0);\n\t}\n}\n\nDUK_LOCAL void duk__check_assert_refcounts(duk_heap *heap) {\n\tduk_heaphdr *curr;\n\tduk_uint32_t i;\n\n\tfor (curr = heap->heap_allocated; curr != NULL; curr = DUK_HEAPHDR_GET_NEXT(heap, curr)) {\n\t\tduk__check_refcount_heaphdr(curr);\n\t}\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n\tfor (curr = heap->finalize_list; curr != NULL; curr = DUK_HEAPHDR_GET_NEXT(heap, curr)) {\n\t\tduk__check_refcount_heaphdr(curr);\n\t}\n#endif\n\n\tfor (i = 0; i < heap->st_size; i++) {\n\t\tduk_hstring *h;\n\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\t\th = DUK_USE_HEAPPTR_DEC16(heap->heap_udata, heap->strtable16[i]);\n#else\n\t\th = heap->strtable[i];\n#endif\n\t\twhile (h != NULL) {\n\t\t\tduk__check_refcount_heaphdr((duk_heaphdr *) h);\n\t\t\th = h->hdr.h_next;\n\t\t}\n\t}\n}\n#endif  /* DUK_USE_REFERENCE_COUNTING */\n#endif  /* DUK_USE_ASSERTIONS */\n\n/*\n *  Main mark-and-sweep function.\n *\n *  'flags' represents the features requested by the caller.  The current\n *  heap->ms_base_flags is ORed automatically into the flags; the base flags\n *  mask typically prevents certain mark-and-sweep operation to avoid trouble.\n */\n\nDUK_INTERNAL void duk_heap_mark_and_sweep(duk_heap *heap, duk_small_uint_t flags) {\n\tduk_size_t count_keep_obj;\n\tduk_size_t count_keep_str;\n#if defined(DUK_USE_VOLUNTARY_GC)\n\tduk_size_t tmp;\n#endif\n\n\t/* If debugger is paused, garbage collection is disabled by default.\n\t * This is achieved by bumping ms_prevent_count when becoming paused.\n\t */\n\tDUK_ASSERT(!DUK_HEAP_HAS_DEBUGGER_PAUSED(heap) || heap->ms_prevent_count > 0);\n\n\t/* Prevention/recursion check as soon as possible because we may\n\t * be called a number of times when voluntary mark-and-sweep is\n\t * pending.\n\t */\n\tif (heap->ms_prevent_count != 0) {\n\t\tDUK_DD(DUK_DDPRINT(\"reject recursive mark-and-sweep\"));\n\t\treturn;\n\t}\n\tDUK_ASSERT(heap->ms_running == 0);  /* ms_prevent_count is bumped when ms_running is set */\n\n\t/* Heap_thread is used during mark-and-sweep for refcount finalization\n\t * (it's also used for finalizer execution once mark-and-sweep is\n\t * complete).  Heap allocation code ensures heap_thread is set and\n\t * properly initialized before setting ms_prevent_count to 0.\n\t */\n\tDUK_ASSERT(heap->heap_thread != NULL);\n\tDUK_ASSERT(heap->heap_thread->valstack != NULL);\n\tDUK_ASSERT(heap->heap_thread->callstack != NULL);\n\tDUK_ASSERT(heap->heap_thread->catchstack != NULL);\n\n\tDUK_D(DUK_DPRINT(\"garbage collect (mark-and-sweep) starting, requested flags: 0x%08lx, effective flags: 0x%08lx\",\n\t                 (unsigned long) flags, (unsigned long) (flags | heap->ms_base_flags)));\n\n\tflags |= heap->ms_base_flags;\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n\tif (heap->finalize_list != NULL) {\n\t\tflags |= DUK_MS_FLAG_POSTPONE_RESCUE;\n\t}\n#endif\n\n\t/*\n\t *  Assertions before\n\t */\n\n#if defined(DUK_USE_ASSERTIONS)\n\tDUK_ASSERT(heap->ms_prevent_count == 0);\n\tDUK_ASSERT(heap->ms_running == 0);\n\tDUK_ASSERT(!DUK_HEAP_HAS_DEBUGGER_PAUSED(heap));\n\tDUK_ASSERT(!DUK_HEAP_HAS_MARKANDSWEEP_RECLIMIT_REACHED(heap));\n\tDUK_ASSERT(heap->ms_recursion_depth == 0);\n\tduk__assert_heaphdr_flags(heap);\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\t/* Note: heap->refzero_free_running may be true; a refcount\n\t * finalizer may trigger a mark-and-sweep.\n\t */\n\tduk__assert_valid_refcounts(heap);\n#endif  /* DUK_USE_REFERENCE_COUNTING */\n#endif  /* DUK_USE_ASSERTIONS */\n\n\t/*\n\t *  Begin\n\t */\n\n\tDUK_ASSERT(heap->ms_prevent_count == 0);\n\tDUK_ASSERT(heap->ms_running == 0);\n\theap->ms_prevent_count = 1;\n\theap->ms_running = 1;\n\n\t/*\n\t *  Mark roots, hoping that recursion limit is not normally hit.\n\t *  If recursion limit is hit, run additional reachability rounds\n\t *  starting from \"temproots\" until marking is complete.\n\t *\n\t *  Marking happens in two phases: first we mark actual reachability\n\t *  roots (and run \"temproots\" to complete the process).  Then we\n\t *  check which objects are unreachable and are finalizable; such\n\t *  objects are marked as FINALIZABLE and marked as reachability\n\t *  (and \"temproots\" is run again to complete the process).\n\t *\n\t *  The heap finalize_list must also be marked as a reachability root.\n\t *  There may be objects on the list from a previous round if the\n\t *  previous run had finalizer skip flag.\n\t */\n\n#if defined(DUK_USE_ASSERTIONS) && defined(DUK_USE_REFERENCE_COUNTING)\n\tduk__clear_assert_refcounts(heap);\n#endif\n\tduk__mark_roots_heap(heap);               /* Mark main reachability roots. */\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tDUK_ASSERT(heap->refzero_list == NULL);   /* Always handled to completion inline in DECREF. */\n#endif\n\tduk__mark_temproots_by_heap_scan(heap);   /* Temproots. */\n\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n\tduk__mark_finalizable(heap);              /* Mark finalizable as reachability roots. */\n\tduk__mark_finalize_list(heap);            /* Mark finalizer work list as reachability roots. */\n#endif\n\tduk__mark_temproots_by_heap_scan(heap);   /* Temproots. */\n\n\t/*\n\t *  Sweep garbage and remove marking flags, and move objects with\n\t *  finalizers to the finalizer work list.\n\t *\n\t *  Objects to be swept need to get their refcounts finalized before\n\t *  they are swept.  In other words, their target object refcounts\n\t *  need to be decreased.  This has to be done before freeing any\n\t *  objects to avoid decref'ing dangling pointers (which may happen\n\t *  even without bugs, e.g. with reference loops)\n\t *\n\t *  Because strings don't point to other heap objects, similar\n\t *  finalization is not necessary for strings.\n\t */\n\n\t/* XXX: more emergency behavior, e.g. find smaller hash sizes etc */\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tduk__finalize_refcounts(heap);\n#endif\n\tduk__sweep_heap(heap, flags, &count_keep_obj);\n\tduk__sweep_stringtable(heap, &count_keep_str);\n#if defined(DUK_USE_ASSERTIONS) && defined(DUK_USE_REFERENCE_COUNTING)\n\tduk__check_assert_refcounts(heap);\n#endif\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tDUK_ASSERT(heap->refzero_list == NULL);   /* Always handled to completion inline in DECREF. */\n#endif\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n\tduk__clear_finalize_list_flags(heap);\n#endif\n\n\t/*\n\t *  Object compaction (emergency only).\n\t *\n\t *  Object compaction is a separate step after sweeping, as there is\n\t *  more free memory for it to work with.  Also, currently compaction\n\t *  may insert new objects into the heap allocated list and the string\n\t *  table which we don't want to do during a sweep (the reachability\n\t *  flags of such objects would be incorrect).  The objects inserted\n\t *  are currently:\n\t *\n\t *    - a temporary duk_hbuffer for a new properties allocation\n\t *    - if array part is abandoned, string keys are interned\n\t *\n\t *  The object insertions go to the front of the list, so they do not\n\t *  cause an infinite loop (they are not compacted).\n\t */\n\n\tif ((flags & DUK_MS_FLAG_EMERGENCY) &&\n\t    !(flags & DUK_MS_FLAG_NO_OBJECT_COMPACTION)) {\n\t\tduk__compact_objects(heap);\n\t}\n\n\t/*\n\t *  String table resize check.\n\t *\n\t *  This is mainly useful in emergency GC: if the string table load\n\t *  factor is really low for some reason, we can shrink the string\n\t *  table to a smaller size and free some memory in the process.\n\t *  Only execute in emergency GC.  String table has internal flags\n\t *  to protect against recursive resizing if this mark-and-sweep pass\n\t *  was triggered by a string table resize.\n\t */\n\n\tif (flags & DUK_MS_FLAG_EMERGENCY) {\n\t\tDUK_D(DUK_DPRINT(\"stringtable resize check in emergency gc\"));\n\t\tduk_heap_strtable_force_resize(heap);\n\t}\n\n\t/*\n\t *  Finish\n\t */\n\n\tDUK_ASSERT(heap->ms_prevent_count == 1);\n\theap->ms_prevent_count = 0;\n\tDUK_ASSERT(heap->ms_running == 1);\n\theap->ms_running = 0;\n\n\t/*\n\t *  Assertions after\n\t */\n\n#if defined(DUK_USE_ASSERTIONS)\n\tDUK_ASSERT(heap->ms_prevent_count == 0);\n\tDUK_ASSERT(!DUK_HEAP_HAS_MARKANDSWEEP_RECLIMIT_REACHED(heap));\n\tDUK_ASSERT(heap->ms_recursion_depth == 0);\n\tduk__assert_heaphdr_flags(heap);\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\t/* Note: heap->refzero_free_running may be true; a refcount\n\t * finalizer may trigger a mark-and-sweep.\n\t */\n\tduk__assert_valid_refcounts(heap);\n#endif  /* DUK_USE_REFERENCE_COUNTING */\n#endif  /* DUK_USE_ASSERTIONS */\n\n\t/*\n\t *  Reset trigger counter\n\t */\n\n#if defined(DUK_USE_VOLUNTARY_GC)\n\ttmp = (count_keep_obj + count_keep_str) / 256;\n\theap->ms_trigger_counter = (duk_int_t) (\n\t    (tmp * DUK_HEAP_MARK_AND_SWEEP_TRIGGER_MULT) +\n\t    DUK_HEAP_MARK_AND_SWEEP_TRIGGER_ADD);\n\tDUK_D(DUK_DPRINT(\"garbage collect (mark-and-sweep) finished: %ld objects kept, %ld strings kept, trigger reset to %ld\",\n\t                 (long) count_keep_obj, (long) count_keep_str, (long) heap->ms_trigger_counter));\n#else\n\tDUK_D(DUK_DPRINT(\"garbage collect (mark-and-sweep) finished: %ld objects kept, %ld strings kept, no voluntary trigger\",\n\t                 (long) count_keep_obj, (long) count_keep_str));\n#endif\n\n\t/*\n\t *  Finalize objects in the finalization work list.  Finalized\n\t *  objects are queued back to heap_allocated with FINALIZED set.\n\t *\n\t *  Since finalizers may cause arbitrary side effects, they are\n\t *  prevented e.g. during string table and object property allocation\n\t *  resizing using heap->pf_prevent_count.  In this case the objects\n\t *  remain in the finalization work list after mark-and-sweep exits\n\t *  and they may be finalized on the next pass or any DECREF checking\n\t *  for finalize_list.\n\t *\n\t *  As of Duktape 2.1 finalization happens outside mark-and-sweep\n\t *  protection.  Mark-and-sweep is allowed while the finalize_list\n\t *  is being processed, but no rescue decisions are done while the\n\t *  process is on-going.  This avoids incorrect rescue decisions\n\t *  if an object is considered reachable (and thus rescued) because\n\t *  of a reference via finalize_list (which is considered a reachability\n\t *  root).  When finalize_list is being processed, reachable objects\n\t *  with FINALIZED set will just keep their FINALIZED flag for later\n\t *  mark-and-sweep processing.\n\t *\n\t *  This could also be handled (a bit better) by having a more refined\n\t *  notion of reachability for rescue/free decisions.\n\t *\n\t *  XXX: avoid finalizer execution when doing emergency GC?\n\t */\n\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n\t/* Attempt to process finalize_list, pf_prevent_count check\n\t * is inside the target.\n\t */\n\tduk_heap_process_finalize_list(heap);\n#endif  /* DUK_USE_FINALIZER_SUPPORT */\n}\n/*\n *  Memory allocation handling.\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Voluntary GC check\n */\n\n#if defined(DUK_USE_VOLUNTARY_GC)\nDUK_LOCAL DUK_INLINE void duk__check_voluntary_gc(duk_heap *heap) {\n\tif (DUK_UNLIKELY(--(heap)->ms_trigger_counter < 0)) {\n#if defined(DUK_USE_DEBUG)\n\t\tif (heap->ms_prevent_count == 0) {\n\t\t\tDUK_D(DUK_DPRINT(\"triggering voluntary mark-and-sweep\"));\n\t\t} else {\n\t\t\tDUK_DD(DUK_DDPRINT(\"gc blocked -> skip voluntary mark-and-sweep now\"));\n\t\t}\n#endif\n\n\t\t/* Prevention checks in the call target handle cases where\n\t\t * voluntary GC is not allowed.  The voluntary GC trigger\n\t\t * counter is only rewritten if mark-and-sweep actually runs.\n\t\t */\n\t\tduk_heap_mark_and_sweep(heap, DUK_MS_FLAG_VOLUNTARY /*flags*/);\n\t}\n}\n#define DUK__VOLUNTARY_PERIODIC_GC(heap)  do { duk__check_voluntary_gc((heap)); } while (0)\n#else\n#define DUK__VOLUNTARY_PERIODIC_GC(heap)  /* no voluntary gc */\n#endif  /* DUK_USE_VOLUNTARY_GC */\n\n/*\n *  Allocate memory with garbage collection\n */\n\nDUK_INTERNAL void *duk_heap_mem_alloc(duk_heap *heap, duk_size_t size) {\n\tvoid *res;\n\tduk_small_int_t i;\n\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT_DISABLE(size >= 0);\n\n\t/*\n\t *  Voluntary periodic GC (if enabled)\n\t */\n\n\tDUK__VOLUNTARY_PERIODIC_GC(heap);\n\n\t/*\n\t *  First attempt\n\t */\n\n#if defined(DUK_USE_GC_TORTURE)\n\t/* simulate alloc failure on every alloc (except when mark-and-sweep is running) */\n\tif (heap->ms_prevent_count == 0) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"gc torture enabled, pretend that first alloc attempt fails\"));\n\t\tres = NULL;\n\t\tDUK_UNREF(res);\n\t\tgoto skip_attempt;\n\t}\n#endif\n\tres = heap->alloc_func(heap->heap_udata, size);\n\tif (DUK_LIKELY(res || size == 0)) {\n\t\t/* for zero size allocations NULL is allowed */\n\t\treturn res;\n\t}\n#if defined(DUK_USE_GC_TORTURE)\n skip_attempt:\n#endif\n\n\tDUK_D(DUK_DPRINT(\"first alloc attempt failed, attempt to gc and retry\"));\n\n#if 0\n\t/*\n\t *  Avoid a GC if GC is already running.  This can happen at a late\n\t *  stage in a GC when we try to e.g. resize the stringtable\n\t *  or compact objects.\n\t *\n\t *  NOTE: explicit handling isn't actually be needed: if the GC is\n\t *  not allowed, duk_heap_mark_and_sweep() will reject it for every\n\t *  attempt in the loop below, resulting in a NULL same as here.\n\t */\n\n\tif (heap->ms_prevent_count != 0) {\n\t\tDUK_D(DUK_DPRINT(\"duk_heap_mem_alloc() failed, gc in progress (gc skipped), alloc size %ld\", (long) size));\n\t\treturn NULL;\n\t}\n#endif\n\n\t/*\n\t *  Retry with several GC attempts.  Initial attempts are made without\n\t *  emergency mode; later attempts use emergency mode which minimizes\n\t *  memory allocations forcibly.\n\t */\n\n\tfor (i = 0; i < DUK_HEAP_ALLOC_FAIL_MARKANDSWEEP_LIMIT; i++) {\n\t\tduk_small_uint_t flags;\n\n\t\tflags = 0;\n\t\tif (i >= DUK_HEAP_ALLOC_FAIL_MARKANDSWEEP_EMERGENCY_LIMIT - 1) {\n\t\t\tflags |= DUK_MS_FLAG_EMERGENCY;\n\t\t}\n\n\t\tduk_heap_mark_and_sweep(heap, flags);\n\n\t\tres = heap->alloc_func(heap->heap_udata, size);\n\t\tif (res) {\n\t\t\tDUK_D(DUK_DPRINT(\"duk_heap_mem_alloc() succeeded after gc (pass %ld), alloc size %ld\",\n\t\t\t                 (long) (i + 1), (long) size));\n\t\t\treturn res;\n\t\t}\n\t}\n\n\tDUK_D(DUK_DPRINT(\"duk_heap_mem_alloc() failed even after gc, alloc size %ld\", (long) size));\n\treturn NULL;\n}\n\nDUK_INTERNAL void *duk_heap_mem_alloc_zeroed(duk_heap *heap, duk_size_t size) {\n\tvoid *res;\n\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT_DISABLE(size >= 0);\n\n\tres = DUK_ALLOC(heap, size);\n\tif (DUK_LIKELY(res != NULL)) {\n\t\t/* assume memset with zero size is OK */\n\t\tDUK_MEMZERO(res, size);\n\t}\n\treturn res;\n}\n\nDUK_INTERNAL void *duk_heap_mem_alloc_checked(duk_hthread *thr, duk_size_t size) {\n\tvoid *res;\n\n\tDUK_ASSERT(thr != NULL);\n\tres = duk_heap_mem_alloc(thr->heap, size);\n\tif (DUK_LIKELY(res != NULL || size == 0)) {\n\t\treturn res;\n\t}\n\tDUK_ERROR_ALLOC_FAILED(thr);\n\treturn NULL;\n}\n\nDUK_INTERNAL void *duk_heap_mem_alloc_checked_zeroed(duk_hthread *thr, duk_size_t size) {\n\tvoid *res;\n\n\tDUK_ASSERT(thr != NULL);\n\tres = duk_heap_mem_alloc_zeroed(thr->heap, size);\n\tif (DUK_LIKELY(res != NULL || size == 0)) {\n\t\treturn res;\n\t}\n\tDUK_ERROR_ALLOC_FAILED(thr);\n\treturn NULL;\n}\n\n/*\n *  Reallocate memory with garbage collection\n */\n\nDUK_INTERNAL void *duk_heap_mem_realloc(duk_heap *heap, void *ptr, duk_size_t newsize) {\n\tvoid *res;\n\tduk_small_int_t i;\n\n\tDUK_ASSERT(heap != NULL);\n\t/* ptr may be NULL */\n\tDUK_ASSERT_DISABLE(newsize >= 0);\n\n\t/*\n\t *  Voluntary periodic GC (if enabled)\n\t */\n\n\tDUK__VOLUNTARY_PERIODIC_GC(heap);\n\n\t/*\n\t *  First attempt\n\t */\n\n#if defined(DUK_USE_GC_TORTURE)\n\t/* simulate alloc failure on every realloc (except when mark-and-sweep is running) */\n\tif (heap->ms_prevent_count == 0) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"gc torture enabled, pretend that first realloc attempt fails\"));\n\t\tres = NULL;\n\t\tDUK_UNREF(res);\n\t\tgoto skip_attempt;\n\t}\n#endif\n\tres = heap->realloc_func(heap->heap_udata, ptr, newsize);\n\tif (DUK_LIKELY(res || newsize == 0)) {\n\t\t/* for zero size allocations NULL is allowed */\n\t\treturn res;\n\t}\n#if defined(DUK_USE_GC_TORTURE)\n skip_attempt:\n#endif\n\n\tDUK_D(DUK_DPRINT(\"first realloc attempt failed, attempt to gc and retry\"));\n\n#if 0\n\t/*\n\t *  Avoid a GC if GC is already running.  See duk_heap_mem_alloc().\n\t */\n\n\tif (heap->ms_prevent_count != 0) {\n\t\tDUK_D(DUK_DPRINT(\"duk_heap_mem_realloc() failed, gc in progress (gc skipped), alloc size %ld\", (long) newsize));\n\t\treturn NULL;\n\t}\n#endif\n\n\t/*\n\t *  Retry with several GC attempts.  Initial attempts are made without\n\t *  emergency mode; later attempts use emergency mode which minimizes\n\t *  memory allocations forcibly.\n\t */\n\n\tfor (i = 0; i < DUK_HEAP_ALLOC_FAIL_MARKANDSWEEP_LIMIT; i++) {\n\t\tduk_small_uint_t flags;\n\n\t\tflags = 0;\n\t\tif (i >= DUK_HEAP_ALLOC_FAIL_MARKANDSWEEP_EMERGENCY_LIMIT - 1) {\n\t\t\tflags |= DUK_MS_FLAG_EMERGENCY;\n\t\t}\n\n\t\tduk_heap_mark_and_sweep(heap, flags);\n\n\t\tres = heap->realloc_func(heap->heap_udata, ptr, newsize);\n\t\tif (res || newsize == 0) {\n\t\t\tDUK_D(DUK_DPRINT(\"duk_heap_mem_realloc() succeeded after gc (pass %ld), alloc size %ld\",\n\t\t\t                 (long) (i + 1), (long) newsize));\n\t\t\treturn res;\n\t\t}\n\t}\n\n\tDUK_D(DUK_DPRINT(\"duk_heap_mem_realloc() failed even after gc, alloc size %ld\", (long) newsize));\n\treturn NULL;\n}\n\n/*\n *  Reallocate memory with garbage collection, using a callback to provide\n *  the current allocated pointer.  This variant is used when a mark-and-sweep\n *  (e.g. finalizers) might change the original pointer.\n */\n\nDUK_INTERNAL void *duk_heap_mem_realloc_indirect(duk_heap *heap, duk_mem_getptr cb, void *ud, duk_size_t newsize) {\n\tvoid *res;\n\tduk_small_int_t i;\n\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT_DISABLE(newsize >= 0);\n\n\t/*\n\t *  Voluntary periodic GC (if enabled)\n\t */\n\n\tDUK__VOLUNTARY_PERIODIC_GC(heap);\n\n\t/*\n\t *  First attempt\n\t */\n\n#if defined(DUK_USE_GC_TORTURE)\n\t/* simulate alloc failure on every realloc (except when mark-and-sweep is running) */\n\tif (heap->ms_prevent_count == 0) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"gc torture enabled, pretend that first indirect realloc attempt fails\"));\n\t\tres = NULL;\n\t\tDUK_UNREF(res);\n\t\tgoto skip_attempt;\n\t}\n#endif\n\tres = heap->realloc_func(heap->heap_udata, cb(heap, ud), newsize);\n\tif (DUK_LIKELY(res || newsize == 0)) {\n\t\t/* for zero size allocations NULL is allowed */\n\t\treturn res;\n\t}\n#if defined(DUK_USE_GC_TORTURE)\n skip_attempt:\n#endif\n\n\tDUK_D(DUK_DPRINT(\"first indirect realloc attempt failed, attempt to gc and retry\"));\n\n#if 0\n\t/*\n\t *  Avoid a GC if GC is already running.  See duk_heap_mem_alloc().\n\t */\n\n\tif (heap->ms_prevent_count != 0) {\n\t\tDUK_D(DUK_DPRINT(\"duk_heap_mem_realloc_indirect() failed, gc in progress (gc skipped), alloc size %ld\", (long) newsize));\n\t\treturn NULL;\n\t}\n#endif\n\n\t/*\n\t *  Retry with several GC attempts.  Initial attempts are made without\n\t *  emergency mode; later attempts use emergency mode which minimizes\n\t *  memory allocations forcibly.\n\t */\n\n\tfor (i = 0; i < DUK_HEAP_ALLOC_FAIL_MARKANDSWEEP_LIMIT; i++) {\n\t\tduk_small_uint_t flags;\n\n#if defined(DUK_USE_ASSERTIONS)\n\t\tvoid *ptr_pre;  /* ptr before mark-and-sweep */\n\t\tvoid *ptr_post;\n#endif\n\n#if defined(DUK_USE_ASSERTIONS)\n\t\tptr_pre = cb(heap, ud);\n#endif\n\t\tflags = 0;\n\t\tif (i >= DUK_HEAP_ALLOC_FAIL_MARKANDSWEEP_EMERGENCY_LIMIT - 1) {\n\t\t\tflags |= DUK_MS_FLAG_EMERGENCY;\n\t\t}\n\n\t\tduk_heap_mark_and_sweep(heap, flags);\n#if defined(DUK_USE_ASSERTIONS)\n\t\tptr_post = cb(heap, ud);\n\t\tif (ptr_pre != ptr_post) {\n\t\t\t/* useful for debugging */\n\t\t\tDUK_DD(DUK_DDPRINT(\"note: base pointer changed by mark-and-sweep: %p -> %p\",\n\t\t\t                   (void *) ptr_pre, (void *) ptr_post));\n\t\t}\n#endif\n\n\t\t/* Note: key issue here is to re-lookup the base pointer on every attempt.\n\t\t * The pointer being reallocated may change after every mark-and-sweep.\n\t\t */\n\n\t\tres = heap->realloc_func(heap->heap_udata, cb(heap, ud), newsize);\n\t\tif (res || newsize == 0) {\n\t\t\tDUK_D(DUK_DPRINT(\"duk_heap_mem_realloc_indirect() succeeded after gc (pass %ld), alloc size %ld\",\n\t\t\t                 (long) (i + 1), (long) newsize));\n\t\t\treturn res;\n\t\t}\n\t}\n\n\tDUK_D(DUK_DPRINT(\"duk_heap_mem_realloc_indirect() failed even after gc, alloc size %ld\", (long) newsize));\n\treturn NULL;\n}\n\n/*\n *  Free memory\n */\n\nDUK_INTERNAL void duk_heap_mem_free(duk_heap *heap, void *ptr) {\n\tDUK_ASSERT(heap != NULL);\n\t/* ptr may be NULL */\n\n\t/* Must behave like a no-op with NULL and any pointer returned from\n\t * malloc/realloc with zero size.\n\t */\n\theap->free_func(heap->heap_udata, ptr);\n\n\t/* Never perform a GC (even voluntary) in a memory free, otherwise\n\t * all call sites doing frees would need to deal with the side effects.\n\t * No need to update voluntary GC counter either.\n\t */\n}\n\n/* automatic undefs */\n#undef DUK__VOLUNTARY_PERIODIC_GC\n/*\n *  Support functions for duk_heap.\n */\n\n/* #include duk_internal.h -> already included */\n\nDUK_INTERNAL void duk_heap_insert_into_heap_allocated(duk_heap *heap, duk_heaphdr *hdr) {\n\tduk_heaphdr *root;\n\n\tDUK_ASSERT(DUK_HEAPHDR_GET_TYPE(hdr) != DUK_HTYPE_STRING);\n\n\troot = heap->heap_allocated;\n#if defined(DUK_USE_DOUBLE_LINKED_HEAP)\n\tif (root != NULL) {\n\t\tDUK_ASSERT(DUK_HEAPHDR_GET_PREV(heap, root) == NULL);\n\t\tDUK_HEAPHDR_SET_PREV(heap, root, hdr);\n\t}\n\tDUK_HEAPHDR_SET_PREV(heap, hdr, NULL);\n#endif\n\tDUK_HEAPHDR_SET_NEXT(heap, hdr, root);\n\tDUK_ASSERT_HEAPHDR_LINKS(heap, hdr);\n\tDUK_ASSERT_HEAPHDR_LINKS(heap, root);\n\theap->heap_allocated = hdr;\n}\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\nDUK_INTERNAL void duk_heap_remove_from_heap_allocated(duk_heap *heap, duk_heaphdr *hdr) {\n\tduk_heaphdr *prev;\n\tduk_heaphdr *next;\n\n\t/* Strings are in string table. */\n\tDUK_ASSERT(hdr != NULL);\n\tDUK_ASSERT(DUK_HEAPHDR_GET_TYPE(hdr) != DUK_HTYPE_STRING);\n\n\t/* Target 'hdr' must be in heap_allocated (not e.g. finalize_list).\n\t * If not, heap lists will become corrupted so assert early for it.\n\t */\n#if defined(DUK_USE_ASSERTIONS)\n\t{\n\t\tduk_heaphdr *tmp;\n\t\tfor (tmp = heap->heap_allocated; tmp != NULL; tmp = DUK_HEAPHDR_GET_NEXT(heap, tmp)) {\n\t\t\tif (tmp == hdr) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tDUK_ASSERT(tmp == hdr);\n\t}\n#endif\n\n\t/* Read/write only once to minimize pointer compression calls. */\n\tprev = DUK_HEAPHDR_GET_PREV(heap, hdr);\n\tnext = DUK_HEAPHDR_GET_NEXT(heap, hdr);\n\n\tif (prev != NULL) {\n\t\tDUK_ASSERT(heap->heap_allocated != hdr);\n\t\tDUK_HEAPHDR_SET_NEXT(heap, prev, next);\n\t} else {\n\t\tDUK_ASSERT(heap->heap_allocated == hdr);\n\t\theap->heap_allocated = next;\n\t}\n\tif (next != NULL) {\n\t\tDUK_HEAPHDR_SET_PREV(heap, next, prev);\n\t} else {\n\t\t;\n\t}\n}\n#endif  /* DUK_USE_REFERENCE_COUNTING */\n\n#if defined(DUK_USE_FINALIZER_SUPPORT)\nDUK_INTERNAL void duk_heap_insert_into_finalize_list(duk_heap *heap, duk_heaphdr *hdr) {\n\tduk_heaphdr *root;\n\n\troot = heap->finalize_list;\n#if defined(DUK_USE_DOUBLE_LINKED_HEAP)\n\tDUK_HEAPHDR_SET_PREV(heap, hdr, NULL);\n\tif (root != NULL) {\n\t\tDUK_ASSERT(DUK_HEAPHDR_GET_PREV(heap, root) == NULL);\n\t\tDUK_HEAPHDR_SET_PREV(heap, root, hdr);\n\t}\n#endif\n\tDUK_HEAPHDR_SET_NEXT(heap, hdr, root);\n\tDUK_ASSERT_HEAPHDR_LINKS(heap, hdr);\n\tDUK_ASSERT_HEAPHDR_LINKS(heap, root);\n\theap->finalize_list = hdr;\n}\n#endif  /* DUK_USE_FINALIZER_SUPPORT */\n\n#if defined(DUK_USE_FINALIZER_SUPPORT)\nDUK_INTERNAL void duk_heap_remove_from_finalize_list(duk_heap *heap, duk_heaphdr *hdr) {\n#if defined(DUK_USE_DOUBLE_LINKED_HEAP)\n\tduk_heaphdr *next;\n\tduk_heaphdr *prev;\n\n\tnext = DUK_HEAPHDR_GET_NEXT(heap, hdr);\n\tprev = DUK_HEAPHDR_GET_PREV(heap, hdr);\n\tif (next != NULL) {\n\t\tDUK_ASSERT(DUK_HEAPHDR_GET_PREV(heap, next) == hdr);\n\t\tDUK_HEAPHDR_SET_PREV(heap, next, prev);\n\t}\n\tif (prev == NULL) {\n\t\tDUK_ASSERT(hdr == heap->finalize_list);\n\t\theap->finalize_list = next;\n\t} else {\n\t\tDUK_ASSERT(hdr != heap->finalize_list);\n\t\tDUK_HEAPHDR_SET_NEXT(heap, prev, next);\n\t}\n#else\n\tduk_heaphdr *next;\n\tduk_heaphdr *curr;\n\n\t/* Random removal is expensive: we need to locate the previous element\n\t * because we don't have a 'prev' pointer.\n\t */\n\tcurr = heap->finalize_list;\n\tif (curr == hdr) {\n\t\theap->finalize_list = DUK_HEAPHDR_GET_NEXT(heap, curr);\n\t} else {\n\t\tDUK_ASSERT(hdr != heap->finalize_list);\n\t\tfor (;;) {\n\t\t\tDUK_ASSERT(curr != NULL);  /* Caller responsibility. */\n\n\t\t\tnext = DUK_HEAPHDR_GET_NEXT(heap, curr);\n\t\t\tif (next == hdr) {\n\t\t\t\tnext = DUK_HEAPHDR_GET_NEXT(heap, hdr);\n\t\t\t\tDUK_HEAPHDR_SET_NEXT(heap, curr, next);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n#endif\n}\n#endif  /* DUK_USE_FINALIZER_SUPPORT */\n\n#if defined(DUK_USE_ASSERTIONS)\nDUK_INTERNAL duk_bool_t duk_heap_in_heap_allocated(duk_heap *heap, duk_heaphdr *ptr) {\n\tduk_heaphdr *curr;\n\tDUK_ASSERT(heap != NULL);\n\n\tfor (curr = heap->heap_allocated; curr != NULL; curr = DUK_HEAPHDR_GET_NEXT(heap, curr)) {\n\t\tif (curr == ptr) {\n\t\t\treturn 1;\n\t\t}\n\t}\n\treturn 0;\n}\n#endif  /* DUK_USE_ASSERTIONS */\n\n#if defined(DUK_USE_INTERRUPT_COUNTER)\nDUK_INTERNAL void duk_heap_switch_thread(duk_heap *heap, duk_hthread *new_thr) {\n\tduk_hthread *curr_thr;\n\n\tDUK_ASSERT(heap != NULL);\n\n\tif (new_thr != NULL) {\n\t\tcurr_thr = heap->curr_thread;\n\t\tif (curr_thr == NULL) {\n\t\t\t/* For initial entry use default value; zero forces an\n\t\t\t * interrupt before executing the first insturction.\n\t\t\t */\n\t\t\tDUK_DD(DUK_DDPRINT(\"switch thread, initial entry, init default interrupt counter\"));\n\t\t\tnew_thr->interrupt_counter = 0;\n\t\t\tnew_thr->interrupt_init = 0;\n\t\t} else {\n\t\t\t/* Copy interrupt counter/init value state to new thread (if any).\n\t\t\t * It's OK for new_thr to be the same as curr_thr.\n\t\t\t */\n#if defined(DUK_USE_DEBUG)\n\t\t\tif (new_thr != curr_thr) {\n\t\t\t\tDUK_DD(DUK_DDPRINT(\"switch thread, not initial entry, copy interrupt counter\"));\n\t\t\t}\n#endif\n\t\t\tnew_thr->interrupt_counter = curr_thr->interrupt_counter;\n\t\t\tnew_thr->interrupt_init = curr_thr->interrupt_init;\n\t\t}\n\t} else {\n\t\tDUK_DD(DUK_DDPRINT(\"switch thread, new thread is NULL, no interrupt counter changes\"));\n\t}\n\n\theap->curr_thread = new_thr;  /* may be NULL */\n}\n#endif  /* DUK_USE_INTERRUPT_COUNTER */\n/*\n *  Reference counting implementation.\n *\n *  INCREF/DECREF, finalization and freeing of objects whose refcount reaches\n *  zero (refzero).  These operations are very performance sensitive, so\n *  various small tricks are used in an attempt to maximize speed.\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\n#if !defined(DUK_USE_DOUBLE_LINKED_HEAP)\n#error internal error, reference counting requires a double linked heap\n#endif\n\n/*\n *  Heap object refcount finalization.\n *\n *  When an object is about to be freed, all other objects it refers to must\n *  be decref'd.  Refcount finalization does NOT free the object or its inner\n *  allocations (mark-and-sweep shares these helpers), it just manipulates\n *  the refcounts.\n *\n *  Note that any of the DECREFs may cause a refcount to drop to zero.  If so,\n *  the object won't be refzero processed inline, but will just be queued to\n *  refzero_list and processed by an earlier caller working on refzero_list,\n *  eliminating C recursion from even long refzero cascades.  If refzero\n *  finalization is triggered by mark-and-sweep, refzero conditions are ignored\n *  (objects are not even queued to refzero_list) because mark-and-sweep deals\n *  with them; refcounts are still updated so that they remain in sync with\n *  actual references.\n */\n\nDUK_INTERNAL void duk_hobject_refcount_finalize_norz(duk_heap *heap, duk_hobject *h) {\n\tduk_hthread *thr;\n\tduk_uint_fast32_t i;\n\tduk_uint_fast32_t n;\n\tduk_propvalue *p_val;\n\tduk_tval *p_tv;\n\tduk_hstring **p_key;\n\tduk_uint8_t *p_flag;\n\tduk_hobject *h_proto;\n\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT(heap->heap_thread != NULL);\n\tDUK_ASSERT(h);\n\tDUK_ASSERT(DUK_HEAPHDR_GET_TYPE((duk_heaphdr *) h) == DUK_HTYPE_OBJECT);\n\n\tthr = heap->heap_thread;\n\tDUK_ASSERT(thr != NULL);\n\n\tp_key = DUK_HOBJECT_E_GET_KEY_BASE(heap, h);\n\tp_val = DUK_HOBJECT_E_GET_VALUE_BASE(heap, h);\n\tp_flag = DUK_HOBJECT_E_GET_FLAGS_BASE(heap, h);\n\tn = DUK_HOBJECT_GET_ENEXT(h);\n\twhile (n-- > 0) {\n\t\tduk_hstring *key;\n\n\t\tkey = p_key[n];\n\t\tif (DUK_UNLIKELY(key == NULL)) {\n\t\t\tcontinue;\n\t\t}\n\t\tDUK_HSTRING_DECREF_NORZ(thr, key);\n\t\tif (DUK_UNLIKELY(p_flag[n] & DUK_PROPDESC_FLAG_ACCESSOR)) {\n\t\t\tduk_hobject *h_getset;\n\t\t\th_getset = p_val[n].a.get;\n\t\t\tDUK_ASSERT(h_getset == NULL || DUK_HEAPHDR_IS_OBJECT((duk_heaphdr *) h_getset));\n\t\t\tDUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr, h_getset);\n\t\t\th_getset = p_val[n].a.set;\n\t\t\tDUK_ASSERT(h_getset == NULL || DUK_HEAPHDR_IS_OBJECT((duk_heaphdr *) h_getset));\n\t\t\tDUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr, h_getset);\n\t\t} else {\n\t\t\tduk_tval *tv_val;\n\t\t\ttv_val = &p_val[n].v;\n\t\t\tDUK_TVAL_DECREF_NORZ(thr, tv_val);\n\t\t}\n\t}\n\n\tp_tv = DUK_HOBJECT_A_GET_BASE(heap, h);\n\tn = DUK_HOBJECT_GET_ASIZE(h);\n\twhile (n-- > 0) {\n\t\tduk_tval *tv_val;\n\t\ttv_val = p_tv + n;\n\t\tDUK_TVAL_DECREF_NORZ(thr, tv_val);\n\t}\n\n\t/* Hash part is a 'weak reference' and doesn't contribute to refcounts. */\n\n\th_proto = (duk_hobject *) DUK_HOBJECT_GET_PROTOTYPE(heap, h);\n\tDUK_ASSERT(h_proto == NULL || DUK_HEAPHDR_IS_OBJECT((duk_heaphdr *) h_proto));\n\tDUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr, h_proto);\n\n\t/* XXX: Object subclass tests are quite awkward at present, ideally\n\t * we should be able to switch-case here with a dense index (subtype\n\t * number or something).  For now, fast path plain objects and arrays\n\t * and bit test the rest individually.\n\t */\n\n\tif (DUK_HOBJECT_HAS_FASTREFS(h)) {\n\t\t/* Plain object or array, nothing more to do.  While a\n\t\t * duk_harray has additional fields, none of them need\n\t\t * DECREF updates.\n\t\t */\n\t\tDUK_ASSERT(DUK_HOBJECT_ALLOWS_FASTREFS(h));\n\t\treturn;\n\t}\n\tDUK_ASSERT(DUK_HOBJECT_PROHIBITS_FASTREFS(h));\n\n\t/* Slow path: special object, start bit checks from most likely. */\n\n\tif (DUK_HOBJECT_IS_COMPFUNC(h)) {\n\t\tduk_hcompfunc *f = (duk_hcompfunc *) h;\n\t\tduk_tval *tv, *tv_end;\n\t\tduk_hobject **funcs, **funcs_end;\n\n\t\tif (DUK_LIKELY(DUK_HCOMPFUNC_GET_DATA(heap, f) != NULL)) {\n\t\t\ttv = DUK_HCOMPFUNC_GET_CONSTS_BASE(heap, f);\n\t\t\ttv_end = DUK_HCOMPFUNC_GET_CONSTS_END(heap, f);\n\t\t\twhile (tv < tv_end) {\n\t\t\t\tDUK_TVAL_DECREF_NORZ(thr, tv);\n\t\t\t\ttv++;\n\t\t\t}\n\n\t\t\tfuncs = DUK_HCOMPFUNC_GET_FUNCS_BASE(heap, f);\n\t\t\tfuncs_end = DUK_HCOMPFUNC_GET_FUNCS_END(heap, f);\n\t\t\twhile (funcs < funcs_end) {\n\t\t\t\tduk_hobject *h_func;\n\t\t\t\th_func = *funcs;\n\t\t\t\tDUK_ASSERT(h_func != NULL);\n\t\t\t\tDUK_ASSERT(DUK_HEAPHDR_IS_OBJECT((duk_heaphdr *) h_func));\n\t\t\t\tDUK_HCOMPFUNC_DECREF_NORZ(thr, (duk_hcompfunc *) h_func);\n\t\t\t\tfuncs++;\n\t\t\t}\n\t\t} else {\n\t\t\t/* May happen in some out-of-memory corner cases. */\n\t\t\tDUK_D(DUK_DPRINT(\"duk_hcompfunc 'data' is NULL, skipping decref\"));\n\t\t}\n\n\t\tDUK_HEAPHDR_DECREF_ALLOWNULL(thr, (duk_heaphdr *) DUK_HCOMPFUNC_GET_LEXENV(heap, f));\n\t\tDUK_HEAPHDR_DECREF_ALLOWNULL(thr, (duk_heaphdr *) DUK_HCOMPFUNC_GET_VARENV(heap, f));\n\t\tDUK_HEAPHDR_DECREF_ALLOWNULL(thr, (duk_hbuffer *) DUK_HCOMPFUNC_GET_DATA(heap, f));\n\t} else if (DUK_HOBJECT_IS_DECENV(h)) {\n\t\tduk_hdecenv *e = (duk_hdecenv *) h;\n\t\tDUK_ASSERT_HDECENV_VALID(e);\n\t\tDUK_HTHREAD_DECREF_NORZ_ALLOWNULL(thr, e->thread);\n\t\tDUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr, e->varmap);\n\t} else if (DUK_HOBJECT_IS_OBJENV(h)) {\n\t\tduk_hobjenv *e = (duk_hobjenv *) h;\n\t\tDUK_ASSERT_HOBJENV_VALID(e);\n\t\tDUK_ASSERT(e->target != NULL);  /* Required for object environments. */\n\t\tDUK_HOBJECT_DECREF_NORZ(thr, e->target);\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n\t} else if (DUK_HOBJECT_IS_BUFOBJ(h)) {\n\t\tduk_hbufobj *b = (duk_hbufobj *) h;\n\t\tDUK_HBUFFER_DECREF_NORZ_ALLOWNULL(thr, (duk_hbuffer *) b->buf);\n\t\tDUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr, (duk_hobject *) b->buf_prop);\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\t} else if (DUK_HOBJECT_IS_THREAD(h)) {\n\t\tduk_hthread *t = (duk_hthread *) h;\n\t\tduk_tval *tv;\n\n\t\ttv = t->valstack;\n\t\twhile (tv < t->valstack_top) {\n\t\t\tDUK_TVAL_DECREF_NORZ(thr, tv);\n\t\t\ttv++;\n\t\t}\n\n\t\tfor (i = 0; i < (duk_uint_fast32_t) t->callstack_top; i++) {\n\t\t\tduk_activation *act = t->callstack + i;\n\t\t\tDUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr, (duk_hobject *) DUK_ACT_GET_FUNC(act));\n\t\t\tDUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr, (duk_hobject *) act->var_env);\n\t\t\tDUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr, (duk_hobject *) act->lex_env);\n#if defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)\n\t\t\tDUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr, (duk_hobject *) act->prev_caller);\n#endif\n\t\t}\n\n#if 0  /* nothing now */\n\t\tfor (i = 0; i < (duk_uint_fast32_t) t->catchstack_top; i++) {\n\t\t\tduk_catcher *cat = t->catchstack + i;\n\t\t}\n#endif\n\n\t\tfor (i = 0; i < DUK_NUM_BUILTINS; i++) {\n\t\t\tDUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr, (duk_hobject *) t->builtins[i]);\n\t\t}\n\n\t\tDUK_HTHREAD_DECREF_NORZ_ALLOWNULL(thr, (duk_hthread *) t->resumer);\n\t} else {\n\t\t/* We may come here if the object should have a FASTREFS flag\n\t\t * but it's missing for some reason.  Assert for never getting\n\t\t * here; however, other than performance, this is harmless.\n\t\t */\n\t\tDUK_D(DUK_DPRINT(\"missing FASTREFS flag for: %!iO\", h));\n\t\tDUK_ASSERT(0);\n\t}\n}\n\nDUK_INTERNAL void duk_heaphdr_refcount_finalize_norz(duk_heap *heap, duk_heaphdr *hdr) {\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT(heap->heap_thread != NULL);\n\tDUK_ASSERT(hdr != NULL);\n\n\tif (DUK_HEAPHDR_IS_OBJECT(hdr)) {\n\t\tduk_hobject_refcount_finalize_norz(heap, (duk_hobject *) hdr);\n\t}\n\t/* DUK_HTYPE_BUFFER: nothing to finalize */\n\t/* DUK_HTYPE_STRING: nothing to finalize */\n}\n\n/*\n *  Refzero processing for duk_hobject: queue a refzero'ed object to either\n *  finalize_list or refzero_list and process the relevent list(s) if\n *  necessary.\n *\n *  Refzero_list is single linked, with only 'prev' pointers set and valid.\n *  All 'next' pointers are intentionally left as garbage.  This doesn't\n *  matter because refzero_list is processed to completion before any other\n *  code (like mark-and-sweep) might walk the list.\n *\n *  In more detail:\n *\n *  - On first insert refzero_list is NULL and the new object becomes the\n *    first and only element on the list; duk__refcount_free_pending() is\n *    called and it starts processing the list from the initial element,\n *    i.e. the list tail.\n *\n *  - As each object is refcount finalized, new objects may be queued to\n *    refzero_list head.  Their 'next' pointers are left as garbage, but\n *    'prev' points are set correctly, with the element at refzero_list\n *    having a NULL 'prev' pointer.  The fact that refzero_list is non-NULL\n *    is used to reject (1) recursive duk__refcount_free_pending() and\n *    (2) finalize_list processing calls.\n *\n *  - When we're done with the current object, read its 'prev' pointer and\n *    free the object.  If 'prev' is NULL, we've reached head of list and are\n *    done: set refzero_list to NULL and process pending finalizers.  Otherwise\n *    continue processing the list.\n *\n *  A refzero cascade is free of side effects because it only involves\n *  queueing more objects and freeing memory; finalizer execution is blocked\n *  in the code path queueing objects to finalize_list.  As a result the\n *  initial refzero call (which triggers duk__refcount_free_pending()) must\n *  check finalize_list so that finalizers are executed snappily.\n *\n *  If finalize_list processing starts first, refzero may occur while we're\n *  processing finalizers.  That's fine: that particular refzero cascade is\n *  handled to completion without side effects.  Once the cascade is complete,\n *  we'll run pending finalizers but notice that we're already doing that and\n *  return.\n *\n *  This could be expanded to allow incremental freeing: just bail out\n *  early and resume at a future alloc/decref/refzero.  However, if that\n *  were done, the list structure would need to be kept consistent at all\n *  times, mark-and-sweep would need to handle refzero_list, etc.\n */\n\nDUK_LOCAL void duk__refcount_free_pending(duk_heap *heap) {\n\tduk_heaphdr *curr;\n#if defined(DUK_USE_DEBUG)\n\tduk_int_t count = 0;\n#endif\n\n\tDUK_ASSERT(heap != NULL);\n\n\tcurr = heap->refzero_list;\n\tDUK_ASSERT(curr != NULL);\n\tDUK_ASSERT(DUK_HEAPHDR_GET_PREV(heap, curr) == NULL);  /* We're called on initial insert only. */\n\t/* curr->next is GARBAGE. */\n\n\tdo {\n\t\tduk_heaphdr *prev;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"refzero processing %p: %!O\", (void *) curr, (duk_heaphdr *) curr));\n\n#if defined(DUK_USE_DEBUG)\n\t\tcount++;\n#endif\n\n\t\tDUK_ASSERT(curr != NULL);\n\t\tDUK_ASSERT(DUK_HEAPHDR_GET_TYPE(curr) == DUK_HTYPE_OBJECT);  /* currently, always the case */\n\t\t/* FINALIZED may be set; don't care about flags here. */\n\n\t\t/* Refcount finalize 'curr'.  Refzero_list must be non-NULL\n\t\t * here to prevent recursive entry to duk__refcount_free_pending().\n\t\t */\n\t\tDUK_ASSERT(heap->refzero_list != NULL);\n\t\tduk_hobject_refcount_finalize_norz(heap, (duk_hobject *) curr);\n\n\t\tprev = DUK_HEAPHDR_GET_PREV(heap, curr);\n\t\tDUK_ASSERT((prev == NULL && heap->refzero_list == curr) || \\\n\t\t           (prev != NULL && heap->refzero_list != curr));\n\t\t/* prev->next is intentionally not updated and is garbage. */\n\n\t\tduk_free_hobject(heap, (duk_hobject *) curr);  /* Invalidates 'curr'. */\n\n\t\tcurr = prev;\n\t} while (curr != NULL);\n\n\theap->refzero_list = NULL;\n\n\tDUK_DD(DUK_DDPRINT(\"refzero processed %ld objects\", (long) count));\n}\n\nDUK_LOCAL DUK_INLINE void duk__refcount_refzero_hobject(duk_heap *heap, duk_hobject *obj, duk_bool_t skip_free_pending) {\n\tduk_heaphdr *hdr;\n\tduk_heaphdr *root;\n\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT(heap->heap_thread != NULL);\n\tDUK_ASSERT(obj != NULL);\n\tDUK_ASSERT(DUK_HEAPHDR_GET_TYPE((duk_heaphdr *) obj) == DUK_HTYPE_OBJECT);\n\n\thdr = (duk_heaphdr *) obj;\n\n\t/* Refzero'd objects must be in heap_allocated.  They can't be in\n\t * finalize_list because all objects on finalize_list have an\n\t * artificial +1 refcount bump.\n\t */\n#if defined(DUK_USE_ASSERTIONS)\n\tDUK_ASSERT(duk_heap_in_heap_allocated(heap, (duk_heaphdr *) obj));\n#endif\n\n\tDUK_HEAP_REMOVE_FROM_HEAP_ALLOCATED(heap, hdr);\n\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n\t/* This finalizer check MUST BE side effect free.  It should also be\n\t * as fast as possible because it's applied to every object freed.\n\t */\n\tif (DUK_UNLIKELY(DUK_HOBJECT_HAS_FINALIZER_FAST(heap, (duk_hobject *) hdr))) {\n\t\t/* Special case: FINALIZED may be set if mark-and-sweep queued\n\t\t * object for finalization, the finalizer was executed (and\n\t\t * FINALIZED set), mark-and-sweep hasn't yet processed the\n\t\t * object again, but its refcount drops to zero.  Free without\n\t\t * running the finalizer again.\n\t\t */\n\t\tif (DUK_HEAPHDR_HAS_FINALIZED(hdr)) {\n\t\t\tDUK_D(DUK_DPRINT(\"refzero'd object has finalizer and FINALIZED is set -> free\"));\n\t\t} else {\n\t\t\t/* Set FINALIZABLE flag so that all objects on finalize_list\n\t\t\t * will have it set and are thus detectable based on the\n\t\t\t * flag alone.\n\t\t\t */\n\t\t\tDUK_HEAPHDR_SET_FINALIZABLE(hdr);\n\t\t\tDUK_ASSERT(!DUK_HEAPHDR_HAS_FINALIZED(hdr));\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\t\t\t/* Bump refcount on finalize_list insert so that a\n\t\t\t * refzero can never occur when an object is waiting\n\t\t\t * for its finalizer call.  Refzero might otherwise\n\t\t\t * now happen because we allow duk_push_heapptr() for\n\t\t\t * objects pending finalization.\n\t\t\t */\n\t\t\tDUK_HEAPHDR_PREINC_REFCOUNT(hdr);\n#endif\n\t\t\tDUK_HEAP_INSERT_INTO_FINALIZE_LIST(heap, hdr);\n\n\t\t\t/* Process finalizers unless skipping is explicitly\n\t\t\t * requested (NORZ) or refzero_list is being processed\n\t\t\t * (avoids side effects during a refzero cascade).\n\t\t\t * If refzero_list is processed, the initial refzero\n\t\t\t * call will run pending finalizers when refzero_list\n\t\t\t * is done.\n\t\t\t */\n\t\t\tif (!skip_free_pending && heap->refzero_list == NULL) {\n\t\t\t\tduk_heap_process_finalize_list(heap);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t}\n#endif  /* DUK_USE_FINALIZER_SUPPORT */\n\n\t/* No need to finalize, free object via refzero_list. */\n\n\troot = heap->refzero_list;\n\n\tDUK_HEAPHDR_SET_PREV(heap, hdr, NULL);\n\t/* 'next' is left as GARBAGE. */\n\theap->refzero_list = hdr;\n\n\tif (root == NULL) {\n\t\t/* Object is now queued.  Refzero_list was NULL so\n\t\t * no-one is currently processing it; do it here.\n\t\t * With refzero processing just doing a cascade of\n\t\t * free calls, we can process it directly even when\n\t\t * NORZ macros are used: there are no side effects.\n\t\t */\n\t\tduk__refcount_free_pending(heap);\n\t\tDUK_ASSERT(heap->refzero_list == NULL);\n\n\t\t/* Process finalizers only after the entire cascade\n\t\t * is finished.  In most cases there's nothing to\n\t\t * finalize, so fast path check to avoid a call.\n\t\t */\n#if defined(DUK_USE_FINALIZER_SUPPORT)\n\t\tif (!skip_free_pending && DUK_UNLIKELY(heap->finalize_list != NULL)) {\n\t\t\tduk_heap_process_finalize_list(heap);\n\t\t}\n#endif\n\t} else {\n\t\tDUK_ASSERT(DUK_HEAPHDR_GET_PREV(heap, root) == NULL);\n\t\tDUK_HEAPHDR_SET_PREV(heap, root, hdr);\n\n\t\t/* Object is now queued.  Because refzero_list was\n\t\t * non-NULL, it's already being processed by someone\n\t\t * in the C call stack, so we're done.\n\t\t */\n\t}\n}\n\n#if defined(DUK_USE_FINALIZER_SUPPORT)\nDUK_INTERNAL DUK_ALWAYS_INLINE void duk_refzero_check_fast(duk_hthread *thr) {\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\tDUK_ASSERT(thr->heap->refzero_list == NULL);  /* Processed to completion inline. */\n\n\tif (DUK_UNLIKELY(thr->heap->finalize_list != NULL)) {\n\t\tduk_heap_process_finalize_list(thr->heap);\n\t}\n}\n\nDUK_INTERNAL void duk_refzero_check_slow(duk_hthread *thr) {\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\tDUK_ASSERT(thr->heap->refzero_list == NULL);  /* Processed to completion inline. */\n\n\tif (DUK_UNLIKELY(thr->heap->finalize_list != NULL)) {\n\t\tduk_heap_process_finalize_list(thr->heap);\n\t}\n}\n#endif  /* DUK_USE_FINALIZER_SUPPORT */\n\n/*\n *  Refzero processing for duk_hstring.\n */\n\nDUK_LOCAL DUK_INLINE void duk__refcount_refzero_hstring(duk_heap *heap, duk_hstring *str) {\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT(heap->heap_thread != NULL);\n\tDUK_ASSERT(str != NULL);\n\tDUK_ASSERT(DUK_HEAPHDR_GET_TYPE((duk_heaphdr *) str) == DUK_HTYPE_STRING);\n\n\tduk_heap_strcache_string_remove(heap, str);\n\tduk_heap_strtable_unlink(heap, str);\n\tduk_free_hstring(heap, str);\n}\n\n/*\n *  Refzero processing for duk_hbuffer.\n */\n\nDUK_LOCAL DUK_INLINE void duk__refcount_refzero_hbuffer(duk_heap *heap, duk_hbuffer *buf) {\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT(heap->heap_thread != NULL);\n\tDUK_ASSERT(buf != NULL);\n\tDUK_ASSERT(DUK_HEAPHDR_GET_TYPE((duk_heaphdr *) buf) == DUK_HTYPE_BUFFER);\n\n\tDUK_HEAP_REMOVE_FROM_HEAP_ALLOCATED(heap, (duk_heaphdr *) buf);\n\tduk_free_hbuffer(heap, buf);\n}\n\n/*\n *  Incref and decref functions.\n *\n *  Decref may trigger immediate refzero handling, which may free and finalize\n *  an arbitrary number of objects (a \"DECREF cascade\").\n *\n *  Refzero handling is skipped entirely if (1) mark-and-sweep is running or\n *  (2) execution is paused in the debugger.  The objects are left in the heap,\n *  and will be freed by mark-and-sweep or eventual heap destruction.\n *\n *  This is necessary during mark-and-sweep because refcounts are also updated\n *  during the sweep phase (otherwise objects referenced by a swept object\n *  would have incorrect refcounts) which then calls here.  This could be\n *  avoided by using separate decref macros in mark-and-sweep; however,\n *  mark-and-sweep also calls finalizers which would use the ordinary decref\n *  macros anyway.\n *\n *  We can't process refzeros (= free objects) when the debugger is running\n *  as the debugger might make an object unreachable but still continue\n *  inspecting it (or even cause it to be pushed back).  So we must rely on\n *  mark-and-sweep to collect them.\n *\n *  The DUK__RZ_SUPPRESS_CHECK() condition is also used in heap destruction\n *  when running finalizers for remaining objects: the flag prevents objects\n *  from being moved around in heap linked lists while that's being done.\n *\n *  The suppress condition is important to performance.\n */\n\n#define DUK__RZ_SUPPRESS_ASSERT1() do { \\\n\t\tDUK_ASSERT(thr != NULL); \\\n\t\tDUK_ASSERT(thr->heap != NULL); \\\n\t\t/* When mark-and-sweep runs, heap_thread must exist. */ \\\n\t\tDUK_ASSERT(thr->heap->ms_running == 0 || thr->heap->heap_thread != NULL); \\\n\t\t/* When mark-and-sweep runs, the 'thr' argument always matches heap_thread. \\\n\t\t * This could be used to e.g. suppress check against 'thr' directly (and \\\n\t\t * knowing it would be heap_thread); not really used now. \\\n\t\t */ \\\n\t\tDUK_ASSERT(thr->heap->ms_running == 0 || thr == thr->heap->heap_thread); \\\n\t\t/* We may be called when the heap is initializing and we process \\\n\t\t * refzeros normally, but mark-and-sweep and finalizers are prevented \\\n\t\t * if that's the case. \\\n\t\t */ \\\n\t\tDUK_ASSERT(thr->heap->heap_initializing == 0 || thr->heap->ms_prevent_count > 0); \\\n\t\tDUK_ASSERT(thr->heap->heap_initializing == 0 || thr->heap->pf_prevent_count > 0); \\\n\t} while (0)\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n#define DUK__RZ_SUPPRESS_ASSERT2() do { \\\n\t\t/* When debugger is paused, ms_running is set. */ \\\n\t\tDUK_ASSERT(!DUK_HEAP_HAS_DEBUGGER_PAUSED(thr->heap) || thr->heap->ms_running != 0); \\\n\t} while (0)\n#define DUK__RZ_SUPPRESS_COND()  (heap->ms_running != 0)\n#else\n#define DUK__RZ_SUPPRESS_ASSERT2() do { } while (0)\n#define DUK__RZ_SUPPRESS_COND()  (heap->ms_running != 0)\n#endif  /* DUK_USE_DEBUGGER_SUPPORT */\n\n#define DUK__RZ_SUPPRESS_CHECK() do { \\\n\t\tDUK__RZ_SUPPRESS_ASSERT1(); \\\n\t\tDUK__RZ_SUPPRESS_ASSERT2(); \\\n\t\tif (DUK_UNLIKELY(DUK__RZ_SUPPRESS_COND())) { \\\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"refzero handling suppressed (not even queued) when mark-and-sweep running, object: %p\", (void *) h)); \\\n\t\t\treturn; \\\n\t\t} \\\n\t} while (0)\n\n#define DUK__RZ_STRING() do { \\\n\t\tduk__refcount_refzero_hstring(heap, (duk_hstring *) h); \\\n\t} while (0)\n#define DUK__RZ_BUFFER() do { \\\n\t\tduk__refcount_refzero_hbuffer(heap, (duk_hbuffer *) h); \\\n\t} while (0)\n#define DUK__RZ_OBJECT() do { \\\n\t\tduk__refcount_refzero_hobject(heap, (duk_hobject *) h, skip_free_pending); \\\n\t} while (0)\n\n/* XXX: test the effect of inlining here vs. NOINLINE in refzero helpers */\n#if defined(DUK_USE_FAST_REFCOUNT_DEFAULT)\n#define DUK__RZ_INLINE DUK_ALWAYS_INLINE\n#else\n#define DUK__RZ_INLINE /*nop*/\n#endif\n\nDUK_LOCAL DUK__RZ_INLINE void duk__hstring_refzero_helper(duk_hthread *thr, duk_hstring *h) {\n\tduk_heap *heap;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(h != NULL);\n\theap = thr->heap;\n\n\tDUK__RZ_SUPPRESS_CHECK();\n\tDUK__RZ_STRING();\n}\n\nDUK_LOCAL DUK__RZ_INLINE void duk__hbuffer_refzero_helper(duk_hthread *thr, duk_hbuffer *h) {\n\tduk_heap *heap;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(h != NULL);\n\theap = thr->heap;\n\n\tDUK__RZ_SUPPRESS_CHECK();\n\tDUK__RZ_BUFFER();\n}\n\nDUK_LOCAL DUK__RZ_INLINE void duk__hobject_refzero_helper(duk_hthread *thr, duk_hobject *h, duk_bool_t skip_free_pending) {\n\tduk_heap *heap;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(h != NULL);\n\theap = thr->heap;\n\n\tDUK__RZ_SUPPRESS_CHECK();\n\tDUK__RZ_OBJECT();\n}\n\nDUK_LOCAL DUK__RZ_INLINE void duk__heaphdr_refzero_helper(duk_hthread *thr, duk_heaphdr *h, duk_bool_t skip_free_pending) {\n\tduk_heap *heap;\n\tduk_small_uint_t htype;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(h != NULL);\n\theap = thr->heap;\n\n\thtype = (duk_small_uint_t) DUK_HEAPHDR_GET_TYPE(h);\n\tDUK__RZ_SUPPRESS_CHECK();\n\n\tswitch (htype) {\n\tcase DUK_HTYPE_STRING:\n\t\t/* Strings have no internal references but do have \"weak\"\n\t\t * references in the string cache.  Also note that strings\n\t\t * are not on the heap_allocated list like other heap\n\t\t * elements.\n\t\t */\n\n\t\tDUK__RZ_STRING();\n\t\tbreak;\n\n\tcase DUK_HTYPE_OBJECT:\n\t\t/* Objects have internal references.  Must finalize through\n\t\t * the \"refzero\" work list.\n\t\t */\n\n\t\tDUK__RZ_OBJECT();\n\t\tbreak;\n\n\tdefault:\n\t\t/* Buffers have no internal references.  However, a dynamic\n\t\t * buffer has a separate allocation for the buffer.  This is\n\t\t * freed by duk_heap_free_heaphdr_raw().\n\t\t */\n\n\t\tDUK_ASSERT(DUK_HEAPHDR_GET_TYPE(h) == DUK_HTYPE_BUFFER);\n\t\tDUK__RZ_BUFFER();\n\t\tbreak;\n\t}\n}\n\nDUK_INTERNAL DUK_NOINLINE void duk_heaphdr_refzero(duk_hthread *thr, duk_heaphdr *h) {\n\tduk__heaphdr_refzero_helper(thr, h, 0 /*skip_free_pending*/);\n}\n\nDUK_INTERNAL DUK_NOINLINE void duk_heaphdr_refzero_norz(duk_hthread *thr, duk_heaphdr *h) {\n\tduk__heaphdr_refzero_helper(thr, h, 1 /*skip_free_pending*/);\n}\n\nDUK_INTERNAL DUK_NOINLINE void duk_hstring_refzero(duk_hthread *thr, duk_hstring *h) {\n\tduk__hstring_refzero_helper(thr, h);\n}\n\nDUK_INTERNAL DUK_NOINLINE void duk_hbuffer_refzero(duk_hthread *thr, duk_hbuffer *h) {\n\tduk__hbuffer_refzero_helper(thr, h);\n}\n\nDUK_INTERNAL DUK_NOINLINE void duk_hobject_refzero(duk_hthread *thr, duk_hobject *h) {\n\tduk__hobject_refzero_helper(thr, h, 0 /*skip_free_pending*/);\n}\n\nDUK_INTERNAL DUK_NOINLINE void duk_hobject_refzero_norz(duk_hthread *thr, duk_hobject *h) {\n\tduk__hobject_refzero_helper(thr, h, 1 /*skip_free_pending*/);\n}\n\n#if !defined(DUK_USE_FAST_REFCOUNT_DEFAULT)\nDUK_INTERNAL void duk_tval_incref(duk_tval *tv) {\n\tDUK_ASSERT(tv != NULL);\n\n\tif (DUK_TVAL_NEEDS_REFCOUNT_UPDATE(tv)) {\n\t\tduk_heaphdr *h = DUK_TVAL_GET_HEAPHDR(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\tDUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID(h));\n\t\tDUK_ASSERT_DISABLE(h->h_refcount >= 0);\n\t\tDUK_HEAPHDR_PREINC_REFCOUNT(h);\n\t\tDUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT(h) != 0);  /* No wrapping. */\n\t}\n}\n\nDUK_INTERNAL void duk_tval_decref(duk_hthread *thr, duk_tval *tv) {\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(tv != NULL);\n\n\tif (DUK_TVAL_NEEDS_REFCOUNT_UPDATE(tv)) {\n\t\tduk_heaphdr *h = DUK_TVAL_GET_HEAPHDR(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\tDUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID(h));\n\t\tDUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT(h) >= 1);\n#if 0\n\t\tif (DUK_HEAPHDR_PREDEC_REFCOUNT(h) != 0) {\n\t\t\treturn;\n\t\t}\n\t\tduk_heaphdr_refzero(thr, h);\n#else\n\t\tduk_heaphdr_decref(thr, h);\n#endif\n\t}\n}\n\nDUK_INTERNAL void duk_tval_decref_norz(duk_hthread *thr, duk_tval *tv) {\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(tv != NULL);\n\n\tif (DUK_TVAL_NEEDS_REFCOUNT_UPDATE(tv)) {\n\t\tduk_heaphdr *h = DUK_TVAL_GET_HEAPHDR(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\tDUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID(h));\n\t\tDUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT(h) >= 1);\n#if 0\n\t\tif (DUK_HEAPHDR_PREDEC_REFCOUNT(h) != 0) {\n\t\t\treturn;\n\t\t}\n\t\tduk_heaphdr_refzero_norz(thr, h);\n#else\n\t\tduk_heaphdr_decref_norz(thr, h);\n#endif\n\t}\n}\n#endif  /* !DUK_USE_FAST_REFCOUNT_DEFAULT */\n\n#define DUK__DECREF_ASSERTS() do { \\\n\t\tDUK_ASSERT(thr != NULL); \\\n\t\tDUK_ASSERT(thr->heap != NULL); \\\n\t\tDUK_ASSERT(h != NULL); \\\n\t\tDUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID((duk_heaphdr *) h)); \\\n\t\tDUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) h) >= 1); \\\n\t} while (0)\n#if defined(DUK_USE_ROM_OBJECTS)\n#define DUK__INCREF_SHARED() do { \\\n\t\tif (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) h)) { \\\n\t\t\treturn; \\\n\t\t} \\\n\t\tDUK_HEAPHDR_PREINC_REFCOUNT((duk_heaphdr *) h); \\\n\t\tDUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) h) != 0);  /* No wrapping. */ \\\n\t} while (0)\n#define DUK__DECREF_SHARED() do { \\\n\t\tif (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) h)) { \\\n\t\t\treturn; \\\n\t\t} \\\n\t\tif (DUK_HEAPHDR_PREDEC_REFCOUNT((duk_heaphdr *) h) != 0) { \\\n\t\t\treturn; \\\n\t\t} \\\n\t} while (0)\n#else\n#define DUK__INCREF_SHARED() do { \\\n\t\tDUK_HEAPHDR_PREINC_REFCOUNT((duk_heaphdr *) h); \\\n\t\tDUK_ASSERT(DUK_HEAPHDR_GET_REFCOUNT((duk_heaphdr *) h) != 0);  /* No wrapping. */ \\\n\t} while (0)\n#define DUK__DECREF_SHARED() do { \\\n\t\tif (DUK_HEAPHDR_PREDEC_REFCOUNT((duk_heaphdr *) h) != 0) { \\\n\t\t\treturn; \\\n\t\t} \\\n\t} while (0)\n#endif\n\n#if !defined(DUK_USE_FAST_REFCOUNT_DEFAULT)\n/* This will in practice be inlined because it's just an INC instructions\n * and a bit test + INC when ROM objects are enabled.\n */\nDUK_INTERNAL void duk_heaphdr_incref(duk_heaphdr *h) {\n\tDUK_ASSERT(h != NULL);\n\tDUK_ASSERT(DUK_HEAPHDR_HTYPE_VALID(h));\n\tDUK_ASSERT_DISABLE(DUK_HEAPHDR_GET_REFCOUNT(h) >= 0);\n\n\tDUK__INCREF_SHARED();\n}\n\nDUK_INTERNAL void duk_heaphdr_decref(duk_hthread *thr, duk_heaphdr *h) {\n\tDUK__DECREF_ASSERTS();\n\tDUK__DECREF_SHARED();\n\tduk_heaphdr_refzero(thr, h);\n\n\t/* Forced mark-and-sweep when GC torture enabled; this could happen\n\t * on any DECREF (but not DECREF_NORZ).\n\t */\n\tDUK_GC_TORTURE(thr->heap);\n}\nDUK_INTERNAL void duk_heaphdr_decref_norz(duk_hthread *thr, duk_heaphdr *h) {\n\tDUK__DECREF_ASSERTS();\n\tDUK__DECREF_SHARED();\n\tduk_heaphdr_refzero_norz(thr, h);\n}\n#endif  /* !DUK_USE_FAST_REFCOUNT_DEFAULT */\n\n#if 0  /* Not needed. */\nDUK_INTERNAL void duk_hstring_decref(duk_hthread *thr, duk_hstring *h) {\n\tDUK__DECREF_ASSERTS();\n\tDUK__DECREF_SHARED();\n\tduk_hstring_refzero(thr, h);\n}\nDUK_INTERNAL void duk_hstring_decref_norz(duk_hthread *thr, duk_hstring *h) {\n\tDUK__DECREF_ASSERTS();\n\tDUK__DECREF_SHARED();\n\tduk_hstring_refzero_norz(thr, h);\n}\nDUK_INTERNAL void duk_hbuffer_decref(duk_hthread *thr, duk_hbuffer *h) {\n\tDUK__DECREF_ASSERTS();\n\tDUK__DECREF_SHARED();\n\tduk_hbuffer_refzero(thr, h);\n}\nDUK_INTERNAL void duk_hbuffer_decref_norz(duk_hthread *thr, duk_hbuffer *h) {\n\tDUK__DECREF_ASSERTS();\n\tDUK__DECREF_SHARED();\n\tduk_hbuffer_refzero_norz(thr, h);\n}\nDUK_INTERNAL void duk_hobject_decref(duk_hthread *thr, duk_hobject *h) {\n\tDUK__DECREF_ASSERTS();\n\tDUK__DECREF_SHARED();\n\tduk_hobject_refzero(thr, h);\n}\nDUK_INTERNAL void duk_hobject_decref_norz(duk_hthread *thr, duk_hobject *h) {\n\tDUK__DECREF_ASSERTS();\n\tDUK__DECREF_SHARED();\n\tduk_hobject_refzero_norz(thr, h);\n}\n#endif\n\n#else  /* DUK_USE_REFERENCE_COUNTING */\n\n/* no refcounting */\n\n#endif  /* DUK_USE_REFERENCE_COUNTING */\n\n/* automatic undefs */\n#undef DUK__DECREF_ASSERTS\n#undef DUK__DECREF_SHARED\n#undef DUK__INCREF_SHARED\n#undef DUK__RZ_BUFFER\n#undef DUK__RZ_INLINE\n#undef DUK__RZ_OBJECT\n#undef DUK__RZ_STRING\n#undef DUK__RZ_SUPPRESS_ASSERT1\n#undef DUK__RZ_SUPPRESS_ASSERT2\n#undef DUK__RZ_SUPPRESS_CHECK\n#undef DUK__RZ_SUPPRESS_COND\n/*\n *  String cache.\n *\n *  Provides a cache to optimize indexed string lookups.  The cache keeps\n *  track of (byte offset, char offset) states for a fixed number of strings.\n *  Otherwise we'd need to scan from either end of the string, as we store\n *  strings in (extended) UTF-8.\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Delete references to given hstring from the heap string cache.\n *\n *  String cache references are 'weak': they are not counted towards\n *  reference counts, nor serve as roots for mark-and-sweep.  When an\n *  object is about to be freed, such references need to be removed.\n */\n\nDUK_INTERNAL void duk_heap_strcache_string_remove(duk_heap *heap, duk_hstring *h) {\n\tduk_small_int_t i;\n\tfor (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) {\n\t\tduk_strcache *c = heap->strcache + i;\n\t\tif (c->h == h) {\n\t\t\tDUK_DD(DUK_DDPRINT(\"deleting weak strcache reference to hstring %p from heap %p\",\n\t\t\t                   (void *) h, (void *) heap));\n\t\t\tc->h = NULL;\n\n\t\t\t/* XXX: the string shouldn't appear twice, but we now loop to the\n\t\t\t * end anyway; if fixed, add a looping assertion to ensure there\n\t\t\t * is no duplicate.\n\t\t\t */\n\t\t}\n\t}\n}\n\n/*\n *  String scanning helpers\n *\n *  All bytes other than UTF-8 continuation bytes ([0x80,0xbf]) are\n *  considered to contribute a character.  This must match how string\n *  character length is computed.\n */\n\nDUK_LOCAL const duk_uint8_t *duk__scan_forwards(const duk_uint8_t *p, const duk_uint8_t *q, duk_uint_fast32_t n) {\n\twhile (n > 0) {\n\t\tfor (;;) {\n\t\t\tp++;\n\t\t\tif (p >= q) {\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tif ((*p & 0xc0) != 0x80) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tn--;\n\t}\n\treturn p;\n}\n\nDUK_LOCAL const duk_uint8_t *duk__scan_backwards(const duk_uint8_t *p, const duk_uint8_t *q, duk_uint_fast32_t n) {\n\twhile (n > 0) {\n\t\tfor (;;) {\n\t\t\tp--;\n\t\t\tif (p < q) {\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tif ((*p & 0xc0) != 0x80) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tn--;\n\t}\n\treturn p;\n}\n\n/*\n *  Convert char offset to byte offset\n *\n *  Avoid using the string cache if possible: for ASCII strings byte and\n *  char offsets are equal and for short strings direct scanning may be\n *  better than using the string cache (which may evict a more important\n *  entry).\n *\n *  Typing now assumes 32-bit string byte/char offsets (duk_uint_fast32_t).\n *  Better typing might be to use duk_size_t.\n *\n *  Caller should ensure 'char_offset' is within the string bounds [0,charlen]\n *  (endpoint is inclusive).  If this is not the case, no memory unsafe\n *  behavior will happen but an error will be thrown.\n */\n\nDUK_INTERNAL duk_uint_fast32_t duk_heap_strcache_offset_char2byte(duk_hthread *thr, duk_hstring *h, duk_uint_fast32_t char_offset) {\n\tduk_heap *heap;\n\tduk_strcache *sce;\n\tduk_uint_fast32_t byte_offset;\n\tduk_small_int_t i;\n\tduk_bool_t use_cache;\n\tduk_uint_fast32_t dist_start, dist_end, dist_sce;\n\tduk_uint_fast32_t char_length;\n\tconst duk_uint8_t *p_start;\n\tconst duk_uint8_t *p_end;\n\tconst duk_uint8_t *p_found;\n\n\t/*\n\t *  For ASCII strings, the answer is simple.\n\t */\n\n\tif (DUK_LIKELY(DUK_HSTRING_IS_ASCII(h))) {\n\t\treturn char_offset;\n\t}\n\n\tchar_length = (duk_uint_fast32_t) DUK_HSTRING_GET_CHARLEN(h);\n\tDUK_ASSERT(char_offset <= char_length);\n\n\tif (DUK_LIKELY(DUK_HSTRING_IS_ASCII(h))) {\n\t\t/* Must recheck because the 'is ascii' flag may be set\n\t\t * lazily.  Alternatively, we could just compare charlen\n\t\t * to bytelen.\n\t\t */\n\t\treturn char_offset;\n\t}\n\n\t/*\n\t *  For non-ASCII strings, we need to scan forwards or backwards\n\t *  from some starting point.  The starting point may be the start\n\t *  or end of the string, or some cached midpoint in the string\n\t *  cache.\n\t *\n\t *  For \"short\" strings we simply scan without checking or updating\n\t *  the cache.  For longer strings we check and update the cache as\n\t *  necessary, inserting a new cache entry if none exists.\n\t */\n\n\tDUK_DDD(DUK_DDDPRINT(\"non-ascii string %p, char_offset=%ld, clen=%ld, blen=%ld\",\n\t                     (void *) h, (long) char_offset,\n\t                     (long) DUK_HSTRING_GET_CHARLEN(h),\n\t                     (long) DUK_HSTRING_GET_BYTELEN(h)));\n\n\theap = thr->heap;\n\tsce = NULL;\n\tuse_cache = (char_length > DUK_HEAP_STRINGCACHE_NOCACHE_LIMIT);\n\n\tif (use_cache) {\n#if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 2)\n\t\tDUK_DDD(DUK_DDDPRINT(\"stringcache before char2byte (using cache):\"));\n\t\tfor (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) {\n\t\t\tduk_strcache *c = heap->strcache + i;\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"  [%ld] -> h=%p, cidx=%ld, bidx=%ld\",\n\t\t\t                     (long) i, (void *) c->h, (long) c->cidx, (long) c->bidx));\n\t\t}\n#endif\n\n\t\tfor (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) {\n\t\t\tduk_strcache *c = heap->strcache + i;\n\n\t\t\tif (c->h == h) {\n\t\t\t\tsce = c;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t/*\n\t *  Scan from shortest distance:\n\t *    - start of string\n\t *    - end of string\n\t *    - cache entry (if exists)\n\t */\n\n\tDUK_ASSERT(DUK_HSTRING_GET_CHARLEN(h) >= char_offset);\n\tdist_start = char_offset;\n\tdist_end = char_length - char_offset;\n\tdist_sce = 0; DUK_UNREF(dist_sce);  /* initialize for debug prints, needed if sce==NULL */\n\n\tp_start = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h);\n\tp_end = (const duk_uint8_t *) (p_start + DUK_HSTRING_GET_BYTELEN(h));\n\tp_found = NULL;\n\n\tif (sce) {\n\t\tif (char_offset >= sce->cidx) {\n\t\t\tdist_sce = char_offset - sce->cidx;\n\t\t\tif ((dist_sce <= dist_start) && (dist_sce <= dist_end)) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"non-ascii string, use_cache=%ld, sce=%p:%ld:%ld, \"\n\t\t\t\t                     \"dist_start=%ld, dist_end=%ld, dist_sce=%ld => \"\n\t\t\t\t                     \"scan forwards from sce\",\n\t\t\t\t                     (long) use_cache, (void *) (sce ? sce->h : NULL),\n\t\t\t\t                     (sce ? (long) sce->cidx : (long) -1),\n\t\t\t\t                     (sce ? (long) sce->bidx : (long) -1),\n\t\t\t\t                     (long) dist_start, (long) dist_end, (long) dist_sce));\n\n\t\t\t\tp_found = duk__scan_forwards(p_start + sce->bidx,\n\t\t\t\t                             p_end,\n\t\t\t\t                             dist_sce);\n\t\t\t\tgoto scan_done;\n\t\t\t}\n\t\t} else {\n\t\t\tdist_sce = sce->cidx - char_offset;\n\t\t\tif ((dist_sce <= dist_start) && (dist_sce <= dist_end)) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"non-ascii string, use_cache=%ld, sce=%p:%ld:%ld, \"\n\t\t\t\t                     \"dist_start=%ld, dist_end=%ld, dist_sce=%ld => \"\n\t\t\t\t                     \"scan backwards from sce\",\n\t\t\t\t                     (long) use_cache, (void *) (sce ? sce->h : NULL),\n\t\t\t\t                     (sce ? (long) sce->cidx : (long) -1),\n\t\t\t\t                     (sce ? (long) sce->bidx : (long) -1),\n\t\t\t\t                     (long) dist_start, (long) dist_end, (long) dist_sce));\n\n\t\t\t\tp_found = duk__scan_backwards(p_start + sce->bidx,\n\t\t\t\t                              p_start,\n\t\t\t\t                              dist_sce);\n\t\t\t\tgoto scan_done;\n\t\t\t}\n\t\t}\n\t}\n\n\t/* no sce, or sce scan not best */\n\n\tif (dist_start <= dist_end) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"non-ascii string, use_cache=%ld, sce=%p:%ld:%ld, \"\n\t\t                     \"dist_start=%ld, dist_end=%ld, dist_sce=%ld => \"\n\t\t                     \"scan forwards from string start\",\n\t\t                     (long) use_cache, (void *) (sce ? sce->h : NULL),\n\t\t                     (sce ? (long) sce->cidx : (long) -1),\n\t\t                     (sce ? (long) sce->bidx : (long) -1),\n\t\t                     (long) dist_start, (long) dist_end, (long) dist_sce));\n\n\t\tp_found = duk__scan_forwards(p_start,\n\t\t                             p_end,\n\t\t                             dist_start);\n\t} else {\n\t\tDUK_DDD(DUK_DDDPRINT(\"non-ascii string, use_cache=%ld, sce=%p:%ld:%ld, \"\n\t\t                     \"dist_start=%ld, dist_end=%ld, dist_sce=%ld => \"\n\t\t                     \"scan backwards from string end\",\n\t\t                     (long) use_cache, (void *) (sce ? sce->h : NULL),\n\t\t                     (sce ? (long) sce->cidx : (long) -1),\n\t\t                     (sce ? (long) sce->bidx : (long) -1),\n\t\t                     (long) dist_start, (long) dist_end, (long) dist_sce));\n\n\t\tp_found = duk__scan_backwards(p_end,\n\t\t                              p_start,\n\t\t                              dist_end);\n\t}\n\n scan_done:\n\n\tif (DUK_UNLIKELY(p_found == NULL)) {\n\t\t/* Scan error: this shouldn't normally happen; it could happen if\n\t\t * string is not valid UTF-8 data, and clen/blen are not consistent\n\t\t * with the scanning algorithm.\n\t\t */\n\t\tgoto scan_error;\n\t}\n\n\tDUK_ASSERT(p_found >= p_start);\n\tDUK_ASSERT(p_found <= p_end);  /* may be equal */\n\tbyte_offset = (duk_uint32_t) (p_found - p_start);\n\n\tDUK_DDD(DUK_DDDPRINT(\"-> string %p, cidx %ld -> bidx %ld\",\n\t                     (void *) h, (long) char_offset, (long) byte_offset));\n\n\t/*\n\t *  Update cache entry (allocating if necessary), and move the\n\t *  cache entry to the first place (in an \"LRU\" policy).\n\t */\n\n\tif (use_cache) {\n\t\t/* update entry, allocating if necessary */\n\t\tif (!sce) {\n\t\t\tsce = heap->strcache + DUK_HEAP_STRCACHE_SIZE - 1;  /* take last entry */\n\t\t\tsce->h = h;\n\t\t}\n\t\tDUK_ASSERT(sce != NULL);\n\t\tsce->bidx = (duk_uint32_t) (p_found - p_start);\n\t\tsce->cidx = (duk_uint32_t) char_offset;\n\n\t\t/* LRU: move our entry to first */\n\t\tif (sce > &heap->strcache[0]) {\n\t\t\t/*\n\t\t\t *   A                  C\n\t\t\t *   B                  A\n\t\t\t *   C <- sce    ==>    B\n\t\t\t *   D                  D\n\t\t\t */\n\t\t\tduk_strcache tmp;\n\n\t\t\ttmp = *sce;\n\t\t\tDUK_MEMMOVE((void *) (&heap->strcache[1]),\n\t\t\t            (const void *) (&heap->strcache[0]),\n\t\t\t            (size_t) (((char *) sce) - ((char *) &heap->strcache[0])));\n\t\t\theap->strcache[0] = tmp;\n\n\t\t\t/* 'sce' points to the wrong entry here, but is no longer used */\n\t\t}\n#if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 2)\n\t\tDUK_DDD(DUK_DDDPRINT(\"stringcache after char2byte (using cache):\"));\n\t\tfor (i = 0; i < DUK_HEAP_STRCACHE_SIZE; i++) {\n\t\t\tduk_strcache *c = heap->strcache + i;\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"  [%ld] -> h=%p, cidx=%ld, bidx=%ld\",\n\t\t\t                     (long) i, (void *) c->h, (long) c->cidx, (long) c->bidx));\n\t\t}\n#endif\n\t}\n\n\treturn byte_offset;\n\n scan_error:\n\tDUK_ERROR_INTERNAL(thr);\n\treturn 0;\n}\n/*\n *  Heap string table handling, string interning.\n */\n\n/* #include duk_internal.h -> already included */\n\n/* Resize checks not needed if minsize == maxsize, typical for low memory\n * targets.\n */\n#define DUK__STRTAB_RESIZE_CHECK\n#if (DUK_USE_STRTAB_MINSIZE == DUK_USE_STRTAB_MAXSIZE)\n#undef DUK__STRTAB_RESIZE_CHECK\n#endif\n\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n#define DUK__HEAPPTR_ENC16(heap,ptr)    DUK_USE_HEAPPTR_ENC16((heap)->heap_udata, (ptr))\n#define DUK__HEAPPTR_DEC16(heap,val)    DUK_USE_HEAPPTR_DEC16((heap)->heap_udata, (val))\n#define DUK__GET_STRTABLE(heap)         ((heap)->strtable16)\n#else\n#define DUK__HEAPPTR_ENC16(heap,ptr)    (ptr)\n#define DUK__HEAPPTR_DEC16(heap,val)    (val)\n#define DUK__GET_STRTABLE(heap)         ((heap)->strtable)\n#endif\n\n#define DUK__STRTAB_U32_MAX_STRLEN      10               /* 4'294'967'295 */\n\n/*\n *  Debug dump stringtable.\n */\n\n#if defined(DUK_USE_DEBUG)\nDUK_INTERNAL void duk_heap_strtable_dump(duk_heap *heap) {\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\tduk_uint16_t *strtable;\n#else\n\tduk_hstring **strtable;\n#endif\n\tduk_uint32_t i;\n\tduk_hstring *h;\n\tduk_size_t count_total = 0;\n\tduk_size_t count_chain;\n\tduk_size_t count_chain_min = DUK_SIZE_MAX;\n\tduk_size_t count_chain_max = 0;\n\tduk_size_t count_len[8];  /* chain lengths from 0 to 7 */\n\n\tif (heap == NULL) {\n\t\tDUK_D(DUK_DPRINT(\"string table, heap=NULL\"));\n\t\treturn;\n\t}\n\n\tstrtable = DUK__GET_STRTABLE(heap);\n\tif (strtable == NULL) {\n\t\tDUK_D(DUK_DPRINT(\"string table, strtab=NULL\"));\n\t\treturn;\n\t}\n\n\tDUK_MEMZERO((void *) count_len, sizeof(count_len));\n\tfor (i = 0; i < heap->st_size; i++) {\n\t\th = DUK__HEAPPTR_DEC16(heap, strtable[i]);\n\t\tcount_chain = 0;\n\t\twhile (h != NULL) {\n\t\t\tcount_chain++;\n\t\t\th = h->hdr.h_next;\n\t\t}\n\t\tif (count_chain < sizeof(count_len) / sizeof(duk_size_t)) {\n\t\t\tcount_len[count_chain]++;\n\t\t}\n\t\tcount_chain_max = (count_chain > count_chain_max ? count_chain : count_chain_max);\n\t\tcount_chain_min = (count_chain < count_chain_min ? count_chain : count_chain_min);\n\t\tcount_total += count_chain;\n\t}\n\n\tDUK_D(DUK_DPRINT(\"string table, strtab=%p, count=%lu, chain min=%lu max=%lu avg=%lf: \"\n\t                 \"counts: %lu %lu %lu %lu %lu %lu %lu %lu ...\",\n\t                 (void *) heap->strtable, (unsigned long) count_total,\n\t                 (unsigned long) count_chain_min, (unsigned long) count_chain_max,\n\t                 (double) count_total / (double) heap->st_size,\n\t                 (unsigned long) count_len[0], (unsigned long) count_len[1],\n\t                 (unsigned long) count_len[2], (unsigned long) count_len[3],\n\t                 (unsigned long) count_len[4], (unsigned long) count_len[5],\n\t                 (unsigned long) count_len[6], (unsigned long) count_len[7]));\n}\n#endif  /* DUK_USE_DEBUG */\n\n/*\n *  Assertion helper to ensure strtable is populated correctly.\n */\n\n#if defined(DUK_USE_ASSERTIONS)\nDUK_LOCAL void duk__strtable_assert_checks(duk_heap *heap) {\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\tduk_uint16_t *strtable;\n#else\n\tduk_hstring **strtable;\n#endif\n\tduk_uint32_t i;\n\tduk_hstring *h;\n\tduk_size_t count = 0;\n\n\tDUK_ASSERT(heap != NULL);\n\n\tstrtable = DUK__GET_STRTABLE(heap);\n\tif (strtable != NULL) {\n\t\tDUK_ASSERT(heap->st_size != 0);\n\t\tDUK_ASSERT(heap->st_mask == heap->st_size - 1);\n\n\t\tfor (i = 0; i < heap->st_size; i++) {\n\t\t\th = DUK__HEAPPTR_DEC16(heap, strtable[i]);\n\t\t\twhile (h != NULL) {\n\t\t\t\tDUK_ASSERT((DUK_HSTRING_GET_HASH(h) & heap->st_mask) == i);\n\t\t\t\tcount++;\n\t\t\t\th = h->hdr.h_next;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tDUK_ASSERT(heap->st_size == 0);\n\t\tDUK_ASSERT(heap->st_mask == 0);\n\t}\n\n#if defined(DUK__STRTAB_RESIZE_CHECK)\n\tDUK_ASSERT(count == (duk_size_t) heap->st_count);\n#endif\n}\n#endif  /* DUK_USE_ASSERTIONS */\n\n/*\n *  Allocate and initialize a duk_hstring.\n *\n *  Returns a NULL if allocation or initialization fails for some reason.\n *\n *  The string won't be inserted into the string table and isn't tracked in\n *  any way (link pointers will be NULL).  The caller must place the string\n *  into the string table without any risk of a longjmp, otherwise the string\n *  is leaked.\n */\n\nDUK_LOCAL duk_hstring *duk__strtable_alloc_hstring(duk_heap *heap,\n                                                   const duk_uint8_t *str,\n                                                   duk_uint32_t blen,\n                                                   duk_uint32_t strhash,\n                                                   const duk_uint8_t *extdata) {\n\tduk_hstring *res;\n\tconst duk_uint8_t *data;\n#if !defined(DUK_USE_HSTRING_ARRIDX)\n\tduk_uarridx_t dummy;\n#endif\n\n\tDUK_ASSERT(heap != NULL);\n\tDUK_UNREF(extdata);\n\n#if defined(DUK_USE_STRLEN16)\n\t/* If blen <= 0xffffUL, clen is also guaranteed to be <= 0xffffUL. */\n\tif (blen > 0xffffUL) {\n\t\tDUK_D(DUK_DPRINT(\"16-bit string blen/clen active and blen over 16 bits, reject intern\"));\n\t\tgoto alloc_error;\n\t}\n#endif\n\n\t/* XXX: Memzeroing the allocated structure is not really necessary\n\t * because we could just initialize all fields explicitly (almost\n\t * all fields are initialized explicitly anyway).\n\t */\n#if defined(DUK_USE_HSTRING_EXTDATA) && defined(DUK_USE_EXTSTR_INTERN_CHECK)\n\tif (extdata) {\n\t\tres = (duk_hstring *) DUK_ALLOC(heap, sizeof(duk_hstring_external));\n\t\tif (DUK_UNLIKELY(res == NULL)) {\n\t\t\tgoto alloc_error;\n\t\t}\n\t\tDUK_MEMZERO(res, sizeof(duk_hstring_external));\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n\t\tDUK_HEAPHDR_STRING_INIT_NULLS(&res->hdr);\n#endif\n\t\tDUK_HEAPHDR_SET_TYPE_AND_FLAGS(&res->hdr, DUK_HTYPE_STRING, DUK_HSTRING_FLAG_EXTDATA);\n\n\t\tDUK_ASSERT(extdata[blen] == 0);  /* Application responsibility. */\n\t\tdata = extdata;\n\t\t((duk_hstring_external *) res)->extdata = extdata;\n\t} else\n#endif  /* DUK_USE_HSTRING_EXTDATA && DUK_USE_EXTSTR_INTERN_CHECK */\n\t{\n\t\tduk_uint8_t *data_tmp;\n\n\t\t/* NUL terminate for convenient C access */\n\t\tDUK_ASSERT(sizeof(duk_hstring) + blen + 1 > blen);  /* No wrap, limits ensure. */\n\t\tres = (duk_hstring *) DUK_ALLOC(heap, sizeof(duk_hstring) + blen + 1);\n\t\tif (DUK_UNLIKELY(res == NULL)) {\n\t\t\tgoto alloc_error;\n\t\t}\n\t\tDUK_MEMZERO(res, sizeof(duk_hstring));\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n\t\tDUK_HEAPHDR_STRING_INIT_NULLS(&res->hdr);\n#endif\n\t\tDUK_HEAPHDR_SET_TYPE_AND_FLAGS(&res->hdr, DUK_HTYPE_STRING, 0);\n\n\t\tdata_tmp = (duk_uint8_t *) (res + 1);\n\t\tDUK_MEMCPY(data_tmp, str, blen);\n\t\tdata_tmp[blen] = (duk_uint8_t) 0;\n\t\tdata = (const duk_uint8_t *) data_tmp;\n\t}\n\n\tDUK_HSTRING_SET_BYTELEN(res, blen);\n\tDUK_HSTRING_SET_HASH(res, strhash);\n\n\tDUK_ASSERT(!DUK_HSTRING_HAS_ARRIDX(res));\n#if defined(DUK_USE_HSTRING_ARRIDX)\n\tres->arridx = duk_js_to_arrayindex_string(data, blen);\n\tif (res->arridx != DUK_HSTRING_NO_ARRAY_INDEX) {\n#else\n\tdummy = duk_js_to_arrayindex_string(data, blen);\n\tif (dummy != DUK_HSTRING_NO_ARRAY_INDEX) {\n#endif\n\t\t/* Array index strings cannot be symbol strings,\n\t\t * and they're always pure ASCII so blen == clen.\n\t\t */\n\t\tDUK_HSTRING_SET_ARRIDX(res);\n\t\tDUK_HSTRING_SET_ASCII(res);\n\t\tDUK_ASSERT(duk_unicode_unvalidated_utf8_length(data, (duk_size_t) blen) == blen);\n\t} else {\n\t\t/* Because 'data' is NUL-terminated, we don't need a\n\t\t * blen > 0 check here.  For NUL (0x00) the symbol\n\t\t * checks will be false.\n\t\t */\n\t\tif (DUK_UNLIKELY(data[0] >= 0x80U)) {\n\t\t\tif (data[0] == 0xffU) {\n\t\t\t\tDUK_HSTRING_SET_SYMBOL(res);\n\t\t\t\tDUK_HSTRING_SET_HIDDEN(res);\n\t\t\t} else if (data[0] <= 0xbf) {\n\t\t\t\t/* Check equivalent to: (data[0] & 0xc0U) == 0x80U. */\n\t\t\t\tDUK_HSTRING_SET_SYMBOL(res);\n\t\t\t}\n\t\t}\n\n\t\t/* Using an explicit 'ASCII' flag has larger footprint (one call site\n\t\t * only) but is quite useful for the case when there's no explicit\n\t\t * 'clen' in duk_hstring.\n\t\t *\n\t\t * The flag is set lazily for RAM strings.\n\t\t */\n\t\tDUK_ASSERT(!DUK_HSTRING_HAS_ASCII(res));\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"interned string, hash=0x%08lx, blen=%ld, has_arridx=%ld, has_extdata=%ld\",\n\t                     (unsigned long) DUK_HSTRING_GET_HASH(res),\n\t                     (long) DUK_HSTRING_GET_BYTELEN(res),\n\t                     (long) (DUK_HSTRING_HAS_ARRIDX(res) ? 1 : 0),\n\t                     (long) (DUK_HSTRING_HAS_EXTDATA(res) ? 1 : 0)));\n\n\tDUK_ASSERT(res != NULL);\n\treturn res;\n\n alloc_error:\n\treturn NULL;\n}\n\n/*\n *  Grow strtable allocation in-place.\n */\n\n#if defined(DUK__STRTAB_RESIZE_CHECK)\nDUK_LOCAL void duk__strtable_grow_inplace(duk_heap *heap) {\n\tduk_uint32_t new_st_size;\n\tduk_uint32_t old_st_size;\n\tduk_uint32_t i;\n\tduk_hstring *h;\n\tduk_hstring *next;\n\tduk_hstring *prev;\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\tduk_uint16_t *new_ptr;\n\tduk_uint16_t *new_ptr_high;\n#else\n\tduk_hstring **new_ptr;\n\tduk_hstring **new_ptr_high;\n#endif\n\n\tDUK_DD(DUK_DDPRINT(\"grow in-place: %lu -> %lu\", (unsigned long) heap->st_size, (unsigned long) heap->st_size * 2));\n\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT(heap->st_resizing == 1);\n\tDUK_ASSERT(heap->st_size >= 2);\n\tDUK_ASSERT((heap->st_size & (heap->st_size - 1)) == 0);  /* 2^N */\n\tDUK_ASSERT(DUK__GET_STRTABLE(heap) != NULL);\n\n\tnew_st_size = heap->st_size << 1U;\n\tDUK_ASSERT(new_st_size > heap->st_size);  /* No overflow. */\n\n\t/* Reallocate the strtable first and then work in-place to rehash\n\t * strings.  We don't need an indirect allocation here: even if GC\n\t * is triggered to satisfy the allocation, recursive strtable resize\n\t * is prevented by flags.  This is also why we don't need to use\n\t * DUK_REALLOC_INDIRECT().\n\t */\n\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\tnew_ptr = (duk_uint16_t *) DUK_REALLOC(heap, heap->strtable16, sizeof(duk_uint16_t) * new_st_size);\n#else\n\tnew_ptr = (duk_hstring **) DUK_REALLOC(heap, heap->strtable, sizeof(duk_hstring *) * new_st_size);\n#endif\n\tif (DUK_UNLIKELY(new_ptr == NULL)) {\n\t\t/* If realloc fails we can continue normally: the string table\n\t\t * won't \"fill up\" although chains will gradually get longer.\n\t\t * When string insertions continue, we'll quite soon try again\n\t\t * with no special handling.\n\t\t */\n\t\tDUK_D(DUK_DPRINT(\"string table grow failed, ignoring\"));\n\t\treturn;\n\t}\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\theap->strtable16 = new_ptr;\n#else\n\theap->strtable = new_ptr;\n#endif\n\n\t/* Rehash a single bucket into two separate ones.  When we grow\n\t * by x2 the highest 'new' bit determines whether a string remains\n\t * in its old position (bit is 0) or goes to a new one (bit is 1).\n\t */\n\n\told_st_size = heap->st_size;\n\tnew_ptr_high = new_ptr + old_st_size;\n\tfor (i = 0; i < old_st_size; i++) {\n\t\tduk_hstring *new_root;\n\t\tduk_hstring *new_root_high;\n\n\t\th = DUK__HEAPPTR_DEC16(heap, new_ptr[i]);\n\t\tnew_root = h;\n\t\tnew_root_high = NULL;\n\n\t\tprev = NULL;\n\t\twhile (h != NULL) {\n\t\t\tduk_uint32_t mask;\n\n\t\t\tDUK_ASSERT((DUK_HSTRING_GET_HASH(h) & heap->st_mask) == i);\n\t\t\tnext = h->hdr.h_next;\n\n\t\t\t/* Example: if previous size was 256, previous mask is 0xFF\n\t\t\t * and size is 0x100 which corresponds to the new bit that\n\t\t\t * comes into play.\n\t\t\t */\n\t\t\tDUK_ASSERT(heap->st_mask == old_st_size - 1);\n\t\t\tmask = old_st_size;\n\t\t\tif (DUK_HSTRING_GET_HASH(h) & mask) {\n\t\t\t\tif (prev != NULL) {\n\t\t\t\t\tprev->hdr.h_next = h->hdr.h_next;\n\t\t\t\t} else {\n\t\t\t\t\tDUK_ASSERT(h == new_root);\n\t\t\t\t\tnew_root = h->hdr.h_next;\n\t\t\t\t}\n\n\t\t\t\th->hdr.h_next = new_root_high;\n\t\t\t\tnew_root_high = h;\n\t\t\t} else {\n\t\t\t\tprev = h;\n\t\t\t}\n\t\t\th = next;\n\t\t}\n\n\t\tnew_ptr[i] = DUK__HEAPPTR_ENC16(heap, new_root);\n\t\tnew_ptr_high[i] = DUK__HEAPPTR_ENC16(heap, new_root_high);\n\t}\n\n\theap->st_size = new_st_size;\n\theap->st_mask = new_st_size - 1;\n\n#if defined(DUK_USE_ASSERTIONS)\n\tduk__strtable_assert_checks(heap);\n#endif\n}\n#endif  /* DUK__STRTAB_RESIZE_CHECK */\n\n/*\n *  Shrink strtable allocation in-place.\n */\n\n#if defined(DUK__STRTAB_RESIZE_CHECK)\nDUK_LOCAL void duk__strtable_shrink_inplace(duk_heap *heap) {\n\tduk_uint32_t new_st_size;\n\tduk_uint32_t i;\n\tduk_hstring *h;\n\tduk_hstring *other;\n\tduk_hstring *root;\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\tduk_uint16_t *old_ptr;\n\tduk_uint16_t *old_ptr_high;\n\tduk_uint16_t *new_ptr;\n#else\n\tduk_hstring **old_ptr;\n\tduk_hstring **old_ptr_high;\n\tduk_hstring **new_ptr;\n#endif\n\n\tDUK_DD(DUK_DDPRINT(\"shrink in-place: %lu -> %lu\", (unsigned long) heap->st_size, (unsigned long) heap->st_size / 2));\n\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT(heap->st_resizing == 1);\n\tDUK_ASSERT(heap->st_size >= 2);\n\tDUK_ASSERT((heap->st_size & (heap->st_size - 1)) == 0);  /* 2^N */\n\tDUK_ASSERT(DUK__GET_STRTABLE(heap) != NULL);\n\n\tnew_st_size = heap->st_size >> 1U;\n\n\t/* Combine two buckets into a single one.  When we shrink, one hash\n\t * bit (highest) disappears.\n\t */\n\told_ptr = DUK__GET_STRTABLE(heap);\n\told_ptr_high = old_ptr + new_st_size;\n\tfor (i = 0; i < new_st_size; i++) {\n\t\th = DUK__HEAPPTR_DEC16(heap, old_ptr[i]);\n\t\tother = DUK__HEAPPTR_DEC16(heap, old_ptr_high[i]);\n\n\t\tif (h == NULL) {\n\t\t\t/* First chain is empty, so use second one as is. */\n\t\t\troot = other;\n\t\t} else {\n\t\t\t/* Find end of first chain, and link in the second. */\n\t\t\troot = h;\n\t\t\twhile (h->hdr.h_next != NULL) {\n\t\t\t\th = h->hdr.h_next;\n\t\t\t}\n\t\t\th->hdr.h_next = other;\n\t\t}\n\n\t\told_ptr[i] = DUK__HEAPPTR_ENC16(heap, root);\n\t}\n\n\theap->st_size = new_st_size;\n\theap->st_mask = new_st_size - 1;\n\n\t/* The strtable is now consistent and we can realloc safely.  Even\n\t * if side effects cause string interning or removal the strtable\n\t * updates are safe.  Recursive resize has been prevented by caller.\n\t * This is also why we don't need to use DUK_REALLOC_INDIRECT().\n\t *\n\t * We assume a realloc() to a smaller size is guaranteed to succeed.\n\t * It would be relatively straightforward to handle the error by\n\t * essentially performing a \"grow\" step to recover.\n\t */\n\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\tnew_ptr = (duk_uint16_t *) DUK_REALLOC(heap, heap->strtable16, sizeof(duk_uint16_t) * new_st_size);\n\tDUK_ASSERT(new_ptr != NULL);\n\theap->strtable16 = new_ptr;\n#else\n\tnew_ptr = (duk_hstring **) DUK_REALLOC(heap, heap->strtable, sizeof(duk_hstring *) * new_st_size);\n\tDUK_ASSERT(new_ptr != NULL);\n\theap->strtable = new_ptr;\n#endif\n\n#if defined(DUK_USE_ASSERTIONS)\n\tduk__strtable_assert_checks(heap);\n#endif\n}\n#endif  /* DUK__STRTAB_RESIZE_CHECK */\n\n/*\n *  Grow/shrink check.\n */\n\n#if defined(DUK__STRTAB_RESIZE_CHECK)\nDUK_LOCAL DUK_COLD DUK_NOINLINE void duk__strtable_resize_check(duk_heap *heap) {\n\tduk_uint32_t load_factor;  /* fixed point */\n\n\tDUK_ASSERT(heap != NULL);\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\tDUK_ASSERT(heap->strtable16 != NULL);\n#else\n\tDUK_ASSERT(heap->strtable != NULL);\n#endif\n\n\t/* Prevent recursive resizing. */\n\tif (DUK_UNLIKELY(heap->st_resizing)) {\n\t\tDUK_D(DUK_DPRINT(\"prevent recursive strtable resize\"));\n\t\treturn;\n\t}\n\n\theap->st_resizing = 1;\n\n\tDUK_ASSERT(heap->st_size >= 16U);\n\tDUK_ASSERT((heap->st_size >> 4U) >= 1);\n\tload_factor = heap->st_count / (heap->st_size >> 4U);\n\n\tDUK_DD(DUK_DDPRINT(\"resize check string table: size=%lu, count=%lu, load_factor=%lu (fixed point .4; float %lf)\",\n\t                   (unsigned long) heap->st_size, (unsigned long) heap->st_count,\n\t                   (unsigned long) load_factor,\n\t                   (double) heap->st_count / (double) heap->st_size));\n\n\tif (load_factor >= DUK_USE_STRTAB_GROW_LIMIT) {\n\t\tif (heap->st_size >= DUK_USE_STRTAB_MAXSIZE) {\n\t\t\tDUK_DD(DUK_DDPRINT(\"want to grow strtable (based on load factor) but already maximum size\"));\n\t\t} else {\n\t\t\tDUK_D(DUK_DPRINT(\"grow string table: %lu -> %lu\", (unsigned long) heap->st_size, (unsigned long) heap->st_size * 2));\n#if defined(DUK_USE_DEBUG)\n\t\t\tduk_heap_strtable_dump(heap);\n#endif\n\t\t\tduk__strtable_grow_inplace(heap);\n\t\t}\n\t} else if (load_factor <= DUK_USE_STRTAB_SHRINK_LIMIT) {\n\t\tif (heap->st_size <= DUK_USE_STRTAB_MINSIZE) {\n\t\t\tDUK_DD(DUK_DDPRINT(\"want to shrink strtable (based on load factor) but already minimum size\"));\n\t\t} else {\n\t\t\tDUK_D(DUK_DPRINT(\"shrink string table: %lu -> %lu\", (unsigned long) heap->st_size, (unsigned long) heap->st_size / 2));\n#if defined(DUK_USE_DEBUG)\n\t\t\tduk_heap_strtable_dump(heap);\n#endif\n\t\t\tduk__strtable_shrink_inplace(heap);\n\t\t}\n\t} else {\n\t\tDUK_DD(DUK_DDPRINT(\"no need for strtable resize\"));\n\t}\n\n\theap->st_resizing = 0;\n}\n#endif  /* DUK__STRTAB_RESIZE_CHECK */\n\n/*\n *  Torture grow/shrink: unconditionally grow and shrink back.\n */\n\n#if defined(DUK_USE_STRTAB_TORTURE) && defined(DUK__STRTAB_RESIZE_CHECK)\nDUK_LOCAL void duk__strtable_resize_torture(duk_heap *heap) {\n\tduk_uint32_t old_st_size;\n\n\tDUK_ASSERT(heap != NULL);\n\n\told_st_size = heap->st_size;\n\tif (old_st_size >= DUK_USE_STRTAB_MAXSIZE) {\n\t\treturn;\n\t}\n\n\theap->st_resizing = 1;\n\tduk__strtable_grow_inplace(heap);\n\tif (heap->st_size > old_st_size) {\n\t\tduk__strtable_shrink_inplace(heap);\n\t}\n\theap->st_resizing = 0;\n}\n#endif  /* DUK_USE_STRTAB_TORTURE && DUK__STRTAB_RESIZE_CHECK */\n\n/*\n *  Raw intern; string already checked not to be present.\n */\n\nDUK_LOCAL duk_hstring *duk__strtable_do_intern(duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen, duk_uint32_t strhash) {\n\tduk_hstring *res;\n\tconst duk_uint8_t *extdata;\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\tduk_uint16_t *slot;\n#else\n\tduk_hstring **slot;\n#endif\n\n\tDUK_DDD(DUK_DDDPRINT(\"do_intern: heap=%p, str=%p, blen=%lu, strhash=%lx, st_size=%lu, st_count=%lu, load=%lf\",\n\t                     (void *) heap, (const void *) str, (unsigned long) blen, (unsigned long) strhash,\n\t                     (unsigned long) heap->st_size, (unsigned long) heap->st_count,\n\t                     (double) heap->st_count / (double) heap->st_size));\n\n\tDUK_ASSERT(heap != NULL);\n\n\t/* Prevent any side effects on the string table and the caller provided\n\t * str/blen arguments while interning is in progress.  For example, if\n\t * the caller provided str/blen from a dynamic buffer, a finalizer\n\t * might resize or modify that dynamic buffer, invalidating the call\n\t * arguments.\n\t *\n\t * While finalizers must be prevented, mark-and-sweep itself is fine.\n\t * Recursive string table resize is prevented explicitly here.\n\t */\n\n\theap->pf_prevent_count++;\n\tDUK_ASSERT(heap->pf_prevent_count != 0);  /* Wrap. */\n\n#if defined(DUK_USE_STRTAB_TORTURE) && defined(DUK__STRTAB_RESIZE_CHECK)\n\tduk__strtable_resize_torture(heap);\n#endif\n\n\t/* String table grow/shrink check.  Because of chaining (and no\n\t * accumulation issues as with hash probe chains and DELETED\n\t * markers) there's never a mandatory need to resize right now.\n\t * Check for the resize only periodically, based on st_count\n\t * bit pattern.  Because string table removal doesn't do a shrink\n\t * check, we do that also here.\n\t *\n\t * Do the resize and possible grow/shrink before the new duk_hstring\n\t * has been allocated.  Otherwise we may trigger a GC when the result\n\t * duk_hstring is not yet strongly referenced.\n\t */\n\n#if defined(DUK__STRTAB_RESIZE_CHECK)\n\tif (DUK_UNLIKELY((heap->st_count & DUK_USE_STRTAB_RESIZE_CHECK_MASK) == 0)) {\n\t\tduk__strtable_resize_check(heap);\n\t}\n#endif\n\n\t/* External string check (low memory optimization). */\n\n#if defined(DUK_USE_HSTRING_EXTDATA) && defined(DUK_USE_EXTSTR_INTERN_CHECK)\n\textdata = (const duk_uint8_t *) DUK_USE_EXTSTR_INTERN_CHECK(heap->heap_udata, (void *) DUK_LOSE_CONST(str), (duk_size_t) blen);\n#else\n\textdata = (const duk_uint8_t *) NULL;\n#endif\n\n\t/* Allocate and initialize string, not yet linked.  This may cause a\n\t * GC which may cause other strings to be interned and inserted into\n\t * the string table before we insert our string.  Finalizer execution\n\t * is disabled intentionally to avoid a finalizer from e.g. resizing\n\t * a buffer used as a data area for 'str'.\n\t */\n\n\tres = duk__strtable_alloc_hstring(heap, str, blen, strhash, extdata);\n\n\t/* Allow side effects again: GC must be avoided until duk_hstring\n\t * result (if successful) has been INCREF'd.\n\t */\n\tDUK_ASSERT(heap->pf_prevent_count > 0);\n\theap->pf_prevent_count--;\n\n\t/* Alloc error handling. */\n\n\tif (DUK_UNLIKELY(res == NULL)) {\n#if defined(DUK_USE_HSTRING_EXTDATA) && defined(DUK_USE_EXTSTR_INTERN_CHECK)\n\t\tif (extdata != NULL) {\n\t\t\tDUK_USE_EXTSTR_FREE(heap->heap_udata, (const void *) extdata);\n\t\t}\n#endif\n\t\treturn NULL;\n\t}\n\n\t/* Insert into string table. */\n\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\tslot = heap->strtable16 + (strhash & heap->st_mask);\n#else\n\tslot = heap->strtable + (strhash & heap->st_mask);\n#endif\n\tDUK_ASSERT(res->hdr.h_next == NULL);  /* This is the case now, but unnecessary zeroing/NULLing. */\n\tres->hdr.h_next = DUK__HEAPPTR_DEC16(heap, *slot);\n\t*slot = DUK__HEAPPTR_ENC16(heap, res);\n\n\t/* Update string count only for successful inserts. */\n\n#if defined(DUK__STRTAB_RESIZE_CHECK)\n\theap->st_count++;\n#endif\n\n\t/* The duk_hstring is in the string table but is not yet strongly\n\t * reachable.  Calling code MUST NOT make any allocations or other\n\t * side effects before the duk_hstring has been INCREF'd and made\n\t * reachable.\n\t */\n\n\treturn res;\n}\n\n/*\n *  Intern a string from str/blen, returning either an existing duk_hstring\n *  or adding a new one into the string table.  The input string does -not-\n *  need to be NUL terminated.\n *\n *  The input 'str' argument may point to a Duktape managed data area such as\n *  the data area of a dynamic buffer.  It's crucial to avoid any side effects\n *  that might affect the data area (e.g. resize the dynamic buffer, or write\n *  to the buffer) before the string is fully interned.\n */\n\n#if defined(DUK_USE_ROM_STRINGS)\nDUK_LOCAL duk_hstring *duk__strtab_romstring_lookup(duk_heap *heap, const duk_uint8_t *str, duk_size_t blen, duk_uint32_t strhash) {\n\tduk_size_t lookup_hash;\n\tduk_hstring *curr;\n\n\tDUK_ASSERT(heap != NULL);\n\tDUK_UNREF(heap);\n\n\tlookup_hash = (blen << 4);\n\tif (blen > 0) {\n\t\tlookup_hash += str[0];\n\t}\n\tlookup_hash &= 0xff;\n\n\tcurr = DUK_LOSE_CONST(duk_rom_strings_lookup[lookup_hash]);\n\twhile (curr != NULL) {\n\t\tif (strhash == DUK_HSTRING_GET_HASH(curr) &&\n\t\t    blen == DUK_HSTRING_GET_BYTELEN(curr) &&\n\t\t    DUK_MEMCMP((const void *) str, (const void *) DUK_HSTRING_GET_DATA(curr), blen) == 0) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"intern check: rom string: %!O, computed hash 0x%08lx, rom hash 0x%08lx\",\n\t\t\t                     curr, (unsigned long) strhash, (unsigned long) DUK_HSTRING_GET_HASH(curr)));\n\t\t\treturn curr;\n\t\t}\n\t\tcurr = curr->hdr.h_next;\n\t}\n\n\treturn NULL;\n}\n#endif  /* DUK_USE_ROM_STRINGS */\n\nDUK_INTERNAL duk_hstring *duk_heap_strtable_intern(duk_heap *heap, const duk_uint8_t *str, duk_uint32_t blen) {\n\tduk_uint32_t strhash;\n\tduk_hstring *h;\n\n\tDUK_DDD(DUK_DDDPRINT(\"intern check: heap=%p, str=%p, blen=%lu\", (void *) heap, (const void *) str, (unsigned long) blen));\n\n\t/* Preliminaries. */\n\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT(blen == 0 || str != NULL);\n\tDUK_ASSERT(blen <= DUK_HSTRING_MAX_BYTELEN);  /* Caller is responsible for ensuring this. */\n\tstrhash = duk_heap_hashstring(heap, str, (duk_size_t) blen);\n\n\t/* String table lookup. */\n\n\tDUK_ASSERT(DUK__GET_STRTABLE(heap) != NULL);\n\tDUK_ASSERT(heap->st_size > 0);\n\tDUK_ASSERT(heap->st_size == heap->st_mask + 1);\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\th = DUK__HEAPPTR_DEC16(heap, heap->strtable16[strhash & heap->st_mask]);\n#else\n\th = heap->strtable[strhash & heap->st_mask];\n#endif\n\twhile (h != NULL) {\n\t\tif (DUK_HSTRING_GET_HASH(h) == strhash &&\n\t\t    DUK_HSTRING_GET_BYTELEN(h) == blen &&\n\t\t    DUK_MEMCMP((const void *) str, (const void *) DUK_HSTRING_GET_DATA(h), (size_t) blen) == 0) {\n\t\t\t/* Found existing entry. */\n\t\t\treturn h;\n\t\t}\n\t\th = h->hdr.h_next;\n\t}\n\n\t/* ROM table lookup.  Because this lookup is slower, do it only after\n\t * RAM lookup.  This works because no ROM string is ever interned into\n\t * the RAM string table.\n\t */\n\n#if defined(DUK_USE_ROM_STRINGS)\n\th = duk__strtab_romstring_lookup(heap, str, blen, strhash);\n\tif (h != NULL) {\n\t\treturn h;\n\t}\n#endif\n\n\t/* Not found in string table; insert. */\n\n\th = duk__strtable_do_intern(heap, str, blen, strhash);\n\treturn h;  /* may be NULL */\n}\n\n/*\n *  Intern a string from u32.\n */\n\n/* XXX: Could arrange some special handling because we know that the result\n * will have an arridx flag and an ASCII flag, won't need a clen check, etc.\n */\n\nDUK_INTERNAL duk_hstring *duk_heap_strtable_intern_u32(duk_heap *heap, duk_uint32_t val) {\n\tchar buf[DUK__STRTAB_U32_MAX_STRLEN];\n\tchar *p;\n\n\tDUK_ASSERT(heap != NULL);\n\n\t/* This is smaller and faster than a %lu sprintf. */\n\tp = buf + sizeof(buf);\n\tdo {\n\t\tp--;\n\t\t*p = duk_lc_digits[val % 10];\n\t\tval = val / 10;\n\t} while (val != 0);  /* For val == 0, emit exactly one '0'. */\n\tDUK_ASSERT(p >= buf);\n\n\treturn duk_heap_strtable_intern(heap, (const duk_uint8_t *) p, (duk_uint32_t) ((buf + sizeof(buf)) - p));\n}\n\n/*\n *  Checked convenience variants.\n *\n *  XXX: Because the main use case is for the checked variants, make them the\n *  main functionality and provide a safe variant separately (it is only needed\n *  during heap init).  The problem with that is that longjmp state and error\n *  creation must already be possible to throw.\n */\n\nDUK_INTERNAL duk_hstring *duk_heap_strtable_intern_checked(duk_hthread *thr, const duk_uint8_t *str, duk_uint32_t blen) {\n\tduk_hstring *res;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\tDUK_ASSERT(blen == 0 || str != NULL);\n\n\tres = duk_heap_strtable_intern(thr->heap, str, blen);\n\tif (DUK_UNLIKELY(res == NULL)) {\n\t\tDUK_ERROR_ALLOC_FAILED(thr);\n\t}\n\treturn res;\n}\n\nDUK_INTERNAL duk_hstring *duk_heap_strtable_intern_u32_checked(duk_hthread *thr, duk_uint32_t val) {\n\tduk_hstring *res;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\n\tres = duk_heap_strtable_intern_u32(thr->heap, val);\n\tif (DUK_UNLIKELY(res == NULL)) {\n\t\tDUK_ERROR_ALLOC_FAILED(thr);\n\t}\n\treturn res;\n}\n\n/*\n *  Remove (unlink) a string from the string table.\n *\n *  Just unlinks the duk_hstring, leaving link pointers as garbage.\n *  Caller must free the string itself.\n */\n\n#if defined(DUK_USE_REFERENCE_COUNTING)\n/* Unlink without a 'prev' pointer. */\nDUK_INTERNAL void duk_heap_strtable_unlink(duk_heap *heap, duk_hstring *h) {\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\tduk_uint16_t *slot;\n#else\n\tduk_hstring **slot;\n#endif\n\tduk_hstring *other;\n\tduk_hstring *prev;\n\n\tDUK_DDD(DUK_DDDPRINT(\"remove: heap=%p, h=%p, blen=%lu, strhash=%lx\",\n\t                     (void *) heap, (void *) h,\n\t                     (unsigned long) (h != NULL ? DUK_HSTRING_GET_BYTELEN(h) : 0),\n\t                     (unsigned long) (h != NULL ? DUK_HSTRING_GET_HASH(h) : 0)));\n\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT(h != NULL);\n\n#if defined(DUK__STRTAB_RESIZE_CHECK)\n\tDUK_ASSERT(heap->st_count > 0);\n\theap->st_count--;\n#endif\n\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\tslot = heap->strtable16 + (DUK_HSTRING_GET_HASH(h) & heap->st_mask);\n#else\n\tslot = heap->strtable + (DUK_HSTRING_GET_HASH(h) & heap->st_mask);\n#endif\n\tother = DUK__HEAPPTR_DEC16(heap, *slot);\n\tDUK_ASSERT(other != NULL);  /* At least argument string is in the chain. */\n\n\tprev = NULL;\n\twhile (other != h) {\n\t\tprev = other;\n\t\tother = other->hdr.h_next;\n\t\tDUK_ASSERT(other != NULL);  /* We'll eventually find 'h'. */\n\t}\n\tif (prev != NULL) {\n\t\t/* Middle of list. */\n\t\tprev->hdr.h_next = h->hdr.h_next;\n\t} else {\n\t\t/* Head of list. */\n\t\t*slot = DUK__HEAPPTR_ENC16(heap, h->hdr.h_next);\n\t}\n\n\t/* There's no resize check on a string free.  The next string\n\t * intern will do one.\n\t */\n}\n#endif  /* DUK_USE_REFERENCE_COUNTING */\n\n/* Unlink with a 'prev' pointer. */\nDUK_INTERNAL void duk_heap_strtable_unlink_prev(duk_heap *heap, duk_hstring *h, duk_hstring *prev) {\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\tduk_uint16_t *slot;\n#else\n\tduk_hstring **slot;\n#endif\n\n\tDUK_DDD(DUK_DDDPRINT(\"remove: heap=%p, prev=%p, h=%p, blen=%lu, strhash=%lx\",\n\t                     (void *) heap, (void *) prev, (void *) h,\n\t                     (unsigned long) (h != NULL ? DUK_HSTRING_GET_BYTELEN(h) : 0),\n\t                     (unsigned long) (h != NULL ? DUK_HSTRING_GET_HASH(h) : 0)));\n\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT(h != NULL);\n\tDUK_ASSERT(prev == NULL || prev->hdr.h_next == h);\n\n#if defined(DUK__STRTAB_RESIZE_CHECK)\n\tDUK_ASSERT(heap->st_count > 0);\n\theap->st_count--;\n#endif\n\n\tif (prev != NULL) {\n\t\t/* Middle of list. */\n\t\tprev->hdr.h_next = h->hdr.h_next;\n\t} else {\n\t\t/* Head of list. */\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\t\tslot = heap->strtable16 + (DUK_HSTRING_GET_HASH(h) & heap->st_mask);\n#else\n\t\tslot = heap->strtable + (DUK_HSTRING_GET_HASH(h) & heap->st_mask);\n#endif\n\t\tDUK_ASSERT(DUK__HEAPPTR_DEC16(heap, *slot) == h);\n\t\t*slot = DUK__HEAPPTR_ENC16(heap, h->hdr.h_next);\n\t}\n}\n\n/*\n *  Force string table resize check in mark-and-sweep.\n */\n\nDUK_INTERNAL void duk_heap_strtable_force_resize(duk_heap *heap) {\n\t/* Does only one grow/shrink step if needed.  The heap->st_resizing\n\t * flag protects against recursive resizing.\n\t */\n\n\tDUK_ASSERT(heap != NULL);\n\tDUK_UNREF(heap);\n\n#if defined(DUK__STRTAB_RESIZE_CHECK)\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\tif (heap->strtable16 != NULL) {\n#else\n\tif (heap->strtable != NULL) {\n#endif\n\t\tduk__strtable_resize_check(heap);\n\t}\n#endif\n}\n\n/*\n *  Free strings in the string table and the string table itself.\n */\n\nDUK_INTERNAL void duk_heap_strtable_free(duk_heap *heap) {\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\tduk_uint16_t *strtable;\n\tduk_uint16_t *st;\n#else\n\tduk_hstring **strtable;\n\tduk_hstring **st;\n#endif\n\tduk_hstring *h;\n\n\tDUK_ASSERT(heap != NULL);\n\n#if defined(DUK_USE_ASSERTIONS)\n\tduk__strtable_assert_checks(heap);\n#endif\n\n\t/* Strtable can be NULL if heap init fails.  However, in that case\n\t * heap->st_size is 0, so strtable == strtable_end and we skip the\n\t * loop without a special check.\n\t */\n\tstrtable = DUK__GET_STRTABLE(heap);\n\tst = strtable + heap->st_size;\n\tDUK_ASSERT(strtable != NULL || heap->st_size == 0);\n\n\twhile (strtable != st) {\n\t\t--st;\n\t\th = DUK__HEAPPTR_DEC16(heap, *st);\n\t\twhile (h) {\n\t\t\tduk_hstring *h_next;\n\t\t\th_next = h->hdr.h_next;\n\n\t\t\t/* Strings may have inner refs (extdata) in some cases. */\n\t\t\tduk_free_hstring(heap, h);\n\n\t\t\th = h_next;\n\t\t}\n\t}\n\n\tDUK_FREE(heap, strtable);\n}\n\n/* automatic undefs */\n#undef DUK__GET_STRTABLE\n#undef DUK__HEAPPTR_DEC16\n#undef DUK__HEAPPTR_ENC16\n#undef DUK__STRTAB_U32_MAX_STRLEN\n/*\n *  Hobject allocation.\n *\n *  Provides primitive allocation functions for all object types (plain object,\n *  compiled function, native function, thread).  The object return is not yet\n *  in \"heap allocated\" list and has a refcount of zero, so caller must careful.\n */\n\n/* XXX: In most cases there's no need for plain allocation without pushing\n * to the value stack.  Maybe rework contract?\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Helpers.\n */\n\nDUK_LOCAL void duk__init_object_parts(duk_heap *heap, duk_uint_t hobject_flags, duk_hobject *obj) {\n\tDUK_ASSERT(obj != NULL);\n\t/* Zeroed by caller. */\n\n\tobj->hdr.h_flags = hobject_flags | DUK_HTYPE_OBJECT;\n\tDUK_ASSERT(DUK_HEAPHDR_GET_TYPE(&obj->hdr) == DUK_HTYPE_OBJECT);  /* Assume zero shift. */\n\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n\tDUK_HOBJECT_SET_PROTOTYPE(heap, obj, NULL);\n\tDUK_HOBJECT_SET_PROPS(heap, obj, NULL);\n#endif\n#if defined(DUK_USE_HEAPPTR16)\n\t/* Zero encoded pointer is required to match NULL. */\n\tDUK_HEAPHDR_SET_NEXT(heap, &obj->hdr, NULL);\n#if defined(DUK_USE_DOUBLE_LINKED_HEAP)\n\tDUK_HEAPHDR_SET_PREV(heap, &obj->hdr, NULL);\n#endif\n#endif\n\tDUK_ASSERT_HEAPHDR_LINKS(heap, &obj->hdr);\n\tDUK_HEAP_INSERT_INTO_HEAP_ALLOCATED(heap, &obj->hdr);\n\n\t/* obj->props is intentionally left as NULL, and duk_hobject_props.c must deal\n\t * with this properly.  This is intentional: empty objects consume a minimum\n\t * amount of memory.  Further, an initial allocation might fail and cause\n\t * 'obj' to \"leak\" (require a mark-and-sweep) since it is not reachable yet.\n\t */\n}\n\nDUK_LOCAL void *duk__hobject_alloc_init(duk_hthread *thr, duk_uint_t hobject_flags, duk_size_t size) {\n\tvoid *res;\n\n\tres = (void *) DUK_ALLOC_CHECKED_ZEROED(thr, size);\n\tDUK_ASSERT(res != NULL);\n\tduk__init_object_parts(thr->heap, hobject_flags, (duk_hobject *) res);\n\treturn res;\n}\n\n/*\n *  Allocate an duk_hobject.\n *\n *  The allocated object has no allocation for properties; the caller may\n *  want to force a resize if a desired size is known.\n *\n *  The allocated object has zero reference count and is not reachable.\n *  The caller MUST make the object reachable and increase its reference\n *  count before invoking any operation that might require memory allocation.\n */\n\nDUK_INTERNAL duk_hobject *duk_hobject_alloc_unchecked(duk_heap *heap, duk_uint_t hobject_flags) {\n\tduk_hobject *res;\n\n\tDUK_ASSERT(heap != NULL);\n\n\t/* different memory layout, alloc size, and init */\n\tDUK_ASSERT((hobject_flags & DUK_HOBJECT_FLAG_COMPFUNC) == 0);\n\tDUK_ASSERT((hobject_flags & DUK_HOBJECT_FLAG_NATFUNC) == 0);\n\n\tres = (duk_hobject *) DUK_ALLOC_ZEROED(heap, sizeof(duk_hobject));\n\tif (DUK_UNLIKELY(res == NULL)) {\n\t\treturn NULL;\n\t}\n\tDUK_ASSERT(!DUK_HOBJECT_IS_THREAD(res));\n\n\tduk__init_object_parts(heap, hobject_flags, res);\n\n\tDUK_ASSERT(!DUK_HOBJECT_IS_THREAD(res));\n\treturn res;\n}\n\nDUK_INTERNAL duk_hobject *duk_hobject_alloc(duk_hthread *thr, duk_uint_t hobject_flags) {\n\tduk_hobject *res;\n\n\tres = (duk_hobject *) duk__hobject_alloc_init(thr, hobject_flags, sizeof(duk_hobject));\n\treturn res;\n}\n\nDUK_INTERNAL duk_hcompfunc *duk_hcompfunc_alloc(duk_hthread *thr, duk_uint_t hobject_flags) {\n\tduk_hcompfunc *res;\n\n\tres = (duk_hcompfunc *) duk__hobject_alloc_init(thr, hobject_flags, sizeof(duk_hcompfunc));\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n#if defined(DUK_USE_HEAPPTR16)\n\t/* NULL pointer is required to encode to zero, so memset is enough. */\n#else\n\tres->data = NULL;\n\tres->funcs = NULL;\n\tres->bytecode = NULL;\n#endif\n\tres->lex_env = NULL;\n\tres->var_env = NULL;\n#endif\n\n\treturn res;\n}\n\nDUK_INTERNAL duk_hnatfunc *duk_hnatfunc_alloc(duk_hthread *thr, duk_uint_t hobject_flags) {\n\tduk_hnatfunc *res;\n\n\tres = (duk_hnatfunc *) duk__hobject_alloc_init(thr, hobject_flags, sizeof(duk_hnatfunc));\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n\tres->func = NULL;\n#endif\n\n\treturn res;\n}\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_INTERNAL duk_hbufobj *duk_hbufobj_alloc(duk_hthread *thr, duk_uint_t hobject_flags) {\n\tduk_hbufobj *res;\n\n\tres = (duk_hbufobj *) duk__hobject_alloc_init(thr, hobject_flags, sizeof(duk_hbufobj));\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n\tres->buf = NULL;\n\tres->buf_prop = NULL;\n#endif\n\n\tDUK_ASSERT_HBUFOBJ_VALID(res);\n\treturn res;\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/* Allocate a new thread.\n *\n * Leaves the built-ins array uninitialized.  The caller must either\n * initialize a new global context or share existing built-ins from\n * another thread.\n */\nDUK_INTERNAL duk_hthread *duk_hthread_alloc_unchecked(duk_heap *heap, duk_uint_t hobject_flags) {\n\tduk_hthread *res;\n\n\tres = (duk_hthread *) DUK_ALLOC(heap, sizeof(duk_hthread));\n\tif (DUK_UNLIKELY(res == NULL)) {\n\t\treturn NULL;\n\t}\n\tDUK_MEMZERO(res, sizeof(duk_hthread));\n\n\tduk__init_object_parts(heap, hobject_flags, &res->obj);\n\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n\tres->ptr_curr_pc = NULL;\n\tres->heap = NULL;\n\tres->valstack = NULL;\n\tres->valstack_end = NULL;\n\tres->valstack_bottom = NULL;\n\tres->valstack_top = NULL;\n\tres->callstack = NULL;\n\tres->callstack_curr = NULL;\n\tres->catchstack = NULL;\n\tres->resumer = NULL;\n\tres->compile_ctx = NULL,\n#if defined(DUK_USE_HEAPPTR16)\n\tres->strs16 = NULL;\n#else\n\tres->strs = NULL;\n#endif\n\t{\n\t\tduk_small_uint_t i;\n\t\tfor (i = 0; i < DUK_NUM_BUILTINS; i++) {\n\t\t\tres->builtins[i] = NULL;\n\t\t}\n\t}\n#endif\n\t/* when nothing is running, API calls are in non-strict mode */\n\tDUK_ASSERT(res->strict == 0);\n\n\tres->heap = heap;\n\tres->valstack_max = DUK_VALSTACK_DEFAULT_MAX;\n\tres->callstack_max = DUK_CALLSTACK_DEFAULT_MAX;\n\tres->catchstack_max = DUK_CATCHSTACK_DEFAULT_MAX;\n\n\treturn res;\n}\n\nDUK_INTERNAL duk_hthread *duk_hthread_alloc(duk_hthread *thr, duk_uint_t hobject_flags) {\n\tduk_hthread *res;\n\n\tres = duk_hthread_alloc_unchecked(thr->heap, hobject_flags);\n\tif (res == NULL) {\n\t\tDUK_ERROR_ALLOC_FAILED(thr);\n\t}\n\treturn res;\n}\n\nDUK_INTERNAL duk_harray *duk_harray_alloc(duk_hthread *thr, duk_uint_t hobject_flags) {\n\tduk_harray *res;\n\n\tres = (duk_harray *) duk__hobject_alloc_init(thr, hobject_flags, sizeof(duk_harray));\n\n\tDUK_ASSERT(res->length == 0);\n\n\treturn res;\n}\n\nDUK_INTERNAL duk_hdecenv *duk_hdecenv_alloc(duk_hthread *thr, duk_uint_t hobject_flags) {\n\tduk_hdecenv *res;\n\n\tres = (duk_hdecenv *) duk__hobject_alloc_init(thr, hobject_flags, sizeof(duk_hdecenv));\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n\tres->thread = NULL;\n\tres->varmap = NULL;\n#endif\n\n\tDUK_ASSERT(res->thread == NULL);\n\tDUK_ASSERT(res->varmap == NULL);\n\tDUK_ASSERT(res->regbase == 0);\n\n\treturn res;\n}\n\nDUK_INTERNAL duk_hobjenv *duk_hobjenv_alloc(duk_hthread *thr, duk_uint_t hobject_flags) {\n\tduk_hobjenv *res;\n\n\tres = (duk_hobjenv *) duk__hobject_alloc_init(thr, hobject_flags, sizeof(duk_hobjenv));\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n\tres->target = NULL;\n#endif\n\n\tDUK_ASSERT(res->target == NULL);\n\n\treturn res;\n}\n/*\n *  Object enumeration support.\n *\n *  Creates an internal enumeration state object to be used e.g. with for-in\n *  enumeration.  The state object contains a snapshot of target object keys\n *  and internal control state for enumeration.  Enumerator flags allow caller\n *  to e.g. request internal/non-enumerable properties, and to enumerate only\n *  \"own\" properties.\n *\n *  Also creates the result value for e.g. Object.keys() based on the same\n *  internal structure.\n *\n *  This snapshot-based enumeration approach is used to simplify enumeration:\n *  non-snapshot-based approaches are difficult to reconcile with mutating\n *  the enumeration target, running multiple long-lived enumerators at the\n *  same time, garbage collection details, etc.  The downside is that the\n *  enumerator object is memory inefficient especially for iterating arrays.\n */\n\n/* #include duk_internal.h -> already included */\n\n/* XXX: identify enumeration target with an object index (not top of stack) */\n\n/* First enumerated key index in enumerator object, must match exactly the\n * number of control properties inserted to the enumerator.\n */\n#define DUK__ENUM_START_INDEX  2\n\n#if 0\n/* Current implementation suffices for ES2015 for now because there's no symbol\n * sorting, so commented out for now.\n */\n\n/*\n *  Helper to sort enumeration keys using a callback for pairwise duk_hstring\n *  comparisons.  The keys are in the enumeration object entry part, starting\n *  from DUK__ENUM_START_INDEX, and the entry part is dense.  Entry part values\n *  are all \"true\", e.g. \"1\" -> true, \"3\" -> true, \"foo\" -> true \"2\" -> true,\n *  so it suffices to just switch keys without switching values.\n *\n *  Insertion sort is used because (1) it's simple and compact, (2) works\n *  in-place, (3) minimizes operations if data is already nearly sorted,\n *  (4) doesn't reorder elements considered equal.\n *  http://en.wikipedia.org/wiki/Insertion_sort\n */\n\ntypedef duk_bool_t (*duk__sort_compare_fn)(duk_hstring *a, duk_hstring *b, duk_uarridx_t val_b);\n\nDUK_LOCAL duk_bool_t duk__sort_compare_es6(duk_hstring *a, duk_hstring *b, duk_uarridx_t val_b) {\n\tduk_uarridx_t val_a;\n\n\tDUK_ASSERT(a != NULL);\n\tDUK_ASSERT(b != NULL);\n\tDUK_UNREF(b);  /* Not actually needed now, val_b suffices. */\n\n\t/* ES2015 [[OwnPropertyKeys]] enumeration order for ordinary objects:\n\t * (1) array indices in ascending order, (2) non-array-index keys in\n\t * insertion order, symbols in insertion order:\n\t * http://www.ecma-international.org/ecma-262/6.0/#sec-ordinary-object-internal-methods-and-internal-slots-ownpropertykeys.\n\t *\n\t * This rule is applied to \"own properties\" at each inheritance level;\n\t * non-duplicate parent keys always follow child keys.  For example,\n\t * an inherited array index will enumerate -after- a symbol in the\n\t * child.\n\t */\n\n\tval_a = DUK_HSTRING_GET_ARRIDX_FAST(a);\n\n\tif (val_b < val_a) {\n\t\t/* Covers:\n\t\t *   - Both keys are array indices and a > b: don't insert here.\n\t\t *   - 'b' is array index, 'a' is not: don't insert here.\n\t\t */\n\t\treturn 0;\n\t} else {\n\t\t/* Covers:\n\t\t *   val_a < val_b where:\n\t\t *   - Both keys are array indices and a < b: insert here.\n\t\t *   - 'a' is array index, 'b' is not: insert here.\n\t\t *   val_a == val_b where:\n\t\t *   - Both keys are array indices and a == b: insert here\n\t\t *     (shouldn't actually happen, can't have non-duplicate\n\t\t *     identical array index keys).\n\t\t *   - Neither key is an array index: insert here, keeps key\n\t\t *     order regardless of the keys themselves.\n\t\t */\n\t\treturn 1;\n\t}\n}\n\nDUK_LOCAL void duk__sort_enum_keys_es6(duk_hthread *thr, duk_hobject *h_obj, duk_int_fast32_t idx_start, duk_int_fast32_t idx_end) {\n\tduk_hstring **keys;\n\tduk_int_fast32_t idx;\n\n\tDUK_ASSERT(h_obj != NULL);\n\tDUK_ASSERT(idx_start >= DUK__ENUM_START_INDEX);\n\tDUK_ASSERT(idx_end >= idx_start);\n\tDUK_UNREF(thr);\n\n\tif (idx_end <= idx_start + 1) {\n\t\treturn;  /* Zero or one element(s). */\n\t}\n\n\tkeys = DUK_HOBJECT_E_GET_KEY_BASE(thr->heap, h_obj);\n\n\tfor (idx = idx_start + 1; idx < idx_end; idx++) {\n\t\tduk_hstring *h_curr;\n\t\tduk_int_fast32_t idx_insert;\n\t\tduk_uarridx_t val_curr;\n\n\t\th_curr = keys[idx];\n\t\tDUK_ASSERT(h_curr != NULL);\n\n\t\t/* Scan backwards for insertion place.  This works very well\n\t\t * when the elements are nearly in order which is the common\n\t\t * (and optimized for) case.\n\t\t */\n\n\t\tval_curr = DUK_HSTRING_GET_ARRIDX_FAST(h_curr);  /* Remains same during scanning. */\n\t\tfor (idx_insert = idx - 1; idx_insert >= idx_start; idx_insert--) {\n\t\t\tduk_hstring *h_insert;\n\t\t\th_insert = keys[idx_insert];\n\t\t\tDUK_ASSERT(h_insert != NULL);\n\n\t\t\t/* XXX: fixed callback rather than a callback argument; only\n\t\t\t * one argument used and using a callback argument doesn't\n\t\t\t * cause e.g. gcc to inline the callback.\n\t\t\t */\n\t\t\tif (duk__sort_compare_es6(h_insert, h_curr, val_curr)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t/* If we're out of indices, idx_insert == idx_start - 1 and idx_insert++\n\t\t * brings us back to idx_start.\n\t\t */\n\t\tidx_insert++;\n\t\tDUK_ASSERT(idx_insert >= 0 && idx_insert <= idx);\n\n\t\t/*        .-- p_insert   .-- p_curr\n\t\t *        v              v\n\t\t *  | ... | insert | ... | curr\n\t\t */\n\n\t\t/* This could also done when the keys are in order, i.e.\n\t\t * idx_insert == idx.  The result would be an unnecessary\n\t\t * memmove() but we use an explicit check because the keys\n\t\t * are very often in order already.\n\t\t */\n\t\tif (idx != idx_insert) {\n\t\t\tDUK_MEMMOVE((void *) (keys + idx_insert + 1),\n\t\t\t            (const void *) (keys + idx_insert),\n\t\t\t            (size_t) ((idx - idx_insert) * sizeof(duk_hstring *)));\n\t\t\tkeys[idx_insert] = h_curr;\n\t\t}\n\t}\n}\n#endif  /* disabled */\n\n/*\n *  Helper to sort keys into ES2015 [[OwnPropertyKeys]] enumeration order:\n *  array keys in ascending order first, followed by keys in insertion\n *  order, followed by symbols in insertion order (not handled here).\n *  Insertion sort based.\n *\n *  This algorithm nominally sorts array indices, but because the \"no array\n *  index\" marker is higher than any array index, non-array-index keys are\n *  sorted after array indices.  Non-array-index keys are also considered\n *  equal for sorting which means that their order is kept as is, so the end\n *  result matches ES2015 [[OwnPropertyKeys]].\n *\n *  Insertion sort is used because (1) it's simple and compact, (2) works\n *  in-place, (3) minimizes operations if data is already nearly sorted,\n *  (4) doesn't reorder elements considered equal.\n *  http://en.wikipedia.org/wiki/Insertion_sort\n */\n\nDUK_LOCAL void duk__sort_enum_keys_es6(duk_hthread *thr, duk_hobject *h_obj, duk_int_fast32_t idx_start, duk_int_fast32_t idx_end) {\n\tduk_hstring **keys;\n\tduk_hstring **p_curr, **p_insert, **p_end;\n\tduk_hstring *h_curr;\n\tduk_uarridx_t val_highest, val_curr, val_insert;\n\n\tDUK_ASSERT(h_obj != NULL);\n\tDUK_ASSERT(idx_start >= DUK__ENUM_START_INDEX);\n\tDUK_ASSERT(idx_end >= idx_start);\n\tDUK_UNREF(thr);\n\n\tif (idx_end <= idx_start + 1) {\n\t\treturn;  /* Zero or one element(s). */\n\t}\n\n\tkeys = DUK_HOBJECT_E_GET_KEY_BASE(thr->heap, h_obj);\n\tp_curr = keys + idx_start;\n\tval_highest = DUK_HSTRING_GET_ARRIDX_SLOW(*p_curr);\n\tfor (p_curr++, p_end = keys + idx_end; p_curr < p_end; p_curr++) {\n\t\tDUK_ASSERT(*p_curr != NULL);\n\t\tval_curr = DUK_HSTRING_GET_ARRIDX_SLOW(*p_curr);\n\n\t\tif (val_curr >= val_highest) {\n\t\t\tval_highest = val_curr;\n\t\t\tcontinue;\n\t\t}\n\n\t\t/* Needs to be inserted; scan backwards, since we optimize\n\t\t * for the case where elements are nearly in order.\n\t\t */\n\n\t\tp_insert = p_curr;\n\t\tfor (;;) {\n\t\t\tp_insert--;  /* Start from p_curr - 1. */\n\t\t\tval_insert = DUK_HSTRING_GET_ARRIDX_SLOW(*p_insert);\n\t\t\tif (val_insert < val_curr) {\n\t\t\t\tp_insert++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (p_insert == keys + idx_start) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t/*        .-- p_insert   .-- p_curr\n\t\t *        v              v\n\t\t *  | ... | insert | ... | curr\n\t\t */\n\n\t\th_curr = *p_curr;\n\t\tDUK_MEMMOVE((void *) (p_insert + 1),\n\t\t            (const void *) p_insert,\n\t\t            (size_t) ((p_curr - p_insert) * sizeof(duk_hstring *)));\n\t\t*p_insert = h_curr;\n\t\t/* keep val_highest */\n\t}\n}\n\n/*\n *  Create an internal enumerator object E, which has its keys ordered\n *  to match desired enumeration ordering.  Also initialize internal control\n *  properties for enumeration.\n *\n *  Note: if an array was used to hold enumeration keys instead, an array\n *  scan would be needed to eliminate duplicates found in the prototype chain.\n */\n\nDUK_LOCAL void duk__add_enum_key(duk_context *ctx, duk_hstring *k) {\n\t/* 'k' may be unreachable on entry so must push without any\n\t * potential for GC.\n\t */\n\tduk_push_hstring(ctx, k);\n\tduk_push_true(ctx);\n\tduk_put_prop(ctx, -3);\n}\n\nDUK_LOCAL void duk__add_enum_key_stridx(duk_context *ctx, duk_small_uint_t stridx) {\n\tduk__add_enum_key(ctx, DUK_HTHREAD_GET_STRING((duk_hthread *) ctx, stridx));\n}\n\nDUK_INTERNAL void duk_hobject_enumerator_create(duk_context *ctx, duk_small_uint_t enum_flags) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *enum_target;\n\tduk_hobject *curr;\n\tduk_hobject *res;\n#if defined(DUK_USE_ES6_PROXY)\n\tduk_hobject *h_proxy_target;\n\tduk_hobject *h_proxy_handler;\n\tduk_hobject *h_trap_result;\n#endif\n\tduk_uint_fast32_t i, len;  /* used for array, stack, and entry indices */\n\tduk_uint_fast32_t sort_start_index;\n\n\tDUK_ASSERT(ctx != NULL);\n\n\tenum_target = duk_require_hobject(ctx, -1);\n\tDUK_ASSERT(enum_target != NULL);\n\n\tduk_push_bare_object(ctx);\n\tres = duk_known_hobject(ctx, -1);\n\n\t/* [enum_target res] */\n\n\t/* Target must be stored so that we can recheck whether or not\n\t * keys still exist when we enumerate.  This is not done if the\n\t * enumeration result comes from a proxy trap as there is no\n\t * real object to check against.\n\t */\n\tduk_push_hobject(ctx, enum_target);\n\tduk_put_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_TARGET);\n\n\t/* Initialize index so that we skip internal control keys. */\n\tduk_push_int(ctx, DUK__ENUM_START_INDEX);\n\tduk_put_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_NEXT);\n\n\t/*\n\t *  Proxy object handling\n\t */\n\n#if defined(DUK_USE_ES6_PROXY)\n\tif (DUK_LIKELY((enum_flags & DUK_ENUM_NO_PROXY_BEHAVIOR) != 0)) {\n\t\tgoto skip_proxy;\n\t}\n\tif (DUK_LIKELY(!duk_hobject_proxy_check(thr,\n\t                                        enum_target,\n\t                                        &h_proxy_target,\n\t                                        &h_proxy_handler))) {\n\t\tgoto skip_proxy;\n\t}\n\n\t/* XXX: share code with Object.keys() Proxy handling */\n\n\t/* In ES2015 for-in invoked the \"enumerate\" trap; in ES2016 \"enumerate\"\n\t * has been obsoleted and \"ownKeys\" is used instead.\n\t */\n\tDUK_DDD(DUK_DDDPRINT(\"proxy enumeration\"));\n\tduk_push_hobject(ctx, h_proxy_handler);\n\tif (!duk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_OWN_KEYS)) {\n\t\t/* No need to replace the 'enum_target' value in stack, only the\n\t\t * enum_target reference.  This also ensures that the original\n\t\t * enum target is reachable, which keeps the proxy and the proxy\n\t\t * target reachable.  We do need to replace the internal _Target.\n\t\t */\n\t\tDUK_DDD(DUK_DDDPRINT(\"no ownKeys trap, enumerate proxy target instead\"));\n\t\tDUK_DDD(DUK_DDDPRINT(\"h_proxy_target=%!O\", (duk_heaphdr *) h_proxy_target));\n\t\tenum_target = h_proxy_target;\n\n\t\tduk_push_hobject(ctx, enum_target);  /* -> [ ... enum_target res handler undefined target ] */\n\t\tduk_put_prop_stridx_short(ctx, -4, DUK_STRIDX_INT_TARGET);\n\n\t\tduk_pop_2(ctx);  /* -> [ ... enum_target res ] */\n\t\tgoto skip_proxy;\n\t}\n\n\t/* [ ... enum_target res handler trap ] */\n\tduk_insert(ctx, -2);\n\tduk_push_hobject(ctx, h_proxy_target);    /* -> [ ... enum_target res trap handler target ] */\n\tduk_call_method(ctx, 1 /*nargs*/);        /* -> [ ... enum_target res trap_result ] */\n\th_trap_result = duk_require_hobject(ctx, -1);\n\tDUK_UNREF(h_trap_result);\n\n\tduk_proxy_ownkeys_postprocess(ctx, h_proxy_target, enum_flags);\n\t/* -> [ ... enum_target res trap_result keys_array ] */\n\n\t/* Copy cleaned up trap result keys into the enumerator object. */\n\t/* XXX: result is a dense array; could make use of that. */\n\tDUK_ASSERT(duk_is_array(ctx, -1));\n\tlen = (duk_uint_fast32_t) duk_get_length(ctx, -1);\n\tfor (i = 0; i < len; i++) {\n\t\t(void) duk_get_prop_index(ctx, -1, i);\n\t\tDUK_ASSERT(duk_is_string(ctx, -1));  /* postprocess cleaned up */\n\t\t/* [ ... enum_target res trap_result keys_array val ] */\n\t\tduk_push_true(ctx);\n\t\t/* [ ... enum_target res trap_result keys_array val true ] */\n\t\tduk_put_prop(ctx, -5);\n\t}\n\t/* [ ... enum_target res trap_result keys_array ] */\n\tduk_pop_2(ctx);\n\tduk_remove_m2(ctx);\n\n\t/* [ ... res ] */\n\n\t/* The internal _Target property is kept pointing to the original\n\t * enumeration target (the proxy object), so that the enumerator\n\t * 'next' operation can read property values if so requested.  The\n\t * fact that the _Target is a proxy disables key existence check\n\t * during enumeration.\n\t */\n\tDUK_DDD(DUK_DDDPRINT(\"proxy enumeration, final res: %!O\", (duk_heaphdr *) res));\n\tgoto compact_and_return;\n\n skip_proxy:\n#endif  /* DUK_USE_ES6_PROXY */\n\n\tcurr = enum_target;\n\tsort_start_index = DUK__ENUM_START_INDEX;\n\tDUK_ASSERT(DUK_HOBJECT_GET_ENEXT(res) == DUK__ENUM_START_INDEX);\n\twhile (curr) {\n\t\tduk_uint_fast32_t sort_end_index;\n#if !defined(DUK_USE_PREFER_SIZE)\n\t\tduk_bool_t need_sort = 0;\n#endif\n\n\t\t/* Enumeration proceeds by inheritance level.  Virtual\n\t\t * properties need to be handled specially, followed by\n\t\t * array part, and finally entry part.\n\t\t *\n\t\t * If there are array index keys in the entry part or any\n\t\t * other risk of the ES2015 [[OwnPropertyKeys]] order being\n\t\t * violated, need_sort is set and an explicit ES2015 sort is\n\t\t * done for the inheritance level.\n\t\t */\n\n\t\t/* XXX: inheriting from proxy */\n\n\t\t/*\n\t\t *  Virtual properties.\n\t\t *\n\t\t *  String and buffer indices are virtual and always enumerable,\n\t\t *  'length' is virtual and non-enumerable.  Array and arguments\n\t\t *  object props have special behavior but are concrete.\n\t\t *\n\t\t *  String and buffer objects don't have an array part so as long\n\t\t *  as virtual array index keys are enumerated first, we don't\n\t\t *  need to set need_sort.\n\t\t */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n\t\tif (DUK_HOBJECT_HAS_EXOTIC_STRINGOBJ(curr) || DUK_HOBJECT_IS_BUFOBJ(curr)) {\n#else\n\t\tif (DUK_HOBJECT_HAS_EXOTIC_STRINGOBJ(curr)) {\n#endif\n\t\t\tduk_bool_t have_length = 1;\n\n\t\t\t/* String and buffer enumeration behavior is identical now,\n\t\t\t * so use shared handler.\n\t\t\t */\n\t\t\tif (DUK_HOBJECT_HAS_EXOTIC_STRINGOBJ(curr)) {\n\t\t\t\tduk_hstring *h_val;\n\t\t\t\th_val = duk_hobject_get_internal_value_string(thr->heap, curr);\n\t\t\t\tDUK_ASSERT(h_val != NULL);  /* string objects must not created without internal value */\n\t\t\t\tlen = (duk_uint_fast32_t) DUK_HSTRING_GET_CHARLEN(h_val);\n\t\t\t}\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n\t\t\telse {\n\t\t\t\tduk_hbufobj *h_bufobj;\n\t\t\t\tDUK_ASSERT(DUK_HOBJECT_IS_BUFOBJ(curr));\n\t\t\t\th_bufobj = (duk_hbufobj *) curr;\n\n\t\t\t\tif (h_bufobj == NULL || !h_bufobj->is_typedarray) {\n\t\t\t\t\t/* Zero length seems like a good behavior for neutered buffers.\n\t\t\t\t\t * ArrayBuffer (non-view) and DataView don't have index properties\n\t\t\t\t\t * or .length property.\n\t\t\t\t\t */\n\t\t\t\t\tlen = 0;\n\t\t\t\t\thave_length = 0;\n\t\t\t\t} else {\n\t\t\t\t\t/* There's intentionally no check for\n\t\t\t\t\t * current underlying buffer length.\n\t\t\t\t\t */\n\t\t\t\t\tlen = (duk_uint_fast32_t) (h_bufobj->length >> h_bufobj->shift);\n\t\t\t\t}\n\t\t\t}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n\t\t\tfor (i = 0; i < len; i++) {\n\t\t\t\tduk_hstring *k;\n\n\t\t\t\t/* This is a bit fragile: the string is not\n\t\t\t\t * reachable until it is pushed by the helper.\n\t\t\t\t */\n\t\t\t\tk = duk_heap_strtable_intern_u32_checked(thr, i);\n\t\t\t\tDUK_ASSERT(k);\n\n\t\t\t\tduk__add_enum_key(ctx, k);\n\n\t\t\t\t/* [enum_target res] */\n\t\t\t}\n\n\t\t\t/* 'length' and other virtual properties are not\n\t\t\t * enumerable, but are included if non-enumerable\n\t\t\t * properties are requested.\n\t\t\t */\n\n\t\t\tif (have_length && (enum_flags & DUK_ENUM_INCLUDE_NONENUMERABLE)) {\n\t\t\t\tduk__add_enum_key_stridx(ctx, DUK_STRIDX_LENGTH);\n\t\t\t}\n\t\t} else if (DUK_HOBJECT_HAS_EXOTIC_DUKFUNC(curr)) {\n\t\t\tif (enum_flags & DUK_ENUM_INCLUDE_NONENUMERABLE) {\n\t\t\t\tduk__add_enum_key_stridx(ctx, DUK_STRIDX_LENGTH);\n\t\t\t}\n\t\t}\n\n\t\t/*\n\t\t *  Array part\n\t\t */\n\n\t\tfor (i = 0; i < (duk_uint_fast32_t) DUK_HOBJECT_GET_ASIZE(curr); i++) {\n\t\t\tduk_hstring *k;\n\t\t\tduk_tval *tv;\n\n\t\t\ttv = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, curr, i);\n\t\t\tif (DUK_TVAL_IS_UNUSED(tv)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tk = duk_heap_strtable_intern_u32_checked(thr, i);  /* Fragile reachability. */\n\t\t\tDUK_ASSERT(k);\n\n\t\t\tduk__add_enum_key(ctx, k);\n\n\t\t\t/* [enum_target res] */\n\t\t}\n\n\t\tif (DUK_HOBJECT_HAS_EXOTIC_ARRAY(curr)) {\n\t\t\t/* Array .length comes after numeric indices. */\n\t\t\tif (enum_flags & DUK_ENUM_INCLUDE_NONENUMERABLE) {\n\t\t\t\tduk__add_enum_key_stridx(ctx, DUK_STRIDX_LENGTH);\n\t\t\t}\n\t\t}\n\n\t\t/*\n\t\t *  Entries part\n\t\t */\n\n\t\tfor (i = 0; i < (duk_uint_fast32_t) DUK_HOBJECT_GET_ENEXT(curr); i++) {\n\t\t\tduk_hstring *k;\n\n\t\t\tk = DUK_HOBJECT_E_GET_KEY(thr->heap, curr, i);\n\t\t\tif (!k) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!(enum_flags & DUK_ENUM_INCLUDE_NONENUMERABLE) &&\n\t\t\t    !DUK_HOBJECT_E_SLOT_IS_ENUMERABLE(thr->heap, curr, i)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(k))) {\n\t\t\t\tif (!(enum_flags & DUK_ENUM_INCLUDE_HIDDEN) &&\n\t\t\t\t    DUK_HSTRING_HAS_HIDDEN(k)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (!(enum_flags & DUK_ENUM_INCLUDE_SYMBOLS)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tDUK_ASSERT(!DUK_HSTRING_HAS_HIDDEN(k));  /* would also have symbol flag */\n\t\t\t\tif (enum_flags & DUK_ENUM_EXCLUDE_STRINGS) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (DUK_HSTRING_HAS_ARRIDX(k)) {\n\t\t\t\t/* This in currently only possible if the\n\t\t\t\t * object has no array part: the array part\n\t\t\t\t * is exhaustive when it is present.\n\t\t\t\t */\n#if !defined(DUK_USE_PREFER_SIZE)\n\t\t\t\tneed_sort = 1;\n#endif\n\t\t\t} else {\n\t\t\t\tif (enum_flags & DUK_ENUM_ARRAY_INDICES_ONLY) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tDUK_ASSERT(DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, curr, i) ||\n\t\t\t           !DUK_TVAL_IS_UNUSED(&DUK_HOBJECT_E_GET_VALUE_PTR(thr->heap, curr, i)->v));\n\n\t\t\tduk__add_enum_key(ctx, k);\n\n\t\t\t/* [enum_target res] */\n\t\t}\n\n\t\t/* Sort enumerated keys according to ES2015 requirements for\n\t\t * the \"inheritance level\" just processed.  This is far from\n\t\t * optimal, ES2015 semantics could be achieved more efficiently\n\t\t * by handling array index string keys (and symbol keys)\n\t\t * specially above in effect doing the sort inline.\n\t\t *\n\t\t * Skip the sort if array index sorting is requested because\n\t\t * we must consider all keys, also inherited, so an explicit\n\t\t * sort is done for the whole result after we're done with the\n\t\t * prototype chain.\n\t\t *\n\t\t * Also skip the sort if need_sort == 0, i.e. we know for\n\t\t * certain that the enumerated order is already correct.\n\t\t */\n\t\tsort_end_index = DUK_HOBJECT_GET_ENEXT(res);\n\n\t\tif (!(enum_flags & DUK_ENUM_SORT_ARRAY_INDICES)) {\n#if defined(DUK_USE_PREFER_SIZE)\n\t\t\tduk__sort_enum_keys_es6(thr, res, sort_start_index, sort_end_index);\n#else\n\t\t\tif (need_sort) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"need to sort\"));\n\t\t\t\tduk__sort_enum_keys_es6(thr, res, sort_start_index, sort_end_index);\n\t\t\t} else {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"no need to sort\"));\n\t\t\t}\n#endif\n\t\t}\n\n\t\tsort_start_index = sort_end_index;\n\n\t\tif (enum_flags & DUK_ENUM_OWN_PROPERTIES_ONLY) {\n\t\t\tbreak;\n\t\t}\n\n\t\tcurr = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, curr);\n\t}\n\n\t/* [enum_target res] */\n\n\tduk_remove_m2(ctx);\n\n\t/* [res] */\n\n\tif (enum_flags & DUK_ENUM_SORT_ARRAY_INDICES) {\n\t\t/* Some E5/E5.1 algorithms require that array indices are iterated\n\t\t * in a strictly ascending order.  This is the case for e.g.\n\t\t * Array.prototype.forEach() and JSON.stringify() PropertyList\n\t\t * handling.  The caller can request an explicit sort in these\n\t\t * cases.\n\t\t */\n\n\t\t/* Sort to ES2015 order which works for pure array incides but\n\t\t * also for mixed keys.\n\t\t */\n\t\tduk__sort_enum_keys_es6(thr, res, DUK__ENUM_START_INDEX, DUK_HOBJECT_GET_ENEXT(res));\n\t}\n\n#if defined(DUK_USE_ES6_PROXY)\n compact_and_return:\n#endif\n\t/* compact; no need to seal because object is internal */\n\tduk_hobject_compact_props(thr, res);\n\n\tDUK_DDD(DUK_DDDPRINT(\"created enumerator object: %!iT\", (duk_tval *) duk_get_tval(ctx, -1)));\n}\n\n/*\n *  Returns non-zero if a key and/or value was enumerated, and:\n *\n *   [enum] -> [key]        (get_value == 0)\n *   [enum] -> [key value]  (get_value == 1)\n *\n *  Returns zero without pushing anything on the stack otherwise.\n */\nDUK_INTERNAL duk_bool_t duk_hobject_enumerator_next(duk_context *ctx, duk_bool_t get_value) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *e;\n\tduk_hobject *enum_target;\n\tduk_hstring *res = NULL;\n\tduk_uint_fast32_t idx;\n\tduk_bool_t check_existence;\n\n\tDUK_ASSERT(ctx != NULL);\n\n\t/* [... enum] */\n\n\te = duk_require_hobject(ctx, -1);\n\n\t/* XXX use get tval ptr, more efficient */\n\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_INT_NEXT);\n\tidx = (duk_uint_fast32_t) duk_require_uint(ctx, -1);\n\tduk_pop(ctx);\n\tDUK_DDD(DUK_DDDPRINT(\"enumeration: index is: %ld\", (long) idx));\n\n\t/* Enumeration keys are checked against the enumeration target (to see\n\t * that they still exist).  In the proxy enumeration case _Target will\n\t * be the proxy, and checking key existence against the proxy is not\n\t * required (or sensible, as the keys may be fully virtual).\n\t */\n\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_INT_TARGET);\n\tenum_target = duk_require_hobject(ctx, -1);\n\tDUK_ASSERT(enum_target != NULL);\n#if defined(DUK_USE_ES6_PROXY)\n\tcheck_existence = (!DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(enum_target));\n#else\n\tcheck_existence = 1;\n#endif\n\tduk_pop(ctx);  /* still reachable */\n\n\tDUK_DDD(DUK_DDDPRINT(\"getting next enum value, enum_target=%!iO, enumerator=%!iT\",\n\t                     (duk_heaphdr *) enum_target, (duk_tval *) duk_get_tval(ctx, -1)));\n\n\t/* no array part */\n\tfor (;;) {\n\t\tduk_hstring *k;\n\n\t\tif (idx >= DUK_HOBJECT_GET_ENEXT(e)) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"enumeration: ran out of elements\"));\n\t\t\tbreak;\n\t\t}\n\n\t\t/* we know these because enum objects are internally created */\n\t\tk = DUK_HOBJECT_E_GET_KEY(thr->heap, e, idx);\n\t\tDUK_ASSERT(k != NULL);\n\t\tDUK_ASSERT(!DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, e, idx));\n\t\tDUK_ASSERT(!DUK_TVAL_IS_UNUSED(&DUK_HOBJECT_E_GET_VALUE(thr->heap, e, idx).v));\n\n\t\tidx++;\n\n\t\t/* recheck that the property still exists */\n\t\tif (check_existence && !duk_hobject_hasprop_raw(thr, enum_target, k)) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"property deleted during enumeration, skip\"));\n\t\t\tcontinue;\n\t\t}\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"enumeration: found element, key: %!O\", (duk_heaphdr *) k));\n\t\tres = k;\n\t\tbreak;\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"enumeration: updating next index to %ld\", (long) idx));\n\n\tduk_push_u32(ctx, (duk_uint32_t) idx);\n\tduk_put_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_NEXT);\n\n\t/* [... enum] */\n\n\tif (res) {\n\t\tduk_push_hstring(ctx, res);\n\t\tif (get_value) {\n\t\t\tduk_push_hobject(ctx, enum_target);\n\t\t\tduk_dup_m2(ctx);       /* -> [... enum key enum_target key] */\n\t\t\tduk_get_prop(ctx, -2); /* -> [... enum key enum_target val] */\n\t\t\tduk_remove_m2(ctx);    /* -> [... enum key val] */\n\t\t\tduk_remove(ctx, -3);   /* -> [... key val] */\n\t\t} else {\n\t\t\tduk_remove_m2(ctx);    /* -> [... key] */\n\t\t}\n\t\treturn 1;\n\t} else {\n\t\tduk_pop(ctx);  /* -> [...] */\n\t\treturn 0;\n\t}\n}\n\n/*\n *  Get enumerated keys in an Ecmascript array.  Matches Object.keys() behavior\n *  described in E5 Section 15.2.3.14.\n */\n\nDUK_INTERNAL duk_ret_t duk_hobject_get_enumerated_keys(duk_context *ctx, duk_small_uint_t enum_flags) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *e;\n\tduk_harray *a;\n\tduk_hstring **keys;\n\tduk_tval *tv;\n\tduk_uint_fast32_t count;\n\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(duk_get_hobject(ctx, -1) != NULL);\n\tDUK_UNREF(thr);\n\n\t/* Create a temporary enumerator to get the (non-duplicated) key list;\n\t * the enumerator state is initialized without being needed, but that\n\t * has little impact.\n\t */\n\n\tduk_hobject_enumerator_create(ctx, enum_flags);\n\te = duk_known_hobject(ctx, -1);\n\n\t/* [enum_target enum res] */\n\n\t/* Create dense result array to exact size. */\n\tDUK_ASSERT(DUK_HOBJECT_GET_ENEXT(e) >= DUK__ENUM_START_INDEX);\n\tcount = (duk_uint32_t) (DUK_HOBJECT_GET_ENEXT(e) - DUK__ENUM_START_INDEX);\n\n\ta = duk_push_harray_with_size(ctx, count);\n\tDUK_ASSERT(a != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_GET_ASIZE((duk_hobject *) a) == count);\n\tDUK_ASSERT(a->length == count);\n\ttv = DUK_HOBJECT_A_GET_BASE(thr->heap, (duk_hobject *) a);\n\n\t/* Fill result array, no side effects. */\n\n\tkeys = DUK_HOBJECT_E_GET_KEY_BASE(thr->heap, e);\n\tkeys += DUK__ENUM_START_INDEX;\n\n\twhile (count-- > 0) {\n\t\tduk_hstring *k;\n\n\t\tk = *keys++;\n\t\tDUK_ASSERT(k != NULL);  /* enumerator must have no keys deleted */\n\n\t\tDUK_TVAL_SET_STRING(tv, k);\n\t\ttv++;\n\t\tDUK_HSTRING_INCREF(thr, k);\n\t}\n\n\t/* [enum_target enum res] */\n\tduk_remove_m2(ctx);\n\n\t/* [enum_target res] */\n\n\treturn 1;  /* return 1 to allow callers to tail call */\n}\n\n/* automatic undefs */\n#undef DUK__ENUM_START_INDEX\n/*\n *  Misc support functions\n */\n\n/* #include duk_internal.h -> already included */\n\nDUK_INTERNAL duk_bool_t duk_hobject_prototype_chain_contains(duk_hthread *thr, duk_hobject *h, duk_hobject *p, duk_bool_t ignore_loop) {\n\tduk_uint_t sanity;\n\n\tDUK_ASSERT(thr != NULL);\n\n\t/* False if the object is NULL or the prototype 'p' is NULL.\n\t * In particular, false if both are NULL (don't compare equal).\n\t */\n\tif (h == NULL || p == NULL) {\n\t\treturn 0;\n\t}\n\n\tsanity = DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY;\n\tdo {\n\t\tif (h == p) {\n\t\t\treturn 1;\n\t\t}\n\n\t\tif (sanity-- == 0) {\n\t\t\tif (ignore_loop) {\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tDUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT);\n\t\t\t}\n\t\t}\n\t\th = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h);\n\t} while (h);\n\n\treturn 0;\n}\n\nDUK_INTERNAL void duk_hobject_set_prototype_updref(duk_hthread *thr, duk_hobject *h, duk_hobject *p) {\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tduk_hobject *tmp;\n\n\tDUK_ASSERT(h);\n\ttmp = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h);\n\tDUK_HOBJECT_SET_PROTOTYPE(thr->heap, h, p);\n\tDUK_HOBJECT_INCREF_ALLOWNULL(thr, p);  /* avoid problems if p == h->prototype */\n\tDUK_HOBJECT_DECREF_ALLOWNULL(thr, tmp);\n#else\n\tDUK_ASSERT(h);\n\tDUK_UNREF(thr);\n\tDUK_HOBJECT_SET_PROTOTYPE(thr->heap, h, p);\n#endif\n}\n/*\n *  Helpers for creating and querying pc2line debug data, which\n *  converts a bytecode program counter to a source line number.\n *\n *  The run-time pc2line data is bit-packed, and documented in:\n *\n *    doc/function-objects.rst\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_PC2LINE)\n\n/* Generate pc2line data for an instruction sequence, leaving a buffer on stack top. */\nDUK_INTERNAL void duk_hobject_pc2line_pack(duk_hthread *thr, duk_compiler_instr *instrs, duk_uint_fast32_t length) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hbuffer_dynamic *h_buf;\n\tduk_bitencoder_ctx be_ctx_alloc;\n\tduk_bitencoder_ctx *be_ctx = &be_ctx_alloc;\n\tduk_uint32_t *hdr;\n\tduk_size_t new_size;\n\tduk_uint_fast32_t num_header_entries;\n\tduk_uint_fast32_t curr_offset;\n\tduk_int_fast32_t curr_line, next_line, diff_line;\n\tduk_uint_fast32_t curr_pc;\n\tduk_uint_fast32_t hdr_index;\n\n\tDUK_ASSERT(length <= DUK_COMPILER_MAX_BYTECODE_LENGTH);\n\n\t/* XXX: add proper spare handling to dynamic buffer, to minimize\n\t * reallocs; currently there is no spare at all.\n\t */\n\n\tnum_header_entries = (length + DUK_PC2LINE_SKIP - 1) / DUK_PC2LINE_SKIP;\n\tcurr_offset = (duk_uint_fast32_t) (sizeof(duk_uint32_t) + num_header_entries * sizeof(duk_uint32_t) * 2);\n\n\tduk_push_dynamic_buffer(ctx, (duk_size_t) curr_offset);\n\th_buf = (duk_hbuffer_dynamic *) duk_known_hbuffer(ctx, -1);\n\tDUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(h_buf) && !DUK_HBUFFER_HAS_EXTERNAL(h_buf));\n\n\thdr = (duk_uint32_t *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, h_buf);\n\tDUK_ASSERT(hdr != NULL);\n\thdr[0] = (duk_uint32_t) length;  /* valid pc range is [0, length[ */\n\n\tcurr_pc = 0U;\n\twhile (curr_pc < length) {\n\t\tnew_size = (duk_size_t) (curr_offset + DUK_PC2LINE_MAX_DIFF_LENGTH);\n\t\tduk_hbuffer_resize(thr, h_buf, new_size);\n\n\t\thdr = (duk_uint32_t *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, h_buf);\n\t\tDUK_ASSERT(hdr != NULL);\n\t\tDUK_ASSERT(curr_pc < length);\n\t\thdr_index = 1 + (curr_pc / DUK_PC2LINE_SKIP) * 2;\n\t\tcurr_line = (duk_int_fast32_t) instrs[curr_pc].line;\n\t\thdr[hdr_index + 0] = (duk_uint32_t) curr_line;\n\t\thdr[hdr_index + 1] = (duk_uint32_t) curr_offset;\n\n#if 0\n\t\tDUK_DDD(DUK_DDDPRINT(\"hdr[%ld]: pc=%ld line=%ld offset=%ld\",\n\t\t                     (long) (curr_pc / DUK_PC2LINE_SKIP),\n\t\t                     (long) curr_pc,\n\t\t                     (long) hdr[hdr_index + 0],\n\t\t                     (long) hdr[hdr_index + 1]));\n#endif\n\n\t\tDUK_MEMZERO(be_ctx, sizeof(*be_ctx));\n\t\tbe_ctx->data = ((duk_uint8_t *) hdr) + curr_offset;\n\t\tbe_ctx->length = (duk_size_t) DUK_PC2LINE_MAX_DIFF_LENGTH;\n\n\t\tfor (;;) {\n\t\t\tcurr_pc++;\n\t\t\tif ( ((curr_pc % DUK_PC2LINE_SKIP) == 0) ||  /* end of diff run */\n\t\t\t     (curr_pc >= length) ) {                 /* end of bytecode */\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tDUK_ASSERT(curr_pc < length);\n\t\t\tnext_line = (duk_int32_t) instrs[curr_pc].line;\n\t\t\tdiff_line = next_line - curr_line;\n\n#if 0\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"curr_line=%ld, next_line=%ld -> diff_line=%ld\",\n\t\t\t                     (long) curr_line, (long) next_line, (long) diff_line));\n#endif\n\n\t\t\tif (diff_line == 0) {\n\t\t\t\t/* 0 */\n\t\t\t\tduk_be_encode(be_ctx, 0, 1);\n\t\t\t} else if (diff_line >= 1 && diff_line <= 4) {\n\t\t\t\t/* 1 0 <2 bits> */\n\t\t\t\tduk_be_encode(be_ctx, (0x02 << 2) + (diff_line - 1), 4);\n\t\t\t} else if (diff_line >= -0x80 && diff_line <= 0x7f) {\n\t\t\t\t/* 1 1 0 <8 bits> */\n\t\t\t\tDUK_ASSERT(diff_line + 0x80 >= 0 && diff_line + 0x80 <= 0xff);\n\t\t\t\tduk_be_encode(be_ctx, (0x06 << 8) + (diff_line + 0x80), 11);\n\t\t\t} else {\n\t\t\t\t/* 1 1 1 <32 bits>\n\t\t\t\t * Encode in two parts to avoid bitencode 24-bit limitation\n\t\t\t\t */\n\t\t\t\tduk_be_encode(be_ctx, (0x07 << 16) + ((next_line >> 16) & 0xffffU), 19);\n\t\t\t\tduk_be_encode(be_ctx, next_line & 0xffffU, 16);\n\t\t\t}\n\n\t\t\tcurr_line = next_line;\n\t\t}\n\n\t\tduk_be_finish(be_ctx);\n\t\tDUK_ASSERT(!be_ctx->truncated);\n\n\t\t/* be_ctx->offset == length of encoded bitstream */\n\t\tcurr_offset += (duk_uint_fast32_t) be_ctx->offset;\n\t}\n\n\t/* compact */\n\tnew_size = (duk_size_t) curr_offset;\n\tduk_hbuffer_resize(thr, h_buf, new_size);\n\n\t(void) duk_to_fixed_buffer(ctx, -1, NULL);\n\n\tDUK_DDD(DUK_DDDPRINT(\"final pc2line data: pc_limit=%ld, length=%ld, %lf bits/opcode --> %!ixT\",\n\t                     (long) length, (long) new_size, (double) new_size * 8.0 / (double) length,\n\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n}\n\n/* PC is unsigned.  If caller does PC arithmetic and gets a negative result,\n * it will map to a large PC which is out of bounds and causes a zero to be\n * returned.\n */\nDUK_LOCAL duk_uint_fast32_t duk__hobject_pc2line_query_raw(duk_hthread *thr, duk_hbuffer_fixed *buf, duk_uint_fast32_t pc) {\n\tduk_bitdecoder_ctx bd_ctx_alloc;\n\tduk_bitdecoder_ctx *bd_ctx = &bd_ctx_alloc;\n\tduk_uint32_t *hdr;\n\tduk_uint_fast32_t start_offset;\n\tduk_uint_fast32_t pc_limit;\n\tduk_uint_fast32_t hdr_index;\n\tduk_uint_fast32_t pc_base;\n\tduk_uint_fast32_t n;\n\tduk_uint_fast32_t curr_line;\n\n\tDUK_ASSERT(buf != NULL);\n\tDUK_ASSERT(!DUK_HBUFFER_HAS_DYNAMIC((duk_hbuffer *) buf) && !DUK_HBUFFER_HAS_EXTERNAL((duk_hbuffer *) buf));\n\tDUK_UNREF(thr);\n\n\t/*\n\t *  Use the index in the header to find the right starting point\n\t */\n\n\thdr_index = pc / DUK_PC2LINE_SKIP;\n\tpc_base = hdr_index * DUK_PC2LINE_SKIP;\n\tn = pc - pc_base;\n\n\tif (DUK_HBUFFER_FIXED_GET_SIZE(buf) <= sizeof(duk_uint32_t)) {\n\t\tDUK_DD(DUK_DDPRINT(\"pc2line lookup failed: buffer is smaller than minimal header\"));\n\t\tgoto pc2line_error;\n\t}\n\n\thdr = (duk_uint32_t *) (void *) DUK_HBUFFER_FIXED_GET_DATA_PTR(thr->heap, buf);\n\tpc_limit = hdr[0];\n\tif (pc >= pc_limit) {\n\t\t/* Note: pc is unsigned and cannot be negative */\n\t\tDUK_DD(DUK_DDPRINT(\"pc2line lookup failed: pc out of bounds (pc=%ld, limit=%ld)\",\n\t\t                   (long) pc, (long) pc_limit));\n\t\tgoto pc2line_error;\n\t}\n\n\tcurr_line = hdr[1 + hdr_index * 2];\n\tstart_offset = hdr[1 + hdr_index * 2 + 1];\n\tif ((duk_size_t) start_offset > DUK_HBUFFER_FIXED_GET_SIZE(buf)) {\n\t\tDUK_DD(DUK_DDPRINT(\"pc2line lookup failed: start_offset out of bounds (start_offset=%ld, buffer_size=%ld)\",\n\t\t                   (long) start_offset, (long) DUK_HBUFFER_GET_SIZE((duk_hbuffer *) buf)));\n\t\tgoto pc2line_error;\n\t}\n\n\t/*\n\t *  Iterate the bitstream (line diffs) until PC is reached\n\t */\n\n\tDUK_MEMZERO(bd_ctx, sizeof(*bd_ctx));\n\tbd_ctx->data = ((duk_uint8_t *) hdr) + start_offset;\n\tbd_ctx->length = (duk_size_t) (DUK_HBUFFER_FIXED_GET_SIZE(buf) - start_offset);\n\n#if 0\n\tDUK_DDD(DUK_DDDPRINT(\"pc2line lookup: pc=%ld -> hdr_index=%ld, pc_base=%ld, n=%ld, start_offset=%ld\",\n\t                     (long) pc, (long) hdr_index, (long) pc_base, (long) n, (long) start_offset));\n#endif\n\n\twhile (n > 0) {\n#if 0\n\t\tDUK_DDD(DUK_DDDPRINT(\"lookup: n=%ld, curr_line=%ld\", (long) n, (long) curr_line));\n#endif\n\n\t\tif (duk_bd_decode_flag(bd_ctx)) {\n\t\t\tif (duk_bd_decode_flag(bd_ctx)) {\n\t\t\t\tif (duk_bd_decode_flag(bd_ctx)) {\n\t\t\t\t\t/* 1 1 1 <32 bits> */\n\t\t\t\t\tduk_uint_fast32_t t;\n\t\t\t\t\tt = duk_bd_decode(bd_ctx, 16);  /* workaround: max nbits = 24 now */\n\t\t\t\t\tt = (t << 16) + duk_bd_decode(bd_ctx, 16);\n\t\t\t\t\tcurr_line = t;\n\t\t\t\t} else {\n\t\t\t\t\t/* 1 1 0 <8 bits> */\n\t\t\t\t\tduk_uint_fast32_t t;\n\t\t\t\t\tt = duk_bd_decode(bd_ctx, 8);\n\t\t\t\t\tcurr_line = curr_line + t - 0x80;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t/* 1 0 <2 bits> */\n\t\t\t\tduk_uint_fast32_t t;\n\t\t\t\tt = duk_bd_decode(bd_ctx, 2);\n\t\t\t\tcurr_line = curr_line + t + 1;\n\t\t\t}\n\t\t} else {\n\t\t\t/* 0: no change */\n\t\t}\n\n\t\tn--;\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"pc2line lookup result: pc %ld -> line %ld\", (long) pc, (long) curr_line));\n\treturn curr_line;\n\n pc2line_error:\n\tDUK_D(DUK_DPRINT(\"pc2line conversion failed for pc=%ld\", (long) pc));\n\treturn 0;\n}\n\nDUK_INTERNAL duk_uint_fast32_t duk_hobject_pc2line_query(duk_context *ctx, duk_idx_t idx_func, duk_uint_fast32_t pc) {\n\tduk_hbuffer_fixed *pc2line;\n\tduk_uint_fast32_t line;\n\n\t/* XXX: now that pc2line is used by the debugger quite heavily in\n\t * checked execution, this should be optimized to avoid value stack\n\t * and perhaps also implement some form of pc2line caching (see\n\t * future work in debugger.rst).\n\t */\n\n\tduk_get_prop_stridx(ctx, idx_func, DUK_STRIDX_INT_PC2LINE);\n\tpc2line = (duk_hbuffer_fixed *) duk_get_hbuffer(ctx, -1);\n\tif (pc2line != NULL) {\n\t\tDUK_ASSERT(!DUK_HBUFFER_HAS_DYNAMIC((duk_hbuffer *) pc2line) && !DUK_HBUFFER_HAS_EXTERNAL((duk_hbuffer *) pc2line));\n\t\tline = duk__hobject_pc2line_query_raw((duk_hthread *) ctx, pc2line, (duk_uint_fast32_t) pc);\n\t} else {\n\t\tline = 0;\n\t}\n\tduk_pop(ctx);\n\n\treturn line;\n}\n\n#endif  /* DUK_USE_PC2LINE */\n/*\n *  duk_hobject property access functionality.\n *\n *  This is very central functionality for size, performance, and compliance.\n *  It is also rather intricate; see hobject-algorithms.rst for discussion on\n *  the algorithms and memory-management.rst for discussion on refcounts and\n *  side effect issues.\n *\n *  Notes:\n *\n *    - It might be tempting to assert \"refcount nonzero\" for objects\n *      being operated on, but that's not always correct: objects with\n *      a zero refcount may be operated on by the refcount implementation\n *      (finalization) for instance.  Hence, no refcount assertions are made.\n *\n *    - Many operations (memory allocation, identifier operations, etc)\n *      may cause arbitrary side effects (e.g. through GC and finalization).\n *      These side effects may invalidate duk_tval pointers which point to\n *      areas subject to reallocation (like value stack).  Heap objects\n *      themselves have stable pointers.  Holding heap object pointers or\n *      duk_tval copies is not problematic with respect to side effects;\n *      care must be taken when holding and using argument duk_tval pointers.\n *\n *    - If a finalizer is executed, it may operate on the the same object\n *      we're currently dealing with.  For instance, the finalizer might\n *      delete a certain property which has already been looked up and\n *      confirmed to exist.  Ideally finalizers would be disabled if GC\n *      happens during property access.  At the moment property table realloc\n *      disables finalizers, and all DECREFs may cause arbitrary changes so\n *      handle DECREF carefully.\n *\n *    - The order of operations for a DECREF matters.  When DECREF is executed,\n *      the entire object graph must be consistent; note that a refzero may\n *      lead to a mark-and-sweep through a refcount finalizer.  Use NORZ macros\n *      and an explicit DUK_REFZERO_CHECK_xxx() if achieving correct order is hard.\n */\n\n/*\n *  XXX: array indices are mostly typed as duk_uint32_t here; duk_uarridx_t\n *  might be more appropriate.\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Local defines\n */\n\n#define DUK__NO_ARRAY_INDEX             DUK_HSTRING_NO_ARRAY_INDEX\n\n/* marker values for hash part */\n#define DUK__HASH_UNUSED                DUK_HOBJECT_HASHIDX_UNUSED\n#define DUK__HASH_DELETED               DUK_HOBJECT_HASHIDX_DELETED\n\n/* valstack space that suffices for all local calls, including recursion\n * of other than Duktape calls (getters etc)\n */\n#define DUK__VALSTACK_SPACE             10\n\n/* valstack space allocated especially for proxy lookup which does a\n * recursive property lookup\n */\n#define DUK__VALSTACK_PROXY_LOOKUP      20\n\n/*\n *  Local prototypes\n */\n\nDUK_LOCAL_DECL duk_bool_t duk__check_arguments_map_for_get(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *temp_desc);\nDUK_LOCAL_DECL void duk__check_arguments_map_for_put(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *temp_desc, duk_bool_t throw_flag);\nDUK_LOCAL_DECL void duk__check_arguments_map_for_delete(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *temp_desc);\n\nDUK_LOCAL_DECL duk_bool_t duk__handle_put_array_length_smaller(duk_hthread *thr, duk_hobject *obj, duk_uint32_t old_len, duk_uint32_t new_len, duk_bool_t force_flag, duk_uint32_t *out_result_len);\nDUK_LOCAL_DECL duk_bool_t duk__handle_put_array_length(duk_hthread *thr, duk_hobject *obj);\n\nDUK_LOCAL_DECL duk_bool_t duk__get_propdesc(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *out_desc, duk_small_uint_t flags);\nDUK_LOCAL_DECL duk_bool_t duk__get_own_propdesc_raw(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_uint32_t arr_idx, duk_propdesc *out_desc, duk_small_uint_t flags);\n\n/*\n *  Misc helpers\n */\n\n/* Convert a duk_tval number (caller checks) to a 32-bit index.  Returns\n * DUK__NO_ARRAY_INDEX if the number is not whole or not a valid array\n * index.\n */\n/* XXX: for fastints, could use a variant which assumes a double duk_tval\n * (and doesn't need to check for fastint again).\n */\nDUK_LOCAL duk_uint32_t duk__tval_number_to_arr_idx(duk_tval *tv) {\n\tduk_double_t dbl;\n\tduk_uint32_t idx;\n\n\tDUK_ASSERT(tv != NULL);\n\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv));\n\n\t/* -0 is accepted here as index 0 because ToString(-0) == \"0\" which is\n\t * in canonical form and thus an array index.\n\t */\n\tdbl = DUK_TVAL_GET_NUMBER(tv);\n\tidx = (duk_uint32_t) dbl;\n\tif ((duk_double_t) idx == dbl) {\n\t        /* Is whole and within 32 bit range.  If the value happens to be 0xFFFFFFFF,\n\t\t * it's not a valid array index but will then match DUK__NO_ARRAY_INDEX.\n\t\t */\n\t\treturn idx;\n\t}\n\treturn DUK__NO_ARRAY_INDEX;\n}\n\n#if defined(DUK_USE_FASTINT)\n/* Convert a duk_tval fastint (caller checks) to a 32-bit index. */\nDUK_LOCAL duk_uint32_t duk__tval_fastint_to_arr_idx(duk_tval *tv) {\n\tduk_int64_t t;\n\n\tDUK_ASSERT(tv != NULL);\n\tDUK_ASSERT(DUK_TVAL_IS_FASTINT(tv));\n\n\tt = DUK_TVAL_GET_FASTINT(tv);\n\tif ((t & ~0xffffffffULL) != 0) {\n\t\t/* Catches >0x100000000 and negative values. */\n\t\treturn DUK__NO_ARRAY_INDEX;\n\t}\n\n\t/* If the value happens to be 0xFFFFFFFF, it's not a valid array index\n\t * but will then match DUK__NO_ARRAY_INDEX.\n\t */\n\treturn (duk_uint32_t) t;\n}\n#endif  /* DUK_USE_FASTINT */\n\n/* Convert a duk_tval on the value stack (in a trusted index we don't validate)\n * to a string or symbol using ES2015 ToPropertyKey():\n * http://www.ecma-international.org/ecma-262/6.0/#sec-topropertykey.\n *\n * Also check if it's a valid array index and return that (or DUK__NO_ARRAY_INDEX\n * if not).\n */\nDUK_LOCAL duk_uint32_t duk__to_property_key(duk_context *ctx, duk_idx_t idx, duk_hstring **out_h) {\n\tduk_uint32_t arr_idx;\n\tduk_hstring *h;\n\tduk_tval *tv_dst;\n\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(out_h != NULL);\n\tDUK_ASSERT(duk_is_valid_index(ctx, idx));\n\tDUK_ASSERT(idx < 0);\n\n\t/* XXX: The revised ES2015 ToPropertyKey() handling (ES5.1 was just\n\t * ToString()) involves a ToPrimitive(), a symbol check, and finally\n\t * a ToString().  Figure out the best way to have a good fast path\n\t * but still be compliant and share code.\n\t */\n\n\ttv_dst = DUK_GET_TVAL_NEGIDX((duk_hthread *) ctx, idx);  /* intentionally unvalidated */\n\tif (DUK_TVAL_IS_STRING(tv_dst)) {\n\t\t/* Most important path: strings and plain symbols are used as\n\t\t * is.  For symbols the array index check below is unnecessary\n\t\t * (they're never valid array indices) but checking that the\n\t\t * string is a symbol would make the plain string path slower\n\t\t * unnecessarily.\n\t\t */\n\t\th = DUK_TVAL_GET_STRING(tv_dst);\n\t} else {\n\t\th = duk_to_property_key_hstring(ctx, idx);\n\t}\n\tDUK_ASSERT(h != NULL);\n\t*out_h = h;\n\n\tarr_idx = DUK_HSTRING_GET_ARRIDX_FAST(h);\n\treturn arr_idx;\n}\n\nDUK_LOCAL duk_uint32_t duk__push_tval_to_property_key(duk_context *ctx, duk_tval *tv_key, duk_hstring **out_h) {\n\tduk_push_tval(ctx, tv_key);  /* XXX: could use an unsafe push here */\n\treturn duk__to_property_key(ctx, -1, out_h);\n}\n\n/* String is an own (virtual) property of a lightfunc. */\nDUK_LOCAL duk_bool_t duk__key_is_lightfunc_ownprop(duk_hthread *thr, duk_hstring *key) {\n\tDUK_UNREF(thr);\n\treturn (key == DUK_HTHREAD_STRING_LENGTH(thr) ||\n\t        key == DUK_HTHREAD_STRING_NAME(thr));\n}\n\n/* String is an own (virtual) property of a plain buffer. */\nDUK_LOCAL duk_bool_t duk__key_is_plain_buf_ownprop(duk_hthread *thr, duk_hbuffer *buf, duk_hstring *key, duk_uint32_t arr_idx) {\n\tDUK_UNREF(thr);\n\n\t/* Virtual index properties.  Checking explicitly for\n\t * 'arr_idx != DUK__NO_ARRAY_INDEX' is not necessary\n\t * because DUK__NO_ARRAY_INDEXi is always larger than\n\t * maximum allowed buffer size.\n\t */\n\tDUK_ASSERT(DUK__NO_ARRAY_INDEX >= DUK_HBUFFER_GET_SIZE(buf));\n\tif (arr_idx < DUK_HBUFFER_GET_SIZE(buf)) {\n\t\treturn 1;\n\t}\n\n\t/* Other virtual properties. */\n\treturn (key == DUK_HTHREAD_STRING_LENGTH(thr));\n}\n\n/*\n *  Helpers for managing property storage size\n */\n\n/* Get default hash part size for a certain entry part size. */\n#if defined(DUK_USE_HOBJECT_HASH_PART)\nDUK_LOCAL duk_uint32_t duk__get_default_h_size(duk_uint32_t e_size) {\n\tDUK_ASSERT(e_size <= DUK_HOBJECT_MAX_PROPERTIES);\n\n\tif (e_size >= DUK_USE_HOBJECT_HASH_PROP_LIMIT) {\n\t\tduk_uint32_t res;\n\t\tduk_uint32_t tmp;\n\n\t\t/* Hash size should be 2^N where N is chosen so that 2^N is\n\t\t * larger than e_size.  Extra shifting is used to ensure hash\n\t\t * is relatively sparse.\n\t\t */\n\t\ttmp = e_size;\n\t\tres = 2;  /* Result will be 2 ** (N + 1). */\n\t\twhile (tmp >= 0x40) {\n\t\t\ttmp >>= 6;\n\t\t\tres <<= 6;\n\t\t}\n\t\twhile (tmp != 0) {\n\t\t\ttmp >>= 1;\n\t\t\tres <<= 1;\n\t\t}\n\t\tDUK_ASSERT((DUK_HOBJECT_MAX_PROPERTIES << 2U) > DUK_HOBJECT_MAX_PROPERTIES);  /* Won't wrap, even shifted by 2. */\n\t\tDUK_ASSERT(res > e_size);\n\t\treturn res;\n\t} else {\n\t\treturn 0;\n\t}\n}\n#endif  /* USE_PROP_HASH_PART */\n\n/* Get minimum entry part growth for a certain size. */\nDUK_LOCAL duk_uint32_t duk__get_min_grow_e(duk_uint32_t e_size) {\n\tduk_uint32_t res;\n\n\tDUK_ASSERT(e_size <= DUK_HOBJECT_MAX_PROPERTIES);\n\n\tres = (e_size + DUK_USE_HOBJECT_ENTRY_MINGROW_ADD) / DUK_USE_HOBJECT_ENTRY_MINGROW_DIVISOR;\n\tDUK_ASSERT(res >= 1);  /* important for callers */\n\treturn res;\n}\n\n/* Get minimum array part growth for a certain size. */\nDUK_LOCAL duk_uint32_t duk__get_min_grow_a(duk_uint32_t a_size) {\n\tduk_uint32_t res;\n\n\tDUK_ASSERT((duk_size_t) a_size <= DUK_HOBJECT_MAX_PROPERTIES);\n\n\tres = (a_size + DUK_USE_HOBJECT_ARRAY_MINGROW_ADD) / DUK_USE_HOBJECT_ARRAY_MINGROW_DIVISOR;\n\tDUK_ASSERT(res >= 1);  /* important for callers */\n\treturn res;\n}\n\n/* Count actually used entry part entries (non-NULL keys). */\nDUK_LOCAL duk_uint32_t duk__count_used_e_keys(duk_hthread *thr, duk_hobject *obj) {\n\tduk_uint_fast32_t i;\n\tduk_uint_fast32_t n = 0;\n\tduk_hstring **e;\n\n\tDUK_ASSERT(obj != NULL);\n\tDUK_UNREF(thr);\n\n\te = DUK_HOBJECT_E_GET_KEY_BASE(thr->heap, obj);\n\tfor (i = 0; i < DUK_HOBJECT_GET_ENEXT(obj); i++) {\n\t\tif (*e++) {\n\t\t\tn++;\n\t\t}\n\t}\n\treturn (duk_uint32_t) n;\n}\n\n/* Count actually used array part entries and array minimum size.\n * NOTE: 'out_min_size' can be computed much faster by starting from the\n * end and breaking out early when finding first used entry, but this is\n * not needed now.\n */\nDUK_LOCAL void duk__compute_a_stats(duk_hthread *thr, duk_hobject *obj, duk_uint32_t *out_used, duk_uint32_t *out_min_size) {\n\tduk_uint_fast32_t i;\n\tduk_uint_fast32_t used = 0;\n\tduk_uint_fast32_t highest_idx = (duk_uint_fast32_t) -1;  /* see below */\n\tduk_tval *a;\n\n\tDUK_ASSERT(obj != NULL);\n\tDUK_ASSERT(out_used != NULL);\n\tDUK_ASSERT(out_min_size != NULL);\n\tDUK_UNREF(thr);\n\n\ta = DUK_HOBJECT_A_GET_BASE(thr->heap, obj);\n\tfor (i = 0; i < DUK_HOBJECT_GET_ASIZE(obj); i++) {\n\t\tduk_tval *tv = a++;\n\t\tif (!DUK_TVAL_IS_UNUSED(tv)) {\n\t\t\tused++;\n\t\t\thighest_idx = i;\n\t\t}\n\t}\n\n\t/* Initial value for highest_idx is -1 coerced to unsigned.  This\n\t * is a bit odd, but (highest_idx + 1) will then wrap to 0 below\n\t * for out_min_size as intended.\n\t */\n\n\t*out_used = used;\n\t*out_min_size = highest_idx + 1;  /* 0 if no used entries */\n}\n\n/* Check array density and indicate whether or not the array part should be abandoned. */\nDUK_LOCAL duk_bool_t duk__abandon_array_density_check(duk_uint32_t a_used, duk_uint32_t a_size) {\n\t/*\n\t *  Array abandon check; abandon if:\n\t *\n\t *    new_used / new_size < limit\n\t *    new_used < limit * new_size        || limit is 3 bits fixed point\n\t *    new_used < limit' / 8 * new_size   || *8\n\t *    8*new_used < limit' * new_size     || :8\n\t *    new_used < limit' * (new_size / 8)\n\t *\n\t *  Here, new_used = a_used, new_size = a_size.\n\t *\n\t *  Note: some callers use approximate values for a_used and/or a_size\n\t *  (e.g. dropping a '+1' term).  This doesn't affect the usefulness\n\t *  of the check, but may confuse debugging.\n\t */\n\n\treturn (a_used < DUK_USE_HOBJECT_ARRAY_ABANDON_LIMIT * (a_size >> 3));\n}\n\n/* Fast check for extending array: check whether or not a slow density check is required. */\nDUK_LOCAL duk_bool_t duk__abandon_array_slow_check_required(duk_uint32_t arr_idx, duk_uint32_t old_size) {\n\t/*\n\t *  In a fast check we assume old_size equals old_used (i.e., existing\n\t *  array is fully dense).\n\t *\n\t *  Slow check if:\n\t *\n\t *    (new_size - old_size) / old_size > limit\n\t *    new_size - old_size > limit * old_size\n\t *    new_size > (1 + limit) * old_size        || limit' is 3 bits fixed point\n\t *    new_size > (1 + (limit' / 8)) * old_size || * 8\n\t *    8 * new_size > (8 + limit') * old_size   || : 8\n\t *    new_size > (8 + limit') * (old_size / 8)\n\t *    new_size > limit'' * (old_size / 8)      || limit'' = 9 -> max 25% increase\n\t *    arr_idx + 1 > limit'' * (old_size / 8)\n\t *\n\t *  This check doesn't work well for small values, so old_size is rounded\n\t *  up for the check (and the '+ 1' of arr_idx can be ignored in practice):\n\t *\n\t *    arr_idx > limit'' * ((old_size + 7) / 8)\n\t */\n\n\treturn (arr_idx > DUK_USE_HOBJECT_ARRAY_FAST_RESIZE_LIMIT * ((old_size + 7) >> 3));\n}\n\n/*\n *  Proxy helpers\n */\n\n#if defined(DUK_USE_ES6_PROXY)\nDUK_INTERNAL duk_bool_t duk_hobject_proxy_check(duk_hthread *thr, duk_hobject *obj, duk_hobject **out_target, duk_hobject **out_handler) {\n\tduk_tval *tv_target;\n\tduk_tval *tv_handler;\n\tduk_hobject *h_target;\n\tduk_hobject *h_handler;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(obj != NULL);\n\tDUK_ASSERT(out_target != NULL);\n\tDUK_ASSERT(out_handler != NULL);\n\n\t/* Caller doesn't need to check exotic proxy behavior (but does so for\n\t * some fast paths).\n\t */\n\tif (DUK_LIKELY(!DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(obj))) {\n\t\treturn 0;\n\t}\n\n\ttv_handler = duk_hobject_find_existing_entry_tval_ptr(thr->heap, obj, DUK_HTHREAD_STRING_INT_HANDLER(thr));\n\tif (!tv_handler) {\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_PROXY_REVOKED);\n\t\treturn 0;\n\t}\n\tDUK_ASSERT(DUK_TVAL_IS_OBJECT(tv_handler));\n\th_handler = DUK_TVAL_GET_OBJECT(tv_handler);\n\tDUK_ASSERT(h_handler != NULL);\n\t*out_handler = h_handler;\n\ttv_handler = NULL;  /* avoid issues with relocation */\n\n\ttv_target = duk_hobject_find_existing_entry_tval_ptr(thr->heap, obj, DUK_HTHREAD_STRING_INT_TARGET(thr));\n\tif (!tv_target) {\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_PROXY_REVOKED);\n\t\treturn 0;\n\t}\n\tDUK_ASSERT(DUK_TVAL_IS_OBJECT(tv_target));\n\th_target = DUK_TVAL_GET_OBJECT(tv_target);\n\tDUK_ASSERT(h_target != NULL);\n\t*out_target = h_target;\n\ttv_target = NULL;  /* avoid issues with relocation */\n\n\treturn 1;\n}\n#endif  /* DUK_USE_ES6_PROXY */\n\n/* Get Proxy target object.  If the argument is not a Proxy, return it as is.\n * If a Proxy is revoked, an error is thrown.\n */\n#if defined(DUK_USE_ES6_PROXY)\nDUK_INTERNAL duk_hobject *duk_hobject_resolve_proxy_target(duk_hthread *thr, duk_hobject *obj) {\n\tduk_hobject *h_target;\n\tduk_hobject *h_handler;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(obj != NULL);\n\n\t/* Resolve Proxy targets until Proxy chain ends.  No explicit check for\n\t * a Proxy loop: user code cannot create such a loop without tweaking\n\t * internal properties directly.\n\t */\n\n\twhile (DUK_UNLIKELY(DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(obj))) {\n\t\tif (duk_hobject_proxy_check(thr, obj, &h_target, &h_handler)) {\n\t\t\tDUK_ASSERT(h_target != NULL);\n\t\t\tobj = h_target;\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tDUK_ASSERT(obj != NULL);\n\treturn obj;\n}\n#endif  /* DUK_USE_ES6_PROXY */\n\n#if defined(DUK_USE_ES6_PROXY)\nDUK_LOCAL duk_bool_t duk__proxy_check_prop(duk_hthread *thr, duk_hobject *obj, duk_small_uint_t stridx_trap, duk_tval *tv_key, duk_hobject **out_target) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hobject *h_handler;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(obj != NULL);\n\tDUK_ASSERT(tv_key != NULL);\n\tDUK_ASSERT(out_target != NULL);\n\n\tif (!duk_hobject_proxy_check(thr, obj, out_target, &h_handler)) {\n\t\treturn 0;\n\t}\n\tDUK_ASSERT(*out_target != NULL);\n\tDUK_ASSERT(h_handler != NULL);\n\n\t/* XXX: At the moment Duktape accesses internal keys like _Finalizer using a\n\t * normal property set/get which would allow a proxy handler to interfere with\n\t * such behavior and to get access to internal key strings.  This is not a problem\n\t * as such because internal key strings can be created in other ways too (e.g.\n\t * through buffers).  The best fix is to change Duktape internal lookups to\n\t * skip proxy behavior.  Until that, internal property accesses bypass the\n\t * proxy and are applied to the target (as if the handler did not exist).\n\t * This has some side effects, see test-bi-proxy-internal-keys.js.\n\t */\n\n\tif (DUK_TVAL_IS_STRING(tv_key)) {\n\t\tduk_hstring *h_key = (duk_hstring *) DUK_TVAL_GET_STRING(tv_key);\n\t\tDUK_ASSERT(h_key != NULL);\n\t\tif (DUK_HSTRING_HAS_HIDDEN(h_key)) {\n\t\t\t/* Symbol accesses must go through proxy lookup in ES2015.\n\t\t\t * Hidden symbols behave like Duktape 1.x internal keys\n\t\t\t * and currently won't.\n\t\t\t */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"hidden key, skip proxy handler and apply to target\"));\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\t/* The handler is looked up with a normal property lookup; it may be an\n\t * accessor or the handler object itself may be a proxy object.  If the\n\t * handler is a proxy, we need to extend the valstack as we make a\n\t * recursive proxy check without a function call in between (in fact\n\t * there is no limit to the potential recursion here).\n\t *\n\t * (For sanity, proxy creation rejects another proxy object as either\n\t * the handler or the target at the moment so recursive proxy cases\n\t * are not realized now.)\n\t */\n\n\t/* XXX: C recursion limit if proxies are allowed as handler/target values */\n\n\tduk_require_stack(ctx, DUK__VALSTACK_PROXY_LOOKUP);\n\tduk_push_hobject(ctx, h_handler);\n\tif (duk_get_prop_stridx_short(ctx, -1, stridx_trap)) {\n\t\t/* -> [ ... handler trap ] */\n\t\tduk_insert(ctx, -2);  /* -> [ ... trap handler ] */\n\n\t\t/* stack prepped for func call: [ ... trap handler ] */\n\t\treturn 1;\n\t} else {\n\t\tduk_pop_2(ctx);\n\t\treturn 0;\n\t}\n}\n#endif  /* DUK_USE_ES6_PROXY */\n\n/*\n *  Reallocate property allocation, moving properties to the new allocation.\n *\n *  Includes key compaction, rehashing, and can also optionally abandon\n *  the array part, 'migrating' array entries into the beginning of the\n *  new entry part.\n *\n *  There is no support for in-place reallocation or just compacting keys\n *  without resizing the property allocation.  This is intentional to keep\n *  code size minimal, but would be useful future work.\n *\n *  The implementation is relatively straightforward, except for the array\n *  abandonment process.  Array abandonment requires that new string keys\n *  are interned, which may trigger GC.  All keys interned so far must be\n *  reachable for GC at all times and correctly refcounted for; valstack is\n *  used for that now.\n *\n *  Also, a GC triggered during this reallocation process must not interfere\n *  with the object being resized.  This is currently controlled by preventing\n *  finalizers (as they may affect ANY object) and object compaction in\n *  mark-and-sweep.  It would suffice to protect only this particular object\n *  from compaction, however.  DECREF refzero cascades are side effect free\n *  and OK.\n *\n *  Note: because we need to potentially resize the valstack (as part\n *  of abandoning the array part), any tval pointers to the valstack\n *  will become invalid after this call.\n */\n\nDUK_INTERNAL void duk_hobject_realloc_props(duk_hthread *thr,\n                                            duk_hobject *obj,\n                                            duk_uint32_t new_e_size,\n                                            duk_uint32_t new_a_size,\n                                            duk_uint32_t new_h_size,\n                                            duk_bool_t abandon_array) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_small_uint_t prev_ms_base_flags;\n\tduk_uint32_t new_alloc_size;\n\tduk_uint32_t new_e_size_adjusted;\n\tduk_uint8_t *new_p;\n\tduk_hstring **new_e_k;\n\tduk_propvalue *new_e_pv;\n\tduk_uint8_t *new_e_f;\n\tduk_tval *new_a;\n\tduk_uint32_t *new_h;\n\tduk_uint32_t new_e_next;\n\tduk_uint_fast32_t i;\n\tduk_size_t array_copy_size;\n#if defined(DUK_USE_ASSERTIONS)\n\tduk_bool_t prev_error_not_allowed;\n#endif\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(obj != NULL);\n\tDUK_ASSERT(!abandon_array || new_a_size == 0);  /* if abandon_array, new_a_size must be 0 */\n\tDUK_ASSERT(DUK_HOBJECT_GET_PROPS(thr->heap, obj) != NULL || (DUK_HOBJECT_GET_ESIZE(obj) == 0 && DUK_HOBJECT_GET_ASIZE(obj) == 0));\n\tDUK_ASSERT(new_h_size == 0 || new_h_size >= new_e_size);  /* required to guarantee success of rehashing,\n\t                                                           * intentionally use unadjusted new_e_size\n\t                                                           */\n\tDUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj));\n\tDUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);\n\n\t/*\n\t *  Pre resize assertions.\n\t */\n\n#if defined(DUK_USE_ASSERTIONS)\n\t/* XXX: pre-checks (such as no duplicate keys) */\n#endif\n\n\t/*\n\t *  For property layout 1, tweak e_size to ensure that the whole entry\n\t *  part (key + val + flags) is a suitable multiple for alignment\n\t *  (platform specific).\n\t *\n\t *  Property layout 2 does not require this tweaking and is preferred\n\t *  on low RAM platforms requiring alignment.\n\t */\n\n#if defined(DUK_USE_HOBJECT_LAYOUT_2) || defined(DUK_USE_HOBJECT_LAYOUT_3)\n\tDUK_DDD(DUK_DDDPRINT(\"using layout 2 or 3, no need to pad e_size: %ld\", (long) new_e_size));\n\tnew_e_size_adjusted = new_e_size;\n#elif defined(DUK_USE_HOBJECT_LAYOUT_1) && (DUK_HOBJECT_ALIGN_TARGET == 1)\n\tDUK_DDD(DUK_DDDPRINT(\"using layout 1, but no need to pad e_size: %ld\", (long) new_e_size));\n\tnew_e_size_adjusted = new_e_size;\n#elif defined(DUK_USE_HOBJECT_LAYOUT_1) && ((DUK_HOBJECT_ALIGN_TARGET == 4) || (DUK_HOBJECT_ALIGN_TARGET == 8))\n\tnew_e_size_adjusted = (new_e_size + DUK_HOBJECT_ALIGN_TARGET - 1) & (~(DUK_HOBJECT_ALIGN_TARGET - 1));\n\tDUK_DDD(DUK_DDDPRINT(\"using layout 1, and alignment target is %ld, adjusted e_size: %ld -> %ld\",\n\t                     (long) DUK_HOBJECT_ALIGN_TARGET, (long) new_e_size, (long) new_e_size_adjusted));\n\tDUK_ASSERT(new_e_size_adjusted >= new_e_size);\n#else\n#error invalid hobject layout defines\n#endif\n\n\t/*\n\t *  Debug logging after adjustment.\n\t */\n\n\tDUK_DDD(DUK_DDDPRINT(\"attempt to resize hobject %p props (%ld -> %ld bytes), from {p=%p,e_size=%ld,e_next=%ld,a_size=%ld,h_size=%ld} to \"\n\t                     \"{e_size=%ld,a_size=%ld,h_size=%ld}, abandon_array=%ld, unadjusted new_e_size=%ld\",\n\t                     (void *) obj,\n\t                     (long) DUK_HOBJECT_P_COMPUTE_SIZE(DUK_HOBJECT_GET_ESIZE(obj),\n\t                                                       DUK_HOBJECT_GET_ASIZE(obj),\n\t                                                       DUK_HOBJECT_GET_HSIZE(obj)),\n\t                     (long) DUK_HOBJECT_P_COMPUTE_SIZE(new_e_size_adjusted, new_a_size, new_h_size),\n\t                     (void *) DUK_HOBJECT_GET_PROPS(thr->heap, obj),\n\t                     (long) DUK_HOBJECT_GET_ESIZE(obj),\n\t                     (long) DUK_HOBJECT_GET_ENEXT(obj),\n\t                     (long) DUK_HOBJECT_GET_ASIZE(obj),\n\t                     (long) DUK_HOBJECT_GET_HSIZE(obj),\n\t                     (long) new_e_size_adjusted,\n\t                     (long) new_a_size,\n\t                     (long) new_h_size,\n\t                     (long) abandon_array,\n\t                     (long) new_e_size));\n\n\t/*\n\t *  Property count check.  This is the only point where we ensure that\n\t *  we don't get more (allocated) property space that we can handle.\n\t *  There aren't hard limits as such, but some algorithms may fail\n\t *  if we get too close to the 4G property limit.\n\t *\n\t *  Since this works based on allocation size (not actually used size),\n\t *  the limit is a bit approximate but good enough in practice.\n\t */\n\n\tif (new_e_size_adjusted + new_a_size > DUK_HOBJECT_MAX_PROPERTIES) {\n\t\tDUK_ERROR_ALLOC_FAILED(thr);\n\t}\n\n\t/*\n\t *  Compute new alloc size and alloc new area.\n\t *\n\t *  The new area is not tracked in the heap at all, so it's critical\n\t *  we get to free/keep it in a controlled manner.\n\t */\n\n#if defined(DUK_USE_ASSERTIONS)\n\t/* Whole path must be error throw free, but we may be called from\n\t * within error handling so can't assert for error_not_allowed == 0.\n\t */\n\tprev_error_not_allowed = thr->heap->error_not_allowed;\n\tthr->heap->error_not_allowed = 1;\n#endif\n\tprev_ms_base_flags = thr->heap->ms_base_flags;\n\tthr->heap->ms_base_flags |=\n\t        DUK_MS_FLAG_NO_OBJECT_COMPACTION;      /* Avoid attempt to compact the current object (all objects really). */\n\tthr->heap->pf_prevent_count++;                 /* Avoid finalizers. */\n\tDUK_ASSERT(thr->heap->pf_prevent_count != 0);  /* Wrap. */\n\n\tnew_alloc_size = DUK_HOBJECT_P_COMPUTE_SIZE(new_e_size_adjusted, new_a_size, new_h_size);\n\tDUK_DDD(DUK_DDDPRINT(\"new hobject allocation size is %ld\", (long) new_alloc_size));\n\tif (new_alloc_size == 0) {\n\t\tDUK_ASSERT(new_e_size_adjusted == 0);\n\t\tDUK_ASSERT(new_a_size == 0);\n\t\tDUK_ASSERT(new_h_size == 0);\n\t\tnew_p = NULL;\n\t} else {\n\t\t/* Alloc may trigger mark-and-sweep but no compaction, and\n\t\t * cannot throw.\n\t\t */\n#if 0  /* XXX: inject test */\n\t\tif (1) {\n\t\t\tgoto alloc_failed;\n\t\t}\n#endif\n\t\tnew_p = (duk_uint8_t *) DUK_ALLOC(thr->heap, new_alloc_size);\n\t\tif (new_p == NULL) {\n\t\t\t/* NULL always indicates alloc failure because\n\t\t\t * new_alloc_size > 0.\n\t\t\t */\n\t\t\tgoto alloc_failed;\n\t\t}\n\t}\n\n\t/* Set up pointers to the new property area: this is hidden behind a macro\n\t * because it is memory layout specific.\n\t */\n\tDUK_HOBJECT_P_SET_REALLOC_PTRS(new_p, new_e_k, new_e_pv, new_e_f, new_a, new_h,\n\t                               new_e_size_adjusted, new_a_size, new_h_size);\n\tDUK_UNREF(new_h);  /* happens when hash part dropped */\n\tnew_e_next = 0;\n\n\t/* if new_p == NULL, all of these pointers are NULL */\n\tDUK_ASSERT((new_p != NULL) ||\n\t           (new_e_k == NULL && new_e_pv == NULL && new_e_f == NULL &&\n\t            new_a == NULL && new_h == NULL));\n\n\tDUK_DDD(DUK_DDDPRINT(\"new alloc size %ld, new_e_k=%p, new_e_pv=%p, new_e_f=%p, new_a=%p, new_h=%p\",\n\t                     (long) new_alloc_size, (void *) new_e_k, (void *) new_e_pv, (void *) new_e_f,\n\t                     (void *) new_a, (void *) new_h));\n\n\t/*\n\t *  Migrate array part to start of entries if requested.\n\t *\n\t *  Note: from an enumeration perspective the order of entry keys matters.\n\t *  Array keys should appear wherever they appeared before the array abandon\n\t *  operation.  (This no longer matters much because keys are ES2015 sorted.)\n\t */\n\n\tif (abandon_array) {\n\t\t/* Assuming new_a_size == 0, and that entry part contains\n\t\t * no conflicting keys, refcounts do not need to be adjusted for\n\t\t * the values, as they remain exactly the same.\n\t\t *\n\t\t * The keys, however, need to be interned, incref'd, and be\n\t\t * reachable for GC.  Any intern attempt may trigger a GC and\n\t\t * claim any non-reachable strings, so every key must be reachable\n\t\t * at all times.  Refcounts must be correct to satisfy refcount\n\t\t * assertions.\n\t\t *\n\t\t * A longjmp must not occur here, as the new_p allocation would\n\t\t * leak.  Refcounts would come out correctly as the interned\n\t\t * strings are valstack tracked.\n\t\t */\n\t\tDUK_ASSERT(new_a_size == 0);\n\n\t\tfor (i = 0; i < DUK_HOBJECT_GET_ASIZE(obj); i++) {\n\t\t\tduk_tval *tv1;\n\t\t\tduk_tval *tv2;\n\t\t\tduk_hstring *key;\n\n\t\t\tDUK_ASSERT(DUK_HOBJECT_GET_PROPS(thr->heap, obj) != NULL);\n\n\t\t\ttv1 = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, obj, i);\n\t\t\tif (DUK_TVAL_IS_UNUSED(tv1)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tDUK_ASSERT(new_p != NULL && new_e_k != NULL &&\n\t\t\t           new_e_pv != NULL && new_e_f != NULL);\n\n\t\t\t/*\n\t\t\t *  Intern key via the valstack to ensure reachability behaves\n\t\t\t *  properly.  We must avoid longjmp's here so use non-checked\n\t\t\t *  primitives.\n\t\t\t *\n\t\t\t *  Note: duk_check_stack() potentially reallocs the valstack,\n\t\t\t *  invalidating any duk_tval pointers to valstack.  Callers\n\t\t\t *  must be careful.\n\t\t\t */\n\n#if 0  /* XXX: inject test */\n\t\t\tif (1) {\n\t\t\t\tgoto abandon_error;\n\t\t\t}\n#endif\n\t\t\t/* Never shrinks; auto-adds DUK_VALSTACK_INTERNAL_EXTRA, which\n\t\t\t * is generous.\n\t\t\t */\n\t\t\tif (!duk_check_stack(ctx, 1)) {\n\t\t\t\tgoto abandon_error;\n\t\t\t}\n\t\t\tDUK_ASSERT_VALSTACK_SPACE(thr, 1);\n\t\t\tkey = duk_heap_strtable_intern_u32(thr->heap, i);\n\t\t\tif (key == NULL) {\n\t\t\t\tgoto abandon_error;\n\t\t\t}\n\t\t\tduk_push_hstring(ctx, key);  /* keep key reachable for GC etc; guaranteed not to fail */\n\n\t\t\t/* Key is now reachable in the valstack, don't INCREF\n\t\t\t * the new allocation yet (we'll steal the refcounts\n\t\t\t * from the value stack once all keys are done).\n\t\t\t */\n\n\t\t\tnew_e_k[new_e_next] = key;\n\t\t\ttv2 = &new_e_pv[new_e_next].v;  /* array entries are all plain values */\n\t\t\tDUK_TVAL_SET_TVAL(tv2, tv1);\n\t\t\tnew_e_f[new_e_next] = DUK_PROPDESC_FLAG_WRITABLE |\n\t\t\t                      DUK_PROPDESC_FLAG_ENUMERABLE |\n\t\t\t                      DUK_PROPDESC_FLAG_CONFIGURABLE;\n\t\t\tnew_e_next++;\n\n\t\t\t/* Note: new_e_next matches pushed temp key count, and nothing can\n\t\t\t * fail above between the push and this point.\n\t\t\t */\n\t\t}\n\n\t\t/* Steal refcounts from value stack. */\n\t\tDUK_DDD(DUK_DDDPRINT(\"abandon array: pop %ld key temps from valstack\", (long) new_e_next));\n\t\tduk_pop_n_nodecref_unsafe(ctx, new_e_next);\n\t}\n\n\t/*\n\t *  Copy keys and values in the entry part (compacting them at the same time).\n\t */\n\n\tfor (i = 0; i < DUK_HOBJECT_GET_ENEXT(obj); i++) {\n\t\tduk_hstring *key;\n\n\t\tDUK_ASSERT(DUK_HOBJECT_GET_PROPS(thr->heap, obj) != NULL);\n\n\t\tkey = DUK_HOBJECT_E_GET_KEY(thr->heap, obj, i);\n\t\tif (key == NULL) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tDUK_ASSERT(new_p != NULL && new_e_k != NULL &&\n\t\t           new_e_pv != NULL && new_e_f != NULL);\n\n\t\tnew_e_k[new_e_next] = key;\n\t\tnew_e_pv[new_e_next] = DUK_HOBJECT_E_GET_VALUE(thr->heap, obj, i);\n\t\tnew_e_f[new_e_next] = DUK_HOBJECT_E_GET_FLAGS(thr->heap, obj, i);\n\t\tnew_e_next++;\n\t}\n\t/* the entries [new_e_next, new_e_size_adjusted[ are left uninitialized on purpose (ok, not gc reachable) */\n\n\t/*\n\t *  Copy array elements to new array part.  If the new array part is\n\t *  larger, initialize the unused entries as UNUSED because they are\n\t *  GC reachable.\n\t */\n\n#if defined(DUK_USE_ASSERTIONS)\n\t/* Caller must have decref'd values above new_a_size (if that is necessary). */\n\tif (!abandon_array) {\n\t\tfor (i = new_a_size; i < DUK_HOBJECT_GET_ASIZE(obj); i++) {\n\t\t\tduk_tval *tv;\n\t\t\ttv = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, obj, i);\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_UNUSED(tv));\n\t\t}\n\t}\n#endif\n\tif (new_a_size > DUK_HOBJECT_GET_ASIZE(obj)) {\n\t\tarray_copy_size = sizeof(duk_tval) * DUK_HOBJECT_GET_ASIZE(obj);\n\t} else {\n\t\tarray_copy_size = sizeof(duk_tval) * new_a_size;\n\t}\n\tif (array_copy_size > 0) {\n\t\t/* Avoid zero copy with an invalid pointer.  If obj->p is NULL,\n\t\t * the 'new_a' pointer will be invalid which is not allowed even\n\t\t * when copy size is zero.\n\t\t */\n\t\tDUK_ASSERT(new_a != NULL);\n\t\tDUK_ASSERT(DUK_HOBJECT_GET_PROPS(thr->heap, obj) != NULL);\n\t\tDUK_ASSERT(DUK_HOBJECT_GET_ASIZE(obj) > 0);\n\t\tDUK_MEMCPY((void *) new_a,\n\t\t           (const void *) DUK_HOBJECT_A_GET_BASE(thr->heap, obj),\n\t\t           array_copy_size);\n\t}\n\tfor (i = DUK_HOBJECT_GET_ASIZE(obj); i < new_a_size; i++) {\n\t\tduk_tval *tv = &new_a[i];\n\t\tDUK_TVAL_SET_UNUSED(tv);\n\t}\n\n\t/*\n\t *  Rebuild the hash part always from scratch (guaranteed to finish\n\t *  as long as caller gave consistent parameters).\n\t *\n\t *  Any resize of hash part requires rehashing.  In addition, by rehashing\n\t *  get rid of any elements marked deleted (DUK__HASH_DELETED) which is critical\n\t *  to ensuring the hash part never fills up.\n\t */\n\n#if defined(DUK_USE_HOBJECT_HASH_PART)\n\tif (new_h_size == 0) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"no hash part, no rehash\"));\n\t} else {\n\t\tduk_uint32_t mask;\n\n\t\tDUK_ASSERT(new_h != NULL);\n\n\t\t/* fill new_h with u32 0xff = UNUSED */\n\t\tDUK_ASSERT(DUK_HOBJECT_GET_PROPS(thr->heap, obj) != NULL);\n\t\tDUK_ASSERT(new_h_size > 0);\n\t\tDUK_MEMSET(new_h, 0xff, sizeof(duk_uint32_t) * new_h_size);\n\n\t\tDUK_ASSERT(new_e_next <= new_h_size);  /* equality not actually possible */\n\n\t\tmask = new_h_size - 1;\n\t\tfor (i = 0; i < new_e_next; i++) {\n\t\t\tduk_hstring *key = new_e_k[i];\n\t\t\tduk_uint32_t j, step;\n\n\t\t\tDUK_ASSERT(key != NULL);\n\t\t\tj = DUK_HSTRING_GET_HASH(key) & mask;\n\t\t\tstep = 1;  /* Cache friendly but clustering prone. */\n\n\t\t\tfor (;;) {\n\t\t\t\tDUK_ASSERT(new_h[j] != DUK__HASH_DELETED);  /* should never happen */\n\t\t\t\tif (new_h[j] == DUK__HASH_UNUSED) {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"rebuild hit %ld -> %ld\", (long) j, (long) i));\n\t\t\t\t\tnew_h[j] = i;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"rebuild miss %ld, step %ld\", (long) j, (long) step));\n\t\t\t\tj = (j + step) & mask;\n\n\t\t\t\t/* Guaranteed to finish (hash is larger than #props). */\n\t\t\t}\n\t\t}\n\t}\n#endif  /* DUK_USE_HOBJECT_HASH_PART */\n\n\t/*\n\t *  Nice debug log.\n\t */\n\n\tDUK_DD(DUK_DDPRINT(\"resized hobject %p props (%ld -> %ld bytes), from {p=%p,e_size=%ld,e_next=%ld,a_size=%ld,h_size=%ld} to \"\n\t                   \"{p=%p,e_size=%ld,e_next=%ld,a_size=%ld,h_size=%ld}, abandon_array=%ld, unadjusted new_e_size=%ld\",\n\t                   (void *) obj,\n\t                   (long) DUK_HOBJECT_P_COMPUTE_SIZE(DUK_HOBJECT_GET_ESIZE(obj),\n\t                                                     DUK_HOBJECT_GET_ASIZE(obj),\n\t                                                     DUK_HOBJECT_GET_HSIZE(obj)),\n\t                   (long) new_alloc_size,\n\t                   (void *) DUK_HOBJECT_GET_PROPS(thr->heap, obj),\n\t                   (long) DUK_HOBJECT_GET_ESIZE(obj),\n\t                   (long) DUK_HOBJECT_GET_ENEXT(obj),\n\t                   (long) DUK_HOBJECT_GET_ASIZE(obj),\n\t                   (long) DUK_HOBJECT_GET_HSIZE(obj),\n\t                   (void *) new_p,\n\t                   (long) new_e_size_adjusted,\n\t                   (long) new_e_next,\n\t                   (long) new_a_size,\n\t                   (long) new_h_size,\n\t                   (long) abandon_array,\n\t                   (long) new_e_size));\n\n\t/*\n\t *  All done, switch properties ('p') allocation to new one.\n\t */\n\n\tDUK_FREE(thr->heap, DUK_HOBJECT_GET_PROPS(thr->heap, obj));  /* NULL obj->p is OK */\n\tDUK_HOBJECT_SET_PROPS(thr->heap, obj, new_p);\n\tDUK_HOBJECT_SET_ESIZE(obj, new_e_size_adjusted);\n\tDUK_HOBJECT_SET_ENEXT(obj, new_e_next);\n\tDUK_HOBJECT_SET_ASIZE(obj, new_a_size);\n\tDUK_HOBJECT_SET_HSIZE(obj, new_h_size);\n\n\t/* Clear array part flag only after switching. */\n\tif (abandon_array) {\n\t\tDUK_HOBJECT_CLEAR_ARRAY_PART(obj);\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"resize result: %!O\", (duk_heaphdr *) obj));\n\n\tDUK_ASSERT(thr->heap->pf_prevent_count > 0);\n\tthr->heap->pf_prevent_count--;\n\tthr->heap->ms_base_flags = prev_ms_base_flags;\n#if defined(DUK_USE_ASSERTIONS)\n\tDUK_ASSERT(thr->heap->error_not_allowed == 1);\n\tthr->heap->error_not_allowed = prev_error_not_allowed;\n#endif\n\n\t/*\n\t *  Post resize assertions.\n\t */\n\n#if defined(DUK_USE_ASSERTIONS)\n\t/* XXX: post-checks (such as no duplicate keys) */\n#endif\n\treturn;\n\n\t/*\n\t *  Abandon array failed.  We don't need to DECREF anything\n\t *  because the references in the new allocation are not\n\t *  INCREF'd until abandon is complete.  The string interned\n\t *  keys are on the value stack and are handled normally by\n\t *  unwind.\n\t */\n\n abandon_error:\n alloc_failed:\n\tDUK_D(DUK_DPRINT(\"object property table resize failed\"));\n\n\tDUK_FREE(thr->heap, new_p);  /* OK for NULL. */\n\n\tthr->heap->pf_prevent_count--;\n\tthr->heap->ms_base_flags = prev_ms_base_flags;\n#if defined(DUK_USE_ASSERTIONS)\n\tDUK_ASSERT(thr->heap->error_not_allowed == 1);\n\tthr->heap->error_not_allowed = prev_error_not_allowed;\n#endif\n\n\tDUK_ERROR_ALLOC_FAILED(thr);\n}\n\n/*\n *  Helpers to resize properties allocation on specific needs.\n */\n\n/* Grow entry part allocation for one additional entry. */\nDUK_LOCAL void duk__grow_props_for_new_entry_item(duk_hthread *thr, duk_hobject *obj) {\n\tduk_uint32_t old_e_used;  /* actually used, non-NULL entries */\n\tduk_uint32_t new_e_size;\n\tduk_uint32_t new_a_size;\n\tduk_uint32_t new_h_size;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(obj != NULL);\n\n\t/* Duktape 0.11.0 and prior tried to optimize the resize by not\n\t * counting the number of actually used keys prior to the resize.\n\t * This worked mostly well but also caused weird leak-like behavior\n\t * as in: test-bug-object-prop-alloc-unbounded.js.  So, now we count\n\t * the keys explicitly to compute the new entry part size.\n\t */\n\n\told_e_used = duk__count_used_e_keys(thr, obj);\n\tnew_e_size = old_e_used + duk__get_min_grow_e(old_e_used);\n#if defined(DUK_USE_HOBJECT_HASH_PART)\n\tnew_h_size = duk__get_default_h_size(new_e_size);\n#else\n\tnew_h_size = 0;\n#endif\n\tnew_a_size = DUK_HOBJECT_GET_ASIZE(obj);\n\tDUK_ASSERT(new_e_size >= old_e_used + 1);  /* duk__get_min_grow_e() is always >= 1 */\n\n\tduk_hobject_realloc_props(thr, obj, new_e_size, new_a_size, new_h_size, 0);\n}\n\n/* Grow array part for a new highest array index. */\nDUK_LOCAL void duk__grow_props_for_array_item(duk_hthread *thr, duk_hobject *obj, duk_uint32_t highest_arr_idx) {\n\tduk_uint32_t new_e_size;\n\tduk_uint32_t new_a_size;\n\tduk_uint32_t new_h_size;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(obj != NULL);\n\tDUK_ASSERT(highest_arr_idx >= DUK_HOBJECT_GET_ASIZE(obj));\n\n\t/* minimum new length is highest_arr_idx + 1 */\n\n\tnew_e_size = DUK_HOBJECT_GET_ESIZE(obj);\n\tnew_h_size = DUK_HOBJECT_GET_HSIZE(obj);\n\tnew_a_size = highest_arr_idx + duk__get_min_grow_a(highest_arr_idx);\n\tDUK_ASSERT(new_a_size >= highest_arr_idx + 1);  /* duk__get_min_grow_a() is always >= 1 */\n\n\tduk_hobject_realloc_props(thr, obj, new_e_size, new_a_size, new_h_size, 0);\n}\n\n/* Abandon array part, moving array entries into entries part.\n * This requires a props resize, which is a heavy operation.\n * We also compact the entries part while we're at it, although\n * this is not strictly required.\n */\nDUK_LOCAL void duk__abandon_array_checked(duk_hthread *thr, duk_hobject *obj) {\n\tduk_uint32_t new_e_size;\n\tduk_uint32_t new_a_size;\n\tduk_uint32_t new_h_size;\n\tduk_uint32_t e_used;  /* actually used, non-NULL keys */\n\tduk_uint32_t a_used;\n\tduk_uint32_t a_size;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(obj != NULL);\n\n\te_used = duk__count_used_e_keys(thr, obj);\n\tduk__compute_a_stats(thr, obj, &a_used, &a_size);\n\n\t/*\n\t *  Must guarantee all actually used array entries will fit into\n\t *  new entry part.  Add one growth step to ensure we don't run out\n\t *  of space right away.\n\t */\n\n\tnew_e_size = e_used + a_used;\n\tnew_e_size = new_e_size + duk__get_min_grow_e(new_e_size);\n\tnew_a_size = 0;\n#if defined(DUK_USE_HOBJECT_HASH_PART)\n\tnew_h_size = duk__get_default_h_size(new_e_size);\n#else\n\tnew_h_size = 0;\n#endif\n\n\tDUK_DD(DUK_DDPRINT(\"abandon array part for hobject %p, \"\n\t                   \"array stats before: e_used=%ld, a_used=%ld, a_size=%ld; \"\n\t                   \"resize to e_size=%ld, a_size=%ld, h_size=%ld\",\n\t                   (void *) obj, (long) e_used, (long) a_used, (long) a_size,\n\t                   (long) new_e_size, (long) new_a_size, (long) new_h_size));\n\n\tduk_hobject_realloc_props(thr, obj, new_e_size, new_a_size, new_h_size, 1);\n}\n\n/*\n *  Compact an object.  Minimizes allocation size for objects which are\n *  not likely to be extended.  This is useful for internal and non-\n *  extensible objects, but can also be called for non-extensible objects.\n *  May abandon the array part if it is computed to be too sparse.\n *\n *  This call is relatively expensive, as it needs to scan both the\n *  entries and the array part.\n *\n *  The call may fail due to allocation error.\n */\n\nDUK_INTERNAL void duk_hobject_compact_props(duk_hthread *thr, duk_hobject *obj) {\n\tduk_uint32_t e_size;       /* currently used -> new size */\n\tduk_uint32_t a_size;       /* currently required */\n\tduk_uint32_t a_used;       /* actually used */\n\tduk_uint32_t h_size;\n\tduk_bool_t abandon_array;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(obj != NULL);\n\n#if defined(DUK_USE_ROM_OBJECTS)\n\tif (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj)) {\n\t\tDUK_DD(DUK_DDPRINT(\"ignore attempt to compact a rom object\"));\n\t\treturn;\n\t}\n#endif\n\n\te_size = duk__count_used_e_keys(thr, obj);\n\tduk__compute_a_stats(thr, obj, &a_used, &a_size);\n\n\tDUK_DD(DUK_DDPRINT(\"compacting hobject, used e keys %ld, used a keys %ld, min a size %ld, \"\n\t                   \"resized array density would be: %ld/%ld = %lf\",\n\t                   (long) e_size, (long) a_used, (long) a_size,\n\t                   (long) a_used, (long) a_size,\n\t                   (double) a_used / (double) a_size));\n\n\tif (duk__abandon_array_density_check(a_used, a_size)) {\n\t\tDUK_DD(DUK_DDPRINT(\"decided to abandon array during compaction, a_used=%ld, a_size=%ld\",\n\t\t                   (long) a_used, (long) a_size));\n\t\tabandon_array = 1;\n\t\te_size += a_used;\n\t\ta_size = 0;\n\t} else {\n\t\tDUK_DD(DUK_DDPRINT(\"decided to keep array during compaction\"));\n\t\tabandon_array = 0;\n\t}\n\n#if defined(DUK_USE_HOBJECT_HASH_PART)\n\tif (e_size >= DUK_USE_HOBJECT_HASH_PROP_LIMIT) {\n\t\th_size = duk__get_default_h_size(e_size);\n\t} else {\n\t\th_size = 0;\n\t}\n#else\n\th_size = 0;\n#endif\n\n\tDUK_DD(DUK_DDPRINT(\"compacting hobject -> new e_size %ld, new a_size=%ld, new h_size=%ld, abandon_array=%ld\",\n\t                   (long) e_size, (long) a_size, (long) h_size, (long) abandon_array));\n\n\tduk_hobject_realloc_props(thr, obj, e_size, a_size, h_size, abandon_array);\n}\n\n/*\n *  Find an existing key from entry part either by linear scan or by\n *  using the hash index (if it exists).\n *\n *  Sets entry index (and possibly the hash index) to output variables,\n *  which allows the caller to update the entry and hash entries in-place.\n *  If entry is not found, both values are set to -1.  If entry is found\n *  but there is no hash part, h_idx is set to -1.\n */\n\nDUK_INTERNAL void duk_hobject_find_existing_entry(duk_heap *heap, duk_hobject *obj, duk_hstring *key, duk_int_t *e_idx, duk_int_t *h_idx) {\n\tDUK_ASSERT(obj != NULL);\n\tDUK_ASSERT(key != NULL);\n\tDUK_ASSERT(e_idx != NULL);\n\tDUK_ASSERT(h_idx != NULL);\n\tDUK_UNREF(heap);\n\n\tif (DUK_LIKELY(DUK_HOBJECT_GET_HSIZE(obj) == 0))\n\t{\n\t\t/* Linear scan: more likely because most objects are small.\n\t\t * This is an important fast path.\n\t\t *\n\t\t * XXX: this might be worth inlining for property lookups.\n\t\t */\n\t\tduk_uint_fast32_t i;\n\t\tduk_uint_fast32_t n;\n\t\tduk_hstring **h_keys_base;\n\t\tDUK_DDD(DUK_DDDPRINT(\"duk_hobject_find_existing_entry() using linear scan for lookup\"));\n\n\t\th_keys_base = DUK_HOBJECT_E_GET_KEY_BASE(heap, obj);\n\t\tn = DUK_HOBJECT_GET_ENEXT(obj);\n\t\tfor (i = 0; i < n; i++) {\n\t\t\tif (h_keys_base[i] == key) {\n\t\t\t\t*e_idx = i;\n\t\t\t\t*h_idx = -1;\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t}\n#if defined(DUK_USE_HOBJECT_HASH_PART)\n\telse\n\t{\n\t\t/* hash lookup */\n\t\tduk_uint32_t n;\n\t\tduk_uint32_t i, step;\n\t\tduk_uint32_t *h_base;\n\t\tduk_uint32_t mask;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"duk_hobject_find_existing_entry() using hash part for lookup\"));\n\n\t\th_base = DUK_HOBJECT_H_GET_BASE(heap, obj);\n\t\tn = DUK_HOBJECT_GET_HSIZE(obj);\n\t\tmask = n - 1;\n\t\ti = DUK_HSTRING_GET_HASH(key) & mask;\n\t\tstep = 1;  /* Cache friendly but clustering prone. */\n\n\t\tfor (;;) {\n\t\t\tduk_uint32_t t;\n\n\t\t\tDUK_ASSERT_DISABLE(i >= 0);  /* unsigned */\n\t\t\tDUK_ASSERT(i < DUK_HOBJECT_GET_HSIZE(obj));\n\t\t\tt = h_base[i];\n\t\t\tDUK_ASSERT(t == DUK__HASH_UNUSED || t == DUK__HASH_DELETED ||\n\t\t\t           (t < DUK_HOBJECT_GET_ESIZE(obj)));  /* t >= 0 always true, unsigned */\n\n\t\t\tif (t == DUK__HASH_UNUSED) {\n\t\t\t\tbreak;\n\t\t\t} else if (t == DUK__HASH_DELETED) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"lookup miss (deleted) i=%ld, t=%ld\",\n\t\t\t\t                     (long) i, (long) t));\n\t\t\t} else {\n\t\t\t\tDUK_ASSERT(t < DUK_HOBJECT_GET_ESIZE(obj));\n\t\t\t\tif (DUK_HOBJECT_E_GET_KEY(heap, obj, t) == key) {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"lookup hit i=%ld, t=%ld -> key %p\",\n\t\t\t\t\t                     (long) i, (long) t, (void *) key));\n\t\t\t\t\t*e_idx = t;\n\t\t\t\t\t*h_idx = i;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"lookup miss i=%ld, t=%ld\",\n\t\t\t\t                     (long) i, (long) t));\n\t\t\t}\n\t\t\ti = (i + step) & mask;\n\n\t\t\t/* Guaranteed to finish (hash is larger than #props). */\n\t\t}\n\t}\n#endif  /* DUK_USE_HOBJECT_HASH_PART */\n\n\t/* not found */\n\t*e_idx = -1;\n\t*h_idx = -1;\n}\n\n/* For internal use: get non-accessor entry value */\nDUK_INTERNAL duk_tval *duk_hobject_find_existing_entry_tval_ptr(duk_heap *heap, duk_hobject *obj, duk_hstring *key) {\n\tduk_int_t e_idx;\n\tduk_int_t h_idx;\n\n\tDUK_ASSERT(obj != NULL);\n\tDUK_ASSERT(key != NULL);\n\tDUK_UNREF(heap);\n\n\tduk_hobject_find_existing_entry(heap, obj, key, &e_idx, &h_idx);\n\tif (e_idx >= 0 && !DUK_HOBJECT_E_SLOT_IS_ACCESSOR(heap, obj, e_idx)) {\n\t\treturn DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(heap, obj, e_idx);\n\t} else {\n\t\treturn NULL;\n\t}\n}\n\n/* For internal use: get non-accessor entry value and attributes */\nDUK_INTERNAL duk_tval *duk_hobject_find_existing_entry_tval_ptr_and_attrs(duk_heap *heap, duk_hobject *obj, duk_hstring *key, duk_int_t *out_attrs) {\n\tduk_int_t e_idx;\n\tduk_int_t h_idx;\n\n\tDUK_ASSERT(obj != NULL);\n\tDUK_ASSERT(key != NULL);\n\tDUK_ASSERT(out_attrs != NULL);\n\tDUK_UNREF(heap);\n\n\tduk_hobject_find_existing_entry(heap, obj, key, &e_idx, &h_idx);\n\tif (e_idx >= 0 && !DUK_HOBJECT_E_SLOT_IS_ACCESSOR(heap, obj, e_idx)) {\n\t\t*out_attrs = DUK_HOBJECT_E_GET_FLAGS(heap, obj, e_idx);\n\t\treturn DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(heap, obj, e_idx);\n\t} else {\n\t\t*out_attrs = 0;\n\t\treturn NULL;\n\t}\n}\n\n/* For internal use: get array part value */\nDUK_INTERNAL duk_tval *duk_hobject_find_existing_array_entry_tval_ptr(duk_heap *heap, duk_hobject *obj, duk_uarridx_t i) {\n\tduk_tval *tv;\n\n\tDUK_ASSERT(obj != NULL);\n\tDUK_UNREF(heap);\n\n\tif (!DUK_HOBJECT_HAS_ARRAY_PART(obj)) {\n\t\treturn NULL;\n\t}\n\tif (i >= DUK_HOBJECT_GET_ASIZE(obj)) {\n\t\treturn NULL;\n\t}\n\ttv = DUK_HOBJECT_A_GET_VALUE_PTR(heap, obj, i);\n\treturn tv;\n}\n\n/*\n *  Allocate and initialize a new entry, resizing the properties allocation\n *  if necessary.  Returns entry index (e_idx) or throws an error if alloc fails.\n *\n *  Sets the key of the entry (increasing the key's refcount), and updates\n *  the hash part if it exists.  Caller must set value and flags, and update\n *  the entry value refcount.  A decref for the previous value is not necessary.\n */\n\nDUK_LOCAL duk_bool_t duk__alloc_entry_checked(duk_hthread *thr, duk_hobject *obj, duk_hstring *key) {\n\tduk_uint32_t idx;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(obj != NULL);\n\tDUK_ASSERT(key != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_GET_ENEXT(obj) <= DUK_HOBJECT_GET_ESIZE(obj));\n\n#if defined(DUK_USE_ASSERTIONS)\n\t/* key must not already exist in entry part */\n\t{\n\t\tduk_uint_fast32_t i;\n\t\tfor (i = 0; i < DUK_HOBJECT_GET_ENEXT(obj); i++) {\n\t\t\tDUK_ASSERT(DUK_HOBJECT_E_GET_KEY(thr->heap, obj, i) != key);\n\t\t}\n\t}\n#endif\n\n\tif (DUK_HOBJECT_GET_ENEXT(obj) >= DUK_HOBJECT_GET_ESIZE(obj)) {\n\t\t/* only need to guarantee 1 more slot, but allocation growth is in chunks */\n\t\tDUK_DDD(DUK_DDDPRINT(\"entry part full, allocate space for one more entry\"));\n\t\tduk__grow_props_for_new_entry_item(thr, obj);\n\t}\n\tDUK_ASSERT(DUK_HOBJECT_GET_ENEXT(obj) < DUK_HOBJECT_GET_ESIZE(obj));\n\tidx = DUK_HOBJECT_POSTINC_ENEXT(obj);\n\n\t/* previous value is assumed to be garbage, so don't touch it */\n\tDUK_HOBJECT_E_SET_KEY(thr->heap, obj, idx, key);\n\tDUK_HSTRING_INCREF(thr, key);\n\n#if defined(DUK_USE_HOBJECT_HASH_PART)\n\tif (DUK_UNLIKELY(DUK_HOBJECT_GET_HSIZE(obj) > 0)) {\n\t\tduk_uint32_t n, mask;\n\t\tduk_uint32_t i, step;\n\t\tduk_uint32_t *h_base = DUK_HOBJECT_H_GET_BASE(thr->heap, obj);\n\n\t\tn = DUK_HOBJECT_GET_HSIZE(obj);\n\t\tmask = n - 1;\n\t\ti = DUK_HSTRING_GET_HASH(key) & mask;\n\t\tstep = 1;  /* Cache friendly but clustering prone. */\n\n\t\tfor (;;) {\n\t\t\tduk_uint32_t t = h_base[i];\n\t\t\tif (t == DUK__HASH_UNUSED || t == DUK__HASH_DELETED) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"duk__alloc_entry_checked() inserted key into hash part, %ld -> %ld\",\n\t\t\t\t                     (long) i, (long) idx));\n\t\t\t\tDUK_ASSERT_DISABLE(i >= 0);  /* unsigned */\n\t\t\t\tDUK_ASSERT(i < DUK_HOBJECT_GET_HSIZE(obj));\n\t\t\t\tDUK_ASSERT_DISABLE(idx >= 0);\n\t\t\t\tDUK_ASSERT(idx < DUK_HOBJECT_GET_ESIZE(obj));\n\t\t\t\th_base[i] = idx;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"duk__alloc_entry_checked() miss %ld\", (long) i));\n\t\t\ti = (i + step) & mask;\n\n\t\t\t/* Guaranteed to finish (hash is larger than #props). */\n\t\t}\n\t}\n#endif  /* DUK_USE_HOBJECT_HASH_PART */\n\n\t/* Note: we could return the hash index here too, but it's not\n\t * needed right now.\n\t */\n\n\tDUK_ASSERT_DISABLE(idx >= 0);\n\tDUK_ASSERT(idx < DUK_HOBJECT_GET_ESIZE(obj));\n\tDUK_ASSERT(idx < DUK_HOBJECT_GET_ENEXT(obj));\n\treturn idx;\n}\n\n/*\n *  Object internal value\n *\n *  Returned value is guaranteed to be reachable / incref'd, caller does not need\n *  to incref OR decref.  No proxies or accessors are invoked, no prototype walk.\n */\n\nDUK_INTERNAL duk_bool_t duk_hobject_get_internal_value(duk_heap *heap, duk_hobject *obj, duk_tval *tv_out) {\n\tduk_int_t e_idx;\n\tduk_int_t h_idx;\n\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT(obj != NULL);\n\tDUK_ASSERT(tv_out != NULL);\n\n\t/* always in entry part, no need to look up parents etc */\n\tduk_hobject_find_existing_entry(heap, obj, DUK_HEAP_STRING_INT_VALUE(heap), &e_idx, &h_idx);\n\tif (e_idx >= 0) {\n\t\tDUK_ASSERT(!DUK_HOBJECT_E_SLOT_IS_ACCESSOR(heap, obj, e_idx));\n\t\tDUK_TVAL_SET_TVAL(tv_out, DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(heap, obj, e_idx));\n\t\treturn 1;\n\t}\n\tDUK_TVAL_SET_UNDEFINED(tv_out);\n\treturn 0;\n}\n\nDUK_INTERNAL duk_hstring *duk_hobject_get_internal_value_string(duk_heap *heap, duk_hobject *obj) {\n\tduk_tval tv;\n\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT(obj != NULL);\n\n\t/* This is not strictly necessary, but avoids compiler warnings; e.g.\n\t * gcc won't reliably detect that no uninitialized data is read below.\n\t */\n\tDUK_MEMZERO((void *) &tv, sizeof(duk_tval));\n\n\tif (duk_hobject_get_internal_value(heap, obj, &tv)) {\n\t\tduk_hstring *h;\n\t\tDUK_ASSERT(DUK_TVAL_IS_STRING(&tv));\n\t\th = DUK_TVAL_GET_STRING(&tv);\n\t\t/* No explicit check for string vs. symbol, accept both. */\n\t\treturn h;\n\t}\n\n\treturn NULL;\n}\n\n/*\n *  Arguments handling helpers (argument map mainly).\n *\n *  An arguments object has exotic behavior for some numeric indices.\n *  Accesses may translate to identifier operations which may have\n *  arbitrary side effects (potentially invalidating any duk_tval\n *  pointers).\n */\n\n/* Lookup 'key' from arguments internal 'map', perform a variable lookup\n * if mapped, and leave the result on top of stack (and return non-zero).\n * Used in E5 Section 10.6 algorithms [[Get]] and [[GetOwnProperty]].\n */\nDUK_LOCAL\nduk_bool_t duk__lookup_arguments_map(duk_hthread *thr,\n                                     duk_hobject *obj,\n                                     duk_hstring *key,\n                                     duk_propdesc *temp_desc,\n                                     duk_hobject **out_map,\n                                     duk_hobject **out_varenv) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hobject *map;\n\tduk_hobject *varenv;\n\tduk_bool_t rc;\n\n\tDUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);\n\n\tDUK_DDD(DUK_DDDPRINT(\"arguments map lookup: thr=%p, obj=%p, key=%p, temp_desc=%p \"\n\t                     \"(obj -> %!O, key -> %!O)\",\n\t                     (void *) thr, (void *) obj, (void *) key, (void *) temp_desc,\n\t                     (duk_heaphdr *) obj, (duk_heaphdr *) key));\n\n\tif (!duk_hobject_get_own_propdesc(thr, obj, DUK_HTHREAD_STRING_INT_MAP(thr), temp_desc, DUK_GETDESC_FLAG_PUSH_VALUE)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"-> no 'map'\"));\n\t\treturn 0;\n\t}\n\n\tmap = duk_require_hobject(ctx, -1);\n\tDUK_ASSERT(map != NULL);\n\tduk_pop(ctx);  /* map is reachable through obj */\n\n\tif (!duk_hobject_get_own_propdesc(thr, map, key, temp_desc, DUK_GETDESC_FLAG_PUSH_VALUE)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"-> 'map' exists, but key not in map\"));\n\t\treturn 0;\n\t}\n\n\t/* [... varname] */\n\tDUK_DDD(DUK_DDDPRINT(\"-> 'map' exists, and contains key, key is mapped to argument/variable binding %!T\",\n\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\tDUK_ASSERT(duk_is_string(ctx, -1));  /* guaranteed when building arguments */\n\n\t/* get varenv for varname (callee's declarative lexical environment) */\n\trc = duk_hobject_get_own_propdesc(thr, obj, DUK_HTHREAD_STRING_INT_VARENV(thr), temp_desc, DUK_GETDESC_FLAG_PUSH_VALUE);\n\tDUK_UNREF(rc);\n\tDUK_ASSERT(rc != 0);  /* arguments MUST have an initialized lexical environment reference */\n\tvarenv = duk_require_hobject(ctx, -1);\n\tDUK_ASSERT(varenv != NULL);\n\tduk_pop(ctx);  /* varenv remains reachable through 'obj' */\n\n\tDUK_DDD(DUK_DDDPRINT(\"arguments varenv is: %!dO\", (duk_heaphdr *) varenv));\n\n\t/* success: leave varname in stack */\n\t*out_map = map;\n\t*out_varenv = varenv;\n\treturn 1;  /* [... varname] */\n}\n\n/* Lookup 'key' from arguments internal 'map', and leave replacement value\n * on stack top if mapped (and return non-zero).\n * Used in E5 Section 10.6 algorithm for [[GetOwnProperty]] (used by [[Get]]).\n */\nDUK_LOCAL duk_bool_t duk__check_arguments_map_for_get(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *temp_desc) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hobject *map;\n\tduk_hobject *varenv;\n\tduk_hstring *varname;\n\n\tDUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);\n\n\tif (!duk__lookup_arguments_map(thr, obj, key, temp_desc, &map, &varenv)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"arguments: key not mapped, no exotic get behavior\"));\n\t\treturn 0;\n\t}\n\n\t/* [... varname] */\n\n\tvarname = duk_require_hstring(ctx, -1);\n\tDUK_ASSERT(varname != NULL);\n\tduk_pop(ctx);  /* varname is still reachable */\n\n\tDUK_DDD(DUK_DDDPRINT(\"arguments object automatic getvar for a bound variable; \"\n\t                     \"key=%!O, varname=%!O\",\n\t                     (duk_heaphdr *) key,\n\t                     (duk_heaphdr *) varname));\n\n\t(void) duk_js_getvar_envrec(thr, varenv, varname, 1 /*throw*/);\n\n\t/* [... value this_binding] */\n\n\tduk_pop(ctx);\n\n\t/* leave result on stack top */\n\treturn 1;\n}\n\n/* Lookup 'key' from arguments internal 'map', perform a variable write if mapped.\n * Used in E5 Section 10.6 algorithm for [[DefineOwnProperty]] (used by [[Put]]).\n * Assumes stack top contains 'put' value (which is NOT popped).\n */\nDUK_LOCAL void duk__check_arguments_map_for_put(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *temp_desc, duk_bool_t throw_flag) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hobject *map;\n\tduk_hobject *varenv;\n\tduk_hstring *varname;\n\n\tDUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);\n\n\tif (!duk__lookup_arguments_map(thr, obj, key, temp_desc, &map, &varenv)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"arguments: key not mapped, no exotic put behavior\"));\n\t\treturn;\n\t}\n\n\t/* [... put_value varname] */\n\n\tvarname = duk_require_hstring(ctx, -1);\n\tDUK_ASSERT(varname != NULL);\n\tduk_pop(ctx);  /* varname is still reachable */\n\n\tDUK_DDD(DUK_DDDPRINT(\"arguments object automatic putvar for a bound variable; \"\n\t                     \"key=%!O, varname=%!O, value=%!T\",\n\t                     (duk_heaphdr *) key,\n\t                     (duk_heaphdr *) varname,\n\t                     (duk_tval *) duk_require_tval(ctx, -1)));\n\n\t/* [... put_value] */\n\n\t/*\n\t *  Note: although arguments object variable mappings are only established\n\t *  for non-strict functions (and a call to a non-strict function created\n\t *  the arguments object in question), an inner strict function may be doing\n\t *  the actual property write.  Hence the throw_flag applied here comes from\n\t *  the property write call.\n\t */\n\n\tduk_js_putvar_envrec(thr, varenv, varname, duk_require_tval(ctx, -1), throw_flag);\n\n\t/* [... put_value] */\n}\n\n/* Lookup 'key' from arguments internal 'map', delete mapping if found.\n * Used in E5 Section 10.6 algorithm for [[Delete]].  Note that the\n * variable/argument itself (where the map points) is not deleted.\n */\nDUK_LOCAL void duk__check_arguments_map_for_delete(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *temp_desc) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hobject *map;\n\n\tDUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);\n\n\tif (!duk_hobject_get_own_propdesc(thr, obj, DUK_HTHREAD_STRING_INT_MAP(thr), temp_desc, DUK_GETDESC_FLAG_PUSH_VALUE)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"arguments: key not mapped, no exotic delete behavior\"));\n\t\treturn;\n\t}\n\n\tmap = duk_require_hobject(ctx, -1);\n\tDUK_ASSERT(map != NULL);\n\tduk_pop(ctx);  /* map is reachable through obj */\n\n\tDUK_DDD(DUK_DDDPRINT(\"-> have 'map', delete key %!O from map (if exists)); ignore result\",\n\t                     (duk_heaphdr *) key));\n\n\t/* Note: no recursion issue, we can trust 'map' to behave */\n\tDUK_ASSERT(!DUK_HOBJECT_HAS_EXOTIC_BEHAVIOR(map));\n\tDUK_DDD(DUK_DDDPRINT(\"map before deletion: %!O\", (duk_heaphdr *) map));\n\t(void) duk_hobject_delprop_raw(thr, map, key, 0);  /* ignore result */\n\tDUK_DDD(DUK_DDDPRINT(\"map after deletion: %!O\", (duk_heaphdr *) map));\n}\n\n/*\n *  Ecmascript compliant [[GetOwnProperty]](P), for internal use only.\n *\n *  If property is found:\n *    - Fills descriptor fields to 'out_desc'\n *    - If DUK_GETDESC_FLAG_PUSH_VALUE is set, pushes a value related to the\n *      property onto the stack ('undefined' for accessor properties).\n *    - Returns non-zero\n *\n *  If property is not found:\n *    - 'out_desc' is left in untouched state (possibly garbage)\n *    - Nothing is pushed onto the stack (not even with DUK_GETDESC_FLAG_PUSH_VALUE\n *      set)\n *    - Returns zero\n *\n *  Notes:\n *\n *    - Getting a property descriptor may cause an allocation (and hence\n *      GC) to take place, hence reachability and refcount of all related\n *      values matter.  Reallocation of value stack, properties, etc may\n *      invalidate many duk_tval pointers (concretely, those which reside\n *      in memory areas subject to reallocation).  However, heap object\n *      pointers are never affected (heap objects have stable pointers).\n *\n *    - The value of a plain property is always reachable and has a non-zero\n *      reference count.\n *\n *    - The value of a virtual property is not necessarily reachable from\n *      elsewhere and may have a refcount of zero.  Hence we push it onto\n *      the valstack for the caller, which ensures it remains reachable\n *      while it is needed.\n *\n *    - There are no virtual accessor properties.  Hence, all getters and\n *      setters are always related to concretely stored properties, which\n *      ensures that the get/set functions in the resulting descriptor are\n *      reachable and have non-zero refcounts.  Should there be virtual\n *      accessor properties later, this would need to change.\n */\n\nDUK_LOCAL duk_bool_t duk__get_own_propdesc_raw(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_uint32_t arr_idx, duk_propdesc *out_desc, duk_small_uint_t flags) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_tval *tv;\n\n\tDUK_DDD(DUK_DDDPRINT(\"duk_hobject_get_own_propdesc: thr=%p, obj=%p, key=%p, out_desc=%p, flags=%lx, \"\n\t                     \"arr_idx=%ld (obj -> %!O, key -> %!O)\",\n\t                     (void *) thr, (void *) obj, (void *) key, (void *) out_desc,\n\t                     (long) flags, (long) arr_idx,\n\t                     (duk_heaphdr *) obj, (duk_heaphdr *) key));\n\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\tDUK_ASSERT(obj != NULL);\n\tDUK_ASSERT(key != NULL);\n\tDUK_ASSERT(out_desc != NULL);\n\tDUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);\n\n\t/* XXX: optimize this filling behavior later */\n\tout_desc->flags = 0;\n\tout_desc->get = NULL;\n\tout_desc->set = NULL;\n\tout_desc->e_idx = -1;\n\tout_desc->h_idx = -1;\n\tout_desc->a_idx = -1;\n\n\t/*\n\t *  Array part\n\t */\n\n\tif (DUK_HOBJECT_HAS_ARRAY_PART(obj) && arr_idx != DUK__NO_ARRAY_INDEX) {\n\t\tif (arr_idx < DUK_HOBJECT_GET_ASIZE(obj)) {\n\t\t\ttv = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, obj, arr_idx);\n\t\t\tif (!DUK_TVAL_IS_UNUSED(tv)) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> found in array part\"));\n\t\t\t\tif (flags & DUK_GETDESC_FLAG_PUSH_VALUE) {\n\t\t\t\t\tduk_push_tval(ctx, tv);\n\t\t\t\t}\n\t\t\t\t/* implicit attributes */\n\t\t\t\tout_desc->flags = DUK_PROPDESC_FLAG_WRITABLE |\n\t\t\t\t                  DUK_PROPDESC_FLAG_CONFIGURABLE |\n\t\t\t\t                  DUK_PROPDESC_FLAG_ENUMERABLE;\n\t\t\t\tout_desc->a_idx = arr_idx;\n\t\t\t\tgoto prop_found;\n\t\t\t}\n\t\t}\n\t\t/* assume array part is comprehensive (contains all array indexed elements\n\t\t * or none of them); hence no need to check the entries part here.\n\t\t */\n\t\tDUK_DDD(DUK_DDDPRINT(\"-> not found as a concrete property (has array part, \"\n\t\t                     \"should be there if present)\"));\n\t\tgoto prop_not_found_concrete;\n\t}\n\n\t/*\n\t *  Entries part\n\t */\n\n\tduk_hobject_find_existing_entry(thr->heap, obj, key, &out_desc->e_idx, &out_desc->h_idx);\n\tif (out_desc->e_idx >= 0) {\n\t\tduk_int_t e_idx = out_desc->e_idx;\n\t\tout_desc->flags = DUK_HOBJECT_E_GET_FLAGS(thr->heap, obj, e_idx);\n\t\tif (out_desc->flags & DUK_PROPDESC_FLAG_ACCESSOR) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> found accessor property in entry part\"));\n\t\t\tout_desc->get = DUK_HOBJECT_E_GET_VALUE_GETTER(thr->heap, obj, e_idx);\n\t\t\tout_desc->set = DUK_HOBJECT_E_GET_VALUE_SETTER(thr->heap, obj, e_idx);\n\t\t\tif (flags & DUK_GETDESC_FLAG_PUSH_VALUE) {\n\t\t\t\t/* a dummy undefined value is pushed to make valstack\n\t\t\t\t * behavior uniform for caller\n\t\t\t\t */\n\t\t\t\tduk_push_undefined(ctx);\n\t\t\t}\n\t\t} else {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> found plain property in entry part\"));\n\t\t\ttv = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, e_idx);\n\t\t\tif (flags & DUK_GETDESC_FLAG_PUSH_VALUE) {\n\t\t\t\tduk_push_tval(ctx, tv);\n\t\t\t}\n\t\t}\n\t\tgoto prop_found;\n\t}\n\n\t/*\n\t *  Not found as a concrete property, check for virtual properties.\n\t */\n\n prop_not_found_concrete:\n\n\tif (!DUK_HOBJECT_HAS_VIRTUAL_PROPERTIES(obj)) {\n\t\t/* Quick skip. */\n\t\tgoto prop_not_found;\n\t}\n\n\tif (DUK_HOBJECT_HAS_EXOTIC_ARRAY(obj)) {\n\t\tduk_harray *a;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"array object exotic property get for key: %!O, arr_idx: %ld\",\n\t\t                     (duk_heaphdr *) key, (long) arr_idx));\n\n\t\ta = (duk_harray *) obj;\n\t\tDUK_ASSERT_HARRAY_VALID(a);\n\n\t\tif (key == DUK_HTHREAD_STRING_LENGTH(thr)) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> found, key is 'length', length exotic behavior\"));\n\n\t\t\tif (flags & DUK_GETDESC_FLAG_PUSH_VALUE) {\n\t\t\t\tduk_push_uint(ctx, (duk_uint_t) a->length);\n\t\t\t}\n\t\t\tout_desc->flags = DUK_PROPDESC_FLAG_VIRTUAL;\n\t\t\tif (DUK_HARRAY_LENGTH_WRITABLE(a)) {\n\t\t\t\tout_desc->flags |= DUK_PROPDESC_FLAG_WRITABLE;\n\t\t\t}\n\n\t\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS(obj));\n\t\t\treturn 1;  /* cannot be arguments exotic */\n\t\t}\n\t} else if (DUK_HOBJECT_HAS_EXOTIC_STRINGOBJ(obj)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"string object exotic property get for key: %!O, arr_idx: %ld\",\n\t\t                     (duk_heaphdr *) key, (long) arr_idx));\n\n\t\t/* XXX: charlen; avoid multiple lookups? */\n\n\t\tif (arr_idx != DUK__NO_ARRAY_INDEX) {\n\t\t\tduk_hstring *h_val;\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"array index exists\"));\n\n\t\t\th_val = duk_hobject_get_internal_value_string(thr->heap, obj);\n\t\t\tDUK_ASSERT(h_val);\n\t\t\tif (arr_idx < DUK_HSTRING_GET_CHARLEN(h_val)) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> found, array index inside string\"));\n\t\t\t\tif (flags & DUK_GETDESC_FLAG_PUSH_VALUE) {\n\t\t\t\t\tduk_push_hstring(ctx, h_val);\n\t\t\t\t\tduk_substring(ctx, -1, arr_idx, arr_idx + 1);  /* [str] -> [substr] */\n\t\t\t\t}\n\t\t\t\tout_desc->flags = DUK_PROPDESC_FLAG_ENUMERABLE |  /* E5 Section 15.5.5.2 */\n\t\t\t\t                  DUK_PROPDESC_FLAG_VIRTUAL;\n\n\t\t\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS(obj));\n\t\t\t\treturn 1;  /* cannot be e.g. arguments exotic, since exotic 'traits' are mutually exclusive */\n\t\t\t} else {\n\t\t\t\t/* index is above internal string length -> property is fully normal */\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"array index outside string -> normal property\"));\n\t\t\t}\n\t\t} else if (key == DUK_HTHREAD_STRING_LENGTH(thr)) {\n\t\t\tduk_hstring *h_val;\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> found, key is 'length', length exotic behavior\"));\n\n\t\t\th_val = duk_hobject_get_internal_value_string(thr->heap, obj);\n\t\t\tDUK_ASSERT(h_val != NULL);\n\t\t\tif (flags & DUK_GETDESC_FLAG_PUSH_VALUE) {\n\t\t\t\tduk_push_uint(ctx, (duk_uint_t) DUK_HSTRING_GET_CHARLEN(h_val));\n\t\t\t}\n\t\t\tout_desc->flags = DUK_PROPDESC_FLAG_VIRTUAL;  /* E5 Section 15.5.5.1 */\n\n\t\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS(obj));\n\t\t\treturn 1;  /* cannot be arguments exotic */\n\t\t}\n\t}\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n\telse if (DUK_HOBJECT_IS_BUFOBJ(obj)) {\n\t\tduk_hbufobj *h_bufobj;\n\t\tduk_uint_t byte_off;\n\t\tduk_small_uint_t elem_size;\n\n\t\th_bufobj = (duk_hbufobj *) obj;\n\t\tDUK_ASSERT_HBUFOBJ_VALID(h_bufobj);\n\t\tDUK_DDD(DUK_DDDPRINT(\"bufobj property get for key: %!O, arr_idx: %ld\",\n\t\t                     (duk_heaphdr *) key, (long) arr_idx));\n\n\t\tif (arr_idx != DUK__NO_ARRAY_INDEX && DUK_HBUFOBJ_HAS_VIRTUAL_INDICES(h_bufobj)) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"array index exists\"));\n\n\t\t\t/* Careful with wrapping: arr_idx upshift may easily wrap, whereas\n\t\t\t * length downshift won't.\n\t\t\t */\n\t\t\tif (arr_idx < (h_bufobj->length >> h_bufobj->shift)) {\n\t\t\t\tbyte_off = arr_idx << h_bufobj->shift;  /* no wrap assuming h_bufobj->length is valid */\n\t\t\t\telem_size = 1 << h_bufobj->shift;\n\t\t\t\tif (flags & DUK_GETDESC_FLAG_PUSH_VALUE) {\n\t\t\t\t\tduk_uint8_t *data;\n\n\t\t\t\t\tif (h_bufobj->buf != NULL && DUK_HBUFOBJ_VALID_BYTEOFFSET_EXCL(h_bufobj, byte_off + elem_size)) {\n\t\t\t\t\t\tdata = (duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_bufobj->buf) + h_bufobj->offset + byte_off;\n\t\t\t\t\t\tduk_hbufobj_push_validated_read(ctx, h_bufobj, data, elem_size);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tDUK_D(DUK_DPRINT(\"bufobj access out of underlying buffer, ignoring (read zero)\"));\n\t\t\t\t\t\tduk_push_uint(ctx, 0);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tout_desc->flags = DUK_PROPDESC_FLAG_WRITABLE |\n\t\t\t\t                  DUK_PROPDESC_FLAG_VIRTUAL;\n\t\t\t\tif (DUK_HOBJECT_GET_CLASS_NUMBER(obj) != DUK_HOBJECT_CLASS_ARRAYBUFFER) {\n\t\t\t\t\t/* ArrayBuffer indices are non-standard and are\n\t\t\t\t\t * non-enumerable to avoid their serialization.\n\t\t\t\t\t */\n\t\t\t\t\tout_desc->flags |= DUK_PROPDESC_FLAG_ENUMERABLE;\n\t\t\t\t}\n\n\t\t\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS(obj));\n\t\t\t\treturn 1;  /* cannot be e.g. arguments exotic, since exotic 'traits' are mutually exclusive */\n\t\t\t} else {\n\t\t\t\t/* index is above internal buffer length -> property is fully normal */\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"array index outside buffer -> normal property\"));\n\t\t\t}\n\t\t} else if (key == DUK_HTHREAD_STRING_LENGTH(thr) && DUK_HBUFOBJ_HAS_VIRTUAL_INDICES(h_bufobj)) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> found, key is 'length', length exotic behavior\"));\n\n\t\t\tif (flags & DUK_GETDESC_FLAG_PUSH_VALUE) {\n\t\t\t\t/* Length in elements: take into account shift, but\n\t\t\t\t * intentionally don't check the underlying buffer here.\n\t\t\t\t */\n\t\t\t\tduk_push_uint(ctx, h_bufobj->length >> h_bufobj->shift);\n\t\t\t}\n\t\t\tout_desc->flags = DUK_PROPDESC_FLAG_VIRTUAL;\n\n\t\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS(obj));\n\t\t\treturn 1;  /* cannot be arguments exotic */\n\t\t}\n\t}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\telse if (DUK_HOBJECT_HAS_EXOTIC_DUKFUNC(obj)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"duktape/c object exotic property get for key: %!O, arr_idx: %ld\",\n\t\t                     (duk_heaphdr *) key, (long) arr_idx));\n\n\t\tif (key == DUK_HTHREAD_STRING_LENGTH(thr)) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> found, key is 'length', length exotic behavior\"));\n\n\t\t\tif (flags & DUK_GETDESC_FLAG_PUSH_VALUE) {\n\t\t\t\tduk_int16_t func_nargs = ((duk_hnatfunc *) obj)->nargs;\n\t\t\t\tduk_push_int(ctx, func_nargs == DUK_HNATFUNC_NARGS_VARARGS ? 0 : func_nargs);\n\t\t\t}\n\t\t\tout_desc->flags = DUK_PROPDESC_FLAG_VIRTUAL;  /* not enumerable */\n\n\t\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS(obj));\n\t\t\treturn 1;  /* cannot be arguments exotic */\n\t\t}\n\t}\n\n\t/* Array properties have exotic behavior but they are concrete,\n\t * so no special handling here.\n\t *\n\t * Arguments exotic behavior (E5 Section 10.6, [[GetOwnProperty]]\n\t * is only relevant as a post-check implemented below; hence no\n\t * check here.\n\t */\n\n\t/*\n\t *  Not found as concrete or virtual\n\t */\n\n prop_not_found:\n\tDUK_DDD(DUK_DDDPRINT(\"-> not found (virtual, entry part, or array part)\"));\n\treturn 0;\n\n\t/*\n\t *  Found\n\t *\n\t *  Arguments object has exotic post-processing, see E5 Section 10.6,\n\t *  description of [[GetOwnProperty]] variant for arguments.\n\t */\n\n prop_found:\n\tDUK_DDD(DUK_DDDPRINT(\"-> property found, checking for arguments exotic post-behavior\"));\n\n\t/* Notes:\n\t *  - only numbered indices are relevant, so arr_idx fast reject is good\n\t *    (this is valid unless there are more than 4**32-1 arguments).\n\t *  - since variable lookup has no side effects, this can be skipped if\n\t *    DUK_GETDESC_FLAG_PUSH_VALUE is not set.\n\t */\n\n\tif (DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS(obj) &&\n\t    arr_idx != DUK__NO_ARRAY_INDEX &&\n\t    (flags & DUK_GETDESC_FLAG_PUSH_VALUE)) {\n\t\tduk_propdesc temp_desc;\n\n\t\t/* Magically bound variable cannot be an accessor.  However,\n\t\t * there may be an accessor property (or a plain property) in\n\t\t * place with magic behavior removed.  This happens e.g. when\n\t\t * a magic property is redefined with defineProperty().\n\t\t * Cannot assert for \"not accessor\" here.\n\t\t */\n\n\t\t/* replaces top of stack with new value if necessary */\n\t\tDUK_ASSERT((flags & DUK_GETDESC_FLAG_PUSH_VALUE) != 0);\n\n\t\t/* This can perform a variable lookup but only into a declarative\n\t\t * environment which has no side effects.\n\t\t */\n\t\tif (duk__check_arguments_map_for_get(thr, obj, key, &temp_desc)) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> arguments exotic behavior overrides result: %!T -> %!T\",\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, -2),\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\t\t\t/* [... old_result result] -> [... result] */\n\t\t\tduk_remove_m2(ctx);\n\t\t}\n\t}\n\n\treturn 1;\n}\n\nDUK_INTERNAL duk_bool_t duk_hobject_get_own_propdesc(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *out_desc, duk_small_uint_t flags) {\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(obj != NULL);\n\tDUK_ASSERT(key != NULL);\n\tDUK_ASSERT(out_desc != NULL);\n\tDUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);\n\n\treturn duk__get_own_propdesc_raw(thr, obj, key, DUK_HSTRING_GET_ARRIDX_SLOW(key), out_desc, flags);\n}\n\n/*\n *  Ecmascript compliant [[GetProperty]](P), for internal use only.\n *\n *  If property is found:\n *    - Fills descriptor fields to 'out_desc'\n *    - If DUK_GETDESC_FLAG_PUSH_VALUE is set, pushes a value related to the\n *      property onto the stack ('undefined' for accessor properties).\n *    - Returns non-zero\n *\n *  If property is not found:\n *    - 'out_desc' is left in untouched state (possibly garbage)\n *    - Nothing is pushed onto the stack (not even with DUK_GETDESC_FLAG_PUSH_VALUE\n *      set)\n *    - Returns zero\n *\n *  May cause arbitrary side effects and invalidate (most) duk_tval\n *  pointers.\n */\n\nDUK_LOCAL duk_bool_t duk__get_propdesc(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_propdesc *out_desc, duk_small_uint_t flags) {\n\tduk_hobject *curr;\n\tduk_uint32_t arr_idx;\n\tduk_uint_t sanity;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\tDUK_ASSERT(obj != NULL);\n\tDUK_ASSERT(key != NULL);\n\tDUK_ASSERT(out_desc != NULL);\n\tDUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);\n\n\tarr_idx = DUK_HSTRING_GET_ARRIDX_FAST(key);\n\n\tDUK_DDD(DUK_DDDPRINT(\"duk__get_propdesc: thr=%p, obj=%p, key=%p, out_desc=%p, flags=%lx, \"\n\t                     \"arr_idx=%ld (obj -> %!O, key -> %!O)\",\n\t                     (void *) thr, (void *) obj, (void *) key, (void *) out_desc,\n\t                     (long) flags, (long) arr_idx,\n\t                     (duk_heaphdr *) obj, (duk_heaphdr *) key));\n\n\tcurr = obj;\n\tDUK_ASSERT(curr != NULL);\n\tsanity = DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY;\n\tdo {\n\t\tif (duk__get_own_propdesc_raw(thr, curr, key, arr_idx, out_desc, flags)) {\n\t\t\t/* stack contains value (if requested), 'out_desc' is set */\n\t\t\treturn 1;\n\t\t}\n\n\t\t/* not found in 'curr', next in prototype chain; impose max depth */\n\t\tif (DUK_UNLIKELY(sanity-- == 0)) {\n\t\t\tif (flags & DUK_GETDESC_FLAG_IGNORE_PROTOLOOP) {\n\t\t\t\t/* treat like property not found */\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tDUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT);\n\t\t\t}\n\t\t}\n\t\tcurr = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, curr);\n\t} while (curr != NULL);\n\n\t/* out_desc is left untouched (possibly garbage), caller must use return\n\t * value to determine whether out_desc can be looked up\n\t */\n\n\treturn 0;\n}\n\n/*\n *  Shallow fast path checks for accessing array elements with numeric\n *  indices.  The goal is to try to avoid coercing an array index to an\n *  (interned) string for the most common lookups, in particular, for\n *  standard Array objects.\n *\n *  Interning is avoided but only for a very narrow set of cases:\n *    - Object has array part, index is within array allocation, and\n *      value is not unused (= key exists)\n *    - Object has no interfering exotic behavior (e.g. arguments or\n *      string object exotic behaviors interfere, array exotic\n *      behavior does not).\n *\n *  Current shortcoming: if key does not exist (even if it is within\n *  the array allocation range) a slow path lookup with interning is\n *  always required.  This can probably be fixed so that there is a\n *  quick fast path for non-existent elements as well, at least for\n *  standard Array objects.\n */\n\n#if defined(DUK_USE_ARRAY_PROP_FASTPATH)\nDUK_LOCAL duk_tval *duk__getprop_shallow_fastpath_array_tval(duk_hthread *thr, duk_hobject *obj, duk_tval *tv_key) {\n\tduk_tval *tv;\n\tduk_uint32_t idx;\n\n\tDUK_UNREF(thr);\n\n\tif (!(DUK_HOBJECT_HAS_ARRAY_PART(obj) &&\n\t     !DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS(obj) &&\n\t     !DUK_HOBJECT_HAS_EXOTIC_STRINGOBJ(obj) &&\n\t     !DUK_HOBJECT_IS_BUFOBJ(obj) &&\n\t     !DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(obj))) {\n\t\t/* Must have array part and no conflicting exotic behaviors.\n\t\t * Doesn't need to have array special behavior, e.g. Arguments\n\t\t * object has array part.\n\t\t */\n\t\treturn NULL;\n\t}\n\n\t/* Arrays never have other exotic behaviors. */\n\n\tDUK_DDD(DUK_DDDPRINT(\"fast path attempt (no exotic string/arguments/buffer \"\n\t                     \"behavior, object has array part)\"));\n\n#if defined(DUK_USE_FASTINT)\n\tif (DUK_TVAL_IS_FASTINT(tv_key)) {\n\t\tidx = duk__tval_fastint_to_arr_idx(tv_key);\n\t} else\n#endif\n\tif (DUK_TVAL_IS_DOUBLE(tv_key)) {\n\t\tidx = duk__tval_number_to_arr_idx(tv_key);\n\t} else {\n\t\tDUK_DDD(DUK_DDDPRINT(\"key is not a number\"));\n\t\treturn NULL;\n\t}\n\n\t/* If index is not valid, idx will be DUK__NO_ARRAY_INDEX which\n\t * is 0xffffffffUL.  We don't need to check for that explicitly\n\t * because 0xffffffffUL will never be inside object 'a_size'.\n\t */\n\n\tif (idx >= DUK_HOBJECT_GET_ASIZE(obj)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"key is not an array index or outside array part\"));\n\t\treturn NULL;\n\t}\n\tDUK_ASSERT(idx != 0xffffffffUL);\n\tDUK_ASSERT(idx != DUK__NO_ARRAY_INDEX);\n\n\t/* XXX: for array instances we could take a shortcut here and assume\n\t * Array.prototype doesn't contain an array index property.\n\t */\n\n\tDUK_DDD(DUK_DDDPRINT(\"key is a valid array index and inside array part\"));\n\ttv = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, obj, idx);\n\tif (!DUK_TVAL_IS_UNUSED(tv)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"-> fast path successful\"));\n\t\treturn tv;\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"fast path attempt failed, fall back to slow path\"));\n\treturn NULL;\n}\n\nDUK_LOCAL duk_bool_t duk__putprop_shallow_fastpath_array_tval(duk_hthread *thr, duk_hobject *obj, duk_tval *tv_key, duk_tval *tv_val) {\n\tduk_tval *tv;\n\tduk_harray *a;\n\tduk_uint32_t idx;\n\tduk_uint32_t old_len, new_len;\n\n\tif (!(DUK_HOBJECT_HAS_EXOTIC_ARRAY(obj) &&\n\t      DUK_HOBJECT_HAS_ARRAY_PART(obj) &&\n\t      DUK_HOBJECT_HAS_EXTENSIBLE(obj))) {\n\t\treturn 0;\n\t}\n\tDUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj));  /* caller ensures */\n\n\ta = (duk_harray *) obj;\n\tDUK_ASSERT_HARRAY_VALID(a);\n\n#if defined(DUK_USE_FASTINT)\n\tif (DUK_TVAL_IS_FASTINT(tv_key)) {\n\t\tidx = duk__tval_fastint_to_arr_idx(tv_key);\n\t} else\n#endif\n\tif (DUK_TVAL_IS_DOUBLE(tv_key)) {\n\t\tidx = duk__tval_number_to_arr_idx(tv_key);\n\t} else {\n\t\tDUK_DDD(DUK_DDDPRINT(\"key is not a number\"));\n\t\treturn 0;\n\t}\n\n\t/* If index is not valid, idx will be DUK__NO_ARRAY_INDEX which\n\t * is 0xffffffffUL.  We don't need to check for that explicitly\n\t * because 0xffffffffUL will never be inside object 'a_size'.\n\t */\n\n\tif (idx >= DUK_HOBJECT_GET_ASIZE(obj)) {  /* for resizing of array part, use slow path */\n\t\treturn 0;\n\t}\n\tDUK_ASSERT(idx != 0xffffffffUL);\n\tDUK_ASSERT(idx != DUK__NO_ARRAY_INDEX);\n\n\told_len = a->length;\n\n\tif (idx >= old_len) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"write new array entry requires length update \"\n\t\t                     \"(arr_idx=%ld, old_len=%ld)\",\n\t\t                     (long) idx, (long) old_len));\n\t\tif (DUK_HARRAY_LENGTH_NONWRITABLE(a)) {\n\t\t\t/* The correct behavior here is either a silent error\n\t\t\t * or a TypeError, depending on strictness.  Fall back\n\t\t\t * to the slow path to handle the situation.\n\t\t\t */\n\t\t\treturn 0;\n\t\t}\n\t\tnew_len = idx + 1;\n\n\t\t((duk_harray *) obj)->length = new_len;\n\t}\n\n\ttv = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, obj, idx);\n\tDUK_TVAL_SET_TVAL_UPDREF(thr, tv, tv_val);  /* side effects */\n\n\tDUK_DDD(DUK_DDDPRINT(\"array fast path success for index %ld\", (long) idx));\n\treturn 1;\n}\n#endif  /* DUK_USE_ARRAY_PROP_FASTPATH */\n\n/*\n *  Fast path for bufobj getprop/putprop\n */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_LOCAL duk_bool_t duk__getprop_fastpath_bufobj_tval(duk_hthread *thr, duk_hobject *obj, duk_tval *tv_key) {\n\tduk_context *ctx;\n\tduk_uint32_t idx;\n\tduk_hbufobj *h_bufobj;\n\tduk_uint_t byte_off;\n\tduk_small_uint_t elem_size;\n\tduk_uint8_t *data;\n\n\tctx = (duk_context *) thr;\n\n\tif (!DUK_HOBJECT_IS_BUFOBJ(obj)) {\n\t\treturn 0;\n\t}\n\th_bufobj = (duk_hbufobj *) obj;\n\tif (!DUK_HBUFOBJ_HAS_VIRTUAL_INDICES(h_bufobj)) {\n\t\treturn 0;\n\t}\n\n#if defined(DUK_USE_FASTINT)\n\tif (DUK_TVAL_IS_FASTINT(tv_key)) {\n\t\tidx = duk__tval_fastint_to_arr_idx(tv_key);\n\t} else\n#endif\n\tif (DUK_TVAL_IS_DOUBLE(tv_key)) {\n\t\tidx = duk__tval_number_to_arr_idx(tv_key);\n\t} else {\n\t\treturn 0;\n\t}\n\n\t/* If index is not valid, idx will be DUK__NO_ARRAY_INDEX which\n\t * is 0xffffffffUL.  We don't need to check for that explicitly\n\t * because 0xffffffffUL will never be inside bufobj length.\n\t */\n\n\t/* Careful with wrapping (left shifting idx would be unsafe). */\n\tif (idx >= (h_bufobj->length >> h_bufobj->shift)) {\n\t\treturn 0;\n\t}\n\tDUK_ASSERT(idx != DUK__NO_ARRAY_INDEX);\n\n\tbyte_off = idx << h_bufobj->shift;  /* no wrap assuming h_bufobj->length is valid */\n\telem_size = 1 << h_bufobj->shift;\n\n\tif (h_bufobj->buf != NULL && DUK_HBUFOBJ_VALID_BYTEOFFSET_EXCL(h_bufobj, byte_off + elem_size)) {\n\t\tdata = (duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_bufobj->buf) + h_bufobj->offset + byte_off;\n\t\tduk_hbufobj_push_validated_read(ctx, h_bufobj, data, elem_size);\n\t} else {\n\t\tDUK_D(DUK_DPRINT(\"bufobj access out of underlying buffer, ignoring (read zero)\"));\n\t\tduk_push_uint(ctx, 0);\n\t}\n\n\treturn 1;\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\nDUK_LOCAL duk_bool_t duk__putprop_fastpath_bufobj_tval(duk_hthread *thr, duk_hobject *obj, duk_tval *tv_key, duk_tval *tv_val) {\n\tduk_context *ctx;\n\tduk_uint32_t idx;\n\tduk_hbufobj *h_bufobj;\n\tduk_uint_t byte_off;\n\tduk_small_uint_t elem_size;\n\tduk_uint8_t *data;\n\n\tctx = (duk_context *) thr;\n\n\tif (!(DUK_HOBJECT_IS_BUFOBJ(obj) &&\n\t      DUK_TVAL_IS_NUMBER(tv_val))) {\n\t\treturn 0;\n\t}\n\tDUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj));  /* caller ensures; rom objects are never bufobjs now */\n\n\th_bufobj = (duk_hbufobj *) obj;\n\tif (!DUK_HBUFOBJ_HAS_VIRTUAL_INDICES(h_bufobj)) {\n\t\treturn 0;\n\t}\n\n#if defined(DUK_USE_FASTINT)\n\tif (DUK_TVAL_IS_FASTINT(tv_key)) {\n\t\tidx = duk__tval_fastint_to_arr_idx(tv_key);\n\t} else\n#endif\n\tif (DUK_TVAL_IS_DOUBLE(tv_key)) {\n\t\tidx = duk__tval_number_to_arr_idx(tv_key);\n\t} else {\n\t\treturn 0;\n\t}\n\n\t/* If index is not valid, idx will be DUK__NO_ARRAY_INDEX which\n\t * is 0xffffffffUL.  We don't need to check for that explicitly\n\t * because 0xffffffffUL will never be inside bufobj length.\n\t */\n\n\t/* Careful with wrapping (left shifting idx would be unsafe). */\n\tif (idx >= (h_bufobj->length >> h_bufobj->shift)) {\n\t\treturn 0;\n\t}\n\tDUK_ASSERT(idx != DUK__NO_ARRAY_INDEX);\n\n\tbyte_off = idx << h_bufobj->shift;  /* no wrap assuming h_bufobj->length is valid */\n\telem_size = 1 << h_bufobj->shift;\n\n\t/* Value is required to be a number in the fast path so there\n\t * are no side effects in write coercion.\n\t */\n\tduk_push_tval(ctx, tv_val);\n\tDUK_ASSERT(duk_is_number(ctx, -1));\n\n\tif (h_bufobj->buf != NULL && DUK_HBUFOBJ_VALID_BYTEOFFSET_EXCL(h_bufobj, byte_off + elem_size)) {\n\t\tdata = (duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_bufobj->buf) + h_bufobj->offset + byte_off;\n\t\tduk_hbufobj_validated_write(ctx, h_bufobj, data, elem_size);\n\t} else {\n\t\tDUK_D(DUK_DPRINT(\"bufobj access out of underlying buffer, ignoring (write skipped)\"));\n\t}\n\n\tduk_pop(ctx);\n\treturn 1;\n}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n/*\n *  GETPROP: Ecmascript property read.\n */\n\nDUK_INTERNAL duk_bool_t duk_hobject_getprop(duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_tval tv_obj_copy;\n\tduk_tval tv_key_copy;\n\tduk_hobject *curr = NULL;\n\tduk_hstring *key = NULL;\n\tduk_uint32_t arr_idx = DUK__NO_ARRAY_INDEX;\n\tduk_propdesc desc;\n\tduk_uint_t sanity;\n\n\tDUK_DDD(DUK_DDDPRINT(\"getprop: thr=%p, obj=%p, key=%p (obj -> %!T, key -> %!T)\",\n\t                     (void *) thr, (void *) tv_obj, (void *) tv_key,\n\t                     (duk_tval *) tv_obj, (duk_tval *) tv_key));\n\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\tDUK_ASSERT(tv_obj != NULL);\n\tDUK_ASSERT(tv_key != NULL);\n\n\tDUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);\n\n\t/*\n\t *  Make a copy of tv_obj, tv_key, and tv_val to avoid any issues of\n\t *  them being invalidated by a valstack resize.\n\t *\n\t *  XXX: this is now an overkill for many fast paths.  Rework this\n\t *  to be faster (although switching to a valstack discipline might\n\t *  be a better solution overall).\n\t */\n\n\tDUK_TVAL_SET_TVAL(&tv_obj_copy, tv_obj);\n\tDUK_TVAL_SET_TVAL(&tv_key_copy, tv_key);\n\ttv_obj = &tv_obj_copy;\n\ttv_key = &tv_key_copy;\n\n\t/*\n\t *  Coercion and fast path processing\n\t */\n\n\tswitch (DUK_TVAL_GET_TAG(tv_obj)) {\n\tcase DUK_TAG_UNDEFINED:\n\tcase DUK_TAG_NULL: {\n\t\t/* Note: unconditional throw */\n\t\tDUK_DDD(DUK_DDDPRINT(\"base object is undefined or null -> reject\"));\n#if defined(DUK_USE_PARANOID_ERRORS)\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_INVALID_BASE);\n#else\n\t\tDUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, \"cannot read property %s of %s\",\n\t\t               duk_push_string_tval_readable(ctx, tv_key), duk_push_string_tval_readable(ctx, tv_obj));\n#endif\n\t\treturn 0;\n\t}\n\n\tcase DUK_TAG_BOOLEAN: {\n\t\tDUK_DDD(DUK_DDDPRINT(\"base object is a boolean, start lookup from boolean prototype\"));\n\t\tcurr = thr->builtins[DUK_BIDX_BOOLEAN_PROTOTYPE];\n\t\tbreak;\n\t}\n\n\tcase DUK_TAG_STRING: {\n\t\tduk_hstring *h = DUK_TVAL_GET_STRING(tv_obj);\n\t\tduk_int_t pop_count;\n\n\t\tif (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) {\n\t\t\t/* Symbols (ES2015 or hidden) don't have virtual properties. */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"base object is a symbol, start lookup from symbol prototype\"));\n\t\t\tcurr = thr->builtins[DUK_BIDX_SYMBOL_PROTOTYPE];\n\t\t\tbreak;\n\t\t}\n\n#if defined(DUK_USE_FASTINT)\n\t\tif (DUK_TVAL_IS_FASTINT(tv_key)) {\n\t\t\tarr_idx = duk__tval_fastint_to_arr_idx(tv_key);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"base object string, key is a fast-path fastint; arr_idx %ld\", (long) arr_idx));\n\t\t\tpop_count = 0;\n\t\t} else\n#endif\n\t\tif (DUK_TVAL_IS_NUMBER(tv_key)) {\n\t\t\tarr_idx = duk__tval_number_to_arr_idx(tv_key);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"base object string, key is a fast-path number; arr_idx %ld\", (long) arr_idx));\n\t\t\tpop_count = 0;\n\t\t} else {\n\t\t\tarr_idx = duk__push_tval_to_property_key(ctx, tv_key, &key);\n\t\t\tDUK_ASSERT(key != NULL);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"base object string, key is a non-fast-path number; after \"\n\t\t\t                     \"coercion key is %!T, arr_idx %ld\",\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, -1), (long) arr_idx));\n\t\t\tpop_count = 1;\n\t\t}\n\n\t\tif (arr_idx != DUK__NO_ARRAY_INDEX &&\n\t\t    arr_idx < DUK_HSTRING_GET_CHARLEN(h)) {\n\t\t\tduk_pop_n(ctx, pop_count);\n\t\t\tduk_push_hstring(ctx, h);\n\t\t\tduk_substring(ctx, -1, arr_idx, arr_idx + 1);  /* [str] -> [substr] */\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> %!T (base is string, key is an index inside string length \"\n\t\t\t                     \"after coercion -> return char)\",\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\t\t\treturn 1;\n\t\t}\n\n\t\tif (pop_count == 0) {\n\t\t\t/* This is a pretty awkward control flow, but we need to recheck the\n\t\t\t * key coercion here.\n\t\t\t */\n\t\t\tarr_idx = duk__push_tval_to_property_key(ctx, tv_key, &key);\n\t\t\tDUK_ASSERT(key != NULL);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"base object string, key is a non-fast-path number; after \"\n\t\t\t                     \"coercion key is %!T, arr_idx %ld\",\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, -1), (long) arr_idx));\n\t\t}\n\n\t\tif (key == DUK_HTHREAD_STRING_LENGTH(thr)) {\n\t\t\tduk_pop(ctx);  /* [key] -> [] */\n\t\t\tduk_push_uint(ctx, (duk_uint_t) DUK_HSTRING_GET_CHARLEN(h));  /* [] -> [res] */\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> %!T (base is string, key is 'length' after coercion -> \"\n\t\t\t                     \"return string length)\",\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\t\t\treturn 1;\n\t\t}\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"base object is a string, start lookup from string prototype\"));\n\t\tcurr = thr->builtins[DUK_BIDX_STRING_PROTOTYPE];\n\t\tgoto lookup;  /* avoid double coercion */\n\t}\n\n\tcase DUK_TAG_OBJECT: {\n#if defined(DUK_USE_ARRAY_PROP_FASTPATH)\n\t\tduk_tval *tmp;\n#endif\n\n\t\tcurr = DUK_TVAL_GET_OBJECT(tv_obj);\n\t\tDUK_ASSERT(curr != NULL);\n\n\t\t/* XXX: array .length fast path (important in e.g. loops)? */\n\n#if defined(DUK_USE_ARRAY_PROP_FASTPATH)\n\t\ttmp = duk__getprop_shallow_fastpath_array_tval(thr, curr, tv_key);\n\t\tif (tmp) {\n\t\t\tduk_push_tval(ctx, tmp);\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> %!T (base is object, key is a number, array part \"\n\t\t\t                     \"fast path)\",\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\t\t\treturn 1;\n\t\t}\n#endif\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n\t\tif (duk__getprop_fastpath_bufobj_tval(thr, curr, tv_key) != 0) {\n\t\t\t/* Read value pushed on stack. */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> %!T (base is bufobj, key is a number, bufobj \"\n\t\t\t                     \"fast path)\",\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\t\t\treturn 1;\n\t\t}\n#endif\n\n#if defined(DUK_USE_ES6_PROXY)\n\t\tif (DUK_UNLIKELY(DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(curr))) {\n\t\t\tduk_hobject *h_target;\n\n\t\t\tif (duk__proxy_check_prop(thr, curr, DUK_STRIDX_GET, tv_key, &h_target)) {\n\t\t\t\t/* -> [ ... trap handler ] */\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> proxy object 'get' for key %!T\", (duk_tval *) tv_key));\n\t\t\t\tduk_push_hobject(ctx, h_target);  /* target */\n\t\t\t\tduk_push_tval(ctx, tv_key);       /* P */\n\t\t\t\tduk_push_tval(ctx, tv_obj);       /* Receiver: Proxy object */\n\t\t\t\tduk_call_method(ctx, 3 /*nargs*/);\n\n\t\t\t\t/* Target object must be checked for a conflicting\n\t\t\t\t * non-configurable property.\n\t\t\t\t */\n\t\t\t\tarr_idx = duk__push_tval_to_property_key(ctx, tv_key, &key);\n\t\t\t\tDUK_ASSERT(key != NULL);\n\n\t\t\t\tif (duk__get_own_propdesc_raw(thr, h_target, key, arr_idx, &desc, DUK_GETDESC_FLAG_PUSH_VALUE)) {\n\t\t\t\t\tduk_tval *tv_hook = duk_require_tval(ctx, -3);  /* value from hook */\n\t\t\t\t\tduk_tval *tv_targ = duk_require_tval(ctx, -1);  /* value from target */\n\t\t\t\t\tduk_bool_t datadesc_reject;\n\t\t\t\t\tduk_bool_t accdesc_reject;\n\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"proxy 'get': target has matching property %!O, check for \"\n\t\t\t\t\t                     \"conflicting property; tv_hook=%!T, tv_targ=%!T, desc.flags=0x%08lx, \"\n\t\t\t\t\t                     \"desc.get=%p, desc.set=%p\",\n\t\t\t\t\t                     (duk_heaphdr *) key, (duk_tval *) tv_hook, (duk_tval *) tv_targ,\n\t\t\t\t\t                     (unsigned long) desc.flags,\n\t\t\t\t\t                     (void *) desc.get, (void *) desc.set));\n\n\t\t\t\t\tdatadesc_reject = !(desc.flags & DUK_PROPDESC_FLAG_ACCESSOR) &&\n\t\t\t\t\t                  !(desc.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) &&\n\t\t\t\t\t                  !(desc.flags & DUK_PROPDESC_FLAG_WRITABLE) &&\n\t\t\t\t\t                  !duk_js_samevalue(tv_hook, tv_targ);\n\t\t\t\t\taccdesc_reject = (desc.flags & DUK_PROPDESC_FLAG_ACCESSOR) &&\n\t\t\t\t\t                 !(desc.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) &&\n\t\t\t\t\t                 (desc.get == NULL) &&\n\t\t\t\t\t                 !DUK_TVAL_IS_UNDEFINED(tv_hook);\n\t\t\t\t\tif (datadesc_reject || accdesc_reject) {\n\t\t\t\t\t\tDUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED);\n\t\t\t\t\t}\n\n\t\t\t\t\tduk_pop_2(ctx);\n\t\t\t\t} else {\n\t\t\t\t\tduk_pop(ctx);\n\t\t\t\t}\n\t\t\t\treturn 1;  /* return value */\n\t\t\t}\n\n\t\t\tcurr = h_target;  /* resume lookup from target */\n\t\t\tDUK_TVAL_SET_OBJECT(tv_obj, curr);\n\t\t}\n#endif  /* DUK_USE_ES6_PROXY */\n\n\t\tif (DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS(curr)) {\n\t\t\tarr_idx = duk__push_tval_to_property_key(ctx, tv_key, &key);\n\t\t\tDUK_ASSERT(key != NULL);\n\n\t\t\tif (duk__check_arguments_map_for_get(thr, curr, key, &desc)) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> %!T (base is object with arguments exotic behavior, \"\n\t\t\t\t                     \"key matches magically bound property -> skip standard \"\n\t\t\t\t                     \"Get with replacement value)\",\n\t\t\t\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\n\t\t\t\t/* no need for 'caller' post-check, because 'key' must be an array index */\n\n\t\t\t\tduk_remove_m2(ctx);  /* [key result] -> [result] */\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\tgoto lookup;  /* avoid double coercion */\n\t\t}\n\t\tbreak;\n\t}\n\n\t/* Buffer has virtual properties similar to string, but indexed values\n\t * are numbers, not 1-byte buffers/strings which would perform badly.\n\t */\n\tcase DUK_TAG_BUFFER: {\n\t\tduk_hbuffer *h = DUK_TVAL_GET_BUFFER(tv_obj);\n\t\tduk_int_t pop_count;\n\n\t\t/*\n\t\t *  Because buffer values are often looped over, a number fast path\n\t\t *  is important.\n\t\t */\n\n#if defined(DUK_USE_FASTINT)\n\t\tif (DUK_TVAL_IS_FASTINT(tv_key)) {\n\t\t\tarr_idx = duk__tval_fastint_to_arr_idx(tv_key);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"base object buffer, key is a fast-path fastint; arr_idx %ld\", (long) arr_idx));\n\t\t\tpop_count = 0;\n\t\t}\n\t\telse\n#endif\n\t\tif (DUK_TVAL_IS_NUMBER(tv_key)) {\n\t\t\tarr_idx = duk__tval_number_to_arr_idx(tv_key);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"base object buffer, key is a fast-path number; arr_idx %ld\", (long) arr_idx));\n\t\t\tpop_count = 0;\n\t\t} else {\n\t\t\tarr_idx = duk__push_tval_to_property_key(ctx, tv_key, &key);\n\t\t\tDUK_ASSERT(key != NULL);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"base object buffer, key is a non-fast-path number; after \"\n\t\t\t                     \"coercion key is %!T, arr_idx %ld\",\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, -1), (long) arr_idx));\n\t\t\tpop_count = 1;\n\t\t}\n\n\t\tif (arr_idx != DUK__NO_ARRAY_INDEX &&\n\t\t    arr_idx < DUK_HBUFFER_GET_SIZE(h)) {\n\t\t\tduk_pop_n(ctx, pop_count);\n\t\t\tduk_push_uint(ctx, ((duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h))[arr_idx]);\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> %!T (base is buffer, key is an index inside buffer length \"\n\t\t\t                     \"after coercion -> return byte as number)\",\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\t\t\treturn 1;\n\t\t}\n\n\t\tif (pop_count == 0) {\n\t\t\t/* This is a pretty awkward control flow, but we need to recheck the\n\t\t\t * key coercion here.\n\t\t\t */\n\t\t\tarr_idx = duk__push_tval_to_property_key(ctx, tv_key, &key);\n\t\t\tDUK_ASSERT(key != NULL);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"base object buffer, key is a non-fast-path number; after \"\n\t\t\t                     \"coercion key is %!T, arr_idx %ld\",\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, -1), (long) arr_idx));\n\t\t}\n\n\t\tif (key == DUK_HTHREAD_STRING_LENGTH(thr)) {\n\t\t\tduk_pop(ctx);  /* [key] -> [] */\n\t\t\tduk_push_uint(ctx, (duk_uint_t) DUK_HBUFFER_GET_SIZE(h));  /* [] -> [res] */\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> %!T (base is buffer, key is 'length' \"\n\t\t\t                     \"after coercion -> return buffer length)\",\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\t\t\treturn 1;\n\t\t}\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"base object is a buffer, start lookup from Uint8Array prototype\"));\n\t\tcurr = thr->builtins[DUK_BIDX_UINT8ARRAY_PROTOTYPE];\n\t\tgoto lookup;  /* avoid double coercion */\n\t}\n\n\tcase DUK_TAG_POINTER: {\n\t\tDUK_DDD(DUK_DDDPRINT(\"base object is a pointer, start lookup from pointer prototype\"));\n\t\tcurr = thr->builtins[DUK_BIDX_POINTER_PROTOTYPE];\n\t\tbreak;\n\t}\n\n\tcase DUK_TAG_LIGHTFUNC: {\n\t\tduk_int_t lf_flags = DUK_TVAL_GET_LIGHTFUNC_FLAGS(tv_obj);\n\n\t\t/* Must coerce key: if key is an object, it may coerce to e.g. 'length'. */\n\t\tarr_idx = duk__push_tval_to_property_key(ctx, tv_key, &key);\n\n\t\tif (key == DUK_HTHREAD_STRING_LENGTH(thr)) {\n\t\t\tduk_int_t lf_len = DUK_LFUNC_FLAGS_GET_LENGTH(lf_flags);\n\t\t\tduk_pop(ctx);\n\t\t\tduk_push_int(ctx, lf_len);\n\t\t\treturn 1;\n\t\t} else if (key == DUK_HTHREAD_STRING_NAME(thr)) {\n\t\t\tduk_pop(ctx);\n\t\t\tduk_push_lightfunc_name(ctx, tv_obj);\n\t\t\treturn 1;\n\t\t}\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"base object is a lightfunc, start lookup from function prototype\"));\n\t\tcurr = thr->builtins[DUK_BIDX_FUNCTION_PROTOTYPE];\n\t\tgoto lookup;  /* avoid double coercion */\n\t}\n\n#if defined(DUK_USE_FASTINT)\n\tcase DUK_TAG_FASTINT:\n#endif\n\tdefault: {\n\t\t/* number */\n\t\tDUK_DDD(DUK_DDDPRINT(\"base object is a number, start lookup from number prototype\"));\n\t\tDUK_ASSERT(!DUK_TVAL_IS_UNUSED(tv_obj));\n\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv_obj));\n\t\tcurr = thr->builtins[DUK_BIDX_NUMBER_PROTOTYPE];\n\t\tbreak;\n\t}\n\t}\n\n\t/* key coercion (unless already coerced above) */\n\tDUK_ASSERT(key == NULL);\n\tarr_idx = duk__push_tval_to_property_key(ctx, tv_key, &key);\n\tDUK_ASSERT(key != NULL);\n\n\t/*\n\t *  Property lookup\n\t */\n\n lookup:\n\t/* [key] (coerced) */\n\tDUK_ASSERT(curr != NULL);\n\tDUK_ASSERT(key != NULL);\n\n\tsanity = DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY;\n\tdo {\n\t\tif (!duk__get_own_propdesc_raw(thr, curr, key, arr_idx, &desc, DUK_GETDESC_FLAG_PUSH_VALUE)) {\n\t\t\tgoto next_in_chain;\n\t\t}\n\n\t\tif (desc.get != NULL) {\n\t\t\t/* accessor with defined getter */\n\t\t\tDUK_ASSERT((desc.flags & DUK_PROPDESC_FLAG_ACCESSOR) != 0);\n\n\t\t\tduk_pop(ctx);                     /* [key undefined] -> [key] */\n\t\t\tduk_push_hobject(ctx, desc.get);\n\t\t\tduk_push_tval(ctx, tv_obj);       /* note: original, uncoerced base */\n#if defined(DUK_USE_NONSTD_GETTER_KEY_ARGUMENT)\n\t\t\tduk_dup_m3(ctx);\n\t\t\tduk_call_method(ctx, 1);          /* [key getter this key] -> [key retval] */\n#else\n\t\t\tduk_call_method(ctx, 0);          /* [key getter this] -> [key retval] */\n#endif\n\t\t} else {\n\t\t\t/* [key value] or [key undefined] */\n\n\t\t\t/* data property or accessor without getter */\n\t\t\tDUK_ASSERT(((desc.flags & DUK_PROPDESC_FLAG_ACCESSOR) == 0) ||\n\t\t\t           (desc.get == NULL));\n\n\t\t\t/* if accessor without getter, return value is undefined */\n\t\t\tDUK_ASSERT(((desc.flags & DUK_PROPDESC_FLAG_ACCESSOR) == 0) ||\n\t\t\t           duk_is_undefined(ctx, -1));\n\n\t\t\t/* Note: for an accessor without getter, falling through to\n\t\t\t * check for \"caller\" exotic behavior is unnecessary as\n\t\t\t * \"undefined\" will never activate the behavior.  But it does\n\t\t\t * no harm, so we'll do it anyway.\n\t\t\t */\n\t\t}\n\n\t\tgoto found;  /* [key result] */\n\n\t next_in_chain:\n\t\t/* XXX: option to pretend property doesn't exist if sanity limit is\n\t\t * hit might be useful.\n\t\t */\n\t\tif (DUK_UNLIKELY(sanity-- == 0)) {\n\t\t\tDUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT);\n\t\t}\n\t\tcurr = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, curr);\n\t} while (curr != NULL);\n\n\t/*\n\t *  Not found\n\t */\n\n\tduk_to_undefined(ctx, -1);  /* [key] -> [undefined] (default value) */\n\n\tDUK_DDD(DUK_DDDPRINT(\"-> %!T (not found)\", (duk_tval *) duk_get_tval(ctx, -1)));\n\treturn 0;\n\n\t/*\n\t *  Found; post-processing (Function and arguments objects)\n\t */\n\n found:\n\t/* [key result] */\n\n#if !defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)\n\t/* Special behavior for 'caller' property of (non-bound) function objects\n\t * and non-strict Arguments objects: if 'caller' -value- (!) is a strict\n\t * mode function, throw a TypeError (E5 Sections 15.3.5.4, 10.6).\n\t * Quite interestingly, a non-strict function with no formal arguments\n\t * will get an arguments object -without- special 'caller' behavior!\n\t *\n\t * The E5.1 spec is a bit ambiguous if this special behavior applies when\n\t * a bound function is the base value (not the 'caller' value): Section\n\t * 15.3.4.5 (describing bind()) states that [[Get]] for bound functions\n\t * matches that of Section 15.3.5.4 ([[Get]] for Function instances).\n\t * However, Section 13.3.5.4 has \"NOTE: Function objects created using\n\t * Function.prototype.bind use the default [[Get]] internal method.\"\n\t * The current implementation assumes this means that bound functions\n\t * should not have the special [[Get]] behavior.\n\t *\n\t * The E5.1 spec is also a bit unclear if the TypeError throwing is\n\t * applied if the 'caller' value is a strict bound function.  The\n\t * current implementation will throw even for both strict non-bound\n\t * and strict bound functions.\n\t *\n\t * See test-dev-strict-func-as-caller-prop-value.js for quite extensive\n\t * tests.\n\t *\n\t * This exotic behavior is disabled when the non-standard 'caller' property\n\t * is enabled, as it conflicts with the free use of 'caller'.\n\t */\n\tif (key == DUK_HTHREAD_STRING_CALLER(thr) &&\n\t    DUK_TVAL_IS_OBJECT(tv_obj)) {\n\t\tduk_hobject *orig = DUK_TVAL_GET_OBJECT(tv_obj);\n\t\tDUK_ASSERT(orig != NULL);\n\n\t\tif (DUK_HOBJECT_IS_NONBOUND_FUNCTION(orig) ||\n\t\t    DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS(orig)) {\n\t\t\tduk_hobject *h;\n\n\t\t\t/* XXX: The TypeError is currently not applied to bound\n\t\t\t * functions because the 'strict' flag is not copied by\n\t\t\t * bind().  This may or may not be correct, the specification\n\t\t\t * only refers to the value being a \"strict mode Function\n\t\t\t * object\" which is ambiguous.\n\t\t\t */\n\t\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_BOUNDFUNC(orig));\n\n\t\t\th = duk_get_hobject(ctx, -1);  /* NULL if not an object */\n\t\t\tif (h &&\n\t\t\t    DUK_HOBJECT_IS_FUNCTION(h) &&\n\t\t\t    DUK_HOBJECT_HAS_STRICT(h)) {\n\t\t\t\t/* XXX: sufficient to check 'strict', assert for 'is function' */\n\t\t\t\tDUK_ERROR_TYPE(thr, DUK_STR_STRICT_CALLER_READ);\n\t\t\t}\n\t\t}\n\t}\n#endif   /* !DUK_USE_NONSTD_FUNC_CALLER_PROPERTY */\n\n\tduk_remove_m2(ctx);  /* [key result] -> [result] */\n\n\tDUK_DDD(DUK_DDDPRINT(\"-> %!T (found)\", (duk_tval *) duk_get_tval(ctx, -1)));\n\treturn 1;\n}\n\n/*\n *  HASPROP: Ecmascript property existence check (\"in\" operator).\n *\n *  Interestingly, the 'in' operator does not do any coercion of\n *  the target object.\n */\n\nDUK_INTERNAL duk_bool_t duk_hobject_hasprop(duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_tval tv_key_copy;\n\tduk_hobject *obj;\n\tduk_hstring *key;\n\tduk_uint32_t arr_idx;\n\tduk_bool_t rc;\n\tduk_propdesc desc;\n\n\tDUK_DDD(DUK_DDDPRINT(\"hasprop: thr=%p, obj=%p, key=%p (obj -> %!T, key -> %!T)\",\n\t                     (void *) thr, (void *) tv_obj, (void *) tv_key,\n\t                     (duk_tval *) tv_obj, (duk_tval *) tv_key));\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\tDUK_ASSERT(tv_obj != NULL);\n\tDUK_ASSERT(tv_key != NULL);\n\tDUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);\n\n\tDUK_TVAL_SET_TVAL(&tv_key_copy, tv_key);\n\ttv_key = &tv_key_copy;\n\n\t/*\n\t *  The 'in' operator requires an object as its right hand side,\n\t *  throwing a TypeError unconditionally if this is not the case.\n\t *\n\t *  However, lightfuncs need to behave like fully fledged objects\n\t *  here to be maximally transparent, so we need to handle them\n\t *  here.  Same goes for plain buffers which behave like ArrayBuffers.\n\t */\n\n\t/* XXX: Refactor key coercion so that it's only called once.  It can't\n\t * be trivially lifted here because the object must be type checked\n\t * first.\n\t */\n\n\tif (DUK_TVAL_IS_OBJECT(tv_obj)) {\n\t\tobj = DUK_TVAL_GET_OBJECT(tv_obj);\n\t\tDUK_ASSERT(obj != NULL);\n\n\t\tarr_idx = duk__push_tval_to_property_key(ctx, tv_key, &key);\n\t} else if (DUK_TVAL_IS_BUFFER(tv_obj)) {\n\t\tarr_idx = duk__push_tval_to_property_key(ctx, tv_key, &key);\n\t\tif (duk__key_is_plain_buf_ownprop(thr, DUK_TVAL_GET_BUFFER(tv_obj), key, arr_idx)) {\n\t\t\trc = 1;\n\t\t\tgoto pop_and_return;\n\t\t}\n\t\tobj = thr->builtins[DUK_BIDX_UINT8ARRAY_PROTOTYPE];\n\t} else if (DUK_TVAL_IS_LIGHTFUNC(tv_obj)) {\n\t\tarr_idx = duk__push_tval_to_property_key(ctx, tv_key, &key);\n\t\tif (duk__key_is_lightfunc_ownprop(thr, key)) {\n\t\t\trc = 1;\n\t\t\tgoto pop_and_return;\n\t\t}\n\n\t\t/* If not found, resume existence check from Function.prototype.\n\t\t * We can just substitute the value in this case; nothing will\n\t\t * need the original base value (as would be the case with e.g.\n\t\t * setters/getters.\n\t\t */\n\t\tobj = thr->builtins[DUK_BIDX_FUNCTION_PROTOTYPE];\n\t} else {\n\t\t/* Note: unconditional throw */\n\t\tDUK_DDD(DUK_DDDPRINT(\"base object is not an object -> reject\"));\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_INVALID_BASE);\n\t}\n\n\t/* XXX: fast path for arrays? */\n\n\tDUK_ASSERT(key != NULL);\n\tDUK_ASSERT(obj != NULL);\n\tDUK_UNREF(arr_idx);\n\n#if defined(DUK_USE_ES6_PROXY)\n\tif (DUK_UNLIKELY(DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(obj))) {\n\t\tduk_hobject *h_target;\n\t\tduk_bool_t tmp_bool;\n\n\t\t/* XXX: the key in 'key in obj' is string coerced before we're called\n\t\t * (which is the required behavior in E5/E5.1/E6) so the key is a string\n\t\t * here already.\n\t\t */\n\n\t\tif (duk__proxy_check_prop(thr, obj, DUK_STRIDX_HAS, tv_key, &h_target)) {\n\t\t\t/* [ ... key trap handler ] */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> proxy object 'has' for key %!T\", (duk_tval *) tv_key));\n\t\t\tduk_push_hobject(ctx, h_target);  /* target */\n\t\t\tduk_push_tval(ctx, tv_key);       /* P */\n\t\t\tduk_call_method(ctx, 2 /*nargs*/);\n\t\t\ttmp_bool = duk_to_boolean(ctx, -1);\n\t\t\tif (!tmp_bool) {\n\t\t\t\t/* Target object must be checked for a conflicting\n\t\t\t\t * non-configurable property.\n\t\t\t\t */\n\n\t\t\t\tif (duk__get_own_propdesc_raw(thr, h_target, key, arr_idx, &desc, 0 /*flags*/)) {  /* don't push value */\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"proxy 'has': target has matching property %!O, check for \"\n\t\t\t\t\t                     \"conflicting property; desc.flags=0x%08lx, \"\n\t\t\t\t\t                     \"desc.get=%p, desc.set=%p\",\n\t\t\t\t\t                     (duk_heaphdr *) key, (unsigned long) desc.flags,\n\t\t\t\t\t                     (void *) desc.get, (void *) desc.set));\n\t\t\t\t\t/* XXX: Extensibility check for target uses IsExtensible().  If we\n\t\t\t\t\t * implemented the isExtensible trap and didn't reject proxies as\n\t\t\t\t\t * proxy targets, it should be respected here.\n\t\t\t\t\t */\n\t\t\t\t\tif (!((desc.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) &&  /* property is configurable and */\n\t\t\t\t\t      DUK_HOBJECT_HAS_EXTENSIBLE(h_target))) {          /* ... target is extensible */\n\t\t\t\t\t\tDUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tduk_pop_2(ctx);  /* [ key trap_result ] -> [] */\n\t\t\treturn tmp_bool;\n\t\t}\n\n\t\tobj = h_target;  /* resume check from proxy target */\n\t}\n#endif  /* DUK_USE_ES6_PROXY */\n\n\t/* XXX: inline into a prototype walking loop? */\n\n\trc = duk__get_propdesc(thr, obj, key, &desc, 0 /*flags*/);  /* don't push value */\n\t/* fall through */\n\n pop_and_return:\n\tduk_pop(ctx);  /* [ key ] -> [] */\n\treturn rc;\n}\n\n/*\n *  HASPROP variant used internally.\n *\n *  This primitive must never throw an error, callers rely on this.\n *  In particular, don't throw an error for prototype loops; instead,\n *  pretend like the property doesn't exist if a prototype sanity limit\n *  is reached.\n *\n *  Does not implement proxy behavior: if applied to a proxy object,\n *  returns key existence on the proxy object itself.\n */\n\nDUK_INTERNAL duk_bool_t duk_hobject_hasprop_raw(duk_hthread *thr, duk_hobject *obj, duk_hstring *key) {\n\tduk_propdesc dummy;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\tDUK_ASSERT(obj != NULL);\n\tDUK_ASSERT(key != NULL);\n\n\tDUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);\n\n\treturn duk__get_propdesc(thr, obj, key, &dummy, DUK_GETDESC_FLAG_IGNORE_PROTOLOOP);  /* don't push value */\n}\n\n/*\n *  Helper: handle Array object 'length' write which automatically\n *  deletes properties, see E5 Section 15.4.5.1, step 3.  This is\n *  quite tricky to get right.\n *\n *  Used by duk_hobject_putprop().\n */\n\n/* Coerce a new .length candidate to a number and check that it's a valid\n * .length.\n */\nDUK_LOCAL duk_uint32_t duk__to_new_array_length_checked(duk_hthread *thr, duk_tval *tv) {\n\tduk_uint32_t res;\n\tduk_double_t d;\n\n#if !defined(DUK_USE_PREFER_SIZE)\n#if defined(DUK_USE_FASTINT)\n\t/* When fastints are enabled, the most interesting case is assigning\n\t * a fastint to .length (e.g. arr.length = 0).\n\t */\n\tif (DUK_TVAL_IS_FASTINT(tv)) {\n\t\t/* Very common case. */\n\t\tduk_int64_t fi;\n\t\tfi = DUK_TVAL_GET_FASTINT(tv);\n\t\tif (fi < 0 || fi > 0xffffffffLL) {\n\t\t\tgoto fail_range;\n\t\t}\n\t\treturn (duk_uint32_t) fi;\n\t}\n#else  /* DUK_USE_FASTINT */\n\t/* When fastints are not enabled, the most interesting case is any\n\t * number.\n\t */\n\tif (DUK_TVAL_IS_DOUBLE(tv)) {\n\t\td = DUK_TVAL_GET_NUMBER(tv);\n\t}\n#endif  /* DUK_USE_FASTINT */\n\telse\n#endif  /* !DUK_USE_PREFER_SIZE */\n\t{\n\t\t/* In all other cases, and when doing a size optimized build,\n\t\t * fall back to the comprehensive handler.\n\t\t */\n\t\td = duk_js_tonumber(thr, tv);\n\t}\n\n\t/* Refuse to update an Array's 'length' to a value outside the\n\t * 32-bit range.  Negative zero is accepted as zero.\n\t */\n\tres = (duk_uint32_t) d;\n\tif ((duk_double_t) res != d) {\n\t\tgoto fail_range;\n\t}\n\n\treturn res;\n\n fail_range:\n\tDUK_ERROR_RANGE(thr, DUK_STR_INVALID_ARRAY_LENGTH);\n\treturn 0;  /* unreachable */\n}\n\n/* Delete elements required by a smaller length, taking into account\n * potentially non-configurable elements.  Returns non-zero if all\n * elements could be deleted, and zero if all or some elements could\n * not be deleted.  Also writes final \"target length\" to 'out_result_len'.\n * This is the length value that should go into the 'length' property\n * (must be set by the caller).  Never throws an error.\n */\nDUK_LOCAL\nduk_bool_t duk__handle_put_array_length_smaller(duk_hthread *thr,\n                                                duk_hobject *obj,\n                                                duk_uint32_t old_len,\n                                                duk_uint32_t new_len,\n                                                duk_bool_t force_flag,\n                                                duk_uint32_t *out_result_len) {\n\tduk_uint32_t target_len;\n\tduk_uint_fast32_t i;\n\tduk_uint32_t arr_idx;\n\tduk_hstring *key;\n\tduk_tval *tv;\n\tduk_bool_t rc;\n\n\tDUK_DDD(DUK_DDDPRINT(\"new array length smaller than old (%ld -> %ld), \"\n\t                     \"probably need to remove elements\",\n\t                     (long) old_len, (long) new_len));\n\n\t/*\n\t *  New length is smaller than old length, need to delete properties above\n\t *  the new length.\n\t *\n\t *  If array part exists, this is straightforward: array entries cannot\n\t *  be non-configurable so this is guaranteed to work.\n\t *\n\t *  If array part does not exist, array-indexed values are scattered\n\t *  in the entry part, and some may not be configurable (preventing length\n\t *  from becoming lower than their index + 1).  To handle the algorithm\n\t *  in E5 Section 15.4.5.1, step l correctly, we scan the entire property\n\t *  set twice.\n\t */\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(obj != NULL);\n\tDUK_ASSERT(new_len < old_len);\n\tDUK_ASSERT(out_result_len != NULL);\n\tDUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);\n\n\tDUK_ASSERT(DUK_HOBJECT_HAS_EXOTIC_ARRAY(obj));\n\tDUK_ASSERT(DUK_HOBJECT_IS_ARRAY(obj));\n\n\tif (DUK_HOBJECT_HAS_ARRAY_PART(obj)) {\n\t\t/*\n\t\t *  All defined array-indexed properties are in the array part\n\t\t *  (we assume the array part is comprehensive), and all array\n\t\t *  entries are writable, configurable, and enumerable.  Thus,\n\t\t *  nothing can prevent array entries from being deleted.\n\t\t */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"have array part, easy case\"));\n\n\t\tif (old_len < DUK_HOBJECT_GET_ASIZE(obj)) {\n\t\t\t/* XXX: assertion that entries >= old_len are already unused */\n\t\t\ti = old_len;\n\t\t} else {\n\t\t\ti = DUK_HOBJECT_GET_ASIZE(obj);\n\t\t}\n\t\tDUK_ASSERT(i <= DUK_HOBJECT_GET_ASIZE(obj));\n\n\t\twhile (i > new_len) {\n\t\t\ti--;\n\t\t\ttv = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, obj, i);\n\t\t\tDUK_TVAL_SET_UNUSED_UPDREF(thr, tv);  /* side effects */\n\t\t}\n\n\t\t*out_result_len = new_len;\n\t\treturn 1;\n\t} else {\n\t\t/*\n\t\t *  Entries part is a bit more complex\n\t\t */\n\n\t\t/* Stage 1: find highest preventing non-configurable entry (if any).\n\t\t * When forcing, ignore non-configurability.\n\t\t */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"no array part, slow case\"));\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"array length write, no array part, stage 1: find target_len \"\n\t\t                     \"(highest preventing non-configurable entry (if any))\"));\n\n\t\ttarget_len = new_len;\n\t\tif (force_flag) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"array length write, no array part; force flag -> skip stage 1\"));\n\t\t\tgoto skip_stage1;\n\t\t}\n\t\tfor (i = 0; i < DUK_HOBJECT_GET_ENEXT(obj); i++) {\n\t\t\tkey = DUK_HOBJECT_E_GET_KEY(thr->heap, obj, i);\n\t\t\tif (!key) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"skip entry index %ld: null key\", (long) i));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!DUK_HSTRING_HAS_ARRIDX(key)) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"skip entry index %ld: key not an array index\", (long) i));\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tDUK_ASSERT(DUK_HSTRING_HAS_ARRIDX(key));  /* XXX: macro checks for array index flag, which is unnecessary here */\n\t\t\tarr_idx = DUK_HSTRING_GET_ARRIDX_SLOW(key);\n\t\t\tDUK_ASSERT(arr_idx != DUK__NO_ARRAY_INDEX);\n\t\t\tDUK_ASSERT(arr_idx < old_len);  /* consistency requires this */\n\n\t\t\tif (arr_idx < new_len) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"skip entry index %ld: key is array index %ld, below new_len\",\n\t\t\t\t                     (long) i, (long) arr_idx));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (DUK_HOBJECT_E_SLOT_IS_CONFIGURABLE(thr->heap, obj, i)) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"skip entry index %ld: key is a relevant array index %ld, but configurable\",\n\t\t\t\t                     (long) i, (long) arr_idx));\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t/* relevant array index is non-configurable, blocks write */\n\t\t\tif (arr_idx >= target_len) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"entry at index %ld has arr_idx %ld, is not configurable, \"\n\t\t\t\t                     \"update target_len %ld -> %ld\",\n\t\t\t\t                     (long) i, (long) arr_idx, (long) target_len,\n\t\t\t\t                     (long) (arr_idx + 1)));\n\t\t\t\ttarget_len = arr_idx + 1;\n\t\t\t}\n\t\t}\n\t skip_stage1:\n\n\t\t/* stage 2: delete configurable entries above target length */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"old_len=%ld, new_len=%ld, target_len=%ld\",\n\t\t                     (long) old_len, (long) new_len, (long) target_len));\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"array length write, no array part, stage 2: remove \"\n\t\t                     \"entries >= target_len\"));\n\n\t\tfor (i = 0; i < DUK_HOBJECT_GET_ENEXT(obj); i++) {\n\t\t\tkey = DUK_HOBJECT_E_GET_KEY(thr->heap, obj, i);\n\t\t\tif (!key) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"skip entry index %ld: null key\", (long) i));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!DUK_HSTRING_HAS_ARRIDX(key)) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"skip entry index %ld: key not an array index\", (long) i));\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tDUK_ASSERT(DUK_HSTRING_HAS_ARRIDX(key));  /* XXX: macro checks for array index flag, which is unnecessary here */\n\t\t\tarr_idx = DUK_HSTRING_GET_ARRIDX_SLOW(key);\n\t\t\tDUK_ASSERT(arr_idx != DUK__NO_ARRAY_INDEX);\n\t\t\tDUK_ASSERT(arr_idx < old_len);  /* consistency requires this */\n\n\t\t\tif (arr_idx < target_len) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"skip entry index %ld: key is array index %ld, below target_len\",\n\t\t\t\t                     (long) i, (long) arr_idx));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tDUK_ASSERT(force_flag || DUK_HOBJECT_E_SLOT_IS_CONFIGURABLE(thr->heap, obj, i));  /* stage 1 guarantees */\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"delete entry index %ld: key is array index %ld\",\n\t\t\t                     (long) i, (long) arr_idx));\n\n\t\t\t/*\n\t\t\t *  Slow delete, but we don't care as we're already in a very slow path.\n\t\t\t *  The delete always succeeds: key has no exotic behavior, property\n\t\t\t *  is configurable, and no resize occurs.\n\t\t\t */\n\t\t\trc = duk_hobject_delprop_raw(thr, obj, key, force_flag ? DUK_DELPROP_FLAG_FORCE : 0);\n\t\t\tDUK_UNREF(rc);\n\t\t\tDUK_ASSERT(rc != 0);\n\t\t}\n\n\t\t/* stage 3: update length (done by caller), decide return code */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"array length write, no array part, stage 3: update length (done by caller)\"));\n\n\t\t*out_result_len = target_len;\n\n\t\tif (target_len == new_len) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"target_len matches new_len, return success\"));\n\t\t\treturn 1;\n\t\t}\n\t\tDUK_DDD(DUK_DDDPRINT(\"target_len does not match new_len (some entry prevented \"\n\t\t                     \"full length adjustment), return error\"));\n\t\treturn 0;\n\t}\n\n\tDUK_UNREACHABLE();\n}\n\n/* XXX: is valstack top best place for argument? */\nDUK_LOCAL duk_bool_t duk__handle_put_array_length(duk_hthread *thr, duk_hobject *obj) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_harray *a;\n\tduk_uint32_t old_len;\n\tduk_uint32_t new_len;\n\tduk_uint32_t result_len;\n\tduk_bool_t rc;\n\n\tDUK_DDD(DUK_DDDPRINT(\"handling a put operation to array 'length' exotic property, \"\n\t                     \"new val: %!T\",\n\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(obj != NULL);\n\n\tDUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);\n\n\tDUK_ASSERT(DUK_HOBJECT_HAS_EXOTIC_ARRAY(obj));\n\tDUK_ASSERT(DUK_HOBJECT_IS_ARRAY(obj));\n\ta = (duk_harray *) obj;\n\tDUK_ASSERT_HARRAY_VALID(a);\n\n\tDUK_ASSERT(duk_is_valid_index(ctx, -1));\n\n\t/*\n\t *  Get old and new length\n\t */\n\n\told_len = a->length;\n\tnew_len = duk__to_new_array_length_checked(thr, DUK_GET_TVAL_NEGIDX(ctx, -1));\n\tDUK_DDD(DUK_DDDPRINT(\"old_len=%ld, new_len=%ld\", (long) old_len, (long) new_len));\n\n\t/*\n\t *  Writability check\n\t */\n\n\tif (DUK_HARRAY_LENGTH_NONWRITABLE(a)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"length is not writable, fail\"));\n\t\treturn 0;\n\t}\n\n\t/*\n\t *  New length not lower than old length => no changes needed\n\t *  (not even array allocation).\n\t */\n\n\tif (new_len >= old_len) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"new length is same or higher than old length, just update length, no deletions\"));\n\t\ta->length = new_len;\n\t\treturn 1;\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"new length is lower than old length, probably must delete entries\"));\n\n\t/*\n\t *  New length lower than old length => delete elements, then\n\t *  update length.\n\t *\n\t *  Note: even though a bunch of elements have been deleted, the 'desc' is\n\t *  still valid as properties haven't been resized (and entries compacted).\n\t */\n\n\trc = duk__handle_put_array_length_smaller(thr, obj, old_len, new_len, 0 /*force_flag*/, &result_len);\n\tDUK_ASSERT(result_len >= new_len && result_len <= old_len);\n\n\ta->length = result_len;\n\n\t/* XXX: shrink array allocation or entries compaction here? */\n\n\treturn rc;\n}\n\n/*\n *  PUTPROP: Ecmascript property write.\n *\n *  Unlike Ecmascript primitive which returns nothing, returns 1 to indicate\n *  success and 0 to indicate failure (assuming throw is not set).\n *\n *  This is an extremely tricky function.  Some examples:\n *\n *    * Currently a decref may trigger a GC, which may compact an object's\n *      property allocation.  Consequently, any entry indices (e_idx) will\n *      be potentially invalidated by a decref.\n *\n *    * Exotic behaviors (strings, arrays, arguments object) require,\n *      among other things:\n *\n *      - Preprocessing before and postprocessing after an actual property\n *        write.  For example, array index write requires pre-checking the\n *        array 'length' property for access control, and may require an\n *        array 'length' update after the actual write has succeeded (but\n *        not if it fails).\n *\n *      - Deletion of multiple entries, as a result of array 'length' write.\n *\n *    * Input values are taken as pointers which may point to the valstack.\n *      If valstack is resized because of the put (this may happen at least\n *      when the array part is abandoned), the pointers can be invalidated.\n *      (We currently make a copy of all of the input values to avoid issues.)\n */\n\nDUK_INTERNAL duk_bool_t duk_hobject_putprop(duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key, duk_tval *tv_val, duk_bool_t throw_flag) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_tval tv_obj_copy;\n\tduk_tval tv_key_copy;\n\tduk_tval tv_val_copy;\n\tduk_hobject *orig = NULL;  /* NULL if tv_obj is primitive */\n\tduk_hobject *curr;\n\tduk_hstring *key = NULL;\n\tduk_propdesc desc;\n\tduk_tval *tv;\n\tduk_uint32_t arr_idx;\n\tduk_bool_t rc;\n\tduk_int_t e_idx;\n\tduk_uint_t sanity;\n\tduk_uint32_t new_array_length = 0;  /* 0 = no update */\n\n\tDUK_DDD(DUK_DDDPRINT(\"putprop: thr=%p, obj=%p, key=%p, val=%p, throw=%ld \"\n\t                     \"(obj -> %!T, key -> %!T, val -> %!T)\",\n\t                     (void *) thr, (void *) tv_obj, (void *) tv_key, (void *) tv_val,\n\t                     (long) throw_flag, (duk_tval *) tv_obj, (duk_tval *) tv_key, (duk_tval *) tv_val));\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(tv_obj != NULL);\n\tDUK_ASSERT(tv_key != NULL);\n\tDUK_ASSERT(tv_val != NULL);\n\n\tDUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);\n\n\t/*\n\t *  Make a copy of tv_obj, tv_key, and tv_val to avoid any issues of\n\t *  them being invalidated by a valstack resize.\n\t *\n\t *  XXX: this is an overkill for some paths, so optimize this later\n\t *  (or maybe switch to a stack arguments model entirely).\n\t */\n\n\tDUK_TVAL_SET_TVAL(&tv_obj_copy, tv_obj);\n\tDUK_TVAL_SET_TVAL(&tv_key_copy, tv_key);\n\tDUK_TVAL_SET_TVAL(&tv_val_copy, tv_val);\n\ttv_obj = &tv_obj_copy;\n\ttv_key = &tv_key_copy;\n\ttv_val = &tv_val_copy;\n\n\t/*\n\t *  Coercion and fast path processing.\n\t */\n\n\tswitch (DUK_TVAL_GET_TAG(tv_obj)) {\n\tcase DUK_TAG_UNDEFINED:\n\tcase DUK_TAG_NULL: {\n\t\t/* Note: unconditional throw */\n\t\tDUK_DDD(DUK_DDDPRINT(\"base object is undefined or null -> reject (object=%!iT)\",\n\t\t                     (duk_tval *) tv_obj));\n#if defined(DUK_USE_PARANOID_ERRORS)\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_INVALID_BASE);\n#else\n\t\tDUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, \"cannot write property %s of %s\",\n\t\t               duk_push_string_tval_readable(ctx, tv_key), duk_push_string_tval_readable(ctx, tv_obj));\n#endif\n\t\treturn 0;\n\t}\n\n\tcase DUK_TAG_BOOLEAN: {\n\t\tDUK_DDD(DUK_DDDPRINT(\"base object is a boolean, start lookup from boolean prototype\"));\n\t\tcurr = thr->builtins[DUK_BIDX_BOOLEAN_PROTOTYPE];\n\t\tbreak;\n\t}\n\n\tcase DUK_TAG_STRING: {\n\t\tduk_hstring *h = DUK_TVAL_GET_STRING(tv_obj);\n\n\t\t/*\n\t\t *  Note: currently no fast path for array index writes.\n\t\t *  They won't be possible anyway as strings are immutable.\n\t\t */\n\n\t\tDUK_ASSERT(key == NULL);\n\t\tarr_idx = duk__push_tval_to_property_key(ctx, tv_key, &key);\n\t\tDUK_ASSERT(key != NULL);\n\n\t\tif (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) {\n\t\t\t/* Symbols (ES2015 or hidden) don't have virtual properties. */\n\t\t\tcurr = thr->builtins[DUK_BIDX_SYMBOL_PROTOTYPE];\n\t\t\tgoto lookup;\n\t\t}\n\n\t\tif (key == DUK_HTHREAD_STRING_LENGTH(thr)) {\n\t\t\tgoto fail_not_writable;\n\t\t}\n\n\t\tif (arr_idx != DUK__NO_ARRAY_INDEX &&\n\t\t    arr_idx < DUK_HSTRING_GET_CHARLEN(h)) {\n\t\t\tgoto fail_not_writable;\n\t\t}\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"base object is a string, start lookup from string prototype\"));\n\t\tcurr = thr->builtins[DUK_BIDX_STRING_PROTOTYPE];\n\t\tgoto lookup;  /* avoid double coercion */\n\t}\n\n\tcase DUK_TAG_OBJECT: {\n\t\torig = DUK_TVAL_GET_OBJECT(tv_obj);\n\t\tDUK_ASSERT(orig != NULL);\n\n#if defined(DUK_USE_ROM_OBJECTS)\n\t\t/* With this check in place fast paths won't need read-only\n\t\t * object checks.  This is technically incorrect if there are\n\t\t * setters that cause no writes to ROM objects, but current\n\t\t * built-ins don't have such setters.\n\t\t */\n\t\tif (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) orig)) {\n\t\t\tDUK_DD(DUK_DDPRINT(\"attempt to putprop on read-only target object\"));\n\t\t\tgoto fail_not_writable_no_pop;  /* Must avoid duk_pop() in exit path */\n\t\t}\n#endif\n\n\t\t/* The fast path for array property put is not fully compliant:\n\t\t * If one places conflicting number-indexed properties into\n\t\t * Array.prototype (for example, a non-writable Array.prototype[7])\n\t\t * the fast path will incorrectly ignore them.\n\t\t *\n\t\t * This fast path could be made compliant by falling through\n\t\t * to the slow path if the previous value was UNUSED.  This would\n\t\t * also remove the need to check for extensibility.  Right now a\n\t\t * non-extensible array is slower than an extensible one as far\n\t\t * as writes are concerned.\n\t\t *\n\t\t * The fast path behavior is documented in more detail here:\n\t\t * tests/ecmascript/test-misc-array-fast-write.js\n\t\t */\n\n\t\t/* XXX: array .length? */\n\n#if defined(DUK_USE_ARRAY_PROP_FASTPATH)\n\t\tif (duk__putprop_shallow_fastpath_array_tval(thr, orig, tv_key, tv_val) != 0) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"array fast path success\"));\n\t\t\treturn 1;\n\t\t}\n#endif\n\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n\t\tif (duk__putprop_fastpath_bufobj_tval(thr, orig, tv_key, tv_val) != 0) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"base is bufobj, key is a number, bufobj fast path\"));\n\t\t\treturn 1;\n\t\t}\n#endif\n\n#if defined(DUK_USE_ES6_PROXY)\n\t\tif (DUK_UNLIKELY(DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(orig))) {\n\t\t\tduk_hobject *h_target;\n\t\t\tduk_bool_t tmp_bool;\n\n\t\t\tif (duk__proxy_check_prop(thr, orig, DUK_STRIDX_SET, tv_key, &h_target)) {\n\t\t\t\t/* -> [ ... trap handler ] */\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> proxy object 'set' for key %!T\", (duk_tval *) tv_key));\n\t\t\t\tduk_push_hobject(ctx, h_target);  /* target */\n\t\t\t\tduk_push_tval(ctx, tv_key);       /* P */\n\t\t\t\tduk_push_tval(ctx, tv_val);       /* V */\n\t\t\t\tduk_push_tval(ctx, tv_obj);       /* Receiver: Proxy object */\n\t\t\t\tduk_call_method(ctx, 4 /*nargs*/);\n\t\t\t\ttmp_bool = duk_to_boolean(ctx, -1);\n\t\t\t\tduk_pop(ctx);\n\t\t\t\tif (!tmp_bool) {\n\t\t\t\t\tgoto fail_proxy_rejected;\n\t\t\t\t}\n\n\t\t\t\t/* Target object must be checked for a conflicting\n\t\t\t\t * non-configurable property.\n\t\t\t\t */\n\t\t\t\tarr_idx = duk__push_tval_to_property_key(ctx, tv_key, &key);\n\t\t\t\tDUK_ASSERT(key != NULL);\n\n\t\t\t\tif (duk__get_own_propdesc_raw(thr, h_target, key, arr_idx, &desc, DUK_GETDESC_FLAG_PUSH_VALUE)) {\n\t\t\t\t\tduk_tval *tv_targ = duk_require_tval(ctx, -1);\n\t\t\t\t\tduk_bool_t datadesc_reject;\n\t\t\t\t\tduk_bool_t accdesc_reject;\n\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"proxy 'set': target has matching property %!O, check for \"\n\t\t\t\t\t                     \"conflicting property; tv_val=%!T, tv_targ=%!T, desc.flags=0x%08lx, \"\n\t\t\t\t\t                     \"desc.get=%p, desc.set=%p\",\n\t\t\t\t\t                     (duk_heaphdr *) key, (duk_tval *) tv_val, (duk_tval *) tv_targ,\n\t\t\t\t\t                     (unsigned long) desc.flags,\n\t\t\t\t\t                     (void *) desc.get, (void *) desc.set));\n\n\t\t\t\t\tdatadesc_reject = !(desc.flags & DUK_PROPDESC_FLAG_ACCESSOR) &&\n\t\t\t\t\t                  !(desc.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) &&\n\t\t\t\t\t                  !(desc.flags & DUK_PROPDESC_FLAG_WRITABLE) &&\n\t\t\t\t\t                  !duk_js_samevalue(tv_val, tv_targ);\n\t\t\t\t\taccdesc_reject = (desc.flags & DUK_PROPDESC_FLAG_ACCESSOR) &&\n\t\t\t\t\t                 !(desc.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) &&\n\t\t\t\t\t                 (desc.set == NULL);\n\t\t\t\t\tif (datadesc_reject || accdesc_reject) {\n\t\t\t\t\t\tDUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED);\n\t\t\t\t\t}\n\n\t\t\t\t\tduk_pop_2(ctx);\n\t\t\t\t} else {\n\t\t\t\t\tduk_pop(ctx);\n\t\t\t\t}\n\t\t\t\treturn 1;  /* success */\n\t\t\t}\n\n\t\t\torig = h_target;  /* resume write to target */\n\t\t\tDUK_TVAL_SET_OBJECT(tv_obj, orig);\n\t\t}\n#endif  /* DUK_USE_ES6_PROXY */\n\n\t\tcurr = orig;\n\t\tbreak;\n\t}\n\n\tcase DUK_TAG_BUFFER: {\n\t\tduk_hbuffer *h = DUK_TVAL_GET_BUFFER(tv_obj);\n\t\tduk_int_t pop_count = 0;\n\n\t\t/*\n\t\t *  Because buffer values may be looped over and read/written\n\t\t *  from, an array index fast path is important.\n\t\t */\n\n#if defined(DUK_USE_FASTINT)\n\t\tif (DUK_TVAL_IS_FASTINT(tv_key)) {\n\t\t\tarr_idx = duk__tval_fastint_to_arr_idx(tv_key);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"base object buffer, key is a fast-path fastint; arr_idx %ld\", (long) arr_idx));\n\t\t\tpop_count = 0;\n\t\t} else\n#endif\n\t\tif (DUK_TVAL_IS_NUMBER(tv_key)) {\n\t\t\tarr_idx = duk__tval_number_to_arr_idx(tv_key);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"base object buffer, key is a fast-path number; arr_idx %ld\", (long) arr_idx));\n\t\t\tpop_count = 0;\n\t\t} else {\n\t\t\tarr_idx = duk__push_tval_to_property_key(ctx, tv_key, &key);\n\t\t\tDUK_ASSERT(key != NULL);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"base object buffer, key is a non-fast-path number; after \"\n\t\t\t                     \"coercion key is %!T, arr_idx %ld\",\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, -1), (long) arr_idx));\n\t\t\tpop_count = 1;\n\t\t}\n\n\t\tif (arr_idx != DUK__NO_ARRAY_INDEX &&\n\t\t    arr_idx < DUK_HBUFFER_GET_SIZE(h)) {\n\t\t\tduk_uint8_t *data;\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"writing to buffer data at index %ld\", (long) arr_idx));\n\t\t\tdata = (duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h);\n\n\t\t\t/* XXX: duk_to_int() ensures we'll get 8 lowest bits as\n\t\t\t * as input is within duk_int_t range (capped outside it).\n\t\t\t */\n#if defined(DUK_USE_FASTINT)\n\t\t\t/* Buffer writes are often integers. */\n\t\t\tif (DUK_TVAL_IS_FASTINT(tv_val)) {\n\t\t\t\tdata[arr_idx] = (duk_uint8_t) DUK_TVAL_GET_FASTINT_U32(tv_val);\n\t\t\t}\n\t\t\telse\n#endif\n\t\t\t{\n\t\t\t\tduk_push_tval(ctx, tv_val);\n\t\t\t\tdata[arr_idx] = (duk_uint8_t) duk_to_uint32(ctx, -1);\n\t\t\t\tpop_count++;\n\t\t\t}\n\n\t\t\tduk_pop_n(ctx, pop_count);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"result: success (buffer data write)\"));\n\t\t\treturn 1;\n\t\t}\n\n\t\tif (pop_count == 0) {\n\t\t\t/* This is a pretty awkward control flow, but we need to recheck the\n\t\t\t * key coercion here.\n\t\t\t */\n\t\t\tarr_idx = duk__push_tval_to_property_key(ctx, tv_key, &key);\n\t\t\tDUK_ASSERT(key != NULL);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"base object buffer, key is a non-fast-path number; after \"\n\t\t\t                     \"coercion key is %!T, arr_idx %ld\",\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, -1), (long) arr_idx));\n\t\t}\n\n\t\tif (key == DUK_HTHREAD_STRING_LENGTH(thr)) {\n\t\t\tgoto fail_not_writable;\n\t\t}\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"base object is a buffer, start lookup from Uint8Array prototype\"));\n\t\tcurr = thr->builtins[DUK_BIDX_UINT8ARRAY_PROTOTYPE];\n\t\tgoto lookup;  /* avoid double coercion */\n\t}\n\n\tcase DUK_TAG_POINTER: {\n\t\tDUK_DDD(DUK_DDDPRINT(\"base object is a pointer, start lookup from pointer prototype\"));\n\t\tcurr = thr->builtins[DUK_BIDX_POINTER_PROTOTYPE];\n\t\tbreak;\n\t}\n\n\tcase DUK_TAG_LIGHTFUNC: {\n\t\t/* All lightfunc own properties are non-writable and the lightfunc\n\t\t * is considered non-extensible.  However, the write may be captured\n\t\t * by an inherited setter which means we can't stop the lookup here.\n\t\t */\n\n\t\tarr_idx = duk__push_tval_to_property_key(ctx, tv_key, &key);\n\n\t\tif (duk__key_is_lightfunc_ownprop(thr, key)) {\n\t\t\tgoto fail_not_writable;\n\t\t}\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"base object is a lightfunc, start lookup from function prototype\"));\n\t\tcurr = thr->builtins[DUK_BIDX_FUNCTION_PROTOTYPE];\n\t\tgoto lookup;  /* avoid double coercion */\n\t}\n\n#if defined(DUK_USE_FASTINT)\n\tcase DUK_TAG_FASTINT:\n#endif\n\tdefault: {\n\t\t/* number */\n\t\tDUK_DDD(DUK_DDDPRINT(\"base object is a number, start lookup from number prototype\"));\n\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv_obj));\n\t\tcurr = thr->builtins[DUK_BIDX_NUMBER_PROTOTYPE];\n\t\tbreak;\n\t}\n\t}\n\n\tDUK_ASSERT(key == NULL);\n\tarr_idx = duk__push_tval_to_property_key(ctx, tv_key, &key);\n\tDUK_ASSERT(key != NULL);\n\n lookup:\n\n\t/*\n\t *  Check whether the property already exists in the prototype chain.\n\t *  Note that the actual write goes into the original base object\n\t *  (except if an accessor property captures the write).\n\t */\n\n\t/* [key] */\n\n\tDUK_ASSERT(curr != NULL);\n\tsanity = DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY;\n\tdo {\n\t\tif (!duk__get_own_propdesc_raw(thr, curr, key, arr_idx, &desc, 0 /*flags*/)) {  /* don't push value */\n\t\t\tgoto next_in_chain;\n\t\t}\n\n\t\tif (desc.flags & DUK_PROPDESC_FLAG_ACCESSOR) {\n\t\t\t/*\n\t\t\t *  Found existing accessor property (own or inherited).\n\t\t\t *  Call setter with 'this' set to orig, and value as the only argument.\n\t\t\t *  Setter calls are OK even for ROM objects.\n\t\t\t *\n\t\t\t *  Note: no exotic arguments object behavior, because [[Put]] never\n\t\t\t *  calls [[DefineOwnProperty]] (E5 Section 8.12.5, step 5.b).\n\t\t\t */\n\n\t\t\tduk_hobject *setter;\n\n\t\t\tDUK_DD(DUK_DDPRINT(\"put to an own or inherited accessor, calling setter\"));\n\n\t\t\tsetter = DUK_HOBJECT_E_GET_VALUE_SETTER(thr->heap, curr, desc.e_idx);\n\t\t\tif (!setter) {\n\t\t\t\tgoto fail_no_setter;\n\t\t\t}\n\t\t\tduk_push_hobject(ctx, setter);\n\t\t\tduk_push_tval(ctx, tv_obj);  /* note: original, uncoerced base */\n\t\t\tduk_push_tval(ctx, tv_val);  /* [key setter this val] */\n#if defined(DUK_USE_NONSTD_SETTER_KEY_ARGUMENT)\n\t\t\tduk_dup_m4(ctx);\n\t\t\tduk_call_method(ctx, 2);     /* [key setter this val key] -> [key retval] */\n#else\n\t\t\tduk_call_method(ctx, 1);     /* [key setter this val] -> [key retval] */\n#endif\n\t\t\tduk_pop(ctx);                /* ignore retval -> [key] */\n\t\t\tgoto success_no_arguments_exotic;\n\t\t}\n\n\t\tif (orig == NULL) {\n\t\t\t/*\n\t\t\t *  Found existing own or inherited plain property, but original\n\t\t\t *  base is a primitive value.\n\t\t\t */\n\t\t\tDUK_DD(DUK_DDPRINT(\"attempt to create a new property in a primitive base object\"));\n\t\t\tgoto fail_base_primitive;\n\t\t}\n\n\t\tif (curr != orig) {\n\t\t\t/*\n\t\t\t *  Found existing inherited plain property.\n\t\t\t *  Do an access control check, and if OK, write\n\t\t\t *  new property to 'orig'.\n\t\t\t */\n\t\t\tif (!DUK_HOBJECT_HAS_EXTENSIBLE(orig)) {\n\t\t\t\tDUK_DD(DUK_DDPRINT(\"found existing inherited plain property, but original object is not extensible\"));\n\t\t\t\tgoto fail_not_extensible;\n\t\t\t}\n\t\t\tif (!(desc.flags & DUK_PROPDESC_FLAG_WRITABLE)) {\n\t\t\t\tDUK_DD(DUK_DDPRINT(\"found existing inherited plain property, original object is extensible, but inherited property is not writable\"));\n\t\t\t\tgoto fail_not_writable;\n\t\t\t}\n\t\t\tDUK_DD(DUK_DDPRINT(\"put to new property, object extensible, inherited property found and is writable\"));\n\t\t\tgoto create_new;\n\t\t} else {\n\t\t\t/*\n\t\t\t *  Found existing own (non-inherited) plain property.\n\t\t\t *  Do an access control check and update in place.\n\t\t\t */\n\n\t\t\tif (!(desc.flags & DUK_PROPDESC_FLAG_WRITABLE)) {\n\t\t\t\tDUK_DD(DUK_DDPRINT(\"found existing own (non-inherited) plain property, but property is not writable\"));\n\t\t\t\tgoto fail_not_writable;\n\t\t\t}\n\t\t\tif (desc.flags & DUK_PROPDESC_FLAG_VIRTUAL) {\n\t\t\t\tDUK_DD(DUK_DDPRINT(\"found existing own (non-inherited) virtual property, property is writable\"));\n\n\t\t\t\tif (DUK_HOBJECT_IS_ARRAY(curr)) {\n\t\t\t\t\t/*\n\t\t\t\t\t *  Write to 'length' of an array is a very complex case\n\t\t\t\t\t *  handled in a helper which updates both the array elements\n\t\t\t\t\t *  and writes the new 'length'.  The write may result in an\n\t\t\t\t\t *  unconditional RangeError or a partial write (indicated\n\t\t\t\t\t *  by a return code).\n\t\t\t\t\t *\n\t\t\t\t\t *  Note: the helper has an unnecessary writability check\n\t\t\t\t\t *  for 'length', we already know it is writable.\n\t\t\t\t\t */\n\t\t\t\t\tDUK_ASSERT(key == DUK_HTHREAD_STRING_LENGTH(thr));  /* only virtual array property */\n\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"writing existing 'length' property to array exotic, invoke complex helper\"));\n\n\t\t\t\t\t/* XXX: the helper currently assumes stack top contains new\n\t\t\t\t\t * 'length' value and the whole calling convention is not very\n\t\t\t\t\t * compatible with what we need.\n\t\t\t\t\t */\n\n\t\t\t\t\tduk_push_tval(ctx, tv_val);  /* [key val] */\n\t\t\t\t\trc = duk__handle_put_array_length(thr, orig);\n\t\t\t\t\tduk_pop(ctx);  /* [key val] -> [key] */\n\t\t\t\t\tif (!rc) {\n\t\t\t\t\t\tgoto fail_array_length_partial;\n\t\t\t\t\t}\n\n\t\t\t\t\t/* key is 'length', cannot match argument exotic behavior */\n\t\t\t\t\tgoto success_no_arguments_exotic;\n\t\t\t\t}\n#if defined(DUK_USE_BUFFEROBJECT_SUPPORT)\n\t\t\t\telse if (DUK_HOBJECT_IS_BUFOBJ(curr)) {\n\t\t\t\t\tduk_hbufobj *h_bufobj;\n\t\t\t\t\tduk_uint_t byte_off;\n\t\t\t\t\tduk_small_uint_t elem_size;\n\n\t\t\t\t\th_bufobj = (duk_hbufobj *) curr;\n\t\t\t\t\tDUK_ASSERT_HBUFOBJ_VALID(h_bufobj);\n\n\t\t\t\t\tDUK_DD(DUK_DDPRINT(\"writable virtual property is in buffer object\"));\n\n\t\t\t\t\t/* Careful with wrapping: arr_idx upshift may easily wrap, whereas\n\t\t\t\t\t * length downshift won't.\n\t\t\t\t\t */\n\t\t\t\t\tif (arr_idx < (h_bufobj->length >> h_bufobj->shift) && DUK_HBUFOBJ_HAS_VIRTUAL_INDICES(h_bufobj)) {\n\t\t\t\t\t\tduk_uint8_t *data;\n\t\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"writing to buffer data at index %ld\", (long) arr_idx));\n\n\t\t\t\t\t\tDUK_ASSERT(arr_idx != DUK__NO_ARRAY_INDEX);  /* index/length check guarantees */\n\t\t\t\t\t\tbyte_off = arr_idx << h_bufobj->shift;       /* no wrap assuming h_bufobj->length is valid */\n\t\t\t\t\t\telem_size = 1 << h_bufobj->shift;\n\n\t\t\t\t\t\t/* Coerce to number before validating pointers etc so that the\n\t\t\t\t\t\t * number coercions in duk_hbufobj_validated_write() are\n\t\t\t\t\t\t * guaranteed to be side effect free and not invalidate the\n\t\t\t\t\t\t * pointer checks we do here.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tduk_push_tval(ctx, tv_val);\n\t\t\t\t\t\t(void) duk_to_number_m1(ctx);\n\n\t\t\t\t\t\tif (h_bufobj->buf != NULL && DUK_HBUFOBJ_VALID_BYTEOFFSET_EXCL(h_bufobj, byte_off + elem_size)) {\n\t\t\t\t\t\t\tdata = (duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(thr->heap, h_bufobj->buf) + h_bufobj->offset + byte_off;\n\t\t\t\t\t\t\tduk_hbufobj_validated_write(ctx, h_bufobj, data, elem_size);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tDUK_D(DUK_DPRINT(\"bufobj access out of underlying buffer, ignoring (write skipped)\"));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tduk_pop(ctx);\n\t\t\t\t\t\tgoto success_no_arguments_exotic;\n\t\t\t\t\t}\n\t\t\t\t}\n#endif  /* DUK_USE_BUFFEROBJECT_SUPPORT */\n\n\t\t\t\tDUK_D(DUK_DPRINT(\"should not happen, key %!O\", key));\n\t\t\t\tgoto fail_internal;  /* should not happen */\n\t\t\t}\n\t\t\tDUK_DD(DUK_DDPRINT(\"put to existing own plain property, property is writable\"));\n\t\t\tgoto update_old;\n\t\t}\n\t\tDUK_UNREACHABLE();\n\n\t next_in_chain:\n\t\t/* XXX: option to pretend property doesn't exist if sanity limit is\n\t\t * hit might be useful.\n\t\t */\n\t\tif (DUK_UNLIKELY(sanity-- == 0)) {\n\t\t\tDUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT);\n\t\t}\n\t\tcurr = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, curr);\n\t} while (curr != NULL);\n\n\t/*\n\t *  Property not found in prototype chain.\n\t */\n\n\tDUK_DDD(DUK_DDDPRINT(\"property not found in prototype chain\"));\n\n\tif (orig == NULL) {\n\t\tDUK_DD(DUK_DDPRINT(\"attempt to create a new property in a primitive base object\"));\n\t\tgoto fail_base_primitive;\n\t}\n\n\tif (!DUK_HOBJECT_HAS_EXTENSIBLE(orig)) {\n\t\tDUK_DD(DUK_DDPRINT(\"put to a new property (not found in prototype chain), but original object not extensible\"));\n\t\tgoto fail_not_extensible;\n\t}\n\n\tgoto create_new;\n\n update_old:\n\n\t/*\n\t *  Update an existing property of the base object.\n\t */\n\n\t/* [key] */\n\n\tDUK_DDD(DUK_DDDPRINT(\"update an existing property of the original object\"));\n\n\tDUK_ASSERT(orig != NULL);\n#if defined(DUK_USE_ROM_OBJECTS)\n\t/* This should not happen because DUK_TAG_OBJECT case checks\n\t * for this already, but check just in case.\n\t */\n\tif (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) orig)) {\n\t\tgoto fail_not_writable;\n\t}\n#endif\n\n\t/* Although there are writable virtual properties (e.g. plain buffer\n\t * and buffer object number indices), they are handled before we come\n\t * here.\n\t */\n\tDUK_ASSERT((desc.flags & DUK_PROPDESC_FLAG_VIRTUAL) == 0);\n\tDUK_ASSERT(desc.a_idx >= 0 || desc.e_idx >= 0);\n\n\t/* Array own property .length is handled above. */\n\tDUK_ASSERT(!(DUK_HOBJECT_IS_ARRAY(orig) && key == DUK_HTHREAD_STRING_LENGTH(thr)));\n\n\tif (desc.e_idx >= 0) {\n\t\ttv = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, orig, desc.e_idx);\n\t\tDUK_DDD(DUK_DDDPRINT(\"previous entry value: %!iT\", (duk_tval *) tv));\n\t\tDUK_TVAL_SET_TVAL_UPDREF(thr, tv, tv_val);  /* side effects; e_idx may be invalidated */\n\t\t/* don't touch property attributes or hash part */\n\t\tDUK_DD(DUK_DDPRINT(\"put to an existing entry at index %ld -> new value %!iT\",\n\t\t                   (long) desc.e_idx, (duk_tval *) tv));\n\t} else {\n\t\t/* Note: array entries are always writable, so the writability check\n\t\t * above is pointless for them.  The check could be avoided with some\n\t\t * refactoring but is probably not worth it.\n\t\t */\n\n\t\tDUK_ASSERT(desc.a_idx >= 0);\n\t\ttv = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, orig, desc.a_idx);\n\t\tDUK_DDD(DUK_DDDPRINT(\"previous array value: %!iT\", (duk_tval *) tv));\n\t\tDUK_TVAL_SET_TVAL_UPDREF(thr, tv, tv_val);  /* side effects; a_idx may be invalidated */\n\t\tDUK_DD(DUK_DDPRINT(\"put to an existing array entry at index %ld -> new value %!iT\",\n\t\t                   (long) desc.a_idx, (duk_tval *) tv));\n\t}\n\n\t/* Regardless of whether property is found in entry or array part,\n\t * it may have arguments exotic behavior (array indices may reside\n\t * in entry part for abandoned / non-existent array parts).\n\t */\n\tgoto success_with_arguments_exotic;\n\n create_new:\n\n\t/*\n\t *  Create a new property in the original object.\n\t *\n\t *  Exotic properties need to be reconsidered here from a write\n\t *  perspective (not just property attributes perspective).\n\t *  However, the property does not exist in the object already,\n\t *  so this limits the kind of exotic properties that apply.\n\t */\n\n\t/* [key] */\n\n\tDUK_DDD(DUK_DDDPRINT(\"create new property to original object\"));\n\n\tDUK_ASSERT(orig != NULL);\n\n\t/* Array own property .length is handled above. */\n\tDUK_ASSERT(!(DUK_HOBJECT_IS_ARRAY(orig) && key == DUK_HTHREAD_STRING_LENGTH(thr)));\n\n#if defined(DUK_USE_ROM_OBJECTS)\n\t/* This should not happen because DUK_TAG_OBJECT case checks\n\t * for this already, but check just in case.\n\t */\n\tif (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) orig)) {\n\t\tgoto fail_not_writable;\n\t}\n#endif\n\n\t/* Not possible because array object 'length' is present\n\t * from its creation and cannot be deleted, and is thus\n\t * caught as an existing property above.\n\t */\n\tDUK_ASSERT(!(DUK_HOBJECT_HAS_EXOTIC_ARRAY(orig) &&\n\t             key == DUK_HTHREAD_STRING_LENGTH(thr)));\n\n\tif (DUK_HOBJECT_HAS_EXOTIC_ARRAY(orig) &&\n\t    arr_idx != DUK__NO_ARRAY_INDEX) {\n\t\t/* automatic length update */\n\t\tduk_uint32_t old_len;\n\t\tduk_harray *a;\n\n\t\ta = (duk_harray *) orig;\n\t\tDUK_ASSERT_HARRAY_VALID(a);\n\n\t\told_len = a->length;\n\n\t\tif (arr_idx >= old_len) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"write new array entry requires length update \"\n\t\t\t                     \"(arr_idx=%ld, old_len=%ld)\",\n\t\t\t                     (long) arr_idx, (long) old_len));\n\n\t\t\tif (DUK_HARRAY_LENGTH_NONWRITABLE(a)) {\n\t\t\t\tDUK_DD(DUK_DDPRINT(\"attempt to extend array, but array 'length' is not writable\"));\n\t\t\t\tgoto fail_not_writable;\n\t\t\t}\n\n\t\t\t/* Note: actual update happens once write has been completed\n\t\t\t * without error below.  The write should always succeed\n\t\t\t * from a specification viewpoint, but we may e.g. run out\n\t\t\t * of memory.  It's safer in this order.\n\t\t\t */\n\n\t\t\tDUK_ASSERT(arr_idx != 0xffffffffUL);\n\t\t\tnew_array_length = arr_idx + 1;  /* flag for later write */\n\t\t} else {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"write new array entry does not require length update \"\n\t\t\t                     \"(arr_idx=%ld, old_len=%ld)\",\n\t\t\t                     (long) arr_idx, (long) old_len));\n\t\t}\n\t}\n\n /* write_to_array_part: */\n\n\t/*\n\t *  Write to array part?\n\t *\n\t *  Note: array abandonding requires a property resize which uses\n\t *  'rechecks' valstack for temporaries and may cause any existing\n\t *  valstack pointers to be invalidated.  To protect against this,\n\t *  tv_obj, tv_key, and tv_val are copies of the original inputs.\n\t */\n\n\tif (arr_idx != DUK__NO_ARRAY_INDEX &&\n\t    DUK_HOBJECT_HAS_ARRAY_PART(orig)) {\n\t\tif (arr_idx < DUK_HOBJECT_GET_ASIZE(orig)) {\n\t\t\tgoto no_array_growth;\n\t\t}\n\n\t\t/*\n\t\t *  Array needs to grow, but we don't want it becoming too sparse.\n\t\t *  If it were to become sparse, abandon array part, moving all\n\t\t *  array entries into the entries part (for good).\n\t\t *\n\t\t *  Since we don't keep track of actual density (used vs. size) of\n\t\t *  the array part, we need to estimate somehow.  The check is made\n\t\t *  in two parts:\n\t\t *\n\t\t *    - Check whether the resize need is small compared to the\n\t\t *      current size (relatively); if so, resize without further\n\t\t *      checking (essentially we assume that the original part is\n\t\t *      \"dense\" so that the result would be dense enough).\n\t\t *\n\t\t *    - Otherwise, compute the resize using an actual density\n\t\t *      measurement based on counting the used array entries.\n\t\t */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"write to new array requires array resize, decide whether to do a \"\n\t\t                     \"fast resize without abandon check (arr_idx=%ld, old_size=%ld)\",\n\t\t                     (long) arr_idx, (long) DUK_HOBJECT_GET_ASIZE(orig)));\n\n\t\tif (duk__abandon_array_slow_check_required(arr_idx, DUK_HOBJECT_GET_ASIZE(orig))) {\n\t\t\tduk_uint32_t old_used;\n\t\t\tduk_uint32_t old_size;\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"=> fast check is NOT OK, do slow check for array abandon\"));\n\n\t\t\tduk__compute_a_stats(thr, orig, &old_used, &old_size);\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"abandon check, array stats: old_used=%ld, old_size=%ld, arr_idx=%ld\",\n\t\t\t                     (long) old_used, (long) old_size, (long) arr_idx));\n\n\t\t\t/* Note: intentionally use approximations to shave a few instructions:\n\t\t\t *   a_used = old_used  (accurate: old_used + 1)\n\t\t\t *   a_size = arr_idx   (accurate: arr_idx + 1)\n\t\t\t */\n\t\t\tif (duk__abandon_array_density_check(old_used, arr_idx)) {\n\t\t\t\tDUK_DD(DUK_DDPRINT(\"write to new array entry beyond current length, \"\n\t\t\t\t                   \"decided to abandon array part (would become too sparse)\"));\n\n\t\t\t\t/* abandoning requires a props allocation resize and\n\t\t\t\t * 'rechecks' the valstack, invalidating any existing\n\t\t\t\t * valstack value pointers!\n\t\t\t\t */\n\t\t\t\tduk__abandon_array_checked(thr, orig);\n\t\t\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_ARRAY_PART(orig));\n\n\t\t\t\tgoto write_to_entry_part;\n\t\t\t}\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"=> decided to keep array part\"));\n\t\t} else {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"=> fast resize is OK\"));\n\t\t}\n\n\t\tDUK_DD(DUK_DDPRINT(\"write to new array entry beyond current length, \"\n\t\t                   \"decided to extend current allocation\"));\n\n\t\tduk__grow_props_for_array_item(thr, orig, arr_idx);\n\n\t no_array_growth:\n\n\t\t/* Note: assume array part is comprehensive, so that either\n\t\t * the write goes to the array part, or we've abandoned the\n\t\t * array above (and will not come here).\n\t\t */\n\n\t\tDUK_ASSERT(DUK_HOBJECT_HAS_ARRAY_PART(orig));\n\t\tDUK_ASSERT(arr_idx < DUK_HOBJECT_GET_ASIZE(orig));\n\n\t\ttv = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, orig, arr_idx);\n\t\t/* prev value must be unused, no decref */\n\t\tDUK_ASSERT(DUK_TVAL_IS_UNUSED(tv));\n\t\tDUK_TVAL_SET_TVAL(tv, tv_val);\n\t\tDUK_TVAL_INCREF(thr, tv);\n\t\tDUK_DD(DUK_DDPRINT(\"put to new array entry: %ld -> %!T\",\n\t\t                   (long) arr_idx, (duk_tval *) tv));\n\n\t\t/* Note: array part values are [[Writable]], [[Enumerable]],\n\t\t * and [[Configurable]] which matches the required attributes\n\t\t * here.\n\t\t */\n\t\tgoto entry_updated;\n\t}\n\n write_to_entry_part:\n\n\t/*\n\t *  Write to entry part\n\t */\n\n\t/* entry allocation updates hash part and increases the key\n\t * refcount; may need a props allocation resize but doesn't\n\t * 'recheck' the valstack.\n\t */\n\te_idx = duk__alloc_entry_checked(thr, orig, key);\n\tDUK_ASSERT(e_idx >= 0);\n\n\ttv = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, orig, e_idx);\n\t/* prev value can be garbage, no decref */\n\tDUK_TVAL_SET_TVAL(tv, tv_val);\n\tDUK_TVAL_INCREF(thr, tv);\n\tDUK_HOBJECT_E_SET_FLAGS(thr->heap, orig, e_idx, DUK_PROPDESC_FLAGS_WEC);\n\tgoto entry_updated;\n\n entry_updated:\n\n\t/*\n\t *  Possible pending array length update, which must only be done\n\t *  if the actual entry write succeeded.\n\t */\n\n\tif (new_array_length > 0) {\n\t\t/* Note: zero works as a \"no update\" marker because the new length\n\t\t * can never be zero after a new property is written.\n\t\t */\n\n\t\tDUK_ASSERT(DUK_HOBJECT_HAS_EXOTIC_ARRAY(orig));\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"write successful, pending array length update to: %ld\",\n\t\t                     (long) new_array_length));\n\n\t\t((duk_harray *) orig)->length = new_array_length;\n\t}\n\n\t/*\n\t *  Arguments exotic behavior not possible for new properties: all\n\t *  magically bound properties are initially present in the arguments\n\t *  object, and if they are deleted, the binding is also removed from\n\t *  parameter map.\n\t */\n\n\tgoto success_no_arguments_exotic;\n\n success_with_arguments_exotic:\n\n\t/*\n\t *  Arguments objects have exotic [[DefineOwnProperty]] which updates\n\t *  the internal 'map' of arguments for writes to currently mapped\n\t *  arguments.  More conretely, writes to mapped arguments generate\n\t *  a write to a bound variable.\n\t *\n\t *  The [[Put]] algorithm invokes [[DefineOwnProperty]] for existing\n\t *  data properties and new properties, but not for existing accessors.\n\t *  Hence, in E5 Section 10.6 ([[DefinedOwnProperty]] algorithm), we\n\t *  have a Desc with 'Value' (and possibly other properties too), and\n\t *  we end up in step 5.b.i.\n\t */\n\n\tif (arr_idx != DUK__NO_ARRAY_INDEX &&\n\t    DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS(orig)) {\n\t\t/* Note: only numbered indices are relevant, so arr_idx fast reject\n\t\t * is good (this is valid unless there are more than 4**32-1 arguments).\n\t\t */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"putprop successful, arguments exotic behavior needed\"));\n\n\t\t/* Note: we can reuse 'desc' here */\n\n\t\t/* XXX: top of stack must contain value, which helper doesn't touch,\n\t\t * rework to use tv_val directly?\n\t\t */\n\n\t\tduk_push_tval(ctx, tv_val);\n\t\t(void) duk__check_arguments_map_for_put(thr, orig, key, &desc, throw_flag);\n\t\tduk_pop(ctx);\n\t}\n\t/* fall thru */\n\n success_no_arguments_exotic:\n\t/* shared exit path now */\n\tDUK_DDD(DUK_DDDPRINT(\"result: success\"));\n\tduk_pop(ctx);  /* remove key */\n\treturn 1;\n\n#if defined(DUK_USE_ES6_PROXY)\n fail_proxy_rejected:\n\tDUK_DDD(DUK_DDDPRINT(\"result: error, proxy rejects\"));\n\tif (throw_flag) {\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED);\n\t}\n\t/* Note: no key on stack */\n\treturn 0;\n#endif\n\n fail_base_primitive:\n\tDUK_DDD(DUK_DDDPRINT(\"result: error, base primitive\"));\n\tif (throw_flag) {\n#if defined(DUK_USE_PARANOID_ERRORS)\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_INVALID_BASE);\n#else\n\t\tDUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, \"cannot write property %s of %s\",\n\t\t               duk_push_string_tval_readable(ctx, tv_key), duk_push_string_tval_readable(ctx, tv_obj));\n#endif\n\t}\n\tduk_pop(ctx);  /* remove key */\n\treturn 0;\n\n fail_not_extensible:\n\tDUK_DDD(DUK_DDDPRINT(\"result: error, not extensible\"));\n\tif (throw_flag) {\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_NOT_EXTENSIBLE);\n\t}\n\tduk_pop(ctx);  /* remove key */\n\treturn 0;\n\n fail_not_writable:\n\tDUK_DDD(DUK_DDDPRINT(\"result: error, not writable\"));\n\tif (throw_flag) {\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_NOT_WRITABLE);\n\t}\n\tduk_pop(ctx);  /* remove key */\n\treturn 0;\n\n#if defined(DUK_USE_ROM_OBJECTS)\n fail_not_writable_no_pop:\n\tDUK_DDD(DUK_DDDPRINT(\"result: error, not writable\"));\n\tif (throw_flag) {\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_NOT_WRITABLE);\n\t}\n\treturn 0;\n#endif\n\n fail_array_length_partial:\n\tDUK_DD(DUK_DDPRINT(\"result: error, array length write only partially successful\"));\n\tif (throw_flag) {\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE);\n\t}\n\tduk_pop(ctx);  /* remove key */\n\treturn 0;\n\n fail_no_setter:\n\tDUK_DDD(DUK_DDDPRINT(\"result: error, accessor property without setter\"));\n\tif (throw_flag) {\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_SETTER_UNDEFINED);\n\t}\n\tduk_pop(ctx);  /* remove key */\n\treturn 0;\n\n fail_internal:\n\tDUK_DDD(DUK_DDDPRINT(\"result: error, internal\"));\n\tif (throw_flag) {\n\t\tDUK_ERROR_INTERNAL(thr);\n\t}\n\tduk_pop(ctx);  /* remove key */\n\treturn 0;\n}\n\n/*\n *  Ecmascript compliant [[Delete]](P, Throw).\n */\n\nDUK_INTERNAL duk_bool_t duk_hobject_delprop_raw(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_small_uint_t flags) {\n\tduk_propdesc desc;\n\tduk_tval *tv;\n\tduk_uint32_t arr_idx;\n\tduk_bool_t throw_flag;\n\tduk_bool_t force_flag;\n\n\tthrow_flag = (flags & DUK_DELPROP_FLAG_THROW);\n\tforce_flag = (flags & DUK_DELPROP_FLAG_FORCE);\n\n\tDUK_DDD(DUK_DDDPRINT(\"delprop_raw: thr=%p, obj=%p, key=%p, throw=%ld, force=%ld (obj -> %!O, key -> %!O)\",\n\t                     (void *) thr, (void *) obj, (void *) key, (long) throw_flag, (long) force_flag,\n\t                     (duk_heaphdr *) obj, (duk_heaphdr *) key));\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\tDUK_ASSERT(obj != NULL);\n\tDUK_ASSERT(key != NULL);\n\n\tDUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);\n\n\tarr_idx = DUK_HSTRING_GET_ARRIDX_FAST(key);\n\n\t/* 0 = don't push current value */\n\tif (!duk__get_own_propdesc_raw(thr, obj, key, arr_idx, &desc, 0 /*flags*/)) {  /* don't push value */\n\t\tDUK_DDD(DUK_DDDPRINT(\"property not found, succeed always\"));\n\t\tgoto success;\n\t}\n\n#if defined(DUK_USE_ROM_OBJECTS)\n\tif (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj)) {\n\t\tDUK_DD(DUK_DDPRINT(\"attempt to delprop on read-only target object\"));\n\t\tgoto fail_not_configurable;\n\t}\n#endif\n\n\tif ((desc.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) == 0 && !force_flag) {\n\t\tgoto fail_not_configurable;\n\t}\n\tif (desc.a_idx < 0 && desc.e_idx < 0) {\n\t\t/* Currently there are no deletable virtual properties, but\n\t\t * with force_flag we might attempt to delete one.\n\t\t */\n\t\tDUK_DD(DUK_DDPRINT(\"delete failed: property found, force flag, but virtual (and implicitly non-configurable)\"));\n\t\tgoto fail_virtual;\n\t}\n\n\tif (desc.a_idx >= 0) {\n\t\tDUK_ASSERT(desc.e_idx < 0);\n\n\t\ttv = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, obj, desc.a_idx);\n\t\tDUK_TVAL_SET_UNUSED_UPDREF(thr, tv);  /* side effects */\n\t\tgoto success;\n\t} else {\n\t\tDUK_ASSERT(desc.a_idx < 0);\n\n\t\t/* remove hash entry (no decref) */\n#if defined(DUK_USE_HOBJECT_HASH_PART)\n\t\tif (desc.h_idx >= 0) {\n\t\t\tduk_uint32_t *h_base = DUK_HOBJECT_H_GET_BASE(thr->heap, obj);\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"removing hash entry at h_idx %ld\", (long) desc.h_idx));\n\t\t\tDUK_ASSERT(DUK_HOBJECT_GET_HSIZE(obj) > 0);\n\t\t\tDUK_ASSERT((duk_uint32_t) desc.h_idx < DUK_HOBJECT_GET_HSIZE(obj));\n\t\t\th_base[desc.h_idx] = DUK__HASH_DELETED;\n\t\t} else {\n\t\t\tDUK_ASSERT(DUK_HOBJECT_GET_HSIZE(obj) == 0);\n\t\t}\n#else\n\t\tDUK_ASSERT(DUK_HOBJECT_GET_HSIZE(obj) == 0);\n#endif\n\n\t\t/* Remove value.  This requires multiple writes so avoid side\n\t\t * effects via no-refzero macros so that e_idx is not\n\t\t * invalidated.\n\t\t */\n\t\tDUK_DDD(DUK_DDDPRINT(\"before removing value, e_idx %ld, key %p, key at slot %p\",\n\t\t                     (long) desc.e_idx, (void *) key, (void *) DUK_HOBJECT_E_GET_KEY(thr->heap, obj, desc.e_idx)));\n\t\tDUK_DDD(DUK_DDDPRINT(\"removing value at e_idx %ld\", (long) desc.e_idx));\n\t\tif (DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, obj, desc.e_idx)) {\n\t\t\tduk_hobject *tmp;\n\n\t\t\ttmp = DUK_HOBJECT_E_GET_VALUE_GETTER(thr->heap, obj, desc.e_idx);\n\t\t\tDUK_HOBJECT_E_SET_VALUE_GETTER(thr->heap, obj, desc.e_idx, NULL);\n\t\t\tDUK_UNREF(tmp);\n\t\t\tDUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr, tmp);\n\n\t\t\ttmp = DUK_HOBJECT_E_GET_VALUE_SETTER(thr->heap, obj, desc.e_idx);\n\t\t\tDUK_HOBJECT_E_SET_VALUE_SETTER(thr->heap, obj, desc.e_idx, NULL);\n\t\t\tDUK_UNREF(tmp);\n\t\t\tDUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr, tmp);\n\t\t} else {\n\t\t\ttv = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, desc.e_idx);\n\t\t\tDUK_TVAL_SET_UNDEFINED_UPDREF_NORZ(thr, tv);\n\t\t}\n#if 0\n\t\t/* Not strictly necessary because if key == NULL, flag MUST be ignored. */\n\t\tDUK_HOBJECT_E_SET_FLAGS(thr->heap, obj, desc.e_idx, 0);\n#endif\n\n\t\t/* Remove key. */\n\t\tDUK_DDD(DUK_DDDPRINT(\"before removing key, e_idx %ld, key %p, key at slot %p\",\n\t\t                     (long) desc.e_idx, (void *) key, (void *) DUK_HOBJECT_E_GET_KEY(thr->heap, obj, desc.e_idx)));\n\t\tDUK_DDD(DUK_DDDPRINT(\"removing key at e_idx %ld\", (long) desc.e_idx));\n\t\tDUK_ASSERT(key == DUK_HOBJECT_E_GET_KEY(thr->heap, obj, desc.e_idx));\n\t\tDUK_HOBJECT_E_SET_KEY(thr->heap, obj, desc.e_idx, NULL);\n\t\tDUK_HSTRING_DECREF_NORZ(thr, key);\n\n\t\t/* Trigger refzero side effects only when we're done as a\n\t\t * finalizer might operate on the object and affect the\n\t\t * e_idx we're supposed to use.\n\t\t */\n\t\tDUK_REFZERO_CHECK_SLOW(thr);\n\t\tgoto success;\n\t}\n\n\tDUK_UNREACHABLE();\n\n success:\n\t/*\n\t *  Argument exotic [[Delete]] behavior (E5 Section 10.6) is\n\t *  a post-check, keeping arguments internal 'map' in sync with\n\t *  any successful deletes (note that property does not need to\n\t *  exist for delete to 'succeed').\n\t *\n\t *  Delete key from 'map'.  Since 'map' only contains array index\n\t *  keys, we can use arr_idx for a fast skip.\n\t */\n\n\tDUK_DDD(DUK_DDDPRINT(\"delete successful, check for arguments exotic behavior\"));\n\n\tif (arr_idx != DUK__NO_ARRAY_INDEX && DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS(obj)) {\n\t\t/* Note: only numbered indices are relevant, so arr_idx fast reject\n\t\t * is good (this is valid unless there are more than 4**32-1 arguments).\n\t\t */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"delete successful, arguments exotic behavior needed\"));\n\n\t\t/* Note: we can reuse 'desc' here */\n\t\t(void) duk__check_arguments_map_for_delete(thr, obj, key, &desc);\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"delete successful\"));\n\treturn 1;\n\n fail_virtual:  /* just use the same \"not configurable\" error message */\n fail_not_configurable:\n\tDUK_DDD(DUK_DDDPRINT(\"delete failed: property found, not configurable\"));\n\n\tif (throw_flag) {\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE);\n\t}\n\treturn 0;\n}\n\n/*\n *  DELPROP: Ecmascript property deletion.\n */\n\nDUK_INTERNAL duk_bool_t duk_hobject_delprop(duk_hthread *thr, duk_tval *tv_obj, duk_tval *tv_key, duk_bool_t throw_flag) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hstring *key = NULL;\n#if defined(DUK_USE_ES6_PROXY)\n\tduk_propdesc desc;\n#endif\n\tduk_int_t entry_top;\n\tduk_uint32_t arr_idx = DUK__NO_ARRAY_INDEX;\n\tduk_bool_t rc;\n\n\tDUK_DDD(DUK_DDDPRINT(\"delprop: thr=%p, obj=%p, key=%p (obj -> %!T, key -> %!T)\",\n\t                     (void *) thr, (void *) tv_obj, (void *) tv_key,\n\t                     (duk_tval *) tv_obj, (duk_tval *) tv_key));\n\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\tDUK_ASSERT(tv_obj != NULL);\n\tDUK_ASSERT(tv_key != NULL);\n\n\tDUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);\n\n\t/* Storing the entry top is cheaper here to ensure stack is correct at exit,\n\t * as there are several paths out.\n\t */\n\tentry_top = duk_get_top(ctx);\n\n\tif (DUK_TVAL_IS_UNDEFINED(tv_obj) ||\n\t    DUK_TVAL_IS_NULL(tv_obj)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"base object is undefined or null -> reject\"));\n\t\tgoto fail_invalid_base_uncond;\n\t}\n\n\tduk_push_tval(ctx, tv_obj);\n\tduk_push_tval(ctx, tv_key);\n\n\ttv_obj = DUK_GET_TVAL_NEGIDX(ctx, -2);\n\tif (DUK_TVAL_IS_OBJECT(tv_obj)) {\n\t\tduk_hobject *obj = DUK_TVAL_GET_OBJECT(tv_obj);\n\t\tDUK_ASSERT(obj != NULL);\n\n#if defined(DUK_USE_ES6_PROXY)\n\t\tif (DUK_UNLIKELY(DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(obj))) {\n\t\t\tduk_hobject *h_target;\n\t\t\tduk_bool_t tmp_bool;\n\n\t\t\t/* Note: proxy handling must happen before key is string coerced. */\n\n\t\t\tif (duk__proxy_check_prop(thr, obj, DUK_STRIDX_DELETE_PROPERTY, tv_key, &h_target)) {\n\t\t\t\t/* -> [ ... obj key trap handler ] */\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"-> proxy object 'deleteProperty' for key %!T\", (duk_tval *) tv_key));\n\t\t\t\tduk_push_hobject(ctx, h_target);  /* target */\n\t\t\t\tduk_dup_m4(ctx);  /* P */\n\t\t\t\tduk_call_method(ctx, 2 /*nargs*/);\n\t\t\t\ttmp_bool = duk_to_boolean(ctx, -1);\n\t\t\t\tduk_pop(ctx);\n\t\t\t\tif (!tmp_bool) {\n\t\t\t\t\tgoto fail_proxy_rejected;  /* retval indicates delete failed */\n\t\t\t\t}\n\n\t\t\t\t/* Target object must be checked for a conflicting\n\t\t\t\t * non-configurable property.\n\t\t\t\t */\n\t\t\t\ttv_key = DUK_GET_TVAL_NEGIDX(ctx, -1);\n\t\t\t\tarr_idx = duk__push_tval_to_property_key(ctx, tv_key, &key);\n\t\t\t\tDUK_ASSERT(key != NULL);\n\n\t\t\t\tif (duk__get_own_propdesc_raw(thr, h_target, key, arr_idx, &desc, 0 /*flags*/)) {  /* don't push value */\n\t\t\t\t\tduk_small_int_t desc_reject;\n\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"proxy 'deleteProperty': target has matching property %!O, check for \"\n\t\t\t\t\t                     \"conflicting property; desc.flags=0x%08lx, \"\n\t\t\t\t\t                     \"desc.get=%p, desc.set=%p\",\n\t\t\t\t\t                     (duk_heaphdr *) key, (unsigned long) desc.flags,\n\t\t\t\t\t                     (void *) desc.get, (void *) desc.set));\n\n\t\t\t\t\tdesc_reject = !(desc.flags & DUK_PROPDESC_FLAG_CONFIGURABLE);\n\t\t\t\t\tif (desc_reject) {\n\t\t\t\t\t\t/* unconditional */\n\t\t\t\t\t\tDUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\trc = 1;  /* success */\n\t\t\t\tgoto done_rc;\n\t\t\t}\n\n\t\t\tobj = h_target;  /* resume delete to target */\n\t\t}\n#endif  /* DUK_USE_ES6_PROXY */\n\n\t\tarr_idx = duk__to_property_key(ctx, -1, &key);\n\t\tDUK_ASSERT(key != NULL);\n\n\t\trc = duk_hobject_delprop_raw(thr, obj, key, throw_flag ? DUK_DELPROP_FLAG_THROW : 0);\n\t\tgoto done_rc;\n\t} else if (DUK_TVAL_IS_STRING(tv_obj)) {\n\t\t/* String has .length and array index virtual properties\n\t\t * which can't be deleted.  No need for a symbol check;\n\t\t * no offending virtual symbols exist.\n\t\t */\n\t\t/* XXX: unnecessary string coercion for array indices,\n\t\t * intentional to keep small.\n\t\t */\n\t\tduk_hstring *h = DUK_TVAL_GET_STRING(tv_obj);\n\t\tDUK_ASSERT(h != NULL);\n\n\t\tarr_idx = duk__to_property_key(ctx, -1, &key);\n\t\tDUK_ASSERT(key != NULL);\n\n\t\tif (key == DUK_HTHREAD_STRING_LENGTH(thr)) {\n\t\t\tgoto fail_not_configurable;\n\t\t}\n\n\t\tif (arr_idx != DUK__NO_ARRAY_INDEX &&\n\t\t    arr_idx < DUK_HSTRING_GET_CHARLEN(h)) {\n\t\t\tgoto fail_not_configurable;\n\t\t}\n\t} else if (DUK_TVAL_IS_BUFFER(tv_obj)) {\n\t\t/* XXX: unnecessary string coercion for array indices,\n\t\t * intentional to keep small; some overlap with string\n\t\t * handling.\n\t\t */\n\t\tduk_hbuffer *h = DUK_TVAL_GET_BUFFER(tv_obj);\n\t\tDUK_ASSERT(h != NULL);\n\n\t\tarr_idx = duk__to_property_key(ctx, -1, &key);\n\t\tDUK_ASSERT(key != NULL);\n\n\t\tif (key == DUK_HTHREAD_STRING_LENGTH(thr)) {\n\t\t\tgoto fail_not_configurable;\n\t\t}\n\n\t\tif (arr_idx != DUK__NO_ARRAY_INDEX &&\n\t\t    arr_idx < DUK_HBUFFER_GET_SIZE(h)) {\n\t\t\tgoto fail_not_configurable;\n\t\t}\n\t} else if (DUK_TVAL_IS_LIGHTFUNC(tv_obj)) {\n\t\t/* Lightfunc virtual properties are non-configurable, so\n\t\t * reject if match any of them.\n\t\t */\n\n\t\tarr_idx = duk__to_property_key(ctx, -1, &key);\n\t\tDUK_ASSERT(key != NULL);\n\n\t\tif (duk__key_is_lightfunc_ownprop(thr, key)) {\n\t\t\tgoto fail_not_configurable;\n\t\t}\n\t}\n\n\t/* non-object base, no offending virtual property */\n\trc = 1;\n\tgoto done_rc;\n\n done_rc:\n\tduk_set_top(ctx, entry_top);\n\treturn rc;\n\n fail_invalid_base_uncond:\n\t/* Note: unconditional throw */\n\tDUK_ASSERT(duk_get_top(ctx) == entry_top);\n#if defined(DUK_USE_PARANOID_ERRORS)\n\tDUK_ERROR_TYPE(thr, DUK_STR_INVALID_BASE);\n#else\n\tDUK_ERROR_FMT2(thr, DUK_ERR_TYPE_ERROR, \"cannot delete property %s of %s\",\n\t               duk_push_string_tval_readable(ctx, tv_key), duk_push_string_tval_readable(ctx, tv_obj));\n#endif\n\treturn 0;\n\n#if defined(DUK_USE_ES6_PROXY)\n fail_proxy_rejected:\n\tif (throw_flag) {\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_PROXY_REJECTED);\n\t}\n\tduk_set_top(ctx, entry_top);\n\treturn 0;\n#endif\n\n fail_not_configurable:\n\tif (throw_flag) {\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE);\n\t}\n\tduk_set_top(ctx, entry_top);\n\treturn 0;\n}\n\n/*\n *  Internal helper to define a property with specific flags, ignoring\n *  normal semantics such as extensibility, write protection etc.\n *  Overwrites any existing value and attributes unless caller requests\n *  that value only be updated if it doesn't already exists.\n *\n *  Does not support:\n *    - virtual properties (error if write attempted)\n *    - getter/setter properties (error if write attempted)\n *    - non-default (!= WEC) attributes for array entries (error if attempted)\n *    - array abandoning: if array part exists, it is always extended\n *    - array 'length' updating\n *\n *  Stack: [... in_val] -> []\n *\n *  Used for e.g. built-in initialization and environment record\n *  operations.\n */\n\nDUK_INTERNAL void duk_hobject_define_property_internal(duk_hthread *thr, duk_hobject *obj, duk_hstring *key, duk_small_uint_t flags) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_propdesc desc;\n\tduk_uint32_t arr_idx;\n\tduk_int_t e_idx;\n\tduk_tval *tv1 = NULL;\n\tduk_tval *tv2 = NULL;\n\tduk_small_uint_t propflags = flags & DUK_PROPDESC_FLAGS_MASK;  /* mask out flags not actually stored */\n\n\tDUK_DDD(DUK_DDDPRINT(\"define new property (internal): thr=%p, obj=%!O, key=%!O, flags=0x%02lx, val=%!T\",\n\t                     (void *) thr, (duk_heaphdr *) obj, (duk_heaphdr *) key,\n\t                     (unsigned long) flags, (duk_tval *) duk_get_tval(ctx, -1)));\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\tDUK_ASSERT(obj != NULL);\n\tDUK_ASSERT(key != NULL);\n\tDUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj));\n\tDUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);\n\tDUK_ASSERT(duk_is_valid_index(ctx, -1));  /* contains value */\n\n\tarr_idx = DUK_HSTRING_GET_ARRIDX_SLOW(key);\n\n\tif (duk__get_own_propdesc_raw(thr, obj, key, arr_idx, &desc, 0 /*flags*/)) {  /* don't push value */\n\t\tif (desc.e_idx >= 0) {\n\t\t\tif (flags & DUK_PROPDESC_FLAG_NO_OVERWRITE) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"property already exists in the entry part -> skip as requested\"));\n\t\t\t\tgoto pop_exit;\n\t\t\t}\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"property already exists in the entry part -> update value and attributes\"));\n\t\t\tif (DUK_UNLIKELY(DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, obj, desc.e_idx))) {\n\t\t\t\tDUK_D(DUK_DPRINT(\"existing property is an accessor, not supported\"));\n\t\t\t\tgoto error_internal;\n\t\t\t}\n\n\t\t\tDUK_HOBJECT_E_SET_FLAGS(thr->heap, obj, desc.e_idx, propflags);\n\t\t\ttv1 = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, desc.e_idx);\n\t\t} else if (desc.a_idx >= 0) {\n\t\t\tif (flags & DUK_PROPDESC_FLAG_NO_OVERWRITE) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"property already exists in the array part -> skip as requested\"));\n\t\t\t\tgoto pop_exit;\n\t\t\t}\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"property already exists in the array part -> update value (assert attributes)\"));\n\t\t\tif (propflags != DUK_PROPDESC_FLAGS_WEC) {\n\t\t\t\tDUK_D(DUK_DPRINT(\"existing property in array part, but propflags not WEC (0x%02lx)\",\n\t\t\t\t                 (unsigned long) propflags));\n\t\t\t\tgoto error_internal;\n\t\t\t}\n\n\t\t\ttv1 = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, obj, desc.a_idx);\n\t\t} else {\n\t\t\tif (flags & DUK_PROPDESC_FLAG_NO_OVERWRITE) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"property already exists but is virtual -> skip as requested\"));\n\t\t\t\tgoto pop_exit;\n\t\t\t}\n\t\t\tif (key == DUK_HTHREAD_STRING_LENGTH(thr) && DUK_HOBJECT_HAS_EXOTIC_ARRAY(obj)) {\n\t\t\t\tduk_uint32_t new_len;\n#if defined(DUK_USE_DEBUG)\n\t\t\t\tduk_uint32_t prev_len;\n\t\t\t\tprev_len = ((duk_harray *) obj)->length;\n#endif\n\t\t\t\tnew_len = duk__to_new_array_length_checked(thr, DUK_GET_TVAL_NEGIDX(ctx, -1));\n\t\t\t\t((duk_harray *) obj)->length = new_len;\n\t\t\t\tDUK_D(DUK_DPRINT(\"internal define property for array .length: %ld -> %ld\",\n\t\t\t\t                 (long) prev_len, (long) ((duk_harray *) obj)->length));\n\t\t\t\tgoto pop_exit;\n\t\t\t}\n\t\t\tDUK_DD(DUK_DDPRINT(\"property already exists but is virtual -> failure\"));\n\t\t\tgoto error_virtual;\n\t\t}\n\n\t\tgoto write_value;\n\t}\n\n\tif (DUK_HOBJECT_HAS_ARRAY_PART(obj)) {\n\t\tif (arr_idx != DUK__NO_ARRAY_INDEX) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"property does not exist, object has array part -> possibly extend array part and write value (assert attributes)\"));\n\t\t\tDUK_ASSERT(propflags == DUK_PROPDESC_FLAGS_WEC);\n\n\t\t\t/* always grow the array, no sparse / abandon support here */\n\t\t\tif (arr_idx >= DUK_HOBJECT_GET_ASIZE(obj)) {\n\t\t\t\tduk__grow_props_for_array_item(thr, obj, arr_idx);\n\t\t\t}\n\n\t\t\tDUK_ASSERT(arr_idx < DUK_HOBJECT_GET_ASIZE(obj));\n\t\t\ttv1 = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, obj, arr_idx);\n\t\t\tgoto write_value;\n\t\t}\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"property does not exist, object belongs in entry part -> allocate new entry and write value and attributes\"));\n\te_idx = duk__alloc_entry_checked(thr, obj, key);  /* increases key refcount */\n\tDUK_ASSERT(e_idx >= 0);\n\tDUK_HOBJECT_E_SET_FLAGS(thr->heap, obj, e_idx, propflags);\n\ttv1 = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, e_idx);\n\t/* new entry: previous value is garbage; set to undefined to share write_value */\n\tDUK_TVAL_SET_UNDEFINED(tv1);\n\tgoto write_value;\n\n write_value:\n\t/* tv1 points to value storage */\n\n\ttv2 = duk_require_tval(ctx, -1);  /* late lookup, avoid side effects */\n\tDUK_DDD(DUK_DDDPRINT(\"writing/updating value: %!T -> %!T\",\n\t                     (duk_tval *) tv1, (duk_tval *) tv2));\n\n\tDUK_TVAL_SET_TVAL_UPDREF(thr, tv1, tv2);  /* side effects */\n\tgoto pop_exit;\n\n pop_exit:\n\tduk_pop(ctx);  /* remove in_val */\n\treturn;\n\n error_virtual:  /* share error message */\n error_internal:\n\tDUK_ERROR_INTERNAL(thr);\n\treturn;\n}\n\n/*\n *  Fast path for defining array indexed values without interning the key.\n *  This is used by e.g. code for Array prototype and traceback creation so\n *  must avoid interning.\n */\n\nDUK_INTERNAL void duk_hobject_define_property_internal_arridx(duk_hthread *thr, duk_hobject *obj, duk_uarridx_t arr_idx, duk_small_uint_t flags) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hstring *key;\n\tduk_tval *tv1, *tv2;\n\n\tDUK_DDD(DUK_DDDPRINT(\"define new property (internal) arr_idx fast path: thr=%p, obj=%!O, \"\n\t                     \"arr_idx=%ld, flags=0x%02lx, val=%!T\",\n\t                     (void *) thr, obj, (long) arr_idx, (unsigned long) flags,\n\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\tDUK_ASSERT(obj != NULL);\n\tDUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj));\n\n\tif (DUK_HOBJECT_HAS_ARRAY_PART(obj) &&\n\t    arr_idx != DUK__NO_ARRAY_INDEX &&\n\t    flags == DUK_PROPDESC_FLAGS_WEC) {\n\t\tDUK_ASSERT((flags & DUK_PROPDESC_FLAG_NO_OVERWRITE) == 0);  /* covered by comparison */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"define property to array part (property may or may not exist yet)\"));\n\n\t\t/* always grow the array, no sparse / abandon support here */\n\t\tif (arr_idx >= DUK_HOBJECT_GET_ASIZE(obj)) {\n\t\t\tduk__grow_props_for_array_item(thr, obj, arr_idx);\n\t\t}\n\n\t\tDUK_ASSERT(arr_idx < DUK_HOBJECT_GET_ASIZE(obj));\n\t\ttv1 = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, obj, arr_idx);\n\t\ttv2 = duk_require_tval(ctx, -1);\n\n\t\tDUK_TVAL_SET_TVAL_UPDREF(thr, tv1, tv2);  /* side effects */\n\n\t\tduk_pop(ctx);  /* [ ...val ] -> [ ... ] */\n\t\treturn;\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"define property fast path didn't work, use slow path\"));\n\n\tkey = duk_push_uint_to_hstring(ctx, (duk_uint_t) arr_idx);\n\tDUK_ASSERT(key != NULL);\n\tduk_insert(ctx, -2);  /* [ ... val key ] -> [ ... key val ] */\n\n\tduk_hobject_define_property_internal(thr, obj, key, flags);\n\n\tduk_pop(ctx);  /* [ ... key ] -> [ ... ] */\n}\n\n/*\n *  Internal helpers for managing object 'length'\n */\n\nDUK_INTERNAL duk_size_t duk_hobject_get_length(duk_hthread *thr, duk_hobject *obj) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_double_t val;\n\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(obj != NULL);\n\n\t/* Fast path for Arrays. */\n\tif (DUK_HOBJECT_HAS_EXOTIC_ARRAY(obj)) {\n\t\treturn ((duk_harray *) obj)->length;\n\t}\n\n\t/* Slow path, .length can be e.g. accessor, obj can be a Proxy, etc. */\n\tduk_push_hobject(ctx, obj);\n\tduk_push_hstring_stridx(ctx, DUK_STRIDX_LENGTH);\n\t(void) duk_hobject_getprop(thr,\n\t                           DUK_GET_TVAL_NEGIDX(ctx, -2),\n\t                           DUK_GET_TVAL_NEGIDX(ctx, -1));\n\tval = duk_to_number_m1(ctx);\n\tduk_pop_3(ctx);\n\n\t/* This isn't part of Ecmascript semantics; return a value within\n\t * duk_size_t range, or 0 otherwise.\n\t */\n\tif (val >= 0.0 && val <= (duk_double_t) DUK_SIZE_MAX) {\n\t\treturn (duk_size_t) val;\n\t}\n\treturn 0;\n}\n\n/*\n *  Fast finalizer check for an object.  Walks the prototype chain, checking\n *  for finalizer presence using DUK_HOBJECT_FLAG_HAVE_FINALIZER which is kept\n *  in sync with the actual property when setting/removing the finalizer.\n */\n\n#if defined(DUK_USE_HEAPPTR16)\nDUK_INTERNAL duk_bool_t duk_hobject_has_finalizer_fast_raw(duk_heap *heap, duk_hobject *obj) {\n#else\nDUK_INTERNAL duk_bool_t duk_hobject_has_finalizer_fast_raw(duk_hobject *obj) {\n#endif\n\tduk_uint_t sanity;\n\n\tDUK_ASSERT(obj != NULL);\n\n\tsanity = DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY;\n\tdo {\n\t\tif (DUK_UNLIKELY(DUK_HOBJECT_HAS_HAVE_FINALIZER(obj))) {\n\t\t\treturn 1;\n\t\t}\n\t\tif (DUK_UNLIKELY(sanity-- == 0)) {\n\t\t\tDUK_D(DUK_DPRINT(\"prototype loop when checking for finalizer existence; returning false\"));\n\t\t\treturn 0;\n\t\t}\n#if defined(DUK_USE_HEAPPTR16)\n\t\tDUK_ASSERT(heap != NULL);\n\t\tobj = DUK_HOBJECT_GET_PROTOTYPE(heap, obj);\n#else\n\t\tobj = DUK_HOBJECT_GET_PROTOTYPE(NULL, obj);  /* 'heap' arg ignored */\n#endif\n\t} while (obj != NULL);\n\n\treturn 0;\n}\n\n/*\n *  Object.getOwnPropertyDescriptor()  (E5 Sections 15.2.3.3, 8.10.4)\n *\n *  [ ... key ] -> [ ... desc/undefined ]\n */\n\nDUK_INTERNAL void duk_hobject_object_get_own_property_descriptor(duk_context *ctx, duk_idx_t obj_idx) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hobject *obj;\n\tduk_hstring *key;\n\tduk_propdesc pd;\n\tduk_bool_t rc;\n\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\n\tobj = duk_require_hobject_promote_mask(ctx, obj_idx, DUK_TYPE_MASK_LIGHTFUNC | DUK_TYPE_MASK_BUFFER);\n\tkey = duk_to_property_key_hstring(ctx, -1);\n\tDUK_ASSERT(key != NULL);\n\n\tDUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);\n\n\trc = duk_hobject_get_own_propdesc(thr, obj, key, &pd, DUK_GETDESC_FLAG_PUSH_VALUE);\n\tif (!rc) {\n\t\tduk_push_undefined(ctx);\n\t\tduk_remove_m2(ctx);\n\t\treturn;\n\t}\n\n\tduk_push_object(ctx);\n\n\t/* [ ... key value desc ] */\n\n\tif (DUK_PROPDESC_IS_ACCESSOR(&pd)) {\n\t\t/* If a setter/getter is missing (undefined), the descriptor must\n\t\t * still have the property present with the value 'undefined'.\n\t\t */\n\t\tif (pd.get) {\n\t\t\tduk_push_hobject(ctx, pd.get);\n\t\t} else {\n\t\t\tduk_push_undefined(ctx);\n\t\t}\n\t\tduk_put_prop_stridx_short(ctx, -2, DUK_STRIDX_GET);\n\t\tif (pd.set) {\n\t\t\tduk_push_hobject(ctx, pd.set);\n\t\t} else {\n\t\t\tduk_push_undefined(ctx);\n\t\t}\n\t\tduk_put_prop_stridx_short(ctx, -2, DUK_STRIDX_SET);\n\t} else {\n\t\tduk_dup_m2(ctx);\n\t\tduk_put_prop_stridx_short(ctx, -2, DUK_STRIDX_VALUE);\n\t\tduk_push_boolean(ctx, DUK_PROPDESC_IS_WRITABLE(&pd));\n\t\tduk_put_prop_stridx_short(ctx, -2, DUK_STRIDX_WRITABLE);\n\t}\n\tduk_push_boolean(ctx, DUK_PROPDESC_IS_ENUMERABLE(&pd));\n\tduk_put_prop_stridx_short(ctx, -2, DUK_STRIDX_ENUMERABLE);\n\tduk_push_boolean(ctx, DUK_PROPDESC_IS_CONFIGURABLE(&pd));\n\tduk_put_prop_stridx_short(ctx, -2, DUK_STRIDX_CONFIGURABLE);\n\n\t/* [ ... key value desc ] */\n\n\tduk_replace(ctx, -3);\n\tduk_pop(ctx);  /* -> [ ... desc ] */\n}\n\n/*\n *  NormalizePropertyDescriptor() related helper.\n *\n *  Internal helper which validates and normalizes a property descriptor\n *  represented as an Ecmascript object (e.g. argument to defineProperty()).\n *  The output of this conversion is a set of defprop_flags and possibly\n *  some values pushed on the value stack to (1) ensure borrowed pointers\n *  remain valid, and (2) avoid unnecessary pops for footprint reasons.\n *  Caller must manage stack top carefully because the number of values\n *  pushed depends on the input property descriptor.\n *\n *  The original descriptor object must not be altered in the process.\n */\n\n/* XXX: very basic optimization -> duk_get_prop_stridx_top */\n\nDUK_INTERNAL\nvoid duk_hobject_prepare_property_descriptor(duk_context *ctx,\n                                             duk_idx_t idx_in,\n                                             duk_uint_t *out_defprop_flags,\n                                             duk_idx_t *out_idx_value,\n                                             duk_hobject **out_getter,\n                                             duk_hobject **out_setter) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_idx_t idx_value = -1;\n\tduk_hobject *getter = NULL;\n\tduk_hobject *setter = NULL;\n\tduk_bool_t is_data_desc = 0;\n\tduk_bool_t is_acc_desc = 0;\n\tduk_uint_t defprop_flags = 0;\n\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(out_defprop_flags != NULL);\n\tDUK_ASSERT(out_idx_value != NULL);\n\tDUK_ASSERT(out_getter != NULL);\n\tDUK_ASSERT(out_setter != NULL);\n\tDUK_ASSERT(idx_in <= 0x7fffL);  /* short variants would be OK, but not used to avoid shifts */\n\n\t/* Must be an object, otherwise TypeError (E5.1 Section 8.10.5, step 1). */\n\tidx_in = duk_require_normalize_index(ctx, idx_in);\n\t(void) duk_require_hobject(ctx, idx_in);\n\n\t/* The coercion order must match the ToPropertyDescriptor() algorithm\n\t * so that side effects in coercion happen in the correct order.\n\t * (This order also happens to be compatible with duk_def_prop(),\n\t * although it doesn't matter in practice.)\n\t */\n\n\tif (duk_get_prop_stridx(ctx, idx_in, DUK_STRIDX_VALUE)) {\n\t\tis_data_desc = 1;\n\t\tdefprop_flags |= DUK_DEFPROP_HAVE_VALUE;\n\t\tidx_value = duk_get_top_index(ctx);\n\t}\n\n\tif (duk_get_prop_stridx(ctx, idx_in, DUK_STRIDX_WRITABLE)) {\n\t\tis_data_desc = 1;\n\t\tif (duk_to_boolean(ctx, -1)) {\n\t\t\tdefprop_flags |= DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_WRITABLE;\n\t\t} else {\n\t\t\tdefprop_flags |= DUK_DEFPROP_HAVE_WRITABLE;\n\t\t}\n\t}\n\n\tif (duk_get_prop_stridx(ctx, idx_in, DUK_STRIDX_GET)) {\n\t\tduk_tval *tv = duk_require_tval(ctx, -1);\n\t\tduk_hobject *h_get;\n\n\t\tif (DUK_TVAL_IS_UNDEFINED(tv)) {\n\t\t\t/* undefined is accepted */\n\t\t\tDUK_ASSERT(getter == NULL);\n\t\t} else {\n\t\t\t/* NOTE: lightfuncs are coerced to full functions because\n\t\t\t * lightfuncs don't fit into a property value slot.  This\n\t\t\t * has some side effects, see test-dev-lightfunc-accessor.js.\n\t\t\t */\n\t\t\th_get = duk_get_hobject_promote_lfunc(ctx, -1);\n\t\t\tif (h_get == NULL || !DUK_HOBJECT_IS_CALLABLE(h_get)) {\n\t\t\t\tgoto type_error;\n\t\t\t}\n\t\t\tgetter = h_get;\n\t\t}\n\t\tis_acc_desc = 1;\n\t\tdefprop_flags |= DUK_DEFPROP_HAVE_GETTER;\n\t}\n\n\tif (duk_get_prop_stridx(ctx, idx_in, DUK_STRIDX_SET)) {\n\t\tduk_tval *tv = duk_require_tval(ctx, -1);\n\t\tduk_hobject *h_set;\n\n\t\tif (DUK_TVAL_IS_UNDEFINED(tv)) {\n\t\t\t/* undefined is accepted */\n\t\t\tDUK_ASSERT(setter == NULL);\n\t\t}  else {\n\t\t\t/* NOTE: lightfuncs are coerced to full functions because\n\t\t\t * lightfuncs don't fit into a property value slot.  This\n\t\t\t * has some side effects, see test-dev-lightfunc-accessor.js.\n\t\t\t */\n\t\t\th_set = duk_get_hobject_promote_lfunc(ctx, -1);\n\t\t\tif (h_set == NULL || !DUK_HOBJECT_IS_CALLABLE(h_set)) {\n\t\t\t\tgoto type_error;\n\t\t\t}\n\t\t\tsetter = h_set;\n\t\t}\n\t\tis_acc_desc = 1;\n\t\tdefprop_flags |= DUK_DEFPROP_HAVE_SETTER;\n\t}\n\n\tif (duk_get_prop_stridx(ctx, idx_in, DUK_STRIDX_ENUMERABLE)) {\n\t\tif (duk_to_boolean(ctx, -1)) {\n\t\t\tdefprop_flags |= DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE;\n\t\t} else {\n\t\t\tdefprop_flags |= DUK_DEFPROP_HAVE_ENUMERABLE;\n\t\t}\n\t}\n\n\tif (duk_get_prop_stridx(ctx, idx_in, DUK_STRIDX_CONFIGURABLE)) {\n\t\tif (duk_to_boolean(ctx, -1)) {\n\t\t\tdefprop_flags |= DUK_DEFPROP_HAVE_CONFIGURABLE | DUK_DEFPROP_CONFIGURABLE;\n\t\t} else {\n\t\t\tdefprop_flags |= DUK_DEFPROP_HAVE_CONFIGURABLE;\n\t\t}\n\t}\n\n\tif (is_data_desc && is_acc_desc) {\n\t\tgoto type_error;\n\t}\n\n\t*out_defprop_flags = defprop_flags;\n\t*out_idx_value = idx_value;\n\t*out_getter = getter;\n\t*out_setter = setter;\n\n\t/* [ ... [multiple values] ] */\n\treturn;\n\n type_error:\n\tDUK_ERROR_TYPE(thr, DUK_STR_INVALID_DESCRIPTOR);\n}\n\n/*\n *  Object.defineProperty() related helper (E5 Section 15.2.3.6).\n *  Also handles ES2015 Reflect.defineProperty().\n *\n *  Inlines all [[DefineOwnProperty]] exotic behaviors.\n *\n *  Note: Ecmascript compliant [[DefineOwnProperty]](P, Desc, Throw) is not\n *  implemented directly, but Object.defineProperty() serves its purpose.\n *  We don't need the [[DefineOwnProperty]] internally and we don't have a\n *  property descriptor with 'missing values' so it's easier to avoid it\n *  entirely.\n *\n *  Note: this is only called for actual objects, not primitive values.\n *  This must support virtual properties for full objects (e.g. Strings)\n *  but not for plain values (e.g. strings).  Lightfuncs, even though\n *  primitive in a sense, are treated like objects and accepted as target\n *  values.\n */\n\n/* XXX: this is a major target for size optimization */\nDUK_INTERNAL\nduk_bool_t duk_hobject_define_property_helper(duk_context *ctx,\n                                              duk_uint_t defprop_flags,\n                                              duk_hobject *obj,\n                                              duk_hstring *key,\n                                              duk_idx_t idx_value,\n                                              duk_hobject *get,\n                                              duk_hobject *set,\n                                              duk_bool_t throw_flag) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_uint32_t arr_idx;\n\tduk_tval tv;\n\tduk_bool_t has_enumerable;\n\tduk_bool_t has_configurable;\n\tduk_bool_t has_writable;\n\tduk_bool_t has_value;\n\tduk_bool_t has_get;\n\tduk_bool_t has_set;\n\tduk_bool_t is_enumerable;\n\tduk_bool_t is_configurable;\n\tduk_bool_t is_writable;\n\tduk_bool_t force_flag;\n\tduk_small_uint_t new_flags;\n\tduk_propdesc curr;\n\tduk_uint32_t arridx_new_array_length;  /* != 0 => post-update for array 'length' (used when key is an array index) */\n\tduk_uint32_t arrlen_old_len;\n\tduk_uint32_t arrlen_new_len;\n\tduk_bool_t pending_write_protect;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(obj != NULL);\n\tDUK_ASSERT(key != NULL);\n\t/* idx_value may be < 0 (no value), set and get may be NULL */\n\n\tDUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);\n\n\t/* All the flags fit in 16 bits, so will fit into duk_bool_t. */\n\n\thas_writable = (defprop_flags & DUK_DEFPROP_HAVE_WRITABLE);\n\thas_enumerable = (defprop_flags & DUK_DEFPROP_HAVE_ENUMERABLE);\n\thas_configurable = (defprop_flags & DUK_DEFPROP_HAVE_CONFIGURABLE);\n\thas_value = (defprop_flags & DUK_DEFPROP_HAVE_VALUE);\n\thas_get = (defprop_flags & DUK_DEFPROP_HAVE_GETTER);\n\thas_set = (defprop_flags & DUK_DEFPROP_HAVE_SETTER);\n\tis_writable = (defprop_flags & DUK_DEFPROP_WRITABLE);\n\tis_enumerable = (defprop_flags & DUK_DEFPROP_ENUMERABLE);\n\tis_configurable = (defprop_flags & DUK_DEFPROP_CONFIGURABLE);\n\tforce_flag = (defprop_flags & DUK_DEFPROP_FORCE);\n\n\tarr_idx = DUK_HSTRING_GET_ARRIDX_SLOW(key);\n\n\tarridx_new_array_length = 0;\n\tpending_write_protect = 0;\n\tarrlen_old_len = 0;\n\tarrlen_new_len = 0;\n\n\tDUK_DDD(DUK_DDDPRINT(\"has_enumerable=%ld is_enumerable=%ld \"\n\t                     \"has_configurable=%ld is_configurable=%ld \"\n\t                     \"has_writable=%ld is_writable=%ld \"\n\t                     \"has_value=%ld value=%!T \"\n\t                     \"has_get=%ld get=%p=%!O \"\n\t                     \"has_set=%ld set=%p=%!O \"\n\t                     \"arr_idx=%ld throw_flag=!%ld\",\n\t                     (long) has_enumerable, (long) is_enumerable,\n\t                     (long) has_configurable, (long) is_configurable,\n\t                     (long) has_writable, (long) is_writable,\n\t                     (long) has_value, (duk_tval *) (idx_value >= 0 ? duk_get_tval(ctx, idx_value) : NULL),\n\t                     (long) has_get, (void *) get, (duk_heaphdr *) get,\n\t                     (long) has_set, (void *) set, (duk_heaphdr *) set,\n\t                     (long) arr_idx, (long) throw_flag));\n\n\t/*\n\t *  Array exotic behaviors can be implemented at this point.  The local variables\n\t *  are essentially a 'value copy' of the input descriptor (Desc), which is modified\n\t *  by the Array [[DefineOwnProperty]] (E5 Section 15.4.5.1).\n\t */\n\n\tif (!DUK_HOBJECT_HAS_EXOTIC_ARRAY(obj)) {\n\t\tgoto skip_array_exotic;\n\t}\n\n\tif (key == DUK_HTHREAD_STRING_LENGTH(thr)) {\n\t\tduk_harray *a;\n\n\t\t/* E5 Section 15.4.5.1, step 3, steps a - i are implemented here, j - n at the end */\n\t\tif (!has_value) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"exotic array behavior for 'length', but no value in descriptor -> normal behavior\"));\n\t\t\tgoto skip_array_exotic;\n\t\t}\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"exotic array behavior for 'length', value present in descriptor -> exotic behavior\"));\n\n\t\t/*\n\t\t *  Get old and new length\n\t\t */\n\n\t\ta = (duk_harray *) obj;\n\t\tDUK_ASSERT_HARRAY_VALID(a);\n\t\tarrlen_old_len = a->length;\n\n\t\tDUK_ASSERT(idx_value >= 0);\n\t\tarrlen_new_len = duk__to_new_array_length_checked(thr, DUK_GET_TVAL_POSIDX(ctx, idx_value));\n\t\tduk_push_u32(ctx, arrlen_new_len);\n\t\tduk_replace(ctx, idx_value);  /* step 3.e: replace 'Desc.[[Value]]' */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"old_len=%ld, new_len=%ld\", (long) arrlen_old_len, (long) arrlen_new_len));\n\n\t\tif (arrlen_new_len >= arrlen_old_len) {\n\t\t\t/* standard behavior, step 3.f.i */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"new length is same or higher as previous => standard behavior\"));\n\t\t\tgoto skip_array_exotic;\n\t\t}\n\t\tDUK_DDD(DUK_DDDPRINT(\"new length is smaller than previous => exotic post behavior\"));\n\n\t\t/* XXX: consolidated algorithm step 15.f -> redundant? */\n\t\tif (DUK_HARRAY_LENGTH_NONWRITABLE(a) && !force_flag) {\n\t\t\t/* Array .length is always non-configurable; if it's also\n\t\t\t * non-writable, don't allow it to be written.\n\t\t\t */\n\t\t\tgoto fail_not_configurable;\n\t\t}\n\n\t\t/* steps 3.h and 3.i */\n\t\tif (has_writable && !is_writable) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"desc writable is false, force it back to true, and flag pending write protect\"));\n\t\t\tis_writable = 1;\n\t\t\tpending_write_protect = 1;\n\t\t}\n\n\t\t/* remaining actual steps are carried out if standard DefineOwnProperty succeeds */\n\t} else if (arr_idx != DUK__NO_ARRAY_INDEX) {\n\t\t/* XXX: any chance of unifying this with the 'length' key handling? */\n\n\t\t/* E5 Section 15.4.5.1, step 4 */\n\t\tduk_uint32_t old_len;\n\t\tduk_harray *a;\n\n\t\ta = (duk_harray *) obj;\n\t\tDUK_ASSERT_HARRAY_VALID(a);\n\n\t\told_len = a->length;\n\n\t\tif (arr_idx >= old_len) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"defineProperty requires array length update \"\n\t\t\t                     \"(arr_idx=%ld, old_len=%ld)\",\n\t\t\t                     (long) arr_idx, (long) old_len));\n\n\t\t\tif (DUK_HARRAY_LENGTH_NONWRITABLE(a) && !force_flag) {\n\t\t\t\t/* Array .length is always non-configurable, so\n\t\t\t\t * if it's also non-writable, don't allow a value\n\t\t\t\t * write.  With force flag allow writing.\n\t\t\t\t */\n\t\t\t\tgoto fail_not_configurable;\n\t\t\t}\n\n\t\t\t/* actual update happens once write has been completed without\n\t\t\t * error below.\n\t\t\t */\n\t\t\tDUK_ASSERT(arr_idx != 0xffffffffUL);\n\t\t\tarridx_new_array_length = arr_idx + 1;\n\t\t} else {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"defineProperty does not require length update \"\n\t\t\t                     \"(arr_idx=%ld, old_len=%ld) -> standard behavior\",\n\t\t\t                     (long) arr_idx, (long) old_len));\n\t\t}\n\t}\n skip_array_exotic:\n\n\t/* XXX: There is currently no support for writing buffer object\n\t * indexed elements here.  Attempt to do so will succeed and\n\t * write a concrete property into the buffer object.  This should\n\t * be fixed at some point but because buffers are a custom feature\n\t * anyway, this is relatively unimportant.\n\t */\n\n\t/*\n\t *  Actual Object.defineProperty() default algorithm.\n\t */\n\n\t/*\n\t *  First check whether property exists; if not, simple case.  This covers\n\t *  steps 1-4.\n\t */\n\n\tif (!duk__get_own_propdesc_raw(thr, obj, key, arr_idx, &curr, DUK_GETDESC_FLAG_PUSH_VALUE)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"property does not exist\"));\n\n\t\tif (!DUK_HOBJECT_HAS_EXTENSIBLE(obj) && !force_flag) {\n\t\t\tgoto fail_not_extensible;\n\t\t}\n\n#if defined(DUK_USE_ROM_OBJECTS)\n\t\t/* ROM objects are never extensible but force flag may\n\t\t * allow us to come here anyway.\n\t\t */\n\t\tDUK_ASSERT(!DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj) || !DUK_HOBJECT_HAS_EXTENSIBLE(obj));\n\t\tif (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj)) {\n\t\t\tDUK_D(DUK_DPRINT(\"attempt to define property on a read-only target object\"));\n\t\t\tgoto fail_not_configurable;\n\t\t}\n#endif\n\n\t\t/* XXX: share final setting code for value and flags?  difficult because\n\t\t * refcount code is different.  Share entry allocation?  But can't allocate\n\t\t * until array index checked.\n\t\t */\n\n\t\t/* steps 4.a and 4.b are tricky */\n\t\tif (has_set || has_get) {\n\t\t\tduk_int_t e_idx;\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"create new accessor property\"));\n\n\t\t\tDUK_ASSERT(has_set || set == NULL);\n\t\t\tDUK_ASSERT(has_get || get == NULL);\n\t\t\tDUK_ASSERT(!has_value);\n\t\t\tDUK_ASSERT(!has_writable);\n\n\t\t\tnew_flags = DUK_PROPDESC_FLAG_ACCESSOR;  /* defaults, E5 Section 8.6.1, Table 7 */\n\t\t\tif (has_enumerable && is_enumerable) {\n\t\t\t\tnew_flags |= DUK_PROPDESC_FLAG_ENUMERABLE;\n\t\t\t}\n\t\t\tif (has_configurable && is_configurable) {\n\t\t\t\tnew_flags |= DUK_PROPDESC_FLAG_CONFIGURABLE;\n\t\t\t}\n\n\t\t\tif (arr_idx != DUK__NO_ARRAY_INDEX && DUK_HOBJECT_HAS_ARRAY_PART(obj)) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"accessor cannot go to array part, abandon array\"));\n\t\t\t\tduk__abandon_array_checked(thr, obj);\n\t\t\t}\n\n\t\t\t/* write to entry part */\n\t\t\te_idx = duk__alloc_entry_checked(thr, obj, key);\n\t\t\tDUK_ASSERT(e_idx >= 0);\n\n\t\t\tDUK_HOBJECT_E_SET_VALUE_GETTER(thr->heap, obj, e_idx, get);\n\t\t\tDUK_HOBJECT_E_SET_VALUE_SETTER(thr->heap, obj, e_idx, set);\n\t\t\tDUK_HOBJECT_INCREF_ALLOWNULL(thr, get);\n\t\t\tDUK_HOBJECT_INCREF_ALLOWNULL(thr, set);\n\n\t\t\tDUK_HOBJECT_E_SET_FLAGS(thr->heap, obj, e_idx, new_flags);\n\t\t\tgoto success_exotics;\n\t\t} else {\n\t\t\tduk_int_t e_idx;\n\t\t\tduk_tval *tv2;\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"create new data property\"));\n\n\t\t\tDUK_ASSERT(!has_set);\n\t\t\tDUK_ASSERT(!has_get);\n\n\t\t\tnew_flags = 0;  /* defaults, E5 Section 8.6.1, Table 7 */\n\t\t\tif (has_writable && is_writable) {\n\t\t\t\tnew_flags |= DUK_PROPDESC_FLAG_WRITABLE;\n\t\t\t}\n\t\t\tif (has_enumerable && is_enumerable) {\n\t\t\t\tnew_flags |= DUK_PROPDESC_FLAG_ENUMERABLE;\n\t\t\t}\n\t\t\tif (has_configurable && is_configurable) {\n\t\t\t\tnew_flags |= DUK_PROPDESC_FLAG_CONFIGURABLE;\n\t\t\t}\n\t\t\tif (has_value) {\n\t\t\t\tduk_tval *tv_tmp = duk_require_tval(ctx, idx_value);\n\t\t\t\tDUK_TVAL_SET_TVAL(&tv, tv_tmp);\n\t\t\t} else {\n\t\t\t\tDUK_TVAL_SET_UNDEFINED(&tv);  /* default value */\n\t\t\t}\n\n\t\t\tif (arr_idx != DUK__NO_ARRAY_INDEX && DUK_HOBJECT_HAS_ARRAY_PART(obj)) {\n\t\t\t\tif (new_flags == DUK_PROPDESC_FLAGS_WEC) {\n#if 0\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"new data property attributes match array defaults, attempt to write to array part\"));\n\t\t\t\t\t/* may become sparse...*/\n#endif\n\t\t\t\t\t/* XXX: handling for array part missing now; this doesn't affect\n\t\t\t\t\t * compliance but causes array entry writes using defineProperty()\n\t\t\t\t\t * to always abandon array part.\n\t\t\t\t\t */\n\t\t\t\t}\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"new data property cannot go to array part, abandon array\"));\n\t\t\t\tduk__abandon_array_checked(thr, obj);\n\t\t\t\t/* fall through */\n\t\t\t}\n\n\t\t\t/* write to entry part */\n\t\t\te_idx = duk__alloc_entry_checked(thr, obj, key);\n\t\t\tDUK_ASSERT(e_idx >= 0);\n\t\t\ttv2 = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, e_idx);\n\t\t\tDUK_TVAL_SET_TVAL(tv2, &tv);\n\t\t\tDUK_TVAL_INCREF(thr, tv2);\n\n\t\t\tDUK_HOBJECT_E_SET_FLAGS(thr->heap, obj, e_idx, new_flags);\n\t\t\tgoto success_exotics;\n\t\t}\n\t\tDUK_UNREACHABLE();\n\t}\n\n\t/* we currently assume virtual properties are not configurable (as none of them are) */\n\tDUK_ASSERT((curr.e_idx >= 0 || curr.a_idx >= 0) || !(curr.flags & DUK_PROPDESC_FLAG_CONFIGURABLE));\n\n\t/* [obj key desc value get set curr_value] */\n\n\t/*\n\t *  Property already exists.  Steps 5-6 detect whether any changes need\n\t *  to be made.\n\t */\n\n\tif (has_enumerable) {\n\t\tif (is_enumerable) {\n\t\t\tif (!(curr.flags & DUK_PROPDESC_FLAG_ENUMERABLE)) {\n\t\t\t\tgoto need_check;\n\t\t\t}\n\t\t} else {\n\t\t\tif (curr.flags & DUK_PROPDESC_FLAG_ENUMERABLE) {\n\t\t\t\tgoto need_check;\n\t\t\t}\n\t\t}\n\t}\n\tif (has_configurable) {\n\t\tif (is_configurable) {\n\t\t\tif (!(curr.flags & DUK_PROPDESC_FLAG_CONFIGURABLE)) {\n\t\t\t\tgoto need_check;\n\t\t\t}\n\t\t} else {\n\t\t\tif (curr.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) {\n\t\t\t\tgoto need_check;\n\t\t\t}\n\t\t}\n\t}\n\tif (has_value) {\n\t\tduk_tval *tmp1;\n\t\tduk_tval *tmp2;\n\n\t\t/* attempt to change from accessor to data property */\n\t\tif (curr.flags & DUK_PROPDESC_FLAG_ACCESSOR) {\n\t\t\tgoto need_check;\n\t\t}\n\n\t\ttmp1 = duk_require_tval(ctx, -1);         /* curr value */\n\t\ttmp2 = duk_require_tval(ctx, idx_value);  /* new value */\n\t\tif (!duk_js_samevalue(tmp1, tmp2)) {\n\t\t\tgoto need_check;\n\t\t}\n\t}\n\tif (has_writable) {\n\t\t/* attempt to change from accessor to data property */\n\t\tif (curr.flags & DUK_PROPDESC_FLAG_ACCESSOR) {\n\t\t\tgoto need_check;\n\t\t}\n\n\t\tif (is_writable) {\n\t\t\tif (!(curr.flags & DUK_PROPDESC_FLAG_WRITABLE)) {\n\t\t\t\tgoto need_check;\n\t\t\t}\n\t\t} else {\n\t\t\tif (curr.flags & DUK_PROPDESC_FLAG_WRITABLE) {\n\t\t\t\tgoto need_check;\n\t\t\t}\n\t\t}\n\t}\n\tif (has_set) {\n\t\tif (curr.flags & DUK_PROPDESC_FLAG_ACCESSOR) {\n\t\t\tif (set != curr.set) {\n\t\t\t\tgoto need_check;\n\t\t\t}\n\t\t} else {\n\t\t\tgoto need_check;\n\t\t}\n\t}\n\tif (has_get) {\n\t\tif (curr.flags & DUK_PROPDESC_FLAG_ACCESSOR) {\n\t\t\tif (get != curr.get) {\n\t\t\t\tgoto need_check;\n\t\t\t}\n\t\t} else {\n\t\t\tgoto need_check;\n\t\t}\n\t}\n\n\t/* property exists, either 'desc' is empty, or all values\n\t * match (SameValue)\n\t */\n\tgoto success_no_exotics;\n\n need_check:\n\n\t/*\n\t *  Some change(s) need to be made.  Steps 7-11.\n\t */\n\n\t/* shared checks for all descriptor types */\n\tif (!(curr.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) && !force_flag) {\n\t\tif (has_configurable && is_configurable) {\n\t\t\tgoto fail_not_configurable;\n\t\t}\n\t\tif (has_enumerable) {\n\t\t\tif (curr.flags & DUK_PROPDESC_FLAG_ENUMERABLE) {\n\t\t\t\tif (!is_enumerable) {\n\t\t\t\t\tgoto fail_not_configurable;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (is_enumerable) {\n\t\t\t\t\tgoto fail_not_configurable;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Virtual properties don't have backing so they can't mostly be\n\t * edited.  Some virtual properties are, however, writable: for\n\t * example, virtual index properties of buffer objects and Array\n\t * instance .length.  These are not configurable so the checks\n\t * above mostly cover attempts to change them, except when the\n\t * duk_def_prop() call is used with DUK_DEFPROP_FORCE; even in\n\t * that case we can't forcibly change the property attributes\n\t * because they don't have concrete backing.\n\t */\n\n\t/* XXX: for ROM objects too it'd be best if value modify was\n\t * allowed if the value matches SameValue.\n\t */\n\t/* Reject attempt to change a read-only object. */\n#if defined(DUK_USE_ROM_OBJECTS)\n\tif (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj)) {\n\t\tDUK_DD(DUK_DDPRINT(\"attempt to define property on read-only target object\"));\n\t\tgoto fail_not_configurable;\n\t}\n#endif\n\n\t/* descriptor type specific checks */\n\tif (has_set || has_get) {\n\t\t/* IsAccessorDescriptor(desc) == true */\n\t\tDUK_ASSERT(!has_writable);\n\t\tDUK_ASSERT(!has_value);\n\n\t\tif (curr.flags & DUK_PROPDESC_FLAG_ACCESSOR) {\n\t\t\t/* curr and desc are accessors */\n\t\t\tif (!(curr.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) && !force_flag) {\n\t\t\t\tif (has_set && set != curr.set) {\n\t\t\t\t\tgoto fail_not_configurable;\n\t\t\t\t}\n\t\t\t\tif (has_get && get != curr.get) {\n\t\t\t\t\tgoto fail_not_configurable;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tduk_bool_t rc;\n\t\t\tduk_tval *tv1;\n\n\t\t\t/* curr is data, desc is accessor */\n\t\t\tif (!(curr.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) && !force_flag) {\n\t\t\t\tgoto fail_not_configurable;\n\t\t\t}\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"convert property to accessor property\"));\n\t\t\tif (curr.a_idx >= 0) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"property to convert is stored in an array entry, abandon array and re-lookup\"));\n\t\t\t\tduk__abandon_array_checked(thr, obj);\n\t\t\t\tduk_pop(ctx);  /* remove old value */\n\t\t\t\trc = duk__get_own_propdesc_raw(thr, obj, key, arr_idx, &curr, DUK_GETDESC_FLAG_PUSH_VALUE);\n\t\t\t\tDUK_UNREF(rc);\n\t\t\t\tDUK_ASSERT(rc != 0);\n\t\t\t\tDUK_ASSERT(curr.e_idx >= 0 && curr.a_idx < 0);\n\t\t\t}\n\t\t\tif (curr.e_idx < 0) {\n\t\t\t\tDUK_ASSERT(curr.a_idx < 0 && curr.e_idx < 0);\n\t\t\t\tgoto fail_virtual;  /* safeguard for virtual property */\n\t\t\t}\n\n\t\t\tDUK_ASSERT(curr.e_idx >= 0);\n\t\t\tDUK_ASSERT(!DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, obj, curr.e_idx));\n\n\t\t\ttv1 = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, curr.e_idx);\n\t\t\tDUK_TVAL_SET_UNDEFINED_UPDREF_NORZ(thr, tv1);  /* XXX: just decref */\n\n\t\t\tDUK_HOBJECT_E_SET_VALUE_GETTER(thr->heap, obj, curr.e_idx, NULL);\n\t\t\tDUK_HOBJECT_E_SET_VALUE_SETTER(thr->heap, obj, curr.e_idx, NULL);\n\t\t\tDUK_HOBJECT_E_SLOT_CLEAR_WRITABLE(thr->heap, obj, curr.e_idx);\n\t\t\tDUK_HOBJECT_E_SLOT_SET_ACCESSOR(thr->heap, obj, curr.e_idx);\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"flags after data->accessor conversion: 0x%02lx\",\n\t\t\t                     (unsigned long) DUK_HOBJECT_E_GET_FLAGS(thr->heap, obj, curr.e_idx)));\n\t\t\t/* Update curr.flags; faster than a re-lookup. */\n\t\t\tcurr.flags &= ~DUK_PROPDESC_FLAG_WRITABLE;\n\t\t\tcurr.flags |= DUK_PROPDESC_FLAG_ACCESSOR;\n\t\t}\n\t} else if (has_value || has_writable) {\n\t\t/* IsDataDescriptor(desc) == true */\n\t\tDUK_ASSERT(!has_set);\n\t\tDUK_ASSERT(!has_get);\n\n\t\tif (curr.flags & DUK_PROPDESC_FLAG_ACCESSOR) {\n\t\t\tduk_hobject *tmp;\n\n\t\t\t/* curr is accessor, desc is data */\n\t\t\tif (!(curr.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) && !force_flag) {\n\t\t\t\tgoto fail_not_configurable;\n\t\t\t}\n\n\t\t\t/* curr is accessor -> cannot be in array part. */\n\t\t\tDUK_ASSERT(curr.a_idx < 0);\n\t\t\tif (curr.e_idx < 0) {\n\t\t\t\tgoto fail_virtual;  /* safeguard; no virtual accessors now */\n\t\t\t}\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"convert property to data property\"));\n\n\t\t\tDUK_ASSERT(DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, obj, curr.e_idx));\n\t\t\ttmp = DUK_HOBJECT_E_GET_VALUE_GETTER(thr->heap, obj, curr.e_idx);\n\t\t\tDUK_UNREF(tmp);\n\t\t\tDUK_HOBJECT_E_SET_VALUE_GETTER(thr->heap, obj, curr.e_idx, NULL);\n\t\t\tDUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr, tmp);\n\t\t\ttmp = DUK_HOBJECT_E_GET_VALUE_SETTER(thr->heap, obj, curr.e_idx);\n\t\t\tDUK_UNREF(tmp);\n\t\t\tDUK_HOBJECT_E_SET_VALUE_SETTER(thr->heap, obj, curr.e_idx, NULL);\n\t\t\tDUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr, tmp);\n\n\t\t\tDUK_TVAL_SET_UNDEFINED(DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, curr.e_idx));\n\t\t\tDUK_HOBJECT_E_SLOT_CLEAR_WRITABLE(thr->heap, obj, curr.e_idx);\n\t\t\tDUK_HOBJECT_E_SLOT_CLEAR_ACCESSOR(thr->heap, obj, curr.e_idx);\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"flags after accessor->data conversion: 0x%02lx\",\n\t\t\t                     (unsigned long) DUK_HOBJECT_E_GET_FLAGS(thr->heap, obj, curr.e_idx)));\n\n\t\t\t/* Update curr.flags; faster than a re-lookup. */\n\t\t\tcurr.flags &= ~(DUK_PROPDESC_FLAG_WRITABLE | DUK_PROPDESC_FLAG_ACCESSOR);\n\t\t} else {\n\t\t\t/* curr and desc are data */\n\t\t\tif (!(curr.flags & DUK_PROPDESC_FLAG_CONFIGURABLE) && !force_flag) {\n\t\t\t\tif (!(curr.flags & DUK_PROPDESC_FLAG_WRITABLE) && has_writable && is_writable) {\n\t\t\t\t\tgoto fail_not_configurable;\n\t\t\t\t}\n\t\t\t\t/* Note: changing from writable to non-writable is OK */\n\t\t\t\tif (!(curr.flags & DUK_PROPDESC_FLAG_WRITABLE) && has_value) {\n\t\t\t\t\tduk_tval *tmp1 = duk_require_tval(ctx, -1);         /* curr value */\n\t\t\t\t\tduk_tval *tmp2 = duk_require_tval(ctx, idx_value);  /* new value */\n\t\t\t\t\tif (!duk_js_samevalue(tmp1, tmp2)) {\n\t\t\t\t\t\tgoto fail_not_configurable;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\t/* IsGenericDescriptor(desc) == true; this means in practice that 'desc'\n\t\t * only has [[Enumerable]] or [[Configurable]] flag updates, which are\n\t\t * allowed at this point.\n\t\t */\n\n\t\tDUK_ASSERT(!has_value && !has_writable && !has_get && !has_set);\n\t}\n\n\t/*\n\t *  Start doing property attributes updates.  Steps 12-13.\n\t *\n\t *  Start by computing new attribute flags without writing yet.\n\t *  Property type conversion is done above if necessary.\n\t */\n\n\tnew_flags = curr.flags;\n\n\tif (has_enumerable) {\n\t\tif (is_enumerable) {\n\t\t\tnew_flags |= DUK_PROPDESC_FLAG_ENUMERABLE;\n\t\t} else {\n\t\t\tnew_flags &= ~DUK_PROPDESC_FLAG_ENUMERABLE;\n\t\t}\n\t}\n\tif (has_configurable) {\n\t\tif (is_configurable) {\n\t\t\tnew_flags |= DUK_PROPDESC_FLAG_CONFIGURABLE;\n\t\t} else {\n\t\t\tnew_flags &= ~DUK_PROPDESC_FLAG_CONFIGURABLE;\n\t\t}\n\t}\n\tif (has_writable) {\n\t\tif (is_writable) {\n\t\t\tnew_flags |= DUK_PROPDESC_FLAG_WRITABLE;\n\t\t} else {\n\t\t\tnew_flags &= ~DUK_PROPDESC_FLAG_WRITABLE;\n\t\t}\n\t}\n\n\t/* XXX: write protect after flag? -> any chance of handling it here? */\n\n\tDUK_DDD(DUK_DDDPRINT(\"new flags that we want to write: 0x%02lx\",\n\t                     (unsigned long) new_flags));\n\n\t/*\n\t *  Check whether we need to abandon an array part (if it exists)\n\t */\n\n\tif (curr.a_idx >= 0) {\n\t\tduk_bool_t rc;\n\n\t\tDUK_ASSERT(curr.e_idx < 0);\n\n\t\tif (new_flags == DUK_PROPDESC_FLAGS_WEC) {\n\t\t\tduk_tval *tv1, *tv2;\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"array index, new property attributes match array defaults, update in-place\"));\n\n\t\t\tDUK_ASSERT(curr.flags == DUK_PROPDESC_FLAGS_WEC);  /* must have been, since in array part */\n\t\t\tDUK_ASSERT(!has_set);\n\t\t\tDUK_ASSERT(!has_get);\n\t\t\tDUK_ASSERT(idx_value >= 0);  /* must be: if attributes match and we get here the value must differ (otherwise no change) */\n\n\t\t\ttv2 = duk_require_tval(ctx, idx_value);\n\t\t\ttv1 = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, obj, curr.a_idx);\n\t\t\tDUK_TVAL_SET_TVAL_UPDREF(thr, tv1, tv2);  /* side effects; may invalidate a_idx */\n\t\t\tgoto success_exotics;\n\t\t}\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"array index, new property attributes do not match array defaults, abandon array and re-lookup\"));\n\t\tduk__abandon_array_checked(thr, obj);\n\t\tduk_pop(ctx);  /* remove old value */\n\t\trc = duk__get_own_propdesc_raw(thr, obj, key, arr_idx, &curr, DUK_GETDESC_FLAG_PUSH_VALUE);\n\t\tDUK_UNREF(rc);\n\t\tDUK_ASSERT(rc != 0);\n\t\tDUK_ASSERT(curr.e_idx >= 0 && curr.a_idx < 0);\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"updating existing property in entry part\"));\n\n\t/* Array case is handled comprehensively above: either in entry\n\t * part or a virtual property.\n\t */\n\tDUK_ASSERT(curr.a_idx < 0);\n\n\tDUK_DDD(DUK_DDDPRINT(\"update existing property attributes\"));\n\tif (curr.e_idx >= 0) {\n\t\tDUK_HOBJECT_E_SET_FLAGS(thr->heap, obj, curr.e_idx, new_flags);\n\t} else {\n\t\t/* For Array .length the only allowed transition is for .length\n\t\t * to become non-writable.\n\t\t */\n\t\tif (key == DUK_HTHREAD_STRING_LENGTH(thr) && DUK_HOBJECT_HAS_EXOTIC_ARRAY(obj)) {\n\t\t\tduk_harray *a;\n\t\t\ta = (duk_harray *) obj;\n\t\t\tDUK_DD(DUK_DDPRINT(\"Object.defineProperty() attribute update for duk_harray .length -> %02lx\", (unsigned long) new_flags));\n\t\t\tDUK_ASSERT_HARRAY_VALID(a);\n\t\t\tif ((new_flags & DUK_PROPDESC_FLAGS_EC) != (curr.flags & DUK_PROPDESC_FLAGS_EC)) {\n\t\t\t\tDUK_D(DUK_DPRINT(\"Object.defineProperty() attempt to change virtual array .length enumerable or configurable attribute, fail\"));\n\t\t\t\tgoto fail_virtual;\n\t\t\t}\n\t\t\tif (new_flags & DUK_PROPDESC_FLAG_WRITABLE) {\n\t\t\t\tDUK_HARRAY_SET_LENGTH_WRITABLE(a);\n\t\t\t} else {\n\t\t\t\tDUK_HARRAY_SET_LENGTH_NONWRITABLE(a);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (has_set) {\n\t\tduk_hobject *tmp;\n\n\t\t/* Virtual properties are non-configurable but with a 'force'\n\t\t * flag we might come here so check explicitly for virtual.\n\t\t */\n\t\tif (curr.e_idx < 0) {\n\t\t\tgoto fail_virtual;\n\t\t}\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"update existing property setter\"));\n\t\tDUK_ASSERT(DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, obj, curr.e_idx));\n\n\t\ttmp = DUK_HOBJECT_E_GET_VALUE_SETTER(thr->heap, obj, curr.e_idx);\n\t\tDUK_UNREF(tmp);\n\t\tDUK_HOBJECT_E_SET_VALUE_SETTER(thr->heap, obj, curr.e_idx, set);\n\t\tDUK_HOBJECT_INCREF_ALLOWNULL(thr, set);\n\t\tDUK_HOBJECT_DECREF_ALLOWNULL(thr, tmp);  /* side effects; may invalidate e_idx */\n\t}\n\tif (has_get) {\n\t\tduk_hobject *tmp;\n\n\t\tif (curr.e_idx < 0) {\n\t\t\tgoto fail_virtual;\n\t\t}\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"update existing property getter\"));\n\t\tDUK_ASSERT(DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, obj, curr.e_idx));\n\n\t\ttmp = DUK_HOBJECT_E_GET_VALUE_GETTER(thr->heap, obj, curr.e_idx);\n\t\tDUK_UNREF(tmp);\n\t\tDUK_HOBJECT_E_SET_VALUE_GETTER(thr->heap, obj, curr.e_idx, get);\n\t\tDUK_HOBJECT_INCREF_ALLOWNULL(thr, get);\n\t\tDUK_HOBJECT_DECREF_ALLOWNULL(thr, tmp);  /* side effects; may invalidate e_idx */\n\t}\n\tif (has_value) {\n\t\tduk_tval *tv1, *tv2;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"update existing property value\"));\n\n\t\tif (curr.e_idx >= 0) {\n\t\t\tDUK_ASSERT(!DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, obj, curr.e_idx));\n\t\t\ttv2 = duk_require_tval(ctx, idx_value);\n\t\t\ttv1 = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, obj, curr.e_idx);\n\t\t\tDUK_TVAL_SET_TVAL_UPDREF(thr, tv1, tv2);  /* side effects; may invalidate e_idx */\n\t\t} else {\n\t\t\tDUK_ASSERT(curr.a_idx < 0);  /* array part case handled comprehensively previously */\n\n\t\t\tDUK_DD(DUK_DDPRINT(\"Object.defineProperty(), value update for virtual property\"));\n\t\t\t/* XXX: Uint8Array and other typed array virtual writes not currently\n\t\t\t * handled.\n\t\t\t */\n\t\t\tif (key == DUK_HTHREAD_STRING_LENGTH(thr) && DUK_HOBJECT_HAS_EXOTIC_ARRAY(obj)) {\n\t\t\t\tduk_harray *a;\n\t\t\t\ta = (duk_harray *) obj;\n\t\t\t\tDUK_DD(DUK_DDPRINT(\"Object.defineProperty() value update for duk_harray .length -> %ld\", (long) arrlen_new_len));\n\t\t\t\tDUK_ASSERT_HARRAY_VALID(a);\n\t\t\t\ta->length = arrlen_new_len;\n\t\t\t} else {\n\t\t\t\tgoto fail_virtual;  /* should not happen */\n\t\t\t}\n\t\t}\n\t}\n\n\t/*\n\t *  Standard algorithm succeeded without errors, check for exotic post-behaviors.\n\t *\n\t *  Arguments exotic behavior in E5 Section 10.6 occurs after the standard\n\t *  [[DefineOwnProperty]] has completed successfully.\n\t *\n\t *  Array exotic behavior in E5 Section 15.4.5.1 is implemented partly\n\t *  prior to the default [[DefineOwnProperty]], but:\n\t *    - for an array index key (e.g. \"10\") the final 'length' update occurs here\n\t *    - for 'length' key the element deletion and 'length' update occurs here\n\t */\n\n success_exotics:\n\n\t/* curr.a_idx or curr.e_idx may have been invalidated by side effects\n\t * above.\n\t */\n\n\t/* [obj key desc value get set curr_value] */\n\n\tif (DUK_HOBJECT_HAS_EXOTIC_ARRAY(obj)) {\n\t\tduk_harray *a;\n\n\t\ta = (duk_harray *) obj;\n\t\tDUK_ASSERT_HARRAY_VALID(a);\n\n\t\tif (arridx_new_array_length > 0) {\n\t\t\t/*\n\t\t\t *  Note: zero works as a \"no update\" marker because the new length\n\t\t\t *  can never be zero after a new property is written.\n\t\t\t */\n\n\t\t\t/* E5 Section 15.4.5.1, steps 4.e.i - 4.e.ii */\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"defineProperty successful, pending array length update to: %ld\",\n\t\t\t                     (long) arridx_new_array_length));\n\n\t\t\ta->length = arridx_new_array_length;\n\t\t}\n\n\t\tif (key == DUK_HTHREAD_STRING_LENGTH(thr) && arrlen_new_len < arrlen_old_len) {\n\t\t\t/*\n\t\t\t *  E5 Section 15.4.5.1, steps 3.k - 3.n.  The order at the end combines\n\t\t\t *  the error case 3.l.iii and the success case 3.m-3.n.\n\t\t\t */\n\n\t\t\t/* XXX: investigate whether write protect can be handled above, if we\n\t\t\t * just update length here while ignoring its protected status\n\t\t\t */\n\n\t\t\tduk_uint32_t result_len;\n\t\t\tduk_bool_t rc;\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"defineProperty successful, key is 'length', exotic array behavior, \"\n\t\t\t                     \"doing array element deletion and length update\"));\n\n\t\t\trc = duk__handle_put_array_length_smaller(thr, obj, arrlen_old_len, arrlen_new_len, force_flag, &result_len);\n\n\t\t\t/* update length (curr points to length, and we assume it's still valid) */\n\t\t\tDUK_ASSERT(result_len >= arrlen_new_len && result_len <= arrlen_old_len);\n\n\t\t\ta->length = result_len;\n\n\t\t\tif (pending_write_protect) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"setting array length non-writable (pending writability update)\"));\n\t\t\t\tDUK_HARRAY_SET_LENGTH_NONWRITABLE(a);\n\t\t\t}\n\n\t\t\t/* XXX: shrink array allocation or entries compaction here? */\n\t\t\tif (!rc) {\n\t\t\t\tDUK_DD(DUK_DDPRINT(\"array length write only partially successful\"));\n\t\t\t\tgoto fail_not_configurable;\n\t\t\t}\n\t\t}\n\t} else if (arr_idx != DUK__NO_ARRAY_INDEX && DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS(obj)) {\n\t\tduk_hobject *map;\n\t\tduk_hobject *varenv;\n\n\t\tDUK_ASSERT(arridx_new_array_length == 0);\n\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_EXOTIC_ARRAY(obj));  /* traits are separate; in particular, arguments not an array */\n\n\t\tmap = NULL;\n\t\tvarenv = NULL;\n\t\tif (!duk__lookup_arguments_map(thr, obj, key, &curr, &map, &varenv)) {\n\t\t\tgoto success_no_exotics;\n\t\t}\n\t\tDUK_ASSERT(map != NULL);\n\t\tDUK_ASSERT(varenv != NULL);\n\n\t\t/* [obj key desc value get set curr_value varname] */\n\n\t\tif (has_set || has_get) {\n\t\t\t/* = IsAccessorDescriptor(Desc) */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"defineProperty successful, key mapped to arguments 'map' \"\n\t\t\t                     \"changed to an accessor, delete arguments binding\"));\n\n\t\t\t(void) duk_hobject_delprop_raw(thr, map, key, 0);  /* ignore result */\n\t\t} else {\n\t\t\t/* Note: this order matters (final value before deleting map entry must be done) */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"defineProperty successful, key mapped to arguments 'map', \"\n\t\t\t                     \"check for value update / binding deletion\"));\n\n\t\t\tif (has_value) {\n\t\t\t\tduk_hstring *varname;\n\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"defineProperty successful, key mapped to arguments 'map', \"\n\t\t\t\t                     \"update bound value (variable/argument)\"));\n\n\t\t\t\tvarname = duk_require_hstring(ctx, -1);\n\t\t\t\tDUK_ASSERT(varname != NULL);\n\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"arguments object automatic putvar for a bound variable; \"\n\t\t\t\t                     \"key=%!O, varname=%!O, value=%!T\",\n\t\t\t\t                     (duk_heaphdr *) key,\n\t\t\t\t                     (duk_heaphdr *) varname,\n\t\t\t\t                     (duk_tval *) duk_require_tval(ctx, idx_value)));\n\n\t\t\t\t/* strict flag for putvar comes from our caller (currently: fixed) */\n\t\t\t\tduk_js_putvar_envrec(thr, varenv, varname, duk_require_tval(ctx, idx_value), 1 /*throw_flag*/);\n\t\t\t}\n\t\t\tif (has_writable && !is_writable) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"defineProperty successful, key mapped to arguments 'map', \"\n\t\t\t\t                     \"changed to non-writable, delete arguments binding\"));\n\n\t\t\t\t(void) duk_hobject_delprop_raw(thr, map, key, 0);  /* ignore result */\n\t\t\t}\n\t\t}\n\n\t\t/* 'varname' is in stack in this else branch, leaving an unbalanced stack below,\n\t\t * but this doesn't matter now.\n\t\t */\n\t}\n\n success_no_exotics:\n\t/* Some code paths use NORZ macros for simplicity, ensure refzero\n\t * handling is completed.\n\t */\n\tDUK_REFZERO_CHECK_SLOW(thr);\n\treturn 1;\n\n fail_not_extensible:\n\tif (throw_flag) {\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_NOT_EXTENSIBLE);\n\t}\n\treturn 0;\n\n fail_virtual:  /* just use the same \"not configurable\" error message\" */\n fail_not_configurable:\n\tif (throw_flag) {\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE);\n\t}\n\treturn 0;\n}\n\n/*\n *  Object.prototype.hasOwnProperty() and Object.prototype.propertyIsEnumerable().\n */\n\nDUK_INTERNAL duk_bool_t duk_hobject_object_ownprop_helper(duk_context *ctx, duk_small_uint_t required_desc_flags) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hstring *h_v;\n\tduk_hobject *h_obj;\n\tduk_propdesc desc;\n\tduk_bool_t ret;\n\n\t/* coercion order matters */\n\th_v = duk_to_hstring_acceptsymbol(ctx, 0);\n\tDUK_ASSERT(h_v != NULL);\n\n\th_obj = duk_push_this_coercible_to_object(ctx);\n\tDUK_ASSERT(h_obj != NULL);\n\n\tret = duk_hobject_get_own_propdesc(thr, h_obj, h_v, &desc, 0 /*flags*/);  /* don't push value */\n\n\tduk_push_boolean(ctx, ret && ((desc.flags & required_desc_flags) == required_desc_flags));\n\treturn 1;\n}\n\n/*\n *  Object.seal() and Object.freeze()  (E5 Sections 15.2.3.8 and 15.2.3.9)\n *\n *  Since the algorithms are similar, a helper provides both functions.\n *  Freezing is essentially sealing + making plain properties non-writable.\n *\n *  Note: virtual (non-concrete) properties which are non-configurable but\n *  writable would pose some problems, but such properties do not currently\n *  exist (all virtual properties are non-configurable and non-writable).\n *  If they did exist, the non-configurability does NOT prevent them from\n *  becoming non-writable.  However, this change should be recorded somehow\n *  so that it would turn up (e.g. when getting the property descriptor),\n *  requiring some additional flags in the object.\n */\n\nDUK_INTERNAL void duk_hobject_object_seal_freeze_helper(duk_hthread *thr, duk_hobject *obj, duk_bool_t is_freeze) {\n\tduk_uint_fast32_t i;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\tDUK_ASSERT(obj != NULL);\n\n\tDUK_ASSERT_VALSTACK_SPACE(thr, DUK__VALSTACK_SPACE);\n\n#if defined(DUK_USE_ROM_OBJECTS)\n\tif (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) obj)) {\n\t\tDUK_DD(DUK_DDPRINT(\"attempt to seal/freeze a readonly object, reject\"));\n\t\tDUK_ERROR_TYPE(thr, DUK_STR_NOT_CONFIGURABLE);\n\t}\n#endif\n\n\t/*\n\t *  Abandon array part because all properties must become non-configurable.\n\t *  Note that this is now done regardless of whether this is always the case\n\t *  (skips check, but performance problem if caller would do this many times\n\t *  for the same object; not likely).\n\t */\n\n\tduk__abandon_array_checked(thr, obj);\n\tDUK_ASSERT(DUK_HOBJECT_GET_ASIZE(obj) == 0);\n\n\tfor (i = 0; i < DUK_HOBJECT_GET_ENEXT(obj); i++) {\n\t\tduk_uint8_t *fp;\n\n\t\t/* since duk__abandon_array_checked() causes a resize, there should be no gaps in keys */\n\t\tDUK_ASSERT(DUK_HOBJECT_E_GET_KEY(thr->heap, obj, i) != NULL);\n\n\t\t/* avoid multiple computations of flags address; bypasses macros */\n\t\tfp = DUK_HOBJECT_E_GET_FLAGS_PTR(thr->heap, obj, i);\n\t\tif (is_freeze && !((*fp) & DUK_PROPDESC_FLAG_ACCESSOR)) {\n\t\t\t*fp &= ~(DUK_PROPDESC_FLAG_WRITABLE | DUK_PROPDESC_FLAG_CONFIGURABLE);\n\t\t} else {\n\t\t\t*fp &= ~DUK_PROPDESC_FLAG_CONFIGURABLE;\n\t\t}\n\t}\n\n\tDUK_HOBJECT_CLEAR_EXTENSIBLE(obj);\n\n\t/* no need to compact since we already did that in duk__abandon_array_checked()\n\t * (regardless of whether an array part existed or not.\n\t */\n\n\treturn;\n}\n\n/*\n *  Object.isSealed() and Object.isFrozen()  (E5 Sections 15.2.3.11, 15.2.3.13)\n *\n *  Since the algorithms are similar, a helper provides both functions.\n *  Freezing is essentially sealing + making plain properties non-writable.\n *\n *  Note: all virtual (non-concrete) properties are currently non-configurable\n *  and non-writable (and there are no accessor virtual properties), so they don't\n *  need to be considered here now.\n */\n\nDUK_INTERNAL duk_bool_t duk_hobject_object_is_sealed_frozen_helper(duk_hthread *thr, duk_hobject *obj, duk_bool_t is_frozen) {\n\tduk_uint_fast32_t i;\n\n\tDUK_ASSERT(obj != NULL);\n\tDUK_UNREF(thr);\n\n\t/* Note: no allocation pressure, no need to check refcounts etc */\n\n\t/* must not be extensible */\n\tif (DUK_HOBJECT_HAS_EXTENSIBLE(obj)) {\n\t\treturn 0;\n\t}\n\n\t/* all virtual properties are non-configurable and non-writable */\n\n\t/* entry part must not contain any configurable properties, or\n\t * writable properties (if is_frozen).\n\t */\n\tfor (i = 0; i < DUK_HOBJECT_GET_ENEXT(obj); i++) {\n\t\tduk_small_uint_t flags;\n\n\t\tif (!DUK_HOBJECT_E_GET_KEY(thr->heap, obj, i)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t/* avoid multiple computations of flags address; bypasses macros */\n\t\tflags = (duk_small_uint_t) DUK_HOBJECT_E_GET_FLAGS(thr->heap, obj, i);\n\n\t\tif (flags & DUK_PROPDESC_FLAG_CONFIGURABLE) {\n\t\t\treturn 0;\n\t\t}\n\t\tif (is_frozen &&\n\t\t    !(flags & DUK_PROPDESC_FLAG_ACCESSOR) &&\n\t\t    (flags & DUK_PROPDESC_FLAG_WRITABLE)) {\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\t/* array part must not contain any non-unused properties, as they would\n\t * be configurable and writable.\n\t */\n\tfor (i = 0; i < DUK_HOBJECT_GET_ASIZE(obj); i++) {\n\t\tduk_tval *tv = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, obj, i);\n\t\tif (!DUK_TVAL_IS_UNUSED(tv)) {\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\treturn 1;\n}\n\n/*\n *  Object.preventExtensions() and Object.isExtensible()  (E5 Sections 15.2.3.10, 15.2.3.13)\n *\n *  Not needed, implemented by macros DUK_HOBJECT_{HAS,CLEAR,SET}_EXTENSIBLE\n *  and the Object built-in bindings.\n */\n\n/* automatic undefs */\n#undef DUK__HASH_DELETED\n#undef DUK__HASH_UNUSED\n#undef DUK__NO_ARRAY_INDEX\n#undef DUK__VALSTACK_PROXY_LOOKUP\n#undef DUK__VALSTACK_SPACE\n/*\n *  Misc support functions\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  duk_hstring charCodeAt, with and without surrogate awareness\n */\n\nDUK_INTERNAL duk_ucodepoint_t duk_hstring_char_code_at_raw(duk_hthread *thr, duk_hstring *h, duk_uint_t pos, duk_bool_t surrogate_aware) {\n\tduk_uint32_t boff;\n\tconst duk_uint8_t *p, *p_start, *p_end;\n\tduk_ucodepoint_t cp1;\n\tduk_ucodepoint_t cp2;\n\n\t/* Caller must check character offset to be inside the string. */\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(h != NULL);\n\tDUK_ASSERT_DISABLE(pos >= 0);  /* unsigned */\n\tDUK_ASSERT(pos < (duk_uint_t) DUK_HSTRING_GET_CHARLEN(h));\n\n\tboff = duk_heap_strcache_offset_char2byte(thr, h, (duk_uint32_t) pos);\n\tDUK_DDD(DUK_DDDPRINT(\"charCodeAt: pos=%ld -> boff=%ld, str=%!O\",\n\t                     (long) pos, (long) boff, (duk_heaphdr *) h));\n\tDUK_ASSERT_DISABLE(boff >= 0);\n\tDUK_ASSERT(boff < DUK_HSTRING_GET_BYTELEN(h));\n\n\tp_start = DUK_HSTRING_GET_DATA(h);\n\tp_end = p_start + DUK_HSTRING_GET_BYTELEN(h);\n\tp = p_start + boff;\n\tDUK_DDD(DUK_DDDPRINT(\"p_start=%p, p_end=%p, p=%p\",\n\t                     (const void *) p_start, (const void *) p_end,\n\t                     (const void *) p));\n\n\t/* For invalid UTF-8 (never happens for standard Ecmascript strings)\n\t * return U+FFFD replacement character.\n\t */\n\tif (duk_unicode_decode_xutf8(thr, &p, p_start, p_end, &cp1)) {\n\t\tif (surrogate_aware && cp1 >= 0xd800UL && cp1 <= 0xdbffUL) {\n\t\t\t/* The decode helper is memory safe even if 'cp1' was\n\t\t\t * decoded at the end of the string and 'p' is no longer\n\t\t\t * within string memory range.\n\t\t\t */\n\t\t\tcp2 = 0;  /* If call fails, this is left untouched and won't match cp2 check. */\n\t\t\t(void) duk_unicode_decode_xutf8(thr, &p, p_start, p_end, &cp2);\n\t\t\tif (cp2 >= 0xdc00UL && cp2 <= 0xdfffUL) {\n\t\t\t\tcp1 = ((cp1 - 0xd800UL) << 10) + (cp2 - 0xdc00UL) + 0x10000UL;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tcp1 = DUK_UNICODE_CP_REPLACEMENT_CHARACTER;\n\t}\n\n\treturn cp1;\n}\n\n/*\n *  duk_hstring charlen access\n */\n\n#if defined(DUK_USE_HSTRING_CLEN)\nDUK_LOCAL DUK_COLD duk_size_t duk__hstring_get_charlen_slowpath(duk_hstring *h) {\n\tduk_size_t res;\n\n\tDUK_ASSERT(h->clen == 0);  /* Checked by caller. */\n\n#if defined(DUK_USE_ROM_STRINGS)\n\t/* ROM strings have precomputed clen, but if the computed clen is zero\n\t * we can still come here and can't write anything.\n\t */\n\tif (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) h)) {\n\t\treturn 0;\n\t}\n#endif\n\n\tres = duk_unicode_unvalidated_utf8_length(DUK_HSTRING_GET_DATA(h), DUK_HSTRING_GET_BYTELEN(h));\n#if defined(DUK_USE_STRLEN16)\n\tDUK_ASSERT(res <= 0xffffUL);  /* Bytelength checked during interning. */\n\th->clen16 = (duk_uint16_t) res;\n#else\n\th->clen = (duk_uint32_t) res;\n#endif\n\tif (DUK_LIKELY(res == DUK_HSTRING_GET_BYTELEN(h))) {\n\t\tDUK_HSTRING_SET_ASCII(h);\n\t}\n\treturn res;\n}\n#else  /* DUK_USE_HSTRING_CLEN */\nDUK_LOCAL duk_size_t duk__hstring_get_charlen_slowpath(duk_hstring *h) {\n\tif (DUK_LIKELY(DUK_HSTRING_HAS_ASCII(h))) {\n\t\t/* Most practical strings will go here. */\n\t\treturn DUK_HSTRING_GET_BYTELEN(h);\n\t} else {\n\t\t/* ASCII flag is lazy, so set it here. */\n\t\tduk_size_t res;\n\n\t\t/* XXX: here we could use the strcache to speed up the\n\t\t * computation (matters for 'i < str.length' loops).\n\t\t */\n\n\t\tres = duk_unicode_unvalidated_utf8_length(DUK_HSTRING_GET_DATA(h), DUK_HSTRING_GET_BYTELEN(h));\n\n#if defined(DUK_USE_ROM_STRINGS)\n\t\tif (DUK_HEAPHDR_HAS_READONLY((duk_heaphdr *) h)) {\n\t\t\t/* For ROM strings, can't write anything; ASCII flag\n\t\t\t * is preset so we don't need to update it.\n\t\t\t */\n\t\t\treturn res;\n\t\t}\n#endif\n\t\tif (DUK_LIKELY(res == DUK_HSTRING_GET_BYTELEN(h))) {\n\t\t\tDUK_HSTRING_SET_ASCII(h);\n\t\t}\n\t\treturn res;\n\t}\n}\n#endif  /* DUK_USE_HSTRING_CLEN */\n\n#if defined(DUK_USE_HSTRING_CLEN)\nDUK_INTERNAL DUK_HOT duk_size_t duk_hstring_get_charlen(duk_hstring *h) {\n#if defined(DUK_USE_STRLEN16)\n\tif (DUK_LIKELY(h->clen16 != 0)) {\n\t\treturn h->clen16;\n\t}\n#else\n\tif (DUK_LIKELY(h->clen != 0)) {\n\t\treturn h->clen;\n\t}\n#endif\n\treturn duk__hstring_get_charlen_slowpath(h);\n}\n#else  /* DUK_USE_HSTRING_CLEN */\nDUK_INTERNAL DUK_HOT duk_size_t duk_hstring_get_charlen(duk_hstring *h) {\n\t/* Always use slow path. */\n\treturn duk__hstring_get_charlen_slowpath(h);\n}\n#endif  /* DUK_USE_HSTRING_CLEN */\n/*\n *  duk_hthread allocation and freeing.\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Allocate initial stacks for a thread.  Note that 'thr' must be reachable\n *  as a garbage collection may be triggered by the allocation attempts.\n *  Returns zero (without leaking memory) if init fails.\n */\n\nDUK_INTERNAL duk_bool_t duk_hthread_init_stacks(duk_heap *heap, duk_hthread *thr) {\n\tduk_size_t alloc_size;\n\tduk_size_t i;\n\n\tDUK_ASSERT(heap != NULL);\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->valstack == NULL);\n\tDUK_ASSERT(thr->valstack_end == NULL);\n\tDUK_ASSERT(thr->valstack_bottom == NULL);\n\tDUK_ASSERT(thr->valstack_top == NULL);\n\tDUK_ASSERT(thr->callstack == NULL);\n\tDUK_ASSERT(thr->callstack_curr == NULL);\n\tDUK_ASSERT(thr->catchstack == NULL);\n\n\t/* valstack */\n\talloc_size = sizeof(duk_tval) * DUK_VALSTACK_INITIAL_SIZE;\n\tthr->valstack = (duk_tval *) DUK_ALLOC(heap, alloc_size);\n\tif (!thr->valstack) {\n\t\tgoto fail;\n\t}\n\tDUK_MEMZERO(thr->valstack, alloc_size);\n\tthr->valstack_end = thr->valstack + DUK_VALSTACK_INITIAL_SIZE;\n#if !defined(DUK_USE_PREFER_SIZE)\n\tthr->valstack_size = DUK_VALSTACK_INITIAL_SIZE;\n#endif\n\tthr->valstack_bottom = thr->valstack;\n\tthr->valstack_top = thr->valstack;\n\n\tfor (i = 0; i < DUK_VALSTACK_INITIAL_SIZE; i++) {\n\t\tDUK_TVAL_SET_UNDEFINED(&thr->valstack[i]);\n\t}\n\n\t/* callstack */\n\talloc_size = sizeof(duk_activation) * DUK_CALLSTACK_INITIAL_SIZE;\n\tthr->callstack = (duk_activation *) DUK_ALLOC(heap, alloc_size);\n\tif (!thr->callstack) {\n\t\tgoto fail;\n\t}\n\tDUK_MEMZERO(thr->callstack, alloc_size);\n\tthr->callstack_size = DUK_CALLSTACK_INITIAL_SIZE;\n\tDUK_ASSERT(thr->callstack_top == 0);\n\tDUK_ASSERT(thr->callstack_curr == NULL);\n\n\t/* catchstack */\n\talloc_size = sizeof(duk_catcher) * DUK_CATCHSTACK_INITIAL_SIZE;\n\tthr->catchstack = (duk_catcher *) DUK_ALLOC(heap, alloc_size);\n\tif (!thr->catchstack) {\n\t\tgoto fail;\n\t}\n\tDUK_MEMZERO(thr->catchstack, alloc_size);\n\tthr->catchstack_size = DUK_CATCHSTACK_INITIAL_SIZE;\n\tDUK_ASSERT(thr->catchstack_top == 0);\n\n\treturn 1;\n\n fail:\n\tDUK_FREE(heap, thr->valstack);\n\tDUK_FREE(heap, thr->callstack);\n\tDUK_FREE(heap, thr->catchstack);\n\n\tthr->valstack = NULL;\n\tthr->callstack = NULL;\n\tthr->catchstack = NULL;\n\treturn 0;\n}\n\n/* For indirect allocs. */\n\nDUK_INTERNAL void *duk_hthread_get_valstack_ptr(duk_heap *heap, void *ud) {\n\tduk_hthread *thr = (duk_hthread *) ud;\n\tDUK_UNREF(heap);\n\treturn (void *) thr->valstack;\n}\n\nDUK_INTERNAL void *duk_hthread_get_callstack_ptr(duk_heap *heap, void *ud) {\n\tduk_hthread *thr = (duk_hthread *) ud;\n\tDUK_UNREF(heap);\n\treturn (void *) thr->callstack;\n}\n\nDUK_INTERNAL void *duk_hthread_get_catchstack_ptr(duk_heap *heap, void *ud) {\n\tduk_hthread *thr = (duk_hthread *) ud;\n\tDUK_UNREF(heap);\n\treturn (void *) thr->catchstack;\n}\n/*\n *  Initialize built-in objects.  Current thread must have a valstack\n *  and initialization errors may longjmp, so a setjmp() catch point\n *  must exist.\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Encoding constants, must match genbuiltins.py\n */\n\n#define DUK__PROP_FLAGS_BITS             3\n#define DUK__LENGTH_PROP_BITS            3\n#define DUK__NARGS_BITS                  3\n#define DUK__PROP_TYPE_BITS              3\n\n#define DUK__NARGS_VARARGS_MARKER        0x07\n\n#define DUK__PROP_TYPE_DOUBLE            0\n#define DUK__PROP_TYPE_STRING            1\n#define DUK__PROP_TYPE_STRIDX            2\n#define DUK__PROP_TYPE_BUILTIN           3\n#define DUK__PROP_TYPE_UNDEFINED         4\n#define DUK__PROP_TYPE_BOOLEAN_TRUE      5\n#define DUK__PROP_TYPE_BOOLEAN_FALSE     6\n#define DUK__PROP_TYPE_ACCESSOR          7\n\n/*\n *  Create built-in objects by parsing an init bitstream generated\n *  by genbuiltins.py.\n */\n\n#if defined(DUK_USE_ROM_OBJECTS)\n#if defined(DUK_USE_ROM_GLOBAL_CLONE) || defined(DUK_USE_ROM_GLOBAL_INHERIT)\nDUK_LOCAL void duk__duplicate_ram_global_object(duk_hthread *thr) {\n\tduk_context *ctx;\n\tduk_hobject *h_global;\n#if defined(DUK_USE_ROM_GLOBAL_CLONE)\n\tduk_hobject *h_oldglobal;\n\tduk_uint8_t *props;\n\tduk_size_t alloc_size;\n#endif\n\tduk_hobject *h_objenv;\n\n\tctx = (duk_context *) thr;\n\n\t/* XXX: refactor into internal helper, duk_clone_hobject() */\n\n#if defined(DUK_USE_ROM_GLOBAL_INHERIT)\n\t/* Inherit from ROM-based global object: less RAM usage, less transparent. */\n\th_global = duk_push_object_helper(ctx,\n\t                                  DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                                  DUK_HOBJECT_FLAG_FASTREFS |\n\t                                  DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_GLOBAL),\n\t                                  DUK_BIDX_GLOBAL);\n\tDUK_ASSERT(h_global != NULL);\n#elif defined(DUK_USE_ROM_GLOBAL_CLONE)\n\t/* Clone the properties of the ROM-based global object to create a\n\t * fully RAM-based global object.  Uses more memory than the inherit\n\t * model but more compliant.\n\t */\n\th_global = duk_push_object_helper(ctx,\n\t                                  DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                                  DUK_HOBJECT_FLAG_FASTREFS |\n\t                                  DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_GLOBAL),\n\t                                  DUK_BIDX_OBJECT_PROTOTYPE);\n\tDUK_ASSERT(h_global != NULL);\n\th_oldglobal = thr->builtins[DUK_BIDX_GLOBAL];\n\tDUK_ASSERT(h_oldglobal != NULL);\n\n\t/* Copy the property table verbatim; this handles attributes etc.\n\t * For ROM objects it's not necessary (or possible) to update\n\t * refcounts so leave them as is.\n\t */\n\talloc_size = DUK_HOBJECT_P_ALLOC_SIZE(h_oldglobal);\n\tDUK_ASSERT(alloc_size > 0);\n\tprops = DUK_ALLOC_CHECKED(thr, alloc_size);\n\tDUK_ASSERT(props != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_GET_PROPS(thr->heap, h_oldglobal) != NULL);\n\tDUK_MEMCPY((void *) props, (const void *) DUK_HOBJECT_GET_PROPS(thr->heap, h_oldglobal), alloc_size);\n\n\t/* XXX: keep property attributes or tweak them here?\n\t * Properties will now be non-configurable even when they're\n\t * normally configurable for the global object.\n\t */\n\n\tDUK_ASSERT(DUK_HOBJECT_GET_PROPS(thr->heap, h_global) == NULL);\n\tDUK_HOBJECT_SET_PROPS(thr->heap, h_global, props);\n\tDUK_HOBJECT_SET_ESIZE(h_global, DUK_HOBJECT_GET_ESIZE(h_oldglobal));\n\tDUK_HOBJECT_SET_ENEXT(h_global, DUK_HOBJECT_GET_ENEXT(h_oldglobal));\n\tDUK_HOBJECT_SET_ASIZE(h_global, DUK_HOBJECT_GET_ASIZE(h_oldglobal));\n\tDUK_HOBJECT_SET_HSIZE(h_global, DUK_HOBJECT_GET_HSIZE(h_oldglobal));\n#else\n#error internal error in config defines\n#endif\n\n\tduk_hobject_compact_props(thr, h_global);\n\tDUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL] != NULL);\n\tDUK_ASSERT(!DUK_HEAPHDR_NEEDS_REFCOUNT_UPDATE((duk_heaphdr *) thr->builtins[DUK_BIDX_GLOBAL]));  /* no need to decref: ROM object */\n\tthr->builtins[DUK_BIDX_GLOBAL] = h_global;\n\tDUK_HOBJECT_INCREF(thr, h_global);\n\tDUK_D(DUK_DPRINT(\"duplicated global object: %!O\", h_global));\n\n\t/* Create a fresh object environment for the global scope.  This is\n\t * needed so that the global scope points to the newly created RAM-based\n\t * global object.\n\t */\n\th_objenv = (duk_hobject *) duk_hobjenv_alloc(thr,\n\t                                             DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                                             DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_OBJENV));\n\tDUK_ASSERT(h_objenv != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_GET_PROTOTYPE(thr->heap, h_objenv) == NULL);\n\tduk_push_hobject(ctx, h_objenv);\n\n\tDUK_ASSERT(h_global != NULL);\n\t((duk_hobjenv *) h_objenv)->target = h_global;\n\tDUK_HOBJECT_INCREF(thr, h_global);\n\tDUK_ASSERT(((duk_hobjenv *) h_objenv)->has_this == 0);\n\n\tDUK_ASSERT(thr->builtins[DUK_BIDX_GLOBAL_ENV] != NULL);\n\tDUK_ASSERT(!DUK_HEAPHDR_NEEDS_REFCOUNT_UPDATE((duk_heaphdr *) thr->builtins[DUK_BIDX_GLOBAL_ENV]));  /* no need to decref: ROM object */\n\tthr->builtins[DUK_BIDX_GLOBAL_ENV] = h_objenv;\n\tDUK_HOBJECT_INCREF(thr, h_objenv);\n\tDUK_D(DUK_DPRINT(\"duplicated global env: %!O\", h_objenv));\n\n\tDUK_ASSERT_HOBJENV_VALID((duk_hobjenv *) h_objenv);\n\n\tduk_pop_2(ctx);  /* Pop global object and global env. */\n}\n#endif  /* DUK_USE_ROM_GLOBAL_CLONE || DUK_USE_ROM_GLOBAL_INHERIT */\n\nDUK_INTERNAL void duk_hthread_create_builtin_objects(duk_hthread *thr) {\n\t/* Setup builtins from ROM objects.  All heaps/threads will share\n\t * the same readonly objects.\n\t */\n\tduk_small_uint_t i;\n\n\tfor (i = 0; i < DUK_NUM_BUILTINS; i++) {\n\t\tduk_hobject *h;\n\t\th = (duk_hobject *) DUK_LOSE_CONST(duk_rom_builtins_bidx[i]);\n\t\tDUK_ASSERT(h != NULL);\n\t\tthr->builtins[i] = h;\n\t}\n\n#if defined(DUK_USE_ROM_GLOBAL_CLONE) || defined(DUK_USE_ROM_GLOBAL_INHERIT)\n\t/* By default the global object is read-only which is often much\n\t * more of an issue than having read-only built-in objects (like\n\t * RegExp, Date, etc).  Use a RAM-based copy of the global object\n\t * and the global environment object for convenience.\n\t */\n\tduk__duplicate_ram_global_object(thr);\n#endif\n}\n#else  /* DUK_USE_ROM_OBJECTS */\nDUK_LOCAL void duk__push_stridx(duk_context *ctx, duk_bitdecoder_ctx *bd) {\n\tduk_small_uint_t n;\n\n\tn = (duk_small_uint_t) duk_bd_decode_varuint(bd);\n\tDUK_ASSERT_DISABLE(n >= 0);  /* unsigned */\n\tDUK_ASSERT(n < DUK_HEAP_NUM_STRINGS);\n\tduk_push_hstring_stridx(ctx, n);\n}\nDUK_LOCAL void duk__push_string(duk_context *ctx, duk_bitdecoder_ctx *bd) {\n\t/* XXX: built-ins data could provide a maximum length that is\n\t * actually needed; bitpacked max length is now 256 bytes.\n\t */\n\tduk_uint8_t tmp[DUK_BD_BITPACKED_STRING_MAXLEN];\n\tduk_small_uint_t len;\n\n\tlen = duk_bd_decode_bitpacked_string(bd, tmp);\n\tduk_push_lstring(ctx, (const char *) tmp, (duk_size_t) len);\n}\nDUK_LOCAL void duk__push_stridx_or_string(duk_context *ctx, duk_bitdecoder_ctx *bd) {\n\tduk_small_uint_t n;\n\n\tn = (duk_small_uint_t) duk_bd_decode_varuint(bd);\n\tif (n == 0) {\n\t\tduk__push_string(ctx, bd);\n\t} else {\n\t\tn--;\n\t\tDUK_ASSERT(n < DUK_HEAP_NUM_STRINGS);\n\t\tduk_push_hstring_stridx(ctx, n);\n\t}\n}\nDUK_LOCAL void duk__push_double(duk_context *ctx, duk_bitdecoder_ctx *bd) {\n\tduk_double_union du;\n\tduk_small_uint_t i;\n\n\tfor (i = 0; i < 8; i++) {\n\t\t/* Encoding endianness must match target memory layout,\n\t\t * build scripts and genbuiltins.py must ensure this.\n\t\t */\n\t\tdu.uc[i] = (duk_uint8_t) duk_bd_decode(bd, 8);\n\t}\n\n\tduk_push_number(ctx, du.d);  /* push operation normalizes NaNs */\n}\n\nDUK_INTERNAL void duk_hthread_create_builtin_objects(duk_hthread *thr) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_bitdecoder_ctx bd_ctx;\n\tduk_bitdecoder_ctx *bd = &bd_ctx;  /* convenience */\n\tduk_hobject *h;\n\tduk_small_uint_t i, j;\n\n\tDUK_D(DUK_DPRINT(\"INITBUILTINS BEGIN: DUK_NUM_BUILTINS=%d, DUK_NUM_BUILTINS_ALL=%d\", (int) DUK_NUM_BUILTINS, (int) DUK_NUM_ALL_BUILTINS));\n\n\tDUK_MEMZERO(&bd_ctx, sizeof(bd_ctx));\n\tbd->data = (const duk_uint8_t *) duk_builtins_data;\n\tbd->length = (duk_size_t) DUK_BUILTINS_DATA_LENGTH;\n\n\t/*\n\t *  First create all built-in bare objects on the empty valstack.\n\t *\n\t *  Built-ins in the index range [0,DUK_NUM_BUILTINS-1] have value\n\t *  stack indices matching their eventual thr->builtins[] index.\n\t *\n\t *  Built-ins in the index range [DUK_NUM_BUILTINS,DUK_NUM_ALL_BUILTINS]\n\t *  will exist on the value stack during init but won't be placed\n\t *  into thr->builtins[].  These are objects referenced in some way\n\t *  from thr->builtins[] roots but which don't need to be indexed by\n\t *  Duktape through thr->builtins[] (e.g. user custom objects).\n\t */\n\n\tduk_require_stack(ctx, DUK_NUM_ALL_BUILTINS);\n\n\tDUK_DD(DUK_DDPRINT(\"create empty built-ins\"));\n\tDUK_ASSERT_TOP(ctx, 0);\n\tfor (i = 0; i < DUK_NUM_ALL_BUILTINS; i++) {\n\t\tduk_small_uint_t class_num;\n\t\tduk_small_int_t len = -1;  /* must be signed */\n\n\t\tclass_num = (duk_small_uint_t) duk_bd_decode_varuint(bd);\n\t\tlen = (duk_small_int_t) duk_bd_decode_flagged_signed(bd, DUK__LENGTH_PROP_BITS, (duk_int32_t) -1 /*def_value*/);\n\n\t\tif (class_num == DUK_HOBJECT_CLASS_FUNCTION) {\n\t\t\tduk_small_uint_t natidx;\n\t\t\tduk_small_int_t c_nargs;  /* must hold DUK_VARARGS */\n\t\t\tduk_c_function c_func;\n\t\t\tduk_int16_t magic;\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"len=%ld\", (long) len));\n\t\t\tDUK_ASSERT(len >= 0);\n\n\t\t\tnatidx = (duk_small_uint_t) duk_bd_decode_varuint(bd);\n\t\t\tDUK_ASSERT(natidx != 0);\n\t\t\tc_func = duk_bi_native_functions[natidx];\n\t\t\tDUK_ASSERT(c_func != NULL);\n\n\t\t\tc_nargs = (duk_small_int_t) duk_bd_decode_flagged_signed(bd, DUK__NARGS_BITS, len /*def_value*/);\n\t\t\tif (c_nargs == DUK__NARGS_VARARGS_MARKER) {\n\t\t\t\tc_nargs = DUK_VARARGS;\n\t\t\t}\n\n\t\t\t/* XXX: set magic directly here? (it could share the c_nargs arg) */\n\t\t\tduk_push_c_function_noexotic(ctx, c_func, c_nargs);\n\n\t\t\th = duk_known_hobject(ctx, -1);\n\n\t\t\t/* Currently all built-in native functions are strict.\n\t\t\t * duk_push_c_function() now sets strict flag, so\n\t\t\t * assert for it.\n\t\t\t */\n\t\t\tDUK_ASSERT(DUK_HOBJECT_HAS_STRICT(h));\n\n\t\t\t/* XXX: function properties */\n\n\t\t\tduk__push_stridx_or_string(ctx, bd);\n#if defined(DUK_USE_FUNC_NAME_PROPERTY)\n\t\t\tduk_xdef_prop_stridx_short(ctx,\n\t\t\t                           -2,\n\t\t\t                           DUK_STRIDX_NAME,\n\t\t\t                           DUK_PROPDESC_FLAGS_C);\n#else\n\t\t\tduk_pop(ctx);  /* Not very ideal but good enough for now. */\n#endif\n\n\t\t\t/* Almost all global level Function objects are constructable\n\t\t\t * but not all: Function.prototype is a non-constructable,\n\t\t\t * callable Function.\n\t\t\t */\n\t\t\tif (duk_bd_decode_flag(bd)) {\n\t\t\t\tDUK_ASSERT(DUK_HOBJECT_HAS_CONSTRUCTABLE(h));\n\t\t\t} else {\n\t\t\t\tDUK_HOBJECT_CLEAR_CONSTRUCTABLE(h);\n\t\t\t}\n\n\t\t\t/* Cast converts magic to 16-bit signed value */\n\t\t\tmagic = (duk_int16_t) duk_bd_decode_varuint(bd);\n\t\t\t((duk_hnatfunc *) h)->magic = magic;\n\t\t} else if (class_num == DUK_HOBJECT_CLASS_ARRAY) {\n\t\t\tduk_push_array(ctx);\n\t\t} else if (class_num == DUK_HOBJECT_CLASS_OBJENV) {\n\t\t\tduk_hobjenv *env;\n\t\t\tduk_hobject *global;\n\n\t\t\tDUK_ASSERT(i == DUK_BIDX_GLOBAL_ENV);\n\t\t\tDUK_ASSERT(DUK_BIDX_GLOBAL_ENV > DUK_BIDX_GLOBAL);\n\n\t\t\tenv = duk_hobjenv_alloc(thr,\n\t                                        DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                                        DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_OBJENV));\n\t\t\tDUK_ASSERT(env->target == NULL);\n\t\t\tduk_push_hobject(ctx, (duk_hobject *) env);\n\n\t\t\tglobal = duk_known_hobject(ctx, DUK_BIDX_GLOBAL);\n\t\t\tDUK_ASSERT(global != NULL);\n\t\t\tenv->target = global;\n\t\t\tDUK_HOBJECT_INCREF(thr, global);\n\t\t\tDUK_ASSERT(env->has_this == 0);\n\n\t\t\tDUK_ASSERT_HOBJENV_VALID(env);\n\t\t} else {\n\t\t\tDUK_ASSERT(class_num != DUK_HOBJECT_CLASS_DECENV);\n\n\t\t\t(void) duk_push_object_helper(ctx,\n\t\t\t                              DUK_HOBJECT_FLAG_FASTREFS |\n\t\t\t                              DUK_HOBJECT_FLAG_EXTENSIBLE,\n\t\t\t                              -1);  /* no prototype or class yet */\n\n\t\t}\n\n\t\th = duk_known_hobject(ctx, -1);\n\t\tDUK_HOBJECT_SET_CLASS_NUMBER(h, class_num);\n\n\t\tif (i < DUK_NUM_BUILTINS) {\n\t\t\tthr->builtins[i] = h;\n\t\t\tDUK_HOBJECT_INCREF(thr, &h->hdr);\n\t\t}\n\n\t\tif (len >= 0) {\n\t\t\t/* In ES2015+ built-in function object .length property\n\t\t\t * has property attributes C (configurable only):\n\t\t\t * http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-standard-built-in-objects\n\t\t\t *\n\t\t\t * Array.prototype remains an Array instance in ES2015+\n\t\t\t * and its length has attributes W (writable only).\n\t\t\t * Because .length is now virtual for duk_harray, it is\n\t\t\t * not encoded explicitly in init data.\n\t\t\t */\n\n\t\t\tDUK_ASSERT(class_num != DUK_HOBJECT_CLASS_ARRAY);  /* .length is virtual */\n\t\t\tduk_push_int(ctx, len);\n\t\t\tduk_xdef_prop_stridx_short(ctx,\n\t\t\t                           -2,\n\t\t\t                           DUK_STRIDX_LENGTH,\n\t\t\t                           DUK_PROPDESC_FLAGS_C);\n\t\t}\n\n\t\t/* enable exotic behaviors last */\n\n\t\tif (class_num == DUK_HOBJECT_CLASS_ARRAY) {\n\t\t\tDUK_ASSERT(DUK_HOBJECT_HAS_EXOTIC_ARRAY(h));  /* set by duk_push_array() */\n\t\t}\n\t\tif (class_num == DUK_HOBJECT_CLASS_STRING) {\n\t\t\tDUK_HOBJECT_SET_EXOTIC_STRINGOBJ(h);\n\t\t}\n\n\t\t/* some assertions */\n\n\t\tDUK_ASSERT(DUK_HOBJECT_HAS_EXTENSIBLE(h));\n\t\t/* DUK_HOBJECT_FLAG_CONSTRUCTABLE varies */\n\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_BOUNDFUNC(h));\n\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_COMPFUNC(h));\n\t\t/* DUK_HOBJECT_FLAG_NATFUNC varies */\n\t\tDUK_ASSERT(!DUK_HOBJECT_IS_THREAD(h));\n\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_ARRAY_PART(h) || class_num == DUK_HOBJECT_CLASS_ARRAY);\n\t\t/* DUK_HOBJECT_FLAG_STRICT varies */\n\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_NATFUNC(h) ||  /* all native functions have NEWENV */\n\t\t           DUK_HOBJECT_HAS_NEWENV(h));\n\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_NAMEBINDING(h));\n\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_CREATEARGS(h));\n\t\t/* DUK_HOBJECT_FLAG_EXOTIC_ARRAY varies */\n\t\t/* DUK_HOBJECT_FLAG_EXOTIC_STRINGOBJ varies */\n\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS(h));\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"created built-in %ld, class=%ld, length=%ld\", (long) i, (long) class_num, (long) len));\n\t}\n\n\t/*\n\t *  Then decode the builtins init data (see genbuiltins.py) to\n\t *  init objects\n\t */\n\n\tDUK_DD(DUK_DDPRINT(\"initialize built-in object properties\"));\n\tfor (i = 0; i < DUK_NUM_ALL_BUILTINS; i++) {\n\t\tduk_small_uint_t t;\n\t\tduk_small_uint_t num;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"initializing built-in object at index %ld\", (long) i));\n\t\th = duk_known_hobject(ctx, i);\n\n\t\tt = (duk_small_uint_t) duk_bd_decode_varuint(bd);\n\t\tif (t > 0) {\n\t\t\tt--;\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"set internal prototype: built-in %ld\", (long) t));\n\t\t\tDUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, h, duk_known_hobject(ctx, t));\n\t\t}\n\n\t\tt = (duk_small_uint_t) duk_bd_decode_varuint(bd);\n\t\tif (t > 0) {\n\t\t\t/* 'prototype' property for all built-in objects (which have it) has attributes:\n\t\t\t *  [[Writable]] = false,\n\t\t\t *  [[Enumerable]] = false,\n\t\t\t *  [[Configurable]] = false\n\t\t\t */\n\t\t\tt--;\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"set external prototype: built-in %ld\", (long) t));\n\t\t\tduk_xdef_prop_stridx_builtin(ctx, i, DUK_STRIDX_PROTOTYPE, t, DUK_PROPDESC_FLAGS_NONE);\n\t\t}\n\n\t\tt = (duk_small_uint_t) duk_bd_decode_varuint(bd);\n\t\tif (t > 0) {\n\t\t\t/* 'constructor' property for all built-in objects (which have it) has attributes:\n\t\t\t *  [[Writable]] = true,\n\t\t\t *  [[Enumerable]] = false,\n\t\t\t *  [[Configurable]] = true\n\t\t\t */\n\t\t\tt--;\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"set external constructor: built-in %ld\", (long) t));\n\t\t\tduk_xdef_prop_stridx_builtin(ctx, i, DUK_STRIDX_CONSTRUCTOR, t, DUK_PROPDESC_FLAGS_WC);\n\t\t}\n\n\t\t/* normal valued properties */\n\t\tnum = (duk_small_uint_t) duk_bd_decode_varuint(bd);\n\t\tDUK_DDD(DUK_DDDPRINT(\"built-in object %ld, %ld normal valued properties\", (long) i, (long) num));\n\t\tfor (j = 0; j < num; j++) {\n\t\t\tduk_small_uint_t defprop_flags;\n\n\t\t\tduk__push_stridx_or_string(ctx, bd);\n\n\t\t\t/*\n\t\t\t *  Property attribute defaults are defined in E5 Section 15 (first\n\t\t\t *  few pages); there is a default for all properties and a special\n\t\t\t *  default for 'length' properties.  Variation from the defaults is\n\t\t\t *  signaled using a single flag bit in the bitstream.\n\t\t\t */\n\n\t\t\tif (duk_bd_decode_flag(bd)) {\n\t\t\t\tdefprop_flags = (duk_small_uint_t) duk_bd_decode(bd, DUK__PROP_FLAGS_BITS);\n\t\t\t} else {\n\t\t\t\tdefprop_flags = DUK_PROPDESC_FLAGS_WC;\n\t\t\t}\n\t\t\tdefprop_flags |= DUK_DEFPROP_FORCE |\n\t\t\t                 DUK_DEFPROP_HAVE_VALUE |\n\t\t\t                 DUK_DEFPROP_HAVE_WRITABLE |\n\t\t\t                 DUK_DEFPROP_HAVE_ENUMERABLE |\n\t\t\t                 DUK_DEFPROP_HAVE_CONFIGURABLE;  /* Defaults for data properties. */\n\n\t\t\t/* The writable, enumerable, configurable flags in prop_flags\n\t\t\t * match both duk_def_prop() and internal property flags.\n\t\t\t */\n\t\t\tDUK_ASSERT(DUK_PROPDESC_FLAG_WRITABLE == DUK_DEFPROP_WRITABLE);\n\t\t\tDUK_ASSERT(DUK_PROPDESC_FLAG_ENUMERABLE == DUK_DEFPROP_ENUMERABLE);\n\t\t\tDUK_ASSERT(DUK_PROPDESC_FLAG_CONFIGURABLE == DUK_DEFPROP_CONFIGURABLE);\n\n\t\t\tt = (duk_small_uint_t) duk_bd_decode(bd, DUK__PROP_TYPE_BITS);\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"built-in %ld, normal-valued property %ld, key %!T, flags 0x%02lx, type %ld\",\n\t\t\t                     (long) i, (long) j, duk_get_tval(ctx, -1), (unsigned long) defprop_flags, (long) t));\n\n\t\t\tswitch (t) {\n\t\t\tcase DUK__PROP_TYPE_DOUBLE: {\n\t\t\t\tduk__push_double(ctx, bd);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase DUK__PROP_TYPE_STRING: {\n\t\t\t\tduk__push_string(ctx, bd);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase DUK__PROP_TYPE_STRIDX: {\n\t\t\t\tduk__push_stridx(ctx, bd);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase DUK__PROP_TYPE_BUILTIN: {\n\t\t\t\tduk_small_uint_t bidx;\n\n\t\t\t\tbidx = (duk_small_uint_t) duk_bd_decode_varuint(bd);\n\t\t\t\tduk_dup(ctx, (duk_idx_t) bidx);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase DUK__PROP_TYPE_UNDEFINED: {\n\t\t\t\tduk_push_undefined(ctx);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase DUK__PROP_TYPE_BOOLEAN_TRUE: {\n\t\t\t\tduk_push_true(ctx);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase DUK__PROP_TYPE_BOOLEAN_FALSE: {\n\t\t\t\tduk_push_false(ctx);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase DUK__PROP_TYPE_ACCESSOR: {\n\t\t\t\tduk_small_uint_t natidx_getter = (duk_small_uint_t) duk_bd_decode_varuint(bd);\n\t\t\t\tduk_small_uint_t natidx_setter = (duk_small_uint_t) duk_bd_decode_varuint(bd);\n\t\t\t\tduk_small_uint_t accessor_magic = (duk_small_uint_t) duk_bd_decode_varuint(bd);\n\t\t\t\tduk_c_function c_func_getter;\n\t\t\t\tduk_c_function c_func_setter;\n\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"built-in accessor property: objidx=%ld, key=%!T, getteridx=%ld, setteridx=%ld, flags=0x%04lx\",\n\t\t\t\t                     (long) i, duk_get_tval(ctx, -1), (long) natidx_getter, (long) natidx_setter, (unsigned long) defprop_flags));\n\n\t\t\t\tc_func_getter = duk_bi_native_functions[natidx_getter];\n\t\t\t\tif (c_func_getter != NULL) {\n\t\t\t\t\tduk_push_c_function_noconstruct_noexotic(ctx, c_func_getter, 0);  /* always 0 args */\n\t\t\t\t\tduk_set_magic(ctx, -1, (duk_int_t) accessor_magic);\n\t\t\t\t\tdefprop_flags |= DUK_DEFPROP_HAVE_GETTER;\n\t\t\t\t}\n\t\t\t\tc_func_setter = duk_bi_native_functions[natidx_setter];\n\t\t\t\tif (c_func_setter != NULL) {\n\t\t\t\t\tduk_push_c_function_noconstruct_noexotic(ctx, c_func_setter, 1);  /* always 1 arg */\n\t\t\t\t\tduk_set_magic(ctx, -1, (duk_int_t) accessor_magic);\n\t\t\t\t\tdefprop_flags |= DUK_DEFPROP_HAVE_SETTER;\n\t\t\t\t}\n\n\t\t\t\t/* Writable flag doesn't make sense for an accessor. */\n\t\t\t\tDUK_ASSERT((defprop_flags & DUK_PROPDESC_FLAG_WRITABLE) == 0);  /* genbuiltins.py ensures */\n\n\t\t\t\tdefprop_flags &= ~(DUK_DEFPROP_HAVE_VALUE | DUK_DEFPROP_HAVE_WRITABLE);\n\t\t\t\tdefprop_flags |= DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_HAVE_CONFIGURABLE;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\t/* exhaustive */\n\t\t\t\tDUK_UNREACHABLE();\n\t\t\t}\n\t\t\t}\n\n\t\t\tduk_def_prop(ctx, i, defprop_flags);\n\t\t\tDUK_ASSERT_TOP(ctx, DUK_NUM_ALL_BUILTINS);\n\t\t}\n\n\t\t/* native function properties */\n\t\tnum = (duk_small_uint_t) duk_bd_decode_varuint(bd);\n\t\tDUK_DDD(DUK_DDDPRINT(\"built-in object %ld, %ld function valued properties\", (long) i, (long) num));\n\t\tfor (j = 0; j < num; j++) {\n\t\t\tduk_hstring *h_key;\n\t\t\tduk_small_uint_t natidx;\n\t\t\tduk_int_t c_nargs;  /* must hold DUK_VARARGS */\n\t\t\tduk_small_uint_t c_length;\n\t\t\tduk_int16_t magic;\n\t\t\tduk_c_function c_func;\n\t\t\tduk_hnatfunc *h_func;\n#if defined(DUK_USE_LIGHTFUNC_BUILTINS)\n\t\t\tduk_small_int_t lightfunc_eligible;\n#endif\n\n\t\t\tduk__push_stridx_or_string(ctx, bd);\n\t\t\th_key = duk_known_hstring(ctx, -1);\n\t\t\tDUK_UNREF(h_key);\n\t\t\tnatidx = (duk_small_uint_t) duk_bd_decode_varuint(bd);\n\n\t\t\tc_length = (duk_small_uint_t) duk_bd_decode(bd, DUK__LENGTH_PROP_BITS);\n\t\t\tc_nargs = (duk_int_t) duk_bd_decode_flagged(bd, DUK__NARGS_BITS, (duk_int32_t) c_length /*def_value*/);\n\t\t\tif (c_nargs == DUK__NARGS_VARARGS_MARKER) {\n\t\t\t\tc_nargs = DUK_VARARGS;\n\t\t\t}\n\n\t\t\tc_func = duk_bi_native_functions[natidx];\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"built-in %ld, function-valued property %ld, key %!O, natidx %ld, length %ld, nargs %ld\",\n\t\t\t                     (long) i, (long) j, (duk_heaphdr *) h_key, (long) natidx, (long) c_length,\n\t\t\t                     (c_nargs == DUK_VARARGS ? (long) -1 : (long) c_nargs)));\n\n\t\t\t/* Cast converts magic to 16-bit signed value */\n\t\t\tmagic = (duk_int16_t) duk_bd_decode_varuint(bd);\n\n#if defined(DUK_USE_LIGHTFUNC_BUILTINS)\n\t\t\tlightfunc_eligible =\n\t\t\t\t((c_nargs >= DUK_LFUNC_NARGS_MIN && c_nargs <= DUK_LFUNC_NARGS_MAX) || (c_nargs == DUK_VARARGS)) &&\n\t\t\t\t(c_length <= DUK_LFUNC_LENGTH_MAX) &&\n\t\t\t\t(magic >= DUK_LFUNC_MAGIC_MIN && magic <= DUK_LFUNC_MAGIC_MAX);\n\n\t\t\tif (h_key == DUK_HTHREAD_STRING_EVAL(thr) ||\n\t\t\t    h_key == DUK_HTHREAD_STRING_YIELD(thr) ||\n\t\t\t    h_key == DUK_HTHREAD_STRING_RESUME(thr)) {\n\t\t\t\t/* These functions have trouble working as lightfuncs.\n\t\t\t\t * Some of them have specific asserts and some may have\n\t\t\t         * additional properties (e.g. 'require.id' may be written).\n\t\t\t\t */\n\t\t\t\tDUK_D(DUK_DPRINT(\"reject as lightfunc: key=%!O, i=%d, j=%d\", (duk_heaphdr *) h_key, (int) i, (int) j));\n\t\t\t\tlightfunc_eligible = 0;\n\t\t\t}\n\n\t\t\tif (lightfunc_eligible) {\n\t\t\t\tduk_tval tv_lfunc;\n\t\t\t\tduk_small_uint_t lf_nargs = (c_nargs == DUK_VARARGS ? DUK_LFUNC_NARGS_VARARGS : c_nargs);\n\t\t\t\tduk_small_uint_t lf_flags = DUK_LFUNC_FLAGS_PACK(magic, c_length, lf_nargs);\n\t\t\t\tDUK_TVAL_SET_LIGHTFUNC(&tv_lfunc, c_func, lf_flags);\n\t\t\t\tduk_push_tval(ctx, &tv_lfunc);\n\t\t\t\tDUK_D(DUK_DPRINT(\"built-in function eligible as light function: i=%d, j=%d c_length=%ld, c_nargs=%ld, magic=%ld -> %!iT\", (int) i, (int) j, (long) c_length, (long) c_nargs, (long) magic, duk_get_tval(ctx, -1)));\n\t\t\t\tgoto lightfunc_skip;\n\t\t\t}\n\n\t\t\tDUK_D(DUK_DPRINT(\"built-in function NOT ELIGIBLE as light function: i=%d, j=%d c_length=%ld, c_nargs=%ld, magic=%ld\", (int) i, (int) j, (long) c_length, (long) c_nargs, (long) magic));\n#endif  /* DUK_USE_LIGHTFUNC_BUILTINS */\n\n\t\t\t/* [ (builtin objects) name ] */\n\n\t\t\tduk_push_c_function_noconstruct_noexotic(ctx, c_func, c_nargs);\n\t\t\th_func = duk_known_hnatfunc(ctx, -1);\n\t\t\tDUK_UNREF(h_func);\n\n\t\t\t/* Currently all built-in native functions are strict.\n\t\t\t * This doesn't matter for many functions, but e.g.\n\t\t\t * String.prototype.charAt (and other string functions)\n\t\t\t * rely on being strict so that their 'this' binding is\n\t\t\t * not automatically coerced.\n\t\t\t */\n\t\t\tDUK_HOBJECT_SET_STRICT((duk_hobject *) h_func);\n\n\t\t\t/* No built-in functions are constructable except the top\n\t\t\t * level ones (Number, etc).\n\t\t\t */\n\t\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_CONSTRUCTABLE((duk_hobject *) h_func));\n\n\t\t\t/* XXX: any way to avoid decoding magic bit; there are quite\n\t\t\t * many function properties and relatively few with magic values.\n\t\t\t */\n\t\t\th_func->magic = magic;\n\n\t\t\t/* [ (builtin objects) name func ] */\n\n\t\t\tduk_push_int(ctx, c_length);\n\t\t\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_LENGTH, DUK_PROPDESC_FLAGS_C);\n\n\t\t\tduk_dup_m2(ctx);\n\t\t\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_NAME, DUK_PROPDESC_FLAGS_C);\n\n\t\t\t/* XXX: other properties of function instances; 'arguments', 'caller'. */\n\n\t\t\tDUK_DD(DUK_DDPRINT(\"built-in object %ld, function property %ld -> %!T\",\n\t\t\t                   (long) i, (long) j, (duk_tval *) duk_get_tval(ctx, -1)));\n\n\t\t\t/* [ (builtin objects) name func ] */\n\n\t\t\t/*\n\t\t\t *  The default property attributes are correct for all\n\t\t\t *  function valued properties of built-in objects now.\n\t\t\t */\n\n#if defined(DUK_USE_LIGHTFUNC_BUILTINS)\n\t\t lightfunc_skip:\n#endif\n\n\t\t\tduk_xdef_prop(ctx, i, DUK_PROPDESC_FLAGS_WC);\n\n\t\t\t/* [ (builtin objects) ] */\n\t\t}\n\t}\n\n\t/*\n\t *  Special post-tweaks, for cases not covered by the init data format.\n\t *\n\t *  - Set Date.prototype.toGMTString to Date.prototype.toUTCString.\n\t *    toGMTString is required to have the same Function object as\n\t *    toUTCString in E5 Section B.2.6.  Note that while Smjs respects\n\t *    this, V8 does not (the Function objects are distinct).\n\t *\n\t *  - Make DoubleError non-extensible.\n\t *\n\t *  - Add info about most important effective compile options to Duktape.\n\t *\n\t *  - Possibly remove some properties (values or methods) which are not\n\t *    desirable with current feature options but are not currently\n\t *    conditional in init data.\n\t */\n\n#if defined(DUK_USE_DATE_BUILTIN)\n\tduk_get_prop_stridx_short(ctx, DUK_BIDX_DATE_PROTOTYPE, DUK_STRIDX_TO_UTC_STRING);\n\tduk_xdef_prop_stridx_short(ctx, DUK_BIDX_DATE_PROTOTYPE, DUK_STRIDX_TO_GMT_STRING, DUK_PROPDESC_FLAGS_WC);\n#endif\n\n\th = duk_known_hobject(ctx, DUK_BIDX_DOUBLE_ERROR);\n\tDUK_HOBJECT_CLEAR_EXTENSIBLE(h);\n\n#if !defined(DUK_USE_ES6_OBJECT_PROTO_PROPERTY)\n\tDUK_DD(DUK_DDPRINT(\"delete Object.prototype.__proto__ built-in which is not enabled in features\"));\n\t(void) duk_hobject_delprop_raw(thr, thr->builtins[DUK_BIDX_OBJECT_PROTOTYPE], DUK_HTHREAD_STRING___PROTO__(thr), DUK_DELPROP_FLAG_THROW);\n#endif\n\n#if !defined(DUK_USE_ES6_OBJECT_SETPROTOTYPEOF)\n\tDUK_DD(DUK_DDPRINT(\"delete Object.setPrototypeOf built-in which is not enabled in features\"));\n\t(void) duk_hobject_delprop_raw(thr, thr->builtins[DUK_BIDX_OBJECT_CONSTRUCTOR], DUK_HTHREAD_STRING_SET_PROTOTYPE_OF(thr), DUK_DELPROP_FLAG_THROW);\n#endif\n\n\t/* XXX: relocate */\n\tduk_push_string(ctx,\n\t\t\t/* Endianness indicator */\n#if defined(DUK_USE_INTEGER_LE)\n\t                \"l\"\n#elif defined(DUK_USE_INTEGER_BE)\n\t                \"b\"\n#elif defined(DUK_USE_INTEGER_ME)  /* integer mixed endian not really used now */\n\t                \"m\"\n#else\n\t                \"?\"\n#endif\n#if defined(DUK_USE_DOUBLE_LE)\n\t                \"l\"\n#elif defined(DUK_USE_DOUBLE_BE)\n\t                \"b\"\n#elif defined(DUK_USE_DOUBLE_ME)\n\t                \"m\"\n#else\n\t                \"?\"\n#endif\n\t                \" \"\n\t\t\t/* Packed or unpacked tval */\n#if defined(DUK_USE_PACKED_TVAL)\n\t                \"p\"\n#else\n\t                \"u\"\n#endif\n#if defined(DUK_USE_FASTINT)\n\t\t\t\"f\"\n#endif\n\t\t\t\" \"\n\t\t\t/* Low memory options */\n#if defined(DUK_USE_STRTAB_PTRCOMP)\n\t\t\t\"s\"\n#endif\n#if !defined(DUK_USE_HEAPPTR16) && !defined(DUK_DATAPTR16) && !defined(DUK_FUNCPTR16)\n\t\t\t\"n\"\n#endif\n#if defined(DUK_USE_HEAPPTR16)\n\t\t\t\"h\"\n#endif\n#if defined(DUK_USE_DATAPTR16)\n\t\t\t\"d\"\n#endif\n#if defined(DUK_USE_FUNCPTR16)\n\t\t\t\"f\"\n#endif\n#if defined(DUK_USE_REFCOUNT16)\n\t\t\t\"R\"\n#endif\n#if defined(DUK_USE_STRHASH16)\n\t\t\t\"H\"\n#endif\n#if defined(DUK_USE_STRLEN16)\n\t\t\t\"S\"\n#endif\n#if defined(DUK_USE_BUFLEN16)\n\t\t\t\"B\"\n#endif\n#if defined(DUK_USE_OBJSIZES16)\n\t\t\t\"O\"\n#endif\n#if defined(DUK_USE_LIGHTFUNC_BUILTINS)\n\t\t\t\"L\"\n#endif\n#if defined(DUK_USE_ROM_STRINGS) || defined(DUK_USE_ROM_OBJECTS)\n\t\t\t/* XXX: This won't be shown in practice now\n\t\t\t * because this code is not run when builtins\n\t\t\t * are in ROM.\n\t\t\t */\n\t\t\t\"Z\"\n#endif\n\t                \" \"\n\t\t\t/* Object property allocation layout */\n#if defined(DUK_USE_HOBJECT_LAYOUT_1)\n\t\t\t\"p1\"\n#elif defined(DUK_USE_HOBJECT_LAYOUT_2)\n\t\t\t\"p2\"\n#elif defined(DUK_USE_HOBJECT_LAYOUT_3)\n\t\t\t\"p3\"\n#else\n\t\t\t\"p?\"\n#endif\n\t\t\t\" \"\n\t\t\t/* Alignment guarantee */\n#if (DUK_USE_ALIGN_BY == 4)\n\t\t\t\"a4\"\n#elif (DUK_USE_ALIGN_BY == 8)\n\t\t\t\"a8\"\n#elif (DUK_USE_ALIGN_BY == 1)\n\t\t\t\"a1\"\n#else\n#error invalid DUK_USE_ALIGN_BY\n#endif\n\t\t\t\" \"\n\t\t\t/* Architecture, OS, and compiler strings */\n\t                DUK_USE_ARCH_STRING\n\t\t\t\" \"\n\t                DUK_USE_OS_STRING\n\t\t\t\" \"\n\t                DUK_USE_COMPILER_STRING);\n\tduk_xdef_prop_stridx_short(ctx, DUK_BIDX_DUKTAPE, DUK_STRIDX_ENV, DUK_PROPDESC_FLAGS_WC);\n\n\t/*\n\t *  Since built-ins are not often extended, compact them.\n\t */\n\n\tDUK_DD(DUK_DDPRINT(\"compact built-ins\"));\n\tfor (i = 0; i < DUK_NUM_ALL_BUILTINS; i++) {\n\t\tduk_hobject_compact_props(thr, duk_known_hobject(ctx, i));\n\t}\n\n\tDUK_D(DUK_DPRINT(\"INITBUILTINS END\"));\n\n#if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 1)\n\tfor (i = 0; i < DUK_NUM_ALL_BUILTINS; i++) {\n\t\tDUK_DD(DUK_DDPRINT(\"built-in object %ld after initialization and compacting: %!@iO\",\n\t\t                   (long) i, (duk_heaphdr *) duk_require_hobject(ctx, i)));\n\t}\n#endif\n\n\t/*\n\t *  Pop built-ins from stack: they are now INCREF'd and\n\t *  reachable from the builtins[] array or indirectly\n\t *  through builtins[].\n\t */\n\n\tduk_set_top(ctx, 0);\n\tDUK_ASSERT_TOP(ctx, 0);\n}\n#endif  /* DUK_USE_ROM_OBJECTS */\n\nDUK_INTERNAL void duk_hthread_copy_builtin_objects(duk_hthread *thr_from, duk_hthread *thr_to) {\n\tduk_small_uint_t i;\n\n\tfor (i = 0; i < DUK_NUM_BUILTINS; i++) {\n\t\tthr_to->builtins[i] = thr_from->builtins[i];\n\t\tDUK_HOBJECT_INCREF_ALLOWNULL(thr_to, thr_to->builtins[i]);  /* side effect free */\n\t}\n}\n\n/* automatic undefs */\n#undef DUK__LENGTH_PROP_BITS\n#undef DUK__NARGS_BITS\n#undef DUK__NARGS_VARARGS_MARKER\n#undef DUK__PROP_FLAGS_BITS\n#undef DUK__PROP_TYPE_ACCESSOR\n#undef DUK__PROP_TYPE_BITS\n#undef DUK__PROP_TYPE_BOOLEAN_FALSE\n#undef DUK__PROP_TYPE_BOOLEAN_TRUE\n#undef DUK__PROP_TYPE_BUILTIN\n#undef DUK__PROP_TYPE_DOUBLE\n#undef DUK__PROP_TYPE_STRIDX\n#undef DUK__PROP_TYPE_STRING\n#undef DUK__PROP_TYPE_UNDEFINED\n/*\n *  Thread support.\n */\n\n/* #include duk_internal.h -> already included */\n\nDUK_INTERNAL void duk_hthread_terminate(duk_hthread *thr) {\n\tDUK_ASSERT(thr != NULL);\n\n\t/* Order of unwinding is important */\n\n\tduk_hthread_catchstack_unwind(thr, 0);\n\tduk_hthread_callstack_unwind(thr, 0);  /* side effects, possibly errors */\n\n\tthr->valstack_bottom = thr->valstack;\n\tduk_set_top((duk_context *) thr, 0);  /* unwinds valstack, updating refcounts */\n\n\tthr->state = DUK_HTHREAD_STATE_TERMINATED;\n\n\t/* Here we could remove references to built-ins, but it may not be\n\t * worth the effort because built-ins are quite likely to be shared\n\t * with another (unterminated) thread, and terminated threads are also\n\t * usually garbage collected quite quickly.  Also, doing DECREFs\n\t * could trigger finalization, which would run on the current thread\n\t * and have access to only some of the built-ins.  Garbage collection\n\t * deals with this correctly already.\n\t */\n\n\t/* XXX: Shrink the stacks to minimize memory usage?  May not\n\t * be worth the effort because terminated threads are usually\n\t * garbage collected quite soon.\n\t */\n}\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\nDUK_INTERNAL duk_uint_fast32_t duk_hthread_get_act_curr_pc(duk_hthread *thr, duk_activation *act) {\n\tduk_instr_t *bcode;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(act != NULL);\n\tDUK_UNREF(thr);\n\n\t/* XXX: store 'bcode' pointer to activation for faster lookup? */\n\tif (act->func && DUK_HOBJECT_IS_COMPFUNC(act->func)) {\n\t\tbcode = DUK_HCOMPFUNC_GET_CODE_BASE(thr->heap, (duk_hcompfunc *) (act->func));\n\t\treturn (duk_uint_fast32_t) (act->curr_pc - bcode);\n\t}\n\treturn 0;\n}\n#endif  /* DUK_USE_DEBUGGER_SUPPORT */\n\nDUK_INTERNAL duk_uint_fast32_t duk_hthread_get_act_prev_pc(duk_hthread *thr, duk_activation *act) {\n\tduk_instr_t *bcode;\n\tduk_uint_fast32_t ret;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(act != NULL);\n\tDUK_UNREF(thr);\n\n\tif (act->func && DUK_HOBJECT_IS_COMPFUNC(act->func)) {\n\t\tbcode = DUK_HCOMPFUNC_GET_CODE_BASE(thr->heap, (duk_hcompfunc *) (act->func));\n\t\tret = (duk_uint_fast32_t) (act->curr_pc - bcode);\n\t\tif (ret > 0) {\n\t\t\tret--;\n\t\t}\n\t\treturn ret;\n\t}\n\treturn 0;\n}\n\n/* Write bytecode executor's curr_pc back to topmost activation (if any). */\nDUK_INTERNAL void duk_hthread_sync_currpc(duk_hthread *thr) {\n\tduk_activation *act;\n\n\tDUK_ASSERT(thr != NULL);\n\n\tif (thr->ptr_curr_pc != NULL) {\n\t\t/* ptr_curr_pc != NULL only when bytecode executor is active. */\n\t\tDUK_ASSERT(thr->callstack_top > 0);\n\t\tDUK_ASSERT(thr->callstack_curr != NULL);\n\t\tact = thr->callstack_curr;\n\t\tDUK_ASSERT(act != NULL);\n\t\tact->curr_pc = *thr->ptr_curr_pc;\n\t}\n}\n\nDUK_INTERNAL void duk_hthread_sync_and_null_currpc(duk_hthread *thr) {\n\tduk_activation *act;\n\n\tDUK_ASSERT(thr != NULL);\n\n\tif (thr->ptr_curr_pc != NULL) {\n\t\t/* ptr_curr_pc != NULL only when bytecode executor is active. */\n\t\tDUK_ASSERT(thr->callstack_top > 0);\n\t\tDUK_ASSERT(thr->callstack_curr != NULL);\n\t\tact = thr->callstack_curr;\n\t\tDUK_ASSERT(act != NULL);\n\t\tact->curr_pc = *thr->ptr_curr_pc;\n\t\tthr->ptr_curr_pc = NULL;\n\t}\n}\n/*\n *  Manipulation of thread stacks (valstack, callstack, catchstack).\n *\n *  Ideally unwinding of stacks should have no side effects, which would\n *  then favor separate unwinding and shrink check primitives for each\n *  stack type.  A shrink check may realloc and thus have side effects.\n *\n *  However, currently callstack unwinding itself has side effects, as it\n *  needs to DECREF multiple objects, close environment records, etc.\n *  Stacks must thus be unwound in the correct order by the caller.\n *\n *  (XXX: This should be probably reworked so that there is a shared\n *  unwind primitive which handles all stacks as requested, and knows\n *  the proper order for unwinding.)\n *\n *  Valstack entries above 'top' are always kept initialized to\n *  \"undefined unused\".  Callstack and catchstack entries above 'top'\n *  are not zeroed and are left as garbage.\n *\n *  Value stack handling is mostly a part of the API implementation.\n */\n\n/* #include duk_internal.h -> already included */\n\nDUK_LOCAL DUK_COLD DUK_NOINLINE void duk__hthread_do_callstack_grow(duk_hthread *thr) {\n\tduk_activation *new_ptr;\n\tduk_size_t old_size;\n\tduk_size_t new_size;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT_DISABLE(thr->callstack_top >= 0);   /* avoid warning (unsigned) */\n\tDUK_ASSERT(thr->callstack_size >= thr->callstack_top);\n\n\told_size = thr->callstack_size;\n\tnew_size = old_size + DUK_CALLSTACK_GROW_STEP;\n\n\t/* this is a bit approximate (errors out before max is reached); this is OK */\n\tif (new_size >= thr->callstack_max) {\n\t\tDUK_ERROR_RANGE(thr, DUK_STR_CALLSTACK_LIMIT);\n\t}\n\n\tDUK_DD(DUK_DDPRINT(\"growing callstack %ld -> %ld\", (long) old_size, (long) new_size));\n\n\t/*\n\t *  Note: must use indirect variant of DUK_REALLOC() because underlying\n\t *  pointer may be changed by mark-and-sweep.\n\t */\n\n\tDUK_ASSERT(new_size > 0);\n\tnew_ptr = (duk_activation *) DUK_REALLOC_INDIRECT(thr->heap, duk_hthread_get_callstack_ptr, (void *) thr, sizeof(duk_activation) * new_size);\n\tif (!new_ptr) {\n\t\t/* No need for a NULL/zero-size check because new_size > 0) */\n\t\tDUK_ERROR_ALLOC_FAILED(thr);\n\t}\n\tthr->callstack = new_ptr;\n\tthr->callstack_size = new_size;\n\n\tif (thr->callstack_top > 0) {\n\t\tthr->callstack_curr = thr->callstack + thr->callstack_top - 1;\n\t} else {\n\t\tthr->callstack_curr = NULL;\n\t}\n\n\t/* note: any entries above the callstack top are garbage and not zeroed */\n}\n\n/* check that there is space for at least one new entry */\nDUK_INTERNAL void duk_hthread_callstack_grow(duk_hthread *thr) {\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT_DISABLE(thr->callstack_top >= 0);   /* avoid warning (unsigned) */\n\tDUK_ASSERT(thr->callstack_size >= thr->callstack_top);\n\n\tif (DUK_LIKELY(thr->callstack_top < thr->callstack_size)) {\n\t\treturn;\n\t}\n\tduk__hthread_do_callstack_grow(thr);\n}\n\nDUK_LOCAL DUK_COLD DUK_NOINLINE void duk__hthread_do_callstack_shrink(duk_hthread *thr) {\n\tduk_size_t new_size;\n\tduk_activation *p;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT_DISABLE(thr->callstack_top >= 0);  /* avoid warning (unsigned) */\n\tDUK_ASSERT(thr->callstack_size >= thr->callstack_top);\n\n\tnew_size = thr->callstack_top + DUK_CALLSTACK_SHRINK_SPARE;\n\tDUK_ASSERT(new_size >= thr->callstack_top);\n\n\tDUK_DD(DUK_DDPRINT(\"shrinking callstack %ld -> %ld\", (long) thr->callstack_size, (long) new_size));\n\n\t/*\n\t *  Note: must use indirect variant of DUK_REALLOC() because underlying\n\t *  pointer may be changed by mark-and-sweep.\n\t */\n\n\t/* shrink failure is not fatal */\n\tp = (duk_activation *) DUK_REALLOC_INDIRECT(thr->heap, duk_hthread_get_callstack_ptr, (void *) thr, sizeof(duk_activation) * new_size);\n\tif (p) {\n\t\tthr->callstack = p;\n\t\tthr->callstack_size = new_size;\n\n\t\tif (thr->callstack_top > 0) {\n\t\t\tthr->callstack_curr = thr->callstack + thr->callstack_top - 1;\n\t\t} else {\n\t\t\tthr->callstack_curr = NULL;\n\t\t}\n\t} else {\n\t\t/* Because new_size != 0, if condition doesn't need to be\n\t\t * (p != NULL || new_size == 0).\n\t\t */\n\t\tDUK_ASSERT(new_size != 0);\n\t\tDUK_D(DUK_DPRINT(\"callstack shrink failed, ignoring\"));\n\t}\n\n\t/* note: any entries above the callstack top are garbage and not zeroed */\n}\n\nDUK_INTERNAL void duk_hthread_callstack_shrink_check(duk_hthread *thr) {\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT_DISABLE(thr->callstack_top >= 0);  /* avoid warning (unsigned) */\n\tDUK_ASSERT(thr->callstack_size >= thr->callstack_top);\n\n\tif (DUK_LIKELY(thr->callstack_size - thr->callstack_top < DUK_CALLSTACK_SHRINK_THRESHOLD)) {\n\t\treturn;\n\t}\n\n\tduk__hthread_do_callstack_shrink(thr);\n}\n\nDUK_INTERNAL void duk_hthread_callstack_unwind_norz(duk_hthread *thr, duk_size_t new_top) {\n\tduk_size_t idx;\n\n\tDUK_DDD(DUK_DDDPRINT(\"unwind callstack top of thread %p from %ld to %ld\",\n\t                     (void *) thr,\n\t                     (thr != NULL ? (long) thr->callstack_top : (long) -1),\n\t                     (long) new_top));\n\n\tDUK_ASSERT(thr);\n\tDUK_ASSERT(thr->heap);\n\tDUK_ASSERT_DISABLE(new_top >= 0);  /* unsigned */\n\tDUK_ASSERT((duk_size_t) new_top <= thr->callstack_top);  /* cannot grow */\n\n\t/*\n\t *  The loop below must avoid issues with potential callstack\n\t *  reallocations.  A resize (and other side effects) may happen\n\t *  e.g. due to finalizer/errhandler calls caused by a refzero or\n\t *  mark-and-sweep.  Arbitrary finalizers may run, because when\n\t *  an environment record is refzero'd, it may refer to arbitrary\n\t *  values which also become refzero'd.\n\t *\n\t *  So, the pointer 'p' is re-looked-up below whenever a side effect\n\t *  might have changed it.\n\t */\n\n\tidx = thr->callstack_top;\n\twhile (idx > new_top) {\n\t\tduk_activation *act;\n\t\tduk_hobject *func;\n\t\tduk_hobject *tmp;\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\t\tduk_heap *heap;\n#endif\n\n\t\tidx--;\n\t\tDUK_ASSERT_DISABLE(idx >= 0);  /* unsigned */\n\t\tDUK_ASSERT((duk_size_t) idx < thr->callstack_size);  /* true, despite side effect resizes */\n\n\t\tact = thr->callstack + idx;\n\t\t/* With lightfuncs, act 'func' may be NULL */\n\n#if defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)\n\t\t/*\n\t\t *  Restore 'caller' property for non-strict callee functions.\n\t\t */\n\n\t\tfunc = DUK_ACT_GET_FUNC(act);\n\t\tif (func != NULL && !DUK_HOBJECT_HAS_STRICT(func)) {\n\t\t\tduk_tval *tv_caller;\n\t\t\tduk_tval tv_tmp;\n\t\t\tduk_hobject *h_tmp;\n\n\t\t\ttv_caller = duk_hobject_find_existing_entry_tval_ptr(thr->heap, func, DUK_HTHREAD_STRING_CALLER(thr));\n\n\t\t\t/* The act->prev_caller should only be set if the entry for 'caller'\n\t\t\t * exists (as it is only set in that case, and the property is not\n\t\t\t * configurable), but handle all the cases anyway.\n\t\t\t */\n\n\t\t\tif (tv_caller) {\n\t\t\t\tDUK_TVAL_SET_TVAL(&tv_tmp, tv_caller);\n\t\t\t\tif (act->prev_caller) {\n\t\t\t\t\t/* Just transfer the refcount from act->prev_caller to tv_caller,\n\t\t\t\t\t * so no need for a refcount update.  This is the expected case.\n\t\t\t\t\t */\n\t\t\t\t\tDUK_TVAL_SET_OBJECT(tv_caller, act->prev_caller);\n\t\t\t\t\tact->prev_caller = NULL;\n\t\t\t\t} else {\n\t\t\t\t\tDUK_TVAL_SET_NULL(tv_caller);   /* no incref needed */\n\t\t\t\t\tDUK_ASSERT(act->prev_caller == NULL);\n\t\t\t\t}\n\t\t\t\tDUK_TVAL_DECREF_NORZ(thr, &tv_tmp);\n\t\t\t} else {\n\t\t\t\th_tmp = act->prev_caller;\n\t\t\t\tif (h_tmp) {\n\t\t\t\t\tact->prev_caller = NULL;\n\t\t\t\t\tDUK_HOBJECT_DECREF_NORZ(thr, h_tmp);\n\t\t\t\t}\n\t\t\t}\n\t\t\tact = thr->callstack + idx;  /* avoid side effects */\n\t\t\tDUK_ASSERT(act->prev_caller == NULL);\n\t\t}\n#endif\n\n\t\t/*\n\t\t *  Unwind debugger state.  If we unwind while stepping\n\t\t *  (either step over or step into), pause execution.\n\t\t */\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\t\theap = thr->heap;\n\t\tif (heap->dbg_step_thread == thr &&\n\t\t    heap->dbg_step_csindex == idx) {\n\t\t\t/* Pause for all step types: step into, step over, step out.\n\t\t\t * This is the only place explicitly handling a step out.\n\t\t\t */\n\t\t\tif (duk_debug_is_paused(heap)) {\n\t\t\t\tDUK_D(DUK_DPRINT(\"step pause trigger but already paused, ignoring\"));\n\t\t\t} else {\n\t\t\t\tduk_debug_set_paused(heap);\n\t\t\t\tDUK_ASSERT(heap->dbg_step_thread == NULL);\n\t\t\t}\n\t\t}\n#endif\n\n\t\t/*\n\t\t *  Close environment record(s) if they exist.\n\t\t *\n\t\t *  Only variable environments are closed.  If lex_env != var_env, it\n\t\t *  cannot currently contain any register bound declarations.\n\t\t *\n\t\t *  Only environments created for a NEWENV function are closed.  If an\n\t\t *  environment is created for e.g. an eval call, it must not be closed.\n\t\t */\n\n\t\tfunc = DUK_ACT_GET_FUNC(act);\n\t\tif (func != NULL && !DUK_HOBJECT_HAS_NEWENV(func)) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"skip closing environments, envs not owned by this activation\"));\n\t\t\tgoto skip_env_close;\n\t\t}\n\t\t/* func is NULL for lightfunc */\n\n\t\t/* Catch sites are required to clean up their environments\n\t\t * in FINALLY part before propagating, so this should\n\t\t * always hold here.\n\t\t */\n\t\tDUK_ASSERT(act->lex_env == act->var_env);\n\n\t\tif (act->var_env != NULL) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"closing var_env record %p -> %!O\",\n\t\t\t                     (void *) act->var_env, (duk_heaphdr *) act->var_env));\n\t\t\tduk_js_close_environment_record(thr, act->var_env);\n\t\t\tact = thr->callstack + idx;  /* avoid side effect issues */\n\t\t}\n\n\t skip_env_close:\n\n\t\t/*\n\t\t *  Update preventcount\n\t\t */\n\n\t\tif (act->flags & DUK_ACT_FLAG_PREVENT_YIELD) {\n\t\t\tDUK_ASSERT(thr->callstack_preventcount >= 1);\n\t\t\tthr->callstack_preventcount--;\n\t\t}\n\n\t\t/*\n\t\t *  Reference count updates, using NORZ macros so we don't\n\t\t *  need to handle side effects.\n\t\t */\n\n\t\tDUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr, act->var_env);\n\t\tact->var_env = NULL;\n\t\tDUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr, act->lex_env);\n\t\tact->lex_env = NULL;\n\n\t\t/* Note: this may cause a corner case situation where a finalizer\n\t\t * may see a currently reachable activation whose 'func' is NULL.\n\t\t */\n\t\ttmp = DUK_ACT_GET_FUNC(act);\n\t\tDUK_HOBJECT_DECREF_NORZ_ALLOWNULL(thr, tmp);\n\t\tDUK_UNREF(tmp);\n\t\tact->func = NULL;\n\t}\n\n\tthr->callstack_top = new_top;\n\tif (new_top > 0) {\n\t\tthr->callstack_curr = thr->callstack + new_top - 1;\n\t} else {\n\t\tthr->callstack_curr = NULL;\n\t}\n\n\t/*\n\t *  We could clear the book-keeping variables for the topmost activation,\n\t *  but don't do so now.\n\t */\n#if 0\n\tif (thr->callstack_curr != NULL) {\n\t\tduk_activation *act = thr->callstack_curr;\n\t\tact->idx_retval = 0;\n\t}\n#endif\n\n\t/* Note: any entries above the callstack top are garbage and not zeroed.\n\t * Also topmost activation idx_retval is garbage (not zeroed), and must\n\t * be ignored.\n\t */\n}\n\nDUK_INTERNAL void duk_hthread_callstack_unwind(duk_hthread *thr, duk_size_t new_top) {\n\tduk_hthread_callstack_unwind_norz(thr, new_top);\n\tDUK_REFZERO_CHECK_FAST(thr);\n}\n\nDUK_LOCAL DUK_COLD DUK_NOINLINE void duk__hthread_do_catchstack_grow(duk_hthread *thr) {\n\tduk_catcher *new_ptr;\n\tduk_size_t old_size;\n\tduk_size_t new_size;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT_DISABLE(thr->catchstack_top);  /* avoid warning (unsigned) */\n\tDUK_ASSERT(thr->catchstack_size >= thr->catchstack_top);\n\n\told_size = thr->catchstack_size;\n\tnew_size = old_size + DUK_CATCHSTACK_GROW_STEP;\n\n\t/* this is a bit approximate (errors out before max is reached); this is OK */\n\tif (new_size >= thr->catchstack_max) {\n\t\tDUK_ERROR_RANGE(thr, DUK_STR_CATCHSTACK_LIMIT);\n\t}\n\n\tDUK_DD(DUK_DDPRINT(\"growing catchstack %ld -> %ld\", (long) old_size, (long) new_size));\n\n\t/*\n\t *  Note: must use indirect variant of DUK_REALLOC() because underlying\n\t *  pointer may be changed by mark-and-sweep.\n\t */\n\n\tDUK_ASSERT(new_size > 0);\n\tnew_ptr = (duk_catcher *) DUK_REALLOC_INDIRECT(thr->heap, duk_hthread_get_catchstack_ptr, (void *) thr, sizeof(duk_catcher) * new_size);\n\tif (!new_ptr) {\n\t\t/* No need for a NULL/zero-size check because new_size > 0) */\n\t\tDUK_ERROR_ALLOC_FAILED(thr);\n\t}\n\tthr->catchstack = new_ptr;\n\tthr->catchstack_size = new_size;\n\n\t/* note: any entries above the catchstack top are garbage and not zeroed */\n}\n\nDUK_INTERNAL void duk_hthread_catchstack_grow(duk_hthread *thr) {\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT_DISABLE(thr->catchstack_top);  /* avoid warning (unsigned) */\n\tDUK_ASSERT(thr->catchstack_size >= thr->catchstack_top);\n\n\tif (DUK_LIKELY(thr->catchstack_top < thr->catchstack_size)) {\n\t\treturn;\n\t}\n\n\tduk__hthread_do_catchstack_grow(thr);\n}\n\nDUK_LOCAL DUK_COLD DUK_NOINLINE void duk__hthread_do_catchstack_shrink(duk_hthread *thr) {\n\tduk_size_t new_size;\n\tduk_catcher *p;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT_DISABLE(thr->catchstack_top >= 0);  /* avoid warning (unsigned) */\n\tDUK_ASSERT(thr->catchstack_size >= thr->catchstack_top);\n\n\tnew_size = thr->catchstack_top + DUK_CATCHSTACK_SHRINK_SPARE;\n\tDUK_ASSERT(new_size >= thr->catchstack_top);\n\n\tDUK_DD(DUK_DDPRINT(\"shrinking catchstack %ld -> %ld\", (long) thr->catchstack_size, (long) new_size));\n\n\t/*\n\t *  Note: must use indirect variant of DUK_REALLOC() because underlying\n\t *  pointer may be changed by mark-and-sweep.\n\t */\n\n\t/* shrink failure is not fatal */\n\tp = (duk_catcher *) DUK_REALLOC_INDIRECT(thr->heap, duk_hthread_get_catchstack_ptr, (void *) thr, sizeof(duk_catcher) * new_size);\n\tif (p) {\n\t\tthr->catchstack = p;\n\t\tthr->catchstack_size = new_size;\n\t} else {\n\t\t/* Because new_size != 0, if condition doesn't need to be\n\t\t * (p != NULL || new_size == 0).\n\t\t */\n\t\tDUK_ASSERT(new_size != 0);\n\t\tDUK_D(DUK_DPRINT(\"catchstack shrink failed, ignoring\"));\n\t}\n\n\t/* note: any entries above the catchstack top are garbage and not zeroed */\n}\n\nDUK_INTERNAL void duk_hthread_catchstack_shrink_check(duk_hthread *thr) {\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT_DISABLE(thr->catchstack_top >= 0);  /* avoid warning (unsigned) */\n\tDUK_ASSERT(thr->catchstack_size >= thr->catchstack_top);\n\n\tif (DUK_LIKELY(thr->catchstack_size - thr->catchstack_top < DUK_CATCHSTACK_SHRINK_THRESHOLD)) {\n\t\treturn;\n\t}\n\n\tduk__hthread_do_catchstack_shrink(thr);\n}\n\nDUK_INTERNAL void duk_hthread_catchstack_unwind_norz(duk_hthread *thr, duk_size_t new_top) {\n\tduk_size_t idx;\n\n\tDUK_DDD(DUK_DDDPRINT(\"unwind catchstack top of thread %p from %ld to %ld\",\n\t                     (void *) thr,\n\t                     (thr != NULL ? (long) thr->catchstack_top : (long) -1),\n\t                     (long) new_top));\n\n\tDUK_ASSERT(thr);\n\tDUK_ASSERT(thr->heap);\n\tDUK_ASSERT_DISABLE(new_top >= 0);  /* unsigned */\n\tDUK_ASSERT((duk_size_t) new_top <= thr->catchstack_top);  /* cannot grow */\n\n\t/*\n\t *  Since there are no references in the catcher structure,\n\t *  unwinding is quite simple.  The only thing we need to\n\t *  look out for is popping a possible lexical environment\n\t *  established for an active catch clause.\n\t */\n\n\tidx = thr->catchstack_top;\n\twhile (idx > new_top) {\n\t\tduk_catcher *p;\n\t\tduk_activation *act;\n\t\tduk_hobject *env;\n\n\t\tidx--;\n\t\tDUK_ASSERT_DISABLE(idx >= 0);  /* unsigned */\n\t\tDUK_ASSERT((duk_size_t) idx < thr->catchstack_size);\n\n\t\tp = thr->catchstack + idx;\n\n\t\tif (DUK_CAT_HAS_LEXENV_ACTIVE(p)) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"unwinding catchstack idx %ld, callstack idx %ld, callstack top %ld: lexical environment active\",\n\t\t\t                     (long) idx, (long) p->callstack_index, (long) thr->callstack_top));\n\n\t\t\t/* XXX: Here we have a nasty dependency: the need to manipulate\n\t\t\t * the callstack means that catchstack must always be unwound by\n\t\t\t * the caller before unwinding the callstack.  This should be fixed\n\t\t\t * later.\n\t\t\t */\n\n\t\t\t/* Note that multiple catchstack entries may refer to the same\n\t\t\t * callstack entry.\n\t\t\t */\n\t\t\tact = thr->callstack + p->callstack_index;\n\t\t\tDUK_ASSERT(act >= thr->callstack);\n\t\t\tDUK_ASSERT(act < thr->callstack + thr->callstack_top);\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"catchstack_index=%ld, callstack_index=%ld, lex_env=%!iO\",\n\t\t\t                     (long) idx, (long) p->callstack_index,\n\t\t\t                     (duk_heaphdr *) act->lex_env));\n\n\t\t\tenv = act->lex_env;             /* current lex_env of the activation (created for catcher) */\n\t\t\tDUK_ASSERT(env != NULL);        /* must be, since env was created when catcher was created */\n\t\t\tact->lex_env = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, env);  /* prototype is lex_env before catcher created */\n\t\t\tDUK_HOBJECT_INCREF(thr, act->lex_env);\n\t\t\tDUK_HOBJECT_DECREF_NORZ(thr, env);\n\n\t\t\t/* There is no need to decref anything else than 'env': if 'env'\n\t\t\t * becomes unreachable, refzero will handle decref'ing its prototype.\n\t\t\t */\n\t\t}\n\t}\n\n\tthr->catchstack_top = new_top;\n\n\t/* note: any entries above the catchstack top are garbage and not zeroed */\n}\n\nDUK_INTERNAL void duk_hthread_catchstack_unwind(duk_hthread *thr, duk_size_t new_top) {\n\tduk_hthread_catchstack_unwind_norz(thr, new_top);\n\tDUK_REFZERO_CHECK_FAST(thr);\n}\n\n#if defined(DUK_USE_FINALIZER_TORTURE)\nDUK_INTERNAL void duk_hthread_valstack_torture_realloc(duk_hthread *thr) {\n\tduk_size_t alloc_size;\n\tduk_tval *new_ptr;\n\tduk_ptrdiff_t end_off;\n\tduk_ptrdiff_t bottom_off;\n\tduk_ptrdiff_t top_off;\n\n\tif (thr->valstack == NULL) {\n\t\treturn;\n\t}\n\n\tend_off = (duk_ptrdiff_t) ((duk_uint8_t *) thr->valstack_end - (duk_uint8_t *) thr->valstack);\n\tbottom_off = (duk_ptrdiff_t) ((duk_uint8_t *) thr->valstack_bottom - (duk_uint8_t *) thr->valstack);\n\ttop_off = (duk_ptrdiff_t) ((duk_uint8_t *) thr->valstack_top - (duk_uint8_t *) thr->valstack);\n\talloc_size = (duk_size_t) end_off;\n\tif (alloc_size == 0) {\n\t\treturn;\n\t}\n\n\tnew_ptr = (duk_tval *) DUK_ALLOC(thr->heap, alloc_size);\n\tif (new_ptr != NULL) {\n\t\tDUK_MEMCPY((void *) new_ptr, (const void *) thr->valstack, alloc_size);\n\t\tDUK_MEMSET((void *) thr->valstack, 0x55, alloc_size);\n\t\tDUK_FREE(thr->heap, (void *) thr->valstack);\n\t\tthr->valstack = new_ptr;\n\t\tthr->valstack_end = (duk_tval *) ((duk_uint8_t *) new_ptr + end_off);\n\t\tthr->valstack_bottom = (duk_tval *) ((duk_uint8_t *) new_ptr + bottom_off);\n\t\tthr->valstack_top = (duk_tval *) ((duk_uint8_t *) new_ptr + top_off);\n\t\t/* No change in size. */\n\t} else {\n\t\tDUK_D(DUK_DPRINT(\"failed to realloc valstack for torture, ignore\"));\n\t}\n}\n\nDUK_INTERNAL void duk_hthread_callstack_torture_realloc(duk_hthread *thr) {\n\tduk_size_t alloc_size;\n\tduk_activation *new_ptr;\n\tduk_ptrdiff_t curr_off;\n\n\tif (thr->callstack == NULL) {\n\t\treturn;\n\t}\n\n\tcurr_off = (duk_ptrdiff_t) ((duk_uint8_t *) thr->callstack_curr - (duk_uint8_t *) thr->callstack);\n\talloc_size = sizeof(duk_activation) * thr->callstack_size;\n\tif (alloc_size == 0) {\n\t\treturn;\n\t}\n\n\tnew_ptr = (duk_activation *) DUK_ALLOC(thr->heap, alloc_size);\n\tif (new_ptr != NULL) {\n\t\tDUK_MEMCPY((void *) new_ptr, (const void *) thr->callstack, alloc_size);\n\t\tDUK_MEMSET((void *) thr->callstack, 0x55, alloc_size);\n\t\tDUK_FREE(thr->heap, (void *) thr->callstack);\n\t\tthr->callstack = new_ptr;\n\t\tthr->callstack_curr = (duk_activation *) ((duk_uint8_t *) new_ptr + curr_off);\n\t\t/* No change in size. */\n\t} else {\n\t\tDUK_D(DUK_DPRINT(\"failed to realloc callstack for torture, ignore\"));\n\t}\n}\n\nDUK_INTERNAL void duk_hthread_catchstack_torture_realloc(duk_hthread *thr) {\n\tduk_size_t alloc_size;\n\tduk_catcher *new_ptr;\n\n\tif (thr->catchstack == NULL) {\n\t\treturn;\n\t}\n\n\talloc_size = sizeof(duk_catcher) * thr->catchstack_size;\n\tif (alloc_size == 0) {\n\t\treturn;\n\t}\n\n\tnew_ptr = (duk_catcher *) DUK_ALLOC(thr->heap, alloc_size);\n\tif (new_ptr != NULL) {\n\t\tDUK_MEMCPY((void *) new_ptr, (const void *) thr->catchstack, alloc_size);\n\t\tDUK_MEMSET((void *) thr->catchstack, 0x55, alloc_size);\n\t\tDUK_FREE(thr->heap, (void *) thr->catchstack);\n\t\tthr->catchstack = new_ptr;\n\t\t/* No change in size. */\n\t} else {\n\t\tDUK_D(DUK_DPRINT(\"failed to realloc catchstack for torture, ignore\"));\n\t}\n}\n#endif  /* DUK_USE_FINALIZER_TORTURE */\n/*\n *  Shared helpers for arithmetic operations\n */\n\n/* #include duk_internal.h -> already included */\n\n/* Ecmascript modulus ('%') does not match IEEE 754 \"remainder\" operation\n * (implemented by remainder() in C99) but does seem to match ANSI C fmod().\n * Compare E5 Section 11.5.3 and \"man fmod\".\n */\nDUK_INTERNAL double duk_js_arith_mod(double d1, double d2) {\n#if defined(DUK_USE_POW_WORKAROUNDS)\n\t/* Specific fixes to common fmod() implementation issues:\n\t * - test-bug-mingw-math-issues.js\n\t */\n\tif (DUK_ISINF(d2)) {\n\t\tif (DUK_ISINF(d1)) {\n\t\t\treturn DUK_DOUBLE_NAN;\n\t\t} else {\n\t\t\treturn d1;\n\t\t}\n\t} else if (d1 == 0.0) {\n\t\t/* d1 +/-0 is returned as is (preserving sign) except when\n\t\t * d2 is zero or NaN.\n\t\t */\n\t\tif (d2 == 0.0 || DUK_ISNAN(d2)) {\n\t\t\treturn DUK_DOUBLE_NAN;\n\t\t} else {\n\t\t\treturn d1;\n\t\t}\n\t}\n#else\n\t/* Some ISO C assumptions. */\n\tDUK_ASSERT(DUK_FMOD(1.0, DUK_DOUBLE_INFINITY) == 1.0);\n\tDUK_ASSERT(DUK_FMOD(-1.0, DUK_DOUBLE_INFINITY) == -1.0);\n\tDUK_ASSERT(DUK_FMOD(1.0, -DUK_DOUBLE_INFINITY) == 1.0);\n\tDUK_ASSERT(DUK_FMOD(-1.0, -DUK_DOUBLE_INFINITY) == -1.0);\n\tDUK_ASSERT(DUK_ISNAN(DUK_FMOD(DUK_DOUBLE_INFINITY, DUK_DOUBLE_INFINITY)));\n\tDUK_ASSERT(DUK_ISNAN(DUK_FMOD(DUK_DOUBLE_INFINITY, -DUK_DOUBLE_INFINITY)));\n\tDUK_ASSERT(DUK_ISNAN(DUK_FMOD(-DUK_DOUBLE_INFINITY, DUK_DOUBLE_INFINITY)));\n\tDUK_ASSERT(DUK_ISNAN(DUK_FMOD(-DUK_DOUBLE_INFINITY, -DUK_DOUBLE_INFINITY)));\n\tDUK_ASSERT(DUK_FMOD(0.0, 1.0) == 0.0 && DUK_SIGNBIT(DUK_FMOD(0.0, 1.0)) == 0);\n\tDUK_ASSERT(DUK_FMOD(-0.0, 1.0) == 0.0 && DUK_SIGNBIT(DUK_FMOD(-0.0, 1.0)) != 0);\n\tDUK_ASSERT(DUK_FMOD(0.0, DUK_DOUBLE_INFINITY) == 0.0 && DUK_SIGNBIT(DUK_FMOD(0.0, DUK_DOUBLE_INFINITY)) == 0);\n\tDUK_ASSERT(DUK_FMOD(-0.0, DUK_DOUBLE_INFINITY) == 0.0 && DUK_SIGNBIT(DUK_FMOD(-0.0, DUK_DOUBLE_INFINITY)) != 0);\n\tDUK_ASSERT(DUK_FMOD(0.0, -DUK_DOUBLE_INFINITY) == 0.0 && DUK_SIGNBIT(DUK_FMOD(0.0, DUK_DOUBLE_INFINITY)) == 0);\n\tDUK_ASSERT(DUK_FMOD(-0.0, -DUK_DOUBLE_INFINITY) == 0.0 && DUK_SIGNBIT(DUK_FMOD(-0.0, -DUK_DOUBLE_INFINITY)) != 0);\n\tDUK_ASSERT(DUK_ISNAN(DUK_FMOD(0.0, 0.0)));\n\tDUK_ASSERT(DUK_ISNAN(DUK_FMOD(-0.0, 0.0)));\n\tDUK_ASSERT(DUK_ISNAN(DUK_FMOD(0.0, -0.0)));\n\tDUK_ASSERT(DUK_ISNAN(DUK_FMOD(-0.0, -0.0)));\n\tDUK_ASSERT(DUK_ISNAN(DUK_FMOD(0.0, DUK_DOUBLE_NAN)));\n\tDUK_ASSERT(DUK_ISNAN(DUK_FMOD(-0.0, DUK_DOUBLE_NAN)));\n#endif\n\n\treturn (duk_double_t) DUK_FMOD((double) d1, (double) d2);\n}\n\n/* Shared helper for Math.pow() and exponentiation operator. */\nDUK_INTERNAL double duk_js_arith_pow(double x, double y) {\n\t/* The ANSI C pow() semantics differ from Ecmascript.\n\t *\n\t * E.g. when x==1 and y is +/- infinite, the Ecmascript required\n\t * result is NaN, while at least Linux pow() returns 1.\n\t */\n\n\tduk_small_int_t cx, cy, sx;\n\n\tDUK_UNREF(cx);\n\tDUK_UNREF(sx);\n\tcy = (duk_small_int_t) DUK_FPCLASSIFY(y);\n\n\tif (cy == DUK_FP_NAN) {\n\t\tgoto ret_nan;\n\t}\n\tif (DUK_FABS(x) == 1.0 && cy == DUK_FP_INFINITE) {\n\t\tgoto ret_nan;\n\t}\n\n#if defined(DUK_USE_POW_WORKAROUNDS)\n\t/* Specific fixes to common pow() implementation issues:\n\t *   - test-bug-netbsd-math-pow.js: NetBSD 6.0 on x86 (at least)\n\t *   - test-bug-mingw-math-issues.js\n\t */\n\tcx = (duk_small_int_t) DUK_FPCLASSIFY(x);\n\tif (cx == DUK_FP_ZERO && y < 0.0) {\n\t\tsx = (duk_small_int_t) DUK_SIGNBIT(x);\n\t\tif (sx == 0) {\n\t\t\t/* Math.pow(+0,y) should be Infinity when y<0.  NetBSD pow()\n\t\t\t * returns -Infinity instead when y is <0 and finite.  The\n\t\t\t * if-clause also catches y == -Infinity (which works even\n\t\t\t * without the fix).\n\t\t\t */\n\t\t\treturn DUK_DOUBLE_INFINITY;\n\t\t} else {\n\t\t\t/* Math.pow(-0,y) where y<0 should be:\n\t\t\t *   - -Infinity if y<0 and an odd integer\n\t\t\t *   - Infinity if y<0 but not an odd integer\n\t\t\t * NetBSD pow() returns -Infinity for all finite y<0.  The\n\t\t\t * if-clause also catches y == -Infinity (which works even\n\t\t\t * without the fix).\n\t\t\t */\n\n\t\t\t/* fmod() return value has same sign as input (negative) so\n\t\t\t * the result here will be in the range ]-2,0], -1 indicates\n\t\t\t * odd.  If x is -Infinity, NaN is returned and the odd check\n\t\t\t * always concludes \"not odd\" which results in desired outcome.\n\t\t\t */\n\t\t\tdouble tmp = DUK_FMOD(y, 2);\n\t\t\tif (tmp == -1.0) {\n\t\t\t\treturn -DUK_DOUBLE_INFINITY;\n\t\t\t} else {\n\t\t\t\t/* Not odd, or y == -Infinity */\n\t\t\t\treturn DUK_DOUBLE_INFINITY;\n\t\t\t}\n\t\t}\n\t} else if (cx == DUK_FP_NAN) {\n\t\tif (y == 0.0) {\n\t\t\t/* NaN ** +/- 0 should always be 1, but is NaN on\n\t\t\t * at least some Cygwin/MinGW versions.\n\t\t\t */\n\t\t\treturn 1.0;\n\t\t}\n\t}\n#else\n\t/* Some ISO C assumptions. */\n\tDUK_ASSERT(DUK_POW(DUK_DOUBLE_NAN, 0.0) == 1.0);\n\tDUK_ASSERT(DUK_ISINF(DUK_POW(0.0, -1.0)) && DUK_SIGNBIT(DUK_POW(0.0, -1.0)) == 0);\n\tDUK_ASSERT(DUK_ISINF(DUK_POW(-0.0, -2.0)) && DUK_SIGNBIT(DUK_POW(-0.0, -2.0)) == 0);\n\tDUK_ASSERT(DUK_ISINF(DUK_POW(-0.0, -3.0)) && DUK_SIGNBIT(DUK_POW(-0.0, -3.0)) != 0);\n#endif\n\n\treturn DUK_POW(x, y);\n\n ret_nan:\n\treturn DUK_DOUBLE_NAN;\n}\n/*\n *  Call handling.\n *\n *  Main functions are:\n *\n *    - duk_handle_call_unprotected(): unprotected call to Ecmascript or\n *      Duktape/C function\n *    - duk_handle_call_protected(): protected call to Ecmascript or\n *      Duktape/C function\n *    - duk_handle_safe_call(): make a protected C call within current\n *      activation\n *    - duk_handle_ecma_call_setup(): Ecmascript-to-Ecmascript calls\n *      (not always possible), including tail calls and coroutine resume\n *\n *  See 'execution.rst'.\n *\n *  Note: setjmp() and local variables have a nasty interaction,\n *  see execution.rst; non-volatile locals modified after setjmp()\n *  call are not guaranteed to keep their value.\n */\n\n/* #include duk_internal.h -> already included */\n\n/* XXX: heap->error_not_allowed for success path too? */\n\n/*\n *  Forward declarations.\n */\n\nDUK_LOCAL void duk__handle_call_inner(duk_hthread *thr,\n                                      duk_idx_t num_stack_args,\n                                      duk_small_uint_t call_flags,\n                                      duk_idx_t idx_func);\nDUK_LOCAL void duk__handle_call_error(duk_hthread *thr,\n                                      duk_size_t entry_valstack_bottom_index,\n                                      duk_size_t entry_valstack_end,\n                                      duk_size_t entry_catchstack_top,\n                                      duk_size_t entry_callstack_top,\n                                      duk_int_t entry_call_recursion_depth,\n                                      duk_hthread *entry_curr_thread,\n                                      duk_uint_fast8_t entry_thread_state,\n                                      duk_instr_t **entry_ptr_curr_pc,\n                                      duk_idx_t idx_func,\n                                      duk_jmpbuf *old_jmpbuf_ptr);\nDUK_LOCAL void duk__handle_safe_call_inner(duk_hthread *thr,\n                                           duk_safe_call_function func,\n                                           void *udata,\n                                           duk_idx_t idx_retbase,\n                                           duk_idx_t num_stack_rets,\n                                           duk_size_t entry_valstack_bottom_index,\n                                           duk_size_t entry_callstack_top,\n                                           duk_size_t entry_catchstack_top);\nDUK_LOCAL void duk__handle_safe_call_error(duk_hthread *thr,\n                                           duk_idx_t idx_retbase,\n                                           duk_idx_t num_stack_rets,\n                                           duk_size_t entry_valstack_bottom_index,\n                                           duk_size_t entry_callstack_top,\n                                           duk_size_t entry_catchstack_top,\n                                           duk_jmpbuf *old_jmpbuf_ptr);\nDUK_LOCAL void duk__handle_safe_call_shared(duk_hthread *thr,\n                                            duk_idx_t idx_retbase,\n                                            duk_idx_t num_stack_rets,\n                                            duk_int_t entry_call_recursion_depth,\n                                            duk_hthread *entry_curr_thread,\n                                            duk_uint_fast8_t entry_thread_state,\n                                            duk_instr_t **entry_ptr_curr_pc);\n\n/*\n *  Interrupt counter fixup (for development only).\n */\n\n#if defined(DUK_USE_INTERRUPT_COUNTER) && defined(DUK_USE_DEBUG)\nDUK_LOCAL void duk__interrupt_fixup(duk_hthread *thr, duk_hthread *entry_curr_thread) {\n\t/* Currently the bytecode executor and executor interrupt\n\t * instruction counts are off because we don't execute the\n\t * interrupt handler when we're about to exit from the initial\n\t * user call into Duktape.\n\t *\n\t * If we were to execute the interrupt handler here, the counts\n\t * would match.  You can enable this block manually to check\n\t * that this is the case.\n\t */\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\n#if defined(DUK_USE_INTERRUPT_DEBUG_FIXUP)\n\tif (entry_curr_thread == NULL) {\n\t\tthr->interrupt_init = thr->interrupt_init - thr->interrupt_counter;\n\t\tthr->heap->inst_count_interrupt += thr->interrupt_init;\n\t\tDUK_DD(DUK_DDPRINT(\"debug test: updated interrupt count on exit to \"\n\t\t                   \"user code, instruction counts: executor=%ld, interrupt=%ld\",\n\t\t                   (long) thr->heap->inst_count_exec, (long) thr->heap->inst_count_interrupt));\n\t\tDUK_ASSERT(thr->heap->inst_count_exec == thr->heap->inst_count_interrupt);\n\t}\n#else\n\tDUK_UNREF(thr);\n\tDUK_UNREF(entry_curr_thread);\n#endif\n}\n#endif\n\n/*\n *  Arguments object creation.\n *\n *  Creating arguments objects involves many small details, see E5 Section\n *  10.6 for the specific requirements.  Much of the arguments object exotic\n *  behavior is implemented in duk_hobject_props.c, and is enabled by the\n *  object flag DUK_HOBJECT_FLAG_EXOTIC_ARGUMENTS.\n */\n\nDUK_LOCAL void duk__create_arguments_object(duk_hthread *thr,\n                                            duk_hobject *func,\n                                            duk_hobject *varenv,\n                                            duk_idx_t idx_argbase,        /* idx of first argument on stack */\n                                            duk_idx_t num_stack_args) {   /* num args starting from idx_argbase */\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hobject *arg;          /* 'arguments' */\n\tduk_hobject *formals;      /* formals for 'func' (may be NULL if func is a C function) */\n\tduk_idx_t i_arg;\n\tduk_idx_t i_map;\n\tduk_idx_t i_mappednames;\n\tduk_idx_t i_formals;\n\tduk_idx_t i_argbase;\n\tduk_idx_t n_formals;\n\tduk_idx_t idx;\n\tduk_bool_t need_map;\n\n\tDUK_DDD(DUK_DDDPRINT(\"creating arguments object for func=%!iO, varenv=%!iO, \"\n\t                     \"idx_argbase=%ld, num_stack_args=%ld\",\n\t                     (duk_heaphdr *) func, (duk_heaphdr *) varenv,\n\t                     (long) idx_argbase, (long) num_stack_args));\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(func != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_IS_NONBOUND_FUNCTION(func));\n\tDUK_ASSERT(varenv != NULL);\n\tDUK_ASSERT(idx_argbase >= 0);  /* assumed to bottom relative */\n\tDUK_ASSERT(num_stack_args >= 0);\n\n\tneed_map = 0;\n\n\ti_argbase = idx_argbase;\n\tDUK_ASSERT(i_argbase >= 0);\n\n\tduk_push_hobject(ctx, func);\n\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_INT_FORMALS);\n\tformals = duk_get_hobject(ctx, -1);\n\tif (formals) {\n\t\tn_formals = (duk_idx_t) duk_get_length(ctx, -1);\n\t} else {\n\t\t/* This shouldn't happen without tampering of internal\n\t\t * properties: if a function accesses 'arguments', _Formals\n\t\t * is kept.  Check for the case anyway in case internal\n\t\t * properties have been modified manually.\n\t\t */\n\t\tDUK_D(DUK_DPRINT(\"_Formals is undefined when creating arguments, use n_formals == 0\"));\n\t\tn_formals = 0;\n\t}\n\tduk_remove_m2(ctx);  /* leave formals on stack for later use */\n\ti_formals = duk_require_top_index(ctx);\n\n\tDUK_ASSERT(n_formals >= 0);\n\tDUK_ASSERT(formals != NULL || n_formals == 0);\n\n\tDUK_DDD(DUK_DDDPRINT(\"func=%!O, formals=%!O, n_formals=%ld\",\n\t                     (duk_heaphdr *) func, (duk_heaphdr *) formals,\n\t                     (long) n_formals));\n\n\t/* [ ... formals ] */\n\n\t/*\n\t *  Create required objects:\n\t *    - 'arguments' object: array-like, but not an array\n\t *    - 'map' object: internal object, tied to 'arguments'\n\t *    - 'mappedNames' object: temporary value used during construction\n\t */\n\n\targ = duk_push_object_helper(ctx,\n\t                             DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                             DUK_HOBJECT_FLAG_FASTREFS |\n\t                             DUK_HOBJECT_FLAG_ARRAY_PART |\n\t                             DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_ARGUMENTS),\n\t                             DUK_BIDX_OBJECT_PROTOTYPE);\n\tDUK_ASSERT(arg != NULL);\n\t(void) duk_push_object_helper(ctx,\n\t                              DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                              DUK_HOBJECT_FLAG_FASTREFS |\n\t                              DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_OBJECT),\n\t                              -1);  /* no prototype */\n\t(void) duk_push_object_helper(ctx,\n\t                              DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                              DUK_HOBJECT_FLAG_FASTREFS |\n\t                              DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_OBJECT),\n\t                              -1);  /* no prototype */\n\ti_arg = duk_get_top(ctx) - 3;\n\ti_map = i_arg + 1;\n\ti_mappednames = i_arg + 2;\n\n\t/* [ ... formals arguments map mappedNames ] */\n\n\tDUK_DDD(DUK_DDDPRINT(\"created arguments related objects: \"\n\t                     \"arguments at index %ld -> %!O \"\n\t                     \"map at index %ld -> %!O \"\n\t                     \"mappednames at index %ld -> %!O\",\n\t                     (long) i_arg, (duk_heaphdr *) duk_get_hobject(ctx, i_arg),\n\t                     (long) i_map, (duk_heaphdr *) duk_get_hobject(ctx, i_map),\n\t                     (long) i_mappednames, (duk_heaphdr *) duk_get_hobject(ctx, i_mappednames)));\n\n\t/*\n\t *  Init arguments properties, map, etc.\n\t */\n\n\tduk_push_int(ctx, num_stack_args);\n\tduk_xdef_prop_stridx(ctx, i_arg, DUK_STRIDX_LENGTH, DUK_PROPDESC_FLAGS_WC);\n\n\t/*\n\t *  Init argument related properties\n\t */\n\n\t/* step 11 */\n\tidx = num_stack_args - 1;\n\twhile (idx >= 0) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"arg idx %ld, argbase=%ld, argidx=%ld\",\n\t\t                     (long) idx, (long) i_argbase, (long) (i_argbase + idx)));\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"define arguments[%ld]=arg\", (long) idx));\n\t\tduk_dup(ctx, i_argbase + idx);\n\t\tduk_xdef_prop_index_wec(ctx, i_arg, (duk_uarridx_t) idx);\n\t\tDUK_DDD(DUK_DDDPRINT(\"defined arguments[%ld]=arg\", (long) idx));\n\n\t\t/* step 11.c is relevant only if non-strict (checked in 11.c.ii) */\n\t\tif (!DUK_HOBJECT_HAS_STRICT(func) && idx < n_formals) {\n\t\t\tDUK_ASSERT(formals != NULL);\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"strict function, index within formals (%ld < %ld)\",\n\t\t\t                     (long) idx, (long) n_formals));\n\n\t\t\tduk_get_prop_index(ctx, i_formals, idx);\n\t\t\tDUK_ASSERT(duk_is_string(ctx, -1));\n\n\t\t\tduk_dup_top(ctx);  /* [ ... name name ] */\n\n\t\t\tif (!duk_has_prop(ctx, i_mappednames)) {\n\t\t\t\t/* steps 11.c.ii.1 - 11.c.ii.4, but our internal book-keeping\n\t\t\t\t * differs from the reference model\n\t\t\t\t */\n\n\t\t\t\t/* [ ... name ] */\n\n\t\t\t\tneed_map = 1;\n\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"set mappednames[%s]=%ld\",\n\t\t\t\t                     (const char *) duk_get_string(ctx, -1),\n\t\t\t\t                     (long) idx));\n\t\t\t\tduk_dup_top(ctx);                      /* name */\n\t\t\t\t(void) duk_push_uint_to_hstring(ctx, (duk_uint_t) idx);  /* index */\n\t\t\t\tduk_xdef_prop_wec(ctx, i_mappednames);  /* out of spec, must be configurable */\n\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"set map[%ld]=%s\",\n\t\t\t\t                     (long) idx,\n\t\t\t\t                     duk_get_string(ctx, -1)));\n\t\t\t\tduk_dup_top(ctx);         /* name */\n\t\t\t\tduk_xdef_prop_index_wec(ctx, i_map, (duk_uarridx_t) idx);  /* out of spec, must be configurable */\n\t\t\t} else {\n\t\t\t\t/* duk_has_prop() popped the second 'name' */\n\t\t\t}\n\n\t\t\t/* [ ... name ] */\n\t\t\tduk_pop(ctx);  /* pop 'name' */\n\t\t}\n\n\t\tidx--;\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"actual arguments processed\"));\n\n\t/* step 12 */\n\tif (need_map) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"adding 'map' and 'varenv' to arguments object\"));\n\n\t\t/* should never happen for a strict callee */\n\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_STRICT(func));\n\n\t\tduk_dup(ctx, i_map);\n\t\tduk_xdef_prop_stridx(ctx, i_arg, DUK_STRIDX_INT_MAP, DUK_PROPDESC_FLAGS_NONE);  /* out of spec, don't care */\n\n\t\t/* The variable environment for magic variable bindings needs to be\n\t\t * given by the caller and recorded in the arguments object.\n\t\t *\n\t\t * See E5 Section 10.6, the creation of setters/getters.\n\t\t *\n\t\t * The variable environment also provides access to the callee, so\n\t\t * an explicit (internal) callee property is not needed.\n\t\t */\n\n\t\tduk_push_hobject(ctx, varenv);\n\t\tduk_xdef_prop_stridx(ctx, i_arg, DUK_STRIDX_INT_VARENV, DUK_PROPDESC_FLAGS_NONE);  /* out of spec, don't care */\n\t}\n\n\t/* steps 13-14 */\n\tif (DUK_HOBJECT_HAS_STRICT(func)) {\n\t\t/* Callee/caller are throwers and are not deletable etc.  They\n\t\t * could be implemented as virtual properties, but currently\n\t\t * there is no support for virtual properties which are accessors\n\t\t * (only plain virtual properties).  This would not be difficult\n\t\t * to change in duk_hobject_props, but we can make the throwers\n\t\t * normal, concrete properties just as easily.\n\t\t *\n\t\t * Note that the specification requires that the *same* thrower\n\t\t * built-in object is used here!  See E5 Section 10.6 main\n\t\t * algoritm, step 14, and Section 13.2.3 which describes the\n\t\t * thrower.  See test case test-arguments-throwers.js.\n\t\t */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"strict function, setting caller/callee to throwers\"));\n\n\t\tduk_xdef_prop_stridx_thrower(ctx, i_arg, DUK_STRIDX_CALLER);\n\t\tduk_xdef_prop_stridx_thrower(ctx, i_arg, DUK_STRIDX_CALLEE);\n\t} else {\n\t\tDUK_DDD(DUK_DDDPRINT(\"non-strict function, setting callee to actual value\"));\n\t\tduk_push_hobject(ctx, func);\n\t\tduk_xdef_prop_stridx(ctx, i_arg, DUK_STRIDX_CALLEE, DUK_PROPDESC_FLAGS_WC);\n\t}\n\n\t/* set exotic behavior only after we're done */\n\tif (need_map) {\n\t\t/* Exotic behaviors are only enabled for arguments objects\n\t\t * which have a parameter map (see E5 Section 10.6 main\n\t\t * algorithm, step 12).\n\t\t *\n\t\t * In particular, a non-strict arguments object with no\n\t\t * mapped formals does *NOT* get exotic behavior, even\n\t\t * for e.g. \"caller\" property.  This seems counterintuitive\n\t\t * but seems to be the case.\n\t\t */\n\n\t\t/* cannot be strict (never mapped variables) */\n\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_STRICT(func));\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"enabling exotic behavior for arguments object\"));\n\t\tDUK_HOBJECT_SET_EXOTIC_ARGUMENTS(arg);\n\t} else {\n\t\tDUK_DDD(DUK_DDDPRINT(\"not enabling exotic behavior for arguments object\"));\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"final arguments related objects: \"\n\t                     \"arguments at index %ld -> %!O \"\n\t                     \"map at index %ld -> %!O \"\n\t                     \"mappednames at index %ld -> %!O\",\n\t                     (long) i_arg, (duk_heaphdr *) duk_get_hobject(ctx, i_arg),\n\t                     (long) i_map, (duk_heaphdr *) duk_get_hobject(ctx, i_map),\n\t                     (long) i_mappednames, (duk_heaphdr *) duk_get_hobject(ctx, i_mappednames)));\n\n\t/* [ args(n) [crud] formals arguments map mappednames ] */\n\n\tduk_pop_2(ctx);\n\tduk_remove_m2(ctx);\n\n\t/* [ args [crud] arguments ] */\n}\n\n/* Helper for creating the arguments object and adding it to the env record\n * on top of the value stack.  This helper has a very strict dependency on\n * the shape of the input stack.\n */\nDUK_LOCAL void duk__handle_createargs_for_call(duk_hthread *thr,\n                                               duk_hobject *func,\n                                               duk_hobject *env,\n                                               duk_idx_t num_stack_args) {\n\tduk_context *ctx = (duk_context *) thr;\n\n\tDUK_DDD(DUK_DDDPRINT(\"creating arguments object for function call\"));\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(func != NULL);\n\tDUK_ASSERT(env != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_HAS_CREATEARGS(func));\n\tDUK_ASSERT(duk_get_top(ctx) >= num_stack_args + 1);\n\n\t/* [ ... arg1 ... argN envobj ] */\n\n\tduk__create_arguments_object(thr,\n\t                             func,\n\t                             env,\n\t                             duk_get_top(ctx) - num_stack_args - 1,    /* idx_argbase */\n\t                             num_stack_args);\n\n\t/* [ ... arg1 ... argN envobj argobj ] */\n\n\tduk_xdef_prop_stridx_short(ctx,\n\t                           -2,\n\t                           DUK_STRIDX_LC_ARGUMENTS,\n\t                           DUK_HOBJECT_HAS_STRICT(func) ? DUK_PROPDESC_FLAGS_E :   /* strict: non-deletable, non-writable */\n\t                                                          DUK_PROPDESC_FLAGS_WE);  /* non-strict: non-deletable, writable */\n\t/* [ ... arg1 ... argN envobj ] */\n}\n\n/*\n *  Helper for handling a \"bound function\" chain when a call is being made.\n *\n *  Follows the bound function chain until a non-bound function is found.\n *  Prepends the bound arguments to the value stack (at idx_func + 2),\n *  updating 'num_stack_args' in the process.  The 'this' binding is also\n *  updated if necessary (at idx_func + 1).  Note that for constructor calls\n *  the 'this' binding is never updated by [[BoundThis]].\n *\n *  XXX: bound function chains could be collapsed at bound function creation\n *  time so that each bound function would point directly to a non-bound\n *  function.  This would make call time handling much easier.\n */\n\nDUK_LOCAL void duk__handle_bound_chain_for_call(duk_hthread *thr,\n                                                duk_idx_t idx_func,\n                                                duk_idx_t *p_num_stack_args,   /* may be changed by call */\n                                                duk_bool_t is_constructor_call) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_idx_t num_stack_args;\n\tduk_tval *tv_func;\n\tduk_hobject *func;\n\tduk_uint_t sanity;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(p_num_stack_args != NULL);\n\n\t/* On entry, item at idx_func is a bound, non-lightweight function,\n\t * but we don't rely on that below.\n\t */\n\n\tnum_stack_args = *p_num_stack_args;\n\n\tsanity = DUK_HOBJECT_BOUND_CHAIN_SANITY;\n\tdo {\n\t\tduk_idx_t i, len;\n\n\t\ttv_func = duk_require_tval(ctx, idx_func);\n\t\tDUK_ASSERT(tv_func != NULL);\n\n\t\tif (DUK_TVAL_IS_LIGHTFUNC(tv_func)) {\n\t\t\t/* Lightweight function: never bound, so terminate. */\n\t\t\tbreak;\n\t\t} else if (DUK_TVAL_IS_OBJECT(tv_func)) {\n\t\t\tfunc = DUK_TVAL_GET_OBJECT(tv_func);\n\t\t\tif (!DUK_HOBJECT_HAS_BOUNDFUNC(func)) {\n\t\t\t\t/* Normal non-bound function. */\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else {\n\t\t\t/* Function.prototype.bind() should never let this happen,\n\t\t\t * ugly error message is enough.\n\t\t\t */\n\t\t\tDUK_ERROR_INTERNAL(thr);\n\t\t}\n\t\tDUK_ASSERT(DUK_TVAL_GET_OBJECT(tv_func) != NULL);\n\n\t\t/* XXX: this could be more compact by accessing the internal properties\n\t\t * directly as own properties (they cannot be inherited, and are not\n\t\t * externally visible).\n\t\t */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"bound function encountered, ptr=%p, num_stack_args=%ld: %!T\",\n\t\t                     (void *) DUK_TVAL_GET_OBJECT(tv_func), (long) num_stack_args, tv_func));\n\n\t\t/* [ ... func this arg1 ... argN ] */\n\n\t\tif (is_constructor_call) {\n\t\t\t/* See: tests/ecmascript/test-spec-bound-constructor.js */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"constructor call: don't update this binding\"));\n\t\t} else {\n\t\t\tduk_get_prop_stridx(ctx, idx_func, DUK_STRIDX_INT_THIS);\n\t\t\tduk_replace(ctx, idx_func + 1);  /* idx_this = idx_func + 1 */\n\t\t}\n\n\t\t/* [ ... func this arg1 ... argN ] */\n\n\t\t/* XXX: duk_get_length? */\n\t\tduk_get_prop_stridx(ctx, idx_func, DUK_STRIDX_INT_ARGS);  /* -> [ ... func this arg1 ... argN _Args ] */\n\t\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_LENGTH);          /* -> [ ... func this arg1 ... argN _Args length ] */\n\t\tlen = (duk_idx_t) duk_require_int(ctx, -1);\n\t\tduk_pop(ctx);\n\t\tfor (i = 0; i < len; i++) {\n\t\t\t/* XXX: very slow - better to bulk allocate a gap, and copy\n\t\t\t * from args_array directly (we know it has a compact array\n\t\t\t * part, etc).\n\t\t\t */\n\n\t\t\t/* [ ... func this <some bound args> arg1 ... argN _Args ] */\n\t\t\tduk_get_prop_index(ctx, -1, i);\n\t\t\tduk_insert(ctx, idx_func + 2 + i);  /* idx_args = idx_func + 2 */\n\t\t}\n\t\tnum_stack_args += len;  /* must be updated to work properly (e.g. creation of 'arguments') */\n\t\tduk_pop(ctx);\n\n\t\t/* [ ... func this <bound args> arg1 ... argN ] */\n\n\t\tduk_get_prop_stridx(ctx, idx_func, DUK_STRIDX_INT_TARGET);\n\t\tduk_replace(ctx, idx_func);  /* replace in stack */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"bound function handled, num_stack_args=%ld, idx_func=%ld, curr func=%!T\",\n\t\t                     (long) num_stack_args, (long) idx_func, duk_get_tval(ctx, idx_func)));\n\t} while (--sanity > 0);\n\n\tif (DUK_UNLIKELY(sanity == 0)) {\n\t\tDUK_ERROR_RANGE(thr, DUK_STR_BOUND_CHAIN_LIMIT);\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"final non-bound function is: %!T\", duk_get_tval(ctx, idx_func)));\n\n#if defined(DUK_USE_ASSERTIONS)\n\ttv_func = duk_require_tval(ctx, idx_func);\n\tDUK_ASSERT(DUK_TVAL_IS_LIGHTFUNC(tv_func) || DUK_TVAL_IS_OBJECT(tv_func));\n\tif (DUK_TVAL_IS_OBJECT(tv_func)) {\n\t\tfunc = DUK_TVAL_GET_OBJECT(tv_func);\n\t\tDUK_ASSERT(func != NULL);\n\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_BOUNDFUNC(func));\n\t\tDUK_ASSERT(DUK_HOBJECT_HAS_COMPFUNC(func) ||\n\t\t           DUK_HOBJECT_HAS_NATFUNC(func));\n\t}\n#endif\n\n\t/* write back */\n\t*p_num_stack_args = num_stack_args;\n}\n\n/*\n *  Helper for setting up var_env and lex_env of an activation,\n *  assuming it does NOT have the DUK_HOBJECT_FLAG_NEWENV flag.\n */\n\nDUK_LOCAL void duk__handle_oldenv_for_call(duk_hthread *thr,\n                                           duk_hobject *func,\n                                           duk_activation *act) {\n\tduk_hcompfunc *f;\n\tduk_hobject *h_lex;\n\tduk_hobject *h_var;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(func != NULL);\n\tDUK_ASSERT(act != NULL);\n\tDUK_ASSERT(!DUK_HOBJECT_HAS_NEWENV(func));\n\tDUK_ASSERT(!DUK_HOBJECT_HAS_CREATEARGS(func));\n\tDUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(func));\n\tDUK_UNREF(thr);\n\n\tf = (duk_hcompfunc *) func;\n\th_lex = DUK_HCOMPFUNC_GET_LEXENV(thr->heap, f);\n\th_var = DUK_HCOMPFUNC_GET_VARENV(thr->heap, f);\n\tDUK_ASSERT(h_lex != NULL);  /* Always true for closures (not for templates) */\n\tDUK_ASSERT(h_var != NULL);\n\tact->lex_env = h_lex;\n\tact->var_env = h_var;\n\tDUK_HOBJECT_INCREF(thr, h_lex);\n\tDUK_HOBJECT_INCREF(thr, h_var);\n}\n\n/*\n *  Helper for updating callee 'caller' property.\n */\n\n#if defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)\nDUK_LOCAL void duk__update_func_caller_prop(duk_hthread *thr, duk_hobject *func) {\n\tduk_tval *tv_caller;\n\tduk_hobject *h_tmp;\n\tduk_activation *act_callee;\n\tduk_activation *act_caller;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(func != NULL);\n\tDUK_ASSERT(!DUK_HOBJECT_HAS_BOUNDFUNC(func));  /* bound chain resolved */\n\tDUK_ASSERT(thr->callstack_top >= 1);\n\n\tif (DUK_HOBJECT_HAS_STRICT(func)) {\n\t\t/* Strict functions don't get their 'caller' updated. */\n\t\treturn;\n\t}\n\n\tDUK_ASSERT(thr->callstack_top > 0);\n\tact_callee = thr->callstack_curr;\n\tDUK_ASSERT(act_callee != NULL);\n\tact_caller = (thr->callstack_top >= 2 ? act_callee - 1 : NULL);\n\n\t/* XXX: check .caller writability? */\n\n\t/* Backup 'caller' property and update its value. */\n\ttv_caller = duk_hobject_find_existing_entry_tval_ptr(thr->heap, func, DUK_HTHREAD_STRING_CALLER(thr));\n\tif (tv_caller) {\n\t\t/* If caller is global/eval code, 'caller' should be set to\n\t\t * 'null'.\n\t\t *\n\t\t * XXX: there is no exotic flag to infer this correctly now.\n\t\t * The NEWENV flag is used now which works as intended for\n\t\t * everything (global code, non-strict eval code, and functions)\n\t\t * except strict eval code.  Bound functions are never an issue\n\t\t * because 'func' has been resolved to a non-bound function.\n\t\t */\n\n\t\tif (act_caller) {\n\t\t\t/* act_caller->func may be NULL in some finalization cases,\n\t\t\t * just treat like we don't know the caller.\n\t\t\t */\n\t\t\tif (act_caller->func && !DUK_HOBJECT_HAS_NEWENV(act_caller->func)) {\n\t\t\t\t/* Setting to NULL causes 'caller' to be set to\n\t\t\t\t * 'null' as desired.\n\t\t\t\t */\n\t\t\t\tact_caller = NULL;\n\t\t\t}\n\t\t}\n\n\t\tif (DUK_TVAL_IS_OBJECT(tv_caller)) {\n\t\t\th_tmp = DUK_TVAL_GET_OBJECT(tv_caller);\n\t\t\tDUK_ASSERT(h_tmp != NULL);\n\t\t\tact_callee->prev_caller = h_tmp;\n\n\t\t\t/* Previous value doesn't need refcount changes because its ownership\n\t\t\t * is transferred to prev_caller.\n\t\t\t */\n\n\t\t\tif (act_caller) {\n\t\t\t\tDUK_ASSERT(act_caller->func != NULL);\n\t\t\t\tDUK_TVAL_SET_OBJECT(tv_caller, act_caller->func);\n\t\t\t\tDUK_TVAL_INCREF(thr, tv_caller);\n\t\t\t} else {\n\t\t\t\tDUK_TVAL_SET_NULL(tv_caller);  /* no incref */\n\t\t\t}\n\t\t} else {\n\t\t\t/* 'caller' must only take on 'null' or function value */\n\t\t\tDUK_ASSERT(!DUK_TVAL_IS_HEAP_ALLOCATED(tv_caller));\n\t\t\tDUK_ASSERT(act_callee->prev_caller == NULL);\n\t\t\tif (act_caller && act_caller->func) {\n\t\t\t\t/* Tolerate act_caller->func == NULL which happens in\n\t\t\t\t * some finalization cases; treat like unknown caller.\n\t\t\t\t */\n\t\t\t\tDUK_TVAL_SET_OBJECT(tv_caller, act_caller->func);\n\t\t\t\tDUK_TVAL_INCREF(thr, tv_caller);\n\t\t\t} else {\n\t\t\t\tDUK_TVAL_SET_NULL(tv_caller);  /* no incref */\n\t\t\t}\n\t\t}\n\t}\n}\n#endif  /* DUK_USE_NONSTD_FUNC_CALLER_PROPERTY */\n\n/*\n *  Determine the effective 'this' binding and coerce the current value\n *  on the valstack to the effective one (in-place, at idx_this).\n *\n *  The current this value in the valstack (at idx_this) represents either:\n *    - the caller's requested 'this' binding; or\n *    - a 'this' binding accumulated from the bound function chain\n *\n *  The final 'this' binding for the target function may still be\n *  different, and is determined as described in E5 Section 10.4.3.\n *\n *  For global and eval code (E5 Sections 10.4.1 and 10.4.2), we assume\n *  that the caller has provided the correct 'this' binding explicitly\n *  when calling, i.e.:\n *\n *    - global code: this=global object\n *    - direct eval: this=copy from eval() caller's this binding\n *    - other eval:  this=global object\n *\n *  Note: this function may cause a recursive function call with arbitrary\n *  side effects, because ToObject() may be called.\n */\n\nDUK_LOCAL void duk__coerce_effective_this_binding(duk_hthread *thr,\n                                                  duk_hobject *func,\n                                                  duk_idx_t idx_this) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_tval *tv_this;\n\tduk_hobject *obj_global;\n\n\tif (func == NULL || DUK_HOBJECT_HAS_STRICT(func)) {\n\t\t/* Lightfuncs are always considered strict. */\n\t\tDUK_DDD(DUK_DDDPRINT(\"this binding: strict -> use directly\"));\n\t\treturn;\n\t}\n\n\t/* XXX: byte offset */\n\ttv_this = thr->valstack_bottom + idx_this;\n\tswitch (DUK_TVAL_GET_TAG(tv_this)) {\n\tcase DUK_TAG_OBJECT:\n\t\tDUK_DDD(DUK_DDDPRINT(\"this binding: non-strict, object -> use directly\"));\n\t\tbreak;\n\tcase DUK_TAG_UNDEFINED:\n\tcase DUK_TAG_NULL:\n\t\tDUK_DDD(DUK_DDDPRINT(\"this binding: non-strict, undefined/null -> use global object\"));\n\t\tobj_global = thr->builtins[DUK_BIDX_GLOBAL];\n\t\t/* XXX: avoid this check somehow */\n\t\tif (DUK_LIKELY(obj_global != NULL)) {\n\t\t\tDUK_ASSERT(!DUK_TVAL_IS_HEAP_ALLOCATED(tv_this));  /* no need to decref previous value */\n\t\t\tDUK_TVAL_SET_OBJECT(tv_this, obj_global);\n\t\t\tDUK_HOBJECT_INCREF(thr, obj_global);\n\t\t} else {\n\t\t\t/* This may only happen if built-ins are being \"torn down\".\n\t\t\t * This behavior is out of specification scope.\n\t\t\t */\n\t\t\tDUK_D(DUK_DPRINT(\"this binding: wanted to use global object, but it is NULL -> using undefined instead\"));\n\t\t\tDUK_ASSERT(!DUK_TVAL_IS_HEAP_ALLOCATED(tv_this));  /* no need to decref previous value */\n\t\t\tDUK_TVAL_SET_UNDEFINED(tv_this);  /* nothing to incref */\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\t/* Plain buffers and lightfuncs are object coerced.  Lightfuncs\n\t\t * very rarely come here however, because the call target would\n\t\t * need to be a strict non-lightfunc (lightfuncs are considered\n\t\t * strict) with an explicit lightfunc 'this' binding.\n\t\t */\n\t\tDUK_ASSERT(!DUK_TVAL_IS_UNUSED(tv_this));\n\t\tDUK_DDD(DUK_DDDPRINT(\"this binding: non-strict, not object/undefined/null -> use ToObject(value)\"));\n\t\tduk_to_object(ctx, idx_this);  /* may have side effects */\n\t\tbreak;\n\t}\n}\n\n/*\n *  Shared helper for non-bound func lookup.\n *\n *  Returns duk_hobject * to the final non-bound function (NULL for lightfunc).\n */\n\nDUK_LOCAL duk_hobject *duk__nonbound_func_lookup(duk_context *ctx,\n                                                 duk_idx_t idx_func,\n                                                 duk_idx_t *out_num_stack_args,\n                                                 duk_tval **out_tv_func,\n                                                 duk_small_uint_t call_flags) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_tval *tv_func;\n\tduk_hobject *func;\n\n\tfor (;;) {\n\t\t/* Use loop to minimize code size of relookup after bound function case */\n\t\ttv_func = DUK_GET_TVAL_POSIDX(ctx, idx_func);\n\t\tDUK_ASSERT(tv_func != NULL);\n\n\t\tif (DUK_TVAL_IS_OBJECT(tv_func)) {\n\t\t\tfunc = DUK_TVAL_GET_OBJECT(tv_func);\n\t\t\tif (!DUK_HOBJECT_IS_CALLABLE(func)) {\n\t\t\t\tgoto not_callable_error;\n\t\t\t}\n\t\t\tif (DUK_HOBJECT_HAS_BOUNDFUNC(func)) {\n\t\t\t\tduk__handle_bound_chain_for_call(thr, idx_func, out_num_stack_args, call_flags & DUK_CALL_FLAG_CONSTRUCTOR_CALL);\n\n\t\t\t\t/* The final object may be a normal function or a lightfunc.\n\t\t\t\t * We need to re-lookup tv_func because it may have changed\n\t\t\t\t * (also value stack may have been resized).  Loop again to\n\t\t\t\t * do that; we're guaranteed not to come here again.\n\t\t\t\t */\n\t\t\t\tDUK_ASSERT(DUK_TVAL_IS_OBJECT(duk_require_tval(ctx, idx_func)) ||\n\t\t\t\t           DUK_TVAL_IS_LIGHTFUNC(duk_require_tval(ctx, idx_func)));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t} else if (DUK_TVAL_IS_LIGHTFUNC(tv_func)) {\n\t\t\tfunc = NULL;\n\t\t} else {\n\t\t\tgoto not_callable_error;\n\t\t}\n\t\tbreak;\n\t}\n\n\tDUK_ASSERT((DUK_TVAL_IS_OBJECT(tv_func) && DUK_HOBJECT_IS_CALLABLE(DUK_TVAL_GET_OBJECT(tv_func))) ||\n\t           DUK_TVAL_IS_LIGHTFUNC(tv_func));\n\tDUK_ASSERT(func == NULL || !DUK_HOBJECT_HAS_BOUNDFUNC(func));\n\tDUK_ASSERT(func == NULL || (DUK_HOBJECT_IS_COMPFUNC(func) ||\n\t                            DUK_HOBJECT_IS_NATFUNC(func)));\n\n\t*out_tv_func = tv_func;\n\treturn func;\n\n not_callable_error:\n\tDUK_ASSERT(tv_func != NULL);\n#if defined(DUK_USE_PARANOID_ERRORS)\n\tDUK_ERROR_TYPE(thr, DUK_STR_NOT_CALLABLE);\n#else\n\tDUK_ERROR_FMT1(thr, DUK_ERR_TYPE_ERROR, \"%s not callable\", duk_push_string_tval_readable(ctx, tv_func));\n#endif\n\tDUK_UNREACHABLE();\n\treturn NULL;  /* never executed */\n}\n\n/*\n *  Value stack resize and stack top adjustment helper.\n *\n *  XXX: This should all be merged to duk_valstack_resize_raw().\n */\n\nDUK_LOCAL void duk__adjust_valstack_and_top(duk_hthread *thr,\n                                            duk_idx_t num_stack_args,\n                                            duk_idx_t idx_args,\n                                            duk_idx_t nregs,\n                                            duk_idx_t nargs,\n                                            duk_hobject *func) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_size_t vs_min_size;\n\tduk_bool_t adjusted_top = 0;\n\n\tvs_min_size = (thr->valstack_bottom - thr->valstack) +  /* bottom of current func */\n\t              idx_args;                                 /* bottom of new func */\n\n\tif (nregs >= 0) {\n\t\tDUK_ASSERT(nargs >= 0);\n\t\tDUK_ASSERT(nregs >= nargs);\n\t\tvs_min_size += nregs;\n\t} else {\n\t\t/* 'func' wants stack \"as is\" */\n\t\tvs_min_size += num_stack_args;  /* num entries of new func at entry */\n\t}\n\tif (func == NULL || DUK_HOBJECT_IS_NATFUNC(func)) {\n\t\tvs_min_size += DUK_VALSTACK_API_ENTRY_MINIMUM;  /* Duktape/C API guaranteed entries (on top of args) */\n\t}\n\tvs_min_size += DUK_VALSTACK_INTERNAL_EXTRA;             /* + spare */\n\n\t/* XXX: We can't resize the value stack to a size smaller than the\n\t * current top, so the order of the resize and adjusting the stack\n\t * top depends on the current vs. final size of the value stack.\n\t * The operations could be combined to avoid this, but the proper\n\t * fix is to only grow the value stack on a function call, and only\n\t * shrink it (without throwing if the shrink fails) on function\n\t * return.\n\t */\n\n\tif (vs_min_size < (duk_size_t) (thr->valstack_top  - thr->valstack)) {\n\t\tDUK_DDD(DUK_DDDPRINT((\"final size smaller, set top before resize\")));\n\n\t\tDUK_ASSERT(nregs >= 0);  /* can't happen when keeping current stack size */\n\t\tduk_set_top(ctx, idx_args + nargs);  /* clamp anything above nargs */\n\t\tduk_set_top(ctx, idx_args + nregs);  /* extend with undefined */\n\t\tadjusted_top = 1;\n\t}\n\n\t(void) duk_valstack_resize_raw((duk_context *) thr,\n\t                               vs_min_size,\n\t                               DUK_VSRESIZE_FLAG_SHRINK |      /* flags */\n\t                               0 /* no compact */ |\n\t                               DUK_VSRESIZE_FLAG_THROW);\n\n\tif (!adjusted_top) {\n\t\tif (nregs >= 0) {\n\t\t\tDUK_ASSERT(nregs >= nargs);\n\t\t\tduk_set_top(ctx, idx_args + nargs);  /* clamp anything above nargs */\n\t\t\tduk_set_top(ctx, idx_args + nregs);  /* extend with undefined */\n\t\t}\n\t}\n}\n\n/*\n *  Manipulate value stack so that exactly 'num_stack_rets' return\n *  values are at 'idx_retbase' in every case, assuming there are\n *  'rc' return values on top of stack.\n *\n *  This is a bit tricky, because the called C function operates in\n *  the same activation record and may have e.g. popped the stack\n *  empty (below idx_retbase).\n */\n\nDUK_LOCAL void duk__safe_call_adjust_valstack(duk_hthread *thr, duk_idx_t idx_retbase, duk_idx_t num_stack_rets, duk_idx_t num_actual_rets) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_idx_t idx_rcbase;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(idx_retbase >= 0);\n\tDUK_ASSERT(num_stack_rets >= 0);\n\tDUK_ASSERT(num_actual_rets >= 0);\n\n\tidx_rcbase = duk_get_top(ctx) - num_actual_rets;  /* base of known return values */\n\n\tDUK_DDD(DUK_DDDPRINT(\"adjust valstack after func call: \"\n\t                     \"num_stack_rets=%ld, num_actual_rets=%ld, stack_top=%ld, idx_retbase=%ld, idx_rcbase=%ld\",\n\t                     (long) num_stack_rets, (long) num_actual_rets, (long) duk_get_top(ctx),\n\t                     (long) idx_retbase, (long) idx_rcbase));\n\n\tDUK_ASSERT(idx_rcbase >= 0);  /* caller must check */\n\n\t/* Ensure space for final configuration (idx_retbase + num_stack_rets)\n\t * and intermediate configurations.\n\t */\n\tduk_require_stack_top(ctx,\n\t                      (idx_rcbase > idx_retbase ? idx_rcbase : idx_retbase) +\n\t                      num_stack_rets);\n\n\t/* Chop extra retvals away / extend with undefined. */\n\tduk_set_top(ctx, idx_rcbase + num_stack_rets);\n\n\tif (idx_rcbase >= idx_retbase) {\n\t\tduk_idx_t count = idx_rcbase - idx_retbase;\n\t\tduk_idx_t i;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"elements at/after idx_retbase have enough to cover func retvals \"\n\t\t                     \"(idx_retbase=%ld, idx_rcbase=%ld)\", (long) idx_retbase, (long) idx_rcbase));\n\n\t\t/* nuke values at idx_retbase to get the first retval (initially\n\t\t * at idx_rcbase) to idx_retbase\n\t\t */\n\n\t\tDUK_ASSERT(count >= 0);\n\n\t\tfor (i = 0; i < count; i++) {\n\t\t\t/* XXX: inefficient; block remove primitive */\n\t\t\tduk_remove(ctx, idx_retbase);\n\t\t}\n\t} else {\n\t\tduk_idx_t count = idx_retbase - idx_rcbase;\n\t\tduk_idx_t i;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"not enough elements at/after idx_retbase to cover func retvals \"\n\t\t                     \"(idx_retbase=%ld, idx_rcbase=%ld)\", (long) idx_retbase, (long) idx_rcbase));\n\n\t\t/* insert 'undefined' values at idx_rcbase to get the\n\t\t * return values to idx_retbase\n\t\t */\n\n\t\tDUK_ASSERT(count > 0);\n\n\t\tfor (i = 0; i < count; i++) {\n\t\t\t/* XXX: inefficient; block insert primitive */\n\t\t\tduk_push_undefined(ctx);\n\t\t\tduk_insert(ctx, idx_rcbase);\n\t\t}\n\t}\n}\n\n/*\n *  Misc shared helpers.\n */\n\n/* Get valstack index for the func argument or throw if insane stack. */\nDUK_LOCAL duk_idx_t duk__get_idx_func(duk_hthread *thr, duk_idx_t num_stack_args) {\n\tduk_size_t off_stack_top;\n\tduk_size_t off_stack_args;\n\tduk_size_t off_stack_all;\n\tduk_idx_t idx_func;         /* valstack index of 'func' and retval (relative to entry valstack_bottom) */\n\n\t/* Argument validation and func/args offset. */\n\toff_stack_top = (duk_size_t) ((duk_uint8_t *) thr->valstack_top - (duk_uint8_t *) thr->valstack_bottom);\n\toff_stack_args = (duk_size_t) ((duk_size_t) num_stack_args * sizeof(duk_tval));\n\toff_stack_all = off_stack_args + 2 * sizeof(duk_tval);\n\tif (DUK_UNLIKELY(off_stack_all > off_stack_top)) {\n\t\t/* Since stack indices are not reliable, we can't do anything useful\n\t\t * here.  Invoke the existing setjmp catcher, or if it doesn't exist,\n\t\t * call the fatal error handler.\n\t\t */\n\t\tDUK_ERROR_TYPE_INVALID_ARGS(thr);\n\t\treturn 0;\n\t}\n\tidx_func = (duk_idx_t) ((off_stack_top - off_stack_all) / sizeof(duk_tval));\n\treturn idx_func;\n}\n\n/*\n *  duk_handle_call_protected() and duk_handle_call_unprotected():\n *  call into a Duktape/C or an Ecmascript function from any state.\n *\n *  Input stack (thr):\n *\n *    [ func this arg1 ... argN ]\n *\n *  Output stack (thr):\n *\n *    [ retval ]         (DUK_EXEC_SUCCESS)\n *    [ errobj ]         (DUK_EXEC_ERROR (normal error), protected call)\n *\n *  Even when executing a protected call an error may be thrown in rare cases\n *  such as an insane num_stack_args argument.  If there is no catchpoint for\n *  such errors, the fatal error handler is called.\n *\n *  The error handling path should be error free, even for out-of-memory\n *  errors, to ensure safe sandboxing.  (As of Duktape 1.4.0 this is not\n *  yet the case, see XXX notes below.)\n */\n\nDUK_INTERNAL duk_int_t duk_handle_call_protected(duk_hthread *thr,\n                                                 duk_idx_t num_stack_args,\n                                                 duk_small_uint_t call_flags) {\n\tduk_context *ctx;\n\tduk_size_t entry_valstack_bottom_index;\n\tduk_size_t entry_valstack_end;\n\tduk_size_t entry_callstack_top;\n\tduk_size_t entry_catchstack_top;\n\tduk_int_t entry_call_recursion_depth;\n\tduk_hthread *entry_curr_thread;\n\tduk_uint_fast8_t entry_thread_state;\n\tduk_instr_t **entry_ptr_curr_pc;\n\tduk_jmpbuf *old_jmpbuf_ptr = NULL;\n\tduk_jmpbuf our_jmpbuf;\n\tduk_idx_t idx_func;  /* valstack index of 'func' and retval (relative to entry valstack_bottom) */\n\n\t/* XXX: Multiple tv_func lookups are now avoided by making a local\n\t * copy of tv_func.  Another approach would be to compute an offset\n\t * for tv_func from valstack bottom and recomputing the tv_func\n\t * pointer quickly as valstack + offset instead of calling duk_get_tval().\n\t */\n\n\tctx = (duk_context *) thr;\n\tDUK_UNREF(ctx);\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(num_stack_args >= 0);\n\t/* XXX: currently NULL allocations are not supported; remove if later allowed */\n\tDUK_ASSERT(thr->valstack != NULL);\n\tDUK_ASSERT(thr->callstack != NULL);\n\tDUK_ASSERT(thr->catchstack != NULL);\n\n\t/* Argument validation and func/args offset. */\n\tidx_func = duk__get_idx_func(thr, num_stack_args);\n\n\t/* Preliminaries, required by setjmp() handler.  Must be careful not\n\t * to throw an unintended error here.\n\t */\n\n\tentry_valstack_bottom_index = (duk_size_t) (thr->valstack_bottom - thr->valstack);\n#if defined(DUK_USE_PREFER_SIZE)\n\tentry_valstack_end = (duk_size_t) (thr->valstack_end - thr->valstack);\n#else\n\tDUK_ASSERT((duk_size_t) (thr->valstack_end - thr->valstack) == thr->valstack_size);\n\tentry_valstack_end = thr->valstack_size;\n#endif\n\tentry_callstack_top = thr->callstack_top;\n\tentry_catchstack_top = thr->catchstack_top;\n\tentry_call_recursion_depth = thr->heap->call_recursion_depth;\n\tentry_curr_thread = thr->heap->curr_thread;  /* Note: may be NULL if first call */\n\tentry_thread_state = thr->state;\n\tentry_ptr_curr_pc = thr->ptr_curr_pc;  /* may be NULL */\n\n\tDUK_DD(DUK_DDPRINT(\"duk_handle_call_protected: thr=%p, num_stack_args=%ld, \"\n\t                   \"call_flags=0x%08lx (ignorerec=%ld, constructor=%ld), \"\n\t                   \"valstack_top=%ld, idx_func=%ld, idx_args=%ld, rec_depth=%ld/%ld, \"\n\t                   \"entry_valstack_bottom_index=%ld, entry_callstack_top=%ld, entry_catchstack_top=%ld, \"\n\t                   \"entry_call_recursion_depth=%ld, entry_curr_thread=%p, entry_thread_state=%ld\",\n\t                   (void *) thr,\n\t                   (long) num_stack_args,\n\t                   (unsigned long) call_flags,\n\t                   (long) ((call_flags & DUK_CALL_FLAG_IGNORE_RECLIMIT) != 0 ? 1 : 0),\n\t                   (long) ((call_flags & DUK_CALL_FLAG_CONSTRUCTOR_CALL) != 0 ? 1 : 0),\n\t                   (long) duk_get_top(ctx),\n\t                   (long) idx_func,\n\t                   (long) (idx_func + 2),\n\t                   (long) thr->heap->call_recursion_depth,\n\t                   (long) thr->heap->call_recursion_limit,\n\t                   (long) entry_valstack_bottom_index,\n\t                   (long) entry_callstack_top,\n\t                   (long) entry_catchstack_top,\n\t                   (long) entry_call_recursion_depth,\n\t                   (void *) entry_curr_thread,\n\t                   (long) entry_thread_state));\n\n\told_jmpbuf_ptr = thr->heap->lj.jmpbuf_ptr;\n\tthr->heap->lj.jmpbuf_ptr = &our_jmpbuf;\n\n#if defined(DUK_USE_CPP_EXCEPTIONS)\n\ttry {\n#else\n\tDUK_ASSERT(thr->heap->lj.jmpbuf_ptr == &our_jmpbuf);\n\tif (DUK_SETJMP(our_jmpbuf.jb) == 0) {\n#endif\n\t\t/* Call handling and success path.  Success path exit cleans\n\t\t * up almost all state.\n\t\t */\n\t\tduk__handle_call_inner(thr, num_stack_args, call_flags, idx_func);\n\n\t\tthr->heap->lj.jmpbuf_ptr = old_jmpbuf_ptr;\n\n\t\treturn DUK_EXEC_SUCCESS;\n#if defined(DUK_USE_CPP_EXCEPTIONS)\n\t} catch (duk_internal_exception &exc) {\n#else\n\t} else {\n#endif\n\t\t/* Error; error value is in heap->lj.value1. */\n\n#if defined(DUK_USE_CPP_EXCEPTIONS)\n\t\tDUK_UNREF(exc);\n#endif\n\n\t\tduk__handle_call_error(thr,\n\t\t                       entry_valstack_bottom_index,\n\t\t                       entry_valstack_end,\n\t\t                       entry_catchstack_top,\n\t\t                       entry_callstack_top,\n\t\t                       entry_call_recursion_depth,\n\t\t                       entry_curr_thread,\n\t\t                       entry_thread_state,\n\t\t                       entry_ptr_curr_pc,\n\t\t                       idx_func,\n\t\t                       old_jmpbuf_ptr);\n\n\t\treturn DUK_EXEC_ERROR;\n\t}\n#if defined(DUK_USE_CPP_EXCEPTIONS)\n\tcatch (std::exception &exc) {\n\t\tconst char *what = exc.what();\n\t\tif (!what) {\n\t\t\twhat = \"unknown\";\n\t\t}\n\t\tDUK_D(DUK_DPRINT(\"unexpected c++ std::exception (perhaps thrown by user code)\"));\n\t\ttry {\n\t\t\tDUK_ERROR_FMT1(thr, DUK_ERR_TYPE_ERROR, \"caught invalid c++ std::exception '%s' (perhaps thrown by user code)\", what);\n\t\t} catch (duk_internal_exception exc) {\n\t\t\tDUK_D(DUK_DPRINT(\"caught api error thrown from unexpected c++ std::exception\"));\n\t\t\tDUK_UNREF(exc);\n\t\t\tduk__handle_call_error(thr,\n\t\t\t                       entry_valstack_bottom_index,\n\t\t\t                       entry_valstack_end,\n\t\t\t                       entry_catchstack_top,\n\t\t\t                       entry_callstack_top,\n\t\t\t                       entry_call_recursion_depth,\n\t\t\t                       entry_curr_thread,\n\t\t\t                       entry_thread_state,\n\t\t\t                       entry_ptr_curr_pc,\n\t\t\t                       idx_func,\n\t\t\t                       old_jmpbuf_ptr);\n\n\t\t\treturn DUK_EXEC_ERROR;\n\t\t}\n\t} catch (...) {\n\t\tDUK_D(DUK_DPRINT(\"unexpected c++ exception (perhaps thrown by user code)\"));\n\t\ttry {\n\t\t\tDUK_ERROR_TYPE(thr, \"caught invalid c++ exception (perhaps thrown by user code)\");\n\t\t} catch (duk_internal_exception exc) {\n\t\t\tDUK_D(DUK_DPRINT(\"caught api error thrown from unexpected c++ exception\"));\n\t\t\tDUK_UNREF(exc);\n\t\t\tduk__handle_call_error(thr,\n\t\t\t                       entry_valstack_bottom_index,\n\t\t\t                       entry_valstack_end,\n\t\t\t                       entry_catchstack_top,\n\t\t\t                       entry_callstack_top,\n\t\t\t                       entry_call_recursion_depth,\n\t\t\t                       entry_curr_thread,\n\t\t\t                       entry_thread_state,\n\t\t\t                       entry_ptr_curr_pc,\n\t\t\t                       idx_func,\n\t\t\t                       old_jmpbuf_ptr);\n\n\t\t\treturn DUK_EXEC_ERROR;\n\t\t}\n\t}\n#endif\n}\n\nDUK_INTERNAL void duk_handle_call_unprotected(duk_hthread *thr,\n                                              duk_idx_t num_stack_args,\n                                              duk_small_uint_t call_flags) {\n\tduk_idx_t idx_func;         /* valstack index of 'func' and retval (relative to entry valstack_bottom) */\n\n\t/* Argument validation and func/args offset. */\n\tidx_func = duk__get_idx_func(thr, num_stack_args);\n\n\tduk__handle_call_inner(thr, num_stack_args, call_flags, idx_func);\n}\n\nDUK_LOCAL void duk__handle_call_inner(duk_hthread *thr,\n                                      duk_idx_t num_stack_args,\n                                      duk_small_uint_t call_flags,\n                                      duk_idx_t idx_func) {\n\tduk_context *ctx;\n\tduk_size_t entry_valstack_bottom_index;\n\tduk_size_t entry_valstack_end;\n\tduk_size_t entry_callstack_top;\n\tduk_size_t entry_catchstack_top;\n\tduk_int_t entry_call_recursion_depth;\n\tduk_hthread *entry_curr_thread;\n\tduk_uint_fast8_t entry_thread_state;\n\tduk_instr_t **entry_ptr_curr_pc;\n\tduk_idx_t nargs;            /* # argument registers target function wants (< 0 => \"as is\") */\n\tduk_idx_t nregs;            /* # total registers target function wants on entry (< 0 => \"as is\") */\n\tduk_hobject *func;          /* 'func' on stack (borrowed reference) */\n\tduk_tval *tv_func;          /* duk_tval ptr for 'func' on stack (borrowed reference) or tv_func_copy */\n\tduk_tval tv_func_copy;      /* to avoid relookups */\n\tduk_activation *act;\n\tduk_hobject *env;\n\tduk_ret_t rc;\n\n\tctx = (duk_context *) thr;\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(num_stack_args >= 0);\n\t/* XXX: currently NULL allocations are not supported; remove if later allowed */\n\tDUK_ASSERT(thr->valstack != NULL);\n\tDUK_ASSERT(thr->callstack != NULL);\n\tDUK_ASSERT(thr->catchstack != NULL);\n\n\tDUK_DD(DUK_DDPRINT(\"duk__handle_call_inner: num_stack_args=%ld, call_flags=0x%08lx, top=%ld\",\n\t                   (long) num_stack_args, (long) call_flags, (long) duk_get_top(ctx)));\n\n\t/*\n\t *  Store entry state.\n\t */\n\n\tentry_valstack_bottom_index = (duk_size_t) (thr->valstack_bottom - thr->valstack);\n#if defined(DUK_USE_PREFER_SIZE)\n\tentry_valstack_end = (duk_size_t) (thr->valstack_end - thr->valstack);\n#else\n\tDUK_ASSERT((duk_size_t) (thr->valstack_end - thr->valstack) == thr->valstack_size);\n\tentry_valstack_end = thr->valstack_size;\n#endif\n\tentry_callstack_top = thr->callstack_top;\n\tentry_catchstack_top = thr->catchstack_top;\n\tentry_call_recursion_depth = thr->heap->call_recursion_depth;\n\tentry_curr_thread = thr->heap->curr_thread;  /* Note: may be NULL if first call */\n\tentry_thread_state = thr->state;\n\tentry_ptr_curr_pc = thr->ptr_curr_pc;  /* may be NULL */\n\n\t/* If thr->ptr_curr_pc is set, sync curr_pc to act->pc.  Then NULL\n\t * thr->ptr_curr_pc so that it's not accidentally used with an incorrect\n\t * activation when side effects occur.\n\t */\n\tduk_hthread_sync_and_null_currpc(thr);\n\n\tDUK_DD(DUK_DDPRINT(\"duk__handle_call_inner: thr=%p, num_stack_args=%ld, \"\n\t                   \"call_flags=0x%08lx (ignorerec=%ld, constructor=%ld), \"\n\t                   \"valstack_top=%ld, idx_func=%ld, idx_args=%ld, rec_depth=%ld/%ld, \"\n\t                   \"entry_valstack_bottom_index=%ld, entry_callstack_top=%ld, entry_catchstack_top=%ld, \"\n\t                   \"entry_call_recursion_depth=%ld, entry_curr_thread=%p, entry_thread_state=%ld\",\n\t                   (void *) thr,\n\t                   (long) num_stack_args,\n\t                   (unsigned long) call_flags,\n\t                   (long) ((call_flags & DUK_CALL_FLAG_IGNORE_RECLIMIT) != 0 ? 1 : 0),\n\t                   (long) ((call_flags & DUK_CALL_FLAG_CONSTRUCTOR_CALL) != 0 ? 1 : 0),\n\t                   (long) duk_get_top(ctx),\n\t                   (long) idx_func,\n\t                   (long) (idx_func + 2),\n\t                   (long) thr->heap->call_recursion_depth,\n\t                   (long) thr->heap->call_recursion_limit,\n\t                   (long) entry_valstack_bottom_index,\n\t                   (long) entry_callstack_top,\n\t                   (long) entry_catchstack_top,\n\t                   (long) entry_call_recursion_depth,\n\t                   (void *) entry_curr_thread,\n\t                   (long) entry_thread_state));\n\n\n\t/*\n\t *  Thread state check and book-keeping.\n\t */\n\n\tif (thr == thr->heap->curr_thread) {\n\t\t/* same thread */\n\t\tif (thr->state != DUK_HTHREAD_STATE_RUNNING) {\n\t\t\t/* should actually never happen, but check anyway */\n\t\t\tgoto thread_state_error;\n\t\t}\n\t} else {\n\t\t/* different thread */\n\t\tDUK_ASSERT(thr->heap->curr_thread == NULL ||\n\t\t           thr->heap->curr_thread->state == DUK_HTHREAD_STATE_RUNNING);\n\t\tif (thr->state != DUK_HTHREAD_STATE_INACTIVE) {\n\t\t\tgoto thread_state_error;\n\t\t}\n\t\tDUK_HEAP_SWITCH_THREAD(thr->heap, thr);\n\t\tthr->state = DUK_HTHREAD_STATE_RUNNING;\n\n\t\t/* Note: multiple threads may be simultaneously in the RUNNING\n\t\t * state, but not in the same \"resume chain\".\n\t\t */\n\t}\n\tDUK_ASSERT(thr->heap->curr_thread == thr);\n\tDUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING);\n\n\t/*\n\t *  C call recursion depth check, which provides a reasonable upper\n\t *  bound on maximum C stack size (arbitrary C stack growth is only\n\t *  possible by recursive handle_call / handle_safe_call calls).\n\t */\n\n\t/* XXX: remove DUK_CALL_FLAG_IGNORE_RECLIMIT flag: there's now the\n\t * reclimit bump?\n\t */\n\n\tDUK_ASSERT(thr->heap->call_recursion_depth >= 0);\n\tDUK_ASSERT(thr->heap->call_recursion_depth <= thr->heap->call_recursion_limit);\n\tif (call_flags & DUK_CALL_FLAG_IGNORE_RECLIMIT) {\n\t\tDUK_DD(DUK_DDPRINT(\"ignoring reclimit for this call (probably an errhandler call)\"));\n\t} else {\n\t\tif (thr->heap->call_recursion_depth >= thr->heap->call_recursion_limit) {\n\t\t\t/* XXX: error message is a bit misleading: we reached a recursion\n\t\t\t * limit which is also essentially the same as a C callstack limit\n\t\t\t * (except perhaps with some relaxed threading assumptions).\n\t\t\t */\n\t\t\tDUK_ERROR_RANGE(thr, DUK_STR_C_CALLSTACK_LIMIT);\n\t\t}\n\t\tthr->heap->call_recursion_depth++;\n\t}\n\n\t/*\n\t *  Check the function type, handle bound function chains, and prepare\n\t *  parameters for the rest of the call handling.  Also figure out the\n\t *  effective 'this' binding, which replaces the current value at\n\t *  idx_func + 1.\n\t *\n\t *  If the target function is a 'bound' one, follow the chain of 'bound'\n\t *  functions until a non-bound function is found.  During this process,\n\t *  bound arguments are 'prepended' to existing ones, and the \"this\"\n\t *  binding is overridden.  See E5 Section 15.3.4.5.1.\n\t *\n\t *  Lightfunc detection happens here too.  Note that lightweight functions\n\t *  can be wrapped by (non-lightweight) bound functions so we must resolve\n\t *  the bound function chain first.\n\t */\n\n\tfunc = duk__nonbound_func_lookup(ctx, idx_func, &num_stack_args, &tv_func, call_flags);\n\tDUK_TVAL_SET_TVAL(&tv_func_copy, tv_func);\n\ttv_func = &tv_func_copy;  /* local copy to avoid relookups */\n\n\tDUK_ASSERT(func == NULL || !DUK_HOBJECT_HAS_BOUNDFUNC(func));\n\tDUK_ASSERT(func == NULL || (DUK_HOBJECT_IS_COMPFUNC(func) ||\n\t                            DUK_HOBJECT_IS_NATFUNC(func)));\n\n\tduk__coerce_effective_this_binding(thr, func, idx_func + 1);\n\tDUK_DDD(DUK_DDDPRINT(\"effective 'this' binding is: %!T\",\n\t                     (duk_tval *) duk_get_tval(ctx, idx_func + 1)));\n\n\t/* [ ... func this arg1 ... argN ] */\n\n\t/*\n\t *  Setup a preliminary activation and figure out nargs/nregs.\n\t *\n\t *  Don't touch valstack_bottom or valstack_top yet so that Duktape API\n\t *  calls work normally.\n\t */\n\n\tduk_hthread_callstack_grow(thr);\n\n\tact = thr->callstack_curr;\n\tif (act != NULL) {\n\t\t/*\n\t\t *  Update idx_retval of current activation.\n\t\t *\n\t\t *  Although it might seem this is not necessary (bytecode executor\n\t\t *  does this for Ecmascript-to-Ecmascript calls; other calls are\n\t\t *  handled here), this turns out to be necessary for handling yield\n\t\t *  and resume.  For them, an Ecmascript-to-native call happens, and\n\t\t *  the Ecmascript call's idx_retval must be set for things to work.\n\t\t */\n\n\t\tact->idx_retval = entry_valstack_bottom_index + idx_func;\n\t}\n\n\tDUK_ASSERT(thr->callstack_top < thr->callstack_size);\n\tact = thr->callstack + thr->callstack_top;\n\tthr->callstack_top++;\n\tthr->callstack_curr = act;\n\tDUK_ASSERT(thr->callstack_top <= thr->callstack_size);\n\tDUK_ASSERT(thr->valstack_top > thr->valstack_bottom);  /* at least effective 'this' */\n\tDUK_ASSERT(func == NULL || !DUK_HOBJECT_HAS_BOUNDFUNC(func));\n\n\tact->flags = 0;\n\n\t/* For now all calls except Ecma-to-Ecma calls prevent a yield. */\n\tact->flags |= DUK_ACT_FLAG_PREVENT_YIELD;\n\tif (call_flags & DUK_CALL_FLAG_CONSTRUCTOR_CALL) {\n\t\tact->flags |= DUK_ACT_FLAG_CONSTRUCT;\n\t}\n\tif (call_flags & DUK_CALL_FLAG_DIRECT_EVAL) {\n\t\tact->flags |= DUK_ACT_FLAG_DIRECT_EVAL;\n\t}\n\n\t/* These base values are never used, but if the compiler doesn't know\n\t * that DUK_ERROR() won't return, these are needed to silence warnings.\n\t * On the other hand, scan-build will warn about the values not being\n\t * used, so add a DUK_UNREF.\n\t */\n\tnargs = 0; DUK_UNREF(nargs);\n\tnregs = 0; DUK_UNREF(nregs);\n\n\tif (DUK_LIKELY(func != NULL)) {\n\t\tif (DUK_HOBJECT_HAS_STRICT(func)) {\n\t\t\tact->flags |= DUK_ACT_FLAG_STRICT;\n\t\t}\n\t\tif (DUK_HOBJECT_IS_COMPFUNC(func)) {\n\t\t\tnargs = ((duk_hcompfunc *) func)->nargs;\n\t\t\tnregs = ((duk_hcompfunc *) func)->nregs;\n\t\t\tDUK_ASSERT(nregs >= nargs);\n\t\t} else {\n\t\t\t/* True because of call target lookup checks. */\n\t\t\tDUK_ASSERT(DUK_HOBJECT_IS_NATFUNC(func));\n\n\t\t\t/* Note: nargs (and nregs) may be negative for a native,\n\t\t\t * function, which indicates that the function wants the\n\t\t\t * input stack \"as is\" (i.e. handles \"vararg\" arguments).\n\t\t\t */\n\t\t\tnargs = ((duk_hnatfunc *) func)->nargs;\n\t\t\tnregs = nargs;\n\t\t}\n\t} else {\n\t\tduk_small_uint_t lf_flags;\n\n\t\tDUK_ASSERT(DUK_TVAL_IS_LIGHTFUNC(tv_func));\n\t\tlf_flags = DUK_TVAL_GET_LIGHTFUNC_FLAGS(tv_func);\n\t\tnargs = DUK_LFUNC_FLAGS_GET_NARGS(lf_flags);\n\t\tif (nargs == DUK_LFUNC_NARGS_VARARGS) {\n\t\t\tnargs = -1;  /* vararg */\n\t\t}\n\t\tnregs = nargs;\n\n\t\tact->flags |= DUK_ACT_FLAG_STRICT;\n\t}\n\n\tact->func = func;  /* NULL for lightfunc */\n\tact->var_env = NULL;\n\tact->lex_env = NULL;\n#if defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)\n\tact->prev_caller = NULL;\n#endif\n\tact->curr_pc = NULL;\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\tact->prev_line = 0;\n#endif\n\tact->idx_bottom = entry_valstack_bottom_index + idx_func + 2;\n#if 0  /* topmost activation idx_retval is considered garbage, no need to init */\n\tact->idx_retval = 0;\n#endif\n\tDUK_TVAL_SET_TVAL(&act->tv_func, tv_func);  /* borrowed, no refcount */\n\n\t/* XXX: remove the preventcount and make yield walk the callstack?\n\t * Or perhaps just use a single flag, not a counter, faster to just\n\t * set and restore?\n\t */\n\tif (act->flags & DUK_ACT_FLAG_PREVENT_YIELD) {\n\t\t/* duk_hthread_callstack_unwind() will decrease this on unwind */\n\t\tthr->callstack_preventcount++;\n\t}\n\n\t/* XXX: Is this INCREF necessary? 'func' is always a borrowed\n\t * reference reachable through the value stack?  If changed, stack\n\t * unwind code also needs to be fixed to match.\n\t */\n\tDUK_HOBJECT_INCREF_ALLOWNULL(thr, func);  /* act->func */\n\n#if defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)\n\tif (func) {\n\t\tduk__update_func_caller_prop(thr, func);\n\t\tact = thr->callstack_curr;\n\t}\n#endif\n\n\t/* [ ... func this arg1 ... argN ] */\n\n\t/*\n\t *  Environment record creation and 'arguments' object creation.\n\t *  Named function expression name binding is handled by the\n\t *  compiler; the compiled function's parent env will contain\n\t *  the (immutable) binding already.\n\t *\n\t *  This handling is now identical for C and Ecmascript functions.\n\t *  C functions always have the 'NEWENV' flag set, so their\n\t *  environment record initialization is delayed (which is good).\n\t *\n\t *  Delayed creation (on demand) is handled in duk_js_var.c.\n\t */\n\n\tDUK_ASSERT(func == NULL || !DUK_HOBJECT_HAS_BOUNDFUNC(func));  /* bound function chain has already been resolved */\n\n\tif (DUK_LIKELY(func != NULL)) {\n\t\tif (DUK_LIKELY(DUK_HOBJECT_HAS_NEWENV(func))) {\n\t\t\tif (DUK_LIKELY(!DUK_HOBJECT_HAS_CREATEARGS(func))) {\n\t\t\t\t/* Use a new environment but there's no 'arguments' object;\n\t\t\t\t * delayed environment initialization.  This is the most\n\t\t\t\t * common case.\n\t\t\t\t */\n\t\t\t\tDUK_ASSERT(act->lex_env == NULL);\n\t\t\t\tDUK_ASSERT(act->var_env == NULL);\n\t\t\t} else {\n\t\t\t\t/* Use a new environment and there's an 'arguments' object.\n\t\t\t\t * We need to initialize it right now.\n\t\t\t\t */\n\n\t\t\t\t/* third arg: absolute index (to entire valstack) of idx_bottom of new activation */\n\t\t\t\tenv = duk_create_activation_environment_record(thr, func, act->idx_bottom);\n\t\t\t\tDUK_ASSERT(env != NULL);\n\n\t\t\t\t/* [ ... func this arg1 ... argN envobj ] */\n\n\t\t\t\tDUK_ASSERT(DUK_HOBJECT_HAS_CREATEARGS(func));\n\t\t\t\tduk__handle_createargs_for_call(thr, func, env, num_stack_args);\n\n\t\t\t\t/* [ ... func this arg1 ... argN envobj ] */\n\n\t\t\t\tact = thr->callstack_curr;\n\t\t\t\tact->lex_env = env;\n\t\t\t\tact->var_env = env;\n\t\t\t\tDUK_HOBJECT_INCREF(thr, env);\n\t\t\t\tDUK_HOBJECT_INCREF(thr, env);  /* XXX: incref by count (2) directly */\n\t\t\t\tduk_pop(ctx);\n\t\t\t}\n\t\t} else {\n\t\t\t/* Use existing env (e.g. for non-strict eval); cannot have\n\t\t\t * an own 'arguments' object (but can refer to an existing one).\n\t\t\t */\n\n\t\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_CREATEARGS(func));\n\n\t\t\tduk__handle_oldenv_for_call(thr, func, act);\n\t\t\t/* No need to re-lookup 'act' at present: no side effects. */\n\n\t\t\tDUK_ASSERT(act->lex_env != NULL);\n\t\t\tDUK_ASSERT(act->var_env != NULL);\n\t\t}\n\t} else {\n\t\t/* Lightfuncs are always native functions and have \"newenv\". */\n\t\tDUK_ASSERT(act->lex_env == NULL);\n\t\tDUK_ASSERT(act->var_env == NULL);\n\t}\n\n\t/* [ ... func this arg1 ... argN ] */\n\n\t/*\n\t *  Setup value stack: clamp to 'nargs', fill up to 'nregs'\n\t *\n\t *  Value stack may either grow or shrink, depending on the\n\t *  number of func registers and the number of actual arguments.\n\t *  If nregs >= 0, func wants args clamped to 'nargs'; else it\n\t *  wants all args (= 'num_stack_args').\n\t */\n\n\t/* XXX: optimize value stack operation */\n\t/* XXX: don't want to shrink allocation here */\n\n\tduk__adjust_valstack_and_top(thr,\n\t                             num_stack_args,\n\t                             idx_func + 2,\n\t                             nregs,\n\t                             nargs,\n\t                             func);\n\n\t/*\n\t *  Determine call type, then finalize activation, shift to\n\t *  new value stack bottom, and call the target.\n\t */\n\n\tact = thr->callstack_curr;\n\tif (func != NULL && DUK_HOBJECT_IS_COMPFUNC(func)) {\n\t\t/*\n\t\t *  Ecmascript call\n\t\t */\n\n\t\tduk_tval *tv_ret;\n\t\tduk_tval *tv_funret;\n\n\t\tDUK_ASSERT(func != NULL);\n\t\tDUK_ASSERT(DUK_HOBJECT_HAS_COMPFUNC(func));\n\t\tact->curr_pc = DUK_HCOMPFUNC_GET_CODE_BASE(thr->heap, (duk_hcompfunc *) func);\n\n\t\tthr->valstack_bottom = thr->valstack_bottom + idx_func + 2;\n\t\t/* keep current valstack_top */\n\t\tDUK_ASSERT(thr->valstack_bottom >= thr->valstack);\n\t\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n\t\tDUK_ASSERT(thr->valstack_end >= thr->valstack_top);\n\n\t\t/* [ ... func this | arg1 ... argN ] ('this' must precede new bottom) */\n\n\t\t/*\n\t\t *  Bytecode executor call.\n\t\t *\n\t\t *  Execute bytecode, handling any recursive function calls and\n\t\t *  thread resumptions.  Returns when execution would return from\n\t\t *  the entry level activation.  When the executor returns, a\n\t\t *  single return value is left on the stack top.\n\t\t *\n\t\t *  The only possible longjmp() is an error (DUK_LJ_TYPE_THROW),\n\t\t *  other types are handled internally by the executor.\n\t\t */\n\n\t\t/* thr->ptr_curr_pc is set by bytecode executor early on entry */\n\t\tDUK_ASSERT(thr->ptr_curr_pc == NULL);\n\t\tDUK_DDD(DUK_DDDPRINT(\"entering bytecode execution\"));\n\t\tduk_js_execute_bytecode(thr);\n\t\tDUK_DDD(DUK_DDDPRINT(\"returned from bytecode execution\"));\n\n\t\t/* Unwind. */\n\n\t\tDUK_ASSERT(thr->catchstack_top >= entry_catchstack_top);  /* may need unwind */\n\t\tDUK_ASSERT(thr->callstack_top == entry_callstack_top + 1);\n\t\tduk_hthread_catchstack_unwind_norz(thr, entry_catchstack_top);\n\t\tduk_hthread_catchstack_shrink_check(thr);\n\t\tduk_hthread_callstack_unwind_norz(thr, entry_callstack_top);  /* XXX: may now fail */\n\t\tduk_hthread_callstack_shrink_check(thr);\n\n\t\tthr->valstack_bottom = thr->valstack + entry_valstack_bottom_index;\n\t\t/* keep current valstack_top */\n\t\tDUK_ASSERT(thr->valstack_bottom >= thr->valstack);\n\t\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n\t\tDUK_ASSERT(thr->valstack_end >= thr->valstack_top);\n\t\tDUK_ASSERT(thr->valstack_top - thr->valstack_bottom >= idx_func + 1);\n\n\t\t/* Return value handling. */\n\n\t\t/* [ ... func this (crud) retval ] */\n\n\t\ttv_ret = thr->valstack_bottom + idx_func;\n\t\ttv_funret = thr->valstack_top - 1;\n#if defined(DUK_USE_FASTINT)\n\t\t/* Explicit check for fastint downgrade. */\n\t\tDUK_TVAL_CHKFAST_INPLACE_FAST(tv_funret);\n#endif\n\t\tDUK_TVAL_SET_TVAL_UPDREF(thr, tv_ret, tv_funret);  /* side effects */\n\t} else {\n\t\t/*\n\t\t *  Native call.\n\t\t */\n\n\t\tduk_tval *tv_ret;\n\t\tduk_tval *tv_funret;\n\n\t\tthr->valstack_bottom = thr->valstack_bottom + idx_func + 2;\n\t\t/* keep current valstack_top */\n\t\tDUK_ASSERT(thr->valstack_bottom >= thr->valstack);\n\t\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n\t\tDUK_ASSERT(thr->valstack_end >= thr->valstack_top);\n\t\tDUK_ASSERT(func == NULL || ((duk_hnatfunc *) func)->func != NULL);\n\n\t\t/* [ ... func this | arg1 ... argN ] ('this' must precede new bottom) */\n\n\t\t/* For native calls must be NULL so we don't sync back */\n\t\tDUK_ASSERT(thr->ptr_curr_pc == NULL);\n\n\t\tif (func) {\n\t\t\trc = ((duk_hnatfunc *) func)->func((duk_context *) thr);\n\t\t} else {\n\t\t\tduk_c_function funcptr = DUK_TVAL_GET_LIGHTFUNC_FUNCPTR(tv_func);\n\t\t\trc = funcptr((duk_context *) thr);\n\t\t}\n\n\t\t/* Automatic error throwing, retval check. */\n\n\t\tif (rc < 0) {\n\t\t\tduk_error_throw_from_negative_rc(thr, rc);\n\t\t\tDUK_UNREACHABLE();\n\t\t} else if (rc > 1) {\n\t\t\tDUK_ERROR_TYPE(thr, \"c function returned invalid rc\");\n\t\t}\n\t\tDUK_ASSERT(rc == 0 || rc == 1);\n\n\t\t/* Unwind. */\n\n\t\tDUK_ASSERT(thr->catchstack_top == entry_catchstack_top);  /* no need to unwind */\n\t\tDUK_ASSERT(thr->callstack_top == entry_callstack_top + 1);\n\t\tduk_hthread_callstack_unwind_norz(thr, entry_callstack_top);\n\t\tduk_hthread_callstack_shrink_check(thr);\n\n\t\tthr->valstack_bottom = thr->valstack + entry_valstack_bottom_index;\n\t\t/* keep current valstack_top */\n\t\tDUK_ASSERT(thr->valstack_bottom >= thr->valstack);\n\t\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n\t\tDUK_ASSERT(thr->valstack_end >= thr->valstack_top);\n\t\tDUK_ASSERT(thr->valstack_top - thr->valstack_bottom >= idx_func + 1);\n\n\t\t/* Return value handling. */\n\n\t\t/* XXX: should this happen in the callee's activation or after unwinding? */\n\t\ttv_ret = thr->valstack_bottom + idx_func;\n\t\tif (rc == 0) {\n\t\t\tDUK_TVAL_SET_UNDEFINED_UPDREF(thr, tv_ret);  /* side effects */\n\t\t} else {\n\t\t\t/* [ ... func this (crud) retval ] */\n\t\t\ttv_funret = thr->valstack_top - 1;\n#if defined(DUK_USE_FASTINT)\n\t\t\t/* Explicit check for fastint downgrade. */\n\t\t\tDUK_TVAL_CHKFAST_INPLACE_FAST(tv_funret);\n#endif\n\t\t\tDUK_TVAL_SET_TVAL_UPDREF(thr, tv_ret, tv_funret);  /* side effects */\n\t\t}\n\t}\n\n\tduk_set_top(ctx, idx_func + 1);  /* XXX: unnecessary, handle in adjust */\n\n\t/* [ ... retval ] */\n\n\t/* Ensure there is internal valstack spare before we exit; this may\n\t * throw an alloc error.  The same guaranteed size must be available\n\t * as before the call.  This is not optimal now: we store the valstack\n\t * allocated size during entry; this value may be higher than the\n\t * minimal guarantee for an application.\n\t */\n\n\t/* XXX: we should never shrink here; when we error out later, we'd\n\t * need to potentially grow the value stack in error unwind which could\n\t * cause another error.\n\t */\n\n\t(void) duk_valstack_resize_raw((duk_context *) thr,\n\t                               entry_valstack_end,                    /* same as during entry */\n\t                               DUK_VSRESIZE_FLAG_SHRINK |             /* flags */\n\t                               DUK_VSRESIZE_FLAG_COMPACT |\n\t                               DUK_VSRESIZE_FLAG_THROW);\n\n\t/* Restore entry thread executor curr_pc stack frame pointer. */\n\tthr->ptr_curr_pc = entry_ptr_curr_pc;\n\n\tDUK_HEAP_SWITCH_THREAD(thr->heap, entry_curr_thread);  /* may be NULL */\n\tthr->state = (duk_uint8_t) entry_thread_state;\n\n\t/* Disabled assert: triggered with some torture tests. */\n#if 0\n\tDUK_ASSERT((thr->state == DUK_HTHREAD_STATE_INACTIVE && thr->heap->curr_thread == NULL) ||  /* first call */\n\t           (thr->state == DUK_HTHREAD_STATE_INACTIVE && thr->heap->curr_thread != NULL) ||  /* other call */\n\t           (thr->state == DUK_HTHREAD_STATE_RUNNING && thr->heap->curr_thread == thr));     /* current thread */\n#endif\n\n\tthr->heap->call_recursion_depth = entry_call_recursion_depth;\n\n\t/* If the debugger is active we need to force an interrupt so that\n\t * debugger breakpoints are rechecked.  This is important for function\n\t * calls caused by side effects (e.g. when doing a DUK_OP_GETPROP), see\n\t * GH-303.  Only needed for success path, error path always causes a\n\t * breakpoint recheck in the executor.  It would be enough to set this\n\t * only when returning to an Ecmascript activation, but setting the flag\n\t * on every return should have no ill effect.\n\t */\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\tif (duk_debug_is_attached(thr->heap)) {\n\t\tDUK_DD(DUK_DDPRINT(\"returning with debugger enabled, force interrupt\"));\n\t\tDUK_ASSERT(thr->interrupt_counter <= thr->interrupt_init);\n\t\tthr->interrupt_init -= thr->interrupt_counter;\n\t\tthr->interrupt_counter = 0;\n\t\tthr->heap->dbg_force_restart = 1;\n\t}\n#endif\n\n#if defined(DUK_USE_INTERRUPT_COUNTER) && defined(DUK_USE_DEBUG)\n\tduk__interrupt_fixup(thr, entry_curr_thread);\n#endif\n\n\t/* Restored by success path. */\n\tDUK_ASSERT(thr->heap->call_recursion_depth == entry_call_recursion_depth);\n\tDUK_ASSERT(thr->ptr_curr_pc == entry_ptr_curr_pc);\n\n\tDUK_ASSERT_LJSTATE_UNSET(thr->heap);\n\n\tDUK_REFZERO_CHECK_FAST(thr);\n\n\treturn;\n\n thread_state_error:\n\tDUK_ERROR_FMT1(thr, DUK_ERR_TYPE_ERROR, \"invalid thread state for call (%ld)\", (long) thr->state);\n\tDUK_UNREACHABLE();\n\treturn;  /* never executed */\n}\n\nDUK_LOCAL void duk__handle_call_error(duk_hthread *thr,\n                                      duk_size_t entry_valstack_bottom_index,\n                                      duk_size_t entry_valstack_end,\n                                      duk_size_t entry_catchstack_top,\n                                      duk_size_t entry_callstack_top,\n                                      duk_int_t entry_call_recursion_depth,\n                                      duk_hthread *entry_curr_thread,\n                                      duk_uint_fast8_t entry_thread_state,\n                                      duk_instr_t **entry_ptr_curr_pc,\n                                      duk_idx_t idx_func,\n                                      duk_jmpbuf *old_jmpbuf_ptr) {\n\tduk_context *ctx;\n\tduk_tval *tv_ret;\n\n\tctx = (duk_context *) thr;\n\n\tDUK_DDD(DUK_DDDPRINT(\"error caught during duk__handle_call_inner(): %!T\",\n\t                     (duk_tval *) &thr->heap->lj.value1));\n\n\t/* Other longjmp types are handled by executor before propagating\n\t * the error here.\n\t */\n\tDUK_ASSERT(thr->heap->lj.type == DUK_LJ_TYPE_THROW);\n\tDUK_ASSERT_LJSTATE_SET(thr->heap);\n\tDUK_ASSERT(thr->callstack_top >= entry_callstack_top);\n\tDUK_ASSERT(thr->catchstack_top >= entry_catchstack_top);\n\n\t/* We don't need to sync back thr->ptr_curr_pc here because\n\t * the bytecode executor always has a setjmp catchpoint which\n\t * does that before errors propagate to here.\n\t */\n\tDUK_ASSERT(thr->ptr_curr_pc == NULL);\n\n\t/* Restore the previous setjmp catcher so that any error in\n\t * error handling will propagate outwards rather than re-enter\n\t * the same handler.  However, the error handling path must be\n\t * designed to be error free so that sandboxing guarantees are\n\t * reliable, see e.g. https://github.com/svaarala/duktape/issues/476.\n\t */\n\tthr->heap->lj.jmpbuf_ptr = old_jmpbuf_ptr;\n\n\t/* XXX: callstack unwind may now throw an error when closing\n\t * scopes; this is a sandboxing issue, described in:\n\t * https://github.com/svaarala/duktape/issues/476\n\t */\n\tduk_hthread_catchstack_unwind_norz(thr, entry_catchstack_top);\n\tduk_hthread_catchstack_shrink_check(thr);\n\tduk_hthread_callstack_unwind_norz(thr, entry_callstack_top);\n\tduk_hthread_callstack_shrink_check(thr);\n\n\tthr->valstack_bottom = thr->valstack + entry_valstack_bottom_index;\n\ttv_ret = thr->valstack_bottom + idx_func;  /* XXX: byte offset? */\n\tDUK_TVAL_SET_TVAL_UPDREF(thr, tv_ret, &thr->heap->lj.value1);  /* side effects */\n#if defined(DUK_USE_FASTINT)\n\t/* Explicit check for fastint downgrade. */\n\tDUK_TVAL_CHKFAST_INPLACE_FAST(tv_ret);\n#endif\n\tduk_set_top(ctx, idx_func + 1);  /* XXX: could be eliminated with valstack adjust */\n\n\t/* [ ... errobj ] */\n\n\t/* Ensure there is internal valstack spare before we exit; this may\n\t * throw an alloc error.  The same guaranteed size must be available\n\t * as before the call.  This is not optimal now: we store the valstack\n\t * allocated size during entry; this value may be higher than the\n\t * minimal guarantee for an application.\n\t */\n\n\t/* XXX: this needs to be reworked so that we never shrink the value\n\t * stack on function entry so that we never need to grow it here.\n\t * Needing to grow here is a sandboxing issue because we need to\n\t * allocate which may cause an error in the error handling path\n\t * and thus propagate an error out of a protected call.\n\t */\n\n\t(void) duk_valstack_resize_raw((duk_context *) thr,\n\t                               entry_valstack_end,                    /* same as during entry */\n\t                               DUK_VSRESIZE_FLAG_SHRINK |             /* flags */\n\t                               DUK_VSRESIZE_FLAG_COMPACT |\n\t                               DUK_VSRESIZE_FLAG_THROW);\n\n\n\t/* These are just convenience \"wiping\" of state.  Side effects should\n\t * not be an issue here: thr->heap and thr->heap->lj have a stable\n\t * pointer.  Finalizer runs etc capture even out-of-memory errors so\n\t * nothing should throw here.\n\t */\n\tthr->heap->lj.type = DUK_LJ_TYPE_UNKNOWN;\n\tthr->heap->lj.iserror = 0;\n\tDUK_TVAL_SET_UNDEFINED_UPDREF(thr, &thr->heap->lj.value1);  /* side effects */\n\tDUK_TVAL_SET_UNDEFINED_UPDREF(thr, &thr->heap->lj.value2);  /* side effects */\n\n\t/* Restore entry thread executor curr_pc stack frame pointer. */\n\tthr->ptr_curr_pc = entry_ptr_curr_pc;\n\n\tDUK_HEAP_SWITCH_THREAD(thr->heap, entry_curr_thread);  /* may be NULL */\n\tthr->state = (duk_uint8_t) entry_thread_state;\n\n\t/* Disabled assert: triggered with some torture tests. */\n#if 0\n\tDUK_ASSERT((thr->state == DUK_HTHREAD_STATE_INACTIVE && thr->heap->curr_thread == NULL) ||  /* first call */\n\t           (thr->state == DUK_HTHREAD_STATE_INACTIVE && thr->heap->curr_thread != NULL) ||  /* other call */\n\t           (thr->state == DUK_HTHREAD_STATE_RUNNING && thr->heap->curr_thread == thr));     /* current thread */\n#endif\n\n\tthr->heap->call_recursion_depth = entry_call_recursion_depth;\n\n\t/* If the debugger is active we need to force an interrupt so that\n\t * debugger breakpoints are rechecked.  This is important for function\n\t * calls caused by side effects (e.g. when doing a DUK_OP_GETPROP), see\n\t * GH-303.  Only needed for success path, error path always causes a\n\t * breakpoint recheck in the executor.  It would be enough to set this\n\t * only when returning to an Ecmascript activation, but setting the flag\n\t * on every return should have no ill effect.\n\t */\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\tif (duk_debug_is_attached(thr->heap)) {\n\t\tDUK_DD(DUK_DDPRINT(\"returning with debugger enabled, force interrupt\"));\n\t\tDUK_ASSERT(thr->interrupt_counter <= thr->interrupt_init);\n\t\tthr->interrupt_init -= thr->interrupt_counter;\n\t\tthr->interrupt_counter = 0;\n\t\tthr->heap->dbg_force_restart = 1;\n\t}\n#endif\n\n#if defined(DUK_USE_INTERRUPT_COUNTER) && defined(DUK_USE_DEBUG)\n\tduk__interrupt_fixup(thr, entry_curr_thread);\n#endif\n\n\t/* Error handling complete, remove side effect protections and\n\t * process pending finalizers.\n\t */\n#if defined(DUK_USE_ASSERTIONS)\n\tDUK_ASSERT(thr->heap->error_not_allowed == 1);\n\tthr->heap->error_not_allowed = 0;\n#endif\n\tDUK_ASSERT(thr->heap->pf_prevent_count > 0);\n\tthr->heap->pf_prevent_count--;\n\tDUK_DD(DUK_DDPRINT(\"call error handled, pf_prevent_count updated to %ld\", (long) thr->heap->pf_prevent_count));\n\n\tDUK_ASSERT_LJSTATE_UNSET(thr->heap);\n\n\tDUK_REFZERO_CHECK_SLOW(thr);\n}\n\n/*\n *  duk_handle_safe_call(): make a \"C protected call\" within the\n *  current activation.\n *\n *  The allowed thread states for making a call are the same as for\n *  duk_handle_call_xxx().\n *\n *  Error handling is similar to duk_handle_call_xxx(); errors may be thrown\n *  (and result in a fatal error) for insane arguments.\n */\n\n/* XXX: bump preventcount by one for the duration of this call? */\n\nDUK_INTERNAL duk_int_t duk_handle_safe_call(duk_hthread *thr,\n                                            duk_safe_call_function func,\n                                            void *udata,\n                                            duk_idx_t num_stack_args,\n                                            duk_idx_t num_stack_rets) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_size_t entry_valstack_bottom_index;\n\tduk_size_t entry_callstack_top;\n\tduk_size_t entry_catchstack_top;\n\tduk_int_t entry_call_recursion_depth;\n\tduk_hthread *entry_curr_thread;\n\tduk_uint_fast8_t entry_thread_state;\n\tduk_instr_t **entry_ptr_curr_pc;\n\tduk_jmpbuf *old_jmpbuf_ptr = NULL;\n\tduk_jmpbuf our_jmpbuf;\n\tduk_idx_t idx_retbase;\n\tduk_int_t retval;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(ctx != NULL);\n\n\t/* Note: careful with indices like '-x'; if 'x' is zero, it refers to bottom */\n\tentry_valstack_bottom_index = (duk_size_t) (thr->valstack_bottom - thr->valstack);\n\tentry_callstack_top = thr->callstack_top;\n\tentry_catchstack_top = thr->catchstack_top;\n\tentry_call_recursion_depth = thr->heap->call_recursion_depth;\n\tentry_curr_thread = thr->heap->curr_thread;  /* Note: may be NULL if first call */\n\tentry_thread_state = thr->state;\n\tentry_ptr_curr_pc = thr->ptr_curr_pc;  /* may be NULL */\n\tidx_retbase = duk_get_top(ctx) - num_stack_args;  /* Note: not a valid stack index if num_stack_args == 0 */\n\n\t/* Note: cannot portably debug print a function pointer, hence 'func' not printed! */\n\tDUK_DD(DUK_DDPRINT(\"duk_handle_safe_call: thr=%p, num_stack_args=%ld, num_stack_rets=%ld, \"\n\t                   \"valstack_top=%ld, idx_retbase=%ld, rec_depth=%ld/%ld, \"\n\t                   \"entry_valstack_bottom_index=%ld, entry_callstack_top=%ld, entry_catchstack_top=%ld, \"\n\t                   \"entry_call_recursion_depth=%ld, entry_curr_thread=%p, entry_thread_state=%ld\",\n\t                   (void *) thr,\n\t                   (long) num_stack_args,\n\t                   (long) num_stack_rets,\n\t                   (long) duk_get_top(ctx),\n\t                   (long) idx_retbase,\n\t                   (long) thr->heap->call_recursion_depth,\n\t                   (long) thr->heap->call_recursion_limit,\n\t                   (long) entry_valstack_bottom_index,\n\t                   (long) entry_callstack_top,\n\t                   (long) entry_catchstack_top,\n\t                   (long) entry_call_recursion_depth,\n\t                   (void *) entry_curr_thread,\n\t                   (long) entry_thread_state));\n\n\tif (idx_retbase < 0) {\n\t\t/* Since stack indices are not reliable, we can't do anything useful\n\t\t * here.  Invoke the existing setjmp catcher, or if it doesn't exist,\n\t\t * call the fatal error handler.\n\t\t */\n\n\t\tDUK_ERROR_TYPE_INVALID_ARGS(thr);\n\t}\n\n\t/* setjmp catchpoint setup */\n\n\told_jmpbuf_ptr = thr->heap->lj.jmpbuf_ptr;\n\tthr->heap->lj.jmpbuf_ptr = &our_jmpbuf;\n\n#if defined(DUK_USE_CPP_EXCEPTIONS)\n\ttry {\n#else\n\tDUK_ASSERT(thr->heap->lj.jmpbuf_ptr == &our_jmpbuf);\n\tif (DUK_SETJMP(our_jmpbuf.jb) == 0) {\n\t\t/* Success path. */\n#endif\n\t\tDUK_DDD(DUK_DDDPRINT(\"safe_call setjmp catchpoint setup complete\"));\n\n\t\tduk__handle_safe_call_inner(thr,\n\t\t                            func,\n\t\t                            udata,\n\t\t                            idx_retbase,\n\t\t                            num_stack_rets,\n\t\t                            entry_valstack_bottom_index,\n\t\t                            entry_callstack_top,\n\t\t                            entry_catchstack_top);\n\n\t\t/* Note: either pointer may be NULL (at entry), so don't assert */\n\t\tthr->heap->lj.jmpbuf_ptr = old_jmpbuf_ptr;\n\n\t\tretval = DUK_EXEC_SUCCESS;\n#if defined(DUK_USE_CPP_EXCEPTIONS)\n\t} catch (duk_internal_exception &exc) {\n\t\tDUK_UNREF(exc);\n#else\n\t} else {\n\t\t/* Error path. */\n#endif\n\t\tduk__handle_safe_call_error(thr,\n\t\t                            idx_retbase,\n\t\t                            num_stack_rets,\n\t\t                            entry_valstack_bottom_index,\n\t\t                            entry_callstack_top,\n\t\t                            entry_catchstack_top,\n\t\t                            old_jmpbuf_ptr);\n\n\t\tretval = DUK_EXEC_ERROR;\n\t}\n#if defined(DUK_USE_CPP_EXCEPTIONS)\n\tcatch (std::exception &exc) {\n\t\tconst char *what = exc.what();\n\t\tif (!what) {\n\t\t\twhat = \"unknown\";\n\t\t}\n\t\tDUK_D(DUK_DPRINT(\"unexpected c++ std::exception (perhaps thrown by user code)\"));\n\t\ttry {\n\t\t\tDUK_ERROR_FMT1(thr, DUK_ERR_TYPE_ERROR, \"caught invalid c++ std::exception '%s' (perhaps thrown by user code)\", what);\n\t\t} catch (duk_internal_exception exc) {\n\t\t\tDUK_D(DUK_DPRINT(\"caught api error thrown from unexpected c++ std::exception\"));\n\t\t\tDUK_UNREF(exc);\n\t\t\tduk__handle_safe_call_error(thr,\n\t\t\t                            idx_retbase,\n\t\t\t                            num_stack_rets,\n\t\t\t                            entry_valstack_bottom_index,\n\t\t\t                            entry_callstack_top,\n\t\t\t                            entry_catchstack_top,\n\t\t\t                            old_jmpbuf_ptr);\n\t\t\tretval = DUK_EXEC_ERROR;\n\t\t}\n\t} catch (...) {\n\t\tDUK_D(DUK_DPRINT(\"unexpected c++ exception (perhaps thrown by user code)\"));\n\t\ttry {\n\t\t\tDUK_ERROR_TYPE(thr, \"caught invalid c++ exception (perhaps thrown by user code)\");\n\t\t} catch (duk_internal_exception exc) {\n\t\t\tDUK_D(DUK_DPRINT(\"caught api error thrown from unexpected c++ exception\"));\n\t\t\tDUK_UNREF(exc);\n\t\t\tduk__handle_safe_call_error(thr,\n\t\t\t                            idx_retbase,\n\t\t\t                            num_stack_rets,\n\t\t\t                            entry_valstack_bottom_index,\n\t\t\t                            entry_callstack_top,\n\t\t\t                            entry_catchstack_top,\n\t\t\t                            old_jmpbuf_ptr);\n\t\t\tretval = DUK_EXEC_ERROR;\n\t\t}\n\t}\n#endif\n\n\tDUK_ASSERT(thr->heap->lj.jmpbuf_ptr == old_jmpbuf_ptr);  /* success/error path both do this */\n\n\tDUK_ASSERT_LJSTATE_UNSET(thr->heap);\n\n\tduk__handle_safe_call_shared(thr,\n\t                             idx_retbase,\n\t                             num_stack_rets,\n\t                             entry_call_recursion_depth,\n\t                             entry_curr_thread,\n\t                             entry_thread_state,\n\t                             entry_ptr_curr_pc);\n\n\treturn retval;\n}\n\nDUK_LOCAL void duk__handle_safe_call_inner(duk_hthread *thr,\n                                           duk_safe_call_function func,\n                                           void *udata,\n                                           duk_idx_t idx_retbase,\n                                           duk_idx_t num_stack_rets,\n                                           duk_size_t entry_valstack_bottom_index,\n                                           duk_size_t entry_callstack_top,\n                                           duk_size_t entry_catchstack_top) {\n\tduk_context *ctx;\n\tduk_ret_t rc;\n\n\tDUK_ASSERT(thr != NULL);\n\tctx = (duk_context *) thr;\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_UNREF(entry_valstack_bottom_index);\n\tDUK_UNREF(entry_callstack_top);\n\tDUK_UNREF(entry_catchstack_top);\n\n\t/*\n\t *  Thread state check and book-keeping.\n\t */\n\n\tif (thr == thr->heap->curr_thread) {\n\t\t/* same thread */\n\t\tif (thr->state != DUK_HTHREAD_STATE_RUNNING) {\n\t\t\t/* should actually never happen, but check anyway */\n\t\t\tgoto thread_state_error;\n\t\t}\n\t} else {\n\t\t/* different thread */\n\t\tDUK_ASSERT(thr->heap->curr_thread == NULL ||\n\t\t           thr->heap->curr_thread->state == DUK_HTHREAD_STATE_RUNNING);\n\t\tif (thr->state != DUK_HTHREAD_STATE_INACTIVE) {\n\t\t\tgoto thread_state_error;\n\t\t}\n\t\tDUK_HEAP_SWITCH_THREAD(thr->heap, thr);\n\t\tthr->state = DUK_HTHREAD_STATE_RUNNING;\n\n\t\t/* Note: multiple threads may be simultaneously in the RUNNING\n\t\t * state, but not in the same \"resume chain\".\n\t\t */\n\t}\n\n\tDUK_ASSERT(thr->heap->curr_thread == thr);\n\tDUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING);\n\n\t/*\n\t *  Recursion limit check.\n\t *\n\t *  Note: there is no need for an \"ignore recursion limit\" flag\n\t *  for duk_handle_safe_call now.\n\t */\n\n\tDUK_ASSERT(thr->heap->call_recursion_depth >= 0);\n\tDUK_ASSERT(thr->heap->call_recursion_depth <= thr->heap->call_recursion_limit);\n\tif (thr->heap->call_recursion_depth >= thr->heap->call_recursion_limit) {\n\t\t/* XXX: error message is a bit misleading: we reached a recursion\n\t\t * limit which is also essentially the same as a C callstack limit\n\t\t * (except perhaps with some relaxed threading assumptions).\n\t\t */\n\t\tDUK_ERROR_RANGE(thr, DUK_STR_C_CALLSTACK_LIMIT);\n\t}\n\tthr->heap->call_recursion_depth++;\n\n\t/*\n\t *  Valstack spare check\n\t */\n\n\tduk_require_stack(ctx, 0);  /* internal spare */\n\n\t/*\n\t *  Make the C call\n\t */\n\n\trc = func(ctx, udata);\n\n\tDUK_DDD(DUK_DDDPRINT(\"safe_call, func rc=%ld\", (long) rc));\n\n\t/*\n\t *  Valstack manipulation for results.\n\t */\n\n\t/* we're running inside the caller's activation, so no change in call/catch stack or valstack bottom */\n\tDUK_ASSERT(thr->callstack_top == entry_callstack_top);\n\tDUK_ASSERT(thr->catchstack_top == entry_catchstack_top);\n\tDUK_ASSERT(thr->valstack_bottom >= thr->valstack);\n\tDUK_ASSERT((duk_size_t) (thr->valstack_bottom - thr->valstack) == entry_valstack_bottom_index);\n\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n\tDUK_ASSERT(thr->valstack_end >= thr->valstack_top);\n\n\tif (rc < 0) {\n\t\tduk_error_throw_from_negative_rc(thr, rc);\n\t}\n\tDUK_ASSERT(rc >= 0);\n\n\tif (duk_get_top(ctx) < rc) {\n\t\tDUK_ERROR_RANGE(thr, \"not enough stack values for safe_call rc\");\n\t}\n\n\tDUK_ASSERT(thr->catchstack_top == entry_catchstack_top);  /* no need to unwind */\n\tDUK_ASSERT(thr->callstack_top == entry_callstack_top);\n\n\tduk__safe_call_adjust_valstack(thr, idx_retbase, num_stack_rets, rc);\n\n\tDUK_ASSERT_LJSTATE_UNSET(thr->heap);\n\n\tDUK_REFZERO_CHECK_FAST(thr);\n\treturn;\n\n thread_state_error:\n\tDUK_ERROR_FMT1(thr, DUK_ERR_TYPE_ERROR, \"invalid thread state for safe_call (%ld)\", (long) thr->state);\n\tDUK_UNREACHABLE();\n}\n\nDUK_LOCAL void duk__handle_safe_call_error(duk_hthread *thr,\n                                           duk_idx_t idx_retbase,\n                                           duk_idx_t num_stack_rets,\n                                           duk_size_t entry_valstack_bottom_index,\n                                           duk_size_t entry_callstack_top,\n                                           duk_size_t entry_catchstack_top,\n                                           duk_jmpbuf *old_jmpbuf_ptr) {\n\tduk_context *ctx;\n\n\tDUK_ASSERT(thr != NULL);\n\tctx = (duk_context *) thr;\n\tDUK_ASSERT_CTX_VALID(ctx);\n\n\t/*\n\t *  Error during call.  The error value is at heap->lj.value1.\n\t *\n\t *  The very first thing we do is restore the previous setjmp catcher.\n\t *  This means that any error in error handling will propagate outwards\n\t *  instead of causing a setjmp() re-entry above.\n\t */\n\n\tDUK_DDD(DUK_DDDPRINT(\"error caught during protected duk_handle_safe_call()\"));\n\n\t/* Other longjmp types are handled by executor before propagating\n\t * the error here.\n\t */\n\tDUK_ASSERT(thr->heap->lj.type == DUK_LJ_TYPE_THROW);\n\tDUK_ASSERT_LJSTATE_SET(thr->heap);\n\tDUK_ASSERT(thr->callstack_top >= entry_callstack_top);\n\tDUK_ASSERT(thr->catchstack_top >= entry_catchstack_top);\n\n\t/* Note: either pointer may be NULL (at entry), so don't assert. */\n\tthr->heap->lj.jmpbuf_ptr = old_jmpbuf_ptr;\n\n\tDUK_ASSERT(thr->catchstack_top >= entry_catchstack_top);\n\tDUK_ASSERT(thr->callstack_top >= entry_callstack_top);\n\tduk_hthread_catchstack_unwind_norz(thr, entry_catchstack_top);\n\tduk_hthread_catchstack_shrink_check(thr);\n\tduk_hthread_callstack_unwind_norz(thr, entry_callstack_top);\n\tduk_hthread_callstack_shrink_check(thr);\n\tthr->valstack_bottom = thr->valstack + entry_valstack_bottom_index;\n\n\t/* [ ... | (crud) ] */\n\n\t/* XXX: space in valstack?  see discussion in duk_handle_call_xxx(). */\n\tduk_push_tval(ctx, &thr->heap->lj.value1);\n\n\t/* [ ... | (crud) errobj ] */\n\n\tDUK_ASSERT(duk_get_top(ctx) >= 1);  /* at least errobj must be on stack */\n\n\t/* check that the valstack has space for the final amount and any\n\t * intermediate space needed; this is unoptimal but should be safe\n\t */\n\tduk_require_stack_top(ctx, idx_retbase + num_stack_rets);  /* final configuration */\n\tduk_require_stack(ctx, num_stack_rets);\n\n\tduk__safe_call_adjust_valstack(thr, idx_retbase, num_stack_rets, 1);  /* 1 = num actual 'return values' */\n\n\t/* [ ... | ] or [ ... | errobj (M * undefined)] where M = num_stack_rets - 1 */\n\n\t/* These are just convenience \"wiping\" of state.  Side effects should\n\t * not be an issue here: thr->heap and thr->heap->lj have a stable\n\t * pointer.  Finalizer runs etc capture even out-of-memory errors so\n\t * nothing should throw here.\n\t */\n\tthr->heap->lj.type = DUK_LJ_TYPE_UNKNOWN;\n\tthr->heap->lj.iserror = 0;\n\tDUK_TVAL_SET_UNDEFINED_UPDREF(thr, &thr->heap->lj.value1);  /* side effects */\n\tDUK_TVAL_SET_UNDEFINED_UPDREF(thr, &thr->heap->lj.value2);  /* side effects */\n\n\t/* Error handling complete, remove side effect protections and\n\t * process pending finalizers.\n\t */\n#if defined(DUK_USE_ASSERTIONS)\n\tDUK_ASSERT(thr->heap->error_not_allowed == 1);\n\tthr->heap->error_not_allowed = 0;\n#endif\n\tDUK_ASSERT(thr->heap->pf_prevent_count > 0);\n\tthr->heap->pf_prevent_count--;\n\tDUK_DD(DUK_DDPRINT(\"safe call error handled, pf_prevent_count updated to %ld\", (long) thr->heap->pf_prevent_count));\n\n\tDUK_ASSERT_LJSTATE_UNSET(thr->heap);\n\n\tDUK_REFZERO_CHECK_SLOW(thr);\n}\n\nDUK_LOCAL void duk__handle_safe_call_shared(duk_hthread *thr,\n                                            duk_idx_t idx_retbase,\n                                            duk_idx_t num_stack_rets,\n                                            duk_int_t entry_call_recursion_depth,\n                                            duk_hthread *entry_curr_thread,\n                                            duk_uint_fast8_t entry_thread_state,\n                                            duk_instr_t **entry_ptr_curr_pc) {\n\tduk_context *ctx;\n\n\tDUK_ASSERT(thr != NULL);\n\tctx = (duk_context *) thr;\n\tDUK_ASSERT_CTX_VALID(ctx);\n\tDUK_UNREF(ctx);\n\tDUK_UNREF(idx_retbase);\n\tDUK_UNREF(num_stack_rets);\n\n\t/* Restore entry thread executor curr_pc stack frame pointer. */\n\tthr->ptr_curr_pc = entry_ptr_curr_pc;\n\n\t/* XXX: because we unwind stacks above, thr->heap->curr_thread is at\n\t * risk of pointing to an already freed thread.  This was indeed the\n\t * case in test-bug-multithread-valgrind.c, until duk_handle_call()\n\t * was fixed to restore thr->heap->curr_thread before rethrowing an\n\t * uncaught error.\n\t */\n\tDUK_HEAP_SWITCH_THREAD(thr->heap, entry_curr_thread);  /* may be NULL */\n\tthr->state = (duk_uint8_t) entry_thread_state;\n\n\tDUK_ASSERT((thr->state == DUK_HTHREAD_STATE_INACTIVE && thr->heap->curr_thread == NULL) ||  /* first call */\n\t           (thr->state == DUK_HTHREAD_STATE_INACTIVE && thr->heap->curr_thread != NULL) ||  /* other call */\n\t           (thr->state == DUK_HTHREAD_STATE_RUNNING && thr->heap->curr_thread == thr));     /* current thread */\n\n\tthr->heap->call_recursion_depth = entry_call_recursion_depth;\n\n\t/* stack discipline consistency check */\n\tDUK_ASSERT(duk_get_top(ctx) == idx_retbase + num_stack_rets);\n\n\t/* A debugger forced interrupt check is not needed here, as\n\t * problematic safe calls are not caused by side effects.\n\t */\n\n#if defined(DUK_USE_INTERRUPT_COUNTER) && defined(DUK_USE_DEBUG)\n\tduk__interrupt_fixup(thr, entry_curr_thread);\n#endif\n\n\tDUK_ASSERT_LJSTATE_UNSET(thr->heap);\n}\n\n/*\n *  Helper for handling an Ecmascript-to-Ecmascript call or an Ecmascript\n *  function (initial) Duktape.Thread.resume().\n *\n *  Compared to normal calls handled by duk_handle_call(), there are a\n *  bunch of differences:\n *\n *    - the call is never protected\n *    - there is no C recursion depth increase (hence an \"ignore recursion\n *      limit\" flag is not applicable)\n *    - instead of making the call, this helper just performs the thread\n *      setup and returns; the bytecode executor then restarts execution\n *      internally\n *    - ecmascript functions are never 'vararg' functions (they access\n *      varargs through the 'arguments' object)\n *\n *  The callstack of the target contains an earlier Ecmascript call in case\n *  of an Ecmascript-to-Ecmascript call (whose idx_retval is updated), or\n *  is empty in case of an initial Duktape.Thread.resume().\n *\n *  The first thing to do here is to figure out whether an ecma-to-ecma\n *  call is actually possible.  It's not always the case if the target is\n *  a bound function; the final function may be native.  In that case,\n *  return an error so caller can fall back to a normal call path.\n */\n\nDUK_INTERNAL duk_bool_t duk_handle_ecma_call_setup(duk_hthread *thr,\n                                                   duk_idx_t num_stack_args,\n                                                   duk_small_uint_t call_flags) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_size_t entry_valstack_bottom_index;\n\tduk_idx_t idx_func;     /* valstack index of 'func' and retval (relative to entry valstack_bottom) */\n\tduk_idx_t idx_args;     /* valstack index of start of args (arg1) (relative to entry valstack_bottom) */\n\tduk_idx_t nargs;        /* # argument registers target function wants (< 0 => never for ecma calls) */\n\tduk_idx_t nregs;        /* # total registers target function wants on entry (< 0 => never for ecma calls) */\n\tduk_hobject *func;      /* 'func' on stack (borrowed reference) */\n\tduk_tval *tv_func;      /* duk_tval ptr for 'func' on stack (borrowed reference) */\n\tduk_activation *act;\n\tduk_hobject *env;\n\tduk_bool_t use_tailcall;\n\tduk_instr_t **entry_ptr_curr_pc;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(!((call_flags & DUK_CALL_FLAG_IS_RESUME) != 0 && (call_flags & DUK_CALL_FLAG_IS_TAILCALL) != 0));\n\n\t/* XXX: assume these? */\n\tDUK_ASSERT(thr->valstack != NULL);\n\tDUK_ASSERT(thr->callstack != NULL);\n\tDUK_ASSERT(thr->catchstack != NULL);\n\n\t/* no need to handle thread state book-keeping here */\n\tDUK_ASSERT((call_flags & DUK_CALL_FLAG_IS_RESUME) != 0 ||\n\t           (thr->state == DUK_HTHREAD_STATE_RUNNING &&\n\t            thr->heap->curr_thread == thr));\n\n\t/* If thr->ptr_curr_pc is set, sync curr_pc to act->pc.  Then NULL\n\t * thr->ptr_curr_pc so that it's not accidentally used with an incorrect\n\t * activation when side effects occur.  If we end up not making the\n\t * call we must restore the value.\n\t */\n\tentry_ptr_curr_pc = thr->ptr_curr_pc;\n\tduk_hthread_sync_and_null_currpc(thr);\n\n\t/* if a tail call:\n\t *   - an Ecmascript activation must be on top of the callstack\n\t *   - there cannot be any active catchstack entries\n\t */\n#if defined(DUK_USE_ASSERTIONS)\n\tif (call_flags & DUK_CALL_FLAG_IS_TAILCALL) {\n\t\tduk_size_t our_callstack_index;\n\t\tduk_size_t i;\n\n\t\tDUK_ASSERT(thr->callstack_top >= 1);\n\t\tour_callstack_index = thr->callstack_top - 1;\n\t\tDUK_ASSERT_DISABLE(our_callstack_index >= 0);\n\t\tDUK_ASSERT(our_callstack_index < thr->callstack_size);\n\t\tDUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack + our_callstack_index) != NULL);\n\t\tDUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack + our_callstack_index)));\n\n\t\t/* No entry in the catchstack which would actually catch a\n\t\t * throw can refer to the callstack entry being reused.\n\t\t * There *can* be catchstack entries referring to the current\n\t\t * callstack entry as long as they don't catch (e.g. label sites).\n\t\t */\n\n\t\tfor (i = 0; i < thr->catchstack_top; i++) {\n\t\t\tDUK_ASSERT(thr->catchstack[i].callstack_index < our_callstack_index ||  /* refer to callstack entries below current */\n\t\t\t           DUK_CAT_GET_TYPE(thr->catchstack + i) == DUK_CAT_TYPE_LABEL); /* or a non-catching entry */\n\t\t}\n\t}\n#endif  /* DUK_USE_ASSERTIONS */\n\n\tentry_valstack_bottom_index = (duk_size_t) (thr->valstack_bottom - thr->valstack);\n\t/* XXX: rework */\n\tidx_func = duk_normalize_index(thr, -num_stack_args - 2);\n\tidx_args = idx_func + 2;\n\n\tDUK_DD(DUK_DDPRINT(\"handle_ecma_call_setup: thr=%p, \"\n\t                   \"num_stack_args=%ld, call_flags=0x%08lx (resume=%ld, tailcall=%ld), \"\n\t                   \"idx_func=%ld, idx_args=%ld, entry_valstack_bottom_index=%ld\",\n\t                   (void *) thr,\n\t                   (long) num_stack_args,\n\t                   (unsigned long) call_flags,\n\t                   (long) ((call_flags & DUK_CALL_FLAG_IS_RESUME) != 0 ? 1 : 0),\n\t                   (long) ((call_flags & DUK_CALL_FLAG_IS_TAILCALL) != 0 ? 1 : 0),\n\t                   (long) idx_func,\n\t                   (long) idx_args,\n\t                   (long) entry_valstack_bottom_index));\n\n\tif (DUK_UNLIKELY(idx_func < 0 || idx_args < 0)) {\n\t\t/* XXX: assert? compiler is responsible for this never happening */\n\t\tDUK_ERROR_TYPE_INVALID_ARGS(thr);\n\t}\n\n\t/*\n\t *  Check the function type, handle bound function chains, and prepare\n\t *  parameters for the rest of the call handling.  Also figure out the\n\t *  effective 'this' binding, which replaces the current value at\n\t *  idx_func + 1.\n\t *\n\t *  If the target function is a 'bound' one, follow the chain of 'bound'\n\t *  functions until a non-bound function is found.  During this process,\n\t *  bound arguments are 'prepended' to existing ones, and the \"this\"\n\t *  binding is overridden.  See E5 Section 15.3.4.5.1.\n\t *\n\t *  If the final target function cannot be handled by an ecma-to-ecma\n\t *  call, return to the caller with a return value indicating this case.\n\t *  The bound chain is resolved and the caller can resume with a plain\n\t *  function call.\n\t */\n\n\tfunc = duk__nonbound_func_lookup(ctx, idx_func, &num_stack_args, &tv_func, call_flags);\n\tif (func == NULL || !DUK_HOBJECT_IS_COMPFUNC(func)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"final target is a lightfunc/nativefunc, cannot do ecma-to-ecma call\"));\n\t\tthr->ptr_curr_pc = entry_ptr_curr_pc;\n\t\treturn 0;\n\t}\n\t/* XXX: tv_func is not actually needed */\n\n\tDUK_ASSERT(func != NULL);\n\tDUK_ASSERT(!DUK_HOBJECT_HAS_BOUNDFUNC(func));\n\tDUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(func));\n\n\tduk__coerce_effective_this_binding(thr, func, idx_func + 1);\n\tDUK_DDD(DUK_DDDPRINT(\"effective 'this' binding is: %!T\",\n\t                     duk_get_tval(ctx, idx_func + 1)));\n\n\tnargs = ((duk_hcompfunc *) func)->nargs;\n\tnregs = ((duk_hcompfunc *) func)->nregs;\n\tDUK_ASSERT(nregs >= nargs);\n\n\t/* [ ... func this arg1 ... argN ] */\n\n\t/*\n\t *  Preliminary activation record and valstack manipulation.\n\t *  The concrete actions depend on whether the we're dealing\n\t *  with a tail call (reuse an existing activation), a resume,\n\t *  or a normal call.\n\t *\n\t *  The basic actions, in varying order, are:\n\t *\n\t *    - Check stack size for call handling\n\t *    - Grow call stack if necessary (non-tail-calls)\n\t *    - Update current activation (idx_retval) if necessary\n\t *      (non-tail, non-resume calls)\n\t *    - Move start of args (idx_args) to valstack bottom\n\t *      (tail calls)\n\t *\n\t *  Don't touch valstack_bottom or valstack_top yet so that Duktape API\n\t *  calls work normally.\n\t */\n\n\t/* XXX: some overlapping code; cleanup */\n\tuse_tailcall = call_flags & DUK_CALL_FLAG_IS_TAILCALL;\n#if !defined(DUK_USE_TAILCALL)\n\tDUK_ASSERT(use_tailcall == 0);  /* compiler ensures this */\n#endif\n\tif (use_tailcall) {\n\t\t/* tailcall cannot be flagged to resume calls, and a\n\t\t * previous frame must exist\n\t\t */\n\t\tDUK_ASSERT(thr->callstack_top >= 1);\n\t\tDUK_ASSERT((call_flags & DUK_CALL_FLAG_IS_RESUME) == 0);\n\n\t\tact = thr->callstack_curr;\n\t\tDUK_ASSERT(act != NULL);\n\t\tif (act->flags & DUK_ACT_FLAG_PREVENT_YIELD) {\n\t\t\t/* See: test-bug-tailcall-preventyield-assert.c. */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"tail call prevented by current activation having DUK_ACT_FLAG_PREVENTYIELD\"));\n\t\t\tuse_tailcall = 0;\n\t\t} else if (DUK_HOBJECT_HAS_NOTAIL(func)) {\n\t\t\tDUK_D(DUK_DPRINT(\"tail call prevented by function having a notail flag\"));\n\t\t\tuse_tailcall = 0;\n\t\t}\n\t}\n\n\tif (use_tailcall) {\n\t\tduk_tval *tv1, *tv2;\n\t\tduk_size_t cs_index;\n\t\tduk_int_t i_stk;  /* must be signed for loop structure */\n\t\tduk_idx_t i_arg;\n\n\t\t/*\n\t\t *  Tailcall handling\n\t\t *\n\t\t *  Although the callstack entry is reused, we need to explicitly unwind\n\t\t *  the current activation (or simulate an unwind).  In particular, the\n\t\t *  current activation must be closed, otherwise something like\n\t\t *  test-bug-reduce-judofyr.js results.  Also catchstack needs be unwound\n\t\t *  because there may be non-error-catching label entries in valid tail calls.\n\t\t */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"is tail call, reusing activation at callstack top, at index %ld\",\n\t\t                     (long) (thr->callstack_top - 1)));\n\n\t\t/* 'act' already set above */\n\n\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_BOUNDFUNC(func));\n\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_NATFUNC(func));\n\t\tDUK_ASSERT(DUK_HOBJECT_HAS_COMPFUNC(func));\n\t\tDUK_ASSERT((act->flags & DUK_ACT_FLAG_PREVENT_YIELD) == 0);\n\n\t\t/* Unwind catchstack entries referring to the callstack entry we're reusing */\n\t\tcs_index = thr->callstack_top - 1;\n\t\tDUK_ASSERT(thr->catchstack_top <= DUK_INT_MAX);  /* catchstack limits */\n\t\tfor (i_stk = (duk_int_t) (thr->catchstack_top - 1); i_stk >= 0; i_stk--) {\n\t\t\tduk_catcher *cat = thr->catchstack + i_stk;\n\t\t\tif (cat->callstack_index != cs_index) {\n\t\t\t\t/* 'i' is the first entry we'll keep */\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tduk_hthread_catchstack_unwind_norz(thr, i_stk + 1);\n\n\t\t/* Unwind the topmost callstack entry before reusing it */\n\t\tDUK_ASSERT(thr->callstack_top > 0);\n\t\tduk_hthread_callstack_unwind_norz(thr, thr->callstack_top - 1);\n\n\t\t/* Then reuse the unwound activation; callstack was not shrunk so there is always space */\n\t\tDUK_ASSERT(thr->callstack_top < thr->callstack_size);\n\t\tact = thr->callstack + thr->callstack_top;\n\t\tthr->callstack_top++;\n\t\tthr->callstack_curr = act;\n\n\t\t/* Start filling in the activation */\n\t\tact->func = func;  /* don't want an intermediate exposed state with func == NULL */\n#if defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)\n\t\tact->prev_caller = NULL;\n#endif\n\t\tDUK_ASSERT(func != NULL);\n\t\tDUK_ASSERT(DUK_HOBJECT_HAS_COMPFUNC(func));\n\t\t/* don't want an intermediate exposed state with invalid pc */\n\t\tact->curr_pc = DUK_HCOMPFUNC_GET_CODE_BASE(thr->heap, (duk_hcompfunc *) func);\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\t\tact->prev_line = 0;\n#endif\n\t\tDUK_TVAL_SET_OBJECT(&act->tv_func, func);  /* borrowed, no refcount */\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\t\tDUK_HOBJECT_INCREF(thr, func);\n\t\tact = thr->callstack_curr;  /* side effects (currently none though) */\n#endif\n\n#if defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)\n#if defined(DUK_USE_TAILCALL)\n#error incorrect options: tail calls enabled with function caller property\n#endif\n\t\t/* XXX: this doesn't actually work properly for tail calls, so\n\t\t * tail calls are disabled when DUK_USE_NONSTD_FUNC_CALLER_PROPERTY\n\t\t * is in use.\n\t\t */\n\t\tduk__update_func_caller_prop(thr, func);\n\t\tact = thr->callstack_curr;\n#endif\n\n\t\tact->flags = (DUK_HOBJECT_HAS_STRICT(func) ?\n\t\t              DUK_ACT_FLAG_STRICT | DUK_ACT_FLAG_TAILCALLED :\n\t\t              DUK_ACT_FLAG_TAILCALLED);\n\n\t\tDUK_ASSERT(DUK_ACT_GET_FUNC(act) == func);      /* already updated */\n\t\tDUK_ASSERT(act->var_env == NULL);   /* already NULLed (by unwind) */\n\t\tDUK_ASSERT(act->lex_env == NULL);   /* already NULLed (by unwind) */\n\t\tact->idx_bottom = entry_valstack_bottom_index;  /* tail call -> reuse current \"frame\" */\n\t\tDUK_ASSERT(nregs >= 0);\n#if 0  /* topmost activation idx_retval is considered garbage, no need to init */\n\t\tact->idx_retval = 0;\n#endif\n\n\t\t/*\n\t\t *  Manipulate valstack so that args are on the current bottom and the\n\t\t *  previous caller's 'this' binding (which is the value preceding the\n\t\t *  current bottom) is replaced with the new 'this' binding:\n\t\t *\n\t\t *       [ ... this_old | (crud) func this_new arg1 ... argN ]\n\t\t *  -->  [ ... this_new | arg1 ... argN ]\n\t\t *\n\t\t *  For tail calling to work properly, the valstack bottom must not grow\n\t\t *  here; otherwise crud would accumulate on the valstack.\n\t\t */\n\n\t\ttv1 = thr->valstack_bottom - 1;\n\t\ttv2 = thr->valstack_bottom + idx_func + 1;\n\t\tDUK_ASSERT(tv1 >= thr->valstack && tv1 < thr->valstack_top);  /* tv1 is -below- valstack_bottom */\n\t\tDUK_ASSERT(tv2 >= thr->valstack_bottom && tv2 < thr->valstack_top);\n\t\tDUK_TVAL_SET_TVAL_UPDREF(thr, tv1, tv2);  /* side effects */\n\n\t\tfor (i_arg = 0; i_arg < idx_args; i_arg++) {\n\t\t\t/* XXX: block removal API primitive */\n\t\t\t/* Note: 'func' is popped from valstack here, but it is\n\t\t\t * already reachable from the activation.\n\t\t\t */\n\t\t\tduk_remove(ctx, 0);\n\t\t}\n\t\tidx_func = 0; DUK_UNREF(idx_func);  /* really 'not applicable' anymore, should not be referenced after this */\n\t\tidx_args = 0;\n\n\t\t/* [ ... this_new | arg1 ... argN ] */\n\t} else {\n\t\tDUK_DDD(DUK_DDDPRINT(\"not a tail call, pushing a new activation to callstack, to index %ld\",\n\t\t                     (long) (thr->callstack_top)));\n\n\t\tduk_hthread_callstack_grow(thr);\n\n\t\tif (call_flags & DUK_CALL_FLAG_IS_RESUME) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"is resume -> no update to current activation (may not even exist)\"));\n\t\t} else {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"update to current activation idx_retval\"));\n\t\t\tDUK_ASSERT(thr->callstack_top < thr->callstack_size);\n\t\t\tDUK_ASSERT(thr->callstack_top >= 1);\n\t\t\tact = thr->callstack_curr;\n\t\t\tDUK_ASSERT(DUK_ACT_GET_FUNC(act) != NULL);\n\t\t\tDUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(act)));\n\t\t\tact->idx_retval = entry_valstack_bottom_index + idx_func;\n\t\t}\n\n\t\tDUK_ASSERT(thr->callstack_top < thr->callstack_size);\n\t\tact = thr->callstack + thr->callstack_top;\n\t\tthr->callstack_top++;\n\t\tthr->callstack_curr = act;\n\t\tDUK_ASSERT(thr->callstack_top <= thr->callstack_size);\n\n\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_BOUNDFUNC(func));\n\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_NATFUNC(func));\n\t\tDUK_ASSERT(DUK_HOBJECT_HAS_COMPFUNC(func));\n\n\t\tact->flags = (DUK_HOBJECT_HAS_STRICT(func) ?\n\t\t              DUK_ACT_FLAG_STRICT :\n\t\t              0);\n\t\tact->func = func;\n\t\tact->var_env = NULL;\n\t\tact->lex_env = NULL;\n#if defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)\n\t\tact->prev_caller = NULL;\n#endif\n\t\tDUK_ASSERT(func != NULL);\n\t\tDUK_ASSERT(DUK_HOBJECT_HAS_COMPFUNC(func));\n\t\tact->curr_pc = DUK_HCOMPFUNC_GET_CODE_BASE(thr->heap, (duk_hcompfunc *) func);\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\t\tact->prev_line = 0;\n#endif\n\t\tact->idx_bottom = entry_valstack_bottom_index + idx_args;\n\t\tDUK_ASSERT(nregs >= 0);\n#if 0  /* topmost activation idx_retval is considered garbage, no need to init */\n\t\tact->idx_retval = 0;\n#endif\n\t\tDUK_TVAL_SET_OBJECT(&act->tv_func, func);  /* borrowed, no refcount */\n\n\t\tDUK_HOBJECT_INCREF(thr, func);  /* act->func */\n\n#if defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)\n\t\tduk__update_func_caller_prop(thr, func);\n\t\tact = thr->callstack_curr;\n#endif\n\t}\n\n\t/* [ ... func this arg1 ... argN ]  (not tail call)\n\t * [ this | arg1 ... argN ]         (tail call)\n\t *\n\t * idx_args updated to match\n\t */\n\n\t/*\n\t *  Environment record creation and 'arguments' object creation.\n\t *  Named function expression name binding is handled by the\n\t *  compiler; the compiled function's parent env will contain\n\t *  the (immutable) binding already.\n\t *\n\t *  Delayed creation (on demand) is handled in duk_js_var.c.\n\t */\n\n\t/* XXX: unify handling with native call. */\n\n\tDUK_ASSERT(!DUK_HOBJECT_HAS_BOUNDFUNC(func));  /* bound function chain has already been resolved */\n\n\tif (!DUK_HOBJECT_HAS_NEWENV(func)) {\n\t\t/* use existing env (e.g. for non-strict eval); cannot have\n\t\t * an own 'arguments' object (but can refer to the existing one)\n\t\t */\n\n\t\tduk__handle_oldenv_for_call(thr, func, act);\n\t\t/* No need to re-lookup 'act' at present: no side effects. */\n\n\t\tDUK_ASSERT(act->lex_env != NULL);\n\t\tDUK_ASSERT(act->var_env != NULL);\n\t\tgoto env_done;\n\t}\n\n\tDUK_ASSERT(DUK_HOBJECT_HAS_NEWENV(func));\n\n\tif (!DUK_HOBJECT_HAS_CREATEARGS(func)) {\n\t\t/* no need to create environment record now; leave as NULL */\n\t\tDUK_ASSERT(act->lex_env == NULL);\n\t\tDUK_ASSERT(act->var_env == NULL);\n\t\tgoto env_done;\n\t}\n\n\t/* third arg: absolute index (to entire valstack) of idx_bottom of new activation */\n\tenv = duk_create_activation_environment_record(thr, func, act->idx_bottom);\n\tDUK_ASSERT(env != NULL);\n\n\t/* [ ... arg1 ... argN envobj ] */\n\n\t/* original input stack before nargs/nregs handling must be\n\t * intact for 'arguments' object\n\t */\n\tDUK_ASSERT(DUK_HOBJECT_HAS_CREATEARGS(func));\n\tduk__handle_createargs_for_call(thr, func, env, num_stack_args);\n\n\t/* [ ... arg1 ... argN envobj ] */\n\n\tact = thr->callstack_curr;\n\tact->lex_env = env;\n\tact->var_env = env;\n\tDUK_HOBJECT_INCREF(thr, act->lex_env);\n\tDUK_HOBJECT_INCREF(thr, act->var_env);\n\tduk_pop(ctx);\n\n env_done:\n\t/* [ ... arg1 ... argN ] */\n\n\t/*\n\t *  Setup value stack: clamp to 'nargs', fill up to 'nregs'\n\t */\n\n\tduk__adjust_valstack_and_top(thr,\n\t                             num_stack_args,\n\t                             idx_args,\n\t                             nregs,\n\t                             nargs,\n\t                             func);\n\n\t/*\n\t *  Shift to new valstack_bottom.\n\t */\n\n\tthr->valstack_bottom = thr->valstack_bottom + idx_args;\n\t/* keep current valstack_top */\n\tDUK_ASSERT(thr->valstack_bottom >= thr->valstack);\n\tDUK_ASSERT(thr->valstack_top >= thr->valstack_bottom);\n\tDUK_ASSERT(thr->valstack_end >= thr->valstack_top);\n\n\t/*\n\t *  Return to bytecode executor, which will resume execution from\n\t *  the topmost activation.\n\t */\n\n\tDUK_REFZERO_CHECK_FAST(thr);\n\treturn 1;\n}\n/*\n *  Ecmascript compiler.\n *\n *  Parses an input string and generates a function template result.\n *  Compilation may happen in multiple contexts (global code, eval\n *  code, function code).\n *\n *  The parser uses a traditional top-down recursive parsing for the\n *  statement level, and an operator precedence based top-down approach\n *  for the expression level.  The attempt is to minimize the C stack\n *  depth.  Bytecode is generated directly without an intermediate\n *  representation (tree), at the cost of needing two (and sometimes\n *  three) passes over each function.\n *\n *  The top-down recursive parser functions are named \"duk__parse_XXX\".\n *\n *  Recursion limits are in key functions to prevent arbitrary C recursion:\n *  function body parsing, statement parsing, and expression parsing.\n *\n *  See doc/compiler.rst for discussion on the design.\n *\n *  A few typing notes:\n *\n *    - duk_regconst_t: unsigned, no marker value for \"none\"\n *    - duk_reg_t: signed, < 0 = none\n *    - PC values: duk_int_t, negative values used as markers\n */\n\n/* #include duk_internal.h -> already included */\n\n/* If highest bit of a register number is set, it refers to a constant instead.\n * When interpreted as a signed value, this means const values are always\n * negative (when interpreted as two's complement).  For example DUK__ISTEMP()\n * uses this approach to avoid an explicit DUK__ISREG() check (the condition is\n * logically \"'x' is a register AND 'x' >= temp_first\").\n */\n#define DUK__CONST_MARKER                   DUK_REGCONST_CONST_MARKER\n#define DUK__ISREG(x)                       (((x) & DUK__CONST_MARKER) == 0)\n#define DUK__ISCONST(x)                     (((x) & DUK__CONST_MARKER) != 0)\n#define DUK__REMOVECONST(x)                 ((x) & ~DUK__CONST_MARKER)\n#define DUK__ISTEMP(comp_ctx,x)             ((duk_int32_t) (x) >= (duk_int32_t) ((comp_ctx)->curr_func.temp_first))  /* Avoid DUK__ISREG() check by interpreting as negative value. */\n#define DUK__GETTEMP(comp_ctx)              ((comp_ctx)->curr_func.temp_next)\n#define DUK__SETTEMP(comp_ctx,x)            ((comp_ctx)->curr_func.temp_next = (x))  /* dangerous: must only lower (temp_max not updated) */\n#define DUK__SETTEMP_CHECKMAX(comp_ctx,x)   duk__settemp_checkmax((comp_ctx),(x))\n#define DUK__ALLOCTEMP(comp_ctx)            duk__alloctemp((comp_ctx))\n#define DUK__ALLOCTEMPS(comp_ctx,count)     duk__alloctemps((comp_ctx),(count))\n\n/* Init value set size for array and object literals. */\n#define DUK__MAX_ARRAY_INIT_VALUES        20\n#define DUK__MAX_OBJECT_INIT_PAIRS        10\n\n/* XXX: hack, remove when const lookup is not O(n) */\n#define DUK__GETCONST_MAX_CONSTS_CHECK    256\n\n/* These limits are based on bytecode limits.  Max temps is limited\n * by duk_hcompfunc nargs/nregs fields being 16 bits.\n */\n#define DUK__MAX_CONSTS                   DUK_BC_BC_MAX\n#define DUK__MAX_FUNCS                    DUK_BC_BC_MAX\n#define DUK__MAX_TEMPS                    0xffffL\n\n/* Initial bytecode size allocation. */\n#if defined(DUK_USE_PREFER_SIZE)\n#define DUK__BC_INITIAL_INSTS             16\n#else\n#define DUK__BC_INITIAL_INSTS             256\n#endif\n\n#define DUK__RECURSION_INCREASE(comp_ctx,thr)  do { \\\n\t\tDUK_DDD(DUK_DDDPRINT(\"RECURSION INCREASE: %s:%ld\", (const char *) DUK_FILE_MACRO, (long) DUK_LINE_MACRO)); \\\n\t\tduk__recursion_increase((comp_ctx)); \\\n\t} while (0)\n\n#define DUK__RECURSION_DECREASE(comp_ctx,thr)  do { \\\n\t\tDUK_DDD(DUK_DDDPRINT(\"RECURSION DECREASE: %s:%ld\", (const char *) DUK_FILE_MACRO, (long) DUK_LINE_MACRO)); \\\n\t\tduk__recursion_decrease((comp_ctx)); \\\n\t} while (0)\n\n/* Value stack slot limits: these are quite approximate right now, and\n * because they overlap in control flow, some could be eliminated.\n */\n#define DUK__COMPILE_ENTRY_SLOTS          8\n#define DUK__FUNCTION_INIT_REQUIRE_SLOTS  16\n#define DUK__FUNCTION_BODY_REQUIRE_SLOTS  16\n#define DUK__PARSE_STATEMENTS_SLOTS       16\n#define DUK__PARSE_EXPR_SLOTS             16\n\n/* Temporary structure used to pass a stack allocated region through\n * duk_safe_call().\n */\ntypedef struct {\n\tduk_small_uint_t flags;\n\tduk_compiler_ctx comp_ctx_alloc;\n\tduk_lexer_point lex_pt_alloc;\n} duk__compiler_stkstate;\n\n/*\n *  Prototypes\n */\n\n/* lexing */\nDUK_LOCAL_DECL void duk__advance_helper(duk_compiler_ctx *comp_ctx, duk_small_int_t expect);\nDUK_LOCAL_DECL void duk__advance_expect(duk_compiler_ctx *comp_ctx, duk_small_int_t expect);\nDUK_LOCAL_DECL void duk__advance(duk_compiler_ctx *ctx);\n\n/* function helpers */\nDUK_LOCAL_DECL void duk__init_func_valstack_slots(duk_compiler_ctx *comp_ctx);\nDUK_LOCAL_DECL void duk__reset_func_for_pass2(duk_compiler_ctx *comp_ctx);\nDUK_LOCAL_DECL void duk__init_varmap_and_prologue_for_pass2(duk_compiler_ctx *comp_ctx, duk_reg_t *out_stmt_value_reg);\nDUK_LOCAL_DECL void duk__convert_to_func_template(duk_compiler_ctx *comp_ctx);\nDUK_LOCAL_DECL duk_int_t duk__cleanup_varmap(duk_compiler_ctx *comp_ctx);\n\n/* code emission */\nDUK_LOCAL_DECL duk_int_t duk__get_current_pc(duk_compiler_ctx *comp_ctx);\nDUK_LOCAL_DECL duk_compiler_instr *duk__get_instr_ptr(duk_compiler_ctx *comp_ctx, duk_int_t pc);\nDUK_LOCAL_DECL void duk__emit(duk_compiler_ctx *comp_ctx, duk_instr_t ins);\nDUK_LOCAL_DECL void duk__emit_op_only(duk_compiler_ctx *comp_ctx, duk_small_uint_t op);\nDUK_LOCAL_DECL void duk__emit_a_b_c(duk_compiler_ctx *comp_ctx, duk_small_uint_t op_flags, duk_regconst_t a, duk_regconst_t b, duk_regconst_t c);\nDUK_LOCAL_DECL void duk__emit_a_b(duk_compiler_ctx *comp_ctx, duk_small_uint_t op_flags, duk_regconst_t a, duk_regconst_t b);\nDUK_LOCAL_DECL void duk__emit_b_c(duk_compiler_ctx *comp_ctx, duk_small_uint_t op_flags, duk_regconst_t b, duk_regconst_t c);\n#if 0  /* unused */\nDUK_LOCAL_DECL void duk__emit_a(duk_compiler_ctx *comp_ctx, duk_small_uint_t op_flags, duk_regconst_t a);\n#endif\nDUK_LOCAL_DECL void duk__emit_b(duk_compiler_ctx *comp_ctx, duk_small_uint_t op_flags, duk_regconst_t b);\nDUK_LOCAL_DECL void duk__emit_a_bc(duk_compiler_ctx *comp_ctx, duk_small_uint_t op_flags, duk_regconst_t a, duk_regconst_t bc);\nDUK_LOCAL_DECL void duk__emit_bc(duk_compiler_ctx *comp_ctx, duk_small_uint_t op, duk_regconst_t bc);\nDUK_LOCAL_DECL void duk__emit_abc(duk_compiler_ctx *comp_ctx, duk_small_uint_t op, duk_regconst_t abc);\nDUK_LOCAL_DECL void duk__emit_load_int32(duk_compiler_ctx *comp_ctx, duk_reg_t reg, duk_int32_t val);\nDUK_LOCAL_DECL void duk__emit_load_int32_noshuffle(duk_compiler_ctx *comp_ctx, duk_reg_t reg, duk_int32_t val);\nDUK_LOCAL_DECL void duk__emit_jump(duk_compiler_ctx *comp_ctx, duk_int_t target_pc);\nDUK_LOCAL_DECL duk_int_t duk__emit_jump_empty(duk_compiler_ctx *comp_ctx);\nDUK_LOCAL_DECL void duk__insert_jump_entry(duk_compiler_ctx *comp_ctx, duk_int_t jump_pc);\nDUK_LOCAL_DECL void duk__patch_jump(duk_compiler_ctx *comp_ctx, duk_int_t jump_pc, duk_int_t target_pc);\nDUK_LOCAL_DECL void duk__patch_jump_here(duk_compiler_ctx *comp_ctx, duk_int_t jump_pc);\nDUK_LOCAL_DECL void duk__patch_trycatch(duk_compiler_ctx *comp_ctx, duk_int_t ldconst_pc, duk_int_t trycatch_pc, duk_regconst_t reg_catch, duk_regconst_t const_varname, duk_small_uint_t flags);\nDUK_LOCAL_DECL void duk__emit_if_false_skip(duk_compiler_ctx *comp_ctx, duk_regconst_t regconst);\nDUK_LOCAL_DECL void duk__emit_if_true_skip(duk_compiler_ctx *comp_ctx, duk_regconst_t regconst);\nDUK_LOCAL_DECL void duk__emit_invalid(duk_compiler_ctx *comp_ctx);\n\n/* ivalue/ispec helpers */\nDUK_LOCAL_DECL void duk__ivalue_regconst(duk_ivalue *x, duk_regconst_t regconst);\nDUK_LOCAL_DECL void duk__ivalue_plain_fromstack(duk_compiler_ctx *comp_ctx, duk_ivalue *x);\nDUK_LOCAL_DECL void duk__ivalue_var_fromstack(duk_compiler_ctx *comp_ctx, duk_ivalue *x);\nDUK_LOCAL_DECL void duk__ivalue_var_hstring(duk_compiler_ctx *comp_ctx, duk_ivalue *x, duk_hstring *h);\nDUK_LOCAL_DECL void duk__copy_ispec(duk_compiler_ctx *comp_ctx, duk_ispec *src, duk_ispec *dst);\nDUK_LOCAL_DECL void duk__copy_ivalue(duk_compiler_ctx *comp_ctx, duk_ivalue *src, duk_ivalue *dst);\nDUK_LOCAL_DECL duk_reg_t duk__alloctemps(duk_compiler_ctx *comp_ctx, duk_small_int_t num);\nDUK_LOCAL_DECL duk_reg_t duk__alloctemp(duk_compiler_ctx *comp_ctx);\nDUK_LOCAL_DECL void duk__settemp_checkmax(duk_compiler_ctx *comp_ctx, duk_reg_t temp_next);\nDUK_LOCAL_DECL duk_regconst_t duk__getconst(duk_compiler_ctx *comp_ctx);\nDUK_LOCAL_DECL\nduk_regconst_t duk__ispec_toregconst_raw(duk_compiler_ctx *comp_ctx,\n                                         duk_ispec *x,\n                                         duk_reg_t forced_reg,\n                                         duk_small_uint_t flags);\nDUK_LOCAL_DECL void duk__ispec_toforcedreg(duk_compiler_ctx *comp_ctx, duk_ispec *x, duk_reg_t forced_reg);\nDUK_LOCAL_DECL void duk__ivalue_toplain_raw(duk_compiler_ctx *comp_ctx, duk_ivalue *x, duk_reg_t forced_reg);\nDUK_LOCAL_DECL void duk__ivalue_toplain(duk_compiler_ctx *comp_ctx, duk_ivalue *x);\nDUK_LOCAL_DECL void duk__ivalue_toplain_ignore(duk_compiler_ctx *comp_ctx, duk_ivalue *x);\nDUK_LOCAL_DECL\nduk_regconst_t duk__ivalue_toregconst_raw(duk_compiler_ctx *comp_ctx,\n                                          duk_ivalue *x,\n                                          duk_reg_t forced_reg,\n                                          duk_small_uint_t flags);\nDUK_LOCAL_DECL duk_reg_t duk__ivalue_toreg(duk_compiler_ctx *comp_ctx, duk_ivalue *x);\n#if 0  /* unused */\nDUK_LOCAL_DECL duk_reg_t duk__ivalue_totemp(duk_compiler_ctx *comp_ctx, duk_ivalue *x);\n#endif\nDUK_LOCAL_DECL void duk__ivalue_toforcedreg(duk_compiler_ctx *comp_ctx, duk_ivalue *x, duk_int_t forced_reg);\nDUK_LOCAL_DECL duk_regconst_t duk__ivalue_toregconst(duk_compiler_ctx *comp_ctx, duk_ivalue *x);\nDUK_LOCAL_DECL duk_regconst_t duk__ivalue_totempconst(duk_compiler_ctx *comp_ctx, duk_ivalue *x);\n\n/* identifier handling */\nDUK_LOCAL_DECL duk_reg_t duk__lookup_active_register_binding(duk_compiler_ctx *comp_ctx);\nDUK_LOCAL_DECL duk_bool_t duk__lookup_lhs(duk_compiler_ctx *ctx, duk_reg_t *out_reg_varbind, duk_regconst_t *out_rc_varname);\n\n/* label handling */\nDUK_LOCAL_DECL void duk__add_label(duk_compiler_ctx *comp_ctx, duk_hstring *h_label, duk_int_t pc_label, duk_int_t label_id);\nDUK_LOCAL_DECL void duk__update_label_flags(duk_compiler_ctx *comp_ctx, duk_int_t label_id, duk_small_uint_t flags);\nDUK_LOCAL_DECL void duk__lookup_active_label(duk_compiler_ctx *comp_ctx, duk_hstring *h_label, duk_bool_t is_break, duk_int_t *out_label_id, duk_int_t *out_label_catch_depth, duk_int_t *out_label_pc, duk_bool_t *out_is_closest);\nDUK_LOCAL_DECL void duk__reset_labels_to_length(duk_compiler_ctx *comp_ctx, duk_int_t len);\n\n/* top-down expression parser */\nDUK_LOCAL_DECL void duk__expr_nud(duk_compiler_ctx *comp_ctx, duk_ivalue *res);\nDUK_LOCAL_DECL void duk__expr_led(duk_compiler_ctx *comp_ctx, duk_ivalue *left, duk_ivalue *res);\nDUK_LOCAL_DECL duk_small_uint_t duk__expr_lbp(duk_compiler_ctx *comp_ctx);\nDUK_LOCAL_DECL duk_bool_t duk__expr_is_empty(duk_compiler_ctx *comp_ctx);\n\n/* exprtop is the top level variant which resets nud/led counts */\nDUK_LOCAL_DECL void duk__expr(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags);\nDUK_LOCAL_DECL void duk__exprtop(duk_compiler_ctx *ctx, duk_ivalue *res, duk_small_uint_t rbp_flags);\n\n/* convenience helpers */\n#if 0  /* unused */\nDUK_LOCAL_DECL duk_reg_t duk__expr_toreg(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags);\n#endif\n#if 0  /* unused */\nDUK_LOCAL_DECL duk_reg_t duk__expr_totemp(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags);\n#endif\nDUK_LOCAL_DECL void duk__expr_toforcedreg(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags, duk_reg_t forced_reg);\nDUK_LOCAL_DECL duk_regconst_t duk__expr_toregconst(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags);\n#if 0  /* unused */\nDUK_LOCAL_DECL duk_regconst_t duk__expr_totempconst(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags);\n#endif\nDUK_LOCAL_DECL void duk__expr_toplain(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags);\nDUK_LOCAL_DECL void duk__expr_toplain_ignore(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags);\nDUK_LOCAL_DECL duk_reg_t duk__exprtop_toreg(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags);\n#if 0  /* unused */\nDUK_LOCAL_DECL duk_reg_t duk__exprtop_totemp(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags);\n#endif\nDUK_LOCAL_DECL void duk__exprtop_toforcedreg(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags, duk_reg_t forced_reg);\nDUK_LOCAL_DECL duk_regconst_t duk__exprtop_toregconst(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags);\n#if 0  /* unused */\nDUK_LOCAL_DECL void duk__exprtop_toplain_ignore(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags);\n#endif\n\n/* expression parsing helpers */\nDUK_LOCAL_DECL duk_int_t duk__parse_arguments(duk_compiler_ctx *comp_ctx, duk_ivalue *res);\nDUK_LOCAL_DECL void duk__nud_array_literal(duk_compiler_ctx *comp_ctx, duk_ivalue *res);\nDUK_LOCAL_DECL void duk__nud_object_literal(duk_compiler_ctx *comp_ctx, duk_ivalue *res);\n\n/* statement parsing */\nDUK_LOCAL_DECL void duk__parse_var_decl(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t expr_flags, duk_reg_t *out_reg_varbind, duk_regconst_t *out_rc_varname);\nDUK_LOCAL_DECL void duk__parse_var_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t expr_flags);\nDUK_LOCAL_DECL void duk__parse_for_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_int_t pc_label_site);\nDUK_LOCAL_DECL void duk__parse_switch_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_int_t pc_label_site);\nDUK_LOCAL_DECL void duk__parse_if_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res);\nDUK_LOCAL_DECL void duk__parse_do_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_int_t pc_label_site);\nDUK_LOCAL_DECL void duk__parse_while_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_int_t pc_label_site);\nDUK_LOCAL_DECL void duk__parse_break_or_continue_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res);\nDUK_LOCAL_DECL void duk__parse_return_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res);\nDUK_LOCAL_DECL void duk__parse_throw_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res);\nDUK_LOCAL_DECL void duk__parse_try_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res);\nDUK_LOCAL_DECL void duk__parse_with_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res);\nDUK_LOCAL_DECL void duk__parse_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_bool_t allow_source_elem);\nDUK_LOCAL_DECL duk_int_t duk__stmt_label_site(duk_compiler_ctx *comp_ctx, duk_int_t label_id);\nDUK_LOCAL_DECL void duk__parse_stmts(duk_compiler_ctx *comp_ctx, duk_bool_t allow_source_elem, duk_bool_t expect_eof);\n\nDUK_LOCAL_DECL void duk__parse_func_body(duk_compiler_ctx *comp_ctx, duk_bool_t expect_eof, duk_bool_t implicit_return_value, duk_small_int_t expect_token);\nDUK_LOCAL_DECL void duk__parse_func_formals(duk_compiler_ctx *comp_ctx);\nDUK_LOCAL_DECL void duk__parse_func_like_raw(duk_compiler_ctx *comp_ctx, duk_small_uint_t flags);\nDUK_LOCAL_DECL duk_int_t duk__parse_func_like_fnum(duk_compiler_ctx *comp_ctx, duk_small_uint_t flags);\n\n#define DUK__FUNC_FLAG_DECL            (1 << 0)   /* Parsing a function declaration. */\n#define DUK__FUNC_FLAG_GETSET          (1 << 1)   /* Parsing an object literal getter/setter. */\n#define DUK__FUNC_FLAG_METDEF          (1 << 2)   /* Parsing an object literal method definition shorthand. */\n#define DUK__FUNC_FLAG_PUSHNAME_PASS1  (1 << 3)   /* Push function name when creating template (first pass only). */\n#define DUK__FUNC_FLAG_USE_PREVTOKEN   (1 << 4)   /* Use prev_token to start function parsing (workaround for object literal). */\n\n/*\n *  Parser control values for tokens.  The token table is ordered by the\n *  DUK_TOK_XXX defines.\n *\n *  The binding powers are for lbp() use (i.e. for use in led() context).\n *  Binding powers are positive for typing convenience, and bits at the\n *  top should be reserved for flags.  Binding power step must be higher\n *  than 1 so that binding power \"lbp - 1\" can be used for right associative\n *  operators.  Currently a step of 2 is used (which frees one more bit for\n *  flags).\n */\n\n/* XXX: actually single step levels would work just fine, clean up */\n\n/* binding power \"levels\" (see doc/compiler.rst) */\n#define DUK__BP_INVALID                0             /* always terminates led() */\n#define DUK__BP_EOF                    2\n#define DUK__BP_CLOSING                4             /* token closes expression, e.g. ')', ']' */\n#define DUK__BP_FOR_EXPR               DUK__BP_CLOSING    /* bp to use when parsing a top level Expression */\n#define DUK__BP_COMMA                  6\n#define DUK__BP_ASSIGNMENT             8\n#define DUK__BP_CONDITIONAL            10\n#define DUK__BP_LOR                    12\n#define DUK__BP_LAND                   14\n#define DUK__BP_BOR                    16\n#define DUK__BP_BXOR                   18\n#define DUK__BP_BAND                   20\n#define DUK__BP_EQUALITY               22\n#define DUK__BP_RELATIONAL             24\n#define DUK__BP_SHIFT                  26\n#define DUK__BP_ADDITIVE               28\n#define DUK__BP_MULTIPLICATIVE         30\n#define DUK__BP_EXPONENTIATION         32\n#define DUK__BP_POSTFIX                34\n#define DUK__BP_CALL                   36\n#define DUK__BP_MEMBER                 38\n\n#define DUK__TOKEN_LBP_BP_MASK         0x1f\n#define DUK__TOKEN_LBP_FLAG_NO_REGEXP  (1 << 5)   /* regexp literal must not follow this token */\n#define DUK__TOKEN_LBP_FLAG_TERMINATES (1 << 6)   /* terminates expression; e.g. post-increment/-decrement */\n#define DUK__TOKEN_LBP_FLAG_UNUSED     (1 << 7)   /* spare */\n\n#define DUK__TOKEN_LBP_GET_BP(x)       ((duk_small_uint_t) (((x) & DUK__TOKEN_LBP_BP_MASK) * 2))\n\n#define DUK__MK_LBP(bp)                ((bp) >> 1)    /* bp is assumed to be even */\n#define DUK__MK_LBP_FLAGS(bp,flags)    (((bp) >> 1) | (flags))\n\nDUK_LOCAL const duk_uint8_t duk__token_lbp[] = {\n\tDUK__MK_LBP(DUK__BP_EOF),                                 /* DUK_TOK_EOF */\n\tDUK__MK_LBP_FLAGS(DUK__BP_INVALID, DUK__TOKEN_LBP_FLAG_NO_REGEXP),  /* DUK_TOK_IDENTIFIER */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_BREAK */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_CASE */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_CATCH */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_CONTINUE */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_DEBUGGER */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_DEFAULT */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_DELETE */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_DO */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_ELSE */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_FINALLY */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_FOR */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_FUNCTION */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_IF */\n\tDUK__MK_LBP(DUK__BP_RELATIONAL),                          /* DUK_TOK_IN */\n\tDUK__MK_LBP(DUK__BP_RELATIONAL),                          /* DUK_TOK_INSTANCEOF */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_NEW */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_RETURN */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_SWITCH */\n\tDUK__MK_LBP_FLAGS(DUK__BP_INVALID, DUK__TOKEN_LBP_FLAG_NO_REGEXP),  /* DUK_TOK_THIS */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_THROW */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_TRY */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_TYPEOF */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_VAR */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_CONST */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_VOID */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_WHILE */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_WITH */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_CLASS */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_ENUM */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_EXPORT */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_EXTENDS */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_IMPORT */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_SUPER */\n\tDUK__MK_LBP_FLAGS(DUK__BP_INVALID, DUK__TOKEN_LBP_FLAG_NO_REGEXP),  /* DUK_TOK_NULL */\n\tDUK__MK_LBP_FLAGS(DUK__BP_INVALID, DUK__TOKEN_LBP_FLAG_NO_REGEXP),  /* DUK_TOK_TRUE */\n\tDUK__MK_LBP_FLAGS(DUK__BP_INVALID, DUK__TOKEN_LBP_FLAG_NO_REGEXP),  /* DUK_TOK_FALSE */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_GET */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_SET */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_IMPLEMENTS */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_INTERFACE */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_LET */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_PACKAGE */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_PRIVATE */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_PROTECTED */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_PUBLIC */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_STATIC */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_YIELD */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_LCURLY */\n\tDUK__MK_LBP_FLAGS(DUK__BP_INVALID, DUK__TOKEN_LBP_FLAG_NO_REGEXP),  /* DUK_TOK_RCURLY */\n\tDUK__MK_LBP(DUK__BP_MEMBER),                              /* DUK_TOK_LBRACKET */\n\tDUK__MK_LBP_FLAGS(DUK__BP_CLOSING, DUK__TOKEN_LBP_FLAG_NO_REGEXP),  /* DUK_TOK_RBRACKET */\n\tDUK__MK_LBP(DUK__BP_CALL),                                /* DUK_TOK_LPAREN */\n\tDUK__MK_LBP_FLAGS(DUK__BP_CLOSING, DUK__TOKEN_LBP_FLAG_NO_REGEXP),  /* DUK_TOK_RPAREN */\n\tDUK__MK_LBP(DUK__BP_MEMBER),                              /* DUK_TOK_PERIOD */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_SEMICOLON */\n\tDUK__MK_LBP(DUK__BP_COMMA),                               /* DUK_TOK_COMMA */\n\tDUK__MK_LBP(DUK__BP_RELATIONAL),                          /* DUK_TOK_LT */\n\tDUK__MK_LBP(DUK__BP_RELATIONAL),                          /* DUK_TOK_GT */\n\tDUK__MK_LBP(DUK__BP_RELATIONAL),                          /* DUK_TOK_LE */\n\tDUK__MK_LBP(DUK__BP_RELATIONAL),                          /* DUK_TOK_GE */\n\tDUK__MK_LBP(DUK__BP_EQUALITY),                            /* DUK_TOK_EQ */\n\tDUK__MK_LBP(DUK__BP_EQUALITY),                            /* DUK_TOK_NEQ */\n\tDUK__MK_LBP(DUK__BP_EQUALITY),                            /* DUK_TOK_SEQ */\n\tDUK__MK_LBP(DUK__BP_EQUALITY),                            /* DUK_TOK_SNEQ */\n\tDUK__MK_LBP(DUK__BP_ADDITIVE),                            /* DUK_TOK_ADD */\n\tDUK__MK_LBP(DUK__BP_ADDITIVE),                            /* DUK_TOK_SUB */\n\tDUK__MK_LBP(DUK__BP_MULTIPLICATIVE),                      /* DUK_TOK_MUL */\n\tDUK__MK_LBP(DUK__BP_MULTIPLICATIVE),                      /* DUK_TOK_DIV */\n\tDUK__MK_LBP(DUK__BP_MULTIPLICATIVE),                      /* DUK_TOK_MOD */\n\tDUK__MK_LBP(DUK__BP_EXPONENTIATION),                      /* DUK_TOK_EXP */\n\tDUK__MK_LBP(DUK__BP_POSTFIX),                             /* DUK_TOK_INCREMENT */\n\tDUK__MK_LBP(DUK__BP_POSTFIX),                             /* DUK_TOK_DECREMENT */\n\tDUK__MK_LBP(DUK__BP_SHIFT),                               /* DUK_TOK_ALSHIFT */\n\tDUK__MK_LBP(DUK__BP_SHIFT),                               /* DUK_TOK_ARSHIFT */\n\tDUK__MK_LBP(DUK__BP_SHIFT),                               /* DUK_TOK_RSHIFT */\n\tDUK__MK_LBP(DUK__BP_BAND),                                /* DUK_TOK_BAND */\n\tDUK__MK_LBP(DUK__BP_BOR),                                 /* DUK_TOK_BOR */\n\tDUK__MK_LBP(DUK__BP_BXOR),                                /* DUK_TOK_BXOR */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_LNOT */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_BNOT */\n\tDUK__MK_LBP(DUK__BP_LAND),                                /* DUK_TOK_LAND */\n\tDUK__MK_LBP(DUK__BP_LOR),                                 /* DUK_TOK_LOR */\n\tDUK__MK_LBP(DUK__BP_CONDITIONAL),                         /* DUK_TOK_QUESTION */\n\tDUK__MK_LBP(DUK__BP_INVALID),                             /* DUK_TOK_COLON */\n\tDUK__MK_LBP(DUK__BP_ASSIGNMENT),                          /* DUK_TOK_EQUALSIGN */\n\tDUK__MK_LBP(DUK__BP_ASSIGNMENT),                          /* DUK_TOK_ADD_EQ */\n\tDUK__MK_LBP(DUK__BP_ASSIGNMENT),                          /* DUK_TOK_SUB_EQ */\n\tDUK__MK_LBP(DUK__BP_ASSIGNMENT),                          /* DUK_TOK_MUL_EQ */\n\tDUK__MK_LBP(DUK__BP_ASSIGNMENT),                          /* DUK_TOK_DIV_EQ */\n\tDUK__MK_LBP(DUK__BP_ASSIGNMENT),                          /* DUK_TOK_MOD_EQ */\n\tDUK__MK_LBP(DUK__BP_ASSIGNMENT),                          /* DUK_TOK_EXP_EQ */\n\tDUK__MK_LBP(DUK__BP_ASSIGNMENT),                          /* DUK_TOK_ALSHIFT_EQ */\n\tDUK__MK_LBP(DUK__BP_ASSIGNMENT),                          /* DUK_TOK_ARSHIFT_EQ */\n\tDUK__MK_LBP(DUK__BP_ASSIGNMENT),                          /* DUK_TOK_RSHIFT_EQ */\n\tDUK__MK_LBP(DUK__BP_ASSIGNMENT),                          /* DUK_TOK_BAND_EQ */\n\tDUK__MK_LBP(DUK__BP_ASSIGNMENT),                          /* DUK_TOK_BOR_EQ */\n\tDUK__MK_LBP(DUK__BP_ASSIGNMENT),                          /* DUK_TOK_BXOR_EQ */\n\tDUK__MK_LBP_FLAGS(DUK__BP_INVALID, DUK__TOKEN_LBP_FLAG_NO_REGEXP),  /* DUK_TOK_NUMBER */\n\tDUK__MK_LBP_FLAGS(DUK__BP_INVALID, DUK__TOKEN_LBP_FLAG_NO_REGEXP),  /* DUK_TOK_STRING */\n\tDUK__MK_LBP_FLAGS(DUK__BP_INVALID, DUK__TOKEN_LBP_FLAG_NO_REGEXP),  /* DUK_TOK_REGEXP */\n};\n\n/*\n *  Misc helpers\n */\n\nDUK_LOCAL void duk__recursion_increase(duk_compiler_ctx *comp_ctx) {\n\tDUK_ASSERT(comp_ctx != NULL);\n\tDUK_ASSERT(comp_ctx->recursion_depth >= 0);\n\tif (comp_ctx->recursion_depth >= comp_ctx->recursion_limit) {\n\t\tDUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_COMPILER_RECURSION_LIMIT);\n\t}\n\tcomp_ctx->recursion_depth++;\n}\n\nDUK_LOCAL void duk__recursion_decrease(duk_compiler_ctx *comp_ctx) {\n\tDUK_ASSERT(comp_ctx != NULL);\n\tDUK_ASSERT(comp_ctx->recursion_depth > 0);\n\tcomp_ctx->recursion_depth--;\n}\n\nDUK_LOCAL duk_bool_t duk__hstring_is_eval_or_arguments(duk_compiler_ctx *comp_ctx, duk_hstring *h) {\n\tDUK_UNREF(comp_ctx);\n\tDUK_ASSERT(h != NULL);\n\treturn DUK_HSTRING_HAS_EVAL_OR_ARGUMENTS(h);\n}\n\nDUK_LOCAL duk_bool_t duk__hstring_is_eval_or_arguments_in_strict_mode(duk_compiler_ctx *comp_ctx, duk_hstring *h) {\n\tDUK_ASSERT(h != NULL);\n\treturn (comp_ctx->curr_func.is_strict &&\n\t        DUK_HSTRING_HAS_EVAL_OR_ARGUMENTS(h));\n}\n\n/*\n *  Parser duk__advance() token eating functions\n */\n\n/* XXX: valstack handling is awkward.  Add a valstack helper which\n * avoids dup():ing; valstack_copy(src, dst)?\n */\n\nDUK_LOCAL void duk__advance_helper(duk_compiler_ctx *comp_ctx, duk_small_int_t expect) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_bool_t regexp;\n\n\tDUK_ASSERT(comp_ctx->curr_token.t >= 0 && comp_ctx->curr_token.t <= DUK_TOK_MAXVAL);  /* MAXVAL is inclusive */\n\n\t/*\n\t *  Use current token to decide whether a RegExp can follow.\n\t *\n\t *  We can use either 't' or 't_nores'; the latter would not\n\t *  recognize keywords.  Some keywords can be followed by a\n\t *  RegExp (e.g. \"return\"), so using 't' is better.  This is\n\t *  not trivial, see doc/compiler.rst.\n\t */\n\n\tregexp = 1;\n\tif (duk__token_lbp[comp_ctx->curr_token.t] & DUK__TOKEN_LBP_FLAG_NO_REGEXP) {\n\t\tregexp = 0;\n\t}\n\tif (comp_ctx->curr_func.reject_regexp_in_adv) {\n\t\tcomp_ctx->curr_func.reject_regexp_in_adv = 0;\n\t\tregexp = 0;\n\t}\n\n\tif (expect >= 0 && comp_ctx->curr_token.t != expect) {\n\t\tDUK_D(DUK_DPRINT(\"parse error: expect=%ld, got=%ld\",\n\t\t                 (long) expect, (long) comp_ctx->curr_token.t));\n\t\tDUK_ERROR_SYNTAX(thr, DUK_STR_PARSE_ERROR);\n\t}\n\n\t/* make current token the previous; need to fiddle with valstack \"backing store\" */\n\tDUK_MEMCPY(&comp_ctx->prev_token, &comp_ctx->curr_token, sizeof(duk_token));\n\tduk_copy(ctx, comp_ctx->tok11_idx, comp_ctx->tok21_idx);\n\tduk_copy(ctx, comp_ctx->tok12_idx, comp_ctx->tok22_idx);\n\n\t/* parse new token */\n\tduk_lexer_parse_js_input_element(&comp_ctx->lex,\n\t                                 &comp_ctx->curr_token,\n\t                                 comp_ctx->curr_func.is_strict,\n\t                                 regexp);\n\n\tDUK_DDD(DUK_DDDPRINT(\"advance: curr: tok=%ld/%ld,%ld,term=%ld,%!T,%!T \"\n\t                     \"prev: tok=%ld/%ld,%ld,term=%ld,%!T,%!T\",\n\t                     (long) comp_ctx->curr_token.t,\n\t                     (long) comp_ctx->curr_token.t_nores,\n\t                     (long) comp_ctx->curr_token.start_line,\n\t                     (long) comp_ctx->curr_token.lineterm,\n\t                     (duk_tval *) duk_get_tval(ctx, comp_ctx->tok11_idx),\n\t                     (duk_tval *) duk_get_tval(ctx, comp_ctx->tok12_idx),\n\t                     (long) comp_ctx->prev_token.t,\n\t                     (long) comp_ctx->prev_token.t_nores,\n\t                     (long) comp_ctx->prev_token.start_line,\n\t                     (long) comp_ctx->prev_token.lineterm,\n\t                     (duk_tval *) duk_get_tval(ctx, comp_ctx->tok21_idx),\n\t                     (duk_tval *) duk_get_tval(ctx, comp_ctx->tok22_idx)));\n}\n\n/* advance, expecting current token to be a specific token; parse next token in regexp context */\nDUK_LOCAL void duk__advance_expect(duk_compiler_ctx *comp_ctx, duk_small_int_t expect) {\n\tduk__advance_helper(comp_ctx, expect);\n}\n\n/* advance, whatever the current token is; parse next token in regexp context */\nDUK_LOCAL void duk__advance(duk_compiler_ctx *comp_ctx) {\n\tduk__advance_helper(comp_ctx, -1);\n}\n\n/*\n *  Helpers for duk_compiler_func.\n */\n\n/* init function state: inits valstack allocations */\nDUK_LOCAL void duk__init_func_valstack_slots(duk_compiler_ctx *comp_ctx) {\n\tduk_compiler_func *func = &comp_ctx->curr_func;\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_idx_t entry_top;\n\n\tentry_top = duk_get_top(ctx);\n\n\tDUK_MEMZERO(func, sizeof(*func));  /* intentional overlap with earlier memzero */\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n\tfunc->h_name = NULL;\n\tfunc->h_consts = NULL;\n\tfunc->h_funcs = NULL;\n\tfunc->h_decls = NULL;\n\tfunc->h_labelnames = NULL;\n\tfunc->h_labelinfos = NULL;\n\tfunc->h_argnames = NULL;\n\tfunc->h_varmap = NULL;\n#endif\n\n\tduk_require_stack(ctx, DUK__FUNCTION_INIT_REQUIRE_SLOTS);\n\n\tDUK_BW_INIT_PUSHBUF(thr, &func->bw_code, DUK__BC_INITIAL_INSTS * sizeof(duk_compiler_instr));\n\t/* code_idx = entry_top + 0 */\n\n\tduk_push_array(ctx);\n\tfunc->consts_idx = entry_top + 1;\n\tfunc->h_consts = DUK_GET_HOBJECT_POSIDX(ctx, entry_top + 1);\n\tDUK_ASSERT(func->h_consts != NULL);\n\n\tduk_push_array(ctx);\n\tfunc->funcs_idx = entry_top + 2;\n\tfunc->h_funcs = DUK_GET_HOBJECT_POSIDX(ctx, entry_top + 2);\n\tDUK_ASSERT(func->h_funcs != NULL);\n\tDUK_ASSERT(func->fnum_next == 0);\n\n\tduk_push_array(ctx);\n\tfunc->decls_idx = entry_top + 3;\n\tfunc->h_decls = DUK_GET_HOBJECT_POSIDX(ctx, entry_top + 3);\n\tDUK_ASSERT(func->h_decls != NULL);\n\n\tduk_push_array(ctx);\n\tfunc->labelnames_idx = entry_top + 4;\n\tfunc->h_labelnames = DUK_GET_HOBJECT_POSIDX(ctx, entry_top + 4);\n\tDUK_ASSERT(func->h_labelnames != NULL);\n\n\tduk_push_dynamic_buffer(ctx, 0);\n\tfunc->labelinfos_idx = entry_top + 5;\n\tfunc->h_labelinfos = (duk_hbuffer_dynamic *) duk_known_hbuffer(ctx, entry_top + 5);\n\tDUK_ASSERT(func->h_labelinfos != NULL);\n\tDUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(func->h_labelinfos) && !DUK_HBUFFER_HAS_EXTERNAL(func->h_labelinfos));\n\n\tduk_push_array(ctx);\n\tfunc->argnames_idx = entry_top + 6;\n\tfunc->h_argnames = DUK_GET_HOBJECT_POSIDX(ctx, entry_top + 6);\n\tDUK_ASSERT(func->h_argnames != NULL);\n\n\tduk_push_bare_object(ctx);\n\tfunc->varmap_idx = entry_top + 7;\n\tfunc->h_varmap = DUK_GET_HOBJECT_POSIDX(ctx, entry_top + 7);\n\tDUK_ASSERT(func->h_varmap != NULL);\n}\n\n/* reset function state (prepare for pass 2) */\nDUK_LOCAL void duk__reset_func_for_pass2(duk_compiler_ctx *comp_ctx) {\n\tduk_compiler_func *func = &comp_ctx->curr_func;\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\n\t/* reset bytecode buffer but keep current size; pass 2 will\n\t * require same amount or more.\n\t */\n\tDUK_BW_RESET_SIZE(thr, &func->bw_code);\n\n\tduk_set_length(ctx, func->consts_idx, 0);\n\t/* keep func->h_funcs; inner functions are not reparsed to avoid O(depth^2) parsing */\n\tfunc->fnum_next = 0;\n\t/* duk_set_length(ctx, func->funcs_idx, 0); */\n\tduk_set_length(ctx, func->labelnames_idx, 0);\n\tduk_hbuffer_reset(thr, func->h_labelinfos);\n\t/* keep func->h_argnames; it is fixed for all passes */\n\n\t/* truncated in case pass 3 needed */\n\tduk_push_bare_object(ctx);\n\tduk_replace(ctx, func->varmap_idx);\n\tfunc->h_varmap = DUK_GET_HOBJECT_POSIDX(ctx, func->varmap_idx);\n\tDUK_ASSERT(func->h_varmap != NULL);\n}\n\n/* cleanup varmap from any null entries, compact it, etc; returns number\n * of final entries after cleanup.\n */\nDUK_LOCAL duk_int_t duk__cleanup_varmap(duk_compiler_ctx *comp_ctx) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hobject *h_varmap;\n\tduk_hstring *h_key;\n\tduk_tval *tv;\n\tduk_uint32_t i, e_next;\n\tduk_int_t ret;\n\n\t/* [ ... varmap ] */\n\n\th_varmap = DUK_GET_HOBJECT_NEGIDX(ctx, -1);\n\tDUK_ASSERT(h_varmap != NULL);\n\n\tret = 0;\n\te_next = DUK_HOBJECT_GET_ENEXT(h_varmap);\n\tfor (i = 0; i < e_next; i++) {\n\t\th_key = DUK_HOBJECT_E_GET_KEY(thr->heap, h_varmap, i);\n\t\tif (!h_key) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tDUK_ASSERT(!DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, h_varmap, i));\n\n\t\t/* The entries can either be register numbers or 'null' values.\n\t\t * Thus, no need to DECREF them and get side effects.  DECREF'ing\n\t\t * the keys (strings) can cause memory to be freed but no side\n\t\t * effects as strings don't have finalizers.  This is why we can\n\t\t * rely on the object properties not changing from underneath us.\n\t\t */\n\n\t\ttv = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, h_varmap, i);\n\t\tif (!DUK_TVAL_IS_NUMBER(tv)) {\n\t\t\tDUK_ASSERT(!DUK_TVAL_IS_HEAP_ALLOCATED(tv));\n\t\t\tDUK_HOBJECT_E_SET_KEY(thr->heap, h_varmap, i, NULL);\n\t\t\tDUK_HSTRING_DECREF(thr, h_key);\n\t\t\t/* when key is NULL, value is garbage so no need to set */\n\t\t} else {\n\t\t\tret++;\n\t\t}\n\t}\n\n\tduk_compact_m1(ctx);\n\n\treturn ret;\n}\n\n/* Convert duk_compiler_func into a function template, leaving the result\n * on top of stack.\n */\n/* XXX: awkward and bloated asm -- use faster internal accesses */\nDUK_LOCAL void duk__convert_to_func_template(duk_compiler_ctx *comp_ctx) {\n\tduk_compiler_func *func = &comp_ctx->curr_func;\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hcompfunc *h_res;\n\tduk_hbuffer_fixed *h_data;\n\tduk_size_t consts_count;\n\tduk_size_t funcs_count;\n\tduk_size_t code_count;\n\tduk_size_t code_size;\n\tduk_size_t data_size;\n\tduk_size_t i;\n\tduk_tval *p_const;\n\tduk_hobject **p_func;\n\tduk_instr_t *p_instr;\n\tduk_compiler_instr *q_instr;\n\tduk_tval *tv;\n\tduk_bool_t keep_varmap;\n\tduk_bool_t keep_formals;\n#if !defined(DUK_USE_DEBUGGER_SUPPORT)\n\tduk_size_t formals_length;\n#endif\n\n\tDUK_DDD(DUK_DDDPRINT(\"converting duk_compiler_func to function/template\"));\n\n\t/*\n\t *  Push result object and init its flags\n\t */\n\n\t/* Valstack should suffice here, required on function valstack init */\n\n\th_res = duk_push_hcompfunc(ctx);\n\tDUK_ASSERT(h_res != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_GET_PROTOTYPE(thr->heap, (duk_hobject *) h_res) == thr->builtins[DUK_BIDX_FUNCTION_PROTOTYPE]);\n\tDUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, (duk_hobject *) h_res, NULL);  /* Function templates are \"bare objects\". */\n\n\tif (func->is_function) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"function -> set NEWENV\"));\n\t\tDUK_HOBJECT_SET_NEWENV((duk_hobject *) h_res);\n\n\t\tif (!func->is_arguments_shadowed) {\n\t\t\t/* arguments object would be accessible; note that shadowing\n\t\t\t * bindings are arguments or function declarations, neither\n\t\t\t * of which are deletable, so this is safe.\n\t\t\t */\n\n\t\t\tif (func->id_access_arguments || func->may_direct_eval) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"function may access 'arguments' object directly or \"\n\t\t\t\t                     \"indirectly -> set CREATEARGS\"));\n\t\t\t\tDUK_HOBJECT_SET_CREATEARGS((duk_hobject *) h_res);\n\t\t\t}\n\t\t}\n\t} else if (func->is_eval && func->is_strict) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"strict eval code -> set NEWENV\"));\n\t\tDUK_HOBJECT_SET_NEWENV((duk_hobject *) h_res);\n\t} else {\n\t\t/* non-strict eval: env is caller's env or global env (direct vs. indirect call)\n\t\t * global code: env is is global env\n\t\t */\n\t\tDUK_DDD(DUK_DDDPRINT(\"non-strict eval code or global code -> no NEWENV\"));\n\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_NEWENV((duk_hobject *) h_res));\n\t}\n\n#if defined(DUK_USE_FUNC_NAME_PROPERTY)\n\tif (func->is_function && func->is_namebinding && func->h_name != NULL) {\n\t\t/* Object literal set/get functions have a name (property\n\t\t * name) but must not have a lexical name binding, see\n\t\t * test-bug-getset-func-name.js.\n\t\t */\n\t\tDUK_DDD(DUK_DDDPRINT(\"function expression with a name -> set NAMEBINDING\"));\n\t\tDUK_HOBJECT_SET_NAMEBINDING((duk_hobject *) h_res);\n\t}\n#endif\n\n\tif (func->is_strict) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"function is strict -> set STRICT\"));\n\t\tDUK_HOBJECT_SET_STRICT((duk_hobject *) h_res);\n\t}\n\n\tif (func->is_notail) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"function is notail -> set NOTAIL\"));\n\t\tDUK_HOBJECT_SET_NOTAIL((duk_hobject *) h_res);\n\t}\n\n\tif (func->is_constructable) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"function is constructable -> set CONSTRUCTABLE\"));\n\t\tDUK_HOBJECT_SET_CONSTRUCTABLE((duk_hobject *) h_res);\n\t}\n\n\t/*\n\t *  Build function fixed size 'data' buffer, which contains bytecode,\n\t *  constants, and inner function references.\n\t *\n\t *  During the building phase 'data' is reachable but incomplete.\n\t *  Only incref's occur during building (no refzero or GC happens),\n\t *  so the building process is atomic.\n\t */\n\n\tconsts_count = duk_hobject_get_length(thr, func->h_consts);\n\tfuncs_count = duk_hobject_get_length(thr, func->h_funcs) / 3;\n\tcode_count = DUK_BW_GET_SIZE(thr, &func->bw_code) / sizeof(duk_compiler_instr);\n\tcode_size = code_count * sizeof(duk_instr_t);\n\n\tdata_size = consts_count * sizeof(duk_tval) +\n\t            funcs_count * sizeof(duk_hobject *) +\n\t            code_size;\n\n\tDUK_DDD(DUK_DDDPRINT(\"consts_count=%ld, funcs_count=%ld, code_size=%ld -> \"\n\t                     \"data_size=%ld*%ld + %ld*%ld + %ld = %ld\",\n\t                     (long) consts_count, (long) funcs_count, (long) code_size,\n\t                     (long) consts_count, (long) sizeof(duk_tval),\n\t                     (long) funcs_count, (long) sizeof(duk_hobject *),\n\t                     (long) code_size, (long) data_size));\n\n\tduk_push_fixed_buffer_nozero(ctx, data_size);\n\th_data = (duk_hbuffer_fixed *) duk_known_hbuffer(ctx, -1);\n\n\tDUK_HCOMPFUNC_SET_DATA(thr->heap, h_res, (duk_hbuffer *) h_data);\n\tDUK_HEAPHDR_INCREF(thr, h_data);\n\n\tp_const = (duk_tval *) (void *) DUK_HBUFFER_FIXED_GET_DATA_PTR(thr->heap, h_data);\n\tfor (i = 0; i < consts_count; i++) {\n\t\tDUK_ASSERT(i <= DUK_UARRIDX_MAX);  /* const limits */\n\t\ttv = duk_hobject_find_existing_array_entry_tval_ptr(thr->heap, func->h_consts, (duk_uarridx_t) i);\n\t\tDUK_ASSERT(tv != NULL);\n\t\tDUK_TVAL_SET_TVAL(p_const, tv);\n\t\tp_const++;\n\t\tDUK_TVAL_INCREF(thr, tv);  /* may be a string constant */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"constant: %!T\", (duk_tval *) tv));\n\t}\n\n\tp_func = (duk_hobject **) p_const;\n\tDUK_HCOMPFUNC_SET_FUNCS(thr->heap, h_res, p_func);\n\tfor (i = 0; i < funcs_count; i++) {\n\t\tduk_hobject *h;\n\t\tDUK_ASSERT(i * 3 <= DUK_UARRIDX_MAX);  /* func limits */\n\t\ttv = duk_hobject_find_existing_array_entry_tval_ptr(thr->heap, func->h_funcs, (duk_uarridx_t) (i * 3));\n\t\tDUK_ASSERT(tv != NULL);\n\t\tDUK_ASSERT(DUK_TVAL_IS_OBJECT(tv));\n\t\th = DUK_TVAL_GET_OBJECT(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\tDUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(h));\n\t\t*p_func++ = h;\n\t\tDUK_HOBJECT_INCREF(thr, h);\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"inner function: %p -> %!iO\",\n\t\t                     (void *) h, (duk_heaphdr *) h));\n\t}\n\n\tp_instr = (duk_instr_t *) p_func;\n\tDUK_HCOMPFUNC_SET_BYTECODE(thr->heap, h_res, p_instr);\n\n\t/* copy bytecode instructions one at a time */\n\tq_instr = (duk_compiler_instr *) (void *) DUK_BW_GET_BASEPTR(thr, &func->bw_code);\n\tfor (i = 0; i < code_count; i++) {\n\t\tp_instr[i] = q_instr[i].ins;\n\t}\n\t/* Note: 'q_instr' is still used below */\n\n\tDUK_ASSERT((duk_uint8_t *) (p_instr + code_count) == DUK_HBUFFER_FIXED_GET_DATA_PTR(thr->heap, h_data) + data_size);\n\n\tduk_pop(ctx);  /* 'data' (and everything in it) is reachable through h_res now */\n\n\t/*\n\t *  Init non-property result fields\n\t *\n\t *  'nregs' controls how large a register frame is allocated.\n\t *\n\t *  'nargs' controls how many formal arguments are written to registers:\n\t *  r0, ... r(nargs-1).  The remaining registers are initialized to\n\t *  undefined.\n\t */\n\n\tDUK_ASSERT(func->temp_max >= 0);\n\th_res->nregs = (duk_uint16_t) func->temp_max;\n\th_res->nargs = (duk_uint16_t) duk_hobject_get_length(thr, func->h_argnames);\n\tDUK_ASSERT(h_res->nregs >= h_res->nargs);  /* pass2 allocation handles this */\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\th_res->start_line = (duk_uint32_t) func->min_line;\n\th_res->end_line = (duk_uint32_t) func->max_line;\n#endif\n\n\t/*\n\t *  Init object properties\n\t *\n\t *  Properties should be added in decreasing order of access frequency.\n\t *  (Not very critical for function templates.)\n\t */\n\n\tDUK_DDD(DUK_DDDPRINT(\"init function properties\"));\n\n\t/* [ ... res ] */\n\n\t/* _Varmap: omitted if function is guaranteed not to do a slow path\n\t * identifier access that might be caught by locally declared variables.\n\t * The varmap can also be omitted if it turns out empty of actual\n\t * register mappings after a cleanup.  When debugging is enabled, we\n\t * always need the varmap to be able to lookup variables at any point.\n\t */\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\tDUK_DD(DUK_DDPRINT(\"keeping _Varmap because debugger support is enabled\"));\n\tkeep_varmap = 1;\n#else\n\tif (func->id_access_slow_own ||   /* directly uses slow accesses that may match own variables */\n\t    func->id_access_arguments ||  /* accesses 'arguments' directly */\n\t    func->may_direct_eval ||      /* may indirectly slow access through a direct eval */\n\t    funcs_count > 0) {            /* has inner functions which may slow access (XXX: this can be optimized by looking at the inner functions) */\n\t\tDUK_DD(DUK_DDPRINT(\"keeping _Varmap because of direct eval, slow path access that may match local variables, or presence of inner functions\"));\n\t\tkeep_varmap = 1;\n\t} else {\n\t\tDUK_DD(DUK_DDPRINT(\"dropping _Varmap\"));\n\t\tkeep_varmap = 0;\n\t}\n#endif\n\n\tif (keep_varmap) {\n\t\tduk_int_t num_used;\n\t\tduk_dup(ctx, func->varmap_idx);\n\t\tnum_used = duk__cleanup_varmap(comp_ctx);\n\t\tDUK_DDD(DUK_DDDPRINT(\"cleaned up varmap: %!T (num_used=%ld)\",\n\t\t                     (duk_tval *) duk_get_tval(ctx, -1), (long) num_used));\n\n\t\tif (num_used > 0) {\n\t\t\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_VARMAP, DUK_PROPDESC_FLAGS_NONE);\n\t\t} else {\n\t\t\tDUK_DD(DUK_DDPRINT(\"varmap is empty after cleanup -> no need to add\"));\n\t\t\tduk_pop(ctx);\n\t\t}\n\t}\n\n\t/* _Formals: omitted if function is guaranteed not to need a (non-strict)\n\t * arguments object, and _Formals.length matches nargs exactly.\n\t *\n\t * Non-arrow functions can't see an outer function's 'argument' binding\n\t * (because they have their own), but arrow functions can.  When arrow\n\t * functions are added, this condition would need to be added:\n\t *     inner_arrow_funcs_count > 0   inner arrow functions may access 'arguments'\n\t */\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\tDUK_DD(DUK_DDPRINT(\"keeping _Formals because debugger support is enabled\"));\n\tkeep_formals = 1;\n#else\n\tformals_length = duk_get_length(ctx, func->argnames_idx);\n\tif (formals_length != (duk_size_t) h_res->nargs) {\n\t\t/* Nargs not enough for closure .length: keep _Formals regardless\n\t\t * of its length.  Shouldn't happen in practice at the moment.\n\t\t */\n\t\tDUK_DD(DUK_DDPRINT(\"keeping _Formals because _Formals.length != nargs\"));\n\t\tkeep_formals = 1;\n\t} else if ((func->id_access_arguments || func->may_direct_eval) &&\n\t           (formals_length > 0)) {\n\t\t/* Direct eval (may access 'arguments') or accesses 'arguments'\n\t\t * explicitly: keep _Formals unless it is zero length.\n\t\t */\n\t\tDUK_DD(DUK_DDPRINT(\"keeping _Formals because of direct eval or explicit access to 'arguments', and _Formals.length != 0\"));\n\t\tkeep_formals = 1;\n\t} else {\n\t\tDUK_DD(DUK_DDPRINT(\"omitting _Formals, nargs matches _Formals.length, so no properties added\"));\n\t\tkeep_formals = 0;\n\t}\n#endif\n\n\tif (keep_formals) {\n\t\tduk_dup(ctx, func->argnames_idx);\n\t\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_FORMALS, DUK_PROPDESC_FLAGS_NONE);\n\t}\n\n\t/* name */\n#if defined(DUK_USE_FUNC_NAME_PROPERTY)\n\tif (func->h_name) {\n\t\tduk_push_hstring(ctx, func->h_name);\n\t\tDUK_DD(DUK_DDPRINT(\"setting function template .name to %!T\", duk_get_tval(ctx, -1)));\n\t\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_NAME, DUK_PROPDESC_FLAGS_NONE);\n\t}\n#endif  /* DUK_USE_FUNC_NAME_PROPERTY */\n\n\t/* _Source */\n#if defined(DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY)\n\tif (0) {\n\t\t/* XXX: Currently function source code is not stored, as it is not\n\t\t * required by the standard.  Source code should not be stored by\n\t\t * default (user should enable it explicitly), and the source should\n\t\t * probably be compressed with a trivial text compressor; average\n\t\t * compression of 20-30% is quite easy to achieve even with a trivial\n\t\t * compressor (RLE + backwards lookup).\n\t\t *\n\t\t * Debugging needs source code to be useful: sometimes input code is\n\t\t * not found in files as it may be generated and then eval()'d, given\n\t\t * by dynamic C code, etc.\n\t\t *\n\t\t * Other issues:\n\t\t *\n\t\t *   - Need tokenizer indices for start and end to substring\n\t\t *   - Always normalize function declaration part?\n\t\t *   - If we keep _Formals, only need to store body\n\t\t */\n\n\t\t/*\n\t\t *  For global or eval code this is straightforward.  For functions\n\t\t *  created with the Function constructor we only get the source for\n\t\t *  the body and must manufacture the \"function ...\" part.\n\t\t *\n\t\t *  For instance, for constructed functions (v8):\n\t\t *\n\t\t *    > a = new Function(\"foo\", \"bar\", \"print(foo)\");\n\t\t *    [Function]\n\t\t *    > a.toString()\n\t\t *    'function anonymous(foo,bar) {\\nprint(foo)\\n}'\n\t\t *\n\t\t *  Similarly for e.g. getters (v8):\n\t\t *\n\t\t *    > x = { get a(foo,bar) { print(foo); } }\n\t\t *    { a: [Getter] }\n\t\t *    > Object.getOwnPropertyDescriptor(x, 'a').get.toString()\n\t\t *    'function a(foo,bar) { print(foo); }'\n\t\t */\n\n#if 0\n\t\tduk_push_string(ctx, \"XXX\");\n\t\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_SOURCE, DUK_PROPDESC_FLAGS_NONE);\n#endif\n\t}\n#endif  /* DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY */\n\n\t/* _Pc2line */\n#if defined(DUK_USE_PC2LINE)\n\tif (1) {\n\t\t/*\n\t\t *  Size-optimized pc->line mapping.\n\t\t */\n\n\t\tDUK_ASSERT(code_count <= DUK_COMPILER_MAX_BYTECODE_LENGTH);\n\t\tduk_hobject_pc2line_pack(thr, q_instr, (duk_uint_fast32_t) code_count);  /* -> pushes fixed buffer */\n\t\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_PC2LINE, DUK_PROPDESC_FLAGS_NONE);\n\n\t\t/* XXX: if assertions enabled, walk through all valid PCs\n\t\t * and check line mapping.\n\t\t */\n\t}\n#endif  /* DUK_USE_PC2LINE */\n\n\t/* fileName */\n#if defined(DUK_USE_FUNC_FILENAME_PROPERTY)\n\tif (comp_ctx->h_filename) {\n\t\t/*\n\t\t *  Source filename (or equivalent), for identifying thrown errors.\n\t\t */\n\n\t\tduk_push_hstring(ctx, comp_ctx->h_filename);\n\t\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_FILE_NAME, DUK_PROPDESC_FLAGS_NONE);\n\t}\n#endif\n\n\tDUK_DD(DUK_DDPRINT(\"converted function: %!ixT\",\n\t                   (duk_tval *) duk_get_tval(ctx, -1)));\n\n\t/*\n\t *  Compact the function template.\n\t */\n\n\tduk_compact_m1(ctx);\n\n\t/*\n\t *  Debug dumping\n\t */\n\n#if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 2)\n\t{\n\t\tduk_hcompfunc *h;\n\t\tduk_instr_t *p, *p_start, *p_end;\n\n\t\th = (duk_hcompfunc *) duk_get_hobject(ctx, -1);\n\t\tp_start = (duk_instr_t *) DUK_HCOMPFUNC_GET_CODE_BASE(thr->heap, h);\n\t\tp_end = (duk_instr_t *) DUK_HCOMPFUNC_GET_CODE_END(thr->heap, h);\n\n\t\tp = p_start;\n\t\twhile (p < p_end) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"BC %04ld: %!I        ; 0x%08lx op=%ld (%!C) a=%ld b=%ld c=%ld\",\n\t\t\t                     (long) (p - p_start),\n\t\t\t                     (duk_instr_t) (*p),\n\t\t\t                     (unsigned long) (*p),\n\t\t\t                     (long) DUK_DEC_OP(*p),\n\t\t\t                     (long) DUK_DEC_OP(*p),\n\t\t\t                     (long) DUK_DEC_A(*p),\n\t\t\t                     (long) DUK_DEC_B(*p),\n\t\t\t                     (long) DUK_DEC_C(*p)));\n\t\t\tp++;\n\t\t}\n\t}\n#endif\n}\n\n/*\n *  Code emission helpers\n *\n *  Some emission helpers understand the range of target and source reg/const\n *  values and automatically emit shuffling code if necessary.  This is the\n *  case when the slot in question (A, B, C) is used in the standard way and\n *  for opcodes the emission helpers explicitly understand (like DUK_OP_MPUTOBJ).\n *\n *  The standard way is that:\n *    - slot A is a target register\n *    - slot B is a source register/constant\n *    - slot C is a source register/constant\n *\n *  If a slot is used in a non-standard way the caller must indicate this\n *  somehow.  If a slot is used as a target instead of a source (or vice\n *  versa), this can be indicated with a flag to trigger proper shuffling\n *  (e.g. DUK__EMIT_FLAG_B_IS_TARGET).  If the value in the slot is not\n *  register/const related at all, the caller must ensure that the raw value\n *  fits into the corresponding slot so as to not trigger shuffling.  The\n *  caller must set a \"no shuffle\" flag to ensure compilation fails if\n *  shuffling were to be triggered because of an internal error.\n *\n *  For slots B and C the raw slot size is 9 bits but one bit is reserved for\n *  the reg/const indicator.  To use the full 9-bit range for a raw value,\n *  shuffling must be disabled with the DUK__EMIT_FLAG_NO_SHUFFLE_{B,C} flag.\n *  Shuffling is only done for A, B, and C slots, not the larger BC or ABC slots.\n *\n *  There is call handling specific understanding in the A-B-C emitter to\n *  convert call setup and call instructions into indirect ones if necessary.\n */\n\n/* Code emission flags, passed in the 'opcode' field.  Opcode + flags\n * fit into 16 bits for now, so use duk_small_uint_t.\n */\n#define DUK__EMIT_FLAG_NO_SHUFFLE_A      (1 << 8)\n#define DUK__EMIT_FLAG_NO_SHUFFLE_B      (1 << 9)\n#define DUK__EMIT_FLAG_NO_SHUFFLE_C      (1 << 10)\n#define DUK__EMIT_FLAG_A_IS_SOURCE       (1 << 11)  /* slot A is a source (default: target) */\n#define DUK__EMIT_FLAG_B_IS_TARGET       (1 << 12)  /* slot B is a target (default: source) */\n#define DUK__EMIT_FLAG_C_IS_TARGET       (1 << 13)  /* slot C is a target (default: source) */\n#define DUK__EMIT_FLAG_BC_REGCONST       (1 << 14)  /* slots B and C are reg/const */\n#define DUK__EMIT_FLAG_RESERVE_JUMPSLOT  (1 << 15)  /* reserve a jumpslot after instr before target spilling, used for NEXTENUM */\n\n/* XXX: macro smaller than call? */\nDUK_LOCAL duk_int_t duk__get_current_pc(duk_compiler_ctx *comp_ctx) {\n\tduk_compiler_func *func;\n\tfunc = &comp_ctx->curr_func;\n\treturn (duk_int_t) (DUK_BW_GET_SIZE(comp_ctx->thr, &func->bw_code) / sizeof(duk_compiler_instr));\n}\n\nDUK_LOCAL duk_compiler_instr *duk__get_instr_ptr(duk_compiler_ctx *comp_ctx, duk_int_t pc) {\n\tDUK_ASSERT(pc >= 0);\n\tDUK_ASSERT((duk_size_t) pc < (duk_size_t) (DUK_BW_GET_SIZE(comp_ctx->thr, &comp_ctx->curr_func.bw_code) / sizeof(duk_compiler_instr)));\n\treturn ((duk_compiler_instr *) (void *) DUK_BW_GET_BASEPTR(comp_ctx->thr, &comp_ctx->curr_func.bw_code)) + pc;\n}\n\n/* emit instruction; could return PC but that's not needed in the majority\n * of cases.\n */\nDUK_LOCAL void duk__emit(duk_compiler_ctx *comp_ctx, duk_instr_t ins) {\n#if defined(DUK_USE_PC2LINE)\n\tduk_int_t line;\n#endif\n\tduk_compiler_instr *instr;\n\n\tDUK_DDD(DUK_DDDPRINT(\"duk__emit: 0x%08lx curr_token.start_line=%ld prev_token.start_line=%ld pc=%ld --> %!I\",\n\t                     (unsigned long) ins,\n\t                     (long) comp_ctx->curr_token.start_line,\n\t                     (long) comp_ctx->prev_token.start_line,\n\t                     (long) duk__get_current_pc(comp_ctx),\n\t                     (duk_instr_t) ins));\n\n\tinstr = (duk_compiler_instr *) (void *) DUK_BW_ENSURE_GETPTR(comp_ctx->thr, &comp_ctx->curr_func.bw_code, sizeof(duk_compiler_instr));\n\tDUK_BW_ADD_PTR(comp_ctx->thr, &comp_ctx->curr_func.bw_code, sizeof(duk_compiler_instr));\n\n#if defined(DUK_USE_PC2LINE)\n\t/* The line number tracking is a bit inconsistent right now, which\n\t * affects debugger accuracy.  Mostly call sites emit opcodes when\n\t * they have parsed a token (say a terminating semicolon) and called\n\t * duk__advance().  In this case the line number of the previous\n\t * token is the most accurate one (except in prologue where\n\t * prev_token.start_line is 0).  This is probably not 100% correct\n\t * right now.\n\t */\n\t/* approximation, close enough */\n\tline = comp_ctx->prev_token.start_line;\n\tif (line == 0) {\n\t\tline = comp_ctx->curr_token.start_line;\n\t}\n#endif\n\n\tinstr->ins = ins;\n#if defined(DUK_USE_PC2LINE)\n\tinstr->line = line;\n#endif\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\tif (line < comp_ctx->curr_func.min_line) {\n\t\tcomp_ctx->curr_func.min_line = line;\n\t}\n\tif (line > comp_ctx->curr_func.max_line) {\n\t\tcomp_ctx->curr_func.max_line = line;\n\t}\n#endif\n\n\t/* Limit checks for bytecode byte size and line number. */\n\tif (DUK_UNLIKELY(DUK_BW_GET_SIZE(comp_ctx->thr, &comp_ctx->curr_func.bw_code) > DUK_USE_ESBC_MAX_BYTES)) {\n\t\tgoto fail_bc_limit;\n\t}\n#if defined(DUK_USE_PC2LINE) && defined(DUK_USE_ESBC_LIMITS)\n#if defined(DUK_USE_BUFLEN16)\n\t/* Buffer length is bounded to 0xffff automatically, avoid compile warning. */\n\tif (DUK_UNLIKELY(line > DUK_USE_ESBC_MAX_LINENUMBER)) {\n\t\tgoto fail_bc_limit;\n\t}\n#else\n\tif (DUK_UNLIKELY(line > DUK_USE_ESBC_MAX_LINENUMBER)) {\n\t\tgoto fail_bc_limit;\n\t}\n#endif\n#endif\n\n\treturn;\n\n  fail_bc_limit:\n\tDUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_BYTECODE_LIMIT);\n}\n\n/* Update function min/max line from current token.  Needed to improve\n * function line range information for debugging, so that e.g. opening\n * curly brace is covered by line range even when no opcodes are emitted\n * for the line containing the brace.\n */\nDUK_LOCAL void duk__update_lineinfo_currtoken(duk_compiler_ctx *comp_ctx) {\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\tduk_int_t line;\n\n\tline = comp_ctx->curr_token.start_line;\n\tif (line == 0) {\n\t\treturn;\n\t}\n\tif (line < comp_ctx->curr_func.min_line) {\n\t\tcomp_ctx->curr_func.min_line = line;\n\t}\n\tif (line > comp_ctx->curr_func.max_line) {\n\t\tcomp_ctx->curr_func.max_line = line;\n\t}\n#else\n\tDUK_UNREF(comp_ctx);\n#endif\n}\n\nDUK_LOCAL void duk__emit_op_only(duk_compiler_ctx *comp_ctx, duk_small_uint_t op) {\n\tduk__emit(comp_ctx, DUK_ENC_OP_ABC(op, 0));\n}\n\n/* Important main primitive. */\nDUK_LOCAL void duk__emit_a_b_c(duk_compiler_ctx *comp_ctx, duk_small_uint_t op_flags, duk_regconst_t a, duk_regconst_t b, duk_regconst_t c) {\n\tduk_instr_t ins = 0;\n\tduk_int_t a_out = -1;\n\tduk_int_t b_out = -1;\n\tduk_int_t c_out = -1;\n\tduk_int_t tmp;\n\tduk_small_int_t op = op_flags & 0xff;\n\n\tDUK_DDD(DUK_DDDPRINT(\"emit: op_flags=%04lx, a=%ld, b=%ld, c=%ld\",\n\t                     (unsigned long) op_flags, (long) a, (long) b, (long) c));\n\n\t/* We could rely on max temp/const checks: if they don't exceed BC\n\t * limit, nothing here can either (just asserts would be enough).\n\t * Currently we check for the limits, which provides additional\n\t * protection against creating invalid bytecode due to compiler\n\t * bugs.\n\t */\n\n\tDUK_ASSERT_DISABLE((op_flags & 0xff) >= DUK_BC_OP_MIN);  /* unsigned */\n\tDUK_ASSERT((op_flags & 0xff) <= DUK_BC_OP_MAX);\n\n\t/* Input shuffling happens before the actual operation, while output\n\t * shuffling happens afterwards.  Output shuffling decisions are still\n\t * made at the same time to reduce branch clutter; output shuffle decisions\n\t * are recorded into X_out variables.\n\t */\n\n\t/* Slot A: currently no support for reg/const. */\n\n#if defined(DUK_USE_SHUFFLE_TORTURE)\n\tif (a <= DUK_BC_A_MAX && (op_flags & DUK__EMIT_FLAG_NO_SHUFFLE_A)) {\n#else\n\tif (a <= DUK_BC_A_MAX) {\n#endif\n\t\t;\n\t} else if (op_flags & DUK__EMIT_FLAG_NO_SHUFFLE_A) {\n\t\tDUK_D(DUK_DPRINT(\"out of regs: 'a' (reg) needs shuffling but shuffle prohibited, a: %ld\", (long) a));\n\t\tgoto error_outofregs;\n\t} else if (a <= DUK_BC_BC_MAX) {\n\t\tcomp_ctx->curr_func.needs_shuffle = 1;\n\t\ttmp = comp_ctx->curr_func.shuffle1;\n\t\tif (op_flags & DUK__EMIT_FLAG_A_IS_SOURCE) {\n\t\t\tduk__emit(comp_ctx, DUK_ENC_OP_A_BC(DUK_OP_LDREG, tmp, a));\n\t\t} else {\n\t\t\t/* Output shuffle needed after main operation */\n\t\t\ta_out = a;\n\n\t\t\t/* The DUK_OP_CSVAR output shuffle assumes shuffle registers are\n\t\t\t * consecutive.\n\t\t\t */\n\t\t\tDUK_ASSERT((comp_ctx->curr_func.shuffle1 == 0 && comp_ctx->curr_func.shuffle2 == 0) ||\n\t\t\t           comp_ctx->curr_func.shuffle2 == comp_ctx->curr_func.shuffle1 + 1);\n\t\t\tif (op == DUK_OP_CSVAR) {\n\t\t\t\t/* For CSVAR the limit is one smaller because output shuffle\n\t\t\t\t * must be able to express 'a + 1' in BC.\n\t\t\t\t */\n\t\t\t\tif (a + 1 > DUK_BC_BC_MAX) {\n\t\t\t\t\tgoto error_outofregs;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\ta = tmp;\n\t} else {\n\t\tDUK_D(DUK_DPRINT(\"out of regs: 'a' (reg) needs shuffling but does not fit into BC, a: %ld\", (long) a));\n\t\tgoto error_outofregs;\n\t}\n\n\t/* Slot B: reg/const support, mapped to bit 0 of opcode. */\n\n\tif (b & DUK__CONST_MARKER) {\n\t\tDUK_ASSERT((op_flags & DUK__EMIT_FLAG_NO_SHUFFLE_B) == 0);\n\t\tDUK_ASSERT((op_flags & DUK__EMIT_FLAG_B_IS_TARGET) == 0);\n\t\tb = b & ~DUK__CONST_MARKER;\n#if defined(DUK_USE_SHUFFLE_TORTURE)\n\t\tif (0) {\n#else\n\t\tif (b <= 0xff) {\n#endif\n\t\t\tif (op_flags & DUK__EMIT_FLAG_BC_REGCONST) {\n\t\t\t\t/* Opcode follows B/C reg/const convention. */\n\t\t\t\tDUK_ASSERT((op & 0x01) == 0);\n\t\t\t\tins |= DUK_ENC_OP_A_B_C(0x01, 0, 0, 0);  /* const flag for B */\n\t\t\t} else {\n\t\t\t\tDUK_D(DUK_DPRINT(\"B is const, opcode is not B/C reg/const: %x\", op_flags));\n\t\t\t}\n\t\t} else if (b <= DUK_BC_BC_MAX) {\n\t\t\tcomp_ctx->curr_func.needs_shuffle = 1;\n\t\t\ttmp = comp_ctx->curr_func.shuffle2;\n\t\t\tduk__emit(comp_ctx, DUK_ENC_OP_A_BC(DUK_OP_LDCONST, tmp, b));\n\t\t\tb = tmp;\n\t\t} else {\n\t\t\tDUK_D(DUK_DPRINT(\"out of regs: 'b' (const) needs shuffling but does not fit into BC, b: %ld\", (long) b));\n\t\t\tgoto error_outofregs;\n\t\t}\n\t} else {\n#if defined(DUK_USE_SHUFFLE_TORTURE)\n\t\tif (b <= 0xff && (op_flags & DUK__EMIT_FLAG_NO_SHUFFLE_B)) {\n#else\n\t\tif (b <= 0xff) {\n#endif\n\t\t\t;\n\t\t} else if (op_flags & DUK__EMIT_FLAG_NO_SHUFFLE_B) {\n\t\t\tif (b > DUK_BC_B_MAX) {\n\t\t\t\t/* Note: 0xff != DUK_BC_B_MAX */\n\t\t\t\tDUK_D(DUK_DPRINT(\"out of regs: 'b' (reg) needs shuffling but shuffle prohibited, b: %ld\", (long) b));\n\t\t\t\tgoto error_outofregs;\n\t\t\t}\n\t\t} else if (b <= DUK_BC_BC_MAX) {\n\t\t\tcomp_ctx->curr_func.needs_shuffle = 1;\n\t\t\ttmp = comp_ctx->curr_func.shuffle2;\n\t\t\tif (op_flags & DUK__EMIT_FLAG_B_IS_TARGET) {\n\t\t\t\t/* Output shuffle needed after main operation */\n\t\t\t\tb_out = b;\n\t\t\t}\n\t\t\tif (!(op_flags & DUK__EMIT_FLAG_B_IS_TARGET)) {\n\t\t\t\tif (op == DUK_OP_MPUTOBJ || op == DUK_OP_MPUTARR) {\n\t\t\t\t\t/* Special handling for MPUTOBJ/MPUTARR shuffling.\n\t\t\t\t\t * For each, slot B identifies the first register of a range\n\t\t\t\t\t * of registers, so normal shuffling won't work.  Instead,\n\t\t\t\t\t * an indirect version of the opcode is used.\n\t\t\t\t\t */\n\t\t\t\t\tDUK_ASSERT((op_flags & DUK__EMIT_FLAG_B_IS_TARGET) == 0);\n\t\t\t\t\tduk__emit_load_int32_noshuffle(comp_ctx, tmp, b);\n\t\t\t\t\tDUK_ASSERT(DUK_OP_MPUTOBJI == DUK_OP_MPUTOBJ + 1);\n\t\t\t\t\tDUK_ASSERT(DUK_OP_MPUTARRI == DUK_OP_MPUTARR + 1);\n\t\t\t\t\top_flags++;  /* indirect opcode follows direct */\n\t\t\t\t} else {\n\t\t\t\t\tduk__emit(comp_ctx, DUK_ENC_OP_A_BC(DUK_OP_LDREG, tmp, b));\n\t\t\t\t}\n\t\t\t}\n\t\t\tb = tmp;\n\t\t} else {\n\t\t\tDUK_D(DUK_DPRINT(\"out of regs: 'b' (reg) needs shuffling but does not fit into BC, b: %ld\", (long) b));\n\t\t\tgoto error_outofregs;\n\t\t}\n\t}\n\n\t/* Slot C: reg/const support, mapped to bit 1 of opcode. */\n\n\tif (c & DUK__CONST_MARKER) {\n\t\tDUK_ASSERT((op_flags & DUK__EMIT_FLAG_NO_SHUFFLE_C) == 0);\n\t\tDUK_ASSERT((op_flags & DUK__EMIT_FLAG_C_IS_TARGET) == 0);\n\t\tc = c & ~DUK__CONST_MARKER;\n#if defined(DUK_USE_SHUFFLE_TORTURE)\n\t\tif (0) {\n#else\n\t\tif (c <= 0xff) {\n#endif\n\t\t\tif (op_flags & DUK__EMIT_FLAG_BC_REGCONST) {\n\t\t\t\t/* Opcode follows B/C reg/const convention. */\n\t\t\t\tDUK_ASSERT((op & 0x02) == 0);\n\t\t\t\tins |= DUK_ENC_OP_A_B_C(0x02, 0, 0, 0);  /* const flag for C */\n\t\t\t} else {\n\t\t\t\tDUK_D(DUK_DPRINT(\"C is const, opcode is not B/C reg/const: %x\", op_flags));\n\t\t\t}\n\t\t} else if (c <= DUK_BC_BC_MAX) {\n\t\t\tcomp_ctx->curr_func.needs_shuffle = 1;\n\t\t\ttmp = comp_ctx->curr_func.shuffle3;\n\t\t\tduk__emit(comp_ctx, DUK_ENC_OP_A_BC(DUK_OP_LDCONST, tmp, c));\n\t\t\tc = tmp;\n\t\t} else {\n\t\t\tDUK_D(DUK_DPRINT(\"out of regs: 'c' (const) needs shuffling but does not fit into BC, c: %ld\", (long) c));\n\t\t\tgoto error_outofregs;\n\t\t}\n\t} else {\n#if defined(DUK_USE_SHUFFLE_TORTURE)\n\t\tif (c <= 0xff && (op_flags & DUK__EMIT_FLAG_NO_SHUFFLE_C)) {\n#else\n\t\tif (c <= 0xff) {\n#endif\n\t\t\t;\n\t\t} else if (op_flags & DUK__EMIT_FLAG_NO_SHUFFLE_C) {\n\t\t\tif (c > DUK_BC_C_MAX) {\n\t\t\t\t/* Note: 0xff != DUK_BC_C_MAX */\n\t\t\t\tDUK_D(DUK_DPRINT(\"out of regs: 'c' (reg) needs shuffling but shuffle prohibited, c: %ld\", (long) c));\n\t\t\t\tgoto error_outofregs;\n\t\t\t}\n\t\t} else if (c <= DUK_BC_BC_MAX) {\n\t\t\tcomp_ctx->curr_func.needs_shuffle = 1;\n\t\t\ttmp = comp_ctx->curr_func.shuffle3;\n\t\t\tif (op_flags & DUK__EMIT_FLAG_C_IS_TARGET) {\n\t\t\t\t/* Output shuffle needed after main operation */\n\t\t\t\tc_out = c;\n\t\t\t} else {\n\t\t\t\tduk__emit(comp_ctx, DUK_ENC_OP_A_BC(DUK_OP_LDREG, tmp, c));\n\t\t\t}\n\t\t\tc = tmp;\n\t\t} else {\n\t\t\tDUK_D(DUK_DPRINT(\"out of regs: 'c' (reg) needs shuffling but does not fit into BC, c: %ld\", (long) c));\n\t\t\tgoto error_outofregs;\n\t\t}\n\t}\n\n\t/* Main operation */\n\n\tDUK_ASSERT_DISABLE(a >= DUK_BC_A_MIN);  /* unsigned */\n\tDUK_ASSERT(a <= DUK_BC_A_MAX);\n\tDUK_ASSERT_DISABLE(b >= DUK_BC_B_MIN);  /* unsigned */\n\tDUK_ASSERT(b <= DUK_BC_B_MAX);\n\tDUK_ASSERT_DISABLE(c >= DUK_BC_C_MIN);  /* unsigned */\n\tDUK_ASSERT(c <= DUK_BC_C_MAX);\n\n\tins |= DUK_ENC_OP_A_B_C(op_flags & 0xff, a, b, c);\n\tduk__emit(comp_ctx, ins);\n\n\t/* NEXTENUM needs a jump slot right after the main instruction.\n\t * When the JUMP is taken, output spilling is not needed so this\n\t * workaround is possible.  The jump slot PC is exceptionally\n\t * plumbed through comp_ctx to minimize call sites.\n\t */\n\tif (op_flags & DUK__EMIT_FLAG_RESERVE_JUMPSLOT) {\n\t\tcomp_ctx->emit_jumpslot_pc = duk__get_current_pc(comp_ctx);\n\t\tduk__emit_abc(comp_ctx, DUK_OP_JUMP, 0);\n\t}\n\n\t/* Output shuffling: only one output register is realistically possible.\n\t *\n\t * (Zero would normally be an OK marker value: if the target register\n\t * was zero, it would never be shuffled.  But with DUK_USE_SHUFFLE_TORTURE\n\t * this is no longer true, so use -1 as a marker instead.)\n\t */\n\n\tif (a_out >= 0) {\n\t\tDUK_ASSERT(b_out < 0);\n\t\tDUK_ASSERT(c_out < 0);\n\t\tduk__emit(comp_ctx, DUK_ENC_OP_A_BC(DUK_OP_STREG, a, a_out));\n\n\t\tif (op == DUK_OP_CSVAR) {\n\t\t\t/* Special handling for CSVAR shuffling.  The variable lookup\n\t\t\t * results in a <value, this binding> pair in successive\n\t\t\t * registers so use two shuffle registers and two output\n\t\t\t * loads.  (In practice this is dead code because temp/const\n\t\t\t * limit is reached first.)\n\t\t\t */\n\t\t\tduk__emit(comp_ctx, DUK_ENC_OP_A_BC(DUK_OP_STREG, a + 1, a_out + 1));\n\t\t}\n\t} else if (b_out >= 0) {\n\t\tDUK_ASSERT(a_out < 0);\n\t\tDUK_ASSERT(c_out < 0);\n\t\tduk__emit(comp_ctx, DUK_ENC_OP_A_BC(DUK_OP_STREG, b, b_out));\n\t} else if (c_out >= 0) {\n\t\tDUK_ASSERT(b_out < 0);\n\t\tDUK_ASSERT(c_out < 0);\n\t\tduk__emit(comp_ctx, DUK_ENC_OP_A_BC(DUK_OP_STREG, c, c_out));\n\t}\n\n\treturn;\n\n error_outofregs:\n\tDUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_REG_LIMIT);\n}\n\n/* For many of the helpers below it'd be technically correct to add\n * \"no shuffle\" flags for parameters passed in as zero.  For example,\n * duk__emit_a_b() should call duk__emit_a_b_c() with C set to 0, and\n * DUK__EMIT_FLAG_NO_SHUFFLE_C added to op_flags.  However, since the\n * C value is 0, it'll never get shuffled so adding the flag is just\n * unnecessary additional code.  This is unfortunately not true for\n * \"shuffle torture\" mode which needs special handling.\n */\n\nDUK_LOCAL void duk__emit_a_b(duk_compiler_ctx *comp_ctx, duk_small_uint_t op_flags, duk_regconst_t a, duk_regconst_t b) {\n#if defined(DUK_USE_SHUFFLE_TORTURE)\n\top_flags |= DUK__EMIT_FLAG_NO_SHUFFLE_C;\n#endif\n\tduk__emit_a_b_c(comp_ctx, op_flags, a, b, 0);\n}\n\nDUK_LOCAL void duk__emit_b_c(duk_compiler_ctx *comp_ctx, duk_small_uint_t op_flags, duk_regconst_t b, duk_regconst_t c) {\n#if defined(DUK_USE_SHUFFLE_TORTURE)\n\top_flags |= DUK__EMIT_FLAG_NO_SHUFFLE_A;\n#endif\n\tduk__emit_a_b_c(comp_ctx, op_flags, 0, b, c);\n}\n\n#if 0  /* unused */\nDUK_LOCAL void duk__emit_a(duk_compiler_ctx *comp_ctx, int op_flags, int a) {\n#if defined(DUK_USE_SHUFFLE_TORTURE)\n\top_flags |= DUK__EMIT_FLAG_NO_SHUFFLE_B | DUK__EMIT_FLAG_NO_SHUFFLE_C;\n#endif\n\tduk__emit_a_b_c(comp_ctx, op_flags, a, 0, 0);\n}\n#endif\n\nDUK_LOCAL void duk__emit_b(duk_compiler_ctx *comp_ctx, duk_small_uint_t op_flags, duk_regconst_t b) {\n#if defined(DUK_USE_SHUFFLE_TORTURE)\n\top_flags |= DUK__EMIT_FLAG_NO_SHUFFLE_A | DUK__EMIT_FLAG_NO_SHUFFLE_C;\n#endif\n\tduk__emit_a_b_c(comp_ctx, op_flags, 0, b, 0);\n}\n\nDUK_LOCAL void duk__emit_a_bc(duk_compiler_ctx *comp_ctx, duk_small_uint_t op_flags, duk_regconst_t a, duk_regconst_t bc) {\n\tduk_instr_t ins;\n\tduk_int_t tmp;\n\n\t/* allow caller to give a const number with the DUK__CONST_MARKER */\n\tbc = bc & (~DUK__CONST_MARKER);\n\n\tDUK_ASSERT_DISABLE((op_flags & 0xff) >= DUK_BC_OP_MIN);  /* unsigned */\n\tDUK_ASSERT((op_flags & 0xff) <= DUK_BC_OP_MAX);\n\tDUK_ASSERT_DISABLE(bc >= DUK_BC_BC_MIN);  /* unsigned */\n\tDUK_ASSERT(bc <= DUK_BC_BC_MAX);\n\tDUK_ASSERT((bc & DUK__CONST_MARKER) == 0);\n\n\tif (bc <= DUK_BC_BC_MAX) {\n\t\t;\n\t} else {\n\t\t/* No BC shuffling now. */\n\t\tgoto error_outofregs;\n\t}\n\n#if defined(DUK_USE_SHUFFLE_TORTURE)\n\tif (a <= DUK_BC_A_MAX && (op_flags & DUK__EMIT_FLAG_NO_SHUFFLE_A)) {\n#else\n\tif (a <= DUK_BC_A_MAX) {\n#endif\n\t\tins = DUK_ENC_OP_A_BC(op_flags & 0xff, a, bc);\n\t\tduk__emit(comp_ctx, ins);\n\t} else if (op_flags & DUK__EMIT_FLAG_NO_SHUFFLE_A) {\n\t\tgoto error_outofregs;\n\t} else if (a <= DUK_BC_BC_MAX) {\n\t\tcomp_ctx->curr_func.needs_shuffle = 1;\n\t\ttmp = comp_ctx->curr_func.shuffle1;\n\t\tins = DUK_ENC_OP_A_BC(op_flags & 0xff, tmp, bc);\n\t\tif (op_flags & DUK__EMIT_FLAG_A_IS_SOURCE) {\n\t\t\tduk__emit(comp_ctx, DUK_ENC_OP_A_BC(DUK_OP_LDREG, tmp, a));\n\t\t\tduk__emit(comp_ctx, ins);\n\t\t} else {\n\t\t\tduk__emit(comp_ctx, ins);\n\t\t\tduk__emit(comp_ctx, DUK_ENC_OP_A_BC(DUK_OP_STREG, tmp, a));\n\t\t}\n\t} else {\n\t\tgoto error_outofregs;\n\t}\n\treturn;\n\n error_outofregs:\n\tDUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_REG_LIMIT);\n}\n\nDUK_LOCAL void duk__emit_bc(duk_compiler_ctx *comp_ctx, duk_small_uint_t op, duk_regconst_t bc) {\n#if defined(DUK_USE_SHUFFLE_TORTURE)\n\top |= DUK__EMIT_FLAG_NO_SHUFFLE_A;\n#endif\n\tduk__emit_a_bc(comp_ctx, op, 0, bc);\n}\n\nDUK_LOCAL void duk__emit_abc(duk_compiler_ctx *comp_ctx, duk_small_uint_t op, duk_regconst_t abc) {\n\tduk_instr_t ins;\n\n\tDUK_ASSERT_DISABLE(op >= DUK_BC_OP_MIN);  /* unsigned */\n\tDUK_ASSERT(op <= DUK_BC_OP_MAX);\n\tDUK_ASSERT_DISABLE(abc >= DUK_BC_ABC_MIN);  /* unsigned */\n\tDUK_ASSERT(abc <= DUK_BC_ABC_MAX);\n\tDUK_ASSERT((abc & DUK__CONST_MARKER) == 0);\n\n\tif (abc <= DUK_BC_ABC_MAX) {\n\t\t;\n\t} else {\n\t\tgoto error_outofregs;\n\t}\n\tins = DUK_ENC_OP_ABC(op, abc);\n\tDUK_DDD(DUK_DDDPRINT(\"duk__emit_abc: 0x%08lx line=%ld pc=%ld op=%ld (%!C) abc=%ld (%!I)\",\n\t                     (unsigned long) ins, (long) comp_ctx->curr_token.start_line,\n\t                     (long) duk__get_current_pc(comp_ctx), (long) op, (long) op,\n\t                     (long) abc, (duk_instr_t) ins));\n\tduk__emit(comp_ctx, ins);\n\treturn;\n\n error_outofregs:\n\tDUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_REG_LIMIT);\n}\n\nDUK_LOCAL void duk__emit_load_int32_raw(duk_compiler_ctx *comp_ctx, duk_reg_t reg, duk_int32_t val, duk_small_uint_t op_flags) {\n\t/* XXX: Shuffling support could be implemented here so that LDINT+LDINTX\n\t * would only shuffle once (instead of twice).  The current code works\n\t * though, and has a smaller compiler footprint.\n\t */\n\n\tif ((val >= (duk_int32_t) DUK_BC_BC_MIN - (duk_int32_t) DUK_BC_LDINT_BIAS) &&\n\t    (val <= (duk_int32_t) DUK_BC_BC_MAX - (duk_int32_t) DUK_BC_LDINT_BIAS)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"emit LDINT to reg %ld for %ld\", (long) reg, (long) val));\n\t\tduk__emit_a_bc(comp_ctx, DUK_OP_LDINT | op_flags, reg, (duk_regconst_t) (val + (duk_int32_t) DUK_BC_LDINT_BIAS));\n\t} else {\n\t\tduk_int32_t hi = val >> DUK_BC_LDINTX_SHIFT;\n\t\tduk_int32_t lo = val & ((((duk_int32_t) 1) << DUK_BC_LDINTX_SHIFT) - 1);\n\t\tDUK_ASSERT(lo >= 0);\n\t\tDUK_DDD(DUK_DDDPRINT(\"emit LDINT+LDINTX to reg %ld for %ld -> hi %ld, lo %ld\",\n\t\t                     (long) reg, (long) val, (long) hi, (long) lo));\n\t\tduk__emit_a_bc(comp_ctx, DUK_OP_LDINT | op_flags, reg, (duk_regconst_t) (hi + (duk_int32_t) DUK_BC_LDINT_BIAS));\n\t\tduk__emit_a_bc(comp_ctx, DUK_OP_LDINTX | op_flags, reg, (duk_regconst_t) lo);\n\t}\n}\n\nDUK_LOCAL void duk__emit_load_int32(duk_compiler_ctx *comp_ctx, duk_reg_t reg, duk_int32_t val) {\n\tduk__emit_load_int32_raw(comp_ctx, reg, val, 0 /*op_flags*/);\n}\n\n#if defined(DUK_USE_SHUFFLE_TORTURE)\n/* Used by duk__emit*() calls so that we don't shuffle the loadints that\n * are needed to handle indirect opcodes.\n */\nDUK_LOCAL void duk__emit_load_int32_noshuffle(duk_compiler_ctx *comp_ctx, duk_reg_t reg, duk_int32_t val) {\n\tduk__emit_load_int32_raw(comp_ctx, reg, val, DUK__EMIT_FLAG_NO_SHUFFLE_A /*op_flags*/);\n}\n#else\nDUK_LOCAL void duk__emit_load_int32_noshuffle(duk_compiler_ctx *comp_ctx, duk_reg_t reg, duk_int32_t val) {\n\t/* When torture not enabled, can just use the same helper because\n\t * 'reg' won't get spilled.\n\t */\n\tDUK_ASSERT(reg <= DUK_BC_A_MAX);\n\tduk__emit_load_int32(comp_ctx, reg, val);\n}\n#endif\n\nDUK_LOCAL void duk__emit_jump(duk_compiler_ctx *comp_ctx, duk_int_t target_pc) {\n\tduk_int_t curr_pc;\n\tduk_int_t offset;\n\n\tcurr_pc = (duk_int_t) (DUK_BW_GET_SIZE(comp_ctx->thr, &comp_ctx->curr_func.bw_code) / sizeof(duk_compiler_instr));\n\toffset = (duk_int_t) target_pc - (duk_int_t) curr_pc - 1;\n\tDUK_ASSERT(offset + DUK_BC_JUMP_BIAS >= DUK_BC_ABC_MIN);\n\tDUK_ASSERT(offset + DUK_BC_JUMP_BIAS <= DUK_BC_ABC_MAX);\n\tduk__emit_abc(comp_ctx, DUK_OP_JUMP, (duk_regconst_t) (offset + DUK_BC_JUMP_BIAS));\n}\n\nDUK_LOCAL duk_int_t duk__emit_jump_empty(duk_compiler_ctx *comp_ctx) {\n\tduk_int_t ret;\n\n\tret = duk__get_current_pc(comp_ctx);  /* useful for patching jumps later */\n\tduk__emit_op_only(comp_ctx, DUK_OP_JUMP);\n\treturn ret;\n}\n\n/* Insert an empty jump in the middle of code emitted earlier.  This is\n * currently needed for compiling for-in.\n */\nDUK_LOCAL void duk__insert_jump_entry(duk_compiler_ctx *comp_ctx, duk_int_t jump_pc) {\n#if defined(DUK_USE_PC2LINE)\n\tduk_int_t line;\n#endif\n\tduk_compiler_instr *instr;\n\tduk_size_t offset;\n\n\toffset = jump_pc * sizeof(duk_compiler_instr),\n\tinstr = (duk_compiler_instr *) (void *)\n\t        DUK_BW_INSERT_ENSURE_AREA(comp_ctx->thr,\n\t                                  &comp_ctx->curr_func.bw_code,\n\t                                  offset,\n\t                                  sizeof(duk_compiler_instr));\n\n#if defined(DUK_USE_PC2LINE)\n\tline = comp_ctx->curr_token.start_line;  /* approximation, close enough */\n#endif\n\tinstr->ins = DUK_ENC_OP_ABC(DUK_OP_JUMP, 0);\n#if defined(DUK_USE_PC2LINE)\n\tinstr->line = line;\n#endif\n\n\tDUK_BW_ADD_PTR(comp_ctx->thr, &comp_ctx->curr_func.bw_code, sizeof(duk_compiler_instr));\n\tif (DUK_UNLIKELY(DUK_BW_GET_SIZE(comp_ctx->thr, &comp_ctx->curr_func.bw_code) > DUK_USE_ESBC_MAX_BYTES)) {\n\t\tgoto fail_bc_limit;\n\t}\n\treturn;\n\n  fail_bc_limit:\n\tDUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_BYTECODE_LIMIT);\n}\n\n/* Does not assume that jump_pc contains a DUK_OP_JUMP previously; this is intentional\n * to allow e.g. an INVALID opcode be overwritten with a JUMP (label management uses this).\n */\nDUK_LOCAL void duk__patch_jump(duk_compiler_ctx *comp_ctx, duk_int_t jump_pc, duk_int_t target_pc) {\n\tduk_compiler_instr *instr;\n\tduk_int_t offset;\n\n\t/* allow negative PCs, behave as a no-op */\n\tif (jump_pc < 0) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"duk__patch_jump(): nop call, jump_pc=%ld (<0), target_pc=%ld\",\n\t\t                     (long) jump_pc, (long) target_pc));\n\t\treturn;\n\t}\n\tDUK_ASSERT(jump_pc >= 0);\n\n\t/* XXX: range assert */\n\tinstr = duk__get_instr_ptr(comp_ctx, jump_pc);\n\tDUK_ASSERT(instr != NULL);\n\n\t/* XXX: range assert */\n\toffset = target_pc - jump_pc - 1;\n\n\tinstr->ins = DUK_ENC_OP_ABC(DUK_OP_JUMP, offset + DUK_BC_JUMP_BIAS);\n\tDUK_DDD(DUK_DDDPRINT(\"duk__patch_jump(): jump_pc=%ld, target_pc=%ld, offset=%ld\",\n\t                     (long) jump_pc, (long) target_pc, (long) offset));\n}\n\nDUK_LOCAL void duk__patch_jump_here(duk_compiler_ctx *comp_ctx, duk_int_t jump_pc) {\n\tduk__patch_jump(comp_ctx, jump_pc, duk__get_current_pc(comp_ctx));\n}\n\nDUK_LOCAL void duk__patch_trycatch(duk_compiler_ctx *comp_ctx, duk_int_t ldconst_pc, duk_int_t trycatch_pc, duk_regconst_t reg_catch, duk_regconst_t const_varname, duk_small_uint_t flags) {\n\tduk_compiler_instr *instr;\n\n\tDUK_ASSERT((reg_catch & DUK__CONST_MARKER) == 0);\n\n\tinstr = duk__get_instr_ptr(comp_ctx, ldconst_pc);\n\tDUK_ASSERT(DUK_DEC_OP(instr->ins) == DUK_OP_LDCONST);\n\tDUK_ASSERT(instr != NULL);\n\tif (const_varname & DUK__CONST_MARKER) {\n\t\t/* Have a catch variable. */\n\t\tconst_varname = const_varname & (~DUK__CONST_MARKER);\n\t\tif (reg_catch > DUK_BC_BC_MAX || const_varname > DUK_BC_BC_MAX) {\n\t\t\t/* Catch attempts to use out-of-range reg/const.  Without this\n\t\t\t * check Duktape 0.12.0 could generate invalid code which caused\n\t\t\t * an assert failure on execution.  This error is triggered e.g.\n\t\t\t * for functions with a lot of constants and a try-catch statement.\n\t\t\t * Shuffling or opcode semantics change is needed to fix the issue.\n\t\t\t * See: test-bug-trycatch-many-constants.js.\n\t\t\t */\n\t\t\tDUK_D(DUK_DPRINT(\"failed to patch trycatch: flags=%ld, reg_catch=%ld, const_varname=%ld (0x%08lx)\",\n\t\t\t                 (long) flags, (long) reg_catch, (long) const_varname, (long) const_varname));\n\t\t\tDUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_REG_LIMIT);\n\t\t}\n\t\tinstr->ins |= DUK_ENC_OP_A_BC(0, 0, const_varname);\n\t} else {\n\t\t/* No catch variable, e.g. a try-finally; replace LDCONST with\n\t\t * NOP to avoid a bogus LDCONST.\n\t\t */\n\t\tinstr->ins = DUK_ENC_OP(DUK_OP_NOP);\n\t}\n\n\tinstr = duk__get_instr_ptr(comp_ctx, trycatch_pc);\n\tDUK_ASSERT(instr != NULL);\n\tDUK_ASSERT_DISABLE(flags >= DUK_BC_A_MIN);\n\tDUK_ASSERT(flags <= DUK_BC_A_MAX);\n\tinstr->ins = DUK_ENC_OP_A_BC(DUK_OP_TRYCATCH, flags, reg_catch);\n}\n\nDUK_LOCAL void duk__emit_if_false_skip(duk_compiler_ctx *comp_ctx, duk_regconst_t regconst) {\n\tduk_small_uint_t op;\n\n\top = DUK__ISREG(regconst) ? DUK_OP_IFFALSE_R : DUK_OP_IFFALSE_C;\n\tduk__emit_bc(comp_ctx, op, regconst);  /* helper will remove const flag */\n}\n\nDUK_LOCAL void duk__emit_if_true_skip(duk_compiler_ctx *comp_ctx, duk_regconst_t regconst) {\n\tduk_small_uint_t op;\n\n\top = DUK__ISREG(regconst) ? DUK_OP_IFTRUE_R : DUK_OP_IFTRUE_C;\n\tduk__emit_bc(comp_ctx, op, regconst);  /* helper will remove const flag */\n}\n\nDUK_LOCAL void duk__emit_invalid(duk_compiler_ctx *comp_ctx) {\n\tduk__emit_op_only(comp_ctx, DUK_OP_INVALID);\n}\n\n/*\n *  Peephole optimizer for finished bytecode.\n *\n *  Does not remove opcodes; currently only straightens out unconditional\n *  jump chains which are generated by several control structures.\n */\n\nDUK_LOCAL void duk__peephole_optimize_bytecode(duk_compiler_ctx *comp_ctx) {\n\tduk_compiler_instr *bc;\n\tduk_small_uint_t iter;\n\tduk_int_t i, n;\n\tduk_int_t count_opt;\n\n\tbc = (duk_compiler_instr *) (void *) DUK_BW_GET_BASEPTR(comp_ctx->thr, &comp_ctx->curr_func.bw_code);\n#if defined(DUK_USE_BUFLEN16)\n\t/* No need to assert, buffer size maximum is 0xffff. */\n#else\n\tDUK_ASSERT((duk_size_t) DUK_BW_GET_SIZE(comp_ctx->thr, &comp_ctx->curr_func.bw_code) / sizeof(duk_compiler_instr) <= (duk_size_t) DUK_INT_MAX);  /* bytecode limits */\n#endif\n\tn = (duk_int_t) (DUK_BW_GET_SIZE(comp_ctx->thr, &comp_ctx->curr_func.bw_code) / sizeof(duk_compiler_instr));\n\n\tfor (iter = 0; iter < DUK_COMPILER_PEEPHOLE_MAXITER; iter++) {\n\t\tcount_opt = 0;\n\n\t\tfor (i = 0; i < n; i++) {\n\t\t\tduk_instr_t ins;\n\t\t\tduk_int_t target_pc1;\n\t\t\tduk_int_t target_pc2;\n\n\t\t\tins = bc[i].ins;\n\t\t\tif (DUK_DEC_OP(ins) != DUK_OP_JUMP) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\ttarget_pc1 = i + 1 + DUK_DEC_ABC(ins) - DUK_BC_JUMP_BIAS;\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"consider jump at pc %ld; target_pc=%ld\", (long) i, (long) target_pc1));\n\t\t\tDUK_ASSERT(target_pc1 >= 0);\n\t\t\tDUK_ASSERT(target_pc1 < n);\n\n\t\t\t/* Note: if target_pc1 == i, we'll optimize a jump to itself.\n\t\t\t * This does not need to be checked for explicitly; the case\n\t\t\t * is rare and max iter breaks us out.\n\t\t\t */\n\n\t\t\tins = bc[target_pc1].ins;\n\t\t\tif (DUK_DEC_OP(ins) != DUK_OP_JUMP) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\ttarget_pc2 = target_pc1 + 1 + DUK_DEC_ABC(ins) - DUK_BC_JUMP_BIAS;\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"optimizing jump at pc %ld; old target is %ld -> new target is %ld\",\n\t\t\t                     (long) i, (long) target_pc1, (long) target_pc2));\n\n\t\t\tbc[i].ins = DUK_ENC_OP_ABC(DUK_OP_JUMP, target_pc2 - (i + 1) + DUK_BC_JUMP_BIAS);\n\n\t\t\tcount_opt++;\n\t\t}\n\n\t\tDUK_DD(DUK_DDPRINT(\"optimized %ld jumps on peephole round %ld\", (long) count_opt, (long) (iter + 1)));\n\n\t\tif (count_opt == 0) {\n\t\t\tbreak;\n\t\t}\n\t}\n}\n\n/*\n *  Intermediate value helpers\n */\n\n/* Flags for intermediate value coercions.  A flag for using a forced reg\n * is not needed, the forced_reg argument suffices and generates better\n * code (it is checked as it is used).\n */\n#define DUK__IVAL_FLAG_ALLOW_CONST          (1 << 0)  /* allow a constant to be returned */\n#define DUK__IVAL_FLAG_REQUIRE_TEMP         (1 << 1)  /* require a (mutable) temporary as a result (or a const if allowed) */\n#define DUK__IVAL_FLAG_REQUIRE_SHORT        (1 << 2)  /* require a short (8-bit) reg/const which fits into bytecode B/C slot */\n\n/* XXX: some code might benefit from DUK__SETTEMP_IFTEMP(ctx,x) */\n\n#if 0  /* enable manually for dumping */\n#define DUK__DUMP_ISPEC(compctx,ispec) do { duk__dump_ispec((compctx), (ispec)); } while (0)\n#define DUK__DUMP_IVALUE(compctx,ivalue) do { duk__dump_ivalue((compctx), (ivalue)); } while (0)\n\nDUK_LOCAL void duk__dump_ispec(duk_compiler_ctx *comp_ctx, duk_ispec *x) {\n\tDUK_D(DUK_DPRINT(\"ispec dump: t=%ld regconst=0x%08lx, valstack_idx=%ld, value=%!T\",\n\t                 (long) x->t, (unsigned long) x->regconst, (long) x->valstack_idx,\n\t                 duk_get_tval((duk_context *) comp_ctx->thr, x->valstack_idx)));\n}\nDUK_LOCAL void duk__dump_ivalue(duk_compiler_ctx *comp_ctx, duk_ivalue *x) {\n\tDUK_D(DUK_DPRINT(\"ivalue dump: t=%ld op=%ld \"\n\t                 \"x1={t=%ld regconst=0x%08lx valstack_idx=%ld value=%!T} \"\n\t                 \"x2={t=%ld regconst=0x%08lx valstack_idx=%ld value=%!T}\",\n\t\t         (long) x->t, (long) x->op,\n\t                 (long) x->x1.t, (unsigned long) x->x1.regconst, (long) x->x1.valstack_idx,\n\t                 duk_get_tval((duk_context *) comp_ctx->thr, x->x1.valstack_idx),\n\t                 (long) x->x2.t, (unsigned long) x->x2.regconst, (long) x->x2.valstack_idx,\n\t                 duk_get_tval((duk_context *) comp_ctx->thr, x->x2.valstack_idx)));\n}\n#else\n#define DUK__DUMP_ISPEC(comp_ctx,x) do {} while (0)\n#define DUK__DUMP_IVALUE(comp_ctx,x) do {} while (0)\n#endif\n\nDUK_LOCAL void duk__ivalue_regconst(duk_ivalue *x, duk_regconst_t regconst) {\n\tx->t = DUK_IVAL_PLAIN;\n\tx->x1.t = DUK_ISPEC_REGCONST;\n\tx->x1.regconst = (duk_regconst_t) regconst;\n}\n\nDUK_LOCAL void duk__ivalue_plain_fromstack(duk_compiler_ctx *comp_ctx, duk_ivalue *x) {\n\tx->t = DUK_IVAL_PLAIN;\n\tx->x1.t = DUK_ISPEC_VALUE;\n\tduk_replace((duk_context *) comp_ctx->thr, x->x1.valstack_idx);\n}\n\nDUK_LOCAL void duk__ivalue_var_fromstack(duk_compiler_ctx *comp_ctx, duk_ivalue *x) {\n\tx->t = DUK_IVAL_VAR;\n\tx->x1.t = DUK_ISPEC_VALUE;\n\tduk_replace((duk_context *) comp_ctx->thr, x->x1.valstack_idx);\n}\n\nDUK_LOCAL_DECL void duk__ivalue_var_hstring(duk_compiler_ctx *comp_ctx, duk_ivalue *x, duk_hstring *h) {\n\tDUK_ASSERT(h != NULL);\n\tduk_push_hstring((duk_context *) comp_ctx->thr, h);\n\tduk__ivalue_var_fromstack(comp_ctx, x);\n}\n\nDUK_LOCAL void duk__copy_ispec(duk_compiler_ctx *comp_ctx, duk_ispec *src, duk_ispec *dst) {\n\tduk_context *ctx = (duk_context *) comp_ctx->thr;\n\n\tdst->t = src->t;\n\tdst->regconst = src->regconst;\n\tduk_copy(ctx, src->valstack_idx, dst->valstack_idx);\n}\n\nDUK_LOCAL void duk__copy_ivalue(duk_compiler_ctx *comp_ctx, duk_ivalue *src, duk_ivalue *dst) {\n\tduk_context *ctx = (duk_context *) comp_ctx->thr;\n\n\tdst->t = src->t;\n\tdst->op = src->op;\n\tdst->x1.t = src->x1.t;\n\tdst->x1.regconst = src->x1.regconst;\n\tdst->x2.t = src->x2.t;\n\tdst->x2.regconst = src->x2.regconst;\n\tduk_copy(ctx, src->x1.valstack_idx, dst->x1.valstack_idx);\n\tduk_copy(ctx, src->x2.valstack_idx, dst->x2.valstack_idx);\n}\n\nDUK_LOCAL duk_reg_t duk__alloctemps(duk_compiler_ctx *comp_ctx, duk_small_int_t num) {\n\tduk_reg_t res;\n\n\tres = comp_ctx->curr_func.temp_next;\n\tcomp_ctx->curr_func.temp_next += num;\n\n\tif (comp_ctx->curr_func.temp_next > DUK__MAX_TEMPS) {  /* == DUK__MAX_TEMPS is OK */\n\t\tDUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_TEMP_LIMIT);\n\t}\n\n\t/* maintain highest 'used' temporary, needed to figure out nregs of function */\n\tif (comp_ctx->curr_func.temp_next > comp_ctx->curr_func.temp_max) {\n\t\tcomp_ctx->curr_func.temp_max = comp_ctx->curr_func.temp_next;\n\t}\n\n\treturn res;\n}\n\nDUK_LOCAL duk_reg_t duk__alloctemp(duk_compiler_ctx *comp_ctx) {\n\treturn duk__alloctemps(comp_ctx, 1);\n}\n\nDUK_LOCAL void duk__settemp_checkmax(duk_compiler_ctx *comp_ctx, duk_reg_t temp_next) {\n\tcomp_ctx->curr_func.temp_next = temp_next;\n\tif (temp_next > comp_ctx->curr_func.temp_max) {\n\t\tcomp_ctx->curr_func.temp_max = temp_next;\n\t}\n}\n\n/* get const for value at valstack top */\nDUK_LOCAL duk_regconst_t duk__getconst(duk_compiler_ctx *comp_ctx) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_compiler_func *f = &comp_ctx->curr_func;\n\tduk_tval *tv1;\n\tduk_int_t i, n, n_check;\n\n\tn = (duk_int_t) duk_get_length(ctx, f->consts_idx);\n\n\ttv1 = DUK_GET_TVAL_NEGIDX(ctx, -1);\n\tDUK_ASSERT(tv1 != NULL);\n\n#if defined(DUK_USE_FASTINT)\n\t/* Explicit check for fastint downgrade. */\n\tDUK_TVAL_CHKFAST_INPLACE_SLOW(tv1);\n#endif\n\n\t/* Sanity workaround for handling functions with a large number of\n\t * constants at least somewhat reasonably.  Otherwise checking whether\n\t * we already have the constant would grow very slow (as it is O(N^2)).\n\t */\n\tn_check = (n > DUK__GETCONST_MAX_CONSTS_CHECK ? DUK__GETCONST_MAX_CONSTS_CHECK : n);\n\tfor (i = 0; i < n_check; i++) {\n\t\tduk_tval *tv2 = DUK_HOBJECT_A_GET_VALUE_PTR(thr->heap, f->h_consts, i);\n\n\t\t/* Strict equality is NOT enough, because we cannot use the same\n\t\t * constant for e.g. +0 and -0.\n\t\t */\n\t\tif (duk_js_samevalue(tv1, tv2)) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"reused existing constant for %!T -> const index %ld\",\n\t\t\t                     (duk_tval *) tv1, (long) i));\n\t\t\tduk_pop(ctx);\n\t\t\treturn (duk_regconst_t) (i | DUK__CONST_MARKER);\n\t\t}\n\t}\n\n\tif (n > DUK__MAX_CONSTS) {\n\t\tDUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_CONST_LIMIT);\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"allocating new constant for %!T -> const index %ld\",\n\t                     (duk_tval *) tv1, (long) n));\n\t(void) duk_put_prop_index(ctx, f->consts_idx, n);  /* invalidates tv1, tv2 */\n\treturn (duk_regconst_t) (n | DUK__CONST_MARKER);\n}\n\nDUK_LOCAL duk_bool_t duk__const_needs_refcount(duk_compiler_ctx *comp_ctx, duk_regconst_t rc) {\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\tduk_context *ctx = (duk_context *) comp_ctx->thr;\n\tduk_compiler_func *f = &comp_ctx->curr_func;\n\tduk_bool_t ret;\n\n\tDUK_ASSERT((rc & DUK__CONST_MARKER) == 0);  /* caller removes const marker */\n\t(void) duk_get_prop_index(ctx, f->consts_idx, (duk_uarridx_t) rc);\n\tret = !duk_is_number(ctx, -1);  /* now only number/string, so conservative check */\n\tduk_pop(ctx);\n\treturn ret;\n#else\n\tDUK_UNREF(comp_ctx);\n\tDUK_UNREF(rc);\n\tDUK_ASSERT((rc & DUK__CONST_MARKER) == 0);  /* caller removes const marker */\n\treturn 0;\n#endif\n}\n\n/* Get the value represented by an duk_ispec to a register or constant.\n * The caller can control the result by indicating whether or not:\n *\n *   (1) a constant is allowed (sometimes the caller needs the result to\n *       be in a register)\n *\n *   (2) a temporary register is required (usually when caller requires\n *       the register to be safely mutable; normally either a bound\n *       register or a temporary register are both OK)\n *\n *   (3) a forced register target needs to be used\n *\n * Bytecode may be emitted to generate the necessary value.  The return\n * value is either a register or a constant.\n */\n\nDUK_LOCAL\nduk_regconst_t duk__ispec_toregconst_raw(duk_compiler_ctx *comp_ctx,\n                                         duk_ispec *x,\n                                         duk_reg_t forced_reg,\n                                         duk_small_uint_t flags) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\n\tDUK_DDD(DUK_DDDPRINT(\"duk__ispec_toregconst_raw(): x={%ld:%ld:%!T}, \"\n\t                     \"forced_reg=%ld, flags 0x%08lx: allow_const=%ld require_temp=%ld require_short=%ld\",\n\t                     (long) x->t,\n\t                     (long) x->regconst,\n\t                     (duk_tval *) duk_get_tval(ctx, x->valstack_idx),\n\t                     (long) forced_reg,\n\t                     (unsigned long) flags,\n\t                     (long) ((flags & DUK__IVAL_FLAG_ALLOW_CONST) ? 1 : 0),\n\t                     (long) ((flags & DUK__IVAL_FLAG_REQUIRE_TEMP) ? 1 : 0),\n\t                     (long) ((flags & DUK__IVAL_FLAG_REQUIRE_SHORT) ? 1 : 0)));\n\n\tswitch (x->t) {\n\tcase DUK_ISPEC_VALUE: {\n\t\tduk_tval *tv;\n\n\t\ttv = DUK_GET_TVAL_POSIDX(ctx, x->valstack_idx);\n\t\tDUK_ASSERT(tv != NULL);\n\n\t\tswitch (DUK_TVAL_GET_TAG(tv)) {\n\t\tcase DUK_TAG_UNDEFINED: {\n\t\t\t/* Note: although there is no 'undefined' literal, undefined\n\t\t\t * values can occur during compilation as a result of e.g.\n\t\t\t * the 'void' operator.\n\t\t\t */\n\t\t\tduk_reg_t dest = (forced_reg >= 0 ? forced_reg : DUK__ALLOCTEMP(comp_ctx));\n\t\t\tduk__emit_bc(comp_ctx, DUK_OP_LDUNDEF, (duk_regconst_t) dest);\n\t\t\treturn (duk_regconst_t) dest;\n\t\t}\n\t\tcase DUK_TAG_NULL: {\n\t\t\tduk_reg_t dest = (forced_reg >= 0 ? forced_reg : DUK__ALLOCTEMP(comp_ctx));\n\t\t\tduk__emit_bc(comp_ctx, DUK_OP_LDNULL, (duk_regconst_t) dest);\n\t\t\treturn (duk_regconst_t) dest;\n\t\t}\n\t\tcase DUK_TAG_BOOLEAN: {\n\t\t\tduk_reg_t dest = (forced_reg >= 0 ? forced_reg : DUK__ALLOCTEMP(comp_ctx));\n\t\t\tduk__emit_bc(comp_ctx,\n\t\t\t             (DUK_TVAL_GET_BOOLEAN(tv) ? DUK_OP_LDTRUE : DUK_OP_LDFALSE),\n\t\t\t             (duk_regconst_t) dest);\n\t\t\treturn (duk_regconst_t) dest;\n\t\t}\n\t\tcase DUK_TAG_POINTER: {\n\t\t\tDUK_UNREACHABLE();\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_TAG_STRING: {\n\t\t\tduk_hstring *h;\n\t\t\tduk_reg_t dest;\n\t\t\tduk_regconst_t constidx;\n\n\t\t\th = DUK_TVAL_GET_STRING(tv);\n\t\t\tDUK_UNREF(h);\n\t\t\tDUK_ASSERT(h != NULL);\n\n#if 0  /* XXX: to be implemented? */\n\t\t\t/* Use special opcodes to load short strings */\n\t\t\tif (DUK_HSTRING_GET_BYTELEN(h) <= 2) {\n\t\t\t\t/* Encode into a single opcode (18 bits can encode 1-2 bytes + length indicator) */\n\t\t\t} else if (DUK_HSTRING_GET_BYTELEN(h) <= 6) {\n\t\t\t\t/* Encode into a double constant (53 bits can encode 6*8 = 48 bits + 3-bit length */\n\t\t\t}\n#endif\n\t\t\tduk_dup(ctx, x->valstack_idx);\n\t\t\tconstidx = duk__getconst(comp_ctx);\n\n\t\t\tif (flags & DUK__IVAL_FLAG_ALLOW_CONST) {\n\t\t\t\treturn constidx;\n\t\t\t}\n\n\t\t\tdest = (forced_reg >= 0 ? forced_reg : DUK__ALLOCTEMP(comp_ctx));\n\t\t\tduk__emit_a_bc(comp_ctx, DUK_OP_LDCONST, (duk_regconst_t) dest, constidx);\n\t\t\treturn (duk_regconst_t) dest;\n\t\t}\n\t\tcase DUK_TAG_OBJECT: {\n\t\t\tDUK_UNREACHABLE();\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_TAG_BUFFER: {\n\t\t\tDUK_UNREACHABLE();\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_TAG_LIGHTFUNC: {\n\t\t\tDUK_UNREACHABLE();\n\t\t\tbreak;\n\t\t}\n#if defined(DUK_USE_FASTINT)\n\t\tcase DUK_TAG_FASTINT:\n#endif\n\t\tdefault: {\n\t\t\t/* number */\n\t\t\tduk_reg_t dest;\n\t\t\tduk_regconst_t constidx;\n\t\t\tduk_double_t dval;\n\t\t\tduk_int32_t ival;\n\n\t\t\tDUK_ASSERT(!DUK_TVAL_IS_UNUSED(tv));\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv));\n\t\t\tdval = DUK_TVAL_GET_NUMBER(tv);\n\n\t\t\tif (!(flags & DUK__IVAL_FLAG_ALLOW_CONST)) {\n\t\t\t\t/* A number can be loaded either through a constant, using\n\t\t\t\t * LDINT, or using LDINT+LDINTX.  LDINT is always a size win,\n\t\t\t\t * LDINT+LDINTX is not if the constant is used multiple times.\n\t\t\t\t * Currently always prefer LDINT+LDINTX over a double constant.\n\t\t\t\t */\n\n\t\t\t\tif (duk_is_whole_get_int32_nonegzero(dval, &ival)) {\n\t\t\t\t\tdest = (forced_reg >= 0 ? forced_reg : DUK__ALLOCTEMP(comp_ctx));\n\t\t\t\t\tduk__emit_load_int32(comp_ctx, dest, ival);\n\t\t\t\t\treturn (duk_regconst_t) dest;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tduk_dup(ctx, x->valstack_idx);\n\t\t\tconstidx = duk__getconst(comp_ctx);\n\n\t\t\tif (flags & DUK__IVAL_FLAG_ALLOW_CONST) {\n\t\t\t\treturn constidx;\n\t\t\t} else {\n\t\t\t\tdest = (forced_reg >= 0 ? forced_reg : DUK__ALLOCTEMP(comp_ctx));\n\t\t\t\tduk__emit_a_bc(comp_ctx, DUK_OP_LDCONST, (duk_regconst_t) dest, constidx);\n\t\t\t\treturn (duk_regconst_t) dest;\n\t\t\t}\n\t\t}\n\t\t}  /* end switch */\n\t}\n\tcase DUK_ISPEC_REGCONST: {\n\t\tif (forced_reg >= 0) {\n\t\t\tif (x->regconst & DUK__CONST_MARKER) {\n\t\t\t\tduk__emit_a_bc(comp_ctx, DUK_OP_LDCONST, forced_reg, x->regconst);\n\t\t\t} else if (x->regconst != (duk_regconst_t) forced_reg) {\n\t\t\t\tduk__emit_a_bc(comp_ctx, DUK_OP_LDREG, forced_reg, x->regconst);\n\t\t\t} else {\n\t\t\t\t; /* already in correct reg */\n\t\t\t}\n\t\t\treturn (duk_regconst_t) forced_reg;\n\t\t}\n\n\t\tDUK_ASSERT(forced_reg < 0);\n\t\tif (x->regconst & DUK__CONST_MARKER) {\n\t\t\tif (!(flags & DUK__IVAL_FLAG_ALLOW_CONST)) {\n\t\t\t\tduk_reg_t dest = DUK__ALLOCTEMP(comp_ctx);\n\t\t\t\tduk__emit_a_bc(comp_ctx, DUK_OP_LDCONST, (duk_regconst_t) dest, x->regconst);\n\t\t\t\treturn (duk_regconst_t) dest;\n\t\t\t}\n\t\t\treturn x->regconst;\n\t\t}\n\n\t\tDUK_ASSERT(forced_reg < 0 && !(x->regconst & DUK__CONST_MARKER));\n\t\tif ((flags & DUK__IVAL_FLAG_REQUIRE_TEMP) && !DUK__ISTEMP(comp_ctx, x->regconst)) {\n\t\t\tduk_reg_t dest = DUK__ALLOCTEMP(comp_ctx);\n\t\t\tduk__emit_a_bc(comp_ctx, DUK_OP_LDREG, (duk_regconst_t) dest, x->regconst);\n\t\t\treturn (duk_regconst_t) dest;\n\t\t}\n\t\treturn x->regconst;\n\t}\n\tdefault: {\n\t\tbreak;\n\t}\n\t}\n\n\tDUK_ERROR_INTERNAL(thr);\n\treturn 0;\n}\n\nDUK_LOCAL void duk__ispec_toforcedreg(duk_compiler_ctx *comp_ctx, duk_ispec *x, duk_reg_t forced_reg) {\n\tDUK_ASSERT(forced_reg >= 0);\n\t(void) duk__ispec_toregconst_raw(comp_ctx, x, forced_reg, 0 /*flags*/);\n}\n\n/* Coerce an duk_ivalue to a 'plain' value by generating the necessary\n * arithmetic operations, property access, or variable access bytecode.\n * The duk_ivalue argument ('x') is converted into a plain value as a\n * side effect.\n */\nDUK_LOCAL void duk__ivalue_toplain_raw(duk_compiler_ctx *comp_ctx, duk_ivalue *x, duk_reg_t forced_reg) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\n\tDUK_DDD(DUK_DDDPRINT(\"duk__ivalue_toplain_raw(): x={t=%ld,op=%ld,x1={%ld:%ld:%!T},x2={%ld:%ld:%!T}}, \"\n\t                     \"forced_reg=%ld\",\n\t                     (long) x->t, (long) x->op,\n\t                     (long) x->x1.t, (long) x->x1.regconst,\n\t                     (duk_tval *) duk_get_tval(ctx, x->x1.valstack_idx),\n\t                     (long) x->x2.t, (long) x->x2.regconst,\n\t                     (duk_tval *) duk_get_tval(ctx, x->x2.valstack_idx),\n\t                     (long) forced_reg));\n\n\tswitch (x->t) {\n\tcase DUK_IVAL_PLAIN: {\n\t\treturn;\n\t}\n\t/* XXX: support unary arithmetic ivalues (useful?) */\n\tcase DUK_IVAL_ARITH: {\n\t\tduk_regconst_t arg1;\n\t\tduk_regconst_t arg2;\n\t\tduk_reg_t dest;\n\t\tduk_tval *tv1;\n\t\tduk_tval *tv2;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"arith to plain conversion\"));\n\n\t\t/* inline arithmetic check for constant values */\n\t\t/* XXX: use the exactly same arithmetic function here as in executor */\n\t\tif (x->x1.t == DUK_ISPEC_VALUE && x->x2.t == DUK_ISPEC_VALUE && x->t == DUK_IVAL_ARITH) {\n\t\t\ttv1 = DUK_GET_TVAL_POSIDX(ctx, x->x1.valstack_idx);\n\t\t\ttv2 = DUK_GET_TVAL_POSIDX(ctx, x->x2.valstack_idx);\n\t\t\tDUK_ASSERT(tv1 != NULL);\n\t\t\tDUK_ASSERT(tv2 != NULL);\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"arith: tv1=%!T, tv2=%!T\",\n\t\t\t                     (duk_tval *) tv1,\n\t\t\t                     (duk_tval *) tv2));\n\n\t\t\tif (DUK_TVAL_IS_NUMBER(tv1) && DUK_TVAL_IS_NUMBER(tv2)) {\n\t\t\t\tduk_double_t d1 = DUK_TVAL_GET_NUMBER(tv1);\n\t\t\t\tduk_double_t d2 = DUK_TVAL_GET_NUMBER(tv2);\n\t\t\t\tduk_double_t d3;\n\t\t\t\tduk_bool_t accept_fold = 1;\n\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"arith inline check: d1=%lf, d2=%lf, op=%ld\",\n\t\t\t\t                     (double) d1, (double) d2, (long) x->op));\n\t\t\t\tswitch (x->op) {\n\t\t\t\tcase DUK_OP_ADD: {\n\t\t\t\t\td3 = d1 + d2;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase DUK_OP_SUB: {\n\t\t\t\t\td3 = d1 - d2;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase DUK_OP_MUL: {\n\t\t\t\t\td3 = d1 * d2;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase DUK_OP_DIV: {\n\t\t\t\t\td3 = d1 / d2;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase DUK_OP_EXP: {\n\t\t\t\t\td3 = (duk_double_t) duk_js_arith_pow((double) d1, (double) d2);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tdefault: {\n\t\t\t\t\td3 = 0.0;  /* Won't be used, but silence MSVC /W4 warning. */\n\t\t\t\t\taccept_fold = 0;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (accept_fold) {\n\t\t\t\t\tduk_double_union du;\n\t\t\t\t\tdu.d = d3;\n\t\t\t\t\tDUK_DBLUNION_NORMALIZE_NAN_CHECK(&du);\n\t\t\t\t\td3 = du.d;\n\n\t\t\t\t\tx->t = DUK_IVAL_PLAIN;\n\t\t\t\t\tDUK_ASSERT(x->x1.t == DUK_ISPEC_VALUE);\n\t\t\t\t\tDUK_TVAL_SET_NUMBER(tv1, d3);  /* old value is number: no refcount */\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else if (x->op == DUK_OP_ADD && DUK_TVAL_IS_STRING(tv1) && DUK_TVAL_IS_STRING(tv2)) {\n\t\t\t\t/* Inline string concatenation.  No need to check for\n\t\t\t\t * symbols, as all inputs are valid Ecmascript strings.\n\t\t\t\t */\n\t\t\t\tduk_dup(ctx, x->x1.valstack_idx);\n\t\t\t\tduk_dup(ctx, x->x2.valstack_idx);\n\t\t\t\tduk_concat(ctx, 2);\n\t\t\t\tduk_replace(ctx, x->x1.valstack_idx);\n\t\t\t\tx->t = DUK_IVAL_PLAIN;\n\t\t\t\tDUK_ASSERT(x->x1.t == DUK_ISPEC_VALUE);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\targ1 = duk__ispec_toregconst_raw(comp_ctx, &x->x1, -1, DUK__IVAL_FLAG_ALLOW_CONST | DUK__IVAL_FLAG_REQUIRE_SHORT /*flags*/);\n\t\targ2 = duk__ispec_toregconst_raw(comp_ctx, &x->x2, -1, DUK__IVAL_FLAG_ALLOW_CONST | DUK__IVAL_FLAG_REQUIRE_SHORT /*flags*/);\n\n\t\t/* If forced reg, use it as destination.  Otherwise try to\n\t\t * use either coerced ispec if it is a temporary.\n\t\t */\n\t\tif (forced_reg >= 0) {\n\t\t\tdest = forced_reg;\n\t\t} else if (DUK__ISTEMP(comp_ctx, arg1)) {\n\t\t\tdest = (duk_reg_t) arg1;\n\t\t} else if (DUK__ISTEMP(comp_ctx, arg2)) {\n\t\t\tdest = (duk_reg_t) arg2;\n\t\t} else {\n\t\t\tdest = DUK__ALLOCTEMP(comp_ctx);\n\t\t}\n\n\t\tDUK_ASSERT(DUK__ISREG(dest));\n\t\tduk__emit_a_b_c(comp_ctx, x->op | DUK__EMIT_FLAG_BC_REGCONST, (duk_regconst_t) dest, arg1, arg2);\n\n\t\tduk__ivalue_regconst(x, (duk_regconst_t) dest);\n\t\treturn;\n\t}\n\tcase DUK_IVAL_PROP: {\n\t\t/* XXX: very similar to DUK_IVAL_ARITH - merge? */\n\t\tduk_regconst_t arg1;\n\t\tduk_regconst_t arg2;\n\t\tduk_reg_t dest;\n\n\t\t/* Need a short reg/const, does not have to be a mutable temp. */\n\t\targ1 = duk__ispec_toregconst_raw(comp_ctx, &x->x1, -1, DUK__IVAL_FLAG_ALLOW_CONST | DUK__IVAL_FLAG_REQUIRE_SHORT /*flags*/);\n\t\targ2 = duk__ispec_toregconst_raw(comp_ctx, &x->x2, -1, DUK__IVAL_FLAG_ALLOW_CONST | DUK__IVAL_FLAG_REQUIRE_SHORT /*flags*/);\n\n\t\t/* Pick a destination register.  If either base value or key\n\t\t * happens to be a temp value, reuse it as the destination.\n\t\t *\n\t\t * XXX: The temp must be a \"mutable\" one, i.e. such that no\n\t\t * other expression is using it anymore.  Here this should be\n\t\t * the case because the value of a property access expression\n\t\t * is neither the base nor the key, but the lookup result.\n\t\t */\n\n\t\tif (forced_reg >= 0) {\n\t\t\tdest = forced_reg;\n\t\t} else if (DUK__ISTEMP(comp_ctx, arg1)) {\n\t\t\tdest = (duk_reg_t) arg1;\n\t\t} else if (DUK__ISTEMP(comp_ctx, arg2)) {\n\t\t\tdest = (duk_reg_t) arg2;\n\t\t} else {\n\t\t\tdest = DUK__ALLOCTEMP(comp_ctx);\n\t\t}\n\n\t\tduk__emit_a_b_c(comp_ctx,\n\t\t                DUK_OP_GETPROP | DUK__EMIT_FLAG_BC_REGCONST,\n\t\t                (duk_regconst_t) dest,\n\t\t                arg1,\n\t\t                arg2);\n\n\t\tduk__ivalue_regconst(x, (duk_regconst_t) dest);\n\t\treturn;\n\t}\n\tcase DUK_IVAL_VAR: {\n\t\t/* x1 must be a string */\n\t\tduk_reg_t dest;\n\t\tduk_reg_t reg_varbind;\n\t\tduk_regconst_t rc_varname;\n\n\t\tDUK_ASSERT(x->x1.t == DUK_ISPEC_VALUE);\n\n\t\tduk_dup(ctx, x->x1.valstack_idx);\n\t\tif (duk__lookup_lhs(comp_ctx, &reg_varbind, &rc_varname)) {\n\t\t\tduk__ivalue_regconst(x, (duk_regconst_t) reg_varbind);\n\t\t} else {\n\t\t\tdest = (forced_reg >= 0 ? forced_reg : DUK__ALLOCTEMP(comp_ctx));\n\t\t\tduk__emit_a_bc(comp_ctx, DUK_OP_GETVAR, (duk_regconst_t) dest, rc_varname);\n\t\t\tduk__ivalue_regconst(x, (duk_regconst_t) dest);\n\t\t}\n\t\treturn;\n\t}\n\tcase DUK_IVAL_NONE:\n\tdefault: {\n\t\tDUK_D(DUK_DPRINT(\"invalid ivalue type: %ld\", (long) x->t));\n\t\tbreak;\n\t}\n\t}\n\n\tDUK_ERROR_INTERNAL(thr);\n\treturn;\n}\n\n/* evaluate to plain value, no forced register (temp/bound reg both ok) */\nDUK_LOCAL void duk__ivalue_toplain(duk_compiler_ctx *comp_ctx, duk_ivalue *x) {\n\tduk__ivalue_toplain_raw(comp_ctx, x, -1 /*forced_reg*/);\n}\n\n/* evaluate to final form (e.g. coerce GETPROP to code), throw away temp */\nDUK_LOCAL void duk__ivalue_toplain_ignore(duk_compiler_ctx *comp_ctx, duk_ivalue *x) {\n\tduk_reg_t temp;\n\n\t/* If duk__ivalue_toplain_raw() allocates a temp, forget it and\n\t * restore next temp state.\n\t */\n\ttemp = DUK__GETTEMP(comp_ctx);\n\tduk__ivalue_toplain_raw(comp_ctx, x, -1 /*forced_reg*/);\n\tDUK__SETTEMP(comp_ctx, temp);\n}\n\n/* Coerce an duk_ivalue to a register or constant; result register may\n * be a temp or a bound register.\n *\n * The duk_ivalue argument ('x') is converted into a regconst as a\n * side effect.\n */\nDUK_LOCAL\nduk_regconst_t duk__ivalue_toregconst_raw(duk_compiler_ctx *comp_ctx,\n                                          duk_ivalue *x,\n                                          duk_reg_t forced_reg,\n                                          duk_small_uint_t flags) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_regconst_t reg;\n\tDUK_UNREF(thr);\n\tDUK_UNREF(ctx);\n\n\tDUK_DDD(DUK_DDDPRINT(\"duk__ivalue_toregconst_raw(): x={t=%ld,op=%ld,x1={%ld:%ld:%!T},x2={%ld:%ld:%!T}}, \"\n\t                     \"forced_reg=%ld, flags 0x%08lx: allow_const=%ld require_temp=%ld require_short=%ld\",\n\t                     (long) x->t, (long) x->op,\n\t                     (long) x->x1.t, (long) x->x1.regconst,\n\t                     (duk_tval *) duk_get_tval(ctx, x->x1.valstack_idx),\n\t                     (long) x->x2.t, (long) x->x2.regconst,\n\t                     (duk_tval *) duk_get_tval(ctx, x->x2.valstack_idx),\n\t                     (long) forced_reg,\n\t                     (unsigned long) flags,\n\t                     (long) ((flags & DUK__IVAL_FLAG_ALLOW_CONST) ? 1 : 0),\n\t                     (long) ((flags & DUK__IVAL_FLAG_REQUIRE_TEMP) ? 1 : 0),\n\t                     (long) ((flags & DUK__IVAL_FLAG_REQUIRE_SHORT) ? 1 : 0)));\n\n\t/* first coerce to a plain value */\n\tduk__ivalue_toplain_raw(comp_ctx, x, forced_reg);\n\tDUK_ASSERT(x->t == DUK_IVAL_PLAIN);\n\n\t/* then to a register */\n\treg = duk__ispec_toregconst_raw(comp_ctx, &x->x1, forced_reg, flags);\n\tduk__ivalue_regconst(x, (duk_regconst_t) reg);\n\n\treturn reg;\n}\n\nDUK_LOCAL duk_reg_t duk__ivalue_toreg(duk_compiler_ctx *comp_ctx, duk_ivalue *x) {\n\treturn duk__ivalue_toregconst_raw(comp_ctx, x, -1, 0 /*flags*/);\n}\n\n#if 0  /* unused */\nDUK_LOCAL duk_reg_t duk__ivalue_totemp(duk_compiler_ctx *comp_ctx, duk_ivalue *x) {\n\treturn duk__ivalue_toregconst_raw(comp_ctx, x, -1, DUK__IVAL_FLAG_REQUIRE_TEMP /*flags*/);\n}\n#endif\n\nDUK_LOCAL void duk__ivalue_toforcedreg(duk_compiler_ctx *comp_ctx, duk_ivalue *x, duk_int_t forced_reg) {\n\tDUK_ASSERT(forced_reg >= 0);\n\t(void) duk__ivalue_toregconst_raw(comp_ctx, x, forced_reg, 0 /*flags*/);\n}\n\nDUK_LOCAL duk_regconst_t duk__ivalue_toregconst(duk_compiler_ctx *comp_ctx, duk_ivalue *x) {\n\treturn duk__ivalue_toregconst_raw(comp_ctx, x, -1, DUK__IVAL_FLAG_ALLOW_CONST /*flags*/);\n}\n\nDUK_LOCAL duk_regconst_t duk__ivalue_totempconst(duk_compiler_ctx *comp_ctx, duk_ivalue *x) {\n\treturn duk__ivalue_toregconst_raw(comp_ctx, x, -1, DUK__IVAL_FLAG_ALLOW_CONST | DUK__IVAL_FLAG_REQUIRE_TEMP /*flags*/);\n}\n\n/* The issues below can be solved with better flags */\n\n/* XXX: many operations actually want toforcedtemp() -- brand new temp? */\n/* XXX: need a toplain_ignore() which will only coerce a value to a temp\n * register if it might have a side effect.  Side-effect free values do not\n * need to be coerced.\n */\n\n/*\n *  Identifier handling\n */\n\nDUK_LOCAL duk_reg_t duk__lookup_active_register_binding(duk_compiler_ctx *comp_ctx) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hstring *h_varname;\n\tduk_reg_t ret;\n\n\tDUK_DDD(DUK_DDDPRINT(\"resolving identifier reference to '%!T'\",\n\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\n\t/*\n\t *  Special name handling\n\t */\n\n\th_varname = duk_known_hstring(ctx, -1);\n\n\tif (h_varname == DUK_HTHREAD_STRING_LC_ARGUMENTS(thr)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"flagging function as accessing 'arguments'\"));\n\t\tcomp_ctx->curr_func.id_access_arguments = 1;\n\t}\n\n\t/*\n\t *  Inside one or more 'with' statements fall back to slow path always.\n\t *  (See e.g. test-stmt-with.js.)\n\t */\n\n\tif (comp_ctx->curr_func.with_depth > 0) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"identifier lookup inside a 'with' -> fall back to slow path\"));\n\t\tgoto slow_path_own;\n\t}\n\n\t/*\n\t *  Any catch bindings (\"catch (e)\") also affect identifier binding.\n\t *\n\t *  Currently, the varmap is modified for the duration of the catch\n\t *  clause to ensure any identifier accesses with the catch variable\n\t *  name will use slow path.\n\t */\n\n\tduk_get_prop(ctx, comp_ctx->curr_func.varmap_idx);\n\tif (duk_is_number(ctx, -1)) {\n\t\tret = duk_to_int(ctx, -1);\n\t\tduk_pop(ctx);\n\t} else {\n\t\tduk_pop(ctx);\n\t\tif (comp_ctx->curr_func.catch_depth > 0 || comp_ctx->curr_func.with_depth > 0) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"slow path access from inside a try-catch or with needs _Varmap\"));\n\t\t\tgoto slow_path_own;\n\t\t} else {\n\t\t\t/* In this case we're doing a variable lookup that doesn't\n\t\t\t * match our own variables, so _Varmap won't be needed at\n\t\t\t * run time.\n\t\t\t */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"slow path access outside of try-catch and with, no need for _Varmap\"));\n\t\t\tgoto slow_path_notown;\n\t\t}\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"identifier lookup -> reg %ld\", (long) ret));\n\treturn ret;\n\n slow_path_notown:\n\tDUK_DDD(DUK_DDDPRINT(\"identifier lookup -> slow path, not own variable\"));\n\n\tcomp_ctx->curr_func.id_access_slow = 1;\n\treturn (duk_reg_t) -1;\n\n slow_path_own:\n\tDUK_DDD(DUK_DDDPRINT(\"identifier lookup -> slow path, may be own variable\"));\n\n\tcomp_ctx->curr_func.id_access_slow = 1;\n\tcomp_ctx->curr_func.id_access_slow_own = 1;\n\treturn (duk_reg_t) -1;\n}\n\n/* Lookup an identifier name in the current varmap, indicating whether the\n * identifier is register-bound and if not, allocating a constant for the\n * identifier name.  Returns 1 if register-bound, 0 otherwise.  Caller can\n * also check (out_reg_varbind >= 0) to check whether or not identifier is\n * register bound.  The caller must NOT use out_rc_varname at all unless\n * return code is 0 or out_reg_varbind is < 0; this is becuase out_rc_varname\n * is unsigned and doesn't have a \"unused\" / none value.\n */\nDUK_LOCAL duk_bool_t duk__lookup_lhs(duk_compiler_ctx *comp_ctx, duk_reg_t *out_reg_varbind, duk_regconst_t *out_rc_varname) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_reg_t reg_varbind;\n\tduk_regconst_t rc_varname;\n\n\t/* [ ... varname ] */\n\n\tduk_dup_top(ctx);\n\treg_varbind = duk__lookup_active_register_binding(comp_ctx);\n\n\tif (reg_varbind >= 0) {\n\t\t*out_reg_varbind = reg_varbind;\n\t\t*out_rc_varname = 0;  /* duk_regconst_t is unsigned, so use 0 as dummy value (ignored by caller) */\n\t\tduk_pop(ctx);\n\t\treturn 1;\n\t} else {\n\t\trc_varname = duk__getconst(comp_ctx);\n\t\t*out_reg_varbind = -1;\n\t\t*out_rc_varname = rc_varname;\n\t\treturn 0;\n\t}\n}\n\n/*\n *  Label handling\n *\n *  Labels are initially added with flags prohibiting both break and continue.\n *  When the statement type is finally uncovered (after potentially multiple\n *  labels), all the labels are updated to allow/prohibit break and continue.\n */\n\nDUK_LOCAL void duk__add_label(duk_compiler_ctx *comp_ctx, duk_hstring *h_label, duk_int_t pc_label, duk_int_t label_id) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_size_t n;\n\tduk_size_t new_size;\n\tduk_uint8_t *p;\n\tduk_labelinfo *li_start, *li;\n\n\t/* Duplicate (shadowing) labels are not allowed, except for the empty\n\t * labels (which are used as default labels for switch and iteration\n\t * statements).\n\t *\n\t * We could also allow shadowing of non-empty pending labels without any\n\t * other issues than breaking the required label shadowing requirements\n\t * of the E5 specification, see Section 12.12.\n\t */\n\n\tp = (duk_uint8_t *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, comp_ctx->curr_func.h_labelinfos);\n\tli_start = (duk_labelinfo *) (void *) p;\n\tli = (duk_labelinfo *) (void *) (p + DUK_HBUFFER_GET_SIZE(comp_ctx->curr_func.h_labelinfos));\n\tn = (duk_size_t) (li - li_start);\n\n\twhile (li > li_start) {\n\t\tli--;\n\n\t\tif (li->h_label == h_label && h_label != DUK_HTHREAD_STRING_EMPTY_STRING(thr)) {\n\t\t\tDUK_ERROR_SYNTAX(thr, DUK_STR_DUPLICATE_LABEL);\n\t\t}\n\t}\n\n\tduk_push_hstring(ctx, h_label);\n\tDUK_ASSERT(n <= DUK_UARRIDX_MAX);  /* label limits */\n\t(void) duk_put_prop_index(ctx, comp_ctx->curr_func.labelnames_idx, (duk_uarridx_t) n);\n\n\tnew_size = (n + 1) * sizeof(duk_labelinfo);\n\tduk_hbuffer_resize(thr, comp_ctx->curr_func.h_labelinfos, new_size);\n\t/* XXX: spare handling, slow now */\n\n\t/* relookup after possible realloc */\n\tp = (duk_uint8_t *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, comp_ctx->curr_func.h_labelinfos);\n\tli_start = (duk_labelinfo *) (void *) p;\n\tDUK_UNREF(li_start);  /* silence scan-build warning */\n\tli = (duk_labelinfo *) (void *) (p + DUK_HBUFFER_GET_SIZE(comp_ctx->curr_func.h_labelinfos));\n\tli--;\n\n\t/* Labels can be used for iteration statements but also for other statements,\n\t * in particular a label can be used for a block statement.  All cases of a\n\t * named label accept a 'break' so that flag is set here.  Iteration statements\n\t * also allow 'continue', so that flag is updated when we figure out the\n\t * statement type.\n\t */\n\n\tli->flags = DUK_LABEL_FLAG_ALLOW_BREAK;\n\tli->label_id = label_id;\n\tli->h_label = h_label;\n\tli->catch_depth = comp_ctx->curr_func.catch_depth;   /* catch depth from current func */\n\tli->pc_label = pc_label;\n\n\tDUK_DDD(DUK_DDDPRINT(\"registered label: flags=0x%08lx, id=%ld, name=%!O, catch_depth=%ld, pc_label=%ld\",\n\t                     (unsigned long) li->flags, (long) li->label_id, (duk_heaphdr *) li->h_label,\n\t                     (long) li->catch_depth, (long) li->pc_label));\n}\n\n/* Update all labels with matching label_id. */\nDUK_LOCAL void duk__update_label_flags(duk_compiler_ctx *comp_ctx, duk_int_t label_id, duk_small_uint_t flags) {\n\tduk_uint8_t *p;\n\tduk_labelinfo *li_start, *li;\n\n\tp = (duk_uint8_t *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(comp_ctx->thr->heap, comp_ctx->curr_func.h_labelinfos);\n\tli_start = (duk_labelinfo *) (void *) p;\n\tli = (duk_labelinfo *) (void *) (p + DUK_HBUFFER_GET_SIZE(comp_ctx->curr_func.h_labelinfos));\n\n\t/* Match labels starting from latest; once label_id no longer matches, we can\n\t * safely exit without checking the rest of the labels (only the topmost labels\n\t * are ever updated).\n\t */\n\twhile (li > li_start) {\n\t\tli--;\n\n\t\tif (li->label_id != label_id) {\n\t\t\tbreak;\n\t\t}\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"updating (overwriting) label flags for li=%p, label_id=%ld, flags=%ld\",\n\t\t                     (void *) li, (long) label_id, (long) flags));\n\n\t\tli->flags = flags;\n\t}\n}\n\n/* Lookup active label information.  Break/continue distinction is necessary to handle switch\n * statement related labels correctly: a switch will only catch a 'break', not a 'continue'.\n *\n * An explicit label cannot appear multiple times in the active set, but empty labels (unlabelled\n * iteration and switch statements) can.  A break will match the closest unlabelled or labelled\n * statement.  A continue will match the closest unlabelled or labelled iteration statement.  It is\n * a syntax error if a continue matches a labelled switch statement; because an explicit label cannot\n * be duplicated, the continue cannot match any valid label outside the switch.\n *\n * A side effect of these rules is that a LABEL statement related to a switch should never actually\n * catch a continue abrupt completion at run-time.  Hence an INVALID opcode can be placed in the\n * continue slot of the switch's LABEL statement.\n */\n\n/* XXX: awkward, especially the bunch of separate output values -> output struct? */\nDUK_LOCAL void duk__lookup_active_label(duk_compiler_ctx *comp_ctx, duk_hstring *h_label, duk_bool_t is_break, duk_int_t *out_label_id, duk_int_t *out_label_catch_depth, duk_int_t *out_label_pc, duk_bool_t *out_is_closest) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_uint8_t *p;\n\tduk_labelinfo *li_start, *li_end, *li;\n\tduk_bool_t match = 0;\n\n\tDUK_DDD(DUK_DDDPRINT(\"looking up active label: label='%!O', is_break=%ld\",\n\t                     (duk_heaphdr *) h_label, (long) is_break));\n\n\tDUK_UNREF(ctx);\n\n\tp = (duk_uint8_t *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, comp_ctx->curr_func.h_labelinfos);\n\tli_start = (duk_labelinfo *) (void *) p;\n\tli_end = (duk_labelinfo *) (void *) (p + DUK_HBUFFER_GET_SIZE(comp_ctx->curr_func.h_labelinfos));\n\tli = li_end;\n\n\t/* Match labels starting from latest label because there can be duplicate empty\n\t * labels in the label set.\n\t */\n\twhile (li > li_start) {\n\t\tli--;\n\n\t\tif (li->h_label != h_label) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"labelinfo[%ld] ->'%!O' != %!O\",\n\t\t\t                     (long) (li - li_start),\n\t\t\t                     (duk_heaphdr *) li->h_label,\n\t\t\t                     (duk_heaphdr *) h_label));\n\t\t\tcontinue;\n\t\t}\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"labelinfo[%ld] -> '%!O' label name matches (still need to check type)\",\n\t\t                     (long) (li - li_start), (duk_heaphdr *) h_label));\n\n\t\t/* currently all labels accept a break, so no explicit check for it now */\n\t\tDUK_ASSERT(li->flags & DUK_LABEL_FLAG_ALLOW_BREAK);\n\n\t\tif (is_break) {\n\t\t\t/* break matches always */\n\t\t\tmatch = 1;\n\t\t\tbreak;\n\t\t} else if (li->flags & DUK_LABEL_FLAG_ALLOW_CONTINUE) {\n\t\t\t/* iteration statements allow continue */\n\t\t\tmatch = 1;\n\t\t\tbreak;\n\t\t} else {\n\t\t\t/* continue matched this label -- we can only continue if this is the empty\n\t\t\t * label, for which duplication is allowed, and thus there is hope of\n\t\t\t * finding a match deeper in the label stack.\n\t\t\t */\n\t\t\tif (h_label != DUK_HTHREAD_STRING_EMPTY_STRING(thr)) {\n\t\t\t\tDUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_LABEL);\n\t\t\t} else {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"continue matched an empty label which does not \"\n\t\t\t\t                     \"allow a continue -> continue lookup deeper in label stack\"));\n\t\t\t}\n\t\t}\n\t}\n\t/* XXX: match flag is awkward, rework */\n\tif (!match) {\n\t\tDUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_LABEL);\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"label match: %!O -> label_id %ld, catch_depth=%ld, pc_label=%ld\",\n\t                     (duk_heaphdr *) h_label, (long) li->label_id,\n\t                     (long) li->catch_depth, (long) li->pc_label));\n\n\t*out_label_id = li->label_id;\n\t*out_label_catch_depth = li->catch_depth;\n\t*out_label_pc = li->pc_label;\n\t*out_is_closest = (li == li_end - 1);\n}\n\nDUK_LOCAL void duk__reset_labels_to_length(duk_compiler_ctx *comp_ctx, duk_int_t len) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\n\tduk_set_length(ctx, comp_ctx->curr_func.labelnames_idx, (duk_size_t) len);\n\tduk_hbuffer_resize(thr, comp_ctx->curr_func.h_labelinfos, sizeof(duk_labelinfo) * (duk_size_t) len);\n}\n\n/*\n *  Expression parsing: duk__expr_nud(), duk__expr_led(), duk__expr_lbp(), and helpers.\n *\n *  - duk__expr_nud(): (\"null denotation\"): process prev_token as a \"start\" of an expression (e.g. literal)\n *  - duk__expr_led(): (\"left denotation\"): process prev_token in the \"middle\" of an expression (e.g. operator)\n *  - duk__expr_lbp(): (\"left-binding power\"): return left-binding power of curr_token\n */\n\n/* object literal key tracking flags */\n#define DUK__OBJ_LIT_KEY_PLAIN  (1 << 0)  /* key encountered as a plain property */\n#define DUK__OBJ_LIT_KEY_GET    (1 << 1)  /* key encountered as a getter */\n#define DUK__OBJ_LIT_KEY_SET    (1 << 2)  /* key encountered as a setter */\n\nDUK_LOCAL void duk__nud_array_literal(duk_compiler_ctx *comp_ctx, duk_ivalue *res) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_reg_t reg_obj;                 /* result reg */\n\tduk_reg_t reg_temp;                /* temp reg */\n\tduk_reg_t temp_start;              /* temp reg value for start of loop */\n\tduk_small_uint_t max_init_values;  /* max # of values initialized in one MPUTARR set */\n\tduk_small_uint_t num_values;       /* number of values in current MPUTARR set */\n\tduk_uarridx_t curr_idx;            /* current (next) array index */\n\tduk_uarridx_t start_idx;           /* start array index of current MPUTARR set */\n\tduk_uarridx_t init_idx;            /* last array index explicitly initialized, +1 */\n\tduk_bool_t require_comma;          /* next loop requires a comma */\n\n\t/* DUK_TOK_LBRACKET already eaten, current token is right after that */\n\tDUK_ASSERT(comp_ctx->prev_token.t == DUK_TOK_LBRACKET);\n\n\tmax_init_values = DUK__MAX_ARRAY_INIT_VALUES;  /* XXX: depend on available temps? */\n\n\treg_obj = DUK__ALLOCTEMP(comp_ctx);\n\tduk__emit_bc(comp_ctx, DUK_OP_NEWARR, reg_obj);  /* XXX: patch initial size hint afterwards? */\n\ttemp_start = DUK__GETTEMP(comp_ctx);\n\n\t/*\n\t *  Emit initializers in sets of maximum max_init_values.\n\t *  Corner cases such as single value initializers do not have\n\t *  special handling now.\n\t *\n\t *  Elided elements must not be emitted as 'undefined' values,\n\t *  because such values would be enumerable (which is incorrect).\n\t *  Also note that trailing elisions must be reflected in the\n\t *  length of the final array but cause no elements to be actually\n\t *  inserted.\n\t */\n\n\tcurr_idx = 0;\n\tinit_idx = 0;         /* tracks maximum initialized index + 1 */\n\tstart_idx = 0;\n\trequire_comma = 0;\n\n\tfor (;;) {\n\t\tnum_values = 0;\n\t\tDUK__SETTEMP(comp_ctx, temp_start);\n\n\t\tif (comp_ctx->curr_token.t == DUK_TOK_RBRACKET) {\n\t\t\tbreak;\n\t\t}\n\n\t\tfor (;;) {\n\t\t\tif (comp_ctx->curr_token.t == DUK_TOK_RBRACKET) {\n\t\t\t\t/* the outer loop will recheck and exit */\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\t/* comma check */\n\t\t\tif (require_comma) {\n\t\t\t\tif (comp_ctx->curr_token.t == DUK_TOK_COMMA) {\n\t\t\t\t\t/* comma after a value, expected */\n\t\t\t\t\tduk__advance(comp_ctx);\n\t\t\t\t\trequire_comma = 0;\n\t\t\t\t\tcontinue;\n\t\t\t\t} else {\n\t\t\t\t\tgoto syntax_error;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (comp_ctx->curr_token.t == DUK_TOK_COMMA) {\n\t\t\t\t\t/* elision - flush */\n\t\t\t\t\tcurr_idx++;\n\t\t\t\t\tduk__advance(comp_ctx);\n\t\t\t\t\t/* if num_values > 0, MPUTARR emitted by outer loop after break */\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t/* else an array initializer element */\n\n\t\t\t/* initial index */\n\t\t\tif (num_values == 0) {\n\t\t\t\tstart_idx = curr_idx;\n\t\t\t\treg_temp = DUK__ALLOCTEMP(comp_ctx);\n\t\t\t\tduk__emit_load_int32(comp_ctx, reg_temp, (duk_int32_t) start_idx);\n\t\t\t}\n\n\t\t\treg_temp = DUK__ALLOCTEMP(comp_ctx);   /* alloc temp just in case, to update max temp */\n\t\t\tDUK__SETTEMP(comp_ctx, reg_temp);\n\t\t\tduk__expr_toforcedreg(comp_ctx, res, DUK__BP_COMMA /*rbp_flags*/, reg_temp /*forced_reg*/);\n\t\t\tDUK__SETTEMP(comp_ctx, reg_temp + 1);\n\n\t\t\tnum_values++;\n\t\t\tcurr_idx++;\n\t\t\trequire_comma = 1;\n\n\t\t\tif (num_values >= max_init_values) {\n\t\t\t\t/* MPUTARR emitted by outer loop */\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (num_values > 0) {\n\t\t\t/* - A is a source register (it's not a write target, but used\n\t\t\t *   to identify the target object) but can be shuffled.\n\t\t\t * - B cannot be shuffled normally because it identifies a range\n\t\t\t *   of registers, the emitter has special handling for this\n\t\t\t *   (the \"no shuffle\" flag must not be set).\n\t\t\t * - C is a non-register number and cannot be shuffled, but\n\t\t\t *   never needs to be.\n\t\t\t */\n\t\t\tduk__emit_a_b_c(comp_ctx,\n\t\t\t                DUK_OP_MPUTARR |\n\t\t\t                    DUK__EMIT_FLAG_NO_SHUFFLE_C |\n\t\t\t                    DUK__EMIT_FLAG_A_IS_SOURCE,\n\t\t\t                (duk_regconst_t) reg_obj,\n\t\t\t                (duk_regconst_t) temp_start,\n\t\t\t                (duk_regconst_t) (num_values + 1));\n\t\t\tinit_idx = start_idx + num_values;\n\n\t\t\t/* num_values and temp_start reset at top of outer loop */\n\t\t}\n\t}\n\n\tDUK_ASSERT(comp_ctx->curr_token.t == DUK_TOK_RBRACKET);\n\tduk__advance(comp_ctx);\n\n\tDUK_DDD(DUK_DDDPRINT(\"array literal done, curridx=%ld, initidx=%ld\",\n\t                     (long) curr_idx, (long) init_idx));\n\n\t/* trailing elisions? */\n\tif (curr_idx > init_idx) {\n\t\t/* yes, must set array length explicitly */\n\t\tDUK_DDD(DUK_DDDPRINT(\"array literal has trailing elisions which affect its length\"));\n\t\treg_temp = DUK__ALLOCTEMP(comp_ctx);\n\t\tduk__emit_load_int32(comp_ctx, reg_temp, (duk_int_t) curr_idx);\n\t\tduk__emit_a_bc(comp_ctx,\n\t\t               DUK_OP_SETALEN | DUK__EMIT_FLAG_A_IS_SOURCE,\n\t\t               (duk_regconst_t) reg_obj,\n\t\t               (duk_regconst_t) reg_temp);\n\t}\n\n\tDUK__SETTEMP(comp_ctx, temp_start);\n\n\tduk__ivalue_regconst(res, (duk_regconst_t) reg_obj);\n\treturn;\n\n syntax_error:\n\tDUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_ARRAY_LITERAL);\n}\n\ntypedef struct {\n\tduk_reg_t reg_obj;\n\tduk_reg_t temp_start;\n\tduk_small_uint_t num_pairs;\n} duk__objlit_state;\n\nDUK_LOCAL void duk__objlit_flush_keys(duk_compiler_ctx *comp_ctx, duk__objlit_state *st) {\n\tif (st->num_pairs > 0) {\n\t\t/* - A is a source register (it's not a write target, but used\n\t\t *   to identify the target object) but can be shuffled.\n\t\t * - B cannot be shuffled normally because it identifies a range\n\t\t *   of registers, the emitter has special handling for this\n\t\t *   (the \"no shuffle\" flag must not be set).\n\t\t * - C is a non-register number and cannot be shuffled, but\n\t\t *   never needs to be.\n\t\t */\n\t\tDUK_ASSERT(st->num_pairs > 0);\n\t\tduk__emit_a_b_c(comp_ctx,\n\t\t                DUK_OP_MPUTOBJ |\n\t\t                    DUK__EMIT_FLAG_NO_SHUFFLE_C |\n\t\t                    DUK__EMIT_FLAG_A_IS_SOURCE,\n\t\t                st->reg_obj,\n\t\t                st->temp_start,\n\t\t                st->num_pairs * 2);\n\t\tst->num_pairs = 0;\n\t}\n\tDUK__SETTEMP(comp_ctx, st->temp_start);\n}\n\nDUK_LOCAL duk_bool_t duk__objlit_load_key(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_token *tok, duk_reg_t reg_temp) {\n\tif (tok->t_nores == DUK_TOK_IDENTIFIER || tok->t_nores == DUK_TOK_STRING) {\n\t\t/* same handling for identifiers and strings */\n\t\tDUK_ASSERT(tok->str1 != NULL);\n\t\tduk_push_hstring((duk_context *) comp_ctx->thr, tok->str1);\n\t} else if (tok->t == DUK_TOK_NUMBER) {\n\t\t/* numbers can be loaded as numbers and coerced on the fly */\n\t\tduk_push_number((duk_context *) comp_ctx->thr, tok->num);\n\t} else {\n\t\treturn 1;  /* error */\n\t}\n\n\tduk__ivalue_plain_fromstack(comp_ctx, res);\n\tDUK__SETTEMP(comp_ctx, reg_temp + 1);\n\tduk__ivalue_toforcedreg(comp_ctx, res, reg_temp);\n\tDUK__SETTEMP(comp_ctx, reg_temp + 1);\n\treturn 0;\n}\n\nDUK_LOCAL void duk__nud_object_literal(duk_compiler_ctx *comp_ctx, duk_ivalue *res) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk__objlit_state st;\n\tduk_reg_t reg_temp;               /* temp reg */\n\tduk_small_uint_t max_init_pairs;  /* max # of key-value pairs initialized in one MPUTOBJ set */\n\tduk_bool_t first;                 /* first value: comma must not precede the value */\n\tduk_bool_t is_set, is_get;        /* temps */\n\n\tDUK_ASSERT(comp_ctx->prev_token.t == DUK_TOK_LCURLY);\n\n\tmax_init_pairs = DUK__MAX_OBJECT_INIT_PAIRS;  /* XXX: depend on available temps? */\n\n\tst.reg_obj = DUK__ALLOCTEMP(comp_ctx);    /* target object */\n\tst.temp_start = DUK__GETTEMP(comp_ctx);   /* start of MPUTOBJ argument list */\n\tst.num_pairs = 0;                         /* number of key/value pairs emitted for current MPUTOBJ set */\n\n\tduk__emit_bc(comp_ctx, DUK_OP_NEWOBJ, st.reg_obj);  /* XXX: patch initial size hint afterwards? */\n\n\t/*\n\t *  Emit initializers in sets of maximum max_init_pairs keys.\n\t *  Setter/getter is handled separately and terminates the\n\t *  current set of initializer values.  Corner cases such as\n\t *  single value initializers do not have special handling now.\n\t */\n\n\tfirst = 1;\n\tfor (;;) {\n\t\t/*\n\t\t *  ES5 and ES2015+ provide a lot of different PropertyDefinition\n\t\t *  formats, see http://www.ecma-international.org/ecma-262/6.0/#sec-object-initializer.\n\t\t *\n\t\t *  PropertyName can be IdentifierName (includes reserved words), a string\n\t\t *  literal, or a number literal.  Note that IdentifierName allows 'get' and\n\t\t *  'set' too, so we need to look ahead to the next token to distinguish:\n\t\t *\n\t\t *     { get : 1 }\n\t\t *\n\t\t *  and\n\t\t *\n\t\t *     { get foo() { return 1 } }\n\t\t *     { get get() { return 1 } }    // 'get' as getter propertyname\n\t\t *\n\t\t *  Finally, a trailing comma is allowed.\n\t\t *\n\t\t *  Key name is coerced to string at compile time (and ends up as a\n\t\t *  a string constant) even for numeric keys (e.g. \"{1:'foo'}\").\n\t\t *  These could be emitted using e.g. LDINT, but that seems hardly\n\t\t *  worth the effort and would increase code size.\n\t\t */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"object literal loop, curr_token->t = %ld\",\n\t\t                     (long) comp_ctx->curr_token.t));\n\n\t\tif (comp_ctx->curr_token.t == DUK_TOK_RCURLY) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (first) {\n\t\t\tfirst = 0;\n\t\t} else {\n\t\t\tif (comp_ctx->curr_token.t != DUK_TOK_COMMA) {\n\t\t\t\tgoto syntax_error;\n\t\t\t}\n\t\t\tduk__advance(comp_ctx);\n\t\t\tif (comp_ctx->curr_token.t == DUK_TOK_RCURLY) {\n\t\t\t\t/* trailing comma followed by rcurly */\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t/* Advance to get one step of lookup. */\n\t\tduk__advance(comp_ctx);\n\n\t\t/* Flush current MPUTOBJ if enough many pairs gathered. */\n\t\tif (st.num_pairs >= max_init_pairs) {\n\t\t\tduk__objlit_flush_keys(comp_ctx, &st);\n\t\t\tDUK_ASSERT(st.num_pairs == 0);\n\t\t}\n\n\t\t/* Reset temp register state and reserve reg_temp and\n\t\t * reg_temp + 1 for handling the current property.\n\t\t */\n\t\tDUK__SETTEMP(comp_ctx, st.temp_start + 2 * st.num_pairs);\n\t\treg_temp = DUK__ALLOCTEMPS(comp_ctx, 2);\n\n\t\t/* NOTE: \"get\" and \"set\" are not officially ReservedWords and the lexer\n\t\t * currently treats them always like ordinary identifiers (DUK_TOK_GET\n\t\t * and DUK_TOK_SET are unused).  They need to be detected based on the\n\t\t * identifier string content.\n\t\t */\n\n\t\tis_get = (comp_ctx->prev_token.t == DUK_TOK_IDENTIFIER &&\n\t\t          comp_ctx->prev_token.str1 == DUK_HTHREAD_STRING_GET(thr));\n\t\tis_set = (comp_ctx->prev_token.t == DUK_TOK_IDENTIFIER &&\n\t\t          comp_ctx->prev_token.str1 == DUK_HTHREAD_STRING_SET(thr));\n\t\tif ((is_get || is_set) && comp_ctx->curr_token.t != DUK_TOK_COLON) {\n\t\t\t/* getter/setter */\n\t\t\tduk_int_t fnum;\n\n\t\t\tduk__objlit_flush_keys(comp_ctx, &st);\n\t\t\tDUK_ASSERT(DUK__GETTEMP(comp_ctx) == st.temp_start);  /* 2 regs are guaranteed to be allocated w.r.t. temp_max */\n\t\t\treg_temp = DUK__ALLOCTEMPS(comp_ctx, 2);\n\n\t\t\tif (duk__objlit_load_key(comp_ctx, res, &comp_ctx->curr_token, reg_temp) != 0) {\n\t\t\t\tgoto syntax_error;\n\t\t\t}\n\n\t\t\t/* curr_token = get/set name */\n\t\t\tfnum = duk__parse_func_like_fnum(comp_ctx, DUK__FUNC_FLAG_GETSET);\n\n\t\t\tduk__emit_a_bc(comp_ctx,\n\t\t\t               DUK_OP_CLOSURE,\n\t\t\t               (duk_regconst_t) (st.temp_start + 1),\n\t\t\t               (duk_regconst_t) fnum);\n\n\t\t\t/* Slot C is used in a non-standard fashion (range of regs),\n\t\t\t * emitter code has special handling for it (must not set the\n\t\t\t * \"no shuffle\" flag).\n\t\t\t */\n\t\t\tduk__emit_a_bc(comp_ctx,\n\t\t\t              (is_get ? DUK_OP_INITGET : DUK_OP_INITSET) | DUK__EMIT_FLAG_A_IS_SOURCE,\n\t\t\t              st.reg_obj,\n\t\t\t              st.temp_start);   /* temp_start+0 = key, temp_start+1 = closure */\n\n\t\t\tDUK_ASSERT(st.num_pairs == 0);  /* temp state is reset on next loop */\n#if defined(DUK_USE_ES6)\n\t\t} else if (comp_ctx->prev_token.t == DUK_TOK_IDENTIFIER &&\n\t\t           (comp_ctx->curr_token.t == DUK_TOK_COMMA || comp_ctx->curr_token.t == DUK_TOK_RCURLY)) {\n\t\t\tduk_bool_t load_rc;\n\n\t\t\tload_rc = duk__objlit_load_key(comp_ctx, res, &comp_ctx->prev_token, reg_temp);\n\t\t\tDUK_UNREF(load_rc);\n\t\t\tDUK_ASSERT(load_rc == 0);  /* always succeeds because token is identifier */\n\n\t\t\tduk__ivalue_var_hstring(comp_ctx, res, comp_ctx->prev_token.str1);\n\t\t\tDUK_ASSERT(DUK__GETTEMP(comp_ctx) == reg_temp + 1);\n\t\t\tduk__ivalue_toforcedreg(comp_ctx, res, reg_temp + 1);\n\n\t\t\tst.num_pairs++;\n\t\t} else if ((comp_ctx->prev_token.t == DUK_TOK_IDENTIFIER ||\n\t\t            comp_ctx->prev_token.t == DUK_TOK_STRING ||\n\t\t            comp_ctx->prev_token.t == DUK_TOK_NUMBER) &&\n\t\t           comp_ctx->curr_token.t == DUK_TOK_LPAREN) {\n\t\t\tduk_int_t fnum;\n\n\t\t\t/* Parsing-wise there's a small hickup here: the token parsing\n\t\t\t * state is one step too advanced for the function parse helper\n\t\t\t * compared to other cases.  The current solution is an extra\n\t\t\t * flag to indicate whether function parsing should use the\n\t\t\t * current or the previous token to starting parsing from.\n\t\t\t */\n\n\t\t\tif (duk__objlit_load_key(comp_ctx, res, &comp_ctx->prev_token, reg_temp) != 0) {\n\t\t\t\tgoto syntax_error;\n\t\t\t}\n\n\t\t\tfnum = duk__parse_func_like_fnum(comp_ctx, DUK__FUNC_FLAG_USE_PREVTOKEN | DUK__FUNC_FLAG_METDEF);\n\n\t\t\tduk__emit_a_bc(comp_ctx,\n\t\t\t               DUK_OP_CLOSURE,\n\t\t\t               (duk_regconst_t) (reg_temp + 1),\n\t\t\t               (duk_regconst_t) fnum);\n\n\t\t\tst.num_pairs++;\n#endif  /* DUK_USE_ES6 */\n\t\t} else {\n#if defined(DUK_USE_ES6)\n\t\t\tif (comp_ctx->prev_token.t == DUK_TOK_LBRACKET) {\n\t\t\t\t/* ES2015 computed property name.  Executor ToPropertyKey()\n\t\t\t\t * coerces the key at runtime.\n\t\t\t\t */\n\t\t\t\tDUK__SETTEMP(comp_ctx, reg_temp);\n\t\t\t\tduk__expr_toforcedreg(comp_ctx, res, DUK__BP_FOR_EXPR, reg_temp);\n\t\t\t\tduk__advance_expect(comp_ctx, DUK_TOK_RBRACKET);\n\n\t\t\t\t/* XXX: If next token is '(' we're dealing with\n\t\t\t\t * the method shorthand with a computed name,\n\t\t\t\t * e.g. { [Symbol.for('foo')](a,b) {} }.  This\n\t\t\t\t * form is not yet supported and causes a\n\t\t\t\t * SyntaxError on the DUK_TOK_COLON check below.\n\t\t\t\t */\n\t\t\t}\n\t\t\telse\n#endif  /* DUK_USE_ES6 */\n\t\t\t{\n\t\t\t\tif (duk__objlit_load_key(comp_ctx, res, &comp_ctx->prev_token, reg_temp) != 0) {\n\t\t\t\t\tgoto syntax_error;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tduk__advance_expect(comp_ctx, DUK_TOK_COLON);\n\n\t\t\tDUK__SETTEMP(comp_ctx, reg_temp + 1);\n\t\t\tduk__expr_toforcedreg(comp_ctx, res, DUK__BP_COMMA /*rbp_flags*/, reg_temp + 1 /*forced_reg*/);\n\n\t\t\tst.num_pairs++;\n\t\t}\n\t}  /* property loop */\n\n\t/* Flush remaining properties. */\n\tduk__objlit_flush_keys(comp_ctx, &st);\n\tDUK_ASSERT(st.num_pairs == 0);\n\tDUK_ASSERT(DUK__GETTEMP(comp_ctx) == st.temp_start);\n\n\tDUK_ASSERT(comp_ctx->curr_token.t == DUK_TOK_RCURLY);\n\tduk__advance(comp_ctx);\n\n\tduk__ivalue_regconst(res, (duk_regconst_t) st.reg_obj);\n\treturn;\n\n syntax_error:\n\tDUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_OBJECT_LITERAL);\n}\n\n/* Parse argument list.  Arguments are written to temps starting from\n * \"next temp\".  Returns number of arguments parsed.  Expects left paren\n * to be already eaten, and eats the right paren before returning.\n */\nDUK_LOCAL duk_int_t duk__parse_arguments(duk_compiler_ctx *comp_ctx, duk_ivalue *res) {\n\tduk_int_t nargs = 0;\n\tduk_reg_t reg_temp;\n\n\t/* Note: expect that caller has already eaten the left paren */\n\n\tDUK_DDD(DUK_DDDPRINT(\"start parsing arguments, prev_token.t=%ld, curr_token.t=%ld\",\n\t                     (long) comp_ctx->prev_token.t, (long) comp_ctx->curr_token.t));\n\n\tfor (;;) {\n\t\tif (comp_ctx->curr_token.t == DUK_TOK_RPAREN) {\n\t\t\tbreak;\n\t\t}\n\t\tif (nargs > 0) {\n\t\t\tduk__advance_expect(comp_ctx, DUK_TOK_COMMA);\n\t\t}\n\n\t\t/* We want the argument expression value to go to \"next temp\"\n\t\t * without additional moves.  That should almost always be the\n\t\t * case, but we double check after expression parsing.\n\t\t *\n\t\t * This is not the cleanest possible approach.\n\t\t */\n\n\t\treg_temp = DUK__ALLOCTEMP(comp_ctx);  /* bump up \"allocated\" reg count, just in case */\n\t\tDUK__SETTEMP(comp_ctx, reg_temp);\n\n\t\t/* binding power must be high enough to NOT allow comma expressions directly */\n\t\tduk__expr_toforcedreg(comp_ctx, res, DUK__BP_COMMA /*rbp_flags*/, reg_temp);  /* always allow 'in', coerce to 'tr' just in case */\n\n\t\tDUK__SETTEMP(comp_ctx, reg_temp + 1);\n\t\tnargs++;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"argument #%ld written into reg %ld\", (long) nargs, (long) reg_temp));\n\t}\n\n\t/* eat the right paren */\n\tduk__advance_expect(comp_ctx, DUK_TOK_RPAREN);\n\n\tDUK_DDD(DUK_DDDPRINT(\"end parsing arguments\"));\n\n\treturn nargs;\n}\n\nDUK_LOCAL duk_bool_t duk__expr_is_empty(duk_compiler_ctx *comp_ctx) {\n\t/* empty expressions can be detected conveniently with nud/led counts */\n\treturn (comp_ctx->curr_func.nud_count == 0) &&\n\t       (comp_ctx->curr_func.led_count == 0);\n}\n\nDUK_LOCAL void duk__expr_nud(duk_compiler_ctx *comp_ctx, duk_ivalue *res) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_token *tk;\n\tduk_reg_t temp_at_entry;\n\tduk_small_int_t tok;\n\tduk_uint32_t args;  /* temp variable to pass constants and flags to shared code */\n\n\t/*\n\t *  ctx->prev_token     token to process with duk__expr_nud()\n\t *  ctx->curr_token     updated by caller\n\t *\n\t *  Note: the token in the switch below has already been eaten.\n\t */\n\n\ttemp_at_entry = DUK__GETTEMP(comp_ctx);\n\n\tcomp_ctx->curr_func.nud_count++;\n\n\ttk = &comp_ctx->prev_token;\n\ttok = tk->t;\n\tres->t = DUK_IVAL_NONE;\n\n\tDUK_DDD(DUK_DDDPRINT(\"duk__expr_nud(), prev_token.t=%ld, allow_in=%ld, paren_level=%ld\",\n\t                     (long) tk->t, (long) comp_ctx->curr_func.allow_in, (long) comp_ctx->curr_func.paren_level));\n\n\tswitch (tok) {\n\n\t/* PRIMARY EXPRESSIONS */\n\n\tcase DUK_TOK_THIS: {\n\t\tduk_reg_t reg_temp;\n\t\treg_temp = DUK__ALLOCTEMP(comp_ctx);\n\t\tduk__emit_bc(comp_ctx,\n\t\t             DUK_OP_LDTHIS,\n\t\t             (duk_regconst_t) reg_temp);\n\t\tduk__ivalue_regconst(res, (duk_regconst_t) reg_temp);\n\t\treturn;\n\t}\n\tcase DUK_TOK_IDENTIFIER: {\n\t\tduk__ivalue_var_hstring(comp_ctx, res, tk->str1);\n\t\treturn;\n\t}\n\tcase DUK_TOK_NULL: {\n\t\tduk_push_null(ctx);\n\t\tgoto plain_value;\n\t}\n\tcase DUK_TOK_TRUE: {\n\t\tduk_push_true(ctx);\n\t\tgoto plain_value;\n\t}\n\tcase DUK_TOK_FALSE: {\n\t\tduk_push_false(ctx);\n\t\tgoto plain_value;\n\t}\n\tcase DUK_TOK_NUMBER: {\n\t\tduk_push_number(ctx, tk->num);\n\t\tgoto plain_value;\n\t}\n\tcase DUK_TOK_STRING: {\n\t\tDUK_ASSERT(tk->str1 != NULL);\n\t\tduk_push_hstring(ctx, tk->str1);\n\t\tgoto plain_value;\n\t}\n\tcase DUK_TOK_REGEXP: {\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\t\tduk_reg_t reg_temp;\n\t\tduk_regconst_t rc_re_bytecode;  /* const */\n\t\tduk_regconst_t rc_re_source;    /* const */\n\n\t\tDUK_ASSERT(tk->str1 != NULL);\n\t\tDUK_ASSERT(tk->str2 != NULL);\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"emitting regexp op, str1=%!O, str2=%!O\",\n\t\t                     (duk_heaphdr *) tk->str1,\n\t\t                     (duk_heaphdr *) tk->str2));\n\n\t\treg_temp = DUK__ALLOCTEMP(comp_ctx);\n\t\tduk_push_hstring(ctx, tk->str1);\n\t\tduk_push_hstring(ctx, tk->str2);\n\n\t\t/* [ ... pattern flags ] */\n\n\t\tduk_regexp_compile(thr);\n\n\t\t/* [ ... escaped_source bytecode ] */\n\n\t\trc_re_bytecode = duk__getconst(comp_ctx);\n\t\trc_re_source = duk__getconst(comp_ctx);\n\n\t\tduk__emit_a_b_c(comp_ctx,\n\t\t                DUK_OP_REGEXP | DUK__EMIT_FLAG_BC_REGCONST,\n\t\t                (duk_regconst_t) reg_temp /*a*/,\n\t\t                rc_re_bytecode /*b*/,\n\t\t                rc_re_source /*c*/);\n\n\t\tduk__ivalue_regconst(res, (duk_regconst_t) reg_temp);\n\t\treturn;\n#else  /* DUK_USE_REGEXP_SUPPORT */\n\t\tgoto syntax_error;\n#endif  /* DUK_USE_REGEXP_SUPPORT */\n\t}\n\tcase DUK_TOK_LBRACKET: {\n\t\tDUK_DDD(DUK_DDDPRINT(\"parsing array literal\"));\n\t\tduk__nud_array_literal(comp_ctx, res);\n\t\treturn;\n\t}\n\tcase DUK_TOK_LCURLY: {\n\t\tDUK_DDD(DUK_DDDPRINT(\"parsing object literal\"));\n\t\tduk__nud_object_literal(comp_ctx, res);\n\t\treturn;\n\t}\n\tcase DUK_TOK_LPAREN: {\n\t\tduk_bool_t prev_allow_in;\n\n\t\tcomp_ctx->curr_func.paren_level++;\n\t\tprev_allow_in = comp_ctx->curr_func.allow_in;\n\t\tcomp_ctx->curr_func.allow_in = 1; /* reset 'allow_in' for parenthesized expression */\n\n\t\tduk__expr(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/);  /* Expression, terminates at a ')' */\n\n\t\tduk__advance_expect(comp_ctx, DUK_TOK_RPAREN);\n\t\tcomp_ctx->curr_func.allow_in = prev_allow_in;\n\t\tcomp_ctx->curr_func.paren_level--;\n\t\treturn;\n\t}\n\n\t/* MEMBER/NEW/CALL EXPRESSIONS */\n\n\tcase DUK_TOK_NEW: {\n\t\t/*\n\t\t *  Parsing an expression starting with 'new' is tricky because\n\t\t *  there are multiple possible productions deriving from\n\t\t *  LeftHandSideExpression which begin with 'new'.\n\t\t *\n\t\t *  We currently resort to one-token lookahead to distinguish the\n\t\t *  cases.  Hopefully this is correct.  The binding power must be\n\t\t *  such that parsing ends at an LPAREN (CallExpression) but not at\n\t\t *  a PERIOD or LBRACKET (MemberExpression).\n\t\t *\n\t\t *  See doc/compiler.rst for discussion on the parsing approach,\n\t\t *  and testcases/test-dev-new.js for a bunch of documented tests.\n\t\t */\n\n\t\tduk_reg_t reg_target;\n\t\tduk_int_t nargs;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"begin parsing new expression\"));\n\n\t\treg_target = DUK__ALLOCTEMP(comp_ctx);\n\t\tduk__expr_toforcedreg(comp_ctx, res, DUK__BP_CALL /*rbp_flags*/, reg_target /*forced_reg*/);\n\t\tDUK__SETTEMP(comp_ctx, reg_target + 1);\n\n\t\tif (comp_ctx->curr_token.t == DUK_TOK_LPAREN) {\n\t\t\t/* 'new' MemberExpression Arguments */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"new expression has argument list\"));\n\t\t\tduk__advance(comp_ctx);\n\t\t\tnargs = duk__parse_arguments(comp_ctx, res);  /* parse args starting from \"next temp\", reg_target + 1 */\n\t\t\t/* right paren eaten */\n\t\t} else {\n\t\t\t/* 'new' MemberExpression */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"new expression has no argument list\"));\n\t\t\tnargs = 0;\n\t\t}\n\n\t\t/* Opcode slot C is used in a non-standard way, so shuffling\n\t\t * is not allowed.\n\t\t */\n\t\tduk__emit_a_bc(comp_ctx,\n\t\t              DUK_OP_NEW | DUK__EMIT_FLAG_NO_SHUFFLE_A,\n\t\t              nargs /*num_args*/,\n\t\t              reg_target /*target*/);\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"end parsing new expression\"));\n\n\t\tduk__ivalue_regconst(res, (duk_regconst_t) reg_target);\n\t\treturn;\n\t}\n\n\t/* FUNCTION EXPRESSIONS */\n\n\tcase DUK_TOK_FUNCTION: {\n\t\t/* Function expression.  Note that any statement beginning with 'function'\n\t\t * is handled by the statement parser as a function declaration, or a\n\t\t * non-standard function expression/statement (or a SyntaxError).  We only\n\t\t * handle actual function expressions (occurring inside an expression) here.\n\t\t *\n\t\t * O(depth^2) parse count for inner functions is handled by recording a\n\t\t * lexer offset on the first compilation pass, so that the function can\n\t\t * be efficiently skipped on the second pass.  This is encapsulated into\n\t\t * duk__parse_func_like_fnum().\n\t\t */\n\n\t\tduk_reg_t reg_temp;\n\t\tduk_int_t fnum;\n\n\t\treg_temp = DUK__ALLOCTEMP(comp_ctx);\n\n\t\t/* curr_token follows 'function' */\n\t\tfnum = duk__parse_func_like_fnum(comp_ctx, 0 /*flags*/);\n\t\tDUK_DDD(DUK_DDDPRINT(\"parsed inner function -> fnum %ld\", (long) fnum));\n\n\t\tduk__emit_a_bc(comp_ctx,\n\t\t               DUK_OP_CLOSURE,\n\t\t               (duk_regconst_t) reg_temp /*a*/,\n\t\t               (duk_regconst_t) fnum /*bc*/);\n\n\t\tduk__ivalue_regconst(res, (duk_regconst_t) reg_temp);\n\t\treturn;\n\t}\n\n\t/* UNARY EXPRESSIONS */\n\n\tcase DUK_TOK_DELETE: {\n\t\t/* Delete semantics are a bit tricky.  The description in E5 specification\n\t\t * is kind of confusing, because it distinguishes between resolvability of\n\t\t * a reference (which is only known at runtime) seemingly at compile time\n\t\t * (= SyntaxError throwing).\n\t\t */\n\t\tduk__expr(comp_ctx, res, DUK__BP_MULTIPLICATIVE /*rbp_flags*/);  /* UnaryExpression */\n\t\tif (res->t == DUK_IVAL_VAR) {\n\t\t\t/* not allowed in strict mode, regardless of whether resolves;\n\t\t\t * in non-strict mode DELVAR handles both non-resolving and\n\t\t\t * resolving cases (the specification description is a bit confusing).\n\t\t\t */\n\n\t\t\tduk_reg_t reg_temp;\n\t\t\tduk_reg_t reg_varbind;\n\t\t\tduk_regconst_t rc_varname;\n\n\t\t\tif (comp_ctx->curr_func.is_strict) {\n\t\t\t\tDUK_ERROR_SYNTAX(thr, DUK_STR_CANNOT_DELETE_IDENTIFIER);\n\t\t\t}\n\n\t\t\tDUK__SETTEMP(comp_ctx, temp_at_entry);\n\t\t\treg_temp = DUK__ALLOCTEMP(comp_ctx);\n\n\t\t\tduk_dup(ctx, res->x1.valstack_idx);\n\t\t\tif (duk__lookup_lhs(comp_ctx, &reg_varbind, &rc_varname)) {\n\t\t\t\t/* register bound variables are non-configurable -> always false */\n\t\t\t\tduk__emit_bc(comp_ctx,\n\t\t\t\t             DUK_OP_LDFALSE,\n\t\t\t\t             (duk_regconst_t) reg_temp);\n\t\t\t} else {\n\t\t\t\tduk_dup(ctx, res->x1.valstack_idx);\n\t\t\t\trc_varname = duk__getconst(comp_ctx);\n\t\t\t\tduk__emit_a_bc(comp_ctx,\n\t\t\t\t               DUK_OP_DELVAR,\n\t\t\t\t               (duk_regconst_t) reg_temp,\n\t\t\t\t               (duk_regconst_t) rc_varname);\n\t\t\t}\n\t\t\tduk__ivalue_regconst(res, (duk_regconst_t) reg_temp);\n\t\t} else if (res->t == DUK_IVAL_PROP) {\n\t\t\tduk_reg_t reg_temp;\n\t\t\tduk_reg_t reg_obj;\n\t\t\tduk_regconst_t rc_key;\n\n\t\t\tDUK__SETTEMP(comp_ctx, temp_at_entry);\n\t\t\treg_temp = DUK__ALLOCTEMP(comp_ctx);\n\t\t\treg_obj = duk__ispec_toregconst_raw(comp_ctx, &res->x1, -1 /*forced_reg*/, 0 /*flags*/);  /* don't allow const */\n\t\t\trc_key = duk__ispec_toregconst_raw(comp_ctx, &res->x2, -1 /*forced_reg*/, DUK__IVAL_FLAG_ALLOW_CONST /*flags*/);\n\t\t\tduk__emit_a_b_c(comp_ctx,\n\t\t\t                DUK_OP_DELPROP | DUK__EMIT_FLAG_BC_REGCONST,\n\t\t\t                (duk_regconst_t) reg_temp,\n\t\t\t                (duk_regconst_t) reg_obj,\n\t\t\t                rc_key);\n\n\t\t\tduk__ivalue_regconst(res, (duk_regconst_t) reg_temp);\n\t\t} else {\n\t\t\t/* non-Reference deletion is always 'true', even in strict mode */\n\t\t\tduk_push_true(ctx);\n\t\t\tgoto plain_value;\n\t\t}\n\t\treturn;\n\t}\n\tcase DUK_TOK_VOID: {\n\t\tduk__expr_toplain_ignore(comp_ctx, res, DUK__BP_MULTIPLICATIVE /*rbp_flags*/);  /* UnaryExpression */\n\t\tduk_push_undefined(ctx);\n\t\tgoto plain_value;\n\t}\n\tcase DUK_TOK_TYPEOF: {\n\t\t/* 'typeof' must handle unresolvable references without throwing\n\t\t * a ReferenceError (E5 Section 11.4.3).  Register mapped values\n\t\t * will never be unresolvable so special handling is only required\n\t\t * when an identifier is a \"slow path\" one.\n\t\t */\n\t\tduk__expr(comp_ctx, res, DUK__BP_MULTIPLICATIVE /*rbp_flags*/);  /* UnaryExpression */\n\n\t\tif (res->t == DUK_IVAL_VAR) {\n\t\t\tduk_reg_t reg_varbind;\n\t\t\tduk_regconst_t rc_varname;\n\t\t\tduk_reg_t reg_temp;\n\n\t\t\tduk_dup(ctx, res->x1.valstack_idx);\n\t\t\tif (!duk__lookup_lhs(comp_ctx, &reg_varbind, &rc_varname)) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"typeof for an identifier name which could not be resolved \"\n\t\t\t\t                     \"at compile time, need to use special run-time handling\"));\n\t\t\t\treg_temp = DUK__ALLOCTEMP(comp_ctx);\n\t\t\t\tduk__emit_a_bc(comp_ctx,\n\t\t\t\t               DUK_OP_TYPEOFID,\n\t\t\t\t               reg_temp,\n\t\t\t\t               rc_varname);\n\t\t\t\tduk__ivalue_regconst(res, (duk_regconst_t) reg_temp);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\n\t\targs = DUK_OP_TYPEOF;\n\t\tgoto unary;\n\t}\n\tcase DUK_TOK_INCREMENT: {\n\t\targs = (DUK_OP_PREINCP << 8) + DUK_OP_PREINCR;\n\t\tgoto preincdec;\n\t}\n\tcase DUK_TOK_DECREMENT: {\n\t\targs = (DUK_OP_PREDECP << 8) + DUK_OP_PREDECR;\n\t\tgoto preincdec;\n\t}\n\tcase DUK_TOK_ADD: {\n\t\t/* unary plus */\n\t\tduk__expr(comp_ctx, res, DUK__BP_MULTIPLICATIVE /*rbp_flags*/);  /* UnaryExpression */\n\t\tif (res->t == DUK_IVAL_PLAIN && res->x1.t == DUK_ISPEC_VALUE &&\n\t\t    duk_is_number(ctx, res->x1.valstack_idx)) {\n\t\t\t/* unary plus of a number is identity */\n\t\t\treturn;\n\t\t}\n\t\targs = DUK_OP_UNP;\n\t\tgoto unary;\n\t}\n\tcase DUK_TOK_SUB: {\n\t\t/* unary minus */\n\t\tduk__expr(comp_ctx, res, DUK__BP_MULTIPLICATIVE /*rbp_flags*/);  /* UnaryExpression */\n\t\tif (res->t == DUK_IVAL_PLAIN && res->x1.t == DUK_ISPEC_VALUE &&\n\t\t    duk_is_number(ctx, res->x1.valstack_idx)) {\n\t\t\t/* this optimization is important to handle negative literals\n\t\t\t * (which are not directly provided by the lexical grammar)\n\t\t\t */\n\t\t\tduk_tval *tv_num;\n\t\t\tduk_double_union du;\n\n\t\t\ttv_num = DUK_GET_TVAL_POSIDX(ctx, res->x1.valstack_idx);\n\t\t\tDUK_ASSERT(tv_num != NULL);\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv_num));\n\t\t\tdu.d = DUK_TVAL_GET_NUMBER(tv_num);\n\t\t\tdu.d = -du.d;\n\t\t\tDUK_DBLUNION_NORMALIZE_NAN_CHECK(&du);\n\t\t\tDUK_TVAL_SET_NUMBER(tv_num, du.d);\n\t\t\treturn;\n\t\t}\n\t\targs = DUK_OP_UNM;\n\t\tgoto unary;\n\t}\n\tcase DUK_TOK_BNOT: {\n\t\tduk__expr(comp_ctx, res, DUK__BP_MULTIPLICATIVE /*rbp_flags*/);  /* UnaryExpression */\n\t\targs = DUK_OP_BNOT;\n\t\tgoto unary;\n\t}\n\tcase DUK_TOK_LNOT: {\n\t\tduk__expr(comp_ctx, res, DUK__BP_MULTIPLICATIVE /*rbp_flags*/);  /* UnaryExpression */\n\t\tif (res->t == DUK_IVAL_PLAIN && res->x1.t == DUK_ISPEC_VALUE) {\n\t\t\t/* Very minimal inlining to handle common idioms '!0' and '!1',\n\t\t\t * and also boolean arguments like '!false' and '!true'.\n\t\t\t */\n\t\t\tduk_tval *tv_val;\n\n\t\t\ttv_val = DUK_GET_TVAL_POSIDX(ctx, res->x1.valstack_idx);\n\t\t\tDUK_ASSERT(tv_val != NULL);\n\t\t\tif (DUK_TVAL_IS_NUMBER(tv_val)) {\n\t\t\t\tduk_double_t d;\n\t\t\t\td = DUK_TVAL_GET_NUMBER(tv_val);\n\t\t\t\tif (d == 0.0) {\n\t\t\t\t\t/* Matches both +0 and -0 on purpose. */\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"inlined lnot: !0 -> true\"));\n\t\t\t\t\tDUK_TVAL_SET_BOOLEAN_TRUE(tv_val);\n\t\t\t\t\treturn;\n\t\t\t\t} else if (d == 1.0) {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"inlined lnot: !1 -> false\"));\n\t\t\t\t\tDUK_TVAL_SET_BOOLEAN_FALSE(tv_val);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else if (DUK_TVAL_IS_BOOLEAN(tv_val)) {\n\t\t\t\tduk_small_int_t v;\n\t\t\t\tv = DUK_TVAL_GET_BOOLEAN(tv_val);\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"inlined lnot boolean: %ld\", (long) v));\n\t\t\t\tDUK_ASSERT(v == 0 || v == 1);\n\t\t\t\tDUK_TVAL_SET_BOOLEAN(tv_val, v ^ 0x01);\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\targs = DUK_OP_LNOT;\n\t\tgoto unary;\n\t}\n\n\t}  /* end switch */\n\n\tDUK_ERROR_SYNTAX(thr, DUK_STR_PARSE_ERROR);\n\treturn;\n\n unary:\n\t{\n\t\t/* Unary opcodes use just the 'BC' register source because it\n\t\t * matches current shuffle limits, and maps cleanly to 16 high\n\t\t * bits of the opcode.\n\t\t */\n\n\t\tduk_reg_t reg_src, reg_res;\n\n\t\treg_src = duk__ivalue_toregconst_raw(comp_ctx, res, -1 /*forced_reg*/, 0 /*flags*/);\n\t\tif (DUK__ISTEMP(comp_ctx, reg_src)) {\n\t\t\treg_res = reg_src;\n\t\t} else {\n\t\t\treg_res = DUK__ALLOCTEMP(comp_ctx);\n\t\t}\n\t\tduk__emit_a_bc(comp_ctx,\n\t\t             args,\n\t\t             reg_res,\n\t\t             (duk_regconst_t) reg_src);\n\t\tduk__ivalue_regconst(res, (duk_regconst_t) reg_res);\n\t\treturn;\n\t}\n\n preincdec:\n\t{\n\t\t/* preincrement and predecrement */\n\t\tduk_reg_t reg_res;\n\t\tduk_small_uint_t args_op1 = args & 0xff;  /* DUK_OP_PREINCR/DUK_OP_PREDECR */\n\t\tduk_small_uint_t args_op2 = args >> 8;    /* DUK_OP_PREINCP_RR/DUK_OP_PREDECP_RR */\n\n\t\t/* Specific assumptions for opcode numbering. */\n\t\tDUK_ASSERT(DUK_OP_PREINCR + 4 == DUK_OP_PREINCV);\n\t\tDUK_ASSERT(DUK_OP_PREDECR + 4 == DUK_OP_PREDECV);\n\n\t\treg_res = DUK__ALLOCTEMP(comp_ctx);\n\n\t\tduk__expr(comp_ctx, res, DUK__BP_MULTIPLICATIVE /*rbp_flags*/);  /* UnaryExpression */\n\t\tif (res->t == DUK_IVAL_VAR) {\n\t\t\tduk_hstring *h_varname;\n\t\t\tduk_reg_t reg_varbind;\n\t\t\tduk_regconst_t rc_varname;\n\n\t\t\th_varname = duk_known_hstring(ctx, res->x1.valstack_idx);\n\n\t\t\tif (duk__hstring_is_eval_or_arguments_in_strict_mode(comp_ctx, h_varname)) {\n\t\t\t\tgoto syntax_error;\n\t\t\t}\n\n\t\t\tduk_dup(ctx, res->x1.valstack_idx);\n\t\t\tif (duk__lookup_lhs(comp_ctx, &reg_varbind, &rc_varname)) {\n\t\t\t\tduk__emit_a_bc(comp_ctx,\n\t\t\t\t               args_op1,  /* e.g. DUK_OP_PREINCR */\n\t\t\t\t               (duk_regconst_t) reg_res,\n\t\t\t\t               (duk_regconst_t) reg_varbind);\n\t\t\t} else {\n\t\t\t\tduk__emit_a_bc(comp_ctx,\n\t\t\t\t                args_op1 + 4,  /* e.g. DUK_OP_PREINCV */\n\t\t\t\t                (duk_regconst_t) reg_res,\n\t\t\t\t                rc_varname);\n\t\t\t}\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"preincdec to '%!O' -> reg_varbind=%ld, rc_varname=%ld\",\n\t\t\t                     (duk_heaphdr *) h_varname, (long) reg_varbind, (long) rc_varname));\n\t\t} else if (res->t == DUK_IVAL_PROP) {\n\t\t\tduk_reg_t reg_obj;  /* allocate to reg only (not const) */\n\t\t\tduk_regconst_t rc_key;\n\t\t\treg_obj = duk__ispec_toregconst_raw(comp_ctx, &res->x1, -1 /*forced_reg*/, 0 /*flags*/);  /* don't allow const */\n\t\t\trc_key = duk__ispec_toregconst_raw(comp_ctx, &res->x2, -1 /*forced_reg*/, DUK__IVAL_FLAG_ALLOW_CONST /*flags*/);\n\t\t\tduk__emit_a_b_c(comp_ctx,\n\t\t\t                args_op2 | DUK__EMIT_FLAG_BC_REGCONST,  /* e.g. DUK_OP_PREINCP */\n\t\t\t                (duk_regconst_t) reg_res,\n\t\t\t                (duk_regconst_t) reg_obj,\n\t\t\t                rc_key);\n\t\t} else {\n\t\t\t/* Technically return value is not needed because INVLHS will\n\t\t\t * unconditially throw a ReferenceError.  Coercion is necessary\n\t\t\t * for proper semantics (consider ToNumber() called for an object).\n\t\t\t * Use DUK_OP_UNP with a dummy register to get ToNumber().\n\t\t\t */\n\n\t\t\tduk__ivalue_toforcedreg(comp_ctx, res, reg_res);\n\t\t\tduk__emit_bc(comp_ctx,\n\t\t\t             DUK_OP_UNP,\n\t\t\t             reg_res);  /* for side effects, result ignored */\n\t\t\tduk__emit_op_only(comp_ctx,\n\t\t\t                  DUK_OP_INVLHS);\n\t\t}\n\t\tDUK__SETTEMP(comp_ctx, reg_res + 1);\n\t\tduk__ivalue_regconst(res, (duk_regconst_t) reg_res);\n\t\treturn;\n\t}\n\n plain_value:\n\t{\n\t\t/* Stack top contains plain value */\n\t\tduk__ivalue_plain_fromstack(comp_ctx, res);\n\t\treturn;\n\t}\n\n syntax_error:\n\tDUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_EXPRESSION);\n}\n\n/* XXX: add flag to indicate whether caller cares about return value; this\n * affects e.g. handling of assignment expressions.  This change needs API\n * changes elsewhere too.\n */\nDUK_LOCAL void duk__expr_led(duk_compiler_ctx *comp_ctx, duk_ivalue *left, duk_ivalue *res) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_token *tk;\n\tduk_small_int_t tok;\n\tduk_uint32_t args;  /* temp variable to pass constants and flags to shared code */\n\n\t/*\n\t *  ctx->prev_token     token to process with duk__expr_led()\n\t *  ctx->curr_token     updated by caller\n\t */\n\n\tcomp_ctx->curr_func.led_count++;\n\n\t/* The token in the switch has already been eaten here */\n\ttk = &comp_ctx->prev_token;\n\ttok = tk->t;\n\n\tDUK_DDD(DUK_DDDPRINT(\"duk__expr_led(), prev_token.t=%ld, allow_in=%ld, paren_level=%ld\",\n\t                     (long) tk->t, (long) comp_ctx->curr_func.allow_in, (long) comp_ctx->curr_func.paren_level));\n\n\t/* XXX: default priority for infix operators is duk__expr_lbp(tok) -> get it here? */\n\n\tswitch (tok) {\n\n\t/* PRIMARY EXPRESSIONS */\n\n\tcase DUK_TOK_PERIOD: {\n\t\t/* Property access expressions are critical for correct LHS ordering,\n\t\t * see comments in duk__expr()!\n\t\t *\n\t\t * A conservative approach would be to use duk__ivalue_totempconst()\n\t\t * for 'left'.  However, allowing a reg-bound variable seems safe here\n\t\t * and is nice because \"foo.bar\" is a common expression.  If the ivalue\n\t\t * is used in an expression a GETPROP will occur before any changes to\n\t\t * the base value can occur.  If the ivalue is used as an assignment\n\t\t * LHS, the assignment code will ensure the base value is safe from\n\t\t * RHS mutation.\n\t\t */\n\n\t\t/* XXX: This now coerces an identifier into a GETVAR to a temp, which\n\t\t * causes an extra LDREG in call setup.  It's sufficient to coerce to a\n\t\t * unary ivalue?\n\t\t */\n\t\tduk__ivalue_toplain(comp_ctx, left);\n\n\t\t/* NB: must accept reserved words as property name */\n\t\tif (comp_ctx->curr_token.t_nores != DUK_TOK_IDENTIFIER) {\n\t\t\tDUK_ERROR_SYNTAX(thr, DUK_STR_EXPECTED_IDENTIFIER);\n\t\t}\n\n\t\tres->t = DUK_IVAL_PROP;\n\t\tduk__copy_ispec(comp_ctx, &left->x1, &res->x1);  /* left.x1 -> res.x1 */\n\t\tDUK_ASSERT(comp_ctx->curr_token.str1 != NULL);\n\t\tduk_push_hstring(ctx, comp_ctx->curr_token.str1);\n\t\tduk_replace(ctx, res->x2.valstack_idx);\n\t\tres->x2.t = DUK_ISPEC_VALUE;\n\n\t\t/* special RegExp literal handling after IdentifierName */\n\t\tcomp_ctx->curr_func.reject_regexp_in_adv = 1;\n\n\t\tduk__advance(comp_ctx);\n\t\treturn;\n\t}\n\tcase DUK_TOK_LBRACKET: {\n\t\t/* Property access expressions are critical for correct LHS ordering,\n\t\t * see comments in duk__expr()!\n\t\t */\n\n\t\t/* XXX: optimize temp reg use */\n\t\t/* XXX: similar coercion issue as in DUK_TOK_PERIOD */\n\t\t/* XXX: coerce to regs? it might be better for enumeration use, where the\n\t\t * same PROP ivalue is used multiple times.  Or perhaps coerce PROP further\n\t\t * there?\n\t\t */\n\t\t/* XXX: for simple cases like x['y'] an unnecessary LDREG is\n\t\t * emitted for the base value; could avoid it if we knew that\n\t\t * the key expression is safe (e.g. just a single literal).\n\t\t */\n\n\t\t/* The 'left' value must not be a register bound variable\n\t\t * because it may be mutated during the rest of the expression\n\t\t * and E5.1 Section 11.2.1 specifies the order of evaluation\n\t\t * so that the base value is evaluated first.\n\t\t * See: test-bug-nested-prop-mutate.js.\n\t\t */\n\t\tduk__ivalue_totempconst(comp_ctx, left);\n\t\tduk__expr_toplain(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/);  /* Expression, ']' terminates */\n\t\tduk__advance_expect(comp_ctx, DUK_TOK_RBRACKET);\n\n\t\tres->t = DUK_IVAL_PROP;\n\t\tduk__copy_ispec(comp_ctx, &res->x1, &res->x2);   /* res.x1 -> res.x2 */\n\t\tduk__copy_ispec(comp_ctx, &left->x1, &res->x1);  /* left.x1 -> res.x1 */\n\t\treturn;\n\t}\n\tcase DUK_TOK_LPAREN: {\n\t\t/* function call */\n\t\tduk_reg_t reg_cs = DUK__ALLOCTEMPS(comp_ctx, 2);\n\t\tduk_int_t nargs;\n\t\tduk_small_uint_t call_op = DUK_OP_CALL;\n\n\t\t/* XXX: attempt to get the call result to \"next temp\" whenever\n\t\t * possible to avoid unnecessary register shuffles.\n\t\t */\n\n\t\t/*\n\t\t *  Setup call: target and 'this' binding.  Three cases:\n\t\t *\n\t\t *    1. Identifier base (e.g. \"foo()\")\n\t\t *    2. Property base (e.g. \"foo.bar()\")\n\t\t *    3. Register base (e.g. \"foo()()\"; i.e. when a return value is a function)\n\t\t */\n\n\t\tif (left->t == DUK_IVAL_VAR) {\n\t\t\tduk_hstring *h_varname;\n\t\t\tduk_reg_t reg_varbind;\n\t\t\tduk_regconst_t rc_varname;\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"function call with identifier base\"));\n\n\t\t\th_varname = duk_known_hstring(ctx, left->x1.valstack_idx);\n\t\t\tif (h_varname == DUK_HTHREAD_STRING_EVAL(thr)) {\n\t\t\t\t/* Potential direct eval call detected, flag the CALL\n\t\t\t\t * so that a run-time \"direct eval\" check is made and\n\t\t\t\t * special behavior may be triggered.  Note that this\n\t\t\t\t * does not prevent 'eval' from being register bound.\n\t\t\t\t */\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"function call with identifier 'eval' \"\n\t\t\t\t                     \"-> using EVALCALL, marking function \"\n\t\t\t\t                     \"as may_direct_eval\"));\n\t\t\t\tcall_op = DUK_OP_EVALCALL;\n\t\t\t\tcomp_ctx->curr_func.may_direct_eval = 1;\n\t\t\t}\n\n\t\t\tduk_dup(ctx, left->x1.valstack_idx);\n\t\t\tif (duk__lookup_lhs(comp_ctx, &reg_varbind, &rc_varname)) {\n\t\t\t\tduk__emit_a_bc(comp_ctx,\n\t\t\t\t              DUK_OP_CSREG | DUK__EMIT_FLAG_A_IS_SOURCE,\n\t\t\t\t              (duk_regconst_t) reg_varbind,\n\t\t\t\t              (duk_regconst_t) (reg_cs + 0));\n\t\t\t} else {\n\t\t\t\t/* XXX: expand target register or constant field to\n\t\t\t\t * reduce shuffling.\n\t\t\t\t */\n\t\t\t\tDUK_ASSERT(DUK__ISCONST(rc_varname));\n\t\t\t\tduk__emit_a_b(comp_ctx,\n\t\t\t\t              DUK_OP_CSVAR | DUK__EMIT_FLAG_BC_REGCONST,\n\t\t\t\t              (duk_regconst_t) (reg_cs + 0),\n\t\t\t\t              rc_varname);\n\t\t\t}\n\t\t} else if (left->t == DUK_IVAL_PROP) {\n\t\t\t/* Call through a property lookup, E5 Section 11.2.3, step 6.a.i,\n\t\t\t * E5 Section 10.4.3.  There used to be a separate CSPROP opcode\n\t\t\t * but a typical call setup took 3 opcodes (e.g. LDREG, LDCONST,\n\t\t\t * CSPROP) and the same can be achieved with ordinary loads.\n\t\t\t */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"function call with property base\"));\n\n\t\t\tduk__ispec_toforcedreg(comp_ctx, &left->x1, reg_cs + 1);  /* base */\n\t\t\tduk__ivalue_toforcedreg(comp_ctx, left, reg_cs + 0);  /* base[key] */\n\t\t} else {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"function call with register base\"));\n\n\t\t\tduk__ivalue_toforcedreg(comp_ctx, left, reg_cs + 0);\n\t\t\tduk__emit_a_bc(comp_ctx,\n\t\t\t               DUK_OP_CSREG | DUK__EMIT_FLAG_A_IS_SOURCE,\n\t\t\t               (duk_regconst_t) (reg_cs + 0),\n\t\t\t               (duk_regconst_t) (reg_cs + 0));  /* in-place setup */\n\t\t}\n\n\t\tDUK__SETTEMP(comp_ctx, reg_cs + 2);\n\t\tnargs = duk__parse_arguments(comp_ctx, res);  /* parse args starting from \"next temp\" */\n\n\t\t/* Tailcalls are handled by back-patching the opcode to TAILCALL to the\n\t\t * already emitted instruction later (in return statement parser).\n\t\t */\n\n\t\tduk__emit_a_bc(comp_ctx,\n\t\t               call_op | DUK__EMIT_FLAG_NO_SHUFFLE_A,\n\t\t               (duk_regconst_t) nargs /*numargs*/,\n\t\t               (duk_regconst_t) reg_cs /*basereg*/);\n\t\tDUK__SETTEMP(comp_ctx, reg_cs + 1);    /* result in csreg */\n\n\t\tduk__ivalue_regconst(res, (duk_regconst_t) reg_cs);\n\t\treturn;\n\t}\n\n\t/* POSTFIX EXPRESSION */\n\n\tcase DUK_TOK_INCREMENT: {\n\t\targs = (DUK_OP_POSTINCP_RR << 16) + (DUK_OP_POSTINCR << 8) + 0;\n\t\tgoto postincdec;\n\t}\n\tcase DUK_TOK_DECREMENT: {\n\t\targs = (DUK_OP_POSTDECP_RR << 16) + (DUK_OP_POSTDECR << 8) + 0;\n\t\tgoto postincdec;\n\t}\n\n\t/* EXPONENTIATION EXPRESSION */\n\n#if defined(DUK_USE_ES7_EXP_OPERATOR)\n\tcase DUK_TOK_EXP: {\n\t\targs = (DUK_OP_EXP << 8) + DUK__BP_EXPONENTIATION - 1;  /* UnaryExpression */\n\t\tgoto binary;\n\t}\n#endif\n\n\t/* MULTIPLICATIVE EXPRESSION */\n\n\tcase DUK_TOK_MUL: {\n\t\targs = (DUK_OP_MUL << 8) + DUK__BP_MULTIPLICATIVE;  /* ExponentiationExpression */\n\t\tgoto binary;\n\t}\n\tcase DUK_TOK_DIV: {\n\t\targs = (DUK_OP_DIV << 8) + DUK__BP_MULTIPLICATIVE;  /* ExponentiationExpression */\n\t\tgoto binary;\n\t}\n\tcase DUK_TOK_MOD: {\n\t\targs = (DUK_OP_MOD << 8) + DUK__BP_MULTIPLICATIVE;  /* ExponentiationExpression */\n\t\tgoto binary;\n\t}\n\n\t/* ADDITIVE EXPRESSION */\n\n\tcase DUK_TOK_ADD: {\n\t\targs = (DUK_OP_ADD << 8) + DUK__BP_ADDITIVE;  /* MultiplicativeExpression */\n\t\tgoto binary;\n\t}\n\tcase DUK_TOK_SUB: {\n\t\targs = (DUK_OP_SUB << 8) + DUK__BP_ADDITIVE;  /* MultiplicativeExpression */\n\t\tgoto binary;\n\t}\n\n\t/* SHIFT EXPRESSION */\n\n\tcase DUK_TOK_ALSHIFT: {\n\t\t/* << */\n\t\targs = (DUK_OP_BASL << 8) + DUK__BP_SHIFT;\n\t\tgoto binary;\n\t}\n\tcase DUK_TOK_ARSHIFT: {\n\t\t/* >> */\n\t\targs = (DUK_OP_BASR << 8) + DUK__BP_SHIFT;\n\t\tgoto binary;\n\t}\n\tcase DUK_TOK_RSHIFT: {\n\t\t/* >>> */\n\t\targs = (DUK_OP_BLSR << 8) + DUK__BP_SHIFT;\n\t\tgoto binary;\n\t}\n\n\t/* RELATIONAL EXPRESSION */\n\n\tcase DUK_TOK_LT: {\n\t\t/* < */\n\t\targs = (DUK_OP_LT << 8) + DUK__BP_RELATIONAL;\n\t\tgoto binary;\n\t}\n\tcase DUK_TOK_GT: {\n\t\targs = (DUK_OP_GT << 8) + DUK__BP_RELATIONAL;\n\t\tgoto binary;\n\t}\n\tcase DUK_TOK_LE: {\n\t\targs = (DUK_OP_LE << 8) + DUK__BP_RELATIONAL;\n\t\tgoto binary;\n\t}\n\tcase DUK_TOK_GE: {\n\t\targs = (DUK_OP_GE << 8) + DUK__BP_RELATIONAL;\n\t\tgoto binary;\n\t}\n\tcase DUK_TOK_INSTANCEOF: {\n\t\targs = (DUK_OP_INSTOF << 8) + DUK__BP_RELATIONAL;\n\t\tgoto binary;\n\t}\n\tcase DUK_TOK_IN: {\n\t\targs = (DUK_OP_IN << 8) + DUK__BP_RELATIONAL;\n\t\tgoto binary;\n\t}\n\n\t/* EQUALITY EXPRESSION */\n\n\tcase DUK_TOK_EQ: {\n\t\targs = (DUK_OP_EQ << 8) + DUK__BP_EQUALITY;\n\t\tgoto binary;\n\t}\n\tcase DUK_TOK_NEQ: {\n\t\targs = (DUK_OP_NEQ << 8) + DUK__BP_EQUALITY;\n\t\tgoto binary;\n\t}\n\tcase DUK_TOK_SEQ: {\n\t\targs = (DUK_OP_SEQ << 8) + DUK__BP_EQUALITY;\n\t\tgoto binary;\n\t}\n\tcase DUK_TOK_SNEQ: {\n\t\targs = (DUK_OP_SNEQ << 8) + DUK__BP_EQUALITY;\n\t\tgoto binary;\n\t}\n\n\t/* BITWISE EXPRESSIONS */\n\n\tcase DUK_TOK_BAND: {\n\t\targs = (DUK_OP_BAND << 8) + DUK__BP_BAND;\n\t\tgoto binary;\n\t}\n\tcase DUK_TOK_BXOR: {\n\t\targs = (DUK_OP_BXOR << 8) + DUK__BP_BXOR;\n\t\tgoto binary;\n\t}\n\tcase DUK_TOK_BOR: {\n\t\targs = (DUK_OP_BOR << 8) + DUK__BP_BOR;\n\t\tgoto binary;\n\t}\n\n\t/* LOGICAL EXPRESSIONS */\n\n\tcase DUK_TOK_LAND: {\n\t\t/* syntactically left-associative but parsed as right-associative */\n\t\targs = (1 << 8) + DUK__BP_LAND - 1;\n\t\tgoto binary_logical;\n\t}\n\tcase DUK_TOK_LOR: {\n\t\t/* syntactically left-associative but parsed as right-associative */\n\t\targs = (0 << 8) + DUK__BP_LOR - 1;\n\t\tgoto binary_logical;\n\t}\n\n\t/* CONDITIONAL EXPRESSION */\n\n\tcase DUK_TOK_QUESTION: {\n\t\t/* XXX: common reg allocation need is to reuse a sub-expression's temp reg,\n\t\t * but only if it really is a temp.  Nothing fancy here now.\n\t\t */\n\t\tduk_reg_t reg_temp;\n\t\tduk_int_t pc_jump1;\n\t\tduk_int_t pc_jump2;\n\n\t\treg_temp = DUK__ALLOCTEMP(comp_ctx);\n\t\tduk__ivalue_toforcedreg(comp_ctx, left, reg_temp);\n\t\tduk__emit_if_true_skip(comp_ctx, reg_temp);\n\t\tpc_jump1 = duk__emit_jump_empty(comp_ctx);  /* jump to false */\n\t\tduk__expr_toforcedreg(comp_ctx, res, DUK__BP_COMMA /*rbp_flags*/, reg_temp /*forced_reg*/);  /* AssignmentExpression */\n\t\tduk__advance_expect(comp_ctx, DUK_TOK_COLON);\n\t\tpc_jump2 = duk__emit_jump_empty(comp_ctx);  /* jump to end */\n\t\tduk__patch_jump_here(comp_ctx, pc_jump1);\n\t\tduk__expr_toforcedreg(comp_ctx, res, DUK__BP_COMMA /*rbp_flags*/, reg_temp /*forced_reg*/);  /* AssignmentExpression */\n\t\tduk__patch_jump_here(comp_ctx, pc_jump2);\n\n\t\tDUK__SETTEMP(comp_ctx, reg_temp + 1);\n\t\tduk__ivalue_regconst(res, (duk_regconst_t) reg_temp);\n\t\treturn;\n\t}\n\n\t/* ASSIGNMENT EXPRESSION */\n\n\tcase DUK_TOK_EQUALSIGN: {\n\t\t/*\n\t\t *  Assignments are right associative, allows e.g.\n\t\t *    a = 5;\n\t\t *    a += b = 9;   // same as a += (b = 9)\n\t\t *  -> expression value 14, a = 14, b = 9\n\t\t *\n\t\t *  Right associativiness is reflected in the BP for recursion,\n\t\t *  \"-1\" ensures assignment operations are allowed.\n\t\t *\n\t\t *  XXX: just use DUK__BP_COMMA (i.e. no need for 2-step bp levels)?\n\t\t */\n\t\targs = (DUK_OP_NONE << 8) + DUK__BP_ASSIGNMENT - 1;   /* DUK_OP_NONE marks a 'plain' assignment */\n\t\tgoto assign;\n\t}\n\tcase DUK_TOK_ADD_EQ: {\n\t\t/* right associative */\n\t\targs = (DUK_OP_ADD << 8) + DUK__BP_ASSIGNMENT - 1;\n\t\tgoto assign;\n\t}\n\tcase DUK_TOK_SUB_EQ: {\n\t\t/* right associative */\n\t\targs = (DUK_OP_SUB << 8) + DUK__BP_ASSIGNMENT - 1;\n\t\tgoto assign;\n\t}\n\tcase DUK_TOK_MUL_EQ: {\n\t\t/* right associative */\n\t\targs = (DUK_OP_MUL << 8) + DUK__BP_ASSIGNMENT - 1;\n\t\tgoto assign;\n\t}\n\tcase DUK_TOK_DIV_EQ: {\n\t\t/* right associative */\n\t\targs = (DUK_OP_DIV << 8) + DUK__BP_ASSIGNMENT - 1;\n\t\tgoto assign;\n\t}\n\tcase DUK_TOK_MOD_EQ: {\n\t\t/* right associative */\n\t\targs = (DUK_OP_MOD << 8) + DUK__BP_ASSIGNMENT - 1;\n\t\tgoto assign;\n\t}\n#if defined(DUK_USE_ES7_EXP_OPERATOR)\n\tcase DUK_TOK_EXP_EQ: {\n\t\t/* right associative */\n\t\targs = (DUK_OP_EXP << 8) + DUK__BP_ASSIGNMENT - 1;\n\t\tgoto assign;\n\t}\n#endif\n\tcase DUK_TOK_ALSHIFT_EQ: {\n\t\t/* right associative */\n\t\targs = (DUK_OP_BASL << 8) + DUK__BP_ASSIGNMENT - 1;\n\t\tgoto assign;\n\t}\n\tcase DUK_TOK_ARSHIFT_EQ: {\n\t\t/* right associative */\n\t\targs = (DUK_OP_BASR << 8) + DUK__BP_ASSIGNMENT - 1;\n\t\tgoto assign;\n\t}\n\tcase DUK_TOK_RSHIFT_EQ: {\n\t\t/* right associative */\n\t\targs = (DUK_OP_BLSR << 8) + DUK__BP_ASSIGNMENT - 1;\n\t\tgoto assign;\n\t}\n\tcase DUK_TOK_BAND_EQ: {\n\t\t/* right associative */\n\t\targs = (DUK_OP_BAND << 8) + DUK__BP_ASSIGNMENT - 1;\n\t\tgoto assign;\n\t}\n\tcase DUK_TOK_BOR_EQ: {\n\t\t/* right associative */\n\t\targs = (DUK_OP_BOR << 8) + DUK__BP_ASSIGNMENT - 1;\n\t\tgoto assign;\n\t}\n\tcase DUK_TOK_BXOR_EQ: {\n\t\t/* right associative */\n\t\targs = (DUK_OP_BXOR << 8) + DUK__BP_ASSIGNMENT - 1;\n\t\tgoto assign;\n\t}\n\n\t/* COMMA */\n\n\tcase DUK_TOK_COMMA: {\n\t\t/* right associative */\n\n\t\tduk__ivalue_toplain_ignore(comp_ctx, left);  /* need side effects, not value */\n\t\tduk__expr_toplain(comp_ctx, res, DUK__BP_COMMA - 1 /*rbp_flags*/);\n\n\t\t/* return 'res' (of right part) as our result */\n\t\treturn;\n\t}\n\n\tdefault: {\n\t\tbreak;\n\t}\n\t}\n\n\tDUK_D(DUK_DPRINT(\"parse error: unexpected token: %ld\", (long) tok));\n\tDUK_ERROR_SYNTAX(thr, DUK_STR_PARSE_ERROR);\n\treturn;\n\n#if 0\n\t/* XXX: shared handling for 'duk__expr_lhs'? */\n\tif (comp_ctx->curr_func.paren_level == 0 && XXX) {\n\t\tcomp_ctx->curr_func.duk__expr_lhs = 0;\n\t}\n#endif\n\n binary:\n\t/*\n\t *  Shared handling of binary operations\n\t *\n\t *  args = (opcode << 8) + rbp\n\t */\n\t{\n\t\tduk__ivalue_toplain(comp_ctx, left);\n\t\tduk__expr_toplain(comp_ctx, res, args & 0xff /*rbp_flags*/);\n\n\t\t/* combine left->x1 and res->x1 (right->x1, really) -> (left->x1 OP res->x1) */\n\t\tDUK_ASSERT(left->t == DUK_IVAL_PLAIN);\n\t\tDUK_ASSERT(res->t == DUK_IVAL_PLAIN);\n\n\t\tres->t = DUK_IVAL_ARITH;\n\t\tres->op = (args >> 8) & 0xff;\n\n\t\tres->x2.t = res->x1.t;\n\t\tres->x2.regconst = res->x1.regconst;\n\t\tduk_copy(ctx, res->x1.valstack_idx, res->x2.valstack_idx);\n\n\t\tres->x1.t = left->x1.t;\n\t\tres->x1.regconst = left->x1.regconst;\n\t\tduk_copy(ctx, left->x1.valstack_idx, res->x1.valstack_idx);\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"binary op, res: t=%ld, x1.t=%ld, x1.regconst=0x%08lx, x2.t=%ld, x2.regconst=0x%08lx\",\n\t\t                     (long) res->t, (long) res->x1.t, (unsigned long) res->x1.regconst, (long) res->x2.t, (unsigned long) res->x2.regconst));\n\t\treturn;\n\t}\n\n binary_logical:\n\t/*\n\t *  Shared handling for logical AND and logical OR.\n\t *\n\t *  args = (truthval << 8) + rbp\n\t *\n\t *  Truthval determines when to skip right-hand-side.\n\t *  For logical AND truthval=1, for logical OR truthval=0.\n\t *\n\t *  See doc/compiler.rst for discussion on compiling logical\n\t *  AND and OR expressions.  The approach here is very simplistic,\n\t *  generating extra jumps and multiple evaluations of truth values,\n\t *  but generates code on-the-fly with only local back-patching.\n\t *\n\t *  Both logical AND and OR are syntactically left-associated.\n\t *  However, logical ANDs are compiled as right associative\n\t *  expressions, i.e. \"A && B && C\" as \"A && (B && C)\", to allow\n\t *  skip jumps to skip over the entire tail.  Similarly for logical OR.\n\t */\n\n\t{\n\t\tduk_reg_t reg_temp;\n\t\tduk_int_t pc_jump;\n\t\tduk_small_uint_t args_truthval = args >> 8;\n\t\tduk_small_uint_t args_rbp = args & 0xff;\n\n\t\t/* XXX: unoptimal use of temps, resetting */\n\n\t\treg_temp = DUK__ALLOCTEMP(comp_ctx);\n\n\t\tduk__ivalue_toforcedreg(comp_ctx, left, reg_temp);\n\t\tDUK_ASSERT(DUK__ISREG(reg_temp));\n\t\tduk__emit_bc(comp_ctx,\n\t\t            (args_truthval ? DUK_OP_IFTRUE_R : DUK_OP_IFFALSE_R),\n\t\t            (duk_regconst_t) reg_temp);  /* skip jump conditionally */\n\t\tpc_jump = duk__emit_jump_empty(comp_ctx);\n\t\tduk__expr_toforcedreg(comp_ctx, res, args_rbp /*rbp_flags*/, reg_temp /*forced_reg*/);\n\t\tduk__patch_jump_here(comp_ctx, pc_jump);\n\n\t\tduk__ivalue_regconst(res, (duk_regconst_t) reg_temp);\n\t\treturn;\n\t}\n\n assign:\n\t/*\n\t *  Shared assignment expression handling\n\t *\n\t *  args = (opcode << 8) + rbp\n\t *\n\t *  If 'opcode' is DUK_OP_NONE, plain assignment without arithmetic.\n\t *  Syntactically valid left-hand-side forms which are not accepted as\n\t *  left-hand-side values (e.g. as in \"f() = 1\") must NOT cause a\n\t *  SyntaxError, but rather a run-time ReferenceError.\n\t *\n\t *  When evaluating X <op>= Y, the LHS (X) is conceptually evaluated\n\t *  to a temporary first.  The RHS is then evaluated.  Finally, the\n\t *  <op> is applied to the initial value of RHS (not the value after\n\t *  RHS evaluation), and written to X.  Doing so concretely generates\n\t *  inefficient code so we'd like to avoid the temporary when possible.\n\t *  See: https://github.com/svaarala/duktape/pull/992.\n\t *\n\t *  The expression value (final LHS value, written to RHS) is\n\t *  conceptually copied into a fresh temporary so that it won't\n\t *  change even if the LHS/RHS values change in outer expressions.\n\t *  For example, it'd be generally incorrect for the expression value\n\t *  to be the RHS register binding, unless there's a guarantee that it\n\t *  won't change during further expression evaluation.  Using the\n\t *  temporary concretely produces inefficient bytecode, so we try to\n\t *  avoid the extra temporary for some known-to-be-safe cases.\n\t *  Currently the only safe case we detect is a \"top level assignment\",\n\t *  for example \"x = y + z;\", where the assignment expression value is\n\t *  ignored.\n\t *  See: test-dev-assign-expr.js and test-bug-assign-mutate-gh381.js.\n\t */\n\n\t{\n\t\tduk_small_uint_t args_op = args >> 8;\n\t\tduk_small_uint_t args_rbp = args & 0xff;\n\t\tduk_bool_t toplevel_assign;\n\n\t\t/* XXX: here we need to know if 'left' is left-hand-side compatible.\n\t\t * That information is no longer available from current expr parsing\n\t\t * state; it would need to be carried into the 'left' ivalue or by\n\t\t * some other means.\n\t\t */\n\n\t\t/* A top-level assignment is e.g. \"x = y;\".  For these it's safe\n\t\t * to use the RHS as-is as the expression value, even if the RHS\n\t\t * is a reg-bound identifier.  The RHS ('res') is right associative\n\t\t * so it has consumed all other assignment level operations; the\n\t\t * only relevant lower binding power construct is comma operator\n\t\t * which will ignore the expression value provided here.  Usually\n\t\t * the top level assignment expression value is ignored, but it\n\t\t * is relevant for e.g. eval code.\n\t\t */\n\t\ttoplevel_assign = (comp_ctx->curr_func.nud_count == 1 && /* one token before */\n\t\t                   comp_ctx->curr_func.led_count == 1);  /* one operator (= assign) */\n\t\tDUK_DDD(DUK_DDDPRINT(\"assignment: nud_count=%ld, led_count=%ld, toplevel_assign=%ld\",\n\t\t                     (long) comp_ctx->curr_func.nud_count,\n\t\t                     (long) comp_ctx->curr_func.led_count,\n\t\t                     (long) toplevel_assign));\n\n\t\tif (left->t == DUK_IVAL_VAR) {\n\t\t\tduk_hstring *h_varname;\n\t\t\tduk_reg_t reg_varbind;\n\t\t\tduk_regconst_t rc_varname;\n\n\t\t\tDUK_ASSERT(left->x1.t == DUK_ISPEC_VALUE);  /* LHS is already side effect free */\n\n\t\t\th_varname = duk_known_hstring(ctx, left->x1.valstack_idx);\n\t\t\tif (duk__hstring_is_eval_or_arguments_in_strict_mode(comp_ctx, h_varname)) {\n\t\t\t\t/* E5 Section 11.13.1 (and others for other assignments), step 4. */\n\t\t\t\tgoto syntax_error_lvalue;\n\t\t\t}\n\t\t\tduk_dup(ctx, left->x1.valstack_idx);\n\t\t\t(void) duk__lookup_lhs(comp_ctx, &reg_varbind, &rc_varname);\n\n\t\t\tif (args_op == DUK_OP_NONE) {\n\t\t\t\tduk__expr(comp_ctx, res, args_rbp /*rbp_flags*/);\n\t\t\t\tif (toplevel_assign) {\n\t\t\t\t\t/* Any 'res' will do. */\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"plain assignment, toplevel assign, use as is\"));\n\t\t\t\t} else {\n\t\t\t\t\t/* 'res' must be a plain ivalue, and not register-bound variable. */\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"plain assignment, not toplevel assign, ensure not a reg-bound identifier\"));\n\t\t\t\t\tif (res->t != DUK_IVAL_PLAIN || (res->x1.t == DUK_ISPEC_REGCONST &&\n\t\t\t\t\t                                 (res->x1.regconst & DUK__CONST_MARKER) == 0 &&\n\t\t\t\t\t                                 !DUK__ISTEMP(comp_ctx, res->x1.regconst))) {\n\t\t\t\t\t\tduk__ivalue_totempconst(comp_ctx, res);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t/* For X <op>= Y we need to evaluate the pre-op\n\t\t\t\t * value of X before evaluating the RHS: the RHS\n\t\t\t\t * can change X, but when we do <op> we must use\n\t\t\t\t * the pre-op value.\n\t\t\t\t */\n\t\t\t\tduk_reg_t reg_temp;\n\n\t\t\t\treg_temp = DUK__ALLOCTEMP(comp_ctx);\n\n\t\t\t\tif (reg_varbind >= 0) {\n\t\t\t\t\tduk_reg_t reg_res;\n\t\t\t\t\tduk_reg_t reg_src;\n\t\t\t\t\tduk_int_t pc_temp_load;\n\t\t\t\t\tduk_int_t pc_before_rhs;\n\t\t\t\t\tduk_int_t pc_after_rhs;\n\n\t\t\t\t\tif (toplevel_assign) {\n\t\t\t\t\t\t/* 'reg_varbind' is the operation result and can also\n\t\t\t\t\t\t * become the expression value for top level assignments\n\t\t\t\t\t\t * such as: \"var x; x += y;\".\n\t\t\t\t\t\t */\n\t\t\t\t\t\tDUK_DD(DUK_DDPRINT(\"<op>= expression is top level, write directly to reg_varbind\"));\n\t\t\t\t\t\treg_res = reg_varbind;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t/* Not safe to use 'reg_varbind' as assignment expression\n\t\t\t\t\t\t * value, so go through a temp.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tDUK_DD(DUK_DDPRINT(\"<op>= expression is not top level, write to reg_temp\"));\n\t\t\t\t\t\treg_res = reg_temp;  /* reg_res should be smallest possible */\n\t\t\t\t\t\treg_temp = DUK__ALLOCTEMP(comp_ctx);\n\t\t\t\t\t}\n\n\t\t\t\t\t/* Try to optimize X <op>= Y for reg-bound\n\t\t\t\t\t * variables.  Detect side-effect free RHS\n\t\t\t\t\t * narrowly by seeing whether it emits code.\n\t\t\t\t\t * If not, rewind the code emitter and overwrite\n\t\t\t\t\t * the unnecessary temp reg load.\n\t\t\t\t\t */\n\n\t\t\t\t\tpc_temp_load = duk__get_current_pc(comp_ctx);\n\t\t\t\t\tduk__emit_a_bc(comp_ctx,\n\t\t\t\t\t               DUK_OP_LDREG,\n\t\t\t\t\t               (duk_regconst_t) reg_temp,\n\t\t\t\t\t               reg_varbind);\n\n\t\t\t\t\tpc_before_rhs = duk__get_current_pc(comp_ctx);\n\t\t\t\t\tduk__expr_toregconst(comp_ctx, res, args_rbp /*rbp_flags*/);\n\t\t\t\t\tDUK_ASSERT(res->t == DUK_IVAL_PLAIN && res->x1.t == DUK_ISPEC_REGCONST);\n\t\t\t\t\tpc_after_rhs = duk__get_current_pc(comp_ctx);\n\n\t\t\t\t\tDUK_DD(DUK_DDPRINT(\"pc_temp_load=%ld, pc_before_rhs=%ld, pc_after_rhs=%ld\",\n\t\t\t\t\t                   (long) pc_temp_load, (long) pc_before_rhs,\n\t\t\t\t\t                   (long) pc_after_rhs));\n\n\t\t\t\t\tif (pc_after_rhs == pc_before_rhs) {\n\t\t\t\t\t\t/* Note: if the reg_temp load generated shuffling\n\t\t\t\t\t\t * instructions, we may need to rewind more than\n\t\t\t\t\t\t * one instruction, so use explicit PC computation.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tDUK_DD(DUK_DDPRINT(\"rhs is side effect free, rewind and avoid unnecessary temp for reg-based <op>=\"));\n\t\t\t\t\t\tDUK_BW_ADD_PTR(comp_ctx->thr, &comp_ctx->curr_func.bw_code, (pc_temp_load - pc_before_rhs) * sizeof(duk_compiler_instr));\n\t\t\t\t\t\treg_src = reg_varbind;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tDUK_DD(DUK_DDPRINT(\"rhs evaluation emitted code, not sure if rhs is side effect free; use temp reg for LHS\"));\n\t\t\t\t\t\treg_src = reg_temp;\n\t\t\t\t\t}\n\n\t\t\t\t\tduk__emit_a_b_c(comp_ctx,\n\t\t\t\t\t                args_op | DUK__EMIT_FLAG_BC_REGCONST,\n\t\t\t\t\t                (duk_regconst_t) reg_res,\n\t\t\t\t\t                (duk_regconst_t) reg_src,\n\t\t\t\t\t                res->x1.regconst);\n\n\t\t\t\t\tres->x1.regconst = (duk_regconst_t) reg_res;\n\n\t\t\t\t\t/* Ensure compact use of temps. */\n\t\t\t\t\tif (DUK__ISTEMP(comp_ctx, reg_res)) {\n\t\t\t\t\t\tDUK__SETTEMP(comp_ctx, reg_res + 1);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t/* When LHS is not register bound, always go through a\n\t\t\t\t\t * temporary.  No optimization for top level assignment.\n\t\t\t\t\t */\n\n\t\t\t\t\tduk__emit_a_bc(comp_ctx,\n\t\t\t\t\t               DUK_OP_GETVAR,\n\t\t\t\t\t               (duk_regconst_t) reg_temp,\n\t\t\t\t\t               rc_varname);\n\n\t\t\t\t\tduk__expr_toregconst(comp_ctx, res, args_rbp /*rbp_flags*/);\n\t\t\t\t\tDUK_ASSERT(res->t == DUK_IVAL_PLAIN && res->x1.t == DUK_ISPEC_REGCONST);\n\n\t\t\t\t\tduk__emit_a_b_c(comp_ctx,\n\t\t\t\t\t                args_op | DUK__EMIT_FLAG_BC_REGCONST,\n\t\t\t\t\t                (duk_regconst_t) reg_temp,\n\t\t\t\t\t                (duk_regconst_t) reg_temp,\n\t\t\t\t\t                res->x1.regconst);\n\t\t\t\t\tres->x1.regconst = (duk_regconst_t) reg_temp;\n\t\t\t\t}\n\n\t\t\t\tDUK_ASSERT(res->t == DUK_IVAL_PLAIN && res->x1.t == DUK_ISPEC_REGCONST);\n\t\t\t}\n\n\t\t\t/* At this point 'res' holds the potential expression value.\n\t\t\t * It can be basically any ivalue here, including a reg-bound\n\t\t\t * identifier (if code above deems it safe) or a unary/binary\n\t\t\t * operation.  Operations must be resolved to a side effect free\n\t\t\t * plain value, and the side effects must happen exactly once.\n\t\t\t */\n\n\t\t\tif (reg_varbind >= 0) {\n\t\t\t\tif (res->t != DUK_IVAL_PLAIN) {\n\t\t\t\t\t/* Resolve 'res' directly into the LHS binding, and use\n\t\t\t\t\t * that as the expression value if safe.  If not safe,\n\t\t\t\t\t * resolve to a temp/const and copy to LHS.\n\t\t\t\t\t */\n\t\t\t\t\tif (toplevel_assign) {\n\t\t\t\t\t\tduk__ivalue_toforcedreg(comp_ctx, res, (duk_int_t) reg_varbind);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tduk__ivalue_totempconst(comp_ctx, res);\n\t\t\t\t\t\tduk__copy_ivalue(comp_ctx, res, left);  /* use 'left' as a temp */\n\t\t\t\t\t\tduk__ivalue_toforcedreg(comp_ctx, left, (duk_int_t) reg_varbind);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t/* Use 'res' as the expression value (it's side effect\n\t\t\t\t\t * free and may be a plain value, a register, or a\n\t\t\t\t\t * constant) and write it to the LHS binding too.\n\t\t\t\t\t */\n\t\t\t\t\tduk__copy_ivalue(comp_ctx, res, left);  /* use 'left' as a temp */\n\t\t\t\t\tduk__ivalue_toforcedreg(comp_ctx, left, (duk_int_t) reg_varbind);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t/* Only a reg fits into 'A' so coerce 'res' into a register\n\t\t\t\t * for PUTVAR.\n\t\t\t\t *\n\t\t\t\t * XXX: here the current A/B/C split is suboptimal: we could\n\t\t\t\t * just use 9 bits for reg_res (and support constants) and 17\n\t\t\t\t * instead of 18 bits for the varname const index.\n\t\t\t\t */\n\n\t\t\t\tduk__ivalue_toreg(comp_ctx, res);\n\t\t\t\tduk__emit_a_bc(comp_ctx,\n\t\t\t\t               DUK_OP_PUTVAR | DUK__EMIT_FLAG_A_IS_SOURCE,\n\t\t\t\t               res->x1.regconst,\n\t\t\t\t               rc_varname);\n\t\t\t}\n\n\t\t\t/* 'res' contains expression value */\n\t\t} else if (left->t == DUK_IVAL_PROP) {\n\t\t\t/* E5 Section 11.13.1 (and others) step 4 never matches for prop writes -> no check */\n\t\t\tduk_reg_t reg_obj;\n\t\t\tduk_regconst_t rc_key;\n\t\t\tduk_regconst_t rc_res;\n\t\t\tduk_reg_t reg_temp;\n\n\t\t\t/* Property access expressions ('a[b]') are critical to correct\n\t\t\t * LHS evaluation ordering, see test-dev-assign-eval-order*.js.\n\t\t\t * We must make sure that the LHS target slot (base object and\n\t\t\t * key) don't change during RHS evaluation.  The only concrete\n\t\t\t * problem is a register reference to a variable-bound register\n\t\t\t * (i.e., non-temp).  Require temp regs for both key and base.\n\t\t\t *\n\t\t\t * Don't allow a constant for the object (even for a number\n\t\t\t * etc), as it goes into the 'A' field of the opcode.\n\t\t\t */\n\n\t\t\treg_obj = duk__ispec_toregconst_raw(comp_ctx,\n\t\t\t                                    &left->x1,\n\t\t\t                                    -1 /*forced_reg*/,\n\t\t\t                                    DUK__IVAL_FLAG_REQUIRE_TEMP /*flags*/);\n\n\t\t\trc_key = duk__ispec_toregconst_raw(comp_ctx,\n\t\t\t                                   &left->x2,\n\t\t\t                                   -1 /*forced_reg*/,\n\t\t\t                                   DUK__IVAL_FLAG_REQUIRE_TEMP | DUK__IVAL_FLAG_ALLOW_CONST /*flags*/);\n\n\t\t\t/* Evaluate RHS only when LHS is safe. */\n\n\t\t\tif (args_op == DUK_OP_NONE) {\n\t\t\t\tduk__expr_toregconst(comp_ctx, res, args_rbp /*rbp_flags*/);\n\t\t\t\tDUK_ASSERT(res->t == DUK_IVAL_PLAIN && res->x1.t == DUK_ISPEC_REGCONST);\n\t\t\t\trc_res = res->x1.regconst;\n\t\t\t} else {\n\t\t\t\treg_temp = DUK__ALLOCTEMP(comp_ctx);\n\t\t\t\tduk__emit_a_b_c(comp_ctx,\n\t\t\t\t                DUK_OP_GETPROP | DUK__EMIT_FLAG_BC_REGCONST,\n\t\t\t\t                (duk_regconst_t) reg_temp,\n\t\t\t\t                (duk_regconst_t) reg_obj,\n\t\t\t\t                rc_key);\n\n\t\t\t\tduk__expr_toregconst(comp_ctx, res, args_rbp /*rbp_flags*/);\n\t\t\t\tDUK_ASSERT(res->t == DUK_IVAL_PLAIN && res->x1.t == DUK_ISPEC_REGCONST);\n\n\t\t\t\tduk__emit_a_b_c(comp_ctx,\n\t\t\t\t                args_op | DUK__EMIT_FLAG_BC_REGCONST,\n\t\t\t\t                (duk_regconst_t) reg_temp,\n\t\t\t\t                (duk_regconst_t) reg_temp,\n\t\t\t\t                res->x1.regconst);\n\t\t\t\trc_res = (duk_regconst_t) reg_temp;\n\t\t\t}\n\n\t\t\tduk__emit_a_b_c(comp_ctx,\n\t\t\t                DUK_OP_PUTPROP | DUK__EMIT_FLAG_A_IS_SOURCE | DUK__EMIT_FLAG_BC_REGCONST,\n\t\t\t                (duk_regconst_t) reg_obj,\n\t\t\t                rc_key,\n\t\t\t                rc_res);\n\n\t\t\tduk__ivalue_regconst(res, (duk_regconst_t) rc_res);\n\t\t} else {\n\t\t\t/* No support for lvalues returned from new or function call expressions.\n\t\t\t * However, these must NOT cause compile-time SyntaxErrors, but run-time\n\t\t\t * ReferenceErrors.  Both left and right sides of the assignment must be\n\t\t\t * evaluated before throwing a ReferenceError.  For instance:\n\t\t\t *\n\t\t\t *     f() = g();\n\t\t\t *\n\t\t\t * must result in f() being evaluated, then g() being evaluated, and\n\t\t\t * finally, a ReferenceError being thrown.  See E5 Section 11.13.1.\n\t\t\t */\n\n\t\t\tduk_regconst_t rc_res;\n\n\t\t\t/* First evaluate LHS fully to ensure all side effects are out. */\n\t\t\tduk__ivalue_toplain_ignore(comp_ctx, left);\n\n\t\t\t/* Then evaluate RHS fully (its value becomes the expression value too).\n\t\t\t * Technically we'd need the side effect safety check here too, but because\n\t\t\t * we always throw using INVLHS the result doesn't matter.\n\t\t\t */\n\t\t\trc_res = duk__expr_toregconst(comp_ctx, res, args_rbp /*rbp_flags*/);\n\n\t\t\tduk__emit_op_only(comp_ctx, DUK_OP_INVLHS);\n\n\t\t\tduk__ivalue_regconst(res, (duk_regconst_t) rc_res);\n\t\t}\n\n\t\treturn;\n\t}\n\n postincdec:\n\t{\n\t\t/*\n\t\t *  Post-increment/decrement will return the original value as its\n\t\t *  result value.  However, even that value will be coerced using\n\t\t *  ToNumber() which is quite awkward.  Specific bytecode opcodes\n\t\t *  are used to handle these semantics.\n\t\t *\n\t\t *  Note that post increment/decrement has a \"no LineTerminator here\"\n\t\t *  restriction.  This is handled by duk__expr_lbp(), which forcibly terminates\n\t\t *  the previous expression if a LineTerminator occurs before '++'/'--'.\n\t\t */\n\n\t\tduk_reg_t reg_res;\n\t\tduk_small_uint_t args_op1 = (args >> 8) & 0xff;  /* DUK_OP_POSTINCR/DUK_OP_POSTDECR */\n\t\tduk_small_uint_t args_op2 = args >> 16;          /* DUK_OP_POSTINCP_RR/DUK_OP_POSTDECP_RR */\n\n\t\t/* Specific assumptions for opcode numbering. */\n\t\tDUK_ASSERT(DUK_OP_POSTINCR + 4 == DUK_OP_POSTINCV);\n\t\tDUK_ASSERT(DUK_OP_POSTDECR + 4 == DUK_OP_POSTDECV);\n\n\t\treg_res = DUK__ALLOCTEMP(comp_ctx);\n\n\t\tif (left->t == DUK_IVAL_VAR) {\n\t\t\tduk_hstring *h_varname;\n\t\t\tduk_reg_t reg_varbind;\n\t\t\tduk_regconst_t rc_varname;\n\n\t\t\th_varname = duk_known_hstring(ctx, left->x1.valstack_idx);\n\n\t\t\tif (duk__hstring_is_eval_or_arguments_in_strict_mode(comp_ctx, h_varname)) {\n\t\t\t\tgoto syntax_error;\n\t\t\t}\n\n\t\t\tduk_dup(ctx, left->x1.valstack_idx);\n\t\t\tif (duk__lookup_lhs(comp_ctx, &reg_varbind, &rc_varname)) {\n\t\t\t\tduk__emit_a_bc(comp_ctx,\n\t\t\t\t               args_op1,  /* e.g. DUK_OP_POSTINCR */\n\t\t\t\t               (duk_regconst_t) reg_res,\n\t\t\t\t               (duk_regconst_t) reg_varbind);\n\t\t\t} else {\n\t\t\t\tduk__emit_a_bc(comp_ctx,\n\t\t\t\t               args_op1 + 4,  /* e.g. DUK_OP_POSTINCV */\n\t\t\t\t               (duk_regconst_t) reg_res,\n\t\t\t\t               rc_varname);\n\t\t\t}\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"postincdec to '%!O' -> reg_varbind=%ld, rc_varname=%ld\",\n\t\t\t                     (duk_heaphdr *) h_varname, (long) reg_varbind, (long) rc_varname));\n\t\t} else if (left->t == DUK_IVAL_PROP) {\n\t\t\tduk_reg_t reg_obj;  /* allocate to reg only (not const) */\n\t\t\tduk_regconst_t rc_key;\n\n\t\t\treg_obj = duk__ispec_toregconst_raw(comp_ctx, &left->x1, -1 /*forced_reg*/, 0 /*flags*/);  /* don't allow const */\n\t\t\trc_key = duk__ispec_toregconst_raw(comp_ctx, &left->x2, -1 /*forced_reg*/, DUK__IVAL_FLAG_ALLOW_CONST /*flags*/);\n\t\t\tduk__emit_a_b_c(comp_ctx,\n\t\t\t                args_op2 | DUK__EMIT_FLAG_BC_REGCONST,  /* e.g. DUK_OP_POSTINCP */\n\t\t\t                (duk_regconst_t) reg_res,\n\t\t\t                (duk_regconst_t) reg_obj,\n\t\t\t                rc_key);\n\t\t} else {\n\t\t\t/* Technically return value is not needed because INVLHS will\n\t\t\t * unconditially throw a ReferenceError.  Coercion is necessary\n\t\t\t * for proper semantics (consider ToNumber() called for an object).\n\t\t\t * Use DUK_OP_UNP with a dummy register to get ToNumber().\n\t\t\t */\n\t\t\tduk__ivalue_toforcedreg(comp_ctx, left, reg_res);\n\t\t\tduk__emit_bc(comp_ctx,\n\t\t\t             DUK_OP_UNP,\n\t\t\t             reg_res);  /* for side effects, result ignored */\n\t\t\tduk__emit_op_only(comp_ctx,\n\t\t\t                  DUK_OP_INVLHS);\n\t\t}\n\n\t\tDUK__SETTEMP(comp_ctx, reg_res + 1);\n\t\tduk__ivalue_regconst(res, (duk_regconst_t) reg_res);\n\t\treturn;\n\t}\n\n syntax_error:\n\tDUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_EXPRESSION);\n\treturn;\n\n syntax_error_lvalue:\n\tDUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_LVALUE);\n\treturn;\n}\n\nDUK_LOCAL duk_small_uint_t duk__expr_lbp(duk_compiler_ctx *comp_ctx) {\n\tduk_small_int_t tok = comp_ctx->curr_token.t;\n\n\tDUK_ASSERT(tok >= DUK_TOK_MINVAL && tok <= DUK_TOK_MAXVAL);\n\tDUK_ASSERT(sizeof(duk__token_lbp) == DUK_TOK_MAXVAL + 1);\n\n\t/* XXX: integrate support for this into led() instead?\n\t * Similar issue as post-increment/post-decrement.\n\t */\n\n\t/* prevent duk__expr_led() by using a binding power less than anything valid */\n\tif (tok == DUK_TOK_IN && !comp_ctx->curr_func.allow_in) {\n\t\treturn 0;\n\t}\n\n\tif ((tok == DUK_TOK_DECREMENT || tok == DUK_TOK_INCREMENT) &&\n\t    (comp_ctx->curr_token.lineterm)) {\n\t\t/* '++' or '--' in a post-increment/decrement position,\n\t\t * and a LineTerminator occurs between the operator and\n\t\t * the preceding expression.  Force the previous expr\n\t\t * to terminate, in effect treating e.g. \"a,b\\n++\" as\n\t\t * \"a,b;++\" (= SyntaxError).\n\t\t */\n\t\treturn 0;\n\t}\n\n\treturn DUK__TOKEN_LBP_GET_BP(duk__token_lbp[tok]);  /* format is bit packed */\n}\n\n/*\n *  Expression parsing.\n *\n *  Upon entry to 'expr' and its variants, 'curr_tok' is assumed to be the\n *  first token of the expression.  Upon exit, 'curr_tok' will be the first\n *  token not part of the expression (e.g. semicolon terminating an expression\n *  statement).\n */\n\n#define DUK__EXPR_RBP_MASK           0xff\n#define DUK__EXPR_FLAG_REJECT_IN     (1 << 8)   /* reject 'in' token (used for for-in) */\n#define DUK__EXPR_FLAG_ALLOW_EMPTY   (1 << 9)   /* allow empty expression */\n#define DUK__EXPR_FLAG_REQUIRE_INIT  (1 << 10)  /* require initializer for var/const */\n\n/* main expression parser function */\nDUK_LOCAL void duk__expr(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_ivalue tmp_alloc;   /* 'res' is used for \"left\", and 'tmp' for \"right\" */\n\tduk_ivalue *tmp = &tmp_alloc;\n\tduk_small_uint_t rbp;\n\n\tDUK__RECURSION_INCREASE(comp_ctx, thr);\n\n\tduk_require_stack(ctx, DUK__PARSE_EXPR_SLOTS);\n\n\t/* filter out flags from exprtop rbp_flags here to save space */\n\trbp = rbp_flags & DUK__EXPR_RBP_MASK;\n\n\tDUK_DDD(DUK_DDDPRINT(\"duk__expr(), rbp_flags=%ld, rbp=%ld, allow_in=%ld, paren_level=%ld\",\n\t                     (long) rbp_flags, (long) rbp, (long) comp_ctx->curr_func.allow_in,\n\t                     (long) comp_ctx->curr_func.paren_level));\n\n\tDUK_MEMZERO(&tmp_alloc, sizeof(tmp_alloc));\n\ttmp->x1.valstack_idx = duk_get_top(ctx);\n\ttmp->x2.valstack_idx = tmp->x1.valstack_idx + 1;\n\tduk_push_undefined(ctx);\n\tduk_push_undefined(ctx);\n\n\t/* XXX: where to release temp regs in intermediate expressions?\n\t * e.g. 1+2+3 -> don't inflate temp register count when parsing this.\n\t * that particular expression temp regs can be forced here.\n\t */\n\n\t/* XXX: increase ctx->expr_tokens here for every consumed token\n\t * (this would be a nice statistic)?\n\t */\n\n\tif (comp_ctx->curr_token.t == DUK_TOK_SEMICOLON || comp_ctx->curr_token.t == DUK_TOK_RPAREN) {\n\t\t/* XXX: possibly incorrect handling of empty expression */\n\t\tDUK_DDD(DUK_DDDPRINT(\"empty expression\"));\n\t\tif (!(rbp_flags & DUK__EXPR_FLAG_ALLOW_EMPTY)) {\n\t\t\tDUK_ERROR_SYNTAX(thr, DUK_STR_EMPTY_EXPR_NOT_ALLOWED);\n\t\t}\n\t\tduk_push_undefined(ctx);\n\t\tduk__ivalue_plain_fromstack(comp_ctx, res);\n\t\tgoto cleanup;\n\t}\n\n\tduk__advance(comp_ctx);\n\tduk__expr_nud(comp_ctx, res);  /* reuse 'res' as 'left' */\n\twhile (rbp < duk__expr_lbp(comp_ctx)) {\n\t\tduk__advance(comp_ctx);\n\t\tduk__expr_led(comp_ctx, res, tmp);\n\t\tduk__copy_ivalue(comp_ctx, tmp, res);  /* tmp -> res */\n\t}\n\n cleanup:\n\t/* final result is already in 'res' */\n\n\tduk_pop_2(ctx);\n\n\tDUK__RECURSION_DECREASE(comp_ctx, thr);\n}\n\nDUK_LOCAL void duk__exprtop(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags) {\n\tduk_hthread *thr = comp_ctx->thr;\n\n\t/* Note: these variables must reside in 'curr_func' instead of the global\n\t * context: when parsing function expressions, expression parsing is nested.\n\t */\n\tcomp_ctx->curr_func.nud_count = 0;\n\tcomp_ctx->curr_func.led_count = 0;\n\tcomp_ctx->curr_func.paren_level = 0;\n\tcomp_ctx->curr_func.expr_lhs = 1;\n\tcomp_ctx->curr_func.allow_in = (rbp_flags & DUK__EXPR_FLAG_REJECT_IN ? 0 : 1);\n\n\tduk__expr(comp_ctx, res, rbp_flags);\n\n\tif (!(rbp_flags & DUK__EXPR_FLAG_ALLOW_EMPTY) && duk__expr_is_empty(comp_ctx)) {\n\t\tDUK_ERROR_SYNTAX(thr, DUK_STR_EMPTY_EXPR_NOT_ALLOWED);\n\t}\n}\n\n/* A bunch of helpers (for size optimization) that combine duk__expr()/duk__exprtop()\n * and result conversions.\n *\n * Each helper needs at least 2-3 calls to make it worth while to wrap.\n */\n\n#if 0  /* unused */\nDUK_LOCAL duk_reg_t duk__expr_toreg(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags) {\n\tduk__expr(comp_ctx, res, rbp_flags);\n\treturn duk__ivalue_toreg(comp_ctx, res);\n}\n#endif\n\n#if 0  /* unused */\nDUK_LOCAL duk_reg_t duk__expr_totemp(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags) {\n\tduk__expr(comp_ctx, res, rbp_flags);\n\treturn duk__ivalue_totemp(comp_ctx, res);\n}\n#endif\n\nDUK_LOCAL void duk__expr_toforcedreg(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags, duk_reg_t forced_reg) {\n\tDUK_ASSERT(forced_reg >= 0);\n\tduk__expr(comp_ctx, res, rbp_flags);\n\tduk__ivalue_toforcedreg(comp_ctx, res, forced_reg);\n}\n\nDUK_LOCAL duk_regconst_t duk__expr_toregconst(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags) {\n\tduk__expr(comp_ctx, res, rbp_flags);\n\treturn duk__ivalue_toregconst(comp_ctx, res);\n}\n\n#if 0  /* unused */\nDUK_LOCAL duk_regconst_t duk__expr_totempconst(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags) {\n\tduk__expr(comp_ctx, res, rbp_flags);\n\treturn duk__ivalue_totempconst(comp_ctx, res);\n}\n#endif\n\nDUK_LOCAL void duk__expr_toplain(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags) {\n\tduk__expr(comp_ctx, res, rbp_flags);\n\tduk__ivalue_toplain(comp_ctx, res);\n}\n\nDUK_LOCAL void duk__expr_toplain_ignore(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags) {\n\tduk__expr(comp_ctx, res, rbp_flags);\n\tduk__ivalue_toplain_ignore(comp_ctx, res);\n}\n\nDUK_LOCAL duk_reg_t duk__exprtop_toreg(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags) {\n\tduk__exprtop(comp_ctx, res, rbp_flags);\n\treturn duk__ivalue_toreg(comp_ctx, res);\n}\n\n#if 0  /* unused */\nDUK_LOCAL duk_reg_t duk__exprtop_totemp(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags) {\n\tduk__exprtop(comp_ctx, res, rbp_flags);\n\treturn duk__ivalue_totemp(comp_ctx, res);\n}\n#endif\n\nDUK_LOCAL void duk__exprtop_toforcedreg(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags, duk_reg_t forced_reg) {\n\tDUK_ASSERT(forced_reg >= 0);\n\tduk__exprtop(comp_ctx, res, rbp_flags);\n\tduk__ivalue_toforcedreg(comp_ctx, res, forced_reg);\n}\n\nDUK_LOCAL duk_regconst_t duk__exprtop_toregconst(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t rbp_flags) {\n\tduk__exprtop(comp_ctx, res, rbp_flags);\n\treturn duk__ivalue_toregconst(comp_ctx, res);\n}\n\n#if 0  /* unused */\nDUK_LOCAL void duk__exprtop_toplain_ignore(duk_compiler_ctx *comp_ctx, duk_ivalue *res, int rbp_flags) {\n\tduk__exprtop(comp_ctx, res, rbp_flags);\n\tduk__ivalue_toplain_ignore(comp_ctx, res);\n}\n#endif\n\n/*\n *  Parse an individual source element (top level statement) or a statement.\n *\n *  Handles labeled statements automatically (peeling away labels before\n *  parsing an expression that follows the label(s)).\n *\n *  Upon entry, 'curr_tok' contains the first token of the statement (parsed\n *  in \"allow regexp literal\" mode).  Upon exit, 'curr_tok' contains the first\n *  token following the statement (if the statement has a terminator, this is\n *  the token after the terminator).\n */\n\n#define DUK__HAS_VAL                  (1 << 0)  /* stmt has non-empty value */\n#define DUK__HAS_TERM                 (1 << 1)  /* stmt has explicit/implicit semicolon terminator */\n#define DUK__ALLOW_AUTO_SEMI_ALWAYS   (1 << 2)  /* allow automatic semicolon even without lineterm (compatibility) */\n#define DUK__STILL_PROLOGUE           (1 << 3)  /* statement does not terminate directive prologue */\n#define DUK__IS_TERMINAL              (1 << 4)  /* statement is guaranteed to be terminal (control doesn't flow to next statement) */\n\n/* Parse a single variable declaration (e.g. \"i\" or \"i=10\").  A leading 'var'\n * has already been eaten.  These is no return value in 'res', it is used only\n * as a temporary.\n *\n * When called from 'for-in' statement parser, the initializer expression must\n * not allow the 'in' token.  The caller supply additional expression parsing\n * flags (like DUK__EXPR_FLAG_REJECT_IN) in 'expr_flags'.\n *\n * Finally, out_rc_varname and out_reg_varbind are updated to reflect where\n * the identifier is bound:\n *\n *    If register bound:      out_reg_varbind >= 0, out_rc_varname == 0 (ignore)\n *    If not register bound:  out_reg_varbind < 0, out_rc_varname >= 0\n *\n * These allow the caller to use the variable for further assignment, e.g.\n * as is done in 'for-in' parsing.\n */\n\nDUK_LOCAL void duk__parse_var_decl(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t expr_flags, duk_reg_t *out_reg_varbind, duk_regconst_t *out_rc_varname) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hstring *h_varname;\n\tduk_reg_t reg_varbind;\n\tduk_regconst_t rc_varname;\n\n\t/* assume 'var' has been eaten */\n\n\t/* Note: Identifier rejects reserved words */\n\tif (comp_ctx->curr_token.t != DUK_TOK_IDENTIFIER) {\n\t\tgoto syntax_error;\n\t}\n\th_varname = comp_ctx->curr_token.str1;\n\n\tDUK_ASSERT(h_varname != NULL);\n\n\t/* strict mode restrictions (E5 Section 12.2.1) */\n\tif (duk__hstring_is_eval_or_arguments_in_strict_mode(comp_ctx, h_varname)) {\n\t\tgoto syntax_error;\n\t}\n\n\t/* register declarations in first pass */\n\tif (comp_ctx->curr_func.in_scanning) {\n\t\tduk_uarridx_t n;\n\t\tDUK_DDD(DUK_DDDPRINT(\"register variable declaration %!O in pass 1\",\n\t\t                     (duk_heaphdr *) h_varname));\n\t\tn = (duk_uarridx_t) duk_get_length(ctx, comp_ctx->curr_func.decls_idx);\n\t\tduk_push_hstring(ctx, h_varname);\n\t\tduk_put_prop_index(ctx, comp_ctx->curr_func.decls_idx, n);\n\t\tduk_push_int(ctx, DUK_DECL_TYPE_VAR + (0 << 8));\n\t\tduk_put_prop_index(ctx, comp_ctx->curr_func.decls_idx, n + 1);\n\t}\n\n\tduk_push_hstring(ctx, h_varname);  /* push before advancing to keep reachable */\n\n\t/* register binding lookup is based on varmap (even in first pass) */\n\tduk_dup_top(ctx);\n\t(void) duk__lookup_lhs(comp_ctx, &reg_varbind, &rc_varname);\n\n\tduk__advance(comp_ctx);  /* eat identifier */\n\n\tif (comp_ctx->curr_token.t == DUK_TOK_EQUALSIGN) {\n\t\tduk__advance(comp_ctx);\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"vardecl, assign to '%!O' -> reg_varbind=%ld, rc_varname=%ld\",\n\t\t                     (duk_heaphdr *) h_varname, (long) reg_varbind, (long) rc_varname));\n\n\t\tduk__exprtop(comp_ctx, res, DUK__BP_COMMA | expr_flags /*rbp_flags*/);  /* AssignmentExpression */\n\n\t\tif (reg_varbind >= 0) {\n\t\t\tduk__ivalue_toforcedreg(comp_ctx, res, reg_varbind);\n\t\t} else {\n\t\t\tduk_reg_t reg_val;\n\t\t\treg_val = duk__ivalue_toreg(comp_ctx, res);\n\t\t\tduk__emit_a_bc(comp_ctx,\n\t\t\t               DUK_OP_PUTVAR | DUK__EMIT_FLAG_A_IS_SOURCE,\n\t\t\t               (duk_regconst_t) reg_val,\n\t\t\t               rc_varname);\n\t\t}\n\t} else {\n\t\tif (expr_flags & DUK__EXPR_FLAG_REQUIRE_INIT) {\n\t\t\t/* Used for minimal 'const': initializer required. */\n\t\t\tgoto syntax_error;\n\t\t}\n\t}\n\n\tduk_pop(ctx);  /* pop varname */\n\n\t*out_rc_varname = rc_varname;\n\t*out_reg_varbind = reg_varbind;\n\n\treturn;\n\n syntax_error:\n\tDUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_VAR_DECLARATION);\n}\n\nDUK_LOCAL void duk__parse_var_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_small_uint_t expr_flags) {\n\tduk_reg_t reg_varbind;\n\tduk_regconst_t rc_varname;\n\n\tduk__advance(comp_ctx);  /* eat 'var' */\n\n\tfor (;;) {\n\t\t/* rc_varname and reg_varbind are ignored here */\n\t\tduk__parse_var_decl(comp_ctx, res, 0 | expr_flags, &reg_varbind, &rc_varname);\n\n\t\tif (comp_ctx->curr_token.t != DUK_TOK_COMMA) {\n\t\t\tbreak;\n\t\t}\n\t\tduk__advance(comp_ctx);\n\t}\n}\n\nDUK_LOCAL void duk__parse_for_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_int_t pc_label_site) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_int_t pc_v34_lhs;    /* start variant 3/4 left-hand-side code (L1 in doc/compiler.rst example) */\n\tduk_reg_t temp_reset;    /* knock back \"next temp\" to this whenever possible */\n\tduk_reg_t reg_temps;     /* preallocated temporaries (2) for variants 3 and 4 */\n\n\tDUK_DDD(DUK_DDDPRINT(\"start parsing a for/for-in statement\"));\n\n\t/* Two temporaries are preallocated here for variants 3 and 4 which need\n\t * registers which are never clobbered by expressions in the loop\n\t * (concretely: for the enumerator object and the next enumerated value).\n\t * Variants 1 and 2 \"release\" these temps.\n\t */\n\n\treg_temps = DUK__ALLOCTEMPS(comp_ctx, 2);\n\n\ttemp_reset = DUK__GETTEMP(comp_ctx);\n\n\t/*\n\t *  For/for-in main variants are:\n\t *\n\t *    1. for (ExpressionNoIn_opt; Expression_opt; Expression_opt) Statement\n\t *    2. for (var VariableDeclarationNoIn; Expression_opt; Expression_opt) Statement\n\t *    3. for (LeftHandSideExpression in Expression) Statement\n\t *    4. for (var VariableDeclarationNoIn in Expression) Statement\n\t *\n\t *  Parsing these without arbitrary lookahead or backtracking is relatively\n\t *  tricky but we manage to do so for now.\n\t *\n\t *  See doc/compiler.rst for a detailed discussion of control flow\n\t *  issues, evaluation order issues, etc.\n\t */\n\n\tduk__advance(comp_ctx);  /* eat 'for' */\n\tduk__advance_expect(comp_ctx, DUK_TOK_LPAREN);\n\n\tDUK_DDD(DUK_DDDPRINT(\"detecting for/for-in loop variant, pc=%ld\", (long) duk__get_current_pc(comp_ctx)));\n\n\t/* a label site has been emitted by duk__parse_stmt() automatically\n\t * (it will also emit the ENDLABEL).\n\t */\n\n\tif (comp_ctx->curr_token.t == DUK_TOK_VAR) {\n\t\t/*\n\t\t *  Variant 2 or 4\n\t\t */\n\n\t\tduk_reg_t reg_varbind;       /* variable binding register if register-bound (otherwise < 0) */\n\t\tduk_regconst_t rc_varname;   /* variable name reg/const, if variable not register-bound */\n\n\t\tduk__advance(comp_ctx);  /* eat 'var' */\n\t\tduk__parse_var_decl(comp_ctx, res, DUK__EXPR_FLAG_REJECT_IN, &reg_varbind, &rc_varname);\n\t\tDUK__SETTEMP(comp_ctx, temp_reset);\n\n\t\tif (comp_ctx->curr_token.t == DUK_TOK_IN) {\n\t\t\t/*\n\t\t\t *  Variant 4\n\t\t\t */\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"detected for variant 4: for (var VariableDeclarationNoIn in Expression) Statement\"));\n\t\t\tpc_v34_lhs = duk__get_current_pc(comp_ctx);  /* jump is inserted here */\n\t\t\tif (reg_varbind >= 0) {\n\t\t\t\tduk__emit_a_bc(comp_ctx,\n\t\t\t\t               DUK_OP_LDREG,\n\t\t\t\t               (duk_regconst_t) reg_varbind,\n\t\t\t\t               (duk_regconst_t) (reg_temps + 0));\n\t\t\t} else {\n\t\t\t\tduk__emit_a_bc(comp_ctx,\n\t\t\t\t               DUK_OP_PUTVAR | DUK__EMIT_FLAG_A_IS_SOURCE,\n\t\t\t\t               (duk_regconst_t) (reg_temps + 0),\n\t\t\t\t               rc_varname);\n\t\t\t}\n\t\t\tgoto parse_3_or_4;\n\t\t} else {\n\t\t\t/*\n\t\t\t *  Variant 2\n\t\t\t */\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"detected for variant 2: for (var VariableDeclarationNoIn; Expression_opt; Expression_opt) Statement\"));\n\t\t\tfor (;;) {\n\t\t\t\t/* more initializers */\n\t\t\t\tif (comp_ctx->curr_token.t != DUK_TOK_COMMA) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"variant 2 has another variable initializer\"));\n\n\t\t\t\tduk__advance(comp_ctx);  /* eat comma */\n\t\t\t\tduk__parse_var_decl(comp_ctx, res, DUK__EXPR_FLAG_REJECT_IN, &reg_varbind, &rc_varname);\n\t\t\t}\n\t\t\tgoto parse_1_or_2;\n\t\t}\n\t} else {\n\t\t/*\n\t\t *  Variant 1 or 3\n\t\t */\n\n\t\tpc_v34_lhs = duk__get_current_pc(comp_ctx);  /* jump is inserted here (variant 3) */\n\n\t\t/* Note that duk__exprtop() here can clobber any reg above current temp_next,\n\t\t * so any loop variables (e.g. enumerator) must be \"preallocated\".\n\t\t */\n\n\t\t/* don't coerce yet to a plain value (variant 3 needs special handling) */\n\t\tduk__exprtop(comp_ctx, res, DUK__BP_FOR_EXPR | DUK__EXPR_FLAG_REJECT_IN | DUK__EXPR_FLAG_ALLOW_EMPTY /*rbp_flags*/);  /* Expression */\n\t\tif (comp_ctx->curr_token.t == DUK_TOK_IN) {\n\t\t\t/*\n\t\t\t *  Variant 3\n\t\t\t */\n\n\t\t\t/* XXX: need to determine LHS type, and check that it is LHS compatible */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"detected for variant 3: for (LeftHandSideExpression in Expression) Statement\"));\n\t\t\tif (duk__expr_is_empty(comp_ctx)) {\n\t\t\t\tgoto syntax_error;  /* LeftHandSideExpression does not allow empty expression */\n\t\t\t}\n\n\t\t\tif (res->t == DUK_IVAL_VAR) {\n\t\t\t\tduk_reg_t reg_varbind;\n\t\t\t\tduk_regconst_t rc_varname;\n\n\t\t\t\tduk_dup(ctx, res->x1.valstack_idx);\n\t\t\t\tif (duk__lookup_lhs(comp_ctx, &reg_varbind, &rc_varname)) {\n\t\t\t\t\tduk__emit_a_bc(comp_ctx,\n\t\t\t\t\t               DUK_OP_LDREG,\n\t\t\t\t\t               (duk_regconst_t) reg_varbind,\n\t\t\t\t\t               (duk_regconst_t) (reg_temps + 0));\n\t\t\t\t} else {\n\t\t\t\t\tduk__emit_a_bc(comp_ctx,\n\t\t\t\t\t               DUK_OP_PUTVAR | DUK__EMIT_FLAG_A_IS_SOURCE,\n\t\t\t\t\t               (duk_regconst_t) (reg_temps + 0),\n\t\t\t\t\t               rc_varname);\n\t\t\t\t}\n\t\t\t} else if (res->t == DUK_IVAL_PROP) {\n\t\t\t\t/* Don't allow a constant for the object (even for a number etc), as\n\t\t\t\t * it goes into the 'A' field of the opcode.\n\t\t\t\t */\n\t\t\t\tduk_reg_t reg_obj;\n\t\t\t\tduk_regconst_t rc_key;\n\t\t\t\treg_obj = duk__ispec_toregconst_raw(comp_ctx, &res->x1, -1 /*forced_reg*/, 0 /*flags*/);  /* don't allow const */\n\t\t\t\trc_key = duk__ispec_toregconst_raw(comp_ctx, &res->x2, -1 /*forced_reg*/, DUK__IVAL_FLAG_ALLOW_CONST /*flags*/);\n\t\t\t\tduk__emit_a_b_c(comp_ctx,\n\t\t\t\t                DUK_OP_PUTPROP | DUK__EMIT_FLAG_A_IS_SOURCE | DUK__EMIT_FLAG_BC_REGCONST,\n\t\t\t\t                (duk_regconst_t) reg_obj,\n\t\t\t\t                rc_key,\n\t\t\t\t                (duk_regconst_t) (reg_temps + 0));\n\t\t\t} else {\n\t\t\t\tduk__ivalue_toplain_ignore(comp_ctx, res);  /* just in case */\n\t\t\t\tduk__emit_op_only(comp_ctx,\n\t\t\t\t                  DUK_OP_INVLHS);\n\t\t\t}\n\t\t\tgoto parse_3_or_4;\n\t\t} else {\n\t\t\t/*\n\t\t\t *  Variant 1\n\t\t\t */\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"detected for variant 1: for (ExpressionNoIn_opt; Expression_opt; Expression_opt) Statement\"));\n\t\t\tduk__ivalue_toplain_ignore(comp_ctx, res);\n\t\t\tgoto parse_1_or_2;\n\t\t}\n\t}\n\n parse_1_or_2:\n\t/*\n\t *  Parse variant 1 or 2.  The first part expression (which differs\n\t *  in the variants) has already been parsed and its code emitted.\n\t *\n\t *  reg_temps + 0: unused\n\t *  reg_temps + 1: unused\n\t */\n\t{\n\t\tduk_regconst_t rc_cond;\n\t\tduk_int_t pc_l1, pc_l2, pc_l3, pc_l4;\n\t\tduk_int_t pc_jumpto_l3, pc_jumpto_l4;\n\t\tduk_bool_t expr_c_empty;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"shared code for parsing variants 1 and 2\"));\n\n\t\t/* \"release\" preallocated temps since we won't need them */\n\t\ttemp_reset = reg_temps + 0;\n\t\tDUK__SETTEMP(comp_ctx, temp_reset);\n\n\t\tduk__advance_expect(comp_ctx, DUK_TOK_SEMICOLON);\n\n\t\tpc_l1 = duk__get_current_pc(comp_ctx);\n\t\tduk__exprtop(comp_ctx, res, DUK__BP_FOR_EXPR | DUK__EXPR_FLAG_ALLOW_EMPTY /*rbp_flags*/);  /* Expression_opt */\n\t\tif (duk__expr_is_empty(comp_ctx)) {\n\t\t\t/* no need to coerce */\n\t\t\tpc_jumpto_l3 = duk__emit_jump_empty(comp_ctx);  /* to body */\n\t\t\tpc_jumpto_l4 = -1;  /* omitted */\n\t\t} else {\n\t\t\trc_cond = duk__ivalue_toregconst(comp_ctx, res);\n\t\t\tduk__emit_if_false_skip(comp_ctx, rc_cond);\n\t\t\tpc_jumpto_l3 = duk__emit_jump_empty(comp_ctx);  /* to body */\n\t\t\tpc_jumpto_l4 = duk__emit_jump_empty(comp_ctx);  /* to exit */\n\t\t}\n\t\tDUK__SETTEMP(comp_ctx, temp_reset);\n\n\t\tduk__advance_expect(comp_ctx, DUK_TOK_SEMICOLON);\n\n\t\tpc_l2 = duk__get_current_pc(comp_ctx);\n\t\tduk__exprtop(comp_ctx, res, DUK__BP_FOR_EXPR | DUK__EXPR_FLAG_ALLOW_EMPTY /*rbp_flags*/);  /* Expression_opt */\n\t\tif (duk__expr_is_empty(comp_ctx)) {\n\t\t\t/* no need to coerce */\n\t\t\texpr_c_empty = 1;\n\t\t\t/* JUMP L1 omitted */\n\t\t} else {\n\t\t\tduk__ivalue_toplain_ignore(comp_ctx, res);\n\t\t\texpr_c_empty = 0;\n\t\t\tduk__emit_jump(comp_ctx, pc_l1);\n\t\t}\n\t\tDUK__SETTEMP(comp_ctx, temp_reset);\n\n\t\tduk__advance_expect(comp_ctx, DUK_TOK_RPAREN);\n\n\t\tpc_l3 = duk__get_current_pc(comp_ctx);\n\t\tduk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/);\n\t\tif (expr_c_empty) {\n\t\t\tduk__emit_jump(comp_ctx, pc_l1);\n\t\t} else {\n\t\t\tduk__emit_jump(comp_ctx, pc_l2);\n\t\t}\n\t\t/* temp reset is not necessary after duk__parse_stmt(), which already does it */\n\n\t\tpc_l4 = duk__get_current_pc(comp_ctx);\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"patching jumps: jumpto_l3: %ld->%ld, jumpto_l4: %ld->%ld, \"\n\t\t                     \"break: %ld->%ld, continue: %ld->%ld\",\n\t\t\t             (long) pc_jumpto_l3, (long) pc_l3, (long) pc_jumpto_l4, (long) pc_l4,\n\t\t                     (long) (pc_label_site + 1), (long) pc_l4, (long) (pc_label_site + 2), (long) pc_l2));\n\n\t\tduk__patch_jump(comp_ctx, pc_jumpto_l3, pc_l3);\n\t\tduk__patch_jump(comp_ctx, pc_jumpto_l4, pc_l4);\n\t\tduk__patch_jump(comp_ctx,\n\t\t                pc_label_site + 1,\n\t\t                pc_l4);                         /* break jump */\n\t\tduk__patch_jump(comp_ctx,\n\t\t                pc_label_site + 2,\n\t\t                expr_c_empty ? pc_l1 : pc_l2);  /* continue jump */\n\t}\n\tgoto finished;\n\n parse_3_or_4:\n\t/*\n\t *  Parse variant 3 or 4.\n\t *\n\t *  For variant 3 (e.g. \"for (A in C) D;\") the code for A (except the\n\t *  final property/variable write) has already been emitted.  The first\n\t *  instruction of that code is at pc_v34_lhs; a JUMP needs to be inserted\n\t *  there to satisfy control flow needs.\n\t *\n\t *  For variant 4, if the variable declaration had an initializer\n\t *  (e.g. \"for (var A = B in C) D;\") the code for the assignment\n\t *  (B) has already been emitted.\n\t *\n\t *  Variables set before entering here:\n\t *\n\t *    pc_v34_lhs:    insert a \"JUMP L2\" here (see doc/compiler.rst example).\n\t *    reg_temps + 0: iteration target value (written to LHS)\n\t *    reg_temps + 1: enumerator object\n\t */\n\t{\n\t\tduk_int_t pc_l1, pc_l2, pc_l3, pc_l4, pc_l5;\n\t\tduk_int_t pc_jumpto_l2, pc_jumpto_l3, pc_jumpto_l4, pc_jumpto_l5;\n\t\tduk_reg_t reg_target;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"shared code for parsing variants 3 and 4, pc_v34_lhs=%ld\", (long) pc_v34_lhs));\n\n\t\tDUK__SETTEMP(comp_ctx, temp_reset);\n\n\t\t/* First we need to insert a jump in the middle of previously\n\t\t * emitted code to get the control flow right.  No jumps can\n\t\t * cross the position where the jump is inserted.  See doc/compiler.rst\n\t\t * for discussion on the intricacies of control flow and side effects\n\t\t * for variants 3 and 4.\n\t\t */\n\n\t\tduk__insert_jump_entry(comp_ctx, pc_v34_lhs);\n\t\tpc_jumpto_l2 = pc_v34_lhs;  /* inserted jump */\n\t\tpc_l1 = pc_v34_lhs + 1;     /* +1, right after inserted jump */\n\n\t\t/* The code for writing reg_temps + 0 to the left hand side has already\n\t\t * been emitted.\n\t\t */\n\n\t\tpc_jumpto_l3 = duk__emit_jump_empty(comp_ctx);  /* -> loop body */\n\n\t\tduk__advance(comp_ctx);  /* eat 'in' */\n\n\t\t/* Parse enumeration target and initialize enumerator.  For 'null' and 'undefined',\n\t\t * INITENUM will creates a 'null' enumerator which works like an empty enumerator\n\t\t * (E5 Section 12.6.4, step 3).  Note that INITENUM requires the value to be in a\n\t\t * register (constant not allowed).\n\t\t */\n\n\t\tpc_l2 = duk__get_current_pc(comp_ctx);\n\t\treg_target = duk__exprtop_toreg(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/);  /* Expression */\n\t\tduk__emit_b_c(comp_ctx,\n\t\t              DUK_OP_INITENUM | DUK__EMIT_FLAG_B_IS_TARGET,\n\t\t              (duk_regconst_t) (reg_temps + 1),\n\t\t              (duk_regconst_t) reg_target);\n\t\tpc_jumpto_l4 = duk__emit_jump_empty(comp_ctx);\n\t\tDUK__SETTEMP(comp_ctx, temp_reset);\n\n\t\tduk__advance_expect(comp_ctx, DUK_TOK_RPAREN);\n\n\t\tpc_l3 = duk__get_current_pc(comp_ctx);\n\t\tduk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/);\n\t\t/* temp reset is not necessary after duk__parse_stmt(), which already does it */\n\n\t\t/* NEXTENUM needs a jump slot right after the main opcode.\n\t\t * We need the code emitter to reserve the slot: if there's\n\t\t * target shuffling, the target shuffle opcodes must happen\n\t\t * after the jump slot (for NEXTENUM the shuffle opcodes are\n\t\t * not needed if the enum is finished).\n\t\t */\n\t\tpc_l4 = duk__get_current_pc(comp_ctx);\n\t\tduk__emit_b_c(comp_ctx,\n\t\t              DUK_OP_NEXTENUM | DUK__EMIT_FLAG_B_IS_TARGET | DUK__EMIT_FLAG_RESERVE_JUMPSLOT,\n\t\t              (duk_regconst_t) (reg_temps + 0),\n\t\t              (duk_regconst_t) (reg_temps + 1));\n\t\tpc_jumpto_l5 = comp_ctx->emit_jumpslot_pc;  /* NEXTENUM jump slot: executed when enum finished */\n\t\tduk__emit_jump(comp_ctx, pc_l1);  /* jump to next loop, using reg_v34_iter as iterated value */\n\n\t\tpc_l5 = duk__get_current_pc(comp_ctx);\n\n\t\t/* XXX: since the enumerator may be a memory expensive object,\n\t\t * perhaps clear it explicitly here?  If so, break jump must\n\t\t * go through this clearing operation.\n\t\t */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"patching jumps: jumpto_l2: %ld->%ld, jumpto_l3: %ld->%ld, \"\n\t\t                     \"jumpto_l4: %ld->%ld, jumpto_l5: %ld->%ld, \"\n\t\t                     \"break: %ld->%ld, continue: %ld->%ld\",\n\t\t\t             (long) pc_jumpto_l2, (long) pc_l2, (long) pc_jumpto_l3, (long) pc_l3,\n\t\t\t             (long) pc_jumpto_l4, (long) pc_l4, (long) pc_jumpto_l5, (long) pc_l5,\n\t\t                     (long) (pc_label_site + 1), (long) pc_l5, (long) (pc_label_site + 2), (long) pc_l4));\n\n\t\tduk__patch_jump(comp_ctx, pc_jumpto_l2, pc_l2);\n\t\tduk__patch_jump(comp_ctx, pc_jumpto_l3, pc_l3);\n\t\tduk__patch_jump(comp_ctx, pc_jumpto_l4, pc_l4);\n\t\tduk__patch_jump(comp_ctx, pc_jumpto_l5, pc_l5);\n\t\tduk__patch_jump(comp_ctx, pc_label_site + 1, pc_l5);  /* break jump */\n\t\tduk__patch_jump(comp_ctx, pc_label_site + 2, pc_l4);  /* continue jump */\n\t}\n\tgoto finished;\n\n finished:\n\tDUK_DDD(DUK_DDDPRINT(\"end parsing a for/for-in statement\"));\n\treturn;\n\n syntax_error:\n\tDUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_FOR);\n}\n\nDUK_LOCAL void duk__parse_switch_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_int_t pc_label_site) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_reg_t temp_at_loop;\n\tduk_regconst_t rc_switch;    /* reg/const for switch value */\n\tduk_regconst_t rc_case;      /* reg/const for case value */\n\tduk_reg_t reg_temp;          /* general temp register */\n\tduk_int_t pc_prevcase = -1;\n\tduk_int_t pc_prevstmt = -1;\n\tduk_int_t pc_default = -1;   /* -1 == not set, -2 == pending (next statement list) */\n\n\t/* Note: negative pc values are ignored when patching jumps, so no explicit checks needed */\n\n\t/*\n\t *  Switch is pretty complicated because of several conflicting concerns:\n\t *\n\t *    - Want to generate code without an intermediate representation,\n\t *      i.e., in one go\n\t *\n\t *    - Case selectors are expressions, not values, and may thus e.g. throw\n\t *      exceptions (which causes evaluation order concerns)\n\t *\n\t *    - Evaluation semantics of case selectors and default clause need to be\n\t *      carefully implemented to provide correct behavior even with case value\n\t *      side effects\n\t *\n\t *    - Fall through case and default clauses; avoiding dead JUMPs if case\n\t *      ends with an unconditional jump (a break or a continue)\n\t *\n\t *    - The same case value may occur multiple times, but evaluation rules\n\t *      only process the first match before switching to a \"propagation\" mode\n\t *      where case values are no longer evaluated\n\t *\n\t *  See E5 Section 12.11.  Also see doc/compiler.rst for compilation\n\t *  discussion.\n\t */\n\n\tduk__advance(comp_ctx);\n\tduk__advance_expect(comp_ctx, DUK_TOK_LPAREN);\n\trc_switch = duk__exprtop_toregconst(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/);\n\tduk__advance_expect(comp_ctx, DUK_TOK_RPAREN);\n\tduk__advance_expect(comp_ctx, DUK_TOK_LCURLY);\n\n\tDUK_DDD(DUK_DDDPRINT(\"switch value in register %ld\", (long) rc_switch));\n\n\ttemp_at_loop = DUK__GETTEMP(comp_ctx);\n\n\tfor (;;) {\n\t\tduk_int_t num_stmts;\n\t\tduk_small_int_t tok;\n\n\t\t/* sufficient for keeping temp reg numbers in check */\n\t\tDUK__SETTEMP(comp_ctx, temp_at_loop);\n\n\t\tif (comp_ctx->curr_token.t == DUK_TOK_RCURLY) {\n\t\t\tbreak;\n\t\t}\n\n\t\t/*\n\t\t *  Parse a case or default clause.\n\t\t */\n\n\t\tif (comp_ctx->curr_token.t == DUK_TOK_CASE) {\n\t\t\t/*\n\t\t\t *  Case clause.\n\t\t\t *\n\t\t\t *  Note: cannot use reg_case as a temp register (for SEQ target)\n\t\t\t *  because it may be a constant.\n\t\t\t */\n\n\t\t\tduk__patch_jump_here(comp_ctx, pc_prevcase);  /* chain jumps for case\n\t\t\t                                               * evaluation and checking\n\t\t\t                                               */\n\n\t\t\tduk__advance(comp_ctx);\n\t\t\trc_case = duk__exprtop_toregconst(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/);\n\t\t\tduk__advance_expect(comp_ctx, DUK_TOK_COLON);\n\n\t\t\treg_temp = DUK__ALLOCTEMP(comp_ctx);\n\t\t\tduk__emit_a_b_c(comp_ctx,\n\t\t\t                DUK_OP_SEQ | DUK__EMIT_FLAG_BC_REGCONST,\n\t\t\t                (duk_regconst_t) reg_temp,\n\t\t\t                rc_switch,\n\t\t\t                rc_case);\n\t\t\tduk__emit_if_true_skip(comp_ctx, (duk_regconst_t) reg_temp);\n\n\t\t\t/* jump to next case clause */\n\t\t\tpc_prevcase = duk__emit_jump_empty(comp_ctx);  /* no match, next case */\n\n\t\t\t/* statements go here (if any) on next loop */\n\t\t} else if (comp_ctx->curr_token.t == DUK_TOK_DEFAULT) {\n\t\t\t/*\n\t\t\t *  Default clause.\n\t\t\t */\n\n\t\t\tif (pc_default >= 0) {\n\t\t\t\tgoto syntax_error;\n\t\t\t}\n\t\t\tduk__advance(comp_ctx);\n\t\t\tduk__advance_expect(comp_ctx, DUK_TOK_COLON);\n\n\t\t\t/* Fix for https://github.com/svaarala/duktape/issues/155:\n\t\t\t * If 'default' is first clause (detected by pc_prevcase < 0)\n\t\t\t * we need to ensure we stay in the matching chain.\n\t\t\t */\n\t\t\tif (pc_prevcase < 0) {\n\t\t\t\tDUK_DD(DUK_DDPRINT(\"default clause is first, emit prevcase jump\"));\n\t\t\t\tpc_prevcase = duk__emit_jump_empty(comp_ctx);\n\t\t\t}\n\n\t\t\t/* default clause matches next statement list (if any) */\n\t\t\tpc_default = -2;\n\t\t} else {\n\t\t\t/* Code is not accepted before the first case/default clause */\n\t\t\tgoto syntax_error;\n\t\t}\n\n\t\t/*\n\t\t *  Parse code after the clause.  Possible terminators are\n\t\t *  'case', 'default', and '}'.\n\t\t *\n\t\t *  Note that there may be no code at all, not even an empty statement,\n\t\t *  between case clauses.  This must be handled just like an empty statement\n\t\t *  (omitting seemingly pointless JUMPs), to avoid situations like\n\t\t *  test-bug-case-fallthrough.js.\n\t\t */\n\n\t\tnum_stmts = 0;\n\t\tif (pc_default == -2) {\n\t\t\tpc_default = duk__get_current_pc(comp_ctx);\n\t\t}\n\n\t\t/* Note: this is correct even for default clause statements:\n\t\t * they participate in 'fall-through' behavior even if the\n\t\t * default clause is in the middle.\n\t\t */\n\t\tduk__patch_jump_here(comp_ctx, pc_prevstmt);  /* chain jumps for 'fall-through'\n\t\t                                               * after a case matches.\n\t\t                                               */\n\n\t\tfor (;;) {\n\t\t\ttok = comp_ctx->curr_token.t;\n\t\t\tif (tok == DUK_TOK_CASE || tok == DUK_TOK_DEFAULT ||\n\t\t\t    tok == DUK_TOK_RCURLY) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tnum_stmts++;\n\t\t\tduk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/);\n\t\t}\n\n\t\t/* fall-through jump to next code of next case (backpatched) */\n\t\tpc_prevstmt = duk__emit_jump_empty(comp_ctx);\n\n\t\t/* XXX: would be nice to omit this jump when the jump is not\n\t\t * reachable, at least in the obvious cases (such as the case\n\t\t * ending with a 'break'.\n\t\t *\n\t\t * Perhaps duk__parse_stmt() could provide some info on whether\n\t\t * the statement is a \"dead end\"?\n\t\t *\n\t\t * If implemented, just set pc_prevstmt to -1 when not needed.\n\t\t */\n\t}\n\n\tDUK_ASSERT(comp_ctx->curr_token.t == DUK_TOK_RCURLY);\n\tduk__advance(comp_ctx);\n\n\t/* default case control flow patchup; note that if pc_prevcase < 0\n\t * (i.e. no case clauses), control enters default case automatically.\n\t */\n\tif (pc_default >= 0) {\n\t\t/* default case exists: go there if no case matches */\n\t\tduk__patch_jump(comp_ctx, pc_prevcase, pc_default);\n\t} else {\n\t\t/* default case does not exist, or no statements present\n\t\t * after default case: finish case evaluation\n\t\t */\n\t\tduk__patch_jump_here(comp_ctx, pc_prevcase);\n\t}\n\n\t/* fall-through control flow patchup; note that pc_prevstmt may be\n\t * < 0 (i.e. no case clauses), in which case this is a no-op.\n\t */\n\tduk__patch_jump_here(comp_ctx, pc_prevstmt);\n\n\t/* continue jump not patched, an INVALID opcode remains there */\n\tduk__patch_jump_here(comp_ctx, pc_label_site + 1);  /* break jump */\n\n\t/* Note: 'fast' breaks will jump to pc_label_site + 1, which will\n\t * then jump here.  The double jump will be eliminated by a\n\t * peephole pass, resulting in an optimal jump here.  The label\n\t * site jumps will remain in bytecode and will waste code size.\n\t */\n\n\treturn;\n\n syntax_error:\n\tDUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_SWITCH);\n}\n\nDUK_LOCAL void duk__parse_if_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res) {\n\tduk_reg_t temp_reset;\n\tduk_regconst_t rc_cond;\n\tduk_int_t pc_jump_false;\n\n\tDUK_DDD(DUK_DDDPRINT(\"begin parsing if statement\"));\n\n\ttemp_reset = DUK__GETTEMP(comp_ctx);\n\n\tduk__advance(comp_ctx);  /* eat 'if' */\n\tduk__advance_expect(comp_ctx, DUK_TOK_LPAREN);\n\n\trc_cond = duk__exprtop_toregconst(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/);\n\tduk__emit_if_true_skip(comp_ctx, rc_cond);\n\tpc_jump_false = duk__emit_jump_empty(comp_ctx);  /* jump to end or else part */\n\tDUK__SETTEMP(comp_ctx, temp_reset);\n\n\tduk__advance_expect(comp_ctx, DUK_TOK_RPAREN);\n\n\tduk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/);\n\n\t/* The 'else' ambiguity is resolved by 'else' binding to the innermost\n\t * construct, so greedy matching is correct here.\n\t */\n\n\tif (comp_ctx->curr_token.t == DUK_TOK_ELSE) {\n\t\tduk_int_t pc_jump_end;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"if has else part\"));\n\n\t\tduk__advance(comp_ctx);\n\n\t\tpc_jump_end = duk__emit_jump_empty(comp_ctx);  /* jump from true part to end */\n\t\tduk__patch_jump_here(comp_ctx, pc_jump_false);\n\n\t\tduk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/);\n\n\t\tduk__patch_jump_here(comp_ctx, pc_jump_end);\n\t} else {\n\t\tDUK_DDD(DUK_DDDPRINT(\"if does not have else part\"));\n\n\t\tduk__patch_jump_here(comp_ctx, pc_jump_false);\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"end parsing if statement\"));\n}\n\nDUK_LOCAL void duk__parse_do_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_int_t pc_label_site) {\n\tduk_regconst_t rc_cond;\n\tduk_int_t pc_start;\n\n\tDUK_DDD(DUK_DDDPRINT(\"begin parsing do statement\"));\n\n\tduk__advance(comp_ctx);  /* eat 'do' */\n\n\tpc_start = duk__get_current_pc(comp_ctx);\n\tduk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/);\n\tduk__patch_jump_here(comp_ctx, pc_label_site + 2);  /* continue jump */\n\n\tduk__advance_expect(comp_ctx, DUK_TOK_WHILE);\n\tduk__advance_expect(comp_ctx, DUK_TOK_LPAREN);\n\n\trc_cond = duk__exprtop_toregconst(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/);\n\tduk__emit_if_false_skip(comp_ctx, rc_cond);\n\tduk__emit_jump(comp_ctx, pc_start);\n\t/* no need to reset temps, as we're finished emitting code */\n\n\tduk__advance_expect(comp_ctx, DUK_TOK_RPAREN);\n\n\tduk__patch_jump_here(comp_ctx, pc_label_site + 1);  /* break jump */\n\n\tDUK_DDD(DUK_DDDPRINT(\"end parsing do statement\"));\n}\n\nDUK_LOCAL void duk__parse_while_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_int_t pc_label_site) {\n\tduk_reg_t temp_reset;\n\tduk_regconst_t rc_cond;\n\tduk_int_t pc_start;\n\tduk_int_t pc_jump_false;\n\n\tDUK_DDD(DUK_DDDPRINT(\"begin parsing while statement\"));\n\n\ttemp_reset = DUK__GETTEMP(comp_ctx);\n\n\tduk__advance(comp_ctx);  /* eat 'while' */\n\n\tduk__advance_expect(comp_ctx, DUK_TOK_LPAREN);\n\n\tpc_start = duk__get_current_pc(comp_ctx);\n\tduk__patch_jump_here(comp_ctx, pc_label_site + 2);  /* continue jump */\n\n\trc_cond = duk__exprtop_toregconst(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/);\n\tduk__emit_if_true_skip(comp_ctx, rc_cond);\n\tpc_jump_false = duk__emit_jump_empty(comp_ctx);\n\tDUK__SETTEMP(comp_ctx, temp_reset);\n\n\tduk__advance_expect(comp_ctx, DUK_TOK_RPAREN);\n\n\tduk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/);\n\tduk__emit_jump(comp_ctx, pc_start);\n\n\tduk__patch_jump_here(comp_ctx, pc_jump_false);\n\tduk__patch_jump_here(comp_ctx, pc_label_site + 1);  /* break jump */\n\n\tDUK_DDD(DUK_DDDPRINT(\"end parsing while statement\"));\n}\n\nDUK_LOCAL void duk__parse_break_or_continue_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_bool_t is_break = (comp_ctx->curr_token.t == DUK_TOK_BREAK);\n\tduk_int_t label_id;\n\tduk_int_t label_catch_depth;\n\tduk_int_t label_pc;  /* points to LABEL; pc+1 = jump site for break; pc+2 = jump site for continue */\n\tduk_bool_t label_is_closest;\n\n\tDUK_UNREF(res);\n\n\tduk__advance(comp_ctx);  /* eat 'break' or 'continue' */\n\n\tif (comp_ctx->curr_token.t == DUK_TOK_SEMICOLON ||  /* explicit semi follows */\n\t    comp_ctx->curr_token.lineterm ||                /* automatic semi will be inserted */\n\t    comp_ctx->curr_token.allow_auto_semi) {         /* automatic semi will be inserted */\n\t\t/* break/continue without label */\n\n\t\tduk__lookup_active_label(comp_ctx, DUK_HTHREAD_STRING_EMPTY_STRING(thr), is_break, &label_id, &label_catch_depth, &label_pc, &label_is_closest);\n\t} else if (comp_ctx->curr_token.t == DUK_TOK_IDENTIFIER) {\n\t\t/* break/continue with label (label cannot be a reserved word, production is 'Identifier' */\n\t\tDUK_ASSERT(comp_ctx->curr_token.str1 != NULL);\n\t\tduk__lookup_active_label(comp_ctx, comp_ctx->curr_token.str1, is_break, &label_id, &label_catch_depth, &label_pc, &label_is_closest);\n\t\tduk__advance(comp_ctx);\n\t} else {\n\t\tDUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_BREAK_CONT_LABEL);\n\t}\n\n\t/* Use a fast break/continue when possible.  A fast break/continue is\n\t * just a jump to the LABEL break/continue jump slot, which then jumps\n\t * to an appropriate place (for break, going through ENDLABEL correctly).\n\t * The peephole optimizer will optimize the jump to a direct one.\n\t */\n\n\tif (label_catch_depth == comp_ctx->curr_func.catch_depth &&\n\t    label_is_closest) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"break/continue: is_break=%ld, label_id=%ld, label_is_closest=%ld, \"\n\t\t                     \"label_catch_depth=%ld, catch_depth=%ld \"\n\t\t                     \"-> use fast variant (direct jump)\",\n\t\t                     (long) is_break, (long) label_id, (long) label_is_closest,\n\t\t                     (long) label_catch_depth, (long) comp_ctx->curr_func.catch_depth));\n\n\t\tduk__emit_jump(comp_ctx, label_pc + (is_break ? 1 : 2));\n\t} else {\n\t\tDUK_DDD(DUK_DDDPRINT(\"break/continue: is_break=%ld, label_id=%ld, label_is_closest=%ld, \"\n\t\t                     \"label_catch_depth=%ld, catch_depth=%ld \"\n\t\t                     \"-> use slow variant (longjmp)\",\n\t\t                     (long) is_break, (long) label_id, (long) label_is_closest,\n\t\t                     (long) label_catch_depth, (long) comp_ctx->curr_func.catch_depth));\n\n\t\tduk__emit_bc(comp_ctx,\n\t\t             is_break ? DUK_OP_BREAK : DUK_OP_CONTINUE,\n\t\t             (duk_regconst_t) label_id);\n\t}\n}\n\nDUK_LOCAL void duk__parse_return_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_regconst_t rc_val;\n\n\tduk__advance(comp_ctx);  /* eat 'return' */\n\n\t/* A 'return' statement is only allowed inside an actual function body,\n\t * not as part of eval or global code.\n\t */\n\tif (!comp_ctx->curr_func.is_function) {\n\t\tDUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_RETURN);\n\t}\n\n\tif (comp_ctx->curr_token.t == DUK_TOK_SEMICOLON ||  /* explicit semi follows */\n\t    comp_ctx->curr_token.lineterm ||                /* automatic semi will be inserted */\n\t    comp_ctx->curr_token.allow_auto_semi) {         /* automatic semi will be inserted */\n\t\tDUK_DDD(DUK_DDDPRINT(\"empty return value -> undefined\"));\n\t\tduk__emit_op_only(comp_ctx, DUK_OP_RETUNDEF);\n\t} else {\n\t\tduk_int_t pc_before_expr;\n\t\tduk_int_t pc_after_expr;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"return with a value\"));\n\n\t\tDUK_UNREF(pc_before_expr);\n\t\tDUK_UNREF(pc_after_expr);\n\n\t\tpc_before_expr = duk__get_current_pc(comp_ctx);\n\t\trc_val = duk__exprtop_toregconst(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/);\n\t\tpc_after_expr = duk__get_current_pc(comp_ctx);\n\n\t\t/* Tail call check: if last opcode emitted was CALL, and\n\t\t * the context allows it, change the CALL to TAILCALL.\n\t\t * This doesn't guarantee that a tail call will be allowed at\n\t\t * runtime, so the RETURN must still be emitted.  (Duktape\n\t\t * 0.10.0 avoided this and simulated a RETURN if a tail call\n\t\t * couldn't be used at runtime; but this didn't work\n\t\t * correctly with a thread yield/resume, see\n\t\t * test-bug-tailcall-thread-yield-resume.js for discussion.)\n\t\t *\n\t\t * In addition to the last opcode being CALL, we also need to\n\t\t * be sure that 'rc_val' is the result register of the CALL.\n\t\t * For instance, for the expression 'return 0, (function ()\n\t\t * { return 1; }), 2' the last opcode emitted is CALL (no\n\t\t * bytecode is emitted for '2') but 'rc_val' indicates\n\t\t * constant '2'.  Similarly if '2' is replaced by a register\n\t\t * bound variable, no opcodes are emitted but tail call would\n\t\t * be incorrect.\n\t\t *\n\t\t * This is tricky and easy to get wrong.  It would be best to\n\t\t * track enough expression metadata to check that 'rc_val' came\n\t\t * from that last CALL instruction.  We don't have that metadata\n\t\t * now, so we check that 'rc_val' is a temporary register result\n\t\t * (not a constant or a register bound variable).  There should\n\t\t * be no way currently for 'rc_val' to be a temporary for an\n\t\t * expression following the CALL instruction without emitting\n\t\t * some opcodes following the CALL.  This proxy check is used\n\t\t * below.\n\t\t *\n\t\t * See: test-bug-comma-expr-gh131.js.\n\t\t *\n\t\t * The non-standard 'caller' property disables tail calls\n\t\t * because they pose some special cases which haven't been\n\t\t * fixed yet.\n\t\t */\n\n#if defined(DUK_USE_TAILCALL)\n\t\tif (comp_ctx->curr_func.catch_depth == 0 &&   /* no catchers */\n\t\t    pc_after_expr > pc_before_expr) {         /* at least one opcode emitted */\n\t\t\tduk_compiler_instr *instr;\n\t\t\tduk_instr_t ins;\n\t\t\tduk_small_uint_t op;\n\n\t\t\tinstr = duk__get_instr_ptr(comp_ctx, pc_after_expr - 1);\n\t\t\tDUK_ASSERT(instr != NULL);\n\n\t\t\tins = instr->ins;\n\t\t\top = (duk_small_uint_t) DUK_DEC_OP(ins);\n\t\t\tif (op == DUK_OP_CALL &&\n\t\t\t    DUK__ISTEMP(comp_ctx, rc_val) /* see above */) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"return statement detected a tail call opportunity: \"\n\t\t\t\t                     \"catch depth is 0, duk__exprtop() emitted >= 1 instructions, \"\n\t\t\t\t                     \"and last instruction is a CALL \"\n\t\t\t\t                     \"-> change to TAILCALL\"));\n\t\t\t\tins = (ins & ~DUK_BC_SHIFTED_MASK_OP) | (DUK_OP_TAILCALL << DUK_BC_SHIFT_OP);\n\t\t\t\tinstr->ins = ins;\n\t\t\t}\n\t\t}\n#endif  /* DUK_USE_TAILCALL */\n\n\t\tif (DUK__ISREG(rc_val)) {\n\t\t\tduk__emit_bc(comp_ctx, DUK_OP_RETREG, rc_val);\n\t\t} else {\n\t\t\trc_val = DUK__REMOVECONST(rc_val);\n\t\t\tif (duk__const_needs_refcount(comp_ctx, rc_val)) {\n\t\t\t\tduk__emit_bc(comp_ctx, DUK_OP_RETCONST, rc_val);\n\t\t\t} else {\n\t\t\t\tduk__emit_bc(comp_ctx, DUK_OP_RETCONSTN, rc_val);\n\t\t\t}\n\t\t}\n\t}\n}\n\nDUK_LOCAL void duk__parse_throw_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res) {\n\tduk_reg_t reg_val;\n\n\tduk__advance(comp_ctx);  /* eat 'throw' */\n\n\t/* Unlike break/continue, throw statement does not allow an empty value. */\n\n\tif (comp_ctx->curr_token.lineterm) {\n\t\tDUK_ERROR_SYNTAX(comp_ctx->thr, DUK_STR_INVALID_THROW);\n\t}\n\n\treg_val = duk__exprtop_toreg(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/);\n\tduk__emit_bc(comp_ctx,\n\t             DUK_OP_THROW,\n\t             (duk_regconst_t) reg_val);\n}\n\nDUK_LOCAL void duk__parse_try_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_reg_t reg_catch;      /* reg_catch+0 and reg_catch+1 are reserved for TRYCATCH */\n\tduk_regconst_t rc_varname = 0;\n\tduk_small_uint_t trycatch_flags = 0;\n\tduk_int_t pc_ldconst = -1;\n\tduk_int_t pc_trycatch = -1;\n\tduk_int_t pc_catch = -1;\n\tduk_int_t pc_finally = -1;\n\n\tDUK_UNREF(res);\n\n\t/*\n\t *  See the following documentation for discussion:\n\t *\n\t *    doc/execution.rst: control flow details\n\t *\n\t *  Try, catch, and finally \"parts\" are Blocks, not Statements, so\n\t *  they must always be delimited by curly braces.  This is unlike e.g.\n\t *  the if statement, which accepts any Statement.  This eliminates any\n\t *  questions of matching parts of nested try statements.  The Block\n\t *  parsing is implemented inline here (instead of calling out).\n\t *\n\t *  Finally part has a 'let scoped' variable, which requires a few kinks\n\t *  here.\n\t */\n\n\tcomp_ctx->curr_func.catch_depth++;\n\n\tduk__advance(comp_ctx);  /* eat 'try' */\n\n\treg_catch = DUK__ALLOCTEMPS(comp_ctx, 2);\n\n\t/* The target for this LDCONST may need output shuffling, but we assume\n\t * that 'pc_ldconst' will be the LDCONST that we can patch later.  This\n\t * should be the case because there's no input shuffling.  (If there's\n\t * no catch clause, this LDCONST will be replaced with a NOP.)\n\t */\n\tpc_ldconst = duk__get_current_pc(comp_ctx);\n\tduk__emit_a_bc(comp_ctx, DUK_OP_LDCONST, reg_catch, 0 /*patched later*/);\n\n\tpc_trycatch = duk__get_current_pc(comp_ctx);\n\tduk__emit_invalid(comp_ctx);  /* TRYCATCH, cannot emit now (not enough info) */\n\tduk__emit_invalid(comp_ctx);  /* jump for 'catch' case */\n\tduk__emit_invalid(comp_ctx);  /* jump for 'finally' case or end (if no finally) */\n\n\t/* try part */\n\tduk__advance_expect(comp_ctx, DUK_TOK_LCURLY);\n\tduk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/);\n\t/* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */\n\tduk__emit_op_only(comp_ctx,\n\t                  DUK_OP_ENDTRY);\n\n\tif (comp_ctx->curr_token.t == DUK_TOK_CATCH) {\n\t\t/*\n\t\t *  The catch variable must be updated to reflect the new allocated\n\t\t *  register for the duration of the catch clause.  We need to store\n\t\t *  and restore the original value for the varmap entry (if any).\n\t\t */\n\n\t\t/*\n\t\t *  Note: currently register bindings must be fixed for the entire\n\t\t *  function.  So, even though the catch variable is in a register\n\t\t *  we know, we must use an explicit environment record and slow path\n\t\t *  accesses to read/write the catch binding to make closures created\n\t\t *  within the catch clause work correctly.  This restriction should\n\t\t *  be fixable (at least in common cases) later.\n\t\t *\n\t\t *  See: test-bug-catch-binding-2.js.\n\t\t *\n\t\t *  XXX: improve to get fast path access to most catch clauses.\n\t\t */\n\n\t\tduk_hstring *h_var;\n\t\tduk_int_t varmap_value;  /* for storing/restoring the varmap binding for catch variable */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"stack top at start of catch clause: %ld\", (long) duk_get_top(ctx)));\n\n\t\ttrycatch_flags |= DUK_BC_TRYCATCH_FLAG_HAVE_CATCH;\n\n\t\tpc_catch = duk__get_current_pc(comp_ctx);\n\n\t\tduk__advance(comp_ctx);\n\t\tduk__advance_expect(comp_ctx, DUK_TOK_LPAREN);\n\n\t\tif (comp_ctx->curr_token.t != DUK_TOK_IDENTIFIER) {\n\t\t\t/* Identifier, i.e. don't allow reserved words */\n\t\t\tgoto syntax_error;\n\t\t}\n\t\th_var = comp_ctx->curr_token.str1;\n\t\tDUK_ASSERT(h_var != NULL);\n\n\t\tduk_push_hstring(ctx, h_var);  /* keep in on valstack, use borrowed ref below */\n\n\t\tif (comp_ctx->curr_func.is_strict &&\n\t\t    ((h_var == DUK_HTHREAD_STRING_EVAL(thr)) ||\n\t\t     (h_var == DUK_HTHREAD_STRING_LC_ARGUMENTS(thr)))) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"catch identifier 'eval' or 'arguments' in strict mode -> SyntaxError\"));\n\t\t\tgoto syntax_error;\n\t\t}\n\n\t\tduk_dup_top(ctx);\n\t\trc_varname = duk__getconst(comp_ctx);\n\t\tDUK_DDD(DUK_DDDPRINT(\"catch clause, rc_varname=0x%08lx (%ld)\",\n\t\t                     (unsigned long) rc_varname, (long) rc_varname));\n\n\t\tduk__advance(comp_ctx);\n\t\tduk__advance_expect(comp_ctx, DUK_TOK_RPAREN);\n\n\t\tduk__advance_expect(comp_ctx, DUK_TOK_LCURLY);\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"varmap before modifying for catch clause: %!iT\",\n\t\t                     (duk_tval *) duk_get_tval(ctx, comp_ctx->curr_func.varmap_idx)));\n\n\t\tduk_dup_top(ctx);\n\t\tduk_get_prop(ctx, comp_ctx->curr_func.varmap_idx);\n\t\tif (duk_is_undefined(ctx, -1)) {\n\t\t\tvarmap_value = -2;\n\t\t} else if (duk_is_null(ctx, -1)) {\n\t\t\tvarmap_value = -1;\n\t\t} else {\n\t\t\tDUK_ASSERT(duk_is_number(ctx, -1));\n\t\t\tvarmap_value = duk_get_int(ctx, -1);\n\t\t\tDUK_ASSERT(varmap_value >= 0);\n\t\t}\n\t\tduk_pop(ctx);\n\n#if 0\n\t\t/* It'd be nice to do something like this - but it doesn't\n\t\t * work for closures created inside the catch clause.\n\t\t */\n\t\tduk_dup_top(ctx);\n\t\tduk_push_int(ctx, (duk_int_t) (reg_catch + 0));\n\t\tduk_put_prop(ctx, comp_ctx->curr_func.varmap_idx);\n#endif\n\t\tduk_dup_top(ctx);\n\t\tduk_push_null(ctx);\n\t\tduk_put_prop(ctx, comp_ctx->curr_func.varmap_idx);\n\n\t\tduk__emit_a_bc(comp_ctx,\n\t\t               DUK_OP_PUTVAR | DUK__EMIT_FLAG_A_IS_SOURCE,\n\t\t               (duk_regconst_t) (reg_catch + 0) /*value*/,\n\t\t               rc_varname /*varname*/);\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"varmap before parsing catch clause: %!iT\",\n\t\t                     (duk_tval *) duk_get_tval(ctx, comp_ctx->curr_func.varmap_idx)));\n\n\t\tduk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/);\n\t\t/* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */\n\n\t\tif (varmap_value == -2) {\n\t\t\t/* not present */\n\t\t\tduk_del_prop(ctx, comp_ctx->curr_func.varmap_idx);\n\t\t} else {\n\t\t\tif (varmap_value == -1) {\n\t\t\t\tduk_push_null(ctx);\n\t\t\t} else {\n\t\t\t\tDUK_ASSERT(varmap_value >= 0);\n\t\t\t\tduk_push_int(ctx, varmap_value);\n\t\t\t}\n\t\t\tduk_put_prop(ctx, comp_ctx->curr_func.varmap_idx);\n\t\t}\n\t\t/* varname is popped by above code */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"varmap after restore catch clause: %!iT\",\n\t\t                     (duk_tval *) duk_get_tval(ctx, comp_ctx->curr_func.varmap_idx)));\n\n\t\tduk__emit_op_only(comp_ctx,\n\t\t                  DUK_OP_ENDCATCH);\n\n\t\t/*\n\t\t *  XXX: for now, indicate that an expensive catch binding\n\t\t *  declarative environment is always needed.  If we don't\n\t\t *  need it, we don't need the const_varname either.\n\t\t */\n\n\t\ttrycatch_flags |= DUK_BC_TRYCATCH_FLAG_CATCH_BINDING;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"stack top at end of catch clause: %ld\", (long) duk_get_top(ctx)));\n\t}\n\n\tif (comp_ctx->curr_token.t == DUK_TOK_FINALLY) {\n\t\ttrycatch_flags |= DUK_BC_TRYCATCH_FLAG_HAVE_FINALLY;\n\n\t\tpc_finally = duk__get_current_pc(comp_ctx);\n\n\t\tduk__advance(comp_ctx);\n\n\t\tduk__advance_expect(comp_ctx, DUK_TOK_LCURLY);\n\t\tduk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/);\n\t\t/* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */\n\t\tduk__emit_b(comp_ctx,\n\t\t            DUK_OP_ENDFIN,\n\t\t            reg_catch);  /* rethrow */\n\t}\n\n\tif (!(trycatch_flags & DUK_BC_TRYCATCH_FLAG_HAVE_CATCH) &&\n\t    !(trycatch_flags & DUK_BC_TRYCATCH_FLAG_HAVE_FINALLY)) {\n\t\t/* must have catch and/or finally */\n\t\tgoto syntax_error;\n\t}\n\n\t/* If there's no catch block, rc_varname will be 0 and duk__patch_trycatch()\n\t * will replace the LDCONST with a NOP.  For any actual constant (including\n\t * constant 0) the DUK__CONST_MARKER flag will be set in rc_varname.\n\t */\n\n\tduk__patch_trycatch(comp_ctx,\n\t                    pc_ldconst,\n\t                    pc_trycatch,\n\t                    reg_catch,\n\t                    rc_varname,\n\t                    trycatch_flags);\n\n\tif (trycatch_flags & DUK_BC_TRYCATCH_FLAG_HAVE_CATCH) {\n\t\tDUK_ASSERT(pc_catch >= 0);\n\t\tduk__patch_jump(comp_ctx, pc_trycatch + 1, pc_catch);\n\t}\n\n\tif (trycatch_flags & DUK_BC_TRYCATCH_FLAG_HAVE_FINALLY) {\n\t\tDUK_ASSERT(pc_finally >= 0);\n\t\tduk__patch_jump(comp_ctx, pc_trycatch + 2, pc_finally);\n\t} else {\n\t\t/* without finally, the second jump slot is used to jump to end of stmt */\n\t\tduk__patch_jump_here(comp_ctx, pc_trycatch + 2);\n\t}\n\n\tcomp_ctx->curr_func.catch_depth--;\n\treturn;\n\n syntax_error:\n\tDUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_TRY);\n}\n\nDUK_LOCAL void duk__parse_with_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res) {\n\tduk_int_t pc_trycatch;\n\tduk_int_t pc_finished;\n\tduk_reg_t reg_catch;\n\tduk_small_uint_t trycatch_flags;\n\n\tif (comp_ctx->curr_func.is_strict) {\n\t\tDUK_ERROR_SYNTAX(comp_ctx->thr, DUK_STR_WITH_IN_STRICT_MODE);\n\t}\n\n\tcomp_ctx->curr_func.catch_depth++;\n\n\tduk__advance(comp_ctx);  /* eat 'with' */\n\n\treg_catch = DUK__ALLOCTEMPS(comp_ctx, 2);\n\n\tduk__advance_expect(comp_ctx, DUK_TOK_LPAREN);\n\tduk__exprtop_toforcedreg(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/, reg_catch);\n\tduk__advance_expect(comp_ctx, DUK_TOK_RPAREN);\n\n\tpc_trycatch = duk__get_current_pc(comp_ctx);\n\ttrycatch_flags = DUK_BC_TRYCATCH_FLAG_WITH_BINDING;\n\tduk__emit_a_bc(comp_ctx,\n\t                DUK_OP_TRYCATCH | DUK__EMIT_FLAG_NO_SHUFFLE_A,\n\t                (duk_regconst_t) trycatch_flags /*a*/,\n\t                (duk_regconst_t) reg_catch /*bc*/);\n\tduk__emit_invalid(comp_ctx);  /* catch jump */\n\tduk__emit_invalid(comp_ctx);  /* finished jump */\n\n\tduk__parse_stmt(comp_ctx, res, 0 /*allow_source_elem*/);\n\tduk__emit_op_only(comp_ctx,\n\t                  DUK_OP_ENDTRY);\n\n\tpc_finished = duk__get_current_pc(comp_ctx);\n\n\tduk__patch_jump(comp_ctx, pc_trycatch + 2, pc_finished);\n\n\tcomp_ctx->curr_func.catch_depth--;\n}\n\nDUK_LOCAL duk_int_t duk__stmt_label_site(duk_compiler_ctx *comp_ctx, duk_int_t label_id) {\n\t/* if a site already exists, nop: max one label site per statement */\n\tif (label_id >= 0) {\n\t\treturn label_id;\n\t}\n\n\tlabel_id = comp_ctx->curr_func.label_next++;\n\tDUK_DDD(DUK_DDDPRINT(\"allocated new label id for label site: %ld\", (long) label_id));\n\n\tduk__emit_bc(comp_ctx,\n\t             DUK_OP_LABEL,\n\t             (duk_regconst_t) label_id);\n\tduk__emit_invalid(comp_ctx);\n\tduk__emit_invalid(comp_ctx);\n\n\treturn label_id;\n}\n\n/* Parse a single statement.\n *\n * Creates a label site (with an empty label) automatically for iteration\n * statements.  Also \"peels off\" any label statements for explicit labels.\n */\nDUK_LOCAL void duk__parse_stmt(duk_compiler_ctx *comp_ctx, duk_ivalue *res, duk_bool_t allow_source_elem) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_bool_t dir_prol_at_entry;    /* directive prologue status at entry */\n\tduk_reg_t temp_at_entry;\n\tduk_uarridx_t labels_len_at_entry;\n\tduk_int_t pc_at_entry;           /* assumed to also be PC of \"LABEL\" */\n\tduk_int_t stmt_id;\n\tduk_small_uint_t stmt_flags = 0;\n\tduk_int_t label_id = -1;\n\tduk_small_uint_t tok;\n\tduk_bool_t test_func_decl;\n\n\tDUK__RECURSION_INCREASE(comp_ctx, thr);\n\n\ttemp_at_entry = DUK__GETTEMP(comp_ctx);\n\tpc_at_entry = duk__get_current_pc(comp_ctx);\n\tlabels_len_at_entry = (duk_uarridx_t) duk_get_length(ctx, comp_ctx->curr_func.labelnames_idx);\n\tstmt_id = comp_ctx->curr_func.stmt_next++;\n\tdir_prol_at_entry = comp_ctx->curr_func.in_directive_prologue;\n\n\tDUK_UNREF(stmt_id);\n\n\tDUK_DDD(DUK_DDDPRINT(\"parsing a statement, stmt_id=%ld, temp_at_entry=%ld, labels_len_at_entry=%ld, \"\n\t                     \"is_strict=%ld, in_directive_prologue=%ld, catch_depth=%ld\",\n\t                     (long) stmt_id, (long) temp_at_entry, (long) labels_len_at_entry,\n\t                     (long) comp_ctx->curr_func.is_strict, (long) comp_ctx->curr_func.in_directive_prologue,\n\t                     (long) comp_ctx->curr_func.catch_depth));\n\n\t/* The directive prologue flag is cleared by default so that it is\n\t * unset for any recursive statement parsing.  It is only \"revived\"\n\t * if a directive is detected.  (We could also make directives only\n\t * allowed if 'allow_source_elem' was true.)\n\t */\n\tcomp_ctx->curr_func.in_directive_prologue = 0;\n\n retry_parse:\n\n\tDUK_DDD(DUK_DDDPRINT(\"try stmt parse, stmt_id=%ld, label_id=%ld, allow_source_elem=%ld, catch_depth=%ld\",\n\t                     (long) stmt_id, (long) label_id, (long) allow_source_elem,\n\t                     (long) comp_ctx->curr_func.catch_depth));\n\n\t/*\n\t *  Detect iteration statements; if encountered, establish an\n\t *  empty label.\n\t */\n\n\ttok = comp_ctx->curr_token.t;\n\tif (tok == DUK_TOK_FOR || tok == DUK_TOK_DO || tok == DUK_TOK_WHILE ||\n\t    tok == DUK_TOK_SWITCH) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"iteration/switch statement -> add empty label\"));\n\n\t\tlabel_id = duk__stmt_label_site(comp_ctx, label_id);\n\t\tduk__add_label(comp_ctx,\n\t\t               DUK_HTHREAD_STRING_EMPTY_STRING(thr),\n\t\t               pc_at_entry /*pc_label*/,\n\t\t               label_id);\n\t}\n\n\t/*\n\t *  Main switch for statement / source element type.\n\t */\n\n\tswitch (comp_ctx->curr_token.t) {\n\tcase DUK_TOK_FUNCTION: {\n\t\t/*\n\t\t *  Function declaration, function expression, or (non-standard)\n\t\t *  function statement.\n\t\t *\n\t\t *  The E5 specification only allows function declarations at\n\t\t *  the top level (in \"source elements\").  An ExpressionStatement\n\t\t *  is explicitly not allowed to begin with a \"function\" keyword\n\t\t *  (E5 Section 12.4).  Hence any non-error semantics for such\n\t\t *  non-top-level statements are non-standard.  Duktape semantics\n\t\t *  for function statements are modelled after V8, see\n\t\t *  test-dev-func-decl-outside-top.js.\n\t\t */\n\t\ttest_func_decl = allow_source_elem;\n#if defined(DUK_USE_NONSTD_FUNC_STMT)\n\t\t/* Lenient: allow function declarations outside top level in\n\t\t * non-strict mode but reject them in strict mode.\n\t\t */\n\t\ttest_func_decl = test_func_decl || !comp_ctx->curr_func.is_strict;\n#endif  /* DUK_USE_NONSTD_FUNC_STMT */\n\t\t/* Strict: never allow function declarations outside top level. */\n\t\tif (test_func_decl) {\n\t\t\t/* FunctionDeclaration: not strictly a statement but handled as such.\n\t\t\t *\n\t\t\t * O(depth^2) parse count for inner functions is handled by recording a\n\t\t\t * lexer offset on the first compilation pass, so that the function can\n\t\t\t * be efficiently skipped on the second pass.  This is encapsulated into\n\t\t\t * duk__parse_func_like_fnum().\n\t\t\t */\n\n\t\t\tduk_int_t fnum;\n#if defined(DUK_USE_ASSERTIONS)\n\t\t\tduk_idx_t top_before;\n#endif\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"function declaration statement\"));\n\n#if defined(DUK_USE_ASSERTIONS)\n\t\t\ttop_before = duk_get_top(ctx);\n#endif\n\n\t\t\tduk__advance(comp_ctx);  /* eat 'function' */\n\t\t\tfnum = duk__parse_func_like_fnum(comp_ctx, DUK__FUNC_FLAG_DECL | DUK__FUNC_FLAG_PUSHNAME_PASS1);\n\n\t\t\t/* The value stack convention here is a bit odd: the function\n\t\t\t * name is only pushed on pass 1 (in_scanning), and is needed\n\t\t\t * to process function declarations.\n\t\t\t */\n\t\t\tif (comp_ctx->curr_func.in_scanning) {\n\t\t\t\tduk_uarridx_t n;\n\n#if defined(DUK_USE_ASSERTIONS)\n\t\t\t\tDUK_ASSERT(duk_get_top(ctx) == top_before + 1);\n#endif\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"register function declaration %!T in pass 1, fnum %ld\",\n\t\t\t\t                     duk_get_tval(ctx, -1), (long) fnum));\n\t\t\t\tn = (duk_uarridx_t) duk_get_length(ctx, comp_ctx->curr_func.decls_idx);\n\t\t\t\t/* funcname is at index -1 */\n\t\t\t\tduk_put_prop_index(ctx, comp_ctx->curr_func.decls_idx, n);\n\t\t\t\tduk_push_int(ctx, (duk_int_t) (DUK_DECL_TYPE_FUNC + (fnum << 8)));\n\t\t\t\tduk_put_prop_index(ctx, comp_ctx->curr_func.decls_idx, n + 1);\n\t\t\t} else {\n#if defined(DUK_USE_ASSERTIONS)\n\t\t\t\tDUK_ASSERT(duk_get_top(ctx) == top_before);\n#endif\n\t\t\t}\n\n\t\t\t/* no statement value (unlike function expression) */\n\t\t\tstmt_flags = 0;\n\t\t\tbreak;\n\t\t} else {\n\t\t\tDUK_ERROR_SYNTAX(thr, DUK_STR_FUNC_STMT_NOT_ALLOWED);\n\t\t}\n\t\tbreak;\n\t}\n\tcase DUK_TOK_LCURLY: {\n\t\tDUK_DDD(DUK_DDDPRINT(\"block statement\"));\n\t\tduk__advance(comp_ctx);\n\t\tduk__parse_stmts(comp_ctx, 0 /*allow_source_elem*/, 0 /*expect_eof*/);\n\t\t/* the DUK_TOK_RCURLY is eaten by duk__parse_stmts() */\n\t\tif (label_id >= 0) {\n\t\t\tduk__patch_jump_here(comp_ctx, pc_at_entry + 1);  /* break jump */\n\t\t}\n\t\tstmt_flags = 0;\n\t\tbreak;\n\t}\n\tcase DUK_TOK_CONST: {\n\t\tDUK_DDD(DUK_DDDPRINT(\"constant declaration statement\"));\n\t\tduk__parse_var_stmt(comp_ctx, res, DUK__EXPR_FLAG_REQUIRE_INIT /*expr_flags*/);\n\t\tstmt_flags = DUK__HAS_TERM;\n\t\tbreak;\n\t}\n\tcase DUK_TOK_VAR: {\n\t\tDUK_DDD(DUK_DDDPRINT(\"variable declaration statement\"));\n\t\tduk__parse_var_stmt(comp_ctx, res, 0 /*expr_flags*/);\n\t\tstmt_flags = DUK__HAS_TERM;\n\t\tbreak;\n\t}\n\tcase DUK_TOK_SEMICOLON: {\n\t\t/* empty statement with an explicit semicolon */\n\t\tDUK_DDD(DUK_DDDPRINT(\"empty statement\"));\n\t\tstmt_flags = DUK__HAS_TERM;\n\t\tbreak;\n\t}\n\tcase DUK_TOK_IF: {\n\t\tDUK_DDD(DUK_DDDPRINT(\"if statement\"));\n\t\tduk__parse_if_stmt(comp_ctx, res);\n\t\tif (label_id >= 0) {\n\t\t\tduk__patch_jump_here(comp_ctx, pc_at_entry + 1);  /* break jump */\n\t\t}\n\t\tstmt_flags = 0;\n\t\tbreak;\n\t}\n\tcase DUK_TOK_DO: {\n\t\t/*\n\t\t *  Do-while statement is mostly trivial, but there is special\n\t\t *  handling for automatic semicolon handling (triggered by the\n\t\t *  DUK__ALLOW_AUTO_SEMI_ALWAYS) flag related to a bug filed at:\n\t\t *\n\t\t *    https://bugs.ecmascript.org/show_bug.cgi?id=8\n\t\t *\n\t\t *  See doc/compiler.rst for details.\n\t\t */\n\t\tDUK_DDD(DUK_DDDPRINT(\"do statement\"));\n\t\tDUK_ASSERT(label_id >= 0);\n\t\tduk__update_label_flags(comp_ctx,\n\t\t                        label_id,\n\t\t                        DUK_LABEL_FLAG_ALLOW_BREAK | DUK_LABEL_FLAG_ALLOW_CONTINUE);\n\t\tduk__parse_do_stmt(comp_ctx, res, pc_at_entry);\n\t\tstmt_flags = DUK__HAS_TERM | DUK__ALLOW_AUTO_SEMI_ALWAYS;  /* DUK__ALLOW_AUTO_SEMI_ALWAYS workaround */\n\t\tbreak;\n\t}\n\tcase DUK_TOK_WHILE: {\n\t\tDUK_DDD(DUK_DDDPRINT(\"while statement\"));\n\t\tDUK_ASSERT(label_id >= 0);\n\t\tduk__update_label_flags(comp_ctx,\n\t\t                        label_id,\n\t\t                        DUK_LABEL_FLAG_ALLOW_BREAK | DUK_LABEL_FLAG_ALLOW_CONTINUE);\n\t\tduk__parse_while_stmt(comp_ctx, res, pc_at_entry);\n\t\tstmt_flags = 0;\n\t\tbreak;\n\t}\n\tcase DUK_TOK_FOR: {\n\t\t/*\n\t\t *  For/for-in statement is complicated to parse because\n\t\t *  determining the statement type (three-part for vs. a\n\t\t *  for-in) requires potential backtracking.\n\t\t *\n\t\t *  See the helper for the messy stuff.\n\t\t */\n\t\tDUK_DDD(DUK_DDDPRINT(\"for/for-in statement\"));\n\t\tDUK_ASSERT(label_id >= 0);\n\t\tduk__update_label_flags(comp_ctx,\n\t\t                        label_id,\n\t\t                        DUK_LABEL_FLAG_ALLOW_BREAK | DUK_LABEL_FLAG_ALLOW_CONTINUE);\n\t\tduk__parse_for_stmt(comp_ctx, res, pc_at_entry);\n\t\tstmt_flags = 0;\n\t\tbreak;\n\t}\n\tcase DUK_TOK_CONTINUE:\n\tcase DUK_TOK_BREAK: {\n\t\tDUK_DDD(DUK_DDDPRINT(\"break/continue statement\"));\n\t\tduk__parse_break_or_continue_stmt(comp_ctx, res);\n\t\tstmt_flags = DUK__HAS_TERM | DUK__IS_TERMINAL;\n\t\tbreak;\n\t}\n\tcase DUK_TOK_RETURN: {\n\t\tDUK_DDD(DUK_DDDPRINT(\"return statement\"));\n\t\tduk__parse_return_stmt(comp_ctx, res);\n\t\tstmt_flags = DUK__HAS_TERM | DUK__IS_TERMINAL;\n\t\tbreak;\n\t}\n\tcase DUK_TOK_WITH: {\n\t\tDUK_DDD(DUK_DDDPRINT(\"with statement\"));\n\t\tcomp_ctx->curr_func.with_depth++;\n\t\tduk__parse_with_stmt(comp_ctx, res);\n\t\tif (label_id >= 0) {\n\t\t\tduk__patch_jump_here(comp_ctx, pc_at_entry + 1);  /* break jump */\n\t\t}\n\t\tcomp_ctx->curr_func.with_depth--;\n\t\tstmt_flags = 0;\n\t\tbreak;\n\t}\n\tcase DUK_TOK_SWITCH: {\n\t\t/*\n\t\t *  The switch statement is pretty messy to compile.\n\t\t *  See the helper for details.\n\t\t */\n\t\tDUK_DDD(DUK_DDDPRINT(\"switch statement\"));\n\t\tDUK_ASSERT(label_id >= 0);\n\t\tduk__update_label_flags(comp_ctx,\n\t\t                        label_id,\n\t\t                        DUK_LABEL_FLAG_ALLOW_BREAK);  /* don't allow continue */\n\t\tduk__parse_switch_stmt(comp_ctx, res, pc_at_entry);\n\t\tstmt_flags = 0;\n\t\tbreak;\n\t}\n\tcase DUK_TOK_THROW: {\n\t\tDUK_DDD(DUK_DDDPRINT(\"throw statement\"));\n\t\tduk__parse_throw_stmt(comp_ctx, res);\n\t\tstmt_flags = DUK__HAS_TERM | DUK__IS_TERMINAL;\n\t\tbreak;\n\t}\n\tcase DUK_TOK_TRY: {\n\t\tDUK_DDD(DUK_DDDPRINT(\"try statement\"));\n\t\tduk__parse_try_stmt(comp_ctx, res);\n\t\tstmt_flags = 0;\n\t\tbreak;\n\t}\n\tcase DUK_TOK_DEBUGGER: {\n\t\tduk__advance(comp_ctx);\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\t\tDUK_DDD(DUK_DDDPRINT(\"debugger statement: debugging enabled, emit debugger opcode\"));\n\t\tduk__emit_op_only(comp_ctx, DUK_OP_DEBUGGER);\n#else\n\t\tDUK_DDD(DUK_DDDPRINT(\"debugger statement: ignored\"));\n#endif\n\t\tstmt_flags = DUK__HAS_TERM;\n\t\tbreak;\n\t}\n\tdefault: {\n\t\t/*\n\t\t *  Else, must be one of:\n\t\t *    - ExpressionStatement, possibly a directive (String)\n\t\t *    - LabelledStatement (Identifier followed by ':')\n\t\t *\n\t\t *  Expressions beginning with 'function' keyword are covered by a case\n\t\t *  above (such expressions are not allowed in standard E5 anyway).\n\t\t *  Also expressions starting with '{' are interpreted as block\n\t\t *  statements.  See E5 Section 12.4.\n\t\t *\n\t\t *  Directive detection is tricky; see E5 Section 14.1 on directive\n\t\t *  prologue.  A directive is an expression statement with a single\n\t\t *  string literal and an explicit or automatic semicolon.  Escape\n\t\t *  characters are significant and no parens etc are allowed:\n\t\t *\n\t\t *    'use strict';          // valid 'use strict' directive\n\t\t *    'use\\u0020strict';     // valid directive, not a 'use strict' directive\n\t\t *    ('use strict');        // not a valid directive\n\t\t *\n\t\t *  The expression is determined to consist of a single string literal\n\t\t *  based on duk__expr_nud() and duk__expr_led() call counts.  The string literal\n\t\t *  of a 'use strict' directive is determined to lack any escapes based\n\t\t *  num_escapes count from the lexer.  Note that other directives may be\n\t\t *  allowed to contain escapes, so a directive with escapes does not\n\t\t *  terminate a directive prologue.\n\t\t *\n\t\t *  We rely on the fact that the expression parser will not emit any\n\t\t *  code for a single token expression.  However, it will generate an\n\t\t *  intermediate value which we will then successfully ignore.\n\t\t *\n\t\t *  A similar approach is used for labels.\n\t\t */\n\n\t\tduk_bool_t single_token;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"expression statement\"));\n\t\tduk__exprtop(comp_ctx, res, DUK__BP_FOR_EXPR /*rbp_flags*/);\n\n\t\tsingle_token = (comp_ctx->curr_func.nud_count == 1 &&  /* one token */\n\t\t                comp_ctx->curr_func.led_count == 0);   /* no operators */\n\n\t\tif (single_token &&\n\t\t    comp_ctx->prev_token.t == DUK_TOK_IDENTIFIER &&\n\t\t    comp_ctx->curr_token.t == DUK_TOK_COLON) {\n\t\t\t/*\n\t\t\t *  Detected label\n\t\t\t */\n\n\t\t\tduk_hstring *h_lab;\n\n\t\t\t/* expected ival */\n\t\t\tDUK_ASSERT(res->t == DUK_IVAL_VAR);\n\t\t\tDUK_ASSERT(res->x1.t == DUK_ISPEC_VALUE);\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_STRING(duk_get_tval(ctx, res->x1.valstack_idx)));\n\t\t\th_lab = comp_ctx->prev_token.str1;\n\t\t\tDUK_ASSERT(h_lab != NULL);\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"explicit label site for label '%!O'\",\n\t\t\t                     (duk_heaphdr *) h_lab));\n\n\t\t\tduk__advance(comp_ctx);  /* eat colon */\n\n\t\t\tlabel_id = duk__stmt_label_site(comp_ctx, label_id);\n\n\t\t\tduk__add_label(comp_ctx,\n\t\t\t               h_lab,\n\t\t\t               pc_at_entry /*pc_label*/,\n\t\t\t               label_id);\n\n\t\t\t/* a statement following a label cannot be a source element\n\t\t\t * (a function declaration).\n\t\t\t */\n\t\t\tallow_source_elem = 0;\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"label handled, retry statement parsing\"));\n\t\t\tgoto retry_parse;\n\t\t}\n\n\t\tstmt_flags = 0;\n\n\t\tif (dir_prol_at_entry &&                           /* still in prologue */\n\t\t    single_token &&                                /* single string token */\n\t\t    comp_ctx->prev_token.t == DUK_TOK_STRING) {\n\t\t\t/*\n\t\t\t *  Detected a directive\n\t\t\t */\n\t\t\tduk_hstring *h_dir;\n\n\t\t\t/* expected ival */\n\t\t\tDUK_ASSERT(res->t == DUK_IVAL_PLAIN);\n\t\t\tDUK_ASSERT(res->x1.t == DUK_ISPEC_VALUE);\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_STRING(duk_get_tval(ctx, res->x1.valstack_idx)));\n\t\t\th_dir = comp_ctx->prev_token.str1;\n\t\t\tDUK_ASSERT(h_dir != NULL);\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"potential directive: %!O\", h_dir));\n\n\t\t\tstmt_flags |= DUK__STILL_PROLOGUE;\n\n\t\t\t/* Note: escaped characters differentiate directives */\n\n\t\t\tif (comp_ctx->prev_token.num_escapes > 0) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"directive contains escapes: valid directive \"\n\t\t\t\t                     \"but we ignore such directives\"));\n\t\t\t} else {\n\t\t\t\t/*\n\t\t\t\t * The length comparisons are present to handle\n\t\t\t\t * strings like \"use strict\\u0000foo\" as required.\n\t\t\t\t */\n\n\t\t\t\tif (DUK_HSTRING_GET_BYTELEN(h_dir) == 10 &&\n\t\t\t\t    DUK_STRNCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), \"use strict\", 10) == 0) {\n#if defined(DUK_USE_STRICT_DECL)\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"use strict directive detected: strict flag %ld -> %ld\",\n\t\t\t\t\t                     (long) comp_ctx->curr_func.is_strict, (long) 1));\n\t\t\t\t\tcomp_ctx->curr_func.is_strict = 1;\n#else\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"use strict detected but strict declarations disabled, ignoring\"));\n#endif\n\t\t\t\t} else if (DUK_HSTRING_GET_BYTELEN(h_dir) == 14 &&\n\t\t\t\t           DUK_STRNCMP((const char *) DUK_HSTRING_GET_DATA(h_dir), \"use duk notail\", 14) == 0) {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"use duk notail directive detected: notail flag %ld -> %ld\",\n\t\t\t\t\t                     (long) comp_ctx->curr_func.is_notail, (long) 1));\n\t\t\t\t\tcomp_ctx->curr_func.is_notail = 1;\n\t\t\t\t} else {\n\t\t\t\t\tDUK_DD(DUK_DDPRINT(\"unknown directive: '%!O', ignoring but not terminating \"\n\t\t\t\t\t                   \"directive prologue\", (duk_hobject *) h_dir));\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"non-directive expression statement or no longer in prologue; \"\n\t\t\t                     \"prologue terminated if still active\"));\n                }\n\n\t\tstmt_flags |= DUK__HAS_VAL | DUK__HAS_TERM;\n\t}\n\t}  /* end switch (tok) */\n\n\t/*\n\t *  Statement value handling.\n\t *\n\t *  Global code and eval code has an implicit return value\n\t *  which comes from the last statement with a value\n\t *  (technically a non-\"empty\" continuation, which is\n\t *  different from an empty statement).\n\t *\n\t *  Since we don't know whether a later statement will\n\t *  override the value of the current statement, we need\n\t *  to coerce the statement value to a register allocated\n\t *  for implicit return values.  In other cases we need\n\t *  to coerce the statement value to a plain value to get\n\t *  any side effects out (consider e.g. \"foo.bar;\").\n\t */\n\n\t/* XXX: what about statements which leave a half-cooked value in 'res'\n\t * but have no stmt value?  Any such statements?\n\t */\n\n\tif (stmt_flags & DUK__HAS_VAL) {\n\t\tduk_reg_t reg_stmt_value = comp_ctx->curr_func.reg_stmt_value;\n\t\tif (reg_stmt_value >= 0) {\n\t\t\tduk__ivalue_toforcedreg(comp_ctx, res, reg_stmt_value);\n\t\t} else {\n\t\t\tduk__ivalue_toplain_ignore(comp_ctx, res);\n\t\t}\n\t} else {\n\t\t;\n\t}\n\n\t/*\n\t *  Statement terminator check, including automatic semicolon\n\t *  handling.  After this step, 'curr_tok' should be the first\n\t *  token after a possible statement terminator.\n\t */\n\n\tif (stmt_flags & DUK__HAS_TERM) {\n\t\tif (comp_ctx->curr_token.t == DUK_TOK_SEMICOLON) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"explicit semicolon terminates statement\"));\n\t\t\tduk__advance(comp_ctx);\n\t\t} else {\n\t\t\tif (comp_ctx->curr_token.allow_auto_semi) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"automatic semicolon terminates statement\"));\n\t\t\t} else if (stmt_flags & DUK__ALLOW_AUTO_SEMI_ALWAYS) {\n\t\t\t\t/* XXX: make this lenience dependent on flags or strictness? */\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"automatic semicolon terminates statement (allowed for compatibility \"\n\t\t\t\t                     \"even though no lineterm present before next token)\"));\n\t\t\t} else {\n\t\t\t\tDUK_ERROR_SYNTAX(thr, DUK_STR_UNTERMINATED_STMT);\n\t\t\t}\n\t\t}\n\t} else {\n\t\tDUK_DDD(DUK_DDDPRINT(\"statement has no terminator\"));\n\t}\n\n\t/*\n\t *  Directive prologue tracking.\n\t */\n\n\tif (stmt_flags & DUK__STILL_PROLOGUE) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"setting in_directive_prologue\"));\n\t\tcomp_ctx->curr_func.in_directive_prologue = 1;\n\t}\n\n\t/*\n\t *  Cleanups (all statement parsing flows through here).\n\t *\n\t *  Pop label site and reset labels.  Reset 'next temp' to value at\n\t *  entry to reuse temps.\n\t */\n\n\tif (label_id >= 0) {\n\t\tduk__emit_bc(comp_ctx,\n\t\t             DUK_OP_ENDLABEL,\n\t\t             (duk_regconst_t) label_id);\n\t}\n\n\tDUK__SETTEMP(comp_ctx, temp_at_entry);\n\n\tduk__reset_labels_to_length(comp_ctx, labels_len_at_entry);\n\n\t/* XXX: return indication of \"terminalness\" (e.g. a 'throw' is terminal) */\n\n\tDUK__RECURSION_DECREASE(comp_ctx, thr);\n}\n\n/*\n *  Parse a statement list.\n *\n *  Handles automatic semicolon insertion and implicit return value.\n *\n *  Upon entry, 'curr_tok' should contain the first token of the first\n *  statement (parsed in the \"allow regexp literal\" mode).  Upon exit,\n *  'curr_tok' contains the token following the statement list terminator\n *  (EOF or closing brace).\n */\n\nDUK_LOCAL void duk__parse_stmts(duk_compiler_ctx *comp_ctx, duk_bool_t allow_source_elem, duk_bool_t expect_eof) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_ivalue res_alloc;\n\tduk_ivalue *res = &res_alloc;\n\n\t/* Setup state.  Initial ivalue is 'undefined'. */\n\n\tduk_require_stack(ctx, DUK__PARSE_STATEMENTS_SLOTS);\n\n\t/* XXX: 'res' setup can be moved to function body level; in fact, two 'res'\n\t * intermediate values suffice for parsing of each function.  Nesting is needed\n\t * for nested functions (which may occur inside expressions).\n\t */\n\n\tDUK_MEMZERO(&res_alloc, sizeof(res_alloc));\n\tres->t = DUK_IVAL_PLAIN;\n\tres->x1.t = DUK_ISPEC_VALUE;\n\tres->x1.valstack_idx = duk_get_top(ctx);\n\tres->x2.valstack_idx = res->x1.valstack_idx + 1;\n\tduk_push_undefined(ctx);\n\tduk_push_undefined(ctx);\n\n\t/* Parse statements until a closing token (EOF or '}') is found. */\n\n\tfor (;;) {\n\t\t/* Check whether statement list ends. */\n\n\t\tif (expect_eof) {\n\t\t\tif (comp_ctx->curr_token.t == DUK_TOK_EOF) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else {\n\t\t\tif (comp_ctx->curr_token.t == DUK_TOK_RCURLY) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t/* Check statement type based on the first token type.\n\t\t *\n\t\t * Note: expression parsing helpers expect 'curr_tok' to\n\t\t * contain the first token of the expression upon entry.\n\t\t */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"TOKEN %ld (non-whitespace, non-comment)\", (long) comp_ctx->curr_token.t));\n\n\t\tduk__parse_stmt(comp_ctx, res, allow_source_elem);\n\t}\n\n\tduk__advance(comp_ctx);\n\n\t/* Tear down state. */\n\n\tduk_pop_2(ctx);\n}\n\n/*\n *  Declaration binding instantiation conceptually happens when calling a\n *  function; for us it essentially means that function prologue.  The\n *  conceptual process is described in E5 Section 10.5.\n *\n *  We need to keep track of all encountered identifiers to (1) create an\n *  identifier-to-register map (\"varmap\"); and (2) detect duplicate\n *  declarations.  Identifiers which are not bound to registers still need\n *  to be tracked for detecting duplicates.  Currently such identifiers\n *  are put into the varmap with a 'null' value, which is later cleaned up.\n *\n *  To support functions with a large number of variable and function\n *  declarations, registers are not allocated beyond a certain limit;\n *  after that limit, variables and functions need slow path access.\n *  Arguments are currently always register bound, which imposes a hard\n *  (and relatively small) argument count limit.\n *\n *  Some bindings in E5 are not configurable (= deletable) and almost all\n *  are mutable (writable).  Exceptions are:\n *\n *    - The 'arguments' binding, established only if no shadowing argument\n *      or function declaration exists.  We handle 'arguments' creation\n *      and binding through an explicit slow path environment record.\n *\n *    - The \"name\" binding for a named function expression.  This is also\n *      handled through an explicit slow path environment record.\n */\n\n/* XXX: add support for variables to not be register bound always, to\n * handle cases with a very large number of variables?\n */\n\nDUK_LOCAL void duk__init_varmap_and_prologue_for_pass2(duk_compiler_ctx *comp_ctx, duk_reg_t *out_stmt_value_reg) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hstring *h_name;\n\tduk_bool_t configurable_bindings;\n\tduk_uarridx_t num_args;\n\tduk_uarridx_t num_decls;\n\tduk_regconst_t rc_name;\n\tduk_small_uint_t declvar_flags;\n\tduk_uarridx_t i;\n#if defined(DUK_USE_ASSERTIONS)\n\tduk_idx_t entry_top;\n#endif\n\n#if defined(DUK_USE_ASSERTIONS)\n\tentry_top = duk_get_top(ctx);\n#endif\n\n\t/*\n\t *  Preliminaries\n\t */\n\n\tconfigurable_bindings = comp_ctx->curr_func.is_eval;\n\tDUK_DDD(DUK_DDDPRINT(\"configurable_bindings=%ld\", (long) configurable_bindings));\n\n\t/* varmap is already in comp_ctx->curr_func.varmap_idx */\n\n\t/*\n\t *  Function formal arguments, always bound to registers\n\t *  (there's no support for shuffling them now).\n\t */\n\n\tnum_args = (duk_uarridx_t) duk_get_length(ctx, comp_ctx->curr_func.argnames_idx);\n\tDUK_DDD(DUK_DDDPRINT(\"num_args=%ld\", (long) num_args));\n\t/* XXX: check num_args */\n\n\tfor (i = 0; i < num_args; i++) {\n\t\tduk_get_prop_index(ctx, comp_ctx->curr_func.argnames_idx, i);\n\t\th_name = duk_known_hstring(ctx, -1);\n\n\t\tif (comp_ctx->curr_func.is_strict) {\n\t\t\tif (duk__hstring_is_eval_or_arguments(comp_ctx, h_name)) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"arg named 'eval' or 'arguments' in strict mode -> SyntaxError\"));\n\t\t\t\tgoto error_argname;\n\t\t\t}\n\t\t\tduk_dup_top(ctx);\n\t\t\tif (duk_has_prop(ctx, comp_ctx->curr_func.varmap_idx)) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"duplicate arg name in strict mode -> SyntaxError\"));\n\t\t\t\tgoto error_argname;\n\t\t\t}\n\n\t\t\t/* Ensure argument name is not a reserved word in current\n\t\t\t * (final) strictness.  Formal argument parsing may not\n\t\t\t * catch reserved names if strictness changes during\n\t\t\t * parsing.\n\t\t\t *\n\t\t\t * We only need to do this in strict mode because non-strict\n\t\t\t * keyword are always detected in formal argument parsing.\n\t\t\t */\n\n\t\t\tif (DUK_HSTRING_HAS_STRICT_RESERVED_WORD(h_name)) {\n\t\t\t\tgoto error_argname;\n\t\t\t}\n\t\t}\n\n\t\t/* overwrite any previous binding of the same name; the effect is\n\t\t * that last argument of a certain name wins.\n\t\t */\n\n\t\t/* only functions can have arguments */\n\t\tDUK_ASSERT(comp_ctx->curr_func.is_function);\n\t\tduk_push_uarridx(ctx, i);  /* -> [ ... name index ] */\n\t\tduk_put_prop(ctx, comp_ctx->curr_func.varmap_idx); /* -> [ ... ] */\n\n\t\t/* no code needs to be emitted, the regs already have values */\n\t}\n\n\t/* use temp_next for tracking register allocations */\n\tDUK__SETTEMP_CHECKMAX(comp_ctx, (duk_reg_t) num_args);\n\n\t/*\n\t *  After arguments, allocate special registers (like shuffling temps)\n\t */\n\n\tif (out_stmt_value_reg) {\n\t\t*out_stmt_value_reg = DUK__ALLOCTEMP(comp_ctx);\n\t}\n\tif (comp_ctx->curr_func.needs_shuffle) {\n\t\tduk_reg_t shuffle_base = DUK__ALLOCTEMPS(comp_ctx, 3);\n\t\tcomp_ctx->curr_func.shuffle1 = shuffle_base;\n\t\tcomp_ctx->curr_func.shuffle2 = shuffle_base + 1;\n\t\tcomp_ctx->curr_func.shuffle3 = shuffle_base + 2;\n\t\tDUK_D(DUK_DPRINT(\"shuffle registers needed by function, allocated: %ld %ld %ld\",\n\t\t                 (long) comp_ctx->curr_func.shuffle1,\n\t\t                 (long) comp_ctx->curr_func.shuffle2,\n\t\t                 (long) comp_ctx->curr_func.shuffle3));\n\t}\n\tif (comp_ctx->curr_func.temp_next > 0x100) {\n\t\tDUK_D(DUK_DPRINT(\"not enough 8-bit regs: temp_next=%ld\", (long) comp_ctx->curr_func.temp_next));\n\t\tgoto error_outofregs;\n\t}\n\n\t/*\n\t *  Function declarations\n\t */\n\n\tnum_decls = (duk_uarridx_t) duk_get_length(ctx, comp_ctx->curr_func.decls_idx);\n\tDUK_DDD(DUK_DDDPRINT(\"num_decls=%ld -> %!T\",\n\t                     (long) num_decls,\n\t                     (duk_tval *) duk_get_tval(ctx, comp_ctx->curr_func.decls_idx)));\n\tfor (i = 0; i < num_decls; i += 2) {\n\t\tduk_int_t decl_type;\n\t\tduk_int_t fnum;\n\n\t\tduk_get_prop_index(ctx, comp_ctx->curr_func.decls_idx, i + 1);  /* decl type */\n\t\tdecl_type = duk_to_int(ctx, -1);\n\t\tfnum = decl_type >> 8;  /* XXX: macros */\n\t\tdecl_type = decl_type & 0xff;\n\t\tduk_pop(ctx);\n\n\t\tif (decl_type != DUK_DECL_TYPE_FUNC) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tduk_get_prop_index(ctx, comp_ctx->curr_func.decls_idx, i);  /* decl name */\n\n\t\t/* XXX: spilling */\n\t\tif (comp_ctx->curr_func.is_function) {\n\t\t\tduk_reg_t reg_bind;\n\t\t\tduk_dup_top(ctx);\n\t\t\tif (duk_has_prop(ctx, comp_ctx->curr_func.varmap_idx)) {\n\t\t\t\t/* shadowed; update value */\n\t\t\t\tduk_dup_top(ctx);\n\t\t\t\tduk_get_prop(ctx, comp_ctx->curr_func.varmap_idx);\n\t\t\t\treg_bind = duk_to_int(ctx, -1);  /* [ ... name reg_bind ] */\n\t\t\t\tduk__emit_a_bc(comp_ctx,\n\t\t\t\t               DUK_OP_CLOSURE,\n\t\t\t\t               (duk_regconst_t) reg_bind,\n\t\t\t\t               (duk_regconst_t) fnum);\n\t\t\t} else {\n\t\t\t\t/* function: always register bound */\n\t\t\t\treg_bind = DUK__ALLOCTEMP(comp_ctx);\n\t\t\t\tduk__emit_a_bc(comp_ctx,\n\t\t\t\t               DUK_OP_CLOSURE,\n\t\t\t\t               (duk_regconst_t) reg_bind,\n\t\t\t\t               (duk_regconst_t) fnum);\n\t\t\t\tduk_push_int(ctx, (duk_int_t) reg_bind);\n\t\t\t}\n\t\t} else {\n\t\t\t/* Function declaration for global/eval code is emitted even\n\t\t\t * for duplicates, because of E5 Section 10.5, step 5.e of\n\t\t\t * E5.1 (special behavior for variable bound to global object).\n\t\t\t *\n\t\t\t * DECLVAR will not re-declare a variable as such, but will\n\t\t\t * update the binding value.\n\t\t\t */\n\n\t\t\tduk_reg_t reg_temp = DUK__ALLOCTEMP(comp_ctx);\n\t\t\tduk_dup_top(ctx);\n\t\t\trc_name = duk__getconst(comp_ctx);\n\t\t\tduk_push_null(ctx);\n\n\t\t\tduk__emit_a_bc(comp_ctx,\n\t\t\t               DUK_OP_CLOSURE,\n\t\t\t               (duk_regconst_t) reg_temp,\n\t\t\t               (duk_regconst_t) fnum);\n\n\t\t\tdeclvar_flags = DUK_PROPDESC_FLAG_WRITABLE |\n\t\t\t                DUK_PROPDESC_FLAG_ENUMERABLE |\n\t\t\t                DUK_BC_DECLVAR_FLAG_FUNC_DECL;\n\n\t\t\tif (configurable_bindings) {\n\t\t\t\tdeclvar_flags |= DUK_PROPDESC_FLAG_CONFIGURABLE;\n\t\t\t}\n\n\t\t\tduk__emit_a_b_c(comp_ctx,\n\t\t\t                DUK_OP_DECLVAR | DUK__EMIT_FLAG_NO_SHUFFLE_A | DUK__EMIT_FLAG_BC_REGCONST,\n\t\t\t                (duk_regconst_t) declvar_flags /*flags*/,\n\t\t\t                rc_name /*name*/,\n\t\t\t                (duk_regconst_t) reg_temp /*value*/);\n\n\t\t\tDUK__SETTEMP(comp_ctx, reg_temp);  /* forget temp */\n\t\t}\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"function declaration to varmap: %!T -> %!T\",\n\t\t                     (duk_tval *) duk_get_tval(ctx, -2),\n\t\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\n#if defined(DUK_USE_FASTINT)\n\t\tDUK_ASSERT(DUK_TVAL_IS_NULL(duk_get_tval(ctx, -1)) || DUK_TVAL_IS_FASTINT(duk_get_tval(ctx, -1)));\n#endif\n\t\tduk_put_prop(ctx, comp_ctx->curr_func.varmap_idx);  /* [ ... name reg/null ] -> [ ... ] */\n\t}\n\n\t/*\n\t *  'arguments' binding is special; if a shadowing argument or\n\t *  function declaration exists, an arguments object will\n\t *  definitely not be needed, regardless of whether the identifier\n\t *  'arguments' is referenced inside the function body.\n\t */\n\n\tif (duk_has_prop_stridx(ctx, comp_ctx->curr_func.varmap_idx, DUK_STRIDX_LC_ARGUMENTS)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"'arguments' is shadowed by argument or function declaration \"\n\t\t                     \"-> arguments object creation can be skipped\"));\n\t\tcomp_ctx->curr_func.is_arguments_shadowed = 1;\n\t}\n\n\t/*\n\t *  Variable declarations.\n\t *\n\t *  Unlike function declarations, variable declaration values don't get\n\t *  assigned on entry.  If a binding of the same name already exists, just\n\t *  ignore it silently.\n\t */\n\n\tfor (i = 0; i < num_decls; i += 2) {\n\t\tduk_int_t decl_type;\n\n\t\tduk_get_prop_index(ctx, comp_ctx->curr_func.decls_idx, i + 1);  /* decl type */\n\t\tdecl_type = duk_to_int(ctx, -1);\n\t\tdecl_type = decl_type & 0xff;\n\t\tduk_pop(ctx);\n\n\t\tif (decl_type != DUK_DECL_TYPE_VAR) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tduk_get_prop_index(ctx, comp_ctx->curr_func.decls_idx, i);  /* decl name */\n\n\t\tif (duk_has_prop(ctx, comp_ctx->curr_func.varmap_idx)) {\n\t\t\t/* shadowed, ignore */\n\t\t} else {\n\t\t\tduk_get_prop_index(ctx, comp_ctx->curr_func.decls_idx, i);  /* decl name */\n\t\t\th_name = duk_known_hstring(ctx, -1);\n\n\t\t\tif (h_name == DUK_HTHREAD_STRING_LC_ARGUMENTS(thr) &&\n\t\t\t    !comp_ctx->curr_func.is_arguments_shadowed) {\n\t\t\t\t/* E5 Section steps 7-8 */\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"'arguments' not shadowed by a function declaration, \"\n\t\t\t\t                     \"but appears as a variable declaration -> treat as \"\n\t\t\t\t                     \"a no-op for variable declaration purposes\"));\n\t\t\t\tduk_pop(ctx);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t/* XXX: spilling */\n\t\t\tif (comp_ctx->curr_func.is_function) {\n\t\t\t\tduk_reg_t reg_bind = DUK__ALLOCTEMP(comp_ctx);\n\t\t\t\t/* no need to init reg, it will be undefined on entry */\n\t\t\t\tduk_push_int(ctx, (duk_int_t) reg_bind);\n\t\t\t} else {\n\t\t\t\tduk_dup_top(ctx);\n\t\t\t\trc_name = duk__getconst(comp_ctx);\n\t\t\t\tduk_push_null(ctx);\n\n\t\t\t\tdeclvar_flags = DUK_PROPDESC_FLAG_WRITABLE |\n\t\t\t                        DUK_PROPDESC_FLAG_ENUMERABLE;\n\t\t\t\tif (configurable_bindings) {\n\t\t\t\t\tdeclvar_flags |= DUK_PROPDESC_FLAG_CONFIGURABLE;\n\t\t\t\t}\n\n\t\t\t\tduk__emit_a_b_c(comp_ctx,\n\t\t\t\t                DUK_OP_DECLVAR | DUK__EMIT_FLAG_NO_SHUFFLE_A | DUK__EMIT_FLAG_BC_REGCONST,\n\t\t\t\t                (duk_regconst_t) declvar_flags /*flags*/,\n\t\t\t\t                rc_name /*name*/,\n\t\t\t\t                (duk_regconst_t) 0 /*value*/);\n\t\t\t}\n\n\t\t\tduk_put_prop(ctx, comp_ctx->curr_func.varmap_idx);  /* [ ... name reg/null ] -> [ ... ] */\n\t\t}\n\t}\n\n\t/*\n\t *  Wrap up\n\t */\n\n\tDUK_DDD(DUK_DDDPRINT(\"varmap: %!T, is_arguments_shadowed=%ld\",\n\t                     (duk_tval *) duk_get_tval(ctx, comp_ctx->curr_func.varmap_idx),\n\t                     (long) comp_ctx->curr_func.is_arguments_shadowed));\n\n\tDUK_ASSERT_TOP(ctx, entry_top);\n\treturn;\n\n error_outofregs:\n\tDUK_ERROR_RANGE(thr, DUK_STR_REG_LIMIT);\n\tDUK_UNREACHABLE();\n\treturn;\n\n error_argname:\n\tDUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_ARG_NAME);\n\tDUK_UNREACHABLE();\n\treturn;\n}\n\n/*\n *  Parse a function-body-like expression (FunctionBody or Program\n *  in E5 grammar) using a two-pass parse.  The productions appear\n *  in the following contexts:\n *\n *    - function expression\n *    - function statement\n *    - function declaration\n *    - getter in object literal\n *    - setter in object literal\n *    - global code\n *    - eval code\n *    - Function constructor body\n *\n *  This function only parses the statement list of the body; the argument\n *  list and possible function name must be initialized by the caller.\n *  For instance, for Function constructor, the argument names are originally\n *  on the value stack.  The parsing of statements ends either at an EOF or\n *  a closing brace; this is controlled by an input flag.\n *\n *  Note that there are many differences affecting parsing and even code\n *  generation:\n *\n *    - Global and eval code have an implicit return value generated\n *      by the last statement; function code does not\n *\n *    - Global code, eval code, and Function constructor body end in\n *      an EOF, other bodies in a closing brace ('}')\n *\n *  Upon entry, 'curr_tok' is ignored and the function will pull in the\n *  first token on its own.  Upon exit, 'curr_tok' is the terminating\n *  token (EOF or closing brace).\n */\n\nDUK_LOCAL void duk__parse_func_body(duk_compiler_ctx *comp_ctx, duk_bool_t expect_eof, duk_bool_t implicit_return_value, duk_small_int_t expect_token) {\n\tduk_compiler_func *func;\n\tduk_hthread *thr;\n\tduk_context *ctx;\n\tduk_reg_t reg_stmt_value = -1;\n\tduk_lexer_point lex_pt;\n\tduk_reg_t temp_first;\n\tduk_small_int_t compile_round = 1;\n\n\tDUK_ASSERT(comp_ctx != NULL);\n\n\tthr = comp_ctx->thr;\n\tctx = (duk_context *) thr;\n\tDUK_ASSERT(thr != NULL);\n\n\tfunc = &comp_ctx->curr_func;\n\tDUK_ASSERT(func != NULL);\n\n\tDUK__RECURSION_INCREASE(comp_ctx, thr);\n\n\tduk_require_stack(ctx, DUK__FUNCTION_BODY_REQUIRE_SLOTS);\n\n\t/*\n\t *  Store lexer position for a later rewind\n\t */\n\n\tDUK_LEXER_GETPOINT(&comp_ctx->lex, &lex_pt);\n\n\t/*\n\t *  Program code (global and eval code) has an implicit return value\n\t *  from the last statement value (e.g. eval(\"1; 2+3;\") returns 3).\n\t *  This is not the case with functions.  If implicit statement return\n\t *  value is requested, all statements are coerced to a register\n\t *  allocated here, and used in the implicit return statement below.\n\t */\n\n\t/* XXX: this is pointless here because pass 1 is throw-away */\n\tif (implicit_return_value) {\n\t\treg_stmt_value = DUK__ALLOCTEMP(comp_ctx);\n\n\t\t/* If an implicit return value is needed by caller, it must be\n\t\t * initialized to 'undefined' because we don't know whether any\n\t\t * non-empty (where \"empty\" is a continuation type, and different\n\t\t * from an empty statement) statements will be executed.\n\t\t *\n\t\t * However, since 1st pass is a throwaway one, no need to emit\n\t\t * it here.\n\t\t */\n#if 0\n\t\tduk__emit_bc(comp_ctx,\n\t\t             DUK_OP_LDUNDEF,\n\t\t             0);\n#endif\n\t}\n\n\t/*\n\t *  First pass.\n\t *\n\t *  Gather variable/function declarations needed for second pass.\n\t *  Code generated is dummy and discarded.\n\t */\n\n\tfunc->in_directive_prologue = 1;\n\tfunc->in_scanning = 1;\n\tfunc->may_direct_eval = 0;\n\tfunc->id_access_arguments = 0;\n\tfunc->id_access_slow = 0;\n\tfunc->id_access_slow_own = 0;\n\tfunc->reg_stmt_value = reg_stmt_value;\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\tfunc->min_line = DUK_INT_MAX;\n\tfunc->max_line = 0;\n#endif\n\n\t/* duk__parse_stmts() expects curr_tok to be set; parse in \"allow regexp literal\" mode with current strictness */\n\tif (expect_token >= 0) {\n\t\t/* Eating a left curly; regexp mode is allowed by left curly\n\t\t * based on duk__token_lbp[] automatically.\n\t\t */\n\t\tDUK_ASSERT(expect_token == DUK_TOK_LCURLY);\n\t\tduk__update_lineinfo_currtoken(comp_ctx);\n\t\tduk__advance_expect(comp_ctx, expect_token);\n\t} else {\n\t\t/* Need to set curr_token.t because lexing regexp mode depends on current\n\t\t * token type.  Zero value causes \"allow regexp\" mode.\n\t\t */\n\t\tcomp_ctx->curr_token.t = 0;\n\t\tduk__advance(comp_ctx);\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"begin 1st pass\"));\n\tduk__parse_stmts(comp_ctx,\n\t                 1,             /* allow source elements */\n\t                 expect_eof);   /* expect EOF instead of } */\n\tDUK_DDD(DUK_DDDPRINT(\"end 1st pass\"));\n\n\t/*\n\t *  Second (and possibly third) pass.\n\t *\n\t *  Generate actual code.  In most cases the need for shuffle\n\t *  registers is detected during pass 1, but in some corner cases\n\t *  we'll only detect it during pass 2 and a third pass is then\n\t *  needed (see GH-115).\n\t */\n\n\tfor (;;) {\n\t\tduk_bool_t needs_shuffle_before = comp_ctx->curr_func.needs_shuffle;\n\t\tcompile_round++;\n\n\t\t/*\n\t\t *  Rewind lexer.\n\t\t *\n\t\t *  duk__parse_stmts() expects curr_tok to be set; parse in \"allow regexp\n\t\t *  literal\" mode with current strictness.\n\t\t *\n\t\t *  curr_token line number info should be initialized for pass 2 before\n\t\t *  generating prologue, to ensure prologue bytecode gets nice line numbers.\n\t\t */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"rewind lexer\"));\n\t\tDUK_LEXER_SETPOINT(&comp_ctx->lex, &lex_pt);\n\t\tcomp_ctx->curr_token.t = 0;  /* this is needed for regexp mode */\n\t\tcomp_ctx->curr_token.start_line = 0;  /* needed for line number tracking (becomes prev_token.start_line) */\n\t\tduk__advance(comp_ctx);\n\n\t\t/*\n\t\t *  Reset function state and perform register allocation, which creates\n\t\t *  'varmap' for second pass.  Function prologue for variable declarations,\n\t\t *  binding value initializations etc is emitted as a by-product.\n\t\t *\n\t\t *  Strict mode restrictions for duplicate and invalid argument\n\t\t *  names are checked here now that we know whether the function\n\t\t *  is actually strict.  See: test-dev-strict-mode-boundary.js.\n\t\t *\n\t\t *  Inner functions are compiled during pass 1 and are not reset.\n\t\t */\n\n\t\tduk__reset_func_for_pass2(comp_ctx);\n\t\tfunc->in_directive_prologue = 1;\n\t\tfunc->in_scanning = 0;\n\n\t\t/* must be able to emit code, alloc consts, etc. */\n\n\t\tduk__init_varmap_and_prologue_for_pass2(comp_ctx,\n\t\t                                        (implicit_return_value ? &reg_stmt_value : NULL));\n\t\tfunc->reg_stmt_value = reg_stmt_value;\n\n\t\ttemp_first = DUK__GETTEMP(comp_ctx);\n\n\t\tfunc->temp_first = temp_first;\n\t\tfunc->temp_next = temp_first;\n\t\tfunc->stmt_next = 0;\n\t\tfunc->label_next = 0;\n\n\t\t/* XXX: init or assert catch depth etc -- all values */\n\t\tfunc->id_access_arguments = 0;\n\t\tfunc->id_access_slow = 0;\n\t\tfunc->id_access_slow_own = 0;\n\n\t\t/*\n\t\t *  Check function name validity now that we know strictness.\n\t\t *  This only applies to function declarations and expressions,\n\t\t *  not setter/getter name.\n\t\t *\n\t\t *  See: test-dev-strict-mode-boundary.js\n\t\t */\n\n\t\tif (func->is_function && !func->is_setget && func->h_name != NULL) {\n\t\t\tif (func->is_strict) {\n\t\t\t\tif (duk__hstring_is_eval_or_arguments(comp_ctx, func->h_name)) {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"func name is 'eval' or 'arguments' in strict mode\"));\n\t\t\t\t\tgoto error_funcname;\n\t\t\t\t}\n\t\t\t\tif (DUK_HSTRING_HAS_STRICT_RESERVED_WORD(func->h_name)) {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"func name is a reserved word in strict mode\"));\n\t\t\t\t\tgoto error_funcname;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (DUK_HSTRING_HAS_RESERVED_WORD(func->h_name) &&\n\t\t\t\t    !DUK_HSTRING_HAS_STRICT_RESERVED_WORD(func->h_name)) {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"func name is a reserved word in non-strict mode\"));\n\t\t\t\t\tgoto error_funcname;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/*\n\t\t *  Second pass parsing.\n\t\t */\n\n\t\tif (implicit_return_value) {\n\t\t\t/* Default implicit return value. */\n\t\t\tduk__emit_bc(comp_ctx,\n\t\t\t             DUK_OP_LDUNDEF,\n\t\t\t             0);\n\t\t}\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"begin 2nd pass\"));\n\t\tduk__parse_stmts(comp_ctx,\n\t\t                 1,             /* allow source elements */\n\t\t                 expect_eof);   /* expect EOF instead of } */\n\t\tDUK_DDD(DUK_DDDPRINT(\"end 2nd pass\"));\n\n\t\tduk__update_lineinfo_currtoken(comp_ctx);\n\n\t\tif (needs_shuffle_before == comp_ctx->curr_func.needs_shuffle) {\n\t\t\t/* Shuffle decision not changed. */\n\t\t\tbreak;\n\t\t}\n\t\tif (compile_round >= 3) {\n\t\t\t/* Should never happen but avoid infinite loop just in case. */\n\t\t\tDUK_D(DUK_DPRINT(\"more than 3 compile passes needed, should never happen\"));\n\t\t\tDUK_ERROR_INTERNAL(thr);\n\t\t}\n\t\tDUK_D(DUK_DPRINT(\"need additional round to compile function, round now %d\", (int) compile_round));\n\t}\n\n\t/*\n\t *  Emit a final RETURN.\n\t *\n\t *  It would be nice to avoid emitting an unnecessary \"return\" opcode\n\t *  if the current PC is not reachable.  However, this cannot be reliably\n\t *  detected; even if the previous instruction is an unconditional jump,\n\t *  there may be a previous jump which jumps to current PC (which is the\n\t *  case for iteration and conditional statements, for instance).\n\t */\n\n\t/* XXX: request a \"last statement is terminal\" from duk__parse_stmt() and duk__parse_stmts();\n\t * we could avoid the last RETURN if we could ensure there is no way to get here\n\t * (directly or via a jump)\n\t */\n\n\tDUK_ASSERT(comp_ctx->curr_func.catch_depth == 0);\n\tif (reg_stmt_value >= 0) {\n\t\tDUK_ASSERT(DUK__ISREG(reg_stmt_value));\n\t\tduk__emit_bc(comp_ctx, DUK_OP_RETREG, (duk_regconst_t) reg_stmt_value /*reg*/);\n\t} else {\n\t\tduk__emit_op_only(comp_ctx, DUK_OP_RETUNDEF);\n\t}\n\n\t/*\n\t *  Peephole optimize JUMP chains.\n\t */\n\n\tduk__peephole_optimize_bytecode(comp_ctx);\n\n\t/*\n\t *  comp_ctx->curr_func is now ready to be converted into an actual\n\t *  function template.\n\t */\n\n\tDUK__RECURSION_DECREASE(comp_ctx, thr);\n\treturn;\n\n error_funcname:\n\tDUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_FUNC_NAME);\n}\n\n/*\n *  Parse a function-like expression:\n *\n *    - function expression\n *    - function declaration\n *    - function statement (non-standard)\n *    - setter/getter\n *\n *  Adds the function to comp_ctx->curr_func function table and returns the\n *  function number.\n *\n *  On entry, curr_token points to:\n *\n *    - the token after 'function' for function expression/declaration/statement\n *    - the token after 'set' or 'get' for setter/getter\n */\n\n/* Parse formals. */\nDUK_LOCAL void duk__parse_func_formals(duk_compiler_ctx *comp_ctx) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_bool_t first = 1;\n\tduk_uarridx_t n;\n\n\tfor (;;) {\n\t\tif (comp_ctx->curr_token.t == DUK_TOK_RPAREN) {\n\t\t\tbreak;\n\t\t}\n\n\t\tif (first) {\n\t\t\t/* no comma */\n\t\t\tfirst = 0;\n\t\t} else {\n\t\t\tduk__advance_expect(comp_ctx, DUK_TOK_COMMA);\n\t\t}\n\n\t\t/* Note: when parsing a formal list in non-strict context, e.g.\n\t\t * \"implements\" is parsed as an identifier.  When the function is\n\t\t * later detected to be strict, the argument list must be rechecked\n\t\t * against a larger set of reserved words (that of strict mode).\n\t\t * This is handled by duk__parse_func_body().  Here we recognize\n\t\t * whatever tokens are considered reserved in current strictness\n\t\t * (which is not always enough).\n\t\t */\n\n\t\tif (comp_ctx->curr_token.t != DUK_TOK_IDENTIFIER) {\n\t\t\tDUK_ERROR_SYNTAX(thr, \"expected identifier\");\n\t\t}\n\t\tDUK_ASSERT(comp_ctx->curr_token.t == DUK_TOK_IDENTIFIER);\n\t\tDUK_ASSERT(comp_ctx->curr_token.str1 != NULL);\n\t\tDUK_DDD(DUK_DDDPRINT(\"formal argument: %!O\",\n\t\t                     (duk_heaphdr *) comp_ctx->curr_token.str1));\n\n\t\t/* XXX: append primitive */\n\t\tduk_push_hstring(ctx, comp_ctx->curr_token.str1);\n\t\tn = (duk_uarridx_t) duk_get_length(ctx, comp_ctx->curr_func.argnames_idx);\n\t\tduk_put_prop_index(ctx, comp_ctx->curr_func.argnames_idx, n);\n\n\t\tduk__advance(comp_ctx);  /* eat identifier */\n\t}\n}\n\n/* Parse a function-like expression, assuming that 'comp_ctx->curr_func' is\n * correctly set up.  Assumes that curr_token is just after 'function' (or\n * 'set'/'get' etc).\n */\nDUK_LOCAL void duk__parse_func_like_raw(duk_compiler_ctx *comp_ctx, duk_small_uint_t flags) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_token *tok;\n\tduk_bool_t no_advance;\n\n\tDUK_ASSERT(comp_ctx->curr_func.num_formals == 0);\n\tDUK_ASSERT(comp_ctx->curr_func.is_function == 1);\n\tDUK_ASSERT(comp_ctx->curr_func.is_eval == 0);\n\tDUK_ASSERT(comp_ctx->curr_func.is_global == 0);\n\tDUK_ASSERT(comp_ctx->curr_func.is_setget == ((flags & DUK__FUNC_FLAG_GETSET) != 0));\n\n\tduk__update_lineinfo_currtoken(comp_ctx);\n\n\t/*\n\t *  Function name (if any)\n\t *\n\t *  We don't check for prohibited names here, because we don't\n\t *  yet know whether the function will be strict.  Function body\n\t *  parsing handles this retroactively.\n\t *\n\t *  For function expressions and declarations function name must\n\t *  be an Identifer (excludes reserved words).  For setter/getter\n\t *  it is a PropertyName which allows reserved words and also\n\t *  strings and numbers (e.g. \"{ get 1() { ... } }\").\n\t *\n\t *  Function parsing may start either from prev_token or curr_token\n\t *  (object literal method definition uses prev_token for example).\n\t *  This is dealt with for the initial token.\n\t */\n\n\tno_advance = (flags & DUK__FUNC_FLAG_USE_PREVTOKEN);\n\tif (no_advance) {\n\t\ttok = &comp_ctx->prev_token;\n\t} else {\n\t\ttok = &comp_ctx->curr_token;\n\t}\n\n\tif (flags & DUK__FUNC_FLAG_GETSET) {\n\t\t/* PropertyName -> IdentifierName | StringLiteral | NumericLiteral */\n\t\tif (tok->t_nores == DUK_TOK_IDENTIFIER || tok->t == DUK_TOK_STRING) {\n\t\t\tduk_push_hstring(ctx, tok->str1);       /* keep in valstack */\n\t\t} else if (tok->t == DUK_TOK_NUMBER) {\n\t\t\tduk_push_number(ctx, tok->num);\n\t\t\tduk_to_string(ctx, -1);\n\t\t} else {\n\t\t\tDUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_GETSET_NAME);\n\t\t}\n\t\tcomp_ctx->curr_func.h_name = duk_known_hstring(ctx, -1);  /* borrowed reference */\n\t} else {\n\t\t/* Function name is an Identifier (not IdentifierName), but we get\n\t\t * the raw name (not recognizing keywords) here and perform the name\n\t\t * checks only after pass 1.\n\t\t */\n\t\tif (tok->t_nores == DUK_TOK_IDENTIFIER) {\n\t\t\tduk_push_hstring(ctx, tok->str1);       /* keep in valstack */\n\t\t\tcomp_ctx->curr_func.h_name = duk_known_hstring(ctx, -1);  /* borrowed reference */\n\t\t} else {\n\t\t\t/* valstack will be unbalanced, which is OK */\n\t\t\tDUK_ASSERT((flags & DUK__FUNC_FLAG_GETSET) == 0);\n\t\t\tDUK_ASSERT(comp_ctx->curr_func.h_name == NULL);\n\t\t\tno_advance = 1;\n\t\t\tif (flags & DUK__FUNC_FLAG_DECL) {\n\t\t\t\tDUK_ERROR_SYNTAX(thr, DUK_STR_FUNC_NAME_REQUIRED);\n\t\t\t}\n\t\t}\n\t}\n\n\tDUK_DD(DUK_DDPRINT(\"function name: %!O\",\n\t                   (duk_heaphdr *) comp_ctx->curr_func.h_name));\n\n\tif (!no_advance) {\n\t\tduk__advance(comp_ctx);\n\t}\n\n\t/*\n\t *  Formal argument list\n\t *\n\t *  We don't check for prohibited names or for duplicate argument\n\t *  names here, becase we don't yet know whether the function will\n\t *  be strict.  Function body parsing handles this retroactively.\n\t */\n\n\tduk__advance_expect(comp_ctx, DUK_TOK_LPAREN);\n\n\tduk__parse_func_formals(comp_ctx);\n\n\tDUK_ASSERT(comp_ctx->curr_token.t == DUK_TOK_RPAREN);\n\tduk__advance(comp_ctx);\n\n\t/*\n\t *  Parse function body\n\t */\n\n\tduk__parse_func_body(comp_ctx,\n\t                     0,   /* expect_eof */\n\t                     0,   /* implicit_return_value */\n\t                     DUK_TOK_LCURLY);  /* expect_token */\n\n\t/*\n\t *  Convert duk_compiler_func to a function template and add it\n\t *  to the parent function table.\n\t */\n\n\tduk__convert_to_func_template(comp_ctx);  /* -> [ ... func ] */\n}\n\n/* Parse an inner function, adding the function template to the current function's\n * function table.  Return a function number to be used by the outer function.\n *\n * Avoiding O(depth^2) inner function parsing is handled here.  On the first pass,\n * compile and register the function normally into the 'funcs' array, also recording\n * a lexer point (offset/line) to the closing brace of the function.  On the second\n * pass, skip the function and return the same 'fnum' as on the first pass by using\n * a running counter.\n *\n * An unfortunate side effect of this is that when parsing the inner function, almost\n * nothing is known of the outer function, i.e. the inner function's scope.  We don't\n * need that information at the moment, but it would allow some optimizations if it\n * were used.\n */\nDUK_LOCAL duk_int_t duk__parse_func_like_fnum(duk_compiler_ctx *comp_ctx, duk_small_uint_t flags) {\n\tduk_hthread *thr = comp_ctx->thr;\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_compiler_func old_func;\n\tduk_idx_t entry_top;\n\tduk_int_t fnum;\n\n\t/*\n\t *  On second pass, skip the function.\n\t */\n\n\tif (!comp_ctx->curr_func.in_scanning) {\n\t\tduk_lexer_point lex_pt;\n\n\t\tfnum = comp_ctx->curr_func.fnum_next++;\n\t\tduk_get_prop_index(ctx, comp_ctx->curr_func.funcs_idx, (duk_uarridx_t) (fnum * 3 + 1));\n\t\tlex_pt.offset = duk_to_int(ctx, -1);\n\t\tduk_pop(ctx);\n\t\tduk_get_prop_index(ctx, comp_ctx->curr_func.funcs_idx, (duk_uarridx_t) (fnum * 3 + 2));\n\t\tlex_pt.line = duk_to_int(ctx, -1);\n\t\tduk_pop(ctx);\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"second pass of an inner func, skip the function, reparse closing brace; lex offset=%ld, line=%ld\",\n\t\t                     (long) lex_pt.offset, (long) lex_pt.line));\n\n\t\tDUK_LEXER_SETPOINT(&comp_ctx->lex, &lex_pt);\n\t\tcomp_ctx->curr_token.t = 0;  /* this is needed for regexp mode */\n\t\tcomp_ctx->curr_token.start_line = 0;  /* needed for line number tracking (becomes prev_token.start_line) */\n\t\tduk__advance(comp_ctx);\n\t\tduk__advance_expect(comp_ctx, DUK_TOK_RCURLY);\n\n\t\treturn fnum;\n\t}\n\n\t/*\n\t *  On first pass, perform actual parsing.  Remember valstack top on entry\n\t *  to restore it later, and switch to using a new function in comp_ctx.\n\t */\n\n\tentry_top = duk_get_top(ctx);\n\tDUK_DDD(DUK_DDDPRINT(\"before func: entry_top=%ld, curr_tok.start_offset=%ld\",\n\t                     (long) entry_top, (long) comp_ctx->curr_token.start_offset));\n\n\tDUK_MEMCPY(&old_func, &comp_ctx->curr_func, sizeof(duk_compiler_func));\n\n\tDUK_MEMZERO(&comp_ctx->curr_func, sizeof(duk_compiler_func));\n\tduk__init_func_valstack_slots(comp_ctx);\n\tDUK_ASSERT(comp_ctx->curr_func.num_formals == 0);\n\n\t/* inherit initial strictness from parent */\n\tcomp_ctx->curr_func.is_strict = old_func.is_strict;\n\n\t/* XXX: It might be better to just store the flags into the curr_func\n\t * struct and use them as is without this flag interpretation step\n\t * here.\n\t */\n\tDUK_ASSERT(comp_ctx->curr_func.is_notail == 0);\n\tcomp_ctx->curr_func.is_function = 1;\n\tDUK_ASSERT(comp_ctx->curr_func.is_eval == 0);\n\tDUK_ASSERT(comp_ctx->curr_func.is_global == 0);\n\tcomp_ctx->curr_func.is_setget = ((flags & DUK__FUNC_FLAG_GETSET) != 0);\n\tcomp_ctx->curr_func.is_namebinding = !(flags & (DUK__FUNC_FLAG_GETSET |\n\t                                                DUK__FUNC_FLAG_METDEF |\n\t                                                DUK__FUNC_FLAG_DECL));  /* no name binding for: declarations, objlit getset, objlit method def */\n\tcomp_ctx->curr_func.is_constructable = !(flags & (DUK__FUNC_FLAG_GETSET |\n\t                                                  DUK__FUNC_FLAG_METDEF));  /* not constructable: objlit getset, objlit method def */\n\n\t/*\n\t *  Parse inner function\n\t */\n\n\tduk__parse_func_like_raw(comp_ctx, flags);  /* pushes function template */\n\n\t/* prev_token.start_offset points to the closing brace here; when skipping\n\t * we're going to reparse the closing brace to ensure semicolon insertion\n\t * etc work as expected.\n\t */\n\tDUK_DDD(DUK_DDDPRINT(\"after func: prev_tok.start_offset=%ld, curr_tok.start_offset=%ld\",\n\t                     (long) comp_ctx->prev_token.start_offset, (long) comp_ctx->curr_token.start_offset));\n\tDUK_ASSERT(comp_ctx->lex.input[comp_ctx->prev_token.start_offset] == (duk_uint8_t) DUK_ASC_RCURLY);\n\n\t/* XXX: append primitive */\n\tDUK_ASSERT(duk_get_length(ctx, old_func.funcs_idx) == (duk_size_t) (old_func.fnum_next * 3));\n\tfnum = old_func.fnum_next++;\n\n\tif (fnum > DUK__MAX_FUNCS) {\n\t\tDUK_ERROR_RANGE(comp_ctx->thr, DUK_STR_FUNC_LIMIT);\n\t}\n\n\t/* array writes autoincrement length */\n\t(void) duk_put_prop_index(ctx, old_func.funcs_idx, (duk_uarridx_t) (fnum * 3));\n\tduk_push_size_t(ctx, comp_ctx->prev_token.start_offset);\n\t(void) duk_put_prop_index(ctx, old_func.funcs_idx, (duk_uarridx_t) (fnum * 3 + 1));\n\tduk_push_int(ctx, comp_ctx->prev_token.start_line);\n\t(void) duk_put_prop_index(ctx, old_func.funcs_idx, (duk_uarridx_t) (fnum * 3 + 2));\n\n\t/*\n\t *  Cleanup: restore original function, restore valstack state.\n\t *\n\t *  Function declaration handling needs the function name to be pushed\n\t *  on the value stack.\n\t */\n\n\tif (flags & DUK__FUNC_FLAG_PUSHNAME_PASS1) {\n\t\tDUK_ASSERT(comp_ctx->curr_func.h_name != NULL);\n\t\tduk_push_hstring(ctx, comp_ctx->curr_func.h_name);\n\t\tduk_replace(ctx, entry_top);\n\t\tduk_set_top(ctx, entry_top + 1);\n\t} else {\n\t\tduk_set_top(ctx, entry_top);\n\t}\n\tDUK_MEMCPY((void *) &comp_ctx->curr_func, (void *) &old_func, sizeof(duk_compiler_func));\n\n\treturn fnum;\n}\n\n/*\n *  Compile input string into an executable function template without\n *  arguments.\n *\n *  The string is parsed as the \"Program\" production of Ecmascript E5.\n *  Compilation context can be either global code or eval code (see E5\n *  Sections 14 and 15.1.2.1).\n *\n *  Input stack:  [ ... filename ]\n *  Output stack: [ ... func_template ]\n */\n\n/* XXX: source code property */\n\nDUK_LOCAL duk_ret_t duk__js_compile_raw(duk_context *ctx, void *udata) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk_hstring *h_filename;\n\tduk__compiler_stkstate *comp_stk;\n\tduk_compiler_ctx *comp_ctx;\n\tduk_lexer_point *lex_pt;\n\tduk_compiler_func *func;\n\tduk_idx_t entry_top;\n\tduk_bool_t is_strict;\n\tduk_bool_t is_eval;\n\tduk_bool_t is_funcexpr;\n\tduk_small_uint_t flags;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(udata != NULL);\n\n\t/*\n\t *  Arguments check\n\t */\n\n\tentry_top = duk_get_top(ctx);\n\tDUK_ASSERT(entry_top >= 1);\n\n\tcomp_stk = (duk__compiler_stkstate *) udata;\n\tcomp_ctx = &comp_stk->comp_ctx_alloc;\n\tlex_pt = &comp_stk->lex_pt_alloc;\n\tDUK_ASSERT(comp_ctx != NULL);\n\tDUK_ASSERT(lex_pt != NULL);\n\n\tflags = comp_stk->flags;\n\tis_eval = (flags & DUK_COMPILE_EVAL ? 1 : 0);\n\tis_strict = (flags & DUK_COMPILE_STRICT ? 1 : 0);\n\tis_funcexpr = (flags & DUK_COMPILE_FUNCEXPR ? 1 : 0);\n\n\th_filename = duk_get_hstring(ctx, -1);  /* may be undefined */\n\n\t/*\n\t *  Init compiler and lexer contexts\n\t */\n\n\tfunc = &comp_ctx->curr_func;\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n\tcomp_ctx->thr = NULL;\n\tcomp_ctx->h_filename = NULL;\n\tcomp_ctx->prev_token.str1 = NULL;\n\tcomp_ctx->prev_token.str2 = NULL;\n\tcomp_ctx->curr_token.str1 = NULL;\n\tcomp_ctx->curr_token.str2 = NULL;\n#endif\n\n\tduk_require_stack(ctx, DUK__COMPILE_ENTRY_SLOTS);\n\n\tduk_push_dynamic_buffer(ctx, 0);       /* entry_top + 0 */\n\tduk_push_undefined(ctx);               /* entry_top + 1 */\n\tduk_push_undefined(ctx);               /* entry_top + 2 */\n\tduk_push_undefined(ctx);               /* entry_top + 3 */\n\tduk_push_undefined(ctx);               /* entry_top + 4 */\n\n\tcomp_ctx->thr = thr;\n\tcomp_ctx->h_filename = h_filename;\n\tcomp_ctx->tok11_idx = entry_top + 1;\n\tcomp_ctx->tok12_idx = entry_top + 2;\n\tcomp_ctx->tok21_idx = entry_top + 3;\n\tcomp_ctx->tok22_idx = entry_top + 4;\n\tcomp_ctx->recursion_limit = DUK_USE_COMPILER_RECLIMIT;\n\n\t/* comp_ctx->lex has been pre-initialized by caller: it has been\n\t * zeroed and input/input_length has been set.\n\t */\n\tcomp_ctx->lex.thr = thr;\n\t/* comp_ctx->lex.input and comp_ctx->lex.input_length filled by caller */\n\tcomp_ctx->lex.slot1_idx = comp_ctx->tok11_idx;\n\tcomp_ctx->lex.slot2_idx = comp_ctx->tok12_idx;\n\tcomp_ctx->lex.buf_idx = entry_top + 0;\n\tcomp_ctx->lex.buf = (duk_hbuffer_dynamic *) duk_known_hbuffer(ctx, entry_top + 0);\n\tDUK_ASSERT(DUK_HBUFFER_HAS_DYNAMIC(comp_ctx->lex.buf) && !DUK_HBUFFER_HAS_EXTERNAL(comp_ctx->lex.buf));\n\tcomp_ctx->lex.token_limit = DUK_COMPILER_TOKEN_LIMIT;\n\n\tlex_pt->offset = 0;\n\tlex_pt->line = 1;\n\tDUK_LEXER_SETPOINT(&comp_ctx->lex, lex_pt);    /* fills window */\n\tcomp_ctx->curr_token.start_line = 0;  /* needed for line number tracking (becomes prev_token.start_line) */\n\n\t/*\n\t *  Initialize function state for a zero-argument function\n\t */\n\n\tduk__init_func_valstack_slots(comp_ctx);\n\tDUK_ASSERT(func->num_formals == 0);\n\n\tif (is_funcexpr) {\n\t\t/* Name will be filled from function expression, not by caller.\n\t\t * This case is used by Function constructor and duk_compile()\n\t\t * API with the DUK_COMPILE_FUNCTION option.\n\t\t */\n\t\tDUK_ASSERT(func->h_name == NULL);\n\t} else {\n\t\tduk_push_hstring_stridx(ctx, (is_eval ? DUK_STRIDX_EVAL :\n\t\t                                        DUK_STRIDX_GLOBAL));\n\t\tfunc->h_name = duk_get_hstring(ctx, -1);\n\t}\n\n\t/*\n\t *  Parse a function body or a function-like expression, depending\n\t *  on flags.\n\t */\n\n\tDUK_ASSERT(func->is_setget == 0);\n\tfunc->is_strict = (duk_uint8_t) is_strict;\n\tDUK_ASSERT(func->is_notail == 0);\n\n\tif (is_funcexpr) {\n\t\tfunc->is_function = 1;\n\t\tDUK_ASSERT(func->is_eval == 0);\n\t\tDUK_ASSERT(func->is_global == 0);\n\t\tfunc->is_namebinding = 1;\n\t\tfunc->is_constructable = 1;\n\n\t\tduk__advance(comp_ctx);  /* init 'curr_token' */\n\t\tduk__advance_expect(comp_ctx, DUK_TOK_FUNCTION);\n\t\t(void) duk__parse_func_like_raw(comp_ctx, 0 /*flags*/);\n\t} else {\n\t\tDUK_ASSERT(func->is_function == 0);\n\t\tDUK_ASSERT(is_eval == 0 || is_eval == 1);\n\t\tfunc->is_eval = (duk_uint8_t) is_eval;\n\t\tfunc->is_global = (duk_uint8_t) !is_eval;\n\t\tDUK_ASSERT(func->is_namebinding == 0);\n\t\tDUK_ASSERT(func->is_constructable == 0);\n\n\t\tduk__parse_func_body(comp_ctx,\n\t\t                     1,             /* expect_eof */\n\t\t                     1,             /* implicit_return_value */\n\t\t                     -1);           /* expect_token */\n\t}\n\n\t/*\n\t *  Convert duk_compiler_func to a function template\n\t */\n\n\tduk__convert_to_func_template(comp_ctx);\n\n\t/*\n\t *  Wrapping duk_safe_call() will mangle the stack, just return stack top\n\t */\n\n\t/* [ ... filename (temps) func ] */\n\n\treturn 1;\n}\n\nDUK_INTERNAL void duk_js_compile(duk_hthread *thr, const duk_uint8_t *src_buffer, duk_size_t src_length, duk_small_uint_t flags) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk__compiler_stkstate comp_stk;\n\tduk_compiler_ctx *prev_ctx;\n\tduk_ret_t safe_rc;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(src_buffer != NULL);\n\n\t/* preinitialize lexer state partially */\n\tDUK_MEMZERO(&comp_stk, sizeof(comp_stk));\n\tcomp_stk.flags = flags;\n\tDUK_LEXER_INITCTX(&comp_stk.comp_ctx_alloc.lex);\n\tcomp_stk.comp_ctx_alloc.lex.input = src_buffer;\n\tcomp_stk.comp_ctx_alloc.lex.input_length = src_length;\n\tcomp_stk.comp_ctx_alloc.lex.flags = flags;  /* Forward flags directly for now. */\n\n\t/* [ ... filename ] */\n\n\tprev_ctx = thr->compile_ctx;\n\tthr->compile_ctx = &comp_stk.comp_ctx_alloc;  /* for duk_error_augment.c */\n\tsafe_rc = duk_safe_call(ctx, duk__js_compile_raw, (void *) &comp_stk /*udata*/, 1 /*nargs*/, 1 /*nret*/);\n\tthr->compile_ctx = prev_ctx;  /* must restore reliably before returning */\n\n\tif (safe_rc != DUK_EXEC_SUCCESS) {\n\t\tDUK_D(DUK_DPRINT(\"compilation failed: %!T\", duk_get_tval(ctx, -1)));\n\t\t(void) duk_throw(ctx);\n\t}\n\n\t/* [ ... template ] */\n}\n\n/* automatic undefs */\n#undef DUK__ALLOCTEMP\n#undef DUK__ALLOCTEMPS\n#undef DUK__ALLOW_AUTO_SEMI_ALWAYS\n#undef DUK__BC_INITIAL_INSTS\n#undef DUK__BP_ADDITIVE\n#undef DUK__BP_ASSIGNMENT\n#undef DUK__BP_BAND\n#undef DUK__BP_BOR\n#undef DUK__BP_BXOR\n#undef DUK__BP_CALL\n#undef DUK__BP_CLOSING\n#undef DUK__BP_COMMA\n#undef DUK__BP_CONDITIONAL\n#undef DUK__BP_EOF\n#undef DUK__BP_EQUALITY\n#undef DUK__BP_EXPONENTIATION\n#undef DUK__BP_FOR_EXPR\n#undef DUK__BP_INVALID\n#undef DUK__BP_LAND\n#undef DUK__BP_LOR\n#undef DUK__BP_MEMBER\n#undef DUK__BP_MULTIPLICATIVE\n#undef DUK__BP_POSTFIX\n#undef DUK__BP_RELATIONAL\n#undef DUK__BP_SHIFT\n#undef DUK__COMPILE_ENTRY_SLOTS\n#undef DUK__CONST_MARKER\n#undef DUK__DUMP_ISPEC\n#undef DUK__DUMP_IVALUE\n#undef DUK__EMIT_FLAG_A_IS_SOURCE\n#undef DUK__EMIT_FLAG_BC_REGCONST\n#undef DUK__EMIT_FLAG_B_IS_TARGET\n#undef DUK__EMIT_FLAG_C_IS_TARGET\n#undef DUK__EMIT_FLAG_NO_SHUFFLE_A\n#undef DUK__EMIT_FLAG_NO_SHUFFLE_B\n#undef DUK__EMIT_FLAG_NO_SHUFFLE_C\n#undef DUK__EMIT_FLAG_RESERVE_JUMPSLOT\n#undef DUK__EXPR_FLAG_ALLOW_EMPTY\n#undef DUK__EXPR_FLAG_REJECT_IN\n#undef DUK__EXPR_FLAG_REQUIRE_INIT\n#undef DUK__EXPR_RBP_MASK\n#undef DUK__FUNCTION_BODY_REQUIRE_SLOTS\n#undef DUK__FUNCTION_INIT_REQUIRE_SLOTS\n#undef DUK__FUNC_FLAG_DECL\n#undef DUK__FUNC_FLAG_GETSET\n#undef DUK__FUNC_FLAG_METDEF\n#undef DUK__FUNC_FLAG_PUSHNAME_PASS1\n#undef DUK__FUNC_FLAG_USE_PREVTOKEN\n#undef DUK__GETCONST_MAX_CONSTS_CHECK\n#undef DUK__GETTEMP\n#undef DUK__HAS_TERM\n#undef DUK__HAS_VAL\n#undef DUK__ISCONST\n#undef DUK__ISREG\n#undef DUK__ISTEMP\n#undef DUK__IS_TERMINAL\n#undef DUK__IVAL_FLAG_ALLOW_CONST\n#undef DUK__IVAL_FLAG_REQUIRE_SHORT\n#undef DUK__IVAL_FLAG_REQUIRE_TEMP\n#undef DUK__MAX_ARRAY_INIT_VALUES\n#undef DUK__MAX_CONSTS\n#undef DUK__MAX_FUNCS\n#undef DUK__MAX_OBJECT_INIT_PAIRS\n#undef DUK__MAX_TEMPS\n#undef DUK__MK_LBP\n#undef DUK__MK_LBP_FLAGS\n#undef DUK__OBJ_LIT_KEY_GET\n#undef DUK__OBJ_LIT_KEY_PLAIN\n#undef DUK__OBJ_LIT_KEY_SET\n#undef DUK__PARSE_EXPR_SLOTS\n#undef DUK__PARSE_STATEMENTS_SLOTS\n#undef DUK__RECURSION_DECREASE\n#undef DUK__RECURSION_INCREASE\n#undef DUK__REMOVECONST\n#undef DUK__SETTEMP\n#undef DUK__SETTEMP_CHECKMAX\n#undef DUK__STILL_PROLOGUE\n#undef DUK__TOKEN_LBP_BP_MASK\n#undef DUK__TOKEN_LBP_FLAG_NO_REGEXP\n#undef DUK__TOKEN_LBP_FLAG_TERMINATES\n#undef DUK__TOKEN_LBP_FLAG_UNUSED\n#undef DUK__TOKEN_LBP_GET_BP\n/*\n *  Ecmascript bytecode executor.\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Local declarations.\n */\n\nDUK_LOCAL_DECL void duk__js_execute_bytecode_inner(duk_hthread *entry_thread, duk_size_t entry_callstack_top);\n\n/*\n *  Misc helpers.\n */\n\n/* Forced inline declaration, only applied for performance oriented build. */\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n#define DUK__INLINE_PERF\n#else\n#define DUK__INLINE_PERF DUK_ALWAYS_INLINE\n#endif\n\n/* Replace value stack top to value at 'tv_ptr'.  Optimize for\n * performance by only applying the net refcount change.\n */\n#define DUK__REPLACE_TO_TVPTR(thr,tv_ptr) do { \\\n\t\tduk_hthread *duk__thr; \\\n\t\tduk_tval *duk__tvsrc; \\\n\t\tduk_tval *duk__tvdst; \\\n\t\tduk_tval duk__tvtmp; \\\n\t\tduk__thr = (thr); \\\n\t\tduk__tvsrc = DUK_GET_TVAL_NEGIDX((duk_context *) duk__thr, -1); \\\n\t\tduk__tvdst = (tv_ptr); \\\n\t\tDUK_TVAL_SET_TVAL(&duk__tvtmp, duk__tvdst); \\\n\t\tDUK_TVAL_SET_TVAL(duk__tvdst, duk__tvsrc); \\\n\t\tDUK_TVAL_SET_UNDEFINED(duk__tvsrc);  /* value stack init policy */ \\\n\t\tduk__thr->valstack_top = duk__tvsrc; \\\n\t\tDUK_TVAL_DECREF(duk__thr, &duk__tvtmp); \\\n\t} while (0)\n\n/* XXX: candidate of being an internal shared API call */\n#if !defined(DUK_USE_EXEC_PREFER_SIZE)\nDUK_LOCAL void duk__push_tvals_incref_only(duk_hthread *thr, duk_tval *tv_src, duk_small_uint_fast_t count) {\n\tduk_tval *tv_dst;\n\tduk_size_t copy_size;\n\tduk_size_t i;\n\n\ttv_dst = thr->valstack_top;\n\tcopy_size = sizeof(duk_tval) * count;\n\tDUK_MEMCPY((void *) tv_dst, (const void *) tv_src, copy_size);\n\tfor (i = 0; i < count; i++) {\n\t\tDUK_TVAL_INCREF(thr, tv_dst);\n\t\ttv_dst++;\n\t}\n\tthr->valstack_top = tv_dst;\n}\n#endif\n\n/*\n *  Arithmetic, binary, and logical helpers.\n *\n *  Note: there is no opcode for logical AND or logical OR; this is on\n *  purpose, because the evalution order semantics for them make such\n *  opcodes pretty pointless: short circuiting means they are most\n *  comfortably implemented as jumps.  However, a logical NOT opcode\n *  is useful.\n *\n *  Note: careful with duk_tval pointers here: they are potentially\n *  invalidated by any DECREF and almost any API call.  It's still\n *  preferable to work without making a copy but that's not always\n *  possible.\n */\n\nDUK_LOCAL DUK__INLINE_PERF duk_double_t duk__compute_mod(duk_double_t d1, duk_double_t d2) {\n\treturn (duk_double_t) duk_js_arith_mod((double) d1, (double) d2);\n}\n\n#if defined(DUK_USE_ES7_EXP_OPERATOR)\nDUK_LOCAL DUK__INLINE_PERF duk_double_t duk__compute_exp(duk_double_t d1, duk_double_t d2) {\n\treturn (duk_double_t) duk_js_arith_pow((double) d1, (double) d2);\n}\n#endif\n\nDUK_LOCAL DUK__INLINE_PERF void duk__vm_arith_add(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_small_uint_fast_t idx_z) {\n\t/*\n\t *  Addition operator is different from other arithmetic\n\t *  operations in that it also provides string concatenation.\n\t *  Hence it is implemented separately.\n\t *\n\t *  There is a fast path for number addition.  Other cases go\n\t *  through potentially multiple coercions as described in the\n\t *  E5 specification.  It may be possible to reduce the number\n\t *  of coercions, but this must be done carefully to preserve\n\t *  the exact semantics.\n\t *\n\t *  E5 Section 11.6.1.\n\t *\n\t *  Custom types also have special behavior implemented here.\n\t */\n\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_double_union du;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(tv_x != NULL);  /* may be reg or const */\n\tDUK_ASSERT(tv_y != NULL);  /* may be reg or const */\n\tDUK_ASSERT_DISABLE(idx_z >= 0);  /* unsigned */\n\tDUK_ASSERT((duk_uint_t) idx_z < (duk_uint_t) duk_get_top(ctx));\n\n\t/*\n\t *  Fast paths\n\t */\n\n#if defined(DUK_USE_FASTINT)\n\tif (DUK_TVAL_IS_FASTINT(tv_x) && DUK_TVAL_IS_FASTINT(tv_y)) {\n\t\tduk_int64_t v1, v2, v3;\n\t\tduk_int32_t v3_hi;\n\t\tduk_tval *tv_z;\n\n\t\t/* Input values are signed 48-bit so we can detect overflow\n\t\t * reliably from high bits or just a comparison.\n\t\t */\n\n\t\tv1 = DUK_TVAL_GET_FASTINT(tv_x);\n\t\tv2 = DUK_TVAL_GET_FASTINT(tv_y);\n\t\tv3 = v1 + v2;\n\t\tv3_hi = (duk_int32_t) (v3 >> 32);\n\t\tif (DUK_LIKELY(v3_hi >= -0x8000LL && v3_hi <= 0x7fffLL)) {\n\t\t\ttv_z = thr->valstack_bottom + idx_z;\n\t\t\tDUK_TVAL_SET_FASTINT_UPDREF(thr, tv_z, v3);  /* side effects */\n\t\t\treturn;\n\t\t} else {\n\t\t\t/* overflow, fall through */\n\t\t\t;\n\t\t}\n\t}\n#endif  /* DUK_USE_FASTINT */\n\n\tif (DUK_TVAL_IS_NUMBER(tv_x) && DUK_TVAL_IS_NUMBER(tv_y)) {\n#if !defined(DUK_USE_EXEC_PREFER_SIZE)\n\t\tduk_tval *tv_z;\n#endif\n\n\t\tdu.d = DUK_TVAL_GET_NUMBER(tv_x) + DUK_TVAL_GET_NUMBER(tv_y);\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n\t\tduk_push_number(ctx, du.d);  /* will NaN normalize result */\n\t\tduk_replace(ctx, idx_z);\n#else  /* DUK_USE_EXEC_PREFER_SIZE */\n\t\tDUK_DBLUNION_NORMALIZE_NAN_CHECK(&du);\n\t\tDUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du));\n\t\ttv_z = thr->valstack_bottom + idx_z;\n\t\tDUK_TVAL_SET_NUMBER_UPDREF(thr, tv_z, du.d);  /* side effects */\n#endif  /* DUK_USE_EXEC_PREFER_SIZE */\n\t\treturn;\n\t}\n\n\t/*\n\t *  Slow path: potentially requires function calls for coercion\n\t */\n\n\tduk_push_tval(ctx, tv_x);\n\tduk_push_tval(ctx, tv_y);\n\tduk_to_primitive(ctx, -2, DUK_HINT_NONE);  /* side effects -> don't use tv_x, tv_y after */\n\tduk_to_primitive(ctx, -1, DUK_HINT_NONE);\n\n\t/* Since Duktape 2.x plain buffers are treated like ArrayBuffer. */\n\tif (duk_is_string(ctx, -2) || duk_is_string(ctx, -1)) {\n\t\t/* Symbols shouldn't technically be handled here, but should\n\t\t * go into the default ToNumber() coercion path instead and\n\t\t * fail there with a TypeError.  However, there's a ToString()\n\t\t * here which also fails with TypeError so no explicit check\n\t\t * is needed.\n\t\t */\n\t\tduk_to_string(ctx, -2);\n\t\tduk_to_string(ctx, -1);\n\t\tduk_concat(ctx, 2);  /* [... s1 s2] -> [... s1+s2] */\n\t} else {\n\t\tduk_double_t d1, d2;\n\n\t\td1 = duk_to_number_m2(ctx);\n\t\td2 = duk_to_number_m1(ctx);\n\t\tDUK_ASSERT(duk_is_number(ctx, -2));\n\t\tDUK_ASSERT(duk_is_number(ctx, -1));\n\t\tDUK_ASSERT_DOUBLE_IS_NORMALIZED(d1);\n\t\tDUK_ASSERT_DOUBLE_IS_NORMALIZED(d2);\n\n\t\tdu.d = d1 + d2;\n\t\tduk_pop_2(ctx);\n\t\tduk_push_number(ctx, du.d);  /* will NaN normalize result */\n\t}\n\tduk_replace(ctx, (duk_idx_t) idx_z);  /* side effects */\n}\n\nDUK_LOCAL DUK__INLINE_PERF void duk__vm_arith_binary_op(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_idx_t idx_z, duk_small_uint_fast_t opcode) {\n\t/*\n\t *  Arithmetic operations other than '+' have number-only semantics\n\t *  and are implemented here.  The separate switch-case here means a\n\t *  \"double dispatch\" of the arithmetic opcode, but saves code space.\n\t *\n\t *  E5 Sections 11.5, 11.5.1, 11.5.2, 11.5.3, 11.6, 11.6.1, 11.6.2, 11.6.3.\n\t */\n\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_double_t d1, d2;\n\tduk_double_union du;\n\tduk_small_uint_fast_t opcode_shifted;\n#if defined(DUK_USE_FASTINT) || !defined(DUK_USE_EXEC_PREFER_SIZE)\n\tduk_tval *tv_z;\n#endif\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(tv_x != NULL);  /* may be reg or const */\n\tDUK_ASSERT(tv_y != NULL);  /* may be reg or const */\n\tDUK_ASSERT_DISABLE(idx_z >= 0);  /* unsigned */\n\tDUK_ASSERT((duk_uint_t) idx_z < (duk_uint_t) duk_get_top(ctx));\n\n\topcode_shifted = opcode >> 2;  /* Get base opcode without reg/const modifiers. */\n\n#if defined(DUK_USE_FASTINT)\n\tif (DUK_TVAL_IS_FASTINT(tv_x) && DUK_TVAL_IS_FASTINT(tv_y)) {\n\t\tduk_int64_t v1, v2, v3;\n\t\tduk_int32_t v3_hi;\n\n\t\tv1 = DUK_TVAL_GET_FASTINT(tv_x);\n\t\tv2 = DUK_TVAL_GET_FASTINT(tv_y);\n\n\t\tswitch (opcode_shifted) {\n\t\tcase DUK_OP_SUB >> 2: {\n\t\t\tv3 = v1 - v2;\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_MUL >> 2: {\n\t\t\t/* Must ensure result is 64-bit (no overflow); a\n\t\t\t * simple and sufficient fast path is to allow only\n\t\t\t * 32-bit inputs.  Avoid zero inputs to avoid\n\t\t\t * negative zero issues (-1 * 0 = -0, for instance).\n\t\t\t */\n\t\t\tif (v1 >= -0x80000000LL && v1 <= 0x7fffffffLL && v1 != 0 &&\n\t\t\t    v2 >= -0x80000000LL && v2 <= 0x7fffffffLL && v2 != 0) {\n\t\t\t\tv3 = v1 * v2;\n\t\t\t} else {\n\t\t\t\tgoto skip_fastint;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_DIV >> 2: {\n\t\t\t/* Don't allow a zero divisor.  Fast path check by\n\t\t\t * \"verifying\" with multiplication.  Also avoid zero\n\t\t\t * dividend to avoid negative zero issues (0 / -1 = -0\n\t\t\t * for instance).\n\t\t\t */\n\t\t\tif (v1 == 0 || v2 == 0) {\n\t\t\t\tgoto skip_fastint;\n\t\t\t}\n\t\t\tv3 = v1 / v2;\n\t\t\tif (v3 * v2 != v1) {\n\t\t\t\tgoto skip_fastint;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_MOD >> 2: {\n\t\t\t/* Don't allow a zero divisor.  Restrict both v1 and\n\t\t\t * v2 to positive values to avoid compiler specific\n\t\t\t * behavior.\n\t\t\t */\n\t\t\tif (v1 < 1 || v2 < 1) {\n\t\t\t\tgoto skip_fastint;\n\t\t\t}\n\t\t\tv3 = v1 % v2;\n\t\t\tDUK_ASSERT(v3 >= 0);\n\t\t\tDUK_ASSERT(v3 < v2);\n\t\t\tDUK_ASSERT(v1 - (v1 / v2) * v2 == v3);\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\t/* Possible with DUK_OP_EXP. */\n\t\t\tgoto skip_fastint;\n\t\t}\n\t\t}\n\n\t\tv3_hi = (duk_int32_t) (v3 >> 32);\n\t\tif (DUK_LIKELY(v3_hi >= -0x8000LL && v3_hi <= 0x7fffLL)) {\n\t\t\ttv_z = thr->valstack_bottom + idx_z;\n\t\t\tDUK_TVAL_SET_FASTINT_UPDREF(thr, tv_z, v3);  /* side effects */\n\t\t\treturn;\n\t\t}\n\t\t/* fall through if overflow etc */\n\t}\n skip_fastint:\n#endif  /* DUK_USE_FASTINT */\n\n\tif (DUK_TVAL_IS_NUMBER(tv_x) && DUK_TVAL_IS_NUMBER(tv_y)) {\n\t\t/* fast path */\n\t\td1 = DUK_TVAL_GET_NUMBER(tv_x);\n\t\td2 = DUK_TVAL_GET_NUMBER(tv_y);\n\t} else {\n\t\tduk_push_tval(ctx, tv_x);\n\t\tduk_push_tval(ctx, tv_y);\n\t\td1 = duk_to_number_m2(ctx);  /* side effects */\n\t\td2 = duk_to_number_m1(ctx);\n\t\tDUK_ASSERT(duk_is_number(ctx, -2));\n\t\tDUK_ASSERT(duk_is_number(ctx, -1));\n\t\tDUK_ASSERT_DOUBLE_IS_NORMALIZED(d1);\n\t\tDUK_ASSERT_DOUBLE_IS_NORMALIZED(d2);\n\t\tduk_pop_2(ctx);\n\t}\n\n\tswitch (opcode_shifted) {\n\tcase DUK_OP_SUB >> 2: {\n\t\tdu.d = d1 - d2;\n\t\tbreak;\n\t}\n\tcase DUK_OP_MUL >> 2: {\n\t\tdu.d = d1 * d2;\n\t\tbreak;\n\t}\n\tcase DUK_OP_DIV >> 2: {\n\t\tdu.d = d1 / d2;\n\t\tbreak;\n\t}\n\tcase DUK_OP_MOD >> 2: {\n\t\tdu.d = duk__compute_mod(d1, d2);\n\t\tbreak;\n\t}\n#if defined(DUK_USE_ES7_EXP_OPERATOR)\n\tcase DUK_OP_EXP >> 2: {\n\t\tdu.d = duk__compute_exp(d1, d2);\n\t\tbreak;\n\t}\n#endif\n\tdefault: {\n\t\tDUK_UNREACHABLE();\n\t\tdu.d = DUK_DOUBLE_NAN;  /* should not happen */\n\t\tbreak;\n\t}\n\t}\n\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n\tduk_push_number(ctx, du.d);  /* will NaN normalize result */\n\tduk_replace(ctx, idx_z);\n#else  /* DUK_USE_EXEC_PREFER_SIZE */\n\t/* important to use normalized NaN with 8-byte tagged types */\n\tDUK_DBLUNION_NORMALIZE_NAN_CHECK(&du);\n\tDUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du));\n\ttv_z = thr->valstack_bottom + idx_z;\n\tDUK_TVAL_SET_NUMBER_UPDREF(thr, tv_z, du.d);  /* side effects */\n#endif  /* DUK_USE_EXEC_PREFER_SIZE */\n}\n\nDUK_LOCAL DUK__INLINE_PERF void duk__vm_bitwise_binary_op(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_small_uint_fast_t idx_z, duk_small_uint_fast_t opcode) {\n\t/*\n\t *  Binary bitwise operations use different coercions (ToInt32, ToUint32)\n\t *  depending on the operation.  We coerce the arguments first using\n\t *  ToInt32(), and then cast to an 32-bit value if necessary.  Note that\n\t *  such casts must be correct even if there is no native 32-bit type\n\t *  (e.g., duk_int32_t and duk_uint32_t are 64-bit).\n\t *\n\t *  E5 Sections 11.10, 11.7.1, 11.7.2, 11.7.3\n\t */\n\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_int32_t i1, i2, i3;\n\tduk_uint32_t u1, u2, u3;\n#if defined(DUK_USE_FASTINT)\n\tduk_int64_t fi3;\n#else\n\tduk_double_t d3;\n#endif\n\tduk_small_uint_fast_t opcode_shifted;\n#if defined(DUK_USE_FASTINT) || !defined(DUK_USE_EXEC_PREFER_SIZE)\n\tduk_tval *tv_z;\n#endif\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(tv_x != NULL);  /* may be reg or const */\n\tDUK_ASSERT(tv_y != NULL);  /* may be reg or const */\n\tDUK_ASSERT_DISABLE(idx_z >= 0);  /* unsigned */\n\tDUK_ASSERT((duk_uint_t) idx_z < (duk_uint_t) duk_get_top(ctx));\n\n\topcode_shifted = opcode >> 2;  /* Get base opcode without reg/const modifiers. */\n\n#if defined(DUK_USE_FASTINT)\n\tif (DUK_TVAL_IS_FASTINT(tv_x) && DUK_TVAL_IS_FASTINT(tv_y)) {\n\t\ti1 = (duk_int32_t) DUK_TVAL_GET_FASTINT_I32(tv_x);\n\t\ti2 = (duk_int32_t) DUK_TVAL_GET_FASTINT_I32(tv_y);\n\t}\n\telse\n#endif  /* DUK_USE_FASTINT */\n\t{\n\t\tduk_push_tval(ctx, tv_x);\n\t\tduk_push_tval(ctx, tv_y);\n\t\ti1 = duk_to_int32(ctx, -2);\n\t\ti2 = duk_to_int32(ctx, -1);\n\t\tduk_pop_2(ctx);\n\t}\n\n\tswitch (opcode_shifted) {\n\tcase DUK_OP_BAND >> 2: {\n\t\ti3 = i1 & i2;\n\t\tbreak;\n\t}\n\tcase DUK_OP_BOR >> 2: {\n\t\ti3 = i1 | i2;\n\t\tbreak;\n\t}\n\tcase DUK_OP_BXOR >> 2: {\n\t\ti3 = i1 ^ i2;\n\t\tbreak;\n\t}\n\tcase DUK_OP_BASL >> 2: {\n\t\t/* Signed shift, named \"arithmetic\" (asl) because the result\n\t\t * is signed, e.g. 4294967295 << 1 -> -2.  Note that result\n\t\t * must be masked.\n\t\t */\n\n\t\tu2 = ((duk_uint32_t) i2) & 0xffffffffUL;\n\t\ti3 = (duk_int32_t) (((duk_uint32_t) i1) << (u2 & 0x1fUL));  /* E5 Section 11.7.1, steps 7 and 8 */\n\t\ti3 = i3 & ((duk_int32_t) 0xffffffffUL);                     /* Note: left shift, should mask */\n\t\tbreak;\n\t}\n\tcase DUK_OP_BASR >> 2: {\n\t\t/* signed shift */\n\n\t\tu2 = ((duk_uint32_t) i2) & 0xffffffffUL;\n\t\ti3 = i1 >> (u2 & 0x1fUL);                      /* E5 Section 11.7.2, steps 7 and 8 */\n\t\tbreak;\n\t}\n\tcase DUK_OP_BLSR >> 2: {\n\t\t/* unsigned shift */\n\n\t\tu1 = ((duk_uint32_t) i1) & 0xffffffffUL;\n\t\tu2 = ((duk_uint32_t) i2) & 0xffffffffUL;\n\n\t\t/* special result value handling */\n\t\tu3 = u1 >> (u2 & 0x1fUL);     /* E5 Section 11.7.2, steps 7 and 8 */\n#if defined(DUK_USE_FASTINT)\n\t\tfi3 = (duk_int64_t) u3;\n\t\tgoto fastint_result_set;\n#else\n\t\td3 = (duk_double_t) u3;\n\t\tgoto result_set;\n#endif\n\t}\n\tdefault: {\n\t\tDUK_UNREACHABLE();\n\t\ti3 = 0;  /* should not happen */\n\t\tbreak;\n\t}\n\t}\n\n#if defined(DUK_USE_FASTINT)\n\t/* Result is always fastint compatible. */\n\t/* XXX: Set 32-bit result (but must then handle signed and\n\t * unsigned results separately).\n\t */\n\tfi3 = (duk_int64_t) i3;\n\n fastint_result_set:\n\ttv_z = thr->valstack_bottom + idx_z;\n\tDUK_TVAL_SET_FASTINT_UPDREF(thr, tv_z, fi3);  /* side effects */\n#else  /* DUK_USE_FASTINT */\n\td3 = (duk_double_t) i3;\n\n result_set:\n\tDUK_ASSERT(!DUK_ISNAN(d3));            /* 'd3' is never NaN, so no need to normalize */\n\tDUK_ASSERT_DOUBLE_IS_NORMALIZED(d3);   /* always normalized */\n\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n\tduk_push_number(ctx, d3);  /* would NaN normalize result, but unnecessary */\n\tduk_replace(ctx, idx_z);\n#else  /* DUK_USE_EXEC_PREFER_SIZE */\n\ttv_z = thr->valstack_bottom + idx_z;\n\tDUK_TVAL_SET_NUMBER_UPDREF(thr, tv_z, d3);  /* side effects */\n#endif  /* DUK_USE_EXEC_PREFER_SIZE */\n#endif  /* DUK_USE_FASTINT */\n}\n\n/* In-place unary operation. */\nDUK_LOCAL DUK__INLINE_PERF void duk__vm_arith_unary_op(duk_hthread *thr, duk_idx_t idx_src, duk_idx_t idx_dst, duk_small_uint_fast_t opcode) {\n\t/*\n\t *  Arithmetic operations other than '+' have number-only semantics\n\t *  and are implemented here.  The separate switch-case here means a\n\t *  \"double dispatch\" of the arithmetic opcode, but saves code space.\n\t *\n\t *  E5 Sections 11.5, 11.5.1, 11.5.2, 11.5.3, 11.6, 11.6.1, 11.6.2, 11.6.3.\n\t */\n\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_tval *tv;\n\tduk_double_t d1;\n\tduk_double_union du;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(opcode == DUK_OP_UNM || opcode == DUK_OP_UNP);\n\tDUK_ASSERT(idx_src >= 0);\n\tDUK_ASSERT(idx_dst >= 0);\n\n\ttv = DUK_GET_TVAL_POSIDX(ctx, idx_src);\n\n#if defined(DUK_USE_FASTINT)\n\tif (DUK_TVAL_IS_FASTINT(tv)) {\n\t\tduk_int64_t v1, v2;\n\n\t\tv1 = DUK_TVAL_GET_FASTINT(tv);\n\t\tif (opcode == DUK_OP_UNM) {\n\t\t\t/* The smallest fastint is no longer 48-bit when\n\t\t\t * negated.  Positive zero becames negative zero\n\t\t\t * (cannot be represented) when negated.\n\t\t\t */\n\t\t\tif (DUK_LIKELY(v1 != DUK_FASTINT_MIN && v1 != 0)) {\n\t\t\t\tv2 = -v1;\n\t\t\t\ttv = DUK_GET_TVAL_POSIDX(ctx, idx_dst);\n\t\t\t\tDUK_TVAL_SET_FASTINT_UPDREF(thr, tv, v2);\n\t\t\t\treturn;\n\t\t\t}\n\t\t} else {\n\t\t\t/* ToNumber() for a fastint is a no-op. */\n\t\t\tDUK_ASSERT(opcode == DUK_OP_UNP);\n\t\t\tv2 = v1;\n\t\t\ttv = DUK_GET_TVAL_POSIDX(ctx, idx_dst);\n\t\t\tDUK_TVAL_SET_FASTINT_UPDREF(thr, tv, v2);\n\t\t\treturn;\n\t\t}\n\t\t/* fall through if overflow etc */\n\t}\n#endif  /* DUK_USE_FASTINT */\n\n\tif (DUK_TVAL_IS_NUMBER(tv)) {\n\t\td1 = DUK_TVAL_GET_NUMBER(tv);\n\t} else {\n\t\td1 = duk_to_number(ctx, idx_src);  /* side effects, perform in-place */\n\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(DUK_GET_TVAL_POSIDX(ctx, idx_src)));\n\t}\n\n\tif (opcode == DUK_OP_UNP) {\n\t\t/* ToNumber() for a double is a no-op, but unary plus is\n\t\t * used to force a fastint check so do that here.\n\t\t */\n\t\tdu.d = d1;\n\t\tDUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du));\n#if defined(DUK_USE_FASTINT)\n\t\ttv = DUK_GET_TVAL_POSIDX(ctx, idx_dst);\n\t\tDUK_TVAL_SET_NUMBER_CHKFAST_UPDREF(thr, tv, du.d);  /* always 'fast', i.e. inlined */\n\t\treturn;\n#endif\n\t} else {\n\t\tDUK_ASSERT(opcode == DUK_OP_UNM);\n\t\tdu.d = -d1;\n\t\tDUK_DBLUNION_NORMALIZE_NAN_CHECK(&du);  /* mandatory if du.d is a NaN */\n\t\tDUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du));\n\t}\n\n\t/* XXX: size optimize: push+replace? */\n\ttv = DUK_GET_TVAL_POSIDX(ctx, idx_dst);\n\tDUK_TVAL_SET_NUMBER_UPDREF(thr, tv, du.d);\n}\n\nDUK_LOCAL DUK__INLINE_PERF void duk__vm_bitwise_not(duk_hthread *thr, duk_uint_fast_t idx_src, duk_uint_fast_t idx_dst) {\n\t/*\n\t *  E5 Section 11.4.8\n\t */\n\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_tval *tv;\n\tduk_int32_t i1, i2;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT_DISABLE(idx_src >= 0);\n\tDUK_ASSERT_DISABLE(idx_dst >= 0);\n\tDUK_ASSERT((duk_uint_t) idx_src < (duk_uint_t) duk_get_top(ctx));\n\tDUK_ASSERT((duk_uint_t) idx_dst < (duk_uint_t) duk_get_top(ctx));\n\tDUK_UNREF(thr);  /* w/o refcounts */\n\n\ttv = DUK_GET_TVAL_POSIDX(ctx, idx_src);\n\n#if defined(DUK_USE_FASTINT)\n\tif (DUK_TVAL_IS_FASTINT(tv)) {\n\t\ti1 = (duk_int32_t) DUK_TVAL_GET_FASTINT_I32(tv);\n\t}\n\telse\n#endif  /* DUK_USE_FASTINT */\n\t{\n\t\ti1 = duk_to_int32(ctx, idx_src);  /* side effects */\n\t}\n\n\t/* Result is always fastint compatible. */\n\ti2 = ~i1;\n\ttv = DUK_GET_TVAL_POSIDX(ctx, idx_dst);\n\tDUK_TVAL_SET_I32_UPDREF(thr, tv, i2);  /* side effects */\n}\n\nDUK_LOCAL DUK__INLINE_PERF void duk__vm_logical_not(duk_hthread *thr, duk_idx_t idx_src, duk_idx_t idx_dst) {\n\t/*\n\t *  E5 Section 11.4.9\n\t */\n\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_tval *tv;\n\tduk_bool_t res;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT_DISABLE(idx_src >= 0);\n\tDUK_ASSERT_DISABLE(idx_dst >= 0);\n\tDUK_ASSERT((duk_uint_t) idx_src < (duk_uint_t) duk_get_top(ctx));\n\tDUK_ASSERT((duk_uint_t) idx_dst < (duk_uint_t) duk_get_top(ctx));\n\tDUK_UNREF(thr);  /* w/o refcounts */\n\n\t/* ToBoolean() does not require any operations with side effects so\n\t * we can do it efficiently.  For footprint it would be better to use\n\t * duk_js_toboolean() and then push+replace to the result slot.\n\t */\n\ttv = DUK_GET_TVAL_POSIDX(ctx, idx_src);\n\tres = duk_js_toboolean(tv);  /* does not modify 'tv' */\n\tDUK_ASSERT(res == 0 || res == 1);\n\tres ^= 1;\n\ttv = DUK_GET_TVAL_POSIDX(ctx, idx_dst);\n\t/* XXX: size optimize: push+replace? */\n\tDUK_TVAL_SET_BOOLEAN_UPDREF(thr, tv, res);  /* side effects */\n}\n\n/* XXX: size optimized variant */\nDUK_LOCAL DUK__INLINE_PERF void duk__prepost_incdec_reg_helper(duk_hthread *thr, duk_tval *tv_dst, duk_tval *tv_src, duk_small_uint_t op) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_double_t x, y, z;\n\n\t/* Two lowest bits of opcode are used to distinguish\n\t * variants.  Bit 0 = inc(0)/dec(1), bit 1 = pre(0)/post(1).\n\t */\n\tDUK_ASSERT((DUK_OP_PREINCR & 0x03) == 0x00);\n\tDUK_ASSERT((DUK_OP_PREDECR & 0x03) == 0x01);\n\tDUK_ASSERT((DUK_OP_POSTINCR & 0x03) == 0x02);\n\tDUK_ASSERT((DUK_OP_POSTDECR & 0x03) == 0x03);\n\n#if defined(DUK_USE_FASTINT)\n\tif (DUK_TVAL_IS_FASTINT(tv_src)) {\n\t\tduk_int64_t x_fi, y_fi, z_fi;\n\t\tx_fi = DUK_TVAL_GET_FASTINT(tv_src);\n\t\tif (op & 0x01) {\n\t\t\tif (DUK_UNLIKELY(x_fi == DUK_FASTINT_MIN)) {\n\t\t\t\tgoto skip_fastint;\n\t\t\t}\n\t\t\ty_fi = x_fi - 1;\n\t\t} else {\n\t\t\tif (DUK_UNLIKELY(x_fi == DUK_FASTINT_MAX)) {\n\t\t\t\tgoto skip_fastint;\n\t\t\t}\n\t\t\ty_fi = x_fi + 1;\n\t\t}\n\n\t\tDUK_TVAL_SET_FASTINT(tv_src, y_fi);  /* no need for refcount update */\n\n\t\tz_fi = (op & 0x02) ? x_fi : y_fi;\n\t\tDUK_TVAL_SET_FASTINT_UPDREF(thr, tv_dst, z_fi);  /* side effects */\n\t\treturn;\n\t}\n skip_fastint:\n#endif\n\tif (DUK_TVAL_IS_NUMBER(tv_src)) {\n\t\t/* Fast path for the case where the register\n\t\t * is a number (e.g. loop counter).\n\t\t */\n\n\t\tx = DUK_TVAL_GET_NUMBER(tv_src);\n\t\tif (op & 0x01) {\n\t\t\ty = x - 1.0;\n\t\t} else {\n\t\t\ty = x + 1.0;\n\t\t}\n\n\t\tDUK_TVAL_SET_NUMBER(tv_src, y);  /* no need for refcount update */\n\t} else {\n\t\t/* Preserve duk_tval pointer(s) across a potential valstack\n\t\t * resize by converting them into offsets temporarily.\n\t\t */\n\t\tduk_idx_t bc;\n\t\tduk_size_t off_dst;\n\n\t\toff_dst = (duk_size_t) ((duk_uint8_t *) tv_dst - (duk_uint8_t *) thr->valstack_bottom);\n\t\tbc = (duk_idx_t) (tv_src - thr->valstack_bottom);  /* XXX: pass index explicitly? */\n\t\ttv_src = NULL;  /* no longer referenced */\n\n\t\tx = duk_to_number(ctx, bc);\n\t\tif (op & 0x01) {\n\t\t\ty = x - 1.0;\n\t\t} else {\n\t\t\ty = x + 1.0;\n\t\t}\n\n\t\tduk_push_number(ctx, y);\n\t\tduk_replace(ctx, bc);\n\n\t\ttv_dst = (duk_tval *) (void *) (((duk_uint8_t *) thr->valstack_bottom) + off_dst);\n\t}\n\n\tz = (op & 0x02) ? x : y;\n\tDUK_TVAL_SET_NUMBER_UPDREF(thr, tv_dst, z);  /* side effects */\n}\n\nDUK_LOCAL DUK__INLINE_PERF void duk__prepost_incdec_var_helper(duk_hthread *thr, duk_small_uint_t idx_dst, duk_tval *tv_id, duk_small_uint_t op, duk_uint_t is_strict) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_activation *act;\n\tduk_double_t x, y;\n\tduk_hstring *name;\n\n\t/* XXX: The pre/post inc/dec for an identifier lookup is\n\t * missing the important fast path where the identifier\n\t * has a storage location e.g. in a scope object so that\n\t * it can be updated in-place.  In particular, the case\n\t * where the identifier has a storage location AND the\n\t * previous value is a number should be optimized because\n\t * it's side effect free.\n\t */\n\n\t/* Two lowest bits of opcode are used to distinguish\n\t * variants.  Bit 0 = inc(0)/dec(1), bit 1 = pre(0)/post(1).\n\t */\n\tDUK_ASSERT((DUK_OP_PREINCV & 0x03) == 0x00);\n\tDUK_ASSERT((DUK_OP_PREDECV & 0x03) == 0x01);\n\tDUK_ASSERT((DUK_OP_POSTINCV & 0x03) == 0x02);\n\tDUK_ASSERT((DUK_OP_POSTDECV & 0x03) == 0x03);\n\n\tDUK_ASSERT(DUK_TVAL_IS_STRING(tv_id));\n\tname = DUK_TVAL_GET_STRING(tv_id);\n\tDUK_ASSERT(name != NULL);\n\tact = thr->callstack_curr;\n\t(void) duk_js_getvar_activation(thr, act, name, 1 /*throw*/);  /* -> [ ... val this ] */\n\n\t/* XXX: Fastint fast path would be useful here.  Also fastints\n\t * now lose their fastint status in current handling which is\n\t * not intuitive.\n\t */\n\n\tx = duk_to_number_m2(ctx);\n\tif (op & 0x01) {\n\t\ty = x - 1.0;\n\t} else {\n\t\ty = x + 1.0;\n\t}\n\n\t/* [... x this] */\n\n\tif (op & 0x02) {\n\t\tduk_push_number(ctx, y);  /* -> [ ... x this y ] */\n\t\tact = thr->callstack_curr;\n\t\tduk_js_putvar_activation(thr, act, name, DUK_GET_TVAL_NEGIDX(ctx, -1), is_strict);\n\t\tduk_pop_2(ctx);  /* -> [ ... x ] */\n\t} else {\n\t\tduk_pop_2(ctx);  /* -> [ ... ] */\n\t\tduk_push_number(ctx, y);  /* -> [ ... y ] */\n\t\tact = thr->callstack_curr;\n\t\tduk_js_putvar_activation(thr, act, name, DUK_GET_TVAL_NEGIDX(ctx, -1), is_strict);\n\t}\n\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n\tduk_replace(ctx, (duk_idx_t) idx_dst);\n#else  /* DUK_USE_EXEC_PREFER_SIZE */\n\tDUK__REPLACE_TO_TVPTR(thr, DUK_GET_TVAL_POSIDX(ctx, idx_dst));\n#endif  /* DUK_USE_EXEC_PREFER_SIZE */\n}\n\n/*\n *  Longjmp and other control flow transfer for the bytecode executor.\n *\n *  The longjmp handler can handle all longjmp types: error, yield, and\n *  resume (pseudotypes are never actually thrown).\n *\n *  Error policy for longjmp: should not ordinarily throw errors; if errors\n *  occur (e.g. due to out-of-memory) they bubble outwards rather than being\n *  handled recursively.\n */\n\n#define DUK__LONGJMP_RESTART   0  /* state updated, restart bytecode execution */\n#define DUK__LONGJMP_RETHROW   1  /* exit bytecode executor by rethrowing an error to caller */\n\n#define DUK__RETHAND_RESTART   0  /* state updated, restart bytecode execution */\n#define DUK__RETHAND_FINISHED  1  /* exit bytecode execution with return value */\n\n/* XXX: optimize reconfig valstack operations so that resize, clamp, and setting\n * top are combined into one pass.\n */\n\n/* Reconfigure value stack for return to an Ecmascript function at 'act_idx'. */\nDUK_LOCAL void duk__reconfig_valstack_ecma_return(duk_hthread *thr, duk_size_t act_idx) {\n\tduk_activation *act;\n\tduk_hcompfunc *h_func;\n\tduk_idx_t clamp_top;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT_DISABLE(act_idx >= 0);  /* unsigned */\n\tDUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack + act_idx) != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack + act_idx)));\n\tDUK_ASSERT_DISABLE(thr->callstack[act_idx].idx_retval >= 0);  /* unsigned */\n\n\t/* Clamp so that values at 'clamp_top' and above are wiped and won't\n\t * retain reachable garbage.  Then extend to 'nregs' because we're\n\t * returning to an Ecmascript function.\n\t */\n\n\tact = thr->callstack + act_idx;\n\th_func = (duk_hcompfunc *) DUK_ACT_GET_FUNC(act);\n\n\tthr->valstack_bottom = thr->valstack + act->idx_bottom;\n\tDUK_ASSERT(act->idx_retval >= act->idx_bottom);\n\tclamp_top = (duk_idx_t) (act->idx_retval - act->idx_bottom + 1);  /* +1 = one retval */\n\tduk_set_top((duk_context *) thr, clamp_top);\n\tact = NULL;\n\n\t(void) duk_valstack_resize_raw((duk_context *) thr,\n\t                               (thr->valstack_bottom - thr->valstack) +  /* bottom of current func */\n\t                                   h_func->nregs +                       /* reg count */\n\t                                   DUK_VALSTACK_INTERNAL_EXTRA,          /* + spare */\n\t                               DUK_VSRESIZE_FLAG_SHRINK |                /* flags */\n\t                               0 /* no compact */ |\n\t                               DUK_VSRESIZE_FLAG_THROW);\n\n\tduk_set_top((duk_context *) thr, h_func->nregs);\n}\n\nDUK_LOCAL void duk__reconfig_valstack_ecma_catcher(duk_hthread *thr, duk_size_t act_idx, duk_size_t cat_idx) {\n\tduk_activation *act;\n\tduk_catcher *cat;\n\tduk_hcompfunc *h_func;\n\tduk_idx_t clamp_top;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT_DISABLE(act_idx >= 0);  /* unsigned */\n\tDUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack + act_idx) != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack + act_idx)));\n\tDUK_ASSERT_DISABLE(thr->callstack[act_idx].idx_retval >= 0);  /* unsigned */\n\n\tact = thr->callstack + act_idx;\n\tcat = thr->catchstack + cat_idx;\n\th_func = (duk_hcompfunc *) DUK_ACT_GET_FUNC(act);\n\n\tthr->valstack_bottom = thr->valstack + act->idx_bottom;\n\tDUK_ASSERT(cat->idx_base >= act->idx_bottom);\n\tclamp_top = (duk_idx_t) (cat->idx_base - act->idx_bottom + 2);  /* +2 = catcher value, catcher lj_type */\n\tduk_set_top((duk_context *) thr, clamp_top);\n\tact = NULL;\n\tcat = NULL;\n\n\t(void) duk_valstack_resize_raw((duk_context *) thr,\n\t                               (thr->valstack_bottom - thr->valstack) +  /* bottom of current func */\n\t                                   h_func->nregs +                       /* reg count */\n\t                                   DUK_VALSTACK_INTERNAL_EXTRA,          /* + spare */\n\t                               DUK_VSRESIZE_FLAG_SHRINK |                /* flags */\n\t                               0 /* no compact */ |\n\t                               DUK_VSRESIZE_FLAG_THROW);\n\n\tduk_set_top((duk_context *) thr, h_func->nregs);\n}\n\n/* Set catcher regs: idx_base+0 = value, idx_base+1 = lj_type. */\nDUK_LOCAL void duk__set_catcher_regs(duk_hthread *thr, duk_size_t cat_idx, duk_tval *tv_val_unstable, duk_small_uint_t lj_type) {\n\tduk_tval *tv1;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(tv_val_unstable != NULL);\n\n\ttv1 = thr->valstack + thr->catchstack[cat_idx].idx_base;\n\tDUK_ASSERT(tv1 < thr->valstack_top);\n\tDUK_TVAL_SET_TVAL_UPDREF(thr, tv1, tv_val_unstable);  /* side effects */\n\n\ttv1 = thr->valstack + thr->catchstack[cat_idx].idx_base + 1;\n\tDUK_ASSERT(tv1 < thr->valstack_top);\n\n\tDUK_TVAL_SET_U32_UPDREF(thr, tv1, (duk_uint32_t) lj_type);  /* side effects */\n}\n\nDUK_LOCAL void duk__handle_catch(duk_hthread *thr, duk_size_t cat_idx, duk_tval *tv_val_unstable, duk_small_uint_t lj_type) {\n\tduk_context *ctx;\n\tduk_activation *act;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(tv_val_unstable != NULL);\n\tctx = (duk_context *) thr;\n\n\tduk__set_catcher_regs(thr, cat_idx, tv_val_unstable, lj_type);\n\n\tduk_hthread_catchstack_unwind_norz(thr, cat_idx + 1);\n\tduk_hthread_callstack_unwind_norz(thr, thr->catchstack[cat_idx].callstack_index + 1);\n\n\tDUK_ASSERT(thr->callstack_top >= 1);\n\tDUK_ASSERT(thr->callstack_curr != NULL);\n\tDUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack_curr) != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr)));\n\n\tduk__reconfig_valstack_ecma_catcher(thr, thr->callstack_top - 1, cat_idx);\n\n\tDUK_ASSERT(thr->callstack_top >= 1);\n\tact = thr->callstack_curr;\n\tDUK_ASSERT(act != NULL);\n\tact->curr_pc = thr->catchstack[cat_idx].pc_base + 0;  /* +0 = catch */\n\tact = NULL;\n\n\t/*\n\t *  If entering a 'catch' block which requires an automatic\n\t *  catch variable binding, create the lexical environment.\n\t *\n\t *  The binding is mutable (= writable) but not deletable.\n\t *  Step 4 for the catch production in E5 Section 12.14;\n\t *  no value is given for CreateMutableBinding 'D' argument,\n\t *  which implies the binding is not deletable.\n\t */\n\n\tif (DUK_CAT_HAS_CATCH_BINDING_ENABLED(&thr->catchstack[cat_idx])) {\n\t\tduk_hdecenv *new_env;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"catcher has an automatic catch binding\"));\n\n\t\t/* Note: 'act' is dangerous here because it may get invalidate at many\n\t\t * points, so we re-lookup it multiple times.\n\t\t */\n\t\tDUK_ASSERT(thr->callstack_top >= 1);\n\t\tact = thr->callstack_curr;\n\t\tDUK_ASSERT(act != NULL);\n\n\t\tif (act->lex_env == NULL) {\n\t\t\tDUK_ASSERT(act->var_env == NULL);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"delayed environment initialization\"));\n\n\t\t\t/* this may have side effects, so re-lookup act */\n\t\t\tduk_js_init_activation_environment_records_delayed(thr, act);\n\t\t\tact = thr->callstack_curr;\n\t\t\tDUK_ASSERT(act != NULL);\n\t\t}\n\t\tDUK_ASSERT(act->lex_env != NULL);\n\t\tDUK_ASSERT(act->var_env != NULL);\n\t\tDUK_ASSERT(DUK_ACT_GET_FUNC(act) != NULL);\n\t\tDUK_UNREF(act);  /* unreferenced without assertions */\n\n\t\t/* XXX: If an out-of-memory happens here, longjmp state asserts\n\t\t * will be triggered at present and a try-catch fails to catch.\n\t\t * That's not sandboxing fatal (C API protected calls are what\n\t\t * matters), and script catch code can immediately throw anyway\n\t\t * for almost any operation.\n\t\t */\n\t\tnew_env = duk_hdecenv_alloc(thr,\n\t\t                            DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t\t                            DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_DECENV));\n\t\tDUK_ASSERT(new_env != NULL);\n\t\tduk_push_hobject(ctx, (duk_hobject *) new_env);\n\t\tDUK_ASSERT(DUK_HOBJECT_GET_PROTOTYPE(thr->heap, (duk_hobject *) new_env) == NULL);\n\t\tDUK_DDD(DUK_DDDPRINT(\"new_env allocated: %!iO\", (duk_heaphdr *) new_env));\n\n\t\t/* Note: currently the catch binding is handled without a register\n\t\t * binding because we don't support dynamic register bindings (they\n\t\t * must be fixed for an entire function).  So, there is no need to\n\t\t * record regbases etc.\n\t\t */\n\n\t\t/* XXX: duk_xdef_prop() may cause an out-of-memory, see above. */\n\t\tDUK_ASSERT(thr->catchstack[cat_idx].h_varname != NULL);\n\t\tduk_push_hstring(ctx, thr->catchstack[cat_idx].h_varname);\n\t\tduk_push_tval(ctx, thr->valstack + thr->catchstack[cat_idx].idx_base);\n\t\tduk_xdef_prop(ctx, -3, DUK_PROPDESC_FLAGS_W);  /* writable, not configurable */\n\n\t\tact = thr->callstack_curr;\n\t\tDUK_ASSERT(act != NULL);\n\t\tDUK_HOBJECT_SET_PROTOTYPE(thr->heap, (duk_hobject *) new_env, act->lex_env);\n\t\tact->lex_env = (duk_hobject *) new_env;\n\t\tDUK_HOBJECT_INCREF(thr, (duk_hobject *) new_env);  /* reachable through activation */\n\t\t/* Net refcount change to act->lex_env is 0: incref for new_env's\n\t\t * prototype, decref for act->lex_env overwrite.\n\t\t */\n\n\t\tDUK_CAT_SET_LEXENV_ACTIVE(&thr->catchstack[cat_idx]);\n\n\t\tduk_pop(ctx);\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"new_env finished: %!iO\", (duk_heaphdr *) new_env));\n\t}\n\n\tDUK_CAT_CLEAR_CATCH_ENABLED(&thr->catchstack[cat_idx]);\n}\n\nDUK_LOCAL void duk__handle_finally(duk_hthread *thr, duk_size_t cat_idx, duk_tval *tv_val_unstable, duk_small_uint_t lj_type) {\n\tduk_activation *act;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(tv_val_unstable != NULL);\n\n\tduk__set_catcher_regs(thr, cat_idx, tv_val_unstable, lj_type);\n\n\tduk_hthread_catchstack_unwind_norz(thr, cat_idx + 1);  /* cat_idx catcher is kept, even for finally */\n\tduk_hthread_callstack_unwind_norz(thr, thr->catchstack[cat_idx].callstack_index + 1);\n\n\tDUK_ASSERT(thr->callstack_top >= 1);\n\tDUK_ASSERT(thr->callstack_curr != NULL);\n\tDUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack_curr) != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr)));\n\n\tduk__reconfig_valstack_ecma_catcher(thr, thr->callstack_top - 1, cat_idx);\n\n\tDUK_ASSERT(thr->callstack_top >= 1);\n\tact = thr->callstack_curr;\n\tDUK_ASSERT(act != NULL);\n\tact->curr_pc = thr->catchstack[cat_idx].pc_base + 1;  /* +1 = finally */\n\tact = NULL;\n\n\tDUK_CAT_CLEAR_FINALLY_ENABLED(&thr->catchstack[cat_idx]);\n}\n\nDUK_LOCAL void duk__handle_label(duk_hthread *thr, duk_size_t cat_idx, duk_small_uint_t lj_type) {\n\tduk_activation *act;\n\n\tDUK_ASSERT(thr != NULL);\n\n\tDUK_ASSERT(thr->callstack_top >= 1);\n\tact = thr->callstack_curr;\n\tDUK_ASSERT(act != NULL);\n\n\tDUK_ASSERT(DUK_ACT_GET_FUNC(act) != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_HAS_COMPFUNC(DUK_ACT_GET_FUNC(act)));\n\n\t/* +0 = break, +1 = continue */\n\tact->curr_pc = thr->catchstack[cat_idx].pc_base + (lj_type == DUK_LJ_TYPE_CONTINUE ? 1 : 0);\n\tact = NULL;  /* invalidated */\n\n\tduk_hthread_catchstack_unwind_norz(thr, cat_idx + 1);  /* keep label catcher */\n\t/* no need to unwind callstack */\n\n\t/* valstack should not need changes */\n#if defined(DUK_USE_ASSERTIONS)\n\tDUK_ASSERT(thr->callstack_top >= 1);\n\tact = thr->callstack_curr;\n\tDUK_ASSERT(act != NULL);\n\tDUK_ASSERT((duk_size_t) (thr->valstack_top - thr->valstack_bottom) ==\n\t           (duk_size_t) ((duk_hcompfunc *) DUK_ACT_GET_FUNC(act))->nregs);\n#endif\n}\n\n/* Called for handling both a longjmp() with type DUK_LJ_TYPE_YIELD and\n * when a RETURN opcode terminates a thread and yields to the resumer.\n */\n#if defined(DUK_USE_COROUTINE_SUPPORT)\nDUK_LOCAL void duk__handle_yield(duk_hthread *thr, duk_hthread *resumer, duk_size_t act_idx, duk_tval *tv_val_unstable) {\n\tduk_tval *tv1;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(resumer != NULL);\n\tDUK_ASSERT(tv_val_unstable != NULL);\n\tDUK_ASSERT(DUK_ACT_GET_FUNC(resumer->callstack + act_idx) != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(resumer->callstack + act_idx)));  /* resume caller must be an ecmascript func */\n\n\ttv1 = resumer->valstack + resumer->callstack[act_idx].idx_retval;  /* return value from Duktape.Thread.resume() */\n\tDUK_TVAL_SET_TVAL_UPDREF(thr, tv1, tv_val_unstable);  /* side effects */\n\n\tduk_hthread_callstack_unwind_norz(resumer, act_idx + 1);  /* unwind to 'resume' caller */\n\n\t/* no need to unwind catchstack */\n\tduk__reconfig_valstack_ecma_return(resumer, act_idx);\n\n\t/* caller must change active thread, and set thr->resumer to NULL */\n}\n#endif  /* DUK_USE_COROUTINE_SUPPORT */\n\nDUK_LOCAL\nduk_small_uint_t duk__handle_longjmp(duk_hthread *thr,\n                                     duk_hthread *entry_thread,\n                                     duk_size_t entry_callstack_top) {\n\tduk_size_t entry_callstack_index;\n\tduk_small_uint_t retval = DUK__LONGJMP_RESTART;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(entry_thread != NULL);\n\tDUK_ASSERT(entry_callstack_top > 0);  /* guarantees entry_callstack_top - 1 >= 0 */\n\n\tentry_callstack_index = entry_callstack_top - 1;\n\n\t/* 'thr' is the current thread, as no-one resumes except us and we\n\t * switch 'thr' in that case.\n\t */\n\tDUK_ASSERT(thr == thr->heap->curr_thread);\n\n\t/*\n\t *  (Re)try handling the longjmp.\n\t *\n\t *  A longjmp handler may convert the longjmp to a different type and\n\t *  \"virtually\" rethrow by goto'ing to 'check_longjmp'.  Before the goto,\n\t *  the following must be updated:\n\t *    - the heap 'lj' state\n\t *    - 'thr' must reflect the \"throwing\" thread\n\t */\n\n check_longjmp:\n\n\tDUK_DD(DUK_DDPRINT(\"handling longjmp: type=%ld, value1=%!T, value2=%!T, iserror=%ld\",\n\t                   (long) thr->heap->lj.type,\n\t                   (duk_tval *) &thr->heap->lj.value1,\n\t                   (duk_tval *) &thr->heap->lj.value2,\n\t                   (long) thr->heap->lj.iserror));\n\n\tswitch (thr->heap->lj.type) {\n\n#if defined(DUK_USE_COROUTINE_SUPPORT)\n\tcase DUK_LJ_TYPE_RESUME: {\n\t\t/*\n\t\t *  Note: lj.value1 is 'value', lj.value2 is 'resumee'.\n\t\t *  This differs from YIELD.\n\t\t */\n\n\t\tduk_tval *tv;\n\t\tduk_tval *tv2;\n\t\tduk_size_t act_idx;\n\t\tduk_hthread *resumee;\n\n\t\t/* duk_bi_duk_object_yield() and duk_bi_duk_object_resume() ensure all of these are met */\n\n\t\tDUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING);                                                         /* unchanged by Duktape.Thread.resume() */\n\t\tDUK_ASSERT(thr->callstack_top >= 2);                                                                         /* Ecmascript activation + Duktape.Thread.resume() activation */\n\t\tDUK_ASSERT(thr->callstack_curr != NULL);\n\t\tDUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack_curr) != NULL &&\n\t\t           DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr)) &&\n\t\t           ((duk_hnatfunc *) DUK_ACT_GET_FUNC(thr->callstack_curr))->func == duk_bi_thread_resume);\n\t\tDUK_ASSERT_DISABLE((thr->callstack_curr - 1)->idx_retval >= 0);                                              /* unsigned */\n\n\t\ttv = &thr->heap->lj.value2;  /* resumee */\n\t\tDUK_ASSERT(DUK_TVAL_IS_OBJECT(tv));\n\t\tDUK_ASSERT(DUK_TVAL_GET_OBJECT(tv) != NULL);\n\t\tDUK_ASSERT(DUK_HOBJECT_IS_THREAD(DUK_TVAL_GET_OBJECT(tv)));\n\t\tresumee = (duk_hthread *) DUK_TVAL_GET_OBJECT(tv);\n\n\t\tDUK_ASSERT(resumee != NULL);\n\t\tDUK_ASSERT(resumee->resumer == NULL);\n\t\tDUK_ASSERT(resumee->state == DUK_HTHREAD_STATE_INACTIVE ||\n\t\t           resumee->state == DUK_HTHREAD_STATE_YIELDED);                                                     /* checked by Duktape.Thread.resume() */\n\t\tDUK_ASSERT(resumee->state != DUK_HTHREAD_STATE_YIELDED ||\n\t\t           resumee->callstack_top >= 2);                                                                     /* YIELDED: Ecmascript activation + Duktape.Thread.yield() activation */\n\t\tDUK_ASSERT(resumee->state != DUK_HTHREAD_STATE_YIELDED ||\n\t\t           (DUK_ACT_GET_FUNC(resumee->callstack_curr) != NULL &&\n\t\t            DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(resumee->callstack_curr)) &&\n\t\t            ((duk_hnatfunc *) DUK_ACT_GET_FUNC(resumee->callstack_curr))->func == duk_bi_thread_yield));\n\t\tDUK_ASSERT_DISABLE(resumee->state != DUK_HTHREAD_STATE_YIELDED ||\n\t\t           (resumee->callstack_curr - 1)->idx_retval >= 0);                                                  /* idx_retval unsigned */\n\t\tDUK_ASSERT(resumee->state != DUK_HTHREAD_STATE_INACTIVE ||\n\t\t           resumee->callstack_top == 0);                                                                     /* INACTIVE: no activation, single function value on valstack */\n\n\t\tif (thr->heap->lj.iserror) {\n\t\t\t/*\n\t\t\t *  Throw the error in the resumed thread's context; the\n\t\t\t *  error value is pushed onto the resumee valstack.\n\t\t\t *\n\t\t\t *  Note: the callstack of the target may empty in this case\n\t\t\t *  too (i.e. the target thread has never been resumed).  The\n\t\t\t *  value stack will contain the initial function in that case,\n\t\t\t *  which we simply ignore.\n\t\t\t */\n\n\t\t\tDUK_ASSERT(resumee->resumer == NULL);\n\t\t\tresumee->resumer = thr;\n\t\t\tDUK_HTHREAD_INCREF(thr, thr);\n\t\t\tresumee->state = DUK_HTHREAD_STATE_RUNNING;\n\t\t\tthr->state = DUK_HTHREAD_STATE_RESUMED;\n\t\t\tDUK_HEAP_SWITCH_THREAD(thr->heap, resumee);\n\t\t\tthr = resumee;\n\n\t\t\tthr->heap->lj.type = DUK_LJ_TYPE_THROW;\n\n\t\t\t/* thr->heap->lj.value1 is already the value to throw */\n\t\t\t/* thr->heap->lj.value2 is 'thread', will be wiped out at the end */\n\n\t\t\tDUK_ASSERT(thr->heap->lj.iserror);  /* already set */\n\n\t\t\tDUK_DD(DUK_DDPRINT(\"-> resume with an error, converted to a throw in the resumee, propagate\"));\n\t\t\tgoto check_longjmp;\n\t\t} else if (resumee->state == DUK_HTHREAD_STATE_YIELDED) {\n\t\t\tact_idx = resumee->callstack_top - 2;  /* Ecmascript function */\n\t\t\tDUK_ASSERT_DISABLE(resumee->callstack[act_idx].idx_retval >= 0);  /* unsigned */\n\n\t\t\ttv = resumee->valstack + resumee->callstack[act_idx].idx_retval;  /* return value from Duktape.Thread.yield() */\n\t\t\tDUK_ASSERT(tv >= resumee->valstack && tv < resumee->valstack_top);\n\t\t\ttv2 = &thr->heap->lj.value1;\n\t\t\tDUK_TVAL_SET_TVAL_UPDREF(thr, tv, tv2);  /* side effects */\n\n\t\t\tduk_hthread_callstack_unwind_norz(resumee, act_idx + 1);  /* unwind to 'yield' caller */\n\n\t\t\t/* no need to unwind catchstack */\n\n\t\t\tduk__reconfig_valstack_ecma_return(resumee, act_idx);\n\n\t\t\tDUK_ASSERT(resumee->resumer == NULL);\n\t\t\tresumee->resumer = thr;\n\t\t\tDUK_HTHREAD_INCREF(thr, thr);\n\t\t\tresumee->state = DUK_HTHREAD_STATE_RUNNING;\n\t\t\tthr->state = DUK_HTHREAD_STATE_RESUMED;\n\t\t\tDUK_HEAP_SWITCH_THREAD(thr->heap, resumee);\n#if 0\n\t\t\tthr = resumee;  /* not needed, as we exit right away */\n#endif\n\t\t\tDUK_DD(DUK_DDPRINT(\"-> resume with a value, restart execution in resumee\"));\n\t\t\tretval = DUK__LONGJMP_RESTART;\n\t\t\tgoto wipe_and_return;\n\t\t} else {\n\t\t\tduk_small_uint_t call_flags;\n\t\t\tduk_bool_t setup_rc;\n\n\t\t\t/* resumee: [... initial_func]  (currently actually: [initial_func]) */\n\n\t\t\tduk_push_undefined((duk_context *) resumee);\n\t\t\ttv = &thr->heap->lj.value1;\n\t\t\tduk_push_tval((duk_context *) resumee, tv);\n\n\t\t\t/* resumee: [... initial_func undefined(= this) resume_value ] */\n\n\t\t\tcall_flags = DUK_CALL_FLAG_IS_RESUME;  /* is resume, not a tail call */\n\n\t\t\tsetup_rc = duk_handle_ecma_call_setup(resumee,\n\t\t\t                                      1,              /* num_stack_args */\n\t\t\t                                      call_flags);    /* call_flags */\n\t\t\tif (setup_rc == 0) {\n\t\t\t\t/* This shouldn't happen; Duktape.Thread.resume()\n\t\t\t\t * should make sure of that.  If it does happen\n\t\t\t\t * this internal error will propagate out of the\n\t\t\t\t * executor which can be quite misleading.\n\t\t\t\t */\n\t\t\t\tDUK_ERROR_INTERNAL(thr);\n\t\t\t}\n\n\t\t\tDUK_ASSERT(resumee->resumer == NULL);\n\t\t\tresumee->resumer = thr;\n\t\t\tDUK_HTHREAD_INCREF(thr, thr);\n\t\t\tresumee->state = DUK_HTHREAD_STATE_RUNNING;\n\t\t\tthr->state = DUK_HTHREAD_STATE_RESUMED;\n\t\t\tDUK_HEAP_SWITCH_THREAD(thr->heap, resumee);\n#if 0\n\t\t\tthr = resumee;  /* not needed, as we exit right away */\n#endif\n\t\t\tDUK_DD(DUK_DDPRINT(\"-> resume with a value, restart execution in resumee\"));\n\t\t\tretval = DUK__LONGJMP_RESTART;\n\t\t\tgoto wipe_and_return;\n\t\t}\n\t\tDUK_UNREACHABLE();\n\t\tbreak;  /* never here */\n\t}\n\n\tcase DUK_LJ_TYPE_YIELD: {\n\t\t/*\n\t\t *  Currently only allowed only if yielding thread has only\n\t\t *  Ecmascript activations (except for the Duktape.Thread.yield()\n\t\t *  call at the callstack top) and none of them constructor\n\t\t *  calls.\n\t\t *\n\t\t *  This excludes the 'entry' thread which will always have\n\t\t *  a preventcount > 0.\n\t\t */\n\n\t\tduk_hthread *resumer;\n\n\t\t/* duk_bi_duk_object_yield() and duk_bi_duk_object_resume() ensure all of these are met */\n\n\t\tDUK_ASSERT(thr != entry_thread);                                                                             /* Duktape.Thread.yield() should prevent */\n\t\tDUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING);                                                         /* unchanged from Duktape.Thread.yield() */\n\t\tDUK_ASSERT(thr->callstack_top >= 2);                                                                         /* Ecmascript activation + Duktape.Thread.yield() activation */\n\t\tDUK_ASSERT(thr->callstack_curr != NULL);\n\t\tDUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack_curr) != NULL &&\n\t\t           DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr)) &&\n\t\t           ((duk_hnatfunc *) DUK_ACT_GET_FUNC(thr->callstack_curr))->func == duk_bi_thread_yield);\n\t\tDUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack_curr - 1) != NULL &&\n\t\t           DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr - 1)));                              /* an Ecmascript function */\n\t\tDUK_ASSERT_DISABLE((thr->callstack_curr - 1)->idx_retval >= 0);                                              /* unsigned */\n\n\t\tresumer = thr->resumer;\n\n\t\tDUK_ASSERT(resumer != NULL);\n\t\tDUK_ASSERT(resumer->state == DUK_HTHREAD_STATE_RESUMED);                                                     /* written by a previous RESUME handling */\n\t\tDUK_ASSERT(resumer->callstack_top >= 2);                                                                     /* Ecmascript activation + Duktape.Thread.resume() activation */\n\t\tDUK_ASSERT(resumer->callstack_curr != NULL);\n\t\tDUK_ASSERT(DUK_ACT_GET_FUNC(resumer->callstack_curr) != NULL &&\n\t\t           DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(resumer->callstack_curr)) &&\n\t\t           ((duk_hnatfunc *) DUK_ACT_GET_FUNC(resumer->callstack_curr))->func == duk_bi_thread_resume);\n\t\tDUK_ASSERT(DUK_ACT_GET_FUNC(resumer->callstack_curr - 1) != NULL &&\n\t\t           DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(resumer->callstack_curr - 1)));                            /* an Ecmascript function */\n\t\tDUK_ASSERT_DISABLE((resumer->callstack_curr - 1)->idx_retval >= 0);                                            /* unsigned */\n\n\t\tif (thr->heap->lj.iserror) {\n\t\t\tthr->state = DUK_HTHREAD_STATE_YIELDED;\n\t\t\tthr->resumer = NULL;\n\t\t\tDUK_HTHREAD_DECREF_NORZ(thr, resumer);\n\t\t\tresumer->state = DUK_HTHREAD_STATE_RUNNING;\n\t\t\tDUK_HEAP_SWITCH_THREAD(thr->heap, resumer);\n\t\t\tthr = resumer;\n\n\t\t\tthr->heap->lj.type = DUK_LJ_TYPE_THROW;\n\t\t\t/* lj.value1 is already set */\n\t\t\tDUK_ASSERT(thr->heap->lj.iserror);  /* already set */\n\n\t\t\tDUK_DD(DUK_DDPRINT(\"-> yield an error, converted to a throw in the resumer, propagate\"));\n\t\t\tgoto check_longjmp;\n\t\t} else {\n\t\t\tduk__handle_yield(thr, resumer, resumer->callstack_top - 2, &thr->heap->lj.value1);\n\n\t\t\tthr->state = DUK_HTHREAD_STATE_YIELDED;\n\t\t\tthr->resumer = NULL;\n\t\t\tDUK_HTHREAD_DECREF_NORZ(thr, resumer);\n\t\t\tresumer->state = DUK_HTHREAD_STATE_RUNNING;\n\t\t\tDUK_HEAP_SWITCH_THREAD(thr->heap, resumer);\n#if 0\n\t\t\tthr = resumer;  /* not needed, as we exit right away */\n#endif\n\n\t\t\tDUK_DD(DUK_DDPRINT(\"-> yield a value, restart execution in resumer\"));\n\t\t\tretval = DUK__LONGJMP_RESTART;\n\t\t\tgoto wipe_and_return;\n\t\t}\n\t\tDUK_UNREACHABLE();\n\t\tbreak;  /* never here */\n\t}\n#endif  /* DUK_USE_COROUTINE_SUPPORT */\n\n\tcase DUK_LJ_TYPE_THROW: {\n\t\t/*\n\t\t *  Three possible outcomes:\n\t\t *    * A try or finally catcher is found => resume there.\n\t\t *      (or)\n\t\t *    * The error propagates to the bytecode executor entry\n\t\t *      level (and we're in the entry thread) => rethrow\n\t\t *      with a new longjmp(), after restoring the previous\n\t\t *      catchpoint.\n\t\t *    * The error is not caught in the current thread, so\n\t\t *      the thread finishes with an error.  This works like\n\t\t *      a yielded error, except that the thread is finished\n\t\t *      and can no longer be resumed.  (There is always a\n\t\t *      resumer in this case.)\n\t\t *\n\t\t *  Note: until we hit the entry level, there can only be\n\t\t *  Ecmascript activations.\n\t\t */\n\n\t\tduk_catcher *cat;\n\t\tduk_hthread *resumer;\n\n\t\tcat = thr->catchstack + thr->catchstack_top - 1;\n\t\twhile (cat >= thr->catchstack) {\n\t\t\tif (thr == entry_thread &&\n\t\t\t    cat->callstack_index < entry_callstack_index) {\n\t\t\t\t/* entry level reached */\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif (DUK_CAT_HAS_CATCH_ENABLED(cat)) {\n\t\t\t\tDUK_ASSERT(DUK_CAT_GET_TYPE(cat) == DUK_CAT_TYPE_TCF);\n\n\t\t\t\tduk__handle_catch(thr,\n\t\t\t\t                  cat - thr->catchstack,\n\t\t\t\t                  &thr->heap->lj.value1,\n\t\t\t\t                  DUK_LJ_TYPE_THROW);\n\n\t\t\t\tDUK_DD(DUK_DDPRINT(\"-> throw caught by a 'catch' clause, restart execution\"));\n\t\t\t\tretval = DUK__LONGJMP_RESTART;\n\t\t\t\tgoto wipe_and_return;\n\t\t\t}\n\n\t\t\tif (DUK_CAT_HAS_FINALLY_ENABLED(cat)) {\n\t\t\t\tDUK_ASSERT(DUK_CAT_GET_TYPE(cat) == DUK_CAT_TYPE_TCF);\n\t\t\t\tDUK_ASSERT(!DUK_CAT_HAS_CATCH_ENABLED(cat));\n\n\t\t\t\tduk__handle_finally(thr,\n\t\t\t\t                    cat - thr->catchstack,\n\t\t\t\t                    &thr->heap->lj.value1,\n\t\t\t\t                    DUK_LJ_TYPE_THROW);\n\n\t\t\t\tDUK_DD(DUK_DDPRINT(\"-> throw caught by a 'finally' clause, restart execution\"));\n\t\t\t\tretval = DUK__LONGJMP_RESTART;\n\t\t\t\tgoto wipe_and_return;\n\t\t\t}\n\n\t\t\tcat--;\n\t\t}\n\n\t\tif (thr == entry_thread) {\n\t\t\t/* not caught by anything before entry level; rethrow and let the\n\t\t\t * final catcher unwind everything\n\t\t\t */\n#if 0\n\t\t\tduk_hthread_catchstack_unwind_norz(thr, (cat - thr->catchstack) + 1);  /* leave 'cat' as top catcher (also works if catchstack exhausted) */\n\t\t\tduk_hthread_callstack_unwind_norz(thr, entry_callstack_index + 1);\n\t\t\tDUK_REFZERO_CHECK_SLOW(thr);\n#endif\n\t\t\tDUK_D(DUK_DPRINT(\"-> throw propagated up to entry level, rethrow and exit bytecode executor\"));\n\t\t\tretval = DUK__LONGJMP_RETHROW;\n\t\t\tgoto just_return;\n\t\t\t/* Note: MUST NOT wipe_and_return here, as heap->lj must remain intact */\n\t\t}\n\n\t\tDUK_DD(DUK_DDPRINT(\"-> throw not caught by current thread, yield error to resumer and recheck longjmp\"));\n\n\t\t/* not caught by current thread, thread terminates (yield error to resumer);\n\t\t * note that this may cause a cascade if the resumer terminates with an uncaught\n\t\t * exception etc (this is OK, but needs careful testing)\n\t\t */\n\n\t\tDUK_ASSERT(thr->resumer != NULL);\n\t\tDUK_ASSERT(thr->resumer->callstack_top >= 2);  /* Ecmascript activation + Duktape.Thread.resume() activation */\n\t\tDUK_ASSERT(thr->resumer->callstack_curr != NULL);\n\t\tDUK_ASSERT(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr) != NULL &&\n\t\t           DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr)) &&\n\t\t           ((duk_hnatfunc *) DUK_ACT_GET_FUNC(thr->resumer->callstack_curr))->func == duk_bi_thread_resume);  /* Duktape.Thread.resume() */\n\t\tDUK_ASSERT(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr - 1) != NULL &&\n\t\t           DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr - 1)));  /* an Ecmascript function */\n\n\t\tresumer = thr->resumer;\n\n\t\t/* reset longjmp */\n\n\t\tDUK_ASSERT(thr->heap->lj.type == DUK_LJ_TYPE_THROW);  /* already set */\n\t\t/* lj.value1 already set */\n\n\t\tduk_hthread_terminate(thr);  /* updates thread state, minimizes its allocations */\n\t\tDUK_ASSERT(thr->state == DUK_HTHREAD_STATE_TERMINATED);\n\n\t\tthr->resumer = NULL;\n\t\tDUK_HTHREAD_DECREF_NORZ(thr, resumer);\n\t\tresumer->state = DUK_HTHREAD_STATE_RUNNING;\n\t\tDUK_HEAP_SWITCH_THREAD(thr->heap, resumer);\n\t\tthr = resumer;\n\t\tgoto check_longjmp;\n\t}\n\n\tcase DUK_LJ_TYPE_BREAK:  /* pseudotypes, not used in actual longjmps */\n\tcase DUK_LJ_TYPE_CONTINUE:\n\tcase DUK_LJ_TYPE_RETURN:\n\tcase DUK_LJ_TYPE_NORMAL:\n\tdefault: {\n\t\t/* should never happen, but be robust */\n\t\tDUK_D(DUK_DPRINT(\"caught unknown longjmp type %ld, treat as internal error\", (long) thr->heap->lj.type));\n\t\tgoto convert_to_internal_error;\n\t}\n\n\t}  /* end switch */\n\n\tDUK_UNREACHABLE();\n\n wipe_and_return:\n\t/* this is not strictly necessary, but helps debugging */\n\tthr->heap->lj.type = DUK_LJ_TYPE_UNKNOWN;\n\tthr->heap->lj.iserror = 0;\n\n\tDUK_TVAL_SET_UNDEFINED_UPDREF(thr, &thr->heap->lj.value1);  /* side effects */\n\tDUK_TVAL_SET_UNDEFINED_UPDREF(thr, &thr->heap->lj.value2);  /* side effects */\n\n\tDUK_GC_TORTURE(thr->heap);\n\n just_return:\n\treturn retval;\n\n convert_to_internal_error:\n\t/* This could also be thrown internally (set the error, goto check_longjmp),\n\t * but it's better for internal errors to bubble outwards so that we won't\n\t * infinite loop in this catchpoint.\n\t */\n\tDUK_ERROR_INTERNAL(thr);\n\tDUK_UNREACHABLE();\n\treturn retval;\n}\n\n/* Handle a BREAK/CONTINUE opcode.  Avoid using longjmp() for BREAK/CONTINUE\n * handling because it has a measurable performance impact in ordinary\n * environments and an extreme impact in Emscripten (GH-342).\n */\nDUK_LOCAL void duk__handle_break_or_continue(duk_hthread *thr,\n                                             duk_uint_t label_id,\n                                             duk_small_uint_t lj_type) {\n\tduk_catcher *cat;\n\tduk_size_t orig_callstack_index;\n\n\tDUK_ASSERT(thr != NULL);\n\n\t/*\n\t *  Find a matching label catcher or 'finally' catcher in\n\t *  the same function.\n\t *\n\t *  A label catcher must always exist and will match unless\n\t *  a 'finally' captures the break/continue first.  It is the\n\t *  compiler's responsibility to ensure that labels are used\n\t *  correctly.\n\t */\n\n\t/* Note: thr->catchstack_top may be 0, so that cat < thr->catchstack\n\t * initially.  This is OK and intended.\n\t */\n\tcat = thr->catchstack + thr->catchstack_top - 1;\n\tDUK_ASSERT(thr->callstack_top > 0);\n\torig_callstack_index = thr->callstack_top - 1;\n\n\tDUK_DDD(DUK_DDDPRINT(\"handling break/continue with label=%ld, callstack index=%ld\",\n\t                     (long) label_id, (long) cat->callstack_index));\n\n\twhile (cat >= thr->catchstack) {\n\t\tif (cat->callstack_index != orig_callstack_index) {\n\t\t\tbreak;\n\t\t}\n\t\tDUK_DDD(DUK_DDDPRINT(\"considering catcher %ld: type=%ld label=%ld\",\n\t\t                     (long) (cat - thr->catchstack),\n\t\t                     (long) DUK_CAT_GET_TYPE(cat),\n\t\t                     (long) DUK_CAT_GET_LABEL(cat)));\n\n\t\tif (DUK_CAT_GET_TYPE(cat) == DUK_CAT_TYPE_TCF &&\n\t\t    DUK_CAT_HAS_FINALLY_ENABLED(cat)) {\n\t\t\tduk_size_t cat_idx;\n\t\t\tduk_tval tv_tmp;\n\n\t\t\tcat_idx = (duk_size_t) (cat - thr->catchstack);  /* get before side effects */\n\n\t\t\tDUK_TVAL_SET_U32(&tv_tmp, (duk_uint32_t) label_id);\n\t\t\tduk__handle_finally(thr, cat_idx, &tv_tmp, lj_type);\n\n\t\t\tDUK_DD(DUK_DDPRINT(\"-> break/continue caught by 'finally', restart execution\"));\n\t\t\treturn;\n\t\t}\n\t\tif (DUK_CAT_GET_TYPE(cat) == DUK_CAT_TYPE_LABEL &&\n\t\t    (duk_uint_t) DUK_CAT_GET_LABEL(cat) == label_id) {\n\t\t\tduk_size_t cat_idx;\n\n\t\t\tcat_idx = (duk_size_t) (cat - thr->catchstack);\n\t\t\tduk__handle_label(thr, cat_idx, lj_type);\n\n\t\t\tDUK_DD(DUK_DDPRINT(\"-> break/continue caught by a label catcher (in the same function), restart execution\"));\n\t\t\treturn;\n\t\t}\n\t\tcat--;\n\t}\n\n\t/* should never happen, but be robust */\n\tDUK_D(DUK_DPRINT(\"-> break/continue not caught by anything in the current function (should never happen), throw internal error\"));\n\tDUK_ERROR_INTERNAL(thr);\n\treturn;\n}\n\n/* Handle a RETURN opcode.  Avoid using longjmp() for return handling because\n * it has a measurable performance impact in ordinary environments and an extreme\n * impact in Emscripten (GH-342).  Return value is on value stack top.\n */\nDUK_LOCAL duk_small_uint_t duk__handle_return(duk_hthread *thr,\n                                              duk_hthread *entry_thread,\n                                              duk_size_t entry_callstack_top) {\n\tduk_tval *tv1;\n\tduk_tval *tv2;\n#if defined(DUK_USE_COROUTINE_SUPPORT)\n\tduk_hthread *resumer;\n#endif\n\tduk_catcher *cat;\n\tduk_size_t new_cat_top;\n\tduk_size_t orig_callstack_index;\n\n\t/* We can directly access value stack here. */\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(entry_thread != NULL);\n\tDUK_ASSERT(thr->valstack_top - 1 >= thr->valstack_bottom);\n\ttv1 = thr->valstack_top - 1;\n\tDUK_TVAL_CHKFAST_INPLACE_FAST(tv1);  /* fastint downgrade check for return values */\n\n\t/*\n\t *  Four possible outcomes:\n\t *\n\t *    1. A 'finally' in the same function catches the 'return'.\n\t *       It may continue to propagate when 'finally' is finished,\n\t *       or it may be neutralized by 'finally' (both handled by\n\t *       ENDFIN).\n\t *\n\t *    2. The return happens at the entry level of the bytecode\n\t *       executor, so return from the executor (in C stack).\n\t *\n\t *    3. There is a calling (Ecmascript) activation in the call\n\t *       stack => return to it, in the same executor instance.\n\t *\n\t *    4. There is no calling activation, and the thread is\n\t *       terminated.  There is always a resumer in this case,\n\t *       which gets the return value similarly to a 'yield'\n\t *       (except that the current thread can no longer be\n\t *       resumed).\n\t */\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->callstack_top >= 1);\n\tDUK_ASSERT(thr->catchstack != NULL);\n\n\t/* XXX: does not work if thr->catchstack is NULL */\n\t/* XXX: does not work if thr->catchstack is allocated but lowest pointer */\n\n\tcat = thr->catchstack + thr->catchstack_top - 1;  /* may be < thr->catchstack initially */\n\tDUK_ASSERT(thr->callstack_top > 0);  /* ensures callstack_top - 1 >= 0 */\n\tDUK_ASSERT(thr->callstack_curr != NULL);\n\torig_callstack_index = thr->callstack_top - 1;\n\n\twhile (cat >= thr->catchstack) {\n\t\tif (cat->callstack_index != orig_callstack_index) {\n\t\t\tbreak;\n\t\t}\n\t\tif (DUK_CAT_GET_TYPE(cat) == DUK_CAT_TYPE_TCF &&\n\t\t    DUK_CAT_HAS_FINALLY_ENABLED(cat)) {\n\t\t\tduk_size_t cat_idx;\n\n\t\t\tcat_idx = (duk_size_t) (cat - thr->catchstack);  /* get before side effects */\n\n\t\t\tDUK_ASSERT(thr->valstack_top - 1 >= thr->valstack_bottom);\n\t\t\tduk__handle_finally(thr, cat_idx, thr->valstack_top - 1, DUK_LJ_TYPE_RETURN);\n\n\t\t\tDUK_DD(DUK_DDPRINT(\"-> return caught by 'finally', restart execution\"));\n\t\t\treturn DUK__RETHAND_RESTART;\n\t\t}\n\t\tcat--;\n\t}\n\t/* If out of catchstack, cat = thr->catchstack - 1;\n\t * new_cat_top will be 0 in that case.\n\t */\n\tnew_cat_top = (duk_size_t) ((cat + 1) - thr->catchstack);\n\tcat = NULL;  /* avoid referencing, invalidated */\n\n\tDUK_DDD(DUK_DDDPRINT(\"no catcher in catch stack, return to calling activation / yield\"));\n\n\tif (thr == entry_thread &&\n\t    thr->callstack_top == entry_callstack_top) {\n\t\t/* Return to the bytecode executor caller which will unwind stacks.\n\t\t * Return value is already on the stack top: [ ... retval ].\n\t\t */\n\n\t\t/* XXX: could unwind catchstack here, so that call handling\n\t\t * didn't need to do that?\n\t\t */\n\t\tDUK_DDD(DUK_DDDPRINT(\"-> return propagated up to entry level, exit bytecode executor\"));\n\t\treturn DUK__RETHAND_FINISHED;\n\t}\n\n\tif (thr->callstack_top >= 2) {\n\t\t/* There is a caller; it MUST be an Ecmascript caller (otherwise it would\n\t\t * match entry level check)\n\t\t */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"return to Ecmascript caller, idx_retval=%ld, lj_value1=%!T\",\n\t\t                     (long) (thr->callstack_curr - 1)->idx_retval,\n\t\t                     (duk_tval *) &thr->heap->lj.value1));\n\n\t\tDUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr - 1)));   /* must be ecmascript */\n\n\t\ttv1 = thr->valstack + (thr->callstack_curr - 1)->idx_retval;\n\t\tDUK_ASSERT(thr->valstack_top - 1 >= thr->valstack_bottom);\n\t\ttv2 = thr->valstack_top - 1;\n\t\tDUK_TVAL_SET_TVAL_UPDREF(thr, tv1, tv2);  /* side effects */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"return value at idx_retval=%ld is %!T\",\n\t\t                     (long) (thr->callstack_curr - 1)->idx_retval,\n\t\t                     (duk_tval *) (thr->valstack + (thr->callstack_curr - 1)->idx_retval)));\n\n\t\tduk_hthread_catchstack_unwind_norz(thr, new_cat_top);  /* leave 'cat' as top catcher (also works if catchstack exhausted) */\n\t\tduk_hthread_callstack_unwind_norz(thr, thr->callstack_top - 1);\n\t\tduk__reconfig_valstack_ecma_return(thr, thr->callstack_top - 1);\n\n\t\tDUK_DD(DUK_DDPRINT(\"-> return not intercepted, restart execution in caller\"));\n\t\treturn DUK__RETHAND_RESTART;\n\t}\n\n#if defined(DUK_USE_COROUTINE_SUPPORT)\n\tDUK_DD(DUK_DDPRINT(\"no calling activation, thread finishes (similar to yield)\"));\n\n\tDUK_ASSERT(thr->resumer != NULL);\n\tDUK_ASSERT(thr->resumer->callstack_top >= 2);  /* Ecmascript activation + Duktape.Thread.resume() activation */\n\tDUK_ASSERT(thr->resumer->callstack_curr != NULL);\n\tDUK_ASSERT(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr) != NULL &&\n\t           DUK_HOBJECT_IS_NATFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr)) &&\n\t           ((duk_hnatfunc *) DUK_ACT_GET_FUNC(thr->resumer->callstack_curr))->func == duk_bi_thread_resume);  /* Duktape.Thread.resume() */\n\tDUK_ASSERT(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr - 1) != NULL &&\n\t           DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->resumer->callstack_curr - 1)));  /* an Ecmascript function */\n\tDUK_ASSERT_DISABLE((thr->resumer->callstack_curr - 1)->idx_retval >= 0);                  /* unsigned */\n\tDUK_ASSERT(thr->state == DUK_HTHREAD_STATE_RUNNING);\n\tDUK_ASSERT(thr->resumer->state == DUK_HTHREAD_STATE_RESUMED);\n\n\tresumer = thr->resumer;\n\n\t/* Share yield longjmp handler. */\n\tDUK_ASSERT(thr->valstack_top - 1 >= thr->valstack_bottom);\n\tduk__handle_yield(thr, resumer, resumer->callstack_top - 2, thr->valstack_top - 1);\n\n\tduk_hthread_terminate(thr);  /* updates thread state, minimizes its allocations */\n\tDUK_ASSERT(thr->state == DUK_HTHREAD_STATE_TERMINATED);\n\n\tthr->resumer = NULL;\n\tDUK_HTHREAD_DECREF(thr, resumer);\n\tresumer->state = DUK_HTHREAD_STATE_RUNNING;\n\tDUK_HEAP_SWITCH_THREAD(thr->heap, resumer);\n#if 0\n\tthr = resumer;  /* not needed */\n#endif\n\n\tDUK_DD(DUK_DDPRINT(\"-> return not caught, thread terminated; handle like yield, restart execution in resumer\"));\n\treturn DUK__RETHAND_RESTART;\n#else\n\t/* Without coroutine support this case should never happen. */\n\tDUK_ERROR_INTERNAL(thr);\n\treturn DUK__RETHAND_FINISHED;  /* not executed */\n#endif\n}\n\n/*\n *  Executor interrupt handling\n *\n *  The handler is called whenever the interrupt countdown reaches zero\n *  (or below).  The handler must perform whatever checks are activated,\n *  e.g. check for cumulative step count to impose an execution step\n *  limit or check for breakpoints or other debugger interaction.\n *\n *  When the actions are done, the handler must reinit the interrupt\n *  init and counter values.  The 'init' value must indicate how many\n *  bytecode instructions are executed before the next interrupt.  The\n *  counter must interface with the bytecode executor loop.  Concretely,\n *  the new init value is normally one higher than the new counter value.\n *  For instance, to execute exactly one bytecode instruction the init\n *  value is set to 1 and the counter to 0.  If an error is thrown by the\n *  interrupt handler, the counters are set to the same value (e.g. both\n *  to 0 to cause an interrupt when the next bytecode instruction is about\n *  to be executed after error handling).\n *\n *  Maintaining the init/counter value properly is important for accurate\n *  behavior.  For instance, executor step limit needs a cumulative step\n *  count which is simply computed as a sum of 'init' values.  This must\n *  work accurately even when single stepping.\n */\n\n#if defined(DUK_USE_INTERRUPT_COUNTER)\n\n#define DUK__INT_NOACTION    0    /* no specific action, resume normal execution */\n#define DUK__INT_RESTART     1    /* must \"goto restart_execution\", e.g. breakpoints changed */\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\nDUK_LOCAL void duk__interrupt_handle_debugger(duk_hthread *thr, duk_bool_t *out_immediate, duk_small_uint_t *out_interrupt_retval) {\n\tduk_context *ctx;\n\tduk_activation *act;\n\tduk_breakpoint *bp;\n\tduk_breakpoint **bp_active;\n\tduk_uint_fast32_t line = 0;\n\tduk_bool_t process_messages;\n\tduk_bool_t processed_messages = 0;\n\n\tDUK_ASSERT(thr->heap->dbg_processing == 0);  /* don't re-enter e.g. during Eval */\n\n\tctx = (duk_context *) thr;\n\tact = thr->callstack_curr;\n\tDUK_ASSERT(act != NULL);\n\n\t/* It might seem that replacing 'thr->heap' with just 'heap' below\n\t * might be a good idea, but it increases code size slightly\n\t * (probably due to unnecessary spilling) at least on x64.\n\t */\n\n\t/*\n\t *  Breakpoint and step state checks\n\t */\n\n\tif (act->flags & DUK_ACT_FLAG_BREAKPOINT_ACTIVE ||\n\t    (thr->heap->dbg_step_thread == thr &&\n\t     thr->heap->dbg_step_csindex == thr->callstack_top - 1)) {\n\t\tline = duk_debug_curr_line(thr);\n\n\t\tif (act->prev_line != line) {\n\t\t\t/* Stepped?  Step out is handled by callstack unwind. */\n\t\t\tif ((thr->heap->dbg_step_type == DUK_STEP_TYPE_INTO ||\n\t\t\t     thr->heap->dbg_step_type == DUK_STEP_TYPE_OVER) &&\n\t\t\t    (thr->heap->dbg_step_thread == thr) &&\n\t\t\t    (thr->heap->dbg_step_csindex == thr->callstack_top - 1) &&\n\t\t\t    (line != thr->heap->dbg_step_startline)) {\n\t\t\t\tDUK_D(DUK_DPRINT(\"STEP STATE TRIGGERED PAUSE at line %ld\",\n\t\t\t\t                 (long) line));\n\t\t\t\tduk_debug_set_paused(thr->heap);\n\t\t\t}\n\n\t\t\t/* Check for breakpoints only on line transition.\n\t\t\t * Breakpoint is triggered when we enter the target\n\t\t\t * line from a different line, and the previous line\n\t\t\t * was within the same function.\n\t\t\t *\n\t\t\t * This condition is tricky: the condition used to be\n\t\t\t * that transition to -or across- the breakpoint line\n\t\t\t * triggered the breakpoint.  This seems intuitively\n\t\t\t * better because it handles breakpoints on lines with\n\t\t\t * no emitted opcodes; but this leads to the issue\n\t\t\t * described in: https://github.com/svaarala/duktape/issues/263.\n\t\t\t */\n\t\t\tbp_active = thr->heap->dbg_breakpoints_active;\n\t\t\tfor (;;) {\n\t\t\t\tbp = *bp_active++;\n\t\t\t\tif (bp == NULL) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tDUK_ASSERT(bp->filename != NULL);\n\t\t\t\tif (act->prev_line != bp->line && line == bp->line) {\n\t\t\t\t\tDUK_D(DUK_DPRINT(\"BREAKPOINT TRIGGERED at %!O:%ld\",\n\t\t\t\t\t                 (duk_heaphdr *) bp->filename, (long) bp->line));\n\t\t\t\t\tduk_debug_set_paused(thr->heap);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t;\n\t\t}\n\n\t\tact->prev_line = line;\n\t}\n\n\t/*\n\t *  Rate limit check for sending status update or peeking into\n\t *  the debug transport.  Both can be expensive operations that\n\t *  we don't want to do on every opcode.\n\t *\n\t *  Making sure the interval remains reasonable on a wide variety\n\t *  of targets and bytecode is difficult without a timestamp, so\n\t *  we use a Date-provided timestamp for the rate limit check.\n\t *  But since it's also expensive to get a timestamp, a bytecode\n\t *  counter is used to rate limit getting timestamps.\n\t */\n\n\tprocess_messages = 0;\n\tif (thr->heap->dbg_state_dirty || DUK_HEAP_HAS_DEBUGGER_PAUSED(thr->heap) || thr->heap->dbg_detaching) {\n\t\t/* Enter message processing loop for sending Status notifys and\n\t\t * to finish a pending detach.\n\t\t */\n\t\tprocess_messages = 1;\n\t}\n\n\t/* XXX: remove heap->dbg_exec_counter, use heap->inst_count_interrupt instead? */\n\tthr->heap->dbg_exec_counter += thr->interrupt_init;\n\tif (thr->heap->dbg_exec_counter - thr->heap->dbg_last_counter >= DUK_HEAP_DBG_RATELIMIT_OPCODES) {\n\t\t/* Overflow of the execution counter is fine and doesn't break\n\t\t * anything here.\n\t\t */\n\n\t\tduk_double_t now, diff_last;\n\n\t\tthr->heap->dbg_last_counter = thr->heap->dbg_exec_counter;\n\t\tnow = DUK_USE_DATE_GET_NOW(ctx);\n\n\t\tdiff_last = now - thr->heap->dbg_last_time;\n\t\tif (diff_last < 0.0 || diff_last >= (duk_double_t) DUK_HEAP_DBG_RATELIMIT_MILLISECS) {\n\t\t\t/* Negative value checked so that a \"time jump\" works\n\t\t\t * reasonably.\n\t\t\t *\n\t\t\t * Same interval is now used for status sending and\n\t\t\t * peeking.\n\t\t\t */\n\n\t\t\tthr->heap->dbg_last_time = now;\n\t\t\tthr->heap->dbg_state_dirty = 1;\n\t\t\tprocess_messages = 1;\n\t\t}\n\t}\n\n\t/*\n\t *  Process messages and send status if necessary.\n\t *\n\t *  If we're paused, we'll block for new messages.  If we're not\n\t *  paused, we'll process anything we can peek but won't block\n\t *  for more.  Detach (and re-attach) handling is all localized\n\t *  to duk_debug_process_messages() too.\n\t *\n\t *  Debugger writes outside the message loop may cause debugger\n\t *  detach1 phase to run, after which dbg_read_cb == NULL and\n\t *  dbg_detaching != 0.  The message loop will finish the detach\n\t *  by running detach2 phase, so enter the message loop also when\n\t *  detaching.\n\t */\n\n\tact = NULL;  /* may be changed */\n\tif (process_messages) {\n\t\tDUK_ASSERT(thr->heap->dbg_processing == 0);\n\t\tprocessed_messages = duk_debug_process_messages(thr, 0 /*no_block*/);\n\t\tDUK_ASSERT(thr->heap->dbg_processing == 0);\n\t}\n\n\t/* Continue checked execution if there are breakpoints or we're stepping.\n\t * Also use checked execution if paused flag is active - it shouldn't be\n\t * because the debug message loop shouldn't terminate if it was.  Step out\n\t * is handled by callstack unwind and doesn't need checked execution.\n\t * Note that debugger may have detached due to error or explicit request\n\t * above, so we must recheck attach status.\n\t */\n\n\tif (duk_debug_is_attached(thr->heap)) {\n\t\tact = thr->callstack_curr;  /* relookup, may have changed */\n\t\tDUK_ASSERT(act != NULL);\n\t\tif (act->flags & DUK_ACT_FLAG_BREAKPOINT_ACTIVE ||\n\t\t    ((thr->heap->dbg_step_type == DUK_STEP_TYPE_INTO ||\n\t\t      thr->heap->dbg_step_type == DUK_STEP_TYPE_OVER) &&\n\t\t     thr->heap->dbg_step_thread == thr &&\n\t\t     thr->heap->dbg_step_csindex == thr->callstack_top - 1) ||\n\t\t     DUK_HEAP_HAS_DEBUGGER_PAUSED(thr->heap)) {\n\t\t\t*out_immediate = 1;\n\t\t}\n\n\t\t/* If we processed any debug messages breakpoints may have\n\t\t * changed; restart execution to re-check active breakpoints.\n\t\t */\n\t\tif (processed_messages) {\n\t\t\tDUK_D(DUK_DPRINT(\"processed debug messages, restart execution to recheck possibly changed breakpoints\"));\n\t\t\t*out_interrupt_retval = DUK__INT_RESTART;\n\t\t}\n\t} else {\n\t\tDUK_D(DUK_DPRINT(\"debugger became detached, resume normal execution\"));\n\t}\n}\n#endif  /* DUK_USE_DEBUGGER_SUPPORT */\n\nDUK_LOCAL DUK_NOINLINE DUK_COLD duk_small_uint_t duk__executor_interrupt(duk_hthread *thr) {\n\tduk_int_t ctr;\n\tduk_activation *act;\n\tduk_hcompfunc *fun;\n\tduk_bool_t immediate = 0;\n\tduk_small_uint_t retval;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->heap != NULL);\n\tDUK_ASSERT(thr->callstack != NULL);\n\tDUK_ASSERT(thr->callstack_top > 0);\n\n#if defined(DUK_USE_DEBUG)\n\tthr->heap->inst_count_interrupt += thr->interrupt_init;\n\tDUK_DD(DUK_DDPRINT(\"execution interrupt, counter=%ld, init=%ld, \"\n\t                   \"instruction counts: executor=%ld, interrupt=%ld\",\n\t                   (long) thr->interrupt_counter, (long) thr->interrupt_init,\n\t                   (long) thr->heap->inst_count_exec, (long) thr->heap->inst_count_interrupt));\n#endif\n\n\tretval = DUK__INT_NOACTION;\n\tctr = DUK_HTHREAD_INTCTR_DEFAULT;\n\n\t/*\n\t *  Avoid nested calls.  Concretely this happens during debugging, e.g.\n\t *  when we eval() an expression.\n\t *\n\t *  Also don't interrupt if we're currently doing debug processing\n\t *  (which can be initiated outside the bytecode executor) as this\n\t *  may cause the debugger to be called recursively.  Check required\n\t *  for correct operation of throw intercept and other \"exotic\" halting\n\t * scenarios.\n\t */\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\tif (DUK_HEAP_HAS_INTERRUPT_RUNNING(thr->heap) || thr->heap->dbg_processing) {\n#else\n\tif (DUK_HEAP_HAS_INTERRUPT_RUNNING(thr->heap)) {\n#endif\n\t\tDUK_DD(DUK_DDPRINT(\"nested executor interrupt, ignoring\"));\n\n\t\t/* Set a high interrupt counter; the original executor\n\t\t * interrupt invocation will rewrite before exiting.\n\t\t */\n\t\tthr->interrupt_init = ctr;\n\t\tthr->interrupt_counter = ctr - 1;\n\t\treturn DUK__INT_NOACTION;\n\t}\n\tDUK_HEAP_SET_INTERRUPT_RUNNING(thr->heap);\n\n\tact = thr->callstack_curr;\n\tDUK_ASSERT(act != NULL);\n\n\tfun = (duk_hcompfunc *) DUK_ACT_GET_FUNC(act);\n\tDUK_ASSERT(DUK_HOBJECT_HAS_COMPFUNC((duk_hobject *) fun));\n\n\tDUK_UNREF(fun);\n\n#if defined(DUK_USE_EXEC_TIMEOUT_CHECK)\n\t/*\n\t *  Execution timeout check\n\t */\n\n\tif (DUK_USE_EXEC_TIMEOUT_CHECK(thr->heap->heap_udata)) {\n\t\t/* Keep throwing an error whenever we get here.  The unusual values\n\t\t * are set this way because no instruction is ever executed, we just\n\t\t * throw an error until all try/catch/finally and other catchpoints\n\t\t * have been exhausted.  Duktape/C code gets control at each protected\n\t\t * call but whenever it enters back into Duktape the RangeError gets\n\t\t * raised.  User exec timeout check must consistently indicate a timeout\n\t\t * until we've fully bubbled out of Duktape.\n\t\t */\n\t\tDUK_D(DUK_DPRINT(\"execution timeout, throwing a RangeError\"));\n\t\tthr->interrupt_init = 0;\n\t\tthr->interrupt_counter = 0;\n\t\tDUK_HEAP_CLEAR_INTERRUPT_RUNNING(thr->heap);\n\t\tDUK_ERROR_RANGE(thr, \"execution timeout\");\n\t}\n#endif  /* DUK_USE_EXEC_TIMEOUT_CHECK */\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\tif (!thr->heap->dbg_processing &&\n\t    (thr->heap->dbg_read_cb != NULL || thr->heap->dbg_detaching)) {\n\t\t/* Avoid recursive re-entry; enter when we're attached or\n\t\t * detaching (to finish off the pending detach).\n\t\t */\n\t\tduk__interrupt_handle_debugger(thr, &immediate, &retval);\n\t\tact = thr->callstack_curr;  /* relookup if changed */\n\t\tDUK_UNREF(act);  /* 'act' is no longer accessed, scanbuild fix */\n\t}\n#endif  /* DUK_USE_DEBUGGER_SUPPORT */\n\n\t/*\n\t *  Update the interrupt counter\n\t */\n\n\tif (immediate) {\n\t\t/* Cause an interrupt after executing one instruction. */\n\t\tctr = 1;\n\t}\n\n\t/* The counter value is one less than the init value: init value should\n\t * indicate how many instructions are executed before interrupt.  To\n\t * execute 1 instruction (after interrupt handler return), counter must\n\t * be 0.\n\t */\n\tDUK_ASSERT(ctr >= 1);\n\tthr->interrupt_init = ctr;\n\tthr->interrupt_counter = ctr - 1;\n\tDUK_HEAP_CLEAR_INTERRUPT_RUNNING(thr->heap);\n\n\treturn retval;\n}\n#endif  /* DUK_USE_INTERRUPT_COUNTER */\n\n/*\n *  Debugger handling for executor restart\n *\n *  Check for breakpoints, stepping, etc, and figure out if we should execute\n *  in checked or normal mode.  Note that we can't do this when an activation\n *  is created, because breakpoint status (and stepping status) may change\n *  later, so we must recheck every time we're executing an activation.\n *  This primitive should be side effect free to avoid changes during check.\n */\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\nDUK_LOCAL void duk__executor_recheck_debugger(duk_hthread *thr, duk_activation *act, duk_hcompfunc *fun) {\n\tduk_heap *heap;\n\tduk_tval *tv_tmp;\n\tduk_hstring *filename;\n\tduk_small_uint_t bp_idx;\n\tduk_breakpoint **bp_active;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(act != NULL);\n\tDUK_ASSERT(fun != NULL);\n\n\theap = thr->heap;\n\tbp_active = heap->dbg_breakpoints_active;\n\tact->flags &= ~DUK_ACT_FLAG_BREAKPOINT_ACTIVE;\n\n\ttv_tmp = duk_hobject_find_existing_entry_tval_ptr(thr->heap, (duk_hobject *) fun, DUK_HTHREAD_STRING_FILE_NAME(thr));\n\tif (tv_tmp && DUK_TVAL_IS_STRING(tv_tmp)) {\n\t\tfilename = DUK_TVAL_GET_STRING(tv_tmp);\n\n\t\t/* Figure out all active breakpoints.  A breakpoint is\n\t\t * considered active if the current function's fileName\n\t\t * matches the breakpoint's fileName, AND there is no\n\t\t * inner function that has matching line numbers\n\t\t * (otherwise a breakpoint would be triggered both\n\t\t * inside and outside of the inner function which would\n\t\t * be confusing).  Example:\n\t\t *\n\t\t *     function foo() {\n\t\t *         print('foo');\n\t\t *         function bar() {    <-.  breakpoints in these\n\t\t *             print('bar');     |  lines should not affect\n\t\t *         }                   <-'  foo() execution\n\t\t *         bar();\n\t\t *     }\n\t\t *\n\t\t * We need a few things that are only available when\n\t\t * debugger support is enabled: (1) a line range for\n\t\t * each function, and (2) access to the function\n\t\t * template to access the inner functions (and their\n\t\t * line ranges).\n\t\t *\n\t\t * It's important to have a narrow match for active\n\t\t * breakpoints so that we don't enter checked execution\n\t\t * when that's not necessary.  For instance, if we're\n\t\t * running inside a certain function and there's\n\t\t * breakpoint outside in (after the call site), we\n\t\t * don't want to slow down execution of the function.\n\t\t */\n\n\t\tfor (bp_idx = 0; bp_idx < heap->dbg_breakpoint_count; bp_idx++) {\n\t\t\tduk_breakpoint *bp = heap->dbg_breakpoints + bp_idx;\n\t\t\tduk_hobject **funcs, **funcs_end;\n\t\t\tduk_hcompfunc *inner_fun;\n\t\t\tduk_bool_t bp_match;\n\n\t\t\tif (bp->filename == filename &&\n\t\t\t    bp->line >= fun->start_line && bp->line <= fun->end_line) {\n\t\t\t\tbp_match = 1;\n\t\t\t\tDUK_DD(DUK_DDPRINT(\"breakpoint filename and line match: \"\n\t\t\t\t                   \"%s:%ld vs. %s (line %ld vs. %ld-%ld)\",\n\t\t\t\t                   DUK_HSTRING_GET_DATA(bp->filename),\n\t\t\t\t                   (long) bp->line,\n\t\t\t\t                   DUK_HSTRING_GET_DATA(filename),\n\t\t\t\t                   (long) bp->line,\n\t\t\t\t                   (long) fun->start_line,\n\t\t\t\t                   (long) fun->end_line));\n\n\t\t\t\tfuncs = DUK_HCOMPFUNC_GET_FUNCS_BASE(thr->heap, fun);\n\t\t\t\tfuncs_end = DUK_HCOMPFUNC_GET_FUNCS_END(thr->heap, fun);\n\t\t\t\twhile (funcs != funcs_end) {\n\t\t\t\t\tinner_fun = (duk_hcompfunc *) *funcs;\n\t\t\t\t\tDUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC((duk_hobject *) inner_fun));\n\t\t\t\t\tif (bp->line >= inner_fun->start_line && bp->line <= inner_fun->end_line) {\n\t\t\t\t\t\tDUK_DD(DUK_DDPRINT(\"inner function masks ('captures') breakpoint\"));\n\t\t\t\t\t\tbp_match = 0;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tfuncs++;\n\t\t\t\t}\n\n\t\t\t\tif (bp_match) {\n\t\t\t\t\t/* No need to check for size of bp_active list,\n\t\t\t\t\t * it's always larger than maximum number of\n\t\t\t\t\t * breakpoints.\n\t\t\t\t\t */\n\t\t\t\t\tact->flags |= DUK_ACT_FLAG_BREAKPOINT_ACTIVE;\n\t\t\t\t\t*bp_active = heap->dbg_breakpoints + bp_idx;\n\t\t\t\t\tbp_active++;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t*bp_active = NULL;  /* terminate */\n\n\tDUK_DD(DUK_DDPRINT(\"ACTIVE BREAKPOINTS: %ld\", (long) (bp_active - thr->heap->dbg_breakpoints_active)));\n\n\t/* Force pause if we were doing \"step into\" in another activation. */\n\tif (thr->heap->dbg_step_thread != NULL &&\n\t    thr->heap->dbg_step_type == DUK_STEP_TYPE_INTO &&\n\t    (thr->heap->dbg_step_thread != thr ||\n\t     thr->heap->dbg_step_csindex != thr->callstack_top - 1)) {\n\t\tDUK_D(DUK_DPRINT(\"STEP INTO ACTIVE, FORCE PAUSED\"));\n\t\tduk_debug_set_paused(thr->heap);\n\t}\n\n\t/* Force interrupt right away if we're paused or in \"checked mode\".\n\t * Step out is handled by callstack unwind.\n\t */\n\tif (act->flags & (DUK_ACT_FLAG_BREAKPOINT_ACTIVE) ||\n\t    DUK_HEAP_HAS_DEBUGGER_PAUSED(thr->heap) ||\n\t    (thr->heap->dbg_step_type != DUK_STEP_TYPE_OUT &&\n\t     thr->heap->dbg_step_csindex == thr->callstack_top - 1)) {\n\t\t/* We'll need to interrupt early so recompute the init\n\t\t * counter to reflect the number of bytecode instructions\n\t\t * executed so that step counts for e.g. debugger rate\n\t\t * limiting are accurate.\n\t\t */\n\t\tDUK_ASSERT(thr->interrupt_counter <= thr->interrupt_init);\n\t\tthr->interrupt_init = thr->interrupt_init - thr->interrupt_counter;\n\t\tthr->interrupt_counter = 0;\n\t}\n}\n#endif  /* DUK_USE_DEBUGGER_SUPPORT */\n\n/*\n *  Ecmascript bytecode executor.\n *\n *  Resume execution for the current thread from its current activation.\n *  Returns when execution would return from the entry level activation,\n *  leaving a single return value on top of the stack.  Function calls\n *  and thread resumptions are handled internally.  If an error occurs,\n *  a longjmp() with type DUK_LJ_TYPE_THROW is called on the entry level\n *  setjmp() jmpbuf.\n *\n *  Ecmascript function calls and coroutine resumptions are handled\n *  internally (by the outer executor function) without recursive C calls.\n *  Other function calls are handled using duk_handle_call(), increasing\n *  C recursion depth.\n *\n *  Abrupt completions (= long control tranfers) are handled either\n *  directly by reconfiguring relevant stacks and restarting execution,\n *  or via a longjmp.  Longjmp-free handling is preferable for performance\n *  (especially Emscripten performance), and is used for: break, continue,\n *  and return.\n *\n *  For more detailed notes, see doc/execution.rst.\n *\n *  Also see doc/code-issues.rst for discussion of setjmp(), longjmp(),\n *  and volatile.\n */\n\n/* Presence of 'fun' is config based, there's a marginal performance\n * difference and the best option is architecture dependent.\n */\n#if defined(DUK_USE_EXEC_FUN_LOCAL)\n#define DUK__FUN()          fun\n#else\n#define DUK__FUN()          ((duk_hcompfunc *) DUK_ACT_GET_FUNC((thr)->callstack_curr))\n#endif\n#define DUK__STRICT()       (DUK_HOBJECT_HAS_STRICT((duk_hobject *) DUK__FUN()))\n\n/* Reg/const access macros: these are very footprint and performance sensitive\n * so modify with care.  Arguments are sometimes evaluated multiple times which\n * is not ideal.\n */\n#define DUK__REG(x)         (*(thr->valstack_bottom + (x)))\n#define DUK__REGP(x)        (thr->valstack_bottom + (x))\n#define DUK__CONST(x)       (*(consts + (x)))\n#define DUK__CONSTP(x)      (consts + (x))\n\n/* Reg/const access macros which take the 32-bit instruction and avoid an\n * explicit field decoding step by using shifts and masks.  These must be\n * kept in sync with duk_js_bytecode.h.  The shift/mask values are chosen\n * so that 'ins' can be shifted and masked and used as a -byte- offset\n * instead of a duk_tval offset which needs further shifting (which is an\n * issue on some, but not all, CPUs).\n */\n#define DUK__RCBIT_B           DUK_BC_REGCONST_B\n#define DUK__RCBIT_C           DUK_BC_REGCONST_C\n#if defined(DUK_USE_EXEC_REGCONST_OPTIMIZE)\n#if defined(DUK_USE_PACKED_TVAL)\n#define DUK__TVAL_SHIFT        3  /* sizeof(duk_tval) == 8 */\n#else\n#define DUK__TVAL_SHIFT        4  /* sizeof(duk_tval) == 16; not always the case so also asserted for */\n#endif\n#define DUK__SHIFT_A           (DUK_BC_SHIFT_A - DUK__TVAL_SHIFT)\n#define DUK__SHIFT_B           (DUK_BC_SHIFT_B - DUK__TVAL_SHIFT)\n#define DUK__SHIFT_C           (DUK_BC_SHIFT_C - DUK__TVAL_SHIFT)\n#define DUK__SHIFT_BC          (DUK_BC_SHIFT_BC - DUK__TVAL_SHIFT)\n#define DUK__MASK_A            (DUK_BC_UNSHIFTED_MASK_A << DUK__TVAL_SHIFT)\n#define DUK__MASK_B            (DUK_BC_UNSHIFTED_MASK_B << DUK__TVAL_SHIFT)\n#define DUK__MASK_C            (DUK_BC_UNSHIFTED_MASK_C << DUK__TVAL_SHIFT)\n#define DUK__MASK_BC           (DUK_BC_UNSHIFTED_MASK_BC << DUK__TVAL_SHIFT)\n#define DUK__BYTEOFF_A(ins)    (((ins) >> DUK__SHIFT_A) & DUK__MASK_A)\n#define DUK__BYTEOFF_B(ins)    (((ins) >> DUK__SHIFT_B) & DUK__MASK_B)\n#define DUK__BYTEOFF_C(ins)    (((ins) >> DUK__SHIFT_C) & DUK__MASK_C)\n#define DUK__BYTEOFF_BC(ins)   (((ins) >> DUK__SHIFT_BC) & DUK__MASK_BC)\n\n#define DUK__REGP_A(ins)       ((duk_tval *) (void *) ((duk_uint8_t *) thr->valstack_bottom + DUK__BYTEOFF_A((ins))))\n#define DUK__REGP_B(ins)       ((duk_tval *) (void *) ((duk_uint8_t *) thr->valstack_bottom + DUK__BYTEOFF_B((ins))))\n#define DUK__REGP_C(ins)       ((duk_tval *) (void *) ((duk_uint8_t *) thr->valstack_bottom + DUK__BYTEOFF_C((ins))))\n#define DUK__REGP_BC(ins)      ((duk_tval *) (void *) ((duk_uint8_t *) thr->valstack_bottom + DUK__BYTEOFF_BC((ins))))\n#define DUK__CONSTP_A(ins)     ((duk_tval *) (void *) ((duk_uint8_t *) consts + DUK__BYTEOFF_A((ins))))\n#define DUK__CONSTP_B(ins)     ((duk_tval *) (void *) ((duk_uint8_t *) consts + DUK__BYTEOFF_B((ins))))\n#define DUK__CONSTP_C(ins)     ((duk_tval *) (void *) ((duk_uint8_t *) consts + DUK__BYTEOFF_C((ins))))\n#define DUK__CONSTP_BC(ins)    ((duk_tval *) (void *) ((duk_uint8_t *) consts + DUK__BYTEOFF_BC((ins))))\n#define DUK__REGCONSTP_B(ins)  ((duk_tval *) (void *) ((duk_uint8_t *) (((ins) & DUK__RCBIT_B) ? consts : thr->valstack_bottom) + DUK__BYTEOFF_B((ins))))\n#define DUK__REGCONSTP_C(ins)  ((duk_tval *) (void *) ((duk_uint8_t *) (((ins) & DUK__RCBIT_C) ? consts : thr->valstack_bottom) + DUK__BYTEOFF_C((ins))))\n#else  /* DUK_USE_EXEC_REGCONST_OPTIMIZE */\n/* Safe alternatives, no assumption about duk_tval size. */\n#define DUK__REGP_A(ins)       DUK__REGP(DUK_DEC_A((ins)))\n#define DUK__REGP_B(ins)       DUK__REGP(DUK_DEC_B((ins)))\n#define DUK__REGP_C(ins)       DUK__REGP(DUK_DEC_C((ins)))\n#define DUK__REGP_BC(ins)      DUK__REGP(DUK_DEC_BC((ins)))\n#define DUK__CONSTP_A(ins)     DUK__CONSTP(DUK_DEC_A((ins)))\n#define DUK__CONSTP_B(ins)     DUK__CONSTP(DUK_DEC_B((ins)))\n#define DUK__CONSTP_C(ins)     DUK__CONSTP(DUK_DEC_C((ins)))\n#define DUK__CONSTP_BC(ins)    DUK__CONSTP(DUK_DEC_BC((ins)))\n#define DUK__REGCONSTP_B(ins)  ((((ins) & DUK__RCBIT_B) ? consts : thr->valstack_bottom) + DUK_DEC_B((ins)))\n#define DUK__REGCONSTP_C(ins)  ((((ins) & DUK__RCBIT_C) ? consts : thr->valstack_bottom) + DUK_DEC_C((ins)))\n#endif  /* DUK_USE_EXEC_REGCONST_OPTIMIZE */\n\n#if defined(DUK_USE_VERBOSE_EXECUTOR_ERRORS)\n#define DUK__INTERNAL_ERROR(msg)  do { \\\n\t\tDUK_ERROR_ERROR(thr, (msg)); \\\n\t} while (0)\n#else\n#define DUK__INTERNAL_ERROR(msg)  do { \\\n\t\tgoto internal_error; \\\n\t} while (0)\n#endif\n\n#define DUK__SYNC_CURR_PC()  do { \\\n\t\tduk_activation *act; \\\n\t\tact = thr->callstack_curr; \\\n\t\tact->curr_pc = curr_pc; \\\n\t} while (0)\n#define DUK__SYNC_AND_NULL_CURR_PC()  do { \\\n\t\tduk_activation *act; \\\n\t\tact = thr->callstack_curr; \\\n\t\tact->curr_pc = curr_pc; \\\n\t\tthr->ptr_curr_pc = NULL; \\\n\t} while (0)\n\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n#define DUK__LOOKUP_INDIRECT_INDEX(idx) do { \\\n\t\t(idx) = (duk_uint_fast_t) duk_get_uint(ctx, (idx)); \\\n\t} while (0)\n#elif defined(DUK_USE_FASTINT)\n#define DUK__LOOKUP_INDIRECT_INDEX(idx) do { \\\n\t\tduk_tval *tv_ind; \\\n\t\ttv_ind = DUK__REGP((idx)); \\\n\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv_ind)); \\\n\t\tDUK_ASSERT(DUK_TVAL_IS_FASTINT(tv_ind));  /* compiler guarantees */ \\\n\t\t(idx) = (duk_uint_fast_t) DUK_TVAL_GET_FASTINT_U32(tv_ind); \\\n\t} while (0)\n#else\n#define DUK__LOOKUP_INDIRECT_INDEX(idx) do { \\\n\t\tduk_tval *tv_ind; \\\n\t\ttv_ind = DUK__REGP(idx); \\\n\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv_ind)); \\\n\t\tidx = (duk_uint_fast_t) DUK_TVAL_GET_NUMBER(tv_ind); \\\n\t} while (0)\n#endif\n\nDUK_LOCAL void duk__handle_executor_error(duk_heap *heap,\n                                          duk_hthread *entry_thread,\n                                          duk_size_t entry_callstack_top,\n                                          duk_int_t entry_call_recursion_depth,\n                                          duk_jmpbuf *entry_jmpbuf_ptr) {\n\tduk_small_uint_t lj_ret;\n\n\t/* Longjmp callers are required to sync-and-null thr->ptr_curr_pc\n\t * before longjmp.\n\t */\n\tDUK_ASSERT(heap->curr_thread != NULL);\n\tDUK_ASSERT(heap->curr_thread->ptr_curr_pc == NULL);\n\n\t/* XXX: signalling the need to shrink check (only if unwound) */\n\n\t/* Must be restored here to handle e.g. yields properly. */\n\theap->call_recursion_depth = entry_call_recursion_depth;\n\n\t/* Switch to caller's setjmp() catcher so that if an error occurs\n\t * during error handling, it is always propagated outwards instead\n\t * of causing an infinite loop in our own handler.\n\t */\n\theap->lj.jmpbuf_ptr = (duk_jmpbuf *) entry_jmpbuf_ptr;\n\n\tlj_ret = duk__handle_longjmp(heap->curr_thread, entry_thread, entry_callstack_top);\n\n\t/* Error handling complete, remove side effect protections.\n\t */\n#if defined(DUK_USE_ASSERTIONS)\n\tDUK_ASSERT(heap->error_not_allowed == 1);\n\theap->error_not_allowed = 0;\n#endif\n\tDUK_ASSERT(heap->pf_prevent_count > 0);\n\theap->pf_prevent_count--;\n\tDUK_DD(DUK_DDPRINT(\"executor error handled, pf_prevent_count updated to %ld\", (long) heap->pf_prevent_count));\n\n\tif (lj_ret == DUK__LONGJMP_RESTART) {\n\t\t/* Restart bytecode execution, possibly with a changed thread. */\n\t\tDUK_REFZERO_CHECK_SLOW(heap->curr_thread);\n\t} else {\n\t\t/* If an error is propagated, don't run refzero checks here.\n\t\t * The next catcher will deal with that.  Pf_prevent_count\n\t\t * will be re-bumped by the longjmp.\n\t\t */\n\n\t\tDUK_ASSERT(lj_ret == DUK__LONGJMP_RETHROW);  /* Rethrow error to calling state. */\n\t\tDUK_ASSERT(heap->lj.jmpbuf_ptr == entry_jmpbuf_ptr);  /* Longjmp handling has restored jmpbuf_ptr. */\n\n\t\t/* Thread may have changed, e.g. YIELD converted to THROW. */\n\t\tduk_err_longjmp(heap->curr_thread);\n\t\tDUK_UNREACHABLE();\n\t}\n}\n\n/* Outer executor with setjmp/longjmp handling. */\nDUK_INTERNAL void duk_js_execute_bytecode(duk_hthread *exec_thr) {\n\t/* Entry level info. */\n\tduk_hthread *entry_thread;\n\tduk_size_t entry_callstack_top;\n\tduk_int_t entry_call_recursion_depth;\n\tduk_jmpbuf *entry_jmpbuf_ptr;\n\tduk_jmpbuf our_jmpbuf;\n\tduk_heap *heap;\n\n\tDUK_ASSERT(exec_thr != NULL);\n\tDUK_ASSERT(exec_thr->heap != NULL);\n\tDUK_ASSERT(exec_thr->heap->curr_thread != NULL);\n\tDUK_ASSERT_REFCOUNT_NONZERO_HEAPHDR((duk_heaphdr *) exec_thr);\n\tDUK_ASSERT(exec_thr->callstack_top >= 1);  /* at least one activation, ours */\n\tDUK_ASSERT(DUK_ACT_GET_FUNC(exec_thr->callstack_curr) != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(exec_thr->callstack_curr)));\n\n\tDUK_GC_TORTURE(exec_thr->heap);\n\n\tentry_thread = exec_thr;\n\theap = entry_thread->heap;\n\tentry_callstack_top = entry_thread->callstack_top;\n\tentry_call_recursion_depth = entry_thread->heap->call_recursion_depth;\n\tentry_jmpbuf_ptr = entry_thread->heap->lj.jmpbuf_ptr;\n\n\t/*\n\t *  Note: we currently assume that the setjmp() catchpoint is\n\t *  not re-entrant (longjmp() cannot be called more than once\n\t *  for a single setjmp()).\n\t *\n\t *  See doc/code-issues.rst for notes on variable assignment\n\t *  before and after setjmp().\n\t */\n\n\tfor (;;) {\n\t\theap->lj.jmpbuf_ptr = &our_jmpbuf;\n\t\tDUK_ASSERT(heap->lj.jmpbuf_ptr != NULL);\n\n#if defined(DUK_USE_CPP_EXCEPTIONS)\n\t\ttry {\n#else\n\t\tDUK_ASSERT(heap->lj.jmpbuf_ptr == &our_jmpbuf);\n\t\tif (DUK_SETJMP(our_jmpbuf.jb) == 0) {\n#endif\n\t\t\t/* Execute bytecode until returned or longjmp(). */\n\t\t\tduk__js_execute_bytecode_inner(entry_thread, entry_callstack_top);\n\n\t\t\t/* Successful return: restore jmpbuf and return to caller. */\n\t\t\theap->lj.jmpbuf_ptr = entry_jmpbuf_ptr;\n\n\t\t\treturn;\n#if defined(DUK_USE_CPP_EXCEPTIONS)\n\t\t} catch (duk_internal_exception &exc) {\n#else\n\t\t} else {\n#endif\n#if defined(DUK_USE_CPP_EXCEPTIONS)\n\t\t\tDUK_UNREF(exc);\n#endif\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"longjmp caught by bytecode executor\"));\n\n\t\t\tduk__handle_executor_error(heap,\n\t\t\t                           entry_thread,\n\t\t\t                           entry_callstack_top,\n\t\t\t                           entry_call_recursion_depth,\n\t\t\t                           entry_jmpbuf_ptr);\n\t\t}\n#if defined(DUK_USE_CPP_EXCEPTIONS)\n\t\tcatch (std::exception &exc) {\n\t\t\tconst char *what = exc.what();\n\t\t\tif (!what) {\n\t\t\t\twhat = \"unknown\";\n\t\t\t}\n\t\t\tDUK_D(DUK_DPRINT(\"unexpected c++ std::exception (perhaps thrown by user code)\"));\n\t\t\ttry {\n\t\t\t\tDUK_ASSERT(heap->curr_thread != NULL);\n\t\t\t\tDUK_ERROR_FMT1(heap->curr_thread, DUK_ERR_TYPE_ERROR, \"caught invalid c++ std::exception '%s' (perhaps thrown by user code)\", what);\n\t\t\t} catch (duk_internal_exception exc) {\n\t\t\t\tDUK_D(DUK_DPRINT(\"caught api error thrown from unexpected c++ std::exception\"));\n\t\t\t\tDUK_UNREF(exc);\n\t\t\t\tduk__handle_executor_error(heap,\n\t\t\t\t                           entry_thread,\n\t\t\t\t                           entry_callstack_top,\n\t\t\t\t                           entry_call_recursion_depth,\n\t\t\t\t                           entry_jmpbuf_ptr);\n\t\t\t}\n\t\t} catch (...) {\n\t\t\tDUK_D(DUK_DPRINT(\"unexpected c++ exception (perhaps thrown by user code)\"));\n\t\t\ttry {\n\t\t\t\tDUK_ASSERT(heap->curr_thread != NULL);\n\t\t\t\tDUK_ERROR_TYPE(heap->curr_thread, \"caught invalid c++ exception (perhaps thrown by user code)\");\n\t\t\t} catch (duk_internal_exception exc) {\n\t\t\t\tDUK_D(DUK_DPRINT(\"caught api error thrown from unexpected c++ exception\"));\n\t\t\t\tDUK_UNREF(exc);\n\t\t\t\tduk__handle_executor_error(heap,\n\t\t\t\t                           entry_thread,\n\t\t\t\t                           entry_callstack_top,\n\t\t\t\t                           entry_call_recursion_depth,\n\t\t\t\t                           entry_jmpbuf_ptr);\n\t\t\t}\n\t\t}\n#endif\n\t}\n\n\tDUK_UNREACHABLE();\n}\n\n/* Inner executor, performance critical. */\nDUK_LOCAL DUK_NOINLINE DUK_HOT void duk__js_execute_bytecode_inner(duk_hthread *entry_thread, duk_size_t entry_callstack_top) {\n\t/* Current PC, accessed by other functions through thr->ptr_to_curr_pc.\n\t * Critical for performance.  It would be safest to make this volatile,\n\t * but that eliminates performance benefits; aliasing guarantees\n\t * should be enough though.\n\t */\n\tduk_instr_t *curr_pc;         /* bytecode has a stable pointer */\n\n\t/* Hot variables for interpretation.  Critical for performance,\n\t * but must add sparingly to minimize register shuffling.\n\t */\n\tduk_hthread *thr;             /* stable */\n\tduk_tval *consts;             /* stable */\n\tduk_uint_fast32_t ins;\n\t/* 'funcs' is quite rarely used, so no local for it */\n#if defined(DUK_USE_EXEC_FUN_LOCAL)\n\tduk_hcompfunc *fun;\n#else\n\t/* 'fun' is quite rarely used, so no local for it */\n#endif\n\n#if defined(DUK_USE_INTERRUPT_COUNTER)\n\tduk_int_t int_ctr;\n#endif\n\n#if defined(DUK_USE_ASSERTIONS)\n\tduk_size_t valstack_top_base;    /* valstack top, should match before interpreting each op (no leftovers) */\n#endif\n\n\t/* Optimized reg/const access macros assume sizeof(duk_tval) to be\n\t * either 8 or 16.  Heap allocation checks this even without asserts\n\t * enabled now because it can't be autodetected in duk_config.h.\n\t */\n#if 1\n#if defined(DUK_USE_PACKED_TVAL)\n\tDUK_ASSERT(sizeof(duk_tval) == 8);\n#else\n\tDUK_ASSERT(sizeof(duk_tval) == 16);\n#endif\n#endif\n\n\tDUK_GC_TORTURE(entry_thread->heap);\n\n\t/*\n\t *  Restart execution by reloading thread state.\n\t *\n\t *  Note that 'thr' and any thread configuration may have changed,\n\t *  so all local variables are suspect and we need to reinitialize.\n\t *\n\t *  The number of local variables should be kept to a minimum: if\n\t *  the variables are spilled, they will need to be loaded from\n\t *  memory anyway.\n\t *\n\t *  Any 'goto restart_execution;' code path in opcode dispatch must\n\t *  ensure 'curr_pc' is synced back to act->curr_pc before the goto\n\t *  takes place.\n\t *\n\t *  The interpreter must be very careful with memory pointers, as\n\t *  many pointers are not guaranteed to be 'stable' and may be\n\t *  reallocated and relocated on-the-fly quite easily (e.g. by a\n\t *  memory allocation or a property access).\n\t *\n\t *  The following are assumed to have stable pointers:\n\t *    - the current thread\n\t *    - the current function\n\t *    - the bytecode, constant table, inner function table of the\n\t *      current function (as they are a part of the function allocation)\n\t *\n\t *  The following are assumed to have semi-stable pointers:\n\t *    - the current activation entry: stable as long as callstack\n\t *      is not changed (reallocated by growing or shrinking), or\n\t *      by any garbage collection invocation (through finalizers)\n\t *    - Note in particular that ANY DECREF can invalidate the\n\t *      activation pointer, so for the most part a fresh lookup\n\t *      is required\n\t *\n\t *  The following are not assumed to have stable pointers at all:\n\t *    - the value stack (registers) of the current thread\n\t *    - the catch stack of the current thread\n\t *\n\t *  See execution.rst for discussion.\n\t */\n\n restart_execution:\n\n\t/* Lookup current thread; use the stable 'entry_thread' for this to\n\t * avoid clobber warnings.  Any valid, reachable 'thr' value would be\n\t * fine for this, so using 'entry_thread' is just to silence warnings.\n\t */\n\tthr = entry_thread->heap->curr_thread;\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(thr->callstack_top >= 1);\n\tDUK_ASSERT(thr->callstack_curr != NULL);\n\tDUK_ASSERT(DUK_ACT_GET_FUNC(thr->callstack_curr) != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(DUK_ACT_GET_FUNC(thr->callstack_curr)));\n\n\tDUK_GC_TORTURE(thr->heap);\n\n\tthr->ptr_curr_pc = &curr_pc;\n\n\t/* Relookup and initialize dispatch loop variables.  Debugger check. */\n\t{\n\t\tduk_activation *act;\n#if !defined(DUK_USE_EXEC_FUN_LOCAL)\n\t\tduk_hcompfunc *fun;\n#endif\n\n\t\t/* Assume interrupt init/counter are properly initialized here. */\n\t\t/* Assume that thr->valstack_bottom has been set-up before getting here. */\n\n\t\tact = thr->callstack_curr;\n\t\tDUK_ASSERT(act != NULL);\n\t\tfun = (duk_hcompfunc *) DUK_ACT_GET_FUNC(act);\n\t\tDUK_ASSERT(fun != NULL);\n\t\tDUK_ASSERT(thr->valstack_top - thr->valstack_bottom == fun->nregs);\n\t\tconsts = DUK_HCOMPFUNC_GET_CONSTS_BASE(thr->heap, fun);\n\t\tDUK_ASSERT(consts != NULL);\n\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\t\tif (duk_debug_is_attached(thr->heap) && !thr->heap->dbg_processing) {\n\t\t\tduk__executor_recheck_debugger(thr, act, fun);\n\t\t\tact = thr->callstack_curr;  /* relookup after side effects (no side effects currently however) */\n\t\t\tDUK_ASSERT(act != NULL);\n\t\t}\n#endif  /* DUK_USE_DEBUGGER_SUPPORT */\n\n#if defined(DUK_USE_ASSERTIONS)\n\t\tvalstack_top_base = (duk_size_t) (thr->valstack_top - thr->valstack);\n#endif\n\n\t\t/* Set up curr_pc for opcode dispatch. */\n\t\tcurr_pc = act->curr_pc;\n\t}\n\n\tDUK_DD(DUK_DDPRINT(\"restarting execution, thr %p, act idx %ld, fun %p,\"\n\t                   \"consts %p, funcs %p, lev %ld, regbot %ld, regtop %ld, catchstack_top=%ld, \"\n\t                   \"preventcount=%ld\",\n\t                   (void *) thr,\n\t                   (long) (thr->callstack_top - 1),\n\t                   (void *) DUK__FUN(),\n\t                   (void *) DUK_HCOMPFUNC_GET_CONSTS_BASE(thr->heap, DUK__FUN()),\n\t                   (void *) DUK_HCOMPFUNC_GET_FUNCS_BASE(thr->heap, DUK__FUN()),\n\t                   (long) (thr->callstack_top - 1),\n\t                   (long) (thr->valstack_bottom - thr->valstack),\n\t                   (long) (thr->valstack_top - thr->valstack),\n\t                   (long) thr->catchstack_top,\n\t                   (long) thr->callstack_preventcount));\n\n\t/* Dispatch loop. */\n\n\tfor (;;) {\n\t\tduk_uint8_t op;\n\n\t\tDUK_ASSERT(thr->callstack_top >= 1);\n\t\tDUK_ASSERT(thr->valstack_top - thr->valstack_bottom == DUK__FUN()->nregs);\n\t\tDUK_ASSERT((duk_size_t) (thr->valstack_top - thr->valstack) == valstack_top_base);\n\n\t\t/* Executor interrupt counter check, used to implement breakpoints,\n\t\t * debugging interface, execution timeouts, etc.  The counter is heap\n\t\t * specific but is maintained in the current thread to make the check\n\t\t * as fast as possible.  The counter is copied back to the heap struct\n\t\t * whenever a thread switch occurs by the DUK_HEAP_SWITCH_THREAD() macro.\n\t\t */\n#if defined(DUK_USE_INTERRUPT_COUNTER)\n\t\tint_ctr = thr->interrupt_counter;\n\t\tif (DUK_LIKELY(int_ctr > 0)) {\n\t\t\tthr->interrupt_counter = int_ctr - 1;\n\t\t} else {\n\t\t\t/* Trigger at zero or below */\n\t\t\tduk_small_uint_t exec_int_ret;\n\n\t\t\t/* Write curr_pc back for the debugger. */\n\t\t\t{\n\t\t\t\tduk_activation *act;\n\t\t\t\tDUK_ASSERT(thr->callstack_top > 0);\n\t\t\t\tact = thr->callstack_curr;\n\t\t\t\tDUK_ASSERT(act != NULL);\n\t\t\t\tact->curr_pc = (duk_instr_t *) curr_pc;\n\t\t\t}\n\n\t\t\t/* Force restart caused by a function return; must recheck\n\t\t\t * debugger breakpoints before checking line transitions,\n\t\t\t * see GH-303.  Restart and then handle interrupt_counter\n\t\t\t * zero again.\n\t\t\t */\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\t\t\tif (thr->heap->dbg_force_restart) {\n\t\t\t\tDUK_DD(DUK_DDPRINT(\"dbg_force_restart flag forced restart execution\"));  /* GH-303 */\n\t\t\t\tthr->heap->dbg_force_restart = 0;\n\t\t\t\tgoto restart_execution;\n\t\t\t}\n#endif\n\n\t\t\texec_int_ret = duk__executor_interrupt(thr);\n\t\t\tif (exec_int_ret == DUK__INT_RESTART) {\n\t\t\t\t/* curr_pc synced back above */\n\t\t\t\tgoto restart_execution;\n\t\t\t}\n\t\t}\n#endif  /* DUK_USE_INTERRUPT_COUNTER */\n#if defined(DUK_USE_INTERRUPT_COUNTER) && defined(DUK_USE_DEBUG)\n\t\t/* For cross-checking during development: ensure dispatch count\n\t\t * matches cumulative interrupt counter init value sums.\n\t\t */\n\t\tthr->heap->inst_count_exec++;\n#endif\n\n#if defined(DUK_USE_ASSERTIONS) || defined(DUK_USE_DEBUG)\n\t\t{\n\t\t\tduk_activation *act;\n\t\t\tact = thr->callstack_curr;\n\t\t\tDUK_ASSERT(curr_pc >= DUK_HCOMPFUNC_GET_CODE_BASE(thr->heap, DUK__FUN()));\n\t\t\tDUK_ASSERT(curr_pc < DUK_HCOMPFUNC_GET_CODE_END(thr->heap, DUK__FUN()));\n\t\t\tDUK_UNREF(act);  /* if debugging disabled */\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"executing bytecode: pc=%ld, ins=0x%08lx, op=%ld, valstack_top=%ld/%ld, nregs=%ld  -->  %!I\",\n\t\t\t                     (long) (curr_pc - DUK_HCOMPFUNC_GET_CODE_BASE(thr->heap, DUK__FUN())),\n\t\t\t                     (unsigned long) *curr_pc,\n\t\t\t                     (long) DUK_DEC_OP(*curr_pc),\n\t\t\t                     (long) (thr->valstack_top - thr->valstack),\n\t\t\t                     (long) (thr->valstack_end - thr->valstack),\n\t\t\t                     (long) (DUK__FUN() ? DUK__FUN()->nregs : -1),\n\t\t\t                     (duk_instr_t) *curr_pc));\n\t\t}\n#endif\n\n#if defined(DUK_USE_ASSERTIONS)\n\t\t/* Quite heavy assert: check valstack policy.  Improper\n\t\t * shuffle instructions can write beyond valstack_top/end\n\t\t * so this check catches them in the act.\n\t\t */\n\t\t{\n\t\t\tduk_tval *tv;\n\t\t\ttv = thr->valstack_top;\n\t\t\twhile (tv != thr->valstack_end) {\n\t\t\t\tDUK_ASSERT(DUK_TVAL_IS_UNDEFINED(tv));\n\t\t\t\ttv++;\n\t\t\t}\n\t\t}\n#endif\n\n\t\tins = *curr_pc++;\n\n\t\t/* Typing: use duk_small_(u)int_fast_t when decoding small\n\t\t * opcode fields (op, A, B, C, BC) which fit into 16 bits\n\t\t * and duk_(u)int_fast_t when decoding larger fields (e.g.\n\t\t * ABC).  Use unsigned variant by default, signed when the\n\t\t * value is used in signed arithmetic.  Using variable names\n\t\t * such as 'a', 'b', 'c', 'bc', etc makes it easier to spot\n\t\t * typing mismatches.\n\t\t */\n\n\t\t/* Switch based on opcode.  Cast to 8-bit unsigned value and\n\t\t * use a fully populated case clauses so that the compiler\n\t\t * will (at least usually) omit a bounds check.\n\t\t */\n\t\top = (duk_uint8_t) DUK_DEC_OP(ins);\n\t\tswitch (op) {\n\n\t\t/* Some useful macros.  These access inner executor variables\n\t\t * directly so they only apply within the executor.\n\t\t */\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n#define DUK__REPLACE_TOP_A_BREAK() { goto replace_top_a; }\n#define DUK__REPLACE_TOP_BC_BREAK() { goto replace_top_bc; }\n#define DUK__REPLACE_BOOL_A_BREAK(bval) { \\\n\t\tduk_bool_t duk__bval; \\\n\t\tduk__bval = (bval); \\\n\t\tDUK_ASSERT(duk__bval == 0 || duk__bval == 1); \\\n\t\tduk_push_boolean((duk_context *) thr, duk__bval); \\\n\t\tDUK__REPLACE_TOP_A_BREAK(); \\\n\t}\n#else\n#define DUK__REPLACE_TOP_A_BREAK() { DUK__REPLACE_TO_TVPTR(thr, DUK__REGP_A(ins)); break; }\n#define DUK__REPLACE_TOP_BC_BREAK() { DUK__REPLACE_TO_TVPTR(thr, DUK__REGP_BC(ins)); break; }\n#define DUK__REPLACE_BOOL_A_BREAK(bval) { \\\n\t\tduk_bool_t duk__bval; \\\n\t\tduk_tval *duk__tvdst; \\\n\t\tduk__bval = (bval); \\\n\t\tDUK_ASSERT(duk__bval == 0 || duk__bval == 1); \\\n\t\tduk__tvdst = DUK__REGP_A(ins); \\\n\t\tDUK_TVAL_SET_BOOLEAN_UPDREF(thr, duk__tvdst, duk__bval); \\\n\t\tbreak; \\\n\t}\n#endif\n\n\t\t/* XXX: 12 + 12 bit variant might make sense too, for both reg and\n\t\t * const loads.\n\t\t */\n\n\t\t/* For LDREG, STREG, LDCONST footprint optimized variants would just\n\t\t * duk_dup() + duk_replace(), but because they're used quite a lot\n\t\t * they're currently intentionally not size optimized.\n\t\t */\n\t\tcase DUK_OP_LDREG: {\n\t\t\tduk_tval *tv1, *tv2;\n\n\t\t\ttv1 = DUK__REGP_A(ins);\n\t\t\ttv2 = DUK__REGP_BC(ins);\n\t\t\tDUK_TVAL_SET_TVAL_UPDREF_FAST(thr, tv1, tv2);  /* side effects */\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_STREG: {\n\t\t\tduk_tval *tv1, *tv2;\n\n\t\t\ttv1 = DUK__REGP_A(ins);\n\t\t\ttv2 = DUK__REGP_BC(ins);\n\t\t\tDUK_TVAL_SET_TVAL_UPDREF_FAST(thr, tv2, tv1);  /* side effects */\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_LDCONST: {\n\t\t\tduk_tval *tv1, *tv2;\n\n\t\t\ttv1 = DUK__REGP_A(ins);\n\t\t\ttv2 = DUK__CONSTP_BC(ins);\n\t\t\tDUK_TVAL_SET_TVAL_UPDREF_FAST(thr, tv1, tv2);  /* side effects */\n\t\t\tbreak;\n\t\t}\n\n\t\t/* LDINT and LDINTX are intended to load an arbitrary signed\n\t\t * 32-bit value.  Only an LDINT+LDINTX sequence is supported.\n\t\t * This also guarantees all values remain fastints.\n\t\t */\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n\t\tcase DUK_OP_LDINT: {\n\t\t\tduk_int32_t val;\n\n\t\t\tval = (duk_int32_t) DUK_DEC_BC(ins) - (duk_int32_t) DUK_BC_LDINT_BIAS;\n\t\t\tduk_push_int((duk_context *) thr, val);\n\t\t\tDUK__REPLACE_TOP_A_BREAK();\n\t\t}\n\t\tcase DUK_OP_LDINTX: {\n\t\t\tduk_int32_t val;\n\n\t\t\tval = (duk_int32_t) duk_get_int((duk_context *) thr, DUK_DEC_A(ins));\n\t\t\tval = (val << DUK_BC_LDINTX_SHIFT) + (duk_int32_t) DUK_DEC_BC(ins);  /* no bias */\n\t\t\tduk_push_int((duk_context *) thr, val);\n\t\t\tDUK__REPLACE_TOP_A_BREAK();\n\t\t}\n#else  /* DUK_USE_EXEC_PREFER_SIZE */\n\t\tcase DUK_OP_LDINT: {\n\t\t\tduk_tval *tv1;\n\t\t\tduk_int32_t val;\n\n\t\t\tval = (duk_int32_t) DUK_DEC_BC(ins) - (duk_int32_t) DUK_BC_LDINT_BIAS;\n\t\t\ttv1 = DUK__REGP_A(ins);\n\t\t\tDUK_TVAL_SET_I32_UPDREF(thr, tv1, val);  /* side effects */\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_LDINTX: {\n\t\t\tduk_tval *tv1;\n\t\t\tduk_int32_t val;\n\n\t\t\ttv1 = DUK__REGP_A(ins);\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv1));\n#if defined(DUK_USE_FASTINT)\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_FASTINT(tv1));\n\t\t\tval = DUK_TVAL_GET_FASTINT_I32(tv1);\n#else\n\t\t\t/* XXX: fast double-to-int conversion, we know number is integer in [-0x80000000,0xffffffff]. */\n\t\t\tval = (duk_int32_t) DUK_TVAL_GET_NUMBER(tv1);\n#endif\n\t\t\tval = (val << DUK_BC_LDINTX_SHIFT) + (duk_int32_t) DUK_DEC_BC(ins);  /* no bias */\n\t\t\tDUK_TVAL_SET_I32_UPDREF(thr, tv1, val);  /* side effects */\n\t\t\tbreak;\n\t\t}\n#endif  /* DUK_USE_EXEC_PREFER_SIZE */\n\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n\t\tcase DUK_OP_LDTHIS: {\n\t\t\tduk_push_this((duk_context *) thr);\n\t\t\tDUK__REPLACE_TOP_BC_BREAK();\n\t\t}\n\t\tcase DUK_OP_LDUNDEF: {\n\t\t\tduk_to_undefined((duk_context *) thr, (duk_idx_t) DUK_DEC_BC(ins));\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_LDNULL: {\n\t\t\tduk_to_null((duk_context *) thr, (duk_idx_t) DUK_DEC_BC(ins));\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_LDTRUE: {\n\t\t\tduk_push_true((duk_context *) thr);\n\t\t\tDUK__REPLACE_TOP_BC_BREAK();\n\t\t}\n\t\tcase DUK_OP_LDFALSE: {\n\t\t\tduk_push_false((duk_context *) thr);\n\t\t\tDUK__REPLACE_TOP_BC_BREAK();\n\t\t}\n#else  /* DUK_USE_EXEC_PREFER_SIZE */\n\t\tcase DUK_OP_LDTHIS: {\n\t\t\t/* Note: 'this' may be bound to any value, not just an object */\n\t\t\tduk_tval *tv1, *tv2;\n\n\t\t\ttv1 = DUK__REGP_BC(ins);\n\t\t\ttv2 = thr->valstack_bottom - 1;  /* 'this binding' is just under bottom */\n\t\t\tDUK_ASSERT(tv2 >= thr->valstack);\n\t\t\tDUK_TVAL_SET_TVAL_UPDREF_FAST(thr, tv1, tv2);  /* side effects */\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_LDUNDEF: {\n\t\t\tduk_tval *tv1;\n\n\t\t\ttv1 = DUK__REGP_BC(ins);\n\t\t\tDUK_TVAL_SET_UNDEFINED_UPDREF(thr, tv1);  /* side effects */\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_LDNULL: {\n\t\t\tduk_tval *tv1;\n\n\t\t\ttv1 = DUK__REGP_BC(ins);\n\t\t\tDUK_TVAL_SET_NULL_UPDREF(thr, tv1);  /* side effects */\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_LDTRUE: {\n\t\t\tduk_tval *tv1;\n\n\t\t\ttv1 = DUK__REGP_BC(ins);\n\t\t\tDUK_TVAL_SET_BOOLEAN_UPDREF(thr, tv1, 1);  /* side effects */\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_LDFALSE: {\n\t\t\tduk_tval *tv1;\n\n\t\t\ttv1 = DUK__REGP_BC(ins);\n\t\t\tDUK_TVAL_SET_BOOLEAN_UPDREF(thr, tv1, 0);  /* side effects */\n\t\t\tbreak;\n\t\t}\n#endif  /* DUK_USE_EXEC_PREFER_SIZE */\n\n\t\tcase DUK_OP_BNOT: {\n\t\t\tduk__vm_bitwise_not(thr, DUK_DEC_BC(ins), DUK_DEC_A(ins));\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_LNOT: {\n\t\t\tduk__vm_logical_not(thr, DUK_DEC_BC(ins), DUK_DEC_A(ins));\n\t\t\tbreak;\n\t\t}\n\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n\t\tcase DUK_OP_UNM:\n\t\tcase DUK_OP_UNP: {\n\t\t\tduk__vm_arith_unary_op(thr, DUK_DEC_BC(ins), DUK_DEC_A(ins), op);\n\t\t\tbreak;\n\t\t}\n#else  /* DUK_USE_EXEC_PREFER_SIZE */\n\t\tcase DUK_OP_UNM: {\n\t\t\tduk__vm_arith_unary_op(thr, DUK_DEC_BC(ins), DUK_DEC_A(ins), DUK_OP_UNM);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_UNP: {\n\t\t\tduk__vm_arith_unary_op(thr, DUK_DEC_BC(ins), DUK_DEC_A(ins), DUK_OP_UNP);\n\t\t\tbreak;\n\t\t}\n#endif  /* DUK_USE_EXEC_PREFER_SIZE */\n\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n\t\tcase DUK_OP_TYPEOF: {\n\t\t\tduk_small_uint_t stridx;\n\n\t\t\tstridx = duk_js_typeof_stridx(DUK__REGP_BC(ins));\n\t\t\tDUK_ASSERT(stridx >= 0 && stridx < DUK_HEAP_NUM_STRINGS);\n\t\t\tduk_push_hstring_stridx((duk_context *) thr, stridx);\n\t\t\tDUK__REPLACE_TOP_A_BREAK();\n\t\t}\n#else  /* DUK_USE_EXEC_PREFER_SIZE */\n\t\tcase DUK_OP_TYPEOF: {\n\t\t\tduk_tval *tv;\n\t\t\tduk_small_uint_t stridx;\n\t\t\tduk_hstring *h_str;\n\n\t\t\ttv = DUK__REGP_BC(ins);\n\t\t\tstridx = duk_js_typeof_stridx(tv);\n\t\t\tDUK_ASSERT_STRIDX_VALID(stridx);\n\t\t\th_str = DUK_HTHREAD_GET_STRING(thr, stridx);\n\t\t\ttv = DUK__REGP_A(ins);\n\t\t\tDUK_TVAL_SET_STRING_UPDREF(thr, tv, h_str);\n\t\t\tbreak;\n\t\t}\n#endif  /* DUK_USE_EXEC_PREFER_SIZE */\n\n\t\tcase DUK_OP_TYPEOFID: {\n\t\t\tduk_context *ctx = (duk_context *) thr;\n\t\t\tduk_small_uint_t stridx;\n#if !defined(DUK_USE_EXEC_PREFER_SIZE)\n\t\t\tduk_hstring *h_str;\n#endif\n\t\t\tduk_activation *act;\n\t\t\tduk_hstring *name;\n\t\t\tduk_tval *tv;\n\n\t\t\t/* A -> target register\n\t\t\t * BC -> constant index of identifier name\n\t\t\t */\n\n\t\t\ttv = DUK__CONSTP_BC(ins);\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_STRING(tv));\n\t\t\tname = DUK_TVAL_GET_STRING(tv);\n\t\t\ttv = NULL;  /* lookup has side effects */\n\t\t\tact = thr->callstack_curr;\n\t\t\tif (duk_js_getvar_activation(thr, act, name, 0 /*throw*/)) {\n\t\t\t\t/* -> [... val this] */\n\t\t\t\ttv = DUK_GET_TVAL_NEGIDX(ctx, -2);\n\t\t\t\tstridx = duk_js_typeof_stridx(tv);\n\t\t\t\ttv = NULL;  /* no longer needed */\n\t\t\t\tduk_pop_2(ctx);\n\t\t\t} else {\n\t\t\t\t/* unresolvable, no stack changes */\n\t\t\t\tstridx = DUK_STRIDX_LC_UNDEFINED;\n\t\t\t}\n\t\t\tDUK_ASSERT_STRIDX_VALID(stridx);\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n\t\t\tduk_push_hstring_stridx(ctx, stridx);\n\t\t\tDUK__REPLACE_TOP_A_BREAK();\n#else  /* DUK_USE_EXEC_PREFER_SIZE */\n\t\t\th_str = DUK_HTHREAD_GET_STRING(thr, stridx);\n\t\t\ttv = DUK__REGP_A(ins);\n\t\t\tDUK_TVAL_SET_STRING_UPDREF(thr, tv, h_str);\n\t\t\tbreak;\n#endif  /* DUK_USE_EXEC_PREFER_SIZE */\n\t\t}\n\n\t\t/* Equality: E5 Sections 11.9.1, 11.9.3 */\n\n#define DUK__EQ_BODY(barg,carg) { \\\n\t\tduk_bool_t tmp; \\\n\t\ttmp = duk_js_equals(thr, (barg), (carg)); \\\n\t\tDUK_ASSERT(tmp == 0 || tmp == 1); \\\n\t\tDUK__REPLACE_BOOL_A_BREAK(tmp); \\\n\t}\n#define DUK__NEQ_BODY(barg,carg) { \\\n\t\tduk_bool_t tmp; \\\n\t\ttmp = duk_js_equals(thr, (barg), (carg)); \\\n\t\tDUK_ASSERT(tmp == 0 || tmp == 1); \\\n\t\ttmp ^= 1; \\\n\t\tDUK__REPLACE_BOOL_A_BREAK(tmp); \\\n\t}\n#define DUK__SEQ_BODY(barg,carg) { \\\n\t\tduk_bool_t tmp; \\\n\t\ttmp = duk_js_strict_equals((barg), (carg)); \\\n\t\tDUK_ASSERT(tmp == 0 || tmp == 1); \\\n\t\tDUK__REPLACE_BOOL_A_BREAK(tmp); \\\n\t}\n#define DUK__SNEQ_BODY(barg,carg) { \\\n\t\tduk_bool_t tmp; \\\n\t\ttmp = duk_js_strict_equals((barg), (carg)); \\\n\t\tDUK_ASSERT(tmp == 0 || tmp == 1); \\\n\t\ttmp ^= 1; \\\n\t\tDUK__REPLACE_BOOL_A_BREAK(tmp); \\\n\t}\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n\t\tcase DUK_OP_EQ_RR:\n\t\tcase DUK_OP_EQ_CR:\n\t\tcase DUK_OP_EQ_RC:\n\t\tcase DUK_OP_EQ_CC:\n\t\t\tDUK__EQ_BODY(DUK__REGCONSTP_B(ins), DUK__REGCONSTP_C(ins));\n\t\tcase DUK_OP_NEQ_RR:\n\t\tcase DUK_OP_NEQ_CR:\n\t\tcase DUK_OP_NEQ_RC:\n\t\tcase DUK_OP_NEQ_CC:\n\t\t\tDUK__NEQ_BODY(DUK__REGCONSTP_B(ins), DUK__REGCONSTP_C(ins));\n\t\tcase DUK_OP_SEQ_RR:\n\t\tcase DUK_OP_SEQ_CR:\n\t\tcase DUK_OP_SEQ_RC:\n\t\tcase DUK_OP_SEQ_CC:\n\t\t\tDUK__SEQ_BODY(DUK__REGCONSTP_B(ins), DUK__REGCONSTP_C(ins));\n\t\tcase DUK_OP_SNEQ_RR:\n\t\tcase DUK_OP_SNEQ_CR:\n\t\tcase DUK_OP_SNEQ_RC:\n\t\tcase DUK_OP_SNEQ_CC:\n\t\t\tDUK__SNEQ_BODY(DUK__REGCONSTP_B(ins), DUK__REGCONSTP_C(ins));\n#else  /* DUK_USE_EXEC_PREFER_SIZE */\n\t\tcase DUK_OP_EQ_RR:\n\t\t\tDUK__EQ_BODY(DUK__REGP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_EQ_CR:\n\t\t\tDUK__EQ_BODY(DUK__CONSTP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_EQ_RC:\n\t\t\tDUK__EQ_BODY(DUK__REGP_B(ins), DUK__CONSTP_C(ins));\n\t\tcase DUK_OP_EQ_CC:\n\t\t\tDUK__EQ_BODY(DUK__CONSTP_B(ins), DUK__CONSTP_C(ins));\n\t\tcase DUK_OP_NEQ_RR:\n\t\t\tDUK__NEQ_BODY(DUK__REGP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_NEQ_CR:\n\t\t\tDUK__NEQ_BODY(DUK__CONSTP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_NEQ_RC:\n\t\t\tDUK__NEQ_BODY(DUK__REGP_B(ins), DUK__CONSTP_C(ins));\n\t\tcase DUK_OP_NEQ_CC:\n\t\t\tDUK__NEQ_BODY(DUK__CONSTP_B(ins), DUK__CONSTP_C(ins));\n\t\tcase DUK_OP_SEQ_RR:\n\t\t\tDUK__SEQ_BODY(DUK__REGP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_SEQ_CR:\n\t\t\tDUK__SEQ_BODY(DUK__CONSTP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_SEQ_RC:\n\t\t\tDUK__SEQ_BODY(DUK__REGP_B(ins), DUK__CONSTP_C(ins));\n\t\tcase DUK_OP_SEQ_CC:\n\t\t\tDUK__SEQ_BODY(DUK__CONSTP_B(ins), DUK__CONSTP_C(ins));\n\t\tcase DUK_OP_SNEQ_RR:\n\t\t\tDUK__SNEQ_BODY(DUK__REGP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_SNEQ_CR:\n\t\t\tDUK__SNEQ_BODY(DUK__CONSTP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_SNEQ_RC:\n\t\t\tDUK__SNEQ_BODY(DUK__REGP_B(ins), DUK__CONSTP_C(ins));\n\t\tcase DUK_OP_SNEQ_CC:\n\t\t\tDUK__SNEQ_BODY(DUK__CONSTP_B(ins), DUK__CONSTP_C(ins));\n#endif  /* DUK_USE_EXEC_PREFER_SIZE */\n\n#define DUK__COMPARE_BODY(arg1,arg2,flags) { \\\n\t\tduk_bool_t tmp; \\\n\t\ttmp = duk_js_compare_helper(thr, (arg1), (arg2), (flags)); \\\n\t\tDUK_ASSERT(tmp == 0 || tmp == 1); \\\n\t\tDUK__REPLACE_BOOL_A_BREAK(tmp); \\\n\t}\n#define DUK__GT_BODY(barg,carg) DUK__COMPARE_BODY((carg), (barg), 0)\n#define DUK__GE_BODY(barg,carg) DUK__COMPARE_BODY((barg), (carg), DUK_COMPARE_FLAG_EVAL_LEFT_FIRST | DUK_COMPARE_FLAG_NEGATE)\n#define DUK__LT_BODY(barg,carg) DUK__COMPARE_BODY((barg), (carg), DUK_COMPARE_FLAG_EVAL_LEFT_FIRST)\n#define DUK__LE_BODY(barg,carg) DUK__COMPARE_BODY((carg), (barg), DUK_COMPARE_FLAG_NEGATE)\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n\t\tcase DUK_OP_GT_RR:\n\t\tcase DUK_OP_GT_CR:\n\t\tcase DUK_OP_GT_RC:\n\t\tcase DUK_OP_GT_CC:\n\t\t\tDUK__GT_BODY(DUK__REGCONSTP_B(ins), DUK__REGCONSTP_C(ins));\n\t\tcase DUK_OP_GE_RR:\n\t\tcase DUK_OP_GE_CR:\n\t\tcase DUK_OP_GE_RC:\n\t\tcase DUK_OP_GE_CC:\n\t\t\tDUK__GE_BODY(DUK__REGCONSTP_B(ins), DUK__REGCONSTP_C(ins));\n\t\tcase DUK_OP_LT_RR:\n\t\tcase DUK_OP_LT_CR:\n\t\tcase DUK_OP_LT_RC:\n\t\tcase DUK_OP_LT_CC:\n\t\t\tDUK__LT_BODY(DUK__REGCONSTP_B(ins), DUK__REGCONSTP_C(ins));\n\t\tcase DUK_OP_LE_RR:\n\t\tcase DUK_OP_LE_CR:\n\t\tcase DUK_OP_LE_RC:\n\t\tcase DUK_OP_LE_CC:\n\t\t\tDUK__LE_BODY(DUK__REGCONSTP_B(ins), DUK__REGCONSTP_C(ins));\n#else  /* DUK_USE_EXEC_PREFER_SIZE */\n\t\tcase DUK_OP_GT_RR:\n\t\t\tDUK__GT_BODY(DUK__REGP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_GT_CR:\n\t\t\tDUK__GT_BODY(DUK__CONSTP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_GT_RC:\n\t\t\tDUK__GT_BODY(DUK__REGP_B(ins), DUK__CONSTP_C(ins));\n\t\tcase DUK_OP_GT_CC:\n\t\t\tDUK__GT_BODY(DUK__CONSTP_B(ins), DUK__CONSTP_C(ins));\n\t\tcase DUK_OP_GE_RR:\n\t\t\tDUK__GE_BODY(DUK__REGP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_GE_CR:\n\t\t\tDUK__GE_BODY(DUK__CONSTP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_GE_RC:\n\t\t\tDUK__GE_BODY(DUK__REGP_B(ins), DUK__CONSTP_C(ins));\n\t\tcase DUK_OP_GE_CC:\n\t\t\tDUK__GE_BODY(DUK__CONSTP_B(ins), DUK__CONSTP_C(ins));\n\t\tcase DUK_OP_LT_RR:\n\t\t\tDUK__LT_BODY(DUK__REGP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_LT_CR:\n\t\t\tDUK__LT_BODY(DUK__CONSTP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_LT_RC:\n\t\t\tDUK__LT_BODY(DUK__REGP_B(ins), DUK__CONSTP_C(ins));\n\t\tcase DUK_OP_LT_CC:\n\t\t\tDUK__LT_BODY(DUK__CONSTP_B(ins), DUK__CONSTP_C(ins));\n\t\tcase DUK_OP_LE_RR:\n\t\t\tDUK__LE_BODY(DUK__REGP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_LE_CR:\n\t\t\tDUK__LE_BODY(DUK__CONSTP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_LE_RC:\n\t\t\tDUK__LE_BODY(DUK__REGP_B(ins), DUK__CONSTP_C(ins));\n\t\tcase DUK_OP_LE_CC:\n\t\t\tDUK__LE_BODY(DUK__CONSTP_B(ins), DUK__CONSTP_C(ins));\n#endif  /* DUK_USE_EXEC_PREFER_SIZE */\n\n\t\t/* No size optimized variant at present for IF. */\n\t\tcase DUK_OP_IFTRUE_R: {\n\t\t\tif (duk_js_toboolean(DUK__REGP_BC(ins)) != 0) {\n\t\t\t\tcurr_pc++;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_IFTRUE_C: {\n\t\t\tif (duk_js_toboolean(DUK__CONSTP_BC(ins)) != 0) {\n\t\t\t\tcurr_pc++;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_IFFALSE_R: {\n\t\t\tif (duk_js_toboolean(DUK__REGP_BC(ins)) == 0) {\n\t\t\t\tcurr_pc++;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_IFFALSE_C: {\n\t\t\tif (duk_js_toboolean(DUK__CONSTP_BC(ins)) == 0) {\n\t\t\t\tcurr_pc++;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n\t\tcase DUK_OP_ADD_RR:\n\t\tcase DUK_OP_ADD_CR:\n\t\tcase DUK_OP_ADD_RC:\n\t\tcase DUK_OP_ADD_CC: {\n\t\t\t/* XXX: could leave value on stack top and goto replace_top_a; */\n\t\t\tduk__vm_arith_add(thr, DUK__REGCONSTP_B(ins), DUK__REGCONSTP_C(ins), DUK_DEC_A(ins));\n\t\t\tbreak;\n\t\t}\n#else  /* DUK_USE_EXEC_PREFER_SIZE */\n\t\tcase DUK_OP_ADD_RR: {\n\t\t\tduk__vm_arith_add(thr, DUK__REGP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins));\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_ADD_CR: {\n\t\t\tduk__vm_arith_add(thr, DUK__CONSTP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins));\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_ADD_RC: {\n\t\t\tduk__vm_arith_add(thr, DUK__REGP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins));\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_ADD_CC: {\n\t\t\tduk__vm_arith_add(thr, DUK__CONSTP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins));\n\t\t\tbreak;\n\t\t}\n#endif  /* DUK_USE_EXEC_PREFER_SIZE */\n\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n\t\tcase DUK_OP_SUB_RR:\n\t\tcase DUK_OP_SUB_CR:\n\t\tcase DUK_OP_SUB_RC:\n\t\tcase DUK_OP_SUB_CC:\n\t\tcase DUK_OP_MUL_RR:\n\t\tcase DUK_OP_MUL_CR:\n\t\tcase DUK_OP_MUL_RC:\n\t\tcase DUK_OP_MUL_CC:\n\t\tcase DUK_OP_DIV_RR:\n\t\tcase DUK_OP_DIV_CR:\n\t\tcase DUK_OP_DIV_RC:\n\t\tcase DUK_OP_DIV_CC:\n\t\tcase DUK_OP_MOD_RR:\n\t\tcase DUK_OP_MOD_CR:\n\t\tcase DUK_OP_MOD_RC:\n\t\tcase DUK_OP_MOD_CC:\n#if defined(DUK_USE_ES7_EXP_OPERATOR)\n\t\tcase DUK_OP_EXP_RR:\n\t\tcase DUK_OP_EXP_CR:\n\t\tcase DUK_OP_EXP_RC:\n\t\tcase DUK_OP_EXP_CC:\n#endif  /* DUK_USE_ES7_EXP_OPERATOR */\n\t\t{\n\t\t\t/* XXX: could leave value on stack top and goto replace_top_a; */\n\t\t\tduk__vm_arith_binary_op(thr, DUK__REGCONSTP_B(ins), DUK__REGCONSTP_C(ins), DUK_DEC_A(ins), op);\n\t\t\tbreak;\n\t\t}\n#else  /* DUK_USE_EXEC_PREFER_SIZE */\n\t\tcase DUK_OP_SUB_RR: {\n\t\t\tduk__vm_arith_binary_op(thr, DUK__REGP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins), DUK_OP_SUB);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_SUB_CR: {\n\t\t\tduk__vm_arith_binary_op(thr, DUK__CONSTP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins), DUK_OP_SUB);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_SUB_RC: {\n\t\t\tduk__vm_arith_binary_op(thr, DUK__REGP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins), DUK_OP_SUB);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_SUB_CC: {\n\t\t\tduk__vm_arith_binary_op(thr, DUK__CONSTP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins), DUK_OP_SUB);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_MUL_RR: {\n\t\t\tduk__vm_arith_binary_op(thr, DUK__REGP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins), DUK_OP_MUL);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_MUL_CR: {\n\t\t\tduk__vm_arith_binary_op(thr, DUK__CONSTP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins), DUK_OP_MUL);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_MUL_RC: {\n\t\t\tduk__vm_arith_binary_op(thr, DUK__REGP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins), DUK_OP_MUL);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_MUL_CC: {\n\t\t\tduk__vm_arith_binary_op(thr, DUK__CONSTP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins), DUK_OP_MUL);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_DIV_RR: {\n\t\t\tduk__vm_arith_binary_op(thr, DUK__REGP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins), DUK_OP_DIV);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_DIV_CR: {\n\t\t\tduk__vm_arith_binary_op(thr, DUK__CONSTP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins), DUK_OP_DIV);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_DIV_RC: {\n\t\t\tduk__vm_arith_binary_op(thr, DUK__REGP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins), DUK_OP_DIV);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_DIV_CC: {\n\t\t\tduk__vm_arith_binary_op(thr, DUK__CONSTP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins), DUK_OP_DIV);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_MOD_RR: {\n\t\t\tduk__vm_arith_binary_op(thr, DUK__REGP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins), DUK_OP_MOD);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_MOD_CR: {\n\t\t\tduk__vm_arith_binary_op(thr, DUK__CONSTP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins), DUK_OP_MOD);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_MOD_RC: {\n\t\t\tduk__vm_arith_binary_op(thr, DUK__REGP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins), DUK_OP_MOD);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_MOD_CC: {\n\t\t\tduk__vm_arith_binary_op(thr, DUK__CONSTP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins), DUK_OP_MOD);\n\t\t\tbreak;\n\t\t}\n#if defined(DUK_USE_ES7_EXP_OPERATOR)\n\t\tcase DUK_OP_EXP_RR: {\n\t\t\tduk__vm_arith_binary_op(thr, DUK__REGP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins), DUK_OP_EXP);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_EXP_CR: {\n\t\t\tduk__vm_arith_binary_op(thr, DUK__CONSTP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins), DUK_OP_EXP);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_EXP_RC: {\n\t\t\tduk__vm_arith_binary_op(thr, DUK__REGP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins), DUK_OP_EXP);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_EXP_CC: {\n\t\t\tduk__vm_arith_binary_op(thr, DUK__CONSTP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins), DUK_OP_EXP);\n\t\t\tbreak;\n\t\t}\n#endif  /* DUK_USE_ES7_EXP_OPERATOR */\n#endif  /* DUK_USE_EXEC_PREFER_SIZE */\n\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n\t\tcase DUK_OP_BAND_RR:\n\t\tcase DUK_OP_BAND_CR:\n\t\tcase DUK_OP_BAND_RC:\n\t\tcase DUK_OP_BAND_CC:\n\t\tcase DUK_OP_BOR_RR:\n\t\tcase DUK_OP_BOR_CR:\n\t\tcase DUK_OP_BOR_RC:\n\t\tcase DUK_OP_BOR_CC:\n\t\tcase DUK_OP_BXOR_RR:\n\t\tcase DUK_OP_BXOR_CR:\n\t\tcase DUK_OP_BXOR_RC:\n\t\tcase DUK_OP_BXOR_CC:\n\t\tcase DUK_OP_BASL_RR:\n\t\tcase DUK_OP_BASL_CR:\n\t\tcase DUK_OP_BASL_RC:\n\t\tcase DUK_OP_BASL_CC:\n\t\tcase DUK_OP_BLSR_RR:\n\t\tcase DUK_OP_BLSR_CR:\n\t\tcase DUK_OP_BLSR_RC:\n\t\tcase DUK_OP_BLSR_CC:\n\t\tcase DUK_OP_BASR_RR:\n\t\tcase DUK_OP_BASR_CR:\n\t\tcase DUK_OP_BASR_RC:\n\t\tcase DUK_OP_BASR_CC: {\n\t\t\t/* XXX: could leave value on stack top and goto replace_top_a; */\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__REGCONSTP_B(ins), DUK__REGCONSTP_C(ins), DUK_DEC_A(ins), op);\n\t\t\tbreak;\n\t\t}\n#else  /* DUK_USE_EXEC_PREFER_SIZE */\n\t\tcase DUK_OP_BAND_RR: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__REGP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins), DUK_OP_BAND);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BAND_CR: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__CONSTP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins), DUK_OP_BAND);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BAND_RC: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__REGP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins), DUK_OP_BAND);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BAND_CC: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__CONSTP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins), DUK_OP_BAND);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BOR_RR: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__REGP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins), DUK_OP_BOR);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BOR_CR: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__CONSTP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins), DUK_OP_BOR);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BOR_RC: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__REGP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins), DUK_OP_BOR);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BOR_CC: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__CONSTP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins), DUK_OP_BOR);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BXOR_RR: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__REGP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins), DUK_OP_BXOR);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BXOR_CR: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__CONSTP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins), DUK_OP_BXOR);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BXOR_RC: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__REGP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins), DUK_OP_BXOR);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BXOR_CC: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__CONSTP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins), DUK_OP_BXOR);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BASL_RR: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__REGP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins), DUK_OP_BASL);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BASL_CR: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__CONSTP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins), DUK_OP_BASL);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BASL_RC: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__REGP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins), DUK_OP_BASL);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BASL_CC: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__CONSTP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins), DUK_OP_BASL);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BLSR_RR: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__REGP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins), DUK_OP_BLSR);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BLSR_CR: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__CONSTP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins), DUK_OP_BLSR);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BLSR_RC: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__REGP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins), DUK_OP_BLSR);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BLSR_CC: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__CONSTP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins), DUK_OP_BLSR);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BASR_RR: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__REGP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins), DUK_OP_BASR);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BASR_CR: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__CONSTP_B(ins), DUK__REGP_C(ins), DUK_DEC_A(ins), DUK_OP_BASR);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BASR_RC: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__REGP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins), DUK_OP_BASR);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_BASR_CC: {\n\t\t\tduk__vm_bitwise_binary_op(thr, DUK__CONSTP_B(ins), DUK__CONSTP_C(ins), DUK_DEC_A(ins), DUK_OP_BASR);\n\t\t\tbreak;\n\t\t}\n#endif  /* DUK_USE_EXEC_PREFER_SIZE */\n\n\t\t/* For INSTOF and IN, B is always a register. */\n#define DUK__INSTOF_BODY(barg,carg) { \\\n\t\tduk_bool_t tmp; \\\n\t\ttmp = duk_js_instanceof(thr, (barg), (carg)); \\\n\t\tDUK_ASSERT(tmp == 0 || tmp == 1); \\\n\t\tDUK__REPLACE_BOOL_A_BREAK(tmp); \\\n\t}\n#define DUK__IN_BODY(barg,carg) { \\\n\t\tduk_bool_t tmp; \\\n\t\ttmp = duk_js_in(thr, (barg), (carg)); \\\n\t\tDUK_ASSERT(tmp == 0 || tmp == 1); \\\n\t\tDUK__REPLACE_BOOL_A_BREAK(tmp); \\\n\t}\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n\t\tcase DUK_OP_INSTOF_RR:\n\t\tcase DUK_OP_INSTOF_CR:\n\t\tcase DUK_OP_INSTOF_RC:\n\t\tcase DUK_OP_INSTOF_CC:\n\t\t\tDUK__INSTOF_BODY(DUK__REGCONSTP_B(ins), DUK__REGCONSTP_C(ins));\n\t\tcase DUK_OP_IN_RR:\n\t\tcase DUK_OP_IN_CR:\n\t\tcase DUK_OP_IN_RC:\n\t\tcase DUK_OP_IN_CC:\n\t\t\tDUK__IN_BODY(DUK__REGCONSTP_B(ins), DUK__REGCONSTP_C(ins));\n#else  /* DUK_USE_EXEC_PREFER_SIZE */\n\t\tcase DUK_OP_INSTOF_RR:\n\t\t\tDUK__INSTOF_BODY(DUK__REGP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_INSTOF_CR:\n\t\t\tDUK__INSTOF_BODY(DUK__CONSTP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_INSTOF_RC:\n\t\t\tDUK__INSTOF_BODY(DUK__REGP_B(ins), DUK__CONSTP_C(ins));\n\t\tcase DUK_OP_INSTOF_CC:\n\t\t\tDUK__INSTOF_BODY(DUK__CONSTP_B(ins), DUK__CONSTP_C(ins));\n\t\tcase DUK_OP_IN_RR:\n\t\t\tDUK__IN_BODY(DUK__REGP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_IN_CR:\n\t\t\tDUK__IN_BODY(DUK__CONSTP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_IN_RC:\n\t\t\tDUK__IN_BODY(DUK__REGP_B(ins), DUK__CONSTP_C(ins));\n\t\tcase DUK_OP_IN_CC:\n\t\t\tDUK__IN_BODY(DUK__CONSTP_B(ins), DUK__CONSTP_C(ins));\n#endif  /* DUK_USE_EXEC_PREFER_SIZE */\n\n\t\t/* Pre/post inc/dec for register variables, important for loops. */\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n\t\tcase DUK_OP_PREINCR:\n\t\tcase DUK_OP_PREDECR:\n\t\tcase DUK_OP_POSTINCR:\n\t\tcase DUK_OP_POSTDECR: {\n\t\t\tduk__prepost_incdec_reg_helper(thr, DUK__REGP_A(ins), DUK__REGP_BC(ins), op);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_PREINCV:\n\t\tcase DUK_OP_PREDECV:\n\t\tcase DUK_OP_POSTINCV:\n\t\tcase DUK_OP_POSTDECV: {\n\t\t\tduk__prepost_incdec_var_helper(thr, DUK_DEC_A(ins), DUK__CONSTP_BC(ins), op, DUK__STRICT());\n\t\t\tbreak;\n\t\t}\n#else  /* DUK_USE_EXEC_PREFER_SIZE */\n\t\tcase DUK_OP_PREINCR: {\n\t\t\tduk__prepost_incdec_reg_helper(thr, DUK__REGP_A(ins), DUK__REGP_BC(ins), DUK_OP_PREINCR);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_PREDECR: {\n\t\t\tduk__prepost_incdec_reg_helper(thr, DUK__REGP_A(ins), DUK__REGP_BC(ins), DUK_OP_PREDECR);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_POSTINCR: {\n\t\t\tduk__prepost_incdec_reg_helper(thr, DUK__REGP_A(ins), DUK__REGP_BC(ins), DUK_OP_POSTINCR);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_POSTDECR: {\n\t\t\tduk__prepost_incdec_reg_helper(thr, DUK__REGP_A(ins), DUK__REGP_BC(ins), DUK_OP_POSTDECR);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_PREINCV: {\n\t\t\tduk__prepost_incdec_var_helper(thr, DUK_DEC_A(ins), DUK__CONSTP_BC(ins), DUK_OP_PREINCV, DUK__STRICT());\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_PREDECV: {\n\t\t\tduk__prepost_incdec_var_helper(thr, DUK_DEC_A(ins), DUK__CONSTP_BC(ins), DUK_OP_PREDECV, DUK__STRICT());\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_POSTINCV: {\n\t\t\tduk__prepost_incdec_var_helper(thr, DUK_DEC_A(ins), DUK__CONSTP_BC(ins), DUK_OP_POSTINCV, DUK__STRICT());\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_OP_POSTDECV: {\n\t\t\tduk__prepost_incdec_var_helper(thr, DUK_DEC_A(ins), DUK__CONSTP_BC(ins), DUK_OP_POSTDECV, DUK__STRICT());\n\t\t\tbreak;\n\t\t}\n#endif  /* DUK_USE_EXEC_PREFER_SIZE */\n\n\t\t/* XXX: Move to separate helper, optimize for perf/size separately. */\n\t\t/* Preinc/predec for object properties. */\n\t\tcase DUK_OP_PREINCP_RR:\n\t\tcase DUK_OP_PREINCP_CR:\n\t\tcase DUK_OP_PREINCP_RC:\n\t\tcase DUK_OP_PREINCP_CC:\n\t\tcase DUK_OP_PREDECP_RR:\n\t\tcase DUK_OP_PREDECP_CR:\n\t\tcase DUK_OP_PREDECP_RC:\n\t\tcase DUK_OP_PREDECP_CC:\n\t\tcase DUK_OP_POSTINCP_RR:\n\t\tcase DUK_OP_POSTINCP_CR:\n\t\tcase DUK_OP_POSTINCP_RC:\n\t\tcase DUK_OP_POSTINCP_CC:\n\t\tcase DUK_OP_POSTDECP_RR:\n\t\tcase DUK_OP_POSTDECP_CR:\n\t\tcase DUK_OP_POSTDECP_RC:\n\t\tcase DUK_OP_POSTDECP_CC: {\n\t\t\tduk_context *ctx = (duk_context *) thr;\n\t\t\tduk_tval *tv_obj;\n\t\t\tduk_tval *tv_key;\n\t\t\tduk_tval *tv_val;\n\t\t\tduk_bool_t rc;\n\t\t\tduk_double_t x, y, z;\n#if !defined(DUK_USE_EXEC_PREFER_SIZE)\n\t\t\tduk_tval *tv_dst;\n#endif  /* DUK_USE_EXEC_PREFER_SIZE */\n\n\t\t\t/* A -> target reg\n\t\t\t * B -> object reg/const (may be const e.g. in \"'foo'[1]\")\n\t\t\t * C -> key reg/const\n\t\t\t */\n\n\t\t\t/* Opcode bits 0-1 are used to distinguish reg/const variants.\n\t\t\t * Opcode bits 2-3 are used to distinguish inc/dec variants:\n\t\t\t * Bit 2 = inc(0)/dec(1), bit 3 = pre(0)/post(1).\n\t\t\t */\n\t\t\tDUK_ASSERT((DUK_OP_PREINCP_RR & 0x0c) == 0x00);\n\t\t\tDUK_ASSERT((DUK_OP_PREDECP_RR & 0x0c) == 0x04);\n\t\t\tDUK_ASSERT((DUK_OP_POSTINCP_RR & 0x0c) == 0x08);\n\t\t\tDUK_ASSERT((DUK_OP_POSTDECP_RR & 0x0c) == 0x0c);\n\n\t\t\ttv_obj = DUK__REGCONSTP_B(ins);\n\t\t\ttv_key = DUK__REGCONSTP_C(ins);\n\t\t\trc = duk_hobject_getprop(thr, tv_obj, tv_key);  /* -> [val] */\n\t\t\tDUK_UNREF(rc);  /* ignore */\n\t\t\ttv_obj = NULL;  /* invalidated */\n\t\t\ttv_key = NULL;  /* invalidated */\n\n\t\t\t/* XXX: Fastint fast path would be useful here.  Also fastints\n\t\t\t * now lose their fastint status in current handling which is\n\t\t\t * not intuitive.\n\t\t\t */\n\n\t\t\tx = duk_to_number_m1(ctx);\n\t\t\tduk_pop(ctx);\n\t\t\tif (ins & DUK_BC_INCDECP_FLAG_DEC) {\n\t\t\t\ty = x - 1.0;\n\t\t\t} else {\n\t\t\t\ty = x + 1.0;\n\t\t\t}\n\n\t\t\tduk_push_number(ctx, y);\n\t\t\ttv_val = DUK_GET_TVAL_NEGIDX(ctx, -1);\n\t\t\tDUK_ASSERT(tv_val != NULL);\n\t\t\ttv_obj = DUK__REGCONSTP_B(ins);\n\t\t\ttv_key = DUK__REGCONSTP_C(ins);\n\t\t\trc = duk_hobject_putprop(thr, tv_obj, tv_key, tv_val, DUK__STRICT());\n\t\t\tDUK_UNREF(rc);  /* ignore */\n\t\t\ttv_obj = NULL;  /* invalidated */\n\t\t\ttv_key = NULL;  /* invalidated */\n\t\t\tduk_pop(ctx);\n\n\t\t\tz = (ins & DUK_BC_INCDECP_FLAG_POST) ? x : y;\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n\t\t\tduk_push_number(ctx, z);\n\t\t\tDUK__REPLACE_TOP_A_BREAK();\n#else\n\t\t\ttv_dst = DUK__REGP_A(ins);\n\t\t\tDUK_TVAL_SET_NUMBER_UPDREF(thr, tv_dst, z);\n\t\t\tbreak;\n#endif\n\t\t}\n\n\t\t/* XXX: GETPROP where object is 'this', GETPROPT?\n\t\t * Occurs relatively often in object oriented code.\n\t\t */\n\n#define DUK__GETPROP_BODY(barg,carg) { \\\n\t\t/* A -> target reg \\\n\t\t * B -> object reg/const (may be const e.g. in \"'foo'[1]\") \\\n\t\t * C -> key reg/const \\\n\t\t */ \\\n\t\t(void) duk_hobject_getprop(thr, (barg), (carg)); \\\n\t\tDUK__REPLACE_TOP_A_BREAK(); \\\n\t}\n#define DUK__PUTPROP_BODY(aarg,barg,carg) { \\\n\t\t/* A -> object reg \\\n\t\t * B -> key reg/const \\\n\t\t * C -> value reg/const \\\n\t\t * \\\n\t\t * Note: intentional difference to register arrangement \\\n\t\t * of e.g. GETPROP; 'A' must contain a register-only value. \\\n\t\t */ \\\n\t\t(void) duk_hobject_putprop(thr, (aarg), (barg), (carg), DUK__STRICT()); \\\n\t\tbreak; \\\n\t}\n#define DUK__DELPROP_BODY(barg,carg) { \\\n\t\t/* A -> result reg \\\n\t\t * B -> object reg \\\n\t\t * C -> key reg/const \\\n\t\t */ \\\n\t\tduk_bool_t rc; \\\n\t\trc = duk_hobject_delprop(thr, (barg), (carg), DUK__STRICT()); \\\n\t\tDUK_ASSERT(rc == 0 || rc == 1); \\\n\t\tDUK__REPLACE_BOOL_A_BREAK(rc); \\\n\t}\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n\t\tcase DUK_OP_GETPROP_RR:\n\t\tcase DUK_OP_GETPROP_CR:\n\t\tcase DUK_OP_GETPROP_RC:\n\t\tcase DUK_OP_GETPROP_CC:\n\t\t\tDUK__GETPROP_BODY(DUK__REGCONSTP_B(ins), DUK__REGCONSTP_C(ins));\n\t\tcase DUK_OP_PUTPROP_RR:\n\t\tcase DUK_OP_PUTPROP_CR:\n\t\tcase DUK_OP_PUTPROP_RC:\n\t\tcase DUK_OP_PUTPROP_CC:\n\t\t\tDUK__PUTPROP_BODY(DUK__REGP_A(ins), DUK__REGCONSTP_B(ins), DUK__REGCONSTP_C(ins));\n\t\tcase DUK_OP_DELPROP_RR:\n\t\tcase DUK_OP_DELPROP_RC:  /* B is always reg */\n\t\t\tDUK__DELPROP_BODY(DUK__REGP_B(ins), DUK__REGCONSTP_C(ins));\n#else  /* DUK_USE_EXEC_PREFER_SIZE */\n\t\tcase DUK_OP_GETPROP_RR:\n\t\t\tDUK__GETPROP_BODY(DUK__REGP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_GETPROP_CR:\n\t\t\tDUK__GETPROP_BODY(DUK__CONSTP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_GETPROP_RC:\n\t\t\tDUK__GETPROP_BODY(DUK__REGP_B(ins), DUK__CONSTP_C(ins));\n\t\tcase DUK_OP_GETPROP_CC:\n\t\t\tDUK__GETPROP_BODY(DUK__CONSTP_B(ins), DUK__CONSTP_C(ins));\n\t\tcase DUK_OP_PUTPROP_RR:\n\t\t\tDUK__PUTPROP_BODY(DUK__REGP_A(ins), DUK__REGP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_PUTPROP_CR:\n\t\t\tDUK__PUTPROP_BODY(DUK__REGP_A(ins), DUK__CONSTP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_PUTPROP_RC:\n\t\t\tDUK__PUTPROP_BODY(DUK__REGP_A(ins), DUK__REGP_B(ins), DUK__CONSTP_C(ins));\n\t\tcase DUK_OP_PUTPROP_CC:\n\t\t\tDUK__PUTPROP_BODY(DUK__REGP_A(ins), DUK__CONSTP_B(ins), DUK__CONSTP_C(ins));\n\t\tcase DUK_OP_DELPROP_RR:  /* B is always reg */\n\t\t\tDUK__DELPROP_BODY(DUK__REGP_B(ins), DUK__REGP_C(ins));\n\t\tcase DUK_OP_DELPROP_RC:\n\t\t\tDUK__DELPROP_BODY(DUK__REGP_B(ins), DUK__CONSTP_C(ins));\n#endif  /* DUK_USE_EXEC_PREFER_SIZE */\n\n\t\t/* No fast path for DECLVAR now, it's quite a rare instruction. */\n\t\tcase DUK_OP_DECLVAR_RR:\n\t\tcase DUK_OP_DECLVAR_CR:\n\t\tcase DUK_OP_DECLVAR_RC:\n\t\tcase DUK_OP_DECLVAR_CC: {\n\t\t\tduk_activation *act;\n\t\t\tduk_context *ctx = (duk_context *) thr;\n\t\t\tduk_small_uint_fast_t a = DUK_DEC_A(ins);\n\t\t\tduk_tval *tv1;\n\t\t\tduk_hstring *name;\n\t\t\tduk_small_uint_t prop_flags;\n\t\t\tduk_bool_t is_func_decl;\n\n\t\t\ttv1 = DUK__REGCONSTP_B(ins);\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_STRING(tv1));\n\t\t\tname = DUK_TVAL_GET_STRING(tv1);\n\t\t\tDUK_ASSERT(name != NULL);\n\n\t\t\tis_func_decl = ((a & DUK_BC_DECLVAR_FLAG_FUNC_DECL) != 0);\n\n\t\t\t/* XXX: declvar takes an duk_tval pointer, which is awkward and\n\t\t\t * should be reworked.\n\t\t\t */\n\n\t\t\t/* Compiler is responsible for selecting property flags (configurability,\n\t\t\t * writability, etc).\n\t\t\t */\n\t\t\tprop_flags = a & DUK_PROPDESC_FLAGS_MASK;\n\n\t\t\tif (is_func_decl) {\n\t\t\t\tduk_push_tval(ctx, DUK__REGCONSTP_C(ins));\n\t\t\t} else {\n\t\t\t\tDUK_ASSERT(DUK_TVAL_IS_UNDEFINED(thr->valstack_top));  /* valstack policy */\n\t\t\t\tthr->valstack_top++;\n\t\t\t}\n\t\t\ttv1 = DUK_GET_TVAL_NEGIDX(ctx, -1);\n\n\t\t\tact = thr->callstack_curr;\n\t\t\tif (duk_js_declvar_activation(thr, act, name, tv1, prop_flags, is_func_decl)) {\n\t\t\t\tif (is_func_decl) {\n\t\t\t\t\t/* Already declared, update value. */\n\t\t\t\t\ttv1 = DUK_GET_TVAL_NEGIDX(ctx, -1);\n\t\t\t\t\tduk_js_putvar_activation(thr, act, name, tv1, DUK__STRICT());\n\t\t\t\t} else {\n\t\t\t\t\t/* Already declared but no initializer value\n\t\t\t\t\t * (e.g. 'var xyz;'), no-op.\n\t\t\t\t\t */\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tduk_pop(ctx);\n\t\t\tbreak;\n\t\t}\n\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\t\t/* The compiler should never emit DUK_OP_REGEXP if there is no\n\t\t * regexp support.\n\t\t */\n\t\tcase DUK_OP_REGEXP_RR:\n\t\tcase DUK_OP_REGEXP_CR:\n\t\tcase DUK_OP_REGEXP_RC:\n\t\tcase DUK_OP_REGEXP_CC: {\n\t\t\t/* A -> target register\n\t\t\t * B -> bytecode (also contains flags)\n\t\t\t * C -> escaped source\n\t\t\t */\n\n\t\t\tduk_push_tval((duk_context *) thr, DUK__REGCONSTP_C(ins));\n\t\t\tduk_push_tval((duk_context *) thr, DUK__REGCONSTP_B(ins));  /* -> [ ... escaped_source bytecode ] */\n\t\t\tduk_regexp_create_instance(thr);   /* -> [ ... regexp_instance ] */\n\t\t\tDUK__REPLACE_TOP_A_BREAK();\n\t\t}\n#endif  /* DUK_USE_REGEXP_SUPPORT */\n\n\t\t/* XXX: 'c' is unused, use whole BC, etc. */\n\t\tcase DUK_OP_CSVAR_RR:\n\t\tcase DUK_OP_CSVAR_CR:\n\t\tcase DUK_OP_CSVAR_RC:\n\t\tcase DUK_OP_CSVAR_CC: {\n\t\t\t/* The speciality of calling through a variable binding is that the\n\t\t\t * 'this' value may be provided by the variable lookup: E5 Section 6.b.i.\n\t\t\t *\n\t\t\t * The only (standard) case where the 'this' binding is non-null is when\n\t\t\t *   (1) the variable is found in an object environment record, and\n\t\t\t *   (2) that object environment record is a 'with' block.\n\t\t\t */\n\n\t\t\tduk_context *ctx = (duk_context *) thr;\n\t\t\tduk_activation *act;\n\t\t\tduk_uint_fast_t idx;\n\t\t\tduk_tval *tv1;\n\t\t\tduk_hstring *name;\n\n\t\t\t/* A -> target registers (A, A + 1) for call setup\n\t\t\t * B -> identifier name, usually constant but can be a register due to shuffling\n\t\t\t */\n\n\t\t\ttv1 = DUK__REGCONSTP_B(ins);\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_STRING(tv1));\n\t\t\tname = DUK_TVAL_GET_STRING(tv1);\n\t\t\tDUK_ASSERT(name != NULL);\n\t\t\tact = thr->callstack_curr;\n\t\t\t(void) duk_js_getvar_activation(thr, act, name, 1 /*throw*/);  /* -> [... val this] */\n\n\t\t\tidx = (duk_uint_fast_t) DUK_DEC_A(ins);\n\n\t\t\t/* Could add direct value stack handling. */\n\t\t\tduk_replace(ctx, (duk_idx_t) (idx + 1));  /* 'this' binding */\n\t\t\tduk_replace(ctx, (duk_idx_t) idx);        /* variable value (function, we hope, not checked here) */\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_CLOSURE: {\n\t\t\tduk_activation *act;\n\t\t\tduk_hcompfunc *fun_act;\n\t\t\tduk_small_uint_fast_t bc = DUK_DEC_BC(ins);\n\t\t\tduk_hobject *fun_temp;\n\n\t\t\t/* A -> target reg\n\t\t\t * BC -> inner function index\n\t\t\t */\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"CLOSURE to target register %ld, fnum %ld (count %ld)\",\n\t\t\t                     (long) DUK_DEC_A(ins), (long) DUK_DEC_BC(ins), (long) DUK_HCOMPFUNC_GET_FUNCS_COUNT(thr->heap, DUK__FUN())));\n\n\t\t\tDUK_ASSERT_DISABLE(bc >= 0); /* unsigned */\n\t\t\tDUK_ASSERT((duk_uint_t) bc < (duk_uint_t) DUK_HCOMPFUNC_GET_FUNCS_COUNT(thr->heap, DUK__FUN()));\n\n\t\t\tact = thr->callstack_curr;\n\t\t\tfun_act = (duk_hcompfunc *) DUK_ACT_GET_FUNC(act);\n\t\t\tfun_temp = DUK_HCOMPFUNC_GET_FUNCS_BASE(thr->heap, fun_act)[bc];\n\t\t\tDUK_ASSERT(fun_temp != NULL);\n\t\t\tDUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC(fun_temp));\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"CLOSURE: function template is: %p -> %!O\",\n\t\t\t                     (void *) fun_temp, (duk_heaphdr *) fun_temp));\n\n\t\t\tif (act->lex_env == NULL) {\n\t\t\t\tDUK_ASSERT(act->var_env == NULL);\n\t\t\t\tduk_js_init_activation_environment_records_delayed(thr, act);\n\t\t\t\tact = thr->callstack_curr;\n\t\t\t}\n\t\t\tDUK_ASSERT(act->lex_env != NULL);\n\t\t\tDUK_ASSERT(act->var_env != NULL);\n\n\t\t\t/* functions always have a NEWENV flag, i.e. they get a\n\t\t\t * new variable declaration environment, so only lex_env\n\t\t\t * matters here.\n\t\t\t */\n\t\t\tduk_js_push_closure(thr,\n\t\t\t                    (duk_hcompfunc *) fun_temp,\n\t\t\t                    act->var_env,\n\t\t\t                    act->lex_env,\n\t\t\t                    1 /*add_auto_proto*/);\n\t\t\tDUK__REPLACE_TOP_A_BREAK();\n\t\t}\n\n\t\tcase DUK_OP_GETVAR: {\n\t\t\tduk_context *ctx = (duk_context *) thr;\n\t\t\tduk_activation *act;\n\t\t\tduk_tval *tv1;\n\t\t\tduk_hstring *name;\n\n\t\t\ttv1 = DUK__CONSTP_BC(ins);\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_STRING(tv1));\n\t\t\tname = DUK_TVAL_GET_STRING(tv1);\n\t\t\tDUK_ASSERT(name != NULL);\n\t\t\tact = thr->callstack_curr;\n\t\t\t(void) duk_js_getvar_activation(thr, act, name, 1 /*throw*/);  /* -> [... val this] */\n\t\t\tduk_pop(ctx);  /* 'this' binding is not needed here */\n\t\t\tDUK__REPLACE_TOP_A_BREAK();\n\t\t}\n\n\t\tcase DUK_OP_PUTVAR: {\n\t\t\tduk_activation *act;\n\t\t\tduk_tval *tv1;\n\t\t\tduk_hstring *name;\n\n\t\t\ttv1 = DUK__CONSTP_BC(ins);\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_STRING(tv1));\n\t\t\tname = DUK_TVAL_GET_STRING(tv1);\n\t\t\tDUK_ASSERT(name != NULL);\n\n\t\t\t/* XXX: putvar takes a duk_tval pointer, which is awkward and\n\t\t\t * should be reworked.\n\t\t\t */\n\n\t\t\ttv1 = DUK__REGP_A(ins);  /* val */\n\t\t\tact = thr->callstack_curr;\n\t\t\tduk_js_putvar_activation(thr, act, name, tv1, DUK__STRICT());\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_DELVAR: {\n\t\t\tduk_activation *act;\n\t\t\tduk_tval *tv1;\n\t\t\tduk_hstring *name;\n\t\t\tduk_bool_t rc;\n\n\t\t\ttv1 = DUK__CONSTP_BC(ins);\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_STRING(tv1));\n\t\t\tname = DUK_TVAL_GET_STRING(tv1);\n\t\t\tDUK_ASSERT(name != NULL);\n\t\t\tact = thr->callstack_curr;\n\t\t\trc = duk_js_delvar_activation(thr, act, name);\n\t\t\tDUK__REPLACE_BOOL_A_BREAK(rc);\n\t\t}\n\n\t\tcase DUK_OP_JUMP: {\n\t\t\t/* Note: without explicit cast to signed, MSVC will\n\t\t\t * apparently generate a large positive jump when the\n\t\t\t * bias-corrected value would normally be negative.\n\t\t\t */\n\t\t\tcurr_pc += (duk_int_fast_t) DUK_DEC_ABC(ins) - (duk_int_fast_t) DUK_BC_JUMP_BIAS;\n\t\t\tbreak;\n\t\t}\n\n#define DUK__RETURN_SHARED() do { \\\n\t\tduk_small_uint_t ret_result; \\\n\t\t/* duk__handle_return() is guaranteed never to throw, except \\\n\t\t * for potential out-of-memory situations which will then \\\n\t\t * propagate out of the executor longjmp handler. \\\n\t\t */ \\\n\t\tret_result = duk__handle_return(thr, \\\n\t\t\t                        entry_thread, \\\n\t\t\t                        entry_callstack_top); \\\n\t\tif (ret_result == DUK__RETHAND_RESTART) { \\\n\t\t\tgoto restart_execution; \\\n\t\t} \\\n\t\tDUK_ASSERT(ret_result == DUK__RETHAND_FINISHED); \\\n\t\treturn; \\\n\t} while (0)\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n\t\tcase DUK_OP_RETREG:\n\t\tcase DUK_OP_RETCONST:\n\t\tcase DUK_OP_RETCONSTN:\n\t\tcase DUK_OP_RETUNDEF: {\n\t\t\t /* BC -> return value reg/const */\n\n\t\t\tDUK__SYNC_AND_NULL_CURR_PC();\n\n\t\t\tif (op == DUK_OP_RETREG) {\n\t\t\t\tduk_push_tval((duk_context *) thr, DUK__REGP_BC(ins));\n\t\t\t} else if (op == DUK_OP_RETUNDEF) {\n\t\t\t\tDUK_ASSERT(DUK_TVAL_IS_UNDEFINED(thr->valstack_top));  /* valstack policy */\n\t\t\t\tthr->valstack_top++;\n\t\t\t} else {\n\t\t\t\tDUK_ASSERT(op == DUK_OP_RETCONST || op == DUK_OP_RETCONSTN);\n\t\t\t\tduk_push_tval((duk_context *) thr, DUK__CONSTP_BC(ins));\n\t\t\t}\n\n\t\t\tDUK__RETURN_SHARED();\n\t\t}\n#else  /* DUK_USE_EXEC_PREFER_SIZE */\n\t\tcase DUK_OP_RETREG: {\n\t\t\tduk_tval *tv;\n\n\t\t\tDUK__SYNC_AND_NULL_CURR_PC();\n\t\t\ttv = DUK__REGP_BC(ins);\n\t\t\tDUK_TVAL_SET_TVAL(thr->valstack_top, tv);\n\t\t\tDUK_TVAL_INCREF(thr, tv);\n\t\t\tthr->valstack_top++;\n\t\t\tDUK__RETURN_SHARED();\n\t\t}\n\t\t/* This will be unused without refcounting. */\n\t\tcase DUK_OP_RETCONST: {\n\t\t\tduk_tval *tv;\n\n\t\t\tDUK__SYNC_AND_NULL_CURR_PC();\n\t\t\ttv = DUK__CONSTP_BC(ins);\n\t\t\tDUK_TVAL_SET_TVAL(thr->valstack_top, tv);\n\t\t\tDUK_TVAL_INCREF(thr, tv);\n\t\t\tthr->valstack_top++;\n\t\t\tDUK__RETURN_SHARED();\n\t\t}\n\t\tcase DUK_OP_RETCONSTN: {\n\t\t\tduk_tval *tv;\n\n\t\t\tDUK__SYNC_AND_NULL_CURR_PC();\n\t\t\ttv = DUK__CONSTP_BC(ins);\n\t\t\tDUK_TVAL_SET_TVAL(thr->valstack_top, tv);\n#if defined(DUK_USE_REFERENCE_COUNTING)\n\t\t\t/* Without refcounting only RETCONSTN is used. */\n\t\t\tDUK_ASSERT(!DUK_TVAL_IS_HEAP_ALLOCATED(tv));  /* no INCREF for this constant */\n#endif\n\t\t\tthr->valstack_top++;\n\t\t\tDUK__RETURN_SHARED();\n\t\t}\n\t\tcase DUK_OP_RETUNDEF: {\n\t\t\tDUK__SYNC_AND_NULL_CURR_PC();\n\t\t\tthr->valstack_top++;  /* value at valstack top is already undefined by valstack policy */\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_UNDEFINED(thr->valstack_top));\n\t\t\tDUK__RETURN_SHARED();\n\t\t}\n#endif  /* DUK_USE_EXEC_PREFER_SIZE */\n\n\t\tcase DUK_OP_LABEL: {\n\t\t\tduk_catcher *cat;\n\t\t\tduk_small_uint_fast_t bc = DUK_DEC_BC(ins);\n\n\t\t\t/* allocate catcher and populate it (should be atomic) */\n\n\t\t\tduk_hthread_catchstack_grow(thr);\n\t\t\tcat = thr->catchstack + thr->catchstack_top;\n\t\t\tthr->catchstack_top++;\n\n\t\t\tcat->flags = DUK_CAT_TYPE_LABEL | (bc << DUK_CAT_LABEL_SHIFT);\n\t\t\tcat->callstack_index = thr->callstack_top - 1;\n\t\t\tcat->pc_base = (duk_instr_t *) curr_pc;  /* pre-incremented, points to first jump slot */\n\t\t\tcat->idx_base = 0;  /* unused for label */\n\t\t\tcat->h_varname = NULL;\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"LABEL catcher: flags=0x%08lx, callstack_index=%ld, pc_base=%ld, \"\n\t\t\t                     \"idx_base=%ld, h_varname=%!O, label_id=%ld\",\n\t\t\t                     (long) cat->flags, (long) cat->callstack_index, (long) cat->pc_base,\n\t\t\t                     (long) cat->idx_base, (duk_heaphdr *) cat->h_varname, (long) DUK_CAT_GET_LABEL(cat)));\n\n\t\t\tcurr_pc += 2;  /* skip jump slots */\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_ENDLABEL: {\n\t\t\tduk_catcher *cat;\n#if (defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 2)) || defined(DUK_USE_ASSERTIONS)\n\t\t\tduk_small_uint_fast_t bc = DUK_DEC_BC(ins);\n#endif\n#if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 2)\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"ENDLABEL %ld\", (long) bc));\n#endif\n\n\t\t\tDUK_ASSERT(thr->catchstack_top >= 1);\n\n\t\t\tcat = thr->catchstack + thr->catchstack_top - 1;\n\t\t\tDUK_UNREF(cat);\n\t\t\tDUK_ASSERT(DUK_CAT_GET_TYPE(cat) == DUK_CAT_TYPE_LABEL);\n\t\t\tDUK_ASSERT((duk_uint_fast_t) DUK_CAT_GET_LABEL(cat) == bc);\n\n\t\t\tduk_hthread_catchstack_unwind(thr, thr->catchstack_top - 1);\n\t\t\t/* no need to unwind callstack */\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_BREAK: {\n\t\t\tduk_small_uint_fast_t bc = DUK_DEC_BC(ins);\n\n\t\t\tDUK__SYNC_AND_NULL_CURR_PC();\n\t\t\tduk__handle_break_or_continue(thr, (duk_uint_t) bc, DUK_LJ_TYPE_BREAK);\n\t\t\tgoto restart_execution;\n\t\t}\n\n\t\tcase DUK_OP_CONTINUE: {\n\t\t\tduk_small_uint_fast_t bc = DUK_DEC_BC(ins);\n\n\t\t\tDUK__SYNC_AND_NULL_CURR_PC();\n\t\t\tduk__handle_break_or_continue(thr, (duk_uint_t) bc, DUK_LJ_TYPE_CONTINUE);\n\t\t\tgoto restart_execution;\n\t\t}\n\n\t\t/* XXX: move to helper, too large to be inline here */\n\t\tcase DUK_OP_TRYCATCH: {\n\t\t\tduk_context *ctx = (duk_context *) thr;\n\t\t\tduk_activation *act;\n\t\t\tduk_catcher *cat;\n\t\t\tduk_tval *tv1;\n\t\t\tduk_small_uint_fast_t a;\n\t\t\tduk_small_uint_fast_t bc;\n\n\t\t\t/* A -> flags\n\t\t\t * BC -> reg_catch; base register for two registers used both during\n\t\t\t *       trycatch setup and when catch is triggered\n\t\t\t *\n\t\t\t *      If DUK_BC_TRYCATCH_FLAG_CATCH_BINDING set:\n\t\t\t *          reg_catch + 0: catch binding variable name (string).\n\t\t\t *          Automatic declarative environment is established for\n\t\t\t *          the duration of the 'catch' clause.\n\t\t\t *\n\t\t\t *      If DUK_BC_TRYCATCH_FLAG_WITH_BINDING set:\n\t\t\t *          reg_catch + 0: with 'target value', which is coerced to\n\t\t\t *          an object and then used as a bindind object for an\n\t\t\t *          environment record.  The binding is initialized here, for\n\t\t\t *          the 'try' clause.\n\t\t\t *\n\t\t\t * Note that a TRYCATCH generated for a 'with' statement has no\n\t\t\t * catch or finally parts.\n\t\t\t */\n\n\t\t\t/* XXX: TRYCATCH handling should be reworked to avoid creating\n\t\t\t * an explicit scope unless it is actually needed (e.g. function\n\t\t\t * instances or eval is executed inside the catch block).  This\n\t\t\t * rework is not trivial because the compiler doesn't have an\n\t\t\t * intermediate representation.  When the rework is done, the\n\t\t\t * opcode format can also be made more straightforward.\n\t\t\t */\n\n\t\t\t/* XXX: side effect handling is quite awkward here */\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"TRYCATCH: reg_catch=%ld, have_catch=%ld, \"\n\t\t\t                     \"have_finally=%ld, catch_binding=%ld, with_binding=%ld (flags=0x%02lx)\",\n\t\t\t                     (long) DUK_DEC_BC(ins),\n\t\t\t                     (long) (DUK_DEC_A(ins) & DUK_BC_TRYCATCH_FLAG_HAVE_CATCH ? 1 : 0),\n\t\t\t                     (long) (DUK_DEC_A(ins) & DUK_BC_TRYCATCH_FLAG_HAVE_FINALLY ? 1 : 0),\n\t\t\t                     (long) (DUK_DEC_A(ins) & DUK_BC_TRYCATCH_FLAG_CATCH_BINDING ? 1 : 0),\n\t\t\t                     (long) (DUK_DEC_A(ins) & DUK_BC_TRYCATCH_FLAG_WITH_BINDING ? 1 : 0),\n\t\t\t                     (unsigned long) DUK_DEC_A(ins)));\n\n\t\t\ta = DUK_DEC_A(ins);\n\t\t\tbc = DUK_DEC_BC(ins);\n\n\t\t\t/* Registers 'bc' and 'bc + 1' are written in longjmp handling\n\t\t\t * and if their previous values (which are temporaries) become\n\t\t\t * unreachable -and- have a finalizer, there'll be a function\n\t\t\t * call during error handling which is not supported now (GH-287).\n\t\t\t * Ensure that both 'bc' and 'bc + 1' have primitive values to\n\t\t\t * guarantee no finalizer calls in error handling.  Scrubbing also\n\t\t\t * ensures finalizers for the previous values run here rather than\n\t\t\t * later.  Error handling related values are also written to 'bc'\n\t\t\t * and 'bc + 1' but those values never become unreachable during\n\t\t\t * error handling, so there's no side effect problem even if the\n\t\t\t * error value has a finalizer.\n\t\t\t */\n\t\t\tduk_dup(ctx, bc);  /* Stabilize value. */\n\t\t\tduk_to_undefined(ctx, bc);\n\t\t\tduk_to_undefined(ctx, bc + 1);\n\n\t\t\t/* Ensure a catchstack entry is available.  One entry\n\t\t\t * is guaranteed even if side effects cause function\n\t\t\t * calls and the catchstack is shrunk because some\n\t\t\t * spare room is left behind by a shrink operation.\n\t\t\t */\n\t\t\tduk_hthread_catchstack_grow(thr);\n\n\t\t\t/* Allocate catcher and populate it.  Doesn't have to\n\t\t\t * be fully atomic, but the catcher must be in a\n\t\t\t * consistent state if side effects (such as finalizer\n\t\t\t * calls) occur.\n\t\t\t */\n\n\t\t\tDUK_ASSERT(thr->catchstack_top + 1 <= thr->catchstack_size);\n\t\t\tcat = thr->catchstack + thr->catchstack_top;\n\t\t\tthr->catchstack_top++;\n\n\t\t\tcat->flags = DUK_CAT_TYPE_TCF;\n\t\t\tcat->h_varname = NULL;\n\t\t\tcat->callstack_index = thr->callstack_top - 1;\n\t\t\tcat->pc_base = (duk_instr_t *) curr_pc;  /* pre-incremented, points to first jump slot */\n\t\t\tcat->idx_base = (duk_size_t) (thr->valstack_bottom - thr->valstack) + bc;\n\n\t\t\tif (a & DUK_BC_TRYCATCH_FLAG_HAVE_CATCH) {\n\t\t\t\tcat->flags |= DUK_CAT_FLAG_CATCH_ENABLED;\n\t\t\t}\n\t\t\tif (a & DUK_BC_TRYCATCH_FLAG_HAVE_FINALLY) {\n\t\t\t\tcat->flags |= DUK_CAT_FLAG_FINALLY_ENABLED;\n\t\t\t}\n\t\t\tif (a & DUK_BC_TRYCATCH_FLAG_CATCH_BINDING) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"catch binding flag set to catcher\"));\n\t\t\t\tcat->flags |= DUK_CAT_FLAG_CATCH_BINDING_ENABLED;\n\t\t\t\ttv1 = DUK_GET_TVAL_NEGIDX(thr, -1);\n\t\t\t\tDUK_ASSERT(DUK_TVAL_IS_STRING(tv1));\n\n\t\t\t\t/* borrowed reference; although 'tv1' comes from a register,\n\t\t\t\t * its value was loaded using LDCONST so the constant will\n\t\t\t\t * also exist and be reachable.\n\t\t\t\t */\n\t\t\t\tcat->h_varname = DUK_TVAL_GET_STRING(tv1);\n\t\t\t} else if (a & DUK_BC_TRYCATCH_FLAG_WITH_BINDING) {\n\t\t\t\tduk_hobjenv *env;\n\t\t\t\tduk_hobject *target;\n\n\t\t\t\t/* Delayed env initialization for activation (if needed). */\n\t\t\t\tDUK_ASSERT(thr->callstack_top >= 1);\n\t\t\t\tact = thr->callstack_curr;\n\t\t\t\tDUK_ASSERT(act != NULL);\n\t\t\t\tif (act->lex_env == NULL) {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"delayed environment initialization\"));\n\t\t\t\t\tDUK_ASSERT(act->var_env == NULL);\n\n\t\t\t\t\tduk_js_init_activation_environment_records_delayed(thr, act);\n\t\t\t\t\tact = thr->callstack_curr;  /* relookup, side effects */\n\t\t\t\t\tDUK_UNREF(act);  /* 'act' is no longer accessed, scanbuild fix */\n\t\t\t\t}\n\t\t\t\tDUK_ASSERT(act->lex_env != NULL);\n\t\t\t\tDUK_ASSERT(act->var_env != NULL);\n\n\t\t\t\t/* Coerce 'with' target. */\n\t\t\t\ttarget = duk_to_hobject(ctx, -1);\n\t\t\t\tDUK_ASSERT(target != NULL);\n\n\t\t\t\t/* Create an object environment; it is not pushed\n\t\t\t\t * so avoid side effects very carefully until it is\n\t\t\t\t * referenced.\n\t\t\t\t */\n\t\t\t\tenv = duk_hobjenv_alloc(thr,\n\t\t\t\t                        DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t\t\t\t                        DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_OBJENV));\n\t\t\t\tDUK_ASSERT(env != NULL);\n\t\t\t\tDUK_ASSERT(DUK_HOBJECT_GET_PROTOTYPE(thr->heap, (duk_hobject *) env) == NULL);\n\t\t\t\tenv->target = target;  /* always provideThis=true */\n\t\t\t\tDUK_HOBJECT_INCREF(thr, target);\n\t\t\t\tenv->has_this = 1;\n\t\t\t\tDUK_ASSERT_HOBJENV_VALID(env);\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"environment for with binding: %!iO\", env));\n\n\t\t\t\tact = thr->callstack_curr;  /* relookup (side effects) */\n\t\t\t\tDUK_ASSERT(DUK_HOBJECT_GET_PROTOTYPE(thr->heap, (duk_hobject *) env) == NULL);\n\t\t\t\tDUK_ASSERT(act->lex_env != NULL);\n\t\t\t\tDUK_HOBJECT_SET_PROTOTYPE(thr->heap, (duk_hobject *) env, act->lex_env);\n\t\t\t\tact->lex_env = (duk_hobject *) env;  /* Now reachable. */\n\t\t\t\tDUK_HOBJECT_INCREF(thr, (duk_hobject *) env);\n\t\t\t\t/* Net refcount change to act->lex_env is 0: incref for env's\n\t\t\t\t * prototype, decref for act->lex_env overwrite.\n\t\t\t\t */\n\n\t\t\t\t/* Set catcher lex_env active (affects unwind)\n\t\t\t\t * only when the whole setup is complete.\n\t\t\t\t */\n\t\t\t\tcat = thr->catchstack + thr->catchstack_top - 1;\n\t\t\t\tcat->flags |= DUK_CAT_FLAG_LEXENV_ACTIVE;\n\t\t\t} else {\n\t\t\t\t;\n\t\t\t}\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"TRYCATCH catcher: flags=0x%08lx, callstack_index=%ld, pc_base=%ld, \"\n\t\t\t                     \"idx_base=%ld, h_varname=%!O\",\n\t\t\t                     (unsigned long) cat->flags, (long) cat->callstack_index,\n\t\t\t                     (long) cat->pc_base, (long) cat->idx_base, (duk_heaphdr *) cat->h_varname));\n\n\t\t\tduk_pop(ctx);\n\n\t\t\tcurr_pc += 2;  /* skip jump slots */\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_ENDTRY: {\n\t\t\tduk_catcher *cat;\n\t\t\tduk_tval *tv1;\n\n\t\t\tDUK_ASSERT(thr->catchstack_top >= 1);\n\t\t\tDUK_ASSERT(thr->callstack_top >= 1);\n\t\t\tDUK_ASSERT(thr->catchstack[thr->catchstack_top - 1].callstack_index == thr->callstack_top - 1);\n\n\t\t\tcat = thr->catchstack + thr->catchstack_top - 1;\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"ENDTRY: clearing catch active flag (regardless of whether it was set or not)\"));\n\t\t\tDUK_CAT_CLEAR_CATCH_ENABLED(cat);\n\n\t\t\tif (DUK_CAT_HAS_FINALLY_ENABLED(cat)) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"ENDTRY: finally part is active, jump through 2nd jump slot with 'normal continuation'\"));\n\n\t\t\t\ttv1 = thr->valstack + cat->idx_base;\n\t\t\t\tDUK_ASSERT(tv1 >= thr->valstack && tv1 < thr->valstack_top);\n\t\t\t\tDUK_TVAL_SET_UNDEFINED_UPDREF(thr, tv1);  /* side effects */\n\t\t\t\ttv1 = NULL;\n\n\t\t\t\ttv1 = thr->valstack + cat->idx_base + 1;\n\t\t\t\tDUK_ASSERT(tv1 >= thr->valstack && tv1 < thr->valstack_top);\n\t\t\t\tDUK_TVAL_SET_U32_UPDREF(thr, tv1, (duk_uint32_t) DUK_LJ_TYPE_NORMAL);  /* side effects */\n\t\t\t\ttv1 = NULL;\n\n\t\t\t\tDUK_CAT_CLEAR_FINALLY_ENABLED(cat);\n\t\t\t} else {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"ENDTRY: no finally part, dismantle catcher, jump through 2nd jump slot (to end of statement)\"));\n\t\t\t\tduk_hthread_catchstack_unwind(thr, thr->catchstack_top - 1);\n\t\t\t\t/* no need to unwind callstack */\n\t\t\t}\n\n\t\t\tcurr_pc = cat->pc_base + 1;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_ENDCATCH: {\n\t\t\tduk_activation *act;\n\t\t\tduk_catcher *cat;\n\t\t\tduk_tval *tv1;\n\n\t\t\tDUK_ASSERT(thr->catchstack_top >= 1);\n\t\t\tDUK_ASSERT(thr->callstack_top >= 1);\n\t\t\tDUK_ASSERT(thr->catchstack[thr->catchstack_top - 1].callstack_index == thr->callstack_top - 1);\n\n\t\t\tcat = thr->catchstack + thr->catchstack_top - 1;\n\t\t\tDUK_ASSERT(!DUK_CAT_HAS_CATCH_ENABLED(cat));  /* cleared before entering catch part */\n\n\t\t\tact = thr->callstack_curr;\n\t\t\tDUK_ASSERT(act != NULL);\n\n\t\t\tif (DUK_CAT_HAS_LEXENV_ACTIVE(cat)) {\n\t\t\t\tduk_hobject *prev_env;\n\n\t\t\t\t/* 'with' binding has no catch clause, so can't be here unless a normal try-catch */\n\t\t\t\tDUK_ASSERT(DUK_CAT_HAS_CATCH_BINDING_ENABLED(cat));\n\t\t\t\tDUK_ASSERT(act->lex_env != NULL);\n\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"ENDCATCH: popping catcher part lexical environment\"));\n\n\t\t\t\tprev_env = act->lex_env;\n\t\t\t\tDUK_ASSERT(prev_env != NULL);\n\t\t\t\tact->lex_env = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, prev_env);\n\t\t\t\tDUK_CAT_CLEAR_LEXENV_ACTIVE(cat);\n\t\t\t\tDUK_HOBJECT_INCREF(thr, act->lex_env);\n\t\t\t\tDUK_HOBJECT_DECREF(thr, prev_env);  /* side effects */\n\t\t\t}\n\n\t\t\tif (DUK_CAT_HAS_FINALLY_ENABLED(cat)) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"ENDCATCH: finally part is active, jump through 2nd jump slot with 'normal continuation'\"));\n\n\t\t\t\ttv1 = thr->valstack + cat->idx_base;\n\t\t\t\tDUK_ASSERT(tv1 >= thr->valstack && tv1 < thr->valstack_top);\n\t\t\t\tDUK_TVAL_SET_UNDEFINED_UPDREF(thr, tv1);  /* side effects */\n\t\t\t\ttv1 = NULL;\n\n\t\t\t\ttv1 = thr->valstack + cat->idx_base + 1;\n\t\t\t\tDUK_ASSERT(tv1 >= thr->valstack && tv1 < thr->valstack_top);\n\t\t\t\tDUK_TVAL_SET_U32_UPDREF(thr, tv1, (duk_uint32_t) DUK_LJ_TYPE_NORMAL);  /* side effects */\n\t\t\t\ttv1 = NULL;\n\n\t\t\t\tDUK_CAT_CLEAR_FINALLY_ENABLED(cat);\n\t\t\t} else {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"ENDCATCH: no finally part, dismantle catcher, jump through 2nd jump slot (to end of statement)\"));\n\t\t\t\tduk_hthread_catchstack_unwind(thr, thr->catchstack_top - 1);\n\t\t\t\t/* no need to unwind callstack */\n\t\t\t}\n\n\t\t\tcurr_pc = cat->pc_base + 1;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_ENDFIN: {\n\t\t\tduk_context *ctx = (duk_context *) thr;\n\t\t\tduk_catcher *cat;\n\t\t\tduk_tval *tv1;\n\t\t\tduk_small_uint_t cont_type;\n\t\t\tduk_small_uint_t ret_result;\n\n\t\t\t/* Sync and NULL early. */\n\t\t\tDUK__SYNC_AND_NULL_CURR_PC();\n\n\t\t\tDUK_ASSERT(thr->catchstack_top >= 1);\n\t\t\tDUK_ASSERT(thr->callstack_top >= 1);\n\t\t\tDUK_ASSERT(thr->catchstack[thr->catchstack_top - 1].callstack_index == thr->callstack_top - 1);\n\n\t\t\tcat = thr->catchstack + thr->catchstack_top - 1;\n\n\t\t\t/* CATCH flag may be enabled or disabled here; it may be enabled if\n\t\t\t * the statement has a catch block but the try block does not throw\n\t\t\t * an error.\n\t\t\t */\n\t\t\tDUK_ASSERT(!DUK_CAT_HAS_FINALLY_ENABLED(cat));  /* cleared before entering finally */\n\t\t\t/* XXX: assert idx_base */\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"ENDFIN: completion value=%!T, type=%!T\",\n\t\t\t                     (duk_tval *) (thr->valstack + cat->idx_base + 0),\n\t\t\t                     (duk_tval *) (thr->valstack + cat->idx_base + 1)));\n\n\t\t\ttv1 = thr->valstack + cat->idx_base + 1;  /* type */\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv1));\n\t\t\tcont_type = (duk_small_uint_t) DUK_TVAL_GET_NUMBER(tv1);\n\n\t\t\tswitch (cont_type) {\n\t\t\tcase DUK_LJ_TYPE_NORMAL: {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"ENDFIN: finally part finishing with 'normal' (non-abrupt) completion -> \"\n\t\t\t\t                     \"dismantle catcher, resume execution after ENDFIN\"));\n\t\t\t\tduk_hthread_catchstack_unwind(thr, thr->catchstack_top - 1);\n\t\t\t\t/* no need to unwind callstack */\n\t\t\t\tgoto restart_execution;\n\t\t\t}\n\t\t\tcase DUK_LJ_TYPE_RETURN: {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"ENDFIN: finally part finishing with 'return' complation -> dismantle \"\n\t\t\t\t                     \"catcher, handle return, lj.value1=%!T\", thr->valstack + cat->idx_base));\n\n\t\t\t\t/* Not necessary to unwind catchstack: return handling will\n\t\t\t\t * do it.  The finally flag of 'cat' is no longer set.  The\n\t\t\t\t * catch flag may be set, but it's not checked by return handling.\n\t\t\t\t */\n\t\t\t\tDUK_ASSERT(!DUK_CAT_HAS_FINALLY_ENABLED(cat));  /* cleared before entering finally */\n#if 0\n\t\t\t\tduk_hthread_catchstack_unwind(thr, thr->catchstack_top - 1);\n#endif\n\n\t\t\t\tduk_push_tval(ctx, thr->valstack + cat->idx_base);\n\t\t\t\tret_result = duk__handle_return(thr,\n\t\t\t\t\t                        entry_thread,\n\t\t\t\t\t                        entry_callstack_top);\n\t\t\t\tif (ret_result == DUK__RETHAND_RESTART) {\n\t\t\t\t\tgoto restart_execution;\n\t\t\t\t}\n\t\t\t\tDUK_ASSERT(ret_result == DUK__RETHAND_FINISHED);\n\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"exiting executor after ENDFIN and RETURN (pseudo) longjmp type\"));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase DUK_LJ_TYPE_BREAK:\n\t\t\tcase DUK_LJ_TYPE_CONTINUE: {\n\t\t\t\tduk_uint_t label_id;\n\t\t\t\tduk_small_uint_t lj_type;\n\n\t\t\t\t/* Not necessary to unwind catchstack: break/continue\n\t\t\t\t * handling will do it.  The finally flag of 'cat' is\n\t\t\t\t * no longer set.  The catch flag may be set, but it's\n\t\t\t\t * not checked by break/continue handling.\n\t\t\t\t */\n#if 0\n\t\t\t\tduk_hthread_catchstack_unwind(thr, thr->catchstack_top - 1);\n#endif\n\n\t\t\t\ttv1 = thr->valstack + cat->idx_base;\n\t\t\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv1));\n#if defined(DUK_USE_FASTINT)\n\t\t\t\tDUK_ASSERT(DUK_TVAL_IS_FASTINT(tv1));\n\t\t\t\tlabel_id = (duk_small_uint_t) DUK_TVAL_GET_FASTINT_U32(tv1);\n#else\n\t\t\t\tlabel_id = (duk_small_uint_t) DUK_TVAL_GET_NUMBER(tv1);\n#endif\n\t\t\t\tlj_type = cont_type;\n\t\t\t\tduk__handle_break_or_continue(thr, label_id, lj_type);\n\t\t\t\tgoto restart_execution;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"ENDFIN: finally part finishing with abrupt completion, lj_type=%ld -> \"\n\t\t\t\t                     \"dismantle catcher, re-throw error\",\n\t\t\t\t                     (long) cont_type));\n\n\t\t\t\tduk_push_tval(ctx, thr->valstack + cat->idx_base);\n\n\t\t\t\tduk_err_setup_ljstate1(thr, (duk_small_int_t) cont_type, thr->valstack + cat->idx_base);\n\t\t\t\t/* No debugger Throw notify check on purpose (rethrow). */\n\n\t\t\t\tDUK_ASSERT(thr->heap->lj.jmpbuf_ptr != NULL);  /* always in executor */\n\t\t\t\tduk_err_longjmp(thr);\n\t\t\t\tDUK_UNREACHABLE();\n\t\t\t}\n\t\t\t}\n\n\t\t\t/* Must restart in all cases because we NULLed thr->ptr_curr_pc. */\n\t\t\tDUK_UNREACHABLE();\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_THROW: {\n\t\t\tduk_context *ctx = (duk_context *) thr;\n\t\t\tduk_small_uint_fast_t bc = DUK_DEC_BC(ins);\n\n\t\t\t/* Note: errors are augmented when they are created, not\n\t\t\t * when they are thrown.  So, don't augment here, it would\n\t\t\t * break re-throwing for instance.\n\t\t\t */\n\n\t\t\t/* Sync so that augmentation sees up-to-date activations, NULL\n\t\t\t * thr->ptr_curr_pc so that it's not used if side effects occur\n\t\t\t * in augmentation or longjmp handling.\n\t\t\t */\n\t\t\tDUK__SYNC_AND_NULL_CURR_PC();\n\n\t\t\tduk_dup(ctx, (duk_idx_t) bc);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"THROW ERROR (BYTECODE): %!dT (before throw augment)\",\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n#if defined(DUK_USE_AUGMENT_ERROR_THROW)\n\t\t\tduk_err_augment_error_throw(thr);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"THROW ERROR (BYTECODE): %!dT (after throw augment)\",\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n#endif\n\n\t\t\tduk_err_setup_ljstate1(thr, DUK_LJ_TYPE_THROW, DUK_GET_TVAL_NEGIDX(ctx, -1));\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\t\t\tduk_err_check_debugger_integration(thr);\n#endif\n\n\t\t\tDUK_ASSERT(thr->heap->lj.jmpbuf_ptr != NULL);  /* always in executor */\n\t\t\tduk_err_longjmp(thr);\n\t\t\tDUK_UNREACHABLE();\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_CSREG: {\n\t\t\t/*\n\t\t\t *  Assuming a register binds to a variable declared within this\n\t\t\t *  function (a declarative binding), the 'this' for the call\n\t\t\t *  setup is always 'undefined'.  E5 Section 10.2.1.1.6.\n\t\t\t */\n\n\t\t\tduk_small_uint_fast_t a = DUK_DEC_A(ins);\n\t\t\tduk_small_uint_fast_t bc = DUK_DEC_BC(ins);\n\n\t\t\t/* A -> register containing target function (not type checked here)\n\t\t\t * BC -> target registers (BC, BC + 1) for call setup\n\t\t\t */\n\n#if defined(DUK_USE_PREFER_SIZE)\n\t\t\tduk_dup((duk_context *) thr, a);\n\t\t\tduk_replace((duk_context *) thr, bc);\n\t\t\tduk_to_undefined((duk_context *) thr, bc + 1);\n#else\n\t\t\tduk_tval *tv1;\n\t\t\tduk_tval *tv2;\n\t\t\tduk_tval *tv3;\n\t\t\tduk_tval tv_tmp1;\n\t\t\tduk_tval tv_tmp2;\n\n\t\t\ttv1 = DUK__REGP(bc);\n\t\t\ttv2 = tv1 + 1;\n\t\t\tDUK_TVAL_SET_TVAL(&tv_tmp1, tv1);\n\t\t\tDUK_TVAL_SET_TVAL(&tv_tmp2, tv2);\n\t\t\ttv3 = DUK__REGP(a);\n\t\t\tDUK_TVAL_SET_TVAL(tv1, tv3);\n\t\t\tDUK_TVAL_INCREF(thr, tv1);  /* no side effects */\n\t\t\tDUK_TVAL_SET_UNDEFINED(tv2);  /* no need for incref */\n\t\t\tDUK_TVAL_DECREF(thr, &tv_tmp1);\n\t\t\tDUK_TVAL_DECREF(thr, &tv_tmp2);\n#endif\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_EVALCALL: {\n\t\t\t/* Eval call or a normal call made using the identifier 'eval'.\n\t\t\t * Eval calls are never handled as tail calls for simplicity.\n\t\t\t */\n\t\t\tduk_context *ctx = (duk_context *) thr;\n\t\t\tduk_small_uint_fast_t nargs;\n\t\t\tduk_uint_fast_t idx;\n\t\t\tduk_idx_t num_stack_args;\n\t\t\tduk_small_uint_t call_flags;\n\t\t\tduk_tval *tv_func;\n\t\t\tduk_hobject *obj_func;\n#if !defined(DUK_USE_EXEC_FUN_LOCAL)\n\t\t\tduk_hcompfunc *fun;\n#endif\n\n\t\t\t/* Technically we should also check for the possibility of\n\t\t\t * a pure Ecmascript-to-Ecmascript call: while built-in eval()\n\t\t\t * is native, it's possible for the 'eval' identifier to be\n\t\t\t * shadowed.  In practice that would be rare and optimizing the\n\t\t\t * C call stack for that case is a bit pointless.\n\t\t\t */\n\n\t\t\tnargs = (duk_small_uint_fast_t) DUK_DEC_A(ins);\n\t\t\tidx = (duk_uint_fast_t) DUK_DEC_BC(ins);\n\t\t\tduk_set_top(ctx, (duk_idx_t) (idx + nargs + 2));   /* [ ... func this arg1 ... argN ] */\n\n\t\t\tcall_flags = 0;\n\t\t\ttv_func = DUK_GET_TVAL_POSIDX(ctx, idx);\n\t\t\tif (DUK_TVAL_IS_OBJECT(tv_func)) {\n\t\t\t\tobj_func = DUK_TVAL_GET_OBJECT(tv_func);\n\t\t\t\tDUK_ASSERT(obj_func != NULL);\n\t\t\t\tif (DUK_HOBJECT_IS_NATFUNC(obj_func) &&\n\t\t\t\t    ((duk_hnatfunc *) obj_func)->func == duk_bi_global_object_eval) {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"call target is eval, call identifier was 'eval' -> direct eval\"));\n\t\t\t\t\tcall_flags |= DUK_CALL_FLAG_DIRECT_EVAL;\n\t\t\t\t}\n\t\t\t}\n\t\t\tnum_stack_args = nargs;\n\t\t\tduk_handle_call_unprotected(thr, num_stack_args, call_flags);\n\n#if !defined(DUK_USE_EXEC_FUN_LOCAL)\n\t\t\tfun = DUK__FUN();\n#endif\n\t\t\tduk_set_top(ctx, (duk_idx_t) fun->nregs);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_CALL:\n\t\tcase DUK_OP_TAILCALL: {\n\t\t\t/* DUK_OP_CALL: plain call, not tailcall compatible.\n\t\t\t *\n\t\t\t * DUK_OP_TAILCALL: plain call which is tailcall\n\t\t\t * compatible.  Tail call may not be possible due\n\t\t\t * to e.g. target not being an Ecmascript function.\n\t\t\t *\n\t\t\t * Not a direct eval call.  Indirect eval calls don't\n\t\t\t * need special handling here.\n\t\t\t */\n\n\t\t\t/* To determine whether to use an optimized Ecmascript-to-Ecmascript\n\t\t\t * call, we need to know whether the final, non-bound function is an\n\t\t\t * Ecmascript function.  Current implementation is to first try an\n\t\t\t * Ecma-to-Ecma call setup which also resolves the bound function\n\t\t\t * chain.  The setup attempt overwrites call target at DUK__REGP(idx)\n\t\t\t * and may also fudge the argument list.  However, it won't resolve\n\t\t\t * the effective 'this' binding if the setup fails.  This is somewhat\n\t\t\t * awkward, and the two call setup code paths should be merged.\n\t\t\t *\n\t\t\t * If an Ecma-to-Ecma call is not possible, the actual call handling\n\t\t\t * will do another (unnecessary) attempt to resolve the bound function.\n\t\t\t */\n\n\t\t\tduk_context *ctx = (duk_context *) thr;\n\t\t\tduk_small_uint_fast_t nargs;\n\t\t\tduk_uint_fast_t idx;\n\t\t\tduk_idx_t num_stack_args;\n\t\t\tduk_small_uint_t call_flags;\n#if !defined(DUK_USE_EXEC_FUN_LOCAL)\n\t\t\tduk_hcompfunc *fun;\n#endif\n\n\t\t\t/* A -> nargs\n\t\t\t * BC -> base register for call (base -> func, base+1 -> this, base+2 -> arg1 ... base+2+N-1 -> argN)\n\t\t\t */\n\n\t\t\t/* XXX: in some cases it's faster NOT to reuse the value\n\t\t\t * stack but rather copy the arguments on top of the stack\n\t\t\t * (mainly when the calling value stack is large and the value\n\t\t\t * stack resize would be large).  See DUK_OP_NEW.\n\t\t\t */\n\n\t\t\tnargs = (duk_small_uint_fast_t) DUK_DEC_A(ins);\n\t\t\tidx = (duk_uint_fast_t) DUK_DEC_BC(ins);\n\t\t\tduk_set_top(ctx, (duk_idx_t) (idx + nargs + 2));   /* [ ... func this arg1 ... argN ] */\n\n\t\t\t/* DUK_OP_CALL and DUK_OP_TAILCALL are consecutive\n\t\t\t * which allows a simple bit test.\n\t\t\t */\n\t\t\tDUK_ASSERT((DUK_OP_CALL & 0x01) == 0);\n\t\t\tDUK_ASSERT((DUK_OP_TAILCALL & 0x01) == 1);\n\t\t\tcall_flags = (ins & (1UL << DUK_BC_SHIFT_OP)) ? DUK_CALL_FLAG_IS_TAILCALL : 0;\n\n\t\t\tnum_stack_args = nargs;\n\t\t\tif (duk_handle_ecma_call_setup(thr, num_stack_args, call_flags)) {\n\t\t\t\t/* Ecma-to-ecma call possible, may or may not be a tail call.\n\t\t\t\t * Avoid C recursion by being clever.\n\t\t\t\t */\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"ecma-to-ecma call setup possible, restart execution\"));\n\t\t\t\t/* curr_pc synced by duk_handle_ecma_call_setup() */\n\t\t\t\tgoto restart_execution;\n\t\t\t}\n\n\t\t\t/* Recompute argument count: bound function handling may have shifted. */\n\t\t\tnum_stack_args = duk_get_top(ctx) - (idx + 2);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"recomputed arg count: %ld\\n\", (long) num_stack_args));\n\n\t\t\t/* Target is either a lightfunc or a function object.\n\t\t\t * We don't need to check for eval handling here: the\n\t\t\t * call may be an indirect eval ('myEval(\"something\")')\n\t\t\t * but that requires no special handling.\n\t\t\t */\n\n\t\t\tduk_handle_call_unprotected(thr, num_stack_args, 0 /*call_flags*/);\n\n\t\t\t/* duk_js_call.c is required to restore the stack reserve\n\t\t\t * so we only need to reset the top.\n\t\t\t */\n#if !defined(DUK_USE_EXEC_FUN_LOCAL)\n\t\t\tfun = DUK__FUN();\n#endif\n\t\t\tduk_set_top(ctx, (duk_idx_t) fun->nregs);\n\n\t\t\t/* No need to reinit setjmp() catchpoint, as call handling\n\t\t\t * will store and restore our state.\n\t\t\t */\n\n\t\t\t/* When debugger is enabled, we need to recheck the activation\n\t\t\t * status after returning.  This is now handled by call handling\n\t\t\t * and heap->dbg_force_restart.\n\t\t\t */\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_NEW: {\n\t\t\tduk_context *ctx = (duk_context *) thr;\n\t\t\tduk_small_uint_fast_t a = DUK_DEC_A(ins);\n\t\t\tduk_small_uint_fast_t bc = DUK_DEC_BC(ins);\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n#if !defined(DUK_USE_EXEC_FUN_LOCAL)\n\t\t\tduk_hcompfunc *fun;\n#endif\n#else\n\t\t\tduk_small_uint_fast_t count;\n\t\t\tduk_tval *tv_src;\n#endif\n\n\t\t\t/* A -> num args (N)\n\t\t\t * BC -> target register and start reg: constructor, arg1, ..., argN\n\t\t\t */\n\n\t\t\t/* duk_new() will call the constuctor using duk_handle_call().\n\t\t\t * A constructor call prevents a yield from inside the constructor,\n\t\t\t * even if the constructor is an Ecmascript function.\n\t\t\t */\n\n\t\t\t/* Don't need to sync curr_pc here; duk_new() will do that\n\t\t\t * when it augments the created error.\n\t\t\t */\n\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n\t\t\t/* This alternative relies on our being allowed to trash anything\n\t\t\t * above 'bc' so we can just reuse the argument registers which\n\t\t\t * means smaller value stack use.  Footprint is a bit smaller.\n\t\t\t */\n\t\t\tduk_set_top(ctx, (duk_idx_t) (bc + a + 1));\n\t\t\tduk_new(ctx, (duk_idx_t) a);  /* [... constructor arg1 ... argN] -> [retval] */\n\n\t\t\t/* The return value is already in its correct place at the stack,\n\t\t\t * i.e. it has replaced the 'constructor' at index bc.  Just reset\n\t\t\t * top and we're done.\n\t\t\t */\n\n#if !defined(DUK_USE_EXEC_FUN_LOCAL)\n\t\t\tfun = DUK__FUN();\n#endif\n\t\t\tduk_set_top(ctx, (duk_idx_t) fun->nregs);\n#else  /* DUK_USE_EXEC_PREFER_SIZE */\n\t\t\t/* Faster alternative is to duplicate the values to avoid a resize.\n\t\t\t * This depends on the relative size between the value stack and\n\t\t\t * the argument count, though.\n\t\t\t */\n\t\t\tcount = a + 1;\n\t\t\tduk_require_stack(ctx, count);\n\t\t\ttv_src = DUK_GET_TVAL_POSIDX(ctx, bc);\n\t\t\tduk__push_tvals_incref_only(thr, tv_src, count);\n\t\t\tduk_new(ctx, (duk_idx_t) a);  /* [... constructor arg1 ... argN] -> [retval] */\n\t\t\tduk_replace(ctx, bc);\n#endif  /* DUK_USE_EXEC_PREFER_SIZE */\n\n\t\t\t/* When debugger is enabled, we need to recheck the activation\n\t\t\t * status after returning.  This is now handled by call handling\n\t\t\t * and heap->dbg_force_restart.\n\t\t\t */\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_NEWOBJ: {\n\t\t\tduk_context *ctx = (duk_context *) thr;\n\t\t\tduk_push_object(ctx);\n\t\t\tDUK__REPLACE_TOP_BC_BREAK();\n\t\t}\n\n\t\tcase DUK_OP_NEWARR: {\n\t\t\tduk_context *ctx = (duk_context *) thr;\n\t\t\tduk_push_array(ctx);\n\t\t\tDUK__REPLACE_TOP_BC_BREAK();\n\t\t}\n\n\t\tcase DUK_OP_MPUTOBJ:\n\t\tcase DUK_OP_MPUTOBJI: {\n\t\t\tduk_context *ctx = (duk_context *) thr;\n\t\t\tduk_idx_t obj_idx;\n\t\t\tduk_uint_fast_t idx, idx_end;\n\t\t\tduk_small_uint_fast_t count;\n\n\t\t\t/* A -> register of target object\n\t\t\t * B -> first register of key/value pair list\n\t\t\t *      or register containing first register number if indirect\n\t\t\t * C -> number of key/value pairs * 2\n\t\t\t *      (= number of value stack indices used starting from 'B')\n\t\t\t */\n\n\t\t\tobj_idx = DUK_DEC_A(ins);\n\t\t\tDUK_ASSERT(duk_is_object(ctx, obj_idx));\n\n\t\t\tidx = (duk_uint_fast_t) DUK_DEC_B(ins);\n\t\t\tif (DUK_DEC_OP(ins) == DUK_OP_MPUTOBJI) {\n\t\t\t\tDUK__LOOKUP_INDIRECT_INDEX(idx);\n\t\t\t}\n\n\t\t\tcount = (duk_small_uint_fast_t) DUK_DEC_C(ins);\n\t\t\tDUK_ASSERT(count > 0);  /* compiler guarantees */\n\t\t\tidx_end = idx + count;\n\n#if defined(DUK_USE_EXEC_INDIRECT_BOUND_CHECK)\n\t\t\tif (DUK_UNLIKELY(idx_end > (duk_uint_fast_t) duk_get_top(ctx))) {\n\t\t\t\t/* XXX: use duk_is_valid_index() instead? */\n\t\t\t\t/* XXX: improve check; check against nregs, not against top */\n\t\t\t\tDUK__INTERNAL_ERROR(\"MPUTOBJ out of bounds\");\n\t\t\t}\n#endif\n\n\t\t\t/* Use 'force' flag to duk_def_prop() to ensure that any\n\t\t\t * inherited properties don't prevent the operation.\n\t\t\t * With ES2015 duplicate properties are allowed, so that we\n\t\t\t * must overwrite any previous data or accessor property.\n\t\t\t *\n\t\t\t * With ES2015 computed property names the literal keys\n\t\t\t * may be arbitrary values and need to be ToPropertyKey()\n\t\t\t * coerced at runtime.\n\t\t\t */\n\t\t\tdo {\n\t\t\t\t/* XXX: faster initialization (direct access or better primitives) */\n\t\t\t\tduk_dup(ctx, idx);\n\t\t\t\tduk_dup(ctx, idx + 1);\n\t\t\t\tduk_def_prop(ctx, obj_idx, DUK_DEFPROP_HAVE_VALUE |\n\t\t\t\t                           DUK_DEFPROP_FORCE |\n\t\t\t\t                           DUK_DEFPROP_SET_WRITABLE |\n\t\t\t\t                           DUK_DEFPROP_SET_ENUMERABLE |\n\t\t\t\t                           DUK_DEFPROP_SET_CONFIGURABLE);\n\t\t\t\tidx += 2;\n\t\t\t} while (idx < idx_end);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_INITSET:\n\t\tcase DUK_OP_INITGET: {\n\t\t\tduk_context *ctx = (duk_context *) thr;\n\t\t\tduk_bool_t is_set = (op == DUK_OP_INITSET);\n\t\t\tduk_uint_fast_t idx;\n\t\t\tduk_uint_t defprop_flags;\n\n\t\t\t/* A -> object register (acts as a source)\n\t\t\t * BC -> BC+0 contains key, BC+1 closure (value)\n\t\t\t */\n\n\t\t\t/* INITSET/INITGET are only used to initialize object literal keys.\n\t\t\t * There may be a previous propery in ES2015 because duplicate property\n\t\t\t * names are allowed.\n\t\t\t */\n\n\t\t\t/* This could be made more optimal by accessing internals directly. */\n\n\t\t\tidx = (duk_uint_fast_t) DUK_DEC_BC(ins);\n\t\t\tduk_dup(ctx, (duk_idx_t) (idx + 0));  /* key */\n\t\t\tduk_dup(ctx, (duk_idx_t) (idx + 1));  /* getter/setter */\n\t\t\tif (is_set) {\n\t\t\t\tdefprop_flags = DUK_DEFPROP_HAVE_SETTER |\n\t\t\t\t                DUK_DEFPROP_FORCE |\n\t\t\t\t                DUK_DEFPROP_SET_ENUMERABLE |\n\t\t\t\t                DUK_DEFPROP_SET_CONFIGURABLE;\n\t\t\t} else {\n\t\t\t\tdefprop_flags = DUK_DEFPROP_HAVE_GETTER |\n\t\t\t\t                DUK_DEFPROP_FORCE |\n\t\t\t\t                DUK_DEFPROP_SET_ENUMERABLE |\n\t\t\t\t                DUK_DEFPROP_SET_CONFIGURABLE;\n\t\t\t}\n\t\t\tduk_def_prop(ctx, (duk_idx_t) DUK_DEC_A(ins), defprop_flags);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_MPUTARR:\n\t\tcase DUK_OP_MPUTARRI: {\n\t\t\tduk_context *ctx = (duk_context *) thr;\n\t\t\tduk_idx_t obj_idx;\n\t\t\tduk_uint_fast_t idx, idx_end;\n\t\t\tduk_small_uint_fast_t count;\n\t\t\tduk_tval *tv1;\n\t\t\tduk_uint32_t arr_idx;\n\n\t\t\t/* A -> register of target object\n\t\t\t * B -> first register of value data (start_index, value1, value2, ..., valueN)\n\t\t\t *      or register containing first register number if indirect\n\t\t\t * C -> number of key/value pairs (N)\n\t\t\t */\n\n\t\t\tobj_idx = DUK_DEC_A(ins);\n\t\t\tDUK_ASSERT(duk_is_object(ctx, obj_idx));\n\n\t\t\tidx = (duk_uint_fast_t) DUK_DEC_B(ins);\n\t\t\tif (DUK_DEC_OP(ins) == DUK_OP_MPUTARRI) {\n\t\t\t\tDUK__LOOKUP_INDIRECT_INDEX(idx);\n\t\t\t}\n\n\t\t\tcount = (duk_small_uint_fast_t) DUK_DEC_C(ins);\n\t\t\tDUK_ASSERT(count > 0 + 1);  /* compiler guarantees */\n\t\t\tidx_end = idx + count;\n\n#if defined(DUK_USE_EXEC_INDIRECT_BOUND_CHECK)\n\t\t\tif (idx_end > (duk_uint_fast_t) duk_get_top(ctx)) {\n\t\t\t\t/* XXX: use duk_is_valid_index() instead? */\n\t\t\t\t/* XXX: improve check; check against nregs, not against top */\n\t\t\t\tDUK__INTERNAL_ERROR(\"MPUTARR out of bounds\");\n\t\t\t}\n#endif\n\n\t\t\ttv1 = DUK__REGP(idx);\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv1));\n#if defined(DUK_USE_FASTINT)\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_FASTINT(tv1));\n\t\t\tarr_idx = (duk_uint32_t) DUK_TVAL_GET_FASTINT_U32(tv1);\n#else\n\t\t\tarr_idx = (duk_uint32_t) DUK_TVAL_GET_NUMBER(tv1);\n#endif\n\t\t\tidx++;\n\n\t\t\tdo {\n\t\t\t\t/* duk_xdef_prop() will define an own property without any array\n\t\t\t\t * special behaviors.  We'll need to set the array length explicitly\n\t\t\t\t * in the end.  For arrays with elisions, the compiler will emit an\n\t\t\t\t * explicit SETALEN which will update the length.\n\t\t\t\t */\n\n\t\t\t\t/* XXX: because we're dealing with 'own' properties of a fresh array,\n\t\t\t\t * the array initializer should just ensure that the array has a large\n\t\t\t\t * enough array part and write the values directly into array part,\n\t\t\t\t * and finally set 'length' manually in the end (as already happens now).\n\t\t\t\t */\n\n\t\t\t\tduk_dup(ctx, idx);\n\t\t\t\tduk_xdef_prop_index_wec(ctx, obj_idx, arr_idx);\n\n\t\t\t\tidx++;\n\t\t\t\tarr_idx++;\n\t\t\t} while (idx < idx_end);\n\n\t\t\t/* XXX: E5.1 Section 11.1.4 coerces the final length through\n\t\t\t * ToUint32() which is odd but happens now as a side effect of\n\t\t\t * 'arr_idx' type.\n\t\t\t */\n\t\t\tduk_set_length(thr, obj_idx, (duk_size_t) (duk_uarridx_t) arr_idx);\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_SETALEN: {\n\t\t\tduk_tval *tv1;\n\t\t\tduk_hobject *h;\n\t\t\tduk_uint32_t len;\n\n\t\t\ttv1 = DUK__REGP_A(ins);\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_OBJECT(tv1));\n\t\t\th = DUK_TVAL_GET_OBJECT(tv1);\n\t\t\tDUK_ASSERT(DUK_HOBJECT_IS_ARRAY(h));\n\n\t\t\ttv1 = DUK__REGP_BC(ins);\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv1));\n#if defined(DUK_USE_FASTINT)\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_FASTINT(tv1));\n\t\t\tlen = (duk_uint32_t) DUK_TVAL_GET_FASTINT_U32(tv1);\n#else\n\t\t\tlen = (duk_uint32_t) DUK_TVAL_GET_NUMBER(tv1);\n#endif\n\t\t\t((duk_harray *) h)->length = len;\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_INITENUM: {\n\t\t\tduk_context *ctx = (duk_context *) thr;\n\t\t\tduk_small_uint_fast_t b = DUK_DEC_B(ins);\n\t\t\tduk_small_uint_fast_t c = DUK_DEC_C(ins);\n\n\t\t\t/*\n\t\t\t *  Enumeration semantics come from for-in statement, E5 Section 12.6.4.\n\t\t\t *  If called with 'null' or 'undefined', this opcode returns 'null' as\n\t\t\t *  the enumerator, which is special cased in NEXTENUM.  This simplifies\n\t\t\t *  the compiler part\n\t\t\t */\n\n\t\t\t/* B -> register for writing enumerator object\n\t\t\t * C -> value to be enumerated (register)\n\t\t\t */\n\n\t\t\tif (duk_is_null_or_undefined(ctx, (duk_idx_t) c)) {\n\t\t\t\tduk_push_null(ctx);\n\t\t\t\tduk_replace(ctx, (duk_idx_t) b);\n\t\t\t} else {\n\t\t\t\tduk_dup(ctx, (duk_idx_t) c);\n\t\t\t\tduk_to_object(ctx, -1);\n\t\t\t\tduk_hobject_enumerator_create(ctx, 0 /*enum_flags*/);  /* [ ... val ] --> [ ... enum ] */\n\t\t\t\tduk_replace(ctx, (duk_idx_t) b);\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_NEXTENUM: {\n\t\t\tduk_context *ctx = (duk_context *) thr;\n\t\t\tduk_small_uint_fast_t b = DUK_DEC_B(ins);\n\t\t\tduk_small_uint_fast_t c = DUK_DEC_C(ins);\n\n\t\t\t/*\n\t\t\t *  NEXTENUM checks whether the enumerator still has unenumerated\n\t\t\t *  keys.  If so, the next key is loaded to the target register\n\t\t\t *  and the next instruction is skipped.  Otherwise the next instruction\n\t\t\t *  will be executed, jumping out of the enumeration loop.\n\t\t\t */\n\n\t\t\t/* B -> target register for next key\n\t\t\t * C -> enum register\n\t\t\t */\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"NEXTENUM: b->%!T, c->%!T\",\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, (duk_idx_t) b),\n\t\t\t                     (duk_tval *) duk_get_tval(ctx, (duk_idx_t) c)));\n\n\t\t\tif (duk_is_object(ctx, (duk_idx_t) c)) {\n\t\t\t\t/* XXX: assert 'c' is an enumerator */\n\t\t\t\tduk_dup(ctx, (duk_idx_t) c);\n\t\t\t\tif (duk_hobject_enumerator_next(ctx, 0 /*get_value*/)) {\n\t\t\t\t\t/* [ ... enum ] -> [ ... next_key ] */\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"enum active, next key is %!T, skip jump slot \",\n\t\t\t\t\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\t\t\t\t\tcurr_pc++;\n\t\t\t\t} else {\n\t\t\t\t\t/* [ ... enum ] -> [ ... ] */\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"enum finished, execute jump slot\"));\n\t\t\t\t\tDUK_ASSERT(DUK_TVAL_IS_UNDEFINED(thr->valstack_top));  /* valstack policy */\n\t\t\t\t\tthr->valstack_top++;\n\t\t\t\t}\n\t\t\t\tduk_replace(ctx, (duk_idx_t) b);\n\t\t\t} else {\n\t\t\t\t/* 'null' enumerator case -> behave as with an empty enumerator */\n\t\t\t\tDUK_ASSERT(duk_is_null(ctx, (duk_idx_t) c));\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"enum is null, execute jump slot\"));\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_INVLHS: {\n\t\t\tDUK_ERROR_REFERENCE(thr, DUK_STR_INVALID_LVALUE);\n\t\t\tDUK_UNREACHABLE();\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_DEBUGGER: {\n\t\t\t/* Opcode only emitted by compiler when debugger\n\t\t\t * support is enabled.  Ignore it silently without\n\t\t\t * debugger support, in case it has been loaded\n\t\t\t * from precompiled bytecode.\n\t\t\t */\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\t\t\tif (duk_debug_is_attached(thr->heap)) {\n\t\t\t\tDUK_D(DUK_DPRINT(\"DEBUGGER statement encountered, halt execution\"));\n\t\t\t\tDUK__SYNC_AND_NULL_CURR_PC();\n\t\t\t\tduk_debug_halt_execution(thr, 1 /*use_prev_pc*/);\n\t\t\t\tDUK_D(DUK_DPRINT(\"DEBUGGER statement finished, resume execution\"));\n\t\t\t\tgoto restart_execution;\n\t\t\t} else {\n\t\t\t\tDUK_D(DUK_DPRINT(\"DEBUGGER statement ignored, debugger not attached\"));\n\t\t\t}\n#else\n\t\t\tDUK_D(DUK_DPRINT(\"DEBUGGER statement ignored, no debugger support\"));\n#endif\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_NOP: {\n\t\t\t/* nop */\n\t\t\tbreak;\n\t\t}\n\n\t\tcase DUK_OP_INVALID: {\n\t\t\tDUK_ERROR_FMT1(thr, DUK_ERR_ERROR, \"INVALID opcode (%ld)\", (long) DUK_DEC_ABC(ins));\n\t\t\tbreak;\n\t\t}\n\n#if !defined(DUK_USE_EXEC_PREFER_SIZE)\n#if !defined(DUK_USE_ES7_EXP_OPERATOR)\n\t\tcase DUK_OP_EXP_RR:\n\t\tcase DUK_OP_EXP_CR:\n\t\tcase DUK_OP_EXP_RC:\n\t\tcase DUK_OP_EXP_CC:\n#endif\n\t\tcase DUK_OP_UNUSED194:\n\t\tcase DUK_OP_UNUSED195:\n\t\tcase DUK_OP_UNUSED196:\n\t\tcase DUK_OP_UNUSED197:\n\t\tcase DUK_OP_UNUSED198:\n\t\tcase DUK_OP_UNUSED199:\n\t\tcase DUK_OP_UNUSED200:\n\t\tcase DUK_OP_UNUSED201:\n\t\tcase DUK_OP_UNUSED202:\n\t\tcase DUK_OP_UNUSED203:\n\t\tcase DUK_OP_UNUSED204:\n\t\tcase DUK_OP_UNUSED205:\n\t\tcase DUK_OP_UNUSED206:\n\t\tcase DUK_OP_UNUSED207:\n\t\tcase DUK_OP_UNUSED208:\n\t\tcase DUK_OP_UNUSED209:\n\t\tcase DUK_OP_UNUSED210:\n\t\tcase DUK_OP_UNUSED211:\n\t\tcase DUK_OP_UNUSED212:\n\t\tcase DUK_OP_UNUSED213:\n\t\tcase DUK_OP_UNUSED214:\n\t\tcase DUK_OP_UNUSED215:\n\t\tcase DUK_OP_UNUSED216:\n\t\tcase DUK_OP_UNUSED217:\n\t\tcase DUK_OP_UNUSED218:\n\t\tcase DUK_OP_UNUSED219:\n\t\tcase DUK_OP_UNUSED220:\n\t\tcase DUK_OP_UNUSED221:\n\t\tcase DUK_OP_UNUSED222:\n\t\tcase DUK_OP_UNUSED223:\n\t\tcase DUK_OP_UNUSED224:\n\t\tcase DUK_OP_UNUSED225:\n\t\tcase DUK_OP_UNUSED226:\n\t\tcase DUK_OP_UNUSED227:\n\t\tcase DUK_OP_UNUSED228:\n\t\tcase DUK_OP_UNUSED229:\n\t\tcase DUK_OP_UNUSED230:\n\t\tcase DUK_OP_UNUSED231:\n\t\tcase DUK_OP_UNUSED232:\n\t\tcase DUK_OP_UNUSED233:\n\t\tcase DUK_OP_UNUSED234:\n\t\tcase DUK_OP_UNUSED235:\n\t\tcase DUK_OP_UNUSED236:\n\t\tcase DUK_OP_UNUSED237:\n\t\tcase DUK_OP_UNUSED238:\n\t\tcase DUK_OP_UNUSED239:\n\t\tcase DUK_OP_UNUSED240:\n\t\tcase DUK_OP_UNUSED241:\n\t\tcase DUK_OP_UNUSED242:\n\t\tcase DUK_OP_UNUSED243:\n\t\tcase DUK_OP_UNUSED244:\n\t\tcase DUK_OP_UNUSED245:\n\t\tcase DUK_OP_UNUSED246:\n\t\tcase DUK_OP_UNUSED247:\n\t\tcase DUK_OP_UNUSED248:\n\t\tcase DUK_OP_UNUSED249:\n\t\tcase DUK_OP_UNUSED250:\n\t\tcase DUK_OP_UNUSED251:\n\t\tcase DUK_OP_UNUSED252:\n\t\tcase DUK_OP_UNUSED253:\n\t\tcase DUK_OP_UNUSED254:\n\t\tcase DUK_OP_UNUSED255:\n\t\t/* Force all case clauses to map to an actual handler\n\t\t * so that the compiler can emit a jump without a bounds\n\t\t * check: the switch argument is a duk_uint8_t so that\n\t\t * the compiler may be able to figure it out.  This is\n\t\t * a small detail and obviously compiler dependent.\n\t\t */\n\t\t/* default: clause omitted on purpose */\n#else\n\t\tdefault:\n#endif  /* DUK_USE_EXEC_PREFER_SIZE */\n\t\t{\n\t\t\t/* Default case catches invalid/unsupported opcodes. */\n\t\t\tDUK_D(DUK_DPRINT(\"invalid opcode: %ld - %!I\", (long) op, ins));\n\t\t\tDUK__INTERNAL_ERROR(\"invalid opcode\");\n\t\t\tbreak;\n\t\t}\n\n\t\t}  /* end switch */\n\n\t\tcontinue;\n\n\t\t/* Some shared exit paths for opcode handling below.  These\n\t\t * are mostly useful to reduce code footprint when multiple\n\t\t * opcodes have a similar epilogue (like replacing stack top\n\t\t * with index 'a').\n\t\t */\n\n#if defined(DUK_USE_EXEC_PREFER_SIZE)\n\t replace_top_a:\n\t\tDUK__REPLACE_TO_TVPTR(thr, DUK__REGP_A(ins));\n\t\tcontinue;\n\t replace_top_bc:\n\t\tDUK__REPLACE_TO_TVPTR(thr, DUK__REGP_BC(ins));\n\t\tcontinue;\n#endif\n\t}\n\tDUK_UNREACHABLE();\n\n#if !defined(DUK_USE_VERBOSE_EXECUTOR_ERRORS)\n internal_error:\n\tDUK_ERROR_INTERNAL(thr);\n#endif\n}\n\n/* automatic undefs */\n#undef DUK__BYTEOFF_A\n#undef DUK__BYTEOFF_B\n#undef DUK__BYTEOFF_BC\n#undef DUK__BYTEOFF_C\n#undef DUK__COMPARE_BODY\n#undef DUK__CONST\n#undef DUK__CONSTP\n#undef DUK__CONSTP_A\n#undef DUK__CONSTP_B\n#undef DUK__CONSTP_BC\n#undef DUK__CONSTP_C\n#undef DUK__DELPROP_BODY\n#undef DUK__EQ_BODY\n#undef DUK__FUN\n#undef DUK__GETPROP_BODY\n#undef DUK__GE_BODY\n#undef DUK__GT_BODY\n#undef DUK__INLINE_PERF\n#undef DUK__INSTOF_BODY\n#undef DUK__INTERNAL_ERROR\n#undef DUK__INT_NOACTION\n#undef DUK__INT_RESTART\n#undef DUK__IN_BODY\n#undef DUK__LE_BODY\n#undef DUK__LONGJMP_RESTART\n#undef DUK__LONGJMP_RETHROW\n#undef DUK__LOOKUP_INDIRECT_INDEX\n#undef DUK__LT_BODY\n#undef DUK__MASK_A\n#undef DUK__MASK_B\n#undef DUK__MASK_BC\n#undef DUK__MASK_C\n#undef DUK__NEQ_BODY\n#undef DUK__PUTPROP_BODY\n#undef DUK__RCBIT_B\n#undef DUK__RCBIT_C\n#undef DUK__REG\n#undef DUK__REGCONSTP_B\n#undef DUK__REGCONSTP_C\n#undef DUK__REGP\n#undef DUK__REGP_A\n#undef DUK__REGP_B\n#undef DUK__REGP_BC\n#undef DUK__REGP_C\n#undef DUK__REPLACE_BOOL_A_BREAK\n#undef DUK__REPLACE_TOP_A_BREAK\n#undef DUK__REPLACE_TOP_BC_BREAK\n#undef DUK__REPLACE_TO_TVPTR\n#undef DUK__RETHAND_FINISHED\n#undef DUK__RETHAND_RESTART\n#undef DUK__RETURN_SHARED\n#undef DUK__SEQ_BODY\n#undef DUK__SHIFT_A\n#undef DUK__SHIFT_B\n#undef DUK__SHIFT_BC\n#undef DUK__SHIFT_C\n#undef DUK__SNEQ_BODY\n#undef DUK__STRICT\n#undef DUK__SYNC_AND_NULL_CURR_PC\n#undef DUK__SYNC_CURR_PC\n#undef DUK__TVAL_SHIFT\n/*\n *  Ecmascript specification algorithm and conversion helpers.\n *\n *  These helpers encapsulate the primitive Ecmascript operation semantics,\n *  and are used by the bytecode executor and the API (among other places).\n *  Some primitives are only implemented as part of the API and have no\n *  \"internal\" helper.  This is the case when an internal helper would not\n *  really be useful; e.g. the operation is rare, uses value stack heavily,\n *  etc.\n *\n *  The operation arguments depend on what is required to implement\n *  the operation:\n *\n *    - If an operation is simple and stateless, and has no side\n *      effects, it won't take an duk_hthread argument and its\n *      arguments may be duk_tval pointers (which are safe as long\n *      as no side effects take place).\n *\n *    - If complex coercions are required (e.g. a \"ToNumber\" coercion)\n *      or errors may be thrown, the operation takes an duk_hthread\n *      argument.  This also implies that the operation may have\n *      arbitrary side effects, invalidating any duk_tval pointers.\n *\n *    - For operations with potential side effects, arguments can be\n *      taken in several ways:\n *\n *      a) as duk_tval pointers, which makes sense if the \"common case\"\n *         can be resolved without side effects (e.g. coercion); the\n *         arguments are pushed to the valstack for coercion if\n *         necessary\n *\n *      b) as duk_tval values\n *\n *      c) implicitly on value stack top\n *\n *      d) as indices to the value stack\n *\n *  Future work:\n *\n *     - Argument styles may not be the most sensible in every case now.\n *\n *     - In-place coercions might be useful for several operations, if\n *       in-place coercion is OK for the bytecode executor and the API.\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  ToPrimitive()  (E5 Section 9.1)\n *\n *  ==> implemented in the API.\n */\n\n/*\n *  ToBoolean()  (E5 Section 9.2)\n */\n\nDUK_INTERNAL duk_bool_t duk_js_toboolean(duk_tval *tv) {\n\tswitch (DUK_TVAL_GET_TAG(tv)) {\n\tcase DUK_TAG_UNDEFINED:\n\tcase DUK_TAG_NULL:\n\t\treturn 0;\n\tcase DUK_TAG_BOOLEAN:\n\t\tDUK_ASSERT(DUK_TVAL_GET_BOOLEAN(tv) == 0 || DUK_TVAL_GET_BOOLEAN(tv) == 1);\n\t\treturn DUK_TVAL_GET_BOOLEAN(tv);\n\tcase DUK_TAG_STRING: {\n\t\t/* Symbols ToBoolean() coerce to true, regardless of their\n\t\t * description.  This happens with no explicit check because\n\t\t * of the symbol representation byte prefix.\n\t\t */\n\t\tduk_hstring *h = DUK_TVAL_GET_STRING(tv);\n\t\tDUK_ASSERT(h != NULL);\n\t\treturn (DUK_HSTRING_GET_BYTELEN(h) > 0 ? 1 : 0);\n\t}\n\tcase DUK_TAG_OBJECT: {\n\t\treturn 1;\n\t}\n\tcase DUK_TAG_BUFFER: {\n\t\t/* Mimic Uint8Array semantics: objects coerce true, regardless\n\t\t * of buffer length (zero or not) or context.\n\t\t */\n\t\treturn 1;\n\t}\n\tcase DUK_TAG_POINTER: {\n\t\tvoid *p = DUK_TVAL_GET_POINTER(tv);\n\t\treturn (p != NULL ? 1 : 0);\n\t}\n\tcase DUK_TAG_LIGHTFUNC: {\n\t\treturn 1;\n\t}\n#if defined(DUK_USE_FASTINT)\n\tcase DUK_TAG_FASTINT:\n\t\tif (DUK_TVAL_GET_FASTINT(tv) != 0) {\n\t\t\treturn 1;\n\t\t} else {\n\t\t\treturn 0;\n\t\t}\n#endif\n\tdefault: {\n\t\t/* number */\n\t\tduk_double_t d;\n#if defined(DUK_USE_PREFER_SIZE)\n\t\tint c;\n#endif\n\t\tDUK_ASSERT(!DUK_TVAL_IS_UNUSED(tv));\n\t\tDUK_ASSERT(DUK_TVAL_IS_DOUBLE(tv));\n\t\td = DUK_TVAL_GET_DOUBLE(tv);\n#if defined(DUK_USE_PREFER_SIZE)\n\t\tc = DUK_FPCLASSIFY((double) d);\n\t\tif (c == DUK_FP_ZERO || c == DUK_FP_NAN) {\n\t\t\treturn 0;\n\t\t} else {\n\t\t\treturn 1;\n\t\t}\n#else\n\t\tDUK_ASSERT(duk_double_is_nan_or_zero(d) == 0 || duk_double_is_nan_or_zero(d) == 1);\n\t\treturn duk_double_is_nan_or_zero(d) ^ 1;\n#endif\n\t}\n\t}\n\tDUK_UNREACHABLE();\n}\n\n/*\n *  ToNumber()  (E5 Section 9.3)\n *\n *  Value to convert must be on stack top, and is popped before exit.\n *\n *  See: http://www.cs.indiana.edu/~burger/FP-Printing-PLDI96.pdf\n *       http://www.cs.indiana.edu/~burger/fp/index.html\n *\n *  Notes on the conversion:\n *\n *    - There are specific requirements on the accuracy of the conversion\n *      through a \"Mathematical Value\" (MV), so this conversion is not\n *      trivial.\n *\n *    - Quick rejects (e.g. based on first char) are difficult because\n *      the grammar allows leading and trailing white space.\n *\n *    - Quick reject based on string length is difficult even after\n *      accounting for white space; there may be arbitrarily many\n *      decimal digits.\n *\n *    - Standard grammar allows decimal values (\"123\"), hex values\n *      (\"0x123\") and infinities\n *\n *    - Unlike source code literals, ToNumber() coerces empty strings\n *      and strings with only whitespace to zero (not NaN).\n */\n\n/* E5 Section 9.3.1 */\nDUK_LOCAL duk_double_t duk__tonumber_string_raw(duk_hthread *thr) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_small_uint_t s2n_flags;\n\tduk_double_t d;\n\n\tDUK_ASSERT(duk_is_string(ctx, -1));\n\n\t/* Quite lenient, e.g. allow empty as zero, but don't allow trailing\n\t * garbage.\n\t */\n\ts2n_flags = DUK_S2N_FLAG_TRIM_WHITE |\n\t            DUK_S2N_FLAG_ALLOW_EXP |\n\t            DUK_S2N_FLAG_ALLOW_PLUS |\n\t            DUK_S2N_FLAG_ALLOW_MINUS |\n\t            DUK_S2N_FLAG_ALLOW_INF |\n\t            DUK_S2N_FLAG_ALLOW_FRAC |\n\t            DUK_S2N_FLAG_ALLOW_NAKED_FRAC |\n\t            DUK_S2N_FLAG_ALLOW_EMPTY_FRAC |\n\t            DUK_S2N_FLAG_ALLOW_EMPTY_AS_ZERO |\n\t            DUK_S2N_FLAG_ALLOW_LEADING_ZERO |\n\t            DUK_S2N_FLAG_ALLOW_AUTO_HEX_INT |\n\t            DUK_S2N_FLAG_ALLOW_AUTO_OCT_INT |\n\t            DUK_S2N_FLAG_ALLOW_AUTO_BIN_INT;\n\n\tduk_numconv_parse(ctx, 10 /*radix*/, s2n_flags);\n\n#if defined(DUK_USE_PREFER_SIZE)\n\td = duk_get_number(ctx, -1);\n\tduk_pop(ctx);\n#else\n\tthr->valstack_top--;\n\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(thr->valstack_top));\n\tDUK_ASSERT(DUK_TVAL_IS_DOUBLE(thr->valstack_top));  /* no fastint conversion in numconv now */\n\tDUK_ASSERT(!DUK_TVAL_NEEDS_REFCOUNT_UPDATE(thr->valstack_top));\n\td = DUK_TVAL_GET_DOUBLE(thr->valstack_top);  /* assumes not a fastint */\n\tDUK_TVAL_SET_UNDEFINED(thr->valstack_top);\n#endif\n\n\treturn d;\n}\n\nDUK_INTERNAL duk_double_t duk_js_tonumber(duk_hthread *thr, duk_tval *tv) {\n\tduk_context *ctx = (duk_hthread *) thr;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(tv != NULL);\n\n\tswitch (DUK_TVAL_GET_TAG(tv)) {\n\tcase DUK_TAG_UNDEFINED: {\n\t\t/* return a specific NaN (although not strictly necessary) */\n\t\tduk_double_union du;\n\t\tDUK_DBLUNION_SET_NAN(&du);\n\t\tDUK_ASSERT(DUK_DBLUNION_IS_NORMALIZED(&du));\n\t\treturn du.d;\n\t}\n\tcase DUK_TAG_NULL: {\n\t\t/* +0.0 */\n\t\treturn 0.0;\n\t}\n\tcase DUK_TAG_BOOLEAN: {\n\t\tif (DUK_TVAL_IS_BOOLEAN_TRUE(tv)) {\n\t\t\treturn 1.0;\n\t\t}\n\t\treturn 0.0;\n\t}\n\tcase DUK_TAG_STRING: {\n\t\t/* For Symbols ToNumber() is always a TypeError. */\n\t\tduk_hstring *h = DUK_TVAL_GET_STRING(tv);\n\t\tif (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(h))) {\n\t\t\tDUK_ERROR_TYPE(thr, DUK_STR_CANNOT_NUMBER_COERCE_SYMBOL);\n\t\t}\n\t\tduk_push_hstring(ctx, h);\n\t\treturn duk__tonumber_string_raw(thr);\n\t}\n\tcase DUK_TAG_BUFFER:  /* plain buffer treated like object */\n\tcase DUK_TAG_OBJECT: {\n\t\tduk_double_t d;\n\t\tduk_push_tval(ctx, tv);\n\t\tduk_to_primitive(ctx, -1, DUK_HINT_NUMBER);  /* 'tv' becomes invalid */\n\n\t\t/* recursive call for a primitive value (guaranteed not to cause second\n\t\t * recursion).\n\t\t */\n\t\tDUK_ASSERT(duk_get_tval(ctx, -1) != NULL);\n\t\td = duk_js_tonumber(thr, duk_get_tval(ctx, -1));\n\n\t\tduk_pop(ctx);\n\t\treturn d;\n\t}\n\tcase DUK_TAG_POINTER: {\n\t\t/* Coerce like boolean */\n\t\tvoid *p = DUK_TVAL_GET_POINTER(tv);\n\t\treturn (p != NULL ? 1.0 : 0.0);\n\t}\n\tcase DUK_TAG_LIGHTFUNC: {\n\t\t/* +(function(){}) -> NaN */\n\t\treturn DUK_DOUBLE_NAN;\n\t}\n#if defined(DUK_USE_FASTINT)\n\tcase DUK_TAG_FASTINT:\n\t\treturn (duk_double_t) DUK_TVAL_GET_FASTINT(tv);\n#endif\n\tdefault: {\n\t\t/* number */\n\t\tDUK_ASSERT(!DUK_TVAL_IS_UNUSED(tv));\n\t\tDUK_ASSERT(DUK_TVAL_IS_DOUBLE(tv));\n\t\treturn DUK_TVAL_GET_DOUBLE(tv);\n\t}\n\t}\n\n\tDUK_UNREACHABLE();\n}\n\n/*\n *  ToInteger()  (E5 Section 9.4)\n */\n\n/* exposed, used by e.g. duk_bi_date.c */\nDUK_INTERNAL duk_double_t duk_js_tointeger_number(duk_double_t x) {\n#if defined(DUK_USE_PREFER_SIZE)\n\tduk_small_int_t c = (duk_small_int_t) DUK_FPCLASSIFY(x);\n\n\tif (DUK_UNLIKELY(c == DUK_FP_NAN)) {\n\t\treturn 0.0;\n\t} else if (DUK_UNLIKELY(c == DUK_FP_INFINITE)) {\n\t\treturn x;\n\t} else {\n\t\t/* Finite, including neg/pos zero.  Neg zero sign must be\n\t\t * preserved.\n\t\t */\n\t\treturn duk_double_trunc_towards_zero(x);\n\t}\n#else  /* DUK_USE_PREFER_SIZE */\n\t/* NaN and Infinity have the same exponent so it's a cheap\n\t * initial check for the rare path.\n\t */\n\tif (DUK_UNLIKELY(duk_double_is_nan_or_inf(x))) {\n\t\tif (duk_double_is_nan(x)) {\n\t\t\treturn 0.0;\n\t\t} else {\n\t\t\treturn x;\n\t\t}\n\t} else {\n\t\treturn duk_double_trunc_towards_zero(x);\n\t}\n#endif  /* DUK_USE_PREFER_SIZE */\n}\n\nDUK_INTERNAL duk_double_t duk_js_tointeger(duk_hthread *thr, duk_tval *tv) {\n\t/* XXX: fastint */\n\tduk_double_t d = duk_js_tonumber(thr, tv);  /* invalidates tv */\n\treturn duk_js_tointeger_number(d);\n}\n\n/*\n *  ToInt32(), ToUint32(), ToUint16()  (E5 Sections 9.5, 9.6, 9.7)\n */\n\n/* combined algorithm matching E5 Sections 9.5 and 9.6 */\nDUK_LOCAL duk_double_t duk__toint32_touint32_helper(duk_double_t x, duk_bool_t is_toint32) {\n#if defined (DUK_USE_PREFER_SIZE)\n\tduk_small_int_t c;\n#endif\n\n#if defined (DUK_USE_PREFER_SIZE)\n\tc = (duk_small_int_t) DUK_FPCLASSIFY(x);\n\tif (c == DUK_FP_NAN || c == DUK_FP_ZERO || c == DUK_FP_INFINITE) {\n\t\treturn 0.0;\n\t}\n#else\n\tif (duk_double_is_nan_zero_inf(x)) {\n\t\treturn 0.0;\n\t}\n#endif\n\n\t/* x = sign(x) * floor(abs(x)), i.e. truncate towards zero, keep sign */\n\tx = duk_double_trunc_towards_zero(x);\n\n\t/* NOTE: fmod(x) result sign is same as sign of x, which\n\t * differs from what Javascript wants (see Section 9.6).\n\t */\n\n\tx = DUK_FMOD(x, DUK_DOUBLE_2TO32);    /* -> x in ]-2**32, 2**32[ */\n\n\tif (x < 0.0) {\n\t\tx += DUK_DOUBLE_2TO32;\n\t}\n\tDUK_ASSERT(x >= 0 && x < DUK_DOUBLE_2TO32);  /* -> x in [0, 2**32[ */\n\n\tif (is_toint32) {\n\t\tif (x >= DUK_DOUBLE_2TO31) {\n\t\t\t/* x in [2**31, 2**32[ */\n\n\t\t\tx -= DUK_DOUBLE_2TO32;  /* -> x in [-2**31,2**31[ */\n\t\t}\n\t}\n\n\treturn x;\n}\n\nDUK_INTERNAL duk_int32_t duk_js_toint32(duk_hthread *thr, duk_tval *tv) {\n\tduk_double_t d;\n\n#if defined(DUK_USE_FASTINT)\n\tif (DUK_TVAL_IS_FASTINT(tv)) {\n\t\treturn DUK_TVAL_GET_FASTINT_I32(tv);\n\t}\n#endif\n\n\td = duk_js_tonumber(thr, tv);  /* invalidates tv */\n\td = duk__toint32_touint32_helper(d, 1);\n\tDUK_ASSERT(DUK_FPCLASSIFY(d) == DUK_FP_ZERO || DUK_FPCLASSIFY(d) == DUK_FP_NORMAL);\n\tDUK_ASSERT(d >= -2147483648.0 && d <= 2147483647.0);  /* [-0x80000000,0x7fffffff] */\n\tDUK_ASSERT(d == ((duk_double_t) ((duk_int32_t) d)));  /* whole, won't clip */\n\treturn (duk_int32_t) d;\n}\n\n\nDUK_INTERNAL duk_uint32_t duk_js_touint32(duk_hthread *thr, duk_tval *tv) {\n\tduk_double_t d;\n\n#if defined(DUK_USE_FASTINT)\n\tif (DUK_TVAL_IS_FASTINT(tv)) {\n\t\treturn DUK_TVAL_GET_FASTINT_U32(tv);\n\t}\n#endif\n\n\td = duk_js_tonumber(thr, tv);  /* invalidates tv */\n\td = duk__toint32_touint32_helper(d, 0);\n\tDUK_ASSERT(DUK_FPCLASSIFY(d) == DUK_FP_ZERO || DUK_FPCLASSIFY(d) == DUK_FP_NORMAL);\n\tDUK_ASSERT(d >= 0.0 && d <= 4294967295.0);  /* [0x00000000, 0xffffffff] */\n\tDUK_ASSERT(d == ((duk_double_t) ((duk_uint32_t) d)));  /* whole, won't clip */\n\treturn (duk_uint32_t) d;\n\n}\n\nDUK_INTERNAL duk_uint16_t duk_js_touint16(duk_hthread *thr, duk_tval *tv) {\n\t/* should be a safe way to compute this */\n\treturn (duk_uint16_t) (duk_js_touint32(thr, tv) & 0x0000ffffU);\n}\n\n/*\n *  ToString()  (E5 Section 9.8)\n *  ToObject()  (E5 Section 9.9)\n *  CheckObjectCoercible()  (E5 Section 9.10)\n *  IsCallable()  (E5 Section 9.11)\n *\n *  ==> implemented in the API.\n */\n\n/*\n *  Loose equality, strict equality, and SameValue (E5 Sections 11.9.1, 11.9.4,\n *  9.12).  These have much in common so they can share some helpers.\n *\n *  Future work notes:\n *\n *    - Current implementation (and spec definition) has recursion; this should\n *      be fixed if possible.\n *\n *    - String-to-number coercion should be possible without going through the\n *      value stack (and be more compact) if a shared helper is invoked.\n */\n\n/* Note that this is the same operation for strict and loose equality:\n *  - E5 Section 11.9.3, step 1.c (loose)\n *  - E5 Section 11.9.6, step 4 (strict)\n */\n\nDUK_LOCAL duk_bool_t duk__js_equals_number(duk_double_t x, duk_double_t y) {\n#if defined(DUK_USE_PARANOID_MATH)\n\t/* Straightforward algorithm, makes fewer compiler assumptions. */\n\tduk_small_int_t cx = (duk_small_int_t) DUK_FPCLASSIFY(x);\n\tduk_small_int_t cy = (duk_small_int_t) DUK_FPCLASSIFY(y);\n\tif (cx == DUK_FP_NAN || cy == DUK_FP_NAN) {\n\t\treturn 0;\n\t}\n\tif (cx == DUK_FP_ZERO && cy == DUK_FP_ZERO) {\n\t\treturn 1;\n\t}\n\tif (x == y) {\n\t\treturn 1;\n\t}\n\treturn 0;\n#else  /* DUK_USE_PARANOID_MATH */\n\t/* Better equivalent algorithm.  If the compiler is compliant, C and\n\t * Ecmascript semantics are identical for this particular comparison.\n\t * In particular, NaNs must never compare equal and zeroes must compare\n\t * equal regardless of sign.  Could also use a macro, but this inlines\n\t * already nicely (no difference on gcc, for instance).\n\t */\n\tif (x == y) {\n\t\t/* IEEE requires that NaNs compare false */\n\t\tDUK_ASSERT(DUK_FPCLASSIFY(x) != DUK_FP_NAN);\n\t\tDUK_ASSERT(DUK_FPCLASSIFY(y) != DUK_FP_NAN);\n\t\treturn 1;\n\t} else {\n\t\t/* IEEE requires that zeros compare the same regardless\n\t\t * of their signed, so if both x and y are zeroes, they\n\t\t * are caught above.\n\t\t */\n\t\tDUK_ASSERT(!(DUK_FPCLASSIFY(x) == DUK_FP_ZERO && DUK_FPCLASSIFY(y) == DUK_FP_ZERO));\n\t\treturn 0;\n\t}\n#endif  /* DUK_USE_PARANOID_MATH */\n}\n\nDUK_LOCAL duk_bool_t duk__js_samevalue_number(duk_double_t x, duk_double_t y) {\n#if defined(DUK_USE_PARANOID_MATH)\n\tduk_small_int_t cx = (duk_small_int_t) DUK_FPCLASSIFY(x);\n\tduk_small_int_t cy = (duk_small_int_t) DUK_FPCLASSIFY(y);\n\n\tif (cx == DUK_FP_NAN && cy == DUK_FP_NAN) {\n\t\t/* SameValue(NaN, NaN) = true, regardless of NaN sign or extra bits */\n\t\treturn 1;\n\t}\n\tif (cx == DUK_FP_ZERO && cy == DUK_FP_ZERO) {\n\t\t/* Note: cannot assume that a non-zero return value of signbit() would\n\t\t * always be the same -- hence cannot (portably) use something like:\n\t\t *\n\t\t *     signbit(x) == signbit(y)\n\t\t */\n\t\tduk_small_int_t sx = DUK_SIGNBIT(x) ? 1 : 0;\n\t\tduk_small_int_t sy = DUK_SIGNBIT(y) ? 1 : 0;\n\t\treturn (sx == sy);\n\t}\n\n\t/* normal comparison; known:\n\t *   - both x and y are not NaNs (but one of them can be)\n\t *   - both x and y are not zero (but one of them can be)\n\t *   - x and y may be denormal or infinite\n\t */\n\n\treturn (x == y);\n#else  /* DUK_USE_PARANOID_MATH */\n\tduk_small_int_t cx = (duk_small_int_t) DUK_FPCLASSIFY(x);\n\tduk_small_int_t cy = (duk_small_int_t) DUK_FPCLASSIFY(y);\n\n\tif (x == y) {\n\t\t/* IEEE requires that NaNs compare false */\n\t\tDUK_ASSERT(DUK_FPCLASSIFY(x) != DUK_FP_NAN);\n\t\tDUK_ASSERT(DUK_FPCLASSIFY(y) != DUK_FP_NAN);\n\n\t\t/* Using classification has smaller footprint than direct comparison. */\n\t\tif (DUK_UNLIKELY(cx == DUK_FP_ZERO && cy == DUK_FP_ZERO)) {\n\t\t\t/* Note: cannot assume that a non-zero return value of signbit() would\n\t\t\t * always be the same -- hence cannot (portably) use something like:\n\t\t\t *\n\t\t\t *     signbit(x) == signbit(y)\n\t\t\t */\n\t\t\treturn duk_double_same_sign(x, y);\n\t\t}\n\t\treturn 1;\n\t} else {\n\t\t/* IEEE requires that zeros compare the same regardless\n\t\t * of their sign, so if both x and y are zeroes, they\n\t\t * are caught above.\n\t\t */\n\t\tDUK_ASSERT(!(DUK_FPCLASSIFY(x) == DUK_FP_ZERO && DUK_FPCLASSIFY(y) == DUK_FP_ZERO));\n\n\t\t/* Difference to non-strict/strict comparison is that NaNs compare\n\t\t * equal and signed zero signs matter.\n\t\t */\n\t\tif (DUK_UNLIKELY(cx == DUK_FP_NAN && cy == DUK_FP_NAN)) {\n\t\t\t/* SameValue(NaN, NaN) = true, regardless of NaN sign or extra bits */\n\t\t\treturn 1;\n\t\t}\n\t\treturn 0;\n\t}\n#endif  /* DUK_USE_PARANOID_MATH */\n}\n\nDUK_INTERNAL duk_bool_t duk_js_equals_helper(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_small_int_t flags) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_uint_t type_mask_x;\n\tduk_uint_t type_mask_y;\n\n\t/* If flags != 0 (strict or SameValue), thr can be NULL.  For loose\n\t * equals comparison it must be != NULL.\n\t */\n\tDUK_ASSERT(flags != 0 || thr != NULL);\n\n\t/*\n\t *  Same type?\n\t *\n\t *  Note: since number values have no explicit tag in the 8-byte\n\t *  representation, need the awkward if + switch.\n\t */\n\n#if defined(DUK_USE_FASTINT)\n\tif (DUK_TVAL_IS_FASTINT(tv_x) && DUK_TVAL_IS_FASTINT(tv_y)) {\n\t\tif (DUK_TVAL_GET_FASTINT(tv_x) == DUK_TVAL_GET_FASTINT(tv_y)) {\n\t\t\treturn 1;\n\t\t} else {\n\t\t\treturn 0;\n\t\t}\n\t}\n\telse\n#endif\n\tif (DUK_TVAL_IS_NUMBER(tv_x) && DUK_TVAL_IS_NUMBER(tv_y)) {\n\t\tduk_double_t d1, d2;\n\n\t\t/* Catches both doubles and cases where only one argument is\n\t\t * a fastint so can't assume a double.\n\t\t */\n\t\td1 = DUK_TVAL_GET_NUMBER(tv_x);\n\t\td2 = DUK_TVAL_GET_NUMBER(tv_y);\n\t\tif (DUK_UNLIKELY((flags & DUK_EQUALS_FLAG_SAMEVALUE) != 0)) {\n\t\t\t/* SameValue */\n\t\t\treturn duk__js_samevalue_number(d1, d2);\n\t\t} else {\n\t\t\t/* equals and strict equals */\n\t\t\treturn duk__js_equals_number(d1, d2);\n\t\t}\n\t} else if (DUK_TVAL_GET_TAG(tv_x) == DUK_TVAL_GET_TAG(tv_y)) {\n\t\tswitch (DUK_TVAL_GET_TAG(tv_x)) {\n\t\tcase DUK_TAG_UNDEFINED:\n\t\tcase DUK_TAG_NULL: {\n\t\t\treturn 1;\n\t\t}\n\t\tcase DUK_TAG_BOOLEAN: {\n\t\t\treturn DUK_TVAL_GET_BOOLEAN(tv_x) == DUK_TVAL_GET_BOOLEAN(tv_y);\n\t\t}\n\t\tcase DUK_TAG_POINTER: {\n\t\t\treturn DUK_TVAL_GET_POINTER(tv_x) == DUK_TVAL_GET_POINTER(tv_y);\n\t\t}\n\t\tcase DUK_TAG_STRING:\n\t\tcase DUK_TAG_OBJECT: {\n\t\t\t/* Heap pointer comparison suffices for strings and objects.\n\t\t\t * Symbols compare equal if they have the same internal\n\t\t\t * representation; again heap pointer comparison suffices.\n\t\t\t */\n\t\t\treturn DUK_TVAL_GET_HEAPHDR(tv_x) == DUK_TVAL_GET_HEAPHDR(tv_y);\n\t\t}\n\t\tcase DUK_TAG_BUFFER: {\n\t\t\t/* In Duktape 2.x plain buffers mimic Uint8Array objects\n\t\t\t * so always compare by heap pointer.  In Duktape 1.x\n\t\t\t * strict comparison would compare heap pointers and\n\t\t\t * non-strict would compare contents.\n\t\t\t */\n\t\t\treturn DUK_TVAL_GET_HEAPHDR(tv_x) == DUK_TVAL_GET_HEAPHDR(tv_y);\n\t\t}\n\t\tcase DUK_TAG_LIGHTFUNC: {\n\t\t\t/* At least 'magic' has a significant impact on function\n\t\t\t * identity.\n\t\t\t */\n\t\t\tduk_small_uint_t lf_flags_x;\n\t\t\tduk_small_uint_t lf_flags_y;\n\t\t\tduk_c_function func_x;\n\t\t\tduk_c_function func_y;\n\n\t\t\tDUK_TVAL_GET_LIGHTFUNC(tv_x, func_x, lf_flags_x);\n\t\t\tDUK_TVAL_GET_LIGHTFUNC(tv_y, func_y, lf_flags_y);\n\t\t\treturn ((func_x == func_y) && (lf_flags_x == lf_flags_y)) ? 1 : 0;\n\t\t}\n#if defined(DUK_USE_FASTINT)\n\t\tcase DUK_TAG_FASTINT:\n#endif\n\t\tdefault: {\n\t\t\tDUK_ASSERT(!DUK_TVAL_IS_UNUSED(tv_x));\n\t\t\tDUK_ASSERT(!DUK_TVAL_IS_UNUSED(tv_y));\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv_x));\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv_y));\n\t\t\tDUK_UNREACHABLE();\n\t\t\treturn 0;\n\t\t}\n\t\t}\n\t}\n\n\tif ((flags & (DUK_EQUALS_FLAG_STRICT | DUK_EQUALS_FLAG_SAMEVALUE)) != 0) {\n\t\treturn 0;\n\t}\n\n\tDUK_ASSERT(flags == 0);  /* non-strict equality from here on */\n\n\t/*\n\t *  Types are different; various cases for non-strict comparison\n\t *\n\t *  Since comparison is symmetric, we use a \"swap trick\" to reduce\n\t *  code size.\n\t */\n\n\ttype_mask_x = duk_get_type_mask_tval(tv_x);\n\ttype_mask_y = duk_get_type_mask_tval(tv_y);\n\n\t/* Undefined/null are considered equal (e.g. \"null == undefined\" -> true). */\n\tif ((type_mask_x & (DUK_TYPE_MASK_UNDEFINED | DUK_TYPE_MASK_NULL)) &&\n\t    (type_mask_y & (DUK_TYPE_MASK_NULL | DUK_TYPE_MASK_UNDEFINED))) {\n\t\treturn 1;\n\t}\n\n\t/* Number/string -> coerce string to number (e.g. \"'1.5' == 1.5\" -> true). */\n\tif ((type_mask_x & DUK_TYPE_MASK_NUMBER) && (type_mask_y & DUK_TYPE_MASK_STRING)) {\n\t\tif (!DUK_TVAL_STRING_IS_SYMBOL(tv_y)) {\n\t\t\tduk_double_t d1, d2;\n\t\t\td1 = DUK_TVAL_GET_NUMBER(tv_x);\n\t\t\td2 = duk_to_number_tval(ctx, tv_y);\n\t\t\treturn duk__js_equals_number(d1, d2);\n\t\t}\n\t}\n\tif ((type_mask_x & DUK_TYPE_MASK_STRING) && (type_mask_y & DUK_TYPE_MASK_NUMBER)) {\n\t\tif (!DUK_TVAL_STRING_IS_SYMBOL(tv_x)) {\n\t\t\tduk_double_t d1, d2;\n\t\t\td1 = DUK_TVAL_GET_NUMBER(tv_y);\n\t\t\td2 = duk_to_number_tval(ctx, tv_x);\n\t\t\treturn duk__js_equals_number(d1, d2);\n\t\t}\n\t}\n\n\t/* Boolean/any -> coerce boolean to number and try again.  If boolean is\n\t * compared to a pointer, the final comparison after coercion now always\n\t * yields false (as pointer vs. number compares to false), but this is\n\t * not special cased.\n\t *\n\t * ToNumber(bool) is +1.0 or 0.0.  Tagged boolean value is always 0 or 1.\n\t */\n\tif (type_mask_x & DUK_TYPE_MASK_BOOLEAN) {\n\t\tDUK_ASSERT(DUK_TVAL_GET_BOOLEAN(tv_x) == 0 || DUK_TVAL_GET_BOOLEAN(tv_x) == 1);\n\t\tduk_push_int(ctx, DUK_TVAL_GET_BOOLEAN(tv_x));\n\t\tduk_push_tval(ctx, tv_y);\n\t\tgoto recursive_call;\n\t}\n\tif (type_mask_y & DUK_TYPE_MASK_BOOLEAN) {\n\t\tDUK_ASSERT(DUK_TVAL_GET_BOOLEAN(tv_y) == 0 || DUK_TVAL_GET_BOOLEAN(tv_y) == 1);\n\t\tduk_push_tval(ctx, tv_x);\n\t\tduk_push_int(ctx, DUK_TVAL_GET_BOOLEAN(tv_y));\n\t\tgoto recursive_call;\n\t}\n\n\t/* String-number-symbol/object -> coerce object to primitive (apparently without hint), then try again. */\n\tif ((type_mask_x & (DUK_TYPE_MASK_STRING | DUK_TYPE_MASK_NUMBER)) &&\n\t    (type_mask_y & DUK_TYPE_MASK_OBJECT)) {\n\t\t/* No symbol check needed because symbols and strings are accepted. */\n\t\tduk_push_tval(ctx, tv_x);\n\t\tduk_push_tval(ctx, tv_y);\n\t\tduk_to_primitive(ctx, -1, DUK_HINT_NONE);  /* apparently no hint? */\n\t\tgoto recursive_call;\n\t}\n\tif ((type_mask_x & DUK_TYPE_MASK_OBJECT) &&\n\t    (type_mask_y & (DUK_TYPE_MASK_STRING | DUK_TYPE_MASK_NUMBER))) {\n\t\t/* No symbol check needed because symbols and strings are accepted. */\n\t\tduk_push_tval(ctx, tv_x);\n\t\tduk_push_tval(ctx, tv_y);\n\t\tduk_to_primitive(ctx, -2, DUK_HINT_NONE);  /* apparently no hint? */\n\t\tgoto recursive_call;\n\t}\n\n\t/* Nothing worked -> not equal. */\n\treturn 0;\n\n recursive_call:\n\t/* Shared code path to call the helper again with arguments on stack top. */\n\t{\n\t\tduk_bool_t rc;\n\t\trc = duk_js_equals_helper(thr,\n\t\t                          DUK_GET_TVAL_NEGIDX(ctx, -2),\n\t\t                          DUK_GET_TVAL_NEGIDX(ctx, -1),\n\t\t                          0 /*flags:nonstrict*/);\n\t\tduk_pop_2(ctx);\n\t\treturn rc;\n\t}\n}\n\n/*\n *  Comparisons (x >= y, x > y, x <= y, x < y)\n *\n *  E5 Section 11.8.5: implement 'x < y' and then use negate and eval_left_first\n *  flags to get the rest.\n */\n\n/* XXX: this should probably just operate on the stack top, because it\n * needs to push stuff on the stack anyway...\n */\n\nDUK_INTERNAL duk_small_int_t duk_js_data_compare(const duk_uint8_t *buf1, const duk_uint8_t *buf2, duk_size_t len1, duk_size_t len2) {\n\tduk_size_t prefix_len;\n\tduk_small_int_t rc;\n\n\tprefix_len = (len1 <= len2 ? len1 : len2);\n\n\t/* DUK_MEMCMP() is guaranteed to return zero (equal) for zero length\n\t * inputs so no zero length check is needed.\n\t */\n\trc = DUK_MEMCMP((const void *) buf1,\n\t                (const void *) buf2,\n\t                (size_t) prefix_len);\n\n\tif (rc < 0) {\n\t\treturn -1;\n\t} else if (rc > 0) {\n\t\treturn 1;\n\t}\n\n\t/* prefix matches, lengths matter now */\n\tif (len1 < len2) {\n\t\t/* e.g. \"x\" < \"xx\" */\n\t\treturn -1;\n\t} else if (len1 > len2) {\n\t\treturn 1;\n\t}\n\n\treturn 0;\n}\n\nDUK_INTERNAL duk_small_int_t duk_js_string_compare(duk_hstring *h1, duk_hstring *h2) {\n\t/*\n\t *  String comparison (E5 Section 11.8.5, step 4), which\n\t *  needs to compare codepoint by codepoint.\n\t *\n\t *  However, UTF-8 allows us to use strcmp directly: the shared\n\t *  prefix will be encoded identically (UTF-8 has unique encoding)\n\t *  and the first differing character can be compared with a simple\n\t *  unsigned byte comparison (which strcmp does).\n\t *\n\t *  This will not work properly for non-xutf-8 strings, but this\n\t *  is not an issue for compliance.\n\t */\n\n\tDUK_ASSERT(h1 != NULL);\n\tDUK_ASSERT(h2 != NULL);\n\n\treturn duk_js_data_compare((const duk_uint8_t *) DUK_HSTRING_GET_DATA(h1),\n\t                           (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h2),\n\t                           (duk_size_t) DUK_HSTRING_GET_BYTELEN(h1),\n\t                           (duk_size_t) DUK_HSTRING_GET_BYTELEN(h2));\n}\n\n#if 0  /* unused */\nDUK_INTERNAL duk_small_int_t duk_js_buffer_compare(duk_heap *heap, duk_hbuffer *h1, duk_hbuffer *h2) {\n\t/* Similar to String comparison. */\n\n\tDUK_ASSERT(h1 != NULL);\n\tDUK_ASSERT(h2 != NULL);\n\tDUK_UNREF(heap);\n\n\treturn duk_js_data_compare((const duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(heap, h1),\n\t                           (const duk_uint8_t *) DUK_HBUFFER_GET_DATA_PTR(heap, h2),\n\t                           (duk_size_t) DUK_HBUFFER_GET_SIZE(h1),\n\t                           (duk_size_t) DUK_HBUFFER_GET_SIZE(h2));\n}\n#endif\n\n#if defined(DUK_USE_FASTINT)\nDUK_LOCAL duk_bool_t duk__compare_fastint(duk_bool_t retval, duk_int64_t v1, duk_int64_t v2) {\n\tDUK_ASSERT(retval == 0 || retval == 1);\n\tif (v1 < v2) {\n\t\treturn retval ^ 1;\n\t} else {\n\t\treturn retval;\n\t}\n}\n#endif\n\n#if defined(DUK_USE_PARANOID_MATH)\nDUK_LOCAL duk_bool_t duk__compare_number(duk_bool_t retval, duk_double_t d1, duk_double_t d2) {\n\tduk_small_int_t c1, s1, c2, s2;\n\n\tDUK_ASSERT(retval == 0 || retval == 1);\n\tc1 = (duk_small_int_t) DUK_FPCLASSIFY(d1);\n\ts1 = (duk_small_int_t) DUK_SIGNBIT(d1);\n\tc2 = (duk_small_int_t) DUK_FPCLASSIFY(d2);\n\ts2 = (duk_small_int_t) DUK_SIGNBIT(d2);\n\n\tif (c1 == DUK_FP_NAN || c2 == DUK_FP_NAN) {\n\t\treturn 0;  /* Always false, regardless of negation. */\n\t}\n\n\tif (c1 == DUK_FP_ZERO && c2 == DUK_FP_ZERO) {\n\t\t/* For all combinations: +0 < +0, +0 < -0, -0 < +0, -0 < -0,\n\t\t * steps e, f, and g.\n\t\t */\n\t\treturn retval;  /* false */\n\t}\n\n\tif (d1 == d2) {\n\t\treturn retval;  /* false */\n\t}\n\n\tif (c1 == DUK_FP_INFINITE && s1 == 0) {\n\t\t/* x == +Infinity */\n\t\treturn retval;  /* false */\n\t}\n\n\tif (c2 == DUK_FP_INFINITE && s2 == 0) {\n\t\t/* y == +Infinity */\n\t\treturn retval ^ 1;  /* true */\n\t}\n\n\tif (c2 == DUK_FP_INFINITE && s2 != 0) {\n\t\t/* y == -Infinity */\n\t\treturn retval;  /* false */\n\t}\n\n\tif (c1 == DUK_FP_INFINITE && s1 != 0) {\n\t\t/* x == -Infinity */\n\t\treturn retval ^ 1;  /* true */\n\t}\n\n\tif (d1 < d2) {\n\t\treturn retval ^ 1;  /* true */\n\t}\n\n\treturn retval;  /* false */\n}\n#else  /* DUK_USE_PARANOID_MATH */\nDUK_LOCAL duk_bool_t duk__compare_number(duk_bool_t retval, duk_double_t d1, duk_double_t d2) {\n\t/* This comparison tree relies doesn't match the exact steps in\n\t * E5 Section 11.8.5 but should produce the same results.  The\n\t * steps rely on exact IEEE semantics for NaNs, etc.\n\t */\n\n\tDUK_ASSERT(retval == 0 || retval == 1);\n\tif (d1 < d2) {\n\t\t/* In no case should both (d1 < d2) and (d2 < d1) be true.\n\t\t * It's possible that neither is true though, and that's\n\t\t * handled below.\n\t\t */\n\t\tDUK_ASSERT(!(d2 < d1));\n\n\t\t/* - d1 < d2, both d1/d2 are normals (not Infinity, not NaN)\n\t\t * - d2 is +Infinity, d1 != +Infinity and NaN\n\t\t * - d1 is -Infinity, d2 != -Infinity and NaN\n\t\t */\n\t\treturn retval ^ 1;\n\t} else {\n\t\tif (d2 < d1) {\n\t\t\t/* - !(d1 < d2), both d1/d2 are normals (not Infinity, not NaN)\n\t\t\t * - d1 is +Infinity, d2 != +Infinity and NaN\n\t\t\t * - d2 is -Infinity, d1 != -Infinity and NaN\n\t\t\t */\n\t\t\treturn retval;\n\t\t} else {\n\t\t\t/* - d1 and/or d2 is NaN\n\t\t\t * - d1 and d2 are both +/- 0\n\t\t\t * - d1 == d2 (including infinities)\n\t\t\t */\n\t\t\tif (duk_double_is_nan(d1) || duk_double_is_nan(d2)) {\n\t\t\t\t/* Note: undefined from Section 11.8.5 always\n\t\t\t\t * results in false return (see e.g. Section\n\t\t\t\t * 11.8.3) - hence special treatment here.\n\t\t\t\t */\n\t\t\t\treturn 0;  /* zero regardless of negation */\n\t\t\t} else {\n\t\t\t\treturn retval;\n\t\t\t}\n\t\t}\n\t}\n}\n#endif  /* DUK_USE_PARANOID_MATH */\n\nDUK_INTERNAL duk_bool_t duk_js_compare_helper(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y, duk_small_int_t flags) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_double_t d1, d2;\n\tduk_small_int_t rc;\n\tduk_bool_t retval;\n\n\tDUK_ASSERT(DUK_COMPARE_FLAG_NEGATE == 1);  /* Rely on this flag being lowest. */\n\tretval = flags & DUK_COMPARE_FLAG_NEGATE;\n\tDUK_ASSERT(retval == 0 || retval == 1);\n\n\t/* Fast path for fastints */\n#if defined(DUK_USE_FASTINT)\n\tif (DUK_LIKELY(DUK_TVAL_IS_FASTINT(tv_x) && DUK_TVAL_IS_FASTINT(tv_y))) {\n\t\treturn duk__compare_fastint(retval,\n\t\t                            DUK_TVAL_GET_FASTINT(tv_x),\n\t\t                            DUK_TVAL_GET_FASTINT(tv_y));\n\t}\n#endif  /* DUK_USE_FASTINT */\n\n\t/* Fast path for numbers (one of which may be a fastint) */\n#if !defined(DUK_USE_PREFER_SIZE)\n\tif (DUK_LIKELY(DUK_TVAL_IS_NUMBER(tv_x) && DUK_TVAL_IS_NUMBER(tv_y))) {\n\t\treturn duk__compare_number(retval,\n\t\t                           DUK_TVAL_GET_NUMBER(tv_x),\n\t\t                           DUK_TVAL_GET_NUMBER(tv_y));\n\t}\n#endif\n\n\t/* Slow path */\n\n\tduk_push_tval(ctx, tv_x);\n\tduk_push_tval(ctx, tv_y);\n\n\tif (flags & DUK_COMPARE_FLAG_EVAL_LEFT_FIRST) {\n\t\tduk_to_primitive(ctx, -2, DUK_HINT_NUMBER);\n\t\tduk_to_primitive(ctx, -1, DUK_HINT_NUMBER);\n\t} else {\n\t\tduk_to_primitive(ctx, -1, DUK_HINT_NUMBER);\n\t\tduk_to_primitive(ctx, -2, DUK_HINT_NUMBER);\n\t}\n\n\t/* Note: reuse variables */\n\ttv_x = DUK_GET_TVAL_NEGIDX(ctx, -2);\n\ttv_y = DUK_GET_TVAL_NEGIDX(ctx, -1);\n\n\tif (DUK_TVAL_IS_STRING(tv_x) && DUK_TVAL_IS_STRING(tv_y)) {\n\t\tduk_hstring *h1 = DUK_TVAL_GET_STRING(tv_x);\n\t\tduk_hstring *h2 = DUK_TVAL_GET_STRING(tv_y);\n\t\tDUK_ASSERT(h1 != NULL);\n\t\tDUK_ASSERT(h2 != NULL);\n\n\t\tif (DUK_LIKELY(!DUK_HSTRING_HAS_SYMBOL(h1) && !DUK_HSTRING_HAS_SYMBOL(h2))) {\n\t\t\trc = duk_js_string_compare(h1, h2);\n\t\t\tduk_pop_2(ctx);\n\t\t\tif (rc < 0) {\n\t\t\t\treturn retval ^ 1;\n\t\t\t} else {\n\t\t\t\treturn retval;\n\t\t\t}\n\t\t}\n\n\t\t/* One or both are Symbols: fall through to handle in the\n\t\t * generic path.  Concretely, ToNumber() will fail.\n\t\t */\n\t}\n\n\t/* Ordering should not matter (E5 Section 11.8.5, step 3.a). */\n#if 0\n\tif (flags & DUK_COMPARE_FLAG_EVAL_LEFT_FIRST) {\n\t\td1 = duk_to_number_m2(ctx);\n\t\td2 = duk_to_number_m1(ctx);\n\t} else {\n\t\td2 = duk_to_number_m1(ctx);\n\t\td1 = duk_to_number_m2(ctx);\n\t}\n#endif\n\td1 = duk_to_number_m2(ctx);\n\td2 = duk_to_number_m1(ctx);\n\n\t/* We want to duk_pop_2(ctx); because the values are numbers\n\t * no decref check is needed.\n\t */\n#if defined(DUK_USE_PREFER_SIZE)\n\tduk_pop_2(ctx);\n#else\n\tDUK_ASSERT(!DUK_TVAL_NEEDS_REFCOUNT_UPDATE(duk_get_tval(ctx, -2)));\n\tDUK_ASSERT(!DUK_TVAL_NEEDS_REFCOUNT_UPDATE(duk_get_tval(ctx, -1)));\n\tDUK_ASSERT(duk_get_top(ctx) >= 2);\n\t((duk_hthread *) ctx)->valstack_top -= 2;\n\ttv_x = ((duk_hthread *) ctx)->valstack_top;\n\ttv_y = tv_x + 1;\n\tDUK_TVAL_SET_UNDEFINED(tv_x);  /* Value stack policy */\n\tDUK_TVAL_SET_UNDEFINED(tv_y);\n#endif\n\n\treturn duk__compare_number(retval, d1, d2);\n}\n\n/*\n *  instanceof\n */\n\n/*\n *  E5 Section 11.8.6 describes the main algorithm, which uses\n *  [[HasInstance]].  [[HasInstance]] is defined for only\n *  function objects:\n *\n *    - Normal functions:\n *      E5 Section 15.3.5.3\n *    - Functions established with Function.prototype.bind():\n *      E5 Section 15.3.4.5.3\n *\n *  For other objects, a TypeError is thrown.\n *\n *  Limited Proxy support: don't support 'getPrototypeOf' trap but\n *  continue lookup in Proxy target if the value is a Proxy.\n */\n\nDUK_INTERNAL duk_bool_t duk_js_instanceof(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hobject *func;\n\tduk_hobject *val;\n\tduk_hobject *proto;\n\tduk_tval *tv;\n\tduk_uint_t sanity;\n\tduk_bool_t skip_first;\n\n\t/*\n\t *  Get the values onto the stack first.  It would be possible to cover\n\t *  some normal cases without resorting to the value stack.\n\t *\n\t *  The right hand side could be a light function (as they generally\n\t *  behave like objects).  Light functions never have a 'prototype'\n\t *  property so E5.1 Section 15.3.5.3 step 3 always throws a TypeError.\n\t *  Using duk_require_hobject() is thus correct (except for error msg).\n\t */\n\n\tduk_push_tval(ctx, tv_x);\n\tduk_push_tval(ctx, tv_y);\n\tfunc = duk_require_hobject(ctx, -1);\n\n\t/*\n\t *  For bound objects, [[HasInstance]] just calls the target function\n\t *  [[HasInstance]].  If that is again a bound object, repeat until\n\t *  we find a non-bound Function object.\n\t */\n\n\t/* XXX: this bound function resolution also happens elsewhere,\n\t * move into a shared helper.\n\t */\n\n\tsanity = DUK_HOBJECT_BOUND_CHAIN_SANITY;\n\tdo {\n\t\t/* check func supports [[HasInstance]] (this is checked for every function\n\t\t * in the bound chain, including the final one)\n\t\t */\n\n\t\tif (!DUK_HOBJECT_IS_CALLABLE(func)) {\n\t\t\t/*\n\t\t\t *  Note: of native Ecmascript objects, only Function instances\n\t\t\t *  have a [[HasInstance]] internal property.  Custom objects might\n\t\t\t *  also have it, but not in current implementation.\n\t\t\t *\n\t\t\t *  XXX: add a separate flag, DUK_HOBJECT_FLAG_ALLOW_INSTANCEOF?\n\t\t\t */\n\t\t\tDUK_ERROR_TYPE(thr, \"invalid instanceof rval\");\n\t\t}\n\n\t\tif (!DUK_HOBJECT_HAS_BOUNDFUNC(func)) {\n\t\t\tbreak;\n\t\t}\n\n\t\t/* [ ... lval rval ] */\n\n\t\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_INT_TARGET);         /* -> [ ... lval rval new_rval ] */\n\t\tduk_replace(ctx, -1);                                        /* -> [ ... lval new_rval ] */\n\t\tfunc = duk_require_hobject(ctx, -1);\n\n\t\t/* func support for [[HasInstance]] checked in the beginning of the loop */\n\t} while (--sanity > 0);\n\n\tif (DUK_UNLIKELY(sanity == 0)) {\n\t\tDUK_ERROR_RANGE(thr, DUK_STR_BOUND_CHAIN_LIMIT);\n\t}\n\n\t/*\n\t *  'func' is now a non-bound object which supports [[HasInstance]]\n\t *  (which here just means DUK_HOBJECT_FLAG_CALLABLE).  Move on\n\t *  to execute E5 Section 15.3.5.3.\n\t */\n\n\tDUK_ASSERT(!DUK_HOBJECT_HAS_BOUNDFUNC(func));\n\tDUK_ASSERT(DUK_HOBJECT_IS_CALLABLE(func));\n\n\t/* [ ... lval rval(func) ] */\n\n\t/* For lightfuncs, buffers, and pointers start the comparison directly\n\t * from the virtual prototype object.\n\t */\n\tskip_first = 0;\n\ttv = DUK_GET_TVAL_NEGIDX(ctx, -2);\n\tswitch (DUK_TVAL_GET_TAG(tv)) {\n\tcase DUK_TAG_LIGHTFUNC:\n\t\tval = thr->builtins[DUK_BIDX_FUNCTION_PROTOTYPE];\n\t\tDUK_ASSERT(val != NULL);\n\t\tbreak;\n\tcase DUK_TAG_BUFFER:\n\t\tval = thr->builtins[DUK_BIDX_UINT8ARRAY_PROTOTYPE];\n\t\tDUK_ASSERT(val != NULL);\n\t\tbreak;\n\tcase DUK_TAG_POINTER:\n\t\tval = thr->builtins[DUK_BIDX_POINTER_PROTOTYPE];\n\t\tDUK_ASSERT(val != NULL);\n\t\tbreak;\n\tcase DUK_TAG_OBJECT:\n\t\tskip_first = 1;  /* Ignore object itself on first round. */\n\t\tval = DUK_TVAL_GET_OBJECT(tv);\n\t\tDUK_ASSERT(val != NULL);\n\t\tbreak;\n\tdefault:\n\t\tgoto pop_and_false;\n\t}\n\tDUK_ASSERT(val != NULL);  /* Loop doesn't actually rely on this. */\n\n\tduk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_PROTOTYPE);  /* -> [ ... lval rval rval.prototype ] */\n\tproto = duk_require_hobject(ctx, -1);\n\tduk_pop(ctx);  /* -> [ ... lval rval ] */\n\n\tsanity = DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY;\n\tdo {\n\t\t/*\n\t\t *  Note: prototype chain is followed BEFORE first comparison.  This\n\t\t *  means that the instanceof lval is never itself compared to the\n\t\t *  rval.prototype property.  This is apparently intentional, see E5\n\t\t *  Section 15.3.5.3, step 4.a.\n\t\t *\n\t\t *  Also note:\n\t\t *\n\t\t *      js> (function() {}) instanceof Function\n\t\t *      true\n\t\t *      js> Function instanceof Function\n\t\t *      true\n\t\t *\n\t\t *  For the latter, h_proto will be Function.prototype, which is the\n\t\t *  built-in Function prototype.  Because Function.[[Prototype]] is\n\t\t *  also the built-in Function prototype, the result is true.\n\t\t */\n\n\t\tif (!val) {\n\t\t\tgoto pop_and_false;\n\t\t}\n\n\t\tDUK_ASSERT(val != NULL);\n#if defined(DUK_USE_ES6_PROXY)\n\t\tval = duk_hobject_resolve_proxy_target(thr, val);\n#endif\n\n\t\tif (skip_first) {\n\t\t\tskip_first = 0;\n\t\t} else if (val == proto) {\n\t\t\tgoto pop_and_true;\n\t\t}\n\n\t\tDUK_ASSERT(val != NULL);\n\t\tval = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, val);\n\t} while (--sanity > 0);\n\n\tif (DUK_UNLIKELY(sanity == 0)) {\n\t\tDUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT);\n\t}\n\tDUK_UNREACHABLE();\n\n pop_and_false:\n\tduk_pop_2(ctx);\n\treturn 0;\n\n pop_and_true:\n\tduk_pop_2(ctx);\n\treturn 1;\n}\n\n/*\n *  in\n */\n\n/*\n *  E5 Sections 11.8.7, 8.12.6.\n *\n *  Basically just a property existence check using [[HasProperty]].\n */\n\nDUK_INTERNAL duk_bool_t duk_js_in(duk_hthread *thr, duk_tval *tv_x, duk_tval *tv_y) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_bool_t retval;\n\n\t/*\n\t *  Get the values onto the stack first.  It would be possible to cover\n\t *  some normal cases without resorting to the value stack (e.g. if\n\t *  lval is already a string).\n\t */\n\n\t/* XXX: The ES5/5.1/6 specifications require that the key in 'key in obj'\n\t * must be string coerced before the internal HasProperty() algorithm is\n\t * invoked.  A fast path skipping coercion could be safely implemented for\n\t * numbers (as number-to-string coercion has no side effects).  For ES2015\n\t * proxy behavior, the trap 'key' argument must be in a string coerced\n\t * form (which is a shame).\n\t */\n\n\t/* TypeError if rval is not an object or object like (e.g. lightfunc\n\t * or plain buffer).\n\t */\n\tduk_push_tval(ctx, tv_x);\n\tduk_push_tval(ctx, tv_y);\n\tduk_require_type_mask(ctx, -1, DUK_TYPE_MASK_OBJECT | DUK_TYPE_MASK_LIGHTFUNC | DUK_TYPE_MASK_BUFFER);\n\n\t(void) duk_to_property_key_hstring(ctx, -2);\n\n\tretval = duk_hobject_hasprop(thr,\n\t                             DUK_GET_TVAL_NEGIDX(ctx, -1),\n\t                             DUK_GET_TVAL_NEGIDX(ctx, -2));\n\n\tduk_pop_2(ctx);\n\treturn retval;\n}\n\n/*\n *  typeof\n *\n *  E5 Section 11.4.3.\n *\n *  Very straightforward.  The only question is what to return for our\n *  non-standard tag / object types.\n *\n *  There is an unfortunate string constant define naming problem with\n *  typeof return values for e.g. \"Object\" and \"object\"; careful with\n *  the built-in string defines.  The LC_XXX defines are used for the\n *  lowercase variants now.\n */\n\nDUK_INTERNAL duk_small_uint_t duk_js_typeof_stridx(duk_tval *tv_x) {\n\tduk_small_uint_t stridx = 0;\n\n\tswitch (DUK_TVAL_GET_TAG(tv_x)) {\n\tcase DUK_TAG_UNDEFINED: {\n\t\tstridx = DUK_STRIDX_LC_UNDEFINED;\n\t\tbreak;\n\t}\n\tcase DUK_TAG_NULL: {\n\t\t/* Note: not a typo, \"object\" is returned for a null value. */\n\t\tstridx = DUK_STRIDX_LC_OBJECT;\n\t\tbreak;\n\t}\n\tcase DUK_TAG_BOOLEAN: {\n\t\tstridx = DUK_STRIDX_LC_BOOLEAN;\n\t\tbreak;\n\t}\n\tcase DUK_TAG_POINTER: {\n\t\t/* Implementation specific. */\n\t\tstridx = DUK_STRIDX_LC_POINTER;\n\t\tbreak;\n\t}\n\tcase DUK_TAG_STRING: {\n\t\tduk_hstring *str;\n\n\t\t/* All internal keys are identified as Symbols. */\n\t\tstr = DUK_TVAL_GET_STRING(tv_x);\n\t\tDUK_ASSERT(str != NULL);\n\t\tif (DUK_UNLIKELY(DUK_HSTRING_HAS_SYMBOL(str))) {\n\t\t\tstridx = DUK_STRIDX_LC_SYMBOL;\n\t\t} else {\n\t\t\tstridx = DUK_STRIDX_LC_STRING;\n\t\t}\n\t\tbreak;\n\t}\n\tcase DUK_TAG_OBJECT: {\n\t\tduk_hobject *obj = DUK_TVAL_GET_OBJECT(tv_x);\n\t\tDUK_ASSERT(obj != NULL);\n\t\tif (DUK_HOBJECT_IS_CALLABLE(obj)) {\n\t\t\tstridx = DUK_STRIDX_LC_FUNCTION;\n\t\t} else {\n\t\t\tstridx = DUK_STRIDX_LC_OBJECT;\n\t\t}\n\t\tbreak;\n\t}\n\tcase DUK_TAG_BUFFER: {\n\t\t/* Implementation specific.  In Duktape 1.x this would be\n\t\t * 'buffer', in Duktape 2.x changed to 'object' because plain\n\t\t * buffers now mimic Uint8Array objects.\n\t\t */\n\t\tstridx = DUK_STRIDX_LC_OBJECT;\n\t\tbreak;\n\t}\n\tcase DUK_TAG_LIGHTFUNC: {\n\t\tstridx = DUK_STRIDX_LC_FUNCTION;\n\t\tbreak;\n\t}\n#if defined(DUK_USE_FASTINT)\n\tcase DUK_TAG_FASTINT:\n#endif\n\tdefault: {\n\t\t/* number */\n\t\tDUK_ASSERT(!DUK_TVAL_IS_UNUSED(tv_x));\n\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv_x));\n\t\tstridx = DUK_STRIDX_LC_NUMBER;\n\t\tbreak;\n\t}\n\t}\n\n\tDUK_ASSERT_STRIDX_VALID(stridx);\n\treturn stridx;\n}\n\n/*\n *  Array index and length\n *\n *  Array index: E5 Section 15.4\n *  Array length: E5 Section 15.4.5.1 steps 3.c - 3.d (array length write)\n */\n\n/* Compure array index from string context, or return a \"not array index\"\n * indicator.\n */\nDUK_INTERNAL duk_uarridx_t duk_js_to_arrayindex_string(const duk_uint8_t *str, duk_uint32_t blen) {\n\tduk_uarridx_t res;\n\n\t/* Only strings with byte length 1-10 can be 32-bit array indices.\n\t * Leading zeroes (except '0' alone), plus/minus signs are not allowed.\n\t * We could do a lot of prechecks here, but since most strings won't\n\t * start with any digits, it's simpler to just parse the number and\n\t * fail quickly.\n\t */\n\n\tres = 0;\n\tif (blen == 0) {\n\t\tgoto parse_fail;\n\t}\n\tdo {\n\t\tduk_uarridx_t dig;\n\t\tdig = (duk_uarridx_t) (*str++) - DUK_ASC_0;\n\n\t\tif (dig <= 9U) {\n\t\t\t/* Careful overflow handling.  When multiplying by 10:\n\t\t\t * - 0x19999998 x 10 = 0xfffffff0: no overflow, and adding\n\t\t\t *   0...9 is safe.\n\t\t\t * - 0x19999999 x 10 = 0xfffffffa: no overflow, adding\n\t\t\t *   0...5 is safe, 6...9 overflows.\n\t\t\t * - 0x1999999a x 10 = 0x100000004: always overflow.\n\t\t\t */\n\t\t\tif (DUK_UNLIKELY(res >= 0x19999999UL)) {\n\t\t\t\tif (res >= 0x1999999aUL) {\n\t\t\t\t\t/* Always overflow. */\n\t\t\t\t\tgoto parse_fail;\n\t\t\t\t}\n\t\t\t\tDUK_ASSERT(res == 0x19999999UL);\n\t\t\t\tif (dig >= 6U) {\n\t\t\t\t\tgoto parse_fail;\n\t\t\t\t}\n\t\t\t\tres = 0xfffffffaUL + dig;\n\t\t\t\tDUK_ASSERT(res >= 0xfffffffaUL);\n\t\t\t\tDUK_ASSERT_DISABLE(res <= 0xffffffffUL);  /* range */\n\t\t\t} else {\n\t\t\t\tres = res * 10U + dig;\n\t\t\t\tif (DUK_UNLIKELY(res == 0)) {\n\t\t\t\t\t/* If 'res' is 0, previous 'res' must\n\t\t\t\t\t * have been 0 and we scanned in a zero.\n\t\t\t\t\t * This is only allowed if blen == 1,\n\t\t\t\t\t * i.e. the exact string '0'.\n\t\t\t\t\t */\n\t\t\t\t\tif (blen == (duk_uint32_t) 1) {\n\t\t\t\t\t\treturn 0;\n\t\t\t\t\t}\n\t\t\t\t\tgoto parse_fail;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t/* Because 'dig' is unsigned, catches both values\n\t\t\t * above '9' and below '0'.\n\t\t\t */\n\t\t\tgoto parse_fail;\n\t\t}\n\t} while (--blen > 0);\n\n\treturn res;\n\n parse_fail:\n\treturn DUK_HSTRING_NO_ARRAY_INDEX;\n}\n\n#if !defined(DUK_USE_HSTRING_ARRIDX)\n/* Get array index for a string which is known to be an array index.  This helper\n * is needed when duk_hstring doesn't concretely store the array index, but strings\n * are flagged as array indices at intern time.\n */\nDUK_INTERNAL duk_uarridx_t duk_js_to_arrayindex_hstring_fast_known(duk_hstring *h) {\n\tconst duk_uint8_t *p;\n\tduk_uarridx_t res;\n\tduk_uint8_t t;\n\n\tDUK_ASSERT(h != NULL);\n\tDUK_ASSERT(DUK_HSTRING_HAS_ARRIDX(h));\n\n\tp = DUK_HSTRING_GET_DATA(h);\n\tres = 0;\n\tfor (;;) {\n\t\tt = *p++;\n\t\tif (DUK_UNLIKELY(t == 0)) {\n\t\t\t/* Scanning to NUL is always safe for interned strings. */\n\t\t\tbreak;\n\t\t}\n\t\tDUK_ASSERT(t >= DUK_ASC_0 && t <= DUK_ASC_9);\n\t\tres = res * 10U + (t - DUK_ASC_0);\n\t}\n\treturn res;\n}\n\nDUK_INTERNAL duk_uarridx_t duk_js_to_arrayindex_hstring_fast(duk_hstring *h) {\n\tDUK_ASSERT(h != NULL);\n\tif (!DUK_HSTRING_HAS_ARRIDX(h)) {\n\t\treturn DUK_HSTRING_NO_ARRAY_INDEX;\n\t}\n\treturn duk_js_to_arrayindex_hstring_fast_known(h);\n}\n#endif  /* DUK_USE_HSTRING_ARRIDX */\n/*\n *  Identifier access and function closure handling.\n *\n *  Provides the primitives for slow path identifier accesses: GETVAR,\n *  PUTVAR, DELVAR, etc.  The fast path, direct register accesses, should\n *  be used for most identifier accesses.  Consequently, these slow path\n *  primitives should be optimized for maximum compactness.\n *\n *  Ecmascript environment records (declarative and object) are represented\n *  as internal objects with control keys.  Environment records have a\n *  parent record (\"outer environment reference\") which is represented by\n *  the implicit prototype for technical reasons (in other words, it is a\n *  convenient field).  The prototype chain is not followed in the ordinary\n *  sense for variable lookups.\n *\n *  See identifier-handling.rst for more details on the identifier algorithms\n *  and the internal representation.  See function-objects.rst for details on\n *  what function templates and instances are expected to look like.\n *\n *  Care must be taken to avoid duk_tval pointer invalidation caused by\n *  e.g. value stack or object resizing.\n *\n *  TODO: properties for function instances could be initialized much more\n *  efficiently by creating a property allocation for a certain size and\n *  filling in keys and values directly (and INCREFing both with \"bulk incref\"\n *  primitives.\n *\n *  XXX: duk_hobject_getprop() and duk_hobject_putprop() calls are a bit\n *  awkward (especially because they follow the prototype chain); rework\n *  if \"raw\" own property helpers are added.\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Local result type for duk__get_identifier_reference() lookup.\n */\n\ntypedef struct {\n\tduk_hobject *env;\n\tduk_hobject *holder;      /* for object-bound identifiers */\n\tduk_tval *value;          /* for register-bound and declarative env identifiers */\n\tduk_int_t attrs;          /* property attributes for identifier (relevant if value != NULL) */\n\tduk_bool_t has_this;      /* for object-bound identifiers: provide 'this' binding */\n} duk__id_lookup_result;\n\n/*\n *  Create a new function object based on a \"template function\" which contains\n *  compiled bytecode, constants, etc, but lacks a lexical environment.\n *\n *  Ecmascript requires that each created closure is a separate object, with\n *  its own set of editable properties.  However, structured property values\n *  (such as the formal arguments list and the variable map) are shared.\n *  Also the bytecode, constants, and inner functions are shared.\n *\n *  See E5 Section 13.2 for detailed requirements on the function objects;\n *  there are no similar requirements for function \"templates\" which are an\n *  implementation dependent internal feature.  Also see function-objects.rst\n *  for a discussion on the function instance properties provided by this\n *  implementation.\n *\n *  Notes:\n *\n *   * Order of internal properties should match frequency of use, since the\n *     properties will be linearly scanned on lookup (functions usually don't\n *     have enough properties to warrant a hash part).\n *\n *   * The created closure is independent of its template; they do share the\n *     same 'data' buffer object, but the template object itself can be freed\n *     even if the closure object remains reachable.\n */\n\nDUK_LOCAL void duk__inc_data_inner_refcounts(duk_hthread *thr, duk_hcompfunc *f) {\n\tduk_tval *tv, *tv_end;\n\tduk_hobject **funcs, **funcs_end;\n\n\tDUK_UNREF(thr);\n\n\t/* If function creation fails due to out-of-memory, the data buffer\n\t * pointer may be NULL in some cases.  That's actually possible for\n\t * GC code, but shouldn't be possible here because the incomplete\n\t * function will be unwound from the value stack and never instantiated.\n\t */\n\tDUK_ASSERT(DUK_HCOMPFUNC_GET_DATA(thr->heap, f) != NULL);\n\n\ttv = DUK_HCOMPFUNC_GET_CONSTS_BASE(thr->heap, f);\n\ttv_end = DUK_HCOMPFUNC_GET_CONSTS_END(thr->heap, f);\n\twhile (tv < tv_end) {\n\t\tDUK_TVAL_INCREF(thr, tv);\n\t\ttv++;\n\t}\n\n\tfuncs = DUK_HCOMPFUNC_GET_FUNCS_BASE(thr->heap, f);\n\tfuncs_end = DUK_HCOMPFUNC_GET_FUNCS_END(thr->heap, f);\n\twhile (funcs < funcs_end) {\n\t\tDUK_HEAPHDR_INCREF(thr, (duk_heaphdr *) *funcs);\n\t\tfuncs++;\n\t}\n}\n\n/* Push a new closure on the stack.\n *\n * Note: if fun_temp has NEWENV, i.e. a new lexical and variable declaration\n * is created when the function is called, only outer_lex_env matters\n * (outer_var_env is ignored and may or may not be same as outer_lex_env).\n */\n\nDUK_LOCAL const duk_uint16_t duk__closure_copy_proplist[] = {\n\t/* order: most frequent to least frequent */\n\tDUK_STRIDX_INT_VARMAP,\n\tDUK_STRIDX_INT_FORMALS,\n#if defined(DUK_USE_PC2LINE)\n\tDUK_STRIDX_INT_PC2LINE,\n#endif\n#if defined(DUK_USE_FUNC_FILENAME_PROPERTY)\n\tDUK_STRIDX_FILE_NAME,\n#endif\n#if defined(DUK_USE_NONSTD_FUNC_SOURCE_PROPERTY)\n\tDUK_STRIDX_INT_SOURCE\n#endif\n};\n\nDUK_INTERNAL\nvoid duk_js_push_closure(duk_hthread *thr,\n                         duk_hcompfunc *fun_temp,\n                         duk_hobject *outer_var_env,\n                         duk_hobject *outer_lex_env,\n                         duk_bool_t add_auto_proto) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hcompfunc *fun_clos;\n\tduk_small_uint_t i;\n\tduk_uint_t len_value;\n\n\tDUK_ASSERT(fun_temp != NULL);\n\tDUK_ASSERT(DUK_HCOMPFUNC_GET_DATA(thr->heap, fun_temp) != NULL);\n\tDUK_ASSERT(DUK_HCOMPFUNC_GET_FUNCS(thr->heap, fun_temp) != NULL);\n\tDUK_ASSERT(DUK_HCOMPFUNC_GET_BYTECODE(thr->heap, fun_temp) != NULL);\n\tDUK_ASSERT(outer_var_env != NULL);\n\tDUK_ASSERT(outer_lex_env != NULL);\n\tDUK_UNREF(len_value);\n\n\tfun_clos = duk_push_hcompfunc(ctx);\n\tDUK_ASSERT(fun_clos != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_GET_PROTOTYPE(thr->heap, (duk_hobject *) fun_clos) == thr->builtins[DUK_BIDX_FUNCTION_PROTOTYPE]);\n\n\tduk_push_hobject(ctx, &fun_temp->obj);  /* -> [ ... closure template ] */\n\n\tDUK_ASSERT(DUK_HOBJECT_IS_COMPFUNC((duk_hobject *) fun_clos));\n\tDUK_ASSERT(DUK_HCOMPFUNC_GET_DATA(thr->heap, fun_clos) == NULL);\n\tDUK_ASSERT(DUK_HCOMPFUNC_GET_FUNCS(thr->heap, fun_clos) == NULL);\n\tDUK_ASSERT(DUK_HCOMPFUNC_GET_BYTECODE(thr->heap, fun_clos) == NULL);\n\n\tDUK_HCOMPFUNC_SET_DATA(thr->heap, fun_clos, DUK_HCOMPFUNC_GET_DATA(thr->heap, fun_temp));\n\tDUK_HCOMPFUNC_SET_FUNCS(thr->heap, fun_clos, DUK_HCOMPFUNC_GET_FUNCS(thr->heap, fun_temp));\n\tDUK_HCOMPFUNC_SET_BYTECODE(thr->heap, fun_clos, DUK_HCOMPFUNC_GET_BYTECODE(thr->heap, fun_temp));\n\n\t/* Note: all references inside 'data' need to get their refcounts\n\t * upped too.  This is the case because refcounts are decreased\n\t * through every function referencing 'data' independently.\n\t */\n\n\tDUK_HBUFFER_INCREF(thr, DUK_HCOMPFUNC_GET_DATA(thr->heap, fun_clos));\n\tduk__inc_data_inner_refcounts(thr, fun_temp);\n\n\tfun_clos->nregs = fun_temp->nregs;\n\tfun_clos->nargs = fun_temp->nargs;\n#if defined(DUK_USE_DEBUGGER_SUPPORT)\n\tfun_clos->start_line = fun_temp->start_line;\n\tfun_clos->end_line = fun_temp->end_line;\n#endif\n\n\tDUK_ASSERT(DUK_HCOMPFUNC_GET_DATA(thr->heap, fun_clos) != NULL);\n\tDUK_ASSERT(DUK_HCOMPFUNC_GET_FUNCS(thr->heap, fun_clos) != NULL);\n\tDUK_ASSERT(DUK_HCOMPFUNC_GET_BYTECODE(thr->heap, fun_clos) != NULL);\n\n\t/* XXX: could also copy from template, but there's no way to have any\n\t * other value here now (used code has no access to the template).\n\t */\n\tDUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, &fun_clos->obj, thr->builtins[DUK_BIDX_FUNCTION_PROTOTYPE]);\n\n\t/* Copy duk_hobject flags as is from the template using a mask.\n\t * Leave out duk_heaphdr owned flags just in case (e.g. if there's\n\t * some GC flag or similar).  Some flags can then be adjusted\n\t * separately if necessary.\n\t */\n\n\t/* DUK_HEAPHDR_SET_FLAGS() masks changes to non-duk_heaphdr flags only. */\n\tDUK_HEAPHDR_SET_FLAGS((duk_heaphdr *) fun_clos, DUK_HEAPHDR_GET_FLAGS_RAW((duk_heaphdr *) fun_temp));\n\tDUK_DD(DUK_DDPRINT(\"fun_temp heaphdr flags: 0x%08lx, fun_clos heaphdr flags: 0x%08lx\",\n\t                   (unsigned long) DUK_HEAPHDR_GET_FLAGS_RAW((duk_heaphdr *) fun_temp),\n\t                   (unsigned long) DUK_HEAPHDR_GET_FLAGS_RAW((duk_heaphdr *) fun_clos)));\n\n\tDUK_ASSERT(DUK_HOBJECT_HAS_EXTENSIBLE(&fun_clos->obj));\n\tDUK_ASSERT(!DUK_HOBJECT_HAS_BOUNDFUNC(&fun_clos->obj));\n\tDUK_ASSERT(DUK_HOBJECT_HAS_COMPFUNC(&fun_clos->obj));\n\tDUK_ASSERT(!DUK_HOBJECT_HAS_NATFUNC(&fun_clos->obj));\n\tDUK_ASSERT(!DUK_HOBJECT_IS_THREAD(&fun_clos->obj));\n\t/* DUK_HOBJECT_FLAG_ARRAY_PART: don't care */\n\t/* DUK_HOBJECT_FLAG_NEWENV: handled below */\n\tDUK_ASSERT(!DUK_HOBJECT_HAS_EXOTIC_ARRAY(&fun_clos->obj));\n\tDUK_ASSERT(!DUK_HOBJECT_HAS_EXOTIC_STRINGOBJ(&fun_clos->obj));\n\tDUK_ASSERT(!DUK_HOBJECT_HAS_EXOTIC_ARGUMENTS(&fun_clos->obj));\n\n\tif (!DUK_HOBJECT_HAS_CONSTRUCTABLE(&fun_clos->obj)) {\n\t\t/* If the template is not constructable don't add an automatic\n\t\t * .prototype property.  This is the case for e.g. ES2015 object\n\t\t * literal getters/setters and method definitions.\n\t\t */\n\t\tadd_auto_proto = 0;\n\t}\n\n\t/*\n\t *  Setup environment record properties based on the template and\n\t *  its flags.\n\t *\n\t *  If DUK_HOBJECT_HAS_NEWENV(fun_temp) is true, the environment\n\t *  records represent identifiers \"outside\" the function; the\n\t *  \"inner\" environment records are created on demand.  Otherwise,\n\t *  the environment records are those that will be directly used\n\t *  (e.g. for declarations).\n\t *\n\t *  _Lexenv is always set; _Varenv defaults to _Lexenv if missing,\n\t *  so _Varenv is only set if _Lexenv != _Varenv.\n\t *\n\t *  This is relatively complex, see doc/identifier-handling.rst.\n\t */\n\n\tif (DUK_HOBJECT_HAS_NEWENV(&fun_clos->obj)) {\n#if defined(DUK_USE_FUNC_NAME_PROPERTY)\n\t\tif (DUK_HOBJECT_HAS_NAMEBINDING(&fun_clos->obj)) {\n\t\t\tduk_hobject *proto;\n\t\t\tduk_hdecenv *new_env;\n\n\t\t\t/*\n\t\t\t *  Named function expression, name needs to be bound\n\t\t\t *  in an intermediate environment record.  The \"outer\"\n\t\t\t *  lexical/variable environment will thus be:\n\t\t\t *\n\t\t\t *  a) { funcname: <func>, __prototype: outer_lex_env }\n\t\t\t *  b) { funcname: <func>, __prototype:  <globalenv> }  (if outer_lex_env missing)\n\t\t\t */\n\n\t\t\tif (outer_lex_env) {\n\t\t\t\tproto = outer_lex_env;\n\t\t\t} else {\n\t\t\t\tproto = thr->builtins[DUK_BIDX_GLOBAL_ENV];\n\t\t\t}\n\n\t\t\t/* -> [ ... closure template env ] */\n\t\t\tnew_env = duk_hdecenv_alloc(thr,\n\t\t\t                            DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t\t\t                            DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_DECENV));\n\t\t\tDUK_ASSERT(new_env != NULL);\n\t\t\tduk_push_hobject(ctx, (duk_hobject *) new_env);\n\n\t\t\tDUK_ASSERT(DUK_HOBJECT_GET_PROTOTYPE(thr->heap, (duk_hobject *) new_env) == NULL);\n\t\t\tDUK_HOBJECT_SET_PROTOTYPE(thr->heap, (duk_hobject *) new_env, proto);\n\t\t\tDUK_HOBJECT_INCREF_ALLOWNULL(thr, proto);\n\n\t\t\tDUK_ASSERT(new_env->thread == NULL);  /* Closed. */\n\t\t\tDUK_ASSERT(new_env->varmap == NULL);\n\n\t\t\t/* It's important that duk_xdef_prop() is a 'raw define' so that any\n\t\t\t * properties in an ancestor are never an issue (they should never be\n\t\t\t * e.g. non-writable, but just in case).\n\t\t\t *\n\t\t\t * Because template objects are not visible to user code, the case\n\t\t\t * where .name is missing shouldn't happen in practice.  It it does,\n\t\t\t * the name 'undefined' gets bound and maps to the closure (which is\n\t\t\t * a bit odd, but safe).\n\t\t\t */\n\t\t\t(void) duk_get_prop_stridx_short(ctx, -2, DUK_STRIDX_NAME);\n\t\t\t/* -> [ ... closure template env funcname ] */\n\t\t\tduk_dup_m4(ctx);                                           /* -> [ ... closure template env funcname closure ] */\n\t\t\tduk_xdef_prop(ctx, -3, DUK_PROPDESC_FLAGS_NONE);           /* -> [ ... closure template env ] */\n\t\t\t/* env[funcname] = closure */\n\n\t\t\t/* [ ... closure template env ] */\n\n\t\t\tDUK_HCOMPFUNC_SET_LEXENV(thr->heap, fun_clos, (duk_hobject *) new_env);\n\t\t\tDUK_HCOMPFUNC_SET_VARENV(thr->heap, fun_clos, (duk_hobject *) new_env);\n\t\t\tDUK_HOBJECT_INCREF(thr, (duk_hobject *) new_env);\n\t\t\tDUK_HOBJECT_INCREF(thr, (duk_hobject *) new_env);\n\t\t\tduk_pop(ctx);\n\n\t\t\t/* [ ... closure template ] */\n\t\t}\n\t\telse\n#endif  /* DUK_USE_FUNC_NAME_PROPERTY */\n\t\t{\n\t\t\t/*\n\t\t\t *  Other cases (function declaration, anonymous function expression,\n\t\t\t *  strict direct eval code).  The \"outer\" environment will be whatever\n\t\t\t *  the caller gave us.\n\t\t\t */\n\n\t\t\tDUK_HCOMPFUNC_SET_LEXENV(thr->heap, fun_clos, outer_lex_env);\n\t\t\tDUK_HCOMPFUNC_SET_VARENV(thr->heap, fun_clos, outer_lex_env);\n\t\t\tDUK_HOBJECT_INCREF(thr, outer_lex_env);\n\t\t\tDUK_HOBJECT_INCREF(thr, outer_lex_env);\n\n\t\t\t/* [ ... closure template ] */\n\t\t}\n\t} else {\n\t\t/*\n\t\t *  Function gets no new environment when called.  This is the\n\t\t *  case for global code, indirect eval code, and non-strict\n\t\t *  direct eval code.  There is no direct correspondence to the\n\t\t *  E5 specification, as global/eval code is not exposed as a\n\t\t *  function.\n\t\t */\n\n\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_NAMEBINDING(&fun_temp->obj));\n\n\t\tDUK_HCOMPFUNC_SET_LEXENV(thr->heap, fun_clos, outer_lex_env);\n\t\tDUK_HCOMPFUNC_SET_VARENV(thr->heap, fun_clos, outer_var_env);\n\t\tDUK_HOBJECT_INCREF(thr, outer_lex_env);  /* NULLs not allowed; asserted on entry */\n\t\tDUK_HOBJECT_INCREF(thr, outer_var_env);\n\t}\n\tDUK_DDD(DUK_DDDPRINT(\"closure varenv -> %!ipO, lexenv -> %!ipO\",\n\t                     (duk_heaphdr *) fun_clos->var_env,\n\t                     (duk_heaphdr *) fun_clos->lex_env));\n\n\t/* Call handling assumes this for all callable closures. */\n\tDUK_ASSERT(DUK_HCOMPFUNC_GET_LEXENV(thr->heap, fun_clos) != NULL);\n\tDUK_ASSERT(DUK_HCOMPFUNC_GET_VARENV(thr->heap, fun_clos) != NULL);\n\n\t/*\n\t *  Copy some internal properties directly\n\t *\n\t *  The properties will be non-writable and non-enumerable, but\n\t *  configurable.\n\t */\n\n\t/* [ ... closure template ] */\n\n\tDUK_DDD(DUK_DDDPRINT(\"copying properties: closure=%!iT, template=%!iT\",\n\t                     (duk_tval *) duk_get_tval(ctx, -2),\n\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\n\tfor (i = 0; i < (duk_small_uint_t) (sizeof(duk__closure_copy_proplist) / sizeof(duk_uint16_t)); i++) {\n\t\tduk_small_int_t stridx = (duk_small_int_t) duk__closure_copy_proplist[i];\n\t\tif (duk_get_prop_stridx_short(ctx, -1, stridx)) {\n\t\t\t/* [ ... closure template val ] */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"copying property, stridx=%ld -> found\", (long) stridx));\n\t\t\tduk_xdef_prop_stridx_short(ctx, -3, stridx, DUK_PROPDESC_FLAGS_C);\n\t\t} else {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"copying property, stridx=%ld -> not found\", (long) stridx));\n\t\t\tduk_pop(ctx);\n\t\t}\n\t}\n\n\t/*\n\t *  \"length\" maps to number of formals (E5 Section 13.2) for function\n\t *  declarations/expressions (non-bound functions).  Note that 'nargs'\n\t *  is NOT necessarily equal to the number of arguments.  Use length\n\t *  of _Formals; if missing, assume nargs matches .length.\n\t */\n\n\t/* [ ... closure template ] */\n\n\t/* XXX: these lookups should be just own property lookups instead of\n\t * looking up the inheritance chain.\n\t */\n\tif (duk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_INT_FORMALS)) {\n\t\t/* [ ... closure template formals ] */\n\t\tlen_value = (duk_uint_t) duk_get_length(ctx, -1);  /* could access duk_harray directly, not important */\n\t\tDUK_DD(DUK_DDPRINT(\"closure length from _Formals -> %ld\", (long) len_value));\n\t} else {\n\t\tlen_value = fun_temp->nargs;\n\t\tDUK_DD(DUK_DDPRINT(\"closure length defaulted from nargs -> %ld\", (long) len_value));\n\t}\n\tduk_pop(ctx);\n\n\tduk_push_uint(ctx, len_value);  /* [ ... closure template len_value ] */\n\tduk_xdef_prop_stridx_short(ctx, -3, DUK_STRIDX_LENGTH, DUK_PROPDESC_FLAGS_C);\n\n\t/*\n\t *  \"prototype\" is, by default, a fresh object with the \"constructor\"\n\t *  property.\n\t *\n\t *  Note that this creates a circular reference for every function\n\t *  instance (closure) which prevents refcount-based collection of\n\t *  function instances.\n\t *\n\t *  XXX: Try to avoid creating the default prototype object, because\n\t *  many functions are not used as constructors and the default\n\t *  prototype is unnecessary.  Perhaps it could be created on-demand\n\t *  when it is first accessed?\n\t */\n\n\t/* [ ... closure template ] */\n\n\tif (add_auto_proto) {\n\t\tduk_push_object(ctx);  /* -> [ ... closure template newobj ] */\n\t\tduk_dup_m3(ctx);       /* -> [ ... closure template newobj closure ] */\n\t\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_CONSTRUCTOR, DUK_PROPDESC_FLAGS_WC);  /* -> [ ... closure template newobj ] */\n\t\tduk_compact(ctx, -1);  /* compact the prototype */\n\t\tduk_xdef_prop_stridx_short(ctx, -3, DUK_STRIDX_PROTOTYPE, DUK_PROPDESC_FLAGS_W);     /* -> [ ... closure template ] */\n\t}\n\n\t/*\n\t *  \"arguments\" and \"caller\" must be mapped to throwers for strict\n\t *  mode and bound functions (E5 Section 15.3.5).\n\t *\n\t *  XXX: This is expensive to have for every strict function instance.\n\t *  Try to implement as virtual properties or on-demand created properties.\n\t */\n\n\t/* [ ... closure template ] */\n\n\tif (DUK_HOBJECT_HAS_STRICT(&fun_clos->obj)) {\n\t\tduk_xdef_prop_stridx_thrower(ctx, -2, DUK_STRIDX_CALLER);\n\t\tduk_xdef_prop_stridx_thrower(ctx, -2, DUK_STRIDX_LC_ARGUMENTS);\n\t} else {\n#if defined(DUK_USE_NONSTD_FUNC_CALLER_PROPERTY)\n\t\tDUK_DDD(DUK_DDDPRINT(\"function is non-strict and non-standard 'caller' property in use, add initial 'null' value\"));\n\t\tduk_push_null(ctx);\n\t\tduk_xdef_prop_stridx_short(ctx, -3, DUK_STRIDX_CALLER, DUK_PROPDESC_FLAGS_NONE);\n#else\n\t\tDUK_DDD(DUK_DDDPRINT(\"function is non-strict and non-standard 'caller' property not used\"));\n#endif\n\t}\n\n\t/*\n\t *  \"name\" used to be non-standard but is now defined by ES2015.\n\t *  In ES2015/ES2016 the .name property is configurable.\n\t */\n\n\t/* [ ... closure template ] */\n\n#if defined(DUK_USE_FUNC_NAME_PROPERTY)\n\t/* XXX: Look for own property only; doesn't matter much because\n\t * templates are bare objects.\n\t */\n\tif (duk_get_prop_stridx_short(ctx, -1, DUK_STRIDX_NAME)) {\n\t\t/* [ ... closure template name ] */\n\t\tDUK_ASSERT(duk_is_string(ctx, -1));\n\t\tDUK_DD(DUK_DDPRINT(\"setting function instance name to %!T\", duk_get_tval(ctx, -1)));\n\t\tduk_xdef_prop_stridx_short(ctx, -3, DUK_STRIDX_NAME, DUK_PROPDESC_FLAGS_C);  /* -> [ ... closure template ] */\n\t} else {\n\t\t/* Anonymous functions don't have a .name in ES2015, so don't set\n\t\t * it on the instance either.  The instance will then inherit\n\t\t * it from Function.prototype.name.\n\t\t */\n\t\tDUK_DD(DUK_DDPRINT(\"not setting function instance .name\"));\n\t\tduk_pop(ctx);\n\t}\n#endif\n\n\t/*\n\t *  Compact the closure, in most cases no properties will be added later.\n\t *  Also, without this the closures end up having unused property slots\n\t *  (e.g. in Duktape 0.9.0, 8 slots would be allocated and only 7 used).\n\t *  A better future solution would be to allocate the closure directly\n\t *  to correct size (and setup the properties directly without going\n\t *  through the API).\n\t */\n\n\tduk_compact(ctx, -2);\n\n\t/*\n\t *  Some assertions (E5 Section 13.2).\n\t */\n\n\tDUK_ASSERT(DUK_HOBJECT_GET_CLASS_NUMBER(&fun_clos->obj) == DUK_HOBJECT_CLASS_FUNCTION);\n\tDUK_ASSERT(DUK_HOBJECT_GET_PROTOTYPE(thr->heap, &fun_clos->obj) == thr->builtins[DUK_BIDX_FUNCTION_PROTOTYPE]);\n\tDUK_ASSERT(DUK_HOBJECT_HAS_EXTENSIBLE(&fun_clos->obj));\n\tDUK_ASSERT(duk_has_prop_stridx(ctx, -2, DUK_STRIDX_LENGTH) != 0);\n\tDUK_ASSERT(add_auto_proto == 0 || duk_has_prop_stridx(ctx, -2, DUK_STRIDX_PROTOTYPE) != 0);\n\t/* May be missing .name */\n\tDUK_ASSERT(!DUK_HOBJECT_HAS_STRICT(&fun_clos->obj) ||\n\t           duk_has_prop_stridx(ctx, -2, DUK_STRIDX_CALLER) != 0);\n\tDUK_ASSERT(!DUK_HOBJECT_HAS_STRICT(&fun_clos->obj) ||\n\t           duk_has_prop_stridx(ctx, -2, DUK_STRIDX_LC_ARGUMENTS) != 0);\n\n\t/*\n\t *  Finish\n\t */\n\n\t/* [ ... closure template ] */\n\n\tDUK_DDD(DUK_DDDPRINT(\"created function instance: template=%!iT -> closure=%!iT\",\n\t                     (duk_tval *) duk_get_tval(ctx, -1),\n\t                     (duk_tval *) duk_get_tval(ctx, -2)));\n\n\tduk_pop(ctx);\n\n\t/* [ ... closure ] */\n}\n\n/*\n *  Delayed activation environment record initialization (for functions\n *  with NEWENV).\n *\n *  The non-delayed initialization is handled by duk_handle_call().\n */\n\n/* shared helper */\nDUK_INTERNAL\nduk_hobject *duk_create_activation_environment_record(duk_hthread *thr,\n                                                      duk_hobject *func,\n                                                      duk_size_t idx_bottom) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hdecenv *env;\n\tduk_hobject *parent;\n\tduk_hcompfunc *f;\n\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(func != NULL);\n\n\tf = (duk_hcompfunc *) func;\n\tparent = DUK_HCOMPFUNC_GET_LEXENV(thr->heap, f);\n\tif (!parent) {\n\t\tparent = thr->builtins[DUK_BIDX_GLOBAL_ENV];\n\t}\n\n\tenv = duk_hdecenv_alloc(thr,\n\t                        DUK_HOBJECT_FLAG_EXTENSIBLE |\n\t                        DUK_HOBJECT_CLASS_AS_FLAGS(DUK_HOBJECT_CLASS_DECENV));\n\tDUK_ASSERT(env != NULL);\n\tduk_push_hobject(ctx, (duk_hobject *) env);\n\n\tDUK_ASSERT(DUK_HOBJECT_GET_PROTOTYPE(thr->heap, (duk_hobject *) env) == NULL);\n\tDUK_HOBJECT_SET_PROTOTYPE(thr->heap, (duk_hobject *) env, parent);\n\tDUK_HOBJECT_INCREF_ALLOWNULL(thr, parent);  /* parent env is the prototype */\n\n\t/* open scope information, for compiled functions only */\n\n\tDUK_ASSERT(env->thread == NULL);\n\tDUK_ASSERT(env->varmap == NULL);\n\tDUK_ASSERT(env->regbase == 0);\n\tif (DUK_HOBJECT_IS_COMPFUNC(func)) {\n\t\tduk_hobject *varmap;\n\t\tduk_tval *tv;\n\n\t\ttv = duk_hobject_find_existing_entry_tval_ptr(thr->heap, func, DUK_HTHREAD_STRING_INT_VARMAP(thr));\n\t\tif (tv != NULL && DUK_TVAL_IS_OBJECT(tv)) {\n\t\t\tDUK_ASSERT(DUK_TVAL_IS_OBJECT(tv));\n\t\t\tvarmap = DUK_TVAL_GET_OBJECT(tv);\n\t\t\tDUK_ASSERT(varmap != NULL);\n\t\t\tenv->varmap = varmap;\n\t\t\tDUK_HOBJECT_INCREF(thr, varmap);\n\t\t\tenv->thread = thr;\n\t\t\tDUK_HTHREAD_INCREF(thr, thr);\n\t\t\tenv->regbase = idx_bottom;\n\t\t} else {\n\t\t\t/* If function has no _Varmap, leave the environment closed. */\n\t\t\tDUK_ASSERT(env->thread == NULL);\n\t\t\tDUK_ASSERT(env->varmap == NULL);\n\t\t\tDUK_ASSERT(env->regbase == 0);\n\t\t}\n\t}\n\n\treturn (duk_hobject *) env;\n}\n\nDUK_INTERNAL\nvoid duk_js_init_activation_environment_records_delayed(duk_hthread *thr,\n                                                        duk_activation *act) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hobject *func;\n\tduk_hobject *env;\n\tduk_size_t act_off;\n\n\tDUK_ASSERT(act != NULL);\n\tact_off = (duk_size_t) ((duk_uint8_t *) act - (duk_uint8_t *) thr->callstack);\n\tfunc = DUK_ACT_GET_FUNC(act);\n\tDUK_ASSERT(func != NULL);\n\tDUK_ASSERT(!DUK_HOBJECT_HAS_BOUNDFUNC(func));  /* bound functions are never in act 'func' */\n\n\t/*\n\t *  Delayed initialization only occurs for 'NEWENV' functions.\n\t */\n\n\tDUK_ASSERT(DUK_HOBJECT_HAS_NEWENV(func));\n\tDUK_ASSERT(act->lex_env == NULL);\n\tDUK_ASSERT(act->var_env == NULL);\n\n\tenv = duk_create_activation_environment_record(thr, func, act->idx_bottom);\n\tDUK_ASSERT(env != NULL);\n\tact = (duk_activation *) (void *) ((duk_uint8_t *) thr->callstack + act_off);\n\n\tDUK_DDD(DUK_DDDPRINT(\"created delayed fresh env: %!ipO\", (duk_heaphdr *) env));\n#if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 2)\n\t{\n\t\tduk_hobject *p = env;\n\t\twhile (p) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"  -> %!ipO\", (duk_heaphdr *) p));\n\t\t\tp = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, p);\n\t\t}\n\t}\n#endif\n\n\tact->lex_env = env;\n\tact->var_env = env;\n\tDUK_HOBJECT_INCREF(thr, env);  /* XXX: incref by count (here 2 times) */\n\tDUK_HOBJECT_INCREF(thr, env);\n\n\tduk_pop(ctx);\n}\n\n/*\n *  Closing environment records.\n *\n *  The environment record MUST be closed with the thread where its activation\n *  is; i.e. if 'env' is open, 'thr' must match env->thread, and the regbase\n *  and varmap must still be valid.  On entry, 'env' must be reachable.\n */\n\nDUK_INTERNAL void duk_js_close_environment_record(duk_hthread *thr, duk_hobject *env) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_uint_fast32_t i;\n\tduk_hobject *varmap;\n\tduk_hstring *key;\n\tduk_tval *tv;\n\tduk_uint_t regnum;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(env != NULL);\n\n\tif (DUK_UNLIKELY(!DUK_HOBJECT_IS_DECENV(env))) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"env not a declarative record: %!iO\", (duk_heaphdr *) env));\n\t\treturn;\n\t}\n\n\tvarmap = ((duk_hdecenv *) env)->varmap;\n\tif (varmap == NULL) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"env already closed: %!iO\", (duk_heaphdr *) env));\n\n\t\treturn;\n\t}\n\tDUK_ASSERT(((duk_hdecenv *) env)->thread != NULL);\n\tDUK_ASSERT_HDECENV_VALID((duk_hdecenv *) env);\n\n\tDUK_DDD(DUK_DDDPRINT(\"closing env: %!iO\", (duk_heaphdr *) env));\n\tDUK_DDD(DUK_DDDPRINT(\"varmap: %!O\", (duk_heaphdr *) varmap));\n\n\t/* Env must be closed in the same thread as where it runs. */\n\tDUK_ASSERT(((duk_hdecenv *) env)->thread == thr);\n\n\t/* XXX: additional conditions when to close variables? we don't want to do it\n\t * unless the environment may have \"escaped\" (referenced in a function closure).\n\t * With delayed environments, the existence is probably good enough of a check.\n\t */\n\n\t/* Note: we rely on the _Varmap having a bunch of nice properties, like:\n\t *  - being compacted and unmodified during this process\n\t *  - not containing an array part\n\t *  - having correct value types\n\t */\n\n\tDUK_DDD(DUK_DDDPRINT(\"copying bound register values, %ld bound regs\", (long) DUK_HOBJECT_GET_ENEXT(varmap)));\n\n\t/* Copy over current variable values from value stack to the\n\t * environment record.  The scope object is empty but may\n\t * inherit from another scope which has conflicting names.\n\t */\n\n\t/* XXX: Do this using a once allocated entry area, no side effects.\n\t * Hash part would need special treatment however (maybe copy, and\n\t * then realloc with hash part if large enough).\n\t */\n\tfor (i = 0; i < (duk_uint_fast32_t) DUK_HOBJECT_GET_ENEXT(varmap); i++) {\n\t\tduk_size_t regbase;\n\n\t\tkey = DUK_HOBJECT_E_GET_KEY(thr->heap, varmap, i);\n\t\tDUK_ASSERT(key != NULL);   /* assume keys are compact in _Varmap */\n\t\tDUK_ASSERT(!DUK_HOBJECT_E_SLOT_IS_ACCESSOR(thr->heap, varmap, i));  /* assume plain values */\n\n\t\ttv = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, varmap, i);\n\t\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv));\n\t\tDUK_ASSERT(DUK_TVAL_GET_NUMBER(tv) <= (duk_double_t) DUK_UINT32_MAX);  /* limits */\n#if defined(DUK_USE_FASTINT)\n\t\tDUK_ASSERT(DUK_TVAL_IS_FASTINT(tv));\n\t\tregnum = (duk_uint_t) DUK_TVAL_GET_FASTINT_U32(tv);\n#else\n\t\tregnum = (duk_uint_t) DUK_TVAL_GET_NUMBER(tv);\n#endif\n\n\t\tregbase = ((duk_hdecenv *) env)->regbase;\n\t\tDUK_ASSERT(thr->valstack + regbase + regnum >= thr->valstack);\n\t\tDUK_ASSERT(thr->valstack + regbase + regnum < thr->valstack_top);\n\n\t\t/* If property already exists, overwrites silently.\n\t\t * Property is writable, but not deletable (not configurable\n\t\t * in terms of property attributes).\n\t\t */\n\t\tduk_push_tval(ctx, thr->valstack + regbase + regnum);\n\t\tDUK_DDD(DUK_DDDPRINT(\"closing identifier %!O -> reg %ld, value %!T\",\n\t\t                     (duk_heaphdr *) key,\n\t\t                     (long) regnum,\n\t\t                     (duk_tval *) duk_get_tval(ctx, -1)));\n\t\tduk_hobject_define_property_internal(thr, env, key, DUK_PROPDESC_FLAGS_WE);\n\t}\n\n\t/* NULL atomically to avoid inconsistent state + side effects. */\n\tDUK_HOBJECT_DECREF_NORZ(thr, ((duk_hdecenv *) env)->thread);\n\tDUK_HOBJECT_DECREF_NORZ(thr, ((duk_hdecenv *) env)->varmap);\n\t((duk_hdecenv *) env)->thread = NULL;\n\t((duk_hdecenv *) env)->varmap = NULL;\n\n\tDUK_DDD(DUK_DDDPRINT(\"env after closing: %!O\", (duk_heaphdr *) env));\n}\n\n/*\n *  GETIDREF: a GetIdentifierReference-like helper.\n *\n *  Provides a parent traversing lookup and a single level lookup\n *  (for HasBinding).\n *\n *  Instead of returning the value, returns a bunch of values allowing\n *  the caller to read, write, or delete the binding.  Value pointers\n *  are duk_tval pointers which can be mutated directly as long as\n *  refcounts are properly updated.  Note that any operation which may\n *  reallocate valstacks or compact objects may invalidate the returned\n *  duk_tval (but not object) pointers, so caller must be very careful.\n *\n *  If starting environment record 'env' is given, 'act' is ignored.\n *  However, if 'env' is NULL, the caller may identify, in 'act', an\n *  activation which hasn't had its declarative environment initialized\n *  yet.  The activation registers are then looked up, and its parent\n *  traversed normally.\n *\n *  The 'out' structure values are only valid if the function returns\n *  success (non-zero).\n */\n\n/* lookup name from an open declarative record's registers */\nDUK_LOCAL\nduk_bool_t duk__getid_open_decl_env_regs(duk_hthread *thr,\n                                         duk_hstring *name,\n                                         duk_hdecenv *env,\n                                         duk__id_lookup_result *out) {\n\tduk_tval *tv;\n\tduk_size_t reg_rel;\n\tduk_size_t idx;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(name != NULL);\n\tDUK_ASSERT(env != NULL);\n\tDUK_ASSERT(out != NULL);\n\n\tDUK_ASSERT(DUK_HOBJECT_IS_DECENV((duk_hobject *) env));\n\tDUK_ASSERT_HDECENV_VALID(env);\n\n\tif (env->thread == NULL) {\n\t\t/* already closed */\n\t\treturn 0;\n\t}\n\tDUK_ASSERT(env->varmap != NULL);\n\n\ttv = duk_hobject_find_existing_entry_tval_ptr(thr->heap, env->varmap, name);\n\tif (DUK_UNLIKELY(tv == NULL)) {\n\t\treturn 0;\n\t}\n\n\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv));\n\tDUK_ASSERT(DUK_TVAL_GET_NUMBER(tv) <= (duk_double_t) DUK_UINT32_MAX);  /* limits */\n#if defined(DUK_USE_FASTINT)\n\tDUK_ASSERT(DUK_TVAL_IS_FASTINT(tv));\n\treg_rel = (duk_size_t) DUK_TVAL_GET_FASTINT_U32(tv);\n#else\n\treg_rel = (duk_size_t) DUK_TVAL_GET_NUMBER(tv);\n#endif\n\tDUK_ASSERT_DISABLE(reg_rel >= 0);  /* unsigned */\n\n\tidx = env->regbase + reg_rel;\n\ttv = env->thread->valstack + idx;\n\tDUK_ASSERT(tv >= env->thread->valstack && tv < env->thread->valstack_end);  /* XXX: more accurate? */\n\n\tout->value = tv;\n\tout->attrs = DUK_PROPDESC_FLAGS_W;  /* registers are mutable, non-deletable */\n\tout->env = (duk_hobject *) env;\n\tout->holder = NULL;\n\tout->has_this = 0;\n\treturn 1;\n}\n\n/* lookup name from current activation record's functions' registers */\nDUK_LOCAL\nduk_bool_t duk__getid_activation_regs(duk_hthread *thr,\n                                      duk_hstring *name,\n                                      duk_activation *act,\n                                      duk__id_lookup_result *out) {\n\tduk_tval *tv;\n\tduk_hobject *func;\n\tduk_hobject *varmap;\n\tduk_size_t reg_rel;\n\tduk_size_t idx;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(name != NULL);\n\tDUK_ASSERT(act != NULL);\n\tDUK_ASSERT(out != NULL);\n\n\tfunc = DUK_ACT_GET_FUNC(act);\n\tDUK_ASSERT(func != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_HAS_NEWENV(func));\n\n\tif (!DUK_HOBJECT_IS_COMPFUNC(func)) {\n\t\treturn 0;\n\t}\n\n\t/* XXX: move varmap to duk_hcompfunc struct field. */\n\ttv = duk_hobject_find_existing_entry_tval_ptr(thr->heap, func, DUK_HTHREAD_STRING_INT_VARMAP(thr));\n\tif (!tv) {\n\t\treturn 0;\n\t}\n\tDUK_ASSERT(DUK_TVAL_IS_OBJECT(tv));\n\tvarmap = DUK_TVAL_GET_OBJECT(tv);\n\tDUK_ASSERT(varmap != NULL);\n\n\ttv = duk_hobject_find_existing_entry_tval_ptr(thr->heap, varmap, name);\n\tif (!tv) {\n\t\treturn 0;\n\t}\n\tDUK_ASSERT(DUK_TVAL_IS_NUMBER(tv));\n\treg_rel = (duk_size_t) DUK_TVAL_GET_NUMBER(tv);\n\tDUK_ASSERT_DISABLE(reg_rel >= 0);\n\tDUK_ASSERT(reg_rel < ((duk_hcompfunc *) func)->nregs);\n\n\tidx = act->idx_bottom + reg_rel;\n\tDUK_ASSERT(idx >= act->idx_bottom);\n\ttv = thr->valstack + idx;\n\n\tout->value = tv;\n\tout->attrs = DUK_PROPDESC_FLAGS_W;  /* registers are mutable, non-deletable */\n\tout->env = NULL;\n\tout->holder = NULL;\n\tout->has_this = 0;\n\treturn 1;\n}\n\nDUK_LOCAL\nduk_bool_t duk__get_identifier_reference(duk_hthread *thr,\n                                         duk_hobject *env,\n                                         duk_hstring *name,\n                                         duk_activation *act,\n                                         duk_bool_t parents,\n                                         duk__id_lookup_result *out) {\n\tduk_tval *tv;\n\tduk_tval tv_name;\n\tduk_uint_t sanity;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(env != NULL || act != NULL);\n\tDUK_ASSERT(name != NULL);\n\tDUK_ASSERT(out != NULL);\n\n\tDUK_ASSERT(!env || DUK_HOBJECT_IS_ENV(env));\n\tDUK_ASSERT(!env || !DUK_HOBJECT_HAS_ARRAY_PART(env));\n\n\t/*\n\t *  Conceptually, we look for the identifier binding by starting from\n\t *  'env' and following to chain of environment records (represented\n\t *  by the prototype chain).\n\t *\n\t *  If 'env' is NULL, the current activation does not yet have an\n\t *  allocated declarative environment record; this should be treated\n\t *  exactly as if the environment record existed but had no bindings\n\t *  other than register bindings.\n\t *\n\t *  Note: we assume that with the DUK_HOBJECT_FLAG_NEWENV cleared\n\t *  the environment will always be initialized immediately; hence\n\t *  a NULL 'env' should only happen with the flag set.  This is the\n\t *  case for: (1) function calls, and (2) strict, direct eval calls.\n\t */\n\n\tif (env == NULL && act != NULL) {\n\t\tduk_hobject *func;\n\t\tduk_hcompfunc *f;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"duk__get_identifier_reference: env is NULL, activation is non-NULL -> \"\n\t\t                     \"delayed env case, look up activation regs first\"));\n\n\t\t/*\n\t\t *  Try registers\n\t\t */\n\n\t\tif (duk__getid_activation_regs(thr, name, act, out)) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"duk__get_identifier_reference successful: \"\n\t\t\t                     \"name=%!O -> value=%!T, attrs=%ld, has_this=%ld, env=%!O, holder=%!O \"\n\t\t\t                     \"(found from register bindings when env=NULL)\",\n\t\t\t                     (duk_heaphdr *) name, (duk_tval *) out->value,\n\t\t\t                     (long) out->attrs, (long) out->has_this,\n\t\t\t                     (duk_heaphdr *) out->env, (duk_heaphdr *) out->holder));\n\t\t\treturn 1;\n\t\t}\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"not found in current activation regs\"));\n\n\t\t/*\n\t\t *  Not found in registers, proceed to the parent record.\n\t\t *  Here we need to determine what the parent would be,\n\t\t *  if 'env' was not NULL (i.e. same logic as when initializing\n\t\t *  the record).\n\t\t *\n\t\t *  Note that environment initialization is only deferred when\n\t\t *  DUK_HOBJECT_HAS_NEWENV is set, and this only happens for:\n\t\t *    - Function code\n\t\t *    - Strict eval code\n\t\t *\n\t\t *  We only need to check _Lexenv here; _Varenv exists only if it\n\t\t *  differs from _Lexenv (and thus _Lexenv will also be present).\n\t\t */\n\n\t\tif (!parents) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"duk__get_identifier_reference failed, no parent traversal \"\n\t\t\t                     \"(not found from register bindings when env=NULL)\"));\n\t\t\tgoto fail_not_found;\n\t\t}\n\n\t\tfunc = DUK_ACT_GET_FUNC(act);\n\t\tDUK_ASSERT(func != NULL);\n\t\tDUK_ASSERT(DUK_HOBJECT_HAS_NEWENV(func));\n\t\tf = (duk_hcompfunc *) func;\n\n\t\tenv = DUK_HCOMPFUNC_GET_LEXENV(thr->heap, f);\n\t\tif (!env) {\n\t\t\tenv = thr->builtins[DUK_BIDX_GLOBAL_ENV];\n\t\t}\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"continue lookup from env: %!iO\",\n\t\t                     (duk_heaphdr *) env));\n\t}\n\n\t/*\n\t *  Prototype walking starting from 'env'.\n\t *\n\t *  ('act' is not needed anywhere here.)\n\t */\n\n\tsanity = DUK_HOBJECT_PROTOTYPE_CHAIN_SANITY;\n\twhile (env != NULL) {\n\t\tduk_small_int_t cl;\n\t\tduk_int_t attrs;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"duk__get_identifier_reference, name=%!O, considering env=%p -> %!iO\",\n\t\t                     (duk_heaphdr *) name,\n\t\t                     (void *) env,\n\t\t                     (duk_heaphdr *) env));\n\n\t\tDUK_ASSERT(env != NULL);\n\t\tDUK_ASSERT(DUK_HOBJECT_IS_ENV(env));\n\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_ARRAY_PART(env));\n\n\t\tcl = DUK_HOBJECT_GET_CLASS_NUMBER(env);\n\t\tDUK_ASSERT(cl == DUK_HOBJECT_CLASS_OBJENV || cl == DUK_HOBJECT_CLASS_DECENV);\n\t\tif (cl == DUK_HOBJECT_CLASS_DECENV) {\n\t\t\t/*\n\t\t\t *  Declarative environment record.\n\t\t\t *\n\t\t\t *  Identifiers can never be stored in ancestors and are\n\t\t\t *  always plain values, so we can use an internal helper\n\t\t\t *  and access the value directly with an duk_tval ptr.\n\t\t\t *\n\t\t\t *  A closed environment is only indicated by it missing\n\t\t\t *  the \"book-keeping\" properties required for accessing\n\t\t\t *  register-bound variables.\n\t\t\t */\n\n\t\t\tDUK_ASSERT_HDECENV_VALID((duk_hdecenv *) env);\n\t\t\tif (duk__getid_open_decl_env_regs(thr, name, (duk_hdecenv *) env, out)) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"duk__get_identifier_reference successful: \"\n\t\t\t\t                     \"name=%!O -> value=%!T, attrs=%ld, has_this=%ld, env=%!O, holder=%!O \"\n\t\t\t\t                     \"(declarative environment record, scope open, found in regs)\",\n\t\t\t\t                     (duk_heaphdr *) name, (duk_tval *) out->value,\n\t\t\t\t                     (long) out->attrs, (long) out->has_this,\n\t\t\t\t                     (duk_heaphdr *) out->env, (duk_heaphdr *) out->holder));\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\ttv = duk_hobject_find_existing_entry_tval_ptr_and_attrs(thr->heap, env, name, &attrs);\n\t\t\tif (tv) {\n\t\t\t\tout->value = tv;\n\t\t\t\tout->attrs = attrs;\n\t\t\t\tout->env = env;\n\t\t\t\tout->holder = env;\n\t\t\t\tout->has_this = 0;\n\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"duk__get_identifier_reference successful: \"\n\t\t\t\t                     \"name=%!O -> value=%!T, attrs=%ld, has_this=%ld, env=%!O, holder=%!O \"\n\t\t\t\t                     \"(declarative environment record, found in properties)\",\n\t\t\t\t                     (duk_heaphdr *) name, (duk_tval *) out->value,\n\t\t\t\t                     (long) out->attrs, (long) out->has_this,\n\t\t\t\t                     (duk_heaphdr *) out->env, (duk_heaphdr *) out->holder));\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t} else {\n\t\t\t/*\n\t\t\t *  Object environment record.\n\t\t\t *\n\t\t\t *  Binding (target) object is an external, uncontrolled object.\n\t\t\t *  Identifier may be bound in an ancestor property, and may be\n\t\t\t *  an accessor.  Target can also be a Proxy which we must support\n\t\t\t *  here.\n\t\t\t */\n\n\t\t\t/* XXX: we could save space by using _Target OR _This.  If _Target, assume\n\t\t\t * this binding is undefined.  If _This, assumes this binding is _This, and\n\t\t\t * target is also _This.  One property would then be enough.\n\t\t\t */\n\n\t\t\tduk_hobject *target;\n\t\t\tduk_bool_t found;\n\n\t\t\tDUK_ASSERT(cl == DUK_HOBJECT_CLASS_OBJENV);\n\t\t\tDUK_ASSERT_HOBJENV_VALID((duk_hobjenv *) env);\n\n\t\t\ttarget = ((duk_hobjenv *) env)->target;\n\t\t\tDUK_ASSERT(target != NULL);\n\n\t\t\t/* Target may be a Proxy or property may be an accessor, so we must\n\t\t\t * use an actual, Proxy-aware hasprop check here.\n\t\t\t *\n\t\t\t * out->holder is NOT set to the actual duk_hobject where the\n\t\t\t * property is found, but rather the object binding target object.\n\t\t\t */\n\n\t\t\tif (DUK_HOBJECT_HAS_EXOTIC_PROXYOBJ(target)) {\n\t\t\t\tduk_tval tv_target_tmp;\n\n\t\t\t\tDUK_ASSERT(name != NULL);\n\t\t\t\tDUK_TVAL_SET_STRING(&tv_name, name);\n\t\t\t\tDUK_TVAL_SET_OBJECT(&tv_target_tmp, target);\n\n\t\t\t\tfound = duk_hobject_hasprop(thr, &tv_target_tmp, &tv_name);\n\t\t\t} else {\n\t\t\t\t/* XXX: duk_hobject_hasprop() would be correct for\n\t\t\t\t * non-Proxy objects too, but it is about ~20-25%\n\t\t\t\t * slower at present so separate code paths for\n\t\t\t\t * Proxy and non-Proxy now.\n\t\t\t\t */\n\t\t\t\tfound = duk_hobject_hasprop_raw(thr, target, name);\n\t\t\t}\n\n\t\t\tif (found) {\n\t\t\t\tout->value = NULL;  /* can't get value, may be accessor */\n\t\t\t\tout->attrs = 0;     /* irrelevant when out->value == NULL */\n\t\t\t\tout->env = env;\n\t\t\t\tout->holder = target;\n\t\t\t\tout->has_this = ((duk_hobjenv *) env)->has_this;\n\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"duk__get_identifier_reference successful: \"\n\t\t\t\t                     \"name=%!O -> value=%!T, attrs=%ld, has_this=%ld, env=%!O, holder=%!O \"\n\t\t\t\t                     \"(object environment record)\",\n\t\t\t\t                     (duk_heaphdr *) name, (duk_tval *) out->value,\n\t\t\t\t                     (long) out->attrs, (long) out->has_this,\n\t\t\t\t                     (duk_heaphdr *) out->env, (duk_heaphdr *) out->holder));\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t}\n\n\t\tif (!parents) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"duk__get_identifier_reference failed, no parent traversal \"\n\t\t\t                     \"(not found from first traversed env)\"));\n\t\t\tgoto fail_not_found;\n\t\t}\n\n                if (DUK_UNLIKELY(sanity-- == 0)) {\n                        DUK_ERROR_RANGE(thr, DUK_STR_PROTOTYPE_CHAIN_LIMIT);\n                }\n\t\tenv = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, env);\n\t}\n\n\t/*\n\t *  Not found (even in global object)\n\t */\n\n fail_not_found:\n\treturn 0;\n}\n\n/*\n *  HASVAR: check identifier binding from a given environment record\n *  without traversing its parents.\n *\n *  This primitive is not exposed to user code as such, but is used\n *  internally for e.g. declaration binding instantiation.\n *\n *  See E5 Sections:\n *    10.2.1.1.1 HasBinding(N)\n *    10.2.1.2.1 HasBinding(N)\n *\n *  Note: strictness has no bearing on this check.  Hence we don't take\n *  a 'strict' parameter.\n */\n\n#if 0  /*unused*/\nDUK_INTERNAL\nduk_bool_t duk_js_hasvar_envrec(duk_hthread *thr,\n                                duk_hobject *env,\n                                duk_hstring *name) {\n\tduk__id_lookup_result ref;\n\tduk_bool_t parents;\n\n\tDUK_DDD(DUK_DDDPRINT(\"hasvar: thr=%p, env=%p, name=%!O \"\n\t                     \"(env -> %!dO)\",\n\t                     (void *) thr, (void *) env, (duk_heaphdr *) name,\n\t                     (duk_heaphdr *) env));\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(env != NULL);\n\tDUK_ASSERT(name != NULL);\n\n        DUK_ASSERT_REFCOUNT_NONZERO_HEAPHDR(env);\n        DUK_ASSERT_REFCOUNT_NONZERO_HEAPHDR(name);\n\n\tDUK_ASSERT(DUK_HOBJECT_IS_ENV(env));\n\tDUK_ASSERT(!DUK_HOBJECT_HAS_ARRAY_PART(env));\n\n\t/* lookup results is ignored */\n\tparents = 0;\n\treturn duk__get_identifier_reference(thr, env, name, NULL, parents, &ref);\n}\n#endif\n\n/*\n *  GETVAR\n *\n *  See E5 Sections:\n *    11.1.2 Identifier Reference\n *    10.3.1 Identifier Resolution\n *    11.13.1 Simple Assignment  [example of where the Reference is GetValue'd]\n *    8.7.1 GetValue (V)\n *    8.12.1 [[GetOwnProperty]] (P)\n *    8.12.2 [[GetProperty]] (P)\n *    8.12.3 [[Get]] (P)\n *\n *  If 'throw' is true, always leaves two values on top of stack: [val this].\n *\n *  If 'throw' is false, returns 0 if identifier cannot be resolved, and the\n *  stack will be unaffected in this case.  If identifier is resolved, returns\n *  1 and leaves [val this] on top of stack.\n *\n *  Note: the 'strict' flag of a reference returned by GetIdentifierReference\n *  is ignored by GetValue.  Hence we don't take a 'strict' parameter.\n *\n *  The 'throw' flag is needed for implementing 'typeof' for an unreferenced\n *  identifier.  An unreference identifier in other contexts generates a\n *  ReferenceError.\n */\n\nDUK_LOCAL\nduk_bool_t duk__getvar_helper(duk_hthread *thr,\n                              duk_hobject *env,\n                              duk_activation *act,\n                              duk_hstring *name,\n                              duk_bool_t throw_flag) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk__id_lookup_result ref;\n\tduk_tval tv_tmp_obj;\n\tduk_tval tv_tmp_key;\n\tduk_bool_t parents;\n\n\tDUK_DDD(DUK_DDDPRINT(\"getvar: thr=%p, env=%p, act=%p, name=%!O \"\n\t                     \"(env -> %!dO)\",\n\t                     (void *) thr, (void *) env, (void *) act,\n\t                     (duk_heaphdr *) name, (duk_heaphdr *) env));\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(name != NULL);\n\t/* env and act may be NULL */\n\n        DUK_ASSERT_REFCOUNT_NONZERO_HEAPHDR(env);\n        DUK_ASSERT_REFCOUNT_NONZERO_HEAPHDR(name);\n\n\tparents = 1;     /* follow parent chain */\n\tif (duk__get_identifier_reference(thr, env, name, act, parents, &ref)) {\n\t\tif (ref.value) {\n\t\t\tduk_push_tval(ctx, ref.value);\n\t\t\tduk_push_undefined(ctx);\n\t\t} else {\n\t\t\tDUK_ASSERT(ref.holder != NULL);\n\n\t\t\t/* ref.holder is safe across the getprop call (even\n\t\t\t * with side effects) because 'env' is reachable and\n\t\t\t * ref.holder is a direct heap pointer.\n\t\t\t */\n\n\t\t\tDUK_TVAL_SET_OBJECT(&tv_tmp_obj, ref.holder);\n\t\t\tDUK_TVAL_SET_STRING(&tv_tmp_key, name);\n\t\t\t(void) duk_hobject_getprop(thr, &tv_tmp_obj, &tv_tmp_key);  /* [value] */\n\n\t\t\tif (ref.has_this) {\n\t\t\t\tduk_push_hobject(ctx, ref.holder);\n\t\t\t} else {\n\t\t\t\tduk_push_undefined(ctx);\n\t\t\t}\n\n\t\t\t/* [value this] */\n\t\t}\n\n\t\treturn 1;\n\t} else {\n\t\tif (throw_flag) {\n\t\t\tDUK_ERROR_FMT1(thr, DUK_ERR_REFERENCE_ERROR,\n\t\t\t               \"identifier '%s' undefined\",\n\t\t\t               (const char *) DUK_HSTRING_GET_DATA(name));\n\t\t}\n\n\t\treturn 0;\n\t}\n}\n\nDUK_INTERNAL\nduk_bool_t duk_js_getvar_envrec(duk_hthread *thr,\n                                duk_hobject *env,\n                                duk_hstring *name,\n                                duk_bool_t throw_flag) {\n\treturn duk__getvar_helper(thr, env, NULL, name, throw_flag);\n}\n\nDUK_INTERNAL\nduk_bool_t duk_js_getvar_activation(duk_hthread *thr,\n                                    duk_activation *act,\n                                    duk_hstring *name,\n                                    duk_bool_t throw_flag) {\n\tDUK_ASSERT(act != NULL);\n\treturn duk__getvar_helper(thr, act->lex_env, act, name, throw_flag);\n}\n\n/*\n *  PUTVAR\n *\n *  See E5 Sections:\n *    11.1.2 Identifier Reference\n *    10.3.1 Identifier Resolution\n *    11.13.1 Simple Assignment  [example of where the Reference is PutValue'd]\n *    8.7.2 PutValue (V,W)  [see especially step 3.b, undefined -> automatic global in non-strict mode]\n *    8.12.4 [[CanPut]] (P)\n *    8.12.5 [[Put]] (P)\n *\n *  Note: may invalidate any valstack (or object) duk_tval pointers because\n *  putting a value may reallocate any object or any valstack.  Caller beware.\n */\n\nDUK_LOCAL\nvoid duk__putvar_helper(duk_hthread *thr,\n                        duk_hobject *env,\n                        duk_activation *act,\n                        duk_hstring *name,\n                        duk_tval *val,\n                        duk_bool_t strict) {\n\tduk__id_lookup_result ref;\n\tduk_tval tv_tmp_obj;\n\tduk_tval tv_tmp_key;\n\tduk_bool_t parents;\n\n\tDUK_DDD(DUK_DDDPRINT(\"putvar: thr=%p, env=%p, act=%p, name=%!O, val=%p, strict=%ld \"\n\t                     \"(env -> %!dO, val -> %!T)\",\n\t                     (void *) thr, (void *) env, (void *) act,\n\t                     (duk_heaphdr *) name, (void *) val, (long) strict,\n\t                     (duk_heaphdr *) env, (duk_tval *) val));\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(name != NULL);\n\tDUK_ASSERT(val != NULL);\n\t/* env and act may be NULL */\n\n        DUK_ASSERT_REFCOUNT_NONZERO_HEAPHDR(env);\n        DUK_ASSERT_REFCOUNT_NONZERO_HEAPHDR(name);\n\tDUK_ASSERT_REFCOUNT_NONZERO_TVAL(val);\n\n\t/*\n\t *  In strict mode E5 protects 'eval' and 'arguments' from being\n\t *  assigned to (or even declared anywhere).  Attempt to do so\n\t *  should result in a compile time SyntaxError.  See the internal\n\t *  design documentation for details.\n\t *\n\t *  Thus, we should never come here, run-time, for strict code,\n\t *  and name 'eval' or 'arguments'.\n\t */\n\n\tDUK_ASSERT(!strict ||\n\t           (name != DUK_HTHREAD_STRING_EVAL(thr) &&\n\t            name != DUK_HTHREAD_STRING_LC_ARGUMENTS(thr)));\n\n\t/*\n\t *  Lookup variable and update in-place if found.\n\t */\n\n\tparents = 1;     /* follow parent chain */\n\n\tif (duk__get_identifier_reference(thr, env, name, act, parents, &ref)) {\n\t\tif (ref.value && (ref.attrs & DUK_PROPDESC_FLAG_WRITABLE)) {\n\t\t\t/* Update duk_tval in-place if pointer provided and the\n\t\t\t * property is writable.  If the property is not writable\n\t\t\t * (immutable binding), use duk_hobject_putprop() which\n\t\t\t * will respect mutability.\n\t\t\t */\n\t\t\tduk_tval *tv_val;\n\n\t\t\ttv_val = ref.value;\n\t\t\tDUK_ASSERT(tv_val != NULL);\n\t\t\tDUK_TVAL_SET_TVAL_UPDREF(thr, tv_val, val);  /* side effects */\n\n\t\t\t/* ref.value invalidated here */\n\t\t} else {\n\t\t\tDUK_ASSERT(ref.holder != NULL);\n\n\t\t\tDUK_TVAL_SET_OBJECT(&tv_tmp_obj, ref.holder);\n\t\t\tDUK_TVAL_SET_STRING(&tv_tmp_key, name);\n\t\t\t(void) duk_hobject_putprop(thr, &tv_tmp_obj, &tv_tmp_key, val, strict);\n\n\t\t\t/* ref.value invalidated here */\n\t\t}\n\n\t\treturn;\n\t}\n\n\t/*\n\t *  Not found: write to global object (non-strict) or ReferenceError\n\t *  (strict); see E5 Section 8.7.2, step 3.\n\t */\n\n\tif (strict) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"identifier binding not found, strict => reference error\"));\n\t\tDUK_ERROR_FMT1(thr, DUK_ERR_REFERENCE_ERROR,\n\t\t               \"identifier '%s' undefined\",\n\t\t               (const char *) DUK_HSTRING_GET_DATA(name));\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"identifier binding not found, not strict => set to global\"));\n\n\tDUK_TVAL_SET_OBJECT(&tv_tmp_obj, thr->builtins[DUK_BIDX_GLOBAL]);\n\tDUK_TVAL_SET_STRING(&tv_tmp_key, name);\n\t(void) duk_hobject_putprop(thr, &tv_tmp_obj, &tv_tmp_key, val, 0);  /* 0 = no throw */\n\n\t/* NB: 'val' may be invalidated here because put_value may realloc valstack,\n\t * caller beware.\n\t */\n}\n\nDUK_INTERNAL\nvoid duk_js_putvar_envrec(duk_hthread *thr,\n                          duk_hobject *env,\n                          duk_hstring *name,\n                          duk_tval *val,\n                          duk_bool_t strict) {\n\tduk__putvar_helper(thr, env, NULL, name, val, strict);\n}\n\nDUK_INTERNAL\nvoid duk_js_putvar_activation(duk_hthread *thr,\n                              duk_activation *act,\n                              duk_hstring *name,\n                              duk_tval *val,\n                              duk_bool_t strict) {\n\tDUK_ASSERT(act != NULL);\n\tduk__putvar_helper(thr, act->lex_env, act, name, val, strict);\n}\n\n/*\n *  DELVAR\n *\n *  See E5 Sections:\n *    11.4.1 The delete operator\n *    10.2.1.1.5 DeleteBinding (N)  [declarative environment record]\n *    10.2.1.2.5 DeleteBinding (N)  [object environment record]\n *\n *  Variable bindings established inside eval() are deletable (configurable),\n *  other bindings are not, including variables declared in global level.\n *  Registers are always non-deletable, and the deletion of other bindings\n *  is controlled by the configurable flag.\n *\n *  For strict mode code, the 'delete' operator should fail with a compile\n *  time SyntaxError if applied to identifiers.  Hence, no strict mode\n *  run-time deletion of identifiers should ever happen.  This function\n *  should never be called from strict mode code!\n */\n\nDUK_LOCAL\nduk_bool_t duk__delvar_helper(duk_hthread *thr,\n                              duk_hobject *env,\n                              duk_activation *act,\n                              duk_hstring *name) {\n\tduk__id_lookup_result ref;\n\tduk_bool_t parents;\n\n\tDUK_DDD(DUK_DDDPRINT(\"delvar: thr=%p, env=%p, act=%p, name=%!O \"\n\t                     \"(env -> %!dO)\",\n\t                     (void *) thr, (void *) env, (void *) act,\n\t                     (duk_heaphdr *) name, (duk_heaphdr *) env));\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(name != NULL);\n\t/* env and act may be NULL */\n\n        DUK_ASSERT_REFCOUNT_NONZERO_HEAPHDR(name);\n\n\tparents = 1;     /* follow parent chain */\n\n\tif (duk__get_identifier_reference(thr, env, name, act, parents, &ref)) {\n\t\tif (ref.value && !(ref.attrs & DUK_PROPDESC_FLAG_CONFIGURABLE)) {\n\t\t\t/* Identifier found in registers (always non-deletable)\n\t\t\t * or declarative environment record and non-configurable.\n\t\t\t */\n\t\t\treturn 0;\n\t\t}\n\t\tDUK_ASSERT(ref.holder != NULL);\n\n\t\treturn duk_hobject_delprop_raw(thr, ref.holder, name, 0);\n\t}\n\n\t/*\n\t *  Not found (even in global object).\n\t *\n\t *  In non-strict mode this is a silent SUCCESS (!), see E5 Section 11.4.1,\n\t *  step 3.b.  In strict mode this case is a compile time SyntaxError so\n\t *  we should not come here.\n\t */\n\n\tDUK_DDD(DUK_DDDPRINT(\"identifier to be deleted not found: name=%!O \"\n\t                     \"(treated as silent success)\",\n\t                     (duk_heaphdr *) name));\n\treturn 1;\n}\n\n#if 0  /*unused*/\nDUK_INTERNAL\nduk_bool_t duk_js_delvar_envrec(duk_hthread *thr,\n                                duk_hobject *env,\n                                duk_hstring *name) {\n\treturn duk__delvar_helper(thr, env, NULL, name);\n}\n#endif\n\nDUK_INTERNAL\nduk_bool_t duk_js_delvar_activation(duk_hthread *thr,\n                                    duk_activation *act,\n                                    duk_hstring *name) {\n\tDUK_ASSERT(act != NULL);\n\treturn duk__delvar_helper(thr, act->lex_env, act, name);\n}\n\n/*\n *  DECLVAR\n *\n *  See E5 Sections:\n *    10.4.3 Entering Function Code\n *    10.5 Declaration Binding Instantion\n *    12.2 Variable Statement\n *    11.1.2 Identifier Reference\n *    10.3.1 Identifier Resolution\n *\n *  Variable declaration behavior is mainly discussed in Section 10.5,\n *  and is not discussed in the execution semantics (Sections 11-13).\n *\n *  Conceptually declarations happen when code (global, eval, function)\n *  is entered, before any user code is executed.  In practice, register-\n *  bound identifiers are 'declared' automatically (by virtue of being\n *  allocated to registers with the initial value 'undefined').  Other\n *  identifiers are declared in the function prologue with this primitive.\n *\n *  Since non-register bindings eventually back to an internal object's\n *  properties, the 'prop_flags' argument is used to specify binding\n *  type:\n *\n *    - Immutable binding: set DUK_PROPDESC_FLAG_WRITABLE to false\n *    - Non-deletable binding: set DUK_PROPDESC_FLAG_CONFIGURABLE to false\n *    - The flag DUK_PROPDESC_FLAG_ENUMERABLE should be set, although it\n *      doesn't really matter for internal objects\n *\n *  All bindings are non-deletable mutable bindings except:\n *\n *    - Declarations in eval code (mutable, deletable)\n *    - 'arguments' binding in strict function code (immutable)\n *    - Function name binding of a function expression (immutable)\n *\n *  Declarations may go to declarative environment records (always\n *  so for functions), but may also go to object environment records\n *  (e.g. global code).  The global object environment has special\n *  behavior when re-declaring a function (but not a variable); see\n *  E5.1 specification, Section 10.5, step 5.e.\n *\n *  Declarations always go to the 'top-most' environment record, i.e.\n *  we never check the record chain.  It's not an error even if a\n *  property (even an immutable or non-deletable one) of the same name\n *  already exists.\n *\n *  If a declared variable already exists, its value needs to be updated\n *  (if possible).  Returns 1 if a PUTVAR needs to be done by the caller;\n *  otherwise returns 0.\n */\n\nDUK_LOCAL\nduk_bool_t duk__declvar_helper(duk_hthread *thr,\n                               duk_hobject *env,\n                               duk_hstring *name,\n                               duk_tval *val,\n                               duk_small_int_t prop_flags,\n                               duk_bool_t is_func_decl) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hobject *holder;\n\tduk_bool_t parents;\n\tduk__id_lookup_result ref;\n\tduk_tval *tv;\n\n\tDUK_DDD(DUK_DDDPRINT(\"declvar: thr=%p, env=%p, name=%!O, val=%!T, prop_flags=0x%08lx, is_func_decl=%ld \"\n\t                     \"(env -> %!iO)\",\n\t                     (void *) thr, (void *) env, (duk_heaphdr *) name,\n\t                     (duk_tval *) val, (unsigned long) prop_flags,\n\t                     (unsigned int) is_func_decl, (duk_heaphdr *) env));\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(env != NULL);\n\tDUK_ASSERT(name != NULL);\n\tDUK_ASSERT(val != NULL);\n\n\t/* Note: in strict mode the compiler should reject explicit\n\t * declaration of 'eval' or 'arguments'.  However, internal\n\t * bytecode may declare 'arguments' in the function prologue.\n\t * We don't bother checking (or asserting) for these now.\n\t */\n\n\t/* Note: val is a stable duk_tval pointer.  The caller makes\n\t * a value copy into its stack frame, so 'tv_val' is not subject\n\t * to side effects here.\n\t */\n\n\t/*\n\t *  Check whether already declared.\n\t *\n\t *  We need to check whether the binding exists in the environment\n\t *  without walking its parents.  However, we still need to check\n\t *  register-bound identifiers and the prototype chain of an object\n\t *  environment target object.\n\t */\n\n\tparents = 0;  /* just check 'env' */\n\tif (duk__get_identifier_reference(thr, env, name, NULL, parents, &ref)) {\n\t\tduk_int_t e_idx;\n\t\tduk_int_t h_idx;\n\t\tduk_small_int_t flags;\n\n\t\t/*\n\t\t *  Variable already declared, ignore re-declaration.\n\t\t *  The only exception is the updated behavior of E5.1 for\n\t\t *  global function declarations, E5.1 Section 10.5, step 5.e.\n\t\t *  This behavior does not apply to global variable declarations.\n\t\t */\n\n\t\tif (!(is_func_decl && env == thr->builtins[DUK_BIDX_GLOBAL_ENV])) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"re-declare a binding, ignoring\"));\n\t\t\treturn 1;  /* 1 -> needs a PUTVAR */\n\t\t}\n\n\t\t/*\n\t\t *  Special behavior in E5.1.\n\t\t *\n\t\t *  Note that even though parents == 0, the conflicting property\n\t\t *  may be an inherited property (currently our global object's\n\t\t *  prototype is Object.prototype).  Step 5.e first operates on\n\t\t *  the existing property (which is potentially in an ancestor)\n\t\t *  and then defines a new property in the global object (and\n\t\t *  never modifies the ancestor).\n\t\t *\n\t\t *  Also note that this logic would become even more complicated\n\t\t *  if the conflicting property might be a virtual one.  Object\n\t\t *  prototype has no virtual properties, though.\n\t\t *\n\t\t *  XXX: this is now very awkward, rework.\n\t\t */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"re-declare a function binding in global object, \"\n\t\t                     \"updated E5.1 processing\"));\n\n\t\tDUK_ASSERT(ref.holder != NULL);\n\t\tholder = ref.holder;\n\n\t\t/* holder will be set to the target object, not the actual object\n\t\t * where the property was found (see duk__get_identifier_reference()).\n\t\t */\n\t\tDUK_ASSERT(DUK_HOBJECT_GET_CLASS_NUMBER(holder) == DUK_HOBJECT_CLASS_GLOBAL);\n\t\tDUK_ASSERT(!DUK_HOBJECT_HAS_EXOTIC_ARRAY(holder));  /* global object doesn't have array part */\n\n\t\t/* XXX: use a helper for prototype traversal; no loop check here */\n\t\t/* must be found: was found earlier, and cannot be inherited */\n\t\tfor (;;) {\n\t\t\tDUK_ASSERT(holder != NULL);\n\t\t\tduk_hobject_find_existing_entry(thr->heap, holder, name, &e_idx, &h_idx);\n\t\t\tif (e_idx >= 0) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t/* SCANBUILD: NULL pointer dereference, doesn't actually trigger,\n\t\t\t * asserted above.\n\t\t\t */\n\t\t\tholder = DUK_HOBJECT_GET_PROTOTYPE(thr->heap, holder);\n\t\t}\n\t\tDUK_ASSERT(holder != NULL);\n\t\tDUK_ASSERT(e_idx >= 0);\n\t\t/* SCANBUILD: scan-build produces a NULL pointer dereference warning\n\t\t * below; it never actually triggers because holder is actually never\n\t\t * NULL.\n\t\t */\n\n\t\t/* ref.holder is global object, holder is the object with the\n\t\t * conflicting property.\n\t\t */\n\n\t\tflags = DUK_HOBJECT_E_GET_FLAGS(thr->heap, holder, e_idx);\n\t\tif (!(flags & DUK_PROPDESC_FLAG_CONFIGURABLE)) {\n\t\t\tif (flags & DUK_PROPDESC_FLAG_ACCESSOR) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"existing property is a non-configurable \"\n\t\t\t\t                     \"accessor -> reject\"));\n\t\t\t\tgoto fail_existing_attributes;\n\t\t\t}\n\t\t\tif (!((flags & DUK_PROPDESC_FLAG_WRITABLE) &&\n\t\t\t      (flags & DUK_PROPDESC_FLAG_ENUMERABLE))) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"existing property is a non-configurable \"\n\t\t\t\t                     \"plain property which is not writable and \"\n\t\t\t\t                     \"enumerable -> reject\"));\n\t\t\t\tgoto fail_existing_attributes;\n\t\t\t}\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"existing property is not configurable but \"\n\t\t\t                     \"is plain, enumerable, and writable -> \"\n\t\t\t                     \"allow redeclaration\"));\n\t\t}\n\n\t\tif (holder == ref.holder) {\n\t\t\t/* XXX: if duk_hobject_define_property_internal() was updated\n\t\t\t * to handle a pre-existing accessor property, this would be\n\t\t\t * a simple call (like for the ancestor case).\n\t\t\t */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"redefine, offending property in global object itself\"));\n\n\t\t\tif (flags & DUK_PROPDESC_FLAG_ACCESSOR) {\n\t\t\t\tduk_hobject *tmp;\n\n\t\t\t\ttmp = DUK_HOBJECT_E_GET_VALUE_GETTER(thr->heap, holder, e_idx);\n\t\t\t\tDUK_HOBJECT_E_SET_VALUE_GETTER(thr->heap, holder, e_idx, NULL);\n\t\t\t\tDUK_HOBJECT_DECREF_ALLOWNULL(thr, tmp);\n\t\t\t\tDUK_UNREF(tmp);\n\t\t\t\ttmp = DUK_HOBJECT_E_GET_VALUE_SETTER(thr->heap, holder, e_idx);\n\t\t\t\tDUK_HOBJECT_E_SET_VALUE_SETTER(thr->heap, holder, e_idx, NULL);\n\t\t\t\tDUK_HOBJECT_DECREF_ALLOWNULL(thr, tmp);\n\t\t\t\tDUK_UNREF(tmp);\n\t\t\t} else {\n\t\t\t\ttv = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, holder, e_idx);\n\t\t\t\tDUK_TVAL_SET_UNDEFINED_UPDREF(thr, tv);\n\t\t\t}\n\n\t\t\t/* Here val would be potentially invalid if we didn't make\n\t\t\t * a value copy at the caller.\n\t\t\t */\n\n\t\t\ttv = DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, holder, e_idx);\n\t\t\tDUK_TVAL_SET_TVAL(tv, val);\n\t\t\tDUK_TVAL_INCREF(thr, tv);\n\t\t\tDUK_HOBJECT_E_SET_FLAGS(thr->heap, holder, e_idx, prop_flags);\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"updated global binding, final result: \"\n\t\t\t                     \"value -> %!T, prop_flags=0x%08lx\",\n\t\t\t                     (duk_tval *) DUK_HOBJECT_E_GET_VALUE_TVAL_PTR(thr->heap, holder, e_idx),\n\t\t\t                     (unsigned long) prop_flags));\n\t\t} else {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"redefine, offending property in ancestor\"));\n\n\t\t\tDUK_ASSERT(ref.holder == thr->builtins[DUK_BIDX_GLOBAL]);\n\t\t\tduk_push_tval(ctx, val);\n\t\t\tduk_hobject_define_property_internal(thr, ref.holder, name, prop_flags);\n\t\t}\n\n\t\treturn 0;\n\t}\n\n\t/*\n\t *  Not found (in registers or record objects).  Declare\n\t *  to current variable environment.\n\t */\n\n\t/*\n\t *  Get holder object\n\t */\n\n\tif (DUK_HOBJECT_IS_DECENV(env)) {\n\t\tDUK_ASSERT_HDECENV_VALID((duk_hdecenv *) env);\n\t\tholder = env;\n\t} else {\n\t\tDUK_ASSERT_HOBJENV_VALID((duk_hobjenv *) env);\n\t\tholder = ((duk_hobjenv *) env)->target;\n\t\tDUK_ASSERT(holder != NULL);\n\t}\n\n\t/*\n\t *  Define new property\n\t *\n\t *  Note: this may fail if the holder is not extensible.\n\t */\n\n\t/* XXX: this is awkward as we use an internal method which doesn't handle\n\t * extensibility etc correctly.  Basically we'd want to do a [[DefineOwnProperty]]\n\t * or Object.defineProperty() here.\n\t */\n\n\tif (!DUK_HOBJECT_HAS_EXTENSIBLE(holder)) {\n\t\tgoto fail_not_extensible;\n\t}\n\n\tduk_push_hobject(ctx, holder);\n\tduk_push_hstring(ctx, name);\n\tduk_push_tval(ctx, val);\n\tduk_xdef_prop(ctx, -3, prop_flags);  /* [holder name val] -> [holder] */\n\tduk_pop(ctx);\n\n\treturn 0;\n\n fail_existing_attributes:\n fail_not_extensible:\n\tDUK_ERROR_TYPE(thr, \"declaration failed\");\n\treturn 0;\n}\n\nDUK_INTERNAL\nduk_bool_t duk_js_declvar_activation(duk_hthread *thr,\n                                     duk_activation *act,\n                                     duk_hstring *name,\n                                     duk_tval *val,\n                                     duk_small_int_t prop_flags,\n                                     duk_bool_t is_func_decl) {\n\tduk_hobject *env;\n\tduk_tval tv_val_copy;\n\tduk_size_t act_off;\n\n\tDUK_ASSERT(act != NULL);\n\tact_off = (duk_size_t) ((duk_uint8_t *) act - (duk_uint8_t *) thr->callstack);\n\n\t/*\n\t *  Make a value copy of the input val.  This ensures that\n\t *  side effects cannot invalidate the pointer.\n\t */\n\n\tDUK_TVAL_SET_TVAL(&tv_val_copy, val);\n\tval = &tv_val_copy;\n\n\t/*\n\t *  Delayed env creation check\n\t */\n\n\tif (!act->var_env) {\n\t\tDUK_ASSERT(act->lex_env == NULL);\n\t\tduk_js_init_activation_environment_records_delayed(thr, act);\n\t\tact = (duk_activation *) (void *) ((duk_uint8_t *) thr->callstack + act_off);\n\t}\n\tDUK_ASSERT(act->lex_env != NULL);\n\tDUK_ASSERT(act->var_env != NULL);\n\n\tenv = act->var_env;\n\tDUK_ASSERT(env != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_IS_ENV(env));\n\n\treturn duk__declvar_helper(thr, env, name, val, prop_flags, is_func_decl);\n}\n/*\n *  Lexer for source files, ToNumber() string conversions, RegExp expressions,\n *  and JSON.\n *\n *  Provides a stream of Ecmascript tokens from an UTF-8/CESU-8 buffer.  The\n *  caller can also rewind the token stream into a certain position which is\n *  needed by the compiler part for multi-pass scanning.  Tokens are\n *  represented as duk_token structures, and contain line number information.\n *  Token types are identified with DUK_TOK_* defines.\n *\n *  Characters are decoded into a fixed size lookup window consisting of\n *  decoded Unicode code points, with window positions past the end of the\n *  input filled with an invalid codepoint (-1).  The tokenizer can thus\n *  perform multiple character lookups efficiently and with few sanity\n *  checks (such as access outside the end of the input), which keeps the\n *  tokenization code small at the cost of performance.\n *\n *  Character data in tokens, such as identifier names and string literals,\n *  is encoded into CESU-8 format on-the-fly while parsing the token in\n *  question.  The string data is made reachable to garbage collection by\n *  placing the token-related values in value stack entries allocated for\n *  this purpose by the caller.  The characters exist in Unicode code point\n *  form only in the fixed size lookup window, which keeps character data\n *  expansion (of especially ASCII data) low.\n *\n *  Token parsing supports the full range of Unicode characters as described\n *  in the E5 specification.  Parsing has been optimized for ASCII characters\n *  because ordinary Ecmascript code consists almost entirely of ASCII\n *  characters.  Matching of complex Unicode codepoint sets (such as in the\n *  IdentifierStart and IdentifierPart productions) is optimized for size,\n *  and is done using a linear scan of a bit-packed list of ranges.  This is\n *  very slow, but should never be entered unless the source code actually\n *  contains Unicode characters.\n *\n *  Ecmascript tokenization is partially context sensitive.  First,\n *  additional future reserved words are recognized in strict mode (see E5\n *  Section 7.6.1.2).  Second, a forward slash character ('/') can be\n *  recognized either as starting a RegExp literal or as a division operator,\n *  depending on context.  The caller must provide necessary context flags\n *  when requesting a new token.\n *\n *  Future work:\n *\n *    * Make line number tracking optional, as it consumes space.\n *\n *    * Add a feature flag for disabling UTF-8 decoding of input, as most\n *      source code is ASCII.  Because of Unicode escapes written in ASCII,\n *      this does not allow Unicode support to be removed from e.g.\n *      duk_unicode_is_identifier_start() nor does it allow removal of CESU-8\n *      encoding of e.g. string literals.\n *\n *    * Add a feature flag for disabling Unicode compliance of e.g. identifier\n *      names.  This allows for a build more than a kilobyte smaller, because\n *      Unicode ranges needed by duk_unicode_is_identifier_start() and\n *      duk_unicode_is_identifier_part() can be dropped.  String literals\n *      should still be allowed to contain escaped Unicode, so this still does\n *      not allow removal of CESU-8 encoding of e.g. string literals.\n *\n *    * Character lookup tables for codepoints above BMP could be stripped.\n *\n *    * Strictly speaking, E5 specification requires that source code consists\n *      of 16-bit code units, and if not, must be conceptually converted to\n *      that format first.  The current lexer processes Unicode code points\n *      and allows characters outside the BMP.  These should be converted to\n *      surrogate pairs while reading the source characters into the window,\n *      not after tokens have been formed (as is done now).  However, the fix\n *      is not trivial because two characters are decoded from one codepoint.\n *\n *    * Optimize for speed as well as size.  Large if-else ladders are (at\n *      least potentially) slow.\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Various defines and file specific helper macros\n */\n\n#define DUK__MAX_RE_DECESC_DIGITS     9\n#define DUK__MAX_RE_QUANT_DIGITS      9   /* Does not allow e.g. 2**31-1, but one more would allow overflows of u32. */\n\n/* whether to use macros or helper function depends on call count */\n#define DUK__ISDIGIT(x)          ((x) >= DUK_ASC_0 && (x) <= DUK_ASC_9)\n#define DUK__ISHEXDIGIT(x)       duk__is_hex_digit((x))\n#define DUK__ISOCTDIGIT(x)       ((x) >= DUK_ASC_0 && (x) <= DUK_ASC_7)\n#define DUK__ISDIGIT03(x)        ((x) >= DUK_ASC_0 && (x) <= DUK_ASC_3)\n#define DUK__ISDIGIT47(x)        ((x) >= DUK_ASC_4 && (x) <= DUK_ASC_7)\n\n/* lexer character window helpers */\n#define DUK__LOOKUP(lex_ctx,idx)            ((lex_ctx)->window[(idx)].codepoint)\n#define DUK__ADVANCECHARS(lex_ctx,count)    duk__advance_chars((lex_ctx), (count))\n#define DUK__ADVANCEBYTES(lex_ctx,count)    duk__advance_bytes((lex_ctx), (count))\n#define DUK__INITBUFFER(lex_ctx)            duk__initbuffer((lex_ctx))\n#define DUK__APPENDBUFFER(lex_ctx,x)        duk__appendbuffer((lex_ctx), (duk_codepoint_t) (x))\n#define DUK__APPENDBUFFER_ASCII(lex_ctx,x)  duk__appendbuffer_ascii((lex_ctx), (duk_codepoint_t) (x))\n\n/* lookup shorthands (note: assume context variable is named 'lex_ctx') */\n#define DUK__L0()  DUK__LOOKUP(lex_ctx, 0)\n#define DUK__L1()  DUK__LOOKUP(lex_ctx, 1)\n#define DUK__L2()  DUK__LOOKUP(lex_ctx, 2)\n#define DUK__L3()  DUK__LOOKUP(lex_ctx, 3)\n#define DUK__L4()  DUK__LOOKUP(lex_ctx, 4)\n#define DUK__L5()  DUK__LOOKUP(lex_ctx, 5)\n\n/* packed advance/token number macro used by multiple functions */\n#define DUK__ADVTOK(advbytes,tok)  ((((advbytes) * sizeof(duk_lexer_codepoint)) << 8) + (tok))\n\n/*\n *  Advance lookup window by N characters, filling in new characters as\n *  necessary.  After returning caller is guaranteed a character window of\n *  at least DUK_LEXER_WINDOW_SIZE characters.\n *\n *  The main function duk__advance_bytes() is called at least once per every\n *  token so it has a major lexer/compiler performance impact.  There are two\n *  variants for the main duk__advance_bytes() algorithm: a sliding window\n *  approach which is slightly faster at the cost of larger code footprint,\n *  and a simple copying one.\n *\n *  Decoding directly from the source string would be another lexing option.\n *  But the lookup window based approach has the advantage of hiding the\n *  source string and its encoding effectively which gives more flexibility\n *  going forward to e.g. support chunked streaming of source from flash.\n *\n *  Decodes UTF-8/CESU-8 leniently with support for code points from U+0000 to\n *  U+10FFFF, causing an error if the input is unparseable.  Leniency means:\n *\n *    * Unicode code point validation is intentionally not performed,\n *      except to check that the codepoint does not exceed 0x10ffff.\n *\n *    * In particular, surrogate pairs are allowed and not combined, which\n *      allows source files to represent all SourceCharacters with CESU-8.\n *      Broken surrogate pairs are allowed, as Ecmascript does not mandate\n *      their validation.\n *\n *    * Allow non-shortest UTF-8 encodings.\n *\n *  Leniency here causes few security concerns because all character data is\n *  decoded into Unicode codepoints before lexer processing, and is then\n *  re-encoded into CESU-8.  The source can be parsed as strict UTF-8 with\n *  a compiler option.  However, Ecmascript source characters include -all-\n *  16-bit unsigned integer codepoints, so leniency seems to be appropriate.\n *\n *  Note that codepoints above the BMP are not strictly SourceCharacters,\n *  but the lexer still accepts them as such.  Before ending up in a string\n *  or an identifier name, codepoints above BMP are converted into surrogate\n *  pairs and then CESU-8 encoded, resulting in 16-bit Unicode data as\n *  expected by Ecmascript.\n *\n *  An alternative approach to dealing with invalid or partial sequences\n *  would be to skip them and replace them with e.g. the Unicode replacement\n *  character U+FFFD.  This has limited utility because a replacement character\n *  will most likely cause a parse error, unless it occurs inside a string.\n *  Further, Ecmascript source is typically pure ASCII.\n *\n *  See:\n *\n *     http://en.wikipedia.org/wiki/UTF-8\n *     http://en.wikipedia.org/wiki/CESU-8\n *     http://tools.ietf.org/html/rfc3629\n *     http://en.wikipedia.org/wiki/UTF-8#Invalid_byte_sequences\n *\n *  Future work:\n *\n *    * Reject other invalid Unicode sequences (see Wikipedia entry for examples)\n *      in strict UTF-8 mode.\n *\n *    * Size optimize.  An attempt to use a 16-byte lookup table for the first\n *      byte resulted in a code increase though.\n *\n *    * Is checking against maximum 0x10ffff really useful?  4-byte encoding\n *      imposes a certain limit anyway.\n *\n *    * Support chunked streaming of source code.  Can be implemented either\n *      by streaming chunks of bytes or chunks of codepoints.\n */\n\n#if defined(DUK_USE_LEXER_SLIDING_WINDOW)\nDUK_LOCAL void duk__fill_lexer_buffer(duk_lexer_ctx *lex_ctx, duk_small_uint_t start_offset_bytes) {\n\tduk_lexer_codepoint *cp, *cp_end;\n\tduk_ucodepoint_t x;\n\tduk_small_uint_t contlen;\n\tconst duk_uint8_t *p, *p_end;\n#if defined(DUK_USE_STRICT_UTF8_SOURCE)\n\tduk_ucodepoint_t mincp;\n#endif\n\tduk_int_t input_line;\n\n\t/* Use temporaries and update lex_ctx only when finished. */\n\tinput_line = lex_ctx->input_line;\n\tp = lex_ctx->input + lex_ctx->input_offset;\n\tp_end = lex_ctx->input + lex_ctx->input_length;\n\n\tcp = (duk_lexer_codepoint *) (void *) ((duk_uint8_t *) lex_ctx->buffer + start_offset_bytes);\n\tcp_end = lex_ctx->buffer + DUK_LEXER_BUFFER_SIZE;\n\n\tfor (; cp != cp_end; cp++) {\n\t\tcp->offset = (duk_size_t) (p - lex_ctx->input);\n\t\tcp->line = input_line;\n\n\t\t/* XXX: potential issue with signed pointers, p_end < p. */\n\t\tif (DUK_UNLIKELY(p >= p_end)) {\n\t\t\t/* If input_offset were assigned a negative value, it would\n\t\t\t * result in a large positive value.  Most likely it would be\n\t\t\t * larger than input_length and be caught here.  In any case\n\t\t\t * no memory unsafe behavior would happen.\n\t\t\t */\n\t\t\tcp->codepoint = -1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tx = (duk_ucodepoint_t) (*p++);\n\n\t\t/* Fast path. */\n\n\t\tif (DUK_LIKELY(x < 0x80UL)) {\n\t\t\tDUK_ASSERT(x != 0x2028UL && x != 0x2029UL);  /* not LS/PS */\n\t\t\tif (DUK_UNLIKELY(x <= 0x000dUL)) {\n\t\t\t\tif ((x == 0x000aUL) ||\n\t\t\t\t    ((x == 0x000dUL) && (p >= p_end || *p != 0x000aUL))) {\n\t\t\t\t\t/* lookup for 0x000a above assumes shortest encoding now */\n\n\t\t\t\t\t/* E5 Section 7.3, treat the following as newlines:\n\t\t\t\t\t *   LF\n\t\t\t\t\t *   CR [not followed by LF]\n\t\t\t\t\t *   LS\n\t\t\t\t\t *   PS\n\t\t\t\t\t *\n\t\t\t\t\t * For CR LF, CR is ignored if it is followed by LF, and the LF will bump\n\t\t\t\t\t * the line number.\n\t\t\t\t\t */\n\t\t\t\t\tinput_line++;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcp->codepoint = (duk_codepoint_t) x;\n\t\t\tcontinue;\n\t\t}\n\n\t\t/* Slow path. */\n\n\t\tif (x < 0xc0UL) {\n\t\t\t/* 10xx xxxx -> invalid */\n\t\t\tgoto error_encoding;\n\t\t} else if (x < 0xe0UL) {\n\t\t\t/* 110x xxxx   10xx xxxx  */\n\t\t\tcontlen = 1;\n#if defined(DUK_USE_STRICT_UTF8_SOURCE)\n\t\t\tmincp = 0x80UL;\n#endif\n\t\t\tx = x & 0x1fUL;\n\t\t} else if (x < 0xf0UL) {\n\t\t\t/* 1110 xxxx   10xx xxxx   10xx xxxx */\n\t\t\tcontlen = 2;\n#if defined(DUK_USE_STRICT_UTF8_SOURCE)\n\t\t\tmincp = 0x800UL;\n#endif\n\t\t\tx = x & 0x0fUL;\n\t\t} else if (x < 0xf8UL) {\n\t\t\t/* 1111 0xxx   10xx xxxx   10xx xxxx   10xx xxxx */\n\t\t\tcontlen = 3;\n#if defined(DUK_USE_STRICT_UTF8_SOURCE)\n\t\t\tmincp = 0x10000UL;\n#endif\n\t\t\tx = x & 0x07UL;\n\t\t} else {\n\t\t\t/* no point in supporting encodings of 5 or more bytes */\n\t\t\tgoto error_encoding;\n\t\t}\n\n\t\tDUK_ASSERT(p_end >= p);\n\t\tif ((duk_size_t) contlen > (duk_size_t) (p_end - p)) {\n\t\t\tgoto error_clipped;\n\t\t}\n\n\t\twhile (contlen > 0) {\n\t\t\tduk_small_uint_t y;\n\t\t\ty = *p++;\n\t\t\tif ((y & 0xc0U) != 0x80U) {\n\t\t\t\t/* check that byte has the form 10xx xxxx */\n\t\t\t\tgoto error_encoding;\n\t\t\t}\n\t\t\tx = x << 6;\n\t\t\tx += y & 0x3fUL;\n\t\t\tcontlen--;\n\t\t}\n\n\t\t/* check final character validity */\n\n\t\tif (x > 0x10ffffUL) {\n\t\t\tgoto error_encoding;\n\t\t}\n#if defined(DUK_USE_STRICT_UTF8_SOURCE)\n\t\tif (x < mincp || (x >= 0xd800UL && x <= 0xdfffUL) || x == 0xfffeUL) {\n\t\t\tgoto error_encoding;\n\t\t}\n#endif\n\n\t\tDUK_ASSERT(x != 0x000aUL && x != 0x000dUL);\n\t\tif ((x == 0x2028UL) || (x == 0x2029UL)) {\n\t\t\tinput_line++;\n\t\t}\n\n\t\tcp->codepoint = (duk_codepoint_t) x;\n\t}\n\n\tlex_ctx->input_offset = (duk_size_t) (p - lex_ctx->input);\n\tlex_ctx->input_line = input_line;\n\treturn;\n\n error_clipped:   /* clipped codepoint */\n error_encoding:  /* invalid codepoint encoding or codepoint */\n\tlex_ctx->input_offset = (duk_size_t) (p - lex_ctx->input);\n\tlex_ctx->input_line = input_line;\n\n\tDUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_DECODE_FAILED);\n}\n\nDUK_LOCAL void duk__advance_bytes(duk_lexer_ctx *lex_ctx, duk_small_uint_t count_bytes) {\n\tduk_small_uint_t used_bytes, avail_bytes;\n\n\tDUK_ASSERT_DISABLE(count_bytes >= 0);  /* unsigned */\n\tDUK_ASSERT(count_bytes <= (duk_small_uint_t) (DUK_LEXER_WINDOW_SIZE * sizeof(duk_lexer_codepoint)));\n\tDUK_ASSERT(lex_ctx->window >= lex_ctx->buffer);\n\tDUK_ASSERT(lex_ctx->window < lex_ctx->buffer + DUK_LEXER_BUFFER_SIZE);\n\tDUK_ASSERT((duk_uint8_t *) lex_ctx->window + count_bytes <= (duk_uint8_t *) lex_ctx->buffer + DUK_LEXER_BUFFER_SIZE * sizeof(duk_lexer_codepoint));\n\n\t/* Zero 'count' is also allowed to make call sites easier.\n\t * Arithmetic in bytes generates better code in GCC.\n\t */\n\n\tlex_ctx->window = (duk_lexer_codepoint *) (void *) ((duk_uint8_t *) lex_ctx->window + count_bytes);  /* avoid multiply */\n\tused_bytes = (duk_small_uint_t) ((duk_uint8_t *) lex_ctx->window - (duk_uint8_t *) lex_ctx->buffer);\n\tavail_bytes = DUK_LEXER_BUFFER_SIZE * sizeof(duk_lexer_codepoint) - used_bytes;\n\tif (avail_bytes < (duk_small_uint_t) (DUK_LEXER_WINDOW_SIZE * sizeof(duk_lexer_codepoint))) {\n\t\t/* Not enough data to provide a full window, so \"scroll\" window to\n\t\t * start of buffer and fill up the rest.\n\t\t */\n\t\tDUK_MEMMOVE((void *) lex_ctx->buffer,\n\t\t            (const void *) lex_ctx->window,\n\t\t            (size_t) avail_bytes);\n\t\tlex_ctx->window = lex_ctx->buffer;\n\t\tduk__fill_lexer_buffer(lex_ctx, avail_bytes);\n\t}\n}\n\nDUK_LOCAL void duk__init_lexer_window(duk_lexer_ctx *lex_ctx) {\n\tlex_ctx->window = lex_ctx->buffer;\n\tduk__fill_lexer_buffer(lex_ctx, 0);\n}\n#else  /* DUK_USE_LEXER_SLIDING_WINDOW */\nDUK_LOCAL duk_codepoint_t duk__read_char(duk_lexer_ctx *lex_ctx) {\n\tduk_ucodepoint_t x;\n\tduk_small_uint_t len;\n\tduk_small_uint_t i;\n\tconst duk_uint8_t *p;\n#if defined(DUK_USE_STRICT_UTF8_SOURCE)\n\tduk_ucodepoint_t mincp;\n#endif\n\tduk_size_t input_offset;\n\n\tinput_offset = lex_ctx->input_offset;\n\tif (DUK_UNLIKELY(input_offset >= lex_ctx->input_length)) {\n\t\t/* If input_offset were assigned a negative value, it would\n\t\t * result in a large positive value.  Most likely it would be\n\t\t * larger than input_length and be caught here.  In any case\n\t\t * no memory unsafe behavior would happen.\n\t\t */\n\t\treturn -1;\n\t}\n\n\tp = lex_ctx->input + input_offset;\n\tx = (duk_ucodepoint_t) (*p);\n\n\tif (DUK_LIKELY(x < 0x80UL)) {\n\t\t/* 0xxx xxxx -> fast path */\n\n\t\t/* input offset tracking */\n\t\tlex_ctx->input_offset++;\n\n\t\tDUK_ASSERT(x != 0x2028UL && x != 0x2029UL);  /* not LS/PS */\n\t\tif (DUK_UNLIKELY(x <= 0x000dUL)) {\n\t\t\tif ((x == 0x000aUL) ||\n\t\t\t    ((x == 0x000dUL) && (lex_ctx->input_offset >= lex_ctx->input_length ||\n\t\t\t                         lex_ctx->input[lex_ctx->input_offset] != 0x000aUL))) {\n\t\t\t\t/* lookup for 0x000a above assumes shortest encoding now */\n\n\t\t\t\t/* E5 Section 7.3, treat the following as newlines:\n\t\t\t\t *   LF\n\t\t\t\t *   CR [not followed by LF]\n\t\t\t\t *   LS\n\t\t\t\t *   PS\n\t\t\t\t *\n\t\t\t\t * For CR LF, CR is ignored if it is followed by LF, and the LF will bump\n\t\t\t\t * the line number.\n\t\t\t\t */\n\t\t\t\tlex_ctx->input_line++;\n\t\t\t}\n\t\t}\n\n\t\treturn (duk_codepoint_t) x;\n\t}\n\n\t/* Slow path. */\n\n\tif (x < 0xc0UL) {\n\t\t/* 10xx xxxx -> invalid */\n\t\tgoto error_encoding;\n\t} else if (x < 0xe0UL) {\n\t\t/* 110x xxxx   10xx xxxx  */\n\t\tlen = 2;\n#if defined(DUK_USE_STRICT_UTF8_SOURCE)\n\t\tmincp = 0x80UL;\n#endif\n\t\tx = x & 0x1fUL;\n\t} else if (x < 0xf0UL) {\n\t\t/* 1110 xxxx   10xx xxxx   10xx xxxx */\n\t\tlen = 3;\n#if defined(DUK_USE_STRICT_UTF8_SOURCE)\n\t\tmincp = 0x800UL;\n#endif\n\t\tx = x & 0x0fUL;\n\t} else if (x < 0xf8UL) {\n\t\t/* 1111 0xxx   10xx xxxx   10xx xxxx   10xx xxxx */\n\t\tlen = 4;\n#if defined(DUK_USE_STRICT_UTF8_SOURCE)\n\t\tmincp = 0x10000UL;\n#endif\n\t\tx = x & 0x07UL;\n\t} else {\n\t\t/* no point in supporting encodings of 5 or more bytes */\n\t\tgoto error_encoding;\n\t}\n\n\tDUK_ASSERT(lex_ctx->input_length >= lex_ctx->input_offset);\n\tif ((duk_size_t) len > (duk_size_t) (lex_ctx->input_length - lex_ctx->input_offset)) {\n\t\tgoto error_clipped;\n\t}\n\n\tp++;\n\tfor (i = 1; i < len; i++) {\n\t\tduk_small_uint_t y;\n\t\ty = *p++;\n\t\tif ((y & 0xc0U) != 0x80U) {\n\t\t\t/* check that byte has the form 10xx xxxx */\n\t\t\tgoto error_encoding;\n\t\t}\n\t\tx = x << 6;\n\t\tx += y & 0x3fUL;\n\t}\n\n\t/* check final character validity */\n\n\tif (x > 0x10ffffUL) {\n\t\tgoto error_encoding;\n\t}\n#if defined(DUK_USE_STRICT_UTF8_SOURCE)\n\tif (x < mincp || (x >= 0xd800UL && x <= 0xdfffUL) || x == 0xfffeUL) {\n\t\tgoto error_encoding;\n\t}\n#endif\n\n\t/* input offset tracking */\n\tlex_ctx->input_offset += len;\n\n\t/* line tracking */\n\tDUK_ASSERT(x != 0x000aUL && x != 0x000dUL);\n\tif ((x == 0x2028UL) || (x == 0x2029UL)) {\n\t\tlex_ctx->input_line++;\n\t}\n\n\treturn (duk_codepoint_t) x;\n\n error_clipped:   /* clipped codepoint */\n error_encoding:  /* invalid codepoint encoding or codepoint */\n\tDUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_DECODE_FAILED);\n\treturn 0;\n}\n\nDUK_LOCAL void duk__advance_bytes(duk_lexer_ctx *lex_ctx, duk_small_uint_t count_bytes) {\n\tduk_small_uint_t keep_bytes;\n\tduk_lexer_codepoint *cp, *cp_end;\n\n\tDUK_ASSERT_DISABLE(count_bytes >= 0);  /* unsigned */\n\tDUK_ASSERT(count_bytes <= (duk_small_uint_t) (DUK_LEXER_WINDOW_SIZE * sizeof(duk_lexer_codepoint)));\n\n\t/* Zero 'count' is also allowed to make call sites easier. */\n\n\tkeep_bytes = DUK_LEXER_WINDOW_SIZE * sizeof(duk_lexer_codepoint) - count_bytes;\n\tDUK_MEMMOVE((void *) lex_ctx->window,\n\t            (const void *) ((duk_uint8_t *) lex_ctx->window + count_bytes),\n\t            (size_t) keep_bytes);\n\n\tcp = (duk_lexer_codepoint *) ((duk_uint8_t *) lex_ctx->window + keep_bytes);\n\tcp_end = lex_ctx->window + DUK_LEXER_WINDOW_SIZE;\n\tfor (; cp != cp_end; cp++) {\n\t\tcp->offset = lex_ctx->input_offset;\n\t\tcp->line = lex_ctx->input_line;\n\t\tcp->codepoint = duk__read_char(lex_ctx);\n\t}\n}\n\nDUK_LOCAL void duk__init_lexer_window(duk_lexer_ctx *lex_ctx) {\n\t/* Call with count == DUK_LEXER_WINDOW_SIZE to fill buffer initially. */\n\tduk__advance_bytes(lex_ctx, DUK_LEXER_WINDOW_SIZE * sizeof(duk_lexer_codepoint));  /* fill window */\n}\n#endif  /* DUK_USE_LEXER_SLIDING_WINDOW */\n\nDUK_LOCAL void duk__advance_chars(duk_lexer_ctx *lex_ctx, duk_small_uint_t count_chars) {\n\tduk__advance_bytes(lex_ctx, count_chars * sizeof(duk_lexer_codepoint));\n}\n\n/*\n *  (Re)initialize the temporary byte buffer.  May be called extra times\n *  with little impact.\n */\n\nDUK_LOCAL void duk__initbuffer(duk_lexer_ctx *lex_ctx) {\n\t/* Reuse buffer as is unless buffer has grown large. */\n\tif (DUK_HBUFFER_DYNAMIC_GET_SIZE(lex_ctx->buf) < DUK_LEXER_TEMP_BUF_LIMIT) {\n\t\t/* Keep current size */\n\t} else {\n\t\tduk_hbuffer_resize(lex_ctx->thr, lex_ctx->buf, DUK_LEXER_TEMP_BUF_LIMIT);\n\t}\n\n\tDUK_BW_INIT_WITHBUF(lex_ctx->thr, &lex_ctx->bw, lex_ctx->buf);\n}\n\n/*\n *  Append a Unicode codepoint to the temporary byte buffer.  Performs\n *  CESU-8 surrogate pair encoding for codepoints above the BMP.\n *  Existing surrogate pairs are allowed and also encoded into CESU-8.\n */\n\nDUK_LOCAL void duk__appendbuffer(duk_lexer_ctx *lex_ctx, duk_codepoint_t x) {\n\t/*\n\t *  Since character data is only generated by decoding the source or by\n\t *  the compiler itself, we rely on the input codepoints being correct\n\t *  and avoid a check here.\n\t *\n\t *  Character data can also come here through decoding of Unicode\n\t *  escapes (\"\\udead\\ubeef\") so all 16-but unsigned values can be\n\t *  present, even when the source file itself is strict UTF-8.\n\t */\n\tDUK_ASSERT(x >= 0 && x <= 0x10ffffL);\n\n\tDUK_BW_WRITE_ENSURE_CESU8(lex_ctx->thr, &lex_ctx->bw, (duk_ucodepoint_t) x);\n}\n\nDUK_LOCAL void duk__appendbuffer_ascii(duk_lexer_ctx *lex_ctx, duk_codepoint_t x) {\n\t/* ASCII characters can be emitted as a single byte without encoding\n\t * which matters for some fast paths.\n\t */\n\tDUK_ASSERT(x >= 0 && x <= 0x7f);\n\n\tDUK_BW_WRITE_ENSURE_U8(lex_ctx->thr, &lex_ctx->bw, (duk_uint8_t) x);\n}\n\n/*\n *  Intern the temporary byte buffer into a valstack slot\n *  (in practice, slot1 or slot2).\n */\n\nDUK_LOCAL duk_hstring *duk__internbuffer(duk_lexer_ctx *lex_ctx, duk_idx_t valstack_idx) {\n\tduk_context *ctx = (duk_context *) lex_ctx->thr;\n\n\tDUK_ASSERT(valstack_idx == lex_ctx->slot1_idx || valstack_idx == lex_ctx->slot2_idx);\n\n\tDUK_BW_PUSH_AS_STRING(lex_ctx->thr, &lex_ctx->bw);\n\tduk_replace(ctx, valstack_idx);\n\treturn duk_known_hstring(ctx, valstack_idx);\n}\n\n/*\n *  Init lexer context\n */\n\nDUK_INTERNAL void duk_lexer_initctx(duk_lexer_ctx *lex_ctx) {\n\tDUK_ASSERT(lex_ctx != NULL);\n\n\tDUK_MEMZERO(lex_ctx, sizeof(*lex_ctx));\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n#if defined(DUK_USE_LEXER_SLIDING_WINDOW)\n\tlex_ctx->window = NULL;\n#endif\n\tlex_ctx->thr = NULL;\n\tlex_ctx->input = NULL;\n\tlex_ctx->buf = NULL;\n#endif\n}\n\n/*\n *  Set lexer input position and reinitialize lookup window.\n */\n\nDUK_INTERNAL void duk_lexer_getpoint(duk_lexer_ctx *lex_ctx, duk_lexer_point *pt) {\n\tpt->offset = lex_ctx->window[0].offset;\n\tpt->line = lex_ctx->window[0].line;\n}\n\nDUK_INTERNAL void duk_lexer_setpoint(duk_lexer_ctx *lex_ctx, duk_lexer_point *pt) {\n\tDUK_ASSERT_DISABLE(pt->offset >= 0);  /* unsigned */\n\tDUK_ASSERT(pt->line >= 1);\n\tlex_ctx->input_offset = pt->offset;\n\tlex_ctx->input_line = pt->line;\n\tduk__init_lexer_window(lex_ctx);\n}\n\n/*\n *  Lexing helpers\n */\n\n/* Numeric value of a hex digit (also covers octal and decimal digits) or\n * -1 if not a valid hex digit.\n */\nDUK_LOCAL duk_codepoint_t duk__hexval_validate(duk_codepoint_t x) {\n\tduk_small_int_t t;\n\n\t/* Here 'x' is a Unicode codepoint */\n\tif (DUK_LIKELY(x >= 0 && x <= 0xff)) {\n\t\tt = duk_hex_dectab[x];\n\t\tif (DUK_LIKELY(t >= 0)) {\n\t\t\treturn t;\n\t\t}\n\t}\n\n\treturn -1;\n}\n\n/* Just a wrapper for call sites where 'x' is known to be valid so\n * we assert for it before decoding.\n */\nDUK_LOCAL duk_codepoint_t duk__hexval(duk_codepoint_t x) {\n\tduk_codepoint_t ret;\n\n\tDUK_ASSERT((x >= DUK_ASC_0 && x <= DUK_ASC_9) ||\n\t           (x >= DUK_ASC_LC_A && x <= DUK_ASC_LC_F) ||\n\t           (x >= DUK_ASC_UC_A && x <= DUK_ASC_UC_F));\n\tret = duk__hexval_validate(x);\n\tDUK_ASSERT(ret >= 0 && ret <= 15);\n\treturn ret;\n}\n\n/* having this as a separate function provided a size benefit */\nDUK_LOCAL duk_bool_t duk__is_hex_digit(duk_codepoint_t x) {\n\tif (DUK_LIKELY(x >= 0 && x <= 0xff)) {\n\t\treturn (duk_hex_dectab[x] >= 0);\n\t}\n\treturn 0;\n}\n\n/* Parse a Unicode escape of the form \\xHH, \\uHHHH, or \\u{H+}.  Shared by\n * source and RegExp parsing.\n */\nDUK_LOCAL duk_codepoint_t duk__lexer_parse_escape(duk_lexer_ctx *lex_ctx, duk_bool_t allow_es6) {\n\tduk_small_int_t digits;  /* Initial value 2 or 4 for fixed length escapes, 0 for ES2015 \\u{H+}. */\n\tduk_codepoint_t escval;\n\tduk_codepoint_t x;\n\tduk_small_int_t adv;\n\n\tDUK_ASSERT(DUK__L0() == DUK_ASC_BACKSLASH);  /* caller responsibilities */\n\tDUK_ASSERT(DUK__L1() == DUK_ASC_LC_X || DUK__L1() == DUK_ASC_LC_U);\n\tDUK_UNREF(allow_es6);\n\n\tadv = 2;\n\tdigits = 2;\n\tif (DUK__L1() == DUK_ASC_LC_U) {\n\t\tdigits = 4;\n#if defined(DUK_USE_ES6_UNICODE_ESCAPE)\n\t\tif (DUK__L2() == DUK_ASC_LCURLY && allow_es6) {\n\t\t\tdigits = 0;\n\t\t\tadv = 3;\n\t\t}\n#endif\n\t}\n\tDUK__ADVANCECHARS(lex_ctx, adv);\n\n\tescval = 0;\n\tfor (;;) {\n\t\t/* One of the escape forms: \\xHH, \\uHHHH, \\u{H+}.\n\t\t * The 'digits' variable tracks parsing state and is\n\t\t * initialized to:\n\t\t *\n\t\t *   \\xHH     2\n\t\t *   \\uHH     4\n\t\t *   \\u{H+}   0 first time, updated to -1 to indicate\n\t\t *            at least one digit has been parsed\n\t\t *\n\t\t * Octal parsing is handled separately because it can be\n\t\t * done with fixed lookahead and also has validation\n\t\t * rules which depend on the escape length (which is\n\t\t * variable).\n\t\t *\n\t\t * We don't need a specific check for x < 0 (end of\n\t\t * input) or duk_unicode_is_line_terminator(x)\n\t\t * because the 'dig' decode will fail and lead to a\n\t\t * SyntaxError.\n\t\t */\n\t\tduk_codepoint_t dig;\n\n\t\tx = DUK__L0();\n\t\tDUK__ADVANCECHARS(lex_ctx, 1);\n\n\t\tdig = duk__hexval_validate(x);\n\t\tif (digits > 0) {\n\t\t\tdigits--;\n\t\t\tif (dig < 0) {\n\t\t\t\tgoto fail_escape;\n\t\t\t}\n\t\t\tDUK_ASSERT(dig >= 0x00 && dig <= 0x0f);\n\t\t\tescval = (escval << 4) + dig;\n\t\t\tif (digits == 0) {\n\t\t\t\tDUK_ASSERT(escval >= 0 && escval <= 0xffffL);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else {\n#if defined(DUK_USE_ES6_UNICODE_ESCAPE)\n\t\t\tDUK_ASSERT(digits == 0 /* first time */ || digits == -1 /* others */);\n\t\t\tif (dig >= 0) {\n\t\t\t\tDUK_ASSERT(dig >= 0x00 && dig <= 0x0f);\n\t\t\t\tescval = (escval << 4) + dig;\n\t\t\t\tif (escval > 0x10ffffL) {\n\t\t\t\t\tgoto fail_escape;\n\t\t\t\t}\n\t\t\t} else if (x == DUK_ASC_RCURLY) {\n\t\t\t\tif (digits == 0) {\n\t\t\t\t\t/* Empty escape, \\u{}. */\n\t\t\t\t\tgoto fail_escape;\n\t\t\t\t}\n\t\t\t\tDUK_ASSERT(escval >= 0 && escval <= 0x10ffffL);\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tgoto fail_escape;\n\t\t\t}\n\t\t\tdigits = -1;  /* Indicate we have at least one digit. */\n#else  /* DUK_USE_ES6_UNICODE_ESCAPE */\n\t\t\tDUK_ASSERT(0);  /* Never happens if \\u{H+} support disabled. */\n#endif  /* DUK_USE_ES6_UNICODE_ESCAPE */\n\t\t}\n\t}\n\n\treturn escval;\n\n fail_escape:\n\tDUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_ESCAPE);\n}\n\n/* Parse legacy octal escape of the form \\N{1,3}, e.g. \\0, \\5, \\0377.  Maximum\n * allowed value is \\0377 (U+00FF), longest match is used.  Used for both string\n * RegExp octal escape parsing.  Window[0] must be the slash '\\' and the first\n * digit must already be validated to be in [0-9] by the caller.\n */\nDUK_LOCAL duk_codepoint_t duk__lexer_parse_legacy_octal(duk_lexer_ctx *lex_ctx, duk_small_int_t *out_adv, duk_bool_t reject_annex_b) {\n\tduk_codepoint_t cp;\n\tduk_small_uint_t lookup_idx;\n\tduk_small_int_t adv;\n\tduk_codepoint_t tmp;\n\n\tDUK_ASSERT(out_adv != NULL);\n\tDUK_ASSERT(DUK__LOOKUP(lex_ctx, 0) == DUK_ASC_BACKSLASH);\n\tDUK_ASSERT(DUK__LOOKUP(lex_ctx, 1) >= DUK_ASC_0 && DUK__LOOKUP(lex_ctx, 1) <= DUK_ASC_9);\n\n\tcp = 0;\n\tfor (lookup_idx = 1; lookup_idx <= 3; lookup_idx++) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"lookup_idx=%ld, cp=%ld\", (long) lookup_idx, (long) cp));\n\t\ttmp = DUK__LOOKUP(lex_ctx, lookup_idx);\n\t\tif (tmp < DUK_ASC_0 || tmp > DUK_ASC_7) {\n\t\t\t/* No more valid digits. */\n\t\t\tbreak;\n\t\t}\n\t\ttmp = (cp << 3) + (tmp - DUK_ASC_0);\n\t\tif (tmp > 0xff) {\n\t\t\t/* Three digit octal escapes above \\377 (= 0xff)\n\t\t\t * are not allowed.\n\t\t\t */\n\t\t\tbreak;\n\t\t}\n\t\tcp = tmp;\n\t}\n\tDUK_DDD(DUK_DDDPRINT(\"final lookup_idx=%ld, cp=%ld\", (long) lookup_idx, (long) cp));\n\n\tadv = lookup_idx;\n\tif (lookup_idx == 1) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"\\\\8 or \\\\9 -> treat as literal, accept in strict mode too\"));\n\t\tDUK_ASSERT(tmp == DUK_ASC_8 || tmp == DUK_ASC_9);\n\t\tcp = tmp;\n\t\tadv++;  /* correction to above, eat offending character */\n\t} else if (lookup_idx == 2 && cp == 0) {\n\t\t/* Note: 'foo\\0bar' is OK in strict mode, but 'foo\\00bar' is not.\n\t\t * It won't be interpreted as 'foo\\u{0}0bar' but as a SyntaxError.\n\t\t */\n\t\tDUK_DDD(DUK_DDDPRINT(\"\\\\0 -> accept in strict mode too\"));\n\t} else {\n\t\t/* This clause also handles non-shortest zero, e.g. \\00. */\n\t\tif (reject_annex_b) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"non-zero octal literal %ld -> reject in strict-mode\", (long) cp));\n\t\t\tcp = -1;\n\t\t} else {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"non-zero octal literal %ld -> accepted\", (long) cp));\n\t\t\tDUK_ASSERT(cp >= 0 && cp <= 0xff);\n\t\t}\n\t}\n\n\t*out_adv = adv;\n\n\tDUK_ASSERT((cp >= 0 && cp <= 0xff) || (cp == -1 && reject_annex_b));\n\treturn cp;\n}\n\n/* XXX: move strict mode to lex_ctx? */\nDUK_LOCAL void duk__lexer_parse_string_literal(duk_lexer_ctx *lex_ctx, duk_token *out_token, duk_small_int_t quote, duk_bool_t strict_mode) {\n\tduk_small_int_t adv;\n\n\tfor (adv = 1 /* initial quote */ ;;) {\n\t\tduk_codepoint_t x;\n\n\t\tDUK__ADVANCECHARS(lex_ctx, adv);  /* eat opening quote on first loop */\n\t\tx = DUK__L0();\n\n\t\tadv = 1;\n\t\tif (x == quote) {\n\t\t\tDUK__ADVANCECHARS(lex_ctx, 1);  /* eat closing quote */\n\t\t\tbreak;\n\t\t} else if (x == '\\\\') {\n\t\t\t/* DUK__L0        -> '\\' char\n\t\t\t * DUK__L1 ... DUK__L5 -> more lookup\n\t\t\t */\n\t\t\tduk_small_int_t emitcp = -1;\n\n\t\t\tx = DUK__L1();\n\n\t\t\t/* How much to advance before next loop. */\n\t\t\tadv = 2;  /* note: long live range */\n\n\t\t\tswitch (x) {\n\t\t\tcase '\\'':\n\t\t\t\temitcp = 0x0027;\n\t\t\t\tbreak;\n\t\t\tcase '\"':\n\t\t\t\temitcp = 0x0022;\n\t\t\t\tbreak;\n\t\t\tcase '\\\\':\n\t\t\t\temitcp = 0x005c;\n\t\t\t\tbreak;\n\t\t\tcase 'b':\n\t\t\t\temitcp = 0x0008;\n\t\t\t\tbreak;\n\t\t\tcase 'f':\n\t\t\t\temitcp = 0x000c;\n\t\t\t\tbreak;\n\t\t\tcase 'n':\n\t\t\t\temitcp = 0x000a;\n\t\t\t\tbreak;\n\t\t\tcase 'r':\n\t\t\t\temitcp = 0x000d;\n\t\t\t\tbreak;\n\t\t\tcase 't':\n\t\t\t\temitcp = 0x0009;\n\t\t\t\tbreak;\n\t\t\tcase 'v':\n\t\t\t\temitcp = 0x000b;\n\t\t\t\tbreak;\n\t\t\tcase 'x':\n\t\t\tcase 'u': {\n\t\t\t\tduk_codepoint_t esc_cp;\n\t\t\t\tesc_cp = duk__lexer_parse_escape(lex_ctx, 1 /*allow_es6*/);\n\t\t\t\tDUK__APPENDBUFFER(lex_ctx, esc_cp);\n\t\t\t\tadv = 0;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tif (duk_unicode_is_line_terminator(x)) {\n\t\t\t\t\t/* line continuation */\n\t\t\t\t\tif (x == 0x000d && DUK__L2() == 0x000a) {\n\t\t\t\t\t\t/* CR LF again a special case */\n\t\t\t\t\t\tadv = 3;  /* line terminator, CR, LF */\n\t\t\t\t\t}\n\t\t\t\t} else if (DUK__ISDIGIT(x)) {\n\t\t\t\t\t/*\n\t\t\t\t\t *  Octal escape or zero escape:\n\t\t\t\t\t *    \\0                                     (lookahead not OctalDigit)\n\t\t\t\t\t *    \\1 ... \\7                              (lookahead not OctalDigit)\n\t\t\t\t\t *    \\ZeroToThree OctalDigit                (lookahead not OctalDigit)\n\t\t\t\t\t *    \\FourToSeven OctalDigit                (no lookahead restrictions)\n\t\t\t\t\t *    \\ZeroToThree OctalDigit OctalDigit     (no lookahead restrictions)\n\t\t\t\t\t *\n\t\t\t\t\t *  Zero escape is part of the standard syntax.  Octal escapes are\n\t\t\t\t\t *  defined in E5 Section B.1.2, and are only allowed in non-strict mode.\n\t\t\t\t\t *  Any other productions starting with a decimal digit are invalid\n\t\t\t\t\t *  but are in practice treated like identity escapes.\n\t\t\t\t\t *\n\t\t\t\t\t *  Parse octal (up to 3 digits) from the lookup window.\n\t\t\t\t\t */\n\n\t\t\t\t\temitcp = duk__lexer_parse_legacy_octal(lex_ctx, &adv, strict_mode /*reject_annex_b*/);\n\t\t\t\t\tif (emitcp < 0) {\n\t\t\t\t\t\tgoto fail_escape;\n\t\t\t\t\t}\n\t\t\t\t} else if (x < 0) {\n\t\t\t\t\tgoto fail_unterminated;\n\t\t\t\t} else {\n\t\t\t\t\t/* escaped NonEscapeCharacter */\n\t\t\t\t\tDUK__APPENDBUFFER(lex_ctx, x);\n\t\t\t\t}\n\t\t\t}  /* end default clause */\n\t\t\t}  /* end switch */\n\n\t\t\t/* Shared handling for single codepoint escapes. */\n\t\t\tif (emitcp >= 0) {\n\t\t\t\tDUK__APPENDBUFFER(lex_ctx, emitcp);\n\t\t\t}\n\n\t\t\t/* Track number of escapes; count not really needed but directive\n\t\t\t * prologues need to detect whether there were any escapes or line\n\t\t\t * continuations or not.\n\t\t\t */\n\t\t\tout_token->num_escapes++;\n\t\t} else if (x >= 0x20 && x <= 0x7f) {\n\t\t\t/* Fast path for ASCII case, avoids line terminator\n\t\t\t * check and CESU-8 encoding.\n\t\t\t */\n\t\t\tDUK_ASSERT(x >= 0);\n\t\t\tDUK_ASSERT(!duk_unicode_is_line_terminator(x));\n\t\t\tDUK_ASSERT(x != quote);\n\t\t\tDUK_ASSERT(x != DUK_ASC_BACKSLASH);\n\t\t\tDUK__APPENDBUFFER_ASCII(lex_ctx, x);\n\t\t} else if (x < 0 || duk_unicode_is_line_terminator(x)) {\n\t\t\tgoto fail_unterminated;\n\t\t} else {\n\t\t\t/* Character which is part of the string but wasn't handled\n\t\t\t * by the fast path.\n\t\t\t */\n\t\t\tDUK__APPENDBUFFER(lex_ctx, x);\n\t\t}\n\t} /* string parse loop */\n\n\treturn;\n\n fail_escape:\n\tDUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_ESCAPE);\n\treturn;\n\n fail_unterminated:\n\tDUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_UNTERMINATED_STRING);\n\treturn;\n}\n\n/* Skip to end-of-line (or end-of-file), used for single line comments. */\nDUK_LOCAL void duk__lexer_skip_to_endofline(duk_lexer_ctx *lex_ctx) {\n\tfor (;;) {\n\t\tduk_codepoint_t x;\n\n\t\tx = DUK__L0();\n\t\tif (x < 0 || duk_unicode_is_line_terminator(x)) {\n\t\t\tbreak;\n\t\t}\n\t\tDUK__ADVANCECHARS(lex_ctx, 1);\n\t}\n}\n\n/*\n *  Parse Ecmascript source InputElementDiv or InputElementRegExp\n *  (E5 Section 7), skipping whitespace, comments, and line terminators.\n *\n *  Possible results are:\n *    (1) a token\n *    (2) a line terminator (skipped)\n *    (3) a comment (skipped)\n *    (4) EOF\n *\n *  White space is automatically skipped from the current position (but\n *  not after the input element).  If input has already ended, returns\n *  DUK_TOK_EOF indefinitely.  If a parse error occurs, uses an DUK_ERROR()\n *  macro call (and hence a longjmp through current heap longjmp context).\n *  Comments and line terminator tokens are automatically skipped.\n *\n *  The input element being matched is determined by regexp_mode; if set,\n *  parses a InputElementRegExp, otherwise a InputElementDiv.  The\n *  difference between these are handling of productions starting with a\n *  forward slash.\n *\n *  If strict_mode is set, recognizes additional future reserved words\n *  specific to strict mode, and refuses to parse octal literals.\n *\n *  The matching strategy below is to (currently) use a six character\n *  lookup window to quickly determine which production is the -longest-\n *  matching one, and then parse that.  The top-level if-else clauses\n *  match the first character, and the code blocks for each clause\n *  handle -all- alternatives for that first character.  Ecmascript\n *  specification uses the \"longest match wins\" semantics, so the order\n *  of the if-clauses matters.\n *\n *  Misc notes:\n *\n *    * Ecmascript numeric literals do not accept a sign character.\n *      Consequently e.g. \"-1.0\" is parsed as two tokens: a negative\n *      sign and a positive numeric literal.  The compiler performs\n *      the negation during compilation, so this has no adverse impact.\n *\n *    * There is no token for \"undefined\": it is just a value available\n *      from the global object (or simply established by doing a reference\n *      to an undefined value).\n *\n *    * Some contexts want Identifier tokens, which are IdentifierNames\n *      excluding reserved words, while some contexts want IdentifierNames\n *      directly.  In the latter case e.g. \"while\" is interpreted as an\n *      identifier name, not a DUK_TOK_WHILE token.  The solution here is\n *      to provide both token types: DUK_TOK_WHILE goes to 't' while\n *      DUK_TOK_IDENTIFIER goes to 't_nores', and 'slot1' always contains\n *      the identifier / keyword name.\n *\n *    * Directive prologue needs to identify string literals such as\n *      \"use strict\" and 'use strict', which are sensitive to line\n *      continuations and escape sequences.  For instance, \"use\\u0020strict\"\n *      is a valid directive but is distinct from \"use strict\".  The solution\n *      here is to decode escapes while tokenizing, but to keep track of the\n *      number of escapes.  Directive detection can then check that the\n *      number of escapes is zero.\n *\n *    * Multi-line comments with one or more internal LineTerminator are\n *      treated like a line terminator to comply with automatic semicolon\n *      insertion.\n */\n\nDUK_INTERNAL\nvoid duk_lexer_parse_js_input_element(duk_lexer_ctx *lex_ctx,\n                                      duk_token *out_token,\n                                      duk_bool_t strict_mode,\n                                      duk_bool_t regexp_mode) {\n\tduk_codepoint_t x;           /* temporary, must be signed and 32-bit to hold Unicode code points */\n\tduk_small_uint_t advtok = 0; /* (advance << 8) + token_type, updated at function end,\n\t                              * init is unnecessary but suppresses \"may be used uninitialized\" warnings.\n\t                              */\n\tduk_bool_t got_lineterm = 0;  /* got lineterm preceding non-whitespace, non-lineterm token */\n\n\tif (++lex_ctx->token_count >= lex_ctx->token_limit) {\n\t\tgoto fail_token_limit;\n\t}\n\n\tout_token->t = DUK_TOK_EOF;\n\tout_token->t_nores = -1;  /* marker: copy t if not changed */\n#if 0  /* not necessary to init, disabled for faster parsing */\n\tout_token->num = DUK_DOUBLE_NAN;\n\tout_token->str1 = NULL;\n\tout_token->str2 = NULL;\n#endif\n\tout_token->num_escapes = 0;\n\t/* out_token->lineterm set by caller */\n\n\t/* This would be nice, but parsing is faster without resetting the\n\t * value slots.  The only side effect is that references to temporary\n\t * string values may linger until lexing is finished; they're then\n\t * freed normally.\n\t */\n#if 0\n\tduk_to_undefined((duk_context *) lex_ctx->thr, lex_ctx->slot1_idx);\n\tduk_to_undefined((duk_context *) lex_ctx->thr, lex_ctx->slot2_idx);\n#endif\n\n\t/* 'advtok' indicates how much to advance and which token id to assign\n\t * at the end.  This shared functionality minimizes code size.  All\n\t * code paths are required to set 'advtok' to some value, so no default\n\t * init value is used.  Code paths calling DUK_ERROR() never return so\n\t * they don't need to set advtok.\n\t */\n\n\t/*\n\t *  Matching order:\n\t *\n\t *    Punctuator first chars, also covers comments, regexps\n\t *    LineTerminator\n\t *    Identifier or reserved word, also covers null/true/false literals\n\t *    NumericLiteral\n\t *    StringLiteral\n\t *    EOF\n\t *\n\t *  The order does not matter as long as the longest match is\n\t *  always correctly identified.  There are order dependencies\n\t *  in the clauses, so it's not trivial to convert to a switch.\n\t */\n\n restart_lineupdate:\n\tout_token->start_line = lex_ctx->window[0].line;\n\n restart:\n\tout_token->start_offset = lex_ctx->window[0].offset;\n\n\tx = DUK__L0();\n\n\tswitch (x) {\n\tcase DUK_ASC_SPACE:\n\tcase DUK_ASC_HT:  /* fast paths for space and tab */\n\t\tDUK__ADVANCECHARS(lex_ctx, 1);\n\t\tgoto restart;\n\tcase DUK_ASC_LF:  /* LF line terminator; CR LF and Unicode lineterms are handled in slow path */\n\t\tDUK__ADVANCECHARS(lex_ctx, 1);\n\t\tgot_lineterm = 1;\n\t\tgoto restart_lineupdate;\n#if defined(DUK_USE_SHEBANG_COMMENTS)\n\tcase DUK_ASC_HASH:  /* '#' */\n\t\tif (DUK__L1() == DUK_ASC_EXCLAMATION && lex_ctx->window[0].offset == 0 &&\n\t\t    (lex_ctx->flags & DUK_COMPILE_SHEBANG)) {\n\t\t\t/* \"Shebang\" comment ('#! ...') on first line. */\n\t\t\t/* DUK__ADVANCECHARS(lex_ctx, 2) would be correct here, but not necessary */\n\t\t\tduk__lexer_skip_to_endofline(lex_ctx);\n\t\t\tgoto restart;  /* line terminator will be handled on next round */\n\t\t}\n\t\tgoto fail_token;\n#endif  /* DUK_USE_SHEBANG_COMMENTS */\n\tcase DUK_ASC_SLASH:  /* '/' */\n\t\tif (DUK__L1() == DUK_ASC_SLASH) {\n\t\t\t/*\n\t\t\t *  E5 Section 7.4, allow SourceCharacter (which is any 16-bit\n\t\t\t *  code point).\n\t\t\t */\n\n\t\t\t/* DUK__ADVANCECHARS(lex_ctx, 2) would be correct here, but not necessary */\n\t\t\tduk__lexer_skip_to_endofline(lex_ctx);\n\t\t\tgoto restart;  /* line terminator will be handled on next round */\n\t\t} else if (DUK__L1() == DUK_ASC_STAR) {\n\t\t\t/*\n\t\t\t *  E5 Section 7.4.  If the multi-line comment contains a newline,\n\t\t\t *  it is treated like a single line terminator for automatic\n\t\t\t *  semicolon insertion.\n\t\t\t */\n\n\t\t\tduk_bool_t last_asterisk = 0;\n\t\t\tDUK__ADVANCECHARS(lex_ctx, 2);\n\t\t\tfor (;;) {\n\t\t\t\tx = DUK__L0();\n\t\t\t\tif (x < 0) {\n\t\t\t\t\tgoto fail_unterm_comment;\n\t\t\t\t}\n\t\t\t\tDUK__ADVANCECHARS(lex_ctx, 1);\n\t\t\t\tif (last_asterisk && x == DUK_ASC_SLASH) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (duk_unicode_is_line_terminator(x)) {\n\t\t\t\t\tgot_lineterm = 1;\n\t\t\t\t}\n\t\t\t\tlast_asterisk = (x == DUK_ASC_STAR);\n\t\t\t}\n\t\t\tgoto restart_lineupdate;\n\t\t} else if (regexp_mode) {\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\t\t\t/*\n\t\t\t *  \"/\" followed by something in regexp mode.  See E5 Section 7.8.5.\n\t\t\t *\n\t\t\t *  RegExp parsing is a bit complex.  First, the regexp body is delimited\n\t\t\t *  by forward slashes, but the body may also contain forward slashes as\n\t\t\t *  part of an escape sequence or inside a character class (delimited by\n\t\t\t *  square brackets).  A mini state machine is used to implement these.\n\t\t\t *\n\t\t\t *  Further, an early (parse time) error must be thrown if the regexp\n\t\t\t *  would cause a run-time error when used in the expression new RegExp(...).\n\t\t\t *  Parsing here simply extracts the (candidate) regexp, and also accepts\n\t\t\t *  invalid regular expressions (which are delimited properly).  The caller\n\t\t\t *  (compiler) must perform final validation and regexp compilation.\n\t\t\t *\n\t\t\t *  RegExp first char may not be '/' (single line comment) or '*' (multi-\n\t\t\t *  line comment).  These have already been checked above, so there is no\n\t\t\t *  need below for special handling of the first regexp character as in\n\t\t\t *  the E5 productions.\n\t\t\t *\n\t\t\t *  About unicode escapes within regexp literals:\n\t\t\t *\n\t\t\t *      E5 Section 7.8.5 grammar does NOT accept \\uHHHH escapes.\n\t\t\t *      However, Section 6 states that regexps accept the escapes,\n\t\t\t *      see paragraph starting with \"In string literals...\".\n\t\t\t *      The regexp grammar, which sees the decoded regexp literal\n\t\t\t *      (after lexical parsing) DOES have a \\uHHHH unicode escape.\n\t\t\t *      So, for instance:\n\t\t\t *\n\t\t\t *          /\\u1234/\n\t\t\t *\n\t\t\t *      should first be parsed by the lexical grammar as:\n\t\t\t *\n\t\t\t *          '\\' 'u'      RegularExpressionBackslashSequence\n\t\t\t *          '1'          RegularExpressionNonTerminator\n\t\t\t *          '2'          RegularExpressionNonTerminator\n\t\t\t *          '3'          RegularExpressionNonTerminator\n\t\t\t *          '4'          RegularExpressionNonTerminator\n\t\t\t *\n\t\t\t *      and the escape itself is then parsed by the regexp engine.\n\t\t\t *      This is the current implementation.\n\t\t\t *\n\t\t\t *  Minor spec inconsistency:\n\t\t\t *\n\t\t\t *      E5 Section 7.8.5 RegularExpressionBackslashSequence is:\n\t\t\t *\n\t\t\t *         \\ RegularExpressionNonTerminator\n\t\t\t *\n\t\t\t *      while Section A.1 RegularExpressionBackslashSequence is:\n\t\t\t *\n\t\t\t *         \\ NonTerminator\n\t\t\t *\n\t\t\t *      The latter is not normative and a typo.\n\t\t\t *\n\t\t\t */\n\n\t\t\t/* first, parse regexp body roughly */\n\n\t\t\tduk_small_int_t state = 0;  /* 0=base, 1=esc, 2=class, 3=class+esc */\n\n\t\t\tDUK__INITBUFFER(lex_ctx);\n\t\t\tfor (;;) {\n\t\t\t\tDUK__ADVANCECHARS(lex_ctx, 1);  /* skip opening slash on first loop */\n\t\t\t\tx = DUK__L0();\n\t\t\t\tif (x < 0 || duk_unicode_is_line_terminator(x)) {\n\t\t\t\t\tgoto fail_unterm_regexp;\n\t\t\t\t}\n\t\t\t\tx = DUK__L0();  /* re-read to avoid spill / fetch */\n\t\t\t\tif (state == 0) {\n\t\t\t\t\tif (x == DUK_ASC_SLASH) {\n\t\t\t\t\t\tDUK__ADVANCECHARS(lex_ctx, 1);  /* eat closing slash */\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t} else if (x == DUK_ASC_BACKSLASH) {\n\t\t\t\t\t\tstate = 1;\n\t\t\t\t\t} else if (x == DUK_ASC_LBRACKET) {\n\t\t\t\t\t\tstate = 2;\n\t\t\t\t\t}\n\t\t\t\t} else if (state == 1) {\n\t\t\t\t\tstate = 0;\n\t\t\t\t} else if (state == 2) {\n\t\t\t\t\tif (x == DUK_ASC_RBRACKET) {\n\t\t\t\t\t\tstate = 0;\n\t\t\t\t\t} else if (x == DUK_ASC_BACKSLASH) {\n\t\t\t\t\t\tstate = 3;\n\t\t\t\t\t}\n\t\t\t\t} else { /* state == 3 */\n\t\t\t\t\tstate = 2;\n\t\t\t\t}\n\t\t\t\tDUK__APPENDBUFFER(lex_ctx, x);\n\t\t\t}\n\t\t\tout_token->str1 = duk__internbuffer(lex_ctx, lex_ctx->slot1_idx);\n\n\t\t\t/* second, parse flags */\n\n\t\t\tDUK__INITBUFFER(lex_ctx);\n\t\t\tfor (;;) {\n\t\t\t\tx = DUK__L0();\n\t\t\t\tif (!duk_unicode_is_identifier_part(x)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tx = DUK__L0();  /* re-read to avoid spill / fetch */\n\t\t\t\tDUK__APPENDBUFFER(lex_ctx, x);\n\t\t\t\tDUK__ADVANCECHARS(lex_ctx, 1);\n\t\t\t}\n\t\t\tout_token->str2 = duk__internbuffer(lex_ctx, lex_ctx->slot2_idx);\n\n\t\t\tDUK__INITBUFFER(lex_ctx);  /* free some memory */\n\n\t\t\t/* validation of the regexp is caller's responsibility */\n\n\t\t\tadvtok = DUK__ADVTOK(0, DUK_TOK_REGEXP);\n#else  /* DUK_USE_REGEXP_SUPPORT */\n\t\t\tgoto fail_regexp_support;\n#endif  /* DUK_USE_REGEXP_SUPPORT */\n\t\t} else if (DUK__L1() == DUK_ASC_EQUALS) {\n\t\t\t/* \"/=\" and not in regexp mode */\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_TOK_DIV_EQ);\n\t\t} else {\n\t\t\t/* \"/\" and not in regexp mode */\n\t\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_DIV);\n\t\t}\n\t\tbreak;\n\tcase DUK_ASC_LCURLY:  /* '{' */\n\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_LCURLY);\n\t\tbreak;\n\tcase DUK_ASC_RCURLY:  /* '}' */\n\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_RCURLY);\n\t\tbreak;\n\tcase DUK_ASC_LPAREN:  /* '(' */\n\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_LPAREN);\n\t\tbreak;\n\tcase DUK_ASC_RPAREN:  /* ')' */\n\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_RPAREN);\n\t\tbreak;\n\tcase DUK_ASC_LBRACKET:  /* '[' */\n\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_LBRACKET);\n\t\tbreak;\n\tcase DUK_ASC_RBRACKET:  /* ']' */\n\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_RBRACKET);\n\t\tbreak;\n\tcase DUK_ASC_PERIOD:  /* '.' */\n\t\tif (DUK__ISDIGIT(DUK__L1())) {\n\t\t\t/* Period followed by a digit can only start DecimalLiteral\n\t\t\t * (handled in slow path).  We could jump straight into the\n\t\t\t * DecimalLiteral handling but should avoid goto to inside\n\t\t\t * a block.\n\t\t\t */\n\t\t\tgoto slow_path;\n\t\t}\n\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_PERIOD);\n\t\tbreak;\n\tcase DUK_ASC_SEMICOLON:  /* ';' */\n\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_SEMICOLON);\n\t\tbreak;\n\tcase DUK_ASC_COMMA:  /* ',' */\n\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_COMMA);\n\t\tbreak;\n\tcase DUK_ASC_LANGLE:  /* '<' */\n#if defined(DUK_USE_HTML_COMMENTS)\n\t\tif (DUK__L1() == DUK_ASC_EXCLAMATION && DUK__L2() == DUK_ASC_MINUS && DUK__L3() == DUK_ASC_MINUS) {\n\t\t\t/*\n\t\t\t *  ES6: B.1.3, handle \"<!--\" SingleLineHTMLOpenComment\n\t\t\t */\n\n\t\t\t/* DUK__ADVANCECHARS(lex_ctx, 4) would be correct here, but not necessary */\n\t\t\tduk__lexer_skip_to_endofline(lex_ctx);\n\t\t\tgoto restart;  /* line terminator will be handled on next round */\n\t\t}\n\t\telse\n#endif  /* DUK_USE_HTML_COMMENTS */\n\t\tif (DUK__L1() == DUK_ASC_LANGLE && DUK__L2() == DUK_ASC_EQUALS) {\n\t\t\tadvtok = DUK__ADVTOK(3, DUK_TOK_ALSHIFT_EQ);\n\t\t} else if (DUK__L1() == DUK_ASC_EQUALS) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_TOK_LE);\n\t\t} else if (DUK__L1() == DUK_ASC_LANGLE) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_TOK_ALSHIFT);\n\t\t} else {\n\t\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_LT);\n\t\t}\n\t\tbreak;\n\tcase DUK_ASC_RANGLE:  /* '>' */\n\t\tif (DUK__L1() == DUK_ASC_RANGLE && DUK__L2() == DUK_ASC_RANGLE && DUK__L3() == DUK_ASC_EQUALS) {\n\t\t\tadvtok = DUK__ADVTOK(4, DUK_TOK_RSHIFT_EQ);\n\t\t} else if (DUK__L1() == DUK_ASC_RANGLE && DUK__L2() == DUK_ASC_RANGLE) {\n\t\t\tadvtok = DUK__ADVTOK(3, DUK_TOK_RSHIFT);\n\t\t} else if (DUK__L1() == DUK_ASC_RANGLE && DUK__L2() == DUK_ASC_EQUALS) {\n\t\t\tadvtok = DUK__ADVTOK(3, DUK_TOK_ARSHIFT_EQ);\n\t\t} else if (DUK__L1() == DUK_ASC_EQUALS) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_TOK_GE);\n\t\t} else if (DUK__L1() == DUK_ASC_RANGLE) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_TOK_ARSHIFT);\n\t\t} else {\n\t\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_GT);\n\t\t}\n\t\tbreak;\n\tcase DUK_ASC_EQUALS:  /* '=' */\n\t\tif (DUK__L1() == DUK_ASC_EQUALS && DUK__L2() == DUK_ASC_EQUALS) {\n\t\t\tadvtok = DUK__ADVTOK(3, DUK_TOK_SEQ);\n\t\t} else if (DUK__L1() == DUK_ASC_EQUALS) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_TOK_EQ);\n\t\t} else {\n\t\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_EQUALSIGN);\n\t\t}\n\t\tbreak;\n\tcase DUK_ASC_EXCLAMATION:  /* '!' */\n\t\tif (DUK__L1() == DUK_ASC_EQUALS && DUK__L2() == DUK_ASC_EQUALS) {\n\t\t\tadvtok = DUK__ADVTOK(3, DUK_TOK_SNEQ);\n\t\t} else if (DUK__L1() == DUK_ASC_EQUALS) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_TOK_NEQ);\n\t\t} else {\n\t\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_LNOT);\n\t\t}\n\t\tbreak;\n\tcase DUK_ASC_PLUS:  /* '+' */\n\t\tif (DUK__L1() == DUK_ASC_PLUS) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_TOK_INCREMENT);\n\t\t} else if (DUK__L1() == DUK_ASC_EQUALS) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_TOK_ADD_EQ);\n\t\t} else {\n\t\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_ADD);\n\t\t}\n\t\tbreak;\n\tcase DUK_ASC_MINUS:  /* '-' */\n#if defined(DUK_USE_HTML_COMMENTS)\n\t\tif (got_lineterm && DUK__L1() == DUK_ASC_MINUS && DUK__L2() == DUK_ASC_RANGLE) {\n\t\t\t/*\n\t\t\t *  ES6: B.1.3, handle \"-->\" SingleLineHTMLCloseComment\n\t\t\t *  Only allowed:\n\t\t\t *  - on new line\n\t\t\t *  - preceded only by whitespace\n\t\t\t *  - preceded by end of multiline comment and optional whitespace\n\t\t\t *\n\t\t\t * Since whitespace generates no tokens, and multiline comments\n\t\t\t * are treated as a line ending, consulting `got_lineterm` is\n\t\t\t * sufficient to test for these three options.\n\t\t\t */\n\n\t\t\t/* DUK__ADVANCECHARS(lex_ctx, 3) would be correct here, but not necessary */\n\t\t\tduk__lexer_skip_to_endofline(lex_ctx);\n\t\t\tgoto restart;  /* line terminator will be handled on next round */\n\t\t} else\n#endif  /* DUK_USE_HTML_COMMENTS */\n\t\tif (DUK__L1() == DUK_ASC_MINUS) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_TOK_DECREMENT);\n\t\t} else if (DUK__L1() == DUK_ASC_EQUALS) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_TOK_SUB_EQ);\n\t\t} else {\n\t\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_SUB);\n\t\t}\n\t\tbreak;\n\tcase DUK_ASC_STAR:  /* '*' */\n#if defined(DUK_USE_ES7_EXP_OPERATOR)\n\t\tif (DUK__L1() == DUK_ASC_STAR && DUK__L2() == DUK_ASC_EQUALS) {\n\t\t\tadvtok = DUK__ADVTOK(3, DUK_TOK_EXP_EQ);\n\t\t} else if (DUK__L1() == DUK_ASC_STAR) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_TOK_EXP);\n\t\t} else\n#endif\n\t\tif (DUK__L1() == DUK_ASC_EQUALS) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_TOK_MUL_EQ);\n\t\t} else {\n\t\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_MUL);\n\t\t}\n\t\tbreak;\n\tcase DUK_ASC_PERCENT:  /* '%' */\n\t\tif (DUK__L1() == DUK_ASC_EQUALS) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_TOK_MOD_EQ);\n\t\t} else {\n\t\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_MOD);\n\t\t}\n\t\tbreak;\n\tcase DUK_ASC_AMP:  /* '&' */\n\t\tif (DUK__L1() == DUK_ASC_AMP) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_TOK_LAND);\n\t\t} else if (DUK__L1() == DUK_ASC_EQUALS) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_TOK_BAND_EQ);\n\t\t} else {\n\t\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_BAND);\n\t\t}\n\t\tbreak;\n\tcase DUK_ASC_PIPE:  /* '|' */\n\t\tif (DUK__L1() == DUK_ASC_PIPE) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_TOK_LOR);\n\t\t} else if (DUK__L1() == DUK_ASC_EQUALS) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_TOK_BOR_EQ);\n\t\t} else {\n\t\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_BOR);\n\t\t}\n\t\tbreak;\n\tcase DUK_ASC_CARET:  /* '^' */\n\t\tif (DUK__L1() == DUK_ASC_EQUALS) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_TOK_BXOR_EQ);\n\t\t} else {\n\t\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_BXOR);\n\t\t}\n\t\tbreak;\n\tcase DUK_ASC_TILDE:  /* '~' */\n\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_BNOT);\n\t\tbreak;\n\tcase DUK_ASC_QUESTION:  /* '?' */\n\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_QUESTION);\n\t\tbreak;\n\tcase DUK_ASC_COLON:  /* ':' */\n\t\tadvtok = DUK__ADVTOK(1, DUK_TOK_COLON);\n\t\tbreak;\n\tcase DUK_ASC_DOUBLEQUOTE:    /* '\"' */\n\tcase DUK_ASC_SINGLEQUOTE: {  /* '\\'' */\n\t\tDUK__INITBUFFER(lex_ctx);\n\t\tduk__lexer_parse_string_literal(lex_ctx, out_token, x /*quote*/, strict_mode);\n\t\tduk__internbuffer(lex_ctx, lex_ctx->slot1_idx);\n\t\tout_token->str1 = duk_known_hstring((duk_context *) lex_ctx->thr, lex_ctx->slot1_idx);\n\n\t\tDUK__INITBUFFER(lex_ctx);  /* free some memory */\n\n\t\tadvtok = DUK__ADVTOK(0, DUK_TOK_STRING);\n\t\tbreak;\n\t}\n\tdefault:\n\t\tgoto slow_path;\n\t}  /* switch */\n\n\tgoto skip_slow_path;\n\n slow_path:\n\tif (duk_unicode_is_line_terminator(x)) {\n\t\tif (x == 0x000d && DUK__L1() == 0x000a) {\n\t\t\t/*\n\t\t\t *  E5 Section 7.3: CR LF is detected as a single line terminator for\n\t\t\t *  line numbers.  Here we also detect it as a single line terminator\n\t\t\t *  token.\n\t\t\t */\n\t\t\tDUK__ADVANCECHARS(lex_ctx, 2);\n\t\t} else {\n\t\t\tDUK__ADVANCECHARS(lex_ctx, 1);\n\t\t}\n\t\tgot_lineterm = 1;\n\t\tgoto restart_lineupdate;\n\t} else if (duk_unicode_is_identifier_start(x) || x == DUK_ASC_BACKSLASH) {\n\t\t/*\n\t\t *  Parse an identifier and then check whether it is:\n\t\t *    - reserved word (keyword or other reserved word)\n\t\t *    - \"null\"  (NullLiteral)\n\t\t *    - \"true\"  (BooleanLiteral)\n\t\t *    - \"false\" (BooleanLiteral)\n\t\t *    - anything else => identifier\n\t\t *\n\t\t *  This does not follow the E5 productions cleanly, but is\n\t\t *  useful and compact.\n\t\t *\n\t\t *  Note that identifiers may contain Unicode escapes,\n\t\t *  see E5 Sections 6 and 7.6.  They must be decoded first,\n\t\t *  and the result checked against allowed characters.\n\t\t *  The above if-clause accepts an identifier start and an\n\t\t *  '\\' character -- no other token can begin with a '\\'.\n\t\t *\n\t\t *  Note that \"get\" and \"set\" are not reserved words in E5\n\t\t *  specification so they are recognized as plain identifiers\n\t\t *  (the tokens DUK_TOK_GET and DUK_TOK_SET are actually not\n\t\t *  used now).  The compiler needs to work around this.\n\t\t *\n\t\t *  Strictly speaking, following Ecmascript longest match\n\t\t *  specification, an invalid escape for the first character\n\t\t *  should cause a syntax error.  However, an invalid escape\n\t\t *  for IdentifierParts should just terminate the identifier\n\t\t *  early (longest match), and let the next tokenization\n\t\t *  fail.  For instance Rhino croaks with 'foo\\z' when\n\t\t *  parsing the identifier.  This has little practical impact.\n\t\t */\n\n\t\tduk_small_int_t i, i_end;\n\t\tduk_bool_t first = 1;\n\t\tduk_hstring *str;\n\n\t\tDUK__INITBUFFER(lex_ctx);\n\t\tfor (;;) {\n\t\t\t/* re-lookup first char on first loop */\n\t\t\tif (DUK__L0() == DUK_ASC_BACKSLASH) {\n\t\t\t\tduk_codepoint_t esc_cp;\n\t\t\t\tif (DUK__L1() != DUK_ASC_LC_U) {\n\t\t\t\t\tgoto fail_escape;\n\t\t\t\t}\n\t\t\t\tesc_cp = duk__lexer_parse_escape(lex_ctx, 1 /*allow_es6*/);\n\t\t\t\tDUK__APPENDBUFFER(lex_ctx, esc_cp);\n\n\t\t\t\t/* IdentifierStart is stricter than IdentifierPart, so if the first\n\t\t\t\t * character is escaped, must have a stricter check here.\n\t\t\t\t */\n\t\t\t\tif (!(first ? duk_unicode_is_identifier_start(esc_cp) : duk_unicode_is_identifier_part(esc_cp))) {\n\t\t\t\t\tgoto fail_escape;\n\t\t\t\t}\n\n\t\t\t\t/* Track number of escapes: necessary for proper keyword\n\t\t\t\t * detection.\n\t\t\t\t */\n\t\t\t\tout_token->num_escapes++;\n\t\t\t} else {\n\t\t\t\t/* Note: first character is checked against this.  But because\n\t\t\t\t * IdentifierPart includes all IdentifierStart characters, and\n\t\t\t\t * the first character (if unescaped) has already been checked\n\t\t\t\t * in the if condition, this is OK.\n\t\t\t\t */\n\t\t\t\tif (!duk_unicode_is_identifier_part(DUK__L0())) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tDUK__APPENDBUFFER(lex_ctx, DUK__L0());\n\t\t\t\tDUK__ADVANCECHARS(lex_ctx, 1);\n\t\t\t}\n\t\t\tfirst = 0;\n\t\t}\n\n\t\tout_token->str1 = duk__internbuffer(lex_ctx, lex_ctx->slot1_idx);\n\t\tstr = out_token->str1;\n\t\tout_token->t_nores = DUK_TOK_IDENTIFIER;\n\n\t\tDUK__INITBUFFER(lex_ctx);  /* free some memory */\n\n\t\t/*\n\t\t *  Interned identifier is compared against reserved words, which are\n\t\t *  currently interned into the heap context.  See genbuiltins.py.\n\t\t *\n\t\t *  Note that an escape in the identifier disables recognition of\n\t\t *  keywords; e.g. \"\\u0069f = 1;\" is a valid statement (assigns to\n\t\t *  identifier named \"if\").  This is not necessarily compliant,\n\t\t *  see test-dec-escaped-char-in-keyword.js.\n\t\t *\n\t\t *  Note: \"get\" and \"set\" are awkward.  They are not officially\n\t\t *  ReservedWords (and indeed e.g. \"var set = 1;\" is valid), and\n\t\t *  must come out as DUK_TOK_IDENTIFIER.  The compiler needs to\n\t\t *  work around this a bit.\n\t\t */\n\n\t\t/* XXX: optimize by adding the token numbers directly into the\n\t\t * always interned duk_hstring objects (there should be enough\n\t\t * flag bits free for that)?\n\t\t */\n\n\t\ti_end = (strict_mode ? DUK_STRIDX_END_RESERVED : DUK_STRIDX_START_STRICT_RESERVED);\n\n\t\tadvtok = DUK__ADVTOK(0, DUK_TOK_IDENTIFIER);\n\t\tif (out_token->num_escapes == 0) {\n\t\t\tfor (i = DUK_STRIDX_START_RESERVED; i < i_end; i++) {\n\t\t\t\tDUK_ASSERT(i >= 0 && i < DUK_HEAP_NUM_STRINGS);\n\t\t\t\tif (DUK_HTHREAD_GET_STRING(lex_ctx->thr, i) == str) {\n\t\t\t\t\tadvtok = DUK__ADVTOK(0, DUK_STRIDX_TO_TOK(i));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else if (DUK__ISDIGIT(x) || (x == DUK_ASC_PERIOD)) {\n\t\t/* Note: decimal number may start with a period, but must be followed by a digit */\n\n\t\t/*\n\t\t *  Pre-parsing for decimal, hex, octal (both legacy and ES2015),\n\t\t *  and binary literals, followed by an actual parser step\n\t\t *  provided by numconv.\n\t\t *\n\t\t *  Note: the leading sign character ('+' or '-') is -not- part of\n\t\t *  the production in E5 grammar, and that the a DecimalLiteral\n\t\t *  starting with a '0' must be followed by a non-digit.\n\t\t *\n\t\t *  XXX: the two step parsing process is quite awkward, it would\n\t\t *  be more straightforward to allow numconv to parse the longest\n\t\t *  valid prefix (it already does that, it only needs to indicate\n\t\t *  where the input ended).  However, the lexer decodes characters\n\t\t *  using a limited lookup window, so this is not a trivial change.\n\t\t */\n\n\t\t/* XXX: because of the final check below (that the literal is not\n\t\t * followed by a digit), this could maybe be simplified, if we bail\n\t\t * out early from a leading zero (and if there are no periods etc).\n\t\t * Maybe too complex.\n\t\t */\n\n\t\tduk_double_t val;\n\t\tduk_bool_t legacy_oct = 0;\n\t\tduk_small_int_t state;  /* 0=before period/exp,\n\t\t                         * 1=after period, before exp\n\t\t                         * 2=after exp, allow '+' or '-'\n\t\t                         * 3=after exp and exp sign\n\t\t                         */\n\t\tduk_small_uint_t s2n_flags;\n\t\tduk_codepoint_t y, z;\n\t\tduk_small_uint_t s2n_radix = 10;\n\t\tduk_small_uint_t pre_adv = 0;\n\n\t\tDUK__INITBUFFER(lex_ctx);\n\t\ty = DUK__L1();\n\n\t\tif (x == DUK_ASC_0) {\n\t\t\tz = DUK_LOWERCASE_CHAR_ASCII(y);\n\n\t\t\tpre_adv = 2;  /* default for 0xNNN, 0oNNN, 0bNNN. */\n\t\t\tif (z == DUK_ASC_LC_X) {\n\t\t\t\ts2n_radix = 16;\n\t\t\t} else if (z == DUK_ASC_LC_O) {\n\t\t\t\ts2n_radix = 8;\n\t\t\t} else if (z == DUK_ASC_LC_B) {\n\t\t\t\ts2n_radix = 2;\n\t\t\t} else {\n\t\t\t\tpre_adv = 0;\n\t\t\t\tif (DUK__ISDIGIT(y)) {\n\t\t\t\t\tif (strict_mode) {\n\t\t\t\t\t\t/* Reject octal like \\07 but also octal-lookalike\n\t\t\t\t\t\t * decimal like \\08 in strict mode.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tgoto fail_number_literal;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t/* Legacy OctalIntegerLiteral or octal-lookalice\n\t\t\t\t\t\t * decimal.  Deciding between the two happens below\n\t\t\t\t\t\t * in digit scanning.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tDUK__APPENDBUFFER(lex_ctx, x);\n\t\t\t\t\t\tpre_adv = 1;\n\t\t\t\t\t\tlegacy_oct = 1;\n\t\t\t\t\t\ts2n_radix = 8;  /* tentative unless conflicting digits found */\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tDUK__ADVANCECHARS(lex_ctx, pre_adv);\n\n\t\t/* XXX: we could parse integers here directly, and fall back\n\t\t * to numconv only when encountering a fractional expression\n\t\t * or when an octal literal turned out to be decimal (0778 etc).\n\t\t */\n\t\tstate = 0;\n\t\tfor (;;) {\n\t\t\tx = DUK__L0();  /* re-lookup curr char on first round */\n\t\t\tif (DUK__ISDIGIT(x)) {\n\t\t\t\t/* Note: intentionally allow leading zeroes here, as the\n\t\t\t\t * actual parser will check for them.\n\t\t\t\t */\n\t\t\t\tif (state == 0 && legacy_oct && (x == DUK_ASC_8 || x == DUK_ASC_9)) {\n\t\t\t\t\t/* Started out as an octal-lookalike\n\t\t\t\t\t * but interpreted as decimal, e.g.\n\t\t\t\t\t * '0779' -> 779.  This also means\n\t\t\t\t\t * that fractions are allowed, e.g.\n\t\t\t\t\t * '0779.123' is allowed but '0777.123'\n\t\t\t\t\t * is not!\n\t\t\t\t\t */\n\t\t\t\t\ts2n_radix = 10;\n\t\t\t\t}\n\t\t\t\tif (state == 2) {\n\t\t\t\t\tstate = 3;\n\t\t\t\t}\n\t\t\t} else if (s2n_radix == 16 && DUK__ISHEXDIGIT(x)) {\n\t\t\t\t/* Note: 'e' and 'E' are also accepted here. */\n\t\t\t\t;\n\t\t\t} else if (x == DUK_ASC_PERIOD) {\n\t\t\t\tif (state >= 1 || s2n_radix != 10) {\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\tstate = 1;\n\t\t\t\t}\n\t\t\t} else if (x == DUK_ASC_LC_E || x == DUK_ASC_UC_E) {\n\t\t\t\tif (state >= 2 || s2n_radix != 10) {\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\tstate = 2;\n\t\t\t\t}\n\t\t\t} else if (x == DUK_ASC_MINUS || x == DUK_ASC_PLUS) {\n\t\t\t\tif (state != 2) {\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\tstate = 3;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tDUK__APPENDBUFFER(lex_ctx, x);\n\t\t\tDUK__ADVANCECHARS(lex_ctx, 1);\n\t\t}\n\n\t\t/* XXX: better coercion */\n\t\t(void) duk__internbuffer(lex_ctx, lex_ctx->slot1_idx);\n\n\t\tif (s2n_radix != 10) {\n\t\t\t/* For bases other than 10, integer only. */\n\t\t\ts2n_flags = DUK_S2N_FLAG_ALLOW_LEADING_ZERO;\n\t\t} else {\n\t\t\ts2n_flags = DUK_S2N_FLAG_ALLOW_EXP |\n\t\t\t            DUK_S2N_FLAG_ALLOW_FRAC |\n\t\t\t            DUK_S2N_FLAG_ALLOW_NAKED_FRAC |\n\t\t\t            DUK_S2N_FLAG_ALLOW_EMPTY_FRAC |\n\t\t\t            DUK_S2N_FLAG_ALLOW_LEADING_ZERO;\n\t\t}\n\n\t\tduk_dup((duk_context *) lex_ctx->thr, lex_ctx->slot1_idx);\n\t\tduk_numconv_parse((duk_context *) lex_ctx->thr, s2n_radix, s2n_flags);\n\t\tval = duk_to_number_m1((duk_context *) lex_ctx->thr);\n\t\tif (DUK_ISNAN(val)) {\n\t\t\tgoto fail_number_literal;\n\t\t}\n\t\tduk_replace((duk_context *) lex_ctx->thr, lex_ctx->slot1_idx);  /* could also just pop? */\n\n\t\tDUK__INITBUFFER(lex_ctx);  /* free some memory */\n\n\t\t/* Section 7.8.3 (note): NumericLiteral must be followed by something other than\n\t\t * IdentifierStart or DecimalDigit.\n\t\t */\n\n\t\tif (DUK__ISDIGIT(DUK__L0()) || duk_unicode_is_identifier_start(DUK__L0())) {\n\t\t\tgoto fail_number_literal;\n\t\t}\n\n\t\tout_token->num = val;\n\t\tadvtok = DUK__ADVTOK(0, DUK_TOK_NUMBER);\n\t} else if (duk_unicode_is_whitespace(DUK__LOOKUP(lex_ctx, 0))) {\n\t\tDUK__ADVANCECHARS(lex_ctx, 1);\n\t\tgoto restart;\n\t} else if (x < 0) {\n\t\tadvtok = DUK__ADVTOK(0, DUK_TOK_EOF);\n\t} else {\n\t\tgoto fail_token;\n\t}\n skip_slow_path:\n\n\t/*\n\t *  Shared exit path\n\t */\n\n\tDUK__ADVANCEBYTES(lex_ctx, advtok >> 8);\n\tout_token->t = advtok & 0xff;\n\tif (out_token->t_nores < 0) {\n\t\tout_token->t_nores = out_token->t;\n\t}\n\tout_token->lineterm = got_lineterm;\n\n\t/* Automatic semicolon insertion is allowed if a token is preceded\n\t * by line terminator(s), or terminates a statement list (right curly\n\t * or EOF).\n\t */\n\tif (got_lineterm || out_token->t == DUK_TOK_RCURLY || out_token->t == DUK_TOK_EOF) {\n\t\tout_token->allow_auto_semi = 1;\n\t} else {\n\t\tout_token->allow_auto_semi = 0;\n\t}\n\n\treturn;\n\n fail_token_limit:\n\tDUK_ERROR_RANGE(lex_ctx->thr, DUK_STR_TOKEN_LIMIT);\n\treturn;\n\n fail_token:\n\tDUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_TOKEN);\n\treturn;\n\n fail_number_literal:\n\tDUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_NUMBER_LITERAL);\n\treturn;\n\n fail_escape:\n\tDUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_ESCAPE);\n\treturn;\n\n fail_unterm_regexp:\n\tDUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_UNTERMINATED_REGEXP);\n\treturn;\n\n fail_unterm_comment:\n\tDUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_UNTERMINATED_COMMENT);\n\treturn;\n\n#if !defined(DUK_USE_REGEXP_SUPPORT)\n fail_regexp_support:\n\tDUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_REGEXP_SUPPORT_DISABLED);\n\treturn;\n#endif\n}\n\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\n/*\n *  Parse a RegExp token.  The grammar is described in E5 Section 15.10.\n *  Terminal constructions (such as quantifiers) are parsed directly here.\n *\n *  0xffffffffU is used as a marker for \"infinity\" in quantifiers.  Further,\n *  DUK__MAX_RE_QUANT_DIGITS limits the maximum number of digits that\n *  will be accepted for a quantifier.\n */\n\nDUK_INTERNAL void duk_lexer_parse_re_token(duk_lexer_ctx *lex_ctx, duk_re_token *out_token) {\n\tduk_small_int_t advtok = 0;  /* init is unnecessary but suppresses \"may be used uninitialized\" warnings */\n\tduk_codepoint_t x, y;\n\n\tif (++lex_ctx->token_count >= lex_ctx->token_limit) {\n\t\tgoto fail_token_limit;\n\t}\n\n\tDUK_MEMZERO(out_token, sizeof(*out_token));\n\n\tx = DUK__L0();\n\ty = DUK__L1();\n\n\tDUK_DDD(DUK_DDDPRINT(\"parsing regexp token, L0=%ld, L1=%ld\", (long) x, (long) y));\n\n\tswitch (x) {\n\tcase DUK_ASC_PIPE: {\n\t\tadvtok = DUK__ADVTOK(1, DUK_RETOK_DISJUNCTION);\n\t\tbreak;\n\t}\n\tcase DUK_ASC_CARET: {\n\t\tadvtok = DUK__ADVTOK(1, DUK_RETOK_ASSERT_START);\n\t\tbreak;\n\t}\n\tcase DUK_ASC_DOLLAR: {\n\t\tadvtok = DUK__ADVTOK(1, DUK_RETOK_ASSERT_END);\n\t\tbreak;\n\t}\n\tcase DUK_ASC_QUESTION: {\n\t\tout_token->qmin = 0;\n\t\tout_token->qmax = 1;\n\t\tif (y == DUK_ASC_QUESTION) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_RETOK_QUANTIFIER);\n\t\t\tout_token->greedy = 0;\n\t\t} else {\n\t\t\tadvtok = DUK__ADVTOK(1, DUK_RETOK_QUANTIFIER);\n\t\t\tout_token->greedy = 1;\n\t\t}\n\t\tbreak;\n\t}\n\tcase DUK_ASC_STAR: {\n\t\tout_token->qmin = 0;\n\t\tout_token->qmax = DUK_RE_QUANTIFIER_INFINITE;\n\t\tif (y == DUK_ASC_QUESTION) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_RETOK_QUANTIFIER);\n\t\t\tout_token->greedy = 0;\n\t\t} else {\n\t\t\tadvtok = DUK__ADVTOK(1, DUK_RETOK_QUANTIFIER);\n\t\t\tout_token->greedy = 1;\n\t\t}\n\t\tbreak;\n\t}\n\tcase DUK_ASC_PLUS: {\n\t\tout_token->qmin = 1;\n\t\tout_token->qmax = DUK_RE_QUANTIFIER_INFINITE;\n\t\tif (y == DUK_ASC_QUESTION) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_RETOK_QUANTIFIER);\n\t\t\tout_token->greedy = 0;\n\t\t} else {\n\t\t\tadvtok = DUK__ADVTOK(1, DUK_RETOK_QUANTIFIER);\n\t\t\tout_token->greedy = 1;\n\t\t}\n\t\tbreak;\n\t}\n\tcase DUK_ASC_LCURLY: {\n\t\t/* Production allows 'DecimalDigits', including leading zeroes */\n\t\tduk_uint_fast32_t val1 = 0;\n\t\tduk_uint_fast32_t val2 = DUK_RE_QUANTIFIER_INFINITE;\n\t\tduk_small_int_t digits = 0;\n#if defined(DUK_USE_ES6_REGEXP_SYNTAX)\n\t\tduk_lexer_point lex_pt;\n#endif\n\n#if defined(DUK_USE_ES6_REGEXP_SYNTAX)\n\t\t/* Store lexer position, restoring if quantifier is invalid. */\n\t\tDUK_LEXER_GETPOINT(lex_ctx, &lex_pt);\n#endif\n\n\t\tfor (;;) {\n\t\t\tDUK__ADVANCECHARS(lex_ctx, 1);  /* eat '{' on entry */\n\t\t\tx = DUK__L0();\n\t\t\tif (DUK__ISDIGIT(x)) {\n\t\t\t\tdigits++;\n\t\t\t\tval1 = val1 * 10 + (duk_uint_fast32_t) duk__hexval(x);\n\t\t\t} else if (x == DUK_ASC_COMMA) {\n\t\t\t\tif (digits > DUK__MAX_RE_QUANT_DIGITS) {\n\t\t\t\t\tgoto invalid_quantifier;\n\t\t\t\t}\n\t\t\t\tif (val2 != DUK_RE_QUANTIFIER_INFINITE) {\n\t\t\t\t\tgoto invalid_quantifier;\n\t\t\t\t}\n\t\t\t\tif (DUK__L1() == DUK_ASC_RCURLY) {\n\t\t\t\t\t/* form: { DecimalDigits , }, val1 = min count */\n\t\t\t\t\tif (digits == 0) {\n\t\t\t\t\t\tgoto invalid_quantifier;\n\t\t\t\t\t}\n\t\t\t\t\tout_token->qmin = val1;\n\t\t\t\t\tout_token->qmax = DUK_RE_QUANTIFIER_INFINITE;\n\t\t\t\t\tDUK__ADVANCECHARS(lex_ctx, 2);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tval2 = val1;\n\t\t\t\tval1 = 0;\n\t\t\t\tdigits = 0;  /* not strictly necessary because of lookahead '}' above */\n\t\t\t} else if (x == DUK_ASC_RCURLY) {\n\t\t\t\tif (digits > DUK__MAX_RE_QUANT_DIGITS) {\n\t\t\t\t\tgoto invalid_quantifier;\n\t\t\t\t}\n\t\t\t\tif (digits == 0) {\n\t\t\t\t\tgoto invalid_quantifier;\n\t\t\t\t}\n\t\t\t\tif (val2 != DUK_RE_QUANTIFIER_INFINITE) {\n\t\t\t\t\t/* val2 = min count, val1 = max count */\n\t\t\t\t\tout_token->qmin = val2;\n\t\t\t\t\tout_token->qmax = val1;\n\t\t\t\t} else {\n\t\t\t\t\t/* val1 = count */\n\t\t\t\t\tout_token->qmin = val1;\n\t\t\t\t\tout_token->qmax = val1;\n\t\t\t\t}\n\t\t\t\tDUK__ADVANCECHARS(lex_ctx, 1);\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tgoto invalid_quantifier;\n\t\t\t}\n\t\t}\n\t\tif (DUK__L0() == DUK_ASC_QUESTION) {\n\t\t\tout_token->greedy = 0;\n\t\t\tDUK__ADVANCECHARS(lex_ctx, 1);\n\t\t} else {\n\t\t\tout_token->greedy = 1;\n\t\t}\n\t\tadvtok = DUK__ADVTOK(0, DUK_RETOK_QUANTIFIER);\n\t\tbreak;\n invalid_quantifier:\n#if defined(DUK_USE_ES6_REGEXP_SYNTAX)\n\t\t/* Failed to match the quantifier, restore lexer and parse\n\t\t * opening brace as a literal.\n\t\t */\n\t\tDUK_LEXER_SETPOINT(lex_ctx, &lex_pt);\n\t\tadvtok = DUK__ADVTOK(1, DUK_RETOK_ATOM_CHAR);\n\t\tout_token->num = DUK_ASC_LCURLY;\n#else\n\t\tgoto fail_quantifier;\n#endif\n\t\tbreak;\n\t}\n\tcase DUK_ASC_PERIOD: {\n\t\tadvtok = DUK__ADVTOK(1, DUK_RETOK_ATOM_PERIOD);\n\t\tbreak;\n\t}\n\tcase DUK_ASC_BACKSLASH: {\n\t\t/* The E5.1 specification does not seem to allow IdentifierPart characters\n\t\t * to be used as identity escapes.  Unfortunately this includes '$', which\n\t\t * cannot be escaped as '\\$'; it needs to be escaped e.g. as '\\u0024'.\n\t\t * Many other implementations (including V8 and Rhino, for instance) do\n\t\t * accept '\\$' as a valid identity escape, which is quite pragmatic, and\n\t\t * ES2015 Annex B relaxes the rules to allow these (and other) real world forms.\n\t\t */\n\n\t\tadvtok = DUK__ADVTOK(2, DUK_RETOK_ATOM_CHAR);  /* default: char escape (two chars) */\n\t\tif (y == DUK_ASC_LC_B) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_RETOK_ASSERT_WORD_BOUNDARY);\n\t\t} else if (y == DUK_ASC_UC_B) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_RETOK_ASSERT_NOT_WORD_BOUNDARY);\n\t\t} else if (y == DUK_ASC_LC_F) {\n\t\t\tout_token->num = 0x000c;\n\t\t} else if (y == DUK_ASC_LC_N) {\n\t\t\tout_token->num = 0x000a;\n\t\t} else if (y == DUK_ASC_LC_T) {\n\t\t\tout_token->num = 0x0009;\n\t\t} else if (y == DUK_ASC_LC_R) {\n\t\t\tout_token->num = 0x000d;\n\t\t} else if (y == DUK_ASC_LC_V) {\n\t\t\tout_token->num = 0x000b;\n\t\t} else if (y == DUK_ASC_LC_C) {\n\t\t\tx = DUK__L2();\n\t\t\tif ((x >= DUK_ASC_LC_A && x <= DUK_ASC_LC_Z) ||\n\t\t\t    (x >= DUK_ASC_UC_A && x <= DUK_ASC_UC_Z)) {\n\t\t\t\tout_token->num = (x % 32);\n\t\t\t\tadvtok = DUK__ADVTOK(3, DUK_RETOK_ATOM_CHAR);\n\t\t\t} else {\n\t\t\t\tgoto fail_escape;\n\t\t\t}\n\t\t} else if (y == DUK_ASC_LC_X || y == DUK_ASC_LC_U) {\n\t\t\t/* The token value is the Unicode codepoint without\n\t\t\t * it being decode into surrogate pair characters\n\t\t\t * here.  The \\u{H+} is only allowed in Unicode mode\n\t\t\t * which we don't support yet.\n\t\t\t */\n\t\t\tout_token->num = duk__lexer_parse_escape(lex_ctx, 0 /*allow_es6*/);\n\t\t\tadvtok = DUK__ADVTOK(0, DUK_RETOK_ATOM_CHAR);\n\t\t} else if (y == DUK_ASC_LC_D) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_RETOK_ATOM_DIGIT);\n\t\t} else if (y == DUK_ASC_UC_D) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_RETOK_ATOM_NOT_DIGIT);\n\t\t} else if (y == DUK_ASC_LC_S) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_RETOK_ATOM_WHITE);\n\t\t} else if (y == DUK_ASC_UC_S) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_RETOK_ATOM_NOT_WHITE);\n\t\t} else if (y == DUK_ASC_LC_W) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_RETOK_ATOM_WORD_CHAR);\n\t\t} else if (y == DUK_ASC_UC_W) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_RETOK_ATOM_NOT_WORD_CHAR);\n\t\t} else if (DUK__ISDIGIT(y)) {\n\t\t\t/* E5 Section 15.10.2.11 */\n\t\t\tif (y == DUK_ASC_0) {\n\t\t\t\tif (DUK__ISDIGIT(DUK__L2())) {\n\t\t\t\t\tgoto fail_escape;\n\t\t\t\t}\n\t\t\t\tout_token->num = 0x0000;\n\t\t\t\tadvtok = DUK__ADVTOK(2, DUK_RETOK_ATOM_CHAR);\n\t\t\t} else {\n\t\t\t\t/* XXX: shared parsing? */\n\t\t\t\tduk_uint_fast32_t val = 0;\n\t\t\t\tduk_small_int_t i;\n\t\t\t\tfor (i = 0; ; i++) {\n\t\t\t\t\tif (i >= DUK__MAX_RE_DECESC_DIGITS) {\n\t\t\t\t\t\tgoto fail_escape;\n\t\t\t\t\t}\n\t\t\t\t\tDUK__ADVANCECHARS(lex_ctx, 1);  /* eat backslash on entry */\n\t\t\t\t\tx = DUK__L0();\n\t\t\t\t\tif (!DUK__ISDIGIT(x)) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tval = val * 10 + (duk_uint_fast32_t) duk__hexval(x);\n\t\t\t\t}\n\t\t\t\t/* DUK__L0() cannot be a digit, because the loop doesn't terminate if it is */\n\t\t\t\tadvtok = DUK__ADVTOK(0, DUK_RETOK_ATOM_BACKREFERENCE);\n\t\t\t\tout_token->num = val;\n\t\t\t}\n#if defined(DUK_USE_ES6_REGEXP_SYNTAX)\n\t\t} else if (y >= 0) {\n\t\t\t/* For ES2015 Annex B, accept any source character as identity\n\t\t\t * escape except 'c' which is used for control characters.\n\t\t\t * http://www.ecma-international.org/ecma-262/6.0/#sec-regular-expressions-patterns\n\t\t\t * Careful not to match end-of-buffer (<0) here.\n\t\t\t * This is not yet full ES2015 Annex B because cases above\n\t\t\t * (like hex escape) won't backtrack.\n\t\t\t */\n\t\t\tDUK_ASSERT(y != DUK_ASC_LC_C);  /* covered above */\n#else  /* DUK_USE_ES6_REGEXP_SYNTAX */\n\t\t} else if ((y >= 0 && !duk_unicode_is_identifier_part(y)) ||\n\t\t           y == DUK_UNICODE_CP_ZWNJ ||\n\t\t           y == DUK_UNICODE_CP_ZWJ) {\n\t\t\t/* For ES5.1 identity escapes are not allowed for identifier\n\t\t\t * parts.  This conflicts with a lot of real world code as this\n\t\t\t * doesn't e.g. allow escaping a dollar sign as /\\$/, see\n\t\t\t * test-regexp-identity-escape-dollar.js.\n\t\t\t */\n#endif  /* DUK_USE_ES6_REGEXP_SYNTAX */\n\t\t\tout_token->num = y;\n\t\t} else {\n\t\t\tgoto fail_escape;\n\t\t}\n\t\tbreak;\n\t}\n\tcase DUK_ASC_LPAREN: {\n\t\t/* XXX: naming is inconsistent: ATOM_END_GROUP ends an ASSERT_START_LOOKAHEAD */\n\n\t\tif (y == DUK_ASC_QUESTION) {\n\t\t\tif (DUK__L2() == DUK_ASC_EQUALS) {\n\t\t\t\t/* (?= */\n\t\t\t\tadvtok = DUK__ADVTOK(3, DUK_RETOK_ASSERT_START_POS_LOOKAHEAD);\n\t\t\t} else if (DUK__L2() == DUK_ASC_EXCLAMATION) {\n\t\t\t\t/* (?! */\n\t\t\t\tadvtok = DUK__ADVTOK(3, DUK_RETOK_ASSERT_START_NEG_LOOKAHEAD);\n\t\t\t} else if (DUK__L2() == DUK_ASC_COLON) {\n\t\t\t\t/* (?: */\n\t\t\t\tadvtok = DUK__ADVTOK(3, DUK_RETOK_ATOM_START_NONCAPTURE_GROUP);\n\t\t\t} else {\n\t\t\t\tgoto fail_group;\n\t\t\t}\n\t\t} else {\n\t\t\t/* ( */\n\t\t\tadvtok = DUK__ADVTOK(1, DUK_RETOK_ATOM_START_CAPTURE_GROUP);\n\t\t}\n\t\tbreak;\n\t}\n\tcase DUK_ASC_RPAREN: {\n\t\tadvtok = DUK__ADVTOK(1, DUK_RETOK_ATOM_END_GROUP);\n\t\tbreak;\n\t}\n\tcase DUK_ASC_LBRACKET: {\n\t\t/*\n\t\t *  To avoid creating a heavy intermediate value for the list of ranges,\n\t\t *  only the start token ('[' or '[^') is parsed here.  The regexp\n\t\t *  compiler parses the ranges itself.\n\t\t */\n\n\t\t/* XXX: with DUK_USE_ES6_REGEXP_SYNTAX we should allow left bracket\n\t\t * literal too, but it's not easy to parse without backtracking.\n\t\t */\n\n\t\tadvtok = DUK__ADVTOK(1, DUK_RETOK_ATOM_START_CHARCLASS);\n\t\tif (y == DUK_ASC_CARET) {\n\t\t\tadvtok = DUK__ADVTOK(2, DUK_RETOK_ATOM_START_CHARCLASS_INVERTED);\n\t\t}\n\t\tbreak;\n\t}\n#if !defined(DUK_USE_ES6_REGEXP_SYNTAX)\n\tcase DUK_ASC_RCURLY:\n\tcase DUK_ASC_RBRACKET: {\n\t\t/* Although these could be parsed as PatternCharacters unambiguously (here),\n\t\t * E5 Section 15.10.1 grammar explicitly forbids these as PatternCharacters.\n\t\t */\n\t\tgoto fail_invalid_char;\n\t\tbreak;\n\t}\n#endif\n\tcase -1: {\n\t\t/* EOF */\n\t\tadvtok = DUK__ADVTOK(0, DUK_TOK_EOF);\n\t\tbreak;\n\t}\n\tdefault: {\n\t\t/* PatternCharacter, all excluded characters are matched by cases above */\n\t\tadvtok = DUK__ADVTOK(1, DUK_RETOK_ATOM_CHAR);\n\t\tout_token->num = x;\n\t\tbreak;\n\t}\n\t}\n\n\t/*\n\t *  Shared exit path\n\t */\n\n\tDUK__ADVANCEBYTES(lex_ctx, advtok >> 8);\n\tout_token->t = advtok & 0xff;\n\treturn;\n\n fail_token_limit:\n\tDUK_ERROR_RANGE(lex_ctx->thr, DUK_STR_TOKEN_LIMIT);\n\treturn;\n\n fail_escape:\n\tDUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_REGEXP_ESCAPE);\n\treturn;\n\n fail_group:\n\tDUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_REGEXP_GROUP);\n\treturn;\n\n#if !defined(DUK_USE_ES6_REGEXP_SYNTAX)\n fail_invalid_char:\n\tDUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_REGEXP_CHARACTER);\n\treturn;\n\n fail_quantifier:\n\tDUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_QUANTIFIER);\n\treturn;\n#endif\n}\n\n/*\n *  Special parser for character classes; calls callback for every\n *  range parsed and returns the number of ranges present.\n */\n\n/* XXX: this duplicates functionality in duk_regexp.c where a similar loop is\n * required anyway.  We could use that BUT we need to update the regexp compiler\n * 'nranges' too.  Work this out a bit more cleanly to save space.\n */\n\n/* XXX: the handling of character range detection is a bit convoluted.\n * Try to simplify and make smaller.\n */\n\n/* XXX: logic for handling character ranges is now incorrect, it will accept\n * e.g. [\\d-z] whereas it should croak from it?  SMJS accepts this too, though.\n *\n * Needs a read through and a lot of additional tests.\n */\n\nDUK_LOCAL\nvoid duk__emit_u16_direct_ranges(duk_lexer_ctx *lex_ctx,\n                                 duk_re_range_callback gen_range,\n                                 void *userdata,\n                                 const duk_uint16_t *ranges,\n                                 duk_small_int_t num) {\n\tconst duk_uint16_t *ranges_end;\n\n\tDUK_UNREF(lex_ctx);\n\n\tranges_end = ranges + num;\n\twhile (ranges < ranges_end) {\n\t\t/* mark range 'direct', bypass canonicalization (see Wiki) */\n\t\tgen_range(userdata, (duk_codepoint_t) ranges[0], (duk_codepoint_t) ranges[1], 1);\n\t\tranges += 2;\n\t}\n}\n\nDUK_INTERNAL void duk_lexer_parse_re_ranges(duk_lexer_ctx *lex_ctx, duk_re_range_callback gen_range, void *userdata) {\n\tduk_codepoint_t start = -1;\n\tduk_codepoint_t ch;\n\tduk_codepoint_t x;\n\tduk_bool_t dash = 0;\n\tduk_small_int_t adv = 0;\n\n\tDUK_DD(DUK_DDPRINT(\"parsing regexp ranges\"));\n\n\tfor (;;) {\n\t\tDUK__ADVANCECHARS(lex_ctx, adv);\n\t\tadv = 1;\n\n\t\tx = DUK__L0();\n\n\t\tch = -1;  /* not strictly necessary, but avoids \"uninitialized variable\" warnings */\n\t\tDUK_UNREF(ch);\n\n\t\tif (x < 0) {\n\t\t\tgoto fail_unterm_charclass;\n\t\t} else if (x == DUK_ASC_RBRACKET) {\n\t\t\tif (start >= 0) {\n\t\t\t\tgen_range(userdata, start, start, 0);\n\t\t\t}\n\t\t\tDUK__ADVANCECHARS(lex_ctx, 1);  /* eat ']' before finishing */\n\t\t\tbreak;\n\t\t} else if (x == DUK_ASC_MINUS) {\n\t\t\tif (start >= 0 && !dash && DUK__L0() != DUK_ASC_RBRACKET) {\n\t\t\t\t/* '-' as a range indicator */\n\t\t\t\tdash = 1;\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\t/* '-' verbatim */\n\t\t\t\tch = x;\n\t\t\t}\n\t\t} else if (x == DUK_ASC_BACKSLASH) {\n\t\t\t/*\n\t\t\t *  The escapes are same as outside a character class, except that \\b has a\n\t\t\t *  different meaning, and \\B and backreferences are prohibited (see E5\n\t\t\t *  Section 15.10.2.19).  However, it's difficult to share code because we\n\t\t\t *  handle e.g. \"\\n\" very differently: here we generate a single character\n\t\t\t *  range for it.\n\t\t\t */\n\n\t\t\t/* XXX: ES2015 surrogate pair handling. */\n\n\t\t\tx = DUK__L1();\n\n\t\t\tadv = 2;\n\n\t\t\tif (x == DUK_ASC_LC_B) {\n\t\t\t\t/* Note: '\\b' in char class is different than outside (assertion),\n\t\t\t\t * '\\B' is not allowed and is caught by the duk_unicode_is_identifier_part()\n\t\t\t\t * check below.\n\t\t\t\t */\n\t\t\t\tch = 0x0008;\n\t\t\t} else if (x == DUK_ASC_LC_F) {\n\t\t\t\tch = 0x000c;\n\t\t\t} else if (x == DUK_ASC_LC_N) {\n\t\t\t\tch = 0x000a;\n\t\t\t} else if (x == DUK_ASC_LC_T) {\n\t\t\t\tch = 0x0009;\n\t\t\t} else if (x == DUK_ASC_LC_R) {\n\t\t\t\tch = 0x000d;\n\t\t\t} else if (x == DUK_ASC_LC_V) {\n\t\t\t\tch = 0x000b;\n\t\t\t} else if (x == DUK_ASC_LC_C) {\n\t\t\t\tx = DUK__L2();\n\t\t\t\tadv = 3;\n\t\t\t\tif ((x >= DUK_ASC_LC_A && x <= DUK_ASC_LC_Z) ||\n\t\t\t\t    (x >= DUK_ASC_UC_A && x <= DUK_ASC_UC_Z)) {\n\t\t\t\t\tch = (x % 32);\n\t\t\t\t} else {\n\t\t\t\t\tgoto fail_escape;\n\t\t\t\t}\n\t\t\t} else if (x == DUK_ASC_LC_X || x == DUK_ASC_LC_U) {\n\t\t\t\t/* The \\u{H+} form is only allowed in Unicode mode which\n\t\t\t\t * we don't support yet.\n\t\t\t\t */\n\t\t\t\tch = duk__lexer_parse_escape(lex_ctx, 0 /*allow_es6*/);\n\t\t\t\tadv = 0;\n\t\t\t} else if (x == DUK_ASC_LC_D) {\n\t\t\t\tduk__emit_u16_direct_ranges(lex_ctx,\n\t\t\t\t                            gen_range,\n\t\t\t\t                            userdata,\n\t\t\t\t                            duk_unicode_re_ranges_digit,\n\t\t\t\t                            sizeof(duk_unicode_re_ranges_digit) / sizeof(duk_uint16_t));\n\t\t\t\tch = -1;\n\t\t\t} else if (x == DUK_ASC_UC_D) {\n\t\t\t\tduk__emit_u16_direct_ranges(lex_ctx,\n\t\t\t\t                            gen_range,\n\t\t\t\t                            userdata,\n\t\t\t\t                            duk_unicode_re_ranges_not_digit,\n\t\t\t\t                            sizeof(duk_unicode_re_ranges_not_digit) / sizeof(duk_uint16_t));\n\t\t\t\tch = -1;\n\t\t\t} else if (x == DUK_ASC_LC_S) {\n\t\t\t\tduk__emit_u16_direct_ranges(lex_ctx,\n\t\t\t\t                            gen_range,\n\t\t\t\t                            userdata,\n\t\t\t\t                            duk_unicode_re_ranges_white,\n\t\t\t\t                            sizeof(duk_unicode_re_ranges_white) / sizeof(duk_uint16_t));\n\t\t\t\tch = -1;\n\t\t\t} else if (x == DUK_ASC_UC_S) {\n\t\t\t\tduk__emit_u16_direct_ranges(lex_ctx,\n\t\t\t\t                            gen_range,\n\t\t\t\t                            userdata,\n\t\t\t\t                            duk_unicode_re_ranges_not_white,\n\t\t\t\t                            sizeof(duk_unicode_re_ranges_not_white) / sizeof(duk_uint16_t));\n\t\t\t\tch = -1;\n\t\t\t} else if (x == DUK_ASC_LC_W) {\n\t\t\t\tduk__emit_u16_direct_ranges(lex_ctx,\n\t\t\t\t                            gen_range,\n\t\t\t\t                            userdata,\n\t\t\t\t                            duk_unicode_re_ranges_wordchar,\n\t\t\t\t                            sizeof(duk_unicode_re_ranges_wordchar) / sizeof(duk_uint16_t));\n\t\t\t\tch = -1;\n\t\t\t} else if (x == DUK_ASC_UC_W) {\n\t\t\t\tduk__emit_u16_direct_ranges(lex_ctx,\n\t\t\t\t                            gen_range,\n\t\t\t\t                            userdata,\n\t\t\t\t                            duk_unicode_re_ranges_not_wordchar,\n\t\t\t\t                            sizeof(duk_unicode_re_ranges_not_wordchar) / sizeof(duk_uint16_t));\n\t\t\t\tch = -1;\n\t\t\t} else if (DUK__ISDIGIT(x)) {\n\t\t\t\t/* DecimalEscape, only \\0 is allowed, no leading\n\t\t\t\t * zeroes are allowed.\n\t\t\t\t *\n\t\t\t\t * ES2015 Annex B also allows (maximal match) legacy\n\t\t\t\t * octal escapes up to \\377 and \\8 and \\9 are\n\t\t\t\t * accepted as literal '8' and '9', also in strict mode.\n\t\t\t\t */\n\n#if defined(DUK_USE_ES6_REGEXP_SYNTAX)\n\t\t\t\tch = duk__lexer_parse_legacy_octal(lex_ctx, &adv, 0 /*reject_annex_b*/);\n\t\t\t\tDUK_ASSERT(ch >= 0);  /* no rejections */\n#else\n\t\t\t\tif (x == DUK_ASC_0 && !DUK__ISDIGIT(DUK__L2())) {\n\t\t\t\t\tch = 0x0000;\n\t\t\t\t} else {\n\t\t\t\t\tgoto fail_escape;\n\t\t\t\t}\n#endif\n#if defined(DUK_USE_ES6_REGEXP_SYNTAX)\n\t\t\t} else if (x >= 0) {\n\t\t\t\t/* IdentityEscape: ES2015 Annex B allows almost all\n\t\t\t\t * source characters here.  Match anything except\n\t\t\t\t * EOF here.\n\t\t\t\t */\n\t\t\t\tch = x;\n#else  /* DUK_USE_ES6_REGEXP_SYNTAX */\n\t\t\t} else if (!duk_unicode_is_identifier_part(x)) {\n\t\t\t\t/* IdentityEscape: ES5.1 doesn't allow identity escape\n\t\t\t\t * for identifier part characters, which conflicts with\n\t\t\t\t * some real world code.  For example, it doesn't allow\n\t\t\t\t * /[\\$]/ which is awkward.\n\t\t\t\t */\n\t\t\t\tch = x;\n#endif  /* DUK_USE_ES6_REGEXP_SYNTAX */\n\t\t\t} else {\n\t\t\t\tgoto fail_escape;\n\t\t\t}\n\t\t} else {\n\t\t\t/* character represents itself */\n\t\t\tch = x;\n\t\t}\n\n\t\t/* ch is a literal character here or -1 if parsed entity was\n\t\t * an escape such as \"\\s\".\n\t\t */\n\n\t\tif (ch < 0) {\n\t\t\t/* multi-character sets not allowed as part of ranges, see\n\t\t\t * E5 Section 15.10.2.15, abstract operation CharacterRange.\n\t\t\t */\n\t\t\tif (start >= 0) {\n\t\t\t\tif (dash) {\n\t\t\t\t\tgoto fail_range;\n\t\t\t\t} else {\n\t\t\t\t\tgen_range(userdata, start, start, 0);\n\t\t\t\t\tstart = -1;\n\t\t\t\t\t/* dash is already 0 */\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tif (start >= 0) {\n\t\t\t\tif (dash) {\n\t\t\t\t\tif (start > ch) {\n\t\t\t\t\t\tgoto fail_range;\n\t\t\t\t\t}\n\t\t\t\t\tgen_range(userdata, start, ch, 0);\n\t\t\t\t\tstart = -1;\n\t\t\t\t\tdash = 0;\n\t\t\t\t} else {\n\t\t\t\t\tgen_range(userdata, start, start, 0);\n\t\t\t\t\tstart = ch;\n\t\t\t\t\t/* dash is already 0 */\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tstart = ch;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn;\n\n fail_escape:\n\tDUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_REGEXP_ESCAPE);\n\treturn;\n\n fail_range:\n\tDUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_INVALID_RANGE);\n\treturn;\n\n fail_unterm_charclass:\n\tDUK_ERROR_SYNTAX(lex_ctx->thr, DUK_STR_UNTERMINATED_CHARCLASS);\n\treturn;\n}\n\n#endif  /* DUK_USE_REGEXP_SUPPORT */\n\n/* automatic undefs */\n#undef DUK__ADVANCEBYTES\n#undef DUK__ADVANCECHARS\n#undef DUK__ADVTOK\n#undef DUK__APPENDBUFFER\n#undef DUK__APPENDBUFFER_ASCII\n#undef DUK__INITBUFFER\n#undef DUK__ISDIGIT\n#undef DUK__ISDIGIT03\n#undef DUK__ISDIGIT47\n#undef DUK__ISHEXDIGIT\n#undef DUK__ISOCTDIGIT\n#undef DUK__L0\n#undef DUK__L1\n#undef DUK__L2\n#undef DUK__L3\n#undef DUK__L4\n#undef DUK__L5\n#undef DUK__LOOKUP\n#undef DUK__MAX_RE_DECESC_DIGITS\n#undef DUK__MAX_RE_QUANT_DIGITS\n/*\n *  Number-to-string and string-to-number conversions.\n *\n *  Slow path number-to-string and string-to-number conversion is based on\n *  a Dragon4 variant, with fast paths for small integers.  Big integer\n *  arithmetic is needed for guaranteeing that the conversion is correct\n *  and uses a minimum number of digits.  The big number arithmetic has a\n *  fixed maximum size and does not require dynamic allocations.\n *\n *  See: doc/number-conversion.rst.\n */\n\n/* #include duk_internal.h -> already included */\n\n#define DUK__IEEE_DOUBLE_EXP_BIAS  1023\n#define DUK__IEEE_DOUBLE_EXP_MIN   (-1022)   /* biased exp == 0 -> denormal, exp -1022 */\n\n#define DUK__DIGITCHAR(x)  duk_lc_digits[(x)]\n\n/*\n *  Tables generated with util/gennumdigits.py.\n *\n *  duk__str2num_digits_for_radix indicates, for each radix, how many input\n *  digits should be considered significant for string-to-number conversion.\n *  The input is also padded to this many digits to give the Dragon4\n *  conversion enough (apparent) precision to work with.\n *\n *  duk__str2num_exp_limits indicates, for each radix, the radix-specific\n *  minimum/maximum exponent values (for a Dragon4 integer mantissa)\n *  below and above which the number is guaranteed to underflow to zero\n *  or overflow to Infinity.  This allows parsing to keep bigint values\n *  bounded.\n */\n\nDUK_LOCAL const duk_uint8_t duk__str2num_digits_for_radix[] = {\n\t69, 44, 35, 30, 27, 25, 23, 22, 20, 20,    /* 2 to 11 */\n\t20, 19, 19, 18, 18, 17, 17, 17, 16, 16,    /* 12 to 21 */\n\t16, 16, 16, 15, 15, 15, 15, 15, 15, 14,    /* 22 to 31 */\n\t14, 14, 14, 14, 14                         /* 31 to 36 */\n};\n\ntypedef struct {\n\tduk_int16_t upper;\n\tduk_int16_t lower;\n} duk__exp_limits;\n\nDUK_LOCAL const duk__exp_limits duk__str2num_exp_limits[] = {\n\t{ 957, -1147 }, { 605, -725 },  { 479, -575 },  { 414, -496 },\n\t{ 372, -446 },  { 342, -411 },  { 321, -384 },  { 304, -364 },\n\t{ 291, -346 },  { 279, -334 },  { 268, -323 },  { 260, -312 },\n\t{ 252, -304 },  { 247, -296 },  { 240, -289 },  { 236, -283 },\n\t{ 231, -278 },  { 227, -273 },  { 223, -267 },  { 220, -263 },\n\t{ 216, -260 },  { 213, -256 },  { 210, -253 },  { 208, -249 },\n\t{ 205, -246 },  { 203, -244 },  { 201, -241 },  { 198, -239 },\n\t{ 196, -237 },  { 195, -234 },  { 193, -232 },  { 191, -230 },\n\t{ 190, -228 },  { 188, -226 },  { 187, -225 },\n};\n\n/*\n *  Limited functionality bigint implementation.\n *\n *  Restricted to non-negative numbers with less than 32 * DUK__BI_MAX_PARTS bits,\n *  with the caller responsible for ensuring this is never exceeded.  No memory\n *  allocation (except stack) is needed for bigint computation.  Operations\n *  have been tailored for number conversion needs.\n *\n *  Argument order is \"assignment order\", i.e. target first, then arguments:\n *  x <- y * z  -->  duk__bi_mul(x, y, z);\n */\n\n/* This upper value has been experimentally determined; debug build will check\n * bigint size with assertions.\n */\n#define DUK__BI_MAX_PARTS  37  /* 37x32 = 1184 bits */\n\n#if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 2)\n#define DUK__BI_PRINT(name,x)  duk__bi_print((name),(x))\n#else\n#define DUK__BI_PRINT(name,x)\n#endif\n\n/* Current size is about 152 bytes. */\ntypedef struct {\n\tduk_small_int_t n;\n\tduk_uint32_t v[DUK__BI_MAX_PARTS];  /* low to high */\n} duk__bigint;\n\n#if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 2)\nDUK_LOCAL void duk__bi_print(const char *name, duk__bigint *x) {\n\t/* Overestimate required size; debug code so not critical to be tight. */\n\tchar buf[DUK__BI_MAX_PARTS * 9 + 64];\n\tchar *p = buf;\n\tduk_small_int_t i;\n\n\t/* No NUL term checks in this debug code. */\n\tp += DUK_SPRINTF(p, \"%p n=%ld\", (void *) x, (long) x->n);\n\tif (x->n == 0) {\n\t\tp += DUK_SPRINTF(p, \" 0\");\n\t}\n\tfor (i = x->n - 1; i >= 0; i--) {\n\t\tp += DUK_SPRINTF(p, \" %08lx\", (unsigned long) x->v[i]);\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"%s: %s\", (const char *) name, (const char *) buf));\n}\n#endif\n\n#if defined(DUK_USE_ASSERTIONS)\nDUK_LOCAL duk_small_int_t duk__bi_is_valid(duk__bigint *x) {\n\treturn (duk_small_int_t)\n\t       ( ((x->n >= 0) && (x->n <= DUK__BI_MAX_PARTS)) /* is valid size */ &&\n\t         ((x->n == 0) || (x->v[x->n - 1] != 0)) /* is normalized */ );\n}\n#endif\n\nDUK_LOCAL void duk__bi_normalize(duk__bigint *x) {\n\tduk_small_int_t i;\n\n\tfor (i = x->n - 1; i >= 0; i--) {\n\t\tif (x->v[i] != 0) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t/* Note: if 'x' is zero, x->n becomes 0 here */\n\tx->n = i + 1;\n\tDUK_ASSERT(duk__bi_is_valid(x));\n}\n\n/* x <- y */\nDUK_LOCAL void duk__bi_copy(duk__bigint *x, duk__bigint *y) {\n\tduk_small_int_t n;\n\n\tn = y->n;\n\tx->n = n;\n\tif (n == 0) {\n\t\treturn;\n\t}\n\tDUK_MEMCPY((void *) x->v, (const void *) y->v, (size_t) (sizeof(duk_uint32_t) * n));\n}\n\nDUK_LOCAL void duk__bi_set_small(duk__bigint *x, duk_uint32_t v) {\n\tif (v == 0U) {\n\t\tx->n = 0;\n\t} else {\n\t\tx->n = 1;\n\t\tx->v[0] = v;\n\t}\n\tDUK_ASSERT(duk__bi_is_valid(x));\n}\n\n/* Return value: <0  <=>  x < y\n *                0  <=>  x == y\n *               >0  <=>  x > y\n */\nDUK_LOCAL int duk__bi_compare(duk__bigint *x, duk__bigint *y) {\n\tduk_small_int_t i, nx, ny;\n\tduk_uint32_t tx, ty;\n\n\tDUK_ASSERT(duk__bi_is_valid(x));\n\tDUK_ASSERT(duk__bi_is_valid(y));\n\n\tnx = x->n;\n\tny = y->n;\n\tif (nx > ny) {\n\t\tgoto ret_gt;\n\t}\n\tif (nx < ny) {\n\t\tgoto ret_lt;\n\t}\n\tfor (i = nx - 1; i >= 0; i--) {\n\t\ttx = x->v[i];\n\t\tty = y->v[i];\n\n\t\tif (tx > ty) {\n\t\t\tgoto ret_gt;\n\t\t}\n\t\tif (tx < ty) {\n\t\t\tgoto ret_lt;\n\t\t}\n\t}\n\n\treturn 0;\n\n ret_gt:\n\treturn 1;\n\n ret_lt:\n\treturn -1;\n}\n\n/* x <- y + z */\n#if defined(DUK_USE_64BIT_OPS)\nDUK_LOCAL void duk__bi_add(duk__bigint *x, duk__bigint *y, duk__bigint *z) {\n\tduk_uint64_t tmp;\n\tduk_small_int_t i, ny, nz;\n\n\tDUK_ASSERT(duk__bi_is_valid(y));\n\tDUK_ASSERT(duk__bi_is_valid(z));\n\n\tif (z->n > y->n) {\n\t\tduk__bigint *t;\n\t\tt = y; y = z; z = t;\n\t}\n\tDUK_ASSERT(y->n >= z->n);\n\n\tny = y->n; nz = z->n;\n\ttmp = 0U;\n\tfor (i = 0; i < ny; i++) {\n\t\tDUK_ASSERT(i < DUK__BI_MAX_PARTS);\n\t\ttmp += y->v[i];\n\t\tif (i < nz) {\n\t\t\ttmp += z->v[i];\n\t\t}\n\t\tx->v[i] = (duk_uint32_t) (tmp & 0xffffffffUL);\n\t\ttmp = tmp >> 32;\n\t}\n\tif (tmp != 0U) {\n\t\tDUK_ASSERT(i < DUK__BI_MAX_PARTS);\n\t\tx->v[i++] = (duk_uint32_t) tmp;\n\t}\n\tx->n = i;\n\tDUK_ASSERT(x->n <= DUK__BI_MAX_PARTS);\n\n\t/* no need to normalize */\n\tDUK_ASSERT(duk__bi_is_valid(x));\n}\n#else  /* DUK_USE_64BIT_OPS */\nDUK_LOCAL void duk__bi_add(duk__bigint *x, duk__bigint *y, duk__bigint *z) {\n\tduk_uint32_t carry, tmp1, tmp2;\n\tduk_small_int_t i, ny, nz;\n\n\tDUK_ASSERT(duk__bi_is_valid(y));\n\tDUK_ASSERT(duk__bi_is_valid(z));\n\n\tif (z->n > y->n) {\n\t\tduk__bigint *t;\n\t\tt = y; y = z; z = t;\n\t}\n\tDUK_ASSERT(y->n >= z->n);\n\n\tny = y->n; nz = z->n;\n\tcarry = 0U;\n\tfor (i = 0; i < ny; i++) {\n\t\t/* Carry is detected based on wrapping which relies on exact 32-bit\n\t\t * types.\n\t\t */\n\t\tDUK_ASSERT(i < DUK__BI_MAX_PARTS);\n\t\ttmp1 = y->v[i];\n\t\ttmp2 = tmp1;\n\t\tif (i < nz) {\n\t\t\ttmp2 += z->v[i];\n\t\t}\n\n\t\t/* Careful with carry condition:\n\t\t *  - If carry not added: 0x12345678 + 0 + 0xffffffff = 0x12345677 (< 0x12345678)\n\t\t *  - If carry added:     0x12345678 + 1 + 0xffffffff = 0x12345678 (== 0x12345678)\n\t\t */\n\t\tif (carry) {\n\t\t\ttmp2++;\n\t\t\tcarry = (tmp2 <= tmp1 ? 1U : 0U);\n\t\t} else {\n\t\t\tcarry = (tmp2 < tmp1 ? 1U : 0U);\n\t\t}\n\n\t\tx->v[i] = tmp2;\n\t}\n\tif (carry) {\n\t\tDUK_ASSERT(i < DUK__BI_MAX_PARTS);\n\t\tDUK_ASSERT(carry == 1U);\n\t\tx->v[i++] = carry;\n\t}\n\tx->n = i;\n\tDUK_ASSERT(x->n <= DUK__BI_MAX_PARTS);\n\n\t/* no need to normalize */\n\tDUK_ASSERT(duk__bi_is_valid(x));\n}\n#endif  /* DUK_USE_64BIT_OPS */\n\n/* x <- y + z */\nDUK_LOCAL void duk__bi_add_small(duk__bigint *x, duk__bigint *y, duk_uint32_t z) {\n\tduk__bigint tmp;\n\n\tDUK_ASSERT(duk__bi_is_valid(y));\n\n\t/* XXX: this could be optimized; there is only one call site now though */\n\tduk__bi_set_small(&tmp, z);\n\tduk__bi_add(x, y, &tmp);\n\n\tDUK_ASSERT(duk__bi_is_valid(x));\n}\n\n#if 0  /* unused */\n/* x <- x + y, use t as temp */\nDUK_LOCAL void duk__bi_add_copy(duk__bigint *x, duk__bigint *y, duk__bigint *t) {\n\tduk__bi_add(t, x, y);\n\tduk__bi_copy(x, t);\n}\n#endif\n\n/* x <- y - z, require x >= y => z >= 0, i.e. y >= z */\n#if defined(DUK_USE_64BIT_OPS)\nDUK_LOCAL void duk__bi_sub(duk__bigint *x, duk__bigint *y, duk__bigint *z) {\n\tduk_small_int_t i, ny, nz;\n\tduk_uint32_t ty, tz;\n\tduk_int64_t tmp;\n\n\tDUK_ASSERT(duk__bi_is_valid(y));\n\tDUK_ASSERT(duk__bi_is_valid(z));\n\tDUK_ASSERT(duk__bi_compare(y, z) >= 0);\n\tDUK_ASSERT(y->n >= z->n);\n\n\tny = y->n; nz = z->n;\n\ttmp = 0;\n\tfor (i = 0; i < ny; i++) {\n\t\tty = y->v[i];\n\t\tif (i < nz) {\n\t\t\ttz = z->v[i];\n\t\t} else {\n\t\t\ttz = 0;\n\t\t}\n\t\ttmp = (duk_int64_t) ty - (duk_int64_t) tz + tmp;\n\t\tx->v[i] = (duk_uint32_t) (tmp & 0xffffffffUL);\n\t\ttmp = tmp >> 32;  /* 0 or -1 */\n\t}\n\tDUK_ASSERT(tmp == 0);\n\n\tx->n = i;\n\tduk__bi_normalize(x);  /* need to normalize, may even cancel to 0 */\n\tDUK_ASSERT(duk__bi_is_valid(x));\n}\n#else\nDUK_LOCAL void duk__bi_sub(duk__bigint *x, duk__bigint *y, duk__bigint *z) {\n\tduk_small_int_t i, ny, nz;\n\tduk_uint32_t tmp1, tmp2, borrow;\n\n\tDUK_ASSERT(duk__bi_is_valid(y));\n\tDUK_ASSERT(duk__bi_is_valid(z));\n\tDUK_ASSERT(duk__bi_compare(y, z) >= 0);\n\tDUK_ASSERT(y->n >= z->n);\n\n\tny = y->n; nz = z->n;\n\tborrow = 0U;\n\tfor (i = 0; i < ny; i++) {\n\t\t/* Borrow is detected based on wrapping which relies on exact 32-bit\n\t\t * types.\n\t\t */\n\t\ttmp1 = y->v[i];\n\t\ttmp2 = tmp1;\n\t\tif (i < nz) {\n\t\t\ttmp2 -= z->v[i];\n\t\t}\n\n\t\t/* Careful with borrow condition:\n\t\t *  - If borrow not subtracted: 0x12345678 - 0 - 0xffffffff = 0x12345679 (> 0x12345678)\n\t\t *  - If borrow subtracted:     0x12345678 - 1 - 0xffffffff = 0x12345678 (== 0x12345678)\n\t\t */\n\t\tif (borrow) {\n\t\t\ttmp2--;\n\t\t\tborrow = (tmp2 >= tmp1 ? 1U : 0U);\n\t\t} else {\n\t\t\tborrow = (tmp2 > tmp1 ? 1U : 0U);\n\t\t}\n\n\t\tx->v[i] = tmp2;\n\t}\n\tDUK_ASSERT(borrow == 0U);\n\n\tx->n = i;\n\tduk__bi_normalize(x);  /* need to normalize, may even cancel to 0 */\n\tDUK_ASSERT(duk__bi_is_valid(x));\n}\n#endif\n\n#if 0  /* unused */\n/* x <- y - z */\nDUK_LOCAL void duk__bi_sub_small(duk__bigint *x, duk__bigint *y, duk_uint32_t z) {\n\tduk__bigint tmp;\n\n\tDUK_ASSERT(duk__bi_is_valid(y));\n\n\t/* XXX: this could be optimized */\n\tduk__bi_set_small(&tmp, z);\n\tduk__bi_sub(x, y, &tmp);\n\n\tDUK_ASSERT(duk__bi_is_valid(x));\n}\n#endif\n\n/* x <- x - y, use t as temp */\nDUK_LOCAL void duk__bi_sub_copy(duk__bigint *x, duk__bigint *y, duk__bigint *t) {\n\tduk__bi_sub(t, x, y);\n\tduk__bi_copy(x, t);\n}\n\n/* x <- y * z */\nDUK_LOCAL void duk__bi_mul(duk__bigint *x, duk__bigint *y, duk__bigint *z) {\n\tduk_small_int_t i, j, nx, nz;\n\n\tDUK_ASSERT(duk__bi_is_valid(y));\n\tDUK_ASSERT(duk__bi_is_valid(z));\n\n\tnx = y->n + z->n;  /* max possible */\n\tDUK_ASSERT(nx <= DUK__BI_MAX_PARTS);\n\n\tif (nx == 0) {\n\t\t/* Both inputs are zero; cases where only one is zero can go\n\t\t * through main algorithm.\n\t\t */\n\t\tx->n = 0;\n\t\treturn;\n\t}\n\n\tDUK_MEMZERO((void *) x->v, (size_t) (sizeof(duk_uint32_t) * nx));\n\tx->n = nx;\n\n\tnz = z->n;\n\tfor (i = 0; i < y->n; i++) {\n#if defined(DUK_USE_64BIT_OPS)\n\t\tduk_uint64_t tmp = 0U;\n\t\tfor (j = 0; j < nz; j++) {\n\t\t\ttmp += (duk_uint64_t) y->v[i] * (duk_uint64_t) z->v[j] + x->v[i+j];\n\t\t\tx->v[i+j] = (duk_uint32_t) (tmp & 0xffffffffUL);\n\t\t\ttmp = tmp >> 32;\n\t\t}\n\t\tif (tmp > 0) {\n\t\t\tDUK_ASSERT(i + j < nx);\n\t\t\tDUK_ASSERT(i + j < DUK__BI_MAX_PARTS);\n\t\t\tDUK_ASSERT(x->v[i+j] == 0U);\n\t\t\tx->v[i+j] = (duk_uint32_t) tmp;\n\t\t}\n#else\n\t\t/*\n\t\t *  Multiply + add + carry for 32-bit components using only 16x16->32\n\t\t *  multiplies and carry detection based on unsigned overflow.\n\t\t *\n\t\t *    1st mult, 32-bit: (A*2^16 + B)\n\t\t *    2nd mult, 32-bit: (C*2^16 + D)\n\t\t *    3rd add, 32-bit: E\n\t\t *    4th add, 32-bit: F\n\t\t *\n\t\t *      (AC*2^16 + B) * (C*2^16 + D) + E + F\n\t\t *    = AC*2^32 + AD*2^16 + BC*2^16 + BD + E + F\n\t\t *    = AC*2^32 + (AD + BC)*2^16 + (BD + E + F)\n\t\t *    = AC*2^32 + AD*2^16 + BC*2^16 + (BD + E + F)\n\t\t */\n\t\tduk_uint32_t a, b, c, d, e, f;\n\t\tduk_uint32_t r, s, t;\n\n\t\ta = y->v[i]; b = a & 0xffffUL; a = a >> 16;\n\n\t\tf = 0;\n\t\tfor (j = 0; j < nz; j++) {\n\t\t\tc = z->v[j]; d = c & 0xffffUL; c = c >> 16;\n\t\t\te = x->v[i+j];\n\n\t\t\t/* build result as: (r << 32) + s: start with (BD + E + F) */\n\t\t\tr = 0;\n\t\t\ts = b * d;\n\n\t\t\t/* add E */\n\t\t\tt = s + e;\n\t\t\tif (t < s) { r++; }  /* carry */\n\t\t\ts = t;\n\n\t\t\t/* add F */\n\t\t\tt = s + f;\n\t\t\tif (t < s) { r++; }  /* carry */\n\t\t\ts = t;\n\n\t\t\t/* add BC*2^16 */\n\t\t\tt = b * c;\n\t\t\tr += (t >> 16);\n\t\t\tt = s + ((t & 0xffffUL) << 16);\n\t\t\tif (t < s) { r++; }  /* carry */\n\t\t\ts = t;\n\n\t\t\t/* add AD*2^16 */\n\t\t\tt = a * d;\n\t\t\tr += (t >> 16);\n\t\t\tt = s + ((t & 0xffffUL) << 16);\n\t\t\tif (t < s) { r++; }  /* carry */\n\t\t\ts = t;\n\n\t\t\t/* add AC*2^32 */\n\t\t\tt = a * c;\n\t\t\tr += t;\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"ab=%08lx cd=%08lx ef=%08lx -> rs=%08lx %08lx\",\n\t\t\t                     (unsigned long) y->v[i], (unsigned long) z->v[j],\n\t\t\t                     (unsigned long) x->v[i+j], (unsigned long) r,\n\t\t\t                     (unsigned long) s));\n\n\t\t\tx->v[i+j] = s;\n\t\t\tf = r;\n\t\t}\n\t\tif (f > 0U) {\n\t\t\tDUK_ASSERT(i + j < nx);\n\t\t\tDUK_ASSERT(i + j < DUK__BI_MAX_PARTS);\n\t\t\tDUK_ASSERT(x->v[i+j] == 0U);\n\t\t\tx->v[i+j] = (duk_uint32_t) f;\n\t\t}\n#endif  /* DUK_USE_64BIT_OPS */\n\t}\n\n\tduk__bi_normalize(x);\n\tDUK_ASSERT(duk__bi_is_valid(x));\n}\n\n/* x <- y * z */\nDUK_LOCAL void duk__bi_mul_small(duk__bigint *x, duk__bigint *y, duk_uint32_t z) {\n\tduk__bigint tmp;\n\n\tDUK_ASSERT(duk__bi_is_valid(y));\n\n\t/* XXX: this could be optimized */\n\tduk__bi_set_small(&tmp, z);\n\tduk__bi_mul(x, y, &tmp);\n\n\tDUK_ASSERT(duk__bi_is_valid(x));\n}\n\n/* x <- x * y, use t as temp */\nDUK_LOCAL void duk__bi_mul_copy(duk__bigint *x, duk__bigint *y, duk__bigint *t) {\n\tduk__bi_mul(t, x, y);\n\tduk__bi_copy(x, t);\n}\n\n/* x <- x * y, use t as temp */\nDUK_LOCAL void duk__bi_mul_small_copy(duk__bigint *x, duk_uint32_t y, duk__bigint *t) {\n\tduk__bi_mul_small(t, x, y);\n\tduk__bi_copy(x, t);\n}\n\nDUK_LOCAL int duk__bi_is_even(duk__bigint *x) {\n\tDUK_ASSERT(duk__bi_is_valid(x));\n\treturn (x->n == 0) || ((x->v[0] & 0x01) == 0);\n}\n\nDUK_LOCAL int duk__bi_is_zero(duk__bigint *x) {\n\tDUK_ASSERT(duk__bi_is_valid(x));\n\treturn (x->n == 0);  /* this is the case for normalized numbers */\n}\n\n/* Bigint is 2^52.  Used to detect normalized IEEE double mantissa values\n * which are at the lowest edge (next floating point value downwards has\n * a different exponent).  The lowest mantissa has the form:\n *\n *     1000........000    (52 zeroes; only \"hidden bit\" is set)\n */\nDUK_LOCAL duk_small_int_t duk__bi_is_2to52(duk__bigint *x) {\n\tDUK_ASSERT(duk__bi_is_valid(x));\n\treturn (duk_small_int_t)\n\t        (x->n == 2) && (x->v[0] == 0U) && (x->v[1] == (1U << (52-32)));\n}\n\n/* x <- (1<<y) */\nDUK_LOCAL void duk__bi_twoexp(duk__bigint *x, duk_small_int_t y) {\n\tduk_small_int_t n, r;\n\n\tn = (y / 32) + 1;\n\tDUK_ASSERT(n > 0);\n\tr = y % 32;\n\tDUK_MEMZERO((void *) x->v, sizeof(duk_uint32_t) * n);\n\tx->n = n;\n\tx->v[n - 1] = (((duk_uint32_t) 1) << r);\n}\n\n/* x <- b^y; use t1 and t2 as temps */\nDUK_LOCAL void duk__bi_exp_small(duk__bigint *x, duk_small_int_t b, duk_small_int_t y, duk__bigint *t1, duk__bigint *t2) {\n\t/* Fast path the binary case */\n\n\tDUK_ASSERT(x != t1 && x != t2 && t1 != t2);  /* distinct bignums, easy mistake to make */\n\tDUK_ASSERT(b >= 0);\n\tDUK_ASSERT(y >= 0);\n\n\tif (b == 2) {\n\t\tduk__bi_twoexp(x, y);\n\t\treturn;\n\t}\n\n\t/* http://en.wikipedia.org/wiki/Exponentiation_by_squaring */\n\n\tDUK_DDD(DUK_DDDPRINT(\"exp_small: b=%ld, y=%ld\", (long) b, (long) y));\n\n\tduk__bi_set_small(x, 1);\n\tduk__bi_set_small(t1, b);\n\tfor (;;) {\n\t\t/* Loop structure ensures that we don't compute t1^2 unnecessarily\n\t\t * on the final round, as that might create a bignum exceeding the\n\t\t * current DUK__BI_MAX_PARTS limit.\n\t\t */\n\t\tif (y & 0x01) {\n\t\t\tduk__bi_mul_copy(x, t1, t2);\n\t\t}\n\t\ty = y >> 1;\n\t\tif (y == 0) {\n\t\t\tbreak;\n\t\t}\n\t\tduk__bi_mul_copy(t1, t1, t2);\n\t}\n\n\tDUK__BI_PRINT(\"exp_small result\", x);\n}\n\n/*\n *  A Dragon4 number-to-string variant, based on:\n *\n *    Guy L. Steele Jr., Jon L. White: \"How to Print Floating-Point Numbers\n *    Accurately\"\n *\n *    Robert G. Burger, R. Kent Dybvig: \"Printing Floating-Point Numbers\n *    Quickly and Accurately\"\n *\n *  The current algorithm is based on Figure 1 of the Burger-Dybvig paper,\n *  i.e. the base implementation without logarithm estimation speedups\n *  (these would increase code footprint considerably).  Fixed-format output\n *  does not follow the suggestions in the paper; instead, we generate an\n *  extra digit and round-with-carry.\n *\n *  The same algorithm is used for number parsing (with b=10 and B=2)\n *  by generating one extra digit and doing rounding manually.\n *\n *  See doc/number-conversion.rst for limitations.\n */\n\n/* Maximum number of digits generated. */\n#define DUK__MAX_OUTPUT_DIGITS          1040  /* (Number.MAX_VALUE).toString(2).length == 1024, + spare */\n\n/* Maximum number of characters in formatted value. */\n#define DUK__MAX_FORMATTED_LENGTH       1040  /* (-Number.MAX_VALUE).toString(2).length == 1025, + spare */\n\n/* Number and (minimum) size of bigints in the nc_ctx structure. */\n#define DUK__NUMCONV_CTX_NUM_BIGINTS    7\n#define DUK__NUMCONV_CTX_BIGINTS_SIZE   (sizeof(duk__bigint) * DUK__NUMCONV_CTX_NUM_BIGINTS)\n\ntypedef struct {\n\t/* Currently about 7*152 = 1064 bytes.  The space for these\n\t * duk__bigints is used also as a temporary buffer for generating\n\t * the final string.  This is a bit awkard; a union would be\n\t * more correct.\n\t */\n\tduk__bigint f, r, s, mp, mm, t1, t2;\n\n\tduk_small_int_t is_s2n;        /* if 1, doing a string-to-number; else doing a number-to-string */\n\tduk_small_int_t is_fixed;      /* if 1, doing a fixed format output (not free format) */\n\tduk_small_int_t req_digits;    /* requested number of output digits; 0 = free-format */\n\tduk_small_int_t abs_pos;       /* digit position is absolute, not relative */\n\tduk_small_int_t e;             /* exponent for 'f' */\n\tduk_small_int_t b;             /* input radix */\n\tduk_small_int_t B;             /* output radix */\n\tduk_small_int_t k;             /* see algorithm */\n\tduk_small_int_t low_ok;        /* see algorithm */\n\tduk_small_int_t high_ok;       /* see algorithm */\n\tduk_small_int_t unequal_gaps;  /* m+ != m- (very rarely) */\n\n\t/* Buffer used for generated digits, values are in the range [0,B-1]. */\n\tduk_uint8_t digits[DUK__MAX_OUTPUT_DIGITS];\n\tduk_small_int_t count;  /* digit count */\n} duk__numconv_stringify_ctx;\n\n/* Note: computes with 'idx' in assertions, so caller beware.\n * 'idx' is preincremented, i.e. '1' on first call, because it\n * is more convenient for the caller.\n */\n#define DUK__DRAGON4_OUTPUT_PREINC(nc_ctx,preinc_idx,x)  do { \\\n\t\tDUK_ASSERT((preinc_idx) - 1 >= 0); \\\n\t\tDUK_ASSERT((preinc_idx) - 1 < DUK__MAX_OUTPUT_DIGITS); \\\n\t\t((nc_ctx)->digits[(preinc_idx) - 1]) = (duk_uint8_t) (x); \\\n\t} while (0)\n\nDUK_LOCAL duk_size_t duk__dragon4_format_uint32(duk_uint8_t *buf, duk_uint32_t x, duk_small_int_t radix) {\n\tduk_uint8_t *p;\n\tduk_size_t len;\n\tduk_small_int_t dig;\n\tduk_small_int_t t;\n\n\tDUK_ASSERT(radix >= 2 && radix <= 36);\n\n\t/* A 32-bit unsigned integer formats to at most 32 digits (the\n\t * worst case happens with radix == 2).  Output the digits backwards,\n\t * and use a memmove() to get them in the right place.\n\t */\n\n\tp = buf + 32;\n\tfor (;;) {\n\t\tt = x / radix;\n\t\tdig = x - t * radix;\n\t\tx = t;\n\n\t\tDUK_ASSERT(dig >= 0 && dig < 36);\n\t\t*(--p) = DUK__DIGITCHAR(dig);\n\n\t\tif (x == 0) {\n\t\t\tbreak;\n\t\t}\n\t}\n\tlen = (duk_size_t) ((buf + 32) - p);\n\n\tDUK_MEMMOVE((void *) buf, (const void *) p, (size_t) len);\n\n\treturn len;\n}\n\nDUK_LOCAL void duk__dragon4_prepare(duk__numconv_stringify_ctx *nc_ctx) {\n\tduk_small_int_t lowest_mantissa;\n\n#if 1\n\t/* Assume IEEE round-to-even, so that shorter encoding can be used\n\t * when round-to-even would produce correct result.  By removing\n\t * this check (and having low_ok == high_ok == 0) the results would\n\t * still be accurate but in some cases longer than necessary.\n\t */\n\tif (duk__bi_is_even(&nc_ctx->f)) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"f is even\"));\n\t\tnc_ctx->low_ok = 1;\n\t\tnc_ctx->high_ok = 1;\n\t} else {\n\t\tDUK_DDD(DUK_DDDPRINT(\"f is odd\"));\n\t\tnc_ctx->low_ok = 0;\n\t\tnc_ctx->high_ok = 0;\n\t}\n#else\n\t/* Note: not honoring round-to-even should work but now generates incorrect\n\t * results.  For instance, 1e23 serializes to \"a000...\", i.e. the first digit\n\t * equals the radix (10).  Scaling stops one step too early in this case.\n\t * Don't know why this is the case, but since this code path is unused, it\n\t * doesn't matter.\n\t */\n\tnc_ctx->low_ok = 0;\n\tnc_ctx->high_ok = 0;\n#endif\n\n\t/* For string-to-number, pretend we never have the lowest mantissa as there\n\t * is no natural \"precision\" for inputs.  Having lowest_mantissa == 0, we'll\n\t * fall into the base cases for both e >= 0 and e < 0.\n\t */\n\tif (nc_ctx->is_s2n) {\n\t\tlowest_mantissa = 0;\n\t} else {\n\t\tlowest_mantissa = duk__bi_is_2to52(&nc_ctx->f);\n\t}\n\n\tnc_ctx->unequal_gaps = 0;\n\tif (nc_ctx->e >= 0) {\n\t\t/* exponent non-negative (and thus not minimum exponent) */\n\n\t\tif (lowest_mantissa) {\n\t\t\t/* (>= e 0) AND (= f (expt b (- p 1)))\n\t\t\t *\n\t\t\t * be <- (expt b e) == b^e\n\t\t\t * be1 <- (* be b) == (expt b (+ e 1)) == b^(e+1)\n\t\t\t * r <- (* f be1 2) == 2 * f * b^(e+1)    [if b==2 -> f * b^(e+2)]\n\t\t\t * s <- (* b 2)                           [if b==2 -> 4]\n\t\t\t * m+ <- be1 == b^(e+1)\n\t\t\t * m- <- be == b^e\n\t\t\t * k <- 0\n\t\t\t * B <- B\n\t\t\t * low_ok <- round\n\t\t\t * high_ok <- round\n\t\t\t */\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"non-negative exponent (not smallest exponent); \"\n\t\t\t                     \"lowest mantissa value for this exponent -> \"\n\t\t\t                     \"unequal gaps\"));\n\n\t\t\tduk__bi_exp_small(&nc_ctx->mm, nc_ctx->b, nc_ctx->e, &nc_ctx->t1, &nc_ctx->t2);  /* mm <- b^e */\n\t\t\tduk__bi_mul_small(&nc_ctx->mp, &nc_ctx->mm, nc_ctx->b);  /* mp <- b^(e+1) */\n\t\t\tduk__bi_mul_small(&nc_ctx->t1, &nc_ctx->f, 2);\n\t\t\tduk__bi_mul(&nc_ctx->r, &nc_ctx->t1, &nc_ctx->mp);       /* r <- (2 * f) * b^(e+1) */\n\t\t\tduk__bi_set_small(&nc_ctx->s, nc_ctx->b * 2);            /* s <- 2 * b */\n\t\t\tnc_ctx->unequal_gaps = 1;\n\t\t} else {\n\t\t\t/* (>= e 0) AND (not (= f (expt b (- p 1))))\n\t\t\t *\n\t\t\t * be <- (expt b e) == b^e\n\t\t\t * r <- (* f be 2) == 2 * f * b^e    [if b==2 -> f * b^(e+1)]\n\t\t\t * s <- 2\n\t\t\t * m+ <- be == b^e\n\t\t\t * m- <- be == b^e\n\t\t\t * k <- 0\n\t\t\t * B <- B\n\t\t\t * low_ok <- round\n\t\t\t * high_ok <- round\n\t\t\t */\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"non-negative exponent (not smallest exponent); \"\n\t\t\t                     \"not lowest mantissa for this exponent -> \"\n\t\t\t                     \"equal gaps\"));\n\n\t\t\tduk__bi_exp_small(&nc_ctx->mm, nc_ctx->b, nc_ctx->e, &nc_ctx->t1, &nc_ctx->t2);  /* mm <- b^e */\n\t\t\tduk__bi_copy(&nc_ctx->mp, &nc_ctx->mm);                /* mp <- b^e */\n\t\t\tduk__bi_mul_small(&nc_ctx->t1, &nc_ctx->f, 2);\n\t\t\tduk__bi_mul(&nc_ctx->r, &nc_ctx->t1, &nc_ctx->mp);     /* r <- (2 * f) * b^e */\n\t\t\tduk__bi_set_small(&nc_ctx->s, 2);                      /* s <- 2 */\n\t\t}\n\t} else {\n\t\t/* When doing string-to-number, lowest_mantissa is always 0 so\n\t\t * the exponent check, while incorrect, won't matter.\n\t\t */\n\t\tif (nc_ctx->e > DUK__IEEE_DOUBLE_EXP_MIN /*not minimum exponent*/ &&\n\t\t    lowest_mantissa /* lowest mantissa for this exponent*/) {\n\t\t\t/* r <- (* f b 2)                                [if b==2 -> (* f 4)]\n\t\t\t * s <- (* (expt b (- 1 e)) 2) == b^(1-e) * 2    [if b==2 -> b^(2-e)]\n\t\t\t * m+ <- b == 2\n\t\t\t * m- <- 1\n\t\t\t * k <- 0\n\t\t\t * B <- B\n\t\t\t * low_ok <- round\n\t\t\t * high_ok <- round\n\t\t\t */\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"negative exponent; not minimum exponent and \"\n\t\t\t                     \"lowest mantissa for this exponent -> \"\n\t\t\t                     \"unequal gaps\"));\n\n\t\t\tduk__bi_mul_small(&nc_ctx->r, &nc_ctx->f, nc_ctx->b * 2);  /* r <- (2 * b) * f */\n\t\t\tduk__bi_exp_small(&nc_ctx->t1, nc_ctx->b, 1 - nc_ctx->e, &nc_ctx->s, &nc_ctx->t2);  /* NB: use 's' as temp on purpose */\n\t\t\tduk__bi_mul_small(&nc_ctx->s, &nc_ctx->t1, 2);             /* s <- b^(1-e) * 2 */\n\t\t\tduk__bi_set_small(&nc_ctx->mp, 2);\n\t\t\tduk__bi_set_small(&nc_ctx->mm, 1);\n\t\t\tnc_ctx->unequal_gaps = 1;\n\t\t} else {\n\t\t\t/* r <- (* f 2)\n\t\t\t * s <- (* (expt b (- e)) 2) == b^(-e) * 2    [if b==2 -> b^(1-e)]\n\t\t\t * m+ <- 1\n\t\t\t * m- <- 1\n\t\t\t * k <- 0\n\t\t\t * B <- B\n\t\t\t * low_ok <- round\n\t\t\t * high_ok <- round\n\t\t\t */\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"negative exponent; minimum exponent or not \"\n\t\t\t                     \"lowest mantissa for this exponent -> \"\n\t\t\t                     \"equal gaps\"));\n\n\t\t\tduk__bi_mul_small(&nc_ctx->r, &nc_ctx->f, 2);            /* r <- 2 * f */\n\t\t\tduk__bi_exp_small(&nc_ctx->t1, nc_ctx->b, -nc_ctx->e, &nc_ctx->s, &nc_ctx->t2);  /* NB: use 's' as temp on purpose */\n\t\t\tduk__bi_mul_small(&nc_ctx->s, &nc_ctx->t1, 2);           /* s <- b^(-e) * 2 */\n\t\t\tduk__bi_set_small(&nc_ctx->mp, 1);\n\t\t\tduk__bi_set_small(&nc_ctx->mm, 1);\n\t\t}\n\t}\n}\n\nDUK_LOCAL void duk__dragon4_scale(duk__numconv_stringify_ctx *nc_ctx) {\n\tduk_small_int_t k = 0;\n\n\t/* This is essentially the 'scale' algorithm, with recursion removed.\n\t * Note that 'k' is either correct immediately, or will move in one\n\t * direction in the loop.  There's no need to do the low/high checks\n\t * on every round (like the Scheme algorithm does).\n\t *\n\t * The scheme algorithm finds 'k' and updates 's' simultaneously,\n\t * while the logical algorithm finds 'k' with 's' having its initial\n\t * value, after which 's' is updated separately (see the Burger-Dybvig\n\t * paper, Section 3.1, steps 2 and 3).\n\t *\n\t * The case where m+ == m- (almost always) is optimized for, because\n\t * it reduces the bigint operations considerably and almost always\n\t * applies.  The scale loop only needs to work with m+, so this works.\n\t */\n\n\t/* XXX: this algorithm could be optimized quite a lot by using e.g.\n\t * a logarithm based estimator for 'k' and performing B^n multiplication\n\t * using a lookup table or using some bit-representation based exp\n\t * algorithm.  Currently we just loop, with significant performance\n\t * impact for very large and very small numbers.\n\t */\n\n\tDUK_DDD(DUK_DDDPRINT(\"scale: B=%ld, low_ok=%ld, high_ok=%ld\",\n\t                     (long) nc_ctx->B, (long) nc_ctx->low_ok, (long) nc_ctx->high_ok));\n\tDUK__BI_PRINT(\"r(init)\", &nc_ctx->r);\n\tDUK__BI_PRINT(\"s(init)\", &nc_ctx->s);\n\tDUK__BI_PRINT(\"mp(init)\", &nc_ctx->mp);\n\tDUK__BI_PRINT(\"mm(init)\", &nc_ctx->mm);\n\n\tfor (;;) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"scale loop (inc k), k=%ld\", (long) k));\n\t\tDUK__BI_PRINT(\"r\", &nc_ctx->r);\n\t\tDUK__BI_PRINT(\"s\", &nc_ctx->s);\n\t\tDUK__BI_PRINT(\"m+\", &nc_ctx->mp);\n\t\tDUK__BI_PRINT(\"m-\", &nc_ctx->mm);\n\n\t\tduk__bi_add(&nc_ctx->t1, &nc_ctx->r, &nc_ctx->mp);  /* t1 = (+ r m+) */\n\t\tif (duk__bi_compare(&nc_ctx->t1, &nc_ctx->s) >= (nc_ctx->high_ok ? 0 : 1)) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"k is too low\"));\n\t\t\t/* r <- r\n\t\t\t * s <- (* s B)\n\t\t\t * m+ <- m+\n\t\t\t * m- <- m-\n\t\t\t * k <- (+ k 1)\n\t\t\t */\n\n\t\t\tduk__bi_mul_small_copy(&nc_ctx->s, nc_ctx->B, &nc_ctx->t1);\n\t\t\tk++;\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t/* k > 0 -> k was too low, and cannot be too high */\n\tif (k > 0) {\n\t\tgoto skip_dec_k;\n\t}\n\n\tfor (;;) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"scale loop (dec k), k=%ld\", (long) k));\n\t\tDUK__BI_PRINT(\"r\", &nc_ctx->r);\n\t\tDUK__BI_PRINT(\"s\", &nc_ctx->s);\n\t\tDUK__BI_PRINT(\"m+\", &nc_ctx->mp);\n\t\tDUK__BI_PRINT(\"m-\", &nc_ctx->mm);\n\n\t\tduk__bi_add(&nc_ctx->t1, &nc_ctx->r, &nc_ctx->mp);  /* t1 = (+ r m+) */\n\t\tduk__bi_mul_small(&nc_ctx->t2, &nc_ctx->t1, nc_ctx->B);   /* t2 = (* (+ r m+) B) */\n\t\tif (duk__bi_compare(&nc_ctx->t2, &nc_ctx->s) <= (nc_ctx->high_ok ? -1 : 0)) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"k is too high\"));\n\t\t\t/* r <- (* r B)\n\t\t\t * s <- s\n\t\t\t * m+ <- (* m+ B)\n\t\t\t * m- <- (* m- B)\n\t\t\t * k <- (- k 1)\n\t\t\t */\n\t\t\tduk__bi_mul_small_copy(&nc_ctx->r, nc_ctx->B, &nc_ctx->t1);\n\t\t\tduk__bi_mul_small_copy(&nc_ctx->mp, nc_ctx->B, &nc_ctx->t1);\n\t\t\tif (nc_ctx->unequal_gaps) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"m+ != m- -> need to update m- too\"));\n\t\t\t\tduk__bi_mul_small_copy(&nc_ctx->mm, nc_ctx->B, &nc_ctx->t1);\n\t\t\t}\n\t\t\tk--;\n\t\t} else {\n\t\t\tbreak;\n\t\t}\n\t}\n\n skip_dec_k:\n\n\tif (!nc_ctx->unequal_gaps) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"equal gaps, copy m- from m+\"));\n\t\tduk__bi_copy(&nc_ctx->mm, &nc_ctx->mp);  /* mm <- mp */\n\t}\n\tnc_ctx->k = k;\n\n\tDUK_DDD(DUK_DDDPRINT(\"final k: %ld\", (long) k));\n\tDUK__BI_PRINT(\"r(final)\", &nc_ctx->r);\n\tDUK__BI_PRINT(\"s(final)\", &nc_ctx->s);\n\tDUK__BI_PRINT(\"mp(final)\", &nc_ctx->mp);\n\tDUK__BI_PRINT(\"mm(final)\", &nc_ctx->mm);\n}\n\nDUK_LOCAL void duk__dragon4_generate(duk__numconv_stringify_ctx *nc_ctx) {\n\tduk_small_int_t tc1, tc2;    /* terminating conditions */\n\tduk_small_int_t d;           /* current digit */\n\tduk_small_int_t count = 0;   /* digit count */\n\n\t/*\n\t *  Digit generation loop.\n\t *\n\t *  Different termination conditions:\n\t *\n\t *    1. Free format output.  Terminate when shortest accurate\n\t *       representation found.\n\t *\n\t *    2. Fixed format output, with specific number of digits.\n\t *       Ignore termination conditions, terminate when digits\n\t *       generated.  Caller requests an extra digit and rounds.\n\t *\n\t *    3. Fixed format output, with a specific absolute cut-off\n\t *       position (e.g. 10 digits after decimal point).  Note\n\t *       that we always generate at least one digit, even if\n\t *       the digit is below the cut-off point already.\n\t */\n\n\tfor (;;) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"generate loop, count=%ld, k=%ld, B=%ld, low_ok=%ld, high_ok=%ld\",\n\t\t                     (long) count, (long) nc_ctx->k, (long) nc_ctx->B,\n\t\t                     (long) nc_ctx->low_ok, (long) nc_ctx->high_ok));\n\t\tDUK__BI_PRINT(\"r\", &nc_ctx->r);\n\t\tDUK__BI_PRINT(\"s\", &nc_ctx->s);\n\t\tDUK__BI_PRINT(\"m+\", &nc_ctx->mp);\n\t\tDUK__BI_PRINT(\"m-\", &nc_ctx->mm);\n\n\t\t/* (quotient-remainder (* r B) s) using a dummy subtraction loop */\n\t\tduk__bi_mul_small(&nc_ctx->t1, &nc_ctx->r, nc_ctx->B);       /* t1 <- (* r B) */\n\t\td = 0;\n\t\tfor (;;) {\n\t\t\tif (duk__bi_compare(&nc_ctx->t1, &nc_ctx->s) < 0) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tduk__bi_sub_copy(&nc_ctx->t1, &nc_ctx->s, &nc_ctx->t2);  /* t1 <- t1 - s */\n\t\t\td++;\n\t\t}\n\t\tduk__bi_copy(&nc_ctx->r, &nc_ctx->t1);  /* r <- (remainder (* r B) s) */\n\t\t                                        /* d <- (quotient (* r B) s)   (in range 0...B-1) */\n\t\tDUK_DDD(DUK_DDDPRINT(\"-> d(quot)=%ld\", (long) d));\n\t\tDUK__BI_PRINT(\"r(rem)\", &nc_ctx->r);\n\n\t\tduk__bi_mul_small_copy(&nc_ctx->mp, nc_ctx->B, &nc_ctx->t2); /* m+ <- (* m+ B) */\n\t\tduk__bi_mul_small_copy(&nc_ctx->mm, nc_ctx->B, &nc_ctx->t2); /* m- <- (* m- B) */\n\t\tDUK__BI_PRINT(\"mp(upd)\", &nc_ctx->mp);\n\t\tDUK__BI_PRINT(\"mm(upd)\", &nc_ctx->mm);\n\n\t\t/* Terminating conditions.  For fixed width output, we just ignore the\n\t\t * terminating conditions (and pretend that tc1 == tc2 == false).  The\n\t\t * the current shortcut for fixed-format output is to generate a few\n\t\t * extra digits and use rounding (with carry) to finish the output.\n\t\t */\n\n\t\tif (nc_ctx->is_fixed == 0) {\n\t\t\t/* free-form */\n\t\t\ttc1 = (duk__bi_compare(&nc_ctx->r, &nc_ctx->mm) <= (nc_ctx->low_ok ? 0 : -1));\n\n\t\t\tduk__bi_add(&nc_ctx->t1, &nc_ctx->r, &nc_ctx->mp);  /* t1 <- (+ r m+) */\n\t\t\ttc2 = (duk__bi_compare(&nc_ctx->t1, &nc_ctx->s) >= (nc_ctx->high_ok ? 0 : 1));\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"tc1=%ld, tc2=%ld\", (long) tc1, (long) tc2));\n\t\t} else {\n\t\t\t/* fixed-format */\n\t\t\ttc1 = 0;\n\t\t\ttc2 = 0;\n\t\t}\n\n\t\t/* Count is incremented before DUK__DRAGON4_OUTPUT_PREINC() call\n\t\t * on purpose, which is taken into account by the macro.\n\t\t */\n\t\tcount++;\n\n\t\tif (tc1) {\n\t\t\tif (tc2) {\n\t\t\t\t/* tc1 = true, tc2 = true */\n\t\t\t\tduk__bi_mul_small(&nc_ctx->t1, &nc_ctx->r, 2);\n\t\t\t\tif (duk__bi_compare(&nc_ctx->t1, &nc_ctx->s) < 0) {  /* (< (* r 2) s) */\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"tc1=true, tc2=true, 2r > s: output d --> %ld (k=%ld)\",\n\t\t\t\t\t                     (long) d, (long) nc_ctx->k));\n\t\t\t\t\tDUK__DRAGON4_OUTPUT_PREINC(nc_ctx, count, d);\n\t\t\t\t} else {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"tc1=true, tc2=true, 2r <= s: output d+1 --> %ld (k=%ld)\",\n\t\t\t\t\t                     (long) (d + 1), (long) nc_ctx->k));\n\t\t\t\t\tDUK__DRAGON4_OUTPUT_PREINC(nc_ctx, count, d + 1);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\t/* tc1 = true, tc2 = false */\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"tc1=true, tc2=false: output d --> %ld (k=%ld)\",\n\t\t\t\t                     (long) d, (long) nc_ctx->k));\n\t\t\t\tDUK__DRAGON4_OUTPUT_PREINC(nc_ctx, count, d);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} else {\n\t\t\tif (tc2) {\n\t\t\t\t/* tc1 = false, tc2 = true */\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"tc1=false, tc2=true: output d+1 --> %ld (k=%ld)\",\n\t\t\t\t                     (long) (d + 1), (long) nc_ctx->k));\n\t\t\t\tDUK__DRAGON4_OUTPUT_PREINC(nc_ctx, count, d + 1);\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\t/* tc1 = false, tc2 = false */\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"tc1=false, tc2=false: output d --> %ld (k=%ld)\",\n\t\t\t\t                     (long) d, (long) nc_ctx->k));\n\t\t\t\tDUK__DRAGON4_OUTPUT_PREINC(nc_ctx, count, d);\n\n\t\t\t\t/* r <- r    (updated above: r <- (remainder (* r B) s)\n\t\t\t\t * s <- s\n\t\t\t\t * m+ <- m+  (updated above: m+ <- (* m+ B)\n\t\t\t\t * m- <- m-  (updated above: m- <- (* m- B)\n\t\t\t\t * B, low_ok, high_ok are fixed\n\t\t\t\t */\n\n\t\t\t\t/* fall through and continue for-loop */\n\t\t\t}\n\t\t}\n\n\t\t/* fixed-format termination conditions */\n\t\tif (nc_ctx->is_fixed) {\n\t\t\tif (nc_ctx->abs_pos) {\n\t\t\t\tint pos = nc_ctx->k - count + 1;  /* count is already incremented, take into account */\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"fixed format, absolute: abs pos=%ld, k=%ld, count=%ld, req=%ld\",\n\t\t\t\t                     (long) pos, (long) nc_ctx->k, (long) count, (long) nc_ctx->req_digits));\n\t\t\t\tif (pos <= nc_ctx->req_digits) {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"digit position reached req_digits, end generate loop\"));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"fixed format, relative: k=%ld, count=%ld, req=%ld\",\n\t\t\t\t                     (long) nc_ctx->k, (long) count, (long) nc_ctx->req_digits));\n\t\t\t\tif (count >= nc_ctx->req_digits) {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"digit count reached req_digits, end generate loop\"));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}  /* for */\n\n\tnc_ctx->count = count;\n\n\tDUK_DDD(DUK_DDDPRINT(\"generate finished\"));\n\n#if defined(DUK_USE_DEBUG_LEVEL) && (DUK_USE_DEBUG_LEVEL >= 2)\n\t{\n\t\tduk_uint8_t buf[2048];\n\t\tduk_small_int_t i, t;\n\t\tDUK_MEMZERO(buf, sizeof(buf));\n\t\tfor (i = 0; i < nc_ctx->count; i++) {\n\t\t\tt = nc_ctx->digits[i];\n\t\t\tif (t < 0 || t > 36) {\n\t\t\t\tbuf[i] = (duk_uint8_t) '?';\n\t\t\t} else {\n\t\t\t\tbuf[i] = (duk_uint8_t) DUK__DIGITCHAR(t);\n\t\t\t}\n\t\t}\n\t\tDUK_DDD(DUK_DDDPRINT(\"-> generated digits; k=%ld, digits='%s'\",\n\t\t                     (long) nc_ctx->k, (const char *) buf));\n\t}\n#endif\n}\n\n/* Round up digits to a given position.  If position is out-of-bounds,\n * does nothing.  If carry propagates over the first digit, a '1' is\n * prepended to digits and 'k' will be updated.  Return value indicates\n * whether carry propagated over the first digit.\n *\n * Note that nc_ctx->count is NOT updated based on the rounding position\n * (it is updated only if carry overflows over the first digit and an\n * extra digit is prepended).\n */\nDUK_LOCAL duk_small_int_t duk__dragon4_fixed_format_round(duk__numconv_stringify_ctx *nc_ctx, duk_small_int_t round_idx) {\n\tduk_small_int_t t;\n\tduk_uint8_t *p;\n\tduk_uint8_t roundup_limit;\n\tduk_small_int_t ret = 0;\n\n\t/*\n\t *  round_idx points to the digit which is considered for rounding; the\n\t *  digit to its left is the final digit of the rounded value.  If round_idx\n\t *  is zero, rounding will be performed; the result will either be an empty\n\t *  rounded value or if carry happens a '1' digit is generated.\n\t */\n\n\tif (round_idx >= nc_ctx->count) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"round_idx out of bounds (%ld >= %ld (count)) -> no rounding\",\n\t\t                     (long) round_idx, (long) nc_ctx->count));\n\t\treturn 0;\n\t} else if (round_idx < 0) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"round_idx out of bounds (%ld < 0) -> no rounding\",\n\t\t                     (long) round_idx));\n\t\treturn 0;\n\t}\n\n\t/*\n\t *  Round-up limit.\n\t *\n\t *  For even values, divides evenly, e.g. 10 -> roundup_limit=5.\n\t *\n\t *  For odd values, rounds up, e.g. 3 -> roundup_limit=2.\n\t *  If radix is 3, 0/3 -> down, 1/3 -> down, 2/3 -> up.\n\t */\n\troundup_limit = (duk_uint8_t) ((nc_ctx->B + 1) / 2);\n\n\tp = &nc_ctx->digits[round_idx];\n\tif (*p >= roundup_limit) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"fixed-format rounding carry required\"));\n\t\t/* carry */\n\t\tfor (;;) {\n\t\t\t*p = 0;\n\t\t\tif (p == &nc_ctx->digits[0]) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"carry propagated to first digit -> special case handling\"));\n\t\t\t\tDUK_MEMMOVE((void *) (&nc_ctx->digits[1]),\n\t\t\t\t            (const void *) (&nc_ctx->digits[0]),\n\t\t\t\t            (size_t) (sizeof(char) * nc_ctx->count));\n\t\t\t\tnc_ctx->digits[0] = 1;  /* don't increase 'count' */\n\t\t\t\tnc_ctx->k++;  /* position of highest digit changed */\n\t\t\t\tnc_ctx->count++;  /* number of digits changed */\n\t\t\t\tret = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"fixed-format rounding carry: B=%ld, roundup_limit=%ld, p=%p, digits=%p\",\n\t\t\t                     (long) nc_ctx->B, (long) roundup_limit, (void *) p, (void *) nc_ctx->digits));\n\t\t\tp--;\n\t\t\tt = *p;\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"digit before carry: %ld\", (long) t));\n\t\t\tif (++t < nc_ctx->B) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"rounding carry terminated\"));\n\t\t\t\t*p = (duk_uint8_t) t;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"wraps, carry to next digit\"));\n\t\t}\n\t}\n\n\treturn ret;\n}\n\n#define DUK__NO_EXP  (65536)  /* arbitrary marker, outside valid exp range */\n\nDUK_LOCAL void duk__dragon4_convert_and_push(duk__numconv_stringify_ctx *nc_ctx,\n                                          duk_context *ctx,\n                                          duk_small_int_t radix,\n                                          duk_small_int_t digits,\n                                          duk_small_uint_t flags,\n                                          duk_small_int_t neg) {\n\tduk_small_int_t k;\n\tduk_small_int_t pos, pos_end;\n\tduk_small_int_t expt;\n\tduk_small_int_t dig;\n\tduk_uint8_t *q;\n\tduk_uint8_t *buf;\n\n\t/*\n\t *  The string conversion here incorporates all the necessary Ecmascript\n\t *  semantics without attempting to be generic.  nc_ctx->digits contains\n\t *  nc_ctx->count digits (>= 1), with the topmost digit's 'position'\n\t *  indicated by nc_ctx->k as follows:\n\t *\n\t *    digits=\"123\" count=3 k=0   -->   0.123\n\t *    digits=\"123\" count=3 k=1   -->   1.23\n\t *    digits=\"123\" count=3 k=5   -->   12300\n\t *    digits=\"123\" count=3 k=-1  -->   0.0123\n\t *\n\t *  Note that the identifier names used for format selection are different\n\t *  in Burger-Dybvig paper and Ecmascript specification (quite confusingly\n\t *  so, because e.g. 'k' has a totally different meaning in each).  See\n\t *  documentation for discussion.\n\t *\n\t *  Ecmascript doesn't specify any specific behavior for format selection\n\t *  (e.g. when to use exponent notation) for non-base-10 numbers.\n\t *\n\t *  The bigint space in the context is reused for string output, as there\n\t *  is more than enough space for that (>1kB at the moment), and we avoid\n\t *  allocating even more stack.\n\t */\n\n\tDUK_ASSERT(DUK__NUMCONV_CTX_BIGINTS_SIZE >= DUK__MAX_FORMATTED_LENGTH);\n\tDUK_ASSERT(nc_ctx->count >= 1);\n\n\tk = nc_ctx->k;\n\tbuf = (duk_uint8_t *) &nc_ctx->f;  /* XXX: union would be more correct */\n\tq = buf;\n\n\t/* Exponent handling: if exponent format is used, record exponent value and\n\t * fake k such that one leading digit is generated (e.g. digits=123 -> \"1.23\").\n\t *\n\t * toFixed() prevents exponent use; otherwise apply a set of criteria to\n\t * match the other API calls (toString(), toPrecision, etc).\n\t */\n\n\texpt = DUK__NO_EXP;\n\tif (!nc_ctx->abs_pos /* toFixed() */) {\n\t\tif ((flags & DUK_N2S_FLAG_FORCE_EXP) ||             /* exponential notation forced */\n\t\t    ((flags & DUK_N2S_FLAG_NO_ZERO_PAD) &&          /* fixed precision and zero padding would be required */\n\t             (k - digits >= 1)) ||                          /* (e.g. k=3, digits=2 -> \"12X\") */\n\t\t    ((k > 21 || k <= -6) && (radix == 10))) {       /* toString() conditions */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"use exponential notation: k=%ld -> expt=%ld\",\n\t\t\t                     (long) k, (long) (k - 1)));\n\t\t\texpt = k - 1;  /* e.g. 12.3 -> digits=\"123\" k=2 -> 1.23e1 */\n\t\t\tk = 1;  /* generate mantissa with a single leading whole number digit */\n\t\t}\n\t}\n\n\tif (neg) {\n\t\t*q++ = '-';\n\t}\n\n\t/* Start position (inclusive) and end position (exclusive) */\n\tpos = (k >= 1 ? k : 1);\n\tif (nc_ctx->is_fixed) {\n\t\tif (nc_ctx->abs_pos) {\n\t\t\t/* toFixed() */\n\t\t\tpos_end = -digits;\n\t\t} else {\n\t\t\tpos_end = k - digits;\n\t\t}\n\t} else {\n\t\tpos_end = k - nc_ctx->count;\n\t}\n\tif (pos_end > 0) {\n\t\tpos_end = 0;\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"expt=%ld, k=%ld, count=%ld, pos=%ld, pos_end=%ld, is_fixed=%ld, \"\n\t                     \"digits=%ld, abs_pos=%ld\",\n\t                     (long) expt, (long) k, (long) nc_ctx->count, (long) pos, (long) pos_end,\n\t                     (long) nc_ctx->is_fixed, (long) digits, (long) nc_ctx->abs_pos));\n\n\t/* Digit generation */\n\twhile (pos > pos_end) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"digit generation: pos=%ld, pos_end=%ld\",\n\t\t                     (long) pos, (long) pos_end));\n\t\tif (pos == 0) {\n\t\t\t*q++ = (duk_uint8_t) '.';\n\t\t}\n\t\tif (pos > k) {\n\t\t\t*q++ = (duk_uint8_t) '0';\n\t\t} else if (pos <= k - nc_ctx->count) {\n\t\t\t*q++ = (duk_uint8_t) '0';\n\t\t} else {\n\t\t\tdig = nc_ctx->digits[k - pos];\n\t\t\tDUK_ASSERT(dig >= 0 && dig < nc_ctx->B);\n\t\t\t*q++ = (duk_uint8_t) DUK__DIGITCHAR(dig);\n\t\t}\n\n\t\tpos--;\n\t}\n\tDUK_ASSERT(pos <= 1);\n\n\t/* Exponent */\n\tif (expt != DUK__NO_EXP) {\n\t\t/*\n\t\t *  Exponent notation for non-base-10 numbers isn't specified in Ecmascript\n\t\t *  specification, as it never explicitly turns up: non-decimal numbers can\n\t\t *  only be formatted with Number.prototype.toString([radix]) and for that,\n\t\t *  behavior is not explicitly specified.\n\t\t *\n\t\t *  Logical choices include formatting the exponent as decimal (e.g. binary\n\t\t *  100000 as 1e+5) or in current radix (e.g. binary 100000 as 1e+101).\n\t\t *  The Dragon4 algorithm (in the original paper) prints the exponent value\n\t\t *  in the target radix B.  However, for radix values 15 and above, the\n\t\t *  exponent separator 'e' is no longer easily parseable.  Consider, for\n\t\t *  instance, the number \"1.faecee+1c\".\n\t\t */\n\n\t\tduk_size_t len;\n\t\tchar expt_sign;\n\n\t\t*q++ = 'e';\n\t\tif (expt >= 0) {\n\t\t\texpt_sign = '+';\n\t\t} else {\n\t\t\texpt_sign = '-';\n\t\t\texpt = -expt;\n\t\t}\n\t\t*q++ = (duk_uint8_t) expt_sign;\n\t\tlen = duk__dragon4_format_uint32(q, (duk_uint32_t) expt, radix);\n\t\tq += len;\n\t}\n\n\tduk_push_lstring(ctx, (const char *) buf, (size_t) (q - buf));\n}\n\n/*\n *  Conversion helpers\n */\n\nDUK_LOCAL void duk__dragon4_double_to_ctx(duk__numconv_stringify_ctx *nc_ctx, duk_double_t x) {\n\tduk_double_union u;\n\tduk_uint32_t tmp;\n\tduk_small_int_t expt;\n\n\t/*\n\t *    seeeeeee eeeeffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff\n\t *       A        B        C        D        E        F        G        H\n\t *\n\t *    s       sign bit\n\t *    eee...  exponent field\n\t *    fff...  fraction\n\t *\n\t *    ieee value = 1.ffff... * 2^(e - 1023)  (normal)\n\t *               = 0.ffff... * 2^(-1022)     (denormal)\n\t *\n\t *    algorithm v = f * b^e\n\t */\n\n\tDUK_DBLUNION_SET_DOUBLE(&u, x);\n\n\tnc_ctx->f.n = 2;\n\n\ttmp = DUK_DBLUNION_GET_LOW32(&u);\n\tnc_ctx->f.v[0] = tmp;\n\ttmp = DUK_DBLUNION_GET_HIGH32(&u);\n\tnc_ctx->f.v[1] = tmp & 0x000fffffUL;\n\texpt = (duk_small_int_t) ((tmp >> 20) & 0x07ffUL);\n\n\tif (expt == 0) {\n\t\t/* denormal */\n\t\texpt = DUK__IEEE_DOUBLE_EXP_MIN - 52;\n\t\tduk__bi_normalize(&nc_ctx->f);\n\t} else {\n\t\t/* normal: implicit leading 1-bit */\n\t\tnc_ctx->f.v[1] |= 0x00100000UL;\n\t\texpt = expt - DUK__IEEE_DOUBLE_EXP_BIAS - 52;\n\t\tDUK_ASSERT(duk__bi_is_valid(&nc_ctx->f));  /* true, because v[1] has at least one bit set */\n\t}\n\n\tDUK_ASSERT(duk__bi_is_valid(&nc_ctx->f));\n\n\tnc_ctx->e = expt;\n}\n\nDUK_LOCAL void duk__dragon4_ctx_to_double(duk__numconv_stringify_ctx *nc_ctx, duk_double_t *x) {\n\tduk_double_union u;\n\tduk_small_int_t expt;\n\tduk_small_int_t i;\n\tduk_small_int_t bitstart;\n\tduk_small_int_t bitround;\n\tduk_small_int_t bitidx;\n\tduk_small_int_t skip_round;\n\tduk_uint32_t t, v;\n\n\tDUK_ASSERT(nc_ctx->count == 53 + 1);\n\n\t/* Sometimes this assert is not true right now; it will be true after\n\t * rounding.  See: test-bug-numconv-mantissa-assert.js.\n\t */\n\tDUK_ASSERT_DISABLE(nc_ctx->digits[0] == 1);  /* zero handled by caller */\n\n\t/* Should not be required because the code below always sets both high\n\t * and low parts, but at least gcc-4.4.5 fails to deduce this correctly\n\t * (perhaps because the low part is set (seemingly) conditionally in a\n\t * loop), so this is here to avoid the bogus warning.\n\t */\n\tDUK_MEMZERO((void *) &u, sizeof(u));\n\n\t/*\n\t *  Figure out how generated digits match up with the mantissa,\n\t *  and then perform rounding.  If mantissa overflows, need to\n\t *  recompute the exponent (it is bumped and may overflow to\n\t *  infinity).\n\t *\n\t *  For normal numbers the leading '1' is hidden and ignored,\n\t *  and the last bit is used for rounding:\n\t *\n\t *                          rounding pt\n\t *       <--------52------->|\n\t *     1 x x x x ... x x x x|y  ==>  x x x x ... x x x x\n\t *\n\t *  For denormals, the leading '1' is included in the number,\n\t *  and the rounding point is different:\n\t *\n\t *                      rounding pt\n\t *     <--52 or less--->|\n\t *     1 x x x x ... x x|x x y  ==>  0 0 ... 1 x x ... x x\n\t *\n\t *  The largest denormals will have a mantissa beginning with\n\t *  a '1' (the explicit leading bit); smaller denormals will\n\t *  have leading zero bits.\n\t *\n\t *  If the exponent would become too high, the result becomes\n\t *  Infinity.  If the exponent is so small that the entire\n\t *  mantissa becomes zero, the result becomes zero.\n\t *\n\t *  Note: the Dragon4 'k' is off-by-one with respect to the IEEE\n\t *  exponent.  For instance, k==0 indicates that the leading '1'\n\t *  digit is at the first binary fraction position (0.1xxx...);\n\t *  the corresponding IEEE exponent would be -1.\n\t */\n\n\tskip_round = 0;\n\n recheck_exp:\n\n\texpt = nc_ctx->k - 1;   /* IEEE exp without bias */\n\tif (expt > 1023) {\n\t\t/* Infinity */\n\t\tbitstart = -255;  /* needed for inf: causes mantissa to become zero,\n\t\t                   * and rounding to be skipped.\n\t\t                   */\n\t\texpt = 2047;\n\t} else if (expt >= -1022) {\n\t\t/* normal */\n\t\tbitstart = 1;  /* skip leading digit */\n\t\texpt += DUK__IEEE_DOUBLE_EXP_BIAS;\n\t\tDUK_ASSERT(expt >= 1 && expt <= 2046);\n\t} else {\n\t\t/* denormal or zero */\n\t\tbitstart = 1023 + expt;  /* expt==-1023 -> bitstart=0 (leading 1);\n\t\t                          * expt==-1024 -> bitstart=-1 (one left of leading 1), etc\n\t\t                          */\n\t\texpt = 0;\n\t}\n\tbitround = bitstart + 52;\n\n\tDUK_DDD(DUK_DDDPRINT(\"ieee expt=%ld, bitstart=%ld, bitround=%ld\",\n\t                     (long) expt, (long) bitstart, (long) bitround));\n\n\tif (!skip_round) {\n\t\tif (duk__dragon4_fixed_format_round(nc_ctx, bitround)) {\n\t\t\t/* Corner case: see test-numconv-parse-mant-carry.js.  We could\n\t\t\t * just bump the exponent and update bitstart, but it's more robust\n\t\t\t * to recompute (but avoid rounding twice).\n\t\t\t */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"rounding caused exponent to be bumped, recheck exponent\"));\n\t\t\tskip_round = 1;\n\t\t\tgoto recheck_exp;\n\t\t}\n\t}\n\n\t/*\n\t *  Create mantissa\n\t */\n\n\tt = 0;\n\tfor (i = 0; i < 52; i++) {\n\t\tbitidx = bitstart + 52 - 1 - i;\n\t\tif (bitidx >= nc_ctx->count) {\n\t\t\tv = 0;\n\t\t} else if (bitidx < 0) {\n\t\t\tv = 0;\n\t\t} else {\n\t\t\tv = nc_ctx->digits[bitidx];\n\t\t}\n\t\tDUK_ASSERT(v == 0 || v == 1);\n\t\tt += v << (i % 32);\n\t\tif (i == 31) {\n\t\t\t/* low 32 bits is complete */\n\t\t\tDUK_DBLUNION_SET_LOW32(&u, t);\n\t\t\tt = 0;\n\t\t}\n\t}\n\t/* t has high mantissa */\n\n\tDUK_DDD(DUK_DDDPRINT(\"mantissa is complete: %08lx %08lx\",\n\t                     (unsigned long) t,\n\t                     (unsigned long) DUK_DBLUNION_GET_LOW32(&u)));\n\n\tDUK_ASSERT(expt >= 0 && expt <= 0x7ffL);\n\tt += expt << 20;\n#if 0  /* caller handles sign change */\n\tif (negative) {\n\t\tt |= 0x80000000U;\n\t}\n#endif\n\tDUK_DBLUNION_SET_HIGH32(&u, t);\n\n\tDUK_DDD(DUK_DDDPRINT(\"number is complete: %08lx %08lx\",\n\t                     (unsigned long) DUK_DBLUNION_GET_HIGH32(&u),\n\t                     (unsigned long) DUK_DBLUNION_GET_LOW32(&u)));\n\n\t*x = DUK_DBLUNION_GET_DOUBLE(&u);\n}\n\n/*\n *  Exposed number-to-string API\n *\n *  Input: [ number ]\n *  Output: [ string ]\n */\n\nDUK_INTERNAL void duk_numconv_stringify(duk_context *ctx, duk_small_int_t radix, duk_small_int_t digits, duk_small_uint_t flags) {\n\tduk_double_t x;\n\tduk_small_int_t c;\n\tduk_small_int_t neg;\n\tduk_uint32_t uval;\n\tduk__numconv_stringify_ctx nc_ctx_alloc;  /* large context; around 2kB now */\n\tduk__numconv_stringify_ctx *nc_ctx = &nc_ctx_alloc;\n\n\tx = (duk_double_t) duk_require_number(ctx, -1);\n\tduk_pop(ctx);\n\n\t/*\n\t *  Handle special cases (NaN, infinity, zero).\n\t */\n\n\tc = (duk_small_int_t) DUK_FPCLASSIFY(x);\n\tif (DUK_SIGNBIT((double) x)) {\n\t\tx = -x;\n\t\tneg = 1;\n\t} else {\n\t\tneg = 0;\n\t}\n\n\t/* NaN sign bit is platform specific with unpacked, un-normalized NaNs */\n\tDUK_ASSERT(c == DUK_FP_NAN || DUK_SIGNBIT((double) x) == 0);\n\n\tif (c == DUK_FP_NAN) {\n\t\tduk_push_hstring_stridx(ctx, DUK_STRIDX_NAN);\n\t\treturn;\n\t} else if (c == DUK_FP_INFINITE) {\n\t\tif (neg) {\n\t\t\t/* -Infinity */\n\t\t\tduk_push_hstring_stridx(ctx, DUK_STRIDX_MINUS_INFINITY);\n\t\t} else {\n\t\t\t/* Infinity */\n\t\t\tduk_push_hstring_stridx(ctx, DUK_STRIDX_INFINITY);\n\t\t}\n\t\treturn;\n\t} else if (c == DUK_FP_ZERO) {\n\t\t/* We can't shortcut zero here if it goes through special formatting\n\t\t * (such as forced exponential notation).\n\t\t */\n\t\t;\n\t}\n\n\t/*\n\t *  Handle integers in 32-bit range (that is, [-(2**32-1),2**32-1])\n\t *  specially, as they're very likely for embedded programs.  This\n\t *  is now done for all radix values.  We must be careful not to use\n\t *  the fast path when special formatting (e.g. forced exponential)\n\t *  is in force.\n\t *\n\t *  XXX: could save space by supporting radix 10 only and using\n\t *  sprintf \"%lu\" for the fast path and for exponent formatting.\n\t */\n\n\tuval = (unsigned int) x;\n\tif (((double) uval) == x &&  /* integer number in range */\n\t    flags == 0) {            /* no special formatting */\n\t\t/* use bigint area as a temp */\n\t\tduk_uint8_t *buf = (duk_uint8_t *) (&nc_ctx->f);\n\t\tduk_uint8_t *p = buf;\n\n\t\tDUK_ASSERT(DUK__NUMCONV_CTX_BIGINTS_SIZE >= 32 + 1);  /* max size: radix=2 + sign */\n\t\tif (neg && uval != 0) {\n\t\t\t/* no negative sign for zero */\n\t\t\t*p++ = (duk_uint8_t) '-';\n\t\t}\n\t\tp += duk__dragon4_format_uint32(p, uval, radix);\n\t\tduk_push_lstring(ctx, (const char *) buf, (duk_size_t) (p - buf));\n\t\treturn;\n\t}\n\n\t/*\n\t *  Dragon4 setup.\n\t *\n\t *  Convert double from IEEE representation for conversion;\n\t *  normal finite values have an implicit leading 1-bit.  The\n\t *  slow path algorithm doesn't handle zero, so zero is special\n\t *  cased here but still creates a valid nc_ctx, and goes\n\t *  through normal formatting in case special formatting has\n\t *  been requested (e.g. forced exponential format: 0 -> \"0e+0\").\n\t */\n\n\t/* Would be nice to bulk clear the allocation, but the context\n\t * is 1-2 kilobytes and nothing should rely on it being zeroed.\n\t */\n#if 0\n\tDUK_MEMZERO((void *) nc_ctx, sizeof(*nc_ctx));  /* slow init, do only for slow path cases */\n#endif\n\n\tnc_ctx->is_s2n = 0;\n\tnc_ctx->b = 2;\n\tnc_ctx->B = radix;\n\tnc_ctx->abs_pos = 0;\n\tif (flags & DUK_N2S_FLAG_FIXED_FORMAT) {\n\t\tnc_ctx->is_fixed = 1;\n\t\tif (flags & DUK_N2S_FLAG_FRACTION_DIGITS) {\n\t\t\t/* absolute req_digits; e.g. digits = 1 -> last digit is 0,\n\t\t\t * but add an extra digit for rounding.\n\t\t\t */\n\t\t\tnc_ctx->abs_pos = 1;\n\t\t\tnc_ctx->req_digits = (-digits + 1) - 1;\n\t\t} else {\n\t\t\tnc_ctx->req_digits = digits + 1;\n\t\t}\n\t} else {\n\t\tnc_ctx->is_fixed = 0;\n\t\tnc_ctx->req_digits = 0;\n\t}\n\n\tif (c == DUK_FP_ZERO) {\n\t\t/* Zero special case: fake requested number of zero digits; ensure\n\t\t * no sign bit is printed.  Relative and absolute fixed format\n\t\t * require separate handling.\n\t\t */\n\t\tduk_small_int_t count;\n\t\tif (nc_ctx->is_fixed) {\n\t\t\tif (nc_ctx->abs_pos) {\n\t\t\t\tcount = digits + 2;  /* lead zero + 'digits' fractions + 1 for rounding */\n\t\t\t} else {\n\t\t\t\tcount = digits + 1;  /* + 1 for rounding */\n\t\t\t}\n\t\t} else {\n\t\t\tcount = 1;\n\t\t}\n\t\tDUK_DDD(DUK_DDDPRINT(\"count=%ld\", (long) count));\n\t\tDUK_ASSERT(count >= 1);\n\t\tDUK_MEMZERO((void *) nc_ctx->digits, count);\n\t\tnc_ctx->count = count;\n\t\tnc_ctx->k = 1;  /* 0.000... */\n\t\tneg = 0;\n\t\tgoto zero_skip;\n\t}\n\n\tduk__dragon4_double_to_ctx(nc_ctx, x);   /* -> sets 'f' and 'e' */\n\tDUK__BI_PRINT(\"f\", &nc_ctx->f);\n\tDUK_DDD(DUK_DDDPRINT(\"e=%ld\", (long) nc_ctx->e));\n\n\t/*\n\t *  Dragon4 slow path digit generation.\n\t */\n\n\tduk__dragon4_prepare(nc_ctx);  /* setup many variables in nc_ctx */\n\n\tDUK_DDD(DUK_DDDPRINT(\"after prepare:\"));\n\tDUK__BI_PRINT(\"r\", &nc_ctx->r);\n\tDUK__BI_PRINT(\"s\", &nc_ctx->s);\n\tDUK__BI_PRINT(\"mp\", &nc_ctx->mp);\n\tDUK__BI_PRINT(\"mm\", &nc_ctx->mm);\n\n\tduk__dragon4_scale(nc_ctx);\n\n\tDUK_DDD(DUK_DDDPRINT(\"after scale; k=%ld\", (long) nc_ctx->k));\n\tDUK__BI_PRINT(\"r\", &nc_ctx->r);\n\tDUK__BI_PRINT(\"s\", &nc_ctx->s);\n\tDUK__BI_PRINT(\"mp\", &nc_ctx->mp);\n\tDUK__BI_PRINT(\"mm\", &nc_ctx->mm);\n\n\tduk__dragon4_generate(nc_ctx);\n\n\t/*\n\t *  Convert and push final string.\n\t */\n\n zero_skip:\n\n\tif (flags & DUK_N2S_FLAG_FIXED_FORMAT) {\n\t\t/* Perform fixed-format rounding. */\n\t\tduk_small_int_t roundpos;\n\t\tif (flags & DUK_N2S_FLAG_FRACTION_DIGITS) {\n\t\t\t/* 'roundpos' is relative to nc_ctx->k and increases to the right\n\t\t\t * (opposite of how 'k' changes).\n\t\t\t */\n\t\t\troundpos = -digits;  /* absolute position for digit considered for rounding */\n\t\t\troundpos = nc_ctx->k - roundpos;\n\t\t} else {\n\t\t\troundpos = digits;\n\t\t}\n\t\tDUK_DDD(DUK_DDDPRINT(\"rounding: k=%ld, count=%ld, digits=%ld, roundpos=%ld\",\n\t\t                     (long) nc_ctx->k, (long) nc_ctx->count, (long) digits, (long) roundpos));\n\t\t(void) duk__dragon4_fixed_format_round(nc_ctx, roundpos);\n\n\t\t/* Note: 'count' is currently not adjusted by rounding (i.e. the\n\t\t * digits are not \"chopped off\".  That shouldn't matter because\n\t\t * the digit position (absolute or relative) is passed on to the\n\t\t * convert-and-push function.\n\t\t */\n\t}\n\n\tduk__dragon4_convert_and_push(nc_ctx, ctx, radix, digits, flags, neg);\n}\n\n/*\n *  Exposed string-to-number API\n *\n *  Input: [ string ]\n *  Output: [ number ]\n *\n *  If number parsing fails, a NaN is pushed as the result.  If number parsing\n *  fails due to an internal error, an InternalError is thrown.\n */\n\nDUK_INTERNAL void duk_numconv_parse(duk_context *ctx, duk_small_int_t radix, duk_small_uint_t flags) {\n\tduk_hthread *thr = (duk_hthread *) ctx;\n\tduk__numconv_stringify_ctx nc_ctx_alloc;  /* large context; around 2kB now */\n\tduk__numconv_stringify_ctx *nc_ctx = &nc_ctx_alloc;\n\tduk_double_t res;\n\tduk_hstring *h_str;\n\tduk_small_int_t expt;\n\tduk_small_int_t expt_neg;\n\tduk_small_int_t expt_adj;\n\tduk_small_int_t neg;\n\tduk_small_int_t dig;\n\tduk_small_int_t dig_whole;\n\tduk_small_int_t dig_lzero;\n\tduk_small_int_t dig_frac;\n\tduk_small_int_t dig_expt;\n\tduk_small_int_t dig_prec;\n\tconst duk__exp_limits *explim;\n\tconst duk_uint8_t *p;\n\tduk_small_int_t ch;\n\n\tDUK_DDD(DUK_DDDPRINT(\"parse number: %!T, radix=%ld, flags=0x%08lx\",\n\t                     (duk_tval *) duk_get_tval(ctx, -1),\n\t                     (long) radix, (unsigned long) flags));\n\n\tDUK_ASSERT(radix >= 2 && radix <= 36);\n\tDUK_ASSERT(radix - 2 < (duk_small_int_t) sizeof(duk__str2num_digits_for_radix));\n\n\t/*\n\t *  Preliminaries: trim, sign, Infinity check\n\t *\n\t *  We rely on the interned string having a NUL terminator, which will\n\t *  cause a parse failure wherever it is encountered.  As a result, we\n\t *  don't need separate pointer checks.\n\t *\n\t *  There is no special parsing for 'NaN' in the specification although\n\t *  'Infinity' (with an optional sign) is allowed in some contexts.\n\t *  Some contexts allow plus/minus sign, while others only allow the\n\t *  minus sign (like JSON.parse()).\n\t *\n\t *  Automatic hex number detection (leading '0x' or '0X') and octal\n\t *  number detection (leading '0' followed by at least one octal digit)\n\t *  is done here too.\n\t *\n\t *  Symbols are not explicitly rejected here (that's up to the caller).\n\t *  If a symbol were passed here, it should ultimately safely fail\n\t *  parsing due to a syntax error.\n\t */\n\n\tif (flags & DUK_S2N_FLAG_TRIM_WHITE) {\n\t\t/* Leading / trailing whitespace is sometimes accepted and\n\t\t * sometimes not.  After white space trimming, all valid input\n\t\t * characters are pure ASCII.\n\t\t */\n\t\tduk_trim(ctx, -1);\n\t}\n\th_str = duk_require_hstring(ctx, -1);\n\tDUK_ASSERT(h_str != NULL);\n\tp = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_str);\n\n\tneg = 0;\n\tch = *p;\n\tif (ch == (duk_small_int_t) '+') {\n\t\tif ((flags & DUK_S2N_FLAG_ALLOW_PLUS) == 0) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"parse failed: leading plus sign not allowed\"));\n\t\t\tgoto parse_fail;\n\t\t}\n\t\tp++;\n\t} else if (ch == (duk_small_int_t) '-') {\n\t\tif ((flags & DUK_S2N_FLAG_ALLOW_MINUS) == 0) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"parse failed: leading minus sign not allowed\"));\n\t\t\tgoto parse_fail;\n\t\t}\n\t\tp++;\n\t\tneg = 1;\n\t}\n\n\tif ((flags & DUK_S2N_FLAG_ALLOW_INF) && DUK_STRNCMP((const char *) p, \"Infinity\", 8) == 0) {\n\t\t/* Don't check for Infinity unless the context allows it.\n\t\t * 'Infinity' is a valid integer literal in e.g. base-36:\n\t\t *\n\t\t *   parseInt('Infinity', 36)\n\t\t *   1461559270678\n\t\t */\n\n\t\tif ((flags & DUK_S2N_FLAG_ALLOW_GARBAGE) == 0 && p[8] != DUK_ASC_NUL) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"parse failed: trailing garbage after matching 'Infinity' not allowed\"));\n\t\t\tgoto parse_fail;\n\t\t} else {\n\t\t\tres = DUK_DOUBLE_INFINITY;\n\t\t\tgoto negcheck_and_ret;\n\t\t}\n\t}\n\tch = *p;\n\tif (ch == (duk_small_int_t) '0') {\n\t\tduk_small_int_t detect_radix = 0;\n\t\tch = DUK_LOWERCASE_CHAR_ASCII(p[1]);  /* 'x' or 'X' -> 'x' */\n\t\tif ((flags & DUK_S2N_FLAG_ALLOW_AUTO_HEX_INT) && ch == DUK_ASC_LC_X) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"detected 0x/0X hex prefix, changing radix and preventing fractions and exponent\"));\n\t\t\tdetect_radix = 16;\n#if 0\n\t\t} else if ((flags & DUK_S2N_FLAG_ALLOW_AUTO_LEGACY_OCT_INT) &&\n\t\t           (ch >= (duk_small_int_t) '0' && ch <= (duk_small_int_t) '9')) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"detected 0n oct prefix, changing radix and preventing fractions and exponent\"));\n\t\t\tdetect_radix = 8;\n\n\t\t\t/* NOTE: if this legacy octal case is added back, it has\n\t\t\t * different flags and 'p' advance so this needs to be\n\t\t\t * reworked.\n\t\t\t */\n\t\t\tflags |= DUK_S2N_FLAG_ALLOW_EMPTY_AS_ZERO;  /* interpret e.g. '09' as '0', not NaN */\n\t\t\tp += 1;\n#endif\n\t\t} else if ((flags & DUK_S2N_FLAG_ALLOW_AUTO_OCT_INT) && ch == DUK_ASC_LC_O) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"detected 0o oct prefix, changing radix and preventing fractions and exponent\"));\n\t\t\tdetect_radix = 8;\n\t\t} else if ((flags & DUK_S2N_FLAG_ALLOW_AUTO_BIN_INT) && ch == DUK_ASC_LC_B) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"detected 0b bin prefix, changing radix and preventing fractions and exponent\"));\n\t\t\tdetect_radix = 2;\n\t\t}\n\t\tif (detect_radix > 0) {\n\t\t\tradix = detect_radix;\n\t\t\t/* Clear empty as zero flag: interpret e.g. '0x' and '0xg' as a NaN (= parse error) */\n\t\t\tflags &= ~(DUK_S2N_FLAG_ALLOW_EXP | DUK_S2N_FLAG_ALLOW_EMPTY_FRAC |\n\t\t\t           DUK_S2N_FLAG_ALLOW_FRAC | DUK_S2N_FLAG_ALLOW_NAKED_FRAC |\n\t\t\t           DUK_S2N_FLAG_ALLOW_EMPTY_AS_ZERO);\n\t\t\tflags |= DUK_S2N_FLAG_ALLOW_LEADING_ZERO;  /* allow e.g. '0x0009' and '0b00010001' */\n\t\t\tp += 2;\n\t\t}\n\t}\n\n\t/*\n\t *  Scan number and setup for Dragon4.\n\t *\n\t *  The fast path case is detected during setup: an integer which\n\t *  can be converted without rounding, no net exponent.  The fast\n\t *  path could be implemented as a separate scan, but may not really\n\t *  be worth it: the multiplications for building 'f' are not\n\t *  expensive when 'f' is small.\n\t *\n\t *  The significand ('f') must contain enough bits of (apparent)\n\t *  accuracy, so that Dragon4 will generate enough binary output digits.\n\t *  For decimal numbers, this means generating a 20-digit significand,\n\t *  which should yield enough practical accuracy to parse IEEE doubles.\n\t *  In fact, the Ecmascript specification explicitly allows an\n\t *  implementation to treat digits beyond 20 as zeroes (and even\n\t *  to round the 20th digit upwards).  For non-decimal numbers, the\n\t *  appropriate number of digits has been precomputed for comparable\n\t *  accuracy.\n\t *\n\t *  Digit counts:\n\t *\n\t *    [ dig_lzero ]\n\t *      |\n\t *     .+-..---[ dig_prec ]----.\n\t *     |  ||                   |\n\t *     0000123.456789012345678901234567890e+123456\n\t *     |     | |                         |  |    |\n\t *     `--+--' `------[ dig_frac ]-------'  `-+--'\n\t *        |                                   |\n\t *    [ dig_whole ]                       [ dig_expt ]\n\t *\n\t *    dig_frac and dig_expt are -1 if not present\n\t *    dig_lzero is only computed for whole number part\n\t *\n\t *  Parsing state\n\t *\n\t *     Parsing whole part      dig_frac < 0 AND dig_expt < 0\n\t *     Parsing fraction part   dig_frac >= 0 AND dig_expt < 0\n\t *     Parsing exponent part   dig_expt >= 0   (dig_frac may be < 0 or >= 0)\n\t *\n\t *  Note: in case we hit an implementation limit (like exponent range),\n\t *  we should throw an error, NOT return NaN or Infinity.  Even with\n\t *  very large exponent (or significand) values the final result may be\n\t *  finite, so NaN/Infinity would be incorrect.\n\t */\n\n\tduk__bi_set_small(&nc_ctx->f, 0);\n\tdig_prec = 0;\n\tdig_lzero = 0;\n\tdig_whole = 0;\n\tdig_frac = -1;\n\tdig_expt = -1;\n\texpt = 0;\n\texpt_adj = 0;  /* essentially tracks digit position of lowest 'f' digit */\n\texpt_neg = 0;\n\tfor (;;) {\n\t\tch = *p++;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"parse digits: p=%p, ch='%c' (%ld), expt=%ld, expt_adj=%ld, \"\n\t\t                     \"dig_whole=%ld, dig_frac=%ld, dig_expt=%ld, dig_lzero=%ld, dig_prec=%ld\",\n\t\t                     (const void *) p, (int) ((ch >= 0x20 && ch <= 0x7e) ? ch : '?'), (long) ch,\n\t\t                     (long) expt, (long) expt_adj, (long) dig_whole, (long) dig_frac,\n\t\t                     (long) dig_expt, (long) dig_lzero, (long) dig_prec));\n\t\tDUK__BI_PRINT(\"f\", &nc_ctx->f);\n\n\t\t/* Most common cases first. */\n\t\tif (ch >= (duk_small_int_t) '0' && ch <= (duk_small_int_t) '9') {\n\t\t\tdig = (duk_small_int_t) ch - '0' + 0;\n\t\t} else if (ch == (duk_small_int_t) '.') {\n\t\t\t/* A leading digit is not required in some cases, e.g. accept \".123\".\n\t\t\t * In other cases (JSON.parse()) a leading digit is required.  This\n\t\t\t * is checked for after the loop.\n\t\t\t */\n\t\t\tif (dig_frac >= 0 || dig_expt >= 0) {\n\t\t\t\tif (flags & DUK_S2N_FLAG_ALLOW_GARBAGE) {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"garbage termination (invalid period)\"));\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"parse failed: period not allowed\"));\n\t\t\t\t\tgoto parse_fail;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ((flags & DUK_S2N_FLAG_ALLOW_FRAC) == 0) {\n\t\t\t\t/* Some contexts don't allow fractions at all; this can't be a\n\t\t\t\t * post-check because the state ('f' and expt) would be incorrect.\n\t\t\t\t */\n\t\t\t\tif (flags & DUK_S2N_FLAG_ALLOW_GARBAGE) {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"garbage termination (invalid first period)\"));\n\t\t\t\t\tbreak;\n\t\t\t\t} else {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"parse failed: fraction part not allowed\"));\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"start fraction part\"));\n\t\t\tdig_frac = 0;\n\t\t\tcontinue;\n\t\t} else if (ch == (duk_small_int_t) 0) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"NUL termination\"));\n\t\t\tbreak;\n\t\t} else if ((flags & DUK_S2N_FLAG_ALLOW_EXP) &&\n\t\t           dig_expt < 0 && (ch == (duk_small_int_t) 'e' || ch == (duk_small_int_t) 'E')) {\n\t\t\t/* Note: we don't parse back exponent notation for anything else\n\t\t\t * than radix 10, so this is not an ambiguous check (e.g. hex\n\t\t\t * exponent values may have 'e' either as a significand digit\n\t\t\t * or as an exponent separator).\n\t\t\t *\n\t\t\t * If the exponent separator occurs twice, 'e' will be interpreted\n\t\t\t * as a digit (= 14) and will be rejected as an invalid decimal\n\t\t\t * digit.\n\t\t\t */\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"start exponent part\"));\n\n\t\t\t/* Exponent without a sign or with a +/- sign is accepted\n\t\t\t * by all call sites (even JSON.parse()).\n\t\t\t */\n\t\t\tch = *p;\n\t\t\tif (ch == (duk_small_int_t) '-') {\n\t\t\t\texpt_neg = 1;\n\t\t\t\tp++;\n\t\t\t} else if (ch == (duk_small_int_t) '+') {\n\t\t\t\tp++;\n\t\t\t}\n\t\t\tdig_expt = 0;\n\t\t\tcontinue;\n\t\t} else if (ch >= (duk_small_int_t) 'a' && ch <= (duk_small_int_t) 'z') {\n\t\t\tdig = (duk_small_int_t) (ch - (duk_small_int_t) 'a' + 0x0a);\n\t\t} else if (ch >= (duk_small_int_t) 'A' && ch <= (duk_small_int_t) 'Z') {\n\t\t\tdig = (duk_small_int_t) (ch - (duk_small_int_t) 'A' + 0x0a);\n\t\t} else {\n\t\t\tdig = 255;  /* triggers garbage digit check below */\n\t\t}\n\t\tDUK_ASSERT((dig >= 0 && dig <= 35) || dig == 255);\n\n\t\tif (dig >= radix) {\n\t\t\tif (flags & DUK_S2N_FLAG_ALLOW_GARBAGE) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"garbage termination\"));\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"parse failed: trailing garbage or invalid digit\"));\n\t\t\t\tgoto parse_fail;\n\t\t\t}\n\t\t}\n\n\t\tif (dig_expt < 0) {\n\t\t\t/* whole or fraction digit */\n\n\t\t\tif (dig_prec < duk__str2num_digits_for_radix[radix - 2]) {\n\t\t\t\t/* significant from precision perspective */\n\n\t\t\t\tduk_small_int_t f_zero = duk__bi_is_zero(&nc_ctx->f);\n\t\t\t\tif (f_zero && dig == 0) {\n\t\t\t\t\t/* Leading zero is not counted towards precision digits; not\n\t\t\t\t\t * in the integer part, nor in the fraction part.\n\t\t\t\t\t */\n\t\t\t\t\tif (dig_frac < 0) {\n\t\t\t\t\t\tdig_lzero++;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t/* XXX: join these ops (multiply-accumulate), but only if\n\t\t\t\t\t * code footprint decreases.\n\t\t\t\t\t */\n\t\t\t\t\tduk__bi_mul_small(&nc_ctx->t1, &nc_ctx->f, radix);\n\t\t\t\t\tduk__bi_add_small(&nc_ctx->f, &nc_ctx->t1, dig);\n\t\t\t\t\tdig_prec++;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t/* Ignore digits beyond a radix-specific limit, but note them\n\t\t\t\t * in expt_adj.\n\t\t\t\t */\n\t\t\t\texpt_adj++;\n\t\t\t}\n\n\t\t\tif (dig_frac >= 0) {\n\t\t\t\tdig_frac++;\n\t\t\t\texpt_adj--;\n\t\t\t} else {\n\t\t\t\tdig_whole++;\n\t\t\t}\n\t\t} else {\n\t\t\t/* exponent digit */\n\n\t\t\texpt = expt * radix + dig;\n\t\t\tif (expt > DUK_S2N_MAX_EXPONENT) {\n\t\t\t\t/* impose a reasonable exponent limit, so that exp\n\t\t\t\t * doesn't need to get tracked using a bigint.\n\t\t\t\t */\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"parse failed: exponent too large\"));\n\t\t\t\tgoto parse_explimit_error;\n\t\t\t}\n\t\t\tdig_expt++;\n\t\t}\n\t}\n\n\t/* Leading zero. */\n\n\tif (dig_lzero > 0 && dig_whole > 1) {\n\t\tif ((flags & DUK_S2N_FLAG_ALLOW_LEADING_ZERO) == 0) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"parse failed: leading zeroes not allowed in integer part\"));\n\t\t\tgoto parse_fail;\n\t\t}\n\t}\n\n\t/* Validity checks for various fraction formats (\"0.1\", \".1\", \"1.\", \".\"). */\n\n\tif (dig_whole == 0) {\n\t\tif (dig_frac == 0) {\n\t\t\t/* \".\" is not accepted in any format */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"parse failed: plain period without leading or trailing digits\"));\n\t\t\tgoto parse_fail;\n\t\t} else if (dig_frac > 0) {\n\t\t\t/* \".123\" */\n\t\t\tif ((flags & DUK_S2N_FLAG_ALLOW_NAKED_FRAC) == 0) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"parse failed: fraction part not allowed without \"\n\t\t\t\t                     \"leading integer digit(s)\"));\n\t\t\t\tgoto parse_fail;\n\t\t\t}\n\t\t} else {\n\t\t\t/* empty (\"\") is allowed in some formats (e.g. Number(''), as zero */\n\t\t\tif ((flags & DUK_S2N_FLAG_ALLOW_EMPTY_AS_ZERO) == 0) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"parse failed: empty string not allowed (as zero)\"));\n\t\t\t\tgoto parse_fail;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tif (dig_frac == 0) {\n\t\t\t/* \"123.\" is allowed in some formats */\n\t\t\tif ((flags & DUK_S2N_FLAG_ALLOW_EMPTY_FRAC) == 0) {\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"parse failed: empty fractions\"));\n\t\t\t\tgoto parse_fail;\n\t\t\t}\n\t\t} else if (dig_frac > 0) {\n\t\t\t/* \"123.456\" */\n\t\t\t;\n\t\t} else {\n\t\t\t/* \"123\" */\n\t\t\t;\n\t\t}\n\t}\n\n\t/* Exponent without digits (e.g. \"1e\" or \"1e+\").  If trailing garbage is\n\t * allowed, ignore exponent part as garbage (= parse as \"1\", i.e. exp 0).\n\t */\n\n\tif (dig_expt == 0) {\n\t\tif ((flags & DUK_S2N_FLAG_ALLOW_GARBAGE) == 0) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"parse failed: empty exponent\"));\n\t\t\tgoto parse_fail;\n\t\t}\n\t\tDUK_ASSERT(expt == 0);\n\t}\n\n\tif (expt_neg) {\n\t\texpt = -expt;\n\t}\n\tDUK_DDD(DUK_DDDPRINT(\"expt=%ld, expt_adj=%ld, net exponent -> %ld\",\n\t                     (long) expt, (long) expt_adj, (long) (expt + expt_adj)));\n\texpt += expt_adj;\n\n\t/* Fast path check. */\n\n\tif (nc_ctx->f.n <= 1 &&   /* 32-bit value */\n\t    expt == 0    /* no net exponent */) {\n\t\t/* Fast path is triggered for no exponent and also for balanced exponent\n\t\t * and fraction parts, e.g. for \"1.23e2\" == \"123\".  Remember to respect\n\t\t * zero sign.\n\t\t */\n\n\t\t/* XXX: could accept numbers larger than 32 bits, e.g. up to 53 bits? */\n\t\tDUK_DDD(DUK_DDDPRINT(\"fast path number parse\"));\n\t\tif (nc_ctx->f.n == 1) {\n\t\t\tres = (double) nc_ctx->f.v[0];\n\t\t} else {\n\t\t\tres = 0.0;\n\t\t}\n\t\tgoto negcheck_and_ret;\n\t}\n\n\t/* Significand ('f') padding. */\n\n\twhile (dig_prec < duk__str2num_digits_for_radix[radix - 2]) {\n\t\t/* Pad significand with \"virtual\" zero digits so that Dragon4 will\n\t\t * have enough (apparent) precision to work with.\n\t\t */\n\t\tDUK_DDD(DUK_DDDPRINT(\"dig_prec=%ld, pad significand with zero\", (long) dig_prec));\n\t\tduk__bi_mul_small_copy(&nc_ctx->f, radix, &nc_ctx->t1);\n\t\tDUK__BI_PRINT(\"f\", &nc_ctx->f);\n\t\texpt--;\n\t\tdig_prec++;\n\t}\n\n\tDUK_DDD(DUK_DDDPRINT(\"final exponent: %ld\", (long) expt));\n\n\t/* Detect zero special case. */\n\n\tif (nc_ctx->f.n == 0) {\n\t\t/* This may happen even after the fast path check, if exponent is\n\t\t * not balanced (e.g. \"0e1\").  Remember to respect zero sign.\n\t\t */\n\t\tDUK_DDD(DUK_DDDPRINT(\"significand is zero\"));\n\t\tres = 0.0;\n\t\tgoto negcheck_and_ret;\n\t}\n\n\n\t/* Quick reject of too large or too small exponents.  This check\n\t * would be incorrect for zero (e.g. \"0e1000\" is zero, not Infinity)\n\t * so zero check must be above.\n\t */\n\n\texplim = &duk__str2num_exp_limits[radix - 2];\n\tif (expt > explim->upper) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"exponent too large -> infinite\"));\n\t\tres = (duk_double_t) DUK_DOUBLE_INFINITY;\n\t\tgoto negcheck_and_ret;\n\t} else if (expt < explim->lower) {\n\t\tDUK_DDD(DUK_DDDPRINT(\"exponent too small -> zero\"));\n\t\tres = (duk_double_t) 0.0;\n\t\tgoto negcheck_and_ret;\n\t}\n\n\tnc_ctx->is_s2n = 1;\n\tnc_ctx->e = expt;\n\tnc_ctx->b = radix;\n\tnc_ctx->B = 2;\n\tnc_ctx->is_fixed = 1;\n\tnc_ctx->abs_pos = 0;\n\tnc_ctx->req_digits = 53 + 1;\n\n\tDUK__BI_PRINT(\"f\", &nc_ctx->f);\n\tDUK_DDD(DUK_DDDPRINT(\"e=%ld\", (long) nc_ctx->e));\n\n\t/*\n\t *  Dragon4 slow path (binary) digit generation.\n\t *  An extra digit is generated for rounding.\n\t */\n\n\tduk__dragon4_prepare(nc_ctx);  /* setup many variables in nc_ctx */\n\n\tDUK_DDD(DUK_DDDPRINT(\"after prepare:\"));\n\tDUK__BI_PRINT(\"r\", &nc_ctx->r);\n\tDUK__BI_PRINT(\"s\", &nc_ctx->s);\n\tDUK__BI_PRINT(\"mp\", &nc_ctx->mp);\n\tDUK__BI_PRINT(\"mm\", &nc_ctx->mm);\n\n\tduk__dragon4_scale(nc_ctx);\n\n\tDUK_DDD(DUK_DDDPRINT(\"after scale; k=%ld\", (long) nc_ctx->k));\n\tDUK__BI_PRINT(\"r\", &nc_ctx->r);\n\tDUK__BI_PRINT(\"s\", &nc_ctx->s);\n\tDUK__BI_PRINT(\"mp\", &nc_ctx->mp);\n\tDUK__BI_PRINT(\"mm\", &nc_ctx->mm);\n\n\tduk__dragon4_generate(nc_ctx);\n\n\tDUK_ASSERT(nc_ctx->count == 53 + 1);\n\n\t/*\n\t *  Convert binary digits into an IEEE double.  Need to handle\n\t *  denormals and rounding correctly.\n\t *\n\t *  Some call sites currently assume the result is always a\n\t *  non-fastint double.  If this is changed, check all call\n\t *  sites.\n\t */\n\n\tduk__dragon4_ctx_to_double(nc_ctx, &res);\n\tgoto negcheck_and_ret;\n\n negcheck_and_ret:\n\tif (neg) {\n\t\tres = -res;\n\t}\n\tduk_pop(ctx);\n\tduk_push_number(ctx, (double) res);\n\tDUK_DDD(DUK_DDDPRINT(\"result: %!T\", (duk_tval *) duk_get_tval(ctx, -1)));\n\treturn;\n\n parse_fail:\n\tDUK_DDD(DUK_DDDPRINT(\"parse failed\"));\n\tduk_pop(ctx);\n\tduk_push_nan(ctx);\n\treturn;\n\n parse_explimit_error:\n\tDUK_DDD(DUK_DDDPRINT(\"parse failed, internal error, can't return a value\"));\n\tDUK_ERROR_RANGE(thr, \"exponent too large\");\n\treturn;\n}\n\n/* automatic undefs */\n#undef DUK__BI_MAX_PARTS\n#undef DUK__BI_PRINT\n#undef DUK__DIGITCHAR\n#undef DUK__DRAGON4_OUTPUT_PREINC\n#undef DUK__IEEE_DOUBLE_EXP_BIAS\n#undef DUK__IEEE_DOUBLE_EXP_MIN\n#undef DUK__MAX_FORMATTED_LENGTH\n#undef DUK__MAX_OUTPUT_DIGITS\n#undef DUK__NO_EXP\n#undef DUK__NUMCONV_CTX_BIGINTS_SIZE\n#undef DUK__NUMCONV_CTX_NUM_BIGINTS\n/*\n *  Regexp compilation.\n *\n *  See doc/regexp.rst for a discussion of the compilation approach and\n *  current limitations.\n *\n *  Regexp bytecode assumes jumps can be expressed with signed 32-bit\n *  integers.  Consequently the bytecode size must not exceed 0x7fffffffL.\n *  The implementation casts duk_size_t (buffer size) to duk_(u)int32_t\n *  in many places.  Although this could be changed, the bytecode format\n *  limit would still prevent regexps exceeding the signed 32-bit limit\n *  from working.\n *\n *  XXX: The implementation does not prevent bytecode from exceeding the\n *  maximum supported size.  This could be done by limiting the maximum\n *  input string size (assuming an upper bound can be computed for number\n *  of bytecode bytes emitted per input byte) or checking buffer maximum\n *  size when emitting bytecode (slower).\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\n/*\n *  Helper macros\n */\n\n#define DUK__RE_INITIAL_BUFSIZE 64\n\n#define DUK__RE_BUFLEN(re_ctx) \\\n\tDUK_BW_GET_SIZE(re_ctx->thr, &re_ctx->bw)\n\n/*\n *  Disjunction struct: result of parsing a disjunction\n */\n\ntypedef struct {\n\t/* Number of characters that the atom matches (e.g. 3 for 'abc'),\n\t * -1 if atom is complex and number of matched characters either\n\t * varies or is not known.\n\t */\n\tduk_int32_t charlen;\n\n#if 0\n\t/* These are not needed to implement quantifier capture handling,\n\t * but might be needed at some point.\n\t */\n\n\t/* re_ctx->captures at start and end of atom parsing.\n\t * Since 'captures' indicates highest capture number emitted\n\t * so far in a DUK_REOP_SAVE, the captures numbers saved by\n\t * the atom are: ]start_captures,end_captures].\n\t */\n\tduk_uint32_t start_captures;\n\tduk_uint32_t end_captures;\n#endif\n} duk__re_disjunction_info;\n\n/*\n *  Encoding helpers\n *\n *  Some of the typing is bytecode based, e.g. slice sizes are unsigned 32-bit\n *  even though the buffer operations will use duk_size_t.\n */\n\n/* XXX: the insert helpers should ensure that the bytecode result is not\n * larger than expected (or at least assert for it).  Many things in the\n * bytecode, like skip offsets, won't work correctly if the bytecode is\n * larger than say 2G.\n */\n\nDUK_LOCAL duk_uint32_t duk__encode_i32(duk_int32_t x) {\n\tif (x < 0) {\n\t\treturn ((duk_uint32_t) (-x)) * 2 + 1;\n\t} else {\n\t\treturn ((duk_uint32_t) x) * 2;\n\t}\n}\n\n/* XXX: return type should probably be duk_size_t, or explicit checks are needed for\n * maximum size.\n */\nDUK_LOCAL duk_uint32_t duk__insert_u32(duk_re_compiler_ctx *re_ctx, duk_uint32_t offset, duk_uint32_t x) {\n\tduk_uint8_t buf[DUK_UNICODE_MAX_XUTF8_LENGTH];\n\tduk_small_int_t len;\n\n\tlen = duk_unicode_encode_xutf8((duk_ucodepoint_t) x, buf);\n\tDUK_BW_INSERT_ENSURE_BYTES(re_ctx->thr, &re_ctx->bw, offset, buf, len);\n\treturn (duk_uint32_t) len;\n}\n\nDUK_LOCAL void duk__append_u32(duk_re_compiler_ctx *re_ctx, duk_uint32_t x) {\n\tDUK_BW_WRITE_ENSURE_XUTF8(re_ctx->thr, &re_ctx->bw, x);\n}\n\nDUK_LOCAL void duk__append_7bit(duk_re_compiler_ctx *re_ctx, duk_uint32_t x) {\n#if defined(DUK_USE_PREFER_SIZE)\n\tduk__append_u32(re_ctx, x);\n#else\n\tDUK_ASSERT(x <= 0x7fU);\n\tDUK_BW_WRITE_ENSURE_U8(re_ctx->thr, &re_ctx->bw, (duk_uint8_t) x);\n#endif\n}\n\n#if 0\nDUK_LOCAL void duk__append_2bytes(duk_re_compiler_ctx *re_ctx, duk_uint8_t x, duk_uint8_t y) {\n\tDUK_BW_WRITE_ENSURE_U8_2(re_ctx->thr, &re_ctx->bw, x, y);\n}\n#endif\n\nDUK_LOCAL duk_uint32_t duk__insert_i32(duk_re_compiler_ctx *re_ctx, duk_uint32_t offset, duk_int32_t x) {\n\treturn duk__insert_u32(re_ctx, offset, duk__encode_i32(x));\n}\n\nDUK_LOCAL void duk__append_reop(duk_re_compiler_ctx *re_ctx, duk_uint32_t reop) {\n\tDUK_ASSERT(reop <= 0x7fU);\n\t(void) duk__append_7bit(re_ctx, reop);\n}\n\n#if 0  /* unused */\nDUK_LOCAL void duk__append_i32(duk_re_compiler_ctx *re_ctx, duk_int32_t x) {\n\tduk__append_u32(re_ctx, duk__encode_i32(x));\n}\n#endif\n\n/* special helper for emitting u16 lists (used for character ranges for built-in char classes) */\nDUK_LOCAL void duk__append_u16_list(duk_re_compiler_ctx *re_ctx, const duk_uint16_t *values, duk_uint32_t count) {\n\t/* Call sites don't need the result length so it's not accumulated. */\n\twhile (count-- > 0) {\n\t\tduk__append_u32(re_ctx, (duk_uint32_t) (*values++));\n\t}\n}\n\nDUK_LOCAL void duk__insert_slice(duk_re_compiler_ctx *re_ctx, duk_uint32_t offset, duk_uint32_t data_offset, duk_uint32_t data_length) {\n\tDUK_BW_INSERT_ENSURE_SLICE(re_ctx->thr, &re_ctx->bw, offset, data_offset, data_length);\n}\n\nDUK_LOCAL void duk__append_slice(duk_re_compiler_ctx *re_ctx, duk_uint32_t data_offset, duk_uint32_t data_length) {\n\tDUK_BW_WRITE_ENSURE_SLICE(re_ctx->thr, &re_ctx->bw, data_offset, data_length);\n}\n\nDUK_LOCAL void duk__remove_slice(duk_re_compiler_ctx *re_ctx, duk_uint32_t data_offset, duk_uint32_t data_length) {\n\tDUK_BW_REMOVE_ENSURE_SLICE(re_ctx->thr, &re_ctx->bw, data_offset, data_length);\n}\n\n/*\n *  Insert a jump offset at 'offset' to complete an instruction\n *  (the jump offset is always the last component of an instruction).\n *  The 'skip' argument must be computed relative to 'offset',\n *  -without- taking into account the skip field being inserted.\n *\n *       ... A B C ins X Y Z ...   (ins may be a JUMP, SPLIT1/SPLIT2, etc)\n *   =>  ... A B C ins SKIP X Y Z\n *\n *  Computing the final (adjusted) skip value, which is relative to the\n *  first byte of the next instruction, is a bit tricky because of the\n *  variable length UTF-8 encoding.  See doc/regexp.rst for discussion.\n */\nDUK_LOCAL duk_uint32_t duk__insert_jump_offset(duk_re_compiler_ctx *re_ctx, duk_uint32_t offset, duk_int32_t skip) {\n#if 0\n\t/* Iterative solution. */\n\tif (skip < 0) {\n\t\tduk_small_int_t len;\n\t\t/* two encoding attempts suffices */\n\t\tlen = duk_unicode_get_xutf8_length((duk_codepoint_t) duk__encode_i32(skip));\n\t\tlen = duk_unicode_get_xutf8_length((duk_codepoint_t) duk__encode_i32(skip - (duk_int32_t) len));\n\t\tDUK_ASSERT(duk_unicode_get_xutf8_length(duk__encode_i32(skip - (duk_int32_t) len)) == len);  /* no change */\n\t\tskip -= (duk_int32_t) len;\n\t}\n#endif\n\n#if defined(DUK_USE_PREFER_SIZE)\n\t/* Closed form solution, this produces smallest code.\n\t * See re_neg_jump_offset (closed2).\n\t */\n\tif (skip < 0) {\n\t\tskip--;\n\t\tif (skip < -0x3fL) {\n\t\t\tskip--;\n\t\t}\n\t\tif (skip < -0x3ffL) {\n\t\t\tskip--;\n\t\t}\n\t\tif (skip < -0x7fffL) {\n\t\t\tskip--;\n\t\t}\n\t\tif (skip < -0xfffffL) {\n\t\t\tskip--;\n\t\t}\n\t\tif (skip < -0x1ffffffL) {\n\t\t\tskip--;\n\t\t}\n\t\tif (skip < -0x3fffffffL) {\n\t\t\tskip--;\n\t\t}\n\t}\n#else  /* DUK_USE_PREFER_SIZE */\n\t/* Closed form solution, this produces fastest code.\n\t * See re_neg_jump_offset (closed1).\n\t */\n\tif (skip < 0) {\n\t\tif (skip >= -0x3eL) {\n\t\t\tskip -= 1;\n\t\t} else if (skip >= -0x3fdL) {\n\t\t\tskip -= 2;\n\t\t} else if (skip >= -0x7ffcL) {\n\t\t\tskip -= 3;\n\t\t} else if (skip >= -0xffffbL) {\n\t\t\tskip -= 4;\n\t\t} else if (skip >= -0x1fffffaL) {\n\t\t\tskip -= 5;\n\t\t} else if (skip >= -0x3ffffff9L) {\n\t\t\tskip -= 6;\n\t\t} else {\n\t\t\tskip -= 7;\n\t\t}\n\t}\n#endif  /* DUK_USE_PREFER_SIZE */\n\n\treturn duk__insert_i32(re_ctx, offset, skip);\n}\n\nDUK_LOCAL duk_uint32_t duk__append_jump_offset(duk_re_compiler_ctx *re_ctx, duk_int32_t skip) {\n\treturn (duk_uint32_t) duk__insert_jump_offset(re_ctx, (duk_uint32_t) DUK__RE_BUFLEN(re_ctx), skip);\n}\n\n/*\n *  duk_re_range_callback for generating character class ranges.\n *\n *  When ignoreCase is false, the range is simply emitted as is.\n *  We don't, for instance, eliminate duplicates or overlapping\n *  ranges in a character class.\n *\n *  When ignoreCase is true, the range needs to be normalized through\n *  canonicalization.  Unfortunately a canonicalized version of a\n *  continuous range is not necessarily continuous (e.g. [x-{] is\n *  continuous but [X-{] is not).  The current algorithm creates the\n *  canonicalized range(s) space efficiently at the cost of compile\n *  time execution time (see doc/regexp.rst for discussion).\n *\n *  Note that the ctx->nranges is a context-wide temporary value\n *  (this is OK because there cannot be multiple character classes\n *  being parsed simultaneously).\n */\n\nDUK_LOCAL void duk__generate_ranges(void *userdata, duk_codepoint_t r1, duk_codepoint_t r2, duk_bool_t direct) {\n\tduk_re_compiler_ctx *re_ctx = (duk_re_compiler_ctx *) userdata;\n\n\tDUK_DD(DUK_DDPRINT(\"duk__generate_ranges(): re_ctx=%p, range=[%ld,%ld] direct=%ld\",\n\t                   (void *) re_ctx, (long) r1, (long) r2, (long) direct));\n\n\tif (!direct && (re_ctx->re_flags & DUK_RE_FLAG_IGNORE_CASE)) {\n\t\t/*\n\t\t *  Canonicalize a range, generating result ranges as necessary.\n\t\t *  Needs to exhaustively scan the entire range (at most 65536\n\t\t *  code points).  If 'direct' is set, caller (lexer) has ensured\n\t\t *  that the range is already canonicalization compatible (this\n\t\t *  is used to avoid unnecessary canonicalization of built-in\n\t\t *  ranges like \\W, which are not affected by canonicalization).\n\t\t *\n\t\t *  NOTE: here is one place where we don't want to support chars\n\t\t *  outside the BMP, because the exhaustive search would be\n\t\t *  massively larger.\n\t\t */\n\n\t\tduk_codepoint_t i;\n\t\tduk_codepoint_t t;\n\t\tduk_codepoint_t r_start, r_end;\n\n\t\tr_start = duk_unicode_re_canonicalize_char(re_ctx->thr, r1);\n\t\tr_end = r_start;\n\t\tfor (i = r1 + 1; i <= r2; i++) {\n\t\t\tt = duk_unicode_re_canonicalize_char(re_ctx->thr, i);\n\t\t\tif (t == r_end + 1) {\n\t\t\t\tr_end = t;\n\t\t\t} else {\n\t\t\t\tDUK_DD(DUK_DDPRINT(\"canonicalized, emit range: [%ld,%ld]\", (long) r_start, (long) r_end));\n\t\t\t\tduk__append_u32(re_ctx, (duk_uint32_t) r_start);\n\t\t\t\tduk__append_u32(re_ctx, (duk_uint32_t) r_end);\n\t\t\t\tre_ctx->nranges++;\n\t\t\t\tr_start = t;\n\t\t\t\tr_end = t;\n\t\t\t}\n\t\t}\n\t\tDUK_DD(DUK_DDPRINT(\"canonicalized, emit range: [%ld,%ld]\", (long) r_start, (long) r_end));\n\t\tduk__append_u32(re_ctx, (duk_uint32_t) r_start);\n\t\tduk__append_u32(re_ctx, (duk_uint32_t) r_end);\n\t\tre_ctx->nranges++;\n\t} else {\n\t\tDUK_DD(DUK_DDPRINT(\"direct, emit range: [%ld,%ld]\", (long) r1, (long) r2));\n\t\tduk__append_u32(re_ctx, (duk_uint32_t) r1);\n\t\tduk__append_u32(re_ctx, (duk_uint32_t) r2);\n\t\tre_ctx->nranges++;\n\t}\n}\n\n/*\n *  Parse regexp Disjunction.  Most of regexp compilation happens here.\n *\n *  Handles Disjunction, Alternative, and Term productions directly without\n *  recursion.  The only constructs requiring recursion are positive/negative\n *  lookaheads, capturing parentheses, and non-capturing parentheses.\n *\n *  The function determines whether the entire disjunction is a 'simple atom'\n *  (see doc/regexp.rst discussion on 'simple quantifiers') and if so,\n *  returns the atom character length which is needed by the caller to keep\n *  track of its own atom character length.  A disjunction with more than one\n *  alternative is never considered a simple atom (although in some cases\n *  that might be the case).\n *\n *  Return value: simple atom character length or < 0 if not a simple atom.\n *  Appends the bytecode for the disjunction matcher to the end of the temp\n *  buffer.\n *\n *  Regexp top level structure is:\n *\n *    Disjunction = Term*\n *                | Term* | Disjunction\n *\n *    Term = Assertion\n *         | Atom\n *         | Atom Quantifier\n *\n *  An empty Term sequence is a valid disjunction alternative (e.g. /|||c||/).\n *\n *  Notes:\n *\n *    * Tracking of the 'simple-ness' of the current atom vs. the entire\n *      disjunction are separate matters.  For instance, the disjunction\n *      may be complex, but individual atoms may be simple.  Furthermore,\n *      simple quantifiers are used whenever possible, even if the\n *      disjunction as a whole is complex.\n *\n *    * The estimate of whether an atom is simple is conservative now,\n *      and it would be possible to expand it.  For instance, captures\n *      cause the disjunction to be marked complex, even though captures\n *      -can- be handled by simple quantifiers with some minor modifications.\n *\n *    * Disjunction 'tainting' as 'complex' is handled at the end of the\n *      main for loop collectively for atoms.  Assertions, quantifiers,\n *      and '|' tokens need to taint the result manually if necessary.\n *      Assertions cannot add to result char length, only atoms (and\n *      quantifiers) can; currently quantifiers will taint the result\n *      as complex though.\n */\n\nDUK_LOCAL const duk_uint16_t * const duk__re_range_lookup1[3] = {\n\tduk_unicode_re_ranges_digit,\n\tduk_unicode_re_ranges_white,\n\tduk_unicode_re_ranges_wordchar\n};\nDUK_LOCAL const duk_uint8_t duk__re_range_lookup2[3] = {\n\tsizeof(duk_unicode_re_ranges_digit) / (2 * sizeof(duk_uint16_t)),\n\tsizeof(duk_unicode_re_ranges_white) / (2 * sizeof(duk_uint16_t)),\n\tsizeof(duk_unicode_re_ranges_wordchar) / (2 * sizeof(duk_uint16_t))\n};\n\nDUK_LOCAL void duk__append_range_atom_matcher(duk_re_compiler_ctx *re_ctx, duk_small_uint_t re_op, const duk_uint16_t *ranges, duk_small_uint_t count) {\n#if 0\n\tDUK_ASSERT(re_op <= 0x7fUL);\n\tDUK_ASSERT(count <= 0x7fUL);\n\tduk__append_2bytes(re_ctx, (duk_uint8_t) re_op, (duk_uint8_t) count);\n#endif\n\tduk__append_reop(re_ctx, re_op);\n\tduk__append_7bit(re_ctx, count);\n\tduk__append_u16_list(re_ctx, ranges, count * 2);\n}\n\nDUK_LOCAL void duk__parse_disjunction(duk_re_compiler_ctx *re_ctx, duk_bool_t expect_eof, duk__re_disjunction_info *out_atom_info) {\n\tduk_int32_t atom_start_offset = -1;                   /* negative -> no atom matched on previous round */\n\tduk_int32_t atom_char_length = 0;                     /* negative -> complex atom */\n\tduk_uint32_t atom_start_captures = re_ctx->captures;  /* value of re_ctx->captures at start of atom */\n\tduk_int32_t unpatched_disjunction_split = -1;\n\tduk_int32_t unpatched_disjunction_jump = -1;\n\tduk_uint32_t entry_offset = (duk_uint32_t) DUK__RE_BUFLEN(re_ctx);\n\tduk_int32_t res_charlen = 0;  /* -1 if disjunction is complex, char length if simple */\n\tduk__re_disjunction_info tmp_disj;\n\n\tDUK_ASSERT(out_atom_info != NULL);\n\n\tif (re_ctx->recursion_depth >= re_ctx->recursion_limit) {\n\t\tDUK_ERROR_RANGE(re_ctx->thr, DUK_STR_REGEXP_COMPILER_RECURSION_LIMIT);\n\t}\n\tre_ctx->recursion_depth++;\n\n#if 0\n\tout_atom_info->start_captures = re_ctx->captures;\n#endif\n\n\tfor (;;) {\n\t\t/* atom_char_length, atom_start_offset, atom_start_offset reflect the\n\t\t * atom matched on the previous loop.  If a quantifier is encountered\n\t\t * on this loop, these are needed to handle the quantifier correctly.\n\t\t * new_atom_char_length etc are for the atom parsed on this round;\n\t\t * they're written to atom_char_length etc at the end of the round.\n\t\t */\n\t\tduk_int32_t new_atom_char_length;   /* char length of the atom parsed in this loop */\n\t\tduk_int32_t new_atom_start_offset;  /* bytecode start offset of the atom parsed in this loop\n\t\t                                     * (allows quantifiers to copy the atom bytecode)\n\t\t                                     */\n\t\tduk_uint32_t new_atom_start_captures;  /* re_ctx->captures at the start of the atom parsed in this loop */\n\n\t\tduk_lexer_parse_re_token(&re_ctx->lex, &re_ctx->curr_token);\n\n\t\tDUK_DD(DUK_DDPRINT(\"re token: %ld (num=%ld, char=%c)\",\n\t\t                   (long) re_ctx->curr_token.t,\n\t\t                   (long) re_ctx->curr_token.num,\n\t\t                   (re_ctx->curr_token.num >= 0x20 && re_ctx->curr_token.num <= 0x7e) ?\n\t\t                   (int) re_ctx->curr_token.num : (int) '?'));\n\n\t\t/* set by atom case clauses */\n\t\tnew_atom_start_offset = -1;\n\t\tnew_atom_char_length = -1;\n\t\tnew_atom_start_captures = re_ctx->captures;\n\n\t\tswitch (re_ctx->curr_token.t) {\n\t\tcase DUK_RETOK_DISJUNCTION: {\n\t\t\t/*\n\t\t\t *  The handling here is a bit tricky.  If a previous '|' has been processed,\n\t\t\t *  we have a pending split1 and a pending jump (for a previous match).  These\n\t\t\t *  need to be back-patched carefully.  See docs for a detailed example.\n\t\t\t */\n\n\t\t\t/* patch pending jump and split */\n\t\t\tif (unpatched_disjunction_jump >= 0) {\n\t\t\t\tduk_uint32_t offset;\n\n\t\t\t\tDUK_ASSERT(unpatched_disjunction_split >= 0);\n\t\t\t\toffset = unpatched_disjunction_jump;\n\t\t\t\toffset += duk__insert_jump_offset(re_ctx,\n\t\t\t\t                                  offset,\n\t\t\t\t                                  (duk_int32_t) (DUK__RE_BUFLEN(re_ctx) - offset));\n\t\t\t\t/* offset is now target of the pending split (right after jump) */\n\t\t\t\tduk__insert_jump_offset(re_ctx,\n\t\t\t\t                        unpatched_disjunction_split,\n\t\t\t\t                        offset - unpatched_disjunction_split);\n\t\t\t}\n\n\t\t\t/* add a new pending split to the beginning of the entire disjunction */\n\t\t\t(void) duk__insert_u32(re_ctx,\n\t\t\t                       entry_offset,\n\t\t\t                       DUK_REOP_SPLIT1);   /* prefer direct execution */\n\t\t\tunpatched_disjunction_split = entry_offset + 1;   /* +1 for opcode */\n\n\t\t\t/* add a new pending match jump for latest finished alternative */\n\t\t\tduk__append_reop(re_ctx, DUK_REOP_JUMP);\n\t\t\tunpatched_disjunction_jump = (duk_int32_t) DUK__RE_BUFLEN(re_ctx);\n\n\t\t\t/* 'taint' result as complex */\n\t\t\tres_charlen = -1;\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_RETOK_QUANTIFIER: {\n\t\t\tif (atom_start_offset < 0) {\n\t\t\t\tDUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_INVALID_QUANTIFIER_NO_ATOM);\n\t\t\t}\n\t\t\tif (re_ctx->curr_token.qmin > re_ctx->curr_token.qmax) {\n\t\t\t\tDUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_INVALID_QUANTIFIER_VALUES);\n\t\t\t}\n\t\t\tif (atom_char_length >= 0) {\n\t\t\t\t/*\n\t\t\t\t *  Simple atom\n\t\t\t\t *\n\t\t\t\t *  If atom_char_length is zero, we'll have unbounded execution time for e.g.\n\t\t\t\t *  /()*x/.exec('x').  We can't just skip the match because it might have some\n\t\t\t\t *  side effects (for instance, if we allowed captures in simple atoms, the\n\t\t\t\t *  capture needs to happen).  The simple solution below is to force the\n\t\t\t\t *  quantifier to match at most once, since the additional matches have no effect.\n\t\t\t\t *\n\t\t\t\t *  With a simple atom there can be no capture groups, so no captures need\n\t\t\t\t *  to be reset.\n\t\t\t\t */\n\t\t\t\tduk_int32_t atom_code_length;\n\t\t\t\tduk_uint32_t offset;\n\t\t\t\tduk_uint32_t qmin, qmax;\n\n\t\t\t\tqmin = re_ctx->curr_token.qmin;\n\t\t\t\tqmax = re_ctx->curr_token.qmax;\n\t\t\t\tif (atom_char_length == 0) {\n\t\t\t\t\t/* qmin and qmax will be 0 or 1 */\n\t\t\t\t\tif (qmin > 1) {\n\t\t\t\t\t\tqmin = 1;\n\t\t\t\t\t}\n\t\t\t\t\tif (qmax > 1) {\n\t\t\t\t\t\tqmax = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tduk__append_reop(re_ctx, DUK_REOP_MATCH);   /* complete 'sub atom' */\n\t\t\t\tatom_code_length = (duk_int32_t) (DUK__RE_BUFLEN(re_ctx) - atom_start_offset);\n\n\t\t\t\toffset = atom_start_offset;\n\t\t\t\tif (re_ctx->curr_token.greedy) {\n\t\t\t\t\toffset += duk__insert_u32(re_ctx, offset, DUK_REOP_SQGREEDY);\n\t\t\t\t\toffset += duk__insert_u32(re_ctx, offset, qmin);\n\t\t\t\t\toffset += duk__insert_u32(re_ctx, offset, qmax);\n\t\t\t\t\toffset += duk__insert_u32(re_ctx, offset, atom_char_length);\n\t\t\t\t\toffset += duk__insert_jump_offset(re_ctx, offset, atom_code_length);\n\t\t\t\t} else {\n\t\t\t\t\toffset += duk__insert_u32(re_ctx, offset, DUK_REOP_SQMINIMAL);\n\t\t\t\t\toffset += duk__insert_u32(re_ctx, offset, qmin);\n\t\t\t\t\toffset += duk__insert_u32(re_ctx, offset, qmax);\n\t\t\t\t\toffset += duk__insert_jump_offset(re_ctx, offset, atom_code_length);\n\t\t\t\t}\n\t\t\t\tDUK_UNREF(offset);  /* silence scan-build warning */\n\t\t\t} else {\n\t\t\t\t/*\n\t\t\t\t *  Complex atom\n\t\t\t\t *\n\t\t\t\t *  The original code is used as a template, and removed at the end\n\t\t\t\t *  (this differs from the handling of simple quantifiers).\n\t\t\t\t *\n\t\t\t\t *  NOTE: there is no current solution for empty atoms in complex\n\t\t\t\t *  quantifiers.  This would need some sort of a 'progress' instruction.\n\t\t\t\t *\n\t\t\t\t *  XXX: impose limit on maximum result size, i.e. atom_code_len * atom_copies?\n\t\t\t\t */\n\t\t\t\tduk_int32_t atom_code_length;\n\t\t\t\tduk_uint32_t atom_copies;\n\t\t\t\tduk_uint32_t tmp_qmin, tmp_qmax;\n\n\t\t\t\t/* pre-check how many atom copies we're willing to make (atom_copies not needed below) */\n\t\t\t\tatom_copies = (re_ctx->curr_token.qmax == DUK_RE_QUANTIFIER_INFINITE) ?\n\t\t\t\t              re_ctx->curr_token.qmin : re_ctx->curr_token.qmax;\n\t\t\t\tif (atom_copies > DUK_RE_MAX_ATOM_COPIES) {\n\t\t\t\t\tDUK_ERROR_RANGE(re_ctx->thr, DUK_STR_QUANTIFIER_TOO_MANY_COPIES);\n\t\t\t\t}\n\n\t\t\t\t/* wipe the capture range made by the atom (if any) */\n\t\t\t\tDUK_ASSERT(atom_start_captures <= re_ctx->captures);\n\t\t\t\tif (atom_start_captures != re_ctx->captures) {\n\t\t\t\t\tDUK_ASSERT(atom_start_captures < re_ctx->captures);\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"must wipe ]atom_start_captures,re_ctx->captures]: ]%ld,%ld]\",\n\t\t\t\t\t                     (long) atom_start_captures, (long) re_ctx->captures));\n\n\t\t\t\t\t/* insert (DUK_REOP_WIPERANGE, start, count) in reverse order so the order ends up right */\n\t\t\t\t\tduk__insert_u32(re_ctx, atom_start_offset, (re_ctx->captures - atom_start_captures) * 2);\n\t\t\t\t\tduk__insert_u32(re_ctx, atom_start_offset, (atom_start_captures + 1) * 2);\n\t\t\t\t\tduk__insert_u32(re_ctx, atom_start_offset, DUK_REOP_WIPERANGE);\n\t\t\t\t} else {\n\t\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"no need to wipe captures: atom_start_captures == re_ctx->captures == %ld\",\n\t\t\t\t\t                     (long) atom_start_captures));\n\t\t\t\t}\n\n\t\t\t\tatom_code_length = (duk_int32_t) DUK__RE_BUFLEN(re_ctx) - atom_start_offset;\n\n\t\t\t\t/* insert the required matches (qmin) by copying the atom */\n\t\t\t\ttmp_qmin = re_ctx->curr_token.qmin;\n\t\t\t\ttmp_qmax = re_ctx->curr_token.qmax;\n\t\t\t\twhile (tmp_qmin > 0) {\n\t\t\t\t\tduk__append_slice(re_ctx, atom_start_offset, atom_code_length);\n\t\t\t\t\ttmp_qmin--;\n\t\t\t\t\tif (tmp_qmax != DUK_RE_QUANTIFIER_INFINITE) {\n\t\t\t\t\t\ttmp_qmax--;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tDUK_ASSERT(tmp_qmin == 0);\n\n\t\t\t\t/* insert code for matching the remainder - infinite or finite */\n\t\t\t\tif (tmp_qmax == DUK_RE_QUANTIFIER_INFINITE) {\n\t\t\t\t\t/* reuse last emitted atom for remaining 'infinite' quantifier */\n\n\t\t\t\t\tif (re_ctx->curr_token.qmin == 0) {\n\t\t\t\t\t\t/* Special case: original qmin was zero so there is nothing\n\t\t\t\t\t\t * to repeat.  Emit an atom copy but jump over it here.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tduk__append_reop(re_ctx, DUK_REOP_JUMP);\n\t\t\t\t\t\tduk__append_jump_offset(re_ctx, atom_code_length);\n\t\t\t\t\t\tduk__append_slice(re_ctx, atom_start_offset, atom_code_length);\n\t\t\t\t\t}\n\t\t\t\t\tif (re_ctx->curr_token.greedy) {\n\t\t\t\t\t\tduk__append_reop(re_ctx, DUK_REOP_SPLIT2);   /* prefer jump */\n\t\t\t\t\t} else {\n\t\t\t\t\t\tduk__append_reop(re_ctx, DUK_REOP_SPLIT1);   /* prefer direct */\n\t\t\t\t\t}\n\t\t\t\t\tduk__append_jump_offset(re_ctx, -atom_code_length - 1);  /* -1 for opcode */\n\t\t\t\t} else {\n\t\t\t\t\t/*\n\t\t\t\t\t *  The remaining matches are emitted as sequence of SPLITs and atom\n\t\t\t\t\t *  copies; the SPLITs skip the remaining copies and match the sequel.\n\t\t\t\t\t *  This sequence needs to be emitted starting from the last copy\n\t\t\t\t\t *  because the SPLITs are variable length due to the variable length\n\t\t\t\t\t *  skip offset.  This causes a lot of memory copying now.\n\t\t\t\t\t *\n\t\t\t\t\t *  Example structure (greedy, match maximum # atoms):\n\t\t\t\t\t *\n\t\t\t\t\t *      SPLIT1 LSEQ\n\t\t\t\t\t *      (atom)\n\t\t\t\t\t *      SPLIT1 LSEQ    ; <- the byte length of this instruction is needed\n\t\t\t\t\t *      (atom)         ; to encode the above SPLIT1 correctly\n\t\t\t\t\t *      ...\n\t\t\t\t\t *   LSEQ:\n\t\t\t\t\t */\n\t\t\t\t\tduk_uint32_t offset = (duk_uint32_t) DUK__RE_BUFLEN(re_ctx);\n\t\t\t\t\twhile (tmp_qmax > 0) {\n\t\t\t\t\t\tduk__insert_slice(re_ctx, offset, atom_start_offset, atom_code_length);\n\t\t\t\t\t\tif (re_ctx->curr_token.greedy) {\n\t\t\t\t\t\t\tduk__insert_u32(re_ctx, offset, DUK_REOP_SPLIT1);   /* prefer direct */\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tduk__insert_u32(re_ctx, offset, DUK_REOP_SPLIT2);   /* prefer jump */\n\t\t\t\t\t\t}\n\t\t\t\t\t\tduk__insert_jump_offset(re_ctx,\n\t\t\t\t\t\t                        offset + 1,   /* +1 for opcode */\n\t\t\t\t\t\t                        (duk_int32_t) (DUK__RE_BUFLEN(re_ctx) - (offset + 1)));\n\t\t\t\t\t\ttmp_qmax--;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t/* remove the original 'template' atom */\n\t\t\t\tduk__remove_slice(re_ctx, atom_start_offset, atom_code_length);\n\t\t\t}\n\n\t\t\t/* 'taint' result as complex */\n\t\t\tres_charlen = -1;\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_RETOK_ASSERT_START: {\n\t\t\tduk__append_reop(re_ctx, DUK_REOP_ASSERT_START);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_RETOK_ASSERT_END: {\n\t\t\tduk__append_reop(re_ctx, DUK_REOP_ASSERT_END);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_RETOK_ASSERT_WORD_BOUNDARY: {\n\t\t\tduk__append_reop(re_ctx, DUK_REOP_ASSERT_WORD_BOUNDARY);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_RETOK_ASSERT_NOT_WORD_BOUNDARY: {\n\t\t\tduk__append_reop(re_ctx, DUK_REOP_ASSERT_NOT_WORD_BOUNDARY);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_RETOK_ASSERT_START_POS_LOOKAHEAD:\n\t\tcase DUK_RETOK_ASSERT_START_NEG_LOOKAHEAD: {\n\t\t\tduk_uint32_t offset;\n\t\t\tduk_uint32_t opcode = (re_ctx->curr_token.t == DUK_RETOK_ASSERT_START_POS_LOOKAHEAD) ?\n\t\t\t                      DUK_REOP_LOOKPOS : DUK_REOP_LOOKNEG;\n\n\t\t\toffset = (duk_uint32_t) DUK__RE_BUFLEN(re_ctx);\n\t\t\tduk__parse_disjunction(re_ctx, 0, &tmp_disj);\n\t\t\tduk__append_reop(re_ctx, DUK_REOP_MATCH);\n\n\t\t\t(void) duk__insert_u32(re_ctx, offset, opcode);\n\t\t\t(void) duk__insert_jump_offset(re_ctx,\n\t\t\t                               offset + 1,   /* +1 for opcode */\n\t\t\t                               (duk_int32_t) (DUK__RE_BUFLEN(re_ctx) - (offset + 1)));\n\n\t\t\t/* 'taint' result as complex -- this is conservative,\n\t\t\t * as lookaheads do not backtrack.\n\t\t\t */\n\t\t\tres_charlen = -1;\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_RETOK_ATOM_PERIOD: {\n\t\t\tnew_atom_char_length = 1;\n\t\t\tnew_atom_start_offset = (duk_int32_t) DUK__RE_BUFLEN(re_ctx);\n\t\t\tduk__append_reop(re_ctx, DUK_REOP_PERIOD);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_RETOK_ATOM_CHAR: {\n\t\t\t/* Note: successive characters could be joined into string matches\n\t\t\t * but this is not trivial (consider e.g. '/xyz+/); see docs for\n\t\t\t * more discussion.\n\t\t\t *\n\t\t\t * No support for \\u{H+} yet.  While only BMP Unicode escapes are\n\t\t\t * supported for RegExps at present, 'ch' may still be a non-BMP\n\t\t\t * codepoint if it is decoded straight from source text UTF-8.\n\t\t\t * There's no non-BMP support yet so this is handled simply by\n\t\t\t * matching the non-BMP character (which is custom behavior).\n\t\t\t */\n\t\t\tduk_uint32_t ch;\n\n\t\t\tnew_atom_char_length = 1;\n\t\t\tnew_atom_start_offset = (duk_int32_t) DUK__RE_BUFLEN(re_ctx);\n\t\t\tduk__append_reop(re_ctx, DUK_REOP_CHAR);\n\t\t\tch = re_ctx->curr_token.num;\n\t\t\tif (re_ctx->re_flags & DUK_RE_FLAG_IGNORE_CASE) {\n\t\t\t\tch = duk_unicode_re_canonicalize_char(re_ctx->thr, ch);\n\t\t\t}\n\t\t\tduk__append_u32(re_ctx, ch);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_RETOK_ATOM_DIGIT:\n\t\tcase DUK_RETOK_ATOM_NOT_DIGIT:\n\t\tcase DUK_RETOK_ATOM_WHITE:\n\t\tcase DUK_RETOK_ATOM_NOT_WHITE:\n\t\tcase DUK_RETOK_ATOM_WORD_CHAR:\n\t\tcase DUK_RETOK_ATOM_NOT_WORD_CHAR: {\n\t\t\tduk_small_uint_t re_op;\n\t\t\tduk_small_uint_t idx;\n\n\t\t\tnew_atom_char_length = 1;\n\t\t\tnew_atom_start_offset = (duk_int32_t) DUK__RE_BUFLEN(re_ctx);\n\n\t\t\tDUK_ASSERT((DUK_RETOK_ATOM_DIGIT & 0x01) != 0);\n\t\t\tDUK_ASSERT((DUK_RETOK_ATOM_WHITE & 0x01) != 0);\n\t\t\tDUK_ASSERT((DUK_RETOK_ATOM_WORD_CHAR & 0x01) != 0);\n\t\t\tDUK_ASSERT((DUK_RETOK_ATOM_NOT_DIGIT & 0x01) == 0);\n\t\t\tDUK_ASSERT((DUK_RETOK_ATOM_NOT_WHITE & 0x01) == 0);\n\t\t\tDUK_ASSERT((DUK_RETOK_ATOM_NOT_WORD_CHAR & 0x01) == 0);\n\t\t\tre_op = (re_ctx->curr_token.t & 0x01) ? DUK_REOP_RANGES : DUK_REOP_INVRANGES;\n\n\t\t\tDUK_ASSERT(DUK_RETOK_ATOM_WHITE == DUK_RETOK_ATOM_DIGIT + 2);\n\t\t\tDUK_ASSERT(DUK_RETOK_ATOM_WORD_CHAR == DUK_RETOK_ATOM_DIGIT + 4);\n\t\t\tidx = (re_ctx->curr_token.t - DUK_RETOK_ATOM_DIGIT) >> 1;\n\t\t\tDUK_ASSERT(idx <= 2);  /* Assume continuous token numbers; also checks negative underflow. */\n\n\t\t\tduk__append_range_atom_matcher(re_ctx, re_op, duk__re_range_lookup1[idx], duk__re_range_lookup2[idx]);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_RETOK_ATOM_BACKREFERENCE: {\n\t\t\tduk_uint32_t backref = (duk_uint32_t) re_ctx->curr_token.num;\n\t\t\tif (backref > re_ctx->highest_backref) {\n\t\t\t\tre_ctx->highest_backref = backref;\n\t\t\t}\n\t\t\tnew_atom_char_length = -1;   /* mark as complex */\n\t\t\tnew_atom_start_offset = (duk_int32_t) DUK__RE_BUFLEN(re_ctx);\n\t\t\tduk__append_reop(re_ctx, DUK_REOP_BACKREFERENCE);\n\t\t\tduk__append_u32(re_ctx, backref);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_RETOK_ATOM_START_CAPTURE_GROUP: {\n\t\t\tduk_uint32_t cap;\n\n\t\t\tnew_atom_char_length = -1;   /* mark as complex (capture handling) */\n\t\t\tnew_atom_start_offset = (duk_int32_t) DUK__RE_BUFLEN(re_ctx);\n\t\t\tcap = ++re_ctx->captures;\n\t\t\tduk__append_reop(re_ctx, DUK_REOP_SAVE);\n\t\t\tduk__append_u32(re_ctx, cap * 2);\n\t\t\tduk__parse_disjunction(re_ctx, 0, &tmp_disj);  /* retval (sub-atom char length) unused, tainted as complex above */\n\t\t\tduk__append_reop(re_ctx, DUK_REOP_SAVE);\n\t\t\tduk__append_u32(re_ctx, cap * 2 + 1);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_RETOK_ATOM_START_NONCAPTURE_GROUP: {\n\t\t\tnew_atom_start_offset = (duk_int32_t) DUK__RE_BUFLEN(re_ctx);\n\t\t\tduk__parse_disjunction(re_ctx, 0, &tmp_disj);\n\t\t\tnew_atom_char_length = tmp_disj.charlen;\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_RETOK_ATOM_START_CHARCLASS:\n\t\tcase DUK_RETOK_ATOM_START_CHARCLASS_INVERTED: {\n\t\t\t/*\n\t\t\t *  Range parsing is done with a special lexer function which calls\n\t\t\t *  us for every range parsed.  This is different from how rest of\n\t\t\t *  the parsing works, but avoids a heavy, arbitrary size intermediate\n\t\t\t *  value type to hold the ranges.\n\t\t\t *\n\t\t\t *  Another complication is the handling of character ranges when\n\t\t\t *  case insensitive matching is used (see docs for discussion).\n\t\t\t *  The range handler callback given to the lexer takes care of this\n\t\t\t *  as well.\n\t\t\t *\n\t\t\t *  Note that duplicate ranges are not eliminated when parsing character\n\t\t\t *  classes, so that canonicalization of\n\t\t\t *\n\t\t\t *    [0-9a-fA-Fx-{]\n\t\t\t *\n\t\t\t *  creates the result (note the duplicate ranges):\n\t\t\t *\n\t\t\t *    [0-9A-FA-FX-Z{-{]\n\t\t\t *\n\t\t\t *  where [x-{] is split as a result of canonicalization.  The duplicate\n\t\t\t *  ranges are not a semantics issue: they work correctly.\n\t\t\t */\n\n\t\t\tduk_uint32_t offset;\n\n\t\t\tDUK_DD(DUK_DDPRINT(\"character class\"));\n\n\t\t\t/* insert ranges instruction, range count patched in later */\n\t\t\tnew_atom_char_length = 1;\n\t\t\tnew_atom_start_offset = (duk_int32_t) DUK__RE_BUFLEN(re_ctx);\n\t\t\tduk__append_reop(re_ctx,\n\t\t\t                 (re_ctx->curr_token.t == DUK_RETOK_ATOM_START_CHARCLASS) ?\n\t\t\t                 DUK_REOP_RANGES : DUK_REOP_INVRANGES);\n\t\t\toffset = (duk_uint32_t) DUK__RE_BUFLEN(re_ctx);    /* patch in range count later */\n\n\t\t\t/* parse ranges until character class ends */\n\t\t\tre_ctx->nranges = 0;    /* note: ctx-wide temporary */\n\t\t\tduk_lexer_parse_re_ranges(&re_ctx->lex, duk__generate_ranges, (void *) re_ctx);\n\n\t\t\t/* insert range count */\n\t\t\tduk__insert_u32(re_ctx, offset, re_ctx->nranges);\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_RETOK_ATOM_END_GROUP: {\n\t\t\tif (expect_eof) {\n\t\t\t\tDUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_UNEXPECTED_CLOSING_PAREN);\n\t\t\t}\n\t\t\tgoto done;\n\t\t}\n\t\tcase DUK_RETOK_EOF: {\n\t\t\tif (!expect_eof) {\n\t\t\t\tDUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_UNEXPECTED_END_OF_PATTERN);\n\t\t\t}\n\t\t\tgoto done;\n\t\t}\n\t\tdefault: {\n\t\t\tDUK_ERROR_SYNTAX(re_ctx->thr, DUK_STR_UNEXPECTED_REGEXP_TOKEN);\n\t\t}\n\t\t}\n\n\t\t/* a complex (new) atom taints the result */\n\t\tif (new_atom_start_offset >= 0) {\n\t\t\tif (new_atom_char_length < 0) {\n\t\t\t\tres_charlen = -1;\n\t\t\t} else if (res_charlen >= 0) {\n\t\t\t\t/* only advance if not tainted */\n\t\t\t\tres_charlen += new_atom_char_length;\n\t\t\t}\n\t\t}\n\n\t\t/* record previous atom info in case next token is a quantifier */\n\t\tatom_start_offset = new_atom_start_offset;\n\t\tatom_char_length = new_atom_char_length;\n\t\tatom_start_captures = new_atom_start_captures;\n\t}\n\n done:\n\n\t/* finish up pending jump and split for last alternative */\n\tif (unpatched_disjunction_jump >= 0) {\n\t\tduk_uint32_t offset;\n\n\t\tDUK_ASSERT(unpatched_disjunction_split >= 0);\n\t\toffset = unpatched_disjunction_jump;\n\t\toffset += duk__insert_jump_offset(re_ctx,\n\t\t                                  offset,\n\t\t                                  (duk_int32_t) (DUK__RE_BUFLEN(re_ctx) - offset));\n\t\t/* offset is now target of the pending split (right after jump) */\n\t\tduk__insert_jump_offset(re_ctx,\n\t\t                        unpatched_disjunction_split,\n\t\t                        offset - unpatched_disjunction_split);\n\t}\n\n#if 0\n\tout_atom_info->end_captures = re_ctx->captures;\n#endif\n\tout_atom_info->charlen = res_charlen;\n\tDUK_DDD(DUK_DDDPRINT(\"parse disjunction finished: charlen=%ld\",\n\t                     (long) out_atom_info->charlen));\n\n\tre_ctx->recursion_depth--;\n}\n\n/*\n *  Flags parsing (see E5 Section 15.10.4.1).\n */\n\nDUK_LOCAL duk_uint32_t duk__parse_regexp_flags(duk_hthread *thr, duk_hstring *h) {\n\tconst duk_uint8_t *p;\n\tconst duk_uint8_t *p_end;\n\tduk_uint32_t flags = 0;\n\n\tp = DUK_HSTRING_GET_DATA(h);\n\tp_end = p + DUK_HSTRING_GET_BYTELEN(h);\n\n\t/* Note: can be safely scanned as bytes (undecoded) */\n\n\twhile (p < p_end) {\n\t\tduk_uint8_t c = *p++;\n\t\tswitch (c) {\n\t\tcase (duk_uint8_t) 'g': {\n\t\t\tif (flags & DUK_RE_FLAG_GLOBAL) {\n\t\t\t\tgoto flags_error;\n\t\t\t}\n\t\t\tflags |= DUK_RE_FLAG_GLOBAL;\n\t\t\tbreak;\n\t\t}\n\t\tcase (duk_uint8_t) 'i': {\n\t\t\tif (flags & DUK_RE_FLAG_IGNORE_CASE) {\n\t\t\t\tgoto flags_error;\n\t\t\t}\n\t\t\tflags |= DUK_RE_FLAG_IGNORE_CASE;\n\t\t\tbreak;\n\t\t}\n\t\tcase (duk_uint8_t) 'm': {\n\t\t\tif (flags & DUK_RE_FLAG_MULTILINE) {\n\t\t\t\tgoto flags_error;\n\t\t\t}\n\t\t\tflags |= DUK_RE_FLAG_MULTILINE;\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tgoto flags_error;\n\t\t}\n\t\t}\n\t}\n\n\treturn flags;\n\n flags_error:\n\tDUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_REGEXP_FLAGS);\n\treturn 0;  /* never here */\n}\n\n/*\n *  Create escaped RegExp source (E5 Section 15.10.3).\n *\n *  The current approach is to special case the empty RegExp\n *  ('' -> '(?:)') and otherwise replace unescaped '/' characters\n *  with '\\/' regardless of where they occur in the regexp.\n *\n *  Note that normalization does not seem to be necessary for\n *  RegExp literals (e.g. '/foo/') because to be acceptable as\n *  a RegExp literal, the text between forward slashes must\n *  already match the escaping requirements (e.g. must not contain\n *  unescaped forward slashes or be empty).  Escaping IS needed\n *  for expressions like 'new Regexp(\"...\", \"\")' however.\n *  Currently, we re-escape in either case.\n *\n *  Also note that we process the source here in UTF-8 encoded\n *  form.  This is correct, because any non-ASCII characters are\n *  passed through without change.\n */\n\nDUK_LOCAL void duk__create_escaped_source(duk_hthread *thr, int idx_pattern) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hstring *h;\n\tconst duk_uint8_t *p;\n\tduk_bufwriter_ctx bw_alloc;\n\tduk_bufwriter_ctx *bw;\n\tduk_uint8_t *q;\n\tduk_size_t i, n;\n\tduk_uint_fast8_t c_prev, c;\n\n\th = duk_known_hstring(ctx, idx_pattern);\n\tp = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h);\n\tn = (duk_size_t) DUK_HSTRING_GET_BYTELEN(h);\n\n\tif (n == 0) {\n\t\tduk_push_string(ctx, \"(?:)\");\n\t\treturn;\n\t}\n\n\tbw = &bw_alloc;\n\tDUK_BW_INIT_PUSHBUF(thr, bw, n);\n\tq = DUK_BW_GET_PTR(thr, bw);\n\n\tc_prev = (duk_uint_fast8_t) 0;\n\n\tfor (i = 0; i < n; i++) {\n\t\tc = p[i];\n\n\t\tq = DUK_BW_ENSURE_RAW(thr, bw, 2, q);\n\n\t\tif (c == (duk_uint_fast8_t) '/' && c_prev != (duk_uint_fast8_t) '\\\\') {\n\t\t\t/* Unescaped '/' ANYWHERE in the regexp (in disjunction,\n\t\t\t * inside a character class, ...) => same escape works.\n\t\t\t */\n\t\t\t*q++ = DUK_ASC_BACKSLASH;\n\t\t}\n\t\t*q++ = (duk_uint8_t) c;\n\n\t\tc_prev = c;\n\t}\n\n\tDUK_BW_SETPTR_AND_COMPACT(thr, bw, q);\n\t(void) duk_buffer_to_string(ctx, -1);  /* Safe if input is safe. */\n\n\t/* [ ... escaped_source ] */\n}\n\n/*\n *  Exposed regexp compilation primitive.\n *\n *  Sets up a regexp compilation context, and calls duk__parse_disjunction() to do the\n *  actual parsing.  Handles generation of the compiled regexp header and the\n *  \"boilerplate\" capture of the matching substring (save 0 and 1).  Also does some\n *  global level regexp checks after recursive compilation has finished.\n *\n *  An escaped version of the regexp source, suitable for use as a RegExp instance\n *  'source' property (see E5 Section 15.10.3), is also left on the stack.\n *\n *  Input stack:  [ pattern flags ]\n *  Output stack: [ bytecode escaped_source ]  (both as strings)\n */\n\nDUK_INTERNAL void duk_regexp_compile(duk_hthread *thr) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_re_compiler_ctx re_ctx;\n\tduk_lexer_point lex_point;\n\tduk_hstring *h_pattern;\n\tduk_hstring *h_flags;\n\tduk__re_disjunction_info ign_disj;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(ctx != NULL);\n\n\t/*\n\t *  Args validation\n\t */\n\n\t/* TypeError if fails */\n\th_pattern = duk_require_hstring_notsymbol(ctx, -2);\n\th_flags = duk_require_hstring_notsymbol(ctx, -1);\n\n\t/*\n\t *  Create normalized 'source' property (E5 Section 15.10.3).\n\t */\n\n\t/* [ ... pattern flags ] */\n\n\tduk__create_escaped_source(thr, -2);\n\n\t/* [ ... pattern flags escaped_source ] */\n\n\t/*\n\t *  Init compilation context\n\t */\n\n\t/* [ ... pattern flags escaped_source buffer ] */\n\n\tDUK_MEMZERO(&re_ctx, sizeof(re_ctx));\n\tDUK_LEXER_INITCTX(&re_ctx.lex);  /* duplicate zeroing, expect for (possible) NULL inits */\n\tre_ctx.thr = thr;\n\tre_ctx.lex.thr = thr;\n\tre_ctx.lex.input = DUK_HSTRING_GET_DATA(h_pattern);\n\tre_ctx.lex.input_length = DUK_HSTRING_GET_BYTELEN(h_pattern);\n\tre_ctx.lex.token_limit = DUK_RE_COMPILE_TOKEN_LIMIT;\n\tre_ctx.recursion_limit = DUK_USE_REGEXP_COMPILER_RECLIMIT;\n\tre_ctx.re_flags = duk__parse_regexp_flags(thr, h_flags);\n\n\tDUK_BW_INIT_PUSHBUF(thr, &re_ctx.bw, DUK__RE_INITIAL_BUFSIZE);\n\n\tDUK_DD(DUK_DDPRINT(\"regexp compiler ctx initialized, flags=0x%08lx, recursion_limit=%ld\",\n\t                   (unsigned long) re_ctx.re_flags, (long) re_ctx.recursion_limit));\n\n\t/*\n\t *  Init lexer\n\t */\n\n\tlex_point.offset = 0;  /* expensive init, just want to fill window */\n\tlex_point.line = 1;\n\tDUK_LEXER_SETPOINT(&re_ctx.lex, &lex_point);\n\n\t/*\n\t *  Compilation\n\t */\n\n\tDUK_DD(DUK_DDPRINT(\"starting regexp compilation\"));\n\n\tduk__append_reop(&re_ctx, DUK_REOP_SAVE);\n\tduk__append_7bit(&re_ctx, 0);\n\tduk__parse_disjunction(&re_ctx, 1 /*expect_eof*/, &ign_disj);\n\tduk__append_reop(&re_ctx, DUK_REOP_SAVE);\n\tduk__append_7bit(&re_ctx, 1);\n\tduk__append_reop(&re_ctx, DUK_REOP_MATCH);\n\n\t/*\n\t *  Check for invalid backreferences; note that it is NOT an error\n\t *  to back-reference a capture group which has not yet been introduced\n\t *  in the pattern (as in /\\1(foo)/); in fact, the backreference will\n\t *  always match!  It IS an error to back-reference a capture group\n\t *  which will never be introduced in the pattern.  Thus, we can check\n\t *  for such references only after parsing is complete.\n\t */\n\n\tif (re_ctx.highest_backref > re_ctx.captures) {\n\t\tDUK_ERROR_SYNTAX(thr, DUK_STR_INVALID_BACKREFS);\n\t}\n\n\t/*\n\t *  Emit compiled regexp header: flags, ncaptures\n\t *  (insertion order inverted on purpose)\n\t */\n\n\tduk__insert_u32(&re_ctx, 0, (re_ctx.captures + 1) * 2);\n\tduk__insert_u32(&re_ctx, 0, re_ctx.re_flags);\n\n\t/* [ ... pattern flags escaped_source buffer ] */\n\n\tDUK_BW_COMPACT(thr, &re_ctx.bw);\n\t(void) duk_buffer_to_string(ctx, -1);  /* Safe because flags is at most 7 bit. */\n\n\t/* [ ... pattern flags escaped_source bytecode ] */\n\n\t/*\n\t *  Finalize stack\n\t */\n\n\tduk_remove(ctx, -4);     /* -> [ ... flags escaped_source bytecode ] */\n\tduk_remove(ctx, -3);     /* -> [ ... escaped_source bytecode ] */\n\n\tDUK_DD(DUK_DDPRINT(\"regexp compilation successful, bytecode: %!T, escaped source: %!T\",\n\t                   (duk_tval *) duk_get_tval(ctx, -1), (duk_tval *) duk_get_tval(ctx, -2)));\n}\n\n/*\n *  Create a RegExp instance (E5 Section 15.10.7).\n *\n *  Note: the output stack left by duk_regexp_compile() is directly compatible\n *  with the input here.\n *\n *  Input stack:  [ escaped_source bytecode ]  (both as strings)\n *  Output stack: [ RegExp ]\n */\n\nDUK_INTERNAL void duk_regexp_create_instance(duk_hthread *thr) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_hobject *h;\n\n\t/* [ ... escaped_source bytecode ] */\n\n\tduk_push_object(ctx);\n\th = duk_known_hobject(ctx, -1);\n\tduk_insert(ctx, -3);\n\n\t/* [ ... regexp_object escaped_source bytecode ] */\n\n\tDUK_HOBJECT_SET_CLASS_NUMBER(h, DUK_HOBJECT_CLASS_REGEXP);\n\tDUK_HOBJECT_SET_PROTOTYPE_UPDREF(thr, h, thr->builtins[DUK_BIDX_REGEXP_PROTOTYPE]);\n\n\tduk_xdef_prop_stridx_short(ctx, -3, DUK_STRIDX_INT_BYTECODE, DUK_PROPDESC_FLAGS_NONE);\n\n\t/* [ ... regexp_object escaped_source ] */\n\n\t/* In ES2015 .source, and the .global, .multiline, etc flags are\n\t * inherited getters.  Store the escaped source as an internal\n\t * property for the getter.\n\t */\n\n\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_SOURCE, DUK_PROPDESC_FLAGS_NONE);\n\n\t/* [ ... regexp_object ] */\n\n\tduk_push_int(ctx, 0);\n\tduk_xdef_prop_stridx_short(ctx, -2, DUK_STRIDX_LAST_INDEX, DUK_PROPDESC_FLAGS_W);\n\n\t/* [ ... regexp_object ] */\n}\n\n#else  /* DUK_USE_REGEXP_SUPPORT */\n\n/* regexp support disabled */\n\n#endif  /* DUK_USE_REGEXP_SUPPORT */\n\n/* automatic undefs */\n#undef DUK__RE_BUFLEN\n#undef DUK__RE_INITIAL_BUFSIZE\n/*\n *  Regexp executor.\n *\n *  Safety: the Ecmascript executor should prevent user from reading and\n *  replacing regexp bytecode.  Even so, the executor must validate all\n *  memory accesses etc.  When an invalid access is detected (e.g. a 'save'\n *  opcode to invalid, unallocated index) it should fail with an internal\n *  error but not cause a segmentation fault.\n *\n *  Notes:\n *\n *    - Backtrack counts are limited to unsigned 32 bits but should\n *      technically be duk_size_t for strings longer than 4G chars.\n *      This also requires a regexp bytecode change.\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_REGEXP_SUPPORT)\n\n/*\n *  Helpers for UTF-8 handling\n *\n *  For bytecode readers the duk_uint32_t and duk_int32_t types are correct\n *  because they're used for more than just codepoints.\n */\n\nDUK_LOCAL duk_uint32_t duk__bc_get_u32(duk_re_matcher_ctx *re_ctx, const duk_uint8_t **pc) {\n\treturn (duk_uint32_t) duk_unicode_decode_xutf8_checked(re_ctx->thr, pc, re_ctx->bytecode, re_ctx->bytecode_end);\n}\n\nDUK_LOCAL duk_int32_t duk__bc_get_i32(duk_re_matcher_ctx *re_ctx, const duk_uint8_t **pc) {\n\tduk_uint32_t t;\n\n\t/* signed integer encoding needed to work with UTF-8 */\n\tt = (duk_uint32_t) duk_unicode_decode_xutf8_checked(re_ctx->thr, pc, re_ctx->bytecode, re_ctx->bytecode_end);\n\tif (t & 1) {\n\t\treturn -((duk_int32_t) (t >> 1));\n\t} else {\n\t\treturn (duk_int32_t) (t >> 1);\n\t}\n}\n\nDUK_LOCAL const duk_uint8_t *duk__utf8_backtrack(duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end, duk_uint_fast32_t count) {\n\tconst duk_uint8_t *p;\n\n\t/* Note: allow backtracking from p == ptr_end */\n\tp = *ptr;\n\tif (p < ptr_start || p > ptr_end) {\n\t\tgoto fail;\n\t}\n\n\twhile (count > 0) {\n\t\tfor (;;) {\n\t\t\tp--;\n\t\t\tif (p < ptr_start) {\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tif ((*p & 0xc0) != 0x80) {\n\t\t\t\t/* utf-8 continuation bytes have the form 10xx xxxx */\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tcount--;\n\t}\n\t*ptr = p;\n\treturn p;\n\n fail:\n\tDUK_ERROR_INTERNAL(thr);\n\treturn NULL;  /* never here */\n}\n\nDUK_LOCAL const duk_uint8_t *duk__utf8_advance(duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end, duk_uint_fast32_t count) {\n\tconst duk_uint8_t *p;\n\n\tp = *ptr;\n\tif (p < ptr_start || p >= ptr_end) {\n\t\tgoto fail;\n\t}\n\n\twhile (count > 0) {\n\t\tfor (;;) {\n\t\t\tp++;\n\n\t\t\t/* Note: if encoding ends by hitting end of input, we don't check that\n\t\t\t * the encoding is valid, we just assume it is.\n\t\t\t */\n\t\t\tif (p >= ptr_end || ((*p & 0xc0) != 0x80)) {\n\t\t\t\t/* utf-8 continuation bytes have the form 10xx xxxx */\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tcount--;\n\t}\n\n\t*ptr = p;\n\treturn p;\n\n fail:\n\tDUK_ERROR_INTERNAL(thr);\n\treturn NULL;  /* never here */\n}\n\n/*\n *  Helpers for dealing with the input string\n */\n\n/* Get a (possibly canonicalized) input character from current sp.  The input\n * itself is never modified, and captures always record non-canonicalized\n * characters even in case-insensitive matching.  Return <0 if out of input.\n */\nDUK_LOCAL duk_codepoint_t duk__inp_get_cp(duk_re_matcher_ctx *re_ctx, const duk_uint8_t **sp) {\n\tduk_codepoint_t res;\n\n\tif (*sp >= re_ctx->input_end) {\n\t\treturn -1;\n\t}\n\tres = (duk_codepoint_t) duk_unicode_decode_xutf8_checked(re_ctx->thr, sp, re_ctx->input, re_ctx->input_end);\n\tif (re_ctx->re_flags & DUK_RE_FLAG_IGNORE_CASE) {\n\t\tres = duk_unicode_re_canonicalize_char(re_ctx->thr, res);\n\t}\n\treturn res;\n}\n\nDUK_LOCAL const duk_uint8_t *duk__inp_backtrack(duk_re_matcher_ctx *re_ctx, const duk_uint8_t **sp, duk_uint_fast32_t count) {\n\treturn duk__utf8_backtrack(re_ctx->thr, sp, re_ctx->input, re_ctx->input_end, count);\n}\n\n/* Backtrack utf-8 input and return a (possibly canonicalized) input character. */\nDUK_LOCAL duk_codepoint_t duk__inp_get_prev_cp(duk_re_matcher_ctx *re_ctx, const duk_uint8_t *sp) {\n\t/* note: caller 'sp' is intentionally not updated here */\n\t(void) duk__inp_backtrack(re_ctx, &sp, (duk_uint_fast32_t) 1);\n\treturn duk__inp_get_cp(re_ctx, &sp);\n}\n\n/*\n *  Regexp recursive matching function.\n *\n *  Returns 'sp' on successful match (points to character after last matched one),\n *  NULL otherwise.\n *\n *  The C recursion depth limit check is only performed in this function, this\n *  suffices because the function is present in all true recursion required by\n *  regexp execution.\n */\n\nDUK_LOCAL const duk_uint8_t *duk__match_regexp(duk_re_matcher_ctx *re_ctx, const duk_uint8_t *pc, const duk_uint8_t *sp) {\n\tif (re_ctx->recursion_depth >= re_ctx->recursion_limit) {\n\t\tDUK_ERROR_RANGE(re_ctx->thr, DUK_STR_REGEXP_EXECUTOR_RECURSION_LIMIT);\n\t}\n\tre_ctx->recursion_depth++;\n\n\tfor (;;) {\n\t\tduk_small_int_t op;\n\n\t\tif (re_ctx->steps_count >= re_ctx->steps_limit) {\n\t\t\tDUK_ERROR_RANGE(re_ctx->thr, DUK_STR_REGEXP_EXECUTOR_STEP_LIMIT);\n\t\t}\n\t\tre_ctx->steps_count++;\n\n\t\t/* Opcodes are at most 7 bits now so they encode to one byte.  If this\n\t\t * were not the case or 'pc' is invalid here (due to a bug etc) we'll\n\t\t * still fail safely through the switch default case.\n\t\t */\n\t\tDUK_ASSERT(pc[0] <= 0x7fU);\n#if 0\n\t\top = (duk_small_int_t) duk__bc_get_u32(re_ctx, &pc);\n#endif\n\t\top = *pc++;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"match: rec=%ld, steps=%ld, pc (after op)=%ld, sp=%ld, op=%ld\",\n\t\t                     (long) re_ctx->recursion_depth,\n\t\t                     (long) re_ctx->steps_count,\n\t\t                     (long) (pc - re_ctx->bytecode),\n\t\t                     (long) (sp - re_ctx->input),\n\t\t                     (long) op));\n\n\t\tswitch (op) {\n\t\tcase DUK_REOP_MATCH: {\n\t\t\tgoto match;\n\t\t}\n\t\tcase DUK_REOP_CHAR: {\n\t\t\t/*\n\t\t\t *  Byte-based matching would be possible for case-sensitive\n\t\t\t *  matching but not for case-insensitive matching.  So, we\n\t\t\t *  match by decoding the input and bytecode character normally.\n\t\t\t *\n\t\t\t *  Bytecode characters are assumed to be already canonicalized.\n\t\t\t *  Input characters are canonicalized automatically by\n\t\t\t *  duk__inp_get_cp() if necessary.\n\t\t\t *\n\t\t\t *  There is no opcode for matching multiple characters.  The\n\t\t\t *  regexp compiler has trouble joining strings efficiently\n\t\t\t *  during compilation.  See doc/regexp.rst for more discussion.\n\t\t\t */\n\t\t\tduk_codepoint_t c1, c2;\n\n\t\t\tc1 = (duk_codepoint_t) duk__bc_get_u32(re_ctx, &pc);\n\t\t\tDUK_ASSERT(!(re_ctx->re_flags & DUK_RE_FLAG_IGNORE_CASE) ||\n\t\t\t           c1 == duk_unicode_re_canonicalize_char(re_ctx->thr, c1));  /* canonicalized by compiler */\n\t\t\tc2 = duk__inp_get_cp(re_ctx, &sp);\n\t\t\t/* No need to check for c2 < 0 (end of input): because c1 >= 0, it\n\t\t\t * will fail the match below automatically and cause goto fail.\n\t\t\t */\n#if 0\n\t\t\tif (c2 < 0) {\n\t\t\t\tgoto fail;\n\t\t\t}\n#endif\n\t\t\tDUK_ASSERT(c1 >= 0);\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"char match, c1=%ld, c2=%ld\", (long) c1, (long) c2));\n\t\t\tif (c1 != c2) {\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_REOP_PERIOD: {\n\t\t\tduk_codepoint_t c;\n\n\t\t\tc = duk__inp_get_cp(re_ctx, &sp);\n\t\t\tif (c < 0 || duk_unicode_is_line_terminator(c)) {\n\t\t\t\t/* E5 Sections 15.10.2.8, 7.3 */\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_REOP_RANGES:\n\t\tcase DUK_REOP_INVRANGES: {\n\t\t\tduk_uint32_t n;\n\t\t\tduk_codepoint_t c;\n\t\t\tduk_small_int_t match;\n\n\t\t\tn = duk__bc_get_u32(re_ctx, &pc);\n\t\t\tc = duk__inp_get_cp(re_ctx, &sp);\n\t\t\tif (c < 0) {\n\t\t\t\tgoto fail;\n\t\t\t}\n\n\t\t\tmatch = 0;\n\t\t\twhile (n) {\n\t\t\t\tduk_codepoint_t r1, r2;\n\t\t\t\tr1 = (duk_codepoint_t) duk__bc_get_u32(re_ctx, &pc);\n\t\t\t\tr2 = (duk_codepoint_t) duk__bc_get_u32(re_ctx, &pc);\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"matching ranges/invranges, n=%ld, r1=%ld, r2=%ld, c=%ld\",\n\t\t\t\t                     (long) n, (long) r1, (long) r2, (long) c));\n\t\t\t\tif (c >= r1 && c <= r2) {\n\t\t\t\t\t/* Note: don't bail out early, we must read all the ranges from\n\t\t\t\t\t * bytecode.  Another option is to skip them efficiently after\n\t\t\t\t\t * breaking out of here.  Prefer smallest code.\n\t\t\t\t\t */\n\t\t\t\t\tmatch = 1;\n\t\t\t\t}\n\t\t\t\tn--;\n\t\t\t}\n\n\t\t\tif (op == DUK_REOP_RANGES) {\n\t\t\t\tif (!match) {\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tDUK_ASSERT(op == DUK_REOP_INVRANGES);\n\t\t\t\tif (match) {\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_REOP_ASSERT_START: {\n\t\t\tduk_codepoint_t c;\n\n\t\t\tif (sp <= re_ctx->input) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (!(re_ctx->re_flags & DUK_RE_FLAG_MULTILINE)) {\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tc = duk__inp_get_prev_cp(re_ctx, sp);\n\t\t\tif (duk_unicode_is_line_terminator(c)) {\n\t\t\t\t/* E5 Sections 15.10.2.8, 7.3 */\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tgoto fail;\n\t\t}\n\t\tcase DUK_REOP_ASSERT_END: {\n\t\t\tduk_codepoint_t c;\n\t\t\tconst duk_uint8_t *tmp_sp;\n\n\t\t\ttmp_sp = sp;\n\t\t\tc = duk__inp_get_cp(re_ctx, &tmp_sp);\n\t\t\tif (c < 0) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (!(re_ctx->re_flags & DUK_RE_FLAG_MULTILINE)) {\n\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tif (duk_unicode_is_line_terminator(c)) {\n\t\t\t\t/* E5 Sections 15.10.2.8, 7.3 */\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tgoto fail;\n\t\t}\n\t\tcase DUK_REOP_ASSERT_WORD_BOUNDARY:\n\t\tcase DUK_REOP_ASSERT_NOT_WORD_BOUNDARY: {\n\t\t\t/*\n\t\t\t *  E5 Section 15.10.2.6.  The previous and current character\n\t\t\t *  should -not- be canonicalized as they are now.  However,\n\t\t\t *  canonicalization does not affect the result of IsWordChar()\n\t\t\t *  (which depends on Unicode characters never canonicalizing\n\t\t\t *  into ASCII characters) so this does not matter.\n\t\t\t */\n\t\t\tduk_small_int_t w1, w2;\n\n\t\t\tif (sp <= re_ctx->input) {\n\t\t\t\tw1 = 0;  /* not a wordchar */\n\t\t\t} else {\n\t\t\t\tduk_codepoint_t c;\n\t\t\t\tc = duk__inp_get_prev_cp(re_ctx, sp);\n\t\t\t\tw1 = duk_unicode_re_is_wordchar(c);\n\t\t\t}\n\t\t\tif (sp >= re_ctx->input_end) {\n\t\t\t\tw2 = 0;  /* not a wordchar */\n\t\t\t} else {\n\t\t\t\tconst duk_uint8_t *tmp_sp = sp;  /* dummy so sp won't get updated */\n\t\t\t\tduk_codepoint_t c;\n\t\t\t\tc = duk__inp_get_cp(re_ctx, &tmp_sp);\n\t\t\t\tw2 = duk_unicode_re_is_wordchar(c);\n\t\t\t}\n\n\t\t\tif (op == DUK_REOP_ASSERT_WORD_BOUNDARY) {\n\t\t\t\tif (w1 == w2) {\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tDUK_ASSERT(op == DUK_REOP_ASSERT_NOT_WORD_BOUNDARY);\n\t\t\t\tif (w1 != w2) {\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_REOP_JUMP: {\n\t\t\tduk_int32_t skip;\n\n\t\t\tskip = duk__bc_get_i32(re_ctx, &pc);\n\t\t\tpc += skip;\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_REOP_SPLIT1: {\n\t\t\t/* split1: prefer direct execution (no jump) */\n\t\t\tconst duk_uint8_t *sub_sp;\n\t\t\tduk_int32_t skip;\n\n\t\t\tskip = duk__bc_get_i32(re_ctx, &pc);\n\t\t\tsub_sp = duk__match_regexp(re_ctx, pc, sp);\n\t\t\tif (sub_sp) {\n\t\t\t\tsp = sub_sp;\n\t\t\t\tgoto match;\n\t\t\t}\n\t\t\tpc += skip;\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_REOP_SPLIT2: {\n\t\t\t/* split2: prefer jump execution (not direct) */\n\t\t\tconst duk_uint8_t *sub_sp;\n\t\t\tduk_int32_t skip;\n\n\t\t\tskip = duk__bc_get_i32(re_ctx, &pc);\n\t\t\tsub_sp = duk__match_regexp(re_ctx, pc + skip, sp);\n\t\t\tif (sub_sp) {\n\t\t\t\tsp = sub_sp;\n\t\t\t\tgoto match;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tcase DUK_REOP_SQMINIMAL: {\n\t\t\tduk_uint32_t q, qmin, qmax;\n\t\t\tduk_int32_t skip;\n\t\t\tconst duk_uint8_t *sub_sp;\n\n\t\t\tqmin = duk__bc_get_u32(re_ctx, &pc);\n\t\t\tqmax = duk__bc_get_u32(re_ctx, &pc);\n\t\t\tskip = duk__bc_get_i32(re_ctx, &pc);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"minimal quantifier, qmin=%lu, qmax=%lu, skip=%ld\",\n\t\t\t                     (unsigned long) qmin, (unsigned long) qmax, (long) skip));\n\n\t\t\tq = 0;\n\t\t\twhile (q <= qmax) {\n\t\t\t\tif (q >= qmin) {\n\t\t\t\t\tsub_sp = duk__match_regexp(re_ctx, pc + skip, sp);\n\t\t\t\t\tif (sub_sp) {\n\t\t\t\t\t\tsp = sub_sp;\n\t\t\t\t\t\tgoto match;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tsub_sp = duk__match_regexp(re_ctx, pc, sp);\n\t\t\t\tif (!sub_sp) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tsp = sub_sp;\n\t\t\t\tq++;\n\t\t\t}\n\t\t\tgoto fail;\n\t\t}\n\t\tcase DUK_REOP_SQGREEDY: {\n\t\t\tduk_uint32_t q, qmin, qmax, atomlen;\n\t\t\tduk_int32_t skip;\n\t\t\tconst duk_uint8_t *sub_sp;\n\n\t\t\tqmin = duk__bc_get_u32(re_ctx, &pc);\n\t\t\tqmax = duk__bc_get_u32(re_ctx, &pc);\n\t\t\tatomlen = duk__bc_get_u32(re_ctx, &pc);\n\t\t\tskip = duk__bc_get_i32(re_ctx, &pc);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"greedy quantifier, qmin=%lu, qmax=%lu, atomlen=%lu, skip=%ld\",\n\t\t\t                     (unsigned long) qmin, (unsigned long) qmax, (unsigned long) atomlen, (long) skip));\n\n\t\t\tq = 0;\n\t\t\twhile (q < qmax) {\n\t\t\t\tsub_sp = duk__match_regexp(re_ctx, pc, sp);\n\t\t\t\tif (!sub_sp) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tsp = sub_sp;\n\t\t\t\tq++;\n\t\t\t}\n\t\t\twhile (q >= qmin) {\n\t\t\t\tsub_sp = duk__match_regexp(re_ctx, pc + skip, sp);\n\t\t\t\tif (sub_sp) {\n\t\t\t\t\tsp = sub_sp;\n\t\t\t\t\tgoto match;\n\t\t\t\t}\n\t\t\t\tif (q == qmin) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t/* Note: if atom were to contain e.g. captures, we would need to\n\t\t\t\t * re-match the atom to get correct captures.  Simply quantifiers\n\t\t\t\t * do not allow captures in their atom now, so this is not an issue.\n\t\t\t\t */\n\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"greedy quantifier, backtrack %ld characters (atomlen)\",\n\t\t\t\t                     (long) atomlen));\n\t\t\t\tsp = duk__inp_backtrack(re_ctx, &sp, (duk_uint_fast32_t) atomlen);\n\t\t\t\tq--;\n\t\t\t}\n\t\t\tgoto fail;\n\t\t}\n\t\tcase DUK_REOP_SAVE: {\n\t\t\tduk_uint32_t idx;\n\t\t\tconst duk_uint8_t *old;\n\t\t\tconst duk_uint8_t *sub_sp;\n\n\t\t\tidx = duk__bc_get_u32(re_ctx, &pc);\n\t\t\tif (idx >= re_ctx->nsaved) {\n\t\t\t\t/* idx is unsigned, < 0 check is not necessary */\n\t\t\t\tDUK_D(DUK_DPRINT(\"internal error, regexp save index insane: idx=%ld\", (long) idx));\n\t\t\t\tgoto internal_error;\n\t\t\t}\n\t\t\told = re_ctx->saved[idx];\n\t\t\tre_ctx->saved[idx] = sp;\n\t\t\tsub_sp = duk__match_regexp(re_ctx, pc, sp);\n\t\t\tif (sub_sp) {\n\t\t\t\tsp = sub_sp;\n\t\t\t\tgoto match;\n\t\t\t}\n\t\t\tre_ctx->saved[idx] = old;\n\t\t\tgoto fail;\n\t\t}\n\t\tcase DUK_REOP_WIPERANGE: {\n\t\t\t/* Wipe capture range and save old values for backtracking.\n\t\t\t *\n\t\t\t * XXX: this typically happens with a relatively small idx_count.\n\t\t\t * It might be useful to handle cases where the count is small\n\t\t\t * (say <= 8) by saving the values in stack instead.  This would\n\t\t\t * reduce memory churn and improve performance, at the cost of a\n\t\t\t * slightly higher code footprint.\n\t\t\t */\n\t\t\tduk_uint32_t idx_start, idx_count;\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n\t\t\tduk_uint32_t idx_end, idx;\n#endif\n\t\t\tduk_uint8_t **range_save;\n\t\t\tconst duk_uint8_t *sub_sp;\n\n\t\t\tidx_start = duk__bc_get_u32(re_ctx, &pc);\n\t\t\tidx_count = duk__bc_get_u32(re_ctx, &pc);\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"wipe saved range: start=%ld, count=%ld -> [%ld,%ld] (captures [%ld,%ld])\",\n\t\t\t                     (long) idx_start, (long) idx_count,\n\t\t\t                     (long) idx_start, (long) (idx_start + idx_count - 1),\n\t\t\t                     (long) (idx_start / 2), (long) ((idx_start + idx_count - 1) / 2)));\n\t\t\tif (idx_start + idx_count > re_ctx->nsaved || idx_count == 0) {\n\t\t\t\t/* idx is unsigned, < 0 check is not necessary */\n\t\t\t\tDUK_D(DUK_DPRINT(\"internal error, regexp wipe indices insane: idx_start=%ld, idx_count=%ld\",\n\t\t\t\t                 (long) idx_start, (long) idx_count));\n\t\t\t\tgoto internal_error;\n\t\t\t}\n\t\t\tDUK_ASSERT(idx_count > 0);\n\n\t\t\tduk_require_stack((duk_context *) re_ctx->thr, 1);\n\t\t\trange_save = (duk_uint8_t **) duk_push_fixed_buffer_nozero((duk_context *) re_ctx->thr,\n\t\t\t                                                           sizeof(duk_uint8_t *) * idx_count);\n\t\t\tDUK_ASSERT(range_save != NULL);\n\t\t\tDUK_MEMCPY(range_save, re_ctx->saved + idx_start, sizeof(duk_uint8_t *) * idx_count);\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n\t\t\tidx_end = idx_start + idx_count;\n\t\t\tfor (idx = idx_start; idx < idx_end; idx++) {\n\t\t\t\tre_ctx->saved[idx] = NULL;\n\t\t\t}\n#else\n\t\t\tDUK_MEMZERO((void *) (re_ctx->saved + idx_start), sizeof(duk_uint8_t *) * idx_count);\n#endif\n\n\t\t\tsub_sp = duk__match_regexp(re_ctx, pc, sp);\n\t\t\tif (sub_sp) {\n\t\t\t\t/* match: keep wiped/resaved values */\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"match: keep wiped/resaved values [%ld,%ld] (captures [%ld,%ld])\",\n\t\t\t\t                     (long) idx_start, (long) (idx_start + idx_count - 1),\n\t\t\t                             (long) (idx_start / 2), (long) ((idx_start + idx_count - 1) / 2)));\n\t\t\t\tduk_pop((duk_context *) re_ctx->thr);\n\t\t\t\tsp = sub_sp;\n\t\t\t\tgoto match;\n\t\t\t}\n\n\t\t\t/* fail: restore saves */\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"fail: restore wiped/resaved values [%ld,%ld] (captures [%ld,%ld])\",\n\t\t\t                     (long) idx_start, (long) (idx_start + idx_count - 1),\n\t\t\t                     (long) (idx_start / 2), (long) ((idx_start + idx_count - 1) / 2)));\n\t\t\tDUK_MEMCPY((void *) (re_ctx->saved + idx_start),\n\t\t\t           (const void *) range_save,\n\t\t\t           sizeof(duk_uint8_t *) * idx_count);\n\t\t\tduk_pop((duk_context *) re_ctx->thr);\n\t\t\tgoto fail;\n\t\t}\n\t\tcase DUK_REOP_LOOKPOS:\n\t\tcase DUK_REOP_LOOKNEG: {\n\t\t\t/*\n\t\t\t *  Needs a save of multiple saved[] entries depending on what range\n\t\t\t *  may be overwritten.  Because the regexp parser does no such analysis,\n\t\t\t *  we currently save the entire saved array here.  Lookaheads are thus\n\t\t\t *  a bit expensive.  Note that the saved array is not needed for just\n\t\t\t *  the lookahead sub-match, but for the matching of the entire sequel.\n\t\t\t *\n\t\t\t *  The temporary save buffer is pushed on to the valstack to handle\n\t\t\t *  errors correctly.  Each lookahead causes a C recursion and pushes\n\t\t\t *  more stuff on the value stack.  If the C recursion limit is less\n\t\t\t *  than the value stack spare, there is no need to check the stack.\n\t\t\t *  We do so regardless, just in case.\n\t\t\t */\n\n\t\t\tduk_int32_t skip;\n\t\t\tduk_uint8_t **full_save;\n\t\t\tconst duk_uint8_t *sub_sp;\n\n\t\t\tDUK_ASSERT(re_ctx->nsaved > 0);\n\n\t\t\tduk_require_stack((duk_context *) re_ctx->thr, 1);\n\t\t\tfull_save = (duk_uint8_t **) duk_push_fixed_buffer_nozero((duk_context *) re_ctx->thr,\n\t\t\t                                                          sizeof(duk_uint8_t *) * re_ctx->nsaved);\n\t\t\tDUK_ASSERT(full_save != NULL);\n\t\t\tDUK_MEMCPY(full_save, re_ctx->saved, sizeof(duk_uint8_t *) * re_ctx->nsaved);\n\n\t\t\tskip = duk__bc_get_i32(re_ctx, &pc);\n\t\t\tsub_sp = duk__match_regexp(re_ctx, pc, sp);\n\t\t\tif (op == DUK_REOP_LOOKPOS) {\n\t\t\t\tif (!sub_sp) {\n\t\t\t\t\tgoto lookahead_fail;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (sub_sp) {\n\t\t\t\t\tgoto lookahead_fail;\n\t\t\t\t}\n\t\t\t}\n\t\t\tsub_sp = duk__match_regexp(re_ctx, pc + skip, sp);\n\t\t\tif (sub_sp) {\n\t\t\t\t/* match: keep saves */\n\t\t\t\tduk_pop((duk_context *) re_ctx->thr);\n\t\t\t\tsp = sub_sp;\n\t\t\t\tgoto match;\n\t\t\t}\n\n\t\t\t/* fall through */\n\n\t\t lookahead_fail:\n\t\t\t/* fail: restore saves */\n\t\t\tDUK_MEMCPY((void *) re_ctx->saved,\n\t\t\t           (const void *) full_save,\n\t\t\t           sizeof(duk_uint8_t *) * re_ctx->nsaved);\n\t\t\tduk_pop((duk_context *) re_ctx->thr);\n\t\t\tgoto fail;\n\t\t}\n\t\tcase DUK_REOP_BACKREFERENCE: {\n\t\t\t/*\n\t\t\t *  Byte matching for back-references would be OK in case-\n\t\t\t *  sensitive matching.  In case-insensitive matching we need\n\t\t\t *  to canonicalize characters, so back-reference matching needs\n\t\t\t *  to be done with codepoints instead.  So, we just decode\n\t\t\t *  everything normally here, too.\n\t\t\t *\n\t\t\t *  Note: back-reference index which is 0 or higher than\n\t\t\t *  NCapturingParens (= number of capturing parens in the\n\t\t\t *  -entire- regexp) is a compile time error.  However, a\n\t\t\t *  backreference referring to a valid capture which has\n\t\t\t *  not matched anything always succeeds!  See E5 Section\n\t\t\t *  15.10.2.9, step 5, sub-step 3.\n\t\t\t */\n\t\t\tduk_uint32_t idx;\n\t\t\tconst duk_uint8_t *p;\n\n\t\t\tidx = duk__bc_get_u32(re_ctx, &pc);\n\t\t\tidx = idx << 1;  /* backref n -> saved indices [n*2, n*2+1] */\n\t\t\tif (idx < 2 || idx + 1 >= re_ctx->nsaved) {\n\t\t\t\t/* regexp compiler should catch these */\n\t\t\t\tDUK_D(DUK_DPRINT(\"internal error, backreference index insane\"));\n\t\t\t\tgoto internal_error;\n\t\t\t}\n\t\t\tif (!re_ctx->saved[idx] || !re_ctx->saved[idx+1]) {\n\t\t\t\t/* capture is 'undefined', always matches! */\n\t\t\t\tDUK_DDD(DUK_DDDPRINT(\"backreference: saved[%ld,%ld] not complete, always match\",\n\t\t\t\t                     (long) idx, (long) (idx + 1)));\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"backreference: match saved[%ld,%ld]\", (long) idx, (long) (idx + 1)));\n\n\t\t\tp = re_ctx->saved[idx];\n\t\t\twhile (p < re_ctx->saved[idx+1]) {\n\t\t\t\tduk_codepoint_t c1, c2;\n\n\t\t\t\t/* Note: not necessary to check p against re_ctx->input_end:\n\t\t\t\t * the memory access is checked by duk__inp_get_cp(), while\n\t\t\t\t * valid compiled regexps cannot write a saved[] entry\n\t\t\t\t * which points to outside the string.\n\t\t\t\t */\n\t\t\t\tc1 = duk__inp_get_cp(re_ctx, &p);\n\t\t\t\tDUK_ASSERT(c1 >= 0);\n\t\t\t\tc2 = duk__inp_get_cp(re_ctx, &sp);\n\t\t\t\t/* No need for an explicit c2 < 0 check: because c1 >= 0,\n\t\t\t\t * the comparison will always fail if c2 < 0.\n\t\t\t\t */\n#if 0\n\t\t\t\tif (c2 < 0) {\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n#endif\n\t\t\t\tif (c1 != c2) {\n\t\t\t\t\tgoto fail;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tDUK_D(DUK_DPRINT(\"internal error, regexp opcode error: %ld\", (long) op));\n\t\t\tgoto internal_error;\n\t\t}\n\t\t}\n\t}\n\n match:\n\tre_ctx->recursion_depth--;\n\treturn sp;\n\n fail:\n\tre_ctx->recursion_depth--;\n\treturn NULL;\n\n internal_error:\n\tDUK_ERROR_INTERNAL(re_ctx->thr);\n\treturn NULL;  /* never here */\n}\n\n/*\n *  Exposed matcher function which provides the semantics of RegExp.prototype.exec().\n *\n *  RegExp.prototype.test() has the same semantics as exec() but does not return the\n *  result object (which contains the matching string and capture groups).  Currently\n *  there is no separate test() helper, so a temporary result object is created and\n *  discarded if test() is needed.  This is intentional, to save code space.\n *\n *  Input stack:  [ ... re_obj input ]\n *  Output stack: [ ... result ]\n */\n\nDUK_LOCAL void duk__regexp_match_helper(duk_hthread *thr, duk_small_int_t force_global) {\n\tduk_context *ctx = (duk_context *) thr;\n\tduk_re_matcher_ctx re_ctx;\n\tduk_hobject *h_regexp;\n\tduk_hstring *h_bytecode;\n\tduk_hstring *h_input;\n\tduk_uint8_t *p_buf;\n\tconst duk_uint8_t *pc;\n\tconst duk_uint8_t *sp;\n\tduk_small_int_t match = 0;\n\tduk_small_int_t global;\n\tduk_uint_fast32_t i;\n\tdouble d;\n\tduk_uint32_t char_offset;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(ctx != NULL);\n\n\tDUK_DD(DUK_DDPRINT(\"regexp match: regexp=%!T, input=%!T\",\n\t                   (duk_tval *) duk_get_tval(ctx, -2),\n\t                   (duk_tval *) duk_get_tval(ctx, -1)));\n\n\t/*\n\t *  Regexp instance check, bytecode check, input coercion.\n\t *\n\t *  See E5 Section 15.10.6.\n\t */\n\n\t/* TypeError if wrong; class check, see E5 Section 15.10.6 */\n\th_regexp = duk_require_hobject_with_class(ctx, -2, DUK_HOBJECT_CLASS_REGEXP);\n\tDUK_ASSERT(h_regexp != NULL);\n\tDUK_ASSERT(DUK_HOBJECT_GET_CLASS_NUMBER(h_regexp) == DUK_HOBJECT_CLASS_REGEXP);\n\tDUK_UNREF(h_regexp);\n\n\th_input = duk_to_hstring(ctx, -1);\n\tDUK_ASSERT(h_input != NULL);\n\n\tduk_get_prop_stridx_short(ctx, -2, DUK_STRIDX_INT_BYTECODE);  /* [ ... re_obj input ] -> [ ... re_obj input bc ] */\n\th_bytecode = duk_require_hstring(ctx, -1);  /* no regexp instance should exist without a non-configurable bytecode property */\n\tDUK_ASSERT(h_bytecode != NULL);\n\n\t/*\n\t *  Basic context initialization.\n\t *\n\t *  Some init values are read from the bytecode header\n\t *  whose format is (UTF-8 codepoints):\n\t *\n\t *    uint   flags\n\t *    uint   nsaved (even, 2n+2 where n = num captures)\n\t */\n\n\t/* [ ... re_obj input bc ] */\n\n\tDUK_MEMZERO(&re_ctx, sizeof(re_ctx));\n\n\tre_ctx.thr = thr;\n\tre_ctx.input = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_input);\n\tre_ctx.input_end = re_ctx.input + DUK_HSTRING_GET_BYTELEN(h_input);\n\tre_ctx.bytecode = (const duk_uint8_t *) DUK_HSTRING_GET_DATA(h_bytecode);\n\tre_ctx.bytecode_end = re_ctx.bytecode + DUK_HSTRING_GET_BYTELEN(h_bytecode);\n\tre_ctx.saved = NULL;\n\tre_ctx.recursion_limit = DUK_USE_REGEXP_EXECUTOR_RECLIMIT;\n\tre_ctx.steps_limit = DUK_RE_EXECUTE_STEPS_LIMIT;\n\n\t/* read header */\n\tpc = re_ctx.bytecode;\n\tre_ctx.re_flags = duk__bc_get_u32(&re_ctx, &pc);\n\tre_ctx.nsaved = duk__bc_get_u32(&re_ctx, &pc);\n\tre_ctx.bytecode = pc;\n\n\tDUK_ASSERT(DUK_RE_FLAG_GLOBAL < 0x10000UL);  /* must fit into duk_small_int_t */\n\tglobal = (duk_small_int_t) (force_global | (re_ctx.re_flags & DUK_RE_FLAG_GLOBAL));\n\n\tDUK_ASSERT(re_ctx.nsaved >= 2);\n\tDUK_ASSERT((re_ctx.nsaved % 2) == 0);\n\n\tp_buf = (duk_uint8_t *) duk_push_fixed_buffer(ctx, sizeof(duk_uint8_t *) * re_ctx.nsaved);  /* rely on zeroing */\n\tDUK_UNREF(p_buf);\n\tre_ctx.saved = (const duk_uint8_t **) duk_get_buffer(ctx, -1, NULL);\n\tDUK_ASSERT(re_ctx.saved != NULL);\n\n\t/* [ ... re_obj input bc saved_buf ] */\n\n#if defined(DUK_USE_EXPLICIT_NULL_INIT)\n\tfor (i = 0; i < re_ctx.nsaved; i++) {\n\t\tre_ctx.saved[i] = (duk_uint8_t *) NULL;\n\t}\n#elif defined(DUK_USE_ZERO_BUFFER_DATA)\n\t/* buffer is automatically zeroed */\n#else\n\tDUK_MEMZERO((void *) p_buf, sizeof(duk_uint8_t *) * re_ctx.nsaved);\n#endif\n\n\tDUK_DDD(DUK_DDDPRINT(\"regexp ctx initialized, flags=0x%08lx, nsaved=%ld, recursion_limit=%ld, steps_limit=%ld\",\n\t                     (unsigned long) re_ctx.re_flags, (long) re_ctx.nsaved, (long) re_ctx.recursion_limit,\n\t                     (long) re_ctx.steps_limit));\n\n\t/*\n\t *  Get starting character offset for match, and initialize 'sp' based on it.\n\t *\n\t *  Note: lastIndex is non-configurable so it must be present (we check the\n\t *  internal class of the object above, so we know it is).  User code can set\n\t *  its value to an arbitrary (garbage) value though; E5 requires that lastIndex\n\t *  be coerced to a number before using.  The code below works even if the\n\t *  property is missing: the value will then be coerced to zero.\n\t *\n\t *  Note: lastIndex may be outside Uint32 range even after ToInteger() coercion.\n\t *  For instance, ToInteger(+Infinity) = +Infinity.  We track the match offset\n\t *  as an integer, but pre-check it to be inside the 32-bit range before the loop.\n\t *  If not, the check in E5 Section 15.10.6.2, step 9.a applies.\n\t */\n\n\t/* XXX: lastIndex handling produces a lot of asm */\n\n\t/* [ ... re_obj input bc saved_buf ] */\n\n\tduk_get_prop_stridx_short(ctx, -4, DUK_STRIDX_LAST_INDEX);  /* -> [ ... re_obj input bc saved_buf lastIndex ] */\n\t(void) duk_to_int(ctx, -1);  /* ToInteger(lastIndex) */\n\td = duk_get_number(ctx, -1);  /* integer, but may be +/- Infinite, +/- zero (not NaN, though) */\n\tduk_pop(ctx);\n\n\tif (global) {\n\t\tif (d < 0.0 || d > (double) DUK_HSTRING_GET_CHARLEN(h_input)) {\n\t\t\t/* match fail */\n\t\t\tchar_offset = 0;   /* not really necessary */\n\t\t\tDUK_ASSERT(match == 0);\n\t\t\tgoto match_over;\n\t\t}\n\t\tchar_offset = (duk_uint32_t) d;\n\t} else {\n\t\t/* lastIndex must be ignored for non-global regexps, but get the\n\t\t * value for (theoretical) side effects.  No side effects can\n\t\t * really occur, because lastIndex is a normal property and is\n\t\t * always non-configurable for RegExp instances.\n\t\t */\n\t\tchar_offset = (duk_uint32_t) 0;\n\t}\n\n\tDUK_ASSERT(char_offset <= DUK_HSTRING_GET_CHARLEN(h_input));\n\tsp = re_ctx.input + duk_heap_strcache_offset_char2byte(thr, h_input, char_offset);\n\n\t/*\n\t *  Match loop.\n\t *\n\t *  Try matching at different offsets until match found or input exhausted.\n\t */\n\n\t/* [ ... re_obj input bc saved_buf ] */\n\n\tDUK_ASSERT(match == 0);\n\n\tfor (;;) {\n\t\t/* char offset in [0, h_input->clen] (both ends inclusive), checked before entry */\n\t\tDUK_ASSERT_DISABLE(char_offset >= 0);\n\t\tDUK_ASSERT(char_offset <= DUK_HSTRING_GET_CHARLEN(h_input));\n\n\t\t/* Note: ctx.steps is intentionally not reset, it applies to the entire unanchored match */\n\t\tDUK_ASSERT(re_ctx.recursion_depth == 0);\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"attempt match at char offset %ld; %p [%p,%p]\",\n\t\t                     (long) char_offset, (const void *) sp,\n\t\t                     (const void *) re_ctx.input, (const void *) re_ctx.input_end));\n\n\t\t/*\n\t\t *  Note:\n\t\t *\n\t\t *    - duk__match_regexp() is required not to longjmp() in ordinary \"non-match\"\n\t\t *      conditions; a longjmp() will terminate the entire matching process.\n\t\t *\n\t\t *    - Clearing saved[] is not necessary because backtracking does it\n\t\t *\n\t\t *    - Backtracking also rewinds ctx.recursion back to zero, unless an\n\t\t *      internal/limit error occurs (which causes a longjmp())\n\t\t *\n\t\t *    - If we supported anchored matches, we would break out here\n\t\t *      unconditionally; however, Ecmascript regexps don't have anchored\n\t\t *      matches.  It might make sense to implement a fast bail-out if\n\t\t *      the regexp begins with '^' and sp is not 0: currently we'll just\n\t\t *      run through the entire input string, trivially failing the match\n\t\t *      at every non-zero offset.\n\t\t */\n\n\t\tif (duk__match_regexp(&re_ctx, re_ctx.bytecode, sp) != NULL) {\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"match at offset %ld\", (long) char_offset));\n\t\t\tmatch = 1;\n\t\t\tbreak;\n\t\t}\n\n\t\t/* advance by one character (code point) and one char_offset */\n\t\tchar_offset++;\n\t\tif (char_offset > DUK_HSTRING_GET_CHARLEN(h_input)) {\n\t\t\t/*\n\t\t\t *  Note:\n\t\t\t *\n\t\t\t *    - Intentionally attempt (empty) match at char_offset == k_input->clen\n\t\t\t *\n\t\t\t *    - Negative char_offsets have been eliminated and char_offset is duk_uint32_t\n\t\t\t *      -> no need or use for a negative check\n\t\t\t */\n\n\t\t\tDUK_DDD(DUK_DDDPRINT(\"no match after trying all sp offsets\"));\n\t\t\tbreak;\n\t\t}\n\n\t\t/* avoid calling at end of input, will DUK_ERROR (above check suffices to avoid this) */\n\t\t(void) duk__utf8_advance(thr, &sp, re_ctx.input, re_ctx.input_end, (duk_uint_fast32_t) 1);\n\t}\n\n match_over:\n\n\t/*\n\t *  Matching complete, create result array or return a 'null'.  Update lastIndex\n\t *  if necessary.  See E5 Section 15.10.6.2.\n\t *\n\t *  Because lastIndex is a character (not byte) offset, we need the character\n\t *  length of the match which we conveniently get as a side effect of interning\n\t *  the matching substring (0th index of result array).\n\t *\n\t *  saved[0]         start pointer (~ byte offset) of current match\n\t *  saved[1]         end pointer (~ byte offset) of current match (exclusive)\n\t *  char_offset      start character offset of current match (-> .index of result)\n\t *  char_end_offset  end character offset (computed below)\n\t */\n\n\t/* [ ... re_obj input bc saved_buf ] */\n\n\tif (match) {\n#if defined(DUK_USE_ASSERTIONS)\n\t\tduk_hobject *h_res;\n#endif\n\t\tduk_uint32_t char_end_offset = 0;\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"regexp matches at char_offset %ld\", (long) char_offset));\n\n\t\tDUK_ASSERT(re_ctx.nsaved >= 2);        /* must have start and end */\n\t\tDUK_ASSERT((re_ctx.nsaved % 2) == 0);  /* and even number */\n\n\t\t/* XXX: Array size is known before and (2 * re_ctx.nsaved) but not taken\n\t\t * advantage of now.  The array is not compacted either, as regexp match\n\t\t * objects are usually short lived.\n\t\t */\n\n\t\tduk_push_array(ctx);\n\n#if defined(DUK_USE_ASSERTIONS)\n\t\th_res = duk_require_hobject(ctx, -1);\n\t\tDUK_ASSERT(DUK_HOBJECT_HAS_EXTENSIBLE(h_res));\n\t\tDUK_ASSERT(DUK_HOBJECT_HAS_EXOTIC_ARRAY(h_res));\n\t\tDUK_ASSERT(DUK_HOBJECT_GET_CLASS_NUMBER(h_res) == DUK_HOBJECT_CLASS_ARRAY);\n#endif\n\n\t\t/* [ ... re_obj input bc saved_buf res_obj ] */\n\n\t\tduk_push_u32(ctx, char_offset);\n\t\tduk_xdef_prop_stridx_short_wec(ctx, -2, DUK_STRIDX_INDEX);\n\n\t\tduk_dup_m4(ctx);\n\t\tduk_xdef_prop_stridx_short_wec(ctx, -2, DUK_STRIDX_INPUT);\n\n\t\tfor (i = 0; i < re_ctx.nsaved; i += 2) {\n\t\t\t/* Captures which are undefined have NULL pointers and are returned\n\t\t\t * as 'undefined'.  The same is done when saved[] pointers are insane\n\t\t\t * (this should, of course, never happen in practice).\n\t\t\t */\n\t\t\tif (re_ctx.saved[i] && re_ctx.saved[i + 1] && re_ctx.saved[i + 1] >= re_ctx.saved[i]) {\n\t\t\t\tduk_push_lstring(ctx,\n\t\t\t\t                 (const char *) re_ctx.saved[i],\n\t\t\t\t                 (duk_size_t) (re_ctx.saved[i+1] - re_ctx.saved[i]));\n\t\t\t\tif (i == 0) {\n\t\t\t\t\t/* Assumes that saved[0] and saved[1] are always\n\t\t\t\t\t * set by regexp bytecode (if not, char_end_offset\n\t\t\t\t\t * will be zero).  Also assumes clen reflects the\n\t\t\t\t\t * correct char length.\n\t\t\t\t\t */\n\t\t\t\t\tchar_end_offset = char_offset + (duk_uint32_t) duk_get_length(ctx, -1);  /* add charlen */\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tduk_push_undefined(ctx);\n\t\t\t}\n\n\t\t\t/* [ ... re_obj input bc saved_buf res_obj val ] */\n\t\t\tduk_put_prop_index(ctx, -2, i / 2);\n\t\t}\n\n\t\t/* [ ... re_obj input bc saved_buf res_obj ] */\n\n\t\t/* NB: 'length' property is automatically updated by the array setup loop */\n\n\t\tif (global) {\n\t\t\t/* global regexp: lastIndex updated on match */\n\t\t\tduk_push_u32(ctx, char_end_offset);\n\t\t\tduk_put_prop_stridx_short(ctx, -6, DUK_STRIDX_LAST_INDEX);\n\t\t} else {\n\t\t\t/* non-global regexp: lastIndex never updated on match */\n\t\t\t;\n\t\t}\n\t} else {\n\t\t/*\n\t\t *  No match, E5 Section 15.10.6.2, step 9.a.i - 9.a.ii apply, regardless\n\t\t *  of 'global' flag of the RegExp.  In particular, if lastIndex is invalid\n\t\t *  initially, it is reset to zero.\n\t\t */\n\n\t\tDUK_DDD(DUK_DDDPRINT(\"regexp does not match\"));\n\n\t\tduk_push_null(ctx);\n\n\t\t/* [ ... re_obj input bc saved_buf res_obj ] */\n\n\t\tduk_push_int(ctx, 0);\n\t\tduk_put_prop_stridx_short(ctx, -6, DUK_STRIDX_LAST_INDEX);\n\t}\n\n\t/* [ ... re_obj input bc saved_buf res_obj ] */\n\n\tduk_insert(ctx, -5);\n\n\t/* [ ... res_obj re_obj input bc saved_buf ] */\n\n\tduk_pop_n(ctx, 4);\n\n\t/* [ ... res_obj ] */\n\n\t/* XXX: these last tricks are unnecessary if the function is made\n\t * a genuine native function.\n\t */\n}\n\nDUK_INTERNAL void duk_regexp_match(duk_hthread *thr) {\n\tduk__regexp_match_helper(thr, 0 /*force_global*/);\n}\n\n/* This variant is needed by String.prototype.split(); it needs to perform\n * global-style matching on a cloned RegExp which is potentially non-global.\n */\nDUK_INTERNAL void duk_regexp_match_force_global(duk_hthread *thr) {\n\tduk__regexp_match_helper(thr, 1 /*force_global*/);\n}\n\n#else  /* DUK_USE_REGEXP_SUPPORT */\n\n/* regexp support disabled */\n\n#endif  /* DUK_USE_REGEXP_SUPPORT */\n/*\n *  Self tests to ensure execution environment is sane.  Intended to catch\n *  compiler/platform problems which cannot be detected at compile time.\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_SELF_TESTS)\n\n/*\n *  Unions and structs for self tests\n */\n\ntypedef union {\n\tdouble d;\n\tduk_uint8_t x[8];\n} duk__test_double_union;\n\n/* Self test failed.  Expects a local variable 'error_count' to exist. */\n#define DUK__FAILED(msg)  do { \\\n\t\tDUK_D(DUK_DPRINT(\"self test failed: \" #msg \" at \" DUK_FILE_MACRO \":\" DUK_MACRO_STRINGIFY(DUK_LINE_MACRO))); \\\n\t\terror_count++; \\\n\t} while (0)\n\n#define DUK__DBLUNION_CMP_TRUE(a,b)  do { \\\n\t\tif (DUK_MEMCMP((const void *) (a), (const void *) (b), sizeof(duk__test_double_union)) != 0) { \\\n\t\t\tDUK__FAILED(\"double union compares false (expected true)\"); \\\n\t\t} \\\n\t} while (0)\n\n#define DUK__DBLUNION_CMP_FALSE(a,b)  do { \\\n\t\tif (DUK_MEMCMP((const void *) (a), (const void *) (b), sizeof(duk__test_double_union)) == 0) { \\\n\t\t\tDUK__FAILED(\"double union compares true (expected false)\"); \\\n\t\t} \\\n\t} while (0)\n\ntypedef union {\n\tduk_uint32_t i;\n\tduk_uint8_t x[8];\n} duk__test_u32_union;\n\n#if defined(DUK_USE_INTEGER_LE)\n#define DUK__U32_INIT(u, a, b, c, d) do { \\\n\t\t(u)->x[0] = (d); (u)->x[1] = (c); (u)->x[2] = (b); (u)->x[3] = (a); \\\n\t} while (0)\n#elif defined(DUK_USE_INTEGER_ME)\n#error integer mixed endian not supported now\n#elif defined(DUK_USE_INTEGER_BE)\n#define DUK__U32_INIT(u, a, b, c, d) do { \\\n\t\t(u)->x[0] = (a); (u)->x[1] = (b); (u)->x[2] = (c); (u)->x[3] = (d); \\\n\t} while (0)\n#else\n#error unknown integer endianness\n#endif\n\n#if defined(DUK_USE_DOUBLE_LE)\n#define DUK__DOUBLE_INIT(u, a, b, c, d, e, f, g, h) do { \\\n\t\t(u)->x[0] = (h); (u)->x[1] = (g); (u)->x[2] = (f); (u)->x[3] = (e); \\\n\t\t(u)->x[4] = (d); (u)->x[5] = (c); (u)->x[6] = (b); (u)->x[7] = (a); \\\n\t} while (0)\n#define DUK__DOUBLE_COMPARE(u, a, b, c, d, e, f, g, h) \\\n\t((u)->x[0] == (h) && (u)->x[1] == (g) && (u)->x[2] == (f) && (u)->x[3] == (e) && \\\n\t (u)->x[4] == (d) && (u)->x[5] == (c) && (u)->x[6] == (b) && (u)->x[7] == (a))\n#elif defined(DUK_USE_DOUBLE_ME)\n#define DUK__DOUBLE_INIT(u, a, b, c, d, e, f, g, h) do { \\\n\t\t(u)->x[0] = (d); (u)->x[1] = (c); (u)->x[2] = (b); (u)->x[3] = (a); \\\n\t\t(u)->x[4] = (h); (u)->x[5] = (g); (u)->x[6] = (f); (u)->x[7] = (e); \\\n\t} while (0)\n#define DUK__DOUBLE_COMPARE(u, a, b, c, d, e, f, g, h) \\\n\t((u)->x[0] == (d) && (u)->x[1] == (c) && (u)->x[2] == (b) && (u)->x[3] == (a) && \\\n\t (u)->x[4] == (h) && (u)->x[5] == (g) && (u)->x[6] == (f) && (u)->x[7] == (e))\n#elif defined(DUK_USE_DOUBLE_BE)\n#define DUK__DOUBLE_INIT(u, a, b, c, d, e, f, g, h) do { \\\n\t\t(u)->x[0] = (a); (u)->x[1] = (b); (u)->x[2] = (c); (u)->x[3] = (d); \\\n\t\t(u)->x[4] = (e); (u)->x[5] = (f); (u)->x[6] = (g); (u)->x[7] = (h); \\\n\t} while (0)\n#define DUK__DOUBLE_COMPARE(u, a, b, c, d, e, f, g, h) \\\n\t((u)->x[0] == (a) && (u)->x[1] == (b) && (u)->x[2] == (c) && (u)->x[3] == (d) && \\\n\t (u)->x[4] == (e) && (u)->x[5] == (f) && (u)->x[6] == (g) && (u)->x[7] == (h))\n#else\n#error unknown double endianness\n#endif\n\n/*\n *  Various sanity checks for typing\n */\n\nDUK_LOCAL duk_uint_t duk__selftest_types(void) {\n\tduk_uint_t error_count = 0;\n\n\tif (!(sizeof(duk_int8_t) == 1 &&\n\t      sizeof(duk_uint8_t) == 1 &&\n\t      sizeof(duk_int16_t) == 2 &&\n\t      sizeof(duk_uint16_t) == 2 &&\n\t      sizeof(duk_int32_t) == 4 &&\n\t      sizeof(duk_uint32_t) == 4)) {\n\t\tDUK__FAILED(\"duk_(u)int{8,16,32}_t size\");\n\t}\n#if defined(DUK_USE_64BIT_OPS)\n\tif (!(sizeof(duk_int64_t) == 8 &&\n\t      sizeof(duk_uint64_t) == 8)) {\n\t\tDUK__FAILED(\"duk_(u)int64_t size\");\n\t}\n#endif\n\n\tif (!(sizeof(duk_size_t) >= sizeof(duk_uint_t))) {\n\t\t/* Some internal code now assumes that all duk_uint_t values\n\t\t * can be expressed with a duk_size_t.\n\t\t */\n\t\tDUK__FAILED(\"duk_size_t is smaller than duk_uint_t\");\n\t}\n\tif (!(sizeof(duk_int_t) >= 4)) {\n\t\tDUK__FAILED(\"duk_int_t is not 32 bits\");\n\t}\n\n\treturn error_count;\n}\n\n/*\n *  Packed tval sanity\n */\n\nDUK_LOCAL duk_uint_t duk__selftest_packed_tval(void) {\n\tduk_uint_t error_count = 0;\n\n#if defined(DUK_USE_PACKED_TVAL)\n\tif (sizeof(void *) > 4) {\n\t\tDUK__FAILED(\"packed duk_tval in use but sizeof(void *) > 4\");\n\t}\n#endif\n\n\treturn error_count;\n}\n\n/*\n *  Two's complement arithmetic.\n */\n\nDUK_LOCAL duk_uint_t duk__selftest_twos_complement(void) {\n\tduk_uint_t error_count = 0;\n\tvolatile int test;\n\ttest = -1;\n\n\t/* Note that byte order doesn't affect this test: all bytes in\n\t * 'test' will be 0xFF for two's complement.\n\t */\n\tif (((volatile duk_uint8_t *) &test)[0] != (duk_uint8_t) 0xff) {\n\t\tDUK__FAILED(\"two's complement arithmetic\");\n\t}\n\n\treturn error_count;\n}\n\n/*\n *  Byte order.  Important to self check, because on some exotic platforms\n *  there is no actual detection but rather assumption based on platform\n *  defines.\n */\n\nDUK_LOCAL duk_uint_t duk__selftest_byte_order(void) {\n\tduk_uint_t error_count = 0;\n\tduk__test_u32_union u1;\n\tduk__test_double_union u2;\n\n\t/*\n\t *  >>> struct.pack('>d', 102030405060).encode('hex')\n\t *  '4237c17c6dc40000'\n\t */\n\n\tDUK__U32_INIT(&u1, 0xde, 0xad, 0xbe, 0xef);\n\tDUK__DOUBLE_INIT(&u2, 0x42, 0x37, 0xc1, 0x7c, 0x6d, 0xc4, 0x00, 0x00);\n\n\tif (u1.i != (duk_uint32_t) 0xdeadbeefUL) {\n\t\tDUK__FAILED(\"duk_uint32_t byte order\");\n\t}\n\n\tif (u2.d != (double) 102030405060.0) {\n\t\tDUK__FAILED(\"double byte order\");\n\t}\n\n\treturn error_count;\n}\n\n/*\n *  DUK_BSWAP macros\n */\n\nDUK_LOCAL duk_uint_t duk__selftest_bswap_macros(void) {\n\tduk_uint_t error_count = 0;\n\tduk_uint32_t x32;\n\tduk_uint16_t x16;\n\tduk_double_union du;\n\tduk_double_t du_diff;\n\n\tx16 = 0xbeefUL;\n\tx16 = DUK_BSWAP16(x16);\n\tif (x16 != (duk_uint16_t) 0xefbeUL) {\n\t\tDUK__FAILED(\"DUK_BSWAP16\");\n\t}\n\n\tx32 = 0xdeadbeefUL;\n\tx32 = DUK_BSWAP32(x32);\n\tif (x32 != (duk_uint32_t) 0xefbeaddeUL) {\n\t\tDUK__FAILED(\"DUK_BSWAP32\");\n\t}\n\n\t/* >>> struct.unpack('>d', '4000112233445566'.decode('hex'))\n\t * (2.008366013071895,)\n\t */\n\n\tdu.uc[0] = 0x40; du.uc[1] = 0x00; du.uc[2] = 0x11; du.uc[3] = 0x22;\n\tdu.uc[4] = 0x33; du.uc[5] = 0x44; du.uc[6] = 0x55; du.uc[7] = 0x66;\n\tDUK_DBLUNION_DOUBLE_NTOH(&du);\n\tdu_diff = du.d - 2.008366013071895;\n#if 0\n\tDUK_D(DUK_DPRINT(\"du_diff: %lg\\n\", (double) du_diff));\n#endif\n\tif (du_diff > 1e-15) {\n\t\t/* Allow very small lenience because some compilers won't parse\n\t\t * exact IEEE double constants (happened in matrix testing with\n\t\t * Linux gcc-4.8 -m32 at least).\n\t\t */\n#if 0\n\t\tDUK_D(DUK_DPRINT(\"Result of DUK_DBLUNION_DOUBLE_NTOH: %02x %02x %02x %02x %02x %02x %02x %02x\\n\",\n\t\t            (unsigned int) du.uc[0], (unsigned int) du.uc[1],\n\t\t            (unsigned int) du.uc[2], (unsigned int) du.uc[3],\n\t\t            (unsigned int) du.uc[4], (unsigned int) du.uc[5],\n\t\t            (unsigned int) du.uc[6], (unsigned int) du.uc[7]));\n#endif\n\t\tDUK__FAILED(\"DUK_DBLUNION_DOUBLE_NTOH\");\n\t}\n\n\treturn error_count;\n}\n\n/*\n *  Basic double / byte union memory layout.\n */\n\nDUK_LOCAL duk_uint_t duk__selftest_double_union_size(void) {\n\tduk_uint_t error_count = 0;\n\n\tif (sizeof(duk__test_double_union) != 8) {\n\t\tDUK__FAILED(\"invalid union size\");\n\t}\n\n\treturn error_count;\n}\n\n/*\n *  Union aliasing, see misc/clang_aliasing.c.\n */\n\nDUK_LOCAL duk_uint_t duk__selftest_double_aliasing(void) {\n\t/* This testcase fails when Emscripten-generated code runs on Firefox.\n\t * It's not an issue because the failure should only affect packed\n\t * duk_tval representation, which is not used with Emscripten.\n\t */\n#if defined(DUK_USE_PACKED_TVAL)\n\tduk_uint_t error_count = 0;\n\tduk__test_double_union a, b;\n\n\t/* Test signaling NaN and alias assignment in all endianness combinations.\n\t */\n\n\t/* little endian */\n\ta.x[0] = 0x11; a.x[1] = 0x22; a.x[2] = 0x33; a.x[3] = 0x44;\n\ta.x[4] = 0x00; a.x[5] = 0x00; a.x[6] = 0xf1; a.x[7] = 0xff;\n\tb = a;\n\tDUK__DBLUNION_CMP_TRUE(&a, &b);\n\n\t/* big endian */\n\ta.x[0] = 0xff; a.x[1] = 0xf1; a.x[2] = 0x00; a.x[3] = 0x00;\n\ta.x[4] = 0x44; a.x[5] = 0x33; a.x[6] = 0x22; a.x[7] = 0x11;\n\tb = a;\n\tDUK__DBLUNION_CMP_TRUE(&a, &b);\n\n\t/* mixed endian */\n\ta.x[0] = 0x00; a.x[1] = 0x00; a.x[2] = 0xf1; a.x[3] = 0xff;\n\ta.x[4] = 0x11; a.x[5] = 0x22; a.x[6] = 0x33; a.x[7] = 0x44;\n\tb = a;\n\tDUK__DBLUNION_CMP_TRUE(&a, &b);\n\n\treturn error_count;\n#else\n\tDUK_D(DUK_DPRINT(\"skip double aliasing self test when duk_tval is not packed\"));\n\treturn 0;\n#endif\n}\n\n/*\n *  Zero sign, see misc/tcc_zerosign2.c.\n */\n\nDUK_LOCAL duk_uint_t duk__selftest_double_zero_sign(void) {\n\tduk_uint_t error_count = 0;\n\tduk__test_double_union a, b;\n\n\ta.d = 0.0;\n\tb.d = -a.d;\n\tDUK__DBLUNION_CMP_FALSE(&a, &b);\n\n\treturn error_count;\n}\n\n/*\n *  Rounding mode: Duktape assumes round-to-nearest, check that this is true.\n *  If we had C99 fenv.h we could check that fegetround() == FE_TONEAREST,\n *  but we don't want to rely on that header; and even if we did, it's good\n *  to ensure the rounding actually works.\n */\n\nDUK_LOCAL duk_uint_t duk__selftest_double_rounding(void) {\n\tduk_uint_t error_count = 0;\n\tduk__test_double_union a, b, c;\n\n#if 0\n\t/* Include <fenv.h> and test manually; these trigger failures: */\n\tfesetround(FE_UPWARD);\n\tfesetround(FE_DOWNWARD);\n\tfesetround(FE_TOWARDZERO);\n\n\t/* This is the default and passes. */\n\tfesetround(FE_TONEAREST);\n#endif\n\n\t/* Rounding tests check that none of the other modes (round to\n\t * +Inf, round to -Inf, round to zero) can be active:\n\t * http://www.gnu.org/software/libc/manual/html_node/Rounding.html\n\t */\n\n\t/* 1.0 + 2^(-53): result is midway between 1.0 and 1.0 + ulp.\n\t * Round to nearest: 1.0\n\t * Round to +Inf:    1.0 + ulp\n\t * Round to -Inf:    1.0\n\t * Round to zero:    1.0\n\t * => Correct result eliminates round to +Inf.\n\t */\n\tDUK__DOUBLE_INIT(&a, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);\n\tDUK__DOUBLE_INIT(&b, 0x3c, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);\n\tDUK_MEMSET((void *) &c, 0, sizeof(c));\n\tc.d = a.d + b.d;\n\tif (!DUK__DOUBLE_COMPARE(&c, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)) {\n\t\tDUK_D(DUK_DPRINT(\"broken result (native endiannesss): %02x %02x %02x %02x %02x %02x %02x %02x\",\n\t\t                 (unsigned int) c.x[0], (unsigned int) c.x[1],\n\t\t                 (unsigned int) c.x[2], (unsigned int) c.x[3],\n\t\t                 (unsigned int) c.x[4], (unsigned int) c.x[5],\n\t\t                 (unsigned int) c.x[6], (unsigned int) c.x[7]));\n\t\tDUK__FAILED(\"invalid result from 1.0 + 0.5ulp\");\n\t}\n\n\t/* (1.0 + ulp) + 2^(-53): result is midway between 1.0 + ulp and 1.0 + 2*ulp.\n\t * Round to nearest: 1.0 + 2*ulp (round to even mantissa)\n\t * Round to +Inf:    1.0 + 2*ulp\n\t * Round to -Inf:    1.0 + ulp\n\t * Round to zero:    1.0 + ulp\n\t * => Correct result eliminates round to -Inf and round to zero.\n\t */\n\tDUK__DOUBLE_INIT(&a, 0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01);\n\tDUK__DOUBLE_INIT(&b, 0x3c, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);\n\tDUK_MEMSET((void *) &c, 0, sizeof(c));\n\tc.d = a.d + b.d;\n\tif (!DUK__DOUBLE_COMPARE(&c, 0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02)) {\n\t\tDUK_D(DUK_DPRINT(\"broken result (native endiannesss): %02x %02x %02x %02x %02x %02x %02x %02x\",\n\t\t                 (unsigned int) c.x[0], (unsigned int) c.x[1],\n\t\t                 (unsigned int) c.x[2], (unsigned int) c.x[3],\n\t\t                 (unsigned int) c.x[4], (unsigned int) c.x[5],\n\t\t                 (unsigned int) c.x[6], (unsigned int) c.x[7]));\n\t\tDUK__FAILED(\"invalid result from (1.0 + ulp) + 0.5ulp\");\n\t}\n\n\t/* Could do negative number testing too, but the tests above should\n\t * differentiate between IEEE 754 rounding modes.\n\t */\n\treturn error_count;\n}\n\n/*\n *  fmod(): often a portability issue in embedded or bare platform targets.\n *  Check for at least minimally correct behavior.  Unlike some other math\n *  functions (like cos()) Duktape relies on fmod() internally too.\n */\n\nDUK_LOCAL duk_uint_t duk__selftest_fmod(void) {\n\tduk_uint_t error_count = 0;\n\tduk__test_double_union u1, u2;\n\n\t/* fmod() with integer argument and exponent 2^32 is used by e.g.\n\t * ToUint32() and some Duktape internals.\n\t */\n\tu1.d = DUK_FMOD(10.0, 4294967296.0);\n\tu2.d = 10.0;\n\tDUK__DBLUNION_CMP_TRUE(&u1, &u2);\n\n\tu1.d = DUK_FMOD(4294967306.0, 4294967296.0);\n\tu2.d = 10.0;\n\tDUK__DBLUNION_CMP_TRUE(&u1, &u2);\n\n\tu1.d = DUK_FMOD(73014444042.0, 4294967296.0);\n\tu2.d = 10.0;\n\tDUK__DBLUNION_CMP_TRUE(&u1, &u2);\n\n\t/* C99 behavior is for fmod() result sign to mathc argument sign. */\n\tu1.d = DUK_FMOD(-10.0, 4294967296.0);\n\tu2.d = -10.0;\n\tDUK__DBLUNION_CMP_TRUE(&u1, &u2);\n\n\tu1.d = DUK_FMOD(-4294967306.0, 4294967296.0);\n\tu2.d = -10.0;\n\tDUK__DBLUNION_CMP_TRUE(&u1, &u2);\n\n\tu1.d = DUK_FMOD(-73014444042.0, 4294967296.0);\n\tu2.d = -10.0;\n\tDUK__DBLUNION_CMP_TRUE(&u1, &u2);\n\n\treturn error_count;\n}\n\n/*\n *  Struct size/alignment if platform requires it\n *\n *  There are some compiler specific struct padding pragmas etc in use, this\n *  selftest ensures they're correctly detected and used.\n */\n\nDUK_LOCAL duk_uint_t duk__selftest_struct_align(void) {\n\tduk_uint_t error_count = 0;\n\n#if (DUK_USE_ALIGN_BY == 4)\n\tif ((sizeof(duk_hbuffer_fixed) % 4) != 0) {\n\t\tDUK__FAILED(\"sizeof(duk_hbuffer_fixed) not aligned to 4\");\n\t}\n#elif (DUK_USE_ALIGN_BY == 8)\n\tif ((sizeof(duk_hbuffer_fixed) % 8) != 0) {\n\t\tDUK__FAILED(\"sizeof(duk_hbuffer_fixed) not aligned to 8\");\n\t}\n#elif (DUK_USE_ALIGN_BY == 1)\n\t/* no check */\n#else\n#error invalid DUK_USE_ALIGN_BY\n#endif\n\treturn error_count;\n}\n\n/*\n *  64-bit arithmetic\n *\n *  There are some platforms/compilers where 64-bit types are available\n *  but don't work correctly.  Test for known cases.\n */\n\nDUK_LOCAL duk_uint_t duk__selftest_64bit_arithmetic(void) {\n\tduk_uint_t error_count = 0;\n#if defined(DUK_USE_64BIT_OPS)\n\tvolatile duk_int64_t i;\n\tvolatile duk_double_t d;\n\n\t/* Catch a double-to-int64 cast issue encountered in practice. */\n\td = 2147483648.0;\n\ti = (duk_int64_t) d;\n\tif (i != 0x80000000LL) {\n\t\tDUK__FAILED(\"casting 2147483648.0 to duk_int64_t failed\");\n\t}\n#else\n\t/* nop */\n#endif\n\treturn error_count;\n}\n\n/*\n *  Casting\n */\n\nDUK_LOCAL duk_uint_t duk__selftest_cast_double_to_small_uint(void) {\n\t/*\n\t *  https://github.com/svaarala/duktape/issues/127#issuecomment-77863473\n\t */\n\n\tduk_uint_t error_count = 0;\n\n\tduk_double_t d1, d2;\n\tduk_small_uint_t u;\n\n\tduk_double_t d1v, d2v;\n\tduk_small_uint_t uv;\n\n\t/* Test without volatiles */\n\n\td1 = 1.0;\n\tu = (duk_small_uint_t) d1;\n\td2 = (duk_double_t) u;\n\n\tif (!(d1 == 1.0 && u == 1 && d2 == 1.0 && d1 == d2)) {\n\t\tDUK__FAILED(\"double to duk_small_uint_t cast failed\");\n\t}\n\n\t/* Same test with volatiles */\n\n\td1v = 1.0;\n\tuv = (duk_small_uint_t) d1v;\n\td2v = (duk_double_t) uv;\n\n\tif (!(d1v == 1.0 && uv == 1 && d2v == 1.0 && d1v == d2v)) {\n\t\tDUK__FAILED(\"double to duk_small_uint_t cast failed\");\n\t}\n\n\treturn error_count;\n}\n\nDUK_LOCAL duk_uint_t duk__selftest_cast_double_to_uint32(void) {\n\t/*\n\t *  This test fails on an exotic ARM target; double-to-uint\n\t *  cast is incorrectly clamped to -signed- int highest value.\n\t *\n\t *  https://github.com/svaarala/duktape/issues/336\n\t */\n\n\tduk_uint_t error_count = 0;\n\tduk_double_t dv;\n\tduk_uint32_t uv;\n\n\tdv = 3735928559.0;  /* 0xdeadbeef in decimal */\n\tuv = (duk_uint32_t) dv;\n\n\tif (uv != 0xdeadbeefUL) {\n\t\tDUK__FAILED(\"double to duk_uint32_t cast failed\");\n\t}\n\n\treturn error_count;\n}\n\n/*\n *  Minimal test of user supplied allocation functions\n *\n *    - Basic alloc + realloc + free cycle\n *\n *    - Realloc to significantly larger size to (hopefully) trigger a\n *      relocation and check that relocation copying works\n */\n\nDUK_LOCAL duk_uint_t duk__selftest_alloc_funcs(duk_alloc_function alloc_func,\n                                               duk_realloc_function realloc_func,\n                                               duk_free_function free_func,\n                                               void *udata) {\n\tduk_uint_t error_count = 0;\n\tvoid *ptr;\n\tvoid *new_ptr;\n\tduk_small_int_t i, j;\n\tunsigned char x;\n\n\tif (alloc_func == NULL || realloc_func == NULL || free_func == NULL) {\n\t\treturn 0;\n\t}\n\n\tfor (i = 1; i <= 256; i++) {\n\t\tptr = alloc_func(udata, i);\n\t\tif (ptr == NULL) {\n\t\t\tDUK_D(DUK_DPRINT(\"alloc failed, ignore\"));\n\t\t\tcontinue;  /* alloc failed, ignore */\n\t\t}\n\t\tfor (j = 0; j < i; j++) {\n\t\t\t((unsigned char *) ptr)[j] = (unsigned char) (0x80 + j);\n\t\t}\n\t\tnew_ptr = realloc_func(udata, ptr, 1024);\n\t\tif (new_ptr == NULL) {\n\t\t\tDUK_D(DUK_DPRINT(\"realloc failed, ignore\"));\n\t\t\tfree_func(udata, ptr);\n\t\t\tcontinue;  /* realloc failed, ignore */\n\t\t}\n\t\tptr = new_ptr;\n\t\tfor (j = 0; j < i; j++) {\n\t\t\tx = ((unsigned char *) ptr)[j];\n\t\t\tif (x != (unsigned char) (0x80 + j)) {\n\t\t\t\tDUK_D(DUK_DPRINT(\"byte at index %ld doesn't match after realloc: %02lx\",\n\t\t\t\t                 (long) j, (unsigned long) x));\n\t\t\t\tDUK__FAILED(\"byte compare after realloc\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tfree_func(udata, ptr);\n\t}\n\n\treturn error_count;\n}\n\n/*\n *  Self test main\n */\n\nDUK_INTERNAL duk_uint_t duk_selftest_run_tests(duk_alloc_function alloc_func,\n                                               duk_realloc_function realloc_func,\n                                               duk_free_function free_func,\n                                               void *udata) {\n\tduk_uint_t error_count = 0;\n\n\tDUK_D(DUK_DPRINT(\"self test starting\"));\n\n\terror_count += duk__selftest_types();\n\terror_count += duk__selftest_packed_tval();\n\terror_count += duk__selftest_twos_complement();\n\terror_count += duk__selftest_byte_order();\n\terror_count += duk__selftest_bswap_macros();\n\terror_count += duk__selftest_double_union_size();\n\terror_count += duk__selftest_double_aliasing();\n\terror_count += duk__selftest_double_zero_sign();\n\terror_count += duk__selftest_double_rounding();\n\terror_count += duk__selftest_fmod();\n\terror_count += duk__selftest_struct_align();\n\terror_count += duk__selftest_64bit_arithmetic();\n\terror_count += duk__selftest_cast_double_to_small_uint();\n\terror_count += duk__selftest_cast_double_to_uint32();\n\terror_count += duk__selftest_alloc_funcs(alloc_func, realloc_func, free_func, udata);\n\n\tDUK_D(DUK_DPRINT(\"self test complete, total error count: %ld\", (long) error_count));\n\n\treturn error_count;\n}\n\n#endif  /* DUK_USE_SELF_TESTS */\n\n/* automatic undefs */\n#undef DUK__DBLUNION_CMP_FALSE\n#undef DUK__DBLUNION_CMP_TRUE\n#undef DUK__DOUBLE_COMPARE\n#undef DUK__DOUBLE_INIT\n#undef DUK__FAILED\n#undef DUK__U32_INIT\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_FASTINT)\n\n/*\n *  Manually optimized double-to-fastint downgrade check.\n *\n *  This check has a large impact on performance, especially for fastint\n *  slow paths, so must be changed carefully.  The code should probably be\n *  optimized for the case where the result does not fit into a fastint,\n *  to minimize the penalty for \"slow path code\" dealing with fractions etc.\n *\n *  At least on one tested soft float ARM platform double-to-int64 coercion\n *  is very slow (and sometimes produces incorrect results, see self tests).\n *  This algorithm combines a fastint compatibility check and extracting the\n *  integer value from an IEEE double for setting the tagged fastint.  For\n *  other platforms a more naive approach might be better.\n *\n *  See doc/fastint.rst for details.\n */\n\nDUK_INTERNAL DUK_ALWAYS_INLINE void duk_tval_set_number_chkfast_fast(duk_tval *tv, duk_double_t x) {\n\tduk_double_union du;\n\tduk_int64_t i;\n\tduk_small_int_t expt;\n\tduk_small_int_t shift;\n\n\t/* XXX: optimize for packed duk_tval directly? */\n\n\tdu.d = x;\n\ti = (duk_int64_t) DUK_DBLUNION_GET_INT64(&du);\n\texpt = (duk_small_int_t) ((i >> 52) & 0x07ff);\n\tshift = expt - 1023;\n\n\tif (shift >= 0 && shift <= 46) {  /* exponents 1023 to 1069 */\n\t\tduk_int64_t t;\n\n\t\tif (((0x000fffffffffffffLL >> shift) & i) == 0) {\n\t\t\tt = i | 0x0010000000000000LL;  /* implicit leading one */\n\t\t\tt = t & 0x001fffffffffffffLL;\n\t\t\tt = t >> (52 - shift);\n\t\t\tif (i < 0) {\n\t\t\t\tt = -t;\n\t\t\t}\n\t\t\tDUK_TVAL_SET_FASTINT(tv, t);\n\t\t\treturn;\n\t\t}\n\t} else if (shift == -1023) {  /* exponent 0 */\n\t\tif (i >= 0 && (i & 0x000fffffffffffffLL) == 0) {\n\t\t\t/* Note: reject negative zero. */\n\t\t\tDUK_TVAL_SET_FASTINT(tv, (duk_int64_t) 0);\n\t\t\treturn;\n\t\t}\n\t} else if (shift == 47) {  /* exponent 1070 */\n\t\tif (i < 0 && (i & 0x000fffffffffffffLL) == 0) {\n\t\t\tDUK_TVAL_SET_FASTINT(tv, (duk_int64_t) DUK_FASTINT_MIN);\n\t\t\treturn;\n\t\t}\n\t}\n\n\tDUK_TVAL_SET_DOUBLE(tv, x);\n\treturn;\n}\n\nDUK_INTERNAL DUK_NOINLINE void duk_tval_set_number_chkfast_slow(duk_tval *tv, duk_double_t x) {\n\tduk_tval_set_number_chkfast_fast(tv, x);\n}\n\n/*\n *  Manually optimized number-to-double conversion\n */\n\n#if defined(DUK_USE_FASTINT) && defined(DUK_USE_PACKED_TVAL)\nDUK_INTERNAL DUK_ALWAYS_INLINE duk_double_t duk_tval_get_number_packed(duk_tval *tv) {\n\tduk_double_union du;\n\tduk_uint64_t t;\n\n\tt = (duk_uint64_t) DUK_DBLUNION_GET_UINT64(tv);\n\tif ((t >> 48) != DUK_TAG_FASTINT) {\n\t\treturn tv->d;\n\t} else if (t & 0x0000800000000000ULL) {\n\t\tt = (duk_uint64_t) (-((duk_int64_t) t));  /* avoid unary minus on unsigned */\n\t\tt = t & 0x0000ffffffffffffULL;  /* negative */\n\t\tt |= 0xc330000000000000ULL;\n\t\tDUK_DBLUNION_SET_UINT64(&du, t);\n\t\treturn du.d + 4503599627370496.0;  /* 1 << 52 */\n\t} else if (t != 0) {\n\t\tt &= 0x0000ffffffffffffULL;  /* positive */\n\t\tt |= 0x4330000000000000ULL;\n\t\tDUK_DBLUNION_SET_UINT64(&du, t);\n\t\treturn du.d - 4503599627370496.0;  /* 1 << 52 */\n\t} else {\n\t\treturn 0.0;  /* zero */\n\t}\n}\n#endif  /* DUK_USE_FASTINT && DUK_USE_PACKED_TVAL */\n\n#if 0  /* unused */\n#if defined(DUK_USE_FASTINT) && !defined(DUK_USE_PACKED_TVAL)\nDUK_INTERNAL DUK_ALWAYS_INLINE duk_double_t duk_tval_get_number_unpacked(duk_tval *tv) {\n\tduk_double_union du;\n\tduk_uint64_t t;\n\n\tDUK_ASSERT(tv->t == DUK_TAG_NUMBER || tv->t == DUK_TAG_FASTINT);\n\n\tif (tv->t == DUK_TAG_FASTINT) {\n\t\tif (tv->v.fi >= 0) {\n\t\t\tt = 0x4330000000000000ULL | (duk_uint64_t) tv->v.fi;\n\t\t\tDUK_DBLUNION_SET_UINT64(&du, t);\n\t\t\treturn du.d - 4503599627370496.0;  /* 1 << 52 */\n\t\t} else {\n\t\t\tt = 0xc330000000000000ULL | (duk_uint64_t) (-tv->v.fi);\n\t\t\tDUK_DBLUNION_SET_UINT64(&du, t);\n\t\t\treturn du.d + 4503599627370496.0;  /* 1 << 52 */\n\t\t}\n\t} else {\n\t\treturn tv->v.d;\n\t}\n}\n#endif  /* DUK_USE_FASTINT && DUK_USE_PACKED_TVAL */\n#endif  /* 0 */\n\n#if defined(DUK_USE_FASTINT) && !defined(DUK_USE_PACKED_TVAL)\nDUK_INTERNAL DUK_ALWAYS_INLINE duk_double_t duk_tval_get_number_unpacked_fastint(duk_tval *tv) {\n\tduk_double_union du;\n\tduk_uint64_t t;\n\n\tDUK_ASSERT(tv->t == DUK_TAG_FASTINT);\n\n\tif (tv->v.fi >= 0) {\n\t\tt = 0x4330000000000000ULL | (duk_uint64_t) tv->v.fi;\n\t\tDUK_DBLUNION_SET_UINT64(&du, t);\n\t\treturn du.d - 4503599627370496.0;  /* 1 << 52 */\n\t} else {\n\t\tt = 0xc330000000000000ULL | (duk_uint64_t) (-tv->v.fi);\n\t\tDUK_DBLUNION_SET_UINT64(&du, t);\n\t\treturn du.d + 4503599627370496.0;  /* 1 << 52 */\n\t}\n}\n#endif  /* DUK_USE_FASTINT && DUK_USE_PACKED_TVAL */\n\n#endif  /* DUK_USE_FASTINT */\n/*\n *  Unicode support tables automatically generated during build.\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Unicode tables containing ranges of Unicode characters in a\n *  packed format.  These tables are used to match non-ASCII\n *  characters of complex productions by resorting to a linear\n *  range-by-range comparison.  This is very slow, but is expected\n *  to be very rare in practical Ecmascript source code, and thus\n *  compactness is most important.\n *\n *  The tables are matched using uni_range_match() and the format\n *  is described in tools/extract_chars.py.\n */\n\n#if defined(DUK_USE_SOURCE_NONBMP)\n/* IdentifierStart production with ASCII excluded */\n/* duk_unicode_ids_noa[] */\n/*\n *  Automatically generated by extract_chars.py, do not edit!\n */\n\nconst duk_uint8_t duk_unicode_ids_noa[1036] = {\n249,176,176,80,111,7,47,15,47,254,11,197,191,0,72,2,15,115,66,19,50,7,2,34,\n2,240,66,244,50,247,185,249,98,241,99,8,241,127,58,240,182,47,31,241,191,\n21,18,245,50,15,1,24,27,35,15,2,2,240,239,15,244,156,15,10,241,26,21,6,240,\n101,10,4,15,9,240,159,57,240,82,127,56,242,100,15,4,8,159,1,240,5,115,19,\n240,98,98,4,52,15,2,14,18,47,0,31,5,85,19,240,98,98,18,18,31,17,50,15,5,47,\n2,130,34,240,98,98,18,68,15,4,15,1,31,9,12,115,19,240,98,98,18,68,15,16,18,\n47,1,15,3,2,84,34,52,18,2,20,20,36,191,8,15,38,114,34,240,114,240,4,15,12,\n38,31,16,5,114,34,240,114,146,68,15,18,2,31,1,31,4,114,34,241,147,15,2,6,\n41,47,10,86,240,36,240,130,130,3,111,44,242,2,29,111,44,18,3,18,3,7,50,98,\n34,2,3,18,50,26,3,66,15,7,63,18,15,49,114,241,79,13,79,101,241,191,6,15,2,\n85,52,4,24,37,205,15,3,241,98,6,3,241,178,255,224,63,35,54,32,35,63,25,35,\n63,17,35,54,32,35,62,47,41,35,63,51,241,127,0,240,47,70,53,79,254,21,227,\n240,18,240,166,243,180,168,194,63,0,240,47,0,240,47,0,194,47,1,242,79,21,5,\n15,53,244,137,67,241,34,6,243,107,240,255,35,240,227,76,241,197,240,175,40,\n240,122,242,95,68,15,79,241,255,3,111,41,240,238,27,241,207,12,241,79,27,\n43,241,67,143,82,50,52,26,251,15,50,255,224,8,53,63,22,53,55,32,32,32,47,\n15,63,37,38,32,66,38,67,53,92,98,38,246,96,224,240,44,245,112,80,57,32,68,\n112,32,32,35,42,51,100,80,240,63,25,255,233,107,241,242,241,242,247,87,52,\n29,241,98,6,3,242,136,15,2,240,122,98,98,98,98,98,98,98,111,66,15,254,12,\n146,240,184,132,52,95,70,114,47,74,35,111,25,79,78,240,63,11,242,127,0,255,\n224,244,255,240,0,138,143,60,255,240,4,12,143,28,255,227,127,243,95,30,63,\n253,79,0,177,240,111,31,240,47,15,63,64,241,152,63,87,63,20,39,243,26,34,\n35,47,7,240,255,36,240,15,34,243,5,64,32,223,12,191,7,240,191,13,143,31,\n240,224,240,36,41,180,47,25,240,146,39,240,111,7,64,79,34,32,65,52,48,32,\n240,162,58,130,213,53,53,166,38,47,27,41,191,99,240,255,255,0,26,150,223,7,\n95,33,255,240,0,255,143,254,6,3,245,175,24,109,70,2,146,194,66,2,18,18,245,\n207,19,255,224,93,240,79,48,63,38,241,171,246,100,47,119,241,111,10,127,10,\n207,73,69,53,53,50,241,91,47,10,47,3,33,46,61,241,79,107,243,127,37,255,\n223,13,79,33,242,31,16,240,47,11,111,22,191,14,63,20,87,36,241,207,142,240,\n79,20,95,20,95,24,159,36,248,239,254,2,154,240,107,127,138,83,2,241,194,20,\n3,240,123,240,122,240,255,51,240,50,27,240,107,240,175,56,242,135,31,50,15,\n1,50,34,240,191,30,240,212,240,223,21,114,240,207,13,242,107,240,107,240,\n62,240,47,96,243,159,41,242,62,242,63,254,32,79,37,243,223,29,241,47,9,240,\n207,20,241,191,19,64,223,32,240,3,240,112,32,241,95,2,47,9,244,102,32,35,\n46,41,143,31,241,135,49,63,6,38,33,36,64,240,64,212,249,15,37,240,67,242,\n127,32,240,97,32,250,175,31,241,179,241,111,32,240,96,242,223,27,244,127,\n10,255,224,122,243,15,17,15,254,11,79,41,255,152,47,21,240,48,242,63,14,\n255,226,100,255,226,140,245,143,95,240,63,180,255,233,176,255,227,33,255,\n238,197,255,225,57,255,240,1,10,223,254,18,184,240,255,99,240,239,4,242,15,\n2,63,17,240,86,240,63,254,38,79,53,192,243,76,243,32,241,31,255,0,6,223,\n240,95,254,30,95,255,0,20,1,31,254,175,47,91,108,72,137,255,240,0,101,175,\n69,47,55,33,48,49,51,43,32,38,47,49,35,55,38,47,12,35,36,32,70,47,254,4,99,\n240,146,240,146,240,242,240,146,240,242,240,146,240,242,240,146,240,242,\n240,146,127,254,242,143,181,242,223,52,255,227,176,50,240,178,18,3,2,146,\n50,2,7,5,2,2,2,34,18,3,2,2,2,2,2,18,3,50,98,50,50,2,146,240,22,34,66,240,\n31,255,0,0,56,255,240,9,92,159,27,255,239,39,207,206,63,255,0,5,116,255,\n240,1,133,47,254,17,0,\n};\n#else\n/* IdentifierStart production with ASCII and non-BMP excluded */\n/* duk_unicode_ids_noabmp[] */\n/*\n *  Automatically generated by extract_chars.py, do not edit!\n */\n\nconst duk_uint8_t duk_unicode_ids_noabmp[625] = {\n249,176,176,80,111,7,47,15,47,254,11,197,191,0,72,2,15,115,66,19,50,7,2,34,\n2,240,66,244,50,247,185,249,98,241,99,8,241,127,58,240,182,47,31,241,191,\n21,18,245,50,15,1,24,27,35,15,2,2,240,239,15,244,156,15,10,241,26,21,6,240,\n101,10,4,15,9,240,159,57,240,82,127,56,242,100,15,4,8,159,1,240,5,115,19,\n240,98,98,4,52,15,2,14,18,47,0,31,5,85,19,240,98,98,18,18,31,17,50,15,5,47,\n2,130,34,240,98,98,18,68,15,4,15,1,31,9,12,115,19,240,98,98,18,68,15,16,18,\n47,1,15,3,2,84,34,52,18,2,20,20,36,191,8,15,38,114,34,240,114,240,4,15,12,\n38,31,16,5,114,34,240,114,146,68,15,18,2,31,1,31,4,114,34,241,147,15,2,6,\n41,47,10,86,240,36,240,130,130,3,111,44,242,2,29,111,44,18,3,18,3,7,50,98,\n34,2,3,18,50,26,3,66,15,7,63,18,15,49,114,241,79,13,79,101,241,191,6,15,2,\n85,52,4,24,37,205,15,3,241,98,6,3,241,178,255,224,63,35,54,32,35,63,25,35,\n63,17,35,54,32,35,62,47,41,35,63,51,241,127,0,240,47,70,53,79,254,21,227,\n240,18,240,166,243,180,168,194,63,0,240,47,0,240,47,0,194,47,1,242,79,21,5,\n15,53,244,137,67,241,34,6,243,107,240,255,35,240,227,76,241,197,240,175,40,\n240,122,242,95,68,15,79,241,255,3,111,41,240,238,27,241,207,12,241,79,27,\n43,241,67,143,82,50,52,26,251,15,50,255,224,8,53,63,22,53,55,32,32,32,47,\n15,63,37,38,32,66,38,67,53,92,98,38,246,96,224,240,44,245,112,80,57,32,68,\n112,32,32,35,42,51,100,80,240,63,25,255,233,107,241,242,241,242,247,87,52,\n29,241,98,6,3,242,136,15,2,240,122,98,98,98,98,98,98,98,111,66,15,254,12,\n146,240,184,132,52,95,70,114,47,74,35,111,25,79,78,240,63,11,242,127,0,255,\n224,244,255,240,0,138,143,60,255,240,4,12,143,28,255,227,127,243,95,30,63,\n253,79,0,177,240,111,31,240,47,15,63,64,241,152,63,87,63,20,39,243,26,34,\n35,47,7,240,255,36,240,15,34,243,5,64,32,223,12,191,7,240,191,13,143,31,\n240,224,240,36,41,180,47,25,240,146,39,240,111,7,64,79,34,32,65,52,48,32,\n240,162,58,130,213,53,53,166,38,47,27,41,191,99,240,255,255,0,26,150,223,7,\n95,33,255,240,0,255,143,254,6,3,245,175,24,109,70,2,146,194,66,2,18,18,245,\n207,19,255,224,93,240,79,48,63,38,241,171,246,100,47,119,241,111,10,127,10,\n207,73,69,53,53,50,0,\n};\n#endif\n\n#if defined(DUK_USE_SOURCE_NONBMP)\n/* IdentifierStart production with Letter and ASCII excluded */\n/* duk_unicode_ids_m_let_noa[] */\n/*\n *  Automatically generated by extract_chars.py, do not edit!\n */\n\nconst duk_uint8_t duk_unicode_ids_m_let_noa[42] = {\n255,240,0,94,18,255,233,99,241,51,63,254,215,32,240,184,240,2,255,240,6,89,\n249,255,240,4,148,79,37,255,224,192,9,15,120,79,255,0,15,30,245,240,\n};\n#else\n/* IdentifierStart production with Letter, ASCII, and non-BMP excluded */\n/* duk_unicode_ids_m_let_noabmp[] */\n/*\n *  Automatically generated by extract_chars.py, do not edit!\n */\n\nconst duk_uint8_t duk_unicode_ids_m_let_noabmp[24] = {\n255,240,0,94,18,255,233,99,241,51,63,254,215,32,240,184,240,2,255,240,6,89,\n249,0,\n};\n#endif\n\n#if defined(DUK_USE_SOURCE_NONBMP)\n/* IdentifierPart production with IdentifierStart and ASCII excluded */\n/* duk_unicode_idp_m_ids_noa[] */\n/*\n *  Automatically generated by extract_chars.py, do not edit!\n */\n\nconst duk_uint8_t duk_unicode_idp_m_ids_noa[530] = {\n255,225,243,246,15,254,0,116,255,191,29,32,33,33,32,243,170,242,47,15,112,\n245,118,53,49,35,57,240,144,241,15,11,244,218,240,25,241,56,241,67,40,34,\n36,241,210,246,173,47,17,242,130,47,2,38,177,57,240,50,242,160,38,49,50,\n160,177,57,240,50,242,160,36,81,50,64,240,107,64,194,242,160,39,34,34,240,\n97,57,240,50,242,160,38,49,50,145,177,57,240,64,242,212,66,35,160,240,9,\n240,35,242,198,34,35,129,193,57,240,50,242,160,38,34,35,129,193,57,240,50,\n242,198,34,35,160,177,57,240,65,243,128,85,32,39,121,49,242,240,54,215,41,\n244,144,53,33,197,57,243,1,121,192,32,32,81,242,63,4,33,106,47,20,160,245,\n111,4,41,211,82,34,54,67,235,46,255,225,179,47,254,42,98,240,242,240,241,\n241,1,243,47,16,160,57,241,50,57,245,209,241,64,246,139,91,185,247,41,242,\n244,242,185,47,13,58,121,240,141,243,68,242,31,1,201,240,56,210,241,12,57,\n241,237,242,47,4,153,121,246,130,47,5,80,82,65,251,143,38,100,255,225,0,31,\n35,31,5,15,109,197,4,191,254,175,34,247,240,245,47,16,255,225,30,95,91,31,\n255,0,100,121,159,55,5,159,18,31,66,31,254,0,64,64,80,240,148,244,161,242,\n79,2,185,127,2,240,9,240,231,240,188,241,227,242,29,240,25,192,185,242,29,\n208,145,57,241,50,242,64,34,49,97,32,241,180,97,253,231,33,57,255,240,3,\n225,128,255,225,213,240,15,2,240,4,31,10,47,178,159,23,15,254,27,16,253,64,\n248,116,255,224,25,159,254,68,178,33,99,241,162,80,249,113,255,228,13,47,\n39,239,17,159,1,63,31,175,39,151,47,22,210,159,37,13,47,34,218,36,159,68,\n183,15,146,182,151,63,42,2,99,19,42,11,19,100,79,178,240,42,159,72,240,77,\n159,199,99,143,13,31,68,240,31,1,159,67,201,159,69,229,159,254,9,169,255,\n226,57,114,127,2,159,42,240,98,223,255,0,60,157,159,120,79,45,111,11,159,\n254,46,191,30,240,35,255,240,3,191,225,255,240,0,59,164,69,151,54,241,3,\n248,98,255,228,125,242,47,254,15,79,39,95,34,144,240,0,240,132,46,255,228,\n68,98,240,19,98,18,79,254,121,150,245,246,105,255,240,192,105,175,224,0,\n};\n#else\n/* IdentifierPart production with IdentifierStart, ASCII, and non-BMP excluded */\n/* duk_unicode_idp_m_ids_noabmp[] */\n/*\n *  Automatically generated by extract_chars.py, do not edit!\n */\n\nconst duk_uint8_t duk_unicode_idp_m_ids_noabmp[357] = {\n255,225,243,246,15,254,0,116,255,191,29,32,33,33,32,243,170,242,47,15,112,\n245,118,53,49,35,57,240,144,241,15,11,244,218,240,25,241,56,241,67,40,34,\n36,241,210,246,173,47,17,242,130,47,2,38,177,57,240,50,242,160,38,49,50,\n160,177,57,240,50,242,160,36,81,50,64,240,107,64,194,242,160,39,34,34,240,\n97,57,240,50,242,160,38,49,50,145,177,57,240,64,242,212,66,35,160,240,9,\n240,35,242,198,34,35,129,193,57,240,50,242,160,38,34,35,129,193,57,240,50,\n242,198,34,35,160,177,57,240,65,243,128,85,32,39,121,49,242,240,54,215,41,\n244,144,53,33,197,57,243,1,121,192,32,32,81,242,63,4,33,106,47,20,160,245,\n111,4,41,211,82,34,54,67,235,46,255,225,179,47,254,42,98,240,242,240,241,\n241,1,243,47,16,160,57,241,50,57,245,209,241,64,246,139,91,185,247,41,242,\n244,242,185,47,13,58,121,240,141,243,68,242,31,1,201,240,56,210,241,12,57,\n241,237,242,47,4,153,121,246,130,47,5,80,82,65,251,143,38,100,255,225,0,31,\n35,31,5,15,109,197,4,191,254,175,34,247,240,245,47,16,255,225,30,95,91,31,\n255,0,100,121,159,55,5,159,18,31,66,31,254,0,64,64,80,240,148,244,161,242,\n79,2,185,127,2,240,9,240,231,240,188,241,227,242,29,240,25,192,185,242,29,\n208,145,57,241,50,242,64,34,49,97,32,241,180,97,253,231,33,57,255,240,3,\n225,128,255,225,213,240,15,2,240,4,31,10,47,178,159,23,0,\n};\n#endif\n\n/*\n *  Case conversion tables generated using tools/extract_caseconv.py.\n */\n\n/* duk_unicode_caseconv_uc[] */\n/* duk_unicode_caseconv_lc[] */\n\n/*\n *  Automatically generated by extract_caseconv.py, do not edit!\n */\n\nconst duk_uint8_t duk_unicode_caseconv_uc[1386] = {\n144,3,128,3,0,184,7,192,6,192,112,35,242,199,224,64,74,192,49,32,128,162,\n128,108,65,1,189,129,254,131,3,173,3,136,6,7,98,7,34,68,15,12,14,140,72,30,\n104,28,112,32,67,0,65,4,0,138,0,128,4,1,88,65,76,83,9,252,9,248,6,28,131,4,\n33,4,62,0,62,16,32,124,64,124,96,48,249,0,249,64,129,243,1,243,129,3,232,3,\n233,1,135,216,7,218,4,15,184,15,221,2,31,114,31,200,8,62,236,63,180,8,125,\n224,127,224,16,251,208,255,80,33,247,193,255,160,67,246,3,247,0,135,244,7,\n246,1,15,240,15,244,2,33,112,33,96,32,73,160,73,108,104,176,192,176,1,121,\n104,0,133,2,106,183,1,58,10,31,232,63,228,38,162,1,1,1,0,48,2,102,2,100,12,\n4,232,4,228,64,10,88,10,81,112,23,160,23,144,96,48,96,48,64,128,104,64,104,\n1,128,218,0,217,130,1,206,1,205,16,3,190,3,188,36,7,228,7,224,160,17,24,17,\n16,144,36,112,36,96,160,110,32,110,0,128,246,64,246,6,2,48,130,48,17,4,139,\n4,138,54,9,132,9,130,28,19,68,19,65,128,240,8,240,4,177,234,17,234,6,3,234,\n35,235,33,11,26,11,25,193,150,64,150,64,50,44,236,44,235,5,76,131,76,128,\n94,154,6,154,0,117,57,29,57,16,122,115,58,115,35,244,239,84,239,32,169,223,\n233,223,130,211,200,211,200,2,167,151,167,150,21,79,107,79,104,8,112,26,\n208,26,192,64,56,160,56,128,192,113,128,113,1,128,249,0,248,130,2,128,1,\n166,4,7,240,7,238,8,177,204,177,200,16,96,49,0,48,224,128,110,64,110,1,1,\n51,83,213,2,0,48,35,192,35,176,64,77,32,50,192,139,73,196,49,193,127,48,2,\n212,14,112,3,252,5,224,4,196,1,36,5,252,1,76,6,0,9,12,6,72,6,68,6,84,7,216,\n6,100,6,96,6,104,8,244,6,120,8,128,6,160,6,156,6,252,7,220,7,116,6,56,7,\n204,7,196,9,64,177,188,9,68,177,180,9,72,177,192,9,76,6,4,9,80,6,24,9,100,\n6,60,9,108,6,64,9,114,158,172,9,128,6,76,9,134,158,176,9,140,6,80,9,150,\n158,52,9,160,6,92,9,172,177,136,9,178,158,180,9,196,177,184,9,200,6,116,9,\n212,6,124,9,244,177,144,10,30,158,196,10,32,6,184,10,36,9,16,10,48,9,20,10,\n72,6,220,10,118,158,200,10,122,158,192,13,20,14,100,13,220,13,216,14,176,\n14,24,15,8,14,140,15,48,14,48,15,64,14,72,15,68,14,96,15,84,14,152,15,88,\n14,128,15,92,15,60,15,192,14,104,15,196,14,132,15,200,15,228,15,204,13,252,\n15,212,14,84,19,60,19,0,114,0,16,72,114,4,16,80,114,8,16,120,114,20,16,136,\n114,24,16,168,114,28,17,136,114,34,153,40,117,230,157,244,117,244,177,140,\n122,108,121,128,126,248,14,100,127,148,127,176,133,56,132,200,134,16,134,\n12,177,132,177,128,177,148,8,232,177,152,8,248,179,204,179,202,158,50,158,\n46,173,78,158,207,48,6,252,0,166,0,166,2,147,1,94,0,39,0,248,64,9,64,97,\n128,114,24,28,200,24,64,24,8,29,134,7,74,6,16,6,2,11,15,2,154,130,169,15,\n75,64,9,0,102,35,210,240,2,160,24,64,244,196,0,174,6,20,61,51,0,44,129,133,\n15,77,64,8,32,87,195,234,16,29,40,24,152,250,150,7,74,6,38,6,0,62,169,129,\n210,129,137,129,128,143,171,96,116,160,98,96,104,67,240,16,248,64,28,200,\n252,12,62,18,7,50,63,5,15,133,1,204,143,193,195,225,96,115,35,240,144,248,\n96,28,200,252,44,62,26,7,50,63,13,15,135,1,204,143,195,195,225,224,115,35,\n241,16,248,64,28,200,252,76,62,18,7,50,63,21,15,133,1,204,143,197,195,225,\n96,115,35,241,144,248,96,28,200,252,108,62,26,7,50,63,29,15,135,1,204,143,\n199,195,225,224,115,35,242,16,249,64,28,200,252,140,62,82,7,50,63,37,15,\n149,1,204,143,201,195,229,96,115,35,242,144,249,96,28,200,252,172,62,90,7,\n50,63,45,15,151,1,204,143,203,195,229,224,115,35,243,16,249,64,28,200,252,\n204,62,82,7,50,63,53,15,149,1,204,143,205,195,229,96,115,35,243,144,249,96,\n28,200,252,236,62,90,7,50,63,61,15,151,1,204,143,207,195,229,224,115,35,\n244,16,251,64,28,200,253,12,62,210,7,50,63,69,15,181,1,204,143,209,195,237,\n96,115,35,244,144,251,96,28,200,253,44,62,218,7,50,63,77,15,183,1,204,143,\n211,195,237,224,115,35,245,16,251,64,28,200,253,76,62,210,7,50,63,85,15,\n181,1,204,143,213,195,237,96,115,35,245,144,251,96,28,200,253,108,62,218,7,\n50,63,93,15,183,1,204,143,215,195,237,224,115,35,246,80,253,208,28,200,253,\n156,7,34,7,50,63,105,1,195,1,204,143,219,64,114,32,104,67,246,248,28,136,\n26,16,28,200,253,228,7,34,7,50,63,133,15,229,1,204,143,225,192,114,224,115,\n35,248,144,28,72,28,200,254,52,7,46,6,132,63,143,129,203,129,161,1,204,143,\n230,64,114,224,115,35,250,88,28,200,24,64,24,0,254,158,7,50,6,16,6,2,63,\n173,1,204,129,161,15,235,224,115,32,97,0,104,67,252,88,29,40,24,64,24,0,\n255,30,7,74,6,16,6,2,63,201,1,208,129,137,143,243,64,116,160,104,67,252,\n248,29,40,24,64,26,16,255,148,63,244,7,50,63,231,1,212,129,204,143,250,64,\n113,224,115,35,254,208,29,72,26,16,255,190,7,82,6,132,7,50,63,249,1,212,\n129,204,253,128,64,8,192,8,223,96,48,2,48,2,79,216,20,0,140,0,153,246,7,\n128,35,0,35,0,36,253,130,96,8,192,8,192,9,159,96,176,2,152,2,167,216,52,0,\n166,0,169,246,39,2,162,2,163,125,138,64,168,128,166,191,98,176,42,32,41,\n223,216,180,10,156,10,141,246,47,2,162,2,158,128,\n};\nconst duk_uint8_t duk_unicode_caseconv_lc[680] = {\n152,3,0,3,128,184,6,192,7,192,112,24,144,37,96,64,54,32,81,64,128,226,0,\n235,65,129,199,1,230,130,3,145,3,177,34,7,70,7,134,36,15,244,13,236,24,32,\n0,34,129,0,65,0,67,4,0,166,32,172,41,132,40,11,64,19,9,208,85,184,80,19,\n240,19,248,12,62,16,62,0,32,124,96,124,64,48,249,64,249,0,129,243,129,243,\n1,3,233,3,232,1,135,218,7,216,4,15,196,15,192,8,31,152,31,144,16,63,80,63,\n64,32,126,224,126,192,16,253,208,251,128,33,252,129,247,32,131,251,3,250,0,\n135,246,135,221,129,15,244,15,240,2,31,234,31,122,4,63,240,62,240,8,127,\n232,125,240,17,11,1,11,129,2,75,98,77,3,69,128,5,134,11,203,31,128,143,193,\n127,144,255,160,154,140,4,0,4,4,192,9,144,9,152,48,19,144,19,161,0,41,64,\n41,101,192,94,64,94,129,128,193,0,193,130,1,160,1,161,6,3,102,3,104,8,7,44,\n7,48,72,14,240,14,248,144,31,32,31,48,64,63,0,63,37,0,136,128,136,196,129,\n35,1,35,133,3,112,3,113,4,7,176,7,178,48,17,128,17,132,136,36,80,36,89,176,\n76,16,76,32,224,154,0,154,44,7,128,7,128,101,143,80,15,80,176,31,89,31,81,\n8,88,206,88,208,12,178,0,178,5,145,103,89,103,96,42,100,10,100,18,244,208,\n20,208,35,169,200,169,200,195,211,153,83,153,159,167,121,167,122,5,78,253,\n78,254,22,158,66,158,68,21,60,181,60,184,170,123,74,123,80,67,0,211,1,64,2,\n1,172,1,173,4,3,136,3,140,12,7,20,7,24,16,31,184,31,192,34,199,34,199,48,\n65,128,195,128,196,2,1,184,1,185,5,79,84,4,204,8,0,192,101,128,154,65,1,29,\n129,30,2,16,199,45,39,5,251,240,23,128,15,240,24,16,37,48,24,96,37,64,24,\n224,29,208,24,240,37,144,25,0,37,176,25,16,25,32,25,48,38,0,25,64,38,48,25,\n112,38,128,25,128,25,144,25,208,39,32,25,240,39,80,26,112,26,128,26,224,40,\n128,27,112,41,32,31,16,31,48,31,96,25,80,31,112,27,240,34,0,25,224,35,162,\n198,80,35,208,25,160,35,226,198,96,36,48,24,0,36,64,40,144,36,80,40,192,55,\n96,55,112,55,240,63,48,56,96,58,192,56,192,60,192,60,240,61,112,63,64,59,\n128,63,144,63,32,76,0,76,241,233,224,13,241,251,193,251,49,252,193,252,49,\n254,193,254,81,255,193,255,50,18,96,60,146,18,160,6,178,18,176,14,82,19,34,\n20,226,24,50,24,66,198,2,198,18,198,32,38,178,198,49,215,210,198,64,39,210,\n198,208,37,18,198,224,39,18,198,240,37,2,199,0,37,34,207,34,207,58,119,209,\n215,154,120,186,120,202,120,208,38,90,122,176,37,202,122,192,38,26,122,208,\n38,202,123,0,41,234,123,16,40,122,123,32,41,218,123,58,181,48,32,38,16,3,\n72,24,56,\n};\n\n#if defined(DUK_USE_REGEXP_CANON_WORKAROUND)\n/*\n *  Automatically generated by extract_caseconv.py, do not edit!\n */\n\nconst duk_uint16_t duk_unicode_re_canon_lookup[65536] = {\n0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,\n28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,\n53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,\n78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,65,66,67,68,69,70,\n71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,123,124,125,\n126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,\n144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,\n162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,\n180,924,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,\n198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,\n216,217,218,219,220,221,222,223,192,193,194,195,196,197,198,199,200,201,\n202,203,204,205,206,207,208,209,210,211,212,213,214,247,216,217,218,219,\n220,221,222,376,256,256,258,258,260,260,262,262,264,264,266,266,268,268,\n270,270,272,272,274,274,276,276,278,278,280,280,282,282,284,284,286,286,\n288,288,290,290,292,292,294,294,296,296,298,298,300,300,302,302,304,305,\n306,306,308,308,310,310,312,313,313,315,315,317,317,319,319,321,321,323,\n323,325,325,327,327,329,330,330,332,332,334,334,336,336,338,338,340,340,\n342,342,344,344,346,346,348,348,350,350,352,352,354,354,356,356,358,358,\n360,360,362,362,364,364,366,366,368,368,370,370,372,372,374,374,376,377,\n377,379,379,381,381,383,579,385,386,386,388,388,390,391,391,393,394,395,\n395,397,398,399,400,401,401,403,404,502,406,407,408,408,573,411,412,413,\n544,415,416,416,418,418,420,420,422,423,423,425,426,427,428,428,430,431,\n431,433,434,435,435,437,437,439,440,440,442,443,444,444,446,503,448,449,\n450,451,452,452,452,455,455,455,458,458,458,461,461,463,463,465,465,467,\n467,469,469,471,471,473,473,475,475,398,478,478,480,480,482,482,484,484,\n486,486,488,488,490,490,492,492,494,494,496,497,497,497,500,500,502,503,\n504,504,506,506,508,508,510,510,512,512,514,514,516,516,518,518,520,520,\n522,522,524,524,526,526,528,528,530,530,532,532,534,534,536,536,538,538,\n540,540,542,542,544,545,546,546,548,548,550,550,552,552,554,554,556,556,\n558,558,560,560,562,562,564,565,566,567,568,569,570,571,571,573,574,11390,\n11391,577,577,579,580,581,582,582,584,584,586,586,588,588,590,590,11375,\n11373,11376,385,390,597,393,394,600,399,602,400,42923L,605,606,607,403,\n42924L,610,404,612,42893L,42922L,615,407,406,42926L,11362,42925L,621,622,\n412,624,11374,413,627,628,415,630,631,632,633,634,635,636,11364,638,639,\n422,641,642,425,644,645,646,42929L,430,580,433,434,581,653,654,655,656,657,\n439,659,660,661,662,663,664,665,666,667,668,42930L,42928L,671,672,673,674,\n675,676,677,678,679,680,681,682,683,684,685,686,687,688,689,690,691,692,\n693,694,695,696,697,698,699,700,701,702,703,704,705,706,707,708,709,710,\n711,712,713,714,715,716,717,718,719,720,721,722,723,724,725,726,727,728,\n729,730,731,732,733,734,735,736,737,738,739,740,741,742,743,744,745,746,\n747,748,749,750,751,752,753,754,755,756,757,758,759,760,761,762,763,764,\n765,766,767,768,769,770,771,772,773,774,775,776,777,778,779,780,781,782,\n783,784,785,786,787,788,789,790,791,792,793,794,795,796,797,798,799,800,\n801,802,803,804,805,806,807,808,809,810,811,812,813,814,815,816,817,818,\n819,820,821,822,823,824,825,826,827,828,829,830,831,832,833,834,835,836,\n921,838,839,840,841,842,843,844,845,846,847,848,849,850,851,852,853,854,\n855,856,857,858,859,860,861,862,863,864,865,866,867,868,869,870,871,872,\n873,874,875,876,877,878,879,880,880,882,882,884,885,886,886,888,889,890,\n1021,1022,1023,894,895,896,897,898,899,900,901,902,903,904,905,906,907,908,\n909,910,911,912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,\n927,928,929,930,931,932,933,934,935,936,937,938,939,902,904,905,906,944,\n913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,931,\n931,932,933,934,935,936,937,938,939,908,910,911,975,914,920,978,979,980,\n934,928,975,984,984,986,986,988,988,990,990,992,992,994,994,996,996,998,\n998,1000,1000,1002,1002,1004,1004,1006,1006,922,929,1017,895,1012,917,1014,\n1015,1015,1017,1018,1018,1020,1021,1022,1023,1024,1025,1026,1027,1028,1029,\n1030,1031,1032,1033,1034,1035,1036,1037,1038,1039,1040,1041,1042,1043,1044,\n1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,\n1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1040,1041,1042,\n1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,\n1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1024,\n1025,1026,1027,1028,1029,1030,1031,1032,1033,1034,1035,1036,1037,1038,1039,\n1120,1120,1122,1122,1124,1124,1126,1126,1128,1128,1130,1130,1132,1132,1134,\n1134,1136,1136,1138,1138,1140,1140,1142,1142,1144,1144,1146,1146,1148,1148,\n1150,1150,1152,1152,1154,1155,1156,1157,1158,1159,1160,1161,1162,1162,1164,\n1164,1166,1166,1168,1168,1170,1170,1172,1172,1174,1174,1176,1176,1178,1178,\n1180,1180,1182,1182,1184,1184,1186,1186,1188,1188,1190,1190,1192,1192,1194,\n1194,1196,1196,1198,1198,1200,1200,1202,1202,1204,1204,1206,1206,1208,1208,\n1210,1210,1212,1212,1214,1214,1216,1217,1217,1219,1219,1221,1221,1223,1223,\n1225,1225,1227,1227,1229,1229,1216,1232,1232,1234,1234,1236,1236,1238,1238,\n1240,1240,1242,1242,1244,1244,1246,1246,1248,1248,1250,1250,1252,1252,1254,\n1254,1256,1256,1258,1258,1260,1260,1262,1262,1264,1264,1266,1266,1268,1268,\n1270,1270,1272,1272,1274,1274,1276,1276,1278,1278,1280,1280,1282,1282,1284,\n1284,1286,1286,1288,1288,1290,1290,1292,1292,1294,1294,1296,1296,1298,1298,\n1300,1300,1302,1302,1304,1304,1306,1306,1308,1308,1310,1310,1312,1312,1314,\n1314,1316,1316,1318,1318,1320,1320,1322,1322,1324,1324,1326,1326,1328,1329,\n1330,1331,1332,1333,1334,1335,1336,1337,1338,1339,1340,1341,1342,1343,1344,\n1345,1346,1347,1348,1349,1350,1351,1352,1353,1354,1355,1356,1357,1358,1359,\n1360,1361,1362,1363,1364,1365,1366,1367,1368,1369,1370,1371,1372,1373,1374,\n1375,1376,1329,1330,1331,1332,1333,1334,1335,1336,1337,1338,1339,1340,1341,\n1342,1343,1344,1345,1346,1347,1348,1349,1350,1351,1352,1353,1354,1355,1356,\n1357,1358,1359,1360,1361,1362,1363,1364,1365,1366,1415,1416,1417,1418,1419,\n1420,1421,1422,1423,1424,1425,1426,1427,1428,1429,1430,1431,1432,1433,1434,\n1435,1436,1437,1438,1439,1440,1441,1442,1443,1444,1445,1446,1447,1448,1449,\n1450,1451,1452,1453,1454,1455,1456,1457,1458,1459,1460,1461,1462,1463,1464,\n1465,1466,1467,1468,1469,1470,1471,1472,1473,1474,1475,1476,1477,1478,1479,\n1480,1481,1482,1483,1484,1485,1486,1487,1488,1489,1490,1491,1492,1493,1494,\n1495,1496,1497,1498,1499,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,\n1510,1511,1512,1513,1514,1515,1516,1517,1518,1519,1520,1521,1522,1523,1524,\n1525,1526,1527,1528,1529,1530,1531,1532,1533,1534,1535,1536,1537,1538,1539,\n1540,1541,1542,1543,1544,1545,1546,1547,1548,1549,1550,1551,1552,1553,1554,\n1555,1556,1557,1558,1559,1560,1561,1562,1563,1564,1565,1566,1567,1568,1569,\n1570,1571,1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,1584,\n1585,1586,1587,1588,1589,1590,1591,1592,1593,1594,1595,1596,1597,1598,1599,\n1600,1601,1602,1603,1604,1605,1606,1607,1608,1609,1610,1611,1612,1613,1614,\n1615,1616,1617,1618,1619,1620,1621,1622,1623,1624,1625,1626,1627,1628,1629,\n1630,1631,1632,1633,1634,1635,1636,1637,1638,1639,1640,1641,1642,1643,1644,\n1645,1646,1647,1648,1649,1650,1651,1652,1653,1654,1655,1656,1657,1658,1659,\n1660,1661,1662,1663,1664,1665,1666,1667,1668,1669,1670,1671,1672,1673,1674,\n1675,1676,1677,1678,1679,1680,1681,1682,1683,1684,1685,1686,1687,1688,1689,\n1690,1691,1692,1693,1694,1695,1696,1697,1698,1699,1700,1701,1702,1703,1704,\n1705,1706,1707,1708,1709,1710,1711,1712,1713,1714,1715,1716,1717,1718,1719,\n1720,1721,1722,1723,1724,1725,1726,1727,1728,1729,1730,1731,1732,1733,1734,\n1735,1736,1737,1738,1739,1740,1741,1742,1743,1744,1745,1746,1747,1748,1749,\n1750,1751,1752,1753,1754,1755,1756,1757,1758,1759,1760,1761,1762,1763,1764,\n1765,1766,1767,1768,1769,1770,1771,1772,1773,1774,1775,1776,1777,1778,1779,\n1780,1781,1782,1783,1784,1785,1786,1787,1788,1789,1790,1791,1792,1793,1794,\n1795,1796,1797,1798,1799,1800,1801,1802,1803,1804,1805,1806,1807,1808,1809,\n1810,1811,1812,1813,1814,1815,1816,1817,1818,1819,1820,1821,1822,1823,1824,\n1825,1826,1827,1828,1829,1830,1831,1832,1833,1834,1835,1836,1837,1838,1839,\n1840,1841,1842,1843,1844,1845,1846,1847,1848,1849,1850,1851,1852,1853,1854,\n1855,1856,1857,1858,1859,1860,1861,1862,1863,1864,1865,1866,1867,1868,1869,\n1870,1871,1872,1873,1874,1875,1876,1877,1878,1879,1880,1881,1882,1883,1884,\n1885,1886,1887,1888,1889,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,\n1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,1914,\n1915,1916,1917,1918,1919,1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,\n1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,\n1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1958,1959,\n1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,\n1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,\n1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,\n2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,\n2020,2021,2022,2023,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,2034,\n2035,2036,2037,2038,2039,2040,2041,2042,2043,2044,2045,2046,2047,2048,2049,\n2050,2051,2052,2053,2054,2055,2056,2057,2058,2059,2060,2061,2062,2063,2064,\n2065,2066,2067,2068,2069,2070,2071,2072,2073,2074,2075,2076,2077,2078,2079,\n2080,2081,2082,2083,2084,2085,2086,2087,2088,2089,2090,2091,2092,2093,2094,\n2095,2096,2097,2098,2099,2100,2101,2102,2103,2104,2105,2106,2107,2108,2109,\n2110,2111,2112,2113,2114,2115,2116,2117,2118,2119,2120,2121,2122,2123,2124,\n2125,2126,2127,2128,2129,2130,2131,2132,2133,2134,2135,2136,2137,2138,2139,\n2140,2141,2142,2143,2144,2145,2146,2147,2148,2149,2150,2151,2152,2153,2154,\n2155,2156,2157,2158,2159,2160,2161,2162,2163,2164,2165,2166,2167,2168,2169,\n2170,2171,2172,2173,2174,2175,2176,2177,2178,2179,2180,2181,2182,2183,2184,\n2185,2186,2187,2188,2189,2190,2191,2192,2193,2194,2195,2196,2197,2198,2199,\n2200,2201,2202,2203,2204,2205,2206,2207,2208,2209,2210,2211,2212,2213,2214,\n2215,2216,2217,2218,2219,2220,2221,2222,2223,2224,2225,2226,2227,2228,2229,\n2230,2231,2232,2233,2234,2235,2236,2237,2238,2239,2240,2241,2242,2243,2244,\n2245,2246,2247,2248,2249,2250,2251,2252,2253,2254,2255,2256,2257,2258,2259,\n2260,2261,2262,2263,2264,2265,2266,2267,2268,2269,2270,2271,2272,2273,2274,\n2275,2276,2277,2278,2279,2280,2281,2282,2283,2284,2285,2286,2287,2288,2289,\n2290,2291,2292,2293,2294,2295,2296,2297,2298,2299,2300,2301,2302,2303,2304,\n2305,2306,2307,2308,2309,2310,2311,2312,2313,2314,2315,2316,2317,2318,2319,\n2320,2321,2322,2323,2324,2325,2326,2327,2328,2329,2330,2331,2332,2333,2334,\n2335,2336,2337,2338,2339,2340,2341,2342,2343,2344,2345,2346,2347,2348,2349,\n2350,2351,2352,2353,2354,2355,2356,2357,2358,2359,2360,2361,2362,2363,2364,\n2365,2366,2367,2368,2369,2370,2371,2372,2373,2374,2375,2376,2377,2378,2379,\n2380,2381,2382,2383,2384,2385,2386,2387,2388,2389,2390,2391,2392,2393,2394,\n2395,2396,2397,2398,2399,2400,2401,2402,2403,2404,2405,2406,2407,2408,2409,\n2410,2411,2412,2413,2414,2415,2416,2417,2418,2419,2420,2421,2422,2423,2424,\n2425,2426,2427,2428,2429,2430,2431,2432,2433,2434,2435,2436,2437,2438,2439,\n2440,2441,2442,2443,2444,2445,2446,2447,2448,2449,2450,2451,2452,2453,2454,\n2455,2456,2457,2458,2459,2460,2461,2462,2463,2464,2465,2466,2467,2468,2469,\n2470,2471,2472,2473,2474,2475,2476,2477,2478,2479,2480,2481,2482,2483,2484,\n2485,2486,2487,2488,2489,2490,2491,2492,2493,2494,2495,2496,2497,2498,2499,\n2500,2501,2502,2503,2504,2505,2506,2507,2508,2509,2510,2511,2512,2513,2514,\n2515,2516,2517,2518,2519,2520,2521,2522,2523,2524,2525,2526,2527,2528,2529,\n2530,2531,2532,2533,2534,2535,2536,2537,2538,2539,2540,2541,2542,2543,2544,\n2545,2546,2547,2548,2549,2550,2551,2552,2553,2554,2555,2556,2557,2558,2559,\n2560,2561,2562,2563,2564,2565,2566,2567,2568,2569,2570,2571,2572,2573,2574,\n2575,2576,2577,2578,2579,2580,2581,2582,2583,2584,2585,2586,2587,2588,2589,\n2590,2591,2592,2593,2594,2595,2596,2597,2598,2599,2600,2601,2602,2603,2604,\n2605,2606,2607,2608,2609,2610,2611,2612,2613,2614,2615,2616,2617,2618,2619,\n2620,2621,2622,2623,2624,2625,2626,2627,2628,2629,2630,2631,2632,2633,2634,\n2635,2636,2637,2638,2639,2640,2641,2642,2643,2644,2645,2646,2647,2648,2649,\n2650,2651,2652,2653,2654,2655,2656,2657,2658,2659,2660,2661,2662,2663,2664,\n2665,2666,2667,2668,2669,2670,2671,2672,2673,2674,2675,2676,2677,2678,2679,\n2680,2681,2682,2683,2684,2685,2686,2687,2688,2689,2690,2691,2692,2693,2694,\n2695,2696,2697,2698,2699,2700,2701,2702,2703,2704,2705,2706,2707,2708,2709,\n2710,2711,2712,2713,2714,2715,2716,2717,2718,2719,2720,2721,2722,2723,2724,\n2725,2726,2727,2728,2729,2730,2731,2732,2733,2734,2735,2736,2737,2738,2739,\n2740,2741,2742,2743,2744,2745,2746,2747,2748,2749,2750,2751,2752,2753,2754,\n2755,2756,2757,2758,2759,2760,2761,2762,2763,2764,2765,2766,2767,2768,2769,\n2770,2771,2772,2773,2774,2775,2776,2777,2778,2779,2780,2781,2782,2783,2784,\n2785,2786,2787,2788,2789,2790,2791,2792,2793,2794,2795,2796,2797,2798,2799,\n2800,2801,2802,2803,2804,2805,2806,2807,2808,2809,2810,2811,2812,2813,2814,\n2815,2816,2817,2818,2819,2820,2821,2822,2823,2824,2825,2826,2827,2828,2829,\n2830,2831,2832,2833,2834,2835,2836,2837,2838,2839,2840,2841,2842,2843,2844,\n2845,2846,2847,2848,2849,2850,2851,2852,2853,2854,2855,2856,2857,2858,2859,\n2860,2861,2862,2863,2864,2865,2866,2867,2868,2869,2870,2871,2872,2873,2874,\n2875,2876,2877,2878,2879,2880,2881,2882,2883,2884,2885,2886,2887,2888,2889,\n2890,2891,2892,2893,2894,2895,2896,2897,2898,2899,2900,2901,2902,2903,2904,\n2905,2906,2907,2908,2909,2910,2911,2912,2913,2914,2915,2916,2917,2918,2919,\n2920,2921,2922,2923,2924,2925,2926,2927,2928,2929,2930,2931,2932,2933,2934,\n2935,2936,2937,2938,2939,2940,2941,2942,2943,2944,2945,2946,2947,2948,2949,\n2950,2951,2952,2953,2954,2955,2956,2957,2958,2959,2960,2961,2962,2963,2964,\n2965,2966,2967,2968,2969,2970,2971,2972,2973,2974,2975,2976,2977,2978,2979,\n2980,2981,2982,2983,2984,2985,2986,2987,2988,2989,2990,2991,2992,2993,2994,\n2995,2996,2997,2998,2999,3000,3001,3002,3003,3004,3005,3006,3007,3008,3009,\n3010,3011,3012,3013,3014,3015,3016,3017,3018,3019,3020,3021,3022,3023,3024,\n3025,3026,3027,3028,3029,3030,3031,3032,3033,3034,3035,3036,3037,3038,3039,\n3040,3041,3042,3043,3044,3045,3046,3047,3048,3049,3050,3051,3052,3053,3054,\n3055,3056,3057,3058,3059,3060,3061,3062,3063,3064,3065,3066,3067,3068,3069,\n3070,3071,3072,3073,3074,3075,3076,3077,3078,3079,3080,3081,3082,3083,3084,\n3085,3086,3087,3088,3089,3090,3091,3092,3093,3094,3095,3096,3097,3098,3099,\n3100,3101,3102,3103,3104,3105,3106,3107,3108,3109,3110,3111,3112,3113,3114,\n3115,3116,3117,3118,3119,3120,3121,3122,3123,3124,3125,3126,3127,3128,3129,\n3130,3131,3132,3133,3134,3135,3136,3137,3138,3139,3140,3141,3142,3143,3144,\n3145,3146,3147,3148,3149,3150,3151,3152,3153,3154,3155,3156,3157,3158,3159,\n3160,3161,3162,3163,3164,3165,3166,3167,3168,3169,3170,3171,3172,3173,3174,\n3175,3176,3177,3178,3179,3180,3181,3182,3183,3184,3185,3186,3187,3188,3189,\n3190,3191,3192,3193,3194,3195,3196,3197,3198,3199,3200,3201,3202,3203,3204,\n3205,3206,3207,3208,3209,3210,3211,3212,3213,3214,3215,3216,3217,3218,3219,\n3220,3221,3222,3223,3224,3225,3226,3227,3228,3229,3230,3231,3232,3233,3234,\n3235,3236,3237,3238,3239,3240,3241,3242,3243,3244,3245,3246,3247,3248,3249,\n3250,3251,3252,3253,3254,3255,3256,3257,3258,3259,3260,3261,3262,3263,3264,\n3265,3266,3267,3268,3269,3270,3271,3272,3273,3274,3275,3276,3277,3278,3279,\n3280,3281,3282,3283,3284,3285,3286,3287,3288,3289,3290,3291,3292,3293,3294,\n3295,3296,3297,3298,3299,3300,3301,3302,3303,3304,3305,3306,3307,3308,3309,\n3310,3311,3312,3313,3314,3315,3316,3317,3318,3319,3320,3321,3322,3323,3324,\n3325,3326,3327,3328,3329,3330,3331,3332,3333,3334,3335,3336,3337,3338,3339,\n3340,3341,3342,3343,3344,3345,3346,3347,3348,3349,3350,3351,3352,3353,3354,\n3355,3356,3357,3358,3359,3360,3361,3362,3363,3364,3365,3366,3367,3368,3369,\n3370,3371,3372,3373,3374,3375,3376,3377,3378,3379,3380,3381,3382,3383,3384,\n3385,3386,3387,3388,3389,3390,3391,3392,3393,3394,3395,3396,3397,3398,3399,\n3400,3401,3402,3403,3404,3405,3406,3407,3408,3409,3410,3411,3412,3413,3414,\n3415,3416,3417,3418,3419,3420,3421,3422,3423,3424,3425,3426,3427,3428,3429,\n3430,3431,3432,3433,3434,3435,3436,3437,3438,3439,3440,3441,3442,3443,3444,\n3445,3446,3447,3448,3449,3450,3451,3452,3453,3454,3455,3456,3457,3458,3459,\n3460,3461,3462,3463,3464,3465,3466,3467,3468,3469,3470,3471,3472,3473,3474,\n3475,3476,3477,3478,3479,3480,3481,3482,3483,3484,3485,3486,3487,3488,3489,\n3490,3491,3492,3493,3494,3495,3496,3497,3498,3499,3500,3501,3502,3503,3504,\n3505,3506,3507,3508,3509,3510,3511,3512,3513,3514,3515,3516,3517,3518,3519,\n3520,3521,3522,3523,3524,3525,3526,3527,3528,3529,3530,3531,3532,3533,3534,\n3535,3536,3537,3538,3539,3540,3541,3542,3543,3544,3545,3546,3547,3548,3549,\n3550,3551,3552,3553,3554,3555,3556,3557,3558,3559,3560,3561,3562,3563,3564,\n3565,3566,3567,3568,3569,3570,3571,3572,3573,3574,3575,3576,3577,3578,3579,\n3580,3581,3582,3583,3584,3585,3586,3587,3588,3589,3590,3591,3592,3593,3594,\n3595,3596,3597,3598,3599,3600,3601,3602,3603,3604,3605,3606,3607,3608,3609,\n3610,3611,3612,3613,3614,3615,3616,3617,3618,3619,3620,3621,3622,3623,3624,\n3625,3626,3627,3628,3629,3630,3631,3632,3633,3634,3635,3636,3637,3638,3639,\n3640,3641,3642,3643,3644,3645,3646,3647,3648,3649,3650,3651,3652,3653,3654,\n3655,3656,3657,3658,3659,3660,3661,3662,3663,3664,3665,3666,3667,3668,3669,\n3670,3671,3672,3673,3674,3675,3676,3677,3678,3679,3680,3681,3682,3683,3684,\n3685,3686,3687,3688,3689,3690,3691,3692,3693,3694,3695,3696,3697,3698,3699,\n3700,3701,3702,3703,3704,3705,3706,3707,3708,3709,3710,3711,3712,3713,3714,\n3715,3716,3717,3718,3719,3720,3721,3722,3723,3724,3725,3726,3727,3728,3729,\n3730,3731,3732,3733,3734,3735,3736,3737,3738,3739,3740,3741,3742,3743,3744,\n3745,3746,3747,3748,3749,3750,3751,3752,3753,3754,3755,3756,3757,3758,3759,\n3760,3761,3762,3763,3764,3765,3766,3767,3768,3769,3770,3771,3772,3773,3774,\n3775,3776,3777,3778,3779,3780,3781,3782,3783,3784,3785,3786,3787,3788,3789,\n3790,3791,3792,3793,3794,3795,3796,3797,3798,3799,3800,3801,3802,3803,3804,\n3805,3806,3807,3808,3809,3810,3811,3812,3813,3814,3815,3816,3817,3818,3819,\n3820,3821,3822,3823,3824,3825,3826,3827,3828,3829,3830,3831,3832,3833,3834,\n3835,3836,3837,3838,3839,3840,3841,3842,3843,3844,3845,3846,3847,3848,3849,\n3850,3851,3852,3853,3854,3855,3856,3857,3858,3859,3860,3861,3862,3863,3864,\n3865,3866,3867,3868,3869,3870,3871,3872,3873,3874,3875,3876,3877,3878,3879,\n3880,3881,3882,3883,3884,3885,3886,3887,3888,3889,3890,3891,3892,3893,3894,\n3895,3896,3897,3898,3899,3900,3901,3902,3903,3904,3905,3906,3907,3908,3909,\n3910,3911,3912,3913,3914,3915,3916,3917,3918,3919,3920,3921,3922,3923,3924,\n3925,3926,3927,3928,3929,3930,3931,3932,3933,3934,3935,3936,3937,3938,3939,\n3940,3941,3942,3943,3944,3945,3946,3947,3948,3949,3950,3951,3952,3953,3954,\n3955,3956,3957,3958,3959,3960,3961,3962,3963,3964,3965,3966,3967,3968,3969,\n3970,3971,3972,3973,3974,3975,3976,3977,3978,3979,3980,3981,3982,3983,3984,\n3985,3986,3987,3988,3989,3990,3991,3992,3993,3994,3995,3996,3997,3998,3999,\n4000,4001,4002,4003,4004,4005,4006,4007,4008,4009,4010,4011,4012,4013,4014,\n4015,4016,4017,4018,4019,4020,4021,4022,4023,4024,4025,4026,4027,4028,4029,\n4030,4031,4032,4033,4034,4035,4036,4037,4038,4039,4040,4041,4042,4043,4044,\n4045,4046,4047,4048,4049,4050,4051,4052,4053,4054,4055,4056,4057,4058,4059,\n4060,4061,4062,4063,4064,4065,4066,4067,4068,4069,4070,4071,4072,4073,4074,\n4075,4076,4077,4078,4079,4080,4081,4082,4083,4084,4085,4086,4087,4088,4089,\n4090,4091,4092,4093,4094,4095,4096,4097,4098,4099,4100,4101,4102,4103,4104,\n4105,4106,4107,4108,4109,4110,4111,4112,4113,4114,4115,4116,4117,4118,4119,\n4120,4121,4122,4123,4124,4125,4126,4127,4128,4129,4130,4131,4132,4133,4134,\n4135,4136,4137,4138,4139,4140,4141,4142,4143,4144,4145,4146,4147,4148,4149,\n4150,4151,4152,4153,4154,4155,4156,4157,4158,4159,4160,4161,4162,4163,4164,\n4165,4166,4167,4168,4169,4170,4171,4172,4173,4174,4175,4176,4177,4178,4179,\n4180,4181,4182,4183,4184,4185,4186,4187,4188,4189,4190,4191,4192,4193,4194,\n4195,4196,4197,4198,4199,4200,4201,4202,4203,4204,4205,4206,4207,4208,4209,\n4210,4211,4212,4213,4214,4215,4216,4217,4218,4219,4220,4221,4222,4223,4224,\n4225,4226,4227,4228,4229,4230,4231,4232,4233,4234,4235,4236,4237,4238,4239,\n4240,4241,4242,4243,4244,4245,4246,4247,4248,4249,4250,4251,4252,4253,4254,\n4255,4256,4257,4258,4259,4260,4261,4262,4263,4264,4265,4266,4267,4268,4269,\n4270,4271,4272,4273,4274,4275,4276,4277,4278,4279,4280,4281,4282,4283,4284,\n4285,4286,4287,4288,4289,4290,4291,4292,4293,4294,4295,4296,4297,4298,4299,\n4300,4301,4302,4303,4304,4305,4306,4307,4308,4309,4310,4311,4312,4313,4314,\n4315,4316,4317,4318,4319,4320,4321,4322,4323,4324,4325,4326,4327,4328,4329,\n4330,4331,4332,4333,4334,4335,4336,4337,4338,4339,4340,4341,4342,4343,4344,\n4345,4346,4347,4348,4349,4350,4351,4352,4353,4354,4355,4356,4357,4358,4359,\n4360,4361,4362,4363,4364,4365,4366,4367,4368,4369,4370,4371,4372,4373,4374,\n4375,4376,4377,4378,4379,4380,4381,4382,4383,4384,4385,4386,4387,4388,4389,\n4390,4391,4392,4393,4394,4395,4396,4397,4398,4399,4400,4401,4402,4403,4404,\n4405,4406,4407,4408,4409,4410,4411,4412,4413,4414,4415,4416,4417,4418,4419,\n4420,4421,4422,4423,4424,4425,4426,4427,4428,4429,4430,4431,4432,4433,4434,\n4435,4436,4437,4438,4439,4440,4441,4442,4443,4444,4445,4446,4447,4448,4449,\n4450,4451,4452,4453,4454,4455,4456,4457,4458,4459,4460,4461,4462,4463,4464,\n4465,4466,4467,4468,4469,4470,4471,4472,4473,4474,4475,4476,4477,4478,4479,\n4480,4481,4482,4483,4484,4485,4486,4487,4488,4489,4490,4491,4492,4493,4494,\n4495,4496,4497,4498,4499,4500,4501,4502,4503,4504,4505,4506,4507,4508,4509,\n4510,4511,4512,4513,4514,4515,4516,4517,4518,4519,4520,4521,4522,4523,4524,\n4525,4526,4527,4528,4529,4530,4531,4532,4533,4534,4535,4536,4537,4538,4539,\n4540,4541,4542,4543,4544,4545,4546,4547,4548,4549,4550,4551,4552,4553,4554,\n4555,4556,4557,4558,4559,4560,4561,4562,4563,4564,4565,4566,4567,4568,4569,\n4570,4571,4572,4573,4574,4575,4576,4577,4578,4579,4580,4581,4582,4583,4584,\n4585,4586,4587,4588,4589,4590,4591,4592,4593,4594,4595,4596,4597,4598,4599,\n4600,4601,4602,4603,4604,4605,4606,4607,4608,4609,4610,4611,4612,4613,4614,\n4615,4616,4617,4618,4619,4620,4621,4622,4623,4624,4625,4626,4627,4628,4629,\n4630,4631,4632,4633,4634,4635,4636,4637,4638,4639,4640,4641,4642,4643,4644,\n4645,4646,4647,4648,4649,4650,4651,4652,4653,4654,4655,4656,4657,4658,4659,\n4660,4661,4662,4663,4664,4665,4666,4667,4668,4669,4670,4671,4672,4673,4674,\n4675,4676,4677,4678,4679,4680,4681,4682,4683,4684,4685,4686,4687,4688,4689,\n4690,4691,4692,4693,4694,4695,4696,4697,4698,4699,4700,4701,4702,4703,4704,\n4705,4706,4707,4708,4709,4710,4711,4712,4713,4714,4715,4716,4717,4718,4719,\n4720,4721,4722,4723,4724,4725,4726,4727,4728,4729,4730,4731,4732,4733,4734,\n4735,4736,4737,4738,4739,4740,4741,4742,4743,4744,4745,4746,4747,4748,4749,\n4750,4751,4752,4753,4754,4755,4756,4757,4758,4759,4760,4761,4762,4763,4764,\n4765,4766,4767,4768,4769,4770,4771,4772,4773,4774,4775,4776,4777,4778,4779,\n4780,4781,4782,4783,4784,4785,4786,4787,4788,4789,4790,4791,4792,4793,4794,\n4795,4796,4797,4798,4799,4800,4801,4802,4803,4804,4805,4806,4807,4808,4809,\n4810,4811,4812,4813,4814,4815,4816,4817,4818,4819,4820,4821,4822,4823,4824,\n4825,4826,4827,4828,4829,4830,4831,4832,4833,4834,4835,4836,4837,4838,4839,\n4840,4841,4842,4843,4844,4845,4846,4847,4848,4849,4850,4851,4852,4853,4854,\n4855,4856,4857,4858,4859,4860,4861,4862,4863,4864,4865,4866,4867,4868,4869,\n4870,4871,4872,4873,4874,4875,4876,4877,4878,4879,4880,4881,4882,4883,4884,\n4885,4886,4887,4888,4889,4890,4891,4892,4893,4894,4895,4896,4897,4898,4899,\n4900,4901,4902,4903,4904,4905,4906,4907,4908,4909,4910,4911,4912,4913,4914,\n4915,4916,4917,4918,4919,4920,4921,4922,4923,4924,4925,4926,4927,4928,4929,\n4930,4931,4932,4933,4934,4935,4936,4937,4938,4939,4940,4941,4942,4943,4944,\n4945,4946,4947,4948,4949,4950,4951,4952,4953,4954,4955,4956,4957,4958,4959,\n4960,4961,4962,4963,4964,4965,4966,4967,4968,4969,4970,4971,4972,4973,4974,\n4975,4976,4977,4978,4979,4980,4981,4982,4983,4984,4985,4986,4987,4988,4989,\n4990,4991,4992,4993,4994,4995,4996,4997,4998,4999,5000,5001,5002,5003,5004,\n5005,5006,5007,5008,5009,5010,5011,5012,5013,5014,5015,5016,5017,5018,5019,\n5020,5021,5022,5023,5024,5025,5026,5027,5028,5029,5030,5031,5032,5033,5034,\n5035,5036,5037,5038,5039,5040,5041,5042,5043,5044,5045,5046,5047,5048,5049,\n5050,5051,5052,5053,5054,5055,5056,5057,5058,5059,5060,5061,5062,5063,5064,\n5065,5066,5067,5068,5069,5070,5071,5072,5073,5074,5075,5076,5077,5078,5079,\n5080,5081,5082,5083,5084,5085,5086,5087,5088,5089,5090,5091,5092,5093,5094,\n5095,5096,5097,5098,5099,5100,5101,5102,5103,5104,5105,5106,5107,5108,5109,\n5110,5111,5104,5105,5106,5107,5108,5109,5118,5119,5120,5121,5122,5123,5124,\n5125,5126,5127,5128,5129,5130,5131,5132,5133,5134,5135,5136,5137,5138,5139,\n5140,5141,5142,5143,5144,5145,5146,5147,5148,5149,5150,5151,5152,5153,5154,\n5155,5156,5157,5158,5159,5160,5161,5162,5163,5164,5165,5166,5167,5168,5169,\n5170,5171,5172,5173,5174,5175,5176,5177,5178,5179,5180,5181,5182,5183,5184,\n5185,5186,5187,5188,5189,5190,5191,5192,5193,5194,5195,5196,5197,5198,5199,\n5200,5201,5202,5203,5204,5205,5206,5207,5208,5209,5210,5211,5212,5213,5214,\n5215,5216,5217,5218,5219,5220,5221,5222,5223,5224,5225,5226,5227,5228,5229,\n5230,5231,5232,5233,5234,5235,5236,5237,5238,5239,5240,5241,5242,5243,5244,\n5245,5246,5247,5248,5249,5250,5251,5252,5253,5254,5255,5256,5257,5258,5259,\n5260,5261,5262,5263,5264,5265,5266,5267,5268,5269,5270,5271,5272,5273,5274,\n5275,5276,5277,5278,5279,5280,5281,5282,5283,5284,5285,5286,5287,5288,5289,\n5290,5291,5292,5293,5294,5295,5296,5297,5298,5299,5300,5301,5302,5303,5304,\n5305,5306,5307,5308,5309,5310,5311,5312,5313,5314,5315,5316,5317,5318,5319,\n5320,5321,5322,5323,5324,5325,5326,5327,5328,5329,5330,5331,5332,5333,5334,\n5335,5336,5337,5338,5339,5340,5341,5342,5343,5344,5345,5346,5347,5348,5349,\n5350,5351,5352,5353,5354,5355,5356,5357,5358,5359,5360,5361,5362,5363,5364,\n5365,5366,5367,5368,5369,5370,5371,5372,5373,5374,5375,5376,5377,5378,5379,\n5380,5381,5382,5383,5384,5385,5386,5387,5388,5389,5390,5391,5392,5393,5394,\n5395,5396,5397,5398,5399,5400,5401,5402,5403,5404,5405,5406,5407,5408,5409,\n5410,5411,5412,5413,5414,5415,5416,5417,5418,5419,5420,5421,5422,5423,5424,\n5425,5426,5427,5428,5429,5430,5431,5432,5433,5434,5435,5436,5437,5438,5439,\n5440,5441,5442,5443,5444,5445,5446,5447,5448,5449,5450,5451,5452,5453,5454,\n5455,5456,5457,5458,5459,5460,5461,5462,5463,5464,5465,5466,5467,5468,5469,\n5470,5471,5472,5473,5474,5475,5476,5477,5478,5479,5480,5481,5482,5483,5484,\n5485,5486,5487,5488,5489,5490,5491,5492,5493,5494,5495,5496,5497,5498,5499,\n5500,5501,5502,5503,5504,5505,5506,5507,5508,5509,5510,5511,5512,5513,5514,\n5515,5516,5517,5518,5519,5520,5521,5522,5523,5524,5525,5526,5527,5528,5529,\n5530,5531,5532,5533,5534,5535,5536,5537,5538,5539,5540,5541,5542,5543,5544,\n5545,5546,5547,5548,5549,5550,5551,5552,5553,5554,5555,5556,5557,5558,5559,\n5560,5561,5562,5563,5564,5565,5566,5567,5568,5569,5570,5571,5572,5573,5574,\n5575,5576,5577,5578,5579,5580,5581,5582,5583,5584,5585,5586,5587,5588,5589,\n5590,5591,5592,5593,5594,5595,5596,5597,5598,5599,5600,5601,5602,5603,5604,\n5605,5606,5607,5608,5609,5610,5611,5612,5613,5614,5615,5616,5617,5618,5619,\n5620,5621,5622,5623,5624,5625,5626,5627,5628,5629,5630,5631,5632,5633,5634,\n5635,5636,5637,5638,5639,5640,5641,5642,5643,5644,5645,5646,5647,5648,5649,\n5650,5651,5652,5653,5654,5655,5656,5657,5658,5659,5660,5661,5662,5663,5664,\n5665,5666,5667,5668,5669,5670,5671,5672,5673,5674,5675,5676,5677,5678,5679,\n5680,5681,5682,5683,5684,5685,5686,5687,5688,5689,5690,5691,5692,5693,5694,\n5695,5696,5697,5698,5699,5700,5701,5702,5703,5704,5705,5706,5707,5708,5709,\n5710,5711,5712,5713,5714,5715,5716,5717,5718,5719,5720,5721,5722,5723,5724,\n5725,5726,5727,5728,5729,5730,5731,5732,5733,5734,5735,5736,5737,5738,5739,\n5740,5741,5742,5743,5744,5745,5746,5747,5748,5749,5750,5751,5752,5753,5754,\n5755,5756,5757,5758,5759,5760,5761,5762,5763,5764,5765,5766,5767,5768,5769,\n5770,5771,5772,5773,5774,5775,5776,5777,5778,5779,5780,5781,5782,5783,5784,\n5785,5786,5787,5788,5789,5790,5791,5792,5793,5794,5795,5796,5797,5798,5799,\n5800,5801,5802,5803,5804,5805,5806,5807,5808,5809,5810,5811,5812,5813,5814,\n5815,5816,5817,5818,5819,5820,5821,5822,5823,5824,5825,5826,5827,5828,5829,\n5830,5831,5832,5833,5834,5835,5836,5837,5838,5839,5840,5841,5842,5843,5844,\n5845,5846,5847,5848,5849,5850,5851,5852,5853,5854,5855,5856,5857,5858,5859,\n5860,5861,5862,5863,5864,5865,5866,5867,5868,5869,5870,5871,5872,5873,5874,\n5875,5876,5877,5878,5879,5880,5881,5882,5883,5884,5885,5886,5887,5888,5889,\n5890,5891,5892,5893,5894,5895,5896,5897,5898,5899,5900,5901,5902,5903,5904,\n5905,5906,5907,5908,5909,5910,5911,5912,5913,5914,5915,5916,5917,5918,5919,\n5920,5921,5922,5923,5924,5925,5926,5927,5928,5929,5930,5931,5932,5933,5934,\n5935,5936,5937,5938,5939,5940,5941,5942,5943,5944,5945,5946,5947,5948,5949,\n5950,5951,5952,5953,5954,5955,5956,5957,5958,5959,5960,5961,5962,5963,5964,\n5965,5966,5967,5968,5969,5970,5971,5972,5973,5974,5975,5976,5977,5978,5979,\n5980,5981,5982,5983,5984,5985,5986,5987,5988,5989,5990,5991,5992,5993,5994,\n5995,5996,5997,5998,5999,6000,6001,6002,6003,6004,6005,6006,6007,6008,6009,\n6010,6011,6012,6013,6014,6015,6016,6017,6018,6019,6020,6021,6022,6023,6024,\n6025,6026,6027,6028,6029,6030,6031,6032,6033,6034,6035,6036,6037,6038,6039,\n6040,6041,6042,6043,6044,6045,6046,6047,6048,6049,6050,6051,6052,6053,6054,\n6055,6056,6057,6058,6059,6060,6061,6062,6063,6064,6065,6066,6067,6068,6069,\n6070,6071,6072,6073,6074,6075,6076,6077,6078,6079,6080,6081,6082,6083,6084,\n6085,6086,6087,6088,6089,6090,6091,6092,6093,6094,6095,6096,6097,6098,6099,\n6100,6101,6102,6103,6104,6105,6106,6107,6108,6109,6110,6111,6112,6113,6114,\n6115,6116,6117,6118,6119,6120,6121,6122,6123,6124,6125,6126,6127,6128,6129,\n6130,6131,6132,6133,6134,6135,6136,6137,6138,6139,6140,6141,6142,6143,6144,\n6145,6146,6147,6148,6149,6150,6151,6152,6153,6154,6155,6156,6157,6158,6159,\n6160,6161,6162,6163,6164,6165,6166,6167,6168,6169,6170,6171,6172,6173,6174,\n6175,6176,6177,6178,6179,6180,6181,6182,6183,6184,6185,6186,6187,6188,6189,\n6190,6191,6192,6193,6194,6195,6196,6197,6198,6199,6200,6201,6202,6203,6204,\n6205,6206,6207,6208,6209,6210,6211,6212,6213,6214,6215,6216,6217,6218,6219,\n6220,6221,6222,6223,6224,6225,6226,6227,6228,6229,6230,6231,6232,6233,6234,\n6235,6236,6237,6238,6239,6240,6241,6242,6243,6244,6245,6246,6247,6248,6249,\n6250,6251,6252,6253,6254,6255,6256,6257,6258,6259,6260,6261,6262,6263,6264,\n6265,6266,6267,6268,6269,6270,6271,6272,6273,6274,6275,6276,6277,6278,6279,\n6280,6281,6282,6283,6284,6285,6286,6287,6288,6289,6290,6291,6292,6293,6294,\n6295,6296,6297,6298,6299,6300,6301,6302,6303,6304,6305,6306,6307,6308,6309,\n6310,6311,6312,6313,6314,6315,6316,6317,6318,6319,6320,6321,6322,6323,6324,\n6325,6326,6327,6328,6329,6330,6331,6332,6333,6334,6335,6336,6337,6338,6339,\n6340,6341,6342,6343,6344,6345,6346,6347,6348,6349,6350,6351,6352,6353,6354,\n6355,6356,6357,6358,6359,6360,6361,6362,6363,6364,6365,6366,6367,6368,6369,\n6370,6371,6372,6373,6374,6375,6376,6377,6378,6379,6380,6381,6382,6383,6384,\n6385,6386,6387,6388,6389,6390,6391,6392,6393,6394,6395,6396,6397,6398,6399,\n6400,6401,6402,6403,6404,6405,6406,6407,6408,6409,6410,6411,6412,6413,6414,\n6415,6416,6417,6418,6419,6420,6421,6422,6423,6424,6425,6426,6427,6428,6429,\n6430,6431,6432,6433,6434,6435,6436,6437,6438,6439,6440,6441,6442,6443,6444,\n6445,6446,6447,6448,6449,6450,6451,6452,6453,6454,6455,6456,6457,6458,6459,\n6460,6461,6462,6463,6464,6465,6466,6467,6468,6469,6470,6471,6472,6473,6474,\n6475,6476,6477,6478,6479,6480,6481,6482,6483,6484,6485,6486,6487,6488,6489,\n6490,6491,6492,6493,6494,6495,6496,6497,6498,6499,6500,6501,6502,6503,6504,\n6505,6506,6507,6508,6509,6510,6511,6512,6513,6514,6515,6516,6517,6518,6519,\n6520,6521,6522,6523,6524,6525,6526,6527,6528,6529,6530,6531,6532,6533,6534,\n6535,6536,6537,6538,6539,6540,6541,6542,6543,6544,6545,6546,6547,6548,6549,\n6550,6551,6552,6553,6554,6555,6556,6557,6558,6559,6560,6561,6562,6563,6564,\n6565,6566,6567,6568,6569,6570,6571,6572,6573,6574,6575,6576,6577,6578,6579,\n6580,6581,6582,6583,6584,6585,6586,6587,6588,6589,6590,6591,6592,6593,6594,\n6595,6596,6597,6598,6599,6600,6601,6602,6603,6604,6605,6606,6607,6608,6609,\n6610,6611,6612,6613,6614,6615,6616,6617,6618,6619,6620,6621,6622,6623,6624,\n6625,6626,6627,6628,6629,6630,6631,6632,6633,6634,6635,6636,6637,6638,6639,\n6640,6641,6642,6643,6644,6645,6646,6647,6648,6649,6650,6651,6652,6653,6654,\n6655,6656,6657,6658,6659,6660,6661,6662,6663,6664,6665,6666,6667,6668,6669,\n6670,6671,6672,6673,6674,6675,6676,6677,6678,6679,6680,6681,6682,6683,6684,\n6685,6686,6687,6688,6689,6690,6691,6692,6693,6694,6695,6696,6697,6698,6699,\n6700,6701,6702,6703,6704,6705,6706,6707,6708,6709,6710,6711,6712,6713,6714,\n6715,6716,6717,6718,6719,6720,6721,6722,6723,6724,6725,6726,6727,6728,6729,\n6730,6731,6732,6733,6734,6735,6736,6737,6738,6739,6740,6741,6742,6743,6744,\n6745,6746,6747,6748,6749,6750,6751,6752,6753,6754,6755,6756,6757,6758,6759,\n6760,6761,6762,6763,6764,6765,6766,6767,6768,6769,6770,6771,6772,6773,6774,\n6775,6776,6777,6778,6779,6780,6781,6782,6783,6784,6785,6786,6787,6788,6789,\n6790,6791,6792,6793,6794,6795,6796,6797,6798,6799,6800,6801,6802,6803,6804,\n6805,6806,6807,6808,6809,6810,6811,6812,6813,6814,6815,6816,6817,6818,6819,\n6820,6821,6822,6823,6824,6825,6826,6827,6828,6829,6830,6831,6832,6833,6834,\n6835,6836,6837,6838,6839,6840,6841,6842,6843,6844,6845,6846,6847,6848,6849,\n6850,6851,6852,6853,6854,6855,6856,6857,6858,6859,6860,6861,6862,6863,6864,\n6865,6866,6867,6868,6869,6870,6871,6872,6873,6874,6875,6876,6877,6878,6879,\n6880,6881,6882,6883,6884,6885,6886,6887,6888,6889,6890,6891,6892,6893,6894,\n6895,6896,6897,6898,6899,6900,6901,6902,6903,6904,6905,6906,6907,6908,6909,\n6910,6911,6912,6913,6914,6915,6916,6917,6918,6919,6920,6921,6922,6923,6924,\n6925,6926,6927,6928,6929,6930,6931,6932,6933,6934,6935,6936,6937,6938,6939,\n6940,6941,6942,6943,6944,6945,6946,6947,6948,6949,6950,6951,6952,6953,6954,\n6955,6956,6957,6958,6959,6960,6961,6962,6963,6964,6965,6966,6967,6968,6969,\n6970,6971,6972,6973,6974,6975,6976,6977,6978,6979,6980,6981,6982,6983,6984,\n6985,6986,6987,6988,6989,6990,6991,6992,6993,6994,6995,6996,6997,6998,6999,\n7000,7001,7002,7003,7004,7005,7006,7007,7008,7009,7010,7011,7012,7013,7014,\n7015,7016,7017,7018,7019,7020,7021,7022,7023,7024,7025,7026,7027,7028,7029,\n7030,7031,7032,7033,7034,7035,7036,7037,7038,7039,7040,7041,7042,7043,7044,\n7045,7046,7047,7048,7049,7050,7051,7052,7053,7054,7055,7056,7057,7058,7059,\n7060,7061,7062,7063,7064,7065,7066,7067,7068,7069,7070,7071,7072,7073,7074,\n7075,7076,7077,7078,7079,7080,7081,7082,7083,7084,7085,7086,7087,7088,7089,\n7090,7091,7092,7093,7094,7095,7096,7097,7098,7099,7100,7101,7102,7103,7104,\n7105,7106,7107,7108,7109,7110,7111,7112,7113,7114,7115,7116,7117,7118,7119,\n7120,7121,7122,7123,7124,7125,7126,7127,7128,7129,7130,7131,7132,7133,7134,\n7135,7136,7137,7138,7139,7140,7141,7142,7143,7144,7145,7146,7147,7148,7149,\n7150,7151,7152,7153,7154,7155,7156,7157,7158,7159,7160,7161,7162,7163,7164,\n7165,7166,7167,7168,7169,7170,7171,7172,7173,7174,7175,7176,7177,7178,7179,\n7180,7181,7182,7183,7184,7185,7186,7187,7188,7189,7190,7191,7192,7193,7194,\n7195,7196,7197,7198,7199,7200,7201,7202,7203,7204,7205,7206,7207,7208,7209,\n7210,7211,7212,7213,7214,7215,7216,7217,7218,7219,7220,7221,7222,7223,7224,\n7225,7226,7227,7228,7229,7230,7231,7232,7233,7234,7235,7236,7237,7238,7239,\n7240,7241,7242,7243,7244,7245,7246,7247,7248,7249,7250,7251,7252,7253,7254,\n7255,7256,7257,7258,7259,7260,7261,7262,7263,7264,7265,7266,7267,7268,7269,\n7270,7271,7272,7273,7274,7275,7276,7277,7278,7279,7280,7281,7282,7283,7284,\n7285,7286,7287,7288,7289,7290,7291,7292,7293,7294,7295,1042,1044,1054,1057,\n1058,1058,1066,1122,42570L,7305,7306,7307,7308,7309,7310,7311,7312,7313,\n7314,7315,7316,7317,7318,7319,7320,7321,7322,7323,7324,7325,7326,7327,7328,\n7329,7330,7331,7332,7333,7334,7335,7336,7337,7338,7339,7340,7341,7342,7343,\n7344,7345,7346,7347,7348,7349,7350,7351,7352,7353,7354,7355,7356,7357,7358,\n7359,7360,7361,7362,7363,7364,7365,7366,7367,7368,7369,7370,7371,7372,7373,\n7374,7375,7376,7377,7378,7379,7380,7381,7382,7383,7384,7385,7386,7387,7388,\n7389,7390,7391,7392,7393,7394,7395,7396,7397,7398,7399,7400,7401,7402,7403,\n7404,7405,7406,7407,7408,7409,7410,7411,7412,7413,7414,7415,7416,7417,7418,\n7419,7420,7421,7422,7423,7424,7425,7426,7427,7428,7429,7430,7431,7432,7433,\n7434,7435,7436,7437,7438,7439,7440,7441,7442,7443,7444,7445,7446,7447,7448,\n7449,7450,7451,7452,7453,7454,7455,7456,7457,7458,7459,7460,7461,7462,7463,\n7464,7465,7466,7467,7468,7469,7470,7471,7472,7473,7474,7475,7476,7477,7478,\n7479,7480,7481,7482,7483,7484,7485,7486,7487,7488,7489,7490,7491,7492,7493,\n7494,7495,7496,7497,7498,7499,7500,7501,7502,7503,7504,7505,7506,7507,7508,\n7509,7510,7511,7512,7513,7514,7515,7516,7517,7518,7519,7520,7521,7522,7523,\n7524,7525,7526,7527,7528,7529,7530,7531,7532,7533,7534,7535,7536,7537,7538,\n7539,7540,7541,7542,7543,7544,42877L,7546,7547,7548,11363,7550,7551,7552,\n7553,7554,7555,7556,7557,7558,7559,7560,7561,7562,7563,7564,7565,7566,7567,\n7568,7569,7570,7571,7572,7573,7574,7575,7576,7577,7578,7579,7580,7581,7582,\n7583,7584,7585,7586,7587,7588,7589,7590,7591,7592,7593,7594,7595,7596,7597,\n7598,7599,7600,7601,7602,7603,7604,7605,7606,7607,7608,7609,7610,7611,7612,\n7613,7614,7615,7616,7617,7618,7619,7620,7621,7622,7623,7624,7625,7626,7627,\n7628,7629,7630,7631,7632,7633,7634,7635,7636,7637,7638,7639,7640,7641,7642,\n7643,7644,7645,7646,7647,7648,7649,7650,7651,7652,7653,7654,7655,7656,7657,\n7658,7659,7660,7661,7662,7663,7664,7665,7666,7667,7668,7669,7670,7671,7672,\n7673,7674,7675,7676,7677,7678,7679,7680,7680,7682,7682,7684,7684,7686,7686,\n7688,7688,7690,7690,7692,7692,7694,7694,7696,7696,7698,7698,7700,7700,7702,\n7702,7704,7704,7706,7706,7708,7708,7710,7710,7712,7712,7714,7714,7716,7716,\n7718,7718,7720,7720,7722,7722,7724,7724,7726,7726,7728,7728,7730,7730,7732,\n7732,7734,7734,7736,7736,7738,7738,7740,7740,7742,7742,7744,7744,7746,7746,\n7748,7748,7750,7750,7752,7752,7754,7754,7756,7756,7758,7758,7760,7760,7762,\n7762,7764,7764,7766,7766,7768,7768,7770,7770,7772,7772,7774,7774,7776,7776,\n7778,7778,7780,7780,7782,7782,7784,7784,7786,7786,7788,7788,7790,7790,7792,\n7792,7794,7794,7796,7796,7798,7798,7800,7800,7802,7802,7804,7804,7806,7806,\n7808,7808,7810,7810,7812,7812,7814,7814,7816,7816,7818,7818,7820,7820,7822,\n7822,7824,7824,7826,7826,7828,7828,7830,7831,7832,7833,7834,7776,7836,7837,\n7838,7839,7840,7840,7842,7842,7844,7844,7846,7846,7848,7848,7850,7850,7852,\n7852,7854,7854,7856,7856,7858,7858,7860,7860,7862,7862,7864,7864,7866,7866,\n7868,7868,7870,7870,7872,7872,7874,7874,7876,7876,7878,7878,7880,7880,7882,\n7882,7884,7884,7886,7886,7888,7888,7890,7890,7892,7892,7894,7894,7896,7896,\n7898,7898,7900,7900,7902,7902,7904,7904,7906,7906,7908,7908,7910,7910,7912,\n7912,7914,7914,7916,7916,7918,7918,7920,7920,7922,7922,7924,7924,7926,7926,\n7928,7928,7930,7930,7932,7932,7934,7934,7944,7945,7946,7947,7948,7949,7950,\n7951,7944,7945,7946,7947,7948,7949,7950,7951,7960,7961,7962,7963,7964,7965,\n7958,7959,7960,7961,7962,7963,7964,7965,7966,7967,7976,7977,7978,7979,7980,\n7981,7982,7983,7976,7977,7978,7979,7980,7981,7982,7983,7992,7993,7994,7995,\n7996,7997,7998,7999,7992,7993,7994,7995,7996,7997,7998,7999,8008,8009,8010,\n8011,8012,8013,8006,8007,8008,8009,8010,8011,8012,8013,8014,8015,8016,8025,\n8018,8027,8020,8029,8022,8031,8024,8025,8026,8027,8028,8029,8030,8031,8040,\n8041,8042,8043,8044,8045,8046,8047,8040,8041,8042,8043,8044,8045,8046,8047,\n8122,8123,8136,8137,8138,8139,8154,8155,8184,8185,8170,8171,8186,8187,8062,\n8063,8064,8065,8066,8067,8068,8069,8070,8071,8072,8073,8074,8075,8076,8077,\n8078,8079,8080,8081,8082,8083,8084,8085,8086,8087,8088,8089,8090,8091,8092,\n8093,8094,8095,8096,8097,8098,8099,8100,8101,8102,8103,8104,8105,8106,8107,\n8108,8109,8110,8111,8120,8121,8114,8115,8116,8117,8118,8119,8120,8121,8122,\n8123,8124,8125,921,8127,8128,8129,8130,8131,8132,8133,8134,8135,8136,8137,\n8138,8139,8140,8141,8142,8143,8152,8153,8146,8147,8148,8149,8150,8151,8152,\n8153,8154,8155,8156,8157,8158,8159,8168,8169,8162,8163,8164,8172,8166,8167,\n8168,8169,8170,8171,8172,8173,8174,8175,8176,8177,8178,8179,8180,8181,8182,\n8183,8184,8185,8186,8187,8188,8189,8190,8191,8192,8193,8194,8195,8196,8197,\n8198,8199,8200,8201,8202,8203,8204,8205,8206,8207,8208,8209,8210,8211,8212,\n8213,8214,8215,8216,8217,8218,8219,8220,8221,8222,8223,8224,8225,8226,8227,\n8228,8229,8230,8231,8232,8233,8234,8235,8236,8237,8238,8239,8240,8241,8242,\n8243,8244,8245,8246,8247,8248,8249,8250,8251,8252,8253,8254,8255,8256,8257,\n8258,8259,8260,8261,8262,8263,8264,8265,8266,8267,8268,8269,8270,8271,8272,\n8273,8274,8275,8276,8277,8278,8279,8280,8281,8282,8283,8284,8285,8286,8287,\n8288,8289,8290,8291,8292,8293,8294,8295,8296,8297,8298,8299,8300,8301,8302,\n8303,8304,8305,8306,8307,8308,8309,8310,8311,8312,8313,8314,8315,8316,8317,\n8318,8319,8320,8321,8322,8323,8324,8325,8326,8327,8328,8329,8330,8331,8332,\n8333,8334,8335,8336,8337,8338,8339,8340,8341,8342,8343,8344,8345,8346,8347,\n8348,8349,8350,8351,8352,8353,8354,8355,8356,8357,8358,8359,8360,8361,8362,\n8363,8364,8365,8366,8367,8368,8369,8370,8371,8372,8373,8374,8375,8376,8377,\n8378,8379,8380,8381,8382,8383,8384,8385,8386,8387,8388,8389,8390,8391,8392,\n8393,8394,8395,8396,8397,8398,8399,8400,8401,8402,8403,8404,8405,8406,8407,\n8408,8409,8410,8411,8412,8413,8414,8415,8416,8417,8418,8419,8420,8421,8422,\n8423,8424,8425,8426,8427,8428,8429,8430,8431,8432,8433,8434,8435,8436,8437,\n8438,8439,8440,8441,8442,8443,8444,8445,8446,8447,8448,8449,8450,8451,8452,\n8453,8454,8455,8456,8457,8458,8459,8460,8461,8462,8463,8464,8465,8466,8467,\n8468,8469,8470,8471,8472,8473,8474,8475,8476,8477,8478,8479,8480,8481,8482,\n8483,8484,8485,8486,8487,8488,8489,8490,8491,8492,8493,8494,8495,8496,8497,\n8498,8499,8500,8501,8502,8503,8504,8505,8506,8507,8508,8509,8510,8511,8512,\n8513,8514,8515,8516,8517,8518,8519,8520,8521,8522,8523,8524,8525,8498,8527,\n8528,8529,8530,8531,8532,8533,8534,8535,8536,8537,8538,8539,8540,8541,8542,\n8543,8544,8545,8546,8547,8548,8549,8550,8551,8552,8553,8554,8555,8556,8557,\n8558,8559,8544,8545,8546,8547,8548,8549,8550,8551,8552,8553,8554,8555,8556,\n8557,8558,8559,8576,8577,8578,8579,8579,8581,8582,8583,8584,8585,8586,8587,\n8588,8589,8590,8591,8592,8593,8594,8595,8596,8597,8598,8599,8600,8601,8602,\n8603,8604,8605,8606,8607,8608,8609,8610,8611,8612,8613,8614,8615,8616,8617,\n8618,8619,8620,8621,8622,8623,8624,8625,8626,8627,8628,8629,8630,8631,8632,\n8633,8634,8635,8636,8637,8638,8639,8640,8641,8642,8643,8644,8645,8646,8647,\n8648,8649,8650,8651,8652,8653,8654,8655,8656,8657,8658,8659,8660,8661,8662,\n8663,8664,8665,8666,8667,8668,8669,8670,8671,8672,8673,8674,8675,8676,8677,\n8678,8679,8680,8681,8682,8683,8684,8685,8686,8687,8688,8689,8690,8691,8692,\n8693,8694,8695,8696,8697,8698,8699,8700,8701,8702,8703,8704,8705,8706,8707,\n8708,8709,8710,8711,8712,8713,8714,8715,8716,8717,8718,8719,8720,8721,8722,\n8723,8724,8725,8726,8727,8728,8729,8730,8731,8732,8733,8734,8735,8736,8737,\n8738,8739,8740,8741,8742,8743,8744,8745,8746,8747,8748,8749,8750,8751,8752,\n8753,8754,8755,8756,8757,8758,8759,8760,8761,8762,8763,8764,8765,8766,8767,\n8768,8769,8770,8771,8772,8773,8774,8775,8776,8777,8778,8779,8780,8781,8782,\n8783,8784,8785,8786,8787,8788,8789,8790,8791,8792,8793,8794,8795,8796,8797,\n8798,8799,8800,8801,8802,8803,8804,8805,8806,8807,8808,8809,8810,8811,8812,\n8813,8814,8815,8816,8817,8818,8819,8820,8821,8822,8823,8824,8825,8826,8827,\n8828,8829,8830,8831,8832,8833,8834,8835,8836,8837,8838,8839,8840,8841,8842,\n8843,8844,8845,8846,8847,8848,8849,8850,8851,8852,8853,8854,8855,8856,8857,\n8858,8859,8860,8861,8862,8863,8864,8865,8866,8867,8868,8869,8870,8871,8872,\n8873,8874,8875,8876,8877,8878,8879,8880,8881,8882,8883,8884,8885,8886,8887,\n8888,8889,8890,8891,8892,8893,8894,8895,8896,8897,8898,8899,8900,8901,8902,\n8903,8904,8905,8906,8907,8908,8909,8910,8911,8912,8913,8914,8915,8916,8917,\n8918,8919,8920,8921,8922,8923,8924,8925,8926,8927,8928,8929,8930,8931,8932,\n8933,8934,8935,8936,8937,8938,8939,8940,8941,8942,8943,8944,8945,8946,8947,\n8948,8949,8950,8951,8952,8953,8954,8955,8956,8957,8958,8959,8960,8961,8962,\n8963,8964,8965,8966,8967,8968,8969,8970,8971,8972,8973,8974,8975,8976,8977,\n8978,8979,8980,8981,8982,8983,8984,8985,8986,8987,8988,8989,8990,8991,8992,\n8993,8994,8995,8996,8997,8998,8999,9000,9001,9002,9003,9004,9005,9006,9007,\n9008,9009,9010,9011,9012,9013,9014,9015,9016,9017,9018,9019,9020,9021,9022,\n9023,9024,9025,9026,9027,9028,9029,9030,9031,9032,9033,9034,9035,9036,9037,\n9038,9039,9040,9041,9042,9043,9044,9045,9046,9047,9048,9049,9050,9051,9052,\n9053,9054,9055,9056,9057,9058,9059,9060,9061,9062,9063,9064,9065,9066,9067,\n9068,9069,9070,9071,9072,9073,9074,9075,9076,9077,9078,9079,9080,9081,9082,\n9083,9084,9085,9086,9087,9088,9089,9090,9091,9092,9093,9094,9095,9096,9097,\n9098,9099,9100,9101,9102,9103,9104,9105,9106,9107,9108,9109,9110,9111,9112,\n9113,9114,9115,9116,9117,9118,9119,9120,9121,9122,9123,9124,9125,9126,9127,\n9128,9129,9130,9131,9132,9133,9134,9135,9136,9137,9138,9139,9140,9141,9142,\n9143,9144,9145,9146,9147,9148,9149,9150,9151,9152,9153,9154,9155,9156,9157,\n9158,9159,9160,9161,9162,9163,9164,9165,9166,9167,9168,9169,9170,9171,9172,\n9173,9174,9175,9176,9177,9178,9179,9180,9181,9182,9183,9184,9185,9186,9187,\n9188,9189,9190,9191,9192,9193,9194,9195,9196,9197,9198,9199,9200,9201,9202,\n9203,9204,9205,9206,9207,9208,9209,9210,9211,9212,9213,9214,9215,9216,9217,\n9218,9219,9220,9221,9222,9223,9224,9225,9226,9227,9228,9229,9230,9231,9232,\n9233,9234,9235,9236,9237,9238,9239,9240,9241,9242,9243,9244,9245,9246,9247,\n9248,9249,9250,9251,9252,9253,9254,9255,9256,9257,9258,9259,9260,9261,9262,\n9263,9264,9265,9266,9267,9268,9269,9270,9271,9272,9273,9274,9275,9276,9277,\n9278,9279,9280,9281,9282,9283,9284,9285,9286,9287,9288,9289,9290,9291,9292,\n9293,9294,9295,9296,9297,9298,9299,9300,9301,9302,9303,9304,9305,9306,9307,\n9308,9309,9310,9311,9312,9313,9314,9315,9316,9317,9318,9319,9320,9321,9322,\n9323,9324,9325,9326,9327,9328,9329,9330,9331,9332,9333,9334,9335,9336,9337,\n9338,9339,9340,9341,9342,9343,9344,9345,9346,9347,9348,9349,9350,9351,9352,\n9353,9354,9355,9356,9357,9358,9359,9360,9361,9362,9363,9364,9365,9366,9367,\n9368,9369,9370,9371,9372,9373,9374,9375,9376,9377,9378,9379,9380,9381,9382,\n9383,9384,9385,9386,9387,9388,9389,9390,9391,9392,9393,9394,9395,9396,9397,\n9398,9399,9400,9401,9402,9403,9404,9405,9406,9407,9408,9409,9410,9411,9412,\n9413,9414,9415,9416,9417,9418,9419,9420,9421,9422,9423,9398,9399,9400,9401,\n9402,9403,9404,9405,9406,9407,9408,9409,9410,9411,9412,9413,9414,9415,9416,\n9417,9418,9419,9420,9421,9422,9423,9450,9451,9452,9453,9454,9455,9456,9457,\n9458,9459,9460,9461,9462,9463,9464,9465,9466,9467,9468,9469,9470,9471,9472,\n9473,9474,9475,9476,9477,9478,9479,9480,9481,9482,9483,9484,9485,9486,9487,\n9488,9489,9490,9491,9492,9493,9494,9495,9496,9497,9498,9499,9500,9501,9502,\n9503,9504,9505,9506,9507,9508,9509,9510,9511,9512,9513,9514,9515,9516,9517,\n9518,9519,9520,9521,9522,9523,9524,9525,9526,9527,9528,9529,9530,9531,9532,\n9533,9534,9535,9536,9537,9538,9539,9540,9541,9542,9543,9544,9545,9546,9547,\n9548,9549,9550,9551,9552,9553,9554,9555,9556,9557,9558,9559,9560,9561,9562,\n9563,9564,9565,9566,9567,9568,9569,9570,9571,9572,9573,9574,9575,9576,9577,\n9578,9579,9580,9581,9582,9583,9584,9585,9586,9587,9588,9589,9590,9591,9592,\n9593,9594,9595,9596,9597,9598,9599,9600,9601,9602,9603,9604,9605,9606,9607,\n9608,9609,9610,9611,9612,9613,9614,9615,9616,9617,9618,9619,9620,9621,9622,\n9623,9624,9625,9626,9627,9628,9629,9630,9631,9632,9633,9634,9635,9636,9637,\n9638,9639,9640,9641,9642,9643,9644,9645,9646,9647,9648,9649,9650,9651,9652,\n9653,9654,9655,9656,9657,9658,9659,9660,9661,9662,9663,9664,9665,9666,9667,\n9668,9669,9670,9671,9672,9673,9674,9675,9676,9677,9678,9679,9680,9681,9682,\n9683,9684,9685,9686,9687,9688,9689,9690,9691,9692,9693,9694,9695,9696,9697,\n9698,9699,9700,9701,9702,9703,9704,9705,9706,9707,9708,9709,9710,9711,9712,\n9713,9714,9715,9716,9717,9718,9719,9720,9721,9722,9723,9724,9725,9726,9727,\n9728,9729,9730,9731,9732,9733,9734,9735,9736,9737,9738,9739,9740,9741,9742,\n9743,9744,9745,9746,9747,9748,9749,9750,9751,9752,9753,9754,9755,9756,9757,\n9758,9759,9760,9761,9762,9763,9764,9765,9766,9767,9768,9769,9770,9771,9772,\n9773,9774,9775,9776,9777,9778,9779,9780,9781,9782,9783,9784,9785,9786,9787,\n9788,9789,9790,9791,9792,9793,9794,9795,9796,9797,9798,9799,9800,9801,9802,\n9803,9804,9805,9806,9807,9808,9809,9810,9811,9812,9813,9814,9815,9816,9817,\n9818,9819,9820,9821,9822,9823,9824,9825,9826,9827,9828,9829,9830,9831,9832,\n9833,9834,9835,9836,9837,9838,9839,9840,9841,9842,9843,9844,9845,9846,9847,\n9848,9849,9850,9851,9852,9853,9854,9855,9856,9857,9858,9859,9860,9861,9862,\n9863,9864,9865,9866,9867,9868,9869,9870,9871,9872,9873,9874,9875,9876,9877,\n9878,9879,9880,9881,9882,9883,9884,9885,9886,9887,9888,9889,9890,9891,9892,\n9893,9894,9895,9896,9897,9898,9899,9900,9901,9902,9903,9904,9905,9906,9907,\n9908,9909,9910,9911,9912,9913,9914,9915,9916,9917,9918,9919,9920,9921,9922,\n9923,9924,9925,9926,9927,9928,9929,9930,9931,9932,9933,9934,9935,9936,9937,\n9938,9939,9940,9941,9942,9943,9944,9945,9946,9947,9948,9949,9950,9951,9952,\n9953,9954,9955,9956,9957,9958,9959,9960,9961,9962,9963,9964,9965,9966,9967,\n9968,9969,9970,9971,9972,9973,9974,9975,9976,9977,9978,9979,9980,9981,9982,\n9983,9984,9985,9986,9987,9988,9989,9990,9991,9992,9993,9994,9995,9996,9997,\n9998,9999,10000,10001,10002,10003,10004,10005,10006,10007,10008,10009,\n10010,10011,10012,10013,10014,10015,10016,10017,10018,10019,10020,10021,\n10022,10023,10024,10025,10026,10027,10028,10029,10030,10031,10032,10033,\n10034,10035,10036,10037,10038,10039,10040,10041,10042,10043,10044,10045,\n10046,10047,10048,10049,10050,10051,10052,10053,10054,10055,10056,10057,\n10058,10059,10060,10061,10062,10063,10064,10065,10066,10067,10068,10069,\n10070,10071,10072,10073,10074,10075,10076,10077,10078,10079,10080,10081,\n10082,10083,10084,10085,10086,10087,10088,10089,10090,10091,10092,10093,\n10094,10095,10096,10097,10098,10099,10100,10101,10102,10103,10104,10105,\n10106,10107,10108,10109,10110,10111,10112,10113,10114,10115,10116,10117,\n10118,10119,10120,10121,10122,10123,10124,10125,10126,10127,10128,10129,\n10130,10131,10132,10133,10134,10135,10136,10137,10138,10139,10140,10141,\n10142,10143,10144,10145,10146,10147,10148,10149,10150,10151,10152,10153,\n10154,10155,10156,10157,10158,10159,10160,10161,10162,10163,10164,10165,\n10166,10167,10168,10169,10170,10171,10172,10173,10174,10175,10176,10177,\n10178,10179,10180,10181,10182,10183,10184,10185,10186,10187,10188,10189,\n10190,10191,10192,10193,10194,10195,10196,10197,10198,10199,10200,10201,\n10202,10203,10204,10205,10206,10207,10208,10209,10210,10211,10212,10213,\n10214,10215,10216,10217,10218,10219,10220,10221,10222,10223,10224,10225,\n10226,10227,10228,10229,10230,10231,10232,10233,10234,10235,10236,10237,\n10238,10239,10240,10241,10242,10243,10244,10245,10246,10247,10248,10249,\n10250,10251,10252,10253,10254,10255,10256,10257,10258,10259,10260,10261,\n10262,10263,10264,10265,10266,10267,10268,10269,10270,10271,10272,10273,\n10274,10275,10276,10277,10278,10279,10280,10281,10282,10283,10284,10285,\n10286,10287,10288,10289,10290,10291,10292,10293,10294,10295,10296,10297,\n10298,10299,10300,10301,10302,10303,10304,10305,10306,10307,10308,10309,\n10310,10311,10312,10313,10314,10315,10316,10317,10318,10319,10320,10321,\n10322,10323,10324,10325,10326,10327,10328,10329,10330,10331,10332,10333,\n10334,10335,10336,10337,10338,10339,10340,10341,10342,10343,10344,10345,\n10346,10347,10348,10349,10350,10351,10352,10353,10354,10355,10356,10357,\n10358,10359,10360,10361,10362,10363,10364,10365,10366,10367,10368,10369,\n10370,10371,10372,10373,10374,10375,10376,10377,10378,10379,10380,10381,\n10382,10383,10384,10385,10386,10387,10388,10389,10390,10391,10392,10393,\n10394,10395,10396,10397,10398,10399,10400,10401,10402,10403,10404,10405,\n10406,10407,10408,10409,10410,10411,10412,10413,10414,10415,10416,10417,\n10418,10419,10420,10421,10422,10423,10424,10425,10426,10427,10428,10429,\n10430,10431,10432,10433,10434,10435,10436,10437,10438,10439,10440,10441,\n10442,10443,10444,10445,10446,10447,10448,10449,10450,10451,10452,10453,\n10454,10455,10456,10457,10458,10459,10460,10461,10462,10463,10464,10465,\n10466,10467,10468,10469,10470,10471,10472,10473,10474,10475,10476,10477,\n10478,10479,10480,10481,10482,10483,10484,10485,10486,10487,10488,10489,\n10490,10491,10492,10493,10494,10495,10496,10497,10498,10499,10500,10501,\n10502,10503,10504,10505,10506,10507,10508,10509,10510,10511,10512,10513,\n10514,10515,10516,10517,10518,10519,10520,10521,10522,10523,10524,10525,\n10526,10527,10528,10529,10530,10531,10532,10533,10534,10535,10536,10537,\n10538,10539,10540,10541,10542,10543,10544,10545,10546,10547,10548,10549,\n10550,10551,10552,10553,10554,10555,10556,10557,10558,10559,10560,10561,\n10562,10563,10564,10565,10566,10567,10568,10569,10570,10571,10572,10573,\n10574,10575,10576,10577,10578,10579,10580,10581,10582,10583,10584,10585,\n10586,10587,10588,10589,10590,10591,10592,10593,10594,10595,10596,10597,\n10598,10599,10600,10601,10602,10603,10604,10605,10606,10607,10608,10609,\n10610,10611,10612,10613,10614,10615,10616,10617,10618,10619,10620,10621,\n10622,10623,10624,10625,10626,10627,10628,10629,10630,10631,10632,10633,\n10634,10635,10636,10637,10638,10639,10640,10641,10642,10643,10644,10645,\n10646,10647,10648,10649,10650,10651,10652,10653,10654,10655,10656,10657,\n10658,10659,10660,10661,10662,10663,10664,10665,10666,10667,10668,10669,\n10670,10671,10672,10673,10674,10675,10676,10677,10678,10679,10680,10681,\n10682,10683,10684,10685,10686,10687,10688,10689,10690,10691,10692,10693,\n10694,10695,10696,10697,10698,10699,10700,10701,10702,10703,10704,10705,\n10706,10707,10708,10709,10710,10711,10712,10713,10714,10715,10716,10717,\n10718,10719,10720,10721,10722,10723,10724,10725,10726,10727,10728,10729,\n10730,10731,10732,10733,10734,10735,10736,10737,10738,10739,10740,10741,\n10742,10743,10744,10745,10746,10747,10748,10749,10750,10751,10752,10753,\n10754,10755,10756,10757,10758,10759,10760,10761,10762,10763,10764,10765,\n10766,10767,10768,10769,10770,10771,10772,10773,10774,10775,10776,10777,\n10778,10779,10780,10781,10782,10783,10784,10785,10786,10787,10788,10789,\n10790,10791,10792,10793,10794,10795,10796,10797,10798,10799,10800,10801,\n10802,10803,10804,10805,10806,10807,10808,10809,10810,10811,10812,10813,\n10814,10815,10816,10817,10818,10819,10820,10821,10822,10823,10824,10825,\n10826,10827,10828,10829,10830,10831,10832,10833,10834,10835,10836,10837,\n10838,10839,10840,10841,10842,10843,10844,10845,10846,10847,10848,10849,\n10850,10851,10852,10853,10854,10855,10856,10857,10858,10859,10860,10861,\n10862,10863,10864,10865,10866,10867,10868,10869,10870,10871,10872,10873,\n10874,10875,10876,10877,10878,10879,10880,10881,10882,10883,10884,10885,\n10886,10887,10888,10889,10890,10891,10892,10893,10894,10895,10896,10897,\n10898,10899,10900,10901,10902,10903,10904,10905,10906,10907,10908,10909,\n10910,10911,10912,10913,10914,10915,10916,10917,10918,10919,10920,10921,\n10922,10923,10924,10925,10926,10927,10928,10929,10930,10931,10932,10933,\n10934,10935,10936,10937,10938,10939,10940,10941,10942,10943,10944,10945,\n10946,10947,10948,10949,10950,10951,10952,10953,10954,10955,10956,10957,\n10958,10959,10960,10961,10962,10963,10964,10965,10966,10967,10968,10969,\n10970,10971,10972,10973,10974,10975,10976,10977,10978,10979,10980,10981,\n10982,10983,10984,10985,10986,10987,10988,10989,10990,10991,10992,10993,\n10994,10995,10996,10997,10998,10999,11000,11001,11002,11003,11004,11005,\n11006,11007,11008,11009,11010,11011,11012,11013,11014,11015,11016,11017,\n11018,11019,11020,11021,11022,11023,11024,11025,11026,11027,11028,11029,\n11030,11031,11032,11033,11034,11035,11036,11037,11038,11039,11040,11041,\n11042,11043,11044,11045,11046,11047,11048,11049,11050,11051,11052,11053,\n11054,11055,11056,11057,11058,11059,11060,11061,11062,11063,11064,11065,\n11066,11067,11068,11069,11070,11071,11072,11073,11074,11075,11076,11077,\n11078,11079,11080,11081,11082,11083,11084,11085,11086,11087,11088,11089,\n11090,11091,11092,11093,11094,11095,11096,11097,11098,11099,11100,11101,\n11102,11103,11104,11105,11106,11107,11108,11109,11110,11111,11112,11113,\n11114,11115,11116,11117,11118,11119,11120,11121,11122,11123,11124,11125,\n11126,11127,11128,11129,11130,11131,11132,11133,11134,11135,11136,11137,\n11138,11139,11140,11141,11142,11143,11144,11145,11146,11147,11148,11149,\n11150,11151,11152,11153,11154,11155,11156,11157,11158,11159,11160,11161,\n11162,11163,11164,11165,11166,11167,11168,11169,11170,11171,11172,11173,\n11174,11175,11176,11177,11178,11179,11180,11181,11182,11183,11184,11185,\n11186,11187,11188,11189,11190,11191,11192,11193,11194,11195,11196,11197,\n11198,11199,11200,11201,11202,11203,11204,11205,11206,11207,11208,11209,\n11210,11211,11212,11213,11214,11215,11216,11217,11218,11219,11220,11221,\n11222,11223,11224,11225,11226,11227,11228,11229,11230,11231,11232,11233,\n11234,11235,11236,11237,11238,11239,11240,11241,11242,11243,11244,11245,\n11246,11247,11248,11249,11250,11251,11252,11253,11254,11255,11256,11257,\n11258,11259,11260,11261,11262,11263,11264,11265,11266,11267,11268,11269,\n11270,11271,11272,11273,11274,11275,11276,11277,11278,11279,11280,11281,\n11282,11283,11284,11285,11286,11287,11288,11289,11290,11291,11292,11293,\n11294,11295,11296,11297,11298,11299,11300,11301,11302,11303,11304,11305,\n11306,11307,11308,11309,11310,11311,11264,11265,11266,11267,11268,11269,\n11270,11271,11272,11273,11274,11275,11276,11277,11278,11279,11280,11281,\n11282,11283,11284,11285,11286,11287,11288,11289,11290,11291,11292,11293,\n11294,11295,11296,11297,11298,11299,11300,11301,11302,11303,11304,11305,\n11306,11307,11308,11309,11310,11359,11360,11360,11362,11363,11364,570,574,\n11367,11367,11369,11369,11371,11371,11373,11374,11375,11376,11377,11378,\n11378,11380,11381,11381,11383,11384,11385,11386,11387,11388,11389,11390,\n11391,11392,11392,11394,11394,11396,11396,11398,11398,11400,11400,11402,\n11402,11404,11404,11406,11406,11408,11408,11410,11410,11412,11412,11414,\n11414,11416,11416,11418,11418,11420,11420,11422,11422,11424,11424,11426,\n11426,11428,11428,11430,11430,11432,11432,11434,11434,11436,11436,11438,\n11438,11440,11440,11442,11442,11444,11444,11446,11446,11448,11448,11450,\n11450,11452,11452,11454,11454,11456,11456,11458,11458,11460,11460,11462,\n11462,11464,11464,11466,11466,11468,11468,11470,11470,11472,11472,11474,\n11474,11476,11476,11478,11478,11480,11480,11482,11482,11484,11484,11486,\n11486,11488,11488,11490,11490,11492,11493,11494,11495,11496,11497,11498,\n11499,11499,11501,11501,11503,11504,11505,11506,11506,11508,11509,11510,\n11511,11512,11513,11514,11515,11516,11517,11518,11519,4256,4257,4258,4259,\n4260,4261,4262,4263,4264,4265,4266,4267,4268,4269,4270,4271,4272,4273,4274,\n4275,4276,4277,4278,4279,4280,4281,4282,4283,4284,4285,4286,4287,4288,4289,\n4290,4291,4292,4293,11558,4295,11560,11561,11562,11563,11564,4301,11566,\n11567,11568,11569,11570,11571,11572,11573,11574,11575,11576,11577,11578,\n11579,11580,11581,11582,11583,11584,11585,11586,11587,11588,11589,11590,\n11591,11592,11593,11594,11595,11596,11597,11598,11599,11600,11601,11602,\n11603,11604,11605,11606,11607,11608,11609,11610,11611,11612,11613,11614,\n11615,11616,11617,11618,11619,11620,11621,11622,11623,11624,11625,11626,\n11627,11628,11629,11630,11631,11632,11633,11634,11635,11636,11637,11638,\n11639,11640,11641,11642,11643,11644,11645,11646,11647,11648,11649,11650,\n11651,11652,11653,11654,11655,11656,11657,11658,11659,11660,11661,11662,\n11663,11664,11665,11666,11667,11668,11669,11670,11671,11672,11673,11674,\n11675,11676,11677,11678,11679,11680,11681,11682,11683,11684,11685,11686,\n11687,11688,11689,11690,11691,11692,11693,11694,11695,11696,11697,11698,\n11699,11700,11701,11702,11703,11704,11705,11706,11707,11708,11709,11710,\n11711,11712,11713,11714,11715,11716,11717,11718,11719,11720,11721,11722,\n11723,11724,11725,11726,11727,11728,11729,11730,11731,11732,11733,11734,\n11735,11736,11737,11738,11739,11740,11741,11742,11743,11744,11745,11746,\n11747,11748,11749,11750,11751,11752,11753,11754,11755,11756,11757,11758,\n11759,11760,11761,11762,11763,11764,11765,11766,11767,11768,11769,11770,\n11771,11772,11773,11774,11775,11776,11777,11778,11779,11780,11781,11782,\n11783,11784,11785,11786,11787,11788,11789,11790,11791,11792,11793,11794,\n11795,11796,11797,11798,11799,11800,11801,11802,11803,11804,11805,11806,\n11807,11808,11809,11810,11811,11812,11813,11814,11815,11816,11817,11818,\n11819,11820,11821,11822,11823,11824,11825,11826,11827,11828,11829,11830,\n11831,11832,11833,11834,11835,11836,11837,11838,11839,11840,11841,11842,\n11843,11844,11845,11846,11847,11848,11849,11850,11851,11852,11853,11854,\n11855,11856,11857,11858,11859,11860,11861,11862,11863,11864,11865,11866,\n11867,11868,11869,11870,11871,11872,11873,11874,11875,11876,11877,11878,\n11879,11880,11881,11882,11883,11884,11885,11886,11887,11888,11889,11890,\n11891,11892,11893,11894,11895,11896,11897,11898,11899,11900,11901,11902,\n11903,11904,11905,11906,11907,11908,11909,11910,11911,11912,11913,11914,\n11915,11916,11917,11918,11919,11920,11921,11922,11923,11924,11925,11926,\n11927,11928,11929,11930,11931,11932,11933,11934,11935,11936,11937,11938,\n11939,11940,11941,11942,11943,11944,11945,11946,11947,11948,11949,11950,\n11951,11952,11953,11954,11955,11956,11957,11958,11959,11960,11961,11962,\n11963,11964,11965,11966,11967,11968,11969,11970,11971,11972,11973,11974,\n11975,11976,11977,11978,11979,11980,11981,11982,11983,11984,11985,11986,\n11987,11988,11989,11990,11991,11992,11993,11994,11995,11996,11997,11998,\n11999,12000,12001,12002,12003,12004,12005,12006,12007,12008,12009,12010,\n12011,12012,12013,12014,12015,12016,12017,12018,12019,12020,12021,12022,\n12023,12024,12025,12026,12027,12028,12029,12030,12031,12032,12033,12034,\n12035,12036,12037,12038,12039,12040,12041,12042,12043,12044,12045,12046,\n12047,12048,12049,12050,12051,12052,12053,12054,12055,12056,12057,12058,\n12059,12060,12061,12062,12063,12064,12065,12066,12067,12068,12069,12070,\n12071,12072,12073,12074,12075,12076,12077,12078,12079,12080,12081,12082,\n12083,12084,12085,12086,12087,12088,12089,12090,12091,12092,12093,12094,\n12095,12096,12097,12098,12099,12100,12101,12102,12103,12104,12105,12106,\n12107,12108,12109,12110,12111,12112,12113,12114,12115,12116,12117,12118,\n12119,12120,12121,12122,12123,12124,12125,12126,12127,12128,12129,12130,\n12131,12132,12133,12134,12135,12136,12137,12138,12139,12140,12141,12142,\n12143,12144,12145,12146,12147,12148,12149,12150,12151,12152,12153,12154,\n12155,12156,12157,12158,12159,12160,12161,12162,12163,12164,12165,12166,\n12167,12168,12169,12170,12171,12172,12173,12174,12175,12176,12177,12178,\n12179,12180,12181,12182,12183,12184,12185,12186,12187,12188,12189,12190,\n12191,12192,12193,12194,12195,12196,12197,12198,12199,12200,12201,12202,\n12203,12204,12205,12206,12207,12208,12209,12210,12211,12212,12213,12214,\n12215,12216,12217,12218,12219,12220,12221,12222,12223,12224,12225,12226,\n12227,12228,12229,12230,12231,12232,12233,12234,12235,12236,12237,12238,\n12239,12240,12241,12242,12243,12244,12245,12246,12247,12248,12249,12250,\n12251,12252,12253,12254,12255,12256,12257,12258,12259,12260,12261,12262,\n12263,12264,12265,12266,12267,12268,12269,12270,12271,12272,12273,12274,\n12275,12276,12277,12278,12279,12280,12281,12282,12283,12284,12285,12286,\n12287,12288,12289,12290,12291,12292,12293,12294,12295,12296,12297,12298,\n12299,12300,12301,12302,12303,12304,12305,12306,12307,12308,12309,12310,\n12311,12312,12313,12314,12315,12316,12317,12318,12319,12320,12321,12322,\n12323,12324,12325,12326,12327,12328,12329,12330,12331,12332,12333,12334,\n12335,12336,12337,12338,12339,12340,12341,12342,12343,12344,12345,12346,\n12347,12348,12349,12350,12351,12352,12353,12354,12355,12356,12357,12358,\n12359,12360,12361,12362,12363,12364,12365,12366,12367,12368,12369,12370,\n12371,12372,12373,12374,12375,12376,12377,12378,12379,12380,12381,12382,\n12383,12384,12385,12386,12387,12388,12389,12390,12391,12392,12393,12394,\n12395,12396,12397,12398,12399,12400,12401,12402,12403,12404,12405,12406,\n12407,12408,12409,12410,12411,12412,12413,12414,12415,12416,12417,12418,\n12419,12420,12421,12422,12423,12424,12425,12426,12427,12428,12429,12430,\n12431,12432,12433,12434,12435,12436,12437,12438,12439,12440,12441,12442,\n12443,12444,12445,12446,12447,12448,12449,12450,12451,12452,12453,12454,\n12455,12456,12457,12458,12459,12460,12461,12462,12463,12464,12465,12466,\n12467,12468,12469,12470,12471,12472,12473,12474,12475,12476,12477,12478,\n12479,12480,12481,12482,12483,12484,12485,12486,12487,12488,12489,12490,\n12491,12492,12493,12494,12495,12496,12497,12498,12499,12500,12501,12502,\n12503,12504,12505,12506,12507,12508,12509,12510,12511,12512,12513,12514,\n12515,12516,12517,12518,12519,12520,12521,12522,12523,12524,12525,12526,\n12527,12528,12529,12530,12531,12532,12533,12534,12535,12536,12537,12538,\n12539,12540,12541,12542,12543,12544,12545,12546,12547,12548,12549,12550,\n12551,12552,12553,12554,12555,12556,12557,12558,12559,12560,12561,12562,\n12563,12564,12565,12566,12567,12568,12569,12570,12571,12572,12573,12574,\n12575,12576,12577,12578,12579,12580,12581,12582,12583,12584,12585,12586,\n12587,12588,12589,12590,12591,12592,12593,12594,12595,12596,12597,12598,\n12599,12600,12601,12602,12603,12604,12605,12606,12607,12608,12609,12610,\n12611,12612,12613,12614,12615,12616,12617,12618,12619,12620,12621,12622,\n12623,12624,12625,12626,12627,12628,12629,12630,12631,12632,12633,12634,\n12635,12636,12637,12638,12639,12640,12641,12642,12643,12644,12645,12646,\n12647,12648,12649,12650,12651,12652,12653,12654,12655,12656,12657,12658,\n12659,12660,12661,12662,12663,12664,12665,12666,12667,12668,12669,12670,\n12671,12672,12673,12674,12675,12676,12677,12678,12679,12680,12681,12682,\n12683,12684,12685,12686,12687,12688,12689,12690,12691,12692,12693,12694,\n12695,12696,12697,12698,12699,12700,12701,12702,12703,12704,12705,12706,\n12707,12708,12709,12710,12711,12712,12713,12714,12715,12716,12717,12718,\n12719,12720,12721,12722,12723,12724,12725,12726,12727,12728,12729,12730,\n12731,12732,12733,12734,12735,12736,12737,12738,12739,12740,12741,12742,\n12743,12744,12745,12746,12747,12748,12749,12750,12751,12752,12753,12754,\n12755,12756,12757,12758,12759,12760,12761,12762,12763,12764,12765,12766,\n12767,12768,12769,12770,12771,12772,12773,12774,12775,12776,12777,12778,\n12779,12780,12781,12782,12783,12784,12785,12786,12787,12788,12789,12790,\n12791,12792,12793,12794,12795,12796,12797,12798,12799,12800,12801,12802,\n12803,12804,12805,12806,12807,12808,12809,12810,12811,12812,12813,12814,\n12815,12816,12817,12818,12819,12820,12821,12822,12823,12824,12825,12826,\n12827,12828,12829,12830,12831,12832,12833,12834,12835,12836,12837,12838,\n12839,12840,12841,12842,12843,12844,12845,12846,12847,12848,12849,12850,\n12851,12852,12853,12854,12855,12856,12857,12858,12859,12860,12861,12862,\n12863,12864,12865,12866,12867,12868,12869,12870,12871,12872,12873,12874,\n12875,12876,12877,12878,12879,12880,12881,12882,12883,12884,12885,12886,\n12887,12888,12889,12890,12891,12892,12893,12894,12895,12896,12897,12898,\n12899,12900,12901,12902,12903,12904,12905,12906,12907,12908,12909,12910,\n12911,12912,12913,12914,12915,12916,12917,12918,12919,12920,12921,12922,\n12923,12924,12925,12926,12927,12928,12929,12930,12931,12932,12933,12934,\n12935,12936,12937,12938,12939,12940,12941,12942,12943,12944,12945,12946,\n12947,12948,12949,12950,12951,12952,12953,12954,12955,12956,12957,12958,\n12959,12960,12961,12962,12963,12964,12965,12966,12967,12968,12969,12970,\n12971,12972,12973,12974,12975,12976,12977,12978,12979,12980,12981,12982,\n12983,12984,12985,12986,12987,12988,12989,12990,12991,12992,12993,12994,\n12995,12996,12997,12998,12999,13000,13001,13002,13003,13004,13005,13006,\n13007,13008,13009,13010,13011,13012,13013,13014,13015,13016,13017,13018,\n13019,13020,13021,13022,13023,13024,13025,13026,13027,13028,13029,13030,\n13031,13032,13033,13034,13035,13036,13037,13038,13039,13040,13041,13042,\n13043,13044,13045,13046,13047,13048,13049,13050,13051,13052,13053,13054,\n13055,13056,13057,13058,13059,13060,13061,13062,13063,13064,13065,13066,\n13067,13068,13069,13070,13071,13072,13073,13074,13075,13076,13077,13078,\n13079,13080,13081,13082,13083,13084,13085,13086,13087,13088,13089,13090,\n13091,13092,13093,13094,13095,13096,13097,13098,13099,13100,13101,13102,\n13103,13104,13105,13106,13107,13108,13109,13110,13111,13112,13113,13114,\n13115,13116,13117,13118,13119,13120,13121,13122,13123,13124,13125,13126,\n13127,13128,13129,13130,13131,13132,13133,13134,13135,13136,13137,13138,\n13139,13140,13141,13142,13143,13144,13145,13146,13147,13148,13149,13150,\n13151,13152,13153,13154,13155,13156,13157,13158,13159,13160,13161,13162,\n13163,13164,13165,13166,13167,13168,13169,13170,13171,13172,13173,13174,\n13175,13176,13177,13178,13179,13180,13181,13182,13183,13184,13185,13186,\n13187,13188,13189,13190,13191,13192,13193,13194,13195,13196,13197,13198,\n13199,13200,13201,13202,13203,13204,13205,13206,13207,13208,13209,13210,\n13211,13212,13213,13214,13215,13216,13217,13218,13219,13220,13221,13222,\n13223,13224,13225,13226,13227,13228,13229,13230,13231,13232,13233,13234,\n13235,13236,13237,13238,13239,13240,13241,13242,13243,13244,13245,13246,\n13247,13248,13249,13250,13251,13252,13253,13254,13255,13256,13257,13258,\n13259,13260,13261,13262,13263,13264,13265,13266,13267,13268,13269,13270,\n13271,13272,13273,13274,13275,13276,13277,13278,13279,13280,13281,13282,\n13283,13284,13285,13286,13287,13288,13289,13290,13291,13292,13293,13294,\n13295,13296,13297,13298,13299,13300,13301,13302,13303,13304,13305,13306,\n13307,13308,13309,13310,13311,13312,13313,13314,13315,13316,13317,13318,\n13319,13320,13321,13322,13323,13324,13325,13326,13327,13328,13329,13330,\n13331,13332,13333,13334,13335,13336,13337,13338,13339,13340,13341,13342,\n13343,13344,13345,13346,13347,13348,13349,13350,13351,13352,13353,13354,\n13355,13356,13357,13358,13359,13360,13361,13362,13363,13364,13365,13366,\n13367,13368,13369,13370,13371,13372,13373,13374,13375,13376,13377,13378,\n13379,13380,13381,13382,13383,13384,13385,13386,13387,13388,13389,13390,\n13391,13392,13393,13394,13395,13396,13397,13398,13399,13400,13401,13402,\n13403,13404,13405,13406,13407,13408,13409,13410,13411,13412,13413,13414,\n13415,13416,13417,13418,13419,13420,13421,13422,13423,13424,13425,13426,\n13427,13428,13429,13430,13431,13432,13433,13434,13435,13436,13437,13438,\n13439,13440,13441,13442,13443,13444,13445,13446,13447,13448,13449,13450,\n13451,13452,13453,13454,13455,13456,13457,13458,13459,13460,13461,13462,\n13463,13464,13465,13466,13467,13468,13469,13470,13471,13472,13473,13474,\n13475,13476,13477,13478,13479,13480,13481,13482,13483,13484,13485,13486,\n13487,13488,13489,13490,13491,13492,13493,13494,13495,13496,13497,13498,\n13499,13500,13501,13502,13503,13504,13505,13506,13507,13508,13509,13510,\n13511,13512,13513,13514,13515,13516,13517,13518,13519,13520,13521,13522,\n13523,13524,13525,13526,13527,13528,13529,13530,13531,13532,13533,13534,\n13535,13536,13537,13538,13539,13540,13541,13542,13543,13544,13545,13546,\n13547,13548,13549,13550,13551,13552,13553,13554,13555,13556,13557,13558,\n13559,13560,13561,13562,13563,13564,13565,13566,13567,13568,13569,13570,\n13571,13572,13573,13574,13575,13576,13577,13578,13579,13580,13581,13582,\n13583,13584,13585,13586,13587,13588,13589,13590,13591,13592,13593,13594,\n13595,13596,13597,13598,13599,13600,13601,13602,13603,13604,13605,13606,\n13607,13608,13609,13610,13611,13612,13613,13614,13615,13616,13617,13618,\n13619,13620,13621,13622,13623,13624,13625,13626,13627,13628,13629,13630,\n13631,13632,13633,13634,13635,13636,13637,13638,13639,13640,13641,13642,\n13643,13644,13645,13646,13647,13648,13649,13650,13651,13652,13653,13654,\n13655,13656,13657,13658,13659,13660,13661,13662,13663,13664,13665,13666,\n13667,13668,13669,13670,13671,13672,13673,13674,13675,13676,13677,13678,\n13679,13680,13681,13682,13683,13684,13685,13686,13687,13688,13689,13690,\n13691,13692,13693,13694,13695,13696,13697,13698,13699,13700,13701,13702,\n13703,13704,13705,13706,13707,13708,13709,13710,13711,13712,13713,13714,\n13715,13716,13717,13718,13719,13720,13721,13722,13723,13724,13725,13726,\n13727,13728,13729,13730,13731,13732,13733,13734,13735,13736,13737,13738,\n13739,13740,13741,13742,13743,13744,13745,13746,13747,13748,13749,13750,\n13751,13752,13753,13754,13755,13756,13757,13758,13759,13760,13761,13762,\n13763,13764,13765,13766,13767,13768,13769,13770,13771,13772,13773,13774,\n13775,13776,13777,13778,13779,13780,13781,13782,13783,13784,13785,13786,\n13787,13788,13789,13790,13791,13792,13793,13794,13795,13796,13797,13798,\n13799,13800,13801,13802,13803,13804,13805,13806,13807,13808,13809,13810,\n13811,13812,13813,13814,13815,13816,13817,13818,13819,13820,13821,13822,\n13823,13824,13825,13826,13827,13828,13829,13830,13831,13832,13833,13834,\n13835,13836,13837,13838,13839,13840,13841,13842,13843,13844,13845,13846,\n13847,13848,13849,13850,13851,13852,13853,13854,13855,13856,13857,13858,\n13859,13860,13861,13862,13863,13864,13865,13866,13867,13868,13869,13870,\n13871,13872,13873,13874,13875,13876,13877,13878,13879,13880,13881,13882,\n13883,13884,13885,13886,13887,13888,13889,13890,13891,13892,13893,13894,\n13895,13896,13897,13898,13899,13900,13901,13902,13903,13904,13905,13906,\n13907,13908,13909,13910,13911,13912,13913,13914,13915,13916,13917,13918,\n13919,13920,13921,13922,13923,13924,13925,13926,13927,13928,13929,13930,\n13931,13932,13933,13934,13935,13936,13937,13938,13939,13940,13941,13942,\n13943,13944,13945,13946,13947,13948,13949,13950,13951,13952,13953,13954,\n13955,13956,13957,13958,13959,13960,13961,13962,13963,13964,13965,13966,\n13967,13968,13969,13970,13971,13972,13973,13974,13975,13976,13977,13978,\n13979,13980,13981,13982,13983,13984,13985,13986,13987,13988,13989,13990,\n13991,13992,13993,13994,13995,13996,13997,13998,13999,14000,14001,14002,\n14003,14004,14005,14006,14007,14008,14009,14010,14011,14012,14013,14014,\n14015,14016,14017,14018,14019,14020,14021,14022,14023,14024,14025,14026,\n14027,14028,14029,14030,14031,14032,14033,14034,14035,14036,14037,14038,\n14039,14040,14041,14042,14043,14044,14045,14046,14047,14048,14049,14050,\n14051,14052,14053,14054,14055,14056,14057,14058,14059,14060,14061,14062,\n14063,14064,14065,14066,14067,14068,14069,14070,14071,14072,14073,14074,\n14075,14076,14077,14078,14079,14080,14081,14082,14083,14084,14085,14086,\n14087,14088,14089,14090,14091,14092,14093,14094,14095,14096,14097,14098,\n14099,14100,14101,14102,14103,14104,14105,14106,14107,14108,14109,14110,\n14111,14112,14113,14114,14115,14116,14117,14118,14119,14120,14121,14122,\n14123,14124,14125,14126,14127,14128,14129,14130,14131,14132,14133,14134,\n14135,14136,14137,14138,14139,14140,14141,14142,14143,14144,14145,14146,\n14147,14148,14149,14150,14151,14152,14153,14154,14155,14156,14157,14158,\n14159,14160,14161,14162,14163,14164,14165,14166,14167,14168,14169,14170,\n14171,14172,14173,14174,14175,14176,14177,14178,14179,14180,14181,14182,\n14183,14184,14185,14186,14187,14188,14189,14190,14191,14192,14193,14194,\n14195,14196,14197,14198,14199,14200,14201,14202,14203,14204,14205,14206,\n14207,14208,14209,14210,14211,14212,14213,14214,14215,14216,14217,14218,\n14219,14220,14221,14222,14223,14224,14225,14226,14227,14228,14229,14230,\n14231,14232,14233,14234,14235,14236,14237,14238,14239,14240,14241,14242,\n14243,14244,14245,14246,14247,14248,14249,14250,14251,14252,14253,14254,\n14255,14256,14257,14258,14259,14260,14261,14262,14263,14264,14265,14266,\n14267,14268,14269,14270,14271,14272,14273,14274,14275,14276,14277,14278,\n14279,14280,14281,14282,14283,14284,14285,14286,14287,14288,14289,14290,\n14291,14292,14293,14294,14295,14296,14297,14298,14299,14300,14301,14302,\n14303,14304,14305,14306,14307,14308,14309,14310,14311,14312,14313,14314,\n14315,14316,14317,14318,14319,14320,14321,14322,14323,14324,14325,14326,\n14327,14328,14329,14330,14331,14332,14333,14334,14335,14336,14337,14338,\n14339,14340,14341,14342,14343,14344,14345,14346,14347,14348,14349,14350,\n14351,14352,14353,14354,14355,14356,14357,14358,14359,14360,14361,14362,\n14363,14364,14365,14366,14367,14368,14369,14370,14371,14372,14373,14374,\n14375,14376,14377,14378,14379,14380,14381,14382,14383,14384,14385,14386,\n14387,14388,14389,14390,14391,14392,14393,14394,14395,14396,14397,14398,\n14399,14400,14401,14402,14403,14404,14405,14406,14407,14408,14409,14410,\n14411,14412,14413,14414,14415,14416,14417,14418,14419,14420,14421,14422,\n14423,14424,14425,14426,14427,14428,14429,14430,14431,14432,14433,14434,\n14435,14436,14437,14438,14439,14440,14441,14442,14443,14444,14445,14446,\n14447,14448,14449,14450,14451,14452,14453,14454,14455,14456,14457,14458,\n14459,14460,14461,14462,14463,14464,14465,14466,14467,14468,14469,14470,\n14471,14472,14473,14474,14475,14476,14477,14478,14479,14480,14481,14482,\n14483,14484,14485,14486,14487,14488,14489,14490,14491,14492,14493,14494,\n14495,14496,14497,14498,14499,14500,14501,14502,14503,14504,14505,14506,\n14507,14508,14509,14510,14511,14512,14513,14514,14515,14516,14517,14518,\n14519,14520,14521,14522,14523,14524,14525,14526,14527,14528,14529,14530,\n14531,14532,14533,14534,14535,14536,14537,14538,14539,14540,14541,14542,\n14543,14544,14545,14546,14547,14548,14549,14550,14551,14552,14553,14554,\n14555,14556,14557,14558,14559,14560,14561,14562,14563,14564,14565,14566,\n14567,14568,14569,14570,14571,14572,14573,14574,14575,14576,14577,14578,\n14579,14580,14581,14582,14583,14584,14585,14586,14587,14588,14589,14590,\n14591,14592,14593,14594,14595,14596,14597,14598,14599,14600,14601,14602,\n14603,14604,14605,14606,14607,14608,14609,14610,14611,14612,14613,14614,\n14615,14616,14617,14618,14619,14620,14621,14622,14623,14624,14625,14626,\n14627,14628,14629,14630,14631,14632,14633,14634,14635,14636,14637,14638,\n14639,14640,14641,14642,14643,14644,14645,14646,14647,14648,14649,14650,\n14651,14652,14653,14654,14655,14656,14657,14658,14659,14660,14661,14662,\n14663,14664,14665,14666,14667,14668,14669,14670,14671,14672,14673,14674,\n14675,14676,14677,14678,14679,14680,14681,14682,14683,14684,14685,14686,\n14687,14688,14689,14690,14691,14692,14693,14694,14695,14696,14697,14698,\n14699,14700,14701,14702,14703,14704,14705,14706,14707,14708,14709,14710,\n14711,14712,14713,14714,14715,14716,14717,14718,14719,14720,14721,14722,\n14723,14724,14725,14726,14727,14728,14729,14730,14731,14732,14733,14734,\n14735,14736,14737,14738,14739,14740,14741,14742,14743,14744,14745,14746,\n14747,14748,14749,14750,14751,14752,14753,14754,14755,14756,14757,14758,\n14759,14760,14761,14762,14763,14764,14765,14766,14767,14768,14769,14770,\n14771,14772,14773,14774,14775,14776,14777,14778,14779,14780,14781,14782,\n14783,14784,14785,14786,14787,14788,14789,14790,14791,14792,14793,14794,\n14795,14796,14797,14798,14799,14800,14801,14802,14803,14804,14805,14806,\n14807,14808,14809,14810,14811,14812,14813,14814,14815,14816,14817,14818,\n14819,14820,14821,14822,14823,14824,14825,14826,14827,14828,14829,14830,\n14831,14832,14833,14834,14835,14836,14837,14838,14839,14840,14841,14842,\n14843,14844,14845,14846,14847,14848,14849,14850,14851,14852,14853,14854,\n14855,14856,14857,14858,14859,14860,14861,14862,14863,14864,14865,14866,\n14867,14868,14869,14870,14871,14872,14873,14874,14875,14876,14877,14878,\n14879,14880,14881,14882,14883,14884,14885,14886,14887,14888,14889,14890,\n14891,14892,14893,14894,14895,14896,14897,14898,14899,14900,14901,14902,\n14903,14904,14905,14906,14907,14908,14909,14910,14911,14912,14913,14914,\n14915,14916,14917,14918,14919,14920,14921,14922,14923,14924,14925,14926,\n14927,14928,14929,14930,14931,14932,14933,14934,14935,14936,14937,14938,\n14939,14940,14941,14942,14943,14944,14945,14946,14947,14948,14949,14950,\n14951,14952,14953,14954,14955,14956,14957,14958,14959,14960,14961,14962,\n14963,14964,14965,14966,14967,14968,14969,14970,14971,14972,14973,14974,\n14975,14976,14977,14978,14979,14980,14981,14982,14983,14984,14985,14986,\n14987,14988,14989,14990,14991,14992,14993,14994,14995,14996,14997,14998,\n14999,15000,15001,15002,15003,15004,15005,15006,15007,15008,15009,15010,\n15011,15012,15013,15014,15015,15016,15017,15018,15019,15020,15021,15022,\n15023,15024,15025,15026,15027,15028,15029,15030,15031,15032,15033,15034,\n15035,15036,15037,15038,15039,15040,15041,15042,15043,15044,15045,15046,\n15047,15048,15049,15050,15051,15052,15053,15054,15055,15056,15057,15058,\n15059,15060,15061,15062,15063,15064,15065,15066,15067,15068,15069,15070,\n15071,15072,15073,15074,15075,15076,15077,15078,15079,15080,15081,15082,\n15083,15084,15085,15086,15087,15088,15089,15090,15091,15092,15093,15094,\n15095,15096,15097,15098,15099,15100,15101,15102,15103,15104,15105,15106,\n15107,15108,15109,15110,15111,15112,15113,15114,15115,15116,15117,15118,\n15119,15120,15121,15122,15123,15124,15125,15126,15127,15128,15129,15130,\n15131,15132,15133,15134,15135,15136,15137,15138,15139,15140,15141,15142,\n15143,15144,15145,15146,15147,15148,15149,15150,15151,15152,15153,15154,\n15155,15156,15157,15158,15159,15160,15161,15162,15163,15164,15165,15166,\n15167,15168,15169,15170,15171,15172,15173,15174,15175,15176,15177,15178,\n15179,15180,15181,15182,15183,15184,15185,15186,15187,15188,15189,15190,\n15191,15192,15193,15194,15195,15196,15197,15198,15199,15200,15201,15202,\n15203,15204,15205,15206,15207,15208,15209,15210,15211,15212,15213,15214,\n15215,15216,15217,15218,15219,15220,15221,15222,15223,15224,15225,15226,\n15227,15228,15229,15230,15231,15232,15233,15234,15235,15236,15237,15238,\n15239,15240,15241,15242,15243,15244,15245,15246,15247,15248,15249,15250,\n15251,15252,15253,15254,15255,15256,15257,15258,15259,15260,15261,15262,\n15263,15264,15265,15266,15267,15268,15269,15270,15271,15272,15273,15274,\n15275,15276,15277,15278,15279,15280,15281,15282,15283,15284,15285,15286,\n15287,15288,15289,15290,15291,15292,15293,15294,15295,15296,15297,15298,\n15299,15300,15301,15302,15303,15304,15305,15306,15307,15308,15309,15310,\n15311,15312,15313,15314,15315,15316,15317,15318,15319,15320,15321,15322,\n15323,15324,15325,15326,15327,15328,15329,15330,15331,15332,15333,15334,\n15335,15336,15337,15338,15339,15340,15341,15342,15343,15344,15345,15346,\n15347,15348,15349,15350,15351,15352,15353,15354,15355,15356,15357,15358,\n15359,15360,15361,15362,15363,15364,15365,15366,15367,15368,15369,15370,\n15371,15372,15373,15374,15375,15376,15377,15378,15379,15380,15381,15382,\n15383,15384,15385,15386,15387,15388,15389,15390,15391,15392,15393,15394,\n15395,15396,15397,15398,15399,15400,15401,15402,15403,15404,15405,15406,\n15407,15408,15409,15410,15411,15412,15413,15414,15415,15416,15417,15418,\n15419,15420,15421,15422,15423,15424,15425,15426,15427,15428,15429,15430,\n15431,15432,15433,15434,15435,15436,15437,15438,15439,15440,15441,15442,\n15443,15444,15445,15446,15447,15448,15449,15450,15451,15452,15453,15454,\n15455,15456,15457,15458,15459,15460,15461,15462,15463,15464,15465,15466,\n15467,15468,15469,15470,15471,15472,15473,15474,15475,15476,15477,15478,\n15479,15480,15481,15482,15483,15484,15485,15486,15487,15488,15489,15490,\n15491,15492,15493,15494,15495,15496,15497,15498,15499,15500,15501,15502,\n15503,15504,15505,15506,15507,15508,15509,15510,15511,15512,15513,15514,\n15515,15516,15517,15518,15519,15520,15521,15522,15523,15524,15525,15526,\n15527,15528,15529,15530,15531,15532,15533,15534,15535,15536,15537,15538,\n15539,15540,15541,15542,15543,15544,15545,15546,15547,15548,15549,15550,\n15551,15552,15553,15554,15555,15556,15557,15558,15559,15560,15561,15562,\n15563,15564,15565,15566,15567,15568,15569,15570,15571,15572,15573,15574,\n15575,15576,15577,15578,15579,15580,15581,15582,15583,15584,15585,15586,\n15587,15588,15589,15590,15591,15592,15593,15594,15595,15596,15597,15598,\n15599,15600,15601,15602,15603,15604,15605,15606,15607,15608,15609,15610,\n15611,15612,15613,15614,15615,15616,15617,15618,15619,15620,15621,15622,\n15623,15624,15625,15626,15627,15628,15629,15630,15631,15632,15633,15634,\n15635,15636,15637,15638,15639,15640,15641,15642,15643,15644,15645,15646,\n15647,15648,15649,15650,15651,15652,15653,15654,15655,15656,15657,15658,\n15659,15660,15661,15662,15663,15664,15665,15666,15667,15668,15669,15670,\n15671,15672,15673,15674,15675,15676,15677,15678,15679,15680,15681,15682,\n15683,15684,15685,15686,15687,15688,15689,15690,15691,15692,15693,15694,\n15695,15696,15697,15698,15699,15700,15701,15702,15703,15704,15705,15706,\n15707,15708,15709,15710,15711,15712,15713,15714,15715,15716,15717,15718,\n15719,15720,15721,15722,15723,15724,15725,15726,15727,15728,15729,15730,\n15731,15732,15733,15734,15735,15736,15737,15738,15739,15740,15741,15742,\n15743,15744,15745,15746,15747,15748,15749,15750,15751,15752,15753,15754,\n15755,15756,15757,15758,15759,15760,15761,15762,15763,15764,15765,15766,\n15767,15768,15769,15770,15771,15772,15773,15774,15775,15776,15777,15778,\n15779,15780,15781,15782,15783,15784,15785,15786,15787,15788,15789,15790,\n15791,15792,15793,15794,15795,15796,15797,15798,15799,15800,15801,15802,\n15803,15804,15805,15806,15807,15808,15809,15810,15811,15812,15813,15814,\n15815,15816,15817,15818,15819,15820,15821,15822,15823,15824,15825,15826,\n15827,15828,15829,15830,15831,15832,15833,15834,15835,15836,15837,15838,\n15839,15840,15841,15842,15843,15844,15845,15846,15847,15848,15849,15850,\n15851,15852,15853,15854,15855,15856,15857,15858,15859,15860,15861,15862,\n15863,15864,15865,15866,15867,15868,15869,15870,15871,15872,15873,15874,\n15875,15876,15877,15878,15879,15880,15881,15882,15883,15884,15885,15886,\n15887,15888,15889,15890,15891,15892,15893,15894,15895,15896,15897,15898,\n15899,15900,15901,15902,15903,15904,15905,15906,15907,15908,15909,15910,\n15911,15912,15913,15914,15915,15916,15917,15918,15919,15920,15921,15922,\n15923,15924,15925,15926,15927,15928,15929,15930,15931,15932,15933,15934,\n15935,15936,15937,15938,15939,15940,15941,15942,15943,15944,15945,15946,\n15947,15948,15949,15950,15951,15952,15953,15954,15955,15956,15957,15958,\n15959,15960,15961,15962,15963,15964,15965,15966,15967,15968,15969,15970,\n15971,15972,15973,15974,15975,15976,15977,15978,15979,15980,15981,15982,\n15983,15984,15985,15986,15987,15988,15989,15990,15991,15992,15993,15994,\n15995,15996,15997,15998,15999,16000,16001,16002,16003,16004,16005,16006,\n16007,16008,16009,16010,16011,16012,16013,16014,16015,16016,16017,16018,\n16019,16020,16021,16022,16023,16024,16025,16026,16027,16028,16029,16030,\n16031,16032,16033,16034,16035,16036,16037,16038,16039,16040,16041,16042,\n16043,16044,16045,16046,16047,16048,16049,16050,16051,16052,16053,16054,\n16055,16056,16057,16058,16059,16060,16061,16062,16063,16064,16065,16066,\n16067,16068,16069,16070,16071,16072,16073,16074,16075,16076,16077,16078,\n16079,16080,16081,16082,16083,16084,16085,16086,16087,16088,16089,16090,\n16091,16092,16093,16094,16095,16096,16097,16098,16099,16100,16101,16102,\n16103,16104,16105,16106,16107,16108,16109,16110,16111,16112,16113,16114,\n16115,16116,16117,16118,16119,16120,16121,16122,16123,16124,16125,16126,\n16127,16128,16129,16130,16131,16132,16133,16134,16135,16136,16137,16138,\n16139,16140,16141,16142,16143,16144,16145,16146,16147,16148,16149,16150,\n16151,16152,16153,16154,16155,16156,16157,16158,16159,16160,16161,16162,\n16163,16164,16165,16166,16167,16168,16169,16170,16171,16172,16173,16174,\n16175,16176,16177,16178,16179,16180,16181,16182,16183,16184,16185,16186,\n16187,16188,16189,16190,16191,16192,16193,16194,16195,16196,16197,16198,\n16199,16200,16201,16202,16203,16204,16205,16206,16207,16208,16209,16210,\n16211,16212,16213,16214,16215,16216,16217,16218,16219,16220,16221,16222,\n16223,16224,16225,16226,16227,16228,16229,16230,16231,16232,16233,16234,\n16235,16236,16237,16238,16239,16240,16241,16242,16243,16244,16245,16246,\n16247,16248,16249,16250,16251,16252,16253,16254,16255,16256,16257,16258,\n16259,16260,16261,16262,16263,16264,16265,16266,16267,16268,16269,16270,\n16271,16272,16273,16274,16275,16276,16277,16278,16279,16280,16281,16282,\n16283,16284,16285,16286,16287,16288,16289,16290,16291,16292,16293,16294,\n16295,16296,16297,16298,16299,16300,16301,16302,16303,16304,16305,16306,\n16307,16308,16309,16310,16311,16312,16313,16314,16315,16316,16317,16318,\n16319,16320,16321,16322,16323,16324,16325,16326,16327,16328,16329,16330,\n16331,16332,16333,16334,16335,16336,16337,16338,16339,16340,16341,16342,\n16343,16344,16345,16346,16347,16348,16349,16350,16351,16352,16353,16354,\n16355,16356,16357,16358,16359,16360,16361,16362,16363,16364,16365,16366,\n16367,16368,16369,16370,16371,16372,16373,16374,16375,16376,16377,16378,\n16379,16380,16381,16382,16383,16384,16385,16386,16387,16388,16389,16390,\n16391,16392,16393,16394,16395,16396,16397,16398,16399,16400,16401,16402,\n16403,16404,16405,16406,16407,16408,16409,16410,16411,16412,16413,16414,\n16415,16416,16417,16418,16419,16420,16421,16422,16423,16424,16425,16426,\n16427,16428,16429,16430,16431,16432,16433,16434,16435,16436,16437,16438,\n16439,16440,16441,16442,16443,16444,16445,16446,16447,16448,16449,16450,\n16451,16452,16453,16454,16455,16456,16457,16458,16459,16460,16461,16462,\n16463,16464,16465,16466,16467,16468,16469,16470,16471,16472,16473,16474,\n16475,16476,16477,16478,16479,16480,16481,16482,16483,16484,16485,16486,\n16487,16488,16489,16490,16491,16492,16493,16494,16495,16496,16497,16498,\n16499,16500,16501,16502,16503,16504,16505,16506,16507,16508,16509,16510,\n16511,16512,16513,16514,16515,16516,16517,16518,16519,16520,16521,16522,\n16523,16524,16525,16526,16527,16528,16529,16530,16531,16532,16533,16534,\n16535,16536,16537,16538,16539,16540,16541,16542,16543,16544,16545,16546,\n16547,16548,16549,16550,16551,16552,16553,16554,16555,16556,16557,16558,\n16559,16560,16561,16562,16563,16564,16565,16566,16567,16568,16569,16570,\n16571,16572,16573,16574,16575,16576,16577,16578,16579,16580,16581,16582,\n16583,16584,16585,16586,16587,16588,16589,16590,16591,16592,16593,16594,\n16595,16596,16597,16598,16599,16600,16601,16602,16603,16604,16605,16606,\n16607,16608,16609,16610,16611,16612,16613,16614,16615,16616,16617,16618,\n16619,16620,16621,16622,16623,16624,16625,16626,16627,16628,16629,16630,\n16631,16632,16633,16634,16635,16636,16637,16638,16639,16640,16641,16642,\n16643,16644,16645,16646,16647,16648,16649,16650,16651,16652,16653,16654,\n16655,16656,16657,16658,16659,16660,16661,16662,16663,16664,16665,16666,\n16667,16668,16669,16670,16671,16672,16673,16674,16675,16676,16677,16678,\n16679,16680,16681,16682,16683,16684,16685,16686,16687,16688,16689,16690,\n16691,16692,16693,16694,16695,16696,16697,16698,16699,16700,16701,16702,\n16703,16704,16705,16706,16707,16708,16709,16710,16711,16712,16713,16714,\n16715,16716,16717,16718,16719,16720,16721,16722,16723,16724,16725,16726,\n16727,16728,16729,16730,16731,16732,16733,16734,16735,16736,16737,16738,\n16739,16740,16741,16742,16743,16744,16745,16746,16747,16748,16749,16750,\n16751,16752,16753,16754,16755,16756,16757,16758,16759,16760,16761,16762,\n16763,16764,16765,16766,16767,16768,16769,16770,16771,16772,16773,16774,\n16775,16776,16777,16778,16779,16780,16781,16782,16783,16784,16785,16786,\n16787,16788,16789,16790,16791,16792,16793,16794,16795,16796,16797,16798,\n16799,16800,16801,16802,16803,16804,16805,16806,16807,16808,16809,16810,\n16811,16812,16813,16814,16815,16816,16817,16818,16819,16820,16821,16822,\n16823,16824,16825,16826,16827,16828,16829,16830,16831,16832,16833,16834,\n16835,16836,16837,16838,16839,16840,16841,16842,16843,16844,16845,16846,\n16847,16848,16849,16850,16851,16852,16853,16854,16855,16856,16857,16858,\n16859,16860,16861,16862,16863,16864,16865,16866,16867,16868,16869,16870,\n16871,16872,16873,16874,16875,16876,16877,16878,16879,16880,16881,16882,\n16883,16884,16885,16886,16887,16888,16889,16890,16891,16892,16893,16894,\n16895,16896,16897,16898,16899,16900,16901,16902,16903,16904,16905,16906,\n16907,16908,16909,16910,16911,16912,16913,16914,16915,16916,16917,16918,\n16919,16920,16921,16922,16923,16924,16925,16926,16927,16928,16929,16930,\n16931,16932,16933,16934,16935,16936,16937,16938,16939,16940,16941,16942,\n16943,16944,16945,16946,16947,16948,16949,16950,16951,16952,16953,16954,\n16955,16956,16957,16958,16959,16960,16961,16962,16963,16964,16965,16966,\n16967,16968,16969,16970,16971,16972,16973,16974,16975,16976,16977,16978,\n16979,16980,16981,16982,16983,16984,16985,16986,16987,16988,16989,16990,\n16991,16992,16993,16994,16995,16996,16997,16998,16999,17000,17001,17002,\n17003,17004,17005,17006,17007,17008,17009,17010,17011,17012,17013,17014,\n17015,17016,17017,17018,17019,17020,17021,17022,17023,17024,17025,17026,\n17027,17028,17029,17030,17031,17032,17033,17034,17035,17036,17037,17038,\n17039,17040,17041,17042,17043,17044,17045,17046,17047,17048,17049,17050,\n17051,17052,17053,17054,17055,17056,17057,17058,17059,17060,17061,17062,\n17063,17064,17065,17066,17067,17068,17069,17070,17071,17072,17073,17074,\n17075,17076,17077,17078,17079,17080,17081,17082,17083,17084,17085,17086,\n17087,17088,17089,17090,17091,17092,17093,17094,17095,17096,17097,17098,\n17099,17100,17101,17102,17103,17104,17105,17106,17107,17108,17109,17110,\n17111,17112,17113,17114,17115,17116,17117,17118,17119,17120,17121,17122,\n17123,17124,17125,17126,17127,17128,17129,17130,17131,17132,17133,17134,\n17135,17136,17137,17138,17139,17140,17141,17142,17143,17144,17145,17146,\n17147,17148,17149,17150,17151,17152,17153,17154,17155,17156,17157,17158,\n17159,17160,17161,17162,17163,17164,17165,17166,17167,17168,17169,17170,\n17171,17172,17173,17174,17175,17176,17177,17178,17179,17180,17181,17182,\n17183,17184,17185,17186,17187,17188,17189,17190,17191,17192,17193,17194,\n17195,17196,17197,17198,17199,17200,17201,17202,17203,17204,17205,17206,\n17207,17208,17209,17210,17211,17212,17213,17214,17215,17216,17217,17218,\n17219,17220,17221,17222,17223,17224,17225,17226,17227,17228,17229,17230,\n17231,17232,17233,17234,17235,17236,17237,17238,17239,17240,17241,17242,\n17243,17244,17245,17246,17247,17248,17249,17250,17251,17252,17253,17254,\n17255,17256,17257,17258,17259,17260,17261,17262,17263,17264,17265,17266,\n17267,17268,17269,17270,17271,17272,17273,17274,17275,17276,17277,17278,\n17279,17280,17281,17282,17283,17284,17285,17286,17287,17288,17289,17290,\n17291,17292,17293,17294,17295,17296,17297,17298,17299,17300,17301,17302,\n17303,17304,17305,17306,17307,17308,17309,17310,17311,17312,17313,17314,\n17315,17316,17317,17318,17319,17320,17321,17322,17323,17324,17325,17326,\n17327,17328,17329,17330,17331,17332,17333,17334,17335,17336,17337,17338,\n17339,17340,17341,17342,17343,17344,17345,17346,17347,17348,17349,17350,\n17351,17352,17353,17354,17355,17356,17357,17358,17359,17360,17361,17362,\n17363,17364,17365,17366,17367,17368,17369,17370,17371,17372,17373,17374,\n17375,17376,17377,17378,17379,17380,17381,17382,17383,17384,17385,17386,\n17387,17388,17389,17390,17391,17392,17393,17394,17395,17396,17397,17398,\n17399,17400,17401,17402,17403,17404,17405,17406,17407,17408,17409,17410,\n17411,17412,17413,17414,17415,17416,17417,17418,17419,17420,17421,17422,\n17423,17424,17425,17426,17427,17428,17429,17430,17431,17432,17433,17434,\n17435,17436,17437,17438,17439,17440,17441,17442,17443,17444,17445,17446,\n17447,17448,17449,17450,17451,17452,17453,17454,17455,17456,17457,17458,\n17459,17460,17461,17462,17463,17464,17465,17466,17467,17468,17469,17470,\n17471,17472,17473,17474,17475,17476,17477,17478,17479,17480,17481,17482,\n17483,17484,17485,17486,17487,17488,17489,17490,17491,17492,17493,17494,\n17495,17496,17497,17498,17499,17500,17501,17502,17503,17504,17505,17506,\n17507,17508,17509,17510,17511,17512,17513,17514,17515,17516,17517,17518,\n17519,17520,17521,17522,17523,17524,17525,17526,17527,17528,17529,17530,\n17531,17532,17533,17534,17535,17536,17537,17538,17539,17540,17541,17542,\n17543,17544,17545,17546,17547,17548,17549,17550,17551,17552,17553,17554,\n17555,17556,17557,17558,17559,17560,17561,17562,17563,17564,17565,17566,\n17567,17568,17569,17570,17571,17572,17573,17574,17575,17576,17577,17578,\n17579,17580,17581,17582,17583,17584,17585,17586,17587,17588,17589,17590,\n17591,17592,17593,17594,17595,17596,17597,17598,17599,17600,17601,17602,\n17603,17604,17605,17606,17607,17608,17609,17610,17611,17612,17613,17614,\n17615,17616,17617,17618,17619,17620,17621,17622,17623,17624,17625,17626,\n17627,17628,17629,17630,17631,17632,17633,17634,17635,17636,17637,17638,\n17639,17640,17641,17642,17643,17644,17645,17646,17647,17648,17649,17650,\n17651,17652,17653,17654,17655,17656,17657,17658,17659,17660,17661,17662,\n17663,17664,17665,17666,17667,17668,17669,17670,17671,17672,17673,17674,\n17675,17676,17677,17678,17679,17680,17681,17682,17683,17684,17685,17686,\n17687,17688,17689,17690,17691,17692,17693,17694,17695,17696,17697,17698,\n17699,17700,17701,17702,17703,17704,17705,17706,17707,17708,17709,17710,\n17711,17712,17713,17714,17715,17716,17717,17718,17719,17720,17721,17722,\n17723,17724,17725,17726,17727,17728,17729,17730,17731,17732,17733,17734,\n17735,17736,17737,17738,17739,17740,17741,17742,17743,17744,17745,17746,\n17747,17748,17749,17750,17751,17752,17753,17754,17755,17756,17757,17758,\n17759,17760,17761,17762,17763,17764,17765,17766,17767,17768,17769,17770,\n17771,17772,17773,17774,17775,17776,17777,17778,17779,17780,17781,17782,\n17783,17784,17785,17786,17787,17788,17789,17790,17791,17792,17793,17794,\n17795,17796,17797,17798,17799,17800,17801,17802,17803,17804,17805,17806,\n17807,17808,17809,17810,17811,17812,17813,17814,17815,17816,17817,17818,\n17819,17820,17821,17822,17823,17824,17825,17826,17827,17828,17829,17830,\n17831,17832,17833,17834,17835,17836,17837,17838,17839,17840,17841,17842,\n17843,17844,17845,17846,17847,17848,17849,17850,17851,17852,17853,17854,\n17855,17856,17857,17858,17859,17860,17861,17862,17863,17864,17865,17866,\n17867,17868,17869,17870,17871,17872,17873,17874,17875,17876,17877,17878,\n17879,17880,17881,17882,17883,17884,17885,17886,17887,17888,17889,17890,\n17891,17892,17893,17894,17895,17896,17897,17898,17899,17900,17901,17902,\n17903,17904,17905,17906,17907,17908,17909,17910,17911,17912,17913,17914,\n17915,17916,17917,17918,17919,17920,17921,17922,17923,17924,17925,17926,\n17927,17928,17929,17930,17931,17932,17933,17934,17935,17936,17937,17938,\n17939,17940,17941,17942,17943,17944,17945,17946,17947,17948,17949,17950,\n17951,17952,17953,17954,17955,17956,17957,17958,17959,17960,17961,17962,\n17963,17964,17965,17966,17967,17968,17969,17970,17971,17972,17973,17974,\n17975,17976,17977,17978,17979,17980,17981,17982,17983,17984,17985,17986,\n17987,17988,17989,17990,17991,17992,17993,17994,17995,17996,17997,17998,\n17999,18000,18001,18002,18003,18004,18005,18006,18007,18008,18009,18010,\n18011,18012,18013,18014,18015,18016,18017,18018,18019,18020,18021,18022,\n18023,18024,18025,18026,18027,18028,18029,18030,18031,18032,18033,18034,\n18035,18036,18037,18038,18039,18040,18041,18042,18043,18044,18045,18046,\n18047,18048,18049,18050,18051,18052,18053,18054,18055,18056,18057,18058,\n18059,18060,18061,18062,18063,18064,18065,18066,18067,18068,18069,18070,\n18071,18072,18073,18074,18075,18076,18077,18078,18079,18080,18081,18082,\n18083,18084,18085,18086,18087,18088,18089,18090,18091,18092,18093,18094,\n18095,18096,18097,18098,18099,18100,18101,18102,18103,18104,18105,18106,\n18107,18108,18109,18110,18111,18112,18113,18114,18115,18116,18117,18118,\n18119,18120,18121,18122,18123,18124,18125,18126,18127,18128,18129,18130,\n18131,18132,18133,18134,18135,18136,18137,18138,18139,18140,18141,18142,\n18143,18144,18145,18146,18147,18148,18149,18150,18151,18152,18153,18154,\n18155,18156,18157,18158,18159,18160,18161,18162,18163,18164,18165,18166,\n18167,18168,18169,18170,18171,18172,18173,18174,18175,18176,18177,18178,\n18179,18180,18181,18182,18183,18184,18185,18186,18187,18188,18189,18190,\n18191,18192,18193,18194,18195,18196,18197,18198,18199,18200,18201,18202,\n18203,18204,18205,18206,18207,18208,18209,18210,18211,18212,18213,18214,\n18215,18216,18217,18218,18219,18220,18221,18222,18223,18224,18225,18226,\n18227,18228,18229,18230,18231,18232,18233,18234,18235,18236,18237,18238,\n18239,18240,18241,18242,18243,18244,18245,18246,18247,18248,18249,18250,\n18251,18252,18253,18254,18255,18256,18257,18258,18259,18260,18261,18262,\n18263,18264,18265,18266,18267,18268,18269,18270,18271,18272,18273,18274,\n18275,18276,18277,18278,18279,18280,18281,18282,18283,18284,18285,18286,\n18287,18288,18289,18290,18291,18292,18293,18294,18295,18296,18297,18298,\n18299,18300,18301,18302,18303,18304,18305,18306,18307,18308,18309,18310,\n18311,18312,18313,18314,18315,18316,18317,18318,18319,18320,18321,18322,\n18323,18324,18325,18326,18327,18328,18329,18330,18331,18332,18333,18334,\n18335,18336,18337,18338,18339,18340,18341,18342,18343,18344,18345,18346,\n18347,18348,18349,18350,18351,18352,18353,18354,18355,18356,18357,18358,\n18359,18360,18361,18362,18363,18364,18365,18366,18367,18368,18369,18370,\n18371,18372,18373,18374,18375,18376,18377,18378,18379,18380,18381,18382,\n18383,18384,18385,18386,18387,18388,18389,18390,18391,18392,18393,18394,\n18395,18396,18397,18398,18399,18400,18401,18402,18403,18404,18405,18406,\n18407,18408,18409,18410,18411,18412,18413,18414,18415,18416,18417,18418,\n18419,18420,18421,18422,18423,18424,18425,18426,18427,18428,18429,18430,\n18431,18432,18433,18434,18435,18436,18437,18438,18439,18440,18441,18442,\n18443,18444,18445,18446,18447,18448,18449,18450,18451,18452,18453,18454,\n18455,18456,18457,18458,18459,18460,18461,18462,18463,18464,18465,18466,\n18467,18468,18469,18470,18471,18472,18473,18474,18475,18476,18477,18478,\n18479,18480,18481,18482,18483,18484,18485,18486,18487,18488,18489,18490,\n18491,18492,18493,18494,18495,18496,18497,18498,18499,18500,18501,18502,\n18503,18504,18505,18506,18507,18508,18509,18510,18511,18512,18513,18514,\n18515,18516,18517,18518,18519,18520,18521,18522,18523,18524,18525,18526,\n18527,18528,18529,18530,18531,18532,18533,18534,18535,18536,18537,18538,\n18539,18540,18541,18542,18543,18544,18545,18546,18547,18548,18549,18550,\n18551,18552,18553,18554,18555,18556,18557,18558,18559,18560,18561,18562,\n18563,18564,18565,18566,18567,18568,18569,18570,18571,18572,18573,18574,\n18575,18576,18577,18578,18579,18580,18581,18582,18583,18584,18585,18586,\n18587,18588,18589,18590,18591,18592,18593,18594,18595,18596,18597,18598,\n18599,18600,18601,18602,18603,18604,18605,18606,18607,18608,18609,18610,\n18611,18612,18613,18614,18615,18616,18617,18618,18619,18620,18621,18622,\n18623,18624,18625,18626,18627,18628,18629,18630,18631,18632,18633,18634,\n18635,18636,18637,18638,18639,18640,18641,18642,18643,18644,18645,18646,\n18647,18648,18649,18650,18651,18652,18653,18654,18655,18656,18657,18658,\n18659,18660,18661,18662,18663,18664,18665,18666,18667,18668,18669,18670,\n18671,18672,18673,18674,18675,18676,18677,18678,18679,18680,18681,18682,\n18683,18684,18685,18686,18687,18688,18689,18690,18691,18692,18693,18694,\n18695,18696,18697,18698,18699,18700,18701,18702,18703,18704,18705,18706,\n18707,18708,18709,18710,18711,18712,18713,18714,18715,18716,18717,18718,\n18719,18720,18721,18722,18723,18724,18725,18726,18727,18728,18729,18730,\n18731,18732,18733,18734,18735,18736,18737,18738,18739,18740,18741,18742,\n18743,18744,18745,18746,18747,18748,18749,18750,18751,18752,18753,18754,\n18755,18756,18757,18758,18759,18760,18761,18762,18763,18764,18765,18766,\n18767,18768,18769,18770,18771,18772,18773,18774,18775,18776,18777,18778,\n18779,18780,18781,18782,18783,18784,18785,18786,18787,18788,18789,18790,\n18791,18792,18793,18794,18795,18796,18797,18798,18799,18800,18801,18802,\n18803,18804,18805,18806,18807,18808,18809,18810,18811,18812,18813,18814,\n18815,18816,18817,18818,18819,18820,18821,18822,18823,18824,18825,18826,\n18827,18828,18829,18830,18831,18832,18833,18834,18835,18836,18837,18838,\n18839,18840,18841,18842,18843,18844,18845,18846,18847,18848,18849,18850,\n18851,18852,18853,18854,18855,18856,18857,18858,18859,18860,18861,18862,\n18863,18864,18865,18866,18867,18868,18869,18870,18871,18872,18873,18874,\n18875,18876,18877,18878,18879,18880,18881,18882,18883,18884,18885,18886,\n18887,18888,18889,18890,18891,18892,18893,18894,18895,18896,18897,18898,\n18899,18900,18901,18902,18903,18904,18905,18906,18907,18908,18909,18910,\n18911,18912,18913,18914,18915,18916,18917,18918,18919,18920,18921,18922,\n18923,18924,18925,18926,18927,18928,18929,18930,18931,18932,18933,18934,\n18935,18936,18937,18938,18939,18940,18941,18942,18943,18944,18945,18946,\n18947,18948,18949,18950,18951,18952,18953,18954,18955,18956,18957,18958,\n18959,18960,18961,18962,18963,18964,18965,18966,18967,18968,18969,18970,\n18971,18972,18973,18974,18975,18976,18977,18978,18979,18980,18981,18982,\n18983,18984,18985,18986,18987,18988,18989,18990,18991,18992,18993,18994,\n18995,18996,18997,18998,18999,19000,19001,19002,19003,19004,19005,19006,\n19007,19008,19009,19010,19011,19012,19013,19014,19015,19016,19017,19018,\n19019,19020,19021,19022,19023,19024,19025,19026,19027,19028,19029,19030,\n19031,19032,19033,19034,19035,19036,19037,19038,19039,19040,19041,19042,\n19043,19044,19045,19046,19047,19048,19049,19050,19051,19052,19053,19054,\n19055,19056,19057,19058,19059,19060,19061,19062,19063,19064,19065,19066,\n19067,19068,19069,19070,19071,19072,19073,19074,19075,19076,19077,19078,\n19079,19080,19081,19082,19083,19084,19085,19086,19087,19088,19089,19090,\n19091,19092,19093,19094,19095,19096,19097,19098,19099,19100,19101,19102,\n19103,19104,19105,19106,19107,19108,19109,19110,19111,19112,19113,19114,\n19115,19116,19117,19118,19119,19120,19121,19122,19123,19124,19125,19126,\n19127,19128,19129,19130,19131,19132,19133,19134,19135,19136,19137,19138,\n19139,19140,19141,19142,19143,19144,19145,19146,19147,19148,19149,19150,\n19151,19152,19153,19154,19155,19156,19157,19158,19159,19160,19161,19162,\n19163,19164,19165,19166,19167,19168,19169,19170,19171,19172,19173,19174,\n19175,19176,19177,19178,19179,19180,19181,19182,19183,19184,19185,19186,\n19187,19188,19189,19190,19191,19192,19193,19194,19195,19196,19197,19198,\n19199,19200,19201,19202,19203,19204,19205,19206,19207,19208,19209,19210,\n19211,19212,19213,19214,19215,19216,19217,19218,19219,19220,19221,19222,\n19223,19224,19225,19226,19227,19228,19229,19230,19231,19232,19233,19234,\n19235,19236,19237,19238,19239,19240,19241,19242,19243,19244,19245,19246,\n19247,19248,19249,19250,19251,19252,19253,19254,19255,19256,19257,19258,\n19259,19260,19261,19262,19263,19264,19265,19266,19267,19268,19269,19270,\n19271,19272,19273,19274,19275,19276,19277,19278,19279,19280,19281,19282,\n19283,19284,19285,19286,19287,19288,19289,19290,19291,19292,19293,19294,\n19295,19296,19297,19298,19299,19300,19301,19302,19303,19304,19305,19306,\n19307,19308,19309,19310,19311,19312,19313,19314,19315,19316,19317,19318,\n19319,19320,19321,19322,19323,19324,19325,19326,19327,19328,19329,19330,\n19331,19332,19333,19334,19335,19336,19337,19338,19339,19340,19341,19342,\n19343,19344,19345,19346,19347,19348,19349,19350,19351,19352,19353,19354,\n19355,19356,19357,19358,19359,19360,19361,19362,19363,19364,19365,19366,\n19367,19368,19369,19370,19371,19372,19373,19374,19375,19376,19377,19378,\n19379,19380,19381,19382,19383,19384,19385,19386,19387,19388,19389,19390,\n19391,19392,19393,19394,19395,19396,19397,19398,19399,19400,19401,19402,\n19403,19404,19405,19406,19407,19408,19409,19410,19411,19412,19413,19414,\n19415,19416,19417,19418,19419,19420,19421,19422,19423,19424,19425,19426,\n19427,19428,19429,19430,19431,19432,19433,19434,19435,19436,19437,19438,\n19439,19440,19441,19442,19443,19444,19445,19446,19447,19448,19449,19450,\n19451,19452,19453,19454,19455,19456,19457,19458,19459,19460,19461,19462,\n19463,19464,19465,19466,19467,19468,19469,19470,19471,19472,19473,19474,\n19475,19476,19477,19478,19479,19480,19481,19482,19483,19484,19485,19486,\n19487,19488,19489,19490,19491,19492,19493,19494,19495,19496,19497,19498,\n19499,19500,19501,19502,19503,19504,19505,19506,19507,19508,19509,19510,\n19511,19512,19513,19514,19515,19516,19517,19518,19519,19520,19521,19522,\n19523,19524,19525,19526,19527,19528,19529,19530,19531,19532,19533,19534,\n19535,19536,19537,19538,19539,19540,19541,19542,19543,19544,19545,19546,\n19547,19548,19549,19550,19551,19552,19553,19554,19555,19556,19557,19558,\n19559,19560,19561,19562,19563,19564,19565,19566,19567,19568,19569,19570,\n19571,19572,19573,19574,19575,19576,19577,19578,19579,19580,19581,19582,\n19583,19584,19585,19586,19587,19588,19589,19590,19591,19592,19593,19594,\n19595,19596,19597,19598,19599,19600,19601,19602,19603,19604,19605,19606,\n19607,19608,19609,19610,19611,19612,19613,19614,19615,19616,19617,19618,\n19619,19620,19621,19622,19623,19624,19625,19626,19627,19628,19629,19630,\n19631,19632,19633,19634,19635,19636,19637,19638,19639,19640,19641,19642,\n19643,19644,19645,19646,19647,19648,19649,19650,19651,19652,19653,19654,\n19655,19656,19657,19658,19659,19660,19661,19662,19663,19664,19665,19666,\n19667,19668,19669,19670,19671,19672,19673,19674,19675,19676,19677,19678,\n19679,19680,19681,19682,19683,19684,19685,19686,19687,19688,19689,19690,\n19691,19692,19693,19694,19695,19696,19697,19698,19699,19700,19701,19702,\n19703,19704,19705,19706,19707,19708,19709,19710,19711,19712,19713,19714,\n19715,19716,19717,19718,19719,19720,19721,19722,19723,19724,19725,19726,\n19727,19728,19729,19730,19731,19732,19733,19734,19735,19736,19737,19738,\n19739,19740,19741,19742,19743,19744,19745,19746,19747,19748,19749,19750,\n19751,19752,19753,19754,19755,19756,19757,19758,19759,19760,19761,19762,\n19763,19764,19765,19766,19767,19768,19769,19770,19771,19772,19773,19774,\n19775,19776,19777,19778,19779,19780,19781,19782,19783,19784,19785,19786,\n19787,19788,19789,19790,19791,19792,19793,19794,19795,19796,19797,19798,\n19799,19800,19801,19802,19803,19804,19805,19806,19807,19808,19809,19810,\n19811,19812,19813,19814,19815,19816,19817,19818,19819,19820,19821,19822,\n19823,19824,19825,19826,19827,19828,19829,19830,19831,19832,19833,19834,\n19835,19836,19837,19838,19839,19840,19841,19842,19843,19844,19845,19846,\n19847,19848,19849,19850,19851,19852,19853,19854,19855,19856,19857,19858,\n19859,19860,19861,19862,19863,19864,19865,19866,19867,19868,19869,19870,\n19871,19872,19873,19874,19875,19876,19877,19878,19879,19880,19881,19882,\n19883,19884,19885,19886,19887,19888,19889,19890,19891,19892,19893,19894,\n19895,19896,19897,19898,19899,19900,19901,19902,19903,19904,19905,19906,\n19907,19908,19909,19910,19911,19912,19913,19914,19915,19916,19917,19918,\n19919,19920,19921,19922,19923,19924,19925,19926,19927,19928,19929,19930,\n19931,19932,19933,19934,19935,19936,19937,19938,19939,19940,19941,19942,\n19943,19944,19945,19946,19947,19948,19949,19950,19951,19952,19953,19954,\n19955,19956,19957,19958,19959,19960,19961,19962,19963,19964,19965,19966,\n19967,19968,19969,19970,19971,19972,19973,19974,19975,19976,19977,19978,\n19979,19980,19981,19982,19983,19984,19985,19986,19987,19988,19989,19990,\n19991,19992,19993,19994,19995,19996,19997,19998,19999,20000,20001,20002,\n20003,20004,20005,20006,20007,20008,20009,20010,20011,20012,20013,20014,\n20015,20016,20017,20018,20019,20020,20021,20022,20023,20024,20025,20026,\n20027,20028,20029,20030,20031,20032,20033,20034,20035,20036,20037,20038,\n20039,20040,20041,20042,20043,20044,20045,20046,20047,20048,20049,20050,\n20051,20052,20053,20054,20055,20056,20057,20058,20059,20060,20061,20062,\n20063,20064,20065,20066,20067,20068,20069,20070,20071,20072,20073,20074,\n20075,20076,20077,20078,20079,20080,20081,20082,20083,20084,20085,20086,\n20087,20088,20089,20090,20091,20092,20093,20094,20095,20096,20097,20098,\n20099,20100,20101,20102,20103,20104,20105,20106,20107,20108,20109,20110,\n20111,20112,20113,20114,20115,20116,20117,20118,20119,20120,20121,20122,\n20123,20124,20125,20126,20127,20128,20129,20130,20131,20132,20133,20134,\n20135,20136,20137,20138,20139,20140,20141,20142,20143,20144,20145,20146,\n20147,20148,20149,20150,20151,20152,20153,20154,20155,20156,20157,20158,\n20159,20160,20161,20162,20163,20164,20165,20166,20167,20168,20169,20170,\n20171,20172,20173,20174,20175,20176,20177,20178,20179,20180,20181,20182,\n20183,20184,20185,20186,20187,20188,20189,20190,20191,20192,20193,20194,\n20195,20196,20197,20198,20199,20200,20201,20202,20203,20204,20205,20206,\n20207,20208,20209,20210,20211,20212,20213,20214,20215,20216,20217,20218,\n20219,20220,20221,20222,20223,20224,20225,20226,20227,20228,20229,20230,\n20231,20232,20233,20234,20235,20236,20237,20238,20239,20240,20241,20242,\n20243,20244,20245,20246,20247,20248,20249,20250,20251,20252,20253,20254,\n20255,20256,20257,20258,20259,20260,20261,20262,20263,20264,20265,20266,\n20267,20268,20269,20270,20271,20272,20273,20274,20275,20276,20277,20278,\n20279,20280,20281,20282,20283,20284,20285,20286,20287,20288,20289,20290,\n20291,20292,20293,20294,20295,20296,20297,20298,20299,20300,20301,20302,\n20303,20304,20305,20306,20307,20308,20309,20310,20311,20312,20313,20314,\n20315,20316,20317,20318,20319,20320,20321,20322,20323,20324,20325,20326,\n20327,20328,20329,20330,20331,20332,20333,20334,20335,20336,20337,20338,\n20339,20340,20341,20342,20343,20344,20345,20346,20347,20348,20349,20350,\n20351,20352,20353,20354,20355,20356,20357,20358,20359,20360,20361,20362,\n20363,20364,20365,20366,20367,20368,20369,20370,20371,20372,20373,20374,\n20375,20376,20377,20378,20379,20380,20381,20382,20383,20384,20385,20386,\n20387,20388,20389,20390,20391,20392,20393,20394,20395,20396,20397,20398,\n20399,20400,20401,20402,20403,20404,20405,20406,20407,20408,20409,20410,\n20411,20412,20413,20414,20415,20416,20417,20418,20419,20420,20421,20422,\n20423,20424,20425,20426,20427,20428,20429,20430,20431,20432,20433,20434,\n20435,20436,20437,20438,20439,20440,20441,20442,20443,20444,20445,20446,\n20447,20448,20449,20450,20451,20452,20453,20454,20455,20456,20457,20458,\n20459,20460,20461,20462,20463,20464,20465,20466,20467,20468,20469,20470,\n20471,20472,20473,20474,20475,20476,20477,20478,20479,20480,20481,20482,\n20483,20484,20485,20486,20487,20488,20489,20490,20491,20492,20493,20494,\n20495,20496,20497,20498,20499,20500,20501,20502,20503,20504,20505,20506,\n20507,20508,20509,20510,20511,20512,20513,20514,20515,20516,20517,20518,\n20519,20520,20521,20522,20523,20524,20525,20526,20527,20528,20529,20530,\n20531,20532,20533,20534,20535,20536,20537,20538,20539,20540,20541,20542,\n20543,20544,20545,20546,20547,20548,20549,20550,20551,20552,20553,20554,\n20555,20556,20557,20558,20559,20560,20561,20562,20563,20564,20565,20566,\n20567,20568,20569,20570,20571,20572,20573,20574,20575,20576,20577,20578,\n20579,20580,20581,20582,20583,20584,20585,20586,20587,20588,20589,20590,\n20591,20592,20593,20594,20595,20596,20597,20598,20599,20600,20601,20602,\n20603,20604,20605,20606,20607,20608,20609,20610,20611,20612,20613,20614,\n20615,20616,20617,20618,20619,20620,20621,20622,20623,20624,20625,20626,\n20627,20628,20629,20630,20631,20632,20633,20634,20635,20636,20637,20638,\n20639,20640,20641,20642,20643,20644,20645,20646,20647,20648,20649,20650,\n20651,20652,20653,20654,20655,20656,20657,20658,20659,20660,20661,20662,\n20663,20664,20665,20666,20667,20668,20669,20670,20671,20672,20673,20674,\n20675,20676,20677,20678,20679,20680,20681,20682,20683,20684,20685,20686,\n20687,20688,20689,20690,20691,20692,20693,20694,20695,20696,20697,20698,\n20699,20700,20701,20702,20703,20704,20705,20706,20707,20708,20709,20710,\n20711,20712,20713,20714,20715,20716,20717,20718,20719,20720,20721,20722,\n20723,20724,20725,20726,20727,20728,20729,20730,20731,20732,20733,20734,\n20735,20736,20737,20738,20739,20740,20741,20742,20743,20744,20745,20746,\n20747,20748,20749,20750,20751,20752,20753,20754,20755,20756,20757,20758,\n20759,20760,20761,20762,20763,20764,20765,20766,20767,20768,20769,20770,\n20771,20772,20773,20774,20775,20776,20777,20778,20779,20780,20781,20782,\n20783,20784,20785,20786,20787,20788,20789,20790,20791,20792,20793,20794,\n20795,20796,20797,20798,20799,20800,20801,20802,20803,20804,20805,20806,\n20807,20808,20809,20810,20811,20812,20813,20814,20815,20816,20817,20818,\n20819,20820,20821,20822,20823,20824,20825,20826,20827,20828,20829,20830,\n20831,20832,20833,20834,20835,20836,20837,20838,20839,20840,20841,20842,\n20843,20844,20845,20846,20847,20848,20849,20850,20851,20852,20853,20854,\n20855,20856,20857,20858,20859,20860,20861,20862,20863,20864,20865,20866,\n20867,20868,20869,20870,20871,20872,20873,20874,20875,20876,20877,20878,\n20879,20880,20881,20882,20883,20884,20885,20886,20887,20888,20889,20890,\n20891,20892,20893,20894,20895,20896,20897,20898,20899,20900,20901,20902,\n20903,20904,20905,20906,20907,20908,20909,20910,20911,20912,20913,20914,\n20915,20916,20917,20918,20919,20920,20921,20922,20923,20924,20925,20926,\n20927,20928,20929,20930,20931,20932,20933,20934,20935,20936,20937,20938,\n20939,20940,20941,20942,20943,20944,20945,20946,20947,20948,20949,20950,\n20951,20952,20953,20954,20955,20956,20957,20958,20959,20960,20961,20962,\n20963,20964,20965,20966,20967,20968,20969,20970,20971,20972,20973,20974,\n20975,20976,20977,20978,20979,20980,20981,20982,20983,20984,20985,20986,\n20987,20988,20989,20990,20991,20992,20993,20994,20995,20996,20997,20998,\n20999,21000,21001,21002,21003,21004,21005,21006,21007,21008,21009,21010,\n21011,21012,21013,21014,21015,21016,21017,21018,21019,21020,21021,21022,\n21023,21024,21025,21026,21027,21028,21029,21030,21031,21032,21033,21034,\n21035,21036,21037,21038,21039,21040,21041,21042,21043,21044,21045,21046,\n21047,21048,21049,21050,21051,21052,21053,21054,21055,21056,21057,21058,\n21059,21060,21061,21062,21063,21064,21065,21066,21067,21068,21069,21070,\n21071,21072,21073,21074,21075,21076,21077,21078,21079,21080,21081,21082,\n21083,21084,21085,21086,21087,21088,21089,21090,21091,21092,21093,21094,\n21095,21096,21097,21098,21099,21100,21101,21102,21103,21104,21105,21106,\n21107,21108,21109,21110,21111,21112,21113,21114,21115,21116,21117,21118,\n21119,21120,21121,21122,21123,21124,21125,21126,21127,21128,21129,21130,\n21131,21132,21133,21134,21135,21136,21137,21138,21139,21140,21141,21142,\n21143,21144,21145,21146,21147,21148,21149,21150,21151,21152,21153,21154,\n21155,21156,21157,21158,21159,21160,21161,21162,21163,21164,21165,21166,\n21167,21168,21169,21170,21171,21172,21173,21174,21175,21176,21177,21178,\n21179,21180,21181,21182,21183,21184,21185,21186,21187,21188,21189,21190,\n21191,21192,21193,21194,21195,21196,21197,21198,21199,21200,21201,21202,\n21203,21204,21205,21206,21207,21208,21209,21210,21211,21212,21213,21214,\n21215,21216,21217,21218,21219,21220,21221,21222,21223,21224,21225,21226,\n21227,21228,21229,21230,21231,21232,21233,21234,21235,21236,21237,21238,\n21239,21240,21241,21242,21243,21244,21245,21246,21247,21248,21249,21250,\n21251,21252,21253,21254,21255,21256,21257,21258,21259,21260,21261,21262,\n21263,21264,21265,21266,21267,21268,21269,21270,21271,21272,21273,21274,\n21275,21276,21277,21278,21279,21280,21281,21282,21283,21284,21285,21286,\n21287,21288,21289,21290,21291,21292,21293,21294,21295,21296,21297,21298,\n21299,21300,21301,21302,21303,21304,21305,21306,21307,21308,21309,21310,\n21311,21312,21313,21314,21315,21316,21317,21318,21319,21320,21321,21322,\n21323,21324,21325,21326,21327,21328,21329,21330,21331,21332,21333,21334,\n21335,21336,21337,21338,21339,21340,21341,21342,21343,21344,21345,21346,\n21347,21348,21349,21350,21351,21352,21353,21354,21355,21356,21357,21358,\n21359,21360,21361,21362,21363,21364,21365,21366,21367,21368,21369,21370,\n21371,21372,21373,21374,21375,21376,21377,21378,21379,21380,21381,21382,\n21383,21384,21385,21386,21387,21388,21389,21390,21391,21392,21393,21394,\n21395,21396,21397,21398,21399,21400,21401,21402,21403,21404,21405,21406,\n21407,21408,21409,21410,21411,21412,21413,21414,21415,21416,21417,21418,\n21419,21420,21421,21422,21423,21424,21425,21426,21427,21428,21429,21430,\n21431,21432,21433,21434,21435,21436,21437,21438,21439,21440,21441,21442,\n21443,21444,21445,21446,21447,21448,21449,21450,21451,21452,21453,21454,\n21455,21456,21457,21458,21459,21460,21461,21462,21463,21464,21465,21466,\n21467,21468,21469,21470,21471,21472,21473,21474,21475,21476,21477,21478,\n21479,21480,21481,21482,21483,21484,21485,21486,21487,21488,21489,21490,\n21491,21492,21493,21494,21495,21496,21497,21498,21499,21500,21501,21502,\n21503,21504,21505,21506,21507,21508,21509,21510,21511,21512,21513,21514,\n21515,21516,21517,21518,21519,21520,21521,21522,21523,21524,21525,21526,\n21527,21528,21529,21530,21531,21532,21533,21534,21535,21536,21537,21538,\n21539,21540,21541,21542,21543,21544,21545,21546,21547,21548,21549,21550,\n21551,21552,21553,21554,21555,21556,21557,21558,21559,21560,21561,21562,\n21563,21564,21565,21566,21567,21568,21569,21570,21571,21572,21573,21574,\n21575,21576,21577,21578,21579,21580,21581,21582,21583,21584,21585,21586,\n21587,21588,21589,21590,21591,21592,21593,21594,21595,21596,21597,21598,\n21599,21600,21601,21602,21603,21604,21605,21606,21607,21608,21609,21610,\n21611,21612,21613,21614,21615,21616,21617,21618,21619,21620,21621,21622,\n21623,21624,21625,21626,21627,21628,21629,21630,21631,21632,21633,21634,\n21635,21636,21637,21638,21639,21640,21641,21642,21643,21644,21645,21646,\n21647,21648,21649,21650,21651,21652,21653,21654,21655,21656,21657,21658,\n21659,21660,21661,21662,21663,21664,21665,21666,21667,21668,21669,21670,\n21671,21672,21673,21674,21675,21676,21677,21678,21679,21680,21681,21682,\n21683,21684,21685,21686,21687,21688,21689,21690,21691,21692,21693,21694,\n21695,21696,21697,21698,21699,21700,21701,21702,21703,21704,21705,21706,\n21707,21708,21709,21710,21711,21712,21713,21714,21715,21716,21717,21718,\n21719,21720,21721,21722,21723,21724,21725,21726,21727,21728,21729,21730,\n21731,21732,21733,21734,21735,21736,21737,21738,21739,21740,21741,21742,\n21743,21744,21745,21746,21747,21748,21749,21750,21751,21752,21753,21754,\n21755,21756,21757,21758,21759,21760,21761,21762,21763,21764,21765,21766,\n21767,21768,21769,21770,21771,21772,21773,21774,21775,21776,21777,21778,\n21779,21780,21781,21782,21783,21784,21785,21786,21787,21788,21789,21790,\n21791,21792,21793,21794,21795,21796,21797,21798,21799,21800,21801,21802,\n21803,21804,21805,21806,21807,21808,21809,21810,21811,21812,21813,21814,\n21815,21816,21817,21818,21819,21820,21821,21822,21823,21824,21825,21826,\n21827,21828,21829,21830,21831,21832,21833,21834,21835,21836,21837,21838,\n21839,21840,21841,21842,21843,21844,21845,21846,21847,21848,21849,21850,\n21851,21852,21853,21854,21855,21856,21857,21858,21859,21860,21861,21862,\n21863,21864,21865,21866,21867,21868,21869,21870,21871,21872,21873,21874,\n21875,21876,21877,21878,21879,21880,21881,21882,21883,21884,21885,21886,\n21887,21888,21889,21890,21891,21892,21893,21894,21895,21896,21897,21898,\n21899,21900,21901,21902,21903,21904,21905,21906,21907,21908,21909,21910,\n21911,21912,21913,21914,21915,21916,21917,21918,21919,21920,21921,21922,\n21923,21924,21925,21926,21927,21928,21929,21930,21931,21932,21933,21934,\n21935,21936,21937,21938,21939,21940,21941,21942,21943,21944,21945,21946,\n21947,21948,21949,21950,21951,21952,21953,21954,21955,21956,21957,21958,\n21959,21960,21961,21962,21963,21964,21965,21966,21967,21968,21969,21970,\n21971,21972,21973,21974,21975,21976,21977,21978,21979,21980,21981,21982,\n21983,21984,21985,21986,21987,21988,21989,21990,21991,21992,21993,21994,\n21995,21996,21997,21998,21999,22000,22001,22002,22003,22004,22005,22006,\n22007,22008,22009,22010,22011,22012,22013,22014,22015,22016,22017,22018,\n22019,22020,22021,22022,22023,22024,22025,22026,22027,22028,22029,22030,\n22031,22032,22033,22034,22035,22036,22037,22038,22039,22040,22041,22042,\n22043,22044,22045,22046,22047,22048,22049,22050,22051,22052,22053,22054,\n22055,22056,22057,22058,22059,22060,22061,22062,22063,22064,22065,22066,\n22067,22068,22069,22070,22071,22072,22073,22074,22075,22076,22077,22078,\n22079,22080,22081,22082,22083,22084,22085,22086,22087,22088,22089,22090,\n22091,22092,22093,22094,22095,22096,22097,22098,22099,22100,22101,22102,\n22103,22104,22105,22106,22107,22108,22109,22110,22111,22112,22113,22114,\n22115,22116,22117,22118,22119,22120,22121,22122,22123,22124,22125,22126,\n22127,22128,22129,22130,22131,22132,22133,22134,22135,22136,22137,22138,\n22139,22140,22141,22142,22143,22144,22145,22146,22147,22148,22149,22150,\n22151,22152,22153,22154,22155,22156,22157,22158,22159,22160,22161,22162,\n22163,22164,22165,22166,22167,22168,22169,22170,22171,22172,22173,22174,\n22175,22176,22177,22178,22179,22180,22181,22182,22183,22184,22185,22186,\n22187,22188,22189,22190,22191,22192,22193,22194,22195,22196,22197,22198,\n22199,22200,22201,22202,22203,22204,22205,22206,22207,22208,22209,22210,\n22211,22212,22213,22214,22215,22216,22217,22218,22219,22220,22221,22222,\n22223,22224,22225,22226,22227,22228,22229,22230,22231,22232,22233,22234,\n22235,22236,22237,22238,22239,22240,22241,22242,22243,22244,22245,22246,\n22247,22248,22249,22250,22251,22252,22253,22254,22255,22256,22257,22258,\n22259,22260,22261,22262,22263,22264,22265,22266,22267,22268,22269,22270,\n22271,22272,22273,22274,22275,22276,22277,22278,22279,22280,22281,22282,\n22283,22284,22285,22286,22287,22288,22289,22290,22291,22292,22293,22294,\n22295,22296,22297,22298,22299,22300,22301,22302,22303,22304,22305,22306,\n22307,22308,22309,22310,22311,22312,22313,22314,22315,22316,22317,22318,\n22319,22320,22321,22322,22323,22324,22325,22326,22327,22328,22329,22330,\n22331,22332,22333,22334,22335,22336,22337,22338,22339,22340,22341,22342,\n22343,22344,22345,22346,22347,22348,22349,22350,22351,22352,22353,22354,\n22355,22356,22357,22358,22359,22360,22361,22362,22363,22364,22365,22366,\n22367,22368,22369,22370,22371,22372,22373,22374,22375,22376,22377,22378,\n22379,22380,22381,22382,22383,22384,22385,22386,22387,22388,22389,22390,\n22391,22392,22393,22394,22395,22396,22397,22398,22399,22400,22401,22402,\n22403,22404,22405,22406,22407,22408,22409,22410,22411,22412,22413,22414,\n22415,22416,22417,22418,22419,22420,22421,22422,22423,22424,22425,22426,\n22427,22428,22429,22430,22431,22432,22433,22434,22435,22436,22437,22438,\n22439,22440,22441,22442,22443,22444,22445,22446,22447,22448,22449,22450,\n22451,22452,22453,22454,22455,22456,22457,22458,22459,22460,22461,22462,\n22463,22464,22465,22466,22467,22468,22469,22470,22471,22472,22473,22474,\n22475,22476,22477,22478,22479,22480,22481,22482,22483,22484,22485,22486,\n22487,22488,22489,22490,22491,22492,22493,22494,22495,22496,22497,22498,\n22499,22500,22501,22502,22503,22504,22505,22506,22507,22508,22509,22510,\n22511,22512,22513,22514,22515,22516,22517,22518,22519,22520,22521,22522,\n22523,22524,22525,22526,22527,22528,22529,22530,22531,22532,22533,22534,\n22535,22536,22537,22538,22539,22540,22541,22542,22543,22544,22545,22546,\n22547,22548,22549,22550,22551,22552,22553,22554,22555,22556,22557,22558,\n22559,22560,22561,22562,22563,22564,22565,22566,22567,22568,22569,22570,\n22571,22572,22573,22574,22575,22576,22577,22578,22579,22580,22581,22582,\n22583,22584,22585,22586,22587,22588,22589,22590,22591,22592,22593,22594,\n22595,22596,22597,22598,22599,22600,22601,22602,22603,22604,22605,22606,\n22607,22608,22609,22610,22611,22612,22613,22614,22615,22616,22617,22618,\n22619,22620,22621,22622,22623,22624,22625,22626,22627,22628,22629,22630,\n22631,22632,22633,22634,22635,22636,22637,22638,22639,22640,22641,22642,\n22643,22644,22645,22646,22647,22648,22649,22650,22651,22652,22653,22654,\n22655,22656,22657,22658,22659,22660,22661,22662,22663,22664,22665,22666,\n22667,22668,22669,22670,22671,22672,22673,22674,22675,22676,22677,22678,\n22679,22680,22681,22682,22683,22684,22685,22686,22687,22688,22689,22690,\n22691,22692,22693,22694,22695,22696,22697,22698,22699,22700,22701,22702,\n22703,22704,22705,22706,22707,22708,22709,22710,22711,22712,22713,22714,\n22715,22716,22717,22718,22719,22720,22721,22722,22723,22724,22725,22726,\n22727,22728,22729,22730,22731,22732,22733,22734,22735,22736,22737,22738,\n22739,22740,22741,22742,22743,22744,22745,22746,22747,22748,22749,22750,\n22751,22752,22753,22754,22755,22756,22757,22758,22759,22760,22761,22762,\n22763,22764,22765,22766,22767,22768,22769,22770,22771,22772,22773,22774,\n22775,22776,22777,22778,22779,22780,22781,22782,22783,22784,22785,22786,\n22787,22788,22789,22790,22791,22792,22793,22794,22795,22796,22797,22798,\n22799,22800,22801,22802,22803,22804,22805,22806,22807,22808,22809,22810,\n22811,22812,22813,22814,22815,22816,22817,22818,22819,22820,22821,22822,\n22823,22824,22825,22826,22827,22828,22829,22830,22831,22832,22833,22834,\n22835,22836,22837,22838,22839,22840,22841,22842,22843,22844,22845,22846,\n22847,22848,22849,22850,22851,22852,22853,22854,22855,22856,22857,22858,\n22859,22860,22861,22862,22863,22864,22865,22866,22867,22868,22869,22870,\n22871,22872,22873,22874,22875,22876,22877,22878,22879,22880,22881,22882,\n22883,22884,22885,22886,22887,22888,22889,22890,22891,22892,22893,22894,\n22895,22896,22897,22898,22899,22900,22901,22902,22903,22904,22905,22906,\n22907,22908,22909,22910,22911,22912,22913,22914,22915,22916,22917,22918,\n22919,22920,22921,22922,22923,22924,22925,22926,22927,22928,22929,22930,\n22931,22932,22933,22934,22935,22936,22937,22938,22939,22940,22941,22942,\n22943,22944,22945,22946,22947,22948,22949,22950,22951,22952,22953,22954,\n22955,22956,22957,22958,22959,22960,22961,22962,22963,22964,22965,22966,\n22967,22968,22969,22970,22971,22972,22973,22974,22975,22976,22977,22978,\n22979,22980,22981,22982,22983,22984,22985,22986,22987,22988,22989,22990,\n22991,22992,22993,22994,22995,22996,22997,22998,22999,23000,23001,23002,\n23003,23004,23005,23006,23007,23008,23009,23010,23011,23012,23013,23014,\n23015,23016,23017,23018,23019,23020,23021,23022,23023,23024,23025,23026,\n23027,23028,23029,23030,23031,23032,23033,23034,23035,23036,23037,23038,\n23039,23040,23041,23042,23043,23044,23045,23046,23047,23048,23049,23050,\n23051,23052,23053,23054,23055,23056,23057,23058,23059,23060,23061,23062,\n23063,23064,23065,23066,23067,23068,23069,23070,23071,23072,23073,23074,\n23075,23076,23077,23078,23079,23080,23081,23082,23083,23084,23085,23086,\n23087,23088,23089,23090,23091,23092,23093,23094,23095,23096,23097,23098,\n23099,23100,23101,23102,23103,23104,23105,23106,23107,23108,23109,23110,\n23111,23112,23113,23114,23115,23116,23117,23118,23119,23120,23121,23122,\n23123,23124,23125,23126,23127,23128,23129,23130,23131,23132,23133,23134,\n23135,23136,23137,23138,23139,23140,23141,23142,23143,23144,23145,23146,\n23147,23148,23149,23150,23151,23152,23153,23154,23155,23156,23157,23158,\n23159,23160,23161,23162,23163,23164,23165,23166,23167,23168,23169,23170,\n23171,23172,23173,23174,23175,23176,23177,23178,23179,23180,23181,23182,\n23183,23184,23185,23186,23187,23188,23189,23190,23191,23192,23193,23194,\n23195,23196,23197,23198,23199,23200,23201,23202,23203,23204,23205,23206,\n23207,23208,23209,23210,23211,23212,23213,23214,23215,23216,23217,23218,\n23219,23220,23221,23222,23223,23224,23225,23226,23227,23228,23229,23230,\n23231,23232,23233,23234,23235,23236,23237,23238,23239,23240,23241,23242,\n23243,23244,23245,23246,23247,23248,23249,23250,23251,23252,23253,23254,\n23255,23256,23257,23258,23259,23260,23261,23262,23263,23264,23265,23266,\n23267,23268,23269,23270,23271,23272,23273,23274,23275,23276,23277,23278,\n23279,23280,23281,23282,23283,23284,23285,23286,23287,23288,23289,23290,\n23291,23292,23293,23294,23295,23296,23297,23298,23299,23300,23301,23302,\n23303,23304,23305,23306,23307,23308,23309,23310,23311,23312,23313,23314,\n23315,23316,23317,23318,23319,23320,23321,23322,23323,23324,23325,23326,\n23327,23328,23329,23330,23331,23332,23333,23334,23335,23336,23337,23338,\n23339,23340,23341,23342,23343,23344,23345,23346,23347,23348,23349,23350,\n23351,23352,23353,23354,23355,23356,23357,23358,23359,23360,23361,23362,\n23363,23364,23365,23366,23367,23368,23369,23370,23371,23372,23373,23374,\n23375,23376,23377,23378,23379,23380,23381,23382,23383,23384,23385,23386,\n23387,23388,23389,23390,23391,23392,23393,23394,23395,23396,23397,23398,\n23399,23400,23401,23402,23403,23404,23405,23406,23407,23408,23409,23410,\n23411,23412,23413,23414,23415,23416,23417,23418,23419,23420,23421,23422,\n23423,23424,23425,23426,23427,23428,23429,23430,23431,23432,23433,23434,\n23435,23436,23437,23438,23439,23440,23441,23442,23443,23444,23445,23446,\n23447,23448,23449,23450,23451,23452,23453,23454,23455,23456,23457,23458,\n23459,23460,23461,23462,23463,23464,23465,23466,23467,23468,23469,23470,\n23471,23472,23473,23474,23475,23476,23477,23478,23479,23480,23481,23482,\n23483,23484,23485,23486,23487,23488,23489,23490,23491,23492,23493,23494,\n23495,23496,23497,23498,23499,23500,23501,23502,23503,23504,23505,23506,\n23507,23508,23509,23510,23511,23512,23513,23514,23515,23516,23517,23518,\n23519,23520,23521,23522,23523,23524,23525,23526,23527,23528,23529,23530,\n23531,23532,23533,23534,23535,23536,23537,23538,23539,23540,23541,23542,\n23543,23544,23545,23546,23547,23548,23549,23550,23551,23552,23553,23554,\n23555,23556,23557,23558,23559,23560,23561,23562,23563,23564,23565,23566,\n23567,23568,23569,23570,23571,23572,23573,23574,23575,23576,23577,23578,\n23579,23580,23581,23582,23583,23584,23585,23586,23587,23588,23589,23590,\n23591,23592,23593,23594,23595,23596,23597,23598,23599,23600,23601,23602,\n23603,23604,23605,23606,23607,23608,23609,23610,23611,23612,23613,23614,\n23615,23616,23617,23618,23619,23620,23621,23622,23623,23624,23625,23626,\n23627,23628,23629,23630,23631,23632,23633,23634,23635,23636,23637,23638,\n23639,23640,23641,23642,23643,23644,23645,23646,23647,23648,23649,23650,\n23651,23652,23653,23654,23655,23656,23657,23658,23659,23660,23661,23662,\n23663,23664,23665,23666,23667,23668,23669,23670,23671,23672,23673,23674,\n23675,23676,23677,23678,23679,23680,23681,23682,23683,23684,23685,23686,\n23687,23688,23689,23690,23691,23692,23693,23694,23695,23696,23697,23698,\n23699,23700,23701,23702,23703,23704,23705,23706,23707,23708,23709,23710,\n23711,23712,23713,23714,23715,23716,23717,23718,23719,23720,23721,23722,\n23723,23724,23725,23726,23727,23728,23729,23730,23731,23732,23733,23734,\n23735,23736,23737,23738,23739,23740,23741,23742,23743,23744,23745,23746,\n23747,23748,23749,23750,23751,23752,23753,23754,23755,23756,23757,23758,\n23759,23760,23761,23762,23763,23764,23765,23766,23767,23768,23769,23770,\n23771,23772,23773,23774,23775,23776,23777,23778,23779,23780,23781,23782,\n23783,23784,23785,23786,23787,23788,23789,23790,23791,23792,23793,23794,\n23795,23796,23797,23798,23799,23800,23801,23802,23803,23804,23805,23806,\n23807,23808,23809,23810,23811,23812,23813,23814,23815,23816,23817,23818,\n23819,23820,23821,23822,23823,23824,23825,23826,23827,23828,23829,23830,\n23831,23832,23833,23834,23835,23836,23837,23838,23839,23840,23841,23842,\n23843,23844,23845,23846,23847,23848,23849,23850,23851,23852,23853,23854,\n23855,23856,23857,23858,23859,23860,23861,23862,23863,23864,23865,23866,\n23867,23868,23869,23870,23871,23872,23873,23874,23875,23876,23877,23878,\n23879,23880,23881,23882,23883,23884,23885,23886,23887,23888,23889,23890,\n23891,23892,23893,23894,23895,23896,23897,23898,23899,23900,23901,23902,\n23903,23904,23905,23906,23907,23908,23909,23910,23911,23912,23913,23914,\n23915,23916,23917,23918,23919,23920,23921,23922,23923,23924,23925,23926,\n23927,23928,23929,23930,23931,23932,23933,23934,23935,23936,23937,23938,\n23939,23940,23941,23942,23943,23944,23945,23946,23947,23948,23949,23950,\n23951,23952,23953,23954,23955,23956,23957,23958,23959,23960,23961,23962,\n23963,23964,23965,23966,23967,23968,23969,23970,23971,23972,23973,23974,\n23975,23976,23977,23978,23979,23980,23981,23982,23983,23984,23985,23986,\n23987,23988,23989,23990,23991,23992,23993,23994,23995,23996,23997,23998,\n23999,24000,24001,24002,24003,24004,24005,24006,24007,24008,24009,24010,\n24011,24012,24013,24014,24015,24016,24017,24018,24019,24020,24021,24022,\n24023,24024,24025,24026,24027,24028,24029,24030,24031,24032,24033,24034,\n24035,24036,24037,24038,24039,24040,24041,24042,24043,24044,24045,24046,\n24047,24048,24049,24050,24051,24052,24053,24054,24055,24056,24057,24058,\n24059,24060,24061,24062,24063,24064,24065,24066,24067,24068,24069,24070,\n24071,24072,24073,24074,24075,24076,24077,24078,24079,24080,24081,24082,\n24083,24084,24085,24086,24087,24088,24089,24090,24091,24092,24093,24094,\n24095,24096,24097,24098,24099,24100,24101,24102,24103,24104,24105,24106,\n24107,24108,24109,24110,24111,24112,24113,24114,24115,24116,24117,24118,\n24119,24120,24121,24122,24123,24124,24125,24126,24127,24128,24129,24130,\n24131,24132,24133,24134,24135,24136,24137,24138,24139,24140,24141,24142,\n24143,24144,24145,24146,24147,24148,24149,24150,24151,24152,24153,24154,\n24155,24156,24157,24158,24159,24160,24161,24162,24163,24164,24165,24166,\n24167,24168,24169,24170,24171,24172,24173,24174,24175,24176,24177,24178,\n24179,24180,24181,24182,24183,24184,24185,24186,24187,24188,24189,24190,\n24191,24192,24193,24194,24195,24196,24197,24198,24199,24200,24201,24202,\n24203,24204,24205,24206,24207,24208,24209,24210,24211,24212,24213,24214,\n24215,24216,24217,24218,24219,24220,24221,24222,24223,24224,24225,24226,\n24227,24228,24229,24230,24231,24232,24233,24234,24235,24236,24237,24238,\n24239,24240,24241,24242,24243,24244,24245,24246,24247,24248,24249,24250,\n24251,24252,24253,24254,24255,24256,24257,24258,24259,24260,24261,24262,\n24263,24264,24265,24266,24267,24268,24269,24270,24271,24272,24273,24274,\n24275,24276,24277,24278,24279,24280,24281,24282,24283,24284,24285,24286,\n24287,24288,24289,24290,24291,24292,24293,24294,24295,24296,24297,24298,\n24299,24300,24301,24302,24303,24304,24305,24306,24307,24308,24309,24310,\n24311,24312,24313,24314,24315,24316,24317,24318,24319,24320,24321,24322,\n24323,24324,24325,24326,24327,24328,24329,24330,24331,24332,24333,24334,\n24335,24336,24337,24338,24339,24340,24341,24342,24343,24344,24345,24346,\n24347,24348,24349,24350,24351,24352,24353,24354,24355,24356,24357,24358,\n24359,24360,24361,24362,24363,24364,24365,24366,24367,24368,24369,24370,\n24371,24372,24373,24374,24375,24376,24377,24378,24379,24380,24381,24382,\n24383,24384,24385,24386,24387,24388,24389,24390,24391,24392,24393,24394,\n24395,24396,24397,24398,24399,24400,24401,24402,24403,24404,24405,24406,\n24407,24408,24409,24410,24411,24412,24413,24414,24415,24416,24417,24418,\n24419,24420,24421,24422,24423,24424,24425,24426,24427,24428,24429,24430,\n24431,24432,24433,24434,24435,24436,24437,24438,24439,24440,24441,24442,\n24443,24444,24445,24446,24447,24448,24449,24450,24451,24452,24453,24454,\n24455,24456,24457,24458,24459,24460,24461,24462,24463,24464,24465,24466,\n24467,24468,24469,24470,24471,24472,24473,24474,24475,24476,24477,24478,\n24479,24480,24481,24482,24483,24484,24485,24486,24487,24488,24489,24490,\n24491,24492,24493,24494,24495,24496,24497,24498,24499,24500,24501,24502,\n24503,24504,24505,24506,24507,24508,24509,24510,24511,24512,24513,24514,\n24515,24516,24517,24518,24519,24520,24521,24522,24523,24524,24525,24526,\n24527,24528,24529,24530,24531,24532,24533,24534,24535,24536,24537,24538,\n24539,24540,24541,24542,24543,24544,24545,24546,24547,24548,24549,24550,\n24551,24552,24553,24554,24555,24556,24557,24558,24559,24560,24561,24562,\n24563,24564,24565,24566,24567,24568,24569,24570,24571,24572,24573,24574,\n24575,24576,24577,24578,24579,24580,24581,24582,24583,24584,24585,24586,\n24587,24588,24589,24590,24591,24592,24593,24594,24595,24596,24597,24598,\n24599,24600,24601,24602,24603,24604,24605,24606,24607,24608,24609,24610,\n24611,24612,24613,24614,24615,24616,24617,24618,24619,24620,24621,24622,\n24623,24624,24625,24626,24627,24628,24629,24630,24631,24632,24633,24634,\n24635,24636,24637,24638,24639,24640,24641,24642,24643,24644,24645,24646,\n24647,24648,24649,24650,24651,24652,24653,24654,24655,24656,24657,24658,\n24659,24660,24661,24662,24663,24664,24665,24666,24667,24668,24669,24670,\n24671,24672,24673,24674,24675,24676,24677,24678,24679,24680,24681,24682,\n24683,24684,24685,24686,24687,24688,24689,24690,24691,24692,24693,24694,\n24695,24696,24697,24698,24699,24700,24701,24702,24703,24704,24705,24706,\n24707,24708,24709,24710,24711,24712,24713,24714,24715,24716,24717,24718,\n24719,24720,24721,24722,24723,24724,24725,24726,24727,24728,24729,24730,\n24731,24732,24733,24734,24735,24736,24737,24738,24739,24740,24741,24742,\n24743,24744,24745,24746,24747,24748,24749,24750,24751,24752,24753,24754,\n24755,24756,24757,24758,24759,24760,24761,24762,24763,24764,24765,24766,\n24767,24768,24769,24770,24771,24772,24773,24774,24775,24776,24777,24778,\n24779,24780,24781,24782,24783,24784,24785,24786,24787,24788,24789,24790,\n24791,24792,24793,24794,24795,24796,24797,24798,24799,24800,24801,24802,\n24803,24804,24805,24806,24807,24808,24809,24810,24811,24812,24813,24814,\n24815,24816,24817,24818,24819,24820,24821,24822,24823,24824,24825,24826,\n24827,24828,24829,24830,24831,24832,24833,24834,24835,24836,24837,24838,\n24839,24840,24841,24842,24843,24844,24845,24846,24847,24848,24849,24850,\n24851,24852,24853,24854,24855,24856,24857,24858,24859,24860,24861,24862,\n24863,24864,24865,24866,24867,24868,24869,24870,24871,24872,24873,24874,\n24875,24876,24877,24878,24879,24880,24881,24882,24883,24884,24885,24886,\n24887,24888,24889,24890,24891,24892,24893,24894,24895,24896,24897,24898,\n24899,24900,24901,24902,24903,24904,24905,24906,24907,24908,24909,24910,\n24911,24912,24913,24914,24915,24916,24917,24918,24919,24920,24921,24922,\n24923,24924,24925,24926,24927,24928,24929,24930,24931,24932,24933,24934,\n24935,24936,24937,24938,24939,24940,24941,24942,24943,24944,24945,24946,\n24947,24948,24949,24950,24951,24952,24953,24954,24955,24956,24957,24958,\n24959,24960,24961,24962,24963,24964,24965,24966,24967,24968,24969,24970,\n24971,24972,24973,24974,24975,24976,24977,24978,24979,24980,24981,24982,\n24983,24984,24985,24986,24987,24988,24989,24990,24991,24992,24993,24994,\n24995,24996,24997,24998,24999,25000,25001,25002,25003,25004,25005,25006,\n25007,25008,25009,25010,25011,25012,25013,25014,25015,25016,25017,25018,\n25019,25020,25021,25022,25023,25024,25025,25026,25027,25028,25029,25030,\n25031,25032,25033,25034,25035,25036,25037,25038,25039,25040,25041,25042,\n25043,25044,25045,25046,25047,25048,25049,25050,25051,25052,25053,25054,\n25055,25056,25057,25058,25059,25060,25061,25062,25063,25064,25065,25066,\n25067,25068,25069,25070,25071,25072,25073,25074,25075,25076,25077,25078,\n25079,25080,25081,25082,25083,25084,25085,25086,25087,25088,25089,25090,\n25091,25092,25093,25094,25095,25096,25097,25098,25099,25100,25101,25102,\n25103,25104,25105,25106,25107,25108,25109,25110,25111,25112,25113,25114,\n25115,25116,25117,25118,25119,25120,25121,25122,25123,25124,25125,25126,\n25127,25128,25129,25130,25131,25132,25133,25134,25135,25136,25137,25138,\n25139,25140,25141,25142,25143,25144,25145,25146,25147,25148,25149,25150,\n25151,25152,25153,25154,25155,25156,25157,25158,25159,25160,25161,25162,\n25163,25164,25165,25166,25167,25168,25169,25170,25171,25172,25173,25174,\n25175,25176,25177,25178,25179,25180,25181,25182,25183,25184,25185,25186,\n25187,25188,25189,25190,25191,25192,25193,25194,25195,25196,25197,25198,\n25199,25200,25201,25202,25203,25204,25205,25206,25207,25208,25209,25210,\n25211,25212,25213,25214,25215,25216,25217,25218,25219,25220,25221,25222,\n25223,25224,25225,25226,25227,25228,25229,25230,25231,25232,25233,25234,\n25235,25236,25237,25238,25239,25240,25241,25242,25243,25244,25245,25246,\n25247,25248,25249,25250,25251,25252,25253,25254,25255,25256,25257,25258,\n25259,25260,25261,25262,25263,25264,25265,25266,25267,25268,25269,25270,\n25271,25272,25273,25274,25275,25276,25277,25278,25279,25280,25281,25282,\n25283,25284,25285,25286,25287,25288,25289,25290,25291,25292,25293,25294,\n25295,25296,25297,25298,25299,25300,25301,25302,25303,25304,25305,25306,\n25307,25308,25309,25310,25311,25312,25313,25314,25315,25316,25317,25318,\n25319,25320,25321,25322,25323,25324,25325,25326,25327,25328,25329,25330,\n25331,25332,25333,25334,25335,25336,25337,25338,25339,25340,25341,25342,\n25343,25344,25345,25346,25347,25348,25349,25350,25351,25352,25353,25354,\n25355,25356,25357,25358,25359,25360,25361,25362,25363,25364,25365,25366,\n25367,25368,25369,25370,25371,25372,25373,25374,25375,25376,25377,25378,\n25379,25380,25381,25382,25383,25384,25385,25386,25387,25388,25389,25390,\n25391,25392,25393,25394,25395,25396,25397,25398,25399,25400,25401,25402,\n25403,25404,25405,25406,25407,25408,25409,25410,25411,25412,25413,25414,\n25415,25416,25417,25418,25419,25420,25421,25422,25423,25424,25425,25426,\n25427,25428,25429,25430,25431,25432,25433,25434,25435,25436,25437,25438,\n25439,25440,25441,25442,25443,25444,25445,25446,25447,25448,25449,25450,\n25451,25452,25453,25454,25455,25456,25457,25458,25459,25460,25461,25462,\n25463,25464,25465,25466,25467,25468,25469,25470,25471,25472,25473,25474,\n25475,25476,25477,25478,25479,25480,25481,25482,25483,25484,25485,25486,\n25487,25488,25489,25490,25491,25492,25493,25494,25495,25496,25497,25498,\n25499,25500,25501,25502,25503,25504,25505,25506,25507,25508,25509,25510,\n25511,25512,25513,25514,25515,25516,25517,25518,25519,25520,25521,25522,\n25523,25524,25525,25526,25527,25528,25529,25530,25531,25532,25533,25534,\n25535,25536,25537,25538,25539,25540,25541,25542,25543,25544,25545,25546,\n25547,25548,25549,25550,25551,25552,25553,25554,25555,25556,25557,25558,\n25559,25560,25561,25562,25563,25564,25565,25566,25567,25568,25569,25570,\n25571,25572,25573,25574,25575,25576,25577,25578,25579,25580,25581,25582,\n25583,25584,25585,25586,25587,25588,25589,25590,25591,25592,25593,25594,\n25595,25596,25597,25598,25599,25600,25601,25602,25603,25604,25605,25606,\n25607,25608,25609,25610,25611,25612,25613,25614,25615,25616,25617,25618,\n25619,25620,25621,25622,25623,25624,25625,25626,25627,25628,25629,25630,\n25631,25632,25633,25634,25635,25636,25637,25638,25639,25640,25641,25642,\n25643,25644,25645,25646,25647,25648,25649,25650,25651,25652,25653,25654,\n25655,25656,25657,25658,25659,25660,25661,25662,25663,25664,25665,25666,\n25667,25668,25669,25670,25671,25672,25673,25674,25675,25676,25677,25678,\n25679,25680,25681,25682,25683,25684,25685,25686,25687,25688,25689,25690,\n25691,25692,25693,25694,25695,25696,25697,25698,25699,25700,25701,25702,\n25703,25704,25705,25706,25707,25708,25709,25710,25711,25712,25713,25714,\n25715,25716,25717,25718,25719,25720,25721,25722,25723,25724,25725,25726,\n25727,25728,25729,25730,25731,25732,25733,25734,25735,25736,25737,25738,\n25739,25740,25741,25742,25743,25744,25745,25746,25747,25748,25749,25750,\n25751,25752,25753,25754,25755,25756,25757,25758,25759,25760,25761,25762,\n25763,25764,25765,25766,25767,25768,25769,25770,25771,25772,25773,25774,\n25775,25776,25777,25778,25779,25780,25781,25782,25783,25784,25785,25786,\n25787,25788,25789,25790,25791,25792,25793,25794,25795,25796,25797,25798,\n25799,25800,25801,25802,25803,25804,25805,25806,25807,25808,25809,25810,\n25811,25812,25813,25814,25815,25816,25817,25818,25819,25820,25821,25822,\n25823,25824,25825,25826,25827,25828,25829,25830,25831,25832,25833,25834,\n25835,25836,25837,25838,25839,25840,25841,25842,25843,25844,25845,25846,\n25847,25848,25849,25850,25851,25852,25853,25854,25855,25856,25857,25858,\n25859,25860,25861,25862,25863,25864,25865,25866,25867,25868,25869,25870,\n25871,25872,25873,25874,25875,25876,25877,25878,25879,25880,25881,25882,\n25883,25884,25885,25886,25887,25888,25889,25890,25891,25892,25893,25894,\n25895,25896,25897,25898,25899,25900,25901,25902,25903,25904,25905,25906,\n25907,25908,25909,25910,25911,25912,25913,25914,25915,25916,25917,25918,\n25919,25920,25921,25922,25923,25924,25925,25926,25927,25928,25929,25930,\n25931,25932,25933,25934,25935,25936,25937,25938,25939,25940,25941,25942,\n25943,25944,25945,25946,25947,25948,25949,25950,25951,25952,25953,25954,\n25955,25956,25957,25958,25959,25960,25961,25962,25963,25964,25965,25966,\n25967,25968,25969,25970,25971,25972,25973,25974,25975,25976,25977,25978,\n25979,25980,25981,25982,25983,25984,25985,25986,25987,25988,25989,25990,\n25991,25992,25993,25994,25995,25996,25997,25998,25999,26000,26001,26002,\n26003,26004,26005,26006,26007,26008,26009,26010,26011,26012,26013,26014,\n26015,26016,26017,26018,26019,26020,26021,26022,26023,26024,26025,26026,\n26027,26028,26029,26030,26031,26032,26033,26034,26035,26036,26037,26038,\n26039,26040,26041,26042,26043,26044,26045,26046,26047,26048,26049,26050,\n26051,26052,26053,26054,26055,26056,26057,26058,26059,26060,26061,26062,\n26063,26064,26065,26066,26067,26068,26069,26070,26071,26072,26073,26074,\n26075,26076,26077,26078,26079,26080,26081,26082,26083,26084,26085,26086,\n26087,26088,26089,26090,26091,26092,26093,26094,26095,26096,26097,26098,\n26099,26100,26101,26102,26103,26104,26105,26106,26107,26108,26109,26110,\n26111,26112,26113,26114,26115,26116,26117,26118,26119,26120,26121,26122,\n26123,26124,26125,26126,26127,26128,26129,26130,26131,26132,26133,26134,\n26135,26136,26137,26138,26139,26140,26141,26142,26143,26144,26145,26146,\n26147,26148,26149,26150,26151,26152,26153,26154,26155,26156,26157,26158,\n26159,26160,26161,26162,26163,26164,26165,26166,26167,26168,26169,26170,\n26171,26172,26173,26174,26175,26176,26177,26178,26179,26180,26181,26182,\n26183,26184,26185,26186,26187,26188,26189,26190,26191,26192,26193,26194,\n26195,26196,26197,26198,26199,26200,26201,26202,26203,26204,26205,26206,\n26207,26208,26209,26210,26211,26212,26213,26214,26215,26216,26217,26218,\n26219,26220,26221,26222,26223,26224,26225,26226,26227,26228,26229,26230,\n26231,26232,26233,26234,26235,26236,26237,26238,26239,26240,26241,26242,\n26243,26244,26245,26246,26247,26248,26249,26250,26251,26252,26253,26254,\n26255,26256,26257,26258,26259,26260,26261,26262,26263,26264,26265,26266,\n26267,26268,26269,26270,26271,26272,26273,26274,26275,26276,26277,26278,\n26279,26280,26281,26282,26283,26284,26285,26286,26287,26288,26289,26290,\n26291,26292,26293,26294,26295,26296,26297,26298,26299,26300,26301,26302,\n26303,26304,26305,26306,26307,26308,26309,26310,26311,26312,26313,26314,\n26315,26316,26317,26318,26319,26320,26321,26322,26323,26324,26325,26326,\n26327,26328,26329,26330,26331,26332,26333,26334,26335,26336,26337,26338,\n26339,26340,26341,26342,26343,26344,26345,26346,26347,26348,26349,26350,\n26351,26352,26353,26354,26355,26356,26357,26358,26359,26360,26361,26362,\n26363,26364,26365,26366,26367,26368,26369,26370,26371,26372,26373,26374,\n26375,26376,26377,26378,26379,26380,26381,26382,26383,26384,26385,26386,\n26387,26388,26389,26390,26391,26392,26393,26394,26395,26396,26397,26398,\n26399,26400,26401,26402,26403,26404,26405,26406,26407,26408,26409,26410,\n26411,26412,26413,26414,26415,26416,26417,26418,26419,26420,26421,26422,\n26423,26424,26425,26426,26427,26428,26429,26430,26431,26432,26433,26434,\n26435,26436,26437,26438,26439,26440,26441,26442,26443,26444,26445,26446,\n26447,26448,26449,26450,26451,26452,26453,26454,26455,26456,26457,26458,\n26459,26460,26461,26462,26463,26464,26465,26466,26467,26468,26469,26470,\n26471,26472,26473,26474,26475,26476,26477,26478,26479,26480,26481,26482,\n26483,26484,26485,26486,26487,26488,26489,26490,26491,26492,26493,26494,\n26495,26496,26497,26498,26499,26500,26501,26502,26503,26504,26505,26506,\n26507,26508,26509,26510,26511,26512,26513,26514,26515,26516,26517,26518,\n26519,26520,26521,26522,26523,26524,26525,26526,26527,26528,26529,26530,\n26531,26532,26533,26534,26535,26536,26537,26538,26539,26540,26541,26542,\n26543,26544,26545,26546,26547,26548,26549,26550,26551,26552,26553,26554,\n26555,26556,26557,26558,26559,26560,26561,26562,26563,26564,26565,26566,\n26567,26568,26569,26570,26571,26572,26573,26574,26575,26576,26577,26578,\n26579,26580,26581,26582,26583,26584,26585,26586,26587,26588,26589,26590,\n26591,26592,26593,26594,26595,26596,26597,26598,26599,26600,26601,26602,\n26603,26604,26605,26606,26607,26608,26609,26610,26611,26612,26613,26614,\n26615,26616,26617,26618,26619,26620,26621,26622,26623,26624,26625,26626,\n26627,26628,26629,26630,26631,26632,26633,26634,26635,26636,26637,26638,\n26639,26640,26641,26642,26643,26644,26645,26646,26647,26648,26649,26650,\n26651,26652,26653,26654,26655,26656,26657,26658,26659,26660,26661,26662,\n26663,26664,26665,26666,26667,26668,26669,26670,26671,26672,26673,26674,\n26675,26676,26677,26678,26679,26680,26681,26682,26683,26684,26685,26686,\n26687,26688,26689,26690,26691,26692,26693,26694,26695,26696,26697,26698,\n26699,26700,26701,26702,26703,26704,26705,26706,26707,26708,26709,26710,\n26711,26712,26713,26714,26715,26716,26717,26718,26719,26720,26721,26722,\n26723,26724,26725,26726,26727,26728,26729,26730,26731,26732,26733,26734,\n26735,26736,26737,26738,26739,26740,26741,26742,26743,26744,26745,26746,\n26747,26748,26749,26750,26751,26752,26753,26754,26755,26756,26757,26758,\n26759,26760,26761,26762,26763,26764,26765,26766,26767,26768,26769,26770,\n26771,26772,26773,26774,26775,26776,26777,26778,26779,26780,26781,26782,\n26783,26784,26785,26786,26787,26788,26789,26790,26791,26792,26793,26794,\n26795,26796,26797,26798,26799,26800,26801,26802,26803,26804,26805,26806,\n26807,26808,26809,26810,26811,26812,26813,26814,26815,26816,26817,26818,\n26819,26820,26821,26822,26823,26824,26825,26826,26827,26828,26829,26830,\n26831,26832,26833,26834,26835,26836,26837,26838,26839,26840,26841,26842,\n26843,26844,26845,26846,26847,26848,26849,26850,26851,26852,26853,26854,\n26855,26856,26857,26858,26859,26860,26861,26862,26863,26864,26865,26866,\n26867,26868,26869,26870,26871,26872,26873,26874,26875,26876,26877,26878,\n26879,26880,26881,26882,26883,26884,26885,26886,26887,26888,26889,26890,\n26891,26892,26893,26894,26895,26896,26897,26898,26899,26900,26901,26902,\n26903,26904,26905,26906,26907,26908,26909,26910,26911,26912,26913,26914,\n26915,26916,26917,26918,26919,26920,26921,26922,26923,26924,26925,26926,\n26927,26928,26929,26930,26931,26932,26933,26934,26935,26936,26937,26938,\n26939,26940,26941,26942,26943,26944,26945,26946,26947,26948,26949,26950,\n26951,26952,26953,26954,26955,26956,26957,26958,26959,26960,26961,26962,\n26963,26964,26965,26966,26967,26968,26969,26970,26971,26972,26973,26974,\n26975,26976,26977,26978,26979,26980,26981,26982,26983,26984,26985,26986,\n26987,26988,26989,26990,26991,26992,26993,26994,26995,26996,26997,26998,\n26999,27000,27001,27002,27003,27004,27005,27006,27007,27008,27009,27010,\n27011,27012,27013,27014,27015,27016,27017,27018,27019,27020,27021,27022,\n27023,27024,27025,27026,27027,27028,27029,27030,27031,27032,27033,27034,\n27035,27036,27037,27038,27039,27040,27041,27042,27043,27044,27045,27046,\n27047,27048,27049,27050,27051,27052,27053,27054,27055,27056,27057,27058,\n27059,27060,27061,27062,27063,27064,27065,27066,27067,27068,27069,27070,\n27071,27072,27073,27074,27075,27076,27077,27078,27079,27080,27081,27082,\n27083,27084,27085,27086,27087,27088,27089,27090,27091,27092,27093,27094,\n27095,27096,27097,27098,27099,27100,27101,27102,27103,27104,27105,27106,\n27107,27108,27109,27110,27111,27112,27113,27114,27115,27116,27117,27118,\n27119,27120,27121,27122,27123,27124,27125,27126,27127,27128,27129,27130,\n27131,27132,27133,27134,27135,27136,27137,27138,27139,27140,27141,27142,\n27143,27144,27145,27146,27147,27148,27149,27150,27151,27152,27153,27154,\n27155,27156,27157,27158,27159,27160,27161,27162,27163,27164,27165,27166,\n27167,27168,27169,27170,27171,27172,27173,27174,27175,27176,27177,27178,\n27179,27180,27181,27182,27183,27184,27185,27186,27187,27188,27189,27190,\n27191,27192,27193,27194,27195,27196,27197,27198,27199,27200,27201,27202,\n27203,27204,27205,27206,27207,27208,27209,27210,27211,27212,27213,27214,\n27215,27216,27217,27218,27219,27220,27221,27222,27223,27224,27225,27226,\n27227,27228,27229,27230,27231,27232,27233,27234,27235,27236,27237,27238,\n27239,27240,27241,27242,27243,27244,27245,27246,27247,27248,27249,27250,\n27251,27252,27253,27254,27255,27256,27257,27258,27259,27260,27261,27262,\n27263,27264,27265,27266,27267,27268,27269,27270,27271,27272,27273,27274,\n27275,27276,27277,27278,27279,27280,27281,27282,27283,27284,27285,27286,\n27287,27288,27289,27290,27291,27292,27293,27294,27295,27296,27297,27298,\n27299,27300,27301,27302,27303,27304,27305,27306,27307,27308,27309,27310,\n27311,27312,27313,27314,27315,27316,27317,27318,27319,27320,27321,27322,\n27323,27324,27325,27326,27327,27328,27329,27330,27331,27332,27333,27334,\n27335,27336,27337,27338,27339,27340,27341,27342,27343,27344,27345,27346,\n27347,27348,27349,27350,27351,27352,27353,27354,27355,27356,27357,27358,\n27359,27360,27361,27362,27363,27364,27365,27366,27367,27368,27369,27370,\n27371,27372,27373,27374,27375,27376,27377,27378,27379,27380,27381,27382,\n27383,27384,27385,27386,27387,27388,27389,27390,27391,27392,27393,27394,\n27395,27396,27397,27398,27399,27400,27401,27402,27403,27404,27405,27406,\n27407,27408,27409,27410,27411,27412,27413,27414,27415,27416,27417,27418,\n27419,27420,27421,27422,27423,27424,27425,27426,27427,27428,27429,27430,\n27431,27432,27433,27434,27435,27436,27437,27438,27439,27440,27441,27442,\n27443,27444,27445,27446,27447,27448,27449,27450,27451,27452,27453,27454,\n27455,27456,27457,27458,27459,27460,27461,27462,27463,27464,27465,27466,\n27467,27468,27469,27470,27471,27472,27473,27474,27475,27476,27477,27478,\n27479,27480,27481,27482,27483,27484,27485,27486,27487,27488,27489,27490,\n27491,27492,27493,27494,27495,27496,27497,27498,27499,27500,27501,27502,\n27503,27504,27505,27506,27507,27508,27509,27510,27511,27512,27513,27514,\n27515,27516,27517,27518,27519,27520,27521,27522,27523,27524,27525,27526,\n27527,27528,27529,27530,27531,27532,27533,27534,27535,27536,27537,27538,\n27539,27540,27541,27542,27543,27544,27545,27546,27547,27548,27549,27550,\n27551,27552,27553,27554,27555,27556,27557,27558,27559,27560,27561,27562,\n27563,27564,27565,27566,27567,27568,27569,27570,27571,27572,27573,27574,\n27575,27576,27577,27578,27579,27580,27581,27582,27583,27584,27585,27586,\n27587,27588,27589,27590,27591,27592,27593,27594,27595,27596,27597,27598,\n27599,27600,27601,27602,27603,27604,27605,27606,27607,27608,27609,27610,\n27611,27612,27613,27614,27615,27616,27617,27618,27619,27620,27621,27622,\n27623,27624,27625,27626,27627,27628,27629,27630,27631,27632,27633,27634,\n27635,27636,27637,27638,27639,27640,27641,27642,27643,27644,27645,27646,\n27647,27648,27649,27650,27651,27652,27653,27654,27655,27656,27657,27658,\n27659,27660,27661,27662,27663,27664,27665,27666,27667,27668,27669,27670,\n27671,27672,27673,27674,27675,27676,27677,27678,27679,27680,27681,27682,\n27683,27684,27685,27686,27687,27688,27689,27690,27691,27692,27693,27694,\n27695,27696,27697,27698,27699,27700,27701,27702,27703,27704,27705,27706,\n27707,27708,27709,27710,27711,27712,27713,27714,27715,27716,27717,27718,\n27719,27720,27721,27722,27723,27724,27725,27726,27727,27728,27729,27730,\n27731,27732,27733,27734,27735,27736,27737,27738,27739,27740,27741,27742,\n27743,27744,27745,27746,27747,27748,27749,27750,27751,27752,27753,27754,\n27755,27756,27757,27758,27759,27760,27761,27762,27763,27764,27765,27766,\n27767,27768,27769,27770,27771,27772,27773,27774,27775,27776,27777,27778,\n27779,27780,27781,27782,27783,27784,27785,27786,27787,27788,27789,27790,\n27791,27792,27793,27794,27795,27796,27797,27798,27799,27800,27801,27802,\n27803,27804,27805,27806,27807,27808,27809,27810,27811,27812,27813,27814,\n27815,27816,27817,27818,27819,27820,27821,27822,27823,27824,27825,27826,\n27827,27828,27829,27830,27831,27832,27833,27834,27835,27836,27837,27838,\n27839,27840,27841,27842,27843,27844,27845,27846,27847,27848,27849,27850,\n27851,27852,27853,27854,27855,27856,27857,27858,27859,27860,27861,27862,\n27863,27864,27865,27866,27867,27868,27869,27870,27871,27872,27873,27874,\n27875,27876,27877,27878,27879,27880,27881,27882,27883,27884,27885,27886,\n27887,27888,27889,27890,27891,27892,27893,27894,27895,27896,27897,27898,\n27899,27900,27901,27902,27903,27904,27905,27906,27907,27908,27909,27910,\n27911,27912,27913,27914,27915,27916,27917,27918,27919,27920,27921,27922,\n27923,27924,27925,27926,27927,27928,27929,27930,27931,27932,27933,27934,\n27935,27936,27937,27938,27939,27940,27941,27942,27943,27944,27945,27946,\n27947,27948,27949,27950,27951,27952,27953,27954,27955,27956,27957,27958,\n27959,27960,27961,27962,27963,27964,27965,27966,27967,27968,27969,27970,\n27971,27972,27973,27974,27975,27976,27977,27978,27979,27980,27981,27982,\n27983,27984,27985,27986,27987,27988,27989,27990,27991,27992,27993,27994,\n27995,27996,27997,27998,27999,28000,28001,28002,28003,28004,28005,28006,\n28007,28008,28009,28010,28011,28012,28013,28014,28015,28016,28017,28018,\n28019,28020,28021,28022,28023,28024,28025,28026,28027,28028,28029,28030,\n28031,28032,28033,28034,28035,28036,28037,28038,28039,28040,28041,28042,\n28043,28044,28045,28046,28047,28048,28049,28050,28051,28052,28053,28054,\n28055,28056,28057,28058,28059,28060,28061,28062,28063,28064,28065,28066,\n28067,28068,28069,28070,28071,28072,28073,28074,28075,28076,28077,28078,\n28079,28080,28081,28082,28083,28084,28085,28086,28087,28088,28089,28090,\n28091,28092,28093,28094,28095,28096,28097,28098,28099,28100,28101,28102,\n28103,28104,28105,28106,28107,28108,28109,28110,28111,28112,28113,28114,\n28115,28116,28117,28118,28119,28120,28121,28122,28123,28124,28125,28126,\n28127,28128,28129,28130,28131,28132,28133,28134,28135,28136,28137,28138,\n28139,28140,28141,28142,28143,28144,28145,28146,28147,28148,28149,28150,\n28151,28152,28153,28154,28155,28156,28157,28158,28159,28160,28161,28162,\n28163,28164,28165,28166,28167,28168,28169,28170,28171,28172,28173,28174,\n28175,28176,28177,28178,28179,28180,28181,28182,28183,28184,28185,28186,\n28187,28188,28189,28190,28191,28192,28193,28194,28195,28196,28197,28198,\n28199,28200,28201,28202,28203,28204,28205,28206,28207,28208,28209,28210,\n28211,28212,28213,28214,28215,28216,28217,28218,28219,28220,28221,28222,\n28223,28224,28225,28226,28227,28228,28229,28230,28231,28232,28233,28234,\n28235,28236,28237,28238,28239,28240,28241,28242,28243,28244,28245,28246,\n28247,28248,28249,28250,28251,28252,28253,28254,28255,28256,28257,28258,\n28259,28260,28261,28262,28263,28264,28265,28266,28267,28268,28269,28270,\n28271,28272,28273,28274,28275,28276,28277,28278,28279,28280,28281,28282,\n28283,28284,28285,28286,28287,28288,28289,28290,28291,28292,28293,28294,\n28295,28296,28297,28298,28299,28300,28301,28302,28303,28304,28305,28306,\n28307,28308,28309,28310,28311,28312,28313,28314,28315,28316,28317,28318,\n28319,28320,28321,28322,28323,28324,28325,28326,28327,28328,28329,28330,\n28331,28332,28333,28334,28335,28336,28337,28338,28339,28340,28341,28342,\n28343,28344,28345,28346,28347,28348,28349,28350,28351,28352,28353,28354,\n28355,28356,28357,28358,28359,28360,28361,28362,28363,28364,28365,28366,\n28367,28368,28369,28370,28371,28372,28373,28374,28375,28376,28377,28378,\n28379,28380,28381,28382,28383,28384,28385,28386,28387,28388,28389,28390,\n28391,28392,28393,28394,28395,28396,28397,28398,28399,28400,28401,28402,\n28403,28404,28405,28406,28407,28408,28409,28410,28411,28412,28413,28414,\n28415,28416,28417,28418,28419,28420,28421,28422,28423,28424,28425,28426,\n28427,28428,28429,28430,28431,28432,28433,28434,28435,28436,28437,28438,\n28439,28440,28441,28442,28443,28444,28445,28446,28447,28448,28449,28450,\n28451,28452,28453,28454,28455,28456,28457,28458,28459,28460,28461,28462,\n28463,28464,28465,28466,28467,28468,28469,28470,28471,28472,28473,28474,\n28475,28476,28477,28478,28479,28480,28481,28482,28483,28484,28485,28486,\n28487,28488,28489,28490,28491,28492,28493,28494,28495,28496,28497,28498,\n28499,28500,28501,28502,28503,28504,28505,28506,28507,28508,28509,28510,\n28511,28512,28513,28514,28515,28516,28517,28518,28519,28520,28521,28522,\n28523,28524,28525,28526,28527,28528,28529,28530,28531,28532,28533,28534,\n28535,28536,28537,28538,28539,28540,28541,28542,28543,28544,28545,28546,\n28547,28548,28549,28550,28551,28552,28553,28554,28555,28556,28557,28558,\n28559,28560,28561,28562,28563,28564,28565,28566,28567,28568,28569,28570,\n28571,28572,28573,28574,28575,28576,28577,28578,28579,28580,28581,28582,\n28583,28584,28585,28586,28587,28588,28589,28590,28591,28592,28593,28594,\n28595,28596,28597,28598,28599,28600,28601,28602,28603,28604,28605,28606,\n28607,28608,28609,28610,28611,28612,28613,28614,28615,28616,28617,28618,\n28619,28620,28621,28622,28623,28624,28625,28626,28627,28628,28629,28630,\n28631,28632,28633,28634,28635,28636,28637,28638,28639,28640,28641,28642,\n28643,28644,28645,28646,28647,28648,28649,28650,28651,28652,28653,28654,\n28655,28656,28657,28658,28659,28660,28661,28662,28663,28664,28665,28666,\n28667,28668,28669,28670,28671,28672,28673,28674,28675,28676,28677,28678,\n28679,28680,28681,28682,28683,28684,28685,28686,28687,28688,28689,28690,\n28691,28692,28693,28694,28695,28696,28697,28698,28699,28700,28701,28702,\n28703,28704,28705,28706,28707,28708,28709,28710,28711,28712,28713,28714,\n28715,28716,28717,28718,28719,28720,28721,28722,28723,28724,28725,28726,\n28727,28728,28729,28730,28731,28732,28733,28734,28735,28736,28737,28738,\n28739,28740,28741,28742,28743,28744,28745,28746,28747,28748,28749,28750,\n28751,28752,28753,28754,28755,28756,28757,28758,28759,28760,28761,28762,\n28763,28764,28765,28766,28767,28768,28769,28770,28771,28772,28773,28774,\n28775,28776,28777,28778,28779,28780,28781,28782,28783,28784,28785,28786,\n28787,28788,28789,28790,28791,28792,28793,28794,28795,28796,28797,28798,\n28799,28800,28801,28802,28803,28804,28805,28806,28807,28808,28809,28810,\n28811,28812,28813,28814,28815,28816,28817,28818,28819,28820,28821,28822,\n28823,28824,28825,28826,28827,28828,28829,28830,28831,28832,28833,28834,\n28835,28836,28837,28838,28839,28840,28841,28842,28843,28844,28845,28846,\n28847,28848,28849,28850,28851,28852,28853,28854,28855,28856,28857,28858,\n28859,28860,28861,28862,28863,28864,28865,28866,28867,28868,28869,28870,\n28871,28872,28873,28874,28875,28876,28877,28878,28879,28880,28881,28882,\n28883,28884,28885,28886,28887,28888,28889,28890,28891,28892,28893,28894,\n28895,28896,28897,28898,28899,28900,28901,28902,28903,28904,28905,28906,\n28907,28908,28909,28910,28911,28912,28913,28914,28915,28916,28917,28918,\n28919,28920,28921,28922,28923,28924,28925,28926,28927,28928,28929,28930,\n28931,28932,28933,28934,28935,28936,28937,28938,28939,28940,28941,28942,\n28943,28944,28945,28946,28947,28948,28949,28950,28951,28952,28953,28954,\n28955,28956,28957,28958,28959,28960,28961,28962,28963,28964,28965,28966,\n28967,28968,28969,28970,28971,28972,28973,28974,28975,28976,28977,28978,\n28979,28980,28981,28982,28983,28984,28985,28986,28987,28988,28989,28990,\n28991,28992,28993,28994,28995,28996,28997,28998,28999,29000,29001,29002,\n29003,29004,29005,29006,29007,29008,29009,29010,29011,29012,29013,29014,\n29015,29016,29017,29018,29019,29020,29021,29022,29023,29024,29025,29026,\n29027,29028,29029,29030,29031,29032,29033,29034,29035,29036,29037,29038,\n29039,29040,29041,29042,29043,29044,29045,29046,29047,29048,29049,29050,\n29051,29052,29053,29054,29055,29056,29057,29058,29059,29060,29061,29062,\n29063,29064,29065,29066,29067,29068,29069,29070,29071,29072,29073,29074,\n29075,29076,29077,29078,29079,29080,29081,29082,29083,29084,29085,29086,\n29087,29088,29089,29090,29091,29092,29093,29094,29095,29096,29097,29098,\n29099,29100,29101,29102,29103,29104,29105,29106,29107,29108,29109,29110,\n29111,29112,29113,29114,29115,29116,29117,29118,29119,29120,29121,29122,\n29123,29124,29125,29126,29127,29128,29129,29130,29131,29132,29133,29134,\n29135,29136,29137,29138,29139,29140,29141,29142,29143,29144,29145,29146,\n29147,29148,29149,29150,29151,29152,29153,29154,29155,29156,29157,29158,\n29159,29160,29161,29162,29163,29164,29165,29166,29167,29168,29169,29170,\n29171,29172,29173,29174,29175,29176,29177,29178,29179,29180,29181,29182,\n29183,29184,29185,29186,29187,29188,29189,29190,29191,29192,29193,29194,\n29195,29196,29197,29198,29199,29200,29201,29202,29203,29204,29205,29206,\n29207,29208,29209,29210,29211,29212,29213,29214,29215,29216,29217,29218,\n29219,29220,29221,29222,29223,29224,29225,29226,29227,29228,29229,29230,\n29231,29232,29233,29234,29235,29236,29237,29238,29239,29240,29241,29242,\n29243,29244,29245,29246,29247,29248,29249,29250,29251,29252,29253,29254,\n29255,29256,29257,29258,29259,29260,29261,29262,29263,29264,29265,29266,\n29267,29268,29269,29270,29271,29272,29273,29274,29275,29276,29277,29278,\n29279,29280,29281,29282,29283,29284,29285,29286,29287,29288,29289,29290,\n29291,29292,29293,29294,29295,29296,29297,29298,29299,29300,29301,29302,\n29303,29304,29305,29306,29307,29308,29309,29310,29311,29312,29313,29314,\n29315,29316,29317,29318,29319,29320,29321,29322,29323,29324,29325,29326,\n29327,29328,29329,29330,29331,29332,29333,29334,29335,29336,29337,29338,\n29339,29340,29341,29342,29343,29344,29345,29346,29347,29348,29349,29350,\n29351,29352,29353,29354,29355,29356,29357,29358,29359,29360,29361,29362,\n29363,29364,29365,29366,29367,29368,29369,29370,29371,29372,29373,29374,\n29375,29376,29377,29378,29379,29380,29381,29382,29383,29384,29385,29386,\n29387,29388,29389,29390,29391,29392,29393,29394,29395,29396,29397,29398,\n29399,29400,29401,29402,29403,29404,29405,29406,29407,29408,29409,29410,\n29411,29412,29413,29414,29415,29416,29417,29418,29419,29420,29421,29422,\n29423,29424,29425,29426,29427,29428,29429,29430,29431,29432,29433,29434,\n29435,29436,29437,29438,29439,29440,29441,29442,29443,29444,29445,29446,\n29447,29448,29449,29450,29451,29452,29453,29454,29455,29456,29457,29458,\n29459,29460,29461,29462,29463,29464,29465,29466,29467,29468,29469,29470,\n29471,29472,29473,29474,29475,29476,29477,29478,29479,29480,29481,29482,\n29483,29484,29485,29486,29487,29488,29489,29490,29491,29492,29493,29494,\n29495,29496,29497,29498,29499,29500,29501,29502,29503,29504,29505,29506,\n29507,29508,29509,29510,29511,29512,29513,29514,29515,29516,29517,29518,\n29519,29520,29521,29522,29523,29524,29525,29526,29527,29528,29529,29530,\n29531,29532,29533,29534,29535,29536,29537,29538,29539,29540,29541,29542,\n29543,29544,29545,29546,29547,29548,29549,29550,29551,29552,29553,29554,\n29555,29556,29557,29558,29559,29560,29561,29562,29563,29564,29565,29566,\n29567,29568,29569,29570,29571,29572,29573,29574,29575,29576,29577,29578,\n29579,29580,29581,29582,29583,29584,29585,29586,29587,29588,29589,29590,\n29591,29592,29593,29594,29595,29596,29597,29598,29599,29600,29601,29602,\n29603,29604,29605,29606,29607,29608,29609,29610,29611,29612,29613,29614,\n29615,29616,29617,29618,29619,29620,29621,29622,29623,29624,29625,29626,\n29627,29628,29629,29630,29631,29632,29633,29634,29635,29636,29637,29638,\n29639,29640,29641,29642,29643,29644,29645,29646,29647,29648,29649,29650,\n29651,29652,29653,29654,29655,29656,29657,29658,29659,29660,29661,29662,\n29663,29664,29665,29666,29667,29668,29669,29670,29671,29672,29673,29674,\n29675,29676,29677,29678,29679,29680,29681,29682,29683,29684,29685,29686,\n29687,29688,29689,29690,29691,29692,29693,29694,29695,29696,29697,29698,\n29699,29700,29701,29702,29703,29704,29705,29706,29707,29708,29709,29710,\n29711,29712,29713,29714,29715,29716,29717,29718,29719,29720,29721,29722,\n29723,29724,29725,29726,29727,29728,29729,29730,29731,29732,29733,29734,\n29735,29736,29737,29738,29739,29740,29741,29742,29743,29744,29745,29746,\n29747,29748,29749,29750,29751,29752,29753,29754,29755,29756,29757,29758,\n29759,29760,29761,29762,29763,29764,29765,29766,29767,29768,29769,29770,\n29771,29772,29773,29774,29775,29776,29777,29778,29779,29780,29781,29782,\n29783,29784,29785,29786,29787,29788,29789,29790,29791,29792,29793,29794,\n29795,29796,29797,29798,29799,29800,29801,29802,29803,29804,29805,29806,\n29807,29808,29809,29810,29811,29812,29813,29814,29815,29816,29817,29818,\n29819,29820,29821,29822,29823,29824,29825,29826,29827,29828,29829,29830,\n29831,29832,29833,29834,29835,29836,29837,29838,29839,29840,29841,29842,\n29843,29844,29845,29846,29847,29848,29849,29850,29851,29852,29853,29854,\n29855,29856,29857,29858,29859,29860,29861,29862,29863,29864,29865,29866,\n29867,29868,29869,29870,29871,29872,29873,29874,29875,29876,29877,29878,\n29879,29880,29881,29882,29883,29884,29885,29886,29887,29888,29889,29890,\n29891,29892,29893,29894,29895,29896,29897,29898,29899,29900,29901,29902,\n29903,29904,29905,29906,29907,29908,29909,29910,29911,29912,29913,29914,\n29915,29916,29917,29918,29919,29920,29921,29922,29923,29924,29925,29926,\n29927,29928,29929,29930,29931,29932,29933,29934,29935,29936,29937,29938,\n29939,29940,29941,29942,29943,29944,29945,29946,29947,29948,29949,29950,\n29951,29952,29953,29954,29955,29956,29957,29958,29959,29960,29961,29962,\n29963,29964,29965,29966,29967,29968,29969,29970,29971,29972,29973,29974,\n29975,29976,29977,29978,29979,29980,29981,29982,29983,29984,29985,29986,\n29987,29988,29989,29990,29991,29992,29993,29994,29995,29996,29997,29998,\n29999,30000,30001,30002,30003,30004,30005,30006,30007,30008,30009,30010,\n30011,30012,30013,30014,30015,30016,30017,30018,30019,30020,30021,30022,\n30023,30024,30025,30026,30027,30028,30029,30030,30031,30032,30033,30034,\n30035,30036,30037,30038,30039,30040,30041,30042,30043,30044,30045,30046,\n30047,30048,30049,30050,30051,30052,30053,30054,30055,30056,30057,30058,\n30059,30060,30061,30062,30063,30064,30065,30066,30067,30068,30069,30070,\n30071,30072,30073,30074,30075,30076,30077,30078,30079,30080,30081,30082,\n30083,30084,30085,30086,30087,30088,30089,30090,30091,30092,30093,30094,\n30095,30096,30097,30098,30099,30100,30101,30102,30103,30104,30105,30106,\n30107,30108,30109,30110,30111,30112,30113,30114,30115,30116,30117,30118,\n30119,30120,30121,30122,30123,30124,30125,30126,30127,30128,30129,30130,\n30131,30132,30133,30134,30135,30136,30137,30138,30139,30140,30141,30142,\n30143,30144,30145,30146,30147,30148,30149,30150,30151,30152,30153,30154,\n30155,30156,30157,30158,30159,30160,30161,30162,30163,30164,30165,30166,\n30167,30168,30169,30170,30171,30172,30173,30174,30175,30176,30177,30178,\n30179,30180,30181,30182,30183,30184,30185,30186,30187,30188,30189,30190,\n30191,30192,30193,30194,30195,30196,30197,30198,30199,30200,30201,30202,\n30203,30204,30205,30206,30207,30208,30209,30210,30211,30212,30213,30214,\n30215,30216,30217,30218,30219,30220,30221,30222,30223,30224,30225,30226,\n30227,30228,30229,30230,30231,30232,30233,30234,30235,30236,30237,30238,\n30239,30240,30241,30242,30243,30244,30245,30246,30247,30248,30249,30250,\n30251,30252,30253,30254,30255,30256,30257,30258,30259,30260,30261,30262,\n30263,30264,30265,30266,30267,30268,30269,30270,30271,30272,30273,30274,\n30275,30276,30277,30278,30279,30280,30281,30282,30283,30284,30285,30286,\n30287,30288,30289,30290,30291,30292,30293,30294,30295,30296,30297,30298,\n30299,30300,30301,30302,30303,30304,30305,30306,30307,30308,30309,30310,\n30311,30312,30313,30314,30315,30316,30317,30318,30319,30320,30321,30322,\n30323,30324,30325,30326,30327,30328,30329,30330,30331,30332,30333,30334,\n30335,30336,30337,30338,30339,30340,30341,30342,30343,30344,30345,30346,\n30347,30348,30349,30350,30351,30352,30353,30354,30355,30356,30357,30358,\n30359,30360,30361,30362,30363,30364,30365,30366,30367,30368,30369,30370,\n30371,30372,30373,30374,30375,30376,30377,30378,30379,30380,30381,30382,\n30383,30384,30385,30386,30387,30388,30389,30390,30391,30392,30393,30394,\n30395,30396,30397,30398,30399,30400,30401,30402,30403,30404,30405,30406,\n30407,30408,30409,30410,30411,30412,30413,30414,30415,30416,30417,30418,\n30419,30420,30421,30422,30423,30424,30425,30426,30427,30428,30429,30430,\n30431,30432,30433,30434,30435,30436,30437,30438,30439,30440,30441,30442,\n30443,30444,30445,30446,30447,30448,30449,30450,30451,30452,30453,30454,\n30455,30456,30457,30458,30459,30460,30461,30462,30463,30464,30465,30466,\n30467,30468,30469,30470,30471,30472,30473,30474,30475,30476,30477,30478,\n30479,30480,30481,30482,30483,30484,30485,30486,30487,30488,30489,30490,\n30491,30492,30493,30494,30495,30496,30497,30498,30499,30500,30501,30502,\n30503,30504,30505,30506,30507,30508,30509,30510,30511,30512,30513,30514,\n30515,30516,30517,30518,30519,30520,30521,30522,30523,30524,30525,30526,\n30527,30528,30529,30530,30531,30532,30533,30534,30535,30536,30537,30538,\n30539,30540,30541,30542,30543,30544,30545,30546,30547,30548,30549,30550,\n30551,30552,30553,30554,30555,30556,30557,30558,30559,30560,30561,30562,\n30563,30564,30565,30566,30567,30568,30569,30570,30571,30572,30573,30574,\n30575,30576,30577,30578,30579,30580,30581,30582,30583,30584,30585,30586,\n30587,30588,30589,30590,30591,30592,30593,30594,30595,30596,30597,30598,\n30599,30600,30601,30602,30603,30604,30605,30606,30607,30608,30609,30610,\n30611,30612,30613,30614,30615,30616,30617,30618,30619,30620,30621,30622,\n30623,30624,30625,30626,30627,30628,30629,30630,30631,30632,30633,30634,\n30635,30636,30637,30638,30639,30640,30641,30642,30643,30644,30645,30646,\n30647,30648,30649,30650,30651,30652,30653,30654,30655,30656,30657,30658,\n30659,30660,30661,30662,30663,30664,30665,30666,30667,30668,30669,30670,\n30671,30672,30673,30674,30675,30676,30677,30678,30679,30680,30681,30682,\n30683,30684,30685,30686,30687,30688,30689,30690,30691,30692,30693,30694,\n30695,30696,30697,30698,30699,30700,30701,30702,30703,30704,30705,30706,\n30707,30708,30709,30710,30711,30712,30713,30714,30715,30716,30717,30718,\n30719,30720,30721,30722,30723,30724,30725,30726,30727,30728,30729,30730,\n30731,30732,30733,30734,30735,30736,30737,30738,30739,30740,30741,30742,\n30743,30744,30745,30746,30747,30748,30749,30750,30751,30752,30753,30754,\n30755,30756,30757,30758,30759,30760,30761,30762,30763,30764,30765,30766,\n30767,30768,30769,30770,30771,30772,30773,30774,30775,30776,30777,30778,\n30779,30780,30781,30782,30783,30784,30785,30786,30787,30788,30789,30790,\n30791,30792,30793,30794,30795,30796,30797,30798,30799,30800,30801,30802,\n30803,30804,30805,30806,30807,30808,30809,30810,30811,30812,30813,30814,\n30815,30816,30817,30818,30819,30820,30821,30822,30823,30824,30825,30826,\n30827,30828,30829,30830,30831,30832,30833,30834,30835,30836,30837,30838,\n30839,30840,30841,30842,30843,30844,30845,30846,30847,30848,30849,30850,\n30851,30852,30853,30854,30855,30856,30857,30858,30859,30860,30861,30862,\n30863,30864,30865,30866,30867,30868,30869,30870,30871,30872,30873,30874,\n30875,30876,30877,30878,30879,30880,30881,30882,30883,30884,30885,30886,\n30887,30888,30889,30890,30891,30892,30893,30894,30895,30896,30897,30898,\n30899,30900,30901,30902,30903,30904,30905,30906,30907,30908,30909,30910,\n30911,30912,30913,30914,30915,30916,30917,30918,30919,30920,30921,30922,\n30923,30924,30925,30926,30927,30928,30929,30930,30931,30932,30933,30934,\n30935,30936,30937,30938,30939,30940,30941,30942,30943,30944,30945,30946,\n30947,30948,30949,30950,30951,30952,30953,30954,30955,30956,30957,30958,\n30959,30960,30961,30962,30963,30964,30965,30966,30967,30968,30969,30970,\n30971,30972,30973,30974,30975,30976,30977,30978,30979,30980,30981,30982,\n30983,30984,30985,30986,30987,30988,30989,30990,30991,30992,30993,30994,\n30995,30996,30997,30998,30999,31000,31001,31002,31003,31004,31005,31006,\n31007,31008,31009,31010,31011,31012,31013,31014,31015,31016,31017,31018,\n31019,31020,31021,31022,31023,31024,31025,31026,31027,31028,31029,31030,\n31031,31032,31033,31034,31035,31036,31037,31038,31039,31040,31041,31042,\n31043,31044,31045,31046,31047,31048,31049,31050,31051,31052,31053,31054,\n31055,31056,31057,31058,31059,31060,31061,31062,31063,31064,31065,31066,\n31067,31068,31069,31070,31071,31072,31073,31074,31075,31076,31077,31078,\n31079,31080,31081,31082,31083,31084,31085,31086,31087,31088,31089,31090,\n31091,31092,31093,31094,31095,31096,31097,31098,31099,31100,31101,31102,\n31103,31104,31105,31106,31107,31108,31109,31110,31111,31112,31113,31114,\n31115,31116,31117,31118,31119,31120,31121,31122,31123,31124,31125,31126,\n31127,31128,31129,31130,31131,31132,31133,31134,31135,31136,31137,31138,\n31139,31140,31141,31142,31143,31144,31145,31146,31147,31148,31149,31150,\n31151,31152,31153,31154,31155,31156,31157,31158,31159,31160,31161,31162,\n31163,31164,31165,31166,31167,31168,31169,31170,31171,31172,31173,31174,\n31175,31176,31177,31178,31179,31180,31181,31182,31183,31184,31185,31186,\n31187,31188,31189,31190,31191,31192,31193,31194,31195,31196,31197,31198,\n31199,31200,31201,31202,31203,31204,31205,31206,31207,31208,31209,31210,\n31211,31212,31213,31214,31215,31216,31217,31218,31219,31220,31221,31222,\n31223,31224,31225,31226,31227,31228,31229,31230,31231,31232,31233,31234,\n31235,31236,31237,31238,31239,31240,31241,31242,31243,31244,31245,31246,\n31247,31248,31249,31250,31251,31252,31253,31254,31255,31256,31257,31258,\n31259,31260,31261,31262,31263,31264,31265,31266,31267,31268,31269,31270,\n31271,31272,31273,31274,31275,31276,31277,31278,31279,31280,31281,31282,\n31283,31284,31285,31286,31287,31288,31289,31290,31291,31292,31293,31294,\n31295,31296,31297,31298,31299,31300,31301,31302,31303,31304,31305,31306,\n31307,31308,31309,31310,31311,31312,31313,31314,31315,31316,31317,31318,\n31319,31320,31321,31322,31323,31324,31325,31326,31327,31328,31329,31330,\n31331,31332,31333,31334,31335,31336,31337,31338,31339,31340,31341,31342,\n31343,31344,31345,31346,31347,31348,31349,31350,31351,31352,31353,31354,\n31355,31356,31357,31358,31359,31360,31361,31362,31363,31364,31365,31366,\n31367,31368,31369,31370,31371,31372,31373,31374,31375,31376,31377,31378,\n31379,31380,31381,31382,31383,31384,31385,31386,31387,31388,31389,31390,\n31391,31392,31393,31394,31395,31396,31397,31398,31399,31400,31401,31402,\n31403,31404,31405,31406,31407,31408,31409,31410,31411,31412,31413,31414,\n31415,31416,31417,31418,31419,31420,31421,31422,31423,31424,31425,31426,\n31427,31428,31429,31430,31431,31432,31433,31434,31435,31436,31437,31438,\n31439,31440,31441,31442,31443,31444,31445,31446,31447,31448,31449,31450,\n31451,31452,31453,31454,31455,31456,31457,31458,31459,31460,31461,31462,\n31463,31464,31465,31466,31467,31468,31469,31470,31471,31472,31473,31474,\n31475,31476,31477,31478,31479,31480,31481,31482,31483,31484,31485,31486,\n31487,31488,31489,31490,31491,31492,31493,31494,31495,31496,31497,31498,\n31499,31500,31501,31502,31503,31504,31505,31506,31507,31508,31509,31510,\n31511,31512,31513,31514,31515,31516,31517,31518,31519,31520,31521,31522,\n31523,31524,31525,31526,31527,31528,31529,31530,31531,31532,31533,31534,\n31535,31536,31537,31538,31539,31540,31541,31542,31543,31544,31545,31546,\n31547,31548,31549,31550,31551,31552,31553,31554,31555,31556,31557,31558,\n31559,31560,31561,31562,31563,31564,31565,31566,31567,31568,31569,31570,\n31571,31572,31573,31574,31575,31576,31577,31578,31579,31580,31581,31582,\n31583,31584,31585,31586,31587,31588,31589,31590,31591,31592,31593,31594,\n31595,31596,31597,31598,31599,31600,31601,31602,31603,31604,31605,31606,\n31607,31608,31609,31610,31611,31612,31613,31614,31615,31616,31617,31618,\n31619,31620,31621,31622,31623,31624,31625,31626,31627,31628,31629,31630,\n31631,31632,31633,31634,31635,31636,31637,31638,31639,31640,31641,31642,\n31643,31644,31645,31646,31647,31648,31649,31650,31651,31652,31653,31654,\n31655,31656,31657,31658,31659,31660,31661,31662,31663,31664,31665,31666,\n31667,31668,31669,31670,31671,31672,31673,31674,31675,31676,31677,31678,\n31679,31680,31681,31682,31683,31684,31685,31686,31687,31688,31689,31690,\n31691,31692,31693,31694,31695,31696,31697,31698,31699,31700,31701,31702,\n31703,31704,31705,31706,31707,31708,31709,31710,31711,31712,31713,31714,\n31715,31716,31717,31718,31719,31720,31721,31722,31723,31724,31725,31726,\n31727,31728,31729,31730,31731,31732,31733,31734,31735,31736,31737,31738,\n31739,31740,31741,31742,31743,31744,31745,31746,31747,31748,31749,31750,\n31751,31752,31753,31754,31755,31756,31757,31758,31759,31760,31761,31762,\n31763,31764,31765,31766,31767,31768,31769,31770,31771,31772,31773,31774,\n31775,31776,31777,31778,31779,31780,31781,31782,31783,31784,31785,31786,\n31787,31788,31789,31790,31791,31792,31793,31794,31795,31796,31797,31798,\n31799,31800,31801,31802,31803,31804,31805,31806,31807,31808,31809,31810,\n31811,31812,31813,31814,31815,31816,31817,31818,31819,31820,31821,31822,\n31823,31824,31825,31826,31827,31828,31829,31830,31831,31832,31833,31834,\n31835,31836,31837,31838,31839,31840,31841,31842,31843,31844,31845,31846,\n31847,31848,31849,31850,31851,31852,31853,31854,31855,31856,31857,31858,\n31859,31860,31861,31862,31863,31864,31865,31866,31867,31868,31869,31870,\n31871,31872,31873,31874,31875,31876,31877,31878,31879,31880,31881,31882,\n31883,31884,31885,31886,31887,31888,31889,31890,31891,31892,31893,31894,\n31895,31896,31897,31898,31899,31900,31901,31902,31903,31904,31905,31906,\n31907,31908,31909,31910,31911,31912,31913,31914,31915,31916,31917,31918,\n31919,31920,31921,31922,31923,31924,31925,31926,31927,31928,31929,31930,\n31931,31932,31933,31934,31935,31936,31937,31938,31939,31940,31941,31942,\n31943,31944,31945,31946,31947,31948,31949,31950,31951,31952,31953,31954,\n31955,31956,31957,31958,31959,31960,31961,31962,31963,31964,31965,31966,\n31967,31968,31969,31970,31971,31972,31973,31974,31975,31976,31977,31978,\n31979,31980,31981,31982,31983,31984,31985,31986,31987,31988,31989,31990,\n31991,31992,31993,31994,31995,31996,31997,31998,31999,32000,32001,32002,\n32003,32004,32005,32006,32007,32008,32009,32010,32011,32012,32013,32014,\n32015,32016,32017,32018,32019,32020,32021,32022,32023,32024,32025,32026,\n32027,32028,32029,32030,32031,32032,32033,32034,32035,32036,32037,32038,\n32039,32040,32041,32042,32043,32044,32045,32046,32047,32048,32049,32050,\n32051,32052,32053,32054,32055,32056,32057,32058,32059,32060,32061,32062,\n32063,32064,32065,32066,32067,32068,32069,32070,32071,32072,32073,32074,\n32075,32076,32077,32078,32079,32080,32081,32082,32083,32084,32085,32086,\n32087,32088,32089,32090,32091,32092,32093,32094,32095,32096,32097,32098,\n32099,32100,32101,32102,32103,32104,32105,32106,32107,32108,32109,32110,\n32111,32112,32113,32114,32115,32116,32117,32118,32119,32120,32121,32122,\n32123,32124,32125,32126,32127,32128,32129,32130,32131,32132,32133,32134,\n32135,32136,32137,32138,32139,32140,32141,32142,32143,32144,32145,32146,\n32147,32148,32149,32150,32151,32152,32153,32154,32155,32156,32157,32158,\n32159,32160,32161,32162,32163,32164,32165,32166,32167,32168,32169,32170,\n32171,32172,32173,32174,32175,32176,32177,32178,32179,32180,32181,32182,\n32183,32184,32185,32186,32187,32188,32189,32190,32191,32192,32193,32194,\n32195,32196,32197,32198,32199,32200,32201,32202,32203,32204,32205,32206,\n32207,32208,32209,32210,32211,32212,32213,32214,32215,32216,32217,32218,\n32219,32220,32221,32222,32223,32224,32225,32226,32227,32228,32229,32230,\n32231,32232,32233,32234,32235,32236,32237,32238,32239,32240,32241,32242,\n32243,32244,32245,32246,32247,32248,32249,32250,32251,32252,32253,32254,\n32255,32256,32257,32258,32259,32260,32261,32262,32263,32264,32265,32266,\n32267,32268,32269,32270,32271,32272,32273,32274,32275,32276,32277,32278,\n32279,32280,32281,32282,32283,32284,32285,32286,32287,32288,32289,32290,\n32291,32292,32293,32294,32295,32296,32297,32298,32299,32300,32301,32302,\n32303,32304,32305,32306,32307,32308,32309,32310,32311,32312,32313,32314,\n32315,32316,32317,32318,32319,32320,32321,32322,32323,32324,32325,32326,\n32327,32328,32329,32330,32331,32332,32333,32334,32335,32336,32337,32338,\n32339,32340,32341,32342,32343,32344,32345,32346,32347,32348,32349,32350,\n32351,32352,32353,32354,32355,32356,32357,32358,32359,32360,32361,32362,\n32363,32364,32365,32366,32367,32368,32369,32370,32371,32372,32373,32374,\n32375,32376,32377,32378,32379,32380,32381,32382,32383,32384,32385,32386,\n32387,32388,32389,32390,32391,32392,32393,32394,32395,32396,32397,32398,\n32399,32400,32401,32402,32403,32404,32405,32406,32407,32408,32409,32410,\n32411,32412,32413,32414,32415,32416,32417,32418,32419,32420,32421,32422,\n32423,32424,32425,32426,32427,32428,32429,32430,32431,32432,32433,32434,\n32435,32436,32437,32438,32439,32440,32441,32442,32443,32444,32445,32446,\n32447,32448,32449,32450,32451,32452,32453,32454,32455,32456,32457,32458,\n32459,32460,32461,32462,32463,32464,32465,32466,32467,32468,32469,32470,\n32471,32472,32473,32474,32475,32476,32477,32478,32479,32480,32481,32482,\n32483,32484,32485,32486,32487,32488,32489,32490,32491,32492,32493,32494,\n32495,32496,32497,32498,32499,32500,32501,32502,32503,32504,32505,32506,\n32507,32508,32509,32510,32511,32512,32513,32514,32515,32516,32517,32518,\n32519,32520,32521,32522,32523,32524,32525,32526,32527,32528,32529,32530,\n32531,32532,32533,32534,32535,32536,32537,32538,32539,32540,32541,32542,\n32543,32544,32545,32546,32547,32548,32549,32550,32551,32552,32553,32554,\n32555,32556,32557,32558,32559,32560,32561,32562,32563,32564,32565,32566,\n32567,32568,32569,32570,32571,32572,32573,32574,32575,32576,32577,32578,\n32579,32580,32581,32582,32583,32584,32585,32586,32587,32588,32589,32590,\n32591,32592,32593,32594,32595,32596,32597,32598,32599,32600,32601,32602,\n32603,32604,32605,32606,32607,32608,32609,32610,32611,32612,32613,32614,\n32615,32616,32617,32618,32619,32620,32621,32622,32623,32624,32625,32626,\n32627,32628,32629,32630,32631,32632,32633,32634,32635,32636,32637,32638,\n32639,32640,32641,32642,32643,32644,32645,32646,32647,32648,32649,32650,\n32651,32652,32653,32654,32655,32656,32657,32658,32659,32660,32661,32662,\n32663,32664,32665,32666,32667,32668,32669,32670,32671,32672,32673,32674,\n32675,32676,32677,32678,32679,32680,32681,32682,32683,32684,32685,32686,\n32687,32688,32689,32690,32691,32692,32693,32694,32695,32696,32697,32698,\n32699,32700,32701,32702,32703,32704,32705,32706,32707,32708,32709,32710,\n32711,32712,32713,32714,32715,32716,32717,32718,32719,32720,32721,32722,\n32723,32724,32725,32726,32727,32728,32729,32730,32731,32732,32733,32734,\n32735,32736,32737,32738,32739,32740,32741,32742,32743,32744,32745,32746,\n32747,32748,32749,32750,32751,32752,32753,32754,32755,32756,32757,32758,\n32759,32760,32761,32762,32763,32764,32765,32766,32767,32768L,32769L,32770L,\n32771L,32772L,32773L,32774L,32775L,32776L,32777L,32778L,32779L,32780L,\n32781L,32782L,32783L,32784L,32785L,32786L,32787L,32788L,32789L,32790L,\n32791L,32792L,32793L,32794L,32795L,32796L,32797L,32798L,32799L,32800L,\n32801L,32802L,32803L,32804L,32805L,32806L,32807L,32808L,32809L,32810L,\n32811L,32812L,32813L,32814L,32815L,32816L,32817L,32818L,32819L,32820L,\n32821L,32822L,32823L,32824L,32825L,32826L,32827L,32828L,32829L,32830L,\n32831L,32832L,32833L,32834L,32835L,32836L,32837L,32838L,32839L,32840L,\n32841L,32842L,32843L,32844L,32845L,32846L,32847L,32848L,32849L,32850L,\n32851L,32852L,32853L,32854L,32855L,32856L,32857L,32858L,32859L,32860L,\n32861L,32862L,32863L,32864L,32865L,32866L,32867L,32868L,32869L,32870L,\n32871L,32872L,32873L,32874L,32875L,32876L,32877L,32878L,32879L,32880L,\n32881L,32882L,32883L,32884L,32885L,32886L,32887L,32888L,32889L,32890L,\n32891L,32892L,32893L,32894L,32895L,32896L,32897L,32898L,32899L,32900L,\n32901L,32902L,32903L,32904L,32905L,32906L,32907L,32908L,32909L,32910L,\n32911L,32912L,32913L,32914L,32915L,32916L,32917L,32918L,32919L,32920L,\n32921L,32922L,32923L,32924L,32925L,32926L,32927L,32928L,32929L,32930L,\n32931L,32932L,32933L,32934L,32935L,32936L,32937L,32938L,32939L,32940L,\n32941L,32942L,32943L,32944L,32945L,32946L,32947L,32948L,32949L,32950L,\n32951L,32952L,32953L,32954L,32955L,32956L,32957L,32958L,32959L,32960L,\n32961L,32962L,32963L,32964L,32965L,32966L,32967L,32968L,32969L,32970L,\n32971L,32972L,32973L,32974L,32975L,32976L,32977L,32978L,32979L,32980L,\n32981L,32982L,32983L,32984L,32985L,32986L,32987L,32988L,32989L,32990L,\n32991L,32992L,32993L,32994L,32995L,32996L,32997L,32998L,32999L,33000L,\n33001L,33002L,33003L,33004L,33005L,33006L,33007L,33008L,33009L,33010L,\n33011L,33012L,33013L,33014L,33015L,33016L,33017L,33018L,33019L,33020L,\n33021L,33022L,33023L,33024L,33025L,33026L,33027L,33028L,33029L,33030L,\n33031L,33032L,33033L,33034L,33035L,33036L,33037L,33038L,33039L,33040L,\n33041L,33042L,33043L,33044L,33045L,33046L,33047L,33048L,33049L,33050L,\n33051L,33052L,33053L,33054L,33055L,33056L,33057L,33058L,33059L,33060L,\n33061L,33062L,33063L,33064L,33065L,33066L,33067L,33068L,33069L,33070L,\n33071L,33072L,33073L,33074L,33075L,33076L,33077L,33078L,33079L,33080L,\n33081L,33082L,33083L,33084L,33085L,33086L,33087L,33088L,33089L,33090L,\n33091L,33092L,33093L,33094L,33095L,33096L,33097L,33098L,33099L,33100L,\n33101L,33102L,33103L,33104L,33105L,33106L,33107L,33108L,33109L,33110L,\n33111L,33112L,33113L,33114L,33115L,33116L,33117L,33118L,33119L,33120L,\n33121L,33122L,33123L,33124L,33125L,33126L,33127L,33128L,33129L,33130L,\n33131L,33132L,33133L,33134L,33135L,33136L,33137L,33138L,33139L,33140L,\n33141L,33142L,33143L,33144L,33145L,33146L,33147L,33148L,33149L,33150L,\n33151L,33152L,33153L,33154L,33155L,33156L,33157L,33158L,33159L,33160L,\n33161L,33162L,33163L,33164L,33165L,33166L,33167L,33168L,33169L,33170L,\n33171L,33172L,33173L,33174L,33175L,33176L,33177L,33178L,33179L,33180L,\n33181L,33182L,33183L,33184L,33185L,33186L,33187L,33188L,33189L,33190L,\n33191L,33192L,33193L,33194L,33195L,33196L,33197L,33198L,33199L,33200L,\n33201L,33202L,33203L,33204L,33205L,33206L,33207L,33208L,33209L,33210L,\n33211L,33212L,33213L,33214L,33215L,33216L,33217L,33218L,33219L,33220L,\n33221L,33222L,33223L,33224L,33225L,33226L,33227L,33228L,33229L,33230L,\n33231L,33232L,33233L,33234L,33235L,33236L,33237L,33238L,33239L,33240L,\n33241L,33242L,33243L,33244L,33245L,33246L,33247L,33248L,33249L,33250L,\n33251L,33252L,33253L,33254L,33255L,33256L,33257L,33258L,33259L,33260L,\n33261L,33262L,33263L,33264L,33265L,33266L,33267L,33268L,33269L,33270L,\n33271L,33272L,33273L,33274L,33275L,33276L,33277L,33278L,33279L,33280L,\n33281L,33282L,33283L,33284L,33285L,33286L,33287L,33288L,33289L,33290L,\n33291L,33292L,33293L,33294L,33295L,33296L,33297L,33298L,33299L,33300L,\n33301L,33302L,33303L,33304L,33305L,33306L,33307L,33308L,33309L,33310L,\n33311L,33312L,33313L,33314L,33315L,33316L,33317L,33318L,33319L,33320L,\n33321L,33322L,33323L,33324L,33325L,33326L,33327L,33328L,33329L,33330L,\n33331L,33332L,33333L,33334L,33335L,33336L,33337L,33338L,33339L,33340L,\n33341L,33342L,33343L,33344L,33345L,33346L,33347L,33348L,33349L,33350L,\n33351L,33352L,33353L,33354L,33355L,33356L,33357L,33358L,33359L,33360L,\n33361L,33362L,33363L,33364L,33365L,33366L,33367L,33368L,33369L,33370L,\n33371L,33372L,33373L,33374L,33375L,33376L,33377L,33378L,33379L,33380L,\n33381L,33382L,33383L,33384L,33385L,33386L,33387L,33388L,33389L,33390L,\n33391L,33392L,33393L,33394L,33395L,33396L,33397L,33398L,33399L,33400L,\n33401L,33402L,33403L,33404L,33405L,33406L,33407L,33408L,33409L,33410L,\n33411L,33412L,33413L,33414L,33415L,33416L,33417L,33418L,33419L,33420L,\n33421L,33422L,33423L,33424L,33425L,33426L,33427L,33428L,33429L,33430L,\n33431L,33432L,33433L,33434L,33435L,33436L,33437L,33438L,33439L,33440L,\n33441L,33442L,33443L,33444L,33445L,33446L,33447L,33448L,33449L,33450L,\n33451L,33452L,33453L,33454L,33455L,33456L,33457L,33458L,33459L,33460L,\n33461L,33462L,33463L,33464L,33465L,33466L,33467L,33468L,33469L,33470L,\n33471L,33472L,33473L,33474L,33475L,33476L,33477L,33478L,33479L,33480L,\n33481L,33482L,33483L,33484L,33485L,33486L,33487L,33488L,33489L,33490L,\n33491L,33492L,33493L,33494L,33495L,33496L,33497L,33498L,33499L,33500L,\n33501L,33502L,33503L,33504L,33505L,33506L,33507L,33508L,33509L,33510L,\n33511L,33512L,33513L,33514L,33515L,33516L,33517L,33518L,33519L,33520L,\n33521L,33522L,33523L,33524L,33525L,33526L,33527L,33528L,33529L,33530L,\n33531L,33532L,33533L,33534L,33535L,33536L,33537L,33538L,33539L,33540L,\n33541L,33542L,33543L,33544L,33545L,33546L,33547L,33548L,33549L,33550L,\n33551L,33552L,33553L,33554L,33555L,33556L,33557L,33558L,33559L,33560L,\n33561L,33562L,33563L,33564L,33565L,33566L,33567L,33568L,33569L,33570L,\n33571L,33572L,33573L,33574L,33575L,33576L,33577L,33578L,33579L,33580L,\n33581L,33582L,33583L,33584L,33585L,33586L,33587L,33588L,33589L,33590L,\n33591L,33592L,33593L,33594L,33595L,33596L,33597L,33598L,33599L,33600L,\n33601L,33602L,33603L,33604L,33605L,33606L,33607L,33608L,33609L,33610L,\n33611L,33612L,33613L,33614L,33615L,33616L,33617L,33618L,33619L,33620L,\n33621L,33622L,33623L,33624L,33625L,33626L,33627L,33628L,33629L,33630L,\n33631L,33632L,33633L,33634L,33635L,33636L,33637L,33638L,33639L,33640L,\n33641L,33642L,33643L,33644L,33645L,33646L,33647L,33648L,33649L,33650L,\n33651L,33652L,33653L,33654L,33655L,33656L,33657L,33658L,33659L,33660L,\n33661L,33662L,33663L,33664L,33665L,33666L,33667L,33668L,33669L,33670L,\n33671L,33672L,33673L,33674L,33675L,33676L,33677L,33678L,33679L,33680L,\n33681L,33682L,33683L,33684L,33685L,33686L,33687L,33688L,33689L,33690L,\n33691L,33692L,33693L,33694L,33695L,33696L,33697L,33698L,33699L,33700L,\n33701L,33702L,33703L,33704L,33705L,33706L,33707L,33708L,33709L,33710L,\n33711L,33712L,33713L,33714L,33715L,33716L,33717L,33718L,33719L,33720L,\n33721L,33722L,33723L,33724L,33725L,33726L,33727L,33728L,33729L,33730L,\n33731L,33732L,33733L,33734L,33735L,33736L,33737L,33738L,33739L,33740L,\n33741L,33742L,33743L,33744L,33745L,33746L,33747L,33748L,33749L,33750L,\n33751L,33752L,33753L,33754L,33755L,33756L,33757L,33758L,33759L,33760L,\n33761L,33762L,33763L,33764L,33765L,33766L,33767L,33768L,33769L,33770L,\n33771L,33772L,33773L,33774L,33775L,33776L,33777L,33778L,33779L,33780L,\n33781L,33782L,33783L,33784L,33785L,33786L,33787L,33788L,33789L,33790L,\n33791L,33792L,33793L,33794L,33795L,33796L,33797L,33798L,33799L,33800L,\n33801L,33802L,33803L,33804L,33805L,33806L,33807L,33808L,33809L,33810L,\n33811L,33812L,33813L,33814L,33815L,33816L,33817L,33818L,33819L,33820L,\n33821L,33822L,33823L,33824L,33825L,33826L,33827L,33828L,33829L,33830L,\n33831L,33832L,33833L,33834L,33835L,33836L,33837L,33838L,33839L,33840L,\n33841L,33842L,33843L,33844L,33845L,33846L,33847L,33848L,33849L,33850L,\n33851L,33852L,33853L,33854L,33855L,33856L,33857L,33858L,33859L,33860L,\n33861L,33862L,33863L,33864L,33865L,33866L,33867L,33868L,33869L,33870L,\n33871L,33872L,33873L,33874L,33875L,33876L,33877L,33878L,33879L,33880L,\n33881L,33882L,33883L,33884L,33885L,33886L,33887L,33888L,33889L,33890L,\n33891L,33892L,33893L,33894L,33895L,33896L,33897L,33898L,33899L,33900L,\n33901L,33902L,33903L,33904L,33905L,33906L,33907L,33908L,33909L,33910L,\n33911L,33912L,33913L,33914L,33915L,33916L,33917L,33918L,33919L,33920L,\n33921L,33922L,33923L,33924L,33925L,33926L,33927L,33928L,33929L,33930L,\n33931L,33932L,33933L,33934L,33935L,33936L,33937L,33938L,33939L,33940L,\n33941L,33942L,33943L,33944L,33945L,33946L,33947L,33948L,33949L,33950L,\n33951L,33952L,33953L,33954L,33955L,33956L,33957L,33958L,33959L,33960L,\n33961L,33962L,33963L,33964L,33965L,33966L,33967L,33968L,33969L,33970L,\n33971L,33972L,33973L,33974L,33975L,33976L,33977L,33978L,33979L,33980L,\n33981L,33982L,33983L,33984L,33985L,33986L,33987L,33988L,33989L,33990L,\n33991L,33992L,33993L,33994L,33995L,33996L,33997L,33998L,33999L,34000L,\n34001L,34002L,34003L,34004L,34005L,34006L,34007L,34008L,34009L,34010L,\n34011L,34012L,34013L,34014L,34015L,34016L,34017L,34018L,34019L,34020L,\n34021L,34022L,34023L,34024L,34025L,34026L,34027L,34028L,34029L,34030L,\n34031L,34032L,34033L,34034L,34035L,34036L,34037L,34038L,34039L,34040L,\n34041L,34042L,34043L,34044L,34045L,34046L,34047L,34048L,34049L,34050L,\n34051L,34052L,34053L,34054L,34055L,34056L,34057L,34058L,34059L,34060L,\n34061L,34062L,34063L,34064L,34065L,34066L,34067L,34068L,34069L,34070L,\n34071L,34072L,34073L,34074L,34075L,34076L,34077L,34078L,34079L,34080L,\n34081L,34082L,34083L,34084L,34085L,34086L,34087L,34088L,34089L,34090L,\n34091L,34092L,34093L,34094L,34095L,34096L,34097L,34098L,34099L,34100L,\n34101L,34102L,34103L,34104L,34105L,34106L,34107L,34108L,34109L,34110L,\n34111L,34112L,34113L,34114L,34115L,34116L,34117L,34118L,34119L,34120L,\n34121L,34122L,34123L,34124L,34125L,34126L,34127L,34128L,34129L,34130L,\n34131L,34132L,34133L,34134L,34135L,34136L,34137L,34138L,34139L,34140L,\n34141L,34142L,34143L,34144L,34145L,34146L,34147L,34148L,34149L,34150L,\n34151L,34152L,34153L,34154L,34155L,34156L,34157L,34158L,34159L,34160L,\n34161L,34162L,34163L,34164L,34165L,34166L,34167L,34168L,34169L,34170L,\n34171L,34172L,34173L,34174L,34175L,34176L,34177L,34178L,34179L,34180L,\n34181L,34182L,34183L,34184L,34185L,34186L,34187L,34188L,34189L,34190L,\n34191L,34192L,34193L,34194L,34195L,34196L,34197L,34198L,34199L,34200L,\n34201L,34202L,34203L,34204L,34205L,34206L,34207L,34208L,34209L,34210L,\n34211L,34212L,34213L,34214L,34215L,34216L,34217L,34218L,34219L,34220L,\n34221L,34222L,34223L,34224L,34225L,34226L,34227L,34228L,34229L,34230L,\n34231L,34232L,34233L,34234L,34235L,34236L,34237L,34238L,34239L,34240L,\n34241L,34242L,34243L,34244L,34245L,34246L,34247L,34248L,34249L,34250L,\n34251L,34252L,34253L,34254L,34255L,34256L,34257L,34258L,34259L,34260L,\n34261L,34262L,34263L,34264L,34265L,34266L,34267L,34268L,34269L,34270L,\n34271L,34272L,34273L,34274L,34275L,34276L,34277L,34278L,34279L,34280L,\n34281L,34282L,34283L,34284L,34285L,34286L,34287L,34288L,34289L,34290L,\n34291L,34292L,34293L,34294L,34295L,34296L,34297L,34298L,34299L,34300L,\n34301L,34302L,34303L,34304L,34305L,34306L,34307L,34308L,34309L,34310L,\n34311L,34312L,34313L,34314L,34315L,34316L,34317L,34318L,34319L,34320L,\n34321L,34322L,34323L,34324L,34325L,34326L,34327L,34328L,34329L,34330L,\n34331L,34332L,34333L,34334L,34335L,34336L,34337L,34338L,34339L,34340L,\n34341L,34342L,34343L,34344L,34345L,34346L,34347L,34348L,34349L,34350L,\n34351L,34352L,34353L,34354L,34355L,34356L,34357L,34358L,34359L,34360L,\n34361L,34362L,34363L,34364L,34365L,34366L,34367L,34368L,34369L,34370L,\n34371L,34372L,34373L,34374L,34375L,34376L,34377L,34378L,34379L,34380L,\n34381L,34382L,34383L,34384L,34385L,34386L,34387L,34388L,34389L,34390L,\n34391L,34392L,34393L,34394L,34395L,34396L,34397L,34398L,34399L,34400L,\n34401L,34402L,34403L,34404L,34405L,34406L,34407L,34408L,34409L,34410L,\n34411L,34412L,34413L,34414L,34415L,34416L,34417L,34418L,34419L,34420L,\n34421L,34422L,34423L,34424L,34425L,34426L,34427L,34428L,34429L,34430L,\n34431L,34432L,34433L,34434L,34435L,34436L,34437L,34438L,34439L,34440L,\n34441L,34442L,34443L,34444L,34445L,34446L,34447L,34448L,34449L,34450L,\n34451L,34452L,34453L,34454L,34455L,34456L,34457L,34458L,34459L,34460L,\n34461L,34462L,34463L,34464L,34465L,34466L,34467L,34468L,34469L,34470L,\n34471L,34472L,34473L,34474L,34475L,34476L,34477L,34478L,34479L,34480L,\n34481L,34482L,34483L,34484L,34485L,34486L,34487L,34488L,34489L,34490L,\n34491L,34492L,34493L,34494L,34495L,34496L,34497L,34498L,34499L,34500L,\n34501L,34502L,34503L,34504L,34505L,34506L,34507L,34508L,34509L,34510L,\n34511L,34512L,34513L,34514L,34515L,34516L,34517L,34518L,34519L,34520L,\n34521L,34522L,34523L,34524L,34525L,34526L,34527L,34528L,34529L,34530L,\n34531L,34532L,34533L,34534L,34535L,34536L,34537L,34538L,34539L,34540L,\n34541L,34542L,34543L,34544L,34545L,34546L,34547L,34548L,34549L,34550L,\n34551L,34552L,34553L,34554L,34555L,34556L,34557L,34558L,34559L,34560L,\n34561L,34562L,34563L,34564L,34565L,34566L,34567L,34568L,34569L,34570L,\n34571L,34572L,34573L,34574L,34575L,34576L,34577L,34578L,34579L,34580L,\n34581L,34582L,34583L,34584L,34585L,34586L,34587L,34588L,34589L,34590L,\n34591L,34592L,34593L,34594L,34595L,34596L,34597L,34598L,34599L,34600L,\n34601L,34602L,34603L,34604L,34605L,34606L,34607L,34608L,34609L,34610L,\n34611L,34612L,34613L,34614L,34615L,34616L,34617L,34618L,34619L,34620L,\n34621L,34622L,34623L,34624L,34625L,34626L,34627L,34628L,34629L,34630L,\n34631L,34632L,34633L,34634L,34635L,34636L,34637L,34638L,34639L,34640L,\n34641L,34642L,34643L,34644L,34645L,34646L,34647L,34648L,34649L,34650L,\n34651L,34652L,34653L,34654L,34655L,34656L,34657L,34658L,34659L,34660L,\n34661L,34662L,34663L,34664L,34665L,34666L,34667L,34668L,34669L,34670L,\n34671L,34672L,34673L,34674L,34675L,34676L,34677L,34678L,34679L,34680L,\n34681L,34682L,34683L,34684L,34685L,34686L,34687L,34688L,34689L,34690L,\n34691L,34692L,34693L,34694L,34695L,34696L,34697L,34698L,34699L,34700L,\n34701L,34702L,34703L,34704L,34705L,34706L,34707L,34708L,34709L,34710L,\n34711L,34712L,34713L,34714L,34715L,34716L,34717L,34718L,34719L,34720L,\n34721L,34722L,34723L,34724L,34725L,34726L,34727L,34728L,34729L,34730L,\n34731L,34732L,34733L,34734L,34735L,34736L,34737L,34738L,34739L,34740L,\n34741L,34742L,34743L,34744L,34745L,34746L,34747L,34748L,34749L,34750L,\n34751L,34752L,34753L,34754L,34755L,34756L,34757L,34758L,34759L,34760L,\n34761L,34762L,34763L,34764L,34765L,34766L,34767L,34768L,34769L,34770L,\n34771L,34772L,34773L,34774L,34775L,34776L,34777L,34778L,34779L,34780L,\n34781L,34782L,34783L,34784L,34785L,34786L,34787L,34788L,34789L,34790L,\n34791L,34792L,34793L,34794L,34795L,34796L,34797L,34798L,34799L,34800L,\n34801L,34802L,34803L,34804L,34805L,34806L,34807L,34808L,34809L,34810L,\n34811L,34812L,34813L,34814L,34815L,34816L,34817L,34818L,34819L,34820L,\n34821L,34822L,34823L,34824L,34825L,34826L,34827L,34828L,34829L,34830L,\n34831L,34832L,34833L,34834L,34835L,34836L,34837L,34838L,34839L,34840L,\n34841L,34842L,34843L,34844L,34845L,34846L,34847L,34848L,34849L,34850L,\n34851L,34852L,34853L,34854L,34855L,34856L,34857L,34858L,34859L,34860L,\n34861L,34862L,34863L,34864L,34865L,34866L,34867L,34868L,34869L,34870L,\n34871L,34872L,34873L,34874L,34875L,34876L,34877L,34878L,34879L,34880L,\n34881L,34882L,34883L,34884L,34885L,34886L,34887L,34888L,34889L,34890L,\n34891L,34892L,34893L,34894L,34895L,34896L,34897L,34898L,34899L,34900L,\n34901L,34902L,34903L,34904L,34905L,34906L,34907L,34908L,34909L,34910L,\n34911L,34912L,34913L,34914L,34915L,34916L,34917L,34918L,34919L,34920L,\n34921L,34922L,34923L,34924L,34925L,34926L,34927L,34928L,34929L,34930L,\n34931L,34932L,34933L,34934L,34935L,34936L,34937L,34938L,34939L,34940L,\n34941L,34942L,34943L,34944L,34945L,34946L,34947L,34948L,34949L,34950L,\n34951L,34952L,34953L,34954L,34955L,34956L,34957L,34958L,34959L,34960L,\n34961L,34962L,34963L,34964L,34965L,34966L,34967L,34968L,34969L,34970L,\n34971L,34972L,34973L,34974L,34975L,34976L,34977L,34978L,34979L,34980L,\n34981L,34982L,34983L,34984L,34985L,34986L,34987L,34988L,34989L,34990L,\n34991L,34992L,34993L,34994L,34995L,34996L,34997L,34998L,34999L,35000L,\n35001L,35002L,35003L,35004L,35005L,35006L,35007L,35008L,35009L,35010L,\n35011L,35012L,35013L,35014L,35015L,35016L,35017L,35018L,35019L,35020L,\n35021L,35022L,35023L,35024L,35025L,35026L,35027L,35028L,35029L,35030L,\n35031L,35032L,35033L,35034L,35035L,35036L,35037L,35038L,35039L,35040L,\n35041L,35042L,35043L,35044L,35045L,35046L,35047L,35048L,35049L,35050L,\n35051L,35052L,35053L,35054L,35055L,35056L,35057L,35058L,35059L,35060L,\n35061L,35062L,35063L,35064L,35065L,35066L,35067L,35068L,35069L,35070L,\n35071L,35072L,35073L,35074L,35075L,35076L,35077L,35078L,35079L,35080L,\n35081L,35082L,35083L,35084L,35085L,35086L,35087L,35088L,35089L,35090L,\n35091L,35092L,35093L,35094L,35095L,35096L,35097L,35098L,35099L,35100L,\n35101L,35102L,35103L,35104L,35105L,35106L,35107L,35108L,35109L,35110L,\n35111L,35112L,35113L,35114L,35115L,35116L,35117L,35118L,35119L,35120L,\n35121L,35122L,35123L,35124L,35125L,35126L,35127L,35128L,35129L,35130L,\n35131L,35132L,35133L,35134L,35135L,35136L,35137L,35138L,35139L,35140L,\n35141L,35142L,35143L,35144L,35145L,35146L,35147L,35148L,35149L,35150L,\n35151L,35152L,35153L,35154L,35155L,35156L,35157L,35158L,35159L,35160L,\n35161L,35162L,35163L,35164L,35165L,35166L,35167L,35168L,35169L,35170L,\n35171L,35172L,35173L,35174L,35175L,35176L,35177L,35178L,35179L,35180L,\n35181L,35182L,35183L,35184L,35185L,35186L,35187L,35188L,35189L,35190L,\n35191L,35192L,35193L,35194L,35195L,35196L,35197L,35198L,35199L,35200L,\n35201L,35202L,35203L,35204L,35205L,35206L,35207L,35208L,35209L,35210L,\n35211L,35212L,35213L,35214L,35215L,35216L,35217L,35218L,35219L,35220L,\n35221L,35222L,35223L,35224L,35225L,35226L,35227L,35228L,35229L,35230L,\n35231L,35232L,35233L,35234L,35235L,35236L,35237L,35238L,35239L,35240L,\n35241L,35242L,35243L,35244L,35245L,35246L,35247L,35248L,35249L,35250L,\n35251L,35252L,35253L,35254L,35255L,35256L,35257L,35258L,35259L,35260L,\n35261L,35262L,35263L,35264L,35265L,35266L,35267L,35268L,35269L,35270L,\n35271L,35272L,35273L,35274L,35275L,35276L,35277L,35278L,35279L,35280L,\n35281L,35282L,35283L,35284L,35285L,35286L,35287L,35288L,35289L,35290L,\n35291L,35292L,35293L,35294L,35295L,35296L,35297L,35298L,35299L,35300L,\n35301L,35302L,35303L,35304L,35305L,35306L,35307L,35308L,35309L,35310L,\n35311L,35312L,35313L,35314L,35315L,35316L,35317L,35318L,35319L,35320L,\n35321L,35322L,35323L,35324L,35325L,35326L,35327L,35328L,35329L,35330L,\n35331L,35332L,35333L,35334L,35335L,35336L,35337L,35338L,35339L,35340L,\n35341L,35342L,35343L,35344L,35345L,35346L,35347L,35348L,35349L,35350L,\n35351L,35352L,35353L,35354L,35355L,35356L,35357L,35358L,35359L,35360L,\n35361L,35362L,35363L,35364L,35365L,35366L,35367L,35368L,35369L,35370L,\n35371L,35372L,35373L,35374L,35375L,35376L,35377L,35378L,35379L,35380L,\n35381L,35382L,35383L,35384L,35385L,35386L,35387L,35388L,35389L,35390L,\n35391L,35392L,35393L,35394L,35395L,35396L,35397L,35398L,35399L,35400L,\n35401L,35402L,35403L,35404L,35405L,35406L,35407L,35408L,35409L,35410L,\n35411L,35412L,35413L,35414L,35415L,35416L,35417L,35418L,35419L,35420L,\n35421L,35422L,35423L,35424L,35425L,35426L,35427L,35428L,35429L,35430L,\n35431L,35432L,35433L,35434L,35435L,35436L,35437L,35438L,35439L,35440L,\n35441L,35442L,35443L,35444L,35445L,35446L,35447L,35448L,35449L,35450L,\n35451L,35452L,35453L,35454L,35455L,35456L,35457L,35458L,35459L,35460L,\n35461L,35462L,35463L,35464L,35465L,35466L,35467L,35468L,35469L,35470L,\n35471L,35472L,35473L,35474L,35475L,35476L,35477L,35478L,35479L,35480L,\n35481L,35482L,35483L,35484L,35485L,35486L,35487L,35488L,35489L,35490L,\n35491L,35492L,35493L,35494L,35495L,35496L,35497L,35498L,35499L,35500L,\n35501L,35502L,35503L,35504L,35505L,35506L,35507L,35508L,35509L,35510L,\n35511L,35512L,35513L,35514L,35515L,35516L,35517L,35518L,35519L,35520L,\n35521L,35522L,35523L,35524L,35525L,35526L,35527L,35528L,35529L,35530L,\n35531L,35532L,35533L,35534L,35535L,35536L,35537L,35538L,35539L,35540L,\n35541L,35542L,35543L,35544L,35545L,35546L,35547L,35548L,35549L,35550L,\n35551L,35552L,35553L,35554L,35555L,35556L,35557L,35558L,35559L,35560L,\n35561L,35562L,35563L,35564L,35565L,35566L,35567L,35568L,35569L,35570L,\n35571L,35572L,35573L,35574L,35575L,35576L,35577L,35578L,35579L,35580L,\n35581L,35582L,35583L,35584L,35585L,35586L,35587L,35588L,35589L,35590L,\n35591L,35592L,35593L,35594L,35595L,35596L,35597L,35598L,35599L,35600L,\n35601L,35602L,35603L,35604L,35605L,35606L,35607L,35608L,35609L,35610L,\n35611L,35612L,35613L,35614L,35615L,35616L,35617L,35618L,35619L,35620L,\n35621L,35622L,35623L,35624L,35625L,35626L,35627L,35628L,35629L,35630L,\n35631L,35632L,35633L,35634L,35635L,35636L,35637L,35638L,35639L,35640L,\n35641L,35642L,35643L,35644L,35645L,35646L,35647L,35648L,35649L,35650L,\n35651L,35652L,35653L,35654L,35655L,35656L,35657L,35658L,35659L,35660L,\n35661L,35662L,35663L,35664L,35665L,35666L,35667L,35668L,35669L,35670L,\n35671L,35672L,35673L,35674L,35675L,35676L,35677L,35678L,35679L,35680L,\n35681L,35682L,35683L,35684L,35685L,35686L,35687L,35688L,35689L,35690L,\n35691L,35692L,35693L,35694L,35695L,35696L,35697L,35698L,35699L,35700L,\n35701L,35702L,35703L,35704L,35705L,35706L,35707L,35708L,35709L,35710L,\n35711L,35712L,35713L,35714L,35715L,35716L,35717L,35718L,35719L,35720L,\n35721L,35722L,35723L,35724L,35725L,35726L,35727L,35728L,35729L,35730L,\n35731L,35732L,35733L,35734L,35735L,35736L,35737L,35738L,35739L,35740L,\n35741L,35742L,35743L,35744L,35745L,35746L,35747L,35748L,35749L,35750L,\n35751L,35752L,35753L,35754L,35755L,35756L,35757L,35758L,35759L,35760L,\n35761L,35762L,35763L,35764L,35765L,35766L,35767L,35768L,35769L,35770L,\n35771L,35772L,35773L,35774L,35775L,35776L,35777L,35778L,35779L,35780L,\n35781L,35782L,35783L,35784L,35785L,35786L,35787L,35788L,35789L,35790L,\n35791L,35792L,35793L,35794L,35795L,35796L,35797L,35798L,35799L,35800L,\n35801L,35802L,35803L,35804L,35805L,35806L,35807L,35808L,35809L,35810L,\n35811L,35812L,35813L,35814L,35815L,35816L,35817L,35818L,35819L,35820L,\n35821L,35822L,35823L,35824L,35825L,35826L,35827L,35828L,35829L,35830L,\n35831L,35832L,35833L,35834L,35835L,35836L,35837L,35838L,35839L,35840L,\n35841L,35842L,35843L,35844L,35845L,35846L,35847L,35848L,35849L,35850L,\n35851L,35852L,35853L,35854L,35855L,35856L,35857L,35858L,35859L,35860L,\n35861L,35862L,35863L,35864L,35865L,35866L,35867L,35868L,35869L,35870L,\n35871L,35872L,35873L,35874L,35875L,35876L,35877L,35878L,35879L,35880L,\n35881L,35882L,35883L,35884L,35885L,35886L,35887L,35888L,35889L,35890L,\n35891L,35892L,35893L,35894L,35895L,35896L,35897L,35898L,35899L,35900L,\n35901L,35902L,35903L,35904L,35905L,35906L,35907L,35908L,35909L,35910L,\n35911L,35912L,35913L,35914L,35915L,35916L,35917L,35918L,35919L,35920L,\n35921L,35922L,35923L,35924L,35925L,35926L,35927L,35928L,35929L,35930L,\n35931L,35932L,35933L,35934L,35935L,35936L,35937L,35938L,35939L,35940L,\n35941L,35942L,35943L,35944L,35945L,35946L,35947L,35948L,35949L,35950L,\n35951L,35952L,35953L,35954L,35955L,35956L,35957L,35958L,35959L,35960L,\n35961L,35962L,35963L,35964L,35965L,35966L,35967L,35968L,35969L,35970L,\n35971L,35972L,35973L,35974L,35975L,35976L,35977L,35978L,35979L,35980L,\n35981L,35982L,35983L,35984L,35985L,35986L,35987L,35988L,35989L,35990L,\n35991L,35992L,35993L,35994L,35995L,35996L,35997L,35998L,35999L,36000L,\n36001L,36002L,36003L,36004L,36005L,36006L,36007L,36008L,36009L,36010L,\n36011L,36012L,36013L,36014L,36015L,36016L,36017L,36018L,36019L,36020L,\n36021L,36022L,36023L,36024L,36025L,36026L,36027L,36028L,36029L,36030L,\n36031L,36032L,36033L,36034L,36035L,36036L,36037L,36038L,36039L,36040L,\n36041L,36042L,36043L,36044L,36045L,36046L,36047L,36048L,36049L,36050L,\n36051L,36052L,36053L,36054L,36055L,36056L,36057L,36058L,36059L,36060L,\n36061L,36062L,36063L,36064L,36065L,36066L,36067L,36068L,36069L,36070L,\n36071L,36072L,36073L,36074L,36075L,36076L,36077L,36078L,36079L,36080L,\n36081L,36082L,36083L,36084L,36085L,36086L,36087L,36088L,36089L,36090L,\n36091L,36092L,36093L,36094L,36095L,36096L,36097L,36098L,36099L,36100L,\n36101L,36102L,36103L,36104L,36105L,36106L,36107L,36108L,36109L,36110L,\n36111L,36112L,36113L,36114L,36115L,36116L,36117L,36118L,36119L,36120L,\n36121L,36122L,36123L,36124L,36125L,36126L,36127L,36128L,36129L,36130L,\n36131L,36132L,36133L,36134L,36135L,36136L,36137L,36138L,36139L,36140L,\n36141L,36142L,36143L,36144L,36145L,36146L,36147L,36148L,36149L,36150L,\n36151L,36152L,36153L,36154L,36155L,36156L,36157L,36158L,36159L,36160L,\n36161L,36162L,36163L,36164L,36165L,36166L,36167L,36168L,36169L,36170L,\n36171L,36172L,36173L,36174L,36175L,36176L,36177L,36178L,36179L,36180L,\n36181L,36182L,36183L,36184L,36185L,36186L,36187L,36188L,36189L,36190L,\n36191L,36192L,36193L,36194L,36195L,36196L,36197L,36198L,36199L,36200L,\n36201L,36202L,36203L,36204L,36205L,36206L,36207L,36208L,36209L,36210L,\n36211L,36212L,36213L,36214L,36215L,36216L,36217L,36218L,36219L,36220L,\n36221L,36222L,36223L,36224L,36225L,36226L,36227L,36228L,36229L,36230L,\n36231L,36232L,36233L,36234L,36235L,36236L,36237L,36238L,36239L,36240L,\n36241L,36242L,36243L,36244L,36245L,36246L,36247L,36248L,36249L,36250L,\n36251L,36252L,36253L,36254L,36255L,36256L,36257L,36258L,36259L,36260L,\n36261L,36262L,36263L,36264L,36265L,36266L,36267L,36268L,36269L,36270L,\n36271L,36272L,36273L,36274L,36275L,36276L,36277L,36278L,36279L,36280L,\n36281L,36282L,36283L,36284L,36285L,36286L,36287L,36288L,36289L,36290L,\n36291L,36292L,36293L,36294L,36295L,36296L,36297L,36298L,36299L,36300L,\n36301L,36302L,36303L,36304L,36305L,36306L,36307L,36308L,36309L,36310L,\n36311L,36312L,36313L,36314L,36315L,36316L,36317L,36318L,36319L,36320L,\n36321L,36322L,36323L,36324L,36325L,36326L,36327L,36328L,36329L,36330L,\n36331L,36332L,36333L,36334L,36335L,36336L,36337L,36338L,36339L,36340L,\n36341L,36342L,36343L,36344L,36345L,36346L,36347L,36348L,36349L,36350L,\n36351L,36352L,36353L,36354L,36355L,36356L,36357L,36358L,36359L,36360L,\n36361L,36362L,36363L,36364L,36365L,36366L,36367L,36368L,36369L,36370L,\n36371L,36372L,36373L,36374L,36375L,36376L,36377L,36378L,36379L,36380L,\n36381L,36382L,36383L,36384L,36385L,36386L,36387L,36388L,36389L,36390L,\n36391L,36392L,36393L,36394L,36395L,36396L,36397L,36398L,36399L,36400L,\n36401L,36402L,36403L,36404L,36405L,36406L,36407L,36408L,36409L,36410L,\n36411L,36412L,36413L,36414L,36415L,36416L,36417L,36418L,36419L,36420L,\n36421L,36422L,36423L,36424L,36425L,36426L,36427L,36428L,36429L,36430L,\n36431L,36432L,36433L,36434L,36435L,36436L,36437L,36438L,36439L,36440L,\n36441L,36442L,36443L,36444L,36445L,36446L,36447L,36448L,36449L,36450L,\n36451L,36452L,36453L,36454L,36455L,36456L,36457L,36458L,36459L,36460L,\n36461L,36462L,36463L,36464L,36465L,36466L,36467L,36468L,36469L,36470L,\n36471L,36472L,36473L,36474L,36475L,36476L,36477L,36478L,36479L,36480L,\n36481L,36482L,36483L,36484L,36485L,36486L,36487L,36488L,36489L,36490L,\n36491L,36492L,36493L,36494L,36495L,36496L,36497L,36498L,36499L,36500L,\n36501L,36502L,36503L,36504L,36505L,36506L,36507L,36508L,36509L,36510L,\n36511L,36512L,36513L,36514L,36515L,36516L,36517L,36518L,36519L,36520L,\n36521L,36522L,36523L,36524L,36525L,36526L,36527L,36528L,36529L,36530L,\n36531L,36532L,36533L,36534L,36535L,36536L,36537L,36538L,36539L,36540L,\n36541L,36542L,36543L,36544L,36545L,36546L,36547L,36548L,36549L,36550L,\n36551L,36552L,36553L,36554L,36555L,36556L,36557L,36558L,36559L,36560L,\n36561L,36562L,36563L,36564L,36565L,36566L,36567L,36568L,36569L,36570L,\n36571L,36572L,36573L,36574L,36575L,36576L,36577L,36578L,36579L,36580L,\n36581L,36582L,36583L,36584L,36585L,36586L,36587L,36588L,36589L,36590L,\n36591L,36592L,36593L,36594L,36595L,36596L,36597L,36598L,36599L,36600L,\n36601L,36602L,36603L,36604L,36605L,36606L,36607L,36608L,36609L,36610L,\n36611L,36612L,36613L,36614L,36615L,36616L,36617L,36618L,36619L,36620L,\n36621L,36622L,36623L,36624L,36625L,36626L,36627L,36628L,36629L,36630L,\n36631L,36632L,36633L,36634L,36635L,36636L,36637L,36638L,36639L,36640L,\n36641L,36642L,36643L,36644L,36645L,36646L,36647L,36648L,36649L,36650L,\n36651L,36652L,36653L,36654L,36655L,36656L,36657L,36658L,36659L,36660L,\n36661L,36662L,36663L,36664L,36665L,36666L,36667L,36668L,36669L,36670L,\n36671L,36672L,36673L,36674L,36675L,36676L,36677L,36678L,36679L,36680L,\n36681L,36682L,36683L,36684L,36685L,36686L,36687L,36688L,36689L,36690L,\n36691L,36692L,36693L,36694L,36695L,36696L,36697L,36698L,36699L,36700L,\n36701L,36702L,36703L,36704L,36705L,36706L,36707L,36708L,36709L,36710L,\n36711L,36712L,36713L,36714L,36715L,36716L,36717L,36718L,36719L,36720L,\n36721L,36722L,36723L,36724L,36725L,36726L,36727L,36728L,36729L,36730L,\n36731L,36732L,36733L,36734L,36735L,36736L,36737L,36738L,36739L,36740L,\n36741L,36742L,36743L,36744L,36745L,36746L,36747L,36748L,36749L,36750L,\n36751L,36752L,36753L,36754L,36755L,36756L,36757L,36758L,36759L,36760L,\n36761L,36762L,36763L,36764L,36765L,36766L,36767L,36768L,36769L,36770L,\n36771L,36772L,36773L,36774L,36775L,36776L,36777L,36778L,36779L,36780L,\n36781L,36782L,36783L,36784L,36785L,36786L,36787L,36788L,36789L,36790L,\n36791L,36792L,36793L,36794L,36795L,36796L,36797L,36798L,36799L,36800L,\n36801L,36802L,36803L,36804L,36805L,36806L,36807L,36808L,36809L,36810L,\n36811L,36812L,36813L,36814L,36815L,36816L,36817L,36818L,36819L,36820L,\n36821L,36822L,36823L,36824L,36825L,36826L,36827L,36828L,36829L,36830L,\n36831L,36832L,36833L,36834L,36835L,36836L,36837L,36838L,36839L,36840L,\n36841L,36842L,36843L,36844L,36845L,36846L,36847L,36848L,36849L,36850L,\n36851L,36852L,36853L,36854L,36855L,36856L,36857L,36858L,36859L,36860L,\n36861L,36862L,36863L,36864L,36865L,36866L,36867L,36868L,36869L,36870L,\n36871L,36872L,36873L,36874L,36875L,36876L,36877L,36878L,36879L,36880L,\n36881L,36882L,36883L,36884L,36885L,36886L,36887L,36888L,36889L,36890L,\n36891L,36892L,36893L,36894L,36895L,36896L,36897L,36898L,36899L,36900L,\n36901L,36902L,36903L,36904L,36905L,36906L,36907L,36908L,36909L,36910L,\n36911L,36912L,36913L,36914L,36915L,36916L,36917L,36918L,36919L,36920L,\n36921L,36922L,36923L,36924L,36925L,36926L,36927L,36928L,36929L,36930L,\n36931L,36932L,36933L,36934L,36935L,36936L,36937L,36938L,36939L,36940L,\n36941L,36942L,36943L,36944L,36945L,36946L,36947L,36948L,36949L,36950L,\n36951L,36952L,36953L,36954L,36955L,36956L,36957L,36958L,36959L,36960L,\n36961L,36962L,36963L,36964L,36965L,36966L,36967L,36968L,36969L,36970L,\n36971L,36972L,36973L,36974L,36975L,36976L,36977L,36978L,36979L,36980L,\n36981L,36982L,36983L,36984L,36985L,36986L,36987L,36988L,36989L,36990L,\n36991L,36992L,36993L,36994L,36995L,36996L,36997L,36998L,36999L,37000L,\n37001L,37002L,37003L,37004L,37005L,37006L,37007L,37008L,37009L,37010L,\n37011L,37012L,37013L,37014L,37015L,37016L,37017L,37018L,37019L,37020L,\n37021L,37022L,37023L,37024L,37025L,37026L,37027L,37028L,37029L,37030L,\n37031L,37032L,37033L,37034L,37035L,37036L,37037L,37038L,37039L,37040L,\n37041L,37042L,37043L,37044L,37045L,37046L,37047L,37048L,37049L,37050L,\n37051L,37052L,37053L,37054L,37055L,37056L,37057L,37058L,37059L,37060L,\n37061L,37062L,37063L,37064L,37065L,37066L,37067L,37068L,37069L,37070L,\n37071L,37072L,37073L,37074L,37075L,37076L,37077L,37078L,37079L,37080L,\n37081L,37082L,37083L,37084L,37085L,37086L,37087L,37088L,37089L,37090L,\n37091L,37092L,37093L,37094L,37095L,37096L,37097L,37098L,37099L,37100L,\n37101L,37102L,37103L,37104L,37105L,37106L,37107L,37108L,37109L,37110L,\n37111L,37112L,37113L,37114L,37115L,37116L,37117L,37118L,37119L,37120L,\n37121L,37122L,37123L,37124L,37125L,37126L,37127L,37128L,37129L,37130L,\n37131L,37132L,37133L,37134L,37135L,37136L,37137L,37138L,37139L,37140L,\n37141L,37142L,37143L,37144L,37145L,37146L,37147L,37148L,37149L,37150L,\n37151L,37152L,37153L,37154L,37155L,37156L,37157L,37158L,37159L,37160L,\n37161L,37162L,37163L,37164L,37165L,37166L,37167L,37168L,37169L,37170L,\n37171L,37172L,37173L,37174L,37175L,37176L,37177L,37178L,37179L,37180L,\n37181L,37182L,37183L,37184L,37185L,37186L,37187L,37188L,37189L,37190L,\n37191L,37192L,37193L,37194L,37195L,37196L,37197L,37198L,37199L,37200L,\n37201L,37202L,37203L,37204L,37205L,37206L,37207L,37208L,37209L,37210L,\n37211L,37212L,37213L,37214L,37215L,37216L,37217L,37218L,37219L,37220L,\n37221L,37222L,37223L,37224L,37225L,37226L,37227L,37228L,37229L,37230L,\n37231L,37232L,37233L,37234L,37235L,37236L,37237L,37238L,37239L,37240L,\n37241L,37242L,37243L,37244L,37245L,37246L,37247L,37248L,37249L,37250L,\n37251L,37252L,37253L,37254L,37255L,37256L,37257L,37258L,37259L,37260L,\n37261L,37262L,37263L,37264L,37265L,37266L,37267L,37268L,37269L,37270L,\n37271L,37272L,37273L,37274L,37275L,37276L,37277L,37278L,37279L,37280L,\n37281L,37282L,37283L,37284L,37285L,37286L,37287L,37288L,37289L,37290L,\n37291L,37292L,37293L,37294L,37295L,37296L,37297L,37298L,37299L,37300L,\n37301L,37302L,37303L,37304L,37305L,37306L,37307L,37308L,37309L,37310L,\n37311L,37312L,37313L,37314L,37315L,37316L,37317L,37318L,37319L,37320L,\n37321L,37322L,37323L,37324L,37325L,37326L,37327L,37328L,37329L,37330L,\n37331L,37332L,37333L,37334L,37335L,37336L,37337L,37338L,37339L,37340L,\n37341L,37342L,37343L,37344L,37345L,37346L,37347L,37348L,37349L,37350L,\n37351L,37352L,37353L,37354L,37355L,37356L,37357L,37358L,37359L,37360L,\n37361L,37362L,37363L,37364L,37365L,37366L,37367L,37368L,37369L,37370L,\n37371L,37372L,37373L,37374L,37375L,37376L,37377L,37378L,37379L,37380L,\n37381L,37382L,37383L,37384L,37385L,37386L,37387L,37388L,37389L,37390L,\n37391L,37392L,37393L,37394L,37395L,37396L,37397L,37398L,37399L,37400L,\n37401L,37402L,37403L,37404L,37405L,37406L,37407L,37408L,37409L,37410L,\n37411L,37412L,37413L,37414L,37415L,37416L,37417L,37418L,37419L,37420L,\n37421L,37422L,37423L,37424L,37425L,37426L,37427L,37428L,37429L,37430L,\n37431L,37432L,37433L,37434L,37435L,37436L,37437L,37438L,37439L,37440L,\n37441L,37442L,37443L,37444L,37445L,37446L,37447L,37448L,37449L,37450L,\n37451L,37452L,37453L,37454L,37455L,37456L,37457L,37458L,37459L,37460L,\n37461L,37462L,37463L,37464L,37465L,37466L,37467L,37468L,37469L,37470L,\n37471L,37472L,37473L,37474L,37475L,37476L,37477L,37478L,37479L,37480L,\n37481L,37482L,37483L,37484L,37485L,37486L,37487L,37488L,37489L,37490L,\n37491L,37492L,37493L,37494L,37495L,37496L,37497L,37498L,37499L,37500L,\n37501L,37502L,37503L,37504L,37505L,37506L,37507L,37508L,37509L,37510L,\n37511L,37512L,37513L,37514L,37515L,37516L,37517L,37518L,37519L,37520L,\n37521L,37522L,37523L,37524L,37525L,37526L,37527L,37528L,37529L,37530L,\n37531L,37532L,37533L,37534L,37535L,37536L,37537L,37538L,37539L,37540L,\n37541L,37542L,37543L,37544L,37545L,37546L,37547L,37548L,37549L,37550L,\n37551L,37552L,37553L,37554L,37555L,37556L,37557L,37558L,37559L,37560L,\n37561L,37562L,37563L,37564L,37565L,37566L,37567L,37568L,37569L,37570L,\n37571L,37572L,37573L,37574L,37575L,37576L,37577L,37578L,37579L,37580L,\n37581L,37582L,37583L,37584L,37585L,37586L,37587L,37588L,37589L,37590L,\n37591L,37592L,37593L,37594L,37595L,37596L,37597L,37598L,37599L,37600L,\n37601L,37602L,37603L,37604L,37605L,37606L,37607L,37608L,37609L,37610L,\n37611L,37612L,37613L,37614L,37615L,37616L,37617L,37618L,37619L,37620L,\n37621L,37622L,37623L,37624L,37625L,37626L,37627L,37628L,37629L,37630L,\n37631L,37632L,37633L,37634L,37635L,37636L,37637L,37638L,37639L,37640L,\n37641L,37642L,37643L,37644L,37645L,37646L,37647L,37648L,37649L,37650L,\n37651L,37652L,37653L,37654L,37655L,37656L,37657L,37658L,37659L,37660L,\n37661L,37662L,37663L,37664L,37665L,37666L,37667L,37668L,37669L,37670L,\n37671L,37672L,37673L,37674L,37675L,37676L,37677L,37678L,37679L,37680L,\n37681L,37682L,37683L,37684L,37685L,37686L,37687L,37688L,37689L,37690L,\n37691L,37692L,37693L,37694L,37695L,37696L,37697L,37698L,37699L,37700L,\n37701L,37702L,37703L,37704L,37705L,37706L,37707L,37708L,37709L,37710L,\n37711L,37712L,37713L,37714L,37715L,37716L,37717L,37718L,37719L,37720L,\n37721L,37722L,37723L,37724L,37725L,37726L,37727L,37728L,37729L,37730L,\n37731L,37732L,37733L,37734L,37735L,37736L,37737L,37738L,37739L,37740L,\n37741L,37742L,37743L,37744L,37745L,37746L,37747L,37748L,37749L,37750L,\n37751L,37752L,37753L,37754L,37755L,37756L,37757L,37758L,37759L,37760L,\n37761L,37762L,37763L,37764L,37765L,37766L,37767L,37768L,37769L,37770L,\n37771L,37772L,37773L,37774L,37775L,37776L,37777L,37778L,37779L,37780L,\n37781L,37782L,37783L,37784L,37785L,37786L,37787L,37788L,37789L,37790L,\n37791L,37792L,37793L,37794L,37795L,37796L,37797L,37798L,37799L,37800L,\n37801L,37802L,37803L,37804L,37805L,37806L,37807L,37808L,37809L,37810L,\n37811L,37812L,37813L,37814L,37815L,37816L,37817L,37818L,37819L,37820L,\n37821L,37822L,37823L,37824L,37825L,37826L,37827L,37828L,37829L,37830L,\n37831L,37832L,37833L,37834L,37835L,37836L,37837L,37838L,37839L,37840L,\n37841L,37842L,37843L,37844L,37845L,37846L,37847L,37848L,37849L,37850L,\n37851L,37852L,37853L,37854L,37855L,37856L,37857L,37858L,37859L,37860L,\n37861L,37862L,37863L,37864L,37865L,37866L,37867L,37868L,37869L,37870L,\n37871L,37872L,37873L,37874L,37875L,37876L,37877L,37878L,37879L,37880L,\n37881L,37882L,37883L,37884L,37885L,37886L,37887L,37888L,37889L,37890L,\n37891L,37892L,37893L,37894L,37895L,37896L,37897L,37898L,37899L,37900L,\n37901L,37902L,37903L,37904L,37905L,37906L,37907L,37908L,37909L,37910L,\n37911L,37912L,37913L,37914L,37915L,37916L,37917L,37918L,37919L,37920L,\n37921L,37922L,37923L,37924L,37925L,37926L,37927L,37928L,37929L,37930L,\n37931L,37932L,37933L,37934L,37935L,37936L,37937L,37938L,37939L,37940L,\n37941L,37942L,37943L,37944L,37945L,37946L,37947L,37948L,37949L,37950L,\n37951L,37952L,37953L,37954L,37955L,37956L,37957L,37958L,37959L,37960L,\n37961L,37962L,37963L,37964L,37965L,37966L,37967L,37968L,37969L,37970L,\n37971L,37972L,37973L,37974L,37975L,37976L,37977L,37978L,37979L,37980L,\n37981L,37982L,37983L,37984L,37985L,37986L,37987L,37988L,37989L,37990L,\n37991L,37992L,37993L,37994L,37995L,37996L,37997L,37998L,37999L,38000L,\n38001L,38002L,38003L,38004L,38005L,38006L,38007L,38008L,38009L,38010L,\n38011L,38012L,38013L,38014L,38015L,38016L,38017L,38018L,38019L,38020L,\n38021L,38022L,38023L,38024L,38025L,38026L,38027L,38028L,38029L,38030L,\n38031L,38032L,38033L,38034L,38035L,38036L,38037L,38038L,38039L,38040L,\n38041L,38042L,38043L,38044L,38045L,38046L,38047L,38048L,38049L,38050L,\n38051L,38052L,38053L,38054L,38055L,38056L,38057L,38058L,38059L,38060L,\n38061L,38062L,38063L,38064L,38065L,38066L,38067L,38068L,38069L,38070L,\n38071L,38072L,38073L,38074L,38075L,38076L,38077L,38078L,38079L,38080L,\n38081L,38082L,38083L,38084L,38085L,38086L,38087L,38088L,38089L,38090L,\n38091L,38092L,38093L,38094L,38095L,38096L,38097L,38098L,38099L,38100L,\n38101L,38102L,38103L,38104L,38105L,38106L,38107L,38108L,38109L,38110L,\n38111L,38112L,38113L,38114L,38115L,38116L,38117L,38118L,38119L,38120L,\n38121L,38122L,38123L,38124L,38125L,38126L,38127L,38128L,38129L,38130L,\n38131L,38132L,38133L,38134L,38135L,38136L,38137L,38138L,38139L,38140L,\n38141L,38142L,38143L,38144L,38145L,38146L,38147L,38148L,38149L,38150L,\n38151L,38152L,38153L,38154L,38155L,38156L,38157L,38158L,38159L,38160L,\n38161L,38162L,38163L,38164L,38165L,38166L,38167L,38168L,38169L,38170L,\n38171L,38172L,38173L,38174L,38175L,38176L,38177L,38178L,38179L,38180L,\n38181L,38182L,38183L,38184L,38185L,38186L,38187L,38188L,38189L,38190L,\n38191L,38192L,38193L,38194L,38195L,38196L,38197L,38198L,38199L,38200L,\n38201L,38202L,38203L,38204L,38205L,38206L,38207L,38208L,38209L,38210L,\n38211L,38212L,38213L,38214L,38215L,38216L,38217L,38218L,38219L,38220L,\n38221L,38222L,38223L,38224L,38225L,38226L,38227L,38228L,38229L,38230L,\n38231L,38232L,38233L,38234L,38235L,38236L,38237L,38238L,38239L,38240L,\n38241L,38242L,38243L,38244L,38245L,38246L,38247L,38248L,38249L,38250L,\n38251L,38252L,38253L,38254L,38255L,38256L,38257L,38258L,38259L,38260L,\n38261L,38262L,38263L,38264L,38265L,38266L,38267L,38268L,38269L,38270L,\n38271L,38272L,38273L,38274L,38275L,38276L,38277L,38278L,38279L,38280L,\n38281L,38282L,38283L,38284L,38285L,38286L,38287L,38288L,38289L,38290L,\n38291L,38292L,38293L,38294L,38295L,38296L,38297L,38298L,38299L,38300L,\n38301L,38302L,38303L,38304L,38305L,38306L,38307L,38308L,38309L,38310L,\n38311L,38312L,38313L,38314L,38315L,38316L,38317L,38318L,38319L,38320L,\n38321L,38322L,38323L,38324L,38325L,38326L,38327L,38328L,38329L,38330L,\n38331L,38332L,38333L,38334L,38335L,38336L,38337L,38338L,38339L,38340L,\n38341L,38342L,38343L,38344L,38345L,38346L,38347L,38348L,38349L,38350L,\n38351L,38352L,38353L,38354L,38355L,38356L,38357L,38358L,38359L,38360L,\n38361L,38362L,38363L,38364L,38365L,38366L,38367L,38368L,38369L,38370L,\n38371L,38372L,38373L,38374L,38375L,38376L,38377L,38378L,38379L,38380L,\n38381L,38382L,38383L,38384L,38385L,38386L,38387L,38388L,38389L,38390L,\n38391L,38392L,38393L,38394L,38395L,38396L,38397L,38398L,38399L,38400L,\n38401L,38402L,38403L,38404L,38405L,38406L,38407L,38408L,38409L,38410L,\n38411L,38412L,38413L,38414L,38415L,38416L,38417L,38418L,38419L,38420L,\n38421L,38422L,38423L,38424L,38425L,38426L,38427L,38428L,38429L,38430L,\n38431L,38432L,38433L,38434L,38435L,38436L,38437L,38438L,38439L,38440L,\n38441L,38442L,38443L,38444L,38445L,38446L,38447L,38448L,38449L,38450L,\n38451L,38452L,38453L,38454L,38455L,38456L,38457L,38458L,38459L,38460L,\n38461L,38462L,38463L,38464L,38465L,38466L,38467L,38468L,38469L,38470L,\n38471L,38472L,38473L,38474L,38475L,38476L,38477L,38478L,38479L,38480L,\n38481L,38482L,38483L,38484L,38485L,38486L,38487L,38488L,38489L,38490L,\n38491L,38492L,38493L,38494L,38495L,38496L,38497L,38498L,38499L,38500L,\n38501L,38502L,38503L,38504L,38505L,38506L,38507L,38508L,38509L,38510L,\n38511L,38512L,38513L,38514L,38515L,38516L,38517L,38518L,38519L,38520L,\n38521L,38522L,38523L,38524L,38525L,38526L,38527L,38528L,38529L,38530L,\n38531L,38532L,38533L,38534L,38535L,38536L,38537L,38538L,38539L,38540L,\n38541L,38542L,38543L,38544L,38545L,38546L,38547L,38548L,38549L,38550L,\n38551L,38552L,38553L,38554L,38555L,38556L,38557L,38558L,38559L,38560L,\n38561L,38562L,38563L,38564L,38565L,38566L,38567L,38568L,38569L,38570L,\n38571L,38572L,38573L,38574L,38575L,38576L,38577L,38578L,38579L,38580L,\n38581L,38582L,38583L,38584L,38585L,38586L,38587L,38588L,38589L,38590L,\n38591L,38592L,38593L,38594L,38595L,38596L,38597L,38598L,38599L,38600L,\n38601L,38602L,38603L,38604L,38605L,38606L,38607L,38608L,38609L,38610L,\n38611L,38612L,38613L,38614L,38615L,38616L,38617L,38618L,38619L,38620L,\n38621L,38622L,38623L,38624L,38625L,38626L,38627L,38628L,38629L,38630L,\n38631L,38632L,38633L,38634L,38635L,38636L,38637L,38638L,38639L,38640L,\n38641L,38642L,38643L,38644L,38645L,38646L,38647L,38648L,38649L,38650L,\n38651L,38652L,38653L,38654L,38655L,38656L,38657L,38658L,38659L,38660L,\n38661L,38662L,38663L,38664L,38665L,38666L,38667L,38668L,38669L,38670L,\n38671L,38672L,38673L,38674L,38675L,38676L,38677L,38678L,38679L,38680L,\n38681L,38682L,38683L,38684L,38685L,38686L,38687L,38688L,38689L,38690L,\n38691L,38692L,38693L,38694L,38695L,38696L,38697L,38698L,38699L,38700L,\n38701L,38702L,38703L,38704L,38705L,38706L,38707L,38708L,38709L,38710L,\n38711L,38712L,38713L,38714L,38715L,38716L,38717L,38718L,38719L,38720L,\n38721L,38722L,38723L,38724L,38725L,38726L,38727L,38728L,38729L,38730L,\n38731L,38732L,38733L,38734L,38735L,38736L,38737L,38738L,38739L,38740L,\n38741L,38742L,38743L,38744L,38745L,38746L,38747L,38748L,38749L,38750L,\n38751L,38752L,38753L,38754L,38755L,38756L,38757L,38758L,38759L,38760L,\n38761L,38762L,38763L,38764L,38765L,38766L,38767L,38768L,38769L,38770L,\n38771L,38772L,38773L,38774L,38775L,38776L,38777L,38778L,38779L,38780L,\n38781L,38782L,38783L,38784L,38785L,38786L,38787L,38788L,38789L,38790L,\n38791L,38792L,38793L,38794L,38795L,38796L,38797L,38798L,38799L,38800L,\n38801L,38802L,38803L,38804L,38805L,38806L,38807L,38808L,38809L,38810L,\n38811L,38812L,38813L,38814L,38815L,38816L,38817L,38818L,38819L,38820L,\n38821L,38822L,38823L,38824L,38825L,38826L,38827L,38828L,38829L,38830L,\n38831L,38832L,38833L,38834L,38835L,38836L,38837L,38838L,38839L,38840L,\n38841L,38842L,38843L,38844L,38845L,38846L,38847L,38848L,38849L,38850L,\n38851L,38852L,38853L,38854L,38855L,38856L,38857L,38858L,38859L,38860L,\n38861L,38862L,38863L,38864L,38865L,38866L,38867L,38868L,38869L,38870L,\n38871L,38872L,38873L,38874L,38875L,38876L,38877L,38878L,38879L,38880L,\n38881L,38882L,38883L,38884L,38885L,38886L,38887L,38888L,38889L,38890L,\n38891L,38892L,38893L,38894L,38895L,38896L,38897L,38898L,38899L,38900L,\n38901L,38902L,38903L,38904L,38905L,38906L,38907L,38908L,38909L,38910L,\n38911L,38912L,38913L,38914L,38915L,38916L,38917L,38918L,38919L,38920L,\n38921L,38922L,38923L,38924L,38925L,38926L,38927L,38928L,38929L,38930L,\n38931L,38932L,38933L,38934L,38935L,38936L,38937L,38938L,38939L,38940L,\n38941L,38942L,38943L,38944L,38945L,38946L,38947L,38948L,38949L,38950L,\n38951L,38952L,38953L,38954L,38955L,38956L,38957L,38958L,38959L,38960L,\n38961L,38962L,38963L,38964L,38965L,38966L,38967L,38968L,38969L,38970L,\n38971L,38972L,38973L,38974L,38975L,38976L,38977L,38978L,38979L,38980L,\n38981L,38982L,38983L,38984L,38985L,38986L,38987L,38988L,38989L,38990L,\n38991L,38992L,38993L,38994L,38995L,38996L,38997L,38998L,38999L,39000L,\n39001L,39002L,39003L,39004L,39005L,39006L,39007L,39008L,39009L,39010L,\n39011L,39012L,39013L,39014L,39015L,39016L,39017L,39018L,39019L,39020L,\n39021L,39022L,39023L,39024L,39025L,39026L,39027L,39028L,39029L,39030L,\n39031L,39032L,39033L,39034L,39035L,39036L,39037L,39038L,39039L,39040L,\n39041L,39042L,39043L,39044L,39045L,39046L,39047L,39048L,39049L,39050L,\n39051L,39052L,39053L,39054L,39055L,39056L,39057L,39058L,39059L,39060L,\n39061L,39062L,39063L,39064L,39065L,39066L,39067L,39068L,39069L,39070L,\n39071L,39072L,39073L,39074L,39075L,39076L,39077L,39078L,39079L,39080L,\n39081L,39082L,39083L,39084L,39085L,39086L,39087L,39088L,39089L,39090L,\n39091L,39092L,39093L,39094L,39095L,39096L,39097L,39098L,39099L,39100L,\n39101L,39102L,39103L,39104L,39105L,39106L,39107L,39108L,39109L,39110L,\n39111L,39112L,39113L,39114L,39115L,39116L,39117L,39118L,39119L,39120L,\n39121L,39122L,39123L,39124L,39125L,39126L,39127L,39128L,39129L,39130L,\n39131L,39132L,39133L,39134L,39135L,39136L,39137L,39138L,39139L,39140L,\n39141L,39142L,39143L,39144L,39145L,39146L,39147L,39148L,39149L,39150L,\n39151L,39152L,39153L,39154L,39155L,39156L,39157L,39158L,39159L,39160L,\n39161L,39162L,39163L,39164L,39165L,39166L,39167L,39168L,39169L,39170L,\n39171L,39172L,39173L,39174L,39175L,39176L,39177L,39178L,39179L,39180L,\n39181L,39182L,39183L,39184L,39185L,39186L,39187L,39188L,39189L,39190L,\n39191L,39192L,39193L,39194L,39195L,39196L,39197L,39198L,39199L,39200L,\n39201L,39202L,39203L,39204L,39205L,39206L,39207L,39208L,39209L,39210L,\n39211L,39212L,39213L,39214L,39215L,39216L,39217L,39218L,39219L,39220L,\n39221L,39222L,39223L,39224L,39225L,39226L,39227L,39228L,39229L,39230L,\n39231L,39232L,39233L,39234L,39235L,39236L,39237L,39238L,39239L,39240L,\n39241L,39242L,39243L,39244L,39245L,39246L,39247L,39248L,39249L,39250L,\n39251L,39252L,39253L,39254L,39255L,39256L,39257L,39258L,39259L,39260L,\n39261L,39262L,39263L,39264L,39265L,39266L,39267L,39268L,39269L,39270L,\n39271L,39272L,39273L,39274L,39275L,39276L,39277L,39278L,39279L,39280L,\n39281L,39282L,39283L,39284L,39285L,39286L,39287L,39288L,39289L,39290L,\n39291L,39292L,39293L,39294L,39295L,39296L,39297L,39298L,39299L,39300L,\n39301L,39302L,39303L,39304L,39305L,39306L,39307L,39308L,39309L,39310L,\n39311L,39312L,39313L,39314L,39315L,39316L,39317L,39318L,39319L,39320L,\n39321L,39322L,39323L,39324L,39325L,39326L,39327L,39328L,39329L,39330L,\n39331L,39332L,39333L,39334L,39335L,39336L,39337L,39338L,39339L,39340L,\n39341L,39342L,39343L,39344L,39345L,39346L,39347L,39348L,39349L,39350L,\n39351L,39352L,39353L,39354L,39355L,39356L,39357L,39358L,39359L,39360L,\n39361L,39362L,39363L,39364L,39365L,39366L,39367L,39368L,39369L,39370L,\n39371L,39372L,39373L,39374L,39375L,39376L,39377L,39378L,39379L,39380L,\n39381L,39382L,39383L,39384L,39385L,39386L,39387L,39388L,39389L,39390L,\n39391L,39392L,39393L,39394L,39395L,39396L,39397L,39398L,39399L,39400L,\n39401L,39402L,39403L,39404L,39405L,39406L,39407L,39408L,39409L,39410L,\n39411L,39412L,39413L,39414L,39415L,39416L,39417L,39418L,39419L,39420L,\n39421L,39422L,39423L,39424L,39425L,39426L,39427L,39428L,39429L,39430L,\n39431L,39432L,39433L,39434L,39435L,39436L,39437L,39438L,39439L,39440L,\n39441L,39442L,39443L,39444L,39445L,39446L,39447L,39448L,39449L,39450L,\n39451L,39452L,39453L,39454L,39455L,39456L,39457L,39458L,39459L,39460L,\n39461L,39462L,39463L,39464L,39465L,39466L,39467L,39468L,39469L,39470L,\n39471L,39472L,39473L,39474L,39475L,39476L,39477L,39478L,39479L,39480L,\n39481L,39482L,39483L,39484L,39485L,39486L,39487L,39488L,39489L,39490L,\n39491L,39492L,39493L,39494L,39495L,39496L,39497L,39498L,39499L,39500L,\n39501L,39502L,39503L,39504L,39505L,39506L,39507L,39508L,39509L,39510L,\n39511L,39512L,39513L,39514L,39515L,39516L,39517L,39518L,39519L,39520L,\n39521L,39522L,39523L,39524L,39525L,39526L,39527L,39528L,39529L,39530L,\n39531L,39532L,39533L,39534L,39535L,39536L,39537L,39538L,39539L,39540L,\n39541L,39542L,39543L,39544L,39545L,39546L,39547L,39548L,39549L,39550L,\n39551L,39552L,39553L,39554L,39555L,39556L,39557L,39558L,39559L,39560L,\n39561L,39562L,39563L,39564L,39565L,39566L,39567L,39568L,39569L,39570L,\n39571L,39572L,39573L,39574L,39575L,39576L,39577L,39578L,39579L,39580L,\n39581L,39582L,39583L,39584L,39585L,39586L,39587L,39588L,39589L,39590L,\n39591L,39592L,39593L,39594L,39595L,39596L,39597L,39598L,39599L,39600L,\n39601L,39602L,39603L,39604L,39605L,39606L,39607L,39608L,39609L,39610L,\n39611L,39612L,39613L,39614L,39615L,39616L,39617L,39618L,39619L,39620L,\n39621L,39622L,39623L,39624L,39625L,39626L,39627L,39628L,39629L,39630L,\n39631L,39632L,39633L,39634L,39635L,39636L,39637L,39638L,39639L,39640L,\n39641L,39642L,39643L,39644L,39645L,39646L,39647L,39648L,39649L,39650L,\n39651L,39652L,39653L,39654L,39655L,39656L,39657L,39658L,39659L,39660L,\n39661L,39662L,39663L,39664L,39665L,39666L,39667L,39668L,39669L,39670L,\n39671L,39672L,39673L,39674L,39675L,39676L,39677L,39678L,39679L,39680L,\n39681L,39682L,39683L,39684L,39685L,39686L,39687L,39688L,39689L,39690L,\n39691L,39692L,39693L,39694L,39695L,39696L,39697L,39698L,39699L,39700L,\n39701L,39702L,39703L,39704L,39705L,39706L,39707L,39708L,39709L,39710L,\n39711L,39712L,39713L,39714L,39715L,39716L,39717L,39718L,39719L,39720L,\n39721L,39722L,39723L,39724L,39725L,39726L,39727L,39728L,39729L,39730L,\n39731L,39732L,39733L,39734L,39735L,39736L,39737L,39738L,39739L,39740L,\n39741L,39742L,39743L,39744L,39745L,39746L,39747L,39748L,39749L,39750L,\n39751L,39752L,39753L,39754L,39755L,39756L,39757L,39758L,39759L,39760L,\n39761L,39762L,39763L,39764L,39765L,39766L,39767L,39768L,39769L,39770L,\n39771L,39772L,39773L,39774L,39775L,39776L,39777L,39778L,39779L,39780L,\n39781L,39782L,39783L,39784L,39785L,39786L,39787L,39788L,39789L,39790L,\n39791L,39792L,39793L,39794L,39795L,39796L,39797L,39798L,39799L,39800L,\n39801L,39802L,39803L,39804L,39805L,39806L,39807L,39808L,39809L,39810L,\n39811L,39812L,39813L,39814L,39815L,39816L,39817L,39818L,39819L,39820L,\n39821L,39822L,39823L,39824L,39825L,39826L,39827L,39828L,39829L,39830L,\n39831L,39832L,39833L,39834L,39835L,39836L,39837L,39838L,39839L,39840L,\n39841L,39842L,39843L,39844L,39845L,39846L,39847L,39848L,39849L,39850L,\n39851L,39852L,39853L,39854L,39855L,39856L,39857L,39858L,39859L,39860L,\n39861L,39862L,39863L,39864L,39865L,39866L,39867L,39868L,39869L,39870L,\n39871L,39872L,39873L,39874L,39875L,39876L,39877L,39878L,39879L,39880L,\n39881L,39882L,39883L,39884L,39885L,39886L,39887L,39888L,39889L,39890L,\n39891L,39892L,39893L,39894L,39895L,39896L,39897L,39898L,39899L,39900L,\n39901L,39902L,39903L,39904L,39905L,39906L,39907L,39908L,39909L,39910L,\n39911L,39912L,39913L,39914L,39915L,39916L,39917L,39918L,39919L,39920L,\n39921L,39922L,39923L,39924L,39925L,39926L,39927L,39928L,39929L,39930L,\n39931L,39932L,39933L,39934L,39935L,39936L,39937L,39938L,39939L,39940L,\n39941L,39942L,39943L,39944L,39945L,39946L,39947L,39948L,39949L,39950L,\n39951L,39952L,39953L,39954L,39955L,39956L,39957L,39958L,39959L,39960L,\n39961L,39962L,39963L,39964L,39965L,39966L,39967L,39968L,39969L,39970L,\n39971L,39972L,39973L,39974L,39975L,39976L,39977L,39978L,39979L,39980L,\n39981L,39982L,39983L,39984L,39985L,39986L,39987L,39988L,39989L,39990L,\n39991L,39992L,39993L,39994L,39995L,39996L,39997L,39998L,39999L,40000L,\n40001L,40002L,40003L,40004L,40005L,40006L,40007L,40008L,40009L,40010L,\n40011L,40012L,40013L,40014L,40015L,40016L,40017L,40018L,40019L,40020L,\n40021L,40022L,40023L,40024L,40025L,40026L,40027L,40028L,40029L,40030L,\n40031L,40032L,40033L,40034L,40035L,40036L,40037L,40038L,40039L,40040L,\n40041L,40042L,40043L,40044L,40045L,40046L,40047L,40048L,40049L,40050L,\n40051L,40052L,40053L,40054L,40055L,40056L,40057L,40058L,40059L,40060L,\n40061L,40062L,40063L,40064L,40065L,40066L,40067L,40068L,40069L,40070L,\n40071L,40072L,40073L,40074L,40075L,40076L,40077L,40078L,40079L,40080L,\n40081L,40082L,40083L,40084L,40085L,40086L,40087L,40088L,40089L,40090L,\n40091L,40092L,40093L,40094L,40095L,40096L,40097L,40098L,40099L,40100L,\n40101L,40102L,40103L,40104L,40105L,40106L,40107L,40108L,40109L,40110L,\n40111L,40112L,40113L,40114L,40115L,40116L,40117L,40118L,40119L,40120L,\n40121L,40122L,40123L,40124L,40125L,40126L,40127L,40128L,40129L,40130L,\n40131L,40132L,40133L,40134L,40135L,40136L,40137L,40138L,40139L,40140L,\n40141L,40142L,40143L,40144L,40145L,40146L,40147L,40148L,40149L,40150L,\n40151L,40152L,40153L,40154L,40155L,40156L,40157L,40158L,40159L,40160L,\n40161L,40162L,40163L,40164L,40165L,40166L,40167L,40168L,40169L,40170L,\n40171L,40172L,40173L,40174L,40175L,40176L,40177L,40178L,40179L,40180L,\n40181L,40182L,40183L,40184L,40185L,40186L,40187L,40188L,40189L,40190L,\n40191L,40192L,40193L,40194L,40195L,40196L,40197L,40198L,40199L,40200L,\n40201L,40202L,40203L,40204L,40205L,40206L,40207L,40208L,40209L,40210L,\n40211L,40212L,40213L,40214L,40215L,40216L,40217L,40218L,40219L,40220L,\n40221L,40222L,40223L,40224L,40225L,40226L,40227L,40228L,40229L,40230L,\n40231L,40232L,40233L,40234L,40235L,40236L,40237L,40238L,40239L,40240L,\n40241L,40242L,40243L,40244L,40245L,40246L,40247L,40248L,40249L,40250L,\n40251L,40252L,40253L,40254L,40255L,40256L,40257L,40258L,40259L,40260L,\n40261L,40262L,40263L,40264L,40265L,40266L,40267L,40268L,40269L,40270L,\n40271L,40272L,40273L,40274L,40275L,40276L,40277L,40278L,40279L,40280L,\n40281L,40282L,40283L,40284L,40285L,40286L,40287L,40288L,40289L,40290L,\n40291L,40292L,40293L,40294L,40295L,40296L,40297L,40298L,40299L,40300L,\n40301L,40302L,40303L,40304L,40305L,40306L,40307L,40308L,40309L,40310L,\n40311L,40312L,40313L,40314L,40315L,40316L,40317L,40318L,40319L,40320L,\n40321L,40322L,40323L,40324L,40325L,40326L,40327L,40328L,40329L,40330L,\n40331L,40332L,40333L,40334L,40335L,40336L,40337L,40338L,40339L,40340L,\n40341L,40342L,40343L,40344L,40345L,40346L,40347L,40348L,40349L,40350L,\n40351L,40352L,40353L,40354L,40355L,40356L,40357L,40358L,40359L,40360L,\n40361L,40362L,40363L,40364L,40365L,40366L,40367L,40368L,40369L,40370L,\n40371L,40372L,40373L,40374L,40375L,40376L,40377L,40378L,40379L,40380L,\n40381L,40382L,40383L,40384L,40385L,40386L,40387L,40388L,40389L,40390L,\n40391L,40392L,40393L,40394L,40395L,40396L,40397L,40398L,40399L,40400L,\n40401L,40402L,40403L,40404L,40405L,40406L,40407L,40408L,40409L,40410L,\n40411L,40412L,40413L,40414L,40415L,40416L,40417L,40418L,40419L,40420L,\n40421L,40422L,40423L,40424L,40425L,40426L,40427L,40428L,40429L,40430L,\n40431L,40432L,40433L,40434L,40435L,40436L,40437L,40438L,40439L,40440L,\n40441L,40442L,40443L,40444L,40445L,40446L,40447L,40448L,40449L,40450L,\n40451L,40452L,40453L,40454L,40455L,40456L,40457L,40458L,40459L,40460L,\n40461L,40462L,40463L,40464L,40465L,40466L,40467L,40468L,40469L,40470L,\n40471L,40472L,40473L,40474L,40475L,40476L,40477L,40478L,40479L,40480L,\n40481L,40482L,40483L,40484L,40485L,40486L,40487L,40488L,40489L,40490L,\n40491L,40492L,40493L,40494L,40495L,40496L,40497L,40498L,40499L,40500L,\n40501L,40502L,40503L,40504L,40505L,40506L,40507L,40508L,40509L,40510L,\n40511L,40512L,40513L,40514L,40515L,40516L,40517L,40518L,40519L,40520L,\n40521L,40522L,40523L,40524L,40525L,40526L,40527L,40528L,40529L,40530L,\n40531L,40532L,40533L,40534L,40535L,40536L,40537L,40538L,40539L,40540L,\n40541L,40542L,40543L,40544L,40545L,40546L,40547L,40548L,40549L,40550L,\n40551L,40552L,40553L,40554L,40555L,40556L,40557L,40558L,40559L,40560L,\n40561L,40562L,40563L,40564L,40565L,40566L,40567L,40568L,40569L,40570L,\n40571L,40572L,40573L,40574L,40575L,40576L,40577L,40578L,40579L,40580L,\n40581L,40582L,40583L,40584L,40585L,40586L,40587L,40588L,40589L,40590L,\n40591L,40592L,40593L,40594L,40595L,40596L,40597L,40598L,40599L,40600L,\n40601L,40602L,40603L,40604L,40605L,40606L,40607L,40608L,40609L,40610L,\n40611L,40612L,40613L,40614L,40615L,40616L,40617L,40618L,40619L,40620L,\n40621L,40622L,40623L,40624L,40625L,40626L,40627L,40628L,40629L,40630L,\n40631L,40632L,40633L,40634L,40635L,40636L,40637L,40638L,40639L,40640L,\n40641L,40642L,40643L,40644L,40645L,40646L,40647L,40648L,40649L,40650L,\n40651L,40652L,40653L,40654L,40655L,40656L,40657L,40658L,40659L,40660L,\n40661L,40662L,40663L,40664L,40665L,40666L,40667L,40668L,40669L,40670L,\n40671L,40672L,40673L,40674L,40675L,40676L,40677L,40678L,40679L,40680L,\n40681L,40682L,40683L,40684L,40685L,40686L,40687L,40688L,40689L,40690L,\n40691L,40692L,40693L,40694L,40695L,40696L,40697L,40698L,40699L,40700L,\n40701L,40702L,40703L,40704L,40705L,40706L,40707L,40708L,40709L,40710L,\n40711L,40712L,40713L,40714L,40715L,40716L,40717L,40718L,40719L,40720L,\n40721L,40722L,40723L,40724L,40725L,40726L,40727L,40728L,40729L,40730L,\n40731L,40732L,40733L,40734L,40735L,40736L,40737L,40738L,40739L,40740L,\n40741L,40742L,40743L,40744L,40745L,40746L,40747L,40748L,40749L,40750L,\n40751L,40752L,40753L,40754L,40755L,40756L,40757L,40758L,40759L,40760L,\n40761L,40762L,40763L,40764L,40765L,40766L,40767L,40768L,40769L,40770L,\n40771L,40772L,40773L,40774L,40775L,40776L,40777L,40778L,40779L,40780L,\n40781L,40782L,40783L,40784L,40785L,40786L,40787L,40788L,40789L,40790L,\n40791L,40792L,40793L,40794L,40795L,40796L,40797L,40798L,40799L,40800L,\n40801L,40802L,40803L,40804L,40805L,40806L,40807L,40808L,40809L,40810L,\n40811L,40812L,40813L,40814L,40815L,40816L,40817L,40818L,40819L,40820L,\n40821L,40822L,40823L,40824L,40825L,40826L,40827L,40828L,40829L,40830L,\n40831L,40832L,40833L,40834L,40835L,40836L,40837L,40838L,40839L,40840L,\n40841L,40842L,40843L,40844L,40845L,40846L,40847L,40848L,40849L,40850L,\n40851L,40852L,40853L,40854L,40855L,40856L,40857L,40858L,40859L,40860L,\n40861L,40862L,40863L,40864L,40865L,40866L,40867L,40868L,40869L,40870L,\n40871L,40872L,40873L,40874L,40875L,40876L,40877L,40878L,40879L,40880L,\n40881L,40882L,40883L,40884L,40885L,40886L,40887L,40888L,40889L,40890L,\n40891L,40892L,40893L,40894L,40895L,40896L,40897L,40898L,40899L,40900L,\n40901L,40902L,40903L,40904L,40905L,40906L,40907L,40908L,40909L,40910L,\n40911L,40912L,40913L,40914L,40915L,40916L,40917L,40918L,40919L,40920L,\n40921L,40922L,40923L,40924L,40925L,40926L,40927L,40928L,40929L,40930L,\n40931L,40932L,40933L,40934L,40935L,40936L,40937L,40938L,40939L,40940L,\n40941L,40942L,40943L,40944L,40945L,40946L,40947L,40948L,40949L,40950L,\n40951L,40952L,40953L,40954L,40955L,40956L,40957L,40958L,40959L,40960L,\n40961L,40962L,40963L,40964L,40965L,40966L,40967L,40968L,40969L,40970L,\n40971L,40972L,40973L,40974L,40975L,40976L,40977L,40978L,40979L,40980L,\n40981L,40982L,40983L,40984L,40985L,40986L,40987L,40988L,40989L,40990L,\n40991L,40992L,40993L,40994L,40995L,40996L,40997L,40998L,40999L,41000L,\n41001L,41002L,41003L,41004L,41005L,41006L,41007L,41008L,41009L,41010L,\n41011L,41012L,41013L,41014L,41015L,41016L,41017L,41018L,41019L,41020L,\n41021L,41022L,41023L,41024L,41025L,41026L,41027L,41028L,41029L,41030L,\n41031L,41032L,41033L,41034L,41035L,41036L,41037L,41038L,41039L,41040L,\n41041L,41042L,41043L,41044L,41045L,41046L,41047L,41048L,41049L,41050L,\n41051L,41052L,41053L,41054L,41055L,41056L,41057L,41058L,41059L,41060L,\n41061L,41062L,41063L,41064L,41065L,41066L,41067L,41068L,41069L,41070L,\n41071L,41072L,41073L,41074L,41075L,41076L,41077L,41078L,41079L,41080L,\n41081L,41082L,41083L,41084L,41085L,41086L,41087L,41088L,41089L,41090L,\n41091L,41092L,41093L,41094L,41095L,41096L,41097L,41098L,41099L,41100L,\n41101L,41102L,41103L,41104L,41105L,41106L,41107L,41108L,41109L,41110L,\n41111L,41112L,41113L,41114L,41115L,41116L,41117L,41118L,41119L,41120L,\n41121L,41122L,41123L,41124L,41125L,41126L,41127L,41128L,41129L,41130L,\n41131L,41132L,41133L,41134L,41135L,41136L,41137L,41138L,41139L,41140L,\n41141L,41142L,41143L,41144L,41145L,41146L,41147L,41148L,41149L,41150L,\n41151L,41152L,41153L,41154L,41155L,41156L,41157L,41158L,41159L,41160L,\n41161L,41162L,41163L,41164L,41165L,41166L,41167L,41168L,41169L,41170L,\n41171L,41172L,41173L,41174L,41175L,41176L,41177L,41178L,41179L,41180L,\n41181L,41182L,41183L,41184L,41185L,41186L,41187L,41188L,41189L,41190L,\n41191L,41192L,41193L,41194L,41195L,41196L,41197L,41198L,41199L,41200L,\n41201L,41202L,41203L,41204L,41205L,41206L,41207L,41208L,41209L,41210L,\n41211L,41212L,41213L,41214L,41215L,41216L,41217L,41218L,41219L,41220L,\n41221L,41222L,41223L,41224L,41225L,41226L,41227L,41228L,41229L,41230L,\n41231L,41232L,41233L,41234L,41235L,41236L,41237L,41238L,41239L,41240L,\n41241L,41242L,41243L,41244L,41245L,41246L,41247L,41248L,41249L,41250L,\n41251L,41252L,41253L,41254L,41255L,41256L,41257L,41258L,41259L,41260L,\n41261L,41262L,41263L,41264L,41265L,41266L,41267L,41268L,41269L,41270L,\n41271L,41272L,41273L,41274L,41275L,41276L,41277L,41278L,41279L,41280L,\n41281L,41282L,41283L,41284L,41285L,41286L,41287L,41288L,41289L,41290L,\n41291L,41292L,41293L,41294L,41295L,41296L,41297L,41298L,41299L,41300L,\n41301L,41302L,41303L,41304L,41305L,41306L,41307L,41308L,41309L,41310L,\n41311L,41312L,41313L,41314L,41315L,41316L,41317L,41318L,41319L,41320L,\n41321L,41322L,41323L,41324L,41325L,41326L,41327L,41328L,41329L,41330L,\n41331L,41332L,41333L,41334L,41335L,41336L,41337L,41338L,41339L,41340L,\n41341L,41342L,41343L,41344L,41345L,41346L,41347L,41348L,41349L,41350L,\n41351L,41352L,41353L,41354L,41355L,41356L,41357L,41358L,41359L,41360L,\n41361L,41362L,41363L,41364L,41365L,41366L,41367L,41368L,41369L,41370L,\n41371L,41372L,41373L,41374L,41375L,41376L,41377L,41378L,41379L,41380L,\n41381L,41382L,41383L,41384L,41385L,41386L,41387L,41388L,41389L,41390L,\n41391L,41392L,41393L,41394L,41395L,41396L,41397L,41398L,41399L,41400L,\n41401L,41402L,41403L,41404L,41405L,41406L,41407L,41408L,41409L,41410L,\n41411L,41412L,41413L,41414L,41415L,41416L,41417L,41418L,41419L,41420L,\n41421L,41422L,41423L,41424L,41425L,41426L,41427L,41428L,41429L,41430L,\n41431L,41432L,41433L,41434L,41435L,41436L,41437L,41438L,41439L,41440L,\n41441L,41442L,41443L,41444L,41445L,41446L,41447L,41448L,41449L,41450L,\n41451L,41452L,41453L,41454L,41455L,41456L,41457L,41458L,41459L,41460L,\n41461L,41462L,41463L,41464L,41465L,41466L,41467L,41468L,41469L,41470L,\n41471L,41472L,41473L,41474L,41475L,41476L,41477L,41478L,41479L,41480L,\n41481L,41482L,41483L,41484L,41485L,41486L,41487L,41488L,41489L,41490L,\n41491L,41492L,41493L,41494L,41495L,41496L,41497L,41498L,41499L,41500L,\n41501L,41502L,41503L,41504L,41505L,41506L,41507L,41508L,41509L,41510L,\n41511L,41512L,41513L,41514L,41515L,41516L,41517L,41518L,41519L,41520L,\n41521L,41522L,41523L,41524L,41525L,41526L,41527L,41528L,41529L,41530L,\n41531L,41532L,41533L,41534L,41535L,41536L,41537L,41538L,41539L,41540L,\n41541L,41542L,41543L,41544L,41545L,41546L,41547L,41548L,41549L,41550L,\n41551L,41552L,41553L,41554L,41555L,41556L,41557L,41558L,41559L,41560L,\n41561L,41562L,41563L,41564L,41565L,41566L,41567L,41568L,41569L,41570L,\n41571L,41572L,41573L,41574L,41575L,41576L,41577L,41578L,41579L,41580L,\n41581L,41582L,41583L,41584L,41585L,41586L,41587L,41588L,41589L,41590L,\n41591L,41592L,41593L,41594L,41595L,41596L,41597L,41598L,41599L,41600L,\n41601L,41602L,41603L,41604L,41605L,41606L,41607L,41608L,41609L,41610L,\n41611L,41612L,41613L,41614L,41615L,41616L,41617L,41618L,41619L,41620L,\n41621L,41622L,41623L,41624L,41625L,41626L,41627L,41628L,41629L,41630L,\n41631L,41632L,41633L,41634L,41635L,41636L,41637L,41638L,41639L,41640L,\n41641L,41642L,41643L,41644L,41645L,41646L,41647L,41648L,41649L,41650L,\n41651L,41652L,41653L,41654L,41655L,41656L,41657L,41658L,41659L,41660L,\n41661L,41662L,41663L,41664L,41665L,41666L,41667L,41668L,41669L,41670L,\n41671L,41672L,41673L,41674L,41675L,41676L,41677L,41678L,41679L,41680L,\n41681L,41682L,41683L,41684L,41685L,41686L,41687L,41688L,41689L,41690L,\n41691L,41692L,41693L,41694L,41695L,41696L,41697L,41698L,41699L,41700L,\n41701L,41702L,41703L,41704L,41705L,41706L,41707L,41708L,41709L,41710L,\n41711L,41712L,41713L,41714L,41715L,41716L,41717L,41718L,41719L,41720L,\n41721L,41722L,41723L,41724L,41725L,41726L,41727L,41728L,41729L,41730L,\n41731L,41732L,41733L,41734L,41735L,41736L,41737L,41738L,41739L,41740L,\n41741L,41742L,41743L,41744L,41745L,41746L,41747L,41748L,41749L,41750L,\n41751L,41752L,41753L,41754L,41755L,41756L,41757L,41758L,41759L,41760L,\n41761L,41762L,41763L,41764L,41765L,41766L,41767L,41768L,41769L,41770L,\n41771L,41772L,41773L,41774L,41775L,41776L,41777L,41778L,41779L,41780L,\n41781L,41782L,41783L,41784L,41785L,41786L,41787L,41788L,41789L,41790L,\n41791L,41792L,41793L,41794L,41795L,41796L,41797L,41798L,41799L,41800L,\n41801L,41802L,41803L,41804L,41805L,41806L,41807L,41808L,41809L,41810L,\n41811L,41812L,41813L,41814L,41815L,41816L,41817L,41818L,41819L,41820L,\n41821L,41822L,41823L,41824L,41825L,41826L,41827L,41828L,41829L,41830L,\n41831L,41832L,41833L,41834L,41835L,41836L,41837L,41838L,41839L,41840L,\n41841L,41842L,41843L,41844L,41845L,41846L,41847L,41848L,41849L,41850L,\n41851L,41852L,41853L,41854L,41855L,41856L,41857L,41858L,41859L,41860L,\n41861L,41862L,41863L,41864L,41865L,41866L,41867L,41868L,41869L,41870L,\n41871L,41872L,41873L,41874L,41875L,41876L,41877L,41878L,41879L,41880L,\n41881L,41882L,41883L,41884L,41885L,41886L,41887L,41888L,41889L,41890L,\n41891L,41892L,41893L,41894L,41895L,41896L,41897L,41898L,41899L,41900L,\n41901L,41902L,41903L,41904L,41905L,41906L,41907L,41908L,41909L,41910L,\n41911L,41912L,41913L,41914L,41915L,41916L,41917L,41918L,41919L,41920L,\n41921L,41922L,41923L,41924L,41925L,41926L,41927L,41928L,41929L,41930L,\n41931L,41932L,41933L,41934L,41935L,41936L,41937L,41938L,41939L,41940L,\n41941L,41942L,41943L,41944L,41945L,41946L,41947L,41948L,41949L,41950L,\n41951L,41952L,41953L,41954L,41955L,41956L,41957L,41958L,41959L,41960L,\n41961L,41962L,41963L,41964L,41965L,41966L,41967L,41968L,41969L,41970L,\n41971L,41972L,41973L,41974L,41975L,41976L,41977L,41978L,41979L,41980L,\n41981L,41982L,41983L,41984L,41985L,41986L,41987L,41988L,41989L,41990L,\n41991L,41992L,41993L,41994L,41995L,41996L,41997L,41998L,41999L,42000L,\n42001L,42002L,42003L,42004L,42005L,42006L,42007L,42008L,42009L,42010L,\n42011L,42012L,42013L,42014L,42015L,42016L,42017L,42018L,42019L,42020L,\n42021L,42022L,42023L,42024L,42025L,42026L,42027L,42028L,42029L,42030L,\n42031L,42032L,42033L,42034L,42035L,42036L,42037L,42038L,42039L,42040L,\n42041L,42042L,42043L,42044L,42045L,42046L,42047L,42048L,42049L,42050L,\n42051L,42052L,42053L,42054L,42055L,42056L,42057L,42058L,42059L,42060L,\n42061L,42062L,42063L,42064L,42065L,42066L,42067L,42068L,42069L,42070L,\n42071L,42072L,42073L,42074L,42075L,42076L,42077L,42078L,42079L,42080L,\n42081L,42082L,42083L,42084L,42085L,42086L,42087L,42088L,42089L,42090L,\n42091L,42092L,42093L,42094L,42095L,42096L,42097L,42098L,42099L,42100L,\n42101L,42102L,42103L,42104L,42105L,42106L,42107L,42108L,42109L,42110L,\n42111L,42112L,42113L,42114L,42115L,42116L,42117L,42118L,42119L,42120L,\n42121L,42122L,42123L,42124L,42125L,42126L,42127L,42128L,42129L,42130L,\n42131L,42132L,42133L,42134L,42135L,42136L,42137L,42138L,42139L,42140L,\n42141L,42142L,42143L,42144L,42145L,42146L,42147L,42148L,42149L,42150L,\n42151L,42152L,42153L,42154L,42155L,42156L,42157L,42158L,42159L,42160L,\n42161L,42162L,42163L,42164L,42165L,42166L,42167L,42168L,42169L,42170L,\n42171L,42172L,42173L,42174L,42175L,42176L,42177L,42178L,42179L,42180L,\n42181L,42182L,42183L,42184L,42185L,42186L,42187L,42188L,42189L,42190L,\n42191L,42192L,42193L,42194L,42195L,42196L,42197L,42198L,42199L,42200L,\n42201L,42202L,42203L,42204L,42205L,42206L,42207L,42208L,42209L,42210L,\n42211L,42212L,42213L,42214L,42215L,42216L,42217L,42218L,42219L,42220L,\n42221L,42222L,42223L,42224L,42225L,42226L,42227L,42228L,42229L,42230L,\n42231L,42232L,42233L,42234L,42235L,42236L,42237L,42238L,42239L,42240L,\n42241L,42242L,42243L,42244L,42245L,42246L,42247L,42248L,42249L,42250L,\n42251L,42252L,42253L,42254L,42255L,42256L,42257L,42258L,42259L,42260L,\n42261L,42262L,42263L,42264L,42265L,42266L,42267L,42268L,42269L,42270L,\n42271L,42272L,42273L,42274L,42275L,42276L,42277L,42278L,42279L,42280L,\n42281L,42282L,42283L,42284L,42285L,42286L,42287L,42288L,42289L,42290L,\n42291L,42292L,42293L,42294L,42295L,42296L,42297L,42298L,42299L,42300L,\n42301L,42302L,42303L,42304L,42305L,42306L,42307L,42308L,42309L,42310L,\n42311L,42312L,42313L,42314L,42315L,42316L,42317L,42318L,42319L,42320L,\n42321L,42322L,42323L,42324L,42325L,42326L,42327L,42328L,42329L,42330L,\n42331L,42332L,42333L,42334L,42335L,42336L,42337L,42338L,42339L,42340L,\n42341L,42342L,42343L,42344L,42345L,42346L,42347L,42348L,42349L,42350L,\n42351L,42352L,42353L,42354L,42355L,42356L,42357L,42358L,42359L,42360L,\n42361L,42362L,42363L,42364L,42365L,42366L,42367L,42368L,42369L,42370L,\n42371L,42372L,42373L,42374L,42375L,42376L,42377L,42378L,42379L,42380L,\n42381L,42382L,42383L,42384L,42385L,42386L,42387L,42388L,42389L,42390L,\n42391L,42392L,42393L,42394L,42395L,42396L,42397L,42398L,42399L,42400L,\n42401L,42402L,42403L,42404L,42405L,42406L,42407L,42408L,42409L,42410L,\n42411L,42412L,42413L,42414L,42415L,42416L,42417L,42418L,42419L,42420L,\n42421L,42422L,42423L,42424L,42425L,42426L,42427L,42428L,42429L,42430L,\n42431L,42432L,42433L,42434L,42435L,42436L,42437L,42438L,42439L,42440L,\n42441L,42442L,42443L,42444L,42445L,42446L,42447L,42448L,42449L,42450L,\n42451L,42452L,42453L,42454L,42455L,42456L,42457L,42458L,42459L,42460L,\n42461L,42462L,42463L,42464L,42465L,42466L,42467L,42468L,42469L,42470L,\n42471L,42472L,42473L,42474L,42475L,42476L,42477L,42478L,42479L,42480L,\n42481L,42482L,42483L,42484L,42485L,42486L,42487L,42488L,42489L,42490L,\n42491L,42492L,42493L,42494L,42495L,42496L,42497L,42498L,42499L,42500L,\n42501L,42502L,42503L,42504L,42505L,42506L,42507L,42508L,42509L,42510L,\n42511L,42512L,42513L,42514L,42515L,42516L,42517L,42518L,42519L,42520L,\n42521L,42522L,42523L,42524L,42525L,42526L,42527L,42528L,42529L,42530L,\n42531L,42532L,42533L,42534L,42535L,42536L,42537L,42538L,42539L,42540L,\n42541L,42542L,42543L,42544L,42545L,42546L,42547L,42548L,42549L,42550L,\n42551L,42552L,42553L,42554L,42555L,42556L,42557L,42558L,42559L,42560L,\n42560L,42562L,42562L,42564L,42564L,42566L,42566L,42568L,42568L,42570L,\n42570L,42572L,42572L,42574L,42574L,42576L,42576L,42578L,42578L,42580L,\n42580L,42582L,42582L,42584L,42584L,42586L,42586L,42588L,42588L,42590L,\n42590L,42592L,42592L,42594L,42594L,42596L,42596L,42598L,42598L,42600L,\n42600L,42602L,42602L,42604L,42604L,42606L,42607L,42608L,42609L,42610L,\n42611L,42612L,42613L,42614L,42615L,42616L,42617L,42618L,42619L,42620L,\n42621L,42622L,42623L,42624L,42624L,42626L,42626L,42628L,42628L,42630L,\n42630L,42632L,42632L,42634L,42634L,42636L,42636L,42638L,42638L,42640L,\n42640L,42642L,42642L,42644L,42644L,42646L,42646L,42648L,42648L,42650L,\n42650L,42652L,42653L,42654L,42655L,42656L,42657L,42658L,42659L,42660L,\n42661L,42662L,42663L,42664L,42665L,42666L,42667L,42668L,42669L,42670L,\n42671L,42672L,42673L,42674L,42675L,42676L,42677L,42678L,42679L,42680L,\n42681L,42682L,42683L,42684L,42685L,42686L,42687L,42688L,42689L,42690L,\n42691L,42692L,42693L,42694L,42695L,42696L,42697L,42698L,42699L,42700L,\n42701L,42702L,42703L,42704L,42705L,42706L,42707L,42708L,42709L,42710L,\n42711L,42712L,42713L,42714L,42715L,42716L,42717L,42718L,42719L,42720L,\n42721L,42722L,42723L,42724L,42725L,42726L,42727L,42728L,42729L,42730L,\n42731L,42732L,42733L,42734L,42735L,42736L,42737L,42738L,42739L,42740L,\n42741L,42742L,42743L,42744L,42745L,42746L,42747L,42748L,42749L,42750L,\n42751L,42752L,42753L,42754L,42755L,42756L,42757L,42758L,42759L,42760L,\n42761L,42762L,42763L,42764L,42765L,42766L,42767L,42768L,42769L,42770L,\n42771L,42772L,42773L,42774L,42775L,42776L,42777L,42778L,42779L,42780L,\n42781L,42782L,42783L,42784L,42785L,42786L,42786L,42788L,42788L,42790L,\n42790L,42792L,42792L,42794L,42794L,42796L,42796L,42798L,42798L,42800L,\n42801L,42802L,42802L,42804L,42804L,42806L,42806L,42808L,42808L,42810L,\n42810L,42812L,42812L,42814L,42814L,42816L,42816L,42818L,42818L,42820L,\n42820L,42822L,42822L,42824L,42824L,42826L,42826L,42828L,42828L,42830L,\n42830L,42832L,42832L,42834L,42834L,42836L,42836L,42838L,42838L,42840L,\n42840L,42842L,42842L,42844L,42844L,42846L,42846L,42848L,42848L,42850L,\n42850L,42852L,42852L,42854L,42854L,42856L,42856L,42858L,42858L,42860L,\n42860L,42862L,42862L,42864L,42865L,42866L,42867L,42868L,42869L,42870L,\n42871L,42872L,42873L,42873L,42875L,42875L,42877L,42878L,42878L,42880L,\n42880L,42882L,42882L,42884L,42884L,42886L,42886L,42888L,42889L,42890L,\n42891L,42891L,42893L,42894L,42895L,42896L,42896L,42898L,42898L,42900L,\n42901L,42902L,42902L,42904L,42904L,42906L,42906L,42908L,42908L,42910L,\n42910L,42912L,42912L,42914L,42914L,42916L,42916L,42918L,42918L,42920L,\n42920L,42922L,42923L,42924L,42925L,42926L,42927L,42928L,42929L,42930L,\n42931L,42932L,42932L,42934L,42934L,42936L,42937L,42938L,42939L,42940L,\n42941L,42942L,42943L,42944L,42945L,42946L,42947L,42948L,42949L,42950L,\n42951L,42952L,42953L,42954L,42955L,42956L,42957L,42958L,42959L,42960L,\n42961L,42962L,42963L,42964L,42965L,42966L,42967L,42968L,42969L,42970L,\n42971L,42972L,42973L,42974L,42975L,42976L,42977L,42978L,42979L,42980L,\n42981L,42982L,42983L,42984L,42985L,42986L,42987L,42988L,42989L,42990L,\n42991L,42992L,42993L,42994L,42995L,42996L,42997L,42998L,42999L,43000L,\n43001L,43002L,43003L,43004L,43005L,43006L,43007L,43008L,43009L,43010L,\n43011L,43012L,43013L,43014L,43015L,43016L,43017L,43018L,43019L,43020L,\n43021L,43022L,43023L,43024L,43025L,43026L,43027L,43028L,43029L,43030L,\n43031L,43032L,43033L,43034L,43035L,43036L,43037L,43038L,43039L,43040L,\n43041L,43042L,43043L,43044L,43045L,43046L,43047L,43048L,43049L,43050L,\n43051L,43052L,43053L,43054L,43055L,43056L,43057L,43058L,43059L,43060L,\n43061L,43062L,43063L,43064L,43065L,43066L,43067L,43068L,43069L,43070L,\n43071L,43072L,43073L,43074L,43075L,43076L,43077L,43078L,43079L,43080L,\n43081L,43082L,43083L,43084L,43085L,43086L,43087L,43088L,43089L,43090L,\n43091L,43092L,43093L,43094L,43095L,43096L,43097L,43098L,43099L,43100L,\n43101L,43102L,43103L,43104L,43105L,43106L,43107L,43108L,43109L,43110L,\n43111L,43112L,43113L,43114L,43115L,43116L,43117L,43118L,43119L,43120L,\n43121L,43122L,43123L,43124L,43125L,43126L,43127L,43128L,43129L,43130L,\n43131L,43132L,43133L,43134L,43135L,43136L,43137L,43138L,43139L,43140L,\n43141L,43142L,43143L,43144L,43145L,43146L,43147L,43148L,43149L,43150L,\n43151L,43152L,43153L,43154L,43155L,43156L,43157L,43158L,43159L,43160L,\n43161L,43162L,43163L,43164L,43165L,43166L,43167L,43168L,43169L,43170L,\n43171L,43172L,43173L,43174L,43175L,43176L,43177L,43178L,43179L,43180L,\n43181L,43182L,43183L,43184L,43185L,43186L,43187L,43188L,43189L,43190L,\n43191L,43192L,43193L,43194L,43195L,43196L,43197L,43198L,43199L,43200L,\n43201L,43202L,43203L,43204L,43205L,43206L,43207L,43208L,43209L,43210L,\n43211L,43212L,43213L,43214L,43215L,43216L,43217L,43218L,43219L,43220L,\n43221L,43222L,43223L,43224L,43225L,43226L,43227L,43228L,43229L,43230L,\n43231L,43232L,43233L,43234L,43235L,43236L,43237L,43238L,43239L,43240L,\n43241L,43242L,43243L,43244L,43245L,43246L,43247L,43248L,43249L,43250L,\n43251L,43252L,43253L,43254L,43255L,43256L,43257L,43258L,43259L,43260L,\n43261L,43262L,43263L,43264L,43265L,43266L,43267L,43268L,43269L,43270L,\n43271L,43272L,43273L,43274L,43275L,43276L,43277L,43278L,43279L,43280L,\n43281L,43282L,43283L,43284L,43285L,43286L,43287L,43288L,43289L,43290L,\n43291L,43292L,43293L,43294L,43295L,43296L,43297L,43298L,43299L,43300L,\n43301L,43302L,43303L,43304L,43305L,43306L,43307L,43308L,43309L,43310L,\n43311L,43312L,43313L,43314L,43315L,43316L,43317L,43318L,43319L,43320L,\n43321L,43322L,43323L,43324L,43325L,43326L,43327L,43328L,43329L,43330L,\n43331L,43332L,43333L,43334L,43335L,43336L,43337L,43338L,43339L,43340L,\n43341L,43342L,43343L,43344L,43345L,43346L,43347L,43348L,43349L,43350L,\n43351L,43352L,43353L,43354L,43355L,43356L,43357L,43358L,43359L,43360L,\n43361L,43362L,43363L,43364L,43365L,43366L,43367L,43368L,43369L,43370L,\n43371L,43372L,43373L,43374L,43375L,43376L,43377L,43378L,43379L,43380L,\n43381L,43382L,43383L,43384L,43385L,43386L,43387L,43388L,43389L,43390L,\n43391L,43392L,43393L,43394L,43395L,43396L,43397L,43398L,43399L,43400L,\n43401L,43402L,43403L,43404L,43405L,43406L,43407L,43408L,43409L,43410L,\n43411L,43412L,43413L,43414L,43415L,43416L,43417L,43418L,43419L,43420L,\n43421L,43422L,43423L,43424L,43425L,43426L,43427L,43428L,43429L,43430L,\n43431L,43432L,43433L,43434L,43435L,43436L,43437L,43438L,43439L,43440L,\n43441L,43442L,43443L,43444L,43445L,43446L,43447L,43448L,43449L,43450L,\n43451L,43452L,43453L,43454L,43455L,43456L,43457L,43458L,43459L,43460L,\n43461L,43462L,43463L,43464L,43465L,43466L,43467L,43468L,43469L,43470L,\n43471L,43472L,43473L,43474L,43475L,43476L,43477L,43478L,43479L,43480L,\n43481L,43482L,43483L,43484L,43485L,43486L,43487L,43488L,43489L,43490L,\n43491L,43492L,43493L,43494L,43495L,43496L,43497L,43498L,43499L,43500L,\n43501L,43502L,43503L,43504L,43505L,43506L,43507L,43508L,43509L,43510L,\n43511L,43512L,43513L,43514L,43515L,43516L,43517L,43518L,43519L,43520L,\n43521L,43522L,43523L,43524L,43525L,43526L,43527L,43528L,43529L,43530L,\n43531L,43532L,43533L,43534L,43535L,43536L,43537L,43538L,43539L,43540L,\n43541L,43542L,43543L,43544L,43545L,43546L,43547L,43548L,43549L,43550L,\n43551L,43552L,43553L,43554L,43555L,43556L,43557L,43558L,43559L,43560L,\n43561L,43562L,43563L,43564L,43565L,43566L,43567L,43568L,43569L,43570L,\n43571L,43572L,43573L,43574L,43575L,43576L,43577L,43578L,43579L,43580L,\n43581L,43582L,43583L,43584L,43585L,43586L,43587L,43588L,43589L,43590L,\n43591L,43592L,43593L,43594L,43595L,43596L,43597L,43598L,43599L,43600L,\n43601L,43602L,43603L,43604L,43605L,43606L,43607L,43608L,43609L,43610L,\n43611L,43612L,43613L,43614L,43615L,43616L,43617L,43618L,43619L,43620L,\n43621L,43622L,43623L,43624L,43625L,43626L,43627L,43628L,43629L,43630L,\n43631L,43632L,43633L,43634L,43635L,43636L,43637L,43638L,43639L,43640L,\n43641L,43642L,43643L,43644L,43645L,43646L,43647L,43648L,43649L,43650L,\n43651L,43652L,43653L,43654L,43655L,43656L,43657L,43658L,43659L,43660L,\n43661L,43662L,43663L,43664L,43665L,43666L,43667L,43668L,43669L,43670L,\n43671L,43672L,43673L,43674L,43675L,43676L,43677L,43678L,43679L,43680L,\n43681L,43682L,43683L,43684L,43685L,43686L,43687L,43688L,43689L,43690L,\n43691L,43692L,43693L,43694L,43695L,43696L,43697L,43698L,43699L,43700L,\n43701L,43702L,43703L,43704L,43705L,43706L,43707L,43708L,43709L,43710L,\n43711L,43712L,43713L,43714L,43715L,43716L,43717L,43718L,43719L,43720L,\n43721L,43722L,43723L,43724L,43725L,43726L,43727L,43728L,43729L,43730L,\n43731L,43732L,43733L,43734L,43735L,43736L,43737L,43738L,43739L,43740L,\n43741L,43742L,43743L,43744L,43745L,43746L,43747L,43748L,43749L,43750L,\n43751L,43752L,43753L,43754L,43755L,43756L,43757L,43758L,43759L,43760L,\n43761L,43762L,43763L,43764L,43765L,43766L,43767L,43768L,43769L,43770L,\n43771L,43772L,43773L,43774L,43775L,43776L,43777L,43778L,43779L,43780L,\n43781L,43782L,43783L,43784L,43785L,43786L,43787L,43788L,43789L,43790L,\n43791L,43792L,43793L,43794L,43795L,43796L,43797L,43798L,43799L,43800L,\n43801L,43802L,43803L,43804L,43805L,43806L,43807L,43808L,43809L,43810L,\n43811L,43812L,43813L,43814L,43815L,43816L,43817L,43818L,43819L,43820L,\n43821L,43822L,43823L,43824L,43825L,43826L,43827L,43828L,43829L,43830L,\n43831L,43832L,43833L,43834L,43835L,43836L,43837L,43838L,43839L,43840L,\n43841L,43842L,43843L,43844L,43845L,43846L,43847L,43848L,43849L,43850L,\n43851L,43852L,43853L,43854L,43855L,43856L,43857L,43858L,42931L,43860L,\n43861L,43862L,43863L,43864L,43865L,43866L,43867L,43868L,43869L,43870L,\n43871L,43872L,43873L,43874L,43875L,43876L,43877L,43878L,43879L,43880L,\n43881L,43882L,43883L,43884L,43885L,43886L,43887L,5024,5025,5026,5027,5028,\n5029,5030,5031,5032,5033,5034,5035,5036,5037,5038,5039,5040,5041,5042,5043,\n5044,5045,5046,5047,5048,5049,5050,5051,5052,5053,5054,5055,5056,5057,5058,\n5059,5060,5061,5062,5063,5064,5065,5066,5067,5068,5069,5070,5071,5072,5073,\n5074,5075,5076,5077,5078,5079,5080,5081,5082,5083,5084,5085,5086,5087,5088,\n5089,5090,5091,5092,5093,5094,5095,5096,5097,5098,5099,5100,5101,5102,5103,\n43968L,43969L,43970L,43971L,43972L,43973L,43974L,43975L,43976L,43977L,\n43978L,43979L,43980L,43981L,43982L,43983L,43984L,43985L,43986L,43987L,\n43988L,43989L,43990L,43991L,43992L,43993L,43994L,43995L,43996L,43997L,\n43998L,43999L,44000L,44001L,44002L,44003L,44004L,44005L,44006L,44007L,\n44008L,44009L,44010L,44011L,44012L,44013L,44014L,44015L,44016L,44017L,\n44018L,44019L,44020L,44021L,44022L,44023L,44024L,44025L,44026L,44027L,\n44028L,44029L,44030L,44031L,44032L,44033L,44034L,44035L,44036L,44037L,\n44038L,44039L,44040L,44041L,44042L,44043L,44044L,44045L,44046L,44047L,\n44048L,44049L,44050L,44051L,44052L,44053L,44054L,44055L,44056L,44057L,\n44058L,44059L,44060L,44061L,44062L,44063L,44064L,44065L,44066L,44067L,\n44068L,44069L,44070L,44071L,44072L,44073L,44074L,44075L,44076L,44077L,\n44078L,44079L,44080L,44081L,44082L,44083L,44084L,44085L,44086L,44087L,\n44088L,44089L,44090L,44091L,44092L,44093L,44094L,44095L,44096L,44097L,\n44098L,44099L,44100L,44101L,44102L,44103L,44104L,44105L,44106L,44107L,\n44108L,44109L,44110L,44111L,44112L,44113L,44114L,44115L,44116L,44117L,\n44118L,44119L,44120L,44121L,44122L,44123L,44124L,44125L,44126L,44127L,\n44128L,44129L,44130L,44131L,44132L,44133L,44134L,44135L,44136L,44137L,\n44138L,44139L,44140L,44141L,44142L,44143L,44144L,44145L,44146L,44147L,\n44148L,44149L,44150L,44151L,44152L,44153L,44154L,44155L,44156L,44157L,\n44158L,44159L,44160L,44161L,44162L,44163L,44164L,44165L,44166L,44167L,\n44168L,44169L,44170L,44171L,44172L,44173L,44174L,44175L,44176L,44177L,\n44178L,44179L,44180L,44181L,44182L,44183L,44184L,44185L,44186L,44187L,\n44188L,44189L,44190L,44191L,44192L,44193L,44194L,44195L,44196L,44197L,\n44198L,44199L,44200L,44201L,44202L,44203L,44204L,44205L,44206L,44207L,\n44208L,44209L,44210L,44211L,44212L,44213L,44214L,44215L,44216L,44217L,\n44218L,44219L,44220L,44221L,44222L,44223L,44224L,44225L,44226L,44227L,\n44228L,44229L,44230L,44231L,44232L,44233L,44234L,44235L,44236L,44237L,\n44238L,44239L,44240L,44241L,44242L,44243L,44244L,44245L,44246L,44247L,\n44248L,44249L,44250L,44251L,44252L,44253L,44254L,44255L,44256L,44257L,\n44258L,44259L,44260L,44261L,44262L,44263L,44264L,44265L,44266L,44267L,\n44268L,44269L,44270L,44271L,44272L,44273L,44274L,44275L,44276L,44277L,\n44278L,44279L,44280L,44281L,44282L,44283L,44284L,44285L,44286L,44287L,\n44288L,44289L,44290L,44291L,44292L,44293L,44294L,44295L,44296L,44297L,\n44298L,44299L,44300L,44301L,44302L,44303L,44304L,44305L,44306L,44307L,\n44308L,44309L,44310L,44311L,44312L,44313L,44314L,44315L,44316L,44317L,\n44318L,44319L,44320L,44321L,44322L,44323L,44324L,44325L,44326L,44327L,\n44328L,44329L,44330L,44331L,44332L,44333L,44334L,44335L,44336L,44337L,\n44338L,44339L,44340L,44341L,44342L,44343L,44344L,44345L,44346L,44347L,\n44348L,44349L,44350L,44351L,44352L,44353L,44354L,44355L,44356L,44357L,\n44358L,44359L,44360L,44361L,44362L,44363L,44364L,44365L,44366L,44367L,\n44368L,44369L,44370L,44371L,44372L,44373L,44374L,44375L,44376L,44377L,\n44378L,44379L,44380L,44381L,44382L,44383L,44384L,44385L,44386L,44387L,\n44388L,44389L,44390L,44391L,44392L,44393L,44394L,44395L,44396L,44397L,\n44398L,44399L,44400L,44401L,44402L,44403L,44404L,44405L,44406L,44407L,\n44408L,44409L,44410L,44411L,44412L,44413L,44414L,44415L,44416L,44417L,\n44418L,44419L,44420L,44421L,44422L,44423L,44424L,44425L,44426L,44427L,\n44428L,44429L,44430L,44431L,44432L,44433L,44434L,44435L,44436L,44437L,\n44438L,44439L,44440L,44441L,44442L,44443L,44444L,44445L,44446L,44447L,\n44448L,44449L,44450L,44451L,44452L,44453L,44454L,44455L,44456L,44457L,\n44458L,44459L,44460L,44461L,44462L,44463L,44464L,44465L,44466L,44467L,\n44468L,44469L,44470L,44471L,44472L,44473L,44474L,44475L,44476L,44477L,\n44478L,44479L,44480L,44481L,44482L,44483L,44484L,44485L,44486L,44487L,\n44488L,44489L,44490L,44491L,44492L,44493L,44494L,44495L,44496L,44497L,\n44498L,44499L,44500L,44501L,44502L,44503L,44504L,44505L,44506L,44507L,\n44508L,44509L,44510L,44511L,44512L,44513L,44514L,44515L,44516L,44517L,\n44518L,44519L,44520L,44521L,44522L,44523L,44524L,44525L,44526L,44527L,\n44528L,44529L,44530L,44531L,44532L,44533L,44534L,44535L,44536L,44537L,\n44538L,44539L,44540L,44541L,44542L,44543L,44544L,44545L,44546L,44547L,\n44548L,44549L,44550L,44551L,44552L,44553L,44554L,44555L,44556L,44557L,\n44558L,44559L,44560L,44561L,44562L,44563L,44564L,44565L,44566L,44567L,\n44568L,44569L,44570L,44571L,44572L,44573L,44574L,44575L,44576L,44577L,\n44578L,44579L,44580L,44581L,44582L,44583L,44584L,44585L,44586L,44587L,\n44588L,44589L,44590L,44591L,44592L,44593L,44594L,44595L,44596L,44597L,\n44598L,44599L,44600L,44601L,44602L,44603L,44604L,44605L,44606L,44607L,\n44608L,44609L,44610L,44611L,44612L,44613L,44614L,44615L,44616L,44617L,\n44618L,44619L,44620L,44621L,44622L,44623L,44624L,44625L,44626L,44627L,\n44628L,44629L,44630L,44631L,44632L,44633L,44634L,44635L,44636L,44637L,\n44638L,44639L,44640L,44641L,44642L,44643L,44644L,44645L,44646L,44647L,\n44648L,44649L,44650L,44651L,44652L,44653L,44654L,44655L,44656L,44657L,\n44658L,44659L,44660L,44661L,44662L,44663L,44664L,44665L,44666L,44667L,\n44668L,44669L,44670L,44671L,44672L,44673L,44674L,44675L,44676L,44677L,\n44678L,44679L,44680L,44681L,44682L,44683L,44684L,44685L,44686L,44687L,\n44688L,44689L,44690L,44691L,44692L,44693L,44694L,44695L,44696L,44697L,\n44698L,44699L,44700L,44701L,44702L,44703L,44704L,44705L,44706L,44707L,\n44708L,44709L,44710L,44711L,44712L,44713L,44714L,44715L,44716L,44717L,\n44718L,44719L,44720L,44721L,44722L,44723L,44724L,44725L,44726L,44727L,\n44728L,44729L,44730L,44731L,44732L,44733L,44734L,44735L,44736L,44737L,\n44738L,44739L,44740L,44741L,44742L,44743L,44744L,44745L,44746L,44747L,\n44748L,44749L,44750L,44751L,44752L,44753L,44754L,44755L,44756L,44757L,\n44758L,44759L,44760L,44761L,44762L,44763L,44764L,44765L,44766L,44767L,\n44768L,44769L,44770L,44771L,44772L,44773L,44774L,44775L,44776L,44777L,\n44778L,44779L,44780L,44781L,44782L,44783L,44784L,44785L,44786L,44787L,\n44788L,44789L,44790L,44791L,44792L,44793L,44794L,44795L,44796L,44797L,\n44798L,44799L,44800L,44801L,44802L,44803L,44804L,44805L,44806L,44807L,\n44808L,44809L,44810L,44811L,44812L,44813L,44814L,44815L,44816L,44817L,\n44818L,44819L,44820L,44821L,44822L,44823L,44824L,44825L,44826L,44827L,\n44828L,44829L,44830L,44831L,44832L,44833L,44834L,44835L,44836L,44837L,\n44838L,44839L,44840L,44841L,44842L,44843L,44844L,44845L,44846L,44847L,\n44848L,44849L,44850L,44851L,44852L,44853L,44854L,44855L,44856L,44857L,\n44858L,44859L,44860L,44861L,44862L,44863L,44864L,44865L,44866L,44867L,\n44868L,44869L,44870L,44871L,44872L,44873L,44874L,44875L,44876L,44877L,\n44878L,44879L,44880L,44881L,44882L,44883L,44884L,44885L,44886L,44887L,\n44888L,44889L,44890L,44891L,44892L,44893L,44894L,44895L,44896L,44897L,\n44898L,44899L,44900L,44901L,44902L,44903L,44904L,44905L,44906L,44907L,\n44908L,44909L,44910L,44911L,44912L,44913L,44914L,44915L,44916L,44917L,\n44918L,44919L,44920L,44921L,44922L,44923L,44924L,44925L,44926L,44927L,\n44928L,44929L,44930L,44931L,44932L,44933L,44934L,44935L,44936L,44937L,\n44938L,44939L,44940L,44941L,44942L,44943L,44944L,44945L,44946L,44947L,\n44948L,44949L,44950L,44951L,44952L,44953L,44954L,44955L,44956L,44957L,\n44958L,44959L,44960L,44961L,44962L,44963L,44964L,44965L,44966L,44967L,\n44968L,44969L,44970L,44971L,44972L,44973L,44974L,44975L,44976L,44977L,\n44978L,44979L,44980L,44981L,44982L,44983L,44984L,44985L,44986L,44987L,\n44988L,44989L,44990L,44991L,44992L,44993L,44994L,44995L,44996L,44997L,\n44998L,44999L,45000L,45001L,45002L,45003L,45004L,45005L,45006L,45007L,\n45008L,45009L,45010L,45011L,45012L,45013L,45014L,45015L,45016L,45017L,\n45018L,45019L,45020L,45021L,45022L,45023L,45024L,45025L,45026L,45027L,\n45028L,45029L,45030L,45031L,45032L,45033L,45034L,45035L,45036L,45037L,\n45038L,45039L,45040L,45041L,45042L,45043L,45044L,45045L,45046L,45047L,\n45048L,45049L,45050L,45051L,45052L,45053L,45054L,45055L,45056L,45057L,\n45058L,45059L,45060L,45061L,45062L,45063L,45064L,45065L,45066L,45067L,\n45068L,45069L,45070L,45071L,45072L,45073L,45074L,45075L,45076L,45077L,\n45078L,45079L,45080L,45081L,45082L,45083L,45084L,45085L,45086L,45087L,\n45088L,45089L,45090L,45091L,45092L,45093L,45094L,45095L,45096L,45097L,\n45098L,45099L,45100L,45101L,45102L,45103L,45104L,45105L,45106L,45107L,\n45108L,45109L,45110L,45111L,45112L,45113L,45114L,45115L,45116L,45117L,\n45118L,45119L,45120L,45121L,45122L,45123L,45124L,45125L,45126L,45127L,\n45128L,45129L,45130L,45131L,45132L,45133L,45134L,45135L,45136L,45137L,\n45138L,45139L,45140L,45141L,45142L,45143L,45144L,45145L,45146L,45147L,\n45148L,45149L,45150L,45151L,45152L,45153L,45154L,45155L,45156L,45157L,\n45158L,45159L,45160L,45161L,45162L,45163L,45164L,45165L,45166L,45167L,\n45168L,45169L,45170L,45171L,45172L,45173L,45174L,45175L,45176L,45177L,\n45178L,45179L,45180L,45181L,45182L,45183L,45184L,45185L,45186L,45187L,\n45188L,45189L,45190L,45191L,45192L,45193L,45194L,45195L,45196L,45197L,\n45198L,45199L,45200L,45201L,45202L,45203L,45204L,45205L,45206L,45207L,\n45208L,45209L,45210L,45211L,45212L,45213L,45214L,45215L,45216L,45217L,\n45218L,45219L,45220L,45221L,45222L,45223L,45224L,45225L,45226L,45227L,\n45228L,45229L,45230L,45231L,45232L,45233L,45234L,45235L,45236L,45237L,\n45238L,45239L,45240L,45241L,45242L,45243L,45244L,45245L,45246L,45247L,\n45248L,45249L,45250L,45251L,45252L,45253L,45254L,45255L,45256L,45257L,\n45258L,45259L,45260L,45261L,45262L,45263L,45264L,45265L,45266L,45267L,\n45268L,45269L,45270L,45271L,45272L,45273L,45274L,45275L,45276L,45277L,\n45278L,45279L,45280L,45281L,45282L,45283L,45284L,45285L,45286L,45287L,\n45288L,45289L,45290L,45291L,45292L,45293L,45294L,45295L,45296L,45297L,\n45298L,45299L,45300L,45301L,45302L,45303L,45304L,45305L,45306L,45307L,\n45308L,45309L,45310L,45311L,45312L,45313L,45314L,45315L,45316L,45317L,\n45318L,45319L,45320L,45321L,45322L,45323L,45324L,45325L,45326L,45327L,\n45328L,45329L,45330L,45331L,45332L,45333L,45334L,45335L,45336L,45337L,\n45338L,45339L,45340L,45341L,45342L,45343L,45344L,45345L,45346L,45347L,\n45348L,45349L,45350L,45351L,45352L,45353L,45354L,45355L,45356L,45357L,\n45358L,45359L,45360L,45361L,45362L,45363L,45364L,45365L,45366L,45367L,\n45368L,45369L,45370L,45371L,45372L,45373L,45374L,45375L,45376L,45377L,\n45378L,45379L,45380L,45381L,45382L,45383L,45384L,45385L,45386L,45387L,\n45388L,45389L,45390L,45391L,45392L,45393L,45394L,45395L,45396L,45397L,\n45398L,45399L,45400L,45401L,45402L,45403L,45404L,45405L,45406L,45407L,\n45408L,45409L,45410L,45411L,45412L,45413L,45414L,45415L,45416L,45417L,\n45418L,45419L,45420L,45421L,45422L,45423L,45424L,45425L,45426L,45427L,\n45428L,45429L,45430L,45431L,45432L,45433L,45434L,45435L,45436L,45437L,\n45438L,45439L,45440L,45441L,45442L,45443L,45444L,45445L,45446L,45447L,\n45448L,45449L,45450L,45451L,45452L,45453L,45454L,45455L,45456L,45457L,\n45458L,45459L,45460L,45461L,45462L,45463L,45464L,45465L,45466L,45467L,\n45468L,45469L,45470L,45471L,45472L,45473L,45474L,45475L,45476L,45477L,\n45478L,45479L,45480L,45481L,45482L,45483L,45484L,45485L,45486L,45487L,\n45488L,45489L,45490L,45491L,45492L,45493L,45494L,45495L,45496L,45497L,\n45498L,45499L,45500L,45501L,45502L,45503L,45504L,45505L,45506L,45507L,\n45508L,45509L,45510L,45511L,45512L,45513L,45514L,45515L,45516L,45517L,\n45518L,45519L,45520L,45521L,45522L,45523L,45524L,45525L,45526L,45527L,\n45528L,45529L,45530L,45531L,45532L,45533L,45534L,45535L,45536L,45537L,\n45538L,45539L,45540L,45541L,45542L,45543L,45544L,45545L,45546L,45547L,\n45548L,45549L,45550L,45551L,45552L,45553L,45554L,45555L,45556L,45557L,\n45558L,45559L,45560L,45561L,45562L,45563L,45564L,45565L,45566L,45567L,\n45568L,45569L,45570L,45571L,45572L,45573L,45574L,45575L,45576L,45577L,\n45578L,45579L,45580L,45581L,45582L,45583L,45584L,45585L,45586L,45587L,\n45588L,45589L,45590L,45591L,45592L,45593L,45594L,45595L,45596L,45597L,\n45598L,45599L,45600L,45601L,45602L,45603L,45604L,45605L,45606L,45607L,\n45608L,45609L,45610L,45611L,45612L,45613L,45614L,45615L,45616L,45617L,\n45618L,45619L,45620L,45621L,45622L,45623L,45624L,45625L,45626L,45627L,\n45628L,45629L,45630L,45631L,45632L,45633L,45634L,45635L,45636L,45637L,\n45638L,45639L,45640L,45641L,45642L,45643L,45644L,45645L,45646L,45647L,\n45648L,45649L,45650L,45651L,45652L,45653L,45654L,45655L,45656L,45657L,\n45658L,45659L,45660L,45661L,45662L,45663L,45664L,45665L,45666L,45667L,\n45668L,45669L,45670L,45671L,45672L,45673L,45674L,45675L,45676L,45677L,\n45678L,45679L,45680L,45681L,45682L,45683L,45684L,45685L,45686L,45687L,\n45688L,45689L,45690L,45691L,45692L,45693L,45694L,45695L,45696L,45697L,\n45698L,45699L,45700L,45701L,45702L,45703L,45704L,45705L,45706L,45707L,\n45708L,45709L,45710L,45711L,45712L,45713L,45714L,45715L,45716L,45717L,\n45718L,45719L,45720L,45721L,45722L,45723L,45724L,45725L,45726L,45727L,\n45728L,45729L,45730L,45731L,45732L,45733L,45734L,45735L,45736L,45737L,\n45738L,45739L,45740L,45741L,45742L,45743L,45744L,45745L,45746L,45747L,\n45748L,45749L,45750L,45751L,45752L,45753L,45754L,45755L,45756L,45757L,\n45758L,45759L,45760L,45761L,45762L,45763L,45764L,45765L,45766L,45767L,\n45768L,45769L,45770L,45771L,45772L,45773L,45774L,45775L,45776L,45777L,\n45778L,45779L,45780L,45781L,45782L,45783L,45784L,45785L,45786L,45787L,\n45788L,45789L,45790L,45791L,45792L,45793L,45794L,45795L,45796L,45797L,\n45798L,45799L,45800L,45801L,45802L,45803L,45804L,45805L,45806L,45807L,\n45808L,45809L,45810L,45811L,45812L,45813L,45814L,45815L,45816L,45817L,\n45818L,45819L,45820L,45821L,45822L,45823L,45824L,45825L,45826L,45827L,\n45828L,45829L,45830L,45831L,45832L,45833L,45834L,45835L,45836L,45837L,\n45838L,45839L,45840L,45841L,45842L,45843L,45844L,45845L,45846L,45847L,\n45848L,45849L,45850L,45851L,45852L,45853L,45854L,45855L,45856L,45857L,\n45858L,45859L,45860L,45861L,45862L,45863L,45864L,45865L,45866L,45867L,\n45868L,45869L,45870L,45871L,45872L,45873L,45874L,45875L,45876L,45877L,\n45878L,45879L,45880L,45881L,45882L,45883L,45884L,45885L,45886L,45887L,\n45888L,45889L,45890L,45891L,45892L,45893L,45894L,45895L,45896L,45897L,\n45898L,45899L,45900L,45901L,45902L,45903L,45904L,45905L,45906L,45907L,\n45908L,45909L,45910L,45911L,45912L,45913L,45914L,45915L,45916L,45917L,\n45918L,45919L,45920L,45921L,45922L,45923L,45924L,45925L,45926L,45927L,\n45928L,45929L,45930L,45931L,45932L,45933L,45934L,45935L,45936L,45937L,\n45938L,45939L,45940L,45941L,45942L,45943L,45944L,45945L,45946L,45947L,\n45948L,45949L,45950L,45951L,45952L,45953L,45954L,45955L,45956L,45957L,\n45958L,45959L,45960L,45961L,45962L,45963L,45964L,45965L,45966L,45967L,\n45968L,45969L,45970L,45971L,45972L,45973L,45974L,45975L,45976L,45977L,\n45978L,45979L,45980L,45981L,45982L,45983L,45984L,45985L,45986L,45987L,\n45988L,45989L,45990L,45991L,45992L,45993L,45994L,45995L,45996L,45997L,\n45998L,45999L,46000L,46001L,46002L,46003L,46004L,46005L,46006L,46007L,\n46008L,46009L,46010L,46011L,46012L,46013L,46014L,46015L,46016L,46017L,\n46018L,46019L,46020L,46021L,46022L,46023L,46024L,46025L,46026L,46027L,\n46028L,46029L,46030L,46031L,46032L,46033L,46034L,46035L,46036L,46037L,\n46038L,46039L,46040L,46041L,46042L,46043L,46044L,46045L,46046L,46047L,\n46048L,46049L,46050L,46051L,46052L,46053L,46054L,46055L,46056L,46057L,\n46058L,46059L,46060L,46061L,46062L,46063L,46064L,46065L,46066L,46067L,\n46068L,46069L,46070L,46071L,46072L,46073L,46074L,46075L,46076L,46077L,\n46078L,46079L,46080L,46081L,46082L,46083L,46084L,46085L,46086L,46087L,\n46088L,46089L,46090L,46091L,46092L,46093L,46094L,46095L,46096L,46097L,\n46098L,46099L,46100L,46101L,46102L,46103L,46104L,46105L,46106L,46107L,\n46108L,46109L,46110L,46111L,46112L,46113L,46114L,46115L,46116L,46117L,\n46118L,46119L,46120L,46121L,46122L,46123L,46124L,46125L,46126L,46127L,\n46128L,46129L,46130L,46131L,46132L,46133L,46134L,46135L,46136L,46137L,\n46138L,46139L,46140L,46141L,46142L,46143L,46144L,46145L,46146L,46147L,\n46148L,46149L,46150L,46151L,46152L,46153L,46154L,46155L,46156L,46157L,\n46158L,46159L,46160L,46161L,46162L,46163L,46164L,46165L,46166L,46167L,\n46168L,46169L,46170L,46171L,46172L,46173L,46174L,46175L,46176L,46177L,\n46178L,46179L,46180L,46181L,46182L,46183L,46184L,46185L,46186L,46187L,\n46188L,46189L,46190L,46191L,46192L,46193L,46194L,46195L,46196L,46197L,\n46198L,46199L,46200L,46201L,46202L,46203L,46204L,46205L,46206L,46207L,\n46208L,46209L,46210L,46211L,46212L,46213L,46214L,46215L,46216L,46217L,\n46218L,46219L,46220L,46221L,46222L,46223L,46224L,46225L,46226L,46227L,\n46228L,46229L,46230L,46231L,46232L,46233L,46234L,46235L,46236L,46237L,\n46238L,46239L,46240L,46241L,46242L,46243L,46244L,46245L,46246L,46247L,\n46248L,46249L,46250L,46251L,46252L,46253L,46254L,46255L,46256L,46257L,\n46258L,46259L,46260L,46261L,46262L,46263L,46264L,46265L,46266L,46267L,\n46268L,46269L,46270L,46271L,46272L,46273L,46274L,46275L,46276L,46277L,\n46278L,46279L,46280L,46281L,46282L,46283L,46284L,46285L,46286L,46287L,\n46288L,46289L,46290L,46291L,46292L,46293L,46294L,46295L,46296L,46297L,\n46298L,46299L,46300L,46301L,46302L,46303L,46304L,46305L,46306L,46307L,\n46308L,46309L,46310L,46311L,46312L,46313L,46314L,46315L,46316L,46317L,\n46318L,46319L,46320L,46321L,46322L,46323L,46324L,46325L,46326L,46327L,\n46328L,46329L,46330L,46331L,46332L,46333L,46334L,46335L,46336L,46337L,\n46338L,46339L,46340L,46341L,46342L,46343L,46344L,46345L,46346L,46347L,\n46348L,46349L,46350L,46351L,46352L,46353L,46354L,46355L,46356L,46357L,\n46358L,46359L,46360L,46361L,46362L,46363L,46364L,46365L,46366L,46367L,\n46368L,46369L,46370L,46371L,46372L,46373L,46374L,46375L,46376L,46377L,\n46378L,46379L,46380L,46381L,46382L,46383L,46384L,46385L,46386L,46387L,\n46388L,46389L,46390L,46391L,46392L,46393L,46394L,46395L,46396L,46397L,\n46398L,46399L,46400L,46401L,46402L,46403L,46404L,46405L,46406L,46407L,\n46408L,46409L,46410L,46411L,46412L,46413L,46414L,46415L,46416L,46417L,\n46418L,46419L,46420L,46421L,46422L,46423L,46424L,46425L,46426L,46427L,\n46428L,46429L,46430L,46431L,46432L,46433L,46434L,46435L,46436L,46437L,\n46438L,46439L,46440L,46441L,46442L,46443L,46444L,46445L,46446L,46447L,\n46448L,46449L,46450L,46451L,46452L,46453L,46454L,46455L,46456L,46457L,\n46458L,46459L,46460L,46461L,46462L,46463L,46464L,46465L,46466L,46467L,\n46468L,46469L,46470L,46471L,46472L,46473L,46474L,46475L,46476L,46477L,\n46478L,46479L,46480L,46481L,46482L,46483L,46484L,46485L,46486L,46487L,\n46488L,46489L,46490L,46491L,46492L,46493L,46494L,46495L,46496L,46497L,\n46498L,46499L,46500L,46501L,46502L,46503L,46504L,46505L,46506L,46507L,\n46508L,46509L,46510L,46511L,46512L,46513L,46514L,46515L,46516L,46517L,\n46518L,46519L,46520L,46521L,46522L,46523L,46524L,46525L,46526L,46527L,\n46528L,46529L,46530L,46531L,46532L,46533L,46534L,46535L,46536L,46537L,\n46538L,46539L,46540L,46541L,46542L,46543L,46544L,46545L,46546L,46547L,\n46548L,46549L,46550L,46551L,46552L,46553L,46554L,46555L,46556L,46557L,\n46558L,46559L,46560L,46561L,46562L,46563L,46564L,46565L,46566L,46567L,\n46568L,46569L,46570L,46571L,46572L,46573L,46574L,46575L,46576L,46577L,\n46578L,46579L,46580L,46581L,46582L,46583L,46584L,46585L,46586L,46587L,\n46588L,46589L,46590L,46591L,46592L,46593L,46594L,46595L,46596L,46597L,\n46598L,46599L,46600L,46601L,46602L,46603L,46604L,46605L,46606L,46607L,\n46608L,46609L,46610L,46611L,46612L,46613L,46614L,46615L,46616L,46617L,\n46618L,46619L,46620L,46621L,46622L,46623L,46624L,46625L,46626L,46627L,\n46628L,46629L,46630L,46631L,46632L,46633L,46634L,46635L,46636L,46637L,\n46638L,46639L,46640L,46641L,46642L,46643L,46644L,46645L,46646L,46647L,\n46648L,46649L,46650L,46651L,46652L,46653L,46654L,46655L,46656L,46657L,\n46658L,46659L,46660L,46661L,46662L,46663L,46664L,46665L,46666L,46667L,\n46668L,46669L,46670L,46671L,46672L,46673L,46674L,46675L,46676L,46677L,\n46678L,46679L,46680L,46681L,46682L,46683L,46684L,46685L,46686L,46687L,\n46688L,46689L,46690L,46691L,46692L,46693L,46694L,46695L,46696L,46697L,\n46698L,46699L,46700L,46701L,46702L,46703L,46704L,46705L,46706L,46707L,\n46708L,46709L,46710L,46711L,46712L,46713L,46714L,46715L,46716L,46717L,\n46718L,46719L,46720L,46721L,46722L,46723L,46724L,46725L,46726L,46727L,\n46728L,46729L,46730L,46731L,46732L,46733L,46734L,46735L,46736L,46737L,\n46738L,46739L,46740L,46741L,46742L,46743L,46744L,46745L,46746L,46747L,\n46748L,46749L,46750L,46751L,46752L,46753L,46754L,46755L,46756L,46757L,\n46758L,46759L,46760L,46761L,46762L,46763L,46764L,46765L,46766L,46767L,\n46768L,46769L,46770L,46771L,46772L,46773L,46774L,46775L,46776L,46777L,\n46778L,46779L,46780L,46781L,46782L,46783L,46784L,46785L,46786L,46787L,\n46788L,46789L,46790L,46791L,46792L,46793L,46794L,46795L,46796L,46797L,\n46798L,46799L,46800L,46801L,46802L,46803L,46804L,46805L,46806L,46807L,\n46808L,46809L,46810L,46811L,46812L,46813L,46814L,46815L,46816L,46817L,\n46818L,46819L,46820L,46821L,46822L,46823L,46824L,46825L,46826L,46827L,\n46828L,46829L,46830L,46831L,46832L,46833L,46834L,46835L,46836L,46837L,\n46838L,46839L,46840L,46841L,46842L,46843L,46844L,46845L,46846L,46847L,\n46848L,46849L,46850L,46851L,46852L,46853L,46854L,46855L,46856L,46857L,\n46858L,46859L,46860L,46861L,46862L,46863L,46864L,46865L,46866L,46867L,\n46868L,46869L,46870L,46871L,46872L,46873L,46874L,46875L,46876L,46877L,\n46878L,46879L,46880L,46881L,46882L,46883L,46884L,46885L,46886L,46887L,\n46888L,46889L,46890L,46891L,46892L,46893L,46894L,46895L,46896L,46897L,\n46898L,46899L,46900L,46901L,46902L,46903L,46904L,46905L,46906L,46907L,\n46908L,46909L,46910L,46911L,46912L,46913L,46914L,46915L,46916L,46917L,\n46918L,46919L,46920L,46921L,46922L,46923L,46924L,46925L,46926L,46927L,\n46928L,46929L,46930L,46931L,46932L,46933L,46934L,46935L,46936L,46937L,\n46938L,46939L,46940L,46941L,46942L,46943L,46944L,46945L,46946L,46947L,\n46948L,46949L,46950L,46951L,46952L,46953L,46954L,46955L,46956L,46957L,\n46958L,46959L,46960L,46961L,46962L,46963L,46964L,46965L,46966L,46967L,\n46968L,46969L,46970L,46971L,46972L,46973L,46974L,46975L,46976L,46977L,\n46978L,46979L,46980L,46981L,46982L,46983L,46984L,46985L,46986L,46987L,\n46988L,46989L,46990L,46991L,46992L,46993L,46994L,46995L,46996L,46997L,\n46998L,46999L,47000L,47001L,47002L,47003L,47004L,47005L,47006L,47007L,\n47008L,47009L,47010L,47011L,47012L,47013L,47014L,47015L,47016L,47017L,\n47018L,47019L,47020L,47021L,47022L,47023L,47024L,47025L,47026L,47027L,\n47028L,47029L,47030L,47031L,47032L,47033L,47034L,47035L,47036L,47037L,\n47038L,47039L,47040L,47041L,47042L,47043L,47044L,47045L,47046L,47047L,\n47048L,47049L,47050L,47051L,47052L,47053L,47054L,47055L,47056L,47057L,\n47058L,47059L,47060L,47061L,47062L,47063L,47064L,47065L,47066L,47067L,\n47068L,47069L,47070L,47071L,47072L,47073L,47074L,47075L,47076L,47077L,\n47078L,47079L,47080L,47081L,47082L,47083L,47084L,47085L,47086L,47087L,\n47088L,47089L,47090L,47091L,47092L,47093L,47094L,47095L,47096L,47097L,\n47098L,47099L,47100L,47101L,47102L,47103L,47104L,47105L,47106L,47107L,\n47108L,47109L,47110L,47111L,47112L,47113L,47114L,47115L,47116L,47117L,\n47118L,47119L,47120L,47121L,47122L,47123L,47124L,47125L,47126L,47127L,\n47128L,47129L,47130L,47131L,47132L,47133L,47134L,47135L,47136L,47137L,\n47138L,47139L,47140L,47141L,47142L,47143L,47144L,47145L,47146L,47147L,\n47148L,47149L,47150L,47151L,47152L,47153L,47154L,47155L,47156L,47157L,\n47158L,47159L,47160L,47161L,47162L,47163L,47164L,47165L,47166L,47167L,\n47168L,47169L,47170L,47171L,47172L,47173L,47174L,47175L,47176L,47177L,\n47178L,47179L,47180L,47181L,47182L,47183L,47184L,47185L,47186L,47187L,\n47188L,47189L,47190L,47191L,47192L,47193L,47194L,47195L,47196L,47197L,\n47198L,47199L,47200L,47201L,47202L,47203L,47204L,47205L,47206L,47207L,\n47208L,47209L,47210L,47211L,47212L,47213L,47214L,47215L,47216L,47217L,\n47218L,47219L,47220L,47221L,47222L,47223L,47224L,47225L,47226L,47227L,\n47228L,47229L,47230L,47231L,47232L,47233L,47234L,47235L,47236L,47237L,\n47238L,47239L,47240L,47241L,47242L,47243L,47244L,47245L,47246L,47247L,\n47248L,47249L,47250L,47251L,47252L,47253L,47254L,47255L,47256L,47257L,\n47258L,47259L,47260L,47261L,47262L,47263L,47264L,47265L,47266L,47267L,\n47268L,47269L,47270L,47271L,47272L,47273L,47274L,47275L,47276L,47277L,\n47278L,47279L,47280L,47281L,47282L,47283L,47284L,47285L,47286L,47287L,\n47288L,47289L,47290L,47291L,47292L,47293L,47294L,47295L,47296L,47297L,\n47298L,47299L,47300L,47301L,47302L,47303L,47304L,47305L,47306L,47307L,\n47308L,47309L,47310L,47311L,47312L,47313L,47314L,47315L,47316L,47317L,\n47318L,47319L,47320L,47321L,47322L,47323L,47324L,47325L,47326L,47327L,\n47328L,47329L,47330L,47331L,47332L,47333L,47334L,47335L,47336L,47337L,\n47338L,47339L,47340L,47341L,47342L,47343L,47344L,47345L,47346L,47347L,\n47348L,47349L,47350L,47351L,47352L,47353L,47354L,47355L,47356L,47357L,\n47358L,47359L,47360L,47361L,47362L,47363L,47364L,47365L,47366L,47367L,\n47368L,47369L,47370L,47371L,47372L,47373L,47374L,47375L,47376L,47377L,\n47378L,47379L,47380L,47381L,47382L,47383L,47384L,47385L,47386L,47387L,\n47388L,47389L,47390L,47391L,47392L,47393L,47394L,47395L,47396L,47397L,\n47398L,47399L,47400L,47401L,47402L,47403L,47404L,47405L,47406L,47407L,\n47408L,47409L,47410L,47411L,47412L,47413L,47414L,47415L,47416L,47417L,\n47418L,47419L,47420L,47421L,47422L,47423L,47424L,47425L,47426L,47427L,\n47428L,47429L,47430L,47431L,47432L,47433L,47434L,47435L,47436L,47437L,\n47438L,47439L,47440L,47441L,47442L,47443L,47444L,47445L,47446L,47447L,\n47448L,47449L,47450L,47451L,47452L,47453L,47454L,47455L,47456L,47457L,\n47458L,47459L,47460L,47461L,47462L,47463L,47464L,47465L,47466L,47467L,\n47468L,47469L,47470L,47471L,47472L,47473L,47474L,47475L,47476L,47477L,\n47478L,47479L,47480L,47481L,47482L,47483L,47484L,47485L,47486L,47487L,\n47488L,47489L,47490L,47491L,47492L,47493L,47494L,47495L,47496L,47497L,\n47498L,47499L,47500L,47501L,47502L,47503L,47504L,47505L,47506L,47507L,\n47508L,47509L,47510L,47511L,47512L,47513L,47514L,47515L,47516L,47517L,\n47518L,47519L,47520L,47521L,47522L,47523L,47524L,47525L,47526L,47527L,\n47528L,47529L,47530L,47531L,47532L,47533L,47534L,47535L,47536L,47537L,\n47538L,47539L,47540L,47541L,47542L,47543L,47544L,47545L,47546L,47547L,\n47548L,47549L,47550L,47551L,47552L,47553L,47554L,47555L,47556L,47557L,\n47558L,47559L,47560L,47561L,47562L,47563L,47564L,47565L,47566L,47567L,\n47568L,47569L,47570L,47571L,47572L,47573L,47574L,47575L,47576L,47577L,\n47578L,47579L,47580L,47581L,47582L,47583L,47584L,47585L,47586L,47587L,\n47588L,47589L,47590L,47591L,47592L,47593L,47594L,47595L,47596L,47597L,\n47598L,47599L,47600L,47601L,47602L,47603L,47604L,47605L,47606L,47607L,\n47608L,47609L,47610L,47611L,47612L,47613L,47614L,47615L,47616L,47617L,\n47618L,47619L,47620L,47621L,47622L,47623L,47624L,47625L,47626L,47627L,\n47628L,47629L,47630L,47631L,47632L,47633L,47634L,47635L,47636L,47637L,\n47638L,47639L,47640L,47641L,47642L,47643L,47644L,47645L,47646L,47647L,\n47648L,47649L,47650L,47651L,47652L,47653L,47654L,47655L,47656L,47657L,\n47658L,47659L,47660L,47661L,47662L,47663L,47664L,47665L,47666L,47667L,\n47668L,47669L,47670L,47671L,47672L,47673L,47674L,47675L,47676L,47677L,\n47678L,47679L,47680L,47681L,47682L,47683L,47684L,47685L,47686L,47687L,\n47688L,47689L,47690L,47691L,47692L,47693L,47694L,47695L,47696L,47697L,\n47698L,47699L,47700L,47701L,47702L,47703L,47704L,47705L,47706L,47707L,\n47708L,47709L,47710L,47711L,47712L,47713L,47714L,47715L,47716L,47717L,\n47718L,47719L,47720L,47721L,47722L,47723L,47724L,47725L,47726L,47727L,\n47728L,47729L,47730L,47731L,47732L,47733L,47734L,47735L,47736L,47737L,\n47738L,47739L,47740L,47741L,47742L,47743L,47744L,47745L,47746L,47747L,\n47748L,47749L,47750L,47751L,47752L,47753L,47754L,47755L,47756L,47757L,\n47758L,47759L,47760L,47761L,47762L,47763L,47764L,47765L,47766L,47767L,\n47768L,47769L,47770L,47771L,47772L,47773L,47774L,47775L,47776L,47777L,\n47778L,47779L,47780L,47781L,47782L,47783L,47784L,47785L,47786L,47787L,\n47788L,47789L,47790L,47791L,47792L,47793L,47794L,47795L,47796L,47797L,\n47798L,47799L,47800L,47801L,47802L,47803L,47804L,47805L,47806L,47807L,\n47808L,47809L,47810L,47811L,47812L,47813L,47814L,47815L,47816L,47817L,\n47818L,47819L,47820L,47821L,47822L,47823L,47824L,47825L,47826L,47827L,\n47828L,47829L,47830L,47831L,47832L,47833L,47834L,47835L,47836L,47837L,\n47838L,47839L,47840L,47841L,47842L,47843L,47844L,47845L,47846L,47847L,\n47848L,47849L,47850L,47851L,47852L,47853L,47854L,47855L,47856L,47857L,\n47858L,47859L,47860L,47861L,47862L,47863L,47864L,47865L,47866L,47867L,\n47868L,47869L,47870L,47871L,47872L,47873L,47874L,47875L,47876L,47877L,\n47878L,47879L,47880L,47881L,47882L,47883L,47884L,47885L,47886L,47887L,\n47888L,47889L,47890L,47891L,47892L,47893L,47894L,47895L,47896L,47897L,\n47898L,47899L,47900L,47901L,47902L,47903L,47904L,47905L,47906L,47907L,\n47908L,47909L,47910L,47911L,47912L,47913L,47914L,47915L,47916L,47917L,\n47918L,47919L,47920L,47921L,47922L,47923L,47924L,47925L,47926L,47927L,\n47928L,47929L,47930L,47931L,47932L,47933L,47934L,47935L,47936L,47937L,\n47938L,47939L,47940L,47941L,47942L,47943L,47944L,47945L,47946L,47947L,\n47948L,47949L,47950L,47951L,47952L,47953L,47954L,47955L,47956L,47957L,\n47958L,47959L,47960L,47961L,47962L,47963L,47964L,47965L,47966L,47967L,\n47968L,47969L,47970L,47971L,47972L,47973L,47974L,47975L,47976L,47977L,\n47978L,47979L,47980L,47981L,47982L,47983L,47984L,47985L,47986L,47987L,\n47988L,47989L,47990L,47991L,47992L,47993L,47994L,47995L,47996L,47997L,\n47998L,47999L,48000L,48001L,48002L,48003L,48004L,48005L,48006L,48007L,\n48008L,48009L,48010L,48011L,48012L,48013L,48014L,48015L,48016L,48017L,\n48018L,48019L,48020L,48021L,48022L,48023L,48024L,48025L,48026L,48027L,\n48028L,48029L,48030L,48031L,48032L,48033L,48034L,48035L,48036L,48037L,\n48038L,48039L,48040L,48041L,48042L,48043L,48044L,48045L,48046L,48047L,\n48048L,48049L,48050L,48051L,48052L,48053L,48054L,48055L,48056L,48057L,\n48058L,48059L,48060L,48061L,48062L,48063L,48064L,48065L,48066L,48067L,\n48068L,48069L,48070L,48071L,48072L,48073L,48074L,48075L,48076L,48077L,\n48078L,48079L,48080L,48081L,48082L,48083L,48084L,48085L,48086L,48087L,\n48088L,48089L,48090L,48091L,48092L,48093L,48094L,48095L,48096L,48097L,\n48098L,48099L,48100L,48101L,48102L,48103L,48104L,48105L,48106L,48107L,\n48108L,48109L,48110L,48111L,48112L,48113L,48114L,48115L,48116L,48117L,\n48118L,48119L,48120L,48121L,48122L,48123L,48124L,48125L,48126L,48127L,\n48128L,48129L,48130L,48131L,48132L,48133L,48134L,48135L,48136L,48137L,\n48138L,48139L,48140L,48141L,48142L,48143L,48144L,48145L,48146L,48147L,\n48148L,48149L,48150L,48151L,48152L,48153L,48154L,48155L,48156L,48157L,\n48158L,48159L,48160L,48161L,48162L,48163L,48164L,48165L,48166L,48167L,\n48168L,48169L,48170L,48171L,48172L,48173L,48174L,48175L,48176L,48177L,\n48178L,48179L,48180L,48181L,48182L,48183L,48184L,48185L,48186L,48187L,\n48188L,48189L,48190L,48191L,48192L,48193L,48194L,48195L,48196L,48197L,\n48198L,48199L,48200L,48201L,48202L,48203L,48204L,48205L,48206L,48207L,\n48208L,48209L,48210L,48211L,48212L,48213L,48214L,48215L,48216L,48217L,\n48218L,48219L,48220L,48221L,48222L,48223L,48224L,48225L,48226L,48227L,\n48228L,48229L,48230L,48231L,48232L,48233L,48234L,48235L,48236L,48237L,\n48238L,48239L,48240L,48241L,48242L,48243L,48244L,48245L,48246L,48247L,\n48248L,48249L,48250L,48251L,48252L,48253L,48254L,48255L,48256L,48257L,\n48258L,48259L,48260L,48261L,48262L,48263L,48264L,48265L,48266L,48267L,\n48268L,48269L,48270L,48271L,48272L,48273L,48274L,48275L,48276L,48277L,\n48278L,48279L,48280L,48281L,48282L,48283L,48284L,48285L,48286L,48287L,\n48288L,48289L,48290L,48291L,48292L,48293L,48294L,48295L,48296L,48297L,\n48298L,48299L,48300L,48301L,48302L,48303L,48304L,48305L,48306L,48307L,\n48308L,48309L,48310L,48311L,48312L,48313L,48314L,48315L,48316L,48317L,\n48318L,48319L,48320L,48321L,48322L,48323L,48324L,48325L,48326L,48327L,\n48328L,48329L,48330L,48331L,48332L,48333L,48334L,48335L,48336L,48337L,\n48338L,48339L,48340L,48341L,48342L,48343L,48344L,48345L,48346L,48347L,\n48348L,48349L,48350L,48351L,48352L,48353L,48354L,48355L,48356L,48357L,\n48358L,48359L,48360L,48361L,48362L,48363L,48364L,48365L,48366L,48367L,\n48368L,48369L,48370L,48371L,48372L,48373L,48374L,48375L,48376L,48377L,\n48378L,48379L,48380L,48381L,48382L,48383L,48384L,48385L,48386L,48387L,\n48388L,48389L,48390L,48391L,48392L,48393L,48394L,48395L,48396L,48397L,\n48398L,48399L,48400L,48401L,48402L,48403L,48404L,48405L,48406L,48407L,\n48408L,48409L,48410L,48411L,48412L,48413L,48414L,48415L,48416L,48417L,\n48418L,48419L,48420L,48421L,48422L,48423L,48424L,48425L,48426L,48427L,\n48428L,48429L,48430L,48431L,48432L,48433L,48434L,48435L,48436L,48437L,\n48438L,48439L,48440L,48441L,48442L,48443L,48444L,48445L,48446L,48447L,\n48448L,48449L,48450L,48451L,48452L,48453L,48454L,48455L,48456L,48457L,\n48458L,48459L,48460L,48461L,48462L,48463L,48464L,48465L,48466L,48467L,\n48468L,48469L,48470L,48471L,48472L,48473L,48474L,48475L,48476L,48477L,\n48478L,48479L,48480L,48481L,48482L,48483L,48484L,48485L,48486L,48487L,\n48488L,48489L,48490L,48491L,48492L,48493L,48494L,48495L,48496L,48497L,\n48498L,48499L,48500L,48501L,48502L,48503L,48504L,48505L,48506L,48507L,\n48508L,48509L,48510L,48511L,48512L,48513L,48514L,48515L,48516L,48517L,\n48518L,48519L,48520L,48521L,48522L,48523L,48524L,48525L,48526L,48527L,\n48528L,48529L,48530L,48531L,48532L,48533L,48534L,48535L,48536L,48537L,\n48538L,48539L,48540L,48541L,48542L,48543L,48544L,48545L,48546L,48547L,\n48548L,48549L,48550L,48551L,48552L,48553L,48554L,48555L,48556L,48557L,\n48558L,48559L,48560L,48561L,48562L,48563L,48564L,48565L,48566L,48567L,\n48568L,48569L,48570L,48571L,48572L,48573L,48574L,48575L,48576L,48577L,\n48578L,48579L,48580L,48581L,48582L,48583L,48584L,48585L,48586L,48587L,\n48588L,48589L,48590L,48591L,48592L,48593L,48594L,48595L,48596L,48597L,\n48598L,48599L,48600L,48601L,48602L,48603L,48604L,48605L,48606L,48607L,\n48608L,48609L,48610L,48611L,48612L,48613L,48614L,48615L,48616L,48617L,\n48618L,48619L,48620L,48621L,48622L,48623L,48624L,48625L,48626L,48627L,\n48628L,48629L,48630L,48631L,48632L,48633L,48634L,48635L,48636L,48637L,\n48638L,48639L,48640L,48641L,48642L,48643L,48644L,48645L,48646L,48647L,\n48648L,48649L,48650L,48651L,48652L,48653L,48654L,48655L,48656L,48657L,\n48658L,48659L,48660L,48661L,48662L,48663L,48664L,48665L,48666L,48667L,\n48668L,48669L,48670L,48671L,48672L,48673L,48674L,48675L,48676L,48677L,\n48678L,48679L,48680L,48681L,48682L,48683L,48684L,48685L,48686L,48687L,\n48688L,48689L,48690L,48691L,48692L,48693L,48694L,48695L,48696L,48697L,\n48698L,48699L,48700L,48701L,48702L,48703L,48704L,48705L,48706L,48707L,\n48708L,48709L,48710L,48711L,48712L,48713L,48714L,48715L,48716L,48717L,\n48718L,48719L,48720L,48721L,48722L,48723L,48724L,48725L,48726L,48727L,\n48728L,48729L,48730L,48731L,48732L,48733L,48734L,48735L,48736L,48737L,\n48738L,48739L,48740L,48741L,48742L,48743L,48744L,48745L,48746L,48747L,\n48748L,48749L,48750L,48751L,48752L,48753L,48754L,48755L,48756L,48757L,\n48758L,48759L,48760L,48761L,48762L,48763L,48764L,48765L,48766L,48767L,\n48768L,48769L,48770L,48771L,48772L,48773L,48774L,48775L,48776L,48777L,\n48778L,48779L,48780L,48781L,48782L,48783L,48784L,48785L,48786L,48787L,\n48788L,48789L,48790L,48791L,48792L,48793L,48794L,48795L,48796L,48797L,\n48798L,48799L,48800L,48801L,48802L,48803L,48804L,48805L,48806L,48807L,\n48808L,48809L,48810L,48811L,48812L,48813L,48814L,48815L,48816L,48817L,\n48818L,48819L,48820L,48821L,48822L,48823L,48824L,48825L,48826L,48827L,\n48828L,48829L,48830L,48831L,48832L,48833L,48834L,48835L,48836L,48837L,\n48838L,48839L,48840L,48841L,48842L,48843L,48844L,48845L,48846L,48847L,\n48848L,48849L,48850L,48851L,48852L,48853L,48854L,48855L,48856L,48857L,\n48858L,48859L,48860L,48861L,48862L,48863L,48864L,48865L,48866L,48867L,\n48868L,48869L,48870L,48871L,48872L,48873L,48874L,48875L,48876L,48877L,\n48878L,48879L,48880L,48881L,48882L,48883L,48884L,48885L,48886L,48887L,\n48888L,48889L,48890L,48891L,48892L,48893L,48894L,48895L,48896L,48897L,\n48898L,48899L,48900L,48901L,48902L,48903L,48904L,48905L,48906L,48907L,\n48908L,48909L,48910L,48911L,48912L,48913L,48914L,48915L,48916L,48917L,\n48918L,48919L,48920L,48921L,48922L,48923L,48924L,48925L,48926L,48927L,\n48928L,48929L,48930L,48931L,48932L,48933L,48934L,48935L,48936L,48937L,\n48938L,48939L,48940L,48941L,48942L,48943L,48944L,48945L,48946L,48947L,\n48948L,48949L,48950L,48951L,48952L,48953L,48954L,48955L,48956L,48957L,\n48958L,48959L,48960L,48961L,48962L,48963L,48964L,48965L,48966L,48967L,\n48968L,48969L,48970L,48971L,48972L,48973L,48974L,48975L,48976L,48977L,\n48978L,48979L,48980L,48981L,48982L,48983L,48984L,48985L,48986L,48987L,\n48988L,48989L,48990L,48991L,48992L,48993L,48994L,48995L,48996L,48997L,\n48998L,48999L,49000L,49001L,49002L,49003L,49004L,49005L,49006L,49007L,\n49008L,49009L,49010L,49011L,49012L,49013L,49014L,49015L,49016L,49017L,\n49018L,49019L,49020L,49021L,49022L,49023L,49024L,49025L,49026L,49027L,\n49028L,49029L,49030L,49031L,49032L,49033L,49034L,49035L,49036L,49037L,\n49038L,49039L,49040L,49041L,49042L,49043L,49044L,49045L,49046L,49047L,\n49048L,49049L,49050L,49051L,49052L,49053L,49054L,49055L,49056L,49057L,\n49058L,49059L,49060L,49061L,49062L,49063L,49064L,49065L,49066L,49067L,\n49068L,49069L,49070L,49071L,49072L,49073L,49074L,49075L,49076L,49077L,\n49078L,49079L,49080L,49081L,49082L,49083L,49084L,49085L,49086L,49087L,\n49088L,49089L,49090L,49091L,49092L,49093L,49094L,49095L,49096L,49097L,\n49098L,49099L,49100L,49101L,49102L,49103L,49104L,49105L,49106L,49107L,\n49108L,49109L,49110L,49111L,49112L,49113L,49114L,49115L,49116L,49117L,\n49118L,49119L,49120L,49121L,49122L,49123L,49124L,49125L,49126L,49127L,\n49128L,49129L,49130L,49131L,49132L,49133L,49134L,49135L,49136L,49137L,\n49138L,49139L,49140L,49141L,49142L,49143L,49144L,49145L,49146L,49147L,\n49148L,49149L,49150L,49151L,49152L,49153L,49154L,49155L,49156L,49157L,\n49158L,49159L,49160L,49161L,49162L,49163L,49164L,49165L,49166L,49167L,\n49168L,49169L,49170L,49171L,49172L,49173L,49174L,49175L,49176L,49177L,\n49178L,49179L,49180L,49181L,49182L,49183L,49184L,49185L,49186L,49187L,\n49188L,49189L,49190L,49191L,49192L,49193L,49194L,49195L,49196L,49197L,\n49198L,49199L,49200L,49201L,49202L,49203L,49204L,49205L,49206L,49207L,\n49208L,49209L,49210L,49211L,49212L,49213L,49214L,49215L,49216L,49217L,\n49218L,49219L,49220L,49221L,49222L,49223L,49224L,49225L,49226L,49227L,\n49228L,49229L,49230L,49231L,49232L,49233L,49234L,49235L,49236L,49237L,\n49238L,49239L,49240L,49241L,49242L,49243L,49244L,49245L,49246L,49247L,\n49248L,49249L,49250L,49251L,49252L,49253L,49254L,49255L,49256L,49257L,\n49258L,49259L,49260L,49261L,49262L,49263L,49264L,49265L,49266L,49267L,\n49268L,49269L,49270L,49271L,49272L,49273L,49274L,49275L,49276L,49277L,\n49278L,49279L,49280L,49281L,49282L,49283L,49284L,49285L,49286L,49287L,\n49288L,49289L,49290L,49291L,49292L,49293L,49294L,49295L,49296L,49297L,\n49298L,49299L,49300L,49301L,49302L,49303L,49304L,49305L,49306L,49307L,\n49308L,49309L,49310L,49311L,49312L,49313L,49314L,49315L,49316L,49317L,\n49318L,49319L,49320L,49321L,49322L,49323L,49324L,49325L,49326L,49327L,\n49328L,49329L,49330L,49331L,49332L,49333L,49334L,49335L,49336L,49337L,\n49338L,49339L,49340L,49341L,49342L,49343L,49344L,49345L,49346L,49347L,\n49348L,49349L,49350L,49351L,49352L,49353L,49354L,49355L,49356L,49357L,\n49358L,49359L,49360L,49361L,49362L,49363L,49364L,49365L,49366L,49367L,\n49368L,49369L,49370L,49371L,49372L,49373L,49374L,49375L,49376L,49377L,\n49378L,49379L,49380L,49381L,49382L,49383L,49384L,49385L,49386L,49387L,\n49388L,49389L,49390L,49391L,49392L,49393L,49394L,49395L,49396L,49397L,\n49398L,49399L,49400L,49401L,49402L,49403L,49404L,49405L,49406L,49407L,\n49408L,49409L,49410L,49411L,49412L,49413L,49414L,49415L,49416L,49417L,\n49418L,49419L,49420L,49421L,49422L,49423L,49424L,49425L,49426L,49427L,\n49428L,49429L,49430L,49431L,49432L,49433L,49434L,49435L,49436L,49437L,\n49438L,49439L,49440L,49441L,49442L,49443L,49444L,49445L,49446L,49447L,\n49448L,49449L,49450L,49451L,49452L,49453L,49454L,49455L,49456L,49457L,\n49458L,49459L,49460L,49461L,49462L,49463L,49464L,49465L,49466L,49467L,\n49468L,49469L,49470L,49471L,49472L,49473L,49474L,49475L,49476L,49477L,\n49478L,49479L,49480L,49481L,49482L,49483L,49484L,49485L,49486L,49487L,\n49488L,49489L,49490L,49491L,49492L,49493L,49494L,49495L,49496L,49497L,\n49498L,49499L,49500L,49501L,49502L,49503L,49504L,49505L,49506L,49507L,\n49508L,49509L,49510L,49511L,49512L,49513L,49514L,49515L,49516L,49517L,\n49518L,49519L,49520L,49521L,49522L,49523L,49524L,49525L,49526L,49527L,\n49528L,49529L,49530L,49531L,49532L,49533L,49534L,49535L,49536L,49537L,\n49538L,49539L,49540L,49541L,49542L,49543L,49544L,49545L,49546L,49547L,\n49548L,49549L,49550L,49551L,49552L,49553L,49554L,49555L,49556L,49557L,\n49558L,49559L,49560L,49561L,49562L,49563L,49564L,49565L,49566L,49567L,\n49568L,49569L,49570L,49571L,49572L,49573L,49574L,49575L,49576L,49577L,\n49578L,49579L,49580L,49581L,49582L,49583L,49584L,49585L,49586L,49587L,\n49588L,49589L,49590L,49591L,49592L,49593L,49594L,49595L,49596L,49597L,\n49598L,49599L,49600L,49601L,49602L,49603L,49604L,49605L,49606L,49607L,\n49608L,49609L,49610L,49611L,49612L,49613L,49614L,49615L,49616L,49617L,\n49618L,49619L,49620L,49621L,49622L,49623L,49624L,49625L,49626L,49627L,\n49628L,49629L,49630L,49631L,49632L,49633L,49634L,49635L,49636L,49637L,\n49638L,49639L,49640L,49641L,49642L,49643L,49644L,49645L,49646L,49647L,\n49648L,49649L,49650L,49651L,49652L,49653L,49654L,49655L,49656L,49657L,\n49658L,49659L,49660L,49661L,49662L,49663L,49664L,49665L,49666L,49667L,\n49668L,49669L,49670L,49671L,49672L,49673L,49674L,49675L,49676L,49677L,\n49678L,49679L,49680L,49681L,49682L,49683L,49684L,49685L,49686L,49687L,\n49688L,49689L,49690L,49691L,49692L,49693L,49694L,49695L,49696L,49697L,\n49698L,49699L,49700L,49701L,49702L,49703L,49704L,49705L,49706L,49707L,\n49708L,49709L,49710L,49711L,49712L,49713L,49714L,49715L,49716L,49717L,\n49718L,49719L,49720L,49721L,49722L,49723L,49724L,49725L,49726L,49727L,\n49728L,49729L,49730L,49731L,49732L,49733L,49734L,49735L,49736L,49737L,\n49738L,49739L,49740L,49741L,49742L,49743L,49744L,49745L,49746L,49747L,\n49748L,49749L,49750L,49751L,49752L,49753L,49754L,49755L,49756L,49757L,\n49758L,49759L,49760L,49761L,49762L,49763L,49764L,49765L,49766L,49767L,\n49768L,49769L,49770L,49771L,49772L,49773L,49774L,49775L,49776L,49777L,\n49778L,49779L,49780L,49781L,49782L,49783L,49784L,49785L,49786L,49787L,\n49788L,49789L,49790L,49791L,49792L,49793L,49794L,49795L,49796L,49797L,\n49798L,49799L,49800L,49801L,49802L,49803L,49804L,49805L,49806L,49807L,\n49808L,49809L,49810L,49811L,49812L,49813L,49814L,49815L,49816L,49817L,\n49818L,49819L,49820L,49821L,49822L,49823L,49824L,49825L,49826L,49827L,\n49828L,49829L,49830L,49831L,49832L,49833L,49834L,49835L,49836L,49837L,\n49838L,49839L,49840L,49841L,49842L,49843L,49844L,49845L,49846L,49847L,\n49848L,49849L,49850L,49851L,49852L,49853L,49854L,49855L,49856L,49857L,\n49858L,49859L,49860L,49861L,49862L,49863L,49864L,49865L,49866L,49867L,\n49868L,49869L,49870L,49871L,49872L,49873L,49874L,49875L,49876L,49877L,\n49878L,49879L,49880L,49881L,49882L,49883L,49884L,49885L,49886L,49887L,\n49888L,49889L,49890L,49891L,49892L,49893L,49894L,49895L,49896L,49897L,\n49898L,49899L,49900L,49901L,49902L,49903L,49904L,49905L,49906L,49907L,\n49908L,49909L,49910L,49911L,49912L,49913L,49914L,49915L,49916L,49917L,\n49918L,49919L,49920L,49921L,49922L,49923L,49924L,49925L,49926L,49927L,\n49928L,49929L,49930L,49931L,49932L,49933L,49934L,49935L,49936L,49937L,\n49938L,49939L,49940L,49941L,49942L,49943L,49944L,49945L,49946L,49947L,\n49948L,49949L,49950L,49951L,49952L,49953L,49954L,49955L,49956L,49957L,\n49958L,49959L,49960L,49961L,49962L,49963L,49964L,49965L,49966L,49967L,\n49968L,49969L,49970L,49971L,49972L,49973L,49974L,49975L,49976L,49977L,\n49978L,49979L,49980L,49981L,49982L,49983L,49984L,49985L,49986L,49987L,\n49988L,49989L,49990L,49991L,49992L,49993L,49994L,49995L,49996L,49997L,\n49998L,49999L,50000L,50001L,50002L,50003L,50004L,50005L,50006L,50007L,\n50008L,50009L,50010L,50011L,50012L,50013L,50014L,50015L,50016L,50017L,\n50018L,50019L,50020L,50021L,50022L,50023L,50024L,50025L,50026L,50027L,\n50028L,50029L,50030L,50031L,50032L,50033L,50034L,50035L,50036L,50037L,\n50038L,50039L,50040L,50041L,50042L,50043L,50044L,50045L,50046L,50047L,\n50048L,50049L,50050L,50051L,50052L,50053L,50054L,50055L,50056L,50057L,\n50058L,50059L,50060L,50061L,50062L,50063L,50064L,50065L,50066L,50067L,\n50068L,50069L,50070L,50071L,50072L,50073L,50074L,50075L,50076L,50077L,\n50078L,50079L,50080L,50081L,50082L,50083L,50084L,50085L,50086L,50087L,\n50088L,50089L,50090L,50091L,50092L,50093L,50094L,50095L,50096L,50097L,\n50098L,50099L,50100L,50101L,50102L,50103L,50104L,50105L,50106L,50107L,\n50108L,50109L,50110L,50111L,50112L,50113L,50114L,50115L,50116L,50117L,\n50118L,50119L,50120L,50121L,50122L,50123L,50124L,50125L,50126L,50127L,\n50128L,50129L,50130L,50131L,50132L,50133L,50134L,50135L,50136L,50137L,\n50138L,50139L,50140L,50141L,50142L,50143L,50144L,50145L,50146L,50147L,\n50148L,50149L,50150L,50151L,50152L,50153L,50154L,50155L,50156L,50157L,\n50158L,50159L,50160L,50161L,50162L,50163L,50164L,50165L,50166L,50167L,\n50168L,50169L,50170L,50171L,50172L,50173L,50174L,50175L,50176L,50177L,\n50178L,50179L,50180L,50181L,50182L,50183L,50184L,50185L,50186L,50187L,\n50188L,50189L,50190L,50191L,50192L,50193L,50194L,50195L,50196L,50197L,\n50198L,50199L,50200L,50201L,50202L,50203L,50204L,50205L,50206L,50207L,\n50208L,50209L,50210L,50211L,50212L,50213L,50214L,50215L,50216L,50217L,\n50218L,50219L,50220L,50221L,50222L,50223L,50224L,50225L,50226L,50227L,\n50228L,50229L,50230L,50231L,50232L,50233L,50234L,50235L,50236L,50237L,\n50238L,50239L,50240L,50241L,50242L,50243L,50244L,50245L,50246L,50247L,\n50248L,50249L,50250L,50251L,50252L,50253L,50254L,50255L,50256L,50257L,\n50258L,50259L,50260L,50261L,50262L,50263L,50264L,50265L,50266L,50267L,\n50268L,50269L,50270L,50271L,50272L,50273L,50274L,50275L,50276L,50277L,\n50278L,50279L,50280L,50281L,50282L,50283L,50284L,50285L,50286L,50287L,\n50288L,50289L,50290L,50291L,50292L,50293L,50294L,50295L,50296L,50297L,\n50298L,50299L,50300L,50301L,50302L,50303L,50304L,50305L,50306L,50307L,\n50308L,50309L,50310L,50311L,50312L,50313L,50314L,50315L,50316L,50317L,\n50318L,50319L,50320L,50321L,50322L,50323L,50324L,50325L,50326L,50327L,\n50328L,50329L,50330L,50331L,50332L,50333L,50334L,50335L,50336L,50337L,\n50338L,50339L,50340L,50341L,50342L,50343L,50344L,50345L,50346L,50347L,\n50348L,50349L,50350L,50351L,50352L,50353L,50354L,50355L,50356L,50357L,\n50358L,50359L,50360L,50361L,50362L,50363L,50364L,50365L,50366L,50367L,\n50368L,50369L,50370L,50371L,50372L,50373L,50374L,50375L,50376L,50377L,\n50378L,50379L,50380L,50381L,50382L,50383L,50384L,50385L,50386L,50387L,\n50388L,50389L,50390L,50391L,50392L,50393L,50394L,50395L,50396L,50397L,\n50398L,50399L,50400L,50401L,50402L,50403L,50404L,50405L,50406L,50407L,\n50408L,50409L,50410L,50411L,50412L,50413L,50414L,50415L,50416L,50417L,\n50418L,50419L,50420L,50421L,50422L,50423L,50424L,50425L,50426L,50427L,\n50428L,50429L,50430L,50431L,50432L,50433L,50434L,50435L,50436L,50437L,\n50438L,50439L,50440L,50441L,50442L,50443L,50444L,50445L,50446L,50447L,\n50448L,50449L,50450L,50451L,50452L,50453L,50454L,50455L,50456L,50457L,\n50458L,50459L,50460L,50461L,50462L,50463L,50464L,50465L,50466L,50467L,\n50468L,50469L,50470L,50471L,50472L,50473L,50474L,50475L,50476L,50477L,\n50478L,50479L,50480L,50481L,50482L,50483L,50484L,50485L,50486L,50487L,\n50488L,50489L,50490L,50491L,50492L,50493L,50494L,50495L,50496L,50497L,\n50498L,50499L,50500L,50501L,50502L,50503L,50504L,50505L,50506L,50507L,\n50508L,50509L,50510L,50511L,50512L,50513L,50514L,50515L,50516L,50517L,\n50518L,50519L,50520L,50521L,50522L,50523L,50524L,50525L,50526L,50527L,\n50528L,50529L,50530L,50531L,50532L,50533L,50534L,50535L,50536L,50537L,\n50538L,50539L,50540L,50541L,50542L,50543L,50544L,50545L,50546L,50547L,\n50548L,50549L,50550L,50551L,50552L,50553L,50554L,50555L,50556L,50557L,\n50558L,50559L,50560L,50561L,50562L,50563L,50564L,50565L,50566L,50567L,\n50568L,50569L,50570L,50571L,50572L,50573L,50574L,50575L,50576L,50577L,\n50578L,50579L,50580L,50581L,50582L,50583L,50584L,50585L,50586L,50587L,\n50588L,50589L,50590L,50591L,50592L,50593L,50594L,50595L,50596L,50597L,\n50598L,50599L,50600L,50601L,50602L,50603L,50604L,50605L,50606L,50607L,\n50608L,50609L,50610L,50611L,50612L,50613L,50614L,50615L,50616L,50617L,\n50618L,50619L,50620L,50621L,50622L,50623L,50624L,50625L,50626L,50627L,\n50628L,50629L,50630L,50631L,50632L,50633L,50634L,50635L,50636L,50637L,\n50638L,50639L,50640L,50641L,50642L,50643L,50644L,50645L,50646L,50647L,\n50648L,50649L,50650L,50651L,50652L,50653L,50654L,50655L,50656L,50657L,\n50658L,50659L,50660L,50661L,50662L,50663L,50664L,50665L,50666L,50667L,\n50668L,50669L,50670L,50671L,50672L,50673L,50674L,50675L,50676L,50677L,\n50678L,50679L,50680L,50681L,50682L,50683L,50684L,50685L,50686L,50687L,\n50688L,50689L,50690L,50691L,50692L,50693L,50694L,50695L,50696L,50697L,\n50698L,50699L,50700L,50701L,50702L,50703L,50704L,50705L,50706L,50707L,\n50708L,50709L,50710L,50711L,50712L,50713L,50714L,50715L,50716L,50717L,\n50718L,50719L,50720L,50721L,50722L,50723L,50724L,50725L,50726L,50727L,\n50728L,50729L,50730L,50731L,50732L,50733L,50734L,50735L,50736L,50737L,\n50738L,50739L,50740L,50741L,50742L,50743L,50744L,50745L,50746L,50747L,\n50748L,50749L,50750L,50751L,50752L,50753L,50754L,50755L,50756L,50757L,\n50758L,50759L,50760L,50761L,50762L,50763L,50764L,50765L,50766L,50767L,\n50768L,50769L,50770L,50771L,50772L,50773L,50774L,50775L,50776L,50777L,\n50778L,50779L,50780L,50781L,50782L,50783L,50784L,50785L,50786L,50787L,\n50788L,50789L,50790L,50791L,50792L,50793L,50794L,50795L,50796L,50797L,\n50798L,50799L,50800L,50801L,50802L,50803L,50804L,50805L,50806L,50807L,\n50808L,50809L,50810L,50811L,50812L,50813L,50814L,50815L,50816L,50817L,\n50818L,50819L,50820L,50821L,50822L,50823L,50824L,50825L,50826L,50827L,\n50828L,50829L,50830L,50831L,50832L,50833L,50834L,50835L,50836L,50837L,\n50838L,50839L,50840L,50841L,50842L,50843L,50844L,50845L,50846L,50847L,\n50848L,50849L,50850L,50851L,50852L,50853L,50854L,50855L,50856L,50857L,\n50858L,50859L,50860L,50861L,50862L,50863L,50864L,50865L,50866L,50867L,\n50868L,50869L,50870L,50871L,50872L,50873L,50874L,50875L,50876L,50877L,\n50878L,50879L,50880L,50881L,50882L,50883L,50884L,50885L,50886L,50887L,\n50888L,50889L,50890L,50891L,50892L,50893L,50894L,50895L,50896L,50897L,\n50898L,50899L,50900L,50901L,50902L,50903L,50904L,50905L,50906L,50907L,\n50908L,50909L,50910L,50911L,50912L,50913L,50914L,50915L,50916L,50917L,\n50918L,50919L,50920L,50921L,50922L,50923L,50924L,50925L,50926L,50927L,\n50928L,50929L,50930L,50931L,50932L,50933L,50934L,50935L,50936L,50937L,\n50938L,50939L,50940L,50941L,50942L,50943L,50944L,50945L,50946L,50947L,\n50948L,50949L,50950L,50951L,50952L,50953L,50954L,50955L,50956L,50957L,\n50958L,50959L,50960L,50961L,50962L,50963L,50964L,50965L,50966L,50967L,\n50968L,50969L,50970L,50971L,50972L,50973L,50974L,50975L,50976L,50977L,\n50978L,50979L,50980L,50981L,50982L,50983L,50984L,50985L,50986L,50987L,\n50988L,50989L,50990L,50991L,50992L,50993L,50994L,50995L,50996L,50997L,\n50998L,50999L,51000L,51001L,51002L,51003L,51004L,51005L,51006L,51007L,\n51008L,51009L,51010L,51011L,51012L,51013L,51014L,51015L,51016L,51017L,\n51018L,51019L,51020L,51021L,51022L,51023L,51024L,51025L,51026L,51027L,\n51028L,51029L,51030L,51031L,51032L,51033L,51034L,51035L,51036L,51037L,\n51038L,51039L,51040L,51041L,51042L,51043L,51044L,51045L,51046L,51047L,\n51048L,51049L,51050L,51051L,51052L,51053L,51054L,51055L,51056L,51057L,\n51058L,51059L,51060L,51061L,51062L,51063L,51064L,51065L,51066L,51067L,\n51068L,51069L,51070L,51071L,51072L,51073L,51074L,51075L,51076L,51077L,\n51078L,51079L,51080L,51081L,51082L,51083L,51084L,51085L,51086L,51087L,\n51088L,51089L,51090L,51091L,51092L,51093L,51094L,51095L,51096L,51097L,\n51098L,51099L,51100L,51101L,51102L,51103L,51104L,51105L,51106L,51107L,\n51108L,51109L,51110L,51111L,51112L,51113L,51114L,51115L,51116L,51117L,\n51118L,51119L,51120L,51121L,51122L,51123L,51124L,51125L,51126L,51127L,\n51128L,51129L,51130L,51131L,51132L,51133L,51134L,51135L,51136L,51137L,\n51138L,51139L,51140L,51141L,51142L,51143L,51144L,51145L,51146L,51147L,\n51148L,51149L,51150L,51151L,51152L,51153L,51154L,51155L,51156L,51157L,\n51158L,51159L,51160L,51161L,51162L,51163L,51164L,51165L,51166L,51167L,\n51168L,51169L,51170L,51171L,51172L,51173L,51174L,51175L,51176L,51177L,\n51178L,51179L,51180L,51181L,51182L,51183L,51184L,51185L,51186L,51187L,\n51188L,51189L,51190L,51191L,51192L,51193L,51194L,51195L,51196L,51197L,\n51198L,51199L,51200L,51201L,51202L,51203L,51204L,51205L,51206L,51207L,\n51208L,51209L,51210L,51211L,51212L,51213L,51214L,51215L,51216L,51217L,\n51218L,51219L,51220L,51221L,51222L,51223L,51224L,51225L,51226L,51227L,\n51228L,51229L,51230L,51231L,51232L,51233L,51234L,51235L,51236L,51237L,\n51238L,51239L,51240L,51241L,51242L,51243L,51244L,51245L,51246L,51247L,\n51248L,51249L,51250L,51251L,51252L,51253L,51254L,51255L,51256L,51257L,\n51258L,51259L,51260L,51261L,51262L,51263L,51264L,51265L,51266L,51267L,\n51268L,51269L,51270L,51271L,51272L,51273L,51274L,51275L,51276L,51277L,\n51278L,51279L,51280L,51281L,51282L,51283L,51284L,51285L,51286L,51287L,\n51288L,51289L,51290L,51291L,51292L,51293L,51294L,51295L,51296L,51297L,\n51298L,51299L,51300L,51301L,51302L,51303L,51304L,51305L,51306L,51307L,\n51308L,51309L,51310L,51311L,51312L,51313L,51314L,51315L,51316L,51317L,\n51318L,51319L,51320L,51321L,51322L,51323L,51324L,51325L,51326L,51327L,\n51328L,51329L,51330L,51331L,51332L,51333L,51334L,51335L,51336L,51337L,\n51338L,51339L,51340L,51341L,51342L,51343L,51344L,51345L,51346L,51347L,\n51348L,51349L,51350L,51351L,51352L,51353L,51354L,51355L,51356L,51357L,\n51358L,51359L,51360L,51361L,51362L,51363L,51364L,51365L,51366L,51367L,\n51368L,51369L,51370L,51371L,51372L,51373L,51374L,51375L,51376L,51377L,\n51378L,51379L,51380L,51381L,51382L,51383L,51384L,51385L,51386L,51387L,\n51388L,51389L,51390L,51391L,51392L,51393L,51394L,51395L,51396L,51397L,\n51398L,51399L,51400L,51401L,51402L,51403L,51404L,51405L,51406L,51407L,\n51408L,51409L,51410L,51411L,51412L,51413L,51414L,51415L,51416L,51417L,\n51418L,51419L,51420L,51421L,51422L,51423L,51424L,51425L,51426L,51427L,\n51428L,51429L,51430L,51431L,51432L,51433L,51434L,51435L,51436L,51437L,\n51438L,51439L,51440L,51441L,51442L,51443L,51444L,51445L,51446L,51447L,\n51448L,51449L,51450L,51451L,51452L,51453L,51454L,51455L,51456L,51457L,\n51458L,51459L,51460L,51461L,51462L,51463L,51464L,51465L,51466L,51467L,\n51468L,51469L,51470L,51471L,51472L,51473L,51474L,51475L,51476L,51477L,\n51478L,51479L,51480L,51481L,51482L,51483L,51484L,51485L,51486L,51487L,\n51488L,51489L,51490L,51491L,51492L,51493L,51494L,51495L,51496L,51497L,\n51498L,51499L,51500L,51501L,51502L,51503L,51504L,51505L,51506L,51507L,\n51508L,51509L,51510L,51511L,51512L,51513L,51514L,51515L,51516L,51517L,\n51518L,51519L,51520L,51521L,51522L,51523L,51524L,51525L,51526L,51527L,\n51528L,51529L,51530L,51531L,51532L,51533L,51534L,51535L,51536L,51537L,\n51538L,51539L,51540L,51541L,51542L,51543L,51544L,51545L,51546L,51547L,\n51548L,51549L,51550L,51551L,51552L,51553L,51554L,51555L,51556L,51557L,\n51558L,51559L,51560L,51561L,51562L,51563L,51564L,51565L,51566L,51567L,\n51568L,51569L,51570L,51571L,51572L,51573L,51574L,51575L,51576L,51577L,\n51578L,51579L,51580L,51581L,51582L,51583L,51584L,51585L,51586L,51587L,\n51588L,51589L,51590L,51591L,51592L,51593L,51594L,51595L,51596L,51597L,\n51598L,51599L,51600L,51601L,51602L,51603L,51604L,51605L,51606L,51607L,\n51608L,51609L,51610L,51611L,51612L,51613L,51614L,51615L,51616L,51617L,\n51618L,51619L,51620L,51621L,51622L,51623L,51624L,51625L,51626L,51627L,\n51628L,51629L,51630L,51631L,51632L,51633L,51634L,51635L,51636L,51637L,\n51638L,51639L,51640L,51641L,51642L,51643L,51644L,51645L,51646L,51647L,\n51648L,51649L,51650L,51651L,51652L,51653L,51654L,51655L,51656L,51657L,\n51658L,51659L,51660L,51661L,51662L,51663L,51664L,51665L,51666L,51667L,\n51668L,51669L,51670L,51671L,51672L,51673L,51674L,51675L,51676L,51677L,\n51678L,51679L,51680L,51681L,51682L,51683L,51684L,51685L,51686L,51687L,\n51688L,51689L,51690L,51691L,51692L,51693L,51694L,51695L,51696L,51697L,\n51698L,51699L,51700L,51701L,51702L,51703L,51704L,51705L,51706L,51707L,\n51708L,51709L,51710L,51711L,51712L,51713L,51714L,51715L,51716L,51717L,\n51718L,51719L,51720L,51721L,51722L,51723L,51724L,51725L,51726L,51727L,\n51728L,51729L,51730L,51731L,51732L,51733L,51734L,51735L,51736L,51737L,\n51738L,51739L,51740L,51741L,51742L,51743L,51744L,51745L,51746L,51747L,\n51748L,51749L,51750L,51751L,51752L,51753L,51754L,51755L,51756L,51757L,\n51758L,51759L,51760L,51761L,51762L,51763L,51764L,51765L,51766L,51767L,\n51768L,51769L,51770L,51771L,51772L,51773L,51774L,51775L,51776L,51777L,\n51778L,51779L,51780L,51781L,51782L,51783L,51784L,51785L,51786L,51787L,\n51788L,51789L,51790L,51791L,51792L,51793L,51794L,51795L,51796L,51797L,\n51798L,51799L,51800L,51801L,51802L,51803L,51804L,51805L,51806L,51807L,\n51808L,51809L,51810L,51811L,51812L,51813L,51814L,51815L,51816L,51817L,\n51818L,51819L,51820L,51821L,51822L,51823L,51824L,51825L,51826L,51827L,\n51828L,51829L,51830L,51831L,51832L,51833L,51834L,51835L,51836L,51837L,\n51838L,51839L,51840L,51841L,51842L,51843L,51844L,51845L,51846L,51847L,\n51848L,51849L,51850L,51851L,51852L,51853L,51854L,51855L,51856L,51857L,\n51858L,51859L,51860L,51861L,51862L,51863L,51864L,51865L,51866L,51867L,\n51868L,51869L,51870L,51871L,51872L,51873L,51874L,51875L,51876L,51877L,\n51878L,51879L,51880L,51881L,51882L,51883L,51884L,51885L,51886L,51887L,\n51888L,51889L,51890L,51891L,51892L,51893L,51894L,51895L,51896L,51897L,\n51898L,51899L,51900L,51901L,51902L,51903L,51904L,51905L,51906L,51907L,\n51908L,51909L,51910L,51911L,51912L,51913L,51914L,51915L,51916L,51917L,\n51918L,51919L,51920L,51921L,51922L,51923L,51924L,51925L,51926L,51927L,\n51928L,51929L,51930L,51931L,51932L,51933L,51934L,51935L,51936L,51937L,\n51938L,51939L,51940L,51941L,51942L,51943L,51944L,51945L,51946L,51947L,\n51948L,51949L,51950L,51951L,51952L,51953L,51954L,51955L,51956L,51957L,\n51958L,51959L,51960L,51961L,51962L,51963L,51964L,51965L,51966L,51967L,\n51968L,51969L,51970L,51971L,51972L,51973L,51974L,51975L,51976L,51977L,\n51978L,51979L,51980L,51981L,51982L,51983L,51984L,51985L,51986L,51987L,\n51988L,51989L,51990L,51991L,51992L,51993L,51994L,51995L,51996L,51997L,\n51998L,51999L,52000L,52001L,52002L,52003L,52004L,52005L,52006L,52007L,\n52008L,52009L,52010L,52011L,52012L,52013L,52014L,52015L,52016L,52017L,\n52018L,52019L,52020L,52021L,52022L,52023L,52024L,52025L,52026L,52027L,\n52028L,52029L,52030L,52031L,52032L,52033L,52034L,52035L,52036L,52037L,\n52038L,52039L,52040L,52041L,52042L,52043L,52044L,52045L,52046L,52047L,\n52048L,52049L,52050L,52051L,52052L,52053L,52054L,52055L,52056L,52057L,\n52058L,52059L,52060L,52061L,52062L,52063L,52064L,52065L,52066L,52067L,\n52068L,52069L,52070L,52071L,52072L,52073L,52074L,52075L,52076L,52077L,\n52078L,52079L,52080L,52081L,52082L,52083L,52084L,52085L,52086L,52087L,\n52088L,52089L,52090L,52091L,52092L,52093L,52094L,52095L,52096L,52097L,\n52098L,52099L,52100L,52101L,52102L,52103L,52104L,52105L,52106L,52107L,\n52108L,52109L,52110L,52111L,52112L,52113L,52114L,52115L,52116L,52117L,\n52118L,52119L,52120L,52121L,52122L,52123L,52124L,52125L,52126L,52127L,\n52128L,52129L,52130L,52131L,52132L,52133L,52134L,52135L,52136L,52137L,\n52138L,52139L,52140L,52141L,52142L,52143L,52144L,52145L,52146L,52147L,\n52148L,52149L,52150L,52151L,52152L,52153L,52154L,52155L,52156L,52157L,\n52158L,52159L,52160L,52161L,52162L,52163L,52164L,52165L,52166L,52167L,\n52168L,52169L,52170L,52171L,52172L,52173L,52174L,52175L,52176L,52177L,\n52178L,52179L,52180L,52181L,52182L,52183L,52184L,52185L,52186L,52187L,\n52188L,52189L,52190L,52191L,52192L,52193L,52194L,52195L,52196L,52197L,\n52198L,52199L,52200L,52201L,52202L,52203L,52204L,52205L,52206L,52207L,\n52208L,52209L,52210L,52211L,52212L,52213L,52214L,52215L,52216L,52217L,\n52218L,52219L,52220L,52221L,52222L,52223L,52224L,52225L,52226L,52227L,\n52228L,52229L,52230L,52231L,52232L,52233L,52234L,52235L,52236L,52237L,\n52238L,52239L,52240L,52241L,52242L,52243L,52244L,52245L,52246L,52247L,\n52248L,52249L,52250L,52251L,52252L,52253L,52254L,52255L,52256L,52257L,\n52258L,52259L,52260L,52261L,52262L,52263L,52264L,52265L,52266L,52267L,\n52268L,52269L,52270L,52271L,52272L,52273L,52274L,52275L,52276L,52277L,\n52278L,52279L,52280L,52281L,52282L,52283L,52284L,52285L,52286L,52287L,\n52288L,52289L,52290L,52291L,52292L,52293L,52294L,52295L,52296L,52297L,\n52298L,52299L,52300L,52301L,52302L,52303L,52304L,52305L,52306L,52307L,\n52308L,52309L,52310L,52311L,52312L,52313L,52314L,52315L,52316L,52317L,\n52318L,52319L,52320L,52321L,52322L,52323L,52324L,52325L,52326L,52327L,\n52328L,52329L,52330L,52331L,52332L,52333L,52334L,52335L,52336L,52337L,\n52338L,52339L,52340L,52341L,52342L,52343L,52344L,52345L,52346L,52347L,\n52348L,52349L,52350L,52351L,52352L,52353L,52354L,52355L,52356L,52357L,\n52358L,52359L,52360L,52361L,52362L,52363L,52364L,52365L,52366L,52367L,\n52368L,52369L,52370L,52371L,52372L,52373L,52374L,52375L,52376L,52377L,\n52378L,52379L,52380L,52381L,52382L,52383L,52384L,52385L,52386L,52387L,\n52388L,52389L,52390L,52391L,52392L,52393L,52394L,52395L,52396L,52397L,\n52398L,52399L,52400L,52401L,52402L,52403L,52404L,52405L,52406L,52407L,\n52408L,52409L,52410L,52411L,52412L,52413L,52414L,52415L,52416L,52417L,\n52418L,52419L,52420L,52421L,52422L,52423L,52424L,52425L,52426L,52427L,\n52428L,52429L,52430L,52431L,52432L,52433L,52434L,52435L,52436L,52437L,\n52438L,52439L,52440L,52441L,52442L,52443L,52444L,52445L,52446L,52447L,\n52448L,52449L,52450L,52451L,52452L,52453L,52454L,52455L,52456L,52457L,\n52458L,52459L,52460L,52461L,52462L,52463L,52464L,52465L,52466L,52467L,\n52468L,52469L,52470L,52471L,52472L,52473L,52474L,52475L,52476L,52477L,\n52478L,52479L,52480L,52481L,52482L,52483L,52484L,52485L,52486L,52487L,\n52488L,52489L,52490L,52491L,52492L,52493L,52494L,52495L,52496L,52497L,\n52498L,52499L,52500L,52501L,52502L,52503L,52504L,52505L,52506L,52507L,\n52508L,52509L,52510L,52511L,52512L,52513L,52514L,52515L,52516L,52517L,\n52518L,52519L,52520L,52521L,52522L,52523L,52524L,52525L,52526L,52527L,\n52528L,52529L,52530L,52531L,52532L,52533L,52534L,52535L,52536L,52537L,\n52538L,52539L,52540L,52541L,52542L,52543L,52544L,52545L,52546L,52547L,\n52548L,52549L,52550L,52551L,52552L,52553L,52554L,52555L,52556L,52557L,\n52558L,52559L,52560L,52561L,52562L,52563L,52564L,52565L,52566L,52567L,\n52568L,52569L,52570L,52571L,52572L,52573L,52574L,52575L,52576L,52577L,\n52578L,52579L,52580L,52581L,52582L,52583L,52584L,52585L,52586L,52587L,\n52588L,52589L,52590L,52591L,52592L,52593L,52594L,52595L,52596L,52597L,\n52598L,52599L,52600L,52601L,52602L,52603L,52604L,52605L,52606L,52607L,\n52608L,52609L,52610L,52611L,52612L,52613L,52614L,52615L,52616L,52617L,\n52618L,52619L,52620L,52621L,52622L,52623L,52624L,52625L,52626L,52627L,\n52628L,52629L,52630L,52631L,52632L,52633L,52634L,52635L,52636L,52637L,\n52638L,52639L,52640L,52641L,52642L,52643L,52644L,52645L,52646L,52647L,\n52648L,52649L,52650L,52651L,52652L,52653L,52654L,52655L,52656L,52657L,\n52658L,52659L,52660L,52661L,52662L,52663L,52664L,52665L,52666L,52667L,\n52668L,52669L,52670L,52671L,52672L,52673L,52674L,52675L,52676L,52677L,\n52678L,52679L,52680L,52681L,52682L,52683L,52684L,52685L,52686L,52687L,\n52688L,52689L,52690L,52691L,52692L,52693L,52694L,52695L,52696L,52697L,\n52698L,52699L,52700L,52701L,52702L,52703L,52704L,52705L,52706L,52707L,\n52708L,52709L,52710L,52711L,52712L,52713L,52714L,52715L,52716L,52717L,\n52718L,52719L,52720L,52721L,52722L,52723L,52724L,52725L,52726L,52727L,\n52728L,52729L,52730L,52731L,52732L,52733L,52734L,52735L,52736L,52737L,\n52738L,52739L,52740L,52741L,52742L,52743L,52744L,52745L,52746L,52747L,\n52748L,52749L,52750L,52751L,52752L,52753L,52754L,52755L,52756L,52757L,\n52758L,52759L,52760L,52761L,52762L,52763L,52764L,52765L,52766L,52767L,\n52768L,52769L,52770L,52771L,52772L,52773L,52774L,52775L,52776L,52777L,\n52778L,52779L,52780L,52781L,52782L,52783L,52784L,52785L,52786L,52787L,\n52788L,52789L,52790L,52791L,52792L,52793L,52794L,52795L,52796L,52797L,\n52798L,52799L,52800L,52801L,52802L,52803L,52804L,52805L,52806L,52807L,\n52808L,52809L,52810L,52811L,52812L,52813L,52814L,52815L,52816L,52817L,\n52818L,52819L,52820L,52821L,52822L,52823L,52824L,52825L,52826L,52827L,\n52828L,52829L,52830L,52831L,52832L,52833L,52834L,52835L,52836L,52837L,\n52838L,52839L,52840L,52841L,52842L,52843L,52844L,52845L,52846L,52847L,\n52848L,52849L,52850L,52851L,52852L,52853L,52854L,52855L,52856L,52857L,\n52858L,52859L,52860L,52861L,52862L,52863L,52864L,52865L,52866L,52867L,\n52868L,52869L,52870L,52871L,52872L,52873L,52874L,52875L,52876L,52877L,\n52878L,52879L,52880L,52881L,52882L,52883L,52884L,52885L,52886L,52887L,\n52888L,52889L,52890L,52891L,52892L,52893L,52894L,52895L,52896L,52897L,\n52898L,52899L,52900L,52901L,52902L,52903L,52904L,52905L,52906L,52907L,\n52908L,52909L,52910L,52911L,52912L,52913L,52914L,52915L,52916L,52917L,\n52918L,52919L,52920L,52921L,52922L,52923L,52924L,52925L,52926L,52927L,\n52928L,52929L,52930L,52931L,52932L,52933L,52934L,52935L,52936L,52937L,\n52938L,52939L,52940L,52941L,52942L,52943L,52944L,52945L,52946L,52947L,\n52948L,52949L,52950L,52951L,52952L,52953L,52954L,52955L,52956L,52957L,\n52958L,52959L,52960L,52961L,52962L,52963L,52964L,52965L,52966L,52967L,\n52968L,52969L,52970L,52971L,52972L,52973L,52974L,52975L,52976L,52977L,\n52978L,52979L,52980L,52981L,52982L,52983L,52984L,52985L,52986L,52987L,\n52988L,52989L,52990L,52991L,52992L,52993L,52994L,52995L,52996L,52997L,\n52998L,52999L,53000L,53001L,53002L,53003L,53004L,53005L,53006L,53007L,\n53008L,53009L,53010L,53011L,53012L,53013L,53014L,53015L,53016L,53017L,\n53018L,53019L,53020L,53021L,53022L,53023L,53024L,53025L,53026L,53027L,\n53028L,53029L,53030L,53031L,53032L,53033L,53034L,53035L,53036L,53037L,\n53038L,53039L,53040L,53041L,53042L,53043L,53044L,53045L,53046L,53047L,\n53048L,53049L,53050L,53051L,53052L,53053L,53054L,53055L,53056L,53057L,\n53058L,53059L,53060L,53061L,53062L,53063L,53064L,53065L,53066L,53067L,\n53068L,53069L,53070L,53071L,53072L,53073L,53074L,53075L,53076L,53077L,\n53078L,53079L,53080L,53081L,53082L,53083L,53084L,53085L,53086L,53087L,\n53088L,53089L,53090L,53091L,53092L,53093L,53094L,53095L,53096L,53097L,\n53098L,53099L,53100L,53101L,53102L,53103L,53104L,53105L,53106L,53107L,\n53108L,53109L,53110L,53111L,53112L,53113L,53114L,53115L,53116L,53117L,\n53118L,53119L,53120L,53121L,53122L,53123L,53124L,53125L,53126L,53127L,\n53128L,53129L,53130L,53131L,53132L,53133L,53134L,53135L,53136L,53137L,\n53138L,53139L,53140L,53141L,53142L,53143L,53144L,53145L,53146L,53147L,\n53148L,53149L,53150L,53151L,53152L,53153L,53154L,53155L,53156L,53157L,\n53158L,53159L,53160L,53161L,53162L,53163L,53164L,53165L,53166L,53167L,\n53168L,53169L,53170L,53171L,53172L,53173L,53174L,53175L,53176L,53177L,\n53178L,53179L,53180L,53181L,53182L,53183L,53184L,53185L,53186L,53187L,\n53188L,53189L,53190L,53191L,53192L,53193L,53194L,53195L,53196L,53197L,\n53198L,53199L,53200L,53201L,53202L,53203L,53204L,53205L,53206L,53207L,\n53208L,53209L,53210L,53211L,53212L,53213L,53214L,53215L,53216L,53217L,\n53218L,53219L,53220L,53221L,53222L,53223L,53224L,53225L,53226L,53227L,\n53228L,53229L,53230L,53231L,53232L,53233L,53234L,53235L,53236L,53237L,\n53238L,53239L,53240L,53241L,53242L,53243L,53244L,53245L,53246L,53247L,\n53248L,53249L,53250L,53251L,53252L,53253L,53254L,53255L,53256L,53257L,\n53258L,53259L,53260L,53261L,53262L,53263L,53264L,53265L,53266L,53267L,\n53268L,53269L,53270L,53271L,53272L,53273L,53274L,53275L,53276L,53277L,\n53278L,53279L,53280L,53281L,53282L,53283L,53284L,53285L,53286L,53287L,\n53288L,53289L,53290L,53291L,53292L,53293L,53294L,53295L,53296L,53297L,\n53298L,53299L,53300L,53301L,53302L,53303L,53304L,53305L,53306L,53307L,\n53308L,53309L,53310L,53311L,53312L,53313L,53314L,53315L,53316L,53317L,\n53318L,53319L,53320L,53321L,53322L,53323L,53324L,53325L,53326L,53327L,\n53328L,53329L,53330L,53331L,53332L,53333L,53334L,53335L,53336L,53337L,\n53338L,53339L,53340L,53341L,53342L,53343L,53344L,53345L,53346L,53347L,\n53348L,53349L,53350L,53351L,53352L,53353L,53354L,53355L,53356L,53357L,\n53358L,53359L,53360L,53361L,53362L,53363L,53364L,53365L,53366L,53367L,\n53368L,53369L,53370L,53371L,53372L,53373L,53374L,53375L,53376L,53377L,\n53378L,53379L,53380L,53381L,53382L,53383L,53384L,53385L,53386L,53387L,\n53388L,53389L,53390L,53391L,53392L,53393L,53394L,53395L,53396L,53397L,\n53398L,53399L,53400L,53401L,53402L,53403L,53404L,53405L,53406L,53407L,\n53408L,53409L,53410L,53411L,53412L,53413L,53414L,53415L,53416L,53417L,\n53418L,53419L,53420L,53421L,53422L,53423L,53424L,53425L,53426L,53427L,\n53428L,53429L,53430L,53431L,53432L,53433L,53434L,53435L,53436L,53437L,\n53438L,53439L,53440L,53441L,53442L,53443L,53444L,53445L,53446L,53447L,\n53448L,53449L,53450L,53451L,53452L,53453L,53454L,53455L,53456L,53457L,\n53458L,53459L,53460L,53461L,53462L,53463L,53464L,53465L,53466L,53467L,\n53468L,53469L,53470L,53471L,53472L,53473L,53474L,53475L,53476L,53477L,\n53478L,53479L,53480L,53481L,53482L,53483L,53484L,53485L,53486L,53487L,\n53488L,53489L,53490L,53491L,53492L,53493L,53494L,53495L,53496L,53497L,\n53498L,53499L,53500L,53501L,53502L,53503L,53504L,53505L,53506L,53507L,\n53508L,53509L,53510L,53511L,53512L,53513L,53514L,53515L,53516L,53517L,\n53518L,53519L,53520L,53521L,53522L,53523L,53524L,53525L,53526L,53527L,\n53528L,53529L,53530L,53531L,53532L,53533L,53534L,53535L,53536L,53537L,\n53538L,53539L,53540L,53541L,53542L,53543L,53544L,53545L,53546L,53547L,\n53548L,53549L,53550L,53551L,53552L,53553L,53554L,53555L,53556L,53557L,\n53558L,53559L,53560L,53561L,53562L,53563L,53564L,53565L,53566L,53567L,\n53568L,53569L,53570L,53571L,53572L,53573L,53574L,53575L,53576L,53577L,\n53578L,53579L,53580L,53581L,53582L,53583L,53584L,53585L,53586L,53587L,\n53588L,53589L,53590L,53591L,53592L,53593L,53594L,53595L,53596L,53597L,\n53598L,53599L,53600L,53601L,53602L,53603L,53604L,53605L,53606L,53607L,\n53608L,53609L,53610L,53611L,53612L,53613L,53614L,53615L,53616L,53617L,\n53618L,53619L,53620L,53621L,53622L,53623L,53624L,53625L,53626L,53627L,\n53628L,53629L,53630L,53631L,53632L,53633L,53634L,53635L,53636L,53637L,\n53638L,53639L,53640L,53641L,53642L,53643L,53644L,53645L,53646L,53647L,\n53648L,53649L,53650L,53651L,53652L,53653L,53654L,53655L,53656L,53657L,\n53658L,53659L,53660L,53661L,53662L,53663L,53664L,53665L,53666L,53667L,\n53668L,53669L,53670L,53671L,53672L,53673L,53674L,53675L,53676L,53677L,\n53678L,53679L,53680L,53681L,53682L,53683L,53684L,53685L,53686L,53687L,\n53688L,53689L,53690L,53691L,53692L,53693L,53694L,53695L,53696L,53697L,\n53698L,53699L,53700L,53701L,53702L,53703L,53704L,53705L,53706L,53707L,\n53708L,53709L,53710L,53711L,53712L,53713L,53714L,53715L,53716L,53717L,\n53718L,53719L,53720L,53721L,53722L,53723L,53724L,53725L,53726L,53727L,\n53728L,53729L,53730L,53731L,53732L,53733L,53734L,53735L,53736L,53737L,\n53738L,53739L,53740L,53741L,53742L,53743L,53744L,53745L,53746L,53747L,\n53748L,53749L,53750L,53751L,53752L,53753L,53754L,53755L,53756L,53757L,\n53758L,53759L,53760L,53761L,53762L,53763L,53764L,53765L,53766L,53767L,\n53768L,53769L,53770L,53771L,53772L,53773L,53774L,53775L,53776L,53777L,\n53778L,53779L,53780L,53781L,53782L,53783L,53784L,53785L,53786L,53787L,\n53788L,53789L,53790L,53791L,53792L,53793L,53794L,53795L,53796L,53797L,\n53798L,53799L,53800L,53801L,53802L,53803L,53804L,53805L,53806L,53807L,\n53808L,53809L,53810L,53811L,53812L,53813L,53814L,53815L,53816L,53817L,\n53818L,53819L,53820L,53821L,53822L,53823L,53824L,53825L,53826L,53827L,\n53828L,53829L,53830L,53831L,53832L,53833L,53834L,53835L,53836L,53837L,\n53838L,53839L,53840L,53841L,53842L,53843L,53844L,53845L,53846L,53847L,\n53848L,53849L,53850L,53851L,53852L,53853L,53854L,53855L,53856L,53857L,\n53858L,53859L,53860L,53861L,53862L,53863L,53864L,53865L,53866L,53867L,\n53868L,53869L,53870L,53871L,53872L,53873L,53874L,53875L,53876L,53877L,\n53878L,53879L,53880L,53881L,53882L,53883L,53884L,53885L,53886L,53887L,\n53888L,53889L,53890L,53891L,53892L,53893L,53894L,53895L,53896L,53897L,\n53898L,53899L,53900L,53901L,53902L,53903L,53904L,53905L,53906L,53907L,\n53908L,53909L,53910L,53911L,53912L,53913L,53914L,53915L,53916L,53917L,\n53918L,53919L,53920L,53921L,53922L,53923L,53924L,53925L,53926L,53927L,\n53928L,53929L,53930L,53931L,53932L,53933L,53934L,53935L,53936L,53937L,\n53938L,53939L,53940L,53941L,53942L,53943L,53944L,53945L,53946L,53947L,\n53948L,53949L,53950L,53951L,53952L,53953L,53954L,53955L,53956L,53957L,\n53958L,53959L,53960L,53961L,53962L,53963L,53964L,53965L,53966L,53967L,\n53968L,53969L,53970L,53971L,53972L,53973L,53974L,53975L,53976L,53977L,\n53978L,53979L,53980L,53981L,53982L,53983L,53984L,53985L,53986L,53987L,\n53988L,53989L,53990L,53991L,53992L,53993L,53994L,53995L,53996L,53997L,\n53998L,53999L,54000L,54001L,54002L,54003L,54004L,54005L,54006L,54007L,\n54008L,54009L,54010L,54011L,54012L,54013L,54014L,54015L,54016L,54017L,\n54018L,54019L,54020L,54021L,54022L,54023L,54024L,54025L,54026L,54027L,\n54028L,54029L,54030L,54031L,54032L,54033L,54034L,54035L,54036L,54037L,\n54038L,54039L,54040L,54041L,54042L,54043L,54044L,54045L,54046L,54047L,\n54048L,54049L,54050L,54051L,54052L,54053L,54054L,54055L,54056L,54057L,\n54058L,54059L,54060L,54061L,54062L,54063L,54064L,54065L,54066L,54067L,\n54068L,54069L,54070L,54071L,54072L,54073L,54074L,54075L,54076L,54077L,\n54078L,54079L,54080L,54081L,54082L,54083L,54084L,54085L,54086L,54087L,\n54088L,54089L,54090L,54091L,54092L,54093L,54094L,54095L,54096L,54097L,\n54098L,54099L,54100L,54101L,54102L,54103L,54104L,54105L,54106L,54107L,\n54108L,54109L,54110L,54111L,54112L,54113L,54114L,54115L,54116L,54117L,\n54118L,54119L,54120L,54121L,54122L,54123L,54124L,54125L,54126L,54127L,\n54128L,54129L,54130L,54131L,54132L,54133L,54134L,54135L,54136L,54137L,\n54138L,54139L,54140L,54141L,54142L,54143L,54144L,54145L,54146L,54147L,\n54148L,54149L,54150L,54151L,54152L,54153L,54154L,54155L,54156L,54157L,\n54158L,54159L,54160L,54161L,54162L,54163L,54164L,54165L,54166L,54167L,\n54168L,54169L,54170L,54171L,54172L,54173L,54174L,54175L,54176L,54177L,\n54178L,54179L,54180L,54181L,54182L,54183L,54184L,54185L,54186L,54187L,\n54188L,54189L,54190L,54191L,54192L,54193L,54194L,54195L,54196L,54197L,\n54198L,54199L,54200L,54201L,54202L,54203L,54204L,54205L,54206L,54207L,\n54208L,54209L,54210L,54211L,54212L,54213L,54214L,54215L,54216L,54217L,\n54218L,54219L,54220L,54221L,54222L,54223L,54224L,54225L,54226L,54227L,\n54228L,54229L,54230L,54231L,54232L,54233L,54234L,54235L,54236L,54237L,\n54238L,54239L,54240L,54241L,54242L,54243L,54244L,54245L,54246L,54247L,\n54248L,54249L,54250L,54251L,54252L,54253L,54254L,54255L,54256L,54257L,\n54258L,54259L,54260L,54261L,54262L,54263L,54264L,54265L,54266L,54267L,\n54268L,54269L,54270L,54271L,54272L,54273L,54274L,54275L,54276L,54277L,\n54278L,54279L,54280L,54281L,54282L,54283L,54284L,54285L,54286L,54287L,\n54288L,54289L,54290L,54291L,54292L,54293L,54294L,54295L,54296L,54297L,\n54298L,54299L,54300L,54301L,54302L,54303L,54304L,54305L,54306L,54307L,\n54308L,54309L,54310L,54311L,54312L,54313L,54314L,54315L,54316L,54317L,\n54318L,54319L,54320L,54321L,54322L,54323L,54324L,54325L,54326L,54327L,\n54328L,54329L,54330L,54331L,54332L,54333L,54334L,54335L,54336L,54337L,\n54338L,54339L,54340L,54341L,54342L,54343L,54344L,54345L,54346L,54347L,\n54348L,54349L,54350L,54351L,54352L,54353L,54354L,54355L,54356L,54357L,\n54358L,54359L,54360L,54361L,54362L,54363L,54364L,54365L,54366L,54367L,\n54368L,54369L,54370L,54371L,54372L,54373L,54374L,54375L,54376L,54377L,\n54378L,54379L,54380L,54381L,54382L,54383L,54384L,54385L,54386L,54387L,\n54388L,54389L,54390L,54391L,54392L,54393L,54394L,54395L,54396L,54397L,\n54398L,54399L,54400L,54401L,54402L,54403L,54404L,54405L,54406L,54407L,\n54408L,54409L,54410L,54411L,54412L,54413L,54414L,54415L,54416L,54417L,\n54418L,54419L,54420L,54421L,54422L,54423L,54424L,54425L,54426L,54427L,\n54428L,54429L,54430L,54431L,54432L,54433L,54434L,54435L,54436L,54437L,\n54438L,54439L,54440L,54441L,54442L,54443L,54444L,54445L,54446L,54447L,\n54448L,54449L,54450L,54451L,54452L,54453L,54454L,54455L,54456L,54457L,\n54458L,54459L,54460L,54461L,54462L,54463L,54464L,54465L,54466L,54467L,\n54468L,54469L,54470L,54471L,54472L,54473L,54474L,54475L,54476L,54477L,\n54478L,54479L,54480L,54481L,54482L,54483L,54484L,54485L,54486L,54487L,\n54488L,54489L,54490L,54491L,54492L,54493L,54494L,54495L,54496L,54497L,\n54498L,54499L,54500L,54501L,54502L,54503L,54504L,54505L,54506L,54507L,\n54508L,54509L,54510L,54511L,54512L,54513L,54514L,54515L,54516L,54517L,\n54518L,54519L,54520L,54521L,54522L,54523L,54524L,54525L,54526L,54527L,\n54528L,54529L,54530L,54531L,54532L,54533L,54534L,54535L,54536L,54537L,\n54538L,54539L,54540L,54541L,54542L,54543L,54544L,54545L,54546L,54547L,\n54548L,54549L,54550L,54551L,54552L,54553L,54554L,54555L,54556L,54557L,\n54558L,54559L,54560L,54561L,54562L,54563L,54564L,54565L,54566L,54567L,\n54568L,54569L,54570L,54571L,54572L,54573L,54574L,54575L,54576L,54577L,\n54578L,54579L,54580L,54581L,54582L,54583L,54584L,54585L,54586L,54587L,\n54588L,54589L,54590L,54591L,54592L,54593L,54594L,54595L,54596L,54597L,\n54598L,54599L,54600L,54601L,54602L,54603L,54604L,54605L,54606L,54607L,\n54608L,54609L,54610L,54611L,54612L,54613L,54614L,54615L,54616L,54617L,\n54618L,54619L,54620L,54621L,54622L,54623L,54624L,54625L,54626L,54627L,\n54628L,54629L,54630L,54631L,54632L,54633L,54634L,54635L,54636L,54637L,\n54638L,54639L,54640L,54641L,54642L,54643L,54644L,54645L,54646L,54647L,\n54648L,54649L,54650L,54651L,54652L,54653L,54654L,54655L,54656L,54657L,\n54658L,54659L,54660L,54661L,54662L,54663L,54664L,54665L,54666L,54667L,\n54668L,54669L,54670L,54671L,54672L,54673L,54674L,54675L,54676L,54677L,\n54678L,54679L,54680L,54681L,54682L,54683L,54684L,54685L,54686L,54687L,\n54688L,54689L,54690L,54691L,54692L,54693L,54694L,54695L,54696L,54697L,\n54698L,54699L,54700L,54701L,54702L,54703L,54704L,54705L,54706L,54707L,\n54708L,54709L,54710L,54711L,54712L,54713L,54714L,54715L,54716L,54717L,\n54718L,54719L,54720L,54721L,54722L,54723L,54724L,54725L,54726L,54727L,\n54728L,54729L,54730L,54731L,54732L,54733L,54734L,54735L,54736L,54737L,\n54738L,54739L,54740L,54741L,54742L,54743L,54744L,54745L,54746L,54747L,\n54748L,54749L,54750L,54751L,54752L,54753L,54754L,54755L,54756L,54757L,\n54758L,54759L,54760L,54761L,54762L,54763L,54764L,54765L,54766L,54767L,\n54768L,54769L,54770L,54771L,54772L,54773L,54774L,54775L,54776L,54777L,\n54778L,54779L,54780L,54781L,54782L,54783L,54784L,54785L,54786L,54787L,\n54788L,54789L,54790L,54791L,54792L,54793L,54794L,54795L,54796L,54797L,\n54798L,54799L,54800L,54801L,54802L,54803L,54804L,54805L,54806L,54807L,\n54808L,54809L,54810L,54811L,54812L,54813L,54814L,54815L,54816L,54817L,\n54818L,54819L,54820L,54821L,54822L,54823L,54824L,54825L,54826L,54827L,\n54828L,54829L,54830L,54831L,54832L,54833L,54834L,54835L,54836L,54837L,\n54838L,54839L,54840L,54841L,54842L,54843L,54844L,54845L,54846L,54847L,\n54848L,54849L,54850L,54851L,54852L,54853L,54854L,54855L,54856L,54857L,\n54858L,54859L,54860L,54861L,54862L,54863L,54864L,54865L,54866L,54867L,\n54868L,54869L,54870L,54871L,54872L,54873L,54874L,54875L,54876L,54877L,\n54878L,54879L,54880L,54881L,54882L,54883L,54884L,54885L,54886L,54887L,\n54888L,54889L,54890L,54891L,54892L,54893L,54894L,54895L,54896L,54897L,\n54898L,54899L,54900L,54901L,54902L,54903L,54904L,54905L,54906L,54907L,\n54908L,54909L,54910L,54911L,54912L,54913L,54914L,54915L,54916L,54917L,\n54918L,54919L,54920L,54921L,54922L,54923L,54924L,54925L,54926L,54927L,\n54928L,54929L,54930L,54931L,54932L,54933L,54934L,54935L,54936L,54937L,\n54938L,54939L,54940L,54941L,54942L,54943L,54944L,54945L,54946L,54947L,\n54948L,54949L,54950L,54951L,54952L,54953L,54954L,54955L,54956L,54957L,\n54958L,54959L,54960L,54961L,54962L,54963L,54964L,54965L,54966L,54967L,\n54968L,54969L,54970L,54971L,54972L,54973L,54974L,54975L,54976L,54977L,\n54978L,54979L,54980L,54981L,54982L,54983L,54984L,54985L,54986L,54987L,\n54988L,54989L,54990L,54991L,54992L,54993L,54994L,54995L,54996L,54997L,\n54998L,54999L,55000L,55001L,55002L,55003L,55004L,55005L,55006L,55007L,\n55008L,55009L,55010L,55011L,55012L,55013L,55014L,55015L,55016L,55017L,\n55018L,55019L,55020L,55021L,55022L,55023L,55024L,55025L,55026L,55027L,\n55028L,55029L,55030L,55031L,55032L,55033L,55034L,55035L,55036L,55037L,\n55038L,55039L,55040L,55041L,55042L,55043L,55044L,55045L,55046L,55047L,\n55048L,55049L,55050L,55051L,55052L,55053L,55054L,55055L,55056L,55057L,\n55058L,55059L,55060L,55061L,55062L,55063L,55064L,55065L,55066L,55067L,\n55068L,55069L,55070L,55071L,55072L,55073L,55074L,55075L,55076L,55077L,\n55078L,55079L,55080L,55081L,55082L,55083L,55084L,55085L,55086L,55087L,\n55088L,55089L,55090L,55091L,55092L,55093L,55094L,55095L,55096L,55097L,\n55098L,55099L,55100L,55101L,55102L,55103L,55104L,55105L,55106L,55107L,\n55108L,55109L,55110L,55111L,55112L,55113L,55114L,55115L,55116L,55117L,\n55118L,55119L,55120L,55121L,55122L,55123L,55124L,55125L,55126L,55127L,\n55128L,55129L,55130L,55131L,55132L,55133L,55134L,55135L,55136L,55137L,\n55138L,55139L,55140L,55141L,55142L,55143L,55144L,55145L,55146L,55147L,\n55148L,55149L,55150L,55151L,55152L,55153L,55154L,55155L,55156L,55157L,\n55158L,55159L,55160L,55161L,55162L,55163L,55164L,55165L,55166L,55167L,\n55168L,55169L,55170L,55171L,55172L,55173L,55174L,55175L,55176L,55177L,\n55178L,55179L,55180L,55181L,55182L,55183L,55184L,55185L,55186L,55187L,\n55188L,55189L,55190L,55191L,55192L,55193L,55194L,55195L,55196L,55197L,\n55198L,55199L,55200L,55201L,55202L,55203L,55204L,55205L,55206L,55207L,\n55208L,55209L,55210L,55211L,55212L,55213L,55214L,55215L,55216L,55217L,\n55218L,55219L,55220L,55221L,55222L,55223L,55224L,55225L,55226L,55227L,\n55228L,55229L,55230L,55231L,55232L,55233L,55234L,55235L,55236L,55237L,\n55238L,55239L,55240L,55241L,55242L,55243L,55244L,55245L,55246L,55247L,\n55248L,55249L,55250L,55251L,55252L,55253L,55254L,55255L,55256L,55257L,\n55258L,55259L,55260L,55261L,55262L,55263L,55264L,55265L,55266L,55267L,\n55268L,55269L,55270L,55271L,55272L,55273L,55274L,55275L,55276L,55277L,\n55278L,55279L,55280L,55281L,55282L,55283L,55284L,55285L,55286L,55287L,\n55288L,55289L,55290L,55291L,55292L,55293L,55294L,55295L,55296L,55297L,\n55298L,55299L,55300L,55301L,55302L,55303L,55304L,55305L,55306L,55307L,\n55308L,55309L,55310L,55311L,55312L,55313L,55314L,55315L,55316L,55317L,\n55318L,55319L,55320L,55321L,55322L,55323L,55324L,55325L,55326L,55327L,\n55328L,55329L,55330L,55331L,55332L,55333L,55334L,55335L,55336L,55337L,\n55338L,55339L,55340L,55341L,55342L,55343L,55344L,55345L,55346L,55347L,\n55348L,55349L,55350L,55351L,55352L,55353L,55354L,55355L,55356L,55357L,\n55358L,55359L,55360L,55361L,55362L,55363L,55364L,55365L,55366L,55367L,\n55368L,55369L,55370L,55371L,55372L,55373L,55374L,55375L,55376L,55377L,\n55378L,55379L,55380L,55381L,55382L,55383L,55384L,55385L,55386L,55387L,\n55388L,55389L,55390L,55391L,55392L,55393L,55394L,55395L,55396L,55397L,\n55398L,55399L,55400L,55401L,55402L,55403L,55404L,55405L,55406L,55407L,\n55408L,55409L,55410L,55411L,55412L,55413L,55414L,55415L,55416L,55417L,\n55418L,55419L,55420L,55421L,55422L,55423L,55424L,55425L,55426L,55427L,\n55428L,55429L,55430L,55431L,55432L,55433L,55434L,55435L,55436L,55437L,\n55438L,55439L,55440L,55441L,55442L,55443L,55444L,55445L,55446L,55447L,\n55448L,55449L,55450L,55451L,55452L,55453L,55454L,55455L,55456L,55457L,\n55458L,55459L,55460L,55461L,55462L,55463L,55464L,55465L,55466L,55467L,\n55468L,55469L,55470L,55471L,55472L,55473L,55474L,55475L,55476L,55477L,\n55478L,55479L,55480L,55481L,55482L,55483L,55484L,55485L,55486L,55487L,\n55488L,55489L,55490L,55491L,55492L,55493L,55494L,55495L,55496L,55497L,\n55498L,55499L,55500L,55501L,55502L,55503L,55504L,55505L,55506L,55507L,\n55508L,55509L,55510L,55511L,55512L,55513L,55514L,55515L,55516L,55517L,\n55518L,55519L,55520L,55521L,55522L,55523L,55524L,55525L,55526L,55527L,\n55528L,55529L,55530L,55531L,55532L,55533L,55534L,55535L,55536L,55537L,\n55538L,55539L,55540L,55541L,55542L,55543L,55544L,55545L,55546L,55547L,\n55548L,55549L,55550L,55551L,55552L,55553L,55554L,55555L,55556L,55557L,\n55558L,55559L,55560L,55561L,55562L,55563L,55564L,55565L,55566L,55567L,\n55568L,55569L,55570L,55571L,55572L,55573L,55574L,55575L,55576L,55577L,\n55578L,55579L,55580L,55581L,55582L,55583L,55584L,55585L,55586L,55587L,\n55588L,55589L,55590L,55591L,55592L,55593L,55594L,55595L,55596L,55597L,\n55598L,55599L,55600L,55601L,55602L,55603L,55604L,55605L,55606L,55607L,\n55608L,55609L,55610L,55611L,55612L,55613L,55614L,55615L,55616L,55617L,\n55618L,55619L,55620L,55621L,55622L,55623L,55624L,55625L,55626L,55627L,\n55628L,55629L,55630L,55631L,55632L,55633L,55634L,55635L,55636L,55637L,\n55638L,55639L,55640L,55641L,55642L,55643L,55644L,55645L,55646L,55647L,\n55648L,55649L,55650L,55651L,55652L,55653L,55654L,55655L,55656L,55657L,\n55658L,55659L,55660L,55661L,55662L,55663L,55664L,55665L,55666L,55667L,\n55668L,55669L,55670L,55671L,55672L,55673L,55674L,55675L,55676L,55677L,\n55678L,55679L,55680L,55681L,55682L,55683L,55684L,55685L,55686L,55687L,\n55688L,55689L,55690L,55691L,55692L,55693L,55694L,55695L,55696L,55697L,\n55698L,55699L,55700L,55701L,55702L,55703L,55704L,55705L,55706L,55707L,\n55708L,55709L,55710L,55711L,55712L,55713L,55714L,55715L,55716L,55717L,\n55718L,55719L,55720L,55721L,55722L,55723L,55724L,55725L,55726L,55727L,\n55728L,55729L,55730L,55731L,55732L,55733L,55734L,55735L,55736L,55737L,\n55738L,55739L,55740L,55741L,55742L,55743L,55744L,55745L,55746L,55747L,\n55748L,55749L,55750L,55751L,55752L,55753L,55754L,55755L,55756L,55757L,\n55758L,55759L,55760L,55761L,55762L,55763L,55764L,55765L,55766L,55767L,\n55768L,55769L,55770L,55771L,55772L,55773L,55774L,55775L,55776L,55777L,\n55778L,55779L,55780L,55781L,55782L,55783L,55784L,55785L,55786L,55787L,\n55788L,55789L,55790L,55791L,55792L,55793L,55794L,55795L,55796L,55797L,\n55798L,55799L,55800L,55801L,55802L,55803L,55804L,55805L,55806L,55807L,\n55808L,55809L,55810L,55811L,55812L,55813L,55814L,55815L,55816L,55817L,\n55818L,55819L,55820L,55821L,55822L,55823L,55824L,55825L,55826L,55827L,\n55828L,55829L,55830L,55831L,55832L,55833L,55834L,55835L,55836L,55837L,\n55838L,55839L,55840L,55841L,55842L,55843L,55844L,55845L,55846L,55847L,\n55848L,55849L,55850L,55851L,55852L,55853L,55854L,55855L,55856L,55857L,\n55858L,55859L,55860L,55861L,55862L,55863L,55864L,55865L,55866L,55867L,\n55868L,55869L,55870L,55871L,55872L,55873L,55874L,55875L,55876L,55877L,\n55878L,55879L,55880L,55881L,55882L,55883L,55884L,55885L,55886L,55887L,\n55888L,55889L,55890L,55891L,55892L,55893L,55894L,55895L,55896L,55897L,\n55898L,55899L,55900L,55901L,55902L,55903L,55904L,55905L,55906L,55907L,\n55908L,55909L,55910L,55911L,55912L,55913L,55914L,55915L,55916L,55917L,\n55918L,55919L,55920L,55921L,55922L,55923L,55924L,55925L,55926L,55927L,\n55928L,55929L,55930L,55931L,55932L,55933L,55934L,55935L,55936L,55937L,\n55938L,55939L,55940L,55941L,55942L,55943L,55944L,55945L,55946L,55947L,\n55948L,55949L,55950L,55951L,55952L,55953L,55954L,55955L,55956L,55957L,\n55958L,55959L,55960L,55961L,55962L,55963L,55964L,55965L,55966L,55967L,\n55968L,55969L,55970L,55971L,55972L,55973L,55974L,55975L,55976L,55977L,\n55978L,55979L,55980L,55981L,55982L,55983L,55984L,55985L,55986L,55987L,\n55988L,55989L,55990L,55991L,55992L,55993L,55994L,55995L,55996L,55997L,\n55998L,55999L,56000L,56001L,56002L,56003L,56004L,56005L,56006L,56007L,\n56008L,56009L,56010L,56011L,56012L,56013L,56014L,56015L,56016L,56017L,\n56018L,56019L,56020L,56021L,56022L,56023L,56024L,56025L,56026L,56027L,\n56028L,56029L,56030L,56031L,56032L,56033L,56034L,56035L,56036L,56037L,\n56038L,56039L,56040L,56041L,56042L,56043L,56044L,56045L,56046L,56047L,\n56048L,56049L,56050L,56051L,56052L,56053L,56054L,56055L,56056L,56057L,\n56058L,56059L,56060L,56061L,56062L,56063L,56064L,56065L,56066L,56067L,\n56068L,56069L,56070L,56071L,56072L,56073L,56074L,56075L,56076L,56077L,\n56078L,56079L,56080L,56081L,56082L,56083L,56084L,56085L,56086L,56087L,\n56088L,56089L,56090L,56091L,56092L,56093L,56094L,56095L,56096L,56097L,\n56098L,56099L,56100L,56101L,56102L,56103L,56104L,56105L,56106L,56107L,\n56108L,56109L,56110L,56111L,56112L,56113L,56114L,56115L,56116L,56117L,\n56118L,56119L,56120L,56121L,56122L,56123L,56124L,56125L,56126L,56127L,\n56128L,56129L,56130L,56131L,56132L,56133L,56134L,56135L,56136L,56137L,\n56138L,56139L,56140L,56141L,56142L,56143L,56144L,56145L,56146L,56147L,\n56148L,56149L,56150L,56151L,56152L,56153L,56154L,56155L,56156L,56157L,\n56158L,56159L,56160L,56161L,56162L,56163L,56164L,56165L,56166L,56167L,\n56168L,56169L,56170L,56171L,56172L,56173L,56174L,56175L,56176L,56177L,\n56178L,56179L,56180L,56181L,56182L,56183L,56184L,56185L,56186L,56187L,\n56188L,56189L,56190L,56191L,56192L,56193L,56194L,56195L,56196L,56197L,\n56198L,56199L,56200L,56201L,56202L,56203L,56204L,56205L,56206L,56207L,\n56208L,56209L,56210L,56211L,56212L,56213L,56214L,56215L,56216L,56217L,\n56218L,56219L,56220L,56221L,56222L,56223L,56224L,56225L,56226L,56227L,\n56228L,56229L,56230L,56231L,56232L,56233L,56234L,56235L,56236L,56237L,\n56238L,56239L,56240L,56241L,56242L,56243L,56244L,56245L,56246L,56247L,\n56248L,56249L,56250L,56251L,56252L,56253L,56254L,56255L,56256L,56257L,\n56258L,56259L,56260L,56261L,56262L,56263L,56264L,56265L,56266L,56267L,\n56268L,56269L,56270L,56271L,56272L,56273L,56274L,56275L,56276L,56277L,\n56278L,56279L,56280L,56281L,56282L,56283L,56284L,56285L,56286L,56287L,\n56288L,56289L,56290L,56291L,56292L,56293L,56294L,56295L,56296L,56297L,\n56298L,56299L,56300L,56301L,56302L,56303L,56304L,56305L,56306L,56307L,\n56308L,56309L,56310L,56311L,56312L,56313L,56314L,56315L,56316L,56317L,\n56318L,56319L,56320L,56321L,56322L,56323L,56324L,56325L,56326L,56327L,\n56328L,56329L,56330L,56331L,56332L,56333L,56334L,56335L,56336L,56337L,\n56338L,56339L,56340L,56341L,56342L,56343L,56344L,56345L,56346L,56347L,\n56348L,56349L,56350L,56351L,56352L,56353L,56354L,56355L,56356L,56357L,\n56358L,56359L,56360L,56361L,56362L,56363L,56364L,56365L,56366L,56367L,\n56368L,56369L,56370L,56371L,56372L,56373L,56374L,56375L,56376L,56377L,\n56378L,56379L,56380L,56381L,56382L,56383L,56384L,56385L,56386L,56387L,\n56388L,56389L,56390L,56391L,56392L,56393L,56394L,56395L,56396L,56397L,\n56398L,56399L,56400L,56401L,56402L,56403L,56404L,56405L,56406L,56407L,\n56408L,56409L,56410L,56411L,56412L,56413L,56414L,56415L,56416L,56417L,\n56418L,56419L,56420L,56421L,56422L,56423L,56424L,56425L,56426L,56427L,\n56428L,56429L,56430L,56431L,56432L,56433L,56434L,56435L,56436L,56437L,\n56438L,56439L,56440L,56441L,56442L,56443L,56444L,56445L,56446L,56447L,\n56448L,56449L,56450L,56451L,56452L,56453L,56454L,56455L,56456L,56457L,\n56458L,56459L,56460L,56461L,56462L,56463L,56464L,56465L,56466L,56467L,\n56468L,56469L,56470L,56471L,56472L,56473L,56474L,56475L,56476L,56477L,\n56478L,56479L,56480L,56481L,56482L,56483L,56484L,56485L,56486L,56487L,\n56488L,56489L,56490L,56491L,56492L,56493L,56494L,56495L,56496L,56497L,\n56498L,56499L,56500L,56501L,56502L,56503L,56504L,56505L,56506L,56507L,\n56508L,56509L,56510L,56511L,56512L,56513L,56514L,56515L,56516L,56517L,\n56518L,56519L,56520L,56521L,56522L,56523L,56524L,56525L,56526L,56527L,\n56528L,56529L,56530L,56531L,56532L,56533L,56534L,56535L,56536L,56537L,\n56538L,56539L,56540L,56541L,56542L,56543L,56544L,56545L,56546L,56547L,\n56548L,56549L,56550L,56551L,56552L,56553L,56554L,56555L,56556L,56557L,\n56558L,56559L,56560L,56561L,56562L,56563L,56564L,56565L,56566L,56567L,\n56568L,56569L,56570L,56571L,56572L,56573L,56574L,56575L,56576L,56577L,\n56578L,56579L,56580L,56581L,56582L,56583L,56584L,56585L,56586L,56587L,\n56588L,56589L,56590L,56591L,56592L,56593L,56594L,56595L,56596L,56597L,\n56598L,56599L,56600L,56601L,56602L,56603L,56604L,56605L,56606L,56607L,\n56608L,56609L,56610L,56611L,56612L,56613L,56614L,56615L,56616L,56617L,\n56618L,56619L,56620L,56621L,56622L,56623L,56624L,56625L,56626L,56627L,\n56628L,56629L,56630L,56631L,56632L,56633L,56634L,56635L,56636L,56637L,\n56638L,56639L,56640L,56641L,56642L,56643L,56644L,56645L,56646L,56647L,\n56648L,56649L,56650L,56651L,56652L,56653L,56654L,56655L,56656L,56657L,\n56658L,56659L,56660L,56661L,56662L,56663L,56664L,56665L,56666L,56667L,\n56668L,56669L,56670L,56671L,56672L,56673L,56674L,56675L,56676L,56677L,\n56678L,56679L,56680L,56681L,56682L,56683L,56684L,56685L,56686L,56687L,\n56688L,56689L,56690L,56691L,56692L,56693L,56694L,56695L,56696L,56697L,\n56698L,56699L,56700L,56701L,56702L,56703L,56704L,56705L,56706L,56707L,\n56708L,56709L,56710L,56711L,56712L,56713L,56714L,56715L,56716L,56717L,\n56718L,56719L,56720L,56721L,56722L,56723L,56724L,56725L,56726L,56727L,\n56728L,56729L,56730L,56731L,56732L,56733L,56734L,56735L,56736L,56737L,\n56738L,56739L,56740L,56741L,56742L,56743L,56744L,56745L,56746L,56747L,\n56748L,56749L,56750L,56751L,56752L,56753L,56754L,56755L,56756L,56757L,\n56758L,56759L,56760L,56761L,56762L,56763L,56764L,56765L,56766L,56767L,\n56768L,56769L,56770L,56771L,56772L,56773L,56774L,56775L,56776L,56777L,\n56778L,56779L,56780L,56781L,56782L,56783L,56784L,56785L,56786L,56787L,\n56788L,56789L,56790L,56791L,56792L,56793L,56794L,56795L,56796L,56797L,\n56798L,56799L,56800L,56801L,56802L,56803L,56804L,56805L,56806L,56807L,\n56808L,56809L,56810L,56811L,56812L,56813L,56814L,56815L,56816L,56817L,\n56818L,56819L,56820L,56821L,56822L,56823L,56824L,56825L,56826L,56827L,\n56828L,56829L,56830L,56831L,56832L,56833L,56834L,56835L,56836L,56837L,\n56838L,56839L,56840L,56841L,56842L,56843L,56844L,56845L,56846L,56847L,\n56848L,56849L,56850L,56851L,56852L,56853L,56854L,56855L,56856L,56857L,\n56858L,56859L,56860L,56861L,56862L,56863L,56864L,56865L,56866L,56867L,\n56868L,56869L,56870L,56871L,56872L,56873L,56874L,56875L,56876L,56877L,\n56878L,56879L,56880L,56881L,56882L,56883L,56884L,56885L,56886L,56887L,\n56888L,56889L,56890L,56891L,56892L,56893L,56894L,56895L,56896L,56897L,\n56898L,56899L,56900L,56901L,56902L,56903L,56904L,56905L,56906L,56907L,\n56908L,56909L,56910L,56911L,56912L,56913L,56914L,56915L,56916L,56917L,\n56918L,56919L,56920L,56921L,56922L,56923L,56924L,56925L,56926L,56927L,\n56928L,56929L,56930L,56931L,56932L,56933L,56934L,56935L,56936L,56937L,\n56938L,56939L,56940L,56941L,56942L,56943L,56944L,56945L,56946L,56947L,\n56948L,56949L,56950L,56951L,56952L,56953L,56954L,56955L,56956L,56957L,\n56958L,56959L,56960L,56961L,56962L,56963L,56964L,56965L,56966L,56967L,\n56968L,56969L,56970L,56971L,56972L,56973L,56974L,56975L,56976L,56977L,\n56978L,56979L,56980L,56981L,56982L,56983L,56984L,56985L,56986L,56987L,\n56988L,56989L,56990L,56991L,56992L,56993L,56994L,56995L,56996L,56997L,\n56998L,56999L,57000L,57001L,57002L,57003L,57004L,57005L,57006L,57007L,\n57008L,57009L,57010L,57011L,57012L,57013L,57014L,57015L,57016L,57017L,\n57018L,57019L,57020L,57021L,57022L,57023L,57024L,57025L,57026L,57027L,\n57028L,57029L,57030L,57031L,57032L,57033L,57034L,57035L,57036L,57037L,\n57038L,57039L,57040L,57041L,57042L,57043L,57044L,57045L,57046L,57047L,\n57048L,57049L,57050L,57051L,57052L,57053L,57054L,57055L,57056L,57057L,\n57058L,57059L,57060L,57061L,57062L,57063L,57064L,57065L,57066L,57067L,\n57068L,57069L,57070L,57071L,57072L,57073L,57074L,57075L,57076L,57077L,\n57078L,57079L,57080L,57081L,57082L,57083L,57084L,57085L,57086L,57087L,\n57088L,57089L,57090L,57091L,57092L,57093L,57094L,57095L,57096L,57097L,\n57098L,57099L,57100L,57101L,57102L,57103L,57104L,57105L,57106L,57107L,\n57108L,57109L,57110L,57111L,57112L,57113L,57114L,57115L,57116L,57117L,\n57118L,57119L,57120L,57121L,57122L,57123L,57124L,57125L,57126L,57127L,\n57128L,57129L,57130L,57131L,57132L,57133L,57134L,57135L,57136L,57137L,\n57138L,57139L,57140L,57141L,57142L,57143L,57144L,57145L,57146L,57147L,\n57148L,57149L,57150L,57151L,57152L,57153L,57154L,57155L,57156L,57157L,\n57158L,57159L,57160L,57161L,57162L,57163L,57164L,57165L,57166L,57167L,\n57168L,57169L,57170L,57171L,57172L,57173L,57174L,57175L,57176L,57177L,\n57178L,57179L,57180L,57181L,57182L,57183L,57184L,57185L,57186L,57187L,\n57188L,57189L,57190L,57191L,57192L,57193L,57194L,57195L,57196L,57197L,\n57198L,57199L,57200L,57201L,57202L,57203L,57204L,57205L,57206L,57207L,\n57208L,57209L,57210L,57211L,57212L,57213L,57214L,57215L,57216L,57217L,\n57218L,57219L,57220L,57221L,57222L,57223L,57224L,57225L,57226L,57227L,\n57228L,57229L,57230L,57231L,57232L,57233L,57234L,57235L,57236L,57237L,\n57238L,57239L,57240L,57241L,57242L,57243L,57244L,57245L,57246L,57247L,\n57248L,57249L,57250L,57251L,57252L,57253L,57254L,57255L,57256L,57257L,\n57258L,57259L,57260L,57261L,57262L,57263L,57264L,57265L,57266L,57267L,\n57268L,57269L,57270L,57271L,57272L,57273L,57274L,57275L,57276L,57277L,\n57278L,57279L,57280L,57281L,57282L,57283L,57284L,57285L,57286L,57287L,\n57288L,57289L,57290L,57291L,57292L,57293L,57294L,57295L,57296L,57297L,\n57298L,57299L,57300L,57301L,57302L,57303L,57304L,57305L,57306L,57307L,\n57308L,57309L,57310L,57311L,57312L,57313L,57314L,57315L,57316L,57317L,\n57318L,57319L,57320L,57321L,57322L,57323L,57324L,57325L,57326L,57327L,\n57328L,57329L,57330L,57331L,57332L,57333L,57334L,57335L,57336L,57337L,\n57338L,57339L,57340L,57341L,57342L,57343L,57344L,57345L,57346L,57347L,\n57348L,57349L,57350L,57351L,57352L,57353L,57354L,57355L,57356L,57357L,\n57358L,57359L,57360L,57361L,57362L,57363L,57364L,57365L,57366L,57367L,\n57368L,57369L,57370L,57371L,57372L,57373L,57374L,57375L,57376L,57377L,\n57378L,57379L,57380L,57381L,57382L,57383L,57384L,57385L,57386L,57387L,\n57388L,57389L,57390L,57391L,57392L,57393L,57394L,57395L,57396L,57397L,\n57398L,57399L,57400L,57401L,57402L,57403L,57404L,57405L,57406L,57407L,\n57408L,57409L,57410L,57411L,57412L,57413L,57414L,57415L,57416L,57417L,\n57418L,57419L,57420L,57421L,57422L,57423L,57424L,57425L,57426L,57427L,\n57428L,57429L,57430L,57431L,57432L,57433L,57434L,57435L,57436L,57437L,\n57438L,57439L,57440L,57441L,57442L,57443L,57444L,57445L,57446L,57447L,\n57448L,57449L,57450L,57451L,57452L,57453L,57454L,57455L,57456L,57457L,\n57458L,57459L,57460L,57461L,57462L,57463L,57464L,57465L,57466L,57467L,\n57468L,57469L,57470L,57471L,57472L,57473L,57474L,57475L,57476L,57477L,\n57478L,57479L,57480L,57481L,57482L,57483L,57484L,57485L,57486L,57487L,\n57488L,57489L,57490L,57491L,57492L,57493L,57494L,57495L,57496L,57497L,\n57498L,57499L,57500L,57501L,57502L,57503L,57504L,57505L,57506L,57507L,\n57508L,57509L,57510L,57511L,57512L,57513L,57514L,57515L,57516L,57517L,\n57518L,57519L,57520L,57521L,57522L,57523L,57524L,57525L,57526L,57527L,\n57528L,57529L,57530L,57531L,57532L,57533L,57534L,57535L,57536L,57537L,\n57538L,57539L,57540L,57541L,57542L,57543L,57544L,57545L,57546L,57547L,\n57548L,57549L,57550L,57551L,57552L,57553L,57554L,57555L,57556L,57557L,\n57558L,57559L,57560L,57561L,57562L,57563L,57564L,57565L,57566L,57567L,\n57568L,57569L,57570L,57571L,57572L,57573L,57574L,57575L,57576L,57577L,\n57578L,57579L,57580L,57581L,57582L,57583L,57584L,57585L,57586L,57587L,\n57588L,57589L,57590L,57591L,57592L,57593L,57594L,57595L,57596L,57597L,\n57598L,57599L,57600L,57601L,57602L,57603L,57604L,57605L,57606L,57607L,\n57608L,57609L,57610L,57611L,57612L,57613L,57614L,57615L,57616L,57617L,\n57618L,57619L,57620L,57621L,57622L,57623L,57624L,57625L,57626L,57627L,\n57628L,57629L,57630L,57631L,57632L,57633L,57634L,57635L,57636L,57637L,\n57638L,57639L,57640L,57641L,57642L,57643L,57644L,57645L,57646L,57647L,\n57648L,57649L,57650L,57651L,57652L,57653L,57654L,57655L,57656L,57657L,\n57658L,57659L,57660L,57661L,57662L,57663L,57664L,57665L,57666L,57667L,\n57668L,57669L,57670L,57671L,57672L,57673L,57674L,57675L,57676L,57677L,\n57678L,57679L,57680L,57681L,57682L,57683L,57684L,57685L,57686L,57687L,\n57688L,57689L,57690L,57691L,57692L,57693L,57694L,57695L,57696L,57697L,\n57698L,57699L,57700L,57701L,57702L,57703L,57704L,57705L,57706L,57707L,\n57708L,57709L,57710L,57711L,57712L,57713L,57714L,57715L,57716L,57717L,\n57718L,57719L,57720L,57721L,57722L,57723L,57724L,57725L,57726L,57727L,\n57728L,57729L,57730L,57731L,57732L,57733L,57734L,57735L,57736L,57737L,\n57738L,57739L,57740L,57741L,57742L,57743L,57744L,57745L,57746L,57747L,\n57748L,57749L,57750L,57751L,57752L,57753L,57754L,57755L,57756L,57757L,\n57758L,57759L,57760L,57761L,57762L,57763L,57764L,57765L,57766L,57767L,\n57768L,57769L,57770L,57771L,57772L,57773L,57774L,57775L,57776L,57777L,\n57778L,57779L,57780L,57781L,57782L,57783L,57784L,57785L,57786L,57787L,\n57788L,57789L,57790L,57791L,57792L,57793L,57794L,57795L,57796L,57797L,\n57798L,57799L,57800L,57801L,57802L,57803L,57804L,57805L,57806L,57807L,\n57808L,57809L,57810L,57811L,57812L,57813L,57814L,57815L,57816L,57817L,\n57818L,57819L,57820L,57821L,57822L,57823L,57824L,57825L,57826L,57827L,\n57828L,57829L,57830L,57831L,57832L,57833L,57834L,57835L,57836L,57837L,\n57838L,57839L,57840L,57841L,57842L,57843L,57844L,57845L,57846L,57847L,\n57848L,57849L,57850L,57851L,57852L,57853L,57854L,57855L,57856L,57857L,\n57858L,57859L,57860L,57861L,57862L,57863L,57864L,57865L,57866L,57867L,\n57868L,57869L,57870L,57871L,57872L,57873L,57874L,57875L,57876L,57877L,\n57878L,57879L,57880L,57881L,57882L,57883L,57884L,57885L,57886L,57887L,\n57888L,57889L,57890L,57891L,57892L,57893L,57894L,57895L,57896L,57897L,\n57898L,57899L,57900L,57901L,57902L,57903L,57904L,57905L,57906L,57907L,\n57908L,57909L,57910L,57911L,57912L,57913L,57914L,57915L,57916L,57917L,\n57918L,57919L,57920L,57921L,57922L,57923L,57924L,57925L,57926L,57927L,\n57928L,57929L,57930L,57931L,57932L,57933L,57934L,57935L,57936L,57937L,\n57938L,57939L,57940L,57941L,57942L,57943L,57944L,57945L,57946L,57947L,\n57948L,57949L,57950L,57951L,57952L,57953L,57954L,57955L,57956L,57957L,\n57958L,57959L,57960L,57961L,57962L,57963L,57964L,57965L,57966L,57967L,\n57968L,57969L,57970L,57971L,57972L,57973L,57974L,57975L,57976L,57977L,\n57978L,57979L,57980L,57981L,57982L,57983L,57984L,57985L,57986L,57987L,\n57988L,57989L,57990L,57991L,57992L,57993L,57994L,57995L,57996L,57997L,\n57998L,57999L,58000L,58001L,58002L,58003L,58004L,58005L,58006L,58007L,\n58008L,58009L,58010L,58011L,58012L,58013L,58014L,58015L,58016L,58017L,\n58018L,58019L,58020L,58021L,58022L,58023L,58024L,58025L,58026L,58027L,\n58028L,58029L,58030L,58031L,58032L,58033L,58034L,58035L,58036L,58037L,\n58038L,58039L,58040L,58041L,58042L,58043L,58044L,58045L,58046L,58047L,\n58048L,58049L,58050L,58051L,58052L,58053L,58054L,58055L,58056L,58057L,\n58058L,58059L,58060L,58061L,58062L,58063L,58064L,58065L,58066L,58067L,\n58068L,58069L,58070L,58071L,58072L,58073L,58074L,58075L,58076L,58077L,\n58078L,58079L,58080L,58081L,58082L,58083L,58084L,58085L,58086L,58087L,\n58088L,58089L,58090L,58091L,58092L,58093L,58094L,58095L,58096L,58097L,\n58098L,58099L,58100L,58101L,58102L,58103L,58104L,58105L,58106L,58107L,\n58108L,58109L,58110L,58111L,58112L,58113L,58114L,58115L,58116L,58117L,\n58118L,58119L,58120L,58121L,58122L,58123L,58124L,58125L,58126L,58127L,\n58128L,58129L,58130L,58131L,58132L,58133L,58134L,58135L,58136L,58137L,\n58138L,58139L,58140L,58141L,58142L,58143L,58144L,58145L,58146L,58147L,\n58148L,58149L,58150L,58151L,58152L,58153L,58154L,58155L,58156L,58157L,\n58158L,58159L,58160L,58161L,58162L,58163L,58164L,58165L,58166L,58167L,\n58168L,58169L,58170L,58171L,58172L,58173L,58174L,58175L,58176L,58177L,\n58178L,58179L,58180L,58181L,58182L,58183L,58184L,58185L,58186L,58187L,\n58188L,58189L,58190L,58191L,58192L,58193L,58194L,58195L,58196L,58197L,\n58198L,58199L,58200L,58201L,58202L,58203L,58204L,58205L,58206L,58207L,\n58208L,58209L,58210L,58211L,58212L,58213L,58214L,58215L,58216L,58217L,\n58218L,58219L,58220L,58221L,58222L,58223L,58224L,58225L,58226L,58227L,\n58228L,58229L,58230L,58231L,58232L,58233L,58234L,58235L,58236L,58237L,\n58238L,58239L,58240L,58241L,58242L,58243L,58244L,58245L,58246L,58247L,\n58248L,58249L,58250L,58251L,58252L,58253L,58254L,58255L,58256L,58257L,\n58258L,58259L,58260L,58261L,58262L,58263L,58264L,58265L,58266L,58267L,\n58268L,58269L,58270L,58271L,58272L,58273L,58274L,58275L,58276L,58277L,\n58278L,58279L,58280L,58281L,58282L,58283L,58284L,58285L,58286L,58287L,\n58288L,58289L,58290L,58291L,58292L,58293L,58294L,58295L,58296L,58297L,\n58298L,58299L,58300L,58301L,58302L,58303L,58304L,58305L,58306L,58307L,\n58308L,58309L,58310L,58311L,58312L,58313L,58314L,58315L,58316L,58317L,\n58318L,58319L,58320L,58321L,58322L,58323L,58324L,58325L,58326L,58327L,\n58328L,58329L,58330L,58331L,58332L,58333L,58334L,58335L,58336L,58337L,\n58338L,58339L,58340L,58341L,58342L,58343L,58344L,58345L,58346L,58347L,\n58348L,58349L,58350L,58351L,58352L,58353L,58354L,58355L,58356L,58357L,\n58358L,58359L,58360L,58361L,58362L,58363L,58364L,58365L,58366L,58367L,\n58368L,58369L,58370L,58371L,58372L,58373L,58374L,58375L,58376L,58377L,\n58378L,58379L,58380L,58381L,58382L,58383L,58384L,58385L,58386L,58387L,\n58388L,58389L,58390L,58391L,58392L,58393L,58394L,58395L,58396L,58397L,\n58398L,58399L,58400L,58401L,58402L,58403L,58404L,58405L,58406L,58407L,\n58408L,58409L,58410L,58411L,58412L,58413L,58414L,58415L,58416L,58417L,\n58418L,58419L,58420L,58421L,58422L,58423L,58424L,58425L,58426L,58427L,\n58428L,58429L,58430L,58431L,58432L,58433L,58434L,58435L,58436L,58437L,\n58438L,58439L,58440L,58441L,58442L,58443L,58444L,58445L,58446L,58447L,\n58448L,58449L,58450L,58451L,58452L,58453L,58454L,58455L,58456L,58457L,\n58458L,58459L,58460L,58461L,58462L,58463L,58464L,58465L,58466L,58467L,\n58468L,58469L,58470L,58471L,58472L,58473L,58474L,58475L,58476L,58477L,\n58478L,58479L,58480L,58481L,58482L,58483L,58484L,58485L,58486L,58487L,\n58488L,58489L,58490L,58491L,58492L,58493L,58494L,58495L,58496L,58497L,\n58498L,58499L,58500L,58501L,58502L,58503L,58504L,58505L,58506L,58507L,\n58508L,58509L,58510L,58511L,58512L,58513L,58514L,58515L,58516L,58517L,\n58518L,58519L,58520L,58521L,58522L,58523L,58524L,58525L,58526L,58527L,\n58528L,58529L,58530L,58531L,58532L,58533L,58534L,58535L,58536L,58537L,\n58538L,58539L,58540L,58541L,58542L,58543L,58544L,58545L,58546L,58547L,\n58548L,58549L,58550L,58551L,58552L,58553L,58554L,58555L,58556L,58557L,\n58558L,58559L,58560L,58561L,58562L,58563L,58564L,58565L,58566L,58567L,\n58568L,58569L,58570L,58571L,58572L,58573L,58574L,58575L,58576L,58577L,\n58578L,58579L,58580L,58581L,58582L,58583L,58584L,58585L,58586L,58587L,\n58588L,58589L,58590L,58591L,58592L,58593L,58594L,58595L,58596L,58597L,\n58598L,58599L,58600L,58601L,58602L,58603L,58604L,58605L,58606L,58607L,\n58608L,58609L,58610L,58611L,58612L,58613L,58614L,58615L,58616L,58617L,\n58618L,58619L,58620L,58621L,58622L,58623L,58624L,58625L,58626L,58627L,\n58628L,58629L,58630L,58631L,58632L,58633L,58634L,58635L,58636L,58637L,\n58638L,58639L,58640L,58641L,58642L,58643L,58644L,58645L,58646L,58647L,\n58648L,58649L,58650L,58651L,58652L,58653L,58654L,58655L,58656L,58657L,\n58658L,58659L,58660L,58661L,58662L,58663L,58664L,58665L,58666L,58667L,\n58668L,58669L,58670L,58671L,58672L,58673L,58674L,58675L,58676L,58677L,\n58678L,58679L,58680L,58681L,58682L,58683L,58684L,58685L,58686L,58687L,\n58688L,58689L,58690L,58691L,58692L,58693L,58694L,58695L,58696L,58697L,\n58698L,58699L,58700L,58701L,58702L,58703L,58704L,58705L,58706L,58707L,\n58708L,58709L,58710L,58711L,58712L,58713L,58714L,58715L,58716L,58717L,\n58718L,58719L,58720L,58721L,58722L,58723L,58724L,58725L,58726L,58727L,\n58728L,58729L,58730L,58731L,58732L,58733L,58734L,58735L,58736L,58737L,\n58738L,58739L,58740L,58741L,58742L,58743L,58744L,58745L,58746L,58747L,\n58748L,58749L,58750L,58751L,58752L,58753L,58754L,58755L,58756L,58757L,\n58758L,58759L,58760L,58761L,58762L,58763L,58764L,58765L,58766L,58767L,\n58768L,58769L,58770L,58771L,58772L,58773L,58774L,58775L,58776L,58777L,\n58778L,58779L,58780L,58781L,58782L,58783L,58784L,58785L,58786L,58787L,\n58788L,58789L,58790L,58791L,58792L,58793L,58794L,58795L,58796L,58797L,\n58798L,58799L,58800L,58801L,58802L,58803L,58804L,58805L,58806L,58807L,\n58808L,58809L,58810L,58811L,58812L,58813L,58814L,58815L,58816L,58817L,\n58818L,58819L,58820L,58821L,58822L,58823L,58824L,58825L,58826L,58827L,\n58828L,58829L,58830L,58831L,58832L,58833L,58834L,58835L,58836L,58837L,\n58838L,58839L,58840L,58841L,58842L,58843L,58844L,58845L,58846L,58847L,\n58848L,58849L,58850L,58851L,58852L,58853L,58854L,58855L,58856L,58857L,\n58858L,58859L,58860L,58861L,58862L,58863L,58864L,58865L,58866L,58867L,\n58868L,58869L,58870L,58871L,58872L,58873L,58874L,58875L,58876L,58877L,\n58878L,58879L,58880L,58881L,58882L,58883L,58884L,58885L,58886L,58887L,\n58888L,58889L,58890L,58891L,58892L,58893L,58894L,58895L,58896L,58897L,\n58898L,58899L,58900L,58901L,58902L,58903L,58904L,58905L,58906L,58907L,\n58908L,58909L,58910L,58911L,58912L,58913L,58914L,58915L,58916L,58917L,\n58918L,58919L,58920L,58921L,58922L,58923L,58924L,58925L,58926L,58927L,\n58928L,58929L,58930L,58931L,58932L,58933L,58934L,58935L,58936L,58937L,\n58938L,58939L,58940L,58941L,58942L,58943L,58944L,58945L,58946L,58947L,\n58948L,58949L,58950L,58951L,58952L,58953L,58954L,58955L,58956L,58957L,\n58958L,58959L,58960L,58961L,58962L,58963L,58964L,58965L,58966L,58967L,\n58968L,58969L,58970L,58971L,58972L,58973L,58974L,58975L,58976L,58977L,\n58978L,58979L,58980L,58981L,58982L,58983L,58984L,58985L,58986L,58987L,\n58988L,58989L,58990L,58991L,58992L,58993L,58994L,58995L,58996L,58997L,\n58998L,58999L,59000L,59001L,59002L,59003L,59004L,59005L,59006L,59007L,\n59008L,59009L,59010L,59011L,59012L,59013L,59014L,59015L,59016L,59017L,\n59018L,59019L,59020L,59021L,59022L,59023L,59024L,59025L,59026L,59027L,\n59028L,59029L,59030L,59031L,59032L,59033L,59034L,59035L,59036L,59037L,\n59038L,59039L,59040L,59041L,59042L,59043L,59044L,59045L,59046L,59047L,\n59048L,59049L,59050L,59051L,59052L,59053L,59054L,59055L,59056L,59057L,\n59058L,59059L,59060L,59061L,59062L,59063L,59064L,59065L,59066L,59067L,\n59068L,59069L,59070L,59071L,59072L,59073L,59074L,59075L,59076L,59077L,\n59078L,59079L,59080L,59081L,59082L,59083L,59084L,59085L,59086L,59087L,\n59088L,59089L,59090L,59091L,59092L,59093L,59094L,59095L,59096L,59097L,\n59098L,59099L,59100L,59101L,59102L,59103L,59104L,59105L,59106L,59107L,\n59108L,59109L,59110L,59111L,59112L,59113L,59114L,59115L,59116L,59117L,\n59118L,59119L,59120L,59121L,59122L,59123L,59124L,59125L,59126L,59127L,\n59128L,59129L,59130L,59131L,59132L,59133L,59134L,59135L,59136L,59137L,\n59138L,59139L,59140L,59141L,59142L,59143L,59144L,59145L,59146L,59147L,\n59148L,59149L,59150L,59151L,59152L,59153L,59154L,59155L,59156L,59157L,\n59158L,59159L,59160L,59161L,59162L,59163L,59164L,59165L,59166L,59167L,\n59168L,59169L,59170L,59171L,59172L,59173L,59174L,59175L,59176L,59177L,\n59178L,59179L,59180L,59181L,59182L,59183L,59184L,59185L,59186L,59187L,\n59188L,59189L,59190L,59191L,59192L,59193L,59194L,59195L,59196L,59197L,\n59198L,59199L,59200L,59201L,59202L,59203L,59204L,59205L,59206L,59207L,\n59208L,59209L,59210L,59211L,59212L,59213L,59214L,59215L,59216L,59217L,\n59218L,59219L,59220L,59221L,59222L,59223L,59224L,59225L,59226L,59227L,\n59228L,59229L,59230L,59231L,59232L,59233L,59234L,59235L,59236L,59237L,\n59238L,59239L,59240L,59241L,59242L,59243L,59244L,59245L,59246L,59247L,\n59248L,59249L,59250L,59251L,59252L,59253L,59254L,59255L,59256L,59257L,\n59258L,59259L,59260L,59261L,59262L,59263L,59264L,59265L,59266L,59267L,\n59268L,59269L,59270L,59271L,59272L,59273L,59274L,59275L,59276L,59277L,\n59278L,59279L,59280L,59281L,59282L,59283L,59284L,59285L,59286L,59287L,\n59288L,59289L,59290L,59291L,59292L,59293L,59294L,59295L,59296L,59297L,\n59298L,59299L,59300L,59301L,59302L,59303L,59304L,59305L,59306L,59307L,\n59308L,59309L,59310L,59311L,59312L,59313L,59314L,59315L,59316L,59317L,\n59318L,59319L,59320L,59321L,59322L,59323L,59324L,59325L,59326L,59327L,\n59328L,59329L,59330L,59331L,59332L,59333L,59334L,59335L,59336L,59337L,\n59338L,59339L,59340L,59341L,59342L,59343L,59344L,59345L,59346L,59347L,\n59348L,59349L,59350L,59351L,59352L,59353L,59354L,59355L,59356L,59357L,\n59358L,59359L,59360L,59361L,59362L,59363L,59364L,59365L,59366L,59367L,\n59368L,59369L,59370L,59371L,59372L,59373L,59374L,59375L,59376L,59377L,\n59378L,59379L,59380L,59381L,59382L,59383L,59384L,59385L,59386L,59387L,\n59388L,59389L,59390L,59391L,59392L,59393L,59394L,59395L,59396L,59397L,\n59398L,59399L,59400L,59401L,59402L,59403L,59404L,59405L,59406L,59407L,\n59408L,59409L,59410L,59411L,59412L,59413L,59414L,59415L,59416L,59417L,\n59418L,59419L,59420L,59421L,59422L,59423L,59424L,59425L,59426L,59427L,\n59428L,59429L,59430L,59431L,59432L,59433L,59434L,59435L,59436L,59437L,\n59438L,59439L,59440L,59441L,59442L,59443L,59444L,59445L,59446L,59447L,\n59448L,59449L,59450L,59451L,59452L,59453L,59454L,59455L,59456L,59457L,\n59458L,59459L,59460L,59461L,59462L,59463L,59464L,59465L,59466L,59467L,\n59468L,59469L,59470L,59471L,59472L,59473L,59474L,59475L,59476L,59477L,\n59478L,59479L,59480L,59481L,59482L,59483L,59484L,59485L,59486L,59487L,\n59488L,59489L,59490L,59491L,59492L,59493L,59494L,59495L,59496L,59497L,\n59498L,59499L,59500L,59501L,59502L,59503L,59504L,59505L,59506L,59507L,\n59508L,59509L,59510L,59511L,59512L,59513L,59514L,59515L,59516L,59517L,\n59518L,59519L,59520L,59521L,59522L,59523L,59524L,59525L,59526L,59527L,\n59528L,59529L,59530L,59531L,59532L,59533L,59534L,59535L,59536L,59537L,\n59538L,59539L,59540L,59541L,59542L,59543L,59544L,59545L,59546L,59547L,\n59548L,59549L,59550L,59551L,59552L,59553L,59554L,59555L,59556L,59557L,\n59558L,59559L,59560L,59561L,59562L,59563L,59564L,59565L,59566L,59567L,\n59568L,59569L,59570L,59571L,59572L,59573L,59574L,59575L,59576L,59577L,\n59578L,59579L,59580L,59581L,59582L,59583L,59584L,59585L,59586L,59587L,\n59588L,59589L,59590L,59591L,59592L,59593L,59594L,59595L,59596L,59597L,\n59598L,59599L,59600L,59601L,59602L,59603L,59604L,59605L,59606L,59607L,\n59608L,59609L,59610L,59611L,59612L,59613L,59614L,59615L,59616L,59617L,\n59618L,59619L,59620L,59621L,59622L,59623L,59624L,59625L,59626L,59627L,\n59628L,59629L,59630L,59631L,59632L,59633L,59634L,59635L,59636L,59637L,\n59638L,59639L,59640L,59641L,59642L,59643L,59644L,59645L,59646L,59647L,\n59648L,59649L,59650L,59651L,59652L,59653L,59654L,59655L,59656L,59657L,\n59658L,59659L,59660L,59661L,59662L,59663L,59664L,59665L,59666L,59667L,\n59668L,59669L,59670L,59671L,59672L,59673L,59674L,59675L,59676L,59677L,\n59678L,59679L,59680L,59681L,59682L,59683L,59684L,59685L,59686L,59687L,\n59688L,59689L,59690L,59691L,59692L,59693L,59694L,59695L,59696L,59697L,\n59698L,59699L,59700L,59701L,59702L,59703L,59704L,59705L,59706L,59707L,\n59708L,59709L,59710L,59711L,59712L,59713L,59714L,59715L,59716L,59717L,\n59718L,59719L,59720L,59721L,59722L,59723L,59724L,59725L,59726L,59727L,\n59728L,59729L,59730L,59731L,59732L,59733L,59734L,59735L,59736L,59737L,\n59738L,59739L,59740L,59741L,59742L,59743L,59744L,59745L,59746L,59747L,\n59748L,59749L,59750L,59751L,59752L,59753L,59754L,59755L,59756L,59757L,\n59758L,59759L,59760L,59761L,59762L,59763L,59764L,59765L,59766L,59767L,\n59768L,59769L,59770L,59771L,59772L,59773L,59774L,59775L,59776L,59777L,\n59778L,59779L,59780L,59781L,59782L,59783L,59784L,59785L,59786L,59787L,\n59788L,59789L,59790L,59791L,59792L,59793L,59794L,59795L,59796L,59797L,\n59798L,59799L,59800L,59801L,59802L,59803L,59804L,59805L,59806L,59807L,\n59808L,59809L,59810L,59811L,59812L,59813L,59814L,59815L,59816L,59817L,\n59818L,59819L,59820L,59821L,59822L,59823L,59824L,59825L,59826L,59827L,\n59828L,59829L,59830L,59831L,59832L,59833L,59834L,59835L,59836L,59837L,\n59838L,59839L,59840L,59841L,59842L,59843L,59844L,59845L,59846L,59847L,\n59848L,59849L,59850L,59851L,59852L,59853L,59854L,59855L,59856L,59857L,\n59858L,59859L,59860L,59861L,59862L,59863L,59864L,59865L,59866L,59867L,\n59868L,59869L,59870L,59871L,59872L,59873L,59874L,59875L,59876L,59877L,\n59878L,59879L,59880L,59881L,59882L,59883L,59884L,59885L,59886L,59887L,\n59888L,59889L,59890L,59891L,59892L,59893L,59894L,59895L,59896L,59897L,\n59898L,59899L,59900L,59901L,59902L,59903L,59904L,59905L,59906L,59907L,\n59908L,59909L,59910L,59911L,59912L,59913L,59914L,59915L,59916L,59917L,\n59918L,59919L,59920L,59921L,59922L,59923L,59924L,59925L,59926L,59927L,\n59928L,59929L,59930L,59931L,59932L,59933L,59934L,59935L,59936L,59937L,\n59938L,59939L,59940L,59941L,59942L,59943L,59944L,59945L,59946L,59947L,\n59948L,59949L,59950L,59951L,59952L,59953L,59954L,59955L,59956L,59957L,\n59958L,59959L,59960L,59961L,59962L,59963L,59964L,59965L,59966L,59967L,\n59968L,59969L,59970L,59971L,59972L,59973L,59974L,59975L,59976L,59977L,\n59978L,59979L,59980L,59981L,59982L,59983L,59984L,59985L,59986L,59987L,\n59988L,59989L,59990L,59991L,59992L,59993L,59994L,59995L,59996L,59997L,\n59998L,59999L,60000L,60001L,60002L,60003L,60004L,60005L,60006L,60007L,\n60008L,60009L,60010L,60011L,60012L,60013L,60014L,60015L,60016L,60017L,\n60018L,60019L,60020L,60021L,60022L,60023L,60024L,60025L,60026L,60027L,\n60028L,60029L,60030L,60031L,60032L,60033L,60034L,60035L,60036L,60037L,\n60038L,60039L,60040L,60041L,60042L,60043L,60044L,60045L,60046L,60047L,\n60048L,60049L,60050L,60051L,60052L,60053L,60054L,60055L,60056L,60057L,\n60058L,60059L,60060L,60061L,60062L,60063L,60064L,60065L,60066L,60067L,\n60068L,60069L,60070L,60071L,60072L,60073L,60074L,60075L,60076L,60077L,\n60078L,60079L,60080L,60081L,60082L,60083L,60084L,60085L,60086L,60087L,\n60088L,60089L,60090L,60091L,60092L,60093L,60094L,60095L,60096L,60097L,\n60098L,60099L,60100L,60101L,60102L,60103L,60104L,60105L,60106L,60107L,\n60108L,60109L,60110L,60111L,60112L,60113L,60114L,60115L,60116L,60117L,\n60118L,60119L,60120L,60121L,60122L,60123L,60124L,60125L,60126L,60127L,\n60128L,60129L,60130L,60131L,60132L,60133L,60134L,60135L,60136L,60137L,\n60138L,60139L,60140L,60141L,60142L,60143L,60144L,60145L,60146L,60147L,\n60148L,60149L,60150L,60151L,60152L,60153L,60154L,60155L,60156L,60157L,\n60158L,60159L,60160L,60161L,60162L,60163L,60164L,60165L,60166L,60167L,\n60168L,60169L,60170L,60171L,60172L,60173L,60174L,60175L,60176L,60177L,\n60178L,60179L,60180L,60181L,60182L,60183L,60184L,60185L,60186L,60187L,\n60188L,60189L,60190L,60191L,60192L,60193L,60194L,60195L,60196L,60197L,\n60198L,60199L,60200L,60201L,60202L,60203L,60204L,60205L,60206L,60207L,\n60208L,60209L,60210L,60211L,60212L,60213L,60214L,60215L,60216L,60217L,\n60218L,60219L,60220L,60221L,60222L,60223L,60224L,60225L,60226L,60227L,\n60228L,60229L,60230L,60231L,60232L,60233L,60234L,60235L,60236L,60237L,\n60238L,60239L,60240L,60241L,60242L,60243L,60244L,60245L,60246L,60247L,\n60248L,60249L,60250L,60251L,60252L,60253L,60254L,60255L,60256L,60257L,\n60258L,60259L,60260L,60261L,60262L,60263L,60264L,60265L,60266L,60267L,\n60268L,60269L,60270L,60271L,60272L,60273L,60274L,60275L,60276L,60277L,\n60278L,60279L,60280L,60281L,60282L,60283L,60284L,60285L,60286L,60287L,\n60288L,60289L,60290L,60291L,60292L,60293L,60294L,60295L,60296L,60297L,\n60298L,60299L,60300L,60301L,60302L,60303L,60304L,60305L,60306L,60307L,\n60308L,60309L,60310L,60311L,60312L,60313L,60314L,60315L,60316L,60317L,\n60318L,60319L,60320L,60321L,60322L,60323L,60324L,60325L,60326L,60327L,\n60328L,60329L,60330L,60331L,60332L,60333L,60334L,60335L,60336L,60337L,\n60338L,60339L,60340L,60341L,60342L,60343L,60344L,60345L,60346L,60347L,\n60348L,60349L,60350L,60351L,60352L,60353L,60354L,60355L,60356L,60357L,\n60358L,60359L,60360L,60361L,60362L,60363L,60364L,60365L,60366L,60367L,\n60368L,60369L,60370L,60371L,60372L,60373L,60374L,60375L,60376L,60377L,\n60378L,60379L,60380L,60381L,60382L,60383L,60384L,60385L,60386L,60387L,\n60388L,60389L,60390L,60391L,60392L,60393L,60394L,60395L,60396L,60397L,\n60398L,60399L,60400L,60401L,60402L,60403L,60404L,60405L,60406L,60407L,\n60408L,60409L,60410L,60411L,60412L,60413L,60414L,60415L,60416L,60417L,\n60418L,60419L,60420L,60421L,60422L,60423L,60424L,60425L,60426L,60427L,\n60428L,60429L,60430L,60431L,60432L,60433L,60434L,60435L,60436L,60437L,\n60438L,60439L,60440L,60441L,60442L,60443L,60444L,60445L,60446L,60447L,\n60448L,60449L,60450L,60451L,60452L,60453L,60454L,60455L,60456L,60457L,\n60458L,60459L,60460L,60461L,60462L,60463L,60464L,60465L,60466L,60467L,\n60468L,60469L,60470L,60471L,60472L,60473L,60474L,60475L,60476L,60477L,\n60478L,60479L,60480L,60481L,60482L,60483L,60484L,60485L,60486L,60487L,\n60488L,60489L,60490L,60491L,60492L,60493L,60494L,60495L,60496L,60497L,\n60498L,60499L,60500L,60501L,60502L,60503L,60504L,60505L,60506L,60507L,\n60508L,60509L,60510L,60511L,60512L,60513L,60514L,60515L,60516L,60517L,\n60518L,60519L,60520L,60521L,60522L,60523L,60524L,60525L,60526L,60527L,\n60528L,60529L,60530L,60531L,60532L,60533L,60534L,60535L,60536L,60537L,\n60538L,60539L,60540L,60541L,60542L,60543L,60544L,60545L,60546L,60547L,\n60548L,60549L,60550L,60551L,60552L,60553L,60554L,60555L,60556L,60557L,\n60558L,60559L,60560L,60561L,60562L,60563L,60564L,60565L,60566L,60567L,\n60568L,60569L,60570L,60571L,60572L,60573L,60574L,60575L,60576L,60577L,\n60578L,60579L,60580L,60581L,60582L,60583L,60584L,60585L,60586L,60587L,\n60588L,60589L,60590L,60591L,60592L,60593L,60594L,60595L,60596L,60597L,\n60598L,60599L,60600L,60601L,60602L,60603L,60604L,60605L,60606L,60607L,\n60608L,60609L,60610L,60611L,60612L,60613L,60614L,60615L,60616L,60617L,\n60618L,60619L,60620L,60621L,60622L,60623L,60624L,60625L,60626L,60627L,\n60628L,60629L,60630L,60631L,60632L,60633L,60634L,60635L,60636L,60637L,\n60638L,60639L,60640L,60641L,60642L,60643L,60644L,60645L,60646L,60647L,\n60648L,60649L,60650L,60651L,60652L,60653L,60654L,60655L,60656L,60657L,\n60658L,60659L,60660L,60661L,60662L,60663L,60664L,60665L,60666L,60667L,\n60668L,60669L,60670L,60671L,60672L,60673L,60674L,60675L,60676L,60677L,\n60678L,60679L,60680L,60681L,60682L,60683L,60684L,60685L,60686L,60687L,\n60688L,60689L,60690L,60691L,60692L,60693L,60694L,60695L,60696L,60697L,\n60698L,60699L,60700L,60701L,60702L,60703L,60704L,60705L,60706L,60707L,\n60708L,60709L,60710L,60711L,60712L,60713L,60714L,60715L,60716L,60717L,\n60718L,60719L,60720L,60721L,60722L,60723L,60724L,60725L,60726L,60727L,\n60728L,60729L,60730L,60731L,60732L,60733L,60734L,60735L,60736L,60737L,\n60738L,60739L,60740L,60741L,60742L,60743L,60744L,60745L,60746L,60747L,\n60748L,60749L,60750L,60751L,60752L,60753L,60754L,60755L,60756L,60757L,\n60758L,60759L,60760L,60761L,60762L,60763L,60764L,60765L,60766L,60767L,\n60768L,60769L,60770L,60771L,60772L,60773L,60774L,60775L,60776L,60777L,\n60778L,60779L,60780L,60781L,60782L,60783L,60784L,60785L,60786L,60787L,\n60788L,60789L,60790L,60791L,60792L,60793L,60794L,60795L,60796L,60797L,\n60798L,60799L,60800L,60801L,60802L,60803L,60804L,60805L,60806L,60807L,\n60808L,60809L,60810L,60811L,60812L,60813L,60814L,60815L,60816L,60817L,\n60818L,60819L,60820L,60821L,60822L,60823L,60824L,60825L,60826L,60827L,\n60828L,60829L,60830L,60831L,60832L,60833L,60834L,60835L,60836L,60837L,\n60838L,60839L,60840L,60841L,60842L,60843L,60844L,60845L,60846L,60847L,\n60848L,60849L,60850L,60851L,60852L,60853L,60854L,60855L,60856L,60857L,\n60858L,60859L,60860L,60861L,60862L,60863L,60864L,60865L,60866L,60867L,\n60868L,60869L,60870L,60871L,60872L,60873L,60874L,60875L,60876L,60877L,\n60878L,60879L,60880L,60881L,60882L,60883L,60884L,60885L,60886L,60887L,\n60888L,60889L,60890L,60891L,60892L,60893L,60894L,60895L,60896L,60897L,\n60898L,60899L,60900L,60901L,60902L,60903L,60904L,60905L,60906L,60907L,\n60908L,60909L,60910L,60911L,60912L,60913L,60914L,60915L,60916L,60917L,\n60918L,60919L,60920L,60921L,60922L,60923L,60924L,60925L,60926L,60927L,\n60928L,60929L,60930L,60931L,60932L,60933L,60934L,60935L,60936L,60937L,\n60938L,60939L,60940L,60941L,60942L,60943L,60944L,60945L,60946L,60947L,\n60948L,60949L,60950L,60951L,60952L,60953L,60954L,60955L,60956L,60957L,\n60958L,60959L,60960L,60961L,60962L,60963L,60964L,60965L,60966L,60967L,\n60968L,60969L,60970L,60971L,60972L,60973L,60974L,60975L,60976L,60977L,\n60978L,60979L,60980L,60981L,60982L,60983L,60984L,60985L,60986L,60987L,\n60988L,60989L,60990L,60991L,60992L,60993L,60994L,60995L,60996L,60997L,\n60998L,60999L,61000L,61001L,61002L,61003L,61004L,61005L,61006L,61007L,\n61008L,61009L,61010L,61011L,61012L,61013L,61014L,61015L,61016L,61017L,\n61018L,61019L,61020L,61021L,61022L,61023L,61024L,61025L,61026L,61027L,\n61028L,61029L,61030L,61031L,61032L,61033L,61034L,61035L,61036L,61037L,\n61038L,61039L,61040L,61041L,61042L,61043L,61044L,61045L,61046L,61047L,\n61048L,61049L,61050L,61051L,61052L,61053L,61054L,61055L,61056L,61057L,\n61058L,61059L,61060L,61061L,61062L,61063L,61064L,61065L,61066L,61067L,\n61068L,61069L,61070L,61071L,61072L,61073L,61074L,61075L,61076L,61077L,\n61078L,61079L,61080L,61081L,61082L,61083L,61084L,61085L,61086L,61087L,\n61088L,61089L,61090L,61091L,61092L,61093L,61094L,61095L,61096L,61097L,\n61098L,61099L,61100L,61101L,61102L,61103L,61104L,61105L,61106L,61107L,\n61108L,61109L,61110L,61111L,61112L,61113L,61114L,61115L,61116L,61117L,\n61118L,61119L,61120L,61121L,61122L,61123L,61124L,61125L,61126L,61127L,\n61128L,61129L,61130L,61131L,61132L,61133L,61134L,61135L,61136L,61137L,\n61138L,61139L,61140L,61141L,61142L,61143L,61144L,61145L,61146L,61147L,\n61148L,61149L,61150L,61151L,61152L,61153L,61154L,61155L,61156L,61157L,\n61158L,61159L,61160L,61161L,61162L,61163L,61164L,61165L,61166L,61167L,\n61168L,61169L,61170L,61171L,61172L,61173L,61174L,61175L,61176L,61177L,\n61178L,61179L,61180L,61181L,61182L,61183L,61184L,61185L,61186L,61187L,\n61188L,61189L,61190L,61191L,61192L,61193L,61194L,61195L,61196L,61197L,\n61198L,61199L,61200L,61201L,61202L,61203L,61204L,61205L,61206L,61207L,\n61208L,61209L,61210L,61211L,61212L,61213L,61214L,61215L,61216L,61217L,\n61218L,61219L,61220L,61221L,61222L,61223L,61224L,61225L,61226L,61227L,\n61228L,61229L,61230L,61231L,61232L,61233L,61234L,61235L,61236L,61237L,\n61238L,61239L,61240L,61241L,61242L,61243L,61244L,61245L,61246L,61247L,\n61248L,61249L,61250L,61251L,61252L,61253L,61254L,61255L,61256L,61257L,\n61258L,61259L,61260L,61261L,61262L,61263L,61264L,61265L,61266L,61267L,\n61268L,61269L,61270L,61271L,61272L,61273L,61274L,61275L,61276L,61277L,\n61278L,61279L,61280L,61281L,61282L,61283L,61284L,61285L,61286L,61287L,\n61288L,61289L,61290L,61291L,61292L,61293L,61294L,61295L,61296L,61297L,\n61298L,61299L,61300L,61301L,61302L,61303L,61304L,61305L,61306L,61307L,\n61308L,61309L,61310L,61311L,61312L,61313L,61314L,61315L,61316L,61317L,\n61318L,61319L,61320L,61321L,61322L,61323L,61324L,61325L,61326L,61327L,\n61328L,61329L,61330L,61331L,61332L,61333L,61334L,61335L,61336L,61337L,\n61338L,61339L,61340L,61341L,61342L,61343L,61344L,61345L,61346L,61347L,\n61348L,61349L,61350L,61351L,61352L,61353L,61354L,61355L,61356L,61357L,\n61358L,61359L,61360L,61361L,61362L,61363L,61364L,61365L,61366L,61367L,\n61368L,61369L,61370L,61371L,61372L,61373L,61374L,61375L,61376L,61377L,\n61378L,61379L,61380L,61381L,61382L,61383L,61384L,61385L,61386L,61387L,\n61388L,61389L,61390L,61391L,61392L,61393L,61394L,61395L,61396L,61397L,\n61398L,61399L,61400L,61401L,61402L,61403L,61404L,61405L,61406L,61407L,\n61408L,61409L,61410L,61411L,61412L,61413L,61414L,61415L,61416L,61417L,\n61418L,61419L,61420L,61421L,61422L,61423L,61424L,61425L,61426L,61427L,\n61428L,61429L,61430L,61431L,61432L,61433L,61434L,61435L,61436L,61437L,\n61438L,61439L,61440L,61441L,61442L,61443L,61444L,61445L,61446L,61447L,\n61448L,61449L,61450L,61451L,61452L,61453L,61454L,61455L,61456L,61457L,\n61458L,61459L,61460L,61461L,61462L,61463L,61464L,61465L,61466L,61467L,\n61468L,61469L,61470L,61471L,61472L,61473L,61474L,61475L,61476L,61477L,\n61478L,61479L,61480L,61481L,61482L,61483L,61484L,61485L,61486L,61487L,\n61488L,61489L,61490L,61491L,61492L,61493L,61494L,61495L,61496L,61497L,\n61498L,61499L,61500L,61501L,61502L,61503L,61504L,61505L,61506L,61507L,\n61508L,61509L,61510L,61511L,61512L,61513L,61514L,61515L,61516L,61517L,\n61518L,61519L,61520L,61521L,61522L,61523L,61524L,61525L,61526L,61527L,\n61528L,61529L,61530L,61531L,61532L,61533L,61534L,61535L,61536L,61537L,\n61538L,61539L,61540L,61541L,61542L,61543L,61544L,61545L,61546L,61547L,\n61548L,61549L,61550L,61551L,61552L,61553L,61554L,61555L,61556L,61557L,\n61558L,61559L,61560L,61561L,61562L,61563L,61564L,61565L,61566L,61567L,\n61568L,61569L,61570L,61571L,61572L,61573L,61574L,61575L,61576L,61577L,\n61578L,61579L,61580L,61581L,61582L,61583L,61584L,61585L,61586L,61587L,\n61588L,61589L,61590L,61591L,61592L,61593L,61594L,61595L,61596L,61597L,\n61598L,61599L,61600L,61601L,61602L,61603L,61604L,61605L,61606L,61607L,\n61608L,61609L,61610L,61611L,61612L,61613L,61614L,61615L,61616L,61617L,\n61618L,61619L,61620L,61621L,61622L,61623L,61624L,61625L,61626L,61627L,\n61628L,61629L,61630L,61631L,61632L,61633L,61634L,61635L,61636L,61637L,\n61638L,61639L,61640L,61641L,61642L,61643L,61644L,61645L,61646L,61647L,\n61648L,61649L,61650L,61651L,61652L,61653L,61654L,61655L,61656L,61657L,\n61658L,61659L,61660L,61661L,61662L,61663L,61664L,61665L,61666L,61667L,\n61668L,61669L,61670L,61671L,61672L,61673L,61674L,61675L,61676L,61677L,\n61678L,61679L,61680L,61681L,61682L,61683L,61684L,61685L,61686L,61687L,\n61688L,61689L,61690L,61691L,61692L,61693L,61694L,61695L,61696L,61697L,\n61698L,61699L,61700L,61701L,61702L,61703L,61704L,61705L,61706L,61707L,\n61708L,61709L,61710L,61711L,61712L,61713L,61714L,61715L,61716L,61717L,\n61718L,61719L,61720L,61721L,61722L,61723L,61724L,61725L,61726L,61727L,\n61728L,61729L,61730L,61731L,61732L,61733L,61734L,61735L,61736L,61737L,\n61738L,61739L,61740L,61741L,61742L,61743L,61744L,61745L,61746L,61747L,\n61748L,61749L,61750L,61751L,61752L,61753L,61754L,61755L,61756L,61757L,\n61758L,61759L,61760L,61761L,61762L,61763L,61764L,61765L,61766L,61767L,\n61768L,61769L,61770L,61771L,61772L,61773L,61774L,61775L,61776L,61777L,\n61778L,61779L,61780L,61781L,61782L,61783L,61784L,61785L,61786L,61787L,\n61788L,61789L,61790L,61791L,61792L,61793L,61794L,61795L,61796L,61797L,\n61798L,61799L,61800L,61801L,61802L,61803L,61804L,61805L,61806L,61807L,\n61808L,61809L,61810L,61811L,61812L,61813L,61814L,61815L,61816L,61817L,\n61818L,61819L,61820L,61821L,61822L,61823L,61824L,61825L,61826L,61827L,\n61828L,61829L,61830L,61831L,61832L,61833L,61834L,61835L,61836L,61837L,\n61838L,61839L,61840L,61841L,61842L,61843L,61844L,61845L,61846L,61847L,\n61848L,61849L,61850L,61851L,61852L,61853L,61854L,61855L,61856L,61857L,\n61858L,61859L,61860L,61861L,61862L,61863L,61864L,61865L,61866L,61867L,\n61868L,61869L,61870L,61871L,61872L,61873L,61874L,61875L,61876L,61877L,\n61878L,61879L,61880L,61881L,61882L,61883L,61884L,61885L,61886L,61887L,\n61888L,61889L,61890L,61891L,61892L,61893L,61894L,61895L,61896L,61897L,\n61898L,61899L,61900L,61901L,61902L,61903L,61904L,61905L,61906L,61907L,\n61908L,61909L,61910L,61911L,61912L,61913L,61914L,61915L,61916L,61917L,\n61918L,61919L,61920L,61921L,61922L,61923L,61924L,61925L,61926L,61927L,\n61928L,61929L,61930L,61931L,61932L,61933L,61934L,61935L,61936L,61937L,\n61938L,61939L,61940L,61941L,61942L,61943L,61944L,61945L,61946L,61947L,\n61948L,61949L,61950L,61951L,61952L,61953L,61954L,61955L,61956L,61957L,\n61958L,61959L,61960L,61961L,61962L,61963L,61964L,61965L,61966L,61967L,\n61968L,61969L,61970L,61971L,61972L,61973L,61974L,61975L,61976L,61977L,\n61978L,61979L,61980L,61981L,61982L,61983L,61984L,61985L,61986L,61987L,\n61988L,61989L,61990L,61991L,61992L,61993L,61994L,61995L,61996L,61997L,\n61998L,61999L,62000L,62001L,62002L,62003L,62004L,62005L,62006L,62007L,\n62008L,62009L,62010L,62011L,62012L,62013L,62014L,62015L,62016L,62017L,\n62018L,62019L,62020L,62021L,62022L,62023L,62024L,62025L,62026L,62027L,\n62028L,62029L,62030L,62031L,62032L,62033L,62034L,62035L,62036L,62037L,\n62038L,62039L,62040L,62041L,62042L,62043L,62044L,62045L,62046L,62047L,\n62048L,62049L,62050L,62051L,62052L,62053L,62054L,62055L,62056L,62057L,\n62058L,62059L,62060L,62061L,62062L,62063L,62064L,62065L,62066L,62067L,\n62068L,62069L,62070L,62071L,62072L,62073L,62074L,62075L,62076L,62077L,\n62078L,62079L,62080L,62081L,62082L,62083L,62084L,62085L,62086L,62087L,\n62088L,62089L,62090L,62091L,62092L,62093L,62094L,62095L,62096L,62097L,\n62098L,62099L,62100L,62101L,62102L,62103L,62104L,62105L,62106L,62107L,\n62108L,62109L,62110L,62111L,62112L,62113L,62114L,62115L,62116L,62117L,\n62118L,62119L,62120L,62121L,62122L,62123L,62124L,62125L,62126L,62127L,\n62128L,62129L,62130L,62131L,62132L,62133L,62134L,62135L,62136L,62137L,\n62138L,62139L,62140L,62141L,62142L,62143L,62144L,62145L,62146L,62147L,\n62148L,62149L,62150L,62151L,62152L,62153L,62154L,62155L,62156L,62157L,\n62158L,62159L,62160L,62161L,62162L,62163L,62164L,62165L,62166L,62167L,\n62168L,62169L,62170L,62171L,62172L,62173L,62174L,62175L,62176L,62177L,\n62178L,62179L,62180L,62181L,62182L,62183L,62184L,62185L,62186L,62187L,\n62188L,62189L,62190L,62191L,62192L,62193L,62194L,62195L,62196L,62197L,\n62198L,62199L,62200L,62201L,62202L,62203L,62204L,62205L,62206L,62207L,\n62208L,62209L,62210L,62211L,62212L,62213L,62214L,62215L,62216L,62217L,\n62218L,62219L,62220L,62221L,62222L,62223L,62224L,62225L,62226L,62227L,\n62228L,62229L,62230L,62231L,62232L,62233L,62234L,62235L,62236L,62237L,\n62238L,62239L,62240L,62241L,62242L,62243L,62244L,62245L,62246L,62247L,\n62248L,62249L,62250L,62251L,62252L,62253L,62254L,62255L,62256L,62257L,\n62258L,62259L,62260L,62261L,62262L,62263L,62264L,62265L,62266L,62267L,\n62268L,62269L,62270L,62271L,62272L,62273L,62274L,62275L,62276L,62277L,\n62278L,62279L,62280L,62281L,62282L,62283L,62284L,62285L,62286L,62287L,\n62288L,62289L,62290L,62291L,62292L,62293L,62294L,62295L,62296L,62297L,\n62298L,62299L,62300L,62301L,62302L,62303L,62304L,62305L,62306L,62307L,\n62308L,62309L,62310L,62311L,62312L,62313L,62314L,62315L,62316L,62317L,\n62318L,62319L,62320L,62321L,62322L,62323L,62324L,62325L,62326L,62327L,\n62328L,62329L,62330L,62331L,62332L,62333L,62334L,62335L,62336L,62337L,\n62338L,62339L,62340L,62341L,62342L,62343L,62344L,62345L,62346L,62347L,\n62348L,62349L,62350L,62351L,62352L,62353L,62354L,62355L,62356L,62357L,\n62358L,62359L,62360L,62361L,62362L,62363L,62364L,62365L,62366L,62367L,\n62368L,62369L,62370L,62371L,62372L,62373L,62374L,62375L,62376L,62377L,\n62378L,62379L,62380L,62381L,62382L,62383L,62384L,62385L,62386L,62387L,\n62388L,62389L,62390L,62391L,62392L,62393L,62394L,62395L,62396L,62397L,\n62398L,62399L,62400L,62401L,62402L,62403L,62404L,62405L,62406L,62407L,\n62408L,62409L,62410L,62411L,62412L,62413L,62414L,62415L,62416L,62417L,\n62418L,62419L,62420L,62421L,62422L,62423L,62424L,62425L,62426L,62427L,\n62428L,62429L,62430L,62431L,62432L,62433L,62434L,62435L,62436L,62437L,\n62438L,62439L,62440L,62441L,62442L,62443L,62444L,62445L,62446L,62447L,\n62448L,62449L,62450L,62451L,62452L,62453L,62454L,62455L,62456L,62457L,\n62458L,62459L,62460L,62461L,62462L,62463L,62464L,62465L,62466L,62467L,\n62468L,62469L,62470L,62471L,62472L,62473L,62474L,62475L,62476L,62477L,\n62478L,62479L,62480L,62481L,62482L,62483L,62484L,62485L,62486L,62487L,\n62488L,62489L,62490L,62491L,62492L,62493L,62494L,62495L,62496L,62497L,\n62498L,62499L,62500L,62501L,62502L,62503L,62504L,62505L,62506L,62507L,\n62508L,62509L,62510L,62511L,62512L,62513L,62514L,62515L,62516L,62517L,\n62518L,62519L,62520L,62521L,62522L,62523L,62524L,62525L,62526L,62527L,\n62528L,62529L,62530L,62531L,62532L,62533L,62534L,62535L,62536L,62537L,\n62538L,62539L,62540L,62541L,62542L,62543L,62544L,62545L,62546L,62547L,\n62548L,62549L,62550L,62551L,62552L,62553L,62554L,62555L,62556L,62557L,\n62558L,62559L,62560L,62561L,62562L,62563L,62564L,62565L,62566L,62567L,\n62568L,62569L,62570L,62571L,62572L,62573L,62574L,62575L,62576L,62577L,\n62578L,62579L,62580L,62581L,62582L,62583L,62584L,62585L,62586L,62587L,\n62588L,62589L,62590L,62591L,62592L,62593L,62594L,62595L,62596L,62597L,\n62598L,62599L,62600L,62601L,62602L,62603L,62604L,62605L,62606L,62607L,\n62608L,62609L,62610L,62611L,62612L,62613L,62614L,62615L,62616L,62617L,\n62618L,62619L,62620L,62621L,62622L,62623L,62624L,62625L,62626L,62627L,\n62628L,62629L,62630L,62631L,62632L,62633L,62634L,62635L,62636L,62637L,\n62638L,62639L,62640L,62641L,62642L,62643L,62644L,62645L,62646L,62647L,\n62648L,62649L,62650L,62651L,62652L,62653L,62654L,62655L,62656L,62657L,\n62658L,62659L,62660L,62661L,62662L,62663L,62664L,62665L,62666L,62667L,\n62668L,62669L,62670L,62671L,62672L,62673L,62674L,62675L,62676L,62677L,\n62678L,62679L,62680L,62681L,62682L,62683L,62684L,62685L,62686L,62687L,\n62688L,62689L,62690L,62691L,62692L,62693L,62694L,62695L,62696L,62697L,\n62698L,62699L,62700L,62701L,62702L,62703L,62704L,62705L,62706L,62707L,\n62708L,62709L,62710L,62711L,62712L,62713L,62714L,62715L,62716L,62717L,\n62718L,62719L,62720L,62721L,62722L,62723L,62724L,62725L,62726L,62727L,\n62728L,62729L,62730L,62731L,62732L,62733L,62734L,62735L,62736L,62737L,\n62738L,62739L,62740L,62741L,62742L,62743L,62744L,62745L,62746L,62747L,\n62748L,62749L,62750L,62751L,62752L,62753L,62754L,62755L,62756L,62757L,\n62758L,62759L,62760L,62761L,62762L,62763L,62764L,62765L,62766L,62767L,\n62768L,62769L,62770L,62771L,62772L,62773L,62774L,62775L,62776L,62777L,\n62778L,62779L,62780L,62781L,62782L,62783L,62784L,62785L,62786L,62787L,\n62788L,62789L,62790L,62791L,62792L,62793L,62794L,62795L,62796L,62797L,\n62798L,62799L,62800L,62801L,62802L,62803L,62804L,62805L,62806L,62807L,\n62808L,62809L,62810L,62811L,62812L,62813L,62814L,62815L,62816L,62817L,\n62818L,62819L,62820L,62821L,62822L,62823L,62824L,62825L,62826L,62827L,\n62828L,62829L,62830L,62831L,62832L,62833L,62834L,62835L,62836L,62837L,\n62838L,62839L,62840L,62841L,62842L,62843L,62844L,62845L,62846L,62847L,\n62848L,62849L,62850L,62851L,62852L,62853L,62854L,62855L,62856L,62857L,\n62858L,62859L,62860L,62861L,62862L,62863L,62864L,62865L,62866L,62867L,\n62868L,62869L,62870L,62871L,62872L,62873L,62874L,62875L,62876L,62877L,\n62878L,62879L,62880L,62881L,62882L,62883L,62884L,62885L,62886L,62887L,\n62888L,62889L,62890L,62891L,62892L,62893L,62894L,62895L,62896L,62897L,\n62898L,62899L,62900L,62901L,62902L,62903L,62904L,62905L,62906L,62907L,\n62908L,62909L,62910L,62911L,62912L,62913L,62914L,62915L,62916L,62917L,\n62918L,62919L,62920L,62921L,62922L,62923L,62924L,62925L,62926L,62927L,\n62928L,62929L,62930L,62931L,62932L,62933L,62934L,62935L,62936L,62937L,\n62938L,62939L,62940L,62941L,62942L,62943L,62944L,62945L,62946L,62947L,\n62948L,62949L,62950L,62951L,62952L,62953L,62954L,62955L,62956L,62957L,\n62958L,62959L,62960L,62961L,62962L,62963L,62964L,62965L,62966L,62967L,\n62968L,62969L,62970L,62971L,62972L,62973L,62974L,62975L,62976L,62977L,\n62978L,62979L,62980L,62981L,62982L,62983L,62984L,62985L,62986L,62987L,\n62988L,62989L,62990L,62991L,62992L,62993L,62994L,62995L,62996L,62997L,\n62998L,62999L,63000L,63001L,63002L,63003L,63004L,63005L,63006L,63007L,\n63008L,63009L,63010L,63011L,63012L,63013L,63014L,63015L,63016L,63017L,\n63018L,63019L,63020L,63021L,63022L,63023L,63024L,63025L,63026L,63027L,\n63028L,63029L,63030L,63031L,63032L,63033L,63034L,63035L,63036L,63037L,\n63038L,63039L,63040L,63041L,63042L,63043L,63044L,63045L,63046L,63047L,\n63048L,63049L,63050L,63051L,63052L,63053L,63054L,63055L,63056L,63057L,\n63058L,63059L,63060L,63061L,63062L,63063L,63064L,63065L,63066L,63067L,\n63068L,63069L,63070L,63071L,63072L,63073L,63074L,63075L,63076L,63077L,\n63078L,63079L,63080L,63081L,63082L,63083L,63084L,63085L,63086L,63087L,\n63088L,63089L,63090L,63091L,63092L,63093L,63094L,63095L,63096L,63097L,\n63098L,63099L,63100L,63101L,63102L,63103L,63104L,63105L,63106L,63107L,\n63108L,63109L,63110L,63111L,63112L,63113L,63114L,63115L,63116L,63117L,\n63118L,63119L,63120L,63121L,63122L,63123L,63124L,63125L,63126L,63127L,\n63128L,63129L,63130L,63131L,63132L,63133L,63134L,63135L,63136L,63137L,\n63138L,63139L,63140L,63141L,63142L,63143L,63144L,63145L,63146L,63147L,\n63148L,63149L,63150L,63151L,63152L,63153L,63154L,63155L,63156L,63157L,\n63158L,63159L,63160L,63161L,63162L,63163L,63164L,63165L,63166L,63167L,\n63168L,63169L,63170L,63171L,63172L,63173L,63174L,63175L,63176L,63177L,\n63178L,63179L,63180L,63181L,63182L,63183L,63184L,63185L,63186L,63187L,\n63188L,63189L,63190L,63191L,63192L,63193L,63194L,63195L,63196L,63197L,\n63198L,63199L,63200L,63201L,63202L,63203L,63204L,63205L,63206L,63207L,\n63208L,63209L,63210L,63211L,63212L,63213L,63214L,63215L,63216L,63217L,\n63218L,63219L,63220L,63221L,63222L,63223L,63224L,63225L,63226L,63227L,\n63228L,63229L,63230L,63231L,63232L,63233L,63234L,63235L,63236L,63237L,\n63238L,63239L,63240L,63241L,63242L,63243L,63244L,63245L,63246L,63247L,\n63248L,63249L,63250L,63251L,63252L,63253L,63254L,63255L,63256L,63257L,\n63258L,63259L,63260L,63261L,63262L,63263L,63264L,63265L,63266L,63267L,\n63268L,63269L,63270L,63271L,63272L,63273L,63274L,63275L,63276L,63277L,\n63278L,63279L,63280L,63281L,63282L,63283L,63284L,63285L,63286L,63287L,\n63288L,63289L,63290L,63291L,63292L,63293L,63294L,63295L,63296L,63297L,\n63298L,63299L,63300L,63301L,63302L,63303L,63304L,63305L,63306L,63307L,\n63308L,63309L,63310L,63311L,63312L,63313L,63314L,63315L,63316L,63317L,\n63318L,63319L,63320L,63321L,63322L,63323L,63324L,63325L,63326L,63327L,\n63328L,63329L,63330L,63331L,63332L,63333L,63334L,63335L,63336L,63337L,\n63338L,63339L,63340L,63341L,63342L,63343L,63344L,63345L,63346L,63347L,\n63348L,63349L,63350L,63351L,63352L,63353L,63354L,63355L,63356L,63357L,\n63358L,63359L,63360L,63361L,63362L,63363L,63364L,63365L,63366L,63367L,\n63368L,63369L,63370L,63371L,63372L,63373L,63374L,63375L,63376L,63377L,\n63378L,63379L,63380L,63381L,63382L,63383L,63384L,63385L,63386L,63387L,\n63388L,63389L,63390L,63391L,63392L,63393L,63394L,63395L,63396L,63397L,\n63398L,63399L,63400L,63401L,63402L,63403L,63404L,63405L,63406L,63407L,\n63408L,63409L,63410L,63411L,63412L,63413L,63414L,63415L,63416L,63417L,\n63418L,63419L,63420L,63421L,63422L,63423L,63424L,63425L,63426L,63427L,\n63428L,63429L,63430L,63431L,63432L,63433L,63434L,63435L,63436L,63437L,\n63438L,63439L,63440L,63441L,63442L,63443L,63444L,63445L,63446L,63447L,\n63448L,63449L,63450L,63451L,63452L,63453L,63454L,63455L,63456L,63457L,\n63458L,63459L,63460L,63461L,63462L,63463L,63464L,63465L,63466L,63467L,\n63468L,63469L,63470L,63471L,63472L,63473L,63474L,63475L,63476L,63477L,\n63478L,63479L,63480L,63481L,63482L,63483L,63484L,63485L,63486L,63487L,\n63488L,63489L,63490L,63491L,63492L,63493L,63494L,63495L,63496L,63497L,\n63498L,63499L,63500L,63501L,63502L,63503L,63504L,63505L,63506L,63507L,\n63508L,63509L,63510L,63511L,63512L,63513L,63514L,63515L,63516L,63517L,\n63518L,63519L,63520L,63521L,63522L,63523L,63524L,63525L,63526L,63527L,\n63528L,63529L,63530L,63531L,63532L,63533L,63534L,63535L,63536L,63537L,\n63538L,63539L,63540L,63541L,63542L,63543L,63544L,63545L,63546L,63547L,\n63548L,63549L,63550L,63551L,63552L,63553L,63554L,63555L,63556L,63557L,\n63558L,63559L,63560L,63561L,63562L,63563L,63564L,63565L,63566L,63567L,\n63568L,63569L,63570L,63571L,63572L,63573L,63574L,63575L,63576L,63577L,\n63578L,63579L,63580L,63581L,63582L,63583L,63584L,63585L,63586L,63587L,\n63588L,63589L,63590L,63591L,63592L,63593L,63594L,63595L,63596L,63597L,\n63598L,63599L,63600L,63601L,63602L,63603L,63604L,63605L,63606L,63607L,\n63608L,63609L,63610L,63611L,63612L,63613L,63614L,63615L,63616L,63617L,\n63618L,63619L,63620L,63621L,63622L,63623L,63624L,63625L,63626L,63627L,\n63628L,63629L,63630L,63631L,63632L,63633L,63634L,63635L,63636L,63637L,\n63638L,63639L,63640L,63641L,63642L,63643L,63644L,63645L,63646L,63647L,\n63648L,63649L,63650L,63651L,63652L,63653L,63654L,63655L,63656L,63657L,\n63658L,63659L,63660L,63661L,63662L,63663L,63664L,63665L,63666L,63667L,\n63668L,63669L,63670L,63671L,63672L,63673L,63674L,63675L,63676L,63677L,\n63678L,63679L,63680L,63681L,63682L,63683L,63684L,63685L,63686L,63687L,\n63688L,63689L,63690L,63691L,63692L,63693L,63694L,63695L,63696L,63697L,\n63698L,63699L,63700L,63701L,63702L,63703L,63704L,63705L,63706L,63707L,\n63708L,63709L,63710L,63711L,63712L,63713L,63714L,63715L,63716L,63717L,\n63718L,63719L,63720L,63721L,63722L,63723L,63724L,63725L,63726L,63727L,\n63728L,63729L,63730L,63731L,63732L,63733L,63734L,63735L,63736L,63737L,\n63738L,63739L,63740L,63741L,63742L,63743L,63744L,63745L,63746L,63747L,\n63748L,63749L,63750L,63751L,63752L,63753L,63754L,63755L,63756L,63757L,\n63758L,63759L,63760L,63761L,63762L,63763L,63764L,63765L,63766L,63767L,\n63768L,63769L,63770L,63771L,63772L,63773L,63774L,63775L,63776L,63777L,\n63778L,63779L,63780L,63781L,63782L,63783L,63784L,63785L,63786L,63787L,\n63788L,63789L,63790L,63791L,63792L,63793L,63794L,63795L,63796L,63797L,\n63798L,63799L,63800L,63801L,63802L,63803L,63804L,63805L,63806L,63807L,\n63808L,63809L,63810L,63811L,63812L,63813L,63814L,63815L,63816L,63817L,\n63818L,63819L,63820L,63821L,63822L,63823L,63824L,63825L,63826L,63827L,\n63828L,63829L,63830L,63831L,63832L,63833L,63834L,63835L,63836L,63837L,\n63838L,63839L,63840L,63841L,63842L,63843L,63844L,63845L,63846L,63847L,\n63848L,63849L,63850L,63851L,63852L,63853L,63854L,63855L,63856L,63857L,\n63858L,63859L,63860L,63861L,63862L,63863L,63864L,63865L,63866L,63867L,\n63868L,63869L,63870L,63871L,63872L,63873L,63874L,63875L,63876L,63877L,\n63878L,63879L,63880L,63881L,63882L,63883L,63884L,63885L,63886L,63887L,\n63888L,63889L,63890L,63891L,63892L,63893L,63894L,63895L,63896L,63897L,\n63898L,63899L,63900L,63901L,63902L,63903L,63904L,63905L,63906L,63907L,\n63908L,63909L,63910L,63911L,63912L,63913L,63914L,63915L,63916L,63917L,\n63918L,63919L,63920L,63921L,63922L,63923L,63924L,63925L,63926L,63927L,\n63928L,63929L,63930L,63931L,63932L,63933L,63934L,63935L,63936L,63937L,\n63938L,63939L,63940L,63941L,63942L,63943L,63944L,63945L,63946L,63947L,\n63948L,63949L,63950L,63951L,63952L,63953L,63954L,63955L,63956L,63957L,\n63958L,63959L,63960L,63961L,63962L,63963L,63964L,63965L,63966L,63967L,\n63968L,63969L,63970L,63971L,63972L,63973L,63974L,63975L,63976L,63977L,\n63978L,63979L,63980L,63981L,63982L,63983L,63984L,63985L,63986L,63987L,\n63988L,63989L,63990L,63991L,63992L,63993L,63994L,63995L,63996L,63997L,\n63998L,63999L,64000L,64001L,64002L,64003L,64004L,64005L,64006L,64007L,\n64008L,64009L,64010L,64011L,64012L,64013L,64014L,64015L,64016L,64017L,\n64018L,64019L,64020L,64021L,64022L,64023L,64024L,64025L,64026L,64027L,\n64028L,64029L,64030L,64031L,64032L,64033L,64034L,64035L,64036L,64037L,\n64038L,64039L,64040L,64041L,64042L,64043L,64044L,64045L,64046L,64047L,\n64048L,64049L,64050L,64051L,64052L,64053L,64054L,64055L,64056L,64057L,\n64058L,64059L,64060L,64061L,64062L,64063L,64064L,64065L,64066L,64067L,\n64068L,64069L,64070L,64071L,64072L,64073L,64074L,64075L,64076L,64077L,\n64078L,64079L,64080L,64081L,64082L,64083L,64084L,64085L,64086L,64087L,\n64088L,64089L,64090L,64091L,64092L,64093L,64094L,64095L,64096L,64097L,\n64098L,64099L,64100L,64101L,64102L,64103L,64104L,64105L,64106L,64107L,\n64108L,64109L,64110L,64111L,64112L,64113L,64114L,64115L,64116L,64117L,\n64118L,64119L,64120L,64121L,64122L,64123L,64124L,64125L,64126L,64127L,\n64128L,64129L,64130L,64131L,64132L,64133L,64134L,64135L,64136L,64137L,\n64138L,64139L,64140L,64141L,64142L,64143L,64144L,64145L,64146L,64147L,\n64148L,64149L,64150L,64151L,64152L,64153L,64154L,64155L,64156L,64157L,\n64158L,64159L,64160L,64161L,64162L,64163L,64164L,64165L,64166L,64167L,\n64168L,64169L,64170L,64171L,64172L,64173L,64174L,64175L,64176L,64177L,\n64178L,64179L,64180L,64181L,64182L,64183L,64184L,64185L,64186L,64187L,\n64188L,64189L,64190L,64191L,64192L,64193L,64194L,64195L,64196L,64197L,\n64198L,64199L,64200L,64201L,64202L,64203L,64204L,64205L,64206L,64207L,\n64208L,64209L,64210L,64211L,64212L,64213L,64214L,64215L,64216L,64217L,\n64218L,64219L,64220L,64221L,64222L,64223L,64224L,64225L,64226L,64227L,\n64228L,64229L,64230L,64231L,64232L,64233L,64234L,64235L,64236L,64237L,\n64238L,64239L,64240L,64241L,64242L,64243L,64244L,64245L,64246L,64247L,\n64248L,64249L,64250L,64251L,64252L,64253L,64254L,64255L,64256L,64257L,\n64258L,64259L,64260L,64261L,64262L,64263L,64264L,64265L,64266L,64267L,\n64268L,64269L,64270L,64271L,64272L,64273L,64274L,64275L,64276L,64277L,\n64278L,64279L,64280L,64281L,64282L,64283L,64284L,64285L,64286L,64287L,\n64288L,64289L,64290L,64291L,64292L,64293L,64294L,64295L,64296L,64297L,\n64298L,64299L,64300L,64301L,64302L,64303L,64304L,64305L,64306L,64307L,\n64308L,64309L,64310L,64311L,64312L,64313L,64314L,64315L,64316L,64317L,\n64318L,64319L,64320L,64321L,64322L,64323L,64324L,64325L,64326L,64327L,\n64328L,64329L,64330L,64331L,64332L,64333L,64334L,64335L,64336L,64337L,\n64338L,64339L,64340L,64341L,64342L,64343L,64344L,64345L,64346L,64347L,\n64348L,64349L,64350L,64351L,64352L,64353L,64354L,64355L,64356L,64357L,\n64358L,64359L,64360L,64361L,64362L,64363L,64364L,64365L,64366L,64367L,\n64368L,64369L,64370L,64371L,64372L,64373L,64374L,64375L,64376L,64377L,\n64378L,64379L,64380L,64381L,64382L,64383L,64384L,64385L,64386L,64387L,\n64388L,64389L,64390L,64391L,64392L,64393L,64394L,64395L,64396L,64397L,\n64398L,64399L,64400L,64401L,64402L,64403L,64404L,64405L,64406L,64407L,\n64408L,64409L,64410L,64411L,64412L,64413L,64414L,64415L,64416L,64417L,\n64418L,64419L,64420L,64421L,64422L,64423L,64424L,64425L,64426L,64427L,\n64428L,64429L,64430L,64431L,64432L,64433L,64434L,64435L,64436L,64437L,\n64438L,64439L,64440L,64441L,64442L,64443L,64444L,64445L,64446L,64447L,\n64448L,64449L,64450L,64451L,64452L,64453L,64454L,64455L,64456L,64457L,\n64458L,64459L,64460L,64461L,64462L,64463L,64464L,64465L,64466L,64467L,\n64468L,64469L,64470L,64471L,64472L,64473L,64474L,64475L,64476L,64477L,\n64478L,64479L,64480L,64481L,64482L,64483L,64484L,64485L,64486L,64487L,\n64488L,64489L,64490L,64491L,64492L,64493L,64494L,64495L,64496L,64497L,\n64498L,64499L,64500L,64501L,64502L,64503L,64504L,64505L,64506L,64507L,\n64508L,64509L,64510L,64511L,64512L,64513L,64514L,64515L,64516L,64517L,\n64518L,64519L,64520L,64521L,64522L,64523L,64524L,64525L,64526L,64527L,\n64528L,64529L,64530L,64531L,64532L,64533L,64534L,64535L,64536L,64537L,\n64538L,64539L,64540L,64541L,64542L,64543L,64544L,64545L,64546L,64547L,\n64548L,64549L,64550L,64551L,64552L,64553L,64554L,64555L,64556L,64557L,\n64558L,64559L,64560L,64561L,64562L,64563L,64564L,64565L,64566L,64567L,\n64568L,64569L,64570L,64571L,64572L,64573L,64574L,64575L,64576L,64577L,\n64578L,64579L,64580L,64581L,64582L,64583L,64584L,64585L,64586L,64587L,\n64588L,64589L,64590L,64591L,64592L,64593L,64594L,64595L,64596L,64597L,\n64598L,64599L,64600L,64601L,64602L,64603L,64604L,64605L,64606L,64607L,\n64608L,64609L,64610L,64611L,64612L,64613L,64614L,64615L,64616L,64617L,\n64618L,64619L,64620L,64621L,64622L,64623L,64624L,64625L,64626L,64627L,\n64628L,64629L,64630L,64631L,64632L,64633L,64634L,64635L,64636L,64637L,\n64638L,64639L,64640L,64641L,64642L,64643L,64644L,64645L,64646L,64647L,\n64648L,64649L,64650L,64651L,64652L,64653L,64654L,64655L,64656L,64657L,\n64658L,64659L,64660L,64661L,64662L,64663L,64664L,64665L,64666L,64667L,\n64668L,64669L,64670L,64671L,64672L,64673L,64674L,64675L,64676L,64677L,\n64678L,64679L,64680L,64681L,64682L,64683L,64684L,64685L,64686L,64687L,\n64688L,64689L,64690L,64691L,64692L,64693L,64694L,64695L,64696L,64697L,\n64698L,64699L,64700L,64701L,64702L,64703L,64704L,64705L,64706L,64707L,\n64708L,64709L,64710L,64711L,64712L,64713L,64714L,64715L,64716L,64717L,\n64718L,64719L,64720L,64721L,64722L,64723L,64724L,64725L,64726L,64727L,\n64728L,64729L,64730L,64731L,64732L,64733L,64734L,64735L,64736L,64737L,\n64738L,64739L,64740L,64741L,64742L,64743L,64744L,64745L,64746L,64747L,\n64748L,64749L,64750L,64751L,64752L,64753L,64754L,64755L,64756L,64757L,\n64758L,64759L,64760L,64761L,64762L,64763L,64764L,64765L,64766L,64767L,\n64768L,64769L,64770L,64771L,64772L,64773L,64774L,64775L,64776L,64777L,\n64778L,64779L,64780L,64781L,64782L,64783L,64784L,64785L,64786L,64787L,\n64788L,64789L,64790L,64791L,64792L,64793L,64794L,64795L,64796L,64797L,\n64798L,64799L,64800L,64801L,64802L,64803L,64804L,64805L,64806L,64807L,\n64808L,64809L,64810L,64811L,64812L,64813L,64814L,64815L,64816L,64817L,\n64818L,64819L,64820L,64821L,64822L,64823L,64824L,64825L,64826L,64827L,\n64828L,64829L,64830L,64831L,64832L,64833L,64834L,64835L,64836L,64837L,\n64838L,64839L,64840L,64841L,64842L,64843L,64844L,64845L,64846L,64847L,\n64848L,64849L,64850L,64851L,64852L,64853L,64854L,64855L,64856L,64857L,\n64858L,64859L,64860L,64861L,64862L,64863L,64864L,64865L,64866L,64867L,\n64868L,64869L,64870L,64871L,64872L,64873L,64874L,64875L,64876L,64877L,\n64878L,64879L,64880L,64881L,64882L,64883L,64884L,64885L,64886L,64887L,\n64888L,64889L,64890L,64891L,64892L,64893L,64894L,64895L,64896L,64897L,\n64898L,64899L,64900L,64901L,64902L,64903L,64904L,64905L,64906L,64907L,\n64908L,64909L,64910L,64911L,64912L,64913L,64914L,64915L,64916L,64917L,\n64918L,64919L,64920L,64921L,64922L,64923L,64924L,64925L,64926L,64927L,\n64928L,64929L,64930L,64931L,64932L,64933L,64934L,64935L,64936L,64937L,\n64938L,64939L,64940L,64941L,64942L,64943L,64944L,64945L,64946L,64947L,\n64948L,64949L,64950L,64951L,64952L,64953L,64954L,64955L,64956L,64957L,\n64958L,64959L,64960L,64961L,64962L,64963L,64964L,64965L,64966L,64967L,\n64968L,64969L,64970L,64971L,64972L,64973L,64974L,64975L,64976L,64977L,\n64978L,64979L,64980L,64981L,64982L,64983L,64984L,64985L,64986L,64987L,\n64988L,64989L,64990L,64991L,64992L,64993L,64994L,64995L,64996L,64997L,\n64998L,64999L,65000L,65001L,65002L,65003L,65004L,65005L,65006L,65007L,\n65008L,65009L,65010L,65011L,65012L,65013L,65014L,65015L,65016L,65017L,\n65018L,65019L,65020L,65021L,65022L,65023L,65024L,65025L,65026L,65027L,\n65028L,65029L,65030L,65031L,65032L,65033L,65034L,65035L,65036L,65037L,\n65038L,65039L,65040L,65041L,65042L,65043L,65044L,65045L,65046L,65047L,\n65048L,65049L,65050L,65051L,65052L,65053L,65054L,65055L,65056L,65057L,\n65058L,65059L,65060L,65061L,65062L,65063L,65064L,65065L,65066L,65067L,\n65068L,65069L,65070L,65071L,65072L,65073L,65074L,65075L,65076L,65077L,\n65078L,65079L,65080L,65081L,65082L,65083L,65084L,65085L,65086L,65087L,\n65088L,65089L,65090L,65091L,65092L,65093L,65094L,65095L,65096L,65097L,\n65098L,65099L,65100L,65101L,65102L,65103L,65104L,65105L,65106L,65107L,\n65108L,65109L,65110L,65111L,65112L,65113L,65114L,65115L,65116L,65117L,\n65118L,65119L,65120L,65121L,65122L,65123L,65124L,65125L,65126L,65127L,\n65128L,65129L,65130L,65131L,65132L,65133L,65134L,65135L,65136L,65137L,\n65138L,65139L,65140L,65141L,65142L,65143L,65144L,65145L,65146L,65147L,\n65148L,65149L,65150L,65151L,65152L,65153L,65154L,65155L,65156L,65157L,\n65158L,65159L,65160L,65161L,65162L,65163L,65164L,65165L,65166L,65167L,\n65168L,65169L,65170L,65171L,65172L,65173L,65174L,65175L,65176L,65177L,\n65178L,65179L,65180L,65181L,65182L,65183L,65184L,65185L,65186L,65187L,\n65188L,65189L,65190L,65191L,65192L,65193L,65194L,65195L,65196L,65197L,\n65198L,65199L,65200L,65201L,65202L,65203L,65204L,65205L,65206L,65207L,\n65208L,65209L,65210L,65211L,65212L,65213L,65214L,65215L,65216L,65217L,\n65218L,65219L,65220L,65221L,65222L,65223L,65224L,65225L,65226L,65227L,\n65228L,65229L,65230L,65231L,65232L,65233L,65234L,65235L,65236L,65237L,\n65238L,65239L,65240L,65241L,65242L,65243L,65244L,65245L,65246L,65247L,\n65248L,65249L,65250L,65251L,65252L,65253L,65254L,65255L,65256L,65257L,\n65258L,65259L,65260L,65261L,65262L,65263L,65264L,65265L,65266L,65267L,\n65268L,65269L,65270L,65271L,65272L,65273L,65274L,65275L,65276L,65277L,\n65278L,65279L,65280L,65281L,65282L,65283L,65284L,65285L,65286L,65287L,\n65288L,65289L,65290L,65291L,65292L,65293L,65294L,65295L,65296L,65297L,\n65298L,65299L,65300L,65301L,65302L,65303L,65304L,65305L,65306L,65307L,\n65308L,65309L,65310L,65311L,65312L,65313L,65314L,65315L,65316L,65317L,\n65318L,65319L,65320L,65321L,65322L,65323L,65324L,65325L,65326L,65327L,\n65328L,65329L,65330L,65331L,65332L,65333L,65334L,65335L,65336L,65337L,\n65338L,65339L,65340L,65341L,65342L,65343L,65344L,65313L,65314L,65315L,\n65316L,65317L,65318L,65319L,65320L,65321L,65322L,65323L,65324L,65325L,\n65326L,65327L,65328L,65329L,65330L,65331L,65332L,65333L,65334L,65335L,\n65336L,65337L,65338L,65371L,65372L,65373L,65374L,65375L,65376L,65377L,\n65378L,65379L,65380L,65381L,65382L,65383L,65384L,65385L,65386L,65387L,\n65388L,65389L,65390L,65391L,65392L,65393L,65394L,65395L,65396L,65397L,\n65398L,65399L,65400L,65401L,65402L,65403L,65404L,65405L,65406L,65407L,\n65408L,65409L,65410L,65411L,65412L,65413L,65414L,65415L,65416L,65417L,\n65418L,65419L,65420L,65421L,65422L,65423L,65424L,65425L,65426L,65427L,\n65428L,65429L,65430L,65431L,65432L,65433L,65434L,65435L,65436L,65437L,\n65438L,65439L,65440L,65441L,65442L,65443L,65444L,65445L,65446L,65447L,\n65448L,65449L,65450L,65451L,65452L,65453L,65454L,65455L,65456L,65457L,\n65458L,65459L,65460L,65461L,65462L,65463L,65464L,65465L,65466L,65467L,\n65468L,65469L,65470L,65471L,65472L,65473L,65474L,65475L,65476L,65477L,\n65478L,65479L,65480L,65481L,65482L,65483L,65484L,65485L,65486L,65487L,\n65488L,65489L,65490L,65491L,65492L,65493L,65494L,65495L,65496L,65497L,\n65498L,65499L,65500L,65501L,65502L,65503L,65504L,65505L,65506L,65507L,\n65508L,65509L,65510L,65511L,65512L,65513L,65514L,65515L,65516L,65517L,\n65518L,65519L,65520L,65521L,65522L,65523L,65524L,65525L,65526L,65527L,\n65528L,65529L,65530L,65531L,65532L,65533L,65534L,65535L,\n};\n#endif\n/*\n *  Bitstream decoder.\n */\n\n/* #include duk_internal.h -> already included */\n\n/* Decode 'bits' bits from the input stream (bits must be 1...24).\n * When reading past bitstream end, zeroes are shifted in.  The result\n * is signed to match duk_bd_decode_flagged.\n */\nDUK_INTERNAL duk_uint32_t duk_bd_decode(duk_bitdecoder_ctx *ctx, duk_small_int_t bits) {\n\tduk_small_int_t shift;\n\tduk_uint32_t mask;\n\tduk_uint32_t tmp;\n\n\t/* Note: cannot read more than 24 bits without possibly shifting top bits out.\n\t * Fixable, but adds complexity.\n\t */\n\tDUK_ASSERT(bits >= 1 && bits <= 24);\n\n\twhile (ctx->currbits < bits) {\n#if 0\n\t\tDUK_DDD(DUK_DDDPRINT(\"decode_bits: shift more data (bits=%ld, currbits=%ld)\",\n\t\t                     (long) bits, (long) ctx->currbits));\n#endif\n\t\tctx->currval <<= 8;\n\t\tif (ctx->offset < ctx->length) {\n\t\t\t/* If ctx->offset >= ctx->length, we \"shift zeroes in\"\n\t\t\t * instead of croaking.\n\t\t\t */\n\t\t\tctx->currval |= ctx->data[ctx->offset++];\n\t\t}\n\t\tctx->currbits += 8;\n\t}\n#if 0\n\tDUK_DDD(DUK_DDDPRINT(\"decode_bits: bits=%ld, currbits=%ld, currval=0x%08lx\",\n\t                     (long) bits, (long) ctx->currbits, (unsigned long) ctx->currval));\n#endif\n\n\t/* Extract 'top' bits of currval; note that the extracted bits do not need\n\t * to be cleared, we just ignore them on next round.\n\t */\n\tshift = ctx->currbits - bits;\n\tmask = (1 << bits) - 1;\n\ttmp = (ctx->currval >> shift) & mask;\n\tctx->currbits = shift;  /* remaining */\n\n#if 0\n\tDUK_DDD(DUK_DDDPRINT(\"decode_bits: %ld bits -> 0x%08lx (%ld), currbits=%ld, currval=0x%08lx\",\n\t                     (long) bits, (unsigned long) tmp, (long) tmp, (long) ctx->currbits, (unsigned long) ctx->currval));\n#endif\n\n\treturn tmp;\n}\n\nDUK_INTERNAL duk_small_uint_t duk_bd_decode_flag(duk_bitdecoder_ctx *ctx) {\n\treturn (duk_small_uint_t) duk_bd_decode(ctx, 1);\n}\n\n/* Decode a one-bit flag, and if set, decode a value of 'bits', otherwise return\n * default value.\n */\nDUK_INTERNAL duk_uint32_t duk_bd_decode_flagged(duk_bitdecoder_ctx *ctx, duk_small_int_t bits, duk_uint32_t def_value) {\n\tif (duk_bd_decode_flag(ctx)) {\n\t\treturn duk_bd_decode(ctx, bits);\n\t} else {\n\t\treturn def_value;\n\t}\n}\n\n/* Signed variant, allows negative marker value. */\nDUK_INTERNAL duk_int32_t duk_bd_decode_flagged_signed(duk_bitdecoder_ctx *ctx, duk_small_int_t bits, duk_int32_t def_value) {\n\treturn (duk_int32_t) duk_bd_decode_flagged(ctx, bits, (duk_uint32_t) def_value);\n}\n\n/* Shared varint encoding.  Match dukutil.py BitEncode.varuint(). */\nDUK_INTERNAL duk_uint32_t duk_bd_decode_varuint(duk_bitdecoder_ctx *ctx) {\n\tduk_small_uint_t t;\n\n\t/* The bit encoding choices here are based on manual testing against\n\t * the actual varuints generated by genbuiltins.py.\n\t */\n\tswitch (duk_bd_decode(ctx, 2)) {\n\tcase 0:\n\t\treturn 0;  /* [0,0] */\n\tcase 1:\n\t\treturn duk_bd_decode(ctx, 2) + 1;  /* [1,4] */\n\tcase 2:\n\t\treturn duk_bd_decode(ctx, 5) + 5;  /* [5,36] */\n\tdefault:\n\t\tt = duk_bd_decode(ctx, 7);\n\t\tif (t == 0) {\n\t\t\treturn duk_bd_decode(ctx, 20);\n\t\t}\n\t\treturn (t - 1) + 37;  /* [37,163] */\n\t}\n}\n\n/* Decode a bit packed string from a custom format used by genbuiltins.py.\n * This function is here because it's used for both heap and thread inits.\n * Caller must supply the output buffer whose size is NOT checked!\n */\n\n#define DUK__BITPACK_LETTER_LIMIT  26\n#define DUK__BITPACK_LOOKUP1       26\n#define DUK__BITPACK_LOOKUP2       27\n#define DUK__BITPACK_SWITCH1       28\n#define DUK__BITPACK_SWITCH        29\n#define DUK__BITPACK_UNUSED1       30\n#define DUK__BITPACK_EIGHTBIT      31\n\nDUK_LOCAL const duk_uint8_t duk__bitpacked_lookup[16] = {\n\tDUK_ASC_0, DUK_ASC_1, DUK_ASC_2, DUK_ASC_3,\n\tDUK_ASC_4, DUK_ASC_5, DUK_ASC_6, DUK_ASC_7,\n\tDUK_ASC_8, DUK_ASC_9, DUK_ASC_UNDERSCORE, DUK_ASC_SPACE,\n\t0xff, 0x80, DUK_ASC_DOUBLEQUOTE, DUK_ASC_LCURLY\n};\n\nDUK_INTERNAL duk_small_uint_t duk_bd_decode_bitpacked_string(duk_bitdecoder_ctx *bd, duk_uint8_t *out) {\n\tduk_small_uint_t len;\n\tduk_small_uint_t mode;\n\tduk_small_uint_t t;\n\tduk_small_uint_t i;\n\n\tlen = duk_bd_decode(bd, 5);\n\tif (len == 31) {\n\t\tlen = duk_bd_decode(bd, 8);  /* Support up to 256 bytes; rare. */\n\t}\n\n\tmode = 32;  /* 0 = uppercase, 32 = lowercase (= 'a' - 'A') */\n\tfor (i = 0; i < len; i++) {\n\t\tt = duk_bd_decode(bd, 5);\n\t\tif (t < DUK__BITPACK_LETTER_LIMIT) {\n\t\t\tt = t + DUK_ASC_UC_A + mode;\n\t\t} else if (t == DUK__BITPACK_LOOKUP1) {\n\t\t\tt = duk__bitpacked_lookup[duk_bd_decode(bd, 3)];\n\t\t} else if (t == DUK__BITPACK_LOOKUP2) {\n\t\t\tt = duk__bitpacked_lookup[8 + duk_bd_decode(bd, 3)];\n\t\t} else if (t == DUK__BITPACK_SWITCH1) {\n\t\t\tt = duk_bd_decode(bd, 5);\n\t\t\tDUK_ASSERT_DISABLE(t >= 0);  /* unsigned */\n\t\t\tDUK_ASSERT(t <= 25);\n\t\t\tt = t + DUK_ASC_UC_A + (mode ^ 32);\n\t\t} else if (t == DUK__BITPACK_SWITCH) {\n\t\t\tmode = mode ^ 32;\n\t\t\tt = duk_bd_decode(bd, 5);\n\t\t\tDUK_ASSERT_DISABLE(t >= 0);\n\t\t\tDUK_ASSERT(t <= 25);\n\t\t\tt = t + DUK_ASC_UC_A + mode;\n\t\t} else if (t == DUK__BITPACK_EIGHTBIT) {\n\t\t\tt = duk_bd_decode(bd, 8);\n\t\t}\n\t\tout[i] = (duk_uint8_t) t;\n\t}\n\n\treturn len;\n}\n\n/* automatic undefs */\n#undef DUK__BITPACK_EIGHTBIT\n#undef DUK__BITPACK_LETTER_LIMIT\n#undef DUK__BITPACK_LOOKUP1\n#undef DUK__BITPACK_LOOKUP2\n#undef DUK__BITPACK_SWITCH\n#undef DUK__BITPACK_SWITCH1\n#undef DUK__BITPACK_UNUSED1\n/*\n *  Bitstream encoder.\n */\n\n/* #include duk_internal.h -> already included */\n\nDUK_INTERNAL void duk_be_encode(duk_bitencoder_ctx *ctx, duk_uint32_t data, duk_small_int_t bits) {\n\tduk_uint8_t tmp;\n\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(ctx->currbits < 8);\n\n\t/* This limitation would be fixable but adds unnecessary complexity. */\n\tDUK_ASSERT(bits >= 1 && bits <= 24);\n\n\tctx->currval = (ctx->currval << bits) | data;\n\tctx->currbits += bits;\n\n\twhile (ctx->currbits >= 8) {\n\t\tif (ctx->offset < ctx->length) {\n\t\t\ttmp = (duk_uint8_t) ((ctx->currval >> (ctx->currbits - 8)) & 0xff);\n\t\t\tctx->data[ctx->offset++] = tmp;\n\t\t} else {\n\t\t\t/* If buffer has been exhausted, truncate bitstream */\n\t\t\tctx->truncated = 1;\n\t\t}\n\n\t\tctx->currbits -= 8;\n\t}\n}\n\nDUK_INTERNAL void duk_be_finish(duk_bitencoder_ctx *ctx) {\n\tduk_small_int_t npad;\n\n\tDUK_ASSERT(ctx != NULL);\n\tDUK_ASSERT(ctx->currbits < 8);\n\n\tnpad = (duk_small_int_t) (8 - ctx->currbits);\n\tif (npad > 0) {\n\t\tduk_be_encode(ctx, 0, npad);\n\t}\n\tDUK_ASSERT(ctx->currbits == 0);\n}\n/*\n *  Fast buffer writer with spare management.\n */\n\n/* #include duk_internal.h -> already included */\n\n/*\n *  Macro support functions (use only macros in calling code)\n */\n\nDUK_LOCAL void duk__bw_update_ptrs(duk_hthread *thr, duk_bufwriter_ctx *bw_ctx, duk_size_t curr_offset, duk_size_t new_length) {\n\tduk_uint8_t *p;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(bw_ctx != NULL);\n\tDUK_UNREF(thr);\n\n\tp = (duk_uint8_t *) DUK_HBUFFER_DYNAMIC_GET_DATA_PTR(thr->heap, bw_ctx->buf);\n\tDUK_ASSERT(p != NULL || (DUK_HBUFFER_DYNAMIC_GET_SIZE(bw_ctx->buf) == 0 && curr_offset == 0 && new_length == 0));\n\tbw_ctx->p = p + curr_offset;\n\tbw_ctx->p_base = p;\n\tbw_ctx->p_limit = p + new_length;\n}\n\nDUK_INTERNAL void duk_bw_init(duk_hthread *thr, duk_bufwriter_ctx *bw_ctx, duk_hbuffer_dynamic *h_buf) {\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(bw_ctx != NULL);\n\tDUK_ASSERT(h_buf != NULL);\n\tDUK_UNREF(thr);\n\n\tbw_ctx->buf = h_buf;\n\tduk__bw_update_ptrs(thr, bw_ctx, 0, DUK_HBUFFER_DYNAMIC_GET_SIZE(h_buf));\n}\n\nDUK_INTERNAL void duk_bw_init_pushbuf(duk_hthread *thr, duk_bufwriter_ctx *bw_ctx, duk_size_t buf_size) {\n\tduk_context *ctx;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(bw_ctx != NULL);\n\tctx = (duk_context *) thr;\n\n\t(void) duk_push_dynamic_buffer(ctx, buf_size);\n\tbw_ctx->buf = (duk_hbuffer_dynamic *) duk_known_hbuffer(ctx, -1);\n\tduk__bw_update_ptrs(thr, bw_ctx, 0, buf_size);\n}\n\n/* Resize target buffer for requested size.  Called by the macro only when the\n * fast path test (= there is space) fails.\n */\nDUK_INTERNAL duk_uint8_t *duk_bw_resize(duk_hthread *thr, duk_bufwriter_ctx *bw_ctx, duk_size_t sz) {\n\tduk_size_t curr_off;\n\tduk_size_t add_sz;\n\tduk_size_t new_sz;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(bw_ctx != NULL);\n\n\t/* We could do this operation without caller updating bw_ctx->ptr,\n\t * but by writing it back here we can share code better.\n\t */\n\n\tcurr_off = (duk_size_t) (bw_ctx->p - bw_ctx->p_base);\n\tadd_sz = (curr_off >> DUK_BW_SPARE_SHIFT) + DUK_BW_SPARE_ADD;\n\tnew_sz = curr_off + sz + add_sz;\n\tif (DUK_UNLIKELY(new_sz < curr_off)) {\n\t\t/* overflow */\n\t\tDUK_ERROR_RANGE(thr, DUK_STR_BUFFER_TOO_LONG);\n\t\treturn NULL;  /* not reachable */\n\t}\n#if 0  /* for manual torture testing: tight allocation, useful with valgrind */\n\tnew_sz = curr_off + sz;\n#endif\n\n\t/* This is important to ensure dynamic buffer data pointer is not\n\t * NULL (which is possible if buffer size is zero), which in turn\n\t * causes portability issues with e.g. memmove() and memcpy().\n\t */\n\tDUK_ASSERT(new_sz >= 1);\n\n\tDUK_DD(DUK_DDPRINT(\"resize bufferwriter from %ld to %ld (add_sz=%ld)\", (long) curr_off, (long) new_sz, (long) add_sz));\n\n\tduk_hbuffer_resize(thr, bw_ctx->buf, new_sz);\n\tduk__bw_update_ptrs(thr, bw_ctx, curr_off, new_sz);\n\treturn bw_ctx->p;\n}\n\n/* Make buffer compact, matching current written size. */\nDUK_INTERNAL void duk_bw_compact(duk_hthread *thr, duk_bufwriter_ctx *bw_ctx) {\n\tduk_size_t len;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(bw_ctx != NULL);\n\tDUK_UNREF(thr);\n\n\tlen = (duk_size_t) (bw_ctx->p - bw_ctx->p_base);\n\tduk_hbuffer_resize(thr, bw_ctx->buf, len);\n\tduk__bw_update_ptrs(thr, bw_ctx, len, len);\n}\n\nDUK_INTERNAL void duk_bw_write_raw_slice(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t src_off, duk_size_t len) {\n\tduk_uint8_t *p_base;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(bw != NULL);\n\tDUK_ASSERT(src_off <= DUK_BW_GET_SIZE(thr, bw));\n\tDUK_ASSERT(len <= DUK_BW_GET_SIZE(thr, bw));\n\tDUK_ASSERT(src_off + len <= DUK_BW_GET_SIZE(thr, bw));\n\tDUK_UNREF(thr);\n\n\tp_base = bw->p_base;\n\tDUK_MEMCPY((void *) bw->p,\n\t           (const void *) (p_base + src_off),\n\t           (size_t) len);\n\tbw->p += len;\n}\n\nDUK_INTERNAL void duk_bw_write_ensure_slice(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t src_off, duk_size_t len) {\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(bw != NULL);\n\tDUK_ASSERT(src_off <= DUK_BW_GET_SIZE(thr, bw));\n\tDUK_ASSERT(len <= DUK_BW_GET_SIZE(thr, bw));\n\tDUK_ASSERT(src_off + len <= DUK_BW_GET_SIZE(thr, bw));\n\tDUK_UNREF(thr);\n\n\tDUK_BW_ENSURE(thr, bw, len);\n\tduk_bw_write_raw_slice(thr, bw, src_off, len);\n}\n\nDUK_INTERNAL void duk_bw_insert_raw_bytes(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t dst_off, const duk_uint8_t *buf, duk_size_t len) {\n\tduk_uint8_t *p_base;\n\tduk_size_t buf_sz, move_sz;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(bw != NULL);\n\tDUK_ASSERT(dst_off <= DUK_BW_GET_SIZE(thr, bw));\n\tDUK_ASSERT(buf != NULL);\n\tDUK_UNREF(thr);\n\n\tp_base = bw->p_base;\n\tbuf_sz = bw->p - p_base;\n\tmove_sz = buf_sz - dst_off;\n\n\tDUK_ASSERT(p_base != NULL);  /* buffer size is >= 1 */\n\tDUK_MEMMOVE((void *) (p_base + dst_off + len),\n\t            (const void *) (p_base + dst_off),\n\t            (size_t) move_sz);\n\tDUK_MEMCPY((void *) (p_base + dst_off),\n\t           (const void *) buf,\n\t           (size_t) len);\n\tbw->p += len;\n}\n\nDUK_INTERNAL void duk_bw_insert_ensure_bytes(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t dst_off, const duk_uint8_t *buf, duk_size_t len) {\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(bw != NULL);\n\tDUK_ASSERT(dst_off <= DUK_BW_GET_SIZE(thr, bw));\n\tDUK_ASSERT(buf != NULL);\n\tDUK_UNREF(thr);\n\n\tDUK_BW_ENSURE(thr, bw, len);\n\tduk_bw_insert_raw_bytes(thr, bw, dst_off, buf, len);\n}\n\nDUK_INTERNAL void duk_bw_insert_raw_slice(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t dst_off, duk_size_t src_off, duk_size_t len) {\n\tduk_uint8_t *p_base;\n\tduk_size_t buf_sz, move_sz;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(bw != NULL);\n\tDUK_ASSERT(dst_off <= DUK_BW_GET_SIZE(thr, bw));\n\tDUK_ASSERT(src_off <= DUK_BW_GET_SIZE(thr, bw));\n\tDUK_ASSERT(len <= DUK_BW_GET_SIZE(thr, bw));\n\tDUK_ASSERT(src_off + len <= DUK_BW_GET_SIZE(thr, bw));\n\tDUK_UNREF(thr);\n\n\tp_base = bw->p_base;\n\n\t/* Don't support \"straddled\" source now. */\n\tDUK_ASSERT(dst_off <= src_off || dst_off >= src_off + len);\n\n\tif (dst_off <= src_off) {\n\t\t/* Target is before source.  Source offset is expressed as\n\t\t * a \"before change\" offset.  Account for the memmove.\n\t\t */\n\t\tsrc_off += len;\n\t}\n\n\tbuf_sz = bw->p - p_base;\n\tmove_sz = buf_sz - dst_off;\n\n\tDUK_ASSERT(p_base != NULL);  /* buffer size is >= 1 */\n\tDUK_MEMMOVE((void *) (p_base + dst_off + len),\n\t            (const void *) (p_base + dst_off),\n\t            (size_t) move_sz);\n\tDUK_MEMCPY((void *) (p_base + dst_off),\n\t           (const void *) (p_base + src_off),\n\t           (size_t) len);\n\tbw->p += len;\n}\n\nDUK_INTERNAL void duk_bw_insert_ensure_slice(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t dst_off, duk_size_t src_off, duk_size_t len) {\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(bw != NULL);\n\tDUK_ASSERT(dst_off <= DUK_BW_GET_SIZE(thr, bw));\n\tDUK_ASSERT(src_off <= DUK_BW_GET_SIZE(thr, bw));\n\tDUK_ASSERT(len <= DUK_BW_GET_SIZE(thr, bw));\n\tDUK_ASSERT(src_off + len <= DUK_BW_GET_SIZE(thr, bw));\n\tDUK_UNREF(thr);\n\n\t/* Don't support \"straddled\" source now. */\n\tDUK_ASSERT(dst_off <= src_off || dst_off >= src_off + len);\n\n\tDUK_BW_ENSURE(thr, bw, len);\n\tduk_bw_insert_raw_slice(thr, bw, dst_off, src_off, len);\n}\n\nDUK_INTERNAL duk_uint8_t *duk_bw_insert_raw_area(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t off, duk_size_t len) {\n\tduk_uint8_t *p_base, *p_dst, *p_src;\n\tduk_size_t buf_sz, move_sz;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(bw != NULL);\n\tDUK_ASSERT(off <= DUK_BW_GET_SIZE(thr, bw));\n\tDUK_UNREF(thr);\n\n\tp_base = bw->p_base;\n\tbuf_sz = bw->p - p_base;\n\tmove_sz = buf_sz - off;\n\tp_dst = p_base + off + len;\n\tp_src = p_base + off;\n\tDUK_MEMMOVE((void *) p_dst, (const void *) p_src, (size_t) move_sz);\n\treturn p_src;  /* point to start of 'reserved area' */\n}\n\nDUK_INTERNAL duk_uint8_t *duk_bw_insert_ensure_area(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t off, duk_size_t len) {\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(bw != NULL);\n\tDUK_ASSERT(off <= DUK_BW_GET_SIZE(thr, bw));\n\tDUK_UNREF(thr);\n\n\tDUK_BW_ENSURE(thr, bw, len);\n\treturn duk_bw_insert_raw_area(thr, bw, off, len);\n}\n\nDUK_INTERNAL void duk_bw_remove_raw_slice(duk_hthread *thr, duk_bufwriter_ctx *bw, duk_size_t off, duk_size_t len) {\n\tduk_size_t move_sz;\n\n\tduk_uint8_t *p_base;\n\tduk_uint8_t *p_src;\n\tduk_uint8_t *p_dst;\n\n\tDUK_ASSERT(thr != NULL);\n\tDUK_ASSERT(bw != NULL);\n\tDUK_ASSERT(off <= DUK_BW_GET_SIZE(thr, bw));\n\tDUK_ASSERT(len <= DUK_BW_GET_SIZE(thr, bw));\n\tDUK_ASSERT(off + len <= DUK_BW_GET_SIZE(thr, bw));\n\tDUK_UNREF(thr);\n\n\tp_base = bw->p_base;\n\tp_dst = p_base + off;\n\tp_src = p_dst + len;\n\tmove_sz = (duk_size_t) (bw->p - p_src);\n\tDUK_MEMMOVE((void *) p_dst,\n\t            (const void *) p_src,\n\t            (size_t) move_sz);\n\tbw->p -= len;\n}\n\n/*\n *  Macro support functions for reading/writing raw data.\n *\n *  These are done using mempcy to ensure they're valid even for unaligned\n *  reads/writes on platforms where alignment counts.  On x86 at least gcc\n *  is able to compile these into a bswap+mov.  \"Always inline\" is used to\n *  ensure these macros compile to minimal code.\n *\n *  Not really bufwriter related, but currently used together.\n */\n\nDUK_INTERNAL DUK_ALWAYS_INLINE duk_uint16_t duk_raw_read_u16_be(duk_uint8_t **p) {\n\tunion {\n\t\tduk_uint8_t b[2];\n\t\tduk_uint16_t x;\n\t} u;\n\n\tDUK_MEMCPY((void *) u.b, (const void *) (*p), (size_t) 2);\n\tu.x = DUK_NTOH16(u.x);\n\t*p += 2;\n\treturn u.x;\n}\n\nDUK_INTERNAL DUK_ALWAYS_INLINE duk_uint32_t duk_raw_read_u32_be(duk_uint8_t **p) {\n\tunion {\n\t\tduk_uint8_t b[4];\n\t\tduk_uint32_t x;\n\t} u;\n\n\tDUK_MEMCPY((void *) u.b, (const void *) (*p), (size_t) 4);\n\tu.x = DUK_NTOH32(u.x);\n\t*p += 4;\n\treturn u.x;\n}\n\nDUK_INTERNAL DUK_ALWAYS_INLINE duk_double_t duk_raw_read_double_be(duk_uint8_t **p) {\n\tduk_double_union du;\n\tunion {\n\t\tduk_uint8_t b[4];\n\t\tduk_uint32_t x;\n\t} u;\n\n\tDUK_MEMCPY((void *) u.b, (const void *) (*p), (size_t) 4);\n\tu.x = DUK_NTOH32(u.x);\n\tdu.ui[DUK_DBL_IDX_UI0] = u.x;\n\tDUK_MEMCPY((void *) u.b, (const void *) (*p + 4), (size_t) 4);\n\tu.x = DUK_NTOH32(u.x);\n\tdu.ui[DUK_DBL_IDX_UI1] = u.x;\n\t*p += 8;\n\n\treturn du.d;\n}\n\nDUK_INTERNAL DUK_ALWAYS_INLINE void duk_raw_write_u16_be(duk_uint8_t **p, duk_uint16_t val) {\n\tunion {\n\t\tduk_uint8_t b[2];\n\t\tduk_uint16_t x;\n\t} u;\n\n\tu.x = DUK_HTON16(val);\n\tDUK_MEMCPY((void *) (*p), (const void *) u.b, (size_t) 2);\n\t*p += 2;\n}\n\nDUK_INTERNAL DUK_ALWAYS_INLINE void duk_raw_write_u32_be(duk_uint8_t **p, duk_uint32_t val) {\n\tunion {\n\t\tduk_uint8_t b[4];\n\t\tduk_uint32_t x;\n\t} u;\n\n\tu.x = DUK_HTON32(val);\n\tDUK_MEMCPY((void *) (*p), (const void *) u.b, (size_t) 4);\n\t*p += 4;\n}\n\nDUK_INTERNAL DUK_ALWAYS_INLINE void duk_raw_write_double_be(duk_uint8_t **p, duk_double_t val) {\n\tduk_double_union du;\n\tunion {\n\t\tduk_uint8_t b[4];\n\t\tduk_uint32_t x;\n\t} u;\n\n\tdu.d = val;\n\tu.x = du.ui[DUK_DBL_IDX_UI0];\n\tu.x = DUK_HTON32(u.x);\n\tDUK_MEMCPY((void *) (*p), (const void *) u.b, (size_t) 4);\n\tu.x = du.ui[DUK_DBL_IDX_UI1];\n\tu.x = DUK_HTON32(u.x);\n\tDUK_MEMCPY((void *) (*p + 4), (const void *) u.b, (size_t) 4);\n\t*p += 8;\n}\n/*\n *  Hash function duk_util_hashbytes().\n *\n *  Currently, 32-bit MurmurHash2.\n *\n *  Don't rely on specific hash values; hash function may be endianness\n *  dependent, for instance.\n */\n\n/* #include duk_internal.h -> already included */\n\n#if defined(DUK_USE_STRHASH_DENSE)\n/* 'magic' constants for Murmurhash2 */\n#define DUK__MAGIC_M  ((duk_uint32_t) 0x5bd1e995UL)\n#define DUK__MAGIC_R  24\n\nDUK_INTERNAL duk_uint32_t duk_util_hashbytes(const duk_uint8_t *data, duk_size_t len, duk_uint32_t seed) {\n\tduk_uint32_t h = seed ^ ((duk_uint32_t) len);\n\n\twhile (len >= 4) {\n\t\t/* Portability workaround is required for platforms without\n\t\t * unaligned access.  The replacement code emulates little\n\t\t * endian access even on big endian architectures, which is\n\t\t * OK as long as it is consistent for a build.\n\t\t */\n#if defined(DUK_USE_HASHBYTES_UNALIGNED_U32_ACCESS)\n\t\tduk_uint32_t k = *((const duk_uint32_t *) (const void *) data);\n#else\n\t\tduk_uint32_t k = ((duk_uint32_t) data[0]) |\n\t\t                 (((duk_uint32_t) data[1]) << 8) |\n\t\t                 (((duk_uint32_t) data[2]) << 16) |\n\t\t                 (((duk_uint32_t) data[3]) << 24);\n#endif\n\n\t\tk *= DUK__MAGIC_M;\n\t\tk ^= k >> DUK__MAGIC_R;\n\t\tk *= DUK__MAGIC_M;\n\t\th *= DUK__MAGIC_M;\n\t\th ^= k;\n\t\tdata += 4;\n\t\tlen -= 4;\n\t}\n\n\tswitch (len) {\n\tcase 3: h ^= data[2] << 16;\n\tcase 2: h ^= data[1] << 8;\n\tcase 1: h ^= data[0];\n\t        h *= DUK__MAGIC_M;\n        }\n\n\th ^= h >> 13;\n\th *= DUK__MAGIC_M;\n\th ^= h >> 15;\n\n\treturn h;\n}\n#endif  /* DUK_USE_STRHASH_DENSE */\n\n/* automatic undefs */\n#undef DUK__MAGIC_M\n#undef DUK__MAGIC_R\n/*\n *  A tiny random number generator used for Math.random() and other internals.\n *\n *  Default algorithm is xoroshiro128+: http://xoroshiro.di.unimi.it/xoroshiro128plus.c\n *  with SplitMix64 seed preparation: http://xorshift.di.unimi.it/splitmix64.c.\n *\n *  Low memory targets and targets without 64-bit types use a slightly smaller\n *  (but slower) algorithm by Adi Shamir:\n *  http://www.woodmann.com/forum/archive/index.php/t-3100.html.\n *\n */\n\n/* #include duk_internal.h -> already included */\n\n#if !defined(DUK_USE_GET_RANDOM_DOUBLE)\n\n#if defined(DUK_USE_PREFER_SIZE) || !defined(DUK_USE_64BIT_OPS)\n#define DUK__RANDOM_SHAMIR3OP\n#else\n#define DUK__RANDOM_XOROSHIRO128PLUS\n#endif\n\n#if defined(DUK__RANDOM_SHAMIR3OP)\n#define DUK__UPDATE_RND(rnd) do { \\\n\t\t(rnd) += ((rnd) * (rnd)) | 0x05UL; \\\n\t\t(rnd) = ((rnd) & 0xffffffffUL);       /* if duk_uint32_t is exactly 32 bits, this is a NOP */ \\\n\t} while (0)\n\n#define DUK__RND_BIT(rnd)  ((rnd) >> 31)  /* only use the highest bit */\n\nDUK_INTERNAL void duk_util_tinyrandom_prepare_seed(duk_hthread *thr) {\n\tDUK_UNREF(thr);  /* Nothing now. */\n}\n\nDUK_INTERNAL duk_double_t duk_util_tinyrandom_get_double(duk_hthread *thr) {\n\tduk_double_t t;\n\tduk_small_int_t n;\n\tduk_uint32_t rnd;\n\n\trnd = thr->heap->rnd_state;\n\n\tn = 53;  /* enough to cover the whole mantissa */\n\tt = 0.0;\n\n\tdo {\n\t\tDUK__UPDATE_RND(rnd);\n\t\tt += DUK__RND_BIT(rnd);\n\t\tt /= 2.0;\n\t} while (--n);\n\n\tthr->heap->rnd_state = rnd;\n\n\tDUK_ASSERT(t >= (duk_double_t) 0.0);\n\tDUK_ASSERT(t < (duk_double_t) 1.0);\n\n\treturn t;\n}\n#endif  /* DUK__RANDOM_SHAMIR3OP */\n\n#if defined(DUK__RANDOM_XOROSHIRO128PLUS)\nDUK_LOCAL DUK_ALWAYS_INLINE duk_uint64_t duk__rnd_splitmix64(duk_uint64_t *x) {\n\tduk_uint64_t z;\n\tz = (*x += 0x9E3779B97F4A7C15ULL);\n\tz = (z ^ (z >> 30U)) * 0xBF58476D1CE4E5B9ULL;\n\tz = (z ^ (z >> 27U)) * 0x94D049BB133111EBULL;\n\treturn z ^ (z >> 31U);\n}\n\nDUK_LOCAL DUK_ALWAYS_INLINE duk_uint64_t duk__rnd_rotl(const duk_uint64_t x, duk_small_uint_t k) {\n\treturn (x << k) | (x >> (64U - k));\n}\n\nDUK_LOCAL DUK_ALWAYS_INLINE duk_uint64_t duk__xoroshiro128plus(duk_uint64_t *s) {\n\tduk_uint64_t s0;\n\tduk_uint64_t s1;\n\tduk_uint64_t res;\n\n\ts0 = s[0];\n\ts1 = s[1];\n\tres = s0 + s1;\n\ts1 ^= s0;\n\ts[0] = duk__rnd_rotl(s0, 55) ^ s1 ^ (s1 << 14U);\n\ts[1] = duk__rnd_rotl(s1, 36);\n\n\treturn res;\n}\n\nDUK_INTERNAL void duk_util_tinyrandom_prepare_seed(duk_hthread *thr) {\n\tduk_small_uint_t i;\n\tduk_uint64_t x;\n\n\t/* Mix both halves of the initial seed with SplitMix64.  The intent\n\t * is to ensure that very similar raw seeds (which is usually the case\n\t * because current seed is Date.now()) result in different xoroshiro128+\n\t * seeds.\n\t */\n\tx = thr->heap->rnd_state[0];  /* Only [0] is used as input here. */\n\tfor (i = 0; i < 64; i++) {\n\t\tthr->heap->rnd_state[i & 0x01] = duk__rnd_splitmix64(&x);  /* Keep last 2 values. */\n\t}\n}\n\nDUK_INTERNAL duk_double_t duk_util_tinyrandom_get_double(duk_hthread *thr) {\n\tduk_uint64_t v;\n\tduk_double_union du;\n\n\t/* For big and little endian the integer and IEEE double byte order\n\t * is the same so a direct assignment works.  For mixed endian the\n\t * 32-bit parts must be swapped.\n\t */\n\tv = (0x3ffULL << 52U) | (duk__xoroshiro128plus((duk_uint64_t *) thr->heap->rnd_state) >> 12U);\n\tdu.ull[0] = v;\n#if defined(DUK_USE_DOUBLE_ME)\n\tdo {\n\t\tduk_uint32_t tmp;\n\t\ttmp = du.ui[0];\n\t\tdu.ui[0] = du.ui[1];\n\t\tdu.ui[1] = tmp;\n\t} while (0);\n#endif\n\treturn du.d - 1.0;\n}\n#endif  /* DUK__RANDOM_XOROSHIRO128PLUS */\n\n#endif  /* !DUK_USE_GET_RANDOM_DOUBLE */\n\n/* automatic undefs */\n#undef DUK__RANDOM_SHAMIR3OP\n#undef DUK__RANDOM_XOROSHIRO128PLUS\n#undef DUK__RND_BIT\n#undef DUK__UPDATE_RND\n"
  },
  {
    "path": "ext/duktape/duktape-2.1.0/src/duktape.h",
    "content": "/*\n *  Duktape public API for Duktape 2.1.0.\n *\n *  See the API reference for documentation on call semantics.  The exposed,\n *  supported API is between the \"BEGIN PUBLIC API\" and \"END PUBLIC API\"\n *  comments.  Other parts of the header are Duktape internal and related to\n *  e.g. platform/compiler/feature detection.\n *\n *  Git commit 1f1f51a4f9595ffe8def0e9ba45b20f14679393a (v2.1.0).\n *  Git branch master.\n *\n *  See Duktape AUTHORS.rst and LICENSE.txt for copyright and\n *  licensing information.\n */\n\n/* LICENSE.txt */\n/*\n *  ===============\n *  Duktape license\n *  ===============\n *  \n *  (http://opensource.org/licenses/MIT)\n *  \n *  Copyright (c) 2013-2017 by Duktape authors (see AUTHORS.rst)\n *  \n *  Permission is hereby granted, free of charge, to any person obtaining a copy\n *  of this software and associated documentation files (the \"Software\"), to deal\n *  in the Software without restriction, including without limitation the rights\n *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n *  copies of the Software, and to permit persons to whom the Software is\n *  furnished to do so, subject to the following conditions:\n *  \n *  The above copyright notice and this permission notice shall be included in\n *  all copies or substantial portions of the Software.\n *  \n *  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n *  THE SOFTWARE.\n */\n\n/* AUTHORS.rst */\n/*\n *  ===============\n *  Duktape authors\n *  ===============\n *  \n *  Copyright\n *  =========\n *  \n *  Duktape copyrights are held by its authors.  Each author has a copyright\n *  to their contribution, and agrees to irrevocably license the contribution\n *  under the Duktape ``LICENSE.txt``.\n *  \n *  Authors\n *  =======\n *  \n *  Please include an e-mail address, a link to your GitHub profile, or something\n *  similar to allow your contribution to be identified accurately.\n *  \n *  The following people have contributed code, website contents, or Wiki contents,\n *  and agreed to irrevocably license their contributions under the Duktape\n *  ``LICENSE.txt`` (in order of appearance):\n *  \n *  * Sami Vaarala <sami.vaarala@iki.fi>\n *  * Niki Dobrev\n *  * Andreas \\u00d6man <andreas@lonelycoder.com>\n *  * L\\u00e1szl\\u00f3 Lang\\u00f3 <llango.u-szeged@partner.samsung.com>\n *  * Legimet <legimet.calc@gmail.com>\n *  * Karl Skomski <karl@skomski.com>\n *  * Bruce Pascoe <fatcerberus1@gmail.com>\n *  * Ren\\u00e9 Hollander <rene@rene8888.at>\n *  * Julien Hamaide (https://github.com/crazyjul)\n *  * Sebastian G\\u00f6tte (https://github.com/jaseg)\n *  * Tomasz Magulski (https://github.com/magul)\n *  * \\D. Bohdan (https://github.com/dbohdan)\n *  * Ond\\u0159ej Jirman (https://github.com/megous)\n *  * Sa\\u00fal Ibarra Corretg\\u00e9 <saghul@gmail.com>\n *  * Jeremy HU <huxingyi@msn.com>\n *  * Ole Andr\\u00e9 Vadla Ravn\\u00e5s (https://github.com/oleavr)\n *  * Harold Brenes (https://github.com/harold-b)\n *  * Oliver Crow (https://github.com/ocrow)\n *  * Jakub Ch\\u0142api\\u0144ski (https://github.com/jchlapinski)\n *  * Brett Vickers (https://github.com/beevik)\n *  * Dominik Okwieka (https://github.com/okitec)\n *  * Remko Tron\\u00e7on (https://el-tramo.be)\n *  * Romero Malaquias (rbsm@ic.ufal.br)\n *  * Michael Drake <michael.drake@codethink.co.uk>\n *  \n *  Other contributions\n *  ===================\n *  \n *  The following people have contributed something other than code (e.g. reported\n *  bugs, provided ideas, etc; roughly in order of appearance):\n *  \n *  * Greg Burns\n *  * Anthony Rabine\n *  * Carlos Costa\n *  * Aur\\u00e9lien Bouilland\n *  * Preet Desai (Pris Matic)\n *  * judofyr (http://www.reddit.com/user/judofyr)\n *  * Jason Woofenden\n *  * Micha\\u0142 Przyby\\u015b\n *  * Anthony Howe\n *  * Conrad Pankoff\n *  * Jim Schimpf\n *  * Rajaran Gaunker (https://github.com/zimbabao)\n *  * Andreas \\u00d6man\n *  * Doug Sanden\n *  * Josh Engebretson (https://github.com/JoshEngebretson)\n *  * Remo Eichenberger (https://github.com/remoe)\n *  * Mamod Mehyar (https://github.com/mamod)\n *  * David Demelier (https://github.com/markand)\n *  * Tim Caswell (https://github.com/creationix)\n *  * Mitchell Blank Jr (https://github.com/mitchblank)\n *  * https://github.com/yushli\n *  * Seo Sanghyeon (https://github.com/sanxiyn)\n *  * Han ChoongWoo (https://github.com/tunz)\n *  * Joshua Peek (https://github.com/josh)\n *  * Bruce E. Pascoe (https://github.com/fatcerberus)\n *  * https://github.com/Kelledin\n *  * https://github.com/sstruchtrup\n *  * Michael Drake (https://github.com/tlsa)\n *  * https://github.com/chris-y\n *  * Laurent Zubiaur (https://github.com/lzubiaur)\n *  * Neil Kolban (https://github.com/nkolban)\n *  \n *  If you are accidentally missing from this list, send me an e-mail\n *  (``sami.vaarala@iki.fi``) and I'll fix the omission.\n */\n\n#if !defined(DUKTAPE_H_INCLUDED)\n#define DUKTAPE_H_INCLUDED\n\n#define DUK_SINGLE_FILE\n\n/*\n *  BEGIN PUBLIC API\n */\n\n/*\n *  Version and Git commit identification\n */\n\n/* Duktape version, (major * 10000) + (minor * 100) + patch.  Allows C code\n * to #if (DUK_VERSION >= NNN) against Duktape API version.  The same value\n * is also available to Ecmascript code in Duktape.version.  Unofficial\n * development snapshots have 99 for patch level (e.g. 0.10.99 would be a\n * development version after 0.10.0 but before the next official release).\n */\n#define DUK_VERSION                       20100L\n\n/* Git commit, describe, and branch for Duktape build.  Useful for\n * non-official snapshot builds so that application code can easily log\n * which Duktape snapshot was used.  Not available in the Ecmascript\n * environment.\n */\n#define DUK_GIT_COMMIT                    \"1f1f51a4f9595ffe8def0e9ba45b20f14679393a\"\n#define DUK_GIT_DESCRIBE                  \"v2.1.0\"\n#define DUK_GIT_BRANCH                    \"master\"\n\n/* External duk_config.h provides platform/compiler/OS dependent\n * typedefs and macros, and DUK_USE_xxx config options so that\n * the rest of Duktape doesn't need to do any feature detection.\n * DUK_VERSION is defined before including so that configuration\n * snippets can react to it.\n */\n#include \"duk_config.h\"\n\n/*\n *  Avoid C++ name mangling\n */\n\n#if defined(__cplusplus)\nextern \"C\" {\n#endif\n\n/*\n *  Some defines forwarded from feature detection\n */\n\n#undef DUK_API_VARIADIC_MACROS\n#if defined(DUK_USE_VARIADIC_MACROS)\n#define DUK_API_VARIADIC_MACROS\n#endif\n\n#define DUK_API_NORETURN(decl) DUK_NORETURN(decl)\n\n/*\n *  Public API specific typedefs\n *\n *  Many types are wrapped by Duktape for portability to rare platforms\n *  where e.g. 'int' is a 16-bit type.  See practical typing discussion\n *  in Duktape web documentation.\n */\n\nstruct duk_thread_state;\nstruct duk_memory_functions;\nstruct duk_function_list_entry;\nstruct duk_number_list_entry;\nstruct duk_time_components;\n\n/* duk_context is now defined in duk_config.h because it may also be\n * referenced there by prototypes.\n */\ntypedef struct duk_thread_state duk_thread_state;\ntypedef struct duk_memory_functions duk_memory_functions;\ntypedef struct duk_function_list_entry duk_function_list_entry;\ntypedef struct duk_number_list_entry duk_number_list_entry;\ntypedef struct duk_time_components duk_time_components;\n\ntypedef duk_ret_t (*duk_c_function)(duk_context *ctx);\ntypedef void *(*duk_alloc_function) (void *udata, duk_size_t size);\ntypedef void *(*duk_realloc_function) (void *udata, void *ptr, duk_size_t size);\ntypedef void (*duk_free_function) (void *udata, void *ptr);\ntypedef void (*duk_fatal_function) (void *udata, const char *msg);\ntypedef void (*duk_decode_char_function) (void *udata, duk_codepoint_t codepoint);\ntypedef duk_codepoint_t (*duk_map_char_function) (void *udata, duk_codepoint_t codepoint);\ntypedef duk_ret_t (*duk_safe_call_function) (duk_context *ctx, void *udata);\ntypedef duk_size_t (*duk_debug_read_function) (void *udata, char *buffer, duk_size_t length);\ntypedef duk_size_t (*duk_debug_write_function) (void *udata, const char *buffer, duk_size_t length);\ntypedef duk_size_t (*duk_debug_peek_function) (void *udata);\ntypedef void (*duk_debug_read_flush_function) (void *udata);\ntypedef void (*duk_debug_write_flush_function) (void *udata);\ntypedef duk_idx_t (*duk_debug_request_function) (duk_context *ctx, void *udata, duk_idx_t nvalues);\ntypedef void (*duk_debug_detached_function) (duk_context *ctx, void *udata);\n\nstruct duk_thread_state {\n\t/* XXX: Enough space to hold internal suspend/resume structure.\n\t * This is rather awkward and to be fixed when the internal\n\t * structure is visible for the public API header.\n\t */\n\tchar data[128];\n};\n\nstruct duk_memory_functions {\n\tduk_alloc_function alloc_func;\n\tduk_realloc_function realloc_func;\n\tduk_free_function free_func;\n\tvoid *udata;\n};\n\nstruct duk_function_list_entry {\n\tconst char *key;\n\tduk_c_function value;\n\tduk_idx_t nargs;\n};\n\nstruct duk_number_list_entry {\n\tconst char *key;\n\tduk_double_t value;\n};\n\nstruct duk_time_components {\n\tduk_double_t year;          /* year, e.g. 2016, Ecmascript year range */\n\tduk_double_t month;         /* month: 1-12 */\n\tduk_double_t day;           /* day: 1-31 */\n\tduk_double_t hours;         /* hour: 0-59 */\n\tduk_double_t minutes;       /* minute: 0-59 */\n\tduk_double_t seconds;       /* second: 0-59 (in POSIX time no leap second) */\n\tduk_double_t milliseconds;  /* may contain sub-millisecond fractions */\n\tduk_double_t weekday;       /* weekday: 0-6, 0=Sunday, 1=Monday, ..., 6=Saturday */\n};\n\n/*\n *  Constants\n */\n\n/* Duktape debug protocol version used by this build. */\n#define DUK_DEBUG_PROTOCOL_VERSION        2\n\n/* Used to represent invalid index; if caller uses this without checking,\n * this index will map to a non-existent stack entry.  Also used in some\n * API calls as a marker to denote \"no value\".\n */\n#define DUK_INVALID_INDEX                 DUK_IDX_MIN\n\n/* Indicates that a native function does not have a fixed number of args,\n * and the argument stack should not be capped/extended at all.\n */\n#define DUK_VARARGS                       ((duk_int_t) (-1))\n\n/* Number of value stack entries (in addition to actual call arguments)\n * guaranteed to be allocated on entry to a Duktape/C function.\n */\n#define DUK_API_ENTRY_STACK               64\n\n/* Value types, used by e.g. duk_get_type() */\n#define DUK_TYPE_MIN                      0\n#define DUK_TYPE_NONE                     0    /* no value, e.g. invalid index */\n#define DUK_TYPE_UNDEFINED                1    /* Ecmascript undefined */\n#define DUK_TYPE_NULL                     2    /* Ecmascript null */\n#define DUK_TYPE_BOOLEAN                  3    /* Ecmascript boolean: 0 or 1 */\n#define DUK_TYPE_NUMBER                   4    /* Ecmascript number: double */\n#define DUK_TYPE_STRING                   5    /* Ecmascript string: CESU-8 / extended UTF-8 encoded */\n#define DUK_TYPE_OBJECT                   6    /* Ecmascript object: includes objects, arrays, functions, threads */\n#define DUK_TYPE_BUFFER                   7    /* fixed or dynamic, garbage collected byte buffer */\n#define DUK_TYPE_POINTER                  8    /* raw void pointer */\n#define DUK_TYPE_LIGHTFUNC                9    /* lightweight function pointer */\n#define DUK_TYPE_MAX                      9\n\n/* Value mask types, used by e.g. duk_get_type_mask() */\n#define DUK_TYPE_MASK_NONE                (1 << DUK_TYPE_NONE)\n#define DUK_TYPE_MASK_UNDEFINED           (1 << DUK_TYPE_UNDEFINED)\n#define DUK_TYPE_MASK_NULL                (1 << DUK_TYPE_NULL)\n#define DUK_TYPE_MASK_BOOLEAN             (1 << DUK_TYPE_BOOLEAN)\n#define DUK_TYPE_MASK_NUMBER              (1 << DUK_TYPE_NUMBER)\n#define DUK_TYPE_MASK_STRING              (1 << DUK_TYPE_STRING)\n#define DUK_TYPE_MASK_OBJECT              (1 << DUK_TYPE_OBJECT)\n#define DUK_TYPE_MASK_BUFFER              (1 << DUK_TYPE_BUFFER)\n#define DUK_TYPE_MASK_POINTER             (1 << DUK_TYPE_POINTER)\n#define DUK_TYPE_MASK_LIGHTFUNC           (1 << DUK_TYPE_LIGHTFUNC)\n#define DUK_TYPE_MASK_THROW               (1 << 10)  /* internal flag value: throw if mask doesn't match */\n#define DUK_TYPE_MASK_PROMOTE             (1 << 11)  /* internal flag value: promote to object if mask matches */\n\n/* Coercion hints */\n#define DUK_HINT_NONE                     0    /* prefer number, unless input is a Date, in which\n                                                * case prefer string (E5 Section 8.12.8)\n                                                */\n#define DUK_HINT_STRING                   1    /* prefer string */\n#define DUK_HINT_NUMBER                   2    /* prefer number */\n\n/* Enumeration flags for duk_enum() */\n#define DUK_ENUM_INCLUDE_NONENUMERABLE    (1 << 0)    /* enumerate non-numerable properties in addition to enumerable */\n#define DUK_ENUM_INCLUDE_HIDDEN           (1 << 1)    /* enumerate hidden symbols too (in Duktape 1.x called internal properties) */\n#define DUK_ENUM_INCLUDE_SYMBOLS          (1 << 2)    /* enumerate symbols */\n#define DUK_ENUM_EXCLUDE_STRINGS          (1 << 3)    /* exclude strings */\n#define DUK_ENUM_OWN_PROPERTIES_ONLY      (1 << 4)    /* don't walk prototype chain, only check own properties */\n#define DUK_ENUM_ARRAY_INDICES_ONLY       (1 << 5)    /* only enumerate array indices */\n#define DUK_ENUM_SORT_ARRAY_INDICES       (1 << 6)    /* sort array indices (applied to full enumeration result, including inherited array indices) */\n#define DUK_ENUM_NO_PROXY_BEHAVIOR        (1 << 7)    /* enumerate a proxy object itself without invoking proxy behavior */\n\n/* Compilation flags for duk_compile() and duk_eval() */\n/* DUK_COMPILE_xxx bits 0-2 are reserved for an internal 'nargs' argument.\n */\n#define DUK_COMPILE_EVAL                  (1 << 3)    /* compile eval code (instead of global code) */\n#define DUK_COMPILE_FUNCTION              (1 << 4)    /* compile function code (instead of global code) */\n#define DUK_COMPILE_STRICT                (1 << 5)    /* use strict (outer) context for global, eval, or function code */\n#define DUK_COMPILE_SHEBANG               (1 << 6)    /* allow shebang ('#! ...') comment on first line of source */\n#define DUK_COMPILE_SAFE                  (1 << 7)    /* (internal) catch compilation errors */\n#define DUK_COMPILE_NORESULT              (1 << 8)    /* (internal) omit eval result */\n#define DUK_COMPILE_NOSOURCE              (1 << 9)    /* (internal) no source string on stack */\n#define DUK_COMPILE_STRLEN                (1 << 10)   /* (internal) take strlen() of src_buffer (avoids double evaluation in macro) */\n#define DUK_COMPILE_NOFILENAME            (1 << 11)   /* (internal) no filename on stack */\n#define DUK_COMPILE_FUNCEXPR              (1 << 12)   /* (internal) source is a function expression (used for Function constructor) */\n\n/* Flags for duk_def_prop() and its variants */\n#define DUK_DEFPROP_WRITABLE              (1 << 0)    /* set writable (effective if DUK_DEFPROP_HAVE_WRITABLE set) */\n#define DUK_DEFPROP_ENUMERABLE            (1 << 1)    /* set enumerable (effective if DUK_DEFPROP_HAVE_ENUMERABLE set) */\n#define DUK_DEFPROP_CONFIGURABLE          (1 << 2)    /* set configurable (effective if DUK_DEFPROP_HAVE_CONFIGURABLE set) */\n#define DUK_DEFPROP_HAVE_WRITABLE         (1 << 3)    /* set/clear writable */\n#define DUK_DEFPROP_HAVE_ENUMERABLE       (1 << 4)    /* set/clear enumerable */\n#define DUK_DEFPROP_HAVE_CONFIGURABLE     (1 << 5)    /* set/clear configurable */\n#define DUK_DEFPROP_HAVE_VALUE            (1 << 6)    /* set value (given on value stack) */\n#define DUK_DEFPROP_HAVE_GETTER           (1 << 7)    /* set getter (given on value stack) */\n#define DUK_DEFPROP_HAVE_SETTER           (1 << 8)    /* set setter (given on value stack) */\n#define DUK_DEFPROP_FORCE                 (1 << 9)    /* force change if possible, may still fail for e.g. virtual properties */\n#define DUK_DEFPROP_SET_WRITABLE          (DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_WRITABLE)\n#define DUK_DEFPROP_CLEAR_WRITABLE        DUK_DEFPROP_HAVE_WRITABLE\n#define DUK_DEFPROP_SET_ENUMERABLE        (DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE)\n#define DUK_DEFPROP_CLEAR_ENUMERABLE      DUK_DEFPROP_HAVE_ENUMERABLE\n#define DUK_DEFPROP_SET_CONFIGURABLE      (DUK_DEFPROP_HAVE_CONFIGURABLE | DUK_DEFPROP_CONFIGURABLE)\n#define DUK_DEFPROP_CLEAR_CONFIGURABLE    DUK_DEFPROP_HAVE_CONFIGURABLE\n\n/* Flags for duk_push_thread_raw() */\n#define DUK_THREAD_NEW_GLOBAL_ENV         (1 << 0)    /* create a new global environment */\n\n/* Flags for duk_gc() */\n#define DUK_GC_COMPACT                    (1 << 0)    /* compact heap objects */\n\n/* Error codes (must be 8 bits at most, see duk_error.h) */\n#define DUK_ERR_NONE                      0    /* no error (e.g. from duk_get_error_code()) */\n#define DUK_ERR_ERROR                     1    /* Error */\n#define DUK_ERR_EVAL_ERROR                2    /* EvalError */\n#define DUK_ERR_RANGE_ERROR               3    /* RangeError */\n#define DUK_ERR_REFERENCE_ERROR           4    /* ReferenceError */\n#define DUK_ERR_SYNTAX_ERROR              5    /* SyntaxError */\n#define DUK_ERR_TYPE_ERROR                6    /* TypeError */\n#define DUK_ERR_URI_ERROR                 7    /* URIError */\n\n/* Return codes for C functions (shortcut for throwing an error) */\n#define DUK_RET_ERROR                     (-DUK_ERR_ERROR)\n#define DUK_RET_EVAL_ERROR                (-DUK_ERR_EVAL_ERROR)\n#define DUK_RET_RANGE_ERROR               (-DUK_ERR_RANGE_ERROR)\n#define DUK_RET_REFERENCE_ERROR           (-DUK_ERR_REFERENCE_ERROR)\n#define DUK_RET_SYNTAX_ERROR              (-DUK_ERR_SYNTAX_ERROR)\n#define DUK_RET_TYPE_ERROR                (-DUK_ERR_TYPE_ERROR)\n#define DUK_RET_URI_ERROR                 (-DUK_ERR_URI_ERROR)\n\n/* Return codes for protected calls (duk_safe_call(), duk_pcall()) */\n#define DUK_EXEC_SUCCESS                  0\n#define DUK_EXEC_ERROR                    1\n\n/* Debug levels for DUK_USE_DEBUG_WRITE(). */\n#define DUK_LEVEL_DEBUG                   0\n#define DUK_LEVEL_DDEBUG                  1\n#define DUK_LEVEL_DDDEBUG                 2\n\n/*\n *  If no variadic macros, __FILE__ and __LINE__ are passed through globals\n *  which is ugly and not thread safe.\n */\n\n#if !defined(DUK_API_VARIADIC_MACROS)\nDUK_EXTERNAL_DECL const char *duk_api_global_filename;\nDUK_EXTERNAL_DECL duk_int_t duk_api_global_line;\n#endif\n\n/*\n *  Context management\n */\n\nDUK_EXTERNAL_DECL\nduk_context *duk_create_heap(duk_alloc_function alloc_func,\n                             duk_realloc_function realloc_func,\n                             duk_free_function free_func,\n                             void *heap_udata,\n                             duk_fatal_function fatal_handler);\nDUK_EXTERNAL_DECL void duk_destroy_heap(duk_context *ctx);\n\nDUK_EXTERNAL_DECL void duk_suspend(duk_context *ctx, duk_thread_state *state);\nDUK_EXTERNAL_DECL void duk_resume(duk_context *ctx, const duk_thread_state *state);\n\n#define duk_create_heap_default() \\\n\tduk_create_heap(NULL, NULL, NULL, NULL, NULL)\n\n/*\n *  Memory management\n *\n *  Raw functions have no side effects (cannot trigger GC).\n */\n\nDUK_EXTERNAL_DECL void *duk_alloc_raw(duk_context *ctx, duk_size_t size);\nDUK_EXTERNAL_DECL void duk_free_raw(duk_context *ctx, void *ptr);\nDUK_EXTERNAL_DECL void *duk_realloc_raw(duk_context *ctx, void *ptr, duk_size_t size);\nDUK_EXTERNAL_DECL void *duk_alloc(duk_context *ctx, duk_size_t size);\nDUK_EXTERNAL_DECL void duk_free(duk_context *ctx, void *ptr);\nDUK_EXTERNAL_DECL void *duk_realloc(duk_context *ctx, void *ptr, duk_size_t size);\nDUK_EXTERNAL_DECL void duk_get_memory_functions(duk_context *ctx, duk_memory_functions *out_funcs);\nDUK_EXTERNAL_DECL void duk_gc(duk_context *ctx, duk_uint_t flags);\n\n/*\n *  Error handling\n */\n\nDUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_throw_raw(duk_context *ctx));\n#define duk_throw(ctx) \\\n\t(duk_throw_raw((ctx)), (duk_ret_t) 0)\nDUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_fatal_raw(duk_context *ctx, const char *err_msg));\n#define duk_fatal(ctx,err_msg) \\\n\t(duk_fatal_raw((ctx), (err_msg)), (duk_ret_t) 0)\nDUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_error_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, ...));\n\n#if defined(DUK_API_VARIADIC_MACROS)\n#define duk_error(ctx,err_code,...)  \\\n\t(duk_error_raw((ctx), (duk_errcode_t) (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)\n#define duk_generic_error(ctx,...)  \\\n\t(duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)\n#define duk_eval_error(ctx,...)  \\\n\t(duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_EVAL_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)\n#define duk_range_error(ctx,...)  \\\n\t(duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_RANGE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)\n#define duk_reference_error(ctx,...)  \\\n\t(duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_REFERENCE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)\n#define duk_syntax_error(ctx,...)  \\\n\t(duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_SYNTAX_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)\n#define duk_type_error(ctx,...)  \\\n\t(duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_TYPE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)\n#define duk_uri_error(ctx,...)  \\\n\t(duk_error_raw((ctx), (duk_errcode_t) DUK_ERR_URI_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__), (duk_ret_t) 0)\n#else  /* DUK_API_VARIADIC_MACROS */\n/* For legacy compilers without variadic macros a macro hack is used to allow\n * variable arguments.  While the macro allows \"return duk_error(...)\", it\n * will fail with e.g. \"(void) duk_error(...)\".  The calls are noreturn but\n * with a return value to allow the \"return duk_error(...)\" idiom.  This may\n * cause some compiler warnings, but without noreturn the generated code is\n * often worse.  The same approach as with variadic macros (using\n * \"(duk_error(...), 0)\") won't work due to the macro hack structure.\n */\nDUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_error_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt, ...));\nDUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_generic_error_stash(duk_context *ctx, const char *fmt, ...));\nDUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_eval_error_stash(duk_context *ctx, const char *fmt, ...));\nDUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_range_error_stash(duk_context *ctx, const char *fmt, ...));\nDUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_reference_error_stash(duk_context *ctx, const char *fmt, ...));\nDUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_syntax_error_stash(duk_context *ctx, const char *fmt, ...));\nDUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_type_error_stash(duk_context *ctx, const char *fmt, ...));\nDUK_API_NORETURN(DUK_EXTERNAL_DECL duk_ret_t duk_uri_error_stash(duk_context *ctx, const char *fmt, ...));\n#define duk_error  \\\n\t(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \\\n\t duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \\\n\t duk_error_stash)  /* last value is func pointer, arguments follow in parens */\n#define duk_generic_error  \\\n\t(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \\\n\t duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \\\n\t duk_generic_error_stash)\n#define duk_eval_error  \\\n\t(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \\\n\t duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \\\n\t duk_eval_error_stash)\n#define duk_range_error  \\\n\t(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \\\n\t duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \\\n\t duk_range_error_stash)\n#define duk_reference_error  \\\n\t(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \\\n\t duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \\\n\t duk_reference_error_stash)\n#define duk_syntax_error  \\\n\t(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \\\n\t duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \\\n\t duk_syntax_error_stash)\n#define duk_type_error  \\\n\t(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \\\n\t duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \\\n\t duk_type_error_stash)\n#define duk_uri_error  \\\n\t(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \\\n\t duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \\\n\t duk_uri_error_stash)\n#endif  /* DUK_API_VARIADIC_MACROS */\n\nDUK_API_NORETURN(DUK_EXTERNAL_DECL void duk_error_va_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, va_list ap));\n\n#define duk_error_va(ctx,err_code,fmt,ap)  \\\n\t(duk_error_va_raw((ctx), (duk_errcode_t) (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)\n#define duk_generic_error_va(ctx,fmt,ap)  \\\n\t(duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)\n#define duk_eval_error_va(ctx,fmt,ap)  \\\n\t(duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_EVAL_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)\n#define duk_range_error_va(ctx,fmt,ap)  \\\n\t(duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_RANGE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)\n#define duk_reference_error_va(ctx,fmt,ap)  \\\n\t(duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_REFERENCE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)\n#define duk_syntax_error_va(ctx,fmt,ap)  \\\n\t(duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_SYNTAX_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)\n#define duk_type_error_va(ctx,fmt,ap)  \\\n\t(duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_TYPE_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)\n#define duk_uri_error_va(ctx,fmt,ap)  \\\n\t(duk_error_va_raw((ctx), (duk_errcode_t) DUK_ERR_URI_ERROR, (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap)), (duk_ret_t) 0)\n\n/*\n *  Other state related functions\n */\n\nDUK_EXTERNAL_DECL duk_bool_t duk_is_strict_call(duk_context *ctx);\nDUK_EXTERNAL_DECL duk_bool_t duk_is_constructor_call(duk_context *ctx);\n\n/*\n *  Stack management\n */\n\nDUK_EXTERNAL_DECL duk_idx_t duk_normalize_index(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_idx_t duk_require_normalize_index(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_is_valid_index(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL void duk_require_valid_index(duk_context *ctx, duk_idx_t idx);\n\nDUK_EXTERNAL_DECL duk_idx_t duk_get_top(duk_context *ctx);\nDUK_EXTERNAL_DECL void duk_set_top(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_idx_t duk_get_top_index(duk_context *ctx);\nDUK_EXTERNAL_DECL duk_idx_t duk_require_top_index(duk_context *ctx);\n\n/* Although extra/top could be an unsigned type here, using a signed type\n * makes the API more robust to calling code calculation errors or corner\n * cases (where caller might occasionally come up with negative values).\n * Negative values are treated as zero, which is better than casting them\n * to a large unsigned number.  (This principle is used elsewhere in the\n * API too.)\n */\nDUK_EXTERNAL_DECL duk_bool_t duk_check_stack(duk_context *ctx, duk_idx_t extra);\nDUK_EXTERNAL_DECL void duk_require_stack(duk_context *ctx, duk_idx_t extra);\nDUK_EXTERNAL_DECL duk_bool_t duk_check_stack_top(duk_context *ctx, duk_idx_t top);\nDUK_EXTERNAL_DECL void duk_require_stack_top(duk_context *ctx, duk_idx_t top);\n\n/*\n *  Stack manipulation (other than push/pop)\n */\n\nDUK_EXTERNAL_DECL void duk_swap(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);\nDUK_EXTERNAL_DECL void duk_swap_top(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL void duk_dup(duk_context *ctx, duk_idx_t from_idx);\nDUK_EXTERNAL_DECL void duk_dup_top(duk_context *ctx);\nDUK_EXTERNAL_DECL void duk_insert(duk_context *ctx, duk_idx_t to_idx);\nDUK_EXTERNAL_DECL void duk_replace(duk_context *ctx, duk_idx_t to_idx);\nDUK_EXTERNAL_DECL void duk_copy(duk_context *ctx, duk_idx_t from_idx, duk_idx_t to_idx);\nDUK_EXTERNAL_DECL void duk_remove(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL void duk_xcopymove_raw(duk_context *to_ctx, duk_context *from_ctx, duk_idx_t count, duk_bool_t is_copy);\n\n#define duk_xmove_top(to_ctx,from_ctx,count) \\\n\tduk_xcopymove_raw((to_ctx), (from_ctx), (count), 0 /*is_copy*/)\n#define duk_xcopy_top(to_ctx,from_ctx,count) \\\n\tduk_xcopymove_raw((to_ctx), (from_ctx), (count), 1 /*is_copy*/)\n\n/*\n *  Push operations\n *\n *  Push functions return the absolute (relative to bottom of frame)\n *  position of the pushed value for convenience.\n *\n *  Note: duk_dup() is technically a push.\n */\n\nDUK_EXTERNAL_DECL void duk_push_undefined(duk_context *ctx);\nDUK_EXTERNAL_DECL void duk_push_null(duk_context *ctx);\nDUK_EXTERNAL_DECL void duk_push_boolean(duk_context *ctx, duk_bool_t val);\nDUK_EXTERNAL_DECL void duk_push_true(duk_context *ctx);\nDUK_EXTERNAL_DECL void duk_push_false(duk_context *ctx);\nDUK_EXTERNAL_DECL void duk_push_number(duk_context *ctx, duk_double_t val);\nDUK_EXTERNAL_DECL void duk_push_nan(duk_context *ctx);\nDUK_EXTERNAL_DECL void duk_push_int(duk_context *ctx, duk_int_t val);\nDUK_EXTERNAL_DECL void duk_push_uint(duk_context *ctx, duk_uint_t val);\nDUK_EXTERNAL_DECL const char *duk_push_string(duk_context *ctx, const char *str);\nDUK_EXTERNAL_DECL const char *duk_push_lstring(duk_context *ctx, const char *str, duk_size_t len);\nDUK_EXTERNAL_DECL void duk_push_pointer(duk_context *ctx, void *p);\nDUK_EXTERNAL_DECL const char *duk_push_sprintf(duk_context *ctx, const char *fmt, ...);\nDUK_EXTERNAL_DECL const char *duk_push_vsprintf(duk_context *ctx, const char *fmt, va_list ap);\n\nDUK_EXTERNAL_DECL void duk_push_this(duk_context *ctx);\nDUK_EXTERNAL_DECL void duk_push_current_function(duk_context *ctx);\nDUK_EXTERNAL_DECL void duk_push_current_thread(duk_context *ctx);\nDUK_EXTERNAL_DECL void duk_push_global_object(duk_context *ctx);\nDUK_EXTERNAL_DECL void duk_push_heap_stash(duk_context *ctx);\nDUK_EXTERNAL_DECL void duk_push_global_stash(duk_context *ctx);\nDUK_EXTERNAL_DECL void duk_push_thread_stash(duk_context *ctx, duk_context *target_ctx);\n\nDUK_EXTERNAL_DECL duk_idx_t duk_push_object(duk_context *ctx);\nDUK_EXTERNAL_DECL duk_idx_t duk_push_bare_object(duk_context *ctx);\nDUK_EXTERNAL_DECL duk_idx_t duk_push_array(duk_context *ctx);\nDUK_EXTERNAL_DECL duk_idx_t duk_push_c_function(duk_context *ctx, duk_c_function func, duk_idx_t nargs);\nDUK_EXTERNAL_DECL duk_idx_t duk_push_c_lightfunc(duk_context *ctx, duk_c_function func, duk_idx_t nargs, duk_idx_t length, duk_int_t magic);\nDUK_EXTERNAL_DECL duk_idx_t duk_push_thread_raw(duk_context *ctx, duk_uint_t flags);\n\n#define duk_push_thread(ctx) \\\n\tduk_push_thread_raw((ctx), 0 /*flags*/)\n\n#define duk_push_thread_new_globalenv(ctx) \\\n\tduk_push_thread_raw((ctx), DUK_THREAD_NEW_GLOBAL_ENV /*flags*/)\n\nDUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, ...);\n\n#if defined(DUK_API_VARIADIC_MACROS)\n#define duk_push_error_object(ctx,err_code,...)  \\\n\tduk_push_error_object_raw((ctx), (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), __VA_ARGS__)\n#else\nDUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_stash(duk_context *ctx, duk_errcode_t err_code, const char *fmt, ...);\n/* Note: parentheses are required so that the comma expression works in assignments. */\n#define duk_push_error_object  \\\n\t(duk_api_global_filename = (const char *) (DUK_FILE_MACRO), \\\n\t duk_api_global_line = (duk_int_t) (DUK_LINE_MACRO), \\\n\t duk_push_error_object_stash)  /* last value is func pointer, arguments follow in parens */\n#endif\n\nDUK_EXTERNAL_DECL duk_idx_t duk_push_error_object_va_raw(duk_context *ctx, duk_errcode_t err_code, const char *filename, duk_int_t line, const char *fmt, va_list ap);\n#define duk_push_error_object_va(ctx,err_code,fmt,ap)  \\\n\tduk_push_error_object_va_raw((ctx), (err_code), (const char *) (DUK_FILE_MACRO), (duk_int_t) (DUK_LINE_MACRO), (fmt), (ap))\n\n#define DUK_BUF_FLAG_DYNAMIC   (1 << 0)    /* internal flag: dynamic buffer */\n#define DUK_BUF_FLAG_EXTERNAL  (1 << 1)    /* internal flag: external buffer */\n#define DUK_BUF_FLAG_NOZERO    (1 << 2)    /* internal flag: don't zero allocated buffer */\n\nDUK_EXTERNAL_DECL void *duk_push_buffer_raw(duk_context *ctx, duk_size_t size, duk_small_uint_t flags);\n\n#define duk_push_buffer(ctx,size,dynamic) \\\n\tduk_push_buffer_raw((ctx), (size), (dynamic) ? DUK_BUF_FLAG_DYNAMIC : 0)\n#define duk_push_fixed_buffer(ctx,size) \\\n\tduk_push_buffer_raw((ctx), (size), 0 /*flags*/)\n#define duk_push_dynamic_buffer(ctx,size) \\\n\tduk_push_buffer_raw((ctx), (size), DUK_BUF_FLAG_DYNAMIC /*flags*/)\n#define duk_push_external_buffer(ctx) \\\n\t((void) duk_push_buffer_raw((ctx), 0, DUK_BUF_FLAG_DYNAMIC | DUK_BUF_FLAG_EXTERNAL))\n\n#define DUK_BUFOBJ_ARRAYBUFFER         0\n#define DUK_BUFOBJ_NODEJS_BUFFER       1\n#define DUK_BUFOBJ_DATAVIEW            2\n#define DUK_BUFOBJ_INT8ARRAY           3\n#define DUK_BUFOBJ_UINT8ARRAY          4\n#define DUK_BUFOBJ_UINT8CLAMPEDARRAY   5\n#define DUK_BUFOBJ_INT16ARRAY          6\n#define DUK_BUFOBJ_UINT16ARRAY         7\n#define DUK_BUFOBJ_INT32ARRAY          8\n#define DUK_BUFOBJ_UINT32ARRAY         9\n#define DUK_BUFOBJ_FLOAT32ARRAY        10\n#define DUK_BUFOBJ_FLOAT64ARRAY        11\n\nDUK_EXTERNAL_DECL void duk_push_buffer_object(duk_context *ctx, duk_idx_t idx_buffer, duk_size_t byte_offset, duk_size_t byte_length, duk_uint_t flags);\n\nDUK_EXTERNAL_DECL duk_idx_t duk_push_heapptr(duk_context *ctx, void *ptr);\n\n/*\n *  Pop operations\n */\n\nDUK_EXTERNAL_DECL void duk_pop(duk_context *ctx);\nDUK_EXTERNAL_DECL void duk_pop_n(duk_context *ctx, duk_idx_t count);\nDUK_EXTERNAL_DECL void duk_pop_2(duk_context *ctx);\nDUK_EXTERNAL_DECL void duk_pop_3(duk_context *ctx);\n\n/*\n *  Type checks\n *\n *  duk_is_none(), which would indicate whether index it outside of stack,\n *  is not needed; duk_is_valid_index() gives the same information.\n */\n\nDUK_EXTERNAL_DECL duk_int_t duk_get_type(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_check_type(duk_context *ctx, duk_idx_t idx, duk_int_t type);\nDUK_EXTERNAL_DECL duk_uint_t duk_get_type_mask(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_check_type_mask(duk_context *ctx, duk_idx_t idx, duk_uint_t mask);\n\nDUK_EXTERNAL_DECL duk_bool_t duk_is_undefined(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_is_null(duk_context *ctx, duk_idx_t idx);\n#define duk_is_null_or_undefined(ctx, idx) \\\n\t((duk_get_type_mask((ctx), (idx)) & (DUK_TYPE_MASK_NULL | DUK_TYPE_MASK_UNDEFINED)) ? 1 : 0)\n\nDUK_EXTERNAL_DECL duk_bool_t duk_is_boolean(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_is_number(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_is_nan(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_is_string(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_is_object(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_is_buffer(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_is_buffer_data(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_is_pointer(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_is_lightfunc(duk_context *ctx, duk_idx_t idx);\n\nDUK_EXTERNAL_DECL duk_bool_t duk_is_symbol(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_is_array(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_is_function(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_is_c_function(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_is_ecmascript_function(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_is_bound_function(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_is_thread(duk_context *ctx, duk_idx_t idx);\n\n#define duk_is_callable(ctx,idx) \\\n\tduk_is_function((ctx), (idx))\nDUK_EXTERNAL_DECL duk_bool_t duk_is_dynamic_buffer(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_is_fixed_buffer(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_is_external_buffer(duk_context *ctx, duk_idx_t idx);\n\n/* Buffers and lightfuncs are not considered primitive because they mimic\n * objects and e.g. duk_to_primitive() will coerce them instead of returning\n * them as is.  Symbols are represented as strings internally.\n */\n#define duk_is_primitive(ctx,idx) \\\n\tduk_check_type_mask((ctx), (idx), DUK_TYPE_MASK_UNDEFINED | \\\n\t                                  DUK_TYPE_MASK_NULL | \\\n\t                                  DUK_TYPE_MASK_BOOLEAN | \\\n\t                                  DUK_TYPE_MASK_NUMBER | \\\n\t                                  DUK_TYPE_MASK_STRING | \\\n\t                                  DUK_TYPE_MASK_POINTER)\n\n/* Symbols are object coercible, covered by DUK_TYPE_MASK_STRING. */\n#define duk_is_object_coercible(ctx,idx) \\\n\tduk_check_type_mask((ctx), (idx), DUK_TYPE_MASK_BOOLEAN | \\\n\t                                  DUK_TYPE_MASK_NUMBER | \\\n\t                                  DUK_TYPE_MASK_STRING | \\\n\t                                  DUK_TYPE_MASK_OBJECT | \\\n\t                                  DUK_TYPE_MASK_BUFFER | \\\n\t                                  DUK_TYPE_MASK_POINTER | \\\n\t                                  DUK_TYPE_MASK_LIGHTFUNC)\n\nDUK_EXTERNAL_DECL duk_errcode_t duk_get_error_code(duk_context *ctx, duk_idx_t idx);\n#define duk_is_error(ctx,idx) \\\n\t(duk_get_error_code((ctx), (idx)) != 0)\n#define duk_is_eval_error(ctx,idx) \\\n\t(duk_get_error_code((ctx), (idx)) == DUK_ERR_EVAL_ERROR)\n#define duk_is_range_error(ctx,idx) \\\n\t(duk_get_error_code((ctx), (idx)) == DUK_ERR_RANGE_ERROR)\n#define duk_is_reference_error(ctx,idx) \\\n\t(duk_get_error_code((ctx), (idx)) == DUK_ERR_REFERENCE_ERROR)\n#define duk_is_syntax_error(ctx,idx) \\\n\t(duk_get_error_code((ctx), (idx)) == DUK_ERR_SYNTAX_ERROR)\n#define duk_is_type_error(ctx,idx) \\\n\t(duk_get_error_code((ctx), (idx)) == DUK_ERR_TYPE_ERROR)\n#define duk_is_uri_error(ctx,idx) \\\n\t(duk_get_error_code((ctx), (idx)) == DUK_ERR_URI_ERROR)\n\n/*\n *  Get operations: no coercion, returns default value for invalid\n *  indices and invalid value types.\n *\n *  duk_get_undefined() and duk_get_null() would be pointless and\n *  are not included.\n */\n\nDUK_EXTERNAL_DECL duk_bool_t duk_get_boolean(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_double_t duk_get_number(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_int_t duk_get_int(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_uint_t duk_get_uint(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL const char *duk_get_string(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL const char *duk_get_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len);\nDUK_EXTERNAL_DECL void *duk_get_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);\nDUK_EXTERNAL_DECL void *duk_get_buffer_data(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);\nDUK_EXTERNAL_DECL void *duk_get_pointer(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_c_function duk_get_c_function(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_context *duk_get_context(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL void *duk_get_heapptr(duk_context *ctx, duk_idx_t idx);\n\n/*\n *  Get-with-explicit default operations: like get operations but with an\n *  explicit default value.\n */\n\nDUK_EXTERNAL_DECL duk_bool_t duk_get_boolean_default(duk_context *ctx, duk_idx_t idx, duk_bool_t def_value);\nDUK_EXTERNAL_DECL duk_double_t duk_get_number_default(duk_context *ctx, duk_idx_t idx, duk_double_t def_value);\nDUK_EXTERNAL_DECL duk_int_t duk_get_int_default(duk_context *ctx, duk_idx_t idx, duk_int_t def_value);\nDUK_EXTERNAL_DECL duk_uint_t duk_get_uint_default(duk_context *ctx, duk_idx_t idx, duk_uint_t def_value);\nDUK_EXTERNAL_DECL const char *duk_get_string_default(duk_context *ctx, duk_idx_t idx, const char *def_value);\nDUK_EXTERNAL_DECL const char *duk_get_lstring_default(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len, const char *def_ptr, duk_size_t def_len);\nDUK_EXTERNAL_DECL void *duk_get_buffer_default(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size, void *def_ptr, duk_size_t def_len);\nDUK_EXTERNAL_DECL void *duk_get_buffer_data_default(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size, void *def_ptr, duk_size_t def_len);\nDUK_EXTERNAL_DECL void *duk_get_pointer_default(duk_context *ctx, duk_idx_t idx, void *def_value);\nDUK_EXTERNAL_DECL duk_c_function duk_get_c_function_default(duk_context *ctx, duk_idx_t idx, duk_c_function def_value);\nDUK_EXTERNAL_DECL duk_context *duk_get_context_default(duk_context *ctx, duk_idx_t idx, duk_context *def_value);\nDUK_EXTERNAL_DECL void *duk_get_heapptr_default(duk_context *ctx, duk_idx_t idx, void *def_value);\n\n/*\n *  Opt operations: like require operations but with an explicit default value\n *  when value is undefined or index is invalid, null and non-matching types\n *  cause a TypeError.\n */\n\nDUK_EXTERNAL_DECL duk_bool_t duk_opt_boolean(duk_context *ctx, duk_idx_t idx, duk_bool_t def_value);\nDUK_EXTERNAL_DECL duk_double_t duk_opt_number(duk_context *ctx, duk_idx_t idx, duk_double_t def_value);\nDUK_EXTERNAL_DECL duk_int_t duk_opt_int(duk_context *ctx, duk_idx_t idx, duk_int_t def_value);\nDUK_EXTERNAL_DECL duk_uint_t duk_opt_uint(duk_context *ctx, duk_idx_t idx, duk_uint_t def_value);\nDUK_EXTERNAL_DECL const char *duk_opt_string(duk_context *ctx, duk_idx_t idx, const char *def_ptr);\nDUK_EXTERNAL_DECL const char *duk_opt_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len, const char *def_ptr, duk_size_t def_len);\nDUK_EXTERNAL_DECL void *duk_opt_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size, void *def_ptr, duk_size_t def_size);\nDUK_EXTERNAL_DECL void *duk_opt_buffer_data(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size, void *def_ptr, duk_size_t def_size);\nDUK_EXTERNAL_DECL void *duk_opt_pointer(duk_context *ctx, duk_idx_t idx, void *def_value);\nDUK_EXTERNAL_DECL duk_c_function duk_opt_c_function(duk_context *ctx, duk_idx_t idx, duk_c_function def_value);\nDUK_EXTERNAL_DECL duk_context *duk_opt_context(duk_context *ctx, duk_idx_t idx, duk_context *def_value);\nDUK_EXTERNAL_DECL void *duk_opt_heapptr(duk_context *ctx, duk_idx_t idx, void *def_value);\n\n/*\n *  Require operations: no coercion, throw error if index or type\n *  is incorrect.  No defaulting.\n */\n\n#define duk_require_type_mask(ctx,idx,mask) \\\n\t((void) duk_check_type_mask((ctx), (idx), (mask) | DUK_TYPE_MASK_THROW))\n\nDUK_EXTERNAL_DECL void duk_require_undefined(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL void duk_require_null(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_require_boolean(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_double_t duk_require_number(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_int_t duk_require_int(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_uint_t duk_require_uint(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL const char *duk_require_string(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL const char *duk_require_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len);\nDUK_EXTERNAL_DECL void *duk_require_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);\nDUK_EXTERNAL_DECL void *duk_require_buffer_data(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);\nDUK_EXTERNAL_DECL void *duk_require_pointer(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_c_function duk_require_c_function(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_context *duk_require_context(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL void duk_require_function(duk_context *ctx, duk_idx_t idx);\n#define duk_require_callable(ctx,idx) \\\n\tduk_require_function((ctx), (idx))\nDUK_EXTERNAL_DECL void *duk_require_heapptr(duk_context *ctx, duk_idx_t idx);\n\n/* Symbols are object coercible and covered by DUK_TYPE_MASK_STRING. */\n#define duk_require_object_coercible(ctx,idx) \\\n\t((void) duk_check_type_mask((ctx), (idx), DUK_TYPE_MASK_BOOLEAN | \\\n\t                                            DUK_TYPE_MASK_NUMBER | \\\n\t                                            DUK_TYPE_MASK_STRING | \\\n\t                                            DUK_TYPE_MASK_OBJECT | \\\n\t                                            DUK_TYPE_MASK_BUFFER | \\\n\t                                            DUK_TYPE_MASK_POINTER | \\\n\t                                            DUK_TYPE_MASK_LIGHTFUNC | \\\n\t                                            DUK_TYPE_MASK_THROW))\n\n/*\n *  Coercion operations: in-place coercion, return coerced value where\n *  applicable.  If index is invalid, throw error.  Some coercions may\n *  throw an expected error (e.g. from a toString() or valueOf() call)\n *  or an internal error (e.g. from out of memory).\n */\n\nDUK_EXTERNAL_DECL void duk_to_undefined(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL void duk_to_null(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_to_boolean(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_double_t duk_to_number(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_int_t duk_to_int(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_uint_t duk_to_uint(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_int32_t duk_to_int32(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_uint32_t duk_to_uint32(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_uint16_t duk_to_uint16(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL const char *duk_to_string(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL const char *duk_to_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len);\nDUK_EXTERNAL_DECL void *duk_to_buffer_raw(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size, duk_uint_t flags);\nDUK_EXTERNAL_DECL void *duk_to_pointer(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL void duk_to_object(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL void duk_to_primitive(duk_context *ctx, duk_idx_t idx, duk_int_t hint);\n\n#define DUK_BUF_MODE_FIXED      0   /* internal: request fixed buffer result */\n#define DUK_BUF_MODE_DYNAMIC    1   /* internal: request dynamic buffer result */\n#define DUK_BUF_MODE_DONTCARE   2   /* internal: don't care about fixed/dynamic nature */\n\n#define duk_to_buffer(ctx,idx,out_size) \\\n\tduk_to_buffer_raw((ctx), (idx), (out_size), DUK_BUF_MODE_DONTCARE)\n#define duk_to_fixed_buffer(ctx,idx,out_size) \\\n\tduk_to_buffer_raw((ctx), (idx), (out_size), DUK_BUF_MODE_FIXED)\n#define duk_to_dynamic_buffer(ctx,idx,out_size) \\\n\tduk_to_buffer_raw((ctx), (idx), (out_size), DUK_BUF_MODE_DYNAMIC)\n\n/* safe variants of a few coercion operations */\nDUK_EXTERNAL_DECL const char *duk_safe_to_lstring(duk_context *ctx, duk_idx_t idx, duk_size_t *out_len);\n#define duk_safe_to_string(ctx,idx) \\\n\tduk_safe_to_lstring((ctx), (idx), NULL)\n\n/*\n *  Value length\n */\n\nDUK_EXTERNAL_DECL duk_size_t duk_get_length(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL void duk_set_length(duk_context *ctx, duk_idx_t idx, duk_size_t len);\n#if 0\n/* duk_require_length()? */\n/* duk_opt_length()? */\n#endif\n\n/*\n *  Misc conversion\n */\n\nDUK_EXTERNAL_DECL const char *duk_base64_encode(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL void duk_base64_decode(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL const char *duk_hex_encode(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL void duk_hex_decode(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL const char *duk_json_encode(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL void duk_json_decode(duk_context *ctx, duk_idx_t idx);\n\nDUK_EXTERNAL_DECL const char *duk_buffer_to_string(duk_context *ctx, duk_idx_t idx);\n\n/*\n *  Buffer\n */\n\nDUK_EXTERNAL_DECL void *duk_resize_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t new_size);\nDUK_EXTERNAL_DECL void *duk_steal_buffer(duk_context *ctx, duk_idx_t idx, duk_size_t *out_size);\nDUK_EXTERNAL_DECL void duk_config_buffer(duk_context *ctx, duk_idx_t idx, void *ptr, duk_size_t len);\n\n/*\n *  Property access\n *\n *  The basic function assumes key is on stack.  The _string variant takes\n *  a C string as a property name, while the _index variant takes an array\n *  index as a property name (e.g. 123 is equivalent to the key \"123\").\n */\n\nDUK_EXTERNAL_DECL duk_bool_t duk_get_prop(duk_context *ctx, duk_idx_t obj_idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_get_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key);\nDUK_EXTERNAL_DECL duk_bool_t duk_get_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len);\nDUK_EXTERNAL_DECL duk_bool_t duk_get_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_put_prop(duk_context *ctx, duk_idx_t obj_idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_put_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key);\nDUK_EXTERNAL_DECL duk_bool_t duk_put_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len);\nDUK_EXTERNAL_DECL duk_bool_t duk_put_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_del_prop(duk_context *ctx, duk_idx_t obj_idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_del_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key);\nDUK_EXTERNAL_DECL duk_bool_t duk_del_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len);\nDUK_EXTERNAL_DECL duk_bool_t duk_del_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_has_prop(duk_context *ctx, duk_idx_t obj_idx);\nDUK_EXTERNAL_DECL duk_bool_t duk_has_prop_string(duk_context *ctx, duk_idx_t obj_idx, const char *key);\nDUK_EXTERNAL_DECL duk_bool_t duk_has_prop_lstring(duk_context *ctx, duk_idx_t obj_idx, const char *key, duk_size_t key_len);\nDUK_EXTERNAL_DECL duk_bool_t duk_has_prop_index(duk_context *ctx, duk_idx_t obj_idx, duk_uarridx_t arr_idx);\n\nDUK_EXTERNAL_DECL void duk_get_prop_desc(duk_context *ctx, duk_idx_t obj_idx, duk_uint_t flags);\nDUK_EXTERNAL_DECL void duk_def_prop(duk_context *ctx, duk_idx_t obj_idx, duk_uint_t flags);\n\nDUK_EXTERNAL_DECL duk_bool_t duk_get_global_string(duk_context *ctx, const char *key);\nDUK_EXTERNAL_DECL duk_bool_t duk_get_global_lstring(duk_context *ctx, const char *key, duk_size_t key_len);\nDUK_EXTERNAL_DECL duk_bool_t duk_put_global_string(duk_context *ctx, const char *key);\nDUK_EXTERNAL_DECL duk_bool_t duk_put_global_lstring(duk_context *ctx, const char *key, duk_size_t key_len);\n\n/*\n *  Inspection\n */\n\nDUK_EXTERNAL_DECL void duk_inspect_value(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL void duk_inspect_callstack_entry(duk_context *ctx, duk_int_t level);\n\n/*\n *  Object prototype\n */\n\nDUK_EXTERNAL_DECL void duk_get_prototype(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL void duk_set_prototype(duk_context *ctx, duk_idx_t idx);\n\n/*\n *  Object finalizer\n */\n\nDUK_EXTERNAL_DECL void duk_get_finalizer(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL void duk_set_finalizer(duk_context *ctx, duk_idx_t idx);\n\n/*\n *  Global object\n */\n\nDUK_EXTERNAL_DECL void duk_set_global_object(duk_context *ctx);\n\n/*\n *  Duktape/C function magic value\n */\n\nDUK_EXTERNAL_DECL duk_int_t duk_get_magic(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL void duk_set_magic(duk_context *ctx, duk_idx_t idx, duk_int_t magic);\nDUK_EXTERNAL_DECL duk_int_t duk_get_current_magic(duk_context *ctx);\n\n/*\n *  Module helpers: put multiple function or constant properties\n */\n\nDUK_EXTERNAL_DECL void duk_put_function_list(duk_context *ctx, duk_idx_t obj_idx, const duk_function_list_entry *funcs);\nDUK_EXTERNAL_DECL void duk_put_number_list(duk_context *ctx, duk_idx_t obj_idx, const duk_number_list_entry *numbers);\n\n/*\n *  Object operations\n */\n\nDUK_EXTERNAL_DECL void duk_compact(duk_context *ctx, duk_idx_t obj_idx);\nDUK_EXTERNAL_DECL void duk_enum(duk_context *ctx, duk_idx_t obj_idx, duk_uint_t enum_flags);\nDUK_EXTERNAL_DECL duk_bool_t duk_next(duk_context *ctx, duk_idx_t enum_idx, duk_bool_t get_value);\n\n/*\n *  String manipulation\n */\n\nDUK_EXTERNAL_DECL void duk_concat(duk_context *ctx, duk_idx_t count);\nDUK_EXTERNAL_DECL void duk_join(duk_context *ctx, duk_idx_t count);\nDUK_EXTERNAL_DECL void duk_decode_string(duk_context *ctx, duk_idx_t idx, duk_decode_char_function callback, void *udata);\nDUK_EXTERNAL_DECL void duk_map_string(duk_context *ctx, duk_idx_t idx, duk_map_char_function callback, void *udata);\nDUK_EXTERNAL_DECL void duk_substring(duk_context *ctx, duk_idx_t idx, duk_size_t start_char_offset, duk_size_t end_char_offset);\nDUK_EXTERNAL_DECL void duk_trim(duk_context *ctx, duk_idx_t idx);\nDUK_EXTERNAL_DECL duk_codepoint_t duk_char_code_at(duk_context *ctx, duk_idx_t idx, duk_size_t char_offset);\n\n/*\n *  Ecmascript operators\n */\n\nDUK_EXTERNAL_DECL duk_bool_t duk_equals(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);\nDUK_EXTERNAL_DECL duk_bool_t duk_strict_equals(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);\nDUK_EXTERNAL_DECL duk_bool_t duk_samevalue(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);\nDUK_EXTERNAL_DECL duk_bool_t duk_instanceof(duk_context *ctx, duk_idx_t idx1, duk_idx_t idx2);\n\n/*\n *  Function (method) calls\n */\n\nDUK_EXTERNAL_DECL void duk_call(duk_context *ctx, duk_idx_t nargs);\nDUK_EXTERNAL_DECL void duk_call_method(duk_context *ctx, duk_idx_t nargs);\nDUK_EXTERNAL_DECL void duk_call_prop(duk_context *ctx, duk_idx_t obj_idx, duk_idx_t nargs);\nDUK_EXTERNAL_DECL duk_int_t duk_pcall(duk_context *ctx, duk_idx_t nargs);\nDUK_EXTERNAL_DECL duk_int_t duk_pcall_method(duk_context *ctx, duk_idx_t nargs);\nDUK_EXTERNAL_DECL duk_int_t duk_pcall_prop(duk_context *ctx, duk_idx_t obj_idx, duk_idx_t nargs);\nDUK_EXTERNAL_DECL void duk_new(duk_context *ctx, duk_idx_t nargs);\nDUK_EXTERNAL_DECL duk_int_t duk_pnew(duk_context *ctx, duk_idx_t nargs);\nDUK_EXTERNAL_DECL duk_int_t duk_safe_call(duk_context *ctx, duk_safe_call_function func, void *udata, duk_idx_t nargs, duk_idx_t nrets);\n\n/*\n *  Thread management\n */\n\n/* There are currently no native functions to yield/resume, due to the internal\n * limitations on coroutine handling.  These will be added later.\n */\n\n/*\n *  Compilation and evaluation\n */\n\nDUK_EXTERNAL_DECL duk_int_t duk_eval_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags);\nDUK_EXTERNAL_DECL duk_int_t duk_compile_raw(duk_context *ctx, const char *src_buffer, duk_size_t src_length, duk_uint_t flags);\n\n/* plain */\n#define duk_eval(ctx)  \\\n\t((void) duk_eval_raw((ctx), NULL, 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOFILENAME))\n\n#define duk_eval_noresult(ctx)  \\\n\t((void) duk_eval_raw((ctx), NULL, 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))\n\n#define duk_peval(ctx)  \\\n\t(duk_eval_raw((ctx), NULL, 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOFILENAME))\n\n#define duk_peval_noresult(ctx)  \\\n\t(duk_eval_raw((ctx), NULL, 0, 1 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))\n\n#define duk_compile(ctx,flags)  \\\n\t((void) duk_compile_raw((ctx), NULL, 0, 2 /*args*/ | (flags)))\n\n#define duk_pcompile(ctx,flags)  \\\n\t(duk_compile_raw((ctx), NULL, 0, 2 /*args*/ | (flags) | DUK_COMPILE_SAFE))\n\n/* string */\n#define duk_eval_string(ctx,src)  \\\n\t((void) duk_eval_raw((ctx), (src), 0, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))\n\n#define duk_eval_string_noresult(ctx,src)  \\\n\t((void) duk_eval_raw((ctx), (src), 0, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))\n\n#define duk_peval_string(ctx,src)  \\\n\t(duk_eval_raw((ctx), (src), 0, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))\n\n#define duk_peval_string_noresult(ctx,src)  \\\n\t(duk_eval_raw((ctx), (src), 0, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))\n\n#define duk_compile_string(ctx,flags,src)  \\\n\t((void) duk_compile_raw((ctx), (src), 0, 0 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))\n\n#define duk_compile_string_filename(ctx,flags,src)  \\\n\t((void) duk_compile_raw((ctx), (src), 0, 1 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))\n\n#define duk_pcompile_string(ctx,flags,src)  \\\n\t(duk_compile_raw((ctx), (src), 0, 0 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN | DUK_COMPILE_NOFILENAME))\n\n#define duk_pcompile_string_filename(ctx,flags,src)  \\\n\t(duk_compile_raw((ctx), (src), 0, 1 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_STRLEN))\n\n/* lstring */\n#define duk_eval_lstring(ctx,buf,len)  \\\n\t((void) duk_eval_raw((ctx), buf, len, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))\n\n#define duk_eval_lstring_noresult(ctx,buf,len)  \\\n\t((void) duk_eval_raw((ctx), buf, len, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))\n\n#define duk_peval_lstring(ctx,buf,len)  \\\n\t(duk_eval_raw((ctx), buf, len, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_NOSOURCE | DUK_COMPILE_SAFE | DUK_COMPILE_NOFILENAME))\n\n#define duk_peval_lstring_noresult(ctx,buf,len)  \\\n\t(duk_eval_raw((ctx), buf, len, 0 /*args*/ | DUK_COMPILE_EVAL | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NORESULT | DUK_COMPILE_NOFILENAME))\n\n#define duk_compile_lstring(ctx,flags,buf,len)  \\\n\t((void) duk_compile_raw((ctx), buf, len, 0 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))\n\n#define duk_compile_lstring_filename(ctx,flags,buf,len)  \\\n\t((void) duk_compile_raw((ctx), buf, len, 1 /*args*/ | (flags) | DUK_COMPILE_NOSOURCE))\n\n#define duk_pcompile_lstring(ctx,flags,buf,len)  \\\n\t(duk_compile_raw((ctx), buf, len, 0 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE | DUK_COMPILE_NOFILENAME))\n\n#define duk_pcompile_lstring_filename(ctx,flags,buf,len)  \\\n\t(duk_compile_raw((ctx), buf, len, 1 /*args*/ | (flags) | DUK_COMPILE_SAFE | DUK_COMPILE_NOSOURCE))\n\n/*\n *  Bytecode load/dump\n */\n\nDUK_EXTERNAL_DECL void duk_dump_function(duk_context *ctx);\nDUK_EXTERNAL_DECL void duk_load_function(duk_context *ctx);\n\n/*\n *  Debugging\n */\n\nDUK_EXTERNAL_DECL void duk_push_context_dump(duk_context *ctx);\n\n/*\n *  Debugger (debug protocol)\n */\n\nDUK_EXTERNAL_DECL void duk_debugger_attach(duk_context *ctx,\n                                           duk_debug_read_function read_cb,\n                                           duk_debug_write_function write_cb,\n                                           duk_debug_peek_function peek_cb,\n                                           duk_debug_read_flush_function read_flush_cb,\n                                           duk_debug_write_flush_function write_flush_cb,\n                                           duk_debug_request_function request_cb,\n                                           duk_debug_detached_function detached_cb,\n                                           void *udata);\nDUK_EXTERNAL_DECL void duk_debugger_detach(duk_context *ctx);\nDUK_EXTERNAL_DECL void duk_debugger_cooperate(duk_context *ctx);\nDUK_EXTERNAL_DECL duk_bool_t duk_debugger_notify(duk_context *ctx, duk_idx_t nvalues);\nDUK_EXTERNAL_DECL void duk_debugger_pause(duk_context *ctx);\n\n/*\n *  Time handling\n */\n\nDUK_EXTERNAL_DECL duk_double_t duk_get_now(duk_context *ctx);\nDUK_EXTERNAL_DECL void duk_time_to_components(duk_context *ctx, duk_double_t timeval, duk_time_components *comp);\nDUK_EXTERNAL_DECL duk_double_t duk_components_to_time(duk_context *ctx, duk_time_components *comp);\n\n/*\n *  Date provider related constants\n *\n *  NOTE: These are \"semi public\" - you should only use these if you write\n *  your own platform specific Date provider, see doc/datetime.rst.\n */\n\n/* Millisecond count constants. */\n#define DUK_DATE_MSEC_SECOND          1000L\n#define DUK_DATE_MSEC_MINUTE          (60L * 1000L)\n#define DUK_DATE_MSEC_HOUR            (60L * 60L * 1000L)\n#define DUK_DATE_MSEC_DAY             (24L * 60L * 60L * 1000L)\n\n/* Ecmascript date range is 100 million days from Epoch:\n * > 100e6 * 24 * 60 * 60 * 1000  // 100M days in millisecs\n * 8640000000000000\n * (= 8.64e15)\n */\n#define DUK_DATE_MSEC_100M_DAYS         (8.64e15)\n#define DUK_DATE_MSEC_100M_DAYS_LEEWAY  (8.64e15 + 24 * 3600e3)\n\n/* Ecmascript year range:\n * > new Date(100e6 * 24 * 3600e3).toISOString()\n * '+275760-09-13T00:00:00.000Z'\n * > new Date(-100e6 * 24 * 3600e3).toISOString()\n * '-271821-04-20T00:00:00.000Z'\n */\n#define DUK_DATE_MIN_ECMA_YEAR     (-271821L)\n#define DUK_DATE_MAX_ECMA_YEAR     275760L\n\n/* Part indices for internal breakdowns.  Part order from DUK_DATE_IDX_YEAR\n * to DUK_DATE_IDX_MILLISECOND matches argument ordering of Ecmascript API\n * calls (like Date constructor call).  Some functions in duk_bi_date.c\n * depend on the specific ordering, so change with care.  16 bits are not\n * enough for all parts (year, specifically).\n *\n * Must be in-sync with genbuiltins.py.\n */\n#define DUK_DATE_IDX_YEAR           0  /* year */\n#define DUK_DATE_IDX_MONTH          1  /* month: 0 to 11 */\n#define DUK_DATE_IDX_DAY            2  /* day within month: 0 to 30 */\n#define DUK_DATE_IDX_HOUR           3\n#define DUK_DATE_IDX_MINUTE         4\n#define DUK_DATE_IDX_SECOND         5\n#define DUK_DATE_IDX_MILLISECOND    6\n#define DUK_DATE_IDX_WEEKDAY        7  /* weekday: 0 to 6, 0=sunday, 1=monday, etc */\n#define DUK_DATE_IDX_NUM_PARTS      8\n\n/* Internal API call flags, used for various functions in duk_bi_date.c.\n * Certain flags are used by only certain functions, but since the flags\n * don't overlap, a single flags value can be passed around to multiple\n * functions.\n *\n * The unused top bits of the flags field are also used to pass values\n * to helpers (duk__get_part_helper() and duk__set_part_helper()).\n *\n * Must be in-sync with genbuiltins.py.\n */\n\n/* NOTE: when writing a Date provider you only need a few specific\n * flags from here, the rest are internal.  Avoid using anything you\n * don't need.\n */\n\n#define DUK_DATE_FLAG_NAN_TO_ZERO          (1 << 0)  /* timeval breakdown: internal time value NaN -> zero */\n#define DUK_DATE_FLAG_NAN_TO_RANGE_ERROR   (1 << 1)  /* timeval breakdown: internal time value NaN -> RangeError (toISOString) */\n#define DUK_DATE_FLAG_ONEBASED             (1 << 2)  /* timeval breakdown: convert month and day-of-month parts to one-based (default is zero-based) */\n#define DUK_DATE_FLAG_EQUIVYEAR            (1 << 3)  /* timeval breakdown: replace year with equivalent year in the [1971,2037] range for DST calculations */\n#define DUK_DATE_FLAG_LOCALTIME            (1 << 4)  /* convert time value to local time */\n#define DUK_DATE_FLAG_SUB1900              (1 << 5)  /* getter: subtract 1900 from year when getting year part */\n#define DUK_DATE_FLAG_TOSTRING_DATE        (1 << 6)  /* include date part in string conversion result */\n#define DUK_DATE_FLAG_TOSTRING_TIME        (1 << 7)  /* include time part in string conversion result */\n#define DUK_DATE_FLAG_TOSTRING_LOCALE      (1 << 8)  /* use locale specific formatting if available */\n#define DUK_DATE_FLAG_TIMESETTER           (1 << 9)  /* setter: call is a time setter (affects hour, min, sec, ms); otherwise date setter (affects year, month, day-in-month) */\n#define DUK_DATE_FLAG_YEAR_FIXUP           (1 << 10) /* setter: perform 2-digit year fixup (00...99 -> 1900...1999) */\n#define DUK_DATE_FLAG_SEP_T                (1 << 11) /* string conversion: use 'T' instead of ' ' as a separator */\n#define DUK_DATE_FLAG_VALUE_SHIFT          12        /* additional values begin at bit 12 */\n\n/*\n *  ROM pointer compression\n */\n\n/* Support array for ROM pointer compression.  Only declared when ROM\n * pointer compression is active.\n */\n#if defined(DUK_USE_ROM_OBJECTS) && defined(DUK_USE_HEAPPTR16)\nDUK_EXTERNAL_DECL const void * const duk_rom_compressed_pointers[];\n#endif\n\n/*\n *  C++ name mangling\n */\n\n#if defined(__cplusplus)\n/* end 'extern \"C\"' wrapper */\n}\n#endif\n\n/*\n *  END PUBLIC API\n */\n\n#endif  /* DUKTAPE_H_INCLUDED */\n"
  },
  {
    "path": "ext/gmock/CHANGES",
    "content": "Changes for 1.7.0:\n\n* All new improvements in Google Test 1.7.0.\n* New feature: matchers DoubleNear(), FloatNear(),\n  NanSensitiveDoubleNear(), NanSensitiveFloatNear(),\n  UnorderedElementsAre(), UnorderedElementsAreArray(), WhenSorted(),\n  WhenSortedBy(), IsEmpty(), and SizeIs().\n* Improvement: Google Mock can now be built as a DLL.\n* Improvement: when compiled by a C++11 compiler, matchers AllOf()\n  and AnyOf() can accept an arbitrary number of matchers.\n* Improvement: when compiled by a C++11 compiler, matchers\n  ElementsAreArray() can accept an initializer list.\n* Improvement: when exceptions are enabled, a mock method with no\n  default action now throws instead crashing the test.\n* Improvement: added class testing::StringMatchResultListener to aid\n  definition of composite matchers.\n* Improvement: function return types used in MOCK_METHOD*() macros can\n  now contain unprotected commas.\n* Improvement (potentially breaking): EXPECT_THAT() and ASSERT_THAT()\n  are now more strict in ensuring that the value type and the matcher\n  type are compatible, catching potential bugs in tests.\n* Improvement: Pointee() now works on an optional<T>.\n* Improvement: the ElementsAreArray() matcher can now take a vector or\n  iterator range as input, and makes a copy of its input elements\n  before the conversion to a Matcher.\n* Improvement: the Google Mock Generator can now generate mocks for\n  some class templates.\n* Bug fix: mock object destruction triggerred by another mock object's\n  destruction no longer hangs.\n* Improvement: Google Mock Doctor works better with newer Clang and\n  GCC now.\n* Compatibility fixes.\n* Bug/warning fixes.\n\nChanges for 1.6.0:\n\n* Compilation is much faster and uses much less memory, especially\n  when the constructor and destructor of a mock class are moved out of\n  the class body.\n* New matchers: Pointwise(), Each().\n* New actions: ReturnPointee() and ReturnRefOfCopy().\n* CMake support.\n* Project files for Visual Studio 2010.\n* AllOf() and AnyOf() can handle up-to 10 arguments now.\n* Google Mock doctor understands Clang error messages now.\n* SetArgPointee<> now accepts string literals.\n* gmock_gen.py handles storage specifier macros and template return\n  types now.\n* Compatibility fixes.\n* Bug fixes and implementation clean-ups.\n* Potentially incompatible changes: disables the harmful 'make install'\n  command in autotools.\n\nPotentially breaking changes:\n\n* The description string for MATCHER*() changes from Python-style\n  interpolation to an ordinary C++ string expression.\n* SetArgumentPointee is deprecated in favor of SetArgPointee.\n* Some non-essential project files for Visual Studio 2005 are removed.\n\nChanges for 1.5.0:\n\n * New feature: Google Mock can be safely used in multi-threaded tests\n   on platforms having pthreads.\n * New feature: function for printing a value of arbitrary type.\n * New feature: function ExplainMatchResult() for easy definition of\n   composite matchers.\n * The new matcher API lets user-defined matchers generate custom\n   explanations more directly and efficiently.\n * Better failure messages all around.\n * NotNull() and IsNull() now work with smart pointers.\n * Field() and Property() now work when the matcher argument is a pointer\n   passed by reference.\n * Regular expression matchers on all platforms.\n * Added GCC 4.0 support for Google Mock Doctor.\n * Added gmock_all_test.cc for compiling most Google Mock tests\n   in a single file.\n * Significantly cleaned up compiler warnings.\n * Bug fixes, better test coverage, and implementation clean-ups.\n\n Potentially breaking changes:\n\n * Custom matchers defined using MatcherInterface or MakePolymorphicMatcher()\n   need to be updated after upgrading to Google Mock 1.5.0; matchers defined\n   using MATCHER or MATCHER_P* aren't affected.\n * Dropped support for 'make install'.\n\nChanges for 1.4.0 (we skipped 1.2.* and 1.3.* to match the version of\nGoogle Test):\n\n * Works in more environments: Symbian and minGW, Visual C++ 7.1.\n * Lighter weight: comes with our own implementation of TR1 tuple (no\n   more dependency on Boost!).\n * New feature: --gmock_catch_leaked_mocks for detecting leaked mocks.\n * New feature: ACTION_TEMPLATE for defining templatized actions.\n * New feature: the .After() clause for specifying expectation order.\n * New feature: the .With() clause for for specifying inter-argument\n   constraints.\n * New feature: actions ReturnArg<k>(), ReturnNew<T>(...), and\n   DeleteArg<k>().\n * New feature: matchers Key(), Pair(), Args<...>(), AllArgs(), IsNull(),\n   and Contains().\n * New feature: utility class MockFunction<F>, useful for checkpoints, etc.\n * New feature: functions Value(x, m) and SafeMatcherCast<T>(m).\n * New feature: copying a mock object is rejected at compile time.\n * New feature: a script for fusing all Google Mock and Google Test\n   source files for easy deployment.\n * Improved the Google Mock doctor to diagnose more diseases.\n * Improved the Google Mock generator script.\n * Compatibility fixes for Mac OS X and gcc.\n * Bug fixes and implementation clean-ups.\n\nChanges for 1.1.0:\n\n * New feature: ability to use Google Mock with any testing framework.\n * New feature: macros for easily defining new matchers\n * New feature: macros for easily defining new actions.\n * New feature: more container matchers.\n * New feature: actions for accessing function arguments and throwing\n   exceptions.\n * Improved the Google Mock doctor script for diagnosing compiler errors.\n * Bug fixes and implementation clean-ups.\n\nChanges for 1.0.0:\n\n * Initial Open Source release of Google Mock\n"
  },
  {
    "path": "ext/gmock/CMakeLists.txt",
    "content": "########################################################################\n# CMake build script for Google Mock.\n#\n# To run the tests for Google Mock itself on Linux, use 'make test' or\n# ctest.  You can select which tests to run using 'ctest -R regex'.\n# For more options, run 'ctest --help'.\n\n# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to\n# make it prominent in the GUI.\noption(BUILD_SHARED_LIBS \"Build shared libraries (DLLs).\" OFF)\n\noption(gmock_build_tests \"Build all of Google Mock's own tests.\" OFF)\n\n# A directory to find Google Test sources.\nif (EXISTS \"${CMAKE_CURRENT_SOURCE_DIR}/gtest/CMakeLists.txt\")\n  set(gtest_dir gtest)\nelse()\n  set(gtest_dir ../gtest)\nendif()\n\n# Defines pre_project_set_up_hermetic_build() and set_up_hermetic_build().\ninclude(\"${gtest_dir}/cmake/hermetic_build.cmake\" OPTIONAL)\n\nif (COMMAND pre_project_set_up_hermetic_build)\n  # Google Test also calls hermetic setup functions from add_subdirectory,\n  # although its changes will not affect things at the current scope.\n  pre_project_set_up_hermetic_build()\nendif()\n\n########################################################################\n#\n# Project-wide settings\n\n# Name of the project.\n#\n# CMake files in this project can refer to the root source directory\n# as ${gmock_SOURCE_DIR} and to the root binary directory as\n# ${gmock_BINARY_DIR}.\n# Language \"C\" is required for find_package(Threads).\nproject(gmock CXX C)\ncmake_minimum_required(VERSION 2.6.2)\n\nif (COMMAND set_up_hermetic_build)\n  set_up_hermetic_build()\nendif()\n\n# Instructs CMake to process Google Test's CMakeLists.txt and add its\n# targets to the current scope.  We are placing Google Test's binary\n# directory in a subdirectory of our own as VC compilation may break\n# if they are the same (the default).\nadd_subdirectory(\"${gtest_dir}\" \"${gmock_BINARY_DIR}/gtest\")\n\n# Although Google Test's CMakeLists.txt calls this function, the\n# changes there don't affect the current scope.  Therefore we have to\n# call it again here.\n#config_compiler_and_linker()  # from ${gtest_dir}/cmake/internal_utils.cmake\n#^^^ MYSQL Router Team: We comment this out because on Windows it changes the\n#    default runtime /MD to /MT.  Without it we have /MD (in Router we link\n#    either statically or dynamically against /MD runtime).\n\n# Adds Google Mock's and Google Test's header directories to the search path.\ninclude_directories(\"${gmock_SOURCE_DIR}/include\"\n                    \"${gmock_SOURCE_DIR}\"\n                    \"${gtest_SOURCE_DIR}/include\"\n                    # This directory is needed to build directly from Google\n                    # Test sources.\n                    \"${gtest_SOURCE_DIR}\")\n\n########################################################################\n#\n# Defines the gmock & gmock_main libraries.  User tests should link\n# with one of them.\n\n# Google Mock libraries.  We build them using more strict warnings than what\n# are used for other targets, to ensure that Google Mock can be compiled by\n# a user aggressive about warnings.\ncxx_library(gmock\n            \"${cxx_strict}\"\n            \"${gtest_dir}/src/gtest-all.cc\"\n            src/gmock-all.cc)\n\ncxx_library(gmock_main\n            \"${cxx_strict}\"\n            \"${gtest_dir}/src/gtest-all.cc\"\n            src/gmock-all.cc\n            src/gmock_main.cc)\n\n########################################################################\n#\n# Google Mock's own tests.\n#\n# You can skip this section if you aren't interested in testing\n# Google Mock itself.\n#\n# The tests are not built by default.  To build them, set the\n# gmock_build_tests option to ON.  You can do it by running ccmake\n# or specifying the -Dgmock_build_tests=ON flag when running cmake.\n\nif (gmock_build_tests)\n  # This must be set in the root directory for the tests to be run by\n  # 'make test' or ctest.\n  enable_testing()\n\n  ############################################################\n  # C++ tests built with standard compiler flags.\n\n  cxx_test(gmock-actions_test gmock_main)\n  cxx_test(gmock-cardinalities_test gmock_main)\n  cxx_test(gmock_ex_test gmock_main)\n  cxx_test(gmock-generated-actions_test gmock_main)\n  cxx_test(gmock-generated-function-mockers_test gmock_main)\n  cxx_test(gmock-generated-internal-utils_test gmock_main)\n  cxx_test(gmock-generated-matchers_test gmock_main)\n  cxx_test(gmock-internal-utils_test gmock_main)\n  cxx_test(gmock-matchers_test gmock_main)\n  cxx_test(gmock-more-actions_test gmock_main)\n  cxx_test(gmock-nice-strict_test gmock_main)\n  cxx_test(gmock-port_test gmock_main)\n  cxx_test(gmock-spec-builders_test gmock_main)\n  cxx_test(gmock_link_test gmock_main test/gmock_link2_test.cc)\n  cxx_test(gmock_test gmock_main)\n\n  if (CMAKE_USE_PTHREADS_INIT)\n    cxx_test(gmock_stress_test gmock)\n  endif()\n\n  # gmock_all_test is commented to save time building and running tests.\n  # Uncomment if necessary.\n  # cxx_test(gmock_all_test gmock_main)\n\n  ############################################################\n  # C++ tests built with non-standard compiler flags.\n\n  cxx_library(gmock_main_no_exception \"${cxx_no_exception}\"\n    \"${gtest_dir}/src/gtest-all.cc\" src/gmock-all.cc src/gmock_main.cc)\n\n  cxx_library(gmock_main_no_rtti \"${cxx_no_rtti}\"\n    \"${gtest_dir}/src/gtest-all.cc\" src/gmock-all.cc src/gmock_main.cc)\n\n  cxx_library(gmock_main_use_own_tuple \"${cxx_use_own_tuple}\"\n    \"${gtest_dir}/src/gtest-all.cc\" src/gmock-all.cc src/gmock_main.cc)\n\n  cxx_test_with_flags(gmock-more-actions_no_exception_test \"${cxx_no_exception}\"\n    gmock_main_no_exception test/gmock-more-actions_test.cc)\n\n  cxx_test_with_flags(gmock_no_rtti_test \"${cxx_no_rtti}\"\n    gmock_main_no_rtti test/gmock-spec-builders_test.cc)\n\n  cxx_test_with_flags(gmock_use_own_tuple_test \"${cxx_use_own_tuple}\"\n    gmock_main_use_own_tuple test/gmock-spec-builders_test.cc)\n\n  cxx_shared_library(shared_gmock_main \"${cxx_default}\"\n    \"${gtest_dir}/src/gtest-all.cc\" src/gmock-all.cc src/gmock_main.cc)\n\n  # Tests that a binary can be built with Google Mock as a shared library.  On\n  # some system configurations, it may not possible to run the binary without\n  # knowing more details about the system configurations. We do not try to run\n  # this binary. To get a more robust shared library coverage, configure with\n  # -DBUILD_SHARED_LIBS=ON.\n  cxx_executable_with_flags(shared_gmock_test_ \"${cxx_default}\"\n    shared_gmock_main test/gmock-spec-builders_test.cc)\n  set_target_properties(shared_gmock_test_\n    PROPERTIES\n    COMPILE_DEFINITIONS \"GTEST_LINKED_AS_SHARED_LIBRARY=1\")\n\n  ############################################################\n  # Python tests.\n\n  cxx_executable(gmock_leak_test_ test gmock_main)\n  py_test(gmock_leak_test)\n\n  cxx_executable(gmock_output_test_ test gmock)\n  py_test(gmock_output_test)\nendif()\n"
  },
  {
    "path": "ext/gmock/CONTRIBUTORS",
    "content": "# This file contains a list of people who've made non-trivial\n# contribution to the Google C++ Mocking Framework project.  People\n# who commit code to the project are encouraged to add their names\n# here.  Please keep the list sorted by first names.\n\nBenoit Sigoure <tsuna@google.com>\nBogdan Piloca <boo@google.com>\nChandler Carruth <chandlerc@google.com>\nDave MacLachlan <dmaclach@gmail.com>\nDavid Anderson <danderson@google.com>\nDean Sturtevant\nGene Volovich <gv@cite.com>\nHal Burch <gmock@hburch.com>\nJeffrey Yasskin <jyasskin@google.com>\nJim Keller <jimkeller@google.com>\nJoe Walnes <joe@truemesh.com>\nJon Wray <jwray@google.com>\nKeir Mierle <mierle@gmail.com>\nKeith Ray <keith.ray@gmail.com>\nKostya Serebryany <kcc@google.com>\nLev Makhlis\nManuel Klimek <klimek@google.com>\nMario Tanev <radix@google.com>\nMark Paskin\nMarkus Heule <markus.heule@gmail.com>\nMatthew Simmons <simmonmt@acm.org>\nMike Bland <mbland@google.com>\nNeal Norwitz <nnorwitz@gmail.com>\nNermin Ozkiranartli <nermin@google.com>\nOwen Carlsen <ocarlsen@google.com>\nPaneendra Ba <paneendra@google.com>\nPaul Menage <menage@google.com>\nPiotr Kaminski <piotrk@google.com>\nRuss Rufer <russ@pentad.com>\nSverre Sundsdal <sundsdal@gmail.com>\nTakeshi Yoshino <tyoshino@google.com>\nVadim Berman <vadimb@google.com>\nVlad Losev <vladl@google.com>\nWolfgang Klier <wklier@google.com>\nZhanyong Wan <wan@google.com>\n"
  },
  {
    "path": "ext/gmock/LICENSE",
    "content": "Copyright 2008, Google Inc.\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n    * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n    * Neither the name of Google Inc. nor the names of its\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  },
  {
    "path": "ext/gmock/Makefile.am",
    "content": "# Automake file\n\n# Nonstandard package files for distribution.\nEXTRA_DIST = LICENSE\n\n# We may need to build our internally packaged gtest. If so, it will be\n# included in the 'subdirs' variable.\nSUBDIRS = $(subdirs)\n\n# This is generated by the configure script, so clean it for distribution.\nDISTCLEANFILES = scripts/gmock-config\n\n# We define the global AM_CPPFLAGS as everything we compile includes from these\n# directories.\nAM_CPPFLAGS = $(GTEST_CPPFLAGS) -I$(srcdir)/include\n\n# Modifies compiler and linker flags for pthreads compatibility.\nif HAVE_PTHREADS\n  AM_CXXFLAGS = @PTHREAD_CFLAGS@ -DGTEST_HAS_PTHREAD=1\n  AM_LIBS = @PTHREAD_LIBS@\nendif\n\n# Build rules for libraries.\nlib_LTLIBRARIES = lib/libgmock.la lib/libgmock_main.la\n\nlib_libgmock_la_SOURCES = src/gmock-all.cc\n\npkginclude_HEADERS = \\\n  include/gmock/gmock-actions.h \\\n  include/gmock/gmock-cardinalities.h \\\n  include/gmock/gmock-generated-actions.h \\\n  include/gmock/gmock-generated-function-mockers.h \\\n  include/gmock/gmock-generated-matchers.h \\\n  include/gmock/gmock-generated-nice-strict.h \\\n  include/gmock/gmock-matchers.h \\\n  include/gmock/gmock-more-actions.h \\\n  include/gmock/gmock-more-matchers.h \\\n  include/gmock/gmock-spec-builders.h \\\n  include/gmock/gmock.h\n\npkginclude_internaldir = $(pkgincludedir)/internal\npkginclude_internal_HEADERS = \\\n  include/gmock/internal/gmock-generated-internal-utils.h \\\n  include/gmock/internal/gmock-internal-utils.h \\\n  include/gmock/internal/gmock-port.h\n\nlib_libgmock_main_la_SOURCES = src/gmock_main.cc\nlib_libgmock_main_la_LIBADD = lib/libgmock.la\n\n# Build rules for tests. Automake's naming for some of these variables isn't\n# terribly obvious, so this is a brief reference:\n#\n# TESTS -- Programs run automatically by \"make check\"\n# check_PROGRAMS -- Programs built by \"make check\" but not necessarily run\n\nTESTS=\ncheck_PROGRAMS=\nAM_LDFLAGS = $(GTEST_LDFLAGS)\n\n# This exercises all major components of Google Mock.  It also\n# verifies that libgmock works.\nTESTS += test/gmock-spec-builders_test\ncheck_PROGRAMS += test/gmock-spec-builders_test\ntest_gmock_spec_builders_test_SOURCES = test/gmock-spec-builders_test.cc\ntest_gmock_spec_builders_test_LDADD = $(GTEST_LIBS) lib/libgmock.la\n\n# This tests using Google Mock in multiple translation units.  It also\n# verifies that libgmock_main and libgmock work.\nTESTS += test/gmock_link_test\ncheck_PROGRAMS += test/gmock_link_test\ntest_gmock_link_test_SOURCES = \\\n  test/gmock_link2_test.cc \\\n  test/gmock_link_test.cc \\\n  test/gmock_link_test.h\ntest_gmock_link_test_LDADD = $(GTEST_LIBS) lib/libgmock_main.la  lib/libgmock.la\n\nif HAVE_PYTHON\n  # Tests that fused gmock files compile and work.\n  TESTS += test/gmock_fused_test\n  check_PROGRAMS += test/gmock_fused_test\n  test_gmock_fused_test_SOURCES = \\\n    fused-src/gmock-gtest-all.cc \\\n    fused-src/gmock/gmock.h \\\n    fused-src/gmock_main.cc \\\n    fused-src/gtest/gtest.h \\\n    test/gmock_test.cc\n  test_gmock_fused_test_CPPFLAGS = -I\"$(srcdir)/fused-src\"\nendif\n\n# Google Mock source files that we don't compile directly.\nGMOCK_SOURCE_INGLUDES = \\\n  src/gmock-cardinalities.cc \\\n  src/gmock-internal-utils.cc \\\n  src/gmock-matchers.cc \\\n  src/gmock-spec-builders.cc \\\n  src/gmock.cc\n\nEXTRA_DIST += $(GMOCK_SOURCE_INGLUDES)\n\n# C++ tests that we don't compile using autotools.\nEXTRA_DIST += \\\n  test/gmock-actions_test.cc \\\n  test/gmock_all_test.cc \\\n  test/gmock-cardinalities_test.cc \\\n  test/gmock_ex_test.cc \\\n  test/gmock-generated-actions_test.cc \\\n  test/gmock-generated-function-mockers_test.cc \\\n  test/gmock-generated-internal-utils_test.cc \\\n  test/gmock-generated-matchers_test.cc \\\n  test/gmock-internal-utils_test.cc \\\n  test/gmock-matchers_test.cc \\\n  test/gmock-more-actions_test.cc \\\n  test/gmock-nice-strict_test.cc \\\n  test/gmock-port_test.cc \\\n  test/gmock_stress_test.cc\n\n# Python tests, which we don't run using autotools.\nEXTRA_DIST += \\\n  test/gmock_leak_test.py \\\n  test/gmock_leak_test_.cc \\\n  test/gmock_output_test.py \\\n  test/gmock_output_test_.cc \\\n  test/gmock_output_test_golden.txt \\\n  test/gmock_test_utils.py\n\n# Nonstandard package files for distribution.\nEXTRA_DIST += \\\n  CHANGES \\\n  CONTRIBUTORS \\\n  make/Makefile\n\n# Pump scripts for generating Google Mock headers.\n# TODO(chandlerc@google.com): automate the generation of *.h from *.h.pump.\nEXTRA_DIST += \\\n  include/gmock/gmock-generated-actions.h.pump \\\n  include/gmock/gmock-generated-function-mockers.h.pump \\\n  include/gmock/gmock-generated-matchers.h.pump \\\n  include/gmock/gmock-generated-nice-strict.h.pump \\\n  include/gmock/internal/gmock-generated-internal-utils.h.pump\n\n# Script for fusing Google Mock and Google Test source files.\nEXTRA_DIST += scripts/fuse_gmock_files.py\n\n# The Google Mock Generator tool from the cppclean project.\nEXTRA_DIST += \\\n  scripts/generator/LICENSE \\\n  scripts/generator/README \\\n  scripts/generator/README.cppclean \\\n  scripts/generator/cpp/__init__.py \\\n  scripts/generator/cpp/ast.py \\\n  scripts/generator/cpp/gmock_class.py \\\n  scripts/generator/cpp/keywords.py \\\n  scripts/generator/cpp/tokenize.py \\\n  scripts/generator/cpp/utils.py \\\n  scripts/generator/gmock_gen.py\n\n# CMake scripts.\nEXTRA_DIST += \\\n  CMakeLists.txt\n\n# Microsoft Visual Studio 2005 projects.\nEXTRA_DIST += \\\n  msvc/2005/gmock.sln \\\n  msvc/2005/gmock.vcproj \\\n  msvc/2005/gmock_config.vsprops \\\n  msvc/2005/gmock_main.vcproj \\\n  msvc/2005/gmock_test.vcproj\n\n# Microsoft Visual Studio 2010 projects.\nEXTRA_DIST += \\\n  msvc/2010/gmock.sln \\\n  msvc/2010/gmock.vcxproj \\\n  msvc/2010/gmock_config.props \\\n  msvc/2010/gmock_main.vcxproj \\\n  msvc/2010/gmock_test.vcxproj\n\nif HAVE_PYTHON\n# gmock_test.cc does not really depend on files generated by the\n# fused-gmock-internal rule.  However, gmock_test.o does, and it is\n# important to include test/gmock_test.cc as part of this rule in order to\n# prevent compiling gmock_test.o until all dependent files have been\n# generated.\n$(test_gmock_fused_test_SOURCES): fused-gmock-internal\n\n# TODO(vladl@google.com): Find a way to add Google Tests's sources here.\nfused-gmock-internal: $(pkginclude_HEADERS) $(pkginclude_internal_HEADERS) \\\n                      $(lib_libgmock_la_SOURCES) $(GMOCK_SOURCE_INGLUDES) \\\n                      $(lib_libgmock_main_la_SOURCES) \\\n                      scripts/fuse_gmock_files.py\n\tmkdir -p \"$(srcdir)/fused-src\"\n\tchmod -R u+w \"$(srcdir)/fused-src\"\n\trm -f \"$(srcdir)/fused-src/gtest/gtest.h\"\n\trm -f \"$(srcdir)/fused-src/gmock/gmock.h\"\n\trm -f \"$(srcdir)/fused-src/gmock-gtest-all.cc\"\n\t\"$(srcdir)/scripts/fuse_gmock_files.py\" \"$(srcdir)/fused-src\"\n\tcp -f \"$(srcdir)/src/gmock_main.cc\" \"$(srcdir)/fused-src\"\n\nmaintainer-clean-local:\n\trm -rf \"$(srcdir)/fused-src\"\nendif\n\n# Death tests may produce core dumps in the build directory. In case\n# this happens, clean them to keep distcleancheck happy.\nCLEANFILES = core\n\n# Disables 'make install' as installing a compiled version of Google\n# Mock can lead to undefined behavior due to violation of the\n# One-Definition Rule.\n\ninstall-exec-local:\n\techo \"'make install' is dangerous and not supported. Instead, see README for how to integrate Google Mock into your build system.\"\n\tfalse\n\ninstall-data-local:\n\techo \"'make install' is dangerous and not supported. Instead, see README for how to integrate Google Mock into your build system.\"\n\tfalse\n"
  },
  {
    "path": "ext/gmock/README",
    "content": "Google C++ Mocking Framework\n============================\n\nhttp://code.google.com/p/googlemock/\n\nOverview\n--------\n\nGoogle's framework for writing and using C++ mock classes on a variety\nof platforms (Linux, Mac OS X, Windows, Windows CE, Symbian, etc).\nInspired by jMock, EasyMock, and Hamcrest, and designed with C++'s\nspecifics in mind, it can help you derive better designs of your\nsystem and write better tests.\n\nGoogle Mock:\n\n- provides a declarative syntax for defining mocks,\n- can easily define partial (hybrid) mocks, which are a cross of real\n  and mock objects,\n- handles functions of arbitrary types and overloaded functions,\n- comes with a rich set of matchers for validating function arguments,\n- uses an intuitive syntax for controlling the behavior of a mock,\n- does automatic verification of expectations (no record-and-replay\n  needed),\n- allows arbitrary (partial) ordering constraints on\n  function calls to be expressed,\n- lets a user extend it by defining new matchers and actions.\n- does not use exceptions, and\n- is easy to learn and use.\n\nPlease see the project page above for more information as well as the\nmailing list for questions, discussions, and development.  There is\nalso an IRC channel on OFTC (irc.oftc.net) #gtest available.  Please\njoin us!\n\nPlease note that code under scripts/generator/ is from the cppclean\nproject (http://code.google.com/p/cppclean/) and under the Apache\nLicense, which is different from Google Mock's license.\n\nRequirements for End Users\n--------------------------\n\nGoogle Mock is implemented on top of the Google Test C++ testing\nframework (http://code.google.com/p/googletest/), and includes the\nlatter as part of the SVN repositary and distribution package.  You\nmust use the bundled version of Google Test when using Google Mock, or\nyou may get compiler/linker errors.\n\nYou can also easily configure Google Mock to work with another testing\nframework of your choice; although it will still need Google Test as\nan internal dependency.  Please read\nhttp://code.google.com/p/googlemock/wiki/ForDummies#Using_Google_Mock_with_Any_Testing_Framework\nfor how to do it.\n\nGoogle Mock depends on advanced C++ features and thus requires a more\nmodern compiler.  The following are needed to use Google Mock:\n\n### Linux Requirements ###\n\nThese are the base requirements to build and use Google Mock from a source\npackage (as described below):\n\n  * GNU-compatible Make or \"gmake\"\n  * POSIX-standard shell\n  * POSIX(-2) Regular Expressions (regex.h)\n  * C++98-standard-compliant compiler (e.g. GCC 3.4 or newer)\n\n### Windows Requirements ###\n\n  * Microsoft Visual C++ 8.0 SP1 or newer\n\n### Mac OS X Requirements ###\n\n  * Mac OS X 10.4 Tiger or newer\n  * Developer Tools Installed\n\nRequirements for Contributors\n-----------------------------\n\nWe welcome patches.  If you plan to contribute a patch, you need to\nbuild Google Mock and its own tests from an SVN checkout (described\nbelow), which has further requirements:\n\n  * Automake version 1.9 or newer\n  * Autoconf version 2.59 or newer\n  * Libtool / Libtoolize\n  * Python version 2.3 or newer (for running some of the tests and\n    re-generating certain source files from templates)\n\nGetting the Source\n------------------\n\nThere are two primary ways of getting Google Mock's source code: you\ncan download a stable source release in your preferred archive format,\nor directly check out the source from our Subversion (SVN) repositary.\nThe SVN checkout requires a few extra steps and some extra software\npackages on your system, but lets you track development and make\npatches much more easily, so we highly encourage it.\n\n### Source Package ###\n\nGoogle Mock is released in versioned source packages which can be\ndownloaded from the download page [1].  Several different archive\nformats are provided, but the only difference is the tools needed to\nextract their contents, and the size of the resulting file.  Download\nwhichever you are most comfortable with.\n\n  [1] http://code.google.com/p/googlemock/downloads/list\n\nOnce downloaded expand the archive using whichever tools you prefer\nfor that type.  This will always result in a new directory with the\nname \"gmock-X.Y.Z\" which contains all of the source code.  Here are\nsome examples on Linux:\n\n  tar -xvzf gmock-X.Y.Z.tar.gz\n  tar -xvjf gmock-X.Y.Z.tar.bz2\n  unzip gmock-X.Y.Z.zip\n\n### SVN Checkout ###\n\nTo check out the main branch (also known as the \"trunk\") of Google\nMock, run the following Subversion command:\n\n  svn checkout http://googlemock.googlecode.com/svn/trunk/ gmock-svn\n\nIf you are using a *nix system and plan to use the GNU Autotools build\nsystem to build Google Mock (described below), you'll need to\nconfigure it now.  Otherwise you are done with getting the source\nfiles.\n\nTo prepare the Autotools build system, enter the target directory of\nthe checkout command you used ('gmock-svn') and proceed with the\nfollowing command:\n\n  autoreconf -fvi\n\nOnce you have completed this step, you are ready to build the library.\nNote that you should only need to complete this step once.  The\nsubsequent 'make' invocations will automatically re-generate the bits\nof the build system that need to be changed.\n\nIf your system uses older versions of the autotools, the above command\nwill fail.  You may need to explicitly specify a version to use.  For\ninstance, if you have both GNU Automake 1.4 and 1.9 installed and\n'automake' would invoke the 1.4, use instead:\n\n  AUTOMAKE=automake-1.9 ACLOCAL=aclocal-1.9 autoreconf -fvi\n\nMake sure you're using the same version of automake and aclocal.\n\nSetting up the Build\n--------------------\n\nTo build Google Mock and your tests that use it, you need to tell your\nbuild system where to find its headers and source files.  The exact\nway to do it depends on which build system you use, and is usually\nstraightforward.\n\n### Generic Build Instructions ###\n\nThis section shows how you can integrate Google Mock into your\nexisting build system.\n\nSuppose you put Google Mock in directory ${GMOCK_DIR} and Google Test\nin ${GTEST_DIR} (the latter is ${GMOCK_DIR}/gtest by default).  To\nbuild Google Mock, create a library build target (or a project as\ncalled by Visual Studio and Xcode) to compile\n\n  ${GTEST_DIR}/src/gtest-all.cc and ${GMOCK_DIR}/src/gmock-all.cc\n\nwith\n\n  ${GTEST_DIR}/include and ${GMOCK_DIR}/include\n\nin the system header search path, and\n\n  ${GTEST_DIR} and ${GMOCK_DIR}\n\nin the normal header search path.  Assuming a Linux-like system and gcc,\nsomething like the following will do:\n\n  g++ -isystem ${GTEST_DIR}/include -I${GTEST_DIR} \\\n      -isystem ${GMOCK_DIR}/include -I${GMOCK_DIR} \\\n      -pthread -c ${GTEST_DIR}/src/gtest-all.cc\n  g++ -isystem ${GTEST_DIR}/include -I${GTEST_DIR} \\\n      -isystem ${GMOCK_DIR}/include -I${GMOCK_DIR} \\\n      -pthread -c ${GMOCK_DIR}/src/gmock-all.cc\n  ar -rv libgmock.a gtest-all.o gmock-all.o\n\n(We need -pthread as Google Test and Google Mock use threads.)\n\nNext, you should compile your test source file with\n${GTEST_DIR}/include and ${GMOCK_DIR}/include in the header search\npath, and link it with gmock and any other necessary libraries:\n\n  g++ -isystem ${GTEST_DIR}/include -isystem ${GMOCK_DIR}/include \\\n      -pthread path/to/your_test.cc libgmock.a -o your_test\n\nAs an example, the make/ directory contains a Makefile that you can\nuse to build Google Mock on systems where GNU make is available\n(e.g. Linux, Mac OS X, and Cygwin).  It doesn't try to build Google\nMock's own tests.  Instead, it just builds the Google Mock library and\na sample test.  You can use it as a starting point for your own build\nscript.\n\nIf the default settings are correct for your environment, the\nfollowing commands should succeed:\n\n  cd ${GMOCK_DIR}/make\n  make\n  ./gmock_test\n\nIf you see errors, try to tweak the contents of make/Makefile to make\nthem go away.  There are instructions in make/Makefile on how to do\nit.\n\n### Windows ###\n\nThe msvc/2005 directory contains VC++ 2005 projects and the msvc/2010\ndirectory contains VC++ 2010 projects for building Google Mock and\nselected tests.\n\nChange to the appropriate directory and run \"msbuild gmock.sln\" to\nbuild the library and tests (or open the gmock.sln in the MSVC IDE).\nIf you want to create your own project to use with Google Mock, you'll\nhave to configure it to use the gmock_config propety sheet.  For that:\n\n * Open the Property Manager window (View | Other Windows | Property Manager)\n * Right-click on your project and select \"Add Existing Property Sheet...\"\n * Navigate to gmock_config.vsprops or gmock_config.props and select it.\n * In Project Properties | Configuration Properties | General | Additional\n   Include Directories, type <path to Google Mock>/include.\n\nTweaking Google Mock\n--------------------\n\nGoogle Mock can be used in diverse environments.  The default\nconfiguration may not work (or may not work well) out of the box in\nsome environments.  However, you can easily tweak Google Mock by\ndefining control macros on the compiler command line.  Generally,\nthese macros are named like GTEST_XYZ and you define them to either 1\nor 0 to enable or disable a certain feature.\n\nWe list the most frequently used macros below.  For a complete list,\nsee file ${GTEST_DIR}/include/gtest/internal/gtest-port.h.\n\n### Choosing a TR1 Tuple Library ###\n\nGoogle Mock uses the C++ Technical Report 1 (TR1) tuple library\nheavily.  Unfortunately TR1 tuple is not yet widely available with all\ncompilers.  The good news is that Google Test 1.4.0+ implements a\nsubset of TR1 tuple that's enough for Google Mock's need.  Google Mock\nwill automatically use that implementation when the compiler doesn't\nprovide TR1 tuple.\n\nUsually you don't need to care about which tuple library Google Test\nand Google Mock use.  However, if your project already uses TR1 tuple,\nyou need to tell Google Test and Google Mock to use the same TR1 tuple\nlibrary the rest of your project uses, or the two tuple\nimplementations will clash.  To do that, add\n\n  -DGTEST_USE_OWN_TR1_TUPLE=0\n\nto the compiler flags while compiling Google Test, Google Mock, and\nyour tests.  If you want to force Google Test and Google Mock to use\ntheir own tuple library, just add\n\n  -DGTEST_USE_OWN_TR1_TUPLE=1\n\nto the compiler flags instead.\n\nIf you want to use Boost's TR1 tuple library with Google Mock, please\nrefer to the Boost website (http://www.boost.org/) for how to obtain\nit and set it up.\n\n### As a Shared Library (DLL) ###\n\nGoogle Mock is compact, so most users can build and link it as a static\nlibrary for the simplicity.  Google Mock can be used as a DLL, but the\nsame DLL must contain Google Test as well.  See Google Test's README\nfile for instructions on how to set up necessary compiler settings.\n\n### Tweaking Google Mock ###\n\nMost of Google Test's control macros apply to Google Mock as well.\nPlease see file ${GTEST_DIR}/README for how to tweak them.\n\nUpgrading from an Earlier Version\n---------------------------------\n\nWe strive to keep Google Mock releases backward compatible.\nSometimes, though, we have to make some breaking changes for the\nusers' long-term benefits.  This section describes what you'll need to\ndo if you are upgrading from an earlier version of Google Mock.\n\n### Upgrading from 1.1.0 or Earlier ###\n\nYou may need to explicitly enable or disable Google Test's own TR1\ntuple library.  See the instructions in section \"Choosing a TR1 Tuple\nLibrary\".\n\n### Upgrading from 1.4.0 or Earlier ###\n\nOn platforms where the pthread library is available, Google Test and\nGoogle Mock use it in order to be thread-safe.  For this to work, you\nmay need to tweak your compiler and/or linker flags.  Please see the\n\"Multi-threaded Tests\" section in file ${GTEST_DIR}/README for what\nyou may need to do.\n\nIf you have custom matchers defined using MatcherInterface or\nMakePolymorphicMatcher(), you'll need to update their definitions to\nuse the new matcher API [2].  Matchers defined using MATCHER() or\nMATCHER_P*() aren't affected.\n\n  [2] http://code.google.com/p/googlemock/wiki/CookBook#Writing_New_Monomorphic_Matchers,\n      http://code.google.com/p/googlemock/wiki/CookBook#Writing_New_Polymorphic_Matchers\n\nDeveloping Google Mock\n----------------------\n\nThis section discusses how to make your own changes to Google Mock.\n\n### Testing Google Mock Itself ###\n\nTo make sure your changes work as intended and don't break existing\nfunctionality, you'll want to compile and run Google Test's own tests.\nFor that you'll need Autotools.  First, make sure you have followed\nthe instructions in section \"SVN Checkout\" to configure Google Mock.\nThen, create a build output directory and enter it.  Next,\n\n  ${GMOCK_DIR}/configure  # Standard GNU configure script, --help for more info\n\nOnce you have successfully configured Google Mock, the build steps are\nstandard for GNU-style OSS packages.\n\n  make        # Standard makefile following GNU conventions\n  make check  # Builds and runs all tests - all should pass.\n\nNote that when building your project against Google Mock, you are building\nagainst Google Test as well.  There is no need to configure Google Test\nseparately.\n\n### Regenerating Source Files ###\n\nSome of Google Mock's source files are generated from templates (not\nin the C++ sense) using a script.  A template file is named FOO.pump,\nwhere FOO is the name of the file it will generate.  For example, the\nfile include/gmock/gmock-generated-actions.h.pump is used to generate\ngmock-generated-actions.h in the same directory.\n\nNormally you don't need to worry about regenerating the source files,\nunless you need to modify them.  In that case, you should modify the\ncorresponding .pump files instead and run the 'pump' script (for Pump\nis Useful for Meta Programming) to regenerate them.  You can find\npump.py in the ${GTEST_DIR}/scripts/ directory.  Read the Pump manual\n[3] for how to use it.\n\n  [3] http://code.google.com/p/googletest/wiki/PumpManual.\n\n### Contributing a Patch ###\n\nWe welcome patches.  Please read the Google Mock developer's guide [4]\nfor how you can contribute.  In particular, make sure you have signed\nthe Contributor License Agreement, or we won't be able to accept the\npatch.\n\n  [4] http://code.google.com/p/googlemock/wiki/DevGuide\n\nHappy testing!\n"
  },
  {
    "path": "ext/gmock/build-aux/.keep",
    "content": ""
  },
  {
    "path": "ext/gmock/configure.ac",
    "content": "m4_include(gtest/m4/acx_pthread.m4)\n\nAC_INIT([Google C++ Mocking Framework],\n        [1.7.0],\n        [googlemock@googlegroups.com],\n        [gmock])\n\n# Provide various options to initialize the Autoconf and configure processes.\nAC_PREREQ([2.59])\nAC_CONFIG_SRCDIR([./LICENSE])\nAC_CONFIG_AUX_DIR([build-aux])\nAC_CONFIG_HEADERS([build-aux/config.h])\nAC_CONFIG_FILES([Makefile])\nAC_CONFIG_FILES([scripts/gmock-config], [chmod +x scripts/gmock-config])\n\n# Initialize Automake with various options. We require at least v1.9, prevent\n# pedantic complaints about package files, and enable various distribution\n# targets.\nAM_INIT_AUTOMAKE([1.9 dist-bzip2 dist-zip foreign subdir-objects])\n\n# Check for programs used in building Google Test.\nAC_PROG_CC\nAC_PROG_CXX\nAC_LANG([C++])\nAC_PROG_LIBTOOL\n\n# TODO(chandlerc@google.com): Currently we aren't running the Python tests\n# against the interpreter detected by AM_PATH_PYTHON, and so we condition\n# HAVE_PYTHON by requiring \"python\" to be in the PATH, and that interpreter's\n# version to be >= 2.3. This will allow the scripts to use a \"/usr/bin/env\"\n# hashbang.\nPYTHON=  # We *do not* allow the user to specify a python interpreter\nAC_PATH_PROG([PYTHON],[python],[:])\nAS_IF([test \"$PYTHON\" != \":\"],\n      [AM_PYTHON_CHECK_VERSION([$PYTHON],[2.3],[:],[PYTHON=\":\"])])\nAM_CONDITIONAL([HAVE_PYTHON],[test \"$PYTHON\" != \":\"])\n\n# TODO(chandlerc@google.com) Check for the necessary system headers.\n\n# Configure pthreads.\nAC_ARG_WITH([pthreads],\n            [AS_HELP_STRING([--with-pthreads],\n               [use pthreads (default is yes)])],\n            [with_pthreads=$withval],\n            [with_pthreads=check])\n\nhave_pthreads=no\nAS_IF([test \"x$with_pthreads\" != \"xno\"],\n      [ACX_PTHREAD(\n        [],\n        [AS_IF([test \"x$with_pthreads\" != \"xcheck\"],\n               [AC_MSG_FAILURE(\n                 [--with-pthreads was specified, but unable to be used])])])\n       have_pthreads=\"$acx_pthread_ok\"])\nAM_CONDITIONAL([HAVE_PTHREADS],[test \"x$have_pthreads\" == \"xyes\"])\nAC_SUBST(PTHREAD_CFLAGS)\nAC_SUBST(PTHREAD_LIBS)\n\n# GoogleMock currently has hard dependencies upon GoogleTest above and beyond\n# running its own test suite, so we both provide our own version in\n# a subdirectory and provide some logic to use a custom version or a system\n# installed version.\nAC_ARG_WITH([gtest],\n            [AS_HELP_STRING([--with-gtest],\n                            [Specifies how to find the gtest package. If no\n                            arguments are given, the default behavior, a\n                            system installed gtest will be used if present,\n                            and an internal version built otherwise. If a\n                            path is provided, the gtest built or installed at\n                            that prefix will be used.])],\n            [],\n            [with_gtest=yes])\nAC_ARG_ENABLE([external-gtest],\n              [AS_HELP_STRING([--disable-external-gtest],\n                              [Disables any detection or use of a system\n                              installed or user provided gtest. Any option to\n                              '--with-gtest' is ignored. (Default is enabled.)])\n              ], [], [enable_external_gtest=yes])\nAS_IF([test \"x$with_gtest\" == \"xno\"],\n      [AC_MSG_ERROR([dnl\nSupport for GoogleTest was explicitly disabled. Currently GoogleMock has a hard\ndependency upon GoogleTest to build, please provide a version, or allow\nGoogleMock to use any installed version and fall back upon its internal\nversion.])])\n\n# Setup various GTEST variables. TODO(chandlerc@google.com): When these are\n# used below, they should be used such that any pre-existing values always\n# trump values we set them to, so that they can be used to selectively override\n# details of the detection process.\nAC_ARG_VAR([GTEST_CONFIG],\n           [The exact path of Google Test's 'gtest-config' script.])\nAC_ARG_VAR([GTEST_CPPFLAGS],\n           [C-like preprocessor flags for Google Test.])\nAC_ARG_VAR([GTEST_CXXFLAGS],\n           [C++ compile flags for Google Test.])\nAC_ARG_VAR([GTEST_LDFLAGS],\n           [Linker path and option flags for Google Test.])\nAC_ARG_VAR([GTEST_LIBS],\n           [Library linking flags for Google Test.])\nAC_ARG_VAR([GTEST_VERSION],\n           [The version of Google Test available.])\nHAVE_BUILT_GTEST=\"no\"\n\nGTEST_MIN_VERSION=\"1.7.0\"\n\nAS_IF([test \"x${enable_external_gtest}\" = \"xyes\"],\n      [# Begin filling in variables as we are able.\n      AS_IF([test \"x${with_gtest}\" != \"xyes\"],\n            [AS_IF([test -x \"${with_gtest}/scripts/gtest-config\"],\n                   [GTEST_CONFIG=\"${with_gtest}/scripts/gtest-config\"],\n                   [GTEST_CONFIG=\"${with_gtest}/bin/gtest-config\"])\n            AS_IF([test -x \"${GTEST_CONFIG}\"], [],\n                  [AC_MSG_ERROR([dnl\nUnable to locate either a built or installed Google Test at '${with_gtest}'.])\n                  ])])\n\n      AS_IF([test -x \"${GTEST_CONFIG}\"], [],\n            [AC_PATH_PROG([GTEST_CONFIG], [gtest-config])])\n      AS_IF([test -x \"${GTEST_CONFIG}\"],\n            [AC_MSG_CHECKING([for Google Test version >= ${GTEST_MIN_VERSION}])\n            AS_IF([${GTEST_CONFIG} --min-version=${GTEST_MIN_VERSION}],\n                  [AC_MSG_RESULT([yes])\n                  HAVE_BUILT_GTEST=\"yes\"],\n                  [AC_MSG_RESULT([no])])])])\n\nAS_IF([test \"x${HAVE_BUILT_GTEST}\" = \"xyes\"],\n      [GTEST_CPPFLAGS=`${GTEST_CONFIG} --cppflags`\n      GTEST_CXXFLAGS=`${GTEST_CONFIG} --cxxflags`\n      GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`\n      GTEST_LIBS=`${GTEST_CONFIG} --libs`\n      GTEST_VERSION=`${GTEST_CONFIG} --version`],\n      [AC_CONFIG_SUBDIRS([gtest])\n      # GTEST_CONFIG needs to be executable both in a Makefile environmont and\n      # in a shell script environment, so resolve an absolute path for it here.\n      GTEST_CONFIG=\"`pwd -P`/gtest/scripts/gtest-config\"\n      GTEST_CPPFLAGS='-I$(top_srcdir)/gtest/include'\n      GTEST_CXXFLAGS='-g'\n      GTEST_LDFLAGS=''\n      GTEST_LIBS='$(top_builddir)/gtest/lib/libgtest.la'\n      GTEST_VERSION=\"${GTEST_MIN_VERSION}\"])\n\n# TODO(chandlerc@google.com) Check the types, structures, and other compiler\n# and architecture characteristics.\n\n# Output the generated files. No further autoconf macros may be used.\nAC_OUTPUT\n"
  },
  {
    "path": "ext/gmock/include/gmock/gmock-actions.h",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements some commonly used actions.\n\n#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_\n#define GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_\n\n#ifndef _WIN32_WCE\n# include <errno.h>\n#endif\n\n#include <algorithm>\n#include <string>\n\n#include \"gmock/internal/gmock-internal-utils.h\"\n#include \"gmock/internal/gmock-port.h\"\n\nnamespace testing {\n\n// To implement an action Foo, define:\n//   1. a class FooAction that implements the ActionInterface interface, and\n//   2. a factory function that creates an Action object from a\n//      const FooAction*.\n//\n// The two-level delegation design follows that of Matcher, providing\n// consistency for extension developers.  It also eases ownership\n// management as Action objects can now be copied like plain values.\n\nnamespace internal {\n\ntemplate <typename F1, typename F2>\nclass ActionAdaptor;\n\n// BuiltInDefaultValue<T>::Get() returns the \"built-in\" default\n// value for type T, which is NULL when T is a pointer type, 0 when T\n// is a numeric type, false when T is bool, or \"\" when T is string or\n// std::string.  For any other type T, this value is undefined and the\n// function will abort the process.\ntemplate <typename T>\nclass BuiltInDefaultValue {\n public:\n  // This function returns true iff type T has a built-in default value.\n  static bool Exists() { return false; }\n  static T Get() {\n    Assert(false, __FILE__, __LINE__,\n           \"Default action undefined for the function return type.\");\n    return internal::Invalid<T>();\n    // The above statement will never be reached, but is required in\n    // order for this function to compile.\n  }\n};\n\n// This partial specialization says that we use the same built-in\n// default value for T and const T.\ntemplate <typename T>\nclass BuiltInDefaultValue<const T> {\n public:\n  static bool Exists() { return BuiltInDefaultValue<T>::Exists(); }\n  static T Get() { return BuiltInDefaultValue<T>::Get(); }\n};\n\n// This partial specialization defines the default values for pointer\n// types.\ntemplate <typename T>\nclass BuiltInDefaultValue<T*> {\n public:\n  static bool Exists() { return true; }\n  static T* Get() { return NULL; }\n};\n\n// The following specializations define the default values for\n// specific types we care about.\n#define GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(type, value) \\\n  template <> \\\n  class BuiltInDefaultValue<type> { \\\n   public: \\\n    static bool Exists() { return true; } \\\n    static type Get() { return value; } \\\n  }\n\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(void, );  // NOLINT\n#if GTEST_HAS_GLOBAL_STRING\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(::string, \"\");\n#endif  // GTEST_HAS_GLOBAL_STRING\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(::std::string, \"\");\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(bool, false);\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned char, '\\0');\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed char, '\\0');\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(char, '\\0');\n\n// There's no need for a default action for signed wchar_t, as that\n// type is the same as wchar_t for gcc, and invalid for MSVC.\n//\n// There's also no need for a default action for unsigned wchar_t, as\n// that type is the same as unsigned int for gcc, and invalid for\n// MSVC.\n#if GMOCK_WCHAR_T_IS_NATIVE_\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(wchar_t, 0U);  // NOLINT\n#endif\n\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned short, 0U);  // NOLINT\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed short, 0);     // NOLINT\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned int, 0U);\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed int, 0);\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(unsigned long, 0UL);  // NOLINT\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(signed long, 0L);     // NOLINT\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(UInt64, 0);\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(Int64, 0);\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(float, 0);\nGMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_(double, 0);\n\n#undef GMOCK_DEFINE_DEFAULT_ACTION_FOR_RETURN_TYPE_\n\n}  // namespace internal\n\n// When an unexpected function call is encountered, Google Mock will\n// let it return a default value if the user has specified one for its\n// return type, or if the return type has a built-in default value;\n// otherwise Google Mock won't know what value to return and will have\n// to abort the process.\n//\n// The DefaultValue<T> class allows a user to specify the\n// default value for a type T that is both copyable and publicly\n// destructible (i.e. anything that can be used as a function return\n// type).  The usage is:\n//\n//   // Sets the default value for type T to be foo.\n//   DefaultValue<T>::Set(foo);\ntemplate <typename T>\nclass DefaultValue {\n public:\n  // Sets the default value for type T; requires T to be\n  // copy-constructable and have a public destructor.\n  static void Set(T x) {\n    delete value_;\n    value_ = new T(x);\n  }\n\n  // Unsets the default value for type T.\n  static void Clear() {\n    delete value_;\n    value_ = NULL;\n  }\n\n  // Returns true iff the user has set the default value for type T.\n  static bool IsSet() { return value_ != NULL; }\n\n  // Returns true if T has a default return value set by the user or there\n  // exists a built-in default value.\n  static bool Exists() {\n    return IsSet() || internal::BuiltInDefaultValue<T>::Exists();\n  }\n\n  // Returns the default value for type T if the user has set one;\n  // otherwise returns the built-in default value if there is one;\n  // otherwise aborts the process.\n  static T Get() {\n    return value_ == NULL ?\n        internal::BuiltInDefaultValue<T>::Get() : *value_;\n  }\n\n private:\n  static const T* value_;\n};\n\n// This partial specialization allows a user to set default values for\n// reference types.\ntemplate <typename T>\nclass DefaultValue<T&> {\n public:\n  // Sets the default value for type T&.\n  static void Set(T& x) {  // NOLINT\n    address_ = &x;\n  }\n\n  // Unsets the default value for type T&.\n  static void Clear() {\n    address_ = NULL;\n  }\n\n  // Returns true iff the user has set the default value for type T&.\n  static bool IsSet() { return address_ != NULL; }\n\n  // Returns true if T has a default return value set by the user or there\n  // exists a built-in default value.\n  static bool Exists() {\n    return IsSet() || internal::BuiltInDefaultValue<T&>::Exists();\n  }\n\n  // Returns the default value for type T& if the user has set one;\n  // otherwise returns the built-in default value if there is one;\n  // otherwise aborts the process.\n  static T& Get() {\n    return address_ == NULL ?\n        internal::BuiltInDefaultValue<T&>::Get() : *address_;\n  }\n\n private:\n  static T* address_;\n};\n\n// This specialization allows DefaultValue<void>::Get() to\n// compile.\ntemplate <>\nclass DefaultValue<void> {\n public:\n  static bool Exists() { return true; }\n  static void Get() {}\n};\n\n// Points to the user-set default value for type T.\ntemplate <typename T>\nconst T* DefaultValue<T>::value_ = NULL;\n\n// Points to the user-set default value for type T&.\ntemplate <typename T>\nT* DefaultValue<T&>::address_ = NULL;\n\n// Implement this interface to define an action for function type F.\ntemplate <typename F>\nclass ActionInterface {\n public:\n  typedef typename internal::Function<F>::Result Result;\n  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;\n\n  ActionInterface() {}\n  virtual ~ActionInterface() {}\n\n  // Performs the action.  This method is not const, as in general an\n  // action can have side effects and be stateful.  For example, a\n  // get-the-next-element-from-the-collection action will need to\n  // remember the current element.\n  virtual Result Perform(const ArgumentTuple& args) = 0;\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ActionInterface);\n};\n\n// An Action<F> is a copyable and IMMUTABLE (except by assignment)\n// object that represents an action to be taken when a mock function\n// of type F is called.  The implementation of Action<T> is just a\n// linked_ptr to const ActionInterface<T>, so copying is fairly cheap.\n// Don't inherit from Action!\n//\n// You can view an object implementing ActionInterface<F> as a\n// concrete action (including its current state), and an Action<F>\n// object as a handle to it.\ntemplate <typename F>\nclass Action {\n public:\n  typedef typename internal::Function<F>::Result Result;\n  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;\n\n  // Constructs a null Action.  Needed for storing Action objects in\n  // STL containers.\n  Action() : impl_(NULL) {}\n\n  // Constructs an Action from its implementation.  A NULL impl is\n  // used to represent the \"do-default\" action.\n  explicit Action(ActionInterface<F>* impl) : impl_(impl) {}\n\n  // Copy constructor.\n  Action(const Action& action) : impl_(action.impl_) {}\n\n  // This constructor allows us to turn an Action<Func> object into an\n  // Action<F>, as long as F's arguments can be implicitly converted\n  // to Func's and Func's return type can be implicitly converted to\n  // F's.\n  template <typename Func>\n  explicit Action(const Action<Func>& action);\n\n  // Returns true iff this is the DoDefault() action.\n  bool IsDoDefault() const { return impl_.get() == NULL; }\n\n  // Performs the action.  Note that this method is const even though\n  // the corresponding method in ActionInterface is not.  The reason\n  // is that a const Action<F> means that it cannot be re-bound to\n  // another concrete action, not that the concrete action it binds to\n  // cannot change state.  (Think of the difference between a const\n  // pointer and a pointer to const.)\n  Result Perform(const ArgumentTuple& args) const {\n    internal::Assert(\n        !IsDoDefault(), __FILE__, __LINE__,\n        \"You are using DoDefault() inside a composite action like \"\n        \"DoAll() or WithArgs().  This is not supported for technical \"\n        \"reasons.  Please instead spell out the default action, or \"\n        \"assign the default action to an Action variable and use \"\n        \"the variable in various places.\");\n    return impl_->Perform(args);\n  }\n\n private:\n  template <typename F1, typename F2>\n  friend class internal::ActionAdaptor;\n\n  internal::linked_ptr<ActionInterface<F> > impl_;\n};\n\n// The PolymorphicAction class template makes it easy to implement a\n// polymorphic action (i.e. an action that can be used in mock\n// functions of than one type, e.g. Return()).\n//\n// To define a polymorphic action, a user first provides a COPYABLE\n// implementation class that has a Perform() method template:\n//\n//   class FooAction {\n//    public:\n//     template <typename Result, typename ArgumentTuple>\n//     Result Perform(const ArgumentTuple& args) const {\n//       // Processes the arguments and returns a result, using\n//       // tr1::get<N>(args) to get the N-th (0-based) argument in the tuple.\n//     }\n//     ...\n//   };\n//\n// Then the user creates the polymorphic action using\n// MakePolymorphicAction(object) where object has type FooAction.  See\n// the definition of Return(void) and SetArgumentPointee<N>(value) for\n// complete examples.\ntemplate <typename Impl>\nclass PolymorphicAction {\n public:\n  explicit PolymorphicAction(const Impl& impl) : impl_(impl) {}\n\n  template <typename F>\n  operator Action<F>() const {\n    return Action<F>(new MonomorphicImpl<F>(impl_));\n  }\n\n private:\n  template <typename F>\n  class MonomorphicImpl : public ActionInterface<F> {\n   public:\n    typedef typename internal::Function<F>::Result Result;\n    typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;\n\n    explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {}\n\n    virtual Result Perform(const ArgumentTuple& args) {\n      return impl_.template Perform<Result>(args);\n    }\n\n   private:\n    Impl impl_;\n\n    GTEST_DISALLOW_ASSIGN_(MonomorphicImpl);\n  };\n\n  Impl impl_;\n\n  GTEST_DISALLOW_ASSIGN_(PolymorphicAction);\n};\n\n// Creates an Action from its implementation and returns it.  The\n// created Action object owns the implementation.\ntemplate <typename F>\nAction<F> MakeAction(ActionInterface<F>* impl) {\n  return Action<F>(impl);\n}\n\n// Creates a polymorphic action from its implementation.  This is\n// easier to use than the PolymorphicAction<Impl> constructor as it\n// doesn't require you to explicitly write the template argument, e.g.\n//\n//   MakePolymorphicAction(foo);\n// vs\n//   PolymorphicAction<TypeOfFoo>(foo);\ntemplate <typename Impl>\ninline PolymorphicAction<Impl> MakePolymorphicAction(const Impl& impl) {\n  return PolymorphicAction<Impl>(impl);\n}\n\nnamespace internal {\n\n// Allows an Action<F2> object to pose as an Action<F1>, as long as F2\n// and F1 are compatible.\ntemplate <typename F1, typename F2>\nclass ActionAdaptor : public ActionInterface<F1> {\n public:\n  typedef typename internal::Function<F1>::Result Result;\n  typedef typename internal::Function<F1>::ArgumentTuple ArgumentTuple;\n\n  explicit ActionAdaptor(const Action<F2>& from) : impl_(from.impl_) {}\n\n  virtual Result Perform(const ArgumentTuple& args) {\n    return impl_->Perform(args);\n  }\n\n private:\n  const internal::linked_ptr<ActionInterface<F2> > impl_;\n\n  GTEST_DISALLOW_ASSIGN_(ActionAdaptor);\n};\n\n// Implements the polymorphic Return(x) action, which can be used in\n// any function that returns the type of x, regardless of the argument\n// types.\n//\n// Note: The value passed into Return must be converted into\n// Function<F>::Result when this action is cast to Action<F> rather than\n// when that action is performed. This is important in scenarios like\n//\n// MOCK_METHOD1(Method, T(U));\n// ...\n// {\n//   Foo foo;\n//   X x(&foo);\n//   EXPECT_CALL(mock, Method(_)).WillOnce(Return(x));\n// }\n//\n// In the example above the variable x holds reference to foo which leaves\n// scope and gets destroyed.  If copying X just copies a reference to foo,\n// that copy will be left with a hanging reference.  If conversion to T\n// makes a copy of foo, the above code is safe. To support that scenario, we\n// need to make sure that the type conversion happens inside the EXPECT_CALL\n// statement, and conversion of the result of Return to Action<T(U)> is a\n// good place for that.\n//\ntemplate <typename R>\nclass ReturnAction {\n public:\n  // Constructs a ReturnAction object from the value to be returned.\n  // 'value' is passed by value instead of by const reference in order\n  // to allow Return(\"string literal\") to compile.\n  explicit ReturnAction(R value) : value_(value) {}\n\n  // This template type conversion operator allows Return(x) to be\n  // used in ANY function that returns x's type.\n  template <typename F>\n  operator Action<F>() const {\n    // Assert statement belongs here because this is the best place to verify\n    // conditions on F. It produces the clearest error messages\n    // in most compilers.\n    // Impl really belongs in this scope as a local class but can't\n    // because MSVC produces duplicate symbols in different translation units\n    // in this case. Until MS fixes that bug we put Impl into the class scope\n    // and put the typedef both here (for use in assert statement) and\n    // in the Impl class. But both definitions must be the same.\n    typedef typename Function<F>::Result Result;\n    GTEST_COMPILE_ASSERT_(\n        !internal::is_reference<Result>::value,\n        use_ReturnRef_instead_of_Return_to_return_a_reference);\n    return Action<F>(new Impl<F>(value_));\n  }\n\n private:\n  // Implements the Return(x) action for a particular function type F.\n  template <typename F>\n  class Impl : public ActionInterface<F> {\n   public:\n    typedef typename Function<F>::Result Result;\n    typedef typename Function<F>::ArgumentTuple ArgumentTuple;\n\n    // The implicit cast is necessary when Result has more than one\n    // single-argument constructor (e.g. Result is std::vector<int>) and R\n    // has a type conversion operator template.  In that case, value_(value)\n    // won't compile as the compiler doesn't known which constructor of\n    // Result to call.  ImplicitCast_ forces the compiler to convert R to\n    // Result without considering explicit constructors, thus resolving the\n    // ambiguity. value_ is then initialized using its copy constructor.\n    explicit Impl(R value)\n        : value_(::testing::internal::ImplicitCast_<Result>(value)) {}\n\n    virtual Result Perform(const ArgumentTuple&) { return value_; }\n\n   private:\n    GTEST_COMPILE_ASSERT_(!internal::is_reference<Result>::value,\n                          Result_cannot_be_a_reference_type);\n    Result value_;\n\n    GTEST_DISALLOW_ASSIGN_(Impl);\n  };\n\n  R value_;\n\n  GTEST_DISALLOW_ASSIGN_(ReturnAction);\n};\n\n// Implements the ReturnNull() action.\nclass ReturnNullAction {\n public:\n  // Allows ReturnNull() to be used in any pointer-returning function.\n  template <typename Result, typename ArgumentTuple>\n  static Result Perform(const ArgumentTuple&) {\n    GTEST_COMPILE_ASSERT_(internal::is_pointer<Result>::value,\n                          ReturnNull_can_be_used_to_return_a_pointer_only);\n    return NULL;\n  }\n};\n\n// Implements the Return() action.\nclass ReturnVoidAction {\n public:\n  // Allows Return() to be used in any void-returning function.\n  template <typename Result, typename ArgumentTuple>\n  static void Perform(const ArgumentTuple&) {\n    CompileAssertTypesEqual<void, Result>();\n  }\n};\n\n// Implements the polymorphic ReturnRef(x) action, which can be used\n// in any function that returns a reference to the type of x,\n// regardless of the argument types.\ntemplate <typename T>\nclass ReturnRefAction {\n public:\n  // Constructs a ReturnRefAction object from the reference to be returned.\n  explicit ReturnRefAction(T& ref) : ref_(ref) {}  // NOLINT\n\n  // This template type conversion operator allows ReturnRef(x) to be\n  // used in ANY function that returns a reference to x's type.\n  template <typename F>\n  operator Action<F>() const {\n    typedef typename Function<F>::Result Result;\n    // Asserts that the function return type is a reference.  This\n    // catches the user error of using ReturnRef(x) when Return(x)\n    // should be used, and generates some helpful error message.\n    GTEST_COMPILE_ASSERT_(internal::is_reference<Result>::value,\n                          use_Return_instead_of_ReturnRef_to_return_a_value);\n    return Action<F>(new Impl<F>(ref_));\n  }\n\n private:\n  // Implements the ReturnRef(x) action for a particular function type F.\n  template <typename F>\n  class Impl : public ActionInterface<F> {\n   public:\n    typedef typename Function<F>::Result Result;\n    typedef typename Function<F>::ArgumentTuple ArgumentTuple;\n\n    explicit Impl(T& ref) : ref_(ref) {}  // NOLINT\n\n    virtual Result Perform(const ArgumentTuple&) {\n      return ref_;\n    }\n\n   private:\n    T& ref_;\n\n    GTEST_DISALLOW_ASSIGN_(Impl);\n  };\n\n  T& ref_;\n\n  GTEST_DISALLOW_ASSIGN_(ReturnRefAction);\n};\n\n// Implements the polymorphic ReturnRefOfCopy(x) action, which can be\n// used in any function that returns a reference to the type of x,\n// regardless of the argument types.\ntemplate <typename T>\nclass ReturnRefOfCopyAction {\n public:\n  // Constructs a ReturnRefOfCopyAction object from the reference to\n  // be returned.\n  explicit ReturnRefOfCopyAction(const T& value) : value_(value) {}  // NOLINT\n\n  // This template type conversion operator allows ReturnRefOfCopy(x) to be\n  // used in ANY function that returns a reference to x's type.\n  template <typename F>\n  operator Action<F>() const {\n    typedef typename Function<F>::Result Result;\n    // Asserts that the function return type is a reference.  This\n    // catches the user error of using ReturnRefOfCopy(x) when Return(x)\n    // should be used, and generates some helpful error message.\n    GTEST_COMPILE_ASSERT_(\n        internal::is_reference<Result>::value,\n        use_Return_instead_of_ReturnRefOfCopy_to_return_a_value);\n    return Action<F>(new Impl<F>(value_));\n  }\n\n private:\n  // Implements the ReturnRefOfCopy(x) action for a particular function type F.\n  template <typename F>\n  class Impl : public ActionInterface<F> {\n   public:\n    typedef typename Function<F>::Result Result;\n    typedef typename Function<F>::ArgumentTuple ArgumentTuple;\n\n    explicit Impl(const T& value) : value_(value) {}  // NOLINT\n\n    virtual Result Perform(const ArgumentTuple&) {\n      return value_;\n    }\n\n   private:\n    T value_;\n\n    GTEST_DISALLOW_ASSIGN_(Impl);\n  };\n\n  const T value_;\n\n  GTEST_DISALLOW_ASSIGN_(ReturnRefOfCopyAction);\n};\n\n// Implements the polymorphic DoDefault() action.\nclass DoDefaultAction {\n public:\n  // This template type conversion operator allows DoDefault() to be\n  // used in any function.\n  template <typename F>\n  operator Action<F>() const { return Action<F>(NULL); }\n};\n\n// Implements the Assign action to set a given pointer referent to a\n// particular value.\ntemplate <typename T1, typename T2>\nclass AssignAction {\n public:\n  AssignAction(T1* ptr, T2 value) : ptr_(ptr), value_(value) {}\n\n  template <typename Result, typename ArgumentTuple>\n  void Perform(const ArgumentTuple& /* args */) const {\n    *ptr_ = value_;\n  }\n\n private:\n  T1* const ptr_;\n  const T2 value_;\n\n  GTEST_DISALLOW_ASSIGN_(AssignAction);\n};\n\n#if !GTEST_OS_WINDOWS_MOBILE\n\n// Implements the SetErrnoAndReturn action to simulate return from\n// various system calls and libc functions.\ntemplate <typename T>\nclass SetErrnoAndReturnAction {\n public:\n  SetErrnoAndReturnAction(int errno_value, T result)\n      : errno_(errno_value),\n        result_(result) {}\n  template <typename Result, typename ArgumentTuple>\n  Result Perform(const ArgumentTuple& /* args */) const {\n    errno = errno_;\n    return result_;\n  }\n\n private:\n  const int errno_;\n  const T result_;\n\n  GTEST_DISALLOW_ASSIGN_(SetErrnoAndReturnAction);\n};\n\n#endif  // !GTEST_OS_WINDOWS_MOBILE\n\n// Implements the SetArgumentPointee<N>(x) action for any function\n// whose N-th argument (0-based) is a pointer to x's type.  The\n// template parameter kIsProto is true iff type A is ProtocolMessage,\n// proto2::Message, or a sub-class of those.\ntemplate <size_t N, typename A, bool kIsProto>\nclass SetArgumentPointeeAction {\n public:\n  // Constructs an action that sets the variable pointed to by the\n  // N-th function argument to 'value'.\n  explicit SetArgumentPointeeAction(const A& value) : value_(value) {}\n\n  template <typename Result, typename ArgumentTuple>\n  void Perform(const ArgumentTuple& args) const {\n    CompileAssertTypesEqual<void, Result>();\n    *::std::tr1::get<N>(args) = value_;\n  }\n\n private:\n  const A value_;\n\n  GTEST_DISALLOW_ASSIGN_(SetArgumentPointeeAction);\n};\n\ntemplate <size_t N, typename Proto>\nclass SetArgumentPointeeAction<N, Proto, true> {\n public:\n  // Constructs an action that sets the variable pointed to by the\n  // N-th function argument to 'proto'.  Both ProtocolMessage and\n  // proto2::Message have the CopyFrom() method, so the same\n  // implementation works for both.\n  explicit SetArgumentPointeeAction(const Proto& proto) : proto_(new Proto) {\n    proto_->CopyFrom(proto);\n  }\n\n  template <typename Result, typename ArgumentTuple>\n  void Perform(const ArgumentTuple& args) const {\n    CompileAssertTypesEqual<void, Result>();\n    ::std::tr1::get<N>(args)->CopyFrom(*proto_);\n  }\n\n private:\n  const internal::linked_ptr<Proto> proto_;\n\n  GTEST_DISALLOW_ASSIGN_(SetArgumentPointeeAction);\n};\n\n// Implements the InvokeWithoutArgs(f) action.  The template argument\n// FunctionImpl is the implementation type of f, which can be either a\n// function pointer or a functor.  InvokeWithoutArgs(f) can be used as an\n// Action<F> as long as f's type is compatible with F (i.e. f can be\n// assigned to a tr1::function<F>).\ntemplate <typename FunctionImpl>\nclass InvokeWithoutArgsAction {\n public:\n  // The c'tor makes a copy of function_impl (either a function\n  // pointer or a functor).\n  explicit InvokeWithoutArgsAction(FunctionImpl function_impl)\n      : function_impl_(function_impl) {}\n\n  // Allows InvokeWithoutArgs(f) to be used as any action whose type is\n  // compatible with f.\n  template <typename Result, typename ArgumentTuple>\n  Result Perform(const ArgumentTuple&) { return function_impl_(); }\n\n private:\n  FunctionImpl function_impl_;\n\n  GTEST_DISALLOW_ASSIGN_(InvokeWithoutArgsAction);\n};\n\n// Implements the InvokeWithoutArgs(object_ptr, &Class::Method) action.\ntemplate <class Class, typename MethodPtr>\nclass InvokeMethodWithoutArgsAction {\n public:\n  InvokeMethodWithoutArgsAction(Class* obj_ptr, MethodPtr method_ptr)\n      : obj_ptr_(obj_ptr), method_ptr_(method_ptr) {}\n\n  template <typename Result, typename ArgumentTuple>\n  Result Perform(const ArgumentTuple&) const {\n    return (obj_ptr_->*method_ptr_)();\n  }\n\n private:\n  Class* const obj_ptr_;\n  const MethodPtr method_ptr_;\n\n  GTEST_DISALLOW_ASSIGN_(InvokeMethodWithoutArgsAction);\n};\n\n// Implements the IgnoreResult(action) action.\ntemplate <typename A>\nclass IgnoreResultAction {\n public:\n  explicit IgnoreResultAction(const A& action) : action_(action) {}\n\n  template <typename F>\n  operator Action<F>() const {\n    // Assert statement belongs here because this is the best place to verify\n    // conditions on F. It produces the clearest error messages\n    // in most compilers.\n    // Impl really belongs in this scope as a local class but can't\n    // because MSVC produces duplicate symbols in different translation units\n    // in this case. Until MS fixes that bug we put Impl into the class scope\n    // and put the typedef both here (for use in assert statement) and\n    // in the Impl class. But both definitions must be the same.\n    typedef typename internal::Function<F>::Result Result;\n\n    // Asserts at compile time that F returns void.\n    CompileAssertTypesEqual<void, Result>();\n\n    return Action<F>(new Impl<F>(action_));\n  }\n\n private:\n  template <typename F>\n  class Impl : public ActionInterface<F> {\n   public:\n    typedef typename internal::Function<F>::Result Result;\n    typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;\n\n    explicit Impl(const A& action) : action_(action) {}\n\n    virtual void Perform(const ArgumentTuple& args) {\n      // Performs the action and ignores its result.\n      action_.Perform(args);\n    }\n\n   private:\n    // Type OriginalFunction is the same as F except that its return\n    // type is IgnoredValue.\n    typedef typename internal::Function<F>::MakeResultIgnoredValue\n        OriginalFunction;\n\n    const Action<OriginalFunction> action_;\n\n    GTEST_DISALLOW_ASSIGN_(Impl);\n  };\n\n  const A action_;\n\n  GTEST_DISALLOW_ASSIGN_(IgnoreResultAction);\n};\n\n// A ReferenceWrapper<T> object represents a reference to type T,\n// which can be either const or not.  It can be explicitly converted\n// from, and implicitly converted to, a T&.  Unlike a reference,\n// ReferenceWrapper<T> can be copied and can survive template type\n// inference.  This is used to support by-reference arguments in the\n// InvokeArgument<N>(...) action.  The idea was from \"reference\n// wrappers\" in tr1, which we don't have in our source tree yet.\ntemplate <typename T>\nclass ReferenceWrapper {\n public:\n  // Constructs a ReferenceWrapper<T> object from a T&.\n  explicit ReferenceWrapper(T& l_value) : pointer_(&l_value) {}  // NOLINT\n\n  // Allows a ReferenceWrapper<T> object to be implicitly converted to\n  // a T&.\n  operator T&() const { return *pointer_; }\n private:\n  T* pointer_;\n};\n\n// Allows the expression ByRef(x) to be printed as a reference to x.\ntemplate <typename T>\nvoid PrintTo(const ReferenceWrapper<T>& ref, ::std::ostream* os) {\n  T& value = ref;\n  UniversalPrinter<T&>::Print(value, os);\n}\n\n// Does two actions sequentially.  Used for implementing the DoAll(a1,\n// a2, ...) action.\ntemplate <typename Action1, typename Action2>\nclass DoBothAction {\n public:\n  DoBothAction(Action1 action1, Action2 action2)\n      : action1_(action1), action2_(action2) {}\n\n  // This template type conversion operator allows DoAll(a1, ..., a_n)\n  // to be used in ANY function of compatible type.\n  template <typename F>\n  operator Action<F>() const {\n    return Action<F>(new Impl<F>(action1_, action2_));\n  }\n\n private:\n  // Implements the DoAll(...) action for a particular function type F.\n  template <typename F>\n  class Impl : public ActionInterface<F> {\n   public:\n    typedef typename Function<F>::Result Result;\n    typedef typename Function<F>::ArgumentTuple ArgumentTuple;\n    typedef typename Function<F>::MakeResultVoid VoidResult;\n\n    Impl(const Action<VoidResult>& action1, const Action<F>& action2)\n        : action1_(action1), action2_(action2) {}\n\n    virtual Result Perform(const ArgumentTuple& args) {\n      action1_.Perform(args);\n      return action2_.Perform(args);\n    }\n\n   private:\n    const Action<VoidResult> action1_;\n    const Action<F> action2_;\n\n    GTEST_DISALLOW_ASSIGN_(Impl);\n  };\n\n  Action1 action1_;\n  Action2 action2_;\n\n  GTEST_DISALLOW_ASSIGN_(DoBothAction);\n};\n\n}  // namespace internal\n\n// An Unused object can be implicitly constructed from ANY value.\n// This is handy when defining actions that ignore some or all of the\n// mock function arguments.  For example, given\n//\n//   MOCK_METHOD3(Foo, double(const string& label, double x, double y));\n//   MOCK_METHOD3(Bar, double(int index, double x, double y));\n//\n// instead of\n//\n//   double DistanceToOriginWithLabel(const string& label, double x, double y) {\n//     return sqrt(x*x + y*y);\n//   }\n//   double DistanceToOriginWithIndex(int index, double x, double y) {\n//     return sqrt(x*x + y*y);\n//   }\n//   ...\n//   EXEPCT_CALL(mock, Foo(\"abc\", _, _))\n//       .WillOnce(Invoke(DistanceToOriginWithLabel));\n//   EXEPCT_CALL(mock, Bar(5, _, _))\n//       .WillOnce(Invoke(DistanceToOriginWithIndex));\n//\n// you could write\n//\n//   // We can declare any uninteresting argument as Unused.\n//   double DistanceToOrigin(Unused, double x, double y) {\n//     return sqrt(x*x + y*y);\n//   }\n//   ...\n//   EXEPCT_CALL(mock, Foo(\"abc\", _, _)).WillOnce(Invoke(DistanceToOrigin));\n//   EXEPCT_CALL(mock, Bar(5, _, _)).WillOnce(Invoke(DistanceToOrigin));\ntypedef internal::IgnoredValue Unused;\n\n// This constructor allows us to turn an Action<From> object into an\n// Action<To>, as long as To's arguments can be implicitly converted\n// to From's and From's return type cann be implicitly converted to\n// To's.\ntemplate <typename To>\ntemplate <typename From>\nAction<To>::Action(const Action<From>& from)\n    : impl_(new internal::ActionAdaptor<To, From>(from)) {}\n\n// Creates an action that returns 'value'.  'value' is passed by value\n// instead of const reference - otherwise Return(\"string literal\")\n// will trigger a compiler error about using array as initializer.\ntemplate <typename R>\ninternal::ReturnAction<R> Return(R value) {\n  return internal::ReturnAction<R>(value);\n}\n\n// Creates an action that returns NULL.\ninline PolymorphicAction<internal::ReturnNullAction> ReturnNull() {\n  return MakePolymorphicAction(internal::ReturnNullAction());\n}\n\n// Creates an action that returns from a void function.\ninline PolymorphicAction<internal::ReturnVoidAction> Return() {\n  return MakePolymorphicAction(internal::ReturnVoidAction());\n}\n\n// Creates an action that returns the reference to a variable.\ntemplate <typename R>\ninline internal::ReturnRefAction<R> ReturnRef(R& x) {  // NOLINT\n  return internal::ReturnRefAction<R>(x);\n}\n\n// Creates an action that returns the reference to a copy of the\n// argument.  The copy is created when the action is constructed and\n// lives as long as the action.\ntemplate <typename R>\ninline internal::ReturnRefOfCopyAction<R> ReturnRefOfCopy(const R& x) {\n  return internal::ReturnRefOfCopyAction<R>(x);\n}\n\n// Creates an action that does the default action for the give mock function.\ninline internal::DoDefaultAction DoDefault() {\n  return internal::DoDefaultAction();\n}\n\n// Creates an action that sets the variable pointed by the N-th\n// (0-based) function argument to 'value'.\ntemplate <size_t N, typename T>\nPolymorphicAction<\n  internal::SetArgumentPointeeAction<\n    N, T, internal::IsAProtocolMessage<T>::value> >\nSetArgPointee(const T& x) {\n  return MakePolymorphicAction(internal::SetArgumentPointeeAction<\n      N, T, internal::IsAProtocolMessage<T>::value>(x));\n}\n\n#if !((GTEST_GCC_VER_ && GTEST_GCC_VER_ < 40000) || GTEST_OS_SYMBIAN)\n// This overload allows SetArgPointee() to accept a string literal.\n// GCC prior to the version 4.0 and Symbian C++ compiler cannot distinguish\n// this overload from the templated version and emit a compile error.\ntemplate <size_t N>\nPolymorphicAction<\n  internal::SetArgumentPointeeAction<N, const char*, false> >\nSetArgPointee(const char* p) {\n  return MakePolymorphicAction(internal::SetArgumentPointeeAction<\n      N, const char*, false>(p));\n}\n\ntemplate <size_t N>\nPolymorphicAction<\n  internal::SetArgumentPointeeAction<N, const wchar_t*, false> >\nSetArgPointee(const wchar_t* p) {\n  return MakePolymorphicAction(internal::SetArgumentPointeeAction<\n      N, const wchar_t*, false>(p));\n}\n#endif\n\n// The following version is DEPRECATED.\ntemplate <size_t N, typename T>\nPolymorphicAction<\n  internal::SetArgumentPointeeAction<\n    N, T, internal::IsAProtocolMessage<T>::value> >\nSetArgumentPointee(const T& x) {\n  return MakePolymorphicAction(internal::SetArgumentPointeeAction<\n      N, T, internal::IsAProtocolMessage<T>::value>(x));\n}\n\n// Creates an action that sets a pointer referent to a given value.\ntemplate <typename T1, typename T2>\nPolymorphicAction<internal::AssignAction<T1, T2> > Assign(T1* ptr, T2 val) {\n  return MakePolymorphicAction(internal::AssignAction<T1, T2>(ptr, val));\n}\n\n#if !GTEST_OS_WINDOWS_MOBILE\n\n// Creates an action that sets errno and returns the appropriate error.\ntemplate <typename T>\nPolymorphicAction<internal::SetErrnoAndReturnAction<T> >\nSetErrnoAndReturn(int errval, T result) {\n  return MakePolymorphicAction(\n      internal::SetErrnoAndReturnAction<T>(errval, result));\n}\n\n#endif  // !GTEST_OS_WINDOWS_MOBILE\n\n// Various overloads for InvokeWithoutArgs().\n\n// Creates an action that invokes 'function_impl' with no argument.\ntemplate <typename FunctionImpl>\nPolymorphicAction<internal::InvokeWithoutArgsAction<FunctionImpl> >\nInvokeWithoutArgs(FunctionImpl function_impl) {\n  return MakePolymorphicAction(\n      internal::InvokeWithoutArgsAction<FunctionImpl>(function_impl));\n}\n\n// Creates an action that invokes the given method on the given object\n// with no argument.\ntemplate <class Class, typename MethodPtr>\nPolymorphicAction<internal::InvokeMethodWithoutArgsAction<Class, MethodPtr> >\nInvokeWithoutArgs(Class* obj_ptr, MethodPtr method_ptr) {\n  return MakePolymorphicAction(\n      internal::InvokeMethodWithoutArgsAction<Class, MethodPtr>(\n          obj_ptr, method_ptr));\n}\n\n// Creates an action that performs an_action and throws away its\n// result.  In other words, it changes the return type of an_action to\n// void.  an_action MUST NOT return void, or the code won't compile.\ntemplate <typename A>\ninline internal::IgnoreResultAction<A> IgnoreResult(const A& an_action) {\n  return internal::IgnoreResultAction<A>(an_action);\n}\n\n// Creates a reference wrapper for the given L-value.  If necessary,\n// you can explicitly specify the type of the reference.  For example,\n// suppose 'derived' is an object of type Derived, ByRef(derived)\n// would wrap a Derived&.  If you want to wrap a const Base& instead,\n// where Base is a base class of Derived, just write:\n//\n//   ByRef<const Base>(derived)\ntemplate <typename T>\ninline internal::ReferenceWrapper<T> ByRef(T& l_value) {  // NOLINT\n  return internal::ReferenceWrapper<T>(l_value);\n}\n\n}  // namespace testing\n\n#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_ACTIONS_H_\n"
  },
  {
    "path": "ext/gmock/include/gmock/gmock-cardinalities.h",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements some commonly used cardinalities.  More\n// cardinalities can be defined by the user implementing the\n// CardinalityInterface interface if necessary.\n\n#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_\n#define GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_\n\n#include <limits.h>\n#include <ostream>  // NOLINT\n#include \"gmock/internal/gmock-port.h\"\n#include \"gtest/gtest.h\"\n\nnamespace testing {\n\n// To implement a cardinality Foo, define:\n//   1. a class FooCardinality that implements the\n//      CardinalityInterface interface, and\n//   2. a factory function that creates a Cardinality object from a\n//      const FooCardinality*.\n//\n// The two-level delegation design follows that of Matcher, providing\n// consistency for extension developers.  It also eases ownership\n// management as Cardinality objects can now be copied like plain values.\n\n// The implementation of a cardinality.\nclass CardinalityInterface {\n public:\n  virtual ~CardinalityInterface() {}\n\n  // Conservative estimate on the lower/upper bound of the number of\n  // calls allowed.\n  virtual int ConservativeLowerBound() const { return 0; }\n  virtual int ConservativeUpperBound() const { return INT_MAX; }\n\n  // Returns true iff call_count calls will satisfy this cardinality.\n  virtual bool IsSatisfiedByCallCount(int call_count) const = 0;\n\n  // Returns true iff call_count calls will saturate this cardinality.\n  virtual bool IsSaturatedByCallCount(int call_count) const = 0;\n\n  // Describes self to an ostream.\n  virtual void DescribeTo(::std::ostream* os) const = 0;\n};\n\n// A Cardinality is a copyable and IMMUTABLE (except by assignment)\n// object that specifies how many times a mock function is expected to\n// be called.  The implementation of Cardinality is just a linked_ptr\n// to const CardinalityInterface, so copying is fairly cheap.\n// Don't inherit from Cardinality!\nclass GTEST_API_ Cardinality {\n public:\n  // Constructs a null cardinality.  Needed for storing Cardinality\n  // objects in STL containers.\n  Cardinality() {}\n\n  // Constructs a Cardinality from its implementation.\n  explicit Cardinality(const CardinalityInterface* impl) : impl_(impl) {}\n\n  // Conservative estimate on the lower/upper bound of the number of\n  // calls allowed.\n  int ConservativeLowerBound() const { return impl_->ConservativeLowerBound(); }\n  int ConservativeUpperBound() const { return impl_->ConservativeUpperBound(); }\n\n  // Returns true iff call_count calls will satisfy this cardinality.\n  bool IsSatisfiedByCallCount(int call_count) const {\n    return impl_->IsSatisfiedByCallCount(call_count);\n  }\n\n  // Returns true iff call_count calls will saturate this cardinality.\n  bool IsSaturatedByCallCount(int call_count) const {\n    return impl_->IsSaturatedByCallCount(call_count);\n  }\n\n  // Returns true iff call_count calls will over-saturate this\n  // cardinality, i.e. exceed the maximum number of allowed calls.\n  bool IsOverSaturatedByCallCount(int call_count) const {\n    return impl_->IsSaturatedByCallCount(call_count) &&\n        !impl_->IsSatisfiedByCallCount(call_count);\n  }\n\n  // Describes self to an ostream\n  void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); }\n\n  // Describes the given actual call count to an ostream.\n  static void DescribeActualCallCountTo(int actual_call_count,\n                                        ::std::ostream* os);\n\n private:\n  internal::linked_ptr<const CardinalityInterface> impl_;\n};\n\n// Creates a cardinality that allows at least n calls.\nGTEST_API_ Cardinality AtLeast(int n);\n\n// Creates a cardinality that allows at most n calls.\nGTEST_API_ Cardinality AtMost(int n);\n\n// Creates a cardinality that allows any number of calls.\nGTEST_API_ Cardinality AnyNumber();\n\n// Creates a cardinality that allows between min and max calls.\nGTEST_API_ Cardinality Between(int min, int max);\n\n// Creates a cardinality that allows exactly n calls.\nGTEST_API_ Cardinality Exactly(int n);\n\n// Creates a cardinality from its implementation.\ninline Cardinality MakeCardinality(const CardinalityInterface* c) {\n  return Cardinality(c);\n}\n\n}  // namespace testing\n\n#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_CARDINALITIES_H_\n"
  },
  {
    "path": "ext/gmock/include/gmock/gmock-generated-actions.h",
    "content": "// This file was GENERATED by a script.  DO NOT EDIT BY HAND!!!\n\n// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements some commonly used variadic actions.\n\n#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_\n#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_\n\n#include \"gmock/gmock-actions.h\"\n#include \"gmock/internal/gmock-port.h\"\n\nnamespace testing {\nnamespace internal {\n\n// InvokeHelper<F> knows how to unpack an N-tuple and invoke an N-ary\n// function or method with the unpacked values, where F is a function\n// type that takes N arguments.\ntemplate <typename Result, typename ArgumentTuple>\nclass InvokeHelper;\n\ntemplate <typename R>\nclass InvokeHelper<R, ::std::tr1::tuple<> > {\n public:\n  template <typename Function>\n  static R Invoke(Function function, const ::std::tr1::tuple<>&) {\n    return function();\n  }\n\n  template <class Class, typename MethodPtr>\n  static R InvokeMethod(Class* obj_ptr,\n                        MethodPtr method_ptr,\n                        const ::std::tr1::tuple<>&) {\n    return (obj_ptr->*method_ptr)();\n  }\n};\n\ntemplate <typename R, typename A1>\nclass InvokeHelper<R, ::std::tr1::tuple<A1> > {\n public:\n  template <typename Function>\n  static R Invoke(Function function, const ::std::tr1::tuple<A1>& args) {\n    using ::std::tr1::get;\n    return function(get<0>(args));\n  }\n\n  template <class Class, typename MethodPtr>\n  static R InvokeMethod(Class* obj_ptr,\n                        MethodPtr method_ptr,\n                        const ::std::tr1::tuple<A1>& args) {\n    using ::std::tr1::get;\n    return (obj_ptr->*method_ptr)(get<0>(args));\n  }\n};\n\ntemplate <typename R, typename A1, typename A2>\nclass InvokeHelper<R, ::std::tr1::tuple<A1, A2> > {\n public:\n  template <typename Function>\n  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2>& args) {\n    using ::std::tr1::get;\n    return function(get<0>(args), get<1>(args));\n  }\n\n  template <class Class, typename MethodPtr>\n  static R InvokeMethod(Class* obj_ptr,\n                        MethodPtr method_ptr,\n                        const ::std::tr1::tuple<A1, A2>& args) {\n    using ::std::tr1::get;\n    return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args));\n  }\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3>\nclass InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3> > {\n public:\n  template <typename Function>\n  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2,\n      A3>& args) {\n    using ::std::tr1::get;\n    return function(get<0>(args), get<1>(args), get<2>(args));\n  }\n\n  template <class Class, typename MethodPtr>\n  static R InvokeMethod(Class* obj_ptr,\n                        MethodPtr method_ptr,\n                        const ::std::tr1::tuple<A1, A2, A3>& args) {\n    using ::std::tr1::get;\n    return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args));\n  }\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3, typename A4>\nclass InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4> > {\n public:\n  template <typename Function>\n  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3,\n      A4>& args) {\n    using ::std::tr1::get;\n    return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args));\n  }\n\n  template <class Class, typename MethodPtr>\n  static R InvokeMethod(Class* obj_ptr,\n                        MethodPtr method_ptr,\n                        const ::std::tr1::tuple<A1, A2, A3, A4>& args) {\n    using ::std::tr1::get;\n    return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),\n        get<3>(args));\n  }\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3, typename A4,\n    typename A5>\nclass InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5> > {\n public:\n  template <typename Function>\n  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,\n      A5>& args) {\n    using ::std::tr1::get;\n    return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),\n        get<4>(args));\n  }\n\n  template <class Class, typename MethodPtr>\n  static R InvokeMethod(Class* obj_ptr,\n                        MethodPtr method_ptr,\n                        const ::std::tr1::tuple<A1, A2, A3, A4, A5>& args) {\n    using ::std::tr1::get;\n    return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),\n        get<3>(args), get<4>(args));\n  }\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3, typename A4,\n    typename A5, typename A6>\nclass InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6> > {\n public:\n  template <typename Function>\n  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,\n      A5, A6>& args) {\n    using ::std::tr1::get;\n    return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),\n        get<4>(args), get<5>(args));\n  }\n\n  template <class Class, typename MethodPtr>\n  static R InvokeMethod(Class* obj_ptr,\n                        MethodPtr method_ptr,\n                        const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6>& args) {\n    using ::std::tr1::get;\n    return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),\n        get<3>(args), get<4>(args), get<5>(args));\n  }\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3, typename A4,\n    typename A5, typename A6, typename A7>\nclass InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7> > {\n public:\n  template <typename Function>\n  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,\n      A5, A6, A7>& args) {\n    using ::std::tr1::get;\n    return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),\n        get<4>(args), get<5>(args), get<6>(args));\n  }\n\n  template <class Class, typename MethodPtr>\n  static R InvokeMethod(Class* obj_ptr,\n                        MethodPtr method_ptr,\n                        const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6,\n                            A7>& args) {\n    using ::std::tr1::get;\n    return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),\n        get<3>(args), get<4>(args), get<5>(args), get<6>(args));\n  }\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3, typename A4,\n    typename A5, typename A6, typename A7, typename A8>\nclass InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {\n public:\n  template <typename Function>\n  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,\n      A5, A6, A7, A8>& args) {\n    using ::std::tr1::get;\n    return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),\n        get<4>(args), get<5>(args), get<6>(args), get<7>(args));\n  }\n\n  template <class Class, typename MethodPtr>\n  static R InvokeMethod(Class* obj_ptr,\n                        MethodPtr method_ptr,\n                        const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7,\n                            A8>& args) {\n    using ::std::tr1::get;\n    return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),\n        get<3>(args), get<4>(args), get<5>(args), get<6>(args), get<7>(args));\n  }\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3, typename A4,\n    typename A5, typename A6, typename A7, typename A8, typename A9>\nclass InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {\n public:\n  template <typename Function>\n  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,\n      A5, A6, A7, A8, A9>& args) {\n    using ::std::tr1::get;\n    return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),\n        get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args));\n  }\n\n  template <class Class, typename MethodPtr>\n  static R InvokeMethod(Class* obj_ptr,\n                        MethodPtr method_ptr,\n                        const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8,\n                            A9>& args) {\n    using ::std::tr1::get;\n    return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),\n        get<3>(args), get<4>(args), get<5>(args), get<6>(args), get<7>(args),\n        get<8>(args));\n  }\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3, typename A4,\n    typename A5, typename A6, typename A7, typename A8, typename A9,\n    typename A10>\nclass InvokeHelper<R, ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,\n    A10> > {\n public:\n  template <typename Function>\n  static R Invoke(Function function, const ::std::tr1::tuple<A1, A2, A3, A4,\n      A5, A6, A7, A8, A9, A10>& args) {\n    using ::std::tr1::get;\n    return function(get<0>(args), get<1>(args), get<2>(args), get<3>(args),\n        get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),\n        get<9>(args));\n  }\n\n  template <class Class, typename MethodPtr>\n  static R InvokeMethod(Class* obj_ptr,\n                        MethodPtr method_ptr,\n                        const ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8,\n                            A9, A10>& args) {\n    using ::std::tr1::get;\n    return (obj_ptr->*method_ptr)(get<0>(args), get<1>(args), get<2>(args),\n        get<3>(args), get<4>(args), get<5>(args), get<6>(args), get<7>(args),\n        get<8>(args), get<9>(args));\n  }\n};\n\n// CallableHelper has static methods for invoking \"callables\",\n// i.e. function pointers and functors.  It uses overloading to\n// provide a uniform interface for invoking different kinds of\n// callables.  In particular, you can use:\n//\n//   CallableHelper<R>::Call(callable, a1, a2, ..., an)\n//\n// to invoke an n-ary callable, where R is its return type.  If an\n// argument, say a2, needs to be passed by reference, you should write\n// ByRef(a2) instead of a2 in the above expression.\ntemplate <typename R>\nclass CallableHelper {\n public:\n  // Calls a nullary callable.\n  template <typename Function>\n  static R Call(Function function) { return function(); }\n\n  // Calls a unary callable.\n\n  // We deliberately pass a1 by value instead of const reference here\n  // in case it is a C-string literal.  If we had declared the\n  // parameter as 'const A1& a1' and write Call(function, \"Hi\"), the\n  // compiler would've thought A1 is 'char[3]', which causes trouble\n  // when you need to copy a value of type A1.  By declaring the\n  // parameter as 'A1 a1', the compiler will correctly infer that A1\n  // is 'const char*' when it sees Call(function, \"Hi\").\n  //\n  // Since this function is defined inline, the compiler can get rid\n  // of the copying of the arguments.  Therefore the performance won't\n  // be hurt.\n  template <typename Function, typename A1>\n  static R Call(Function function, A1 a1) { return function(a1); }\n\n  // Calls a binary callable.\n  template <typename Function, typename A1, typename A2>\n  static R Call(Function function, A1 a1, A2 a2) {\n    return function(a1, a2);\n  }\n\n  // Calls a ternary callable.\n  template <typename Function, typename A1, typename A2, typename A3>\n  static R Call(Function function, A1 a1, A2 a2, A3 a3) {\n    return function(a1, a2, a3);\n  }\n\n  // Calls a 4-ary callable.\n  template <typename Function, typename A1, typename A2, typename A3,\n      typename A4>\n  static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4) {\n    return function(a1, a2, a3, a4);\n  }\n\n  // Calls a 5-ary callable.\n  template <typename Function, typename A1, typename A2, typename A3,\n      typename A4, typename A5>\n  static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {\n    return function(a1, a2, a3, a4, a5);\n  }\n\n  // Calls a 6-ary callable.\n  template <typename Function, typename A1, typename A2, typename A3,\n      typename A4, typename A5, typename A6>\n  static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {\n    return function(a1, a2, a3, a4, a5, a6);\n  }\n\n  // Calls a 7-ary callable.\n  template <typename Function, typename A1, typename A2, typename A3,\n      typename A4, typename A5, typename A6, typename A7>\n  static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,\n      A7 a7) {\n    return function(a1, a2, a3, a4, a5, a6, a7);\n  }\n\n  // Calls a 8-ary callable.\n  template <typename Function, typename A1, typename A2, typename A3,\n      typename A4, typename A5, typename A6, typename A7, typename A8>\n  static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,\n      A7 a7, A8 a8) {\n    return function(a1, a2, a3, a4, a5, a6, a7, a8);\n  }\n\n  // Calls a 9-ary callable.\n  template <typename Function, typename A1, typename A2, typename A3,\n      typename A4, typename A5, typename A6, typename A7, typename A8,\n      typename A9>\n  static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,\n      A7 a7, A8 a8, A9 a9) {\n    return function(a1, a2, a3, a4, a5, a6, a7, a8, a9);\n  }\n\n  // Calls a 10-ary callable.\n  template <typename Function, typename A1, typename A2, typename A3,\n      typename A4, typename A5, typename A6, typename A7, typename A8,\n      typename A9, typename A10>\n  static R Call(Function function, A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6,\n      A7 a7, A8 a8, A9 a9, A10 a10) {\n    return function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);\n  }\n};  // class CallableHelper\n\n// An INTERNAL macro for extracting the type of a tuple field.  It's\n// subject to change without notice - DO NOT USE IN USER CODE!\n#define GMOCK_FIELD_(Tuple, N) \\\n    typename ::std::tr1::tuple_element<N, Tuple>::type\n\n// SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::type is the\n// type of an n-ary function whose i-th (1-based) argument type is the\n// k{i}-th (0-based) field of ArgumentTuple, which must be a tuple\n// type, and whose return type is Result.  For example,\n//   SelectArgs<int, ::std::tr1::tuple<bool, char, double, long>, 0, 3>::type\n// is int(bool, long).\n//\n// SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::Select(args)\n// returns the selected fields (k1, k2, ..., k_n) of args as a tuple.\n// For example,\n//   SelectArgs<int, ::std::tr1::tuple<bool, char, double>, 2, 0>::Select(\n//       ::std::tr1::make_tuple(true, 'a', 2.5))\n// returns ::std::tr1::tuple (2.5, true).\n//\n// The numbers in list k1, k2, ..., k_n must be >= 0, where n can be\n// in the range [0, 10].  Duplicates are allowed and they don't have\n// to be in an ascending or descending order.\n\ntemplate <typename Result, typename ArgumentTuple, int k1, int k2, int k3,\n    int k4, int k5, int k6, int k7, int k8, int k9, int k10>\nclass SelectArgs {\n public:\n  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),\n      GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),\n      GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),\n      GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),\n      GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9),\n      GMOCK_FIELD_(ArgumentTuple, k10));\n  typedef typename Function<type>::ArgumentTuple SelectedArgs;\n  static SelectedArgs Select(const ArgumentTuple& args) {\n    using ::std::tr1::get;\n    return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),\n        get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),\n        get<k8>(args), get<k9>(args), get<k10>(args));\n  }\n};\n\ntemplate <typename Result, typename ArgumentTuple>\nclass SelectArgs<Result, ArgumentTuple,\n                 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {\n public:\n  typedef Result type();\n  typedef typename Function<type>::ArgumentTuple SelectedArgs;\n  static SelectedArgs Select(const ArgumentTuple& /* args */) {\n    using ::std::tr1::get;\n    return SelectedArgs();\n  }\n};\n\ntemplate <typename Result, typename ArgumentTuple, int k1>\nclass SelectArgs<Result, ArgumentTuple,\n                 k1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {\n public:\n  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1));\n  typedef typename Function<type>::ArgumentTuple SelectedArgs;\n  static SelectedArgs Select(const ArgumentTuple& args) {\n    using ::std::tr1::get;\n    return SelectedArgs(get<k1>(args));\n  }\n};\n\ntemplate <typename Result, typename ArgumentTuple, int k1, int k2>\nclass SelectArgs<Result, ArgumentTuple,\n                 k1, k2, -1, -1, -1, -1, -1, -1, -1, -1> {\n public:\n  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),\n      GMOCK_FIELD_(ArgumentTuple, k2));\n  typedef typename Function<type>::ArgumentTuple SelectedArgs;\n  static SelectedArgs Select(const ArgumentTuple& args) {\n    using ::std::tr1::get;\n    return SelectedArgs(get<k1>(args), get<k2>(args));\n  }\n};\n\ntemplate <typename Result, typename ArgumentTuple, int k1, int k2, int k3>\nclass SelectArgs<Result, ArgumentTuple,\n                 k1, k2, k3, -1, -1, -1, -1, -1, -1, -1> {\n public:\n  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),\n      GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3));\n  typedef typename Function<type>::ArgumentTuple SelectedArgs;\n  static SelectedArgs Select(const ArgumentTuple& args) {\n    using ::std::tr1::get;\n    return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args));\n  }\n};\n\ntemplate <typename Result, typename ArgumentTuple, int k1, int k2, int k3,\n    int k4>\nclass SelectArgs<Result, ArgumentTuple,\n                 k1, k2, k3, k4, -1, -1, -1, -1, -1, -1> {\n public:\n  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),\n      GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),\n      GMOCK_FIELD_(ArgumentTuple, k4));\n  typedef typename Function<type>::ArgumentTuple SelectedArgs;\n  static SelectedArgs Select(const ArgumentTuple& args) {\n    using ::std::tr1::get;\n    return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),\n        get<k4>(args));\n  }\n};\n\ntemplate <typename Result, typename ArgumentTuple, int k1, int k2, int k3,\n    int k4, int k5>\nclass SelectArgs<Result, ArgumentTuple,\n                 k1, k2, k3, k4, k5, -1, -1, -1, -1, -1> {\n public:\n  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),\n      GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),\n      GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5));\n  typedef typename Function<type>::ArgumentTuple SelectedArgs;\n  static SelectedArgs Select(const ArgumentTuple& args) {\n    using ::std::tr1::get;\n    return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),\n        get<k4>(args), get<k5>(args));\n  }\n};\n\ntemplate <typename Result, typename ArgumentTuple, int k1, int k2, int k3,\n    int k4, int k5, int k6>\nclass SelectArgs<Result, ArgumentTuple,\n                 k1, k2, k3, k4, k5, k6, -1, -1, -1, -1> {\n public:\n  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),\n      GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),\n      GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),\n      GMOCK_FIELD_(ArgumentTuple, k6));\n  typedef typename Function<type>::ArgumentTuple SelectedArgs;\n  static SelectedArgs Select(const ArgumentTuple& args) {\n    using ::std::tr1::get;\n    return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),\n        get<k4>(args), get<k5>(args), get<k6>(args));\n  }\n};\n\ntemplate <typename Result, typename ArgumentTuple, int k1, int k2, int k3,\n    int k4, int k5, int k6, int k7>\nclass SelectArgs<Result, ArgumentTuple,\n                 k1, k2, k3, k4, k5, k6, k7, -1, -1, -1> {\n public:\n  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),\n      GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),\n      GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),\n      GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7));\n  typedef typename Function<type>::ArgumentTuple SelectedArgs;\n  static SelectedArgs Select(const ArgumentTuple& args) {\n    using ::std::tr1::get;\n    return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),\n        get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args));\n  }\n};\n\ntemplate <typename Result, typename ArgumentTuple, int k1, int k2, int k3,\n    int k4, int k5, int k6, int k7, int k8>\nclass SelectArgs<Result, ArgumentTuple,\n                 k1, k2, k3, k4, k5, k6, k7, k8, -1, -1> {\n public:\n  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),\n      GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),\n      GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),\n      GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),\n      GMOCK_FIELD_(ArgumentTuple, k8));\n  typedef typename Function<type>::ArgumentTuple SelectedArgs;\n  static SelectedArgs Select(const ArgumentTuple& args) {\n    using ::std::tr1::get;\n    return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),\n        get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),\n        get<k8>(args));\n  }\n};\n\ntemplate <typename Result, typename ArgumentTuple, int k1, int k2, int k3,\n    int k4, int k5, int k6, int k7, int k8, int k9>\nclass SelectArgs<Result, ArgumentTuple,\n                 k1, k2, k3, k4, k5, k6, k7, k8, k9, -1> {\n public:\n  typedef Result type(GMOCK_FIELD_(ArgumentTuple, k1),\n      GMOCK_FIELD_(ArgumentTuple, k2), GMOCK_FIELD_(ArgumentTuple, k3),\n      GMOCK_FIELD_(ArgumentTuple, k4), GMOCK_FIELD_(ArgumentTuple, k5),\n      GMOCK_FIELD_(ArgumentTuple, k6), GMOCK_FIELD_(ArgumentTuple, k7),\n      GMOCK_FIELD_(ArgumentTuple, k8), GMOCK_FIELD_(ArgumentTuple, k9));\n  typedef typename Function<type>::ArgumentTuple SelectedArgs;\n  static SelectedArgs Select(const ArgumentTuple& args) {\n    using ::std::tr1::get;\n    return SelectedArgs(get<k1>(args), get<k2>(args), get<k3>(args),\n        get<k4>(args), get<k5>(args), get<k6>(args), get<k7>(args),\n        get<k8>(args), get<k9>(args));\n  }\n};\n\n#undef GMOCK_FIELD_\n\n// Implements the WithArgs action.\ntemplate <typename InnerAction, int k1 = -1, int k2 = -1, int k3 = -1,\n    int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,\n    int k9 = -1, int k10 = -1>\nclass WithArgsAction {\n public:\n  explicit WithArgsAction(const InnerAction& action) : action_(action) {}\n\n  template <typename F>\n  operator Action<F>() const { return MakeAction(new Impl<F>(action_)); }\n\n private:\n  template <typename F>\n  class Impl : public ActionInterface<F> {\n   public:\n    typedef typename Function<F>::Result Result;\n    typedef typename Function<F>::ArgumentTuple ArgumentTuple;\n\n    explicit Impl(const InnerAction& action) : action_(action) {}\n\n    virtual Result Perform(const ArgumentTuple& args) {\n      return action_.Perform(SelectArgs<Result, ArgumentTuple, k1, k2, k3, k4,\n          k5, k6, k7, k8, k9, k10>::Select(args));\n    }\n\n   private:\n    typedef typename SelectArgs<Result, ArgumentTuple,\n        k1, k2, k3, k4, k5, k6, k7, k8, k9, k10>::type InnerFunctionType;\n\n    Action<InnerFunctionType> action_;\n  };\n\n  const InnerAction action_;\n\n  GTEST_DISALLOW_ASSIGN_(WithArgsAction);\n};\n\n// A macro from the ACTION* family (defined later in this file)\n// defines an action that can be used in a mock function.  Typically,\n// these actions only care about a subset of the arguments of the mock\n// function.  For example, if such an action only uses the second\n// argument, it can be used in any mock function that takes >= 2\n// arguments where the type of the second argument is compatible.\n//\n// Therefore, the action implementation must be prepared to take more\n// arguments than it needs.  The ExcessiveArg type is used to\n// represent those excessive arguments.  In order to keep the compiler\n// error messages tractable, we define it in the testing namespace\n// instead of testing::internal.  However, this is an INTERNAL TYPE\n// and subject to change without notice, so a user MUST NOT USE THIS\n// TYPE DIRECTLY.\nstruct ExcessiveArg {};\n\n// A helper class needed for implementing the ACTION* macros.\ntemplate <typename Result, class Impl>\nclass ActionHelper {\n public:\n  static Result Perform(Impl* impl, const ::std::tr1::tuple<>& args) {\n    using ::std::tr1::get;\n    return impl->template gmock_PerformImpl<>(args, ExcessiveArg(),\n        ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),\n        ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),\n        ExcessiveArg());\n  }\n\n  template <typename A0>\n  static Result Perform(Impl* impl, const ::std::tr1::tuple<A0>& args) {\n    using ::std::tr1::get;\n    return impl->template gmock_PerformImpl<A0>(args, get<0>(args),\n        ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),\n        ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),\n        ExcessiveArg());\n  }\n\n  template <typename A0, typename A1>\n  static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1>& args) {\n    using ::std::tr1::get;\n    return impl->template gmock_PerformImpl<A0, A1>(args, get<0>(args),\n        get<1>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),\n        ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),\n        ExcessiveArg());\n  }\n\n  template <typename A0, typename A1, typename A2>\n  static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2>& args) {\n    using ::std::tr1::get;\n    return impl->template gmock_PerformImpl<A0, A1, A2>(args, get<0>(args),\n        get<1>(args), get<2>(args), ExcessiveArg(), ExcessiveArg(),\n        ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),\n        ExcessiveArg());\n  }\n\n  template <typename A0, typename A1, typename A2, typename A3>\n  static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2,\n      A3>& args) {\n    using ::std::tr1::get;\n    return impl->template gmock_PerformImpl<A0, A1, A2, A3>(args, get<0>(args),\n        get<1>(args), get<2>(args), get<3>(args), ExcessiveArg(),\n        ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),\n        ExcessiveArg());\n  }\n\n  template <typename A0, typename A1, typename A2, typename A3, typename A4>\n  static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3,\n      A4>& args) {\n    using ::std::tr1::get;\n    return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4>(args,\n        get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),\n        ExcessiveArg(), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),\n        ExcessiveArg());\n  }\n\n  template <typename A0, typename A1, typename A2, typename A3, typename A4,\n      typename A5>\n  static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,\n      A5>& args) {\n    using ::std::tr1::get;\n    return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5>(args,\n        get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),\n        get<5>(args), ExcessiveArg(), ExcessiveArg(), ExcessiveArg(),\n        ExcessiveArg());\n  }\n\n  template <typename A0, typename A1, typename A2, typename A3, typename A4,\n      typename A5, typename A6>\n  static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,\n      A5, A6>& args) {\n    using ::std::tr1::get;\n    return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6>(args,\n        get<0>(args), get<1>(args), get<2>(args), get<3>(args), get<4>(args),\n        get<5>(args), get<6>(args), ExcessiveArg(), ExcessiveArg(),\n        ExcessiveArg());\n  }\n\n  template <typename A0, typename A1, typename A2, typename A3, typename A4,\n      typename A5, typename A6, typename A7>\n  static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,\n      A5, A6, A7>& args) {\n    using ::std::tr1::get;\n    return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6,\n        A7>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),\n        get<4>(args), get<5>(args), get<6>(args), get<7>(args), ExcessiveArg(),\n        ExcessiveArg());\n  }\n\n  template <typename A0, typename A1, typename A2, typename A3, typename A4,\n      typename A5, typename A6, typename A7, typename A8>\n  static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,\n      A5, A6, A7, A8>& args) {\n    using ::std::tr1::get;\n    return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7,\n        A8>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),\n        get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),\n        ExcessiveArg());\n  }\n\n  template <typename A0, typename A1, typename A2, typename A3, typename A4,\n      typename A5, typename A6, typename A7, typename A8, typename A9>\n  static Result Perform(Impl* impl, const ::std::tr1::tuple<A0, A1, A2, A3, A4,\n      A5, A6, A7, A8, A9>& args) {\n    using ::std::tr1::get;\n    return impl->template gmock_PerformImpl<A0, A1, A2, A3, A4, A5, A6, A7, A8,\n        A9>(args, get<0>(args), get<1>(args), get<2>(args), get<3>(args),\n        get<4>(args), get<5>(args), get<6>(args), get<7>(args), get<8>(args),\n        get<9>(args));\n  }\n};\n\n}  // namespace internal\n\n// Various overloads for Invoke().\n\n// WithArgs<N1, N2, ..., Nk>(an_action) creates an action that passes\n// the selected arguments of the mock function to an_action and\n// performs it.  It serves as an adaptor between actions with\n// different argument lists.  C++ doesn't support default arguments for\n// function templates, so we have to overload it.\ntemplate <int k1, typename InnerAction>\ninline internal::WithArgsAction<InnerAction, k1>\nWithArgs(const InnerAction& action) {\n  return internal::WithArgsAction<InnerAction, k1>(action);\n}\n\ntemplate <int k1, int k2, typename InnerAction>\ninline internal::WithArgsAction<InnerAction, k1, k2>\nWithArgs(const InnerAction& action) {\n  return internal::WithArgsAction<InnerAction, k1, k2>(action);\n}\n\ntemplate <int k1, int k2, int k3, typename InnerAction>\ninline internal::WithArgsAction<InnerAction, k1, k2, k3>\nWithArgs(const InnerAction& action) {\n  return internal::WithArgsAction<InnerAction, k1, k2, k3>(action);\n}\n\ntemplate <int k1, int k2, int k3, int k4, typename InnerAction>\ninline internal::WithArgsAction<InnerAction, k1, k2, k3, k4>\nWithArgs(const InnerAction& action) {\n  return internal::WithArgsAction<InnerAction, k1, k2, k3, k4>(action);\n}\n\ntemplate <int k1, int k2, int k3, int k4, int k5, typename InnerAction>\ninline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5>\nWithArgs(const InnerAction& action) {\n  return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5>(action);\n}\n\ntemplate <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerAction>\ninline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6>\nWithArgs(const InnerAction& action) {\n  return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6>(action);\n}\n\ntemplate <int k1, int k2, int k3, int k4, int k5, int k6, int k7,\n    typename InnerAction>\ninline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7>\nWithArgs(const InnerAction& action) {\n  return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6,\n      k7>(action);\n}\n\ntemplate <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,\n    typename InnerAction>\ninline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8>\nWithArgs(const InnerAction& action) {\n  return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7,\n      k8>(action);\n}\n\ntemplate <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,\n    int k9, typename InnerAction>\ninline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8, k9>\nWithArgs(const InnerAction& action) {\n  return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,\n      k9>(action);\n}\n\ntemplate <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,\n    int k9, int k10, typename InnerAction>\ninline internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,\n    k9, k10>\nWithArgs(const InnerAction& action) {\n  return internal::WithArgsAction<InnerAction, k1, k2, k3, k4, k5, k6, k7, k8,\n      k9, k10>(action);\n}\n\n// Creates an action that does actions a1, a2, ..., sequentially in\n// each invocation.\ntemplate <typename Action1, typename Action2>\ninline internal::DoBothAction<Action1, Action2>\nDoAll(Action1 a1, Action2 a2) {\n  return internal::DoBothAction<Action1, Action2>(a1, a2);\n}\n\ntemplate <typename Action1, typename Action2, typename Action3>\ninline internal::DoBothAction<Action1, internal::DoBothAction<Action2,\n    Action3> >\nDoAll(Action1 a1, Action2 a2, Action3 a3) {\n  return DoAll(a1, DoAll(a2, a3));\n}\n\ntemplate <typename Action1, typename Action2, typename Action3,\n    typename Action4>\ninline internal::DoBothAction<Action1, internal::DoBothAction<Action2,\n    internal::DoBothAction<Action3, Action4> > >\nDoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4) {\n  return DoAll(a1, DoAll(a2, a3, a4));\n}\n\ntemplate <typename Action1, typename Action2, typename Action3,\n    typename Action4, typename Action5>\ninline internal::DoBothAction<Action1, internal::DoBothAction<Action2,\n    internal::DoBothAction<Action3, internal::DoBothAction<Action4,\n    Action5> > > >\nDoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5) {\n  return DoAll(a1, DoAll(a2, a3, a4, a5));\n}\n\ntemplate <typename Action1, typename Action2, typename Action3,\n    typename Action4, typename Action5, typename Action6>\ninline internal::DoBothAction<Action1, internal::DoBothAction<Action2,\n    internal::DoBothAction<Action3, internal::DoBothAction<Action4,\n    internal::DoBothAction<Action5, Action6> > > > >\nDoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6) {\n  return DoAll(a1, DoAll(a2, a3, a4, a5, a6));\n}\n\ntemplate <typename Action1, typename Action2, typename Action3,\n    typename Action4, typename Action5, typename Action6, typename Action7>\ninline internal::DoBothAction<Action1, internal::DoBothAction<Action2,\n    internal::DoBothAction<Action3, internal::DoBothAction<Action4,\n    internal::DoBothAction<Action5, internal::DoBothAction<Action6,\n    Action7> > > > > >\nDoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,\n    Action7 a7) {\n  return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7));\n}\n\ntemplate <typename Action1, typename Action2, typename Action3,\n    typename Action4, typename Action5, typename Action6, typename Action7,\n    typename Action8>\ninline internal::DoBothAction<Action1, internal::DoBothAction<Action2,\n    internal::DoBothAction<Action3, internal::DoBothAction<Action4,\n    internal::DoBothAction<Action5, internal::DoBothAction<Action6,\n    internal::DoBothAction<Action7, Action8> > > > > > >\nDoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,\n    Action7 a7, Action8 a8) {\n  return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8));\n}\n\ntemplate <typename Action1, typename Action2, typename Action3,\n    typename Action4, typename Action5, typename Action6, typename Action7,\n    typename Action8, typename Action9>\ninline internal::DoBothAction<Action1, internal::DoBothAction<Action2,\n    internal::DoBothAction<Action3, internal::DoBothAction<Action4,\n    internal::DoBothAction<Action5, internal::DoBothAction<Action6,\n    internal::DoBothAction<Action7, internal::DoBothAction<Action8,\n    Action9> > > > > > > >\nDoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,\n    Action7 a7, Action8 a8, Action9 a9) {\n  return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9));\n}\n\ntemplate <typename Action1, typename Action2, typename Action3,\n    typename Action4, typename Action5, typename Action6, typename Action7,\n    typename Action8, typename Action9, typename Action10>\ninline internal::DoBothAction<Action1, internal::DoBothAction<Action2,\n    internal::DoBothAction<Action3, internal::DoBothAction<Action4,\n    internal::DoBothAction<Action5, internal::DoBothAction<Action6,\n    internal::DoBothAction<Action7, internal::DoBothAction<Action8,\n    internal::DoBothAction<Action9, Action10> > > > > > > > >\nDoAll(Action1 a1, Action2 a2, Action3 a3, Action4 a4, Action5 a5, Action6 a6,\n    Action7 a7, Action8 a8, Action9 a9, Action10 a10) {\n  return DoAll(a1, DoAll(a2, a3, a4, a5, a6, a7, a8, a9, a10));\n}\n\n}  // namespace testing\n\n// The ACTION* family of macros can be used in a namespace scope to\n// define custom actions easily.  The syntax:\n//\n//   ACTION(name) { statements; }\n//\n// will define an action with the given name that executes the\n// statements.  The value returned by the statements will be used as\n// the return value of the action.  Inside the statements, you can\n// refer to the K-th (0-based) argument of the mock function by\n// 'argK', and refer to its type by 'argK_type'.  For example:\n//\n//   ACTION(IncrementArg1) {\n//     arg1_type temp = arg1;\n//     return ++(*temp);\n//   }\n//\n// allows you to write\n//\n//   ...WillOnce(IncrementArg1());\n//\n// You can also refer to the entire argument tuple and its type by\n// 'args' and 'args_type', and refer to the mock function type and its\n// return type by 'function_type' and 'return_type'.\n//\n// Note that you don't need to specify the types of the mock function\n// arguments.  However rest assured that your code is still type-safe:\n// you'll get a compiler error if *arg1 doesn't support the ++\n// operator, or if the type of ++(*arg1) isn't compatible with the\n// mock function's return type, for example.\n//\n// Sometimes you'll want to parameterize the action.   For that you can use\n// another macro:\n//\n//   ACTION_P(name, param_name) { statements; }\n//\n// For example:\n//\n//   ACTION_P(Add, n) { return arg0 + n; }\n//\n// will allow you to write:\n//\n//   ...WillOnce(Add(5));\n//\n// Note that you don't need to provide the type of the parameter\n// either.  If you need to reference the type of a parameter named\n// 'foo', you can write 'foo_type'.  For example, in the body of\n// ACTION_P(Add, n) above, you can write 'n_type' to refer to the type\n// of 'n'.\n//\n// We also provide ACTION_P2, ACTION_P3, ..., up to ACTION_P10 to support\n// multi-parameter actions.\n//\n// For the purpose of typing, you can view\n//\n//   ACTION_Pk(Foo, p1, ..., pk) { ... }\n//\n// as shorthand for\n//\n//   template <typename p1_type, ..., typename pk_type>\n//   FooActionPk<p1_type, ..., pk_type> Foo(p1_type p1, ..., pk_type pk) { ... }\n//\n// In particular, you can provide the template type arguments\n// explicitly when invoking Foo(), as in Foo<long, bool>(5, false);\n// although usually you can rely on the compiler to infer the types\n// for you automatically.  You can assign the result of expression\n// Foo(p1, ..., pk) to a variable of type FooActionPk<p1_type, ...,\n// pk_type>.  This can be useful when composing actions.\n//\n// You can also overload actions with different numbers of parameters:\n//\n//   ACTION_P(Plus, a) { ... }\n//   ACTION_P2(Plus, a, b) { ... }\n//\n// While it's tempting to always use the ACTION* macros when defining\n// a new action, you should also consider implementing ActionInterface\n// or using MakePolymorphicAction() instead, especially if you need to\n// use the action a lot.  While these approaches require more work,\n// they give you more control on the types of the mock function\n// arguments and the action parameters, which in general leads to\n// better compiler error messages that pay off in the long run.  They\n// also allow overloading actions based on parameter types (as opposed\n// to just based on the number of parameters).\n//\n// CAVEAT:\n//\n// ACTION*() can only be used in a namespace scope.  The reason is\n// that C++ doesn't yet allow function-local types to be used to\n// instantiate templates.  The up-coming C++0x standard will fix this.\n// Once that's done, we'll consider supporting using ACTION*() inside\n// a function.\n//\n// MORE INFORMATION:\n//\n// To learn more about using these macros, please search for 'ACTION'\n// on http://code.google.com/p/googlemock/wiki/CookBook.\n\n// An internal macro needed for implementing ACTION*().\n#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\\\n    const args_type& args GTEST_ATTRIBUTE_UNUSED_, \\\n    arg0_type arg0 GTEST_ATTRIBUTE_UNUSED_, \\\n    arg1_type arg1 GTEST_ATTRIBUTE_UNUSED_, \\\n    arg2_type arg2 GTEST_ATTRIBUTE_UNUSED_, \\\n    arg3_type arg3 GTEST_ATTRIBUTE_UNUSED_, \\\n    arg4_type arg4 GTEST_ATTRIBUTE_UNUSED_, \\\n    arg5_type arg5 GTEST_ATTRIBUTE_UNUSED_, \\\n    arg6_type arg6 GTEST_ATTRIBUTE_UNUSED_, \\\n    arg7_type arg7 GTEST_ATTRIBUTE_UNUSED_, \\\n    arg8_type arg8 GTEST_ATTRIBUTE_UNUSED_, \\\n    arg9_type arg9 GTEST_ATTRIBUTE_UNUSED_\n\n// Sometimes you want to give an action explicit template parameters\n// that cannot be inferred from its value parameters.  ACTION() and\n// ACTION_P*() don't support that.  ACTION_TEMPLATE() remedies that\n// and can be viewed as an extension to ACTION() and ACTION_P*().\n//\n// The syntax:\n//\n//   ACTION_TEMPLATE(ActionName,\n//                   HAS_m_TEMPLATE_PARAMS(kind1, name1, ..., kind_m, name_m),\n//                   AND_n_VALUE_PARAMS(p1, ..., p_n)) { statements; }\n//\n// defines an action template that takes m explicit template\n// parameters and n value parameters.  name_i is the name of the i-th\n// template parameter, and kind_i specifies whether it's a typename,\n// an integral constant, or a template.  p_i is the name of the i-th\n// value parameter.\n//\n// Example:\n//\n//   // DuplicateArg<k, T>(output) converts the k-th argument of the mock\n//   // function to type T and copies it to *output.\n//   ACTION_TEMPLATE(DuplicateArg,\n//                   HAS_2_TEMPLATE_PARAMS(int, k, typename, T),\n//                   AND_1_VALUE_PARAMS(output)) {\n//     *output = T(std::tr1::get<k>(args));\n//   }\n//   ...\n//     int n;\n//     EXPECT_CALL(mock, Foo(_, _))\n//         .WillOnce(DuplicateArg<1, unsigned char>(&n));\n//\n// To create an instance of an action template, write:\n//\n//   ActionName<t1, ..., t_m>(v1, ..., v_n)\n//\n// where the ts are the template arguments and the vs are the value\n// arguments.  The value argument types are inferred by the compiler.\n// If you want to explicitly specify the value argument types, you can\n// provide additional template arguments:\n//\n//   ActionName<t1, ..., t_m, u1, ..., u_k>(v1, ..., v_n)\n//\n// where u_i is the desired type of v_i.\n//\n// ACTION_TEMPLATE and ACTION/ACTION_P* can be overloaded on the\n// number of value parameters, but not on the number of template\n// parameters.  Without the restriction, the meaning of the following\n// is unclear:\n//\n//   OverloadedAction<int, bool>(x);\n//\n// Are we using a single-template-parameter action where 'bool' refers\n// to the type of x, or are we using a two-template-parameter action\n// where the compiler is asked to infer the type of x?\n//\n// Implementation notes:\n//\n// GMOCK_INTERNAL_*_HAS_m_TEMPLATE_PARAMS and\n// GMOCK_INTERNAL_*_AND_n_VALUE_PARAMS are internal macros for\n// implementing ACTION_TEMPLATE.  The main trick we use is to create\n// new macro invocations when expanding a macro.  For example, we have\n//\n//   #define ACTION_TEMPLATE(name, template_params, value_params)\n//       ... GMOCK_INTERNAL_DECL_##template_params ...\n//\n// which causes ACTION_TEMPLATE(..., HAS_1_TEMPLATE_PARAMS(typename, T), ...)\n// to expand to\n//\n//       ... GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(typename, T) ...\n//\n// Since GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS is a macro, the\n// preprocessor will continue to expand it to\n//\n//       ... typename T ...\n//\n// This technique conforms to the C++ standard and is portable.  It\n// allows us to implement action templates using O(N) code, where N is\n// the maximum number of template/value parameters supported.  Without\n// using it, we'd have to devote O(N^2) amount of code to implement all\n// combinations of m and n.\n\n// Declares the template parameters.\n#define GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(kind0, name0) kind0 name0\n#define GMOCK_INTERNAL_DECL_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \\\n    name1) kind0 name0, kind1 name1\n#define GMOCK_INTERNAL_DECL_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2) kind0 name0, kind1 name1, kind2 name2\n#define GMOCK_INTERNAL_DECL_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3) kind0 name0, kind1 name1, kind2 name2, \\\n    kind3 name3\n#define GMOCK_INTERNAL_DECL_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3, kind4, name4) kind0 name0, kind1 name1, \\\n    kind2 name2, kind3 name3, kind4 name4\n#define GMOCK_INTERNAL_DECL_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3, kind4, name4, kind5, name5) kind0 name0, \\\n    kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5\n#define GMOCK_INTERNAL_DECL_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \\\n    name6) kind0 name0, kind1 name1, kind2 name2, kind3 name3, kind4 name4, \\\n    kind5 name5, kind6 name6\n#define GMOCK_INTERNAL_DECL_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \\\n    kind7, name7) kind0 name0, kind1 name1, kind2 name2, kind3 name3, \\\n    kind4 name4, kind5 name5, kind6 name6, kind7 name7\n#define GMOCK_INTERNAL_DECL_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \\\n    kind7, name7, kind8, name8) kind0 name0, kind1 name1, kind2 name2, \\\n    kind3 name3, kind4 name4, kind5 name5, kind6 name6, kind7 name7, \\\n    kind8 name8\n#define GMOCK_INTERNAL_DECL_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \\\n    name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \\\n    name6, kind7, name7, kind8, name8, kind9, name9) kind0 name0, \\\n    kind1 name1, kind2 name2, kind3 name3, kind4 name4, kind5 name5, \\\n    kind6 name6, kind7 name7, kind8 name8, kind9 name9\n\n// Lists the template parameters.\n#define GMOCK_INTERNAL_LIST_HAS_1_TEMPLATE_PARAMS(kind0, name0) name0\n#define GMOCK_INTERNAL_LIST_HAS_2_TEMPLATE_PARAMS(kind0, name0, kind1, \\\n    name1) name0, name1\n#define GMOCK_INTERNAL_LIST_HAS_3_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2) name0, name1, name2\n#define GMOCK_INTERNAL_LIST_HAS_4_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3) name0, name1, name2, name3\n#define GMOCK_INTERNAL_LIST_HAS_5_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3, kind4, name4) name0, name1, name2, name3, \\\n    name4\n#define GMOCK_INTERNAL_LIST_HAS_6_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3, kind4, name4, kind5, name5) name0, name1, \\\n    name2, name3, name4, name5\n#define GMOCK_INTERNAL_LIST_HAS_7_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \\\n    name6) name0, name1, name2, name3, name4, name5, name6\n#define GMOCK_INTERNAL_LIST_HAS_8_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \\\n    kind7, name7) name0, name1, name2, name3, name4, name5, name6, name7\n#define GMOCK_INTERNAL_LIST_HAS_9_TEMPLATE_PARAMS(kind0, name0, kind1, name1, \\\n    kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, name6, \\\n    kind7, name7, kind8, name8) name0, name1, name2, name3, name4, name5, \\\n    name6, name7, name8\n#define GMOCK_INTERNAL_LIST_HAS_10_TEMPLATE_PARAMS(kind0, name0, kind1, \\\n    name1, kind2, name2, kind3, name3, kind4, name4, kind5, name5, kind6, \\\n    name6, kind7, name7, kind8, name8, kind9, name9) name0, name1, name2, \\\n    name3, name4, name5, name6, name7, name8, name9\n\n// Declares the types of value parameters.\n#define GMOCK_INTERNAL_DECL_TYPE_AND_0_VALUE_PARAMS()\n#define GMOCK_INTERNAL_DECL_TYPE_AND_1_VALUE_PARAMS(p0) , typename p0##_type\n#define GMOCK_INTERNAL_DECL_TYPE_AND_2_VALUE_PARAMS(p0, p1) , \\\n    typename p0##_type, typename p1##_type\n#define GMOCK_INTERNAL_DECL_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , \\\n    typename p0##_type, typename p1##_type, typename p2##_type\n#define GMOCK_INTERNAL_DECL_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \\\n    typename p0##_type, typename p1##_type, typename p2##_type, \\\n    typename p3##_type\n#define GMOCK_INTERNAL_DECL_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \\\n    typename p0##_type, typename p1##_type, typename p2##_type, \\\n    typename p3##_type, typename p4##_type\n#define GMOCK_INTERNAL_DECL_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \\\n    typename p0##_type, typename p1##_type, typename p2##_type, \\\n    typename p3##_type, typename p4##_type, typename p5##_type\n#define GMOCK_INTERNAL_DECL_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \\\n    p6) , typename p0##_type, typename p1##_type, typename p2##_type, \\\n    typename p3##_type, typename p4##_type, typename p5##_type, \\\n    typename p6##_type\n#define GMOCK_INTERNAL_DECL_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \\\n    p6, p7) , typename p0##_type, typename p1##_type, typename p2##_type, \\\n    typename p3##_type, typename p4##_type, typename p5##_type, \\\n    typename p6##_type, typename p7##_type\n#define GMOCK_INTERNAL_DECL_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \\\n    p6, p7, p8) , typename p0##_type, typename p1##_type, typename p2##_type, \\\n    typename p3##_type, typename p4##_type, typename p5##_type, \\\n    typename p6##_type, typename p7##_type, typename p8##_type\n#define GMOCK_INTERNAL_DECL_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \\\n    p6, p7, p8, p9) , typename p0##_type, typename p1##_type, \\\n    typename p2##_type, typename p3##_type, typename p4##_type, \\\n    typename p5##_type, typename p6##_type, typename p7##_type, \\\n    typename p8##_type, typename p9##_type\n\n// Initializes the value parameters.\n#define GMOCK_INTERNAL_INIT_AND_0_VALUE_PARAMS()\\\n    ()\n#define GMOCK_INTERNAL_INIT_AND_1_VALUE_PARAMS(p0)\\\n    (p0##_type gmock_p0) : p0(gmock_p0)\n#define GMOCK_INTERNAL_INIT_AND_2_VALUE_PARAMS(p0, p1)\\\n    (p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), p1(gmock_p1)\n#define GMOCK_INTERNAL_INIT_AND_3_VALUE_PARAMS(p0, p1, p2)\\\n    (p0##_type gmock_p0, p1##_type gmock_p1, \\\n        p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2)\n#define GMOCK_INTERNAL_INIT_AND_4_VALUE_PARAMS(p0, p1, p2, p3)\\\n    (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n        p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \\\n        p3(gmock_p3)\n#define GMOCK_INTERNAL_INIT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)\\\n    (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n        p3##_type gmock_p3, p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), \\\n        p2(gmock_p2), p3(gmock_p3), p4(gmock_p4)\n#define GMOCK_INTERNAL_INIT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)\\\n    (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n        p3##_type gmock_p3, p4##_type gmock_p4, \\\n        p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \\\n        p3(gmock_p3), p4(gmock_p4), p5(gmock_p5)\n#define GMOCK_INTERNAL_INIT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)\\\n    (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n        p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \\\n        p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \\\n        p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6)\n#define GMOCK_INTERNAL_INIT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)\\\n    (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n        p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \\\n        p6##_type gmock_p6, p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), \\\n        p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \\\n        p7(gmock_p7)\n#define GMOCK_INTERNAL_INIT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7, p8)\\\n    (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n        p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \\\n        p6##_type gmock_p6, p7##_type gmock_p7, \\\n        p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \\\n        p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \\\n        p8(gmock_p8)\n#define GMOCK_INTERNAL_INIT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7, p8, p9)\\\n    (p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n        p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \\\n        p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \\\n        p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \\\n        p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \\\n        p8(gmock_p8), p9(gmock_p9)\n\n// Declares the fields for storing the value parameters.\n#define GMOCK_INTERNAL_DEFN_AND_0_VALUE_PARAMS()\n#define GMOCK_INTERNAL_DEFN_AND_1_VALUE_PARAMS(p0) p0##_type p0;\n#define GMOCK_INTERNAL_DEFN_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0; \\\n    p1##_type p1;\n#define GMOCK_INTERNAL_DEFN_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0; \\\n    p1##_type p1; p2##_type p2;\n#define GMOCK_INTERNAL_DEFN_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0; \\\n    p1##_type p1; p2##_type p2; p3##_type p3;\n#define GMOCK_INTERNAL_DEFN_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \\\n    p4) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4;\n#define GMOCK_INTERNAL_DEFN_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \\\n    p5) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \\\n    p5##_type p5;\n#define GMOCK_INTERNAL_DEFN_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \\\n    p6) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \\\n    p5##_type p5; p6##_type p6;\n#define GMOCK_INTERNAL_DEFN_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; p4##_type p4; \\\n    p5##_type p5; p6##_type p6; p7##_type p7;\n#define GMOCK_INTERNAL_DEFN_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7, p8) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \\\n    p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8;\n#define GMOCK_INTERNAL_DEFN_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7, p8, p9) p0##_type p0; p1##_type p1; p2##_type p2; p3##_type p3; \\\n    p4##_type p4; p5##_type p5; p6##_type p6; p7##_type p7; p8##_type p8; \\\n    p9##_type p9;\n\n// Lists the value parameters.\n#define GMOCK_INTERNAL_LIST_AND_0_VALUE_PARAMS()\n#define GMOCK_INTERNAL_LIST_AND_1_VALUE_PARAMS(p0) p0\n#define GMOCK_INTERNAL_LIST_AND_2_VALUE_PARAMS(p0, p1) p0, p1\n#define GMOCK_INTERNAL_LIST_AND_3_VALUE_PARAMS(p0, p1, p2) p0, p1, p2\n#define GMOCK_INTERNAL_LIST_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0, p1, p2, p3\n#define GMOCK_INTERNAL_LIST_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) p0, p1, \\\n    p2, p3, p4\n#define GMOCK_INTERNAL_LIST_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) p0, \\\n    p1, p2, p3, p4, p5\n#define GMOCK_INTERNAL_LIST_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \\\n    p6) p0, p1, p2, p3, p4, p5, p6\n#define GMOCK_INTERNAL_LIST_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7) p0, p1, p2, p3, p4, p5, p6, p7\n#define GMOCK_INTERNAL_LIST_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7, p8) p0, p1, p2, p3, p4, p5, p6, p7, p8\n#define GMOCK_INTERNAL_LIST_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7, p8, p9) p0, p1, p2, p3, p4, p5, p6, p7, p8, p9\n\n// Lists the value parameter types.\n#define GMOCK_INTERNAL_LIST_TYPE_AND_0_VALUE_PARAMS()\n#define GMOCK_INTERNAL_LIST_TYPE_AND_1_VALUE_PARAMS(p0) , p0##_type\n#define GMOCK_INTERNAL_LIST_TYPE_AND_2_VALUE_PARAMS(p0, p1) , p0##_type, \\\n    p1##_type\n#define GMOCK_INTERNAL_LIST_TYPE_AND_3_VALUE_PARAMS(p0, p1, p2) , p0##_type, \\\n    p1##_type, p2##_type\n#define GMOCK_INTERNAL_LIST_TYPE_AND_4_VALUE_PARAMS(p0, p1, p2, p3) , \\\n    p0##_type, p1##_type, p2##_type, p3##_type\n#define GMOCK_INTERNAL_LIST_TYPE_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) , \\\n    p0##_type, p1##_type, p2##_type, p3##_type, p4##_type\n#define GMOCK_INTERNAL_LIST_TYPE_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) , \\\n    p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type\n#define GMOCK_INTERNAL_LIST_TYPE_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \\\n    p6) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, p5##_type, \\\n    p6##_type\n#define GMOCK_INTERNAL_LIST_TYPE_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \\\n    p6, p7) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \\\n    p5##_type, p6##_type, p7##_type\n#define GMOCK_INTERNAL_LIST_TYPE_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \\\n    p6, p7, p8) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \\\n    p5##_type, p6##_type, p7##_type, p8##_type\n#define GMOCK_INTERNAL_LIST_TYPE_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \\\n    p6, p7, p8, p9) , p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \\\n    p5##_type, p6##_type, p7##_type, p8##_type, p9##_type\n\n// Declares the value parameters.\n#define GMOCK_INTERNAL_DECL_AND_0_VALUE_PARAMS()\n#define GMOCK_INTERNAL_DECL_AND_1_VALUE_PARAMS(p0) p0##_type p0\n#define GMOCK_INTERNAL_DECL_AND_2_VALUE_PARAMS(p0, p1) p0##_type p0, \\\n    p1##_type p1\n#define GMOCK_INTERNAL_DECL_AND_3_VALUE_PARAMS(p0, p1, p2) p0##_type p0, \\\n    p1##_type p1, p2##_type p2\n#define GMOCK_INTERNAL_DECL_AND_4_VALUE_PARAMS(p0, p1, p2, p3) p0##_type p0, \\\n    p1##_type p1, p2##_type p2, p3##_type p3\n#define GMOCK_INTERNAL_DECL_AND_5_VALUE_PARAMS(p0, p1, p2, p3, \\\n    p4) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4\n#define GMOCK_INTERNAL_DECL_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, \\\n    p5) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \\\n    p5##_type p5\n#define GMOCK_INTERNAL_DECL_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, \\\n    p6) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \\\n    p5##_type p5, p6##_type p6\n#define GMOCK_INTERNAL_DECL_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, \\\n    p5##_type p5, p6##_type p6, p7##_type p7\n#define GMOCK_INTERNAL_DECL_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7, p8) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \\\n    p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8\n#define GMOCK_INTERNAL_DECL_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7, p8, p9) p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \\\n    p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \\\n    p9##_type p9\n\n// The suffix of the class template implementing the action template.\n#define GMOCK_INTERNAL_COUNT_AND_0_VALUE_PARAMS()\n#define GMOCK_INTERNAL_COUNT_AND_1_VALUE_PARAMS(p0) P\n#define GMOCK_INTERNAL_COUNT_AND_2_VALUE_PARAMS(p0, p1) P2\n#define GMOCK_INTERNAL_COUNT_AND_3_VALUE_PARAMS(p0, p1, p2) P3\n#define GMOCK_INTERNAL_COUNT_AND_4_VALUE_PARAMS(p0, p1, p2, p3) P4\n#define GMOCK_INTERNAL_COUNT_AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4) P5\n#define GMOCK_INTERNAL_COUNT_AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5) P6\n#define GMOCK_INTERNAL_COUNT_AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6) P7\n#define GMOCK_INTERNAL_COUNT_AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7) P8\n#define GMOCK_INTERNAL_COUNT_AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7, p8) P9\n#define GMOCK_INTERNAL_COUNT_AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, \\\n    p7, p8, p9) P10\n\n// The name of the class template implementing the action template.\n#define GMOCK_ACTION_CLASS_(name, value_params)\\\n    GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)\n\n#define ACTION_TEMPLATE(name, template_params, value_params)\\\n  template <GMOCK_INTERNAL_DECL_##template_params\\\n            GMOCK_INTERNAL_DECL_TYPE_##value_params>\\\n  class GMOCK_ACTION_CLASS_(name, value_params) {\\\n   public:\\\n    GMOCK_ACTION_CLASS_(name, value_params)\\\n        GMOCK_INTERNAL_INIT_##value_params {}\\\n    template <typename F>\\\n    class gmock_Impl : public ::testing::ActionInterface<F> {\\\n     public:\\\n      typedef F function_type;\\\n      typedef typename ::testing::internal::Function<F>::Result return_type;\\\n      typedef typename ::testing::internal::Function<F>::ArgumentTuple\\\n          args_type;\\\n      explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {}\\\n      virtual return_type Perform(const args_type& args) {\\\n        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\\\n            Perform(this, args);\\\n      }\\\n      template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n          typename arg3_type, typename arg4_type, typename arg5_type, \\\n          typename arg6_type, typename arg7_type, typename arg8_type, \\\n          typename arg9_type>\\\n      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \\\n          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \\\n          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \\\n          arg9_type arg9) const;\\\n      GMOCK_INTERNAL_DEFN_##value_params\\\n     private:\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename F> operator ::testing::Action<F>() const {\\\n      return ::testing::Action<F>(\\\n          new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\\\n    }\\\n    GMOCK_INTERNAL_DEFN_##value_params\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\\\n  };\\\n  template <GMOCK_INTERNAL_DECL_##template_params\\\n            GMOCK_INTERNAL_DECL_TYPE_##value_params>\\\n  inline GMOCK_ACTION_CLASS_(name, value_params)<\\\n      GMOCK_INTERNAL_LIST_##template_params\\\n      GMOCK_INTERNAL_LIST_TYPE_##value_params> name(\\\n          GMOCK_INTERNAL_DECL_##value_params) {\\\n    return GMOCK_ACTION_CLASS_(name, value_params)<\\\n        GMOCK_INTERNAL_LIST_##template_params\\\n        GMOCK_INTERNAL_LIST_TYPE_##value_params>(\\\n            GMOCK_INTERNAL_LIST_##value_params);\\\n  }\\\n  template <GMOCK_INTERNAL_DECL_##template_params\\\n            GMOCK_INTERNAL_DECL_TYPE_##value_params>\\\n  template <typename F>\\\n  template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n      typename arg3_type, typename arg4_type, typename arg5_type, \\\n      typename arg6_type, typename arg7_type, typename arg8_type, \\\n      typename arg9_type>\\\n  typename ::testing::internal::Function<F>::Result\\\n      GMOCK_ACTION_CLASS_(name, value_params)<\\\n          GMOCK_INTERNAL_LIST_##template_params\\\n          GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl<F>::\\\n              gmock_PerformImpl(\\\n          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const\n\n#define ACTION(name)\\\n  class name##Action {\\\n   public:\\\n    name##Action() {}\\\n    template <typename F>\\\n    class gmock_Impl : public ::testing::ActionInterface<F> {\\\n     public:\\\n      typedef F function_type;\\\n      typedef typename ::testing::internal::Function<F>::Result return_type;\\\n      typedef typename ::testing::internal::Function<F>::ArgumentTuple\\\n          args_type;\\\n      gmock_Impl() {}\\\n      virtual return_type Perform(const args_type& args) {\\\n        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\\\n            Perform(this, args);\\\n      }\\\n      template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n          typename arg3_type, typename arg4_type, typename arg5_type, \\\n          typename arg6_type, typename arg7_type, typename arg8_type, \\\n          typename arg9_type>\\\n      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \\\n          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \\\n          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \\\n          arg9_type arg9) const;\\\n     private:\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename F> operator ::testing::Action<F>() const {\\\n      return ::testing::Action<F>(new gmock_Impl<F>());\\\n    }\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(name##Action);\\\n  };\\\n  inline name##Action name() {\\\n    return name##Action();\\\n  }\\\n  template <typename F>\\\n  template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n      typename arg3_type, typename arg4_type, typename arg5_type, \\\n      typename arg6_type, typename arg7_type, typename arg8_type, \\\n      typename arg9_type>\\\n  typename ::testing::internal::Function<F>::Result\\\n      name##Action::gmock_Impl<F>::gmock_PerformImpl(\\\n          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const\n\n#define ACTION_P(name, p0)\\\n  template <typename p0##_type>\\\n  class name##ActionP {\\\n   public:\\\n    name##ActionP(p0##_type gmock_p0) : p0(gmock_p0) {}\\\n    template <typename F>\\\n    class gmock_Impl : public ::testing::ActionInterface<F> {\\\n     public:\\\n      typedef F function_type;\\\n      typedef typename ::testing::internal::Function<F>::Result return_type;\\\n      typedef typename ::testing::internal::Function<F>::ArgumentTuple\\\n          args_type;\\\n      explicit gmock_Impl(p0##_type gmock_p0) : p0(gmock_p0) {}\\\n      virtual return_type Perform(const args_type& args) {\\\n        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\\\n            Perform(this, args);\\\n      }\\\n      template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n          typename arg3_type, typename arg4_type, typename arg5_type, \\\n          typename arg6_type, typename arg7_type, typename arg8_type, \\\n          typename arg9_type>\\\n      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \\\n          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \\\n          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \\\n          arg9_type arg9) const;\\\n      p0##_type p0;\\\n     private:\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename F> operator ::testing::Action<F>() const {\\\n      return ::testing::Action<F>(new gmock_Impl<F>(p0));\\\n    }\\\n    p0##_type p0;\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(name##ActionP);\\\n  };\\\n  template <typename p0##_type>\\\n  inline name##ActionP<p0##_type> name(p0##_type p0) {\\\n    return name##ActionP<p0##_type>(p0);\\\n  }\\\n  template <typename p0##_type>\\\n  template <typename F>\\\n  template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n      typename arg3_type, typename arg4_type, typename arg5_type, \\\n      typename arg6_type, typename arg7_type, typename arg8_type, \\\n      typename arg9_type>\\\n  typename ::testing::internal::Function<F>::Result\\\n      name##ActionP<p0##_type>::gmock_Impl<F>::gmock_PerformImpl(\\\n          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const\n\n#define ACTION_P2(name, p0, p1)\\\n  template <typename p0##_type, typename p1##_type>\\\n  class name##ActionP2 {\\\n   public:\\\n    name##ActionP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \\\n        p1(gmock_p1) {}\\\n    template <typename F>\\\n    class gmock_Impl : public ::testing::ActionInterface<F> {\\\n     public:\\\n      typedef F function_type;\\\n      typedef typename ::testing::internal::Function<F>::Result return_type;\\\n      typedef typename ::testing::internal::Function<F>::ArgumentTuple\\\n          args_type;\\\n      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \\\n          p1(gmock_p1) {}\\\n      virtual return_type Perform(const args_type& args) {\\\n        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\\\n            Perform(this, args);\\\n      }\\\n      template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n          typename arg3_type, typename arg4_type, typename arg5_type, \\\n          typename arg6_type, typename arg7_type, typename arg8_type, \\\n          typename arg9_type>\\\n      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \\\n          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \\\n          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \\\n          arg9_type arg9) const;\\\n      p0##_type p0;\\\n      p1##_type p1;\\\n     private:\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename F> operator ::testing::Action<F>() const {\\\n      return ::testing::Action<F>(new gmock_Impl<F>(p0, p1));\\\n    }\\\n    p0##_type p0;\\\n    p1##_type p1;\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(name##ActionP2);\\\n  };\\\n  template <typename p0##_type, typename p1##_type>\\\n  inline name##ActionP2<p0##_type, p1##_type> name(p0##_type p0, \\\n      p1##_type p1) {\\\n    return name##ActionP2<p0##_type, p1##_type>(p0, p1);\\\n  }\\\n  template <typename p0##_type, typename p1##_type>\\\n  template <typename F>\\\n  template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n      typename arg3_type, typename arg4_type, typename arg5_type, \\\n      typename arg6_type, typename arg7_type, typename arg8_type, \\\n      typename arg9_type>\\\n  typename ::testing::internal::Function<F>::Result\\\n      name##ActionP2<p0##_type, p1##_type>::gmock_Impl<F>::gmock_PerformImpl(\\\n          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const\n\n#define ACTION_P3(name, p0, p1, p2)\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type>\\\n  class name##ActionP3 {\\\n   public:\\\n    name##ActionP3(p0##_type gmock_p0, p1##_type gmock_p1, \\\n        p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\\\n    template <typename F>\\\n    class gmock_Impl : public ::testing::ActionInterface<F> {\\\n     public:\\\n      typedef F function_type;\\\n      typedef typename ::testing::internal::Function<F>::Result return_type;\\\n      typedef typename ::testing::internal::Function<F>::ArgumentTuple\\\n          args_type;\\\n      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, \\\n          p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\\\n      virtual return_type Perform(const args_type& args) {\\\n        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\\\n            Perform(this, args);\\\n      }\\\n      template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n          typename arg3_type, typename arg4_type, typename arg5_type, \\\n          typename arg6_type, typename arg7_type, typename arg8_type, \\\n          typename arg9_type>\\\n      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \\\n          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \\\n          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \\\n          arg9_type arg9) const;\\\n      p0##_type p0;\\\n      p1##_type p1;\\\n      p2##_type p2;\\\n     private:\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename F> operator ::testing::Action<F>() const {\\\n      return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2));\\\n    }\\\n    p0##_type p0;\\\n    p1##_type p1;\\\n    p2##_type p2;\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(name##ActionP3);\\\n  };\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type>\\\n  inline name##ActionP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \\\n      p1##_type p1, p2##_type p2) {\\\n    return name##ActionP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\\\n  }\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type>\\\n  template <typename F>\\\n  template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n      typename arg3_type, typename arg4_type, typename arg5_type, \\\n      typename arg6_type, typename arg7_type, typename arg8_type, \\\n      typename arg9_type>\\\n  typename ::testing::internal::Function<F>::Result\\\n      name##ActionP3<p0##_type, p1##_type, \\\n          p2##_type>::gmock_Impl<F>::gmock_PerformImpl(\\\n          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const\n\n#define ACTION_P4(name, p0, p1, p2, p3)\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type>\\\n  class name##ActionP4 {\\\n   public:\\\n    name##ActionP4(p0##_type gmock_p0, p1##_type gmock_p1, \\\n        p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), \\\n        p2(gmock_p2), p3(gmock_p3) {}\\\n    template <typename F>\\\n    class gmock_Impl : public ::testing::ActionInterface<F> {\\\n     public:\\\n      typedef F function_type;\\\n      typedef typename ::testing::internal::Function<F>::Result return_type;\\\n      typedef typename ::testing::internal::Function<F>::ArgumentTuple\\\n          args_type;\\\n      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n          p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \\\n          p3(gmock_p3) {}\\\n      virtual return_type Perform(const args_type& args) {\\\n        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\\\n            Perform(this, args);\\\n      }\\\n      template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n          typename arg3_type, typename arg4_type, typename arg5_type, \\\n          typename arg6_type, typename arg7_type, typename arg8_type, \\\n          typename arg9_type>\\\n      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \\\n          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \\\n          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \\\n          arg9_type arg9) const;\\\n      p0##_type p0;\\\n      p1##_type p1;\\\n      p2##_type p2;\\\n      p3##_type p3;\\\n     private:\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename F> operator ::testing::Action<F>() const {\\\n      return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3));\\\n    }\\\n    p0##_type p0;\\\n    p1##_type p1;\\\n    p2##_type p2;\\\n    p3##_type p3;\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(name##ActionP4);\\\n  };\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type>\\\n  inline name##ActionP4<p0##_type, p1##_type, p2##_type, \\\n      p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \\\n      p3##_type p3) {\\\n    return name##ActionP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, p1, \\\n        p2, p3);\\\n  }\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type>\\\n  template <typename F>\\\n  template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n      typename arg3_type, typename arg4_type, typename arg5_type, \\\n      typename arg6_type, typename arg7_type, typename arg8_type, \\\n      typename arg9_type>\\\n  typename ::testing::internal::Function<F>::Result\\\n      name##ActionP4<p0##_type, p1##_type, p2##_type, \\\n          p3##_type>::gmock_Impl<F>::gmock_PerformImpl(\\\n          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const\n\n#define ACTION_P5(name, p0, p1, p2, p3, p4)\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type>\\\n  class name##ActionP5 {\\\n   public:\\\n    name##ActionP5(p0##_type gmock_p0, p1##_type gmock_p1, \\\n        p2##_type gmock_p2, p3##_type gmock_p3, \\\n        p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \\\n        p3(gmock_p3), p4(gmock_p4) {}\\\n    template <typename F>\\\n    class gmock_Impl : public ::testing::ActionInterface<F> {\\\n     public:\\\n      typedef F function_type;\\\n      typedef typename ::testing::internal::Function<F>::Result return_type;\\\n      typedef typename ::testing::internal::Function<F>::ArgumentTuple\\\n          args_type;\\\n      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n          p3##_type gmock_p3, p4##_type gmock_p4) : p0(gmock_p0), \\\n          p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), p4(gmock_p4) {}\\\n      virtual return_type Perform(const args_type& args) {\\\n        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\\\n            Perform(this, args);\\\n      }\\\n      template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n          typename arg3_type, typename arg4_type, typename arg5_type, \\\n          typename arg6_type, typename arg7_type, typename arg8_type, \\\n          typename arg9_type>\\\n      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \\\n          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \\\n          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \\\n          arg9_type arg9) const;\\\n      p0##_type p0;\\\n      p1##_type p1;\\\n      p2##_type p2;\\\n      p3##_type p3;\\\n      p4##_type p4;\\\n     private:\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename F> operator ::testing::Action<F>() const {\\\n      return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4));\\\n    }\\\n    p0##_type p0;\\\n    p1##_type p1;\\\n    p2##_type p2;\\\n    p3##_type p3;\\\n    p4##_type p4;\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(name##ActionP5);\\\n  };\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type>\\\n  inline name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \\\n      p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \\\n      p4##_type p4) {\\\n    return name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \\\n        p4##_type>(p0, p1, p2, p3, p4);\\\n  }\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type>\\\n  template <typename F>\\\n  template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n      typename arg3_type, typename arg4_type, typename arg5_type, \\\n      typename arg6_type, typename arg7_type, typename arg8_type, \\\n      typename arg9_type>\\\n  typename ::testing::internal::Function<F>::Result\\\n      name##ActionP5<p0##_type, p1##_type, p2##_type, p3##_type, \\\n          p4##_type>::gmock_Impl<F>::gmock_PerformImpl(\\\n          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const\n\n#define ACTION_P6(name, p0, p1, p2, p3, p4, p5)\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type>\\\n  class name##ActionP6 {\\\n   public:\\\n    name##ActionP6(p0##_type gmock_p0, p1##_type gmock_p1, \\\n        p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \\\n        p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \\\n        p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {}\\\n    template <typename F>\\\n    class gmock_Impl : public ::testing::ActionInterface<F> {\\\n     public:\\\n      typedef F function_type;\\\n      typedef typename ::testing::internal::Function<F>::Result return_type;\\\n      typedef typename ::testing::internal::Function<F>::ArgumentTuple\\\n          args_type;\\\n      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n          p3##_type gmock_p3, p4##_type gmock_p4, \\\n          p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \\\n          p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {}\\\n      virtual return_type Perform(const args_type& args) {\\\n        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\\\n            Perform(this, args);\\\n      }\\\n      template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n          typename arg3_type, typename arg4_type, typename arg5_type, \\\n          typename arg6_type, typename arg7_type, typename arg8_type, \\\n          typename arg9_type>\\\n      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \\\n          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \\\n          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \\\n          arg9_type arg9) const;\\\n      p0##_type p0;\\\n      p1##_type p1;\\\n      p2##_type p2;\\\n      p3##_type p3;\\\n      p4##_type p4;\\\n      p5##_type p5;\\\n     private:\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename F> operator ::testing::Action<F>() const {\\\n      return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5));\\\n    }\\\n    p0##_type p0;\\\n    p1##_type p1;\\\n    p2##_type p2;\\\n    p3##_type p3;\\\n    p4##_type p4;\\\n    p5##_type p5;\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(name##ActionP6);\\\n  };\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type>\\\n  inline name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \\\n      p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \\\n      p3##_type p3, p4##_type p4, p5##_type p5) {\\\n    return name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, \\\n        p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\\\n  }\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type>\\\n  template <typename F>\\\n  template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n      typename arg3_type, typename arg4_type, typename arg5_type, \\\n      typename arg6_type, typename arg7_type, typename arg8_type, \\\n      typename arg9_type>\\\n  typename ::testing::internal::Function<F>::Result\\\n      name##ActionP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \\\n          p5##_type>::gmock_Impl<F>::gmock_PerformImpl(\\\n          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const\n\n#define ACTION_P7(name, p0, p1, p2, p3, p4, p5, p6)\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type>\\\n  class name##ActionP7 {\\\n   public:\\\n    name##ActionP7(p0##_type gmock_p0, p1##_type gmock_p1, \\\n        p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \\\n        p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), \\\n        p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \\\n        p6(gmock_p6) {}\\\n    template <typename F>\\\n    class gmock_Impl : public ::testing::ActionInterface<F> {\\\n     public:\\\n      typedef F function_type;\\\n      typedef typename ::testing::internal::Function<F>::Result return_type;\\\n      typedef typename ::testing::internal::Function<F>::ArgumentTuple\\\n          args_type;\\\n      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n          p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \\\n          p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \\\n          p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6) {}\\\n      virtual return_type Perform(const args_type& args) {\\\n        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\\\n            Perform(this, args);\\\n      }\\\n      template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n          typename arg3_type, typename arg4_type, typename arg5_type, \\\n          typename arg6_type, typename arg7_type, typename arg8_type, \\\n          typename arg9_type>\\\n      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \\\n          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \\\n          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \\\n          arg9_type arg9) const;\\\n      p0##_type p0;\\\n      p1##_type p1;\\\n      p2##_type p2;\\\n      p3##_type p3;\\\n      p4##_type p4;\\\n      p5##_type p5;\\\n      p6##_type p6;\\\n     private:\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename F> operator ::testing::Action<F>() const {\\\n      return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \\\n          p6));\\\n    }\\\n    p0##_type p0;\\\n    p1##_type p1;\\\n    p2##_type p2;\\\n    p3##_type p3;\\\n    p4##_type p4;\\\n    p5##_type p5;\\\n    p6##_type p6;\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(name##ActionP7);\\\n  };\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type>\\\n  inline name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \\\n      p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \\\n      p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \\\n      p6##_type p6) {\\\n    return name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, \\\n        p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\\\n  }\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type>\\\n  template <typename F>\\\n  template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n      typename arg3_type, typename arg4_type, typename arg5_type, \\\n      typename arg6_type, typename arg7_type, typename arg8_type, \\\n      typename arg9_type>\\\n  typename ::testing::internal::Function<F>::Result\\\n      name##ActionP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \\\n          p5##_type, p6##_type>::gmock_Impl<F>::gmock_PerformImpl(\\\n          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const\n\n#define ACTION_P8(name, p0, p1, p2, p3, p4, p5, p6, p7)\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type, typename p7##_type>\\\n  class name##ActionP8 {\\\n   public:\\\n    name##ActionP8(p0##_type gmock_p0, p1##_type gmock_p1, \\\n        p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \\\n        p5##_type gmock_p5, p6##_type gmock_p6, \\\n        p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \\\n        p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \\\n        p7(gmock_p7) {}\\\n    template <typename F>\\\n    class gmock_Impl : public ::testing::ActionInterface<F> {\\\n     public:\\\n      typedef F function_type;\\\n      typedef typename ::testing::internal::Function<F>::Result return_type;\\\n      typedef typename ::testing::internal::Function<F>::ArgumentTuple\\\n          args_type;\\\n      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n          p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \\\n          p6##_type gmock_p6, p7##_type gmock_p7) : p0(gmock_p0), \\\n          p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), \\\n          p5(gmock_p5), p6(gmock_p6), p7(gmock_p7) {}\\\n      virtual return_type Perform(const args_type& args) {\\\n        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\\\n            Perform(this, args);\\\n      }\\\n      template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n          typename arg3_type, typename arg4_type, typename arg5_type, \\\n          typename arg6_type, typename arg7_type, typename arg8_type, \\\n          typename arg9_type>\\\n      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \\\n          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \\\n          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \\\n          arg9_type arg9) const;\\\n      p0##_type p0;\\\n      p1##_type p1;\\\n      p2##_type p2;\\\n      p3##_type p3;\\\n      p4##_type p4;\\\n      p5##_type p5;\\\n      p6##_type p6;\\\n      p7##_type p7;\\\n     private:\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename F> operator ::testing::Action<F>() const {\\\n      return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \\\n          p6, p7));\\\n    }\\\n    p0##_type p0;\\\n    p1##_type p1;\\\n    p2##_type p2;\\\n    p3##_type p3;\\\n    p4##_type p4;\\\n    p5##_type p5;\\\n    p6##_type p6;\\\n    p7##_type p7;\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(name##ActionP8);\\\n  };\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type, typename p7##_type>\\\n  inline name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \\\n      p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \\\n      p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \\\n      p6##_type p6, p7##_type p7) {\\\n    return name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, \\\n        p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \\\n        p6, p7);\\\n  }\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type, typename p7##_type>\\\n  template <typename F>\\\n  template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n      typename arg3_type, typename arg4_type, typename arg5_type, \\\n      typename arg6_type, typename arg7_type, typename arg8_type, \\\n      typename arg9_type>\\\n  typename ::testing::internal::Function<F>::Result\\\n      name##ActionP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \\\n          p5##_type, p6##_type, \\\n          p7##_type>::gmock_Impl<F>::gmock_PerformImpl(\\\n          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const\n\n#define ACTION_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8)\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type, typename p7##_type, typename p8##_type>\\\n  class name##ActionP9 {\\\n   public:\\\n    name##ActionP9(p0##_type gmock_p0, p1##_type gmock_p1, \\\n        p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \\\n        p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \\\n        p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \\\n        p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \\\n        p8(gmock_p8) {}\\\n    template <typename F>\\\n    class gmock_Impl : public ::testing::ActionInterface<F> {\\\n     public:\\\n      typedef F function_type;\\\n      typedef typename ::testing::internal::Function<F>::Result return_type;\\\n      typedef typename ::testing::internal::Function<F>::ArgumentTuple\\\n          args_type;\\\n      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n          p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \\\n          p6##_type gmock_p6, p7##_type gmock_p7, \\\n          p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \\\n          p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \\\n          p7(gmock_p7), p8(gmock_p8) {}\\\n      virtual return_type Perform(const args_type& args) {\\\n        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\\\n            Perform(this, args);\\\n      }\\\n      template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n          typename arg3_type, typename arg4_type, typename arg5_type, \\\n          typename arg6_type, typename arg7_type, typename arg8_type, \\\n          typename arg9_type>\\\n      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \\\n          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \\\n          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \\\n          arg9_type arg9) const;\\\n      p0##_type p0;\\\n      p1##_type p1;\\\n      p2##_type p2;\\\n      p3##_type p3;\\\n      p4##_type p4;\\\n      p5##_type p5;\\\n      p6##_type p6;\\\n      p7##_type p7;\\\n      p8##_type p8;\\\n     private:\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename F> operator ::testing::Action<F>() const {\\\n      return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \\\n          p6, p7, p8));\\\n    }\\\n    p0##_type p0;\\\n    p1##_type p1;\\\n    p2##_type p2;\\\n    p3##_type p3;\\\n    p4##_type p4;\\\n    p5##_type p5;\\\n    p6##_type p6;\\\n    p7##_type p7;\\\n    p8##_type p8;\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(name##ActionP9);\\\n  };\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type, typename p7##_type, typename p8##_type>\\\n  inline name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \\\n      p4##_type, p5##_type, p6##_type, p7##_type, \\\n      p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \\\n      p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \\\n      p8##_type p8) {\\\n    return name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, \\\n        p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \\\n        p3, p4, p5, p6, p7, p8);\\\n  }\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type, typename p7##_type, typename p8##_type>\\\n  template <typename F>\\\n  template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n      typename arg3_type, typename arg4_type, typename arg5_type, \\\n      typename arg6_type, typename arg7_type, typename arg8_type, \\\n      typename arg9_type>\\\n  typename ::testing::internal::Function<F>::Result\\\n      name##ActionP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \\\n          p5##_type, p6##_type, p7##_type, \\\n          p8##_type>::gmock_Impl<F>::gmock_PerformImpl(\\\n          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const\n\n#define ACTION_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type, typename p7##_type, typename p8##_type, \\\n      typename p9##_type>\\\n  class name##ActionP10 {\\\n   public:\\\n    name##ActionP10(p0##_type gmock_p0, p1##_type gmock_p1, \\\n        p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \\\n        p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \\\n        p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), \\\n        p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \\\n        p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {}\\\n    template <typename F>\\\n    class gmock_Impl : public ::testing::ActionInterface<F> {\\\n     public:\\\n      typedef F function_type;\\\n      typedef typename ::testing::internal::Function<F>::Result return_type;\\\n      typedef typename ::testing::internal::Function<F>::ArgumentTuple\\\n          args_type;\\\n      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n          p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \\\n          p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \\\n          p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \\\n          p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \\\n          p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {}\\\n      virtual return_type Perform(const args_type& args) {\\\n        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\\\n            Perform(this, args);\\\n      }\\\n      template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n          typename arg3_type, typename arg4_type, typename arg5_type, \\\n          typename arg6_type, typename arg7_type, typename arg8_type, \\\n          typename arg9_type>\\\n      return_type gmock_PerformImpl(const args_type& args, arg0_type arg0, \\\n          arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4, \\\n          arg5_type arg5, arg6_type arg6, arg7_type arg7, arg8_type arg8, \\\n          arg9_type arg9) const;\\\n      p0##_type p0;\\\n      p1##_type p1;\\\n      p2##_type p2;\\\n      p3##_type p3;\\\n      p4##_type p4;\\\n      p5##_type p5;\\\n      p6##_type p6;\\\n      p7##_type p7;\\\n      p8##_type p8;\\\n      p9##_type p9;\\\n     private:\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename F> operator ::testing::Action<F>() const {\\\n      return ::testing::Action<F>(new gmock_Impl<F>(p0, p1, p2, p3, p4, p5, \\\n          p6, p7, p8, p9));\\\n    }\\\n    p0##_type p0;\\\n    p1##_type p1;\\\n    p2##_type p2;\\\n    p3##_type p3;\\\n    p4##_type p4;\\\n    p5##_type p5;\\\n    p6##_type p6;\\\n    p7##_type p7;\\\n    p8##_type p8;\\\n    p9##_type p9;\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(name##ActionP10);\\\n  };\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type, typename p7##_type, typename p8##_type, \\\n      typename p9##_type>\\\n  inline name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, \\\n      p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \\\n      p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \\\n      p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \\\n      p9##_type p9) {\\\n    return name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, \\\n        p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \\\n        p1, p2, p3, p4, p5, p6, p7, p8, p9);\\\n  }\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type, typename p7##_type, typename p8##_type, \\\n      typename p9##_type>\\\n  template <typename F>\\\n  template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n      typename arg3_type, typename arg4_type, typename arg5_type, \\\n      typename arg6_type, typename arg7_type, typename arg8_type, \\\n      typename arg9_type>\\\n  typename ::testing::internal::Function<F>::Result\\\n      name##ActionP10<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \\\n          p5##_type, p6##_type, p7##_type, p8##_type, \\\n          p9##_type>::gmock_Impl<F>::gmock_PerformImpl(\\\n          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const\n\nnamespace testing {\n\n// The ACTION*() macros trigger warning C4100 (unreferenced formal\n// parameter) in MSVC with -W4.  Unfortunately they cannot be fixed in\n// the macro definition, as the warnings are generated when the macro\n// is expanded and macro expansion cannot contain #pragma.  Therefore\n// we suppress them here.\n#ifdef _MSC_VER\n# pragma warning(push)\n# pragma warning(disable:4100)\n#endif\n\n// Various overloads for InvokeArgument<N>().\n//\n// The InvokeArgument<N>(a1, a2, ..., a_k) action invokes the N-th\n// (0-based) argument, which must be a k-ary callable, of the mock\n// function, with arguments a1, a2, ..., a_k.\n//\n// Notes:\n//\n//   1. The arguments are passed by value by default.  If you need to\n//   pass an argument by reference, wrap it inside ByRef().  For\n//   example,\n//\n//     InvokeArgument<1>(5, string(\"Hello\"), ByRef(foo))\n//\n//   passes 5 and string(\"Hello\") by value, and passes foo by\n//   reference.\n//\n//   2. If the callable takes an argument by reference but ByRef() is\n//   not used, it will receive the reference to a copy of the value,\n//   instead of the original value.  For example, when the 0-th\n//   argument of the mock function takes a const string&, the action\n//\n//     InvokeArgument<0>(string(\"Hello\"))\n//\n//   makes a copy of the temporary string(\"Hello\") object and passes a\n//   reference of the copy, instead of the original temporary object,\n//   to the callable.  This makes it easy for a user to define an\n//   InvokeArgument action from temporary values and have it performed\n//   later.\n\nACTION_TEMPLATE(InvokeArgument,\n                HAS_1_TEMPLATE_PARAMS(int, k),\n                AND_0_VALUE_PARAMS()) {\n  return internal::CallableHelper<return_type>::Call(\n      ::std::tr1::get<k>(args));\n}\n\nACTION_TEMPLATE(InvokeArgument,\n                HAS_1_TEMPLATE_PARAMS(int, k),\n                AND_1_VALUE_PARAMS(p0)) {\n  return internal::CallableHelper<return_type>::Call(\n      ::std::tr1::get<k>(args), p0);\n}\n\nACTION_TEMPLATE(InvokeArgument,\n                HAS_1_TEMPLATE_PARAMS(int, k),\n                AND_2_VALUE_PARAMS(p0, p1)) {\n  return internal::CallableHelper<return_type>::Call(\n      ::std::tr1::get<k>(args), p0, p1);\n}\n\nACTION_TEMPLATE(InvokeArgument,\n                HAS_1_TEMPLATE_PARAMS(int, k),\n                AND_3_VALUE_PARAMS(p0, p1, p2)) {\n  return internal::CallableHelper<return_type>::Call(\n      ::std::tr1::get<k>(args), p0, p1, p2);\n}\n\nACTION_TEMPLATE(InvokeArgument,\n                HAS_1_TEMPLATE_PARAMS(int, k),\n                AND_4_VALUE_PARAMS(p0, p1, p2, p3)) {\n  return internal::CallableHelper<return_type>::Call(\n      ::std::tr1::get<k>(args), p0, p1, p2, p3);\n}\n\nACTION_TEMPLATE(InvokeArgument,\n                HAS_1_TEMPLATE_PARAMS(int, k),\n                AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) {\n  return internal::CallableHelper<return_type>::Call(\n      ::std::tr1::get<k>(args), p0, p1, p2, p3, p4);\n}\n\nACTION_TEMPLATE(InvokeArgument,\n                HAS_1_TEMPLATE_PARAMS(int, k),\n                AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) {\n  return internal::CallableHelper<return_type>::Call(\n      ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5);\n}\n\nACTION_TEMPLATE(InvokeArgument,\n                HAS_1_TEMPLATE_PARAMS(int, k),\n                AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) {\n  return internal::CallableHelper<return_type>::Call(\n      ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6);\n}\n\nACTION_TEMPLATE(InvokeArgument,\n                HAS_1_TEMPLATE_PARAMS(int, k),\n                AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) {\n  return internal::CallableHelper<return_type>::Call(\n      ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7);\n}\n\nACTION_TEMPLATE(InvokeArgument,\n                HAS_1_TEMPLATE_PARAMS(int, k),\n                AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) {\n  return internal::CallableHelper<return_type>::Call(\n      ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8);\n}\n\nACTION_TEMPLATE(InvokeArgument,\n                HAS_1_TEMPLATE_PARAMS(int, k),\n                AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) {\n  return internal::CallableHelper<return_type>::Call(\n      ::std::tr1::get<k>(args), p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);\n}\n\n// Various overloads for ReturnNew<T>().\n//\n// The ReturnNew<T>(a1, a2, ..., a_k) action returns a pointer to a new\n// instance of type T, constructed on the heap with constructor arguments\n// a1, a2, ..., and a_k. The caller assumes ownership of the returned value.\nACTION_TEMPLATE(ReturnNew,\n                HAS_1_TEMPLATE_PARAMS(typename, T),\n                AND_0_VALUE_PARAMS()) {\n  return new T();\n}\n\nACTION_TEMPLATE(ReturnNew,\n                HAS_1_TEMPLATE_PARAMS(typename, T),\n                AND_1_VALUE_PARAMS(p0)) {\n  return new T(p0);\n}\n\nACTION_TEMPLATE(ReturnNew,\n                HAS_1_TEMPLATE_PARAMS(typename, T),\n                AND_2_VALUE_PARAMS(p0, p1)) {\n  return new T(p0, p1);\n}\n\nACTION_TEMPLATE(ReturnNew,\n                HAS_1_TEMPLATE_PARAMS(typename, T),\n                AND_3_VALUE_PARAMS(p0, p1, p2)) {\n  return new T(p0, p1, p2);\n}\n\nACTION_TEMPLATE(ReturnNew,\n                HAS_1_TEMPLATE_PARAMS(typename, T),\n                AND_4_VALUE_PARAMS(p0, p1, p2, p3)) {\n  return new T(p0, p1, p2, p3);\n}\n\nACTION_TEMPLATE(ReturnNew,\n                HAS_1_TEMPLATE_PARAMS(typename, T),\n                AND_5_VALUE_PARAMS(p0, p1, p2, p3, p4)) {\n  return new T(p0, p1, p2, p3, p4);\n}\n\nACTION_TEMPLATE(ReturnNew,\n                HAS_1_TEMPLATE_PARAMS(typename, T),\n                AND_6_VALUE_PARAMS(p0, p1, p2, p3, p4, p5)) {\n  return new T(p0, p1, p2, p3, p4, p5);\n}\n\nACTION_TEMPLATE(ReturnNew,\n                HAS_1_TEMPLATE_PARAMS(typename, T),\n                AND_7_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6)) {\n  return new T(p0, p1, p2, p3, p4, p5, p6);\n}\n\nACTION_TEMPLATE(ReturnNew,\n                HAS_1_TEMPLATE_PARAMS(typename, T),\n                AND_8_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7)) {\n  return new T(p0, p1, p2, p3, p4, p5, p6, p7);\n}\n\nACTION_TEMPLATE(ReturnNew,\n                HAS_1_TEMPLATE_PARAMS(typename, T),\n                AND_9_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8)) {\n  return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8);\n}\n\nACTION_TEMPLATE(ReturnNew,\n                HAS_1_TEMPLATE_PARAMS(typename, T),\n                AND_10_VALUE_PARAMS(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)) {\n  return new T(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);\n}\n\n#ifdef _MSC_VER\n# pragma warning(pop)\n#endif\n\n}  // namespace testing\n\n#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_\n"
  },
  {
    "path": "ext/gmock/include/gmock/gmock-generated-actions.h.pump",
    "content": "$$ -*- mode: c++; -*-\n$$ This is a Pump source file.  Please use Pump to convert it to\n$$ gmock-generated-actions.h.\n$$\n$var n = 10  $$ The maximum arity we support.\n$$}} This meta comment fixes auto-indentation in editors.\n// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements some commonly used variadic actions.\n\n#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_\n#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_\n\n#include \"gmock/gmock-actions.h\"\n#include \"gmock/internal/gmock-port.h\"\n\nnamespace testing {\nnamespace internal {\n\n// InvokeHelper<F> knows how to unpack an N-tuple and invoke an N-ary\n// function or method with the unpacked values, where F is a function\n// type that takes N arguments.\ntemplate <typename Result, typename ArgumentTuple>\nclass InvokeHelper;\n\n\n$range i 0..n\n$for i [[\n$range j 1..i\n$var types = [[$for j [[, typename A$j]]]]\n$var as = [[$for j, [[A$j]]]]\n$var args = [[$if i==0 [[]] $else [[ args]]]]\n$var import = [[$if i==0 [[]] $else [[\n    using ::std::tr1::get;\n\n]]]]\n$var gets = [[$for j, [[get<$(j - 1)>(args)]]]]\ntemplate <typename R$types>\nclass InvokeHelper<R, ::std::tr1::tuple<$as> > {\n public:\n  template <typename Function>\n  static R Invoke(Function function, const ::std::tr1::tuple<$as>&$args) {\n$import    return function($gets);\n  }\n\n  template <class Class, typename MethodPtr>\n  static R InvokeMethod(Class* obj_ptr,\n                        MethodPtr method_ptr,\n                        const ::std::tr1::tuple<$as>&$args) {\n$import    return (obj_ptr->*method_ptr)($gets);\n  }\n};\n\n\n]]\n// CallableHelper has static methods for invoking \"callables\",\n// i.e. function pointers and functors.  It uses overloading to\n// provide a uniform interface for invoking different kinds of\n// callables.  In particular, you can use:\n//\n//   CallableHelper<R>::Call(callable, a1, a2, ..., an)\n//\n// to invoke an n-ary callable, where R is its return type.  If an\n// argument, say a2, needs to be passed by reference, you should write\n// ByRef(a2) instead of a2 in the above expression.\ntemplate <typename R>\nclass CallableHelper {\n public:\n  // Calls a nullary callable.\n  template <typename Function>\n  static R Call(Function function) { return function(); }\n\n  // Calls a unary callable.\n\n  // We deliberately pass a1 by value instead of const reference here\n  // in case it is a C-string literal.  If we had declared the\n  // parameter as 'const A1& a1' and write Call(function, \"Hi\"), the\n  // compiler would've thought A1 is 'char[3]', which causes trouble\n  // when you need to copy a value of type A1.  By declaring the\n  // parameter as 'A1 a1', the compiler will correctly infer that A1\n  // is 'const char*' when it sees Call(function, \"Hi\").\n  //\n  // Since this function is defined inline, the compiler can get rid\n  // of the copying of the arguments.  Therefore the performance won't\n  // be hurt.\n  template <typename Function, typename A1>\n  static R Call(Function function, A1 a1) { return function(a1); }\n\n$range i 2..n\n$for i\n[[\n$var arity = [[$if i==2 [[binary]] $elif i==3 [[ternary]] $else [[$i-ary]]]]\n\n  // Calls a $arity callable.\n\n$range j 1..i\n$var typename_As = [[$for j, [[typename A$j]]]]\n$var Aas = [[$for j, [[A$j a$j]]]]\n$var as = [[$for j, [[a$j]]]]\n$var typename_Ts = [[$for j, [[typename T$j]]]]\n$var Ts = [[$for j, [[T$j]]]]\n  template <typename Function, $typename_As>\n  static R Call(Function function, $Aas) {\n    return function($as);\n  }\n\n]]\n};  // class CallableHelper\n\n// An INTERNAL macro for extracting the type of a tuple field.  It's\n// subject to change without notice - DO NOT USE IN USER CODE!\n#define GMOCK_FIELD_(Tuple, N) \\\n    typename ::std::tr1::tuple_element<N, Tuple>::type\n\n$range i 1..n\n\n// SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::type is the\n// type of an n-ary function whose i-th (1-based) argument type is the\n// k{i}-th (0-based) field of ArgumentTuple, which must be a tuple\n// type, and whose return type is Result.  For example,\n//   SelectArgs<int, ::std::tr1::tuple<bool, char, double, long>, 0, 3>::type\n// is int(bool, long).\n//\n// SelectArgs<Result, ArgumentTuple, k1, k2, ..., k_n>::Select(args)\n// returns the selected fields (k1, k2, ..., k_n) of args as a tuple.\n// For example,\n//   SelectArgs<int, ::std::tr1::tuple<bool, char, double>, 2, 0>::Select(\n//       ::std::tr1::make_tuple(true, 'a', 2.5))\n// returns ::std::tr1::tuple (2.5, true).\n//\n// The numbers in list k1, k2, ..., k_n must be >= 0, where n can be\n// in the range [0, $n].  Duplicates are allowed and they don't have\n// to be in an ascending or descending order.\n\ntemplate <typename Result, typename ArgumentTuple, $for i, [[int k$i]]>\nclass SelectArgs {\n public:\n  typedef Result type($for i, [[GMOCK_FIELD_(ArgumentTuple, k$i)]]);\n  typedef typename Function<type>::ArgumentTuple SelectedArgs;\n  static SelectedArgs Select(const ArgumentTuple& args) {\n    using ::std::tr1::get;\n    return SelectedArgs($for i, [[get<k$i>(args)]]);\n  }\n};\n\n\n$for i [[\n$range j 1..n\n$range j1 1..i-1\ntemplate <typename Result, typename ArgumentTuple$for j1[[, int k$j1]]>\nclass SelectArgs<Result, ArgumentTuple,\n                 $for j, [[$if j <= i-1 [[k$j]] $else [[-1]]]]> {\n public:\n  typedef Result type($for j1, [[GMOCK_FIELD_(ArgumentTuple, k$j1)]]);\n  typedef typename Function<type>::ArgumentTuple SelectedArgs;\n  static SelectedArgs Select(const ArgumentTuple& [[]]\n$if i == 1 [[/* args */]] $else [[args]]) {\n    using ::std::tr1::get;\n    return SelectedArgs($for j1, [[get<k$j1>(args)]]);\n  }\n};\n\n\n]]\n#undef GMOCK_FIELD_\n\n$var ks = [[$for i, [[k$i]]]]\n\n// Implements the WithArgs action.\ntemplate <typename InnerAction, $for i, [[int k$i = -1]]>\nclass WithArgsAction {\n public:\n  explicit WithArgsAction(const InnerAction& action) : action_(action) {}\n\n  template <typename F>\n  operator Action<F>() const { return MakeAction(new Impl<F>(action_)); }\n\n private:\n  template <typename F>\n  class Impl : public ActionInterface<F> {\n   public:\n    typedef typename Function<F>::Result Result;\n    typedef typename Function<F>::ArgumentTuple ArgumentTuple;\n\n    explicit Impl(const InnerAction& action) : action_(action) {}\n\n    virtual Result Perform(const ArgumentTuple& args) {\n      return action_.Perform(SelectArgs<Result, ArgumentTuple, $ks>::Select(args));\n    }\n\n   private:\n    typedef typename SelectArgs<Result, ArgumentTuple,\n        $ks>::type InnerFunctionType;\n\n    Action<InnerFunctionType> action_;\n  };\n\n  const InnerAction action_;\n\n  GTEST_DISALLOW_ASSIGN_(WithArgsAction);\n};\n\n// A macro from the ACTION* family (defined later in this file)\n// defines an action that can be used in a mock function.  Typically,\n// these actions only care about a subset of the arguments of the mock\n// function.  For example, if such an action only uses the second\n// argument, it can be used in any mock function that takes >= 2\n// arguments where the type of the second argument is compatible.\n//\n// Therefore, the action implementation must be prepared to take more\n// arguments than it needs.  The ExcessiveArg type is used to\n// represent those excessive arguments.  In order to keep the compiler\n// error messages tractable, we define it in the testing namespace\n// instead of testing::internal.  However, this is an INTERNAL TYPE\n// and subject to change without notice, so a user MUST NOT USE THIS\n// TYPE DIRECTLY.\nstruct ExcessiveArg {};\n\n// A helper class needed for implementing the ACTION* macros.\ntemplate <typename Result, class Impl>\nclass ActionHelper {\n public:\n$range i 0..n\n$for i\n\n[[\n$var template = [[$if i==0 [[]] $else [[\n$range j 0..i-1\n  template <$for j, [[typename A$j]]>\n]]]]\n$range j 0..i-1\n$var As = [[$for j, [[A$j]]]]\n$var as = [[$for j, [[get<$j>(args)]]]]\n$range k 1..n-i\n$var eas = [[$for k, [[ExcessiveArg()]]]]\n$var arg_list = [[$if (i==0) | (i==n) [[$as$eas]] $else [[$as, $eas]]]]\n$template\n  static Result Perform(Impl* impl, const ::std::tr1::tuple<$As>& args) {\n    using ::std::tr1::get;\n    return impl->template gmock_PerformImpl<$As>(args, $arg_list);\n  }\n\n]]\n};\n\n}  // namespace internal\n\n// Various overloads for Invoke().\n\n// WithArgs<N1, N2, ..., Nk>(an_action) creates an action that passes\n// the selected arguments of the mock function to an_action and\n// performs it.  It serves as an adaptor between actions with\n// different argument lists.  C++ doesn't support default arguments for\n// function templates, so we have to overload it.\n\n$range i 1..n\n$for i [[\n$range j 1..i\ntemplate <$for j [[int k$j, ]]typename InnerAction>\ninline internal::WithArgsAction<InnerAction$for j [[, k$j]]>\nWithArgs(const InnerAction& action) {\n  return internal::WithArgsAction<InnerAction$for j [[, k$j]]>(action);\n}\n\n\n]]\n// Creates an action that does actions a1, a2, ..., sequentially in\n// each invocation.\n$range i 2..n\n$for i [[\n$range j 2..i\n$var types = [[$for j, [[typename Action$j]]]]\n$var Aas = [[$for j [[, Action$j a$j]]]]\n\ntemplate <typename Action1, $types>\n$range k 1..i-1\n\ninline $for k [[internal::DoBothAction<Action$k, ]]Action$i$for k  [[>]]\n\nDoAll(Action1 a1$Aas) {\n$if i==2 [[\n\n  return internal::DoBothAction<Action1, Action2>(a1, a2);\n]] $else [[\n$range j2 2..i\n\n  return DoAll(a1, DoAll($for j2, [[a$j2]]));\n]]\n\n}\n\n]]\n\n}  // namespace testing\n\n// The ACTION* family of macros can be used in a namespace scope to\n// define custom actions easily.  The syntax:\n//\n//   ACTION(name) { statements; }\n//\n// will define an action with the given name that executes the\n// statements.  The value returned by the statements will be used as\n// the return value of the action.  Inside the statements, you can\n// refer to the K-th (0-based) argument of the mock function by\n// 'argK', and refer to its type by 'argK_type'.  For example:\n//\n//   ACTION(IncrementArg1) {\n//     arg1_type temp = arg1;\n//     return ++(*temp);\n//   }\n//\n// allows you to write\n//\n//   ...WillOnce(IncrementArg1());\n//\n// You can also refer to the entire argument tuple and its type by\n// 'args' and 'args_type', and refer to the mock function type and its\n// return type by 'function_type' and 'return_type'.\n//\n// Note that you don't need to specify the types of the mock function\n// arguments.  However rest assured that your code is still type-safe:\n// you'll get a compiler error if *arg1 doesn't support the ++\n// operator, or if the type of ++(*arg1) isn't compatible with the\n// mock function's return type, for example.\n//\n// Sometimes you'll want to parameterize the action.   For that you can use\n// another macro:\n//\n//   ACTION_P(name, param_name) { statements; }\n//\n// For example:\n//\n//   ACTION_P(Add, n) { return arg0 + n; }\n//\n// will allow you to write:\n//\n//   ...WillOnce(Add(5));\n//\n// Note that you don't need to provide the type of the parameter\n// either.  If you need to reference the type of a parameter named\n// 'foo', you can write 'foo_type'.  For example, in the body of\n// ACTION_P(Add, n) above, you can write 'n_type' to refer to the type\n// of 'n'.\n//\n// We also provide ACTION_P2, ACTION_P3, ..., up to ACTION_P$n to support\n// multi-parameter actions.\n//\n// For the purpose of typing, you can view\n//\n//   ACTION_Pk(Foo, p1, ..., pk) { ... }\n//\n// as shorthand for\n//\n//   template <typename p1_type, ..., typename pk_type>\n//   FooActionPk<p1_type, ..., pk_type> Foo(p1_type p1, ..., pk_type pk) { ... }\n//\n// In particular, you can provide the template type arguments\n// explicitly when invoking Foo(), as in Foo<long, bool>(5, false);\n// although usually you can rely on the compiler to infer the types\n// for you automatically.  You can assign the result of expression\n// Foo(p1, ..., pk) to a variable of type FooActionPk<p1_type, ...,\n// pk_type>.  This can be useful when composing actions.\n//\n// You can also overload actions with different numbers of parameters:\n//\n//   ACTION_P(Plus, a) { ... }\n//   ACTION_P2(Plus, a, b) { ... }\n//\n// While it's tempting to always use the ACTION* macros when defining\n// a new action, you should also consider implementing ActionInterface\n// or using MakePolymorphicAction() instead, especially if you need to\n// use the action a lot.  While these approaches require more work,\n// they give you more control on the types of the mock function\n// arguments and the action parameters, which in general leads to\n// better compiler error messages that pay off in the long run.  They\n// also allow overloading actions based on parameter types (as opposed\n// to just based on the number of parameters).\n//\n// CAVEAT:\n//\n// ACTION*() can only be used in a namespace scope.  The reason is\n// that C++ doesn't yet allow function-local types to be used to\n// instantiate templates.  The up-coming C++0x standard will fix this.\n// Once that's done, we'll consider supporting using ACTION*() inside\n// a function.\n//\n// MORE INFORMATION:\n//\n// To learn more about using these macros, please search for 'ACTION'\n// on http://code.google.com/p/googlemock/wiki/CookBook.\n\n$range i 0..n\n$range k 0..n-1\n\n// An internal macro needed for implementing ACTION*().\n#define GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_\\\n    const args_type& args GTEST_ATTRIBUTE_UNUSED_\n$for k [[, \\\n    arg$k[[]]_type arg$k GTEST_ATTRIBUTE_UNUSED_]]\n\n\n// Sometimes you want to give an action explicit template parameters\n// that cannot be inferred from its value parameters.  ACTION() and\n// ACTION_P*() don't support that.  ACTION_TEMPLATE() remedies that\n// and can be viewed as an extension to ACTION() and ACTION_P*().\n//\n// The syntax:\n//\n//   ACTION_TEMPLATE(ActionName,\n//                   HAS_m_TEMPLATE_PARAMS(kind1, name1, ..., kind_m, name_m),\n//                   AND_n_VALUE_PARAMS(p1, ..., p_n)) { statements; }\n//\n// defines an action template that takes m explicit template\n// parameters and n value parameters.  name_i is the name of the i-th\n// template parameter, and kind_i specifies whether it's a typename,\n// an integral constant, or a template.  p_i is the name of the i-th\n// value parameter.\n//\n// Example:\n//\n//   // DuplicateArg<k, T>(output) converts the k-th argument of the mock\n//   // function to type T and copies it to *output.\n//   ACTION_TEMPLATE(DuplicateArg,\n//                   HAS_2_TEMPLATE_PARAMS(int, k, typename, T),\n//                   AND_1_VALUE_PARAMS(output)) {\n//     *output = T(std::tr1::get<k>(args));\n//   }\n//   ...\n//     int n;\n//     EXPECT_CALL(mock, Foo(_, _))\n//         .WillOnce(DuplicateArg<1, unsigned char>(&n));\n//\n// To create an instance of an action template, write:\n//\n//   ActionName<t1, ..., t_m>(v1, ..., v_n)\n//\n// where the ts are the template arguments and the vs are the value\n// arguments.  The value argument types are inferred by the compiler.\n// If you want to explicitly specify the value argument types, you can\n// provide additional template arguments:\n//\n//   ActionName<t1, ..., t_m, u1, ..., u_k>(v1, ..., v_n)\n//\n// where u_i is the desired type of v_i.\n//\n// ACTION_TEMPLATE and ACTION/ACTION_P* can be overloaded on the\n// number of value parameters, but not on the number of template\n// parameters.  Without the restriction, the meaning of the following\n// is unclear:\n//\n//   OverloadedAction<int, bool>(x);\n//\n// Are we using a single-template-parameter action where 'bool' refers\n// to the type of x, or are we using a two-template-parameter action\n// where the compiler is asked to infer the type of x?\n//\n// Implementation notes:\n//\n// GMOCK_INTERNAL_*_HAS_m_TEMPLATE_PARAMS and\n// GMOCK_INTERNAL_*_AND_n_VALUE_PARAMS are internal macros for\n// implementing ACTION_TEMPLATE.  The main trick we use is to create\n// new macro invocations when expanding a macro.  For example, we have\n//\n//   #define ACTION_TEMPLATE(name, template_params, value_params)\n//       ... GMOCK_INTERNAL_DECL_##template_params ...\n//\n// which causes ACTION_TEMPLATE(..., HAS_1_TEMPLATE_PARAMS(typename, T), ...)\n// to expand to\n//\n//       ... GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS(typename, T) ...\n//\n// Since GMOCK_INTERNAL_DECL_HAS_1_TEMPLATE_PARAMS is a macro, the\n// preprocessor will continue to expand it to\n//\n//       ... typename T ...\n//\n// This technique conforms to the C++ standard and is portable.  It\n// allows us to implement action templates using O(N) code, where N is\n// the maximum number of template/value parameters supported.  Without\n// using it, we'd have to devote O(N^2) amount of code to implement all\n// combinations of m and n.\n\n// Declares the template parameters.\n\n$range j 1..n\n$for j [[\n$range m 0..j-1\n#define GMOCK_INTERNAL_DECL_HAS_$j[[]]\n_TEMPLATE_PARAMS($for m, [[kind$m, name$m]]) $for m, [[kind$m name$m]]\n\n\n]]\n\n// Lists the template parameters.\n\n$for j [[\n$range m 0..j-1\n#define GMOCK_INTERNAL_LIST_HAS_$j[[]]\n_TEMPLATE_PARAMS($for m, [[kind$m, name$m]]) $for m, [[name$m]]\n\n\n]]\n\n// Declares the types of value parameters.\n\n$for i [[\n$range j 0..i-1\n#define GMOCK_INTERNAL_DECL_TYPE_AND_$i[[]]\n_VALUE_PARAMS($for j, [[p$j]]) $for j [[, typename p$j##_type]]\n\n\n]]\n\n// Initializes the value parameters.\n\n$for i [[\n$range j 0..i-1\n#define GMOCK_INTERNAL_INIT_AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]])\\\n    ($for j, [[p$j##_type gmock_p$j]])$if i>0 [[ : ]]$for j, [[p$j(gmock_p$j)]]\n\n\n]]\n\n// Declares the fields for storing the value parameters.\n\n$for i [[\n$range j 0..i-1\n#define GMOCK_INTERNAL_DEFN_AND_$i[[]]\n_VALUE_PARAMS($for j, [[p$j]]) $for j [[p$j##_type p$j; ]]\n\n\n]]\n\n// Lists the value parameters.\n\n$for i [[\n$range j 0..i-1\n#define GMOCK_INTERNAL_LIST_AND_$i[[]]\n_VALUE_PARAMS($for j, [[p$j]]) $for j, [[p$j]]\n\n\n]]\n\n// Lists the value parameter types.\n\n$for i [[\n$range j 0..i-1\n#define GMOCK_INTERNAL_LIST_TYPE_AND_$i[[]]\n_VALUE_PARAMS($for j, [[p$j]]) $for j [[, p$j##_type]]\n\n\n]]\n\n// Declares the value parameters.\n\n$for i [[\n$range j 0..i-1\n#define GMOCK_INTERNAL_DECL_AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]]) [[]]\n$for j, [[p$j##_type p$j]]\n\n\n]]\n\n// The suffix of the class template implementing the action template.\n$for i [[\n\n\n$range j 0..i-1\n#define GMOCK_INTERNAL_COUNT_AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]]) [[]]\n$if i==1 [[P]] $elif i>=2 [[P$i]]\n]]\n\n\n// The name of the class template implementing the action template.\n#define GMOCK_ACTION_CLASS_(name, value_params)\\\n    GTEST_CONCAT_TOKEN_(name##Action, GMOCK_INTERNAL_COUNT_##value_params)\n\n$range k 0..n-1\n\n#define ACTION_TEMPLATE(name, template_params, value_params)\\\n  template <GMOCK_INTERNAL_DECL_##template_params\\\n            GMOCK_INTERNAL_DECL_TYPE_##value_params>\\\n  class GMOCK_ACTION_CLASS_(name, value_params) {\\\n   public:\\\n    GMOCK_ACTION_CLASS_(name, value_params)\\\n        GMOCK_INTERNAL_INIT_##value_params {}\\\n    template <typename F>\\\n    class gmock_Impl : public ::testing::ActionInterface<F> {\\\n     public:\\\n      typedef F function_type;\\\n      typedef typename ::testing::internal::Function<F>::Result return_type;\\\n      typedef typename ::testing::internal::Function<F>::ArgumentTuple\\\n          args_type;\\\n      explicit gmock_Impl GMOCK_INTERNAL_INIT_##value_params {}\\\n      virtual return_type Perform(const args_type& args) {\\\n        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\\\n            Perform(this, args);\\\n      }\\\n      template <$for k, [[typename arg$k[[]]_type]]>\\\n      return_type gmock_PerformImpl(const args_type& args[[]]\n$for k [[, arg$k[[]]_type arg$k]]) const;\\\n      GMOCK_INTERNAL_DEFN_##value_params\\\n     private:\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename F> operator ::testing::Action<F>() const {\\\n      return ::testing::Action<F>(\\\n          new gmock_Impl<F>(GMOCK_INTERNAL_LIST_##value_params));\\\n    }\\\n    GMOCK_INTERNAL_DEFN_##value_params\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(GMOCK_ACTION_CLASS_(name, value_params));\\\n  };\\\n  template <GMOCK_INTERNAL_DECL_##template_params\\\n            GMOCK_INTERNAL_DECL_TYPE_##value_params>\\\n  inline GMOCK_ACTION_CLASS_(name, value_params)<\\\n      GMOCK_INTERNAL_LIST_##template_params\\\n      GMOCK_INTERNAL_LIST_TYPE_##value_params> name(\\\n          GMOCK_INTERNAL_DECL_##value_params) {\\\n    return GMOCK_ACTION_CLASS_(name, value_params)<\\\n        GMOCK_INTERNAL_LIST_##template_params\\\n        GMOCK_INTERNAL_LIST_TYPE_##value_params>(\\\n            GMOCK_INTERNAL_LIST_##value_params);\\\n  }\\\n  template <GMOCK_INTERNAL_DECL_##template_params\\\n            GMOCK_INTERNAL_DECL_TYPE_##value_params>\\\n  template <typename F>\\\n  template <typename arg0_type, typename arg1_type, typename arg2_type, \\\n      typename arg3_type, typename arg4_type, typename arg5_type, \\\n      typename arg6_type, typename arg7_type, typename arg8_type, \\\n      typename arg9_type>\\\n  typename ::testing::internal::Function<F>::Result\\\n      GMOCK_ACTION_CLASS_(name, value_params)<\\\n          GMOCK_INTERNAL_LIST_##template_params\\\n          GMOCK_INTERNAL_LIST_TYPE_##value_params>::gmock_Impl<F>::\\\n              gmock_PerformImpl(\\\n          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const\n\n$for i\n\n[[\n$var template = [[$if i==0 [[]] $else [[\n$range j 0..i-1\n\n  template <$for j, [[typename p$j##_type]]>\\\n]]]]\n$var class_name = [[name##Action[[$if i==0 [[]] $elif i==1 [[P]]\n                                                $else [[P$i]]]]]]\n$range j 0..i-1\n$var ctor_param_list = [[$for j, [[p$j##_type gmock_p$j]]]]\n$var param_types_and_names = [[$for j, [[p$j##_type p$j]]]]\n$var inits = [[$if i==0 [[]] $else [[ : $for j, [[p$j(gmock_p$j)]]]]]]\n$var param_field_decls = [[$for j\n[[\n\n      p$j##_type p$j;\\\n]]]]\n$var param_field_decls2 = [[$for j\n[[\n\n    p$j##_type p$j;\\\n]]]]\n$var params = [[$for j, [[p$j]]]]\n$var param_types = [[$if i==0 [[]] $else [[<$for j, [[p$j##_type]]>]]]]\n$var typename_arg_types = [[$for k, [[typename arg$k[[]]_type]]]]\n$var arg_types_and_names = [[$for k, [[arg$k[[]]_type arg$k]]]]\n$var macro_name = [[$if i==0 [[ACTION]] $elif i==1 [[ACTION_P]]\n                                        $else [[ACTION_P$i]]]]\n\n#define $macro_name(name$for j [[, p$j]])\\$template\n  class $class_name {\\\n   public:\\\n    $class_name($ctor_param_list)$inits {}\\\n    template <typename F>\\\n    class gmock_Impl : public ::testing::ActionInterface<F> {\\\n     public:\\\n      typedef F function_type;\\\n      typedef typename ::testing::internal::Function<F>::Result return_type;\\\n      typedef typename ::testing::internal::Function<F>::ArgumentTuple\\\n          args_type;\\\n      [[$if i==1 [[explicit ]]]]gmock_Impl($ctor_param_list)$inits {}\\\n      virtual return_type Perform(const args_type& args) {\\\n        return ::testing::internal::ActionHelper<return_type, gmock_Impl>::\\\n            Perform(this, args);\\\n      }\\\n      template <$typename_arg_types>\\\n      return_type gmock_PerformImpl(const args_type& args, [[]]\n$arg_types_and_names) const;\\$param_field_decls\n     private:\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename F> operator ::testing::Action<F>() const {\\\n      return ::testing::Action<F>(new gmock_Impl<F>($params));\\\n    }\\$param_field_decls2\n   private:\\\n    GTEST_DISALLOW_ASSIGN_($class_name);\\\n  };\\$template\n  inline $class_name$param_types name($param_types_and_names) {\\\n    return $class_name$param_types($params);\\\n  }\\$template\n  template <typename F>\\\n  template <$typename_arg_types>\\\n  typename ::testing::internal::Function<F>::Result\\\n      $class_name$param_types::gmock_Impl<F>::gmock_PerformImpl(\\\n          GMOCK_ACTION_ARG_TYPES_AND_NAMES_UNUSED_) const\n]]\n$$ }  // This meta comment fixes auto-indentation in Emacs.  It won't\n$$    // show up in the generated code.\n\n\nnamespace testing {\n\n// The ACTION*() macros trigger warning C4100 (unreferenced formal\n// parameter) in MSVC with -W4.  Unfortunately they cannot be fixed in\n// the macro definition, as the warnings are generated when the macro\n// is expanded and macro expansion cannot contain #pragma.  Therefore\n// we suppress them here.\n#ifdef _MSC_VER\n# pragma warning(push)\n# pragma warning(disable:4100)\n#endif\n\n// Various overloads for InvokeArgument<N>().\n//\n// The InvokeArgument<N>(a1, a2, ..., a_k) action invokes the N-th\n// (0-based) argument, which must be a k-ary callable, of the mock\n// function, with arguments a1, a2, ..., a_k.\n//\n// Notes:\n//\n//   1. The arguments are passed by value by default.  If you need to\n//   pass an argument by reference, wrap it inside ByRef().  For\n//   example,\n//\n//     InvokeArgument<1>(5, string(\"Hello\"), ByRef(foo))\n//\n//   passes 5 and string(\"Hello\") by value, and passes foo by\n//   reference.\n//\n//   2. If the callable takes an argument by reference but ByRef() is\n//   not used, it will receive the reference to a copy of the value,\n//   instead of the original value.  For example, when the 0-th\n//   argument of the mock function takes a const string&, the action\n//\n//     InvokeArgument<0>(string(\"Hello\"))\n//\n//   makes a copy of the temporary string(\"Hello\") object and passes a\n//   reference of the copy, instead of the original temporary object,\n//   to the callable.  This makes it easy for a user to define an\n//   InvokeArgument action from temporary values and have it performed\n//   later.\n\n$range i 0..n\n$for i [[\n$range j 0..i-1\n\nACTION_TEMPLATE(InvokeArgument,\n                HAS_1_TEMPLATE_PARAMS(int, k),\n                AND_$i[[]]_VALUE_PARAMS($for j, [[p$j]])) {\n  return internal::CallableHelper<return_type>::Call(\n      ::std::tr1::get<k>(args)$for j [[, p$j]]);\n}\n\n]]\n\n// Various overloads for ReturnNew<T>().\n//\n// The ReturnNew<T>(a1, a2, ..., a_k) action returns a pointer to a new\n// instance of type T, constructed on the heap with constructor arguments\n// a1, a2, ..., and a_k. The caller assumes ownership of the returned value.\n$range i 0..n\n$for i [[\n$range j 0..i-1\n$var ps = [[$for j, [[p$j]]]]\n\nACTION_TEMPLATE(ReturnNew,\n                HAS_1_TEMPLATE_PARAMS(typename, T),\n                AND_$i[[]]_VALUE_PARAMS($ps)) {\n  return new T($ps);\n}\n\n]]\n\n#ifdef _MSC_VER\n# pragma warning(pop)\n#endif\n\n}  // namespace testing\n\n#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_\n"
  },
  {
    "path": "ext/gmock/include/gmock/gmock-generated-function-mockers.h",
    "content": "// This file was GENERATED by command:\n//     pump.py gmock-generated-function-mockers.h.pump\n// DO NOT EDIT BY HAND!!!\n\n// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements function mockers of various arities.\n\n#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_\n#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_\n\n#include \"gmock/gmock-spec-builders.h\"\n#include \"gmock/internal/gmock-internal-utils.h\"\n\nnamespace testing {\nnamespace internal {\n\ntemplate <typename F>\nclass FunctionMockerBase;\n\n// Note: class FunctionMocker really belongs to the ::testing\n// namespace.  However if we define it in ::testing, MSVC will\n// complain when classes in ::testing::internal declare it as a\n// friend class template.  To workaround this compiler bug, we define\n// FunctionMocker in ::testing::internal and import it into ::testing.\ntemplate <typename F>\nclass FunctionMocker;\n\ntemplate <typename R>\nclass FunctionMocker<R()> : public\n    internal::FunctionMockerBase<R()> {\n public:\n  typedef R F();\n  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;\n\n  MockSpec<F>& With() {\n    return this->current_spec();\n  }\n\n  R Invoke() {\n    // Even though gcc and MSVC don't enforce it, 'this->' is required\n    // by the C++ standard [14.6.4] here, as the base class type is\n    // dependent on the template argument (and thus shouldn't be\n    // looked into when resolving InvokeWith).\n    return this->InvokeWith(ArgumentTuple());\n  }\n};\n\ntemplate <typename R, typename A1>\nclass FunctionMocker<R(A1)> : public\n    internal::FunctionMockerBase<R(A1)> {\n public:\n  typedef R F(A1);\n  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;\n\n  MockSpec<F>& With(const Matcher<A1>& m1) {\n    this->current_spec().SetMatchers(::std::tr1::make_tuple(m1));\n    return this->current_spec();\n  }\n\n  R Invoke(A1 a1) {\n    // Even though gcc and MSVC don't enforce it, 'this->' is required\n    // by the C++ standard [14.6.4] here, as the base class type is\n    // dependent on the template argument (and thus shouldn't be\n    // looked into when resolving InvokeWith).\n    return this->InvokeWith(ArgumentTuple(a1));\n  }\n};\n\ntemplate <typename R, typename A1, typename A2>\nclass FunctionMocker<R(A1, A2)> : public\n    internal::FunctionMockerBase<R(A1, A2)> {\n public:\n  typedef R F(A1, A2);\n  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;\n\n  MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2) {\n    this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2));\n    return this->current_spec();\n  }\n\n  R Invoke(A1 a1, A2 a2) {\n    // Even though gcc and MSVC don't enforce it, 'this->' is required\n    // by the C++ standard [14.6.4] here, as the base class type is\n    // dependent on the template argument (and thus shouldn't be\n    // looked into when resolving InvokeWith).\n    return this->InvokeWith(ArgumentTuple(a1, a2));\n  }\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3>\nclass FunctionMocker<R(A1, A2, A3)> : public\n    internal::FunctionMockerBase<R(A1, A2, A3)> {\n public:\n  typedef R F(A1, A2, A3);\n  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;\n\n  MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,\n      const Matcher<A3>& m3) {\n    this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3));\n    return this->current_spec();\n  }\n\n  R Invoke(A1 a1, A2 a2, A3 a3) {\n    // Even though gcc and MSVC don't enforce it, 'this->' is required\n    // by the C++ standard [14.6.4] here, as the base class type is\n    // dependent on the template argument (and thus shouldn't be\n    // looked into when resolving InvokeWith).\n    return this->InvokeWith(ArgumentTuple(a1, a2, a3));\n  }\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3, typename A4>\nclass FunctionMocker<R(A1, A2, A3, A4)> : public\n    internal::FunctionMockerBase<R(A1, A2, A3, A4)> {\n public:\n  typedef R F(A1, A2, A3, A4);\n  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;\n\n  MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,\n      const Matcher<A3>& m3, const Matcher<A4>& m4) {\n    this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4));\n    return this->current_spec();\n  }\n\n  R Invoke(A1 a1, A2 a2, A3 a3, A4 a4) {\n    // Even though gcc and MSVC don't enforce it, 'this->' is required\n    // by the C++ standard [14.6.4] here, as the base class type is\n    // dependent on the template argument (and thus shouldn't be\n    // looked into when resolving InvokeWith).\n    return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4));\n  }\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3, typename A4,\n    typename A5>\nclass FunctionMocker<R(A1, A2, A3, A4, A5)> : public\n    internal::FunctionMockerBase<R(A1, A2, A3, A4, A5)> {\n public:\n  typedef R F(A1, A2, A3, A4, A5);\n  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;\n\n  MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,\n      const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5) {\n    this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4,\n        m5));\n    return this->current_spec();\n  }\n\n  R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5) {\n    // Even though gcc and MSVC don't enforce it, 'this->' is required\n    // by the C++ standard [14.6.4] here, as the base class type is\n    // dependent on the template argument (and thus shouldn't be\n    // looked into when resolving InvokeWith).\n    return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5));\n  }\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3, typename A4,\n    typename A5, typename A6>\nclass FunctionMocker<R(A1, A2, A3, A4, A5, A6)> : public\n    internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6)> {\n public:\n  typedef R F(A1, A2, A3, A4, A5, A6);\n  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;\n\n  MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,\n      const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,\n      const Matcher<A6>& m6) {\n    this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,\n        m6));\n    return this->current_spec();\n  }\n\n  R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6) {\n    // Even though gcc and MSVC don't enforce it, 'this->' is required\n    // by the C++ standard [14.6.4] here, as the base class type is\n    // dependent on the template argument (and thus shouldn't be\n    // looked into when resolving InvokeWith).\n    return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6));\n  }\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3, typename A4,\n    typename A5, typename A6, typename A7>\nclass FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7)> : public\n    internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7)> {\n public:\n  typedef R F(A1, A2, A3, A4, A5, A6, A7);\n  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;\n\n  MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,\n      const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,\n      const Matcher<A6>& m6, const Matcher<A7>& m7) {\n    this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,\n        m6, m7));\n    return this->current_spec();\n  }\n\n  R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7) {\n    // Even though gcc and MSVC don't enforce it, 'this->' is required\n    // by the C++ standard [14.6.4] here, as the base class type is\n    // dependent on the template argument (and thus shouldn't be\n    // looked into when resolving InvokeWith).\n    return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7));\n  }\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3, typename A4,\n    typename A5, typename A6, typename A7, typename A8>\nclass FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8)> : public\n    internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8)> {\n public:\n  typedef R F(A1, A2, A3, A4, A5, A6, A7, A8);\n  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;\n\n  MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,\n      const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,\n      const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8) {\n    this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,\n        m6, m7, m8));\n    return this->current_spec();\n  }\n\n  R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8) {\n    // Even though gcc and MSVC don't enforce it, 'this->' is required\n    // by the C++ standard [14.6.4] here, as the base class type is\n    // dependent on the template argument (and thus shouldn't be\n    // looked into when resolving InvokeWith).\n    return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8));\n  }\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3, typename A4,\n    typename A5, typename A6, typename A7, typename A8, typename A9>\nclass FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> : public\n    internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> {\n public:\n  typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9);\n  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;\n\n  MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,\n      const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,\n      const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8,\n      const Matcher<A9>& m9) {\n    this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,\n        m6, m7, m8, m9));\n    return this->current_spec();\n  }\n\n  R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9) {\n    // Even though gcc and MSVC don't enforce it, 'this->' is required\n    // by the C++ standard [14.6.4] here, as the base class type is\n    // dependent on the template argument (and thus shouldn't be\n    // looked into when resolving InvokeWith).\n    return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9));\n  }\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3, typename A4,\n    typename A5, typename A6, typename A7, typename A8, typename A9,\n    typename A10>\nclass FunctionMocker<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> : public\n    internal::FunctionMockerBase<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)> {\n public:\n  typedef R F(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);\n  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;\n\n  MockSpec<F>& With(const Matcher<A1>& m1, const Matcher<A2>& m2,\n      const Matcher<A3>& m3, const Matcher<A4>& m4, const Matcher<A5>& m5,\n      const Matcher<A6>& m6, const Matcher<A7>& m7, const Matcher<A8>& m8,\n      const Matcher<A9>& m9, const Matcher<A10>& m10) {\n    this->current_spec().SetMatchers(::std::tr1::make_tuple(m1, m2, m3, m4, m5,\n        m6, m7, m8, m9, m10));\n    return this->current_spec();\n  }\n\n  R Invoke(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9,\n      A10 a10) {\n    // Even though gcc and MSVC don't enforce it, 'this->' is required\n    // by the C++ standard [14.6.4] here, as the base class type is\n    // dependent on the template argument (and thus shouldn't be\n    // looked into when resolving InvokeWith).\n    return this->InvokeWith(ArgumentTuple(a1, a2, a3, a4, a5, a6, a7, a8, a9,\n        a10));\n  }\n};\n\n}  // namespace internal\n\n// The style guide prohibits \"using\" statements in a namespace scope\n// inside a header file.  However, the FunctionMocker class template\n// is meant to be defined in the ::testing namespace.  The following\n// line is just a trick for working around a bug in MSVC 8.0, which\n// cannot handle it if we define FunctionMocker in ::testing.\nusing internal::FunctionMocker;\n\n// GMOCK_RESULT_(tn, F) expands to the result type of function type F.\n// We define this as a variadic macro in case F contains unprotected\n// commas (the same reason that we use variadic macros in other places\n// in this file).\n// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!\n#define GMOCK_RESULT_(tn, ...) \\\n    tn ::testing::internal::Function<__VA_ARGS__>::Result\n\n// The type of argument N of the given function type.\n// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!\n#define GMOCK_ARG_(tn, N, ...) \\\n    tn ::testing::internal::Function<__VA_ARGS__>::Argument##N\n\n// The matcher type for argument N of the given function type.\n// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!\n#define GMOCK_MATCHER_(tn, N, ...) \\\n    const ::testing::Matcher<GMOCK_ARG_(tn, N, __VA_ARGS__)>&\n\n// The variable for mocking the given method.\n// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!\n#define GMOCK_MOCKER_(arity, constness, Method) \\\n    GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__)\n\n// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!\n#define GMOCK_METHOD0_(tn, constness, ct, Method, ...) \\\n  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \\\n      ) constness { \\\n    GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size<                          \\\n        tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \\\n            == 0), \\\n        this_method_does_not_take_0_arguments); \\\n    GMOCK_MOCKER_(0, constness, Method).SetOwnerAndName(this, #Method); \\\n    return GMOCK_MOCKER_(0, constness, Method).Invoke(); \\\n  } \\\n  ::testing::MockSpec<__VA_ARGS__>& \\\n      gmock_##Method() constness { \\\n    GMOCK_MOCKER_(0, constness, Method).RegisterOwner(this); \\\n    return GMOCK_MOCKER_(0, constness, Method).With(); \\\n  } \\\n  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(0, constness, \\\n      Method)\n\n// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!\n#define GMOCK_METHOD1_(tn, constness, ct, Method, ...) \\\n  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \\\n      GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1) constness { \\\n    GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size<                          \\\n        tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \\\n            == 1), \\\n        this_method_does_not_take_1_argument); \\\n    GMOCK_MOCKER_(1, constness, Method).SetOwnerAndName(this, #Method); \\\n    return GMOCK_MOCKER_(1, constness, Method).Invoke(gmock_a1); \\\n  } \\\n  ::testing::MockSpec<__VA_ARGS__>& \\\n      gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1) constness { \\\n    GMOCK_MOCKER_(1, constness, Method).RegisterOwner(this); \\\n    return GMOCK_MOCKER_(1, constness, Method).With(gmock_a1); \\\n  } \\\n  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(1, constness, \\\n      Method)\n\n// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!\n#define GMOCK_METHOD2_(tn, constness, ct, Method, ...) \\\n  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \\\n      GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \\\n      GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2) constness { \\\n    GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size<                          \\\n        tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \\\n            == 2), \\\n        this_method_does_not_take_2_arguments); \\\n    GMOCK_MOCKER_(2, constness, Method).SetOwnerAndName(this, #Method); \\\n    return GMOCK_MOCKER_(2, constness, Method).Invoke(gmock_a1, gmock_a2); \\\n  } \\\n  ::testing::MockSpec<__VA_ARGS__>& \\\n      gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \\\n                     GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2) constness { \\\n    GMOCK_MOCKER_(2, constness, Method).RegisterOwner(this); \\\n    return GMOCK_MOCKER_(2, constness, Method).With(gmock_a1, gmock_a2); \\\n  } \\\n  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(2, constness, \\\n      Method)\n\n// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!\n#define GMOCK_METHOD3_(tn, constness, ct, Method, ...) \\\n  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \\\n      GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \\\n      GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \\\n      GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3) constness { \\\n    GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size<                          \\\n        tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \\\n            == 3), \\\n        this_method_does_not_take_3_arguments); \\\n    GMOCK_MOCKER_(3, constness, Method).SetOwnerAndName(this, #Method); \\\n    return GMOCK_MOCKER_(3, constness, Method).Invoke(gmock_a1, gmock_a2, \\\n        gmock_a3); \\\n  } \\\n  ::testing::MockSpec<__VA_ARGS__>& \\\n      gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \\\n                     GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \\\n                     GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3) constness { \\\n    GMOCK_MOCKER_(3, constness, Method).RegisterOwner(this); \\\n    return GMOCK_MOCKER_(3, constness, Method).With(gmock_a1, gmock_a2, \\\n        gmock_a3); \\\n  } \\\n  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(3, constness, \\\n      Method)\n\n// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!\n#define GMOCK_METHOD4_(tn, constness, ct, Method, ...) \\\n  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \\\n      GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \\\n      GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \\\n      GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \\\n      GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4) constness { \\\n    GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size<                          \\\n        tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \\\n            == 4), \\\n        this_method_does_not_take_4_arguments); \\\n    GMOCK_MOCKER_(4, constness, Method).SetOwnerAndName(this, #Method); \\\n    return GMOCK_MOCKER_(4, constness, Method).Invoke(gmock_a1, gmock_a2, \\\n        gmock_a3, gmock_a4); \\\n  } \\\n  ::testing::MockSpec<__VA_ARGS__>& \\\n      gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \\\n                     GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \\\n                     GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \\\n                     GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4) constness { \\\n    GMOCK_MOCKER_(4, constness, Method).RegisterOwner(this); \\\n    return GMOCK_MOCKER_(4, constness, Method).With(gmock_a1, gmock_a2, \\\n        gmock_a3, gmock_a4); \\\n  } \\\n  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(4, constness, \\\n      Method)\n\n// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!\n#define GMOCK_METHOD5_(tn, constness, ct, Method, ...) \\\n  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \\\n      GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \\\n      GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \\\n      GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \\\n      GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \\\n      GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5) constness { \\\n    GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size<                          \\\n        tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \\\n            == 5), \\\n        this_method_does_not_take_5_arguments); \\\n    GMOCK_MOCKER_(5, constness, Method).SetOwnerAndName(this, #Method); \\\n    return GMOCK_MOCKER_(5, constness, Method).Invoke(gmock_a1, gmock_a2, \\\n        gmock_a3, gmock_a4, gmock_a5); \\\n  } \\\n  ::testing::MockSpec<__VA_ARGS__>& \\\n      gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \\\n                     GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \\\n                     GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \\\n                     GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \\\n                     GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5) constness { \\\n    GMOCK_MOCKER_(5, constness, Method).RegisterOwner(this); \\\n    return GMOCK_MOCKER_(5, constness, Method).With(gmock_a1, gmock_a2, \\\n        gmock_a3, gmock_a4, gmock_a5); \\\n  } \\\n  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(5, constness, \\\n      Method)\n\n// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!\n#define GMOCK_METHOD6_(tn, constness, ct, Method, ...) \\\n  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \\\n      GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \\\n      GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \\\n      GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \\\n      GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \\\n      GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \\\n      GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6) constness { \\\n    GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size<                          \\\n        tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \\\n            == 6), \\\n        this_method_does_not_take_6_arguments); \\\n    GMOCK_MOCKER_(6, constness, Method).SetOwnerAndName(this, #Method); \\\n    return GMOCK_MOCKER_(6, constness, Method).Invoke(gmock_a1, gmock_a2, \\\n        gmock_a3, gmock_a4, gmock_a5, gmock_a6); \\\n  } \\\n  ::testing::MockSpec<__VA_ARGS__>& \\\n      gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \\\n                     GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \\\n                     GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \\\n                     GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \\\n                     GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \\\n                     GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6) constness { \\\n    GMOCK_MOCKER_(6, constness, Method).RegisterOwner(this); \\\n    return GMOCK_MOCKER_(6, constness, Method).With(gmock_a1, gmock_a2, \\\n        gmock_a3, gmock_a4, gmock_a5, gmock_a6); \\\n  } \\\n  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(6, constness, \\\n      Method)\n\n// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!\n#define GMOCK_METHOD7_(tn, constness, ct, Method, ...) \\\n  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \\\n      GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \\\n      GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \\\n      GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \\\n      GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \\\n      GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \\\n      GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \\\n      GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7) constness { \\\n    GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size<                          \\\n        tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \\\n            == 7), \\\n        this_method_does_not_take_7_arguments); \\\n    GMOCK_MOCKER_(7, constness, Method).SetOwnerAndName(this, #Method); \\\n    return GMOCK_MOCKER_(7, constness, Method).Invoke(gmock_a1, gmock_a2, \\\n        gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \\\n  } \\\n  ::testing::MockSpec<__VA_ARGS__>& \\\n      gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \\\n                     GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \\\n                     GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \\\n                     GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \\\n                     GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \\\n                     GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \\\n                     GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7) constness { \\\n    GMOCK_MOCKER_(7, constness, Method).RegisterOwner(this); \\\n    return GMOCK_MOCKER_(7, constness, Method).With(gmock_a1, gmock_a2, \\\n        gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7); \\\n  } \\\n  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(7, constness, \\\n      Method)\n\n// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!\n#define GMOCK_METHOD8_(tn, constness, ct, Method, ...) \\\n  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \\\n      GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \\\n      GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \\\n      GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \\\n      GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \\\n      GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \\\n      GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \\\n      GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \\\n      GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8) constness { \\\n    GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size<                          \\\n        tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \\\n            == 8), \\\n        this_method_does_not_take_8_arguments); \\\n    GMOCK_MOCKER_(8, constness, Method).SetOwnerAndName(this, #Method); \\\n    return GMOCK_MOCKER_(8, constness, Method).Invoke(gmock_a1, gmock_a2, \\\n        gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \\\n  } \\\n  ::testing::MockSpec<__VA_ARGS__>& \\\n      gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \\\n                     GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \\\n                     GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \\\n                     GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \\\n                     GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \\\n                     GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \\\n                     GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \\\n                     GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8) constness { \\\n    GMOCK_MOCKER_(8, constness, Method).RegisterOwner(this); \\\n    return GMOCK_MOCKER_(8, constness, Method).With(gmock_a1, gmock_a2, \\\n        gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8); \\\n  } \\\n  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(8, constness, \\\n      Method)\n\n// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!\n#define GMOCK_METHOD9_(tn, constness, ct, Method, ...) \\\n  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \\\n      GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \\\n      GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \\\n      GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \\\n      GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \\\n      GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \\\n      GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \\\n      GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \\\n      GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8, \\\n      GMOCK_ARG_(tn, 9, __VA_ARGS__) gmock_a9) constness { \\\n    GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size<                          \\\n        tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \\\n            == 9), \\\n        this_method_does_not_take_9_arguments); \\\n    GMOCK_MOCKER_(9, constness, Method).SetOwnerAndName(this, #Method); \\\n    return GMOCK_MOCKER_(9, constness, Method).Invoke(gmock_a1, gmock_a2, \\\n        gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \\\n        gmock_a9); \\\n  } \\\n  ::testing::MockSpec<__VA_ARGS__>& \\\n      gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \\\n                     GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \\\n                     GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \\\n                     GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \\\n                     GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \\\n                     GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \\\n                     GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \\\n                     GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8, \\\n                     GMOCK_MATCHER_(tn, 9, __VA_ARGS__) gmock_a9) constness { \\\n    GMOCK_MOCKER_(9, constness, Method).RegisterOwner(this); \\\n    return GMOCK_MOCKER_(9, constness, Method).With(gmock_a1, gmock_a2, \\\n        gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, \\\n        gmock_a9); \\\n  } \\\n  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(9, constness, \\\n      Method)\n\n// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!\n#define GMOCK_METHOD10_(tn, constness, ct, Method, ...) \\\n  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \\\n      GMOCK_ARG_(tn, 1, __VA_ARGS__) gmock_a1, \\\n      GMOCK_ARG_(tn, 2, __VA_ARGS__) gmock_a2, \\\n      GMOCK_ARG_(tn, 3, __VA_ARGS__) gmock_a3, \\\n      GMOCK_ARG_(tn, 4, __VA_ARGS__) gmock_a4, \\\n      GMOCK_ARG_(tn, 5, __VA_ARGS__) gmock_a5, \\\n      GMOCK_ARG_(tn, 6, __VA_ARGS__) gmock_a6, \\\n      GMOCK_ARG_(tn, 7, __VA_ARGS__) gmock_a7, \\\n      GMOCK_ARG_(tn, 8, __VA_ARGS__) gmock_a8, \\\n      GMOCK_ARG_(tn, 9, __VA_ARGS__) gmock_a9, \\\n      GMOCK_ARG_(tn, 10, __VA_ARGS__) gmock_a10) constness { \\\n    GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size<                          \\\n        tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value \\\n            == 10), \\\n        this_method_does_not_take_10_arguments); \\\n    GMOCK_MOCKER_(10, constness, Method).SetOwnerAndName(this, #Method); \\\n    return GMOCK_MOCKER_(10, constness, Method).Invoke(gmock_a1, gmock_a2, \\\n        gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \\\n        gmock_a10); \\\n  } \\\n  ::testing::MockSpec<__VA_ARGS__>& \\\n      gmock_##Method(GMOCK_MATCHER_(tn, 1, __VA_ARGS__) gmock_a1, \\\n                     GMOCK_MATCHER_(tn, 2, __VA_ARGS__) gmock_a2, \\\n                     GMOCK_MATCHER_(tn, 3, __VA_ARGS__) gmock_a3, \\\n                     GMOCK_MATCHER_(tn, 4, __VA_ARGS__) gmock_a4, \\\n                     GMOCK_MATCHER_(tn, 5, __VA_ARGS__) gmock_a5, \\\n                     GMOCK_MATCHER_(tn, 6, __VA_ARGS__) gmock_a6, \\\n                     GMOCK_MATCHER_(tn, 7, __VA_ARGS__) gmock_a7, \\\n                     GMOCK_MATCHER_(tn, 8, __VA_ARGS__) gmock_a8, \\\n                     GMOCK_MATCHER_(tn, 9, __VA_ARGS__) gmock_a9, \\\n                     GMOCK_MATCHER_(tn, 10, \\\n                         __VA_ARGS__) gmock_a10) constness { \\\n    GMOCK_MOCKER_(10, constness, Method).RegisterOwner(this); \\\n    return GMOCK_MOCKER_(10, constness, Method).With(gmock_a1, gmock_a2, \\\n        gmock_a3, gmock_a4, gmock_a5, gmock_a6, gmock_a7, gmock_a8, gmock_a9, \\\n        gmock_a10); \\\n  } \\\n  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_(10, constness, \\\n      Method)\n\n#define MOCK_METHOD0(m, ...) GMOCK_METHOD0_(, , , m, __VA_ARGS__)\n#define MOCK_METHOD1(m, ...) GMOCK_METHOD1_(, , , m, __VA_ARGS__)\n#define MOCK_METHOD2(m, ...) GMOCK_METHOD2_(, , , m, __VA_ARGS__)\n#define MOCK_METHOD3(m, ...) GMOCK_METHOD3_(, , , m, __VA_ARGS__)\n#define MOCK_METHOD4(m, ...) GMOCK_METHOD4_(, , , m, __VA_ARGS__)\n#define MOCK_METHOD5(m, ...) GMOCK_METHOD5_(, , , m, __VA_ARGS__)\n#define MOCK_METHOD6(m, ...) GMOCK_METHOD6_(, , , m, __VA_ARGS__)\n#define MOCK_METHOD7(m, ...) GMOCK_METHOD7_(, , , m, __VA_ARGS__)\n#define MOCK_METHOD8(m, ...) GMOCK_METHOD8_(, , , m, __VA_ARGS__)\n#define MOCK_METHOD9(m, ...) GMOCK_METHOD9_(, , , m, __VA_ARGS__)\n#define MOCK_METHOD10(m, ...) GMOCK_METHOD10_(, , , m, __VA_ARGS__)\n\n#define MOCK_CONST_METHOD0(m, ...) GMOCK_METHOD0_(, const, , m, __VA_ARGS__)\n#define MOCK_CONST_METHOD1(m, ...) GMOCK_METHOD1_(, const, , m, __VA_ARGS__)\n#define MOCK_CONST_METHOD2(m, ...) GMOCK_METHOD2_(, const, , m, __VA_ARGS__)\n#define MOCK_CONST_METHOD3(m, ...) GMOCK_METHOD3_(, const, , m, __VA_ARGS__)\n#define MOCK_CONST_METHOD4(m, ...) GMOCK_METHOD4_(, const, , m, __VA_ARGS__)\n#define MOCK_CONST_METHOD5(m, ...) GMOCK_METHOD5_(, const, , m, __VA_ARGS__)\n#define MOCK_CONST_METHOD6(m, ...) GMOCK_METHOD6_(, const, , m, __VA_ARGS__)\n#define MOCK_CONST_METHOD7(m, ...) GMOCK_METHOD7_(, const, , m, __VA_ARGS__)\n#define MOCK_CONST_METHOD8(m, ...) GMOCK_METHOD8_(, const, , m, __VA_ARGS__)\n#define MOCK_CONST_METHOD9(m, ...) GMOCK_METHOD9_(, const, , m, __VA_ARGS__)\n#define MOCK_CONST_METHOD10(m, ...) GMOCK_METHOD10_(, const, , m, __VA_ARGS__)\n\n#define MOCK_METHOD0_T(m, ...) GMOCK_METHOD0_(typename, , , m, __VA_ARGS__)\n#define MOCK_METHOD1_T(m, ...) GMOCK_METHOD1_(typename, , , m, __VA_ARGS__)\n#define MOCK_METHOD2_T(m, ...) GMOCK_METHOD2_(typename, , , m, __VA_ARGS__)\n#define MOCK_METHOD3_T(m, ...) GMOCK_METHOD3_(typename, , , m, __VA_ARGS__)\n#define MOCK_METHOD4_T(m, ...) GMOCK_METHOD4_(typename, , , m, __VA_ARGS__)\n#define MOCK_METHOD5_T(m, ...) GMOCK_METHOD5_(typename, , , m, __VA_ARGS__)\n#define MOCK_METHOD6_T(m, ...) GMOCK_METHOD6_(typename, , , m, __VA_ARGS__)\n#define MOCK_METHOD7_T(m, ...) GMOCK_METHOD7_(typename, , , m, __VA_ARGS__)\n#define MOCK_METHOD8_T(m, ...) GMOCK_METHOD8_(typename, , , m, __VA_ARGS__)\n#define MOCK_METHOD9_T(m, ...) GMOCK_METHOD9_(typename, , , m, __VA_ARGS__)\n#define MOCK_METHOD10_T(m, ...) GMOCK_METHOD10_(typename, , , m, __VA_ARGS__)\n\n#define MOCK_CONST_METHOD0_T(m, ...) \\\n    GMOCK_METHOD0_(typename, const, , m, __VA_ARGS__)\n#define MOCK_CONST_METHOD1_T(m, ...) \\\n    GMOCK_METHOD1_(typename, const, , m, __VA_ARGS__)\n#define MOCK_CONST_METHOD2_T(m, ...) \\\n    GMOCK_METHOD2_(typename, const, , m, __VA_ARGS__)\n#define MOCK_CONST_METHOD3_T(m, ...) \\\n    GMOCK_METHOD3_(typename, const, , m, __VA_ARGS__)\n#define MOCK_CONST_METHOD4_T(m, ...) \\\n    GMOCK_METHOD4_(typename, const, , m, __VA_ARGS__)\n#define MOCK_CONST_METHOD5_T(m, ...) \\\n    GMOCK_METHOD5_(typename, const, , m, __VA_ARGS__)\n#define MOCK_CONST_METHOD6_T(m, ...) \\\n    GMOCK_METHOD6_(typename, const, , m, __VA_ARGS__)\n#define MOCK_CONST_METHOD7_T(m, ...) \\\n    GMOCK_METHOD7_(typename, const, , m, __VA_ARGS__)\n#define MOCK_CONST_METHOD8_T(m, ...) \\\n    GMOCK_METHOD8_(typename, const, , m, __VA_ARGS__)\n#define MOCK_CONST_METHOD9_T(m, ...) \\\n    GMOCK_METHOD9_(typename, const, , m, __VA_ARGS__)\n#define MOCK_CONST_METHOD10_T(m, ...) \\\n    GMOCK_METHOD10_(typename, const, , m, __VA_ARGS__)\n\n#define MOCK_METHOD0_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD0_(, , ct, m, __VA_ARGS__)\n#define MOCK_METHOD1_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD1_(, , ct, m, __VA_ARGS__)\n#define MOCK_METHOD2_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD2_(, , ct, m, __VA_ARGS__)\n#define MOCK_METHOD3_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD3_(, , ct, m, __VA_ARGS__)\n#define MOCK_METHOD4_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD4_(, , ct, m, __VA_ARGS__)\n#define MOCK_METHOD5_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD5_(, , ct, m, __VA_ARGS__)\n#define MOCK_METHOD6_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD6_(, , ct, m, __VA_ARGS__)\n#define MOCK_METHOD7_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD7_(, , ct, m, __VA_ARGS__)\n#define MOCK_METHOD8_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD8_(, , ct, m, __VA_ARGS__)\n#define MOCK_METHOD9_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD9_(, , ct, m, __VA_ARGS__)\n#define MOCK_METHOD10_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD10_(, , ct, m, __VA_ARGS__)\n\n#define MOCK_CONST_METHOD0_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD0_(, const, ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD1_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD1_(, const, ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD2_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD2_(, const, ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD3_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD3_(, const, ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD4_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD4_(, const, ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD5_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD5_(, const, ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD6_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD6_(, const, ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD7_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD7_(, const, ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD8_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD8_(, const, ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD9_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD9_(, const, ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD10_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD10_(, const, ct, m, __VA_ARGS__)\n\n#define MOCK_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD0_(typename, , ct, m, __VA_ARGS__)\n#define MOCK_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD1_(typename, , ct, m, __VA_ARGS__)\n#define MOCK_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD2_(typename, , ct, m, __VA_ARGS__)\n#define MOCK_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD3_(typename, , ct, m, __VA_ARGS__)\n#define MOCK_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD4_(typename, , ct, m, __VA_ARGS__)\n#define MOCK_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD5_(typename, , ct, m, __VA_ARGS__)\n#define MOCK_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD6_(typename, , ct, m, __VA_ARGS__)\n#define MOCK_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD7_(typename, , ct, m, __VA_ARGS__)\n#define MOCK_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD8_(typename, , ct, m, __VA_ARGS__)\n#define MOCK_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD9_(typename, , ct, m, __VA_ARGS__)\n#define MOCK_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD10_(typename, , ct, m, __VA_ARGS__)\n\n#define MOCK_CONST_METHOD0_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD0_(typename, const, ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD1_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD1_(typename, const, ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD2_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD2_(typename, const, ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD3_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD3_(typename, const, ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD4_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD4_(typename, const, ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD5_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD5_(typename, const, ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD6_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD6_(typename, const, ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD7_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD7_(typename, const, ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD8_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD8_(typename, const, ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD9_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD9_(typename, const, ct, m, __VA_ARGS__)\n#define MOCK_CONST_METHOD10_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD10_(typename, const, ct, m, __VA_ARGS__)\n\n// A MockFunction<F> class has one mock method whose type is F.  It is\n// useful when you just want your test code to emit some messages and\n// have Google Mock verify the right messages are sent (and perhaps at\n// the right times).  For example, if you are exercising code:\n//\n//   Foo(1);\n//   Foo(2);\n//   Foo(3);\n//\n// and want to verify that Foo(1) and Foo(3) both invoke\n// mock.Bar(\"a\"), but Foo(2) doesn't invoke anything, you can write:\n//\n// TEST(FooTest, InvokesBarCorrectly) {\n//   MyMock mock;\n//   MockFunction<void(string check_point_name)> check;\n//   {\n//     InSequence s;\n//\n//     EXPECT_CALL(mock, Bar(\"a\"));\n//     EXPECT_CALL(check, Call(\"1\"));\n//     EXPECT_CALL(check, Call(\"2\"));\n//     EXPECT_CALL(mock, Bar(\"a\"));\n//   }\n//   Foo(1);\n//   check.Call(\"1\");\n//   Foo(2);\n//   check.Call(\"2\");\n//   Foo(3);\n// }\n//\n// The expectation spec says that the first Bar(\"a\") must happen\n// before check point \"1\", the second Bar(\"a\") must happen after check\n// point \"2\", and nothing should happen between the two check\n// points. The explicit check points make it easy to tell which\n// Bar(\"a\") is called by which call to Foo().\ntemplate <typename F>\nclass MockFunction;\n\ntemplate <typename R>\nclass MockFunction<R()> {\n public:\n  MockFunction() {}\n\n  MOCK_METHOD0_T(Call, R());\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);\n};\n\ntemplate <typename R, typename A0>\nclass MockFunction<R(A0)> {\n public:\n  MockFunction() {}\n\n  MOCK_METHOD1_T(Call, R(A0));\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);\n};\n\ntemplate <typename R, typename A0, typename A1>\nclass MockFunction<R(A0, A1)> {\n public:\n  MockFunction() {}\n\n  MOCK_METHOD2_T(Call, R(A0, A1));\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);\n};\n\ntemplate <typename R, typename A0, typename A1, typename A2>\nclass MockFunction<R(A0, A1, A2)> {\n public:\n  MockFunction() {}\n\n  MOCK_METHOD3_T(Call, R(A0, A1, A2));\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);\n};\n\ntemplate <typename R, typename A0, typename A1, typename A2, typename A3>\nclass MockFunction<R(A0, A1, A2, A3)> {\n public:\n  MockFunction() {}\n\n  MOCK_METHOD4_T(Call, R(A0, A1, A2, A3));\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);\n};\n\ntemplate <typename R, typename A0, typename A1, typename A2, typename A3,\n    typename A4>\nclass MockFunction<R(A0, A1, A2, A3, A4)> {\n public:\n  MockFunction() {}\n\n  MOCK_METHOD5_T(Call, R(A0, A1, A2, A3, A4));\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);\n};\n\ntemplate <typename R, typename A0, typename A1, typename A2, typename A3,\n    typename A4, typename A5>\nclass MockFunction<R(A0, A1, A2, A3, A4, A5)> {\n public:\n  MockFunction() {}\n\n  MOCK_METHOD6_T(Call, R(A0, A1, A2, A3, A4, A5));\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);\n};\n\ntemplate <typename R, typename A0, typename A1, typename A2, typename A3,\n    typename A4, typename A5, typename A6>\nclass MockFunction<R(A0, A1, A2, A3, A4, A5, A6)> {\n public:\n  MockFunction() {}\n\n  MOCK_METHOD7_T(Call, R(A0, A1, A2, A3, A4, A5, A6));\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);\n};\n\ntemplate <typename R, typename A0, typename A1, typename A2, typename A3,\n    typename A4, typename A5, typename A6, typename A7>\nclass MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7)> {\n public:\n  MockFunction() {}\n\n  MOCK_METHOD8_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7));\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);\n};\n\ntemplate <typename R, typename A0, typename A1, typename A2, typename A3,\n    typename A4, typename A5, typename A6, typename A7, typename A8>\nclass MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8)> {\n public:\n  MockFunction() {}\n\n  MOCK_METHOD9_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8));\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);\n};\n\ntemplate <typename R, typename A0, typename A1, typename A2, typename A3,\n    typename A4, typename A5, typename A6, typename A7, typename A8,\n    typename A9>\nclass MockFunction<R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9)> {\n public:\n  MockFunction() {}\n\n  MOCK_METHOD10_T(Call, R(A0, A1, A2, A3, A4, A5, A6, A7, A8, A9));\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);\n};\n\n}  // namespace testing\n\n#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_\n"
  },
  {
    "path": "ext/gmock/include/gmock/gmock-generated-function-mockers.h.pump",
    "content": "$$ -*- mode: c++; -*-\n$$ This is a Pump source file.  Please use Pump to convert it to\n$$ gmock-generated-function-mockers.h.\n$$\n$var n = 10  $$ The maximum arity we support.\n// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements function mockers of various arities.\n\n#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_\n#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_\n\n#include \"gmock/gmock-spec-builders.h\"\n#include \"gmock/internal/gmock-internal-utils.h\"\n\nnamespace testing {\nnamespace internal {\n\ntemplate <typename F>\nclass FunctionMockerBase;\n\n// Note: class FunctionMocker really belongs to the ::testing\n// namespace.  However if we define it in ::testing, MSVC will\n// complain when classes in ::testing::internal declare it as a\n// friend class template.  To workaround this compiler bug, we define\n// FunctionMocker in ::testing::internal and import it into ::testing.\ntemplate <typename F>\nclass FunctionMocker;\n\n\n$range i 0..n\n$for i [[\n$range j 1..i\n$var typename_As = [[$for j [[, typename A$j]]]]\n$var As = [[$for j, [[A$j]]]]\n$var as = [[$for j, [[a$j]]]]\n$var Aas = [[$for j, [[A$j a$j]]]]\n$var ms = [[$for j, [[m$j]]]]\n$var matchers = [[$for j, [[const Matcher<A$j>& m$j]]]]\ntemplate <typename R$typename_As>\nclass FunctionMocker<R($As)> : public\n    internal::FunctionMockerBase<R($As)> {\n public:\n  typedef R F($As);\n  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;\n\n  MockSpec<F>& With($matchers) {\n\n$if i >= 1 [[\n    this->current_spec().SetMatchers(::std::tr1::make_tuple($ms));\n\n]]\n    return this->current_spec();\n  }\n\n  R Invoke($Aas) {\n    // Even though gcc and MSVC don't enforce it, 'this->' is required\n    // by the C++ standard [14.6.4] here, as the base class type is\n    // dependent on the template argument (and thus shouldn't be\n    // looked into when resolving InvokeWith).\n    return this->InvokeWith(ArgumentTuple($as));\n  }\n};\n\n\n]]\n}  // namespace internal\n\n// The style guide prohibits \"using\" statements in a namespace scope\n// inside a header file.  However, the FunctionMocker class template\n// is meant to be defined in the ::testing namespace.  The following\n// line is just a trick for working around a bug in MSVC 8.0, which\n// cannot handle it if we define FunctionMocker in ::testing.\nusing internal::FunctionMocker;\n\n// GMOCK_RESULT_(tn, F) expands to the result type of function type F.\n// We define this as a variadic macro in case F contains unprotected\n// commas (the same reason that we use variadic macros in other places\n// in this file).\n// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!\n#define GMOCK_RESULT_(tn, ...) \\\n    tn ::testing::internal::Function<__VA_ARGS__>::Result\n\n// The type of argument N of the given function type.\n// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!\n#define GMOCK_ARG_(tn, N, ...) \\\n    tn ::testing::internal::Function<__VA_ARGS__>::Argument##N\n\n// The matcher type for argument N of the given function type.\n// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!\n#define GMOCK_MATCHER_(tn, N, ...) \\\n    const ::testing::Matcher<GMOCK_ARG_(tn, N, __VA_ARGS__)>&\n\n// The variable for mocking the given method.\n// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!\n#define GMOCK_MOCKER_(arity, constness, Method) \\\n    GTEST_CONCAT_TOKEN_(gmock##constness##arity##_##Method##_, __LINE__)\n\n\n$for i [[\n$range j 1..i\n$var arg_as = [[$for j, \\\n      [[GMOCK_ARG_(tn, $j, __VA_ARGS__) gmock_a$j]]]]\n$var as = [[$for j, [[gmock_a$j]]]]\n$var matcher_as = [[$for j, \\\n                     [[GMOCK_MATCHER_(tn, $j, __VA_ARGS__) gmock_a$j]]]]\n// INTERNAL IMPLEMENTATION - DON'T USE IN USER CODE!!!\n#define GMOCK_METHOD$i[[]]_(tn, constness, ct, Method, ...) \\\n  GMOCK_RESULT_(tn, __VA_ARGS__) ct Method( \\\n      $arg_as) constness { \\\n    GTEST_COMPILE_ASSERT_((::std::tr1::tuple_size<                          \\\n        tn ::testing::internal::Function<__VA_ARGS__>::ArgumentTuple>::value == $i), \\\n        this_method_does_not_take_$i[[]]_argument[[$if i != 1 [[s]]]]); \\\n    GMOCK_MOCKER_($i, constness, Method).SetOwnerAndName(this, #Method); \\\n    return GMOCK_MOCKER_($i, constness, Method).Invoke($as); \\\n  } \\\n  ::testing::MockSpec<__VA_ARGS__>& \\\n      gmock_##Method($matcher_as) constness { \\\n    GMOCK_MOCKER_($i, constness, Method).RegisterOwner(this); \\\n    return GMOCK_MOCKER_($i, constness, Method).With($as); \\\n  } \\\n  mutable ::testing::FunctionMocker<__VA_ARGS__> GMOCK_MOCKER_($i, constness, Method)\n\n\n]]\n$for i [[\n#define MOCK_METHOD$i(m, ...) GMOCK_METHOD$i[[]]_(, , , m, __VA_ARGS__)\n\n]]\n\n\n$for i [[\n#define MOCK_CONST_METHOD$i(m, ...) GMOCK_METHOD$i[[]]_(, const, , m, __VA_ARGS__)\n\n]]\n\n\n$for i [[\n#define MOCK_METHOD$i[[]]_T(m, ...) GMOCK_METHOD$i[[]]_(typename, , , m, __VA_ARGS__)\n\n]]\n\n\n$for i [[\n#define MOCK_CONST_METHOD$i[[]]_T(m, ...) \\\n    GMOCK_METHOD$i[[]]_(typename, const, , m, __VA_ARGS__)\n\n]]\n\n\n$for i [[\n#define MOCK_METHOD$i[[]]_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD$i[[]]_(, , ct, m, __VA_ARGS__)\n\n]]\n\n\n$for i [[\n#define MOCK_CONST_METHOD$i[[]]_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD$i[[]]_(, const, ct, m, __VA_ARGS__)\n\n]]\n\n\n$for i [[\n#define MOCK_METHOD$i[[]]_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD$i[[]]_(typename, , ct, m, __VA_ARGS__)\n\n]]\n\n\n$for i [[\n#define MOCK_CONST_METHOD$i[[]]_T_WITH_CALLTYPE(ct, m, ...) \\\n    GMOCK_METHOD$i[[]]_(typename, const, ct, m, __VA_ARGS__)\n\n]]\n\n// A MockFunction<F> class has one mock method whose type is F.  It is\n// useful when you just want your test code to emit some messages and\n// have Google Mock verify the right messages are sent (and perhaps at\n// the right times).  For example, if you are exercising code:\n//\n//   Foo(1);\n//   Foo(2);\n//   Foo(3);\n//\n// and want to verify that Foo(1) and Foo(3) both invoke\n// mock.Bar(\"a\"), but Foo(2) doesn't invoke anything, you can write:\n//\n// TEST(FooTest, InvokesBarCorrectly) {\n//   MyMock mock;\n//   MockFunction<void(string check_point_name)> check;\n//   {\n//     InSequence s;\n//\n//     EXPECT_CALL(mock, Bar(\"a\"));\n//     EXPECT_CALL(check, Call(\"1\"));\n//     EXPECT_CALL(check, Call(\"2\"));\n//     EXPECT_CALL(mock, Bar(\"a\"));\n//   }\n//   Foo(1);\n//   check.Call(\"1\");\n//   Foo(2);\n//   check.Call(\"2\");\n//   Foo(3);\n// }\n//\n// The expectation spec says that the first Bar(\"a\") must happen\n// before check point \"1\", the second Bar(\"a\") must happen after check\n// point \"2\", and nothing should happen between the two check\n// points. The explicit check points make it easy to tell which\n// Bar(\"a\") is called by which call to Foo().\ntemplate <typename F>\nclass MockFunction;\n\n\n$for i [[\n$range j 0..i-1\ntemplate <typename R$for j [[, typename A$j]]>\nclass MockFunction<R($for j, [[A$j]])> {\n public:\n  MockFunction() {}\n\n  MOCK_METHOD$i[[]]_T(Call, R($for j, [[A$j]]));\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFunction);\n};\n\n\n]]\n}  // namespace testing\n\n#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_FUNCTION_MOCKERS_H_\n"
  },
  {
    "path": "ext/gmock/include/gmock/gmock-generated-matchers.h",
    "content": "// This file was GENERATED by command:\n//     pump.py gmock-generated-matchers.h.pump\n// DO NOT EDIT BY HAND!!!\n\n// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements some commonly used variadic matchers.\n\n#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_\n#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_\n\n#include <iterator>\n#include <sstream>\n#include <string>\n#include <vector>\n#include \"gmock/gmock-matchers.h\"\n\nnamespace testing {\nnamespace internal {\n\n// The type of the i-th (0-based) field of Tuple.\n#define GMOCK_FIELD_TYPE_(Tuple, i) \\\n    typename ::std::tr1::tuple_element<i, Tuple>::type\n\n// TupleFields<Tuple, k0, ..., kn> is for selecting fields from a\n// tuple of type Tuple.  It has two members:\n//\n//   type: a tuple type whose i-th field is the ki-th field of Tuple.\n//   GetSelectedFields(t): returns fields k0, ..., and kn of t as a tuple.\n//\n// For example, in class TupleFields<tuple<bool, char, int>, 2, 0>, we have:\n//\n//   type is tuple<int, bool>, and\n//   GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true).\n\ntemplate <class Tuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,\n    int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,\n    int k9 = -1>\nclass TupleFields;\n\n// This generic version is used when there are 10 selectors.\ntemplate <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,\n    int k7, int k8, int k9>\nclass TupleFields {\n public:\n  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),\n      GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),\n      GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),\n      GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),\n      GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8),\n      GMOCK_FIELD_TYPE_(Tuple, k9)> type;\n  static type GetSelectedFields(const Tuple& t) {\n    using ::std::tr1::get;\n    return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),\n        get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t), get<k9>(t));\n  }\n};\n\n// The following specialization is used for 0 ~ 9 selectors.\n\ntemplate <class Tuple>\nclass TupleFields<Tuple, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1> {\n public:\n  typedef ::std::tr1::tuple<> type;\n  static type GetSelectedFields(const Tuple& /* t */) {\n    using ::std::tr1::get;\n    return type();\n  }\n};\n\ntemplate <class Tuple, int k0>\nclass TupleFields<Tuple, k0, -1, -1, -1, -1, -1, -1, -1, -1, -1> {\n public:\n  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0)> type;\n  static type GetSelectedFields(const Tuple& t) {\n    using ::std::tr1::get;\n    return type(get<k0>(t));\n  }\n};\n\ntemplate <class Tuple, int k0, int k1>\nclass TupleFields<Tuple, k0, k1, -1, -1, -1, -1, -1, -1, -1, -1> {\n public:\n  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),\n      GMOCK_FIELD_TYPE_(Tuple, k1)> type;\n  static type GetSelectedFields(const Tuple& t) {\n    using ::std::tr1::get;\n    return type(get<k0>(t), get<k1>(t));\n  }\n};\n\ntemplate <class Tuple, int k0, int k1, int k2>\nclass TupleFields<Tuple, k0, k1, k2, -1, -1, -1, -1, -1, -1, -1> {\n public:\n  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),\n      GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2)> type;\n  static type GetSelectedFields(const Tuple& t) {\n    using ::std::tr1::get;\n    return type(get<k0>(t), get<k1>(t), get<k2>(t));\n  }\n};\n\ntemplate <class Tuple, int k0, int k1, int k2, int k3>\nclass TupleFields<Tuple, k0, k1, k2, k3, -1, -1, -1, -1, -1, -1> {\n public:\n  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),\n      GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),\n      GMOCK_FIELD_TYPE_(Tuple, k3)> type;\n  static type GetSelectedFields(const Tuple& t) {\n    using ::std::tr1::get;\n    return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t));\n  }\n};\n\ntemplate <class Tuple, int k0, int k1, int k2, int k3, int k4>\nclass TupleFields<Tuple, k0, k1, k2, k3, k4, -1, -1, -1, -1, -1> {\n public:\n  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),\n      GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),\n      GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4)> type;\n  static type GetSelectedFields(const Tuple& t) {\n    using ::std::tr1::get;\n    return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t));\n  }\n};\n\ntemplate <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5>\nclass TupleFields<Tuple, k0, k1, k2, k3, k4, k5, -1, -1, -1, -1> {\n public:\n  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),\n      GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),\n      GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),\n      GMOCK_FIELD_TYPE_(Tuple, k5)> type;\n  static type GetSelectedFields(const Tuple& t) {\n    using ::std::tr1::get;\n    return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),\n        get<k5>(t));\n  }\n};\n\ntemplate <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6>\nclass TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, -1, -1, -1> {\n public:\n  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),\n      GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),\n      GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),\n      GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6)> type;\n  static type GetSelectedFields(const Tuple& t) {\n    using ::std::tr1::get;\n    return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),\n        get<k5>(t), get<k6>(t));\n  }\n};\n\ntemplate <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,\n    int k7>\nclass TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, -1, -1> {\n public:\n  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),\n      GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),\n      GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),\n      GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),\n      GMOCK_FIELD_TYPE_(Tuple, k7)> type;\n  static type GetSelectedFields(const Tuple& t) {\n    using ::std::tr1::get;\n    return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),\n        get<k5>(t), get<k6>(t), get<k7>(t));\n  }\n};\n\ntemplate <class Tuple, int k0, int k1, int k2, int k3, int k4, int k5, int k6,\n    int k7, int k8>\nclass TupleFields<Tuple, k0, k1, k2, k3, k4, k5, k6, k7, k8, -1> {\n public:\n  typedef ::std::tr1::tuple<GMOCK_FIELD_TYPE_(Tuple, k0),\n      GMOCK_FIELD_TYPE_(Tuple, k1), GMOCK_FIELD_TYPE_(Tuple, k2),\n      GMOCK_FIELD_TYPE_(Tuple, k3), GMOCK_FIELD_TYPE_(Tuple, k4),\n      GMOCK_FIELD_TYPE_(Tuple, k5), GMOCK_FIELD_TYPE_(Tuple, k6),\n      GMOCK_FIELD_TYPE_(Tuple, k7), GMOCK_FIELD_TYPE_(Tuple, k8)> type;\n  static type GetSelectedFields(const Tuple& t) {\n    using ::std::tr1::get;\n    return type(get<k0>(t), get<k1>(t), get<k2>(t), get<k3>(t), get<k4>(t),\n        get<k5>(t), get<k6>(t), get<k7>(t), get<k8>(t));\n  }\n};\n\n#undef GMOCK_FIELD_TYPE_\n\n// Implements the Args() matcher.\ntemplate <class ArgsTuple, int k0 = -1, int k1 = -1, int k2 = -1, int k3 = -1,\n    int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1, int k8 = -1,\n    int k9 = -1>\nclass ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {\n public:\n  // ArgsTuple may have top-level const or reference modifiers.\n  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(ArgsTuple) RawArgsTuple;\n  typedef typename internal::TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5,\n      k6, k7, k8, k9>::type SelectedArgs;\n  typedef Matcher<const SelectedArgs&> MonomorphicInnerMatcher;\n\n  template <typename InnerMatcher>\n  explicit ArgsMatcherImpl(const InnerMatcher& inner_matcher)\n      : inner_matcher_(SafeMatcherCast<const SelectedArgs&>(inner_matcher)) {}\n\n  virtual bool MatchAndExplain(ArgsTuple args,\n                               MatchResultListener* listener) const {\n    const SelectedArgs& selected_args = GetSelectedArgs(args);\n    if (!listener->IsInterested())\n      return inner_matcher_.Matches(selected_args);\n\n    PrintIndices(listener->stream());\n    *listener << \"are \" << PrintToString(selected_args);\n\n    StringMatchResultListener inner_listener;\n    const bool match = inner_matcher_.MatchAndExplain(selected_args,\n                                                      &inner_listener);\n    PrintIfNotEmpty(inner_listener.str(), listener->stream());\n    return match;\n  }\n\n  virtual void DescribeTo(::std::ostream* os) const {\n    *os << \"are a tuple \";\n    PrintIndices(os);\n    inner_matcher_.DescribeTo(os);\n  }\n\n  virtual void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"are a tuple \";\n    PrintIndices(os);\n    inner_matcher_.DescribeNegationTo(os);\n  }\n\n private:\n  static SelectedArgs GetSelectedArgs(ArgsTuple args) {\n    return TupleFields<RawArgsTuple, k0, k1, k2, k3, k4, k5, k6, k7, k8,\n        k9>::GetSelectedFields(args);\n  }\n\n  // Prints the indices of the selected fields.\n  static void PrintIndices(::std::ostream* os) {\n    *os << \"whose fields (\";\n    const int indices[10] = { k0, k1, k2, k3, k4, k5, k6, k7, k8, k9 };\n    for (int i = 0; i < 10; i++) {\n      if (indices[i] < 0)\n        break;\n\n      if (i >= 1)\n        *os << \", \";\n\n      *os << \"#\" << indices[i];\n    }\n    *os << \") \";\n  }\n\n  const MonomorphicInnerMatcher inner_matcher_;\n\n  GTEST_DISALLOW_ASSIGN_(ArgsMatcherImpl);\n};\n\ntemplate <class InnerMatcher, int k0 = -1, int k1 = -1, int k2 = -1,\n    int k3 = -1, int k4 = -1, int k5 = -1, int k6 = -1, int k7 = -1,\n    int k8 = -1, int k9 = -1>\nclass ArgsMatcher {\n public:\n  explicit ArgsMatcher(const InnerMatcher& inner_matcher)\n      : inner_matcher_(inner_matcher) {}\n\n  template <typename ArgsTuple>\n  operator Matcher<ArgsTuple>() const {\n    return MakeMatcher(new ArgsMatcherImpl<ArgsTuple, k0, k1, k2, k3, k4, k5,\n        k6, k7, k8, k9>(inner_matcher_));\n  }\n\n private:\n  const InnerMatcher inner_matcher_;\n\n  GTEST_DISALLOW_ASSIGN_(ArgsMatcher);\n};\n\n// A set of metafunctions for computing the result type of AllOf.\n// AllOf(m1, ..., mN) returns\n// AllOfResultN<decltype(m1), ..., decltype(mN)>::type.\n\n// Although AllOf isn't defined for one argument, AllOfResult1 is defined\n// to simplify the implementation.\ntemplate <typename M1>\nstruct AllOfResult1 {\n  typedef M1 type;\n};\n\ntemplate <typename M1, typename M2>\nstruct AllOfResult2 {\n  typedef BothOfMatcher<\n      typename AllOfResult1<M1>::type,\n      typename AllOfResult1<M2>::type\n  > type;\n};\n\ntemplate <typename M1, typename M2, typename M3>\nstruct AllOfResult3 {\n  typedef BothOfMatcher<\n      typename AllOfResult1<M1>::type,\n      typename AllOfResult2<M2, M3>::type\n  > type;\n};\n\ntemplate <typename M1, typename M2, typename M3, typename M4>\nstruct AllOfResult4 {\n  typedef BothOfMatcher<\n      typename AllOfResult2<M1, M2>::type,\n      typename AllOfResult2<M3, M4>::type\n  > type;\n};\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5>\nstruct AllOfResult5 {\n  typedef BothOfMatcher<\n      typename AllOfResult2<M1, M2>::type,\n      typename AllOfResult3<M3, M4, M5>::type\n  > type;\n};\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5,\n    typename M6>\nstruct AllOfResult6 {\n  typedef BothOfMatcher<\n      typename AllOfResult3<M1, M2, M3>::type,\n      typename AllOfResult3<M4, M5, M6>::type\n  > type;\n};\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5,\n    typename M6, typename M7>\nstruct AllOfResult7 {\n  typedef BothOfMatcher<\n      typename AllOfResult3<M1, M2, M3>::type,\n      typename AllOfResult4<M4, M5, M6, M7>::type\n  > type;\n};\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5,\n    typename M6, typename M7, typename M8>\nstruct AllOfResult8 {\n  typedef BothOfMatcher<\n      typename AllOfResult4<M1, M2, M3, M4>::type,\n      typename AllOfResult4<M5, M6, M7, M8>::type\n  > type;\n};\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5,\n    typename M6, typename M7, typename M8, typename M9>\nstruct AllOfResult9 {\n  typedef BothOfMatcher<\n      typename AllOfResult4<M1, M2, M3, M4>::type,\n      typename AllOfResult5<M5, M6, M7, M8, M9>::type\n  > type;\n};\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5,\n    typename M6, typename M7, typename M8, typename M9, typename M10>\nstruct AllOfResult10 {\n  typedef BothOfMatcher<\n      typename AllOfResult5<M1, M2, M3, M4, M5>::type,\n      typename AllOfResult5<M6, M7, M8, M9, M10>::type\n  > type;\n};\n\n// A set of metafunctions for computing the result type of AnyOf.\n// AnyOf(m1, ..., mN) returns\n// AnyOfResultN<decltype(m1), ..., decltype(mN)>::type.\n\n// Although AnyOf isn't defined for one argument, AnyOfResult1 is defined\n// to simplify the implementation.\ntemplate <typename M1>\nstruct AnyOfResult1 {\n  typedef M1 type;\n};\n\ntemplate <typename M1, typename M2>\nstruct AnyOfResult2 {\n  typedef EitherOfMatcher<\n      typename AnyOfResult1<M1>::type,\n      typename AnyOfResult1<M2>::type\n  > type;\n};\n\ntemplate <typename M1, typename M2, typename M3>\nstruct AnyOfResult3 {\n  typedef EitherOfMatcher<\n      typename AnyOfResult1<M1>::type,\n      typename AnyOfResult2<M2, M3>::type\n  > type;\n};\n\ntemplate <typename M1, typename M2, typename M3, typename M4>\nstruct AnyOfResult4 {\n  typedef EitherOfMatcher<\n      typename AnyOfResult2<M1, M2>::type,\n      typename AnyOfResult2<M3, M4>::type\n  > type;\n};\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5>\nstruct AnyOfResult5 {\n  typedef EitherOfMatcher<\n      typename AnyOfResult2<M1, M2>::type,\n      typename AnyOfResult3<M3, M4, M5>::type\n  > type;\n};\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5,\n    typename M6>\nstruct AnyOfResult6 {\n  typedef EitherOfMatcher<\n      typename AnyOfResult3<M1, M2, M3>::type,\n      typename AnyOfResult3<M4, M5, M6>::type\n  > type;\n};\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5,\n    typename M6, typename M7>\nstruct AnyOfResult7 {\n  typedef EitherOfMatcher<\n      typename AnyOfResult3<M1, M2, M3>::type,\n      typename AnyOfResult4<M4, M5, M6, M7>::type\n  > type;\n};\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5,\n    typename M6, typename M7, typename M8>\nstruct AnyOfResult8 {\n  typedef EitherOfMatcher<\n      typename AnyOfResult4<M1, M2, M3, M4>::type,\n      typename AnyOfResult4<M5, M6, M7, M8>::type\n  > type;\n};\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5,\n    typename M6, typename M7, typename M8, typename M9>\nstruct AnyOfResult9 {\n  typedef EitherOfMatcher<\n      typename AnyOfResult4<M1, M2, M3, M4>::type,\n      typename AnyOfResult5<M5, M6, M7, M8, M9>::type\n  > type;\n};\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5,\n    typename M6, typename M7, typename M8, typename M9, typename M10>\nstruct AnyOfResult10 {\n  typedef EitherOfMatcher<\n      typename AnyOfResult5<M1, M2, M3, M4, M5>::type,\n      typename AnyOfResult5<M6, M7, M8, M9, M10>::type\n  > type;\n};\n\n}  // namespace internal\n\n// Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected\n// fields of it matches a_matcher.  C++ doesn't support default\n// arguments for function templates, so we have to overload it.\ntemplate <typename InnerMatcher>\ninline internal::ArgsMatcher<InnerMatcher>\nArgs(const InnerMatcher& matcher) {\n  return internal::ArgsMatcher<InnerMatcher>(matcher);\n}\n\ntemplate <int k1, typename InnerMatcher>\ninline internal::ArgsMatcher<InnerMatcher, k1>\nArgs(const InnerMatcher& matcher) {\n  return internal::ArgsMatcher<InnerMatcher, k1>(matcher);\n}\n\ntemplate <int k1, int k2, typename InnerMatcher>\ninline internal::ArgsMatcher<InnerMatcher, k1, k2>\nArgs(const InnerMatcher& matcher) {\n  return internal::ArgsMatcher<InnerMatcher, k1, k2>(matcher);\n}\n\ntemplate <int k1, int k2, int k3, typename InnerMatcher>\ninline internal::ArgsMatcher<InnerMatcher, k1, k2, k3>\nArgs(const InnerMatcher& matcher) {\n  return internal::ArgsMatcher<InnerMatcher, k1, k2, k3>(matcher);\n}\n\ntemplate <int k1, int k2, int k3, int k4, typename InnerMatcher>\ninline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>\nArgs(const InnerMatcher& matcher) {\n  return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4>(matcher);\n}\n\ntemplate <int k1, int k2, int k3, int k4, int k5, typename InnerMatcher>\ninline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>\nArgs(const InnerMatcher& matcher) {\n  return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5>(matcher);\n}\n\ntemplate <int k1, int k2, int k3, int k4, int k5, int k6, typename InnerMatcher>\ninline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>\nArgs(const InnerMatcher& matcher) {\n  return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6>(matcher);\n}\n\ntemplate <int k1, int k2, int k3, int k4, int k5, int k6, int k7,\n    typename InnerMatcher>\ninline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7>\nArgs(const InnerMatcher& matcher) {\n  return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6,\n      k7>(matcher);\n}\n\ntemplate <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,\n    typename InnerMatcher>\ninline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8>\nArgs(const InnerMatcher& matcher) {\n  return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7,\n      k8>(matcher);\n}\n\ntemplate <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,\n    int k9, typename InnerMatcher>\ninline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9>\nArgs(const InnerMatcher& matcher) {\n  return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,\n      k9>(matcher);\n}\n\ntemplate <int k1, int k2, int k3, int k4, int k5, int k6, int k7, int k8,\n    int k9, int k10, typename InnerMatcher>\ninline internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8, k9,\n    k10>\nArgs(const InnerMatcher& matcher) {\n  return internal::ArgsMatcher<InnerMatcher, k1, k2, k3, k4, k5, k6, k7, k8,\n      k9, k10>(matcher);\n}\n\n// ElementsAre(e_1, e_2, ... e_n) matches an STL-style container with\n// n elements, where the i-th element in the container must\n// match the i-th argument in the list.  Each argument of\n// ElementsAre() can be either a value or a matcher.  We support up to\n// 10 arguments.\n//\n// The use of DecayArray in the implementation allows ElementsAre()\n// to accept string literals, whose type is const char[N], but we\n// want to treat them as const char*.\n//\n// NOTE: Since ElementsAre() cares about the order of the elements, it\n// must not be used with containers whose elements's order is\n// undefined (e.g. hash_map).\n\ninline internal::ElementsAreMatcher<\n    std::tr1::tuple<> >\nElementsAre() {\n  typedef std::tr1::tuple<> Args;\n  return internal::ElementsAreMatcher<Args>(Args());\n}\n\ntemplate <typename T1>\ninline internal::ElementsAreMatcher<\n    std::tr1::tuple<\n        typename internal::DecayArray<T1>::type> >\nElementsAre(const T1& e1) {\n  typedef std::tr1::tuple<\n      typename internal::DecayArray<T1>::type> Args;\n  return internal::ElementsAreMatcher<Args>(Args(e1));\n}\n\ntemplate <typename T1, typename T2>\ninline internal::ElementsAreMatcher<\n    std::tr1::tuple<\n        typename internal::DecayArray<T1>::type,\n        typename internal::DecayArray<T2>::type> >\nElementsAre(const T1& e1, const T2& e2) {\n  typedef std::tr1::tuple<\n      typename internal::DecayArray<T1>::type,\n      typename internal::DecayArray<T2>::type> Args;\n  return internal::ElementsAreMatcher<Args>(Args(e1, e2));\n}\n\ntemplate <typename T1, typename T2, typename T3>\ninline internal::ElementsAreMatcher<\n    std::tr1::tuple<\n        typename internal::DecayArray<T1>::type,\n        typename internal::DecayArray<T2>::type,\n        typename internal::DecayArray<T3>::type> >\nElementsAre(const T1& e1, const T2& e2, const T3& e3) {\n  typedef std::tr1::tuple<\n      typename internal::DecayArray<T1>::type,\n      typename internal::DecayArray<T2>::type,\n      typename internal::DecayArray<T3>::type> Args;\n  return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3));\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4>\ninline internal::ElementsAreMatcher<\n    std::tr1::tuple<\n        typename internal::DecayArray<T1>::type,\n        typename internal::DecayArray<T2>::type,\n        typename internal::DecayArray<T3>::type,\n        typename internal::DecayArray<T4>::type> >\nElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4) {\n  typedef std::tr1::tuple<\n      typename internal::DecayArray<T1>::type,\n      typename internal::DecayArray<T2>::type,\n      typename internal::DecayArray<T3>::type,\n      typename internal::DecayArray<T4>::type> Args;\n  return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4));\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5>\ninline internal::ElementsAreMatcher<\n    std::tr1::tuple<\n        typename internal::DecayArray<T1>::type,\n        typename internal::DecayArray<T2>::type,\n        typename internal::DecayArray<T3>::type,\n        typename internal::DecayArray<T4>::type,\n        typename internal::DecayArray<T5>::type> >\nElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,\n    const T5& e5) {\n  typedef std::tr1::tuple<\n      typename internal::DecayArray<T1>::type,\n      typename internal::DecayArray<T2>::type,\n      typename internal::DecayArray<T3>::type,\n      typename internal::DecayArray<T4>::type,\n      typename internal::DecayArray<T5>::type> Args;\n  return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5));\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6>\ninline internal::ElementsAreMatcher<\n    std::tr1::tuple<\n        typename internal::DecayArray<T1>::type,\n        typename internal::DecayArray<T2>::type,\n        typename internal::DecayArray<T3>::type,\n        typename internal::DecayArray<T4>::type,\n        typename internal::DecayArray<T5>::type,\n        typename internal::DecayArray<T6>::type> >\nElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,\n    const T5& e5, const T6& e6) {\n  typedef std::tr1::tuple<\n      typename internal::DecayArray<T1>::type,\n      typename internal::DecayArray<T2>::type,\n      typename internal::DecayArray<T3>::type,\n      typename internal::DecayArray<T4>::type,\n      typename internal::DecayArray<T5>::type,\n      typename internal::DecayArray<T6>::type> Args;\n  return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6));\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7>\ninline internal::ElementsAreMatcher<\n    std::tr1::tuple<\n        typename internal::DecayArray<T1>::type,\n        typename internal::DecayArray<T2>::type,\n        typename internal::DecayArray<T3>::type,\n        typename internal::DecayArray<T4>::type,\n        typename internal::DecayArray<T5>::type,\n        typename internal::DecayArray<T6>::type,\n        typename internal::DecayArray<T7>::type> >\nElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,\n    const T5& e5, const T6& e6, const T7& e7) {\n  typedef std::tr1::tuple<\n      typename internal::DecayArray<T1>::type,\n      typename internal::DecayArray<T2>::type,\n      typename internal::DecayArray<T3>::type,\n      typename internal::DecayArray<T4>::type,\n      typename internal::DecayArray<T5>::type,\n      typename internal::DecayArray<T6>::type,\n      typename internal::DecayArray<T7>::type> Args;\n  return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7));\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8>\ninline internal::ElementsAreMatcher<\n    std::tr1::tuple<\n        typename internal::DecayArray<T1>::type,\n        typename internal::DecayArray<T2>::type,\n        typename internal::DecayArray<T3>::type,\n        typename internal::DecayArray<T4>::type,\n        typename internal::DecayArray<T5>::type,\n        typename internal::DecayArray<T6>::type,\n        typename internal::DecayArray<T7>::type,\n        typename internal::DecayArray<T8>::type> >\nElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,\n    const T5& e5, const T6& e6, const T7& e7, const T8& e8) {\n  typedef std::tr1::tuple<\n      typename internal::DecayArray<T1>::type,\n      typename internal::DecayArray<T2>::type,\n      typename internal::DecayArray<T3>::type,\n      typename internal::DecayArray<T4>::type,\n      typename internal::DecayArray<T5>::type,\n      typename internal::DecayArray<T6>::type,\n      typename internal::DecayArray<T7>::type,\n      typename internal::DecayArray<T8>::type> Args;\n  return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7,\n      e8));\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9>\ninline internal::ElementsAreMatcher<\n    std::tr1::tuple<\n        typename internal::DecayArray<T1>::type,\n        typename internal::DecayArray<T2>::type,\n        typename internal::DecayArray<T3>::type,\n        typename internal::DecayArray<T4>::type,\n        typename internal::DecayArray<T5>::type,\n        typename internal::DecayArray<T6>::type,\n        typename internal::DecayArray<T7>::type,\n        typename internal::DecayArray<T8>::type,\n        typename internal::DecayArray<T9>::type> >\nElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,\n    const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9) {\n  typedef std::tr1::tuple<\n      typename internal::DecayArray<T1>::type,\n      typename internal::DecayArray<T2>::type,\n      typename internal::DecayArray<T3>::type,\n      typename internal::DecayArray<T4>::type,\n      typename internal::DecayArray<T5>::type,\n      typename internal::DecayArray<T6>::type,\n      typename internal::DecayArray<T7>::type,\n      typename internal::DecayArray<T8>::type,\n      typename internal::DecayArray<T9>::type> Args;\n  return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7,\n      e8, e9));\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10>\ninline internal::ElementsAreMatcher<\n    std::tr1::tuple<\n        typename internal::DecayArray<T1>::type,\n        typename internal::DecayArray<T2>::type,\n        typename internal::DecayArray<T3>::type,\n        typename internal::DecayArray<T4>::type,\n        typename internal::DecayArray<T5>::type,\n        typename internal::DecayArray<T6>::type,\n        typename internal::DecayArray<T7>::type,\n        typename internal::DecayArray<T8>::type,\n        typename internal::DecayArray<T9>::type,\n        typename internal::DecayArray<T10>::type> >\nElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,\n    const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,\n    const T10& e10) {\n  typedef std::tr1::tuple<\n      typename internal::DecayArray<T1>::type,\n      typename internal::DecayArray<T2>::type,\n      typename internal::DecayArray<T3>::type,\n      typename internal::DecayArray<T4>::type,\n      typename internal::DecayArray<T5>::type,\n      typename internal::DecayArray<T6>::type,\n      typename internal::DecayArray<T7>::type,\n      typename internal::DecayArray<T8>::type,\n      typename internal::DecayArray<T9>::type,\n      typename internal::DecayArray<T10>::type> Args;\n  return internal::ElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5, e6, e7,\n      e8, e9, e10));\n}\n\n// UnorderedElementsAre(e_1, e_2, ..., e_n) is an ElementsAre extension\n// that matches n elements in any order.  We support up to n=10 arguments.\n\ninline internal::UnorderedElementsAreMatcher<\n    std::tr1::tuple<> >\nUnorderedElementsAre() {\n  typedef std::tr1::tuple<> Args;\n  return internal::UnorderedElementsAreMatcher<Args>(Args());\n}\n\ntemplate <typename T1>\ninline internal::UnorderedElementsAreMatcher<\n    std::tr1::tuple<\n        typename internal::DecayArray<T1>::type> >\nUnorderedElementsAre(const T1& e1) {\n  typedef std::tr1::tuple<\n      typename internal::DecayArray<T1>::type> Args;\n  return internal::UnorderedElementsAreMatcher<Args>(Args(e1));\n}\n\ntemplate <typename T1, typename T2>\ninline internal::UnorderedElementsAreMatcher<\n    std::tr1::tuple<\n        typename internal::DecayArray<T1>::type,\n        typename internal::DecayArray<T2>::type> >\nUnorderedElementsAre(const T1& e1, const T2& e2) {\n  typedef std::tr1::tuple<\n      typename internal::DecayArray<T1>::type,\n      typename internal::DecayArray<T2>::type> Args;\n  return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2));\n}\n\ntemplate <typename T1, typename T2, typename T3>\ninline internal::UnorderedElementsAreMatcher<\n    std::tr1::tuple<\n        typename internal::DecayArray<T1>::type,\n        typename internal::DecayArray<T2>::type,\n        typename internal::DecayArray<T3>::type> >\nUnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3) {\n  typedef std::tr1::tuple<\n      typename internal::DecayArray<T1>::type,\n      typename internal::DecayArray<T2>::type,\n      typename internal::DecayArray<T3>::type> Args;\n  return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3));\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4>\ninline internal::UnorderedElementsAreMatcher<\n    std::tr1::tuple<\n        typename internal::DecayArray<T1>::type,\n        typename internal::DecayArray<T2>::type,\n        typename internal::DecayArray<T3>::type,\n        typename internal::DecayArray<T4>::type> >\nUnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4) {\n  typedef std::tr1::tuple<\n      typename internal::DecayArray<T1>::type,\n      typename internal::DecayArray<T2>::type,\n      typename internal::DecayArray<T3>::type,\n      typename internal::DecayArray<T4>::type> Args;\n  return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4));\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5>\ninline internal::UnorderedElementsAreMatcher<\n    std::tr1::tuple<\n        typename internal::DecayArray<T1>::type,\n        typename internal::DecayArray<T2>::type,\n        typename internal::DecayArray<T3>::type,\n        typename internal::DecayArray<T4>::type,\n        typename internal::DecayArray<T5>::type> >\nUnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,\n    const T5& e5) {\n  typedef std::tr1::tuple<\n      typename internal::DecayArray<T1>::type,\n      typename internal::DecayArray<T2>::type,\n      typename internal::DecayArray<T3>::type,\n      typename internal::DecayArray<T4>::type,\n      typename internal::DecayArray<T5>::type> Args;\n  return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5));\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6>\ninline internal::UnorderedElementsAreMatcher<\n    std::tr1::tuple<\n        typename internal::DecayArray<T1>::type,\n        typename internal::DecayArray<T2>::type,\n        typename internal::DecayArray<T3>::type,\n        typename internal::DecayArray<T4>::type,\n        typename internal::DecayArray<T5>::type,\n        typename internal::DecayArray<T6>::type> >\nUnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,\n    const T5& e5, const T6& e6) {\n  typedef std::tr1::tuple<\n      typename internal::DecayArray<T1>::type,\n      typename internal::DecayArray<T2>::type,\n      typename internal::DecayArray<T3>::type,\n      typename internal::DecayArray<T4>::type,\n      typename internal::DecayArray<T5>::type,\n      typename internal::DecayArray<T6>::type> Args;\n  return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,\n      e6));\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7>\ninline internal::UnorderedElementsAreMatcher<\n    std::tr1::tuple<\n        typename internal::DecayArray<T1>::type,\n        typename internal::DecayArray<T2>::type,\n        typename internal::DecayArray<T3>::type,\n        typename internal::DecayArray<T4>::type,\n        typename internal::DecayArray<T5>::type,\n        typename internal::DecayArray<T6>::type,\n        typename internal::DecayArray<T7>::type> >\nUnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,\n    const T5& e5, const T6& e6, const T7& e7) {\n  typedef std::tr1::tuple<\n      typename internal::DecayArray<T1>::type,\n      typename internal::DecayArray<T2>::type,\n      typename internal::DecayArray<T3>::type,\n      typename internal::DecayArray<T4>::type,\n      typename internal::DecayArray<T5>::type,\n      typename internal::DecayArray<T6>::type,\n      typename internal::DecayArray<T7>::type> Args;\n  return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,\n      e6, e7));\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8>\ninline internal::UnorderedElementsAreMatcher<\n    std::tr1::tuple<\n        typename internal::DecayArray<T1>::type,\n        typename internal::DecayArray<T2>::type,\n        typename internal::DecayArray<T3>::type,\n        typename internal::DecayArray<T4>::type,\n        typename internal::DecayArray<T5>::type,\n        typename internal::DecayArray<T6>::type,\n        typename internal::DecayArray<T7>::type,\n        typename internal::DecayArray<T8>::type> >\nUnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,\n    const T5& e5, const T6& e6, const T7& e7, const T8& e8) {\n  typedef std::tr1::tuple<\n      typename internal::DecayArray<T1>::type,\n      typename internal::DecayArray<T2>::type,\n      typename internal::DecayArray<T3>::type,\n      typename internal::DecayArray<T4>::type,\n      typename internal::DecayArray<T5>::type,\n      typename internal::DecayArray<T6>::type,\n      typename internal::DecayArray<T7>::type,\n      typename internal::DecayArray<T8>::type> Args;\n  return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,\n      e6, e7, e8));\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9>\ninline internal::UnorderedElementsAreMatcher<\n    std::tr1::tuple<\n        typename internal::DecayArray<T1>::type,\n        typename internal::DecayArray<T2>::type,\n        typename internal::DecayArray<T3>::type,\n        typename internal::DecayArray<T4>::type,\n        typename internal::DecayArray<T5>::type,\n        typename internal::DecayArray<T6>::type,\n        typename internal::DecayArray<T7>::type,\n        typename internal::DecayArray<T8>::type,\n        typename internal::DecayArray<T9>::type> >\nUnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,\n    const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9) {\n  typedef std::tr1::tuple<\n      typename internal::DecayArray<T1>::type,\n      typename internal::DecayArray<T2>::type,\n      typename internal::DecayArray<T3>::type,\n      typename internal::DecayArray<T4>::type,\n      typename internal::DecayArray<T5>::type,\n      typename internal::DecayArray<T6>::type,\n      typename internal::DecayArray<T7>::type,\n      typename internal::DecayArray<T8>::type,\n      typename internal::DecayArray<T9>::type> Args;\n  return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,\n      e6, e7, e8, e9));\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10>\ninline internal::UnorderedElementsAreMatcher<\n    std::tr1::tuple<\n        typename internal::DecayArray<T1>::type,\n        typename internal::DecayArray<T2>::type,\n        typename internal::DecayArray<T3>::type,\n        typename internal::DecayArray<T4>::type,\n        typename internal::DecayArray<T5>::type,\n        typename internal::DecayArray<T6>::type,\n        typename internal::DecayArray<T7>::type,\n        typename internal::DecayArray<T8>::type,\n        typename internal::DecayArray<T9>::type,\n        typename internal::DecayArray<T10>::type> >\nUnorderedElementsAre(const T1& e1, const T2& e2, const T3& e3, const T4& e4,\n    const T5& e5, const T6& e6, const T7& e7, const T8& e8, const T9& e9,\n    const T10& e10) {\n  typedef std::tr1::tuple<\n      typename internal::DecayArray<T1>::type,\n      typename internal::DecayArray<T2>::type,\n      typename internal::DecayArray<T3>::type,\n      typename internal::DecayArray<T4>::type,\n      typename internal::DecayArray<T5>::type,\n      typename internal::DecayArray<T6>::type,\n      typename internal::DecayArray<T7>::type,\n      typename internal::DecayArray<T8>::type,\n      typename internal::DecayArray<T9>::type,\n      typename internal::DecayArray<T10>::type> Args;\n  return internal::UnorderedElementsAreMatcher<Args>(Args(e1, e2, e3, e4, e5,\n      e6, e7, e8, e9, e10));\n}\n\n// AllOf(m1, m2, ..., mk) matches any value that matches all of the given\n// sub-matchers.  AllOf is called fully qualified to prevent ADL from firing.\n\ntemplate <typename M1, typename M2>\ninline typename internal::AllOfResult2<M1, M2>::type\nAllOf(M1 m1, M2 m2) {\n  return typename internal::AllOfResult2<M1, M2>::type(\n      m1,\n      m2);\n}\n\ntemplate <typename M1, typename M2, typename M3>\ninline typename internal::AllOfResult3<M1, M2, M3>::type\nAllOf(M1 m1, M2 m2, M3 m3) {\n  return typename internal::AllOfResult3<M1, M2, M3>::type(\n      m1,\n      ::testing::AllOf(m2, m3));\n}\n\ntemplate <typename M1, typename M2, typename M3, typename M4>\ninline typename internal::AllOfResult4<M1, M2, M3, M4>::type\nAllOf(M1 m1, M2 m2, M3 m3, M4 m4) {\n  return typename internal::AllOfResult4<M1, M2, M3, M4>::type(\n      ::testing::AllOf(m1, m2),\n      ::testing::AllOf(m3, m4));\n}\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5>\ninline typename internal::AllOfResult5<M1, M2, M3, M4, M5>::type\nAllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5) {\n  return typename internal::AllOfResult5<M1, M2, M3, M4, M5>::type(\n      ::testing::AllOf(m1, m2),\n      ::testing::AllOf(m3, m4, m5));\n}\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5,\n    typename M6>\ninline typename internal::AllOfResult6<M1, M2, M3, M4, M5, M6>::type\nAllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6) {\n  return typename internal::AllOfResult6<M1, M2, M3, M4, M5, M6>::type(\n      ::testing::AllOf(m1, m2, m3),\n      ::testing::AllOf(m4, m5, m6));\n}\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5,\n    typename M6, typename M7>\ninline typename internal::AllOfResult7<M1, M2, M3, M4, M5, M6, M7>::type\nAllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7) {\n  return typename internal::AllOfResult7<M1, M2, M3, M4, M5, M6, M7>::type(\n      ::testing::AllOf(m1, m2, m3),\n      ::testing::AllOf(m4, m5, m6, m7));\n}\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5,\n    typename M6, typename M7, typename M8>\ninline typename internal::AllOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type\nAllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8) {\n  return typename internal::AllOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type(\n      ::testing::AllOf(m1, m2, m3, m4),\n      ::testing::AllOf(m5, m6, m7, m8));\n}\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5,\n    typename M6, typename M7, typename M8, typename M9>\ninline typename internal::AllOfResult9<M1, M2, M3, M4, M5, M6, M7, M8, M9>::type\nAllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9) {\n  return typename internal::AllOfResult9<M1, M2, M3, M4, M5, M6, M7, M8,\n      M9>::type(\n      ::testing::AllOf(m1, m2, m3, m4),\n      ::testing::AllOf(m5, m6, m7, m8, m9));\n}\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5,\n    typename M6, typename M7, typename M8, typename M9, typename M10>\ninline typename internal::AllOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,\n    M10>::type\nAllOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {\n  return typename internal::AllOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,\n      M10>::type(\n      ::testing::AllOf(m1, m2, m3, m4, m5),\n      ::testing::AllOf(m6, m7, m8, m9, m10));\n}\n\n// AnyOf(m1, m2, ..., mk) matches any value that matches any of the given\n// sub-matchers.  AnyOf is called fully qualified to prevent ADL from firing.\n\ntemplate <typename M1, typename M2>\ninline typename internal::AnyOfResult2<M1, M2>::type\nAnyOf(M1 m1, M2 m2) {\n  return typename internal::AnyOfResult2<M1, M2>::type(\n      m1,\n      m2);\n}\n\ntemplate <typename M1, typename M2, typename M3>\ninline typename internal::AnyOfResult3<M1, M2, M3>::type\nAnyOf(M1 m1, M2 m2, M3 m3) {\n  return typename internal::AnyOfResult3<M1, M2, M3>::type(\n      m1,\n      ::testing::AnyOf(m2, m3));\n}\n\ntemplate <typename M1, typename M2, typename M3, typename M4>\ninline typename internal::AnyOfResult4<M1, M2, M3, M4>::type\nAnyOf(M1 m1, M2 m2, M3 m3, M4 m4) {\n  return typename internal::AnyOfResult4<M1, M2, M3, M4>::type(\n      ::testing::AnyOf(m1, m2),\n      ::testing::AnyOf(m3, m4));\n}\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5>\ninline typename internal::AnyOfResult5<M1, M2, M3, M4, M5>::type\nAnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5) {\n  return typename internal::AnyOfResult5<M1, M2, M3, M4, M5>::type(\n      ::testing::AnyOf(m1, m2),\n      ::testing::AnyOf(m3, m4, m5));\n}\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5,\n    typename M6>\ninline typename internal::AnyOfResult6<M1, M2, M3, M4, M5, M6>::type\nAnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6) {\n  return typename internal::AnyOfResult6<M1, M2, M3, M4, M5, M6>::type(\n      ::testing::AnyOf(m1, m2, m3),\n      ::testing::AnyOf(m4, m5, m6));\n}\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5,\n    typename M6, typename M7>\ninline typename internal::AnyOfResult7<M1, M2, M3, M4, M5, M6, M7>::type\nAnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7) {\n  return typename internal::AnyOfResult7<M1, M2, M3, M4, M5, M6, M7>::type(\n      ::testing::AnyOf(m1, m2, m3),\n      ::testing::AnyOf(m4, m5, m6, m7));\n}\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5,\n    typename M6, typename M7, typename M8>\ninline typename internal::AnyOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type\nAnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8) {\n  return typename internal::AnyOfResult8<M1, M2, M3, M4, M5, M6, M7, M8>::type(\n      ::testing::AnyOf(m1, m2, m3, m4),\n      ::testing::AnyOf(m5, m6, m7, m8));\n}\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5,\n    typename M6, typename M7, typename M8, typename M9>\ninline typename internal::AnyOfResult9<M1, M2, M3, M4, M5, M6, M7, M8, M9>::type\nAnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9) {\n  return typename internal::AnyOfResult9<M1, M2, M3, M4, M5, M6, M7, M8,\n      M9>::type(\n      ::testing::AnyOf(m1, m2, m3, m4),\n      ::testing::AnyOf(m5, m6, m7, m8, m9));\n}\n\ntemplate <typename M1, typename M2, typename M3, typename M4, typename M5,\n    typename M6, typename M7, typename M8, typename M9, typename M10>\ninline typename internal::AnyOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,\n    M10>::type\nAnyOf(M1 m1, M2 m2, M3 m3, M4 m4, M5 m5, M6 m6, M7 m7, M8 m8, M9 m9, M10 m10) {\n  return typename internal::AnyOfResult10<M1, M2, M3, M4, M5, M6, M7, M8, M9,\n      M10>::type(\n      ::testing::AnyOf(m1, m2, m3, m4, m5),\n      ::testing::AnyOf(m6, m7, m8, m9, m10));\n}\n\n}  // namespace testing\n\n\n// The MATCHER* family of macros can be used in a namespace scope to\n// define custom matchers easily.\n//\n// Basic Usage\n// ===========\n//\n// The syntax\n//\n//   MATCHER(name, description_string) { statements; }\n//\n// defines a matcher with the given name that executes the statements,\n// which must return a bool to indicate if the match succeeds.  Inside\n// the statements, you can refer to the value being matched by 'arg',\n// and refer to its type by 'arg_type'.\n//\n// The description string documents what the matcher does, and is used\n// to generate the failure message when the match fails.  Since a\n// MATCHER() is usually defined in a header file shared by multiple\n// C++ source files, we require the description to be a C-string\n// literal to avoid possible side effects.  It can be empty, in which\n// case we'll use the sequence of words in the matcher name as the\n// description.\n//\n// For example:\n//\n//   MATCHER(IsEven, \"\") { return (arg % 2) == 0; }\n//\n// allows you to write\n//\n//   // Expects mock_foo.Bar(n) to be called where n is even.\n//   EXPECT_CALL(mock_foo, Bar(IsEven()));\n//\n// or,\n//\n//   // Verifies that the value of some_expression is even.\n//   EXPECT_THAT(some_expression, IsEven());\n//\n// If the above assertion fails, it will print something like:\n//\n//   Value of: some_expression\n//   Expected: is even\n//     Actual: 7\n//\n// where the description \"is even\" is automatically calculated from the\n// matcher name IsEven.\n//\n// Argument Type\n// =============\n//\n// Note that the type of the value being matched (arg_type) is\n// determined by the context in which you use the matcher and is\n// supplied to you by the compiler, so you don't need to worry about\n// declaring it (nor can you).  This allows the matcher to be\n// polymorphic.  For example, IsEven() can be used to match any type\n// where the value of \"(arg % 2) == 0\" can be implicitly converted to\n// a bool.  In the \"Bar(IsEven())\" example above, if method Bar()\n// takes an int, 'arg_type' will be int; if it takes an unsigned long,\n// 'arg_type' will be unsigned long; and so on.\n//\n// Parameterizing Matchers\n// =======================\n//\n// Sometimes you'll want to parameterize the matcher.  For that you\n// can use another macro:\n//\n//   MATCHER_P(name, param_name, description_string) { statements; }\n//\n// For example:\n//\n//   MATCHER_P(HasAbsoluteValue, value, \"\") { return abs(arg) == value; }\n//\n// will allow you to write:\n//\n//   EXPECT_THAT(Blah(\"a\"), HasAbsoluteValue(n));\n//\n// which may lead to this message (assuming n is 10):\n//\n//   Value of: Blah(\"a\")\n//   Expected: has absolute value 10\n//     Actual: -9\n//\n// Note that both the matcher description and its parameter are\n// printed, making the message human-friendly.\n//\n// In the matcher definition body, you can write 'foo_type' to\n// reference the type of a parameter named 'foo'.  For example, in the\n// body of MATCHER_P(HasAbsoluteValue, value) above, you can write\n// 'value_type' to refer to the type of 'value'.\n//\n// We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P10 to\n// support multi-parameter matchers.\n//\n// Describing Parameterized Matchers\n// =================================\n//\n// The last argument to MATCHER*() is a string-typed expression.  The\n// expression can reference all of the matcher's parameters and a\n// special bool-typed variable named 'negation'.  When 'negation' is\n// false, the expression should evaluate to the matcher's description;\n// otherwise it should evaluate to the description of the negation of\n// the matcher.  For example,\n//\n//   using testing::PrintToString;\n//\n//   MATCHER_P2(InClosedRange, low, hi,\n//       string(negation ? \"is not\" : \"is\") + \" in range [\" +\n//       PrintToString(low) + \", \" + PrintToString(hi) + \"]\") {\n//     return low <= arg && arg <= hi;\n//   }\n//   ...\n//   EXPECT_THAT(3, InClosedRange(4, 6));\n//   EXPECT_THAT(3, Not(InClosedRange(2, 4)));\n//\n// would generate two failures that contain the text:\n//\n//   Expected: is in range [4, 6]\n//   ...\n//   Expected: is not in range [2, 4]\n//\n// If you specify \"\" as the description, the failure message will\n// contain the sequence of words in the matcher name followed by the\n// parameter values printed as a tuple.  For example,\n//\n//   MATCHER_P2(InClosedRange, low, hi, \"\") { ... }\n//   ...\n//   EXPECT_THAT(3, InClosedRange(4, 6));\n//   EXPECT_THAT(3, Not(InClosedRange(2, 4)));\n//\n// would generate two failures that contain the text:\n//\n//   Expected: in closed range (4, 6)\n//   ...\n//   Expected: not (in closed range (2, 4))\n//\n// Types of Matcher Parameters\n// ===========================\n//\n// For the purpose of typing, you can view\n//\n//   MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... }\n//\n// as shorthand for\n//\n//   template <typename p1_type, ..., typename pk_type>\n//   FooMatcherPk<p1_type, ..., pk_type>\n//   Foo(p1_type p1, ..., pk_type pk) { ... }\n//\n// When you write Foo(v1, ..., vk), the compiler infers the types of\n// the parameters v1, ..., and vk for you.  If you are not happy with\n// the result of the type inference, you can specify the types by\n// explicitly instantiating the template, as in Foo<long, bool>(5,\n// false).  As said earlier, you don't get to (or need to) specify\n// 'arg_type' as that's determined by the context in which the matcher\n// is used.  You can assign the result of expression Foo(p1, ..., pk)\n// to a variable of type FooMatcherPk<p1_type, ..., pk_type>.  This\n// can be useful when composing matchers.\n//\n// While you can instantiate a matcher template with reference types,\n// passing the parameters by pointer usually makes your code more\n// readable.  If, however, you still want to pass a parameter by\n// reference, be aware that in the failure message generated by the\n// matcher you will see the value of the referenced object but not its\n// address.\n//\n// Explaining Match Results\n// ========================\n//\n// Sometimes the matcher description alone isn't enough to explain why\n// the match has failed or succeeded.  For example, when expecting a\n// long string, it can be very helpful to also print the diff between\n// the expected string and the actual one.  To achieve that, you can\n// optionally stream additional information to a special variable\n// named result_listener, whose type is a pointer to class\n// MatchResultListener:\n//\n//   MATCHER_P(EqualsLongString, str, \"\") {\n//     if (arg == str) return true;\n//\n//     *result_listener << \"the difference: \"\n///                     << DiffStrings(str, arg);\n//     return false;\n//   }\n//\n// Overloading Matchers\n// ====================\n//\n// You can overload matchers with different numbers of parameters:\n//\n//   MATCHER_P(Blah, a, description_string1) { ... }\n//   MATCHER_P2(Blah, a, b, description_string2) { ... }\n//\n// Caveats\n// =======\n//\n// When defining a new matcher, you should also consider implementing\n// MatcherInterface or using MakePolymorphicMatcher().  These\n// approaches require more work than the MATCHER* macros, but also\n// give you more control on the types of the value being matched and\n// the matcher parameters, which may leads to better compiler error\n// messages when the matcher is used wrong.  They also allow\n// overloading matchers based on parameter types (as opposed to just\n// based on the number of parameters).\n//\n// MATCHER*() can only be used in a namespace scope.  The reason is\n// that C++ doesn't yet allow function-local types to be used to\n// instantiate templates.  The up-coming C++0x standard will fix this.\n// Once that's done, we'll consider supporting using MATCHER*() inside\n// a function.\n//\n// More Information\n// ================\n//\n// To learn more about using these macros, please search for 'MATCHER'\n// on http://code.google.com/p/googlemock/wiki/CookBook.\n\n#define MATCHER(name, description)\\\n  class name##Matcher {\\\n   public:\\\n    template <typename arg_type>\\\n    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\\\n     public:\\\n      gmock_Impl()\\\n           {}\\\n      virtual bool MatchAndExplain(\\\n          arg_type arg, ::testing::MatchResultListener* result_listener) const;\\\n      virtual void DescribeTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(false);\\\n      }\\\n      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(true);\\\n      }\\\n     private:\\\n      ::testing::internal::string FormatDescription(bool negation) const {\\\n        const ::testing::internal::string gmock_description = (description);\\\n        if (!gmock_description.empty())\\\n          return gmock_description;\\\n        return ::testing::internal::FormatMatcherDescription(\\\n            negation, #name, \\\n            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\\\n                ::std::tr1::tuple<>()));\\\n      }\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename arg_type>\\\n    operator ::testing::Matcher<arg_type>() const {\\\n      return ::testing::Matcher<arg_type>(\\\n          new gmock_Impl<arg_type>());\\\n    }\\\n    name##Matcher() {\\\n    }\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(name##Matcher);\\\n  };\\\n  inline name##Matcher name() {\\\n    return name##Matcher();\\\n  }\\\n  template <typename arg_type>\\\n  bool name##Matcher::gmock_Impl<arg_type>::MatchAndExplain(\\\n      arg_type arg, \\\n      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\\\n          const\n\n#define MATCHER_P(name, p0, description)\\\n  template <typename p0##_type>\\\n  class name##MatcherP {\\\n   public:\\\n    template <typename arg_type>\\\n    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\\\n     public:\\\n      explicit gmock_Impl(p0##_type gmock_p0)\\\n           : p0(gmock_p0) {}\\\n      virtual bool MatchAndExplain(\\\n          arg_type arg, ::testing::MatchResultListener* result_listener) const;\\\n      virtual void DescribeTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(false);\\\n      }\\\n      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(true);\\\n      }\\\n      p0##_type p0;\\\n     private:\\\n      ::testing::internal::string FormatDescription(bool negation) const {\\\n        const ::testing::internal::string gmock_description = (description);\\\n        if (!gmock_description.empty())\\\n          return gmock_description;\\\n        return ::testing::internal::FormatMatcherDescription(\\\n            negation, #name, \\\n            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\\\n                ::std::tr1::tuple<p0##_type>(p0)));\\\n      }\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename arg_type>\\\n    operator ::testing::Matcher<arg_type>() const {\\\n      return ::testing::Matcher<arg_type>(\\\n          new gmock_Impl<arg_type>(p0));\\\n    }\\\n    name##MatcherP(p0##_type gmock_p0) : p0(gmock_p0) {\\\n    }\\\n    p0##_type p0;\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(name##MatcherP);\\\n  };\\\n  template <typename p0##_type>\\\n  inline name##MatcherP<p0##_type> name(p0##_type p0) {\\\n    return name##MatcherP<p0##_type>(p0);\\\n  }\\\n  template <typename p0##_type>\\\n  template <typename arg_type>\\\n  bool name##MatcherP<p0##_type>::gmock_Impl<arg_type>::MatchAndExplain(\\\n      arg_type arg, \\\n      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\\\n          const\n\n#define MATCHER_P2(name, p0, p1, description)\\\n  template <typename p0##_type, typename p1##_type>\\\n  class name##MatcherP2 {\\\n   public:\\\n    template <typename arg_type>\\\n    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\\\n     public:\\\n      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1)\\\n           : p0(gmock_p0), p1(gmock_p1) {}\\\n      virtual bool MatchAndExplain(\\\n          arg_type arg, ::testing::MatchResultListener* result_listener) const;\\\n      virtual void DescribeTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(false);\\\n      }\\\n      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(true);\\\n      }\\\n      p0##_type p0;\\\n      p1##_type p1;\\\n     private:\\\n      ::testing::internal::string FormatDescription(bool negation) const {\\\n        const ::testing::internal::string gmock_description = (description);\\\n        if (!gmock_description.empty())\\\n          return gmock_description;\\\n        return ::testing::internal::FormatMatcherDescription(\\\n            negation, #name, \\\n            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\\\n                ::std::tr1::tuple<p0##_type, p1##_type>(p0, p1)));\\\n      }\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename arg_type>\\\n    operator ::testing::Matcher<arg_type>() const {\\\n      return ::testing::Matcher<arg_type>(\\\n          new gmock_Impl<arg_type>(p0, p1));\\\n    }\\\n    name##MatcherP2(p0##_type gmock_p0, p1##_type gmock_p1) : p0(gmock_p0), \\\n        p1(gmock_p1) {\\\n    }\\\n    p0##_type p0;\\\n    p1##_type p1;\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(name##MatcherP2);\\\n  };\\\n  template <typename p0##_type, typename p1##_type>\\\n  inline name##MatcherP2<p0##_type, p1##_type> name(p0##_type p0, \\\n      p1##_type p1) {\\\n    return name##MatcherP2<p0##_type, p1##_type>(p0, p1);\\\n  }\\\n  template <typename p0##_type, typename p1##_type>\\\n  template <typename arg_type>\\\n  bool name##MatcherP2<p0##_type, \\\n      p1##_type>::gmock_Impl<arg_type>::MatchAndExplain(\\\n      arg_type arg, \\\n      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\\\n          const\n\n#define MATCHER_P3(name, p0, p1, p2, description)\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type>\\\n  class name##MatcherP3 {\\\n   public:\\\n    template <typename arg_type>\\\n    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\\\n     public:\\\n      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2)\\\n           : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {}\\\n      virtual bool MatchAndExplain(\\\n          arg_type arg, ::testing::MatchResultListener* result_listener) const;\\\n      virtual void DescribeTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(false);\\\n      }\\\n      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(true);\\\n      }\\\n      p0##_type p0;\\\n      p1##_type p1;\\\n      p2##_type p2;\\\n     private:\\\n      ::testing::internal::string FormatDescription(bool negation) const {\\\n        const ::testing::internal::string gmock_description = (description);\\\n        if (!gmock_description.empty())\\\n          return gmock_description;\\\n        return ::testing::internal::FormatMatcherDescription(\\\n            negation, #name, \\\n            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\\\n                ::std::tr1::tuple<p0##_type, p1##_type, p2##_type>(p0, p1, \\\n                    p2)));\\\n      }\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename arg_type>\\\n    operator ::testing::Matcher<arg_type>() const {\\\n      return ::testing::Matcher<arg_type>(\\\n          new gmock_Impl<arg_type>(p0, p1, p2));\\\n    }\\\n    name##MatcherP3(p0##_type gmock_p0, p1##_type gmock_p1, \\\n        p2##_type gmock_p2) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2) {\\\n    }\\\n    p0##_type p0;\\\n    p1##_type p1;\\\n    p2##_type p2;\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(name##MatcherP3);\\\n  };\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type>\\\n  inline name##MatcherP3<p0##_type, p1##_type, p2##_type> name(p0##_type p0, \\\n      p1##_type p1, p2##_type p2) {\\\n    return name##MatcherP3<p0##_type, p1##_type, p2##_type>(p0, p1, p2);\\\n  }\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type>\\\n  template <typename arg_type>\\\n  bool name##MatcherP3<p0##_type, p1##_type, \\\n      p2##_type>::gmock_Impl<arg_type>::MatchAndExplain(\\\n      arg_type arg, \\\n      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\\\n          const\n\n#define MATCHER_P4(name, p0, p1, p2, p3, description)\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type>\\\n  class name##MatcherP4 {\\\n   public:\\\n    template <typename arg_type>\\\n    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\\\n     public:\\\n      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n          p3##_type gmock_p3)\\\n           : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3) {}\\\n      virtual bool MatchAndExplain(\\\n          arg_type arg, ::testing::MatchResultListener* result_listener) const;\\\n      virtual void DescribeTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(false);\\\n      }\\\n      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(true);\\\n      }\\\n      p0##_type p0;\\\n      p1##_type p1;\\\n      p2##_type p2;\\\n      p3##_type p3;\\\n     private:\\\n      ::testing::internal::string FormatDescription(bool negation) const {\\\n        const ::testing::internal::string gmock_description = (description);\\\n        if (!gmock_description.empty())\\\n          return gmock_description;\\\n        return ::testing::internal::FormatMatcherDescription(\\\n            negation, #name, \\\n            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\\\n                ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, \\\n                    p3##_type>(p0, p1, p2, p3)));\\\n      }\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename arg_type>\\\n    operator ::testing::Matcher<arg_type>() const {\\\n      return ::testing::Matcher<arg_type>(\\\n          new gmock_Impl<arg_type>(p0, p1, p2, p3));\\\n    }\\\n    name##MatcherP4(p0##_type gmock_p0, p1##_type gmock_p1, \\\n        p2##_type gmock_p2, p3##_type gmock_p3) : p0(gmock_p0), p1(gmock_p1), \\\n        p2(gmock_p2), p3(gmock_p3) {\\\n    }\\\n    p0##_type p0;\\\n    p1##_type p1;\\\n    p2##_type p2;\\\n    p3##_type p3;\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(name##MatcherP4);\\\n  };\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type>\\\n  inline name##MatcherP4<p0##_type, p1##_type, p2##_type, \\\n      p3##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \\\n      p3##_type p3) {\\\n    return name##MatcherP4<p0##_type, p1##_type, p2##_type, p3##_type>(p0, \\\n        p1, p2, p3);\\\n  }\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type>\\\n  template <typename arg_type>\\\n  bool name##MatcherP4<p0##_type, p1##_type, p2##_type, \\\n      p3##_type>::gmock_Impl<arg_type>::MatchAndExplain(\\\n      arg_type arg, \\\n      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\\\n          const\n\n#define MATCHER_P5(name, p0, p1, p2, p3, p4, description)\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type>\\\n  class name##MatcherP5 {\\\n   public:\\\n    template <typename arg_type>\\\n    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\\\n     public:\\\n      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n          p3##_type gmock_p3, p4##_type gmock_p4)\\\n           : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \\\n               p4(gmock_p4) {}\\\n      virtual bool MatchAndExplain(\\\n          arg_type arg, ::testing::MatchResultListener* result_listener) const;\\\n      virtual void DescribeTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(false);\\\n      }\\\n      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(true);\\\n      }\\\n      p0##_type p0;\\\n      p1##_type p1;\\\n      p2##_type p2;\\\n      p3##_type p3;\\\n      p4##_type p4;\\\n     private:\\\n      ::testing::internal::string FormatDescription(bool negation) const {\\\n        const ::testing::internal::string gmock_description = (description);\\\n        if (!gmock_description.empty())\\\n          return gmock_description;\\\n        return ::testing::internal::FormatMatcherDescription(\\\n            negation, #name, \\\n            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\\\n                ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \\\n                    p4##_type>(p0, p1, p2, p3, p4)));\\\n      }\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename arg_type>\\\n    operator ::testing::Matcher<arg_type>() const {\\\n      return ::testing::Matcher<arg_type>(\\\n          new gmock_Impl<arg_type>(p0, p1, p2, p3, p4));\\\n    }\\\n    name##MatcherP5(p0##_type gmock_p0, p1##_type gmock_p1, \\\n        p2##_type gmock_p2, p3##_type gmock_p3, \\\n        p4##_type gmock_p4) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \\\n        p3(gmock_p3), p4(gmock_p4) {\\\n    }\\\n    p0##_type p0;\\\n    p1##_type p1;\\\n    p2##_type p2;\\\n    p3##_type p3;\\\n    p4##_type p4;\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(name##MatcherP5);\\\n  };\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type>\\\n  inline name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \\\n      p4##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \\\n      p4##_type p4) {\\\n    return name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \\\n        p4##_type>(p0, p1, p2, p3, p4);\\\n  }\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type>\\\n  template <typename arg_type>\\\n  bool name##MatcherP5<p0##_type, p1##_type, p2##_type, p3##_type, \\\n      p4##_type>::gmock_Impl<arg_type>::MatchAndExplain(\\\n      arg_type arg, \\\n      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\\\n          const\n\n#define MATCHER_P6(name, p0, p1, p2, p3, p4, p5, description)\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type>\\\n  class name##MatcherP6 {\\\n   public:\\\n    template <typename arg_type>\\\n    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\\\n     public:\\\n      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n          p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5)\\\n           : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \\\n               p4(gmock_p4), p5(gmock_p5) {}\\\n      virtual bool MatchAndExplain(\\\n          arg_type arg, ::testing::MatchResultListener* result_listener) const;\\\n      virtual void DescribeTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(false);\\\n      }\\\n      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(true);\\\n      }\\\n      p0##_type p0;\\\n      p1##_type p1;\\\n      p2##_type p2;\\\n      p3##_type p3;\\\n      p4##_type p4;\\\n      p5##_type p5;\\\n     private:\\\n      ::testing::internal::string FormatDescription(bool negation) const {\\\n        const ::testing::internal::string gmock_description = (description);\\\n        if (!gmock_description.empty())\\\n          return gmock_description;\\\n        return ::testing::internal::FormatMatcherDescription(\\\n            negation, #name, \\\n            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\\\n                ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \\\n                    p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5)));\\\n      }\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename arg_type>\\\n    operator ::testing::Matcher<arg_type>() const {\\\n      return ::testing::Matcher<arg_type>(\\\n          new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5));\\\n    }\\\n    name##MatcherP6(p0##_type gmock_p0, p1##_type gmock_p1, \\\n        p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \\\n        p5##_type gmock_p5) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \\\n        p3(gmock_p3), p4(gmock_p4), p5(gmock_p5) {\\\n    }\\\n    p0##_type p0;\\\n    p1##_type p1;\\\n    p2##_type p2;\\\n    p3##_type p3;\\\n    p4##_type p4;\\\n    p5##_type p5;\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(name##MatcherP6);\\\n  };\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type>\\\n  inline name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \\\n      p4##_type, p5##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, \\\n      p3##_type p3, p4##_type p4, p5##_type p5) {\\\n    return name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, \\\n        p4##_type, p5##_type>(p0, p1, p2, p3, p4, p5);\\\n  }\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type>\\\n  template <typename arg_type>\\\n  bool name##MatcherP6<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \\\n      p5##_type>::gmock_Impl<arg_type>::MatchAndExplain(\\\n      arg_type arg, \\\n      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\\\n          const\n\n#define MATCHER_P7(name, p0, p1, p2, p3, p4, p5, p6, description)\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type>\\\n  class name##MatcherP7 {\\\n   public:\\\n    template <typename arg_type>\\\n    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\\\n     public:\\\n      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n          p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \\\n          p6##_type gmock_p6)\\\n           : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \\\n               p4(gmock_p4), p5(gmock_p5), p6(gmock_p6) {}\\\n      virtual bool MatchAndExplain(\\\n          arg_type arg, ::testing::MatchResultListener* result_listener) const;\\\n      virtual void DescribeTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(false);\\\n      }\\\n      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(true);\\\n      }\\\n      p0##_type p0;\\\n      p1##_type p1;\\\n      p2##_type p2;\\\n      p3##_type p3;\\\n      p4##_type p4;\\\n      p5##_type p5;\\\n      p6##_type p6;\\\n     private:\\\n      ::testing::internal::string FormatDescription(bool negation) const {\\\n        const ::testing::internal::string gmock_description = (description);\\\n        if (!gmock_description.empty())\\\n          return gmock_description;\\\n        return ::testing::internal::FormatMatcherDescription(\\\n            negation, #name, \\\n            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\\\n                ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \\\n                    p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, \\\n                    p6)));\\\n      }\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename arg_type>\\\n    operator ::testing::Matcher<arg_type>() const {\\\n      return ::testing::Matcher<arg_type>(\\\n          new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6));\\\n    }\\\n    name##MatcherP7(p0##_type gmock_p0, p1##_type gmock_p1, \\\n        p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \\\n        p5##_type gmock_p5, p6##_type gmock_p6) : p0(gmock_p0), p1(gmock_p1), \\\n        p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), \\\n        p6(gmock_p6) {\\\n    }\\\n    p0##_type p0;\\\n    p1##_type p1;\\\n    p2##_type p2;\\\n    p3##_type p3;\\\n    p4##_type p4;\\\n    p5##_type p5;\\\n    p6##_type p6;\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(name##MatcherP7);\\\n  };\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type>\\\n  inline name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \\\n      p4##_type, p5##_type, p6##_type> name(p0##_type p0, p1##_type p1, \\\n      p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \\\n      p6##_type p6) {\\\n    return name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, \\\n        p4##_type, p5##_type, p6##_type>(p0, p1, p2, p3, p4, p5, p6);\\\n  }\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type>\\\n  template <typename arg_type>\\\n  bool name##MatcherP7<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \\\n      p5##_type, p6##_type>::gmock_Impl<arg_type>::MatchAndExplain(\\\n      arg_type arg, \\\n      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\\\n          const\n\n#define MATCHER_P8(name, p0, p1, p2, p3, p4, p5, p6, p7, description)\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type, typename p7##_type>\\\n  class name##MatcherP8 {\\\n   public:\\\n    template <typename arg_type>\\\n    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\\\n     public:\\\n      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n          p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \\\n          p6##_type gmock_p6, p7##_type gmock_p7)\\\n           : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \\\n               p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7) {}\\\n      virtual bool MatchAndExplain(\\\n          arg_type arg, ::testing::MatchResultListener* result_listener) const;\\\n      virtual void DescribeTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(false);\\\n      }\\\n      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(true);\\\n      }\\\n      p0##_type p0;\\\n      p1##_type p1;\\\n      p2##_type p2;\\\n      p3##_type p3;\\\n      p4##_type p4;\\\n      p5##_type p5;\\\n      p6##_type p6;\\\n      p7##_type p7;\\\n     private:\\\n      ::testing::internal::string FormatDescription(bool negation) const {\\\n        const ::testing::internal::string gmock_description = (description);\\\n        if (!gmock_description.empty())\\\n          return gmock_description;\\\n        return ::testing::internal::FormatMatcherDescription(\\\n            negation, #name, \\\n            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\\\n                ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \\\n                    p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, \\\n                    p3, p4, p5, p6, p7)));\\\n      }\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename arg_type>\\\n    operator ::testing::Matcher<arg_type>() const {\\\n      return ::testing::Matcher<arg_type>(\\\n          new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7));\\\n    }\\\n    name##MatcherP8(p0##_type gmock_p0, p1##_type gmock_p1, \\\n        p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \\\n        p5##_type gmock_p5, p6##_type gmock_p6, \\\n        p7##_type gmock_p7) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \\\n        p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \\\n        p7(gmock_p7) {\\\n    }\\\n    p0##_type p0;\\\n    p1##_type p1;\\\n    p2##_type p2;\\\n    p3##_type p3;\\\n    p4##_type p4;\\\n    p5##_type p5;\\\n    p6##_type p6;\\\n    p7##_type p7;\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(name##MatcherP8);\\\n  };\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type, typename p7##_type>\\\n  inline name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \\\n      p4##_type, p5##_type, p6##_type, p7##_type> name(p0##_type p0, \\\n      p1##_type p1, p2##_type p2, p3##_type p3, p4##_type p4, p5##_type p5, \\\n      p6##_type p6, p7##_type p7) {\\\n    return name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, \\\n        p4##_type, p5##_type, p6##_type, p7##_type>(p0, p1, p2, p3, p4, p5, \\\n        p6, p7);\\\n  }\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type, typename p7##_type>\\\n  template <typename arg_type>\\\n  bool name##MatcherP8<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \\\n      p5##_type, p6##_type, \\\n      p7##_type>::gmock_Impl<arg_type>::MatchAndExplain(\\\n      arg_type arg, \\\n      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\\\n          const\n\n#define MATCHER_P9(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, description)\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type, typename p7##_type, typename p8##_type>\\\n  class name##MatcherP9 {\\\n   public:\\\n    template <typename arg_type>\\\n    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\\\n     public:\\\n      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n          p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \\\n          p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8)\\\n           : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \\\n               p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \\\n               p8(gmock_p8) {}\\\n      virtual bool MatchAndExplain(\\\n          arg_type arg, ::testing::MatchResultListener* result_listener) const;\\\n      virtual void DescribeTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(false);\\\n      }\\\n      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(true);\\\n      }\\\n      p0##_type p0;\\\n      p1##_type p1;\\\n      p2##_type p2;\\\n      p3##_type p3;\\\n      p4##_type p4;\\\n      p5##_type p5;\\\n      p6##_type p6;\\\n      p7##_type p7;\\\n      p8##_type p8;\\\n     private:\\\n      ::testing::internal::string FormatDescription(bool negation) const {\\\n        const ::testing::internal::string gmock_description = (description);\\\n        if (!gmock_description.empty())\\\n          return gmock_description;\\\n        return ::testing::internal::FormatMatcherDescription(\\\n            negation, #name, \\\n            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\\\n                ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \\\n                    p4##_type, p5##_type, p6##_type, p7##_type, \\\n                    p8##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8)));\\\n      }\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename arg_type>\\\n    operator ::testing::Matcher<arg_type>() const {\\\n      return ::testing::Matcher<arg_type>(\\\n          new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8));\\\n    }\\\n    name##MatcherP9(p0##_type gmock_p0, p1##_type gmock_p1, \\\n        p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \\\n        p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \\\n        p8##_type gmock_p8) : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), \\\n        p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \\\n        p8(gmock_p8) {\\\n    }\\\n    p0##_type p0;\\\n    p1##_type p1;\\\n    p2##_type p2;\\\n    p3##_type p3;\\\n    p4##_type p4;\\\n    p5##_type p5;\\\n    p6##_type p6;\\\n    p7##_type p7;\\\n    p8##_type p8;\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(name##MatcherP9);\\\n  };\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type, typename p7##_type, typename p8##_type>\\\n  inline name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \\\n      p4##_type, p5##_type, p6##_type, p7##_type, \\\n      p8##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \\\n      p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, \\\n      p8##_type p8) {\\\n    return name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, \\\n        p4##_type, p5##_type, p6##_type, p7##_type, p8##_type>(p0, p1, p2, \\\n        p3, p4, p5, p6, p7, p8);\\\n  }\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type, typename p7##_type, typename p8##_type>\\\n  template <typename arg_type>\\\n  bool name##MatcherP9<p0##_type, p1##_type, p2##_type, p3##_type, p4##_type, \\\n      p5##_type, p6##_type, p7##_type, \\\n      p8##_type>::gmock_Impl<arg_type>::MatchAndExplain(\\\n      arg_type arg, \\\n      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\\\n          const\n\n#define MATCHER_P10(name, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, description)\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type, typename p7##_type, typename p8##_type, \\\n      typename p9##_type>\\\n  class name##MatcherP10 {\\\n   public:\\\n    template <typename arg_type>\\\n    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\\\n     public:\\\n      gmock_Impl(p0##_type gmock_p0, p1##_type gmock_p1, p2##_type gmock_p2, \\\n          p3##_type gmock_p3, p4##_type gmock_p4, p5##_type gmock_p5, \\\n          p6##_type gmock_p6, p7##_type gmock_p7, p8##_type gmock_p8, \\\n          p9##_type gmock_p9)\\\n           : p0(gmock_p0), p1(gmock_p1), p2(gmock_p2), p3(gmock_p3), \\\n               p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), p7(gmock_p7), \\\n               p8(gmock_p8), p9(gmock_p9) {}\\\n      virtual bool MatchAndExplain(\\\n          arg_type arg, ::testing::MatchResultListener* result_listener) const;\\\n      virtual void DescribeTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(false);\\\n      }\\\n      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(true);\\\n      }\\\n      p0##_type p0;\\\n      p1##_type p1;\\\n      p2##_type p2;\\\n      p3##_type p3;\\\n      p4##_type p4;\\\n      p5##_type p5;\\\n      p6##_type p6;\\\n      p7##_type p7;\\\n      p8##_type p8;\\\n      p9##_type p9;\\\n     private:\\\n      ::testing::internal::string FormatDescription(bool negation) const {\\\n        const ::testing::internal::string gmock_description = (description);\\\n        if (!gmock_description.empty())\\\n          return gmock_description;\\\n        return ::testing::internal::FormatMatcherDescription(\\\n            negation, #name, \\\n            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\\\n                ::std::tr1::tuple<p0##_type, p1##_type, p2##_type, p3##_type, \\\n                    p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \\\n                    p9##_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9)));\\\n      }\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename arg_type>\\\n    operator ::testing::Matcher<arg_type>() const {\\\n      return ::testing::Matcher<arg_type>(\\\n          new gmock_Impl<arg_type>(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9));\\\n    }\\\n    name##MatcherP10(p0##_type gmock_p0, p1##_type gmock_p1, \\\n        p2##_type gmock_p2, p3##_type gmock_p3, p4##_type gmock_p4, \\\n        p5##_type gmock_p5, p6##_type gmock_p6, p7##_type gmock_p7, \\\n        p8##_type gmock_p8, p9##_type gmock_p9) : p0(gmock_p0), p1(gmock_p1), \\\n        p2(gmock_p2), p3(gmock_p3), p4(gmock_p4), p5(gmock_p5), p6(gmock_p6), \\\n        p7(gmock_p7), p8(gmock_p8), p9(gmock_p9) {\\\n    }\\\n    p0##_type p0;\\\n    p1##_type p1;\\\n    p2##_type p2;\\\n    p3##_type p3;\\\n    p4##_type p4;\\\n    p5##_type p5;\\\n    p6##_type p6;\\\n    p7##_type p7;\\\n    p8##_type p8;\\\n    p9##_type p9;\\\n   private:\\\n    GTEST_DISALLOW_ASSIGN_(name##MatcherP10);\\\n  };\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type, typename p7##_type, typename p8##_type, \\\n      typename p9##_type>\\\n  inline name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \\\n      p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \\\n      p9##_type> name(p0##_type p0, p1##_type p1, p2##_type p2, p3##_type p3, \\\n      p4##_type p4, p5##_type p5, p6##_type p6, p7##_type p7, p8##_type p8, \\\n      p9##_type p9) {\\\n    return name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \\\n        p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, p9##_type>(p0, \\\n        p1, p2, p3, p4, p5, p6, p7, p8, p9);\\\n  }\\\n  template <typename p0##_type, typename p1##_type, typename p2##_type, \\\n      typename p3##_type, typename p4##_type, typename p5##_type, \\\n      typename p6##_type, typename p7##_type, typename p8##_type, \\\n      typename p9##_type>\\\n  template <typename arg_type>\\\n  bool name##MatcherP10<p0##_type, p1##_type, p2##_type, p3##_type, \\\n      p4##_type, p5##_type, p6##_type, p7##_type, p8##_type, \\\n      p9##_type>::gmock_Impl<arg_type>::MatchAndExplain(\\\n      arg_type arg, \\\n      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\\\n          const\n\n#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_\n"
  },
  {
    "path": "ext/gmock/include/gmock/gmock-generated-matchers.h.pump",
    "content": "$$ -*- mode: c++; -*-\n$$ This is a Pump source file.  Please use Pump to convert it to\n$$ gmock-generated-actions.h.\n$$\n$var n = 10  $$ The maximum arity we support.\n$$ }} This line fixes auto-indentation of the following code in Emacs.\n// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements some commonly used variadic matchers.\n\n#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_\n#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_\n\n#include <iterator>\n#include <sstream>\n#include <string>\n#include <vector>\n#include \"gmock/gmock-matchers.h\"\n\nnamespace testing {\nnamespace internal {\n\n$range i 0..n-1\n\n// The type of the i-th (0-based) field of Tuple.\n#define GMOCK_FIELD_TYPE_(Tuple, i) \\\n    typename ::std::tr1::tuple_element<i, Tuple>::type\n\n// TupleFields<Tuple, k0, ..., kn> is for selecting fields from a\n// tuple of type Tuple.  It has two members:\n//\n//   type: a tuple type whose i-th field is the ki-th field of Tuple.\n//   GetSelectedFields(t): returns fields k0, ..., and kn of t as a tuple.\n//\n// For example, in class TupleFields<tuple<bool, char, int>, 2, 0>, we have:\n//\n//   type is tuple<int, bool>, and\n//   GetSelectedFields(make_tuple(true, 'a', 42)) is (42, true).\n\ntemplate <class Tuple$for i [[, int k$i = -1]]>\nclass TupleFields;\n\n// This generic version is used when there are $n selectors.\ntemplate <class Tuple$for i [[, int k$i]]>\nclass TupleFields {\n public:\n  typedef ::std::tr1::tuple<$for i, [[GMOCK_FIELD_TYPE_(Tuple, k$i)]]> type;\n  static type GetSelectedFields(const Tuple& t) {\n    using ::std::tr1::get;\n    return type($for i, [[get<k$i>(t)]]);\n  }\n};\n\n// The following specialization is used for 0 ~ $(n-1) selectors.\n\n$for i [[\n$$ }}}\n$range j 0..i-1\n$range k 0..n-1\n\ntemplate <class Tuple$for j [[, int k$j]]>\nclass TupleFields<Tuple, $for k, [[$if k < i [[k$k]] $else [[-1]]]]> {\n public:\n  typedef ::std::tr1::tuple<$for j, [[GMOCK_FIELD_TYPE_(Tuple, k$j)]]> type;\n  static type GetSelectedFields(const Tuple& $if i==0 [[/* t */]] $else [[t]]) {\n    using ::std::tr1::get;\n    return type($for j, [[get<k$j>(t)]]);\n  }\n};\n\n]]\n\n#undef GMOCK_FIELD_TYPE_\n\n// Implements the Args() matcher.\n\n$var ks = [[$for i, [[k$i]]]]\ntemplate <class ArgsTuple$for i [[, int k$i = -1]]>\nclass ArgsMatcherImpl : public MatcherInterface<ArgsTuple> {\n public:\n  // ArgsTuple may have top-level const or reference modifiers.\n  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(ArgsTuple) RawArgsTuple;\n  typedef typename internal::TupleFields<RawArgsTuple, $ks>::type SelectedArgs;\n  typedef Matcher<const SelectedArgs&> MonomorphicInnerMatcher;\n\n  template <typename InnerMatcher>\n  explicit ArgsMatcherImpl(const InnerMatcher& inner_matcher)\n      : inner_matcher_(SafeMatcherCast<const SelectedArgs&>(inner_matcher)) {}\n\n  virtual bool MatchAndExplain(ArgsTuple args,\n                               MatchResultListener* listener) const {\n    const SelectedArgs& selected_args = GetSelectedArgs(args);\n    if (!listener->IsInterested())\n      return inner_matcher_.Matches(selected_args);\n\n    PrintIndices(listener->stream());\n    *listener << \"are \" << PrintToString(selected_args);\n\n    StringMatchResultListener inner_listener;\n    const bool match = inner_matcher_.MatchAndExplain(selected_args,\n                                                      &inner_listener);\n    PrintIfNotEmpty(inner_listener.str(), listener->stream());\n    return match;\n  }\n\n  virtual void DescribeTo(::std::ostream* os) const {\n    *os << \"are a tuple \";\n    PrintIndices(os);\n    inner_matcher_.DescribeTo(os);\n  }\n\n  virtual void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"are a tuple \";\n    PrintIndices(os);\n    inner_matcher_.DescribeNegationTo(os);\n  }\n\n private:\n  static SelectedArgs GetSelectedArgs(ArgsTuple args) {\n    return TupleFields<RawArgsTuple, $ks>::GetSelectedFields(args);\n  }\n\n  // Prints the indices of the selected fields.\n  static void PrintIndices(::std::ostream* os) {\n    *os << \"whose fields (\";\n    const int indices[$n] = { $ks };\n    for (int i = 0; i < $n; i++) {\n      if (indices[i] < 0)\n        break;\n\n      if (i >= 1)\n        *os << \", \";\n\n      *os << \"#\" << indices[i];\n    }\n    *os << \") \";\n  }\n\n  const MonomorphicInnerMatcher inner_matcher_;\n\n  GTEST_DISALLOW_ASSIGN_(ArgsMatcherImpl);\n};\n\ntemplate <class InnerMatcher$for i [[, int k$i = -1]]>\nclass ArgsMatcher {\n public:\n  explicit ArgsMatcher(const InnerMatcher& inner_matcher)\n      : inner_matcher_(inner_matcher) {}\n\n  template <typename ArgsTuple>\n  operator Matcher<ArgsTuple>() const {\n    return MakeMatcher(new ArgsMatcherImpl<ArgsTuple, $ks>(inner_matcher_));\n  }\n\n private:\n  const InnerMatcher inner_matcher_;\n\n  GTEST_DISALLOW_ASSIGN_(ArgsMatcher);\n};\n\n// A set of metafunctions for computing the result type of AllOf.\n// AllOf(m1, ..., mN) returns\n// AllOfResultN<decltype(m1), ..., decltype(mN)>::type.\n\n// Although AllOf isn't defined for one argument, AllOfResult1 is defined\n// to simplify the implementation.\ntemplate <typename M1>\nstruct AllOfResult1 {\n  typedef M1 type;\n};\n\n$range i 1..n\n\n$range i 2..n\n$for i [[\n$range j 2..i\n$var m = i/2\n$range k 1..m\n$range t m+1..i\n\ntemplate <typename M1$for j [[, typename M$j]]>\nstruct AllOfResult$i {\n  typedef BothOfMatcher<\n      typename AllOfResult$m<$for k, [[M$k]]>::type,\n      typename AllOfResult$(i-m)<$for t, [[M$t]]>::type\n  > type;\n};\n\n]]\n\n// A set of metafunctions for computing the result type of AnyOf.\n// AnyOf(m1, ..., mN) returns\n// AnyOfResultN<decltype(m1), ..., decltype(mN)>::type.\n\n// Although AnyOf isn't defined for one argument, AnyOfResult1 is defined\n// to simplify the implementation.\ntemplate <typename M1>\nstruct AnyOfResult1 {\n  typedef M1 type;\n};\n\n$range i 1..n\n\n$range i 2..n\n$for i [[\n$range j 2..i\n$var m = i/2\n$range k 1..m\n$range t m+1..i\n\ntemplate <typename M1$for j [[, typename M$j]]>\nstruct AnyOfResult$i {\n  typedef EitherOfMatcher<\n      typename AnyOfResult$m<$for k, [[M$k]]>::type,\n      typename AnyOfResult$(i-m)<$for t, [[M$t]]>::type\n  > type;\n};\n\n]]\n\n}  // namespace internal\n\n// Args<N1, N2, ..., Nk>(a_matcher) matches a tuple if the selected\n// fields of it matches a_matcher.  C++ doesn't support default\n// arguments for function templates, so we have to overload it.\n\n$range i 0..n\n$for i [[\n$range j 1..i\ntemplate <$for j [[int k$j, ]]typename InnerMatcher>\ninline internal::ArgsMatcher<InnerMatcher$for j [[, k$j]]>\nArgs(const InnerMatcher& matcher) {\n  return internal::ArgsMatcher<InnerMatcher$for j [[, k$j]]>(matcher);\n}\n\n\n]]\n// ElementsAre(e_1, e_2, ... e_n) matches an STL-style container with\n// n elements, where the i-th element in the container must\n// match the i-th argument in the list.  Each argument of\n// ElementsAre() can be either a value or a matcher.  We support up to\n// $n arguments.\n//\n// The use of DecayArray in the implementation allows ElementsAre()\n// to accept string literals, whose type is const char[N], but we\n// want to treat them as const char*.\n//\n// NOTE: Since ElementsAre() cares about the order of the elements, it\n// must not be used with containers whose elements's order is\n// undefined (e.g. hash_map).\n\n$range i 0..n\n$for i [[\n\n$range j 1..i\n\n$if i>0 [[\n\ntemplate <$for j, [[typename T$j]]>\n]]\n\ninline internal::ElementsAreMatcher<\n    std::tr1::tuple<\n$for j, [[\n\n        typename internal::DecayArray<T$j[[]]>::type]]> >\nElementsAre($for j, [[const T$j& e$j]]) {\n  typedef std::tr1::tuple<\n$for j, [[\n\n      typename internal::DecayArray<T$j[[]]>::type]]> Args;\n  return internal::ElementsAreMatcher<Args>(Args($for j, [[e$j]]));\n}\n\n]]\n\n// UnorderedElementsAre(e_1, e_2, ..., e_n) is an ElementsAre extension\n// that matches n elements in any order.  We support up to n=$n arguments.\n\n$range i 0..n\n$for i [[\n\n$range j 1..i\n\n$if i>0 [[\n\ntemplate <$for j, [[typename T$j]]>\n]]\n\ninline internal::UnorderedElementsAreMatcher<\n    std::tr1::tuple<\n$for j, [[\n\n        typename internal::DecayArray<T$j[[]]>::type]]> >\nUnorderedElementsAre($for j, [[const T$j& e$j]]) {\n  typedef std::tr1::tuple<\n$for j, [[\n\n      typename internal::DecayArray<T$j[[]]>::type]]> Args;\n  return internal::UnorderedElementsAreMatcher<Args>(Args($for j, [[e$j]]));\n}\n\n]]\n\n// AllOf(m1, m2, ..., mk) matches any value that matches all of the given\n// sub-matchers.  AllOf is called fully qualified to prevent ADL from firing.\n\n$range i 2..n\n$for i [[\n$range j 1..i\n$var m = i/2\n$range k 1..m\n$range t m+1..i\n\ntemplate <$for j, [[typename M$j]]>\ninline typename internal::AllOfResult$i<$for j, [[M$j]]>::type\nAllOf($for j, [[M$j m$j]]) {\n  return typename internal::AllOfResult$i<$for j, [[M$j]]>::type(\n      $if m == 1 [[m1]] $else [[::testing::AllOf($for k, [[m$k]])]],\n      $if m+1 == i [[m$i]] $else [[::testing::AllOf($for t, [[m$t]])]]);\n}\n\n]]\n\n// AnyOf(m1, m2, ..., mk) matches any value that matches any of the given\n// sub-matchers.  AnyOf is called fully qualified to prevent ADL from firing.\n\n$range i 2..n\n$for i [[\n$range j 1..i\n$var m = i/2\n$range k 1..m\n$range t m+1..i\n\ntemplate <$for j, [[typename M$j]]>\ninline typename internal::AnyOfResult$i<$for j, [[M$j]]>::type\nAnyOf($for j, [[M$j m$j]]) {\n  return typename internal::AnyOfResult$i<$for j, [[M$j]]>::type(\n      $if m == 1 [[m1]] $else [[::testing::AnyOf($for k, [[m$k]])]],\n      $if m+1 == i [[m$i]] $else [[::testing::AnyOf($for t, [[m$t]])]]);\n}\n\n]]\n\n}  // namespace testing\n$$ } // This Pump meta comment fixes auto-indentation in Emacs. It will not\n$$   // show up in the generated code.\n\n\n// The MATCHER* family of macros can be used in a namespace scope to\n// define custom matchers easily.\n//\n// Basic Usage\n// ===========\n//\n// The syntax\n//\n//   MATCHER(name, description_string) { statements; }\n//\n// defines a matcher with the given name that executes the statements,\n// which must return a bool to indicate if the match succeeds.  Inside\n// the statements, you can refer to the value being matched by 'arg',\n// and refer to its type by 'arg_type'.\n//\n// The description string documents what the matcher does, and is used\n// to generate the failure message when the match fails.  Since a\n// MATCHER() is usually defined in a header file shared by multiple\n// C++ source files, we require the description to be a C-string\n// literal to avoid possible side effects.  It can be empty, in which\n// case we'll use the sequence of words in the matcher name as the\n// description.\n//\n// For example:\n//\n//   MATCHER(IsEven, \"\") { return (arg % 2) == 0; }\n//\n// allows you to write\n//\n//   // Expects mock_foo.Bar(n) to be called where n is even.\n//   EXPECT_CALL(mock_foo, Bar(IsEven()));\n//\n// or,\n//\n//   // Verifies that the value of some_expression is even.\n//   EXPECT_THAT(some_expression, IsEven());\n//\n// If the above assertion fails, it will print something like:\n//\n//   Value of: some_expression\n//   Expected: is even\n//     Actual: 7\n//\n// where the description \"is even\" is automatically calculated from the\n// matcher name IsEven.\n//\n// Argument Type\n// =============\n//\n// Note that the type of the value being matched (arg_type) is\n// determined by the context in which you use the matcher and is\n// supplied to you by the compiler, so you don't need to worry about\n// declaring it (nor can you).  This allows the matcher to be\n// polymorphic.  For example, IsEven() can be used to match any type\n// where the value of \"(arg % 2) == 0\" can be implicitly converted to\n// a bool.  In the \"Bar(IsEven())\" example above, if method Bar()\n// takes an int, 'arg_type' will be int; if it takes an unsigned long,\n// 'arg_type' will be unsigned long; and so on.\n//\n// Parameterizing Matchers\n// =======================\n//\n// Sometimes you'll want to parameterize the matcher.  For that you\n// can use another macro:\n//\n//   MATCHER_P(name, param_name, description_string) { statements; }\n//\n// For example:\n//\n//   MATCHER_P(HasAbsoluteValue, value, \"\") { return abs(arg) == value; }\n//\n// will allow you to write:\n//\n//   EXPECT_THAT(Blah(\"a\"), HasAbsoluteValue(n));\n//\n// which may lead to this message (assuming n is 10):\n//\n//   Value of: Blah(\"a\")\n//   Expected: has absolute value 10\n//     Actual: -9\n//\n// Note that both the matcher description and its parameter are\n// printed, making the message human-friendly.\n//\n// In the matcher definition body, you can write 'foo_type' to\n// reference the type of a parameter named 'foo'.  For example, in the\n// body of MATCHER_P(HasAbsoluteValue, value) above, you can write\n// 'value_type' to refer to the type of 'value'.\n//\n// We also provide MATCHER_P2, MATCHER_P3, ..., up to MATCHER_P$n to\n// support multi-parameter matchers.\n//\n// Describing Parameterized Matchers\n// =================================\n//\n// The last argument to MATCHER*() is a string-typed expression.  The\n// expression can reference all of the matcher's parameters and a\n// special bool-typed variable named 'negation'.  When 'negation' is\n// false, the expression should evaluate to the matcher's description;\n// otherwise it should evaluate to the description of the negation of\n// the matcher.  For example,\n//\n//   using testing::PrintToString;\n//\n//   MATCHER_P2(InClosedRange, low, hi,\n//       string(negation ? \"is not\" : \"is\") + \" in range [\" +\n//       PrintToString(low) + \", \" + PrintToString(hi) + \"]\") {\n//     return low <= arg && arg <= hi;\n//   }\n//   ...\n//   EXPECT_THAT(3, InClosedRange(4, 6));\n//   EXPECT_THAT(3, Not(InClosedRange(2, 4)));\n//\n// would generate two failures that contain the text:\n//\n//   Expected: is in range [4, 6]\n//   ...\n//   Expected: is not in range [2, 4]\n//\n// If you specify \"\" as the description, the failure message will\n// contain the sequence of words in the matcher name followed by the\n// parameter values printed as a tuple.  For example,\n//\n//   MATCHER_P2(InClosedRange, low, hi, \"\") { ... }\n//   ...\n//   EXPECT_THAT(3, InClosedRange(4, 6));\n//   EXPECT_THAT(3, Not(InClosedRange(2, 4)));\n//\n// would generate two failures that contain the text:\n//\n//   Expected: in closed range (4, 6)\n//   ...\n//   Expected: not (in closed range (2, 4))\n//\n// Types of Matcher Parameters\n// ===========================\n//\n// For the purpose of typing, you can view\n//\n//   MATCHER_Pk(Foo, p1, ..., pk, description_string) { ... }\n//\n// as shorthand for\n//\n//   template <typename p1_type, ..., typename pk_type>\n//   FooMatcherPk<p1_type, ..., pk_type>\n//   Foo(p1_type p1, ..., pk_type pk) { ... }\n//\n// When you write Foo(v1, ..., vk), the compiler infers the types of\n// the parameters v1, ..., and vk for you.  If you are not happy with\n// the result of the type inference, you can specify the types by\n// explicitly instantiating the template, as in Foo<long, bool>(5,\n// false).  As said earlier, you don't get to (or need to) specify\n// 'arg_type' as that's determined by the context in which the matcher\n// is used.  You can assign the result of expression Foo(p1, ..., pk)\n// to a variable of type FooMatcherPk<p1_type, ..., pk_type>.  This\n// can be useful when composing matchers.\n//\n// While you can instantiate a matcher template with reference types,\n// passing the parameters by pointer usually makes your code more\n// readable.  If, however, you still want to pass a parameter by\n// reference, be aware that in the failure message generated by the\n// matcher you will see the value of the referenced object but not its\n// address.\n//\n// Explaining Match Results\n// ========================\n//\n// Sometimes the matcher description alone isn't enough to explain why\n// the match has failed or succeeded.  For example, when expecting a\n// long string, it can be very helpful to also print the diff between\n// the expected string and the actual one.  To achieve that, you can\n// optionally stream additional information to a special variable\n// named result_listener, whose type is a pointer to class\n// MatchResultListener:\n//\n//   MATCHER_P(EqualsLongString, str, \"\") {\n//     if (arg == str) return true;\n//\n//     *result_listener << \"the difference: \"\n///                     << DiffStrings(str, arg);\n//     return false;\n//   }\n//\n// Overloading Matchers\n// ====================\n//\n// You can overload matchers with different numbers of parameters:\n//\n//   MATCHER_P(Blah, a, description_string1) { ... }\n//   MATCHER_P2(Blah, a, b, description_string2) { ... }\n//\n// Caveats\n// =======\n//\n// When defining a new matcher, you should also consider implementing\n// MatcherInterface or using MakePolymorphicMatcher().  These\n// approaches require more work than the MATCHER* macros, but also\n// give you more control on the types of the value being matched and\n// the matcher parameters, which may leads to better compiler error\n// messages when the matcher is used wrong.  They also allow\n// overloading matchers based on parameter types (as opposed to just\n// based on the number of parameters).\n//\n// MATCHER*() can only be used in a namespace scope.  The reason is\n// that C++ doesn't yet allow function-local types to be used to\n// instantiate templates.  The up-coming C++0x standard will fix this.\n// Once that's done, we'll consider supporting using MATCHER*() inside\n// a function.\n//\n// More Information\n// ================\n//\n// To learn more about using these macros, please search for 'MATCHER'\n// on http://code.google.com/p/googlemock/wiki/CookBook.\n\n$range i 0..n\n$for i\n\n[[\n$var macro_name = [[$if i==0 [[MATCHER]] $elif i==1 [[MATCHER_P]]\n                                         $else [[MATCHER_P$i]]]]\n$var class_name = [[name##Matcher[[$if i==0 [[]] $elif i==1 [[P]]\n                                                 $else [[P$i]]]]]]\n$range j 0..i-1\n$var template = [[$if i==0 [[]] $else [[\n\n  template <$for j, [[typename p$j##_type]]>\\\n]]]]\n$var ctor_param_list = [[$for j, [[p$j##_type gmock_p$j]]]]\n$var impl_ctor_param_list = [[$for j, [[p$j##_type gmock_p$j]]]]\n$var impl_inits = [[$if i==0 [[]] $else [[ : $for j, [[p$j(gmock_p$j)]]]]]]\n$var inits = [[$if i==0 [[]] $else [[ : $for j, [[p$j(gmock_p$j)]]]]]]\n$var params = [[$for j, [[p$j]]]]\n$var param_types = [[$if i==0 [[]] $else [[<$for j, [[p$j##_type]]>]]]]\n$var param_types_and_names = [[$for j, [[p$j##_type p$j]]]]\n$var param_field_decls = [[$for j\n[[\n\n      p$j##_type p$j;\\\n]]]]\n$var param_field_decls2 = [[$for j\n[[\n\n    p$j##_type p$j;\\\n]]]]\n\n#define $macro_name(name$for j [[, p$j]], description)\\$template\n  class $class_name {\\\n   public:\\\n    template <typename arg_type>\\\n    class gmock_Impl : public ::testing::MatcherInterface<arg_type> {\\\n     public:\\\n      [[$if i==1 [[explicit ]]]]gmock_Impl($impl_ctor_param_list)\\\n          $impl_inits {}\\\n      virtual bool MatchAndExplain(\\\n          arg_type arg, ::testing::MatchResultListener* result_listener) const;\\\n      virtual void DescribeTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(false);\\\n      }\\\n      virtual void DescribeNegationTo(::std::ostream* gmock_os) const {\\\n        *gmock_os << FormatDescription(true);\\\n      }\\$param_field_decls\n     private:\\\n      ::testing::internal::string FormatDescription(bool negation) const {\\\n        const ::testing::internal::string gmock_description = (description);\\\n        if (!gmock_description.empty())\\\n          return gmock_description;\\\n        return ::testing::internal::FormatMatcherDescription(\\\n            negation, #name, \\\n            ::testing::internal::UniversalTersePrintTupleFieldsToStrings(\\\n                ::std::tr1::tuple<$for j, [[p$j##_type]]>($for j, [[p$j]])));\\\n      }\\\n      GTEST_DISALLOW_ASSIGN_(gmock_Impl);\\\n    };\\\n    template <typename arg_type>\\\n    operator ::testing::Matcher<arg_type>() const {\\\n      return ::testing::Matcher<arg_type>(\\\n          new gmock_Impl<arg_type>($params));\\\n    }\\\n    $class_name($ctor_param_list)$inits {\\\n    }\\$param_field_decls2\n   private:\\\n    GTEST_DISALLOW_ASSIGN_($class_name);\\\n  };\\$template\n  inline $class_name$param_types name($param_types_and_names) {\\\n    return $class_name$param_types($params);\\\n  }\\$template\n  template <typename arg_type>\\\n  bool $class_name$param_types::gmock_Impl<arg_type>::MatchAndExplain(\\\n      arg_type arg, \\\n      ::testing::MatchResultListener* result_listener GTEST_ATTRIBUTE_UNUSED_)\\\n          const\n]]\n\n\n#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_MATCHERS_H_\n"
  },
  {
    "path": "ext/gmock/include/gmock/gmock-generated-nice-strict.h",
    "content": "// This file was GENERATED by command:\n//     pump.py gmock-generated-nice-strict.h.pump\n// DO NOT EDIT BY HAND!!!\n\n// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Implements class templates NiceMock, NaggyMock, and StrictMock.\n//\n// Given a mock class MockFoo that is created using Google Mock,\n// NiceMock<MockFoo> is a subclass of MockFoo that allows\n// uninteresting calls (i.e. calls to mock methods that have no\n// EXPECT_CALL specs), NaggyMock<MockFoo> is a subclass of MockFoo\n// that prints a warning when an uninteresting call occurs, and\n// StrictMock<MockFoo> is a subclass of MockFoo that treats all\n// uninteresting calls as errors.\n//\n// Currently a mock is naggy by default, so MockFoo and\n// NaggyMock<MockFoo> behave like the same.  However, we will soon\n// switch the default behavior of mocks to be nice, as that in general\n// leads to more maintainable tests.  When that happens, MockFoo will\n// stop behaving like NaggyMock<MockFoo> and start behaving like\n// NiceMock<MockFoo>.\n//\n// NiceMock, NaggyMock, and StrictMock \"inherit\" the constructors of\n// their respective base class, with up-to 10 arguments.  Therefore\n// you can write NiceMock<MockFoo>(5, \"a\") to construct a nice mock\n// where MockFoo has a constructor that accepts (int, const char*),\n// for example.\n//\n// A known limitation is that NiceMock<MockFoo>, NaggyMock<MockFoo>,\n// and StrictMock<MockFoo> only works for mock methods defined using\n// the MOCK_METHOD* family of macros DIRECTLY in the MockFoo class.\n// If a mock method is defined in a base class of MockFoo, the \"nice\"\n// or \"strict\" modifier may not affect it, depending on the compiler.\n// In particular, nesting NiceMock, NaggyMock, and StrictMock is NOT\n// supported.\n//\n// Another known limitation is that the constructors of the base mock\n// cannot have arguments passed by non-const reference, which are\n// banned by the Google C++ style guide anyway.\n\n#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_\n#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_\n\n#include \"gmock/gmock-spec-builders.h\"\n#include \"gmock/internal/gmock-port.h\"\n\nnamespace testing {\n\ntemplate <class MockClass>\nclass NiceMock : public MockClass {\n public:\n  // We don't factor out the constructor body to a common method, as\n  // we have to avoid a possible clash with members of MockClass.\n  NiceMock() {\n    ::testing::Mock::AllowUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  // C++ doesn't (yet) allow inheritance of constructors, so we have\n  // to define it for each arity.\n  template <typename A1>\n  explicit NiceMock(const A1& a1) : MockClass(a1) {\n    ::testing::Mock::AllowUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n  template <typename A1, typename A2>\n  NiceMock(const A1& a1, const A2& a2) : MockClass(a1, a2) {\n    ::testing::Mock::AllowUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3>\n  NiceMock(const A1& a1, const A2& a2, const A3& a3) : MockClass(a1, a2, a3) {\n    ::testing::Mock::AllowUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3, typename A4>\n  NiceMock(const A1& a1, const A2& a2, const A3& a3,\n      const A4& a4) : MockClass(a1, a2, a3, a4) {\n    ::testing::Mock::AllowUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3, typename A4, typename A5>\n  NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,\n      const A5& a5) : MockClass(a1, a2, a3, a4, a5) {\n    ::testing::Mock::AllowUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3, typename A4, typename A5,\n      typename A6>\n  NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,\n      const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {\n    ::testing::Mock::AllowUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3, typename A4, typename A5,\n      typename A6, typename A7>\n  NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,\n      const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,\n      a6, a7) {\n    ::testing::Mock::AllowUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3, typename A4, typename A5,\n      typename A6, typename A7, typename A8>\n  NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,\n      const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1,\n      a2, a3, a4, a5, a6, a7, a8) {\n    ::testing::Mock::AllowUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3, typename A4, typename A5,\n      typename A6, typename A7, typename A8, typename A9>\n  NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,\n      const A5& a5, const A6& a6, const A7& a7, const A8& a8,\n      const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {\n    ::testing::Mock::AllowUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3, typename A4, typename A5,\n      typename A6, typename A7, typename A8, typename A9, typename A10>\n  NiceMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,\n      const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,\n      const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {\n    ::testing::Mock::AllowUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  virtual ~NiceMock() {\n    ::testing::Mock::UnregisterCallReaction(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(NiceMock);\n};\n\ntemplate <class MockClass>\nclass NaggyMock : public MockClass {\n public:\n  // We don't factor out the constructor body to a common method, as\n  // we have to avoid a possible clash with members of MockClass.\n  NaggyMock() {\n    ::testing::Mock::WarnUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  // C++ doesn't (yet) allow inheritance of constructors, so we have\n  // to define it for each arity.\n  template <typename A1>\n  explicit NaggyMock(const A1& a1) : MockClass(a1) {\n    ::testing::Mock::WarnUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n  template <typename A1, typename A2>\n  NaggyMock(const A1& a1, const A2& a2) : MockClass(a1, a2) {\n    ::testing::Mock::WarnUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3>\n  NaggyMock(const A1& a1, const A2& a2, const A3& a3) : MockClass(a1, a2, a3) {\n    ::testing::Mock::WarnUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3, typename A4>\n  NaggyMock(const A1& a1, const A2& a2, const A3& a3,\n      const A4& a4) : MockClass(a1, a2, a3, a4) {\n    ::testing::Mock::WarnUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3, typename A4, typename A5>\n  NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,\n      const A5& a5) : MockClass(a1, a2, a3, a4, a5) {\n    ::testing::Mock::WarnUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3, typename A4, typename A5,\n      typename A6>\n  NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,\n      const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {\n    ::testing::Mock::WarnUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3, typename A4, typename A5,\n      typename A6, typename A7>\n  NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,\n      const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,\n      a6, a7) {\n    ::testing::Mock::WarnUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3, typename A4, typename A5,\n      typename A6, typename A7, typename A8>\n  NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,\n      const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1,\n      a2, a3, a4, a5, a6, a7, a8) {\n    ::testing::Mock::WarnUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3, typename A4, typename A5,\n      typename A6, typename A7, typename A8, typename A9>\n  NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,\n      const A5& a5, const A6& a6, const A7& a7, const A8& a8,\n      const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {\n    ::testing::Mock::WarnUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3, typename A4, typename A5,\n      typename A6, typename A7, typename A8, typename A9, typename A10>\n  NaggyMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,\n      const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,\n      const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {\n    ::testing::Mock::WarnUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  virtual ~NaggyMock() {\n    ::testing::Mock::UnregisterCallReaction(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(NaggyMock);\n};\n\ntemplate <class MockClass>\nclass StrictMock : public MockClass {\n public:\n  // We don't factor out the constructor body to a common method, as\n  // we have to avoid a possible clash with members of MockClass.\n  StrictMock() {\n    ::testing::Mock::FailUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  // C++ doesn't (yet) allow inheritance of constructors, so we have\n  // to define it for each arity.\n  template <typename A1>\n  explicit StrictMock(const A1& a1) : MockClass(a1) {\n    ::testing::Mock::FailUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n  template <typename A1, typename A2>\n  StrictMock(const A1& a1, const A2& a2) : MockClass(a1, a2) {\n    ::testing::Mock::FailUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3>\n  StrictMock(const A1& a1, const A2& a2, const A3& a3) : MockClass(a1, a2, a3) {\n    ::testing::Mock::FailUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3, typename A4>\n  StrictMock(const A1& a1, const A2& a2, const A3& a3,\n      const A4& a4) : MockClass(a1, a2, a3, a4) {\n    ::testing::Mock::FailUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3, typename A4, typename A5>\n  StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,\n      const A5& a5) : MockClass(a1, a2, a3, a4, a5) {\n    ::testing::Mock::FailUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3, typename A4, typename A5,\n      typename A6>\n  StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,\n      const A5& a5, const A6& a6) : MockClass(a1, a2, a3, a4, a5, a6) {\n    ::testing::Mock::FailUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3, typename A4, typename A5,\n      typename A6, typename A7>\n  StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,\n      const A5& a5, const A6& a6, const A7& a7) : MockClass(a1, a2, a3, a4, a5,\n      a6, a7) {\n    ::testing::Mock::FailUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3, typename A4, typename A5,\n      typename A6, typename A7, typename A8>\n  StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,\n      const A5& a5, const A6& a6, const A7& a7, const A8& a8) : MockClass(a1,\n      a2, a3, a4, a5, a6, a7, a8) {\n    ::testing::Mock::FailUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3, typename A4, typename A5,\n      typename A6, typename A7, typename A8, typename A9>\n  StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,\n      const A5& a5, const A6& a6, const A7& a7, const A8& a8,\n      const A9& a9) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9) {\n    ::testing::Mock::FailUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  template <typename A1, typename A2, typename A3, typename A4, typename A5,\n      typename A6, typename A7, typename A8, typename A9, typename A10>\n  StrictMock(const A1& a1, const A2& a2, const A3& a3, const A4& a4,\n      const A5& a5, const A6& a6, const A7& a7, const A8& a8, const A9& a9,\n      const A10& a10) : MockClass(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {\n    ::testing::Mock::FailUninterestingCalls(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  virtual ~StrictMock() {\n    ::testing::Mock::UnregisterCallReaction(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(StrictMock);\n};\n\n// The following specializations catch some (relatively more common)\n// user errors of nesting nice and strict mocks.  They do NOT catch\n// all possible errors.\n\n// These specializations are declared but not defined, as NiceMock,\n// NaggyMock, and StrictMock cannot be nested.\n\ntemplate <typename MockClass>\nclass NiceMock<NiceMock<MockClass> >;\ntemplate <typename MockClass>\nclass NiceMock<NaggyMock<MockClass> >;\ntemplate <typename MockClass>\nclass NiceMock<StrictMock<MockClass> >;\n\ntemplate <typename MockClass>\nclass NaggyMock<NiceMock<MockClass> >;\ntemplate <typename MockClass>\nclass NaggyMock<NaggyMock<MockClass> >;\ntemplate <typename MockClass>\nclass NaggyMock<StrictMock<MockClass> >;\n\ntemplate <typename MockClass>\nclass StrictMock<NiceMock<MockClass> >;\ntemplate <typename MockClass>\nclass StrictMock<NaggyMock<MockClass> >;\ntemplate <typename MockClass>\nclass StrictMock<StrictMock<MockClass> >;\n\n}  // namespace testing\n\n#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_\n"
  },
  {
    "path": "ext/gmock/include/gmock/gmock-generated-nice-strict.h.pump",
    "content": "$$ -*- mode: c++; -*-\n$$ This is a Pump source file.  Please use Pump to convert it to\n$$ gmock-generated-nice-strict.h.\n$$\n$var n = 10  $$ The maximum arity we support.\n// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Implements class templates NiceMock, NaggyMock, and StrictMock.\n//\n// Given a mock class MockFoo that is created using Google Mock,\n// NiceMock<MockFoo> is a subclass of MockFoo that allows\n// uninteresting calls (i.e. calls to mock methods that have no\n// EXPECT_CALL specs), NaggyMock<MockFoo> is a subclass of MockFoo\n// that prints a warning when an uninteresting call occurs, and\n// StrictMock<MockFoo> is a subclass of MockFoo that treats all\n// uninteresting calls as errors.\n//\n// Currently a mock is naggy by default, so MockFoo and\n// NaggyMock<MockFoo> behave like the same.  However, we will soon\n// switch the default behavior of mocks to be nice, as that in general\n// leads to more maintainable tests.  When that happens, MockFoo will\n// stop behaving like NaggyMock<MockFoo> and start behaving like\n// NiceMock<MockFoo>.\n//\n// NiceMock, NaggyMock, and StrictMock \"inherit\" the constructors of\n// their respective base class, with up-to $n arguments.  Therefore\n// you can write NiceMock<MockFoo>(5, \"a\") to construct a nice mock\n// where MockFoo has a constructor that accepts (int, const char*),\n// for example.\n//\n// A known limitation is that NiceMock<MockFoo>, NaggyMock<MockFoo>,\n// and StrictMock<MockFoo> only works for mock methods defined using\n// the MOCK_METHOD* family of macros DIRECTLY in the MockFoo class.\n// If a mock method is defined in a base class of MockFoo, the \"nice\"\n// or \"strict\" modifier may not affect it, depending on the compiler.\n// In particular, nesting NiceMock, NaggyMock, and StrictMock is NOT\n// supported.\n//\n// Another known limitation is that the constructors of the base mock\n// cannot have arguments passed by non-const reference, which are\n// banned by the Google C++ style guide anyway.\n\n#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_\n#define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_\n\n#include \"gmock/gmock-spec-builders.h\"\n#include \"gmock/internal/gmock-port.h\"\n\nnamespace testing {\n\n$range kind 0..2\n$for kind [[\n\n$var clazz=[[$if kind==0 [[NiceMock]]\n             $elif kind==1 [[NaggyMock]]\n             $else [[StrictMock]]]]\n\n$var method=[[$if kind==0 [[AllowUninterestingCalls]]\n             $elif kind==1 [[WarnUninterestingCalls]]\n             $else [[FailUninterestingCalls]]]]\n\ntemplate <class MockClass>\nclass $clazz : public MockClass {\n public:\n  // We don't factor out the constructor body to a common method, as\n  // we have to avoid a possible clash with members of MockClass.\n  $clazz() {\n    ::testing::Mock::$method(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n  // C++ doesn't (yet) allow inheritance of constructors, so we have\n  // to define it for each arity.\n  template <typename A1>\n  explicit $clazz(const A1& a1) : MockClass(a1) {\n    ::testing::Mock::$method(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n$range i 2..n\n$for i [[\n$range j 1..i\n  template <$for j, [[typename A$j]]>\n  $clazz($for j, [[const A$j& a$j]]) : MockClass($for j, [[a$j]]) {\n    ::testing::Mock::$method(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n\n]]\n  virtual ~$clazz() {\n    ::testing::Mock::UnregisterCallReaction(\n        internal::ImplicitCast_<MockClass*>(this));\n  }\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_($clazz);\n};\n\n]]\n\n// The following specializations catch some (relatively more common)\n// user errors of nesting nice and strict mocks.  They do NOT catch\n// all possible errors.\n\n// These specializations are declared but not defined, as NiceMock,\n// NaggyMock, and StrictMock cannot be nested.\n\ntemplate <typename MockClass>\nclass NiceMock<NiceMock<MockClass> >;\ntemplate <typename MockClass>\nclass NiceMock<NaggyMock<MockClass> >;\ntemplate <typename MockClass>\nclass NiceMock<StrictMock<MockClass> >;\n\ntemplate <typename MockClass>\nclass NaggyMock<NiceMock<MockClass> >;\ntemplate <typename MockClass>\nclass NaggyMock<NaggyMock<MockClass> >;\ntemplate <typename MockClass>\nclass NaggyMock<StrictMock<MockClass> >;\n\ntemplate <typename MockClass>\nclass StrictMock<NiceMock<MockClass> >;\ntemplate <typename MockClass>\nclass StrictMock<NaggyMock<MockClass> >;\ntemplate <typename MockClass>\nclass StrictMock<StrictMock<MockClass> >;\n\n}  // namespace testing\n\n#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_NICE_STRICT_H_\n"
  },
  {
    "path": "ext/gmock/include/gmock/gmock-matchers.h",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements some commonly used argument matchers.  More\n// matchers can be defined by the user implementing the\n// MatcherInterface<T> interface if necessary.\n\n#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_\n#define GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_\n\n#include <math.h>\n#include <algorithm>\n#include <iterator>\n#include <limits>\n#include <ostream>  // NOLINT\n#include <sstream>\n#include <string>\n#include <utility>\n#include <vector>\n\n#include \"gmock/internal/gmock-internal-utils.h\"\n#include \"gmock/internal/gmock-port.h\"\n#include \"gtest/gtest.h\"\n\n#if GTEST_LANG_CXX11\n#include <initializer_list>  // NOLINT -- must be after gtest.h\n#endif\n\nnamespace testing {\n\n// To implement a matcher Foo for type T, define:\n//   1. a class FooMatcherImpl that implements the\n//      MatcherInterface<T> interface, and\n//   2. a factory function that creates a Matcher<T> object from a\n//      FooMatcherImpl*.\n//\n// The two-level delegation design makes it possible to allow a user\n// to write \"v\" instead of \"Eq(v)\" where a Matcher is expected, which\n// is impossible if we pass matchers by pointers.  It also eases\n// ownership management as Matcher objects can now be copied like\n// plain values.\n\n// MatchResultListener is an abstract class.  Its << operator can be\n// used by a matcher to explain why a value matches or doesn't match.\n//\n// TODO(wan@google.com): add method\n//   bool InterestedInWhy(bool result) const;\n// to indicate whether the listener is interested in why the match\n// result is 'result'.\nclass MatchResultListener {\n public:\n  // Creates a listener object with the given underlying ostream.  The\n  // listener does not own the ostream, and does not dereference it\n  // in the constructor or destructor.\n  explicit MatchResultListener(::std::ostream* os) : stream_(os) {}\n  virtual ~MatchResultListener() = 0;  // Makes this class abstract.\n\n  // Streams x to the underlying ostream; does nothing if the ostream\n  // is NULL.\n  template <typename T>\n  MatchResultListener& operator<<(const T& x) {\n    if (stream_ != NULL)\n      *stream_ << x;\n    return *this;\n  }\n\n  // Returns the underlying ostream.\n  ::std::ostream* stream() { return stream_; }\n\n  // Returns true iff the listener is interested in an explanation of\n  // the match result.  A matcher's MatchAndExplain() method can use\n  // this information to avoid generating the explanation when no one\n  // intends to hear it.\n  bool IsInterested() const { return stream_ != NULL; }\n\n private:\n  ::std::ostream* const stream_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MatchResultListener);\n};\n\ninline MatchResultListener::~MatchResultListener() {\n}\n\n// An instance of a subclass of this knows how to describe itself as a\n// matcher.\nclass MatcherDescriberInterface {\n public:\n  virtual ~MatcherDescriberInterface() {}\n\n  // Describes this matcher to an ostream.  The function should print\n  // a verb phrase that describes the property a value matching this\n  // matcher should have.  The subject of the verb phrase is the value\n  // being matched.  For example, the DescribeTo() method of the Gt(7)\n  // matcher prints \"is greater than 7\".\n  virtual void DescribeTo(::std::ostream* os) const = 0;\n\n  // Describes the negation of this matcher to an ostream.  For\n  // example, if the description of this matcher is \"is greater than\n  // 7\", the negated description could be \"is not greater than 7\".\n  // You are not required to override this when implementing\n  // MatcherInterface, but it is highly advised so that your matcher\n  // can produce good error messages.\n  virtual void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"not (\";\n    DescribeTo(os);\n    *os << \")\";\n  }\n};\n\n// The implementation of a matcher.\ntemplate <typename T>\nclass MatcherInterface : public MatcherDescriberInterface {\n public:\n  // Returns true iff the matcher matches x; also explains the match\n  // result to 'listener' if necessary (see the next paragraph), in\n  // the form of a non-restrictive relative clause (\"which ...\",\n  // \"whose ...\", etc) that describes x.  For example, the\n  // MatchAndExplain() method of the Pointee(...) matcher should\n  // generate an explanation like \"which points to ...\".\n  //\n  // Implementations of MatchAndExplain() should add an explanation of\n  // the match result *if and only if* they can provide additional\n  // information that's not already present (or not obvious) in the\n  // print-out of x and the matcher's description.  Whether the match\n  // succeeds is not a factor in deciding whether an explanation is\n  // needed, as sometimes the caller needs to print a failure message\n  // when the match succeeds (e.g. when the matcher is used inside\n  // Not()).\n  //\n  // For example, a \"has at least 10 elements\" matcher should explain\n  // what the actual element count is, regardless of the match result,\n  // as it is useful information to the reader; on the other hand, an\n  // \"is empty\" matcher probably only needs to explain what the actual\n  // size is when the match fails, as it's redundant to say that the\n  // size is 0 when the value is already known to be empty.\n  //\n  // You should override this method when defining a new matcher.\n  //\n  // It's the responsibility of the caller (Google Mock) to guarantee\n  // that 'listener' is not NULL.  This helps to simplify a matcher's\n  // implementation when it doesn't care about the performance, as it\n  // can talk to 'listener' without checking its validity first.\n  // However, in order to implement dummy listeners efficiently,\n  // listener->stream() may be NULL.\n  virtual bool MatchAndExplain(T x, MatchResultListener* listener) const = 0;\n\n  // Inherits these methods from MatcherDescriberInterface:\n  //   virtual void DescribeTo(::std::ostream* os) const = 0;\n  //   virtual void DescribeNegationTo(::std::ostream* os) const;\n};\n\n// A match result listener that stores the explanation in a string.\nclass StringMatchResultListener : public MatchResultListener {\n public:\n  StringMatchResultListener() : MatchResultListener(&ss_) {}\n\n  // Returns the explanation accumulated so far.\n  internal::string str() const { return ss_.str(); }\n\n  // Clears the explanation accumulated so far.\n  void Clear() { ss_.str(\"\"); }\n\n private:\n  ::std::stringstream ss_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(StringMatchResultListener);\n};\n\nnamespace internal {\n\n// A match result listener that ignores the explanation.\nclass DummyMatchResultListener : public MatchResultListener {\n public:\n  DummyMatchResultListener() : MatchResultListener(NULL) {}\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(DummyMatchResultListener);\n};\n\n// A match result listener that forwards the explanation to a given\n// ostream.  The difference between this and MatchResultListener is\n// that the former is concrete.\nclass StreamMatchResultListener : public MatchResultListener {\n public:\n  explicit StreamMatchResultListener(::std::ostream* os)\n      : MatchResultListener(os) {}\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamMatchResultListener);\n};\n\n// An internal class for implementing Matcher<T>, which will derive\n// from it.  We put functionalities common to all Matcher<T>\n// specializations here to avoid code duplication.\ntemplate <typename T>\nclass MatcherBase {\n public:\n  // Returns true iff the matcher matches x; also explains the match\n  // result to 'listener'.\n  bool MatchAndExplain(T x, MatchResultListener* listener) const {\n    return impl_->MatchAndExplain(x, listener);\n  }\n\n  // Returns true iff this matcher matches x.\n  bool Matches(T x) const {\n    DummyMatchResultListener dummy;\n    return MatchAndExplain(x, &dummy);\n  }\n\n  // Describes this matcher to an ostream.\n  void DescribeTo(::std::ostream* os) const { impl_->DescribeTo(os); }\n\n  // Describes the negation of this matcher to an ostream.\n  void DescribeNegationTo(::std::ostream* os) const {\n    impl_->DescribeNegationTo(os);\n  }\n\n  // Explains why x matches, or doesn't match, the matcher.\n  void ExplainMatchResultTo(T x, ::std::ostream* os) const {\n    StreamMatchResultListener listener(os);\n    MatchAndExplain(x, &listener);\n  }\n\n  // Returns the describer for this matcher object; retains ownership\n  // of the describer, which is only guaranteed to be alive when\n  // this matcher object is alive.\n  const MatcherDescriberInterface* GetDescriber() const {\n    return impl_.get();\n  }\n\n protected:\n  MatcherBase() {}\n\n  // Constructs a matcher from its implementation.\n  explicit MatcherBase(const MatcherInterface<T>* impl)\n      : impl_(impl) {}\n\n  virtual ~MatcherBase() {}\n\n private:\n  // shared_ptr (util/gtl/shared_ptr.h) and linked_ptr have similar\n  // interfaces.  The former dynamically allocates a chunk of memory\n  // to hold the reference count, while the latter tracks all\n  // references using a circular linked list without allocating\n  // memory.  It has been observed that linked_ptr performs better in\n  // typical scenarios.  However, shared_ptr can out-perform\n  // linked_ptr when there are many more uses of the copy constructor\n  // than the default constructor.\n  //\n  // If performance becomes a problem, we should see if using\n  // shared_ptr helps.\n  ::testing::internal::linked_ptr<const MatcherInterface<T> > impl_;\n};\n\n}  // namespace internal\n\n// A Matcher<T> is a copyable and IMMUTABLE (except by assignment)\n// object that can check whether a value of type T matches.  The\n// implementation of Matcher<T> is just a linked_ptr to const\n// MatcherInterface<T>, so copying is fairly cheap.  Don't inherit\n// from Matcher!\ntemplate <typename T>\nclass Matcher : public internal::MatcherBase<T> {\n public:\n  // Constructs a null matcher.  Needed for storing Matcher objects in STL\n  // containers.  A default-constructed matcher is not yet initialized.  You\n  // cannot use it until a valid value has been assigned to it.\n  Matcher() {}\n\n  // Constructs a matcher from its implementation.\n  explicit Matcher(const MatcherInterface<T>* impl)\n      : internal::MatcherBase<T>(impl) {}\n\n  // Implicit constructor here allows people to write\n  // EXPECT_CALL(foo, Bar(5)) instead of EXPECT_CALL(foo, Bar(Eq(5))) sometimes\n  Matcher(T value);  // NOLINT\n};\n\n// The following two specializations allow the user to write str\n// instead of Eq(str) and \"foo\" instead of Eq(\"foo\") when a string\n// matcher is expected.\ntemplate <>\nclass GTEST_API_ Matcher<const internal::string&>\n    : public internal::MatcherBase<const internal::string&> {\n public:\n  Matcher() {}\n\n  explicit Matcher(const MatcherInterface<const internal::string&>* impl)\n      : internal::MatcherBase<const internal::string&>(impl) {}\n\n  // Allows the user to write str instead of Eq(str) sometimes, where\n  // str is a string object.\n  Matcher(const internal::string& s);  // NOLINT\n\n  // Allows the user to write \"foo\" instead of Eq(\"foo\") sometimes.\n  Matcher(const char* s);  // NOLINT\n};\n\ntemplate <>\nclass GTEST_API_ Matcher<internal::string>\n    : public internal::MatcherBase<internal::string> {\n public:\n  Matcher() {}\n\n  explicit Matcher(const MatcherInterface<internal::string>* impl)\n      : internal::MatcherBase<internal::string>(impl) {}\n\n  // Allows the user to write str instead of Eq(str) sometimes, where\n  // str is a string object.\n  Matcher(const internal::string& s);  // NOLINT\n\n  // Allows the user to write \"foo\" instead of Eq(\"foo\") sometimes.\n  Matcher(const char* s);  // NOLINT\n};\n\n#if GTEST_HAS_STRING_PIECE_\n// The following two specializations allow the user to write str\n// instead of Eq(str) and \"foo\" instead of Eq(\"foo\") when a StringPiece\n// matcher is expected.\ntemplate <>\nclass GTEST_API_ Matcher<const StringPiece&>\n    : public internal::MatcherBase<const StringPiece&> {\n public:\n  Matcher() {}\n\n  explicit Matcher(const MatcherInterface<const StringPiece&>* impl)\n      : internal::MatcherBase<const StringPiece&>(impl) {}\n\n  // Allows the user to write str instead of Eq(str) sometimes, where\n  // str is a string object.\n  Matcher(const internal::string& s);  // NOLINT\n\n  // Allows the user to write \"foo\" instead of Eq(\"foo\") sometimes.\n  Matcher(const char* s);  // NOLINT\n\n  // Allows the user to pass StringPieces directly.\n  Matcher(StringPiece s);  // NOLINT\n};\n\ntemplate <>\nclass GTEST_API_ Matcher<StringPiece>\n    : public internal::MatcherBase<StringPiece> {\n public:\n  Matcher() {}\n\n  explicit Matcher(const MatcherInterface<StringPiece>* impl)\n      : internal::MatcherBase<StringPiece>(impl) {}\n\n  // Allows the user to write str instead of Eq(str) sometimes, where\n  // str is a string object.\n  Matcher(const internal::string& s);  // NOLINT\n\n  // Allows the user to write \"foo\" instead of Eq(\"foo\") sometimes.\n  Matcher(const char* s);  // NOLINT\n\n  // Allows the user to pass StringPieces directly.\n  Matcher(StringPiece s);  // NOLINT\n};\n#endif  // GTEST_HAS_STRING_PIECE_\n\n// The PolymorphicMatcher class template makes it easy to implement a\n// polymorphic matcher (i.e. a matcher that can match values of more\n// than one type, e.g. Eq(n) and NotNull()).\n//\n// To define a polymorphic matcher, a user should provide an Impl\n// class that has a DescribeTo() method and a DescribeNegationTo()\n// method, and define a member function (or member function template)\n//\n//   bool MatchAndExplain(const Value& value,\n//                        MatchResultListener* listener) const;\n//\n// See the definition of NotNull() for a complete example.\ntemplate <class Impl>\nclass PolymorphicMatcher {\n public:\n  explicit PolymorphicMatcher(const Impl& an_impl) : impl_(an_impl) {}\n\n  // Returns a mutable reference to the underlying matcher\n  // implementation object.\n  Impl& mutable_impl() { return impl_; }\n\n  // Returns an immutable reference to the underlying matcher\n  // implementation object.\n  const Impl& impl() const { return impl_; }\n\n  template <typename T>\n  operator Matcher<T>() const {\n    return Matcher<T>(new MonomorphicImpl<T>(impl_));\n  }\n\n private:\n  template <typename T>\n  class MonomorphicImpl : public MatcherInterface<T> {\n   public:\n    explicit MonomorphicImpl(const Impl& impl) : impl_(impl) {}\n\n    virtual void DescribeTo(::std::ostream* os) const {\n      impl_.DescribeTo(os);\n    }\n\n    virtual void DescribeNegationTo(::std::ostream* os) const {\n      impl_.DescribeNegationTo(os);\n    }\n\n    virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {\n      return impl_.MatchAndExplain(x, listener);\n    }\n\n   private:\n    const Impl impl_;\n\n    GTEST_DISALLOW_ASSIGN_(MonomorphicImpl);\n  };\n\n  Impl impl_;\n\n  GTEST_DISALLOW_ASSIGN_(PolymorphicMatcher);\n};\n\n// Creates a matcher from its implementation.  This is easier to use\n// than the Matcher<T> constructor as it doesn't require you to\n// explicitly write the template argument, e.g.\n//\n//   MakeMatcher(foo);\n// vs\n//   Matcher<const string&>(foo);\ntemplate <typename T>\ninline Matcher<T> MakeMatcher(const MatcherInterface<T>* impl) {\n  return Matcher<T>(impl);\n}\n\n// Creates a polymorphic matcher from its implementation.  This is\n// easier to use than the PolymorphicMatcher<Impl> constructor as it\n// doesn't require you to explicitly write the template argument, e.g.\n//\n//   MakePolymorphicMatcher(foo);\n// vs\n//   PolymorphicMatcher<TypeOfFoo>(foo);\ntemplate <class Impl>\ninline PolymorphicMatcher<Impl> MakePolymorphicMatcher(const Impl& impl) {\n  return PolymorphicMatcher<Impl>(impl);\n}\n\n// Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION\n// and MUST NOT BE USED IN USER CODE!!!\nnamespace internal {\n\n// The MatcherCastImpl class template is a helper for implementing\n// MatcherCast().  We need this helper in order to partially\n// specialize the implementation of MatcherCast() (C++ allows\n// class/struct templates to be partially specialized, but not\n// function templates.).\n\n// This general version is used when MatcherCast()'s argument is a\n// polymorphic matcher (i.e. something that can be converted to a\n// Matcher but is not one yet; for example, Eq(value)) or a value (for\n// example, \"hello\").\ntemplate <typename T, typename M>\nclass MatcherCastImpl {\n public:\n  static Matcher<T> Cast(M polymorphic_matcher_or_value) {\n    // M can be a polymorhic matcher, in which case we want to use\n    // its conversion operator to create Matcher<T>.  Or it can be a value\n    // that should be passed to the Matcher<T>'s constructor.\n    //\n    // We can't call Matcher<T>(polymorphic_matcher_or_value) when M is a\n    // polymorphic matcher because it'll be ambiguous if T has an implicit\n    // constructor from M (this usually happens when T has an implicit\n    // constructor from any type).\n    //\n    // It won't work to unconditionally implict_cast\n    // polymorphic_matcher_or_value to Matcher<T> because it won't trigger\n    // a user-defined conversion from M to T if one exists (assuming M is\n    // a value).\n    return CastImpl(\n        polymorphic_matcher_or_value,\n        BooleanConstant<\n            internal::ImplicitlyConvertible<M, Matcher<T> >::value>());\n  }\n\n private:\n  static Matcher<T> CastImpl(M value, BooleanConstant<false>) {\n    // M can't be implicitly converted to Matcher<T>, so M isn't a polymorphic\n    // matcher.  It must be a value then.  Use direct initialization to create\n    // a matcher.\n    return Matcher<T>(ImplicitCast_<T>(value));\n  }\n\n  static Matcher<T> CastImpl(M polymorphic_matcher_or_value,\n                             BooleanConstant<true>) {\n    // M is implicitly convertible to Matcher<T>, which means that either\n    // M is a polymorhpic matcher or Matcher<T> has an implicit constructor\n    // from M.  In both cases using the implicit conversion will produce a\n    // matcher.\n    //\n    // Even if T has an implicit constructor from M, it won't be called because\n    // creating Matcher<T> would require a chain of two user-defined conversions\n    // (first to create T from M and then to create Matcher<T> from T).\n    return polymorphic_matcher_or_value;\n  }\n};\n\n// This more specialized version is used when MatcherCast()'s argument\n// is already a Matcher.  This only compiles when type T can be\n// statically converted to type U.\ntemplate <typename T, typename U>\nclass MatcherCastImpl<T, Matcher<U> > {\n public:\n  static Matcher<T> Cast(const Matcher<U>& source_matcher) {\n    return Matcher<T>(new Impl(source_matcher));\n  }\n\n private:\n  class Impl : public MatcherInterface<T> {\n   public:\n    explicit Impl(const Matcher<U>& source_matcher)\n        : source_matcher_(source_matcher) {}\n\n    // We delegate the matching logic to the source matcher.\n    virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {\n      return source_matcher_.MatchAndExplain(static_cast<U>(x), listener);\n    }\n\n    virtual void DescribeTo(::std::ostream* os) const {\n      source_matcher_.DescribeTo(os);\n    }\n\n    virtual void DescribeNegationTo(::std::ostream* os) const {\n      source_matcher_.DescribeNegationTo(os);\n    }\n\n   private:\n    const Matcher<U> source_matcher_;\n\n    GTEST_DISALLOW_ASSIGN_(Impl);\n  };\n};\n\n// This even more specialized version is used for efficiently casting\n// a matcher to its own type.\ntemplate <typename T>\nclass MatcherCastImpl<T, Matcher<T> > {\n public:\n  static Matcher<T> Cast(const Matcher<T>& matcher) { return matcher; }\n};\n\n}  // namespace internal\n\n// In order to be safe and clear, casting between different matcher\n// types is done explicitly via MatcherCast<T>(m), which takes a\n// matcher m and returns a Matcher<T>.  It compiles only when T can be\n// statically converted to the argument type of m.\ntemplate <typename T, typename M>\ninline Matcher<T> MatcherCast(M matcher) {\n  return internal::MatcherCastImpl<T, M>::Cast(matcher);\n}\n\n// Implements SafeMatcherCast().\n//\n// We use an intermediate class to do the actual safe casting as Nokia's\n// Symbian compiler cannot decide between\n// template <T, M> ... (M) and\n// template <T, U> ... (const Matcher<U>&)\n// for function templates but can for member function templates.\ntemplate <typename T>\nclass SafeMatcherCastImpl {\n public:\n  // This overload handles polymorphic matchers and values only since\n  // monomorphic matchers are handled by the next one.\n  template <typename M>\n  static inline Matcher<T> Cast(M polymorphic_matcher_or_value) {\n    return internal::MatcherCastImpl<T, M>::Cast(polymorphic_matcher_or_value);\n  }\n\n  // This overload handles monomorphic matchers.\n  //\n  // In general, if type T can be implicitly converted to type U, we can\n  // safely convert a Matcher<U> to a Matcher<T> (i.e. Matcher is\n  // contravariant): just keep a copy of the original Matcher<U>, convert the\n  // argument from type T to U, and then pass it to the underlying Matcher<U>.\n  // The only exception is when U is a reference and T is not, as the\n  // underlying Matcher<U> may be interested in the argument's address, which\n  // is not preserved in the conversion from T to U.\n  template <typename U>\n  static inline Matcher<T> Cast(const Matcher<U>& matcher) {\n    // Enforce that T can be implicitly converted to U.\n    GTEST_COMPILE_ASSERT_((internal::ImplicitlyConvertible<T, U>::value),\n                          T_must_be_implicitly_convertible_to_U);\n    // Enforce that we are not converting a non-reference type T to a reference\n    // type U.\n    GTEST_COMPILE_ASSERT_(\n        internal::is_reference<T>::value || !internal::is_reference<U>::value,\n        cannot_convert_non_referentce_arg_to_reference);\n    // In case both T and U are arithmetic types, enforce that the\n    // conversion is not lossy.\n    typedef GTEST_REMOVE_REFERENCE_AND_CONST_(T) RawT;\n    typedef GTEST_REMOVE_REFERENCE_AND_CONST_(U) RawU;\n    const bool kTIsOther = GMOCK_KIND_OF_(RawT) == internal::kOther;\n    const bool kUIsOther = GMOCK_KIND_OF_(RawU) == internal::kOther;\n    GTEST_COMPILE_ASSERT_(\n        kTIsOther || kUIsOther ||\n        (internal::LosslessArithmeticConvertible<RawT, RawU>::value),\n        conversion_of_arithmetic_types_must_be_lossless);\n    return MatcherCast<T>(matcher);\n  }\n};\n\ntemplate <typename T, typename M>\ninline Matcher<T> SafeMatcherCast(const M& polymorphic_matcher) {\n  return SafeMatcherCastImpl<T>::Cast(polymorphic_matcher);\n}\n\n// A<T>() returns a matcher that matches any value of type T.\ntemplate <typename T>\nMatcher<T> A();\n\n// Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION\n// and MUST NOT BE USED IN USER CODE!!!\nnamespace internal {\n\n// If the explanation is not empty, prints it to the ostream.\ninline void PrintIfNotEmpty(const internal::string& explanation,\n                            ::std::ostream* os) {\n  if (explanation != \"\" && os != NULL) {\n    *os << \", \" << explanation;\n  }\n}\n\n// Returns true if the given type name is easy to read by a human.\n// This is used to decide whether printing the type of a value might\n// be helpful.\ninline bool IsReadableTypeName(const string& type_name) {\n  // We consider a type name readable if it's short or doesn't contain\n  // a template or function type.\n  return (type_name.length() <= 20 ||\n          type_name.find_first_of(\"<(\") == string::npos);\n}\n\n// Matches the value against the given matcher, prints the value and explains\n// the match result to the listener. Returns the match result.\n// 'listener' must not be NULL.\n// Value cannot be passed by const reference, because some matchers take a\n// non-const argument.\ntemplate <typename Value, typename T>\nbool MatchPrintAndExplain(Value& value, const Matcher<T>& matcher,\n                          MatchResultListener* listener) {\n  if (!listener->IsInterested()) {\n    // If the listener is not interested, we do not need to construct the\n    // inner explanation.\n    return matcher.Matches(value);\n  }\n\n  StringMatchResultListener inner_listener;\n  const bool match = matcher.MatchAndExplain(value, &inner_listener);\n\n  UniversalPrint(value, listener->stream());\n#if GTEST_HAS_RTTI\n  const string& type_name = GetTypeName<Value>();\n  if (IsReadableTypeName(type_name))\n    *listener->stream() << \" (of type \" << type_name << \")\";\n#endif\n  PrintIfNotEmpty(inner_listener.str(), listener->stream());\n\n  return match;\n}\n\n// An internal helper class for doing compile-time loop on a tuple's\n// fields.\ntemplate <size_t N>\nclass TuplePrefix {\n public:\n  // TuplePrefix<N>::Matches(matcher_tuple, value_tuple) returns true\n  // iff the first N fields of matcher_tuple matches the first N\n  // fields of value_tuple, respectively.\n  template <typename MatcherTuple, typename ValueTuple>\n  static bool Matches(const MatcherTuple& matcher_tuple,\n                      const ValueTuple& value_tuple) {\n    using ::std::tr1::get;\n    return TuplePrefix<N - 1>::Matches(matcher_tuple, value_tuple)\n        && get<N - 1>(matcher_tuple).Matches(get<N - 1>(value_tuple));\n  }\n\n  // TuplePrefix<N>::ExplainMatchFailuresTo(matchers, values, os)\n  // describes failures in matching the first N fields of matchers\n  // against the first N fields of values.  If there is no failure,\n  // nothing will be streamed to os.\n  template <typename MatcherTuple, typename ValueTuple>\n  static void ExplainMatchFailuresTo(const MatcherTuple& matchers,\n                                     const ValueTuple& values,\n                                     ::std::ostream* os) {\n    using ::std::tr1::tuple_element;\n    using ::std::tr1::get;\n\n    // First, describes failures in the first N - 1 fields.\n    TuplePrefix<N - 1>::ExplainMatchFailuresTo(matchers, values, os);\n\n    // Then describes the failure (if any) in the (N - 1)-th (0-based)\n    // field.\n    typename tuple_element<N - 1, MatcherTuple>::type matcher =\n        get<N - 1>(matchers);\n    typedef typename tuple_element<N - 1, ValueTuple>::type Value;\n    Value value = get<N - 1>(values);\n    StringMatchResultListener listener;\n    if (!matcher.MatchAndExplain(value, &listener)) {\n      // TODO(wan): include in the message the name of the parameter\n      // as used in MOCK_METHOD*() when possible.\n      *os << \"  Expected arg #\" << N - 1 << \": \";\n      get<N - 1>(matchers).DescribeTo(os);\n      *os << \"\\n           Actual: \";\n      // We remove the reference in type Value to prevent the\n      // universal printer from printing the address of value, which\n      // isn't interesting to the user most of the time.  The\n      // matcher's MatchAndExplain() method handles the case when\n      // the address is interesting.\n      internal::UniversalPrint(value, os);\n      PrintIfNotEmpty(listener.str(), os);\n      *os << \"\\n\";\n    }\n  }\n};\n\n// The base case.\ntemplate <>\nclass TuplePrefix<0> {\n public:\n  template <typename MatcherTuple, typename ValueTuple>\n  static bool Matches(const MatcherTuple& /* matcher_tuple */,\n                      const ValueTuple& /* value_tuple */) {\n    return true;\n  }\n\n  template <typename MatcherTuple, typename ValueTuple>\n  static void ExplainMatchFailuresTo(const MatcherTuple& /* matchers */,\n                                     const ValueTuple& /* values */,\n                                     ::std::ostream* /* os */) {}\n};\n\n// TupleMatches(matcher_tuple, value_tuple) returns true iff all\n// matchers in matcher_tuple match the corresponding fields in\n// value_tuple.  It is a compiler error if matcher_tuple and\n// value_tuple have different number of fields or incompatible field\n// types.\ntemplate <typename MatcherTuple, typename ValueTuple>\nbool TupleMatches(const MatcherTuple& matcher_tuple,\n                  const ValueTuple& value_tuple) {\n  using ::std::tr1::tuple_size;\n  // Makes sure that matcher_tuple and value_tuple have the same\n  // number of fields.\n  GTEST_COMPILE_ASSERT_(tuple_size<MatcherTuple>::value ==\n                        tuple_size<ValueTuple>::value,\n                        matcher_and_value_have_different_numbers_of_fields);\n  return TuplePrefix<tuple_size<ValueTuple>::value>::\n      Matches(matcher_tuple, value_tuple);\n}\n\n// Describes failures in matching matchers against values.  If there\n// is no failure, nothing will be streamed to os.\ntemplate <typename MatcherTuple, typename ValueTuple>\nvoid ExplainMatchFailureTupleTo(const MatcherTuple& matchers,\n                                const ValueTuple& values,\n                                ::std::ostream* os) {\n  using ::std::tr1::tuple_size;\n  TuplePrefix<tuple_size<MatcherTuple>::value>::ExplainMatchFailuresTo(\n      matchers, values, os);\n}\n\n// TransformTupleValues and its helper.\n//\n// TransformTupleValuesHelper hides the internal machinery that\n// TransformTupleValues uses to implement a tuple traversal.\ntemplate <typename Tuple, typename Func, typename OutIter>\nclass TransformTupleValuesHelper {\n private:\n  typedef typename ::std::tr1::tuple_size<Tuple> TupleSize;\n\n public:\n  // For each member of tuple 't', taken in order, evaluates '*out++ = f(t)'.\n  // Returns the final value of 'out' in case the caller needs it.\n  static OutIter Run(Func f, const Tuple& t, OutIter out) {\n    return IterateOverTuple<Tuple, TupleSize::value>()(f, t, out);\n  }\n\n private:\n  template <typename Tup, size_t kRemainingSize>\n  struct IterateOverTuple {\n    OutIter operator() (Func f, const Tup& t, OutIter out) const {\n      *out++ = f(::std::tr1::get<TupleSize::value - kRemainingSize>(t));\n      return IterateOverTuple<Tup, kRemainingSize - 1>()(f, t, out);\n    }\n  };\n  template <typename Tup>\n  struct IterateOverTuple<Tup, 0> {\n    OutIter operator() (Func /* f */, const Tup& /* t */, OutIter out) const {\n      return out;\n    }\n  };\n};\n\n// Successively invokes 'f(element)' on each element of the tuple 't',\n// appending each result to the 'out' iterator. Returns the final value\n// of 'out'.\ntemplate <typename Tuple, typename Func, typename OutIter>\nOutIter TransformTupleValues(Func f, const Tuple& t, OutIter out) {\n  return TransformTupleValuesHelper<Tuple, Func, OutIter>::Run(f, t, out);\n}\n\n// Implements A<T>().\ntemplate <typename T>\nclass AnyMatcherImpl : public MatcherInterface<T> {\n public:\n  virtual bool MatchAndExplain(\n      T /* x */, MatchResultListener* /* listener */) const { return true; }\n  virtual void DescribeTo(::std::ostream* os) const { *os << \"is anything\"; }\n  virtual void DescribeNegationTo(::std::ostream* os) const {\n    // This is mostly for completeness' safe, as it's not very useful\n    // to write Not(A<bool>()).  However we cannot completely rule out\n    // such a possibility, and it doesn't hurt to be prepared.\n    *os << \"never matches\";\n  }\n};\n\n// Implements _, a matcher that matches any value of any\n// type.  This is a polymorphic matcher, so we need a template type\n// conversion operator to make it appearing as a Matcher<T> for any\n// type T.\nclass AnythingMatcher {\n public:\n  template <typename T>\n  operator Matcher<T>() const { return A<T>(); }\n};\n\n// Implements a matcher that compares a given value with a\n// pre-supplied value using one of the ==, <=, <, etc, operators.  The\n// two values being compared don't have to have the same type.\n//\n// The matcher defined here is polymorphic (for example, Eq(5) can be\n// used to match an int, a short, a double, etc).  Therefore we use\n// a template type conversion operator in the implementation.\n//\n// We define this as a macro in order to eliminate duplicated source\n// code.\n//\n// The following template definition assumes that the Rhs parameter is\n// a \"bare\" type (i.e. neither 'const T' nor 'T&').\n#define GMOCK_IMPLEMENT_COMPARISON_MATCHER_( \\\n    name, op, relation, negated_relation) \\\n  template <typename Rhs> class name##Matcher { \\\n   public: \\\n    explicit name##Matcher(const Rhs& rhs) : rhs_(rhs) {} \\\n    template <typename Lhs> \\\n    operator Matcher<Lhs>() const { \\\n      return MakeMatcher(new Impl<Lhs>(rhs_)); \\\n    } \\\n   private: \\\n    template <typename Lhs> \\\n    class Impl : public MatcherInterface<Lhs> { \\\n     public: \\\n      explicit Impl(const Rhs& rhs) : rhs_(rhs) {} \\\n      virtual bool MatchAndExplain(\\\n          Lhs lhs, MatchResultListener* /* listener */) const { \\\n        return lhs op rhs_; \\\n      } \\\n      virtual void DescribeTo(::std::ostream* os) const { \\\n        *os << relation  \" \"; \\\n        UniversalPrint(rhs_, os); \\\n      } \\\n      virtual void DescribeNegationTo(::std::ostream* os) const { \\\n        *os << negated_relation  \" \"; \\\n        UniversalPrint(rhs_, os); \\\n      } \\\n     private: \\\n      Rhs rhs_; \\\n      GTEST_DISALLOW_ASSIGN_(Impl); \\\n    }; \\\n    Rhs rhs_; \\\n    GTEST_DISALLOW_ASSIGN_(name##Matcher); \\\n  }\n\n// Implements Eq(v), Ge(v), Gt(v), Le(v), Lt(v), and Ne(v)\n// respectively.\nGMOCK_IMPLEMENT_COMPARISON_MATCHER_(Eq, ==, \"is equal to\", \"isn't equal to\");\nGMOCK_IMPLEMENT_COMPARISON_MATCHER_(Ge, >=, \"is >=\", \"isn't >=\");\nGMOCK_IMPLEMENT_COMPARISON_MATCHER_(Gt, >, \"is >\", \"isn't >\");\nGMOCK_IMPLEMENT_COMPARISON_MATCHER_(Le, <=, \"is <=\", \"isn't <=\");\nGMOCK_IMPLEMENT_COMPARISON_MATCHER_(Lt, <, \"is <\", \"isn't <\");\nGMOCK_IMPLEMENT_COMPARISON_MATCHER_(Ne, !=, \"isn't equal to\", \"is equal to\");\n\n#undef GMOCK_IMPLEMENT_COMPARISON_MATCHER_\n\n// Implements the polymorphic IsNull() matcher, which matches any raw or smart\n// pointer that is NULL.\nclass IsNullMatcher {\n public:\n  template <typename Pointer>\n  bool MatchAndExplain(const Pointer& p,\n                       MatchResultListener* /* listener */) const {\n    return GetRawPointer(p) == NULL;\n  }\n\n  void DescribeTo(::std::ostream* os) const { *os << \"is NULL\"; }\n  void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"isn't NULL\";\n  }\n};\n\n// Implements the polymorphic NotNull() matcher, which matches any raw or smart\n// pointer that is not NULL.\nclass NotNullMatcher {\n public:\n  template <typename Pointer>\n  bool MatchAndExplain(const Pointer& p,\n                       MatchResultListener* /* listener */) const {\n    return GetRawPointer(p) != NULL;\n  }\n\n  void DescribeTo(::std::ostream* os) const { *os << \"isn't NULL\"; }\n  void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"is NULL\";\n  }\n};\n\n// Ref(variable) matches any argument that is a reference to\n// 'variable'.  This matcher is polymorphic as it can match any\n// super type of the type of 'variable'.\n//\n// The RefMatcher template class implements Ref(variable).  It can\n// only be instantiated with a reference type.  This prevents a user\n// from mistakenly using Ref(x) to match a non-reference function\n// argument.  For example, the following will righteously cause a\n// compiler error:\n//\n//   int n;\n//   Matcher<int> m1 = Ref(n);   // This won't compile.\n//   Matcher<int&> m2 = Ref(n);  // This will compile.\ntemplate <typename T>\nclass RefMatcher;\n\ntemplate <typename T>\nclass RefMatcher<T&> {\n  // Google Mock is a generic framework and thus needs to support\n  // mocking any function types, including those that take non-const\n  // reference arguments.  Therefore the template parameter T (and\n  // Super below) can be instantiated to either a const type or a\n  // non-const type.\n public:\n  // RefMatcher() takes a T& instead of const T&, as we want the\n  // compiler to catch using Ref(const_value) as a matcher for a\n  // non-const reference.\n  explicit RefMatcher(T& x) : object_(x) {}  // NOLINT\n\n  template <typename Super>\n  operator Matcher<Super&>() const {\n    // By passing object_ (type T&) to Impl(), which expects a Super&,\n    // we make sure that Super is a super type of T.  In particular,\n    // this catches using Ref(const_value) as a matcher for a\n    // non-const reference, as you cannot implicitly convert a const\n    // reference to a non-const reference.\n    return MakeMatcher(new Impl<Super>(object_));\n  }\n\n private:\n  template <typename Super>\n  class Impl : public MatcherInterface<Super&> {\n   public:\n    explicit Impl(Super& x) : object_(x) {}  // NOLINT\n\n    // MatchAndExplain() takes a Super& (as opposed to const Super&)\n    // in order to match the interface MatcherInterface<Super&>.\n    virtual bool MatchAndExplain(\n        Super& x, MatchResultListener* listener) const {\n      *listener << \"which is located @\" << static_cast<const void*>(&x);\n      return &x == &object_;\n    }\n\n    virtual void DescribeTo(::std::ostream* os) const {\n      *os << \"references the variable \";\n      UniversalPrinter<Super&>::Print(object_, os);\n    }\n\n    virtual void DescribeNegationTo(::std::ostream* os) const {\n      *os << \"does not reference the variable \";\n      UniversalPrinter<Super&>::Print(object_, os);\n    }\n\n   private:\n    const Super& object_;\n\n    GTEST_DISALLOW_ASSIGN_(Impl);\n  };\n\n  T& object_;\n\n  GTEST_DISALLOW_ASSIGN_(RefMatcher);\n};\n\n// Polymorphic helper functions for narrow and wide string matchers.\ninline bool CaseInsensitiveCStringEquals(const char* lhs, const char* rhs) {\n  return String::CaseInsensitiveCStringEquals(lhs, rhs);\n}\n\ninline bool CaseInsensitiveCStringEquals(const wchar_t* lhs,\n                                         const wchar_t* rhs) {\n  return String::CaseInsensitiveWideCStringEquals(lhs, rhs);\n}\n\n// String comparison for narrow or wide strings that can have embedded NUL\n// characters.\ntemplate <typename StringType>\nbool CaseInsensitiveStringEquals(const StringType& s1,\n                                 const StringType& s2) {\n  // Are the heads equal?\n  if (!CaseInsensitiveCStringEquals(s1.c_str(), s2.c_str())) {\n    return false;\n  }\n\n  // Skip the equal heads.\n  const typename StringType::value_type nul = 0;\n  const size_t i1 = s1.find(nul), i2 = s2.find(nul);\n\n  // Are we at the end of either s1 or s2?\n  if (i1 == StringType::npos || i2 == StringType::npos) {\n    return i1 == i2;\n  }\n\n  // Are the tails equal?\n  return CaseInsensitiveStringEquals(s1.substr(i1 + 1), s2.substr(i2 + 1));\n}\n\n// String matchers.\n\n// Implements equality-based string matchers like StrEq, StrCaseNe, and etc.\ntemplate <typename StringType>\nclass StrEqualityMatcher {\n public:\n  StrEqualityMatcher(const StringType& str, bool expect_eq,\n                     bool case_sensitive)\n      : string_(str), expect_eq_(expect_eq), case_sensitive_(case_sensitive) {}\n\n  // Accepts pointer types, particularly:\n  //   const char*\n  //   char*\n  //   const wchar_t*\n  //   wchar_t*\n  template <typename CharType>\n  bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {\n    if (s == NULL) {\n      return !expect_eq_;\n    }\n    return MatchAndExplain(StringType(s), listener);\n  }\n\n  // Matches anything that can convert to StringType.\n  //\n  // This is a template, not just a plain function with const StringType&,\n  // because StringPiece has some interfering non-explicit constructors.\n  template <typename MatcheeStringType>\n  bool MatchAndExplain(const MatcheeStringType& s,\n                       MatchResultListener* /* listener */) const {\n    const StringType& s2(s);\n    const bool eq = case_sensitive_ ? s2 == string_ :\n        CaseInsensitiveStringEquals(s2, string_);\n    return expect_eq_ == eq;\n  }\n\n  void DescribeTo(::std::ostream* os) const {\n    DescribeToHelper(expect_eq_, os);\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const {\n    DescribeToHelper(!expect_eq_, os);\n  }\n\n private:\n  void DescribeToHelper(bool expect_eq, ::std::ostream* os) const {\n    *os << (expect_eq ? \"is \" : \"isn't \");\n    *os << \"equal to \";\n    if (!case_sensitive_) {\n      *os << \"(ignoring case) \";\n    }\n    UniversalPrint(string_, os);\n  }\n\n  const StringType string_;\n  const bool expect_eq_;\n  const bool case_sensitive_;\n\n  GTEST_DISALLOW_ASSIGN_(StrEqualityMatcher);\n};\n\n// Implements the polymorphic HasSubstr(substring) matcher, which\n// can be used as a Matcher<T> as long as T can be converted to a\n// string.\ntemplate <typename StringType>\nclass HasSubstrMatcher {\n public:\n  explicit HasSubstrMatcher(const StringType& substring)\n      : substring_(substring) {}\n\n  // Accepts pointer types, particularly:\n  //   const char*\n  //   char*\n  //   const wchar_t*\n  //   wchar_t*\n  template <typename CharType>\n  bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {\n    return s != NULL && MatchAndExplain(StringType(s), listener);\n  }\n\n  // Matches anything that can convert to StringType.\n  //\n  // This is a template, not just a plain function with const StringType&,\n  // because StringPiece has some interfering non-explicit constructors.\n  template <typename MatcheeStringType>\n  bool MatchAndExplain(const MatcheeStringType& s,\n                       MatchResultListener* /* listener */) const {\n    const StringType& s2(s);\n    return s2.find(substring_) != StringType::npos;\n  }\n\n  // Describes what this matcher matches.\n  void DescribeTo(::std::ostream* os) const {\n    *os << \"has substring \";\n    UniversalPrint(substring_, os);\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"has no substring \";\n    UniversalPrint(substring_, os);\n  }\n\n private:\n  const StringType substring_;\n\n  GTEST_DISALLOW_ASSIGN_(HasSubstrMatcher);\n};\n\n// Implements the polymorphic StartsWith(substring) matcher, which\n// can be used as a Matcher<T> as long as T can be converted to a\n// string.\ntemplate <typename StringType>\nclass StartsWithMatcher {\n public:\n  explicit StartsWithMatcher(const StringType& prefix) : prefix_(prefix) {\n  }\n\n  // Accepts pointer types, particularly:\n  //   const char*\n  //   char*\n  //   const wchar_t*\n  //   wchar_t*\n  template <typename CharType>\n  bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {\n    return s != NULL && MatchAndExplain(StringType(s), listener);\n  }\n\n  // Matches anything that can convert to StringType.\n  //\n  // This is a template, not just a plain function with const StringType&,\n  // because StringPiece has some interfering non-explicit constructors.\n  template <typename MatcheeStringType>\n  bool MatchAndExplain(const MatcheeStringType& s,\n                       MatchResultListener* /* listener */) const {\n    const StringType& s2(s);\n    return s2.length() >= prefix_.length() &&\n        s2.substr(0, prefix_.length()) == prefix_;\n  }\n\n  void DescribeTo(::std::ostream* os) const {\n    *os << \"starts with \";\n    UniversalPrint(prefix_, os);\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"doesn't start with \";\n    UniversalPrint(prefix_, os);\n  }\n\n private:\n  const StringType prefix_;\n\n  GTEST_DISALLOW_ASSIGN_(StartsWithMatcher);\n};\n\n// Implements the polymorphic EndsWith(substring) matcher, which\n// can be used as a Matcher<T> as long as T can be converted to a\n// string.\ntemplate <typename StringType>\nclass EndsWithMatcher {\n public:\n  explicit EndsWithMatcher(const StringType& suffix) : suffix_(suffix) {}\n\n  // Accepts pointer types, particularly:\n  //   const char*\n  //   char*\n  //   const wchar_t*\n  //   wchar_t*\n  template <typename CharType>\n  bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {\n    return s != NULL && MatchAndExplain(StringType(s), listener);\n  }\n\n  // Matches anything that can convert to StringType.\n  //\n  // This is a template, not just a plain function with const StringType&,\n  // because StringPiece has some interfering non-explicit constructors.\n  template <typename MatcheeStringType>\n  bool MatchAndExplain(const MatcheeStringType& s,\n                       MatchResultListener* /* listener */) const {\n    const StringType& s2(s);\n    return s2.length() >= suffix_.length() &&\n        s2.substr(s2.length() - suffix_.length()) == suffix_;\n  }\n\n  void DescribeTo(::std::ostream* os) const {\n    *os << \"ends with \";\n    UniversalPrint(suffix_, os);\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"doesn't end with \";\n    UniversalPrint(suffix_, os);\n  }\n\n private:\n  const StringType suffix_;\n\n  GTEST_DISALLOW_ASSIGN_(EndsWithMatcher);\n};\n\n// Implements polymorphic matchers MatchesRegex(regex) and\n// ContainsRegex(regex), which can be used as a Matcher<T> as long as\n// T can be converted to a string.\nclass MatchesRegexMatcher {\n public:\n  MatchesRegexMatcher(const RE* regex, bool full_match)\n      : regex_(regex), full_match_(full_match) {}\n\n  // Accepts pointer types, particularly:\n  //   const char*\n  //   char*\n  //   const wchar_t*\n  //   wchar_t*\n  template <typename CharType>\n  bool MatchAndExplain(CharType* s, MatchResultListener* listener) const {\n    return s != NULL && MatchAndExplain(internal::string(s), listener);\n  }\n\n  // Matches anything that can convert to internal::string.\n  //\n  // This is a template, not just a plain function with const internal::string&,\n  // because StringPiece has some interfering non-explicit constructors.\n  template <class MatcheeStringType>\n  bool MatchAndExplain(const MatcheeStringType& s,\n                       MatchResultListener* /* listener */) const {\n    const internal::string& s2(s);\n    return full_match_ ? RE::FullMatch(s2, *regex_) :\n        RE::PartialMatch(s2, *regex_);\n  }\n\n  void DescribeTo(::std::ostream* os) const {\n    *os << (full_match_ ? \"matches\" : \"contains\")\n        << \" regular expression \";\n    UniversalPrinter<internal::string>::Print(regex_->pattern(), os);\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"doesn't \" << (full_match_ ? \"match\" : \"contain\")\n        << \" regular expression \";\n    UniversalPrinter<internal::string>::Print(regex_->pattern(), os);\n  }\n\n private:\n  const internal::linked_ptr<const RE> regex_;\n  const bool full_match_;\n\n  GTEST_DISALLOW_ASSIGN_(MatchesRegexMatcher);\n};\n\n// Implements a matcher that compares the two fields of a 2-tuple\n// using one of the ==, <=, <, etc, operators.  The two fields being\n// compared don't have to have the same type.\n//\n// The matcher defined here is polymorphic (for example, Eq() can be\n// used to match a tuple<int, short>, a tuple<const long&, double>,\n// etc).  Therefore we use a template type conversion operator in the\n// implementation.\n//\n// We define this as a macro in order to eliminate duplicated source\n// code.\n#define GMOCK_IMPLEMENT_COMPARISON2_MATCHER_(name, op, relation) \\\n  class name##2Matcher { \\\n   public: \\\n    template <typename T1, typename T2> \\\n    operator Matcher< ::std::tr1::tuple<T1, T2> >() const { \\\n      return MakeMatcher(new Impl< ::std::tr1::tuple<T1, T2> >); \\\n    } \\\n    template <typename T1, typename T2> \\\n    operator Matcher<const ::std::tr1::tuple<T1, T2>&>() const { \\\n      return MakeMatcher(new Impl<const ::std::tr1::tuple<T1, T2>&>); \\\n    } \\\n   private: \\\n    template <typename Tuple> \\\n    class Impl : public MatcherInterface<Tuple> { \\\n     public: \\\n      virtual bool MatchAndExplain( \\\n          Tuple args, \\\n          MatchResultListener* /* listener */) const { \\\n        return ::std::tr1::get<0>(args) op ::std::tr1::get<1>(args); \\\n      } \\\n      virtual void DescribeTo(::std::ostream* os) const { \\\n        *os << \"are \" relation;                                 \\\n      } \\\n      virtual void DescribeNegationTo(::std::ostream* os) const { \\\n        *os << \"aren't \" relation; \\\n      } \\\n    }; \\\n  }\n\n// Implements Eq(), Ge(), Gt(), Le(), Lt(), and Ne() respectively.\nGMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Eq, ==, \"an equal pair\");\nGMOCK_IMPLEMENT_COMPARISON2_MATCHER_(\n    Ge, >=, \"a pair where the first >= the second\");\nGMOCK_IMPLEMENT_COMPARISON2_MATCHER_(\n    Gt, >, \"a pair where the first > the second\");\nGMOCK_IMPLEMENT_COMPARISON2_MATCHER_(\n    Le, <=, \"a pair where the first <= the second\");\nGMOCK_IMPLEMENT_COMPARISON2_MATCHER_(\n    Lt, <, \"a pair where the first < the second\");\nGMOCK_IMPLEMENT_COMPARISON2_MATCHER_(Ne, !=, \"an unequal pair\");\n\n#undef GMOCK_IMPLEMENT_COMPARISON2_MATCHER_\n\n// Implements the Not(...) matcher for a particular argument type T.\n// We do not nest it inside the NotMatcher class template, as that\n// will prevent different instantiations of NotMatcher from sharing\n// the same NotMatcherImpl<T> class.\ntemplate <typename T>\nclass NotMatcherImpl : public MatcherInterface<T> {\n public:\n  explicit NotMatcherImpl(const Matcher<T>& matcher)\n      : matcher_(matcher) {}\n\n  virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {\n    return !matcher_.MatchAndExplain(x, listener);\n  }\n\n  virtual void DescribeTo(::std::ostream* os) const {\n    matcher_.DescribeNegationTo(os);\n  }\n\n  virtual void DescribeNegationTo(::std::ostream* os) const {\n    matcher_.DescribeTo(os);\n  }\n\n private:\n  const Matcher<T> matcher_;\n\n  GTEST_DISALLOW_ASSIGN_(NotMatcherImpl);\n};\n\n// Implements the Not(m) matcher, which matches a value that doesn't\n// match matcher m.\ntemplate <typename InnerMatcher>\nclass NotMatcher {\n public:\n  explicit NotMatcher(InnerMatcher matcher) : matcher_(matcher) {}\n\n  // This template type conversion operator allows Not(m) to be used\n  // to match any type m can match.\n  template <typename T>\n  operator Matcher<T>() const {\n    return Matcher<T>(new NotMatcherImpl<T>(SafeMatcherCast<T>(matcher_)));\n  }\n\n private:\n  InnerMatcher matcher_;\n\n  GTEST_DISALLOW_ASSIGN_(NotMatcher);\n};\n\n// Implements the AllOf(m1, m2) matcher for a particular argument type\n// T. We do not nest it inside the BothOfMatcher class template, as\n// that will prevent different instantiations of BothOfMatcher from\n// sharing the same BothOfMatcherImpl<T> class.\ntemplate <typename T>\nclass BothOfMatcherImpl : public MatcherInterface<T> {\n public:\n  BothOfMatcherImpl(const Matcher<T>& matcher1, const Matcher<T>& matcher2)\n      : matcher1_(matcher1), matcher2_(matcher2) {}\n\n  virtual void DescribeTo(::std::ostream* os) const {\n    *os << \"(\";\n    matcher1_.DescribeTo(os);\n    *os << \") and (\";\n    matcher2_.DescribeTo(os);\n    *os << \")\";\n  }\n\n  virtual void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"(\";\n    matcher1_.DescribeNegationTo(os);\n    *os << \") or (\";\n    matcher2_.DescribeNegationTo(os);\n    *os << \")\";\n  }\n\n  virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {\n    // If either matcher1_ or matcher2_ doesn't match x, we only need\n    // to explain why one of them fails.\n    StringMatchResultListener listener1;\n    if (!matcher1_.MatchAndExplain(x, &listener1)) {\n      *listener << listener1.str();\n      return false;\n    }\n\n    StringMatchResultListener listener2;\n    if (!matcher2_.MatchAndExplain(x, &listener2)) {\n      *listener << listener2.str();\n      return false;\n    }\n\n    // Otherwise we need to explain why *both* of them match.\n    const internal::string s1 = listener1.str();\n    const internal::string s2 = listener2.str();\n\n    if (s1 == \"\") {\n      *listener << s2;\n    } else {\n      *listener << s1;\n      if (s2 != \"\") {\n        *listener << \", and \" << s2;\n      }\n    }\n    return true;\n  }\n\n private:\n  const Matcher<T> matcher1_;\n  const Matcher<T> matcher2_;\n\n  GTEST_DISALLOW_ASSIGN_(BothOfMatcherImpl);\n};\n\n#if GTEST_LANG_CXX11\n// MatcherList provides mechanisms for storing a variable number of matchers in\n// a list structure (ListType) and creating a combining matcher from such a\n// list.\n// The template is defined recursively using the following template paramters:\n//   * kSize is the length of the MatcherList.\n//   * Head is the type of the first matcher of the list.\n//   * Tail denotes the types of the remaining matchers of the list.\ntemplate <int kSize, typename Head, typename... Tail>\nstruct MatcherList {\n  typedef MatcherList<kSize - 1, Tail...> MatcherListTail;\n  typedef ::std::pair<Head, typename MatcherListTail::ListType> ListType;\n\n  // BuildList stores variadic type values in a nested pair structure.\n  // Example:\n  // MatcherList<3, int, string, float>::BuildList(5, \"foo\", 2.0) will return\n  // the corresponding result of type pair<int, pair<string, float>>.\n  static ListType BuildList(const Head& matcher, const Tail&... tail) {\n    return ListType(matcher, MatcherListTail::BuildList(tail...));\n  }\n\n  // CreateMatcher<T> creates a Matcher<T> from a given list of matchers (built\n  // by BuildList()). CombiningMatcher<T> is used to combine the matchers of the\n  // list. CombiningMatcher<T> must implement MatcherInterface<T> and have a\n  // constructor taking two Matcher<T>s as input.\n  template <typename T, template <typename /* T */> class CombiningMatcher>\n  static Matcher<T> CreateMatcher(const ListType& matchers) {\n    return Matcher<T>(new CombiningMatcher<T>(\n        SafeMatcherCast<T>(matchers.first),\n        MatcherListTail::template CreateMatcher<T, CombiningMatcher>(\n            matchers.second)));\n  }\n};\n\n// The following defines the base case for the recursive definition of\n// MatcherList.\ntemplate <typename Matcher1, typename Matcher2>\nstruct MatcherList<2, Matcher1, Matcher2> {\n  typedef ::std::pair<Matcher1, Matcher2> ListType;\n\n  static ListType BuildList(const Matcher1& matcher1,\n                            const Matcher2& matcher2) {\n    return ::std::pair<Matcher1, Matcher2>(matcher1, matcher2);\n  }\n\n  template <typename T, template <typename /* T */> class CombiningMatcher>\n  static Matcher<T> CreateMatcher(const ListType& matchers) {\n    return Matcher<T>(new CombiningMatcher<T>(\n        SafeMatcherCast<T>(matchers.first),\n        SafeMatcherCast<T>(matchers.second)));\n  }\n};\n\n// VariadicMatcher is used for the variadic implementation of\n// AllOf(m_1, m_2, ...) and AnyOf(m_1, m_2, ...).\n// CombiningMatcher<T> is used to recursively combine the provided matchers\n// (of type Args...).\ntemplate <template <typename T> class CombiningMatcher, typename... Args>\nclass VariadicMatcher {\n public:\n  VariadicMatcher(const Args&... matchers)  // NOLINT\n      : matchers_(MatcherListType::BuildList(matchers...)) {}\n\n  // This template type conversion operator allows an\n  // VariadicMatcher<Matcher1, Matcher2...> object to match any type that\n  // all of the provided matchers (Matcher1, Matcher2, ...) can match.\n  template <typename T>\n  operator Matcher<T>() const {\n    return MatcherListType::template CreateMatcher<T, CombiningMatcher>(\n        matchers_);\n  }\n\n private:\n  typedef MatcherList<sizeof...(Args), Args...> MatcherListType;\n\n  const typename MatcherListType::ListType matchers_;\n\n  GTEST_DISALLOW_ASSIGN_(VariadicMatcher);\n};\n\ntemplate <typename... Args>\nusing AllOfMatcher = VariadicMatcher<BothOfMatcherImpl, Args...>;\n\n#endif  // GTEST_LANG_CXX11\n\n// Used for implementing the AllOf(m_1, ..., m_n) matcher, which\n// matches a value that matches all of the matchers m_1, ..., and m_n.\ntemplate <typename Matcher1, typename Matcher2>\nclass BothOfMatcher {\n public:\n  BothOfMatcher(Matcher1 matcher1, Matcher2 matcher2)\n      : matcher1_(matcher1), matcher2_(matcher2) {}\n\n  // This template type conversion operator allows a\n  // BothOfMatcher<Matcher1, Matcher2> object to match any type that\n  // both Matcher1 and Matcher2 can match.\n  template <typename T>\n  operator Matcher<T>() const {\n    return Matcher<T>(new BothOfMatcherImpl<T>(SafeMatcherCast<T>(matcher1_),\n                                               SafeMatcherCast<T>(matcher2_)));\n  }\n\n private:\n  Matcher1 matcher1_;\n  Matcher2 matcher2_;\n\n  GTEST_DISALLOW_ASSIGN_(BothOfMatcher);\n};\n\n// Implements the AnyOf(m1, m2) matcher for a particular argument type\n// T.  We do not nest it inside the AnyOfMatcher class template, as\n// that will prevent different instantiations of AnyOfMatcher from\n// sharing the same EitherOfMatcherImpl<T> class.\ntemplate <typename T>\nclass EitherOfMatcherImpl : public MatcherInterface<T> {\n public:\n  EitherOfMatcherImpl(const Matcher<T>& matcher1, const Matcher<T>& matcher2)\n      : matcher1_(matcher1), matcher2_(matcher2) {}\n\n  virtual void DescribeTo(::std::ostream* os) const {\n    *os << \"(\";\n    matcher1_.DescribeTo(os);\n    *os << \") or (\";\n    matcher2_.DescribeTo(os);\n    *os << \")\";\n  }\n\n  virtual void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"(\";\n    matcher1_.DescribeNegationTo(os);\n    *os << \") and (\";\n    matcher2_.DescribeNegationTo(os);\n    *os << \")\";\n  }\n\n  virtual bool MatchAndExplain(T x, MatchResultListener* listener) const {\n    // If either matcher1_ or matcher2_ matches x, we just need to\n    // explain why *one* of them matches.\n    StringMatchResultListener listener1;\n    if (matcher1_.MatchAndExplain(x, &listener1)) {\n      *listener << listener1.str();\n      return true;\n    }\n\n    StringMatchResultListener listener2;\n    if (matcher2_.MatchAndExplain(x, &listener2)) {\n      *listener << listener2.str();\n      return true;\n    }\n\n    // Otherwise we need to explain why *both* of them fail.\n    const internal::string s1 = listener1.str();\n    const internal::string s2 = listener2.str();\n\n    if (s1 == \"\") {\n      *listener << s2;\n    } else {\n      *listener << s1;\n      if (s2 != \"\") {\n        *listener << \", and \" << s2;\n      }\n    }\n    return false;\n  }\n\n private:\n  const Matcher<T> matcher1_;\n  const Matcher<T> matcher2_;\n\n  GTEST_DISALLOW_ASSIGN_(EitherOfMatcherImpl);\n};\n\n#if GTEST_LANG_CXX11\n// AnyOfMatcher is used for the variadic implementation of AnyOf(m_1, m_2, ...).\ntemplate <typename... Args>\nusing AnyOfMatcher = VariadicMatcher<EitherOfMatcherImpl, Args...>;\n\n#endif  // GTEST_LANG_CXX11\n\n// Used for implementing the AnyOf(m_1, ..., m_n) matcher, which\n// matches a value that matches at least one of the matchers m_1, ...,\n// and m_n.\ntemplate <typename Matcher1, typename Matcher2>\nclass EitherOfMatcher {\n public:\n  EitherOfMatcher(Matcher1 matcher1, Matcher2 matcher2)\n      : matcher1_(matcher1), matcher2_(matcher2) {}\n\n  // This template type conversion operator allows a\n  // EitherOfMatcher<Matcher1, Matcher2> object to match any type that\n  // both Matcher1 and Matcher2 can match.\n  template <typename T>\n  operator Matcher<T>() const {\n    return Matcher<T>(new EitherOfMatcherImpl<T>(\n        SafeMatcherCast<T>(matcher1_), SafeMatcherCast<T>(matcher2_)));\n  }\n\n private:\n  Matcher1 matcher1_;\n  Matcher2 matcher2_;\n\n  GTEST_DISALLOW_ASSIGN_(EitherOfMatcher);\n};\n\n// Used for implementing Truly(pred), which turns a predicate into a\n// matcher.\ntemplate <typename Predicate>\nclass TrulyMatcher {\n public:\n  explicit TrulyMatcher(Predicate pred) : predicate_(pred) {}\n\n  // This method template allows Truly(pred) to be used as a matcher\n  // for type T where T is the argument type of predicate 'pred'.  The\n  // argument is passed by reference as the predicate may be\n  // interested in the address of the argument.\n  template <typename T>\n  bool MatchAndExplain(T& x,  // NOLINT\n                       MatchResultListener* /* listener */) const {\n    // Without the if-statement, MSVC sometimes warns about converting\n    // a value to bool (warning 4800).\n    //\n    // We cannot write 'return !!predicate_(x);' as that doesn't work\n    // when predicate_(x) returns a class convertible to bool but\n    // having no operator!().\n    if (predicate_(x))\n      return true;\n    return false;\n  }\n\n  void DescribeTo(::std::ostream* os) const {\n    *os << \"satisfies the given predicate\";\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"doesn't satisfy the given predicate\";\n  }\n\n private:\n  Predicate predicate_;\n\n  GTEST_DISALLOW_ASSIGN_(TrulyMatcher);\n};\n\n// Used for implementing Matches(matcher), which turns a matcher into\n// a predicate.\ntemplate <typename M>\nclass MatcherAsPredicate {\n public:\n  explicit MatcherAsPredicate(M matcher) : matcher_(matcher) {}\n\n  // This template operator() allows Matches(m) to be used as a\n  // predicate on type T where m is a matcher on type T.\n  //\n  // The argument x is passed by reference instead of by value, as\n  // some matcher may be interested in its address (e.g. as in\n  // Matches(Ref(n))(x)).\n  template <typename T>\n  bool operator()(const T& x) const {\n    // We let matcher_ commit to a particular type here instead of\n    // when the MatcherAsPredicate object was constructed.  This\n    // allows us to write Matches(m) where m is a polymorphic matcher\n    // (e.g. Eq(5)).\n    //\n    // If we write Matcher<T>(matcher_).Matches(x) here, it won't\n    // compile when matcher_ has type Matcher<const T&>; if we write\n    // Matcher<const T&>(matcher_).Matches(x) here, it won't compile\n    // when matcher_ has type Matcher<T>; if we just write\n    // matcher_.Matches(x), it won't compile when matcher_ is\n    // polymorphic, e.g. Eq(5).\n    //\n    // MatcherCast<const T&>() is necessary for making the code work\n    // in all of the above situations.\n    return MatcherCast<const T&>(matcher_).Matches(x);\n  }\n\n private:\n  M matcher_;\n\n  GTEST_DISALLOW_ASSIGN_(MatcherAsPredicate);\n};\n\n// For implementing ASSERT_THAT() and EXPECT_THAT().  The template\n// argument M must be a type that can be converted to a matcher.\ntemplate <typename M>\nclass PredicateFormatterFromMatcher {\n public:\n  explicit PredicateFormatterFromMatcher(const M& m) : matcher_(m) {}\n\n  // This template () operator allows a PredicateFormatterFromMatcher\n  // object to act as a predicate-formatter suitable for using with\n  // Google Test's EXPECT_PRED_FORMAT1() macro.\n  template <typename T>\n  AssertionResult operator()(const char* value_text, const T& x) const {\n    // We convert matcher_ to a Matcher<const T&> *now* instead of\n    // when the PredicateFormatterFromMatcher object was constructed,\n    // as matcher_ may be polymorphic (e.g. NotNull()) and we won't\n    // know which type to instantiate it to until we actually see the\n    // type of x here.\n    //\n    // We write SafeMatcherCast<const T&>(matcher_) instead of\n    // Matcher<const T&>(matcher_), as the latter won't compile when\n    // matcher_ has type Matcher<T> (e.g. An<int>()).\n    // We don't write MatcherCast<const T&> either, as that allows\n    // potentially unsafe downcasting of the matcher argument.\n    const Matcher<const T&> matcher = SafeMatcherCast<const T&>(matcher_);\n    StringMatchResultListener listener;\n    if (MatchPrintAndExplain(x, matcher, &listener))\n      return AssertionSuccess();\n\n    ::std::stringstream ss;\n    ss << \"Value of: \" << value_text << \"\\n\"\n       << \"Expected: \";\n    matcher.DescribeTo(&ss);\n    ss << \"\\n  Actual: \" << listener.str();\n    return AssertionFailure() << ss.str();\n  }\n\n private:\n  const M matcher_;\n\n  GTEST_DISALLOW_ASSIGN_(PredicateFormatterFromMatcher);\n};\n\n// A helper function for converting a matcher to a predicate-formatter\n// without the user needing to explicitly write the type.  This is\n// used for implementing ASSERT_THAT() and EXPECT_THAT().\ntemplate <typename M>\ninline PredicateFormatterFromMatcher<M>\nMakePredicateFormatterFromMatcher(const M& matcher) {\n  return PredicateFormatterFromMatcher<M>(matcher);\n}\n\n// Implements the polymorphic floating point equality matcher, which matches\n// two float values using ULP-based approximation or, optionally, a\n// user-specified epsilon.  The template is meant to be instantiated with\n// FloatType being either float or double.\ntemplate <typename FloatType>\nclass FloatingEqMatcher {\n public:\n  // Constructor for FloatingEqMatcher.\n  // The matcher's input will be compared with rhs.  The matcher treats two\n  // NANs as equal if nan_eq_nan is true.  Otherwise, under IEEE standards,\n  // equality comparisons between NANs will always return false.  We specify a\n  // negative max_abs_error_ term to indicate that ULP-based approximation will\n  // be used for comparison.\n  FloatingEqMatcher(FloatType rhs, bool nan_eq_nan) :\n    rhs_(rhs), nan_eq_nan_(nan_eq_nan), max_abs_error_(-1) {\n  }\n\n  // Constructor that supports a user-specified max_abs_error that will be used\n  // for comparison instead of ULP-based approximation.  The max absolute\n  // should be non-negative.\n  FloatingEqMatcher(FloatType rhs, bool nan_eq_nan, FloatType max_abs_error) :\n    rhs_(rhs), nan_eq_nan_(nan_eq_nan), max_abs_error_(max_abs_error) {\n    GTEST_CHECK_(max_abs_error >= 0)\n        << \", where max_abs_error is\" << max_abs_error;\n  }\n\n  // Implements floating point equality matcher as a Matcher<T>.\n  template <typename T>\n  class Impl : public MatcherInterface<T> {\n   public:\n    Impl(FloatType rhs, bool nan_eq_nan, FloatType max_abs_error) :\n      rhs_(rhs), nan_eq_nan_(nan_eq_nan), max_abs_error_(max_abs_error) {}\n\n    virtual bool MatchAndExplain(T value,\n                                 MatchResultListener* /* listener */) const {\n      const FloatingPoint<FloatType> lhs(value), rhs(rhs_);\n\n      // Compares NaNs first, if nan_eq_nan_ is true.\n      if (lhs.is_nan() || rhs.is_nan()) {\n        if (lhs.is_nan() && rhs.is_nan()) {\n          return nan_eq_nan_;\n        }\n        // One is nan; the other is not nan.\n        return false;\n      }\n      if (HasMaxAbsError()) {\n        // We perform an equality check so that inf will match inf, regardless\n        // of error bounds.  If the result of value - rhs_ would result in\n        // overflow or if either value is inf, the default result is infinity,\n        // which should only match if max_abs_error_ is also infinity.\n        return value == rhs_ || fabs(value - rhs_) <= max_abs_error_;\n      } else {\n        return lhs.AlmostEquals(rhs);\n      }\n    }\n\n    virtual void DescribeTo(::std::ostream* os) const {\n      // os->precision() returns the previously set precision, which we\n      // store to restore the ostream to its original configuration\n      // after outputting.\n      const ::std::streamsize old_precision = os->precision(\n          ::std::numeric_limits<FloatType>::digits10 + 2);\n      if (FloatingPoint<FloatType>(rhs_).is_nan()) {\n        if (nan_eq_nan_) {\n          *os << \"is NaN\";\n        } else {\n          *os << \"never matches\";\n        }\n      } else {\n        *os << \"is approximately \" << rhs_;\n        if (HasMaxAbsError()) {\n          *os << \" (absolute error <= \" << max_abs_error_ << \")\";\n        }\n      }\n      os->precision(old_precision);\n    }\n\n    virtual void DescribeNegationTo(::std::ostream* os) const {\n      // As before, get original precision.\n      const ::std::streamsize old_precision = os->precision(\n          ::std::numeric_limits<FloatType>::digits10 + 2);\n      if (FloatingPoint<FloatType>(rhs_).is_nan()) {\n        if (nan_eq_nan_) {\n          *os << \"isn't NaN\";\n        } else {\n          *os << \"is anything\";\n        }\n      } else {\n        *os << \"isn't approximately \" << rhs_;\n        if (HasMaxAbsError()) {\n          *os << \" (absolute error > \" << max_abs_error_ << \")\";\n        }\n      }\n      // Restore original precision.\n      os->precision(old_precision);\n    }\n\n   private:\n    bool HasMaxAbsError() const {\n      return max_abs_error_ >= 0;\n    }\n\n    const FloatType rhs_;\n    const bool nan_eq_nan_;\n    // max_abs_error will be used for value comparison when >= 0.\n    const FloatType max_abs_error_;\n\n    GTEST_DISALLOW_ASSIGN_(Impl);\n  };\n\n  // The following 3 type conversion operators allow FloatEq(rhs) and\n  // NanSensitiveFloatEq(rhs) to be used as a Matcher<float>, a\n  // Matcher<const float&>, or a Matcher<float&>, but nothing else.\n  // (While Google's C++ coding style doesn't allow arguments passed\n  // by non-const reference, we may see them in code not conforming to\n  // the style.  Therefore Google Mock needs to support them.)\n  operator Matcher<FloatType>() const {\n    return MakeMatcher(new Impl<FloatType>(rhs_, nan_eq_nan_, max_abs_error_));\n  }\n\n  operator Matcher<const FloatType&>() const {\n    return MakeMatcher(\n        new Impl<const FloatType&>(rhs_, nan_eq_nan_, max_abs_error_));\n  }\n\n  operator Matcher<FloatType&>() const {\n    return MakeMatcher(new Impl<FloatType&>(rhs_, nan_eq_nan_, max_abs_error_));\n  }\n\n private:\n  const FloatType rhs_;\n  const bool nan_eq_nan_;\n  // max_abs_error will be used for value comparison when >= 0.\n  const FloatType max_abs_error_;\n\n  GTEST_DISALLOW_ASSIGN_(FloatingEqMatcher);\n};\n\n// Implements the Pointee(m) matcher for matching a pointer whose\n// pointee matches matcher m.  The pointer can be either raw or smart.\ntemplate <typename InnerMatcher>\nclass PointeeMatcher {\n public:\n  explicit PointeeMatcher(const InnerMatcher& matcher) : matcher_(matcher) {}\n\n  // This type conversion operator template allows Pointee(m) to be\n  // used as a matcher for any pointer type whose pointee type is\n  // compatible with the inner matcher, where type Pointer can be\n  // either a raw pointer or a smart pointer.\n  //\n  // The reason we do this instead of relying on\n  // MakePolymorphicMatcher() is that the latter is not flexible\n  // enough for implementing the DescribeTo() method of Pointee().\n  template <typename Pointer>\n  operator Matcher<Pointer>() const {\n    return MakeMatcher(new Impl<Pointer>(matcher_));\n  }\n\n private:\n  // The monomorphic implementation that works for a particular pointer type.\n  template <typename Pointer>\n  class Impl : public MatcherInterface<Pointer> {\n   public:\n    typedef typename PointeeOf<GTEST_REMOVE_CONST_(  // NOLINT\n        GTEST_REMOVE_REFERENCE_(Pointer))>::type Pointee;\n\n    explicit Impl(const InnerMatcher& matcher)\n        : matcher_(MatcherCast<const Pointee&>(matcher)) {}\n\n    virtual void DescribeTo(::std::ostream* os) const {\n      *os << \"points to a value that \";\n      matcher_.DescribeTo(os);\n    }\n\n    virtual void DescribeNegationTo(::std::ostream* os) const {\n      *os << \"does not point to a value that \";\n      matcher_.DescribeTo(os);\n    }\n\n    virtual bool MatchAndExplain(Pointer pointer,\n                                 MatchResultListener* listener) const {\n      if (GetRawPointer(pointer) == NULL)\n        return false;\n\n      *listener << \"which points to \";\n      return MatchPrintAndExplain(*pointer, matcher_, listener);\n    }\n\n   private:\n    const Matcher<const Pointee&> matcher_;\n\n    GTEST_DISALLOW_ASSIGN_(Impl);\n  };\n\n  const InnerMatcher matcher_;\n\n  GTEST_DISALLOW_ASSIGN_(PointeeMatcher);\n};\n\n// Implements the Field() matcher for matching a field (i.e. member\n// variable) of an object.\ntemplate <typename Class, typename FieldType>\nclass FieldMatcher {\n public:\n  FieldMatcher(FieldType Class::*field,\n               const Matcher<const FieldType&>& matcher)\n      : field_(field), matcher_(matcher) {}\n\n  void DescribeTo(::std::ostream* os) const {\n    *os << \"is an object whose given field \";\n    matcher_.DescribeTo(os);\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"is an object whose given field \";\n    matcher_.DescribeNegationTo(os);\n  }\n\n  template <typename T>\n  bool MatchAndExplain(const T& value, MatchResultListener* listener) const {\n    return MatchAndExplainImpl(\n        typename ::testing::internal::\n            is_pointer<GTEST_REMOVE_CONST_(T)>::type(),\n        value, listener);\n  }\n\n private:\n  // The first argument of MatchAndExplainImpl() is needed to help\n  // Symbian's C++ compiler choose which overload to use.  Its type is\n  // true_type iff the Field() matcher is used to match a pointer.\n  bool MatchAndExplainImpl(false_type /* is_not_pointer */, const Class& obj,\n                           MatchResultListener* listener) const {\n    *listener << \"whose given field is \";\n    return MatchPrintAndExplain(obj.*field_, matcher_, listener);\n  }\n\n  bool MatchAndExplainImpl(true_type /* is_pointer */, const Class* p,\n                           MatchResultListener* listener) const {\n    if (p == NULL)\n      return false;\n\n    *listener << \"which points to an object \";\n    // Since *p has a field, it must be a class/struct/union type and\n    // thus cannot be a pointer.  Therefore we pass false_type() as\n    // the first argument.\n    return MatchAndExplainImpl(false_type(), *p, listener);\n  }\n\n  const FieldType Class::*field_;\n  const Matcher<const FieldType&> matcher_;\n\n  GTEST_DISALLOW_ASSIGN_(FieldMatcher);\n};\n\n// Implements the Property() matcher for matching a property\n// (i.e. return value of a getter method) of an object.\ntemplate <typename Class, typename PropertyType>\nclass PropertyMatcher {\n public:\n  // The property may have a reference type, so 'const PropertyType&'\n  // may cause double references and fail to compile.  That's why we\n  // need GTEST_REFERENCE_TO_CONST, which works regardless of\n  // PropertyType being a reference or not.\n  typedef GTEST_REFERENCE_TO_CONST_(PropertyType) RefToConstProperty;\n\n  PropertyMatcher(PropertyType (Class::*property)() const,\n                  const Matcher<RefToConstProperty>& matcher)\n      : property_(property), matcher_(matcher) {}\n\n  void DescribeTo(::std::ostream* os) const {\n    *os << \"is an object whose given property \";\n    matcher_.DescribeTo(os);\n  }\n\n  void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"is an object whose given property \";\n    matcher_.DescribeNegationTo(os);\n  }\n\n  template <typename T>\n  bool MatchAndExplain(const T&value, MatchResultListener* listener) const {\n    return MatchAndExplainImpl(\n        typename ::testing::internal::\n            is_pointer<GTEST_REMOVE_CONST_(T)>::type(),\n        value, listener);\n  }\n\n private:\n  // The first argument of MatchAndExplainImpl() is needed to help\n  // Symbian's C++ compiler choose which overload to use.  Its type is\n  // true_type iff the Property() matcher is used to match a pointer.\n  bool MatchAndExplainImpl(false_type /* is_not_pointer */, const Class& obj,\n                           MatchResultListener* listener) const {\n    *listener << \"whose given property is \";\n    // Cannot pass the return value (for example, int) to MatchPrintAndExplain,\n    // which takes a non-const reference as argument.\n    RefToConstProperty result = (obj.*property_)();\n    return MatchPrintAndExplain(result, matcher_, listener);\n  }\n\n  bool MatchAndExplainImpl(true_type /* is_pointer */, const Class* p,\n                           MatchResultListener* listener) const {\n    if (p == NULL)\n      return false;\n\n    *listener << \"which points to an object \";\n    // Since *p has a property method, it must be a class/struct/union\n    // type and thus cannot be a pointer.  Therefore we pass\n    // false_type() as the first argument.\n    return MatchAndExplainImpl(false_type(), *p, listener);\n  }\n\n  PropertyType (Class::*property_)() const;\n  const Matcher<RefToConstProperty> matcher_;\n\n  GTEST_DISALLOW_ASSIGN_(PropertyMatcher);\n};\n\n// Type traits specifying various features of different functors for ResultOf.\n// The default template specifies features for functor objects.\n// Functor classes have to typedef argument_type and result_type\n// to be compatible with ResultOf.\ntemplate <typename Functor>\nstruct CallableTraits {\n  typedef typename Functor::result_type ResultType;\n  typedef Functor StorageType;\n\n  static void CheckIsValid(Functor /* functor */) {}\n  template <typename T>\n  static ResultType Invoke(Functor f, T arg) { return f(arg); }\n};\n\n// Specialization for function pointers.\ntemplate <typename ArgType, typename ResType>\nstruct CallableTraits<ResType(*)(ArgType)> {\n  typedef ResType ResultType;\n  typedef ResType(*StorageType)(ArgType);\n\n  static void CheckIsValid(ResType(*f)(ArgType)) {\n    GTEST_CHECK_(f != NULL)\n        << \"NULL function pointer is passed into ResultOf().\";\n  }\n  template <typename T>\n  static ResType Invoke(ResType(*f)(ArgType), T arg) {\n    return (*f)(arg);\n  }\n};\n\n// Implements the ResultOf() matcher for matching a return value of a\n// unary function of an object.\ntemplate <typename Callable>\nclass ResultOfMatcher {\n public:\n  typedef typename CallableTraits<Callable>::ResultType ResultType;\n\n  ResultOfMatcher(Callable callable, const Matcher<ResultType>& matcher)\n      : callable_(callable), matcher_(matcher) {\n    CallableTraits<Callable>::CheckIsValid(callable_);\n  }\n\n  template <typename T>\n  operator Matcher<T>() const {\n    return Matcher<T>(new Impl<T>(callable_, matcher_));\n  }\n\n private:\n  typedef typename CallableTraits<Callable>::StorageType CallableStorageType;\n\n  template <typename T>\n  class Impl : public MatcherInterface<T> {\n   public:\n    Impl(CallableStorageType callable, const Matcher<ResultType>& matcher)\n        : callable_(callable), matcher_(matcher) {}\n\n    virtual void DescribeTo(::std::ostream* os) const {\n      *os << \"is mapped by the given callable to a value that \";\n      matcher_.DescribeTo(os);\n    }\n\n    virtual void DescribeNegationTo(::std::ostream* os) const {\n      *os << \"is mapped by the given callable to a value that \";\n      matcher_.DescribeNegationTo(os);\n    }\n\n    virtual bool MatchAndExplain(T obj, MatchResultListener* listener) const {\n      *listener << \"which is mapped by the given callable to \";\n      // Cannot pass the return value (for example, int) to\n      // MatchPrintAndExplain, which takes a non-const reference as argument.\n      ResultType result =\n          CallableTraits<Callable>::template Invoke<T>(callable_, obj);\n      return MatchPrintAndExplain(result, matcher_, listener);\n    }\n\n   private:\n    // Functors often define operator() as non-const method even though\n    // they are actualy stateless. But we need to use them even when\n    // 'this' is a const pointer. It's the user's responsibility not to\n    // use stateful callables with ResultOf(), which does't guarantee\n    // how many times the callable will be invoked.\n    mutable CallableStorageType callable_;\n    const Matcher<ResultType> matcher_;\n\n    GTEST_DISALLOW_ASSIGN_(Impl);\n  };  // class Impl\n\n  const CallableStorageType callable_;\n  const Matcher<ResultType> matcher_;\n\n  GTEST_DISALLOW_ASSIGN_(ResultOfMatcher);\n};\n\n// Implements a matcher that checks the size of an STL-style container.\ntemplate <typename SizeMatcher>\nclass SizeIsMatcher {\n public:\n  explicit SizeIsMatcher(const SizeMatcher& size_matcher)\n       : size_matcher_(size_matcher) {\n  }\n\n  template <typename Container>\n  operator Matcher<Container>() const {\n    return MakeMatcher(new Impl<Container>(size_matcher_));\n  }\n\n  template <typename Container>\n  class Impl : public MatcherInterface<Container> {\n   public:\n    typedef internal::StlContainerView<\n         GTEST_REMOVE_REFERENCE_AND_CONST_(Container)> ContainerView;\n    typedef typename ContainerView::type::size_type SizeType;\n    explicit Impl(const SizeMatcher& size_matcher)\n        : size_matcher_(MatcherCast<SizeType>(size_matcher)) {}\n\n    virtual void DescribeTo(::std::ostream* os) const {\n      *os << \"size \";\n      size_matcher_.DescribeTo(os);\n    }\n    virtual void DescribeNegationTo(::std::ostream* os) const {\n      *os << \"size \";\n      size_matcher_.DescribeNegationTo(os);\n    }\n\n    virtual bool MatchAndExplain(Container container,\n                                 MatchResultListener* listener) const {\n      SizeType size = container.size();\n      StringMatchResultListener size_listener;\n      const bool result = size_matcher_.MatchAndExplain(size, &size_listener);\n      *listener\n          << \"whose size \" << size << (result ? \" matches\" : \" doesn't match\");\n      PrintIfNotEmpty(size_listener.str(), listener->stream());\n      return result;\n    }\n\n   private:\n    const Matcher<SizeType> size_matcher_;\n    GTEST_DISALLOW_ASSIGN_(Impl);\n  };\n\n private:\n  const SizeMatcher size_matcher_;\n  GTEST_DISALLOW_ASSIGN_(SizeIsMatcher);\n};\n\n// Implements an equality matcher for any STL-style container whose elements\n// support ==. This matcher is like Eq(), but its failure explanations provide\n// more detailed information that is useful when the container is used as a set.\n// The failure message reports elements that are in one of the operands but not\n// the other. The failure messages do not report duplicate or out-of-order\n// elements in the containers (which don't properly matter to sets, but can\n// occur if the containers are vectors or lists, for example).\n//\n// Uses the container's const_iterator, value_type, operator ==,\n// begin(), and end().\ntemplate <typename Container>\nclass ContainerEqMatcher {\n public:\n  typedef internal::StlContainerView<Container> View;\n  typedef typename View::type StlContainer;\n  typedef typename View::const_reference StlContainerReference;\n\n  // We make a copy of rhs in case the elements in it are modified\n  // after this matcher is created.\n  explicit ContainerEqMatcher(const Container& rhs) : rhs_(View::Copy(rhs)) {\n    // Makes sure the user doesn't instantiate this class template\n    // with a const or reference type.\n    (void)testing::StaticAssertTypeEq<Container,\n        GTEST_REMOVE_REFERENCE_AND_CONST_(Container)>();\n  }\n\n  void DescribeTo(::std::ostream* os) const {\n    *os << \"equals \";\n    UniversalPrint(rhs_, os);\n  }\n  void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"does not equal \";\n    UniversalPrint(rhs_, os);\n  }\n\n  template <typename LhsContainer>\n  bool MatchAndExplain(const LhsContainer& lhs,\n                       MatchResultListener* listener) const {\n    // GTEST_REMOVE_CONST_() is needed to work around an MSVC 8.0 bug\n    // that causes LhsContainer to be a const type sometimes.\n    typedef internal::StlContainerView<GTEST_REMOVE_CONST_(LhsContainer)>\n        LhsView;\n    typedef typename LhsView::type LhsStlContainer;\n    StlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);\n    if (lhs_stl_container == rhs_)\n      return true;\n\n    ::std::ostream* const os = listener->stream();\n    if (os != NULL) {\n      // Something is different. Check for extra values first.\n      bool printed_header = false;\n      for (typename LhsStlContainer::const_iterator it =\n               lhs_stl_container.begin();\n           it != lhs_stl_container.end(); ++it) {\n        if (internal::ArrayAwareFind(rhs_.begin(), rhs_.end(), *it) ==\n            rhs_.end()) {\n          if (printed_header) {\n            *os << \", \";\n          } else {\n            *os << \"which has these unexpected elements: \";\n            printed_header = true;\n          }\n          UniversalPrint(*it, os);\n        }\n      }\n\n      // Now check for missing values.\n      bool printed_header2 = false;\n      for (typename StlContainer::const_iterator it = rhs_.begin();\n           it != rhs_.end(); ++it) {\n        if (internal::ArrayAwareFind(\n                lhs_stl_container.begin(), lhs_stl_container.end(), *it) ==\n            lhs_stl_container.end()) {\n          if (printed_header2) {\n            *os << \", \";\n          } else {\n            *os << (printed_header ? \",\\nand\" : \"which\")\n                << \" doesn't have these expected elements: \";\n            printed_header2 = true;\n          }\n          UniversalPrint(*it, os);\n        }\n      }\n    }\n\n    return false;\n  }\n\n private:\n  const StlContainer rhs_;\n\n  GTEST_DISALLOW_ASSIGN_(ContainerEqMatcher);\n};\n\n// A comparator functor that uses the < operator to compare two values.\nstruct LessComparator {\n  template <typename T, typename U>\n  bool operator()(const T& lhs, const U& rhs) const { return lhs < rhs; }\n};\n\n// Implements WhenSortedBy(comparator, container_matcher).\ntemplate <typename Comparator, typename ContainerMatcher>\nclass WhenSortedByMatcher {\n public:\n  WhenSortedByMatcher(const Comparator& comparator,\n                      const ContainerMatcher& matcher)\n      : comparator_(comparator), matcher_(matcher) {}\n\n  template <typename LhsContainer>\n  operator Matcher<LhsContainer>() const {\n    return MakeMatcher(new Impl<LhsContainer>(comparator_, matcher_));\n  }\n\n  template <typename LhsContainer>\n  class Impl : public MatcherInterface<LhsContainer> {\n   public:\n    typedef internal::StlContainerView<\n         GTEST_REMOVE_REFERENCE_AND_CONST_(LhsContainer)> LhsView;\n    typedef typename LhsView::type LhsStlContainer;\n    typedef typename LhsView::const_reference LhsStlContainerReference;\n    // Transforms std::pair<const Key, Value> into std::pair<Key, Value>\n    // so that we can match associative containers.\n    typedef typename RemoveConstFromKey<\n        typename LhsStlContainer::value_type>::type LhsValue;\n\n    Impl(const Comparator& comparator, const ContainerMatcher& matcher)\n        : comparator_(comparator), matcher_(matcher) {}\n\n    virtual void DescribeTo(::std::ostream* os) const {\n      *os << \"(when sorted) \";\n      matcher_.DescribeTo(os);\n    }\n\n    virtual void DescribeNegationTo(::std::ostream* os) const {\n      *os << \"(when sorted) \";\n      matcher_.DescribeNegationTo(os);\n    }\n\n    virtual bool MatchAndExplain(LhsContainer lhs,\n                                 MatchResultListener* listener) const {\n      LhsStlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);\n      ::std::vector<LhsValue> sorted_container(lhs_stl_container.begin(),\n                                               lhs_stl_container.end());\n      ::std::sort(\n           sorted_container.begin(), sorted_container.end(), comparator_);\n\n      if (!listener->IsInterested()) {\n        // If the listener is not interested, we do not need to\n        // construct the inner explanation.\n        return matcher_.Matches(sorted_container);\n      }\n\n      *listener << \"which is \";\n      UniversalPrint(sorted_container, listener->stream());\n      *listener << \" when sorted\";\n\n      StringMatchResultListener inner_listener;\n      const bool match = matcher_.MatchAndExplain(sorted_container,\n                                                  &inner_listener);\n      PrintIfNotEmpty(inner_listener.str(), listener->stream());\n      return match;\n    }\n\n   private:\n    const Comparator comparator_;\n    const Matcher<const ::std::vector<LhsValue>&> matcher_;\n\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(Impl);\n  };\n\n private:\n  const Comparator comparator_;\n  const ContainerMatcher matcher_;\n\n  GTEST_DISALLOW_ASSIGN_(WhenSortedByMatcher);\n};\n\n// Implements Pointwise(tuple_matcher, rhs_container).  tuple_matcher\n// must be able to be safely cast to Matcher<tuple<const T1&, const\n// T2&> >, where T1 and T2 are the types of elements in the LHS\n// container and the RHS container respectively.\ntemplate <typename TupleMatcher, typename RhsContainer>\nclass PointwiseMatcher {\n public:\n  typedef internal::StlContainerView<RhsContainer> RhsView;\n  typedef typename RhsView::type RhsStlContainer;\n  typedef typename RhsStlContainer::value_type RhsValue;\n\n  // Like ContainerEq, we make a copy of rhs in case the elements in\n  // it are modified after this matcher is created.\n  PointwiseMatcher(const TupleMatcher& tuple_matcher, const RhsContainer& rhs)\n      : tuple_matcher_(tuple_matcher), rhs_(RhsView::Copy(rhs)) {\n    // Makes sure the user doesn't instantiate this class template\n    // with a const or reference type.\n    (void)testing::StaticAssertTypeEq<RhsContainer,\n        GTEST_REMOVE_REFERENCE_AND_CONST_(RhsContainer)>();\n  }\n\n  template <typename LhsContainer>\n  operator Matcher<LhsContainer>() const {\n    return MakeMatcher(new Impl<LhsContainer>(tuple_matcher_, rhs_));\n  }\n\n  template <typename LhsContainer>\n  class Impl : public MatcherInterface<LhsContainer> {\n   public:\n    typedef internal::StlContainerView<\n         GTEST_REMOVE_REFERENCE_AND_CONST_(LhsContainer)> LhsView;\n    typedef typename LhsView::type LhsStlContainer;\n    typedef typename LhsView::const_reference LhsStlContainerReference;\n    typedef typename LhsStlContainer::value_type LhsValue;\n    // We pass the LHS value and the RHS value to the inner matcher by\n    // reference, as they may be expensive to copy.  We must use tuple\n    // instead of pair here, as a pair cannot hold references (C++ 98,\n    // 20.2.2 [lib.pairs]).\n    typedef ::std::tr1::tuple<const LhsValue&, const RhsValue&> InnerMatcherArg;\n\n    Impl(const TupleMatcher& tuple_matcher, const RhsStlContainer& rhs)\n        // mono_tuple_matcher_ holds a monomorphic version of the tuple matcher.\n        : mono_tuple_matcher_(SafeMatcherCast<InnerMatcherArg>(tuple_matcher)),\n          rhs_(rhs) {}\n\n    virtual void DescribeTo(::std::ostream* os) const {\n      *os << \"contains \" << rhs_.size()\n          << \" values, where each value and its corresponding value in \";\n      UniversalPrinter<RhsStlContainer>::Print(rhs_, os);\n      *os << \" \";\n      mono_tuple_matcher_.DescribeTo(os);\n    }\n    virtual void DescribeNegationTo(::std::ostream* os) const {\n      *os << \"doesn't contain exactly \" << rhs_.size()\n          << \" values, or contains a value x at some index i\"\n          << \" where x and the i-th value of \";\n      UniversalPrint(rhs_, os);\n      *os << \" \";\n      mono_tuple_matcher_.DescribeNegationTo(os);\n    }\n\n    virtual bool MatchAndExplain(LhsContainer lhs,\n                                 MatchResultListener* listener) const {\n      LhsStlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);\n      const size_t actual_size = lhs_stl_container.size();\n      if (actual_size != rhs_.size()) {\n        *listener << \"which contains \" << actual_size << \" values\";\n        return false;\n      }\n\n      typename LhsStlContainer::const_iterator left = lhs_stl_container.begin();\n      typename RhsStlContainer::const_iterator right = rhs_.begin();\n      for (size_t i = 0; i != actual_size; ++i, ++left, ++right) {\n        const InnerMatcherArg value_pair(*left, *right);\n\n        if (listener->IsInterested()) {\n          StringMatchResultListener inner_listener;\n          if (!mono_tuple_matcher_.MatchAndExplain(\n                  value_pair, &inner_listener)) {\n            *listener << \"where the value pair (\";\n            UniversalPrint(*left, listener->stream());\n            *listener << \", \";\n            UniversalPrint(*right, listener->stream());\n            *listener << \") at index #\" << i << \" don't match\";\n            PrintIfNotEmpty(inner_listener.str(), listener->stream());\n            return false;\n          }\n        } else {\n          if (!mono_tuple_matcher_.Matches(value_pair))\n            return false;\n        }\n      }\n\n      return true;\n    }\n\n   private:\n    const Matcher<InnerMatcherArg> mono_tuple_matcher_;\n    const RhsStlContainer rhs_;\n\n    GTEST_DISALLOW_ASSIGN_(Impl);\n  };\n\n private:\n  const TupleMatcher tuple_matcher_;\n  const RhsStlContainer rhs_;\n\n  GTEST_DISALLOW_ASSIGN_(PointwiseMatcher);\n};\n\n// Holds the logic common to ContainsMatcherImpl and EachMatcherImpl.\ntemplate <typename Container>\nclass QuantifierMatcherImpl : public MatcherInterface<Container> {\n public:\n  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;\n  typedef StlContainerView<RawContainer> View;\n  typedef typename View::type StlContainer;\n  typedef typename View::const_reference StlContainerReference;\n  typedef typename StlContainer::value_type Element;\n\n  template <typename InnerMatcher>\n  explicit QuantifierMatcherImpl(InnerMatcher inner_matcher)\n      : inner_matcher_(\n           testing::SafeMatcherCast<const Element&>(inner_matcher)) {}\n\n  // Checks whether:\n  // * All elements in the container match, if all_elements_should_match.\n  // * Any element in the container matches, if !all_elements_should_match.\n  bool MatchAndExplainImpl(bool all_elements_should_match,\n                           Container container,\n                           MatchResultListener* listener) const {\n    StlContainerReference stl_container = View::ConstReference(container);\n    size_t i = 0;\n    for (typename StlContainer::const_iterator it = stl_container.begin();\n         it != stl_container.end(); ++it, ++i) {\n      StringMatchResultListener inner_listener;\n      const bool matches = inner_matcher_.MatchAndExplain(*it, &inner_listener);\n\n      if (matches != all_elements_should_match) {\n        *listener << \"whose element #\" << i\n                  << (matches ? \" matches\" : \" doesn't match\");\n        PrintIfNotEmpty(inner_listener.str(), listener->stream());\n        return !all_elements_should_match;\n      }\n    }\n    return all_elements_should_match;\n  }\n\n protected:\n  const Matcher<const Element&> inner_matcher_;\n\n  GTEST_DISALLOW_ASSIGN_(QuantifierMatcherImpl);\n};\n\n// Implements Contains(element_matcher) for the given argument type Container.\n// Symmetric to EachMatcherImpl.\ntemplate <typename Container>\nclass ContainsMatcherImpl : public QuantifierMatcherImpl<Container> {\n public:\n  template <typename InnerMatcher>\n  explicit ContainsMatcherImpl(InnerMatcher inner_matcher)\n      : QuantifierMatcherImpl<Container>(inner_matcher) {}\n\n  // Describes what this matcher does.\n  virtual void DescribeTo(::std::ostream* os) const {\n    *os << \"contains at least one element that \";\n    this->inner_matcher_.DescribeTo(os);\n  }\n\n  virtual void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"doesn't contain any element that \";\n    this->inner_matcher_.DescribeTo(os);\n  }\n\n  virtual bool MatchAndExplain(Container container,\n                               MatchResultListener* listener) const {\n    return this->MatchAndExplainImpl(false, container, listener);\n  }\n\n private:\n  GTEST_DISALLOW_ASSIGN_(ContainsMatcherImpl);\n};\n\n// Implements Each(element_matcher) for the given argument type Container.\n// Symmetric to ContainsMatcherImpl.\ntemplate <typename Container>\nclass EachMatcherImpl : public QuantifierMatcherImpl<Container> {\n public:\n  template <typename InnerMatcher>\n  explicit EachMatcherImpl(InnerMatcher inner_matcher)\n      : QuantifierMatcherImpl<Container>(inner_matcher) {}\n\n  // Describes what this matcher does.\n  virtual void DescribeTo(::std::ostream* os) const {\n    *os << \"only contains elements that \";\n    this->inner_matcher_.DescribeTo(os);\n  }\n\n  virtual void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"contains some element that \";\n    this->inner_matcher_.DescribeNegationTo(os);\n  }\n\n  virtual bool MatchAndExplain(Container container,\n                               MatchResultListener* listener) const {\n    return this->MatchAndExplainImpl(true, container, listener);\n  }\n\n private:\n  GTEST_DISALLOW_ASSIGN_(EachMatcherImpl);\n};\n\n// Implements polymorphic Contains(element_matcher).\ntemplate <typename M>\nclass ContainsMatcher {\n public:\n  explicit ContainsMatcher(M m) : inner_matcher_(m) {}\n\n  template <typename Container>\n  operator Matcher<Container>() const {\n    return MakeMatcher(new ContainsMatcherImpl<Container>(inner_matcher_));\n  }\n\n private:\n  const M inner_matcher_;\n\n  GTEST_DISALLOW_ASSIGN_(ContainsMatcher);\n};\n\n// Implements polymorphic Each(element_matcher).\ntemplate <typename M>\nclass EachMatcher {\n public:\n  explicit EachMatcher(M m) : inner_matcher_(m) {}\n\n  template <typename Container>\n  operator Matcher<Container>() const {\n    return MakeMatcher(new EachMatcherImpl<Container>(inner_matcher_));\n  }\n\n private:\n  const M inner_matcher_;\n\n  GTEST_DISALLOW_ASSIGN_(EachMatcher);\n};\n\n// Implements Key(inner_matcher) for the given argument pair type.\n// Key(inner_matcher) matches an std::pair whose 'first' field matches\n// inner_matcher.  For example, Contains(Key(Ge(5))) can be used to match an\n// std::map that contains at least one element whose key is >= 5.\ntemplate <typename PairType>\nclass KeyMatcherImpl : public MatcherInterface<PairType> {\n public:\n  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(PairType) RawPairType;\n  typedef typename RawPairType::first_type KeyType;\n\n  template <typename InnerMatcher>\n  explicit KeyMatcherImpl(InnerMatcher inner_matcher)\n      : inner_matcher_(\n          testing::SafeMatcherCast<const KeyType&>(inner_matcher)) {\n  }\n\n  // Returns true iff 'key_value.first' (the key) matches the inner matcher.\n  virtual bool MatchAndExplain(PairType key_value,\n                               MatchResultListener* listener) const {\n    StringMatchResultListener inner_listener;\n    const bool match = inner_matcher_.MatchAndExplain(key_value.first,\n                                                      &inner_listener);\n    const internal::string explanation = inner_listener.str();\n    if (explanation != \"\") {\n      *listener << \"whose first field is a value \" << explanation;\n    }\n    return match;\n  }\n\n  // Describes what this matcher does.\n  virtual void DescribeTo(::std::ostream* os) const {\n    *os << \"has a key that \";\n    inner_matcher_.DescribeTo(os);\n  }\n\n  // Describes what the negation of this matcher does.\n  virtual void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"doesn't have a key that \";\n    inner_matcher_.DescribeTo(os);\n  }\n\n private:\n  const Matcher<const KeyType&> inner_matcher_;\n\n  GTEST_DISALLOW_ASSIGN_(KeyMatcherImpl);\n};\n\n// Implements polymorphic Key(matcher_for_key).\ntemplate <typename M>\nclass KeyMatcher {\n public:\n  explicit KeyMatcher(M m) : matcher_for_key_(m) {}\n\n  template <typename PairType>\n  operator Matcher<PairType>() const {\n    return MakeMatcher(new KeyMatcherImpl<PairType>(matcher_for_key_));\n  }\n\n private:\n  const M matcher_for_key_;\n\n  GTEST_DISALLOW_ASSIGN_(KeyMatcher);\n};\n\n// Implements Pair(first_matcher, second_matcher) for the given argument pair\n// type with its two matchers. See Pair() function below.\ntemplate <typename PairType>\nclass PairMatcherImpl : public MatcherInterface<PairType> {\n public:\n  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(PairType) RawPairType;\n  typedef typename RawPairType::first_type FirstType;\n  typedef typename RawPairType::second_type SecondType;\n\n  template <typename FirstMatcher, typename SecondMatcher>\n  PairMatcherImpl(FirstMatcher first_matcher, SecondMatcher second_matcher)\n      : first_matcher_(\n            testing::SafeMatcherCast<const FirstType&>(first_matcher)),\n        second_matcher_(\n            testing::SafeMatcherCast<const SecondType&>(second_matcher)) {\n  }\n\n  // Describes what this matcher does.\n  virtual void DescribeTo(::std::ostream* os) const {\n    *os << \"has a first field that \";\n    first_matcher_.DescribeTo(os);\n    *os << \", and has a second field that \";\n    second_matcher_.DescribeTo(os);\n  }\n\n  // Describes what the negation of this matcher does.\n  virtual void DescribeNegationTo(::std::ostream* os) const {\n    *os << \"has a first field that \";\n    first_matcher_.DescribeNegationTo(os);\n    *os << \", or has a second field that \";\n    second_matcher_.DescribeNegationTo(os);\n  }\n\n  // Returns true iff 'a_pair.first' matches first_matcher and 'a_pair.second'\n  // matches second_matcher.\n  virtual bool MatchAndExplain(PairType a_pair,\n                               MatchResultListener* listener) const {\n    if (!listener->IsInterested()) {\n      // If the listener is not interested, we don't need to construct the\n      // explanation.\n      return first_matcher_.Matches(a_pair.first) &&\n             second_matcher_.Matches(a_pair.second);\n    }\n    StringMatchResultListener first_inner_listener;\n    if (!first_matcher_.MatchAndExplain(a_pair.first,\n                                        &first_inner_listener)) {\n      *listener << \"whose first field does not match\";\n      PrintIfNotEmpty(first_inner_listener.str(), listener->stream());\n      return false;\n    }\n    StringMatchResultListener second_inner_listener;\n    if (!second_matcher_.MatchAndExplain(a_pair.second,\n                                         &second_inner_listener)) {\n      *listener << \"whose second field does not match\";\n      PrintIfNotEmpty(second_inner_listener.str(), listener->stream());\n      return false;\n    }\n    ExplainSuccess(first_inner_listener.str(), second_inner_listener.str(),\n                   listener);\n    return true;\n  }\n\n private:\n  void ExplainSuccess(const internal::string& first_explanation,\n                      const internal::string& second_explanation,\n                      MatchResultListener* listener) const {\n    *listener << \"whose both fields match\";\n    if (first_explanation != \"\") {\n      *listener << \", where the first field is a value \" << first_explanation;\n    }\n    if (second_explanation != \"\") {\n      *listener << \", \";\n      if (first_explanation != \"\") {\n        *listener << \"and \";\n      } else {\n        *listener << \"where \";\n      }\n      *listener << \"the second field is a value \" << second_explanation;\n    }\n  }\n\n  const Matcher<const FirstType&> first_matcher_;\n  const Matcher<const SecondType&> second_matcher_;\n\n  GTEST_DISALLOW_ASSIGN_(PairMatcherImpl);\n};\n\n// Implements polymorphic Pair(first_matcher, second_matcher).\ntemplate <typename FirstMatcher, typename SecondMatcher>\nclass PairMatcher {\n public:\n  PairMatcher(FirstMatcher first_matcher, SecondMatcher second_matcher)\n      : first_matcher_(first_matcher), second_matcher_(second_matcher) {}\n\n  template <typename PairType>\n  operator Matcher<PairType> () const {\n    return MakeMatcher(\n        new PairMatcherImpl<PairType>(\n            first_matcher_, second_matcher_));\n  }\n\n private:\n  const FirstMatcher first_matcher_;\n  const SecondMatcher second_matcher_;\n\n  GTEST_DISALLOW_ASSIGN_(PairMatcher);\n};\n\n// Implements ElementsAre() and ElementsAreArray().\ntemplate <typename Container>\nclass ElementsAreMatcherImpl : public MatcherInterface<Container> {\n public:\n  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;\n  typedef internal::StlContainerView<RawContainer> View;\n  typedef typename View::type StlContainer;\n  typedef typename View::const_reference StlContainerReference;\n  typedef typename StlContainer::value_type Element;\n\n  // Constructs the matcher from a sequence of element values or\n  // element matchers.\n  template <typename InputIter>\n  ElementsAreMatcherImpl(InputIter first, InputIter last) {\n    while (first != last) {\n      matchers_.push_back(MatcherCast<const Element&>(*first++));\n    }\n  }\n\n  // Describes what this matcher does.\n  virtual void DescribeTo(::std::ostream* os) const {\n    if (count() == 0) {\n      *os << \"is empty\";\n    } else if (count() == 1) {\n      *os << \"has 1 element that \";\n      matchers_[0].DescribeTo(os);\n    } else {\n      *os << \"has \" << Elements(count()) << \" where\\n\";\n      for (size_t i = 0; i != count(); ++i) {\n        *os << \"element #\" << i << \" \";\n        matchers_[i].DescribeTo(os);\n        if (i + 1 < count()) {\n          *os << \",\\n\";\n        }\n      }\n    }\n  }\n\n  // Describes what the negation of this matcher does.\n  virtual void DescribeNegationTo(::std::ostream* os) const {\n    if (count() == 0) {\n      *os << \"isn't empty\";\n      return;\n    }\n\n    *os << \"doesn't have \" << Elements(count()) << \", or\\n\";\n    for (size_t i = 0; i != count(); ++i) {\n      *os << \"element #\" << i << \" \";\n      matchers_[i].DescribeNegationTo(os);\n      if (i + 1 < count()) {\n        *os << \", or\\n\";\n      }\n    }\n  }\n\n  virtual bool MatchAndExplain(Container container,\n                               MatchResultListener* listener) const {\n    // To work with stream-like \"containers\", we must only walk\n    // through the elements in one pass.\n\n    const bool listener_interested = listener->IsInterested();\n\n    // explanations[i] is the explanation of the element at index i.\n    ::std::vector<internal::string> explanations(count());\n    StlContainerReference stl_container = View::ConstReference(container);\n    typename StlContainer::const_iterator it = stl_container.begin();\n    size_t exam_pos = 0;\n    bool mismatch_found = false;  // Have we found a mismatched element yet?\n\n    // Go through the elements and matchers in pairs, until we reach\n    // the end of either the elements or the matchers, or until we find a\n    // mismatch.\n    for (; it != stl_container.end() && exam_pos != count(); ++it, ++exam_pos) {\n      bool match;  // Does the current element match the current matcher?\n      if (listener_interested) {\n        StringMatchResultListener s;\n        match = matchers_[exam_pos].MatchAndExplain(*it, &s);\n        explanations[exam_pos] = s.str();\n      } else {\n        match = matchers_[exam_pos].Matches(*it);\n      }\n\n      if (!match) {\n        mismatch_found = true;\n        break;\n      }\n    }\n    // If mismatch_found is true, 'exam_pos' is the index of the mismatch.\n\n    // Find how many elements the actual container has.  We avoid\n    // calling size() s.t. this code works for stream-like \"containers\"\n    // that don't define size().\n    size_t actual_count = exam_pos;\n    for (; it != stl_container.end(); ++it) {\n      ++actual_count;\n    }\n\n    if (actual_count != count()) {\n      // The element count doesn't match.  If the container is empty,\n      // there's no need to explain anything as Google Mock already\n      // prints the empty container.  Otherwise we just need to show\n      // how many elements there actually are.\n      if (listener_interested && (actual_count != 0)) {\n        *listener << \"which has \" << Elements(actual_count);\n      }\n      return false;\n    }\n\n    if (mismatch_found) {\n      // The element count matches, but the exam_pos-th element doesn't match.\n      if (listener_interested) {\n        *listener << \"whose element #\" << exam_pos << \" doesn't match\";\n        PrintIfNotEmpty(explanations[exam_pos], listener->stream());\n      }\n      return false;\n    }\n\n    // Every element matches its expectation.  We need to explain why\n    // (the obvious ones can be skipped).\n    if (listener_interested) {\n      bool reason_printed = false;\n      for (size_t i = 0; i != count(); ++i) {\n        const internal::string& s = explanations[i];\n        if (!s.empty()) {\n          if (reason_printed) {\n            *listener << \",\\nand \";\n          }\n          *listener << \"whose element #\" << i << \" matches, \" << s;\n          reason_printed = true;\n        }\n      }\n    }\n    return true;\n  }\n\n private:\n  static Message Elements(size_t count) {\n    return Message() << count << (count == 1 ? \" element\" : \" elements\");\n  }\n\n  size_t count() const { return matchers_.size(); }\n\n  ::std::vector<Matcher<const Element&> > matchers_;\n\n  GTEST_DISALLOW_ASSIGN_(ElementsAreMatcherImpl);\n};\n\n// Connectivity matrix of (elements X matchers), in element-major order.\n// Initially, there are no edges.\n// Use NextGraph() to iterate over all possible edge configurations.\n// Use Randomize() to generate a random edge configuration.\nclass GTEST_API_ MatchMatrix {\n public:\n  MatchMatrix(size_t num_elements, size_t num_matchers)\n      : num_elements_(num_elements),\n        num_matchers_(num_matchers),\n        matched_(num_elements_* num_matchers_, 0) {\n  }\n\n  size_t LhsSize() const { return num_elements_; }\n  size_t RhsSize() const { return num_matchers_; }\n  bool HasEdge(size_t ilhs, size_t irhs) const {\n    return matched_[SpaceIndex(ilhs, irhs)] == 1;\n  }\n  void SetEdge(size_t ilhs, size_t irhs, bool b) {\n    matched_[SpaceIndex(ilhs, irhs)] = b ? 1 : 0;\n  }\n\n  // Treating the connectivity matrix as a (LhsSize()*RhsSize())-bit number,\n  // adds 1 to that number; returns false if incrementing the graph left it\n  // empty.\n  bool NextGraph();\n\n  void Randomize();\n\n  string DebugString() const;\n\n private:\n  size_t SpaceIndex(size_t ilhs, size_t irhs) const {\n    return ilhs * num_matchers_ + irhs;\n  }\n\n  size_t num_elements_;\n  size_t num_matchers_;\n\n  // Each element is a char interpreted as bool. They are stored as a\n  // flattened array in lhs-major order, use 'SpaceIndex()' to translate\n  // a (ilhs, irhs) matrix coordinate into an offset.\n  ::std::vector<char> matched_;\n};\n\ntypedef ::std::pair<size_t, size_t> ElementMatcherPair;\ntypedef ::std::vector<ElementMatcherPair> ElementMatcherPairs;\n\n// Returns a maximum bipartite matching for the specified graph 'g'.\n// The matching is represented as a vector of {element, matcher} pairs.\nGTEST_API_ ElementMatcherPairs\nFindMaxBipartiteMatching(const MatchMatrix& g);\n\nGTEST_API_ bool FindPairing(const MatchMatrix& matrix,\n                            MatchResultListener* listener);\n\n// Untyped base class for implementing UnorderedElementsAre.  By\n// putting logic that's not specific to the element type here, we\n// reduce binary bloat and increase compilation speed.\nclass GTEST_API_ UnorderedElementsAreMatcherImplBase {\n protected:\n  // A vector of matcher describers, one for each element matcher.\n  // Does not own the describers (and thus can be used only when the\n  // element matchers are alive).\n  typedef ::std::vector<const MatcherDescriberInterface*> MatcherDescriberVec;\n\n  // Describes this UnorderedElementsAre matcher.\n  void DescribeToImpl(::std::ostream* os) const;\n\n  // Describes the negation of this UnorderedElementsAre matcher.\n  void DescribeNegationToImpl(::std::ostream* os) const;\n\n  bool VerifyAllElementsAndMatchersAreMatched(\n      const ::std::vector<string>& element_printouts,\n      const MatchMatrix& matrix,\n      MatchResultListener* listener) const;\n\n  MatcherDescriberVec& matcher_describers() {\n    return matcher_describers_;\n  }\n\n  static Message Elements(size_t n) {\n    return Message() << n << \" element\" << (n == 1 ? \"\" : \"s\");\n  }\n\n private:\n  MatcherDescriberVec matcher_describers_;\n\n  GTEST_DISALLOW_ASSIGN_(UnorderedElementsAreMatcherImplBase);\n};\n\n// Implements unordered ElementsAre and unordered ElementsAreArray.\ntemplate <typename Container>\nclass UnorderedElementsAreMatcherImpl\n    : public MatcherInterface<Container>,\n      public UnorderedElementsAreMatcherImplBase {\n public:\n  typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;\n  typedef internal::StlContainerView<RawContainer> View;\n  typedef typename View::type StlContainer;\n  typedef typename View::const_reference StlContainerReference;\n  typedef typename StlContainer::const_iterator StlContainerConstIterator;\n  typedef typename StlContainer::value_type Element;\n\n  // Constructs the matcher from a sequence of element values or\n  // element matchers.\n  template <typename InputIter>\n  UnorderedElementsAreMatcherImpl(InputIter first, InputIter last) {\n    for (; first != last; ++first) {\n      matchers_.push_back(MatcherCast<const Element&>(*first));\n      matcher_describers().push_back(matchers_.back().GetDescriber());\n    }\n  }\n\n  // Describes what this matcher does.\n  virtual void DescribeTo(::std::ostream* os) const {\n    return UnorderedElementsAreMatcherImplBase::DescribeToImpl(os);\n  }\n\n  // Describes what the negation of this matcher does.\n  virtual void DescribeNegationTo(::std::ostream* os) const {\n    return UnorderedElementsAreMatcherImplBase::DescribeNegationToImpl(os);\n  }\n\n  virtual bool MatchAndExplain(Container container,\n                               MatchResultListener* listener) const {\n    StlContainerReference stl_container = View::ConstReference(container);\n    ::std::vector<string> element_printouts;\n    MatchMatrix matrix = AnalyzeElements(stl_container.begin(),\n                                         stl_container.end(),\n                                         &element_printouts,\n                                         listener);\n\n    const size_t actual_count = matrix.LhsSize();\n    if (actual_count == 0 && matchers_.empty()) {\n      return true;\n    }\n    if (actual_count != matchers_.size()) {\n      // The element count doesn't match.  If the container is empty,\n      // there's no need to explain anything as Google Mock already\n      // prints the empty container. Otherwise we just need to show\n      // how many elements there actually are.\n      if (actual_count != 0 && listener->IsInterested()) {\n        *listener << \"which has \" << Elements(actual_count);\n      }\n      return false;\n    }\n\n    return VerifyAllElementsAndMatchersAreMatched(element_printouts,\n                                                  matrix, listener) &&\n           FindPairing(matrix, listener);\n  }\n\n private:\n  typedef ::std::vector<Matcher<const Element&> > MatcherVec;\n\n  template <typename ElementIter>\n  MatchMatrix AnalyzeElements(ElementIter elem_first, ElementIter elem_last,\n                              ::std::vector<string>* element_printouts,\n                              MatchResultListener* listener) const {\n    element_printouts->clear();\n    ::std::vector<char> did_match;\n    size_t num_elements = 0;\n    for (; elem_first != elem_last; ++num_elements, ++elem_first) {\n      if (listener->IsInterested()) {\n        element_printouts->push_back(PrintToString(*elem_first));\n      }\n      for (size_t irhs = 0; irhs != matchers_.size(); ++irhs) {\n        did_match.push_back(Matches(matchers_[irhs])(*elem_first));\n      }\n    }\n\n    MatchMatrix matrix(num_elements, matchers_.size());\n    ::std::vector<char>::const_iterator did_match_iter = did_match.begin();\n    for (size_t ilhs = 0; ilhs != num_elements; ++ilhs) {\n      for (size_t irhs = 0; irhs != matchers_.size(); ++irhs) {\n        matrix.SetEdge(ilhs, irhs, *did_match_iter++ != 0);\n      }\n    }\n    return matrix;\n  }\n\n  MatcherVec matchers_;\n\n  GTEST_DISALLOW_ASSIGN_(UnorderedElementsAreMatcherImpl);\n};\n\n// Functor for use in TransformTuple.\n// Performs MatcherCast<Target> on an input argument of any type.\ntemplate <typename Target>\nstruct CastAndAppendTransform {\n  template <typename Arg>\n  Matcher<Target> operator()(const Arg& a) const {\n    return MatcherCast<Target>(a);\n  }\n};\n\n// Implements UnorderedElementsAre.\ntemplate <typename MatcherTuple>\nclass UnorderedElementsAreMatcher {\n public:\n  explicit UnorderedElementsAreMatcher(const MatcherTuple& args)\n      : matchers_(args) {}\n\n  template <typename Container>\n  operator Matcher<Container>() const {\n    typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;\n    typedef typename internal::StlContainerView<RawContainer>::type View;\n    typedef typename View::value_type Element;\n    typedef ::std::vector<Matcher<const Element&> > MatcherVec;\n    MatcherVec matchers;\n    matchers.reserve(::std::tr1::tuple_size<MatcherTuple>::value);\n    TransformTupleValues(CastAndAppendTransform<const Element&>(), matchers_,\n                         ::std::back_inserter(matchers));\n    return MakeMatcher(new UnorderedElementsAreMatcherImpl<Container>(\n                           matchers.begin(), matchers.end()));\n  }\n\n private:\n  const MatcherTuple matchers_;\n  GTEST_DISALLOW_ASSIGN_(UnorderedElementsAreMatcher);\n};\n\n// Implements ElementsAre.\ntemplate <typename MatcherTuple>\nclass ElementsAreMatcher {\n public:\n  explicit ElementsAreMatcher(const MatcherTuple& args) : matchers_(args) {}\n\n  template <typename Container>\n  operator Matcher<Container>() const {\n    typedef GTEST_REMOVE_REFERENCE_AND_CONST_(Container) RawContainer;\n    typedef typename internal::StlContainerView<RawContainer>::type View;\n    typedef typename View::value_type Element;\n    typedef ::std::vector<Matcher<const Element&> > MatcherVec;\n    MatcherVec matchers;\n    matchers.reserve(::std::tr1::tuple_size<MatcherTuple>::value);\n    TransformTupleValues(CastAndAppendTransform<const Element&>(), matchers_,\n                         ::std::back_inserter(matchers));\n    return MakeMatcher(new ElementsAreMatcherImpl<Container>(\n                           matchers.begin(), matchers.end()));\n  }\n\n private:\n  const MatcherTuple matchers_;\n  GTEST_DISALLOW_ASSIGN_(ElementsAreMatcher);\n};\n\n// Implements UnorderedElementsAreArray().\ntemplate <typename T>\nclass UnorderedElementsAreArrayMatcher {\n public:\n  UnorderedElementsAreArrayMatcher() {}\n\n  template <typename Iter>\n  UnorderedElementsAreArrayMatcher(Iter first, Iter last)\n      : matchers_(first, last) {}\n\n  template <typename Container>\n  operator Matcher<Container>() const {\n    return MakeMatcher(\n        new UnorderedElementsAreMatcherImpl<Container>(matchers_.begin(),\n                                                       matchers_.end()));\n  }\n\n private:\n  ::std::vector<T> matchers_;\n\n  GTEST_DISALLOW_ASSIGN_(UnorderedElementsAreArrayMatcher);\n};\n\n// Implements ElementsAreArray().\ntemplate <typename T>\nclass ElementsAreArrayMatcher {\n public:\n  template <typename Iter>\n  ElementsAreArrayMatcher(Iter first, Iter last) : matchers_(first, last) {}\n\n  template <typename Container>\n  operator Matcher<Container>() const {\n    return MakeMatcher(new ElementsAreMatcherImpl<Container>(\n        matchers_.begin(), matchers_.end()));\n  }\n\n private:\n  const ::std::vector<T> matchers_;\n\n  GTEST_DISALLOW_ASSIGN_(ElementsAreArrayMatcher);\n};\n\n// Returns the description for a matcher defined using the MATCHER*()\n// macro where the user-supplied description string is \"\", if\n// 'negation' is false; otherwise returns the description of the\n// negation of the matcher.  'param_values' contains a list of strings\n// that are the print-out of the matcher's parameters.\nGTEST_API_ string FormatMatcherDescription(bool negation,\n                                           const char* matcher_name,\n                                           const Strings& param_values);\n\n}  // namespace internal\n\n// ElementsAreArray(first, last)\n// ElementsAreArray(pointer, count)\n// ElementsAreArray(array)\n// ElementsAreArray(vector)\n// ElementsAreArray({ e1, e2, ..., en })\n//\n// The ElementsAreArray() functions are like ElementsAre(...), except\n// that they are given a homogeneous sequence rather than taking each\n// element as a function argument. The sequence can be specified as an\n// array, a pointer and count, a vector, an initializer list, or an\n// STL iterator range. In each of these cases, the underlying sequence\n// can be either a sequence of values or a sequence of matchers.\n//\n// All forms of ElementsAreArray() make a copy of the input matcher sequence.\n\ntemplate <typename Iter>\ninline internal::ElementsAreArrayMatcher<\n    typename ::std::iterator_traits<Iter>::value_type>\nElementsAreArray(Iter first, Iter last) {\n  typedef typename ::std::iterator_traits<Iter>::value_type T;\n  return internal::ElementsAreArrayMatcher<T>(first, last);\n}\n\ntemplate <typename T>\ninline internal::ElementsAreArrayMatcher<T> ElementsAreArray(\n    const T* pointer, size_t count) {\n  return ElementsAreArray(pointer, pointer + count);\n}\n\ntemplate <typename T, size_t N>\ninline internal::ElementsAreArrayMatcher<T> ElementsAreArray(\n    const T (&array)[N]) {\n  return ElementsAreArray(array, N);\n}\n\ntemplate <typename T, typename A>\ninline internal::ElementsAreArrayMatcher<T> ElementsAreArray(\n    const ::std::vector<T, A>& vec) {\n  return ElementsAreArray(vec.begin(), vec.end());\n}\n\n#if GTEST_LANG_CXX11\ntemplate <typename T>\ninline internal::ElementsAreArrayMatcher<T>\nElementsAreArray(::std::initializer_list<T> xs) {\n  return ElementsAreArray(xs.begin(), xs.end());\n}\n#endif\n\n// UnorderedElementsAreArray(first, last)\n// UnorderedElementsAreArray(pointer, count)\n// UnorderedElementsAreArray(array)\n// UnorderedElementsAreArray(vector)\n// UnorderedElementsAreArray({ e1, e2, ..., en })\n//\n// The UnorderedElementsAreArray() functions are like\n// ElementsAreArray(...), but allow matching the elements in any order.\ntemplate <typename Iter>\ninline internal::UnorderedElementsAreArrayMatcher<\n    typename ::std::iterator_traits<Iter>::value_type>\nUnorderedElementsAreArray(Iter first, Iter last) {\n  typedef typename ::std::iterator_traits<Iter>::value_type T;\n  return internal::UnorderedElementsAreArrayMatcher<T>(first, last);\n}\n\ntemplate <typename T>\ninline internal::UnorderedElementsAreArrayMatcher<T>\nUnorderedElementsAreArray(const T* pointer, size_t count) {\n  return UnorderedElementsAreArray(pointer, pointer + count);\n}\n\ntemplate <typename T, size_t N>\ninline internal::UnorderedElementsAreArrayMatcher<T>\nUnorderedElementsAreArray(const T (&array)[N]) {\n  return UnorderedElementsAreArray(array, N);\n}\n\ntemplate <typename T, typename A>\ninline internal::UnorderedElementsAreArrayMatcher<T>\nUnorderedElementsAreArray(const ::std::vector<T, A>& vec) {\n  return UnorderedElementsAreArray(vec.begin(), vec.end());\n}\n\n#if GTEST_LANG_CXX11\ntemplate <typename T>\ninline internal::UnorderedElementsAreArrayMatcher<T>\nUnorderedElementsAreArray(::std::initializer_list<T> xs) {\n  return UnorderedElementsAreArray(xs.begin(), xs.end());\n}\n#endif\n\n// _ is a matcher that matches anything of any type.\n//\n// This definition is fine as:\n//\n//   1. The C++ standard permits using the name _ in a namespace that\n//      is not the global namespace or ::std.\n//   2. The AnythingMatcher class has no data member or constructor,\n//      so it's OK to create global variables of this type.\n//   3. c-style has approved of using _ in this case.\nconst internal::AnythingMatcher _ = {};\n// Creates a matcher that matches any value of the given type T.\ntemplate <typename T>\ninline Matcher<T> A() { return MakeMatcher(new internal::AnyMatcherImpl<T>()); }\n\n// Creates a matcher that matches any value of the given type T.\ntemplate <typename T>\ninline Matcher<T> An() { return A<T>(); }\n\n// Creates a polymorphic matcher that matches anything equal to x.\n// Note: if the parameter of Eq() were declared as const T&, Eq(\"foo\")\n// wouldn't compile.\ntemplate <typename T>\ninline internal::EqMatcher<T> Eq(T x) { return internal::EqMatcher<T>(x); }\n\n// Constructs a Matcher<T> from a 'value' of type T.  The constructed\n// matcher matches any value that's equal to 'value'.\ntemplate <typename T>\nMatcher<T>::Matcher(T value) { *this = Eq(value); }\n\n// Creates a monomorphic matcher that matches anything with type Lhs\n// and equal to rhs.  A user may need to use this instead of Eq(...)\n// in order to resolve an overloading ambiguity.\n//\n// TypedEq<T>(x) is just a convenient short-hand for Matcher<T>(Eq(x))\n// or Matcher<T>(x), but more readable than the latter.\n//\n// We could define similar monomorphic matchers for other comparison\n// operations (e.g. TypedLt, TypedGe, and etc), but decided not to do\n// it yet as those are used much less than Eq() in practice.  A user\n// can always write Matcher<T>(Lt(5)) to be explicit about the type,\n// for example.\ntemplate <typename Lhs, typename Rhs>\ninline Matcher<Lhs> TypedEq(const Rhs& rhs) { return Eq(rhs); }\n\n// Creates a polymorphic matcher that matches anything >= x.\ntemplate <typename Rhs>\ninline internal::GeMatcher<Rhs> Ge(Rhs x) {\n  return internal::GeMatcher<Rhs>(x);\n}\n\n// Creates a polymorphic matcher that matches anything > x.\ntemplate <typename Rhs>\ninline internal::GtMatcher<Rhs> Gt(Rhs x) {\n  return internal::GtMatcher<Rhs>(x);\n}\n\n// Creates a polymorphic matcher that matches anything <= x.\ntemplate <typename Rhs>\ninline internal::LeMatcher<Rhs> Le(Rhs x) {\n  return internal::LeMatcher<Rhs>(x);\n}\n\n// Creates a polymorphic matcher that matches anything < x.\ntemplate <typename Rhs>\ninline internal::LtMatcher<Rhs> Lt(Rhs x) {\n  return internal::LtMatcher<Rhs>(x);\n}\n\n// Creates a polymorphic matcher that matches anything != x.\ntemplate <typename Rhs>\ninline internal::NeMatcher<Rhs> Ne(Rhs x) {\n  return internal::NeMatcher<Rhs>(x);\n}\n\n// Creates a polymorphic matcher that matches any NULL pointer.\ninline PolymorphicMatcher<internal::IsNullMatcher > IsNull() {\n  return MakePolymorphicMatcher(internal::IsNullMatcher());\n}\n\n// Creates a polymorphic matcher that matches any non-NULL pointer.\n// This is convenient as Not(NULL) doesn't compile (the compiler\n// thinks that that expression is comparing a pointer with an integer).\ninline PolymorphicMatcher<internal::NotNullMatcher > NotNull() {\n  return MakePolymorphicMatcher(internal::NotNullMatcher());\n}\n\n// Creates a polymorphic matcher that matches any argument that\n// references variable x.\ntemplate <typename T>\ninline internal::RefMatcher<T&> Ref(T& x) {  // NOLINT\n  return internal::RefMatcher<T&>(x);\n}\n\n// Creates a matcher that matches any double argument approximately\n// equal to rhs, where two NANs are considered unequal.\ninline internal::FloatingEqMatcher<double> DoubleEq(double rhs) {\n  return internal::FloatingEqMatcher<double>(rhs, false);\n}\n\n// Creates a matcher that matches any double argument approximately\n// equal to rhs, including NaN values when rhs is NaN.\ninline internal::FloatingEqMatcher<double> NanSensitiveDoubleEq(double rhs) {\n  return internal::FloatingEqMatcher<double>(rhs, true);\n}\n\n// Creates a matcher that matches any double argument approximately equal to\n// rhs, up to the specified max absolute error bound, where two NANs are\n// considered unequal.  The max absolute error bound must be non-negative.\ninline internal::FloatingEqMatcher<double> DoubleNear(\n    double rhs, double max_abs_error) {\n  return internal::FloatingEqMatcher<double>(rhs, false, max_abs_error);\n}\n\n// Creates a matcher that matches any double argument approximately equal to\n// rhs, up to the specified max absolute error bound, including NaN values when\n// rhs is NaN.  The max absolute error bound must be non-negative.\ninline internal::FloatingEqMatcher<double> NanSensitiveDoubleNear(\n    double rhs, double max_abs_error) {\n  return internal::FloatingEqMatcher<double>(rhs, true, max_abs_error);\n}\n\n// Creates a matcher that matches any float argument approximately\n// equal to rhs, where two NANs are considered unequal.\ninline internal::FloatingEqMatcher<float> FloatEq(float rhs) {\n  return internal::FloatingEqMatcher<float>(rhs, false);\n}\n\n// Creates a matcher that matches any float argument approximately\n// equal to rhs, including NaN values when rhs is NaN.\ninline internal::FloatingEqMatcher<float> NanSensitiveFloatEq(float rhs) {\n  return internal::FloatingEqMatcher<float>(rhs, true);\n}\n\n// Creates a matcher that matches any float argument approximately equal to\n// rhs, up to the specified max absolute error bound, where two NANs are\n// considered unequal.  The max absolute error bound must be non-negative.\ninline internal::FloatingEqMatcher<float> FloatNear(\n    float rhs, float max_abs_error) {\n  return internal::FloatingEqMatcher<float>(rhs, false, max_abs_error);\n}\n\n// Creates a matcher that matches any float argument approximately equal to\n// rhs, up to the specified max absolute error bound, including NaN values when\n// rhs is NaN.  The max absolute error bound must be non-negative.\ninline internal::FloatingEqMatcher<float> NanSensitiveFloatNear(\n    float rhs, float max_abs_error) {\n  return internal::FloatingEqMatcher<float>(rhs, true, max_abs_error);\n}\n\n// Creates a matcher that matches a pointer (raw or smart) that points\n// to a value that matches inner_matcher.\ntemplate <typename InnerMatcher>\ninline internal::PointeeMatcher<InnerMatcher> Pointee(\n    const InnerMatcher& inner_matcher) {\n  return internal::PointeeMatcher<InnerMatcher>(inner_matcher);\n}\n\n// Creates a matcher that matches an object whose given field matches\n// 'matcher'.  For example,\n//   Field(&Foo::number, Ge(5))\n// matches a Foo object x iff x.number >= 5.\ntemplate <typename Class, typename FieldType, typename FieldMatcher>\ninline PolymorphicMatcher<\n  internal::FieldMatcher<Class, FieldType> > Field(\n    FieldType Class::*field, const FieldMatcher& matcher) {\n  return MakePolymorphicMatcher(\n      internal::FieldMatcher<Class, FieldType>(\n          field, MatcherCast<const FieldType&>(matcher)));\n  // The call to MatcherCast() is required for supporting inner\n  // matchers of compatible types.  For example, it allows\n  //   Field(&Foo::bar, m)\n  // to compile where bar is an int32 and m is a matcher for int64.\n}\n\n// Creates a matcher that matches an object whose given property\n// matches 'matcher'.  For example,\n//   Property(&Foo::str, StartsWith(\"hi\"))\n// matches a Foo object x iff x.str() starts with \"hi\".\ntemplate <typename Class, typename PropertyType, typename PropertyMatcher>\ninline PolymorphicMatcher<\n  internal::PropertyMatcher<Class, PropertyType> > Property(\n    PropertyType (Class::*property)() const, const PropertyMatcher& matcher) {\n  return MakePolymorphicMatcher(\n      internal::PropertyMatcher<Class, PropertyType>(\n          property,\n          MatcherCast<GTEST_REFERENCE_TO_CONST_(PropertyType)>(matcher)));\n  // The call to MatcherCast() is required for supporting inner\n  // matchers of compatible types.  For example, it allows\n  //   Property(&Foo::bar, m)\n  // to compile where bar() returns an int32 and m is a matcher for int64.\n}\n\n// Creates a matcher that matches an object iff the result of applying\n// a callable to x matches 'matcher'.\n// For example,\n//   ResultOf(f, StartsWith(\"hi\"))\n// matches a Foo object x iff f(x) starts with \"hi\".\n// callable parameter can be a function, function pointer, or a functor.\n// Callable has to satisfy the following conditions:\n//   * It is required to keep no state affecting the results of\n//     the calls on it and make no assumptions about how many calls\n//     will be made. Any state it keeps must be protected from the\n//     concurrent access.\n//   * If it is a function object, it has to define type result_type.\n//     We recommend deriving your functor classes from std::unary_function.\ntemplate <typename Callable, typename ResultOfMatcher>\ninternal::ResultOfMatcher<Callable> ResultOf(\n    Callable callable, const ResultOfMatcher& matcher) {\n  return internal::ResultOfMatcher<Callable>(\n          callable,\n          MatcherCast<typename internal::CallableTraits<Callable>::ResultType>(\n              matcher));\n  // The call to MatcherCast() is required for supporting inner\n  // matchers of compatible types.  For example, it allows\n  //   ResultOf(Function, m)\n  // to compile where Function() returns an int32 and m is a matcher for int64.\n}\n\n// String matchers.\n\n// Matches a string equal to str.\ninline PolymorphicMatcher<internal::StrEqualityMatcher<internal::string> >\n    StrEq(const internal::string& str) {\n  return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::string>(\n      str, true, true));\n}\n\n// Matches a string not equal to str.\ninline PolymorphicMatcher<internal::StrEqualityMatcher<internal::string> >\n    StrNe(const internal::string& str) {\n  return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::string>(\n      str, false, true));\n}\n\n// Matches a string equal to str, ignoring case.\ninline PolymorphicMatcher<internal::StrEqualityMatcher<internal::string> >\n    StrCaseEq(const internal::string& str) {\n  return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::string>(\n      str, true, false));\n}\n\n// Matches a string not equal to str, ignoring case.\ninline PolymorphicMatcher<internal::StrEqualityMatcher<internal::string> >\n    StrCaseNe(const internal::string& str) {\n  return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::string>(\n      str, false, false));\n}\n\n// Creates a matcher that matches any string, std::string, or C string\n// that contains the given substring.\ninline PolymorphicMatcher<internal::HasSubstrMatcher<internal::string> >\n    HasSubstr(const internal::string& substring) {\n  return MakePolymorphicMatcher(internal::HasSubstrMatcher<internal::string>(\n      substring));\n}\n\n// Matches a string that starts with 'prefix' (case-sensitive).\ninline PolymorphicMatcher<internal::StartsWithMatcher<internal::string> >\n    StartsWith(const internal::string& prefix) {\n  return MakePolymorphicMatcher(internal::StartsWithMatcher<internal::string>(\n      prefix));\n}\n\n// Matches a string that ends with 'suffix' (case-sensitive).\ninline PolymorphicMatcher<internal::EndsWithMatcher<internal::string> >\n    EndsWith(const internal::string& suffix) {\n  return MakePolymorphicMatcher(internal::EndsWithMatcher<internal::string>(\n      suffix));\n}\n\n// Matches a string that fully matches regular expression 'regex'.\n// The matcher takes ownership of 'regex'.\ninline PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex(\n    const internal::RE* regex) {\n  return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, true));\n}\ninline PolymorphicMatcher<internal::MatchesRegexMatcher> MatchesRegex(\n    const internal::string& regex) {\n  return MatchesRegex(new internal::RE(regex));\n}\n\n// Matches a string that contains regular expression 'regex'.\n// The matcher takes ownership of 'regex'.\ninline PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex(\n    const internal::RE* regex) {\n  return MakePolymorphicMatcher(internal::MatchesRegexMatcher(regex, false));\n}\ninline PolymorphicMatcher<internal::MatchesRegexMatcher> ContainsRegex(\n    const internal::string& regex) {\n  return ContainsRegex(new internal::RE(regex));\n}\n\n#if GTEST_HAS_GLOBAL_WSTRING || GTEST_HAS_STD_WSTRING\n// Wide string matchers.\n\n// Matches a string equal to str.\ninline PolymorphicMatcher<internal::StrEqualityMatcher<internal::wstring> >\n    StrEq(const internal::wstring& str) {\n  return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::wstring>(\n      str, true, true));\n}\n\n// Matches a string not equal to str.\ninline PolymorphicMatcher<internal::StrEqualityMatcher<internal::wstring> >\n    StrNe(const internal::wstring& str) {\n  return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::wstring>(\n      str, false, true));\n}\n\n// Matches a string equal to str, ignoring case.\ninline PolymorphicMatcher<internal::StrEqualityMatcher<internal::wstring> >\n    StrCaseEq(const internal::wstring& str) {\n  return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::wstring>(\n      str, true, false));\n}\n\n// Matches a string not equal to str, ignoring case.\ninline PolymorphicMatcher<internal::StrEqualityMatcher<internal::wstring> >\n    StrCaseNe(const internal::wstring& str) {\n  return MakePolymorphicMatcher(internal::StrEqualityMatcher<internal::wstring>(\n      str, false, false));\n}\n\n// Creates a matcher that matches any wstring, std::wstring, or C wide string\n// that contains the given substring.\ninline PolymorphicMatcher<internal::HasSubstrMatcher<internal::wstring> >\n    HasSubstr(const internal::wstring& substring) {\n  return MakePolymorphicMatcher(internal::HasSubstrMatcher<internal::wstring>(\n      substring));\n}\n\n// Matches a string that starts with 'prefix' (case-sensitive).\ninline PolymorphicMatcher<internal::StartsWithMatcher<internal::wstring> >\n    StartsWith(const internal::wstring& prefix) {\n  return MakePolymorphicMatcher(internal::StartsWithMatcher<internal::wstring>(\n      prefix));\n}\n\n// Matches a string that ends with 'suffix' (case-sensitive).\ninline PolymorphicMatcher<internal::EndsWithMatcher<internal::wstring> >\n    EndsWith(const internal::wstring& suffix) {\n  return MakePolymorphicMatcher(internal::EndsWithMatcher<internal::wstring>(\n      suffix));\n}\n\n#endif  // GTEST_HAS_GLOBAL_WSTRING || GTEST_HAS_STD_WSTRING\n\n// Creates a polymorphic matcher that matches a 2-tuple where the\n// first field == the second field.\ninline internal::Eq2Matcher Eq() { return internal::Eq2Matcher(); }\n\n// Creates a polymorphic matcher that matches a 2-tuple where the\n// first field >= the second field.\ninline internal::Ge2Matcher Ge() { return internal::Ge2Matcher(); }\n\n// Creates a polymorphic matcher that matches a 2-tuple where the\n// first field > the second field.\ninline internal::Gt2Matcher Gt() { return internal::Gt2Matcher(); }\n\n// Creates a polymorphic matcher that matches a 2-tuple where the\n// first field <= the second field.\ninline internal::Le2Matcher Le() { return internal::Le2Matcher(); }\n\n// Creates a polymorphic matcher that matches a 2-tuple where the\n// first field < the second field.\ninline internal::Lt2Matcher Lt() { return internal::Lt2Matcher(); }\n\n// Creates a polymorphic matcher that matches a 2-tuple where the\n// first field != the second field.\ninline internal::Ne2Matcher Ne() { return internal::Ne2Matcher(); }\n\n// Creates a matcher that matches any value of type T that m doesn't\n// match.\ntemplate <typename InnerMatcher>\ninline internal::NotMatcher<InnerMatcher> Not(InnerMatcher m) {\n  return internal::NotMatcher<InnerMatcher>(m);\n}\n\n// Returns a matcher that matches anything that satisfies the given\n// predicate.  The predicate can be any unary function or functor\n// whose return type can be implicitly converted to bool.\ntemplate <typename Predicate>\ninline PolymorphicMatcher<internal::TrulyMatcher<Predicate> >\nTruly(Predicate pred) {\n  return MakePolymorphicMatcher(internal::TrulyMatcher<Predicate>(pred));\n}\n\n// Returns a matcher that matches the container size. The container must\n// support both size() and size_type which all STL-like containers provide.\n// Note that the parameter 'size' can be a value of type size_type as well as\n// matcher. For instance:\n//   EXPECT_THAT(container, SizeIs(2));     // Checks container has 2 elements.\n//   EXPECT_THAT(container, SizeIs(Le(2));  // Checks container has at most 2.\ntemplate <typename SizeMatcher>\ninline internal::SizeIsMatcher<SizeMatcher>\nSizeIs(const SizeMatcher& size_matcher) {\n  return internal::SizeIsMatcher<SizeMatcher>(size_matcher);\n}\n\n// Returns a matcher that matches an equal container.\n// This matcher behaves like Eq(), but in the event of mismatch lists the\n// values that are included in one container but not the other. (Duplicate\n// values and order differences are not explained.)\ntemplate <typename Container>\ninline PolymorphicMatcher<internal::ContainerEqMatcher<  // NOLINT\n                            GTEST_REMOVE_CONST_(Container)> >\n    ContainerEq(const Container& rhs) {\n  // This following line is for working around a bug in MSVC 8.0,\n  // which causes Container to be a const type sometimes.\n  typedef GTEST_REMOVE_CONST_(Container) RawContainer;\n  return MakePolymorphicMatcher(\n      internal::ContainerEqMatcher<RawContainer>(rhs));\n}\n\n// Returns a matcher that matches a container that, when sorted using\n// the given comparator, matches container_matcher.\ntemplate <typename Comparator, typename ContainerMatcher>\ninline internal::WhenSortedByMatcher<Comparator, ContainerMatcher>\nWhenSortedBy(const Comparator& comparator,\n             const ContainerMatcher& container_matcher) {\n  return internal::WhenSortedByMatcher<Comparator, ContainerMatcher>(\n      comparator, container_matcher);\n}\n\n// Returns a matcher that matches a container that, when sorted using\n// the < operator, matches container_matcher.\ntemplate <typename ContainerMatcher>\ninline internal::WhenSortedByMatcher<internal::LessComparator, ContainerMatcher>\nWhenSorted(const ContainerMatcher& container_matcher) {\n  return\n      internal::WhenSortedByMatcher<internal::LessComparator, ContainerMatcher>(\n          internal::LessComparator(), container_matcher);\n}\n\n// Matches an STL-style container or a native array that contains the\n// same number of elements as in rhs, where its i-th element and rhs's\n// i-th element (as a pair) satisfy the given pair matcher, for all i.\n// TupleMatcher must be able to be safely cast to Matcher<tuple<const\n// T1&, const T2&> >, where T1 and T2 are the types of elements in the\n// LHS container and the RHS container respectively.\ntemplate <typename TupleMatcher, typename Container>\ninline internal::PointwiseMatcher<TupleMatcher,\n                                  GTEST_REMOVE_CONST_(Container)>\nPointwise(const TupleMatcher& tuple_matcher, const Container& rhs) {\n  // This following line is for working around a bug in MSVC 8.0,\n  // which causes Container to be a const type sometimes.\n  typedef GTEST_REMOVE_CONST_(Container) RawContainer;\n  return internal::PointwiseMatcher<TupleMatcher, RawContainer>(\n      tuple_matcher, rhs);\n}\n\n// Matches an STL-style container or a native array that contains at\n// least one element matching the given value or matcher.\n//\n// Examples:\n//   ::std::set<int> page_ids;\n//   page_ids.insert(3);\n//   page_ids.insert(1);\n//   EXPECT_THAT(page_ids, Contains(1));\n//   EXPECT_THAT(page_ids, Contains(Gt(2)));\n//   EXPECT_THAT(page_ids, Not(Contains(4)));\n//\n//   ::std::map<int, size_t> page_lengths;\n//   page_lengths[1] = 100;\n//   EXPECT_THAT(page_lengths,\n//               Contains(::std::pair<const int, size_t>(1, 100)));\n//\n//   const char* user_ids[] = { \"joe\", \"mike\", \"tom\" };\n//   EXPECT_THAT(user_ids, Contains(Eq(::std::string(\"tom\"))));\ntemplate <typename M>\ninline internal::ContainsMatcher<M> Contains(M matcher) {\n  return internal::ContainsMatcher<M>(matcher);\n}\n\n// Matches an STL-style container or a native array that contains only\n// elements matching the given value or matcher.\n//\n// Each(m) is semantically equivalent to Not(Contains(Not(m))). Only\n// the messages are different.\n//\n// Examples:\n//   ::std::set<int> page_ids;\n//   // Each(m) matches an empty container, regardless of what m is.\n//   EXPECT_THAT(page_ids, Each(Eq(1)));\n//   EXPECT_THAT(page_ids, Each(Eq(77)));\n//\n//   page_ids.insert(3);\n//   EXPECT_THAT(page_ids, Each(Gt(0)));\n//   EXPECT_THAT(page_ids, Not(Each(Gt(4))));\n//   page_ids.insert(1);\n//   EXPECT_THAT(page_ids, Not(Each(Lt(2))));\n//\n//   ::std::map<int, size_t> page_lengths;\n//   page_lengths[1] = 100;\n//   page_lengths[2] = 200;\n//   page_lengths[3] = 300;\n//   EXPECT_THAT(page_lengths, Not(Each(Pair(1, 100))));\n//   EXPECT_THAT(page_lengths, Each(Key(Le(3))));\n//\n//   const char* user_ids[] = { \"joe\", \"mike\", \"tom\" };\n//   EXPECT_THAT(user_ids, Not(Each(Eq(::std::string(\"tom\")))));\ntemplate <typename M>\ninline internal::EachMatcher<M> Each(M matcher) {\n  return internal::EachMatcher<M>(matcher);\n}\n\n// Key(inner_matcher) matches an std::pair whose 'first' field matches\n// inner_matcher.  For example, Contains(Key(Ge(5))) can be used to match an\n// std::map that contains at least one element whose key is >= 5.\ntemplate <typename M>\ninline internal::KeyMatcher<M> Key(M inner_matcher) {\n  return internal::KeyMatcher<M>(inner_matcher);\n}\n\n// Pair(first_matcher, second_matcher) matches a std::pair whose 'first' field\n// matches first_matcher and whose 'second' field matches second_matcher.  For\n// example, EXPECT_THAT(map_type, ElementsAre(Pair(Ge(5), \"foo\"))) can be used\n// to match a std::map<int, string> that contains exactly one element whose key\n// is >= 5 and whose value equals \"foo\".\ntemplate <typename FirstMatcher, typename SecondMatcher>\ninline internal::PairMatcher<FirstMatcher, SecondMatcher>\nPair(FirstMatcher first_matcher, SecondMatcher second_matcher) {\n  return internal::PairMatcher<FirstMatcher, SecondMatcher>(\n      first_matcher, second_matcher);\n}\n\n// Returns a predicate that is satisfied by anything that matches the\n// given matcher.\ntemplate <typename M>\ninline internal::MatcherAsPredicate<M> Matches(M matcher) {\n  return internal::MatcherAsPredicate<M>(matcher);\n}\n\n// Returns true iff the value matches the matcher.\ntemplate <typename T, typename M>\ninline bool Value(const T& value, M matcher) {\n  return testing::Matches(matcher)(value);\n}\n\n// Matches the value against the given matcher and explains the match\n// result to listener.\ntemplate <typename T, typename M>\ninline bool ExplainMatchResult(\n    M matcher, const T& value, MatchResultListener* listener) {\n  return SafeMatcherCast<const T&>(matcher).MatchAndExplain(value, listener);\n}\n\n#if GTEST_LANG_CXX11\n// Define variadic matcher versions. They are overloaded in\n// gmock-generated-matchers.h for the cases supported by pre C++11 compilers.\ntemplate <typename... Args>\ninline internal::AllOfMatcher<Args...> AllOf(const Args&... matchers) {\n  return internal::AllOfMatcher<Args...>(matchers...);\n}\n\ntemplate <typename... Args>\ninline internal::AnyOfMatcher<Args...> AnyOf(const Args&... matchers) {\n  return internal::AnyOfMatcher<Args...>(matchers...);\n}\n\n#endif  // GTEST_LANG_CXX11\n\n// AllArgs(m) is a synonym of m.  This is useful in\n//\n//   EXPECT_CALL(foo, Bar(_, _)).With(AllArgs(Eq()));\n//\n// which is easier to read than\n//\n//   EXPECT_CALL(foo, Bar(_, _)).With(Eq());\ntemplate <typename InnerMatcher>\ninline InnerMatcher AllArgs(const InnerMatcher& matcher) { return matcher; }\n\n// These macros allow using matchers to check values in Google Test\n// tests.  ASSERT_THAT(value, matcher) and EXPECT_THAT(value, matcher)\n// succeed iff the value matches the matcher.  If the assertion fails,\n// the value and the description of the matcher will be printed.\n#define ASSERT_THAT(value, matcher) ASSERT_PRED_FORMAT1(\\\n    ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)\n#define EXPECT_THAT(value, matcher) EXPECT_PRED_FORMAT1(\\\n    ::testing::internal::MakePredicateFormatterFromMatcher(matcher), value)\n\n}  // namespace testing\n\n#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_MATCHERS_H_\n"
  },
  {
    "path": "ext/gmock/include/gmock/gmock-more-actions.h",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements some actions that depend on gmock-generated-actions.h.\n\n#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_\n#define GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_\n\n#include <algorithm>\n\n#include \"gmock/gmock-generated-actions.h\"\n\nnamespace testing {\nnamespace internal {\n\n// Implements the Invoke(f) action.  The template argument\n// FunctionImpl is the implementation type of f, which can be either a\n// function pointer or a functor.  Invoke(f) can be used as an\n// Action<F> as long as f's type is compatible with F (i.e. f can be\n// assigned to a tr1::function<F>).\ntemplate <typename FunctionImpl>\nclass InvokeAction {\n public:\n  // The c'tor makes a copy of function_impl (either a function\n  // pointer or a functor).\n  explicit InvokeAction(FunctionImpl function_impl)\n      : function_impl_(function_impl) {}\n\n  template <typename Result, typename ArgumentTuple>\n  Result Perform(const ArgumentTuple& args) {\n    return InvokeHelper<Result, ArgumentTuple>::Invoke(function_impl_, args);\n  }\n\n private:\n  FunctionImpl function_impl_;\n\n  GTEST_DISALLOW_ASSIGN_(InvokeAction);\n};\n\n// Implements the Invoke(object_ptr, &Class::Method) action.\ntemplate <class Class, typename MethodPtr>\nclass InvokeMethodAction {\n public:\n  InvokeMethodAction(Class* obj_ptr, MethodPtr method_ptr)\n      : obj_ptr_(obj_ptr), method_ptr_(method_ptr) {}\n\n  template <typename Result, typename ArgumentTuple>\n  Result Perform(const ArgumentTuple& args) const {\n    return InvokeHelper<Result, ArgumentTuple>::InvokeMethod(\n        obj_ptr_, method_ptr_, args);\n  }\n\n private:\n  Class* const obj_ptr_;\n  const MethodPtr method_ptr_;\n\n  GTEST_DISALLOW_ASSIGN_(InvokeMethodAction);\n};\n\n}  // namespace internal\n\n// Various overloads for Invoke().\n\n// Creates an action that invokes 'function_impl' with the mock\n// function's arguments.\ntemplate <typename FunctionImpl>\nPolymorphicAction<internal::InvokeAction<FunctionImpl> > Invoke(\n    FunctionImpl function_impl) {\n  return MakePolymorphicAction(\n      internal::InvokeAction<FunctionImpl>(function_impl));\n}\n\n// Creates an action that invokes the given method on the given object\n// with the mock function's arguments.\ntemplate <class Class, typename MethodPtr>\nPolymorphicAction<internal::InvokeMethodAction<Class, MethodPtr> > Invoke(\n    Class* obj_ptr, MethodPtr method_ptr) {\n  return MakePolymorphicAction(\n      internal::InvokeMethodAction<Class, MethodPtr>(obj_ptr, method_ptr));\n}\n\n// WithoutArgs(inner_action) can be used in a mock function with a\n// non-empty argument list to perform inner_action, which takes no\n// argument.  In other words, it adapts an action accepting no\n// argument to one that accepts (and ignores) arguments.\ntemplate <typename InnerAction>\ninline internal::WithArgsAction<InnerAction>\nWithoutArgs(const InnerAction& action) {\n  return internal::WithArgsAction<InnerAction>(action);\n}\n\n// WithArg<k>(an_action) creates an action that passes the k-th\n// (0-based) argument of the mock function to an_action and performs\n// it.  It adapts an action accepting one argument to one that accepts\n// multiple arguments.  For convenience, we also provide\n// WithArgs<k>(an_action) (defined below) as a synonym.\ntemplate <int k, typename InnerAction>\ninline internal::WithArgsAction<InnerAction, k>\nWithArg(const InnerAction& action) {\n  return internal::WithArgsAction<InnerAction, k>(action);\n}\n\n// The ACTION*() macros trigger warning C4100 (unreferenced formal\n// parameter) in MSVC with -W4.  Unfortunately they cannot be fixed in\n// the macro definition, as the warnings are generated when the macro\n// is expanded and macro expansion cannot contain #pragma.  Therefore\n// we suppress them here.\n#ifdef _MSC_VER\n# pragma warning(push)\n# pragma warning(disable:4100)\n#endif\n\n// Action ReturnArg<k>() returns the k-th argument of the mock function.\nACTION_TEMPLATE(ReturnArg,\n                HAS_1_TEMPLATE_PARAMS(int, k),\n                AND_0_VALUE_PARAMS()) {\n  return std::tr1::get<k>(args);\n}\n\n// Action SaveArg<k>(pointer) saves the k-th (0-based) argument of the\n// mock function to *pointer.\nACTION_TEMPLATE(SaveArg,\n                HAS_1_TEMPLATE_PARAMS(int, k),\n                AND_1_VALUE_PARAMS(pointer)) {\n  *pointer = ::std::tr1::get<k>(args);\n}\n\n// Action SaveArgPointee<k>(pointer) saves the value pointed to\n// by the k-th (0-based) argument of the mock function to *pointer.\nACTION_TEMPLATE(SaveArgPointee,\n                HAS_1_TEMPLATE_PARAMS(int, k),\n                AND_1_VALUE_PARAMS(pointer)) {\n  *pointer = *::std::tr1::get<k>(args);\n}\n\n// Action SetArgReferee<k>(value) assigns 'value' to the variable\n// referenced by the k-th (0-based) argument of the mock function.\nACTION_TEMPLATE(SetArgReferee,\n                HAS_1_TEMPLATE_PARAMS(int, k),\n                AND_1_VALUE_PARAMS(value)) {\n  typedef typename ::std::tr1::tuple_element<k, args_type>::type argk_type;\n  // Ensures that argument #k is a reference.  If you get a compiler\n  // error on the next line, you are using SetArgReferee<k>(value) in\n  // a mock function whose k-th (0-based) argument is not a reference.\n  GTEST_COMPILE_ASSERT_(internal::is_reference<argk_type>::value,\n                        SetArgReferee_must_be_used_with_a_reference_argument);\n  ::std::tr1::get<k>(args) = value;\n}\n\n// Action SetArrayArgument<k>(first, last) copies the elements in\n// source range [first, last) to the array pointed to by the k-th\n// (0-based) argument, which can be either a pointer or an\n// iterator. The action does not take ownership of the elements in the\n// source range.\nACTION_TEMPLATE(SetArrayArgument,\n                HAS_1_TEMPLATE_PARAMS(int, k),\n                AND_2_VALUE_PARAMS(first, last)) {\n  // Microsoft compiler deprecates ::std::copy, so we want to suppress warning\n  // 4996 (Function call with parameters that may be unsafe) there.\n#ifdef _MSC_VER\n# pragma warning(push)          // Saves the current warning state.\n# pragma warning(disable:4996)  // Temporarily disables warning 4996.\n#endif\n  ::std::copy(first, last, ::std::tr1::get<k>(args));\n#ifdef _MSC_VER\n# pragma warning(pop)           // Restores the warning state.\n#endif\n}\n\n// Action DeleteArg<k>() deletes the k-th (0-based) argument of the mock\n// function.\nACTION_TEMPLATE(DeleteArg,\n                HAS_1_TEMPLATE_PARAMS(int, k),\n                AND_0_VALUE_PARAMS()) {\n  delete ::std::tr1::get<k>(args);\n}\n\n// This action returns the value pointed to by 'pointer'.\nACTION_P(ReturnPointee, pointer) { return *pointer; }\n\n// Action Throw(exception) can be used in a mock function of any type\n// to throw the given exception.  Any copyable value can be thrown.\n#if GTEST_HAS_EXCEPTIONS\n\n// Suppresses the 'unreachable code' warning that VC generates in opt modes.\n# ifdef _MSC_VER\n#  pragma warning(push)          // Saves the current warning state.\n#  pragma warning(disable:4702)  // Temporarily disables warning 4702.\n# endif\nACTION_P(Throw, exception) { throw exception; }\n# ifdef _MSC_VER\n#  pragma warning(pop)           // Restores the warning state.\n# endif\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n#ifdef _MSC_VER\n# pragma warning(pop)\n#endif\n\n}  // namespace testing\n\n#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_MORE_ACTIONS_H_\n"
  },
  {
    "path": "ext/gmock/include/gmock/gmock-more-matchers.h",
    "content": "// Copyright 2013, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: marcus.boerger@google.com (Marcus Boerger)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements some matchers that depend on gmock-generated-matchers.h.\n//\n// Note that tests are implemented in gmock-matchers_test.cc rather than\n// gmock-more-matchers-test.cc.\n\n#ifndef GMOCK_GMOCK_MORE_MATCHERS_H_\n#define GMOCK_GMOCK_MORE_MATCHERS_H_\n\n#include \"gmock/gmock-generated-matchers.h\"\n\nnamespace testing {\n\n// Defines a matcher that matches an empty container. The container must\n// support both size() and empty(), which all STL-like containers provide.\nMATCHER(IsEmpty, negation ? \"isn't empty\" : \"is empty\") {\n  if (arg.empty()) {\n    return true;\n  }\n  *result_listener << \"whose size is \" << arg.size();\n  return false;\n}\n\n}  // namespace testing\n\n#endif  // GMOCK_GMOCK_MORE_MATCHERS_H_\n"
  },
  {
    "path": "ext/gmock/include/gmock/gmock-spec-builders.h",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements the ON_CALL() and EXPECT_CALL() macros.\n//\n// A user can use the ON_CALL() macro to specify the default action of\n// a mock method.  The syntax is:\n//\n//   ON_CALL(mock_object, Method(argument-matchers))\n//       .With(multi-argument-matcher)\n//       .WillByDefault(action);\n//\n//  where the .With() clause is optional.\n//\n// A user can use the EXPECT_CALL() macro to specify an expectation on\n// a mock method.  The syntax is:\n//\n//   EXPECT_CALL(mock_object, Method(argument-matchers))\n//       .With(multi-argument-matchers)\n//       .Times(cardinality)\n//       .InSequence(sequences)\n//       .After(expectations)\n//       .WillOnce(action)\n//       .WillRepeatedly(action)\n//       .RetiresOnSaturation();\n//\n// where all clauses are optional, and .InSequence()/.After()/\n// .WillOnce() can appear any number of times.\n\n#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_\n#define GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_\n\n#include <map>\n#include <set>\n#include <sstream>\n#include <string>\n#include <vector>\n\n#if GTEST_HAS_EXCEPTIONS\n# include <stdexcept>  // NOLINT\n#endif\n\n#include \"gmock/gmock-actions.h\"\n#include \"gmock/gmock-cardinalities.h\"\n#include \"gmock/gmock-matchers.h\"\n#include \"gmock/internal/gmock-internal-utils.h\"\n#include \"gmock/internal/gmock-port.h\"\n#include \"gtest/gtest.h\"\n\nnamespace testing {\n\n// An abstract handle of an expectation.\nclass Expectation;\n\n// A set of expectation handles.\nclass ExpectationSet;\n\n// Anything inside the 'internal' namespace IS INTERNAL IMPLEMENTATION\n// and MUST NOT BE USED IN USER CODE!!!\nnamespace internal {\n\n// Implements a mock function.\ntemplate <typename F> class FunctionMocker;\n\n// Base class for expectations.\nclass ExpectationBase;\n\n// Implements an expectation.\ntemplate <typename F> class TypedExpectation;\n\n// Helper class for testing the Expectation class template.\nclass ExpectationTester;\n\n// Base class for function mockers.\ntemplate <typename F> class FunctionMockerBase;\n\n// Protects the mock object registry (in class Mock), all function\n// mockers, and all expectations.\n//\n// The reason we don't use more fine-grained protection is: when a\n// mock function Foo() is called, it needs to consult its expectations\n// to see which one should be picked.  If another thread is allowed to\n// call a mock function (either Foo() or a different one) at the same\n// time, it could affect the \"retired\" attributes of Foo()'s\n// expectations when InSequence() is used, and thus affect which\n// expectation gets picked.  Therefore, we sequence all mock function\n// calls to ensure the integrity of the mock objects' states.\nGTEST_API_ GTEST_DECLARE_STATIC_MUTEX_(g_gmock_mutex);\n\n// Untyped base class for ActionResultHolder<R>.\nclass UntypedActionResultHolderBase;\n\n// Abstract base class of FunctionMockerBase.  This is the\n// type-agnostic part of the function mocker interface.  Its pure\n// virtual methods are implemented by FunctionMockerBase.\nclass GTEST_API_ UntypedFunctionMockerBase {\n public:\n  UntypedFunctionMockerBase();\n  virtual ~UntypedFunctionMockerBase();\n\n  // Verifies that all expectations on this mock function have been\n  // satisfied.  Reports one or more Google Test non-fatal failures\n  // and returns false if not.\n  bool VerifyAndClearExpectationsLocked()\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);\n\n  // Clears the ON_CALL()s set on this mock function.\n  virtual void ClearDefaultActionsLocked()\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) = 0;\n\n  // In all of the following Untyped* functions, it's the caller's\n  // responsibility to guarantee the correctness of the arguments'\n  // types.\n\n  // Performs the default action with the given arguments and returns\n  // the action's result.  The call description string will be used in\n  // the error message to describe the call in the case the default\n  // action fails.\n  // L = *\n  virtual UntypedActionResultHolderBase* UntypedPerformDefaultAction(\n      const void* untyped_args,\n      const string& call_description) const = 0;\n\n  // Performs the given action with the given arguments and returns\n  // the action's result.\n  // L = *\n  virtual UntypedActionResultHolderBase* UntypedPerformAction(\n      const void* untyped_action,\n      const void* untyped_args) const = 0;\n\n  // Writes a message that the call is uninteresting (i.e. neither\n  // explicitly expected nor explicitly unexpected) to the given\n  // ostream.\n  virtual void UntypedDescribeUninterestingCall(\n      const void* untyped_args,\n      ::std::ostream* os) const\n          GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0;\n\n  // Returns the expectation that matches the given function arguments\n  // (or NULL is there's no match); when a match is found,\n  // untyped_action is set to point to the action that should be\n  // performed (or NULL if the action is \"do default\"), and\n  // is_excessive is modified to indicate whether the call exceeds the\n  // expected number.\n  virtual const ExpectationBase* UntypedFindMatchingExpectation(\n      const void* untyped_args,\n      const void** untyped_action, bool* is_excessive,\n      ::std::ostream* what, ::std::ostream* why)\n          GTEST_LOCK_EXCLUDED_(g_gmock_mutex) = 0;\n\n  // Prints the given function arguments to the ostream.\n  virtual void UntypedPrintArgs(const void* untyped_args,\n                                ::std::ostream* os) const = 0;\n\n  // Sets the mock object this mock method belongs to, and registers\n  // this information in the global mock registry.  Will be called\n  // whenever an EXPECT_CALL() or ON_CALL() is executed on this mock\n  // method.\n  // TODO(wan@google.com): rename to SetAndRegisterOwner().\n  void RegisterOwner(const void* mock_obj)\n      GTEST_LOCK_EXCLUDED_(g_gmock_mutex);\n\n  // Sets the mock object this mock method belongs to, and sets the\n  // name of the mock function.  Will be called upon each invocation\n  // of this mock function.\n  void SetOwnerAndName(const void* mock_obj, const char* name)\n      GTEST_LOCK_EXCLUDED_(g_gmock_mutex);\n\n  // Returns the mock object this mock method belongs to.  Must be\n  // called after RegisterOwner() or SetOwnerAndName() has been\n  // called.\n  const void* MockObject() const\n      GTEST_LOCK_EXCLUDED_(g_gmock_mutex);\n\n  // Returns the name of this mock method.  Must be called after\n  // SetOwnerAndName() has been called.\n  const char* Name() const\n      GTEST_LOCK_EXCLUDED_(g_gmock_mutex);\n\n  // Returns the result of invoking this mock function with the given\n  // arguments.  This function can be safely called from multiple\n  // threads concurrently.  The caller is responsible for deleting the\n  // result.\n  const UntypedActionResultHolderBase* UntypedInvokeWith(\n      const void* untyped_args)\n          GTEST_LOCK_EXCLUDED_(g_gmock_mutex);\n\n protected:\n  typedef std::vector<const void*> UntypedOnCallSpecs;\n\n  typedef std::vector<internal::linked_ptr<ExpectationBase> >\n  UntypedExpectations;\n\n  // Returns an Expectation object that references and co-owns exp,\n  // which must be an expectation on this mock function.\n  Expectation GetHandleOf(ExpectationBase* exp);\n\n  // Address of the mock object this mock method belongs to.  Only\n  // valid after this mock method has been called or\n  // ON_CALL/EXPECT_CALL has been invoked on it.\n  const void* mock_obj_;  // Protected by g_gmock_mutex.\n\n  // Name of the function being mocked.  Only valid after this mock\n  // method has been called.\n  const char* name_;  // Protected by g_gmock_mutex.\n\n  // All default action specs for this function mocker.\n  UntypedOnCallSpecs untyped_on_call_specs_;\n\n  // All expectations for this function mocker.\n  UntypedExpectations untyped_expectations_;\n};  // class UntypedFunctionMockerBase\n\n// Untyped base class for OnCallSpec<F>.\nclass UntypedOnCallSpecBase {\n public:\n  // The arguments are the location of the ON_CALL() statement.\n  UntypedOnCallSpecBase(const char* a_file, int a_line)\n      : file_(a_file), line_(a_line), last_clause_(kNone) {}\n\n  // Where in the source file was the default action spec defined?\n  const char* file() const { return file_; }\n  int line() const { return line_; }\n\n protected:\n  // Gives each clause in the ON_CALL() statement a name.\n  enum Clause {\n    // Do not change the order of the enum members!  The run-time\n    // syntax checking relies on it.\n    kNone,\n    kWith,\n    kWillByDefault\n  };\n\n  // Asserts that the ON_CALL() statement has a certain property.\n  void AssertSpecProperty(bool property, const string& failure_message) const {\n    Assert(property, file_, line_, failure_message);\n  }\n\n  // Expects that the ON_CALL() statement has a certain property.\n  void ExpectSpecProperty(bool property, const string& failure_message) const {\n    Expect(property, file_, line_, failure_message);\n  }\n\n  const char* file_;\n  int line_;\n\n  // The last clause in the ON_CALL() statement as seen so far.\n  // Initially kNone and changes as the statement is parsed.\n  Clause last_clause_;\n};  // class UntypedOnCallSpecBase\n\n// This template class implements an ON_CALL spec.\ntemplate <typename F>\nclass OnCallSpec : public UntypedOnCallSpecBase {\n public:\n  typedef typename Function<F>::ArgumentTuple ArgumentTuple;\n  typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;\n\n  // Constructs an OnCallSpec object from the information inside\n  // the parenthesis of an ON_CALL() statement.\n  OnCallSpec(const char* a_file, int a_line,\n             const ArgumentMatcherTuple& matchers)\n      : UntypedOnCallSpecBase(a_file, a_line),\n        matchers_(matchers),\n        // By default, extra_matcher_ should match anything.  However,\n        // we cannot initialize it with _ as that triggers a compiler\n        // bug in Symbian's C++ compiler (cannot decide between two\n        // overloaded constructors of Matcher<const ArgumentTuple&>).\n        extra_matcher_(A<const ArgumentTuple&>()) {\n  }\n\n  // Implements the .With() clause.\n  OnCallSpec& With(const Matcher<const ArgumentTuple&>& m) {\n    // Makes sure this is called at most once.\n    ExpectSpecProperty(last_clause_ < kWith,\n                       \".With() cannot appear \"\n                       \"more than once in an ON_CALL().\");\n    last_clause_ = kWith;\n\n    extra_matcher_ = m;\n    return *this;\n  }\n\n  // Implements the .WillByDefault() clause.\n  OnCallSpec& WillByDefault(const Action<F>& action) {\n    ExpectSpecProperty(last_clause_ < kWillByDefault,\n                       \".WillByDefault() must appear \"\n                       \"exactly once in an ON_CALL().\");\n    last_clause_ = kWillByDefault;\n\n    ExpectSpecProperty(!action.IsDoDefault(),\n                       \"DoDefault() cannot be used in ON_CALL().\");\n    action_ = action;\n    return *this;\n  }\n\n  // Returns true iff the given arguments match the matchers.\n  bool Matches(const ArgumentTuple& args) const {\n    return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);\n  }\n\n  // Returns the action specified by the user.\n  const Action<F>& GetAction() const {\n    AssertSpecProperty(last_clause_ == kWillByDefault,\n                       \".WillByDefault() must appear exactly \"\n                       \"once in an ON_CALL().\");\n    return action_;\n  }\n\n private:\n  // The information in statement\n  //\n  //   ON_CALL(mock_object, Method(matchers))\n  //       .With(multi-argument-matcher)\n  //       .WillByDefault(action);\n  //\n  // is recorded in the data members like this:\n  //\n  //   source file that contains the statement => file_\n  //   line number of the statement            => line_\n  //   matchers                                => matchers_\n  //   multi-argument-matcher                  => extra_matcher_\n  //   action                                  => action_\n  ArgumentMatcherTuple matchers_;\n  Matcher<const ArgumentTuple&> extra_matcher_;\n  Action<F> action_;\n};  // class OnCallSpec\n\n// Possible reactions on uninteresting calls.\nenum CallReaction {\n  kAllow,\n  kWarn,\n  kFail,\n  kDefault = kWarn  // By default, warn about uninteresting calls.\n};\n\n}  // namespace internal\n\n// Utilities for manipulating mock objects.\nclass GTEST_API_ Mock {\n public:\n  // The following public methods can be called concurrently.\n\n  // Tells Google Mock to ignore mock_obj when checking for leaked\n  // mock objects.\n  static void AllowLeak(const void* mock_obj)\n      GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n\n  // Verifies and clears all expectations on the given mock object.\n  // If the expectations aren't satisfied, generates one or more\n  // Google Test non-fatal failures and returns false.\n  static bool VerifyAndClearExpectations(void* mock_obj)\n      GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n\n  // Verifies all expectations on the given mock object and clears its\n  // default actions and expectations.  Returns true iff the\n  // verification was successful.\n  static bool VerifyAndClear(void* mock_obj)\n      GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n\n private:\n  friend class internal::UntypedFunctionMockerBase;\n\n  // Needed for a function mocker to register itself (so that we know\n  // how to clear a mock object).\n  template <typename F>\n  friend class internal::FunctionMockerBase;\n\n  template <typename M>\n  friend class NiceMock;\n\n  template <typename M>\n  friend class NaggyMock;\n\n  template <typename M>\n  friend class StrictMock;\n\n  // Tells Google Mock to allow uninteresting calls on the given mock\n  // object.\n  static void AllowUninterestingCalls(const void* mock_obj)\n      GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n\n  // Tells Google Mock to warn the user about uninteresting calls on\n  // the given mock object.\n  static void WarnUninterestingCalls(const void* mock_obj)\n      GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n\n  // Tells Google Mock to fail uninteresting calls on the given mock\n  // object.\n  static void FailUninterestingCalls(const void* mock_obj)\n      GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n\n  // Tells Google Mock the given mock object is being destroyed and\n  // its entry in the call-reaction table should be removed.\n  static void UnregisterCallReaction(const void* mock_obj)\n      GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n\n  // Returns the reaction Google Mock will have on uninteresting calls\n  // made on the given mock object.\n  static internal::CallReaction GetReactionOnUninterestingCalls(\n      const void* mock_obj)\n          GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n\n  // Verifies that all expectations on the given mock object have been\n  // satisfied.  Reports one or more Google Test non-fatal failures\n  // and returns false if not.\n  static bool VerifyAndClearExpectationsLocked(void* mock_obj)\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex);\n\n  // Clears all ON_CALL()s set on the given mock object.\n  static void ClearDefaultActionsLocked(void* mock_obj)\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex);\n\n  // Registers a mock object and a mock method it owns.\n  static void Register(\n      const void* mock_obj,\n      internal::UntypedFunctionMockerBase* mocker)\n          GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n\n  // Tells Google Mock where in the source code mock_obj is used in an\n  // ON_CALL or EXPECT_CALL.  In case mock_obj is leaked, this\n  // information helps the user identify which object it is.\n  static void RegisterUseByOnCallOrExpectCall(\n      const void* mock_obj, const char* file, int line)\n          GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex);\n\n  // Unregisters a mock method; removes the owning mock object from\n  // the registry when the last mock method associated with it has\n  // been unregistered.  This is called only in the destructor of\n  // FunctionMockerBase.\n  static void UnregisterLocked(internal::UntypedFunctionMockerBase* mocker)\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex);\n};  // class Mock\n\n// An abstract handle of an expectation.  Useful in the .After()\n// clause of EXPECT_CALL() for setting the (partial) order of\n// expectations.  The syntax:\n//\n//   Expectation e1 = EXPECT_CALL(...)...;\n//   EXPECT_CALL(...).After(e1)...;\n//\n// sets two expectations where the latter can only be matched after\n// the former has been satisfied.\n//\n// Notes:\n//   - This class is copyable and has value semantics.\n//   - Constness is shallow: a const Expectation object itself cannot\n//     be modified, but the mutable methods of the ExpectationBase\n//     object it references can be called via expectation_base().\n//   - The constructors and destructor are defined out-of-line because\n//     the Symbian WINSCW compiler wants to otherwise instantiate them\n//     when it sees this class definition, at which point it doesn't have\n//     ExpectationBase available yet, leading to incorrect destruction\n//     in the linked_ptr (or compilation errors if using a checking\n//     linked_ptr).\nclass GTEST_API_ Expectation {\n public:\n  // Constructs a null object that doesn't reference any expectation.\n  Expectation();\n\n  ~Expectation();\n\n  // This single-argument ctor must not be explicit, in order to support the\n  //   Expectation e = EXPECT_CALL(...);\n  // syntax.\n  //\n  // A TypedExpectation object stores its pre-requisites as\n  // Expectation objects, and needs to call the non-const Retire()\n  // method on the ExpectationBase objects they reference.  Therefore\n  // Expectation must receive a *non-const* reference to the\n  // ExpectationBase object.\n  Expectation(internal::ExpectationBase& exp);  // NOLINT\n\n  // The compiler-generated copy ctor and operator= work exactly as\n  // intended, so we don't need to define our own.\n\n  // Returns true iff rhs references the same expectation as this object does.\n  bool operator==(const Expectation& rhs) const {\n    return expectation_base_ == rhs.expectation_base_;\n  }\n\n  bool operator!=(const Expectation& rhs) const { return !(*this == rhs); }\n\n private:\n  friend class ExpectationSet;\n  friend class Sequence;\n  friend class ::testing::internal::ExpectationBase;\n  friend class ::testing::internal::UntypedFunctionMockerBase;\n\n  template <typename F>\n  friend class ::testing::internal::FunctionMockerBase;\n\n  template <typename F>\n  friend class ::testing::internal::TypedExpectation;\n\n  // This comparator is needed for putting Expectation objects into a set.\n  class Less {\n   public:\n    bool operator()(const Expectation& lhs, const Expectation& rhs) const {\n      return lhs.expectation_base_.get() < rhs.expectation_base_.get();\n    }\n  };\n\n  typedef ::std::set<Expectation, Less> Set;\n\n  Expectation(\n      const internal::linked_ptr<internal::ExpectationBase>& expectation_base);\n\n  // Returns the expectation this object references.\n  const internal::linked_ptr<internal::ExpectationBase>&\n  expectation_base() const {\n    return expectation_base_;\n  }\n\n  // A linked_ptr that co-owns the expectation this handle references.\n  internal::linked_ptr<internal::ExpectationBase> expectation_base_;\n};\n\n// A set of expectation handles.  Useful in the .After() clause of\n// EXPECT_CALL() for setting the (partial) order of expectations.  The\n// syntax:\n//\n//   ExpectationSet es;\n//   es += EXPECT_CALL(...)...;\n//   es += EXPECT_CALL(...)...;\n//   EXPECT_CALL(...).After(es)...;\n//\n// sets three expectations where the last one can only be matched\n// after the first two have both been satisfied.\n//\n// This class is copyable and has value semantics.\nclass ExpectationSet {\n public:\n  // A bidirectional iterator that can read a const element in the set.\n  typedef Expectation::Set::const_iterator const_iterator;\n\n  // An object stored in the set.  This is an alias of Expectation.\n  typedef Expectation::Set::value_type value_type;\n\n  // Constructs an empty set.\n  ExpectationSet() {}\n\n  // This single-argument ctor must not be explicit, in order to support the\n  //   ExpectationSet es = EXPECT_CALL(...);\n  // syntax.\n  ExpectationSet(internal::ExpectationBase& exp) {  // NOLINT\n    *this += Expectation(exp);\n  }\n\n  // This single-argument ctor implements implicit conversion from\n  // Expectation and thus must not be explicit.  This allows either an\n  // Expectation or an ExpectationSet to be used in .After().\n  ExpectationSet(const Expectation& e) {  // NOLINT\n    *this += e;\n  }\n\n  // The compiler-generator ctor and operator= works exactly as\n  // intended, so we don't need to define our own.\n\n  // Returns true iff rhs contains the same set of Expectation objects\n  // as this does.\n  bool operator==(const ExpectationSet& rhs) const {\n    return expectations_ == rhs.expectations_;\n  }\n\n  bool operator!=(const ExpectationSet& rhs) const { return !(*this == rhs); }\n\n  // Implements the syntax\n  //   expectation_set += EXPECT_CALL(...);\n  ExpectationSet& operator+=(const Expectation& e) {\n    expectations_.insert(e);\n    return *this;\n  }\n\n  int size() const { return static_cast<int>(expectations_.size()); }\n\n  const_iterator begin() const { return expectations_.begin(); }\n  const_iterator end() const { return expectations_.end(); }\n\n private:\n  Expectation::Set expectations_;\n};\n\n\n// Sequence objects are used by a user to specify the relative order\n// in which the expectations should match.  They are copyable (we rely\n// on the compiler-defined copy constructor and assignment operator).\nclass GTEST_API_ Sequence {\n public:\n  // Constructs an empty sequence.\n  Sequence() : last_expectation_(new Expectation) {}\n\n  // Adds an expectation to this sequence.  The caller must ensure\n  // that no other thread is accessing this Sequence object.\n  void AddExpectation(const Expectation& expectation) const;\n\n private:\n  // The last expectation in this sequence.  We use a linked_ptr here\n  // because Sequence objects are copyable and we want the copies to\n  // be aliases.  The linked_ptr allows the copies to co-own and share\n  // the same Expectation object.\n  internal::linked_ptr<Expectation> last_expectation_;\n};  // class Sequence\n\n// An object of this type causes all EXPECT_CALL() statements\n// encountered in its scope to be put in an anonymous sequence.  The\n// work is done in the constructor and destructor.  You should only\n// create an InSequence object on the stack.\n//\n// The sole purpose for this class is to support easy definition of\n// sequential expectations, e.g.\n//\n//   {\n//     InSequence dummy;  // The name of the object doesn't matter.\n//\n//     // The following expectations must match in the order they appear.\n//     EXPECT_CALL(a, Bar())...;\n//     EXPECT_CALL(a, Baz())...;\n//     ...\n//     EXPECT_CALL(b, Xyz())...;\n//   }\n//\n// You can create InSequence objects in multiple threads, as long as\n// they are used to affect different mock objects.  The idea is that\n// each thread can create and set up its own mocks as if it's the only\n// thread.  However, for clarity of your tests we recommend you to set\n// up mocks in the main thread unless you have a good reason not to do\n// so.\nclass GTEST_API_ InSequence {\n public:\n  InSequence();\n  ~InSequence();\n private:\n  bool sequence_created_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(InSequence);  // NOLINT\n} GTEST_ATTRIBUTE_UNUSED_;\n\nnamespace internal {\n\n// Points to the implicit sequence introduced by a living InSequence\n// object (if any) in the current thread or NULL.\nGTEST_API_ extern ThreadLocal<Sequence*> g_gmock_implicit_sequence;\n\n// Base class for implementing expectations.\n//\n// There are two reasons for having a type-agnostic base class for\n// Expectation:\n//\n//   1. We need to store collections of expectations of different\n//   types (e.g. all pre-requisites of a particular expectation, all\n//   expectations in a sequence).  Therefore these expectation objects\n//   must share a common base class.\n//\n//   2. We can avoid binary code bloat by moving methods not depending\n//   on the template argument of Expectation to the base class.\n//\n// This class is internal and mustn't be used by user code directly.\nclass GTEST_API_ ExpectationBase {\n public:\n  // source_text is the EXPECT_CALL(...) source that created this Expectation.\n  ExpectationBase(const char* file, int line, const string& source_text);\n\n  virtual ~ExpectationBase();\n\n  // Where in the source file was the expectation spec defined?\n  const char* file() const { return file_; }\n  int line() const { return line_; }\n  const char* source_text() const { return source_text_.c_str(); }\n  // Returns the cardinality specified in the expectation spec.\n  const Cardinality& cardinality() const { return cardinality_; }\n\n  // Describes the source file location of this expectation.\n  void DescribeLocationTo(::std::ostream* os) const {\n    *os << FormatFileLocation(file(), line()) << \" \";\n  }\n\n  // Describes how many times a function call matching this\n  // expectation has occurred.\n  void DescribeCallCountTo(::std::ostream* os) const\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);\n\n  // If this mock method has an extra matcher (i.e. .With(matcher)),\n  // describes it to the ostream.\n  virtual void MaybeDescribeExtraMatcherTo(::std::ostream* os) = 0;\n\n protected:\n  friend class ::testing::Expectation;\n  friend class UntypedFunctionMockerBase;\n\n  enum Clause {\n    // Don't change the order of the enum members!\n    kNone,\n    kWith,\n    kTimes,\n    kInSequence,\n    kAfter,\n    kWillOnce,\n    kWillRepeatedly,\n    kRetiresOnSaturation\n  };\n\n  typedef std::vector<const void*> UntypedActions;\n\n  // Returns an Expectation object that references and co-owns this\n  // expectation.\n  virtual Expectation GetHandle() = 0;\n\n  // Asserts that the EXPECT_CALL() statement has the given property.\n  void AssertSpecProperty(bool property, const string& failure_message) const {\n    Assert(property, file_, line_, failure_message);\n  }\n\n  // Expects that the EXPECT_CALL() statement has the given property.\n  void ExpectSpecProperty(bool property, const string& failure_message) const {\n    Expect(property, file_, line_, failure_message);\n  }\n\n  // Explicitly specifies the cardinality of this expectation.  Used\n  // by the subclasses to implement the .Times() clause.\n  void SpecifyCardinality(const Cardinality& cardinality);\n\n  // Returns true iff the user specified the cardinality explicitly\n  // using a .Times().\n  bool cardinality_specified() const { return cardinality_specified_; }\n\n  // Sets the cardinality of this expectation spec.\n  void set_cardinality(const Cardinality& a_cardinality) {\n    cardinality_ = a_cardinality;\n  }\n\n  // The following group of methods should only be called after the\n  // EXPECT_CALL() statement, and only when g_gmock_mutex is held by\n  // the current thread.\n\n  // Retires all pre-requisites of this expectation.\n  void RetireAllPreRequisites()\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);\n\n  // Returns true iff this expectation is retired.\n  bool is_retired() const\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    return retired_;\n  }\n\n  // Retires this expectation.\n  void Retire()\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    retired_ = true;\n  }\n\n  // Returns true iff this expectation is satisfied.\n  bool IsSatisfied() const\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    return cardinality().IsSatisfiedByCallCount(call_count_);\n  }\n\n  // Returns true iff this expectation is saturated.\n  bool IsSaturated() const\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    return cardinality().IsSaturatedByCallCount(call_count_);\n  }\n\n  // Returns true iff this expectation is over-saturated.\n  bool IsOverSaturated() const\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    return cardinality().IsOverSaturatedByCallCount(call_count_);\n  }\n\n  // Returns true iff all pre-requisites of this expectation are satisfied.\n  bool AllPrerequisitesAreSatisfied() const\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);\n\n  // Adds unsatisfied pre-requisites of this expectation to 'result'.\n  void FindUnsatisfiedPrerequisites(ExpectationSet* result) const\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex);\n\n  // Returns the number this expectation has been invoked.\n  int call_count() const\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    return call_count_;\n  }\n\n  // Increments the number this expectation has been invoked.\n  void IncrementCallCount()\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    call_count_++;\n  }\n\n  // Checks the action count (i.e. the number of WillOnce() and\n  // WillRepeatedly() clauses) against the cardinality if this hasn't\n  // been done before.  Prints a warning if there are too many or too\n  // few actions.\n  void CheckActionCountIfNotDone() const\n      GTEST_LOCK_EXCLUDED_(mutex_);\n\n  friend class ::testing::Sequence;\n  friend class ::testing::internal::ExpectationTester;\n\n  template <typename Function>\n  friend class TypedExpectation;\n\n  // Implements the .Times() clause.\n  void UntypedTimes(const Cardinality& a_cardinality);\n\n  // This group of fields are part of the spec and won't change after\n  // an EXPECT_CALL() statement finishes.\n  const char* file_;          // The file that contains the expectation.\n  int line_;                  // The line number of the expectation.\n  const string source_text_;  // The EXPECT_CALL(...) source text.\n  // True iff the cardinality is specified explicitly.\n  bool cardinality_specified_;\n  Cardinality cardinality_;            // The cardinality of the expectation.\n  // The immediate pre-requisites (i.e. expectations that must be\n  // satisfied before this expectation can be matched) of this\n  // expectation.  We use linked_ptr in the set because we want an\n  // Expectation object to be co-owned by its FunctionMocker and its\n  // successors.  This allows multiple mock objects to be deleted at\n  // different times.\n  ExpectationSet immediate_prerequisites_;\n\n  // This group of fields are the current state of the expectation,\n  // and can change as the mock function is called.\n  int call_count_;  // How many times this expectation has been invoked.\n  bool retired_;    // True iff this expectation has retired.\n  UntypedActions untyped_actions_;\n  bool extra_matcher_specified_;\n  bool repeated_action_specified_;  // True if a WillRepeatedly() was specified.\n  bool retires_on_saturation_;\n  Clause last_clause_;\n  mutable bool action_count_checked_;  // Under mutex_.\n  mutable Mutex mutex_;  // Protects action_count_checked_.\n\n  GTEST_DISALLOW_ASSIGN_(ExpectationBase);\n};  // class ExpectationBase\n\n// Impements an expectation for the given function type.\ntemplate <typename F>\nclass TypedExpectation : public ExpectationBase {\n public:\n  typedef typename Function<F>::ArgumentTuple ArgumentTuple;\n  typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;\n  typedef typename Function<F>::Result Result;\n\n  TypedExpectation(FunctionMockerBase<F>* owner,\n                   const char* a_file, int a_line, const string& a_source_text,\n                   const ArgumentMatcherTuple& m)\n      : ExpectationBase(a_file, a_line, a_source_text),\n        owner_(owner),\n        matchers_(m),\n        // By default, extra_matcher_ should match anything.  However,\n        // we cannot initialize it with _ as that triggers a compiler\n        // bug in Symbian's C++ compiler (cannot decide between two\n        // overloaded constructors of Matcher<const ArgumentTuple&>).\n        extra_matcher_(A<const ArgumentTuple&>()),\n        repeated_action_(DoDefault()) {}\n\n  virtual ~TypedExpectation() {\n    // Check the validity of the action count if it hasn't been done\n    // yet (for example, if the expectation was never used).\n    CheckActionCountIfNotDone();\n    for (UntypedActions::const_iterator it = untyped_actions_.begin();\n         it != untyped_actions_.end(); ++it) {\n      delete static_cast<const Action<F>*>(*it);\n    }\n  }\n\n  // Implements the .With() clause.\n  TypedExpectation& With(const Matcher<const ArgumentTuple&>& m) {\n    if (last_clause_ == kWith) {\n      ExpectSpecProperty(false,\n                         \".With() cannot appear \"\n                         \"more than once in an EXPECT_CALL().\");\n    } else {\n      ExpectSpecProperty(last_clause_ < kWith,\n                         \".With() must be the first \"\n                         \"clause in an EXPECT_CALL().\");\n    }\n    last_clause_ = kWith;\n\n    extra_matcher_ = m;\n    extra_matcher_specified_ = true;\n    return *this;\n  }\n\n  // Implements the .Times() clause.\n  TypedExpectation& Times(const Cardinality& a_cardinality) {\n    ExpectationBase::UntypedTimes(a_cardinality);\n    return *this;\n  }\n\n  // Implements the .Times() clause.\n  TypedExpectation& Times(int n) {\n    return Times(Exactly(n));\n  }\n\n  // Implements the .InSequence() clause.\n  TypedExpectation& InSequence(const Sequence& s) {\n    ExpectSpecProperty(last_clause_ <= kInSequence,\n                       \".InSequence() cannot appear after .After(),\"\n                       \" .WillOnce(), .WillRepeatedly(), or \"\n                       \".RetiresOnSaturation().\");\n    last_clause_ = kInSequence;\n\n    s.AddExpectation(GetHandle());\n    return *this;\n  }\n  TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2) {\n    return InSequence(s1).InSequence(s2);\n  }\n  TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,\n                               const Sequence& s3) {\n    return InSequence(s1, s2).InSequence(s3);\n  }\n  TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,\n                               const Sequence& s3, const Sequence& s4) {\n    return InSequence(s1, s2, s3).InSequence(s4);\n  }\n  TypedExpectation& InSequence(const Sequence& s1, const Sequence& s2,\n                               const Sequence& s3, const Sequence& s4,\n                               const Sequence& s5) {\n    return InSequence(s1, s2, s3, s4).InSequence(s5);\n  }\n\n  // Implements that .After() clause.\n  TypedExpectation& After(const ExpectationSet& s) {\n    ExpectSpecProperty(last_clause_ <= kAfter,\n                       \".After() cannot appear after .WillOnce(),\"\n                       \" .WillRepeatedly(), or \"\n                       \".RetiresOnSaturation().\");\n    last_clause_ = kAfter;\n\n    for (ExpectationSet::const_iterator it = s.begin(); it != s.end(); ++it) {\n      immediate_prerequisites_ += *it;\n    }\n    return *this;\n  }\n  TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2) {\n    return After(s1).After(s2);\n  }\n  TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2,\n                          const ExpectationSet& s3) {\n    return After(s1, s2).After(s3);\n  }\n  TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2,\n                          const ExpectationSet& s3, const ExpectationSet& s4) {\n    return After(s1, s2, s3).After(s4);\n  }\n  TypedExpectation& After(const ExpectationSet& s1, const ExpectationSet& s2,\n                          const ExpectationSet& s3, const ExpectationSet& s4,\n                          const ExpectationSet& s5) {\n    return After(s1, s2, s3, s4).After(s5);\n  }\n\n  // Implements the .WillOnce() clause.\n  TypedExpectation& WillOnce(const Action<F>& action) {\n    ExpectSpecProperty(last_clause_ <= kWillOnce,\n                       \".WillOnce() cannot appear after \"\n                       \".WillRepeatedly() or .RetiresOnSaturation().\");\n    last_clause_ = kWillOnce;\n\n    untyped_actions_.push_back(new Action<F>(action));\n    if (!cardinality_specified()) {\n      set_cardinality(Exactly(static_cast<int>(untyped_actions_.size())));\n    }\n    return *this;\n  }\n\n  // Implements the .WillRepeatedly() clause.\n  TypedExpectation& WillRepeatedly(const Action<F>& action) {\n    if (last_clause_ == kWillRepeatedly) {\n      ExpectSpecProperty(false,\n                         \".WillRepeatedly() cannot appear \"\n                         \"more than once in an EXPECT_CALL().\");\n    } else {\n      ExpectSpecProperty(last_clause_ < kWillRepeatedly,\n                         \".WillRepeatedly() cannot appear \"\n                         \"after .RetiresOnSaturation().\");\n    }\n    last_clause_ = kWillRepeatedly;\n    repeated_action_specified_ = true;\n\n    repeated_action_ = action;\n    if (!cardinality_specified()) {\n      set_cardinality(AtLeast(static_cast<int>(untyped_actions_.size())));\n    }\n\n    // Now that no more action clauses can be specified, we check\n    // whether their count makes sense.\n    CheckActionCountIfNotDone();\n    return *this;\n  }\n\n  // Implements the .RetiresOnSaturation() clause.\n  TypedExpectation& RetiresOnSaturation() {\n    ExpectSpecProperty(last_clause_ < kRetiresOnSaturation,\n                       \".RetiresOnSaturation() cannot appear \"\n                       \"more than once.\");\n    last_clause_ = kRetiresOnSaturation;\n    retires_on_saturation_ = true;\n\n    // Now that no more action clauses can be specified, we check\n    // whether their count makes sense.\n    CheckActionCountIfNotDone();\n    return *this;\n  }\n\n  // Returns the matchers for the arguments as specified inside the\n  // EXPECT_CALL() macro.\n  const ArgumentMatcherTuple& matchers() const {\n    return matchers_;\n  }\n\n  // Returns the matcher specified by the .With() clause.\n  const Matcher<const ArgumentTuple&>& extra_matcher() const {\n    return extra_matcher_;\n  }\n\n  // Returns the action specified by the .WillRepeatedly() clause.\n  const Action<F>& repeated_action() const { return repeated_action_; }\n\n  // If this mock method has an extra matcher (i.e. .With(matcher)),\n  // describes it to the ostream.\n  virtual void MaybeDescribeExtraMatcherTo(::std::ostream* os) {\n    if (extra_matcher_specified_) {\n      *os << \"    Expected args: \";\n      extra_matcher_.DescribeTo(os);\n      *os << \"\\n\";\n    }\n  }\n\n private:\n  template <typename Function>\n  friend class FunctionMockerBase;\n\n  // Returns an Expectation object that references and co-owns this\n  // expectation.\n  virtual Expectation GetHandle() {\n    return owner_->GetHandleOf(this);\n  }\n\n  // The following methods will be called only after the EXPECT_CALL()\n  // statement finishes and when the current thread holds\n  // g_gmock_mutex.\n\n  // Returns true iff this expectation matches the given arguments.\n  bool Matches(const ArgumentTuple& args) const\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    return TupleMatches(matchers_, args) && extra_matcher_.Matches(args);\n  }\n\n  // Returns true iff this expectation should handle the given arguments.\n  bool ShouldHandleArguments(const ArgumentTuple& args) const\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n\n    // In case the action count wasn't checked when the expectation\n    // was defined (e.g. if this expectation has no WillRepeatedly()\n    // or RetiresOnSaturation() clause), we check it when the\n    // expectation is used for the first time.\n    CheckActionCountIfNotDone();\n    return !is_retired() && AllPrerequisitesAreSatisfied() && Matches(args);\n  }\n\n  // Describes the result of matching the arguments against this\n  // expectation to the given ostream.\n  void ExplainMatchResultTo(\n      const ArgumentTuple& args,\n      ::std::ostream* os) const\n          GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n\n    if (is_retired()) {\n      *os << \"         Expected: the expectation is active\\n\"\n          << \"           Actual: it is retired\\n\";\n    } else if (!Matches(args)) {\n      if (!TupleMatches(matchers_, args)) {\n        ExplainMatchFailureTupleTo(matchers_, args, os);\n      }\n      StringMatchResultListener listener;\n      if (!extra_matcher_.MatchAndExplain(args, &listener)) {\n        *os << \"    Expected args: \";\n        extra_matcher_.DescribeTo(os);\n        *os << \"\\n           Actual: don't match\";\n\n        internal::PrintIfNotEmpty(listener.str(), os);\n        *os << \"\\n\";\n      }\n    } else if (!AllPrerequisitesAreSatisfied()) {\n      *os << \"         Expected: all pre-requisites are satisfied\\n\"\n          << \"           Actual: the following immediate pre-requisites \"\n          << \"are not satisfied:\\n\";\n      ExpectationSet unsatisfied_prereqs;\n      FindUnsatisfiedPrerequisites(&unsatisfied_prereqs);\n      int i = 0;\n      for (ExpectationSet::const_iterator it = unsatisfied_prereqs.begin();\n           it != unsatisfied_prereqs.end(); ++it) {\n        it->expectation_base()->DescribeLocationTo(os);\n        *os << \"pre-requisite #\" << i++ << \"\\n\";\n      }\n      *os << \"                   (end of pre-requisites)\\n\";\n    } else {\n      // This line is here just for completeness' sake.  It will never\n      // be executed as currently the ExplainMatchResultTo() function\n      // is called only when the mock function call does NOT match the\n      // expectation.\n      *os << \"The call matches the expectation.\\n\";\n    }\n  }\n\n  // Returns the action that should be taken for the current invocation.\n  const Action<F>& GetCurrentAction(\n      const FunctionMockerBase<F>* mocker,\n      const ArgumentTuple& args) const\n          GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    const int count = call_count();\n    Assert(count >= 1, __FILE__, __LINE__,\n           \"call_count() is <= 0 when GetCurrentAction() is \"\n           \"called - this should never happen.\");\n\n    const int action_count = static_cast<int>(untyped_actions_.size());\n    if (action_count > 0 && !repeated_action_specified_ &&\n        count > action_count) {\n      // If there is at least one WillOnce() and no WillRepeatedly(),\n      // we warn the user when the WillOnce() clauses ran out.\n      ::std::stringstream ss;\n      DescribeLocationTo(&ss);\n      ss << \"Actions ran out in \" << source_text() << \"...\\n\"\n         << \"Called \" << count << \" times, but only \"\n         << action_count << \" WillOnce()\"\n         << (action_count == 1 ? \" is\" : \"s are\") << \" specified - \";\n      mocker->DescribeDefaultActionTo(args, &ss);\n      Log(kWarning, ss.str(), 1);\n    }\n\n    return count <= action_count ?\n        *static_cast<const Action<F>*>(untyped_actions_[count - 1]) :\n        repeated_action();\n  }\n\n  // Given the arguments of a mock function call, if the call will\n  // over-saturate this expectation, returns the default action;\n  // otherwise, returns the next action in this expectation.  Also\n  // describes *what* happened to 'what', and explains *why* Google\n  // Mock does it to 'why'.  This method is not const as it calls\n  // IncrementCallCount().  A return value of NULL means the default\n  // action.\n  const Action<F>* GetActionForArguments(\n      const FunctionMockerBase<F>* mocker,\n      const ArgumentTuple& args,\n      ::std::ostream* what,\n      ::std::ostream* why)\n          GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    if (IsSaturated()) {\n      // We have an excessive call.\n      IncrementCallCount();\n      *what << \"Mock function called more times than expected - \";\n      mocker->DescribeDefaultActionTo(args, what);\n      DescribeCallCountTo(why);\n\n      // TODO(wan@google.com): allow the user to control whether\n      // unexpected calls should fail immediately or continue using a\n      // flag --gmock_unexpected_calls_are_fatal.\n      return NULL;\n    }\n\n    IncrementCallCount();\n    RetireAllPreRequisites();\n\n    if (retires_on_saturation_ && IsSaturated()) {\n      Retire();\n    }\n\n    // Must be done after IncrementCount()!\n    *what << \"Mock function call matches \" << source_text() <<\"...\\n\";\n    return &(GetCurrentAction(mocker, args));\n  }\n\n  // All the fields below won't change once the EXPECT_CALL()\n  // statement finishes.\n  FunctionMockerBase<F>* const owner_;\n  ArgumentMatcherTuple matchers_;\n  Matcher<const ArgumentTuple&> extra_matcher_;\n  Action<F> repeated_action_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TypedExpectation);\n};  // class TypedExpectation\n\n// A MockSpec object is used by ON_CALL() or EXPECT_CALL() for\n// specifying the default behavior of, or expectation on, a mock\n// function.\n\n// Note: class MockSpec really belongs to the ::testing namespace.\n// However if we define it in ::testing, MSVC will complain when\n// classes in ::testing::internal declare it as a friend class\n// template.  To workaround this compiler bug, we define MockSpec in\n// ::testing::internal and import it into ::testing.\n\n// Logs a message including file and line number information.\nGTEST_API_ void LogWithLocation(testing::internal::LogSeverity severity,\n                                const char* file, int line,\n                                const string& message);\n\ntemplate <typename F>\nclass MockSpec {\n public:\n  typedef typename internal::Function<F>::ArgumentTuple ArgumentTuple;\n  typedef typename internal::Function<F>::ArgumentMatcherTuple\n      ArgumentMatcherTuple;\n\n  // Constructs a MockSpec object, given the function mocker object\n  // that the spec is associated with.\n  explicit MockSpec(internal::FunctionMockerBase<F>* function_mocker)\n      : function_mocker_(function_mocker) {}\n\n  // Adds a new default action spec to the function mocker and returns\n  // the newly created spec.\n  internal::OnCallSpec<F>& InternalDefaultActionSetAt(\n      const char* file, int line, const char* obj, const char* call) {\n    LogWithLocation(internal::kInfo, file, line,\n        string(\"ON_CALL(\") + obj + \", \" + call + \") invoked\");\n    return function_mocker_->AddNewOnCallSpec(file, line, matchers_);\n  }\n\n  // Adds a new expectation spec to the function mocker and returns\n  // the newly created spec.\n  internal::TypedExpectation<F>& InternalExpectedAt(\n      const char* file, int line, const char* obj, const char* call) {\n    const string source_text(string(\"EXPECT_CALL(\") + obj + \", \" + call + \")\");\n    LogWithLocation(internal::kInfo, file, line, source_text + \" invoked\");\n    return function_mocker_->AddNewExpectation(\n        file, line, source_text, matchers_);\n  }\n\n private:\n  template <typename Function>\n  friend class internal::FunctionMocker;\n\n  void SetMatchers(const ArgumentMatcherTuple& matchers) {\n    matchers_ = matchers;\n  }\n\n  // The function mocker that owns this spec.\n  internal::FunctionMockerBase<F>* const function_mocker_;\n  // The argument matchers specified in the spec.\n  ArgumentMatcherTuple matchers_;\n\n  GTEST_DISALLOW_ASSIGN_(MockSpec);\n};  // class MockSpec\n\n// MSVC warns about using 'this' in base member initializer list, so\n// we need to temporarily disable the warning.  We have to do it for\n// the entire class to suppress the warning, even though it's about\n// the constructor only.\n\n#ifdef _MSC_VER\n# pragma warning(push)          // Saves the current warning state.\n# pragma warning(disable:4355)  // Temporarily disables warning 4355.\n#endif  // _MSV_VER\n\n// C++ treats the void type specially.  For example, you cannot define\n// a void-typed variable or pass a void value to a function.\n// ActionResultHolder<T> holds a value of type T, where T must be a\n// copyable type or void (T doesn't need to be default-constructable).\n// It hides the syntactic difference between void and other types, and\n// is used to unify the code for invoking both void-returning and\n// non-void-returning mock functions.\n\n// Untyped base class for ActionResultHolder<T>.\nclass UntypedActionResultHolderBase {\n public:\n  virtual ~UntypedActionResultHolderBase() {}\n\n  // Prints the held value as an action's result to os.\n  virtual void PrintAsActionResult(::std::ostream* os) const = 0;\n};\n\n// This generic definition is used when T is not void.\ntemplate <typename T>\nclass ActionResultHolder : public UntypedActionResultHolderBase {\n public:\n  explicit ActionResultHolder(T a_value) : value_(a_value) {}\n\n  // The compiler-generated copy constructor and assignment operator\n  // are exactly what we need, so we don't need to define them.\n\n  // Returns the held value and deletes this object.\n  T GetValueAndDelete() const {\n    T retval(value_);\n    delete this;\n    return retval;\n  }\n\n  // Prints the held value as an action's result to os.\n  virtual void PrintAsActionResult(::std::ostream* os) const {\n    *os << \"\\n          Returns: \";\n    // T may be a reference type, so we don't use UniversalPrint().\n    UniversalPrinter<T>::Print(value_, os);\n  }\n\n  // Performs the given mock function's default action and returns the\n  // result in a new-ed ActionResultHolder.\n  template <typename F>\n  static ActionResultHolder* PerformDefaultAction(\n      const FunctionMockerBase<F>* func_mocker,\n      const typename Function<F>::ArgumentTuple& args,\n      const string& call_description) {\n    return new ActionResultHolder(\n        func_mocker->PerformDefaultAction(args, call_description));\n  }\n\n  // Performs the given action and returns the result in a new-ed\n  // ActionResultHolder.\n  template <typename F>\n  static ActionResultHolder*\n  PerformAction(const Action<F>& action,\n                const typename Function<F>::ArgumentTuple& args) {\n    return new ActionResultHolder(action.Perform(args));\n  }\n\n private:\n  T value_;\n\n  // T could be a reference type, so = isn't supported.\n  GTEST_DISALLOW_ASSIGN_(ActionResultHolder);\n};\n\n// Specialization for T = void.\ntemplate <>\nclass ActionResultHolder<void> : public UntypedActionResultHolderBase {\n public:\n  explicit ActionResultHolder() {}\n\n  void GetValueAndDelete() const { delete this; }\n\n  virtual void PrintAsActionResult(::std::ostream* /* os */) const {}\n\n  // Performs the given mock function's default action and returns NULL;\n  template <typename F>\n  static ActionResultHolder* PerformDefaultAction(\n      const FunctionMockerBase<F>* func_mocker,\n      const typename Function<F>::ArgumentTuple& args,\n      const string& call_description) {\n    func_mocker->PerformDefaultAction(args, call_description);\n    return new ActionResultHolder();\n  }\n\n  // Performs the given action and returns NULL.\n  template <typename F>\n  static ActionResultHolder* PerformAction(\n      const Action<F>& action,\n      const typename Function<F>::ArgumentTuple& args) {\n    action.Perform(args);\n    return new ActionResultHolder();\n  }\n};\n\n// The base of the function mocker class for the given function type.\n// We put the methods in this class instead of its child to avoid code\n// bloat.\ntemplate <typename F>\nclass FunctionMockerBase : public UntypedFunctionMockerBase {\n public:\n  typedef typename Function<F>::Result Result;\n  typedef typename Function<F>::ArgumentTuple ArgumentTuple;\n  typedef typename Function<F>::ArgumentMatcherTuple ArgumentMatcherTuple;\n\n  FunctionMockerBase() : current_spec_(this) {}\n\n  // The destructor verifies that all expectations on this mock\n  // function have been satisfied.  If not, it will report Google Test\n  // non-fatal failures for the violations.\n  virtual ~FunctionMockerBase()\n        GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\n    MutexLock l(&g_gmock_mutex);\n    VerifyAndClearExpectationsLocked();\n    Mock::UnregisterLocked(this);\n    ClearDefaultActionsLocked();\n  }\n\n  // Returns the ON_CALL spec that matches this mock function with the\n  // given arguments; returns NULL if no matching ON_CALL is found.\n  // L = *\n  const OnCallSpec<F>* FindOnCallSpec(\n      const ArgumentTuple& args) const {\n    for (UntypedOnCallSpecs::const_reverse_iterator it\n             = untyped_on_call_specs_.rbegin();\n         it != untyped_on_call_specs_.rend(); ++it) {\n      const OnCallSpec<F>* spec = static_cast<const OnCallSpec<F>*>(*it);\n      if (spec->Matches(args))\n        return spec;\n    }\n\n    return NULL;\n  }\n\n  // Performs the default action of this mock function on the given\n  // arguments and returns the result. Asserts (or throws if\n  // exceptions are enabled) with a helpful call descrption if there\n  // is no valid return value. This method doesn't depend on the\n  // mutable state of this object, and thus can be called concurrently\n  // without locking.\n  // L = *\n  Result PerformDefaultAction(const ArgumentTuple& args,\n                              const string& call_description) const {\n    const OnCallSpec<F>* const spec =\n        this->FindOnCallSpec(args);\n    if (spec != NULL) {\n      return spec->GetAction().Perform(args);\n    }\n    const string message = call_description +\n        \"\\n    The mock function has no default action \"\n        \"set, and its return type has no default value set.\";\n#if GTEST_HAS_EXCEPTIONS\n    if (!DefaultValue<Result>::Exists()) {\n      throw std::runtime_error(message);\n    }\n#else\n    Assert(DefaultValue<Result>::Exists(), \"\", -1, message);\n#endif\n    return DefaultValue<Result>::Get();\n  }\n\n  // Performs the default action with the given arguments and returns\n  // the action's result.  The call description string will be used in\n  // the error message to describe the call in the case the default\n  // action fails.  The caller is responsible for deleting the result.\n  // L = *\n  virtual UntypedActionResultHolderBase* UntypedPerformDefaultAction(\n      const void* untyped_args,  // must point to an ArgumentTuple\n      const string& call_description) const {\n    const ArgumentTuple& args =\n        *static_cast<const ArgumentTuple*>(untyped_args);\n    return ResultHolder::PerformDefaultAction(this, args, call_description);\n  }\n\n  // Performs the given action with the given arguments and returns\n  // the action's result.  The caller is responsible for deleting the\n  // result.\n  // L = *\n  virtual UntypedActionResultHolderBase* UntypedPerformAction(\n      const void* untyped_action, const void* untyped_args) const {\n    // Make a copy of the action before performing it, in case the\n    // action deletes the mock object (and thus deletes itself).\n    const Action<F> action = *static_cast<const Action<F>*>(untyped_action);\n    const ArgumentTuple& args =\n        *static_cast<const ArgumentTuple*>(untyped_args);\n    return ResultHolder::PerformAction(action, args);\n  }\n\n  // Implements UntypedFunctionMockerBase::ClearDefaultActionsLocked():\n  // clears the ON_CALL()s set on this mock function.\n  virtual void ClearDefaultActionsLocked()\n      GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n\n    // Deleting our default actions may trigger other mock objects to be\n    // deleted, for example if an action contains a reference counted smart\n    // pointer to that mock object, and that is the last reference. So if we\n    // delete our actions within the context of the global mutex we may deadlock\n    // when this method is called again. Instead, make a copy of the set of\n    // actions to delete, clear our set within the mutex, and then delete the\n    // actions outside of the mutex.\n    UntypedOnCallSpecs specs_to_delete;\n    untyped_on_call_specs_.swap(specs_to_delete);\n\n    g_gmock_mutex.Unlock();\n    for (UntypedOnCallSpecs::const_iterator it =\n             specs_to_delete.begin();\n         it != specs_to_delete.end(); ++it) {\n      delete static_cast<const OnCallSpec<F>*>(*it);\n    }\n\n    // Lock the mutex again, since the caller expects it to be locked when we\n    // return.\n    g_gmock_mutex.Lock();\n  }\n\n protected:\n  template <typename Function>\n  friend class MockSpec;\n\n  typedef ActionResultHolder<Result> ResultHolder;\n\n  // Returns the result of invoking this mock function with the given\n  // arguments.  This function can be safely called from multiple\n  // threads concurrently.\n  Result InvokeWith(const ArgumentTuple& args)\n        GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\n    return static_cast<const ResultHolder*>(\n        this->UntypedInvokeWith(&args))->GetValueAndDelete();\n  }\n\n  // Adds and returns a default action spec for this mock function.\n  OnCallSpec<F>& AddNewOnCallSpec(\n      const char* file, int line,\n      const ArgumentMatcherTuple& m)\n          GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\n    Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);\n    OnCallSpec<F>* const on_call_spec = new OnCallSpec<F>(file, line, m);\n    untyped_on_call_specs_.push_back(on_call_spec);\n    return *on_call_spec;\n  }\n\n  // Adds and returns an expectation spec for this mock function.\n  TypedExpectation<F>& AddNewExpectation(\n      const char* file,\n      int line,\n      const string& source_text,\n      const ArgumentMatcherTuple& m)\n          GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\n    Mock::RegisterUseByOnCallOrExpectCall(MockObject(), file, line);\n    TypedExpectation<F>* const expectation =\n        new TypedExpectation<F>(this, file, line, source_text, m);\n    const linked_ptr<ExpectationBase> untyped_expectation(expectation);\n    untyped_expectations_.push_back(untyped_expectation);\n\n    // Adds this expectation into the implicit sequence if there is one.\n    Sequence* const implicit_sequence = g_gmock_implicit_sequence.get();\n    if (implicit_sequence != NULL) {\n      implicit_sequence->AddExpectation(Expectation(untyped_expectation));\n    }\n\n    return *expectation;\n  }\n\n  // The current spec (either default action spec or expectation spec)\n  // being described on this function mocker.\n  MockSpec<F>& current_spec() { return current_spec_; }\n\n private:\n  template <typename Func> friend class TypedExpectation;\n\n  // Some utilities needed for implementing UntypedInvokeWith().\n\n  // Describes what default action will be performed for the given\n  // arguments.\n  // L = *\n  void DescribeDefaultActionTo(const ArgumentTuple& args,\n                               ::std::ostream* os) const {\n    const OnCallSpec<F>* const spec = FindOnCallSpec(args);\n\n    if (spec == NULL) {\n      *os << (internal::type_equals<Result, void>::value ?\n              \"returning directly.\\n\" :\n              \"returning default value.\\n\");\n    } else {\n      *os << \"taking default action specified at:\\n\"\n          << FormatFileLocation(spec->file(), spec->line()) << \"\\n\";\n    }\n  }\n\n  // Writes a message that the call is uninteresting (i.e. neither\n  // explicitly expected nor explicitly unexpected) to the given\n  // ostream.\n  virtual void UntypedDescribeUninterestingCall(\n      const void* untyped_args,\n      ::std::ostream* os) const\n          GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\n    const ArgumentTuple& args =\n        *static_cast<const ArgumentTuple*>(untyped_args);\n    *os << \"Uninteresting mock function call - \";\n    DescribeDefaultActionTo(args, os);\n    *os << \"    Function call: \" << Name();\n    UniversalPrint(args, os);\n  }\n\n  // Returns the expectation that matches the given function arguments\n  // (or NULL is there's no match); when a match is found,\n  // untyped_action is set to point to the action that should be\n  // performed (or NULL if the action is \"do default\"), and\n  // is_excessive is modified to indicate whether the call exceeds the\n  // expected number.\n  //\n  // Critical section: We must find the matching expectation and the\n  // corresponding action that needs to be taken in an ATOMIC\n  // transaction.  Otherwise another thread may call this mock\n  // method in the middle and mess up the state.\n  //\n  // However, performing the action has to be left out of the critical\n  // section.  The reason is that we have no control on what the\n  // action does (it can invoke an arbitrary user function or even a\n  // mock function) and excessive locking could cause a dead lock.\n  virtual const ExpectationBase* UntypedFindMatchingExpectation(\n      const void* untyped_args,\n      const void** untyped_action, bool* is_excessive,\n      ::std::ostream* what, ::std::ostream* why)\n          GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\n    const ArgumentTuple& args =\n        *static_cast<const ArgumentTuple*>(untyped_args);\n    MutexLock l(&g_gmock_mutex);\n    TypedExpectation<F>* exp = this->FindMatchingExpectationLocked(args);\n    if (exp == NULL) {  // A match wasn't found.\n      this->FormatUnexpectedCallMessageLocked(args, what, why);\n      return NULL;\n    }\n\n    // This line must be done before calling GetActionForArguments(),\n    // which will increment the call count for *exp and thus affect\n    // its saturation status.\n    *is_excessive = exp->IsSaturated();\n    const Action<F>* action = exp->GetActionForArguments(this, args, what, why);\n    if (action != NULL && action->IsDoDefault())\n      action = NULL;  // Normalize \"do default\" to NULL.\n    *untyped_action = action;\n    return exp;\n  }\n\n  // Prints the given function arguments to the ostream.\n  virtual void UntypedPrintArgs(const void* untyped_args,\n                                ::std::ostream* os) const {\n    const ArgumentTuple& args =\n        *static_cast<const ArgumentTuple*>(untyped_args);\n    UniversalPrint(args, os);\n  }\n\n  // Returns the expectation that matches the arguments, or NULL if no\n  // expectation matches them.\n  TypedExpectation<F>* FindMatchingExpectationLocked(\n      const ArgumentTuple& args) const\n          GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    for (typename UntypedExpectations::const_reverse_iterator it =\n             untyped_expectations_.rbegin();\n         it != untyped_expectations_.rend(); ++it) {\n      TypedExpectation<F>* const exp =\n          static_cast<TypedExpectation<F>*>(it->get());\n      if (exp->ShouldHandleArguments(args)) {\n        return exp;\n      }\n    }\n    return NULL;\n  }\n\n  // Returns a message that the arguments don't match any expectation.\n  void FormatUnexpectedCallMessageLocked(\n      const ArgumentTuple& args,\n      ::std::ostream* os,\n      ::std::ostream* why) const\n          GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    *os << \"\\nUnexpected mock function call - \";\n    DescribeDefaultActionTo(args, os);\n    PrintTriedExpectationsLocked(args, why);\n  }\n\n  // Prints a list of expectations that have been tried against the\n  // current mock function call.\n  void PrintTriedExpectationsLocked(\n      const ArgumentTuple& args,\n      ::std::ostream* why) const\n          GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n    g_gmock_mutex.AssertHeld();\n    const int count = static_cast<int>(untyped_expectations_.size());\n    *why << \"Google Mock tried the following \" << count << \" \"\n         << (count == 1 ? \"expectation, but it didn't match\" :\n             \"expectations, but none matched\")\n         << \":\\n\";\n    for (int i = 0; i < count; i++) {\n      TypedExpectation<F>* const expectation =\n          static_cast<TypedExpectation<F>*>(untyped_expectations_[i].get());\n      *why << \"\\n\";\n      expectation->DescribeLocationTo(why);\n      if (count > 1) {\n        *why << \"tried expectation #\" << i << \": \";\n      }\n      *why << expectation->source_text() << \"...\\n\";\n      expectation->ExplainMatchResultTo(args, why);\n      expectation->DescribeCallCountTo(why);\n    }\n  }\n\n  // The current spec (either default action spec or expectation spec)\n  // being described on this function mocker.\n  MockSpec<F> current_spec_;\n\n  // There is no generally useful and implementable semantics of\n  // copying a mock object, so copying a mock is usually a user error.\n  // Thus we disallow copying function mockers.  If the user really\n  // wants to copy a mock object, he should implement his own copy\n  // operation, for example:\n  //\n  //   class MockFoo : public Foo {\n  //    public:\n  //     // Defines a copy constructor explicitly.\n  //     MockFoo(const MockFoo& src) {}\n  //     ...\n  //   };\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(FunctionMockerBase);\n};  // class FunctionMockerBase\n\n#ifdef _MSC_VER\n# pragma warning(pop)  // Restores the warning state.\n#endif  // _MSV_VER\n\n// Implements methods of FunctionMockerBase.\n\n// Verifies that all expectations on this mock function have been\n// satisfied.  Reports one or more Google Test non-fatal failures and\n// returns false if not.\n\n// Reports an uninteresting call (whose description is in msg) in the\n// manner specified by 'reaction'.\nvoid ReportUninterestingCall(CallReaction reaction, const string& msg);\n\n}  // namespace internal\n\n// The style guide prohibits \"using\" statements in a namespace scope\n// inside a header file.  However, the MockSpec class template is\n// meant to be defined in the ::testing namespace.  The following line\n// is just a trick for working around a bug in MSVC 8.0, which cannot\n// handle it if we define MockSpec in ::testing.\nusing internal::MockSpec;\n\n// Const(x) is a convenient function for obtaining a const reference\n// to x.  This is useful for setting expectations on an overloaded\n// const mock method, e.g.\n//\n//   class MockFoo : public FooInterface {\n//    public:\n//     MOCK_METHOD0(Bar, int());\n//     MOCK_CONST_METHOD0(Bar, int&());\n//   };\n//\n//   MockFoo foo;\n//   // Expects a call to non-const MockFoo::Bar().\n//   EXPECT_CALL(foo, Bar());\n//   // Expects a call to const MockFoo::Bar().\n//   EXPECT_CALL(Const(foo), Bar());\ntemplate <typename T>\ninline const T& Const(const T& x) { return x; }\n\n// Constructs an Expectation object that references and co-owns exp.\ninline Expectation::Expectation(internal::ExpectationBase& exp)  // NOLINT\n    : expectation_base_(exp.GetHandle().expectation_base()) {}\n\n}  // namespace testing\n\n// A separate macro is required to avoid compile errors when the name\n// of the method used in call is a result of macro expansion.\n// See CompilesWithMethodNameExpandedFromMacro tests in\n// internal/gmock-spec-builders_test.cc for more details.\n#define GMOCK_ON_CALL_IMPL_(obj, call) \\\n    ((obj).gmock_##call).InternalDefaultActionSetAt(__FILE__, __LINE__, \\\n                                                    #obj, #call)\n#define ON_CALL(obj, call) GMOCK_ON_CALL_IMPL_(obj, call)\n\n#define GMOCK_EXPECT_CALL_IMPL_(obj, call) \\\n    ((obj).gmock_##call).InternalExpectedAt(__FILE__, __LINE__, #obj, #call)\n#define EXPECT_CALL(obj, call) GMOCK_EXPECT_CALL_IMPL_(obj, call)\n\n#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_SPEC_BUILDERS_H_\n"
  },
  {
    "path": "ext/gmock/include/gmock/gmock.h",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This is the main header file a user should include.\n\n#ifndef GMOCK_INCLUDE_GMOCK_GMOCK_H_\n#define GMOCK_INCLUDE_GMOCK_GMOCK_H_\n\n// This file implements the following syntax:\n//\n//   ON_CALL(mock_object.Method(...))\n//     .With(...) ?\n//     .WillByDefault(...);\n//\n// where With() is optional and WillByDefault() must appear exactly\n// once.\n//\n//   EXPECT_CALL(mock_object.Method(...))\n//     .With(...) ?\n//     .Times(...) ?\n//     .InSequence(...) *\n//     .WillOnce(...) *\n//     .WillRepeatedly(...) ?\n//     .RetiresOnSaturation() ? ;\n//\n// where all clauses are optional and WillOnce() can be repeated.\n\n#include \"gmock/gmock-actions.h\"\n#include \"gmock/gmock-cardinalities.h\"\n#include \"gmock/gmock-generated-actions.h\"\n#include \"gmock/gmock-generated-function-mockers.h\"\n#include \"gmock/gmock-generated-nice-strict.h\"\n#include \"gmock/gmock-generated-matchers.h\"\n#include \"gmock/gmock-matchers.h\"\n#include \"gmock/gmock-more-actions.h\"\n#include \"gmock/gmock-more-matchers.h\"\n#include \"gmock/internal/gmock-internal-utils.h\"\n\nnamespace testing {\n\n// Declares Google Mock flags that we want a user to use programmatically.\nGMOCK_DECLARE_bool_(catch_leaked_mocks);\nGMOCK_DECLARE_string_(verbose);\n\n// Initializes Google Mock.  This must be called before running the\n// tests.  In particular, it parses the command line for the flags\n// that Google Mock recognizes.  Whenever a Google Mock flag is seen,\n// it is removed from argv, and *argc is decremented.\n//\n// No value is returned.  Instead, the Google Mock flag variables are\n// updated.\n//\n// Since Google Test is needed for Google Mock to work, this function\n// also initializes Google Test and parses its flags, if that hasn't\n// been done.\nGTEST_API_ void InitGoogleMock(int* argc, char** argv);\n\n// This overloaded version can be used in Windows programs compiled in\n// UNICODE mode.\nGTEST_API_ void InitGoogleMock(int* argc, wchar_t** argv);\n\n}  // namespace testing\n\n#endif  // GMOCK_INCLUDE_GMOCK_GMOCK_H_\n"
  },
  {
    "path": "ext/gmock/include/gmock/internal/gmock-generated-internal-utils.h",
    "content": "// This file was GENERATED by command:\n//     pump.py gmock-generated-internal-utils.h.pump\n// DO NOT EDIT BY HAND!!!\n\n// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file contains template meta-programming utility classes needed\n// for implementing Google Mock.\n\n#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_\n#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_\n\n#include \"gmock/internal/gmock-port.h\"\n\nnamespace testing {\n\ntemplate <typename T>\nclass Matcher;\n\nnamespace internal {\n\n// An IgnoredValue object can be implicitly constructed from ANY value.\n// This is used in implementing the IgnoreResult(a) action.\nclass IgnoredValue {\n public:\n  // This constructor template allows any value to be implicitly\n  // converted to IgnoredValue.  The object has no data member and\n  // doesn't try to remember anything about the argument.  We\n  // deliberately omit the 'explicit' keyword in order to allow the\n  // conversion to be implicit.\n  template <typename T>\n  IgnoredValue(const T& /* ignored */) {}  // NOLINT(runtime/explicit)\n};\n\n// MatcherTuple<T>::type is a tuple type where each field is a Matcher\n// for the corresponding field in tuple type T.\ntemplate <typename Tuple>\nstruct MatcherTuple;\n\ntemplate <>\nstruct MatcherTuple< ::std::tr1::tuple<> > {\n  typedef ::std::tr1::tuple< > type;\n};\n\ntemplate <typename A1>\nstruct MatcherTuple< ::std::tr1::tuple<A1> > {\n  typedef ::std::tr1::tuple<Matcher<A1> > type;\n};\n\ntemplate <typename A1, typename A2>\nstruct MatcherTuple< ::std::tr1::tuple<A1, A2> > {\n  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2> > type;\n};\n\ntemplate <typename A1, typename A2, typename A3>\nstruct MatcherTuple< ::std::tr1::tuple<A1, A2, A3> > {\n  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3> > type;\n};\n\ntemplate <typename A1, typename A2, typename A3, typename A4>\nstruct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4> > {\n  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>,\n      Matcher<A4> > type;\n};\n\ntemplate <typename A1, typename A2, typename A3, typename A4, typename A5>\nstruct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5> > {\n  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,\n      Matcher<A5> > type;\n};\n\ntemplate <typename A1, typename A2, typename A3, typename A4, typename A5,\n    typename A6>\nstruct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6> > {\n  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,\n      Matcher<A5>, Matcher<A6> > type;\n};\n\ntemplate <typename A1, typename A2, typename A3, typename A4, typename A5,\n    typename A6, typename A7>\nstruct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7> > {\n  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,\n      Matcher<A5>, Matcher<A6>, Matcher<A7> > type;\n};\n\ntemplate <typename A1, typename A2, typename A3, typename A4, typename A5,\n    typename A6, typename A7, typename A8>\nstruct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8> > {\n  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,\n      Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8> > type;\n};\n\ntemplate <typename A1, typename A2, typename A3, typename A4, typename A5,\n    typename A6, typename A7, typename A8, typename A9>\nstruct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> > {\n  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,\n      Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A9> > type;\n};\n\ntemplate <typename A1, typename A2, typename A3, typename A4, typename A5,\n    typename A6, typename A7, typename A8, typename A9, typename A10>\nstruct MatcherTuple< ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,\n    A10> > {\n  typedef ::std::tr1::tuple<Matcher<A1>, Matcher<A2>, Matcher<A3>, Matcher<A4>,\n      Matcher<A5>, Matcher<A6>, Matcher<A7>, Matcher<A8>, Matcher<A9>,\n      Matcher<A10> > type;\n};\n\n// Template struct Function<F>, where F must be a function type, contains\n// the following typedefs:\n//\n//   Result:               the function's return type.\n//   ArgumentN:            the type of the N-th argument, where N starts with 1.\n//   ArgumentTuple:        the tuple type consisting of all parameters of F.\n//   ArgumentMatcherTuple: the tuple type consisting of Matchers for all\n//                         parameters of F.\n//   MakeResultVoid:       the function type obtained by substituting void\n//                         for the return type of F.\n//   MakeResultIgnoredValue:\n//                         the function type obtained by substituting Something\n//                         for the return type of F.\ntemplate <typename F>\nstruct Function;\n\ntemplate <typename R>\nstruct Function<R()> {\n  typedef R Result;\n  typedef ::std::tr1::tuple<> ArgumentTuple;\n  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;\n  typedef void MakeResultVoid();\n  typedef IgnoredValue MakeResultIgnoredValue();\n};\n\ntemplate <typename R, typename A1>\nstruct Function<R(A1)>\n    : Function<R()> {\n  typedef A1 Argument1;\n  typedef ::std::tr1::tuple<A1> ArgumentTuple;\n  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;\n  typedef void MakeResultVoid(A1);\n  typedef IgnoredValue MakeResultIgnoredValue(A1);\n};\n\ntemplate <typename R, typename A1, typename A2>\nstruct Function<R(A1, A2)>\n    : Function<R(A1)> {\n  typedef A2 Argument2;\n  typedef ::std::tr1::tuple<A1, A2> ArgumentTuple;\n  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;\n  typedef void MakeResultVoid(A1, A2);\n  typedef IgnoredValue MakeResultIgnoredValue(A1, A2);\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3>\nstruct Function<R(A1, A2, A3)>\n    : Function<R(A1, A2)> {\n  typedef A3 Argument3;\n  typedef ::std::tr1::tuple<A1, A2, A3> ArgumentTuple;\n  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;\n  typedef void MakeResultVoid(A1, A2, A3);\n  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3);\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3, typename A4>\nstruct Function<R(A1, A2, A3, A4)>\n    : Function<R(A1, A2, A3)> {\n  typedef A4 Argument4;\n  typedef ::std::tr1::tuple<A1, A2, A3, A4> ArgumentTuple;\n  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;\n  typedef void MakeResultVoid(A1, A2, A3, A4);\n  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4);\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3, typename A4,\n    typename A5>\nstruct Function<R(A1, A2, A3, A4, A5)>\n    : Function<R(A1, A2, A3, A4)> {\n  typedef A5 Argument5;\n  typedef ::std::tr1::tuple<A1, A2, A3, A4, A5> ArgumentTuple;\n  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;\n  typedef void MakeResultVoid(A1, A2, A3, A4, A5);\n  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5);\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3, typename A4,\n    typename A5, typename A6>\nstruct Function<R(A1, A2, A3, A4, A5, A6)>\n    : Function<R(A1, A2, A3, A4, A5)> {\n  typedef A6 Argument6;\n  typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6> ArgumentTuple;\n  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;\n  typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6);\n  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6);\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3, typename A4,\n    typename A5, typename A6, typename A7>\nstruct Function<R(A1, A2, A3, A4, A5, A6, A7)>\n    : Function<R(A1, A2, A3, A4, A5, A6)> {\n  typedef A7 Argument7;\n  typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7> ArgumentTuple;\n  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;\n  typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7);\n  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7);\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3, typename A4,\n    typename A5, typename A6, typename A7, typename A8>\nstruct Function<R(A1, A2, A3, A4, A5, A6, A7, A8)>\n    : Function<R(A1, A2, A3, A4, A5, A6, A7)> {\n  typedef A8 Argument8;\n  typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8> ArgumentTuple;\n  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;\n  typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8);\n  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8);\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3, typename A4,\n    typename A5, typename A6, typename A7, typename A8, typename A9>\nstruct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)>\n    : Function<R(A1, A2, A3, A4, A5, A6, A7, A8)> {\n  typedef A9 Argument9;\n  typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9> ArgumentTuple;\n  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;\n  typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9);\n  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,\n      A9);\n};\n\ntemplate <typename R, typename A1, typename A2, typename A3, typename A4,\n    typename A5, typename A6, typename A7, typename A8, typename A9,\n    typename A10>\nstruct Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)>\n    : Function<R(A1, A2, A3, A4, A5, A6, A7, A8, A9)> {\n  typedef A10 Argument10;\n  typedef ::std::tr1::tuple<A1, A2, A3, A4, A5, A6, A7, A8, A9,\n      A10> ArgumentTuple;\n  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;\n  typedef void MakeResultVoid(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10);\n  typedef IgnoredValue MakeResultIgnoredValue(A1, A2, A3, A4, A5, A6, A7, A8,\n      A9, A10);\n};\n\n}  // namespace internal\n\n}  // namespace testing\n\n#endif  // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_\n"
  },
  {
    "path": "ext/gmock/include/gmock/internal/gmock-generated-internal-utils.h.pump",
    "content": "$$ -*- mode: c++; -*-\n$$ This is a Pump source file.  Please use Pump to convert it to\n$$ gmock-generated-function-mockers.h.\n$$\n$var n = 10  $$ The maximum arity we support.\n// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file contains template meta-programming utility classes needed\n// for implementing Google Mock.\n\n#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_\n#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_\n\n#include \"gmock/internal/gmock-port.h\"\n\nnamespace testing {\n\ntemplate <typename T>\nclass Matcher;\n\nnamespace internal {\n\n// An IgnoredValue object can be implicitly constructed from ANY value.\n// This is used in implementing the IgnoreResult(a) action.\nclass IgnoredValue {\n public:\n  // This constructor template allows any value to be implicitly\n  // converted to IgnoredValue.  The object has no data member and\n  // doesn't try to remember anything about the argument.  We\n  // deliberately omit the 'explicit' keyword in order to allow the\n  // conversion to be implicit.\n  template <typename T>\n  IgnoredValue(const T& /* ignored */) {}  // NOLINT(runtime/explicit)\n};\n\n// MatcherTuple<T>::type is a tuple type where each field is a Matcher\n// for the corresponding field in tuple type T.\ntemplate <typename Tuple>\nstruct MatcherTuple;\n\n\n$range i 0..n\n$for i [[\n$range j 1..i\n$var typename_As = [[$for j, [[typename A$j]]]]\n$var As = [[$for j, [[A$j]]]]\n$var matcher_As = [[$for j, [[Matcher<A$j>]]]]\ntemplate <$typename_As>\nstruct MatcherTuple< ::std::tr1::tuple<$As> > {\n  typedef ::std::tr1::tuple<$matcher_As > type;\n};\n\n\n]]\n// Template struct Function<F>, where F must be a function type, contains\n// the following typedefs:\n//\n//   Result:               the function's return type.\n//   ArgumentN:            the type of the N-th argument, where N starts with 1.\n//   ArgumentTuple:        the tuple type consisting of all parameters of F.\n//   ArgumentMatcherTuple: the tuple type consisting of Matchers for all\n//                         parameters of F.\n//   MakeResultVoid:       the function type obtained by substituting void\n//                         for the return type of F.\n//   MakeResultIgnoredValue:\n//                         the function type obtained by substituting Something\n//                         for the return type of F.\ntemplate <typename F>\nstruct Function;\n\ntemplate <typename R>\nstruct Function<R()> {\n  typedef R Result;\n  typedef ::std::tr1::tuple<> ArgumentTuple;\n  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;\n  typedef void MakeResultVoid();\n  typedef IgnoredValue MakeResultIgnoredValue();\n};\n\n\n$range i 1..n\n$for i [[\n$range j 1..i\n$var typename_As = [[$for j [[, typename A$j]]]]\n$var As = [[$for j, [[A$j]]]]\n$var matcher_As = [[$for j, [[Matcher<A$j>]]]]\n$range k 1..i-1\n$var prev_As = [[$for k, [[A$k]]]]\ntemplate <typename R$typename_As>\nstruct Function<R($As)>\n    : Function<R($prev_As)> {\n  typedef A$i Argument$i;\n  typedef ::std::tr1::tuple<$As> ArgumentTuple;\n  typedef typename MatcherTuple<ArgumentTuple>::type ArgumentMatcherTuple;\n  typedef void MakeResultVoid($As);\n  typedef IgnoredValue MakeResultIgnoredValue($As);\n};\n\n\n]]\n}  // namespace internal\n\n}  // namespace testing\n\n#endif  // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_GENERATED_INTERNAL_UTILS_H_\n"
  },
  {
    "path": "ext/gmock/include/gmock/internal/gmock-internal-utils.h",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file defines some utilities useful for implementing Google\n// Mock.  They are subject to change without notice, so please DO NOT\n// USE THEM IN USER CODE.\n\n#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_\n#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_\n\n#include <stdio.h>\n#include <ostream>  // NOLINT\n#include <string>\n\n#include \"gmock/internal/gmock-generated-internal-utils.h\"\n#include \"gmock/internal/gmock-port.h\"\n#include \"gtest/gtest.h\"\n\nnamespace testing {\nnamespace internal {\n\n// Converts an identifier name to a space-separated list of lower-case\n// words.  Each maximum substring of the form [A-Za-z][a-z]*|\\d+ is\n// treated as one word.  For example, both \"FooBar123\" and\n// \"foo_bar_123\" are converted to \"foo bar 123\".\nGTEST_API_ string ConvertIdentifierNameToWords(const char* id_name);\n\n// PointeeOf<Pointer>::type is the type of a value pointed to by a\n// Pointer, which can be either a smart pointer or a raw pointer.  The\n// following default implementation is for the case where Pointer is a\n// smart pointer.\ntemplate <typename Pointer>\nstruct PointeeOf {\n  // Smart pointer classes define type element_type as the type of\n  // their pointees.\n  typedef typename Pointer::element_type type;\n};\n// This specialization is for the raw pointer case.\ntemplate <typename T>\nstruct PointeeOf<T*> { typedef T type; };  // NOLINT\n\n// GetRawPointer(p) returns the raw pointer underlying p when p is a\n// smart pointer, or returns p itself when p is already a raw pointer.\n// The following default implementation is for the smart pointer case.\ntemplate <typename Pointer>\ninline const typename Pointer::element_type* GetRawPointer(const Pointer& p) {\n  return p.get();\n}\n// This overloaded version is for the raw pointer case.\ntemplate <typename Element>\ninline Element* GetRawPointer(Element* p) { return p; }\n\n// This comparator allows linked_ptr to be stored in sets.\ntemplate <typename T>\nstruct LinkedPtrLessThan {\n  bool operator()(const ::testing::internal::linked_ptr<T>& lhs,\n                  const ::testing::internal::linked_ptr<T>& rhs) const {\n    return lhs.get() < rhs.get();\n  }\n};\n\n// Symbian compilation can be done with wchar_t being either a native\n// type or a typedef.  Using Google Mock with OpenC without wchar_t\n// should require the definition of _STLP_NO_WCHAR_T.\n//\n// MSVC treats wchar_t as a native type usually, but treats it as the\n// same as unsigned short when the compiler option /Zc:wchar_t- is\n// specified.  It defines _NATIVE_WCHAR_T_DEFINED symbol when wchar_t\n// is a native type.\n#if (GTEST_OS_SYMBIAN && defined(_STLP_NO_WCHAR_T)) || \\\n    (defined(_MSC_VER) && !defined(_NATIVE_WCHAR_T_DEFINED))\n// wchar_t is a typedef.\n#else\n# define GMOCK_WCHAR_T_IS_NATIVE_ 1\n#endif\n\n// signed wchar_t and unsigned wchar_t are NOT in the C++ standard.\n// Using them is a bad practice and not portable.  So DON'T use them.\n//\n// Still, Google Mock is designed to work even if the user uses signed\n// wchar_t or unsigned wchar_t (obviously, assuming the compiler\n// supports them).\n//\n// To gcc,\n//   wchar_t == signed wchar_t != unsigned wchar_t == unsigned int\n#ifdef __GNUC__\n// signed/unsigned wchar_t are valid types.\n# define GMOCK_HAS_SIGNED_WCHAR_T_ 1\n#endif\n\n// In what follows, we use the term \"kind\" to indicate whether a type\n// is bool, an integer type (excluding bool), a floating-point type,\n// or none of them.  This categorization is useful for determining\n// when a matcher argument type can be safely converted to another\n// type in the implementation of SafeMatcherCast.\nenum TypeKind {\n  kBool, kInteger, kFloatingPoint, kOther\n};\n\n// KindOf<T>::value is the kind of type T.\ntemplate <typename T> struct KindOf {\n  enum { value = kOther };  // The default kind.\n};\n\n// This macro declares that the kind of 'type' is 'kind'.\n#define GMOCK_DECLARE_KIND_(type, kind) \\\n  template <> struct KindOf<type> { enum { value = kind }; }\n\nGMOCK_DECLARE_KIND_(bool, kBool);\n\n// All standard integer types.\nGMOCK_DECLARE_KIND_(char, kInteger);\nGMOCK_DECLARE_KIND_(signed char, kInteger);\nGMOCK_DECLARE_KIND_(unsigned char, kInteger);\nGMOCK_DECLARE_KIND_(short, kInteger);  // NOLINT\nGMOCK_DECLARE_KIND_(unsigned short, kInteger);  // NOLINT\nGMOCK_DECLARE_KIND_(int, kInteger);\nGMOCK_DECLARE_KIND_(unsigned int, kInteger);\nGMOCK_DECLARE_KIND_(long, kInteger);  // NOLINT\nGMOCK_DECLARE_KIND_(unsigned long, kInteger);  // NOLINT\n\n#if GMOCK_WCHAR_T_IS_NATIVE_\nGMOCK_DECLARE_KIND_(wchar_t, kInteger);\n#endif\n\n// Non-standard integer types.\nGMOCK_DECLARE_KIND_(Int64, kInteger);\nGMOCK_DECLARE_KIND_(UInt64, kInteger);\n\n// All standard floating-point types.\nGMOCK_DECLARE_KIND_(float, kFloatingPoint);\nGMOCK_DECLARE_KIND_(double, kFloatingPoint);\nGMOCK_DECLARE_KIND_(long double, kFloatingPoint);\n\n#undef GMOCK_DECLARE_KIND_\n\n// Evaluates to the kind of 'type'.\n#define GMOCK_KIND_OF_(type) \\\n  static_cast< ::testing::internal::TypeKind>( \\\n      ::testing::internal::KindOf<type>::value)\n\n// Evaluates to true iff integer type T is signed.\n#define GMOCK_IS_SIGNED_(T) (static_cast<T>(-1) < 0)\n\n// LosslessArithmeticConvertibleImpl<kFromKind, From, kToKind, To>::value\n// is true iff arithmetic type From can be losslessly converted to\n// arithmetic type To.\n//\n// It's the user's responsibility to ensure that both From and To are\n// raw (i.e. has no CV modifier, is not a pointer, and is not a\n// reference) built-in arithmetic types, kFromKind is the kind of\n// From, and kToKind is the kind of To; the value is\n// implementation-defined when the above pre-condition is violated.\ntemplate <TypeKind kFromKind, typename From, TypeKind kToKind, typename To>\nstruct LosslessArithmeticConvertibleImpl : public false_type {};\n\n// Converting bool to bool is lossless.\ntemplate <>\nstruct LosslessArithmeticConvertibleImpl<kBool, bool, kBool, bool>\n    : public true_type {};  // NOLINT\n\n// Converting bool to any integer type is lossless.\ntemplate <typename To>\nstruct LosslessArithmeticConvertibleImpl<kBool, bool, kInteger, To>\n    : public true_type {};  // NOLINT\n\n// Converting bool to any floating-point type is lossless.\ntemplate <typename To>\nstruct LosslessArithmeticConvertibleImpl<kBool, bool, kFloatingPoint, To>\n    : public true_type {};  // NOLINT\n\n// Converting an integer to bool is lossy.\ntemplate <typename From>\nstruct LosslessArithmeticConvertibleImpl<kInteger, From, kBool, bool>\n    : public false_type {};  // NOLINT\n\n// Converting an integer to another non-bool integer is lossless iff\n// the target type's range encloses the source type's range.\ntemplate <typename From, typename To>\nstruct LosslessArithmeticConvertibleImpl<kInteger, From, kInteger, To>\n    : public bool_constant<\n      // When converting from a smaller size to a larger size, we are\n      // fine as long as we are not converting from signed to unsigned.\n      ((sizeof(From) < sizeof(To)) &&\n       (!GMOCK_IS_SIGNED_(From) || GMOCK_IS_SIGNED_(To))) ||\n      // When converting between the same size, the signedness must match.\n      ((sizeof(From) == sizeof(To)) &&\n       (GMOCK_IS_SIGNED_(From) == GMOCK_IS_SIGNED_(To)))> {};  // NOLINT\n\n#undef GMOCK_IS_SIGNED_\n\n// Converting an integer to a floating-point type may be lossy, since\n// the format of a floating-point number is implementation-defined.\ntemplate <typename From, typename To>\nstruct LosslessArithmeticConvertibleImpl<kInteger, From, kFloatingPoint, To>\n    : public false_type {};  // NOLINT\n\n// Converting a floating-point to bool is lossy.\ntemplate <typename From>\nstruct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kBool, bool>\n    : public false_type {};  // NOLINT\n\n// Converting a floating-point to an integer is lossy.\ntemplate <typename From, typename To>\nstruct LosslessArithmeticConvertibleImpl<kFloatingPoint, From, kInteger, To>\n    : public false_type {};  // NOLINT\n\n// Converting a floating-point to another floating-point is lossless\n// iff the target type is at least as big as the source type.\ntemplate <typename From, typename To>\nstruct LosslessArithmeticConvertibleImpl<\n  kFloatingPoint, From, kFloatingPoint, To>\n    : public bool_constant<sizeof(From) <= sizeof(To)> {};  // NOLINT\n\n// LosslessArithmeticConvertible<From, To>::value is true iff arithmetic\n// type From can be losslessly converted to arithmetic type To.\n//\n// It's the user's responsibility to ensure that both From and To are\n// raw (i.e. has no CV modifier, is not a pointer, and is not a\n// reference) built-in arithmetic types; the value is\n// implementation-defined when the above pre-condition is violated.\ntemplate <typename From, typename To>\nstruct LosslessArithmeticConvertible\n    : public LosslessArithmeticConvertibleImpl<\n  GMOCK_KIND_OF_(From), From, GMOCK_KIND_OF_(To), To> {};  // NOLINT\n\n// This interface knows how to report a Google Mock failure (either\n// non-fatal or fatal).\nclass FailureReporterInterface {\n public:\n  // The type of a failure (either non-fatal or fatal).\n  enum FailureType {\n    kNonfatal, kFatal\n  };\n\n  virtual ~FailureReporterInterface() {}\n\n  // Reports a failure that occurred at the given source file location.\n  virtual void ReportFailure(FailureType type, const char* file, int line,\n                             const string& message) = 0;\n};\n\n// Returns the failure reporter used by Google Mock.\nGTEST_API_ FailureReporterInterface* GetFailureReporter();\n\n// Asserts that condition is true; aborts the process with the given\n// message if condition is false.  We cannot use LOG(FATAL) or CHECK()\n// as Google Mock might be used to mock the log sink itself.  We\n// inline this function to prevent it from showing up in the stack\n// trace.\ninline void Assert(bool condition, const char* file, int line,\n                   const string& msg) {\n  if (!condition) {\n    GetFailureReporter()->ReportFailure(FailureReporterInterface::kFatal,\n                                        file, line, msg);\n  }\n}\ninline void Assert(bool condition, const char* file, int line) {\n  Assert(condition, file, line, \"Assertion failed.\");\n}\n\n// Verifies that condition is true; generates a non-fatal failure if\n// condition is false.\ninline void Expect(bool condition, const char* file, int line,\n                   const string& msg) {\n  if (!condition) {\n    GetFailureReporter()->ReportFailure(FailureReporterInterface::kNonfatal,\n                                        file, line, msg);\n  }\n}\ninline void Expect(bool condition, const char* file, int line) {\n  Expect(condition, file, line, \"Expectation failed.\");\n}\n\n// Severity level of a log.\nenum LogSeverity {\n  kInfo = 0,\n  kWarning = 1\n};\n\n// Valid values for the --gmock_verbose flag.\n\n// All logs (informational and warnings) are printed.\nconst char kInfoVerbosity[] = \"info\";\n// Only warnings are printed.\nconst char kWarningVerbosity[] = \"warning\";\n// No logs are printed.\nconst char kErrorVerbosity[] = \"error\";\n\n// Returns true iff a log with the given severity is visible according\n// to the --gmock_verbose flag.\nGTEST_API_ bool LogIsVisible(LogSeverity severity);\n\n// Prints the given message to stdout iff 'severity' >= the level\n// specified by the --gmock_verbose flag.  If stack_frames_to_skip >=\n// 0, also prints the stack trace excluding the top\n// stack_frames_to_skip frames.  In opt mode, any positive\n// stack_frames_to_skip is treated as 0, since we don't know which\n// function calls will be inlined by the compiler and need to be\n// conservative.\nGTEST_API_ void Log(LogSeverity severity,\n                    const string& message,\n                    int stack_frames_to_skip);\n\n// TODO(wan@google.com): group all type utilities together.\n\n// Type traits.\n\n// is_reference<T>::value is non-zero iff T is a reference type.\ntemplate <typename T> struct is_reference : public false_type {};\ntemplate <typename T> struct is_reference<T&> : public true_type {};\n\n// type_equals<T1, T2>::value is non-zero iff T1 and T2 are the same type.\ntemplate <typename T1, typename T2> struct type_equals : public false_type {};\ntemplate <typename T> struct type_equals<T, T> : public true_type {};\n\n// remove_reference<T>::type removes the reference from type T, if any.\ntemplate <typename T> struct remove_reference { typedef T type; };  // NOLINT\ntemplate <typename T> struct remove_reference<T&> { typedef T type; }; // NOLINT\n\n// DecayArray<T>::type turns an array type U[N] to const U* and preserves\n// other types.  Useful for saving a copy of a function argument.\ntemplate <typename T> struct DecayArray { typedef T type; };  // NOLINT\ntemplate <typename T, size_t N> struct DecayArray<T[N]> {\n  typedef const T* type;\n};\n// Sometimes people use arrays whose size is not available at the use site\n// (e.g. extern const char kNamePrefix[]).  This specialization covers that\n// case.\ntemplate <typename T> struct DecayArray<T[]> {\n  typedef const T* type;\n};\n\n// Invalid<T>() returns an invalid value of type T.  This is useful\n// when a value of type T is needed for compilation, but the statement\n// will not really be executed (or we don't care if the statement\n// crashes).\ntemplate <typename T>\ninline T Invalid() {\n  return const_cast<typename remove_reference<T>::type&>(\n      *static_cast<volatile typename remove_reference<T>::type*>(NULL));\n}\ntemplate <>\ninline void Invalid<void>() {}\n\n// Given a raw type (i.e. having no top-level reference or const\n// modifier) RawContainer that's either an STL-style container or a\n// native array, class StlContainerView<RawContainer> has the\n// following members:\n//\n//   - type is a type that provides an STL-style container view to\n//     (i.e. implements the STL container concept for) RawContainer;\n//   - const_reference is a type that provides a reference to a const\n//     RawContainer;\n//   - ConstReference(raw_container) returns a const reference to an STL-style\n//     container view to raw_container, which is a RawContainer.\n//   - Copy(raw_container) returns an STL-style container view of a\n//     copy of raw_container, which is a RawContainer.\n//\n// This generic version is used when RawContainer itself is already an\n// STL-style container.\ntemplate <class RawContainer>\nclass StlContainerView {\n public:\n  typedef RawContainer type;\n  typedef const type& const_reference;\n\n  static const_reference ConstReference(const RawContainer& container) {\n    // Ensures that RawContainer is not a const type.\n    testing::StaticAssertTypeEq<RawContainer,\n        GTEST_REMOVE_CONST_(RawContainer)>();\n    return container;\n  }\n  static type Copy(const RawContainer& container) { return container; }\n};\n\n// This specialization is used when RawContainer is a native array type.\ntemplate <typename Element, size_t N>\nclass StlContainerView<Element[N]> {\n public:\n  typedef GTEST_REMOVE_CONST_(Element) RawElement;\n  typedef internal::NativeArray<RawElement> type;\n  // NativeArray<T> can represent a native array either by value or by\n  // reference (selected by a constructor argument), so 'const type'\n  // can be used to reference a const native array.  We cannot\n  // 'typedef const type& const_reference' here, as that would mean\n  // ConstReference() has to return a reference to a local variable.\n  typedef const type const_reference;\n\n  static const_reference ConstReference(const Element (&array)[N]) {\n    // Ensures that Element is not a const type.\n    testing::StaticAssertTypeEq<Element, RawElement>();\n#if GTEST_OS_SYMBIAN\n    // The Nokia Symbian compiler confuses itself in template instantiation\n    // for this call without the cast to Element*:\n    // function call '[testing::internal::NativeArray<char *>].NativeArray(\n    //     {lval} const char *[4], long, testing::internal::RelationToSource)'\n    //     does not match\n    // 'testing::internal::NativeArray<char *>::NativeArray(\n    //     char *const *, unsigned int, testing::internal::RelationToSource)'\n    // (instantiating: 'testing::internal::ContainsMatcherImpl\n    //     <const char * (&)[4]>::Matches(const char * (&)[4]) const')\n    // (instantiating: 'testing::internal::StlContainerView<char *[4]>::\n    //     ConstReference(const char * (&)[4])')\n    // (and though the N parameter type is mismatched in the above explicit\n    // conversion of it doesn't help - only the conversion of the array).\n    return type(const_cast<Element*>(&array[0]), N, kReference);\n#else\n    return type(array, N, kReference);\n#endif  // GTEST_OS_SYMBIAN\n  }\n  static type Copy(const Element (&array)[N]) {\n#if GTEST_OS_SYMBIAN\n    return type(const_cast<Element*>(&array[0]), N, kCopy);\n#else\n    return type(array, N, kCopy);\n#endif  // GTEST_OS_SYMBIAN\n  }\n};\n\n// This specialization is used when RawContainer is a native array\n// represented as a (pointer, size) tuple.\ntemplate <typename ElementPointer, typename Size>\nclass StlContainerView< ::std::tr1::tuple<ElementPointer, Size> > {\n public:\n  typedef GTEST_REMOVE_CONST_(\n      typename internal::PointeeOf<ElementPointer>::type) RawElement;\n  typedef internal::NativeArray<RawElement> type;\n  typedef const type const_reference;\n\n  static const_reference ConstReference(\n      const ::std::tr1::tuple<ElementPointer, Size>& array) {\n    using ::std::tr1::get;\n    return type(get<0>(array), get<1>(array), kReference);\n  }\n  static type Copy(const ::std::tr1::tuple<ElementPointer, Size>& array) {\n    using ::std::tr1::get;\n    return type(get<0>(array), get<1>(array), kCopy);\n  }\n};\n\n// The following specialization prevents the user from instantiating\n// StlContainer with a reference type.\ntemplate <typename T> class StlContainerView<T&>;\n\n// A type transform to remove constness from the first part of a pair.\n// Pairs like that are used as the value_type of associative containers,\n// and this transform produces a similar but assignable pair.\ntemplate <typename T>\nstruct RemoveConstFromKey {\n  typedef T type;\n};\n\n// Partially specialized to remove constness from std::pair<const K, V>.\ntemplate <typename K, typename V>\nstruct RemoveConstFromKey<std::pair<const K, V> > {\n  typedef std::pair<K, V> type;\n};\n\n// Mapping from booleans to types. Similar to boost::bool_<kValue> and\n// std::integral_constant<bool, kValue>.\ntemplate <bool kValue>\nstruct BooleanConstant {};\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_INTERNAL_UTILS_H_\n"
  },
  {
    "path": "ext/gmock/include/gmock/internal/gmock-port.h",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vadimb@google.com (Vadim Berman)\n//\n// Low-level types and utilities for porting Google Mock to various\n// platforms.  They are subject to change without notice.  DO NOT USE\n// THEM IN USER CODE.\n\n#ifndef GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_\n#define GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_\n\n#include <assert.h>\n#include <stdlib.h>\n#include <iostream>\n\n// Most of the types needed for porting Google Mock are also required\n// for Google Test and are defined in gtest-port.h.\n#include \"gtest/internal/gtest-linked_ptr.h\"\n#include \"gtest/internal/gtest-port.h\"\n\n// To avoid conditional compilation everywhere, we make it\n// gmock-port.h's responsibility to #include the header implementing\n// tr1/tuple.  gmock-port.h does this via gtest-port.h, which is\n// guaranteed to pull in the tuple header.\n\n// For MS Visual C++, check the compiler version. At least VS 2003 is\n// required to compile Google Mock.\n#if defined(_MSC_VER) && _MSC_VER < 1310\n# error \"At least Visual C++ 2003 (7.1) is required to compile Google Mock.\"\n#endif\n\n// Macro for referencing flags.  This is public as we want the user to\n// use this syntax to reference Google Mock flags.\n#define GMOCK_FLAG(name) FLAGS_gmock_##name\n\n// Macros for declaring flags.\n#define GMOCK_DECLARE_bool_(name) extern GTEST_API_ bool GMOCK_FLAG(name)\n#define GMOCK_DECLARE_int32_(name) \\\n    extern GTEST_API_ ::testing::internal::Int32 GMOCK_FLAG(name)\n#define GMOCK_DECLARE_string_(name) \\\n    extern GTEST_API_ ::std::string GMOCK_FLAG(name)\n\n// Macros for defining flags.\n#define GMOCK_DEFINE_bool_(name, default_val, doc) \\\n    GTEST_API_ bool GMOCK_FLAG(name) = (default_val)\n#define GMOCK_DEFINE_int32_(name, default_val, doc) \\\n    GTEST_API_ ::testing::internal::Int32 GMOCK_FLAG(name) = (default_val)\n#define GMOCK_DEFINE_string_(name, default_val, doc) \\\n    GTEST_API_ ::std::string GMOCK_FLAG(name) = (default_val)\n\n#endif  // GMOCK_INCLUDE_GMOCK_INTERNAL_GMOCK_PORT_H_\n"
  },
  {
    "path": "ext/gmock/make/Makefile",
    "content": "# A sample Makefile for building both Google Mock and Google Test and\n# using them in user tests.  This file is self-contained, so you don't\n# need to use the Makefile in Google Test's source tree.  Please tweak\n# it to suit your environment and project.  You may want to move it to\n# your project's root directory.\n#\n# SYNOPSIS:\n#\n#   make [all]  - makes everything.\n#   make TARGET - makes the given target.\n#   make clean  - removes all files generated by make.\n\n# Please tweak the following variable definitions as needed by your\n# project, except GMOCK_HEADERS and GTEST_HEADERS, which you can use\n# in your own targets but shouldn't modify.\n\n# Points to the root of Google Test, relative to where this file is.\n# Remember to tweak this if you move this file, or if you want to use\n# a copy of Google Test at a different location.\nGTEST_DIR = ../gtest\n\n# Points to the root of Google Mock, relative to where this file is.\n# Remember to tweak this if you move this file.\nGMOCK_DIR = ..\n\n# Where to find user code.\nUSER_DIR = ../test\n\n# Flags passed to the preprocessor.\n# Set Google Test and Google Mock's header directories as system\n# directories, such that the compiler doesn't generate warnings in\n# these headers.\nCPPFLAGS += -isystem $(GTEST_DIR)/include -isystem $(GMOCK_DIR)/include\n\n# Flags passed to the C++ compiler.\nCXXFLAGS += -g -Wall -Wextra -pthread\n\n# All tests produced by this Makefile.  Remember to add new tests you\n# created to the list.\nTESTS = gmock_test\n\n# All Google Test headers.  Usually you shouldn't change this\n# definition.\nGTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \\\n                $(GTEST_DIR)/include/gtest/internal/*.h\n\n# All Google Mock headers. Note that all Google Test headers are\n# included here too, as they are #included by Google Mock headers.\n# Usually you shouldn't change this definition.\t\nGMOCK_HEADERS = $(GMOCK_DIR)/include/gmock/*.h \\\n                $(GMOCK_DIR)/include/gmock/internal/*.h \\\n                $(GTEST_HEADERS)\n\n# House-keeping build targets.\n\nall : $(TESTS)\n\nclean :\n\trm -f $(TESTS) gmock.a gmock_main.a *.o\n\n# Builds gmock.a and gmock_main.a.  These libraries contain both\n# Google Mock and Google Test.  A test should link with either gmock.a\n# or gmock_main.a, depending on whether it defines its own main()\n# function.  It's fine if your test only uses features from Google\n# Test (and not Google Mock).\n\n# Usually you shouldn't tweak such internal variables, indicated by a\n# trailing _.\nGTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS)\nGMOCK_SRCS_ = $(GMOCK_DIR)/src/*.cc $(GMOCK_HEADERS)\n\n# For simplicity and to avoid depending on implementation details of\n# Google Mock and Google Test, the dependencies specified below are\n# conservative and not optimized.  This is fine as Google Mock and\n# Google Test compile fast and for ordinary users their source rarely\n# changes.\ngtest-all.o : $(GTEST_SRCS_)\n\t$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) -I$(GMOCK_DIR) $(CXXFLAGS) \\\n            -c $(GTEST_DIR)/src/gtest-all.cc\n\ngmock-all.o : $(GMOCK_SRCS_)\n\t$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) -I$(GMOCK_DIR) $(CXXFLAGS) \\\n            -c $(GMOCK_DIR)/src/gmock-all.cc\n\ngmock_main.o : $(GMOCK_SRCS_)\n\t$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) -I$(GMOCK_DIR) $(CXXFLAGS) \\\n            -c $(GMOCK_DIR)/src/gmock_main.cc\n\ngmock.a : gmock-all.o gtest-all.o\n\t$(AR) $(ARFLAGS) $@ $^\n\ngmock_main.a : gmock-all.o gtest-all.o gmock_main.o\n\t$(AR) $(ARFLAGS) $@ $^\n\n# Builds a sample test.\n\ngmock_test.o : $(USER_DIR)/gmock_test.cc $(GMOCK_HEADERS)\n\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/gmock_test.cc\n\ngmock_test : gmock_test.o gmock_main.a\n\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@\n"
  },
  {
    "path": "ext/gmock/msvc/2005/gmock.sln",
    "content": "﻿\r\nMicrosoft Visual Studio Solution File, Format Version 9.00\r\n# Visual Studio 2005\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"gmock\", \"gmock.vcproj\", \"{34681F0D-CE45-415D-B5F2-5C662DFE3BD5}\"\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"gmock_test\", \"gmock_test.vcproj\", \"{F10D22F8-AC7B-4213-8720-608E7D878CD2}\"\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"gmock_main\", \"gmock_main.vcproj\", \"{E4EF614B-30DF-4954-8C53-580A0BF6B589}\"\r\nEndProject\r\nGlobal\r\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\r\n\t\tDebug|Win32 = Debug|Win32\r\n\t\tRelease|Win32 = Release|Win32\r\n\tEndGlobalSection\r\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n\t\t{34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Debug|Win32.ActiveCfg = Debug|Win32\r\n\t\t{34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Debug|Win32.Build.0 = Debug|Win32\r\n\t\t{34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Release|Win32.ActiveCfg = Release|Win32\r\n\t\t{34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Release|Win32.Build.0 = Release|Win32\r\n\t\t{F10D22F8-AC7B-4213-8720-608E7D878CD2}.Debug|Win32.ActiveCfg = Debug|Win32\r\n\t\t{F10D22F8-AC7B-4213-8720-608E7D878CD2}.Debug|Win32.Build.0 = Debug|Win32\r\n\t\t{F10D22F8-AC7B-4213-8720-608E7D878CD2}.Release|Win32.ActiveCfg = Release|Win32\r\n\t\t{F10D22F8-AC7B-4213-8720-608E7D878CD2}.Release|Win32.Build.0 = Release|Win32\r\n\t\t{E4EF614B-30DF-4954-8C53-580A0BF6B589}.Debug|Win32.ActiveCfg = Debug|Win32\r\n\t\t{E4EF614B-30DF-4954-8C53-580A0BF6B589}.Debug|Win32.Build.0 = Debug|Win32\r\n\t\t{E4EF614B-30DF-4954-8C53-580A0BF6B589}.Release|Win32.ActiveCfg = Release|Win32\r\n\t\t{E4EF614B-30DF-4954-8C53-580A0BF6B589}.Release|Win32.Build.0 = Release|Win32\r\n\tEndGlobalSection\r\n\tGlobalSection(SolutionProperties) = preSolution\r\n\t\tHideSolutionNode = FALSE\r\n\tEndGlobalSection\r\nEndGlobal\r\n"
  },
  {
    "path": "ext/gmock/msvc/2005/gmock.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"8.00\"\r\n\tName=\"gmock\"\r\n\tProjectGUID=\"{34681F0D-CE45-415D-B5F2-5C662DFE3BD5}\"\r\n\tRootNamespace=\"gmock\"\r\n\tKeyword=\"Win32Proj\"\r\n\t>\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"\r\n\t\t/>\r\n\t</Platforms>\r\n\t<ToolFiles>\r\n\t</ToolFiles>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionDir)$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)\\$(ProjectName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\tInheritedPropertySheets=\".\\gmock_config.vsprops\"\r\n\t\t\tCharacterSet=\"1\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"..\\..\\include;..\\..\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_LIB\"\r\n\t\t\t\tMinimalRebuild=\"true\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"1\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"true\"\r\n\t\t\t\tDebugInformationFormat=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionDir)$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)\\$(ProjectName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\tInheritedPropertySheets=\".\\gmock_config.vsprops\"\r\n\t\t\tCharacterSet=\"1\"\r\n\t\t\tWholeProgramOptimization=\"1\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"..\\..\\include;..\\..\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_LIB\"\r\n\t\t\t\tRuntimeLibrary=\"0\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"true\"\r\n\t\t\t\tDebugInformationFormat=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\"\r\n\t\t\t>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\..\\src\\gmock-all.cc\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"$(GTestDir)\\src\\gtest-all.cc\"\r\n\t\t\t\t>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"$(GTestDir)\"\r\n\t\t\t\t\t/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"$(GTestDir)\"\r\n\t\t\t\t\t/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Public Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\"\r\n\t\t\t>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Private Header Files\"\r\n\t\t\t>\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "ext/gmock/msvc/2005/gmock_config.vsprops",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioPropertySheet\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"8.00\"\r\n\tName=\"gmock_config\"\r\n\t>\r\n\t<Tool\r\n\t\tName=\"VCCLCompilerTool\"\r\n\t\tAdditionalIncludeDirectories=\"&quot;$(GTestDir)/include&quot;\"\r\n\t/>\r\n\t<UserMacro\r\n\t\tName=\"GTestDir\"\r\n\t\tValue=\"../../gtest\"\r\n\t/>\r\n</VisualStudioPropertySheet>\r\n"
  },
  {
    "path": "ext/gmock/msvc/2005/gmock_main.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"8.00\"\r\n\tName=\"gmock_main\"\r\n\tProjectGUID=\"{E4EF614B-30DF-4954-8C53-580A0BF6B589}\"\r\n\tRootNamespace=\"gmock_main\"\r\n\tKeyword=\"Win32Proj\"\r\n\t>\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"\r\n\t\t/>\r\n\t</Platforms>\r\n\t<ToolFiles>\r\n\t</ToolFiles>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionDir)$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)\\$(ProjectName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\tInheritedPropertySheets=\".\\gmock_config.vsprops\"\r\n\t\t\tCharacterSet=\"1\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"../../include\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_LIB\"\r\n\t\t\t\tMinimalRebuild=\"true\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"1\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"true\"\r\n\t\t\t\tDebugInformationFormat=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionDir)$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)\\$(ProjectName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\tInheritedPropertySheets=\".\\gmock_config.vsprops\"\r\n\t\t\tCharacterSet=\"1\"\r\n\t\t\tWholeProgramOptimization=\"1\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"../../include\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_LIB\"\r\n\t\t\t\tRuntimeLibrary=\"0\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"true\"\r\n\t\t\t\tDebugInformationFormat=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t\t<ProjectReference\r\n\t\t\tReferencedProjectIdentifier=\"{34681F0D-CE45-415D-B5F2-5C662DFE3BD5}\"\r\n\t\t\tRelativePathToProject=\".\\gmock.vcproj\"\r\n\t\t/>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\"\r\n\t\t\t>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\..\\src\\gmock_main.cc\"\r\n\t\t\t\t>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"../../include\"\r\n\t\t\t\t\t/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"../../include\"\r\n\t\t\t\t\t/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\"\r\n\t\t\t>\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "ext/gmock/msvc/2005/gmock_test.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"8.00\"\r\n\tName=\"gmock_test\"\r\n\tProjectGUID=\"{F10D22F8-AC7B-4213-8720-608E7D878CD2}\"\r\n\tRootNamespace=\"gmock_test\"\r\n\tKeyword=\"Win32Proj\"\r\n\t>\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"\r\n\t\t/>\r\n\t</Platforms>\r\n\t<ToolFiles>\r\n\t</ToolFiles>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionDir)$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)\\$(ProjectName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\tInheritedPropertySheets=\".\\gmock_config.vsprops\"\r\n\t\t\tCharacterSet=\"1\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tAdditionalOptions=\"/bigobj\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"..\\..\\include;..\\..\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_CONSOLE\"\r\n\t\t\t\tMinimalRebuild=\"true\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"1\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"true\"\r\n\t\t\t\tDebugInformationFormat=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tLinkIncremental=\"2\"\r\n\t\t\t\tGenerateDebugInformation=\"true\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tTargetMachine=\"1\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionDir)$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)\\$(ProjectName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\tInheritedPropertySheets=\".\\gmock_config.vsprops\"\r\n\t\t\tCharacterSet=\"1\"\r\n\t\t\tWholeProgramOptimization=\"1\"\r\n\t\t\t>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tAdditionalOptions=\"/bigobj\"\r\n\t\t\t\tAdditionalIncludeDirectories=\"..\\..\\include;..\\..\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_CONSOLE\"\r\n\t\t\t\tRuntimeLibrary=\"0\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"true\"\r\n\t\t\t\tDebugInformationFormat=\"3\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tLinkIncremental=\"1\"\r\n\t\t\t\tGenerateDebugInformation=\"true\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tOptimizeReferences=\"2\"\r\n\t\t\t\tEnableCOMDATFolding=\"2\"\r\n\t\t\t\tTargetMachine=\"1\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCALinkTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManifestTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXDCMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCBscMakeTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCFxCopTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAppVerifierTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"\r\n\t\t\t/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"\r\n\t\t\t/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t\t<ProjectReference\r\n\t\t\tReferencedProjectIdentifier=\"{E4EF614B-30DF-4954-8C53-580A0BF6B589}\"\r\n\t\t\tRelativePathToProject=\".\\gmock_main.vcproj\"\r\n\t\t/>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\"\r\n\t\t\t>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\..\\test\\gmock_all_test.cc\"\r\n\t\t\t\t>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\"\r\n\t\t\t>\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "ext/gmock/msvc/2010/gmock.sln",
    "content": "﻿\r\nMicrosoft Visual Studio Solution File, Format Version 11.00\r\n# Visual C++ Express 2010\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"gmock\", \"gmock.vcxproj\", \"{34681F0D-CE45-415D-B5F2-5C662DFE3BD5}\"\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"gmock_test\", \"gmock_test.vcxproj\", \"{F10D22F8-AC7B-4213-8720-608E7D878CD2}\"\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"gmock_main\", \"gmock_main.vcxproj\", \"{E4EF614B-30DF-4954-8C53-580A0BF6B589}\"\r\nEndProject\r\nGlobal\r\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\r\n\t\tDebug|Win32 = Debug|Win32\r\n\t\tRelease|Win32 = Release|Win32\r\n\tEndGlobalSection\r\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n\t\t{34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Debug|Win32.ActiveCfg = Debug|Win32\r\n\t\t{34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Debug|Win32.Build.0 = Debug|Win32\r\n\t\t{34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Release|Win32.ActiveCfg = Release|Win32\r\n\t\t{34681F0D-CE45-415D-B5F2-5C662DFE3BD5}.Release|Win32.Build.0 = Release|Win32\r\n\t\t{F10D22F8-AC7B-4213-8720-608E7D878CD2}.Debug|Win32.ActiveCfg = Debug|Win32\r\n\t\t{F10D22F8-AC7B-4213-8720-608E7D878CD2}.Debug|Win32.Build.0 = Debug|Win32\r\n\t\t{F10D22F8-AC7B-4213-8720-608E7D878CD2}.Release|Win32.ActiveCfg = Release|Win32\r\n\t\t{F10D22F8-AC7B-4213-8720-608E7D878CD2}.Release|Win32.Build.0 = Release|Win32\r\n\t\t{E4EF614B-30DF-4954-8C53-580A0BF6B589}.Debug|Win32.ActiveCfg = Debug|Win32\r\n\t\t{E4EF614B-30DF-4954-8C53-580A0BF6B589}.Debug|Win32.Build.0 = Debug|Win32\r\n\t\t{E4EF614B-30DF-4954-8C53-580A0BF6B589}.Release|Win32.ActiveCfg = Release|Win32\r\n\t\t{E4EF614B-30DF-4954-8C53-580A0BF6B589}.Release|Win32.Build.0 = Release|Win32\r\n\tEndGlobalSection\r\n\tGlobalSection(SolutionProperties) = preSolution\r\n\t\tHideSolutionNode = FALSE\r\n\tEndGlobalSection\r\nEndGlobal\r\n"
  },
  {
    "path": "ext/gmock/msvc/2010/gmock.vcxproj",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|Win32\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|Win32\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{34681F0D-CE45-415D-B5F2-5C662DFE3BD5}</ProjectGuid>\r\n    <RootNamespace>gmock</RootNamespace>\r\n    <Keyword>Win32Proj</Keyword>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <CharacterSet>Unicode</CharacterSet>\r\n    <WholeProgramOptimization>true</WholeProgramOptimization>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <CharacterSet>Unicode</CharacterSet>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"gmock_config.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"gmock_config.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">$(SolutionDir)$(Configuration)\\</OutDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">$(OutDir)$(ProjectName)\\</IntDir>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">$(SolutionDir)$(Configuration)\\</OutDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">$(OutDir)$(ProjectName)\\</IntDir>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <ClCompile>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>..\\..\\include;..\\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <MinimalRebuild>true</MinimalRebuild>\r\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r\n      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n    </ClCompile>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <ClCompile>\r\n      <AdditionalIncludeDirectories>..\\..\\include;..\\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n    </ClCompile>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\..\\src\\gmock-all.cc\" />\r\n    <ClCompile Include=\"$(GTestDir)\\src\\gtest-all.cc\">\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">$(GTestDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">$(GTestDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n    </ClCompile>\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n</Project>\r\n"
  },
  {
    "path": "ext/gmock/msvc/2010/gmock_config.props",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <PropertyGroup Label=\"UserMacros\">\r\n    <GTestDir>../../gtest</GTestDir>\r\n  </PropertyGroup>\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup>\r\n    <ClCompile>\r\n      <AdditionalIncludeDirectories>$(GTestDir)/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n    </ClCompile>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <BuildMacro Include=\"GTestDir\">\r\n      <Value>$(GTestDir)</Value>\r\n    </BuildMacro>\r\n  </ItemGroup>\r\n</Project>\r\n"
  },
  {
    "path": "ext/gmock/msvc/2010/gmock_main.vcxproj",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|Win32\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|Win32\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{E4EF614B-30DF-4954-8C53-580A0BF6B589}</ProjectGuid>\r\n    <RootNamespace>gmock_main</RootNamespace>\r\n    <Keyword>Win32Proj</Keyword>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <CharacterSet>Unicode</CharacterSet>\r\n    <WholeProgramOptimization>true</WholeProgramOptimization>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>StaticLibrary</ConfigurationType>\r\n    <CharacterSet>Unicode</CharacterSet>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"gmock_config.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"gmock_config.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">$(SolutionDir)$(Configuration)\\</OutDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">$(OutDir)$(ProjectName)\\</IntDir>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">$(SolutionDir)$(Configuration)\\</OutDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">$(OutDir)$(ProjectName)\\</IntDir>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <ClCompile>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <MinimalRebuild>true</MinimalRebuild>\r\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r\n      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n    </ClCompile>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <ClCompile>\r\n      <AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n    </ClCompile>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ProjectReference Include=\"gmock.vcxproj\">\r\n      <Project>{34681f0d-ce45-415d-b5f2-5c662dfe3bd5}</Project>\r\n      <CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>\r\n      <ReferenceOutputAssembly>true</ReferenceOutputAssembly>\r\n    </ProjectReference>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\..\\src\\gmock_main.cc\">\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <AdditionalIncludeDirectories Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n    </ClCompile>\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n</Project>\r\n"
  },
  {
    "path": "ext/gmock/msvc/2010/gmock_test.vcxproj",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <ItemGroup Label=\"ProjectConfigurations\">\r\n    <ProjectConfiguration Include=\"Debug|Win32\">\r\n      <Configuration>Debug</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n    <ProjectConfiguration Include=\"Release|Win32\">\r\n      <Configuration>Release</Configuration>\r\n      <Platform>Win32</Platform>\r\n    </ProjectConfiguration>\r\n  </ItemGroup>\r\n  <PropertyGroup Label=\"Globals\">\r\n    <ProjectGuid>{F10D22F8-AC7B-4213-8720-608E7D878CD2}</ProjectGuid>\r\n    <RootNamespace>gmock_test</RootNamespace>\r\n    <Keyword>Win32Proj</Keyword>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n    <CharacterSet>Unicode</CharacterSet>\r\n    <WholeProgramOptimization>true</WholeProgramOptimization>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"Configuration\">\r\n    <ConfigurationType>Application</ConfigurationType>\r\n    <CharacterSet>Unicode</CharacterSet>\r\n  </PropertyGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\r\n  <ImportGroup Label=\"ExtensionSettings\">\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"gmock_config.props\" />\r\n  </ImportGroup>\r\n  <ImportGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\" Label=\"PropertySheets\">\r\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\r\n    <Import Project=\"gmock_config.props\" />\r\n  </ImportGroup>\r\n  <PropertyGroup Label=\"UserMacros\" />\r\n  <PropertyGroup>\r\n    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">$(SolutionDir)$(Configuration)\\</OutDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">$(OutDir)$(ProjectName)\\</IntDir>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">true</LinkIncremental>\r\n    <OutDir Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">$(SolutionDir)$(Configuration)\\</OutDir>\r\n    <IntDir Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">$(OutDir)$(ProjectName)\\</IntDir>\r\n    <LinkIncremental Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">false</LinkIncremental>\r\n  </PropertyGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|Win32'\">\r\n    <ClCompile>\r\n      <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>\r\n      <Optimization>Disabled</Optimization>\r\n      <AdditionalIncludeDirectories>..\\..\\include;..\\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <MinimalRebuild>true</MinimalRebuild>\r\n      <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r\n      <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Link>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Console</SubSystem>\r\n      <TargetMachine>MachineX86</TargetMachine>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\r\n    <ClCompile>\r\n      <AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>\r\n      <AdditionalIncludeDirectories>..\\..\\include;..\\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r\n      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r\n      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\r\n      <PrecompiledHeader>\r\n      </PrecompiledHeader>\r\n      <WarningLevel>Level3</WarningLevel>\r\n      <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>\r\n    </ClCompile>\r\n    <Link>\r\n      <GenerateDebugInformation>true</GenerateDebugInformation>\r\n      <SubSystem>Console</SubSystem>\r\n      <OptimizeReferences>true</OptimizeReferences>\r\n      <EnableCOMDATFolding>true</EnableCOMDATFolding>\r\n      <TargetMachine>MachineX86</TargetMachine>\r\n    </Link>\r\n  </ItemDefinitionGroup>\r\n  <ItemGroup>\r\n    <ProjectReference Include=\"gmock_main.vcxproj\">\r\n      <Project>{e4ef614b-30df-4954-8c53-580a0bf6b589}</Project>\r\n      <CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>\r\n      <ReferenceOutputAssembly>true</ReferenceOutputAssembly>\r\n    </ProjectReference>\r\n  </ItemGroup>\r\n  <ItemGroup>\r\n    <ClCompile Include=\"..\\..\\test\\gmock_all_test.cc\" />\r\n  </ItemGroup>\r\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\r\n  <ImportGroup Label=\"ExtensionTargets\">\r\n  </ImportGroup>\r\n</Project>\r\n"
  },
  {
    "path": "ext/gmock/scripts/fuse_gmock_files.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2009, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"fuse_gmock_files.py v0.1.0\nFuses Google Mock and Google Test source code into two .h files and a .cc file.\n\nSYNOPSIS\n       fuse_gmock_files.py [GMOCK_ROOT_DIR] OUTPUT_DIR\n\n       Scans GMOCK_ROOT_DIR for Google Mock and Google Test source\n       code, assuming Google Test is in the GMOCK_ROOT_DIR/gtest\n       sub-directory, and generates three files:\n       OUTPUT_DIR/gtest/gtest.h, OUTPUT_DIR/gmock/gmock.h, and\n       OUTPUT_DIR/gmock-gtest-all.cc.  Then you can build your tests\n       by adding OUTPUT_DIR to the include search path and linking\n       with OUTPUT_DIR/gmock-gtest-all.cc.  These three files contain\n       everything you need to use Google Mock.  Hence you can\n       \"install\" Google Mock by copying them to wherever you want.\n\n       GMOCK_ROOT_DIR can be omitted and defaults to the parent\n       directory of the directory holding this script.\n\nEXAMPLES\n       ./fuse_gmock_files.py fused_gmock\n       ./fuse_gmock_files.py path/to/unpacked/gmock fused_gmock\n\nThis tool is experimental.  In particular, it assumes that there is no\nconditional inclusion of Google Mock or Google Test headers.  Please\nreport any problems to googlemock@googlegroups.com.  You can read\nhttp://code.google.com/p/googlemock/wiki/CookBook for more\ninformation.\n\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport re\nimport sets\nimport sys\n\n# We assume that this file is in the scripts/ directory in the Google\n# Mock root directory.\nDEFAULT_GMOCK_ROOT_DIR = os.path.join(os.path.dirname(__file__), '..')\n\n# We need to call into gtest/scripts/fuse_gtest_files.py.\nsys.path.append(os.path.join(DEFAULT_GMOCK_ROOT_DIR, 'gtest/scripts'))\nimport fuse_gtest_files\ngtest = fuse_gtest_files\n\n# Regex for matching '#include \"gmock/...\"'.\nINCLUDE_GMOCK_FILE_REGEX = re.compile(r'^\\s*#\\s*include\\s*\"(gmock/.+)\"')\n\n# Where to find the source seed files.\nGMOCK_H_SEED = 'include/gmock/gmock.h'\nGMOCK_ALL_CC_SEED = 'src/gmock-all.cc'\n\n# Where to put the generated files.\nGTEST_H_OUTPUT = 'gtest/gtest.h'\nGMOCK_H_OUTPUT = 'gmock/gmock.h'\nGMOCK_GTEST_ALL_CC_OUTPUT = 'gmock-gtest-all.cc'\n\n\ndef GetGTestRootDir(gmock_root):\n  \"\"\"Returns the root directory of Google Test.\"\"\"\n\n  return os.path.join(gmock_root, 'gtest')\n\n\ndef ValidateGMockRootDir(gmock_root):\n  \"\"\"Makes sure gmock_root points to a valid gmock root directory.\n\n  The function aborts the program on failure.\n  \"\"\"\n\n  gtest.ValidateGTestRootDir(GetGTestRootDir(gmock_root))\n  gtest.VerifyFileExists(gmock_root, GMOCK_H_SEED)\n  gtest.VerifyFileExists(gmock_root, GMOCK_ALL_CC_SEED)\n\n\ndef ValidateOutputDir(output_dir):\n  \"\"\"Makes sure output_dir points to a valid output directory.\n\n  The function aborts the program on failure.\n  \"\"\"\n\n  gtest.VerifyOutputFile(output_dir, gtest.GTEST_H_OUTPUT)\n  gtest.VerifyOutputFile(output_dir, GMOCK_H_OUTPUT)\n  gtest.VerifyOutputFile(output_dir, GMOCK_GTEST_ALL_CC_OUTPUT)\n\n\ndef FuseGMockH(gmock_root, output_dir):\n  \"\"\"Scans folder gmock_root to generate gmock/gmock.h in output_dir.\"\"\"\n\n  output_file = file(os.path.join(output_dir, GMOCK_H_OUTPUT), 'w')\n  processed_files = sets.Set()  # Holds all gmock headers we've processed.\n\n  def ProcessFile(gmock_header_path):\n    \"\"\"Processes the given gmock header file.\"\"\"\n\n    # We don't process the same header twice.\n    if gmock_header_path in processed_files:\n      return\n\n    processed_files.add(gmock_header_path)\n\n    # Reads each line in the given gmock header.\n    for line in file(os.path.join(gmock_root, gmock_header_path), 'r'):\n      m = INCLUDE_GMOCK_FILE_REGEX.match(line)\n      if m:\n        # It's '#include \"gmock/...\"' - let's process it recursively.\n        ProcessFile('include/' + m.group(1))\n      else:\n        m = gtest.INCLUDE_GTEST_FILE_REGEX.match(line)\n        if m:\n          # It's '#include \"gtest/foo.h\"'.  We translate it to\n          # \"gtest/gtest.h\", regardless of what foo is, since all\n          # gtest headers are fused into gtest/gtest.h.\n\n          # There is no need to #include gtest.h twice.\n          if not gtest.GTEST_H_SEED in processed_files:\n            processed_files.add(gtest.GTEST_H_SEED)\n            output_file.write('#include \"%s\"\\n' % (gtest.GTEST_H_OUTPUT,))\n        else:\n          # Otherwise we copy the line unchanged to the output file.\n          output_file.write(line)\n\n  ProcessFile(GMOCK_H_SEED)\n  output_file.close()\n\n\ndef FuseGMockAllCcToFile(gmock_root, output_file):\n  \"\"\"Scans folder gmock_root to fuse gmock-all.cc into output_file.\"\"\"\n\n  processed_files = sets.Set()\n\n  def ProcessFile(gmock_source_file):\n    \"\"\"Processes the given gmock source file.\"\"\"\n\n    # We don't process the same #included file twice.\n    if gmock_source_file in processed_files:\n      return\n\n    processed_files.add(gmock_source_file)\n\n    # Reads each line in the given gmock source file.\n    for line in file(os.path.join(gmock_root, gmock_source_file), 'r'):\n      m = INCLUDE_GMOCK_FILE_REGEX.match(line)\n      if m:\n        # It's '#include \"gmock/foo.h\"'.  We treat it as '#include\n        # \"gmock/gmock.h\"', as all other gmock headers are being fused\n        # into gmock.h and cannot be #included directly.\n\n        # There is no need to #include \"gmock/gmock.h\" more than once.\n        if not GMOCK_H_SEED in processed_files:\n          processed_files.add(GMOCK_H_SEED)\n          output_file.write('#include \"%s\"\\n' % (GMOCK_H_OUTPUT,))\n      else:\n        m = gtest.INCLUDE_GTEST_FILE_REGEX.match(line)\n        if m:\n          # It's '#include \"gtest/...\"'.\n          # There is no need to #include gtest.h as it has been\n          # #included by gtest-all.cc.\n          pass\n        else:\n          m = gtest.INCLUDE_SRC_FILE_REGEX.match(line)\n          if m:\n            # It's '#include \"src/foo\"' - let's process it recursively.\n            ProcessFile(m.group(1))\n          else:\n            # Otherwise we copy the line unchanged to the output file.\n            output_file.write(line)\n\n  ProcessFile(GMOCK_ALL_CC_SEED)\n\n\ndef FuseGMockGTestAllCc(gmock_root, output_dir):\n  \"\"\"Scans folder gmock_root to generate gmock-gtest-all.cc in output_dir.\"\"\"\n\n  output_file = file(os.path.join(output_dir, GMOCK_GTEST_ALL_CC_OUTPUT), 'w')\n  # First, fuse gtest-all.cc into gmock-gtest-all.cc.\n  gtest.FuseGTestAllCcToFile(GetGTestRootDir(gmock_root), output_file)\n  # Next, append fused gmock-all.cc to gmock-gtest-all.cc.\n  FuseGMockAllCcToFile(gmock_root, output_file)\n  output_file.close()\n\n\ndef FuseGMock(gmock_root, output_dir):\n  \"\"\"Fuses gtest.h, gmock.h, and gmock-gtest-all.h.\"\"\"\n\n  ValidateGMockRootDir(gmock_root)\n  ValidateOutputDir(output_dir)\n\n  gtest.FuseGTestH(GetGTestRootDir(gmock_root), output_dir)\n  FuseGMockH(gmock_root, output_dir)\n  FuseGMockGTestAllCc(gmock_root, output_dir)\n\n\ndef main():\n  argc = len(sys.argv)\n  if argc == 2:\n    # fuse_gmock_files.py OUTPUT_DIR\n    FuseGMock(DEFAULT_GMOCK_ROOT_DIR, sys.argv[1])\n  elif argc == 3:\n    # fuse_gmock_files.py GMOCK_ROOT_DIR OUTPUT_DIR\n    FuseGMock(sys.argv[1], sys.argv[2])\n  else:\n    print __doc__\n    sys.exit(1)\n\n\nif __name__ == '__main__':\n  main()\n"
  },
  {
    "path": "ext/gmock/scripts/generator/LICENSE",
    "content": "\n                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [2007] Neal Norwitz\n   Portions Copyright [2007] Google Inc.\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "ext/gmock/scripts/generator/README",
    "content": "\nThe Google Mock class generator is an application that is part of cppclean.\nFor more information about cppclean, see the README.cppclean file or\nvisit http://code.google.com/p/cppclean/\n\ncppclean requires Python 2.3.5 or later.  If you don't have Python installed\non your system, you will also need to install it.  You can download Python\nfrom:  http://www.python.org/download/releases/\n\nTo use the Google Mock class generator, you need to call it\non the command line passing the header file and class for which you want\nto generate a Google Mock class.\n\nMake sure to install the scripts somewhere in your path.  Then you can\nrun the program.\n\n  gmock_gen.py header-file.h [ClassName]...\n\nIf no ClassNames are specified, all classes in the file are emitted.\n\nTo change the indentation from the default of 2, set INDENT in\nthe environment.  For example to use an indent of 4 spaces:\n\nINDENT=4 gmock_gen.py header-file.h ClassName\n\nThis version was made from SVN revision 281 in the cppclean repository.\n\nKnown Limitations\n-----------------\nNot all code will be generated properly.  For example, when mocking templated\nclasses, the template information is lost.  You will need to add the template\ninformation manually.\n\nNot all permutations of using multiple pointers/references will be rendered\nproperly.  These will also have to be fixed manually.\n"
  },
  {
    "path": "ext/gmock/scripts/generator/README.cppclean",
    "content": "Goal:\n-----\n  CppClean attempts to find problems in C++ source that slow development\n  in large code bases, for example various forms of unused code.\n  Unused code can be unused functions, methods, data members, types, etc\n  to unnecessary #include directives.  Unnecessary #includes can cause\n  considerable extra compiles increasing the edit-compile-run cycle.\n\n  The project home page is:   http://code.google.com/p/cppclean/\n\n\nFeatures:\n---------\n * Find and print C++ language constructs: classes, methods, functions, etc.\n * Find classes with virtual methods, no virtual destructor, and no bases\n * Find global/static data that are potential problems when using threads\n * Unnecessary forward class declarations\n * Unnecessary function declarations\n * Undeclared function definitions\n * (planned) Find unnecessary header files #included\n   - No direct reference to anything in the header\n   - Header is unnecessary if classes were forward declared instead\n * (planned) Source files that reference headers not directly #included,\n   ie, files that rely on a transitive #include from another header\n * (planned) Unused members (private, protected, & public) methods and data\n * (planned) Store AST in a SQL database so relationships can be queried\n\nAST is Abstract Syntax Tree, a representation of parsed source code.\nhttp://en.wikipedia.org/wiki/Abstract_syntax_tree\n\n\nSystem Requirements:\n--------------------\n * Python 2.4 or later (2.3 probably works too)\n * Works on Windows (untested), Mac OS X, and Unix\n\n\nHow to Run:\n-----------\n  For all examples, it is assumed that cppclean resides in a directory called\n  /cppclean.\n\n  To print warnings for classes with virtual methods, no virtual destructor and\n  no base classes:\n\n      /cppclean/run.sh nonvirtual_dtors.py file1.h file2.h file3.cc ...\n\n  To print all the functions defined in header file(s):\n\n      /cppclean/run.sh functions.py file1.h file2.h ...\n\n  All the commands take multiple files on the command line.  Other programs\n  include: find_warnings, headers, methods, and types.  Some other programs\n  are available, but used primarily for debugging.\n\n  run.sh is a simple wrapper that sets PYTHONPATH to /cppclean and then\n  runs the program in /cppclean/cpp/PROGRAM.py.  There is currently\n  no equivalent for Windows.  Contributions for a run.bat file\n  would be greatly appreciated.\n\n\nHow to Configure:\n-----------------\n  You can add a siteheaders.py file in /cppclean/cpp to configure where\n  to look for other headers (typically -I options passed to a compiler).\n  Currently two values are supported:  _TRANSITIVE and GetIncludeDirs.\n  _TRANSITIVE should be set to a boolean value (True or False) indicating\n  whether to transitively process all header files.  The default is False.\n\n  GetIncludeDirs is a function that takes a single argument and returns\n  a sequence of directories to include.  This can be a generator or\n  return a static list.\n\n      def GetIncludeDirs(filename):\n          return ['/some/path/with/other/headers']\n\n      # Here is a more complicated example.\n      def GetIncludeDirs(filename):\n          yield '/path1'\n          yield os.path.join('/path2', os.path.dirname(filename))\n          yield '/path3'\n\n\nHow to Test:\n------------\n  For all examples, it is assumed that cppclean resides in a directory called\n  /cppclean.  The tests require\n\n  cd /cppclean\n  make test\n  # To generate expected results after a change:\n  make expected\n\n\nCurrent Status:\n---------------\n  The parser works pretty well for header files, parsing about 99% of Google's\n  header files.  Anything which inspects structure of C++ source files should\n  work reasonably well.  Function bodies are not transformed to an AST,\n  but left as tokens.  Much work is still needed on finding unused header files\n  and storing an AST in a database.\n\n\nNon-goals:\n----------\n * Parsing all valid C++ source\n * Handling invalid C++ source gracefully\n * Compiling to machine code (or anything beyond an AST)\n\n\nContact:\n--------\n  If you used cppclean, I would love to hear about your experiences\n  cppclean@googlegroups.com.  Even if you don't use cppclean, I'd like to\n  hear from you.  :-)  (You can contact me directly at:  nnorwitz@gmail.com)\n"
  },
  {
    "path": "ext/gmock/scripts/generator/cpp/__init__.py",
    "content": ""
  },
  {
    "path": "ext/gmock/scripts/generator/cpp/ast.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2007 Neal Norwitz\n# Portions Copyright 2007 Google Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Generate an Abstract Syntax Tree (AST) for C++.\"\"\"\n\n__author__ = 'nnorwitz@google.com (Neal Norwitz)'\n\n\n# TODO:\n#  * Tokens should never be exported, need to convert to Nodes\n#    (return types, parameters, etc.)\n#  * Handle static class data for templatized classes\n#  * Handle casts (both C++ and C-style)\n#  * Handle conditions and loops (if/else, switch, for, while/do)\n#\n# TODO much, much later:\n#  * Handle #define\n#  * exceptions\n\n\ntry:\n    # Python 3.x\n    import builtins\nexcept ImportError:\n    # Python 2.x\n    import __builtin__ as builtins\n\nimport sys\nimport traceback\n\nfrom cpp import keywords\nfrom cpp import tokenize\nfrom cpp import utils\n\n\nif not hasattr(builtins, 'reversed'):\n    # Support Python 2.3 and earlier.\n    def reversed(seq):\n        for i in range(len(seq)-1, -1, -1):\n            yield seq[i]\n\nif not hasattr(builtins, 'next'):\n    # Support Python 2.5 and earlier.\n    def next(obj):\n        return obj.next()\n\n\nVISIBILITY_PUBLIC, VISIBILITY_PROTECTED, VISIBILITY_PRIVATE = range(3)\n\nFUNCTION_NONE = 0x00\nFUNCTION_CONST = 0x01\nFUNCTION_VIRTUAL = 0x02\nFUNCTION_PURE_VIRTUAL = 0x04\nFUNCTION_CTOR = 0x08\nFUNCTION_DTOR = 0x10\nFUNCTION_ATTRIBUTE = 0x20\nFUNCTION_UNKNOWN_ANNOTATION = 0x40\nFUNCTION_THROW = 0x80\n\n\"\"\"\nThese are currently unused.  Should really handle these properly at some point.\n\nTYPE_MODIFIER_INLINE   = 0x010000\nTYPE_MODIFIER_EXTERN   = 0x020000\nTYPE_MODIFIER_STATIC   = 0x040000\nTYPE_MODIFIER_CONST    = 0x080000\nTYPE_MODIFIER_REGISTER = 0x100000\nTYPE_MODIFIER_VOLATILE = 0x200000\nTYPE_MODIFIER_MUTABLE  = 0x400000\n\nTYPE_MODIFIER_MAP = {\n    'inline': TYPE_MODIFIER_INLINE,\n    'extern': TYPE_MODIFIER_EXTERN,\n    'static': TYPE_MODIFIER_STATIC,\n    'const': TYPE_MODIFIER_CONST,\n    'register': TYPE_MODIFIER_REGISTER,\n    'volatile': TYPE_MODIFIER_VOLATILE,\n    'mutable': TYPE_MODIFIER_MUTABLE,\n    }\n\"\"\"\n\n_INTERNAL_TOKEN = 'internal'\n_NAMESPACE_POP = 'ns-pop'\n\n\n# TODO(nnorwitz): use this as a singleton for templated_types, etc\n# where we don't want to create a new empty dict each time.  It is also const.\nclass _NullDict(object):\n    __contains__ = lambda self: False\n    keys = values = items = iterkeys = itervalues = iteritems = lambda self: ()\n\n\n# TODO(nnorwitz): move AST nodes into a separate module.\nclass Node(object):\n    \"\"\"Base AST node.\"\"\"\n\n    def __init__(self, start, end):\n        self.start = start\n        self.end = end\n\n    def IsDeclaration(self):\n        \"\"\"Returns bool if this node is a declaration.\"\"\"\n        return False\n\n    def IsDefinition(self):\n        \"\"\"Returns bool if this node is a definition.\"\"\"\n        return False\n\n    def IsExportable(self):\n        \"\"\"Returns bool if this node exportable from a header file.\"\"\"\n        return False\n\n    def Requires(self, node):\n        \"\"\"Does this AST node require the definition of the node passed in?\"\"\"\n        return False\n\n    def XXX__str__(self):\n        return self._StringHelper(self.__class__.__name__, '')\n\n    def _StringHelper(self, name, suffix):\n        if not utils.DEBUG:\n            return '%s(%s)' % (name, suffix)\n        return '%s(%d, %d, %s)' % (name, self.start, self.end, suffix)\n\n    def __repr__(self):\n        return str(self)\n\n\nclass Define(Node):\n    def __init__(self, start, end, name, definition):\n        Node.__init__(self, start, end)\n        self.name = name\n        self.definition = definition\n\n    def __str__(self):\n        value = '%s %s' % (self.name, self.definition)\n        return self._StringHelper(self.__class__.__name__, value)\n\n\nclass Include(Node):\n    def __init__(self, start, end, filename, system):\n        Node.__init__(self, start, end)\n        self.filename = filename\n        self.system = system\n\n    def __str__(self):\n        fmt = '\"%s\"'\n        if self.system:\n            fmt = '<%s>'\n        return self._StringHelper(self.__class__.__name__, fmt % self.filename)\n\n\nclass Goto(Node):\n    def __init__(self, start, end, label):\n        Node.__init__(self, start, end)\n        self.label = label\n\n    def __str__(self):\n        return self._StringHelper(self.__class__.__name__, str(self.label))\n\n\nclass Expr(Node):\n    def __init__(self, start, end, expr):\n        Node.__init__(self, start, end)\n        self.expr = expr\n\n    def Requires(self, node):\n        # TODO(nnorwitz): impl.\n        return False\n\n    def __str__(self):\n        return self._StringHelper(self.__class__.__name__, str(self.expr))\n\n\nclass Return(Expr):\n    pass\n\n\nclass Delete(Expr):\n    pass\n\n\nclass Friend(Expr):\n    def __init__(self, start, end, expr, namespace):\n        Expr.__init__(self, start, end, expr)\n        self.namespace = namespace[:]\n\n\nclass Using(Node):\n    def __init__(self, start, end, names):\n        Node.__init__(self, start, end)\n        self.names = names\n\n    def __str__(self):\n        return self._StringHelper(self.__class__.__name__, str(self.names))\n\n\nclass Parameter(Node):\n    def __init__(self, start, end, name, parameter_type, default):\n        Node.__init__(self, start, end)\n        self.name = name\n        self.type = parameter_type\n        self.default = default\n\n    def Requires(self, node):\n        # TODO(nnorwitz): handle namespaces, etc.\n        return self.type.name == node.name\n\n    def __str__(self):\n        name = str(self.type)\n        suffix = '%s %s' % (name, self.name)\n        if self.default:\n            suffix += ' = ' + ''.join([d.name for d in self.default])\n        return self._StringHelper(self.__class__.__name__, suffix)\n\n\nclass _GenericDeclaration(Node):\n    def __init__(self, start, end, name, namespace):\n        Node.__init__(self, start, end)\n        self.name = name\n        self.namespace = namespace[:]\n\n    def FullName(self):\n        prefix = ''\n        if self.namespace and self.namespace[-1]:\n            prefix = '::'.join(self.namespace) + '::'\n        return prefix + self.name\n\n    def _TypeStringHelper(self, suffix):\n        if self.namespace:\n            names = [n or '<anonymous>' for n in self.namespace]\n            suffix += ' in ' + '::'.join(names)\n        return self._StringHelper(self.__class__.__name__, suffix)\n\n\n# TODO(nnorwitz): merge with Parameter in some way?\nclass VariableDeclaration(_GenericDeclaration):\n    def __init__(self, start, end, name, var_type, initial_value, namespace):\n        _GenericDeclaration.__init__(self, start, end, name, namespace)\n        self.type = var_type\n        self.initial_value = initial_value\n\n    def Requires(self, node):\n        # TODO(nnorwitz): handle namespaces, etc.\n        return self.type.name == node.name\n\n    def ToString(self):\n        \"\"\"Return a string that tries to reconstitute the variable decl.\"\"\"\n        suffix = '%s %s' % (self.type, self.name)\n        if self.initial_value:\n            suffix += ' = ' + self.initial_value\n        return suffix\n\n    def __str__(self):\n        return self._StringHelper(self.__class__.__name__, self.ToString())\n\n\nclass Typedef(_GenericDeclaration):\n    def __init__(self, start, end, name, alias, namespace):\n        _GenericDeclaration.__init__(self, start, end, name, namespace)\n        self.alias = alias\n\n    def IsDefinition(self):\n        return True\n\n    def IsExportable(self):\n        return True\n\n    def Requires(self, node):\n        # TODO(nnorwitz): handle namespaces, etc.\n        name = node.name\n        for token in self.alias:\n            if token is not None and name == token.name:\n                return True\n        return False\n\n    def __str__(self):\n        suffix = '%s, %s' % (self.name, self.alias)\n        return self._TypeStringHelper(suffix)\n\n\nclass _NestedType(_GenericDeclaration):\n    def __init__(self, start, end, name, fields, namespace):\n        _GenericDeclaration.__init__(self, start, end, name, namespace)\n        self.fields = fields\n\n    def IsDefinition(self):\n        return True\n\n    def IsExportable(self):\n        return True\n\n    def __str__(self):\n        suffix = '%s, {%s}' % (self.name, self.fields)\n        return self._TypeStringHelper(suffix)\n\n\nclass Union(_NestedType):\n    pass\n\n\nclass Enum(_NestedType):\n    pass\n\n\nclass Class(_GenericDeclaration):\n    def __init__(self, start, end, name, bases, templated_types, body, namespace):\n        _GenericDeclaration.__init__(self, start, end, name, namespace)\n        self.bases = bases\n        self.body = body\n        self.templated_types = templated_types\n\n    def IsDeclaration(self):\n        return self.bases is None and self.body is None\n\n    def IsDefinition(self):\n        return not self.IsDeclaration()\n\n    def IsExportable(self):\n        return not self.IsDeclaration()\n\n    def Requires(self, node):\n        # TODO(nnorwitz): handle namespaces, etc.\n        if self.bases:\n            for token_list in self.bases:\n                # TODO(nnorwitz): bases are tokens, do name comparision.\n                for token in token_list:\n                    if token.name == node.name:\n                        return True\n        # TODO(nnorwitz): search in body too.\n        return False\n\n    def __str__(self):\n        name = self.name\n        if self.templated_types:\n            name += '<%s>' % self.templated_types\n        suffix = '%s, %s, %s' % (name, self.bases, self.body)\n        return self._TypeStringHelper(suffix)\n\n\nclass Struct(Class):\n    pass\n\n\nclass Function(_GenericDeclaration):\n    def __init__(self, start, end, name, return_type, parameters,\n                 modifiers, templated_types, body, namespace):\n        _GenericDeclaration.__init__(self, start, end, name, namespace)\n        converter = TypeConverter(namespace)\n        self.return_type = converter.CreateReturnType(return_type)\n        self.parameters = converter.ToParameters(parameters)\n        self.modifiers = modifiers\n        self.body = body\n        self.templated_types = templated_types\n\n    def IsDeclaration(self):\n        return self.body is None\n\n    def IsDefinition(self):\n        return self.body is not None\n\n    def IsExportable(self):\n        if self.return_type and 'static' in self.return_type.modifiers:\n            return False\n        return None not in self.namespace\n\n    def Requires(self, node):\n        if self.parameters:\n            # TODO(nnorwitz): parameters are tokens, do name comparision.\n            for p in self.parameters:\n                if p.name == node.name:\n                    return True\n        # TODO(nnorwitz): search in body too.\n        return False\n\n    def __str__(self):\n        # TODO(nnorwitz): add templated_types.\n        suffix = ('%s %s(%s), 0x%02x, %s' %\n                  (self.return_type, self.name, self.parameters,\n                   self.modifiers, self.body))\n        return self._TypeStringHelper(suffix)\n\n\nclass Method(Function):\n    def __init__(self, start, end, name, in_class, return_type, parameters,\n                 modifiers, templated_types, body, namespace):\n        Function.__init__(self, start, end, name, return_type, parameters,\n                          modifiers, templated_types, body, namespace)\n        # TODO(nnorwitz): in_class could also be a namespace which can\n        # mess up finding functions properly.\n        self.in_class = in_class\n\n\nclass Type(_GenericDeclaration):\n    \"\"\"Type used for any variable (eg class, primitive, struct, etc).\"\"\"\n\n    def __init__(self, start, end, name, templated_types, modifiers,\n                 reference, pointer, array):\n        \"\"\"\n        Args:\n          name: str name of main type\n          templated_types: [Class (Type?)] template type info between <>\n          modifiers: [str] type modifiers (keywords) eg, const, mutable, etc.\n          reference, pointer, array: bools\n        \"\"\"\n        _GenericDeclaration.__init__(self, start, end, name, [])\n        self.templated_types = templated_types\n        if not name and modifiers:\n            self.name = modifiers.pop()\n        self.modifiers = modifiers\n        self.reference = reference\n        self.pointer = pointer\n        self.array = array\n\n    def __str__(self):\n        prefix = ''\n        if self.modifiers:\n            prefix = ' '.join(self.modifiers) + ' '\n        name = str(self.name)\n        if self.templated_types:\n            name += '<%s>' % self.templated_types\n        suffix = prefix + name\n        if self.reference:\n            suffix += '&'\n        if self.pointer:\n            suffix += '*'\n        if self.array:\n            suffix += '[]'\n        return self._TypeStringHelper(suffix)\n\n    # By definition, Is* are always False.  A Type can only exist in\n    # some sort of variable declaration, parameter, or return value.\n    def IsDeclaration(self):\n        return False\n\n    def IsDefinition(self):\n        return False\n\n    def IsExportable(self):\n        return False\n\n\nclass TypeConverter(object):\n\n    def __init__(self, namespace_stack):\n        self.namespace_stack = namespace_stack\n\n    def _GetTemplateEnd(self, tokens, start):\n        count = 1\n        end = start\n        while 1:\n            token = tokens[end]\n            end += 1\n            if token.name == '<':\n                count += 1\n            elif token.name == '>':\n                count -= 1\n                if count == 0:\n                    break\n        return tokens[start:end-1], end\n\n    def ToType(self, tokens):\n        \"\"\"Convert [Token,...] to [Class(...), ] useful for base classes.\n        For example, code like class Foo : public Bar<x, y> { ... };\n        the \"Bar<x, y>\" portion gets converted to an AST.\n\n        Returns:\n          [Class(...), ...]\n        \"\"\"\n        result = []\n        name_tokens = []\n        reference = pointer = array = False\n\n        def AddType(templated_types):\n            # Partition tokens into name and modifier tokens.\n            names = []\n            modifiers = []\n            for t in name_tokens:\n                if keywords.IsKeyword(t.name):\n                    modifiers.append(t.name)\n                else:\n                    names.append(t.name)\n            name = ''.join(names)\n            result.append(Type(name_tokens[0].start, name_tokens[-1].end,\n                               name, templated_types, modifiers,\n                               reference, pointer, array))\n            del name_tokens[:]\n\n        i = 0\n        end = len(tokens)\n        while i < end:\n            token = tokens[i]\n            if token.name == '<':\n                new_tokens, new_end = self._GetTemplateEnd(tokens, i+1)\n                AddType(self.ToType(new_tokens))\n                # If there is a comma after the template, we need to consume\n                # that here otherwise it becomes part of the name.\n                i = new_end\n                reference = pointer = array = False\n            elif token.name == ',':\n                AddType([])\n                reference = pointer = array = False\n            elif token.name == '*':\n                pointer = True\n            elif token.name == '&':\n                reference = True\n            elif token.name == '[':\n               pointer = True\n            elif token.name == ']':\n                pass\n            else:\n                name_tokens.append(token)\n            i += 1\n\n        if name_tokens:\n            # No '<' in the tokens, just a simple name and no template.\n            AddType([])\n        return result\n\n    def DeclarationToParts(self, parts, needs_name_removed):\n        name = None\n        default = []\n        if needs_name_removed:\n            # Handle default (initial) values properly.\n            for i, t in enumerate(parts):\n                if t.name == '=':\n                    default = parts[i+1:]\n                    name = parts[i-1].name\n                    if name == ']' and parts[i-2].name == '[':\n                        name = parts[i-3].name\n                        i -= 1\n                    parts = parts[:i-1]\n                    break\n            else:\n                if parts[-1].token_type == tokenize.NAME:\n                    name = parts.pop().name\n                else:\n                    # TODO(nnorwitz): this is a hack that happens for code like\n                    # Register(Foo<T>); where it thinks this is a function call\n                    # but it's actually a declaration.\n                    name = '???'\n        modifiers = []\n        type_name = []\n        other_tokens = []\n        templated_types = []\n        i = 0\n        end = len(parts)\n        while i < end:\n            p = parts[i]\n            if keywords.IsKeyword(p.name):\n                modifiers.append(p.name)\n            elif p.name == '<':\n                templated_tokens, new_end = self._GetTemplateEnd(parts, i+1)\n                templated_types = self.ToType(templated_tokens)\n                i = new_end - 1\n                # Don't add a spurious :: to data members being initialized.\n                next_index = i + 1\n                if next_index < end and parts[next_index].name == '::':\n                    i += 1\n            elif p.name in ('[', ']', '='):\n                # These are handled elsewhere.\n                other_tokens.append(p)\n            elif p.name not in ('*', '&', '>'):\n                # Ensure that names have a space between them.\n                if (type_name and type_name[-1].token_type == tokenize.NAME and\n                    p.token_type == tokenize.NAME):\n                    type_name.append(tokenize.Token(tokenize.SYNTAX, ' ', 0, 0))\n                type_name.append(p)\n            else:\n                other_tokens.append(p)\n            i += 1\n        type_name = ''.join([t.name for t in type_name])\n        return name, type_name, templated_types, modifiers, default, other_tokens\n\n    def ToParameters(self, tokens):\n        if not tokens:\n            return []\n\n        result = []\n        name = type_name = ''\n        type_modifiers = []\n        pointer = reference = array = False\n        first_token = None\n        default = []\n\n        def AddParameter():\n            if default:\n                del default[0]  # Remove flag.\n            end = type_modifiers[-1].end\n            parts = self.DeclarationToParts(type_modifiers, True)\n            (name, type_name, templated_types, modifiers,\n             unused_default, unused_other_tokens) = parts\n            parameter_type = Type(first_token.start, first_token.end,\n                                  type_name, templated_types, modifiers,\n                                  reference, pointer, array)\n            p = Parameter(first_token.start, end, name,\n                          parameter_type, default)\n            result.append(p)\n\n        template_count = 0\n        for s in tokens:\n            if not first_token:\n                first_token = s\n            if s.name == '<':\n                template_count += 1\n            elif s.name == '>':\n                template_count -= 1\n            if template_count > 0:\n                type_modifiers.append(s)\n                continue\n\n            if s.name == ',':\n                AddParameter()\n                name = type_name = ''\n                type_modifiers = []\n                pointer = reference = array = False\n                first_token = None\n                default = []\n            elif s.name == '*':\n                pointer = True\n            elif s.name == '&':\n                reference = True\n            elif s.name == '[':\n                array = True\n            elif s.name == ']':\n                pass  # Just don't add to type_modifiers.\n            elif s.name == '=':\n                # Got a default value.  Add any value (None) as a flag.\n                default.append(None)\n            elif default:\n                default.append(s)\n            else:\n                type_modifiers.append(s)\n        AddParameter()\n        return result\n\n    def CreateReturnType(self, return_type_seq):\n        if not return_type_seq:\n            return None\n        start = return_type_seq[0].start\n        end = return_type_seq[-1].end\n        _, name, templated_types, modifiers, default, other_tokens = \\\n           self.DeclarationToParts(return_type_seq, False)\n        names = [n.name for n in other_tokens]\n        reference = '&' in names\n        pointer = '*' in names\n        array = '[' in names\n        return Type(start, end, name, templated_types, modifiers,\n                    reference, pointer, array)\n\n    def GetTemplateIndices(self, names):\n        # names is a list of strings.\n        start = names.index('<')\n        end = len(names) - 1\n        while end > 0:\n            if names[end] == '>':\n                break\n            end -= 1\n        return start, end+1\n\nclass AstBuilder(object):\n    def __init__(self, token_stream, filename, in_class='', visibility=None,\n                 namespace_stack=[]):\n        self.tokens = token_stream\n        self.filename = filename\n        # TODO(nnorwitz): use a better data structure (deque) for the queue.\n        # Switching directions of the \"queue\" improved perf by about 25%.\n        # Using a deque should be even better since we access from both sides.\n        self.token_queue = []\n        self.namespace_stack = namespace_stack[:]\n        self.in_class = in_class\n        if in_class is None:\n            self.in_class_name_only = None\n        else:\n            self.in_class_name_only = in_class.split('::')[-1]\n        self.visibility = visibility\n        self.in_function = False\n        self.current_token = None\n        # Keep the state whether we are currently handling a typedef or not.\n        self._handling_typedef = False\n\n        self.converter = TypeConverter(self.namespace_stack)\n\n    def HandleError(self, msg, token):\n        printable_queue = list(reversed(self.token_queue[-20:]))\n        sys.stderr.write('Got %s in %s @ %s %s\\n' %\n                         (msg, self.filename, token, printable_queue))\n\n    def Generate(self):\n        while 1:\n            token = self._GetNextToken()\n            if not token:\n                break\n\n            # Get the next token.\n            self.current_token = token\n\n            # Dispatch on the next token type.\n            if token.token_type == _INTERNAL_TOKEN:\n                if token.name == _NAMESPACE_POP:\n                    self.namespace_stack.pop()\n                continue\n\n            try:\n                result = self._GenerateOne(token)\n                if result is not None:\n                    yield result\n            except:\n                self.HandleError('exception', token)\n                raise\n\n    def _CreateVariable(self, pos_token, name, type_name, type_modifiers,\n                        ref_pointer_name_seq, templated_types, value=None):\n        reference = '&' in ref_pointer_name_seq\n        pointer = '*' in ref_pointer_name_seq\n        array = '[' in ref_pointer_name_seq\n        var_type = Type(pos_token.start, pos_token.end, type_name,\n                        templated_types, type_modifiers,\n                        reference, pointer, array)\n        return VariableDeclaration(pos_token.start, pos_token.end,\n                                   name, var_type, value, self.namespace_stack)\n\n    def _GenerateOne(self, token):\n        if token.token_type == tokenize.NAME:\n            if (keywords.IsKeyword(token.name) and\n                not keywords.IsBuiltinType(token.name)):\n                method = getattr(self, 'handle_' + token.name)\n                return method()\n            elif token.name == self.in_class_name_only:\n                # The token name is the same as the class, must be a ctor if\n                # there is a paren.  Otherwise, it's the return type.\n                # Peek ahead to get the next token to figure out which.\n                next = self._GetNextToken()\n                self._AddBackToken(next)\n                if next.token_type == tokenize.SYNTAX and next.name == '(':\n                    return self._GetMethod([token], FUNCTION_CTOR, None, True)\n                # Fall through--handle like any other method.\n\n            # Handle data or function declaration/definition.\n            syntax = tokenize.SYNTAX\n            temp_tokens, last_token = \\\n                self._GetVarTokensUpTo(syntax, '(', ';', '{', '[')\n            temp_tokens.insert(0, token)\n            if last_token.name == '(':\n                # If there is an assignment before the paren,\n                # this is an expression, not a method.\n                expr = bool([e for e in temp_tokens if e.name == '='])\n                if expr:\n                    new_temp = self._GetTokensUpTo(tokenize.SYNTAX, ';')\n                    temp_tokens.append(last_token)\n                    temp_tokens.extend(new_temp)\n                    last_token = tokenize.Token(tokenize.SYNTAX, ';', 0, 0)\n\n            if last_token.name == '[':\n                # Handle array, this isn't a method, unless it's an operator.\n                # TODO(nnorwitz): keep the size somewhere.\n                # unused_size = self._GetTokensUpTo(tokenize.SYNTAX, ']')\n                temp_tokens.append(last_token)\n                if temp_tokens[-2].name == 'operator':\n                    temp_tokens.append(self._GetNextToken())\n                else:\n                    temp_tokens2, last_token = \\\n                        self._GetVarTokensUpTo(tokenize.SYNTAX, ';')\n                    temp_tokens.extend(temp_tokens2)\n\n            if last_token.name == ';':\n                # Handle data, this isn't a method.\n                parts = self.converter.DeclarationToParts(temp_tokens, True)\n                (name, type_name, templated_types, modifiers, default,\n                 unused_other_tokens) = parts\n\n                t0 = temp_tokens[0]\n                names = [t.name for t in temp_tokens]\n                if templated_types:\n                    start, end = self.converter.GetTemplateIndices(names)\n                    names = names[:start] + names[end:]\n                default = ''.join([t.name for t in default])\n                return self._CreateVariable(t0, name, type_name, modifiers,\n                                            names, templated_types, default)\n            if last_token.name == '{':\n                self._AddBackTokens(temp_tokens[1:])\n                self._AddBackToken(last_token)\n                method_name = temp_tokens[0].name\n                method = getattr(self, 'handle_' + method_name, None)\n                if not method:\n                    # Must be declaring a variable.\n                    # TODO(nnorwitz): handle the declaration.\n                    return None\n                return method()\n            return self._GetMethod(temp_tokens, 0, None, False)\n        elif token.token_type == tokenize.SYNTAX:\n            if token.name == '~' and self.in_class:\n                # Must be a dtor (probably not in method body).\n                token = self._GetNextToken()\n                # self.in_class can contain A::Name, but the dtor will only\n                # be Name.  Make sure to compare against the right value.\n                if (token.token_type == tokenize.NAME and\n                    token.name == self.in_class_name_only):\n                    return self._GetMethod([token], FUNCTION_DTOR, None, True)\n            # TODO(nnorwitz): handle a lot more syntax.\n        elif token.token_type == tokenize.PREPROCESSOR:\n            # TODO(nnorwitz): handle more preprocessor directives.\n            # token starts with a #, so remove it and strip whitespace.\n            name = token.name[1:].lstrip()\n            if name.startswith('include'):\n                # Remove \"include\".\n                name = name[7:].strip()\n                assert name\n                # Handle #include \\<newline> \"header-on-second-line.h\".\n                if name.startswith('\\\\'):\n                    name = name[1:].strip()\n                assert name[0] in '<\"', token\n                assert name[-1] in '>\"', token\n                system = name[0] == '<'\n                filename = name[1:-1]\n                return Include(token.start, token.end, filename, system)\n            if name.startswith('define'):\n                # Remove \"define\".\n                name = name[6:].strip()\n                assert name\n                value = ''\n                for i, c in enumerate(name):\n                    if c.isspace():\n                        value = name[i:].lstrip()\n                        name = name[:i]\n                        break\n                return Define(token.start, token.end, name, value)\n            if name.startswith('if') and name[2:3].isspace():\n                condition = name[3:].strip()\n                if condition.startswith('0') or condition.startswith('(0)'):\n                    self._SkipIf0Blocks()\n        return None\n\n    def _GetTokensUpTo(self, expected_token_type, expected_token):\n        return self._GetVarTokensUpTo(expected_token_type, expected_token)[0]\n\n    def _GetVarTokensUpTo(self, expected_token_type, *expected_tokens):\n        last_token = self._GetNextToken()\n        tokens = []\n        while (last_token.token_type != expected_token_type or\n               last_token.name not in expected_tokens):\n            tokens.append(last_token)\n            last_token = self._GetNextToken()\n        return tokens, last_token\n\n    # TODO(nnorwitz): remove _IgnoreUpTo() it shouldn't be necesary.\n    def _IgnoreUpTo(self, token_type, token):\n        unused_tokens = self._GetTokensUpTo(token_type, token)\n\n    def _SkipIf0Blocks(self):\n        count = 1\n        while 1:\n            token = self._GetNextToken()\n            if token.token_type != tokenize.PREPROCESSOR:\n                continue\n\n            name = token.name[1:].lstrip()\n            if name.startswith('endif'):\n                count -= 1\n                if count == 0:\n                    break\n            elif name.startswith('if'):\n                count += 1\n\n    def _GetMatchingChar(self, open_paren, close_paren, GetNextToken=None):\n        if GetNextToken is None:\n            GetNextToken = self._GetNextToken\n        # Assumes the current token is open_paren and we will consume\n        # and return up to the close_paren.\n        count = 1\n        token = GetNextToken()\n        while 1:\n            if token.token_type == tokenize.SYNTAX:\n                if token.name == open_paren:\n                    count += 1\n                elif token.name == close_paren:\n                    count -= 1\n                    if count == 0:\n                        break\n            yield token\n            token = GetNextToken()\n        yield token\n\n    def _GetParameters(self):\n        return self._GetMatchingChar('(', ')')\n\n    def GetScope(self):\n        return self._GetMatchingChar('{', '}')\n\n    def _GetNextToken(self):\n        if self.token_queue:\n            return self.token_queue.pop()\n        return next(self.tokens)\n\n    def _AddBackToken(self, token):\n        if token.whence == tokenize.WHENCE_STREAM:\n            token.whence = tokenize.WHENCE_QUEUE\n            self.token_queue.insert(0, token)\n        else:\n            assert token.whence == tokenize.WHENCE_QUEUE, token\n            self.token_queue.append(token)\n\n    def _AddBackTokens(self, tokens):\n        if tokens:\n            if tokens[-1].whence == tokenize.WHENCE_STREAM:\n                for token in tokens:\n                    token.whence = tokenize.WHENCE_QUEUE\n                self.token_queue[:0] = reversed(tokens)\n            else:\n                assert tokens[-1].whence == tokenize.WHENCE_QUEUE, tokens\n                self.token_queue.extend(reversed(tokens))\n\n    def GetName(self, seq=None):\n        \"\"\"Returns ([tokens], next_token_info).\"\"\"\n        GetNextToken = self._GetNextToken\n        if seq is not None:\n            it = iter(seq)\n            GetNextToken = lambda: next(it)\n        next_token = GetNextToken()\n        tokens = []\n        last_token_was_name = False\n        while (next_token.token_type == tokenize.NAME or\n               (next_token.token_type == tokenize.SYNTAX and\n                next_token.name in ('::', '<'))):\n            # Two NAMEs in a row means the identifier should terminate.\n            # It's probably some sort of variable declaration.\n            if last_token_was_name and next_token.token_type == tokenize.NAME:\n                break\n            last_token_was_name = next_token.token_type == tokenize.NAME\n            tokens.append(next_token)\n            # Handle templated names.\n            if next_token.name == '<':\n                tokens.extend(self._GetMatchingChar('<', '>', GetNextToken))\n                last_token_was_name = True\n            next_token = GetNextToken()\n        return tokens, next_token\n\n    def GetMethod(self, modifiers, templated_types):\n        return_type_and_name = self._GetTokensUpTo(tokenize.SYNTAX, '(')\n        assert len(return_type_and_name) >= 1\n        return self._GetMethod(return_type_and_name, modifiers, templated_types,\n                               False)\n\n    def _GetMethod(self, return_type_and_name, modifiers, templated_types,\n                   get_paren):\n        template_portion = None\n        if get_paren:\n            token = self._GetNextToken()\n            assert token.token_type == tokenize.SYNTAX, token\n            if token.name == '<':\n                # Handle templatized dtors.\n                template_portion = [token]\n                template_portion.extend(self._GetMatchingChar('<', '>'))\n                token = self._GetNextToken()\n            assert token.token_type == tokenize.SYNTAX, token\n            assert token.name == '(', token\n\n        name = return_type_and_name.pop()\n        # Handle templatized ctors.\n        if name.name == '>':\n            index = 1\n            while return_type_and_name[index].name != '<':\n                index += 1\n            template_portion = return_type_and_name[index:] + [name]\n            del return_type_and_name[index:]\n            name = return_type_and_name.pop()\n        elif name.name == ']':\n            rt = return_type_and_name\n            assert rt[-1].name == '[', return_type_and_name\n            assert rt[-2].name == 'operator', return_type_and_name\n            name_seq = return_type_and_name[-2:]\n            del return_type_and_name[-2:]\n            name = tokenize.Token(tokenize.NAME, 'operator[]',\n                                  name_seq[0].start, name.end)\n            # Get the open paren so _GetParameters() below works.\n            unused_open_paren = self._GetNextToken()\n\n        # TODO(nnorwitz): store template_portion.\n        return_type = return_type_and_name\n        indices = name\n        if return_type:\n            indices = return_type[0]\n\n        # Force ctor for templatized ctors.\n        if name.name == self.in_class and not modifiers:\n            modifiers |= FUNCTION_CTOR\n        parameters = list(self._GetParameters())\n        del parameters[-1]              # Remove trailing ')'.\n\n        # Handling operator() is especially weird.\n        if name.name == 'operator' and not parameters:\n            token = self._GetNextToken()\n            assert token.name == '(', token\n            parameters = list(self._GetParameters())\n            del parameters[-1]          # Remove trailing ')'.\n\n        token = self._GetNextToken()\n        while token.token_type == tokenize.NAME:\n            modifier_token = token\n            token = self._GetNextToken()\n            if modifier_token.name == 'const':\n                modifiers |= FUNCTION_CONST\n            elif modifier_token.name == '__attribute__':\n                # TODO(nnorwitz): handle more __attribute__ details.\n                modifiers |= FUNCTION_ATTRIBUTE\n                assert token.name == '(', token\n                # Consume everything between the (parens).\n                unused_tokens = list(self._GetMatchingChar('(', ')'))\n                token = self._GetNextToken()\n            elif modifier_token.name == 'throw':\n                modifiers |= FUNCTION_THROW\n                assert token.name == '(', token\n                # Consume everything between the (parens).\n                unused_tokens = list(self._GetMatchingChar('(', ')'))\n                token = self._GetNextToken()\n            elif modifier_token.name == modifier_token.name.upper():\n                # HACK(nnorwitz):  assume that all upper-case names\n                # are some macro we aren't expanding.\n                modifiers |= FUNCTION_UNKNOWN_ANNOTATION\n            else:\n                self.HandleError('unexpected token', modifier_token)\n\n        assert token.token_type == tokenize.SYNTAX, token\n        # Handle ctor initializers.\n        if token.name == ':':\n            # TODO(nnorwitz): anything else to handle for initializer list?\n            while token.name != ';' and token.name != '{':\n                token = self._GetNextToken()\n\n        # Handle pointer to functions that are really data but look\n        # like method declarations.\n        if token.name == '(':\n            if parameters[0].name == '*':\n                # name contains the return type.\n                name = parameters.pop()\n                # parameters contains the name of the data.\n                modifiers = [p.name for p in parameters]\n                # Already at the ( to open the parameter list.\n                function_parameters = list(self._GetMatchingChar('(', ')'))\n                del function_parameters[-1]  # Remove trailing ')'.\n                # TODO(nnorwitz): store the function_parameters.\n                token = self._GetNextToken()\n                assert token.token_type == tokenize.SYNTAX, token\n                assert token.name == ';', token\n                return self._CreateVariable(indices, name.name, indices.name,\n                                            modifiers, '', None)\n            # At this point, we got something like:\n            #  return_type (type::*name_)(params);\n            # This is a data member called name_ that is a function pointer.\n            # With this code: void (sq_type::*field_)(string&);\n            # We get: name=void return_type=[] parameters=sq_type ... field_\n            # TODO(nnorwitz): is return_type always empty?\n            # TODO(nnorwitz): this isn't even close to being correct.\n            # Just put in something so we don't crash and can move on.\n            real_name = parameters[-1]\n            modifiers = [p.name for p in self._GetParameters()]\n            del modifiers[-1]           # Remove trailing ')'.\n            return self._CreateVariable(indices, real_name.name, indices.name,\n                                        modifiers, '', None)\n\n        if token.name == '{':\n            body = list(self.GetScope())\n            del body[-1]                # Remove trailing '}'.\n        else:\n            body = None\n            if token.name == '=':\n                token = self._GetNextToken()\n                assert token.token_type == tokenize.CONSTANT, token\n                assert token.name == '0', token\n                modifiers |= FUNCTION_PURE_VIRTUAL\n                token = self._GetNextToken()\n\n            if token.name == '[':\n                # TODO(nnorwitz): store tokens and improve parsing.\n                # template <typename T, size_t N> char (&ASH(T (&seq)[N]))[N];\n                tokens = list(self._GetMatchingChar('[', ']'))\n                token = self._GetNextToken()\n\n            assert token.name == ';', (token, return_type_and_name, parameters)\n\n        # Looks like we got a method, not a function.\n        if len(return_type) > 2 and return_type[-1].name == '::':\n            return_type, in_class = \\\n                         self._GetReturnTypeAndClassName(return_type)\n            return Method(indices.start, indices.end, name.name, in_class,\n                          return_type, parameters, modifiers, templated_types,\n                          body, self.namespace_stack)\n        return Function(indices.start, indices.end, name.name, return_type,\n                        parameters, modifiers, templated_types, body,\n                        self.namespace_stack)\n\n    def _GetReturnTypeAndClassName(self, token_seq):\n        # Splitting the return type from the class name in a method\n        # can be tricky.  For example, Return::Type::Is::Hard::To::Find().\n        # Where is the return type and where is the class name?\n        # The heuristic used is to pull the last name as the class name.\n        # This includes all the templated type info.\n        # TODO(nnorwitz): if there is only One name like in the\n        # example above, punt and assume the last bit is the class name.\n\n        # Ignore a :: prefix, if exists so we can find the first real name.\n        i = 0\n        if token_seq[0].name == '::':\n            i = 1\n        # Ignore a :: suffix, if exists.\n        end = len(token_seq) - 1\n        if token_seq[end-1].name == '::':\n            end -= 1\n\n        # Make a copy of the sequence so we can append a sentinel\n        # value. This is required for GetName will has to have some\n        # terminating condition beyond the last name.\n        seq_copy = token_seq[i:end]\n        seq_copy.append(tokenize.Token(tokenize.SYNTAX, '', 0, 0))\n        names = []\n        while i < end:\n            # Iterate through the sequence parsing out each name.\n            new_name, next = self.GetName(seq_copy[i:])\n            assert new_name, 'Got empty new_name, next=%s' % next\n            # We got a pointer or ref.  Add it to the name.\n            if next and next.token_type == tokenize.SYNTAX:\n                new_name.append(next)\n            names.append(new_name)\n            i += len(new_name)\n\n        # Now that we have the names, it's time to undo what we did.\n\n        # Remove the sentinel value.\n        names[-1].pop()\n        # Flatten the token sequence for the return type.\n        return_type = [e for seq in names[:-1] for e in seq]\n        # The class name is the last name.\n        class_name = names[-1]\n        return return_type, class_name\n\n    def handle_bool(self):\n        pass\n\n    def handle_char(self):\n        pass\n\n    def handle_int(self):\n        pass\n\n    def handle_long(self):\n        pass\n\n    def handle_short(self):\n        pass\n\n    def handle_double(self):\n        pass\n\n    def handle_float(self):\n        pass\n\n    def handle_void(self):\n        pass\n\n    def handle_wchar_t(self):\n        pass\n\n    def handle_unsigned(self):\n        pass\n\n    def handle_signed(self):\n        pass\n\n    def _GetNestedType(self, ctor):\n        name = None\n        name_tokens, token = self.GetName()\n        if name_tokens:\n            name = ''.join([t.name for t in name_tokens])\n\n        # Handle forward declarations.\n        if token.token_type == tokenize.SYNTAX and token.name == ';':\n            return ctor(token.start, token.end, name, None,\n                        self.namespace_stack)\n\n        if token.token_type == tokenize.NAME and self._handling_typedef:\n            self._AddBackToken(token)\n            return ctor(token.start, token.end, name, None,\n                        self.namespace_stack)\n\n        # Must be the type declaration.\n        fields = list(self._GetMatchingChar('{', '}'))\n        del fields[-1]                  # Remove trailing '}'.\n        if token.token_type == tokenize.SYNTAX and token.name == '{':\n            next = self._GetNextToken()\n            new_type = ctor(token.start, token.end, name, fields,\n                            self.namespace_stack)\n            # A name means this is an anonymous type and the name\n            # is the variable declaration.\n            if next.token_type != tokenize.NAME:\n                return new_type\n            name = new_type\n            token = next\n\n        # Must be variable declaration using the type prefixed with keyword.\n        assert token.token_type == tokenize.NAME, token\n        return self._CreateVariable(token, token.name, name, [], '', None)\n\n    def handle_struct(self):\n        # Special case the handling typedef/aliasing of structs here.\n        # It would be a pain to handle in the class code.\n        name_tokens, var_token = self.GetName()\n        if name_tokens:\n            next_token = self._GetNextToken()\n            is_syntax = (var_token.token_type == tokenize.SYNTAX and\n                         var_token.name[0] in '*&')\n            is_variable = (var_token.token_type == tokenize.NAME and\n                           next_token.name == ';')\n            variable = var_token\n            if is_syntax and not is_variable:\n                variable = next_token\n                temp = self._GetNextToken()\n                if temp.token_type == tokenize.SYNTAX and temp.name == '(':\n                    # Handle methods declared to return a struct.\n                    t0 = name_tokens[0]\n                    struct = tokenize.Token(tokenize.NAME, 'struct',\n                                            t0.start-7, t0.start-2)\n                    type_and_name = [struct]\n                    type_and_name.extend(name_tokens)\n                    type_and_name.extend((var_token, next_token))\n                    return self._GetMethod(type_and_name, 0, None, False)\n                assert temp.name == ';', (temp, name_tokens, var_token)\n            if is_syntax or (is_variable and not self._handling_typedef):\n                modifiers = ['struct']\n                type_name = ''.join([t.name for t in name_tokens])\n                position = name_tokens[0]\n                return self._CreateVariable(position, variable.name, type_name,\n                                            modifiers, var_token.name, None)\n            name_tokens.extend((var_token, next_token))\n            self._AddBackTokens(name_tokens)\n        else:\n            self._AddBackToken(var_token)\n        return self._GetClass(Struct, VISIBILITY_PUBLIC, None)\n\n    def handle_union(self):\n        return self._GetNestedType(Union)\n\n    def handle_enum(self):\n        return self._GetNestedType(Enum)\n\n    def handle_auto(self):\n        # TODO(nnorwitz): warn about using auto?  Probably not since it\n        # will be reclaimed and useful for C++0x.\n        pass\n\n    def handle_register(self):\n        pass\n\n    def handle_const(self):\n        pass\n\n    def handle_inline(self):\n        pass\n\n    def handle_extern(self):\n        pass\n\n    def handle_static(self):\n        pass\n\n    def handle_virtual(self):\n        # What follows must be a method.\n        token = token2 = self._GetNextToken()\n        if token.name == 'inline':\n            # HACK(nnorwitz): handle inline dtors by ignoring 'inline'.\n            token2 = self._GetNextToken()\n        if token2.token_type == tokenize.SYNTAX and token2.name == '~':\n            return self.GetMethod(FUNCTION_VIRTUAL + FUNCTION_DTOR, None)\n        assert token.token_type == tokenize.NAME or token.name == '::', token\n        return_type_and_name = self._GetTokensUpTo(tokenize.SYNTAX, '(')\n        return_type_and_name.insert(0, token)\n        if token2 is not token:\n            return_type_and_name.insert(1, token2)\n        return self._GetMethod(return_type_and_name, FUNCTION_VIRTUAL,\n                               None, False)\n\n    def handle_volatile(self):\n        pass\n\n    def handle_mutable(self):\n        pass\n\n    def handle_public(self):\n        assert self.in_class\n        self.visibility = VISIBILITY_PUBLIC\n\n    def handle_protected(self):\n        assert self.in_class\n        self.visibility = VISIBILITY_PROTECTED\n\n    def handle_private(self):\n        assert self.in_class\n        self.visibility = VISIBILITY_PRIVATE\n\n    def handle_friend(self):\n        tokens = self._GetTokensUpTo(tokenize.SYNTAX, ';')\n        assert tokens\n        t0 = tokens[0]\n        return Friend(t0.start, t0.end, tokens, self.namespace_stack)\n\n    def handle_static_cast(self):\n        pass\n\n    def handle_const_cast(self):\n        pass\n\n    def handle_dynamic_cast(self):\n        pass\n\n    def handle_reinterpret_cast(self):\n        pass\n\n    def handle_new(self):\n        pass\n\n    def handle_delete(self):\n        tokens = self._GetTokensUpTo(tokenize.SYNTAX, ';')\n        assert tokens\n        return Delete(tokens[0].start, tokens[0].end, tokens)\n\n    def handle_typedef(self):\n        token = self._GetNextToken()\n        if (token.token_type == tokenize.NAME and\n            keywords.IsKeyword(token.name)):\n            # Token must be struct/enum/union/class.\n            method = getattr(self, 'handle_' + token.name)\n            self._handling_typedef = True\n            tokens = [method()]\n            self._handling_typedef = False\n        else:\n            tokens = [token]\n\n        # Get the remainder of the typedef up to the semi-colon.\n        tokens.extend(self._GetTokensUpTo(tokenize.SYNTAX, ';'))\n\n        # TODO(nnorwitz): clean all this up.\n        assert tokens\n        name = tokens.pop()\n        indices = name\n        if tokens:\n            indices = tokens[0]\n        if not indices:\n            indices = token\n        if name.name == ')':\n            # HACK(nnorwitz): Handle pointers to functions \"properly\".\n            if (len(tokens) >= 4 and\n                tokens[1].name == '(' and tokens[2].name == '*'):\n                tokens.append(name)\n                name = tokens[3]\n        elif name.name == ']':\n            # HACK(nnorwitz): Handle arrays properly.\n            if len(tokens) >= 2:\n                tokens.append(name)\n                name = tokens[1]\n        new_type = tokens\n        if tokens and isinstance(tokens[0], tokenize.Token):\n            new_type = self.converter.ToType(tokens)[0]\n        return Typedef(indices.start, indices.end, name.name,\n                       new_type, self.namespace_stack)\n\n    def handle_typeid(self):\n        pass  # Not needed yet.\n\n    def handle_typename(self):\n        pass  # Not needed yet.\n\n    def _GetTemplatedTypes(self):\n        result = {}\n        tokens = list(self._GetMatchingChar('<', '>'))\n        len_tokens = len(tokens) - 1    # Ignore trailing '>'.\n        i = 0\n        while i < len_tokens:\n            key = tokens[i].name\n            i += 1\n            if keywords.IsKeyword(key) or key == ',':\n                continue\n            type_name = default = None\n            if i < len_tokens:\n                i += 1\n                if tokens[i-1].name == '=':\n                    assert i < len_tokens, '%s %s' % (i, tokens)\n                    default, unused_next_token = self.GetName(tokens[i:])\n                    i += len(default)\n                else:\n                    if tokens[i-1].name != ',':\n                        # We got something like: Type variable.\n                        # Re-adjust the key (variable) and type_name (Type).\n                        key = tokens[i-1].name\n                        type_name = tokens[i-2]\n\n            result[key] = (type_name, default)\n        return result\n\n    def handle_template(self):\n        token = self._GetNextToken()\n        assert token.token_type == tokenize.SYNTAX, token\n        assert token.name == '<', token\n        templated_types = self._GetTemplatedTypes()\n        # TODO(nnorwitz): for now, just ignore the template params.\n        token = self._GetNextToken()\n        if token.token_type == tokenize.NAME:\n            if token.name == 'class':\n                return self._GetClass(Class, VISIBILITY_PRIVATE, templated_types)\n            elif token.name == 'struct':\n                return self._GetClass(Struct, VISIBILITY_PUBLIC, templated_types)\n            elif token.name == 'friend':\n                return self.handle_friend()\n        self._AddBackToken(token)\n        tokens, last = self._GetVarTokensUpTo(tokenize.SYNTAX, '(', ';')\n        tokens.append(last)\n        self._AddBackTokens(tokens)\n        if last.name == '(':\n            return self.GetMethod(FUNCTION_NONE, templated_types)\n        # Must be a variable definition.\n        return None\n\n    def handle_true(self):\n        pass  # Nothing to do.\n\n    def handle_false(self):\n        pass  # Nothing to do.\n\n    def handle_asm(self):\n        pass  # Not needed yet.\n\n    def handle_class(self):\n        return self._GetClass(Class, VISIBILITY_PRIVATE, None)\n\n    def _GetBases(self):\n        # Get base classes.\n        bases = []\n        while 1:\n            token = self._GetNextToken()\n            assert token.token_type == tokenize.NAME, token\n            # TODO(nnorwitz): store kind of inheritance...maybe.\n            if token.name not in ('public', 'protected', 'private'):\n                # If inheritance type is not specified, it is private.\n                # Just put the token back so we can form a name.\n                # TODO(nnorwitz): it would be good to warn about this.\n                self._AddBackToken(token)\n            else:\n                # Check for virtual inheritance.\n                token = self._GetNextToken()\n                if token.name != 'virtual':\n                    self._AddBackToken(token)\n                else:\n                    # TODO(nnorwitz): store that we got virtual for this base.\n                    pass\n            base, next_token = self.GetName()\n            bases_ast = self.converter.ToType(base)\n            assert len(bases_ast) == 1, bases_ast\n            bases.append(bases_ast[0])\n            assert next_token.token_type == tokenize.SYNTAX, next_token\n            if next_token.name == '{':\n                token = next_token\n                break\n            # Support multiple inheritance.\n            assert next_token.name == ',', next_token\n        return bases, token\n\n    def _GetClass(self, class_type, visibility, templated_types):\n        class_name = None\n        class_token = self._GetNextToken()\n        if class_token.token_type != tokenize.NAME:\n            assert class_token.token_type == tokenize.SYNTAX, class_token\n            token = class_token\n        else:\n            # Skip any macro (e.g. storage class specifiers) after the\n            # 'class' keyword.\n            next_token = self._GetNextToken()\n            if next_token.token_type == tokenize.NAME:\n                self._AddBackToken(next_token)\n            else:\n                self._AddBackTokens([class_token, next_token])\n            name_tokens, token = self.GetName()\n            class_name = ''.join([t.name for t in name_tokens])\n        bases = None\n        if token.token_type == tokenize.SYNTAX:\n            if token.name == ';':\n                # Forward declaration.\n                return class_type(class_token.start, class_token.end,\n                                  class_name, None, templated_types, None,\n                                  self.namespace_stack)\n            if token.name in '*&':\n                # Inline forward declaration.  Could be method or data.\n                name_token = self._GetNextToken()\n                next_token = self._GetNextToken()\n                if next_token.name == ';':\n                    # Handle data\n                    modifiers = ['class']\n                    return self._CreateVariable(class_token, name_token.name,\n                                                class_name,\n                                                modifiers, token.name, None)\n                else:\n                    # Assume this is a method.\n                    tokens = (class_token, token, name_token, next_token)\n                    self._AddBackTokens(tokens)\n                    return self.GetMethod(FUNCTION_NONE, None)\n            if token.name == ':':\n                bases, token = self._GetBases()\n\n        body = None\n        if token.token_type == tokenize.SYNTAX and token.name == '{':\n            assert token.token_type == tokenize.SYNTAX, token\n            assert token.name == '{', token\n\n            ast = AstBuilder(self.GetScope(), self.filename, class_name,\n                             visibility, self.namespace_stack)\n            body = list(ast.Generate())\n\n            if not self._handling_typedef:\n                token = self._GetNextToken()\n                if token.token_type != tokenize.NAME:\n                    assert token.token_type == tokenize.SYNTAX, token\n                    assert token.name == ';', token\n                else:\n                    new_class = class_type(class_token.start, class_token.end,\n                                           class_name, bases, None,\n                                           body, self.namespace_stack)\n\n                    modifiers = []\n                    return self._CreateVariable(class_token,\n                                                token.name, new_class,\n                                                modifiers, token.name, None)\n        else:\n            if not self._handling_typedef:\n                self.HandleError('non-typedef token', token)\n            self._AddBackToken(token)\n\n        return class_type(class_token.start, class_token.end, class_name,\n                          bases, templated_types, body, self.namespace_stack)\n\n    def handle_namespace(self):\n        token = self._GetNextToken()\n        # Support anonymous namespaces.\n        name = None\n        if token.token_type == tokenize.NAME:\n            name = token.name\n            token = self._GetNextToken()\n        self.namespace_stack.append(name)\n        assert token.token_type == tokenize.SYNTAX, token\n        # Create an internal token that denotes when the namespace is complete.\n        internal_token = tokenize.Token(_INTERNAL_TOKEN, _NAMESPACE_POP,\n                                        None, None)\n        internal_token.whence = token.whence\n        if token.name == '=':\n            # TODO(nnorwitz): handle aliasing namespaces.\n            name, next_token = self.GetName()\n            assert next_token.name == ';', next_token\n            self._AddBackToken(internal_token)\n        else:\n            assert token.name == '{', token\n            tokens = list(self.GetScope())\n            # Replace the trailing } with the internal namespace pop token.\n            tokens[-1] = internal_token\n            # Handle namespace with nothing in it.\n            self._AddBackTokens(tokens)\n        return None\n\n    def handle_using(self):\n        tokens = self._GetTokensUpTo(tokenize.SYNTAX, ';')\n        assert tokens\n        return Using(tokens[0].start, tokens[0].end, tokens)\n\n    def handle_explicit(self):\n        assert self.in_class\n        # Nothing much to do.\n        # TODO(nnorwitz): maybe verify the method name == class name.\n        # This must be a ctor.\n        return self.GetMethod(FUNCTION_CTOR, None)\n\n    def handle_this(self):\n        pass  # Nothing to do.\n\n    def handle_operator(self):\n        # Pull off the next token(s?) and make that part of the method name.\n        pass\n\n    def handle_sizeof(self):\n        pass\n\n    def handle_case(self):\n        pass\n\n    def handle_switch(self):\n        pass\n\n    def handle_default(self):\n        token = self._GetNextToken()\n        assert token.token_type == tokenize.SYNTAX\n        assert token.name == ':'\n\n    def handle_if(self):\n        pass\n\n    def handle_else(self):\n        pass\n\n    def handle_return(self):\n        tokens = self._GetTokensUpTo(tokenize.SYNTAX, ';')\n        if not tokens:\n            return Return(self.current_token.start, self.current_token.end, None)\n        return Return(tokens[0].start, tokens[0].end, tokens)\n\n    def handle_goto(self):\n        tokens = self._GetTokensUpTo(tokenize.SYNTAX, ';')\n        assert len(tokens) == 1, str(tokens)\n        return Goto(tokens[0].start, tokens[0].end, tokens[0].name)\n\n    def handle_try(self):\n        pass  # Not needed yet.\n\n    def handle_catch(self):\n        pass  # Not needed yet.\n\n    def handle_throw(self):\n        pass  # Not needed yet.\n\n    def handle_while(self):\n        pass\n\n    def handle_do(self):\n        pass\n\n    def handle_for(self):\n        pass\n\n    def handle_break(self):\n        self._IgnoreUpTo(tokenize.SYNTAX, ';')\n\n    def handle_continue(self):\n        self._IgnoreUpTo(tokenize.SYNTAX, ';')\n\n\ndef BuilderFromSource(source, filename):\n    \"\"\"Utility method that returns an AstBuilder from source code.\n\n    Args:\n      source: 'C++ source code'\n      filename: 'file1'\n\n    Returns:\n      AstBuilder\n    \"\"\"\n    return AstBuilder(tokenize.GetTokens(source), filename)\n\n\ndef PrintIndentifiers(filename, should_print):\n    \"\"\"Prints all identifiers for a C++ source file.\n\n    Args:\n      filename: 'file1'\n      should_print: predicate with signature: bool Function(token)\n    \"\"\"\n    source = utils.ReadFile(filename, False)\n    if source is None:\n        sys.stderr.write('Unable to find: %s\\n' % filename)\n        return\n\n    #print('Processing %s' % actual_filename)\n    builder = BuilderFromSource(source, filename)\n    try:\n        for node in builder.Generate():\n            if should_print(node):\n                print(node.name)\n    except KeyboardInterrupt:\n        return\n    except:\n        pass\n\n\ndef PrintAllIndentifiers(filenames, should_print):\n    \"\"\"Prints all identifiers for each C++ source file in filenames.\n\n    Args:\n      filenames: ['file1', 'file2', ...]\n      should_print: predicate with signature: bool Function(token)\n    \"\"\"\n    for path in filenames:\n        PrintIndentifiers(path, should_print)\n\n\ndef main(argv):\n    for filename in argv[1:]:\n        source = utils.ReadFile(filename)\n        if source is None:\n            continue\n\n        print('Processing %s' % filename)\n        builder = BuilderFromSource(source, filename)\n        try:\n            entire_ast = filter(None, builder.Generate())\n        except KeyboardInterrupt:\n            return\n        except:\n            # Already printed a warning, print the traceback and continue.\n            traceback.print_exc()\n        else:\n            if utils.DEBUG:\n                for ast in entire_ast:\n                    print(ast)\n\n\nif __name__ == '__main__':\n    main(sys.argv)\n"
  },
  {
    "path": "ext/gmock/scripts/generator/cpp/gmock_class.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2008 Google Inc.  All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Generate Google Mock classes from base classes.\n\nThis program will read in a C++ source file and output the Google Mock\nclasses for the specified classes.  If no class is specified, all\nclasses in the source file are emitted.\n\nUsage:\n  gmock_class.py header-file.h [ClassName]...\n\nOutput is sent to stdout.\n\"\"\"\n\n__author__ = 'nnorwitz@google.com (Neal Norwitz)'\n\n\nimport os\nimport re\nimport sys\n\nfrom cpp import ast\nfrom cpp import utils\n\n# Preserve compatibility with Python 2.3.\ntry:\n  _dummy = set\nexcept NameError:\n  import sets\n  set = sets.Set\n\n_VERSION = (1, 0, 1)  # The version of this script.\n# How many spaces to indent.  Can set me with the INDENT environment variable.\n_INDENT = 2\n\n\ndef _GenerateMethods(output_lines, source, class_node):\n  function_type = ast.FUNCTION_VIRTUAL | ast.FUNCTION_PURE_VIRTUAL\n  ctor_or_dtor = ast.FUNCTION_CTOR | ast.FUNCTION_DTOR\n  indent = ' ' * _INDENT\n\n  for node in class_node.body:\n    # We only care about virtual functions.\n    if (isinstance(node, ast.Function) and\n        node.modifiers & function_type and\n        not node.modifiers & ctor_or_dtor):\n      # Pick out all the elements we need from the original function.\n      const = ''\n      if node.modifiers & ast.FUNCTION_CONST:\n        const = 'CONST_'\n      return_type = 'void'\n      if node.return_type:\n        # Add modifiers like 'const'.\n        modifiers = ''\n        if node.return_type.modifiers:\n          modifiers = ' '.join(node.return_type.modifiers) + ' '\n        return_type = modifiers + node.return_type.name\n        template_args = [arg.name for arg in node.return_type.templated_types]\n        if template_args:\n          return_type += '<' + ', '.join(template_args) + '>'\n          if len(template_args) > 1:\n            for line in [\n                '// The following line won\\'t really compile, as the return',\n                '// type has multiple template arguments.  To fix it, use a',\n                '// typedef for the return type.']:\n              output_lines.append(indent + line)\n        if node.return_type.pointer:\n          return_type += '*'\n        if node.return_type.reference:\n          return_type += '&'\n        num_parameters = len(node.parameters)\n        if len(node.parameters) == 1:\n          first_param = node.parameters[0]\n          if source[first_param.start:first_param.end].strip() == 'void':\n            # We must treat T(void) as a function with no parameters.\n            num_parameters = 0\n      tmpl = ''\n      if class_node.templated_types:\n        tmpl = '_T'\n      mock_method_macro = 'MOCK_%sMETHOD%d%s' % (const, num_parameters, tmpl)\n\n      args = ''\n      if node.parameters:\n        # Due to the parser limitations, it is impossible to keep comments\n        # while stripping the default parameters.  When defaults are\n        # present, we choose to strip them and comments (and produce\n        # compilable code).\n        # TODO(nnorwitz@google.com): Investigate whether it is possible to\n        # preserve parameter name when reconstructing parameter text from\n        # the AST.\n        if len([param for param in node.parameters if param.default]) > 0:\n          args = ', '.join(param.type.name for param in node.parameters)\n        else:\n          # Get the full text of the parameters from the start\n          # of the first parameter to the end of the last parameter.\n          start = node.parameters[0].start\n          end = node.parameters[-1].end\n          # Remove // comments.\n          args_strings = re.sub(r'//.*', '', source[start:end])\n          # Condense multiple spaces and eliminate newlines putting the\n          # parameters together on a single line.  Ensure there is a\n          # space in an argument which is split by a newline without\n          # intervening whitespace, e.g.: int\\nBar\n          args = re.sub('  +', ' ', args_strings.replace('\\n', ' '))\n\n      # Create the mock method definition.\n      output_lines.extend(['%s%s(%s,' % (indent, mock_method_macro, node.name),\n                           '%s%s(%s));' % (indent*3, return_type, args)])\n\n\ndef _GenerateMocks(filename, source, ast_list, desired_class_names):\n  processed_class_names = set()\n  lines = []\n  for node in ast_list:\n    if (isinstance(node, ast.Class) and node.body and\n        # desired_class_names being None means that all classes are selected.\n        (not desired_class_names or node.name in desired_class_names)):\n      class_name = node.name\n      parent_name = class_name\n      processed_class_names.add(class_name)\n      class_node = node\n      # Add namespace before the class.\n      if class_node.namespace:\n        lines.extend(['namespace %s {' % n for n in class_node.namespace])  # }\n        lines.append('')\n\n      # Add template args for templated classes.\n      if class_node.templated_types:\n        # TODO(paulchang): The AST doesn't preserve template argument order,\n        # so we have to make up names here.\n        # TODO(paulchang): Handle non-type template arguments (e.g.\n        # template<typename T, int N>).\n        template_arg_count = len(class_node.templated_types.keys())\n        template_args = ['T%d' % n for n in range(template_arg_count)]\n        template_decls = ['typename ' + arg for arg in template_args]\n        lines.append('template <' + ', '.join(template_decls) + '>')\n        parent_name += '<' + ', '.join(template_args) + '>'\n\n      # Add the class prolog.\n      lines.append('class Mock%s : public %s {'  # }\n                   % (class_name, parent_name))\n      lines.append('%spublic:' % (' ' * (_INDENT // 2)))\n\n      # Add all the methods.\n      _GenerateMethods(lines, source, class_node)\n\n      # Close the class.\n      if lines:\n        # If there are no virtual methods, no need for a public label.\n        if len(lines) == 2:\n          del lines[-1]\n\n        # Only close the class if there really is a class.\n        lines.append('};')\n        lines.append('')  # Add an extra newline.\n\n      # Close the namespace.\n      if class_node.namespace:\n        for i in range(len(class_node.namespace)-1, -1, -1):\n          lines.append('}  // namespace %s' % class_node.namespace[i])\n        lines.append('')  # Add an extra newline.\n\n  if desired_class_names:\n    missing_class_name_list = list(desired_class_names - processed_class_names)\n    if missing_class_name_list:\n      missing_class_name_list.sort()\n      sys.stderr.write('Class(es) not found in %s: %s\\n' %\n                       (filename, ', '.join(missing_class_name_list)))\n  elif not processed_class_names:\n    sys.stderr.write('No class found in %s\\n' % filename)\n\n  return lines\n\n\ndef main(argv=sys.argv):\n  if len(argv) < 2:\n    sys.stderr.write('Google Mock Class Generator v%s\\n\\n' %\n                     '.'.join(map(str, _VERSION)))\n    sys.stderr.write(__doc__)\n    return 1\n\n  global _INDENT\n  try:\n    _INDENT = int(os.environ['INDENT'])\n  except KeyError:\n    pass\n  except:\n    sys.stderr.write('Unable to use indent of %s\\n' % os.environ.get('INDENT'))\n\n  filename = argv[1]\n  desired_class_names = None  # None means all classes in the source file.\n  if len(argv) >= 3:\n    desired_class_names = set(argv[2:])\n  source = utils.ReadFile(filename)\n  if source is None:\n    return 1\n\n  builder = ast.BuilderFromSource(source, filename)\n  try:\n    entire_ast = filter(None, builder.Generate())\n  except KeyboardInterrupt:\n    return\n  except:\n    # An error message was already printed since we couldn't parse.\n    pass\n  else:\n    lines = _GenerateMocks(filename, source, entire_ast, desired_class_names)\n    sys.stdout.write('\\n'.join(lines))\n\n\nif __name__ == '__main__':\n  main(sys.argv)\n"
  },
  {
    "path": "ext/gmock/scripts/generator/cpp/gmock_class_test.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2009 Neal Norwitz All Rights Reserved.\n# Portions Copyright 2009 Google Inc. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Tests for gmock.scripts.generator.cpp.gmock_class.\"\"\"\n\n__author__ = 'nnorwitz@google.com (Neal Norwitz)'\n\n\nimport os\nimport sys\nimport unittest\n\n# Allow the cpp imports below to work when run as a standalone script.\nsys.path.append(os.path.join(os.path.dirname(__file__), '..'))\n\nfrom cpp import ast\nfrom cpp import gmock_class\n\n\nclass TestCase(unittest.TestCase):\n  \"\"\"Helper class that adds assert methods.\"\"\"\n\n  def StripLeadingWhitespace(self, lines):\n    \"\"\"Strip leading whitespace in each line in 'lines'.\"\"\"\n    return '\\n'.join([s.lstrip() for s in lines.split('\\n')])\n\n  def assertEqualIgnoreLeadingWhitespace(self, expected_lines, lines):\n    \"\"\"Specialized assert that ignores the indent level.\"\"\"\n    self.assertEqual(expected_lines, self.StripLeadingWhitespace(lines))\n\n\nclass GenerateMethodsTest(TestCase):\n\n  def GenerateMethodSource(self, cpp_source):\n    \"\"\"Convert C++ source to Google Mock output source lines.\"\"\"\n    method_source_lines = []\n    # <test> is a pseudo-filename, it is not read or written.\n    builder = ast.BuilderFromSource(cpp_source, '<test>')\n    ast_list = list(builder.Generate())\n    gmock_class._GenerateMethods(method_source_lines, cpp_source, ast_list[0])\n    return '\\n'.join(method_source_lines)\n\n  def testSimpleMethod(self):\n    source = \"\"\"\nclass Foo {\n public:\n  virtual int Bar();\n};\n\"\"\"\n    self.assertEqualIgnoreLeadingWhitespace(\n        'MOCK_METHOD0(Bar,\\nint());',\n        self.GenerateMethodSource(source))\n\n  def testSimpleConstMethod(self):\n    source = \"\"\"\nclass Foo {\n public:\n  virtual void Bar(bool flag) const;\n};\n\"\"\"\n    self.assertEqualIgnoreLeadingWhitespace(\n        'MOCK_CONST_METHOD1(Bar,\\nvoid(bool flag));',\n        self.GenerateMethodSource(source))\n\n  def testExplicitVoid(self):\n    source = \"\"\"\nclass Foo {\n public:\n  virtual int Bar(void);\n};\n\"\"\"\n    self.assertEqualIgnoreLeadingWhitespace(\n        'MOCK_METHOD0(Bar,\\nint(void));',\n        self.GenerateMethodSource(source))\n\n  def testStrangeNewlineInParameter(self):\n    source = \"\"\"\nclass Foo {\n public:\n  virtual void Bar(int\na) = 0;\n};\n\"\"\"\n    self.assertEqualIgnoreLeadingWhitespace(\n        'MOCK_METHOD1(Bar,\\nvoid(int a));',\n        self.GenerateMethodSource(source))\n\n  def testDefaultParameters(self):\n    source = \"\"\"\nclass Foo {\n public:\n  virtual void Bar(int a, char c = 'x') = 0;\n};\n\"\"\"\n    self.assertEqualIgnoreLeadingWhitespace(\n        'MOCK_METHOD2(Bar,\\nvoid(int, char));',\n        self.GenerateMethodSource(source))\n\n  def testMultipleDefaultParameters(self):\n    source = \"\"\"\nclass Foo {\n public:\n  virtual void Bar(int a = 42, char c = 'x') = 0;\n};\n\"\"\"\n    self.assertEqualIgnoreLeadingWhitespace(\n        'MOCK_METHOD2(Bar,\\nvoid(int, char));',\n        self.GenerateMethodSource(source))\n\n  def testRemovesCommentsWhenDefaultsArePresent(self):\n    source = \"\"\"\nclass Foo {\n public:\n  virtual void Bar(int a = 42 /* a comment */,\n                   char /* other comment */ c= 'x') = 0;\n};\n\"\"\"\n    self.assertEqualIgnoreLeadingWhitespace(\n        'MOCK_METHOD2(Bar,\\nvoid(int, char));',\n        self.GenerateMethodSource(source))\n\n  def testDoubleSlashCommentsInParameterListAreRemoved(self):\n    source = \"\"\"\nclass Foo {\n public:\n  virtual void Bar(int a,  // inline comments should be elided.\n                   int b   // inline comments should be elided.\n                   ) const = 0;\n};\n\"\"\"\n    self.assertEqualIgnoreLeadingWhitespace(\n        'MOCK_CONST_METHOD2(Bar,\\nvoid(int a, int b));',\n        self.GenerateMethodSource(source))\n\n  def testCStyleCommentsInParameterListAreNotRemoved(self):\n    # NOTE(nnorwitz): I'm not sure if it's the best behavior to keep these\n    # comments.  Also note that C style comments after the last parameter\n    # are still elided.\n    source = \"\"\"\nclass Foo {\n public:\n  virtual const string& Bar(int /* keeper */, int b);\n};\n\"\"\"\n    self.assertEqualIgnoreLeadingWhitespace(\n        'MOCK_METHOD2(Bar,\\nconst string&(int /* keeper */, int b));',\n        self.GenerateMethodSource(source))\n\n  def testArgsOfTemplateTypes(self):\n    source = \"\"\"\nclass Foo {\n public:\n  virtual int Bar(const vector<int>& v, map<int, string>* output);\n};\"\"\"\n    self.assertEqualIgnoreLeadingWhitespace(\n        'MOCK_METHOD2(Bar,\\n'\n        'int(const vector<int>& v, map<int, string>* output));',\n        self.GenerateMethodSource(source))\n\n  def testReturnTypeWithOneTemplateArg(self):\n    source = \"\"\"\nclass Foo {\n public:\n  virtual vector<int>* Bar(int n);\n};\"\"\"\n    self.assertEqualIgnoreLeadingWhitespace(\n        'MOCK_METHOD1(Bar,\\nvector<int>*(int n));',\n        self.GenerateMethodSource(source))\n\n  def testReturnTypeWithManyTemplateArgs(self):\n    source = \"\"\"\nclass Foo {\n public:\n  virtual map<int, string> Bar();\n};\"\"\"\n    # Comparing the comment text is brittle - we'll think of something\n    # better in case this gets annoying, but for now let's keep it simple.\n    self.assertEqualIgnoreLeadingWhitespace(\n        '// The following line won\\'t really compile, as the return\\n'\n        '// type has multiple template arguments.  To fix it, use a\\n'\n        '// typedef for the return type.\\n'\n        'MOCK_METHOD0(Bar,\\nmap<int, string>());',\n        self.GenerateMethodSource(source))\n\n  def testSimpleMethodInTemplatedClass(self):\n    source = \"\"\"\ntemplate<class T>\nclass Foo {\n public:\n  virtual int Bar();\n};\n\"\"\"\n    self.assertEqualIgnoreLeadingWhitespace(\n        'MOCK_METHOD0_T(Bar,\\nint());',\n        self.GenerateMethodSource(source))\n\n\nclass GenerateMocksTest(TestCase):\n\n  def GenerateMocks(self, cpp_source):\n    \"\"\"Convert C++ source to complete Google Mock output source.\"\"\"\n    # <test> is a pseudo-filename, it is not read or written.\n    filename = '<test>'\n    builder = ast.BuilderFromSource(cpp_source, filename)\n    ast_list = list(builder.Generate())\n    lines = gmock_class._GenerateMocks(filename, cpp_source, ast_list, None)\n    return '\\n'.join(lines)\n\n  def testNamespaces(self):\n    source = \"\"\"\nnamespace Foo {\nnamespace Bar { class Forward; }\nnamespace Baz {\n\nclass Test {\n public:\n  virtual void Foo();\n};\n\n}  // namespace Baz\n}  // namespace Foo\n\"\"\"\n    expected = \"\"\"\\\nnamespace Foo {\nnamespace Baz {\n\nclass MockTest : public Test {\npublic:\nMOCK_METHOD0(Foo,\nvoid());\n};\n\n}  // namespace Baz\n}  // namespace Foo\n\"\"\"\n    self.assertEqualIgnoreLeadingWhitespace(\n        expected, self.GenerateMocks(source))\n\n  def testClassWithStorageSpecifierMacro(self):\n    source = \"\"\"\nclass STORAGE_SPECIFIER Test {\n public:\n  virtual void Foo();\n};\n\"\"\"\n    expected = \"\"\"\\\nclass MockTest : public Test {\npublic:\nMOCK_METHOD0(Foo,\nvoid());\n};\n\"\"\"\n    self.assertEqualIgnoreLeadingWhitespace(\n        expected, self.GenerateMocks(source))\n\n  def testTemplatedForwardDeclaration(self):\n    source = \"\"\"\ntemplate <class T> class Forward;  // Forward declaration should be ignored.\nclass Test {\n public:\n  virtual void Foo();\n};\n\"\"\"\n    expected = \"\"\"\\\nclass MockTest : public Test {\npublic:\nMOCK_METHOD0(Foo,\nvoid());\n};\n\"\"\"\n    self.assertEqualIgnoreLeadingWhitespace(\n        expected, self.GenerateMocks(source))\n\n  def testTemplatedClass(self):\n    source = \"\"\"\ntemplate <typename S, typename T>\nclass Test {\n public:\n  virtual void Foo();\n};\n\"\"\"\n    expected = \"\"\"\\\ntemplate <typename T0, typename T1>\nclass MockTest : public Test<T0, T1> {\npublic:\nMOCK_METHOD0_T(Foo,\nvoid());\n};\n\"\"\"\n    self.assertEqualIgnoreLeadingWhitespace(\n        expected, self.GenerateMocks(source))\n\n\nif __name__ == '__main__':\n  unittest.main()\n"
  },
  {
    "path": "ext/gmock/scripts/generator/cpp/keywords.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2007 Neal Norwitz\n# Portions Copyright 2007 Google Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"C++ keywords and helper utilities for determining keywords.\"\"\"\n\n__author__ = 'nnorwitz@google.com (Neal Norwitz)'\n\n\ntry:\n    # Python 3.x\n    import builtins\nexcept ImportError:\n    # Python 2.x\n    import __builtin__ as builtins\n\n\nif not hasattr(builtins, 'set'):\n    # Nominal support for Python 2.3.\n    from sets import Set as set\n\n\nTYPES = set('bool char int long short double float void wchar_t unsigned signed'.split())\nTYPE_MODIFIERS = set('auto register const inline extern static virtual volatile mutable'.split())\nACCESS = set('public protected private friend'.split())\n\nCASTS = set('static_cast const_cast dynamic_cast reinterpret_cast'.split())\n\nOTHERS = set('true false asm class namespace using explicit this operator sizeof'.split())\nOTHER_TYPES = set('new delete typedef struct union enum typeid typename template'.split())\n\nCONTROL = set('case switch default if else return goto'.split())\nEXCEPTION = set('try catch throw'.split())\nLOOP = set('while do for break continue'.split())\n\nALL = TYPES | TYPE_MODIFIERS | ACCESS | CASTS | OTHERS | OTHER_TYPES | CONTROL | EXCEPTION | LOOP\n\n\ndef IsKeyword(token):\n    return token in ALL\n\ndef IsBuiltinType(token):\n    if token in ('virtual', 'inline'):\n        # These only apply to methods, they can't be types by themselves.\n        return False\n    return token in TYPES or token in TYPE_MODIFIERS\n"
  },
  {
    "path": "ext/gmock/scripts/generator/cpp/tokenize.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2007 Neal Norwitz\n# Portions Copyright 2007 Google Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Tokenize C++ source code.\"\"\"\n\n__author__ = 'nnorwitz@google.com (Neal Norwitz)'\n\n\ntry:\n    # Python 3.x\n    import builtins\nexcept ImportError:\n    # Python 2.x\n    import __builtin__ as builtins\n\n\nimport sys\n\nfrom cpp import utils\n\n\nif not hasattr(builtins, 'set'):\n    # Nominal support for Python 2.3.\n    from sets import Set as set\n\n\n# Add $ as a valid identifier char since so much code uses it.\n_letters = 'abcdefghijklmnopqrstuvwxyz'\nVALID_IDENTIFIER_CHARS = set(_letters + _letters.upper() + '_0123456789$')\nHEX_DIGITS = set('0123456789abcdefABCDEF')\nINT_OR_FLOAT_DIGITS = set('01234567890eE-+')\n\n\n# C++0x string preffixes.\n_STR_PREFIXES = set(('R', 'u8', 'u8R', 'u', 'uR', 'U', 'UR', 'L', 'LR'))\n\n\n# Token types.\nUNKNOWN = 'UNKNOWN'\nSYNTAX = 'SYNTAX'\nCONSTANT = 'CONSTANT'\nNAME = 'NAME'\nPREPROCESSOR = 'PREPROCESSOR'\n\n# Where the token originated from.  This can be used for backtracking.\n# It is always set to WHENCE_STREAM in this code.\nWHENCE_STREAM, WHENCE_QUEUE = range(2)\n\n\nclass Token(object):\n    \"\"\"Data container to represent a C++ token.\n\n    Tokens can be identifiers, syntax char(s), constants, or\n    pre-processor directives.\n\n    start contains the index of the first char of the token in the source\n    end contains the index of the last char of the token in the source\n    \"\"\"\n\n    def __init__(self, token_type, name, start, end):\n        self.token_type = token_type\n        self.name = name\n        self.start = start\n        self.end = end\n        self.whence = WHENCE_STREAM\n\n    def __str__(self):\n        if not utils.DEBUG:\n            return 'Token(%r)' % self.name\n        return 'Token(%r, %s, %s)' % (self.name, self.start, self.end)\n\n    __repr__ = __str__\n\n\ndef _GetString(source, start, i):\n    i = source.find('\"', i+1)\n    while source[i-1] == '\\\\':\n        # Count the trailing backslashes.\n        backslash_count = 1\n        j = i - 2\n        while source[j] == '\\\\':\n            backslash_count += 1\n            j -= 1\n        # When trailing backslashes are even, they escape each other.\n        if (backslash_count % 2) == 0:\n            break\n        i = source.find('\"', i+1)\n    return i + 1\n\n\ndef _GetChar(source, start, i):\n    # NOTE(nnorwitz): may not be quite correct, should be good enough.\n    i = source.find(\"'\", i+1)\n    while source[i-1] == '\\\\':\n        # Need to special case '\\\\'.\n        if (i - 2) > start and source[i-2] == '\\\\':\n            break\n        i = source.find(\"'\", i+1)\n    # Try to handle unterminated single quotes (in a #if 0 block).\n    if i < 0:\n        i = start\n    return i + 1\n\n\ndef GetTokens(source):\n    \"\"\"Returns a sequence of Tokens.\n\n    Args:\n      source: string of C++ source code.\n\n    Yields:\n      Token that represents the next token in the source.\n    \"\"\"\n    # Cache various valid character sets for speed.\n    valid_identifier_chars = VALID_IDENTIFIER_CHARS\n    hex_digits = HEX_DIGITS\n    int_or_float_digits = INT_OR_FLOAT_DIGITS\n    int_or_float_digits2 = int_or_float_digits | set('.')\n\n    # Only ignore errors while in a #if 0 block.\n    ignore_errors = False\n    count_ifs = 0\n\n    i = 0\n    end = len(source)\n    while i < end:\n        # Skip whitespace.\n        while i < end and source[i].isspace():\n            i += 1\n        if i >= end:\n            return\n\n        token_type = UNKNOWN\n        start = i\n        c = source[i]\n        if c.isalpha() or c == '_':              # Find a string token.\n            token_type = NAME\n            while source[i] in valid_identifier_chars:\n                i += 1\n            # String and character constants can look like a name if\n            # they are something like L\"\".\n            if (source[i] == \"'\" and (i - start) == 1 and\n                source[start:i] in 'uUL'):\n                # u, U, and L are valid C++0x character preffixes.\n                token_type = CONSTANT\n                i = _GetChar(source, start, i)\n            elif source[i] == \"'\" and source[start:i] in _STR_PREFIXES:\n                token_type = CONSTANT\n                i = _GetString(source, start, i)\n        elif c == '/' and source[i+1] == '/':    # Find // comments.\n            i = source.find('\\n', i)\n            if i == -1:  # Handle EOF.\n                i = end\n            continue\n        elif c == '/' and source[i+1] == '*':    # Find /* comments. */\n            i = source.find('*/', i) + 2\n            continue\n        elif c in ':+-<>&|*=':                   # : or :: (plus other chars).\n            token_type = SYNTAX\n            i += 1\n            new_ch = source[i]\n            if new_ch == c:\n                i += 1\n            elif c == '-' and new_ch == '>':\n                i += 1\n            elif new_ch == '=':\n                i += 1\n        elif c in '()[]{}~!?^%;/.,':             # Handle single char tokens.\n            token_type = SYNTAX\n            i += 1\n            if c == '.' and source[i].isdigit():\n                token_type = CONSTANT\n                i += 1\n                while source[i] in int_or_float_digits:\n                    i += 1\n                # Handle float suffixes.\n                for suffix in ('l', 'f'):\n                    if suffix == source[i:i+1].lower():\n                        i += 1\n                        break\n        elif c.isdigit():                        # Find integer.\n            token_type = CONSTANT\n            if c == '0' and source[i+1] in 'xX':\n                # Handle hex digits.\n                i += 2\n                while source[i] in hex_digits:\n                    i += 1\n            else:\n                while source[i] in int_or_float_digits2:\n                    i += 1\n            # Handle integer (and float) suffixes.\n            for suffix in ('ull', 'll', 'ul', 'l', 'f', 'u'):\n                size = len(suffix)\n                if suffix == source[i:i+size].lower():\n                    i += size\n                    break\n        elif c == '\"':                           # Find string.\n            token_type = CONSTANT\n            i = _GetString(source, start, i)\n        elif c == \"'\":                           # Find char.\n            token_type = CONSTANT\n            i = _GetChar(source, start, i)\n        elif c == '#':                           # Find pre-processor command.\n            token_type = PREPROCESSOR\n            got_if = source[i:i+3] == '#if' and source[i+3:i+4].isspace()\n            if got_if:\n                count_ifs += 1\n            elif source[i:i+6] == '#endif':\n                count_ifs -= 1\n                if count_ifs == 0:\n                    ignore_errors = False\n\n            # TODO(nnorwitz): handle preprocessor statements (\\ continuations).\n            while 1:\n                i1 = source.find('\\n', i)\n                i2 = source.find('//', i)\n                i3 = source.find('/*', i)\n                i4 = source.find('\"', i)\n                # NOTE(nnorwitz): doesn't handle comments in #define macros.\n                # Get the first important symbol (newline, comment, EOF/end).\n                i = min([x for x in (i1, i2, i3, i4, end) if x != -1])\n\n                # Handle #include \"dir//foo.h\" properly.\n                if source[i] == '\"':\n                    i = source.find('\"', i+1) + 1\n                    assert i > 0\n                    continue\n                # Keep going if end of the line and the line ends with \\.\n                if not (i == i1 and source[i-1] == '\\\\'):\n                    if got_if:\n                        condition = source[start+4:i].lstrip()\n                        if (condition.startswith('0') or\n                            condition.startswith('(0)')):\n                            ignore_errors = True\n                    break\n                i += 1\n        elif c == '\\\\':                          # Handle \\ in code.\n            # This is different from the pre-processor \\ handling.\n            i += 1\n            continue\n        elif ignore_errors:\n            # The tokenizer seems to be in pretty good shape.  This\n            # raise is conditionally disabled so that bogus code\n            # in an #if 0 block can be handled.  Since we will ignore\n            # it anyways, this is probably fine.  So disable the\n            # exception and  return the bogus char.\n            i += 1\n        else:\n            sys.stderr.write('Got invalid token in %s @ %d token:%s: %r\\n' %\n                             ('?', i, c, source[i-10:i+10]))\n            raise RuntimeError('unexpected token')\n\n        if i <= 0:\n            print('Invalid index, exiting now.')\n            return\n        yield Token(token_type, source[start:i], start, i)\n\n\nif __name__ == '__main__':\n    def main(argv):\n        \"\"\"Driver mostly for testing purposes.\"\"\"\n        for filename in argv[1:]:\n            source = utils.ReadFile(filename)\n            if source is None:\n                continue\n\n            for token in GetTokens(source):\n                print('%-12s: %s' % (token.token_type, token.name))\n                # print('\\r%6.2f%%' % (100.0 * index / token.end),)\n            sys.stdout.write('\\n')\n\n\n    main(sys.argv)\n"
  },
  {
    "path": "ext/gmock/scripts/generator/cpp/utils.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2007 Neal Norwitz\n# Portions Copyright 2007 Google Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Generic utilities for C++ parsing.\"\"\"\n\n__author__ = 'nnorwitz@google.com (Neal Norwitz)'\n\n\nimport sys\n\n\n# Set to True to see the start/end token indices.\nDEBUG = True\n\n\ndef ReadFile(filename, print_error=True):\n    \"\"\"Returns the contents of a file.\"\"\"\n    try:\n        fp = open(filename)\n        try:\n            return fp.read()\n        finally:\n            fp.close()\n    except IOError:\n        if print_error:\n            print('Error reading %s: %s' % (filename, sys.exc_info()[1]))\n        return None\n"
  },
  {
    "path": "ext/gmock/scripts/generator/gmock_gen.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2008 Google Inc. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#      http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Driver for starting up Google Mock class generator.\"\"\"\n\n__author__ = 'nnorwitz@google.com (Neal Norwitz)'\n\nimport os\nimport sys\n\nif __name__ == '__main__':\n  # Add the directory of this script to the path so we can import gmock_class.\n  sys.path.append(os.path.dirname(__file__))\n\n  from cpp import gmock_class\n  # Fix the docstring in case they require the usage.\n  gmock_class.__doc__ = gmock_class.__doc__.replace('gmock_class.py', __file__)\n  gmock_class.main()\n"
  },
  {
    "path": "ext/gmock/scripts/gmock-config.in",
    "content": "#!/bin/sh\n\n# These variables are automatically filled in by the configure script.\nname=\"@PACKAGE_TARNAME@\"\nversion=\"@PACKAGE_VERSION@\"\n\nshow_usage()\n{\n  echo \"Usage: gmock-config [OPTIONS...]\"\n}\n\nshow_help()\n{\n  show_usage\n  cat <<\\EOF\n\nThe `gmock-config' script provides access to the necessary compile and linking\nflags to connect with Google C++ Mocking Framework, both in a build prior to\ninstallation, and on the system proper after installation. The installation\noverrides may be issued in combination with any other queries, but will only\naffect installation queries if called on a built but not installed gmock. The\ninstallation queries may not be issued with any other types of queries, and\nonly one installation query may be made at a time. The version queries and\ncompiler flag queries may be combined as desired but not mixed. Different\nversion queries are always combined with logical \"and\" semantics, and only the\nlast of any particular query is used while all previous ones ignored. All\nversions must be specified as a sequence of numbers separated by periods.\nCompiler flag queries output the union of the sets of flags when combined.\n\n Examples:\n  gmock-config --min-version=1.0 || echo \"Insufficient Google Mock version.\"\n\n  g++ $(gmock-config --cppflags --cxxflags) -o foo.o -c foo.cpp\n  g++ $(gmock-config --ldflags --libs) -o foo foo.o\n\n  # When using a built but not installed Google Mock:\n  g++ $(../../my_gmock_build/scripts/gmock-config ...) ...\n\n  # When using an installed Google Mock, but with installation overrides:\n  export GMOCK_PREFIX=\"/opt\"\n  g++ $(gmock-config --libdir=\"/opt/lib64\" ...) ...\n\n Help:\n  --usage                    brief usage information\n  --help                     display this help message\n\n Installation Overrides:\n  --prefix=<dir>             overrides the installation prefix\n  --exec-prefix=<dir>        overrides the executable installation prefix\n  --libdir=<dir>             overrides the library installation prefix\n  --includedir=<dir>         overrides the header file installation prefix\n\n Installation Queries:\n  --prefix                   installation prefix\n  --exec-prefix              executable installation prefix\n  --libdir                   library installation directory\n  --includedir               header file installation directory\n  --version                  the version of the Google Mock installation\n\n Version Queries:\n  --min-version=VERSION      return 0 if the version is at least VERSION\n  --exact-version=VERSION    return 0 if the version is exactly VERSION\n  --max-version=VERSION      return 0 if the version is at most VERSION\n\n Compilation Flag Queries:\n  --cppflags                 compile flags specific to the C-like preprocessors\n  --cxxflags                 compile flags appropriate for C++ programs\n  --ldflags                  linker flags\n  --libs                     libraries for linking\n\nEOF\n}\n\n# This function bounds our version with a min and a max. It uses some clever\n# POSIX-compliant variable expansion to portably do all the work in the shell\n# and avoid any dependency on a particular \"sed\" or \"awk\" implementation.\n# Notable is that it will only ever compare the first 3 components of versions.\n# Further components will be cleanly stripped off. All versions must be\n# unadorned, so \"v1.0\" will *not* work. The minimum version must be in $1, and\n# the max in $2. TODO(chandlerc@google.com): If this ever breaks, we should\n# investigate expanding this via autom4te from AS_VERSION_COMPARE rather than\n# continuing to maintain our own shell version.\ncheck_versions()\n{\n  major_version=${version%%.*}\n  minor_version=\"0\"\n  point_version=\"0\"\n  if test \"${version#*.}\" != \"${version}\"; then\n    minor_version=${version#*.}\n    minor_version=${minor_version%%.*}\n  fi\n  if test \"${version#*.*.}\" != \"${version}\"; then\n    point_version=${version#*.*.}\n    point_version=${point_version%%.*}\n  fi\n\n  min_version=\"$1\"\n  min_major_version=${min_version%%.*}\n  min_minor_version=\"0\"\n  min_point_version=\"0\"\n  if test \"${min_version#*.}\" != \"${min_version}\"; then\n    min_minor_version=${min_version#*.}\n    min_minor_version=${min_minor_version%%.*}\n  fi\n  if test \"${min_version#*.*.}\" != \"${min_version}\"; then\n    min_point_version=${min_version#*.*.}\n    min_point_version=${min_point_version%%.*}\n  fi\n\n  max_version=\"$2\"\n  max_major_version=${max_version%%.*}\n  max_minor_version=\"0\"\n  max_point_version=\"0\"\n  if test \"${max_version#*.}\" != \"${max_version}\"; then\n    max_minor_version=${max_version#*.}\n    max_minor_version=${max_minor_version%%.*}\n  fi\n  if test \"${max_version#*.*.}\" != \"${max_version}\"; then\n    max_point_version=${max_version#*.*.}\n    max_point_version=${max_point_version%%.*}\n  fi\n\n  test $(($major_version)) -lt $(($min_major_version)) && exit 1\n  if test $(($major_version)) -eq $(($min_major_version)); then\n    test $(($minor_version)) -lt $(($min_minor_version)) && exit 1\n    if test $(($minor_version)) -eq $(($min_minor_version)); then\n      test $(($point_version)) -lt $(($min_point_version)) && exit 1\n    fi\n  fi\n\n  test $(($major_version)) -gt $(($max_major_version)) && exit 1\n  if test $(($major_version)) -eq $(($max_major_version)); then\n    test $(($minor_version)) -gt $(($max_minor_version)) && exit 1\n    if test $(($minor_version)) -eq $(($max_minor_version)); then\n      test $(($point_version)) -gt $(($max_point_version)) && exit 1\n    fi\n  fi\n\n  exit 0\n}\n\n# Show the usage line when no arguments are specified.\nif test $# -eq 0; then\n  show_usage\n  exit 1\nfi\n\nwhile test $# -gt 0; do\n  case $1 in\n    --usage)          show_usage;         exit 0;;\n    --help)           show_help;          exit 0;;\n\n    # Installation overrides\n    --prefix=*)       GMOCK_PREFIX=${1#--prefix=};;\n    --exec-prefix=*)  GMOCK_EXEC_PREFIX=${1#--exec-prefix=};;\n    --libdir=*)       GMOCK_LIBDIR=${1#--libdir=};;\n    --includedir=*)   GMOCK_INCLUDEDIR=${1#--includedir=};;\n\n    # Installation queries\n    --prefix|--exec-prefix|--libdir|--includedir|--version)\n      if test -n \"${do_query}\"; then\n        show_usage\n        exit 1\n      fi\n      do_query=${1#--}\n      ;;\n\n    # Version checking\n    --min-version=*)\n      do_check_versions=yes\n      min_version=${1#--min-version=}\n      ;;\n    --max-version=*)\n      do_check_versions=yes\n      max_version=${1#--max-version=}\n      ;;\n    --exact-version=*)\n      do_check_versions=yes\n      exact_version=${1#--exact-version=}\n      ;;\n\n    # Compiler flag output\n    --cppflags)       echo_cppflags=yes;;\n    --cxxflags)       echo_cxxflags=yes;;\n    --ldflags)        echo_ldflags=yes;;\n    --libs)           echo_libs=yes;;\n\n    # Everything else is an error\n    *)                show_usage;         exit 1;;\n  esac\n  shift\ndone\n\n# These have defaults filled in by the configure script but can also be\n# overridden by environment variables or command line parameters.\nprefix=\"${GMOCK_PREFIX:-@prefix@}\"\nexec_prefix=\"${GMOCK_EXEC_PREFIX:-@exec_prefix@}\"\nlibdir=\"${GMOCK_LIBDIR:-@libdir@}\"\nincludedir=\"${GMOCK_INCLUDEDIR:-@includedir@}\"\n\n# We try and detect if our binary is not located at its installed location. If\n# it's not, we provide variables pointing to the source and build tree rather\n# than to the install tree. We also locate Google Test using the configured\n# gtest-config script rather than searching the PATH and our bindir for one.\n# This allows building against a just-built gmock rather than an installed\n# gmock.\nbindir=\"@bindir@\"\nthis_relative_bindir=`dirname $0`\nthis_bindir=`cd ${this_relative_bindir}; pwd -P`\nif test \"${this_bindir}\" = \"${this_bindir%${bindir}}\"; then\n  # The path to the script doesn't end in the bindir sequence from Autoconf,\n  # assume that we are in a build tree.\n  build_dir=`dirname ${this_bindir}`\n  src_dir=`cd ${this_bindir}/@top_srcdir@; pwd -P`\n\n  # TODO(chandlerc@google.com): This is a dangerous dependency on libtool, we\n  # should work to remove it, and/or remove libtool altogether, replacing it\n  # with direct references to the library and a link path.\n  gmock_libs=\"${build_dir}/lib/libgmock.la\"\n  gmock_ldflags=\"\"\n\n  # We provide hooks to include from either the source or build dir, where the\n  # build dir is always preferred. This will potentially allow us to write\n  # build rules for generated headers and have them automatically be preferred\n  # over provided versions.\n  gmock_cppflags=\"-I${build_dir}/include -I${src_dir}/include\"\n  gmock_cxxflags=\"\"\n\n  # Directly invoke the gtest-config script used during the build process.\n  gtest_config=\"@GTEST_CONFIG@\"\nelse\n  # We're using an installed gmock, although it may be staged under some\n  # prefix. Assume (as our own libraries do) that we can resolve the prefix,\n  # and are present in the dynamic link paths.\n  gmock_ldflags=\"-L${libdir}\"\n  gmock_libs=\"-l${name}\"\n  gmock_cppflags=\"-I${includedir}\"\n  gmock_cxxflags=\"\"\n\n  # We also prefer any gtest-config script installed in our prefix. Lacking\n  # one, we look in the PATH for one.\n  gtest_config=\"${bindir}/gtest-config\"\n  if test ! -x \"${gtest_config}\"; then\n    gtest_config=`which gtest-config`\n  fi\nfi\n\n# Ensure that we have located a Google Test to link against.\nif ! test -x \"${gtest_config}\"; then\n  echo \"Unable to locate Google Test, check your Google Mock configuration\" \\\n       \"and installation\" >&2\n  exit 1\nelif ! \"${gtest_config}\" \"--exact-version=@GTEST_VERSION@\"; then\n  echo \"The Google Test found is not the same version as Google Mock was \" \\\n       \"built against\" >&2\n  exit 1\nfi\n\n# Add the necessary Google Test bits into the various flag variables\ngmock_cppflags=\"${gmock_cppflags} `${gtest_config} --cppflags`\"\ngmock_cxxflags=\"${gmock_cxxflags} `${gtest_config} --cxxflags`\"\ngmock_ldflags=\"${gmock_ldflags} `${gtest_config} --ldflags`\"\ngmock_libs=\"${gmock_libs} `${gtest_config} --libs`\"\n\n# Do an installation query if requested.\nif test -n \"$do_query\"; then\n  case $do_query in\n    prefix)           echo $prefix;       exit 0;;\n    exec-prefix)      echo $exec_prefix;  exit 0;;\n    libdir)           echo $libdir;       exit 0;;\n    includedir)       echo $includedir;   exit 0;;\n    version)          echo $version;      exit 0;;\n    *)                show_usage;         exit 1;;\n  esac\nfi\n\n# Do a version check if requested.\nif test \"$do_check_versions\" = \"yes\"; then\n  # Make sure we didn't receive a bad combination of parameters.\n  test \"$echo_cppflags\" = \"yes\" && show_usage && exit 1\n  test \"$echo_cxxflags\" = \"yes\" && show_usage && exit 1\n  test \"$echo_ldflags\" = \"yes\"  && show_usage && exit 1\n  test \"$echo_libs\" = \"yes\"     && show_usage && exit 1\n\n  if test \"$exact_version\" != \"\"; then\n    check_versions $exact_version $exact_version\n    # unreachable\n  else\n    check_versions ${min_version:-0.0.0} ${max_version:-9999.9999.9999}\n    # unreachable\n  fi\nfi\n\n# Do the output in the correct order so that these can be used in-line of\n# a compiler invocation.\noutput=\"\"\ntest \"$echo_cppflags\" = \"yes\" && output=\"$output $gmock_cppflags\"\ntest \"$echo_cxxflags\" = \"yes\" && output=\"$output $gmock_cxxflags\"\ntest \"$echo_ldflags\" = \"yes\"  && output=\"$output $gmock_ldflags\"\ntest \"$echo_libs\" = \"yes\"     && output=\"$output $gmock_libs\"\necho $output\n\nexit 0\n"
  },
  {
    "path": "ext/gmock/scripts/gmock_doctor.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2008, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Converts compiler's errors in code using Google Mock to plain English.\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport re\nimport sys\n\n_VERSION = '1.0.3'\n\n_EMAIL = 'googlemock@googlegroups.com'\n\n_COMMON_GMOCK_SYMBOLS = [\n    # Matchers\n    '_',\n    'A',\n    'AddressSatisfies',\n    'AllOf',\n    'An',\n    'AnyOf',\n    'ContainerEq',\n    'Contains',\n    'ContainsRegex',\n    'DoubleEq',\n    'ElementsAre',\n    'ElementsAreArray',\n    'EndsWith',\n    'Eq',\n    'Field',\n    'FloatEq',\n    'Ge',\n    'Gt',\n    'HasSubstr',\n    'IsInitializedProto',\n    'Le',\n    'Lt',\n    'MatcherCast',\n    'Matches',\n    'MatchesRegex',\n    'NanSensitiveDoubleEq',\n    'NanSensitiveFloatEq',\n    'Ne',\n    'Not',\n    'NotNull',\n    'Pointee',\n    'Property',\n    'Ref',\n    'ResultOf',\n    'SafeMatcherCast',\n    'StartsWith',\n    'StrCaseEq',\n    'StrCaseNe',\n    'StrEq',\n    'StrNe',\n    'Truly',\n    'TypedEq',\n    'Value',\n\n    # Actions\n    'Assign',\n    'ByRef',\n    'DeleteArg',\n    'DoAll',\n    'DoDefault',\n    'IgnoreResult',\n    'Invoke',\n    'InvokeArgument',\n    'InvokeWithoutArgs',\n    'Return',\n    'ReturnNew',\n    'ReturnNull',\n    'ReturnRef',\n    'SaveArg',\n    'SetArgReferee',\n    'SetArgPointee',\n    'SetArgumentPointee',\n    'SetArrayArgument',\n    'SetErrnoAndReturn',\n    'Throw',\n    'WithArg',\n    'WithArgs',\n    'WithoutArgs',\n\n    # Cardinalities\n    'AnyNumber',\n    'AtLeast',\n    'AtMost',\n    'Between',\n    'Exactly',\n\n    # Sequences\n    'InSequence',\n    'Sequence',\n\n    # Misc\n    'DefaultValue',\n    'Mock',\n    ]\n\n# Regex for matching source file path and line number in the compiler's errors.\n_GCC_FILE_LINE_RE = r'(?P<file>.*):(?P<line>\\d+):(\\d+:)?\\s+'\n_CLANG_FILE_LINE_RE = r'(?P<file>.*):(?P<line>\\d+):(?P<column>\\d+):\\s+'\n_CLANG_NON_GMOCK_FILE_LINE_RE = (\n    r'(?P<file>.*[/\\\\^](?!gmock-)[^/\\\\]+):(?P<line>\\d+):(?P<column>\\d+):\\s+')\n\n\ndef _FindAllMatches(regex, s):\n  \"\"\"Generates all matches of regex in string s.\"\"\"\n\n  r = re.compile(regex)\n  return r.finditer(s)\n\n\ndef _GenericDiagnoser(short_name, long_name, diagnoses, msg):\n  \"\"\"Diagnoses the given disease by pattern matching.\n\n  Can provide different diagnoses for different patterns.\n\n  Args:\n    short_name: Short name of the disease.\n    long_name:  Long name of the disease.\n    diagnoses:  A list of pairs (regex, pattern for formatting the diagnosis\n                for matching regex).\n    msg:        Compiler's error messages.\n  Yields:\n    Tuples of the form\n      (short name of disease, long name of disease, diagnosis).\n  \"\"\"\n  for regex, diagnosis in diagnoses:\n    if re.search(regex, msg):\n      diagnosis = '%(file)s:%(line)s:' + diagnosis\n      for m in _FindAllMatches(regex, msg):\n        yield (short_name, long_name, diagnosis % m.groupdict())\n\n\ndef _NeedToReturnReferenceDiagnoser(msg):\n  \"\"\"Diagnoses the NRR disease, given the error messages by the compiler.\"\"\"\n\n  gcc_regex = (r'In member function \\'testing::internal::ReturnAction<R>.*\\n'\n               + _GCC_FILE_LINE_RE + r'instantiated from here\\n'\n               r'.*gmock-actions\\.h.*error: creating array with negative size')\n  clang_regex = (r'error:.*array.*negative.*\\r?\\n'\n                 r'(.*\\n)*?' +\n                 _CLANG_NON_GMOCK_FILE_LINE_RE +\n                 r'note: in instantiation of function template specialization '\n                 r'\\'testing::internal::ReturnAction<(?P<type>.*)>'\n                 r'::operator Action<.*>\\' requested here')\n  diagnosis = \"\"\"\nYou are using a Return() action in a function that returns a reference to\n%(type)s.  Please use ReturnRef() instead.\"\"\"\n  return _GenericDiagnoser('NRR', 'Need to Return Reference',\n                           [(clang_regex, diagnosis),\n                            (gcc_regex, diagnosis % {'type': 'a type'})],\n                           msg)\n\n\ndef _NeedToReturnSomethingDiagnoser(msg):\n  \"\"\"Diagnoses the NRS disease, given the error messages by the compiler.\"\"\"\n\n  gcc_regex = (_GCC_FILE_LINE_RE + r'(instantiated from here\\n.'\n               r'*gmock.*actions\\.h.*error: void value not ignored)'\n               r'|(error: control reaches end of non-void function)')\n  clang_regex1 = (_CLANG_FILE_LINE_RE +\n                  r'error: cannot initialize return object '\n                  r'of type \\'Result\\' \\(aka \\'(?P<return_type>.*)\\'\\) '\n                  r'with an rvalue of type \\'void\\'')\n  clang_regex2 = (_CLANG_FILE_LINE_RE +\n                  r'error: cannot initialize return object '\n                  r'of type \\'(?P<return_type>.*)\\' '\n                  r'with an rvalue of type \\'void\\'')\n  diagnosis = \"\"\"\nYou are using an action that returns void, but it needs to return\n%(return_type)s.  Please tell it *what* to return.  Perhaps you can use\nthe pattern DoAll(some_action, Return(some_value))?\"\"\"\n  return _GenericDiagnoser(\n      'NRS',\n      'Need to Return Something',\n      [(gcc_regex, diagnosis % {'return_type': '*something*'}),\n       (clang_regex1, diagnosis),\n       (clang_regex2, diagnosis)],\n      msg)\n\n\ndef _NeedToReturnNothingDiagnoser(msg):\n  \"\"\"Diagnoses the NRN disease, given the error messages by the compiler.\"\"\"\n\n  gcc_regex = (_GCC_FILE_LINE_RE + r'instantiated from here\\n'\n               r'.*gmock-actions\\.h.*error: instantiation of '\n               r'\\'testing::internal::ReturnAction<R>::Impl<F>::value_\\' '\n               r'as type \\'void\\'')\n  clang_regex1 = (r'error: field has incomplete type '\n                  r'\\'Result\\' \\(aka \\'void\\'\\)(\\r)?\\n'\n                  r'(.*\\n)*?' +\n                  _CLANG_NON_GMOCK_FILE_LINE_RE + r'note: in instantiation '\n                  r'of function template specialization '\n                  r'\\'testing::internal::ReturnAction<(?P<return_type>.*)>'\n                  r'::operator Action<void \\(.*\\)>\\' requested here')\n  clang_regex2 = (r'error: field has incomplete type '\n                  r'\\'Result\\' \\(aka \\'void\\'\\)(\\r)?\\n'\n                  r'(.*\\n)*?' +\n                  _CLANG_NON_GMOCK_FILE_LINE_RE + r'note: in instantiation '\n                  r'of function template specialization '\n                  r'\\'testing::internal::DoBothAction<.*>'\n                  r'::operator Action<(?P<return_type>.*) \\(.*\\)>\\' '\n                  r'requested here')\n  diagnosis = \"\"\"\nYou are using an action that returns %(return_type)s, but it needs to return\nvoid.  Please use a void-returning action instead.\n\nAll actions but the last in DoAll(...) must return void.  Perhaps you need\nto re-arrange the order of actions in a DoAll(), if you are using one?\"\"\"\n  return _GenericDiagnoser(\n      'NRN',\n      'Need to Return Nothing',\n      [(gcc_regex, diagnosis % {'return_type': '*something*'}),\n       (clang_regex1, diagnosis),\n       (clang_regex2, diagnosis)],\n      msg)\n\n\ndef _IncompleteByReferenceArgumentDiagnoser(msg):\n  \"\"\"Diagnoses the IBRA disease, given the error messages by the compiler.\"\"\"\n\n  gcc_regex = (_GCC_FILE_LINE_RE + r'instantiated from here\\n'\n               r'.*gtest-printers\\.h.*error: invalid application of '\n               r'\\'sizeof\\' to incomplete type \\'(?P<type>.*)\\'')\n\n  clang_regex = (r'.*gtest-printers\\.h.*error: invalid application of '\n                 r'\\'sizeof\\' to an incomplete type '\n                 r'\\'(?P<type>.*)( const)?\\'\\r?\\n'\n                 r'(.*\\n)*?' +\n                 _CLANG_NON_GMOCK_FILE_LINE_RE +\n                 r'note: in instantiation of member function '\n                 r'\\'testing::internal2::TypeWithoutFormatter<.*>::'\n                 r'PrintValue\\' requested here')\n  diagnosis = \"\"\"\nIn order to mock this function, Google Mock needs to see the definition\nof type \"%(type)s\" - declaration alone is not enough.  Either #include\nthe header that defines it, or change the argument to be passed\nby pointer.\"\"\"\n\n  return _GenericDiagnoser('IBRA', 'Incomplete By-Reference Argument Type',\n                           [(gcc_regex, diagnosis),\n                            (clang_regex, diagnosis)],\n                           msg)\n\n\ndef _OverloadedFunctionMatcherDiagnoser(msg):\n  \"\"\"Diagnoses the OFM disease, given the error messages by the compiler.\"\"\"\n\n  gcc_regex = (_GCC_FILE_LINE_RE + r'error: no matching function for '\n               r'call to \\'Truly\\(<unresolved overloaded function type>\\)')\n  clang_regex = (_CLANG_FILE_LINE_RE + r'error: no matching function for '\n                 r'call to \\'Truly')\n  diagnosis = \"\"\"\nThe argument you gave to Truly() is an overloaded function.  Please tell\nyour compiler which overloaded version you want to use.\n\nFor example, if you want to use the version whose signature is\n  bool Foo(int n);\nyou should write\n  Truly(static_cast<bool (*)(int n)>(Foo))\"\"\"\n  return _GenericDiagnoser('OFM', 'Overloaded Function Matcher',\n                           [(gcc_regex, diagnosis),\n                            (clang_regex, diagnosis)],\n                           msg)\n\n\ndef _OverloadedFunctionActionDiagnoser(msg):\n  \"\"\"Diagnoses the OFA disease, given the error messages by the compiler.\"\"\"\n\n  gcc_regex = (_GCC_FILE_LINE_RE + r'error: no matching function for call to '\n               r'\\'Invoke\\(<unresolved overloaded function type>')\n  clang_regex = (_CLANG_FILE_LINE_RE + r'error: no matching '\n                 r'function for call to \\'Invoke\\'\\r?\\n'\n                 r'(.*\\n)*?'\n                 r'.*\\bgmock-\\w+-actions\\.h:\\d+:\\d+:\\s+'\n                 r'note: candidate template ignored:\\s+'\n                 r'couldn\\'t infer template argument \\'FunctionImpl\\'')\n  diagnosis = \"\"\"\nFunction you are passing to Invoke is overloaded.  Please tell your compiler\nwhich overloaded version you want to use.\n\nFor example, if you want to use the version whose signature is\n  bool MyFunction(int n, double x);\nyou should write something like\n  Invoke(static_cast<bool (*)(int n, double x)>(MyFunction))\"\"\"\n  return _GenericDiagnoser('OFA', 'Overloaded Function Action',\n                           [(gcc_regex, diagnosis),\n                            (clang_regex, diagnosis)],\n                           msg)\n\n\ndef _OverloadedMethodActionDiagnoser(msg):\n  \"\"\"Diagnoses the OMA disease, given the error messages by the compiler.\"\"\"\n\n  gcc_regex = (_GCC_FILE_LINE_RE + r'error: no matching function for '\n               r'call to \\'Invoke\\(.+, <unresolved overloaded function '\n               r'type>\\)')\n  clang_regex = (_CLANG_FILE_LINE_RE + r'error: no matching function '\n                 r'for call to \\'Invoke\\'\\r?\\n'\n                 r'(.*\\n)*?'\n                 r'.*\\bgmock-\\w+-actions\\.h:\\d+:\\d+: '\n                 r'note: candidate function template not viable: '\n                 r'requires .*, but 2 (arguments )?were provided')\n  diagnosis = \"\"\"\nThe second argument you gave to Invoke() is an overloaded method.  Please\ntell your compiler which overloaded version you want to use.\n\nFor example, if you want to use the version whose signature is\n  class Foo {\n    ...\n    bool Bar(int n, double x);\n  };\nyou should write something like\n  Invoke(foo, static_cast<bool (Foo::*)(int n, double x)>(&Foo::Bar))\"\"\"\n  return _GenericDiagnoser('OMA', 'Overloaded Method Action',\n                           [(gcc_regex, diagnosis),\n                            (clang_regex, diagnosis)],\n                           msg)\n\n\ndef _MockObjectPointerDiagnoser(msg):\n  \"\"\"Diagnoses the MOP disease, given the error messages by the compiler.\"\"\"\n\n  gcc_regex = (_GCC_FILE_LINE_RE + r'error: request for member '\n               r'\\'gmock_(?P<method>.+)\\' in \\'(?P<mock_object>.+)\\', '\n               r'which is of non-class type \\'(.*::)*(?P<class_name>.+)\\*\\'')\n  clang_regex = (_CLANG_FILE_LINE_RE + r'error: member reference type '\n                 r'\\'(?P<class_name>.*?) *\\' is a pointer; '\n                 r'maybe you meant to use \\'->\\'\\?')\n  diagnosis = \"\"\"\nThe first argument to ON_CALL() and EXPECT_CALL() must be a mock *object*,\nnot a *pointer* to it.  Please write '*(%(mock_object)s)' instead of\n'%(mock_object)s' as your first argument.\n\nFor example, given the mock class:\n\n  class %(class_name)s : public ... {\n    ...\n    MOCK_METHOD0(%(method)s, ...);\n  };\n\nand the following mock instance:\n\n  %(class_name)s* mock_ptr = ...\n\nyou should use the EXPECT_CALL like this:\n\n  EXPECT_CALL(*mock_ptr, %(method)s(...));\"\"\"\n\n  return _GenericDiagnoser(\n      'MOP',\n      'Mock Object Pointer',\n      [(gcc_regex, diagnosis),\n       (clang_regex, diagnosis % {'mock_object': 'mock_object',\n                                  'method': 'method',\n                                  'class_name': '%(class_name)s'})],\n       msg)\n\n\ndef _NeedToUseSymbolDiagnoser(msg):\n  \"\"\"Diagnoses the NUS disease, given the error messages by the compiler.\"\"\"\n\n  gcc_regex = (_GCC_FILE_LINE_RE + r'error: \\'(?P<symbol>.+)\\' '\n               r'(was not declared in this scope|has not been declared)')\n  clang_regex = (_CLANG_FILE_LINE_RE +\n                 r'error: (use of undeclared identifier|unknown type name|'\n                 r'no template named) \\'(?P<symbol>[^\\']+)\\'')\n  diagnosis = \"\"\"\n'%(symbol)s' is defined by Google Mock in the testing namespace.\nDid you forget to write\n  using testing::%(symbol)s;\n?\"\"\"\n  for m in (list(_FindAllMatches(gcc_regex, msg)) +\n            list(_FindAllMatches(clang_regex, msg))):\n    symbol = m.groupdict()['symbol']\n    if symbol in _COMMON_GMOCK_SYMBOLS:\n      yield ('NUS', 'Need to Use Symbol', diagnosis % m.groupdict())\n\n\ndef _NeedToUseReturnNullDiagnoser(msg):\n  \"\"\"Diagnoses the NRNULL disease, given the error messages by the compiler.\"\"\"\n\n  gcc_regex = ('instantiated from \\'testing::internal::ReturnAction<R>'\n               '::operator testing::Action<Func>\\(\\) const.*\\n' +\n               _GCC_FILE_LINE_RE + r'instantiated from here\\n'\n               r'.*error: no matching function for call to \\'ImplicitCast_\\('\n               r'(:?long )?int&\\)')\n  clang_regex = (r'\\bgmock-actions.h:.* error: no matching function for '\n                 r'call to \\'ImplicitCast_\\'\\r?\\n'\n                 r'(.*\\n)*?' +\n                 _CLANG_NON_GMOCK_FILE_LINE_RE + r'note: in instantiation '\n                 r'of function template specialization '\n                 r'\\'testing::internal::ReturnAction<(int|long)>::operator '\n                 r'Action<(?P<type>.*)\\(\\)>\\' requested here')\n  diagnosis = \"\"\"\nYou are probably calling Return(NULL) and the compiler isn't sure how to turn\nNULL into %(type)s. Use ReturnNull() instead.\nNote: the line number may be off; please fix all instances of Return(NULL).\"\"\"\n  return _GenericDiagnoser(\n      'NRNULL', 'Need to use ReturnNull',\n      [(clang_regex, diagnosis),\n       (gcc_regex, diagnosis % {'type': 'the right type'})],\n      msg)\n\n\ndef _TypeInTemplatedBaseDiagnoser(msg):\n  \"\"\"Diagnoses the TTB disease, given the error messages by the compiler.\"\"\"\n\n  # This version works when the type is used as the mock function's return\n  # type.\n  gcc_4_3_1_regex_type_in_retval = (\n      r'In member function \\'int .*\\n' + _GCC_FILE_LINE_RE +\n      r'error: a function call cannot appear in a constant-expression')\n  gcc_4_4_0_regex_type_in_retval = (\n      r'error: a function call cannot appear in a constant-expression'\n      + _GCC_FILE_LINE_RE + r'error: template argument 1 is invalid\\n')\n  # This version works when the type is used as the mock function's sole\n  # parameter type.\n  gcc_regex_type_of_sole_param = (\n      _GCC_FILE_LINE_RE +\n      r'error: \\'(?P<type>.+)\\' was not declared in this scope\\n'\n      r'.*error: template argument 1 is invalid\\n')\n  # This version works when the type is used as a parameter of a mock\n  # function that has multiple parameters.\n  gcc_regex_type_of_a_param = (\n      r'error: expected `;\\' before \\'::\\' token\\n'\n      + _GCC_FILE_LINE_RE +\n      r'error: \\'(?P<type>.+)\\' was not declared in this scope\\n'\n      r'.*error: template argument 1 is invalid\\n'\n      r'.*error: \\'.+\\' was not declared in this scope')\n  clang_regex_type_of_retval_or_sole_param = (\n      _CLANG_FILE_LINE_RE +\n      r'error: use of undeclared identifier \\'(?P<type>.*)\\'\\n'\n      r'(.*\\n)*?'\n      r'(?P=file):(?P=line):\\d+: error: '\n      r'non-friend class member \\'Result\\' cannot have a qualified name'\n      )\n  clang_regex_type_of_a_param = (\n      _CLANG_FILE_LINE_RE +\n      r'error: C\\+\\+ requires a type specifier for all declarations\\n'\n      r'(.*\\n)*?'\n      r'(?P=file):(?P=line):(?P=column): error: '\n      r'C\\+\\+ requires a type specifier for all declarations'\n      )\n  clang_regex_unknown_type = (\n      _CLANG_FILE_LINE_RE +\n      r'error: unknown type name \\'(?P<type>[^\\']+)\\''\n      )\n\n  diagnosis = \"\"\"\nIn a mock class template, types or typedefs defined in the base class\ntemplate are *not* automatically visible.  This is how C++ works.  Before\nyou can use a type or typedef named %(type)s defined in base class Base<T>, you\nneed to make it visible.  One way to do it is:\n\n  typedef typename Base<T>::%(type)s %(type)s;\"\"\"\n\n  for diag in _GenericDiagnoser(\n      'TTB', 'Type in Template Base',\n      [(gcc_4_3_1_regex_type_in_retval, diagnosis % {'type': 'Foo'}),\n       (gcc_4_4_0_regex_type_in_retval, diagnosis % {'type': 'Foo'}),\n       (gcc_regex_type_of_sole_param, diagnosis),\n       (gcc_regex_type_of_a_param, diagnosis),\n       (clang_regex_type_of_retval_or_sole_param, diagnosis),\n       (clang_regex_type_of_a_param, diagnosis % {'type': 'Foo'})],\n      msg):\n    yield diag\n  # Avoid overlap with the NUS pattern.\n  for m in _FindAllMatches(clang_regex_unknown_type, msg):\n    type_ = m.groupdict()['type']\n    if type_ not in _COMMON_GMOCK_SYMBOLS:\n      yield ('TTB', 'Type in Template Base', diagnosis % m.groupdict())\n\n\ndef _WrongMockMethodMacroDiagnoser(msg):\n  \"\"\"Diagnoses the WMM disease, given the error messages by the compiler.\"\"\"\n\n  gcc_regex = (_GCC_FILE_LINE_RE +\n               r'.*this_method_does_not_take_(?P<wrong_args>\\d+)_argument.*\\n'\n               r'.*\\n'\n               r'.*candidates are.*FunctionMocker<[^>]+A(?P<args>\\d+)\\)>')\n  clang_regex = (_CLANG_NON_GMOCK_FILE_LINE_RE +\n                 r'error:.*array.*negative.*r?\\n'\n                 r'(.*\\n)*?'\n                 r'(?P=file):(?P=line):(?P=column): error: too few arguments '\n                 r'to function call, expected (?P<args>\\d+), '\n                 r'have (?P<wrong_args>\\d+)')\n  diagnosis = \"\"\"\nYou are using MOCK_METHOD%(wrong_args)s to define a mock method that has\n%(args)s arguments. Use MOCK_METHOD%(args)s (or MOCK_CONST_METHOD%(args)s,\nMOCK_METHOD%(args)s_T, MOCK_CONST_METHOD%(args)s_T as appropriate) instead.\"\"\"\n  return _GenericDiagnoser('WMM', 'Wrong MOCK_METHODn Macro',\n                           [(gcc_regex, diagnosis),\n                            (clang_regex, diagnosis)],\n                           msg)\n\n\ndef _WrongParenPositionDiagnoser(msg):\n  \"\"\"Diagnoses the WPP disease, given the error messages by the compiler.\"\"\"\n\n  gcc_regex = (_GCC_FILE_LINE_RE +\n               r'error:.*testing::internal::MockSpec<.* has no member named \\''\n               r'(?P<method>\\w+)\\'')\n  clang_regex = (_CLANG_NON_GMOCK_FILE_LINE_RE +\n                 r'error: no member named \\'(?P<method>\\w+)\\' in '\n                 r'\\'testing::internal::MockSpec<.*>\\'')\n  diagnosis = \"\"\"\nThe closing parenthesis of ON_CALL or EXPECT_CALL should be *before*\n\".%(method)s\".  For example, you should write:\n  EXPECT_CALL(my_mock, Foo(_)).%(method)s(...);\ninstead of:\n  EXPECT_CALL(my_mock, Foo(_).%(method)s(...));\"\"\"\n  return _GenericDiagnoser('WPP', 'Wrong Parenthesis Position',\n                           [(gcc_regex, diagnosis),\n                            (clang_regex, diagnosis)],\n                           msg)\n\n\n_DIAGNOSERS = [\n    _IncompleteByReferenceArgumentDiagnoser,\n    _MockObjectPointerDiagnoser,\n    _NeedToReturnNothingDiagnoser,\n    _NeedToReturnReferenceDiagnoser,\n    _NeedToReturnSomethingDiagnoser,\n    _NeedToUseReturnNullDiagnoser,\n    _NeedToUseSymbolDiagnoser,\n    _OverloadedFunctionActionDiagnoser,\n    _OverloadedFunctionMatcherDiagnoser,\n    _OverloadedMethodActionDiagnoser,\n    _TypeInTemplatedBaseDiagnoser,\n    _WrongMockMethodMacroDiagnoser,\n    _WrongParenPositionDiagnoser,\n    ]\n\n\ndef Diagnose(msg):\n  \"\"\"Generates all possible diagnoses given the compiler error message.\"\"\"\n\n  msg = re.sub(r'\\x1b\\[[^m]*m', '', msg)  # Strips all color formatting.\n  # Assuming the string is using the UTF-8 encoding, replaces the left and\n  # the right single quote characters with apostrophes.\n  msg = re.sub(r'(\\xe2\\x80\\x98|\\xe2\\x80\\x99)', \"'\", msg)\n\n  diagnoses = []\n  for diagnoser in _DIAGNOSERS:\n    for diag in diagnoser(msg):\n      diagnosis = '[%s - %s]\\n%s' % diag\n      if not diagnosis in diagnoses:\n        diagnoses.append(diagnosis)\n  return diagnoses\n\n\ndef main():\n  print ('Google Mock Doctor v%s - '\n         'diagnoses problems in code using Google Mock.' % _VERSION)\n\n  if sys.stdin.isatty():\n    print ('Please copy and paste the compiler errors here.  Press c-D when '\n           'you are done:')\n  else:\n    print 'Waiting for compiler errors on stdin . . .'\n\n  msg = sys.stdin.read().strip()\n  diagnoses = Diagnose(msg)\n  count = len(diagnoses)\n  if not count:\n    print (\"\"\"\nYour compiler complained:\n8<------------------------------------------------------------\n%s\n------------------------------------------------------------>8\n\nUh-oh, I'm not smart enough to figure out what the problem is. :-(\nHowever...\nIf you send your source code and the compiler's error messages to\n%s, you can be helped and I can get smarter --\nwin-win for us!\"\"\" % (msg, _EMAIL))\n  else:\n    print '------------------------------------------------------------'\n    print 'Your code appears to have the following',\n    if count > 1:\n      print '%s diseases:' % (count,)\n    else:\n      print 'disease:'\n    i = 0\n    for d in diagnoses:\n      i += 1\n      if count > 1:\n        print '\\n#%s:' % (i,)\n      print d\n    print (\"\"\"\nHow did I do?  If you think I'm wrong or unhelpful, please send your\nsource code and the compiler's error messages to %s.\nThen you can be helped and I can get smarter -- I promise I won't be upset!\"\"\" %\n           _EMAIL)\n\n\nif __name__ == '__main__':\n  main()\n"
  },
  {
    "path": "ext/gmock/scripts/upload.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2007 Google Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Tool for uploading diffs from a version control system to the codereview app.\n\nUsage summary: upload.py [options] [-- diff_options]\n\nDiff options are passed to the diff command of the underlying system.\n\nSupported version control systems:\n  Git\n  Mercurial\n  Subversion\n\nIt is important for Git/Mercurial users to specify a tree/node/branch to diff\nagainst by using the '--rev' option.\n\"\"\"\n# This code is derived from appcfg.py in the App Engine SDK (open source),\n# and from ASPN recipe #146306.\n\nimport cookielib\nimport getpass\nimport logging\nimport md5\nimport mimetypes\nimport optparse\nimport os\nimport re\nimport socket\nimport subprocess\nimport sys\nimport urllib\nimport urllib2\nimport urlparse\n\ntry:\n  import readline\nexcept ImportError:\n  pass\n\n# The logging verbosity:\n#  0: Errors only.\n#  1: Status messages.\n#  2: Info logs.\n#  3: Debug logs.\nverbosity = 1\n\n# Max size of patch or base file.\nMAX_UPLOAD_SIZE = 900 * 1024\n\n\ndef GetEmail(prompt):\n  \"\"\"Prompts the user for their email address and returns it.\n\n  The last used email address is saved to a file and offered up as a suggestion\n  to the user. If the user presses enter without typing in anything the last\n  used email address is used. If the user enters a new address, it is saved\n  for next time we prompt.\n\n  \"\"\"\n  last_email_file_name = os.path.expanduser(\"~/.last_codereview_email_address\")\n  last_email = \"\"\n  if os.path.exists(last_email_file_name):\n    try:\n      last_email_file = open(last_email_file_name, \"r\")\n      last_email = last_email_file.readline().strip(\"\\n\")\n      last_email_file.close()\n      prompt += \" [%s]\" % last_email\n    except IOError, e:\n      pass\n  email = raw_input(prompt + \": \").strip()\n  if email:\n    try:\n      last_email_file = open(last_email_file_name, \"w\")\n      last_email_file.write(email)\n      last_email_file.close()\n    except IOError, e:\n      pass\n  else:\n    email = last_email\n  return email\n\n\ndef StatusUpdate(msg):\n  \"\"\"Print a status message to stdout.\n\n  If 'verbosity' is greater than 0, print the message.\n\n  Args:\n    msg: The string to print.\n  \"\"\"\n  if verbosity > 0:\n    print msg\n\n\ndef ErrorExit(msg):\n  \"\"\"Print an error message to stderr and exit.\"\"\"\n  print >>sys.stderr, msg\n  sys.exit(1)\n\n\nclass ClientLoginError(urllib2.HTTPError):\n  \"\"\"Raised to indicate there was an error authenticating with ClientLogin.\"\"\"\n\n  def __init__(self, url, code, msg, headers, args):\n    urllib2.HTTPError.__init__(self, url, code, msg, headers, None)\n    self.args = args\n    self.reason = args[\"Error\"]\n\n\nclass AbstractRpcServer(object):\n  \"\"\"Provides a common interface for a simple RPC server.\"\"\"\n\n  def __init__(self, host, auth_function, host_override=None, extra_headers={},\n               save_cookies=False):\n    \"\"\"Creates a new HttpRpcServer.\n\n    Args:\n      host: The host to send requests to.\n      auth_function: A function that takes no arguments and returns an\n        (email, password) tuple when called. Will be called if authentication\n        is required.\n      host_override: The host header to send to the server (defaults to host).\n      extra_headers: A dict of extra headers to append to every request.\n      save_cookies: If True, save the authentication cookies to local disk.\n        If False, use an in-memory cookiejar instead.  Subclasses must\n        implement this functionality.  Defaults to False.\n    \"\"\"\n    self.host = host\n    self.host_override = host_override\n    self.auth_function = auth_function\n    self.authenticated = False\n    self.extra_headers = extra_headers\n    self.save_cookies = save_cookies\n    self.opener = self._GetOpener()\n    if self.host_override:\n      logging.info(\"Server: %s; Host: %s\", self.host, self.host_override)\n    else:\n      logging.info(\"Server: %s\", self.host)\n\n  def _GetOpener(self):\n    \"\"\"Returns an OpenerDirector for making HTTP requests.\n\n    Returns:\n      A urllib2.OpenerDirector object.\n    \"\"\"\n    raise NotImplementedError()\n\n  def _CreateRequest(self, url, data=None):\n    \"\"\"Creates a new urllib request.\"\"\"\n    logging.debug(\"Creating request for: '%s' with payload:\\n%s\", url, data)\n    req = urllib2.Request(url, data=data)\n    if self.host_override:\n      req.add_header(\"Host\", self.host_override)\n    for key, value in self.extra_headers.iteritems():\n      req.add_header(key, value)\n    return req\n\n  def _GetAuthToken(self, email, password):\n    \"\"\"Uses ClientLogin to authenticate the user, returning an auth token.\n\n    Args:\n      email:    The user's email address\n      password: The user's password\n\n    Raises:\n      ClientLoginError: If there was an error authenticating with ClientLogin.\n      HTTPError: If there was some other form of HTTP error.\n\n    Returns:\n      The authentication token returned by ClientLogin.\n    \"\"\"\n    account_type = \"GOOGLE\"\n    if self.host.endswith(\".google.com\"):\n      # Needed for use inside Google.\n      account_type = \"HOSTED\"\n    req = self._CreateRequest(\n        url=\"https://www.google.com/accounts/ClientLogin\",\n        data=urllib.urlencode({\n            \"Email\": email,\n            \"Passwd\": password,\n            \"service\": \"ah\",\n            \"source\": \"rietveld-codereview-upload\",\n            \"accountType\": account_type,\n        }),\n    )\n    try:\n      response = self.opener.open(req)\n      response_body = response.read()\n      response_dict = dict(x.split(\"=\")\n                           for x in response_body.split(\"\\n\") if x)\n      return response_dict[\"Auth\"]\n    except urllib2.HTTPError, e:\n      if e.code == 403:\n        body = e.read()\n        response_dict = dict(x.split(\"=\", 1) for x in body.split(\"\\n\") if x)\n        raise ClientLoginError(req.get_full_url(), e.code, e.msg,\n                               e.headers, response_dict)\n      else:\n        raise\n\n  def _GetAuthCookie(self, auth_token):\n    \"\"\"Fetches authentication cookies for an authentication token.\n\n    Args:\n      auth_token: The authentication token returned by ClientLogin.\n\n    Raises:\n      HTTPError: If there was an error fetching the authentication cookies.\n    \"\"\"\n    # This is a dummy value to allow us to identify when we're successful.\n    continue_location = \"http://localhost/\"\n    args = {\"continue\": continue_location, \"auth\": auth_token}\n    req = self._CreateRequest(\"http://%s/_ah/login?%s\" %\n                              (self.host, urllib.urlencode(args)))\n    try:\n      response = self.opener.open(req)\n    except urllib2.HTTPError, e:\n      response = e\n    if (response.code != 302 or\n        response.info()[\"location\"] != continue_location):\n      raise urllib2.HTTPError(req.get_full_url(), response.code, response.msg,\n                              response.headers, response.fp)\n    self.authenticated = True\n\n  def _Authenticate(self):\n    \"\"\"Authenticates the user.\n\n    The authentication process works as follows:\n     1) We get a username and password from the user\n     2) We use ClientLogin to obtain an AUTH token for the user\n        (see http://code.google.com/apis/accounts/AuthForInstalledApps.html).\n     3) We pass the auth token to /_ah/login on the server to obtain an\n        authentication cookie. If login was successful, it tries to redirect\n        us to the URL we provided.\n\n    If we attempt to access the upload API without first obtaining an\n    authentication cookie, it returns a 401 response and directs us to\n    authenticate ourselves with ClientLogin.\n    \"\"\"\n    for i in range(3):\n      credentials = self.auth_function()\n      try:\n        auth_token = self._GetAuthToken(credentials[0], credentials[1])\n      except ClientLoginError, e:\n        if e.reason == \"BadAuthentication\":\n          print >>sys.stderr, \"Invalid username or password.\"\n          continue\n        if e.reason == \"CaptchaRequired\":\n          print >>sys.stderr, (\n              \"Please go to\\n\"\n              \"https://www.google.com/accounts/DisplayUnlockCaptcha\\n\"\n              \"and verify you are a human.  Then try again.\")\n          break\n        if e.reason == \"NotVerified\":\n          print >>sys.stderr, \"Account not verified.\"\n          break\n        if e.reason == \"TermsNotAgreed\":\n          print >>sys.stderr, \"User has not agreed to TOS.\"\n          break\n        if e.reason == \"AccountDeleted\":\n          print >>sys.stderr, \"The user account has been deleted.\"\n          break\n        if e.reason == \"AccountDisabled\":\n          print >>sys.stderr, \"The user account has been disabled.\"\n          break\n        if e.reason == \"ServiceDisabled\":\n          print >>sys.stderr, (\"The user's access to the service has been \"\n                               \"disabled.\")\n          break\n        if e.reason == \"ServiceUnavailable\":\n          print >>sys.stderr, \"The service is not available; try again later.\"\n          break\n        raise\n      self._GetAuthCookie(auth_token)\n      return\n\n  def Send(self, request_path, payload=None,\n           content_type=\"application/octet-stream\",\n           timeout=None,\n           **kwargs):\n    \"\"\"Sends an RPC and returns the response.\n\n    Args:\n      request_path: The path to send the request to, eg /api/appversion/create.\n      payload: The body of the request, or None to send an empty request.\n      content_type: The Content-Type header to use.\n      timeout: timeout in seconds; default None i.e. no timeout.\n        (Note: for large requests on OS X, the timeout doesn't work right.)\n      kwargs: Any keyword arguments are converted into query string parameters.\n\n    Returns:\n      The response body, as a string.\n    \"\"\"\n    # TODO: Don't require authentication.  Let the server say\n    # whether it is necessary.\n    if not self.authenticated:\n      self._Authenticate()\n\n    old_timeout = socket.getdefaulttimeout()\n    socket.setdefaulttimeout(timeout)\n    try:\n      tries = 0\n      while True:\n        tries += 1\n        args = dict(kwargs)\n        url = \"http://%s%s\" % (self.host, request_path)\n        if args:\n          url += \"?\" + urllib.urlencode(args)\n        req = self._CreateRequest(url=url, data=payload)\n        req.add_header(\"Content-Type\", content_type)\n        try:\n          f = self.opener.open(req)\n          response = f.read()\n          f.close()\n          return response\n        except urllib2.HTTPError, e:\n          if tries > 3:\n            raise\n          elif e.code == 401:\n            self._Authenticate()\n##           elif e.code >= 500 and e.code < 600:\n##             # Server Error - try again.\n##             continue\n          else:\n            raise\n    finally:\n      socket.setdefaulttimeout(old_timeout)\n\n\nclass HttpRpcServer(AbstractRpcServer):\n  \"\"\"Provides a simplified RPC-style interface for HTTP requests.\"\"\"\n\n  def _Authenticate(self):\n    \"\"\"Save the cookie jar after authentication.\"\"\"\n    super(HttpRpcServer, self)._Authenticate()\n    if self.save_cookies:\n      StatusUpdate(\"Saving authentication cookies to %s\" % self.cookie_file)\n      self.cookie_jar.save()\n\n  def _GetOpener(self):\n    \"\"\"Returns an OpenerDirector that supports cookies and ignores redirects.\n\n    Returns:\n      A urllib2.OpenerDirector object.\n    \"\"\"\n    opener = urllib2.OpenerDirector()\n    opener.add_handler(urllib2.ProxyHandler())\n    opener.add_handler(urllib2.UnknownHandler())\n    opener.add_handler(urllib2.HTTPHandler())\n    opener.add_handler(urllib2.HTTPDefaultErrorHandler())\n    opener.add_handler(urllib2.HTTPSHandler())\n    opener.add_handler(urllib2.HTTPErrorProcessor())\n    if self.save_cookies:\n      self.cookie_file = os.path.expanduser(\"~/.codereview_upload_cookies\")\n      self.cookie_jar = cookielib.MozillaCookieJar(self.cookie_file)\n      if os.path.exists(self.cookie_file):\n        try:\n          self.cookie_jar.load()\n          self.authenticated = True\n          StatusUpdate(\"Loaded authentication cookies from %s\" %\n                       self.cookie_file)\n        except (cookielib.LoadError, IOError):\n          # Failed to load cookies - just ignore them.\n          pass\n      else:\n        # Create an empty cookie file with mode 600\n        fd = os.open(self.cookie_file, os.O_CREAT, 0600)\n        os.close(fd)\n      # Always chmod the cookie file\n      os.chmod(self.cookie_file, 0600)\n    else:\n      # Don't save cookies across runs of update.py.\n      self.cookie_jar = cookielib.CookieJar()\n    opener.add_handler(urllib2.HTTPCookieProcessor(self.cookie_jar))\n    return opener\n\n\nparser = optparse.OptionParser(usage=\"%prog [options] [-- diff_options]\")\nparser.add_option(\"-y\", \"--assume_yes\", action=\"store_true\",\n                  dest=\"assume_yes\", default=False,\n                  help=\"Assume that the answer to yes/no questions is 'yes'.\")\n# Logging\ngroup = parser.add_option_group(\"Logging options\")\ngroup.add_option(\"-q\", \"--quiet\", action=\"store_const\", const=0,\n                 dest=\"verbose\", help=\"Print errors only.\")\ngroup.add_option(\"-v\", \"--verbose\", action=\"store_const\", const=2,\n                 dest=\"verbose\", default=1,\n                 help=\"Print info level logs (default).\")\ngroup.add_option(\"--noisy\", action=\"store_const\", const=3,\n                 dest=\"verbose\", help=\"Print all logs.\")\n# Review server\ngroup = parser.add_option_group(\"Review server options\")\ngroup.add_option(\"-s\", \"--server\", action=\"store\", dest=\"server\",\n                 default=\"codereview.appspot.com\",\n                 metavar=\"SERVER\",\n                 help=(\"The server to upload to. The format is host[:port]. \"\n                       \"Defaults to 'codereview.appspot.com'.\"))\ngroup.add_option(\"-e\", \"--email\", action=\"store\", dest=\"email\",\n                 metavar=\"EMAIL\", default=None,\n                 help=\"The username to use. Will prompt if omitted.\")\ngroup.add_option(\"-H\", \"--host\", action=\"store\", dest=\"host\",\n                 metavar=\"HOST\", default=None,\n                 help=\"Overrides the Host header sent with all RPCs.\")\ngroup.add_option(\"--no_cookies\", action=\"store_false\",\n                 dest=\"save_cookies\", default=True,\n                 help=\"Do not save authentication cookies to local disk.\")\n# Issue\ngroup = parser.add_option_group(\"Issue options\")\ngroup.add_option(\"-d\", \"--description\", action=\"store\", dest=\"description\",\n                 metavar=\"DESCRIPTION\", default=None,\n                 help=\"Optional description when creating an issue.\")\ngroup.add_option(\"-f\", \"--description_file\", action=\"store\",\n                 dest=\"description_file\", metavar=\"DESCRIPTION_FILE\",\n                 default=None,\n                 help=\"Optional path of a file that contains \"\n                      \"the description when creating an issue.\")\ngroup.add_option(\"-r\", \"--reviewers\", action=\"store\", dest=\"reviewers\",\n                 metavar=\"REVIEWERS\", default=None,\n                 help=\"Add reviewers (comma separated email addresses).\")\ngroup.add_option(\"--cc\", action=\"store\", dest=\"cc\",\n                 metavar=\"CC\", default=None,\n                 help=\"Add CC (comma separated email addresses).\")\n# Upload options\ngroup = parser.add_option_group(\"Patch options\")\ngroup.add_option(\"-m\", \"--message\", action=\"store\", dest=\"message\",\n                 metavar=\"MESSAGE\", default=None,\n                 help=\"A message to identify the patch. \"\n                      \"Will prompt if omitted.\")\ngroup.add_option(\"-i\", \"--issue\", type=\"int\", action=\"store\",\n                 metavar=\"ISSUE\", default=None,\n                 help=\"Issue number to which to add. Defaults to new issue.\")\ngroup.add_option(\"--download_base\", action=\"store_true\",\n                 dest=\"download_base\", default=False,\n                 help=\"Base files will be downloaded by the server \"\n                 \"(side-by-side diffs may not work on files with CRs).\")\ngroup.add_option(\"--rev\", action=\"store\", dest=\"revision\",\n                 metavar=\"REV\", default=None,\n                 help=\"Branch/tree/revision to diff against (used by DVCS).\")\ngroup.add_option(\"--send_mail\", action=\"store_true\",\n                 dest=\"send_mail\", default=False,\n                 help=\"Send notification email to reviewers.\")\n\n\ndef GetRpcServer(options):\n  \"\"\"Returns an instance of an AbstractRpcServer.\n\n  Returns:\n    A new AbstractRpcServer, on which RPC calls can be made.\n  \"\"\"\n\n  rpc_server_class = HttpRpcServer\n\n  def GetUserCredentials():\n    \"\"\"Prompts the user for a username and password.\"\"\"\n    email = options.email\n    if email is None:\n      email = GetEmail(\"Email (login for uploading to %s)\" % options.server)\n    password = getpass.getpass(\"Password for %s: \" % email)\n    return (email, password)\n\n  # If this is the dev_appserver, use fake authentication.\n  host = (options.host or options.server).lower()\n  if host == \"localhost\" or host.startswith(\"localhost:\"):\n    email = options.email\n    if email is None:\n      email = \"test@example.com\"\n      logging.info(\"Using debug user %s.  Override with --email\" % email)\n    server = rpc_server_class(\n        options.server,\n        lambda: (email, \"password\"),\n        host_override=options.host,\n        extra_headers={\"Cookie\":\n                       'dev_appserver_login=\"%s:False\"' % email},\n        save_cookies=options.save_cookies)\n    # Don't try to talk to ClientLogin.\n    server.authenticated = True\n    return server\n\n  return rpc_server_class(options.server, GetUserCredentials,\n                          host_override=options.host,\n                          save_cookies=options.save_cookies)\n\n\ndef EncodeMultipartFormData(fields, files):\n  \"\"\"Encode form fields for multipart/form-data.\n\n  Args:\n    fields: A sequence of (name, value) elements for regular form fields.\n    files: A sequence of (name, filename, value) elements for data to be\n           uploaded as files.\n  Returns:\n    (content_type, body) ready for httplib.HTTP instance.\n\n  Source:\n    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306\n  \"\"\"\n  BOUNDARY = '-M-A-G-I-C---B-O-U-N-D-A-R-Y-'\n  CRLF = '\\r\\n'\n  lines = []\n  for (key, value) in fields:\n    lines.append('--' + BOUNDARY)\n    lines.append('Content-Disposition: form-data; name=\"%s\"' % key)\n    lines.append('')\n    lines.append(value)\n  for (key, filename, value) in files:\n    lines.append('--' + BOUNDARY)\n    lines.append('Content-Disposition: form-data; name=\"%s\"; filename=\"%s\"' %\n             (key, filename))\n    lines.append('Content-Type: %s' % GetContentType(filename))\n    lines.append('')\n    lines.append(value)\n  lines.append('--' + BOUNDARY + '--')\n  lines.append('')\n  body = CRLF.join(lines)\n  content_type = 'multipart/form-data; boundary=%s' % BOUNDARY\n  return content_type, body\n\n\ndef GetContentType(filename):\n  \"\"\"Helper to guess the content-type from the filename.\"\"\"\n  return mimetypes.guess_type(filename)[0] or 'application/octet-stream'\n\n\n# Use a shell for subcommands on Windows to get a PATH search.\nuse_shell = sys.platform.startswith(\"win\")\n\ndef RunShellWithReturnCode(command, print_output=False,\n                           universal_newlines=True):\n  \"\"\"Executes a command and returns the output from stdout and the return code.\n\n  Args:\n    command: Command to execute.\n    print_output: If True, the output is printed to stdout.\n                  If False, both stdout and stderr are ignored.\n    universal_newlines: Use universal_newlines flag (default: True).\n\n  Returns:\n    Tuple (output, return code)\n  \"\"\"\n  logging.info(\"Running %s\", command)\n  p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE,\n                       shell=use_shell, universal_newlines=universal_newlines)\n  if print_output:\n    output_array = []\n    while True:\n      line = p.stdout.readline()\n      if not line:\n        break\n      print line.strip(\"\\n\")\n      output_array.append(line)\n    output = \"\".join(output_array)\n  else:\n    output = p.stdout.read()\n  p.wait()\n  errout = p.stderr.read()\n  if print_output and errout:\n    print >>sys.stderr, errout\n  p.stdout.close()\n  p.stderr.close()\n  return output, p.returncode\n\n\ndef RunShell(command, silent_ok=False, universal_newlines=True,\n             print_output=False):\n  data, retcode = RunShellWithReturnCode(command, print_output,\n                                         universal_newlines)\n  if retcode:\n    ErrorExit(\"Got error status from %s:\\n%s\" % (command, data))\n  if not silent_ok and not data:\n    ErrorExit(\"No output from %s\" % command)\n  return data\n\n\nclass VersionControlSystem(object):\n  \"\"\"Abstract base class providing an interface to the VCS.\"\"\"\n\n  def __init__(self, options):\n    \"\"\"Constructor.\n\n    Args:\n      options: Command line options.\n    \"\"\"\n    self.options = options\n\n  def GenerateDiff(self, args):\n    \"\"\"Return the current diff as a string.\n\n    Args:\n      args: Extra arguments to pass to the diff command.\n    \"\"\"\n    raise NotImplementedError(\n        \"abstract method -- subclass %s must override\" % self.__class__)\n\n  def GetUnknownFiles(self):\n    \"\"\"Return a list of files unknown to the VCS.\"\"\"\n    raise NotImplementedError(\n        \"abstract method -- subclass %s must override\" % self.__class__)\n\n  def CheckForUnknownFiles(self):\n    \"\"\"Show an \"are you sure?\" prompt if there are unknown files.\"\"\"\n    unknown_files = self.GetUnknownFiles()\n    if unknown_files:\n      print \"The following files are not added to version control:\"\n      for line in unknown_files:\n        print line\n      prompt = \"Are you sure to continue?(y/N) \"\n      answer = raw_input(prompt).strip()\n      if answer != \"y\":\n        ErrorExit(\"User aborted\")\n\n  def GetBaseFile(self, filename):\n    \"\"\"Get the content of the upstream version of a file.\n\n    Returns:\n      A tuple (base_content, new_content, is_binary, status)\n        base_content: The contents of the base file.\n        new_content: For text files, this is empty.  For binary files, this is\n          the contents of the new file, since the diff output won't contain\n          information to reconstruct the current file.\n        is_binary: True iff the file is binary.\n        status: The status of the file.\n    \"\"\"\n\n    raise NotImplementedError(\n        \"abstract method -- subclass %s must override\" % self.__class__)\n\n\n  def GetBaseFiles(self, diff):\n    \"\"\"Helper that calls GetBase file for each file in the patch.\n\n    Returns:\n      A dictionary that maps from filename to GetBaseFile's tuple.  Filenames\n      are retrieved based on lines that start with \"Index:\" or\n      \"Property changes on:\".\n    \"\"\"\n    files = {}\n    for line in diff.splitlines(True):\n      if line.startswith('Index:') or line.startswith('Property changes on:'):\n        unused, filename = line.split(':', 1)\n        # On Windows if a file has property changes its filename uses '\\'\n        # instead of '/'.\n        filename = filename.strip().replace('\\\\', '/')\n        files[filename] = self.GetBaseFile(filename)\n    return files\n\n\n  def UploadBaseFiles(self, issue, rpc_server, patch_list, patchset, options,\n                      files):\n    \"\"\"Uploads the base files (and if necessary, the current ones as well).\"\"\"\n\n    def UploadFile(filename, file_id, content, is_binary, status, is_base):\n      \"\"\"Uploads a file to the server.\"\"\"\n      file_too_large = False\n      if is_base:\n        type = \"base\"\n      else:\n        type = \"current\"\n      if len(content) > MAX_UPLOAD_SIZE:\n        print (\"Not uploading the %s file for %s because it's too large.\" %\n               (type, filename))\n        file_too_large = True\n        content = \"\"\n      checksum = md5.new(content).hexdigest()\n      if options.verbose > 0 and not file_too_large:\n        print \"Uploading %s file for %s\" % (type, filename)\n      url = \"/%d/upload_content/%d/%d\" % (int(issue), int(patchset), file_id)\n      form_fields = [(\"filename\", filename),\n                     (\"status\", status),\n                     (\"checksum\", checksum),\n                     (\"is_binary\", str(is_binary)),\n                     (\"is_current\", str(not is_base)),\n                    ]\n      if file_too_large:\n        form_fields.append((\"file_too_large\", \"1\"))\n      if options.email:\n        form_fields.append((\"user\", options.email))\n      ctype, body = EncodeMultipartFormData(form_fields,\n                                            [(\"data\", filename, content)])\n      response_body = rpc_server.Send(url, body,\n                                      content_type=ctype)\n      if not response_body.startswith(\"OK\"):\n        StatusUpdate(\"  --> %s\" % response_body)\n        sys.exit(1)\n\n    patches = dict()\n    [patches.setdefault(v, k) for k, v in patch_list]\n    for filename in patches.keys():\n      base_content, new_content, is_binary, status = files[filename]\n      file_id_str = patches.get(filename)\n      if file_id_str.find(\"nobase\") != -1:\n        base_content = None\n        file_id_str = file_id_str[file_id_str.rfind(\"_\") + 1:]\n      file_id = int(file_id_str)\n      if base_content != None:\n        UploadFile(filename, file_id, base_content, is_binary, status, True)\n      if new_content != None:\n        UploadFile(filename, file_id, new_content, is_binary, status, False)\n\n  def IsImage(self, filename):\n    \"\"\"Returns true if the filename has an image extension.\"\"\"\n    mimetype =  mimetypes.guess_type(filename)[0]\n    if not mimetype:\n      return False\n    return mimetype.startswith(\"image/\")\n\n\nclass SubversionVCS(VersionControlSystem):\n  \"\"\"Implementation of the VersionControlSystem interface for Subversion.\"\"\"\n\n  def __init__(self, options):\n    super(SubversionVCS, self).__init__(options)\n    if self.options.revision:\n      match = re.match(r\"(\\d+)(:(\\d+))?\", self.options.revision)\n      if not match:\n        ErrorExit(\"Invalid Subversion revision %s.\" % self.options.revision)\n      self.rev_start = match.group(1)\n      self.rev_end = match.group(3)\n    else:\n      self.rev_start = self.rev_end = None\n    # Cache output from \"svn list -r REVNO dirname\".\n    # Keys: dirname, Values: 2-tuple (ouput for start rev and end rev).\n    self.svnls_cache = {}\n    # SVN base URL is required to fetch files deleted in an older revision.\n    # Result is cached to not guess it over and over again in GetBaseFile().\n    required = self.options.download_base or self.options.revision is not None\n    self.svn_base = self._GuessBase(required)\n\n  def GuessBase(self, required):\n    \"\"\"Wrapper for _GuessBase.\"\"\"\n    return self.svn_base\n\n  def _GuessBase(self, required):\n    \"\"\"Returns the SVN base URL.\n\n    Args:\n      required: If true, exits if the url can't be guessed, otherwise None is\n        returned.\n    \"\"\"\n    info = RunShell([\"svn\", \"info\"])\n    for line in info.splitlines():\n      words = line.split()\n      if len(words) == 2 and words[0] == \"URL:\":\n        url = words[1]\n        scheme, netloc, path, params, query, fragment = urlparse.urlparse(url)\n        username, netloc = urllib.splituser(netloc)\n        if username:\n          logging.info(\"Removed username from base URL\")\n        if netloc.endswith(\"svn.python.org\"):\n          if netloc == \"svn.python.org\":\n            if path.startswith(\"/projects/\"):\n              path = path[9:]\n          elif netloc != \"pythondev@svn.python.org\":\n            ErrorExit(\"Unrecognized Python URL: %s\" % url)\n          base = \"http://svn.python.org/view/*checkout*%s/\" % path\n          logging.info(\"Guessed Python base = %s\", base)\n        elif netloc.endswith(\"svn.collab.net\"):\n          if path.startswith(\"/repos/\"):\n            path = path[6:]\n          base = \"http://svn.collab.net/viewvc/*checkout*%s/\" % path\n          logging.info(\"Guessed CollabNet base = %s\", base)\n        elif netloc.endswith(\".googlecode.com\"):\n          path = path + \"/\"\n          base = urlparse.urlunparse((\"http\", netloc, path, params,\n                                      query, fragment))\n          logging.info(\"Guessed Google Code base = %s\", base)\n        else:\n          path = path + \"/\"\n          base = urlparse.urlunparse((scheme, netloc, path, params,\n                                      query, fragment))\n          logging.info(\"Guessed base = %s\", base)\n        return base\n    if required:\n      ErrorExit(\"Can't find URL in output from svn info\")\n    return None\n\n  def GenerateDiff(self, args):\n    cmd = [\"svn\", \"diff\"]\n    if self.options.revision:\n      cmd += [\"-r\", self.options.revision]\n    cmd.extend(args)\n    data = RunShell(cmd)\n    count = 0\n    for line in data.splitlines():\n      if line.startswith(\"Index:\") or line.startswith(\"Property changes on:\"):\n        count += 1\n        logging.info(line)\n    if not count:\n      ErrorExit(\"No valid patches found in output from svn diff\")\n    return data\n\n  def _CollapseKeywords(self, content, keyword_str):\n    \"\"\"Collapses SVN keywords.\"\"\"\n    # svn cat translates keywords but svn diff doesn't. As a result of this\n    # behavior patching.PatchChunks() fails with a chunk mismatch error.\n    # This part was originally written by the Review Board development team\n    # who had the same problem (http://reviews.review-board.org/r/276/).\n    # Mapping of keywords to known aliases\n    svn_keywords = {\n      # Standard keywords\n      'Date':                ['Date', 'LastChangedDate'],\n      'Revision':            ['Revision', 'LastChangedRevision', 'Rev'],\n      'Author':              ['Author', 'LastChangedBy'],\n      'HeadURL':             ['HeadURL', 'URL'],\n      'Id':                  ['Id'],\n\n      # Aliases\n      'LastChangedDate':     ['LastChangedDate', 'Date'],\n      'LastChangedRevision': ['LastChangedRevision', 'Rev', 'Revision'],\n      'LastChangedBy':       ['LastChangedBy', 'Author'],\n      'URL':                 ['URL', 'HeadURL'],\n    }\n\n    def repl(m):\n       if m.group(2):\n         return \"$%s::%s$\" % (m.group(1), \" \" * len(m.group(3)))\n       return \"$%s$\" % m.group(1)\n    keywords = [keyword\n                for name in keyword_str.split(\" \")\n                for keyword in svn_keywords.get(name, [])]\n    return re.sub(r\"\\$(%s):(:?)([^\\$]+)\\$\" % '|'.join(keywords), repl, content)\n\n  def GetUnknownFiles(self):\n    status = RunShell([\"svn\", \"status\", \"--ignore-externals\"], silent_ok=True)\n    unknown_files = []\n    for line in status.split(\"\\n\"):\n      if line and line[0] == \"?\":\n        unknown_files.append(line)\n    return unknown_files\n\n  def ReadFile(self, filename):\n    \"\"\"Returns the contents of a file.\"\"\"\n    file = open(filename, 'rb')\n    result = \"\"\n    try:\n      result = file.read()\n    finally:\n      file.close()\n    return result\n\n  def GetStatus(self, filename):\n    \"\"\"Returns the status of a file.\"\"\"\n    if not self.options.revision:\n      status = RunShell([\"svn\", \"status\", \"--ignore-externals\", filename])\n      if not status:\n        ErrorExit(\"svn status returned no output for %s\" % filename)\n      status_lines = status.splitlines()\n      # If file is in a cl, the output will begin with\n      # \"\\n--- Changelist 'cl_name':\\n\".  See\n      # http://svn.collab.net/repos/svn/trunk/notes/changelist-design.txt\n      if (len(status_lines) == 3 and\n          not status_lines[0] and\n          status_lines[1].startswith(\"--- Changelist\")):\n        status = status_lines[2]\n      else:\n        status = status_lines[0]\n    # If we have a revision to diff against we need to run \"svn list\"\n    # for the old and the new revision and compare the results to get\n    # the correct status for a file.\n    else:\n      dirname, relfilename = os.path.split(filename)\n      if dirname not in self.svnls_cache:\n        cmd = [\"svn\", \"list\", \"-r\", self.rev_start, dirname or \".\"]\n        out, returncode = RunShellWithReturnCode(cmd)\n        if returncode:\n          ErrorExit(\"Failed to get status for %s.\" % filename)\n        old_files = out.splitlines()\n        args = [\"svn\", \"list\"]\n        if self.rev_end:\n          args += [\"-r\", self.rev_end]\n        cmd = args + [dirname or \".\"]\n        out, returncode = RunShellWithReturnCode(cmd)\n        if returncode:\n          ErrorExit(\"Failed to run command %s\" % cmd)\n        self.svnls_cache[dirname] = (old_files, out.splitlines())\n      old_files, new_files = self.svnls_cache[dirname]\n      if relfilename in old_files and relfilename not in new_files:\n        status = \"D   \"\n      elif relfilename in old_files and relfilename in new_files:\n        status = \"M   \"\n      else:\n        status = \"A   \"\n    return status\n\n  def GetBaseFile(self, filename):\n    status = self.GetStatus(filename)\n    base_content = None\n    new_content = None\n\n    # If a file is copied its status will be \"A  +\", which signifies\n    # \"addition-with-history\".  See \"svn st\" for more information.  We need to\n    # upload the original file or else diff parsing will fail if the file was\n    # edited.\n    if status[0] == \"A\" and status[3] != \"+\":\n      # We'll need to upload the new content if we're adding a binary file\n      # since diff's output won't contain it.\n      mimetype = RunShell([\"svn\", \"propget\", \"svn:mime-type\", filename],\n                          silent_ok=True)\n      base_content = \"\"\n      is_binary = mimetype and not mimetype.startswith(\"text/\")\n      if is_binary and self.IsImage(filename):\n        new_content = self.ReadFile(filename)\n    elif (status[0] in (\"M\", \"D\", \"R\") or\n          (status[0] == \"A\" and status[3] == \"+\") or  # Copied file.\n          (status[0] == \" \" and status[1] == \"M\")):  # Property change.\n      args = []\n      if self.options.revision:\n        url = \"%s/%s@%s\" % (self.svn_base, filename, self.rev_start)\n      else:\n        # Don't change filename, it's needed later.\n        url = filename\n        args += [\"-r\", \"BASE\"]\n      cmd = [\"svn\"] + args + [\"propget\", \"svn:mime-type\", url]\n      mimetype, returncode = RunShellWithReturnCode(cmd)\n      if returncode:\n        # File does not exist in the requested revision.\n        # Reset mimetype, it contains an error message.\n        mimetype = \"\"\n      get_base = False\n      is_binary = mimetype and not mimetype.startswith(\"text/\")\n      if status[0] == \" \":\n        # Empty base content just to force an upload.\n        base_content = \"\"\n      elif is_binary:\n        if self.IsImage(filename):\n          get_base = True\n          if status[0] == \"M\":\n            if not self.rev_end:\n              new_content = self.ReadFile(filename)\n            else:\n              url = \"%s/%s@%s\" % (self.svn_base, filename, self.rev_end)\n              new_content = RunShell([\"svn\", \"cat\", url],\n                                     universal_newlines=True, silent_ok=True)\n        else:\n          base_content = \"\"\n      else:\n        get_base = True\n\n      if get_base:\n        if is_binary:\n          universal_newlines = False\n        else:\n          universal_newlines = True\n        if self.rev_start:\n          # \"svn cat -r REV delete_file.txt\" doesn't work. cat requires\n          # the full URL with \"@REV\" appended instead of using \"-r\" option.\n          url = \"%s/%s@%s\" % (self.svn_base, filename, self.rev_start)\n          base_content = RunShell([\"svn\", \"cat\", url],\n                                  universal_newlines=universal_newlines,\n                                  silent_ok=True)\n        else:\n          base_content = RunShell([\"svn\", \"cat\", filename],\n                                  universal_newlines=universal_newlines,\n                                  silent_ok=True)\n        if not is_binary:\n          args = []\n          if self.rev_start:\n            url = \"%s/%s@%s\" % (self.svn_base, filename, self.rev_start)\n          else:\n            url = filename\n            args += [\"-r\", \"BASE\"]\n          cmd = [\"svn\"] + args + [\"propget\", \"svn:keywords\", url]\n          keywords, returncode = RunShellWithReturnCode(cmd)\n          if keywords and not returncode:\n            base_content = self._CollapseKeywords(base_content, keywords)\n    else:\n      StatusUpdate(\"svn status returned unexpected output: %s\" % status)\n      sys.exit(1)\n    return base_content, new_content, is_binary, status[0:5]\n\n\nclass GitVCS(VersionControlSystem):\n  \"\"\"Implementation of the VersionControlSystem interface for Git.\"\"\"\n\n  def __init__(self, options):\n    super(GitVCS, self).__init__(options)\n    # Map of filename -> hash of base file.\n    self.base_hashes = {}\n\n  def GenerateDiff(self, extra_args):\n    # This is more complicated than svn's GenerateDiff because we must convert\n    # the diff output to include an svn-style \"Index:\" line as well as record\n    # the hashes of the base files, so we can upload them along with our diff.\n    if self.options.revision:\n      extra_args = [self.options.revision] + extra_args\n    gitdiff = RunShell([\"git\", \"diff\", \"--full-index\"] + extra_args)\n    svndiff = []\n    filecount = 0\n    filename = None\n    for line in gitdiff.splitlines():\n      match = re.match(r\"diff --git a/(.*) b/.*$\", line)\n      if match:\n        filecount += 1\n        filename = match.group(1)\n        svndiff.append(\"Index: %s\\n\" % filename)\n      else:\n        # The \"index\" line in a git diff looks like this (long hashes elided):\n        #   index 82c0d44..b2cee3f 100755\n        # We want to save the left hash, as that identifies the base file.\n        match = re.match(r\"index (\\w+)\\.\\.\", line)\n        if match:\n          self.base_hashes[filename] = match.group(1)\n      svndiff.append(line + \"\\n\")\n    if not filecount:\n      ErrorExit(\"No valid patches found in output from git diff\")\n    return \"\".join(svndiff)\n\n  def GetUnknownFiles(self):\n    status = RunShell([\"git\", \"ls-files\", \"--exclude-standard\", \"--others\"],\n                      silent_ok=True)\n    return status.splitlines()\n\n  def GetBaseFile(self, filename):\n    hash = self.base_hashes[filename]\n    base_content = None\n    new_content = None\n    is_binary = False\n    if hash == \"0\" * 40:  # All-zero hash indicates no base file.\n      status = \"A\"\n      base_content = \"\"\n    else:\n      status = \"M\"\n      base_content, returncode = RunShellWithReturnCode([\"git\", \"show\", hash])\n      if returncode:\n        ErrorExit(\"Got error status from 'git show %s'\" % hash)\n    return (base_content, new_content, is_binary, status)\n\n\nclass MercurialVCS(VersionControlSystem):\n  \"\"\"Implementation of the VersionControlSystem interface for Mercurial.\"\"\"\n\n  def __init__(self, options, repo_dir):\n    super(MercurialVCS, self).__init__(options)\n    # Absolute path to repository (we can be in a subdir)\n    self.repo_dir = os.path.normpath(repo_dir)\n    # Compute the subdir\n    cwd = os.path.normpath(os.getcwd())\n    assert cwd.startswith(self.repo_dir)\n    self.subdir = cwd[len(self.repo_dir):].lstrip(r\"\\/\")\n    if self.options.revision:\n      self.base_rev = self.options.revision\n    else:\n      self.base_rev = RunShell([\"hg\", \"parent\", \"-q\"]).split(':')[1].strip()\n\n  def _GetRelPath(self, filename):\n    \"\"\"Get relative path of a file according to the current directory,\n    given its logical path in the repo.\"\"\"\n    assert filename.startswith(self.subdir), filename\n    return filename[len(self.subdir):].lstrip(r\"\\/\")\n\n  def GenerateDiff(self, extra_args):\n    # If no file specified, restrict to the current subdir\n    extra_args = extra_args or [\".\"]\n    cmd = [\"hg\", \"diff\", \"--git\", \"-r\", self.base_rev] + extra_args\n    data = RunShell(cmd, silent_ok=True)\n    svndiff = []\n    filecount = 0\n    for line in data.splitlines():\n      m = re.match(\"diff --git a/(\\S+) b/(\\S+)\", line)\n      if m:\n        # Modify line to make it look like as it comes from svn diff.\n        # With this modification no changes on the server side are required\n        # to make upload.py work with Mercurial repos.\n        # NOTE: for proper handling of moved/copied files, we have to use\n        # the second filename.\n        filename = m.group(2)\n        svndiff.append(\"Index: %s\" % filename)\n        svndiff.append(\"=\" * 67)\n        filecount += 1\n        logging.info(line)\n      else:\n        svndiff.append(line)\n    if not filecount:\n      ErrorExit(\"No valid patches found in output from hg diff\")\n    return \"\\n\".join(svndiff) + \"\\n\"\n\n  def GetUnknownFiles(self):\n    \"\"\"Return a list of files unknown to the VCS.\"\"\"\n    args = []\n    status = RunShell([\"hg\", \"status\", \"--rev\", self.base_rev, \"-u\", \".\"],\n        silent_ok=True)\n    unknown_files = []\n    for line in status.splitlines():\n      st, fn = line.split(\" \", 1)\n      if st == \"?\":\n        unknown_files.append(fn)\n    return unknown_files\n\n  def GetBaseFile(self, filename):\n    # \"hg status\" and \"hg cat\" both take a path relative to the current subdir\n    # rather than to the repo root, but \"hg diff\" has given us the full path\n    # to the repo root.\n    base_content = \"\"\n    new_content = None\n    is_binary = False\n    oldrelpath = relpath = self._GetRelPath(filename)\n    # \"hg status -C\" returns two lines for moved/copied files, one otherwise\n    out = RunShell([\"hg\", \"status\", \"-C\", \"--rev\", self.base_rev, relpath])\n    out = out.splitlines()\n    # HACK: strip error message about missing file/directory if it isn't in\n    # the working copy\n    if out[0].startswith('%s: ' % relpath):\n      out = out[1:]\n    if len(out) > 1:\n      # Moved/copied => considered as modified, use old filename to\n      # retrieve base contents\n      oldrelpath = out[1].strip()\n      status = \"M\"\n    else:\n      status, _ = out[0].split(' ', 1)\n    if status != \"A\":\n      base_content = RunShell([\"hg\", \"cat\", \"-r\", self.base_rev, oldrelpath],\n        silent_ok=True)\n      is_binary = \"\\0\" in base_content  # Mercurial's heuristic\n    if status != \"R\":\n      new_content = open(relpath, \"rb\").read()\n      is_binary = is_binary or \"\\0\" in new_content\n    if is_binary and base_content:\n      # Fetch again without converting newlines\n      base_content = RunShell([\"hg\", \"cat\", \"-r\", self.base_rev, oldrelpath],\n        silent_ok=True, universal_newlines=False)\n    if not is_binary or not self.IsImage(relpath):\n      new_content = None\n    return base_content, new_content, is_binary, status\n\n\n# NOTE: The SplitPatch function is duplicated in engine.py, keep them in sync.\ndef SplitPatch(data):\n  \"\"\"Splits a patch into separate pieces for each file.\n\n  Args:\n    data: A string containing the output of svn diff.\n\n  Returns:\n    A list of 2-tuple (filename, text) where text is the svn diff output\n      pertaining to filename.\n  \"\"\"\n  patches = []\n  filename = None\n  diff = []\n  for line in data.splitlines(True):\n    new_filename = None\n    if line.startswith('Index:'):\n      unused, new_filename = line.split(':', 1)\n      new_filename = new_filename.strip()\n    elif line.startswith('Property changes on:'):\n      unused, temp_filename = line.split(':', 1)\n      # When a file is modified, paths use '/' between directories, however\n      # when a property is modified '\\' is used on Windows.  Make them the same\n      # otherwise the file shows up twice.\n      temp_filename = temp_filename.strip().replace('\\\\', '/')\n      if temp_filename != filename:\n        # File has property changes but no modifications, create a new diff.\n        new_filename = temp_filename\n    if new_filename:\n      if filename and diff:\n        patches.append((filename, ''.join(diff)))\n      filename = new_filename\n      diff = [line]\n      continue\n    if diff is not None:\n      diff.append(line)\n  if filename and diff:\n    patches.append((filename, ''.join(diff)))\n  return patches\n\n\ndef UploadSeparatePatches(issue, rpc_server, patchset, data, options):\n  \"\"\"Uploads a separate patch for each file in the diff output.\n\n  Returns a list of [patch_key, filename] for each file.\n  \"\"\"\n  patches = SplitPatch(data)\n  rv = []\n  for patch in patches:\n    if len(patch[1]) > MAX_UPLOAD_SIZE:\n      print (\"Not uploading the patch for \" + patch[0] +\n             \" because the file is too large.\")\n      continue\n    form_fields = [(\"filename\", patch[0])]\n    if not options.download_base:\n      form_fields.append((\"content_upload\", \"1\"))\n    files = [(\"data\", \"data.diff\", patch[1])]\n    ctype, body = EncodeMultipartFormData(form_fields, files)\n    url = \"/%d/upload_patch/%d\" % (int(issue), int(patchset))\n    print \"Uploading patch for \" + patch[0]\n    response_body = rpc_server.Send(url, body, content_type=ctype)\n    lines = response_body.splitlines()\n    if not lines or lines[0] != \"OK\":\n      StatusUpdate(\"  --> %s\" % response_body)\n      sys.exit(1)\n    rv.append([lines[1], patch[0]])\n  return rv\n\n\ndef GuessVCS(options):\n  \"\"\"Helper to guess the version control system.\n\n  This examines the current directory, guesses which VersionControlSystem\n  we're using, and returns an instance of the appropriate class.  Exit with an\n  error if we can't figure it out.\n\n  Returns:\n    A VersionControlSystem instance. Exits if the VCS can't be guessed.\n  \"\"\"\n  # Mercurial has a command to get the base directory of a repository\n  # Try running it, but don't die if we don't have hg installed.\n  # NOTE: we try Mercurial first as it can sit on top of an SVN working copy.\n  try:\n    out, returncode = RunShellWithReturnCode([\"hg\", \"root\"])\n    if returncode == 0:\n      return MercurialVCS(options, out.strip())\n  except OSError, (errno, message):\n    if errno != 2:  # ENOENT -- they don't have hg installed.\n      raise\n\n  # Subversion has a .svn in all working directories.\n  if os.path.isdir('.svn'):\n    logging.info(\"Guessed VCS = Subversion\")\n    return SubversionVCS(options)\n\n  # Git has a command to test if you're in a git tree.\n  # Try running it, but don't die if we don't have git installed.\n  try:\n    out, returncode = RunShellWithReturnCode([\"git\", \"rev-parse\",\n                                              \"--is-inside-work-tree\"])\n    if returncode == 0:\n      return GitVCS(options)\n  except OSError, (errno, message):\n    if errno != 2:  # ENOENT -- they don't have git installed.\n      raise\n\n  ErrorExit((\"Could not guess version control system. \"\n             \"Are you in a working copy directory?\"))\n\n\ndef RealMain(argv, data=None):\n  \"\"\"The real main function.\n\n  Args:\n    argv: Command line arguments.\n    data: Diff contents. If None (default) the diff is generated by\n      the VersionControlSystem implementation returned by GuessVCS().\n\n  Returns:\n    A 2-tuple (issue id, patchset id).\n    The patchset id is None if the base files are not uploaded by this\n    script (applies only to SVN checkouts).\n  \"\"\"\n  logging.basicConfig(format=(\"%(asctime).19s %(levelname)s %(filename)s:\"\n                              \"%(lineno)s %(message)s \"))\n  os.environ['LC_ALL'] = 'C'\n  options, args = parser.parse_args(argv[1:])\n  global verbosity\n  verbosity = options.verbose\n  if verbosity >= 3:\n    logging.getLogger().setLevel(logging.DEBUG)\n  elif verbosity >= 2:\n    logging.getLogger().setLevel(logging.INFO)\n  vcs = GuessVCS(options)\n  if isinstance(vcs, SubversionVCS):\n    # base field is only allowed for Subversion.\n    # Note: Fetching base files may become deprecated in future releases.\n    base = vcs.GuessBase(options.download_base)\n  else:\n    base = None\n  if not base and options.download_base:\n    options.download_base = True\n    logging.info(\"Enabled upload of base file\")\n  if not options.assume_yes:\n    vcs.CheckForUnknownFiles()\n  if data is None:\n    data = vcs.GenerateDiff(args)\n  files = vcs.GetBaseFiles(data)\n  if verbosity >= 1:\n    print \"Upload server:\", options.server, \"(change with -s/--server)\"\n  if options.issue:\n    prompt = \"Message describing this patch set: \"\n  else:\n    prompt = \"New issue subject: \"\n  message = options.message or raw_input(prompt).strip()\n  if not message:\n    ErrorExit(\"A non-empty message is required\")\n  rpc_server = GetRpcServer(options)\n  form_fields = [(\"subject\", message)]\n  if base:\n    form_fields.append((\"base\", base))\n  if options.issue:\n    form_fields.append((\"issue\", str(options.issue)))\n  if options.email:\n    form_fields.append((\"user\", options.email))\n  if options.reviewers:\n    for reviewer in options.reviewers.split(','):\n      if \"@\" in reviewer and not reviewer.split(\"@\")[1].count(\".\") == 1:\n        ErrorExit(\"Invalid email address: %s\" % reviewer)\n    form_fields.append((\"reviewers\", options.reviewers))\n  if options.cc:\n    for cc in options.cc.split(','):\n      if \"@\" in cc and not cc.split(\"@\")[1].count(\".\") == 1:\n        ErrorExit(\"Invalid email address: %s\" % cc)\n    form_fields.append((\"cc\", options.cc))\n  description = options.description\n  if options.description_file:\n    if options.description:\n      ErrorExit(\"Can't specify description and description_file\")\n    file = open(options.description_file, 'r')\n    description = file.read()\n    file.close()\n  if description:\n    form_fields.append((\"description\", description))\n  # Send a hash of all the base file so the server can determine if a copy\n  # already exists in an earlier patchset.\n  base_hashes = \"\"\n  for file, info in files.iteritems():\n    if not info[0] is None:\n      checksum = md5.new(info[0]).hexdigest()\n      if base_hashes:\n        base_hashes += \"|\"\n      base_hashes += checksum + \":\" + file\n  form_fields.append((\"base_hashes\", base_hashes))\n  # If we're uploading base files, don't send the email before the uploads, so\n  # that it contains the file status.\n  if options.send_mail and options.download_base:\n    form_fields.append((\"send_mail\", \"1\"))\n  if not options.download_base:\n    form_fields.append((\"content_upload\", \"1\"))\n  if len(data) > MAX_UPLOAD_SIZE:\n    print \"Patch is large, so uploading file patches separately.\"\n    uploaded_diff_file = []\n    form_fields.append((\"separate_patches\", \"1\"))\n  else:\n    uploaded_diff_file = [(\"data\", \"data.diff\", data)]\n  ctype, body = EncodeMultipartFormData(form_fields, uploaded_diff_file)\n  response_body = rpc_server.Send(\"/upload\", body, content_type=ctype)\n  patchset = None\n  if not options.download_base or not uploaded_diff_file:\n    lines = response_body.splitlines()\n    if len(lines) >= 2:\n      msg = lines[0]\n      patchset = lines[1].strip()\n      patches = [x.split(\" \", 1) for x in lines[2:]]\n    else:\n      msg = response_body\n  else:\n    msg = response_body\n  StatusUpdate(msg)\n  if not response_body.startswith(\"Issue created.\") and \\\n  not response_body.startswith(\"Issue updated.\"):\n    sys.exit(0)\n  issue = msg[msg.rfind(\"/\")+1:]\n\n  if not uploaded_diff_file:\n    result = UploadSeparatePatches(issue, rpc_server, patchset, data, options)\n    if not options.download_base:\n      patches = result\n\n  if not options.download_base:\n    vcs.UploadBaseFiles(issue, rpc_server, patches, patchset, options, files)\n    if options.send_mail:\n      rpc_server.Send(\"/\" + issue + \"/mail\", payload=\"\")\n  return issue, patchset\n\n\ndef main():\n  try:\n    RealMain(sys.argv)\n  except KeyboardInterrupt:\n    print\n    StatusUpdate(\"Interrupted.\")\n    sys.exit(1)\n\n\nif __name__ == \"__main__\":\n  main()\n"
  },
  {
    "path": "ext/gmock/scripts/upload_gmock.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2009, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"upload_gmock.py v0.1.0 -- uploads a Google Mock patch for review.\n\nThis simple wrapper passes all command line flags and\n--cc=googlemock@googlegroups.com to upload.py.\n\nUSAGE: upload_gmock.py [options for upload.py]\n\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport sys\n\nCC_FLAG = '--cc='\nGMOCK_GROUP = 'googlemock@googlegroups.com'\n\n\ndef main():\n  # Finds the path to upload.py, assuming it is in the same directory\n  # as this file.\n  my_dir = os.path.dirname(os.path.abspath(__file__))\n  upload_py_path = os.path.join(my_dir, 'upload.py')\n\n  # Adds Google Mock discussion group to the cc line if it's not there\n  # already.\n  upload_py_argv = [upload_py_path]\n  found_cc_flag = False\n  for arg in sys.argv[1:]:\n    if arg.startswith(CC_FLAG):\n      found_cc_flag = True\n      cc_line = arg[len(CC_FLAG):]\n      cc_list = [addr for addr in cc_line.split(',') if addr]\n      if GMOCK_GROUP not in cc_list:\n        cc_list.append(GMOCK_GROUP)\n      upload_py_argv.append(CC_FLAG + ','.join(cc_list))\n    else:\n      upload_py_argv.append(arg)\n\n  if not found_cc_flag:\n    upload_py_argv.append(CC_FLAG + GMOCK_GROUP)\n\n  # Invokes upload.py with the modified command line flags.\n  os.execv(upload_py_path, upload_py_argv)\n\n\nif __name__ == '__main__':\n  main()\n"
  },
  {
    "path": "ext/gmock/src/gmock-all.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// Google C++ Mocking Framework (Google Mock)\n//\n// This file #includes all Google Mock implementation .cc files.  The\n// purpose is to allow a user to build Google Mock by compiling this\n// file alone.\n\n// This line ensures that gmock.h can be compiled on its own, even\n// when it's fused.\n#include \"gmock/gmock.h\"\n\n// The following lines pull in the real gmock *.cc files.\n#include \"src/gmock-cardinalities.cc\"\n#include \"src/gmock-internal-utils.cc\"\n#include \"src/gmock-matchers.cc\"\n#include \"src/gmock-spec-builders.cc\"\n#include \"src/gmock.cc\"\n"
  },
  {
    "path": "ext/gmock/src/gmock-cardinalities.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements cardinalities.\n\n#include \"gmock/gmock-cardinalities.h\"\n\n#include <limits.h>\n#include <ostream>  // NOLINT\n#include <sstream>\n#include <string>\n#include \"gmock/internal/gmock-internal-utils.h\"\n#include \"gtest/gtest.h\"\n\nnamespace testing {\n\nnamespace {\n\n// Implements the Between(m, n) cardinality.\nclass BetweenCardinalityImpl : public CardinalityInterface {\n public:\n  BetweenCardinalityImpl(int min, int max)\n      : min_(min >= 0 ? min : 0),\n        max_(max >= min_ ? max : min_) {\n    std::stringstream ss;\n    if (min < 0) {\n      ss << \"The invocation lower bound must be >= 0, \"\n         << \"but is actually \" << min << \".\";\n      internal::Expect(false, __FILE__, __LINE__, ss.str());\n    } else if (max < 0) {\n      ss << \"The invocation upper bound must be >= 0, \"\n         << \"but is actually \" << max << \".\";\n      internal::Expect(false, __FILE__, __LINE__, ss.str());\n    } else if (min > max) {\n      ss << \"The invocation upper bound (\" << max\n         << \") must be >= the invocation lower bound (\" << min\n         << \").\";\n      internal::Expect(false, __FILE__, __LINE__, ss.str());\n    }\n  }\n\n  // Conservative estimate on the lower/upper bound of the number of\n  // calls allowed.\n  virtual int ConservativeLowerBound() const { return min_; }\n  virtual int ConservativeUpperBound() const { return max_; }\n\n  virtual bool IsSatisfiedByCallCount(int call_count) const {\n    return min_ <= call_count && call_count <= max_;\n  }\n\n  virtual bool IsSaturatedByCallCount(int call_count) const {\n    return call_count >= max_;\n  }\n\n  virtual void DescribeTo(::std::ostream* os) const;\n\n private:\n  const int min_;\n  const int max_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(BetweenCardinalityImpl);\n};\n\n// Formats \"n times\" in a human-friendly way.\ninline internal::string FormatTimes(int n) {\n  if (n == 1) {\n    return \"once\";\n  } else if (n == 2) {\n    return \"twice\";\n  } else {\n    std::stringstream ss;\n    ss << n << \" times\";\n    return ss.str();\n  }\n}\n\n// Describes the Between(m, n) cardinality in human-friendly text.\nvoid BetweenCardinalityImpl::DescribeTo(::std::ostream* os) const {\n  if (min_ == 0) {\n    if (max_ == 0) {\n      *os << \"never called\";\n    } else if (max_ == INT_MAX) {\n      *os << \"called any number of times\";\n    } else {\n      *os << \"called at most \" << FormatTimes(max_);\n    }\n  } else if (min_ == max_) {\n    *os << \"called \" << FormatTimes(min_);\n  } else if (max_ == INT_MAX) {\n    *os << \"called at least \" << FormatTimes(min_);\n  } else {\n    // 0 < min_ < max_ < INT_MAX\n    *os << \"called between \" << min_ << \" and \" << max_ << \" times\";\n  }\n}\n\n}  // Unnamed namespace\n\n// Describes the given call count to an ostream.\nvoid Cardinality::DescribeActualCallCountTo(int actual_call_count,\n                                            ::std::ostream* os) {\n  if (actual_call_count > 0) {\n    *os << \"called \" << FormatTimes(actual_call_count);\n  } else {\n    *os << \"never called\";\n  }\n}\n\n// Creates a cardinality that allows at least n calls.\nGTEST_API_ Cardinality AtLeast(int n) { return Between(n, INT_MAX); }\n\n// Creates a cardinality that allows at most n calls.\nGTEST_API_ Cardinality AtMost(int n) { return Between(0, n); }\n\n// Creates a cardinality that allows any number of calls.\nGTEST_API_ Cardinality AnyNumber() { return AtLeast(0); }\n\n// Creates a cardinality that allows between min and max calls.\nGTEST_API_ Cardinality Between(int min, int max) {\n  return Cardinality(new BetweenCardinalityImpl(min, max));\n}\n\n// Creates a cardinality that allows exactly n calls.\nGTEST_API_ Cardinality Exactly(int n) { return Between(n, n); }\n\n}  // namespace testing\n"
  },
  {
    "path": "ext/gmock/src/gmock-internal-utils.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file defines some utilities useful for implementing Google\n// Mock.  They are subject to change without notice, so please DO NOT\n// USE THEM IN USER CODE.\n\n#include \"gmock/internal/gmock-internal-utils.h\"\n\n#include <ctype.h>\n#include <ostream>  // NOLINT\n#include <string>\n#include \"gmock/gmock.h\"\n#include \"gmock/internal/gmock-port.h\"\n#include \"gtest/gtest.h\"\n\nnamespace testing {\nnamespace internal {\n\n// Converts an identifier name to a space-separated list of lower-case\n// words.  Each maximum substring of the form [A-Za-z][a-z]*|\\d+ is\n// treated as one word.  For example, both \"FooBar123\" and\n// \"foo_bar_123\" are converted to \"foo bar 123\".\nGTEST_API_ string ConvertIdentifierNameToWords(const char* id_name) {\n  string result;\n  char prev_char = '\\0';\n  for (const char* p = id_name; *p != '\\0'; prev_char = *(p++)) {\n    // We don't care about the current locale as the input is\n    // guaranteed to be a valid C++ identifier name.\n    const bool starts_new_word = IsUpper(*p) ||\n        (!IsAlpha(prev_char) && IsLower(*p)) ||\n        (!IsDigit(prev_char) && IsDigit(*p));\n\n    if (IsAlNum(*p)) {\n      if (starts_new_word && result != \"\")\n        result += ' ';\n      result += ToLower(*p);\n    }\n  }\n  return result;\n}\n\n// This class reports Google Mock failures as Google Test failures.  A\n// user can define another class in a similar fashion if he intends to\n// use Google Mock with a testing framework other than Google Test.\nclass GoogleTestFailureReporter : public FailureReporterInterface {\n public:\n  virtual void ReportFailure(FailureType type, const char* file, int line,\n                             const string& message) {\n    AssertHelper(type == kFatal ?\n                 TestPartResult::kFatalFailure :\n                 TestPartResult::kNonFatalFailure,\n                 file,\n                 line,\n                 message.c_str()) = Message();\n    if (type == kFatal) {\n      posix::Abort();\n    }\n  }\n};\n\n// Returns the global failure reporter.  Will create a\n// GoogleTestFailureReporter and return it the first time called.\nGTEST_API_ FailureReporterInterface* GetFailureReporter() {\n  // Points to the global failure reporter used by Google Mock.  gcc\n  // guarantees that the following use of failure_reporter is\n  // thread-safe.  We may need to add additional synchronization to\n  // protect failure_reporter if we port Google Mock to other\n  // compilers.\n  static FailureReporterInterface* const failure_reporter =\n      new GoogleTestFailureReporter();\n  return failure_reporter;\n}\n\n// Protects global resources (stdout in particular) used by Log().\nstatic GTEST_DEFINE_STATIC_MUTEX_(g_log_mutex);\n\n// Returns true iff a log with the given severity is visible according\n// to the --gmock_verbose flag.\nGTEST_API_ bool LogIsVisible(LogSeverity severity) {\n  if (GMOCK_FLAG(verbose) == kInfoVerbosity) {\n    // Always show the log if --gmock_verbose=info.\n    return true;\n  } else if (GMOCK_FLAG(verbose) == kErrorVerbosity) {\n    // Always hide it if --gmock_verbose=error.\n    return false;\n  } else {\n    // If --gmock_verbose is neither \"info\" nor \"error\", we treat it\n    // as \"warning\" (its default value).\n    return severity == kWarning;\n  }\n}\n\n// Prints the given message to stdout iff 'severity' >= the level\n// specified by the --gmock_verbose flag.  If stack_frames_to_skip >=\n// 0, also prints the stack trace excluding the top\n// stack_frames_to_skip frames.  In opt mode, any positive\n// stack_frames_to_skip is treated as 0, since we don't know which\n// function calls will be inlined by the compiler and need to be\n// conservative.\nGTEST_API_ void Log(LogSeverity severity,\n                    const string& message,\n                    int stack_frames_to_skip) {\n  if (!LogIsVisible(severity))\n    return;\n\n  // Ensures that logs from different threads don't interleave.\n  MutexLock l(&g_log_mutex);\n\n  // \"using ::std::cout;\" doesn't work with Symbian's STLport, where cout is a\n  // macro.\n\n  if (severity == kWarning) {\n    // Prints a GMOCK WARNING marker to make the warnings easily searchable.\n    std::cout << \"\\nGMOCK WARNING:\";\n  }\n  // Pre-pends a new-line to message if it doesn't start with one.\n  if (message.empty() || message[0] != '\\n') {\n    std::cout << \"\\n\";\n  }\n  std::cout << message;\n  if (stack_frames_to_skip >= 0) {\n#ifdef NDEBUG\n    // In opt mode, we have to be conservative and skip no stack frame.\n    const int actual_to_skip = 0;\n#else\n    // In dbg mode, we can do what the caller tell us to do (plus one\n    // for skipping this function's stack frame).\n    const int actual_to_skip = stack_frames_to_skip + 1;\n#endif  // NDEBUG\n\n    // Appends a new-line to message if it doesn't end with one.\n    if (!message.empty() && *message.rbegin() != '\\n') {\n      std::cout << \"\\n\";\n    }\n    std::cout << \"Stack trace:\\n\"\n         << ::testing::internal::GetCurrentOsStackTraceExceptTop(\n             ::testing::UnitTest::GetInstance(), actual_to_skip);\n  }\n  std::cout << ::std::flush;\n}\n\n}  // namespace internal\n}  // namespace testing\n"
  },
  {
    "path": "ext/gmock/src/gmock-matchers.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements Matcher<const string&>, Matcher<string>, and\n// utilities for defining matchers.\n\n#include \"gmock/gmock-matchers.h\"\n#include \"gmock/gmock-generated-matchers.h\"\n\n#include <string.h>\n#include <sstream>\n#include <string>\n\nnamespace testing {\n\n// Constructs a matcher that matches a const string& whose value is\n// equal to s.\nMatcher<const internal::string&>::Matcher(const internal::string& s) {\n  *this = Eq(s);\n}\n\n// Constructs a matcher that matches a const string& whose value is\n// equal to s.\nMatcher<const internal::string&>::Matcher(const char* s) {\n  *this = Eq(internal::string(s));\n}\n\n// Constructs a matcher that matches a string whose value is equal to s.\nMatcher<internal::string>::Matcher(const internal::string& s) { *this = Eq(s); }\n\n// Constructs a matcher that matches a string whose value is equal to s.\nMatcher<internal::string>::Matcher(const char* s) {\n  *this = Eq(internal::string(s));\n}\n\n#if GTEST_HAS_STRING_PIECE_\n// Constructs a matcher that matches a const StringPiece& whose value is\n// equal to s.\nMatcher<const StringPiece&>::Matcher(const internal::string& s) {\n  *this = Eq(s);\n}\n\n// Constructs a matcher that matches a const StringPiece& whose value is\n// equal to s.\nMatcher<const StringPiece&>::Matcher(const char* s) {\n  *this = Eq(internal::string(s));\n}\n\n// Constructs a matcher that matches a const StringPiece& whose value is\n// equal to s.\nMatcher<const StringPiece&>::Matcher(StringPiece s) {\n  *this = Eq(s.ToString());\n}\n\n// Constructs a matcher that matches a StringPiece whose value is equal to s.\nMatcher<StringPiece>::Matcher(const internal::string& s) {\n  *this = Eq(s);\n}\n\n// Constructs a matcher that matches a StringPiece whose value is equal to s.\nMatcher<StringPiece>::Matcher(const char* s) {\n  *this = Eq(internal::string(s));\n}\n\n// Constructs a matcher that matches a StringPiece whose value is equal to s.\nMatcher<StringPiece>::Matcher(StringPiece s) {\n  *this = Eq(s.ToString());\n}\n#endif  // GTEST_HAS_STRING_PIECE_\n\nnamespace internal {\n\n// Joins a vector of strings as if they are fields of a tuple; returns\n// the joined string.\nGTEST_API_ string JoinAsTuple(const Strings& fields) {\n  switch (fields.size()) {\n    case 0:\n      return \"\";\n    case 1:\n      return fields[0];\n    default:\n      string result = \"(\" + fields[0];\n      for (size_t i = 1; i < fields.size(); i++) {\n        result += \", \";\n        result += fields[i];\n      }\n      result += \")\";\n      return result;\n  }\n}\n\n// Returns the description for a matcher defined using the MATCHER*()\n// macro where the user-supplied description string is \"\", if\n// 'negation' is false; otherwise returns the description of the\n// negation of the matcher.  'param_values' contains a list of strings\n// that are the print-out of the matcher's parameters.\nGTEST_API_ string FormatMatcherDescription(bool negation,\n                                           const char* matcher_name,\n                                           const Strings& param_values) {\n  string result = ConvertIdentifierNameToWords(matcher_name);\n  if (param_values.size() >= 1)\n    result += \" \" + JoinAsTuple(param_values);\n  return negation ? \"not (\" + result + \")\" : result;\n}\n\n// FindMaxBipartiteMatching and its helper class.\n//\n// Uses the well-known Ford-Fulkerson max flow method to find a maximum\n// bipartite matching. Flow is considered to be from left to right.\n// There is an implicit source node that is connected to all of the left\n// nodes, and an implicit sink node that is connected to all of the\n// right nodes. All edges have unit capacity.\n//\n// Neither the flow graph nor the residual flow graph are represented\n// explicitly. Instead, they are implied by the information in 'graph' and\n// a vector<int> called 'left_' whose elements are initialized to the\n// value kUnused. This represents the initial state of the algorithm,\n// where the flow graph is empty, and the residual flow graph has the\n// following edges:\n//   - An edge from source to each left_ node\n//   - An edge from each right_ node to sink\n//   - An edge from each left_ node to each right_ node, if the\n//     corresponding edge exists in 'graph'.\n//\n// When the TryAugment() method adds a flow, it sets left_[l] = r for some\n// nodes l and r. This induces the following changes:\n//   - The edges (source, l), (l, r), and (r, sink) are added to the\n//     flow graph.\n//   - The same three edges are removed from the residual flow graph.\n//   - The reverse edges (l, source), (r, l), and (sink, r) are added\n//     to the residual flow graph, which is a directional graph\n//     representing unused flow capacity.\n//\n// When the method augments a flow (moving left_[l] from some r1 to some\n// other r2), this can be thought of as \"undoing\" the above steps with\n// respect to r1 and \"redoing\" them with respect to r2.\n//\n// It bears repeating that the flow graph and residual flow graph are\n// never represented explicitly, but can be derived by looking at the\n// information in 'graph' and in left_.\n//\n// As an optimization, there is a second vector<int> called right_ which\n// does not provide any new information. Instead, it enables more\n// efficient queries about edges entering or leaving the right-side nodes\n// of the flow or residual flow graphs. The following invariants are\n// maintained:\n//\n// left[l] == kUnused or right[left[l]] == l\n// right[r] == kUnused or left[right[r]] == r\n//\n// . [ source ]                                        .\n// .   |||                                             .\n// .   |||                                             .\n// .   ||\\--> left[0]=1  ---\\    right[0]=-1 ----\\     .\n// .   ||                   |                    |     .\n// .   |\\---> left[1]=-1    \\--> right[1]=0  ---\\|     .\n// .   |                                        ||     .\n// .   \\----> left[2]=2  ------> right[2]=2  --\\||     .\n// .                                           |||     .\n// .         elements           matchers       vvv     .\n// .                                         [ sink ]  .\n//\n// See Also:\n//   [1] Cormen, et al (2001). \"Section 26.2: The Ford–Fulkerson method\".\n//       \"Introduction to Algorithms (Second ed.)\", pp. 651–664.\n//   [2] \"Ford–Fulkerson algorithm\", Wikipedia,\n//       'http://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm'\nclass MaxBipartiteMatchState {\n public:\n  explicit MaxBipartiteMatchState(const MatchMatrix& graph)\n      : graph_(&graph),\n        left_(graph_->LhsSize(), kUnused),\n        right_(graph_->RhsSize(), kUnused) {\n  }\n\n  // Returns the edges of a maximal match, each in the form {left, right}.\n  ElementMatcherPairs Compute() {\n    // 'seen' is used for path finding { 0: unseen, 1: seen }.\n    ::std::vector<char> seen;\n    // Searches the residual flow graph for a path from each left node to\n    // the sink in the residual flow graph, and if one is found, add flow\n    // to the graph. It's okay to search through the left nodes once. The\n    // edge from the implicit source node to each previously-visited left\n    // node will have flow if that left node has any path to the sink\n    // whatsoever. Subsequent augmentations can only add flow to the\n    // network, and cannot take away that previous flow unit from the source.\n    // Since the source-to-left edge can only carry one flow unit (or,\n    // each element can be matched to only one matcher), there is no need\n    // to visit the left nodes more than once looking for augmented paths.\n    // The flow is known to be possible or impossible by looking at the\n    // node once.\n    for (size_t ilhs = 0; ilhs < graph_->LhsSize(); ++ilhs) {\n      // Reset the path-marking vector and try to find a path from\n      // source to sink starting at the left_[ilhs] node.\n      GTEST_CHECK_(left_[ilhs] == kUnused)\n          << \"ilhs: \" << ilhs << \", left_[ilhs]: \" << left_[ilhs];\n      // 'seen' initialized to 'graph_->RhsSize()' copies of 0.\n      seen.assign(graph_->RhsSize(), 0);\n      TryAugment(ilhs, &seen);\n    }\n    ElementMatcherPairs result;\n    for (size_t ilhs = 0; ilhs < left_.size(); ++ilhs) {\n      size_t irhs = left_[ilhs];\n      if (irhs == kUnused) continue;\n      result.push_back(ElementMatcherPair(ilhs, irhs));\n    }\n    return result;\n  }\n\n private:\n  static const size_t kUnused = static_cast<size_t>(-1);\n\n  // Perform a depth-first search from left node ilhs to the sink.  If a\n  // path is found, flow is added to the network by linking the left and\n  // right vector elements corresponding each segment of the path.\n  // Returns true if a path to sink was found, which means that a unit of\n  // flow was added to the network. The 'seen' vector elements correspond\n  // to right nodes and are marked to eliminate cycles from the search.\n  //\n  // Left nodes will only be explored at most once because they\n  // are accessible from at most one right node in the residual flow\n  // graph.\n  //\n  // Note that left_[ilhs] is the only element of left_ that TryAugment will\n  // potentially transition from kUnused to another value. Any other\n  // left_ element holding kUnused before TryAugment will be holding it\n  // when TryAugment returns.\n  //\n  bool TryAugment(size_t ilhs, ::std::vector<char>* seen) {\n    for (size_t irhs = 0; irhs < graph_->RhsSize(); ++irhs) {\n      if ((*seen)[irhs])\n        continue;\n      if (!graph_->HasEdge(ilhs, irhs))\n        continue;\n      // There's an available edge from ilhs to irhs.\n      (*seen)[irhs] = 1;\n      // Next a search is performed to determine whether\n      // this edge is a dead end or leads to the sink.\n      //\n      // right_[irhs] == kUnused means that there is residual flow from\n      // right node irhs to the sink, so we can use that to finish this\n      // flow path and return success.\n      //\n      // Otherwise there is residual flow to some ilhs. We push flow\n      // along that path and call ourselves recursively to see if this\n      // ultimately leads to sink.\n      if (right_[irhs] == kUnused || TryAugment(right_[irhs], seen)) {\n        // Add flow from left_[ilhs] to right_[irhs].\n        left_[ilhs] = irhs;\n        right_[irhs] = ilhs;\n        return true;\n      }\n    }\n    return false;\n  }\n\n  const MatchMatrix* graph_;  // not owned\n  // Each element of the left_ vector represents a left hand side node\n  // (i.e. an element) and each element of right_ is a right hand side\n  // node (i.e. a matcher). The values in the left_ vector indicate\n  // outflow from that node to a node on the the right_ side. The values\n  // in the right_ indicate inflow, and specify which left_ node is\n  // feeding that right_ node, if any. For example, left_[3] == 1 means\n  // there's a flow from element #3 to matcher #1. Such a flow would also\n  // be redundantly represented in the right_ vector as right_[1] == 3.\n  // Elements of left_ and right_ are either kUnused or mutually\n  // referent. Mutually referent means that left_[right_[i]] = i and\n  // right_[left_[i]] = i.\n  ::std::vector<size_t> left_;\n  ::std::vector<size_t> right_;\n\n  GTEST_DISALLOW_ASSIGN_(MaxBipartiteMatchState);\n};\n\nconst size_t MaxBipartiteMatchState::kUnused;\n\nGTEST_API_ ElementMatcherPairs\nFindMaxBipartiteMatching(const MatchMatrix& g) {\n  return MaxBipartiteMatchState(g).Compute();\n}\n\nstatic void LogElementMatcherPairVec(const ElementMatcherPairs& pairs,\n                                     ::std::ostream* stream) {\n  typedef ElementMatcherPairs::const_iterator Iter;\n  ::std::ostream& os = *stream;\n  os << \"{\";\n  const char *sep = \"\";\n  for (Iter it = pairs.begin(); it != pairs.end(); ++it) {\n    os << sep << \"\\n  (\"\n       << \"element #\" << it->first << \", \"\n       << \"matcher #\" << it->second << \")\";\n    sep = \",\";\n  }\n  os << \"\\n}\";\n}\n\n// Tries to find a pairing, and explains the result.\nGTEST_API_ bool FindPairing(const MatchMatrix& matrix,\n                            MatchResultListener* listener) {\n  ElementMatcherPairs matches = FindMaxBipartiteMatching(matrix);\n\n  size_t max_flow = matches.size();\n  bool result = (max_flow == matrix.RhsSize());\n\n  if (!result) {\n    if (listener->IsInterested()) {\n      *listener << \"where no permutation of the elements can \"\n                   \"satisfy all matchers, and the closest match is \"\n                << max_flow << \" of \" << matrix.RhsSize()\n                << \" matchers with the pairings:\\n\";\n      LogElementMatcherPairVec(matches, listener->stream());\n    }\n    return false;\n  }\n\n  if (matches.size() > 1) {\n    if (listener->IsInterested()) {\n      const char *sep = \"where:\\n\";\n      for (size_t mi = 0; mi < matches.size(); ++mi) {\n        *listener << sep << \" - element #\" << matches[mi].first\n                  << \" is matched by matcher #\" << matches[mi].second;\n        sep = \",\\n\";\n      }\n    }\n  }\n  return true;\n}\n\nbool MatchMatrix::NextGraph() {\n  for (size_t ilhs = 0; ilhs < LhsSize(); ++ilhs) {\n    for (size_t irhs = 0; irhs < RhsSize(); ++irhs) {\n      char& b = matched_[SpaceIndex(ilhs, irhs)];\n      if (!b) {\n        b = 1;\n        return true;\n      }\n      b = 0;\n    }\n  }\n  return false;\n}\n\nvoid MatchMatrix::Randomize() {\n  for (size_t ilhs = 0; ilhs < LhsSize(); ++ilhs) {\n    for (size_t irhs = 0; irhs < RhsSize(); ++irhs) {\n      char& b = matched_[SpaceIndex(ilhs, irhs)];\n      b = static_cast<char>(rand() & 1);  // NOLINT\n    }\n  }\n}\n\nstring MatchMatrix::DebugString() const {\n  ::std::stringstream ss;\n  const char *sep = \"\";\n  for (size_t i = 0; i < LhsSize(); ++i) {\n    ss << sep;\n    for (size_t j = 0; j < RhsSize(); ++j) {\n      ss << HasEdge(i, j);\n    }\n    sep = \";\";\n  }\n  return ss.str();\n}\n\nvoid UnorderedElementsAreMatcherImplBase::DescribeToImpl(\n    ::std::ostream* os) const {\n  if (matcher_describers_.empty()) {\n    *os << \"is empty\";\n    return;\n  }\n  if (matcher_describers_.size() == 1) {\n    *os << \"has \" << Elements(1) << \" and that element \";\n    matcher_describers_[0]->DescribeTo(os);\n    return;\n  }\n  *os << \"has \" << Elements(matcher_describers_.size())\n      << \" and there exists some permutation of elements such that:\\n\";\n  const char* sep = \"\";\n  for (size_t i = 0; i != matcher_describers_.size(); ++i) {\n    *os << sep << \" - element #\" << i << \" \";\n    matcher_describers_[i]->DescribeTo(os);\n    sep = \", and\\n\";\n  }\n}\n\nvoid UnorderedElementsAreMatcherImplBase::DescribeNegationToImpl(\n    ::std::ostream* os) const {\n  if (matcher_describers_.empty()) {\n    *os << \"isn't empty\";\n    return;\n  }\n  if (matcher_describers_.size() == 1) {\n    *os << \"doesn't have \" << Elements(1)\n        << \", or has \" << Elements(1) << \" that \";\n    matcher_describers_[0]->DescribeNegationTo(os);\n    return;\n  }\n  *os << \"doesn't have \" << Elements(matcher_describers_.size())\n      << \", or there exists no permutation of elements such that:\\n\";\n  const char* sep = \"\";\n  for (size_t i = 0; i != matcher_describers_.size(); ++i) {\n    *os << sep << \" - element #\" << i << \" \";\n    matcher_describers_[i]->DescribeTo(os);\n    sep = \", and\\n\";\n  }\n}\n\n// Checks that all matchers match at least one element, and that all\n// elements match at least one matcher. This enables faster matching\n// and better error reporting.\n// Returns false, writing an explanation to 'listener', if and only\n// if the success criteria are not met.\nbool UnorderedElementsAreMatcherImplBase::\nVerifyAllElementsAndMatchersAreMatched(\n    const ::std::vector<string>& element_printouts,\n    const MatchMatrix& matrix,\n    MatchResultListener* listener) const {\n  bool result = true;\n  ::std::vector<char> element_matched(matrix.LhsSize(), 0);\n  ::std::vector<char> matcher_matched(matrix.RhsSize(), 0);\n\n  for (size_t ilhs = 0; ilhs < matrix.LhsSize(); ilhs++) {\n    for (size_t irhs = 0; irhs < matrix.RhsSize(); irhs++) {\n      char matched = matrix.HasEdge(ilhs, irhs);\n      element_matched[ilhs] |= matched;\n      matcher_matched[irhs] |= matched;\n    }\n  }\n\n  {\n    const char* sep =\n        \"where the following matchers don't match any elements:\\n\";\n    for (size_t mi = 0; mi < matcher_matched.size(); ++mi) {\n      if (matcher_matched[mi])\n        continue;\n      result = false;\n      if (listener->IsInterested()) {\n        *listener << sep << \"matcher #\" << mi << \": \";\n        matcher_describers_[mi]->DescribeTo(listener->stream());\n        sep = \",\\n\";\n      }\n    }\n  }\n\n  {\n    const char* sep =\n        \"where the following elements don't match any matchers:\\n\";\n    const char* outer_sep = \"\";\n    if (!result) {\n      outer_sep = \"\\nand \";\n    }\n    for (size_t ei = 0; ei < element_matched.size(); ++ei) {\n      if (element_matched[ei])\n        continue;\n      result = false;\n      if (listener->IsInterested()) {\n        *listener << outer_sep << sep << \"element #\" << ei << \": \"\n                  << element_printouts[ei];\n        sep = \",\\n\";\n        outer_sep = \"\";\n      }\n    }\n  }\n  return result;\n}\n\n}  // namespace internal\n}  // namespace testing\n"
  },
  {
    "path": "ext/gmock/src/gmock-spec-builders.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file implements the spec builder syntax (ON_CALL and\n// EXPECT_CALL).\n\n#include \"gmock/gmock-spec-builders.h\"\n\n#include <stdlib.h>\n#include <iostream>  // NOLINT\n#include <map>\n#include <set>\n#include <string>\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n#if GTEST_OS_CYGWIN || GTEST_OS_LINUX || GTEST_OS_MAC\n# include <unistd.h>  // NOLINT\n#endif\n\nnamespace testing {\nnamespace internal {\n\n// Protects the mock object registry (in class Mock), all function\n// mockers, and all expectations.\nGTEST_API_ GTEST_DEFINE_STATIC_MUTEX_(g_gmock_mutex);\n\n// Logs a message including file and line number information.\nGTEST_API_ void LogWithLocation(testing::internal::LogSeverity severity,\n                                const char* file, int line,\n                                const string& message) {\n  ::std::ostringstream s;\n  s << file << \":\" << line << \": \" << message << ::std::endl;\n  Log(severity, s.str(), 0);\n}\n\n// Constructs an ExpectationBase object.\nExpectationBase::ExpectationBase(const char* a_file,\n                                 int a_line,\n                                 const string& a_source_text)\n    : file_(a_file),\n      line_(a_line),\n      source_text_(a_source_text),\n      cardinality_specified_(false),\n      cardinality_(Exactly(1)),\n      call_count_(0),\n      retired_(false),\n      extra_matcher_specified_(false),\n      repeated_action_specified_(false),\n      retires_on_saturation_(false),\n      last_clause_(kNone),\n      action_count_checked_(false) {}\n\n// Destructs an ExpectationBase object.\nExpectationBase::~ExpectationBase() {}\n\n// Explicitly specifies the cardinality of this expectation.  Used by\n// the subclasses to implement the .Times() clause.\nvoid ExpectationBase::SpecifyCardinality(const Cardinality& a_cardinality) {\n  cardinality_specified_ = true;\n  cardinality_ = a_cardinality;\n}\n\n// Retires all pre-requisites of this expectation.\nvoid ExpectationBase::RetireAllPreRequisites()\n    GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n  if (is_retired()) {\n    // We can take this short-cut as we never retire an expectation\n    // until we have retired all its pre-requisites.\n    return;\n  }\n\n  for (ExpectationSet::const_iterator it = immediate_prerequisites_.begin();\n       it != immediate_prerequisites_.end(); ++it) {\n    ExpectationBase* const prerequisite = it->expectation_base().get();\n    if (!prerequisite->is_retired()) {\n      prerequisite->RetireAllPreRequisites();\n      prerequisite->Retire();\n    }\n  }\n}\n\n// Returns true iff all pre-requisites of this expectation have been\n// satisfied.\nbool ExpectationBase::AllPrerequisitesAreSatisfied() const\n    GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n  g_gmock_mutex.AssertHeld();\n  for (ExpectationSet::const_iterator it = immediate_prerequisites_.begin();\n       it != immediate_prerequisites_.end(); ++it) {\n    if (!(it->expectation_base()->IsSatisfied()) ||\n        !(it->expectation_base()->AllPrerequisitesAreSatisfied()))\n      return false;\n  }\n  return true;\n}\n\n// Adds unsatisfied pre-requisites of this expectation to 'result'.\nvoid ExpectationBase::FindUnsatisfiedPrerequisites(ExpectationSet* result) const\n    GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n  g_gmock_mutex.AssertHeld();\n  for (ExpectationSet::const_iterator it = immediate_prerequisites_.begin();\n       it != immediate_prerequisites_.end(); ++it) {\n    if (it->expectation_base()->IsSatisfied()) {\n      // If *it is satisfied and has a call count of 0, some of its\n      // pre-requisites may not be satisfied yet.\n      if (it->expectation_base()->call_count_ == 0) {\n        it->expectation_base()->FindUnsatisfiedPrerequisites(result);\n      }\n    } else {\n      // Now that we know *it is unsatisfied, we are not so interested\n      // in whether its pre-requisites are satisfied.  Therefore we\n      // don't recursively call FindUnsatisfiedPrerequisites() here.\n      *result += *it;\n    }\n  }\n}\n\n// Describes how many times a function call matching this\n// expectation has occurred.\nvoid ExpectationBase::DescribeCallCountTo(::std::ostream* os) const\n    GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n  g_gmock_mutex.AssertHeld();\n\n  // Describes how many times the function is expected to be called.\n  *os << \"         Expected: to be \";\n  cardinality().DescribeTo(os);\n  *os << \"\\n           Actual: \";\n  Cardinality::DescribeActualCallCountTo(call_count(), os);\n\n  // Describes the state of the expectation (e.g. is it satisfied?\n  // is it active?).\n  *os << \" - \" << (IsOverSaturated() ? \"over-saturated\" :\n                   IsSaturated() ? \"saturated\" :\n                   IsSatisfied() ? \"satisfied\" : \"unsatisfied\")\n      << \" and \"\n      << (is_retired() ? \"retired\" : \"active\");\n}\n\n// Checks the action count (i.e. the number of WillOnce() and\n// WillRepeatedly() clauses) against the cardinality if this hasn't\n// been done before.  Prints a warning if there are too many or too\n// few actions.\nvoid ExpectationBase::CheckActionCountIfNotDone() const\n    GTEST_LOCK_EXCLUDED_(mutex_) {\n  bool should_check = false;\n  {\n    MutexLock l(&mutex_);\n    if (!action_count_checked_) {\n      action_count_checked_ = true;\n      should_check = true;\n    }\n  }\n\n  if (should_check) {\n    if (!cardinality_specified_) {\n      // The cardinality was inferred - no need to check the action\n      // count against it.\n      return;\n    }\n\n    // The cardinality was explicitly specified.\n    const int action_count = static_cast<int>(untyped_actions_.size());\n    const int upper_bound = cardinality().ConservativeUpperBound();\n    const int lower_bound = cardinality().ConservativeLowerBound();\n    bool too_many;  // True if there are too many actions, or false\n    // if there are too few.\n    if (action_count > upper_bound ||\n        (action_count == upper_bound && repeated_action_specified_)) {\n      too_many = true;\n    } else if (0 < action_count && action_count < lower_bound &&\n               !repeated_action_specified_) {\n      too_many = false;\n    } else {\n      return;\n    }\n\n    ::std::stringstream ss;\n    DescribeLocationTo(&ss);\n    ss << \"Too \" << (too_many ? \"many\" : \"few\")\n       << \" actions specified in \" << source_text() << \"...\\n\"\n       << \"Expected to be \";\n    cardinality().DescribeTo(&ss);\n    ss << \", but has \" << (too_many ? \"\" : \"only \")\n       << action_count << \" WillOnce()\"\n       << (action_count == 1 ? \"\" : \"s\");\n    if (repeated_action_specified_) {\n      ss << \" and a WillRepeatedly()\";\n    }\n    ss << \".\";\n    Log(kWarning, ss.str(), -1);  // -1 means \"don't print stack trace\".\n  }\n}\n\n// Implements the .Times() clause.\nvoid ExpectationBase::UntypedTimes(const Cardinality& a_cardinality) {\n  if (last_clause_ == kTimes) {\n    ExpectSpecProperty(false,\n                       \".Times() cannot appear \"\n                       \"more than once in an EXPECT_CALL().\");\n  } else {\n    ExpectSpecProperty(last_clause_ < kTimes,\n                       \".Times() cannot appear after \"\n                       \".InSequence(), .WillOnce(), .WillRepeatedly(), \"\n                       \"or .RetiresOnSaturation().\");\n  }\n  last_clause_ = kTimes;\n\n  SpecifyCardinality(a_cardinality);\n}\n\n// Points to the implicit sequence introduced by a living InSequence\n// object (if any) in the current thread or NULL.\nGTEST_API_ ThreadLocal<Sequence*> g_gmock_implicit_sequence;\n\n// Reports an uninteresting call (whose description is in msg) in the\n// manner specified by 'reaction'.\nvoid ReportUninterestingCall(CallReaction reaction, const string& msg) {\n  switch (reaction) {\n    case kAllow:\n      Log(kInfo, msg, 3);\n      break;\n    case kWarn:\n      Log(kWarning, msg, 3);\n      break;\n    default:  // FAIL\n      Expect(false, NULL, -1, msg);\n  }\n}\n\nUntypedFunctionMockerBase::UntypedFunctionMockerBase()\n    : mock_obj_(NULL), name_(\"\") {}\n\nUntypedFunctionMockerBase::~UntypedFunctionMockerBase() {}\n\n// Sets the mock object this mock method belongs to, and registers\n// this information in the global mock registry.  Will be called\n// whenever an EXPECT_CALL() or ON_CALL() is executed on this mock\n// method.\nvoid UntypedFunctionMockerBase::RegisterOwner(const void* mock_obj)\n    GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\n  {\n    MutexLock l(&g_gmock_mutex);\n    mock_obj_ = mock_obj;\n  }\n  Mock::Register(mock_obj, this);\n}\n\n// Sets the mock object this mock method belongs to, and sets the name\n// of the mock function.  Will be called upon each invocation of this\n// mock function.\nvoid UntypedFunctionMockerBase::SetOwnerAndName(const void* mock_obj,\n                                                const char* name)\n    GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\n  // We protect name_ under g_gmock_mutex in case this mock function\n  // is called from two threads concurrently.\n  MutexLock l(&g_gmock_mutex);\n  mock_obj_ = mock_obj;\n  name_ = name;\n}\n\n// Returns the name of the function being mocked.  Must be called\n// after RegisterOwner() or SetOwnerAndName() has been called.\nconst void* UntypedFunctionMockerBase::MockObject() const\n    GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\n  const void* mock_obj;\n  {\n    // We protect mock_obj_ under g_gmock_mutex in case this mock\n    // function is called from two threads concurrently.\n    MutexLock l(&g_gmock_mutex);\n    Assert(mock_obj_ != NULL, __FILE__, __LINE__,\n           \"MockObject() must not be called before RegisterOwner() or \"\n           \"SetOwnerAndName() has been called.\");\n    mock_obj = mock_obj_;\n  }\n  return mock_obj;\n}\n\n// Returns the name of this mock method.  Must be called after\n// SetOwnerAndName() has been called.\nconst char* UntypedFunctionMockerBase::Name() const\n    GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\n  const char* name;\n  {\n    // We protect name_ under g_gmock_mutex in case this mock\n    // function is called from two threads concurrently.\n    MutexLock l(&g_gmock_mutex);\n    Assert(name_ != NULL, __FILE__, __LINE__,\n           \"Name() must not be called before SetOwnerAndName() has \"\n           \"been called.\");\n    name = name_;\n  }\n  return name;\n}\n\n// Calculates the result of invoking this mock function with the given\n// arguments, prints it, and returns it.  The caller is responsible\n// for deleting the result.\nconst UntypedActionResultHolderBase*\nUntypedFunctionMockerBase::UntypedInvokeWith(const void* const untyped_args)\n    GTEST_LOCK_EXCLUDED_(g_gmock_mutex) {\n  if (untyped_expectations_.size() == 0) {\n    // No expectation is set on this mock method - we have an\n    // uninteresting call.\n\n    // We must get Google Mock's reaction on uninteresting calls\n    // made on this mock object BEFORE performing the action,\n    // because the action may DELETE the mock object and make the\n    // following expression meaningless.\n    const CallReaction reaction =\n        Mock::GetReactionOnUninterestingCalls(MockObject());\n\n    // True iff we need to print this call's arguments and return\n    // value.  This definition must be kept in sync with\n    // the behavior of ReportUninterestingCall().\n    const bool need_to_report_uninteresting_call =\n        // If the user allows this uninteresting call, we print it\n        // only when he wants informational messages.\n        reaction == kAllow ? LogIsVisible(kInfo) :\n        // If the user wants this to be a warning, we print it only\n        // when he wants to see warnings.\n        reaction == kWarn ? LogIsVisible(kWarning) :\n        // Otherwise, the user wants this to be an error, and we\n        // should always print detailed information in the error.\n        true;\n\n    if (!need_to_report_uninteresting_call) {\n      // Perform the action without printing the call information.\n      return this->UntypedPerformDefaultAction(untyped_args, \"\");\n    }\n\n    // Warns about the uninteresting call.\n    ::std::stringstream ss;\n    this->UntypedDescribeUninterestingCall(untyped_args, &ss);\n\n    // Calculates the function result.\n    const UntypedActionResultHolderBase* const result =\n        this->UntypedPerformDefaultAction(untyped_args, ss.str());\n\n    // Prints the function result.\n    if (result != NULL)\n      result->PrintAsActionResult(&ss);\n\n    ReportUninterestingCall(reaction, ss.str());\n    return result;\n  }\n\n  bool is_excessive = false;\n  ::std::stringstream ss;\n  ::std::stringstream why;\n  ::std::stringstream loc;\n  const void* untyped_action = NULL;\n\n  // The UntypedFindMatchingExpectation() function acquires and\n  // releases g_gmock_mutex.\n  const ExpectationBase* const untyped_expectation =\n      this->UntypedFindMatchingExpectation(\n          untyped_args, &untyped_action, &is_excessive,\n          &ss, &why);\n  const bool found = untyped_expectation != NULL;\n\n  // True iff we need to print the call's arguments and return value.\n  // This definition must be kept in sync with the uses of Expect()\n  // and Log() in this function.\n  const bool need_to_report_call =\n      !found || is_excessive || LogIsVisible(kInfo);\n  if (!need_to_report_call) {\n    // Perform the action without printing the call information.\n    return\n        untyped_action == NULL ?\n        this->UntypedPerformDefaultAction(untyped_args, \"\") :\n        this->UntypedPerformAction(untyped_action, untyped_args);\n  }\n\n  ss << \"    Function call: \" << Name();\n  this->UntypedPrintArgs(untyped_args, &ss);\n\n  // In case the action deletes a piece of the expectation, we\n  // generate the message beforehand.\n  if (found && !is_excessive) {\n    untyped_expectation->DescribeLocationTo(&loc);\n  }\n\n  const UntypedActionResultHolderBase* const result =\n      untyped_action == NULL ?\n      this->UntypedPerformDefaultAction(untyped_args, ss.str()) :\n      this->UntypedPerformAction(untyped_action, untyped_args);\n  if (result != NULL)\n    result->PrintAsActionResult(&ss);\n  ss << \"\\n\" << why.str();\n\n  if (!found) {\n    // No expectation matches this call - reports a failure.\n    Expect(false, NULL, -1, ss.str());\n  } else if (is_excessive) {\n    // We had an upper-bound violation and the failure message is in ss.\n    Expect(false, untyped_expectation->file(),\n           untyped_expectation->line(), ss.str());\n  } else {\n    // We had an expected call and the matching expectation is\n    // described in ss.\n    Log(kInfo, loc.str() + ss.str(), 2);\n  }\n\n  return result;\n}\n\n// Returns an Expectation object that references and co-owns exp,\n// which must be an expectation on this mock function.\nExpectation UntypedFunctionMockerBase::GetHandleOf(ExpectationBase* exp) {\n  for (UntypedExpectations::const_iterator it =\n           untyped_expectations_.begin();\n       it != untyped_expectations_.end(); ++it) {\n    if (it->get() == exp) {\n      return Expectation(*it);\n    }\n  }\n\n  Assert(false, __FILE__, __LINE__, \"Cannot find expectation.\");\n  return Expectation();\n  // The above statement is just to make the code compile, and will\n  // never be executed.\n}\n\n// Verifies that all expectations on this mock function have been\n// satisfied.  Reports one or more Google Test non-fatal failures\n// and returns false if not.\nbool UntypedFunctionMockerBase::VerifyAndClearExpectationsLocked()\n    GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) {\n  g_gmock_mutex.AssertHeld();\n  bool expectations_met = true;\n  for (UntypedExpectations::const_iterator it =\n           untyped_expectations_.begin();\n       it != untyped_expectations_.end(); ++it) {\n    ExpectationBase* const untyped_expectation = it->get();\n    if (untyped_expectation->IsOverSaturated()) {\n      // There was an upper-bound violation.  Since the error was\n      // already reported when it occurred, there is no need to do\n      // anything here.\n      expectations_met = false;\n    } else if (!untyped_expectation->IsSatisfied()) {\n      expectations_met = false;\n      ::std::stringstream ss;\n      ss  << \"Actual function call count doesn't match \"\n          << untyped_expectation->source_text() << \"...\\n\";\n      // No need to show the source file location of the expectation\n      // in the description, as the Expect() call that follows already\n      // takes care of it.\n      untyped_expectation->MaybeDescribeExtraMatcherTo(&ss);\n      untyped_expectation->DescribeCallCountTo(&ss);\n      Expect(false, untyped_expectation->file(),\n             untyped_expectation->line(), ss.str());\n    }\n  }\n\n  // Deleting our expectations may trigger other mock objects to be deleted, for\n  // example if an action contains a reference counted smart pointer to that\n  // mock object, and that is the last reference. So if we delete our\n  // expectations within the context of the global mutex we may deadlock when\n  // this method is called again. Instead, make a copy of the set of\n  // expectations to delete, clear our set within the mutex, and then clear the\n  // copied set outside of it.\n  UntypedExpectations expectations_to_delete;\n  untyped_expectations_.swap(expectations_to_delete);\n\n  g_gmock_mutex.Unlock();\n  expectations_to_delete.clear();\n  g_gmock_mutex.Lock();\n\n  return expectations_met;\n}\n\n}  // namespace internal\n\n// Class Mock.\n\nnamespace {\n\ntypedef std::set<internal::UntypedFunctionMockerBase*> FunctionMockers;\n\n// The current state of a mock object.  Such information is needed for\n// detecting leaked mock objects and explicitly verifying a mock's\n// expectations.\nstruct MockObjectState {\n  MockObjectState()\n      : first_used_file(NULL), first_used_line(-1), leakable(false) {}\n\n  // Where in the source file an ON_CALL or EXPECT_CALL is first\n  // invoked on this mock object.\n  const char* first_used_file;\n  int first_used_line;\n  ::std::string first_used_test_case;\n  ::std::string first_used_test;\n  bool leakable;  // true iff it's OK to leak the object.\n  FunctionMockers function_mockers;  // All registered methods of the object.\n};\n\n// A global registry holding the state of all mock objects that are\n// alive.  A mock object is added to this registry the first time\n// Mock::AllowLeak(), ON_CALL(), or EXPECT_CALL() is called on it.  It\n// is removed from the registry in the mock object's destructor.\nclass MockObjectRegistry {\n public:\n  // Maps a mock object (identified by its address) to its state.\n  typedef std::map<const void*, MockObjectState> StateMap;\n\n  // This destructor will be called when a program exits, after all\n  // tests in it have been run.  By then, there should be no mock\n  // object alive.  Therefore we report any living object as test\n  // failure, unless the user explicitly asked us to ignore it.\n  ~MockObjectRegistry() {\n    // \"using ::std::cout;\" doesn't work with Symbian's STLport, where cout is\n    // a macro.\n\n    if (!GMOCK_FLAG(catch_leaked_mocks))\n      return;\n\n    int leaked_count = 0;\n    for (StateMap::const_iterator it = states_.begin(); it != states_.end();\n         ++it) {\n      if (it->second.leakable)  // The user said it's fine to leak this object.\n        continue;\n\n      // TODO(wan@google.com): Print the type of the leaked object.\n      // This can help the user identify the leaked object.\n      std::cout << \"\\n\";\n      const MockObjectState& state = it->second;\n      std::cout << internal::FormatFileLocation(state.first_used_file,\n                                                state.first_used_line);\n      std::cout << \" ERROR: this mock object\";\n      if (state.first_used_test != \"\") {\n        std::cout << \" (used in test \" << state.first_used_test_case << \".\"\n             << state.first_used_test << \")\";\n      }\n      std::cout << \" should be deleted but never is. Its address is @\"\n           << it->first << \".\";\n      leaked_count++;\n    }\n    if (leaked_count > 0) {\n      std::cout << \"\\nERROR: \" << leaked_count\n           << \" leaked mock \" << (leaked_count == 1 ? \"object\" : \"objects\")\n           << \" found at program exit.\\n\";\n      std::cout.flush();\n      ::std::cerr.flush();\n      // RUN_ALL_TESTS() has already returned when this destructor is\n      // called.  Therefore we cannot use the normal Google Test\n      // failure reporting mechanism.\n      _exit(1);  // We cannot call exit() as it is not reentrant and\n                 // may already have been called.\n    }\n  }\n\n  StateMap& states() { return states_; }\n\n private:\n  StateMap states_;\n};\n\n// Protected by g_gmock_mutex.\nMockObjectRegistry g_mock_object_registry;\n\n// Maps a mock object to the reaction Google Mock should have when an\n// uninteresting method is called.  Protected by g_gmock_mutex.\nstd::map<const void*, internal::CallReaction> g_uninteresting_call_reaction;\n\n// Sets the reaction Google Mock should have when an uninteresting\n// method of the given mock object is called.\nvoid SetReactionOnUninterestingCalls(const void* mock_obj,\n                                     internal::CallReaction reaction)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  internal::MutexLock l(&internal::g_gmock_mutex);\n  g_uninteresting_call_reaction[mock_obj] = reaction;\n}\n\n}  // namespace\n\n// Tells Google Mock to allow uninteresting calls on the given mock\n// object.\nvoid Mock::AllowUninterestingCalls(const void* mock_obj)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  SetReactionOnUninterestingCalls(mock_obj, internal::kAllow);\n}\n\n// Tells Google Mock to warn the user about uninteresting calls on the\n// given mock object.\nvoid Mock::WarnUninterestingCalls(const void* mock_obj)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  SetReactionOnUninterestingCalls(mock_obj, internal::kWarn);\n}\n\n// Tells Google Mock to fail uninteresting calls on the given mock\n// object.\nvoid Mock::FailUninterestingCalls(const void* mock_obj)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  SetReactionOnUninterestingCalls(mock_obj, internal::kFail);\n}\n\n// Tells Google Mock the given mock object is being destroyed and its\n// entry in the call-reaction table should be removed.\nvoid Mock::UnregisterCallReaction(const void* mock_obj)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  internal::MutexLock l(&internal::g_gmock_mutex);\n  g_uninteresting_call_reaction.erase(mock_obj);\n}\n\n// Returns the reaction Google Mock will have on uninteresting calls\n// made on the given mock object.\ninternal::CallReaction Mock::GetReactionOnUninterestingCalls(\n    const void* mock_obj)\n        GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  internal::MutexLock l(&internal::g_gmock_mutex);\n  return (g_uninteresting_call_reaction.count(mock_obj) == 0) ?\n      internal::kDefault : g_uninteresting_call_reaction[mock_obj];\n}\n\n// Tells Google Mock to ignore mock_obj when checking for leaked mock\n// objects.\nvoid Mock::AllowLeak(const void* mock_obj)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  internal::MutexLock l(&internal::g_gmock_mutex);\n  g_mock_object_registry.states()[mock_obj].leakable = true;\n}\n\n// Verifies and clears all expectations on the given mock object.  If\n// the expectations aren't satisfied, generates one or more Google\n// Test non-fatal failures and returns false.\nbool Mock::VerifyAndClearExpectations(void* mock_obj)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  internal::MutexLock l(&internal::g_gmock_mutex);\n  return VerifyAndClearExpectationsLocked(mock_obj);\n}\n\n// Verifies all expectations on the given mock object and clears its\n// default actions and expectations.  Returns true iff the\n// verification was successful.\nbool Mock::VerifyAndClear(void* mock_obj)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  internal::MutexLock l(&internal::g_gmock_mutex);\n  ClearDefaultActionsLocked(mock_obj);\n  return VerifyAndClearExpectationsLocked(mock_obj);\n}\n\n// Verifies and clears all expectations on the given mock object.  If\n// the expectations aren't satisfied, generates one or more Google\n// Test non-fatal failures and returns false.\nbool Mock::VerifyAndClearExpectationsLocked(void* mock_obj)\n    GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex) {\n  internal::g_gmock_mutex.AssertHeld();\n  if (g_mock_object_registry.states().count(mock_obj) == 0) {\n    // No EXPECT_CALL() was set on the given mock object.\n    return true;\n  }\n\n  // Verifies and clears the expectations on each mock method in the\n  // given mock object.\n  bool expectations_met = true;\n  FunctionMockers& mockers =\n      g_mock_object_registry.states()[mock_obj].function_mockers;\n  for (FunctionMockers::const_iterator it = mockers.begin();\n       it != mockers.end(); ++it) {\n    if (!(*it)->VerifyAndClearExpectationsLocked()) {\n      expectations_met = false;\n    }\n  }\n\n  // We don't clear the content of mockers, as they may still be\n  // needed by ClearDefaultActionsLocked().\n  return expectations_met;\n}\n\n// Registers a mock object and a mock method it owns.\nvoid Mock::Register(const void* mock_obj,\n                    internal::UntypedFunctionMockerBase* mocker)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  internal::MutexLock l(&internal::g_gmock_mutex);\n  g_mock_object_registry.states()[mock_obj].function_mockers.insert(mocker);\n}\n\n// Tells Google Mock where in the source code mock_obj is used in an\n// ON_CALL or EXPECT_CALL.  In case mock_obj is leaked, this\n// information helps the user identify which object it is.\nvoid Mock::RegisterUseByOnCallOrExpectCall(const void* mock_obj,\n                                           const char* file, int line)\n    GTEST_LOCK_EXCLUDED_(internal::g_gmock_mutex) {\n  internal::MutexLock l(&internal::g_gmock_mutex);\n  MockObjectState& state = g_mock_object_registry.states()[mock_obj];\n  if (state.first_used_file == NULL) {\n    state.first_used_file = file;\n    state.first_used_line = line;\n    const TestInfo* const test_info =\n        UnitTest::GetInstance()->current_test_info();\n    if (test_info != NULL) {\n      // TODO(wan@google.com): record the test case name when the\n      // ON_CALL or EXPECT_CALL is invoked from SetUpTestCase() or\n      // TearDownTestCase().\n      state.first_used_test_case = test_info->test_case_name();\n      state.first_used_test = test_info->name();\n    }\n  }\n}\n\n// Unregisters a mock method; removes the owning mock object from the\n// registry when the last mock method associated with it has been\n// unregistered.  This is called only in the destructor of\n// FunctionMockerBase.\nvoid Mock::UnregisterLocked(internal::UntypedFunctionMockerBase* mocker)\n    GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex) {\n  internal::g_gmock_mutex.AssertHeld();\n  for (MockObjectRegistry::StateMap::iterator it =\n           g_mock_object_registry.states().begin();\n       it != g_mock_object_registry.states().end(); ++it) {\n    FunctionMockers& mockers = it->second.function_mockers;\n    if (mockers.erase(mocker) > 0) {\n      // mocker was in mockers and has been just removed.\n      if (mockers.empty()) {\n        g_mock_object_registry.states().erase(it);\n      }\n      return;\n    }\n  }\n}\n\n// Clears all ON_CALL()s set on the given mock object.\nvoid Mock::ClearDefaultActionsLocked(void* mock_obj)\n    GTEST_EXCLUSIVE_LOCK_REQUIRED_(internal::g_gmock_mutex) {\n  internal::g_gmock_mutex.AssertHeld();\n\n  if (g_mock_object_registry.states().count(mock_obj) == 0) {\n    // No ON_CALL() was set on the given mock object.\n    return;\n  }\n\n  // Clears the default actions for each mock method in the given mock\n  // object.\n  FunctionMockers& mockers =\n      g_mock_object_registry.states()[mock_obj].function_mockers;\n  for (FunctionMockers::const_iterator it = mockers.begin();\n       it != mockers.end(); ++it) {\n    (*it)->ClearDefaultActionsLocked();\n  }\n\n  // We don't clear the content of mockers, as they may still be\n  // needed by VerifyAndClearExpectationsLocked().\n}\n\nExpectation::Expectation() {}\n\nExpectation::Expectation(\n    const internal::linked_ptr<internal::ExpectationBase>& an_expectation_base)\n    : expectation_base_(an_expectation_base) {}\n\nExpectation::~Expectation() {}\n\n// Adds an expectation to a sequence.\nvoid Sequence::AddExpectation(const Expectation& expectation) const {\n  if (*last_expectation_ != expectation) {\n    if (last_expectation_->expectation_base() != NULL) {\n      expectation.expectation_base()->immediate_prerequisites_\n          += *last_expectation_;\n    }\n    *last_expectation_ = expectation;\n  }\n}\n\n// Creates the implicit sequence if there isn't one.\nInSequence::InSequence() {\n  if (internal::g_gmock_implicit_sequence.get() == NULL) {\n    internal::g_gmock_implicit_sequence.set(new Sequence);\n    sequence_created_ = true;\n  } else {\n    sequence_created_ = false;\n  }\n}\n\n// Deletes the implicit sequence if it was created by the constructor\n// of this object.\nInSequence::~InSequence() {\n  if (sequence_created_) {\n    delete internal::g_gmock_implicit_sequence.get();\n    internal::g_gmock_implicit_sequence.set(NULL);\n  }\n}\n\n}  // namespace testing\n"
  },
  {
    "path": "ext/gmock/src/gmock.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"gmock/gmock.h\"\n#include \"gmock/internal/gmock-port.h\"\n\nnamespace testing {\n\n// TODO(wan@google.com): support using environment variables to\n// control the flag values, like what Google Test does.\n\nGMOCK_DEFINE_bool_(catch_leaked_mocks, true,\n                   \"true iff Google Mock should report leaked mock objects \"\n                   \"as failures.\");\n\nGMOCK_DEFINE_string_(verbose, internal::kWarningVerbosity,\n                     \"Controls how verbose Google Mock's output is.\"\n                     \"  Valid values:\\n\"\n                     \"  info    - prints all messages.\\n\"\n                     \"  warning - prints warnings and errors.\\n\"\n                     \"  error   - prints errors only.\");\n\nnamespace internal {\n\n// Parses a string as a command line flag.  The string should have the\n// format \"--gmock_flag=value\".  When def_optional is true, the\n// \"=value\" part can be omitted.\n//\n// Returns the value of the flag, or NULL if the parsing failed.\nstatic const char* ParseGoogleMockFlagValue(const char* str,\n                                            const char* flag,\n                                            bool def_optional) {\n  // str and flag must not be NULL.\n  if (str == NULL || flag == NULL) return NULL;\n\n  // The flag must start with \"--gmock_\".\n  const std::string flag_str = std::string(\"--gmock_\") + flag;\n  const size_t flag_len = flag_str.length();\n  if (strncmp(str, flag_str.c_str(), flag_len) != 0) return NULL;\n\n  // Skips the flag name.\n  const char* flag_end = str + flag_len;\n\n  // When def_optional is true, it's OK to not have a \"=value\" part.\n  if (def_optional && (flag_end[0] == '\\0')) {\n    return flag_end;\n  }\n\n  // If def_optional is true and there are more characters after the\n  // flag name, or if def_optional is false, there must be a '=' after\n  // the flag name.\n  if (flag_end[0] != '=') return NULL;\n\n  // Returns the string after \"=\".\n  return flag_end + 1;\n}\n\n// Parses a string for a Google Mock bool flag, in the form of\n// \"--gmock_flag=value\".\n//\n// On success, stores the value of the flag in *value, and returns\n// true.  On failure, returns false without changing *value.\nstatic bool ParseGoogleMockBoolFlag(const char* str, const char* flag,\n                                    bool* value) {\n  // Gets the value of the flag as a string.\n  const char* const value_str = ParseGoogleMockFlagValue(str, flag, true);\n\n  // Aborts if the parsing failed.\n  if (value_str == NULL) return false;\n\n  // Converts the string value to a bool.\n  *value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F');\n  return true;\n}\n\n// Parses a string for a Google Mock string flag, in the form of\n// \"--gmock_flag=value\".\n//\n// On success, stores the value of the flag in *value, and returns\n// true.  On failure, returns false without changing *value.\nstatic bool ParseGoogleMockStringFlag(const char* str, const char* flag,\n                                      std::string* value) {\n  // Gets the value of the flag as a string.\n  const char* const value_str = ParseGoogleMockFlagValue(str, flag, false);\n\n  // Aborts if the parsing failed.\n  if (value_str == NULL) return false;\n\n  // Sets *value to the value of the flag.\n  *value = value_str;\n  return true;\n}\n\n// The internal implementation of InitGoogleMock().\n//\n// The type parameter CharType can be instantiated to either char or\n// wchar_t.\ntemplate <typename CharType>\nvoid InitGoogleMockImpl(int* argc, CharType** argv) {\n  // Makes sure Google Test is initialized.  InitGoogleTest() is\n  // idempotent, so it's fine if the user has already called it.\n  InitGoogleTest(argc, argv);\n  if (*argc <= 0) return;\n\n  for (int i = 1; i != *argc; i++) {\n    const std::string arg_string = StreamableToString(argv[i]);\n    const char* const arg = arg_string.c_str();\n\n    // Do we see a Google Mock flag?\n    if (ParseGoogleMockBoolFlag(arg, \"catch_leaked_mocks\",\n                                &GMOCK_FLAG(catch_leaked_mocks)) ||\n        ParseGoogleMockStringFlag(arg, \"verbose\", &GMOCK_FLAG(verbose))) {\n      // Yes.  Shift the remainder of the argv list left by one.  Note\n      // that argv has (*argc + 1) elements, the last one always being\n      // NULL.  The following loop moves the trailing NULL element as\n      // well.\n      for (int j = i; j != *argc; j++) {\n        argv[j] = argv[j + 1];\n      }\n\n      // Decrements the argument count.\n      (*argc)--;\n\n      // We also need to decrement the iterator as we just removed\n      // an element.\n      i--;\n    }\n  }\n}\n\n}  // namespace internal\n\n// Initializes Google Mock.  This must be called before running the\n// tests.  In particular, it parses a command line for the flags that\n// Google Mock recognizes.  Whenever a Google Mock flag is seen, it is\n// removed from argv, and *argc is decremented.\n//\n// No value is returned.  Instead, the Google Mock flag variables are\n// updated.\n//\n// Since Google Test is needed for Google Mock to work, this function\n// also initializes Google Test and parses its flags, if that hasn't\n// been done.\nGTEST_API_ void InitGoogleMock(int* argc, char** argv) {\n  internal::InitGoogleMockImpl(argc, argv);\n}\n\n// This overloaded version can be used in Windows programs compiled in\n// UNICODE mode.\nGTEST_API_ void InitGoogleMock(int* argc, wchar_t** argv) {\n  internal::InitGoogleMockImpl(argc, argv);\n}\n\n}  // namespace testing\n"
  },
  {
    "path": "ext/gmock/src/gmock_main.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include <iostream>\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n// MS C++ compiler/linker has a bug on Windows (not on Windows CE), which\n// causes a link error when _tmain is defined in a static library and UNICODE\n// is enabled. For this reason instead of _tmain, main function is used on\n// Windows. See the following link to track the current status of this bug:\n// http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=394464  // NOLINT\n#if GTEST_OS_WINDOWS_MOBILE\n# include <tchar.h>  // NOLINT\n\nGTEST_API_ int _tmain(int argc, TCHAR** argv) {\n#else\nGTEST_API_ int main(int argc, char** argv) {\n#endif  // GTEST_OS_WINDOWS_MOBILE\n  std::cout << \"Running main() from gmock_main.cc\\n\";\n  // Since Google Mock depends on Google Test, InitGoogleMock() is\n  // also responsible for initializing Google Test.  Therefore there's\n  // no need for calling testing::InitGoogleTest() separately.\n  testing::InitGoogleMock(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "ext/gmock/test/gmock-actions_test.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file tests the built-in actions.\n\n#include \"gmock/gmock-actions.h\"\n#include <algorithm>\n#include <iterator>\n#include <string>\n#include \"gmock/gmock.h\"\n#include \"gmock/internal/gmock-port.h\"\n#include \"gtest/gtest.h\"\n#include \"gtest/gtest-spi.h\"\n\nnamespace {\n\nusing ::std::tr1::get;\nusing ::std::tr1::make_tuple;\nusing ::std::tr1::tuple;\nusing ::std::tr1::tuple_element;\nusing testing::internal::BuiltInDefaultValue;\nusing testing::internal::Int64;\nusing testing::internal::UInt64;\n// This list should be kept sorted.\nusing testing::_;\nusing testing::Action;\nusing testing::ActionInterface;\nusing testing::Assign;\nusing testing::ByRef;\nusing testing::DefaultValue;\nusing testing::DoDefault;\nusing testing::IgnoreResult;\nusing testing::Invoke;\nusing testing::InvokeWithoutArgs;\nusing testing::MakePolymorphicAction;\nusing testing::Ne;\nusing testing::PolymorphicAction;\nusing testing::Return;\nusing testing::ReturnNull;\nusing testing::ReturnRef;\nusing testing::ReturnRefOfCopy;\nusing testing::SetArgPointee;\nusing testing::SetArgumentPointee;\n\n#if !GTEST_OS_WINDOWS_MOBILE\nusing testing::SetErrnoAndReturn;\n#endif\n\n#if GTEST_HAS_PROTOBUF_\nusing testing::internal::TestMessage;\n#endif  // GTEST_HAS_PROTOBUF_\n\n// Tests that BuiltInDefaultValue<T*>::Get() returns NULL.\nTEST(BuiltInDefaultValueTest, IsNullForPointerTypes) {\n  EXPECT_TRUE(BuiltInDefaultValue<int*>::Get() == NULL);\n  EXPECT_TRUE(BuiltInDefaultValue<const char*>::Get() == NULL);\n  EXPECT_TRUE(BuiltInDefaultValue<void*>::Get() == NULL);\n}\n\n// Tests that BuiltInDefaultValue<T*>::Exists() return true.\nTEST(BuiltInDefaultValueTest, ExistsForPointerTypes) {\n  EXPECT_TRUE(BuiltInDefaultValue<int*>::Exists());\n  EXPECT_TRUE(BuiltInDefaultValue<const char*>::Exists());\n  EXPECT_TRUE(BuiltInDefaultValue<void*>::Exists());\n}\n\n// Tests that BuiltInDefaultValue<T>::Get() returns 0 when T is a\n// built-in numeric type.\nTEST(BuiltInDefaultValueTest, IsZeroForNumericTypes) {\n  EXPECT_EQ(0U, BuiltInDefaultValue<unsigned char>::Get());\n  EXPECT_EQ(0, BuiltInDefaultValue<signed char>::Get());\n  EXPECT_EQ(0, BuiltInDefaultValue<char>::Get());\n#if GMOCK_HAS_SIGNED_WCHAR_T_\n  EXPECT_EQ(0U, BuiltInDefaultValue<unsigned wchar_t>::Get());\n  EXPECT_EQ(0, BuiltInDefaultValue<signed wchar_t>::Get());\n#endif\n#if GMOCK_WCHAR_T_IS_NATIVE_\n  EXPECT_EQ(0, BuiltInDefaultValue<wchar_t>::Get());\n#endif\n  EXPECT_EQ(0U, BuiltInDefaultValue<unsigned short>::Get());  // NOLINT\n  EXPECT_EQ(0, BuiltInDefaultValue<signed short>::Get());  // NOLINT\n  EXPECT_EQ(0, BuiltInDefaultValue<short>::Get());  // NOLINT\n  EXPECT_EQ(0U, BuiltInDefaultValue<unsigned int>::Get());\n  EXPECT_EQ(0, BuiltInDefaultValue<signed int>::Get());\n  EXPECT_EQ(0, BuiltInDefaultValue<int>::Get());\n  EXPECT_EQ(0U, BuiltInDefaultValue<unsigned long>::Get());  // NOLINT\n  EXPECT_EQ(0, BuiltInDefaultValue<signed long>::Get());  // NOLINT\n  EXPECT_EQ(0, BuiltInDefaultValue<long>::Get());  // NOLINT\n  EXPECT_EQ(0U, BuiltInDefaultValue<UInt64>::Get());\n  EXPECT_EQ(0, BuiltInDefaultValue<Int64>::Get());\n  EXPECT_EQ(0, BuiltInDefaultValue<float>::Get());\n  EXPECT_EQ(0, BuiltInDefaultValue<double>::Get());\n}\n\n// Tests that BuiltInDefaultValue<T>::Exists() returns true when T is a\n// built-in numeric type.\nTEST(BuiltInDefaultValueTest, ExistsForNumericTypes) {\n  EXPECT_TRUE(BuiltInDefaultValue<unsigned char>::Exists());\n  EXPECT_TRUE(BuiltInDefaultValue<signed char>::Exists());\n  EXPECT_TRUE(BuiltInDefaultValue<char>::Exists());\n#if GMOCK_HAS_SIGNED_WCHAR_T_\n  EXPECT_TRUE(BuiltInDefaultValue<unsigned wchar_t>::Exists());\n  EXPECT_TRUE(BuiltInDefaultValue<signed wchar_t>::Exists());\n#endif\n#if GMOCK_WCHAR_T_IS_NATIVE_\n  EXPECT_TRUE(BuiltInDefaultValue<wchar_t>::Exists());\n#endif\n  EXPECT_TRUE(BuiltInDefaultValue<unsigned short>::Exists());  // NOLINT\n  EXPECT_TRUE(BuiltInDefaultValue<signed short>::Exists());  // NOLINT\n  EXPECT_TRUE(BuiltInDefaultValue<short>::Exists());  // NOLINT\n  EXPECT_TRUE(BuiltInDefaultValue<unsigned int>::Exists());\n  EXPECT_TRUE(BuiltInDefaultValue<signed int>::Exists());\n  EXPECT_TRUE(BuiltInDefaultValue<int>::Exists());\n  EXPECT_TRUE(BuiltInDefaultValue<unsigned long>::Exists());  // NOLINT\n  EXPECT_TRUE(BuiltInDefaultValue<signed long>::Exists());  // NOLINT\n  EXPECT_TRUE(BuiltInDefaultValue<long>::Exists());  // NOLINT\n  EXPECT_TRUE(BuiltInDefaultValue<UInt64>::Exists());\n  EXPECT_TRUE(BuiltInDefaultValue<Int64>::Exists());\n  EXPECT_TRUE(BuiltInDefaultValue<float>::Exists());\n  EXPECT_TRUE(BuiltInDefaultValue<double>::Exists());\n}\n\n// Tests that BuiltInDefaultValue<bool>::Get() returns false.\nTEST(BuiltInDefaultValueTest, IsFalseForBool) {\n  EXPECT_FALSE(BuiltInDefaultValue<bool>::Get());\n}\n\n// Tests that BuiltInDefaultValue<bool>::Exists() returns true.\nTEST(BuiltInDefaultValueTest, BoolExists) {\n  EXPECT_TRUE(BuiltInDefaultValue<bool>::Exists());\n}\n\n// Tests that BuiltInDefaultValue<T>::Get() returns \"\" when T is a\n// string type.\nTEST(BuiltInDefaultValueTest, IsEmptyStringForString) {\n#if GTEST_HAS_GLOBAL_STRING\n  EXPECT_EQ(\"\", BuiltInDefaultValue< ::string>::Get());\n#endif  // GTEST_HAS_GLOBAL_STRING\n\n  EXPECT_EQ(\"\", BuiltInDefaultValue< ::std::string>::Get());\n}\n\n// Tests that BuiltInDefaultValue<T>::Exists() returns true when T is a\n// string type.\nTEST(BuiltInDefaultValueTest, ExistsForString) {\n#if GTEST_HAS_GLOBAL_STRING\n  EXPECT_TRUE(BuiltInDefaultValue< ::string>::Exists());\n#endif  // GTEST_HAS_GLOBAL_STRING\n\n  EXPECT_TRUE(BuiltInDefaultValue< ::std::string>::Exists());\n}\n\n// Tests that BuiltInDefaultValue<const T>::Get() returns the same\n// value as BuiltInDefaultValue<T>::Get() does.\nTEST(BuiltInDefaultValueTest, WorksForConstTypes) {\n  EXPECT_EQ(\"\", BuiltInDefaultValue<const std::string>::Get());\n  EXPECT_EQ(0, BuiltInDefaultValue<const int>::Get());\n  EXPECT_TRUE(BuiltInDefaultValue<char* const>::Get() == NULL);\n  EXPECT_FALSE(BuiltInDefaultValue<const bool>::Get());\n}\n\n// Tests that BuiltInDefaultValue<T>::Get() aborts the program with\n// the correct error message when T is a user-defined type.\nstruct UserType {\n  UserType() : value(0) {}\n\n  int value;\n};\n\nTEST(BuiltInDefaultValueTest, UserTypeHasNoDefault) {\n  EXPECT_FALSE(BuiltInDefaultValue<UserType>::Exists());\n}\n\n// Tests that BuiltInDefaultValue<T&>::Get() aborts the program.\nTEST(BuiltInDefaultValueDeathTest, IsUndefinedForReferences) {\n  EXPECT_DEATH_IF_SUPPORTED({\n    BuiltInDefaultValue<int&>::Get();\n  }, \"\");\n  EXPECT_DEATH_IF_SUPPORTED({\n    BuiltInDefaultValue<const char&>::Get();\n  }, \"\");\n}\n\nTEST(BuiltInDefaultValueDeathTest, IsUndefinedForUserTypes) {\n  EXPECT_DEATH_IF_SUPPORTED({\n    BuiltInDefaultValue<UserType>::Get();\n  }, \"\");\n}\n\n// Tests that DefaultValue<T>::IsSet() is false initially.\nTEST(DefaultValueTest, IsInitiallyUnset) {\n  EXPECT_FALSE(DefaultValue<int>::IsSet());\n  EXPECT_FALSE(DefaultValue<const UserType>::IsSet());\n}\n\n// Tests that DefaultValue<T> can be set and then unset.\nTEST(DefaultValueTest, CanBeSetAndUnset) {\n  EXPECT_TRUE(DefaultValue<int>::Exists());\n  EXPECT_FALSE(DefaultValue<const UserType>::Exists());\n\n  DefaultValue<int>::Set(1);\n  DefaultValue<const UserType>::Set(UserType());\n\n  EXPECT_EQ(1, DefaultValue<int>::Get());\n  EXPECT_EQ(0, DefaultValue<const UserType>::Get().value);\n\n  EXPECT_TRUE(DefaultValue<int>::Exists());\n  EXPECT_TRUE(DefaultValue<const UserType>::Exists());\n\n  DefaultValue<int>::Clear();\n  DefaultValue<const UserType>::Clear();\n\n  EXPECT_FALSE(DefaultValue<int>::IsSet());\n  EXPECT_FALSE(DefaultValue<const UserType>::IsSet());\n\n  EXPECT_TRUE(DefaultValue<int>::Exists());\n  EXPECT_FALSE(DefaultValue<const UserType>::Exists());\n}\n\n// Tests that DefaultValue<T>::Get() returns the\n// BuiltInDefaultValue<T>::Get() when DefaultValue<T>::IsSet() is\n// false.\nTEST(DefaultValueDeathTest, GetReturnsBuiltInDefaultValueWhenUnset) {\n  EXPECT_FALSE(DefaultValue<int>::IsSet());\n  EXPECT_TRUE(DefaultValue<int>::Exists());\n  EXPECT_FALSE(DefaultValue<UserType>::IsSet());\n  EXPECT_FALSE(DefaultValue<UserType>::Exists());\n\n  EXPECT_EQ(0, DefaultValue<int>::Get());\n\n  EXPECT_DEATH_IF_SUPPORTED({\n    DefaultValue<UserType>::Get();\n  }, \"\");\n}\n\n// Tests that DefaultValue<void>::Get() returns void.\nTEST(DefaultValueTest, GetWorksForVoid) {\n  return DefaultValue<void>::Get();\n}\n\n// Tests using DefaultValue with a reference type.\n\n// Tests that DefaultValue<T&>::IsSet() is false initially.\nTEST(DefaultValueOfReferenceTest, IsInitiallyUnset) {\n  EXPECT_FALSE(DefaultValue<int&>::IsSet());\n  EXPECT_FALSE(DefaultValue<UserType&>::IsSet());\n}\n\n// Tests that DefaultValue<T&>::Exists is false initiallly.\nTEST(DefaultValueOfReferenceTest, IsInitiallyNotExisting) {\n  EXPECT_FALSE(DefaultValue<int&>::Exists());\n  EXPECT_FALSE(DefaultValue<UserType&>::Exists());\n}\n\n// Tests that DefaultValue<T&> can be set and then unset.\nTEST(DefaultValueOfReferenceTest, CanBeSetAndUnset) {\n  int n = 1;\n  DefaultValue<const int&>::Set(n);\n  UserType u;\n  DefaultValue<UserType&>::Set(u);\n\n  EXPECT_TRUE(DefaultValue<const int&>::Exists());\n  EXPECT_TRUE(DefaultValue<UserType&>::Exists());\n\n  EXPECT_EQ(&n, &(DefaultValue<const int&>::Get()));\n  EXPECT_EQ(&u, &(DefaultValue<UserType&>::Get()));\n\n  DefaultValue<const int&>::Clear();\n  DefaultValue<UserType&>::Clear();\n\n  EXPECT_FALSE(DefaultValue<const int&>::Exists());\n  EXPECT_FALSE(DefaultValue<UserType&>::Exists());\n\n  EXPECT_FALSE(DefaultValue<const int&>::IsSet());\n  EXPECT_FALSE(DefaultValue<UserType&>::IsSet());\n}\n\n// Tests that DefaultValue<T&>::Get() returns the\n// BuiltInDefaultValue<T&>::Get() when DefaultValue<T&>::IsSet() is\n// false.\nTEST(DefaultValueOfReferenceDeathTest, GetReturnsBuiltInDefaultValueWhenUnset) {\n  EXPECT_FALSE(DefaultValue<int&>::IsSet());\n  EXPECT_FALSE(DefaultValue<UserType&>::IsSet());\n\n  EXPECT_DEATH_IF_SUPPORTED({\n    DefaultValue<int&>::Get();\n  }, \"\");\n  EXPECT_DEATH_IF_SUPPORTED({\n    DefaultValue<UserType>::Get();\n  }, \"\");\n}\n\n// Tests that ActionInterface can be implemented by defining the\n// Perform method.\n\ntypedef int MyGlobalFunction(bool, int);\n\nclass MyActionImpl : public ActionInterface<MyGlobalFunction> {\n public:\n  virtual int Perform(const tuple<bool, int>& args) {\n    return get<0>(args) ? get<1>(args) : 0;\n  }\n};\n\nTEST(ActionInterfaceTest, CanBeImplementedByDefiningPerform) {\n  MyActionImpl my_action_impl;\n  (void)my_action_impl;\n}\n\nTEST(ActionInterfaceTest, MakeAction) {\n  Action<MyGlobalFunction> action = MakeAction(new MyActionImpl);\n\n  // When exercising the Perform() method of Action<F>, we must pass\n  // it a tuple whose size and type are compatible with F's argument\n  // types.  For example, if F is int(), then Perform() takes a\n  // 0-tuple; if F is void(bool, int), then Perform() takes a\n  // tuple<bool, int>, and so on.\n  EXPECT_EQ(5, action.Perform(make_tuple(true, 5)));\n}\n\n// Tests that Action<F> can be contructed from a pointer to\n// ActionInterface<F>.\nTEST(ActionTest, CanBeConstructedFromActionInterface) {\n  Action<MyGlobalFunction> action(new MyActionImpl);\n}\n\n// Tests that Action<F> delegates actual work to ActionInterface<F>.\nTEST(ActionTest, DelegatesWorkToActionInterface) {\n  const Action<MyGlobalFunction> action(new MyActionImpl);\n\n  EXPECT_EQ(5, action.Perform(make_tuple(true, 5)));\n  EXPECT_EQ(0, action.Perform(make_tuple(false, 1)));\n}\n\n// Tests that Action<F> can be copied.\nTEST(ActionTest, IsCopyable) {\n  Action<MyGlobalFunction> a1(new MyActionImpl);\n  Action<MyGlobalFunction> a2(a1);  // Tests the copy constructor.\n\n  // a1 should continue to work after being copied from.\n  EXPECT_EQ(5, a1.Perform(make_tuple(true, 5)));\n  EXPECT_EQ(0, a1.Perform(make_tuple(false, 1)));\n\n  // a2 should work like the action it was copied from.\n  EXPECT_EQ(5, a2.Perform(make_tuple(true, 5)));\n  EXPECT_EQ(0, a2.Perform(make_tuple(false, 1)));\n\n  a2 = a1;  // Tests the assignment operator.\n\n  // a1 should continue to work after being copied from.\n  EXPECT_EQ(5, a1.Perform(make_tuple(true, 5)));\n  EXPECT_EQ(0, a1.Perform(make_tuple(false, 1)));\n\n  // a2 should work like the action it was copied from.\n  EXPECT_EQ(5, a2.Perform(make_tuple(true, 5)));\n  EXPECT_EQ(0, a2.Perform(make_tuple(false, 1)));\n}\n\n// Tests that an Action<From> object can be converted to a\n// compatible Action<To> object.\n\nclass IsNotZero : public ActionInterface<bool(int)> {  // NOLINT\n public:\n  virtual bool Perform(const tuple<int>& arg) {\n    return get<0>(arg) != 0;\n  }\n};\n\n#if !GTEST_OS_SYMBIAN\n// Compiling this test on Nokia's Symbian compiler fails with:\n//  'Result' is not a member of class 'testing::internal::Function<int>'\n//  (point of instantiation: '@unnamed@gmock_actions_test_cc@::\n//      ActionTest_CanBeConvertedToOtherActionType_Test::TestBody()')\n// with no obvious fix.\nTEST(ActionTest, CanBeConvertedToOtherActionType) {\n  const Action<bool(int)> a1(new IsNotZero);  // NOLINT\n  const Action<int(char)> a2 = Action<int(char)>(a1);  // NOLINT\n  EXPECT_EQ(1, a2.Perform(make_tuple('a')));\n  EXPECT_EQ(0, a2.Perform(make_tuple('\\0')));\n}\n#endif  // !GTEST_OS_SYMBIAN\n\n// The following two classes are for testing MakePolymorphicAction().\n\n// Implements a polymorphic action that returns the second of the\n// arguments it receives.\nclass ReturnSecondArgumentAction {\n public:\n  // We want to verify that MakePolymorphicAction() can work with a\n  // polymorphic action whose Perform() method template is either\n  // const or not.  This lets us verify the non-const case.\n  template <typename Result, typename ArgumentTuple>\n  Result Perform(const ArgumentTuple& args) { return get<1>(args); }\n};\n\n// Implements a polymorphic action that can be used in a nullary\n// function to return 0.\nclass ReturnZeroFromNullaryFunctionAction {\n public:\n  // For testing that MakePolymorphicAction() works when the\n  // implementation class' Perform() method template takes only one\n  // template parameter.\n  //\n  // We want to verify that MakePolymorphicAction() can work with a\n  // polymorphic action whose Perform() method template is either\n  // const or not.  This lets us verify the const case.\n  template <typename Result>\n  Result Perform(const tuple<>&) const { return 0; }\n};\n\n// These functions verify that MakePolymorphicAction() returns a\n// PolymorphicAction<T> where T is the argument's type.\n\nPolymorphicAction<ReturnSecondArgumentAction> ReturnSecondArgument() {\n  return MakePolymorphicAction(ReturnSecondArgumentAction());\n}\n\nPolymorphicAction<ReturnZeroFromNullaryFunctionAction>\nReturnZeroFromNullaryFunction() {\n  return MakePolymorphicAction(ReturnZeroFromNullaryFunctionAction());\n}\n\n// Tests that MakePolymorphicAction() turns a polymorphic action\n// implementation class into a polymorphic action.\nTEST(MakePolymorphicActionTest, ConstructsActionFromImpl) {\n  Action<int(bool, int, double)> a1 = ReturnSecondArgument();  // NOLINT\n  EXPECT_EQ(5, a1.Perform(make_tuple(false, 5, 2.0)));\n}\n\n// Tests that MakePolymorphicAction() works when the implementation\n// class' Perform() method template has only one template parameter.\nTEST(MakePolymorphicActionTest, WorksWhenPerformHasOneTemplateParameter) {\n  Action<int()> a1 = ReturnZeroFromNullaryFunction();\n  EXPECT_EQ(0, a1.Perform(make_tuple()));\n\n  Action<void*()> a2 = ReturnZeroFromNullaryFunction();\n  EXPECT_TRUE(a2.Perform(make_tuple()) == NULL);\n}\n\n// Tests that Return() works as an action for void-returning\n// functions.\nTEST(ReturnTest, WorksForVoid) {\n  const Action<void(int)> ret = Return();  // NOLINT\n  return ret.Perform(make_tuple(1));\n}\n\n// Tests that Return(v) returns v.\nTEST(ReturnTest, ReturnsGivenValue) {\n  Action<int()> ret = Return(1);  // NOLINT\n  EXPECT_EQ(1, ret.Perform(make_tuple()));\n\n  ret = Return(-5);\n  EXPECT_EQ(-5, ret.Perform(make_tuple()));\n}\n\n// Tests that Return(\"string literal\") works.\nTEST(ReturnTest, AcceptsStringLiteral) {\n  Action<const char*()> a1 = Return(\"Hello\");\n  EXPECT_STREQ(\"Hello\", a1.Perform(make_tuple()));\n\n  Action<std::string()> a2 = Return(\"world\");\n  EXPECT_EQ(\"world\", a2.Perform(make_tuple()));\n}\n\n// Tests that Return(v) is covaraint.\n\nstruct Base {\n  bool operator==(const Base&) { return true; }\n};\n\nstruct Derived : public Base {\n  bool operator==(const Derived&) { return true; }\n};\n\nTEST(ReturnTest, IsCovariant) {\n  Base base;\n  Derived derived;\n  Action<Base*()> ret = Return(&base);\n  EXPECT_EQ(&base, ret.Perform(make_tuple()));\n\n  ret = Return(&derived);\n  EXPECT_EQ(&derived, ret.Perform(make_tuple()));\n}\n\n// Tests that the type of the value passed into Return is converted into T\n// when the action is cast to Action<T(...)> rather than when the action is\n// performed. See comments on testing::internal::ReturnAction in\n// gmock-actions.h for more information.\nclass FromType {\n public:\n  explicit FromType(bool* is_converted) : converted_(is_converted) {}\n  bool* converted() const { return converted_; }\n\n private:\n  bool* const converted_;\n\n  GTEST_DISALLOW_ASSIGN_(FromType);\n};\n\nclass ToType {\n public:\n  // Must allow implicit conversion due to use in ImplicitCast_<T>.\n  ToType(const FromType& x) { *x.converted() = true; }  // NOLINT\n};\n\nTEST(ReturnTest, ConvertsArgumentWhenConverted) {\n  bool converted = false;\n  FromType x(&converted);\n  Action<ToType()> action(Return(x));\n  EXPECT_TRUE(converted) << \"Return must convert its argument in its own \"\n                         << \"conversion operator.\";\n  converted = false;\n  action.Perform(tuple<>());\n  EXPECT_FALSE(converted) << \"Action must NOT convert its argument \"\n                          << \"when performed.\";\n}\n\nclass DestinationType {};\n\nclass SourceType {\n public:\n  // Note: a non-const typecast operator.\n  operator DestinationType() { return DestinationType(); }\n};\n\nTEST(ReturnTest, CanConvertArgumentUsingNonConstTypeCastOperator) {\n  SourceType s;\n  Action<DestinationType()> action(Return(s));\n}\n\n// Tests that ReturnNull() returns NULL in a pointer-returning function.\nTEST(ReturnNullTest, WorksInPointerReturningFunction) {\n  const Action<int*()> a1 = ReturnNull();\n  EXPECT_TRUE(a1.Perform(make_tuple()) == NULL);\n\n  const Action<const char*(bool)> a2 = ReturnNull();  // NOLINT\n  EXPECT_TRUE(a2.Perform(make_tuple(true)) == NULL);\n}\n\n// Tests that ReturnRef(v) works for reference types.\nTEST(ReturnRefTest, WorksForReference) {\n  const int n = 0;\n  const Action<const int&(bool)> ret = ReturnRef(n);  // NOLINT\n\n  EXPECT_EQ(&n, &ret.Perform(make_tuple(true)));\n}\n\n// Tests that ReturnRef(v) is covariant.\nTEST(ReturnRefTest, IsCovariant) {\n  Base base;\n  Derived derived;\n  Action<Base&()> a = ReturnRef(base);\n  EXPECT_EQ(&base, &a.Perform(make_tuple()));\n\n  a = ReturnRef(derived);\n  EXPECT_EQ(&derived, &a.Perform(make_tuple()));\n}\n\n// Tests that ReturnRefOfCopy(v) works for reference types.\nTEST(ReturnRefOfCopyTest, WorksForReference) {\n  int n = 42;\n  const Action<const int&()> ret = ReturnRefOfCopy(n);\n\n  EXPECT_NE(&n, &ret.Perform(make_tuple()));\n  EXPECT_EQ(42, ret.Perform(make_tuple()));\n\n  n = 43;\n  EXPECT_NE(&n, &ret.Perform(make_tuple()));\n  EXPECT_EQ(42, ret.Perform(make_tuple()));\n}\n\n// Tests that ReturnRefOfCopy(v) is covariant.\nTEST(ReturnRefOfCopyTest, IsCovariant) {\n  Base base;\n  Derived derived;\n  Action<Base&()> a = ReturnRefOfCopy(base);\n  EXPECT_NE(&base, &a.Perform(make_tuple()));\n\n  a = ReturnRefOfCopy(derived);\n  EXPECT_NE(&derived, &a.Perform(make_tuple()));\n}\n\n// Tests that DoDefault() does the default action for the mock method.\n\nclass MyClass {};\n\nclass MockClass {\n public:\n  MockClass() {}\n\n  MOCK_METHOD1(IntFunc, int(bool flag));  // NOLINT\n  MOCK_METHOD0(Foo, MyClass());\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockClass);\n};\n\n// Tests that DoDefault() returns the built-in default value for the\n// return type by default.\nTEST(DoDefaultTest, ReturnsBuiltInDefaultValueByDefault) {\n  MockClass mock;\n  EXPECT_CALL(mock, IntFunc(_))\n      .WillOnce(DoDefault());\n  EXPECT_EQ(0, mock.IntFunc(true));\n}\n\n// Tests that DoDefault() throws (when exceptions are enabled) or aborts\n// the process when there is no built-in default value for the return type.\nTEST(DoDefaultDeathTest, DiesForUnknowType) {\n  MockClass mock;\n  EXPECT_CALL(mock, Foo())\n      .WillRepeatedly(DoDefault());\n#if GTEST_HAS_EXCEPTIONS\n  EXPECT_ANY_THROW(mock.Foo());\n#else\n  EXPECT_DEATH_IF_SUPPORTED({\n    mock.Foo();\n  }, \"\");\n#endif\n}\n\n// Tests that using DoDefault() inside a composite action leads to a\n// run-time error.\n\nvoid VoidFunc(bool /* flag */) {}\n\nTEST(DoDefaultDeathTest, DiesIfUsedInCompositeAction) {\n  MockClass mock;\n  EXPECT_CALL(mock, IntFunc(_))\n      .WillRepeatedly(DoAll(Invoke(VoidFunc),\n                            DoDefault()));\n\n  // Ideally we should verify the error message as well.  Sadly,\n  // EXPECT_DEATH() can only capture stderr, while Google Mock's\n  // errors are printed on stdout.  Therefore we have to settle for\n  // not verifying the message.\n  EXPECT_DEATH_IF_SUPPORTED({\n    mock.IntFunc(true);\n  }, \"\");\n}\n\n// Tests that DoDefault() returns the default value set by\n// DefaultValue<T>::Set() when it's not overriden by an ON_CALL().\nTEST(DoDefaultTest, ReturnsUserSpecifiedPerTypeDefaultValueWhenThereIsOne) {\n  DefaultValue<int>::Set(1);\n  MockClass mock;\n  EXPECT_CALL(mock, IntFunc(_))\n      .WillOnce(DoDefault());\n  EXPECT_EQ(1, mock.IntFunc(false));\n  DefaultValue<int>::Clear();\n}\n\n// Tests that DoDefault() does the action specified by ON_CALL().\nTEST(DoDefaultTest, DoesWhatOnCallSpecifies) {\n  MockClass mock;\n  ON_CALL(mock, IntFunc(_))\n      .WillByDefault(Return(2));\n  EXPECT_CALL(mock, IntFunc(_))\n      .WillOnce(DoDefault());\n  EXPECT_EQ(2, mock.IntFunc(false));\n}\n\n// Tests that using DoDefault() in ON_CALL() leads to a run-time failure.\nTEST(DoDefaultTest, CannotBeUsedInOnCall) {\n  MockClass mock;\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    ON_CALL(mock, IntFunc(_))\n      .WillByDefault(DoDefault());\n  }, \"DoDefault() cannot be used in ON_CALL()\");\n}\n\n// Tests that SetArgPointee<N>(v) sets the variable pointed to by\n// the N-th (0-based) argument to v.\nTEST(SetArgPointeeTest, SetsTheNthPointee) {\n  typedef void MyFunction(bool, int*, char*);\n  Action<MyFunction> a = SetArgPointee<1>(2);\n\n  int n = 0;\n  char ch = '\\0';\n  a.Perform(make_tuple(true, &n, &ch));\n  EXPECT_EQ(2, n);\n  EXPECT_EQ('\\0', ch);\n\n  a = SetArgPointee<2>('a');\n  n = 0;\n  ch = '\\0';\n  a.Perform(make_tuple(true, &n, &ch));\n  EXPECT_EQ(0, n);\n  EXPECT_EQ('a', ch);\n}\n\n#if !((GTEST_GCC_VER_ && GTEST_GCC_VER_ < 40000) || GTEST_OS_SYMBIAN)\n// Tests that SetArgPointee<N>() accepts a string literal.\n// GCC prior to v4.0 and the Symbian compiler do not support this.\nTEST(SetArgPointeeTest, AcceptsStringLiteral) {\n  typedef void MyFunction(std::string*, const char**);\n  Action<MyFunction> a = SetArgPointee<0>(\"hi\");\n  std::string str;\n  const char* ptr = NULL;\n  a.Perform(make_tuple(&str, &ptr));\n  EXPECT_EQ(\"hi\", str);\n  EXPECT_TRUE(ptr == NULL);\n\n  a = SetArgPointee<1>(\"world\");\n  str = \"\";\n  a.Perform(make_tuple(&str, &ptr));\n  EXPECT_EQ(\"\", str);\n  EXPECT_STREQ(\"world\", ptr);\n}\n\nTEST(SetArgPointeeTest, AcceptsWideStringLiteral) {\n  typedef void MyFunction(const wchar_t**);\n  Action<MyFunction> a = SetArgPointee<0>(L\"world\");\n  const wchar_t* ptr = NULL;\n  a.Perform(make_tuple(&ptr));\n  EXPECT_STREQ(L\"world\", ptr);\n\n# if GTEST_HAS_STD_WSTRING\n\n  typedef void MyStringFunction(std::wstring*);\n  Action<MyStringFunction> a2 = SetArgPointee<0>(L\"world\");\n  std::wstring str = L\"\";\n  a2.Perform(make_tuple(&str));\n  EXPECT_EQ(L\"world\", str);\n\n# endif\n}\n#endif\n\n// Tests that SetArgPointee<N>() accepts a char pointer.\nTEST(SetArgPointeeTest, AcceptsCharPointer) {\n  typedef void MyFunction(bool, std::string*, const char**);\n  const char* const hi = \"hi\";\n  Action<MyFunction> a = SetArgPointee<1>(hi);\n  std::string str;\n  const char* ptr = NULL;\n  a.Perform(make_tuple(true, &str, &ptr));\n  EXPECT_EQ(\"hi\", str);\n  EXPECT_TRUE(ptr == NULL);\n\n  char world_array[] = \"world\";\n  char* const world = world_array;\n  a = SetArgPointee<2>(world);\n  str = \"\";\n  a.Perform(make_tuple(true, &str, &ptr));\n  EXPECT_EQ(\"\", str);\n  EXPECT_EQ(world, ptr);\n}\n\nTEST(SetArgPointeeTest, AcceptsWideCharPointer) {\n  typedef void MyFunction(bool, const wchar_t**);\n  const wchar_t* const hi = L\"hi\";\n  Action<MyFunction> a = SetArgPointee<1>(hi);\n  const wchar_t* ptr = NULL;\n  a.Perform(make_tuple(true, &ptr));\n  EXPECT_EQ(hi, ptr);\n\n# if GTEST_HAS_STD_WSTRING\n\n  typedef void MyStringFunction(bool, std::wstring*);\n  wchar_t world_array[] = L\"world\";\n  wchar_t* const world = world_array;\n  Action<MyStringFunction> a2 = SetArgPointee<1>(world);\n  std::wstring str;\n  a2.Perform(make_tuple(true, &str));\n  EXPECT_EQ(world_array, str);\n# endif\n}\n\n#if GTEST_HAS_PROTOBUF_\n\n// Tests that SetArgPointee<N>(proto_buffer) sets the v1 protobuf\n// variable pointed to by the N-th (0-based) argument to proto_buffer.\nTEST(SetArgPointeeTest, SetsTheNthPointeeOfProtoBufferType) {\n  TestMessage* const msg = new TestMessage;\n  msg->set_member(\"yes\");\n  TestMessage orig_msg;\n  orig_msg.CopyFrom(*msg);\n\n  Action<void(bool, TestMessage*)> a = SetArgPointee<1>(*msg);\n  // SetArgPointee<N>(proto_buffer) makes a copy of proto_buffer\n  // s.t. the action works even when the original proto_buffer has\n  // died.  We ensure this behavior by deleting msg before using the\n  // action.\n  delete msg;\n\n  TestMessage dest;\n  EXPECT_FALSE(orig_msg.Equals(dest));\n  a.Perform(make_tuple(true, &dest));\n  EXPECT_TRUE(orig_msg.Equals(dest));\n}\n\n// Tests that SetArgPointee<N>(proto_buffer) sets the\n// ::ProtocolMessage variable pointed to by the N-th (0-based)\n// argument to proto_buffer.\nTEST(SetArgPointeeTest, SetsTheNthPointeeOfProtoBufferBaseType) {\n  TestMessage* const msg = new TestMessage;\n  msg->set_member(\"yes\");\n  TestMessage orig_msg;\n  orig_msg.CopyFrom(*msg);\n\n  Action<void(bool, ::ProtocolMessage*)> a = SetArgPointee<1>(*msg);\n  // SetArgPointee<N>(proto_buffer) makes a copy of proto_buffer\n  // s.t. the action works even when the original proto_buffer has\n  // died.  We ensure this behavior by deleting msg before using the\n  // action.\n  delete msg;\n\n  TestMessage dest;\n  ::ProtocolMessage* const dest_base = &dest;\n  EXPECT_FALSE(orig_msg.Equals(dest));\n  a.Perform(make_tuple(true, dest_base));\n  EXPECT_TRUE(orig_msg.Equals(dest));\n}\n\n// Tests that SetArgPointee<N>(proto2_buffer) sets the v2\n// protobuf variable pointed to by the N-th (0-based) argument to\n// proto2_buffer.\nTEST(SetArgPointeeTest, SetsTheNthPointeeOfProto2BufferType) {\n  using testing::internal::FooMessage;\n  FooMessage* const msg = new FooMessage;\n  msg->set_int_field(2);\n  msg->set_string_field(\"hi\");\n  FooMessage orig_msg;\n  orig_msg.CopyFrom(*msg);\n\n  Action<void(bool, FooMessage*)> a = SetArgPointee<1>(*msg);\n  // SetArgPointee<N>(proto2_buffer) makes a copy of\n  // proto2_buffer s.t. the action works even when the original\n  // proto2_buffer has died.  We ensure this behavior by deleting msg\n  // before using the action.\n  delete msg;\n\n  FooMessage dest;\n  dest.set_int_field(0);\n  a.Perform(make_tuple(true, &dest));\n  EXPECT_EQ(2, dest.int_field());\n  EXPECT_EQ(\"hi\", dest.string_field());\n}\n\n// Tests that SetArgPointee<N>(proto2_buffer) sets the\n// proto2::Message variable pointed to by the N-th (0-based) argument\n// to proto2_buffer.\nTEST(SetArgPointeeTest, SetsTheNthPointeeOfProto2BufferBaseType) {\n  using testing::internal::FooMessage;\n  FooMessage* const msg = new FooMessage;\n  msg->set_int_field(2);\n  msg->set_string_field(\"hi\");\n  FooMessage orig_msg;\n  orig_msg.CopyFrom(*msg);\n\n  Action<void(bool, ::proto2::Message*)> a = SetArgPointee<1>(*msg);\n  // SetArgPointee<N>(proto2_buffer) makes a copy of\n  // proto2_buffer s.t. the action works even when the original\n  // proto2_buffer has died.  We ensure this behavior by deleting msg\n  // before using the action.\n  delete msg;\n\n  FooMessage dest;\n  dest.set_int_field(0);\n  ::proto2::Message* const dest_base = &dest;\n  a.Perform(make_tuple(true, dest_base));\n  EXPECT_EQ(2, dest.int_field());\n  EXPECT_EQ(\"hi\", dest.string_field());\n}\n\n#endif  // GTEST_HAS_PROTOBUF_\n\n// Tests that SetArgumentPointee<N>(v) sets the variable pointed to by\n// the N-th (0-based) argument to v.\nTEST(SetArgumentPointeeTest, SetsTheNthPointee) {\n  typedef void MyFunction(bool, int*, char*);\n  Action<MyFunction> a = SetArgumentPointee<1>(2);\n\n  int n = 0;\n  char ch = '\\0';\n  a.Perform(make_tuple(true, &n, &ch));\n  EXPECT_EQ(2, n);\n  EXPECT_EQ('\\0', ch);\n\n  a = SetArgumentPointee<2>('a');\n  n = 0;\n  ch = '\\0';\n  a.Perform(make_tuple(true, &n, &ch));\n  EXPECT_EQ(0, n);\n  EXPECT_EQ('a', ch);\n}\n\n#if GTEST_HAS_PROTOBUF_\n\n// Tests that SetArgumentPointee<N>(proto_buffer) sets the v1 protobuf\n// variable pointed to by the N-th (0-based) argument to proto_buffer.\nTEST(SetArgumentPointeeTest, SetsTheNthPointeeOfProtoBufferType) {\n  TestMessage* const msg = new TestMessage;\n  msg->set_member(\"yes\");\n  TestMessage orig_msg;\n  orig_msg.CopyFrom(*msg);\n\n  Action<void(bool, TestMessage*)> a = SetArgumentPointee<1>(*msg);\n  // SetArgumentPointee<N>(proto_buffer) makes a copy of proto_buffer\n  // s.t. the action works even when the original proto_buffer has\n  // died.  We ensure this behavior by deleting msg before using the\n  // action.\n  delete msg;\n\n  TestMessage dest;\n  EXPECT_FALSE(orig_msg.Equals(dest));\n  a.Perform(make_tuple(true, &dest));\n  EXPECT_TRUE(orig_msg.Equals(dest));\n}\n\n// Tests that SetArgumentPointee<N>(proto_buffer) sets the\n// ::ProtocolMessage variable pointed to by the N-th (0-based)\n// argument to proto_buffer.\nTEST(SetArgumentPointeeTest, SetsTheNthPointeeOfProtoBufferBaseType) {\n  TestMessage* const msg = new TestMessage;\n  msg->set_member(\"yes\");\n  TestMessage orig_msg;\n  orig_msg.CopyFrom(*msg);\n\n  Action<void(bool, ::ProtocolMessage*)> a = SetArgumentPointee<1>(*msg);\n  // SetArgumentPointee<N>(proto_buffer) makes a copy of proto_buffer\n  // s.t. the action works even when the original proto_buffer has\n  // died.  We ensure this behavior by deleting msg before using the\n  // action.\n  delete msg;\n\n  TestMessage dest;\n  ::ProtocolMessage* const dest_base = &dest;\n  EXPECT_FALSE(orig_msg.Equals(dest));\n  a.Perform(make_tuple(true, dest_base));\n  EXPECT_TRUE(orig_msg.Equals(dest));\n}\n\n// Tests that SetArgumentPointee<N>(proto2_buffer) sets the v2\n// protobuf variable pointed to by the N-th (0-based) argument to\n// proto2_buffer.\nTEST(SetArgumentPointeeTest, SetsTheNthPointeeOfProto2BufferType) {\n  using testing::internal::FooMessage;\n  FooMessage* const msg = new FooMessage;\n  msg->set_int_field(2);\n  msg->set_string_field(\"hi\");\n  FooMessage orig_msg;\n  orig_msg.CopyFrom(*msg);\n\n  Action<void(bool, FooMessage*)> a = SetArgumentPointee<1>(*msg);\n  // SetArgumentPointee<N>(proto2_buffer) makes a copy of\n  // proto2_buffer s.t. the action works even when the original\n  // proto2_buffer has died.  We ensure this behavior by deleting msg\n  // before using the action.\n  delete msg;\n\n  FooMessage dest;\n  dest.set_int_field(0);\n  a.Perform(make_tuple(true, &dest));\n  EXPECT_EQ(2, dest.int_field());\n  EXPECT_EQ(\"hi\", dest.string_field());\n}\n\n// Tests that SetArgumentPointee<N>(proto2_buffer) sets the\n// proto2::Message variable pointed to by the N-th (0-based) argument\n// to proto2_buffer.\nTEST(SetArgumentPointeeTest, SetsTheNthPointeeOfProto2BufferBaseType) {\n  using testing::internal::FooMessage;\n  FooMessage* const msg = new FooMessage;\n  msg->set_int_field(2);\n  msg->set_string_field(\"hi\");\n  FooMessage orig_msg;\n  orig_msg.CopyFrom(*msg);\n\n  Action<void(bool, ::proto2::Message*)> a = SetArgumentPointee<1>(*msg);\n  // SetArgumentPointee<N>(proto2_buffer) makes a copy of\n  // proto2_buffer s.t. the action works even when the original\n  // proto2_buffer has died.  We ensure this behavior by deleting msg\n  // before using the action.\n  delete msg;\n\n  FooMessage dest;\n  dest.set_int_field(0);\n  ::proto2::Message* const dest_base = &dest;\n  a.Perform(make_tuple(true, dest_base));\n  EXPECT_EQ(2, dest.int_field());\n  EXPECT_EQ(\"hi\", dest.string_field());\n}\n\n#endif  // GTEST_HAS_PROTOBUF_\n\n// Sample functions and functors for testing Invoke() and etc.\nint Nullary() { return 1; }\n\nclass NullaryFunctor {\n public:\n  int operator()() { return 2; }\n};\n\nbool g_done = false;\nvoid VoidNullary() { g_done = true; }\n\nclass VoidNullaryFunctor {\n public:\n  void operator()() { g_done = true; }\n};\n\nclass Foo {\n public:\n  Foo() : value_(123) {}\n\n  int Nullary() const { return value_; }\n\n private:\n  int value_;\n};\n\n// Tests InvokeWithoutArgs(function).\nTEST(InvokeWithoutArgsTest, Function) {\n  // As an action that takes one argument.\n  Action<int(int)> a = InvokeWithoutArgs(Nullary);  // NOLINT\n  EXPECT_EQ(1, a.Perform(make_tuple(2)));\n\n  // As an action that takes two arguments.\n  Action<int(int, double)> a2 = InvokeWithoutArgs(Nullary);  // NOLINT\n  EXPECT_EQ(1, a2.Perform(make_tuple(2, 3.5)));\n\n  // As an action that returns void.\n  Action<void(int)> a3 = InvokeWithoutArgs(VoidNullary);  // NOLINT\n  g_done = false;\n  a3.Perform(make_tuple(1));\n  EXPECT_TRUE(g_done);\n}\n\n// Tests InvokeWithoutArgs(functor).\nTEST(InvokeWithoutArgsTest, Functor) {\n  // As an action that takes no argument.\n  Action<int()> a = InvokeWithoutArgs(NullaryFunctor());  // NOLINT\n  EXPECT_EQ(2, a.Perform(make_tuple()));\n\n  // As an action that takes three arguments.\n  Action<int(int, double, char)> a2 =  // NOLINT\n      InvokeWithoutArgs(NullaryFunctor());\n  EXPECT_EQ(2, a2.Perform(make_tuple(3, 3.5, 'a')));\n\n  // As an action that returns void.\n  Action<void()> a3 = InvokeWithoutArgs(VoidNullaryFunctor());\n  g_done = false;\n  a3.Perform(make_tuple());\n  EXPECT_TRUE(g_done);\n}\n\n// Tests InvokeWithoutArgs(obj_ptr, method).\nTEST(InvokeWithoutArgsTest, Method) {\n  Foo foo;\n  Action<int(bool, char)> a =  // NOLINT\n      InvokeWithoutArgs(&foo, &Foo::Nullary);\n  EXPECT_EQ(123, a.Perform(make_tuple(true, 'a')));\n}\n\n// Tests using IgnoreResult() on a polymorphic action.\nTEST(IgnoreResultTest, PolymorphicAction) {\n  Action<void(int)> a = IgnoreResult(Return(5));  // NOLINT\n  a.Perform(make_tuple(1));\n}\n\n// Tests using IgnoreResult() on a monomorphic action.\n\nint ReturnOne() {\n  g_done = true;\n  return 1;\n}\n\nTEST(IgnoreResultTest, MonomorphicAction) {\n  g_done = false;\n  Action<void()> a = IgnoreResult(Invoke(ReturnOne));\n  a.Perform(make_tuple());\n  EXPECT_TRUE(g_done);\n}\n\n// Tests using IgnoreResult() on an action that returns a class type.\n\nMyClass ReturnMyClass(double /* x */) {\n  g_done = true;\n  return MyClass();\n}\n\nTEST(IgnoreResultTest, ActionReturningClass) {\n  g_done = false;\n  Action<void(int)> a = IgnoreResult(Invoke(ReturnMyClass));  // NOLINT\n  a.Perform(make_tuple(2));\n  EXPECT_TRUE(g_done);\n}\n\nTEST(AssignTest, Int) {\n  int x = 0;\n  Action<void(int)> a = Assign(&x, 5);\n  a.Perform(make_tuple(0));\n  EXPECT_EQ(5, x);\n}\n\nTEST(AssignTest, String) {\n  ::std::string x;\n  Action<void(void)> a = Assign(&x, \"Hello, world\");\n  a.Perform(make_tuple());\n  EXPECT_EQ(\"Hello, world\", x);\n}\n\nTEST(AssignTest, CompatibleTypes) {\n  double x = 0;\n  Action<void(int)> a = Assign(&x, 5);\n  a.Perform(make_tuple(0));\n  EXPECT_DOUBLE_EQ(5, x);\n}\n\n#if !GTEST_OS_WINDOWS_MOBILE\n\nclass SetErrnoAndReturnTest : public testing::Test {\n protected:\n  virtual void SetUp() { errno = 0; }\n  virtual void TearDown() { errno = 0; }\n};\n\nTEST_F(SetErrnoAndReturnTest, Int) {\n  Action<int(void)> a = SetErrnoAndReturn(ENOTTY, -5);\n  EXPECT_EQ(-5, a.Perform(make_tuple()));\n  EXPECT_EQ(ENOTTY, errno);\n}\n\nTEST_F(SetErrnoAndReturnTest, Ptr) {\n  int x;\n  Action<int*(void)> a = SetErrnoAndReturn(ENOTTY, &x);\n  EXPECT_EQ(&x, a.Perform(make_tuple()));\n  EXPECT_EQ(ENOTTY, errno);\n}\n\nTEST_F(SetErrnoAndReturnTest, CompatibleTypes) {\n  Action<double()> a = SetErrnoAndReturn(EINVAL, 5);\n  EXPECT_DOUBLE_EQ(5.0, a.Perform(make_tuple()));\n  EXPECT_EQ(EINVAL, errno);\n}\n\n#endif  // !GTEST_OS_WINDOWS_MOBILE\n\n// Tests ByRef().\n\n// Tests that ReferenceWrapper<T> is copyable.\nTEST(ByRefTest, IsCopyable) {\n  const std::string s1 = \"Hi\";\n  const std::string s2 = \"Hello\";\n\n  ::testing::internal::ReferenceWrapper<const std::string> ref_wrapper =\n      ByRef(s1);\n  const std::string& r1 = ref_wrapper;\n  EXPECT_EQ(&s1, &r1);\n\n  // Assigns a new value to ref_wrapper.\n  ref_wrapper = ByRef(s2);\n  const std::string& r2 = ref_wrapper;\n  EXPECT_EQ(&s2, &r2);\n\n  ::testing::internal::ReferenceWrapper<const std::string> ref_wrapper1 =\n      ByRef(s1);\n  // Copies ref_wrapper1 to ref_wrapper.\n  ref_wrapper = ref_wrapper1;\n  const std::string& r3 = ref_wrapper;\n  EXPECT_EQ(&s1, &r3);\n}\n\n// Tests using ByRef() on a const value.\nTEST(ByRefTest, ConstValue) {\n  const int n = 0;\n  // int& ref = ByRef(n);  // This shouldn't compile - we have a\n                           // negative compilation test to catch it.\n  const int& const_ref = ByRef(n);\n  EXPECT_EQ(&n, &const_ref);\n}\n\n// Tests using ByRef() on a non-const value.\nTEST(ByRefTest, NonConstValue) {\n  int n = 0;\n\n  // ByRef(n) can be used as either an int&,\n  int& ref = ByRef(n);\n  EXPECT_EQ(&n, &ref);\n\n  // or a const int&.\n  const int& const_ref = ByRef(n);\n  EXPECT_EQ(&n, &const_ref);\n}\n\n// Tests explicitly specifying the type when using ByRef().\nTEST(ByRefTest, ExplicitType) {\n  int n = 0;\n  const int& r1 = ByRef<const int>(n);\n  EXPECT_EQ(&n, &r1);\n\n  // ByRef<char>(n);  // This shouldn't compile - we have a negative\n                      // compilation test to catch it.\n\n  Derived d;\n  Derived& r2 = ByRef<Derived>(d);\n  EXPECT_EQ(&d, &r2);\n\n  const Derived& r3 = ByRef<const Derived>(d);\n  EXPECT_EQ(&d, &r3);\n\n  Base& r4 = ByRef<Base>(d);\n  EXPECT_EQ(&d, &r4);\n\n  const Base& r5 = ByRef<const Base>(d);\n  EXPECT_EQ(&d, &r5);\n\n  // The following shouldn't compile - we have a negative compilation\n  // test for it.\n  //\n  // Base b;\n  // ByRef<Derived>(b);\n}\n\n// Tests that Google Mock prints expression ByRef(x) as a reference to x.\nTEST(ByRefTest, PrintsCorrectly) {\n  int n = 42;\n  ::std::stringstream expected, actual;\n  testing::internal::UniversalPrinter<const int&>::Print(n, &expected);\n  testing::internal::UniversalPrint(ByRef(n), &actual);\n  EXPECT_EQ(expected.str(), actual.str());\n}\n\n}  // Unnamed namespace\n"
  },
  {
    "path": "ext/gmock/test/gmock-cardinalities_test.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file tests the built-in cardinalities.\n\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n#include \"gtest/gtest-spi.h\"\n\nnamespace {\n\nusing std::stringstream;\nusing testing::AnyNumber;\nusing testing::AtLeast;\nusing testing::AtMost;\nusing testing::Between;\nusing testing::Cardinality;\nusing testing::CardinalityInterface;\nusing testing::Exactly;\nusing testing::IsSubstring;\nusing testing::MakeCardinality;\n\nclass MockFoo {\n public:\n  MockFoo() {}\n  MOCK_METHOD0(Bar, int());  // NOLINT\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo);\n};\n\n// Tests that Cardinality objects can be default constructed.\nTEST(CardinalityTest, IsDefaultConstructable) {\n  Cardinality c;\n}\n\n// Tests that Cardinality objects are copyable.\nTEST(CardinalityTest, IsCopyable) {\n  // Tests the copy constructor.\n  Cardinality c = Exactly(1);\n  EXPECT_FALSE(c.IsSatisfiedByCallCount(0));\n  EXPECT_TRUE(c.IsSatisfiedByCallCount(1));\n  EXPECT_TRUE(c.IsSaturatedByCallCount(1));\n\n  // Tests the assignment operator.\n  c = Exactly(2);\n  EXPECT_FALSE(c.IsSatisfiedByCallCount(1));\n  EXPECT_TRUE(c.IsSatisfiedByCallCount(2));\n  EXPECT_TRUE(c.IsSaturatedByCallCount(2));\n}\n\nTEST(CardinalityTest, IsOverSaturatedByCallCountWorks) {\n  const Cardinality c = AtMost(5);\n  EXPECT_FALSE(c.IsOverSaturatedByCallCount(4));\n  EXPECT_FALSE(c.IsOverSaturatedByCallCount(5));\n  EXPECT_TRUE(c.IsOverSaturatedByCallCount(6));\n}\n\n// Tests that Cardinality::DescribeActualCallCountTo() creates the\n// correct description.\nTEST(CardinalityTest, CanDescribeActualCallCount) {\n  stringstream ss0;\n  Cardinality::DescribeActualCallCountTo(0, &ss0);\n  EXPECT_EQ(\"never called\", ss0.str());\n\n  stringstream ss1;\n  Cardinality::DescribeActualCallCountTo(1, &ss1);\n  EXPECT_EQ(\"called once\", ss1.str());\n\n  stringstream ss2;\n  Cardinality::DescribeActualCallCountTo(2, &ss2);\n  EXPECT_EQ(\"called twice\", ss2.str());\n\n  stringstream ss3;\n  Cardinality::DescribeActualCallCountTo(3, &ss3);\n  EXPECT_EQ(\"called 3 times\", ss3.str());\n}\n\n// Tests AnyNumber()\nTEST(AnyNumber, Works) {\n  const Cardinality c = AnyNumber();\n  EXPECT_TRUE(c.IsSatisfiedByCallCount(0));\n  EXPECT_FALSE(c.IsSaturatedByCallCount(0));\n\n  EXPECT_TRUE(c.IsSatisfiedByCallCount(1));\n  EXPECT_FALSE(c.IsSaturatedByCallCount(1));\n\n  EXPECT_TRUE(c.IsSatisfiedByCallCount(9));\n  EXPECT_FALSE(c.IsSaturatedByCallCount(9));\n\n  stringstream ss;\n  c.DescribeTo(&ss);\n  EXPECT_PRED_FORMAT2(IsSubstring, \"called any number of times\",\n                      ss.str());\n}\n\nTEST(AnyNumberTest, HasCorrectBounds) {\n  const Cardinality c = AnyNumber();\n  EXPECT_EQ(0, c.ConservativeLowerBound());\n  EXPECT_EQ(INT_MAX, c.ConservativeUpperBound());\n}\n\n// Tests AtLeast(n).\n\nTEST(AtLeastTest, OnNegativeNumber) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    AtLeast(-1);\n  }, \"The invocation lower bound must be >= 0\");\n}\n\nTEST(AtLeastTest, OnZero) {\n  const Cardinality c = AtLeast(0);\n  EXPECT_TRUE(c.IsSatisfiedByCallCount(0));\n  EXPECT_FALSE(c.IsSaturatedByCallCount(0));\n\n  EXPECT_TRUE(c.IsSatisfiedByCallCount(1));\n  EXPECT_FALSE(c.IsSaturatedByCallCount(1));\n\n  stringstream ss;\n  c.DescribeTo(&ss);\n  EXPECT_PRED_FORMAT2(IsSubstring, \"any number of times\",\n                      ss.str());\n}\n\nTEST(AtLeastTest, OnPositiveNumber) {\n  const Cardinality c = AtLeast(2);\n  EXPECT_FALSE(c.IsSatisfiedByCallCount(0));\n  EXPECT_FALSE(c.IsSaturatedByCallCount(0));\n\n  EXPECT_FALSE(c.IsSatisfiedByCallCount(1));\n  EXPECT_FALSE(c.IsSaturatedByCallCount(1));\n\n  EXPECT_TRUE(c.IsSatisfiedByCallCount(2));\n  EXPECT_FALSE(c.IsSaturatedByCallCount(2));\n\n  stringstream ss1;\n  AtLeast(1).DescribeTo(&ss1);\n  EXPECT_PRED_FORMAT2(IsSubstring, \"at least once\",\n                      ss1.str());\n\n  stringstream ss2;\n  c.DescribeTo(&ss2);\n  EXPECT_PRED_FORMAT2(IsSubstring, \"at least twice\",\n                      ss2.str());\n\n  stringstream ss3;\n  AtLeast(3).DescribeTo(&ss3);\n  EXPECT_PRED_FORMAT2(IsSubstring, \"at least 3 times\",\n                      ss3.str());\n}\n\nTEST(AtLeastTest, HasCorrectBounds) {\n  const Cardinality c = AtLeast(2);\n  EXPECT_EQ(2, c.ConservativeLowerBound());\n  EXPECT_EQ(INT_MAX, c.ConservativeUpperBound());\n}\n\n// Tests AtMost(n).\n\nTEST(AtMostTest, OnNegativeNumber) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    AtMost(-1);\n  }, \"The invocation upper bound must be >= 0\");\n}\n\nTEST(AtMostTest, OnZero) {\n  const Cardinality c = AtMost(0);\n  EXPECT_TRUE(c.IsSatisfiedByCallCount(0));\n  EXPECT_TRUE(c.IsSaturatedByCallCount(0));\n\n  EXPECT_FALSE(c.IsSatisfiedByCallCount(1));\n  EXPECT_TRUE(c.IsSaturatedByCallCount(1));\n\n  stringstream ss;\n  c.DescribeTo(&ss);\n  EXPECT_PRED_FORMAT2(IsSubstring, \"never called\",\n                      ss.str());\n}\n\nTEST(AtMostTest, OnPositiveNumber) {\n  const Cardinality c = AtMost(2);\n  EXPECT_TRUE(c.IsSatisfiedByCallCount(0));\n  EXPECT_FALSE(c.IsSaturatedByCallCount(0));\n\n  EXPECT_TRUE(c.IsSatisfiedByCallCount(1));\n  EXPECT_FALSE(c.IsSaturatedByCallCount(1));\n\n  EXPECT_TRUE(c.IsSatisfiedByCallCount(2));\n  EXPECT_TRUE(c.IsSaturatedByCallCount(2));\n\n  stringstream ss1;\n  AtMost(1).DescribeTo(&ss1);\n  EXPECT_PRED_FORMAT2(IsSubstring, \"called at most once\",\n                      ss1.str());\n\n  stringstream ss2;\n  c.DescribeTo(&ss2);\n  EXPECT_PRED_FORMAT2(IsSubstring, \"called at most twice\",\n                      ss2.str());\n\n  stringstream ss3;\n  AtMost(3).DescribeTo(&ss3);\n  EXPECT_PRED_FORMAT2(IsSubstring, \"called at most 3 times\",\n                      ss3.str());\n}\n\nTEST(AtMostTest, HasCorrectBounds) {\n  const Cardinality c = AtMost(2);\n  EXPECT_EQ(0, c.ConservativeLowerBound());\n  EXPECT_EQ(2, c.ConservativeUpperBound());\n}\n\n// Tests Between(m, n).\n\nTEST(BetweenTest, OnNegativeStart) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    Between(-1, 2);\n  }, \"The invocation lower bound must be >= 0, but is actually -1\");\n}\n\nTEST(BetweenTest, OnNegativeEnd) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    Between(1, -2);\n  }, \"The invocation upper bound must be >= 0, but is actually -2\");\n}\n\nTEST(BetweenTest, OnStartBiggerThanEnd) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    Between(2, 1);\n  }, \"The invocation upper bound (1) must be >= \"\n     \"the invocation lower bound (2)\");\n}\n\nTEST(BetweenTest, OnZeroStartAndZeroEnd) {\n  const Cardinality c = Between(0, 0);\n\n  EXPECT_TRUE(c.IsSatisfiedByCallCount(0));\n  EXPECT_TRUE(c.IsSaturatedByCallCount(0));\n\n  EXPECT_FALSE(c.IsSatisfiedByCallCount(1));\n  EXPECT_TRUE(c.IsSaturatedByCallCount(1));\n\n  stringstream ss;\n  c.DescribeTo(&ss);\n  EXPECT_PRED_FORMAT2(IsSubstring, \"never called\",\n                      ss.str());\n}\n\nTEST(BetweenTest, OnZeroStartAndNonZeroEnd) {\n  const Cardinality c = Between(0, 2);\n\n  EXPECT_TRUE(c.IsSatisfiedByCallCount(0));\n  EXPECT_FALSE(c.IsSaturatedByCallCount(0));\n\n  EXPECT_TRUE(c.IsSatisfiedByCallCount(2));\n  EXPECT_TRUE(c.IsSaturatedByCallCount(2));\n\n  EXPECT_FALSE(c.IsSatisfiedByCallCount(4));\n  EXPECT_TRUE(c.IsSaturatedByCallCount(4));\n\n  stringstream ss;\n  c.DescribeTo(&ss);\n  EXPECT_PRED_FORMAT2(IsSubstring, \"called at most twice\",\n                      ss.str());\n}\n\nTEST(BetweenTest, OnSameStartAndEnd) {\n  const Cardinality c = Between(3, 3);\n\n  EXPECT_FALSE(c.IsSatisfiedByCallCount(2));\n  EXPECT_FALSE(c.IsSaturatedByCallCount(2));\n\n  EXPECT_TRUE(c.IsSatisfiedByCallCount(3));\n  EXPECT_TRUE(c.IsSaturatedByCallCount(3));\n\n  EXPECT_FALSE(c.IsSatisfiedByCallCount(4));\n  EXPECT_TRUE(c.IsSaturatedByCallCount(4));\n\n  stringstream ss;\n  c.DescribeTo(&ss);\n  EXPECT_PRED_FORMAT2(IsSubstring, \"called 3 times\",\n                      ss.str());\n}\n\nTEST(BetweenTest, OnDifferentStartAndEnd) {\n  const Cardinality c = Between(3, 5);\n\n  EXPECT_FALSE(c.IsSatisfiedByCallCount(2));\n  EXPECT_FALSE(c.IsSaturatedByCallCount(2));\n\n  EXPECT_TRUE(c.IsSatisfiedByCallCount(3));\n  EXPECT_FALSE(c.IsSaturatedByCallCount(3));\n\n  EXPECT_TRUE(c.IsSatisfiedByCallCount(5));\n  EXPECT_TRUE(c.IsSaturatedByCallCount(5));\n\n  EXPECT_FALSE(c.IsSatisfiedByCallCount(6));\n  EXPECT_TRUE(c.IsSaturatedByCallCount(6));\n\n  stringstream ss;\n  c.DescribeTo(&ss);\n  EXPECT_PRED_FORMAT2(IsSubstring, \"called between 3 and 5 times\",\n                      ss.str());\n}\n\nTEST(BetweenTest, HasCorrectBounds) {\n  const Cardinality c = Between(3, 5);\n  EXPECT_EQ(3, c.ConservativeLowerBound());\n  EXPECT_EQ(5, c.ConservativeUpperBound());\n}\n\n// Tests Exactly(n).\n\nTEST(ExactlyTest, OnNegativeNumber) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    Exactly(-1);\n  }, \"The invocation lower bound must be >= 0\");\n}\n\nTEST(ExactlyTest, OnZero) {\n  const Cardinality c = Exactly(0);\n  EXPECT_TRUE(c.IsSatisfiedByCallCount(0));\n  EXPECT_TRUE(c.IsSaturatedByCallCount(0));\n\n  EXPECT_FALSE(c.IsSatisfiedByCallCount(1));\n  EXPECT_TRUE(c.IsSaturatedByCallCount(1));\n\n  stringstream ss;\n  c.DescribeTo(&ss);\n  EXPECT_PRED_FORMAT2(IsSubstring, \"never called\",\n                      ss.str());\n}\n\nTEST(ExactlyTest, OnPositiveNumber) {\n  const Cardinality c = Exactly(2);\n  EXPECT_FALSE(c.IsSatisfiedByCallCount(0));\n  EXPECT_FALSE(c.IsSaturatedByCallCount(0));\n\n  EXPECT_TRUE(c.IsSatisfiedByCallCount(2));\n  EXPECT_TRUE(c.IsSaturatedByCallCount(2));\n\n  stringstream ss1;\n  Exactly(1).DescribeTo(&ss1);\n  EXPECT_PRED_FORMAT2(IsSubstring, \"called once\",\n                      ss1.str());\n\n  stringstream ss2;\n  c.DescribeTo(&ss2);\n  EXPECT_PRED_FORMAT2(IsSubstring, \"called twice\",\n                      ss2.str());\n\n  stringstream ss3;\n  Exactly(3).DescribeTo(&ss3);\n  EXPECT_PRED_FORMAT2(IsSubstring, \"called 3 times\",\n                      ss3.str());\n}\n\nTEST(ExactlyTest, HasCorrectBounds) {\n  const Cardinality c = Exactly(3);\n  EXPECT_EQ(3, c.ConservativeLowerBound());\n  EXPECT_EQ(3, c.ConservativeUpperBound());\n}\n\n// Tests that a user can make his own cardinality by implementing\n// CardinalityInterface and calling MakeCardinality().\n\nclass EvenCardinality : public CardinalityInterface {\n public:\n  // Returns true iff call_count calls will satisfy this cardinality.\n  virtual bool IsSatisfiedByCallCount(int call_count) const {\n    return (call_count % 2 == 0);\n  }\n\n  // Returns true iff call_count calls will saturate this cardinality.\n  virtual bool IsSaturatedByCallCount(int /* call_count */) const {\n    return false;\n  }\n\n  // Describes self to an ostream.\n  virtual void DescribeTo(::std::ostream* ss) const {\n    *ss << \"called even number of times\";\n  }\n};\n\nTEST(MakeCardinalityTest, ConstructsCardinalityFromInterface) {\n  const Cardinality c = MakeCardinality(new EvenCardinality);\n\n  EXPECT_TRUE(c.IsSatisfiedByCallCount(2));\n  EXPECT_FALSE(c.IsSatisfiedByCallCount(3));\n\n  EXPECT_FALSE(c.IsSaturatedByCallCount(10000));\n\n  stringstream ss;\n  c.DescribeTo(&ss);\n  EXPECT_EQ(\"called even number of times\", ss.str());\n}\n\n}  // Unnamed namespace\n"
  },
  {
    "path": "ext/gmock/test/gmock-generated-actions_test.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file tests the built-in actions generated by a script.\n\n#include \"gmock/gmock-generated-actions.h\"\n\n#include <functional>\n#include <sstream>\n#include <string>\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\nnamespace testing {\nnamespace gmock_generated_actions_test {\n\nusing ::std::plus;\nusing ::std::string;\nusing ::std::tr1::get;\nusing ::std::tr1::make_tuple;\nusing ::std::tr1::tuple;\nusing ::std::tr1::tuple_element;\nusing testing::_;\nusing testing::Action;\nusing testing::ActionInterface;\nusing testing::ByRef;\nusing testing::DoAll;\nusing testing::Invoke;\nusing testing::Return;\nusing testing::ReturnNew;\nusing testing::SetArgPointee;\nusing testing::StaticAssertTypeEq;\nusing testing::Unused;\nusing testing::WithArgs;\n\n// For suppressing compiler warnings on conversion possibly losing precision.\ninline short Short(short n) { return n; }  // NOLINT\ninline char Char(char ch) { return ch; }\n\n// Sample functions and functors for testing various actions.\nint Nullary() { return 1; }\n\nclass NullaryFunctor {\n public:\n  int operator()() { return 2; }\n};\n\nbool g_done = false;\n\nbool Unary(int x) { return x < 0; }\n\nconst char* Plus1(const char* s) { return s + 1; }\n\nbool ByConstRef(const string& s) { return s == \"Hi\"; }\n\nconst double g_double = 0;\nbool ReferencesGlobalDouble(const double& x) { return &x == &g_double; }\n\nstring ByNonConstRef(string& s) { return s += \"+\"; }  // NOLINT\n\nstruct UnaryFunctor {\n  int operator()(bool x) { return x ? 1 : -1; }\n};\n\nconst char* Binary(const char* input, short n) { return input + n; }  // NOLINT\n\nvoid VoidBinary(int, char) { g_done = true; }\n\nint Ternary(int x, char y, short z) { return x + y + z; }  // NOLINT\n\nvoid VoidTernary(int, char, bool) { g_done = true; }\n\nint SumOf4(int a, int b, int c, int d) { return a + b + c + d; }\n\nstring Concat4(const char* s1, const char* s2, const char* s3,\n               const char* s4) {\n  return string(s1) + s2 + s3 + s4;\n}\n\nint SumOf5(int a, int b, int c, int d, int e) { return a + b + c + d + e; }\n\nstruct SumOf5Functor {\n  int operator()(int a, int b, int c, int d, int e) {\n    return a + b + c + d + e;\n  }\n};\n\nstring Concat5(const char* s1, const char* s2, const char* s3,\n               const char* s4, const char* s5) {\n  return string(s1) + s2 + s3 + s4 + s5;\n}\n\nint SumOf6(int a, int b, int c, int d, int e, int f) {\n  return a + b + c + d + e + f;\n}\n\nstruct SumOf6Functor {\n  int operator()(int a, int b, int c, int d, int e, int f) {\n    return a + b + c + d + e + f;\n  }\n};\n\nstring Concat6(const char* s1, const char* s2, const char* s3,\n               const char* s4, const char* s5, const char* s6) {\n  return string(s1) + s2 + s3 + s4 + s5 + s6;\n}\n\nstring Concat7(const char* s1, const char* s2, const char* s3,\n               const char* s4, const char* s5, const char* s6,\n               const char* s7) {\n  return string(s1) + s2 + s3 + s4 + s5 + s6 + s7;\n}\n\nstring Concat8(const char* s1, const char* s2, const char* s3,\n               const char* s4, const char* s5, const char* s6,\n               const char* s7, const char* s8) {\n  return string(s1) + s2 + s3 + s4 + s5 + s6 + s7 + s8;\n}\n\nstring Concat9(const char* s1, const char* s2, const char* s3,\n               const char* s4, const char* s5, const char* s6,\n               const char* s7, const char* s8, const char* s9) {\n  return string(s1) + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9;\n}\n\nstring Concat10(const char* s1, const char* s2, const char* s3,\n                const char* s4, const char* s5, const char* s6,\n                const char* s7, const char* s8, const char* s9,\n                const char* s10) {\n  return string(s1) + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10;\n}\n\n// A helper that turns the type of a C-string literal from const\n// char[N] to const char*.\ninline const char* CharPtr(const char* s) { return s; }\n\n// Tests InvokeArgument<N>(...).\n\n// Tests using InvokeArgument with a nullary function.\nTEST(InvokeArgumentTest, Function0) {\n  Action<int(int, int(*)())> a = InvokeArgument<1>();  // NOLINT\n  EXPECT_EQ(1, a.Perform(make_tuple(2, &Nullary)));\n}\n\n// Tests using InvokeArgument with a unary function.\nTEST(InvokeArgumentTest, Functor1) {\n  Action<int(UnaryFunctor)> a = InvokeArgument<0>(true);  // NOLINT\n  EXPECT_EQ(1, a.Perform(make_tuple(UnaryFunctor())));\n}\n\n// Tests using InvokeArgument with a 5-ary function.\nTEST(InvokeArgumentTest, Function5) {\n  Action<int(int(*)(int, int, int, int, int))> a =  // NOLINT\n      InvokeArgument<0>(10000, 2000, 300, 40, 5);\n  EXPECT_EQ(12345, a.Perform(make_tuple(&SumOf5)));\n}\n\n// Tests using InvokeArgument with a 5-ary functor.\nTEST(InvokeArgumentTest, Functor5) {\n  Action<int(SumOf5Functor)> a =  // NOLINT\n      InvokeArgument<0>(10000, 2000, 300, 40, 5);\n  EXPECT_EQ(12345, a.Perform(make_tuple(SumOf5Functor())));\n}\n\n// Tests using InvokeArgument with a 6-ary function.\nTEST(InvokeArgumentTest, Function6) {\n  Action<int(int(*)(int, int, int, int, int, int))> a =  // NOLINT\n      InvokeArgument<0>(100000, 20000, 3000, 400, 50, 6);\n  EXPECT_EQ(123456, a.Perform(make_tuple(&SumOf6)));\n}\n\n// Tests using InvokeArgument with a 6-ary functor.\nTEST(InvokeArgumentTest, Functor6) {\n  Action<int(SumOf6Functor)> a =  // NOLINT\n      InvokeArgument<0>(100000, 20000, 3000, 400, 50, 6);\n  EXPECT_EQ(123456, a.Perform(make_tuple(SumOf6Functor())));\n}\n\n// Tests using InvokeArgument with a 7-ary function.\nTEST(InvokeArgumentTest, Function7) {\n  Action<string(string(*)(const char*, const char*, const char*,\n                          const char*, const char*, const char*,\n                          const char*))> a =\n      InvokeArgument<0>(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\");\n  EXPECT_EQ(\"1234567\", a.Perform(make_tuple(&Concat7)));\n}\n\n// Tests using InvokeArgument with a 8-ary function.\nTEST(InvokeArgumentTest, Function8) {\n  Action<string(string(*)(const char*, const char*, const char*,\n                          const char*, const char*, const char*,\n                          const char*, const char*))> a =\n      InvokeArgument<0>(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\");\n  EXPECT_EQ(\"12345678\", a.Perform(make_tuple(&Concat8)));\n}\n\n// Tests using InvokeArgument with a 9-ary function.\nTEST(InvokeArgumentTest, Function9) {\n  Action<string(string(*)(const char*, const char*, const char*,\n                          const char*, const char*, const char*,\n                          const char*, const char*, const char*))> a =\n      InvokeArgument<0>(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\");\n  EXPECT_EQ(\"123456789\", a.Perform(make_tuple(&Concat9)));\n}\n\n// Tests using InvokeArgument with a 10-ary function.\nTEST(InvokeArgumentTest, Function10) {\n  Action<string(string(*)(const char*, const char*, const char*,\n                          const char*, const char*, const char*,\n                          const char*, const char*, const char*,\n                          const char*))> a =\n      InvokeArgument<0>(\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"0\");\n  EXPECT_EQ(\"1234567890\", a.Perform(make_tuple(&Concat10)));\n}\n\n// Tests using InvokeArgument with a function that takes a pointer argument.\nTEST(InvokeArgumentTest, ByPointerFunction) {\n  Action<const char*(const char*(*)(const char* input, short n))> a =  // NOLINT\n      InvokeArgument<0>(static_cast<const char*>(\"Hi\"), Short(1));\n  EXPECT_STREQ(\"i\", a.Perform(make_tuple(&Binary)));\n}\n\n// Tests using InvokeArgument with a function that takes a const char*\n// by passing it a C-string literal.\nTEST(InvokeArgumentTest, FunctionWithCStringLiteral) {\n  Action<const char*(const char*(*)(const char* input, short n))> a =  // NOLINT\n      InvokeArgument<0>(\"Hi\", Short(1));\n  EXPECT_STREQ(\"i\", a.Perform(make_tuple(&Binary)));\n}\n\n// Tests using InvokeArgument with a function that takes a const reference.\nTEST(InvokeArgumentTest, ByConstReferenceFunction) {\n  Action<bool(bool(*function)(const string& s))> a =  // NOLINT\n      InvokeArgument<0>(string(\"Hi\"));\n  // When action 'a' is constructed, it makes a copy of the temporary\n  // string object passed to it, so it's OK to use 'a' later, when the\n  // temporary object has already died.\n  EXPECT_TRUE(a.Perform(make_tuple(&ByConstRef)));\n}\n\n// Tests using InvokeArgument with ByRef() and a function that takes a\n// const reference.\nTEST(InvokeArgumentTest, ByExplicitConstReferenceFunction) {\n  Action<bool(bool(*)(const double& x))> a =  // NOLINT\n      InvokeArgument<0>(ByRef(g_double));\n  // The above line calls ByRef() on a const value.\n  EXPECT_TRUE(a.Perform(make_tuple(&ReferencesGlobalDouble)));\n\n  double x = 0;\n  a = InvokeArgument<0>(ByRef(x));  // This calls ByRef() on a non-const.\n  EXPECT_FALSE(a.Perform(make_tuple(&ReferencesGlobalDouble)));\n}\n\n// Tests using WithArgs and with an action that takes 1 argument.\nTEST(WithArgsTest, OneArg) {\n  Action<bool(double x, int n)> a = WithArgs<1>(Invoke(Unary));  // NOLINT\n  EXPECT_TRUE(a.Perform(make_tuple(1.5, -1)));\n  EXPECT_FALSE(a.Perform(make_tuple(1.5, 1)));\n}\n\n// Tests using WithArgs with an action that takes 2 arguments.\nTEST(WithArgsTest, TwoArgs) {\n  Action<const char*(const char* s, double x, short n)> a =\n      WithArgs<0, 2>(Invoke(Binary));\n  const char s[] = \"Hello\";\n  EXPECT_EQ(s + 2, a.Perform(make_tuple(CharPtr(s), 0.5, Short(2))));\n}\n\n// Tests using WithArgs with an action that takes 3 arguments.\nTEST(WithArgsTest, ThreeArgs) {\n  Action<int(int, double, char, short)> a =  // NOLINT\n      WithArgs<0, 2, 3>(Invoke(Ternary));\n  EXPECT_EQ(123, a.Perform(make_tuple(100, 6.5, Char(20), Short(3))));\n}\n\n// Tests using WithArgs with an action that takes 4 arguments.\nTEST(WithArgsTest, FourArgs) {\n  Action<string(const char*, const char*, double, const char*, const char*)> a =\n      WithArgs<4, 3, 1, 0>(Invoke(Concat4));\n  EXPECT_EQ(\"4310\", a.Perform(make_tuple(CharPtr(\"0\"), CharPtr(\"1\"), 2.5,\n                                         CharPtr(\"3\"), CharPtr(\"4\"))));\n}\n\n// Tests using WithArgs with an action that takes 5 arguments.\nTEST(WithArgsTest, FiveArgs) {\n  Action<string(const char*, const char*, const char*,\n                const char*, const char*)> a =\n      WithArgs<4, 3, 2, 1, 0>(Invoke(Concat5));\n  EXPECT_EQ(\"43210\",\n            a.Perform(make_tuple(CharPtr(\"0\"), CharPtr(\"1\"), CharPtr(\"2\"),\n                                 CharPtr(\"3\"), CharPtr(\"4\"))));\n}\n\n// Tests using WithArgs with an action that takes 6 arguments.\nTEST(WithArgsTest, SixArgs) {\n  Action<string(const char*, const char*, const char*)> a =\n      WithArgs<0, 1, 2, 2, 1, 0>(Invoke(Concat6));\n  EXPECT_EQ(\"012210\",\n            a.Perform(make_tuple(CharPtr(\"0\"), CharPtr(\"1\"), CharPtr(\"2\"))));\n}\n\n// Tests using WithArgs with an action that takes 7 arguments.\nTEST(WithArgsTest, SevenArgs) {\n  Action<string(const char*, const char*, const char*, const char*)> a =\n      WithArgs<0, 1, 2, 3, 2, 1, 0>(Invoke(Concat7));\n  EXPECT_EQ(\"0123210\",\n            a.Perform(make_tuple(CharPtr(\"0\"), CharPtr(\"1\"), CharPtr(\"2\"),\n                                 CharPtr(\"3\"))));\n}\n\n// Tests using WithArgs with an action that takes 8 arguments.\nTEST(WithArgsTest, EightArgs) {\n  Action<string(const char*, const char*, const char*, const char*)> a =\n      WithArgs<0, 1, 2, 3, 0, 1, 2, 3>(Invoke(Concat8));\n  EXPECT_EQ(\"01230123\",\n            a.Perform(make_tuple(CharPtr(\"0\"), CharPtr(\"1\"), CharPtr(\"2\"),\n                                 CharPtr(\"3\"))));\n}\n\n// Tests using WithArgs with an action that takes 9 arguments.\nTEST(WithArgsTest, NineArgs) {\n  Action<string(const char*, const char*, const char*, const char*)> a =\n      WithArgs<0, 1, 2, 3, 1, 2, 3, 2, 3>(Invoke(Concat9));\n  EXPECT_EQ(\"012312323\",\n            a.Perform(make_tuple(CharPtr(\"0\"), CharPtr(\"1\"), CharPtr(\"2\"),\n                                 CharPtr(\"3\"))));\n}\n\n// Tests using WithArgs with an action that takes 10 arguments.\nTEST(WithArgsTest, TenArgs) {\n  Action<string(const char*, const char*, const char*, const char*)> a =\n      WithArgs<0, 1, 2, 3, 2, 1, 0, 1, 2, 3>(Invoke(Concat10));\n  EXPECT_EQ(\"0123210123\",\n            a.Perform(make_tuple(CharPtr(\"0\"), CharPtr(\"1\"), CharPtr(\"2\"),\n                                 CharPtr(\"3\"))));\n}\n\n// Tests using WithArgs with an action that is not Invoke().\nclass SubstractAction : public ActionInterface<int(int, int)> {  // NOLINT\n public:\n  virtual int Perform(const tuple<int, int>& args) {\n    return get<0>(args) - get<1>(args);\n  }\n};\n\nTEST(WithArgsTest, NonInvokeAction) {\n  Action<int(const string&, int, int)> a =  // NOLINT\n      WithArgs<2, 1>(MakeAction(new SubstractAction));\n  EXPECT_EQ(8, a.Perform(make_tuple(string(\"hi\"), 2, 10)));\n}\n\n// Tests using WithArgs to pass all original arguments in the original order.\nTEST(WithArgsTest, Identity) {\n  Action<int(int x, char y, short z)> a =  // NOLINT\n      WithArgs<0, 1, 2>(Invoke(Ternary));\n  EXPECT_EQ(123, a.Perform(make_tuple(100, Char(20), Short(3))));\n}\n\n// Tests using WithArgs with repeated arguments.\nTEST(WithArgsTest, RepeatedArguments) {\n  Action<int(bool, int m, int n)> a =  // NOLINT\n      WithArgs<1, 1, 1, 1>(Invoke(SumOf4));\n  EXPECT_EQ(4, a.Perform(make_tuple(false, 1, 10)));\n}\n\n// Tests using WithArgs with reversed argument order.\nTEST(WithArgsTest, ReversedArgumentOrder) {\n  Action<const char*(short n, const char* input)> a =  // NOLINT\n      WithArgs<1, 0>(Invoke(Binary));\n  const char s[] = \"Hello\";\n  EXPECT_EQ(s + 2, a.Perform(make_tuple(Short(2), CharPtr(s))));\n}\n\n// Tests using WithArgs with compatible, but not identical, argument types.\nTEST(WithArgsTest, ArgsOfCompatibleTypes) {\n  Action<long(short x, char y, double z, char c)> a =  // NOLINT\n      WithArgs<0, 1, 3>(Invoke(Ternary));\n  EXPECT_EQ(123, a.Perform(make_tuple(Short(100), Char(20), 5.6, Char(3))));\n}\n\n// Tests using WithArgs with an action that returns void.\nTEST(WithArgsTest, VoidAction) {\n  Action<void(double x, char c, int n)> a = WithArgs<2, 1>(Invoke(VoidBinary));\n  g_done = false;\n  a.Perform(make_tuple(1.5, 'a', 3));\n  EXPECT_TRUE(g_done);\n}\n\n// Tests DoAll(a1, a2).\nTEST(DoAllTest, TwoActions) {\n  int n = 0;\n  Action<int(int*)> a = DoAll(SetArgPointee<0>(1),  // NOLINT\n                              Return(2));\n  EXPECT_EQ(2, a.Perform(make_tuple(&n)));\n  EXPECT_EQ(1, n);\n}\n\n// Tests DoAll(a1, a2, a3).\nTEST(DoAllTest, ThreeActions) {\n  int m = 0, n = 0;\n  Action<int(int*, int*)> a = DoAll(SetArgPointee<0>(1),  // NOLINT\n                                    SetArgPointee<1>(2),\n                                    Return(3));\n  EXPECT_EQ(3, a.Perform(make_tuple(&m, &n)));\n  EXPECT_EQ(1, m);\n  EXPECT_EQ(2, n);\n}\n\n// Tests DoAll(a1, a2, a3, a4).\nTEST(DoAllTest, FourActions) {\n  int m = 0, n = 0;\n  char ch = '\\0';\n  Action<int(int*, int*, char*)> a =  // NOLINT\n      DoAll(SetArgPointee<0>(1),\n            SetArgPointee<1>(2),\n            SetArgPointee<2>('a'),\n            Return(3));\n  EXPECT_EQ(3, a.Perform(make_tuple(&m, &n, &ch)));\n  EXPECT_EQ(1, m);\n  EXPECT_EQ(2, n);\n  EXPECT_EQ('a', ch);\n}\n\n// Tests DoAll(a1, a2, a3, a4, a5).\nTEST(DoAllTest, FiveActions) {\n  int m = 0, n = 0;\n  char a = '\\0', b = '\\0';\n  Action<int(int*, int*, char*, char*)> action =  // NOLINT\n      DoAll(SetArgPointee<0>(1),\n            SetArgPointee<1>(2),\n            SetArgPointee<2>('a'),\n            SetArgPointee<3>('b'),\n            Return(3));\n  EXPECT_EQ(3, action.Perform(make_tuple(&m, &n, &a, &b)));\n  EXPECT_EQ(1, m);\n  EXPECT_EQ(2, n);\n  EXPECT_EQ('a', a);\n  EXPECT_EQ('b', b);\n}\n\n// Tests DoAll(a1, a2, ..., a6).\nTEST(DoAllTest, SixActions) {\n  int m = 0, n = 0;\n  char a = '\\0', b = '\\0', c = '\\0';\n  Action<int(int*, int*, char*, char*, char*)> action =  // NOLINT\n      DoAll(SetArgPointee<0>(1),\n            SetArgPointee<1>(2),\n            SetArgPointee<2>('a'),\n            SetArgPointee<3>('b'),\n            SetArgPointee<4>('c'),\n            Return(3));\n  EXPECT_EQ(3, action.Perform(make_tuple(&m, &n, &a, &b, &c)));\n  EXPECT_EQ(1, m);\n  EXPECT_EQ(2, n);\n  EXPECT_EQ('a', a);\n  EXPECT_EQ('b', b);\n  EXPECT_EQ('c', c);\n}\n\n// Tests DoAll(a1, a2, ..., a7).\nTEST(DoAllTest, SevenActions) {\n  int m = 0, n = 0;\n  char a = '\\0', b = '\\0', c = '\\0', d = '\\0';\n  Action<int(int*, int*, char*, char*, char*, char*)> action =  // NOLINT\n      DoAll(SetArgPointee<0>(1),\n            SetArgPointee<1>(2),\n            SetArgPointee<2>('a'),\n            SetArgPointee<3>('b'),\n            SetArgPointee<4>('c'),\n            SetArgPointee<5>('d'),\n            Return(3));\n  EXPECT_EQ(3, action.Perform(make_tuple(&m, &n, &a, &b, &c, &d)));\n  EXPECT_EQ(1, m);\n  EXPECT_EQ(2, n);\n  EXPECT_EQ('a', a);\n  EXPECT_EQ('b', b);\n  EXPECT_EQ('c', c);\n  EXPECT_EQ('d', d);\n}\n\n// Tests DoAll(a1, a2, ..., a8).\nTEST(DoAllTest, EightActions) {\n  int m = 0, n = 0;\n  char a = '\\0', b = '\\0', c = '\\0', d = '\\0', e = '\\0';\n  Action<int(int*, int*, char*, char*, char*, char*,  // NOLINT\n             char*)> action =\n      DoAll(SetArgPointee<0>(1),\n            SetArgPointee<1>(2),\n            SetArgPointee<2>('a'),\n            SetArgPointee<3>('b'),\n            SetArgPointee<4>('c'),\n            SetArgPointee<5>('d'),\n            SetArgPointee<6>('e'),\n            Return(3));\n  EXPECT_EQ(3, action.Perform(make_tuple(&m, &n, &a, &b, &c, &d, &e)));\n  EXPECT_EQ(1, m);\n  EXPECT_EQ(2, n);\n  EXPECT_EQ('a', a);\n  EXPECT_EQ('b', b);\n  EXPECT_EQ('c', c);\n  EXPECT_EQ('d', d);\n  EXPECT_EQ('e', e);\n}\n\n// Tests DoAll(a1, a2, ..., a9).\nTEST(DoAllTest, NineActions) {\n  int m = 0, n = 0;\n  char a = '\\0', b = '\\0', c = '\\0', d = '\\0', e = '\\0', f = '\\0';\n  Action<int(int*, int*, char*, char*, char*, char*,  // NOLINT\n             char*, char*)> action =\n      DoAll(SetArgPointee<0>(1),\n            SetArgPointee<1>(2),\n            SetArgPointee<2>('a'),\n            SetArgPointee<3>('b'),\n            SetArgPointee<4>('c'),\n            SetArgPointee<5>('d'),\n            SetArgPointee<6>('e'),\n            SetArgPointee<7>('f'),\n            Return(3));\n  EXPECT_EQ(3, action.Perform(make_tuple(&m, &n, &a, &b, &c, &d, &e, &f)));\n  EXPECT_EQ(1, m);\n  EXPECT_EQ(2, n);\n  EXPECT_EQ('a', a);\n  EXPECT_EQ('b', b);\n  EXPECT_EQ('c', c);\n  EXPECT_EQ('d', d);\n  EXPECT_EQ('e', e);\n  EXPECT_EQ('f', f);\n}\n\n// Tests DoAll(a1, a2, ..., a10).\nTEST(DoAllTest, TenActions) {\n  int m = 0, n = 0;\n  char a = '\\0', b = '\\0', c = '\\0', d = '\\0';\n  char e = '\\0', f = '\\0', g = '\\0';\n  Action<int(int*, int*, char*, char*, char*, char*,  // NOLINT\n             char*, char*, char*)> action =\n      DoAll(SetArgPointee<0>(1),\n            SetArgPointee<1>(2),\n            SetArgPointee<2>('a'),\n            SetArgPointee<3>('b'),\n            SetArgPointee<4>('c'),\n            SetArgPointee<5>('d'),\n            SetArgPointee<6>('e'),\n            SetArgPointee<7>('f'),\n            SetArgPointee<8>('g'),\n            Return(3));\n  EXPECT_EQ(3, action.Perform(make_tuple(&m, &n, &a, &b, &c, &d, &e, &f, &g)));\n  EXPECT_EQ(1, m);\n  EXPECT_EQ(2, n);\n  EXPECT_EQ('a', a);\n  EXPECT_EQ('b', b);\n  EXPECT_EQ('c', c);\n  EXPECT_EQ('d', d);\n  EXPECT_EQ('e', e);\n  EXPECT_EQ('f', f);\n  EXPECT_EQ('g', g);\n}\n\n// The ACTION*() macros trigger warning C4100 (unreferenced formal\n// parameter) in MSVC with -W4.  Unfortunately they cannot be fixed in\n// the macro definition, as the warnings are generated when the macro\n// is expanded and macro expansion cannot contain #pragma.  Therefore\n// we suppress them here.\n#ifdef _MSC_VER\n# pragma warning(push)\n# pragma warning(disable:4100)\n#endif\n\n// Tests the ACTION*() macro family.\n\n// Tests that ACTION() can define an action that doesn't reference the\n// mock function arguments.\nACTION(Return5) { return 5; }\n\nTEST(ActionMacroTest, WorksWhenNotReferencingArguments) {\n  Action<double()> a1 = Return5();\n  EXPECT_DOUBLE_EQ(5, a1.Perform(make_tuple()));\n\n  Action<int(double, bool)> a2 = Return5();\n  EXPECT_EQ(5, a2.Perform(make_tuple(1, true)));\n}\n\n// Tests that ACTION() can define an action that returns void.\nACTION(IncrementArg1) { (*arg1)++; }\n\nTEST(ActionMacroTest, WorksWhenReturningVoid) {\n  Action<void(int, int*)> a1 = IncrementArg1();\n  int n = 0;\n  a1.Perform(make_tuple(5, &n));\n  EXPECT_EQ(1, n);\n}\n\n// Tests that the body of ACTION() can reference the type of the\n// argument.\nACTION(IncrementArg2) {\n  StaticAssertTypeEq<int*, arg2_type>();\n  arg2_type temp = arg2;\n  (*temp)++;\n}\n\nTEST(ActionMacroTest, CanReferenceArgumentType) {\n  Action<void(int, bool, int*)> a1 = IncrementArg2();\n  int n = 0;\n  a1.Perform(make_tuple(5, false, &n));\n  EXPECT_EQ(1, n);\n}\n\n// Tests that the body of ACTION() can reference the argument tuple\n// via args_type and args.\nACTION(Sum2) {\n  StaticAssertTypeEq< ::std::tr1::tuple<int, char, int*>, args_type>();\n  args_type args_copy = args;\n  return get<0>(args_copy) + get<1>(args_copy);\n}\n\nTEST(ActionMacroTest, CanReferenceArgumentTuple) {\n  Action<int(int, char, int*)> a1 = Sum2();\n  int dummy = 0;\n  EXPECT_EQ(11, a1.Perform(make_tuple(5, Char(6), &dummy)));\n}\n\n// Tests that the body of ACTION() can reference the mock function\n// type.\nint Dummy(bool flag) { return flag? 1 : 0; }\n\nACTION(InvokeDummy) {\n  StaticAssertTypeEq<int(bool), function_type>();\n  function_type* fp = &Dummy;\n  return (*fp)(true);\n}\n\nTEST(ActionMacroTest, CanReferenceMockFunctionType) {\n  Action<int(bool)> a1 = InvokeDummy();\n  EXPECT_EQ(1, a1.Perform(make_tuple(true)));\n  EXPECT_EQ(1, a1.Perform(make_tuple(false)));\n}\n\n// Tests that the body of ACTION() can reference the mock function's\n// return type.\nACTION(InvokeDummy2) {\n  StaticAssertTypeEq<int, return_type>();\n  return_type result = Dummy(true);\n  return result;\n}\n\nTEST(ActionMacroTest, CanReferenceMockFunctionReturnType) {\n  Action<int(bool)> a1 = InvokeDummy2();\n  EXPECT_EQ(1, a1.Perform(make_tuple(true)));\n  EXPECT_EQ(1, a1.Perform(make_tuple(false)));\n}\n\n// Tests that ACTION() works for arguments passed by const reference.\nACTION(ReturnAddrOfConstBoolReferenceArg) {\n  StaticAssertTypeEq<const bool&, arg1_type>();\n  return &arg1;\n}\n\nTEST(ActionMacroTest, WorksForConstReferenceArg) {\n  Action<const bool*(int, const bool&)> a = ReturnAddrOfConstBoolReferenceArg();\n  const bool b = false;\n  EXPECT_EQ(&b, a.Perform(tuple<int, const bool&>(0, b)));\n}\n\n// Tests that ACTION() works for arguments passed by non-const reference.\nACTION(ReturnAddrOfIntReferenceArg) {\n  StaticAssertTypeEq<int&, arg0_type>();\n  return &arg0;\n}\n\nTEST(ActionMacroTest, WorksForNonConstReferenceArg) {\n  Action<int*(int&, bool, int)> a = ReturnAddrOfIntReferenceArg();\n  int n = 0;\n  EXPECT_EQ(&n, a.Perform(tuple<int&, bool, int>(n, true, 1)));\n}\n\n// Tests that ACTION() can be used in a namespace.\nnamespace action_test {\nACTION(Sum) { return arg0 + arg1; }\n}  // namespace action_test\n\nTEST(ActionMacroTest, WorksInNamespace) {\n  Action<int(int, int)> a1 = action_test::Sum();\n  EXPECT_EQ(3, a1.Perform(make_tuple(1, 2)));\n}\n\n// Tests that the same ACTION definition works for mock functions with\n// different argument numbers.\nACTION(PlusTwo) { return arg0 + 2; }\n\nTEST(ActionMacroTest, WorksForDifferentArgumentNumbers) {\n  Action<int(int)> a1 = PlusTwo();\n  EXPECT_EQ(4, a1.Perform(make_tuple(2)));\n\n  Action<double(float, void*)> a2 = PlusTwo();\n  int dummy;\n  EXPECT_DOUBLE_EQ(6, a2.Perform(make_tuple(4.0f, &dummy)));\n}\n\n// Tests that ACTION_P can define a parameterized action.\nACTION_P(Plus, n) { return arg0 + n; }\n\nTEST(ActionPMacroTest, DefinesParameterizedAction) {\n  Action<int(int m, bool t)> a1 = Plus(9);\n  EXPECT_EQ(10, a1.Perform(make_tuple(1, true)));\n}\n\n// Tests that the body of ACTION_P can reference the argument types\n// and the parameter type.\nACTION_P(TypedPlus, n) {\n  arg0_type t1 = arg0;\n  n_type t2 = n;\n  return t1 + t2;\n}\n\nTEST(ActionPMacroTest, CanReferenceArgumentAndParameterTypes) {\n  Action<int(char m, bool t)> a1 = TypedPlus(9);\n  EXPECT_EQ(10, a1.Perform(make_tuple(Char(1), true)));\n}\n\n// Tests that a parameterized action can be used in any mock function\n// whose type is compatible.\nTEST(ActionPMacroTest, WorksInCompatibleMockFunction) {\n  Action<std::string(const std::string& s)> a1 = Plus(\"tail\");\n  const std::string re = \"re\";\n  EXPECT_EQ(\"retail\", a1.Perform(make_tuple(re)));\n}\n\n// Tests that we can use ACTION*() to define actions overloaded on the\n// number of parameters.\n\nACTION(OverloadedAction) { return arg0 ? arg1 : \"hello\"; }\n\nACTION_P(OverloadedAction, default_value) {\n  return arg0 ? arg1 : default_value;\n}\n\nACTION_P2(OverloadedAction, true_value, false_value) {\n  return arg0 ? true_value : false_value;\n}\n\nTEST(ActionMacroTest, CanDefineOverloadedActions) {\n  typedef Action<const char*(bool, const char*)> MyAction;\n\n  const MyAction a1 = OverloadedAction();\n  EXPECT_STREQ(\"hello\", a1.Perform(make_tuple(false, CharPtr(\"world\"))));\n  EXPECT_STREQ(\"world\", a1.Perform(make_tuple(true, CharPtr(\"world\"))));\n\n  const MyAction a2 = OverloadedAction(\"hi\");\n  EXPECT_STREQ(\"hi\", a2.Perform(make_tuple(false, CharPtr(\"world\"))));\n  EXPECT_STREQ(\"world\", a2.Perform(make_tuple(true, CharPtr(\"world\"))));\n\n  const MyAction a3 = OverloadedAction(\"hi\", \"you\");\n  EXPECT_STREQ(\"hi\", a3.Perform(make_tuple(true, CharPtr(\"world\"))));\n  EXPECT_STREQ(\"you\", a3.Perform(make_tuple(false, CharPtr(\"world\"))));\n}\n\n// Tests ACTION_Pn where n >= 3.\n\nACTION_P3(Plus, m, n, k) { return arg0 + m + n + k; }\n\nTEST(ActionPnMacroTest, WorksFor3Parameters) {\n  Action<double(int m, bool t)> a1 = Plus(100, 20, 3.4);\n  EXPECT_DOUBLE_EQ(3123.4, a1.Perform(make_tuple(3000, true)));\n\n  Action<std::string(const std::string& s)> a2 = Plus(\"tail\", \"-\", \">\");\n  const std::string re = \"re\";\n  EXPECT_EQ(\"retail->\", a2.Perform(make_tuple(re)));\n}\n\nACTION_P4(Plus, p0, p1, p2, p3) { return arg0 + p0 + p1 + p2 + p3; }\n\nTEST(ActionPnMacroTest, WorksFor4Parameters) {\n  Action<int(int)> a1 = Plus(1, 2, 3, 4);\n  EXPECT_EQ(10 + 1 + 2 + 3 + 4, a1.Perform(make_tuple(10)));\n}\n\nACTION_P5(Plus, p0, p1, p2, p3, p4) { return arg0 + p0 + p1 + p2 + p3 + p4; }\n\nTEST(ActionPnMacroTest, WorksFor5Parameters) {\n  Action<int(int)> a1 = Plus(1, 2, 3, 4, 5);\n  EXPECT_EQ(10 + 1 + 2 + 3 + 4 + 5, a1.Perform(make_tuple(10)));\n}\n\nACTION_P6(Plus, p0, p1, p2, p3, p4, p5) {\n  return arg0 + p0 + p1 + p2 + p3 + p4 + p5;\n}\n\nTEST(ActionPnMacroTest, WorksFor6Parameters) {\n  Action<int(int)> a1 = Plus(1, 2, 3, 4, 5, 6);\n  EXPECT_EQ(10 + 1 + 2 + 3 + 4 + 5 + 6, a1.Perform(make_tuple(10)));\n}\n\nACTION_P7(Plus, p0, p1, p2, p3, p4, p5, p6) {\n  return arg0 + p0 + p1 + p2 + p3 + p4 + p5 + p6;\n}\n\nTEST(ActionPnMacroTest, WorksFor7Parameters) {\n  Action<int(int)> a1 = Plus(1, 2, 3, 4, 5, 6, 7);\n  EXPECT_EQ(10 + 1 + 2 + 3 + 4 + 5 + 6 + 7, a1.Perform(make_tuple(10)));\n}\n\nACTION_P8(Plus, p0, p1, p2, p3, p4, p5, p6, p7) {\n  return arg0 + p0 + p1 + p2 + p3 + p4 + p5 + p6 + p7;\n}\n\nTEST(ActionPnMacroTest, WorksFor8Parameters) {\n  Action<int(int)> a1 = Plus(1, 2, 3, 4, 5, 6, 7, 8);\n  EXPECT_EQ(10 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8, a1.Perform(make_tuple(10)));\n}\n\nACTION_P9(Plus, p0, p1, p2, p3, p4, p5, p6, p7, p8) {\n  return arg0 + p0 + p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8;\n}\n\nTEST(ActionPnMacroTest, WorksFor9Parameters) {\n  Action<int(int)> a1 = Plus(1, 2, 3, 4, 5, 6, 7, 8, 9);\n  EXPECT_EQ(10 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9, a1.Perform(make_tuple(10)));\n}\n\nACTION_P10(Plus, p0, p1, p2, p3, p4, p5, p6, p7, p8, last_param) {\n  arg0_type t0 = arg0;\n  last_param_type t9 = last_param;\n  return t0 + p0 + p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + t9;\n}\n\nTEST(ActionPnMacroTest, WorksFor10Parameters) {\n  Action<int(int)> a1 = Plus(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);\n  EXPECT_EQ(10 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10,\n            a1.Perform(make_tuple(10)));\n}\n\n// Tests that the action body can promote the parameter types.\n\nACTION_P2(PadArgument, prefix, suffix) {\n  // The following lines promote the two parameters to desired types.\n  std::string prefix_str(prefix);\n  char suffix_char = static_cast<char>(suffix);\n  return prefix_str + arg0 + suffix_char;\n}\n\nTEST(ActionPnMacroTest, SimpleTypePromotion) {\n  Action<std::string(const char*)> no_promo =\n      PadArgument(std::string(\"foo\"), 'r');\n  Action<std::string(const char*)> promo =\n      PadArgument(\"foo\", static_cast<int>('r'));\n  EXPECT_EQ(\"foobar\", no_promo.Perform(make_tuple(CharPtr(\"ba\"))));\n  EXPECT_EQ(\"foobar\", promo.Perform(make_tuple(CharPtr(\"ba\"))));\n}\n\n// Tests that we can partially restrict parameter types using a\n// straight-forward pattern.\n\n// Defines a generic action that doesn't restrict the types of its\n// parameters.\nACTION_P3(ConcatImpl, a, b, c) {\n  std::stringstream ss;\n  ss << a << b << c;\n  return ss.str();\n}\n\n// Next, we try to restrict that either the first parameter is a\n// string, or the second parameter is an int.\n\n// Defines a partially specialized wrapper that restricts the first\n// parameter to std::string.\ntemplate <typename T1, typename T2>\n// ConcatImplActionP3 is the class template ACTION_P3 uses to\n// implement ConcatImpl.  We shouldn't change the name as this\n// pattern requires the user to use it directly.\nConcatImplActionP3<std::string, T1, T2>\nConcat(const std::string& a, T1 b, T2 c) {\n  if (true) {\n    // This branch verifies that ConcatImpl() can be invoked without\n    // explicit template arguments.\n    return ConcatImpl(a, b, c);\n  } else {\n    // This branch verifies that ConcatImpl() can also be invoked with\n    // explicit template arguments.  It doesn't really need to be\n    // executed as this is a compile-time verification.\n    return ConcatImpl<std::string, T1, T2>(a, b, c);\n  }\n}\n\n// Defines another partially specialized wrapper that restricts the\n// second parameter to int.\ntemplate <typename T1, typename T2>\nConcatImplActionP3<T1, int, T2>\nConcat(T1 a, int b, T2 c) {\n  return ConcatImpl(a, b, c);\n}\n\nTEST(ActionPnMacroTest, CanPartiallyRestrictParameterTypes) {\n  Action<const std::string()> a1 = Concat(\"Hello\", \"1\", 2);\n  EXPECT_EQ(\"Hello12\", a1.Perform(make_tuple()));\n\n  a1 = Concat(1, 2, 3);\n  EXPECT_EQ(\"123\", a1.Perform(make_tuple()));\n}\n\n// Verifies the type of an ACTION*.\n\nACTION(DoFoo) {}\nACTION_P(DoFoo, p) {}\nACTION_P2(DoFoo, p0, p1) {}\n\nTEST(ActionPnMacroTest, TypesAreCorrect) {\n  // DoFoo() must be assignable to a DoFooAction variable.\n  DoFooAction a0 = DoFoo();\n\n  // DoFoo(1) must be assignable to a DoFooActionP variable.\n  DoFooActionP<int> a1 = DoFoo(1);\n\n  // DoFoo(p1, ..., pk) must be assignable to a DoFooActionPk\n  // variable, and so on.\n  DoFooActionP2<int, char> a2 = DoFoo(1, '2');\n  PlusActionP3<int, int, char> a3 = Plus(1, 2, '3');\n  PlusActionP4<int, int, int, char> a4 = Plus(1, 2, 3, '4');\n  PlusActionP5<int, int, int, int, char> a5 = Plus(1, 2, 3, 4, '5');\n  PlusActionP6<int, int, int, int, int, char> a6 = Plus(1, 2, 3, 4, 5, '6');\n  PlusActionP7<int, int, int, int, int, int, char> a7 =\n      Plus(1, 2, 3, 4, 5, 6, '7');\n  PlusActionP8<int, int, int, int, int, int, int, char> a8 =\n      Plus(1, 2, 3, 4, 5, 6, 7, '8');\n  PlusActionP9<int, int, int, int, int, int, int, int, char> a9 =\n      Plus(1, 2, 3, 4, 5, 6, 7, 8, '9');\n  PlusActionP10<int, int, int, int, int, int, int, int, int, char> a10 =\n      Plus(1, 2, 3, 4, 5, 6, 7, 8, 9, '0');\n\n  // Avoid \"unused variable\" warnings.\n  (void)a0;\n  (void)a1;\n  (void)a2;\n  (void)a3;\n  (void)a4;\n  (void)a5;\n  (void)a6;\n  (void)a7;\n  (void)a8;\n  (void)a9;\n  (void)a10;\n}\n\n// Tests that an ACTION_P*() action can be explicitly instantiated\n// with reference-typed parameters.\n\nACTION_P(Plus1, x) { return x; }\nACTION_P2(Plus2, x, y) { return x + y; }\nACTION_P3(Plus3, x, y, z) { return x + y + z; }\nACTION_P10(Plus10, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {\n  return a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9;\n}\n\nTEST(ActionPnMacroTest, CanExplicitlyInstantiateWithReferenceTypes) {\n  int x = 1, y = 2, z = 3;\n  const tuple<> empty = make_tuple();\n\n  Action<int()> a = Plus1<int&>(x);\n  EXPECT_EQ(1, a.Perform(empty));\n\n  a = Plus2<const int&, int&>(x, y);\n  EXPECT_EQ(3, a.Perform(empty));\n\n  a = Plus3<int&, const int&, int&>(x, y, z);\n  EXPECT_EQ(6, a.Perform(empty));\n\n  int n[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };\n  a = Plus10<const int&, int&, const int&, int&, const int&, int&, const int&,\n      int&, const int&, int&>(n[0], n[1], n[2], n[3], n[4], n[5], n[6], n[7],\n                              n[8], n[9]);\n  EXPECT_EQ(55, a.Perform(empty));\n}\n\nclass NullaryConstructorClass {\n public:\n  NullaryConstructorClass() : value_(123) {}\n  int value_;\n};\n\n// Tests using ReturnNew() with a nullary constructor.\nTEST(ReturnNewTest, NoArgs) {\n  Action<NullaryConstructorClass*()> a = ReturnNew<NullaryConstructorClass>();\n  NullaryConstructorClass* c = a.Perform(make_tuple());\n  EXPECT_EQ(123, c->value_);\n  delete c;\n}\n\nclass UnaryConstructorClass {\n public:\n  explicit UnaryConstructorClass(int value) : value_(value) {}\n  int value_;\n};\n\n// Tests using ReturnNew() with a unary constructor.\nTEST(ReturnNewTest, Unary) {\n  Action<UnaryConstructorClass*()> a = ReturnNew<UnaryConstructorClass>(4000);\n  UnaryConstructorClass* c = a.Perform(make_tuple());\n  EXPECT_EQ(4000, c->value_);\n  delete c;\n}\n\nTEST(ReturnNewTest, UnaryWorksWhenMockMethodHasArgs) {\n  Action<UnaryConstructorClass*(bool, int)> a =\n      ReturnNew<UnaryConstructorClass>(4000);\n  UnaryConstructorClass* c = a.Perform(make_tuple(false, 5));\n  EXPECT_EQ(4000, c->value_);\n  delete c;\n}\n\nTEST(ReturnNewTest, UnaryWorksWhenMockMethodReturnsPointerToConst) {\n  Action<const UnaryConstructorClass*()> a =\n      ReturnNew<UnaryConstructorClass>(4000);\n  const UnaryConstructorClass* c = a.Perform(make_tuple());\n  EXPECT_EQ(4000, c->value_);\n  delete c;\n}\n\nclass TenArgConstructorClass {\n public:\n  TenArgConstructorClass(int a1, int a2, int a3, int a4, int a5,\n                         int a6, int a7, int a8, int a9, int a10)\n    : value_(a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9 + a10) {\n  }\n  int value_;\n};\n\n// Tests using ReturnNew() with a 10-argument constructor.\nTEST(ReturnNewTest, ConstructorThatTakes10Arguments) {\n  Action<TenArgConstructorClass*()> a =\n      ReturnNew<TenArgConstructorClass>(1000000000, 200000000, 30000000,\n                                        4000000, 500000, 60000,\n                                        7000, 800, 90, 0);\n  TenArgConstructorClass* c = a.Perform(make_tuple());\n  EXPECT_EQ(1234567890, c->value_);\n  delete c;\n}\n\n// Tests that ACTION_TEMPLATE works when there is no value parameter.\nACTION_TEMPLATE(CreateNew,\n                HAS_1_TEMPLATE_PARAMS(typename, T),\n                AND_0_VALUE_PARAMS()) {\n  return new T;\n}\n\nTEST(ActionTemplateTest, WorksWithoutValueParam) {\n  const Action<int*()> a = CreateNew<int>();\n  int* p = a.Perform(make_tuple());\n  delete p;\n}\n\n// Tests that ACTION_TEMPLATE works when there are value parameters.\nACTION_TEMPLATE(CreateNew,\n                HAS_1_TEMPLATE_PARAMS(typename, T),\n                AND_1_VALUE_PARAMS(a0)) {\n  return new T(a0);\n}\n\nTEST(ActionTemplateTest, WorksWithValueParams) {\n  const Action<int*()> a = CreateNew<int>(42);\n  int* p = a.Perform(make_tuple());\n  EXPECT_EQ(42, *p);\n  delete p;\n}\n\n// Tests that ACTION_TEMPLATE works for integral template parameters.\nACTION_TEMPLATE(MyDeleteArg,\n                HAS_1_TEMPLATE_PARAMS(int, k),\n                AND_0_VALUE_PARAMS()) {\n  delete std::tr1::get<k>(args);\n}\n\n// Resets a bool variable in the destructor.\nclass BoolResetter {\n public:\n  explicit BoolResetter(bool* value) : value_(value) {}\n  ~BoolResetter() { *value_ = false; }\n private:\n  bool* value_;\n};\n\nTEST(ActionTemplateTest, WorksForIntegralTemplateParams) {\n  const Action<void(int*, BoolResetter*)> a = MyDeleteArg<1>();\n  int n = 0;\n  bool b = true;\n  BoolResetter* resetter = new BoolResetter(&b);\n  a.Perform(make_tuple(&n, resetter));\n  EXPECT_FALSE(b);  // Verifies that resetter is deleted.\n}\n\n// Tests that ACTION_TEMPLATES works for template template parameters.\nACTION_TEMPLATE(ReturnSmartPointer,\n                HAS_1_TEMPLATE_PARAMS(template <typename Pointee> class,\n                                      Pointer),\n                AND_1_VALUE_PARAMS(pointee)) {\n  return Pointer<pointee_type>(new pointee_type(pointee));\n}\n\nTEST(ActionTemplateTest, WorksForTemplateTemplateParameters) {\n  using ::testing::internal::linked_ptr;\n  const Action<linked_ptr<int>()> a = ReturnSmartPointer<linked_ptr>(42);\n  linked_ptr<int> p = a.Perform(make_tuple());\n  EXPECT_EQ(42, *p);\n}\n\n// Tests that ACTION_TEMPLATE works for 10 template parameters.\ntemplate <typename T1, typename T2, typename T3, int k4, bool k5,\n          unsigned int k6, typename T7, typename T8, typename T9>\nstruct GiantTemplate {\n public:\n  explicit GiantTemplate(int a_value) : value(a_value) {}\n  int value;\n};\n\nACTION_TEMPLATE(ReturnGiant,\n                HAS_10_TEMPLATE_PARAMS(\n                    typename, T1,\n                    typename, T2,\n                    typename, T3,\n                    int, k4,\n                    bool, k5,\n                    unsigned int, k6,\n                    class, T7,\n                    class, T8,\n                    class, T9,\n                    template <typename T> class, T10),\n                AND_1_VALUE_PARAMS(value)) {\n  return GiantTemplate<T10<T1>, T2, T3, k4, k5, k6, T7, T8, T9>(value);\n}\n\nTEST(ActionTemplateTest, WorksFor10TemplateParameters) {\n  using ::testing::internal::linked_ptr;\n  typedef GiantTemplate<linked_ptr<int>, bool, double, 5,\n      true, 6, char, unsigned, int> Giant;\n  const Action<Giant()> a = ReturnGiant<\n      int, bool, double, 5, true, 6, char, unsigned, int, linked_ptr>(42);\n  Giant giant = a.Perform(make_tuple());\n  EXPECT_EQ(42, giant.value);\n}\n\n// Tests that ACTION_TEMPLATE works for 10 value parameters.\nACTION_TEMPLATE(ReturnSum,\n                HAS_1_TEMPLATE_PARAMS(typename, Number),\n                AND_10_VALUE_PARAMS(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10)) {\n  return static_cast<Number>(v1) + v2 + v3 + v4 + v5 + v6 + v7 + v8 + v9 + v10;\n}\n\nTEST(ActionTemplateTest, WorksFor10ValueParameters) {\n  const Action<int()> a = ReturnSum<int>(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);\n  EXPECT_EQ(55, a.Perform(make_tuple()));\n}\n\n// Tests that ACTION_TEMPLATE and ACTION/ACTION_P* can be overloaded\n// on the number of value parameters.\n\nACTION(ReturnSum) { return 0; }\n\nACTION_P(ReturnSum, x) { return x; }\n\nACTION_TEMPLATE(ReturnSum,\n                HAS_1_TEMPLATE_PARAMS(typename, Number),\n                AND_2_VALUE_PARAMS(v1, v2)) {\n  return static_cast<Number>(v1) + v2;\n}\n\nACTION_TEMPLATE(ReturnSum,\n                HAS_1_TEMPLATE_PARAMS(typename, Number),\n                AND_3_VALUE_PARAMS(v1, v2, v3)) {\n  return static_cast<Number>(v1) + v2 + v3;\n}\n\nACTION_TEMPLATE(ReturnSum,\n                HAS_2_TEMPLATE_PARAMS(typename, Number, int, k),\n                AND_4_VALUE_PARAMS(v1, v2, v3, v4)) {\n  return static_cast<Number>(v1) + v2 + v3 + v4 + k;\n}\n\nTEST(ActionTemplateTest, CanBeOverloadedOnNumberOfValueParameters) {\n  const Action<int()> a0 = ReturnSum();\n  const Action<int()> a1 = ReturnSum(1);\n  const Action<int()> a2 = ReturnSum<int>(1, 2);\n  const Action<int()> a3 = ReturnSum<int>(1, 2, 3);\n  const Action<int()> a4 = ReturnSum<int, 10000>(2000, 300, 40, 5);\n  EXPECT_EQ(0, a0.Perform(make_tuple()));\n  EXPECT_EQ(1, a1.Perform(make_tuple()));\n  EXPECT_EQ(3, a2.Perform(make_tuple()));\n  EXPECT_EQ(6, a3.Perform(make_tuple()));\n  EXPECT_EQ(12345, a4.Perform(make_tuple()));\n}\n\n#ifdef _MSC_VER\n# pragma warning(pop)\n#endif\n\n}  // namespace gmock_generated_actions_test\n}  // namespace testing\n"
  },
  {
    "path": "ext/gmock/test/gmock-generated-function-mockers_test.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file tests the function mocker classes.\n\n#include \"gmock/gmock-generated-function-mockers.h\"\n\n#if GTEST_OS_WINDOWS\n// MSDN says the header file to be included for STDMETHOD is BaseTyps.h but\n// we are getting compiler errors if we use basetyps.h, hence including\n// objbase.h for definition of STDMETHOD.\n# include <objbase.h>\n#endif  // GTEST_OS_WINDOWS\n\n#include <map>\n#include <string>\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n// There is a bug in MSVC (fixed in VS 2008) that prevents creating a\n// mock for a function with const arguments, so we don't test such\n// cases for MSVC versions older than 2008.\n#if !GTEST_OS_WINDOWS || (_MSC_VER >= 1500)\n# define GMOCK_ALLOWS_CONST_PARAM_FUNCTIONS\n#endif  // !GTEST_OS_WINDOWS || (_MSC_VER >= 1500)\n\nnamespace testing {\nnamespace gmock_generated_function_mockers_test {\n\nusing testing::internal::string;\nusing testing::_;\nusing testing::A;\nusing testing::An;\nusing testing::AnyNumber;\nusing testing::Const;\nusing testing::DoDefault;\nusing testing::Eq;\nusing testing::Lt;\nusing testing::MockFunction;\nusing testing::Ref;\nusing testing::Return;\nusing testing::ReturnRef;\nusing testing::TypedEq;\n\nclass FooInterface {\n public:\n  virtual ~FooInterface() {}\n\n  virtual void VoidReturning(int x) = 0;\n\n  virtual int Nullary() = 0;\n  virtual bool Unary(int x) = 0;\n  virtual long Binary(short x, int y) = 0;  // NOLINT\n  virtual int Decimal(bool b, char c, short d, int e, long f,  // NOLINT\n                      float g, double h, unsigned i, char* j, const string& k)\n      = 0;\n\n  virtual bool TakesNonConstReference(int& n) = 0;  // NOLINT\n  virtual string TakesConstReference(const int& n) = 0;\n#ifdef GMOCK_ALLOWS_CONST_PARAM_FUNCTIONS\n  virtual bool TakesConst(const int x) = 0;\n#endif  // GMOCK_ALLOWS_CONST_PARAM_FUNCTIONS\n\n  virtual int OverloadedOnArgumentNumber() = 0;\n  virtual int OverloadedOnArgumentNumber(int n) = 0;\n\n  virtual int OverloadedOnArgumentType(int n) = 0;\n  virtual char OverloadedOnArgumentType(char c) = 0;\n\n  virtual int OverloadedOnConstness() = 0;\n  virtual char OverloadedOnConstness() const = 0;\n\n  virtual int TypeWithHole(int (*func)()) = 0;\n  virtual int TypeWithComma(const std::map<int, string>& a_map) = 0;\n\n#if GTEST_OS_WINDOWS\n  STDMETHOD_(int, CTNullary)() = 0;\n  STDMETHOD_(bool, CTUnary)(int x) = 0;\n  STDMETHOD_(int, CTDecimal)(bool b, char c, short d, int e, long f,  // NOLINT\n      float g, double h, unsigned i, char* j, const string& k) = 0;\n  STDMETHOD_(char, CTConst)(int x) const = 0;\n#endif  // GTEST_OS_WINDOWS\n};\n\nclass MockFoo : public FooInterface {\n public:\n  MockFoo() {}\n\n  // Makes sure that a mock function parameter can be named.\n  MOCK_METHOD1(VoidReturning, void(int n));  // NOLINT\n\n  MOCK_METHOD0(Nullary, int());  // NOLINT\n\n  // Makes sure that a mock function parameter can be unnamed.\n  MOCK_METHOD1(Unary, bool(int));  // NOLINT\n  MOCK_METHOD2(Binary, long(short, int));  // NOLINT\n  MOCK_METHOD10(Decimal, int(bool, char, short, int, long, float,  // NOLINT\n                             double, unsigned, char*, const string& str));\n\n  MOCK_METHOD1(TakesNonConstReference, bool(int&));  // NOLINT\n  MOCK_METHOD1(TakesConstReference, string(const int&));\n\n#ifdef GMOCK_ALLOWS_CONST_PARAM_FUNCTIONS\n  MOCK_METHOD1(TakesConst, bool(const int));  // NOLINT\n#endif\n\n  // Tests that the function return type can contain unprotected comma.\n  MOCK_METHOD0(ReturnTypeWithComma, std::map<int, string>());\n  MOCK_CONST_METHOD1(ReturnTypeWithComma,\n                     std::map<int, string>(int));  // NOLINT\n\n  MOCK_METHOD0(OverloadedOnArgumentNumber, int());  // NOLINT\n  MOCK_METHOD1(OverloadedOnArgumentNumber, int(int));  // NOLINT\n\n  MOCK_METHOD1(OverloadedOnArgumentType, int(int));  // NOLINT\n  MOCK_METHOD1(OverloadedOnArgumentType, char(char));  // NOLINT\n\n  MOCK_METHOD0(OverloadedOnConstness, int());  // NOLINT\n  MOCK_CONST_METHOD0(OverloadedOnConstness, char());  // NOLINT\n\n  MOCK_METHOD1(TypeWithHole, int(int (*)()));  // NOLINT\n  MOCK_METHOD1(TypeWithComma, int(const std::map<int, string>&));  // NOLINT\n\n#if GTEST_OS_WINDOWS\n  MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, CTNullary, int());\n  MOCK_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, CTUnary, bool(int));\n  MOCK_METHOD10_WITH_CALLTYPE(STDMETHODCALLTYPE, CTDecimal, int(bool b, char c,\n      short d, int e, long f, float g, double h, unsigned i, char* j,\n      const string& k));\n  MOCK_CONST_METHOD1_WITH_CALLTYPE(STDMETHODCALLTYPE, CTConst, char(int));\n\n  // Tests that the function return type can contain unprotected comma.\n  MOCK_METHOD0_WITH_CALLTYPE(STDMETHODCALLTYPE, CTReturnTypeWithComma,\n                             std::map<int, string>());\n#endif  // GTEST_OS_WINDOWS\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo);\n};\n\nclass FunctionMockerTest : public testing::Test {\n protected:\n  FunctionMockerTest() : foo_(&mock_foo_) {}\n\n  FooInterface* const foo_;\n  MockFoo mock_foo_;\n};\n\n// Tests mocking a void-returning function.\nTEST_F(FunctionMockerTest, MocksVoidFunction) {\n  EXPECT_CALL(mock_foo_, VoidReturning(Lt(100)));\n  foo_->VoidReturning(0);\n}\n\n// Tests mocking a nullary function.\nTEST_F(FunctionMockerTest, MocksNullaryFunction) {\n  EXPECT_CALL(mock_foo_, Nullary())\n      .WillOnce(DoDefault())\n      .WillOnce(Return(1));\n\n  EXPECT_EQ(0, foo_->Nullary());\n  EXPECT_EQ(1, foo_->Nullary());\n}\n\n// Tests mocking a unary function.\nTEST_F(FunctionMockerTest, MocksUnaryFunction) {\n  EXPECT_CALL(mock_foo_, Unary(Eq(2)))\n      .Times(2)\n      .WillOnce(Return(true));\n\n  EXPECT_TRUE(foo_->Unary(2));\n  EXPECT_FALSE(foo_->Unary(2));\n}\n\n// Tests mocking a binary function.\nTEST_F(FunctionMockerTest, MocksBinaryFunction) {\n  EXPECT_CALL(mock_foo_, Binary(2, _))\n      .WillOnce(Return(3));\n\n  EXPECT_EQ(3, foo_->Binary(2, 1));\n}\n\n// Tests mocking a decimal function.\nTEST_F(FunctionMockerTest, MocksDecimalFunction) {\n  EXPECT_CALL(mock_foo_, Decimal(true, 'a', 0, 0, 1L, A<float>(),\n                                 Lt(100), 5U, NULL, \"hi\"))\n      .WillOnce(Return(5));\n\n  EXPECT_EQ(5, foo_->Decimal(true, 'a', 0, 0, 1, 0, 0, 5, NULL, \"hi\"));\n}\n\n// Tests mocking a function that takes a non-const reference.\nTEST_F(FunctionMockerTest, MocksFunctionWithNonConstReferenceArgument) {\n  int a = 0;\n  EXPECT_CALL(mock_foo_, TakesNonConstReference(Ref(a)))\n      .WillOnce(Return(true));\n\n  EXPECT_TRUE(foo_->TakesNonConstReference(a));\n}\n\n// Tests mocking a function that takes a const reference.\nTEST_F(FunctionMockerTest, MocksFunctionWithConstReferenceArgument) {\n  int a = 0;\n  EXPECT_CALL(mock_foo_, TakesConstReference(Ref(a)))\n      .WillOnce(Return(\"Hello\"));\n\n  EXPECT_EQ(\"Hello\", foo_->TakesConstReference(a));\n}\n\n#ifdef GMOCK_ALLOWS_CONST_PARAM_FUNCTIONS\n// Tests mocking a function that takes a const variable.\nTEST_F(FunctionMockerTest, MocksFunctionWithConstArgument) {\n  EXPECT_CALL(mock_foo_, TakesConst(Lt(10)))\n      .WillOnce(DoDefault());\n\n  EXPECT_FALSE(foo_->TakesConst(5));\n}\n#endif  // GMOCK_ALLOWS_CONST_PARAM_FUNCTIONS\n\n// Tests mocking functions overloaded on the number of arguments.\nTEST_F(FunctionMockerTest, MocksFunctionsOverloadedOnArgumentNumber) {\n  EXPECT_CALL(mock_foo_, OverloadedOnArgumentNumber())\n      .WillOnce(Return(1));\n  EXPECT_CALL(mock_foo_, OverloadedOnArgumentNumber(_))\n      .WillOnce(Return(2));\n\n  EXPECT_EQ(2, foo_->OverloadedOnArgumentNumber(1));\n  EXPECT_EQ(1, foo_->OverloadedOnArgumentNumber());\n}\n\n// Tests mocking functions overloaded on the types of argument.\nTEST_F(FunctionMockerTest, MocksFunctionsOverloadedOnArgumentType) {\n  EXPECT_CALL(mock_foo_, OverloadedOnArgumentType(An<int>()))\n      .WillOnce(Return(1));\n  EXPECT_CALL(mock_foo_, OverloadedOnArgumentType(TypedEq<char>('a')))\n      .WillOnce(Return('b'));\n\n  EXPECT_EQ(1, foo_->OverloadedOnArgumentType(0));\n  EXPECT_EQ('b', foo_->OverloadedOnArgumentType('a'));\n}\n\n// Tests mocking functions overloaded on the const-ness of this object.\nTEST_F(FunctionMockerTest, MocksFunctionsOverloadedOnConstnessOfThis) {\n  EXPECT_CALL(mock_foo_, OverloadedOnConstness());\n  EXPECT_CALL(Const(mock_foo_), OverloadedOnConstness())\n      .WillOnce(Return('a'));\n\n  EXPECT_EQ(0, foo_->OverloadedOnConstness());\n  EXPECT_EQ('a', Const(*foo_).OverloadedOnConstness());\n}\n\nTEST_F(FunctionMockerTest, MocksReturnTypeWithComma) {\n  const std::map<int, string> a_map;\n  EXPECT_CALL(mock_foo_, ReturnTypeWithComma())\n      .WillOnce(Return(a_map));\n  EXPECT_CALL(mock_foo_, ReturnTypeWithComma(42))\n      .WillOnce(Return(a_map));\n\n  EXPECT_EQ(a_map, mock_foo_.ReturnTypeWithComma());\n  EXPECT_EQ(a_map, mock_foo_.ReturnTypeWithComma(42));\n}\n\n#if GTEST_OS_WINDOWS\n// Tests mocking a nullary function with calltype.\nTEST_F(FunctionMockerTest, MocksNullaryFunctionWithCallType) {\n  EXPECT_CALL(mock_foo_, CTNullary())\n      .WillOnce(Return(-1))\n      .WillOnce(Return(0));\n\n  EXPECT_EQ(-1, foo_->CTNullary());\n  EXPECT_EQ(0, foo_->CTNullary());\n}\n\n// Tests mocking a unary function with calltype.\nTEST_F(FunctionMockerTest, MocksUnaryFunctionWithCallType) {\n  EXPECT_CALL(mock_foo_, CTUnary(Eq(2)))\n      .Times(2)\n      .WillOnce(Return(true))\n      .WillOnce(Return(false));\n\n  EXPECT_TRUE(foo_->CTUnary(2));\n  EXPECT_FALSE(foo_->CTUnary(2));\n}\n\n// Tests mocking a decimal function with calltype.\nTEST_F(FunctionMockerTest, MocksDecimalFunctionWithCallType) {\n  EXPECT_CALL(mock_foo_, CTDecimal(true, 'a', 0, 0, 1L, A<float>(),\n                                   Lt(100), 5U, NULL, \"hi\"))\n      .WillOnce(Return(10));\n\n  EXPECT_EQ(10, foo_->CTDecimal(true, 'a', 0, 0, 1, 0, 0, 5, NULL, \"hi\"));\n}\n\n// Tests mocking functions overloaded on the const-ness of this object.\nTEST_F(FunctionMockerTest, MocksFunctionsConstFunctionWithCallType) {\n  EXPECT_CALL(Const(mock_foo_), CTConst(_))\n      .WillOnce(Return('a'));\n\n  EXPECT_EQ('a', Const(*foo_).CTConst(0));\n}\n\nTEST_F(FunctionMockerTest, MocksReturnTypeWithCommaAndCallType) {\n  const std::map<int, string> a_map;\n  EXPECT_CALL(mock_foo_, CTReturnTypeWithComma())\n      .WillOnce(Return(a_map));\n\n  EXPECT_EQ(a_map, mock_foo_.CTReturnTypeWithComma());\n}\n\n#endif  // GTEST_OS_WINDOWS\n\nclass MockB {\n public:\n  MockB() {}\n\n  MOCK_METHOD0(DoB, void());\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockB);\n};\n\n// Tests that functions with no EXPECT_CALL() ruls can be called any\n// number of times.\nTEST(ExpectCallTest, UnmentionedFunctionCanBeCalledAnyNumberOfTimes) {\n  {\n    MockB b;\n  }\n\n  {\n    MockB b;\n    b.DoB();\n  }\n\n  {\n    MockB b;\n    b.DoB();\n    b.DoB();\n  }\n}\n\n// Tests mocking template interfaces.\n\ntemplate <typename T>\nclass StackInterface {\n public:\n  virtual ~StackInterface() {}\n\n  // Template parameter appears in function parameter.\n  virtual void Push(const T& value) = 0;\n  virtual void Pop() = 0;\n  virtual int GetSize() const = 0;\n  // Template parameter appears in function return type.\n  virtual const T& GetTop() const = 0;\n};\n\ntemplate <typename T>\nclass MockStack : public StackInterface<T> {\n public:\n  MockStack() {}\n\n  MOCK_METHOD1_T(Push, void(const T& elem));\n  MOCK_METHOD0_T(Pop, void());\n  MOCK_CONST_METHOD0_T(GetSize, int());  // NOLINT\n  MOCK_CONST_METHOD0_T(GetTop, const T&());\n\n  // Tests that the function return type can contain unprotected comma.\n  MOCK_METHOD0_T(ReturnTypeWithComma, std::map<int, int>());\n  MOCK_CONST_METHOD1_T(ReturnTypeWithComma, std::map<int, int>(int));  // NOLINT\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockStack);\n};\n\n// Tests that template mock works.\nTEST(TemplateMockTest, Works) {\n  MockStack<int> mock;\n\n  EXPECT_CALL(mock, GetSize())\n      .WillOnce(Return(0))\n      .WillOnce(Return(1))\n      .WillOnce(Return(0));\n  EXPECT_CALL(mock, Push(_));\n  int n = 5;\n  EXPECT_CALL(mock, GetTop())\n      .WillOnce(ReturnRef(n));\n  EXPECT_CALL(mock, Pop())\n      .Times(AnyNumber());\n\n  EXPECT_EQ(0, mock.GetSize());\n  mock.Push(5);\n  EXPECT_EQ(1, mock.GetSize());\n  EXPECT_EQ(5, mock.GetTop());\n  mock.Pop();\n  EXPECT_EQ(0, mock.GetSize());\n}\n\nTEST(TemplateMockTest, MethodWithCommaInReturnTypeWorks) {\n  MockStack<int> mock;\n\n  const std::map<int, int> a_map;\n  EXPECT_CALL(mock, ReturnTypeWithComma())\n      .WillOnce(Return(a_map));\n  EXPECT_CALL(mock, ReturnTypeWithComma(1))\n      .WillOnce(Return(a_map));\n\n  EXPECT_EQ(a_map, mock.ReturnTypeWithComma());\n  EXPECT_EQ(a_map, mock.ReturnTypeWithComma(1));\n}\n\n#if GTEST_OS_WINDOWS\n// Tests mocking template interfaces with calltype.\n\ntemplate <typename T>\nclass StackInterfaceWithCallType {\n public:\n  virtual ~StackInterfaceWithCallType() {}\n\n  // Template parameter appears in function parameter.\n  STDMETHOD_(void, Push)(const T& value) = 0;\n  STDMETHOD_(void, Pop)() = 0;\n  STDMETHOD_(int, GetSize)() const = 0;\n  // Template parameter appears in function return type.\n  STDMETHOD_(const T&, GetTop)() const = 0;\n};\n\ntemplate <typename T>\nclass MockStackWithCallType : public StackInterfaceWithCallType<T> {\n public:\n  MockStackWithCallType() {}\n\n  MOCK_METHOD1_T_WITH_CALLTYPE(STDMETHODCALLTYPE, Push, void(const T& elem));\n  MOCK_METHOD0_T_WITH_CALLTYPE(STDMETHODCALLTYPE, Pop, void());\n  MOCK_CONST_METHOD0_T_WITH_CALLTYPE(STDMETHODCALLTYPE, GetSize, int());\n  MOCK_CONST_METHOD0_T_WITH_CALLTYPE(STDMETHODCALLTYPE, GetTop, const T&());\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockStackWithCallType);\n};\n\n// Tests that template mock with calltype works.\nTEST(TemplateMockTestWithCallType, Works) {\n  MockStackWithCallType<int> mock;\n\n  EXPECT_CALL(mock, GetSize())\n      .WillOnce(Return(0))\n      .WillOnce(Return(1))\n      .WillOnce(Return(0));\n  EXPECT_CALL(mock, Push(_));\n  int n = 5;\n  EXPECT_CALL(mock, GetTop())\n      .WillOnce(ReturnRef(n));\n  EXPECT_CALL(mock, Pop())\n      .Times(AnyNumber());\n\n  EXPECT_EQ(0, mock.GetSize());\n  mock.Push(5);\n  EXPECT_EQ(1, mock.GetSize());\n  EXPECT_EQ(5, mock.GetTop());\n  mock.Pop();\n  EXPECT_EQ(0, mock.GetSize());\n}\n#endif  // GTEST_OS_WINDOWS\n\n#define MY_MOCK_METHODS1_ \\\n    MOCK_METHOD0(Overloaded, void()); \\\n    MOCK_CONST_METHOD1(Overloaded, int(int n)); \\\n    MOCK_METHOD2(Overloaded, bool(bool f, int n))\n\nclass MockOverloadedOnArgNumber {\n public:\n  MockOverloadedOnArgNumber() {}\n\n  MY_MOCK_METHODS1_;\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockOverloadedOnArgNumber);\n};\n\nTEST(OverloadedMockMethodTest, CanOverloadOnArgNumberInMacroBody) {\n  MockOverloadedOnArgNumber mock;\n  EXPECT_CALL(mock, Overloaded());\n  EXPECT_CALL(mock, Overloaded(1)).WillOnce(Return(2));\n  EXPECT_CALL(mock, Overloaded(true, 1)).WillOnce(Return(true));\n\n  mock.Overloaded();\n  EXPECT_EQ(2, mock.Overloaded(1));\n  EXPECT_TRUE(mock.Overloaded(true, 1));\n}\n\n#define MY_MOCK_METHODS2_ \\\n    MOCK_CONST_METHOD1(Overloaded, int(int n)); \\\n    MOCK_METHOD1(Overloaded, int(int n));\n\nclass MockOverloadedOnConstness {\n public:\n  MockOverloadedOnConstness() {}\n\n  MY_MOCK_METHODS2_;\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockOverloadedOnConstness);\n};\n\nTEST(OverloadedMockMethodTest, CanOverloadOnConstnessInMacroBody) {\n  MockOverloadedOnConstness mock;\n  const MockOverloadedOnConstness* const_mock = &mock;\n  EXPECT_CALL(mock, Overloaded(1)).WillOnce(Return(2));\n  EXPECT_CALL(*const_mock, Overloaded(1)).WillOnce(Return(3));\n\n  EXPECT_EQ(2, mock.Overloaded(1));\n  EXPECT_EQ(3, const_mock->Overloaded(1));\n}\n\nTEST(MockFunctionTest, WorksForVoidNullary) {\n  MockFunction<void()> foo;\n  EXPECT_CALL(foo, Call());\n  foo.Call();\n}\n\nTEST(MockFunctionTest, WorksForNonVoidNullary) {\n  MockFunction<int()> foo;\n  EXPECT_CALL(foo, Call())\n      .WillOnce(Return(1))\n      .WillOnce(Return(2));\n  EXPECT_EQ(1, foo.Call());\n  EXPECT_EQ(2, foo.Call());\n}\n\nTEST(MockFunctionTest, WorksForVoidUnary) {\n  MockFunction<void(int)> foo;\n  EXPECT_CALL(foo, Call(1));\n  foo.Call(1);\n}\n\nTEST(MockFunctionTest, WorksForNonVoidBinary) {\n  MockFunction<int(bool, int)> foo;\n  EXPECT_CALL(foo, Call(false, 42))\n      .WillOnce(Return(1))\n      .WillOnce(Return(2));\n  EXPECT_CALL(foo, Call(true, Ge(100)))\n      .WillOnce(Return(3));\n  EXPECT_EQ(1, foo.Call(false, 42));\n  EXPECT_EQ(2, foo.Call(false, 42));\n  EXPECT_EQ(3, foo.Call(true, 120));\n}\n\nTEST(MockFunctionTest, WorksFor10Arguments) {\n  MockFunction<int(bool a0, char a1, int a2, int a3, int a4,\n                   int a5, int a6, char a7, int a8, bool a9)> foo;\n  EXPECT_CALL(foo, Call(_, 'a', _, _, _, _, _, _, _, _))\n      .WillOnce(Return(1))\n      .WillOnce(Return(2));\n  EXPECT_EQ(1, foo.Call(false, 'a', 0, 0, 0, 0, 0, 'b', 0, true));\n  EXPECT_EQ(2, foo.Call(true, 'a', 0, 0, 0, 0, 0, 'b', 1, false));\n}\n\n}  // namespace gmock_generated_function_mockers_test\n}  // namespace testing\n"
  },
  {
    "path": "ext/gmock/test/gmock-generated-internal-utils_test.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file tests the internal utilities.\n\n#include \"gmock/internal/gmock-generated-internal-utils.h\"\n#include \"gmock/internal/gmock-internal-utils.h\"\n#include \"gtest/gtest.h\"\n\nnamespace {\n\nusing ::std::tr1::tuple;\nusing ::testing::Matcher;\nusing ::testing::internal::CompileAssertTypesEqual;\nusing ::testing::internal::MatcherTuple;\nusing ::testing::internal::Function;\nusing ::testing::internal::IgnoredValue;\n\n// Tests the MatcherTuple template struct.\n\nTEST(MatcherTupleTest, ForSize0) {\n  CompileAssertTypesEqual<tuple<>, MatcherTuple<tuple<> >::type>();\n}\n\nTEST(MatcherTupleTest, ForSize1) {\n  CompileAssertTypesEqual<tuple<Matcher<int> >,\n                          MatcherTuple<tuple<int> >::type>();\n}\n\nTEST(MatcherTupleTest, ForSize2) {\n  CompileAssertTypesEqual<tuple<Matcher<int>, Matcher<char> >,\n                          MatcherTuple<tuple<int, char> >::type>();\n}\n\nTEST(MatcherTupleTest, ForSize5) {\n  CompileAssertTypesEqual<tuple<Matcher<int>, Matcher<char>, Matcher<bool>,\n                                Matcher<double>, Matcher<char*> >,\n                          MatcherTuple<tuple<int, char, bool, double, char*>\n                                      >::type>();\n}\n\n// Tests the Function template struct.\n\nTEST(FunctionTest, Nullary) {\n  typedef Function<int()> F;  // NOLINT\n  CompileAssertTypesEqual<int, F::Result>();\n  CompileAssertTypesEqual<tuple<>, F::ArgumentTuple>();\n  CompileAssertTypesEqual<tuple<>, F::ArgumentMatcherTuple>();\n  CompileAssertTypesEqual<void(), F::MakeResultVoid>();\n  CompileAssertTypesEqual<IgnoredValue(), F::MakeResultIgnoredValue>();\n}\n\nTEST(FunctionTest, Unary) {\n  typedef Function<int(bool)> F;  // NOLINT\n  CompileAssertTypesEqual<int, F::Result>();\n  CompileAssertTypesEqual<bool, F::Argument1>();\n  CompileAssertTypesEqual<tuple<bool>, F::ArgumentTuple>();\n  CompileAssertTypesEqual<tuple<Matcher<bool> >, F::ArgumentMatcherTuple>();\n  CompileAssertTypesEqual<void(bool), F::MakeResultVoid>();  // NOLINT\n  CompileAssertTypesEqual<IgnoredValue(bool),  // NOLINT\n      F::MakeResultIgnoredValue>();\n}\n\nTEST(FunctionTest, Binary) {\n  typedef Function<int(bool, const long&)> F;  // NOLINT\n  CompileAssertTypesEqual<int, F::Result>();\n  CompileAssertTypesEqual<bool, F::Argument1>();\n  CompileAssertTypesEqual<const long&, F::Argument2>();  // NOLINT\n  CompileAssertTypesEqual<tuple<bool, const long&>, F::ArgumentTuple>();  // NOLINT\n  CompileAssertTypesEqual<tuple<Matcher<bool>, Matcher<const long&> >,  // NOLINT\n                          F::ArgumentMatcherTuple>();\n  CompileAssertTypesEqual<void(bool, const long&), F::MakeResultVoid>();  // NOLINT\n  CompileAssertTypesEqual<IgnoredValue(bool, const long&),  // NOLINT\n      F::MakeResultIgnoredValue>();\n}\n\nTEST(FunctionTest, LongArgumentList) {\n  typedef Function<char(bool, int, char*, int&, const long&)> F;  // NOLINT\n  CompileAssertTypesEqual<char, F::Result>();\n  CompileAssertTypesEqual<bool, F::Argument1>();\n  CompileAssertTypesEqual<int, F::Argument2>();\n  CompileAssertTypesEqual<char*, F::Argument3>();\n  CompileAssertTypesEqual<int&, F::Argument4>();\n  CompileAssertTypesEqual<const long&, F::Argument5>();  // NOLINT\n  CompileAssertTypesEqual<tuple<bool, int, char*, int&, const long&>,  // NOLINT\n                          F::ArgumentTuple>();\n  CompileAssertTypesEqual<tuple<Matcher<bool>, Matcher<int>, Matcher<char*>,\n                                Matcher<int&>, Matcher<const long&> >,  // NOLINT\n                          F::ArgumentMatcherTuple>();\n  CompileAssertTypesEqual<void(bool, int, char*, int&, const long&),  // NOLINT\n                          F::MakeResultVoid>();\n  CompileAssertTypesEqual<\n      IgnoredValue(bool, int, char*, int&, const long&),  // NOLINT\n      F::MakeResultIgnoredValue>();\n}\n\n}  // Unnamed namespace\n"
  },
  {
    "path": "ext/gmock/test/gmock-generated-matchers_test.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file tests the built-in matchers generated by a script.\n\n#include \"gmock/gmock-generated-matchers.h\"\n\n#include <list>\n#include <map>\n#include <set>\n#include <sstream>\n#include <string>\n#include <utility>\n#include <vector>\n\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n#include \"gtest/gtest-spi.h\"\n\nnamespace {\n\nusing std::list;\nusing std::map;\nusing std::pair;\nusing std::set;\nusing std::stringstream;\nusing std::vector;\nusing std::tr1::get;\nusing std::tr1::make_tuple;\nusing std::tr1::tuple;\nusing testing::_;\nusing testing::Args;\nusing testing::Contains;\nusing testing::ElementsAre;\nusing testing::ElementsAreArray;\nusing testing::Eq;\nusing testing::Ge;\nusing testing::Gt;\nusing testing::Le;\nusing testing::Lt;\nusing testing::MakeMatcher;\nusing testing::Matcher;\nusing testing::MatcherInterface;\nusing testing::MatchResultListener;\nusing testing::Ne;\nusing testing::Not;\nusing testing::Pointee;\nusing testing::PrintToString;\nusing testing::Ref;\nusing testing::StaticAssertTypeEq;\nusing testing::StrEq;\nusing testing::Value;\nusing testing::internal::ElementsAreArrayMatcher;\nusing testing::internal::string;\n\n// Evaluates to the number of elements in 'array'.\n#define GMOCK_ARRAY_SIZE_(a) (sizeof(a) / sizeof(a[0]))\n\n// Returns the description of the given matcher.\ntemplate <typename T>\nstring Describe(const Matcher<T>& m) {\n  stringstream ss;\n  m.DescribeTo(&ss);\n  return ss.str();\n}\n\n// Returns the description of the negation of the given matcher.\ntemplate <typename T>\nstring DescribeNegation(const Matcher<T>& m) {\n  stringstream ss;\n  m.DescribeNegationTo(&ss);\n  return ss.str();\n}\n\n// Returns the reason why x matches, or doesn't match, m.\ntemplate <typename MatcherType, typename Value>\nstring Explain(const MatcherType& m, const Value& x) {\n  stringstream ss;\n  m.ExplainMatchResultTo(x, &ss);\n  return ss.str();\n}\n\n// Tests Args<k0, ..., kn>(m).\n\nTEST(ArgsTest, AcceptsZeroTemplateArg) {\n  const tuple<int, bool> t(5, true);\n  EXPECT_THAT(t, Args<>(Eq(tuple<>())));\n  EXPECT_THAT(t, Not(Args<>(Ne(tuple<>()))));\n}\n\nTEST(ArgsTest, AcceptsOneTemplateArg) {\n  const tuple<int, bool> t(5, true);\n  EXPECT_THAT(t, Args<0>(Eq(make_tuple(5))));\n  EXPECT_THAT(t, Args<1>(Eq(make_tuple(true))));\n  EXPECT_THAT(t, Not(Args<1>(Eq(make_tuple(false)))));\n}\n\nTEST(ArgsTest, AcceptsTwoTemplateArgs) {\n  const tuple<short, int, long> t(4, 5, 6L);  // NOLINT\n\n  EXPECT_THAT(t, (Args<0, 1>(Lt())));\n  EXPECT_THAT(t, (Args<1, 2>(Lt())));\n  EXPECT_THAT(t, Not(Args<0, 2>(Gt())));\n}\n\nTEST(ArgsTest, AcceptsRepeatedTemplateArgs) {\n  const tuple<short, int, long> t(4, 5, 6L);  // NOLINT\n  EXPECT_THAT(t, (Args<0, 0>(Eq())));\n  EXPECT_THAT(t, Not(Args<1, 1>(Ne())));\n}\n\nTEST(ArgsTest, AcceptsDecreasingTemplateArgs) {\n  const tuple<short, int, long> t(4, 5, 6L);  // NOLINT\n  EXPECT_THAT(t, (Args<2, 0>(Gt())));\n  EXPECT_THAT(t, Not(Args<2, 1>(Lt())));\n}\n\n// The MATCHER*() macros trigger warning C4100 (unreferenced formal\n// parameter) in MSVC with -W4.  Unfortunately they cannot be fixed in\n// the macro definition, as the warnings are generated when the macro\n// is expanded and macro expansion cannot contain #pragma.  Therefore\n// we suppress them here.\n#ifdef _MSC_VER\n# pragma warning(push)\n# pragma warning(disable:4100)\n#endif\n\nMATCHER(SumIsZero, \"\") {\n  return get<0>(arg) + get<1>(arg) + get<2>(arg) == 0;\n}\n\nTEST(ArgsTest, AcceptsMoreTemplateArgsThanArityOfOriginalTuple) {\n  EXPECT_THAT(make_tuple(-1, 2), (Args<0, 0, 1>(SumIsZero())));\n  EXPECT_THAT(make_tuple(1, 2), Not(Args<0, 0, 1>(SumIsZero())));\n}\n\nTEST(ArgsTest, CanBeNested) {\n  const tuple<short, int, long, int> t(4, 5, 6L, 6);  // NOLINT\n  EXPECT_THAT(t, (Args<1, 2, 3>(Args<1, 2>(Eq()))));\n  EXPECT_THAT(t, (Args<0, 1, 3>(Args<0, 2>(Lt()))));\n}\n\nTEST(ArgsTest, CanMatchTupleByValue) {\n  typedef tuple<char, int, int> Tuple3;\n  const Matcher<Tuple3> m = Args<1, 2>(Lt());\n  EXPECT_TRUE(m.Matches(Tuple3('a', 1, 2)));\n  EXPECT_FALSE(m.Matches(Tuple3('b', 2, 2)));\n}\n\nTEST(ArgsTest, CanMatchTupleByReference) {\n  typedef tuple<char, char, int> Tuple3;\n  const Matcher<const Tuple3&> m = Args<0, 1>(Lt());\n  EXPECT_TRUE(m.Matches(Tuple3('a', 'b', 2)));\n  EXPECT_FALSE(m.Matches(Tuple3('b', 'b', 2)));\n}\n\n// Validates that arg is printed as str.\nMATCHER_P(PrintsAs, str, \"\") {\n  return testing::PrintToString(arg) == str;\n}\n\nTEST(ArgsTest, AcceptsTenTemplateArgs) {\n  EXPECT_THAT(make_tuple(0, 1L, 2, 3L, 4, 5, 6, 7, 8, 9),\n              (Args<9, 8, 7, 6, 5, 4, 3, 2, 1, 0>(\n                  PrintsAs(\"(9, 8, 7, 6, 5, 4, 3, 2, 1, 0)\"))));\n  EXPECT_THAT(make_tuple(0, 1L, 2, 3L, 4, 5, 6, 7, 8, 9),\n              Not(Args<9, 8, 7, 6, 5, 4, 3, 2, 1, 0>(\n                      PrintsAs(\"(0, 8, 7, 6, 5, 4, 3, 2, 1, 0)\"))));\n}\n\nTEST(ArgsTest, DescirbesSelfCorrectly) {\n  const Matcher<tuple<int, bool, char> > m = Args<2, 0>(Lt());\n  EXPECT_EQ(\"are a tuple whose fields (#2, #0) are a pair where \"\n            \"the first < the second\",\n            Describe(m));\n}\n\nTEST(ArgsTest, DescirbesNestedArgsCorrectly) {\n  const Matcher<const tuple<int, bool, char, int>&> m =\n      Args<0, 2, 3>(Args<2, 0>(Lt()));\n  EXPECT_EQ(\"are a tuple whose fields (#0, #2, #3) are a tuple \"\n            \"whose fields (#2, #0) are a pair where the first < the second\",\n            Describe(m));\n}\n\nTEST(ArgsTest, DescribesNegationCorrectly) {\n  const Matcher<tuple<int, char> > m = Args<1, 0>(Gt());\n  EXPECT_EQ(\"are a tuple whose fields (#1, #0) aren't a pair \"\n            \"where the first > the second\",\n            DescribeNegation(m));\n}\n\nTEST(ArgsTest, ExplainsMatchResultWithoutInnerExplanation) {\n  const Matcher<tuple<bool, int, int> > m = Args<1, 2>(Eq());\n  EXPECT_EQ(\"whose fields (#1, #2) are (42, 42)\",\n            Explain(m, make_tuple(false, 42, 42)));\n  EXPECT_EQ(\"whose fields (#1, #2) are (42, 43)\",\n            Explain(m, make_tuple(false, 42, 43)));\n}\n\n// For testing Args<>'s explanation.\nclass LessThanMatcher : public MatcherInterface<tuple<char, int> > {\n public:\n  virtual void DescribeTo(::std::ostream* os) const {}\n\n  virtual bool MatchAndExplain(tuple<char, int> value,\n                               MatchResultListener* listener) const {\n    const int diff = get<0>(value) - get<1>(value);\n    if (diff > 0) {\n      *listener << \"where the first value is \" << diff\n                << \" more than the second\";\n    }\n    return diff < 0;\n  }\n};\n\nMatcher<tuple<char, int> > LessThan() {\n  return MakeMatcher(new LessThanMatcher);\n}\n\nTEST(ArgsTest, ExplainsMatchResultWithInnerExplanation) {\n  const Matcher<tuple<char, int, int> > m = Args<0, 2>(LessThan());\n  EXPECT_EQ(\"whose fields (#0, #2) are ('a' (97, 0x61), 42), \"\n            \"where the first value is 55 more than the second\",\n            Explain(m, make_tuple('a', 42, 42)));\n  EXPECT_EQ(\"whose fields (#0, #2) are ('\\\\0', 43)\",\n            Explain(m, make_tuple('\\0', 42, 43)));\n}\n\n// For testing ExplainMatchResultTo().\nclass GreaterThanMatcher : public MatcherInterface<int> {\n public:\n  explicit GreaterThanMatcher(int rhs) : rhs_(rhs) {}\n\n  virtual void DescribeTo(::std::ostream* os) const {\n    *os << \"is greater than \" << rhs_;\n  }\n\n  virtual bool MatchAndExplain(int lhs,\n                               MatchResultListener* listener) const {\n    const int diff = lhs - rhs_;\n    if (diff > 0) {\n      *listener << \"which is \" << diff << \" more than \" << rhs_;\n    } else if (diff == 0) {\n      *listener << \"which is the same as \" << rhs_;\n    } else {\n      *listener << \"which is \" << -diff << \" less than \" << rhs_;\n    }\n\n    return lhs > rhs_;\n  }\n\n private:\n  int rhs_;\n};\n\nMatcher<int> GreaterThan(int n) {\n  return MakeMatcher(new GreaterThanMatcher(n));\n}\n\n// Tests for ElementsAre().\n\nTEST(ElementsAreTest, CanDescribeExpectingNoElement) {\n  Matcher<const vector<int>&> m = ElementsAre();\n  EXPECT_EQ(\"is empty\", Describe(m));\n}\n\nTEST(ElementsAreTest, CanDescribeExpectingOneElement) {\n  Matcher<vector<int> > m = ElementsAre(Gt(5));\n  EXPECT_EQ(\"has 1 element that is > 5\", Describe(m));\n}\n\nTEST(ElementsAreTest, CanDescribeExpectingManyElements) {\n  Matcher<list<string> > m = ElementsAre(StrEq(\"one\"), \"two\");\n  EXPECT_EQ(\"has 2 elements where\\n\"\n            \"element #0 is equal to \\\"one\\\",\\n\"\n            \"element #1 is equal to \\\"two\\\"\", Describe(m));\n}\n\nTEST(ElementsAreTest, CanDescribeNegationOfExpectingNoElement) {\n  Matcher<vector<int> > m = ElementsAre();\n  EXPECT_EQ(\"isn't empty\", DescribeNegation(m));\n}\n\nTEST(ElementsAreTest, CanDescribeNegationOfExpectingOneElment) {\n  Matcher<const list<int>& > m = ElementsAre(Gt(5));\n  EXPECT_EQ(\"doesn't have 1 element, or\\n\"\n            \"element #0 isn't > 5\", DescribeNegation(m));\n}\n\nTEST(ElementsAreTest, CanDescribeNegationOfExpectingManyElements) {\n  Matcher<const list<string>& > m = ElementsAre(\"one\", \"two\");\n  EXPECT_EQ(\"doesn't have 2 elements, or\\n\"\n            \"element #0 isn't equal to \\\"one\\\", or\\n\"\n            \"element #1 isn't equal to \\\"two\\\"\", DescribeNegation(m));\n}\n\nTEST(ElementsAreTest, DoesNotExplainTrivialMatch) {\n  Matcher<const list<int>& > m = ElementsAre(1, Ne(2));\n\n  list<int> test_list;\n  test_list.push_back(1);\n  test_list.push_back(3);\n  EXPECT_EQ(\"\", Explain(m, test_list));  // No need to explain anything.\n}\n\nTEST(ElementsAreTest, ExplainsNonTrivialMatch) {\n  Matcher<const vector<int>& > m =\n      ElementsAre(GreaterThan(1), 0, GreaterThan(2));\n\n  const int a[] = { 10, 0, 100 };\n  vector<int> test_vector(a, a + GMOCK_ARRAY_SIZE_(a));\n  EXPECT_EQ(\"whose element #0 matches, which is 9 more than 1,\\n\"\n            \"and whose element #2 matches, which is 98 more than 2\",\n            Explain(m, test_vector));\n}\n\nTEST(ElementsAreTest, CanExplainMismatchWrongSize) {\n  Matcher<const list<int>& > m = ElementsAre(1, 3);\n\n  list<int> test_list;\n  // No need to explain when the container is empty.\n  EXPECT_EQ(\"\", Explain(m, test_list));\n\n  test_list.push_back(1);\n  EXPECT_EQ(\"which has 1 element\", Explain(m, test_list));\n}\n\nTEST(ElementsAreTest, CanExplainMismatchRightSize) {\n  Matcher<const vector<int>& > m = ElementsAre(1, GreaterThan(5));\n\n  vector<int> v;\n  v.push_back(2);\n  v.push_back(1);\n  EXPECT_EQ(\"whose element #0 doesn't match\", Explain(m, v));\n\n  v[0] = 1;\n  EXPECT_EQ(\"whose element #1 doesn't match, which is 4 less than 5\",\n            Explain(m, v));\n}\n\nTEST(ElementsAreTest, MatchesOneElementVector) {\n  vector<string> test_vector;\n  test_vector.push_back(\"test string\");\n\n  EXPECT_THAT(test_vector, ElementsAre(StrEq(\"test string\")));\n}\n\nTEST(ElementsAreTest, MatchesOneElementList) {\n  list<string> test_list;\n  test_list.push_back(\"test string\");\n\n  EXPECT_THAT(test_list, ElementsAre(\"test string\"));\n}\n\nTEST(ElementsAreTest, MatchesThreeElementVector) {\n  vector<string> test_vector;\n  test_vector.push_back(\"one\");\n  test_vector.push_back(\"two\");\n  test_vector.push_back(\"three\");\n\n  EXPECT_THAT(test_vector, ElementsAre(\"one\", StrEq(\"two\"), _));\n}\n\nTEST(ElementsAreTest, MatchesOneElementEqMatcher) {\n  vector<int> test_vector;\n  test_vector.push_back(4);\n\n  EXPECT_THAT(test_vector, ElementsAre(Eq(4)));\n}\n\nTEST(ElementsAreTest, MatchesOneElementAnyMatcher) {\n  vector<int> test_vector;\n  test_vector.push_back(4);\n\n  EXPECT_THAT(test_vector, ElementsAre(_));\n}\n\nTEST(ElementsAreTest, MatchesOneElementValue) {\n  vector<int> test_vector;\n  test_vector.push_back(4);\n\n  EXPECT_THAT(test_vector, ElementsAre(4));\n}\n\nTEST(ElementsAreTest, MatchesThreeElementsMixedMatchers) {\n  vector<int> test_vector;\n  test_vector.push_back(1);\n  test_vector.push_back(2);\n  test_vector.push_back(3);\n\n  EXPECT_THAT(test_vector, ElementsAre(1, Eq(2), _));\n}\n\nTEST(ElementsAreTest, MatchesTenElementVector) {\n  const int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };\n  vector<int> test_vector(a, a + GMOCK_ARRAY_SIZE_(a));\n\n  EXPECT_THAT(test_vector,\n              // The element list can contain values and/or matchers\n              // of different types.\n              ElementsAre(0, Ge(0), _, 3, 4, Ne(2), Eq(6), 7, 8, _));\n}\n\nTEST(ElementsAreTest, DoesNotMatchWrongSize) {\n  vector<string> test_vector;\n  test_vector.push_back(\"test string\");\n  test_vector.push_back(\"test string\");\n\n  Matcher<vector<string> > m = ElementsAre(StrEq(\"test string\"));\n  EXPECT_FALSE(m.Matches(test_vector));\n}\n\nTEST(ElementsAreTest, DoesNotMatchWrongValue) {\n  vector<string> test_vector;\n  test_vector.push_back(\"other string\");\n\n  Matcher<vector<string> > m = ElementsAre(StrEq(\"test string\"));\n  EXPECT_FALSE(m.Matches(test_vector));\n}\n\nTEST(ElementsAreTest, DoesNotMatchWrongOrder) {\n  vector<string> test_vector;\n  test_vector.push_back(\"one\");\n  test_vector.push_back(\"three\");\n  test_vector.push_back(\"two\");\n\n  Matcher<vector<string> > m = ElementsAre(\n    StrEq(\"one\"), StrEq(\"two\"), StrEq(\"three\"));\n  EXPECT_FALSE(m.Matches(test_vector));\n}\n\nTEST(ElementsAreTest, WorksForNestedContainer) {\n  const char* strings[] = {\n    \"Hi\",\n    \"world\"\n  };\n\n  vector<list<char> > nested;\n  for (size_t i = 0; i < GMOCK_ARRAY_SIZE_(strings); i++) {\n    nested.push_back(list<char>(strings[i], strings[i] + strlen(strings[i])));\n  }\n\n  EXPECT_THAT(nested, ElementsAre(ElementsAre('H', Ne('e')),\n                                  ElementsAre('w', 'o', _, _, 'd')));\n  EXPECT_THAT(nested, Not(ElementsAre(ElementsAre('H', 'e'),\n                                      ElementsAre('w', 'o', _, _, 'd'))));\n}\n\nTEST(ElementsAreTest, WorksWithByRefElementMatchers) {\n  int a[] = { 0, 1, 2 };\n  vector<int> v(a, a + GMOCK_ARRAY_SIZE_(a));\n\n  EXPECT_THAT(v, ElementsAre(Ref(v[0]), Ref(v[1]), Ref(v[2])));\n  EXPECT_THAT(v, Not(ElementsAre(Ref(v[0]), Ref(v[1]), Ref(a[2]))));\n}\n\nTEST(ElementsAreTest, WorksWithContainerPointerUsingPointee) {\n  int a[] = { 0, 1, 2 };\n  vector<int> v(a, a + GMOCK_ARRAY_SIZE_(a));\n\n  EXPECT_THAT(&v, Pointee(ElementsAre(0, 1, _)));\n  EXPECT_THAT(&v, Not(Pointee(ElementsAre(0, _, 3))));\n}\n\nTEST(ElementsAreTest, WorksWithNativeArrayPassedByReference) {\n  int array[] = { 0, 1, 2 };\n  EXPECT_THAT(array, ElementsAre(0, 1, _));\n  EXPECT_THAT(array, Not(ElementsAre(1, _, _)));\n  EXPECT_THAT(array, Not(ElementsAre(0, _)));\n}\n\nclass NativeArrayPassedAsPointerAndSize {\n public:\n  NativeArrayPassedAsPointerAndSize() {}\n\n  MOCK_METHOD2(Helper, void(int* array, int size));\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(NativeArrayPassedAsPointerAndSize);\n};\n\nTEST(ElementsAreTest, WorksWithNativeArrayPassedAsPointerAndSize) {\n  int array[] = { 0, 1 };\n  ::std::tr1::tuple<int*, size_t> array_as_tuple(array, 2);\n  EXPECT_THAT(array_as_tuple, ElementsAre(0, 1));\n  EXPECT_THAT(array_as_tuple, Not(ElementsAre(0)));\n\n  NativeArrayPassedAsPointerAndSize helper;\n  EXPECT_CALL(helper, Helper(_, _))\n      .With(ElementsAre(0, 1));\n  helper.Helper(array, 2);\n}\n\nTEST(ElementsAreTest, WorksWithTwoDimensionalNativeArray) {\n  const char a2[][3] = { \"hi\", \"lo\" };\n  EXPECT_THAT(a2, ElementsAre(ElementsAre('h', 'i', '\\0'),\n                              ElementsAre('l', 'o', '\\0')));\n  EXPECT_THAT(a2, ElementsAre(StrEq(\"hi\"), StrEq(\"lo\")));\n  EXPECT_THAT(a2, ElementsAre(Not(ElementsAre('h', 'o', '\\0')),\n                              ElementsAre('l', 'o', '\\0')));\n}\n\nTEST(ElementsAreTest, AcceptsStringLiteral) {\n  string array[] = { \"hi\", \"one\", \"two\" };\n  EXPECT_THAT(array, ElementsAre(\"hi\", \"one\", \"two\"));\n  EXPECT_THAT(array, Not(ElementsAre(\"hi\", \"one\", \"too\")));\n}\n\n#ifndef _MSC_VER\n\n// The following test passes a value of type const char[] to a\n// function template that expects const T&.  Some versions of MSVC\n// generates a compiler error C2665 for that.  We believe it's a bug\n// in MSVC.  Therefore this test is #if-ed out for MSVC.\n\n// Declared here with the size unknown.  Defined AFTER the following test.\nextern const char kHi[];\n\nTEST(ElementsAreTest, AcceptsArrayWithUnknownSize) {\n  // The size of kHi is not known in this test, but ElementsAre() should\n  // still accept it.\n\n  string array1[] = { \"hi\" };\n  EXPECT_THAT(array1, ElementsAre(kHi));\n\n  string array2[] = { \"ho\" };\n  EXPECT_THAT(array2, Not(ElementsAre(kHi)));\n}\n\nconst char kHi[] = \"hi\";\n\n#endif  // _MSC_VER\n\nTEST(ElementsAreTest, MakesCopyOfArguments) {\n  int x = 1;\n  int y = 2;\n  // This should make a copy of x and y.\n  ::testing::internal::ElementsAreMatcher<std::tr1::tuple<int, int> >\n          polymorphic_matcher = ElementsAre(x, y);\n  // Changing x and y now shouldn't affect the meaning of the above matcher.\n  x = y = 0;\n  const int array1[] = { 1, 2 };\n  EXPECT_THAT(array1, polymorphic_matcher);\n  const int array2[] = { 0, 0 };\n  EXPECT_THAT(array2, Not(polymorphic_matcher));\n}\n\n\n// Tests for ElementsAreArray().  Since ElementsAreArray() shares most\n// of the implementation with ElementsAre(), we don't test it as\n// thoroughly here.\n\nTEST(ElementsAreArrayTest, CanBeCreatedWithValueArray) {\n  const int a[] = { 1, 2, 3 };\n\n  vector<int> test_vector(a, a + GMOCK_ARRAY_SIZE_(a));\n  EXPECT_THAT(test_vector, ElementsAreArray(a));\n\n  test_vector[2] = 0;\n  EXPECT_THAT(test_vector, Not(ElementsAreArray(a)));\n}\n\nTEST(ElementsAreArrayTest, CanBeCreatedWithArraySize) {\n  const char* a[] = { \"one\", \"two\", \"three\" };\n\n  vector<string> test_vector(a, a + GMOCK_ARRAY_SIZE_(a));\n  EXPECT_THAT(test_vector, ElementsAreArray(a, GMOCK_ARRAY_SIZE_(a)));\n\n  const char** p = a;\n  test_vector[0] = \"1\";\n  EXPECT_THAT(test_vector, Not(ElementsAreArray(p, GMOCK_ARRAY_SIZE_(a))));\n}\n\nTEST(ElementsAreArrayTest, CanBeCreatedWithoutArraySize) {\n  const char* a[] = { \"one\", \"two\", \"three\" };\n\n  vector<string> test_vector(a, a + GMOCK_ARRAY_SIZE_(a));\n  EXPECT_THAT(test_vector, ElementsAreArray(a));\n\n  test_vector[0] = \"1\";\n  EXPECT_THAT(test_vector, Not(ElementsAreArray(a)));\n}\n\nTEST(ElementsAreArrayTest, CanBeCreatedWithMatcherArray) {\n  const Matcher<string> kMatcherArray[] =\n    { StrEq(\"one\"), StrEq(\"two\"), StrEq(\"three\") };\n\n  vector<string> test_vector;\n  test_vector.push_back(\"one\");\n  test_vector.push_back(\"two\");\n  test_vector.push_back(\"three\");\n  EXPECT_THAT(test_vector, ElementsAreArray(kMatcherArray));\n\n  test_vector.push_back(\"three\");\n  EXPECT_THAT(test_vector, Not(ElementsAreArray(kMatcherArray)));\n}\n\nTEST(ElementsAreArrayTest, CanBeCreatedWithVector) {\n  const int a[] = { 1, 2, 3 };\n  vector<int> test_vector(a, a + GMOCK_ARRAY_SIZE_(a));\n  const vector<int> expected(a, a + GMOCK_ARRAY_SIZE_(a));\n  EXPECT_THAT(test_vector, ElementsAreArray(expected));\n  test_vector.push_back(4);\n  EXPECT_THAT(test_vector, Not(ElementsAreArray(expected)));\n}\n\n#if GTEST_LANG_CXX11\n\nTEST(ElementsAreArrayTest, TakesInitializerList) {\n  const int a[5] = { 1, 2, 3, 4, 5 };\n  EXPECT_THAT(a, ElementsAreArray({ 1, 2, 3, 4, 5 }));\n  EXPECT_THAT(a, Not(ElementsAreArray({ 1, 2, 3, 5, 4 })));\n  EXPECT_THAT(a, Not(ElementsAreArray({ 1, 2, 3, 4, 6 })));\n}\n\nTEST(ElementsAreArrayTest, TakesInitializerListOfCStrings) {\n  const string a[5] = { \"a\", \"b\", \"c\", \"d\", \"e\" };\n  EXPECT_THAT(a, ElementsAreArray({ \"a\", \"b\", \"c\", \"d\", \"e\" }));\n  EXPECT_THAT(a, Not(ElementsAreArray({ \"a\", \"b\", \"c\", \"e\", \"d\" })));\n  EXPECT_THAT(a, Not(ElementsAreArray({ \"a\", \"b\", \"c\", \"d\", \"ef\" })));\n}\n\nTEST(ElementsAreArrayTest, TakesInitializerListOfSameTypedMatchers) {\n  const int a[5] = { 1, 2, 3, 4, 5 };\n  EXPECT_THAT(a, ElementsAreArray(\n      { Eq(1), Eq(2), Eq(3), Eq(4), Eq(5) }));\n  EXPECT_THAT(a, Not(ElementsAreArray(\n      { Eq(1), Eq(2), Eq(3), Eq(4), Eq(6) })));\n}\n\nTEST(ElementsAreArrayTest,\n     TakesInitializerListOfDifferentTypedMatchers) {\n  const int a[5] = { 1, 2, 3, 4, 5 };\n  // The compiler cannot infer the type of the initializer list if its\n  // elements have different types.  We must explicitly specify the\n  // unified element type in this case.\n  EXPECT_THAT(a, ElementsAreArray<Matcher<int> >(\n      { Eq(1), Ne(-2), Ge(3), Le(4), Eq(5) }));\n  EXPECT_THAT(a, Not(ElementsAreArray<Matcher<int> >(\n      { Eq(1), Ne(-2), Ge(3), Le(4), Eq(6) })));\n}\n\n#endif  // GTEST_LANG_CXX11\n\nTEST(ElementsAreArrayTest, CanBeCreatedWithMatcherVector) {\n  const int a[] = { 1, 2, 3 };\n  const Matcher<int> kMatchers[] = { Eq(1), Eq(2), Eq(3) };\n  vector<int> test_vector(a, a + GMOCK_ARRAY_SIZE_(a));\n  const vector<Matcher<int> > expected(\n      kMatchers, kMatchers + GMOCK_ARRAY_SIZE_(kMatchers));\n  EXPECT_THAT(test_vector, ElementsAreArray(expected));\n  test_vector.push_back(4);\n  EXPECT_THAT(test_vector, Not(ElementsAreArray(expected)));\n}\n\nTEST(ElementsAreArrayTest, CanBeCreatedWithIteratorRange) {\n  const int a[] = { 1, 2, 3 };\n  const vector<int> test_vector(a, a + GMOCK_ARRAY_SIZE_(a));\n  const vector<int> expected(a, a + GMOCK_ARRAY_SIZE_(a));\n  EXPECT_THAT(test_vector, ElementsAreArray(expected.begin(), expected.end()));\n  // Pointers are iterators, too.\n  EXPECT_THAT(test_vector, ElementsAreArray(a, a + GMOCK_ARRAY_SIZE_(a)));\n  // The empty range of NULL pointers should also be okay.\n  int* const null_int = NULL;\n  EXPECT_THAT(test_vector, Not(ElementsAreArray(null_int, null_int)));\n  EXPECT_THAT((vector<int>()), ElementsAreArray(null_int, null_int));\n}\n\n// Since ElementsAre() and ElementsAreArray() share much of the\n// implementation, we only do a sanity test for native arrays here.\nTEST(ElementsAreArrayTest, WorksWithNativeArray) {\n  ::std::string a[] = { \"hi\", \"ho\" };\n  ::std::string b[] = { \"hi\", \"ho\" };\n\n  EXPECT_THAT(a, ElementsAreArray(b));\n  EXPECT_THAT(a, ElementsAreArray(b, 2));\n  EXPECT_THAT(a, Not(ElementsAreArray(b, 1)));\n}\n\nTEST(ElementsAreArrayTest, SourceLifeSpan) {\n  const int a[] = { 1, 2, 3 };\n  vector<int> test_vector(a, a + GMOCK_ARRAY_SIZE_(a));\n  vector<int> expect(a, a + GMOCK_ARRAY_SIZE_(a));\n  ElementsAreArrayMatcher<int> matcher_maker =\n      ElementsAreArray(expect.begin(), expect.end());\n  EXPECT_THAT(test_vector, matcher_maker);\n  // Changing in place the values that initialized matcher_maker should not\n  // affect matcher_maker anymore. It should have made its own copy of them.\n  typedef vector<int>::iterator Iter;\n  for (Iter it = expect.begin(); it != expect.end(); ++it) { *it += 10; }\n  EXPECT_THAT(test_vector, matcher_maker);\n  test_vector.push_back(3);\n  EXPECT_THAT(test_vector, Not(matcher_maker));\n}\n\n// Tests for the MATCHER*() macro family.\n\n// Tests that a simple MATCHER() definition works.\n\nMATCHER(IsEven, \"\") { return (arg % 2) == 0; }\n\nTEST(MatcherMacroTest, Works) {\n  const Matcher<int> m = IsEven();\n  EXPECT_TRUE(m.Matches(6));\n  EXPECT_FALSE(m.Matches(7));\n\n  EXPECT_EQ(\"is even\", Describe(m));\n  EXPECT_EQ(\"not (is even)\", DescribeNegation(m));\n  EXPECT_EQ(\"\", Explain(m, 6));\n  EXPECT_EQ(\"\", Explain(m, 7));\n}\n\n// This also tests that the description string can reference 'negation'.\nMATCHER(IsEven2, negation ? \"is odd\" : \"is even\") {\n  if ((arg % 2) == 0) {\n    // Verifies that we can stream to result_listener, a listener\n    // supplied by the MATCHER macro implicitly.\n    *result_listener << \"OK\";\n    return true;\n  } else {\n    *result_listener << \"% 2 == \" << (arg % 2);\n    return false;\n  }\n}\n\n// This also tests that the description string can reference matcher\n// parameters.\nMATCHER_P2(EqSumOf, x, y,\n           string(negation ? \"doesn't equal\" : \"equals\") + \" the sum of \" +\n           PrintToString(x) + \" and \" + PrintToString(y)) {\n  if (arg == (x + y)) {\n    *result_listener << \"OK\";\n    return true;\n  } else {\n    // Verifies that we can stream to the underlying stream of\n    // result_listener.\n    if (result_listener->stream() != NULL) {\n      *result_listener->stream() << \"diff == \" << (x + y - arg);\n    }\n    return false;\n  }\n}\n\n// Tests that the matcher description can reference 'negation' and the\n// matcher parameters.\nTEST(MatcherMacroTest, DescriptionCanReferenceNegationAndParameters) {\n  const Matcher<int> m1 = IsEven2();\n  EXPECT_EQ(\"is even\", Describe(m1));\n  EXPECT_EQ(\"is odd\", DescribeNegation(m1));\n\n  const Matcher<int> m2 = EqSumOf(5, 9);\n  EXPECT_EQ(\"equals the sum of 5 and 9\", Describe(m2));\n  EXPECT_EQ(\"doesn't equal the sum of 5 and 9\", DescribeNegation(m2));\n}\n\n// Tests explaining match result in a MATCHER* macro.\nTEST(MatcherMacroTest, CanExplainMatchResult) {\n  const Matcher<int> m1 = IsEven2();\n  EXPECT_EQ(\"OK\", Explain(m1, 4));\n  EXPECT_EQ(\"% 2 == 1\", Explain(m1, 5));\n\n  const Matcher<int> m2 = EqSumOf(1, 2);\n  EXPECT_EQ(\"OK\", Explain(m2, 3));\n  EXPECT_EQ(\"diff == -1\", Explain(m2, 4));\n}\n\n// Tests that the body of MATCHER() can reference the type of the\n// value being matched.\n\nMATCHER(IsEmptyString, \"\") {\n  StaticAssertTypeEq< ::std::string, arg_type>();\n  return arg == \"\";\n}\n\nMATCHER(IsEmptyStringByRef, \"\") {\n  StaticAssertTypeEq<const ::std::string&, arg_type>();\n  return arg == \"\";\n}\n\nTEST(MatcherMacroTest, CanReferenceArgType) {\n  const Matcher< ::std::string> m1 = IsEmptyString();\n  EXPECT_TRUE(m1.Matches(\"\"));\n\n  const Matcher<const ::std::string&> m2 = IsEmptyStringByRef();\n  EXPECT_TRUE(m2.Matches(\"\"));\n}\n\n// Tests that MATCHER() can be used in a namespace.\n\nnamespace matcher_test {\nMATCHER(IsOdd, \"\") { return (arg % 2) != 0; }\n}  // namespace matcher_test\n\nTEST(MatcherMacroTest, WorksInNamespace) {\n  Matcher<int> m = matcher_test::IsOdd();\n  EXPECT_FALSE(m.Matches(4));\n  EXPECT_TRUE(m.Matches(5));\n}\n\n// Tests that Value() can be used to compose matchers.\nMATCHER(IsPositiveOdd, \"\") {\n  return Value(arg, matcher_test::IsOdd()) && arg > 0;\n}\n\nTEST(MatcherMacroTest, CanBeComposedUsingValue) {\n  EXPECT_THAT(3, IsPositiveOdd());\n  EXPECT_THAT(4, Not(IsPositiveOdd()));\n  EXPECT_THAT(-1, Not(IsPositiveOdd()));\n}\n\n// Tests that a simple MATCHER_P() definition works.\n\nMATCHER_P(IsGreaterThan32And, n, \"\") { return arg > 32 && arg > n; }\n\nTEST(MatcherPMacroTest, Works) {\n  const Matcher<int> m = IsGreaterThan32And(5);\n  EXPECT_TRUE(m.Matches(36));\n  EXPECT_FALSE(m.Matches(5));\n\n  EXPECT_EQ(\"is greater than 32 and 5\", Describe(m));\n  EXPECT_EQ(\"not (is greater than 32 and 5)\", DescribeNegation(m));\n  EXPECT_EQ(\"\", Explain(m, 36));\n  EXPECT_EQ(\"\", Explain(m, 5));\n}\n\n// Tests that the description is calculated correctly from the matcher name.\nMATCHER_P(_is_Greater_Than32and_, n, \"\") { return arg > 32 && arg > n; }\n\nTEST(MatcherPMacroTest, GeneratesCorrectDescription) {\n  const Matcher<int> m = _is_Greater_Than32and_(5);\n\n  EXPECT_EQ(\"is greater than 32 and 5\", Describe(m));\n  EXPECT_EQ(\"not (is greater than 32 and 5)\", DescribeNegation(m));\n  EXPECT_EQ(\"\", Explain(m, 36));\n  EXPECT_EQ(\"\", Explain(m, 5));\n}\n\n// Tests that a MATCHER_P matcher can be explicitly instantiated with\n// a reference parameter type.\n\nclass UncopyableFoo {\n public:\n  explicit UncopyableFoo(char value) : value_(value) {}\n private:\n  UncopyableFoo(const UncopyableFoo&);\n  void operator=(const UncopyableFoo&);\n\n  char value_;\n};\n\nMATCHER_P(ReferencesUncopyable, variable, \"\") { return &arg == &variable; }\n\nTEST(MatcherPMacroTest, WorksWhenExplicitlyInstantiatedWithReference) {\n  UncopyableFoo foo1('1'), foo2('2');\n  const Matcher<const UncopyableFoo&> m =\n      ReferencesUncopyable<const UncopyableFoo&>(foo1);\n\n  EXPECT_TRUE(m.Matches(foo1));\n  EXPECT_FALSE(m.Matches(foo2));\n\n  // We don't want the address of the parameter printed, as most\n  // likely it will just annoy the user.  If the address is\n  // interesting, the user should consider passing the parameter by\n  // pointer instead.\n  EXPECT_EQ(\"references uncopyable 1-byte object <31>\", Describe(m));\n}\n\n\n// Tests that the body of MATCHER_Pn() can reference the parameter\n// types.\n\nMATCHER_P3(ParamTypesAreIntLongAndChar, foo, bar, baz, \"\") {\n  StaticAssertTypeEq<int, foo_type>();\n  StaticAssertTypeEq<long, bar_type>();  // NOLINT\n  StaticAssertTypeEq<char, baz_type>();\n  return arg == 0;\n}\n\nTEST(MatcherPnMacroTest, CanReferenceParamTypes) {\n  EXPECT_THAT(0, ParamTypesAreIntLongAndChar(10, 20L, 'a'));\n}\n\n// Tests that a MATCHER_Pn matcher can be explicitly instantiated with\n// reference parameter types.\n\nMATCHER_P2(ReferencesAnyOf, variable1, variable2, \"\") {\n  return &arg == &variable1 || &arg == &variable2;\n}\n\nTEST(MatcherPnMacroTest, WorksWhenExplicitlyInstantiatedWithReferences) {\n  UncopyableFoo foo1('1'), foo2('2'), foo3('3');\n  const Matcher<const UncopyableFoo&> m =\n      ReferencesAnyOf<const UncopyableFoo&, const UncopyableFoo&>(foo1, foo2);\n\n  EXPECT_TRUE(m.Matches(foo1));\n  EXPECT_TRUE(m.Matches(foo2));\n  EXPECT_FALSE(m.Matches(foo3));\n}\n\nTEST(MatcherPnMacroTest,\n     GeneratesCorretDescriptionWhenExplicitlyInstantiatedWithReferences) {\n  UncopyableFoo foo1('1'), foo2('2');\n  const Matcher<const UncopyableFoo&> m =\n      ReferencesAnyOf<const UncopyableFoo&, const UncopyableFoo&>(foo1, foo2);\n\n  // We don't want the addresses of the parameters printed, as most\n  // likely they will just annoy the user.  If the addresses are\n  // interesting, the user should consider passing the parameters by\n  // pointers instead.\n  EXPECT_EQ(\"references any of (1-byte object <31>, 1-byte object <32>)\",\n            Describe(m));\n}\n\n// Tests that a simple MATCHER_P2() definition works.\n\nMATCHER_P2(IsNotInClosedRange, low, hi, \"\") { return arg < low || arg > hi; }\n\nTEST(MatcherPnMacroTest, Works) {\n  const Matcher<const long&> m = IsNotInClosedRange(10, 20);  // NOLINT\n  EXPECT_TRUE(m.Matches(36L));\n  EXPECT_FALSE(m.Matches(15L));\n\n  EXPECT_EQ(\"is not in closed range (10, 20)\", Describe(m));\n  EXPECT_EQ(\"not (is not in closed range (10, 20))\", DescribeNegation(m));\n  EXPECT_EQ(\"\", Explain(m, 36L));\n  EXPECT_EQ(\"\", Explain(m, 15L));\n}\n\n// Tests that MATCHER*() definitions can be overloaded on the number\n// of parameters; also tests MATCHER_Pn() where n >= 3.\n\nMATCHER(EqualsSumOf, \"\") { return arg == 0; }\nMATCHER_P(EqualsSumOf, a, \"\") { return arg == a; }\nMATCHER_P2(EqualsSumOf, a, b, \"\") { return arg == a + b; }\nMATCHER_P3(EqualsSumOf, a, b, c, \"\") { return arg == a + b + c; }\nMATCHER_P4(EqualsSumOf, a, b, c, d, \"\") { return arg == a + b + c + d; }\nMATCHER_P5(EqualsSumOf, a, b, c, d, e, \"\") { return arg == a + b + c + d + e; }\nMATCHER_P6(EqualsSumOf, a, b, c, d, e, f, \"\") {\n  return arg == a + b + c + d + e + f;\n}\nMATCHER_P7(EqualsSumOf, a, b, c, d, e, f, g, \"\") {\n  return arg == a + b + c + d + e + f + g;\n}\nMATCHER_P8(EqualsSumOf, a, b, c, d, e, f, g, h, \"\") {\n  return arg == a + b + c + d + e + f + g + h;\n}\nMATCHER_P9(EqualsSumOf, a, b, c, d, e, f, g, h, i, \"\") {\n  return arg == a + b + c + d + e + f + g + h + i;\n}\nMATCHER_P10(EqualsSumOf, a, b, c, d, e, f, g, h, i, j, \"\") {\n  return arg == a + b + c + d + e + f + g + h + i + j;\n}\n\nTEST(MatcherPnMacroTest, CanBeOverloadedOnNumberOfParameters) {\n  EXPECT_THAT(0, EqualsSumOf());\n  EXPECT_THAT(1, EqualsSumOf(1));\n  EXPECT_THAT(12, EqualsSumOf(10, 2));\n  EXPECT_THAT(123, EqualsSumOf(100, 20, 3));\n  EXPECT_THAT(1234, EqualsSumOf(1000, 200, 30, 4));\n  EXPECT_THAT(12345, EqualsSumOf(10000, 2000, 300, 40, 5));\n  EXPECT_THAT(\"abcdef\",\n              EqualsSumOf(::std::string(\"a\"), 'b', 'c', \"d\", \"e\", 'f'));\n  EXPECT_THAT(\"abcdefg\",\n              EqualsSumOf(::std::string(\"a\"), 'b', 'c', \"d\", \"e\", 'f', 'g'));\n  EXPECT_THAT(\"abcdefgh\",\n              EqualsSumOf(::std::string(\"a\"), 'b', 'c', \"d\", \"e\", 'f', 'g',\n                          \"h\"));\n  EXPECT_THAT(\"abcdefghi\",\n              EqualsSumOf(::std::string(\"a\"), 'b', 'c', \"d\", \"e\", 'f', 'g',\n                          \"h\", 'i'));\n  EXPECT_THAT(\"abcdefghij\",\n              EqualsSumOf(::std::string(\"a\"), 'b', 'c', \"d\", \"e\", 'f', 'g',\n                          \"h\", 'i', ::std::string(\"j\")));\n\n  EXPECT_THAT(1, Not(EqualsSumOf()));\n  EXPECT_THAT(-1, Not(EqualsSumOf(1)));\n  EXPECT_THAT(-12, Not(EqualsSumOf(10, 2)));\n  EXPECT_THAT(-123, Not(EqualsSumOf(100, 20, 3)));\n  EXPECT_THAT(-1234, Not(EqualsSumOf(1000, 200, 30, 4)));\n  EXPECT_THAT(-12345, Not(EqualsSumOf(10000, 2000, 300, 40, 5)));\n  EXPECT_THAT(\"abcdef \",\n              Not(EqualsSumOf(::std::string(\"a\"), 'b', 'c', \"d\", \"e\", 'f')));\n  EXPECT_THAT(\"abcdefg \",\n              Not(EqualsSumOf(::std::string(\"a\"), 'b', 'c', \"d\", \"e\", 'f',\n                              'g')));\n  EXPECT_THAT(\"abcdefgh \",\n              Not(EqualsSumOf(::std::string(\"a\"), 'b', 'c', \"d\", \"e\", 'f', 'g',\n                              \"h\")));\n  EXPECT_THAT(\"abcdefghi \",\n              Not(EqualsSumOf(::std::string(\"a\"), 'b', 'c', \"d\", \"e\", 'f', 'g',\n                              \"h\", 'i')));\n  EXPECT_THAT(\"abcdefghij \",\n              Not(EqualsSumOf(::std::string(\"a\"), 'b', 'c', \"d\", \"e\", 'f', 'g',\n                              \"h\", 'i', ::std::string(\"j\"))));\n}\n\n// Tests that a MATCHER_Pn() definition can be instantiated with any\n// compatible parameter types.\nTEST(MatcherPnMacroTest, WorksForDifferentParameterTypes) {\n  EXPECT_THAT(123, EqualsSumOf(100L, 20, static_cast<char>(3)));\n  EXPECT_THAT(\"abcd\", EqualsSumOf(::std::string(\"a\"), \"b\", 'c', \"d\"));\n\n  EXPECT_THAT(124, Not(EqualsSumOf(100L, 20, static_cast<char>(3))));\n  EXPECT_THAT(\"abcde\", Not(EqualsSumOf(::std::string(\"a\"), \"b\", 'c', \"d\")));\n}\n\n// Tests that the matcher body can promote the parameter types.\n\nMATCHER_P2(EqConcat, prefix, suffix, \"\") {\n  // The following lines promote the two parameters to desired types.\n  std::string prefix_str(prefix);\n  char suffix_char = static_cast<char>(suffix);\n  return arg == prefix_str + suffix_char;\n}\n\nTEST(MatcherPnMacroTest, SimpleTypePromotion) {\n  Matcher<std::string> no_promo =\n      EqConcat(std::string(\"foo\"), 't');\n  Matcher<const std::string&> promo =\n      EqConcat(\"foo\", static_cast<int>('t'));\n  EXPECT_FALSE(no_promo.Matches(\"fool\"));\n  EXPECT_FALSE(promo.Matches(\"fool\"));\n  EXPECT_TRUE(no_promo.Matches(\"foot\"));\n  EXPECT_TRUE(promo.Matches(\"foot\"));\n}\n\n// Verifies the type of a MATCHER*.\n\nTEST(MatcherPnMacroTest, TypesAreCorrect) {\n  // EqualsSumOf() must be assignable to a EqualsSumOfMatcher variable.\n  EqualsSumOfMatcher a0 = EqualsSumOf();\n\n  // EqualsSumOf(1) must be assignable to a EqualsSumOfMatcherP variable.\n  EqualsSumOfMatcherP<int> a1 = EqualsSumOf(1);\n\n  // EqualsSumOf(p1, ..., pk) must be assignable to a EqualsSumOfMatcherPk\n  // variable, and so on.\n  EqualsSumOfMatcherP2<int, char> a2 = EqualsSumOf(1, '2');\n  EqualsSumOfMatcherP3<int, int, char> a3 = EqualsSumOf(1, 2, '3');\n  EqualsSumOfMatcherP4<int, int, int, char> a4 = EqualsSumOf(1, 2, 3, '4');\n  EqualsSumOfMatcherP5<int, int, int, int, char> a5 =\n      EqualsSumOf(1, 2, 3, 4, '5');\n  EqualsSumOfMatcherP6<int, int, int, int, int, char> a6 =\n      EqualsSumOf(1, 2, 3, 4, 5, '6');\n  EqualsSumOfMatcherP7<int, int, int, int, int, int, char> a7 =\n      EqualsSumOf(1, 2, 3, 4, 5, 6, '7');\n  EqualsSumOfMatcherP8<int, int, int, int, int, int, int, char> a8 =\n      EqualsSumOf(1, 2, 3, 4, 5, 6, 7, '8');\n  EqualsSumOfMatcherP9<int, int, int, int, int, int, int, int, char> a9 =\n      EqualsSumOf(1, 2, 3, 4, 5, 6, 7, 8, '9');\n  EqualsSumOfMatcherP10<int, int, int, int, int, int, int, int, int, char> a10 =\n      EqualsSumOf(1, 2, 3, 4, 5, 6, 7, 8, 9, '0');\n\n  // Avoid \"unused variable\" warnings.\n  (void)a0;\n  (void)a1;\n  (void)a2;\n  (void)a3;\n  (void)a4;\n  (void)a5;\n  (void)a6;\n  (void)a7;\n  (void)a8;\n  (void)a9;\n  (void)a10;\n}\n\n// Tests that matcher-typed parameters can be used in Value() inside a\n// MATCHER_Pn definition.\n\n// Succeeds if arg matches exactly 2 of the 3 matchers.\nMATCHER_P3(TwoOf, m1, m2, m3, \"\") {\n  const int count = static_cast<int>(Value(arg, m1))\n      + static_cast<int>(Value(arg, m2)) + static_cast<int>(Value(arg, m3));\n  return count == 2;\n}\n\nTEST(MatcherPnMacroTest, CanUseMatcherTypedParameterInValue) {\n  EXPECT_THAT(42, TwoOf(Gt(0), Lt(50), Eq(10)));\n  EXPECT_THAT(0, Not(TwoOf(Gt(-1), Lt(1), Eq(0))));\n}\n\n// Tests Contains().\n\nTEST(ContainsTest, ListMatchesWhenElementIsInContainer) {\n  list<int> some_list;\n  some_list.push_back(3);\n  some_list.push_back(1);\n  some_list.push_back(2);\n  EXPECT_THAT(some_list, Contains(1));\n  EXPECT_THAT(some_list, Contains(Gt(2.5)));\n  EXPECT_THAT(some_list, Contains(Eq(2.0f)));\n\n  list<string> another_list;\n  another_list.push_back(\"fee\");\n  another_list.push_back(\"fie\");\n  another_list.push_back(\"foe\");\n  another_list.push_back(\"fum\");\n  EXPECT_THAT(another_list, Contains(string(\"fee\")));\n}\n\nTEST(ContainsTest, ListDoesNotMatchWhenElementIsNotInContainer) {\n  list<int> some_list;\n  some_list.push_back(3);\n  some_list.push_back(1);\n  EXPECT_THAT(some_list, Not(Contains(4)));\n}\n\nTEST(ContainsTest, SetMatchesWhenElementIsInContainer) {\n  set<int> some_set;\n  some_set.insert(3);\n  some_set.insert(1);\n  some_set.insert(2);\n  EXPECT_THAT(some_set, Contains(Eq(1.0)));\n  EXPECT_THAT(some_set, Contains(Eq(3.0f)));\n  EXPECT_THAT(some_set, Contains(2));\n\n  set<const char*> another_set;\n  another_set.insert(\"fee\");\n  another_set.insert(\"fie\");\n  another_set.insert(\"foe\");\n  another_set.insert(\"fum\");\n  EXPECT_THAT(another_set, Contains(Eq(string(\"fum\"))));\n}\n\nTEST(ContainsTest, SetDoesNotMatchWhenElementIsNotInContainer) {\n  set<int> some_set;\n  some_set.insert(3);\n  some_set.insert(1);\n  EXPECT_THAT(some_set, Not(Contains(4)));\n\n  set<const char*> c_string_set;\n  c_string_set.insert(\"hello\");\n  EXPECT_THAT(c_string_set, Not(Contains(string(\"hello\").c_str())));\n}\n\nTEST(ContainsTest, ExplainsMatchResultCorrectly) {\n  const int a[2] = { 1, 2 };\n  Matcher<const int (&)[2]> m = Contains(2);\n  EXPECT_EQ(\"whose element #1 matches\", Explain(m, a));\n\n  m = Contains(3);\n  EXPECT_EQ(\"\", Explain(m, a));\n\n  m = Contains(GreaterThan(0));\n  EXPECT_EQ(\"whose element #0 matches, which is 1 more than 0\", Explain(m, a));\n\n  m = Contains(GreaterThan(10));\n  EXPECT_EQ(\"\", Explain(m, a));\n}\n\nTEST(ContainsTest, DescribesItselfCorrectly) {\n  Matcher<vector<int> > m = Contains(1);\n  EXPECT_EQ(\"contains at least one element that is equal to 1\", Describe(m));\n\n  Matcher<vector<int> > m2 = Not(m);\n  EXPECT_EQ(\"doesn't contain any element that is equal to 1\", Describe(m2));\n}\n\nTEST(ContainsTest, MapMatchesWhenElementIsInContainer) {\n  map<const char*, int> my_map;\n  const char* bar = \"a string\";\n  my_map[bar] = 2;\n  EXPECT_THAT(my_map, Contains(pair<const char* const, int>(bar, 2)));\n\n  map<string, int> another_map;\n  another_map[\"fee\"] = 1;\n  another_map[\"fie\"] = 2;\n  another_map[\"foe\"] = 3;\n  another_map[\"fum\"] = 4;\n  EXPECT_THAT(another_map, Contains(pair<const string, int>(string(\"fee\"), 1)));\n  EXPECT_THAT(another_map, Contains(pair<const string, int>(\"fie\", 2)));\n}\n\nTEST(ContainsTest, MapDoesNotMatchWhenElementIsNotInContainer) {\n  map<int, int> some_map;\n  some_map[1] = 11;\n  some_map[2] = 22;\n  EXPECT_THAT(some_map, Not(Contains(pair<const int, int>(2, 23))));\n}\n\nTEST(ContainsTest, ArrayMatchesWhenElementIsInContainer) {\n  const char* string_array[] = { \"fee\", \"fie\", \"foe\", \"fum\" };\n  EXPECT_THAT(string_array, Contains(Eq(string(\"fum\"))));\n}\n\nTEST(ContainsTest, ArrayDoesNotMatchWhenElementIsNotInContainer) {\n  int int_array[] = { 1, 2, 3, 4 };\n  EXPECT_THAT(int_array, Not(Contains(5)));\n}\n\nTEST(ContainsTest, AcceptsMatcher) {\n  const int a[] = { 1, 2, 3 };\n  EXPECT_THAT(a, Contains(Gt(2)));\n  EXPECT_THAT(a, Not(Contains(Gt(4))));\n}\n\nTEST(ContainsTest, WorksForNativeArrayAsTuple) {\n  const int a[] = { 1, 2 };\n  const int* const pointer = a;\n  EXPECT_THAT(make_tuple(pointer, 2), Contains(1));\n  EXPECT_THAT(make_tuple(pointer, 2), Not(Contains(Gt(3))));\n}\n\nTEST(ContainsTest, WorksForTwoDimensionalNativeArray) {\n  int a[][3] = { { 1, 2, 3 }, { 4, 5, 6 } };\n  EXPECT_THAT(a, Contains(ElementsAre(4, 5, 6)));\n  EXPECT_THAT(a, Contains(Contains(5)));\n  EXPECT_THAT(a, Not(Contains(ElementsAre(3, 4, 5))));\n  EXPECT_THAT(a, Contains(Not(Contains(5))));\n}\n\nTEST(AllOfTest, HugeMatcher) {\n  // Verify that using AllOf with many arguments doesn't cause\n  // the compiler to exceed template instantiation depth limit.\n  EXPECT_THAT(0, testing::AllOf(_, _, _, _, _, _, _, _, _,\n                                testing::AllOf(_, _, _, _, _, _, _, _, _, _)));\n}\n\nTEST(AnyOfTest, HugeMatcher) {\n  // Verify that using AnyOf with many arguments doesn't cause\n  // the compiler to exceed template instantiation depth limit.\n  EXPECT_THAT(0, testing::AnyOf(_, _, _, _, _, _, _, _, _,\n                                testing::AnyOf(_, _, _, _, _, _, _, _, _, _)));\n}\n\nnamespace adl_test {\n\n// Verifies that the implementation of ::testing::AllOf and ::testing::AnyOf\n// don't issue unqualified recursive calls.  If they do, the argument dependent\n// name lookup will cause AllOf/AnyOf in the 'adl_test' namespace to be found\n// as a candidate and the compilation will break due to an ambiguous overload.\n\n// The matcher must be in the same namespace as AllOf/AnyOf to make argument\n// dependent lookup find those.\nMATCHER(M, \"\") { return true; }\n\ntemplate <typename T1, typename T2>\nbool AllOf(const T1& t1, const T2& t2) { return true; }\n\nTEST(AllOfTest, DoesNotCallAllOfUnqualified) {\n  EXPECT_THAT(42, testing::AllOf(\n      M(), M(), M(), M(), M(), M(), M(), M(), M(), M()));\n}\n\ntemplate <typename T1, typename T2> bool\nAnyOf(const T1& t1, const T2& t2) { return true; }\n\nTEST(AnyOfTest, DoesNotCallAnyOfUnqualified) {\n  EXPECT_THAT(42, testing::AnyOf(\n      M(), M(), M(), M(), M(), M(), M(), M(), M(), M()));\n}\n\n}  // namespace adl_test\n\n#ifdef _MSC_VER\n# pragma warning(pop)\n#endif\n\n}  // namespace\n"
  },
  {
    "path": "ext/gmock/test/gmock-internal-utils_test.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file tests the internal utilities.\n\n#include \"gmock/internal/gmock-internal-utils.h\"\n#include <stdlib.h>\n#include <map>\n#include <string>\n#include <sstream>\n#include <vector>\n#include \"gmock/gmock.h\"\n#include \"gmock/internal/gmock-port.h\"\n#include \"gtest/gtest.h\"\n#include \"gtest/gtest-spi.h\"\n\n#if GTEST_OS_CYGWIN\n# include <sys/types.h>  // For ssize_t. NOLINT\n#endif\n\nclass ProtocolMessage;\n\nnamespace proto2 {\nclass Message;\n}  // namespace proto2\n\nnamespace testing {\nnamespace internal {\n\nnamespace {\n\nusing ::std::tr1::make_tuple;\nusing ::std::tr1::tuple;\n\nTEST(ConvertIdentifierNameToWordsTest, WorksWhenNameContainsNoWord) {\n  EXPECT_EQ(\"\", ConvertIdentifierNameToWords(\"\"));\n  EXPECT_EQ(\"\", ConvertIdentifierNameToWords(\"_\"));\n  EXPECT_EQ(\"\", ConvertIdentifierNameToWords(\"__\"));\n}\n\nTEST(ConvertIdentifierNameToWordsTest, WorksWhenNameContainsDigits) {\n  EXPECT_EQ(\"1\", ConvertIdentifierNameToWords(\"_1\"));\n  EXPECT_EQ(\"2\", ConvertIdentifierNameToWords(\"2_\"));\n  EXPECT_EQ(\"34\", ConvertIdentifierNameToWords(\"_34_\"));\n  EXPECT_EQ(\"34 56\", ConvertIdentifierNameToWords(\"_34_56\"));\n}\n\nTEST(ConvertIdentifierNameToWordsTest, WorksWhenNameContainsCamelCaseWords) {\n  EXPECT_EQ(\"a big word\", ConvertIdentifierNameToWords(\"ABigWord\"));\n  EXPECT_EQ(\"foo bar\", ConvertIdentifierNameToWords(\"FooBar\"));\n  EXPECT_EQ(\"foo\", ConvertIdentifierNameToWords(\"Foo_\"));\n  EXPECT_EQ(\"foo bar\", ConvertIdentifierNameToWords(\"_Foo_Bar_\"));\n  EXPECT_EQ(\"foo and bar\", ConvertIdentifierNameToWords(\"_Foo__And_Bar\"));\n}\n\nTEST(ConvertIdentifierNameToWordsTest, WorksWhenNameContains_SeparatedWords) {\n  EXPECT_EQ(\"foo bar\", ConvertIdentifierNameToWords(\"foo_bar\"));\n  EXPECT_EQ(\"foo\", ConvertIdentifierNameToWords(\"_foo_\"));\n  EXPECT_EQ(\"foo bar\", ConvertIdentifierNameToWords(\"_foo_bar_\"));\n  EXPECT_EQ(\"foo and bar\", ConvertIdentifierNameToWords(\"_foo__and_bar\"));\n}\n\nTEST(ConvertIdentifierNameToWordsTest, WorksWhenNameIsMixture) {\n  EXPECT_EQ(\"foo bar 123\", ConvertIdentifierNameToWords(\"Foo_bar123\"));\n  EXPECT_EQ(\"chapter 11 section 1\",\n            ConvertIdentifierNameToWords(\"_Chapter11Section_1_\"));\n}\n\nTEST(PointeeOfTest, WorksForSmartPointers) {\n  CompileAssertTypesEqual<const char,\n      PointeeOf<internal::linked_ptr<const char> >::type>();\n}\n\nTEST(PointeeOfTest, WorksForRawPointers) {\n  CompileAssertTypesEqual<int, PointeeOf<int*>::type>();\n  CompileAssertTypesEqual<const char, PointeeOf<const char*>::type>();\n  CompileAssertTypesEqual<void, PointeeOf<void*>::type>();\n}\n\nTEST(GetRawPointerTest, WorksForSmartPointers) {\n  const char* const raw_p4 = new const char('a');  // NOLINT\n  const internal::linked_ptr<const char> p4(raw_p4);\n  EXPECT_EQ(raw_p4, GetRawPointer(p4));\n}\n\nTEST(GetRawPointerTest, WorksForRawPointers) {\n  int* p = NULL;\n  // Don't use EXPECT_EQ as no NULL-testing magic on Symbian.\n  EXPECT_TRUE(NULL == GetRawPointer(p));\n  int n = 1;\n  EXPECT_EQ(&n, GetRawPointer(&n));\n}\n\n// Tests KindOf<T>.\n\nclass Base {};\nclass Derived : public Base {};\n\nTEST(KindOfTest, Bool) {\n  EXPECT_EQ(kBool, GMOCK_KIND_OF_(bool));  // NOLINT\n}\n\nTEST(KindOfTest, Integer) {\n  EXPECT_EQ(kInteger, GMOCK_KIND_OF_(char));  // NOLINT\n  EXPECT_EQ(kInteger, GMOCK_KIND_OF_(signed char));  // NOLINT\n  EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned char));  // NOLINT\n  EXPECT_EQ(kInteger, GMOCK_KIND_OF_(short));  // NOLINT\n  EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned short));  // NOLINT\n  EXPECT_EQ(kInteger, GMOCK_KIND_OF_(int));  // NOLINT\n  EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned int));  // NOLINT\n  EXPECT_EQ(kInteger, GMOCK_KIND_OF_(long));  // NOLINT\n  EXPECT_EQ(kInteger, GMOCK_KIND_OF_(unsigned long));  // NOLINT\n  EXPECT_EQ(kInteger, GMOCK_KIND_OF_(wchar_t));  // NOLINT\n  EXPECT_EQ(kInteger, GMOCK_KIND_OF_(Int64));  // NOLINT\n  EXPECT_EQ(kInteger, GMOCK_KIND_OF_(UInt64));  // NOLINT\n  EXPECT_EQ(kInteger, GMOCK_KIND_OF_(size_t));  // NOLINT\n#if GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_CYGWIN\n  // ssize_t is not defined on Windows and possibly some other OSes.\n  EXPECT_EQ(kInteger, GMOCK_KIND_OF_(ssize_t));  // NOLINT\n#endif\n}\n\nTEST(KindOfTest, FloatingPoint) {\n  EXPECT_EQ(kFloatingPoint, GMOCK_KIND_OF_(float));  // NOLINT\n  EXPECT_EQ(kFloatingPoint, GMOCK_KIND_OF_(double));  // NOLINT\n  EXPECT_EQ(kFloatingPoint, GMOCK_KIND_OF_(long double));  // NOLINT\n}\n\nTEST(KindOfTest, Other) {\n  EXPECT_EQ(kOther, GMOCK_KIND_OF_(void*));  // NOLINT\n  EXPECT_EQ(kOther, GMOCK_KIND_OF_(char**));  // NOLINT\n  EXPECT_EQ(kOther, GMOCK_KIND_OF_(Base));  // NOLINT\n}\n\n// Tests LosslessArithmeticConvertible<T, U>.\n\nTEST(LosslessArithmeticConvertibleTest, BoolToBool) {\n  EXPECT_TRUE((LosslessArithmeticConvertible<bool, bool>::value));\n}\n\nTEST(LosslessArithmeticConvertibleTest, BoolToInteger) {\n  EXPECT_TRUE((LosslessArithmeticConvertible<bool, char>::value));\n  EXPECT_TRUE((LosslessArithmeticConvertible<bool, int>::value));\n  EXPECT_TRUE(\n      (LosslessArithmeticConvertible<bool, unsigned long>::value));  // NOLINT\n}\n\nTEST(LosslessArithmeticConvertibleTest, BoolToFloatingPoint) {\n  EXPECT_TRUE((LosslessArithmeticConvertible<bool, float>::value));\n  EXPECT_TRUE((LosslessArithmeticConvertible<bool, double>::value));\n}\n\nTEST(LosslessArithmeticConvertibleTest, IntegerToBool) {\n  EXPECT_FALSE((LosslessArithmeticConvertible<unsigned char, bool>::value));\n  EXPECT_FALSE((LosslessArithmeticConvertible<int, bool>::value));\n}\n\nTEST(LosslessArithmeticConvertibleTest, IntegerToInteger) {\n  // Unsigned => larger signed is fine.\n  EXPECT_TRUE((LosslessArithmeticConvertible<unsigned char, int>::value));\n\n  // Unsigned => larger unsigned is fine.\n  EXPECT_TRUE(\n      (LosslessArithmeticConvertible<unsigned short, UInt64>::value)); // NOLINT\n\n  // Signed => unsigned is not fine.\n  EXPECT_FALSE((LosslessArithmeticConvertible<short, UInt64>::value)); // NOLINT\n  EXPECT_FALSE((LosslessArithmeticConvertible<\n      signed char, unsigned int>::value));  // NOLINT\n\n  // Same size and same signedness: fine too.\n  EXPECT_TRUE((LosslessArithmeticConvertible<\n               unsigned char, unsigned char>::value));\n  EXPECT_TRUE((LosslessArithmeticConvertible<int, int>::value));\n  EXPECT_TRUE((LosslessArithmeticConvertible<wchar_t, wchar_t>::value));\n  EXPECT_TRUE((LosslessArithmeticConvertible<\n               unsigned long, unsigned long>::value));  // NOLINT\n\n  // Same size, different signedness: not fine.\n  EXPECT_FALSE((LosslessArithmeticConvertible<\n                unsigned char, signed char>::value));\n  EXPECT_FALSE((LosslessArithmeticConvertible<int, unsigned int>::value));\n  EXPECT_FALSE((LosslessArithmeticConvertible<UInt64, Int64>::value));\n\n  // Larger size => smaller size is not fine.\n  EXPECT_FALSE((LosslessArithmeticConvertible<long, char>::value));  // NOLINT\n  EXPECT_FALSE((LosslessArithmeticConvertible<int, signed char>::value));\n  EXPECT_FALSE((LosslessArithmeticConvertible<Int64, unsigned int>::value));\n}\n\nTEST(LosslessArithmeticConvertibleTest, IntegerToFloatingPoint) {\n  // Integers cannot be losslessly converted to floating-points, as\n  // the format of the latter is implementation-defined.\n  EXPECT_FALSE((LosslessArithmeticConvertible<char, float>::value));\n  EXPECT_FALSE((LosslessArithmeticConvertible<int, double>::value));\n  EXPECT_FALSE((LosslessArithmeticConvertible<\n                short, long double>::value));  // NOLINT\n}\n\nTEST(LosslessArithmeticConvertibleTest, FloatingPointToBool) {\n  EXPECT_FALSE((LosslessArithmeticConvertible<float, bool>::value));\n  EXPECT_FALSE((LosslessArithmeticConvertible<double, bool>::value));\n}\n\nTEST(LosslessArithmeticConvertibleTest, FloatingPointToInteger) {\n  EXPECT_FALSE((LosslessArithmeticConvertible<float, long>::value));  // NOLINT\n  EXPECT_FALSE((LosslessArithmeticConvertible<double, Int64>::value));\n  EXPECT_FALSE((LosslessArithmeticConvertible<long double, int>::value));\n}\n\nTEST(LosslessArithmeticConvertibleTest, FloatingPointToFloatingPoint) {\n  // Smaller size => larger size is fine.\n  EXPECT_TRUE((LosslessArithmeticConvertible<float, double>::value));\n  EXPECT_TRUE((LosslessArithmeticConvertible<float, long double>::value));\n  EXPECT_TRUE((LosslessArithmeticConvertible<double, long double>::value));\n\n  // Same size: fine.\n  EXPECT_TRUE((LosslessArithmeticConvertible<float, float>::value));\n  EXPECT_TRUE((LosslessArithmeticConvertible<double, double>::value));\n\n  // Larger size => smaller size is not fine.\n  EXPECT_FALSE((LosslessArithmeticConvertible<double, float>::value));\n  if (sizeof(double) == sizeof(long double)) {  // NOLINT\n    // In some implementations (e.g. MSVC), double and long double\n    // have the same size.\n    EXPECT_TRUE((LosslessArithmeticConvertible<long double, double>::value));\n  } else {\n    EXPECT_FALSE((LosslessArithmeticConvertible<long double, double>::value));\n  }\n}\n\n// Tests the TupleMatches() template function.\n\nTEST(TupleMatchesTest, WorksForSize0) {\n  tuple<> matchers;\n  tuple<> values;\n\n  EXPECT_TRUE(TupleMatches(matchers, values));\n}\n\nTEST(TupleMatchesTest, WorksForSize1) {\n  tuple<Matcher<int> > matchers(Eq(1));\n  tuple<int> values1(1),\n      values2(2);\n\n  EXPECT_TRUE(TupleMatches(matchers, values1));\n  EXPECT_FALSE(TupleMatches(matchers, values2));\n}\n\nTEST(TupleMatchesTest, WorksForSize2) {\n  tuple<Matcher<int>, Matcher<char> > matchers(Eq(1), Eq('a'));\n  tuple<int, char> values1(1, 'a'),\n      values2(1, 'b'),\n      values3(2, 'a'),\n      values4(2, 'b');\n\n  EXPECT_TRUE(TupleMatches(matchers, values1));\n  EXPECT_FALSE(TupleMatches(matchers, values2));\n  EXPECT_FALSE(TupleMatches(matchers, values3));\n  EXPECT_FALSE(TupleMatches(matchers, values4));\n}\n\nTEST(TupleMatchesTest, WorksForSize5) {\n  tuple<Matcher<int>, Matcher<char>, Matcher<bool>, Matcher<long>,  // NOLINT\n      Matcher<string> >\n      matchers(Eq(1), Eq('a'), Eq(true), Eq(2L), Eq(\"hi\"));\n  tuple<int, char, bool, long, string>  // NOLINT\n      values1(1, 'a', true, 2L, \"hi\"),\n      values2(1, 'a', true, 2L, \"hello\"),\n      values3(2, 'a', true, 2L, \"hi\");\n\n  EXPECT_TRUE(TupleMatches(matchers, values1));\n  EXPECT_FALSE(TupleMatches(matchers, values2));\n  EXPECT_FALSE(TupleMatches(matchers, values3));\n}\n\n// Tests that Assert(true, ...) succeeds.\nTEST(AssertTest, SucceedsOnTrue) {\n  Assert(true, __FILE__, __LINE__, \"This should succeed.\");\n  Assert(true, __FILE__, __LINE__);  // This should succeed too.\n}\n\n// Tests that Assert(false, ...) generates a fatal failure.\nTEST(AssertTest, FailsFatallyOnFalse) {\n  EXPECT_DEATH_IF_SUPPORTED({\n    Assert(false, __FILE__, __LINE__, \"This should fail.\");\n  }, \"\");\n\n  EXPECT_DEATH_IF_SUPPORTED({\n    Assert(false, __FILE__, __LINE__);\n  }, \"\");\n}\n\n// Tests that Expect(true, ...) succeeds.\nTEST(ExpectTest, SucceedsOnTrue) {\n  Expect(true, __FILE__, __LINE__, \"This should succeed.\");\n  Expect(true, __FILE__, __LINE__);  // This should succeed too.\n}\n\n// Tests that Expect(false, ...) generates a non-fatal failure.\nTEST(ExpectTest, FailsNonfatallyOnFalse) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    Expect(false, __FILE__, __LINE__, \"This should fail.\");\n  }, \"This should fail\");\n\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    Expect(false, __FILE__, __LINE__);\n  }, \"Expectation failed\");\n}\n\n// Tests LogIsVisible().\n\nclass LogIsVisibleTest : public ::testing::Test {\n protected:\n  virtual void SetUp() {\n    original_verbose_ = GMOCK_FLAG(verbose);\n  }\n\n  virtual void TearDown() { GMOCK_FLAG(verbose) = original_verbose_; }\n\n  string original_verbose_;\n};\n\nTEST_F(LogIsVisibleTest, AlwaysReturnsTrueIfVerbosityIsInfo) {\n  GMOCK_FLAG(verbose) = kInfoVerbosity;\n  EXPECT_TRUE(LogIsVisible(kInfo));\n  EXPECT_TRUE(LogIsVisible(kWarning));\n}\n\nTEST_F(LogIsVisibleTest, AlwaysReturnsFalseIfVerbosityIsError) {\n  GMOCK_FLAG(verbose) = kErrorVerbosity;\n  EXPECT_FALSE(LogIsVisible(kInfo));\n  EXPECT_FALSE(LogIsVisible(kWarning));\n}\n\nTEST_F(LogIsVisibleTest, WorksWhenVerbosityIsWarning) {\n  GMOCK_FLAG(verbose) = kWarningVerbosity;\n  EXPECT_FALSE(LogIsVisible(kInfo));\n  EXPECT_TRUE(LogIsVisible(kWarning));\n}\n\n#if GTEST_HAS_STREAM_REDIRECTION\n\n// Tests the Log() function.\n\n// Verifies that Log() behaves correctly for the given verbosity level\n// and log severity.\nvoid TestLogWithSeverity(const string& verbosity, LogSeverity severity,\n                         bool should_print) {\n  const string old_flag = GMOCK_FLAG(verbose);\n  GMOCK_FLAG(verbose) = verbosity;\n  CaptureStdout();\n  Log(severity, \"Test log.\\n\", 0);\n  if (should_print) {\n    EXPECT_THAT(GetCapturedStdout().c_str(),\n                ContainsRegex(\n                    severity == kWarning ?\n                    \"^\\nGMOCK WARNING:\\nTest log\\\\.\\nStack trace:\\n\" :\n                    \"^\\nTest log\\\\.\\nStack trace:\\n\"));\n  } else {\n    EXPECT_STREQ(\"\", GetCapturedStdout().c_str());\n  }\n  GMOCK_FLAG(verbose) = old_flag;\n}\n\n// Tests that when the stack_frames_to_skip parameter is negative,\n// Log() doesn't include the stack trace in the output.\nTEST(LogTest, NoStackTraceWhenStackFramesToSkipIsNegative) {\n  const string saved_flag = GMOCK_FLAG(verbose);\n  GMOCK_FLAG(verbose) = kInfoVerbosity;\n  CaptureStdout();\n  Log(kInfo, \"Test log.\\n\", -1);\n  EXPECT_STREQ(\"\\nTest log.\\n\", GetCapturedStdout().c_str());\n  GMOCK_FLAG(verbose) = saved_flag;\n}\n\n// Tests that in opt mode, a positive stack_frames_to_skip argument is\n// treated as 0.\nTEST(LogTest, NoSkippingStackFrameInOptMode) {\n  CaptureStdout();\n  Log(kWarning, \"Test log.\\n\", 100);\n  const string log = GetCapturedStdout();\n\n# if defined(NDEBUG) && GTEST_GOOGLE3_MODE_\n\n  // In opt mode, no stack frame should be skipped.\n  EXPECT_THAT(log, ContainsRegex(\"\\nGMOCK WARNING:\\n\"\n                                 \"Test log\\\\.\\n\"\n                                 \"Stack trace:\\n\"\n                                 \".+\"));\n# else\n\n  // In dbg mode, the stack frames should be skipped.\n  EXPECT_STREQ(\"\\nGMOCK WARNING:\\n\"\n               \"Test log.\\n\"\n               \"Stack trace:\\n\", log.c_str());\n# endif\n}\n\n// Tests that all logs are printed when the value of the\n// --gmock_verbose flag is \"info\".\nTEST(LogTest, AllLogsArePrintedWhenVerbosityIsInfo) {\n  TestLogWithSeverity(kInfoVerbosity, kInfo, true);\n  TestLogWithSeverity(kInfoVerbosity, kWarning, true);\n}\n\n// Tests that only warnings are printed when the value of the\n// --gmock_verbose flag is \"warning\".\nTEST(LogTest, OnlyWarningsArePrintedWhenVerbosityIsWarning) {\n  TestLogWithSeverity(kWarningVerbosity, kInfo, false);\n  TestLogWithSeverity(kWarningVerbosity, kWarning, true);\n}\n\n// Tests that no logs are printed when the value of the\n// --gmock_verbose flag is \"error\".\nTEST(LogTest, NoLogsArePrintedWhenVerbosityIsError) {\n  TestLogWithSeverity(kErrorVerbosity, kInfo, false);\n  TestLogWithSeverity(kErrorVerbosity, kWarning, false);\n}\n\n// Tests that only warnings are printed when the value of the\n// --gmock_verbose flag is invalid.\nTEST(LogTest, OnlyWarningsArePrintedWhenVerbosityIsInvalid) {\n  TestLogWithSeverity(\"invalid\", kInfo, false);\n  TestLogWithSeverity(\"invalid\", kWarning, true);\n}\n\n#endif  // GTEST_HAS_STREAM_REDIRECTION\n\nTEST(TypeTraitsTest, true_type) {\n  EXPECT_TRUE(true_type::value);\n}\n\nTEST(TypeTraitsTest, false_type) {\n  EXPECT_FALSE(false_type::value);\n}\n\nTEST(TypeTraitsTest, is_reference) {\n  EXPECT_FALSE(is_reference<int>::value);\n  EXPECT_FALSE(is_reference<char*>::value);\n  EXPECT_TRUE(is_reference<const int&>::value);\n}\n\nTEST(TypeTraitsTest, is_pointer) {\n  EXPECT_FALSE(is_pointer<int>::value);\n  EXPECT_FALSE(is_pointer<char&>::value);\n  EXPECT_TRUE(is_pointer<const int*>::value);\n}\n\nTEST(TypeTraitsTest, type_equals) {\n  EXPECT_FALSE((type_equals<int, const int>::value));\n  EXPECT_FALSE((type_equals<int, int&>::value));\n  EXPECT_FALSE((type_equals<int, double>::value));\n  EXPECT_TRUE((type_equals<char, char>::value));\n}\n\nTEST(TypeTraitsTest, remove_reference) {\n  EXPECT_TRUE((type_equals<char, remove_reference<char&>::type>::value));\n  EXPECT_TRUE((type_equals<const int,\n               remove_reference<const int&>::type>::value));\n  EXPECT_TRUE((type_equals<int, remove_reference<int>::type>::value));\n  EXPECT_TRUE((type_equals<double*, remove_reference<double*>::type>::value));\n}\n\n#if GTEST_HAS_STREAM_REDIRECTION\n\n// Verifies that Log() behaves correctly for the given verbosity level\n// and log severity.\nstd::string GrabOutput(void(*logger)(), const char* verbosity) {\n  const string saved_flag = GMOCK_FLAG(verbose);\n  GMOCK_FLAG(verbose) = verbosity;\n  CaptureStdout();\n  logger();\n  GMOCK_FLAG(verbose) = saved_flag;\n  return GetCapturedStdout();\n}\n\nclass DummyMock {\n public:\n  MOCK_METHOD0(TestMethod, void());\n  MOCK_METHOD1(TestMethodArg, void(int dummy));\n};\n\nvoid ExpectCallLogger() {\n  DummyMock mock;\n  EXPECT_CALL(mock, TestMethod());\n  mock.TestMethod();\n};\n\n// Verifies that EXPECT_CALL logs if the --gmock_verbose flag is set to \"info\".\nTEST(ExpectCallTest, LogsWhenVerbosityIsInfo) {\n  EXPECT_THAT(std::string(GrabOutput(ExpectCallLogger, kInfoVerbosity)),\n              HasSubstr(\"EXPECT_CALL(mock, TestMethod())\"));\n}\n\n// Verifies that EXPECT_CALL doesn't log\n// if the --gmock_verbose flag is set to \"warning\".\nTEST(ExpectCallTest, DoesNotLogWhenVerbosityIsWarning) {\n  EXPECT_STREQ(\"\", GrabOutput(ExpectCallLogger, kWarningVerbosity).c_str());\n}\n\n// Verifies that EXPECT_CALL doesn't log\n// if the --gmock_verbose flag is set to \"error\".\nTEST(ExpectCallTest,  DoesNotLogWhenVerbosityIsError) {\n  EXPECT_STREQ(\"\", GrabOutput(ExpectCallLogger, kErrorVerbosity).c_str());\n}\n\nvoid OnCallLogger() {\n  DummyMock mock;\n  ON_CALL(mock, TestMethod());\n};\n\n// Verifies that ON_CALL logs if the --gmock_verbose flag is set to \"info\".\nTEST(OnCallTest, LogsWhenVerbosityIsInfo) {\n  EXPECT_THAT(std::string(GrabOutput(OnCallLogger, kInfoVerbosity)),\n              HasSubstr(\"ON_CALL(mock, TestMethod())\"));\n}\n\n// Verifies that ON_CALL doesn't log\n// if the --gmock_verbose flag is set to \"warning\".\nTEST(OnCallTest, DoesNotLogWhenVerbosityIsWarning) {\n  EXPECT_STREQ(\"\", GrabOutput(OnCallLogger, kWarningVerbosity).c_str());\n}\n\n// Verifies that ON_CALL doesn't log if\n// the --gmock_verbose flag is set to \"error\".\nTEST(OnCallTest, DoesNotLogWhenVerbosityIsError) {\n  EXPECT_STREQ(\"\", GrabOutput(OnCallLogger, kErrorVerbosity).c_str());\n}\n\nvoid OnCallAnyArgumentLogger() {\n  DummyMock mock;\n  ON_CALL(mock, TestMethodArg(_));\n}\n\n// Verifies that ON_CALL prints provided _ argument.\nTEST(OnCallTest, LogsAnythingArgument) {\n  EXPECT_THAT(std::string(GrabOutput(OnCallAnyArgumentLogger, kInfoVerbosity)),\n              HasSubstr(\"ON_CALL(mock, TestMethodArg(_)\"));\n}\n\n#endif  // GTEST_HAS_STREAM_REDIRECTION\n\n// Tests StlContainerView.\n\nTEST(StlContainerViewTest, WorksForStlContainer) {\n  StaticAssertTypeEq<std::vector<int>,\n      StlContainerView<std::vector<int> >::type>();\n  StaticAssertTypeEq<const std::vector<double>&,\n      StlContainerView<std::vector<double> >::const_reference>();\n\n  typedef std::vector<char> Chars;\n  Chars v1;\n  const Chars& v2(StlContainerView<Chars>::ConstReference(v1));\n  EXPECT_EQ(&v1, &v2);\n\n  v1.push_back('a');\n  Chars v3 = StlContainerView<Chars>::Copy(v1);\n  EXPECT_THAT(v3, Eq(v3));\n}\n\nTEST(StlContainerViewTest, WorksForStaticNativeArray) {\n  StaticAssertTypeEq<NativeArray<int>,\n      StlContainerView<int[3]>::type>();\n  StaticAssertTypeEq<NativeArray<double>,\n      StlContainerView<const double[4]>::type>();\n  StaticAssertTypeEq<NativeArray<char[3]>,\n      StlContainerView<const char[2][3]>::type>();\n\n  StaticAssertTypeEq<const NativeArray<int>,\n      StlContainerView<int[2]>::const_reference>();\n\n  int a1[3] = { 0, 1, 2 };\n  NativeArray<int> a2 = StlContainerView<int[3]>::ConstReference(a1);\n  EXPECT_EQ(3U, a2.size());\n  EXPECT_EQ(a1, a2.begin());\n\n  const NativeArray<int> a3 = StlContainerView<int[3]>::Copy(a1);\n  ASSERT_EQ(3U, a3.size());\n  EXPECT_EQ(0, a3.begin()[0]);\n  EXPECT_EQ(1, a3.begin()[1]);\n  EXPECT_EQ(2, a3.begin()[2]);\n\n  // Makes sure a1 and a3 aren't aliases.\n  a1[0] = 3;\n  EXPECT_EQ(0, a3.begin()[0]);\n}\n\nTEST(StlContainerViewTest, WorksForDynamicNativeArray) {\n  StaticAssertTypeEq<NativeArray<int>,\n      StlContainerView<tuple<const int*, size_t> >::type>();\n  StaticAssertTypeEq<NativeArray<double>,\n      StlContainerView<tuple<linked_ptr<double>, int> >::type>();\n\n  StaticAssertTypeEq<const NativeArray<int>,\n      StlContainerView<tuple<const int*, int> >::const_reference>();\n\n  int a1[3] = { 0, 1, 2 };\n  const int* const p1 = a1;\n  NativeArray<int> a2 = StlContainerView<tuple<const int*, int> >::\n      ConstReference(make_tuple(p1, 3));\n  EXPECT_EQ(3U, a2.size());\n  EXPECT_EQ(a1, a2.begin());\n\n  const NativeArray<int> a3 = StlContainerView<tuple<int*, size_t> >::\n      Copy(make_tuple(static_cast<int*>(a1), 3));\n  ASSERT_EQ(3U, a3.size());\n  EXPECT_EQ(0, a3.begin()[0]);\n  EXPECT_EQ(1, a3.begin()[1]);\n  EXPECT_EQ(2, a3.begin()[2]);\n\n  // Makes sure a1 and a3 aren't aliases.\n  a1[0] = 3;\n  EXPECT_EQ(0, a3.begin()[0]);\n}\n\n}  // namespace\n}  // namespace internal\n}  // namespace testing\n"
  },
  {
    "path": "ext/gmock/test/gmock-matchers_test.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file tests some commonly used argument matchers.\n\n#include \"gmock/gmock-matchers.h\"\n#include \"gmock/gmock-more-matchers.h\"\n\n#include <string.h>\n#include <time.h>\n#include <deque>\n#include <functional>\n#include <iostream>\n#include <iterator>\n#include <limits>\n#include <list>\n#include <map>\n#include <set>\n#include <sstream>\n#include <string>\n#include <utility>\n#include <vector>\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n#include \"gtest/gtest-spi.h\"\n\nnamespace testing {\n\nnamespace internal {\nGTEST_API_ string JoinAsTuple(const Strings& fields);\n}  // namespace internal\n\nnamespace gmock_matchers_test {\n\nusing std::greater;\nusing std::less;\nusing std::list;\nusing std::make_pair;\nusing std::map;\nusing std::multimap;\nusing std::multiset;\nusing std::ostream;\nusing std::pair;\nusing std::set;\nusing std::stringstream;\nusing std::tr1::get;\nusing std::tr1::make_tuple;\nusing std::tr1::tuple;\nusing std::vector;\nusing testing::A;\nusing testing::AllArgs;\nusing testing::AllOf;\nusing testing::An;\nusing testing::AnyOf;\nusing testing::ByRef;\nusing testing::ContainsRegex;\nusing testing::DoubleEq;\nusing testing::DoubleNear;\nusing testing::EndsWith;\nusing testing::Eq;\nusing testing::ExplainMatchResult;\nusing testing::Field;\nusing testing::FloatEq;\nusing testing::FloatNear;\nusing testing::Ge;\nusing testing::Gt;\nusing testing::HasSubstr;\nusing testing::IsEmpty;\nusing testing::IsNull;\nusing testing::Key;\nusing testing::Le;\nusing testing::Lt;\nusing testing::MakeMatcher;\nusing testing::MakePolymorphicMatcher;\nusing testing::MatchResultListener;\nusing testing::Matcher;\nusing testing::MatcherCast;\nusing testing::MatcherInterface;\nusing testing::Matches;\nusing testing::MatchesRegex;\nusing testing::NanSensitiveDoubleEq;\nusing testing::NanSensitiveDoubleNear;\nusing testing::NanSensitiveFloatEq;\nusing testing::NanSensitiveFloatNear;\nusing testing::Ne;\nusing testing::Not;\nusing testing::NotNull;\nusing testing::Pair;\nusing testing::Pointee;\nusing testing::Pointwise;\nusing testing::PolymorphicMatcher;\nusing testing::Property;\nusing testing::Ref;\nusing testing::ResultOf;\nusing testing::SizeIs;\nusing testing::StartsWith;\nusing testing::StringMatchResultListener;\nusing testing::StrCaseEq;\nusing testing::StrCaseNe;\nusing testing::StrEq;\nusing testing::StrNe;\nusing testing::Truly;\nusing testing::TypedEq;\nusing testing::Value;\nusing testing::WhenSorted;\nusing testing::WhenSortedBy;\nusing testing::_;\nusing testing::internal::DummyMatchResultListener;\nusing testing::internal::ElementMatcherPair;\nusing testing::internal::ElementMatcherPairs;\nusing testing::internal::ExplainMatchFailureTupleTo;\nusing testing::internal::FloatingEqMatcher;\nusing testing::internal::FormatMatcherDescription;\nusing testing::internal::IsReadableTypeName;\nusing testing::internal::JoinAsTuple;\nusing testing::internal::MatchMatrix;\nusing testing::internal::RE;\nusing testing::internal::StreamMatchResultListener;\nusing testing::internal::Strings;\nusing testing::internal::linked_ptr;\nusing testing::internal::scoped_ptr;\nusing testing::internal::string;\n\n// Evaluates to the number of elements in 'array'.\n#define GMOCK_ARRAY_SIZE_(array) (sizeof(array) / sizeof(array[0]))\n\n// For testing ExplainMatchResultTo().\nclass GreaterThanMatcher : public MatcherInterface<int> {\n public:\n  explicit GreaterThanMatcher(int rhs) : rhs_(rhs) {}\n\n  virtual void DescribeTo(ostream* os) const {\n    *os << \"is > \" << rhs_;\n  }\n\n  virtual bool MatchAndExplain(int lhs,\n                               MatchResultListener* listener) const {\n    const int diff = lhs - rhs_;\n    if (diff > 0) {\n      *listener << \"which is \" << diff << \" more than \" << rhs_;\n    } else if (diff == 0) {\n      *listener << \"which is the same as \" << rhs_;\n    } else {\n      *listener << \"which is \" << -diff << \" less than \" << rhs_;\n    }\n\n    return lhs > rhs_;\n  }\n\n private:\n  int rhs_;\n};\n\nMatcher<int> GreaterThan(int n) {\n  return MakeMatcher(new GreaterThanMatcher(n));\n}\n\nstring OfType(const string& type_name) {\n#if GTEST_HAS_RTTI\n  return \" (of type \" + type_name + \")\";\n#else\n  return \"\";\n#endif\n}\n\n// Returns the description of the given matcher.\ntemplate <typename T>\nstring Describe(const Matcher<T>& m) {\n  stringstream ss;\n  m.DescribeTo(&ss);\n  return ss.str();\n}\n\n// Returns the description of the negation of the given matcher.\ntemplate <typename T>\nstring DescribeNegation(const Matcher<T>& m) {\n  stringstream ss;\n  m.DescribeNegationTo(&ss);\n  return ss.str();\n}\n\n// Returns the reason why x matches, or doesn't match, m.\ntemplate <typename MatcherType, typename Value>\nstring Explain(const MatcherType& m, const Value& x) {\n  StringMatchResultListener listener;\n  ExplainMatchResult(m, x, &listener);\n  return listener.str();\n}\n\nTEST(MatchResultListenerTest, StreamingWorks) {\n  StringMatchResultListener listener;\n  listener << \"hi\" << 5;\n  EXPECT_EQ(\"hi5\", listener.str());\n\n  listener.Clear();\n  EXPECT_EQ(\"\", listener.str());\n\n  listener << 42;\n  EXPECT_EQ(\"42\", listener.str());\n\n  // Streaming shouldn't crash when the underlying ostream is NULL.\n  DummyMatchResultListener dummy;\n  dummy << \"hi\" << 5;\n}\n\nTEST(MatchResultListenerTest, CanAccessUnderlyingStream) {\n  EXPECT_TRUE(DummyMatchResultListener().stream() == NULL);\n  EXPECT_TRUE(StreamMatchResultListener(NULL).stream() == NULL);\n\n  EXPECT_EQ(&std::cout, StreamMatchResultListener(&std::cout).stream());\n}\n\nTEST(MatchResultListenerTest, IsInterestedWorks) {\n  EXPECT_TRUE(StringMatchResultListener().IsInterested());\n  EXPECT_TRUE(StreamMatchResultListener(&std::cout).IsInterested());\n\n  EXPECT_FALSE(DummyMatchResultListener().IsInterested());\n  EXPECT_FALSE(StreamMatchResultListener(NULL).IsInterested());\n}\n\n// Makes sure that the MatcherInterface<T> interface doesn't\n// change.\nclass EvenMatcherImpl : public MatcherInterface<int> {\n public:\n  virtual bool MatchAndExplain(int x,\n                               MatchResultListener* /* listener */) const {\n    return x % 2 == 0;\n  }\n\n  virtual void DescribeTo(ostream* os) const {\n    *os << \"is an even number\";\n  }\n\n  // We deliberately don't define DescribeNegationTo() and\n  // ExplainMatchResultTo() here, to make sure the definition of these\n  // two methods is optional.\n};\n\n// Makes sure that the MatcherInterface API doesn't change.\nTEST(MatcherInterfaceTest, CanBeImplementedUsingPublishedAPI) {\n  EvenMatcherImpl m;\n}\n\n// Tests implementing a monomorphic matcher using MatchAndExplain().\n\nclass NewEvenMatcherImpl : public MatcherInterface<int> {\n public:\n  virtual bool MatchAndExplain(int x, MatchResultListener* listener) const {\n    const bool match = x % 2 == 0;\n    // Verifies that we can stream to a listener directly.\n    *listener << \"value % \" << 2;\n    if (listener->stream() != NULL) {\n      // Verifies that we can stream to a listener's underlying stream\n      // too.\n      *listener->stream() << \" == \" << (x % 2);\n    }\n    return match;\n  }\n\n  virtual void DescribeTo(ostream* os) const {\n    *os << \"is an even number\";\n  }\n};\n\nTEST(MatcherInterfaceTest, CanBeImplementedUsingNewAPI) {\n  Matcher<int> m = MakeMatcher(new NewEvenMatcherImpl);\n  EXPECT_TRUE(m.Matches(2));\n  EXPECT_FALSE(m.Matches(3));\n  EXPECT_EQ(\"value % 2 == 0\", Explain(m, 2));\n  EXPECT_EQ(\"value % 2 == 1\", Explain(m, 3));\n}\n\n// Tests default-constructing a matcher.\nTEST(MatcherTest, CanBeDefaultConstructed) {\n  Matcher<double> m;\n}\n\n// Tests that Matcher<T> can be constructed from a MatcherInterface<T>*.\nTEST(MatcherTest, CanBeConstructedFromMatcherInterface) {\n  const MatcherInterface<int>* impl = new EvenMatcherImpl;\n  Matcher<int> m(impl);\n  EXPECT_TRUE(m.Matches(4));\n  EXPECT_FALSE(m.Matches(5));\n}\n\n// Tests that value can be used in place of Eq(value).\nTEST(MatcherTest, CanBeImplicitlyConstructedFromValue) {\n  Matcher<int> m1 = 5;\n  EXPECT_TRUE(m1.Matches(5));\n  EXPECT_FALSE(m1.Matches(6));\n}\n\n// Tests that NULL can be used in place of Eq(NULL).\nTEST(MatcherTest, CanBeImplicitlyConstructedFromNULL) {\n  Matcher<int*> m1 = NULL;\n  EXPECT_TRUE(m1.Matches(NULL));\n  int n = 0;\n  EXPECT_FALSE(m1.Matches(&n));\n}\n\n// Tests that matchers are copyable.\nTEST(MatcherTest, IsCopyable) {\n  // Tests the copy constructor.\n  Matcher<bool> m1 = Eq(false);\n  EXPECT_TRUE(m1.Matches(false));\n  EXPECT_FALSE(m1.Matches(true));\n\n  // Tests the assignment operator.\n  m1 = Eq(true);\n  EXPECT_TRUE(m1.Matches(true));\n  EXPECT_FALSE(m1.Matches(false));\n}\n\n// Tests that Matcher<T>::DescribeTo() calls\n// MatcherInterface<T>::DescribeTo().\nTEST(MatcherTest, CanDescribeItself) {\n  EXPECT_EQ(\"is an even number\",\n            Describe(Matcher<int>(new EvenMatcherImpl)));\n}\n\n// Tests Matcher<T>::MatchAndExplain().\nTEST(MatcherTest, MatchAndExplain) {\n  Matcher<int> m = GreaterThan(0);\n  StringMatchResultListener listener1;\n  EXPECT_TRUE(m.MatchAndExplain(42, &listener1));\n  EXPECT_EQ(\"which is 42 more than 0\", listener1.str());\n\n  StringMatchResultListener listener2;\n  EXPECT_FALSE(m.MatchAndExplain(-9, &listener2));\n  EXPECT_EQ(\"which is 9 less than 0\", listener2.str());\n}\n\n// Tests that a C-string literal can be implicitly converted to a\n// Matcher<string> or Matcher<const string&>.\nTEST(StringMatcherTest, CanBeImplicitlyConstructedFromCStringLiteral) {\n  Matcher<string> m1 = \"hi\";\n  EXPECT_TRUE(m1.Matches(\"hi\"));\n  EXPECT_FALSE(m1.Matches(\"hello\"));\n\n  Matcher<const string&> m2 = \"hi\";\n  EXPECT_TRUE(m2.Matches(\"hi\"));\n  EXPECT_FALSE(m2.Matches(\"hello\"));\n}\n\n// Tests that a string object can be implicitly converted to a\n// Matcher<string> or Matcher<const string&>.\nTEST(StringMatcherTest, CanBeImplicitlyConstructedFromString) {\n  Matcher<string> m1 = string(\"hi\");\n  EXPECT_TRUE(m1.Matches(\"hi\"));\n  EXPECT_FALSE(m1.Matches(\"hello\"));\n\n  Matcher<const string&> m2 = string(\"hi\");\n  EXPECT_TRUE(m2.Matches(\"hi\"));\n  EXPECT_FALSE(m2.Matches(\"hello\"));\n}\n\n#if GTEST_HAS_STRING_PIECE_\n// Tests that a C-string literal can be implicitly converted to a\n// Matcher<StringPiece> or Matcher<const StringPiece&>.\nTEST(StringPieceMatcherTest, CanBeImplicitlyConstructedFromCStringLiteral) {\n  Matcher<StringPiece> m1 = \"cats\";\n  EXPECT_TRUE(m1.Matches(\"cats\"));\n  EXPECT_FALSE(m1.Matches(\"dogs\"));\n\n  Matcher<const StringPiece&> m2 = \"cats\";\n  EXPECT_TRUE(m2.Matches(\"cats\"));\n  EXPECT_FALSE(m2.Matches(\"dogs\"));\n}\n\n// Tests that a string object can be implicitly converted to a\n// Matcher<StringPiece> or Matcher<const StringPiece&>.\nTEST(StringPieceMatcherTest, CanBeImplicitlyConstructedFromString) {\n  Matcher<StringPiece> m1 = string(\"cats\");\n  EXPECT_TRUE(m1.Matches(\"cats\"));\n  EXPECT_FALSE(m1.Matches(\"dogs\"));\n\n  Matcher<const StringPiece&> m2 = string(\"cats\");\n  EXPECT_TRUE(m2.Matches(\"cats\"));\n  EXPECT_FALSE(m2.Matches(\"dogs\"));\n}\n\n// Tests that a StringPiece object can be implicitly converted to a\n// Matcher<StringPiece> or Matcher<const StringPiece&>.\nTEST(StringPieceMatcherTest, CanBeImplicitlyConstructedFromStringPiece) {\n  Matcher<StringPiece> m1 = StringPiece(\"cats\");\n  EXPECT_TRUE(m1.Matches(\"cats\"));\n  EXPECT_FALSE(m1.Matches(\"dogs\"));\n\n  Matcher<const StringPiece&> m2 = StringPiece(\"cats\");\n  EXPECT_TRUE(m2.Matches(\"cats\"));\n  EXPECT_FALSE(m2.Matches(\"dogs\"));\n}\n#endif  // GTEST_HAS_STRING_PIECE_\n\n// Tests that MakeMatcher() constructs a Matcher<T> from a\n// MatcherInterface* without requiring the user to explicitly\n// write the type.\nTEST(MakeMatcherTest, ConstructsMatcherFromMatcherInterface) {\n  const MatcherInterface<int>* dummy_impl = NULL;\n  Matcher<int> m = MakeMatcher(dummy_impl);\n}\n\n// Tests that MakePolymorphicMatcher() can construct a polymorphic\n// matcher from its implementation using the old API.\nconst int g_bar = 1;\nclass ReferencesBarOrIsZeroImpl {\n public:\n  template <typename T>\n  bool MatchAndExplain(const T& x,\n                       MatchResultListener* /* listener */) const {\n    const void* p = &x;\n    return p == &g_bar || x == 0;\n  }\n\n  void DescribeTo(ostream* os) const { *os << \"g_bar or zero\"; }\n\n  void DescribeNegationTo(ostream* os) const {\n    *os << \"doesn't reference g_bar and is not zero\";\n  }\n};\n\n// This function verifies that MakePolymorphicMatcher() returns a\n// PolymorphicMatcher<T> where T is the argument's type.\nPolymorphicMatcher<ReferencesBarOrIsZeroImpl> ReferencesBarOrIsZero() {\n  return MakePolymorphicMatcher(ReferencesBarOrIsZeroImpl());\n}\n\nTEST(MakePolymorphicMatcherTest, ConstructsMatcherUsingOldAPI) {\n  // Using a polymorphic matcher to match a reference type.\n  Matcher<const int&> m1 = ReferencesBarOrIsZero();\n  EXPECT_TRUE(m1.Matches(0));\n  // Verifies that the identity of a by-reference argument is preserved.\n  EXPECT_TRUE(m1.Matches(g_bar));\n  EXPECT_FALSE(m1.Matches(1));\n  EXPECT_EQ(\"g_bar or zero\", Describe(m1));\n\n  // Using a polymorphic matcher to match a value type.\n  Matcher<double> m2 = ReferencesBarOrIsZero();\n  EXPECT_TRUE(m2.Matches(0.0));\n  EXPECT_FALSE(m2.Matches(0.1));\n  EXPECT_EQ(\"g_bar or zero\", Describe(m2));\n}\n\n// Tests implementing a polymorphic matcher using MatchAndExplain().\n\nclass PolymorphicIsEvenImpl {\n public:\n  void DescribeTo(ostream* os) const { *os << \"is even\"; }\n\n  void DescribeNegationTo(ostream* os) const {\n    *os << \"is odd\";\n  }\n\n  template <typename T>\n  bool MatchAndExplain(const T& x, MatchResultListener* listener) const {\n    // Verifies that we can stream to the listener directly.\n    *listener << \"% \" << 2;\n    if (listener->stream() != NULL) {\n      // Verifies that we can stream to the listener's underlying stream\n      // too.\n      *listener->stream() << \" == \" << (x % 2);\n    }\n    return (x % 2) == 0;\n  }\n};\n\nPolymorphicMatcher<PolymorphicIsEvenImpl> PolymorphicIsEven() {\n  return MakePolymorphicMatcher(PolymorphicIsEvenImpl());\n}\n\nTEST(MakePolymorphicMatcherTest, ConstructsMatcherUsingNewAPI) {\n  // Using PolymorphicIsEven() as a Matcher<int>.\n  const Matcher<int> m1 = PolymorphicIsEven();\n  EXPECT_TRUE(m1.Matches(42));\n  EXPECT_FALSE(m1.Matches(43));\n  EXPECT_EQ(\"is even\", Describe(m1));\n\n  const Matcher<int> not_m1 = Not(m1);\n  EXPECT_EQ(\"is odd\", Describe(not_m1));\n\n  EXPECT_EQ(\"% 2 == 0\", Explain(m1, 42));\n\n  // Using PolymorphicIsEven() as a Matcher<char>.\n  const Matcher<char> m2 = PolymorphicIsEven();\n  EXPECT_TRUE(m2.Matches('\\x42'));\n  EXPECT_FALSE(m2.Matches('\\x43'));\n  EXPECT_EQ(\"is even\", Describe(m2));\n\n  const Matcher<char> not_m2 = Not(m2);\n  EXPECT_EQ(\"is odd\", Describe(not_m2));\n\n  EXPECT_EQ(\"% 2 == 0\", Explain(m2, '\\x42'));\n}\n\n// Tests that MatcherCast<T>(m) works when m is a polymorphic matcher.\nTEST(MatcherCastTest, FromPolymorphicMatcher) {\n  Matcher<int> m = MatcherCast<int>(Eq(5));\n  EXPECT_TRUE(m.Matches(5));\n  EXPECT_FALSE(m.Matches(6));\n}\n\n// For testing casting matchers between compatible types.\nclass IntValue {\n public:\n  // An int can be statically (although not implicitly) cast to a\n  // IntValue.\n  explicit IntValue(int a_value) : value_(a_value) {}\n\n  int value() const { return value_; }\n private:\n  int value_;\n};\n\n// For testing casting matchers between compatible types.\nbool IsPositiveIntValue(const IntValue& foo) {\n  return foo.value() > 0;\n}\n\n// Tests that MatcherCast<T>(m) works when m is a Matcher<U> where T\n// can be statically converted to U.\nTEST(MatcherCastTest, FromCompatibleType) {\n  Matcher<double> m1 = Eq(2.0);\n  Matcher<int> m2 = MatcherCast<int>(m1);\n  EXPECT_TRUE(m2.Matches(2));\n  EXPECT_FALSE(m2.Matches(3));\n\n  Matcher<IntValue> m3 = Truly(IsPositiveIntValue);\n  Matcher<int> m4 = MatcherCast<int>(m3);\n  // In the following, the arguments 1 and 0 are statically converted\n  // to IntValue objects, and then tested by the IsPositiveIntValue()\n  // predicate.\n  EXPECT_TRUE(m4.Matches(1));\n  EXPECT_FALSE(m4.Matches(0));\n}\n\n// Tests that MatcherCast<T>(m) works when m is a Matcher<const T&>.\nTEST(MatcherCastTest, FromConstReferenceToNonReference) {\n  Matcher<const int&> m1 = Eq(0);\n  Matcher<int> m2 = MatcherCast<int>(m1);\n  EXPECT_TRUE(m2.Matches(0));\n  EXPECT_FALSE(m2.Matches(1));\n}\n\n// Tests that MatcherCast<T>(m) works when m is a Matcher<T&>.\nTEST(MatcherCastTest, FromReferenceToNonReference) {\n  Matcher<int&> m1 = Eq(0);\n  Matcher<int> m2 = MatcherCast<int>(m1);\n  EXPECT_TRUE(m2.Matches(0));\n  EXPECT_FALSE(m2.Matches(1));\n}\n\n// Tests that MatcherCast<const T&>(m) works when m is a Matcher<T>.\nTEST(MatcherCastTest, FromNonReferenceToConstReference) {\n  Matcher<int> m1 = Eq(0);\n  Matcher<const int&> m2 = MatcherCast<const int&>(m1);\n  EXPECT_TRUE(m2.Matches(0));\n  EXPECT_FALSE(m2.Matches(1));\n}\n\n// Tests that MatcherCast<T&>(m) works when m is a Matcher<T>.\nTEST(MatcherCastTest, FromNonReferenceToReference) {\n  Matcher<int> m1 = Eq(0);\n  Matcher<int&> m2 = MatcherCast<int&>(m1);\n  int n = 0;\n  EXPECT_TRUE(m2.Matches(n));\n  n = 1;\n  EXPECT_FALSE(m2.Matches(n));\n}\n\n// Tests that MatcherCast<T>(m) works when m is a Matcher<T>.\nTEST(MatcherCastTest, FromSameType) {\n  Matcher<int> m1 = Eq(0);\n  Matcher<int> m2 = MatcherCast<int>(m1);\n  EXPECT_TRUE(m2.Matches(0));\n  EXPECT_FALSE(m2.Matches(1));\n}\n\n// Implicitly convertible form any type.\nstruct ConvertibleFromAny {\n  ConvertibleFromAny(int a_value) : value(a_value) {}\n  template <typename T>\n  ConvertibleFromAny(const T& a_value) : value(-1) {\n    ADD_FAILURE() << \"Conversion constructor called\";\n  }\n  int value;\n};\n\nbool operator==(const ConvertibleFromAny& a, const ConvertibleFromAny& b) {\n  return a.value == b.value;\n}\n\nostream& operator<<(ostream& os, const ConvertibleFromAny& a) {\n  return os << a.value;\n}\n\nTEST(MatcherCastTest, ConversionConstructorIsUsed) {\n  Matcher<ConvertibleFromAny> m = MatcherCast<ConvertibleFromAny>(1);\n  EXPECT_TRUE(m.Matches(ConvertibleFromAny(1)));\n  EXPECT_FALSE(m.Matches(ConvertibleFromAny(2)));\n}\n\nTEST(MatcherCastTest, FromConvertibleFromAny) {\n  Matcher<ConvertibleFromAny> m =\n      MatcherCast<ConvertibleFromAny>(Eq(ConvertibleFromAny(1)));\n  EXPECT_TRUE(m.Matches(ConvertibleFromAny(1)));\n  EXPECT_FALSE(m.Matches(ConvertibleFromAny(2)));\n}\n\nclass Base {};\nclass Derived : public Base {};\n\n// Tests that SafeMatcherCast<T>(m) works when m is a polymorphic matcher.\nTEST(SafeMatcherCastTest, FromPolymorphicMatcher) {\n  Matcher<char> m2 = SafeMatcherCast<char>(Eq(32));\n  EXPECT_TRUE(m2.Matches(' '));\n  EXPECT_FALSE(m2.Matches('\\n'));\n}\n\n// Tests that SafeMatcherCast<T>(m) works when m is a Matcher<U> where\n// T and U are arithmetic types and T can be losslessly converted to\n// U.\nTEST(SafeMatcherCastTest, FromLosslesslyConvertibleArithmeticType) {\n  Matcher<double> m1 = DoubleEq(1.0);\n  Matcher<float> m2 = SafeMatcherCast<float>(m1);\n  EXPECT_TRUE(m2.Matches(1.0f));\n  EXPECT_FALSE(m2.Matches(2.0f));\n\n  Matcher<char> m3 = SafeMatcherCast<char>(TypedEq<int>('a'));\n  EXPECT_TRUE(m3.Matches('a'));\n  EXPECT_FALSE(m3.Matches('b'));\n}\n\n// Tests that SafeMatcherCast<T>(m) works when m is a Matcher<U> where T and U\n// are pointers or references to a derived and a base class, correspondingly.\nTEST(SafeMatcherCastTest, FromBaseClass) {\n  Derived d, d2;\n  Matcher<Base*> m1 = Eq(&d);\n  Matcher<Derived*> m2 = SafeMatcherCast<Derived*>(m1);\n  EXPECT_TRUE(m2.Matches(&d));\n  EXPECT_FALSE(m2.Matches(&d2));\n\n  Matcher<Base&> m3 = Ref(d);\n  Matcher<Derived&> m4 = SafeMatcherCast<Derived&>(m3);\n  EXPECT_TRUE(m4.Matches(d));\n  EXPECT_FALSE(m4.Matches(d2));\n}\n\n// Tests that SafeMatcherCast<T&>(m) works when m is a Matcher<const T&>.\nTEST(SafeMatcherCastTest, FromConstReferenceToReference) {\n  int n = 0;\n  Matcher<const int&> m1 = Ref(n);\n  Matcher<int&> m2 = SafeMatcherCast<int&>(m1);\n  int n1 = 0;\n  EXPECT_TRUE(m2.Matches(n));\n  EXPECT_FALSE(m2.Matches(n1));\n}\n\n// Tests that MatcherCast<const T&>(m) works when m is a Matcher<T>.\nTEST(SafeMatcherCastTest, FromNonReferenceToConstReference) {\n  Matcher<int> m1 = Eq(0);\n  Matcher<const int&> m2 = SafeMatcherCast<const int&>(m1);\n  EXPECT_TRUE(m2.Matches(0));\n  EXPECT_FALSE(m2.Matches(1));\n}\n\n// Tests that SafeMatcherCast<T&>(m) works when m is a Matcher<T>.\nTEST(SafeMatcherCastTest, FromNonReferenceToReference) {\n  Matcher<int> m1 = Eq(0);\n  Matcher<int&> m2 = SafeMatcherCast<int&>(m1);\n  int n = 0;\n  EXPECT_TRUE(m2.Matches(n));\n  n = 1;\n  EXPECT_FALSE(m2.Matches(n));\n}\n\n// Tests that SafeMatcherCast<T>(m) works when m is a Matcher<T>.\nTEST(SafeMatcherCastTest, FromSameType) {\n  Matcher<int> m1 = Eq(0);\n  Matcher<int> m2 = SafeMatcherCast<int>(m1);\n  EXPECT_TRUE(m2.Matches(0));\n  EXPECT_FALSE(m2.Matches(1));\n}\n\nTEST(SafeMatcherCastTest, ConversionConstructorIsUsed) {\n  Matcher<ConvertibleFromAny> m = SafeMatcherCast<ConvertibleFromAny>(1);\n  EXPECT_TRUE(m.Matches(ConvertibleFromAny(1)));\n  EXPECT_FALSE(m.Matches(ConvertibleFromAny(2)));\n}\n\nTEST(SafeMatcherCastTest, FromConvertibleFromAny) {\n  Matcher<ConvertibleFromAny> m =\n      SafeMatcherCast<ConvertibleFromAny>(Eq(ConvertibleFromAny(1)));\n  EXPECT_TRUE(m.Matches(ConvertibleFromAny(1)));\n  EXPECT_FALSE(m.Matches(ConvertibleFromAny(2)));\n}\n\n// Tests that A<T>() matches any value of type T.\nTEST(ATest, MatchesAnyValue) {\n  // Tests a matcher for a value type.\n  Matcher<double> m1 = A<double>();\n  EXPECT_TRUE(m1.Matches(91.43));\n  EXPECT_TRUE(m1.Matches(-15.32));\n\n  // Tests a matcher for a reference type.\n  int a = 2;\n  int b = -6;\n  Matcher<int&> m2 = A<int&>();\n  EXPECT_TRUE(m2.Matches(a));\n  EXPECT_TRUE(m2.Matches(b));\n}\n\nTEST(ATest, WorksForDerivedClass) {\n  Base base;\n  Derived derived;\n  EXPECT_THAT(&base, A<Base*>());\n  // This shouldn't compile: EXPECT_THAT(&base, A<Derived*>());\n  EXPECT_THAT(&derived, A<Base*>());\n  EXPECT_THAT(&derived, A<Derived*>());\n}\n\n// Tests that A<T>() describes itself properly.\nTEST(ATest, CanDescribeSelf) {\n  EXPECT_EQ(\"is anything\", Describe(A<bool>()));\n}\n\n// Tests that An<T>() matches any value of type T.\nTEST(AnTest, MatchesAnyValue) {\n  // Tests a matcher for a value type.\n  Matcher<int> m1 = An<int>();\n  EXPECT_TRUE(m1.Matches(9143));\n  EXPECT_TRUE(m1.Matches(-1532));\n\n  // Tests a matcher for a reference type.\n  int a = 2;\n  int b = -6;\n  Matcher<int&> m2 = An<int&>();\n  EXPECT_TRUE(m2.Matches(a));\n  EXPECT_TRUE(m2.Matches(b));\n}\n\n// Tests that An<T>() describes itself properly.\nTEST(AnTest, CanDescribeSelf) {\n  EXPECT_EQ(\"is anything\", Describe(An<int>()));\n}\n\n// Tests that _ can be used as a matcher for any type and matches any\n// value of that type.\nTEST(UnderscoreTest, MatchesAnyValue) {\n  // Uses _ as a matcher for a value type.\n  Matcher<int> m1 = _;\n  EXPECT_TRUE(m1.Matches(123));\n  EXPECT_TRUE(m1.Matches(-242));\n\n  // Uses _ as a matcher for a reference type.\n  bool a = false;\n  const bool b = true;\n  Matcher<const bool&> m2 = _;\n  EXPECT_TRUE(m2.Matches(a));\n  EXPECT_TRUE(m2.Matches(b));\n}\n\n// Tests that _ describes itself properly.\nTEST(UnderscoreTest, CanDescribeSelf) {\n  Matcher<int> m = _;\n  EXPECT_EQ(\"is anything\", Describe(m));\n}\n\n// Tests that Eq(x) matches any value equal to x.\nTEST(EqTest, MatchesEqualValue) {\n  // 2 C-strings with same content but different addresses.\n  const char a1[] = \"hi\";\n  const char a2[] = \"hi\";\n\n  Matcher<const char*> m1 = Eq(a1);\n  EXPECT_TRUE(m1.Matches(a1));\n  EXPECT_FALSE(m1.Matches(a2));\n}\n\n// Tests that Eq(v) describes itself properly.\n\nclass Unprintable {\n public:\n  Unprintable() : c_('a') {}\n\n  bool operator==(const Unprintable& /* rhs */) { return true; }\n private:\n  char c_;\n};\n\nTEST(EqTest, CanDescribeSelf) {\n  Matcher<Unprintable> m = Eq(Unprintable());\n  EXPECT_EQ(\"is equal to 1-byte object <61>\", Describe(m));\n}\n\n// Tests that Eq(v) can be used to match any type that supports\n// comparing with type T, where T is v's type.\nTEST(EqTest, IsPolymorphic) {\n  Matcher<int> m1 = Eq(1);\n  EXPECT_TRUE(m1.Matches(1));\n  EXPECT_FALSE(m1.Matches(2));\n\n  Matcher<char> m2 = Eq(1);\n  EXPECT_TRUE(m2.Matches('\\1'));\n  EXPECT_FALSE(m2.Matches('a'));\n}\n\n// Tests that TypedEq<T>(v) matches values of type T that's equal to v.\nTEST(TypedEqTest, ChecksEqualityForGivenType) {\n  Matcher<char> m1 = TypedEq<char>('a');\n  EXPECT_TRUE(m1.Matches('a'));\n  EXPECT_FALSE(m1.Matches('b'));\n\n  Matcher<int> m2 = TypedEq<int>(6);\n  EXPECT_TRUE(m2.Matches(6));\n  EXPECT_FALSE(m2.Matches(7));\n}\n\n// Tests that TypedEq(v) describes itself properly.\nTEST(TypedEqTest, CanDescribeSelf) {\n  EXPECT_EQ(\"is equal to 2\", Describe(TypedEq<int>(2)));\n}\n\n// Tests that TypedEq<T>(v) has type Matcher<T>.\n\n// Type<T>::IsTypeOf(v) compiles iff the type of value v is T, where T\n// is a \"bare\" type (i.e. not in the form of const U or U&).  If v's\n// type is not T, the compiler will generate a message about\n// \"undefined referece\".\ntemplate <typename T>\nstruct Type {\n  static bool IsTypeOf(const T& /* v */) { return true; }\n\n  template <typename T2>\n  static void IsTypeOf(T2 v);\n};\n\nTEST(TypedEqTest, HasSpecifiedType) {\n  // Verfies that the type of TypedEq<T>(v) is Matcher<T>.\n  Type<Matcher<int> >::IsTypeOf(TypedEq<int>(5));\n  Type<Matcher<double> >::IsTypeOf(TypedEq<double>(5));\n}\n\n// Tests that Ge(v) matches anything >= v.\nTEST(GeTest, ImplementsGreaterThanOrEqual) {\n  Matcher<int> m1 = Ge(0);\n  EXPECT_TRUE(m1.Matches(1));\n  EXPECT_TRUE(m1.Matches(0));\n  EXPECT_FALSE(m1.Matches(-1));\n}\n\n// Tests that Ge(v) describes itself properly.\nTEST(GeTest, CanDescribeSelf) {\n  Matcher<int> m = Ge(5);\n  EXPECT_EQ(\"is >= 5\", Describe(m));\n}\n\n// Tests that Gt(v) matches anything > v.\nTEST(GtTest, ImplementsGreaterThan) {\n  Matcher<double> m1 = Gt(0);\n  EXPECT_TRUE(m1.Matches(1.0));\n  EXPECT_FALSE(m1.Matches(0.0));\n  EXPECT_FALSE(m1.Matches(-1.0));\n}\n\n// Tests that Gt(v) describes itself properly.\nTEST(GtTest, CanDescribeSelf) {\n  Matcher<int> m = Gt(5);\n  EXPECT_EQ(\"is > 5\", Describe(m));\n}\n\n// Tests that Le(v) matches anything <= v.\nTEST(LeTest, ImplementsLessThanOrEqual) {\n  Matcher<char> m1 = Le('b');\n  EXPECT_TRUE(m1.Matches('a'));\n  EXPECT_TRUE(m1.Matches('b'));\n  EXPECT_FALSE(m1.Matches('c'));\n}\n\n// Tests that Le(v) describes itself properly.\nTEST(LeTest, CanDescribeSelf) {\n  Matcher<int> m = Le(5);\n  EXPECT_EQ(\"is <= 5\", Describe(m));\n}\n\n// Tests that Lt(v) matches anything < v.\nTEST(LtTest, ImplementsLessThan) {\n  Matcher<const string&> m1 = Lt(\"Hello\");\n  EXPECT_TRUE(m1.Matches(\"Abc\"));\n  EXPECT_FALSE(m1.Matches(\"Hello\"));\n  EXPECT_FALSE(m1.Matches(\"Hello, world!\"));\n}\n\n// Tests that Lt(v) describes itself properly.\nTEST(LtTest, CanDescribeSelf) {\n  Matcher<int> m = Lt(5);\n  EXPECT_EQ(\"is < 5\", Describe(m));\n}\n\n// Tests that Ne(v) matches anything != v.\nTEST(NeTest, ImplementsNotEqual) {\n  Matcher<int> m1 = Ne(0);\n  EXPECT_TRUE(m1.Matches(1));\n  EXPECT_TRUE(m1.Matches(-1));\n  EXPECT_FALSE(m1.Matches(0));\n}\n\n// Tests that Ne(v) describes itself properly.\nTEST(NeTest, CanDescribeSelf) {\n  Matcher<int> m = Ne(5);\n  EXPECT_EQ(\"isn't equal to 5\", Describe(m));\n}\n\n// Tests that IsNull() matches any NULL pointer of any type.\nTEST(IsNullTest, MatchesNullPointer) {\n  Matcher<int*> m1 = IsNull();\n  int* p1 = NULL;\n  int n = 0;\n  EXPECT_TRUE(m1.Matches(p1));\n  EXPECT_FALSE(m1.Matches(&n));\n\n  Matcher<const char*> m2 = IsNull();\n  const char* p2 = NULL;\n  EXPECT_TRUE(m2.Matches(p2));\n  EXPECT_FALSE(m2.Matches(\"hi\"));\n\n#if !GTEST_OS_SYMBIAN\n  // Nokia's Symbian compiler generates:\n  // gmock-matchers.h: ambiguous access to overloaded function\n  // gmock-matchers.h: 'testing::Matcher<void *>::Matcher(void *)'\n  // gmock-matchers.h: 'testing::Matcher<void *>::Matcher(const testing::\n  //     MatcherInterface<void *> *)'\n  // gmock-matchers.h:  (point of instantiation: 'testing::\n  //     gmock_matchers_test::IsNullTest_MatchesNullPointer_Test::TestBody()')\n  // gmock-matchers.h:   (instantiating: 'testing::PolymorphicMatc\n  Matcher<void*> m3 = IsNull();\n  void* p3 = NULL;\n  EXPECT_TRUE(m3.Matches(p3));\n  EXPECT_FALSE(m3.Matches(reinterpret_cast<void*>(0xbeef)));\n#endif\n}\n\nTEST(IsNullTest, LinkedPtr) {\n  const Matcher<linked_ptr<int> > m = IsNull();\n  const linked_ptr<int> null_p;\n  const linked_ptr<int> non_null_p(new int);\n\n  EXPECT_TRUE(m.Matches(null_p));\n  EXPECT_FALSE(m.Matches(non_null_p));\n}\n\nTEST(IsNullTest, ReferenceToConstLinkedPtr) {\n  const Matcher<const linked_ptr<double>&> m = IsNull();\n  const linked_ptr<double> null_p;\n  const linked_ptr<double> non_null_p(new double);\n\n  EXPECT_TRUE(m.Matches(null_p));\n  EXPECT_FALSE(m.Matches(non_null_p));\n}\n\nTEST(IsNullTest, ReferenceToConstScopedPtr) {\n  const Matcher<const scoped_ptr<double>&> m = IsNull();\n  const scoped_ptr<double> null_p;\n  const scoped_ptr<double> non_null_p(new double);\n\n  EXPECT_TRUE(m.Matches(null_p));\n  EXPECT_FALSE(m.Matches(non_null_p));\n}\n\n// Tests that IsNull() describes itself properly.\nTEST(IsNullTest, CanDescribeSelf) {\n  Matcher<int*> m = IsNull();\n  EXPECT_EQ(\"is NULL\", Describe(m));\n  EXPECT_EQ(\"isn't NULL\", DescribeNegation(m));\n}\n\n// Tests that NotNull() matches any non-NULL pointer of any type.\nTEST(NotNullTest, MatchesNonNullPointer) {\n  Matcher<int*> m1 = NotNull();\n  int* p1 = NULL;\n  int n = 0;\n  EXPECT_FALSE(m1.Matches(p1));\n  EXPECT_TRUE(m1.Matches(&n));\n\n  Matcher<const char*> m2 = NotNull();\n  const char* p2 = NULL;\n  EXPECT_FALSE(m2.Matches(p2));\n  EXPECT_TRUE(m2.Matches(\"hi\"));\n}\n\nTEST(NotNullTest, LinkedPtr) {\n  const Matcher<linked_ptr<int> > m = NotNull();\n  const linked_ptr<int> null_p;\n  const linked_ptr<int> non_null_p(new int);\n\n  EXPECT_FALSE(m.Matches(null_p));\n  EXPECT_TRUE(m.Matches(non_null_p));\n}\n\nTEST(NotNullTest, ReferenceToConstLinkedPtr) {\n  const Matcher<const linked_ptr<double>&> m = NotNull();\n  const linked_ptr<double> null_p;\n  const linked_ptr<double> non_null_p(new double);\n\n  EXPECT_FALSE(m.Matches(null_p));\n  EXPECT_TRUE(m.Matches(non_null_p));\n}\n\nTEST(NotNullTest, ReferenceToConstScopedPtr) {\n  const Matcher<const scoped_ptr<double>&> m = NotNull();\n  const scoped_ptr<double> null_p;\n  const scoped_ptr<double> non_null_p(new double);\n\n  EXPECT_FALSE(m.Matches(null_p));\n  EXPECT_TRUE(m.Matches(non_null_p));\n}\n\n// Tests that NotNull() describes itself properly.\nTEST(NotNullTest, CanDescribeSelf) {\n  Matcher<int*> m = NotNull();\n  EXPECT_EQ(\"isn't NULL\", Describe(m));\n}\n\n// Tests that Ref(variable) matches an argument that references\n// 'variable'.\nTEST(RefTest, MatchesSameVariable) {\n  int a = 0;\n  int b = 0;\n  Matcher<int&> m = Ref(a);\n  EXPECT_TRUE(m.Matches(a));\n  EXPECT_FALSE(m.Matches(b));\n}\n\n// Tests that Ref(variable) describes itself properly.\nTEST(RefTest, CanDescribeSelf) {\n  int n = 5;\n  Matcher<int&> m = Ref(n);\n  stringstream ss;\n  ss << \"references the variable @\" << &n << \" 5\";\n  EXPECT_EQ(string(ss.str()), Describe(m));\n}\n\n// Test that Ref(non_const_varialbe) can be used as a matcher for a\n// const reference.\nTEST(RefTest, CanBeUsedAsMatcherForConstReference) {\n  int a = 0;\n  int b = 0;\n  Matcher<const int&> m = Ref(a);\n  EXPECT_TRUE(m.Matches(a));\n  EXPECT_FALSE(m.Matches(b));\n}\n\n// Tests that Ref(variable) is covariant, i.e. Ref(derived) can be\n// used wherever Ref(base) can be used (Ref(derived) is a sub-type\n// of Ref(base), but not vice versa.\n\nTEST(RefTest, IsCovariant) {\n  Base base, base2;\n  Derived derived;\n  Matcher<const Base&> m1 = Ref(base);\n  EXPECT_TRUE(m1.Matches(base));\n  EXPECT_FALSE(m1.Matches(base2));\n  EXPECT_FALSE(m1.Matches(derived));\n\n  m1 = Ref(derived);\n  EXPECT_TRUE(m1.Matches(derived));\n  EXPECT_FALSE(m1.Matches(base));\n  EXPECT_FALSE(m1.Matches(base2));\n}\n\nTEST(RefTest, ExplainsResult) {\n  int n = 0;\n  EXPECT_THAT(Explain(Matcher<const int&>(Ref(n)), n),\n              StartsWith(\"which is located @\"));\n\n  int m = 0;\n  EXPECT_THAT(Explain(Matcher<const int&>(Ref(n)), m),\n              StartsWith(\"which is located @\"));\n}\n\n// Tests string comparison matchers.\n\nTEST(StrEqTest, MatchesEqualString) {\n  Matcher<const char*> m = StrEq(string(\"Hello\"));\n  EXPECT_TRUE(m.Matches(\"Hello\"));\n  EXPECT_FALSE(m.Matches(\"hello\"));\n  EXPECT_FALSE(m.Matches(NULL));\n\n  Matcher<const string&> m2 = StrEq(\"Hello\");\n  EXPECT_TRUE(m2.Matches(\"Hello\"));\n  EXPECT_FALSE(m2.Matches(\"Hi\"));\n}\n\nTEST(StrEqTest, CanDescribeSelf) {\n  Matcher<string> m = StrEq(\"Hi-\\'\\\"?\\\\\\a\\b\\f\\n\\r\\t\\v\\xD3\");\n  EXPECT_EQ(\"is equal to \\\"Hi-\\'\\\\\\\"?\\\\\\\\\\\\a\\\\b\\\\f\\\\n\\\\r\\\\t\\\\v\\\\xD3\\\"\",\n      Describe(m));\n\n  string str(\"01204500800\");\n  str[3] = '\\0';\n  Matcher<string> m2 = StrEq(str);\n  EXPECT_EQ(\"is equal to \\\"012\\\\04500800\\\"\", Describe(m2));\n  str[0] = str[6] = str[7] = str[9] = str[10] = '\\0';\n  Matcher<string> m3 = StrEq(str);\n  EXPECT_EQ(\"is equal to \\\"\\\\012\\\\045\\\\0\\\\08\\\\0\\\\0\\\"\", Describe(m3));\n}\n\nTEST(StrNeTest, MatchesUnequalString) {\n  Matcher<const char*> m = StrNe(\"Hello\");\n  EXPECT_TRUE(m.Matches(\"\"));\n  EXPECT_TRUE(m.Matches(NULL));\n  EXPECT_FALSE(m.Matches(\"Hello\"));\n\n  Matcher<string> m2 = StrNe(string(\"Hello\"));\n  EXPECT_TRUE(m2.Matches(\"hello\"));\n  EXPECT_FALSE(m2.Matches(\"Hello\"));\n}\n\nTEST(StrNeTest, CanDescribeSelf) {\n  Matcher<const char*> m = StrNe(\"Hi\");\n  EXPECT_EQ(\"isn't equal to \\\"Hi\\\"\", Describe(m));\n}\n\nTEST(StrCaseEqTest, MatchesEqualStringIgnoringCase) {\n  Matcher<const char*> m = StrCaseEq(string(\"Hello\"));\n  EXPECT_TRUE(m.Matches(\"Hello\"));\n  EXPECT_TRUE(m.Matches(\"hello\"));\n  EXPECT_FALSE(m.Matches(\"Hi\"));\n  EXPECT_FALSE(m.Matches(NULL));\n\n  Matcher<const string&> m2 = StrCaseEq(\"Hello\");\n  EXPECT_TRUE(m2.Matches(\"hello\"));\n  EXPECT_FALSE(m2.Matches(\"Hi\"));\n}\n\nTEST(StrCaseEqTest, MatchesEqualStringWith0IgnoringCase) {\n  string str1(\"oabocdooeoo\");\n  string str2(\"OABOCDOOEOO\");\n  Matcher<const string&> m0 = StrCaseEq(str1);\n  EXPECT_FALSE(m0.Matches(str2 + string(1, '\\0')));\n\n  str1[3] = str2[3] = '\\0';\n  Matcher<const string&> m1 = StrCaseEq(str1);\n  EXPECT_TRUE(m1.Matches(str2));\n\n  str1[0] = str1[6] = str1[7] = str1[10] = '\\0';\n  str2[0] = str2[6] = str2[7] = str2[10] = '\\0';\n  Matcher<const string&> m2 = StrCaseEq(str1);\n  str1[9] = str2[9] = '\\0';\n  EXPECT_FALSE(m2.Matches(str2));\n\n  Matcher<const string&> m3 = StrCaseEq(str1);\n  EXPECT_TRUE(m3.Matches(str2));\n\n  EXPECT_FALSE(m3.Matches(str2 + \"x\"));\n  str2.append(1, '\\0');\n  EXPECT_FALSE(m3.Matches(str2));\n  EXPECT_FALSE(m3.Matches(string(str2, 0, 9)));\n}\n\nTEST(StrCaseEqTest, CanDescribeSelf) {\n  Matcher<string> m = StrCaseEq(\"Hi\");\n  EXPECT_EQ(\"is equal to (ignoring case) \\\"Hi\\\"\", Describe(m));\n}\n\nTEST(StrCaseNeTest, MatchesUnequalStringIgnoringCase) {\n  Matcher<const char*> m = StrCaseNe(\"Hello\");\n  EXPECT_TRUE(m.Matches(\"Hi\"));\n  EXPECT_TRUE(m.Matches(NULL));\n  EXPECT_FALSE(m.Matches(\"Hello\"));\n  EXPECT_FALSE(m.Matches(\"hello\"));\n\n  Matcher<string> m2 = StrCaseNe(string(\"Hello\"));\n  EXPECT_TRUE(m2.Matches(\"\"));\n  EXPECT_FALSE(m2.Matches(\"Hello\"));\n}\n\nTEST(StrCaseNeTest, CanDescribeSelf) {\n  Matcher<const char*> m = StrCaseNe(\"Hi\");\n  EXPECT_EQ(\"isn't equal to (ignoring case) \\\"Hi\\\"\", Describe(m));\n}\n\n// Tests that HasSubstr() works for matching string-typed values.\nTEST(HasSubstrTest, WorksForStringClasses) {\n  const Matcher<string> m1 = HasSubstr(\"foo\");\n  EXPECT_TRUE(m1.Matches(string(\"I love food.\")));\n  EXPECT_FALSE(m1.Matches(string(\"tofo\")));\n\n  const Matcher<const std::string&> m2 = HasSubstr(\"foo\");\n  EXPECT_TRUE(m2.Matches(std::string(\"I love food.\")));\n  EXPECT_FALSE(m2.Matches(std::string(\"tofo\")));\n}\n\n// Tests that HasSubstr() works for matching C-string-typed values.\nTEST(HasSubstrTest, WorksForCStrings) {\n  const Matcher<char*> m1 = HasSubstr(\"foo\");\n  EXPECT_TRUE(m1.Matches(const_cast<char*>(\"I love food.\")));\n  EXPECT_FALSE(m1.Matches(const_cast<char*>(\"tofo\")));\n  EXPECT_FALSE(m1.Matches(NULL));\n\n  const Matcher<const char*> m2 = HasSubstr(\"foo\");\n  EXPECT_TRUE(m2.Matches(\"I love food.\"));\n  EXPECT_FALSE(m2.Matches(\"tofo\"));\n  EXPECT_FALSE(m2.Matches(NULL));\n}\n\n// Tests that HasSubstr(s) describes itself properly.\nTEST(HasSubstrTest, CanDescribeSelf) {\n  Matcher<string> m = HasSubstr(\"foo\\n\\\"\");\n  EXPECT_EQ(\"has substring \\\"foo\\\\n\\\\\\\"\\\"\", Describe(m));\n}\n\nTEST(KeyTest, CanDescribeSelf) {\n  Matcher<const pair<std::string, int>&> m = Key(\"foo\");\n  EXPECT_EQ(\"has a key that is equal to \\\"foo\\\"\", Describe(m));\n  EXPECT_EQ(\"doesn't have a key that is equal to \\\"foo\\\"\", DescribeNegation(m));\n}\n\nTEST(KeyTest, ExplainsResult) {\n  Matcher<pair<int, bool> > m = Key(GreaterThan(10));\n  EXPECT_EQ(\"whose first field is a value which is 5 less than 10\",\n            Explain(m, make_pair(5, true)));\n  EXPECT_EQ(\"whose first field is a value which is 5 more than 10\",\n            Explain(m, make_pair(15, true)));\n}\n\nTEST(KeyTest, MatchesCorrectly) {\n  pair<int, std::string> p(25, \"foo\");\n  EXPECT_THAT(p, Key(25));\n  EXPECT_THAT(p, Not(Key(42)));\n  EXPECT_THAT(p, Key(Ge(20)));\n  EXPECT_THAT(p, Not(Key(Lt(25))));\n}\n\nTEST(KeyTest, SafelyCastsInnerMatcher) {\n  Matcher<int> is_positive = Gt(0);\n  Matcher<int> is_negative = Lt(0);\n  pair<char, bool> p('a', true);\n  EXPECT_THAT(p, Key(is_positive));\n  EXPECT_THAT(p, Not(Key(is_negative)));\n}\n\nTEST(KeyTest, InsideContainsUsingMap) {\n  map<int, char> container;\n  container.insert(make_pair(1, 'a'));\n  container.insert(make_pair(2, 'b'));\n  container.insert(make_pair(4, 'c'));\n  EXPECT_THAT(container, Contains(Key(1)));\n  EXPECT_THAT(container, Not(Contains(Key(3))));\n}\n\nTEST(KeyTest, InsideContainsUsingMultimap) {\n  multimap<int, char> container;\n  container.insert(make_pair(1, 'a'));\n  container.insert(make_pair(2, 'b'));\n  container.insert(make_pair(4, 'c'));\n\n  EXPECT_THAT(container, Not(Contains(Key(25))));\n  container.insert(make_pair(25, 'd'));\n  EXPECT_THAT(container, Contains(Key(25)));\n  container.insert(make_pair(25, 'e'));\n  EXPECT_THAT(container, Contains(Key(25)));\n\n  EXPECT_THAT(container, Contains(Key(1)));\n  EXPECT_THAT(container, Not(Contains(Key(3))));\n}\n\nTEST(PairTest, Typing) {\n  // Test verifies the following type conversions can be compiled.\n  Matcher<const pair<const char*, int>&> m1 = Pair(\"foo\", 42);\n  Matcher<const pair<const char*, int> > m2 = Pair(\"foo\", 42);\n  Matcher<pair<const char*, int> > m3 = Pair(\"foo\", 42);\n\n  Matcher<pair<int, const std::string> > m4 = Pair(25, \"42\");\n  Matcher<pair<const std::string, int> > m5 = Pair(\"25\", 42);\n}\n\nTEST(PairTest, CanDescribeSelf) {\n  Matcher<const pair<std::string, int>&> m1 = Pair(\"foo\", 42);\n  EXPECT_EQ(\"has a first field that is equal to \\\"foo\\\"\"\n            \", and has a second field that is equal to 42\",\n            Describe(m1));\n  EXPECT_EQ(\"has a first field that isn't equal to \\\"foo\\\"\"\n            \", or has a second field that isn't equal to 42\",\n            DescribeNegation(m1));\n  // Double and triple negation (1 or 2 times not and description of negation).\n  Matcher<const pair<int, int>&> m2 = Not(Pair(Not(13), 42));\n  EXPECT_EQ(\"has a first field that isn't equal to 13\"\n            \", and has a second field that is equal to 42\",\n            DescribeNegation(m2));\n}\n\nTEST(PairTest, CanExplainMatchResultTo) {\n  // If neither field matches, Pair() should explain about the first\n  // field.\n  const Matcher<pair<int, int> > m = Pair(GreaterThan(0), GreaterThan(0));\n  EXPECT_EQ(\"whose first field does not match, which is 1 less than 0\",\n            Explain(m, make_pair(-1, -2)));\n\n  // If the first field matches but the second doesn't, Pair() should\n  // explain about the second field.\n  EXPECT_EQ(\"whose second field does not match, which is 2 less than 0\",\n            Explain(m, make_pair(1, -2)));\n\n  // If the first field doesn't match but the second does, Pair()\n  // should explain about the first field.\n  EXPECT_EQ(\"whose first field does not match, which is 1 less than 0\",\n            Explain(m, make_pair(-1, 2)));\n\n  // If both fields match, Pair() should explain about them both.\n  EXPECT_EQ(\"whose both fields match, where the first field is a value \"\n            \"which is 1 more than 0, and the second field is a value \"\n            \"which is 2 more than 0\",\n            Explain(m, make_pair(1, 2)));\n\n  // If only the first match has an explanation, only this explanation should\n  // be printed.\n  const Matcher<pair<int, int> > explain_first = Pair(GreaterThan(0), 0);\n  EXPECT_EQ(\"whose both fields match, where the first field is a value \"\n            \"which is 1 more than 0\",\n            Explain(explain_first, make_pair(1, 0)));\n\n  // If only the second match has an explanation, only this explanation should\n  // be printed.\n  const Matcher<pair<int, int> > explain_second = Pair(0, GreaterThan(0));\n  EXPECT_EQ(\"whose both fields match, where the second field is a value \"\n            \"which is 1 more than 0\",\n            Explain(explain_second, make_pair(0, 1)));\n}\n\nTEST(PairTest, MatchesCorrectly) {\n  pair<int, std::string> p(25, \"foo\");\n\n  // Both fields match.\n  EXPECT_THAT(p, Pair(25, \"foo\"));\n  EXPECT_THAT(p, Pair(Ge(20), HasSubstr(\"o\")));\n\n  // 'first' doesnt' match, but 'second' matches.\n  EXPECT_THAT(p, Not(Pair(42, \"foo\")));\n  EXPECT_THAT(p, Not(Pair(Lt(25), \"foo\")));\n\n  // 'first' matches, but 'second' doesn't match.\n  EXPECT_THAT(p, Not(Pair(25, \"bar\")));\n  EXPECT_THAT(p, Not(Pair(25, Not(\"foo\"))));\n\n  // Neither field matches.\n  EXPECT_THAT(p, Not(Pair(13, \"bar\")));\n  EXPECT_THAT(p, Not(Pair(Lt(13), HasSubstr(\"a\"))));\n}\n\nTEST(PairTest, SafelyCastsInnerMatchers) {\n  Matcher<int> is_positive = Gt(0);\n  Matcher<int> is_negative = Lt(0);\n  pair<char, bool> p('a', true);\n  EXPECT_THAT(p, Pair(is_positive, _));\n  EXPECT_THAT(p, Not(Pair(is_negative, _)));\n  EXPECT_THAT(p, Pair(_, is_positive));\n  EXPECT_THAT(p, Not(Pair(_, is_negative)));\n}\n\nTEST(PairTest, InsideContainsUsingMap) {\n  map<int, char> container;\n  container.insert(make_pair(1, 'a'));\n  container.insert(make_pair(2, 'b'));\n  container.insert(make_pair(4, 'c'));\n  EXPECT_THAT(container, Contains(Pair(1, 'a')));\n  EXPECT_THAT(container, Contains(Pair(1, _)));\n  EXPECT_THAT(container, Contains(Pair(_, 'a')));\n  EXPECT_THAT(container, Not(Contains(Pair(3, _))));\n}\n\n// Tests StartsWith(s).\n\nTEST(StartsWithTest, MatchesStringWithGivenPrefix) {\n  const Matcher<const char*> m1 = StartsWith(string(\"\"));\n  EXPECT_TRUE(m1.Matches(\"Hi\"));\n  EXPECT_TRUE(m1.Matches(\"\"));\n  EXPECT_FALSE(m1.Matches(NULL));\n\n  const Matcher<const string&> m2 = StartsWith(\"Hi\");\n  EXPECT_TRUE(m2.Matches(\"Hi\"));\n  EXPECT_TRUE(m2.Matches(\"Hi Hi!\"));\n  EXPECT_TRUE(m2.Matches(\"High\"));\n  EXPECT_FALSE(m2.Matches(\"H\"));\n  EXPECT_FALSE(m2.Matches(\" Hi\"));\n}\n\nTEST(StartsWithTest, CanDescribeSelf) {\n  Matcher<const std::string> m = StartsWith(\"Hi\");\n  EXPECT_EQ(\"starts with \\\"Hi\\\"\", Describe(m));\n}\n\n// Tests EndsWith(s).\n\nTEST(EndsWithTest, MatchesStringWithGivenSuffix) {\n  const Matcher<const char*> m1 = EndsWith(\"\");\n  EXPECT_TRUE(m1.Matches(\"Hi\"));\n  EXPECT_TRUE(m1.Matches(\"\"));\n  EXPECT_FALSE(m1.Matches(NULL));\n\n  const Matcher<const string&> m2 = EndsWith(string(\"Hi\"));\n  EXPECT_TRUE(m2.Matches(\"Hi\"));\n  EXPECT_TRUE(m2.Matches(\"Wow Hi Hi\"));\n  EXPECT_TRUE(m2.Matches(\"Super Hi\"));\n  EXPECT_FALSE(m2.Matches(\"i\"));\n  EXPECT_FALSE(m2.Matches(\"Hi \"));\n}\n\nTEST(EndsWithTest, CanDescribeSelf) {\n  Matcher<const std::string> m = EndsWith(\"Hi\");\n  EXPECT_EQ(\"ends with \\\"Hi\\\"\", Describe(m));\n}\n\n// Tests MatchesRegex().\n\nTEST(MatchesRegexTest, MatchesStringMatchingGivenRegex) {\n  const Matcher<const char*> m1 = MatchesRegex(\"a.*z\");\n  EXPECT_TRUE(m1.Matches(\"az\"));\n  EXPECT_TRUE(m1.Matches(\"abcz\"));\n  EXPECT_FALSE(m1.Matches(NULL));\n\n  const Matcher<const string&> m2 = MatchesRegex(new RE(\"a.*z\"));\n  EXPECT_TRUE(m2.Matches(\"azbz\"));\n  EXPECT_FALSE(m2.Matches(\"az1\"));\n  EXPECT_FALSE(m2.Matches(\"1az\"));\n}\n\nTEST(MatchesRegexTest, CanDescribeSelf) {\n  Matcher<const std::string> m1 = MatchesRegex(string(\"Hi.*\"));\n  EXPECT_EQ(\"matches regular expression \\\"Hi.*\\\"\", Describe(m1));\n\n  Matcher<const char*> m2 = MatchesRegex(new RE(\"a.*\"));\n  EXPECT_EQ(\"matches regular expression \\\"a.*\\\"\", Describe(m2));\n}\n\n// Tests ContainsRegex().\n\nTEST(ContainsRegexTest, MatchesStringContainingGivenRegex) {\n  const Matcher<const char*> m1 = ContainsRegex(string(\"a.*z\"));\n  EXPECT_TRUE(m1.Matches(\"az\"));\n  EXPECT_TRUE(m1.Matches(\"0abcz1\"));\n  EXPECT_FALSE(m1.Matches(NULL));\n\n  const Matcher<const string&> m2 = ContainsRegex(new RE(\"a.*z\"));\n  EXPECT_TRUE(m2.Matches(\"azbz\"));\n  EXPECT_TRUE(m2.Matches(\"az1\"));\n  EXPECT_FALSE(m2.Matches(\"1a\"));\n}\n\nTEST(ContainsRegexTest, CanDescribeSelf) {\n  Matcher<const std::string> m1 = ContainsRegex(\"Hi.*\");\n  EXPECT_EQ(\"contains regular expression \\\"Hi.*\\\"\", Describe(m1));\n\n  Matcher<const char*> m2 = ContainsRegex(new RE(\"a.*\"));\n  EXPECT_EQ(\"contains regular expression \\\"a.*\\\"\", Describe(m2));\n}\n\n// Tests for wide strings.\n#if GTEST_HAS_STD_WSTRING\nTEST(StdWideStrEqTest, MatchesEqual) {\n  Matcher<const wchar_t*> m = StrEq(::std::wstring(L\"Hello\"));\n  EXPECT_TRUE(m.Matches(L\"Hello\"));\n  EXPECT_FALSE(m.Matches(L\"hello\"));\n  EXPECT_FALSE(m.Matches(NULL));\n\n  Matcher<const ::std::wstring&> m2 = StrEq(L\"Hello\");\n  EXPECT_TRUE(m2.Matches(L\"Hello\"));\n  EXPECT_FALSE(m2.Matches(L\"Hi\"));\n\n  Matcher<const ::std::wstring&> m3 = StrEq(L\"\\xD3\\x576\\x8D3\\xC74D\");\n  EXPECT_TRUE(m3.Matches(L\"\\xD3\\x576\\x8D3\\xC74D\"));\n  EXPECT_FALSE(m3.Matches(L\"\\xD3\\x576\\x8D3\\xC74E\"));\n\n  ::std::wstring str(L\"01204500800\");\n  str[3] = L'\\0';\n  Matcher<const ::std::wstring&> m4 = StrEq(str);\n  EXPECT_TRUE(m4.Matches(str));\n  str[0] = str[6] = str[7] = str[9] = str[10] = L'\\0';\n  Matcher<const ::std::wstring&> m5 = StrEq(str);\n  EXPECT_TRUE(m5.Matches(str));\n}\n\nTEST(StdWideStrEqTest, CanDescribeSelf) {\n  Matcher< ::std::wstring> m = StrEq(L\"Hi-\\'\\\"?\\\\\\a\\b\\f\\n\\r\\t\\v\");\n  EXPECT_EQ(\"is equal to L\\\"Hi-\\'\\\\\\\"?\\\\\\\\\\\\a\\\\b\\\\f\\\\n\\\\r\\\\t\\\\v\\\"\",\n    Describe(m));\n\n  Matcher< ::std::wstring> m2 = StrEq(L\"\\xD3\\x576\\x8D3\\xC74D\");\n  EXPECT_EQ(\"is equal to L\\\"\\\\xD3\\\\x576\\\\x8D3\\\\xC74D\\\"\",\n    Describe(m2));\n\n  ::std::wstring str(L\"01204500800\");\n  str[3] = L'\\0';\n  Matcher<const ::std::wstring&> m4 = StrEq(str);\n  EXPECT_EQ(\"is equal to L\\\"012\\\\04500800\\\"\", Describe(m4));\n  str[0] = str[6] = str[7] = str[9] = str[10] = L'\\0';\n  Matcher<const ::std::wstring&> m5 = StrEq(str);\n  EXPECT_EQ(\"is equal to L\\\"\\\\012\\\\045\\\\0\\\\08\\\\0\\\\0\\\"\", Describe(m5));\n}\n\nTEST(StdWideStrNeTest, MatchesUnequalString) {\n  Matcher<const wchar_t*> m = StrNe(L\"Hello\");\n  EXPECT_TRUE(m.Matches(L\"\"));\n  EXPECT_TRUE(m.Matches(NULL));\n  EXPECT_FALSE(m.Matches(L\"Hello\"));\n\n  Matcher< ::std::wstring> m2 = StrNe(::std::wstring(L\"Hello\"));\n  EXPECT_TRUE(m2.Matches(L\"hello\"));\n  EXPECT_FALSE(m2.Matches(L\"Hello\"));\n}\n\nTEST(StdWideStrNeTest, CanDescribeSelf) {\n  Matcher<const wchar_t*> m = StrNe(L\"Hi\");\n  EXPECT_EQ(\"isn't equal to L\\\"Hi\\\"\", Describe(m));\n}\n\nTEST(StdWideStrCaseEqTest, MatchesEqualStringIgnoringCase) {\n  Matcher<const wchar_t*> m = StrCaseEq(::std::wstring(L\"Hello\"));\n  EXPECT_TRUE(m.Matches(L\"Hello\"));\n  EXPECT_TRUE(m.Matches(L\"hello\"));\n  EXPECT_FALSE(m.Matches(L\"Hi\"));\n  EXPECT_FALSE(m.Matches(NULL));\n\n  Matcher<const ::std::wstring&> m2 = StrCaseEq(L\"Hello\");\n  EXPECT_TRUE(m2.Matches(L\"hello\"));\n  EXPECT_FALSE(m2.Matches(L\"Hi\"));\n}\n\nTEST(StdWideStrCaseEqTest, MatchesEqualStringWith0IgnoringCase) {\n  ::std::wstring str1(L\"oabocdooeoo\");\n  ::std::wstring str2(L\"OABOCDOOEOO\");\n  Matcher<const ::std::wstring&> m0 = StrCaseEq(str1);\n  EXPECT_FALSE(m0.Matches(str2 + ::std::wstring(1, L'\\0')));\n\n  str1[3] = str2[3] = L'\\0';\n  Matcher<const ::std::wstring&> m1 = StrCaseEq(str1);\n  EXPECT_TRUE(m1.Matches(str2));\n\n  str1[0] = str1[6] = str1[7] = str1[10] = L'\\0';\n  str2[0] = str2[6] = str2[7] = str2[10] = L'\\0';\n  Matcher<const ::std::wstring&> m2 = StrCaseEq(str1);\n  str1[9] = str2[9] = L'\\0';\n  EXPECT_FALSE(m2.Matches(str2));\n\n  Matcher<const ::std::wstring&> m3 = StrCaseEq(str1);\n  EXPECT_TRUE(m3.Matches(str2));\n\n  EXPECT_FALSE(m3.Matches(str2 + L\"x\"));\n  str2.append(1, L'\\0');\n  EXPECT_FALSE(m3.Matches(str2));\n  EXPECT_FALSE(m3.Matches(::std::wstring(str2, 0, 9)));\n}\n\nTEST(StdWideStrCaseEqTest, CanDescribeSelf) {\n  Matcher< ::std::wstring> m = StrCaseEq(L\"Hi\");\n  EXPECT_EQ(\"is equal to (ignoring case) L\\\"Hi\\\"\", Describe(m));\n}\n\nTEST(StdWideStrCaseNeTest, MatchesUnequalStringIgnoringCase) {\n  Matcher<const wchar_t*> m = StrCaseNe(L\"Hello\");\n  EXPECT_TRUE(m.Matches(L\"Hi\"));\n  EXPECT_TRUE(m.Matches(NULL));\n  EXPECT_FALSE(m.Matches(L\"Hello\"));\n  EXPECT_FALSE(m.Matches(L\"hello\"));\n\n  Matcher< ::std::wstring> m2 = StrCaseNe(::std::wstring(L\"Hello\"));\n  EXPECT_TRUE(m2.Matches(L\"\"));\n  EXPECT_FALSE(m2.Matches(L\"Hello\"));\n}\n\nTEST(StdWideStrCaseNeTest, CanDescribeSelf) {\n  Matcher<const wchar_t*> m = StrCaseNe(L\"Hi\");\n  EXPECT_EQ(\"isn't equal to (ignoring case) L\\\"Hi\\\"\", Describe(m));\n}\n\n// Tests that HasSubstr() works for matching wstring-typed values.\nTEST(StdWideHasSubstrTest, WorksForStringClasses) {\n  const Matcher< ::std::wstring> m1 = HasSubstr(L\"foo\");\n  EXPECT_TRUE(m1.Matches(::std::wstring(L\"I love food.\")));\n  EXPECT_FALSE(m1.Matches(::std::wstring(L\"tofo\")));\n\n  const Matcher<const ::std::wstring&> m2 = HasSubstr(L\"foo\");\n  EXPECT_TRUE(m2.Matches(::std::wstring(L\"I love food.\")));\n  EXPECT_FALSE(m2.Matches(::std::wstring(L\"tofo\")));\n}\n\n// Tests that HasSubstr() works for matching C-wide-string-typed values.\nTEST(StdWideHasSubstrTest, WorksForCStrings) {\n  const Matcher<wchar_t*> m1 = HasSubstr(L\"foo\");\n  EXPECT_TRUE(m1.Matches(const_cast<wchar_t*>(L\"I love food.\")));\n  EXPECT_FALSE(m1.Matches(const_cast<wchar_t*>(L\"tofo\")));\n  EXPECT_FALSE(m1.Matches(NULL));\n\n  const Matcher<const wchar_t*> m2 = HasSubstr(L\"foo\");\n  EXPECT_TRUE(m2.Matches(L\"I love food.\"));\n  EXPECT_FALSE(m2.Matches(L\"tofo\"));\n  EXPECT_FALSE(m2.Matches(NULL));\n}\n\n// Tests that HasSubstr(s) describes itself properly.\nTEST(StdWideHasSubstrTest, CanDescribeSelf) {\n  Matcher< ::std::wstring> m = HasSubstr(L\"foo\\n\\\"\");\n  EXPECT_EQ(\"has substring L\\\"foo\\\\n\\\\\\\"\\\"\", Describe(m));\n}\n\n// Tests StartsWith(s).\n\nTEST(StdWideStartsWithTest, MatchesStringWithGivenPrefix) {\n  const Matcher<const wchar_t*> m1 = StartsWith(::std::wstring(L\"\"));\n  EXPECT_TRUE(m1.Matches(L\"Hi\"));\n  EXPECT_TRUE(m1.Matches(L\"\"));\n  EXPECT_FALSE(m1.Matches(NULL));\n\n  const Matcher<const ::std::wstring&> m2 = StartsWith(L\"Hi\");\n  EXPECT_TRUE(m2.Matches(L\"Hi\"));\n  EXPECT_TRUE(m2.Matches(L\"Hi Hi!\"));\n  EXPECT_TRUE(m2.Matches(L\"High\"));\n  EXPECT_FALSE(m2.Matches(L\"H\"));\n  EXPECT_FALSE(m2.Matches(L\" Hi\"));\n}\n\nTEST(StdWideStartsWithTest, CanDescribeSelf) {\n  Matcher<const ::std::wstring> m = StartsWith(L\"Hi\");\n  EXPECT_EQ(\"starts with L\\\"Hi\\\"\", Describe(m));\n}\n\n// Tests EndsWith(s).\n\nTEST(StdWideEndsWithTest, MatchesStringWithGivenSuffix) {\n  const Matcher<const wchar_t*> m1 = EndsWith(L\"\");\n  EXPECT_TRUE(m1.Matches(L\"Hi\"));\n  EXPECT_TRUE(m1.Matches(L\"\"));\n  EXPECT_FALSE(m1.Matches(NULL));\n\n  const Matcher<const ::std::wstring&> m2 = EndsWith(::std::wstring(L\"Hi\"));\n  EXPECT_TRUE(m2.Matches(L\"Hi\"));\n  EXPECT_TRUE(m2.Matches(L\"Wow Hi Hi\"));\n  EXPECT_TRUE(m2.Matches(L\"Super Hi\"));\n  EXPECT_FALSE(m2.Matches(L\"i\"));\n  EXPECT_FALSE(m2.Matches(L\"Hi \"));\n}\n\nTEST(StdWideEndsWithTest, CanDescribeSelf) {\n  Matcher<const ::std::wstring> m = EndsWith(L\"Hi\");\n  EXPECT_EQ(\"ends with L\\\"Hi\\\"\", Describe(m));\n}\n\n#endif  // GTEST_HAS_STD_WSTRING\n\n#if GTEST_HAS_GLOBAL_WSTRING\nTEST(GlobalWideStrEqTest, MatchesEqual) {\n  Matcher<const wchar_t*> m = StrEq(::wstring(L\"Hello\"));\n  EXPECT_TRUE(m.Matches(L\"Hello\"));\n  EXPECT_FALSE(m.Matches(L\"hello\"));\n  EXPECT_FALSE(m.Matches(NULL));\n\n  Matcher<const ::wstring&> m2 = StrEq(L\"Hello\");\n  EXPECT_TRUE(m2.Matches(L\"Hello\"));\n  EXPECT_FALSE(m2.Matches(L\"Hi\"));\n\n  Matcher<const ::wstring&> m3 = StrEq(L\"\\xD3\\x576\\x8D3\\xC74D\");\n  EXPECT_TRUE(m3.Matches(L\"\\xD3\\x576\\x8D3\\xC74D\"));\n  EXPECT_FALSE(m3.Matches(L\"\\xD3\\x576\\x8D3\\xC74E\"));\n\n  ::wstring str(L\"01204500800\");\n  str[3] = L'\\0';\n  Matcher<const ::wstring&> m4 = StrEq(str);\n  EXPECT_TRUE(m4.Matches(str));\n  str[0] = str[6] = str[7] = str[9] = str[10] = L'\\0';\n  Matcher<const ::wstring&> m5 = StrEq(str);\n  EXPECT_TRUE(m5.Matches(str));\n}\n\nTEST(GlobalWideStrEqTest, CanDescribeSelf) {\n  Matcher< ::wstring> m = StrEq(L\"Hi-\\'\\\"?\\\\\\a\\b\\f\\n\\r\\t\\v\");\n  EXPECT_EQ(\"is equal to L\\\"Hi-\\'\\\\\\\"?\\\\\\\\\\\\a\\\\b\\\\f\\\\n\\\\r\\\\t\\\\v\\\"\",\n    Describe(m));\n\n  Matcher< ::wstring> m2 = StrEq(L\"\\xD3\\x576\\x8D3\\xC74D\");\n  EXPECT_EQ(\"is equal to L\\\"\\\\xD3\\\\x576\\\\x8D3\\\\xC74D\\\"\",\n    Describe(m2));\n\n  ::wstring str(L\"01204500800\");\n  str[3] = L'\\0';\n  Matcher<const ::wstring&> m4 = StrEq(str);\n  EXPECT_EQ(\"is equal to L\\\"012\\\\04500800\\\"\", Describe(m4));\n  str[0] = str[6] = str[7] = str[9] = str[10] = L'\\0';\n  Matcher<const ::wstring&> m5 = StrEq(str);\n  EXPECT_EQ(\"is equal to L\\\"\\\\012\\\\045\\\\0\\\\08\\\\0\\\\0\\\"\", Describe(m5));\n}\n\nTEST(GlobalWideStrNeTest, MatchesUnequalString) {\n  Matcher<const wchar_t*> m = StrNe(L\"Hello\");\n  EXPECT_TRUE(m.Matches(L\"\"));\n  EXPECT_TRUE(m.Matches(NULL));\n  EXPECT_FALSE(m.Matches(L\"Hello\"));\n\n  Matcher< ::wstring> m2 = StrNe(::wstring(L\"Hello\"));\n  EXPECT_TRUE(m2.Matches(L\"hello\"));\n  EXPECT_FALSE(m2.Matches(L\"Hello\"));\n}\n\nTEST(GlobalWideStrNeTest, CanDescribeSelf) {\n  Matcher<const wchar_t*> m = StrNe(L\"Hi\");\n  EXPECT_EQ(\"isn't equal to L\\\"Hi\\\"\", Describe(m));\n}\n\nTEST(GlobalWideStrCaseEqTest, MatchesEqualStringIgnoringCase) {\n  Matcher<const wchar_t*> m = StrCaseEq(::wstring(L\"Hello\"));\n  EXPECT_TRUE(m.Matches(L\"Hello\"));\n  EXPECT_TRUE(m.Matches(L\"hello\"));\n  EXPECT_FALSE(m.Matches(L\"Hi\"));\n  EXPECT_FALSE(m.Matches(NULL));\n\n  Matcher<const ::wstring&> m2 = StrCaseEq(L\"Hello\");\n  EXPECT_TRUE(m2.Matches(L\"hello\"));\n  EXPECT_FALSE(m2.Matches(L\"Hi\"));\n}\n\nTEST(GlobalWideStrCaseEqTest, MatchesEqualStringWith0IgnoringCase) {\n  ::wstring str1(L\"oabocdooeoo\");\n  ::wstring str2(L\"OABOCDOOEOO\");\n  Matcher<const ::wstring&> m0 = StrCaseEq(str1);\n  EXPECT_FALSE(m0.Matches(str2 + ::wstring(1, L'\\0')));\n\n  str1[3] = str2[3] = L'\\0';\n  Matcher<const ::wstring&> m1 = StrCaseEq(str1);\n  EXPECT_TRUE(m1.Matches(str2));\n\n  str1[0] = str1[6] = str1[7] = str1[10] = L'\\0';\n  str2[0] = str2[6] = str2[7] = str2[10] = L'\\0';\n  Matcher<const ::wstring&> m2 = StrCaseEq(str1);\n  str1[9] = str2[9] = L'\\0';\n  EXPECT_FALSE(m2.Matches(str2));\n\n  Matcher<const ::wstring&> m3 = StrCaseEq(str1);\n  EXPECT_TRUE(m3.Matches(str2));\n\n  EXPECT_FALSE(m3.Matches(str2 + L\"x\"));\n  str2.append(1, L'\\0');\n  EXPECT_FALSE(m3.Matches(str2));\n  EXPECT_FALSE(m3.Matches(::wstring(str2, 0, 9)));\n}\n\nTEST(GlobalWideStrCaseEqTest, CanDescribeSelf) {\n  Matcher< ::wstring> m = StrCaseEq(L\"Hi\");\n  EXPECT_EQ(\"is equal to (ignoring case) L\\\"Hi\\\"\", Describe(m));\n}\n\nTEST(GlobalWideStrCaseNeTest, MatchesUnequalStringIgnoringCase) {\n  Matcher<const wchar_t*> m = StrCaseNe(L\"Hello\");\n  EXPECT_TRUE(m.Matches(L\"Hi\"));\n  EXPECT_TRUE(m.Matches(NULL));\n  EXPECT_FALSE(m.Matches(L\"Hello\"));\n  EXPECT_FALSE(m.Matches(L\"hello\"));\n\n  Matcher< ::wstring> m2 = StrCaseNe(::wstring(L\"Hello\"));\n  EXPECT_TRUE(m2.Matches(L\"\"));\n  EXPECT_FALSE(m2.Matches(L\"Hello\"));\n}\n\nTEST(GlobalWideStrCaseNeTest, CanDescribeSelf) {\n  Matcher<const wchar_t*> m = StrCaseNe(L\"Hi\");\n  EXPECT_EQ(\"isn't equal to (ignoring case) L\\\"Hi\\\"\", Describe(m));\n}\n\n// Tests that HasSubstr() works for matching wstring-typed values.\nTEST(GlobalWideHasSubstrTest, WorksForStringClasses) {\n  const Matcher< ::wstring> m1 = HasSubstr(L\"foo\");\n  EXPECT_TRUE(m1.Matches(::wstring(L\"I love food.\")));\n  EXPECT_FALSE(m1.Matches(::wstring(L\"tofo\")));\n\n  const Matcher<const ::wstring&> m2 = HasSubstr(L\"foo\");\n  EXPECT_TRUE(m2.Matches(::wstring(L\"I love food.\")));\n  EXPECT_FALSE(m2.Matches(::wstring(L\"tofo\")));\n}\n\n// Tests that HasSubstr() works for matching C-wide-string-typed values.\nTEST(GlobalWideHasSubstrTest, WorksForCStrings) {\n  const Matcher<wchar_t*> m1 = HasSubstr(L\"foo\");\n  EXPECT_TRUE(m1.Matches(const_cast<wchar_t*>(L\"I love food.\")));\n  EXPECT_FALSE(m1.Matches(const_cast<wchar_t*>(L\"tofo\")));\n  EXPECT_FALSE(m1.Matches(NULL));\n\n  const Matcher<const wchar_t*> m2 = HasSubstr(L\"foo\");\n  EXPECT_TRUE(m2.Matches(L\"I love food.\"));\n  EXPECT_FALSE(m2.Matches(L\"tofo\"));\n  EXPECT_FALSE(m2.Matches(NULL));\n}\n\n// Tests that HasSubstr(s) describes itself properly.\nTEST(GlobalWideHasSubstrTest, CanDescribeSelf) {\n  Matcher< ::wstring> m = HasSubstr(L\"foo\\n\\\"\");\n  EXPECT_EQ(\"has substring L\\\"foo\\\\n\\\\\\\"\\\"\", Describe(m));\n}\n\n// Tests StartsWith(s).\n\nTEST(GlobalWideStartsWithTest, MatchesStringWithGivenPrefix) {\n  const Matcher<const wchar_t*> m1 = StartsWith(::wstring(L\"\"));\n  EXPECT_TRUE(m1.Matches(L\"Hi\"));\n  EXPECT_TRUE(m1.Matches(L\"\"));\n  EXPECT_FALSE(m1.Matches(NULL));\n\n  const Matcher<const ::wstring&> m2 = StartsWith(L\"Hi\");\n  EXPECT_TRUE(m2.Matches(L\"Hi\"));\n  EXPECT_TRUE(m2.Matches(L\"Hi Hi!\"));\n  EXPECT_TRUE(m2.Matches(L\"High\"));\n  EXPECT_FALSE(m2.Matches(L\"H\"));\n  EXPECT_FALSE(m2.Matches(L\" Hi\"));\n}\n\nTEST(GlobalWideStartsWithTest, CanDescribeSelf) {\n  Matcher<const ::wstring> m = StartsWith(L\"Hi\");\n  EXPECT_EQ(\"starts with L\\\"Hi\\\"\", Describe(m));\n}\n\n// Tests EndsWith(s).\n\nTEST(GlobalWideEndsWithTest, MatchesStringWithGivenSuffix) {\n  const Matcher<const wchar_t*> m1 = EndsWith(L\"\");\n  EXPECT_TRUE(m1.Matches(L\"Hi\"));\n  EXPECT_TRUE(m1.Matches(L\"\"));\n  EXPECT_FALSE(m1.Matches(NULL));\n\n  const Matcher<const ::wstring&> m2 = EndsWith(::wstring(L\"Hi\"));\n  EXPECT_TRUE(m2.Matches(L\"Hi\"));\n  EXPECT_TRUE(m2.Matches(L\"Wow Hi Hi\"));\n  EXPECT_TRUE(m2.Matches(L\"Super Hi\"));\n  EXPECT_FALSE(m2.Matches(L\"i\"));\n  EXPECT_FALSE(m2.Matches(L\"Hi \"));\n}\n\nTEST(GlobalWideEndsWithTest, CanDescribeSelf) {\n  Matcher<const ::wstring> m = EndsWith(L\"Hi\");\n  EXPECT_EQ(\"ends with L\\\"Hi\\\"\", Describe(m));\n}\n\n#endif  // GTEST_HAS_GLOBAL_WSTRING\n\n\ntypedef ::std::tr1::tuple<long, int> Tuple2;  // NOLINT\n\n// Tests that Eq() matches a 2-tuple where the first field == the\n// second field.\nTEST(Eq2Test, MatchesEqualArguments) {\n  Matcher<const Tuple2&> m = Eq();\n  EXPECT_TRUE(m.Matches(Tuple2(5L, 5)));\n  EXPECT_FALSE(m.Matches(Tuple2(5L, 6)));\n}\n\n// Tests that Eq() describes itself properly.\nTEST(Eq2Test, CanDescribeSelf) {\n  Matcher<const Tuple2&> m = Eq();\n  EXPECT_EQ(\"are an equal pair\", Describe(m));\n}\n\n// Tests that Ge() matches a 2-tuple where the first field >= the\n// second field.\nTEST(Ge2Test, MatchesGreaterThanOrEqualArguments) {\n  Matcher<const Tuple2&> m = Ge();\n  EXPECT_TRUE(m.Matches(Tuple2(5L, 4)));\n  EXPECT_TRUE(m.Matches(Tuple2(5L, 5)));\n  EXPECT_FALSE(m.Matches(Tuple2(5L, 6)));\n}\n\n// Tests that Ge() describes itself properly.\nTEST(Ge2Test, CanDescribeSelf) {\n  Matcher<const Tuple2&> m = Ge();\n  EXPECT_EQ(\"are a pair where the first >= the second\", Describe(m));\n}\n\n// Tests that Gt() matches a 2-tuple where the first field > the\n// second field.\nTEST(Gt2Test, MatchesGreaterThanArguments) {\n  Matcher<const Tuple2&> m = Gt();\n  EXPECT_TRUE(m.Matches(Tuple2(5L, 4)));\n  EXPECT_FALSE(m.Matches(Tuple2(5L, 5)));\n  EXPECT_FALSE(m.Matches(Tuple2(5L, 6)));\n}\n\n// Tests that Gt() describes itself properly.\nTEST(Gt2Test, CanDescribeSelf) {\n  Matcher<const Tuple2&> m = Gt();\n  EXPECT_EQ(\"are a pair where the first > the second\", Describe(m));\n}\n\n// Tests that Le() matches a 2-tuple where the first field <= the\n// second field.\nTEST(Le2Test, MatchesLessThanOrEqualArguments) {\n  Matcher<const Tuple2&> m = Le();\n  EXPECT_TRUE(m.Matches(Tuple2(5L, 6)));\n  EXPECT_TRUE(m.Matches(Tuple2(5L, 5)));\n  EXPECT_FALSE(m.Matches(Tuple2(5L, 4)));\n}\n\n// Tests that Le() describes itself properly.\nTEST(Le2Test, CanDescribeSelf) {\n  Matcher<const Tuple2&> m = Le();\n  EXPECT_EQ(\"are a pair where the first <= the second\", Describe(m));\n}\n\n// Tests that Lt() matches a 2-tuple where the first field < the\n// second field.\nTEST(Lt2Test, MatchesLessThanArguments) {\n  Matcher<const Tuple2&> m = Lt();\n  EXPECT_TRUE(m.Matches(Tuple2(5L, 6)));\n  EXPECT_FALSE(m.Matches(Tuple2(5L, 5)));\n  EXPECT_FALSE(m.Matches(Tuple2(5L, 4)));\n}\n\n// Tests that Lt() describes itself properly.\nTEST(Lt2Test, CanDescribeSelf) {\n  Matcher<const Tuple2&> m = Lt();\n  EXPECT_EQ(\"are a pair where the first < the second\", Describe(m));\n}\n\n// Tests that Ne() matches a 2-tuple where the first field != the\n// second field.\nTEST(Ne2Test, MatchesUnequalArguments) {\n  Matcher<const Tuple2&> m = Ne();\n  EXPECT_TRUE(m.Matches(Tuple2(5L, 6)));\n  EXPECT_TRUE(m.Matches(Tuple2(5L, 4)));\n  EXPECT_FALSE(m.Matches(Tuple2(5L, 5)));\n}\n\n// Tests that Ne() describes itself properly.\nTEST(Ne2Test, CanDescribeSelf) {\n  Matcher<const Tuple2&> m = Ne();\n  EXPECT_EQ(\"are an unequal pair\", Describe(m));\n}\n\n// Tests that Not(m) matches any value that doesn't match m.\nTEST(NotTest, NegatesMatcher) {\n  Matcher<int> m;\n  m = Not(Eq(2));\n  EXPECT_TRUE(m.Matches(3));\n  EXPECT_FALSE(m.Matches(2));\n}\n\n// Tests that Not(m) describes itself properly.\nTEST(NotTest, CanDescribeSelf) {\n  Matcher<int> m = Not(Eq(5));\n  EXPECT_EQ(\"isn't equal to 5\", Describe(m));\n}\n\n// Tests that monomorphic matchers are safely cast by the Not matcher.\nTEST(NotTest, NotMatcherSafelyCastsMonomorphicMatchers) {\n  // greater_than_5 is a monomorphic matcher.\n  Matcher<int> greater_than_5 = Gt(5);\n\n  Matcher<const int&> m = Not(greater_than_5);\n  Matcher<int&> m2 = Not(greater_than_5);\n  Matcher<int&> m3 = Not(m);\n}\n\n// Helper to allow easy testing of AllOf matchers with num parameters.\nvoid AllOfMatches(int num, const Matcher<int>& m) {\n  SCOPED_TRACE(Describe(m));\n  EXPECT_TRUE(m.Matches(0));\n  for (int i = 1; i <= num; ++i) {\n    EXPECT_FALSE(m.Matches(i));\n  }\n  EXPECT_TRUE(m.Matches(num + 1));\n}\n\n// Tests that AllOf(m1, ..., mn) matches any value that matches all of\n// the given matchers.\nTEST(AllOfTest, MatchesWhenAllMatch) {\n  Matcher<int> m;\n  m = AllOf(Le(2), Ge(1));\n  EXPECT_TRUE(m.Matches(1));\n  EXPECT_TRUE(m.Matches(2));\n  EXPECT_FALSE(m.Matches(0));\n  EXPECT_FALSE(m.Matches(3));\n\n  m = AllOf(Gt(0), Ne(1), Ne(2));\n  EXPECT_TRUE(m.Matches(3));\n  EXPECT_FALSE(m.Matches(2));\n  EXPECT_FALSE(m.Matches(1));\n  EXPECT_FALSE(m.Matches(0));\n\n  m = AllOf(Gt(0), Ne(1), Ne(2), Ne(3));\n  EXPECT_TRUE(m.Matches(4));\n  EXPECT_FALSE(m.Matches(3));\n  EXPECT_FALSE(m.Matches(2));\n  EXPECT_FALSE(m.Matches(1));\n  EXPECT_FALSE(m.Matches(0));\n\n  m = AllOf(Ge(0), Lt(10), Ne(3), Ne(5), Ne(7));\n  EXPECT_TRUE(m.Matches(0));\n  EXPECT_TRUE(m.Matches(1));\n  EXPECT_FALSE(m.Matches(3));\n\n  // The following tests for varying number of sub-matchers. Due to the way\n  // the sub-matchers are handled it is enough to test every sub-matcher once\n  // with sub-matchers using the same matcher type. Varying matcher types are\n  // checked for above.\n  AllOfMatches(2, AllOf(Ne(1), Ne(2)));\n  AllOfMatches(3, AllOf(Ne(1), Ne(2), Ne(3)));\n  AllOfMatches(4, AllOf(Ne(1), Ne(2), Ne(3), Ne(4)));\n  AllOfMatches(5, AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5)));\n  AllOfMatches(6, AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5), Ne(6)));\n  AllOfMatches(7, AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5), Ne(6), Ne(7)));\n  AllOfMatches(8, AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5), Ne(6), Ne(7),\n                        Ne(8)));\n  AllOfMatches(9, AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5), Ne(6), Ne(7),\n                        Ne(8), Ne(9)));\n  AllOfMatches(10, AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5), Ne(6), Ne(7), Ne(8),\n                         Ne(9), Ne(10)));\n}\n\n#if GTEST_LANG_CXX11\n// Tests the variadic version of the AllOfMatcher.\nTEST(AllOfTest, VariadicMatchesWhenAllMatch) {\n  // Make sure AllOf is defined in the right namespace and does not depend on\n  // ADL.\n  ::testing::AllOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);\n  Matcher<int> m = AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5), Ne(6), Ne(7), Ne(8),\n                         Ne(9), Ne(10), Ne(11));\n  EXPECT_THAT(Describe(m), EndsWith(\"and (isn't equal to 11))))))))))\"));\n  AllOfMatches(11, m);\n  AllOfMatches(50, AllOf(Ne(1), Ne(2), Ne(3), Ne(4), Ne(5), Ne(6), Ne(7), Ne(8),\n                         Ne(9), Ne(10), Ne(11), Ne(12), Ne(13), Ne(14), Ne(15),\n                         Ne(16), Ne(17), Ne(18), Ne(19), Ne(20), Ne(21), Ne(22),\n                         Ne(23), Ne(24), Ne(25), Ne(26), Ne(27), Ne(28), Ne(29),\n                         Ne(30), Ne(31), Ne(32), Ne(33), Ne(34), Ne(35), Ne(36),\n                         Ne(37), Ne(38), Ne(39), Ne(40), Ne(41), Ne(42), Ne(43),\n                         Ne(44), Ne(45), Ne(46), Ne(47), Ne(48), Ne(49),\n                         Ne(50)));\n}\n\n#endif  // GTEST_LANG_CXX11\n\n// Tests that AllOf(m1, ..., mn) describes itself properly.\nTEST(AllOfTest, CanDescribeSelf) {\n  Matcher<int> m;\n  m = AllOf(Le(2), Ge(1));\n  EXPECT_EQ(\"(is <= 2) and (is >= 1)\", Describe(m));\n\n  m = AllOf(Gt(0), Ne(1), Ne(2));\n  EXPECT_EQ(\"(is > 0) and \"\n            \"((isn't equal to 1) and \"\n            \"(isn't equal to 2))\",\n            Describe(m));\n\n\n  m = AllOf(Gt(0), Ne(1), Ne(2), Ne(3));\n  EXPECT_EQ(\"((is > 0) and \"\n            \"(isn't equal to 1)) and \"\n            \"((isn't equal to 2) and \"\n            \"(isn't equal to 3))\",\n            Describe(m));\n\n\n  m = AllOf(Ge(0), Lt(10), Ne(3), Ne(5), Ne(7));\n  EXPECT_EQ(\"((is >= 0) and \"\n            \"(is < 10)) and \"\n            \"((isn't equal to 3) and \"\n            \"((isn't equal to 5) and \"\n            \"(isn't equal to 7)))\",\n            Describe(m));\n}\n\n// Tests that AllOf(m1, ..., mn) describes its negation properly.\nTEST(AllOfTest, CanDescribeNegation) {\n  Matcher<int> m;\n  m = AllOf(Le(2), Ge(1));\n  EXPECT_EQ(\"(isn't <= 2) or \"\n            \"(isn't >= 1)\",\n            DescribeNegation(m));\n\n  m = AllOf(Gt(0), Ne(1), Ne(2));\n  EXPECT_EQ(\"(isn't > 0) or \"\n            \"((is equal to 1) or \"\n            \"(is equal to 2))\",\n            DescribeNegation(m));\n\n\n  m = AllOf(Gt(0), Ne(1), Ne(2), Ne(3));\n  EXPECT_EQ(\"((isn't > 0) or \"\n            \"(is equal to 1)) or \"\n            \"((is equal to 2) or \"\n            \"(is equal to 3))\",\n            DescribeNegation(m));\n\n\n  m = AllOf(Ge(0), Lt(10), Ne(3), Ne(5), Ne(7));\n  EXPECT_EQ(\"((isn't >= 0) or \"\n            \"(isn't < 10)) or \"\n            \"((is equal to 3) or \"\n            \"((is equal to 5) or \"\n            \"(is equal to 7)))\",\n            DescribeNegation(m));\n}\n\n// Tests that monomorphic matchers are safely cast by the AllOf matcher.\nTEST(AllOfTest, AllOfMatcherSafelyCastsMonomorphicMatchers) {\n  // greater_than_5 and less_than_10 are monomorphic matchers.\n  Matcher<int> greater_than_5 = Gt(5);\n  Matcher<int> less_than_10 = Lt(10);\n\n  Matcher<const int&> m = AllOf(greater_than_5, less_than_10);\n  Matcher<int&> m2 = AllOf(greater_than_5, less_than_10);\n  Matcher<int&> m3 = AllOf(greater_than_5, m2);\n\n  // Tests that BothOf works when composing itself.\n  Matcher<const int&> m4 = AllOf(greater_than_5, less_than_10, less_than_10);\n  Matcher<int&> m5 = AllOf(greater_than_5, less_than_10, less_than_10);\n}\n\nTEST(AllOfTest, ExplainsResult) {\n  Matcher<int> m;\n\n  // Successful match.  Both matchers need to explain.  The second\n  // matcher doesn't give an explanation, so only the first matcher's\n  // explanation is printed.\n  m = AllOf(GreaterThan(10), Lt(30));\n  EXPECT_EQ(\"which is 15 more than 10\", Explain(m, 25));\n\n  // Successful match.  Both matchers need to explain.\n  m = AllOf(GreaterThan(10), GreaterThan(20));\n  EXPECT_EQ(\"which is 20 more than 10, and which is 10 more than 20\",\n            Explain(m, 30));\n\n  // Successful match.  All matchers need to explain.  The second\n  // matcher doesn't given an explanation.\n  m = AllOf(GreaterThan(10), Lt(30), GreaterThan(20));\n  EXPECT_EQ(\"which is 15 more than 10, and which is 5 more than 20\",\n            Explain(m, 25));\n\n  // Successful match.  All matchers need to explain.\n  m = AllOf(GreaterThan(10), GreaterThan(20), GreaterThan(30));\n  EXPECT_EQ(\"which is 30 more than 10, and which is 20 more than 20, \"\n            \"and which is 10 more than 30\",\n            Explain(m, 40));\n\n  // Failed match.  The first matcher, which failed, needs to\n  // explain.\n  m = AllOf(GreaterThan(10), GreaterThan(20));\n  EXPECT_EQ(\"which is 5 less than 10\", Explain(m, 5));\n\n  // Failed match.  The second matcher, which failed, needs to\n  // explain.  Since it doesn't given an explanation, nothing is\n  // printed.\n  m = AllOf(GreaterThan(10), Lt(30));\n  EXPECT_EQ(\"\", Explain(m, 40));\n\n  // Failed match.  The second matcher, which failed, needs to\n  // explain.\n  m = AllOf(GreaterThan(10), GreaterThan(20));\n  EXPECT_EQ(\"which is 5 less than 20\", Explain(m, 15));\n}\n\n// Helper to allow easy testing of AnyOf matchers with num parameters.\nvoid AnyOfMatches(int num, const Matcher<int>& m) {\n  SCOPED_TRACE(Describe(m));\n  EXPECT_FALSE(m.Matches(0));\n  for (int i = 1; i <= num; ++i) {\n    EXPECT_TRUE(m.Matches(i));\n  }\n  EXPECT_FALSE(m.Matches(num + 1));\n}\n\n// Tests that AnyOf(m1, ..., mn) matches any value that matches at\n// least one of the given matchers.\nTEST(AnyOfTest, MatchesWhenAnyMatches) {\n  Matcher<int> m;\n  m = AnyOf(Le(1), Ge(3));\n  EXPECT_TRUE(m.Matches(1));\n  EXPECT_TRUE(m.Matches(4));\n  EXPECT_FALSE(m.Matches(2));\n\n  m = AnyOf(Lt(0), Eq(1), Eq(2));\n  EXPECT_TRUE(m.Matches(-1));\n  EXPECT_TRUE(m.Matches(1));\n  EXPECT_TRUE(m.Matches(2));\n  EXPECT_FALSE(m.Matches(0));\n\n  m = AnyOf(Lt(0), Eq(1), Eq(2), Eq(3));\n  EXPECT_TRUE(m.Matches(-1));\n  EXPECT_TRUE(m.Matches(1));\n  EXPECT_TRUE(m.Matches(2));\n  EXPECT_TRUE(m.Matches(3));\n  EXPECT_FALSE(m.Matches(0));\n\n  m = AnyOf(Le(0), Gt(10), 3, 5, 7);\n  EXPECT_TRUE(m.Matches(0));\n  EXPECT_TRUE(m.Matches(11));\n  EXPECT_TRUE(m.Matches(3));\n  EXPECT_FALSE(m.Matches(2));\n\n  // The following tests for varying number of sub-matchers. Due to the way\n  // the sub-matchers are handled it is enough to test every sub-matcher once\n  // with sub-matchers using the same matcher type. Varying matcher types are\n  // checked for above.\n  AnyOfMatches(2, AnyOf(1, 2));\n  AnyOfMatches(3, AnyOf(1, 2, 3));\n  AnyOfMatches(4, AnyOf(1, 2, 3, 4));\n  AnyOfMatches(5, AnyOf(1, 2, 3, 4, 5));\n  AnyOfMatches(6, AnyOf(1, 2, 3, 4, 5, 6));\n  AnyOfMatches(7, AnyOf(1, 2, 3, 4, 5, 6, 7));\n  AnyOfMatches(8, AnyOf(1, 2, 3, 4, 5, 6, 7, 8));\n  AnyOfMatches(9, AnyOf(1, 2, 3, 4, 5, 6, 7, 8, 9));\n  AnyOfMatches(10, AnyOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));\n}\n\n#if GTEST_LANG_CXX11\n// Tests the variadic version of the AnyOfMatcher.\nTEST(AnyOfTest, VariadicMatchesWhenAnyMatches) {\n  // Also make sure AnyOf is defined in the right namespace and does not depend\n  // on ADL.\n  Matcher<int> m = ::testing::AnyOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);\n\n  EXPECT_THAT(Describe(m), EndsWith(\"or (is equal to 11))))))))))\"));\n  AnyOfMatches(11, m);\n  AnyOfMatches(50, AnyOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10,\n                         11, 12, 13, 14, 15, 16, 17, 18, 19, 20,\n                         21, 22, 23, 24, 25, 26, 27, 28, 29, 30,\n                         31, 32, 33, 34, 35, 36, 37, 38, 39, 40,\n                         41, 42, 43, 44, 45, 46, 47, 48, 49, 50));\n}\n\n#endif  // GTEST_LANG_CXX11\n\n// Tests that AnyOf(m1, ..., mn) describes itself properly.\nTEST(AnyOfTest, CanDescribeSelf) {\n  Matcher<int> m;\n  m = AnyOf(Le(1), Ge(3));\n  EXPECT_EQ(\"(is <= 1) or (is >= 3)\",\n            Describe(m));\n\n  m = AnyOf(Lt(0), Eq(1), Eq(2));\n  EXPECT_EQ(\"(is < 0) or \"\n            \"((is equal to 1) or (is equal to 2))\",\n            Describe(m));\n\n  m = AnyOf(Lt(0), Eq(1), Eq(2), Eq(3));\n  EXPECT_EQ(\"((is < 0) or \"\n            \"(is equal to 1)) or \"\n            \"((is equal to 2) or \"\n            \"(is equal to 3))\",\n            Describe(m));\n\n  m = AnyOf(Le(0), Gt(10), 3, 5, 7);\n  EXPECT_EQ(\"((is <= 0) or \"\n            \"(is > 10)) or \"\n            \"((is equal to 3) or \"\n            \"((is equal to 5) or \"\n            \"(is equal to 7)))\",\n            Describe(m));\n}\n\n// Tests that AnyOf(m1, ..., mn) describes its negation properly.\nTEST(AnyOfTest, CanDescribeNegation) {\n  Matcher<int> m;\n  m = AnyOf(Le(1), Ge(3));\n  EXPECT_EQ(\"(isn't <= 1) and (isn't >= 3)\",\n            DescribeNegation(m));\n\n  m = AnyOf(Lt(0), Eq(1), Eq(2));\n  EXPECT_EQ(\"(isn't < 0) and \"\n            \"((isn't equal to 1) and (isn't equal to 2))\",\n            DescribeNegation(m));\n\n  m = AnyOf(Lt(0), Eq(1), Eq(2), Eq(3));\n  EXPECT_EQ(\"((isn't < 0) and \"\n            \"(isn't equal to 1)) and \"\n            \"((isn't equal to 2) and \"\n            \"(isn't equal to 3))\",\n            DescribeNegation(m));\n\n  m = AnyOf(Le(0), Gt(10), 3, 5, 7);\n  EXPECT_EQ(\"((isn't <= 0) and \"\n            \"(isn't > 10)) and \"\n            \"((isn't equal to 3) and \"\n            \"((isn't equal to 5) and \"\n            \"(isn't equal to 7)))\",\n            DescribeNegation(m));\n}\n\n// Tests that monomorphic matchers are safely cast by the AnyOf matcher.\nTEST(AnyOfTest, AnyOfMatcherSafelyCastsMonomorphicMatchers) {\n  // greater_than_5 and less_than_10 are monomorphic matchers.\n  Matcher<int> greater_than_5 = Gt(5);\n  Matcher<int> less_than_10 = Lt(10);\n\n  Matcher<const int&> m = AnyOf(greater_than_5, less_than_10);\n  Matcher<int&> m2 = AnyOf(greater_than_5, less_than_10);\n  Matcher<int&> m3 = AnyOf(greater_than_5, m2);\n\n  // Tests that EitherOf works when composing itself.\n  Matcher<const int&> m4 = AnyOf(greater_than_5, less_than_10, less_than_10);\n  Matcher<int&> m5 = AnyOf(greater_than_5, less_than_10, less_than_10);\n}\n\nTEST(AnyOfTest, ExplainsResult) {\n  Matcher<int> m;\n\n  // Failed match.  Both matchers need to explain.  The second\n  // matcher doesn't give an explanation, so only the first matcher's\n  // explanation is printed.\n  m = AnyOf(GreaterThan(10), Lt(0));\n  EXPECT_EQ(\"which is 5 less than 10\", Explain(m, 5));\n\n  // Failed match.  Both matchers need to explain.\n  m = AnyOf(GreaterThan(10), GreaterThan(20));\n  EXPECT_EQ(\"which is 5 less than 10, and which is 15 less than 20\",\n            Explain(m, 5));\n\n  // Failed match.  All matchers need to explain.  The second\n  // matcher doesn't given an explanation.\n  m = AnyOf(GreaterThan(10), Gt(20), GreaterThan(30));\n  EXPECT_EQ(\"which is 5 less than 10, and which is 25 less than 30\",\n            Explain(m, 5));\n\n  // Failed match.  All matchers need to explain.\n  m = AnyOf(GreaterThan(10), GreaterThan(20), GreaterThan(30));\n  EXPECT_EQ(\"which is 5 less than 10, and which is 15 less than 20, \"\n            \"and which is 25 less than 30\",\n            Explain(m, 5));\n\n  // Successful match.  The first matcher, which succeeded, needs to\n  // explain.\n  m = AnyOf(GreaterThan(10), GreaterThan(20));\n  EXPECT_EQ(\"which is 5 more than 10\", Explain(m, 15));\n\n  // Successful match.  The second matcher, which succeeded, needs to\n  // explain.  Since it doesn't given an explanation, nothing is\n  // printed.\n  m = AnyOf(GreaterThan(10), Lt(30));\n  EXPECT_EQ(\"\", Explain(m, 0));\n\n  // Successful match.  The second matcher, which succeeded, needs to\n  // explain.\n  m = AnyOf(GreaterThan(30), GreaterThan(20));\n  EXPECT_EQ(\"which is 5 more than 20\", Explain(m, 25));\n}\n\n// The following predicate function and predicate functor are for\n// testing the Truly(predicate) matcher.\n\n// Returns non-zero if the input is positive.  Note that the return\n// type of this function is not bool.  It's OK as Truly() accepts any\n// unary function or functor whose return type can be implicitly\n// converted to bool.\nint IsPositive(double x) {\n  return x > 0 ? 1 : 0;\n}\n\n// This functor returns true if the input is greater than the given\n// number.\nclass IsGreaterThan {\n public:\n  explicit IsGreaterThan(int threshold) : threshold_(threshold) {}\n\n  bool operator()(int n) const { return n > threshold_; }\n\n private:\n  int threshold_;\n};\n\n// For testing Truly().\nconst int foo = 0;\n\n// This predicate returns true iff the argument references foo and has\n// a zero value.\nbool ReferencesFooAndIsZero(const int& n) {\n  return (&n == &foo) && (n == 0);\n}\n\n// Tests that Truly(predicate) matches what satisfies the given\n// predicate.\nTEST(TrulyTest, MatchesWhatSatisfiesThePredicate) {\n  Matcher<double> m = Truly(IsPositive);\n  EXPECT_TRUE(m.Matches(2.0));\n  EXPECT_FALSE(m.Matches(-1.5));\n}\n\n// Tests that Truly(predicate_functor) works too.\nTEST(TrulyTest, CanBeUsedWithFunctor) {\n  Matcher<int> m = Truly(IsGreaterThan(5));\n  EXPECT_TRUE(m.Matches(6));\n  EXPECT_FALSE(m.Matches(4));\n}\n\n// A class that can be implicitly converted to bool.\nclass ConvertibleToBool {\n public:\n  explicit ConvertibleToBool(int number) : number_(number) {}\n  operator bool() const { return number_ != 0; }\n\n private:\n  int number_;\n};\n\nConvertibleToBool IsNotZero(int number) {\n  return ConvertibleToBool(number);\n}\n\n// Tests that the predicate used in Truly() may return a class that's\n// implicitly convertible to bool, even when the class has no\n// operator!().\nTEST(TrulyTest, PredicateCanReturnAClassConvertibleToBool) {\n  Matcher<int> m = Truly(IsNotZero);\n  EXPECT_TRUE(m.Matches(1));\n  EXPECT_FALSE(m.Matches(0));\n}\n\n// Tests that Truly(predicate) can describe itself properly.\nTEST(TrulyTest, CanDescribeSelf) {\n  Matcher<double> m = Truly(IsPositive);\n  EXPECT_EQ(\"satisfies the given predicate\",\n            Describe(m));\n}\n\n// Tests that Truly(predicate) works when the matcher takes its\n// argument by reference.\nTEST(TrulyTest, WorksForByRefArguments) {\n  Matcher<const int&> m = Truly(ReferencesFooAndIsZero);\n  EXPECT_TRUE(m.Matches(foo));\n  int n = 0;\n  EXPECT_FALSE(m.Matches(n));\n}\n\n// Tests that Matches(m) is a predicate satisfied by whatever that\n// matches matcher m.\nTEST(MatchesTest, IsSatisfiedByWhatMatchesTheMatcher) {\n  EXPECT_TRUE(Matches(Ge(0))(1));\n  EXPECT_FALSE(Matches(Eq('a'))('b'));\n}\n\n// Tests that Matches(m) works when the matcher takes its argument by\n// reference.\nTEST(MatchesTest, WorksOnByRefArguments) {\n  int m = 0, n = 0;\n  EXPECT_TRUE(Matches(AllOf(Ref(n), Eq(0)))(n));\n  EXPECT_FALSE(Matches(Ref(m))(n));\n}\n\n// Tests that a Matcher on non-reference type can be used in\n// Matches().\nTEST(MatchesTest, WorksWithMatcherOnNonRefType) {\n  Matcher<int> eq5 = Eq(5);\n  EXPECT_TRUE(Matches(eq5)(5));\n  EXPECT_FALSE(Matches(eq5)(2));\n}\n\n// Tests Value(value, matcher).  Since Value() is a simple wrapper for\n// Matches(), which has been tested already, we don't spend a lot of\n// effort on testing Value().\nTEST(ValueTest, WorksWithPolymorphicMatcher) {\n  EXPECT_TRUE(Value(\"hi\", StartsWith(\"h\")));\n  EXPECT_FALSE(Value(5, Gt(10)));\n}\n\nTEST(ValueTest, WorksWithMonomorphicMatcher) {\n  const Matcher<int> is_zero = Eq(0);\n  EXPECT_TRUE(Value(0, is_zero));\n  EXPECT_FALSE(Value('a', is_zero));\n\n  int n = 0;\n  const Matcher<const int&> ref_n = Ref(n);\n  EXPECT_TRUE(Value(n, ref_n));\n  EXPECT_FALSE(Value(1, ref_n));\n}\n\nTEST(ExplainMatchResultTest, WorksWithPolymorphicMatcher) {\n  StringMatchResultListener listener1;\n  EXPECT_TRUE(ExplainMatchResult(PolymorphicIsEven(), 42, &listener1));\n  EXPECT_EQ(\"% 2 == 0\", listener1.str());\n\n  StringMatchResultListener listener2;\n  EXPECT_FALSE(ExplainMatchResult(Ge(42), 1.5, &listener2));\n  EXPECT_EQ(\"\", listener2.str());\n}\n\nTEST(ExplainMatchResultTest, WorksWithMonomorphicMatcher) {\n  const Matcher<int> is_even = PolymorphicIsEven();\n  StringMatchResultListener listener1;\n  EXPECT_TRUE(ExplainMatchResult(is_even, 42, &listener1));\n  EXPECT_EQ(\"% 2 == 0\", listener1.str());\n\n  const Matcher<const double&> is_zero = Eq(0);\n  StringMatchResultListener listener2;\n  EXPECT_FALSE(ExplainMatchResult(is_zero, 1.5, &listener2));\n  EXPECT_EQ(\"\", listener2.str());\n}\n\nMATCHER_P(Really, inner_matcher, \"\") {\n  return ExplainMatchResult(inner_matcher, arg, result_listener);\n}\n\nTEST(ExplainMatchResultTest, WorksInsideMATCHER) {\n  EXPECT_THAT(0, Really(Eq(0)));\n}\n\nTEST(AllArgsTest, WorksForTuple) {\n  EXPECT_THAT(make_tuple(1, 2L), AllArgs(Lt()));\n  EXPECT_THAT(make_tuple(2L, 1), Not(AllArgs(Lt())));\n}\n\nTEST(AllArgsTest, WorksForNonTuple) {\n  EXPECT_THAT(42, AllArgs(Gt(0)));\n  EXPECT_THAT('a', Not(AllArgs(Eq('b'))));\n}\n\nclass AllArgsHelper {\n public:\n  AllArgsHelper() {}\n\n  MOCK_METHOD2(Helper, int(char x, int y));\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(AllArgsHelper);\n};\n\nTEST(AllArgsTest, WorksInWithClause) {\n  AllArgsHelper helper;\n  ON_CALL(helper, Helper(_, _))\n      .With(AllArgs(Lt()))\n      .WillByDefault(Return(1));\n  EXPECT_CALL(helper, Helper(_, _));\n  EXPECT_CALL(helper, Helper(_, _))\n      .With(AllArgs(Gt()))\n      .WillOnce(Return(2));\n\n  EXPECT_EQ(1, helper.Helper('\\1', 2));\n  EXPECT_EQ(2, helper.Helper('a', 1));\n}\n\n// Tests that ASSERT_THAT() and EXPECT_THAT() work when the value\n// matches the matcher.\nTEST(MatcherAssertionTest, WorksWhenMatcherIsSatisfied) {\n  ASSERT_THAT(5, Ge(2)) << \"This should succeed.\";\n  ASSERT_THAT(\"Foo\", EndsWith(\"oo\"));\n  EXPECT_THAT(2, AllOf(Le(7), Ge(0))) << \"This should succeed too.\";\n  EXPECT_THAT(\"Hello\", StartsWith(\"Hell\"));\n}\n\n// Tests that ASSERT_THAT() and EXPECT_THAT() work when the value\n// doesn't match the matcher.\nTEST(MatcherAssertionTest, WorksWhenMatcherIsNotSatisfied) {\n  // 'n' must be static as it is used in an EXPECT_FATAL_FAILURE(),\n  // which cannot reference auto variables.\n  static unsigned short n;  // NOLINT\n  n = 5;\n\n  // VC++ prior to version 8.0 SP1 has a bug where it will not see any\n  // functions declared in the namespace scope from within nested classes.\n  // EXPECT/ASSERT_(NON)FATAL_FAILURE macros use nested classes so that all\n  // namespace-level functions invoked inside them need to be explicitly\n  // resolved.\n  EXPECT_FATAL_FAILURE(ASSERT_THAT(n, ::testing::Gt(10)),\n                       \"Value of: n\\n\"\n                       \"Expected: is > 10\\n\"\n                       \"  Actual: 5\" + OfType(\"unsigned short\"));\n  n = 0;\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_THAT(n, ::testing::AllOf(::testing::Le(7), ::testing::Ge(5))),\n      \"Value of: n\\n\"\n      \"Expected: (is <= 7) and (is >= 5)\\n\"\n      \"  Actual: 0\" + OfType(\"unsigned short\"));\n}\n\n// Tests that ASSERT_THAT() and EXPECT_THAT() work when the argument\n// has a reference type.\nTEST(MatcherAssertionTest, WorksForByRefArguments) {\n  // We use a static variable here as EXPECT_FATAL_FAILURE() cannot\n  // reference auto variables.\n  static int n;\n  n = 0;\n  EXPECT_THAT(n, AllOf(Le(7), Ref(n)));\n  EXPECT_FATAL_FAILURE(ASSERT_THAT(n, ::testing::Not(::testing::Ref(n))),\n                       \"Value of: n\\n\"\n                       \"Expected: does not reference the variable @\");\n  // Tests the \"Actual\" part.\n  EXPECT_FATAL_FAILURE(ASSERT_THAT(n, ::testing::Not(::testing::Ref(n))),\n                       \"Actual: 0\" + OfType(\"int\") + \", which is located @\");\n}\n\n#if !GTEST_OS_SYMBIAN\n// Tests that ASSERT_THAT() and EXPECT_THAT() work when the matcher is\n// monomorphic.\n\n// ASSERT_THAT(\"hello\", starts_with_he) fails to compile with Nokia's\n// Symbian compiler: it tries to compile\n// template<T, U> class MatcherCastImpl { ...\n//   virtual bool MatchAndExplain(T x, ...) const {\n//     return source_matcher_.MatchAndExplain(static_cast<U>(x), ...);\n// with U == string and T == const char*\n// With ASSERT_THAT(\"hello\"...) changed to ASSERT_THAT(string(\"hello\") ... )\n// the compiler silently crashes with no output.\n// If MatcherCastImpl is changed to use U(x) instead of static_cast<U>(x)\n// the code compiles but the converted string is bogus.\nTEST(MatcherAssertionTest, WorksForMonomorphicMatcher) {\n  Matcher<const char*> starts_with_he = StartsWith(\"he\");\n  ASSERT_THAT(\"hello\", starts_with_he);\n\n  Matcher<const string&> ends_with_ok = EndsWith(\"ok\");\n  ASSERT_THAT(\"book\", ends_with_ok);\n  const string bad = \"bad\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_THAT(bad, ends_with_ok),\n                          \"Value of: bad\\n\"\n                          \"Expected: ends with \\\"ok\\\"\\n\"\n                          \"  Actual: \\\"bad\\\"\");\n  Matcher<int> is_greater_than_5 = Gt(5);\n  EXPECT_NONFATAL_FAILURE(EXPECT_THAT(5, is_greater_than_5),\n                          \"Value of: 5\\n\"\n                          \"Expected: is > 5\\n\"\n                          \"  Actual: 5\" + OfType(\"int\"));\n}\n#endif  // !GTEST_OS_SYMBIAN\n\n// Tests floating-point matchers.\ntemplate <typename RawType>\nclass FloatingPointTest : public testing::Test {\n protected:\n  typedef testing::internal::FloatingPoint<RawType> Floating;\n  typedef typename Floating::Bits Bits;\n\n  FloatingPointTest()\n      : max_ulps_(Floating::kMaxUlps),\n        zero_bits_(Floating(0).bits()),\n        one_bits_(Floating(1).bits()),\n        infinity_bits_(Floating(Floating::Infinity()).bits()),\n        close_to_positive_zero_(\n            Floating::ReinterpretBits(zero_bits_ + max_ulps_/2)),\n        close_to_negative_zero_(\n            -Floating::ReinterpretBits(zero_bits_ + max_ulps_ - max_ulps_/2)),\n        further_from_negative_zero_(-Floating::ReinterpretBits(\n            zero_bits_ + max_ulps_ + 1 - max_ulps_/2)),\n        close_to_one_(Floating::ReinterpretBits(one_bits_ + max_ulps_)),\n        further_from_one_(Floating::ReinterpretBits(one_bits_ + max_ulps_ + 1)),\n        infinity_(Floating::Infinity()),\n        close_to_infinity_(\n            Floating::ReinterpretBits(infinity_bits_ - max_ulps_)),\n        further_from_infinity_(\n            Floating::ReinterpretBits(infinity_bits_ - max_ulps_ - 1)),\n        max_(Floating::Max()),\n        nan1_(Floating::ReinterpretBits(Floating::kExponentBitMask | 1)),\n        nan2_(Floating::ReinterpretBits(Floating::kExponentBitMask | 200)) {\n  }\n\n  void TestSize() {\n    EXPECT_EQ(sizeof(RawType), sizeof(Bits));\n  }\n\n  // A battery of tests for FloatingEqMatcher::Matches.\n  // matcher_maker is a pointer to a function which creates a FloatingEqMatcher.\n  void TestMatches(\n      testing::internal::FloatingEqMatcher<RawType> (*matcher_maker)(RawType)) {\n    Matcher<RawType> m1 = matcher_maker(0.0);\n    EXPECT_TRUE(m1.Matches(-0.0));\n    EXPECT_TRUE(m1.Matches(close_to_positive_zero_));\n    EXPECT_TRUE(m1.Matches(close_to_negative_zero_));\n    EXPECT_FALSE(m1.Matches(1.0));\n\n    Matcher<RawType> m2 = matcher_maker(close_to_positive_zero_);\n    EXPECT_FALSE(m2.Matches(further_from_negative_zero_));\n\n    Matcher<RawType> m3 = matcher_maker(1.0);\n    EXPECT_TRUE(m3.Matches(close_to_one_));\n    EXPECT_FALSE(m3.Matches(further_from_one_));\n\n    // Test commutativity: matcher_maker(0.0).Matches(1.0) was tested above.\n    EXPECT_FALSE(m3.Matches(0.0));\n\n    Matcher<RawType> m4 = matcher_maker(-infinity_);\n    EXPECT_TRUE(m4.Matches(-close_to_infinity_));\n\n    Matcher<RawType> m5 = matcher_maker(infinity_);\n    EXPECT_TRUE(m5.Matches(close_to_infinity_));\n\n    // This is interesting as the representations of infinity_ and nan1_\n    // are only 1 DLP apart.\n    EXPECT_FALSE(m5.Matches(nan1_));\n\n    // matcher_maker can produce a Matcher<const RawType&>, which is needed in\n    // some cases.\n    Matcher<const RawType&> m6 = matcher_maker(0.0);\n    EXPECT_TRUE(m6.Matches(-0.0));\n    EXPECT_TRUE(m6.Matches(close_to_positive_zero_));\n    EXPECT_FALSE(m6.Matches(1.0));\n\n    // matcher_maker can produce a Matcher<RawType&>, which is needed in some\n    // cases.\n    Matcher<RawType&> m7 = matcher_maker(0.0);\n    RawType x = 0.0;\n    EXPECT_TRUE(m7.Matches(x));\n    x = 0.01f;\n    EXPECT_FALSE(m7.Matches(x));\n  }\n\n  // Pre-calculated numbers to be used by the tests.\n\n  const size_t max_ulps_;\n\n  const Bits zero_bits_;  // The bits that represent 0.0.\n  const Bits one_bits_;  // The bits that represent 1.0.\n  const Bits infinity_bits_;  // The bits that represent +infinity.\n\n  // Some numbers close to 0.0.\n  const RawType close_to_positive_zero_;\n  const RawType close_to_negative_zero_;\n  const RawType further_from_negative_zero_;\n\n  // Some numbers close to 1.0.\n  const RawType close_to_one_;\n  const RawType further_from_one_;\n\n  // Some numbers close to +infinity.\n  const RawType infinity_;\n  const RawType close_to_infinity_;\n  const RawType further_from_infinity_;\n\n  // Maximum representable value that's not infinity.\n  const RawType max_;\n\n  // Some NaNs.\n  const RawType nan1_;\n  const RawType nan2_;\n};\n\n// Tests floating-point matchers with fixed epsilons.\ntemplate <typename RawType>\nclass FloatingPointNearTest : public FloatingPointTest<RawType> {\n protected:\n  typedef FloatingPointTest<RawType> ParentType;\n\n  // A battery of tests for FloatingEqMatcher::Matches with a fixed epsilon.\n  // matcher_maker is a pointer to a function which creates a FloatingEqMatcher.\n  void TestNearMatches(\n      testing::internal::FloatingEqMatcher<RawType>\n          (*matcher_maker)(RawType, RawType)) {\n    Matcher<RawType> m1 = matcher_maker(0.0, 0.0);\n    EXPECT_TRUE(m1.Matches(0.0));\n    EXPECT_TRUE(m1.Matches(-0.0));\n    EXPECT_FALSE(m1.Matches(ParentType::close_to_positive_zero_));\n    EXPECT_FALSE(m1.Matches(ParentType::close_to_negative_zero_));\n    EXPECT_FALSE(m1.Matches(1.0));\n\n    Matcher<RawType> m2 = matcher_maker(0.0, 1.0);\n    EXPECT_TRUE(m2.Matches(0.0));\n    EXPECT_TRUE(m2.Matches(-0.0));\n    EXPECT_TRUE(m2.Matches(1.0));\n    EXPECT_TRUE(m2.Matches(-1.0));\n    EXPECT_FALSE(m2.Matches(ParentType::close_to_one_));\n    EXPECT_FALSE(m2.Matches(-ParentType::close_to_one_));\n\n    // Check that inf matches inf, regardless of the of the specified max\n    // absolute error.\n    Matcher<RawType> m3 = matcher_maker(ParentType::infinity_, 0.0);\n    EXPECT_TRUE(m3.Matches(ParentType::infinity_));\n    EXPECT_FALSE(m3.Matches(ParentType::close_to_infinity_));\n    EXPECT_FALSE(m3.Matches(-ParentType::infinity_));\n\n    Matcher<RawType> m4 = matcher_maker(-ParentType::infinity_, 0.0);\n    EXPECT_TRUE(m4.Matches(-ParentType::infinity_));\n    EXPECT_FALSE(m4.Matches(-ParentType::close_to_infinity_));\n    EXPECT_FALSE(m4.Matches(ParentType::infinity_));\n\n    // Test various overflow scenarios.\n    Matcher<RawType> m5 = matcher_maker(ParentType::max_, ParentType::max_);\n    EXPECT_TRUE(m5.Matches(ParentType::max_));\n    EXPECT_FALSE(m5.Matches(-ParentType::max_));\n\n    Matcher<RawType> m6 = matcher_maker(-ParentType::max_, ParentType::max_);\n    EXPECT_FALSE(m6.Matches(ParentType::max_));\n    EXPECT_TRUE(m6.Matches(-ParentType::max_));\n\n    Matcher<RawType> m7 = matcher_maker(ParentType::max_, 0);\n    EXPECT_TRUE(m7.Matches(ParentType::max_));\n    EXPECT_FALSE(m7.Matches(-ParentType::max_));\n\n    Matcher<RawType> m8 = matcher_maker(-ParentType::max_, 0);\n    EXPECT_FALSE(m8.Matches(ParentType::max_));\n    EXPECT_TRUE(m8.Matches(-ParentType::max_));\n\n    // The difference between max() and -max() normally overflows to infinity,\n    // but it should still match if the max_abs_error is also infinity.\n    Matcher<RawType> m9 = matcher_maker(\n        ParentType::max_, ParentType::infinity_);\n    EXPECT_TRUE(m8.Matches(-ParentType::max_));\n\n    // matcher_maker can produce a Matcher<const RawType&>, which is needed in\n    // some cases.\n    Matcher<const RawType&> m10 = matcher_maker(0.0, 1.0);\n    EXPECT_TRUE(m10.Matches(-0.0));\n    EXPECT_TRUE(m10.Matches(ParentType::close_to_positive_zero_));\n    EXPECT_FALSE(m10.Matches(ParentType::close_to_one_));\n\n    // matcher_maker can produce a Matcher<RawType&>, which is needed in some\n    // cases.\n    Matcher<RawType&> m11 = matcher_maker(0.0, 1.0);\n    RawType x = 0.0;\n    EXPECT_TRUE(m11.Matches(x));\n    x = 1.0f;\n    EXPECT_TRUE(m11.Matches(x));\n    x = -1.0f;\n    EXPECT_TRUE(m11.Matches(x));\n    x = 1.1f;\n    EXPECT_FALSE(m11.Matches(x));\n    x = -1.1f;\n    EXPECT_FALSE(m11.Matches(x));\n  }\n};\n\n// Instantiate FloatingPointTest for testing floats.\ntypedef FloatingPointTest<float> FloatTest;\n\nTEST_F(FloatTest, FloatEqApproximatelyMatchesFloats) {\n  TestMatches(&FloatEq);\n}\n\nTEST_F(FloatTest, NanSensitiveFloatEqApproximatelyMatchesFloats) {\n  TestMatches(&NanSensitiveFloatEq);\n}\n\nTEST_F(FloatTest, FloatEqCannotMatchNaN) {\n  // FloatEq never matches NaN.\n  Matcher<float> m = FloatEq(nan1_);\n  EXPECT_FALSE(m.Matches(nan1_));\n  EXPECT_FALSE(m.Matches(nan2_));\n  EXPECT_FALSE(m.Matches(1.0));\n}\n\nTEST_F(FloatTest, NanSensitiveFloatEqCanMatchNaN) {\n  // NanSensitiveFloatEq will match NaN.\n  Matcher<float> m = NanSensitiveFloatEq(nan1_);\n  EXPECT_TRUE(m.Matches(nan1_));\n  EXPECT_TRUE(m.Matches(nan2_));\n  EXPECT_FALSE(m.Matches(1.0));\n}\n\nTEST_F(FloatTest, FloatEqCanDescribeSelf) {\n  Matcher<float> m1 = FloatEq(2.0f);\n  EXPECT_EQ(\"is approximately 2\", Describe(m1));\n  EXPECT_EQ(\"isn't approximately 2\", DescribeNegation(m1));\n\n  Matcher<float> m2 = FloatEq(0.5f);\n  EXPECT_EQ(\"is approximately 0.5\", Describe(m2));\n  EXPECT_EQ(\"isn't approximately 0.5\", DescribeNegation(m2));\n\n  Matcher<float> m3 = FloatEq(nan1_);\n  EXPECT_EQ(\"never matches\", Describe(m3));\n  EXPECT_EQ(\"is anything\", DescribeNegation(m3));\n}\n\nTEST_F(FloatTest, NanSensitiveFloatEqCanDescribeSelf) {\n  Matcher<float> m1 = NanSensitiveFloatEq(2.0f);\n  EXPECT_EQ(\"is approximately 2\", Describe(m1));\n  EXPECT_EQ(\"isn't approximately 2\", DescribeNegation(m1));\n\n  Matcher<float> m2 = NanSensitiveFloatEq(0.5f);\n  EXPECT_EQ(\"is approximately 0.5\", Describe(m2));\n  EXPECT_EQ(\"isn't approximately 0.5\", DescribeNegation(m2));\n\n  Matcher<float> m3 = NanSensitiveFloatEq(nan1_);\n  EXPECT_EQ(\"is NaN\", Describe(m3));\n  EXPECT_EQ(\"isn't NaN\", DescribeNegation(m3));\n}\n\n// Instantiate FloatingPointTest for testing floats with a user-specified\n// max absolute error.\ntypedef FloatingPointNearTest<float> FloatNearTest;\n\nTEST_F(FloatNearTest, FloatNearMatches) {\n  TestNearMatches(&FloatNear);\n}\n\nTEST_F(FloatNearTest, NanSensitiveFloatNearApproximatelyMatchesFloats) {\n  TestNearMatches(&NanSensitiveFloatNear);\n}\n\nTEST_F(FloatNearTest, FloatNearCanDescribeSelf) {\n  Matcher<float> m1 = FloatNear(2.0f, 0.5f);\n  EXPECT_EQ(\"is approximately 2 (absolute error <= 0.5)\", Describe(m1));\n  EXPECT_EQ(\n      \"isn't approximately 2 (absolute error > 0.5)\", DescribeNegation(m1));\n\n  Matcher<float> m2 = FloatNear(0.5f, 0.5f);\n  EXPECT_EQ(\"is approximately 0.5 (absolute error <= 0.5)\", Describe(m2));\n  EXPECT_EQ(\n      \"isn't approximately 0.5 (absolute error > 0.5)\", DescribeNegation(m2));\n\n  Matcher<float> m3 = FloatNear(nan1_, 0.0);\n  EXPECT_EQ(\"never matches\", Describe(m3));\n  EXPECT_EQ(\"is anything\", DescribeNegation(m3));\n}\n\nTEST_F(FloatNearTest, NanSensitiveFloatNearCanDescribeSelf) {\n  Matcher<float> m1 = NanSensitiveFloatNear(2.0f, 0.5f);\n  EXPECT_EQ(\"is approximately 2 (absolute error <= 0.5)\", Describe(m1));\n  EXPECT_EQ(\n      \"isn't approximately 2 (absolute error > 0.5)\", DescribeNegation(m1));\n\n  Matcher<float> m2 = NanSensitiveFloatNear(0.5f, 0.5f);\n  EXPECT_EQ(\"is approximately 0.5 (absolute error <= 0.5)\", Describe(m2));\n  EXPECT_EQ(\n      \"isn't approximately 0.5 (absolute error > 0.5)\", DescribeNegation(m2));\n\n  Matcher<float> m3 = NanSensitiveFloatNear(nan1_, 0.1f);\n  EXPECT_EQ(\"is NaN\", Describe(m3));\n  EXPECT_EQ(\"isn't NaN\", DescribeNegation(m3));\n}\n\nTEST_F(FloatNearTest, FloatNearCannotMatchNaN) {\n  // FloatNear never matches NaN.\n  Matcher<float> m = FloatNear(ParentType::nan1_, 0.1f);\n  EXPECT_FALSE(m.Matches(nan1_));\n  EXPECT_FALSE(m.Matches(nan2_));\n  EXPECT_FALSE(m.Matches(1.0));\n}\n\nTEST_F(FloatNearTest, NanSensitiveFloatNearCanMatchNaN) {\n  // NanSensitiveFloatNear will match NaN.\n  Matcher<float> m = NanSensitiveFloatNear(nan1_, 0.1f);\n  EXPECT_TRUE(m.Matches(nan1_));\n  EXPECT_TRUE(m.Matches(nan2_));\n  EXPECT_FALSE(m.Matches(1.0));\n}\n\n// Instantiate FloatingPointTest for testing doubles.\ntypedef FloatingPointTest<double> DoubleTest;\n\nTEST_F(DoubleTest, DoubleEqApproximatelyMatchesDoubles) {\n  TestMatches(&DoubleEq);\n}\n\nTEST_F(DoubleTest, NanSensitiveDoubleEqApproximatelyMatchesDoubles) {\n  TestMatches(&NanSensitiveDoubleEq);\n}\n\nTEST_F(DoubleTest, DoubleEqCannotMatchNaN) {\n  // DoubleEq never matches NaN.\n  Matcher<double> m = DoubleEq(nan1_);\n  EXPECT_FALSE(m.Matches(nan1_));\n  EXPECT_FALSE(m.Matches(nan2_));\n  EXPECT_FALSE(m.Matches(1.0));\n}\n\nTEST_F(DoubleTest, NanSensitiveDoubleEqCanMatchNaN) {\n  // NanSensitiveDoubleEq will match NaN.\n  Matcher<double> m = NanSensitiveDoubleEq(nan1_);\n  EXPECT_TRUE(m.Matches(nan1_));\n  EXPECT_TRUE(m.Matches(nan2_));\n  EXPECT_FALSE(m.Matches(1.0));\n}\n\nTEST_F(DoubleTest, DoubleEqCanDescribeSelf) {\n  Matcher<double> m1 = DoubleEq(2.0);\n  EXPECT_EQ(\"is approximately 2\", Describe(m1));\n  EXPECT_EQ(\"isn't approximately 2\", DescribeNegation(m1));\n\n  Matcher<double> m2 = DoubleEq(0.5);\n  EXPECT_EQ(\"is approximately 0.5\", Describe(m2));\n  EXPECT_EQ(\"isn't approximately 0.5\", DescribeNegation(m2));\n\n  Matcher<double> m3 = DoubleEq(nan1_);\n  EXPECT_EQ(\"never matches\", Describe(m3));\n  EXPECT_EQ(\"is anything\", DescribeNegation(m3));\n}\n\nTEST_F(DoubleTest, NanSensitiveDoubleEqCanDescribeSelf) {\n  Matcher<double> m1 = NanSensitiveDoubleEq(2.0);\n  EXPECT_EQ(\"is approximately 2\", Describe(m1));\n  EXPECT_EQ(\"isn't approximately 2\", DescribeNegation(m1));\n\n  Matcher<double> m2 = NanSensitiveDoubleEq(0.5);\n  EXPECT_EQ(\"is approximately 0.5\", Describe(m2));\n  EXPECT_EQ(\"isn't approximately 0.5\", DescribeNegation(m2));\n\n  Matcher<double> m3 = NanSensitiveDoubleEq(nan1_);\n  EXPECT_EQ(\"is NaN\", Describe(m3));\n  EXPECT_EQ(\"isn't NaN\", DescribeNegation(m3));\n}\n\n// Instantiate FloatingPointTest for testing floats with a user-specified\n// max absolute error.\ntypedef FloatingPointNearTest<double> DoubleNearTest;\n\nTEST_F(DoubleNearTest, DoubleNearMatches) {\n  TestNearMatches(&DoubleNear);\n}\n\nTEST_F(DoubleNearTest, NanSensitiveDoubleNearApproximatelyMatchesDoubles) {\n  TestNearMatches(&NanSensitiveDoubleNear);\n}\n\nTEST_F(DoubleNearTest, DoubleNearCanDescribeSelf) {\n  Matcher<double> m1 = DoubleNear(2.0, 0.5);\n  EXPECT_EQ(\"is approximately 2 (absolute error <= 0.5)\", Describe(m1));\n  EXPECT_EQ(\n      \"isn't approximately 2 (absolute error > 0.5)\", DescribeNegation(m1));\n\n  Matcher<double> m2 = DoubleNear(0.5, 0.5);\n  EXPECT_EQ(\"is approximately 0.5 (absolute error <= 0.5)\", Describe(m2));\n  EXPECT_EQ(\n      \"isn't approximately 0.5 (absolute error > 0.5)\", DescribeNegation(m2));\n\n  Matcher<double> m3 = DoubleNear(nan1_, 0.0);\n  EXPECT_EQ(\"never matches\", Describe(m3));\n  EXPECT_EQ(\"is anything\", DescribeNegation(m3));\n}\n\nTEST_F(DoubleNearTest, NanSensitiveDoubleNearCanDescribeSelf) {\n  Matcher<double> m1 = NanSensitiveDoubleNear(2.0, 0.5);\n  EXPECT_EQ(\"is approximately 2 (absolute error <= 0.5)\", Describe(m1));\n  EXPECT_EQ(\n      \"isn't approximately 2 (absolute error > 0.5)\", DescribeNegation(m1));\n\n  Matcher<double> m2 = NanSensitiveDoubleNear(0.5, 0.5);\n  EXPECT_EQ(\"is approximately 0.5 (absolute error <= 0.5)\", Describe(m2));\n  EXPECT_EQ(\n      \"isn't approximately 0.5 (absolute error > 0.5)\", DescribeNegation(m2));\n\n  Matcher<double> m3 = NanSensitiveDoubleNear(nan1_, 0.1);\n  EXPECT_EQ(\"is NaN\", Describe(m3));\n  EXPECT_EQ(\"isn't NaN\", DescribeNegation(m3));\n}\n\nTEST_F(DoubleNearTest, DoubleNearCannotMatchNaN) {\n  // DoubleNear never matches NaN.\n  Matcher<double> m = DoubleNear(ParentType::nan1_, 0.1);\n  EXPECT_FALSE(m.Matches(nan1_));\n  EXPECT_FALSE(m.Matches(nan2_));\n  EXPECT_FALSE(m.Matches(1.0));\n}\n\nTEST_F(DoubleNearTest, NanSensitiveDoubleNearCanMatchNaN) {\n  // NanSensitiveDoubleNear will match NaN.\n  Matcher<double> m = NanSensitiveDoubleNear(nan1_, 0.1);\n  EXPECT_TRUE(m.Matches(nan1_));\n  EXPECT_TRUE(m.Matches(nan2_));\n  EXPECT_FALSE(m.Matches(1.0));\n}\n\nTEST(PointeeTest, RawPointer) {\n  const Matcher<int*> m = Pointee(Ge(0));\n\n  int n = 1;\n  EXPECT_TRUE(m.Matches(&n));\n  n = -1;\n  EXPECT_FALSE(m.Matches(&n));\n  EXPECT_FALSE(m.Matches(NULL));\n}\n\nTEST(PointeeTest, RawPointerToConst) {\n  const Matcher<const double*> m = Pointee(Ge(0));\n\n  double x = 1;\n  EXPECT_TRUE(m.Matches(&x));\n  x = -1;\n  EXPECT_FALSE(m.Matches(&x));\n  EXPECT_FALSE(m.Matches(NULL));\n}\n\nTEST(PointeeTest, ReferenceToConstRawPointer) {\n  const Matcher<int* const &> m = Pointee(Ge(0));\n\n  int n = 1;\n  EXPECT_TRUE(m.Matches(&n));\n  n = -1;\n  EXPECT_FALSE(m.Matches(&n));\n  EXPECT_FALSE(m.Matches(NULL));\n}\n\nTEST(PointeeTest, ReferenceToNonConstRawPointer) {\n  const Matcher<double* &> m = Pointee(Ge(0));\n\n  double x = 1.0;\n  double* p = &x;\n  EXPECT_TRUE(m.Matches(p));\n  x = -1;\n  EXPECT_FALSE(m.Matches(p));\n  p = NULL;\n  EXPECT_FALSE(m.Matches(p));\n}\n\n// Minimal const-propagating pointer.\ntemplate <typename T>\nclass ConstPropagatingPtr {\n public:\n  typedef T element_type;\n\n  ConstPropagatingPtr() : val_() {}\n  explicit ConstPropagatingPtr(T* t) : val_(t) {}\n  ConstPropagatingPtr(const ConstPropagatingPtr& other) : val_(other.val_) {}\n\n  T* get() { return val_; }\n  T& operator*() { return *val_; }\n  // Most smart pointers return non-const T* and T& from the next methods.\n  const T* get() const { return val_; }\n  const T& operator*() const { return *val_; }\n\n private:\n  T* val_;\n};\n\nTEST(PointeeTest, WorksWithConstPropagatingPointers) {\n  const Matcher< ConstPropagatingPtr<int> > m = Pointee(Lt(5));\n  int three = 3;\n  const ConstPropagatingPtr<int> co(&three);\n  ConstPropagatingPtr<int> o(&three);\n  EXPECT_TRUE(m.Matches(o));\n  EXPECT_TRUE(m.Matches(co));\n  *o = 6;\n  EXPECT_FALSE(m.Matches(o));\n  EXPECT_FALSE(m.Matches(ConstPropagatingPtr<int>()));\n}\n\nTEST(PointeeTest, NeverMatchesNull) {\n  const Matcher<const char*> m = Pointee(_);\n  EXPECT_FALSE(m.Matches(NULL));\n}\n\n// Tests that we can write Pointee(value) instead of Pointee(Eq(value)).\nTEST(PointeeTest, MatchesAgainstAValue) {\n  const Matcher<int*> m = Pointee(5);\n\n  int n = 5;\n  EXPECT_TRUE(m.Matches(&n));\n  n = -1;\n  EXPECT_FALSE(m.Matches(&n));\n  EXPECT_FALSE(m.Matches(NULL));\n}\n\nTEST(PointeeTest, CanDescribeSelf) {\n  const Matcher<int*> m = Pointee(Gt(3));\n  EXPECT_EQ(\"points to a value that is > 3\", Describe(m));\n  EXPECT_EQ(\"does not point to a value that is > 3\",\n            DescribeNegation(m));\n}\n\nTEST(PointeeTest, CanExplainMatchResult) {\n  const Matcher<const string*> m = Pointee(StartsWith(\"Hi\"));\n\n  EXPECT_EQ(\"\", Explain(m, static_cast<const string*>(NULL)));\n\n  const Matcher<long*> m2 = Pointee(GreaterThan(1));  // NOLINT\n  long n = 3;  // NOLINT\n  EXPECT_EQ(\"which points to 3\" + OfType(\"long\") + \", which is 2 more than 1\",\n            Explain(m2, &n));\n}\n\nTEST(PointeeTest, AlwaysExplainsPointee) {\n  const Matcher<int*> m = Pointee(0);\n  int n = 42;\n  EXPECT_EQ(\"which points to 42\" + OfType(\"int\"), Explain(m, &n));\n}\n\n// An uncopyable class.\nclass Uncopyable {\n public:\n  explicit Uncopyable(int a_value) : value_(a_value) {}\n\n  int value() const { return value_; }\n private:\n  const int value_;\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(Uncopyable);\n};\n\n// Returns true iff x.value() is positive.\nbool ValueIsPositive(const Uncopyable& x) { return x.value() > 0; }\n\n// A user-defined struct for testing Field().\nstruct AStruct {\n  AStruct() : x(0), y(1.0), z(5), p(NULL) {}\n  AStruct(const AStruct& rhs)\n      : x(rhs.x), y(rhs.y), z(rhs.z.value()), p(rhs.p) {}\n\n  int x;           // A non-const field.\n  const double y;  // A const field.\n  Uncopyable z;    // An uncopyable field.\n  const char* p;   // A pointer field.\n\n private:\n  GTEST_DISALLOW_ASSIGN_(AStruct);\n};\n\n// A derived struct for testing Field().\nstruct DerivedStruct : public AStruct {\n  char ch;\n\n private:\n  GTEST_DISALLOW_ASSIGN_(DerivedStruct);\n};\n\n// Tests that Field(&Foo::field, ...) works when field is non-const.\nTEST(FieldTest, WorksForNonConstField) {\n  Matcher<AStruct> m = Field(&AStruct::x, Ge(0));\n\n  AStruct a;\n  EXPECT_TRUE(m.Matches(a));\n  a.x = -1;\n  EXPECT_FALSE(m.Matches(a));\n}\n\n// Tests that Field(&Foo::field, ...) works when field is const.\nTEST(FieldTest, WorksForConstField) {\n  AStruct a;\n\n  Matcher<AStruct> m = Field(&AStruct::y, Ge(0.0));\n  EXPECT_TRUE(m.Matches(a));\n  m = Field(&AStruct::y, Le(0.0));\n  EXPECT_FALSE(m.Matches(a));\n}\n\n// Tests that Field(&Foo::field, ...) works when field is not copyable.\nTEST(FieldTest, WorksForUncopyableField) {\n  AStruct a;\n\n  Matcher<AStruct> m = Field(&AStruct::z, Truly(ValueIsPositive));\n  EXPECT_TRUE(m.Matches(a));\n  m = Field(&AStruct::z, Not(Truly(ValueIsPositive)));\n  EXPECT_FALSE(m.Matches(a));\n}\n\n// Tests that Field(&Foo::field, ...) works when field is a pointer.\nTEST(FieldTest, WorksForPointerField) {\n  // Matching against NULL.\n  Matcher<AStruct> m = Field(&AStruct::p, static_cast<const char*>(NULL));\n  AStruct a;\n  EXPECT_TRUE(m.Matches(a));\n  a.p = \"hi\";\n  EXPECT_FALSE(m.Matches(a));\n\n  // Matching a pointer that is not NULL.\n  m = Field(&AStruct::p, StartsWith(\"hi\"));\n  a.p = \"hill\";\n  EXPECT_TRUE(m.Matches(a));\n  a.p = \"hole\";\n  EXPECT_FALSE(m.Matches(a));\n}\n\n// Tests that Field() works when the object is passed by reference.\nTEST(FieldTest, WorksForByRefArgument) {\n  Matcher<const AStruct&> m = Field(&AStruct::x, Ge(0));\n\n  AStruct a;\n  EXPECT_TRUE(m.Matches(a));\n  a.x = -1;\n  EXPECT_FALSE(m.Matches(a));\n}\n\n// Tests that Field(&Foo::field, ...) works when the argument's type\n// is a sub-type of Foo.\nTEST(FieldTest, WorksForArgumentOfSubType) {\n  // Note that the matcher expects DerivedStruct but we say AStruct\n  // inside Field().\n  Matcher<const DerivedStruct&> m = Field(&AStruct::x, Ge(0));\n\n  DerivedStruct d;\n  EXPECT_TRUE(m.Matches(d));\n  d.x = -1;\n  EXPECT_FALSE(m.Matches(d));\n}\n\n// Tests that Field(&Foo::field, m) works when field's type and m's\n// argument type are compatible but not the same.\nTEST(FieldTest, WorksForCompatibleMatcherType) {\n  // The field is an int, but the inner matcher expects a signed char.\n  Matcher<const AStruct&> m = Field(&AStruct::x,\n                                    Matcher<signed char>(Ge(0)));\n\n  AStruct a;\n  EXPECT_TRUE(m.Matches(a));\n  a.x = -1;\n  EXPECT_FALSE(m.Matches(a));\n}\n\n// Tests that Field() can describe itself.\nTEST(FieldTest, CanDescribeSelf) {\n  Matcher<const AStruct&> m = Field(&AStruct::x, Ge(0));\n\n  EXPECT_EQ(\"is an object whose given field is >= 0\", Describe(m));\n  EXPECT_EQ(\"is an object whose given field isn't >= 0\", DescribeNegation(m));\n}\n\n// Tests that Field() can explain the match result.\nTEST(FieldTest, CanExplainMatchResult) {\n  Matcher<const AStruct&> m = Field(&AStruct::x, Ge(0));\n\n  AStruct a;\n  a.x = 1;\n  EXPECT_EQ(\"whose given field is 1\" + OfType(\"int\"), Explain(m, a));\n\n  m = Field(&AStruct::x, GreaterThan(0));\n  EXPECT_EQ(\n      \"whose given field is 1\" + OfType(\"int\") + \", which is 1 more than 0\",\n      Explain(m, a));\n}\n\n// Tests that Field() works when the argument is a pointer to const.\nTEST(FieldForPointerTest, WorksForPointerToConst) {\n  Matcher<const AStruct*> m = Field(&AStruct::x, Ge(0));\n\n  AStruct a;\n  EXPECT_TRUE(m.Matches(&a));\n  a.x = -1;\n  EXPECT_FALSE(m.Matches(&a));\n}\n\n// Tests that Field() works when the argument is a pointer to non-const.\nTEST(FieldForPointerTest, WorksForPointerToNonConst) {\n  Matcher<AStruct*> m = Field(&AStruct::x, Ge(0));\n\n  AStruct a;\n  EXPECT_TRUE(m.Matches(&a));\n  a.x = -1;\n  EXPECT_FALSE(m.Matches(&a));\n}\n\n// Tests that Field() works when the argument is a reference to a const pointer.\nTEST(FieldForPointerTest, WorksForReferenceToConstPointer) {\n  Matcher<AStruct* const&> m = Field(&AStruct::x, Ge(0));\n\n  AStruct a;\n  EXPECT_TRUE(m.Matches(&a));\n  a.x = -1;\n  EXPECT_FALSE(m.Matches(&a));\n}\n\n// Tests that Field() does not match the NULL pointer.\nTEST(FieldForPointerTest, DoesNotMatchNull) {\n  Matcher<const AStruct*> m = Field(&AStruct::x, _);\n  EXPECT_FALSE(m.Matches(NULL));\n}\n\n// Tests that Field(&Foo::field, ...) works when the argument's type\n// is a sub-type of const Foo*.\nTEST(FieldForPointerTest, WorksForArgumentOfSubType) {\n  // Note that the matcher expects DerivedStruct but we say AStruct\n  // inside Field().\n  Matcher<DerivedStruct*> m = Field(&AStruct::x, Ge(0));\n\n  DerivedStruct d;\n  EXPECT_TRUE(m.Matches(&d));\n  d.x = -1;\n  EXPECT_FALSE(m.Matches(&d));\n}\n\n// Tests that Field() can describe itself when used to match a pointer.\nTEST(FieldForPointerTest, CanDescribeSelf) {\n  Matcher<const AStruct*> m = Field(&AStruct::x, Ge(0));\n\n  EXPECT_EQ(\"is an object whose given field is >= 0\", Describe(m));\n  EXPECT_EQ(\"is an object whose given field isn't >= 0\", DescribeNegation(m));\n}\n\n// Tests that Field() can explain the result of matching a pointer.\nTEST(FieldForPointerTest, CanExplainMatchResult) {\n  Matcher<const AStruct*> m = Field(&AStruct::x, Ge(0));\n\n  AStruct a;\n  a.x = 1;\n  EXPECT_EQ(\"\", Explain(m, static_cast<const AStruct*>(NULL)));\n  EXPECT_EQ(\"which points to an object whose given field is 1\" + OfType(\"int\"),\n            Explain(m, &a));\n\n  m = Field(&AStruct::x, GreaterThan(0));\n  EXPECT_EQ(\"which points to an object whose given field is 1\" + OfType(\"int\") +\n            \", which is 1 more than 0\", Explain(m, &a));\n}\n\n// A user-defined class for testing Property().\nclass AClass {\n public:\n  AClass() : n_(0) {}\n\n  // A getter that returns a non-reference.\n  int n() const { return n_; }\n\n  void set_n(int new_n) { n_ = new_n; }\n\n  // A getter that returns a reference to const.\n  const string& s() const { return s_; }\n\n  void set_s(const string& new_s) { s_ = new_s; }\n\n  // A getter that returns a reference to non-const.\n  double& x() const { return x_; }\n private:\n  int n_;\n  string s_;\n\n  static double x_;\n};\n\ndouble AClass::x_ = 0.0;\n\n// A derived class for testing Property().\nclass DerivedClass : public AClass {\n private:\n  int k_;\n};\n\n// Tests that Property(&Foo::property, ...) works when property()\n// returns a non-reference.\nTEST(PropertyTest, WorksForNonReferenceProperty) {\n  Matcher<const AClass&> m = Property(&AClass::n, Ge(0));\n\n  AClass a;\n  a.set_n(1);\n  EXPECT_TRUE(m.Matches(a));\n\n  a.set_n(-1);\n  EXPECT_FALSE(m.Matches(a));\n}\n\n// Tests that Property(&Foo::property, ...) works when property()\n// returns a reference to const.\nTEST(PropertyTest, WorksForReferenceToConstProperty) {\n  Matcher<const AClass&> m = Property(&AClass::s, StartsWith(\"hi\"));\n\n  AClass a;\n  a.set_s(\"hill\");\n  EXPECT_TRUE(m.Matches(a));\n\n  a.set_s(\"hole\");\n  EXPECT_FALSE(m.Matches(a));\n}\n\n// Tests that Property(&Foo::property, ...) works when property()\n// returns a reference to non-const.\nTEST(PropertyTest, WorksForReferenceToNonConstProperty) {\n  double x = 0.0;\n  AClass a;\n\n  Matcher<const AClass&> m = Property(&AClass::x, Ref(x));\n  EXPECT_FALSE(m.Matches(a));\n\n  m = Property(&AClass::x, Not(Ref(x)));\n  EXPECT_TRUE(m.Matches(a));\n}\n\n// Tests that Property(&Foo::property, ...) works when the argument is\n// passed by value.\nTEST(PropertyTest, WorksForByValueArgument) {\n  Matcher<AClass> m = Property(&AClass::s, StartsWith(\"hi\"));\n\n  AClass a;\n  a.set_s(\"hill\");\n  EXPECT_TRUE(m.Matches(a));\n\n  a.set_s(\"hole\");\n  EXPECT_FALSE(m.Matches(a));\n}\n\n// Tests that Property(&Foo::property, ...) works when the argument's\n// type is a sub-type of Foo.\nTEST(PropertyTest, WorksForArgumentOfSubType) {\n  // The matcher expects a DerivedClass, but inside the Property() we\n  // say AClass.\n  Matcher<const DerivedClass&> m = Property(&AClass::n, Ge(0));\n\n  DerivedClass d;\n  d.set_n(1);\n  EXPECT_TRUE(m.Matches(d));\n\n  d.set_n(-1);\n  EXPECT_FALSE(m.Matches(d));\n}\n\n// Tests that Property(&Foo::property, m) works when property()'s type\n// and m's argument type are compatible but different.\nTEST(PropertyTest, WorksForCompatibleMatcherType) {\n  // n() returns an int but the inner matcher expects a signed char.\n  Matcher<const AClass&> m = Property(&AClass::n,\n                                      Matcher<signed char>(Ge(0)));\n\n  AClass a;\n  EXPECT_TRUE(m.Matches(a));\n  a.set_n(-1);\n  EXPECT_FALSE(m.Matches(a));\n}\n\n// Tests that Property() can describe itself.\nTEST(PropertyTest, CanDescribeSelf) {\n  Matcher<const AClass&> m = Property(&AClass::n, Ge(0));\n\n  EXPECT_EQ(\"is an object whose given property is >= 0\", Describe(m));\n  EXPECT_EQ(\"is an object whose given property isn't >= 0\",\n            DescribeNegation(m));\n}\n\n// Tests that Property() can explain the match result.\nTEST(PropertyTest, CanExplainMatchResult) {\n  Matcher<const AClass&> m = Property(&AClass::n, Ge(0));\n\n  AClass a;\n  a.set_n(1);\n  EXPECT_EQ(\"whose given property is 1\" + OfType(\"int\"), Explain(m, a));\n\n  m = Property(&AClass::n, GreaterThan(0));\n  EXPECT_EQ(\n      \"whose given property is 1\" + OfType(\"int\") + \", which is 1 more than 0\",\n      Explain(m, a));\n}\n\n// Tests that Property() works when the argument is a pointer to const.\nTEST(PropertyForPointerTest, WorksForPointerToConst) {\n  Matcher<const AClass*> m = Property(&AClass::n, Ge(0));\n\n  AClass a;\n  a.set_n(1);\n  EXPECT_TRUE(m.Matches(&a));\n\n  a.set_n(-1);\n  EXPECT_FALSE(m.Matches(&a));\n}\n\n// Tests that Property() works when the argument is a pointer to non-const.\nTEST(PropertyForPointerTest, WorksForPointerToNonConst) {\n  Matcher<AClass*> m = Property(&AClass::s, StartsWith(\"hi\"));\n\n  AClass a;\n  a.set_s(\"hill\");\n  EXPECT_TRUE(m.Matches(&a));\n\n  a.set_s(\"hole\");\n  EXPECT_FALSE(m.Matches(&a));\n}\n\n// Tests that Property() works when the argument is a reference to a\n// const pointer.\nTEST(PropertyForPointerTest, WorksForReferenceToConstPointer) {\n  Matcher<AClass* const&> m = Property(&AClass::s, StartsWith(\"hi\"));\n\n  AClass a;\n  a.set_s(\"hill\");\n  EXPECT_TRUE(m.Matches(&a));\n\n  a.set_s(\"hole\");\n  EXPECT_FALSE(m.Matches(&a));\n}\n\n// Tests that Property() does not match the NULL pointer.\nTEST(PropertyForPointerTest, WorksForReferenceToNonConstProperty) {\n  Matcher<const AClass*> m = Property(&AClass::x, _);\n  EXPECT_FALSE(m.Matches(NULL));\n}\n\n// Tests that Property(&Foo::property, ...) works when the argument's\n// type is a sub-type of const Foo*.\nTEST(PropertyForPointerTest, WorksForArgumentOfSubType) {\n  // The matcher expects a DerivedClass, but inside the Property() we\n  // say AClass.\n  Matcher<const DerivedClass*> m = Property(&AClass::n, Ge(0));\n\n  DerivedClass d;\n  d.set_n(1);\n  EXPECT_TRUE(m.Matches(&d));\n\n  d.set_n(-1);\n  EXPECT_FALSE(m.Matches(&d));\n}\n\n// Tests that Property() can describe itself when used to match a pointer.\nTEST(PropertyForPointerTest, CanDescribeSelf) {\n  Matcher<const AClass*> m = Property(&AClass::n, Ge(0));\n\n  EXPECT_EQ(\"is an object whose given property is >= 0\", Describe(m));\n  EXPECT_EQ(\"is an object whose given property isn't >= 0\",\n            DescribeNegation(m));\n}\n\n// Tests that Property() can explain the result of matching a pointer.\nTEST(PropertyForPointerTest, CanExplainMatchResult) {\n  Matcher<const AClass*> m = Property(&AClass::n, Ge(0));\n\n  AClass a;\n  a.set_n(1);\n  EXPECT_EQ(\"\", Explain(m, static_cast<const AClass*>(NULL)));\n  EXPECT_EQ(\n      \"which points to an object whose given property is 1\" + OfType(\"int\"),\n      Explain(m, &a));\n\n  m = Property(&AClass::n, GreaterThan(0));\n  EXPECT_EQ(\"which points to an object whose given property is 1\" +\n            OfType(\"int\") + \", which is 1 more than 0\",\n            Explain(m, &a));\n}\n\n// Tests ResultOf.\n\n// Tests that ResultOf(f, ...) compiles and works as expected when f is a\n// function pointer.\nstring IntToStringFunction(int input) { return input == 1 ? \"foo\" : \"bar\"; }\n\nTEST(ResultOfTest, WorksForFunctionPointers) {\n  Matcher<int> matcher = ResultOf(&IntToStringFunction, Eq(string(\"foo\")));\n\n  EXPECT_TRUE(matcher.Matches(1));\n  EXPECT_FALSE(matcher.Matches(2));\n}\n\n// Tests that ResultOf() can describe itself.\nTEST(ResultOfTest, CanDescribeItself) {\n  Matcher<int> matcher = ResultOf(&IntToStringFunction, StrEq(\"foo\"));\n\n  EXPECT_EQ(\"is mapped by the given callable to a value that \"\n            \"is equal to \\\"foo\\\"\", Describe(matcher));\n  EXPECT_EQ(\"is mapped by the given callable to a value that \"\n            \"isn't equal to \\\"foo\\\"\", DescribeNegation(matcher));\n}\n\n// Tests that ResultOf() can explain the match result.\nint IntFunction(int input) { return input == 42 ? 80 : 90; }\n\nTEST(ResultOfTest, CanExplainMatchResult) {\n  Matcher<int> matcher = ResultOf(&IntFunction, Ge(85));\n  EXPECT_EQ(\"which is mapped by the given callable to 90\" + OfType(\"int\"),\n            Explain(matcher, 36));\n\n  matcher = ResultOf(&IntFunction, GreaterThan(85));\n  EXPECT_EQ(\"which is mapped by the given callable to 90\" + OfType(\"int\") +\n            \", which is 5 more than 85\", Explain(matcher, 36));\n}\n\n// Tests that ResultOf(f, ...) compiles and works as expected when f(x)\n// returns a non-reference.\nTEST(ResultOfTest, WorksForNonReferenceResults) {\n  Matcher<int> matcher = ResultOf(&IntFunction, Eq(80));\n\n  EXPECT_TRUE(matcher.Matches(42));\n  EXPECT_FALSE(matcher.Matches(36));\n}\n\n// Tests that ResultOf(f, ...) compiles and works as expected when f(x)\n// returns a reference to non-const.\ndouble& DoubleFunction(double& input) { return input; }  // NOLINT\n\nUncopyable& RefUncopyableFunction(Uncopyable& obj) {  // NOLINT\n  return obj;\n}\n\nTEST(ResultOfTest, WorksForReferenceToNonConstResults) {\n  double x = 3.14;\n  double x2 = x;\n  Matcher<double&> matcher = ResultOf(&DoubleFunction, Ref(x));\n\n  EXPECT_TRUE(matcher.Matches(x));\n  EXPECT_FALSE(matcher.Matches(x2));\n\n  // Test that ResultOf works with uncopyable objects\n  Uncopyable obj(0);\n  Uncopyable obj2(0);\n  Matcher<Uncopyable&> matcher2 =\n      ResultOf(&RefUncopyableFunction, Ref(obj));\n\n  EXPECT_TRUE(matcher2.Matches(obj));\n  EXPECT_FALSE(matcher2.Matches(obj2));\n}\n\n// Tests that ResultOf(f, ...) compiles and works as expected when f(x)\n// returns a reference to const.\nconst string& StringFunction(const string& input) { return input; }\n\nTEST(ResultOfTest, WorksForReferenceToConstResults) {\n  string s = \"foo\";\n  string s2 = s;\n  Matcher<const string&> matcher = ResultOf(&StringFunction, Ref(s));\n\n  EXPECT_TRUE(matcher.Matches(s));\n  EXPECT_FALSE(matcher.Matches(s2));\n}\n\n// Tests that ResultOf(f, m) works when f(x) and m's\n// argument types are compatible but different.\nTEST(ResultOfTest, WorksForCompatibleMatcherTypes) {\n  // IntFunction() returns int but the inner matcher expects a signed char.\n  Matcher<int> matcher = ResultOf(IntFunction, Matcher<signed char>(Ge(85)));\n\n  EXPECT_TRUE(matcher.Matches(36));\n  EXPECT_FALSE(matcher.Matches(42));\n}\n\n// Tests that the program aborts when ResultOf is passed\n// a NULL function pointer.\nTEST(ResultOfDeathTest, DiesOnNullFunctionPointers) {\n  EXPECT_DEATH_IF_SUPPORTED(\n      ResultOf(static_cast<string(*)(int dummy)>(NULL), Eq(string(\"foo\"))),\n               \"NULL function pointer is passed into ResultOf\\\\(\\\\)\\\\.\");\n}\n\n// Tests that ResultOf(f, ...) compiles and works as expected when f is a\n// function reference.\nTEST(ResultOfTest, WorksForFunctionReferences) {\n  Matcher<int> matcher = ResultOf(IntToStringFunction, StrEq(\"foo\"));\n  EXPECT_TRUE(matcher.Matches(1));\n  EXPECT_FALSE(matcher.Matches(2));\n}\n\n// Tests that ResultOf(f, ...) compiles and works as expected when f is a\n// function object.\nstruct Functor : public ::std::unary_function<int, string> {\n  result_type operator()(argument_type input) const {\n    return IntToStringFunction(input);\n  }\n};\n\nTEST(ResultOfTest, WorksForFunctors) {\n  Matcher<int> matcher = ResultOf(Functor(), Eq(string(\"foo\")));\n\n  EXPECT_TRUE(matcher.Matches(1));\n  EXPECT_FALSE(matcher.Matches(2));\n}\n\n// Tests that ResultOf(f, ...) compiles and works as expected when f is a\n// functor with more then one operator() defined. ResultOf() must work\n// for each defined operator().\nstruct PolymorphicFunctor {\n  typedef int result_type;\n  int operator()(int n) { return n; }\n  int operator()(const char* s) { return static_cast<int>(strlen(s)); }\n};\n\nTEST(ResultOfTest, WorksForPolymorphicFunctors) {\n  Matcher<int> matcher_int = ResultOf(PolymorphicFunctor(), Ge(5));\n\n  EXPECT_TRUE(matcher_int.Matches(10));\n  EXPECT_FALSE(matcher_int.Matches(2));\n\n  Matcher<const char*> matcher_string = ResultOf(PolymorphicFunctor(), Ge(5));\n\n  EXPECT_TRUE(matcher_string.Matches(\"long string\"));\n  EXPECT_FALSE(matcher_string.Matches(\"shrt\"));\n}\n\nconst int* ReferencingFunction(const int& n) { return &n; }\n\nstruct ReferencingFunctor {\n  typedef const int* result_type;\n  result_type operator()(const int& n) { return &n; }\n};\n\nTEST(ResultOfTest, WorksForReferencingCallables) {\n  const int n = 1;\n  const int n2 = 1;\n  Matcher<const int&> matcher2 = ResultOf(ReferencingFunction, Eq(&n));\n  EXPECT_TRUE(matcher2.Matches(n));\n  EXPECT_FALSE(matcher2.Matches(n2));\n\n  Matcher<const int&> matcher3 = ResultOf(ReferencingFunctor(), Eq(&n));\n  EXPECT_TRUE(matcher3.Matches(n));\n  EXPECT_FALSE(matcher3.Matches(n2));\n}\n\nclass DivisibleByImpl {\n public:\n  explicit DivisibleByImpl(int a_divider) : divider_(a_divider) {}\n\n  // For testing using ExplainMatchResultTo() with polymorphic matchers.\n  template <typename T>\n  bool MatchAndExplain(const T& n, MatchResultListener* listener) const {\n    *listener << \"which is \" << (n % divider_) << \" modulo \"\n              << divider_;\n    return (n % divider_) == 0;\n  }\n\n  void DescribeTo(ostream* os) const {\n    *os << \"is divisible by \" << divider_;\n  }\n\n  void DescribeNegationTo(ostream* os) const {\n    *os << \"is not divisible by \" << divider_;\n  }\n\n  void set_divider(int a_divider) { divider_ = a_divider; }\n  int divider() const { return divider_; }\n\n private:\n  int divider_;\n};\n\nPolymorphicMatcher<DivisibleByImpl> DivisibleBy(int n) {\n  return MakePolymorphicMatcher(DivisibleByImpl(n));\n}\n\n// Tests that when AllOf() fails, only the first failing matcher is\n// asked to explain why.\nTEST(ExplainMatchResultTest, AllOf_False_False) {\n  const Matcher<int> m = AllOf(DivisibleBy(4), DivisibleBy(3));\n  EXPECT_EQ(\"which is 1 modulo 4\", Explain(m, 5));\n}\n\n// Tests that when AllOf() fails, only the first failing matcher is\n// asked to explain why.\nTEST(ExplainMatchResultTest, AllOf_False_True) {\n  const Matcher<int> m = AllOf(DivisibleBy(4), DivisibleBy(3));\n  EXPECT_EQ(\"which is 2 modulo 4\", Explain(m, 6));\n}\n\n// Tests that when AllOf() fails, only the first failing matcher is\n// asked to explain why.\nTEST(ExplainMatchResultTest, AllOf_True_False) {\n  const Matcher<int> m = AllOf(Ge(1), DivisibleBy(3));\n  EXPECT_EQ(\"which is 2 modulo 3\", Explain(m, 5));\n}\n\n// Tests that when AllOf() succeeds, all matchers are asked to explain\n// why.\nTEST(ExplainMatchResultTest, AllOf_True_True) {\n  const Matcher<int> m = AllOf(DivisibleBy(2), DivisibleBy(3));\n  EXPECT_EQ(\"which is 0 modulo 2, and which is 0 modulo 3\", Explain(m, 6));\n}\n\nTEST(ExplainMatchResultTest, AllOf_True_True_2) {\n  const Matcher<int> m = AllOf(Ge(2), Le(3));\n  EXPECT_EQ(\"\", Explain(m, 2));\n}\n\nTEST(ExplainmatcherResultTest, MonomorphicMatcher) {\n  const Matcher<int> m = GreaterThan(5);\n  EXPECT_EQ(\"which is 1 more than 5\", Explain(m, 6));\n}\n\n// The following two tests verify that values without a public copy\n// ctor can be used as arguments to matchers like Eq(), Ge(), and etc\n// with the help of ByRef().\n\nclass NotCopyable {\n public:\n  explicit NotCopyable(int a_value) : value_(a_value) {}\n\n  int value() const { return value_; }\n\n  bool operator==(const NotCopyable& rhs) const {\n    return value() == rhs.value();\n  }\n\n  bool operator>=(const NotCopyable& rhs) const {\n    return value() >= rhs.value();\n  }\n private:\n  int value_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(NotCopyable);\n};\n\nTEST(ByRefTest, AllowsNotCopyableConstValueInMatchers) {\n  const NotCopyable const_value1(1);\n  const Matcher<const NotCopyable&> m = Eq(ByRef(const_value1));\n\n  const NotCopyable n1(1), n2(2);\n  EXPECT_TRUE(m.Matches(n1));\n  EXPECT_FALSE(m.Matches(n2));\n}\n\nTEST(ByRefTest, AllowsNotCopyableValueInMatchers) {\n  NotCopyable value2(2);\n  const Matcher<NotCopyable&> m = Ge(ByRef(value2));\n\n  NotCopyable n1(1), n2(2);\n  EXPECT_FALSE(m.Matches(n1));\n  EXPECT_TRUE(m.Matches(n2));\n}\n\nTEST(IsEmptyTest, ImplementsIsEmpty) {\n  vector<int> container;\n  EXPECT_THAT(container, IsEmpty());\n  container.push_back(0);\n  EXPECT_THAT(container, Not(IsEmpty()));\n  container.push_back(1);\n  EXPECT_THAT(container, Not(IsEmpty()));\n}\n\nTEST(IsEmptyTest, WorksWithString) {\n  string text;\n  EXPECT_THAT(text, IsEmpty());\n  text = \"foo\";\n  EXPECT_THAT(text, Not(IsEmpty()));\n  text = string(\"\\0\", 1);\n  EXPECT_THAT(text, Not(IsEmpty()));\n}\n\nTEST(IsEmptyTest, CanDescribeSelf) {\n  Matcher<vector<int> > m = IsEmpty();\n  EXPECT_EQ(\"is empty\", Describe(m));\n  EXPECT_EQ(\"isn't empty\", DescribeNegation(m));\n}\n\nTEST(IsEmptyTest, ExplainsResult) {\n  Matcher<vector<int> > m = IsEmpty();\n  vector<int> container;\n  EXPECT_EQ(\"\", Explain(m, container));\n  container.push_back(0);\n  EXPECT_EQ(\"whose size is 1\", Explain(m, container));\n}\n\nTEST(SizeIsTest, ImplementsSizeIs) {\n  vector<int> container;\n  EXPECT_THAT(container, SizeIs(0));\n  EXPECT_THAT(container, Not(SizeIs(1)));\n  container.push_back(0);\n  EXPECT_THAT(container, Not(SizeIs(0)));\n  EXPECT_THAT(container, SizeIs(1));\n  container.push_back(0);\n  EXPECT_THAT(container, Not(SizeIs(0)));\n  EXPECT_THAT(container, SizeIs(2));\n}\n\nTEST(SizeIsTest, WorksWithMap) {\n  map<string, int> container;\n  EXPECT_THAT(container, SizeIs(0));\n  EXPECT_THAT(container, Not(SizeIs(1)));\n  container.insert(make_pair(\"foo\", 1));\n  EXPECT_THAT(container, Not(SizeIs(0)));\n  EXPECT_THAT(container, SizeIs(1));\n  container.insert(make_pair(\"bar\", 2));\n  EXPECT_THAT(container, Not(SizeIs(0)));\n  EXPECT_THAT(container, SizeIs(2));\n}\n\nTEST(SizeIsTest, WorksWithReferences) {\n  vector<int> container;\n  Matcher<const vector<int>&> m = SizeIs(1);\n  EXPECT_THAT(container, Not(m));\n  container.push_back(0);\n  EXPECT_THAT(container, m);\n}\n\nTEST(SizeIsTest, CanDescribeSelf) {\n  Matcher<vector<int> > m = SizeIs(2);\n  EXPECT_EQ(\"size is equal to 2\", Describe(m));\n  EXPECT_EQ(\"size isn't equal to 2\", DescribeNegation(m));\n}\n\nTEST(SizeIsTest, ExplainsResult) {\n  Matcher<vector<int> > m1 = SizeIs(2);\n  Matcher<vector<int> > m2 = SizeIs(Lt(2u));\n  Matcher<vector<int> > m3 = SizeIs(AnyOf(0, 3));\n  Matcher<vector<int> > m4 = SizeIs(GreaterThan(1));\n  vector<int> container;\n  EXPECT_EQ(\"whose size 0 doesn't match\", Explain(m1, container));\n  EXPECT_EQ(\"whose size 0 matches\", Explain(m2, container));\n  EXPECT_EQ(\"whose size 0 matches\", Explain(m3, container));\n  EXPECT_EQ(\"whose size 0 doesn't match, which is 1 less than 1\",\n            Explain(m4, container));\n  container.push_back(0);\n  container.push_back(0);\n  EXPECT_EQ(\"whose size 2 matches\", Explain(m1, container));\n  EXPECT_EQ(\"whose size 2 doesn't match\", Explain(m2, container));\n  EXPECT_EQ(\"whose size 2 doesn't match\", Explain(m3, container));\n  EXPECT_EQ(\"whose size 2 matches, which is 1 more than 1\",\n            Explain(m4, container));\n}\n\n#if GTEST_HAS_TYPED_TEST\n// Tests ContainerEq with different container types, and\n// different element types.\n\ntemplate <typename T>\nclass ContainerEqTest : public testing::Test {};\n\ntypedef testing::Types<\n    set<int>,\n    vector<size_t>,\n    multiset<size_t>,\n    list<int> >\n    ContainerEqTestTypes;\n\nTYPED_TEST_CASE(ContainerEqTest, ContainerEqTestTypes);\n\n// Tests that the filled container is equal to itself.\nTYPED_TEST(ContainerEqTest, EqualsSelf) {\n  static const int vals[] = {1, 1, 2, 3, 5, 8};\n  TypeParam my_set(vals, vals + 6);\n  const Matcher<TypeParam> m = ContainerEq(my_set);\n  EXPECT_TRUE(m.Matches(my_set));\n  EXPECT_EQ(\"\", Explain(m, my_set));\n}\n\n// Tests that missing values are reported.\nTYPED_TEST(ContainerEqTest, ValueMissing) {\n  static const int vals[] = {1, 1, 2, 3, 5, 8};\n  static const int test_vals[] = {2, 1, 8, 5};\n  TypeParam my_set(vals, vals + 6);\n  TypeParam test_set(test_vals, test_vals + 4);\n  const Matcher<TypeParam> m = ContainerEq(my_set);\n  EXPECT_FALSE(m.Matches(test_set));\n  EXPECT_EQ(\"which doesn't have these expected elements: 3\",\n            Explain(m, test_set));\n}\n\n// Tests that added values are reported.\nTYPED_TEST(ContainerEqTest, ValueAdded) {\n  static const int vals[] = {1, 1, 2, 3, 5, 8};\n  static const int test_vals[] = {1, 2, 3, 5, 8, 46};\n  TypeParam my_set(vals, vals + 6);\n  TypeParam test_set(test_vals, test_vals + 6);\n  const Matcher<const TypeParam&> m = ContainerEq(my_set);\n  EXPECT_FALSE(m.Matches(test_set));\n  EXPECT_EQ(\"which has these unexpected elements: 46\", Explain(m, test_set));\n}\n\n// Tests that added and missing values are reported together.\nTYPED_TEST(ContainerEqTest, ValueAddedAndRemoved) {\n  static const int vals[] = {1, 1, 2, 3, 5, 8};\n  static const int test_vals[] = {1, 2, 3, 8, 46};\n  TypeParam my_set(vals, vals + 6);\n  TypeParam test_set(test_vals, test_vals + 5);\n  const Matcher<TypeParam> m = ContainerEq(my_set);\n  EXPECT_FALSE(m.Matches(test_set));\n  EXPECT_EQ(\"which has these unexpected elements: 46,\\n\"\n            \"and doesn't have these expected elements: 5\",\n            Explain(m, test_set));\n}\n\n// Tests duplicated value -- expect no explanation.\nTYPED_TEST(ContainerEqTest, DuplicateDifference) {\n  static const int vals[] = {1, 1, 2, 3, 5, 8};\n  static const int test_vals[] = {1, 2, 3, 5, 8};\n  TypeParam my_set(vals, vals + 6);\n  TypeParam test_set(test_vals, test_vals + 5);\n  const Matcher<const TypeParam&> m = ContainerEq(my_set);\n  // Depending on the container, match may be true or false\n  // But in any case there should be no explanation.\n  EXPECT_EQ(\"\", Explain(m, test_set));\n}\n#endif  // GTEST_HAS_TYPED_TEST\n\n// Tests that mutliple missing values are reported.\n// Using just vector here, so order is predicatble.\nTEST(ContainerEqExtraTest, MultipleValuesMissing) {\n  static const int vals[] = {1, 1, 2, 3, 5, 8};\n  static const int test_vals[] = {2, 1, 5};\n  vector<int> my_set(vals, vals + 6);\n  vector<int> test_set(test_vals, test_vals + 3);\n  const Matcher<vector<int> > m = ContainerEq(my_set);\n  EXPECT_FALSE(m.Matches(test_set));\n  EXPECT_EQ(\"which doesn't have these expected elements: 3, 8\",\n            Explain(m, test_set));\n}\n\n// Tests that added values are reported.\n// Using just vector here, so order is predicatble.\nTEST(ContainerEqExtraTest, MultipleValuesAdded) {\n  static const int vals[] = {1, 1, 2, 3, 5, 8};\n  static const int test_vals[] = {1, 2, 92, 3, 5, 8, 46};\n  list<size_t> my_set(vals, vals + 6);\n  list<size_t> test_set(test_vals, test_vals + 7);\n  const Matcher<const list<size_t>&> m = ContainerEq(my_set);\n  EXPECT_FALSE(m.Matches(test_set));\n  EXPECT_EQ(\"which has these unexpected elements: 92, 46\",\n            Explain(m, test_set));\n}\n\n// Tests that added and missing values are reported together.\nTEST(ContainerEqExtraTest, MultipleValuesAddedAndRemoved) {\n  static const int vals[] = {1, 1, 2, 3, 5, 8};\n  static const int test_vals[] = {1, 2, 3, 92, 46};\n  list<size_t> my_set(vals, vals + 6);\n  list<size_t> test_set(test_vals, test_vals + 5);\n  const Matcher<const list<size_t> > m = ContainerEq(my_set);\n  EXPECT_FALSE(m.Matches(test_set));\n  EXPECT_EQ(\"which has these unexpected elements: 92, 46,\\n\"\n            \"and doesn't have these expected elements: 5, 8\",\n            Explain(m, test_set));\n}\n\n// Tests to see that duplicate elements are detected,\n// but (as above) not reported in the explanation.\nTEST(ContainerEqExtraTest, MultiSetOfIntDuplicateDifference) {\n  static const int vals[] = {1, 1, 2, 3, 5, 8};\n  static const int test_vals[] = {1, 2, 3, 5, 8};\n  vector<int> my_set(vals, vals + 6);\n  vector<int> test_set(test_vals, test_vals + 5);\n  const Matcher<vector<int> > m = ContainerEq(my_set);\n  EXPECT_TRUE(m.Matches(my_set));\n  EXPECT_FALSE(m.Matches(test_set));\n  // There is nothing to report when both sets contain all the same values.\n  EXPECT_EQ(\"\", Explain(m, test_set));\n}\n\n// Tests that ContainerEq works for non-trivial associative containers,\n// like maps.\nTEST(ContainerEqExtraTest, WorksForMaps) {\n  map<int, std::string> my_map;\n  my_map[0] = \"a\";\n  my_map[1] = \"b\";\n\n  map<int, std::string> test_map;\n  test_map[0] = \"aa\";\n  test_map[1] = \"b\";\n\n  const Matcher<const map<int, std::string>&> m = ContainerEq(my_map);\n  EXPECT_TRUE(m.Matches(my_map));\n  EXPECT_FALSE(m.Matches(test_map));\n\n  EXPECT_EQ(\"which has these unexpected elements: (0, \\\"aa\\\"),\\n\"\n            \"and doesn't have these expected elements: (0, \\\"a\\\")\",\n            Explain(m, test_map));\n}\n\nTEST(ContainerEqExtraTest, WorksForNativeArray) {\n  int a1[] = { 1, 2, 3 };\n  int a2[] = { 1, 2, 3 };\n  int b[] = { 1, 2, 4 };\n\n  EXPECT_THAT(a1, ContainerEq(a2));\n  EXPECT_THAT(a1, Not(ContainerEq(b)));\n}\n\nTEST(ContainerEqExtraTest, WorksForTwoDimensionalNativeArray) {\n  const char a1[][3] = { \"hi\", \"lo\" };\n  const char a2[][3] = { \"hi\", \"lo\" };\n  const char b[][3] = { \"lo\", \"hi\" };\n\n  // Tests using ContainerEq() in the first dimension.\n  EXPECT_THAT(a1, ContainerEq(a2));\n  EXPECT_THAT(a1, Not(ContainerEq(b)));\n\n  // Tests using ContainerEq() in the second dimension.\n  EXPECT_THAT(a1, ElementsAre(ContainerEq(a2[0]), ContainerEq(a2[1])));\n  EXPECT_THAT(a1, ElementsAre(Not(ContainerEq(b[0])), ContainerEq(a2[1])));\n}\n\nTEST(ContainerEqExtraTest, WorksForNativeArrayAsTuple) {\n  const int a1[] = { 1, 2, 3 };\n  const int a2[] = { 1, 2, 3 };\n  const int b[] = { 1, 2, 3, 4 };\n\n  const int* const p1 = a1;\n  EXPECT_THAT(make_tuple(p1, 3), ContainerEq(a2));\n  EXPECT_THAT(make_tuple(p1, 3), Not(ContainerEq(b)));\n\n  const int c[] = { 1, 3, 2 };\n  EXPECT_THAT(make_tuple(p1, 3), Not(ContainerEq(c)));\n}\n\nTEST(ContainerEqExtraTest, CopiesNativeArrayParameter) {\n  std::string a1[][3] = {\n    { \"hi\", \"hello\", \"ciao\" },\n    { \"bye\", \"see you\", \"ciao\" }\n  };\n\n  std::string a2[][3] = {\n    { \"hi\", \"hello\", \"ciao\" },\n    { \"bye\", \"see you\", \"ciao\" }\n  };\n\n  const Matcher<const std::string(&)[2][3]> m = ContainerEq(a2);\n  EXPECT_THAT(a1, m);\n\n  a2[0][0] = \"ha\";\n  EXPECT_THAT(a1, m);\n}\n\nTEST(WhenSortedByTest, WorksForEmptyContainer) {\n  const vector<int> numbers;\n  EXPECT_THAT(numbers, WhenSortedBy(less<int>(), ElementsAre()));\n  EXPECT_THAT(numbers, Not(WhenSortedBy(less<int>(), ElementsAre(1))));\n}\n\nTEST(WhenSortedByTest, WorksForNonEmptyContainer) {\n  vector<unsigned> numbers;\n  numbers.push_back(3);\n  numbers.push_back(1);\n  numbers.push_back(2);\n  numbers.push_back(2);\n  EXPECT_THAT(numbers, WhenSortedBy(greater<unsigned>(),\n                                    ElementsAre(3, 2, 2, 1)));\n  EXPECT_THAT(numbers, Not(WhenSortedBy(greater<unsigned>(),\n                                        ElementsAre(1, 2, 2, 3))));\n}\n\nTEST(WhenSortedByTest, WorksForNonVectorContainer) {\n  list<string> words;\n  words.push_back(\"say\");\n  words.push_back(\"hello\");\n  words.push_back(\"world\");\n  EXPECT_THAT(words, WhenSortedBy(less<string>(),\n                                  ElementsAre(\"hello\", \"say\", \"world\")));\n  EXPECT_THAT(words, Not(WhenSortedBy(less<string>(),\n                                      ElementsAre(\"say\", \"hello\", \"world\"))));\n}\n\nTEST(WhenSortedByTest, WorksForNativeArray) {\n  const int numbers[] = { 1, 3, 2, 4 };\n  const int sorted_numbers[] = { 1, 2, 3, 4 };\n  EXPECT_THAT(numbers, WhenSortedBy(less<int>(), ElementsAre(1, 2, 3, 4)));\n  EXPECT_THAT(numbers, WhenSortedBy(less<int>(),\n                                    ElementsAreArray(sorted_numbers)));\n  EXPECT_THAT(numbers, Not(WhenSortedBy(less<int>(), ElementsAre(1, 3, 2, 4))));\n}\n\nTEST(WhenSortedByTest, CanDescribeSelf) {\n  const Matcher<vector<int> > m = WhenSortedBy(less<int>(), ElementsAre(1, 2));\n  EXPECT_EQ(\"(when sorted) has 2 elements where\\n\"\n            \"element #0 is equal to 1,\\n\"\n            \"element #1 is equal to 2\",\n            Describe(m));\n  EXPECT_EQ(\"(when sorted) doesn't have 2 elements, or\\n\"\n            \"element #0 isn't equal to 1, or\\n\"\n            \"element #1 isn't equal to 2\",\n            DescribeNegation(m));\n}\n\nTEST(WhenSortedByTest, ExplainsMatchResult) {\n  const int a[] = { 2, 1 };\n  EXPECT_EQ(\"which is { 1, 2 } when sorted, whose element #0 doesn't match\",\n            Explain(WhenSortedBy(less<int>(), ElementsAre(2, 3)), a));\n  EXPECT_EQ(\"which is { 1, 2 } when sorted\",\n            Explain(WhenSortedBy(less<int>(), ElementsAre(1, 2)), a));\n}\n\n// WhenSorted() is a simple wrapper on WhenSortedBy().  Hence we don't\n// need to test it as exhaustively as we test the latter.\n\nTEST(WhenSortedTest, WorksForEmptyContainer) {\n  const vector<int> numbers;\n  EXPECT_THAT(numbers, WhenSorted(ElementsAre()));\n  EXPECT_THAT(numbers, Not(WhenSorted(ElementsAre(1))));\n}\n\nTEST(WhenSortedTest, WorksForNonEmptyContainer) {\n  list<string> words;\n  words.push_back(\"3\");\n  words.push_back(\"1\");\n  words.push_back(\"2\");\n  words.push_back(\"2\");\n  EXPECT_THAT(words, WhenSorted(ElementsAre(\"1\", \"2\", \"2\", \"3\")));\n  EXPECT_THAT(words, Not(WhenSorted(ElementsAre(\"3\", \"1\", \"2\", \"2\"))));\n}\n\nTEST(WhenSortedTest, WorksForMapTypes) {\n    map<string, int> word_counts;\n    word_counts[\"and\"] = 1;\n    word_counts[\"the\"] = 1;\n    word_counts[\"buffalo\"] = 2;\n    EXPECT_THAT(word_counts, WhenSorted(ElementsAre(\n            Pair(\"and\", 1), Pair(\"buffalo\", 2), Pair(\"the\", 1))));\n    EXPECT_THAT(word_counts, Not(WhenSorted(ElementsAre(\n            Pair(\"and\", 1), Pair(\"the\", 1), Pair(\"buffalo\", 2)))));\n}\n\nTEST(WhenSortedTest, WorksForMultiMapTypes) {\n    multimap<int, int> ifib;\n    ifib.insert(make_pair(8, 6));\n    ifib.insert(make_pair(2, 3));\n    ifib.insert(make_pair(1, 1));\n    ifib.insert(make_pair(3, 4));\n    ifib.insert(make_pair(1, 2));\n    ifib.insert(make_pair(5, 5));\n    EXPECT_THAT(ifib, WhenSorted(ElementsAre(Pair(1, 1),\n                                             Pair(1, 2),\n                                             Pair(2, 3),\n                                             Pair(3, 4),\n                                             Pair(5, 5),\n                                             Pair(8, 6))));\n    EXPECT_THAT(ifib, Not(WhenSorted(ElementsAre(Pair(8, 6),\n                                                 Pair(2, 3),\n                                                 Pair(1, 1),\n                                                 Pair(3, 4),\n                                                 Pair(1, 2),\n                                                 Pair(5, 5)))));\n}\n\nTEST(WhenSortedTest, WorksForPolymorphicMatcher) {\n    std::deque<int> d;\n    d.push_back(2);\n    d.push_back(1);\n    EXPECT_THAT(d, WhenSorted(ElementsAre(1, 2)));\n    EXPECT_THAT(d, Not(WhenSorted(ElementsAre(2, 1))));\n}\n\nTEST(WhenSortedTest, WorksForVectorConstRefMatcher) {\n    std::deque<int> d;\n    d.push_back(2);\n    d.push_back(1);\n    Matcher<const std::vector<int>&> vector_match = ElementsAre(1, 2);\n    EXPECT_THAT(d, WhenSorted(vector_match));\n    Matcher<const std::vector<int>&> not_vector_match = ElementsAre(2, 1);\n    EXPECT_THAT(d, Not(WhenSorted(not_vector_match)));\n}\n\n// Deliberately bare pseudo-container.\n// Offers only begin() and end() accessors, yielding InputIterator.\ntemplate <typename T>\nclass Streamlike {\n private:\n  class ConstIter;\n public:\n  typedef ConstIter const_iterator;\n  typedef T value_type;\n\n  template <typename InIter>\n  Streamlike(InIter first, InIter last) : remainder_(first, last) {}\n\n  const_iterator begin() const {\n    return const_iterator(this, remainder_.begin());\n  }\n  const_iterator end() const {\n    return const_iterator(this, remainder_.end());\n  }\n\n private:\n  class ConstIter : public std::iterator<std::input_iterator_tag,\n                                         value_type,\n                                         ptrdiff_t,\n                                         const value_type&,\n                                         const value_type*> {\n   public:\n    ConstIter(const Streamlike* s,\n              typename std::list<value_type>::iterator pos)\n        : s_(s), pos_(pos) {}\n\n    const value_type& operator*() const { return *pos_; }\n    const value_type* operator->() const { return &*pos_; }\n    ConstIter& operator++() {\n      s_->remainder_.erase(pos_++);\n      return *this;\n    }\n\n    // *iter++ is required to work (see std::istreambuf_iterator).\n    // (void)iter++ is also required to work.\n    class PostIncrProxy {\n     public:\n      explicit PostIncrProxy(const value_type& value) : value_(value) {}\n      value_type operator*() const { return value_; }\n     private:\n      value_type value_;\n    };\n    PostIncrProxy operator++(int) {\n      PostIncrProxy proxy(**this);\n      ++(*this);\n      return proxy;\n    }\n\n    friend bool operator==(const ConstIter& a, const ConstIter& b) {\n      return a.s_ == b.s_ && a.pos_ == b.pos_;\n    }\n    friend bool operator!=(const ConstIter& a, const ConstIter& b) {\n      return !(a == b);\n    }\n\n   private:\n    const Streamlike* s_;\n    typename std::list<value_type>::iterator pos_;\n  };\n\n  friend std::ostream& operator<<(std::ostream& os, const Streamlike& s) {\n    os << \"[\";\n    typedef typename std::list<value_type>::const_iterator Iter;\n    const char* sep = \"\";\n    for (Iter it = s.remainder_.begin(); it != s.remainder_.end(); ++it) {\n      os << sep << *it;\n      sep = \",\";\n    }\n    os << \"]\";\n    return os;\n  }\n\n  mutable std::list<value_type> remainder_;  // modified by iteration\n};\n\nTEST(StreamlikeTest, Iteration) {\n  const int a[5] = { 2, 1, 4, 5, 3 };\n  Streamlike<int> s(a, a + 5);\n  Streamlike<int>::const_iterator it = s.begin();\n  const int* ip = a;\n  while (it != s.end()) {\n    SCOPED_TRACE(ip - a);\n    EXPECT_EQ(*ip++, *it++);\n  }\n}\n\nTEST(WhenSortedTest, WorksForStreamlike) {\n  // Streamlike 'container' provides only minimal iterator support.\n  // Its iterators are tagged with input_iterator_tag.\n  const int a[5] = { 2, 1, 4, 5, 3 };\n  Streamlike<int> s(a, a + GMOCK_ARRAY_SIZE_(a));\n  EXPECT_THAT(s, WhenSorted(ElementsAre(1, 2, 3, 4, 5)));\n  EXPECT_THAT(s, Not(WhenSorted(ElementsAre(2, 1, 4, 5, 3))));\n}\n\nTEST(WhenSortedTest, WorksForVectorConstRefMatcherOnStreamlike) {\n  const int a[] = { 2, 1, 4, 5, 3 };\n  Streamlike<int> s(a, a + GMOCK_ARRAY_SIZE_(a));\n  Matcher<const std::vector<int>&> vector_match = ElementsAre(1, 2, 3, 4, 5);\n  EXPECT_THAT(s, WhenSorted(vector_match));\n  EXPECT_THAT(s, Not(WhenSorted(ElementsAre(2, 1, 4, 5, 3))));\n}\n\n// Tests using ElementsAre() and ElementsAreArray() with stream-like\n// \"containers\".\n\nTEST(ElemensAreStreamTest, WorksForStreamlike) {\n  const int a[5] = { 1, 2, 3, 4, 5 };\n  Streamlike<int> s(a, a + GMOCK_ARRAY_SIZE_(a));\n  EXPECT_THAT(s, ElementsAre(1, 2, 3, 4, 5));\n  EXPECT_THAT(s, Not(ElementsAre(2, 1, 4, 5, 3)));\n}\n\nTEST(ElemensAreArrayStreamTest, WorksForStreamlike) {\n  const int a[5] = { 1, 2, 3, 4, 5 };\n  Streamlike<int> s(a, a + GMOCK_ARRAY_SIZE_(a));\n\n  vector<int> expected;\n  expected.push_back(1);\n  expected.push_back(2);\n  expected.push_back(3);\n  expected.push_back(4);\n  expected.push_back(5);\n  EXPECT_THAT(s, ElementsAreArray(expected));\n\n  expected[3] = 0;\n  EXPECT_THAT(s, Not(ElementsAreArray(expected)));\n}\n\n// Tests for UnorderedElementsAreArray()\n\nTEST(UnorderedElementsAreArrayTest, SucceedsWhenExpected) {\n  const int a[] = { 0, 1, 2, 3, 4 };\n  std::vector<int> s(a, a + GMOCK_ARRAY_SIZE_(a));\n  do {\n    StringMatchResultListener listener;\n    EXPECT_TRUE(ExplainMatchResult(UnorderedElementsAreArray(a),\n                                   s, &listener)) << listener.str();\n  } while (std::next_permutation(s.begin(), s.end()));\n}\n\nTEST(UnorderedElementsAreArrayTest, VectorBool) {\n  const bool a[] = { 0, 1, 0, 1, 1 };\n  const bool b[] = { 1, 0, 1, 1, 0 };\n  std::vector<bool> expected(a, a + GMOCK_ARRAY_SIZE_(a));\n  std::vector<bool> actual(b, b + GMOCK_ARRAY_SIZE_(b));\n  StringMatchResultListener listener;\n  EXPECT_TRUE(ExplainMatchResult(UnorderedElementsAreArray(expected),\n                                 actual, &listener)) << listener.str();\n}\n\nTEST(UnorderedElementsAreArrayTest, WorksForStreamlike) {\n  // Streamlike 'container' provides only minimal iterator support.\n  // Its iterators are tagged with input_iterator_tag, and it has no\n  // size() or empty() methods.\n  const int a[5] = { 2, 1, 4, 5, 3 };\n  Streamlike<int> s(a, a + GMOCK_ARRAY_SIZE_(a));\n\n  ::std::vector<int> expected;\n  expected.push_back(1);\n  expected.push_back(2);\n  expected.push_back(3);\n  expected.push_back(4);\n  expected.push_back(5);\n  EXPECT_THAT(s, UnorderedElementsAreArray(expected));\n\n  expected.push_back(6);\n  EXPECT_THAT(s, Not(UnorderedElementsAreArray(expected)));\n}\n\n#if GTEST_LANG_CXX11\n\nTEST(UnorderedElementsAreArrayTest, TakesInitializerList) {\n  const int a[5] = { 2, 1, 4, 5, 3 };\n  EXPECT_THAT(a, UnorderedElementsAreArray({ 1, 2, 3, 4, 5 }));\n  EXPECT_THAT(a, Not(UnorderedElementsAreArray({ 1, 2, 3, 4, 6 })));\n}\n\nTEST(UnorderedElementsAreArrayTest, TakesInitializerListOfCStrings) {\n  const string a[5] = { \"a\", \"b\", \"c\", \"d\", \"e\" };\n  EXPECT_THAT(a, UnorderedElementsAreArray({ \"a\", \"b\", \"c\", \"d\", \"e\" }));\n  EXPECT_THAT(a, Not(UnorderedElementsAreArray({ \"a\", \"b\", \"c\", \"d\", \"ef\" })));\n}\n\nTEST(UnorderedElementsAreArrayTest, TakesInitializerListOfSameTypedMatchers) {\n  const int a[5] = { 2, 1, 4, 5, 3 };\n  EXPECT_THAT(a, UnorderedElementsAreArray(\n      { Eq(1), Eq(2), Eq(3), Eq(4), Eq(5) }));\n  EXPECT_THAT(a, Not(UnorderedElementsAreArray(\n      { Eq(1), Eq(2), Eq(3), Eq(4), Eq(6) })));\n}\n\nTEST(UnorderedElementsAreArrayTest,\n     TakesInitializerListOfDifferentTypedMatchers) {\n  const int a[5] = { 2, 1, 4, 5, 3 };\n  // The compiler cannot infer the type of the initializer list if its\n  // elements have different types.  We must explicitly specify the\n  // unified element type in this case.\n  EXPECT_THAT(a, UnorderedElementsAreArray<Matcher<int> >(\n      { Eq(1), Ne(-2), Ge(3), Le(4), Eq(5) }));\n  EXPECT_THAT(a, Not(UnorderedElementsAreArray<Matcher<int> >(\n      { Eq(1), Ne(-2), Ge(3), Le(4), Eq(6) })));\n}\n\n#endif  // GTEST_LANG_CXX11\n\nclass UnorderedElementsAreTest : public testing::Test {\n protected:\n  typedef std::vector<int> IntVec;\n};\n\nTEST_F(UnorderedElementsAreTest, SucceedsWhenExpected) {\n  const int a[] = { 1, 2, 3 };\n  std::vector<int> s(a, a + GMOCK_ARRAY_SIZE_(a));\n  do {\n    StringMatchResultListener listener;\n    EXPECT_TRUE(ExplainMatchResult(UnorderedElementsAre(1, 2, 3),\n                                   s, &listener)) << listener.str();\n  } while (std::next_permutation(s.begin(), s.end()));\n}\n\nTEST_F(UnorderedElementsAreTest, FailsWhenAnElementMatchesNoMatcher) {\n  const int a[] = { 1, 2, 3 };\n  std::vector<int> s(a, a + GMOCK_ARRAY_SIZE_(a));\n  std::vector<Matcher<int> > mv;\n  mv.push_back(1);\n  mv.push_back(2);\n  mv.push_back(2);\n  // The element with value '3' matches nothing: fail fast.\n  StringMatchResultListener listener;\n  EXPECT_FALSE(ExplainMatchResult(UnorderedElementsAreArray(mv),\n                                  s, &listener)) << listener.str();\n}\n\nTEST_F(UnorderedElementsAreTest, WorksForStreamlike) {\n  // Streamlike 'container' provides only minimal iterator support.\n  // Its iterators are tagged with input_iterator_tag, and it has no\n  // size() or empty() methods.\n  const int a[5] = { 2, 1, 4, 5, 3 };\n  Streamlike<int> s(a, a + GMOCK_ARRAY_SIZE_(a));\n\n  EXPECT_THAT(s, UnorderedElementsAre(1, 2, 3, 4, 5));\n  EXPECT_THAT(s, Not(UnorderedElementsAre(2, 2, 3, 4, 5)));\n}\n\n// One naive implementation of the matcher runs in O(N!) time, which is too\n// slow for many real-world inputs. This test shows that our matcher can match\n// 100 inputs very quickly (a few milliseconds).  An O(100!) is 10^158\n// iterations and obviously effectively incomputable.\n// [ RUN      ] UnorderedElementsAreTest.Performance\n// [       OK ] UnorderedElementsAreTest.Performance (4 ms)\nTEST_F(UnorderedElementsAreTest, Performance) {\n  std::vector<int> s;\n  std::vector<Matcher<int> > mv;\n  for (int i = 0; i < 100; ++i) {\n    s.push_back(i);\n    mv.push_back(_);\n  }\n  mv[50] = Eq(0);\n  StringMatchResultListener listener;\n  EXPECT_TRUE(ExplainMatchResult(UnorderedElementsAreArray(mv),\n                                 s, &listener)) << listener.str();\n}\n\n// Another variant of 'Performance' with similar expectations.\n// [ RUN      ] UnorderedElementsAreTest.PerformanceHalfStrict\n// [       OK ] UnorderedElementsAreTest.PerformanceHalfStrict (4 ms)\nTEST_F(UnorderedElementsAreTest, PerformanceHalfStrict) {\n  std::vector<int> s;\n  std::vector<Matcher<int> > mv;\n  for (int i = 0; i < 100; ++i) {\n    s.push_back(i);\n    if (i & 1) {\n      mv.push_back(_);\n    } else {\n      mv.push_back(i);\n    }\n  }\n  StringMatchResultListener listener;\n  EXPECT_TRUE(ExplainMatchResult(UnorderedElementsAreArray(mv),\n                                 s, &listener)) << listener.str();\n}\n\nTEST_F(UnorderedElementsAreTest, FailMessageCountWrong) {\n  std::vector<int> v;\n  v.push_back(4);\n  StringMatchResultListener listener;\n  EXPECT_FALSE(ExplainMatchResult(UnorderedElementsAre(1, 2, 3),\n                                  v, &listener)) << listener.str();\n  EXPECT_THAT(listener.str(), Eq(\"which has 1 element\"));\n}\n\nTEST_F(UnorderedElementsAreTest, FailMessageCountWrongZero) {\n  std::vector<int> v;\n  StringMatchResultListener listener;\n  EXPECT_FALSE(ExplainMatchResult(UnorderedElementsAre(1, 2, 3),\n                                  v, &listener)) << listener.str();\n  EXPECT_THAT(listener.str(), Eq(\"\"));\n}\n\nTEST_F(UnorderedElementsAreTest, FailMessageUnmatchedMatchers) {\n  std::vector<int> v;\n  v.push_back(1);\n  v.push_back(1);\n  StringMatchResultListener listener;\n  EXPECT_FALSE(ExplainMatchResult(UnorderedElementsAre(1, 2),\n                                  v, &listener)) << listener.str();\n  EXPECT_THAT(\n      listener.str(),\n      Eq(\"where the following matchers don't match any elements:\\n\"\n         \"matcher #1: is equal to 2\"));\n}\n\nTEST_F(UnorderedElementsAreTest, FailMessageUnmatchedElements) {\n  std::vector<int> v;\n  v.push_back(1);\n  v.push_back(2);\n  StringMatchResultListener listener;\n  EXPECT_FALSE(ExplainMatchResult(UnorderedElementsAre(1, 1),\n                                  v, &listener)) << listener.str();\n  EXPECT_THAT(\n      listener.str(),\n      Eq(\"where the following elements don't match any matchers:\\n\"\n         \"element #1: 2\"));\n}\n\nTEST_F(UnorderedElementsAreTest, FailMessageUnmatchedMatcherAndElement) {\n  std::vector<int> v;\n  v.push_back(2);\n  v.push_back(3);\n  StringMatchResultListener listener;\n  EXPECT_FALSE(ExplainMatchResult(UnorderedElementsAre(1, 2),\n                                  v, &listener)) << listener.str();\n  EXPECT_THAT(\n      listener.str(),\n      Eq(\"where\"\n         \" the following matchers don't match any elements:\\n\"\n         \"matcher #0: is equal to 1\\n\"\n         \"and\"\n         \" where\"\n         \" the following elements don't match any matchers:\\n\"\n         \"element #1: 3\"));\n}\n\n// Test helper for formatting element, matcher index pairs in expectations.\nstatic string EMString(int element, int matcher) {\n  stringstream ss;\n  ss << \"(element #\" << element << \", matcher #\" << matcher << \")\";\n  return ss.str();\n}\n\nTEST_F(UnorderedElementsAreTest, FailMessageImperfectMatchOnly) {\n  // A situation where all elements and matchers have a match\n  // associated with them, but the max matching is not perfect.\n  std::vector<string> v;\n  v.push_back(\"a\");\n  v.push_back(\"b\");\n  v.push_back(\"c\");\n  StringMatchResultListener listener;\n  EXPECT_FALSE(ExplainMatchResult(\n      UnorderedElementsAre(\"a\", \"a\", AnyOf(\"b\", \"c\")), v, &listener))\n      << listener.str();\n\n  string prefix =\n      \"where no permutation of the elements can satisfy all matchers, \"\n      \"and the closest match is 2 of 3 matchers with the \"\n      \"pairings:\\n\";\n\n  // We have to be a bit loose here, because there are 4 valid max matches.\n  EXPECT_THAT(\n      listener.str(),\n      AnyOf(prefix + \"{\\n  \" + EMString(0, 0) +\n                     \",\\n  \" + EMString(1, 2) + \"\\n}\",\n            prefix + \"{\\n  \" + EMString(0, 1) +\n                     \",\\n  \" + EMString(1, 2) + \"\\n}\",\n            prefix + \"{\\n  \" + EMString(0, 0) +\n                     \",\\n  \" + EMString(2, 2) + \"\\n}\",\n            prefix + \"{\\n  \" + EMString(0, 1) +\n                     \",\\n  \" + EMString(2, 2) + \"\\n}\"));\n}\n\nTEST_F(UnorderedElementsAreTest, Describe) {\n  EXPECT_THAT(Describe<IntVec>(UnorderedElementsAre()),\n              Eq(\"is empty\"));\n  EXPECT_THAT(\n      Describe<IntVec>(UnorderedElementsAre(345)),\n      Eq(\"has 1 element and that element is equal to 345\"));\n  EXPECT_THAT(\n      Describe<IntVec>(UnorderedElementsAre(111, 222, 333)),\n      Eq(\"has 3 elements and there exists some permutation \"\n         \"of elements such that:\\n\"\n         \" - element #0 is equal to 111, and\\n\"\n         \" - element #1 is equal to 222, and\\n\"\n         \" - element #2 is equal to 333\"));\n}\n\nTEST_F(UnorderedElementsAreTest, DescribeNegation) {\n  EXPECT_THAT(DescribeNegation<IntVec>(UnorderedElementsAre()),\n              Eq(\"isn't empty\"));\n  EXPECT_THAT(\n      DescribeNegation<IntVec>(UnorderedElementsAre(345)),\n      Eq(\"doesn't have 1 element, or has 1 element that isn't equal to 345\"));\n  EXPECT_THAT(\n      DescribeNegation<IntVec>(UnorderedElementsAre(123, 234, 345)),\n      Eq(\"doesn't have 3 elements, or there exists no permutation \"\n         \"of elements such that:\\n\"\n         \" - element #0 is equal to 123, and\\n\"\n         \" - element #1 is equal to 234, and\\n\"\n         \" - element #2 is equal to 345\"));\n}\n\nnamespace {\n\n// Used as a check on the more complex max flow method used in the\n// real testing::internal::FindMaxBipartiteMatching. This method is\n// compatible but runs in worst-case factorial time, so we only\n// use it in testing for small problem sizes.\ntemplate <typename Graph>\nclass BacktrackingMaxBPMState {\n public:\n  // Does not take ownership of 'g'.\n  explicit BacktrackingMaxBPMState(const Graph* g) : graph_(g) { }\n\n  ElementMatcherPairs Compute() {\n    if (graph_->LhsSize() == 0 || graph_->RhsSize() == 0) {\n      return best_so_far_;\n    }\n    lhs_used_.assign(graph_->LhsSize(), kUnused);\n    rhs_used_.assign(graph_->RhsSize(), kUnused);\n    for (size_t irhs = 0; irhs < graph_->RhsSize(); ++irhs) {\n      matches_.clear();\n      RecurseInto(irhs);\n      if (best_so_far_.size() == graph_->RhsSize())\n        break;\n    }\n    return best_so_far_;\n  }\n\n private:\n  static const size_t kUnused = static_cast<size_t>(-1);\n\n  void PushMatch(size_t lhs, size_t rhs) {\n    matches_.push_back(ElementMatcherPair(lhs, rhs));\n    lhs_used_[lhs] = rhs;\n    rhs_used_[rhs] = lhs;\n    if (matches_.size() > best_so_far_.size()) {\n      best_so_far_ = matches_;\n    }\n  }\n\n  void PopMatch() {\n    const ElementMatcherPair& back = matches_.back();\n    lhs_used_[back.first] = kUnused;\n    rhs_used_[back.second] = kUnused;\n    matches_.pop_back();\n  }\n\n  bool RecurseInto(size_t irhs) {\n    if (rhs_used_[irhs] != kUnused) {\n      return true;\n    }\n    for (size_t ilhs = 0; ilhs < graph_->LhsSize(); ++ilhs) {\n      if (lhs_used_[ilhs] != kUnused) {\n        continue;\n      }\n      if (!graph_->HasEdge(ilhs, irhs)) {\n        continue;\n      }\n      PushMatch(ilhs, irhs);\n      if (best_so_far_.size() == graph_->RhsSize()) {\n        return false;\n      }\n      for (size_t mi = irhs + 1; mi < graph_->RhsSize(); ++mi) {\n        if (!RecurseInto(mi)) return false;\n      }\n      PopMatch();\n    }\n    return true;\n  }\n\n  const Graph* graph_;  // not owned\n  std::vector<size_t> lhs_used_;\n  std::vector<size_t> rhs_used_;\n  ElementMatcherPairs matches_;\n  ElementMatcherPairs best_so_far_;\n};\n\ntemplate <typename Graph>\nconst size_t BacktrackingMaxBPMState<Graph>::kUnused;\n\n}  // namespace\n\n// Implement a simple backtracking algorithm to determine if it is possible\n// to find one element per matcher, without reusing elements.\ntemplate <typename Graph>\nElementMatcherPairs\nFindBacktrackingMaxBPM(const Graph& g) {\n  return BacktrackingMaxBPMState<Graph>(&g).Compute();\n}\n\nclass BacktrackingBPMTest : public ::testing::Test { };\n\n// Tests the MaxBipartiteMatching algorithm with square matrices.\n// The single int param is the # of nodes on each of the left and right sides.\nclass BipartiteTest : public ::testing::TestWithParam<int> { };\n\n// Verify all match graphs up to some moderate number of edges.\nTEST_P(BipartiteTest, Exhaustive) {\n  int nodes = GetParam();\n  MatchMatrix graph(nodes, nodes);\n  do {\n    ElementMatcherPairs matches =\n        internal::FindMaxBipartiteMatching(graph);\n    EXPECT_EQ(FindBacktrackingMaxBPM(graph).size(), matches.size())\n        << \"graph: \" << graph.DebugString();\n    // Check that all elements of matches are in the graph.\n    // Check that elements of first and second are unique.\n    std::vector<bool> seen_element(graph.LhsSize());\n    std::vector<bool> seen_matcher(graph.RhsSize());\n    SCOPED_TRACE(PrintToString(matches));\n    for (size_t i = 0; i < matches.size(); ++i) {\n      size_t ilhs = matches[i].first;\n      size_t irhs = matches[i].second;\n      EXPECT_TRUE(graph.HasEdge(ilhs, irhs));\n      EXPECT_FALSE(seen_element[ilhs]);\n      EXPECT_FALSE(seen_matcher[irhs]);\n      seen_element[ilhs] = true;\n      seen_matcher[irhs] = true;\n    }\n  } while (graph.NextGraph());\n}\n\nINSTANTIATE_TEST_CASE_P(AllGraphs, BipartiteTest,\n                        ::testing::Range(0, 5));\n\n// Parameterized by a pair interpreted as (LhsSize, RhsSize).\nclass BipartiteNonSquareTest\n    : public ::testing::TestWithParam<std::pair<size_t, size_t> > {\n};\n\nTEST_F(BipartiteNonSquareTest, SimpleBacktracking) {\n  //   .......\n  // 0:-----\\ :\n  // 1:---\\ | :\n  // 2:---\\ | :\n  // 3:-\\ | | :\n  //  :.......:\n  //    0 1 2\n  MatchMatrix g(4, 3);\n  static const int kEdges[][2] = { {0, 2}, {1, 1}, {2, 1}, {3, 0} };\n  for (size_t i = 0; i < GMOCK_ARRAY_SIZE_(kEdges); ++i) {\n    g.SetEdge(kEdges[i][0], kEdges[i][1], true);\n  }\n  EXPECT_THAT(FindBacktrackingMaxBPM(g),\n              ElementsAre(Pair(3, 0),\n                          Pair(AnyOf(1, 2), 1),\n                          Pair(0, 2))) << g.DebugString();\n}\n\n// Verify a few nonsquare matrices.\nTEST_P(BipartiteNonSquareTest, Exhaustive) {\n  size_t nlhs = GetParam().first;\n  size_t nrhs = GetParam().second;\n  MatchMatrix graph(nlhs, nrhs);\n  do {\n    EXPECT_EQ(FindBacktrackingMaxBPM(graph).size(),\n              internal::FindMaxBipartiteMatching(graph).size())\n        << \"graph: \" << graph.DebugString()\n        << \"\\nbacktracking: \"\n        << PrintToString(FindBacktrackingMaxBPM(graph))\n        << \"\\nmax flow: \"\n        << PrintToString(internal::FindMaxBipartiteMatching(graph));\n  } while (graph.NextGraph());\n}\n\nINSTANTIATE_TEST_CASE_P(AllGraphs, BipartiteNonSquareTest,\n    testing::Values(\n        std::make_pair(1, 2),\n        std::make_pair(2, 1),\n        std::make_pair(3, 2),\n        std::make_pair(2, 3),\n        std::make_pair(4, 1),\n        std::make_pair(1, 4),\n        std::make_pair(4, 3),\n        std::make_pair(3, 4)));\n\nclass BipartiteRandomTest\n    : public ::testing::TestWithParam<std::pair<int, int> > {\n};\n\n// Verifies a large sample of larger graphs.\nTEST_P(BipartiteRandomTest, LargerNets) {\n  int nodes = GetParam().first;\n  int iters = GetParam().second;\n  MatchMatrix graph(nodes, nodes);\n\n  testing::internal::Int32 seed = GTEST_FLAG(random_seed);\n  if (seed == 0) {\n    seed = static_cast<testing::internal::Int32>(time(NULL));\n  }\n\n  for (; iters > 0; --iters, ++seed) {\n    srand(static_cast<int>(seed));\n    graph.Randomize();\n    EXPECT_EQ(FindBacktrackingMaxBPM(graph).size(),\n              internal::FindMaxBipartiteMatching(graph).size())\n        << \" graph: \" << graph.DebugString()\n        << \"\\nTo reproduce the failure, rerun the test with the flag\"\n           \" --\" << GTEST_FLAG_PREFIX_ << \"random_seed=\" << seed;\n  }\n}\n\n// Test argument is a std::pair<int, int> representing (nodes, iters).\nINSTANTIATE_TEST_CASE_P(Samples, BipartiteRandomTest,\n    testing::Values(\n        std::make_pair(5, 10000),\n        std::make_pair(6, 5000),\n        std::make_pair(7, 2000),\n        std::make_pair(8, 500),\n        std::make_pair(9, 100)));\n\n// Tests IsReadableTypeName().\n\nTEST(IsReadableTypeNameTest, ReturnsTrueForShortNames) {\n  EXPECT_TRUE(IsReadableTypeName(\"int\"));\n  EXPECT_TRUE(IsReadableTypeName(\"const unsigned char*\"));\n  EXPECT_TRUE(IsReadableTypeName(\"MyMap<int, void*>\"));\n  EXPECT_TRUE(IsReadableTypeName(\"void (*)(int, bool)\"));\n}\n\nTEST(IsReadableTypeNameTest, ReturnsTrueForLongNonTemplateNonFunctionNames) {\n  EXPECT_TRUE(IsReadableTypeName(\"my_long_namespace::MyClassName\"));\n  EXPECT_TRUE(IsReadableTypeName(\"int [5][6][7][8][9][10][11]\"));\n  EXPECT_TRUE(IsReadableTypeName(\"my_namespace::MyOuterClass::MyInnerClass\"));\n}\n\nTEST(IsReadableTypeNameTest, ReturnsFalseForLongTemplateNames) {\n  EXPECT_FALSE(\n      IsReadableTypeName(\"basic_string<char, std::char_traits<char> >\"));\n  EXPECT_FALSE(IsReadableTypeName(\"std::vector<int, std::alloc_traits<int> >\"));\n}\n\nTEST(IsReadableTypeNameTest, ReturnsFalseForLongFunctionTypeNames) {\n  EXPECT_FALSE(IsReadableTypeName(\"void (&)(int, bool, char, float)\"));\n}\n\n// Tests JoinAsTuple().\n\nTEST(JoinAsTupleTest, JoinsEmptyTuple) {\n  EXPECT_EQ(\"\", JoinAsTuple(Strings()));\n}\n\nTEST(JoinAsTupleTest, JoinsOneTuple) {\n  const char* fields[] = { \"1\" };\n  EXPECT_EQ(\"1\", JoinAsTuple(Strings(fields, fields + 1)));\n}\n\nTEST(JoinAsTupleTest, JoinsTwoTuple) {\n  const char* fields[] = { \"1\", \"a\" };\n  EXPECT_EQ(\"(1, a)\", JoinAsTuple(Strings(fields, fields + 2)));\n}\n\nTEST(JoinAsTupleTest, JoinsTenTuple) {\n  const char* fields[] = { \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\" };\n  EXPECT_EQ(\"(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)\",\n            JoinAsTuple(Strings(fields, fields + 10)));\n}\n\n// Tests FormatMatcherDescription().\n\nTEST(FormatMatcherDescriptionTest, WorksForEmptyDescription) {\n  EXPECT_EQ(\"is even\",\n            FormatMatcherDescription(false, \"IsEven\", Strings()));\n  EXPECT_EQ(\"not (is even)\",\n            FormatMatcherDescription(true, \"IsEven\", Strings()));\n\n  const char* params[] = { \"5\" };\n  EXPECT_EQ(\"equals 5\",\n            FormatMatcherDescription(false, \"Equals\",\n                                     Strings(params, params + 1)));\n\n  const char* params2[] = { \"5\", \"8\" };\n  EXPECT_EQ(\"is in range (5, 8)\",\n            FormatMatcherDescription(false, \"IsInRange\",\n                                     Strings(params2, params2 + 2)));\n}\n\n// Tests PolymorphicMatcher::mutable_impl().\nTEST(PolymorphicMatcherTest, CanAccessMutableImpl) {\n  PolymorphicMatcher<DivisibleByImpl> m(DivisibleByImpl(42));\n  DivisibleByImpl& impl = m.mutable_impl();\n  EXPECT_EQ(42, impl.divider());\n\n  impl.set_divider(0);\n  EXPECT_EQ(0, m.mutable_impl().divider());\n}\n\n// Tests PolymorphicMatcher::impl().\nTEST(PolymorphicMatcherTest, CanAccessImpl) {\n  const PolymorphicMatcher<DivisibleByImpl> m(DivisibleByImpl(42));\n  const DivisibleByImpl& impl = m.impl();\n  EXPECT_EQ(42, impl.divider());\n}\n\nTEST(MatcherTupleTest, ExplainsMatchFailure) {\n  stringstream ss1;\n  ExplainMatchFailureTupleTo(make_tuple(Matcher<char>(Eq('a')), GreaterThan(5)),\n                             make_tuple('a', 10), &ss1);\n  EXPECT_EQ(\"\", ss1.str());  // Successful match.\n\n  stringstream ss2;\n  ExplainMatchFailureTupleTo(make_tuple(GreaterThan(5), Matcher<char>(Eq('a'))),\n                             make_tuple(2, 'b'), &ss2);\n  EXPECT_EQ(\"  Expected arg #0: is > 5\\n\"\n            \"           Actual: 2, which is 3 less than 5\\n\"\n            \"  Expected arg #1: is equal to 'a' (97, 0x61)\\n\"\n            \"           Actual: 'b' (98, 0x62)\\n\",\n            ss2.str());  // Failed match where both arguments need explanation.\n\n  stringstream ss3;\n  ExplainMatchFailureTupleTo(make_tuple(GreaterThan(5), Matcher<char>(Eq('a'))),\n                             make_tuple(2, 'a'), &ss3);\n  EXPECT_EQ(\"  Expected arg #0: is > 5\\n\"\n            \"           Actual: 2, which is 3 less than 5\\n\",\n            ss3.str());  // Failed match where only one argument needs\n                         // explanation.\n}\n\n// Tests Each().\n\nTEST(EachTest, ExplainsMatchResultCorrectly) {\n  set<int> a;  // empty\n\n  Matcher<set<int> > m = Each(2);\n  EXPECT_EQ(\"\", Explain(m, a));\n\n  Matcher<const int(&)[1]> n = Each(1);  // NOLINT\n\n  const int b[1] = { 1 };\n  EXPECT_EQ(\"\", Explain(n, b));\n\n  n = Each(3);\n  EXPECT_EQ(\"whose element #0 doesn't match\", Explain(n, b));\n\n  a.insert(1);\n  a.insert(2);\n  a.insert(3);\n  m = Each(GreaterThan(0));\n  EXPECT_EQ(\"\", Explain(m, a));\n\n  m = Each(GreaterThan(10));\n  EXPECT_EQ(\"whose element #0 doesn't match, which is 9 less than 10\",\n            Explain(m, a));\n}\n\nTEST(EachTest, DescribesItselfCorrectly) {\n  Matcher<vector<int> > m = Each(1);\n  EXPECT_EQ(\"only contains elements that is equal to 1\", Describe(m));\n\n  Matcher<vector<int> > m2 = Not(m);\n  EXPECT_EQ(\"contains some element that isn't equal to 1\", Describe(m2));\n}\n\nTEST(EachTest, MatchesVectorWhenAllElementsMatch) {\n  vector<int> some_vector;\n  EXPECT_THAT(some_vector, Each(1));\n  some_vector.push_back(3);\n  EXPECT_THAT(some_vector, Not(Each(1)));\n  EXPECT_THAT(some_vector, Each(3));\n  some_vector.push_back(1);\n  some_vector.push_back(2);\n  EXPECT_THAT(some_vector, Not(Each(3)));\n  EXPECT_THAT(some_vector, Each(Lt(3.5)));\n\n  vector<string> another_vector;\n  another_vector.push_back(\"fee\");\n  EXPECT_THAT(another_vector, Each(string(\"fee\")));\n  another_vector.push_back(\"fie\");\n  another_vector.push_back(\"foe\");\n  another_vector.push_back(\"fum\");\n  EXPECT_THAT(another_vector, Not(Each(string(\"fee\"))));\n}\n\nTEST(EachTest, MatchesMapWhenAllElementsMatch) {\n  map<const char*, int> my_map;\n  const char* bar = \"a string\";\n  my_map[bar] = 2;\n  EXPECT_THAT(my_map, Each(make_pair(bar, 2)));\n\n  map<string, int> another_map;\n  EXPECT_THAT(another_map, Each(make_pair(string(\"fee\"), 1)));\n  another_map[\"fee\"] = 1;\n  EXPECT_THAT(another_map, Each(make_pair(string(\"fee\"), 1)));\n  another_map[\"fie\"] = 2;\n  another_map[\"foe\"] = 3;\n  another_map[\"fum\"] = 4;\n  EXPECT_THAT(another_map, Not(Each(make_pair(string(\"fee\"), 1))));\n  EXPECT_THAT(another_map, Not(Each(make_pair(string(\"fum\"), 1))));\n  EXPECT_THAT(another_map, Each(Pair(_, Gt(0))));\n}\n\nTEST(EachTest, AcceptsMatcher) {\n  const int a[] = { 1, 2, 3 };\n  EXPECT_THAT(a, Each(Gt(0)));\n  EXPECT_THAT(a, Not(Each(Gt(1))));\n}\n\nTEST(EachTest, WorksForNativeArrayAsTuple) {\n  const int a[] = { 1, 2 };\n  const int* const pointer = a;\n  EXPECT_THAT(make_tuple(pointer, 2), Each(Gt(0)));\n  EXPECT_THAT(make_tuple(pointer, 2), Not(Each(Gt(1))));\n}\n\n// For testing Pointwise().\nclass IsHalfOfMatcher {\n public:\n  template <typename T1, typename T2>\n  bool MatchAndExplain(const tuple<T1, T2>& a_pair,\n                       MatchResultListener* listener) const {\n    if (get<0>(a_pair) == get<1>(a_pair)/2) {\n      *listener << \"where the second is \" << get<1>(a_pair);\n      return true;\n    } else {\n      *listener << \"where the second/2 is \" << get<1>(a_pair)/2;\n      return false;\n    }\n  }\n\n  void DescribeTo(ostream* os) const {\n    *os << \"are a pair where the first is half of the second\";\n  }\n\n  void DescribeNegationTo(ostream* os) const {\n    *os << \"are a pair where the first isn't half of the second\";\n  }\n};\n\nPolymorphicMatcher<IsHalfOfMatcher> IsHalfOf() {\n  return MakePolymorphicMatcher(IsHalfOfMatcher());\n}\n\nTEST(PointwiseTest, DescribesSelf) {\n  vector<int> rhs;\n  rhs.push_back(1);\n  rhs.push_back(2);\n  rhs.push_back(3);\n  const Matcher<const vector<int>&> m = Pointwise(IsHalfOf(), rhs);\n  EXPECT_EQ(\"contains 3 values, where each value and its corresponding value \"\n            \"in { 1, 2, 3 } are a pair where the first is half of the second\",\n            Describe(m));\n  EXPECT_EQ(\"doesn't contain exactly 3 values, or contains a value x at some \"\n            \"index i where x and the i-th value of { 1, 2, 3 } are a pair \"\n            \"where the first isn't half of the second\",\n            DescribeNegation(m));\n}\n\nTEST(PointwiseTest, MakesCopyOfRhs) {\n  list<signed char> rhs;\n  rhs.push_back(2);\n  rhs.push_back(4);\n\n  int lhs[] = { 1, 2 };\n  const Matcher<const int (&)[2]> m = Pointwise(IsHalfOf(), rhs);\n  EXPECT_THAT(lhs, m);\n\n  // Changing rhs now shouldn't affect m, which made a copy of rhs.\n  rhs.push_back(6);\n  EXPECT_THAT(lhs, m);\n}\n\nTEST(PointwiseTest, WorksForLhsNativeArray) {\n  const int lhs[] = { 1, 2, 3 };\n  vector<int> rhs;\n  rhs.push_back(2);\n  rhs.push_back(4);\n  rhs.push_back(6);\n  EXPECT_THAT(lhs, Pointwise(Lt(), rhs));\n  EXPECT_THAT(lhs, Not(Pointwise(Gt(), rhs)));\n}\n\nTEST(PointwiseTest, WorksForRhsNativeArray) {\n  const int rhs[] = { 1, 2, 3 };\n  vector<int> lhs;\n  lhs.push_back(2);\n  lhs.push_back(4);\n  lhs.push_back(6);\n  EXPECT_THAT(lhs, Pointwise(Gt(), rhs));\n  EXPECT_THAT(lhs, Not(Pointwise(Lt(), rhs)));\n}\n\nTEST(PointwiseTest, RejectsWrongSize) {\n  const double lhs[2] = { 1, 2 };\n  const int rhs[1] = { 0 };\n  EXPECT_THAT(lhs, Not(Pointwise(Gt(), rhs)));\n  EXPECT_EQ(\"which contains 2 values\",\n            Explain(Pointwise(Gt(), rhs), lhs));\n\n  const int rhs2[3] = { 0, 1, 2 };\n  EXPECT_THAT(lhs, Not(Pointwise(Gt(), rhs2)));\n}\n\nTEST(PointwiseTest, RejectsWrongContent) {\n  const double lhs[3] = { 1, 2, 3 };\n  const int rhs[3] = { 2, 6, 4 };\n  EXPECT_THAT(lhs, Not(Pointwise(IsHalfOf(), rhs)));\n  EXPECT_EQ(\"where the value pair (2, 6) at index #1 don't match, \"\n            \"where the second/2 is 3\",\n            Explain(Pointwise(IsHalfOf(), rhs), lhs));\n}\n\nTEST(PointwiseTest, AcceptsCorrectContent) {\n  const double lhs[3] = { 1, 2, 3 };\n  const int rhs[3] = { 2, 4, 6 };\n  EXPECT_THAT(lhs, Pointwise(IsHalfOf(), rhs));\n  EXPECT_EQ(\"\", Explain(Pointwise(IsHalfOf(), rhs), lhs));\n}\n\nTEST(PointwiseTest, AllowsMonomorphicInnerMatcher) {\n  const double lhs[3] = { 1, 2, 3 };\n  const int rhs[3] = { 2, 4, 6 };\n  const Matcher<tuple<const double&, const int&> > m1 = IsHalfOf();\n  EXPECT_THAT(lhs, Pointwise(m1, rhs));\n  EXPECT_EQ(\"\", Explain(Pointwise(m1, rhs), lhs));\n\n  // This type works as a tuple<const double&, const int&> can be\n  // implicitly cast to tuple<double, int>.\n  const Matcher<tuple<double, int> > m2 = IsHalfOf();\n  EXPECT_THAT(lhs, Pointwise(m2, rhs));\n  EXPECT_EQ(\"\", Explain(Pointwise(m2, rhs), lhs));\n}\n\n}  // namespace gmock_matchers_test\n}  // namespace testing\n"
  },
  {
    "path": "ext/gmock/test/gmock-more-actions_test.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file tests the built-in actions in gmock-more-actions.h.\n\n#include \"gmock/gmock-more-actions.h\"\n\n#include <functional>\n#include <sstream>\n#include <string>\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n#include \"gtest/internal/gtest-linked_ptr.h\"\n\nnamespace testing {\nnamespace gmock_more_actions_test {\n\nusing ::std::plus;\nusing ::std::string;\nusing ::std::tr1::get;\nusing ::std::tr1::make_tuple;\nusing ::std::tr1::tuple;\nusing ::std::tr1::tuple_element;\nusing testing::_;\nusing testing::Action;\nusing testing::ActionInterface;\nusing testing::DeleteArg;\nusing testing::Invoke;\nusing testing::Return;\nusing testing::ReturnArg;\nusing testing::ReturnPointee;\nusing testing::SaveArg;\nusing testing::SaveArgPointee;\nusing testing::SetArgReferee;\nusing testing::StaticAssertTypeEq;\nusing testing::Unused;\nusing testing::WithArg;\nusing testing::WithoutArgs;\nusing testing::internal::linked_ptr;\n\n// For suppressing compiler warnings on conversion possibly losing precision.\ninline short Short(short n) { return n; }  // NOLINT\ninline char Char(char ch) { return ch; }\n\n// Sample functions and functors for testing Invoke() and etc.\nint Nullary() { return 1; }\n\nclass NullaryFunctor {\n public:\n  int operator()() { return 2; }\n};\n\nbool g_done = false;\nvoid VoidNullary() { g_done = true; }\n\nclass VoidNullaryFunctor {\n public:\n  void operator()() { g_done = true; }\n};\n\nbool Unary(int x) { return x < 0; }\n\nconst char* Plus1(const char* s) { return s + 1; }\n\nvoid VoidUnary(int /* n */) { g_done = true; }\n\nbool ByConstRef(const string& s) { return s == \"Hi\"; }\n\nconst double g_double = 0;\nbool ReferencesGlobalDouble(const double& x) { return &x == &g_double; }\n\nstring ByNonConstRef(string& s) { return s += \"+\"; }  // NOLINT\n\nstruct UnaryFunctor {\n  int operator()(bool x) { return x ? 1 : -1; }\n};\n\nconst char* Binary(const char* input, short n) { return input + n; }  // NOLINT\n\nvoid VoidBinary(int, char) { g_done = true; }\n\nint Ternary(int x, char y, short z) { return x + y + z; }  // NOLINT\n\nvoid VoidTernary(int, char, bool) { g_done = true; }\n\nint SumOf4(int a, int b, int c, int d) { return a + b + c + d; }\n\nint SumOfFirst2(int a, int b, Unused, Unused) { return a + b; }\n\nvoid VoidFunctionWithFourArguments(char, int, float, double) { g_done = true; }\n\nstring Concat4(const char* s1, const char* s2, const char* s3,\n               const char* s4) {\n  return string(s1) + s2 + s3 + s4;\n}\n\nint SumOf5(int a, int b, int c, int d, int e) { return a + b + c + d + e; }\n\nstruct SumOf5Functor {\n  int operator()(int a, int b, int c, int d, int e) {\n    return a + b + c + d + e;\n  }\n};\n\nstring Concat5(const char* s1, const char* s2, const char* s3,\n               const char* s4, const char* s5) {\n  return string(s1) + s2 + s3 + s4 + s5;\n}\n\nint SumOf6(int a, int b, int c, int d, int e, int f) {\n  return a + b + c + d + e + f;\n}\n\nstruct SumOf6Functor {\n  int operator()(int a, int b, int c, int d, int e, int f) {\n    return a + b + c + d + e + f;\n  }\n};\n\nstring Concat6(const char* s1, const char* s2, const char* s3,\n               const char* s4, const char* s5, const char* s6) {\n  return string(s1) + s2 + s3 + s4 + s5 + s6;\n}\n\nstring Concat7(const char* s1, const char* s2, const char* s3,\n               const char* s4, const char* s5, const char* s6,\n               const char* s7) {\n  return string(s1) + s2 + s3 + s4 + s5 + s6 + s7;\n}\n\nstring Concat8(const char* s1, const char* s2, const char* s3,\n               const char* s4, const char* s5, const char* s6,\n               const char* s7, const char* s8) {\n  return string(s1) + s2 + s3 + s4 + s5 + s6 + s7 + s8;\n}\n\nstring Concat9(const char* s1, const char* s2, const char* s3,\n               const char* s4, const char* s5, const char* s6,\n               const char* s7, const char* s8, const char* s9) {\n  return string(s1) + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9;\n}\n\nstring Concat10(const char* s1, const char* s2, const char* s3,\n                const char* s4, const char* s5, const char* s6,\n                const char* s7, const char* s8, const char* s9,\n                const char* s10) {\n  return string(s1) + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10;\n}\n\nclass Foo {\n public:\n  Foo() : value_(123) {}\n\n  int Nullary() const { return value_; }\n\n  short Unary(long x) { return static_cast<short>(value_ + x); }  // NOLINT\n\n  string Binary(const string& str, char c) const { return str + c; }\n\n  int Ternary(int x, bool y, char z) { return value_ + x + y*z; }\n\n  int SumOf4(int a, int b, int c, int d) const {\n    return a + b + c + d + value_;\n  }\n\n  int SumOfLast2(Unused, Unused, int a, int b) const { return a + b; }\n\n  int SumOf5(int a, int b, int c, int d, int e) { return a + b + c + d + e; }\n\n  int SumOf6(int a, int b, int c, int d, int e, int f) {\n    return a + b + c + d + e + f;\n  }\n\n  string Concat7(const char* s1, const char* s2, const char* s3,\n                 const char* s4, const char* s5, const char* s6,\n                 const char* s7) {\n    return string(s1) + s2 + s3 + s4 + s5 + s6 + s7;\n  }\n\n  string Concat8(const char* s1, const char* s2, const char* s3,\n                 const char* s4, const char* s5, const char* s6,\n                 const char* s7, const char* s8) {\n    return string(s1) + s2 + s3 + s4 + s5 + s6 + s7 + s8;\n  }\n\n  string Concat9(const char* s1, const char* s2, const char* s3,\n                 const char* s4, const char* s5, const char* s6,\n                 const char* s7, const char* s8, const char* s9) {\n    return string(s1) + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9;\n  }\n\n  string Concat10(const char* s1, const char* s2, const char* s3,\n                  const char* s4, const char* s5, const char* s6,\n                  const char* s7, const char* s8, const char* s9,\n                  const char* s10) {\n    return string(s1) + s2 + s3 + s4 + s5 + s6 + s7 + s8 + s9 + s10;\n  }\n\n private:\n  int value_;\n};\n\n// Tests using Invoke() with a nullary function.\nTEST(InvokeTest, Nullary) {\n  Action<int()> a = Invoke(Nullary);  // NOLINT\n  EXPECT_EQ(1, a.Perform(make_tuple()));\n}\n\n// Tests using Invoke() with a unary function.\nTEST(InvokeTest, Unary) {\n  Action<bool(int)> a = Invoke(Unary);  // NOLINT\n  EXPECT_FALSE(a.Perform(make_tuple(1)));\n  EXPECT_TRUE(a.Perform(make_tuple(-1)));\n}\n\n// Tests using Invoke() with a binary function.\nTEST(InvokeTest, Binary) {\n  Action<const char*(const char*, short)> a = Invoke(Binary);  // NOLINT\n  const char* p = \"Hello\";\n  EXPECT_EQ(p + 2, a.Perform(make_tuple(p, Short(2))));\n}\n\n// Tests using Invoke() with a ternary function.\nTEST(InvokeTest, Ternary) {\n  Action<int(int, char, short)> a = Invoke(Ternary);  // NOLINT\n  EXPECT_EQ(6, a.Perform(make_tuple(1, '\\2', Short(3))));\n}\n\n// Tests using Invoke() with a 4-argument function.\nTEST(InvokeTest, FunctionThatTakes4Arguments) {\n  Action<int(int, int, int, int)> a = Invoke(SumOf4);  // NOLINT\n  EXPECT_EQ(1234, a.Perform(make_tuple(1000, 200, 30, 4)));\n}\n\n// Tests using Invoke() with a 5-argument function.\nTEST(InvokeTest, FunctionThatTakes5Arguments) {\n  Action<int(int, int, int, int, int)> a = Invoke(SumOf5);  // NOLINT\n  EXPECT_EQ(12345, a.Perform(make_tuple(10000, 2000, 300, 40, 5)));\n}\n\n// Tests using Invoke() with a 6-argument function.\nTEST(InvokeTest, FunctionThatTakes6Arguments) {\n  Action<int(int, int, int, int, int, int)> a = Invoke(SumOf6);  // NOLINT\n  EXPECT_EQ(123456, a.Perform(make_tuple(100000, 20000, 3000, 400, 50, 6)));\n}\n\n// A helper that turns the type of a C-string literal from const\n// char[N] to const char*.\ninline const char* CharPtr(const char* s) { return s; }\n\n// Tests using Invoke() with a 7-argument function.\nTEST(InvokeTest, FunctionThatTakes7Arguments) {\n  Action<string(const char*, const char*, const char*, const char*,\n                const char*, const char*, const char*)> a =\n      Invoke(Concat7);\n  EXPECT_EQ(\"1234567\",\n            a.Perform(make_tuple(CharPtr(\"1\"), CharPtr(\"2\"), CharPtr(\"3\"),\n                                 CharPtr(\"4\"), CharPtr(\"5\"), CharPtr(\"6\"),\n                                 CharPtr(\"7\"))));\n}\n\n// Tests using Invoke() with a 8-argument function.\nTEST(InvokeTest, FunctionThatTakes8Arguments) {\n  Action<string(const char*, const char*, const char*, const char*,\n                const char*, const char*, const char*, const char*)> a =\n      Invoke(Concat8);\n  EXPECT_EQ(\"12345678\",\n            a.Perform(make_tuple(CharPtr(\"1\"), CharPtr(\"2\"), CharPtr(\"3\"),\n                                 CharPtr(\"4\"), CharPtr(\"5\"), CharPtr(\"6\"),\n                                 CharPtr(\"7\"), CharPtr(\"8\"))));\n}\n\n// Tests using Invoke() with a 9-argument function.\nTEST(InvokeTest, FunctionThatTakes9Arguments) {\n  Action<string(const char*, const char*, const char*, const char*,\n                const char*, const char*, const char*, const char*,\n                const char*)> a = Invoke(Concat9);\n  EXPECT_EQ(\"123456789\",\n            a.Perform(make_tuple(CharPtr(\"1\"), CharPtr(\"2\"), CharPtr(\"3\"),\n                                 CharPtr(\"4\"), CharPtr(\"5\"), CharPtr(\"6\"),\n                                 CharPtr(\"7\"), CharPtr(\"8\"), CharPtr(\"9\"))));\n}\n\n// Tests using Invoke() with a 10-argument function.\nTEST(InvokeTest, FunctionThatTakes10Arguments) {\n  Action<string(const char*, const char*, const char*, const char*,\n                const char*, const char*, const char*, const char*,\n                const char*, const char*)> a = Invoke(Concat10);\n  EXPECT_EQ(\"1234567890\",\n            a.Perform(make_tuple(CharPtr(\"1\"), CharPtr(\"2\"), CharPtr(\"3\"),\n                                 CharPtr(\"4\"), CharPtr(\"5\"), CharPtr(\"6\"),\n                                 CharPtr(\"7\"), CharPtr(\"8\"), CharPtr(\"9\"),\n                                 CharPtr(\"0\"))));\n}\n\n// Tests using Invoke() with functions with parameters declared as Unused.\nTEST(InvokeTest, FunctionWithUnusedParameters) {\n  Action<int(int, int, double, const string&)> a1 =\n      Invoke(SumOfFirst2);\n  EXPECT_EQ(12, a1.Perform(make_tuple(10, 2, 5.6, string(\"hi\"))));\n\n  Action<int(int, int, bool, int*)> a2 =\n      Invoke(SumOfFirst2);\n  EXPECT_EQ(23, a2.Perform(make_tuple(20, 3, true, static_cast<int*>(NULL))));\n}\n\n// Tests using Invoke() with methods with parameters declared as Unused.\nTEST(InvokeTest, MethodWithUnusedParameters) {\n  Foo foo;\n  Action<int(string, bool, int, int)> a1 =\n      Invoke(&foo, &Foo::SumOfLast2);\n  EXPECT_EQ(12, a1.Perform(make_tuple(CharPtr(\"hi\"), true, 10, 2)));\n\n  Action<int(char, double, int, int)> a2 =\n      Invoke(&foo, &Foo::SumOfLast2);\n  EXPECT_EQ(23, a2.Perform(make_tuple('a', 2.5, 20, 3)));\n}\n\n// Tests using Invoke() with a functor.\nTEST(InvokeTest, Functor) {\n  Action<long(long, int)> a = Invoke(plus<long>());  // NOLINT\n  EXPECT_EQ(3L, a.Perform(make_tuple(1, 2)));\n}\n\n// Tests using Invoke(f) as an action of a compatible type.\nTEST(InvokeTest, FunctionWithCompatibleType) {\n  Action<long(int, short, char, bool)> a = Invoke(SumOf4);  // NOLINT\n  EXPECT_EQ(4321, a.Perform(make_tuple(4000, Short(300), Char(20), true)));\n}\n\n// Tests using Invoke() with an object pointer and a method pointer.\n\n// Tests using Invoke() with a nullary method.\nTEST(InvokeMethodTest, Nullary) {\n  Foo foo;\n  Action<int()> a = Invoke(&foo, &Foo::Nullary);  // NOLINT\n  EXPECT_EQ(123, a.Perform(make_tuple()));\n}\n\n// Tests using Invoke() with a unary method.\nTEST(InvokeMethodTest, Unary) {\n  Foo foo;\n  Action<short(long)> a = Invoke(&foo, &Foo::Unary);  // NOLINT\n  EXPECT_EQ(4123, a.Perform(make_tuple(4000)));\n}\n\n// Tests using Invoke() with a binary method.\nTEST(InvokeMethodTest, Binary) {\n  Foo foo;\n  Action<string(const string&, char)> a = Invoke(&foo, &Foo::Binary);\n  string s(\"Hell\");\n  EXPECT_EQ(\"Hello\", a.Perform(make_tuple(s, 'o')));\n}\n\n// Tests using Invoke() with a ternary method.\nTEST(InvokeMethodTest, Ternary) {\n  Foo foo;\n  Action<int(int, bool, char)> a = Invoke(&foo, &Foo::Ternary);  // NOLINT\n  EXPECT_EQ(1124, a.Perform(make_tuple(1000, true, Char(1))));\n}\n\n// Tests using Invoke() with a 4-argument method.\nTEST(InvokeMethodTest, MethodThatTakes4Arguments) {\n  Foo foo;\n  Action<int(int, int, int, int)> a = Invoke(&foo, &Foo::SumOf4);  // NOLINT\n  EXPECT_EQ(1357, a.Perform(make_tuple(1000, 200, 30, 4)));\n}\n\n// Tests using Invoke() with a 5-argument method.\nTEST(InvokeMethodTest, MethodThatTakes5Arguments) {\n  Foo foo;\n  Action<int(int, int, int, int, int)> a = Invoke(&foo, &Foo::SumOf5);  // NOLINT\n  EXPECT_EQ(12345, a.Perform(make_tuple(10000, 2000, 300, 40, 5)));\n}\n\n// Tests using Invoke() with a 6-argument method.\nTEST(InvokeMethodTest, MethodThatTakes6Arguments) {\n  Foo foo;\n  Action<int(int, int, int, int, int, int)> a =  // NOLINT\n      Invoke(&foo, &Foo::SumOf6);\n  EXPECT_EQ(123456, a.Perform(make_tuple(100000, 20000, 3000, 400, 50, 6)));\n}\n\n// Tests using Invoke() with a 7-argument method.\nTEST(InvokeMethodTest, MethodThatTakes7Arguments) {\n  Foo foo;\n  Action<string(const char*, const char*, const char*, const char*,\n                const char*, const char*, const char*)> a =\n      Invoke(&foo, &Foo::Concat7);\n  EXPECT_EQ(\"1234567\",\n            a.Perform(make_tuple(CharPtr(\"1\"), CharPtr(\"2\"), CharPtr(\"3\"),\n                                 CharPtr(\"4\"), CharPtr(\"5\"), CharPtr(\"6\"),\n                                 CharPtr(\"7\"))));\n}\n\n// Tests using Invoke() with a 8-argument method.\nTEST(InvokeMethodTest, MethodThatTakes8Arguments) {\n  Foo foo;\n  Action<string(const char*, const char*, const char*, const char*,\n                const char*, const char*, const char*, const char*)> a =\n      Invoke(&foo, &Foo::Concat8);\n  EXPECT_EQ(\"12345678\",\n            a.Perform(make_tuple(CharPtr(\"1\"), CharPtr(\"2\"), CharPtr(\"3\"),\n                                 CharPtr(\"4\"), CharPtr(\"5\"), CharPtr(\"6\"),\n                                 CharPtr(\"7\"), CharPtr(\"8\"))));\n}\n\n// Tests using Invoke() with a 9-argument method.\nTEST(InvokeMethodTest, MethodThatTakes9Arguments) {\n  Foo foo;\n  Action<string(const char*, const char*, const char*, const char*,\n                const char*, const char*, const char*, const char*,\n                const char*)> a = Invoke(&foo, &Foo::Concat9);\n  EXPECT_EQ(\"123456789\",\n            a.Perform(make_tuple(CharPtr(\"1\"), CharPtr(\"2\"), CharPtr(\"3\"),\n                                 CharPtr(\"4\"), CharPtr(\"5\"), CharPtr(\"6\"),\n                                 CharPtr(\"7\"), CharPtr(\"8\"), CharPtr(\"9\"))));\n}\n\n// Tests using Invoke() with a 10-argument method.\nTEST(InvokeMethodTest, MethodThatTakes10Arguments) {\n  Foo foo;\n  Action<string(const char*, const char*, const char*, const char*,\n                const char*, const char*, const char*, const char*,\n                const char*, const char*)> a = Invoke(&foo, &Foo::Concat10);\n  EXPECT_EQ(\"1234567890\",\n            a.Perform(make_tuple(CharPtr(\"1\"), CharPtr(\"2\"), CharPtr(\"3\"),\n                                 CharPtr(\"4\"), CharPtr(\"5\"), CharPtr(\"6\"),\n                                 CharPtr(\"7\"), CharPtr(\"8\"), CharPtr(\"9\"),\n                                 CharPtr(\"0\"))));\n}\n\n// Tests using Invoke(f) as an action of a compatible type.\nTEST(InvokeMethodTest, MethodWithCompatibleType) {\n  Foo foo;\n  Action<long(int, short, char, bool)> a =  // NOLINT\n      Invoke(&foo, &Foo::SumOf4);\n  EXPECT_EQ(4444, a.Perform(make_tuple(4000, Short(300), Char(20), true)));\n}\n\n// Tests using WithoutArgs with an action that takes no argument.\nTEST(WithoutArgsTest, NoArg) {\n  Action<int(int n)> a = WithoutArgs(Invoke(Nullary));  // NOLINT\n  EXPECT_EQ(1, a.Perform(make_tuple(2)));\n}\n\n// Tests using WithArg with an action that takes 1 argument.\nTEST(WithArgTest, OneArg) {\n  Action<bool(double x, int n)> b = WithArg<1>(Invoke(Unary));  // NOLINT\n  EXPECT_TRUE(b.Perform(make_tuple(1.5, -1)));\n  EXPECT_FALSE(b.Perform(make_tuple(1.5, 1)));\n}\n\nTEST(ReturnArgActionTest, WorksForOneArgIntArg0) {\n  const Action<int(int)> a = ReturnArg<0>();\n  EXPECT_EQ(5, a.Perform(make_tuple(5)));\n}\n\nTEST(ReturnArgActionTest, WorksForMultiArgBoolArg0) {\n  const Action<bool(bool, bool, bool)> a = ReturnArg<0>();\n  EXPECT_TRUE(a.Perform(make_tuple(true, false, false)));\n}\n\nTEST(ReturnArgActionTest, WorksForMultiArgStringArg2) {\n  const Action<string(int, int, string, int)> a = ReturnArg<2>();\n  EXPECT_EQ(\"seven\", a.Perform(make_tuple(5, 6, string(\"seven\"), 8)));\n}\n\nTEST(SaveArgActionTest, WorksForSameType) {\n  int result = 0;\n  const Action<void(int n)> a1 = SaveArg<0>(&result);\n  a1.Perform(make_tuple(5));\n  EXPECT_EQ(5, result);\n}\n\nTEST(SaveArgActionTest, WorksForCompatibleType) {\n  int result = 0;\n  const Action<void(bool, char)> a1 = SaveArg<1>(&result);\n  a1.Perform(make_tuple(true, 'a'));\n  EXPECT_EQ('a', result);\n}\n\nTEST(SaveArgPointeeActionTest, WorksForSameType) {\n  int result = 0;\n  const int value = 5;\n  const Action<void(const int*)> a1 = SaveArgPointee<0>(&result);\n  a1.Perform(make_tuple(&value));\n  EXPECT_EQ(5, result);\n}\n\nTEST(SaveArgPointeeActionTest, WorksForCompatibleType) {\n  int result = 0;\n  char value = 'a';\n  const Action<void(bool, char*)> a1 = SaveArgPointee<1>(&result);\n  a1.Perform(make_tuple(true, &value));\n  EXPECT_EQ('a', result);\n}\n\nTEST(SaveArgPointeeActionTest, WorksForLinkedPtr) {\n  int result = 0;\n  linked_ptr<int> value(new int(5));\n  const Action<void(linked_ptr<int>)> a1 = SaveArgPointee<0>(&result);\n  a1.Perform(make_tuple(value));\n  EXPECT_EQ(5, result);\n}\n\nTEST(SetArgRefereeActionTest, WorksForSameType) {\n  int value = 0;\n  const Action<void(int&)> a1 = SetArgReferee<0>(1);\n  a1.Perform(tuple<int&>(value));\n  EXPECT_EQ(1, value);\n}\n\nTEST(SetArgRefereeActionTest, WorksForCompatibleType) {\n  int value = 0;\n  const Action<void(int, int&)> a1 = SetArgReferee<1>('a');\n  a1.Perform(tuple<int, int&>(0, value));\n  EXPECT_EQ('a', value);\n}\n\nTEST(SetArgRefereeActionTest, WorksWithExtraArguments) {\n  int value = 0;\n  const Action<void(bool, int, int&, const char*)> a1 = SetArgReferee<2>('a');\n  a1.Perform(tuple<bool, int, int&, const char*>(true, 0, value, \"hi\"));\n  EXPECT_EQ('a', value);\n}\n\n// A class that can be used to verify that its destructor is called: it will set\n// the bool provided to the constructor to true when destroyed.\nclass DeletionTester {\n public:\n  explicit DeletionTester(bool* is_deleted)\n    : is_deleted_(is_deleted) {\n    // Make sure the bit is set to false.\n    *is_deleted_ = false;\n  }\n\n  ~DeletionTester() {\n    *is_deleted_ = true;\n  }\n\n private:\n  bool* is_deleted_;\n};\n\nTEST(DeleteArgActionTest, OneArg) {\n  bool is_deleted = false;\n  DeletionTester* t = new DeletionTester(&is_deleted);\n  const Action<void(DeletionTester*)> a1 = DeleteArg<0>();      // NOLINT\n  EXPECT_FALSE(is_deleted);\n  a1.Perform(make_tuple(t));\n  EXPECT_TRUE(is_deleted);\n}\n\nTEST(DeleteArgActionTest, TenArgs) {\n  bool is_deleted = false;\n  DeletionTester* t = new DeletionTester(&is_deleted);\n  const Action<void(bool, int, int, const char*, bool,\n                    int, int, int, int, DeletionTester*)> a1 = DeleteArg<9>();\n  EXPECT_FALSE(is_deleted);\n  a1.Perform(make_tuple(true, 5, 6, CharPtr(\"hi\"), false, 7, 8, 9, 10, t));\n  EXPECT_TRUE(is_deleted);\n}\n\n#if GTEST_HAS_EXCEPTIONS\n\nTEST(ThrowActionTest, ThrowsGivenExceptionInVoidFunction) {\n  const Action<void(int n)> a = Throw('a');\n  EXPECT_THROW(a.Perform(make_tuple(0)), char);\n}\n\nclass MyException {};\n\nTEST(ThrowActionTest, ThrowsGivenExceptionInNonVoidFunction) {\n  const Action<double(char ch)> a = Throw(MyException());\n  EXPECT_THROW(a.Perform(make_tuple('0')), MyException);\n}\n\nTEST(ThrowActionTest, ThrowsGivenExceptionInNullaryFunction) {\n  const Action<double()> a = Throw(MyException());\n  EXPECT_THROW(a.Perform(make_tuple()), MyException);\n}\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n// Tests that SetArrayArgument<N>(first, last) sets the elements of the array\n// pointed to by the N-th (0-based) argument to values in range [first, last).\nTEST(SetArrayArgumentTest, SetsTheNthArray) {\n  typedef void MyFunction(bool, int*, char*);\n  int numbers[] = { 1, 2, 3 };\n  Action<MyFunction> a = SetArrayArgument<1>(numbers, numbers + 3);\n\n  int n[4] = {};\n  int* pn = n;\n  char ch[4] = {};\n  char* pch = ch;\n  a.Perform(make_tuple(true, pn, pch));\n  EXPECT_EQ(1, n[0]);\n  EXPECT_EQ(2, n[1]);\n  EXPECT_EQ(3, n[2]);\n  EXPECT_EQ(0, n[3]);\n  EXPECT_EQ('\\0', ch[0]);\n  EXPECT_EQ('\\0', ch[1]);\n  EXPECT_EQ('\\0', ch[2]);\n  EXPECT_EQ('\\0', ch[3]);\n\n  // Tests first and last are iterators.\n  std::string letters = \"abc\";\n  a = SetArrayArgument<2>(letters.begin(), letters.end());\n  std::fill_n(n, 4, 0);\n  std::fill_n(ch, 4, '\\0');\n  a.Perform(make_tuple(true, pn, pch));\n  EXPECT_EQ(0, n[0]);\n  EXPECT_EQ(0, n[1]);\n  EXPECT_EQ(0, n[2]);\n  EXPECT_EQ(0, n[3]);\n  EXPECT_EQ('a', ch[0]);\n  EXPECT_EQ('b', ch[1]);\n  EXPECT_EQ('c', ch[2]);\n  EXPECT_EQ('\\0', ch[3]);\n}\n\n// Tests SetArrayArgument<N>(first, last) where first == last.\nTEST(SetArrayArgumentTest, SetsTheNthArrayWithEmptyRange) {\n  typedef void MyFunction(bool, int*);\n  int numbers[] = { 1, 2, 3 };\n  Action<MyFunction> a = SetArrayArgument<1>(numbers, numbers);\n\n  int n[4] = {};\n  int* pn = n;\n  a.Perform(make_tuple(true, pn));\n  EXPECT_EQ(0, n[0]);\n  EXPECT_EQ(0, n[1]);\n  EXPECT_EQ(0, n[2]);\n  EXPECT_EQ(0, n[3]);\n}\n\n// Tests SetArrayArgument<N>(first, last) where *first is convertible\n// (but not equal) to the argument type.\nTEST(SetArrayArgumentTest, SetsTheNthArrayWithConvertibleType) {\n  typedef void MyFunction(bool, char*);\n  int codes[] = { 97, 98, 99 };\n  Action<MyFunction> a = SetArrayArgument<1>(codes, codes + 3);\n\n  char ch[4] = {};\n  char* pch = ch;\n  a.Perform(make_tuple(true, pch));\n  EXPECT_EQ('a', ch[0]);\n  EXPECT_EQ('b', ch[1]);\n  EXPECT_EQ('c', ch[2]);\n  EXPECT_EQ('\\0', ch[3]);\n}\n\n// Test SetArrayArgument<N>(first, last) with iterator as argument.\nTEST(SetArrayArgumentTest, SetsTheNthArrayWithIteratorArgument) {\n  typedef void MyFunction(bool, std::back_insert_iterator<std::string>);\n  std::string letters = \"abc\";\n  Action<MyFunction> a = SetArrayArgument<1>(letters.begin(), letters.end());\n\n  std::string s;\n  a.Perform(make_tuple(true, back_inserter(s)));\n  EXPECT_EQ(letters, s);\n}\n\nTEST(ReturnPointeeTest, Works) {\n  int n = 42;\n  const Action<int()> a = ReturnPointee(&n);\n  EXPECT_EQ(42, a.Perform(make_tuple()));\n\n  n = 43;\n  EXPECT_EQ(43, a.Perform(make_tuple()));\n}\n\n}  // namespace gmock_generated_actions_test\n}  // namespace testing\n"
  },
  {
    "path": "ext/gmock/test/gmock-nice-strict_test.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"gmock/gmock-generated-nice-strict.h\"\n\n#include <string>\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n#include \"gtest/gtest-spi.h\"\n\n// This must not be defined inside the ::testing namespace, or it will\n// clash with ::testing::Mock.\nclass Mock {\n public:\n  Mock() {}\n\n  MOCK_METHOD0(DoThis, void());\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(Mock);\n};\n\nnamespace testing {\nnamespace gmock_nice_strict_test {\n\nusing testing::internal::string;\nusing testing::GMOCK_FLAG(verbose);\nusing testing::HasSubstr;\nusing testing::NaggyMock;\nusing testing::NiceMock;\nusing testing::StrictMock;\n\n#if GTEST_HAS_STREAM_REDIRECTION\nusing testing::internal::CaptureStdout;\nusing testing::internal::GetCapturedStdout;\n#endif\n\n// Defines some mock classes needed by the tests.\n\nclass Foo {\n public:\n  virtual ~Foo() {}\n\n  virtual void DoThis() = 0;\n  virtual int DoThat(bool flag) = 0;\n};\n\nclass MockFoo : public Foo {\n public:\n  MockFoo() {}\n  void Delete() { delete this; }\n\n  MOCK_METHOD0(DoThis, void());\n  MOCK_METHOD1(DoThat, int(bool flag));\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo);\n};\n\nclass MockBar {\n public:\n  explicit MockBar(const string& s) : str_(s) {}\n\n  MockBar(char a1, char a2, string a3, string a4, int a5, int a6,\n          const string& a7, const string& a8, bool a9, bool a10) {\n    str_ = string() + a1 + a2 + a3 + a4 + static_cast<char>(a5) +\n        static_cast<char>(a6) + a7 + a8 + (a9 ? 'T' : 'F') + (a10 ? 'T' : 'F');\n  }\n\n  virtual ~MockBar() {}\n\n  const string& str() const { return str_; }\n\n  MOCK_METHOD0(This, int());\n  MOCK_METHOD2(That, string(int, bool));\n\n private:\n  string str_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockBar);\n};\n\n#if GTEST_HAS_STREAM_REDIRECTION\n\n// Tests that a raw mock generates warnings for uninteresting calls.\nTEST(RawMockTest, WarningForUninterestingCall) {\n  const string saved_flag = GMOCK_FLAG(verbose);\n  GMOCK_FLAG(verbose) = \"warning\";\n\n  MockFoo raw_foo;\n\n  CaptureStdout();\n  raw_foo.DoThis();\n  raw_foo.DoThat(true);\n  EXPECT_THAT(GetCapturedStdout(),\n              HasSubstr(\"Uninteresting mock function call\"));\n\n  GMOCK_FLAG(verbose) = saved_flag;\n}\n\n// Tests that a raw mock generates warnings for uninteresting calls\n// that delete the mock object.\nTEST(RawMockTest, WarningForUninterestingCallAfterDeath) {\n  const string saved_flag = GMOCK_FLAG(verbose);\n  GMOCK_FLAG(verbose) = \"warning\";\n\n  MockFoo* const raw_foo = new MockFoo;\n\n  ON_CALL(*raw_foo, DoThis())\n      .WillByDefault(Invoke(raw_foo, &MockFoo::Delete));\n\n  CaptureStdout();\n  raw_foo->DoThis();\n  EXPECT_THAT(GetCapturedStdout(),\n              HasSubstr(\"Uninteresting mock function call\"));\n\n  GMOCK_FLAG(verbose) = saved_flag;\n}\n\n// Tests that a raw mock generates informational logs for\n// uninteresting calls.\nTEST(RawMockTest, InfoForUninterestingCall) {\n  MockFoo raw_foo;\n\n  const string saved_flag = GMOCK_FLAG(verbose);\n  GMOCK_FLAG(verbose) = \"info\";\n  CaptureStdout();\n  raw_foo.DoThis();\n  EXPECT_THAT(GetCapturedStdout(),\n              HasSubstr(\"Uninteresting mock function call\"));\n\n  GMOCK_FLAG(verbose) = saved_flag;\n}\n\n// Tests that a nice mock generates no warning for uninteresting calls.\nTEST(NiceMockTest, NoWarningForUninterestingCall) {\n  NiceMock<MockFoo> nice_foo;\n\n  CaptureStdout();\n  nice_foo.DoThis();\n  nice_foo.DoThat(true);\n  EXPECT_EQ(\"\", GetCapturedStdout());\n}\n\n// Tests that a nice mock generates no warning for uninteresting calls\n// that delete the mock object.\nTEST(NiceMockTest, NoWarningForUninterestingCallAfterDeath) {\n  NiceMock<MockFoo>* const nice_foo = new NiceMock<MockFoo>;\n\n  ON_CALL(*nice_foo, DoThis())\n      .WillByDefault(Invoke(nice_foo, &MockFoo::Delete));\n\n  CaptureStdout();\n  nice_foo->DoThis();\n  EXPECT_EQ(\"\", GetCapturedStdout());\n}\n\n// Tests that a nice mock generates informational logs for\n// uninteresting calls.\nTEST(NiceMockTest, InfoForUninterestingCall) {\n  NiceMock<MockFoo> nice_foo;\n\n  const string saved_flag = GMOCK_FLAG(verbose);\n  GMOCK_FLAG(verbose) = \"info\";\n  CaptureStdout();\n  nice_foo.DoThis();\n  EXPECT_THAT(GetCapturedStdout(),\n              HasSubstr(\"Uninteresting mock function call\"));\n\n  GMOCK_FLAG(verbose) = saved_flag;\n}\n\n#endif  // GTEST_HAS_STREAM_REDIRECTION\n\n// Tests that a nice mock allows expected calls.\nTEST(NiceMockTest, AllowsExpectedCall) {\n  NiceMock<MockFoo> nice_foo;\n\n  EXPECT_CALL(nice_foo, DoThis());\n  nice_foo.DoThis();\n}\n\n// Tests that an unexpected call on a nice mock fails.\nTEST(NiceMockTest, UnexpectedCallFails) {\n  NiceMock<MockFoo> nice_foo;\n\n  EXPECT_CALL(nice_foo, DoThis()).Times(0);\n  EXPECT_NONFATAL_FAILURE(nice_foo.DoThis(), \"called more times than expected\");\n}\n\n// Tests that NiceMock works with a mock class that has a non-default\n// constructor.\nTEST(NiceMockTest, NonDefaultConstructor) {\n  NiceMock<MockBar> nice_bar(\"hi\");\n  EXPECT_EQ(\"hi\", nice_bar.str());\n\n  nice_bar.This();\n  nice_bar.That(5, true);\n}\n\n// Tests that NiceMock works with a mock class that has a 10-ary\n// non-default constructor.\nTEST(NiceMockTest, NonDefaultConstructor10) {\n  NiceMock<MockBar> nice_bar('a', 'b', \"c\", \"d\", 'e', 'f',\n                             \"g\", \"h\", true, false);\n  EXPECT_EQ(\"abcdefghTF\", nice_bar.str());\n\n  nice_bar.This();\n  nice_bar.That(5, true);\n}\n\n#if !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE\n// Tests that NiceMock<Mock> compiles where Mock is a user-defined\n// class (as opposed to ::testing::Mock).  We had to work around an\n// MSVC 8.0 bug that caused the symbol Mock used in the definition of\n// NiceMock to be looked up in the wrong context, and this test\n// ensures that our fix works.\n//\n// We have to skip this test on Symbian and Windows Mobile, as it\n// causes the program to crash there, for reasons unclear to us yet.\nTEST(NiceMockTest, AcceptsClassNamedMock) {\n  NiceMock< ::Mock> nice;\n  EXPECT_CALL(nice, DoThis());\n  nice.DoThis();\n}\n#endif  // !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE\n\n#if GTEST_HAS_STREAM_REDIRECTION\n\n// Tests that a naggy mock generates warnings for uninteresting calls.\nTEST(NaggyMockTest, WarningForUninterestingCall) {\n  const string saved_flag = GMOCK_FLAG(verbose);\n  GMOCK_FLAG(verbose) = \"warning\";\n\n  NaggyMock<MockFoo> naggy_foo;\n\n  CaptureStdout();\n  naggy_foo.DoThis();\n  naggy_foo.DoThat(true);\n  EXPECT_THAT(GetCapturedStdout(),\n              HasSubstr(\"Uninteresting mock function call\"));\n\n  GMOCK_FLAG(verbose) = saved_flag;\n}\n\n// Tests that a naggy mock generates a warning for an uninteresting call\n// that deletes the mock object.\nTEST(NaggyMockTest, WarningForUninterestingCallAfterDeath) {\n  const string saved_flag = GMOCK_FLAG(verbose);\n  GMOCK_FLAG(verbose) = \"warning\";\n\n  NaggyMock<MockFoo>* const naggy_foo = new NaggyMock<MockFoo>;\n\n  ON_CALL(*naggy_foo, DoThis())\n      .WillByDefault(Invoke(naggy_foo, &MockFoo::Delete));\n\n  CaptureStdout();\n  naggy_foo->DoThis();\n  EXPECT_THAT(GetCapturedStdout(),\n              HasSubstr(\"Uninteresting mock function call\"));\n\n  GMOCK_FLAG(verbose) = saved_flag;\n}\n\n#endif  // GTEST_HAS_STREAM_REDIRECTION\n\n// Tests that a naggy mock allows expected calls.\nTEST(NaggyMockTest, AllowsExpectedCall) {\n  NaggyMock<MockFoo> naggy_foo;\n\n  EXPECT_CALL(naggy_foo, DoThis());\n  naggy_foo.DoThis();\n}\n\n// Tests that an unexpected call on a naggy mock fails.\nTEST(NaggyMockTest, UnexpectedCallFails) {\n  NaggyMock<MockFoo> naggy_foo;\n\n  EXPECT_CALL(naggy_foo, DoThis()).Times(0);\n  EXPECT_NONFATAL_FAILURE(naggy_foo.DoThis(),\n                          \"called more times than expected\");\n}\n\n// Tests that NaggyMock works with a mock class that has a non-default\n// constructor.\nTEST(NaggyMockTest, NonDefaultConstructor) {\n  NaggyMock<MockBar> naggy_bar(\"hi\");\n  EXPECT_EQ(\"hi\", naggy_bar.str());\n\n  naggy_bar.This();\n  naggy_bar.That(5, true);\n}\n\n// Tests that NaggyMock works with a mock class that has a 10-ary\n// non-default constructor.\nTEST(NaggyMockTest, NonDefaultConstructor10) {\n  NaggyMock<MockBar> naggy_bar('0', '1', \"2\", \"3\", '4', '5',\n                               \"6\", \"7\", true, false);\n  EXPECT_EQ(\"01234567TF\", naggy_bar.str());\n\n  naggy_bar.This();\n  naggy_bar.That(5, true);\n}\n\n#if !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE\n// Tests that NaggyMock<Mock> compiles where Mock is a user-defined\n// class (as opposed to ::testing::Mock).  We had to work around an\n// MSVC 8.0 bug that caused the symbol Mock used in the definition of\n// NaggyMock to be looked up in the wrong context, and this test\n// ensures that our fix works.\n//\n// We have to skip this test on Symbian and Windows Mobile, as it\n// causes the program to crash there, for reasons unclear to us yet.\nTEST(NaggyMockTest, AcceptsClassNamedMock) {\n  NaggyMock< ::Mock> naggy;\n  EXPECT_CALL(naggy, DoThis());\n  naggy.DoThis();\n}\n#endif  // !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE\n\n// Tests that a strict mock allows expected calls.\nTEST(StrictMockTest, AllowsExpectedCall) {\n  StrictMock<MockFoo> strict_foo;\n\n  EXPECT_CALL(strict_foo, DoThis());\n  strict_foo.DoThis();\n}\n\n// Tests that an unexpected call on a strict mock fails.\nTEST(StrictMockTest, UnexpectedCallFails) {\n  StrictMock<MockFoo> strict_foo;\n\n  EXPECT_CALL(strict_foo, DoThis()).Times(0);\n  EXPECT_NONFATAL_FAILURE(strict_foo.DoThis(),\n                          \"called more times than expected\");\n}\n\n// Tests that an uninteresting call on a strict mock fails.\nTEST(StrictMockTest, UninterestingCallFails) {\n  StrictMock<MockFoo> strict_foo;\n\n  EXPECT_NONFATAL_FAILURE(strict_foo.DoThis(),\n                          \"Uninteresting mock function call\");\n}\n\n// Tests that an uninteresting call on a strict mock fails, even if\n// the call deletes the mock object.\nTEST(StrictMockTest, UninterestingCallFailsAfterDeath) {\n  StrictMock<MockFoo>* const strict_foo = new StrictMock<MockFoo>;\n\n  ON_CALL(*strict_foo, DoThis())\n      .WillByDefault(Invoke(strict_foo, &MockFoo::Delete));\n\n  EXPECT_NONFATAL_FAILURE(strict_foo->DoThis(),\n                          \"Uninteresting mock function call\");\n}\n\n// Tests that StrictMock works with a mock class that has a\n// non-default constructor.\nTEST(StrictMockTest, NonDefaultConstructor) {\n  StrictMock<MockBar> strict_bar(\"hi\");\n  EXPECT_EQ(\"hi\", strict_bar.str());\n\n  EXPECT_NONFATAL_FAILURE(strict_bar.That(5, true),\n                          \"Uninteresting mock function call\");\n}\n\n// Tests that StrictMock works with a mock class that has a 10-ary\n// non-default constructor.\nTEST(StrictMockTest, NonDefaultConstructor10) {\n  StrictMock<MockBar> strict_bar('a', 'b', \"c\", \"d\", 'e', 'f',\n                                 \"g\", \"h\", true, false);\n  EXPECT_EQ(\"abcdefghTF\", strict_bar.str());\n\n  EXPECT_NONFATAL_FAILURE(strict_bar.That(5, true),\n                          \"Uninteresting mock function call\");\n}\n\n#if !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE\n// Tests that StrictMock<Mock> compiles where Mock is a user-defined\n// class (as opposed to ::testing::Mock).  We had to work around an\n// MSVC 8.0 bug that caused the symbol Mock used in the definition of\n// StrictMock to be looked up in the wrong context, and this test\n// ensures that our fix works.\n//\n// We have to skip this test on Symbian and Windows Mobile, as it\n// causes the program to crash there, for reasons unclear to us yet.\nTEST(StrictMockTest, AcceptsClassNamedMock) {\n  StrictMock< ::Mock> strict;\n  EXPECT_CALL(strict, DoThis());\n  strict.DoThis();\n}\n#endif  // !GTEST_OS_SYMBIAN && !GTEST_OS_WINDOWS_MOBILE\n\n}  // namespace gmock_nice_strict_test\n}  // namespace testing\n"
  },
  {
    "path": "ext/gmock/test/gmock-port_test.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file tests the internal cross-platform support utilities.\n\n#include \"gmock/internal/gmock-port.h\"\n#include \"gtest/gtest.h\"\n\n// NOTE: if this file is left without tests for some reason, put a dummy\n// test here to make references to symbols in the gtest library and avoid\n// 'undefined symbol' linker errors in gmock_main:\n\nTEST(DummyTest, Dummy) {}\n"
  },
  {
    "path": "ext/gmock/test/gmock-spec-builders_test.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file tests the spec builder syntax.\n\n#include \"gmock/gmock-spec-builders.h\"\n\n#include <ostream>  // NOLINT\n#include <sstream>\n#include <string>\n\n#include \"gmock/gmock.h\"\n#include \"gmock/internal/gmock-port.h\"\n#include \"gtest/gtest.h\"\n#include \"gtest/gtest-spi.h\"\n#include \"gtest/internal/gtest-port.h\"\n\nnamespace testing {\nnamespace internal {\n\n// Helper class for testing the Expectation class template.\nclass ExpectationTester {\n public:\n  // Sets the call count of the given expectation to the given number.\n  void SetCallCount(int n, ExpectationBase* exp) {\n    exp->call_count_ = n;\n  }\n};\n\n}  // namespace internal\n}  // namespace testing\n\nnamespace {\n\nusing testing::_;\nusing testing::AnyNumber;\nusing testing::AtLeast;\nusing testing::AtMost;\nusing testing::Between;\nusing testing::Cardinality;\nusing testing::CardinalityInterface;\nusing testing::ContainsRegex;\nusing testing::Const;\nusing testing::DoAll;\nusing testing::DoDefault;\nusing testing::Eq;\nusing testing::Expectation;\nusing testing::ExpectationSet;\nusing testing::GMOCK_FLAG(verbose);\nusing testing::Gt;\nusing testing::InSequence;\nusing testing::Invoke;\nusing testing::InvokeWithoutArgs;\nusing testing::IsSubstring;\nusing testing::Lt;\nusing testing::Message;\nusing testing::Mock;\nusing testing::NaggyMock;\nusing testing::Ne;\nusing testing::Return;\nusing testing::Sequence;\nusing testing::SetArgPointee;\nusing testing::internal::ExpectationTester;\nusing testing::internal::FormatFileLocation;\nusing testing::internal::kErrorVerbosity;\nusing testing::internal::kInfoVerbosity;\nusing testing::internal::kWarningVerbosity;\nusing testing::internal::linked_ptr;\nusing testing::internal::string;\n\n#if GTEST_HAS_STREAM_REDIRECTION\nusing testing::HasSubstr;\nusing testing::internal::CaptureStdout;\nusing testing::internal::GetCapturedStdout;\n#endif\n\nclass Incomplete;\n\nclass MockIncomplete {\n public:\n  // This line verifies that a mock method can take a by-reference\n  // argument of an incomplete type.\n  MOCK_METHOD1(ByRefFunc, void(const Incomplete& x));\n};\n\n// Tells Google Mock how to print a value of type Incomplete.\nvoid PrintTo(const Incomplete& x, ::std::ostream* os);\n\nTEST(MockMethodTest, CanInstantiateWithIncompleteArgType) {\n  // Even though this mock class contains a mock method that takes\n  // by-reference an argument whose type is incomplete, we can still\n  // use the mock, as long as Google Mock knows how to print the\n  // argument.\n  MockIncomplete incomplete;\n  EXPECT_CALL(incomplete, ByRefFunc(_))\n      .Times(AnyNumber());\n}\n\n// The definition of the printer for the argument type doesn't have to\n// be visible where the mock is used.\nvoid PrintTo(const Incomplete& /* x */, ::std::ostream* os) {\n  *os << \"incomplete\";\n}\n\nclass Result {};\n\nclass MockA {\n public:\n  MockA() {}\n\n  MOCK_METHOD1(DoA, void(int n));  // NOLINT\n  MOCK_METHOD1(ReturnResult, Result(int n));  // NOLINT\n  MOCK_METHOD2(Binary, bool(int x, int y));  // NOLINT\n  MOCK_METHOD2(ReturnInt, int(int x, int y));  // NOLINT\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockA);\n};\n\nclass MockB {\n public:\n  MockB() {}\n\n  MOCK_CONST_METHOD0(DoB, int());  // NOLINT\n  MOCK_METHOD1(DoB, int(int n));  // NOLINT\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockB);\n};\n\nclass ReferenceHoldingMock {\n public:\n  ReferenceHoldingMock() {}\n\n  MOCK_METHOD1(AcceptReference, void(linked_ptr<MockA>*));\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ReferenceHoldingMock);\n};\n\n// Tests that EXPECT_CALL and ON_CALL compile in a presence of macro\n// redefining a mock method name. This could happen, for example, when\n// the tested code #includes Win32 API headers which define many APIs\n// as macros, e.g. #define TextOut TextOutW.\n\n#define Method MethodW\n\nclass CC {\n public:\n  virtual ~CC() {}\n  virtual int Method() = 0;\n};\nclass MockCC : public CC {\n public:\n  MockCC() {}\n\n  MOCK_METHOD0(Method, int());\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockCC);\n};\n\n// Tests that a method with expanded name compiles.\nTEST(OnCallSyntaxTest, CompilesWithMethodNameExpandedFromMacro) {\n  MockCC cc;\n  ON_CALL(cc, Method());\n}\n\n// Tests that the method with expanded name not only compiles but runs\n// and returns a correct value, too.\nTEST(OnCallSyntaxTest, WorksWithMethodNameExpandedFromMacro) {\n  MockCC cc;\n  ON_CALL(cc, Method()).WillByDefault(Return(42));\n  EXPECT_EQ(42, cc.Method());\n}\n\n// Tests that a method with expanded name compiles.\nTEST(ExpectCallSyntaxTest, CompilesWithMethodNameExpandedFromMacro) {\n  MockCC cc;\n  EXPECT_CALL(cc, Method());\n  cc.Method();\n}\n\n// Tests that it works, too.\nTEST(ExpectCallSyntaxTest, WorksWithMethodNameExpandedFromMacro) {\n  MockCC cc;\n  EXPECT_CALL(cc, Method()).WillOnce(Return(42));\n  EXPECT_EQ(42, cc.Method());\n}\n\n#undef Method  // Done with macro redefinition tests.\n\n// Tests that ON_CALL evaluates its arguments exactly once as promised\n// by Google Mock.\nTEST(OnCallSyntaxTest, EvaluatesFirstArgumentOnce) {\n  MockA a;\n  MockA* pa = &a;\n\n  ON_CALL(*pa++, DoA(_));\n  EXPECT_EQ(&a + 1, pa);\n}\n\nTEST(OnCallSyntaxTest, EvaluatesSecondArgumentOnce) {\n  MockA a;\n  int n = 0;\n\n  ON_CALL(a, DoA(n++));\n  EXPECT_EQ(1, n);\n}\n\n// Tests that the syntax of ON_CALL() is enforced at run time.\n\nTEST(OnCallSyntaxTest, WithIsOptional) {\n  MockA a;\n\n  ON_CALL(a, DoA(5))\n      .WillByDefault(Return());\n  ON_CALL(a, DoA(_))\n      .With(_)\n      .WillByDefault(Return());\n}\n\nTEST(OnCallSyntaxTest, WithCanAppearAtMostOnce) {\n  MockA a;\n\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    ON_CALL(a, ReturnResult(_))\n        .With(_)\n        .With(_)\n        .WillByDefault(Return(Result()));\n  }, \".With() cannot appear more than once in an ON_CALL()\");\n}\n\nTEST(OnCallSyntaxTest, WillByDefaultIsMandatory) {\n  MockA a;\n\n  EXPECT_DEATH_IF_SUPPORTED({\n    ON_CALL(a, DoA(5));\n    a.DoA(5);\n  }, \"\");\n}\n\nTEST(OnCallSyntaxTest, WillByDefaultCanAppearAtMostOnce) {\n  MockA a;\n\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    ON_CALL(a, DoA(5))\n        .WillByDefault(Return())\n        .WillByDefault(Return());\n  }, \".WillByDefault() must appear exactly once in an ON_CALL()\");\n}\n\n// Tests that EXPECT_CALL evaluates its arguments exactly once as\n// promised by Google Mock.\nTEST(ExpectCallSyntaxTest, EvaluatesFirstArgumentOnce) {\n  MockA a;\n  MockA* pa = &a;\n\n  EXPECT_CALL(*pa++, DoA(_));\n  a.DoA(0);\n  EXPECT_EQ(&a + 1, pa);\n}\n\nTEST(ExpectCallSyntaxTest, EvaluatesSecondArgumentOnce) {\n  MockA a;\n  int n = 0;\n\n  EXPECT_CALL(a, DoA(n++));\n  a.DoA(0);\n  EXPECT_EQ(1, n);\n}\n\n// Tests that the syntax of EXPECT_CALL() is enforced at run time.\n\nTEST(ExpectCallSyntaxTest, WithIsOptional) {\n  MockA a;\n\n  EXPECT_CALL(a, DoA(5))\n      .Times(0);\n  EXPECT_CALL(a, DoA(6))\n      .With(_)\n      .Times(0);\n}\n\nTEST(ExpectCallSyntaxTest, WithCanAppearAtMostOnce) {\n  MockA a;\n\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_CALL(a, DoA(6))\n        .With(_)\n        .With(_);\n  }, \".With() cannot appear more than once in an EXPECT_CALL()\");\n\n  a.DoA(6);\n}\n\nTEST(ExpectCallSyntaxTest, WithMustBeFirstClause) {\n  MockA a;\n\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_CALL(a, DoA(1))\n        .Times(1)\n        .With(_);\n  }, \".With() must be the first clause in an EXPECT_CALL()\");\n\n  a.DoA(1);\n\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_CALL(a, DoA(2))\n        .WillOnce(Return())\n        .With(_);\n  }, \".With() must be the first clause in an EXPECT_CALL()\");\n\n  a.DoA(2);\n}\n\nTEST(ExpectCallSyntaxTest, TimesCanBeInferred) {\n  MockA a;\n\n  EXPECT_CALL(a, DoA(1))\n      .WillOnce(Return());\n\n  EXPECT_CALL(a, DoA(2))\n      .WillOnce(Return())\n      .WillRepeatedly(Return());\n\n  a.DoA(1);\n  a.DoA(2);\n  a.DoA(2);\n}\n\nTEST(ExpectCallSyntaxTest, TimesCanAppearAtMostOnce) {\n  MockA a;\n\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_CALL(a, DoA(1))\n        .Times(1)\n        .Times(2);\n  }, \".Times() cannot appear more than once in an EXPECT_CALL()\");\n\n  a.DoA(1);\n  a.DoA(1);\n}\n\nTEST(ExpectCallSyntaxTest, TimesMustBeBeforeInSequence) {\n  MockA a;\n  Sequence s;\n\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_CALL(a, DoA(1))\n        .InSequence(s)\n        .Times(1);\n  }, \".Times() cannot appear after \");\n\n  a.DoA(1);\n}\n\nTEST(ExpectCallSyntaxTest, InSequenceIsOptional) {\n  MockA a;\n  Sequence s;\n\n  EXPECT_CALL(a, DoA(1));\n  EXPECT_CALL(a, DoA(2))\n      .InSequence(s);\n\n  a.DoA(1);\n  a.DoA(2);\n}\n\nTEST(ExpectCallSyntaxTest, InSequenceCanAppearMultipleTimes) {\n  MockA a;\n  Sequence s1, s2;\n\n  EXPECT_CALL(a, DoA(1))\n      .InSequence(s1, s2)\n      .InSequence(s1);\n\n  a.DoA(1);\n}\n\nTEST(ExpectCallSyntaxTest, InSequenceMustBeBeforeAfter) {\n  MockA a;\n  Sequence s;\n\n  Expectation e = EXPECT_CALL(a, DoA(1))\n      .Times(AnyNumber());\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_CALL(a, DoA(2))\n        .After(e)\n        .InSequence(s);\n  }, \".InSequence() cannot appear after \");\n\n  a.DoA(2);\n}\n\nTEST(ExpectCallSyntaxTest, InSequenceMustBeBeforeWillOnce) {\n  MockA a;\n  Sequence s;\n\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_CALL(a, DoA(1))\n        .WillOnce(Return())\n        .InSequence(s);\n  }, \".InSequence() cannot appear after \");\n\n  a.DoA(1);\n}\n\nTEST(ExpectCallSyntaxTest, AfterMustBeBeforeWillOnce) {\n  MockA a;\n\n  Expectation e = EXPECT_CALL(a, DoA(1));\n  EXPECT_NONFATAL_FAILURE({\n    EXPECT_CALL(a, DoA(2))\n        .WillOnce(Return())\n        .After(e);\n  }, \".After() cannot appear after \");\n\n  a.DoA(1);\n  a.DoA(2);\n}\n\nTEST(ExpectCallSyntaxTest, WillIsOptional) {\n  MockA a;\n\n  EXPECT_CALL(a, DoA(1));\n  EXPECT_CALL(a, DoA(2))\n      .WillOnce(Return());\n\n  a.DoA(1);\n  a.DoA(2);\n}\n\nTEST(ExpectCallSyntaxTest, WillCanAppearMultipleTimes) {\n  MockA a;\n\n  EXPECT_CALL(a, DoA(1))\n      .Times(AnyNumber())\n      .WillOnce(Return())\n      .WillOnce(Return())\n      .WillOnce(Return());\n}\n\nTEST(ExpectCallSyntaxTest, WillMustBeBeforeWillRepeatedly) {\n  MockA a;\n\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_CALL(a, DoA(1))\n        .WillRepeatedly(Return())\n        .WillOnce(Return());\n  }, \".WillOnce() cannot appear after \");\n\n  a.DoA(1);\n}\n\nTEST(ExpectCallSyntaxTest, WillRepeatedlyIsOptional) {\n  MockA a;\n\n  EXPECT_CALL(a, DoA(1))\n      .WillOnce(Return());\n  EXPECT_CALL(a, DoA(2))\n      .WillOnce(Return())\n      .WillRepeatedly(Return());\n\n  a.DoA(1);\n  a.DoA(2);\n  a.DoA(2);\n}\n\nTEST(ExpectCallSyntaxTest, WillRepeatedlyCannotAppearMultipleTimes) {\n  MockA a;\n\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_CALL(a, DoA(1))\n        .WillRepeatedly(Return())\n        .WillRepeatedly(Return());\n  }, \".WillRepeatedly() cannot appear more than once in an \"\n     \"EXPECT_CALL()\");\n}\n\nTEST(ExpectCallSyntaxTest, WillRepeatedlyMustBeBeforeRetiresOnSaturation) {\n  MockA a;\n\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_CALL(a, DoA(1))\n        .RetiresOnSaturation()\n        .WillRepeatedly(Return());\n  }, \".WillRepeatedly() cannot appear after \");\n}\n\nTEST(ExpectCallSyntaxTest, RetiresOnSaturationIsOptional) {\n  MockA a;\n\n  EXPECT_CALL(a, DoA(1));\n  EXPECT_CALL(a, DoA(1))\n      .RetiresOnSaturation();\n\n  a.DoA(1);\n  a.DoA(1);\n}\n\nTEST(ExpectCallSyntaxTest, RetiresOnSaturationCannotAppearMultipleTimes) {\n  MockA a;\n\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_CALL(a, DoA(1))\n        .RetiresOnSaturation()\n        .RetiresOnSaturation();\n  }, \".RetiresOnSaturation() cannot appear more than once\");\n\n  a.DoA(1);\n}\n\nTEST(ExpectCallSyntaxTest, DefaultCardinalityIsOnce) {\n  {\n    MockA a;\n    EXPECT_CALL(a, DoA(1));\n    a.DoA(1);\n  }\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    MockA a;\n    EXPECT_CALL(a, DoA(1));\n  }, \"to be called once\");\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    MockA a;\n    EXPECT_CALL(a, DoA(1));\n    a.DoA(1);\n    a.DoA(1);\n  }, \"to be called once\");\n}\n\n#if GTEST_HAS_STREAM_REDIRECTION\n\n// Tests that Google Mock doesn't print a warning when the number of\n// WillOnce() is adequate.\nTEST(ExpectCallSyntaxTest, DoesNotWarnOnAdequateActionCount) {\n  CaptureStdout();\n  {\n    MockB b;\n\n    // It's always fine to omit WillOnce() entirely.\n    EXPECT_CALL(b, DoB())\n        .Times(0);\n    EXPECT_CALL(b, DoB(1))\n        .Times(AtMost(1));\n    EXPECT_CALL(b, DoB(2))\n        .Times(1)\n        .WillRepeatedly(Return(1));\n\n    // It's fine for the number of WillOnce()s to equal the upper bound.\n    EXPECT_CALL(b, DoB(3))\n        .Times(Between(1, 2))\n        .WillOnce(Return(1))\n        .WillOnce(Return(2));\n\n    // It's fine for the number of WillOnce()s to be smaller than the\n    // upper bound when there is a WillRepeatedly().\n    EXPECT_CALL(b, DoB(4))\n        .Times(AtMost(3))\n        .WillOnce(Return(1))\n        .WillRepeatedly(Return(2));\n\n    // Satisfies the above expectations.\n    b.DoB(2);\n    b.DoB(3);\n  }\n  EXPECT_STREQ(\"\", GetCapturedStdout().c_str());\n}\n\n// Tests that Google Mock warns on having too many actions in an\n// expectation compared to its cardinality.\nTEST(ExpectCallSyntaxTest, WarnsOnTooManyActions) {\n  CaptureStdout();\n  {\n    MockB b;\n\n    // Warns when the number of WillOnce()s is larger than the upper bound.\n    EXPECT_CALL(b, DoB())\n        .Times(0)\n        .WillOnce(Return(1));  // #1\n    EXPECT_CALL(b, DoB())\n        .Times(AtMost(1))\n        .WillOnce(Return(1))\n        .WillOnce(Return(2));  // #2\n    EXPECT_CALL(b, DoB(1))\n        .Times(1)\n        .WillOnce(Return(1))\n        .WillOnce(Return(2))\n        .RetiresOnSaturation();  // #3\n\n    // Warns when the number of WillOnce()s equals the upper bound and\n    // there is a WillRepeatedly().\n    EXPECT_CALL(b, DoB())\n        .Times(0)\n        .WillRepeatedly(Return(1));  // #4\n    EXPECT_CALL(b, DoB(2))\n        .Times(1)\n        .WillOnce(Return(1))\n        .WillRepeatedly(Return(2));  // #5\n\n    // Satisfies the above expectations.\n    b.DoB(1);\n    b.DoB(2);\n  }\n  const std::string output = GetCapturedStdout();\n  EXPECT_PRED_FORMAT2(\n      IsSubstring,\n      \"Too many actions specified in EXPECT_CALL(b, DoB())...\\n\"\n      \"Expected to be never called, but has 1 WillOnce().\",\n      output);  // #1\n  EXPECT_PRED_FORMAT2(\n      IsSubstring,\n      \"Too many actions specified in EXPECT_CALL(b, DoB())...\\n\"\n      \"Expected to be called at most once, \"\n      \"but has 2 WillOnce()s.\",\n      output);  // #2\n  EXPECT_PRED_FORMAT2(\n      IsSubstring,\n      \"Too many actions specified in EXPECT_CALL(b, DoB(1))...\\n\"\n      \"Expected to be called once, but has 2 WillOnce()s.\",\n      output);  // #3\n  EXPECT_PRED_FORMAT2(\n      IsSubstring,\n      \"Too many actions specified in EXPECT_CALL(b, DoB())...\\n\"\n      \"Expected to be never called, but has 0 WillOnce()s \"\n      \"and a WillRepeatedly().\",\n      output);  // #4\n  EXPECT_PRED_FORMAT2(\n      IsSubstring,\n      \"Too many actions specified in EXPECT_CALL(b, DoB(2))...\\n\"\n      \"Expected to be called once, but has 1 WillOnce() \"\n      \"and a WillRepeatedly().\",\n      output);  // #5\n}\n\n// Tests that Google Mock warns on having too few actions in an\n// expectation compared to its cardinality.\nTEST(ExpectCallSyntaxTest, WarnsOnTooFewActions) {\n  MockB b;\n\n  EXPECT_CALL(b, DoB())\n      .Times(Between(2, 3))\n      .WillOnce(Return(1));\n\n  CaptureStdout();\n  b.DoB();\n  const std::string output = GetCapturedStdout();\n  EXPECT_PRED_FORMAT2(\n      IsSubstring,\n      \"Too few actions specified in EXPECT_CALL(b, DoB())...\\n\"\n      \"Expected to be called between 2 and 3 times, \"\n      \"but has only 1 WillOnce().\",\n      output);\n  b.DoB();\n}\n\n#endif  // GTEST_HAS_STREAM_REDIRECTION\n\n// Tests the semantics of ON_CALL().\n\n// Tests that the built-in default action is taken when no ON_CALL()\n// is specified.\nTEST(OnCallTest, TakesBuiltInDefaultActionWhenNoOnCall) {\n  MockB b;\n  EXPECT_CALL(b, DoB());\n\n  EXPECT_EQ(0, b.DoB());\n}\n\n// Tests that the built-in default action is taken when no ON_CALL()\n// matches the invocation.\nTEST(OnCallTest, TakesBuiltInDefaultActionWhenNoOnCallMatches) {\n  MockB b;\n  ON_CALL(b, DoB(1))\n      .WillByDefault(Return(1));\n  EXPECT_CALL(b, DoB(_));\n\n  EXPECT_EQ(0, b.DoB(2));\n}\n\n// Tests that the last matching ON_CALL() action is taken.\nTEST(OnCallTest, PicksLastMatchingOnCall) {\n  MockB b;\n  ON_CALL(b, DoB(_))\n      .WillByDefault(Return(3));\n  ON_CALL(b, DoB(2))\n      .WillByDefault(Return(2));\n  ON_CALL(b, DoB(1))\n      .WillByDefault(Return(1));\n  EXPECT_CALL(b, DoB(_));\n\n  EXPECT_EQ(2, b.DoB(2));\n}\n\n// Tests the semantics of EXPECT_CALL().\n\n// Tests that any call is allowed when no EXPECT_CALL() is specified.\nTEST(ExpectCallTest, AllowsAnyCallWhenNoSpec) {\n  MockB b;\n  EXPECT_CALL(b, DoB());\n  // There is no expectation on DoB(int).\n\n  b.DoB();\n\n  // DoB(int) can be called any number of times.\n  b.DoB(1);\n  b.DoB(2);\n}\n\n// Tests that the last matching EXPECT_CALL() fires.\nTEST(ExpectCallTest, PicksLastMatchingExpectCall) {\n  MockB b;\n  EXPECT_CALL(b, DoB(_))\n      .WillRepeatedly(Return(2));\n  EXPECT_CALL(b, DoB(1))\n      .WillRepeatedly(Return(1));\n\n  EXPECT_EQ(1, b.DoB(1));\n}\n\n// Tests lower-bound violation.\nTEST(ExpectCallTest, CatchesTooFewCalls) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    MockB b;\n    EXPECT_CALL(b, DoB(5))\n        .Times(AtLeast(2));\n\n    b.DoB(5);\n  }, \"Actual function call count doesn't match EXPECT_CALL(b, DoB(5))...\\n\"\n     \"         Expected: to be called at least twice\\n\"\n     \"           Actual: called once - unsatisfied and active\");\n}\n\n// Tests that the cardinality can be inferred when no Times(...) is\n// specified.\nTEST(ExpectCallTest, InfersCardinalityWhenThereIsNoWillRepeatedly) {\n  {\n    MockB b;\n    EXPECT_CALL(b, DoB())\n        .WillOnce(Return(1))\n        .WillOnce(Return(2));\n\n    EXPECT_EQ(1, b.DoB());\n    EXPECT_EQ(2, b.DoB());\n  }\n\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    MockB b;\n    EXPECT_CALL(b, DoB())\n        .WillOnce(Return(1))\n        .WillOnce(Return(2));\n\n    EXPECT_EQ(1, b.DoB());\n  }, \"to be called twice\");\n\n  {  // NOLINT\n    MockB b;\n    EXPECT_CALL(b, DoB())\n        .WillOnce(Return(1))\n        .WillOnce(Return(2));\n\n    EXPECT_EQ(1, b.DoB());\n    EXPECT_EQ(2, b.DoB());\n    EXPECT_NONFATAL_FAILURE(b.DoB(), \"to be called twice\");\n  }\n}\n\nTEST(ExpectCallTest, InfersCardinality1WhenThereIsWillRepeatedly) {\n  {\n    MockB b;\n    EXPECT_CALL(b, DoB())\n        .WillOnce(Return(1))\n        .WillRepeatedly(Return(2));\n\n    EXPECT_EQ(1, b.DoB());\n  }\n\n  {  // NOLINT\n    MockB b;\n    EXPECT_CALL(b, DoB())\n        .WillOnce(Return(1))\n        .WillRepeatedly(Return(2));\n\n    EXPECT_EQ(1, b.DoB());\n    EXPECT_EQ(2, b.DoB());\n    EXPECT_EQ(2, b.DoB());\n  }\n\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    MockB b;\n    EXPECT_CALL(b, DoB())\n        .WillOnce(Return(1))\n        .WillRepeatedly(Return(2));\n  }, \"to be called at least once\");\n}\n\n// Tests that the n-th action is taken for the n-th matching\n// invocation.\nTEST(ExpectCallTest, NthMatchTakesNthAction) {\n  MockB b;\n  EXPECT_CALL(b, DoB())\n      .WillOnce(Return(1))\n      .WillOnce(Return(2))\n      .WillOnce(Return(3));\n\n  EXPECT_EQ(1, b.DoB());\n  EXPECT_EQ(2, b.DoB());\n  EXPECT_EQ(3, b.DoB());\n}\n\n// Tests that the WillRepeatedly() action is taken when the WillOnce(...)\n// list is exhausted.\nTEST(ExpectCallTest, TakesRepeatedActionWhenWillListIsExhausted) {\n  MockB b;\n  EXPECT_CALL(b, DoB())\n      .WillOnce(Return(1))\n      .WillRepeatedly(Return(2));\n\n  EXPECT_EQ(1, b.DoB());\n  EXPECT_EQ(2, b.DoB());\n  EXPECT_EQ(2, b.DoB());\n}\n\n#if GTEST_HAS_STREAM_REDIRECTION\n\n// Tests that the default action is taken when the WillOnce(...) list is\n// exhausted and there is no WillRepeatedly().\nTEST(ExpectCallTest, TakesDefaultActionWhenWillListIsExhausted) {\n  MockB b;\n  EXPECT_CALL(b, DoB(_))\n      .Times(1);\n  EXPECT_CALL(b, DoB())\n      .Times(AnyNumber())\n      .WillOnce(Return(1))\n      .WillOnce(Return(2));\n\n  CaptureStdout();\n  EXPECT_EQ(0, b.DoB(1));  // Shouldn't generate a warning as the\n                           // expectation has no action clause at all.\n  EXPECT_EQ(1, b.DoB());\n  EXPECT_EQ(2, b.DoB());\n  const std::string output1 = GetCapturedStdout();\n  EXPECT_STREQ(\"\", output1.c_str());\n\n  CaptureStdout();\n  EXPECT_EQ(0, b.DoB());\n  EXPECT_EQ(0, b.DoB());\n  const std::string output2 = GetCapturedStdout();\n  EXPECT_THAT(output2.c_str(),\n              HasSubstr(\"Actions ran out in EXPECT_CALL(b, DoB())...\\n\"\n                        \"Called 3 times, but only 2 WillOnce()s are specified\"\n                        \" - returning default value.\"));\n  EXPECT_THAT(output2.c_str(),\n              HasSubstr(\"Actions ran out in EXPECT_CALL(b, DoB())...\\n\"\n                        \"Called 4 times, but only 2 WillOnce()s are specified\"\n                        \" - returning default value.\"));\n}\n\nTEST(FunctionMockerMessageTest, ReportsExpectCallLocationForExhausedActions) {\n  MockB b;\n  std::string expect_call_location = FormatFileLocation(__FILE__, __LINE__ + 1);\n  EXPECT_CALL(b, DoB()).Times(AnyNumber()).WillOnce(Return(1));\n\n  EXPECT_EQ(1, b.DoB());\n\n  CaptureStdout();\n  EXPECT_EQ(0, b.DoB());\n  const std::string output = GetCapturedStdout();\n  // The warning message should contain the call location.\n  EXPECT_PRED_FORMAT2(IsSubstring, expect_call_location, output);\n}\n\nTEST(FunctionMockerMessageTest,\n     ReportsDefaultActionLocationOfUninterestingCallsForNaggyMock) {\n  std::string on_call_location;\n  CaptureStdout();\n  {\n    NaggyMock<MockB> b;\n    on_call_location = FormatFileLocation(__FILE__, __LINE__ + 1);\n    ON_CALL(b, DoB(_)).WillByDefault(Return(0));\n    b.DoB(0);\n  }\n  EXPECT_PRED_FORMAT2(IsSubstring, on_call_location, GetCapturedStdout());\n}\n\n#endif  // GTEST_HAS_STREAM_REDIRECTION\n\n// Tests that an uninteresting call performs the default action.\nTEST(UninterestingCallTest, DoesDefaultAction) {\n  // When there is an ON_CALL() statement, the action specified by it\n  // should be taken.\n  MockA a;\n  ON_CALL(a, Binary(_, _))\n      .WillByDefault(Return(true));\n  EXPECT_TRUE(a.Binary(1, 2));\n\n  // When there is no ON_CALL(), the default value for the return type\n  // should be returned.\n  MockB b;\n  EXPECT_EQ(0, b.DoB());\n}\n\n// Tests that an unexpected call performs the default action.\nTEST(UnexpectedCallTest, DoesDefaultAction) {\n  // When there is an ON_CALL() statement, the action specified by it\n  // should be taken.\n  MockA a;\n  ON_CALL(a, Binary(_, _))\n      .WillByDefault(Return(true));\n  EXPECT_CALL(a, Binary(0, 0));\n  a.Binary(0, 0);\n  bool result = false;\n  EXPECT_NONFATAL_FAILURE(result = a.Binary(1, 2),\n                          \"Unexpected mock function call\");\n  EXPECT_TRUE(result);\n\n  // When there is no ON_CALL(), the default value for the return type\n  // should be returned.\n  MockB b;\n  EXPECT_CALL(b, DoB(0))\n      .Times(0);\n  int n = -1;\n  EXPECT_NONFATAL_FAILURE(n = b.DoB(1),\n                          \"Unexpected mock function call\");\n  EXPECT_EQ(0, n);\n}\n\n// Tests that when an unexpected void function generates the right\n// failure message.\nTEST(UnexpectedCallTest, GeneratesFailureForVoidFunction) {\n  // First, tests the message when there is only one EXPECT_CALL().\n  MockA a1;\n  EXPECT_CALL(a1, DoA(1));\n  a1.DoA(1);\n  // Ideally we should match the failure message against a regex, but\n  // EXPECT_NONFATAL_FAILURE doesn't support that, so we test for\n  // multiple sub-strings instead.\n  EXPECT_NONFATAL_FAILURE(\n      a1.DoA(9),\n      \"Unexpected mock function call - returning directly.\\n\"\n      \"    Function call: DoA(9)\\n\"\n      \"Google Mock tried the following 1 expectation, but it didn't match:\");\n  EXPECT_NONFATAL_FAILURE(\n      a1.DoA(9),\n      \"  Expected arg #0: is equal to 1\\n\"\n      \"           Actual: 9\\n\"\n      \"         Expected: to be called once\\n\"\n      \"           Actual: called once - saturated and active\");\n\n  // Next, tests the message when there are more than one EXPECT_CALL().\n  MockA a2;\n  EXPECT_CALL(a2, DoA(1));\n  EXPECT_CALL(a2, DoA(3));\n  a2.DoA(1);\n  EXPECT_NONFATAL_FAILURE(\n      a2.DoA(2),\n      \"Unexpected mock function call - returning directly.\\n\"\n      \"    Function call: DoA(2)\\n\"\n      \"Google Mock tried the following 2 expectations, but none matched:\");\n  EXPECT_NONFATAL_FAILURE(\n      a2.DoA(2),\n      \"tried expectation #0: EXPECT_CALL(a2, DoA(1))...\\n\"\n      \"  Expected arg #0: is equal to 1\\n\"\n      \"           Actual: 2\\n\"\n      \"         Expected: to be called once\\n\"\n      \"           Actual: called once - saturated and active\");\n  EXPECT_NONFATAL_FAILURE(\n      a2.DoA(2),\n      \"tried expectation #1: EXPECT_CALL(a2, DoA(3))...\\n\"\n      \"  Expected arg #0: is equal to 3\\n\"\n      \"           Actual: 2\\n\"\n      \"         Expected: to be called once\\n\"\n      \"           Actual: never called - unsatisfied and active\");\n  a2.DoA(3);\n}\n\n// Tests that an unexpected non-void function generates the right\n// failure message.\nTEST(UnexpectedCallTest, GeneartesFailureForNonVoidFunction) {\n  MockB b1;\n  EXPECT_CALL(b1, DoB(1));\n  b1.DoB(1);\n  EXPECT_NONFATAL_FAILURE(\n      b1.DoB(2),\n      \"Unexpected mock function call - returning default value.\\n\"\n      \"    Function call: DoB(2)\\n\"\n      \"          Returns: 0\\n\"\n      \"Google Mock tried the following 1 expectation, but it didn't match:\");\n  EXPECT_NONFATAL_FAILURE(\n      b1.DoB(2),\n      \"  Expected arg #0: is equal to 1\\n\"\n      \"           Actual: 2\\n\"\n      \"         Expected: to be called once\\n\"\n      \"           Actual: called once - saturated and active\");\n}\n\n// Tests that Google Mock explains that an retired expectation doesn't\n// match the call.\nTEST(UnexpectedCallTest, RetiredExpectation) {\n  MockB b;\n  EXPECT_CALL(b, DoB(1))\n      .RetiresOnSaturation();\n\n  b.DoB(1);\n  EXPECT_NONFATAL_FAILURE(\n      b.DoB(1),\n      \"         Expected: the expectation is active\\n\"\n      \"           Actual: it is retired\");\n}\n\n// Tests that Google Mock explains that an expectation that doesn't\n// match the arguments doesn't match the call.\nTEST(UnexpectedCallTest, UnmatchedArguments) {\n  MockB b;\n  EXPECT_CALL(b, DoB(1));\n\n  EXPECT_NONFATAL_FAILURE(\n      b.DoB(2),\n      \"  Expected arg #0: is equal to 1\\n\"\n      \"           Actual: 2\\n\");\n  b.DoB(1);\n}\n\n// Tests that Google Mock explains that an expectation with\n// unsatisfied pre-requisites doesn't match the call.\nTEST(UnexpectedCallTest, UnsatisifiedPrerequisites) {\n  Sequence s1, s2;\n  MockB b;\n  EXPECT_CALL(b, DoB(1))\n      .InSequence(s1);\n  EXPECT_CALL(b, DoB(2))\n      .Times(AnyNumber())\n      .InSequence(s1);\n  EXPECT_CALL(b, DoB(3))\n      .InSequence(s2);\n  EXPECT_CALL(b, DoB(4))\n      .InSequence(s1, s2);\n\n  ::testing::TestPartResultArray failures;\n  {\n    ::testing::ScopedFakeTestPartResultReporter reporter(&failures);\n    b.DoB(4);\n    // Now 'failures' contains the Google Test failures generated by\n    // the above statement.\n  }\n\n  // There should be one non-fatal failure.\n  ASSERT_EQ(1, failures.size());\n  const ::testing::TestPartResult& r = failures.GetTestPartResult(0);\n  EXPECT_EQ(::testing::TestPartResult::kNonFatalFailure, r.type());\n\n  // Verifies that the failure message contains the two unsatisfied\n  // pre-requisites but not the satisfied one.\n#if GTEST_USES_PCRE\n  EXPECT_THAT(r.message(), ContainsRegex(\n      // PCRE has trouble using (.|\\n) to match any character, but\n      // supports the (?s) prefix for using . to match any character.\n      \"(?s)the following immediate pre-requisites are not satisfied:\\n\"\n      \".*: pre-requisite #0\\n\"\n      \".*: pre-requisite #1\"));\n#elif GTEST_USES_POSIX_RE\n  EXPECT_THAT(r.message(), ContainsRegex(\n      // POSIX RE doesn't understand the (?s) prefix, but has no trouble\n      // with (.|\\n).\n      \"the following immediate pre-requisites are not satisfied:\\n\"\n      \"(.|\\n)*: pre-requisite #0\\n\"\n      \"(.|\\n)*: pre-requisite #1\"));\n#else\n  // We can only use Google Test's own simple regex.\n  EXPECT_THAT(r.message(), ContainsRegex(\n      \"the following immediate pre-requisites are not satisfied:\"));\n  EXPECT_THAT(r.message(), ContainsRegex(\": pre-requisite #0\"));\n  EXPECT_THAT(r.message(), ContainsRegex(\": pre-requisite #1\"));\n#endif  // GTEST_USES_PCRE\n\n  b.DoB(1);\n  b.DoB(3);\n  b.DoB(4);\n}\n\nTEST(UndefinedReturnValueTest, ReturnValueIsMandatory) {\n  MockA a;\n  // TODO(wan@google.com): We should really verify the output message,\n  // but we cannot yet due to that EXPECT_DEATH only captures stderr\n  // while Google Mock logs to stdout.\n#if GTEST_HAS_EXCEPTIONS\n  EXPECT_ANY_THROW(a.ReturnResult(1));\n#else\n  EXPECT_DEATH_IF_SUPPORTED(a.ReturnResult(1), \"\");\n#endif\n}\n\n// Tests that an excessive call (one whose arguments match the\n// matchers but is called too many times) performs the default action.\nTEST(ExcessiveCallTest, DoesDefaultAction) {\n  // When there is an ON_CALL() statement, the action specified by it\n  // should be taken.\n  MockA a;\n  ON_CALL(a, Binary(_, _))\n      .WillByDefault(Return(true));\n  EXPECT_CALL(a, Binary(0, 0));\n  a.Binary(0, 0);\n  bool result = false;\n  EXPECT_NONFATAL_FAILURE(result = a.Binary(0, 0),\n                          \"Mock function called more times than expected\");\n  EXPECT_TRUE(result);\n\n  // When there is no ON_CALL(), the default value for the return type\n  // should be returned.\n  MockB b;\n  EXPECT_CALL(b, DoB(0))\n      .Times(0);\n  int n = -1;\n  EXPECT_NONFATAL_FAILURE(n = b.DoB(0),\n                          \"Mock function called more times than expected\");\n  EXPECT_EQ(0, n);\n}\n\n// Tests that when a void function is called too many times,\n// the failure message contains the argument values.\nTEST(ExcessiveCallTest, GeneratesFailureForVoidFunction) {\n  MockA a;\n  EXPECT_CALL(a, DoA(_))\n      .Times(0);\n  EXPECT_NONFATAL_FAILURE(\n      a.DoA(9),\n      \"Mock function called more times than expected - returning directly.\\n\"\n      \"    Function call: DoA(9)\\n\"\n      \"         Expected: to be never called\\n\"\n      \"           Actual: called once - over-saturated and active\");\n}\n\n// Tests that when a non-void function is called too many times, the\n// failure message contains the argument values and the return value.\nTEST(ExcessiveCallTest, GeneratesFailureForNonVoidFunction) {\n  MockB b;\n  EXPECT_CALL(b, DoB(_));\n  b.DoB(1);\n  EXPECT_NONFATAL_FAILURE(\n      b.DoB(2),\n      \"Mock function called more times than expected - \"\n      \"returning default value.\\n\"\n      \"    Function call: DoB(2)\\n\"\n      \"          Returns: 0\\n\"\n      \"         Expected: to be called once\\n\"\n      \"           Actual: called twice - over-saturated and active\");\n}\n\n// Tests using sequences.\n\nTEST(InSequenceTest, AllExpectationInScopeAreInSequence) {\n  MockA a;\n  {\n    InSequence dummy;\n\n    EXPECT_CALL(a, DoA(1));\n    EXPECT_CALL(a, DoA(2));\n  }\n\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    a.DoA(2);\n  }, \"Unexpected mock function call\");\n\n  a.DoA(1);\n  a.DoA(2);\n}\n\nTEST(InSequenceTest, NestedInSequence) {\n  MockA a;\n  {\n    InSequence dummy;\n\n    EXPECT_CALL(a, DoA(1));\n    {\n      InSequence dummy2;\n\n      EXPECT_CALL(a, DoA(2));\n      EXPECT_CALL(a, DoA(3));\n    }\n  }\n\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    a.DoA(1);\n    a.DoA(3);\n  }, \"Unexpected mock function call\");\n\n  a.DoA(2);\n  a.DoA(3);\n}\n\nTEST(InSequenceTest, ExpectationsOutOfScopeAreNotAffected) {\n  MockA a;\n  {\n    InSequence dummy;\n\n    EXPECT_CALL(a, DoA(1));\n    EXPECT_CALL(a, DoA(2));\n  }\n  EXPECT_CALL(a, DoA(3));\n\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    a.DoA(2);\n  }, \"Unexpected mock function call\");\n\n  a.DoA(3);\n  a.DoA(1);\n  a.DoA(2);\n}\n\n// Tests that any order is allowed when no sequence is used.\nTEST(SequenceTest, AnyOrderIsOkByDefault) {\n  {\n    MockA a;\n    MockB b;\n\n    EXPECT_CALL(a, DoA(1));\n    EXPECT_CALL(b, DoB())\n        .Times(AnyNumber());\n\n    a.DoA(1);\n    b.DoB();\n  }\n\n  {  // NOLINT\n    MockA a;\n    MockB b;\n\n    EXPECT_CALL(a, DoA(1));\n    EXPECT_CALL(b, DoB())\n        .Times(AnyNumber());\n\n    b.DoB();\n    a.DoA(1);\n  }\n}\n\n// Tests that the calls must be in strict order when a complete order\n// is specified.\nTEST(SequenceTest, CallsMustBeInStrictOrderWhenSaidSo1) {\n  MockA a;\n  ON_CALL(a, ReturnResult(_))\n      .WillByDefault(Return(Result()));\n\n  Sequence s;\n  EXPECT_CALL(a, ReturnResult(1))\n      .InSequence(s);\n  EXPECT_CALL(a, ReturnResult(2))\n      .InSequence(s);\n  EXPECT_CALL(a, ReturnResult(3))\n      .InSequence(s);\n\n  a.ReturnResult(1);\n\n  // May only be called after a.ReturnResult(2).\n  EXPECT_NONFATAL_FAILURE(a.ReturnResult(3), \"Unexpected mock function call\");\n\n  a.ReturnResult(2);\n  a.ReturnResult(3);\n}\n\n// Tests that the calls must be in strict order when a complete order\n// is specified.\nTEST(SequenceTest, CallsMustBeInStrictOrderWhenSaidSo2) {\n  MockA a;\n  ON_CALL(a, ReturnResult(_))\n      .WillByDefault(Return(Result()));\n\n  Sequence s;\n  EXPECT_CALL(a, ReturnResult(1))\n      .InSequence(s);\n  EXPECT_CALL(a, ReturnResult(2))\n      .InSequence(s);\n\n  // May only be called after a.ReturnResult(1).\n  EXPECT_NONFATAL_FAILURE(a.ReturnResult(2), \"Unexpected mock function call\");\n\n  a.ReturnResult(1);\n  a.ReturnResult(2);\n}\n\n// Tests specifying a DAG using multiple sequences.\nclass PartialOrderTest : public testing::Test {\n protected:\n  PartialOrderTest() {\n    ON_CALL(a_, ReturnResult(_))\n        .WillByDefault(Return(Result()));\n\n    // Specifies this partial ordering:\n    //\n    // a.ReturnResult(1) ==>\n    //                       a.ReturnResult(2) * n  ==>  a.ReturnResult(3)\n    // b.DoB() * 2       ==>\n    Sequence x, y;\n    EXPECT_CALL(a_, ReturnResult(1))\n        .InSequence(x);\n    EXPECT_CALL(b_, DoB())\n        .Times(2)\n        .InSequence(y);\n    EXPECT_CALL(a_, ReturnResult(2))\n        .Times(AnyNumber())\n        .InSequence(x, y);\n    EXPECT_CALL(a_, ReturnResult(3))\n        .InSequence(x);\n  }\n\n  MockA a_;\n  MockB b_;\n};\n\nTEST_F(PartialOrderTest, CallsMustConformToSpecifiedDag1) {\n  a_.ReturnResult(1);\n  b_.DoB();\n\n  // May only be called after the second DoB().\n  EXPECT_NONFATAL_FAILURE(a_.ReturnResult(2), \"Unexpected mock function call\");\n\n  b_.DoB();\n  a_.ReturnResult(3);\n}\n\nTEST_F(PartialOrderTest, CallsMustConformToSpecifiedDag2) {\n  // May only be called after ReturnResult(1).\n  EXPECT_NONFATAL_FAILURE(a_.ReturnResult(2), \"Unexpected mock function call\");\n\n  a_.ReturnResult(1);\n  b_.DoB();\n  b_.DoB();\n  a_.ReturnResult(3);\n}\n\nTEST_F(PartialOrderTest, CallsMustConformToSpecifiedDag3) {\n  // May only be called last.\n  EXPECT_NONFATAL_FAILURE(a_.ReturnResult(3), \"Unexpected mock function call\");\n\n  a_.ReturnResult(1);\n  b_.DoB();\n  b_.DoB();\n  a_.ReturnResult(3);\n}\n\nTEST_F(PartialOrderTest, CallsMustConformToSpecifiedDag4) {\n  a_.ReturnResult(1);\n  b_.DoB();\n  b_.DoB();\n  a_.ReturnResult(3);\n\n  // May only be called before ReturnResult(3).\n  EXPECT_NONFATAL_FAILURE(a_.ReturnResult(2), \"Unexpected mock function call\");\n}\n\nTEST(SequenceTest, Retirement) {\n  MockA a;\n  Sequence s;\n\n  EXPECT_CALL(a, DoA(1))\n      .InSequence(s);\n  EXPECT_CALL(a, DoA(_))\n      .InSequence(s)\n      .RetiresOnSaturation();\n  EXPECT_CALL(a, DoA(1))\n      .InSequence(s);\n\n  a.DoA(1);\n  a.DoA(2);\n  a.DoA(1);\n}\n\n// Tests Expectation.\n\nTEST(ExpectationTest, ConstrutorsWork) {\n  MockA a;\n  Expectation e1;  // Default ctor.\n\n  // Ctor from various forms of EXPECT_CALL.\n  Expectation e2 = EXPECT_CALL(a, DoA(2));\n  Expectation e3 = EXPECT_CALL(a, DoA(3)).With(_);\n  {\n    Sequence s;\n    Expectation e4 = EXPECT_CALL(a, DoA(4)).Times(1);\n    Expectation e5 = EXPECT_CALL(a, DoA(5)).InSequence(s);\n  }\n  Expectation e6 = EXPECT_CALL(a, DoA(6)).After(e2);\n  Expectation e7 = EXPECT_CALL(a, DoA(7)).WillOnce(Return());\n  Expectation e8 = EXPECT_CALL(a, DoA(8)).WillRepeatedly(Return());\n  Expectation e9 = EXPECT_CALL(a, DoA(9)).RetiresOnSaturation();\n\n  Expectation e10 = e2;  // Copy ctor.\n\n  EXPECT_THAT(e1, Ne(e2));\n  EXPECT_THAT(e2, Eq(e10));\n\n  a.DoA(2);\n  a.DoA(3);\n  a.DoA(4);\n  a.DoA(5);\n  a.DoA(6);\n  a.DoA(7);\n  a.DoA(8);\n  a.DoA(9);\n}\n\nTEST(ExpectationTest, AssignmentWorks) {\n  MockA a;\n  Expectation e1;\n  Expectation e2 = EXPECT_CALL(a, DoA(1));\n\n  EXPECT_THAT(e1, Ne(e2));\n\n  e1 = e2;\n  EXPECT_THAT(e1, Eq(e2));\n\n  a.DoA(1);\n}\n\n// Tests ExpectationSet.\n\nTEST(ExpectationSetTest, MemberTypesAreCorrect) {\n  ::testing::StaticAssertTypeEq<Expectation, ExpectationSet::value_type>();\n}\n\nTEST(ExpectationSetTest, ConstructorsWork) {\n  MockA a;\n\n  Expectation e1;\n  const Expectation e2;\n  ExpectationSet es1;  // Default ctor.\n  ExpectationSet es2 = EXPECT_CALL(a, DoA(1));  // Ctor from EXPECT_CALL.\n  ExpectationSet es3 = e1;  // Ctor from Expectation.\n  ExpectationSet es4(e1);   // Ctor from Expectation; alternative syntax.\n  ExpectationSet es5 = e2;  // Ctor from const Expectation.\n  ExpectationSet es6(e2);   // Ctor from const Expectation; alternative syntax.\n  ExpectationSet es7 = es2;  // Copy ctor.\n\n  EXPECT_EQ(0, es1.size());\n  EXPECT_EQ(1, es2.size());\n  EXPECT_EQ(1, es3.size());\n  EXPECT_EQ(1, es4.size());\n  EXPECT_EQ(1, es5.size());\n  EXPECT_EQ(1, es6.size());\n  EXPECT_EQ(1, es7.size());\n\n  EXPECT_THAT(es3, Ne(es2));\n  EXPECT_THAT(es4, Eq(es3));\n  EXPECT_THAT(es5, Eq(es4));\n  EXPECT_THAT(es6, Eq(es5));\n  EXPECT_THAT(es7, Eq(es2));\n  a.DoA(1);\n}\n\nTEST(ExpectationSetTest, AssignmentWorks) {\n  ExpectationSet es1;\n  ExpectationSet es2 = Expectation();\n\n  es1 = es2;\n  EXPECT_EQ(1, es1.size());\n  EXPECT_THAT(*(es1.begin()), Eq(Expectation()));\n  EXPECT_THAT(es1, Eq(es2));\n}\n\nTEST(ExpectationSetTest, InsertionWorks) {\n  ExpectationSet es1;\n  Expectation e1;\n  es1 += e1;\n  EXPECT_EQ(1, es1.size());\n  EXPECT_THAT(*(es1.begin()), Eq(e1));\n\n  MockA a;\n  Expectation e2 = EXPECT_CALL(a, DoA(1));\n  es1 += e2;\n  EXPECT_EQ(2, es1.size());\n\n  ExpectationSet::const_iterator it1 = es1.begin();\n  ExpectationSet::const_iterator it2 = it1;\n  ++it2;\n  EXPECT_TRUE(*it1 == e1 || *it2 == e1);  // e1 must be in the set.\n  EXPECT_TRUE(*it1 == e2 || *it2 == e2);  // e2 must be in the set too.\n  a.DoA(1);\n}\n\nTEST(ExpectationSetTest, SizeWorks) {\n  ExpectationSet es;\n  EXPECT_EQ(0, es.size());\n\n  es += Expectation();\n  EXPECT_EQ(1, es.size());\n\n  MockA a;\n  es += EXPECT_CALL(a, DoA(1));\n  EXPECT_EQ(2, es.size());\n\n  a.DoA(1);\n}\n\nTEST(ExpectationSetTest, IsEnumerable) {\n  ExpectationSet es;\n  EXPECT_TRUE(es.begin() == es.end());\n\n  es += Expectation();\n  ExpectationSet::const_iterator it = es.begin();\n  EXPECT_TRUE(it != es.end());\n  EXPECT_THAT(*it, Eq(Expectation()));\n  ++it;\n  EXPECT_TRUE(it== es.end());\n}\n\n// Tests the .After() clause.\n\nTEST(AfterTest, SucceedsWhenPartialOrderIsSatisfied) {\n  MockA a;\n  ExpectationSet es;\n  es += EXPECT_CALL(a, DoA(1));\n  es += EXPECT_CALL(a, DoA(2));\n  EXPECT_CALL(a, DoA(3))\n      .After(es);\n\n  a.DoA(1);\n  a.DoA(2);\n  a.DoA(3);\n}\n\nTEST(AfterTest, SucceedsWhenTotalOrderIsSatisfied) {\n  MockA a;\n  MockB b;\n  // The following also verifies that const Expectation objects work\n  // too.  Do not remove the const modifiers.\n  const Expectation e1 = EXPECT_CALL(a, DoA(1));\n  const Expectation e2 = EXPECT_CALL(b, DoB())\n      .Times(2)\n      .After(e1);\n  EXPECT_CALL(a, DoA(2)).After(e2);\n\n  a.DoA(1);\n  b.DoB();\n  b.DoB();\n  a.DoA(2);\n}\n\n// Calls must be in strict order when specified so using .After().\nTEST(AfterTest, CallsMustBeInStrictOrderWhenSpecifiedSo1) {\n  MockA a;\n  MockB b;\n\n  // Define ordering:\n  //   a.DoA(1) ==> b.DoB() ==> a.DoA(2)\n  Expectation e1 = EXPECT_CALL(a, DoA(1));\n  Expectation e2 = EXPECT_CALL(b, DoB())\n      .After(e1);\n  EXPECT_CALL(a, DoA(2))\n      .After(e2);\n\n  a.DoA(1);\n\n  // May only be called after DoB().\n  EXPECT_NONFATAL_FAILURE(a.DoA(2), \"Unexpected mock function call\");\n\n  b.DoB();\n  a.DoA(2);\n}\n\n// Calls must be in strict order when specified so using .After().\nTEST(AfterTest, CallsMustBeInStrictOrderWhenSpecifiedSo2) {\n  MockA a;\n  MockB b;\n\n  // Define ordering:\n  //   a.DoA(1) ==> b.DoB() * 2 ==> a.DoA(2)\n  Expectation e1 = EXPECT_CALL(a, DoA(1));\n  Expectation e2 = EXPECT_CALL(b, DoB())\n      .Times(2)\n      .After(e1);\n  EXPECT_CALL(a, DoA(2))\n      .After(e2);\n\n  a.DoA(1);\n  b.DoB();\n\n  // May only be called after the second DoB().\n  EXPECT_NONFATAL_FAILURE(a.DoA(2), \"Unexpected mock function call\");\n\n  b.DoB();\n  a.DoA(2);\n}\n\n// Calls must satisfy the partial order when specified so.\nTEST(AfterTest, CallsMustSatisfyPartialOrderWhenSpecifiedSo) {\n  MockA a;\n  ON_CALL(a, ReturnResult(_))\n      .WillByDefault(Return(Result()));\n\n  // Define ordering:\n  //   a.DoA(1) ==>\n  //   a.DoA(2) ==> a.ReturnResult(3)\n  Expectation e = EXPECT_CALL(a, DoA(1));\n  const ExpectationSet es = EXPECT_CALL(a, DoA(2));\n  EXPECT_CALL(a, ReturnResult(3))\n      .After(e, es);\n\n  // May only be called last.\n  EXPECT_NONFATAL_FAILURE(a.ReturnResult(3), \"Unexpected mock function call\");\n\n  a.DoA(2);\n  a.DoA(1);\n  a.ReturnResult(3);\n}\n\n// Calls must satisfy the partial order when specified so.\nTEST(AfterTest, CallsMustSatisfyPartialOrderWhenSpecifiedSo2) {\n  MockA a;\n\n  // Define ordering:\n  //   a.DoA(1) ==>\n  //   a.DoA(2) ==> a.DoA(3)\n  Expectation e = EXPECT_CALL(a, DoA(1));\n  const ExpectationSet es = EXPECT_CALL(a, DoA(2));\n  EXPECT_CALL(a, DoA(3))\n      .After(e, es);\n\n  a.DoA(2);\n\n  // May only be called last.\n  EXPECT_NONFATAL_FAILURE(a.DoA(3), \"Unexpected mock function call\");\n\n  a.DoA(1);\n  a.DoA(3);\n}\n\n// .After() can be combined with .InSequence().\nTEST(AfterTest, CanBeUsedWithInSequence) {\n  MockA a;\n  Sequence s;\n  Expectation e = EXPECT_CALL(a, DoA(1));\n  EXPECT_CALL(a, DoA(2)).InSequence(s);\n  EXPECT_CALL(a, DoA(3))\n      .InSequence(s)\n      .After(e);\n\n  a.DoA(1);\n\n  // May only be after DoA(2).\n  EXPECT_NONFATAL_FAILURE(a.DoA(3), \"Unexpected mock function call\");\n\n  a.DoA(2);\n  a.DoA(3);\n}\n\n// .After() can be called multiple times.\nTEST(AfterTest, CanBeCalledManyTimes) {\n  MockA a;\n  Expectation e1 = EXPECT_CALL(a, DoA(1));\n  Expectation e2 = EXPECT_CALL(a, DoA(2));\n  Expectation e3 = EXPECT_CALL(a, DoA(3));\n  EXPECT_CALL(a, DoA(4))\n      .After(e1)\n      .After(e2)\n      .After(e3);\n\n  a.DoA(3);\n  a.DoA(1);\n  a.DoA(2);\n  a.DoA(4);\n}\n\n// .After() accepts up to 5 arguments.\nTEST(AfterTest, AcceptsUpToFiveArguments) {\n  MockA a;\n  Expectation e1 = EXPECT_CALL(a, DoA(1));\n  Expectation e2 = EXPECT_CALL(a, DoA(2));\n  Expectation e3 = EXPECT_CALL(a, DoA(3));\n  ExpectationSet es1 = EXPECT_CALL(a, DoA(4));\n  ExpectationSet es2 = EXPECT_CALL(a, DoA(5));\n  EXPECT_CALL(a, DoA(6))\n      .After(e1, e2, e3, es1, es2);\n\n  a.DoA(5);\n  a.DoA(2);\n  a.DoA(4);\n  a.DoA(1);\n  a.DoA(3);\n  a.DoA(6);\n}\n\n// .After() allows input to contain duplicated Expectations.\nTEST(AfterTest, AcceptsDuplicatedInput) {\n  MockA a;\n  ON_CALL(a, ReturnResult(_))\n      .WillByDefault(Return(Result()));\n\n  // Define ordering:\n  //   DoA(1) ==>\n  //   DoA(2) ==> ReturnResult(3)\n  Expectation e1 = EXPECT_CALL(a, DoA(1));\n  Expectation e2 = EXPECT_CALL(a, DoA(2));\n  ExpectationSet es;\n  es += e1;\n  es += e2;\n  EXPECT_CALL(a, ReturnResult(3))\n      .After(e1, e2, es, e1);\n\n  a.DoA(1);\n\n  // May only be after DoA(2).\n  EXPECT_NONFATAL_FAILURE(a.ReturnResult(3), \"Unexpected mock function call\");\n\n  a.DoA(2);\n  a.ReturnResult(3);\n}\n\n// An Expectation added to an ExpectationSet after it has been used in\n// an .After() has no effect.\nTEST(AfterTest, ChangesToExpectationSetHaveNoEffectAfterwards) {\n  MockA a;\n  ExpectationSet es1 = EXPECT_CALL(a, DoA(1));\n  Expectation e2 = EXPECT_CALL(a, DoA(2));\n  EXPECT_CALL(a, DoA(3))\n      .After(es1);\n  es1 += e2;\n\n  a.DoA(1);\n  a.DoA(3);\n  a.DoA(2);\n}\n\n// Tests that Google Mock correctly handles calls to mock functions\n// after a mock object owning one of their pre-requisites has died.\n\n// Tests that calls that satisfy the original spec are successful.\nTEST(DeletingMockEarlyTest, Success1) {\n  MockB* const b1 = new MockB;\n  MockA* const a = new MockA;\n  MockB* const b2 = new MockB;\n\n  {\n    InSequence dummy;\n    EXPECT_CALL(*b1, DoB(_))\n        .WillOnce(Return(1));\n    EXPECT_CALL(*a, Binary(_, _))\n        .Times(AnyNumber())\n        .WillRepeatedly(Return(true));\n    EXPECT_CALL(*b2, DoB(_))\n        .Times(AnyNumber())\n        .WillRepeatedly(Return(2));\n  }\n\n  EXPECT_EQ(1, b1->DoB(1));\n  delete b1;\n  // a's pre-requisite has died.\n  EXPECT_TRUE(a->Binary(0, 1));\n  delete b2;\n  // a's successor has died.\n  EXPECT_TRUE(a->Binary(1, 2));\n  delete a;\n}\n\n// Tests that calls that satisfy the original spec are successful.\nTEST(DeletingMockEarlyTest, Success2) {\n  MockB* const b1 = new MockB;\n  MockA* const a = new MockA;\n  MockB* const b2 = new MockB;\n\n  {\n    InSequence dummy;\n    EXPECT_CALL(*b1, DoB(_))\n        .WillOnce(Return(1));\n    EXPECT_CALL(*a, Binary(_, _))\n        .Times(AnyNumber());\n    EXPECT_CALL(*b2, DoB(_))\n        .Times(AnyNumber())\n        .WillRepeatedly(Return(2));\n  }\n\n  delete a;  // a is trivially satisfied.\n  EXPECT_EQ(1, b1->DoB(1));\n  EXPECT_EQ(2, b2->DoB(2));\n  delete b1;\n  delete b2;\n}\n\n// Tests that it's OK to delete a mock object itself in its action.\n\n// Suppresses warning on unreferenced formal parameter in MSVC with\n// -W4.\n#ifdef _MSC_VER\n# pragma warning(push)\n# pragma warning(disable:4100)\n#endif\n\nACTION_P(Delete, ptr) { delete ptr; }\n\n#ifdef _MSC_VER\n# pragma warning(pop)\n#endif\n\nTEST(DeletingMockEarlyTest, CanDeleteSelfInActionReturningVoid) {\n  MockA* const a = new MockA;\n  EXPECT_CALL(*a, DoA(_)).WillOnce(Delete(a));\n  a->DoA(42);  // This will cause a to be deleted.\n}\n\nTEST(DeletingMockEarlyTest, CanDeleteSelfInActionReturningValue) {\n  MockA* const a = new MockA;\n  EXPECT_CALL(*a, ReturnResult(_))\n      .WillOnce(DoAll(Delete(a), Return(Result())));\n  a->ReturnResult(42);  // This will cause a to be deleted.\n}\n\n// Tests that calls that violate the original spec yield failures.\nTEST(DeletingMockEarlyTest, Failure1) {\n  MockB* const b1 = new MockB;\n  MockA* const a = new MockA;\n  MockB* const b2 = new MockB;\n\n  {\n    InSequence dummy;\n    EXPECT_CALL(*b1, DoB(_))\n        .WillOnce(Return(1));\n    EXPECT_CALL(*a, Binary(_, _))\n        .Times(AnyNumber());\n    EXPECT_CALL(*b2, DoB(_))\n        .Times(AnyNumber())\n        .WillRepeatedly(Return(2));\n  }\n\n  delete a;  // a is trivially satisfied.\n  EXPECT_NONFATAL_FAILURE({\n    b2->DoB(2);\n  }, \"Unexpected mock function call\");\n  EXPECT_EQ(1, b1->DoB(1));\n  delete b1;\n  delete b2;\n}\n\n// Tests that calls that violate the original spec yield failures.\nTEST(DeletingMockEarlyTest, Failure2) {\n  MockB* const b1 = new MockB;\n  MockA* const a = new MockA;\n  MockB* const b2 = new MockB;\n\n  {\n    InSequence dummy;\n    EXPECT_CALL(*b1, DoB(_));\n    EXPECT_CALL(*a, Binary(_, _))\n        .Times(AnyNumber());\n    EXPECT_CALL(*b2, DoB(_))\n        .Times(AnyNumber());\n  }\n\n  EXPECT_NONFATAL_FAILURE(delete b1,\n                          \"Actual: never called\");\n  EXPECT_NONFATAL_FAILURE(a->Binary(0, 1),\n                          \"Unexpected mock function call\");\n  EXPECT_NONFATAL_FAILURE(b2->DoB(1),\n                          \"Unexpected mock function call\");\n  delete a;\n  delete b2;\n}\n\nclass EvenNumberCardinality : public CardinalityInterface {\n public:\n  // Returns true iff call_count calls will satisfy this cardinality.\n  virtual bool IsSatisfiedByCallCount(int call_count) const {\n    return call_count % 2 == 0;\n  }\n\n  // Returns true iff call_count calls will saturate this cardinality.\n  virtual bool IsSaturatedByCallCount(int /* call_count */) const {\n    return false;\n  }\n\n  // Describes self to an ostream.\n  virtual void DescribeTo(::std::ostream* os) const {\n    *os << \"called even number of times\";\n  }\n};\n\nCardinality EvenNumber() {\n  return Cardinality(new EvenNumberCardinality);\n}\n\nTEST(ExpectationBaseTest,\n     AllPrerequisitesAreSatisfiedWorksForNonMonotonicCardinality) {\n  MockA* a = new MockA;\n  Sequence s;\n\n  EXPECT_CALL(*a, DoA(1))\n      .Times(EvenNumber())\n      .InSequence(s);\n  EXPECT_CALL(*a, DoA(2))\n      .Times(AnyNumber())\n      .InSequence(s);\n  EXPECT_CALL(*a, DoA(3))\n      .Times(AnyNumber());\n\n  a->DoA(3);\n  a->DoA(1);\n  EXPECT_NONFATAL_FAILURE(a->DoA(2), \"Unexpected mock function call\");\n  EXPECT_NONFATAL_FAILURE(delete a, \"to be called even number of times\");\n}\n\n// The following tests verify the message generated when a mock\n// function is called.\n\nstruct Printable {\n};\n\ninline void operator<<(::std::ostream& os, const Printable&) {\n  os << \"Printable\";\n}\n\nstruct Unprintable {\n  Unprintable() : value(0) {}\n  int value;\n};\n\nclass MockC {\n public:\n  MockC() {}\n\n  MOCK_METHOD6(VoidMethod, void(bool cond, int n, string s, void* p,\n                                const Printable& x, Unprintable y));\n  MOCK_METHOD0(NonVoidMethod, int());  // NOLINT\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockC);\n};\n\nclass VerboseFlagPreservingFixture : public testing::Test {\n protected:\n  VerboseFlagPreservingFixture()\n      : saved_verbose_flag_(GMOCK_FLAG(verbose)) {}\n\n  ~VerboseFlagPreservingFixture() { GMOCK_FLAG(verbose) = saved_verbose_flag_; }\n\n private:\n  const string saved_verbose_flag_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(VerboseFlagPreservingFixture);\n};\n\n#if GTEST_HAS_STREAM_REDIRECTION\n\n// Tests that an uninteresting mock function call on a naggy mock\n// generates a warning containing the stack trace.\nTEST(FunctionCallMessageTest,\n     UninterestingCallOnNaggyMockGeneratesFyiWithStackTrace) {\n  NaggyMock<MockC> c;\n  CaptureStdout();\n  c.VoidMethod(false, 5, \"Hi\", NULL, Printable(), Unprintable());\n  const std::string output = GetCapturedStdout();\n  EXPECT_PRED_FORMAT2(IsSubstring, \"GMOCK WARNING\", output);\n  EXPECT_PRED_FORMAT2(IsSubstring, \"Stack trace:\", output);\n\n# ifndef NDEBUG\n\n  // We check the stack trace content in dbg-mode only, as opt-mode\n  // may inline the call we are interested in seeing.\n\n  // Verifies that a void mock function's name appears in the stack\n  // trace.\n  EXPECT_PRED_FORMAT2(IsSubstring, \"VoidMethod(\", output);\n\n  // Verifies that a non-void mock function's name appears in the\n  // stack trace.\n  CaptureStdout();\n  c.NonVoidMethod();\n  const std::string output2 = GetCapturedStdout();\n  EXPECT_PRED_FORMAT2(IsSubstring, \"NonVoidMethod(\", output2);\n\n# endif  // NDEBUG\n}\n\n// Tests that an uninteresting mock function call on a naggy mock\n// causes the function arguments and return value to be printed.\nTEST(FunctionCallMessageTest,\n     UninterestingCallOnNaggyMockPrintsArgumentsAndReturnValue) {\n  // A non-void mock function.\n  NaggyMock<MockB> b;\n  CaptureStdout();\n  b.DoB();\n  const std::string output1 = GetCapturedStdout();\n  EXPECT_PRED_FORMAT2(\n      IsSubstring,\n      \"Uninteresting mock function call - returning default value.\\n\"\n      \"    Function call: DoB()\\n\"\n      \"          Returns: 0\\n\", output1.c_str());\n  // Makes sure the return value is printed.\n\n  // A void mock function.\n  NaggyMock<MockC> c;\n  CaptureStdout();\n  c.VoidMethod(false, 5, \"Hi\", NULL, Printable(), Unprintable());\n  const std::string output2 = GetCapturedStdout();\n  EXPECT_THAT(output2.c_str(),\n              ContainsRegex(\n                  \"Uninteresting mock function call - returning directly\\\\.\\n\"\n                  \"    Function call: VoidMethod\"\n                  \"\\\\(false, 5, \\\"Hi\\\", NULL, @.+ \"\n                  \"Printable, 4-byte object <00-00 00-00>\\\\)\"));\n  // A void function has no return value to print.\n}\n\n// Tests how the --gmock_verbose flag affects Google Mock's output.\n\nclass GMockVerboseFlagTest : public VerboseFlagPreservingFixture {\n public:\n  // Verifies that the given Google Mock output is correct.  (When\n  // should_print is true, the output should match the given regex and\n  // contain the given function name in the stack trace.  When it's\n  // false, the output should be empty.)\n  void VerifyOutput(const std::string& output, bool should_print,\n                    const string& expected_substring,\n                    const string& function_name) {\n    if (should_print) {\n      EXPECT_THAT(output.c_str(), HasSubstr(expected_substring));\n# ifndef NDEBUG\n      // We check the stack trace content in dbg-mode only, as opt-mode\n      // may inline the call we are interested in seeing.\n      EXPECT_THAT(output.c_str(), HasSubstr(function_name));\n# else\n      // Suppresses 'unused function parameter' warnings.\n      static_cast<void>(function_name);\n# endif  // NDEBUG\n    } else {\n      EXPECT_STREQ(\"\", output.c_str());\n    }\n  }\n\n  // Tests how the flag affects expected calls.\n  void TestExpectedCall(bool should_print) {\n    MockA a;\n    EXPECT_CALL(a, DoA(5));\n    EXPECT_CALL(a, Binary(_, 1))\n        .WillOnce(Return(true));\n\n    // A void-returning function.\n    CaptureStdout();\n    a.DoA(5);\n    VerifyOutput(\n        GetCapturedStdout(),\n        should_print,\n        \"Mock function call matches EXPECT_CALL(a, DoA(5))...\\n\"\n        \"    Function call: DoA(5)\\n\"\n        \"Stack trace:\\n\",\n        \"DoA\");\n\n    // A non-void-returning function.\n    CaptureStdout();\n    a.Binary(2, 1);\n    VerifyOutput(\n        GetCapturedStdout(),\n        should_print,\n        \"Mock function call matches EXPECT_CALL(a, Binary(_, 1))...\\n\"\n        \"    Function call: Binary(2, 1)\\n\"\n        \"          Returns: true\\n\"\n        \"Stack trace:\\n\",\n        \"Binary\");\n  }\n\n  // Tests how the flag affects uninteresting calls on a naggy mock.\n  void TestUninterestingCallOnNaggyMock(bool should_print) {\n    NaggyMock<MockA> a;\n\n    // A void-returning function.\n    CaptureStdout();\n    a.DoA(5);\n    VerifyOutput(\n        GetCapturedStdout(),\n        should_print,\n        \"\\nGMOCK WARNING:\\n\"\n        \"Uninteresting mock function call - returning directly.\\n\"\n        \"    Function call: DoA(5)\\n\"\n        \"Stack trace:\\n\",\n        \"DoA\");\n\n    // A non-void-returning function.\n    CaptureStdout();\n    a.Binary(2, 1);\n    VerifyOutput(\n        GetCapturedStdout(),\n        should_print,\n        \"\\nGMOCK WARNING:\\n\"\n        \"Uninteresting mock function call - returning default value.\\n\"\n        \"    Function call: Binary(2, 1)\\n\"\n        \"          Returns: false\\n\"\n        \"Stack trace:\\n\",\n        \"Binary\");\n  }\n};\n\n// Tests that --gmock_verbose=info causes both expected and\n// uninteresting calls to be reported.\nTEST_F(GMockVerboseFlagTest, Info) {\n  GMOCK_FLAG(verbose) = kInfoVerbosity;\n  TestExpectedCall(true);\n  TestUninterestingCallOnNaggyMock(true);\n}\n\n// Tests that --gmock_verbose=warning causes uninteresting calls to be\n// reported.\nTEST_F(GMockVerboseFlagTest, Warning) {\n  GMOCK_FLAG(verbose) = kWarningVerbosity;\n  TestExpectedCall(false);\n  TestUninterestingCallOnNaggyMock(true);\n}\n\n// Tests that --gmock_verbose=warning causes neither expected nor\n// uninteresting calls to be reported.\nTEST_F(GMockVerboseFlagTest, Error) {\n  GMOCK_FLAG(verbose) = kErrorVerbosity;\n  TestExpectedCall(false);\n  TestUninterestingCallOnNaggyMock(false);\n}\n\n// Tests that --gmock_verbose=SOME_INVALID_VALUE has the same effect\n// as --gmock_verbose=warning.\nTEST_F(GMockVerboseFlagTest, InvalidFlagIsTreatedAsWarning) {\n  GMOCK_FLAG(verbose) = \"invalid\";  // Treated as \"warning\".\n  TestExpectedCall(false);\n  TestUninterestingCallOnNaggyMock(true);\n}\n\n#endif  // GTEST_HAS_STREAM_REDIRECTION\n\n// A helper class that generates a failure when printed.  We use it to\n// ensure that Google Mock doesn't print a value (even to an internal\n// buffer) when it is not supposed to do so.\nclass PrintMeNot {};\n\nvoid PrintTo(PrintMeNot /* dummy */, ::std::ostream* /* os */) {\n  ADD_FAILURE() << \"Google Mock is printing a value that shouldn't be \"\n                << \"printed even to an internal buffer.\";\n}\n\nclass LogTestHelper {\n public:\n  LogTestHelper() {}\n\n  MOCK_METHOD1(Foo, PrintMeNot(PrintMeNot));\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(LogTestHelper);\n};\n\nclass GMockLogTest : public VerboseFlagPreservingFixture {\n protected:\n  LogTestHelper helper_;\n};\n\nTEST_F(GMockLogTest, DoesNotPrintGoodCallInternallyIfVerbosityIsWarning) {\n  GMOCK_FLAG(verbose) = kWarningVerbosity;\n  EXPECT_CALL(helper_, Foo(_))\n      .WillOnce(Return(PrintMeNot()));\n  helper_.Foo(PrintMeNot());  // This is an expected call.\n}\n\nTEST_F(GMockLogTest, DoesNotPrintGoodCallInternallyIfVerbosityIsError) {\n  GMOCK_FLAG(verbose) = kErrorVerbosity;\n  EXPECT_CALL(helper_, Foo(_))\n      .WillOnce(Return(PrintMeNot()));\n  helper_.Foo(PrintMeNot());  // This is an expected call.\n}\n\nTEST_F(GMockLogTest, DoesNotPrintWarningInternallyIfVerbosityIsError) {\n  GMOCK_FLAG(verbose) = kErrorVerbosity;\n  ON_CALL(helper_, Foo(_))\n      .WillByDefault(Return(PrintMeNot()));\n  helper_.Foo(PrintMeNot());  // This should generate a warning.\n}\n\n// Tests Mock::AllowLeak().\n\nTEST(AllowLeakTest, AllowsLeakingUnusedMockObject) {\n  MockA* a = new MockA;\n  Mock::AllowLeak(a);\n}\n\nTEST(AllowLeakTest, CanBeCalledBeforeOnCall) {\n  MockA* a = new MockA;\n  Mock::AllowLeak(a);\n  ON_CALL(*a, DoA(_)).WillByDefault(Return());\n  a->DoA(0);\n}\n\nTEST(AllowLeakTest, CanBeCalledAfterOnCall) {\n  MockA* a = new MockA;\n  ON_CALL(*a, DoA(_)).WillByDefault(Return());\n  Mock::AllowLeak(a);\n}\n\nTEST(AllowLeakTest, CanBeCalledBeforeExpectCall) {\n  MockA* a = new MockA;\n  Mock::AllowLeak(a);\n  EXPECT_CALL(*a, DoA(_));\n  a->DoA(0);\n}\n\nTEST(AllowLeakTest, CanBeCalledAfterExpectCall) {\n  MockA* a = new MockA;\n  EXPECT_CALL(*a, DoA(_)).Times(AnyNumber());\n  Mock::AllowLeak(a);\n}\n\nTEST(AllowLeakTest, WorksWhenBothOnCallAndExpectCallArePresent) {\n  MockA* a = new MockA;\n  ON_CALL(*a, DoA(_)).WillByDefault(Return());\n  EXPECT_CALL(*a, DoA(_)).Times(AnyNumber());\n  Mock::AllowLeak(a);\n}\n\n// Tests that we can verify and clear a mock object's expectations\n// when none of its methods has expectations.\nTEST(VerifyAndClearExpectationsTest, NoMethodHasExpectations) {\n  MockB b;\n  ASSERT_TRUE(Mock::VerifyAndClearExpectations(&b));\n\n  // There should be no expectations on the methods now, so we can\n  // freely call them.\n  EXPECT_EQ(0, b.DoB());\n  EXPECT_EQ(0, b.DoB(1));\n}\n\n// Tests that we can verify and clear a mock object's expectations\n// when some, but not all, of its methods have expectations *and* the\n// verification succeeds.\nTEST(VerifyAndClearExpectationsTest, SomeMethodsHaveExpectationsAndSucceed) {\n  MockB b;\n  EXPECT_CALL(b, DoB())\n      .WillOnce(Return(1));\n  b.DoB();\n  ASSERT_TRUE(Mock::VerifyAndClearExpectations(&b));\n\n  // There should be no expectations on the methods now, so we can\n  // freely call them.\n  EXPECT_EQ(0, b.DoB());\n  EXPECT_EQ(0, b.DoB(1));\n}\n\n// Tests that we can verify and clear a mock object's expectations\n// when some, but not all, of its methods have expectations *and* the\n// verification fails.\nTEST(VerifyAndClearExpectationsTest, SomeMethodsHaveExpectationsAndFail) {\n  MockB b;\n  EXPECT_CALL(b, DoB())\n      .WillOnce(Return(1));\n  bool result = true;\n  EXPECT_NONFATAL_FAILURE(result = Mock::VerifyAndClearExpectations(&b),\n                          \"Actual: never called\");\n  ASSERT_FALSE(result);\n\n  // There should be no expectations on the methods now, so we can\n  // freely call them.\n  EXPECT_EQ(0, b.DoB());\n  EXPECT_EQ(0, b.DoB(1));\n}\n\n// Tests that we can verify and clear a mock object's expectations\n// when all of its methods have expectations.\nTEST(VerifyAndClearExpectationsTest, AllMethodsHaveExpectations) {\n  MockB b;\n  EXPECT_CALL(b, DoB())\n      .WillOnce(Return(1));\n  EXPECT_CALL(b, DoB(_))\n      .WillOnce(Return(2));\n  b.DoB();\n  b.DoB(1);\n  ASSERT_TRUE(Mock::VerifyAndClearExpectations(&b));\n\n  // There should be no expectations on the methods now, so we can\n  // freely call them.\n  EXPECT_EQ(0, b.DoB());\n  EXPECT_EQ(0, b.DoB(1));\n}\n\n// Tests that we can verify and clear a mock object's expectations\n// when a method has more than one expectation.\nTEST(VerifyAndClearExpectationsTest, AMethodHasManyExpectations) {\n  MockB b;\n  EXPECT_CALL(b, DoB(0))\n      .WillOnce(Return(1));\n  EXPECT_CALL(b, DoB(_))\n      .WillOnce(Return(2));\n  b.DoB(1);\n  bool result = true;\n  EXPECT_NONFATAL_FAILURE(result = Mock::VerifyAndClearExpectations(&b),\n                          \"Actual: never called\");\n  ASSERT_FALSE(result);\n\n  // There should be no expectations on the methods now, so we can\n  // freely call them.\n  EXPECT_EQ(0, b.DoB());\n  EXPECT_EQ(0, b.DoB(1));\n}\n\n// Tests that we can call VerifyAndClearExpectations() on the same\n// mock object multiple times.\nTEST(VerifyAndClearExpectationsTest, CanCallManyTimes) {\n  MockB b;\n  EXPECT_CALL(b, DoB());\n  b.DoB();\n  Mock::VerifyAndClearExpectations(&b);\n\n  EXPECT_CALL(b, DoB(_))\n      .WillOnce(Return(1));\n  b.DoB(1);\n  Mock::VerifyAndClearExpectations(&b);\n  Mock::VerifyAndClearExpectations(&b);\n\n  // There should be no expectations on the methods now, so we can\n  // freely call them.\n  EXPECT_EQ(0, b.DoB());\n  EXPECT_EQ(0, b.DoB(1));\n}\n\n// Tests that we can clear a mock object's default actions when none\n// of its methods has default actions.\nTEST(VerifyAndClearTest, NoMethodHasDefaultActions) {\n  MockB b;\n  // If this crashes or generates a failure, the test will catch it.\n  Mock::VerifyAndClear(&b);\n  EXPECT_EQ(0, b.DoB());\n}\n\n// Tests that we can clear a mock object's default actions when some,\n// but not all of its methods have default actions.\nTEST(VerifyAndClearTest, SomeMethodsHaveDefaultActions) {\n  MockB b;\n  ON_CALL(b, DoB())\n      .WillByDefault(Return(1));\n\n  Mock::VerifyAndClear(&b);\n\n  // Verifies that the default action of int DoB() was removed.\n  EXPECT_EQ(0, b.DoB());\n}\n\n// Tests that we can clear a mock object's default actions when all of\n// its methods have default actions.\nTEST(VerifyAndClearTest, AllMethodsHaveDefaultActions) {\n  MockB b;\n  ON_CALL(b, DoB())\n      .WillByDefault(Return(1));\n  ON_CALL(b, DoB(_))\n      .WillByDefault(Return(2));\n\n  Mock::VerifyAndClear(&b);\n\n  // Verifies that the default action of int DoB() was removed.\n  EXPECT_EQ(0, b.DoB());\n\n  // Verifies that the default action of int DoB(int) was removed.\n  EXPECT_EQ(0, b.DoB(0));\n}\n\n// Tests that we can clear a mock object's default actions when a\n// method has more than one ON_CALL() set on it.\nTEST(VerifyAndClearTest, AMethodHasManyDefaultActions) {\n  MockB b;\n  ON_CALL(b, DoB(0))\n      .WillByDefault(Return(1));\n  ON_CALL(b, DoB(_))\n      .WillByDefault(Return(2));\n\n  Mock::VerifyAndClear(&b);\n\n  // Verifies that the default actions (there are two) of int DoB(int)\n  // were removed.\n  EXPECT_EQ(0, b.DoB(0));\n  EXPECT_EQ(0, b.DoB(1));\n}\n\n// Tests that we can call VerifyAndClear() on a mock object multiple\n// times.\nTEST(VerifyAndClearTest, CanCallManyTimes) {\n  MockB b;\n  ON_CALL(b, DoB())\n      .WillByDefault(Return(1));\n  Mock::VerifyAndClear(&b);\n  Mock::VerifyAndClear(&b);\n\n  ON_CALL(b, DoB(_))\n      .WillByDefault(Return(1));\n  Mock::VerifyAndClear(&b);\n\n  EXPECT_EQ(0, b.DoB());\n  EXPECT_EQ(0, b.DoB(1));\n}\n\n// Tests that VerifyAndClear() works when the verification succeeds.\nTEST(VerifyAndClearTest, Success) {\n  MockB b;\n  ON_CALL(b, DoB())\n      .WillByDefault(Return(1));\n  EXPECT_CALL(b, DoB(1))\n      .WillOnce(Return(2));\n\n  b.DoB();\n  b.DoB(1);\n  ASSERT_TRUE(Mock::VerifyAndClear(&b));\n\n  // There should be no expectations on the methods now, so we can\n  // freely call them.\n  EXPECT_EQ(0, b.DoB());\n  EXPECT_EQ(0, b.DoB(1));\n}\n\n// Tests that VerifyAndClear() works when the verification fails.\nTEST(VerifyAndClearTest, Failure) {\n  MockB b;\n  ON_CALL(b, DoB(_))\n      .WillByDefault(Return(1));\n  EXPECT_CALL(b, DoB())\n      .WillOnce(Return(2));\n\n  b.DoB(1);\n  bool result = true;\n  EXPECT_NONFATAL_FAILURE(result = Mock::VerifyAndClear(&b),\n                          \"Actual: never called\");\n  ASSERT_FALSE(result);\n\n  // There should be no expectations on the methods now, so we can\n  // freely call them.\n  EXPECT_EQ(0, b.DoB());\n  EXPECT_EQ(0, b.DoB(1));\n}\n\n// Tests that VerifyAndClear() works when the default actions and\n// expectations are set on a const mock object.\nTEST(VerifyAndClearTest, Const) {\n  MockB b;\n  ON_CALL(Const(b), DoB())\n      .WillByDefault(Return(1));\n\n  EXPECT_CALL(Const(b), DoB())\n      .WillOnce(DoDefault())\n      .WillOnce(Return(2));\n\n  b.DoB();\n  b.DoB();\n  ASSERT_TRUE(Mock::VerifyAndClear(&b));\n\n  // There should be no expectations on the methods now, so we can\n  // freely call them.\n  EXPECT_EQ(0, b.DoB());\n  EXPECT_EQ(0, b.DoB(1));\n}\n\n// Tests that we can set default actions and expectations on a mock\n// object after VerifyAndClear() has been called on it.\nTEST(VerifyAndClearTest, CanSetDefaultActionsAndExpectationsAfterwards) {\n  MockB b;\n  ON_CALL(b, DoB())\n      .WillByDefault(Return(1));\n  EXPECT_CALL(b, DoB(_))\n      .WillOnce(Return(2));\n  b.DoB(1);\n\n  Mock::VerifyAndClear(&b);\n\n  EXPECT_CALL(b, DoB())\n      .WillOnce(Return(3));\n  ON_CALL(b, DoB(_))\n      .WillByDefault(Return(4));\n\n  EXPECT_EQ(3, b.DoB());\n  EXPECT_EQ(4, b.DoB(1));\n}\n\n// Tests that calling VerifyAndClear() on one mock object does not\n// affect other mock objects (either of the same type or not).\nTEST(VerifyAndClearTest, DoesNotAffectOtherMockObjects) {\n  MockA a;\n  MockB b1;\n  MockB b2;\n\n  ON_CALL(a, Binary(_, _))\n      .WillByDefault(Return(true));\n  EXPECT_CALL(a, Binary(_, _))\n      .WillOnce(DoDefault())\n      .WillOnce(Return(false));\n\n  ON_CALL(b1, DoB())\n      .WillByDefault(Return(1));\n  EXPECT_CALL(b1, DoB(_))\n      .WillOnce(Return(2));\n\n  ON_CALL(b2, DoB())\n      .WillByDefault(Return(3));\n  EXPECT_CALL(b2, DoB(_));\n\n  b2.DoB(0);\n  Mock::VerifyAndClear(&b2);\n\n  // Verifies that the default actions and expectations of a and b1\n  // are still in effect.\n  EXPECT_TRUE(a.Binary(0, 0));\n  EXPECT_FALSE(a.Binary(0, 0));\n\n  EXPECT_EQ(1, b1.DoB());\n  EXPECT_EQ(2, b1.DoB(0));\n}\n\nTEST(VerifyAndClearTest,\n     DestroyingChainedMocksDoesNotDeadlockThroughExpectations) {\n  linked_ptr<MockA> a(new MockA);\n  ReferenceHoldingMock test_mock;\n\n  // EXPECT_CALL stores a reference to a inside test_mock.\n  EXPECT_CALL(test_mock, AcceptReference(_))\n      .WillRepeatedly(SetArgPointee<0>(a));\n\n  // Throw away the reference to the mock that we have in a. After this, the\n  // only reference to it is stored by test_mock.\n  a.reset();\n\n  // When test_mock goes out of scope, it destroys the last remaining reference\n  // to the mock object originally pointed to by a. This will cause the MockA\n  // destructor to be called from inside the ReferenceHoldingMock destructor.\n  // The state of all mocks is protected by a single global lock, but there\n  // should be no deadlock.\n}\n\nTEST(VerifyAndClearTest,\n     DestroyingChainedMocksDoesNotDeadlockThroughDefaultAction) {\n  linked_ptr<MockA> a(new MockA);\n  ReferenceHoldingMock test_mock;\n\n  // ON_CALL stores a reference to a inside test_mock.\n  ON_CALL(test_mock, AcceptReference(_))\n      .WillByDefault(SetArgPointee<0>(a));\n\n  // Throw away the reference to the mock that we have in a. After this, the\n  // only reference to it is stored by test_mock.\n  a.reset();\n\n  // When test_mock goes out of scope, it destroys the last remaining reference\n  // to the mock object originally pointed to by a. This will cause the MockA\n  // destructor to be called from inside the ReferenceHoldingMock destructor.\n  // The state of all mocks is protected by a single global lock, but there\n  // should be no deadlock.\n}\n\n// Tests that a mock function's action can call a mock function\n// (either the same function or a different one) either as an explicit\n// action or as a default action without causing a dead lock.  It\n// verifies that the action is not performed inside the critical\n// section.\nTEST(SynchronizationTest, CanCallMockMethodInAction) {\n  MockA a;\n  MockC c;\n  ON_CALL(a, DoA(_))\n      .WillByDefault(IgnoreResult(InvokeWithoutArgs(&c,\n                                                    &MockC::NonVoidMethod)));\n  EXPECT_CALL(a, DoA(1));\n  EXPECT_CALL(a, DoA(1))\n      .WillOnce(Invoke(&a, &MockA::DoA))\n      .RetiresOnSaturation();\n  EXPECT_CALL(c, NonVoidMethod());\n\n  a.DoA(1);\n  // This will match the second EXPECT_CALL() and trigger another a.DoA(1),\n  // which will in turn match the first EXPECT_CALL() and trigger a call to\n  // c.NonVoidMethod() that was specified by the ON_CALL() since the first\n  // EXPECT_CALL() did not specify an action.\n}\n\n}  // namespace\n\n// Allows the user to define his own main and then invoke gmock_main\n// from it. This might be necessary on some platforms which require\n// specific setup and teardown.\n#if GMOCK_RENAME_MAIN\nint gmock_main(int argc, char **argv) {\n#else\nint main(int argc, char **argv) {\n#endif  // GMOCK_RENAME_MAIN\n  testing::InitGoogleMock(&argc, argv);\n\n  // Ensures that the tests pass no matter what value of\n  // --gmock_catch_leaked_mocks and --gmock_verbose the user specifies.\n  testing::GMOCK_FLAG(catch_leaked_mocks) = true;\n  testing::GMOCK_FLAG(verbose) = testing::internal::kWarningVerbosity;\n\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "ext/gmock/test/gmock_all_test.cc",
    "content": "// Copyright 2009, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// Tests for Google C++ Mocking Framework (Google Mock)\n//\n// Sometimes it's desirable to build most of Google Mock's own tests\n// by compiling a single file.  This file serves this purpose.\n#include \"test/gmock-actions_test.cc\"\n#include \"test/gmock-cardinalities_test.cc\"\n#include \"test/gmock-generated-actions_test.cc\"\n#include \"test/gmock-generated-function-mockers_test.cc\"\n#include \"test/gmock-generated-internal-utils_test.cc\"\n#include \"test/gmock-generated-matchers_test.cc\"\n#include \"test/gmock-internal-utils_test.cc\"\n#include \"test/gmock-matchers_test.cc\"\n#include \"test/gmock-more-actions_test.cc\"\n#include \"test/gmock-nice-strict_test.cc\"\n#include \"test/gmock-port_test.cc\"\n#include \"test/gmock-spec-builders_test.cc\"\n#include \"test/gmock_test.cc\"\n"
  },
  {
    "path": "ext/gmock/test/gmock_ex_test.cc",
    "content": "// Copyright 2013, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Tests Google Mock's functionality that depends on exceptions.\n\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\nnamespace {\n\nusing testing::HasSubstr;\nusing testing::internal::GoogleTestFailureException;\n\n// A user-defined class.\nclass Something {};\n\nclass MockFoo {\n public:\n  // A mock method that returns a user-defined type.  Google Mock\n  // doesn't know what the default value for this type is.\n  MOCK_METHOD0(GetSomething, Something());\n};\n\n#if GTEST_HAS_EXCEPTIONS\n\nTEST(DefaultValueTest, ThrowsRuntimeErrorWhenNoDefaultValue) {\n  MockFoo mock;\n  try {\n    // No expectation is set on this method, so Google Mock must\n    // return the default value.  However, since Google Mock knows\n    // nothing about the return type, it doesn't know what to return,\n    // and has to throw (when exceptions are enabled) or abort\n    // (otherwise).\n    mock.GetSomething();\n    FAIL() << \"GetSomething()'s return type has no default value, \"\n           << \"so Google Mock should have thrown.\";\n  } catch (const GoogleTestFailureException& /* unused */) {\n    FAIL() << \"Google Test does not try to catch an exception of type \"\n           << \"GoogleTestFailureException, which is used for reporting \"\n           << \"a failure to other testing frameworks.  Google Mock should \"\n           << \"not throw a GoogleTestFailureException as it will kill the \"\n           << \"entire test program instead of just the current TEST.\";\n  } catch (const std::exception& ex) {\n    EXPECT_THAT(ex.what(), HasSubstr(\"has no default value\"));\n  }\n}\n\n#endif\n\n}  // unnamed namespace\n"
  },
  {
    "path": "ext/gmock/test/gmock_leak_test.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2009, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Tests that leaked mock objects can be caught be Google Mock.\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\n\nimport gmock_test_utils\n\n\nPROGRAM_PATH = gmock_test_utils.GetTestExecutablePath('gmock_leak_test_')\nTEST_WITH_EXPECT_CALL = [PROGRAM_PATH, '--gtest_filter=*ExpectCall*']\nTEST_WITH_ON_CALL = [PROGRAM_PATH, '--gtest_filter=*OnCall*']\nTEST_MULTIPLE_LEAKS = [PROGRAM_PATH, '--gtest_filter=*MultipleLeaked*']\n\nenviron = gmock_test_utils.environ\nSetEnvVar = gmock_test_utils.SetEnvVar\n\n# Tests in this file run a Google-Test-based test program and expect it\n# to terminate prematurely.  Therefore they are incompatible with\n# the premature-exit-file protocol by design.  Unset the\n# premature-exit filepath to prevent Google Test from creating\n# the file.\nSetEnvVar(gmock_test_utils.PREMATURE_EXIT_FILE_ENV_VAR, None)\n\n\nclass GMockLeakTest(gmock_test_utils.TestCase):\n\n  def testCatchesLeakedMockByDefault(self):\n    self.assertNotEqual(\n        0,\n        gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL,\n                                    env=environ).exit_code)\n    self.assertNotEqual(\n        0,\n        gmock_test_utils.Subprocess(TEST_WITH_ON_CALL,\n                                    env=environ).exit_code)\n\n  def testDoesNotCatchLeakedMockWhenDisabled(self):\n    self.assertEquals(\n        0,\n        gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL +\n                                    ['--gmock_catch_leaked_mocks=0'],\n                                    env=environ).exit_code)\n    self.assertEquals(\n        0,\n        gmock_test_utils.Subprocess(TEST_WITH_ON_CALL +\n                                    ['--gmock_catch_leaked_mocks=0'],\n                                    env=environ).exit_code)\n\n  def testCatchesLeakedMockWhenEnabled(self):\n    self.assertNotEqual(\n        0,\n        gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL +\n                                    ['--gmock_catch_leaked_mocks'],\n                                    env=environ).exit_code)\n    self.assertNotEqual(\n        0,\n        gmock_test_utils.Subprocess(TEST_WITH_ON_CALL +\n                                    ['--gmock_catch_leaked_mocks'],\n                                    env=environ).exit_code)\n\n  def testCatchesLeakedMockWhenEnabledWithExplictFlagValue(self):\n    self.assertNotEqual(\n        0,\n        gmock_test_utils.Subprocess(TEST_WITH_EXPECT_CALL +\n                                    ['--gmock_catch_leaked_mocks=1'],\n                                    env=environ).exit_code)\n\n  def testCatchesMultipleLeakedMocks(self):\n    self.assertNotEqual(\n        0,\n        gmock_test_utils.Subprocess(TEST_MULTIPLE_LEAKS +\n                                    ['--gmock_catch_leaked_mocks'],\n                                    env=environ).exit_code)\n\n\nif __name__ == '__main__':\n  gmock_test_utils.Main()\n"
  },
  {
    "path": "ext/gmock/test/gmock_leak_test_.cc",
    "content": "// Copyright 2009, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This program is for verifying that a leaked mock object can be\n// caught by Google Mock's leak detector.\n\n#include \"gmock/gmock.h\"\n\nnamespace {\n\nusing ::testing::Return;\n\nclass FooInterface {\n public:\n  virtual ~FooInterface() {}\n  virtual void DoThis() = 0;\n};\n\nclass MockFoo : public FooInterface {\n public:\n  MockFoo() {}\n\n  MOCK_METHOD0(DoThis, void());\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo);\n};\n\nTEST(LeakTest, LeakedMockWithExpectCallCausesFailureWhenLeakCheckingIsEnabled) {\n  MockFoo* foo = new MockFoo;\n\n  EXPECT_CALL(*foo, DoThis());\n  foo->DoThis();\n\n  // In order to test the leak detector, we deliberately leak foo.\n\n  // Makes sure Google Mock's leak detector can change the exit code\n  // to 1 even when the code is already exiting with 0.\n  exit(0);\n}\n\nTEST(LeakTest, LeakedMockWithOnCallCausesFailureWhenLeakCheckingIsEnabled) {\n  MockFoo* foo = new MockFoo;\n\n  ON_CALL(*foo, DoThis()).WillByDefault(Return());\n\n  // In order to test the leak detector, we deliberately leak foo.\n\n  // Makes sure Google Mock's leak detector can change the exit code\n  // to 1 even when the code is already exiting with 0.\n  exit(0);\n}\n\nTEST(LeakTest, CatchesMultipleLeakedMockObjects) {\n  MockFoo* foo1 = new MockFoo;\n  MockFoo* foo2 = new MockFoo;\n\n  ON_CALL(*foo1, DoThis()).WillByDefault(Return());\n  EXPECT_CALL(*foo2, DoThis());\n  foo2->DoThis();\n\n  // In order to test the leak detector, we deliberately leak foo1 and\n  // foo2.\n\n  // Makes sure Google Mock's leak detector can change the exit code\n  // to 1 even when the code is already exiting with 0.\n  exit(0);\n}\n\n}  // namespace\n"
  },
  {
    "path": "ext/gmock/test/gmock_link2_test.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan), vladl@google.com (Vlad Losev)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file is for verifying that various Google Mock constructs do not\n// produce linker errors when instantiated in different translation units.\n// Please see gmock_link_test.h for details.\n\n#define LinkTest LinkTest2\n\n#include  \"test/gmock_link_test.h\"\n"
  },
  {
    "path": "ext/gmock/test/gmock_link_test.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan), vladl@google.com (Vlad Losev)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file is for verifying that various Google Mock constructs do not\n// produce linker errors when instantiated in different translation units.\n// Please see gmock_link_test.h for details.\n\n#define LinkTest LinkTest1\n\n#include  \"test/gmock_link_test.h\"\n"
  },
  {
    "path": "ext/gmock/test/gmock_link_test.h",
    "content": "// Copyright 2009, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file tests that:\n// a. A header file defining a mock class can be included in multiple\n//    translation units without causing a link error.\n// b. Actions and matchers can be instantiated with identical template\n//    arguments in different translation units without causing link\n//    errors.\n//    The following constructs are currently tested:\n//    Actions:\n//      Return()\n//      Return(value)\n//      ReturnNull\n//      ReturnRef\n//      Assign\n//      SetArgPointee\n//      SetArrayArgument\n//      SetErrnoAndReturn\n//      Invoke(function)\n//      Invoke(object, method)\n//      InvokeWithoutArgs(function)\n//      InvokeWithoutArgs(object, method)\n//      InvokeArgument\n//      WithArg\n//      WithArgs\n//      WithoutArgs\n//      DoAll\n//      DoDefault\n//      IgnoreResult\n//      Throw\n//      ACTION()-generated\n//      ACTION_P()-generated\n//      ACTION_P2()-generated\n//    Matchers:\n//      _\n//      A\n//      An\n//      Eq\n//      Gt, Lt, Ge, Le, Ne\n//      NotNull\n//      Ref\n//      TypedEq\n//      DoubleEq\n//      FloatEq\n//      NanSensitiveDoubleEq\n//      NanSensitiveFloatEq\n//      ContainsRegex\n//      MatchesRegex\n//      EndsWith\n//      HasSubstr\n//      StartsWith\n//      StrCaseEq\n//      StrCaseNe\n//      StrEq\n//      StrNe\n//      ElementsAre\n//      ElementsAreArray\n//      ContainerEq\n//      Field\n//      Property\n//      ResultOf(function)\n//      Pointee\n//      Truly(predicate)\n//      AllOf\n//      AnyOf\n//      Not\n//      MatcherCast<T>\n//\n//  Please note: this test does not verify the functioning of these\n//  constructs, only that the programs using them will link successfully.\n//\n// Implementation note:\n// This test requires identical definitions of Interface and Mock to be\n// included in different translation units.  We achieve this by writing\n// them in this header and #including it in gmock_link_test.cc and\n// gmock_link2_test.cc.  Because the symbols generated by the compiler for\n// those constructs must be identical in both translation units,\n// definitions of Interface and Mock tests MUST be kept in the SAME\n// NON-ANONYMOUS namespace in this file.  The test fixture class LinkTest\n// is defined as LinkTest1 in gmock_link_test.cc and as LinkTest2 in\n// gmock_link2_test.cc to avoid producing linker errors.\n\n#ifndef GMOCK_TEST_GMOCK_LINK_TEST_H_\n#define GMOCK_TEST_GMOCK_LINK_TEST_H_\n\n#include \"gmock/gmock.h\"\n\n#if !GTEST_OS_WINDOWS_MOBILE\n# include <errno.h>\n#endif\n\n#include \"gmock/internal/gmock-port.h\"\n#include \"gtest/gtest.h\"\n#include <iostream>\n#include <vector>\n\nusing testing::_;\nusing testing::A;\nusing testing::AllOf;\nusing testing::AnyOf;\nusing testing::Assign;\nusing testing::ContainerEq;\nusing testing::DoAll;\nusing testing::DoDefault;\nusing testing::DoubleEq;\nusing testing::ElementsAre;\nusing testing::ElementsAreArray;\nusing testing::EndsWith;\nusing testing::Eq;\nusing testing::Field;\nusing testing::FloatEq;\nusing testing::Ge;\nusing testing::Gt;\nusing testing::HasSubstr;\nusing testing::IgnoreResult;\nusing testing::Invoke;\nusing testing::InvokeArgument;\nusing testing::InvokeWithoutArgs;\nusing testing::IsNull;\nusing testing::Le;\nusing testing::Lt;\nusing testing::Matcher;\nusing testing::MatcherCast;\nusing testing::NanSensitiveDoubleEq;\nusing testing::NanSensitiveFloatEq;\nusing testing::Ne;\nusing testing::Not;\nusing testing::NotNull;\nusing testing::Pointee;\nusing testing::Property;\nusing testing::Ref;\nusing testing::ResultOf;\nusing testing::Return;\nusing testing::ReturnNull;\nusing testing::ReturnRef;\nusing testing::SetArgPointee;\nusing testing::SetArrayArgument;\nusing testing::StartsWith;\nusing testing::StrCaseEq;\nusing testing::StrCaseNe;\nusing testing::StrEq;\nusing testing::StrNe;\nusing testing::Truly;\nusing testing::TypedEq;\nusing testing::WithArg;\nusing testing::WithArgs;\nusing testing::WithoutArgs;\n\n#if !GTEST_OS_WINDOWS_MOBILE\nusing testing::SetErrnoAndReturn;\n#endif\n\n#if GTEST_HAS_EXCEPTIONS\nusing testing::Throw;\n#endif\n\nusing testing::ContainsRegex;\nusing testing::MatchesRegex;\n\nclass Interface {\n public:\n  virtual ~Interface() {}\n  virtual void VoidFromString(char* str) = 0;\n  virtual char* StringFromString(char* str) = 0;\n  virtual int IntFromString(char* str) = 0;\n  virtual int& IntRefFromString(char* str) = 0;\n  virtual void VoidFromFunc(void(*func)(char* str)) = 0;\n  virtual void VoidFromIntRef(int& n) = 0;  // NOLINT\n  virtual void VoidFromFloat(float n) = 0;\n  virtual void VoidFromDouble(double n) = 0;\n  virtual void VoidFromVector(const std::vector<int>& v) = 0;\n};\n\nclass Mock: public Interface {\n public:\n  Mock() {}\n\n  MOCK_METHOD1(VoidFromString, void(char* str));\n  MOCK_METHOD1(StringFromString, char*(char* str));\n  MOCK_METHOD1(IntFromString, int(char* str));\n  MOCK_METHOD1(IntRefFromString, int&(char* str));\n  MOCK_METHOD1(VoidFromFunc, void(void(*func)(char* str)));\n  MOCK_METHOD1(VoidFromIntRef, void(int& n));  // NOLINT\n  MOCK_METHOD1(VoidFromFloat, void(float n));\n  MOCK_METHOD1(VoidFromDouble, void(double n));\n  MOCK_METHOD1(VoidFromVector, void(const std::vector<int>& v));\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(Mock);\n};\n\nclass InvokeHelper {\n public:\n  static void StaticVoidFromVoid() {}\n  void VoidFromVoid() {}\n  static void StaticVoidFromString(char* /* str */) {}\n  void VoidFromString(char* /* str */) {}\n  static int StaticIntFromString(char* /* str */) { return 1; }\n  static bool StaticBoolFromString(const char* /* str */) { return true; }\n};\n\nclass FieldHelper {\n public:\n  explicit FieldHelper(int a_field) : field_(a_field) {}\n  int field() const { return field_; }\n  int field_;  // NOLINT -- need external access to field_ to test\n               //           the Field matcher.\n};\n\n// Tests the linkage of the ReturnVoid action.\nTEST(LinkTest, TestReturnVoid) {\n  Mock mock;\n\n  EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Return());\n  mock.VoidFromString(NULL);\n}\n\n// Tests the linkage of the Return action.\nTEST(LinkTest, TestReturn) {\n  Mock mock;\n  char ch = 'x';\n\n  EXPECT_CALL(mock, StringFromString(_)).WillOnce(Return(&ch));\n  mock.StringFromString(NULL);\n}\n\n// Tests the linkage of the ReturnNull action.\nTEST(LinkTest, TestReturnNull) {\n  Mock mock;\n\n  EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Return());\n  mock.VoidFromString(NULL);\n}\n\n// Tests the linkage of the ReturnRef action.\nTEST(LinkTest, TestReturnRef) {\n  Mock mock;\n  int n = 42;\n\n  EXPECT_CALL(mock, IntRefFromString(_)).WillOnce(ReturnRef(n));\n  mock.IntRefFromString(NULL);\n}\n\n// Tests the linkage of the Assign action.\nTEST(LinkTest, TestAssign) {\n  Mock mock;\n  char ch = 'x';\n\n  EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Assign(&ch, 'y'));\n  mock.VoidFromString(NULL);\n}\n\n// Tests the linkage of the SetArgPointee action.\nTEST(LinkTest, TestSetArgPointee) {\n  Mock mock;\n  char ch = 'x';\n\n  EXPECT_CALL(mock, VoidFromString(_)).WillOnce(SetArgPointee<0>('y'));\n  mock.VoidFromString(&ch);\n}\n\n// Tests the linkage of the SetArrayArgument action.\nTEST(LinkTest, TestSetArrayArgument) {\n  Mock mock;\n  char ch = 'x';\n  char ch2 = 'y';\n\n  EXPECT_CALL(mock, VoidFromString(_)).WillOnce(SetArrayArgument<0>(&ch2,\n                                                                    &ch2 + 1));\n  mock.VoidFromString(&ch);\n}\n\n#if !GTEST_OS_WINDOWS_MOBILE\n\n// Tests the linkage of the SetErrnoAndReturn action.\nTEST(LinkTest, TestSetErrnoAndReturn) {\n  Mock mock;\n\n  int saved_errno = errno;\n  EXPECT_CALL(mock, IntFromString(_)).WillOnce(SetErrnoAndReturn(1, -1));\n  mock.IntFromString(NULL);\n  errno = saved_errno;\n}\n\n#endif  // !GTEST_OS_WINDOWS_MOBILE\n\n// Tests the linkage of the Invoke(function) and Invoke(object, method) actions.\nTEST(LinkTest, TestInvoke) {\n  Mock mock;\n  InvokeHelper test_invoke_helper;\n\n  EXPECT_CALL(mock, VoidFromString(_))\n      .WillOnce(Invoke(&InvokeHelper::StaticVoidFromString))\n      .WillOnce(Invoke(&test_invoke_helper, &InvokeHelper::VoidFromString));\n  mock.VoidFromString(NULL);\n  mock.VoidFromString(NULL);\n}\n\n// Tests the linkage of the InvokeWithoutArgs action.\nTEST(LinkTest, TestInvokeWithoutArgs) {\n  Mock mock;\n  InvokeHelper test_invoke_helper;\n\n  EXPECT_CALL(mock, VoidFromString(_))\n      .WillOnce(InvokeWithoutArgs(&InvokeHelper::StaticVoidFromVoid))\n      .WillOnce(InvokeWithoutArgs(&test_invoke_helper,\n                                  &InvokeHelper::VoidFromVoid));\n  mock.VoidFromString(NULL);\n  mock.VoidFromString(NULL);\n}\n\n// Tests the linkage of the InvokeArgument action.\nTEST(LinkTest, TestInvokeArgument) {\n  Mock mock;\n  char ch = 'x';\n\n  EXPECT_CALL(mock, VoidFromFunc(_)).WillOnce(InvokeArgument<0>(&ch));\n  mock.VoidFromFunc(InvokeHelper::StaticVoidFromString);\n}\n\n// Tests the linkage of the WithArg action.\nTEST(LinkTest, TestWithArg) {\n  Mock mock;\n\n  EXPECT_CALL(mock, VoidFromString(_))\n      .WillOnce(WithArg<0>(Invoke(&InvokeHelper::StaticVoidFromString)));\n  mock.VoidFromString(NULL);\n}\n\n// Tests the linkage of the WithArgs action.\nTEST(LinkTest, TestWithArgs) {\n  Mock mock;\n\n  EXPECT_CALL(mock, VoidFromString(_))\n      .WillOnce(WithArgs<0>(Invoke(&InvokeHelper::StaticVoidFromString)));\n  mock.VoidFromString(NULL);\n}\n\n// Tests the linkage of the WithoutArgs action.\nTEST(LinkTest, TestWithoutArgs) {\n  Mock mock;\n\n  EXPECT_CALL(mock, VoidFromString(_)).WillOnce(WithoutArgs(Return()));\n  mock.VoidFromString(NULL);\n}\n\n// Tests the linkage of the DoAll action.\nTEST(LinkTest, TestDoAll) {\n  Mock mock;\n  char ch = 'x';\n\n  EXPECT_CALL(mock, VoidFromString(_))\n      .WillOnce(DoAll(SetArgPointee<0>('y'), Return()));\n  mock.VoidFromString(&ch);\n}\n\n// Tests the linkage of the DoDefault action.\nTEST(LinkTest, TestDoDefault) {\n  Mock mock;\n  char ch = 'x';\n\n  ON_CALL(mock, VoidFromString(_)).WillByDefault(Return());\n  EXPECT_CALL(mock, VoidFromString(_)).WillOnce(DoDefault());\n  mock.VoidFromString(&ch);\n}\n\n// Tests the linkage of the IgnoreResult action.\nTEST(LinkTest, TestIgnoreResult) {\n  Mock mock;\n\n  EXPECT_CALL(mock, VoidFromString(_)).WillOnce(IgnoreResult(Return(42)));\n  mock.VoidFromString(NULL);\n}\n\n#if GTEST_HAS_EXCEPTIONS\n// Tests the linkage of the Throw action.\nTEST(LinkTest, TestThrow) {\n  Mock mock;\n\n  EXPECT_CALL(mock, VoidFromString(_)).WillOnce(Throw(42));\n  EXPECT_THROW(mock.VoidFromString(NULL), int);\n}\n#endif  // GTEST_HAS_EXCEPTIONS\n\n// The ACTION*() macros trigger warning C4100 (unreferenced formal\n// parameter) in MSVC with -W4.  Unfortunately they cannot be fixed in\n// the macro definition, as the warnings are generated when the macro\n// is expanded and macro expansion cannot contain #pragma.  Therefore\n// we suppress them here.\n#ifdef _MSC_VER\n# pragma warning(push)\n# pragma warning(disable:4100)\n#endif\n\n// Tests the linkage of actions created using ACTION macro.\nnamespace {\nACTION(Return1) { return 1; }\n}\n\nTEST(LinkTest, TestActionMacro) {\n  Mock mock;\n\n  EXPECT_CALL(mock, IntFromString(_)).WillOnce(Return1());\n  mock.IntFromString(NULL);\n}\n\n// Tests the linkage of actions created using ACTION_P macro.\nnamespace {\nACTION_P(ReturnArgument, ret_value) { return ret_value; }\n}\n\nTEST(LinkTest, TestActionPMacro) {\n  Mock mock;\n\n  EXPECT_CALL(mock, IntFromString(_)).WillOnce(ReturnArgument(42));\n  mock.IntFromString(NULL);\n}\n\n// Tests the linkage of actions created using ACTION_P2 macro.\nnamespace {\nACTION_P2(ReturnEqualsEitherOf, first, second) {\n  return arg0 == first || arg0 == second;\n}\n}\n\n#ifdef _MSC_VER\n# pragma warning(pop)\n#endif\n\nTEST(LinkTest, TestActionP2Macro) {\n  Mock mock;\n  char ch = 'x';\n\n  EXPECT_CALL(mock, IntFromString(_))\n      .WillOnce(ReturnEqualsEitherOf(\"one\", \"two\"));\n  mock.IntFromString(&ch);\n}\n\n// Tests the linkage of the \"_\" matcher.\nTEST(LinkTest, TestMatcherAnything) {\n  Mock mock;\n\n  ON_CALL(mock, VoidFromString(_)).WillByDefault(Return());\n}\n\n// Tests the linkage of the A matcher.\nTEST(LinkTest, TestMatcherA) {\n  Mock mock;\n\n  ON_CALL(mock, VoidFromString(A<char*>())).WillByDefault(Return());\n}\n\n// Tests the linkage of the Eq and the \"bare value\" matcher.\nTEST(LinkTest, TestMatchersEq) {\n  Mock mock;\n  const char* p = \"x\";\n\n  ON_CALL(mock, VoidFromString(Eq(p))).WillByDefault(Return());\n  ON_CALL(mock, VoidFromString(const_cast<char*>(\"y\")))\n      .WillByDefault(Return());\n}\n\n// Tests the linkage of the Lt, Gt, Le, Ge, and Ne matchers.\nTEST(LinkTest, TestMatchersRelations) {\n  Mock mock;\n\n  ON_CALL(mock, VoidFromFloat(Lt(1.0f))).WillByDefault(Return());\n  ON_CALL(mock, VoidFromFloat(Gt(1.0f))).WillByDefault(Return());\n  ON_CALL(mock, VoidFromFloat(Le(1.0f))).WillByDefault(Return());\n  ON_CALL(mock, VoidFromFloat(Ge(1.0f))).WillByDefault(Return());\n  ON_CALL(mock, VoidFromFloat(Ne(1.0f))).WillByDefault(Return());\n}\n\n// Tests the linkage of the NotNull matcher.\nTEST(LinkTest, TestMatcherNotNull) {\n  Mock mock;\n\n  ON_CALL(mock, VoidFromString(NotNull())).WillByDefault(Return());\n}\n\n// Tests the linkage of the IsNull matcher.\nTEST(LinkTest, TestMatcherIsNull) {\n  Mock mock;\n\n  ON_CALL(mock, VoidFromString(IsNull())).WillByDefault(Return());\n}\n\n// Tests the linkage of the Ref matcher.\nTEST(LinkTest, TestMatcherRef) {\n  Mock mock;\n  int a = 0;\n\n  ON_CALL(mock, VoidFromIntRef(Ref(a))).WillByDefault(Return());\n}\n\n// Tests the linkage of the TypedEq matcher.\nTEST(LinkTest, TestMatcherTypedEq) {\n  Mock mock;\n  long a = 0;\n\n  ON_CALL(mock, VoidFromIntRef(TypedEq<int&>(a))).WillByDefault(Return());\n}\n\n// Tests the linkage of the FloatEq, DoubleEq, NanSensitiveFloatEq and\n// NanSensitiveDoubleEq matchers.\nTEST(LinkTest, TestMatchersFloatingPoint) {\n  Mock mock;\n  float a = 0;\n\n  ON_CALL(mock, VoidFromFloat(FloatEq(a))).WillByDefault(Return());\n  ON_CALL(mock, VoidFromDouble(DoubleEq(a))).WillByDefault(Return());\n  ON_CALL(mock, VoidFromFloat(NanSensitiveFloatEq(a))).WillByDefault(Return());\n  ON_CALL(mock, VoidFromDouble(NanSensitiveDoubleEq(a)))\n      .WillByDefault(Return());\n}\n\n// Tests the linkage of the ContainsRegex matcher.\nTEST(LinkTest, TestMatcherContainsRegex) {\n  Mock mock;\n\n  ON_CALL(mock, VoidFromString(ContainsRegex(\".*\"))).WillByDefault(Return());\n}\n\n// Tests the linkage of the MatchesRegex matcher.\nTEST(LinkTest, TestMatcherMatchesRegex) {\n  Mock mock;\n\n  ON_CALL(mock, VoidFromString(MatchesRegex(\".*\"))).WillByDefault(Return());\n}\n\n// Tests the linkage of the StartsWith, EndsWith, and HasSubstr matchers.\nTEST(LinkTest, TestMatchersSubstrings) {\n  Mock mock;\n\n  ON_CALL(mock, VoidFromString(StartsWith(\"a\"))).WillByDefault(Return());\n  ON_CALL(mock, VoidFromString(EndsWith(\"c\"))).WillByDefault(Return());\n  ON_CALL(mock, VoidFromString(HasSubstr(\"b\"))).WillByDefault(Return());\n}\n\n// Tests the linkage of the StrEq, StrNe, StrCaseEq, and StrCaseNe matchers.\nTEST(LinkTest, TestMatchersStringEquality) {\n  Mock mock;\n  ON_CALL(mock, VoidFromString(StrEq(\"a\"))).WillByDefault(Return());\n  ON_CALL(mock, VoidFromString(StrNe(\"a\"))).WillByDefault(Return());\n  ON_CALL(mock, VoidFromString(StrCaseEq(\"a\"))).WillByDefault(Return());\n  ON_CALL(mock, VoidFromString(StrCaseNe(\"a\"))).WillByDefault(Return());\n}\n\n// Tests the linkage of the ElementsAre matcher.\nTEST(LinkTest, TestMatcherElementsAre) {\n  Mock mock;\n\n  ON_CALL(mock, VoidFromVector(ElementsAre('a', _))).WillByDefault(Return());\n}\n\n// Tests the linkage of the ElementsAreArray matcher.\nTEST(LinkTest, TestMatcherElementsAreArray) {\n  Mock mock;\n  char arr[] = { 'a', 'b' };\n\n  ON_CALL(mock, VoidFromVector(ElementsAreArray(arr))).WillByDefault(Return());\n}\n\n// Tests the linkage of the ContainerEq matcher.\nTEST(LinkTest, TestMatcherContainerEq) {\n  Mock mock;\n  std::vector<int> v;\n\n  ON_CALL(mock, VoidFromVector(ContainerEq(v))).WillByDefault(Return());\n}\n\n// Tests the linkage of the Field matcher.\nTEST(LinkTest, TestMatcherField) {\n  FieldHelper helper(0);\n\n  Matcher<const FieldHelper&> m = Field(&FieldHelper::field_, Eq(0));\n  EXPECT_TRUE(m.Matches(helper));\n\n  Matcher<const FieldHelper*> m2 = Field(&FieldHelper::field_, Eq(0));\n  EXPECT_TRUE(m2.Matches(&helper));\n}\n\n// Tests the linkage of the Property matcher.\nTEST(LinkTest, TestMatcherProperty) {\n  FieldHelper helper(0);\n\n  Matcher<const FieldHelper&> m = Property(&FieldHelper::field, Eq(0));\n  EXPECT_TRUE(m.Matches(helper));\n\n  Matcher<const FieldHelper*> m2 = Property(&FieldHelper::field, Eq(0));\n  EXPECT_TRUE(m2.Matches(&helper));\n}\n\n// Tests the linkage of the ResultOf matcher.\nTEST(LinkTest, TestMatcherResultOf) {\n  Matcher<char*> m = ResultOf(&InvokeHelper::StaticIntFromString, Eq(1));\n  EXPECT_TRUE(m.Matches(NULL));\n}\n\n// Tests the linkage of the ResultOf matcher.\nTEST(LinkTest, TestMatcherPointee) {\n  int n = 1;\n\n  Matcher<int*> m = Pointee(Eq(1));\n  EXPECT_TRUE(m.Matches(&n));\n}\n\n// Tests the linkage of the Truly matcher.\nTEST(LinkTest, TestMatcherTruly) {\n  Matcher<const char*> m = Truly(&InvokeHelper::StaticBoolFromString);\n  EXPECT_TRUE(m.Matches(NULL));\n}\n\n// Tests the linkage of the AllOf matcher.\nTEST(LinkTest, TestMatcherAllOf) {\n  Matcher<int> m = AllOf(_, Eq(1));\n  EXPECT_TRUE(m.Matches(1));\n}\n\n// Tests the linkage of the AnyOf matcher.\nTEST(LinkTest, TestMatcherAnyOf) {\n  Matcher<int> m = AnyOf(_, Eq(1));\n  EXPECT_TRUE(m.Matches(1));\n}\n\n// Tests the linkage of the Not matcher.\nTEST(LinkTest, TestMatcherNot) {\n  Matcher<int> m = Not(_);\n  EXPECT_FALSE(m.Matches(1));\n}\n\n// Tests the linkage of the MatcherCast<T>() function.\nTEST(LinkTest, TestMatcherCast) {\n  Matcher<const char*> m = MatcherCast<const char*>(_);\n  EXPECT_TRUE(m.Matches(NULL));\n}\n\n#endif  // GMOCK_TEST_GMOCK_LINK_TEST_H_\n"
  },
  {
    "path": "ext/gmock/test/gmock_output_test.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2008, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Tests the text output of Google C++ Mocking Framework.\n\nSYNOPSIS\n       gmock_output_test.py --build_dir=BUILD/DIR --gengolden\n         # where BUILD/DIR contains the built gmock_output_test_ file.\n       gmock_output_test.py --gengolden\n       gmock_output_test.py\n\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport re\nimport sys\n\nimport gmock_test_utils\n\n\n# The flag for generating the golden file\nGENGOLDEN_FLAG = '--gengolden'\n\nPROGRAM_PATH = gmock_test_utils.GetTestExecutablePath('gmock_output_test_')\nCOMMAND = [PROGRAM_PATH, '--gtest_stack_trace_depth=0', '--gtest_print_time=0']\nGOLDEN_NAME = 'gmock_output_test_golden.txt'\nGOLDEN_PATH = os.path.join(gmock_test_utils.GetSourceDir(), GOLDEN_NAME)\n\n\ndef ToUnixLineEnding(s):\n  \"\"\"Changes all Windows/Mac line endings in s to UNIX line endings.\"\"\"\n\n  return s.replace('\\r\\n', '\\n').replace('\\r', '\\n')\n\n\ndef RemoveReportHeaderAndFooter(output):\n  \"\"\"Removes Google Test result report's header and footer from the output.\"\"\"\n\n  output = re.sub(r'.*gtest_main.*\\n', '', output)\n  output = re.sub(r'\\[.*\\d+ tests.*\\n', '', output)\n  output = re.sub(r'\\[.* test environment .*\\n', '', output)\n  output = re.sub(r'\\[=+\\] \\d+ tests .* ran.*', '', output)\n  output = re.sub(r'.* FAILED TESTS\\n', '', output)\n  return output\n\n\ndef RemoveLocations(output):\n  \"\"\"Removes all file location info from a Google Test program's output.\n\n  Args:\n       output:  the output of a Google Test program.\n\n  Returns:\n       output with all file location info (in the form of\n       'DIRECTORY/FILE_NAME:LINE_NUMBER: 'or\n       'DIRECTORY\\\\FILE_NAME(LINE_NUMBER): ') replaced by\n       'FILE:#: '.\n  \"\"\"\n\n  return re.sub(r'.*[/\\\\](.+)(\\:\\d+|\\(\\d+\\))\\:', 'FILE:#:', output)\n\n\ndef NormalizeErrorMarker(output):\n  \"\"\"Normalizes the error marker, which is different on Windows vs on Linux.\"\"\"\n\n  return re.sub(r' error: ', ' Failure\\n', output)\n\n\ndef RemoveMemoryAddresses(output):\n  \"\"\"Removes memory addresses from the test output.\"\"\"\n\n  return re.sub(r'@\\w+', '@0x#', output)\n\n\ndef RemoveTestNamesOfLeakedMocks(output):\n  \"\"\"Removes the test names of leaked mock objects from the test output.\"\"\"\n\n  return re.sub(r'\\(used in test .+\\) ', '', output)\n\n\ndef GetLeakyTests(output):\n  \"\"\"Returns a list of test names that leak mock objects.\"\"\"\n\n  # findall() returns a list of all matches of the regex in output.\n  # For example, if '(used in test FooTest.Bar)' is in output, the\n  # list will contain 'FooTest.Bar'.\n  return re.findall(r'\\(used in test (.+)\\)', output)\n\n\ndef GetNormalizedOutputAndLeakyTests(output):\n  \"\"\"Normalizes the output of gmock_output_test_.\n\n  Args:\n    output: The test output.\n\n  Returns:\n    A tuple (the normalized test output, the list of test names that have\n    leaked mocks).\n  \"\"\"\n\n  output = ToUnixLineEnding(output)\n  output = RemoveReportHeaderAndFooter(output)\n  output = NormalizeErrorMarker(output)\n  output = RemoveLocations(output)\n  output = RemoveMemoryAddresses(output)\n  return (RemoveTestNamesOfLeakedMocks(output), GetLeakyTests(output))\n\n\ndef GetShellCommandOutput(cmd):\n  \"\"\"Runs a command in a sub-process, and returns its STDOUT in a string.\"\"\"\n\n  return gmock_test_utils.Subprocess(cmd, capture_stderr=False).output\n\n\ndef GetNormalizedCommandOutputAndLeakyTests(cmd):\n  \"\"\"Runs a command and returns its normalized output and a list of leaky tests.\n\n  Args:\n    cmd:  the shell command.\n  \"\"\"\n\n  # Disables exception pop-ups on Windows.\n  os.environ['GTEST_CATCH_EXCEPTIONS'] = '1'\n  return GetNormalizedOutputAndLeakyTests(GetShellCommandOutput(cmd))\n\n\nclass GMockOutputTest(gmock_test_utils.TestCase):\n  def testOutput(self):\n    (output, leaky_tests) = GetNormalizedCommandOutputAndLeakyTests(COMMAND)\n    golden_file = open(GOLDEN_PATH, 'rb')\n    golden = golden_file.read()\n    golden_file.close()\n\n    # The normalized output should match the golden file.\n    self.assertEquals(golden, output)\n\n    # The raw output should contain 2 leaked mock object errors for\n    # test GMockOutputTest.CatchesLeakedMocks.\n    self.assertEquals(['GMockOutputTest.CatchesLeakedMocks',\n                       'GMockOutputTest.CatchesLeakedMocks'],\n                      leaky_tests)\n\n\nif __name__ == '__main__':\n  if sys.argv[1:] == [GENGOLDEN_FLAG]:\n    (output, _) = GetNormalizedCommandOutputAndLeakyTests(COMMAND)\n    golden_file = open(GOLDEN_PATH, 'wb')\n    golden_file.write(output)\n    golden_file.close()\n  else:\n    gmock_test_utils.Main()\n"
  },
  {
    "path": "ext/gmock/test/gmock_output_test_.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Tests Google Mock's output in various scenarios.  This ensures that\n// Google Mock's messages are readable and useful.\n\n#include \"gmock/gmock.h\"\n\n#include <stdio.h>\n#include <string>\n\n#include \"gtest/gtest.h\"\n\nusing testing::_;\nusing testing::AnyNumber;\nusing testing::Ge;\nusing testing::InSequence;\nusing testing::NaggyMock;\nusing testing::Ref;\nusing testing::Return;\nusing testing::Sequence;\n\nclass MockFoo {\n public:\n  MockFoo() {}\n\n  MOCK_METHOD3(Bar, char(const std::string& s, int i, double x));\n  MOCK_METHOD2(Bar2, bool(int x, int y));\n  MOCK_METHOD2(Bar3, void(int x, int y));\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(MockFoo);\n};\n\nclass GMockOutputTest : public testing::Test {\n protected:\n  NaggyMock<MockFoo> foo_;\n};\n\nTEST_F(GMockOutputTest, ExpectedCall) {\n  testing::GMOCK_FLAG(verbose) = \"info\";\n\n  EXPECT_CALL(foo_, Bar2(0, _));\n  foo_.Bar2(0, 0);  // Expected call\n\n  testing::GMOCK_FLAG(verbose) = \"warning\";\n}\n\nTEST_F(GMockOutputTest, ExpectedCallToVoidFunction) {\n  testing::GMOCK_FLAG(verbose) = \"info\";\n\n  EXPECT_CALL(foo_, Bar3(0, _));\n  foo_.Bar3(0, 0);  // Expected call\n\n  testing::GMOCK_FLAG(verbose) = \"warning\";\n}\n\nTEST_F(GMockOutputTest, ExplicitActionsRunOut) {\n  EXPECT_CALL(foo_, Bar2(_, _))\n      .Times(2)\n      .WillOnce(Return(false));\n  foo_.Bar2(2, 2);\n  foo_.Bar2(1, 1);  // Explicit actions in EXPECT_CALL run out.\n}\n\nTEST_F(GMockOutputTest, UnexpectedCall) {\n  EXPECT_CALL(foo_, Bar2(0, _));\n\n  foo_.Bar2(1, 0);  // Unexpected call\n  foo_.Bar2(0, 0);  // Expected call\n}\n\nTEST_F(GMockOutputTest, UnexpectedCallToVoidFunction) {\n  EXPECT_CALL(foo_, Bar3(0, _));\n\n  foo_.Bar3(1, 0);  // Unexpected call\n  foo_.Bar3(0, 0);  // Expected call\n}\n\nTEST_F(GMockOutputTest, ExcessiveCall) {\n  EXPECT_CALL(foo_, Bar2(0, _));\n\n  foo_.Bar2(0, 0);  // Expected call\n  foo_.Bar2(0, 1);  // Excessive call\n}\n\nTEST_F(GMockOutputTest, ExcessiveCallToVoidFunction) {\n  EXPECT_CALL(foo_, Bar3(0, _));\n\n  foo_.Bar3(0, 0);  // Expected call\n  foo_.Bar3(0, 1);  // Excessive call\n}\n\nTEST_F(GMockOutputTest, UninterestingCall) {\n  foo_.Bar2(0, 1);  // Uninteresting call\n}\n\nTEST_F(GMockOutputTest, UninterestingCallToVoidFunction) {\n  foo_.Bar3(0, 1);  // Uninteresting call\n}\n\nTEST_F(GMockOutputTest, RetiredExpectation) {\n  EXPECT_CALL(foo_, Bar2(_, _))\n      .RetiresOnSaturation();\n  EXPECT_CALL(foo_, Bar2(0, 0));\n\n  foo_.Bar2(1, 1);\n  foo_.Bar2(1, 1);  // Matches a retired expectation\n  foo_.Bar2(0, 0);\n}\n\nTEST_F(GMockOutputTest, UnsatisfiedPrerequisite) {\n  {\n    InSequence s;\n    EXPECT_CALL(foo_, Bar(_, 0, _));\n    EXPECT_CALL(foo_, Bar2(0, 0));\n    EXPECT_CALL(foo_, Bar2(1, _));\n  }\n\n  foo_.Bar2(1, 0);  // Has one immediate unsatisfied pre-requisite\n  foo_.Bar(\"Hi\", 0, 0);\n  foo_.Bar2(0, 0);\n  foo_.Bar2(1, 0);\n}\n\nTEST_F(GMockOutputTest, UnsatisfiedPrerequisites) {\n  Sequence s1, s2;\n\n  EXPECT_CALL(foo_, Bar(_, 0, _))\n      .InSequence(s1);\n  EXPECT_CALL(foo_, Bar2(0, 0))\n      .InSequence(s2);\n  EXPECT_CALL(foo_, Bar2(1, _))\n      .InSequence(s1, s2);\n\n  foo_.Bar2(1, 0);  // Has two immediate unsatisfied pre-requisites\n  foo_.Bar(\"Hi\", 0, 0);\n  foo_.Bar2(0, 0);\n  foo_.Bar2(1, 0);\n}\n\nTEST_F(GMockOutputTest, UnsatisfiedWith) {\n  EXPECT_CALL(foo_, Bar2(_, _)).With(Ge());\n}\n\nTEST_F(GMockOutputTest, UnsatisfiedExpectation) {\n  EXPECT_CALL(foo_, Bar(_, _, _));\n  EXPECT_CALL(foo_, Bar2(0, _))\n      .Times(2);\n\n  foo_.Bar2(0, 1);\n}\n\nTEST_F(GMockOutputTest, MismatchArguments) {\n  const std::string s = \"Hi\";\n  EXPECT_CALL(foo_, Bar(Ref(s), _, Ge(0)));\n\n  foo_.Bar(\"Ho\", 0, -0.1);  // Mismatch arguments\n  foo_.Bar(s, 0, 0);\n}\n\nTEST_F(GMockOutputTest, MismatchWith) {\n  EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1)))\n      .With(Ge());\n\n  foo_.Bar2(2, 3);  // Mismatch With()\n  foo_.Bar2(2, 1);\n}\n\nTEST_F(GMockOutputTest, MismatchArgumentsAndWith) {\n  EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1)))\n      .With(Ge());\n\n  foo_.Bar2(1, 3);  // Mismatch arguments and mismatch With()\n  foo_.Bar2(2, 1);\n}\n\nTEST_F(GMockOutputTest, UnexpectedCallWithDefaultAction) {\n  ON_CALL(foo_, Bar2(_, _))\n      .WillByDefault(Return(true));   // Default action #1\n  ON_CALL(foo_, Bar2(1, _))\n      .WillByDefault(Return(false));  // Default action #2\n\n  EXPECT_CALL(foo_, Bar2(2, 2));\n  foo_.Bar2(1, 0);  // Unexpected call, takes default action #2.\n  foo_.Bar2(0, 0);  // Unexpected call, takes default action #1.\n  foo_.Bar2(2, 2);  // Expected call.\n}\n\nTEST_F(GMockOutputTest, ExcessiveCallWithDefaultAction) {\n  ON_CALL(foo_, Bar2(_, _))\n      .WillByDefault(Return(true));   // Default action #1\n  ON_CALL(foo_, Bar2(1, _))\n      .WillByDefault(Return(false));  // Default action #2\n\n  EXPECT_CALL(foo_, Bar2(2, 2));\n  EXPECT_CALL(foo_, Bar2(1, 1));\n\n  foo_.Bar2(2, 2);  // Expected call.\n  foo_.Bar2(2, 2);  // Excessive call, takes default action #1.\n  foo_.Bar2(1, 1);  // Expected call.\n  foo_.Bar2(1, 1);  // Excessive call, takes default action #2.\n}\n\nTEST_F(GMockOutputTest, UninterestingCallWithDefaultAction) {\n  ON_CALL(foo_, Bar2(_, _))\n      .WillByDefault(Return(true));   // Default action #1\n  ON_CALL(foo_, Bar2(1, _))\n      .WillByDefault(Return(false));  // Default action #2\n\n  foo_.Bar2(2, 2);  // Uninteresting call, takes default action #1.\n  foo_.Bar2(1, 1);  // Uninteresting call, takes default action #2.\n}\n\nTEST_F(GMockOutputTest, ExplicitActionsRunOutWithDefaultAction) {\n  ON_CALL(foo_, Bar2(_, _))\n      .WillByDefault(Return(true));   // Default action #1\n\n  EXPECT_CALL(foo_, Bar2(_, _))\n      .Times(2)\n      .WillOnce(Return(false));\n  foo_.Bar2(2, 2);\n  foo_.Bar2(1, 1);  // Explicit actions in EXPECT_CALL run out.\n}\n\nTEST_F(GMockOutputTest, CatchesLeakedMocks) {\n  MockFoo* foo1 = new MockFoo;\n  MockFoo* foo2 = new MockFoo;\n\n  // Invokes ON_CALL on foo1.\n  ON_CALL(*foo1, Bar(_, _, _)).WillByDefault(Return('a'));\n\n  // Invokes EXPECT_CALL on foo2.\n  EXPECT_CALL(*foo2, Bar2(_, _));\n  EXPECT_CALL(*foo2, Bar2(1, _));\n  EXPECT_CALL(*foo2, Bar3(_, _)).Times(AnyNumber());\n  foo2->Bar2(2, 1);\n  foo2->Bar2(1, 1);\n\n  // Both foo1 and foo2 are deliberately leaked.\n}\n\nvoid TestCatchesLeakedMocksInAdHocTests() {\n  MockFoo* foo = new MockFoo;\n\n  // Invokes EXPECT_CALL on foo.\n  EXPECT_CALL(*foo, Bar2(_, _));\n  foo->Bar2(2, 1);\n\n  // foo is deliberately leaked.\n}\n\nint main(int argc, char **argv) {\n  testing::InitGoogleMock(&argc, argv);\n\n  // Ensures that the tests pass no matter what value of\n  // --gmock_catch_leaked_mocks and --gmock_verbose the user specifies.\n  testing::GMOCK_FLAG(catch_leaked_mocks) = true;\n  testing::GMOCK_FLAG(verbose) = \"warning\";\n\n  TestCatchesLeakedMocksInAdHocTests();\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "ext/gmock/test/gmock_output_test_golden.txt",
    "content": "[ RUN      ] GMockOutputTest.ExpectedCall\n\nFILE:#: EXPECT_CALL(foo_, Bar2(0, _)) invoked\nStack trace:\n\nFILE:#: Mock function call matches EXPECT_CALL(foo_, Bar2(0, _))...\n    Function call: Bar2(0, 0)\n          Returns: false\nStack trace:\n[       OK ] GMockOutputTest.ExpectedCall\n[ RUN      ] GMockOutputTest.ExpectedCallToVoidFunction\n\nFILE:#: EXPECT_CALL(foo_, Bar3(0, _)) invoked\nStack trace:\n\nFILE:#: Mock function call matches EXPECT_CALL(foo_, Bar3(0, _))...\n    Function call: Bar3(0, 0)\nStack trace:\n[       OK ] GMockOutputTest.ExpectedCallToVoidFunction\n[ RUN      ] GMockOutputTest.ExplicitActionsRunOut\n\nGMOCK WARNING:\nFILE:#: Too few actions specified in EXPECT_CALL(foo_, Bar2(_, _))...\nExpected to be called twice, but has only 1 WillOnce().\nGMOCK WARNING:\nFILE:#: Actions ran out in EXPECT_CALL(foo_, Bar2(_, _))...\nCalled 2 times, but only 1 WillOnce() is specified - returning default value.\nStack trace:\n[       OK ] GMockOutputTest.ExplicitActionsRunOut\n[ RUN      ] GMockOutputTest.UnexpectedCall\nunknown file: Failure\n\nUnexpected mock function call - returning default value.\n    Function call: Bar2(1, 0)\n          Returns: false\nGoogle Mock tried the following 1 expectation, but it didn't match:\n\nFILE:#: EXPECT_CALL(foo_, Bar2(0, _))...\n  Expected arg #0: is equal to 0\n           Actual: 1\n         Expected: to be called once\n           Actual: never called - unsatisfied and active\n[  FAILED  ] GMockOutputTest.UnexpectedCall\n[ RUN      ] GMockOutputTest.UnexpectedCallToVoidFunction\nunknown file: Failure\n\nUnexpected mock function call - returning directly.\n    Function call: Bar3(1, 0)\nGoogle Mock tried the following 1 expectation, but it didn't match:\n\nFILE:#: EXPECT_CALL(foo_, Bar3(0, _))...\n  Expected arg #0: is equal to 0\n           Actual: 1\n         Expected: to be called once\n           Actual: never called - unsatisfied and active\n[  FAILED  ] GMockOutputTest.UnexpectedCallToVoidFunction\n[ RUN      ] GMockOutputTest.ExcessiveCall\nFILE:#: Failure\nMock function called more times than expected - returning default value.\n    Function call: Bar2(0, 1)\n          Returns: false\n         Expected: to be called once\n           Actual: called twice - over-saturated and active\n[  FAILED  ] GMockOutputTest.ExcessiveCall\n[ RUN      ] GMockOutputTest.ExcessiveCallToVoidFunction\nFILE:#: Failure\nMock function called more times than expected - returning directly.\n    Function call: Bar3(0, 1)\n         Expected: to be called once\n           Actual: called twice - over-saturated and active\n[  FAILED  ] GMockOutputTest.ExcessiveCallToVoidFunction\n[ RUN      ] GMockOutputTest.UninterestingCall\n\nGMOCK WARNING:\nUninteresting mock function call - returning default value.\n    Function call: Bar2(0, 1)\n          Returns: false\nStack trace:\n[       OK ] GMockOutputTest.UninterestingCall\n[ RUN      ] GMockOutputTest.UninterestingCallToVoidFunction\n\nGMOCK WARNING:\nUninteresting mock function call - returning directly.\n    Function call: Bar3(0, 1)\nStack trace:\n[       OK ] GMockOutputTest.UninterestingCallToVoidFunction\n[ RUN      ] GMockOutputTest.RetiredExpectation\nunknown file: Failure\n\nUnexpected mock function call - returning default value.\n    Function call: Bar2(1, 1)\n          Returns: false\nGoogle Mock tried the following 2 expectations, but none matched:\n\nFILE:#: tried expectation #0: EXPECT_CALL(foo_, Bar2(_, _))...\n         Expected: the expectation is active\n           Actual: it is retired\n         Expected: to be called once\n           Actual: called once - saturated and retired\nFILE:#: tried expectation #1: EXPECT_CALL(foo_, Bar2(0, 0))...\n  Expected arg #0: is equal to 0\n           Actual: 1\n  Expected arg #1: is equal to 0\n           Actual: 1\n         Expected: to be called once\n           Actual: never called - unsatisfied and active\n[  FAILED  ] GMockOutputTest.RetiredExpectation\n[ RUN      ] GMockOutputTest.UnsatisfiedPrerequisite\nunknown file: Failure\n\nUnexpected mock function call - returning default value.\n    Function call: Bar2(1, 0)\n          Returns: false\nGoogle Mock tried the following 2 expectations, but none matched:\n\nFILE:#: tried expectation #0: EXPECT_CALL(foo_, Bar2(0, 0))...\n  Expected arg #0: is equal to 0\n           Actual: 1\n         Expected: to be called once\n           Actual: never called - unsatisfied and active\nFILE:#: tried expectation #1: EXPECT_CALL(foo_, Bar2(1, _))...\n         Expected: all pre-requisites are satisfied\n           Actual: the following immediate pre-requisites are not satisfied:\nFILE:#: pre-requisite #0\n                   (end of pre-requisites)\n         Expected: to be called once\n           Actual: never called - unsatisfied and active\n[  FAILED  ] GMockOutputTest.UnsatisfiedPrerequisite\n[ RUN      ] GMockOutputTest.UnsatisfiedPrerequisites\nunknown file: Failure\n\nUnexpected mock function call - returning default value.\n    Function call: Bar2(1, 0)\n          Returns: false\nGoogle Mock tried the following 2 expectations, but none matched:\n\nFILE:#: tried expectation #0: EXPECT_CALL(foo_, Bar2(0, 0))...\n  Expected arg #0: is equal to 0\n           Actual: 1\n         Expected: to be called once\n           Actual: never called - unsatisfied and active\nFILE:#: tried expectation #1: EXPECT_CALL(foo_, Bar2(1, _))...\n         Expected: all pre-requisites are satisfied\n           Actual: the following immediate pre-requisites are not satisfied:\nFILE:#: pre-requisite #0\nFILE:#: pre-requisite #1\n                   (end of pre-requisites)\n         Expected: to be called once\n           Actual: never called - unsatisfied and active\n[  FAILED  ] GMockOutputTest.UnsatisfiedPrerequisites\n[ RUN      ] GMockOutputTest.UnsatisfiedWith\nFILE:#: Failure\nActual function call count doesn't match EXPECT_CALL(foo_, Bar2(_, _))...\n    Expected args: are a pair where the first >= the second\n         Expected: to be called once\n           Actual: never called - unsatisfied and active\n[  FAILED  ] GMockOutputTest.UnsatisfiedWith\n[ RUN      ] GMockOutputTest.UnsatisfiedExpectation\nFILE:#: Failure\nActual function call count doesn't match EXPECT_CALL(foo_, Bar2(0, _))...\n         Expected: to be called twice\n           Actual: called once - unsatisfied and active\nFILE:#: Failure\nActual function call count doesn't match EXPECT_CALL(foo_, Bar(_, _, _))...\n         Expected: to be called once\n           Actual: never called - unsatisfied and active\n[  FAILED  ] GMockOutputTest.UnsatisfiedExpectation\n[ RUN      ] GMockOutputTest.MismatchArguments\nunknown file: Failure\n\nUnexpected mock function call - returning default value.\n    Function call: Bar(@0x# \"Ho\", 0, -0.1)\n          Returns: '\\0'\nGoogle Mock tried the following 1 expectation, but it didn't match:\n\nFILE:#: EXPECT_CALL(foo_, Bar(Ref(s), _, Ge(0)))...\n  Expected arg #0: references the variable @0x# \"Hi\"\n           Actual: \"Ho\", which is located @0x#\n  Expected arg #2: is >= 0\n           Actual: -0.1\n         Expected: to be called once\n           Actual: never called - unsatisfied and active\n[  FAILED  ] GMockOutputTest.MismatchArguments\n[ RUN      ] GMockOutputTest.MismatchWith\nunknown file: Failure\n\nUnexpected mock function call - returning default value.\n    Function call: Bar2(2, 3)\n          Returns: false\nGoogle Mock tried the following 1 expectation, but it didn't match:\n\nFILE:#: EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1)))...\n    Expected args: are a pair where the first >= the second\n           Actual: don't match\n         Expected: to be called once\n           Actual: never called - unsatisfied and active\n[  FAILED  ] GMockOutputTest.MismatchWith\n[ RUN      ] GMockOutputTest.MismatchArgumentsAndWith\nunknown file: Failure\n\nUnexpected mock function call - returning default value.\n    Function call: Bar2(1, 3)\n          Returns: false\nGoogle Mock tried the following 1 expectation, but it didn't match:\n\nFILE:#: EXPECT_CALL(foo_, Bar2(Ge(2), Ge(1)))...\n  Expected arg #0: is >= 2\n           Actual: 1\n    Expected args: are a pair where the first >= the second\n           Actual: don't match\n         Expected: to be called once\n           Actual: never called - unsatisfied and active\n[  FAILED  ] GMockOutputTest.MismatchArgumentsAndWith\n[ RUN      ] GMockOutputTest.UnexpectedCallWithDefaultAction\nunknown file: Failure\n\nUnexpected mock function call - taking default action specified at:\nFILE:#:\n    Function call: Bar2(1, 0)\n          Returns: false\nGoogle Mock tried the following 1 expectation, but it didn't match:\n\nFILE:#: EXPECT_CALL(foo_, Bar2(2, 2))...\n  Expected arg #0: is equal to 2\n           Actual: 1\n  Expected arg #1: is equal to 2\n           Actual: 0\n         Expected: to be called once\n           Actual: never called - unsatisfied and active\nunknown file: Failure\n\nUnexpected mock function call - taking default action specified at:\nFILE:#:\n    Function call: Bar2(0, 0)\n          Returns: true\nGoogle Mock tried the following 1 expectation, but it didn't match:\n\nFILE:#: EXPECT_CALL(foo_, Bar2(2, 2))...\n  Expected arg #0: is equal to 2\n           Actual: 0\n  Expected arg #1: is equal to 2\n           Actual: 0\n         Expected: to be called once\n           Actual: never called - unsatisfied and active\n[  FAILED  ] GMockOutputTest.UnexpectedCallWithDefaultAction\n[ RUN      ] GMockOutputTest.ExcessiveCallWithDefaultAction\nFILE:#: Failure\nMock function called more times than expected - taking default action specified at:\nFILE:#:\n    Function call: Bar2(2, 2)\n          Returns: true\n         Expected: to be called once\n           Actual: called twice - over-saturated and active\nFILE:#: Failure\nMock function called more times than expected - taking default action specified at:\nFILE:#:\n    Function call: Bar2(1, 1)\n          Returns: false\n         Expected: to be called once\n           Actual: called twice - over-saturated and active\n[  FAILED  ] GMockOutputTest.ExcessiveCallWithDefaultAction\n[ RUN      ] GMockOutputTest.UninterestingCallWithDefaultAction\n\nGMOCK WARNING:\nUninteresting mock function call - taking default action specified at:\nFILE:#:\n    Function call: Bar2(2, 2)\n          Returns: true\nStack trace:\n\nGMOCK WARNING:\nUninteresting mock function call - taking default action specified at:\nFILE:#:\n    Function call: Bar2(1, 1)\n          Returns: false\nStack trace:\n[       OK ] GMockOutputTest.UninterestingCallWithDefaultAction\n[ RUN      ] GMockOutputTest.ExplicitActionsRunOutWithDefaultAction\n\nGMOCK WARNING:\nFILE:#: Too few actions specified in EXPECT_CALL(foo_, Bar2(_, _))...\nExpected to be called twice, but has only 1 WillOnce().\nGMOCK WARNING:\nFILE:#: Actions ran out in EXPECT_CALL(foo_, Bar2(_, _))...\nCalled 2 times, but only 1 WillOnce() is specified - taking default action specified at:\nFILE:#:\nStack trace:\n[       OK ] GMockOutputTest.ExplicitActionsRunOutWithDefaultAction\n[ RUN      ] GMockOutputTest.CatchesLeakedMocks\n[       OK ] GMockOutputTest.CatchesLeakedMocks\n[  FAILED  ] GMockOutputTest.UnexpectedCall\n[  FAILED  ] GMockOutputTest.UnexpectedCallToVoidFunction\n[  FAILED  ] GMockOutputTest.ExcessiveCall\n[  FAILED  ] GMockOutputTest.ExcessiveCallToVoidFunction\n[  FAILED  ] GMockOutputTest.RetiredExpectation\n[  FAILED  ] GMockOutputTest.UnsatisfiedPrerequisite\n[  FAILED  ] GMockOutputTest.UnsatisfiedPrerequisites\n[  FAILED  ] GMockOutputTest.UnsatisfiedWith\n[  FAILED  ] GMockOutputTest.UnsatisfiedExpectation\n[  FAILED  ] GMockOutputTest.MismatchArguments\n[  FAILED  ] GMockOutputTest.MismatchWith\n[  FAILED  ] GMockOutputTest.MismatchArgumentsAndWith\n[  FAILED  ] GMockOutputTest.UnexpectedCallWithDefaultAction\n[  FAILED  ] GMockOutputTest.ExcessiveCallWithDefaultAction\n\n\nFILE:#: ERROR: this mock object should be deleted but never is. Its address is @0x#.\nFILE:#: ERROR: this mock object should be deleted but never is. Its address is @0x#.\nFILE:#: ERROR: this mock object should be deleted but never is. Its address is @0x#.\nERROR: 3 leaked mock objects found at program exit.\n"
  },
  {
    "path": "ext/gmock/test/gmock_stress_test.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Tests that Google Mock constructs can be used in a large number of\n// threads concurrently.\n\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\nnamespace testing {\nnamespace {\n\n// From <gtest/internal/gtest-port.h>.\nusing ::testing::internal::ThreadWithParam;\n\n// The maximum number of test threads (not including helper threads)\n// to create.\nconst int kMaxTestThreads = 50;\n\n// How many times to repeat a task in a test thread.\nconst int kRepeat = 50;\n\nclass MockFoo {\n public:\n  MOCK_METHOD1(Bar, int(int n));  // NOLINT\n  MOCK_METHOD2(Baz, char(const char* s1, const internal::string& s2));  // NOLINT\n};\n\n// Helper for waiting for the given thread to finish and then deleting it.\ntemplate <typename T>\nvoid JoinAndDelete(ThreadWithParam<T>* t) {\n  t->Join();\n  delete t;\n}\n\nusing internal::linked_ptr;\n\n// Helper classes for testing using linked_ptr concurrently.\n\nclass Base {\n public:\n  explicit Base(int a_x) : x_(a_x) {}\n  virtual ~Base() {}\n  int x() const { return x_; }\n private:\n  int x_;\n};\n\nclass Derived1 : public Base {\n public:\n  Derived1(int a_x, int a_y) : Base(a_x), y_(a_y) {}\n  int y() const { return y_; }\n private:\n  int y_;\n};\n\nclass Derived2 : public Base {\n public:\n  Derived2(int a_x, int a_z) : Base(a_x), z_(a_z) {}\n  int z() const { return z_; }\n private:\n  int z_;\n};\n\nlinked_ptr<Derived1> pointer1(new Derived1(1, 2));\nlinked_ptr<Derived2> pointer2(new Derived2(3, 4));\n\nstruct Dummy {};\n\n// Tests that we can copy from a linked_ptr and read it concurrently.\nvoid TestConcurrentCopyAndReadLinkedPtr(Dummy /* dummy */) {\n  // Reads pointer1 and pointer2 while they are being copied from in\n  // another thread.\n  EXPECT_EQ(1, pointer1->x());\n  EXPECT_EQ(2, pointer1->y());\n  EXPECT_EQ(3, pointer2->x());\n  EXPECT_EQ(4, pointer2->z());\n\n  // Copies from pointer1.\n  linked_ptr<Derived1> p1(pointer1);\n  EXPECT_EQ(1, p1->x());\n  EXPECT_EQ(2, p1->y());\n\n  // Assigns from pointer2 where the LHS was empty.\n  linked_ptr<Base> p2;\n  p2 = pointer1;\n  EXPECT_EQ(1, p2->x());\n\n  // Assigns from pointer2 where the LHS was not empty.\n  p2 = pointer2;\n  EXPECT_EQ(3, p2->x());\n}\n\nconst linked_ptr<Derived1> p0(new Derived1(1, 2));\n\n// Tests that we can concurrently modify two linked_ptrs that point to\n// the same object.\nvoid TestConcurrentWriteToEqualLinkedPtr(Dummy /* dummy */) {\n  // p1 and p2 point to the same, shared thing.  One thread resets p1.\n  // Another thread assigns to p2.  This will cause the same\n  // underlying \"ring\" to be updated concurrently.\n  linked_ptr<Derived1> p1(p0);\n  linked_ptr<Derived1> p2(p0);\n\n  EXPECT_EQ(1, p1->x());\n  EXPECT_EQ(2, p1->y());\n\n  EXPECT_EQ(1, p2->x());\n  EXPECT_EQ(2, p2->y());\n\n  p1.reset();\n  p2 = p0;\n\n  EXPECT_EQ(1, p2->x());\n  EXPECT_EQ(2, p2->y());\n}\n\n// Tests that different mock objects can be used in their respective\n// threads.  This should generate no Google Test failure.\nvoid TestConcurrentMockObjects(Dummy /* dummy */) {\n  // Creates a mock and does some typical operations on it.\n  MockFoo foo;\n  ON_CALL(foo, Bar(_))\n      .WillByDefault(Return(1));\n  ON_CALL(foo, Baz(_, _))\n      .WillByDefault(Return('b'));\n  ON_CALL(foo, Baz(_, \"you\"))\n      .WillByDefault(Return('a'));\n\n  EXPECT_CALL(foo, Bar(0))\n      .Times(AtMost(3));\n  EXPECT_CALL(foo, Baz(_, _));\n  EXPECT_CALL(foo, Baz(\"hi\", \"you\"))\n      .WillOnce(Return('z'))\n      .WillRepeatedly(DoDefault());\n\n  EXPECT_EQ(1, foo.Bar(0));\n  EXPECT_EQ(1, foo.Bar(0));\n  EXPECT_EQ('z', foo.Baz(\"hi\", \"you\"));\n  EXPECT_EQ('a', foo.Baz(\"hi\", \"you\"));\n  EXPECT_EQ('b', foo.Baz(\"hi\", \"me\"));\n}\n\n// Tests invoking methods of the same mock object in multiple threads.\n\nstruct Helper1Param {\n  MockFoo* mock_foo;\n  int* count;\n};\n\nvoid Helper1(Helper1Param param) {\n  for (int i = 0; i < kRepeat; i++) {\n    const char ch = param.mock_foo->Baz(\"a\", \"b\");\n    if (ch == 'a') {\n      // It was an expected call.\n      (*param.count)++;\n    } else {\n      // It was an excessive call.\n      EXPECT_EQ('\\0', ch);\n    }\n\n    // An unexpected call.\n    EXPECT_EQ('\\0', param.mock_foo->Baz(\"x\", \"y\")) << \"Expected failure.\";\n\n    // An uninteresting call.\n    EXPECT_EQ(1, param.mock_foo->Bar(5));\n  }\n}\n\n// This should generate 3*kRepeat + 1 failures in total.\nvoid TestConcurrentCallsOnSameObject(Dummy /* dummy */) {\n  MockFoo foo;\n\n  ON_CALL(foo, Bar(_))\n      .WillByDefault(Return(1));\n  EXPECT_CALL(foo, Baz(_, \"b\"))\n      .Times(kRepeat)\n      .WillRepeatedly(Return('a'));\n  EXPECT_CALL(foo, Baz(_, \"c\"));  // Expected to be unsatisfied.\n\n  // This chunk of code should generate kRepeat failures about\n  // excessive calls, and 2*kRepeat failures about unexpected calls.\n  int count1 = 0;\n  const Helper1Param param = { &foo, &count1 };\n  ThreadWithParam<Helper1Param>* const t =\n      new ThreadWithParam<Helper1Param>(Helper1, param, NULL);\n\n  int count2 = 0;\n  const Helper1Param param2 = { &foo, &count2 };\n  Helper1(param2);\n  JoinAndDelete(t);\n\n  EXPECT_EQ(kRepeat, count1 + count2);\n\n  // foo's destructor should generate one failure about unsatisfied\n  // expectation.\n}\n\n// Tests using the same mock object in multiple threads when the\n// expectations are partially ordered.\n\nvoid Helper2(MockFoo* foo) {\n  for (int i = 0; i < kRepeat; i++) {\n    foo->Bar(2);\n    foo->Bar(3);\n  }\n}\n\n// This should generate no Google Test failures.\nvoid TestPartiallyOrderedExpectationsWithThreads(Dummy /* dummy */) {\n  MockFoo foo;\n  Sequence s1, s2;\n\n  {\n    InSequence dummy;\n    EXPECT_CALL(foo, Bar(0));\n    EXPECT_CALL(foo, Bar(1))\n        .InSequence(s1, s2);\n  }\n\n  EXPECT_CALL(foo, Bar(2))\n      .Times(2*kRepeat)\n      .InSequence(s1)\n      .RetiresOnSaturation();\n  EXPECT_CALL(foo, Bar(3))\n      .Times(2*kRepeat)\n      .InSequence(s2);\n\n  {\n    InSequence dummy;\n    EXPECT_CALL(foo, Bar(2))\n        .InSequence(s1, s2);\n    EXPECT_CALL(foo, Bar(4));\n  }\n\n  foo.Bar(0);\n  foo.Bar(1);\n\n  ThreadWithParam<MockFoo*>* const t =\n      new ThreadWithParam<MockFoo*>(Helper2, &foo, NULL);\n  Helper2(&foo);\n  JoinAndDelete(t);\n\n  foo.Bar(2);\n  foo.Bar(4);\n}\n\n// Tests using Google Mock constructs in many threads concurrently.\nTEST(StressTest, CanUseGMockWithThreads) {\n  void (*test_routines[])(Dummy dummy) = {\n    &TestConcurrentCopyAndReadLinkedPtr,\n    &TestConcurrentWriteToEqualLinkedPtr,\n    &TestConcurrentMockObjects,\n    &TestConcurrentCallsOnSameObject,\n    &TestPartiallyOrderedExpectationsWithThreads,\n  };\n\n  const int kRoutines = sizeof(test_routines)/sizeof(test_routines[0]);\n  const int kCopiesOfEachRoutine = kMaxTestThreads / kRoutines;\n  const int kTestThreads = kCopiesOfEachRoutine * kRoutines;\n  ThreadWithParam<Dummy>* threads[kTestThreads] = {};\n  for (int i = 0; i < kTestThreads; i++) {\n    // Creates a thread to run the test function.\n    threads[i] =\n        new ThreadWithParam<Dummy>(test_routines[i % kRoutines], Dummy(), NULL);\n    GTEST_LOG_(INFO) << \"Thread #\" << i << \" running . . .\";\n  }\n\n  // At this point, we have many threads running.\n  for (int i = 0; i < kTestThreads; i++) {\n    JoinAndDelete(threads[i]);\n  }\n\n  // Ensures that the correct number of failures have been reported.\n  const TestInfo* const info = UnitTest::GetInstance()->current_test_info();\n  const TestResult& result = *info->result();\n  const int kExpectedFailures = (3*kRepeat + 1)*kCopiesOfEachRoutine;\n  GTEST_CHECK_(kExpectedFailures == result.total_part_count())\n      << \"Expected \" << kExpectedFailures << \" failures, but got \"\n      << result.total_part_count();\n}\n\n}  // namespace\n}  // namespace testing\n\nint main(int argc, char **argv) {\n  testing::InitGoogleMock(&argc, argv);\n\n  const int exit_code = RUN_ALL_TESTS();  // Expected to fail.\n  GTEST_CHECK_(exit_code != 0) << \"RUN_ALL_TESTS() did not fail as expected\";\n\n  printf(\"\\nPASS\\n\");\n  return 0;\n}\n"
  },
  {
    "path": "ext/gmock/test/gmock_test.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Mock - a framework for writing C++ mock classes.\n//\n// This file tests code in gmock.cc.\n\n#include \"gmock/gmock.h\"\n\n#include <string>\n#include \"gtest/gtest.h\"\n\nusing testing::GMOCK_FLAG(verbose);\nusing testing::InitGoogleMock;\nusing testing::internal::g_init_gtest_count;\n\n// Verifies that calling InitGoogleMock() on argv results in new_argv,\n// and the gmock_verbose flag's value is set to expected_gmock_verbose.\ntemplate <typename Char, int M, int N>\nvoid TestInitGoogleMock(const Char* (&argv)[M], const Char* (&new_argv)[N],\n                        const ::std::string& expected_gmock_verbose) {\n  const ::std::string old_verbose = GMOCK_FLAG(verbose);\n\n  int argc = M;\n  InitGoogleMock(&argc, const_cast<Char**>(argv));\n  ASSERT_EQ(N, argc) << \"The new argv has wrong number of elements.\";\n\n  for (int i = 0; i < N; i++) {\n    EXPECT_STREQ(new_argv[i], argv[i]);\n  }\n\n  EXPECT_EQ(expected_gmock_verbose, GMOCK_FLAG(verbose).c_str());\n  GMOCK_FLAG(verbose) = old_verbose;  // Restores the gmock_verbose flag.\n}\n\nTEST(InitGoogleMockTest, ParsesInvalidCommandLine) {\n  const char* argv[] = {\n    NULL\n  };\n\n  const char* new_argv[] = {\n    NULL\n  };\n\n  TestInitGoogleMock(argv, new_argv, GMOCK_FLAG(verbose));\n}\n\nTEST(InitGoogleMockTest, ParsesEmptyCommandLine) {\n  const char* argv[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  const char* new_argv[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  TestInitGoogleMock(argv, new_argv, GMOCK_FLAG(verbose));\n}\n\nTEST(InitGoogleMockTest, ParsesSingleFlag) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gmock_verbose=info\",\n    NULL\n  };\n\n  const char* new_argv[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  TestInitGoogleMock(argv, new_argv, \"info\");\n}\n\nTEST(InitGoogleMockTest, ParsesUnrecognizedFlag) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--non_gmock_flag=blah\",\n    NULL\n  };\n\n  const char* new_argv[] = {\n    \"foo.exe\",\n    \"--non_gmock_flag=blah\",\n    NULL\n  };\n\n  TestInitGoogleMock(argv, new_argv, GMOCK_FLAG(verbose));\n}\n\nTEST(InitGoogleMockTest, ParsesGoogleMockFlagAndUnrecognizedFlag) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--non_gmock_flag=blah\",\n    \"--gmock_verbose=error\",\n    NULL\n  };\n\n  const char* new_argv[] = {\n    \"foo.exe\",\n    \"--non_gmock_flag=blah\",\n    NULL\n  };\n\n  TestInitGoogleMock(argv, new_argv, \"error\");\n}\n\nTEST(InitGoogleMockTest, CallsInitGoogleTest) {\n  const int old_init_gtest_count = g_init_gtest_count;\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--non_gmock_flag=blah\",\n    \"--gmock_verbose=error\",\n    NULL\n  };\n\n  const char* new_argv[] = {\n    \"foo.exe\",\n    \"--non_gmock_flag=blah\",\n    NULL\n  };\n\n  TestInitGoogleMock(argv, new_argv, \"error\");\n  EXPECT_EQ(old_init_gtest_count + 1, g_init_gtest_count);\n}\n\nTEST(WideInitGoogleMockTest, ParsesInvalidCommandLine) {\n  const wchar_t* argv[] = {\n    NULL\n  };\n\n  const wchar_t* new_argv[] = {\n    NULL\n  };\n\n  TestInitGoogleMock(argv, new_argv, GMOCK_FLAG(verbose));\n}\n\nTEST(WideInitGoogleMockTest, ParsesEmptyCommandLine) {\n  const wchar_t* argv[] = {\n    L\"foo.exe\",\n    NULL\n  };\n\n  const wchar_t* new_argv[] = {\n    L\"foo.exe\",\n    NULL\n  };\n\n  TestInitGoogleMock(argv, new_argv, GMOCK_FLAG(verbose));\n}\n\nTEST(WideInitGoogleMockTest, ParsesSingleFlag) {\n  const wchar_t* argv[] = {\n    L\"foo.exe\",\n    L\"--gmock_verbose=info\",\n    NULL\n  };\n\n  const wchar_t* new_argv[] = {\n    L\"foo.exe\",\n    NULL\n  };\n\n  TestInitGoogleMock(argv, new_argv, \"info\");\n}\n\nTEST(WideInitGoogleMockTest, ParsesUnrecognizedFlag) {\n  const wchar_t* argv[] = {\n    L\"foo.exe\",\n    L\"--non_gmock_flag=blah\",\n    NULL\n  };\n\n  const wchar_t* new_argv[] = {\n    L\"foo.exe\",\n    L\"--non_gmock_flag=blah\",\n    NULL\n  };\n\n  TestInitGoogleMock(argv, new_argv, GMOCK_FLAG(verbose));\n}\n\nTEST(WideInitGoogleMockTest, ParsesGoogleMockFlagAndUnrecognizedFlag) {\n  const wchar_t* argv[] = {\n    L\"foo.exe\",\n    L\"--non_gmock_flag=blah\",\n    L\"--gmock_verbose=error\",\n    NULL\n  };\n\n  const wchar_t* new_argv[] = {\n    L\"foo.exe\",\n    L\"--non_gmock_flag=blah\",\n    NULL\n  };\n\n  TestInitGoogleMock(argv, new_argv, \"error\");\n}\n\nTEST(WideInitGoogleMockTest, CallsInitGoogleTest) {\n  const int old_init_gtest_count = g_init_gtest_count;\n  const wchar_t* argv[] = {\n    L\"foo.exe\",\n    L\"--non_gmock_flag=blah\",\n    L\"--gmock_verbose=error\",\n    NULL\n  };\n\n  const wchar_t* new_argv[] = {\n    L\"foo.exe\",\n    L\"--non_gmock_flag=blah\",\n    NULL\n  };\n\n  TestInitGoogleMock(argv, new_argv, \"error\");\n  EXPECT_EQ(old_init_gtest_count + 1, g_init_gtest_count);\n}\n\n// Makes sure Google Mock flags can be accessed in code.\nTEST(FlagTest, IsAccessibleInCode) {\n  bool dummy = testing::GMOCK_FLAG(catch_leaked_mocks) &&\n      testing::GMOCK_FLAG(verbose) == \"\";\n  (void)dummy;  // Avoids the \"unused local variable\" warning.\n}\n"
  },
  {
    "path": "ext/gmock/test/gmock_test_utils.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2006, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Unit test utilities for Google C++ Mocking Framework.\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport sys\n\n\n# Determines path to gtest_test_utils and imports it.\nSCRIPT_DIR = os.path.dirname(__file__) or '.'\n\n# isdir resolves symbolic links.\ngtest_tests_util_dir = os.path.join(SCRIPT_DIR, '../gtest/test')\nif os.path.isdir(gtest_tests_util_dir):\n  GTEST_TESTS_UTIL_DIR = gtest_tests_util_dir\nelse:\n  GTEST_TESTS_UTIL_DIR = os.path.join(SCRIPT_DIR, '../../gtest/test')\n\nsys.path.append(GTEST_TESTS_UTIL_DIR)\nimport gtest_test_utils  # pylint: disable-msg=C6204\n\n\ndef GetSourceDir():\n  \"\"\"Returns the absolute path of the directory where the .py files are.\"\"\"\n\n  return gtest_test_utils.GetSourceDir()\n\n\ndef GetTestExecutablePath(executable_name):\n  \"\"\"Returns the absolute path of the test binary given its name.\n\n  The function will print a message and abort the program if the resulting file\n  doesn't exist.\n\n  Args:\n    executable_name: name of the test binary that the test script runs.\n\n  Returns:\n    The absolute path of the test binary.\n  \"\"\"\n\n  return gtest_test_utils.GetTestExecutablePath(executable_name)\n\n\ndef GetExitStatus(exit_code):\n  \"\"\"Returns the argument to exit(), or -1 if exit() wasn't called.\n\n  Args:\n    exit_code: the result value of os.system(command).\n  \"\"\"\n\n  if os.name == 'nt':\n    # On Windows, os.WEXITSTATUS() doesn't work and os.system() returns\n    # the argument to exit() directly.\n    return exit_code\n  else:\n    # On Unix, os.WEXITSTATUS() must be used to extract the exit status\n    # from the result of os.system().\n    if os.WIFEXITED(exit_code):\n      return os.WEXITSTATUS(exit_code)\n    else:\n      return -1\n\n\n# Suppresses the \"Invalid const name\" lint complaint\n# pylint: disable-msg=C6409\n\n# Exposes utilities from gtest_test_utils.\nSubprocess = gtest_test_utils.Subprocess\nTestCase = gtest_test_utils.TestCase\nenviron = gtest_test_utils.environ\nSetEnvVar = gtest_test_utils.SetEnvVar\nPREMATURE_EXIT_FILE_ENV_VAR = gtest_test_utils.PREMATURE_EXIT_FILE_ENV_VAR\n\n# pylint: enable-msg=C6409\n\n\ndef Main():\n  \"\"\"Runs the unit test.\"\"\"\n\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "ext/gtest/CHANGES",
    "content": "Changes for 1.7.0:\n\n* New feature: death tests are supported on OpenBSD and in iOS\n  simulator now.\n* New feature: Google Test now implements a protocol to allow\n  a test runner to detect that a test program has exited\n  prematurely and report it as a failure (before it would be\n  falsely reported as a success if the exit code is 0).\n* New feature: Test::RecordProperty() can now be used outside of the\n  lifespan of a test method, in which case it will be attributed to\n  the current test case or the test program in the XML report.\n* New feature (potentially breaking): --gtest_list_tests now prints\n  the type parameters and value parameters for each test.\n* Improvement: char pointers and char arrays are now escaped properly\n  in failure messages.\n* Improvement: failure summary in XML reports now includes file and\n  line information.\n* Improvement: the <testsuites> XML element now has a timestamp attribute.\n* Improvement: When --gtest_filter is specified, XML report now doesn't\n  contain information about tests that are filtered out.\n* Fixed the bug where long --gtest_filter flag values are truncated in\n  death tests.\n* Potentially breaking change: RUN_ALL_TESTS() is now implemented as a\n  function instead of a macro in order to work better with Clang.\n* Compatibility fixes with C++ 11 and various platforms.\n* Bug/warning fixes.\n\nChanges for 1.6.0:\n\n* New feature: ADD_FAILURE_AT() for reporting a test failure at the\n  given source location -- useful for writing testing utilities.\n* New feature: the universal value printer is moved from Google Mock\n  to Google Test.\n* New feature: type parameters and value parameters are reported in\n  the XML report now.\n* A gtest_disable_pthreads CMake option.\n* Colored output works in GNU Screen sessions now.\n* Parameters of value-parameterized tests are now printed in the\n  textual output.\n* Failures from ad hoc test assertions run before RUN_ALL_TESTS() are\n  now correctly reported.\n* Arguments of ASSERT_XY and EXPECT_XY no longer need to support << to\n  ostream.\n* More complete handling of exceptions.\n* GTEST_ASSERT_XY can be used instead of ASSERT_XY in case the latter\n  name is already used by another library.\n* --gtest_catch_exceptions is now true by default, allowing a test\n  program to continue after an exception is thrown.\n* Value-parameterized test fixtures can now derive from Test and\n  WithParamInterface<T> separately, easing conversion of legacy tests.\n* Death test messages are clearly marked to make them more\n  distinguishable from other messages.\n* Compatibility fixes for Android, Google Native Client, MinGW, HP UX,\n  PowerPC, Lucid autotools, libCStd, Sun C++, Borland C++ Builder (Code Gear),\n  IBM XL C++ (Visual Age C++), and C++0x.\n* Bug fixes and implementation clean-ups.\n* Potentially incompatible changes: disables the harmful 'make install'\n  command in autotools.\n\nChanges for 1.5.0:\n\n * New feature: assertions can be safely called in multiple threads\n   where the pthreads library is available.\n * New feature: predicates used inside EXPECT_TRUE() and friends\n   can now generate custom failure messages.\n * New feature: Google Test can now be compiled as a DLL.\n * New feature: fused source files are included.\n * New feature: prints help when encountering unrecognized Google Test flags.\n * Experimental feature: CMake build script (requires CMake 2.6.4+).\n * Experimental feature: the Pump script for meta programming.\n * double values streamed to an assertion are printed with enough precision\n   to differentiate any two different values.\n * Google Test now works on Solaris and AIX.\n * Build and test script improvements.\n * Bug fixes and implementation clean-ups.\n\n Potentially breaking changes:\n\n * Stopped supporting VC++ 7.1 with exceptions disabled.\n * Dropped support for 'make install'.\n\nChanges for 1.4.0:\n\n * New feature: the event listener API\n * New feature: test shuffling\n * New feature: the XML report format is closer to junitreport and can\n   be parsed by Hudson now.\n * New feature: when a test runs under Visual Studio, its failures are\n   integrated in the IDE.\n * New feature: /MD(d) versions of VC++ projects.\n * New feature: elapsed time for the tests is printed by default.\n * New feature: comes with a TR1 tuple implementation such that Boost\n   is no longer needed for Combine().\n * New feature: EXPECT_DEATH_IF_SUPPORTED macro and friends.\n * New feature: the Xcode project can now produce static gtest\n   libraries in addition to a framework.\n * Compatibility fixes for Solaris, Cygwin, minGW, Windows Mobile,\n   Symbian, gcc, and C++Builder.\n * Bug fixes and implementation clean-ups.\n\nChanges for 1.3.0:\n\n * New feature: death tests on Windows, Cygwin, and Mac.\n * New feature: ability to use Google Test assertions in other testing\n   frameworks.\n * New feature: ability to run disabled test via\n   --gtest_also_run_disabled_tests.\n * New feature: the --help flag for printing the usage.\n * New feature: access to Google Test flag values in user code.\n * New feature: a script that packs Google Test into one .h and one\n   .cc file for easy deployment.\n * New feature: support for distributing test functions to multiple\n   machines (requires support from the test runner).\n * Bug fixes and implementation clean-ups.\n\nChanges for 1.2.1:\n\n * Compatibility fixes for Linux IA-64 and IBM z/OS.\n * Added support for using Boost and other TR1 implementations.\n * Changes to the build scripts to support upcoming release of Google C++\n   Mocking Framework.\n * Added Makefile to the distribution package.\n * Improved build instructions in README.\n\nChanges for 1.2.0:\n\n * New feature: value-parameterized tests.\n * New feature: the ASSERT/EXPECT_(NON)FATAL_FAILURE(_ON_ALL_THREADS)\n   macros.\n * Changed the XML report format to match JUnit/Ant's.\n * Added tests to the Xcode project.\n * Added scons/SConscript for building with SCons.\n * Added src/gtest-all.cc for building Google Test from a single file.\n * Fixed compatibility with Solaris and z/OS.\n * Enabled running Python tests on systems with python 2.3 installed,\n   e.g. Mac OS X 10.4.\n * Bug fixes.\n\nChanges for 1.1.0:\n\n * New feature: type-parameterized tests.\n * New feature: exception assertions.\n * New feature: printing elapsed time of tests.\n * Improved the robustness of death tests.\n * Added an Xcode project and samples.\n * Adjusted the output format on Windows to be understandable by Visual Studio.\n * Minor bug fixes.\n\nChanges for 1.0.1:\n\n * Added project files for Visual Studio 7.1.\n * Fixed issues with compiling on Mac OS X.\n * Fixed issues with compiling on Cygwin.\n\nChanges for 1.0.0:\n\n * Initial Open Source release of Google Test\n"
  },
  {
    "path": "ext/gtest/CMakeLists.txt",
    "content": "########################################################################\n# CMake build script for Google Test.\n#\n# To run the tests for Google Test itself on Linux, use 'make test' or\n# ctest.  You can select which tests to run using 'ctest -R regex'.\n# For more options, run 'ctest --help'.\n\n# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to\n# make it prominent in the GUI.\noption(BUILD_SHARED_LIBS \"Build shared libraries (DLLs).\" OFF)\n\n# When other libraries are using a shared version of runtime libraries,\n# Google Test also has to use one.\noption(\n  gtest_force_shared_crt\n  \"Use shared (DLL) run-time lib even when Google Test is built as static lib.\"\n  OFF)\n\noption(gtest_build_tests \"Build all of gtest's own tests.\" OFF)\n\noption(gtest_build_samples \"Build gtest's sample programs.\" OFF)\n\noption(gtest_disable_pthreads \"Disable uses of pthreads in gtest.\" OFF)\n\n# Defines pre_project_set_up_hermetic_build() and set_up_hermetic_build().\ninclude(cmake/hermetic_build.cmake OPTIONAL)\n\nif (COMMAND pre_project_set_up_hermetic_build)\n  pre_project_set_up_hermetic_build()\nendif()\n\n########################################################################\n#\n# Project-wide settings\n\n# Name of the project.\n#\n# CMake files in this project can refer to the root source directory\n# as ${gtest_SOURCE_DIR} and to the root binary directory as\n# ${gtest_BINARY_DIR}.\n# Language \"C\" is required for find_package(Threads).\nproject(gtest CXX C)\ncmake_minimum_required(VERSION 2.6.2)\n\nif (COMMAND set_up_hermetic_build)\n  set_up_hermetic_build()\nendif()\n\n# Define helper functions and macros used by Google Test.\ninclude(cmake/internal_utils.cmake)\n\n#config_compiler_and_linker()  # Defined in internal_utils.cmake.\n#^^^ MYSQL Router Team:\n# 1. See our comment next to this line in gmock/CMakeLists.txt\n# 2. Normally disabling this could be avoided by using a flag for gtest like\n#    cmake -DWINDOWS_RUNTIME_MD=1 ... to skip the call to\n#    config_compiler_and_linker.  In this case it is not possible, because\n#    the gmock/gtest cmakelists.txt is added with \"include(gmock)\" and there\n#    is no way (that we found anyway) to pass a simiar argument to command line\n#    (-DWINDOWS_RUNTIME_MD=1).\n\n# Where Google Test's .h files can be found.\ninclude_directories(\n  ${gtest_SOURCE_DIR}/include\n  ${gtest_SOURCE_DIR})\n\n# Where Google Test's libraries can be found.\nlink_directories(${gtest_BINARY_DIR}/src)\n\n########################################################################\n#\n# Defines the gtest & gtest_main libraries.  User tests should link\n# with one of them.\n\n# Google Test libraries.  We build them using more strict warnings than what\n# are used for other targets, to ensure that gtest can be compiled by a user\n# aggressive about warnings.\ncxx_library(gtest \"${cxx_strict}\" src/gtest-all.cc)\ncxx_library(gtest_main \"${cxx_strict}\" src/gtest_main.cc)\ntarget_link_libraries(gtest_main gtest)\n\n########################################################################\n#\n# Samples on how to link user tests with gtest or gtest_main.\n#\n# They are not built by default.  To build them, set the\n# gtest_build_samples option to ON.  You can do it by running ccmake\n# or specifying the -Dgtest_build_samples=ON flag when running cmake.\n\nif (gtest_build_samples)\n  cxx_executable(sample1_unittest samples gtest_main samples/sample1.cc)\n  cxx_executable(sample2_unittest samples gtest_main samples/sample2.cc)\n  cxx_executable(sample3_unittest samples gtest_main)\n  cxx_executable(sample4_unittest samples gtest_main samples/sample4.cc)\n  cxx_executable(sample5_unittest samples gtest_main samples/sample1.cc)\n  cxx_executable(sample6_unittest samples gtest_main)\n  cxx_executable(sample7_unittest samples gtest_main)\n  cxx_executable(sample8_unittest samples gtest_main)\n  cxx_executable(sample9_unittest samples gtest)\n  cxx_executable(sample10_unittest samples gtest)\nendif()\n\n########################################################################\n#\n# Google Test's own tests.\n#\n# You can skip this section if you aren't interested in testing\n# Google Test itself.\n#\n# The tests are not built by default.  To build them, set the\n# gtest_build_tests option to ON.  You can do it by running ccmake\n# or specifying the -Dgtest_build_tests=ON flag when running cmake.\n\nif (gtest_build_tests)\n  # This must be set in the root directory for the tests to be run by\n  # 'make test' or ctest.\n  enable_testing()\n\n  ############################################################\n  # C++ tests built with standard compiler flags.\n\n  cxx_test(gtest-death-test_test gtest_main)\n  cxx_test(gtest_environment_test gtest)\n  cxx_test(gtest-filepath_test gtest_main)\n  cxx_test(gtest-linked_ptr_test gtest_main)\n  cxx_test(gtest-listener_test gtest_main)\n  cxx_test(gtest_main_unittest gtest_main)\n  cxx_test(gtest-message_test gtest_main)\n  cxx_test(gtest_no_test_unittest gtest)\n  cxx_test(gtest-options_test gtest_main)\n  cxx_test(gtest-param-test_test gtest\n    test/gtest-param-test2_test.cc)\n  cxx_test(gtest-port_test gtest_main)\n  cxx_test(gtest_pred_impl_unittest gtest_main)\n  cxx_test(gtest_premature_exit_test gtest\n    test/gtest_premature_exit_test.cc)\n  cxx_test(gtest-printers_test gtest_main)\n  cxx_test(gtest_prod_test gtest_main\n    test/production.cc)\n  cxx_test(gtest_repeat_test gtest)\n  cxx_test(gtest_sole_header_test gtest_main)\n  cxx_test(gtest_stress_test gtest)\n  cxx_test(gtest-test-part_test gtest_main)\n  cxx_test(gtest_throw_on_failure_ex_test gtest)\n  cxx_test(gtest-typed-test_test gtest_main\n    test/gtest-typed-test2_test.cc)\n  cxx_test(gtest_unittest gtest_main)\n  cxx_test(gtest-unittest-api_test gtest)\n\n  ############################################################\n  # C++ tests built with non-standard compiler flags.\n\n  # MSVC 7.1 does not support STL with exceptions disabled.\n  if (NOT MSVC OR MSVC_VERSION GREATER 1310)\n    cxx_library(gtest_no_exception \"${cxx_no_exception}\"\n      src/gtest-all.cc)\n    cxx_library(gtest_main_no_exception \"${cxx_no_exception}\"\n      src/gtest-all.cc src/gtest_main.cc)\n  endif()\n  cxx_library(gtest_main_no_rtti \"${cxx_no_rtti}\"\n    src/gtest-all.cc src/gtest_main.cc)\n\n  cxx_test_with_flags(gtest-death-test_ex_nocatch_test\n    \"${cxx_exception} -DGTEST_ENABLE_CATCH_EXCEPTIONS_=0\"\n    gtest test/gtest-death-test_ex_test.cc)\n  cxx_test_with_flags(gtest-death-test_ex_catch_test\n    \"${cxx_exception} -DGTEST_ENABLE_CATCH_EXCEPTIONS_=1\"\n    gtest test/gtest-death-test_ex_test.cc)\n\n  cxx_test_with_flags(gtest_no_rtti_unittest \"${cxx_no_rtti}\"\n    gtest_main_no_rtti test/gtest_unittest.cc)\n\n  cxx_shared_library(gtest_dll \"${cxx_default}\"\n    src/gtest-all.cc src/gtest_main.cc)\n\n  cxx_executable_with_flags(gtest_dll_test_ \"${cxx_default}\"\n    gtest_dll test/gtest_all_test.cc)\n  set_target_properties(gtest_dll_test_\n                        PROPERTIES\n                        COMPILE_DEFINITIONS \"GTEST_LINKED_AS_SHARED_LIBRARY=1\")\n\n  if (NOT MSVC OR NOT MSVC_VERSION EQUAL 1600)\n    # The C++ Standard specifies tuple_element<int, class>.\n    # Yet MSVC 10's <utility> declares tuple_element<size_t, class>.\n    # That declaration conflicts with our own standard-conforming\n    # tuple implementation.  Therefore using our own tuple with\n    # MSVC 10 doesn't compile.\n    cxx_library(gtest_main_use_own_tuple \"${cxx_use_own_tuple}\"\n      src/gtest-all.cc src/gtest_main.cc)\n\n    cxx_test_with_flags(gtest-tuple_test \"${cxx_use_own_tuple}\"\n      gtest_main_use_own_tuple test/gtest-tuple_test.cc)\n\n    cxx_test_with_flags(gtest_use_own_tuple_test \"${cxx_use_own_tuple}\"\n      gtest_main_use_own_tuple\n      test/gtest-param-test_test.cc test/gtest-param-test2_test.cc)\n  endif()\n\n  ############################################################\n  # Python tests.\n\n  cxx_executable(gtest_break_on_failure_unittest_ test gtest)\n  py_test(gtest_break_on_failure_unittest)\n\n  # MSVC 7.1 does not support STL with exceptions disabled.\n  if (NOT MSVC OR MSVC_VERSION GREATER 1310)\n    cxx_executable_with_flags(\n      gtest_catch_exceptions_no_ex_test_\n      \"${cxx_no_exception}\"\n      gtest_main_no_exception\n      test/gtest_catch_exceptions_test_.cc)\n  endif()\n\n  cxx_executable_with_flags(\n    gtest_catch_exceptions_ex_test_\n    \"${cxx_exception}\"\n    gtest_main\n    test/gtest_catch_exceptions_test_.cc)\n  py_test(gtest_catch_exceptions_test)\n\n  cxx_executable(gtest_color_test_ test gtest)\n  py_test(gtest_color_test)\n\n  cxx_executable(gtest_env_var_test_ test gtest)\n  py_test(gtest_env_var_test)\n\n  cxx_executable(gtest_filter_unittest_ test gtest)\n  py_test(gtest_filter_unittest)\n\n  cxx_executable(gtest_help_test_ test gtest_main)\n  py_test(gtest_help_test)\n\n  cxx_executable(gtest_list_tests_unittest_ test gtest)\n  py_test(gtest_list_tests_unittest)\n\n  cxx_executable(gtest_output_test_ test gtest)\n  py_test(gtest_output_test)\n\n  cxx_executable(gtest_shuffle_test_ test gtest)\n  py_test(gtest_shuffle_test)\n\n  # MSVC 7.1 does not support STL with exceptions disabled.\n  if (NOT MSVC OR MSVC_VERSION GREATER 1310)\n    cxx_executable(gtest_throw_on_failure_test_ test gtest_no_exception)\n    set_target_properties(gtest_throw_on_failure_test_\n      PROPERTIES\n      COMPILE_FLAGS \"${cxx_no_exception}\")\n    py_test(gtest_throw_on_failure_test)\n  endif()\n\n  cxx_executable(gtest_uninitialized_test_ test gtest)\n  py_test(gtest_uninitialized_test)\n\n  cxx_executable(gtest_xml_outfile1_test_ test gtest_main)\n  cxx_executable(gtest_xml_outfile2_test_ test gtest_main)\n  py_test(gtest_xml_outfiles_test)\n\n  cxx_executable(gtest_xml_output_unittest_ test gtest)\n  py_test(gtest_xml_output_unittest)\nendif()\n"
  },
  {
    "path": "ext/gtest/CONTRIBUTORS",
    "content": "# This file contains a list of people who've made non-trivial\n# contribution to the Google C++ Testing Framework project.  People\n# who commit code to the project are encouraged to add their names\n# here.  Please keep the list sorted by first names.\n\nAjay Joshi <jaj@google.com>\nBalázs Dán <balazs.dan@gmail.com>\nBharat Mediratta <bharat@menalto.com>\nChandler Carruth <chandlerc@google.com>\nChris Prince <cprince@google.com>\nChris Taylor <taylorc@google.com>\nDan Egnor <egnor@google.com>\nEric Roman <eroman@chromium.org>\nHady Zalek <hady.zalek@gmail.com>\nJeffrey Yasskin <jyasskin@google.com>\nJói Sigurðsson <joi@google.com>\nKeir Mierle <mierle@gmail.com>\nKeith Ray <keith.ray@gmail.com>\nKenton Varda <kenton@google.com>\nManuel Klimek <klimek@google.com>\nMarkus Heule <markus.heule@gmail.com>\nMika Raento <mikie@iki.fi>\nMiklós Fazekas <mfazekas@szemafor.com>\nPasi Valminen <pasi.valminen@gmail.com>\nPatrick Hanna <phanna@google.com>\nPatrick Riley <pfr@google.com>\nPeter Kaminski <piotrk@google.com>\nPreston Jackson <preston.a.jackson@gmail.com>\nRainer Klaffenboeck <rainer.klaffenboeck@dynatrace.com>\nRuss Cox <rsc@google.com>\nRuss Rufer <russ@pentad.com>\nSean Mcafee <eefacm@gmail.com>\nSigurður Ásgeirsson <siggi@google.com>\nTracy Bialik <tracy@pentad.com>\nVadim Berman <vadimb@google.com>\nVlad Losev <vladl@google.com>\nZhanyong Wan <wan@google.com>\n"
  },
  {
    "path": "ext/gtest/LICENSE",
    "content": "Copyright 2008, Google Inc.\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n    * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n    * Neither the name of Google Inc. nor the names of its\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n"
  },
  {
    "path": "ext/gtest/Makefile.am",
    "content": "# Automake file\n\nACLOCAL_AMFLAGS = -I m4\n\n# Nonstandard package files for distribution\nEXTRA_DIST = \\\n  CHANGES \\\n  CONTRIBUTORS \\\n  LICENSE \\\n  include/gtest/gtest-param-test.h.pump \\\n  include/gtest/internal/gtest-param-util-generated.h.pump \\\n  include/gtest/internal/gtest-tuple.h.pump \\\n  include/gtest/internal/gtest-type-util.h.pump \\\n  make/Makefile \\\n  scripts/fuse_gtest_files.py \\\n  scripts/gen_gtest_pred_impl.py \\\n  scripts/pump.py \\\n  scripts/test/Makefile\n\n# gtest source files that we don't compile directly.  They are\n# #included by gtest-all.cc.\nGTEST_SRC = \\\n  src/gtest-death-test.cc \\\n  src/gtest-filepath.cc \\\n  src/gtest-internal-inl.h \\\n  src/gtest-port.cc \\\n  src/gtest-printers.cc \\\n  src/gtest-test-part.cc \\\n  src/gtest-typed-test.cc \\\n  src/gtest.cc\n\nEXTRA_DIST += $(GTEST_SRC)\n\n# Sample files that we don't compile.\nEXTRA_DIST += \\\n  samples/prime_tables.h \\\n  samples/sample2_unittest.cc \\\n  samples/sample3_unittest.cc \\\n  samples/sample4_unittest.cc \\\n  samples/sample5_unittest.cc \\\n  samples/sample6_unittest.cc \\\n  samples/sample7_unittest.cc \\\n  samples/sample8_unittest.cc \\\n  samples/sample9_unittest.cc\n\n# C++ test files that we don't compile directly.\nEXTRA_DIST += \\\n  test/gtest-death-test_ex_test.cc \\\n  test/gtest-death-test_test.cc \\\n  test/gtest-filepath_test.cc \\\n  test/gtest-linked_ptr_test.cc \\\n  test/gtest-listener_test.cc \\\n  test/gtest-message_test.cc \\\n  test/gtest-options_test.cc \\\n  test/gtest-param-test2_test.cc \\\n  test/gtest-param-test2_test.cc \\\n  test/gtest-param-test_test.cc \\\n  test/gtest-param-test_test.cc \\\n  test/gtest-param-test_test.h \\\n  test/gtest-port_test.cc \\\n  test/gtest_premature_exit_test.cc \\\n  test/gtest-printers_test.cc \\\n  test/gtest-test-part_test.cc \\\n  test/gtest-tuple_test.cc \\\n  test/gtest-typed-test2_test.cc \\\n  test/gtest-typed-test_test.cc \\\n  test/gtest-typed-test_test.h \\\n  test/gtest-unittest-api_test.cc \\\n  test/gtest_break_on_failure_unittest_.cc \\\n  test/gtest_catch_exceptions_test_.cc \\\n  test/gtest_color_test_.cc \\\n  test/gtest_env_var_test_.cc \\\n  test/gtest_environment_test.cc \\\n  test/gtest_filter_unittest_.cc \\\n  test/gtest_help_test_.cc \\\n  test/gtest_list_tests_unittest_.cc \\\n  test/gtest_main_unittest.cc \\\n  test/gtest_no_test_unittest.cc \\\n  test/gtest_output_test_.cc \\\n  test/gtest_pred_impl_unittest.cc \\\n  test/gtest_prod_test.cc \\\n  test/gtest_repeat_test.cc \\\n  test/gtest_shuffle_test_.cc \\\n  test/gtest_sole_header_test.cc \\\n  test/gtest_stress_test.cc \\\n  test/gtest_throw_on_failure_ex_test.cc \\\n  test/gtest_throw_on_failure_test_.cc \\\n  test/gtest_uninitialized_test_.cc \\\n  test/gtest_unittest.cc \\\n  test/gtest_unittest.cc \\\n  test/gtest_xml_outfile1_test_.cc \\\n  test/gtest_xml_outfile2_test_.cc \\\n  test/gtest_xml_output_unittest_.cc \\\n  test/production.cc \\\n  test/production.h\n\n# Python tests that we don't run.\nEXTRA_DIST += \\\n  test/gtest_break_on_failure_unittest.py \\\n  test/gtest_catch_exceptions_test.py \\\n  test/gtest_color_test.py \\\n  test/gtest_env_var_test.py \\\n  test/gtest_filter_unittest.py \\\n  test/gtest_help_test.py \\\n  test/gtest_list_tests_unittest.py \\\n  test/gtest_output_test.py \\\n  test/gtest_output_test_golden_lin.txt \\\n  test/gtest_shuffle_test.py \\\n  test/gtest_test_utils.py \\\n  test/gtest_throw_on_failure_test.py \\\n  test/gtest_uninitialized_test.py \\\n  test/gtest_xml_outfiles_test.py \\\n  test/gtest_xml_output_unittest.py \\\n  test/gtest_xml_test_utils.py\n\n# CMake script\nEXTRA_DIST += \\\n  CMakeLists.txt \\\n  cmake/internal_utils.cmake\n\n# MSVC project files\nEXTRA_DIST += \\\n  msvc/gtest-md.sln \\\n  msvc/gtest-md.vcproj \\\n  msvc/gtest.sln \\\n  msvc/gtest.vcproj \\\n  msvc/gtest_main-md.vcproj \\\n  msvc/gtest_main.vcproj \\\n  msvc/gtest_prod_test-md.vcproj \\\n  msvc/gtest_prod_test.vcproj \\\n  msvc/gtest_unittest-md.vcproj \\\n  msvc/gtest_unittest.vcproj\n\n# xcode project files\nEXTRA_DIST += \\\n  xcode/Config/DebugProject.xcconfig \\\n  xcode/Config/FrameworkTarget.xcconfig \\\n  xcode/Config/General.xcconfig \\\n  xcode/Config/ReleaseProject.xcconfig \\\n  xcode/Config/StaticLibraryTarget.xcconfig \\\n  xcode/Config/TestTarget.xcconfig \\\n  xcode/Resources/Info.plist \\\n  xcode/Scripts/runtests.sh \\\n  xcode/Scripts/versiongenerate.py \\\n  xcode/gtest.xcodeproj/project.pbxproj\n\n# xcode sample files\nEXTRA_DIST += \\\n  xcode/Samples/FrameworkSample/Info.plist \\\n  xcode/Samples/FrameworkSample/WidgetFramework.xcodeproj/project.pbxproj \\\n  xcode/Samples/FrameworkSample/runtests.sh \\\n  xcode/Samples/FrameworkSample/widget.cc \\\n  xcode/Samples/FrameworkSample/widget.h \\\n  xcode/Samples/FrameworkSample/widget_test.cc\n\n# C++Builder project files\nEXTRA_DIST += \\\n  codegear/gtest.cbproj \\\n  codegear/gtest.groupproj \\\n  codegear/gtest_all.cc \\\n  codegear/gtest_link.cc \\\n  codegear/gtest_main.cbproj \\\n  codegear/gtest_unittest.cbproj\n\n# Distribute and install M4 macro\nm4datadir = $(datadir)/aclocal\nm4data_DATA = m4/gtest.m4\nEXTRA_DIST += $(m4data_DATA)\n\n# We define the global AM_CPPFLAGS as everything we compile includes from these\n# directories.\nAM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/include\n\n# Modifies compiler and linker flags for pthreads compatibility.\nif HAVE_PTHREADS\n  AM_CXXFLAGS = @PTHREAD_CFLAGS@ -DGTEST_HAS_PTHREAD=1\n  AM_LIBS = @PTHREAD_LIBS@\nelse\n  AM_CXXFLAGS = -DGTEST_HAS_PTHREAD=0\nendif\n\n# Build rules for libraries.\nlib_LTLIBRARIES = lib/libgtest.la lib/libgtest_main.la\n\nlib_libgtest_la_SOURCES = src/gtest-all.cc\n\npkginclude_HEADERS = \\\n  include/gtest/gtest-death-test.h \\\n  include/gtest/gtest-message.h \\\n  include/gtest/gtest-param-test.h \\\n  include/gtest/gtest-printers.h \\\n  include/gtest/gtest-spi.h \\\n  include/gtest/gtest-test-part.h \\\n  include/gtest/gtest-typed-test.h \\\n  include/gtest/gtest.h \\\n  include/gtest/gtest_pred_impl.h \\\n  include/gtest/gtest_prod.h\n\npkginclude_internaldir = $(pkgincludedir)/internal\npkginclude_internal_HEADERS = \\\n  include/gtest/internal/gtest-death-test-internal.h \\\n  include/gtest/internal/gtest-filepath.h \\\n  include/gtest/internal/gtest-internal.h \\\n  include/gtest/internal/gtest-linked_ptr.h \\\n  include/gtest/internal/gtest-param-util-generated.h \\\n  include/gtest/internal/gtest-param-util.h \\\n  include/gtest/internal/gtest-port.h \\\n  include/gtest/internal/gtest-string.h \\\n  include/gtest/internal/gtest-tuple.h \\\n  include/gtest/internal/gtest-type-util.h\n\nlib_libgtest_main_la_SOURCES = src/gtest_main.cc\nlib_libgtest_main_la_LIBADD = lib/libgtest.la\n\n# Bulid rules for samples and tests. Automake's naming for some of\n# these variables isn't terribly obvious, so this is a brief\n# reference:\n#\n# TESTS -- Programs run automatically by \"make check\"\n# check_PROGRAMS -- Programs built by \"make check\" but not necessarily run\n\nnoinst_LTLIBRARIES = samples/libsamples.la\n\nsamples_libsamples_la_SOURCES = \\\n  samples/sample1.cc \\\n  samples/sample1.h \\\n  samples/sample2.cc \\\n  samples/sample2.h \\\n  samples/sample3-inl.h \\\n  samples/sample4.cc \\\n  samples/sample4.h\n\nTESTS=\nTESTS_ENVIRONMENT = GTEST_SOURCE_DIR=\"$(srcdir)/test\" \\\n                    GTEST_BUILD_DIR=\"$(top_builddir)/test\"\ncheck_PROGRAMS=\n\n# A simple sample on using gtest.\nTESTS += samples/sample1_unittest\ncheck_PROGRAMS += samples/sample1_unittest\nsamples_sample1_unittest_SOURCES = samples/sample1_unittest.cc\nsamples_sample1_unittest_LDADD = lib/libgtest_main.la \\\n                                 lib/libgtest.la \\\n                                 samples/libsamples.la\n\n# Another sample.  It also verifies that libgtest works.\nTESTS += samples/sample10_unittest\ncheck_PROGRAMS += samples/sample10_unittest\nsamples_sample10_unittest_SOURCES = samples/sample10_unittest.cc\nsamples_sample10_unittest_LDADD = lib/libgtest.la\n\n# This tests most constructs of gtest and verifies that libgtest_main\n# and libgtest work.\nTESTS += test/gtest_all_test\ncheck_PROGRAMS += test/gtest_all_test\ntest_gtest_all_test_SOURCES = test/gtest_all_test.cc\ntest_gtest_all_test_LDADD = lib/libgtest_main.la \\\n                            lib/libgtest.la\n\n# Tests that fused gtest files compile and work.\nFUSED_GTEST_SRC = \\\n  fused-src/gtest/gtest-all.cc \\\n  fused-src/gtest/gtest.h \\\n  fused-src/gtest/gtest_main.cc\n\nif HAVE_PYTHON\nTESTS += test/fused_gtest_test\ncheck_PROGRAMS += test/fused_gtest_test\ntest_fused_gtest_test_SOURCES = $(FUSED_GTEST_SRC) \\\n                                samples/sample1.cc samples/sample1_unittest.cc\ntest_fused_gtest_test_CPPFLAGS = -I\"$(srcdir)/fused-src\"\n\n# Build rules for putting fused Google Test files into the distribution\n# package. The user can also create those files by manually running\n# scripts/fuse_gtest_files.py.\n$(test_fused_gtest_test_SOURCES): fused-gtest\n\nfused-gtest: $(pkginclude_HEADERS) $(pkginclude_internal_HEADERS) \\\n             $(GTEST_SRC) src/gtest-all.cc src/gtest_main.cc \\\n             scripts/fuse_gtest_files.py\n\tmkdir -p \"$(srcdir)/fused-src\"\n\tchmod -R u+w \"$(srcdir)/fused-src\"\n\trm -f \"$(srcdir)/fused-src/gtest/gtest-all.cc\"\n\trm -f \"$(srcdir)/fused-src/gtest/gtest.h\"\n\t\"$(srcdir)/scripts/fuse_gtest_files.py\" \"$(srcdir)/fused-src\"\n\tcp -f \"$(srcdir)/src/gtest_main.cc\" \"$(srcdir)/fused-src/gtest/\"\n\nmaintainer-clean-local:\n\trm -rf \"$(srcdir)/fused-src\"\nendif\n\n# Death tests may produce core dumps in the build directory. In case\n# this happens, clean them to keep distcleancheck happy.\nCLEANFILES = core\n\n# Disables 'make install' as installing a compiled version of Google\n# Test can lead to undefined behavior due to violation of the\n# One-Definition Rule.\n\ninstall-exec-local:\n\techo \"'make install' is dangerous and not supported. Instead, see README for how to integrate Google Test into your build system.\"\n\tfalse\n\ninstall-data-local:\n\techo \"'make install' is dangerous and not supported. Instead, see README for how to integrate Google Test into your build system.\"\n\tfalse\n"
  },
  {
    "path": "ext/gtest/README",
    "content": "Google C++ Testing Framework\n============================\n\nhttp://code.google.com/p/googletest/\n\nOverview\n--------\n\nGoogle's framework for writing C++ tests on a variety of platforms\n(Linux, Mac OS X, Windows, Windows CE, Symbian, etc).  Based on the\nxUnit architecture.  Supports automatic test discovery, a rich set of\nassertions, user-defined assertions, death tests, fatal and non-fatal\nfailures, various options for running the tests, and XML test report\ngeneration.\n\nPlease see the project page above for more information as well as the\nmailing list for questions, discussions, and development.  There is\nalso an IRC channel on OFTC (irc.oftc.net) #gtest available.  Please\njoin us!\n\nRequirements for End Users\n--------------------------\n\nGoogle Test is designed to have fairly minimal requirements to build\nand use with your projects, but there are some.  Currently, we support\nLinux, Windows, Mac OS X, and Cygwin.  We will also make our best\neffort to support other platforms (e.g. Solaris, AIX, and z/OS).\nHowever, since core members of the Google Test project have no access\nto these platforms, Google Test may have outstanding issues there.  If\nyou notice any problems on your platform, please notify\ngoogletestframework@googlegroups.com.  Patches for fixing them are\neven more welcome!\n\n### Linux Requirements ###\n\nThese are the base requirements to build and use Google Test from a source\npackage (as described below):\n  * GNU-compatible Make or gmake\n  * POSIX-standard shell\n  * POSIX(-2) Regular Expressions (regex.h)\n  * A C++98-standard-compliant compiler\n\n### Windows Requirements ###\n\n  * Microsoft Visual C++ 7.1 or newer\n\n### Cygwin Requirements ###\n\n  * Cygwin 1.5.25-14 or newer\n\n### Mac OS X Requirements ###\n\n  * Mac OS X 10.4 Tiger or newer\n  * Developer Tools Installed\n\nAlso, you'll need CMake 2.6.4 or higher if you want to build the\nsamples using the provided CMake script, regardless of the platform.\n\nRequirements for Contributors\n-----------------------------\n\nWe welcome patches.  If you plan to contribute a patch, you need to\nbuild Google Test and its own tests from an SVN checkout (described\nbelow), which has further requirements:\n\n  * Python version 2.3 or newer (for running some of the tests and\n    re-generating certain source files from templates)\n  * CMake 2.6.4 or newer\n\nGetting the Source\n------------------\n\nThere are two primary ways of getting Google Test's source code: you\ncan download a stable source release in your preferred archive format,\nor directly check out the source from our Subversion (SVN) repositary.\nThe SVN checkout requires a few extra steps and some extra software\npackages on your system, but lets you track the latest development and\nmake patches much more easily, so we highly encourage it.\n\n### Source Package ###\n\nGoogle Test is released in versioned source packages which can be\ndownloaded from the download page [1].  Several different archive\nformats are provided, but the only difference is the tools used to\nmanipulate them, and the size of the resulting file.  Download\nwhichever you are most comfortable with.\n\n  [1] http://code.google.com/p/googletest/downloads/list\n\nOnce the package is downloaded, expand it using whichever tools you\nprefer for that type.  This will result in a new directory with the\nname \"gtest-X.Y.Z\" which contains all of the source code.  Here are\nsome examples on Linux:\n\n  tar -xvzf gtest-X.Y.Z.tar.gz\n  tar -xvjf gtest-X.Y.Z.tar.bz2\n  unzip gtest-X.Y.Z.zip\n\n### SVN Checkout ###\n\nTo check out the main branch (also known as the \"trunk\") of Google\nTest, run the following Subversion command:\n\n  svn checkout http://googletest.googlecode.com/svn/trunk/ gtest-svn\n\nSetting up the Build\n--------------------\n\nTo build Google Test and your tests that use it, you need to tell your\nbuild system where to find its headers and source files.  The exact\nway to do it depends on which build system you use, and is usually\nstraightforward.\n\n### Generic Build Instructions ###\n\nSuppose you put Google Test in directory ${GTEST_DIR}.  To build it,\ncreate a library build target (or a project as called by Visual Studio\nand Xcode) to compile\n\n  ${GTEST_DIR}/src/gtest-all.cc\n\nwith ${GTEST_DIR}/include in the system header search path and ${GTEST_DIR}\nin the normal header search path.  Assuming a Linux-like system and gcc,\nsomething like the following will do:\n\n  g++ -isystem ${GTEST_DIR}/include -I${GTEST_DIR} \\\n      -pthread -c ${GTEST_DIR}/src/gtest-all.cc\n  ar -rv libgtest.a gtest-all.o\n\n(We need -pthread as Google Test uses threads.)\n\nNext, you should compile your test source file with\n${GTEST_DIR}/include in the system header search path, and link it\nwith gtest and any other necessary libraries:\n\n  g++ -isystem ${GTEST_DIR}/include -pthread path/to/your_test.cc libgtest.a \\\n      -o your_test\n\nAs an example, the make/ directory contains a Makefile that you can\nuse to build Google Test on systems where GNU make is available\n(e.g. Linux, Mac OS X, and Cygwin).  It doesn't try to build Google\nTest's own tests.  Instead, it just builds the Google Test library and\na sample test.  You can use it as a starting point for your own build\nscript.\n\nIf the default settings are correct for your environment, the\nfollowing commands should succeed:\n\n  cd ${GTEST_DIR}/make\n  make\n  ./sample1_unittest\n\nIf you see errors, try to tweak the contents of make/Makefile to make\nthem go away.  There are instructions in make/Makefile on how to do\nit.\n\n### Using CMake ###\n\nGoogle Test comes with a CMake build script (CMakeLists.txt) that can\nbe used on a wide range of platforms (\"C\" stands for cross-platofrm.).\nIf you don't have CMake installed already, you can download it for\nfree from http://www.cmake.org/.\n\nCMake works by generating native makefiles or build projects that can\nbe used in the compiler environment of your choice.  The typical\nworkflow starts with:\n\n  mkdir mybuild       # Create a directory to hold the build output.\n  cd mybuild\n  cmake ${GTEST_DIR}  # Generate native build scripts.\n\nIf you want to build Google Test's samples, you should replace the\nlast command with\n\n  cmake -Dgtest_build_samples=ON ${GTEST_DIR}\n\nIf you are on a *nix system, you should now see a Makefile in the\ncurrent directory.  Just type 'make' to build gtest.\n\nIf you use Windows and have Vistual Studio installed, a gtest.sln file\nand several .vcproj files will be created.  You can then build them\nusing Visual Studio.\n\nOn Mac OS X with Xcode installed, a .xcodeproj file will be generated.\n\n### Legacy Build Scripts ###\n\nBefore settling on CMake, we have been providing hand-maintained build\nprojects/scripts for Visual Studio, Xcode, and Autotools.  While we\ncontinue to provide them for convenience, they are not actively\nmaintained any more.  We highly recommend that you follow the\ninstructions in the previous two sections to integrate Google Test\nwith your existing build system.\n\nIf you still need to use the legacy build scripts, here's how:\n\nThe msvc\\ folder contains two solutions with Visual C++ projects.\nOpen the gtest.sln or gtest-md.sln file using Visual Studio, and you\nare ready to build Google Test the same way you build any Visual\nStudio project.  Files that have names ending with -md use DLL\nversions of Microsoft runtime libraries (the /MD or the /MDd compiler\noption).  Files without that suffix use static versions of the runtime\nlibraries (the /MT or the /MTd option).  Please note that one must use\nthe same option to compile both gtest and the test code.  If you use\nVisual Studio 2005 or above, we recommend the -md version as /MD is\nthe default for new projects in these versions of Visual Studio.\n\nOn Mac OS X, open the gtest.xcodeproj in the xcode/ folder using\nXcode.  Build the \"gtest\" target.  The universal binary framework will\nend up in your selected build directory (selected in the Xcode\n\"Preferences...\" -> \"Building\" pane and defaults to xcode/build).\nAlternatively, at the command line, enter:\n\n  xcodebuild\n\nThis will build the \"Release\" configuration of gtest.framework in your\ndefault build location.  See the \"xcodebuild\" man page for more\ninformation about building different configurations and building in\ndifferent locations.\n\nIf you wish to use the Google Test Xcode project with Xcode 4.x and\nabove, you need to either:\n * update the SDK configuration options in xcode/Config/General.xconfig.\n   Comment options SDKROOT, MACOS_DEPLOYMENT_TARGET, and GCC_VERSION. If\n   you choose this route you lose the ability to target earlier versions\n   of MacOS X.\n * Install an SDK for an earlier version. This doesn't appear to be\n   supported by Apple, but has been reported to work\n   (http://stackoverflow.com/questions/5378518).\n\nTweaking Google Test\n--------------------\n\nGoogle Test can be used in diverse environments.  The default\nconfiguration may not work (or may not work well) out of the box in\nsome environments.  However, you can easily tweak Google Test by\ndefining control macros on the compiler command line.  Generally,\nthese macros are named like GTEST_XYZ and you define them to either 1\nor 0 to enable or disable a certain feature.\n\nWe list the most frequently used macros below.  For a complete list,\nsee file include/gtest/internal/gtest-port.h.\n\n### Choosing a TR1 Tuple Library ###\n\nSome Google Test features require the C++ Technical Report 1 (TR1)\ntuple library, which is not yet available with all compilers.  The\ngood news is that Google Test implements a subset of TR1 tuple that's\nenough for its own need, and will automatically use this when the\ncompiler doesn't provide TR1 tuple.\n\nUsually you don't need to care about which tuple library Google Test\nuses.  However, if your project already uses TR1 tuple, you need to\ntell Google Test to use the same TR1 tuple library the rest of your\nproject uses, or the two tuple implementations will clash.  To do\nthat, add\n\n  -DGTEST_USE_OWN_TR1_TUPLE=0\n\nto the compiler flags while compiling Google Test and your tests.  If\nyou want to force Google Test to use its own tuple library, just add\n\n  -DGTEST_USE_OWN_TR1_TUPLE=1\n\nto the compiler flags instead.\n\nIf you don't want Google Test to use tuple at all, add\n\n  -DGTEST_HAS_TR1_TUPLE=0\n\nand all features using tuple will be disabled.\n\n### Multi-threaded Tests ###\n\nGoogle Test is thread-safe where the pthread library is available.\nAfter #include \"gtest/gtest.h\", you can check the GTEST_IS_THREADSAFE\nmacro to see whether this is the case (yes if the macro is #defined to\n1, no if it's undefined.).\n\nIf Google Test doesn't correctly detect whether pthread is available\nin your environment, you can force it with\n\n  -DGTEST_HAS_PTHREAD=1\n\nor\n\n  -DGTEST_HAS_PTHREAD=0\n\nWhen Google Test uses pthread, you may need to add flags to your\ncompiler and/or linker to select the pthread library, or you'll get\nlink errors.  If you use the CMake script or the deprecated Autotools\nscript, this is taken care of for you.  If you use your own build\nscript, you'll need to read your compiler and linker's manual to\nfigure out what flags to add.\n\n### As a Shared Library (DLL) ###\n\nGoogle Test is compact, so most users can build and link it as a\nstatic library for the simplicity.  You can choose to use Google Test\nas a shared library (known as a DLL on Windows) if you prefer.\n\nTo compile *gtest* as a shared library, add\n\n  -DGTEST_CREATE_SHARED_LIBRARY=1\n\nto the compiler flags.  You'll also need to tell the linker to produce\na shared library instead - consult your linker's manual for how to do\nit.\n\nTo compile your *tests* that use the gtest shared library, add\n\n  -DGTEST_LINKED_AS_SHARED_LIBRARY=1\n\nto the compiler flags.\n\nNote: while the above steps aren't technically necessary today when\nusing some compilers (e.g. GCC), they may become necessary in the\nfuture, if we decide to improve the speed of loading the library (see\nhttp://gcc.gnu.org/wiki/Visibility for details).  Therefore you are\nrecommended to always add the above flags when using Google Test as a\nshared library.  Otherwise a future release of Google Test may break\nyour build script.\n\n### Avoiding Macro Name Clashes ###\n\nIn C++, macros don't obey namespaces.  Therefore two libraries that\nboth define a macro of the same name will clash if you #include both\ndefinitions.  In case a Google Test macro clashes with another\nlibrary, you can force Google Test to rename its macro to avoid the\nconflict.\n\nSpecifically, if both Google Test and some other code define macro\nFOO, you can add\n\n  -DGTEST_DONT_DEFINE_FOO=1\n\nto the compiler flags to tell Google Test to change the macro's name\nfrom FOO to GTEST_FOO.  Currently FOO can be FAIL, SUCCEED, or TEST.\nFor example, with -DGTEST_DONT_DEFINE_TEST=1, you'll need to write\n\n  GTEST_TEST(SomeTest, DoesThis) { ... }\n\ninstead of\n\n  TEST(SomeTest, DoesThis) { ... }\n\nin order to define a test.\n\nUpgrating from an Earlier Version\n---------------------------------\n\nWe strive to keep Google Test releases backward compatible.\nSometimes, though, we have to make some breaking changes for the\nusers' long-term benefits.  This section describes what you'll need to\ndo if you are upgrading from an earlier version of Google Test.\n\n### Upgrading from 1.3.0 or Earlier ###\n\nYou may need to explicitly enable or disable Google Test's own TR1\ntuple library.  See the instructions in section \"Choosing a TR1 Tuple\nLibrary\".\n\n### Upgrading from 1.4.0 or Earlier ###\n\nThe Autotools build script (configure + make) is no longer officially\nsupportted.  You are encouraged to migrate to your own build system or\nuse CMake.  If you still need to use Autotools, you can find\ninstructions in the README file from Google Test 1.4.0.\n\nOn platforms where the pthread library is available, Google Test uses\nit in order to be thread-safe.  See the \"Multi-threaded Tests\" section\nfor what this means to your build script.\n\nIf you use Microsoft Visual C++ 7.1 with exceptions disabled, Google\nTest will no longer compile.  This should affect very few people, as a\nlarge portion of STL (including <string>) doesn't compile in this mode\nanyway.  We decided to stop supporting it in order to greatly simplify\nGoogle Test's implementation.\n\nDeveloping Google Test\n----------------------\n\nThis section discusses how to make your own changes to Google Test.\n\n### Testing Google Test Itself ###\n\nTo make sure your changes work as intended and don't break existing\nfunctionality, you'll want to compile and run Google Test's own tests.\nFor that you can use CMake:\n\n  mkdir mybuild\n  cd mybuild\n  cmake -Dgtest_build_tests=ON ${GTEST_DIR}\n\nMake sure you have Python installed, as some of Google Test's tests\nare written in Python.  If the cmake command complains about not being\nable to find Python (\"Could NOT find PythonInterp (missing:\nPYTHON_EXECUTABLE)\"), try telling it explicitly where your Python\nexecutable can be found:\n\n  cmake -DPYTHON_EXECUTABLE=path/to/python -Dgtest_build_tests=ON ${GTEST_DIR}\n\nNext, you can build Google Test and all of its own tests.  On *nix,\nthis is usually done by 'make'.  To run the tests, do\n\n  make test\n\nAll tests should pass.\n\n### Regenerating Source Files ###\n\nSome of Google Test's source files are generated from templates (not\nin the C++ sense) using a script.  A template file is named FOO.pump,\nwhere FOO is the name of the file it will generate.  For example, the\nfile include/gtest/internal/gtest-type-util.h.pump is used to generate\ngtest-type-util.h in the same directory.\n\nNormally you don't need to worry about regenerating the source files,\nunless you need to modify them.  In that case, you should modify the\ncorresponding .pump files instead and run the pump.py Python script to\nregenerate them.  You can find pump.py in the scripts/ directory.\nRead the Pump manual [2] for how to use it.\n\n  [2] http://code.google.com/p/googletest/wiki/PumpManual\n\n### Contributing a Patch ###\n\nWe welcome patches.  Please read the Google Test developer's guide [3]\nfor how you can contribute.  In particular, make sure you have signed\nthe Contributor License Agreement, or we won't be able to accept the\npatch.\n\n  [3] http://code.google.com/p/googletest/wiki/GoogleTestDevGuide\n\nHappy testing!\n"
  },
  {
    "path": "ext/gtest/build-aux/.keep",
    "content": ""
  },
  {
    "path": "ext/gtest/cmake/internal_utils.cmake",
    "content": "# Defines functions and macros useful for building Google Test and\n# Google Mock.\n#\n# Note:\n#\n# - This file will be run twice when building Google Mock (once via\n#   Google Test's CMakeLists.txt, and once via Google Mock's).\n#   Therefore it shouldn't have any side effects other than defining\n#   the functions and macros.\n#\n# - The functions/macros defined in this file may depend on Google\n#   Test and Google Mock's option() definitions, and thus must be\n#   called *after* the options have been defined.\n\n# Tweaks CMake's default compiler/linker settings to suit Google Test's needs.\n#\n# This must be a macro(), as inside a function string() can only\n# update variables in the function scope.\nmacro(fix_default_compiler_settings_)\n  if (MSVC)\n    # For MSVC, CMake sets certain flags to defaults we want to override.\n    # This replacement code is taken from sample in the CMake Wiki at\n    # http://www.cmake.org/Wiki/CMake_FAQ#Dynamic_Replace.\n    foreach (flag_var\n             CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE\n             CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)\n      if (NOT BUILD_SHARED_LIBS AND NOT gtest_force_shared_crt)\n        # When Google Test is built as a shared library, it should also use\n        # shared runtime libraries.  Otherwise, it may end up with multiple\n        # copies of runtime library data in different modules, resulting in\n        # hard-to-find crashes. When it is built as a static library, it is\n        # preferable to use CRT as static libraries, as we don't have to rely\n        # on CRT DLLs being available. CMake always defaults to using shared\n        # CRT libraries, so we override that default here.\n        string(REPLACE \"/MD\" \"-MT\" ${flag_var} \"${${flag_var}}\")\n      endif()\n\n      # We prefer more strict warning checking for building Google Test.\n      # Replaces /W3 with /W4 in defaults.\n      string(REPLACE \"/W3\" \"-W4\" ${flag_var} \"${${flag_var}}\")\n    endforeach()\n  endif()\nendmacro()\n\n# Defines the compiler/linker flags used to build Google Test and\n# Google Mock.  You can tweak these definitions to suit your need.  A\n# variable's value is empty before it's explicitly assigned to.\nmacro(config_compiler_and_linker)\n  if (NOT gtest_disable_pthreads)\n    # Defines CMAKE_USE_PTHREADS_INIT and CMAKE_THREAD_LIBS_INIT.\n    find_package(Threads)\n  endif()\n\n  fix_default_compiler_settings_()\n  if (MSVC)\n    # Newlines inside flags variables break CMake's NMake generator.\n    # TODO(vladl@google.com): Add -RTCs and -RTCu to debug builds.\n    set(cxx_base_flags \"-GS -W4 -WX -wd4127 -wd4251 -wd4275 -nologo -J -Zi\")\n    if (MSVC_VERSION LESS 1400)\n      # Suppress spurious warnings MSVC 7.1 sometimes issues.\n      # Forcing value to bool.\n      set(cxx_base_flags \"${cxx_base_flags} -wd4800\")\n      # Copy constructor and assignment operator could not be generated.\n      set(cxx_base_flags \"${cxx_base_flags} -wd4511 -wd4512\")\n      # Compatibility warnings not applicable to Google Test.\n      # Resolved overload was found by argument-dependent lookup.\n      set(cxx_base_flags \"${cxx_base_flags} -wd4675\")\n    endif()\n    set(cxx_base_flags \"${cxx_base_flags} -D_UNICODE -DUNICODE -DWIN32 -D_WIN32\")\n    set(cxx_base_flags \"${cxx_base_flags} -DSTRICT -DWIN32_LEAN_AND_MEAN\")\n    set(cxx_exception_flags \"-EHsc -D_HAS_EXCEPTIONS=1\")\n    set(cxx_no_exception_flags \"-D_HAS_EXCEPTIONS=0\")\n    set(cxx_no_rtti_flags \"-GR-\")\n  elseif (CMAKE_COMPILER_IS_GNUCXX)\n    set(cxx_base_flags \"-Wall -Wshadow\")\n    set(cxx_exception_flags \"-fexceptions\")\n    set(cxx_no_exception_flags \"-fno-exceptions\")\n    # Until version 4.3.2, GCC doesn't define a macro to indicate\n    # whether RTTI is enabled.  Therefore we define GTEST_HAS_RTTI\n    # explicitly.\n    set(cxx_no_rtti_flags \"-fno-rtti -DGTEST_HAS_RTTI=0\")\n    set(cxx_strict_flags\n      \"-Wextra -Wno-unused-parameter -Wno-missing-field-initializers\")\n  elseif (CMAKE_CXX_COMPILER_ID STREQUAL \"SunPro\")\n    set(cxx_exception_flags \"-features=except\")\n    # Sun Pro doesn't provide macros to indicate whether exceptions and\n    # RTTI are enabled, so we define GTEST_HAS_* explicitly.\n    set(cxx_no_exception_flags \"-features=no%except -DGTEST_HAS_EXCEPTIONS=0\")\n    set(cxx_no_rtti_flags \"-features=no%rtti -DGTEST_HAS_RTTI=0\")\n  elseif (CMAKE_CXX_COMPILER_ID STREQUAL \"VisualAge\" OR\n      CMAKE_CXX_COMPILER_ID STREQUAL \"XL\")\n    # CMake 2.8 changes Visual Age's compiler ID to \"XL\".\n    set(cxx_exception_flags \"-qeh\")\n    set(cxx_no_exception_flags \"-qnoeh\")\n    # Until version 9.0, Visual Age doesn't define a macro to indicate\n    # whether RTTI is enabled.  Therefore we define GTEST_HAS_RTTI\n    # explicitly.\n    set(cxx_no_rtti_flags \"-qnortti -DGTEST_HAS_RTTI=0\")\n  elseif (CMAKE_CXX_COMPILER_ID STREQUAL \"HP\")\n    set(cxx_base_flags \"-AA -mt\")\n    set(cxx_exception_flags \"-DGTEST_HAS_EXCEPTIONS=1\")\n    set(cxx_no_exception_flags \"+noeh -DGTEST_HAS_EXCEPTIONS=0\")\n    # RTTI can not be disabled in HP aCC compiler.\n    set(cxx_no_rtti_flags \"\")\n  endif()\n\n  if (CMAKE_USE_PTHREADS_INIT)  # The pthreads library is available and allowed.\n    set(cxx_base_flags \"${cxx_base_flags} -DGTEST_HAS_PTHREAD=1\")\n  else()\n    set(cxx_base_flags \"${cxx_base_flags} -DGTEST_HAS_PTHREAD=0\")\n  endif()\n\n  # For building gtest's own tests and samples.\n  set(cxx_exception \"${CMAKE_CXX_FLAGS} ${cxx_base_flags} ${cxx_exception_flags}\")\n  set(cxx_no_exception\n    \"${CMAKE_CXX_FLAGS} ${cxx_base_flags} ${cxx_no_exception_flags}\")\n  set(cxx_default \"${cxx_exception}\")\n  set(cxx_no_rtti \"${cxx_default} ${cxx_no_rtti_flags}\")\n  set(cxx_use_own_tuple \"${cxx_default} -DGTEST_USE_OWN_TR1_TUPLE=1\")\n\n  # For building the gtest libraries.\n  set(cxx_strict \"${cxx_default} ${cxx_strict_flags}\")\nendmacro()\n\n# Defines the gtest & gtest_main libraries.  User tests should link\n# with one of them.\nfunction(cxx_library_with_type name type cxx_flags)\n  # type can be either STATIC or SHARED to denote a static or shared library.\n  # ARGN refers to additional arguments after 'cxx_flags'.\n  add_library(${name} ${type} ${ARGN})\n  set_target_properties(${name}\n    PROPERTIES\n    COMPILE_FLAGS \"${cxx_flags}\")\n  if (BUILD_SHARED_LIBS OR type STREQUAL \"SHARED\")\n    set_target_properties(${name}\n      PROPERTIES\n      COMPILE_DEFINITIONS \"GTEST_CREATE_SHARED_LIBRARY=1\")\n  endif()\n  if (CMAKE_USE_PTHREADS_INIT)\n    target_link_libraries(${name} ${CMAKE_THREAD_LIBS_INIT})\n  endif()\nendfunction()\n\n########################################################################\n#\n# Helper functions for creating build targets.\n\nfunction(cxx_shared_library name cxx_flags)\n  cxx_library_with_type(${name} SHARED \"${cxx_flags}\" ${ARGN})\nendfunction()\n\nfunction(cxx_library name cxx_flags)\n  cxx_library_with_type(${name} \"\" \"${cxx_flags}\" ${ARGN})\nendfunction()\n\n# cxx_executable_with_flags(name cxx_flags libs srcs...)\n#\n# creates a named C++ executable that depends on the given libraries and\n# is built from the given source files with the given compiler flags.\nfunction(cxx_executable_with_flags name cxx_flags libs)\n  add_executable(${name} ${ARGN})\n  if (cxx_flags)\n    set_target_properties(${name}\n      PROPERTIES\n      COMPILE_FLAGS \"${cxx_flags}\")\n  endif()\n  if (BUILD_SHARED_LIBS)\n    set_target_properties(${name}\n      PROPERTIES\n      COMPILE_DEFINITIONS \"GTEST_LINKED_AS_SHARED_LIBRARY=1\")\n  endif()\n  # To support mixing linking in static and dynamic libraries, link each\n  # library in with an extra call to target_link_libraries.\n  foreach (lib \"${libs}\")\n    target_link_libraries(${name} ${lib})\n  endforeach()\nendfunction()\n\n# cxx_executable(name dir lib srcs...)\n#\n# creates a named target that depends on the given libs and is built\n# from the given source files.  dir/name.cc is implicitly included in\n# the source file list.\nfunction(cxx_executable name dir libs)\n  cxx_executable_with_flags(\n    ${name} \"${cxx_default}\" \"${libs}\" \"${dir}/${name}.cc\" ${ARGN})\nendfunction()\n\n# Sets PYTHONINTERP_FOUND and PYTHON_EXECUTABLE.\nfind_package(PythonInterp)\n\n# cxx_test_with_flags(name cxx_flags libs srcs...)\n#\n# creates a named C++ test that depends on the given libs and is built\n# from the given source files with the given compiler flags.\nfunction(cxx_test_with_flags name cxx_flags libs)\n  cxx_executable_with_flags(${name} \"${cxx_flags}\" \"${libs}\" ${ARGN})\n  add_test(${name} ${name})\nendfunction()\n\n# cxx_test(name libs srcs...)\n#\n# creates a named test target that depends on the given libs and is\n# built from the given source files.  Unlike cxx_test_with_flags,\n# test/name.cc is already implicitly included in the source file list.\nfunction(cxx_test name libs)\n  cxx_test_with_flags(\"${name}\" \"${cxx_default}\" \"${libs}\"\n    \"test/${name}.cc\" ${ARGN})\nendfunction()\n\n# py_test(name)\n#\n# creates a Python test with the given name whose main module is in\n# test/name.py.  It does nothing if Python is not installed.\nfunction(py_test name)\n  # We are not supporting Python tests on Linux yet as they consider\n  # all Linux environments to be google3 and try to use google3 features.\n  if (PYTHONINTERP_FOUND)\n    # ${CMAKE_BINARY_DIR} is known at configuration time, so we can\n    # directly bind it from cmake. ${CTEST_CONFIGURATION_TYPE} is known\n    # only at ctest runtime (by calling ctest -c <Configuration>), so\n    # we have to escape $ to delay variable substitution here.\n    add_test(${name}\n      ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py\n          --build_dir=${CMAKE_CURRENT_BINARY_DIR}/\\${CTEST_CONFIGURATION_TYPE})\n  endif()\nendfunction()\n"
  },
  {
    "path": "ext/gtest/codegear/gtest.cbproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <PropertyGroup>\r\n    <ProjectGuid>{bca37a72-5b07-46cf-b44e-89f8e06451a2}</ProjectGuid>\r\n    <Config Condition=\"'$(Config)'==''\">Release</Config>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Config)'=='Base' or '$(Base)'!=''\">\r\n    <Base>true</Base>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Config)'=='Debug' or '$(Cfg_1)'!=''\">\r\n    <Base>true</Base>\r\n    <Cfg_1>true</Cfg_1>\r\n    <CfgParent>Base</CfgParent>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Config)'=='Release' or '$(Cfg_2)'!=''\">\r\n    <Base>true</Base>\r\n    <Cfg_2>true</Cfg_2>\r\n    <CfgParent>Base</CfgParent>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Base)'!=''\">\r\n    <BCC_OptimizeForSpeed>true</BCC_OptimizeForSpeed>\r\n    <OutputExt>lib</OutputExt>\r\n    <DCC_CBuilderOutput>JPHNE</DCC_CBuilderOutput>\r\n    <Defines>NO_STRICT</Defines>\r\n    <DynamicRTL>true</DynamicRTL>\r\n    <UsePackages>true</UsePackages>\r\n    <ProjectType>CppStaticLibrary</ProjectType>\r\n    <BCC_CPPCompileAlways>true</BCC_CPPCompileAlways>\r\n    <PackageImports>rtl.bpi;vcl.bpi;bcbie.bpi;vclx.bpi;vclactnband.bpi;xmlrtl.bpi;bcbsmp.bpi;dbrtl.bpi;vcldb.bpi;bdertl.bpi;vcldbx.bpi;dsnap.bpi;dsnapcon.bpi;vclib.bpi;ibxpress.bpi;adortl.bpi;dbxcds.bpi;dbexpress.bpi;DbxCommonDriver.bpi;websnap.bpi;vclie.bpi;webdsnap.bpi;inet.bpi;inetdbbde.bpi;inetdbxpress.bpi;soaprtl.bpi;Rave75VCL.bpi;teeUI.bpi;tee.bpi;teedb.bpi;IndyCore.bpi;IndySystem.bpi;IndyProtocols.bpi;IntrawebDB_90_100.bpi;Intraweb_90_100.bpi;dclZipForged11.bpi;vclZipForged11.bpi;GR32_BDS2006.bpi;GR32_DSGN_BDS2006.bpi;Jcl.bpi;JclVcl.bpi;JvCoreD11R.bpi;JvSystemD11R.bpi;JvStdCtrlsD11R.bpi;JvAppFrmD11R.bpi;JvBandsD11R.bpi;JvDBD11R.bpi;JvDlgsD11R.bpi;JvBDED11R.bpi;JvCmpD11R.bpi;JvCryptD11R.bpi;JvCtrlsD11R.bpi;JvCustomD11R.bpi;JvDockingD11R.bpi;JvDotNetCtrlsD11R.bpi;JvEDID11R.bpi;JvGlobusD11R.bpi;JvHMID11R.bpi;JvInterpreterD11R.bpi;JvJansD11R.bpi;JvManagedThreadsD11R.bpi;JvMMD11R.bpi;JvNetD11R.bpi;JvPageCompsD11R.bpi;JvPluginD11R.bpi;JvPrintPreviewD11R.bpi;JvRuntimeDesignD11R.bpi;JvTimeFrameworkD11R.bpi;JvValidatorsD11R.bpi;JvWizardD11R.bpi;JvXPCtrlsD11R.bpi;VclSmp.bpi;CExceptionExpert11.bpi</PackageImports>\r\n    <BCC_wpar>false</BCC_wpar>\r\n    <IncludePath>$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\src;..\\include;..</IncludePath>\r\n    <AllPackageLibs>rtl.lib;vcl.lib</AllPackageLibs>\r\n    <TLIB_PageSize>32</TLIB_PageSize>\r\n    <ILINK_LibraryPath>$(BDS)\\lib;$(BDS)\\lib\\obj;$(BDS)\\lib\\psdk</ILINK_LibraryPath>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Cfg_1)'!=''\">\r\n    <BCC_OptimizeForSpeed>false</BCC_OptimizeForSpeed>\r\n    <DCC_Optimize>false</DCC_Optimize>\r\n    <DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>\r\n    <Defines>_DEBUG;$(Defines)</Defines>\r\n    <ILINK_FullDebugInfo>true</ILINK_FullDebugInfo>\r\n    <BCC_InlineFunctionExpansion>false</BCC_InlineFunctionExpansion>\r\n    <ILINK_DisableIncrementalLinking>true</ILINK_DisableIncrementalLinking>\r\n    <BCC_UseRegisterVariables>None</BCC_UseRegisterVariables>\r\n    <DCC_Define>DEBUG</DCC_Define>\r\n    <BCC_DebugLineNumbers>true</BCC_DebugLineNumbers>\r\n    <IntermediateOutputDir>Debug</IntermediateOutputDir>\r\n    <TASM_DisplaySourceLines>true</TASM_DisplaySourceLines>\r\n    <BCC_StackFrames>true</BCC_StackFrames>\r\n    <BCC_DisableOptimizations>true</BCC_DisableOptimizations>\r\n    <ILINK_LibraryPath>$(BDS)\\lib\\debug;$(ILINK_LibraryPath)</ILINK_LibraryPath>\r\n    <TASM_Debugging>Full</TASM_Debugging>\r\n    <BCC_SourceDebuggingOn>true</BCC_SourceDebuggingOn>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Cfg_2)'!=''\">\r\n    <Defines>NDEBUG;$(Defines)</Defines>\r\n    <IntermediateOutputDir>Release</IntermediateOutputDir>\r\n    <ILINK_LibraryPath>$(BDS)\\lib\\release;$(ILINK_LibraryPath)</ILINK_LibraryPath>\r\n    <TASM_Debugging>None</TASM_Debugging>\r\n  </PropertyGroup>\r\n  <ProjectExtensions>\r\n    <Borland.Personality>CPlusPlusBuilder.Personality</Borland.Personality>\r\n    <Borland.ProjectType>CppStaticLibrary</Borland.ProjectType>\r\n    <BorlandProject>\r\n<BorlandProject><CPlusPlusBuilder.Personality><VersionInfo><VersionInfo Name=\"IncludeVerInfo\">False</VersionInfo><VersionInfo Name=\"AutoIncBuild\">False</VersionInfo><VersionInfo Name=\"MajorVer\">1</VersionInfo><VersionInfo Name=\"MinorVer\">0</VersionInfo><VersionInfo Name=\"Release\">0</VersionInfo><VersionInfo Name=\"Build\">0</VersionInfo><VersionInfo Name=\"Debug\">False</VersionInfo><VersionInfo Name=\"PreRelease\">False</VersionInfo><VersionInfo Name=\"Special\">False</VersionInfo><VersionInfo Name=\"Private\">False</VersionInfo><VersionInfo Name=\"DLL\">False</VersionInfo><VersionInfo Name=\"Locale\">1033</VersionInfo><VersionInfo Name=\"CodePage\">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name=\"CompanyName\"></VersionInfoKeys><VersionInfoKeys Name=\"FileDescription\"></VersionInfoKeys><VersionInfoKeys Name=\"FileVersion\">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name=\"InternalName\"></VersionInfoKeys><VersionInfoKeys Name=\"LegalCopyright\"></VersionInfoKeys><VersionInfoKeys Name=\"LegalTrademarks\"></VersionInfoKeys><VersionInfoKeys Name=\"OriginalFilename\"></VersionInfoKeys><VersionInfoKeys Name=\"ProductName\"></VersionInfoKeys><VersionInfoKeys Name=\"ProductVersion\">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name=\"Comments\"></VersionInfoKeys></VersionInfoKeys><Debugging><Debugging Name=\"DebugSourceDirs\"></Debugging></Debugging><Parameters><Parameters Name=\"RunParams\"></Parameters><Parameters Name=\"Launcher\"></Parameters><Parameters Name=\"UseLauncher\">False</Parameters><Parameters Name=\"DebugCWD\"></Parameters><Parameters Name=\"HostApplication\"></Parameters><Parameters Name=\"RemoteHost\"></Parameters><Parameters Name=\"RemotePath\"></Parameters><Parameters Name=\"RemoteParams\"></Parameters><Parameters Name=\"RemoteLauncher\"></Parameters><Parameters Name=\"UseRemoteLauncher\">False</Parameters><Parameters Name=\"RemoteCWD\"></Parameters><Parameters Name=\"RemoteDebug\">False</Parameters><Parameters Name=\"Debug Symbols Search Path\"></Parameters><Parameters Name=\"LoadAllSymbols\">True</Parameters><Parameters Name=\"LoadUnspecifiedSymbols\">False</Parameters></Parameters><Excluded_Packages>\r\n      \r\n      \r\n      <Excluded_Packages Name=\"$(BDS)\\bin\\bcboffice2k100.bpl\">CodeGear C++Builder Office 2000 Servers Package</Excluded_Packages>\r\n      <Excluded_Packages Name=\"$(BDS)\\bin\\bcbofficexp100.bpl\">CodeGear C++Builder Office XP Servers Package</Excluded_Packages>\r\n    </Excluded_Packages><Linker><Linker Name=\"LibPrefix\"></Linker><Linker Name=\"LibSuffix\"></Linker><Linker Name=\"LibVersion\"></Linker></Linker><ProjectProperties><ProjectProperties Name=\"AutoShowDeps\">False</ProjectProperties><ProjectProperties Name=\"ManagePaths\">True</ProjectProperties><ProjectProperties Name=\"VerifyPackages\">True</ProjectProperties></ProjectProperties><HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Count\">3</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Item0\">$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\src;..\\include;..</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Item1\">$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\src;..\\include;..</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Item2\">$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\src;..\\src;..\\include</HistoryLists_hlIncludePath></HistoryLists_hlIncludePath><HistoryLists_hlILINK_LibraryPath><HistoryLists_hlILINK_LibraryPath Name=\"Count\">1</HistoryLists_hlILINK_LibraryPath><HistoryLists_hlILINK_LibraryPath Name=\"Item0\">$(BDS)\\lib;$(BDS)\\lib\\obj;$(BDS)\\lib\\psdk</HistoryLists_hlILINK_LibraryPath></HistoryLists_hlILINK_LibraryPath><HistoryLists_hlDefines><HistoryLists_hlDefines Name=\"Count\">1</HistoryLists_hlDefines><HistoryLists_hlDefines Name=\"Item0\">NO_STRICT</HistoryLists_hlDefines></HistoryLists_hlDefines><HistoryLists_hlTLIB_PageSize><HistoryLists_hlTLIB_PageSize Name=\"Count\">1</HistoryLists_hlTLIB_PageSize><HistoryLists_hlTLIB_PageSize Name=\"Item0\">32</HistoryLists_hlTLIB_PageSize><HistoryLists_hlTLIB_PageSize Name=\"Item1\">16</HistoryLists_hlTLIB_PageSize></HistoryLists_hlTLIB_PageSize></CPlusPlusBuilder.Personality></BorlandProject></BorlandProject>\r\n  </ProjectExtensions>\r\n  <Import Project=\"$(MSBuildBinPath)\\Borland.Cpp.Targets\" />\r\n  <ItemGroup>\r\n    <None Include=\"..\\include\\gtest\\gtest-death-test.h\">\r\n      <BuildOrder>3</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\gtest-message.h\">\r\n      <BuildOrder>4</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\gtest-param-test.h\">\r\n      <BuildOrder>5</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\gtest-spi.h\">\r\n      <BuildOrder>6</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\gtest-test-part.h\">\r\n      <BuildOrder>7</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\gtest-typed-test.h\">\r\n      <BuildOrder>8</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\gtest.h\">\r\n      <BuildOrder>0</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\gtest_pred_impl.h\">\r\n      <BuildOrder>1</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\gtest_prod.h\">\r\n      <BuildOrder>2</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\internal\\gtest-death-test-internal.h\">\r\n      <BuildOrder>9</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\internal\\gtest-filepath.h\">\r\n      <BuildOrder>10</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\internal\\gtest-internal.h\">\r\n      <BuildOrder>11</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\internal\\gtest-linked_ptr.h\">\r\n      <BuildOrder>12</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\internal\\gtest-param-util-generated.h\">\r\n      <BuildOrder>14</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\internal\\gtest-param-util.h\">\r\n      <BuildOrder>13</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\internal\\gtest-port.h\">\r\n      <BuildOrder>15</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\internal\\gtest-string.h\">\r\n      <BuildOrder>16</BuildOrder>\r\n    </None>\r\n    <None Include=\"..\\include\\gtest\\internal\\gtest-type-util.h\">\r\n      <BuildOrder>17</BuildOrder>\r\n    </None>\r\n    <CppCompile Include=\"gtest_all.cc\">\r\n      <BuildOrder>18</BuildOrder>\r\n    </CppCompile>\r\n    <BuildConfiguration Include=\"Debug\">\r\n      <Key>Cfg_1</Key>\r\n    </BuildConfiguration>\r\n    <BuildConfiguration Include=\"Release\">\r\n      <Key>Cfg_2</Key>\r\n    </BuildConfiguration>\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "ext/gtest/codegear/gtest.groupproj",
    "content": "﻿<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <PropertyGroup>\r\n    <ProjectGuid>{c1d923e0-6cba-4332-9b6f-3420acbf5091}</ProjectGuid>\r\n  </PropertyGroup>\r\n  <ItemGroup />\r\n  <ItemGroup>\r\n    <Projects Include=\"gtest.cbproj\" />\r\n    <Projects Include=\"gtest_main.cbproj\" />\r\n    <Projects Include=\"gtest_unittest.cbproj\" />\r\n  </ItemGroup>\r\n  <ProjectExtensions>\r\n    <Borland.Personality>Default.Personality</Borland.Personality>\r\n    <Borland.ProjectType />\r\n    <BorlandProject>\r\n<BorlandProject xmlns=\"\"><Default.Personality></Default.Personality></BorlandProject></BorlandProject>\r\n  </ProjectExtensions>\r\n  <Target Name=\"gtest\">\r\n    <MSBuild Projects=\"gtest.cbproj\" Targets=\"\" />\r\n  </Target>\r\n  <Target Name=\"gtest:Clean\">\r\n    <MSBuild Projects=\"gtest.cbproj\" Targets=\"Clean\" />\r\n  </Target>\r\n  <Target Name=\"gtest:Make\">\r\n    <MSBuild Projects=\"gtest.cbproj\" Targets=\"Make\" />\r\n  </Target>\r\n  <Target Name=\"gtest_main\">\r\n    <MSBuild Projects=\"gtest_main.cbproj\" Targets=\"\" />\r\n  </Target>\r\n  <Target Name=\"gtest_main:Clean\">\r\n    <MSBuild Projects=\"gtest_main.cbproj\" Targets=\"Clean\" />\r\n  </Target>\r\n  <Target Name=\"gtest_main:Make\">\r\n    <MSBuild Projects=\"gtest_main.cbproj\" Targets=\"Make\" />\r\n  </Target>\r\n  <Target Name=\"gtest_unittest\">\r\n    <MSBuild Projects=\"gtest_unittest.cbproj\" Targets=\"\" />\r\n  </Target>\r\n  <Target Name=\"gtest_unittest:Clean\">\r\n    <MSBuild Projects=\"gtest_unittest.cbproj\" Targets=\"Clean\" />\r\n  </Target>\r\n  <Target Name=\"gtest_unittest:Make\">\r\n    <MSBuild Projects=\"gtest_unittest.cbproj\" Targets=\"Make\" />\r\n  </Target>\r\n  <Target Name=\"Build\">\r\n    <CallTarget Targets=\"gtest;gtest_main;gtest_unittest\" />\r\n  </Target>\r\n  <Target Name=\"Clean\">\r\n    <CallTarget Targets=\"gtest:Clean;gtest_main:Clean;gtest_unittest:Clean\" />\r\n  </Target>\r\n  <Target Name=\"Make\">\r\n    <CallTarget Targets=\"gtest:Make;gtest_main:Make;gtest_unittest:Make\" />\r\n  </Target>\r\n  <Import Condition=\"Exists('$(MSBuildBinPath)\\Borland.Group.Targets')\" Project=\"$(MSBuildBinPath)\\Borland.Group.Targets\" />\r\n</Project>"
  },
  {
    "path": "ext/gtest/codegear/gtest_all.cc",
    "content": "// Copyright 2009, Google Inc.\r\n// All rights reserved.\r\n//\r\n// Redistribution and use in source and binary forms, with or without\r\n// modification, are permitted provided that the following conditions are\r\n// met:\r\n//\r\n//     * Redistributions of source code must retain the above copyright\r\n// notice, this list of conditions and the following disclaimer.\r\n//     * Redistributions in binary form must reproduce the above\r\n// copyright notice, this list of conditions and the following disclaimer\r\n// in the documentation and/or other materials provided with the\r\n// distribution.\r\n//     * Neither the name of Google Inc. nor the names of its\r\n// contributors may be used to endorse or promote products derived from\r\n// this software without specific prior written permission.\r\n//\r\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n//\r\n// Author: Josh Kelley (joshkel@gmail.com)\r\n//\r\n// Google C++ Testing Framework (Google Test)\r\n//\r\n// C++Builder's IDE cannot build a static library from files with hyphens\r\n// in their name.  See http://qc.codegear.com/wc/qcmain.aspx?d=70977 .\r\n// This file serves as a workaround.\r\n\r\n#include \"src/gtest-all.cc\"\r\n"
  },
  {
    "path": "ext/gtest/codegear/gtest_link.cc",
    "content": "// Copyright 2009, Google Inc.\r\n// All rights reserved.\r\n//\r\n// Redistribution and use in source and binary forms, with or without\r\n// modification, are permitted provided that the following conditions are\r\n// met:\r\n//\r\n//     * Redistributions of source code must retain the above copyright\r\n// notice, this list of conditions and the following disclaimer.\r\n//     * Redistributions in binary form must reproduce the above\r\n// copyright notice, this list of conditions and the following disclaimer\r\n// in the documentation and/or other materials provided with the\r\n// distribution.\r\n//     * Neither the name of Google Inc. nor the names of its\r\n// contributors may be used to endorse or promote products derived from\r\n// this software without specific prior written permission.\r\n//\r\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n//\r\n// Author: Josh Kelley (joshkel@gmail.com)\r\n//\r\n// Google C++ Testing Framework (Google Test)\r\n//\r\n// Links gtest.lib and gtest_main.lib into the current project in C++Builder.\r\n// This means that these libraries can't be renamed, but it's the only way to\r\n// ensure that Debug versus Release test builds are linked against the\r\n// appropriate Debug or Release build of the libraries.\r\n\r\n#pragma link \"gtest.lib\"\r\n#pragma link \"gtest_main.lib\"\r\n"
  },
  {
    "path": "ext/gtest/codegear/gtest_main.cbproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <PropertyGroup>\r\n    <ProjectGuid>{bca37a72-5b07-46cf-b44e-89f8e06451a2}</ProjectGuid>\r\n    <Config Condition=\"'$(Config)'==''\">Release</Config>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Config)'=='Base' or '$(Base)'!=''\">\r\n    <Base>true</Base>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Config)'=='Debug' or '$(Cfg_1)'!=''\">\r\n    <Base>true</Base>\r\n    <Cfg_1>true</Cfg_1>\r\n    <CfgParent>Base</CfgParent>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Config)'=='Release' or '$(Cfg_2)'!=''\">\r\n    <Base>true</Base>\r\n    <Cfg_2>true</Cfg_2>\r\n    <CfgParent>Base</CfgParent>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Base)'!=''\">\r\n    <BCC_OptimizeForSpeed>true</BCC_OptimizeForSpeed>\r\n    <OutputExt>lib</OutputExt>\r\n    <DCC_CBuilderOutput>JPHNE</DCC_CBuilderOutput>\r\n    <Defines>NO_STRICT</Defines>\r\n    <DynamicRTL>true</DynamicRTL>\r\n    <UsePackages>true</UsePackages>\r\n    <ProjectType>CppStaticLibrary</ProjectType>\r\n    <BCC_CPPCompileAlways>true</BCC_CPPCompileAlways>\r\n    <PackageImports>rtl.bpi;vcl.bpi;bcbie.bpi;vclx.bpi;vclactnband.bpi;xmlrtl.bpi;bcbsmp.bpi;dbrtl.bpi;vcldb.bpi;bdertl.bpi;vcldbx.bpi;dsnap.bpi;dsnapcon.bpi;vclib.bpi;ibxpress.bpi;adortl.bpi;dbxcds.bpi;dbexpress.bpi;DbxCommonDriver.bpi;websnap.bpi;vclie.bpi;webdsnap.bpi;inet.bpi;inetdbbde.bpi;inetdbxpress.bpi;soaprtl.bpi;Rave75VCL.bpi;teeUI.bpi;tee.bpi;teedb.bpi;IndyCore.bpi;IndySystem.bpi;IndyProtocols.bpi;IntrawebDB_90_100.bpi;Intraweb_90_100.bpi;dclZipForged11.bpi;vclZipForged11.bpi;GR32_BDS2006.bpi;GR32_DSGN_BDS2006.bpi;Jcl.bpi;JclVcl.bpi;JvCoreD11R.bpi;JvSystemD11R.bpi;JvStdCtrlsD11R.bpi;JvAppFrmD11R.bpi;JvBandsD11R.bpi;JvDBD11R.bpi;JvDlgsD11R.bpi;JvBDED11R.bpi;JvCmpD11R.bpi;JvCryptD11R.bpi;JvCtrlsD11R.bpi;JvCustomD11R.bpi;JvDockingD11R.bpi;JvDotNetCtrlsD11R.bpi;JvEDID11R.bpi;JvGlobusD11R.bpi;JvHMID11R.bpi;JvInterpreterD11R.bpi;JvJansD11R.bpi;JvManagedThreadsD11R.bpi;JvMMD11R.bpi;JvNetD11R.bpi;JvPageCompsD11R.bpi;JvPluginD11R.bpi;JvPrintPreviewD11R.bpi;JvRuntimeDesignD11R.bpi;JvTimeFrameworkD11R.bpi;JvValidatorsD11R.bpi;JvWizardD11R.bpi;JvXPCtrlsD11R.bpi;VclSmp.bpi;CExceptionExpert11.bpi</PackageImports>\r\n    <BCC_wpar>false</BCC_wpar>\r\n    <IncludePath>$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\src;..\\include;..</IncludePath>\r\n    <AllPackageLibs>rtl.lib;vcl.lib</AllPackageLibs>\r\n    <TLIB_PageSize>32</TLIB_PageSize>\r\n    <ILINK_LibraryPath>$(BDS)\\lib;$(BDS)\\lib\\obj;$(BDS)\\lib\\psdk</ILINK_LibraryPath>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Cfg_1)'!=''\">\r\n    <BCC_OptimizeForSpeed>false</BCC_OptimizeForSpeed>\r\n    <DCC_Optimize>false</DCC_Optimize>\r\n    <DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>\r\n    <Defines>_DEBUG;$(Defines)</Defines>\r\n    <ILINK_FullDebugInfo>true</ILINK_FullDebugInfo>\r\n    <BCC_InlineFunctionExpansion>false</BCC_InlineFunctionExpansion>\r\n    <ILINK_DisableIncrementalLinking>true</ILINK_DisableIncrementalLinking>\r\n    <BCC_UseRegisterVariables>None</BCC_UseRegisterVariables>\r\n    <DCC_Define>DEBUG</DCC_Define>\r\n    <BCC_DebugLineNumbers>true</BCC_DebugLineNumbers>\r\n    <IntermediateOutputDir>Debug</IntermediateOutputDir>\r\n    <TASM_DisplaySourceLines>true</TASM_DisplaySourceLines>\r\n    <BCC_StackFrames>true</BCC_StackFrames>\r\n    <BCC_DisableOptimizations>true</BCC_DisableOptimizations>\r\n    <ILINK_LibraryPath>$(BDS)\\lib\\debug;$(ILINK_LibraryPath)</ILINK_LibraryPath>\r\n    <TASM_Debugging>Full</TASM_Debugging>\r\n    <BCC_SourceDebuggingOn>true</BCC_SourceDebuggingOn>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Cfg_2)'!=''\">\r\n    <Defines>NDEBUG;$(Defines)</Defines>\r\n    <IntermediateOutputDir>Release</IntermediateOutputDir>\r\n    <ILINK_LibraryPath>$(BDS)\\lib\\release;$(ILINK_LibraryPath)</ILINK_LibraryPath>\r\n    <TASM_Debugging>None</TASM_Debugging>\r\n  </PropertyGroup>\r\n  <ProjectExtensions>\r\n    <Borland.Personality>CPlusPlusBuilder.Personality</Borland.Personality>\r\n    <Borland.ProjectType>CppStaticLibrary</Borland.ProjectType>\r\n    <BorlandProject>\r\n<BorlandProject><CPlusPlusBuilder.Personality><VersionInfo><VersionInfo Name=\"IncludeVerInfo\">False</VersionInfo><VersionInfo Name=\"AutoIncBuild\">False</VersionInfo><VersionInfo Name=\"MajorVer\">1</VersionInfo><VersionInfo Name=\"MinorVer\">0</VersionInfo><VersionInfo Name=\"Release\">0</VersionInfo><VersionInfo Name=\"Build\">0</VersionInfo><VersionInfo Name=\"Debug\">False</VersionInfo><VersionInfo Name=\"PreRelease\">False</VersionInfo><VersionInfo Name=\"Special\">False</VersionInfo><VersionInfo Name=\"Private\">False</VersionInfo><VersionInfo Name=\"DLL\">False</VersionInfo><VersionInfo Name=\"Locale\">1033</VersionInfo><VersionInfo Name=\"CodePage\">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name=\"CompanyName\"></VersionInfoKeys><VersionInfoKeys Name=\"FileDescription\"></VersionInfoKeys><VersionInfoKeys Name=\"FileVersion\">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name=\"InternalName\"></VersionInfoKeys><VersionInfoKeys Name=\"LegalCopyright\"></VersionInfoKeys><VersionInfoKeys Name=\"LegalTrademarks\"></VersionInfoKeys><VersionInfoKeys Name=\"OriginalFilename\"></VersionInfoKeys><VersionInfoKeys Name=\"ProductName\"></VersionInfoKeys><VersionInfoKeys Name=\"ProductVersion\">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name=\"Comments\"></VersionInfoKeys></VersionInfoKeys><Debugging><Debugging Name=\"DebugSourceDirs\"></Debugging></Debugging><Parameters><Parameters Name=\"RunParams\"></Parameters><Parameters Name=\"Launcher\"></Parameters><Parameters Name=\"UseLauncher\">False</Parameters><Parameters Name=\"DebugCWD\"></Parameters><Parameters Name=\"HostApplication\"></Parameters><Parameters Name=\"RemoteHost\"></Parameters><Parameters Name=\"RemotePath\"></Parameters><Parameters Name=\"RemoteParams\"></Parameters><Parameters Name=\"RemoteLauncher\"></Parameters><Parameters Name=\"UseRemoteLauncher\">False</Parameters><Parameters Name=\"RemoteCWD\"></Parameters><Parameters Name=\"RemoteDebug\">False</Parameters><Parameters Name=\"Debug Symbols Search Path\"></Parameters><Parameters Name=\"LoadAllSymbols\">True</Parameters><Parameters Name=\"LoadUnspecifiedSymbols\">False</Parameters></Parameters><Excluded_Packages>\r\n      <Excluded_Packages Name=\"$(BDS)\\bin\\bcboffice2k100.bpl\">CodeGear C++Builder Office 2000 Servers Package</Excluded_Packages>\r\n      <Excluded_Packages Name=\"$(BDS)\\bin\\bcbofficexp100.bpl\">CodeGear C++Builder Office XP Servers Package</Excluded_Packages>\r\n    </Excluded_Packages><Linker><Linker Name=\"LibPrefix\"></Linker><Linker Name=\"LibSuffix\"></Linker><Linker Name=\"LibVersion\"></Linker></Linker><ProjectProperties><ProjectProperties Name=\"AutoShowDeps\">False</ProjectProperties><ProjectProperties Name=\"ManagePaths\">True</ProjectProperties><ProjectProperties Name=\"VerifyPackages\">True</ProjectProperties></ProjectProperties><HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Count\">3</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Item0\">$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\src;..\\include;..</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Item1\">$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\src;..\\include;..</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Item2\">$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\src;..\\src;..\\include</HistoryLists_hlIncludePath></HistoryLists_hlIncludePath><HistoryLists_hlILINK_LibraryPath><HistoryLists_hlILINK_LibraryPath Name=\"Count\">1</HistoryLists_hlILINK_LibraryPath><HistoryLists_hlILINK_LibraryPath Name=\"Item0\">$(BDS)\\lib;$(BDS)\\lib\\obj;$(BDS)\\lib\\psdk</HistoryLists_hlILINK_LibraryPath></HistoryLists_hlILINK_LibraryPath><HistoryLists_hlDefines><HistoryLists_hlDefines Name=\"Count\">1</HistoryLists_hlDefines><HistoryLists_hlDefines Name=\"Item0\">NO_STRICT</HistoryLists_hlDefines></HistoryLists_hlDefines><HistoryLists_hlTLIB_PageSize><HistoryLists_hlTLIB_PageSize Name=\"Count\">1</HistoryLists_hlTLIB_PageSize><HistoryLists_hlTLIB_PageSize Name=\"Item0\">32</HistoryLists_hlTLIB_PageSize><HistoryLists_hlTLIB_PageSize Name=\"Item1\">16</HistoryLists_hlTLIB_PageSize></HistoryLists_hlTLIB_PageSize></CPlusPlusBuilder.Personality></BorlandProject></BorlandProject>\r\n  </ProjectExtensions>\r\n  <Import Project=\"$(MSBuildBinPath)\\Borland.Cpp.Targets\" />\r\n  <ItemGroup>\r\n    <CppCompile Include=\"..\\src\\gtest_main.cc\">\r\n      <BuildOrder>0</BuildOrder>\r\n    </CppCompile>\r\n    <BuildConfiguration Include=\"Debug\">\r\n      <Key>Cfg_1</Key>\r\n    </BuildConfiguration>\r\n    <BuildConfiguration Include=\"Release\">\r\n      <Key>Cfg_2</Key>\r\n    </BuildConfiguration>\r\n  </ItemGroup>\r\n</Project>\r\n"
  },
  {
    "path": "ext/gtest/codegear/gtest_unittest.cbproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\r\n  <PropertyGroup>\r\n    <ProjectGuid>{eea63393-5ac5-4b9c-8909-d75fef2daa41}</ProjectGuid>\r\n    <Config Condition=\"'$(Config)'==''\">Release</Config>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Config)'=='Base' or '$(Base)'!=''\">\r\n    <Base>true</Base>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Config)'=='Debug' or '$(Cfg_1)'!=''\">\r\n    <Base>true</Base>\r\n    <Cfg_1>true</Cfg_1>\r\n    <CfgParent>Base</CfgParent>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Config)'=='Release' or '$(Cfg_2)'!=''\">\r\n    <Base>true</Base>\r\n    <Cfg_2>true</Cfg_2>\r\n    <CfgParent>Base</CfgParent>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Base)'!=''\">\r\n    <OutputExt>exe</OutputExt>\r\n    <BCC_OptimizeForSpeed>true</BCC_OptimizeForSpeed>\r\n    <Defines>NO_STRICT</Defines>\r\n    <DCC_CBuilderOutput>JPHNE</DCC_CBuilderOutput>\r\n    <DynamicRTL>true</DynamicRTL>\r\n    <ILINK_ObjectSearchPath>..\\test</ILINK_ObjectSearchPath>\r\n    <UsePackages>true</UsePackages>\r\n    <ProjectType>CppConsoleApplication</ProjectType>\r\n    <NoVCL>true</NoVCL>\r\n    <BCC_CPPCompileAlways>true</BCC_CPPCompileAlways>\r\n    <PackageImports>rtl.bpi;vcl.bpi;bcbie.bpi;vclx.bpi;vclactnband.bpi;xmlrtl.bpi;bcbsmp.bpi;dbrtl.bpi;vcldb.bpi;bdertl.bpi;vcldbx.bpi;dsnap.bpi;dsnapcon.bpi;vclib.bpi;ibxpress.bpi;adortl.bpi;dbxcds.bpi;dbexpress.bpi;DbxCommonDriver.bpi;websnap.bpi;vclie.bpi;webdsnap.bpi;inet.bpi;inetdbbde.bpi;inetdbxpress.bpi;soaprtl.bpi;Rave75VCL.bpi;teeUI.bpi;tee.bpi;teedb.bpi;IndyCore.bpi;IndySystem.bpi;IndyProtocols.bpi;IntrawebDB_90_100.bpi;Intraweb_90_100.bpi;Jcl.bpi;JclVcl.bpi;JvCoreD11R.bpi;JvSystemD11R.bpi;JvStdCtrlsD11R.bpi;JvAppFrmD11R.bpi;JvBandsD11R.bpi;JvDBD11R.bpi;JvDlgsD11R.bpi;JvBDED11R.bpi;JvCmpD11R.bpi;JvCryptD11R.bpi;JvCtrlsD11R.bpi;JvCustomD11R.bpi;JvDockingD11R.bpi;JvDotNetCtrlsD11R.bpi;JvEDID11R.bpi;JvGlobusD11R.bpi;JvHMID11R.bpi;JvInterpreterD11R.bpi;JvJansD11R.bpi;JvManagedThreadsD11R.bpi;JvMMD11R.bpi;JvNetD11R.bpi;JvPageCompsD11R.bpi;JvPluginD11R.bpi;JvPrintPreviewD11R.bpi;JvRuntimeDesignD11R.bpi;JvTimeFrameworkD11R.bpi;JvValidatorsD11R.bpi;JvWizardD11R.bpi;JvXPCtrlsD11R.bpi;VclSmp.bpi</PackageImports>\r\n    <BCC_wpar>false</BCC_wpar>\r\n    <IncludePath>$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\include;..\\test;..</IncludePath>\r\n    <ILINK_LibraryPath>$(BDS)\\lib;$(BDS)\\lib\\obj;$(BDS)\\lib\\psdk;..\\test</ILINK_LibraryPath>\r\n    <Multithreaded>true</Multithreaded>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Cfg_1)'!=''\">\r\n    <BCC_OptimizeForSpeed>false</BCC_OptimizeForSpeed>\r\n    <DCC_Optimize>false</DCC_Optimize>\r\n    <DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>\r\n    <Defines>_DEBUG;$(Defines)</Defines>\r\n    <ILINK_FullDebugInfo>true</ILINK_FullDebugInfo>\r\n    <BCC_InlineFunctionExpansion>false</BCC_InlineFunctionExpansion>\r\n    <ILINK_DisableIncrementalLinking>true</ILINK_DisableIncrementalLinking>\r\n    <BCC_UseRegisterVariables>None</BCC_UseRegisterVariables>\r\n    <DCC_Define>DEBUG</DCC_Define>\r\n    <BCC_DebugLineNumbers>true</BCC_DebugLineNumbers>\r\n    <IntermediateOutputDir>Debug</IntermediateOutputDir>\r\n    <TASM_DisplaySourceLines>true</TASM_DisplaySourceLines>\r\n    <BCC_StackFrames>true</BCC_StackFrames>\r\n    <BCC_DisableOptimizations>true</BCC_DisableOptimizations>\r\n    <ILINK_LibraryPath>$(BDS)\\lib\\debug;$(ILINK_LibraryPath)</ILINK_LibraryPath>\r\n    <TASM_Debugging>Full</TASM_Debugging>\r\n    <BCC_SourceDebuggingOn>true</BCC_SourceDebuggingOn>\r\n  </PropertyGroup>\r\n  <PropertyGroup Condition=\"'$(Cfg_2)'!=''\">\r\n    <Defines>NDEBUG;$(Defines)</Defines>\r\n    <IntermediateOutputDir>Release</IntermediateOutputDir>\r\n    <ILINK_LibraryPath>$(BDS)\\lib\\release;$(ILINK_LibraryPath)</ILINK_LibraryPath>\r\n    <TASM_Debugging>None</TASM_Debugging>\r\n  </PropertyGroup>\r\n  <ProjectExtensions>\r\n    <Borland.Personality>CPlusPlusBuilder.Personality</Borland.Personality>\r\n    <Borland.ProjectType>CppConsoleApplication</Borland.ProjectType>\r\n    <BorlandProject>\r\n<BorlandProject><CPlusPlusBuilder.Personality><VersionInfo><VersionInfo Name=\"IncludeVerInfo\">False</VersionInfo><VersionInfo Name=\"AutoIncBuild\">False</VersionInfo><VersionInfo Name=\"MajorVer\">1</VersionInfo><VersionInfo Name=\"MinorVer\">0</VersionInfo><VersionInfo Name=\"Release\">0</VersionInfo><VersionInfo Name=\"Build\">0</VersionInfo><VersionInfo Name=\"Debug\">False</VersionInfo><VersionInfo Name=\"PreRelease\">False</VersionInfo><VersionInfo Name=\"Special\">False</VersionInfo><VersionInfo Name=\"Private\">False</VersionInfo><VersionInfo Name=\"DLL\">False</VersionInfo><VersionInfo Name=\"Locale\">1033</VersionInfo><VersionInfo Name=\"CodePage\">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name=\"CompanyName\"></VersionInfoKeys><VersionInfoKeys Name=\"FileDescription\"></VersionInfoKeys><VersionInfoKeys Name=\"FileVersion\">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name=\"InternalName\"></VersionInfoKeys><VersionInfoKeys Name=\"LegalCopyright\"></VersionInfoKeys><VersionInfoKeys Name=\"LegalTrademarks\"></VersionInfoKeys><VersionInfoKeys Name=\"OriginalFilename\"></VersionInfoKeys><VersionInfoKeys Name=\"ProductName\"></VersionInfoKeys><VersionInfoKeys Name=\"ProductVersion\">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name=\"Comments\"></VersionInfoKeys></VersionInfoKeys><Debugging><Debugging Name=\"DebugSourceDirs\"></Debugging></Debugging><Parameters><Parameters Name=\"RunParams\"></Parameters><Parameters Name=\"Launcher\"></Parameters><Parameters Name=\"UseLauncher\">False</Parameters><Parameters Name=\"DebugCWD\"></Parameters><Parameters Name=\"HostApplication\"></Parameters><Parameters Name=\"RemoteHost\"></Parameters><Parameters Name=\"RemotePath\"></Parameters><Parameters Name=\"RemoteParams\"></Parameters><Parameters Name=\"RemoteLauncher\"></Parameters><Parameters Name=\"UseRemoteLauncher\">False</Parameters><Parameters Name=\"RemoteCWD\"></Parameters><Parameters Name=\"RemoteDebug\">False</Parameters><Parameters Name=\"Debug Symbols Search Path\"></Parameters><Parameters Name=\"LoadAllSymbols\">True</Parameters><Parameters Name=\"LoadUnspecifiedSymbols\">False</Parameters></Parameters><Excluded_Packages>\r\n      \r\n      \r\n      <Excluded_Packages Name=\"$(BDS)\\bin\\bcboffice2k100.bpl\">CodeGear C++Builder Office 2000 Servers Package</Excluded_Packages>\r\n      <Excluded_Packages Name=\"$(BDS)\\bin\\bcbofficexp100.bpl\">CodeGear C++Builder Office XP Servers Package</Excluded_Packages>\r\n    </Excluded_Packages><Linker><Linker Name=\"LibPrefix\"></Linker><Linker Name=\"LibSuffix\"></Linker><Linker Name=\"LibVersion\"></Linker></Linker><ProjectProperties><ProjectProperties Name=\"AutoShowDeps\">False</ProjectProperties><ProjectProperties Name=\"ManagePaths\">True</ProjectProperties><ProjectProperties Name=\"VerifyPackages\">True</ProjectProperties></ProjectProperties><HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Count\">3</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Item0\">$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\include;..\\test;..</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Item1\">$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\include;..\\test</HistoryLists_hlIncludePath><HistoryLists_hlIncludePath Name=\"Item2\">$(BDS)\\include;$(BDS)\\include\\dinkumware;$(BDS)\\include\\vcl;..\\include</HistoryLists_hlIncludePath></HistoryLists_hlIncludePath><HistoryLists_hlILINK_LibraryPath><HistoryLists_hlILINK_LibraryPath Name=\"Count\">1</HistoryLists_hlILINK_LibraryPath><HistoryLists_hlILINK_LibraryPath Name=\"Item0\">$(BDS)\\lib;$(BDS)\\lib\\obj;$(BDS)\\lib\\psdk;..\\test</HistoryLists_hlILINK_LibraryPath><HistoryLists_hlILINK_LibraryPath Name=\"Item1\">$(BDS)\\lib;$(BDS)\\lib\\obj;$(BDS)\\lib\\psdk;..\\test</HistoryLists_hlILINK_LibraryPath><HistoryLists_hlILINK_LibraryPath Name=\"Item2\">$(BDS)\\lib;$(BDS)\\lib\\obj;$(BDS)\\lib\\psdk;$(OUTPUTDIR);..\\test</HistoryLists_hlILINK_LibraryPath></HistoryLists_hlILINK_LibraryPath><HistoryLists_hlDefines><HistoryLists_hlDefines Name=\"Count\">2</HistoryLists_hlDefines><HistoryLists_hlDefines Name=\"Item0\">NO_STRICT</HistoryLists_hlDefines><HistoryLists_hlDefines Name=\"Item1\">STRICT</HistoryLists_hlDefines></HistoryLists_hlDefines></CPlusPlusBuilder.Personality></BorlandProject></BorlandProject>\r\n  </ProjectExtensions>\r\n  <Import Project=\"$(MSBuildBinPath)\\Borland.Cpp.Targets\" />\r\n  <ItemGroup>\r\n    <CppCompile Include=\"..\\test\\gtest_unittest.cc\">\r\n      <BuildOrder>0</BuildOrder>\r\n    </CppCompile>\r\n    <CppCompile Include=\"gtest_link.cc\">\r\n      <BuildOrder>1</BuildOrder>\r\n    </CppCompile>\r\n    <BuildConfiguration Include=\"Debug\">\r\n      <Key>Cfg_1</Key>\r\n    </BuildConfiguration>\r\n    <BuildConfiguration Include=\"Release\">\r\n      <Key>Cfg_2</Key>\r\n    </BuildConfiguration>\r\n  </ItemGroup>\r\n</Project>"
  },
  {
    "path": "ext/gtest/configure.ac",
    "content": "m4_include(m4/acx_pthread.m4)\n\n# At this point, the Xcode project assumes the version string will be three\n# integers separated by periods and surrounded by square brackets (e.g.\n# \"[1.0.1]\"). It also asumes that there won't be any closing parenthesis\n# between \"AC_INIT(\" and the closing \")\" including comments and strings.\nAC_INIT([Google C++ Testing Framework],\n        [1.7.0],\n        [googletestframework@googlegroups.com],\n        [gtest])\n\n# Provide various options to initialize the Autoconf and configure processes.\nAC_PREREQ([2.59])\nAC_CONFIG_SRCDIR([./LICENSE])\nAC_CONFIG_MACRO_DIR([m4])\nAC_CONFIG_AUX_DIR([build-aux])\nAC_CONFIG_HEADERS([build-aux/config.h])\nAC_CONFIG_FILES([Makefile])\nAC_CONFIG_FILES([scripts/gtest-config], [chmod +x scripts/gtest-config])\n\n# Initialize Automake with various options. We require at least v1.9, prevent\n# pedantic complaints about package files, and enable various distribution\n# targets.\nAM_INIT_AUTOMAKE([1.9 dist-bzip2 dist-zip foreign subdir-objects])\n\n# Check for programs used in building Google Test.\nAC_PROG_CC\nAC_PROG_CXX\nAC_LANG([C++])\nAC_PROG_LIBTOOL\n\n# TODO(chandlerc@google.com): Currently we aren't running the Python tests\n# against the interpreter detected by AM_PATH_PYTHON, and so we condition\n# HAVE_PYTHON by requiring \"python\" to be in the PATH, and that interpreter's\n# version to be >= 2.3. This will allow the scripts to use a \"/usr/bin/env\"\n# hashbang.\nPYTHON=  # We *do not* allow the user to specify a python interpreter\nAC_PATH_PROG([PYTHON],[python],[:])\nAS_IF([test \"$PYTHON\" != \":\"],\n      [AM_PYTHON_CHECK_VERSION([$PYTHON],[2.3],[:],[PYTHON=\":\"])])\nAM_CONDITIONAL([HAVE_PYTHON],[test \"$PYTHON\" != \":\"])\n\n# Configure pthreads.\nAC_ARG_WITH([pthreads],\n            [AS_HELP_STRING([--with-pthreads],\n               [use pthreads (default is yes)])],\n            [with_pthreads=$withval],\n            [with_pthreads=check])\n\nhave_pthreads=no\nAS_IF([test \"x$with_pthreads\" != \"xno\"],\n      [ACX_PTHREAD(\n        [],\n        [AS_IF([test \"x$with_pthreads\" != \"xcheck\"],\n               [AC_MSG_FAILURE(\n                 [--with-pthreads was specified, but unable to be used])])])\n       have_pthreads=\"$acx_pthread_ok\"])\nAM_CONDITIONAL([HAVE_PTHREADS],[test \"x$have_pthreads\" = \"xyes\"])\nAC_SUBST(PTHREAD_CFLAGS)\nAC_SUBST(PTHREAD_LIBS)\n\n# TODO(chandlerc@google.com) Check for the necessary system headers.\n\n# TODO(chandlerc@google.com) Check the types, structures, and other compiler\n# and architecture characteristics.\n\n# Output the generated files. No further autoconf macros may be used.\nAC_OUTPUT\n"
  },
  {
    "path": "ext/gtest/include/gtest/gtest-death-test.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// The Google C++ Testing Framework (Google Test)\n//\n// This header file defines the public API for death tests.  It is\n// #included by gtest.h so a user doesn't need to include this\n// directly.\n\n#ifndef GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_\n#define GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_\n\n#include \"gtest/internal/gtest-death-test-internal.h\"\n\nnamespace testing {\n\n// This flag controls the style of death tests.  Valid values are \"threadsafe\",\n// meaning that the death test child process will re-execute the test binary\n// from the start, running only a single death test, or \"fast\",\n// meaning that the child process will execute the test logic immediately\n// after forking.\nGTEST_DECLARE_string_(death_test_style);\n\n#if GTEST_HAS_DEATH_TEST\n\nnamespace internal {\n\n// Returns a Boolean value indicating whether the caller is currently\n// executing in the context of the death test child process.  Tools such as\n// Valgrind heap checkers may need this to modify their behavior in death\n// tests.  IMPORTANT: This is an internal utility.  Using it may break the\n// implementation of death tests.  User code MUST NOT use it.\nGTEST_API_ bool InDeathTestChild();\n\n}  // namespace internal\n\n// The following macros are useful for writing death tests.\n\n// Here's what happens when an ASSERT_DEATH* or EXPECT_DEATH* is\n// executed:\n//\n//   1. It generates a warning if there is more than one active\n//   thread.  This is because it's safe to fork() or clone() only\n//   when there is a single thread.\n//\n//   2. The parent process clone()s a sub-process and runs the death\n//   test in it; the sub-process exits with code 0 at the end of the\n//   death test, if it hasn't exited already.\n//\n//   3. The parent process waits for the sub-process to terminate.\n//\n//   4. The parent process checks the exit code and error message of\n//   the sub-process.\n//\n// Examples:\n//\n//   ASSERT_DEATH(server.SendMessage(56, \"Hello\"), \"Invalid port number\");\n//   for (int i = 0; i < 5; i++) {\n//     EXPECT_DEATH(server.ProcessRequest(i),\n//                  \"Invalid request .* in ProcessRequest()\")\n//                  << \"Failed to die on request \" << i;\n//   }\n//\n//   ASSERT_EXIT(server.ExitNow(), ::testing::ExitedWithCode(0), \"Exiting\");\n//\n//   bool KilledBySIGHUP(int exit_code) {\n//     return WIFSIGNALED(exit_code) && WTERMSIG(exit_code) == SIGHUP;\n//   }\n//\n//   ASSERT_EXIT(client.HangUpServer(), KilledBySIGHUP, \"Hanging up!\");\n//\n// On the regular expressions used in death tests:\n//\n//   On POSIX-compliant systems (*nix), we use the <regex.h> library,\n//   which uses the POSIX extended regex syntax.\n//\n//   On other platforms (e.g. Windows), we only support a simple regex\n//   syntax implemented as part of Google Test.  This limited\n//   implementation should be enough most of the time when writing\n//   death tests; though it lacks many features you can find in PCRE\n//   or POSIX extended regex syntax.  For example, we don't support\n//   union (\"x|y\"), grouping (\"(xy)\"), brackets (\"[xy]\"), and\n//   repetition count (\"x{5,7}\"), among others.\n//\n//   Below is the syntax that we do support.  We chose it to be a\n//   subset of both PCRE and POSIX extended regex, so it's easy to\n//   learn wherever you come from.  In the following: 'A' denotes a\n//   literal character, period (.), or a single \\\\ escape sequence;\n//   'x' and 'y' denote regular expressions; 'm' and 'n' are for\n//   natural numbers.\n//\n//     c     matches any literal character c\n//     \\\\d   matches any decimal digit\n//     \\\\D   matches any character that's not a decimal digit\n//     \\\\f   matches \\f\n//     \\\\n   matches \\n\n//     \\\\r   matches \\r\n//     \\\\s   matches any ASCII whitespace, including \\n\n//     \\\\S   matches any character that's not a whitespace\n//     \\\\t   matches \\t\n//     \\\\v   matches \\v\n//     \\\\w   matches any letter, _, or decimal digit\n//     \\\\W   matches any character that \\\\w doesn't match\n//     \\\\c   matches any literal character c, which must be a punctuation\n//     .     matches any single character except \\n\n//     A?    matches 0 or 1 occurrences of A\n//     A*    matches 0 or many occurrences of A\n//     A+    matches 1 or many occurrences of A\n//     ^     matches the beginning of a string (not that of each line)\n//     $     matches the end of a string (not that of each line)\n//     xy    matches x followed by y\n//\n//   If you accidentally use PCRE or POSIX extended regex features\n//   not implemented by us, you will get a run-time failure.  In that\n//   case, please try to rewrite your regular expression within the\n//   above syntax.\n//\n//   This implementation is *not* meant to be as highly tuned or robust\n//   as a compiled regex library, but should perform well enough for a\n//   death test, which already incurs significant overhead by launching\n//   a child process.\n//\n// Known caveats:\n//\n//   A \"threadsafe\" style death test obtains the path to the test\n//   program from argv[0] and re-executes it in the sub-process.  For\n//   simplicity, the current implementation doesn't search the PATH\n//   when launching the sub-process.  This means that the user must\n//   invoke the test program via a path that contains at least one\n//   path separator (e.g. path/to/foo_test and\n//   /absolute/path/to/bar_test are fine, but foo_test is not).  This\n//   is rarely a problem as people usually don't put the test binary\n//   directory in PATH.\n//\n// TODO(wan@google.com): make thread-safe death tests search the PATH.\n\n// Asserts that a given statement causes the program to exit, with an\n// integer exit status that satisfies predicate, and emitting error output\n// that matches regex.\n# define ASSERT_EXIT(statement, predicate, regex) \\\n    GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_)\n\n// Like ASSERT_EXIT, but continues on to successive tests in the\n// test case, if any:\n# define EXPECT_EXIT(statement, predicate, regex) \\\n    GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_)\n\n// Asserts that a given statement causes the program to exit, either by\n// explicitly exiting with a nonzero exit code or being killed by a\n// signal, and emitting error output that matches regex.\n# define ASSERT_DEATH(statement, regex) \\\n    ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)\n\n// Like ASSERT_DEATH, but continues on to successive tests in the\n// test case, if any:\n# define EXPECT_DEATH(statement, regex) \\\n    EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)\n\n// Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*:\n\n// Tests that an exit code describes a normal exit with a given exit code.\nclass GTEST_API_ ExitedWithCode {\n public:\n  explicit ExitedWithCode(int exit_code);\n  bool operator()(int exit_status) const;\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ExitedWithCode& other);\n\n  const int exit_code_;\n};\n\n# if !GTEST_OS_WINDOWS\n// Tests that an exit code describes an exit due to termination by a\n// given signal.\nclass GTEST_API_ KilledBySignal {\n public:\n  explicit KilledBySignal(int signum);\n  bool operator()(int exit_status) const;\n private:\n  const int signum_;\n};\n# endif  // !GTEST_OS_WINDOWS\n\n// EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode.\n// The death testing framework causes this to have interesting semantics,\n// since the sideeffects of the call are only visible in opt mode, and not\n// in debug mode.\n//\n// In practice, this can be used to test functions that utilize the\n// LOG(DFATAL) macro using the following style:\n//\n// int DieInDebugOr12(int* sideeffect) {\n//   if (sideeffect) {\n//     *sideeffect = 12;\n//   }\n//   LOG(DFATAL) << \"death\";\n//   return 12;\n// }\n//\n// TEST(TestCase, TestDieOr12WorksInDgbAndOpt) {\n//   int sideeffect = 0;\n//   // Only asserts in dbg.\n//   EXPECT_DEBUG_DEATH(DieInDebugOr12(&sideeffect), \"death\");\n//\n// #ifdef NDEBUG\n//   // opt-mode has sideeffect visible.\n//   EXPECT_EQ(12, sideeffect);\n// #else\n//   // dbg-mode no visible sideeffect.\n//   EXPECT_EQ(0, sideeffect);\n// #endif\n// }\n//\n// This will assert that DieInDebugReturn12InOpt() crashes in debug\n// mode, usually due to a DCHECK or LOG(DFATAL), but returns the\n// appropriate fallback value (12 in this case) in opt mode. If you\n// need to test that a function has appropriate side-effects in opt\n// mode, include assertions against the side-effects.  A general\n// pattern for this is:\n//\n// EXPECT_DEBUG_DEATH({\n//   // Side-effects here will have an effect after this statement in\n//   // opt mode, but none in debug mode.\n//   EXPECT_EQ(12, DieInDebugOr12(&sideeffect));\n// }, \"death\");\n//\n# ifdef NDEBUG\n\n#  define EXPECT_DEBUG_DEATH(statement, regex) \\\n  GTEST_EXECUTE_STATEMENT_(statement, regex)\n\n#  define ASSERT_DEBUG_DEATH(statement, regex) \\\n  GTEST_EXECUTE_STATEMENT_(statement, regex)\n\n# else\n\n#  define EXPECT_DEBUG_DEATH(statement, regex) \\\n  EXPECT_DEATH(statement, regex)\n\n#  define ASSERT_DEBUG_DEATH(statement, regex) \\\n  ASSERT_DEATH(statement, regex)\n\n# endif  // NDEBUG for EXPECT_DEBUG_DEATH\n#endif  // GTEST_HAS_DEATH_TEST\n\n// EXPECT_DEATH_IF_SUPPORTED(statement, regex) and\n// ASSERT_DEATH_IF_SUPPORTED(statement, regex) expand to real death tests if\n// death tests are supported; otherwise they just issue a warning.  This is\n// useful when you are combining death test assertions with normal test\n// assertions in one test.\n#if GTEST_HAS_DEATH_TEST\n# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \\\n    EXPECT_DEATH(statement, regex)\n# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \\\n    ASSERT_DEATH(statement, regex)\n#else\n# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \\\n    GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, )\n# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \\\n    GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, return)\n#endif\n\n}  // namespace testing\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/gtest-message.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// The Google C++ Testing Framework (Google Test)\n//\n// This header file defines the Message class.\n//\n// IMPORTANT NOTE: Due to limitation of the C++ language, we have to\n// leave some internal implementation details in this header file.\n// They are clearly marked by comments like this:\n//\n//   // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n//\n// Such code is NOT meant to be used by a user directly, and is subject\n// to CHANGE WITHOUT NOTICE.  Therefore DO NOT DEPEND ON IT in a user\n// program!\n\n#ifndef GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_\n#define GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_\n\n#include <limits>\n\n#include \"gtest/internal/gtest-port.h\"\n\n// Ensures that there is at least one operator<< in the global namespace.\n// See Message& operator<<(...) below for why.\nvoid operator<<(const testing::internal::Secret&, int);\n\nnamespace testing {\n\n// The Message class works like an ostream repeater.\n//\n// Typical usage:\n//\n//   1. You stream a bunch of values to a Message object.\n//      It will remember the text in a stringstream.\n//   2. Then you stream the Message object to an ostream.\n//      This causes the text in the Message to be streamed\n//      to the ostream.\n//\n// For example;\n//\n//   testing::Message foo;\n//   foo << 1 << \" != \" << 2;\n//   std::cout << foo;\n//\n// will print \"1 != 2\".\n//\n// Message is not intended to be inherited from.  In particular, its\n// destructor is not virtual.\n//\n// Note that stringstream behaves differently in gcc and in MSVC.  You\n// can stream a NULL char pointer to it in the former, but not in the\n// latter (it causes an access violation if you do).  The Message\n// class hides this difference by treating a NULL char pointer as\n// \"(null)\".\nclass GTEST_API_ Message {\n private:\n  // The type of basic IO manipulators (endl, ends, and flush) for\n  // narrow streams.\n  typedef std::ostream& (*BasicNarrowIoManip)(std::ostream&);\n\n public:\n  // Constructs an empty Message.\n  Message();\n\n  // Copy constructor.\n  Message(const Message& msg) : ss_(new ::std::stringstream) {  // NOLINT\n    *ss_ << msg.GetString();\n  }\n\n  // Constructs a Message from a C-string.\n  explicit Message(const char* str) : ss_(new ::std::stringstream) {\n    *ss_ << str;\n  }\n\n#if GTEST_OS_SYMBIAN\n  // Streams a value (either a pointer or not) to this object.\n  template <typename T>\n  inline Message& operator <<(const T& value) {\n    StreamHelper(typename internal::is_pointer<T>::type(), value);\n    return *this;\n  }\n#else\n  // Streams a non-pointer value to this object.\n  template <typename T>\n  inline Message& operator <<(const T& val) {\n    // Some libraries overload << for STL containers.  These\n    // overloads are defined in the global namespace instead of ::std.\n    //\n    // C++'s symbol lookup rule (i.e. Koenig lookup) says that these\n    // overloads are visible in either the std namespace or the global\n    // namespace, but not other namespaces, including the testing\n    // namespace which Google Test's Message class is in.\n    //\n    // To allow STL containers (and other types that has a << operator\n    // defined in the global namespace) to be used in Google Test\n    // assertions, testing::Message must access the custom << operator\n    // from the global namespace.  With this using declaration,\n    // overloads of << defined in the global namespace and those\n    // visible via Koenig lookup are both exposed in this function.\n    using ::operator <<;\n    *ss_ << val;\n    return *this;\n  }\n\n  // Streams a pointer value to this object.\n  //\n  // This function is an overload of the previous one.  When you\n  // stream a pointer to a Message, this definition will be used as it\n  // is more specialized.  (The C++ Standard, section\n  // [temp.func.order].)  If you stream a non-pointer, then the\n  // previous definition will be used.\n  //\n  // The reason for this overload is that streaming a NULL pointer to\n  // ostream is undefined behavior.  Depending on the compiler, you\n  // may get \"0\", \"(nil)\", \"(null)\", or an access violation.  To\n  // ensure consistent result across compilers, we always treat NULL\n  // as \"(null)\".\n  template <typename T>\n  inline Message& operator <<(T* const& pointer) {  // NOLINT\n    if (pointer == NULL) {\n      *ss_ << \"(null)\";\n    } else {\n      *ss_ << pointer;\n    }\n    return *this;\n  }\n#endif  // GTEST_OS_SYMBIAN\n\n  // Since the basic IO manipulators are overloaded for both narrow\n  // and wide streams, we have to provide this specialized definition\n  // of operator <<, even though its body is the same as the\n  // templatized version above.  Without this definition, streaming\n  // endl or other basic IO manipulators to Message will confuse the\n  // compiler.\n  Message& operator <<(BasicNarrowIoManip val) {\n    *ss_ << val;\n    return *this;\n  }\n\n  // Instead of 1/0, we want to see true/false for bool values.\n  Message& operator <<(bool b) {\n    return *this << (b ? \"true\" : \"false\");\n  }\n\n  // These two overloads allow streaming a wide C string to a Message\n  // using the UTF-8 encoding.\n  Message& operator <<(const wchar_t* wide_c_str);\n  Message& operator <<(wchar_t* wide_c_str);\n\n#if GTEST_HAS_STD_WSTRING\n  // Converts the given wide string to a narrow string using the UTF-8\n  // encoding, and streams the result to this Message object.\n  Message& operator <<(const ::std::wstring& wstr);\n#endif  // GTEST_HAS_STD_WSTRING\n\n#if GTEST_HAS_GLOBAL_WSTRING\n  // Converts the given wide string to a narrow string using the UTF-8\n  // encoding, and streams the result to this Message object.\n  Message& operator <<(const ::wstring& wstr);\n#endif  // GTEST_HAS_GLOBAL_WSTRING\n\n  // Gets the text streamed to this object so far as an std::string.\n  // Each '\\0' character in the buffer is replaced with \"\\\\0\".\n  //\n  // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n  std::string GetString() const;\n\n private:\n\n#if GTEST_OS_SYMBIAN\n  // These are needed as the Nokia Symbian Compiler cannot decide between\n  // const T& and const T* in a function template. The Nokia compiler _can_\n  // decide between class template specializations for T and T*, so a\n  // tr1::type_traits-like is_pointer works, and we can overload on that.\n  template <typename T>\n  inline void StreamHelper(internal::true_type /*is_pointer*/, T* pointer) {\n    if (pointer == NULL) {\n      *ss_ << \"(null)\";\n    } else {\n      *ss_ << pointer;\n    }\n  }\n  template <typename T>\n  inline void StreamHelper(internal::false_type /*is_pointer*/,\n                           const T& value) {\n    // See the comments in Message& operator <<(const T&) above for why\n    // we need this using statement.\n    using ::operator <<;\n    *ss_ << value;\n  }\n#endif  // GTEST_OS_SYMBIAN\n\n  // We'll hold the text streamed to this object here.\n  const internal::scoped_ptr< ::std::stringstream> ss_;\n\n  // We declare (but don't implement) this to prevent the compiler\n  // from implementing the assignment operator.\n  void operator=(const Message&);\n};\n\n// Streams a Message to an ostream.\ninline std::ostream& operator <<(std::ostream& os, const Message& sb) {\n  return os << sb.GetString();\n}\n\nnamespace internal {\n\n// Converts a streamable value to an std::string.  A NULL pointer is\n// converted to \"(null)\".  When the input value is a ::string,\n// ::std::string, ::wstring, or ::std::wstring object, each NUL\n// character in it is replaced with \"\\\\0\".\ntemplate <typename T>\nstd::string StreamableToString(const T& streamable) {\n  return (Message() << streamable).GetString();\n}\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/gtest-param-test.h",
    "content": "// This file was GENERATED by command:\n//     pump.py gtest-param-test.h.pump\n// DO NOT EDIT BY HAND!!!\n\n// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: vladl@google.com (Vlad Losev)\n//\n// Macros and functions for implementing parameterized tests\n// in Google C++ Testing Framework (Google Test)\n//\n// This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!\n//\n#ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_\n#define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_\n\n\n// Value-parameterized tests allow you to test your code with different\n// parameters without writing multiple copies of the same test.\n//\n// Here is how you use value-parameterized tests:\n\n#if 0\n\n// To write value-parameterized tests, first you should define a fixture\n// class. It is usually derived from testing::TestWithParam<T> (see below for\n// another inheritance scheme that's sometimes useful in more complicated\n// class hierarchies), where the type of your parameter values.\n// TestWithParam<T> is itself derived from testing::Test. T can be any\n// copyable type. If it's a raw pointer, you are responsible for managing the\n// lifespan of the pointed values.\n\nclass FooTest : public ::testing::TestWithParam<const char*> {\n  // You can implement all the usual class fixture members here.\n};\n\n// Then, use the TEST_P macro to define as many parameterized tests\n// for this fixture as you want. The _P suffix is for \"parameterized\"\n// or \"pattern\", whichever you prefer to think.\n\nTEST_P(FooTest, DoesBlah) {\n  // Inside a test, access the test parameter with the GetParam() method\n  // of the TestWithParam<T> class:\n  EXPECT_TRUE(foo.Blah(GetParam()));\n  ...\n}\n\nTEST_P(FooTest, HasBlahBlah) {\n  ...\n}\n\n// Finally, you can use INSTANTIATE_TEST_CASE_P to instantiate the test\n// case with any set of parameters you want. Google Test defines a number\n// of functions for generating test parameters. They return what we call\n// (surprise!) parameter generators. Here is a  summary of them, which\n// are all in the testing namespace:\n//\n//\n//  Range(begin, end [, step]) - Yields values {begin, begin+step,\n//                               begin+step+step, ...}. The values do not\n//                               include end. step defaults to 1.\n//  Values(v1, v2, ..., vN)    - Yields values {v1, v2, ..., vN}.\n//  ValuesIn(container)        - Yields values from a C-style array, an STL\n//  ValuesIn(begin,end)          container, or an iterator range [begin, end).\n//  Bool()                     - Yields sequence {false, true}.\n//  Combine(g1, g2, ..., gN)   - Yields all combinations (the Cartesian product\n//                               for the math savvy) of the values generated\n//                               by the N generators.\n//\n// For more details, see comments at the definitions of these functions below\n// in this file.\n//\n// The following statement will instantiate tests from the FooTest test case\n// each with parameter values \"meeny\", \"miny\", and \"moe\".\n\nINSTANTIATE_TEST_CASE_P(InstantiationName,\n                        FooTest,\n                        Values(\"meeny\", \"miny\", \"moe\"));\n\n// To distinguish different instances of the pattern, (yes, you\n// can instantiate it more then once) the first argument to the\n// INSTANTIATE_TEST_CASE_P macro is a prefix that will be added to the\n// actual test case name. Remember to pick unique prefixes for different\n// instantiations. The tests from the instantiation above will have\n// these names:\n//\n//    * InstantiationName/FooTest.DoesBlah/0 for \"meeny\"\n//    * InstantiationName/FooTest.DoesBlah/1 for \"miny\"\n//    * InstantiationName/FooTest.DoesBlah/2 for \"moe\"\n//    * InstantiationName/FooTest.HasBlahBlah/0 for \"meeny\"\n//    * InstantiationName/FooTest.HasBlahBlah/1 for \"miny\"\n//    * InstantiationName/FooTest.HasBlahBlah/2 for \"moe\"\n//\n// You can use these names in --gtest_filter.\n//\n// This statement will instantiate all tests from FooTest again, each\n// with parameter values \"cat\" and \"dog\":\n\nconst char* pets[] = {\"cat\", \"dog\"};\nINSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest, ValuesIn(pets));\n\n// The tests from the instantiation above will have these names:\n//\n//    * AnotherInstantiationName/FooTest.DoesBlah/0 for \"cat\"\n//    * AnotherInstantiationName/FooTest.DoesBlah/1 for \"dog\"\n//    * AnotherInstantiationName/FooTest.HasBlahBlah/0 for \"cat\"\n//    * AnotherInstantiationName/FooTest.HasBlahBlah/1 for \"dog\"\n//\n// Please note that INSTANTIATE_TEST_CASE_P will instantiate all tests\n// in the given test case, whether their definitions come before or\n// AFTER the INSTANTIATE_TEST_CASE_P statement.\n//\n// Please also note that generator expressions (including parameters to the\n// generators) are evaluated in InitGoogleTest(), after main() has started.\n// This allows the user on one hand, to adjust generator parameters in order\n// to dynamically determine a set of tests to run and on the other hand,\n// give the user a chance to inspect the generated tests with Google Test\n// reflection API before RUN_ALL_TESTS() is executed.\n//\n// You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc\n// for more examples.\n//\n// In the future, we plan to publish the API for defining new parameter\n// generators. But for now this interface remains part of the internal\n// implementation and is subject to change.\n//\n//\n// A parameterized test fixture must be derived from testing::Test and from\n// testing::WithParamInterface<T>, where T is the type of the parameter\n// values. Inheriting from TestWithParam<T> satisfies that requirement because\n// TestWithParam<T> inherits from both Test and WithParamInterface. In more\n// complicated hierarchies, however, it is occasionally useful to inherit\n// separately from Test and WithParamInterface. For example:\n\nclass BaseTest : public ::testing::Test {\n  // You can inherit all the usual members for a non-parameterized test\n  // fixture here.\n};\n\nclass DerivedTest : public BaseTest, public ::testing::WithParamInterface<int> {\n  // The usual test fixture members go here too.\n};\n\nTEST_F(BaseTest, HasFoo) {\n  // This is an ordinary non-parameterized test.\n}\n\nTEST_P(DerivedTest, DoesBlah) {\n  // GetParam works just the same here as if you inherit from TestWithParam.\n  EXPECT_TRUE(foo.Blah(GetParam()));\n}\n\n#endif  // 0\n\n#include \"gtest/internal/gtest-port.h\"\n\n#if !GTEST_OS_SYMBIAN\n# include <utility>\n#endif\n\n// scripts/fuse_gtest.py depends on gtest's own header being #included\n// *unconditionally*.  Therefore these #includes cannot be moved\n// inside #if GTEST_HAS_PARAM_TEST.\n#include \"gtest/internal/gtest-internal.h\"\n#include \"gtest/internal/gtest-param-util.h\"\n#include \"gtest/internal/gtest-param-util-generated.h\"\n\n#if GTEST_HAS_PARAM_TEST\n\nnamespace testing {\n\n// Functions producing parameter generators.\n//\n// Google Test uses these generators to produce parameters for value-\n// parameterized tests. When a parameterized test case is instantiated\n// with a particular generator, Google Test creates and runs tests\n// for each element in the sequence produced by the generator.\n//\n// In the following sample, tests from test case FooTest are instantiated\n// each three times with parameter values 3, 5, and 8:\n//\n// class FooTest : public TestWithParam<int> { ... };\n//\n// TEST_P(FooTest, TestThis) {\n// }\n// TEST_P(FooTest, TestThat) {\n// }\n// INSTANTIATE_TEST_CASE_P(TestSequence, FooTest, Values(3, 5, 8));\n//\n\n// Range() returns generators providing sequences of values in a range.\n//\n// Synopsis:\n// Range(start, end)\n//   - returns a generator producing a sequence of values {start, start+1,\n//     start+2, ..., }.\n// Range(start, end, step)\n//   - returns a generator producing a sequence of values {start, start+step,\n//     start+step+step, ..., }.\n// Notes:\n//   * The generated sequences never include end. For example, Range(1, 5)\n//     returns a generator producing a sequence {1, 2, 3, 4}. Range(1, 9, 2)\n//     returns a generator producing {1, 3, 5, 7}.\n//   * start and end must have the same type. That type may be any integral or\n//     floating-point type or a user defined type satisfying these conditions:\n//     * It must be assignable (have operator=() defined).\n//     * It must have operator+() (operator+(int-compatible type) for\n//       two-operand version).\n//     * It must have operator<() defined.\n//     Elements in the resulting sequences will also have that type.\n//   * Condition start < end must be satisfied in order for resulting sequences\n//     to contain any elements.\n//\ntemplate <typename T, typename IncrementT>\ninternal::ParamGenerator<T> Range(T start, T end, IncrementT step) {\n  return internal::ParamGenerator<T>(\n      new internal::RangeGenerator<T, IncrementT>(start, end, step));\n}\n\ntemplate <typename T>\ninternal::ParamGenerator<T> Range(T start, T end) {\n  return Range(start, end, 1);\n}\n\n// ValuesIn() function allows generation of tests with parameters coming from\n// a container.\n//\n// Synopsis:\n// ValuesIn(const T (&array)[N])\n//   - returns a generator producing sequences with elements from\n//     a C-style array.\n// ValuesIn(const Container& container)\n//   - returns a generator producing sequences with elements from\n//     an STL-style container.\n// ValuesIn(Iterator begin, Iterator end)\n//   - returns a generator producing sequences with elements from\n//     a range [begin, end) defined by a pair of STL-style iterators. These\n//     iterators can also be plain C pointers.\n//\n// Please note that ValuesIn copies the values from the containers\n// passed in and keeps them to generate tests in RUN_ALL_TESTS().\n//\n// Examples:\n//\n// This instantiates tests from test case StringTest\n// each with C-string values of \"foo\", \"bar\", and \"baz\":\n//\n// const char* strings[] = {\"foo\", \"bar\", \"baz\"};\n// INSTANTIATE_TEST_CASE_P(StringSequence, SrtingTest, ValuesIn(strings));\n//\n// This instantiates tests from test case StlStringTest\n// each with STL strings with values \"a\" and \"b\":\n//\n// ::std::vector< ::std::string> GetParameterStrings() {\n//   ::std::vector< ::std::string> v;\n//   v.push_back(\"a\");\n//   v.push_back(\"b\");\n//   return v;\n// }\n//\n// INSTANTIATE_TEST_CASE_P(CharSequence,\n//                         StlStringTest,\n//                         ValuesIn(GetParameterStrings()));\n//\n//\n// This will also instantiate tests from CharTest\n// each with parameter values 'a' and 'b':\n//\n// ::std::list<char> GetParameterChars() {\n//   ::std::list<char> list;\n//   list.push_back('a');\n//   list.push_back('b');\n//   return list;\n// }\n// ::std::list<char> l = GetParameterChars();\n// INSTANTIATE_TEST_CASE_P(CharSequence2,\n//                         CharTest,\n//                         ValuesIn(l.begin(), l.end()));\n//\ntemplate <typename ForwardIterator>\ninternal::ParamGenerator<\n  typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>\nValuesIn(ForwardIterator begin, ForwardIterator end) {\n  typedef typename ::testing::internal::IteratorTraits<ForwardIterator>\n      ::value_type ParamType;\n  return internal::ParamGenerator<ParamType>(\n      new internal::ValuesInIteratorRangeGenerator<ParamType>(begin, end));\n}\n\ntemplate <typename T, size_t N>\ninternal::ParamGenerator<T> ValuesIn(const T (&array)[N]) {\n  return ValuesIn(array, array + N);\n}\n\ntemplate <class Container>\ninternal::ParamGenerator<typename Container::value_type> ValuesIn(\n    const Container& container) {\n  return ValuesIn(container.begin(), container.end());\n}\n\n// Values() allows generating tests from explicitly specified list of\n// parameters.\n//\n// Synopsis:\n// Values(T v1, T v2, ..., T vN)\n//   - returns a generator producing sequences with elements v1, v2, ..., vN.\n//\n// For example, this instantiates tests from test case BarTest each\n// with values \"one\", \"two\", and \"three\":\n//\n// INSTANTIATE_TEST_CASE_P(NumSequence, BarTest, Values(\"one\", \"two\", \"three\"));\n//\n// This instantiates tests from test case BazTest each with values 1, 2, 3.5.\n// The exact type of values will depend on the type of parameter in BazTest.\n//\n// INSTANTIATE_TEST_CASE_P(FloatingNumbers, BazTest, Values(1, 2, 3.5));\n//\n// Currently, Values() supports from 1 to 50 parameters.\n//\ntemplate <typename T1>\ninternal::ValueArray1<T1> Values(T1 v1) {\n  return internal::ValueArray1<T1>(v1);\n}\n\ntemplate <typename T1, typename T2>\ninternal::ValueArray2<T1, T2> Values(T1 v1, T2 v2) {\n  return internal::ValueArray2<T1, T2>(v1, v2);\n}\n\ntemplate <typename T1, typename T2, typename T3>\ninternal::ValueArray3<T1, T2, T3> Values(T1 v1, T2 v2, T3 v3) {\n  return internal::ValueArray3<T1, T2, T3>(v1, v2, v3);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4>\ninternal::ValueArray4<T1, T2, T3, T4> Values(T1 v1, T2 v2, T3 v3, T4 v4) {\n  return internal::ValueArray4<T1, T2, T3, T4>(v1, v2, v3, v4);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5>\ninternal::ValueArray5<T1, T2, T3, T4, T5> Values(T1 v1, T2 v2, T3 v3, T4 v4,\n    T5 v5) {\n  return internal::ValueArray5<T1, T2, T3, T4, T5>(v1, v2, v3, v4, v5);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6>\ninternal::ValueArray6<T1, T2, T3, T4, T5, T6> Values(T1 v1, T2 v2, T3 v3,\n    T4 v4, T5 v5, T6 v6) {\n  return internal::ValueArray6<T1, T2, T3, T4, T5, T6>(v1, v2, v3, v4, v5, v6);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7>\ninternal::ValueArray7<T1, T2, T3, T4, T5, T6, T7> Values(T1 v1, T2 v2, T3 v3,\n    T4 v4, T5 v5, T6 v6, T7 v7) {\n  return internal::ValueArray7<T1, T2, T3, T4, T5, T6, T7>(v1, v2, v3, v4, v5,\n      v6, v7);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8>\ninternal::ValueArray8<T1, T2, T3, T4, T5, T6, T7, T8> Values(T1 v1, T2 v2,\n    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8) {\n  return internal::ValueArray8<T1, T2, T3, T4, T5, T6, T7, T8>(v1, v2, v3, v4,\n      v5, v6, v7, v8);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9>\ninternal::ValueArray9<T1, T2, T3, T4, T5, T6, T7, T8, T9> Values(T1 v1, T2 v2,\n    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9) {\n  return internal::ValueArray9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(v1, v2, v3,\n      v4, v5, v6, v7, v8, v9);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10>\ninternal::ValueArray10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> Values(T1 v1,\n    T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10) {\n  return internal::ValueArray10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(v1,\n      v2, v3, v4, v5, v6, v7, v8, v9, v10);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11>\ninternal::ValueArray11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,\n    T11> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11) {\n  return internal::ValueArray11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10,\n      T11>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12>\ninternal::ValueArray12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n    T12> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11, T12 v12) {\n  return internal::ValueArray12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13>\ninternal::ValueArray13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n    T13> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11, T12 v12, T13 v13) {\n  return internal::ValueArray13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14>\ninternal::ValueArray14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14) {\n  return internal::ValueArray14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,\n      v14);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15>\ninternal::ValueArray15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,\n    T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15) {\n  return internal::ValueArray15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12,\n      v13, v14, v15);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16>\ninternal::ValueArray16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,\n    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,\n    T16 v16) {\n  return internal::ValueArray16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,\n      v12, v13, v14, v15, v16);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17>\ninternal::ValueArray17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,\n    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,\n    T16 v16, T17 v17) {\n  return internal::ValueArray17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10,\n      v11, v12, v13, v14, v15, v16, v17);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18>\ninternal::ValueArray18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6,\n    T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,\n    T16 v16, T17 v17, T18 v18) {\n  return internal::ValueArray18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18>(v1, v2, v3, v4, v5, v6, v7, v8, v9,\n      v10, v11, v12, v13, v14, v15, v16, v17, v18);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19>\ninternal::ValueArray19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5,\n    T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14,\n    T15 v15, T16 v16, T17 v17, T18 v18, T19 v19) {\n  return internal::ValueArray19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19>(v1, v2, v3, v4, v5, v6, v7, v8,\n      v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20>\ninternal::ValueArray20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20> Values(T1 v1, T2 v2, T3 v3, T4 v4,\n    T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,\n    T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20) {\n  return internal::ValueArray20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20>(v1, v2, v3, v4, v5, v6, v7,\n      v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21>\ninternal::ValueArray21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21> Values(T1 v1, T2 v2, T3 v3, T4 v4,\n    T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,\n    T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21) {\n  return internal::ValueArray21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21>(v1, v2, v3, v4, v5, v6,\n      v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22>\ninternal::ValueArray22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22> Values(T1 v1, T2 v2, T3 v3,\n    T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,\n    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,\n    T21 v21, T22 v22) {\n  return internal::ValueArray22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22>(v1, v2, v3, v4,\n      v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,\n      v20, v21, v22);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23>\ninternal::ValueArray23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> Values(T1 v1, T2 v2,\n    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,\n    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,\n    T21 v21, T22 v22, T23 v23) {\n  return internal::ValueArray23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23>(v1, v2, v3,\n      v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,\n      v20, v21, v22, v23);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24>\ninternal::ValueArray24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> Values(T1 v1, T2 v2,\n    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,\n    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,\n    T21 v21, T22 v22, T23 v23, T24 v24) {\n  return internal::ValueArray24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24>(v1, v2,\n      v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18,\n      v19, v20, v21, v22, v23, v24);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25>\ninternal::ValueArray25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> Values(T1 v1,\n    T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11,\n    T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19,\n    T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25) {\n  return internal::ValueArray25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25>(v1,\n      v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17,\n      v18, v19, v20, v21, v22, v23, v24, v25);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26>\ninternal::ValueArray26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n    T26> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n    T26 v26) {\n  return internal::ValueArray26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15,\n      v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27>\ninternal::ValueArray27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n    T27> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n    T26 v26, T27 v27) {\n  return internal::ValueArray27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14,\n      v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28>\ninternal::ValueArray28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n    T28> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n    T26 v26, T27 v27, T28 v28) {\n  return internal::ValueArray28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,\n      v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27,\n      v28);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29>\ninternal::ValueArray29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n    T26 v26, T27 v27, T28 v28, T29 v29) {\n  return internal::ValueArray29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12,\n      v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26,\n      v27, v28, v29);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30>\ninternal::ValueArray30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,\n    T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16,\n    T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24,\n    T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30) {\n  return internal::ValueArray30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,\n      v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25,\n      v26, v27, v28, v29, v30);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31>\ninternal::ValueArray31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,\n    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,\n    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,\n    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31) {\n  return internal::ValueArray31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10,\n      v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24,\n      v25, v26, v27, v28, v29, v30, v31);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32>\ninternal::ValueArray32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,\n    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,\n    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,\n    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,\n    T32 v32) {\n  return internal::ValueArray32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32>(v1, v2, v3, v4, v5, v6, v7, v8, v9,\n      v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,\n      v24, v25, v26, v27, v28, v29, v30, v31, v32);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33>\ninternal::ValueArray33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6,\n    T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,\n    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,\n    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,\n    T32 v32, T33 v33) {\n  return internal::ValueArray33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33>(v1, v2, v3, v4, v5, v6, v7, v8,\n      v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,\n      v24, v25, v26, v27, v28, v29, v30, v31, v32, v33);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34>\ninternal::ValueArray34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5,\n    T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14,\n    T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22,\n    T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30,\n    T31 v31, T32 v32, T33 v33, T34 v34) {\n  return internal::ValueArray34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34>(v1, v2, v3, v4, v5, v6, v7,\n      v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22,\n      v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35>\ninternal::ValueArray35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35> Values(T1 v1, T2 v2, T3 v3, T4 v4,\n    T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,\n    T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21,\n    T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29,\n    T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35) {\n  return internal::ValueArray35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35>(v1, v2, v3, v4, v5, v6,\n      v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21,\n      v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36>\ninternal::ValueArray36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36> Values(T1 v1, T2 v2, T3 v3, T4 v4,\n    T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,\n    T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21,\n    T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29,\n    T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36) {\n  return internal::ValueArray36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36>(v1, v2, v3, v4,\n      v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,\n      v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33,\n      v34, v35, v36);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37>\ninternal::ValueArray37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37> Values(T1 v1, T2 v2, T3 v3,\n    T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,\n    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,\n    T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28,\n    T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36,\n    T37 v37) {\n  return internal::ValueArray37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37>(v1, v2, v3,\n      v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,\n      v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33,\n      v34, v35, v36, v37);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38>\ninternal::ValueArray38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> Values(T1 v1, T2 v2,\n    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,\n    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,\n    T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28,\n    T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36,\n    T37 v37, T38 v38) {\n  return internal::ValueArray38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38>(v1, v2,\n      v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18,\n      v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32,\n      v33, v34, v35, v36, v37, v38);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39>\ninternal::ValueArray39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> Values(T1 v1, T2 v2,\n    T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,\n    T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,\n    T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28,\n    T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36,\n    T37 v37, T38 v38, T39 v39) {\n  return internal::ValueArray39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39>(v1,\n      v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17,\n      v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31,\n      v32, v33, v34, v35, v36, v37, v38, v39);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40>\ninternal::ValueArray40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> Values(T1 v1,\n    T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11,\n    T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19,\n    T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27,\n    T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35,\n    T36 v36, T37 v37, T38 v38, T39 v39, T40 v40) {\n  return internal::ValueArray40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15,\n      v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29,\n      v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41>\ninternal::ValueArray41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n    T41> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n    T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n    T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41) {\n  return internal::ValueArray41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40, T41>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14,\n      v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28,\n      v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42>\ninternal::ValueArray42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,\n    T42> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n    T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n    T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n    T42 v42) {\n  return internal::ValueArray42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40, T41, T42>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,\n      v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27,\n      v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41,\n      v42);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43>\ninternal::ValueArray43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,\n    T43> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n    T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n    T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n    T42 v42, T43 v43) {\n  return internal::ValueArray43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40, T41, T42, T43>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12,\n      v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26,\n      v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40,\n      v41, v42, v43);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44>\ninternal::ValueArray44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n    T44> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n    T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n    T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n    T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n    T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n    T42 v42, T43 v43, T44 v44) {\n  return internal::ValueArray44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40, T41, T42, T43, T44>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,\n      v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25,\n      v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39,\n      v40, v41, v42, v43, v44);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45>\ninternal::ValueArray45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n    T44, T45> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,\n    T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16,\n    T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24,\n    T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32,\n    T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40,\n    T41 v41, T42 v42, T43 v43, T44 v44, T45 v45) {\n  return internal::ValueArray45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40, T41, T42, T43, T44, T45>(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10,\n      v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24,\n      v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38,\n      v39, v40, v41, v42, v43, v44, v45);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46>\ninternal::ValueArray46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n    T44, T45, T46> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,\n    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,\n    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,\n    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,\n    T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39,\n    T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46) {\n  return internal::ValueArray46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40, T41, T42, T43, T44, T45, T46>(v1, v2, v3, v4, v5, v6, v7, v8, v9,\n      v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,\n      v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37,\n      v38, v39, v40, v41, v42, v43, v44, v45, v46);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47>\ninternal::ValueArray47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n    T44, T45, T46, T47> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,\n    T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,\n    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,\n    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,\n    T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39,\n    T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47) {\n  return internal::ValueArray47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40, T41, T42, T43, T44, T45, T46, T47>(v1, v2, v3, v4, v5, v6, v7, v8,\n      v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,\n      v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37,\n      v38, v39, v40, v41, v42, v43, v44, v45, v46, v47);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48>\ninternal::ValueArray48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n    T44, T45, T46, T47, T48> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6,\n    T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,\n    T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,\n    T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,\n    T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39,\n    T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47,\n    T48 v48) {\n  return internal::ValueArray48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40, T41, T42, T43, T44, T45, T46, T47, T48>(v1, v2, v3, v4, v5, v6, v7,\n      v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22,\n      v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36,\n      v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48, typename T49>\ninternal::ValueArray49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n    T44, T45, T46, T47, T48, T49> Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5,\n    T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14,\n    T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22,\n    T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30,\n    T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38,\n    T39 v39, T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46,\n    T47 v47, T48 v48, T49 v49) {\n  return internal::ValueArray49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40, T41, T42, T43, T44, T45, T46, T47, T48, T49>(v1, v2, v3, v4, v5, v6,\n      v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21,\n      v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35,\n      v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48, typename T49, typename T50>\ninternal::ValueArray50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n    T44, T45, T46, T47, T48, T49, T50> Values(T1 v1, T2 v2, T3 v3, T4 v4,\n    T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,\n    T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21,\n    T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29,\n    T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37,\n    T38 v38, T39 v39, T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45,\n    T46 v46, T47 v47, T48 v48, T49 v49, T50 v50) {\n  return internal::ValueArray50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26, T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40, T41, T42, T43, T44, T45, T46, T47, T48, T49, T50>(v1, v2, v3, v4,\n      v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,\n      v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33,\n      v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47,\n      v48, v49, v50);\n}\n\n// Bool() allows generating tests with parameters in a set of (false, true).\n//\n// Synopsis:\n// Bool()\n//   - returns a generator producing sequences with elements {false, true}.\n//\n// It is useful when testing code that depends on Boolean flags. Combinations\n// of multiple flags can be tested when several Bool()'s are combined using\n// Combine() function.\n//\n// In the following example all tests in the test case FlagDependentTest\n// will be instantiated twice with parameters false and true.\n//\n// class FlagDependentTest : public testing::TestWithParam<bool> {\n//   virtual void SetUp() {\n//     external_flag = GetParam();\n//   }\n// }\n// INSTANTIATE_TEST_CASE_P(BoolSequence, FlagDependentTest, Bool());\n//\ninline internal::ParamGenerator<bool> Bool() {\n  return Values(false, true);\n}\n\n# if GTEST_HAS_COMBINE\n// Combine() allows the user to combine two or more sequences to produce\n// values of a Cartesian product of those sequences' elements.\n//\n// Synopsis:\n// Combine(gen1, gen2, ..., genN)\n//   - returns a generator producing sequences with elements coming from\n//     the Cartesian product of elements from the sequences generated by\n//     gen1, gen2, ..., genN. The sequence elements will have a type of\n//     tuple<T1, T2, ..., TN> where T1, T2, ..., TN are the types\n//     of elements from sequences produces by gen1, gen2, ..., genN.\n//\n// Combine can have up to 10 arguments. This number is currently limited\n// by the maximum number of elements in the tuple implementation used by Google\n// Test.\n//\n// Example:\n//\n// This will instantiate tests in test case AnimalTest each one with\n// the parameter values tuple(\"cat\", BLACK), tuple(\"cat\", WHITE),\n// tuple(\"dog\", BLACK), and tuple(\"dog\", WHITE):\n//\n// enum Color { BLACK, GRAY, WHITE };\n// class AnimalTest\n//     : public testing::TestWithParam<tuple<const char*, Color> > {...};\n//\n// TEST_P(AnimalTest, AnimalLooksNice) {...}\n//\n// INSTANTIATE_TEST_CASE_P(AnimalVariations, AnimalTest,\n//                         Combine(Values(\"cat\", \"dog\"),\n//                                 Values(BLACK, WHITE)));\n//\n// This will instantiate tests in FlagDependentTest with all variations of two\n// Boolean flags:\n//\n// class FlagDependentTest\n//     : public testing::TestWithParam<tuple<bool, bool> > {\n//   virtual void SetUp() {\n//     // Assigns external_flag_1 and external_flag_2 values from the tuple.\n//     tie(external_flag_1, external_flag_2) = GetParam();\n//   }\n// };\n//\n// TEST_P(FlagDependentTest, TestFeature1) {\n//   // Test your code using external_flag_1 and external_flag_2 here.\n// }\n// INSTANTIATE_TEST_CASE_P(TwoBoolSequence, FlagDependentTest,\n//                         Combine(Bool(), Bool()));\n//\ntemplate <typename Generator1, typename Generator2>\ninternal::CartesianProductHolder2<Generator1, Generator2> Combine(\n    const Generator1& g1, const Generator2& g2) {\n  return internal::CartesianProductHolder2<Generator1, Generator2>(\n      g1, g2);\n}\n\ntemplate <typename Generator1, typename Generator2, typename Generator3>\ninternal::CartesianProductHolder3<Generator1, Generator2, Generator3> Combine(\n    const Generator1& g1, const Generator2& g2, const Generator3& g3) {\n  return internal::CartesianProductHolder3<Generator1, Generator2, Generator3>(\n      g1, g2, g3);\n}\n\ntemplate <typename Generator1, typename Generator2, typename Generator3,\n    typename Generator4>\ninternal::CartesianProductHolder4<Generator1, Generator2, Generator3,\n    Generator4> Combine(\n    const Generator1& g1, const Generator2& g2, const Generator3& g3,\n        const Generator4& g4) {\n  return internal::CartesianProductHolder4<Generator1, Generator2, Generator3,\n      Generator4>(\n      g1, g2, g3, g4);\n}\n\ntemplate <typename Generator1, typename Generator2, typename Generator3,\n    typename Generator4, typename Generator5>\ninternal::CartesianProductHolder5<Generator1, Generator2, Generator3,\n    Generator4, Generator5> Combine(\n    const Generator1& g1, const Generator2& g2, const Generator3& g3,\n        const Generator4& g4, const Generator5& g5) {\n  return internal::CartesianProductHolder5<Generator1, Generator2, Generator3,\n      Generator4, Generator5>(\n      g1, g2, g3, g4, g5);\n}\n\ntemplate <typename Generator1, typename Generator2, typename Generator3,\n    typename Generator4, typename Generator5, typename Generator6>\ninternal::CartesianProductHolder6<Generator1, Generator2, Generator3,\n    Generator4, Generator5, Generator6> Combine(\n    const Generator1& g1, const Generator2& g2, const Generator3& g3,\n        const Generator4& g4, const Generator5& g5, const Generator6& g6) {\n  return internal::CartesianProductHolder6<Generator1, Generator2, Generator3,\n      Generator4, Generator5, Generator6>(\n      g1, g2, g3, g4, g5, g6);\n}\n\ntemplate <typename Generator1, typename Generator2, typename Generator3,\n    typename Generator4, typename Generator5, typename Generator6,\n    typename Generator7>\ninternal::CartesianProductHolder7<Generator1, Generator2, Generator3,\n    Generator4, Generator5, Generator6, Generator7> Combine(\n    const Generator1& g1, const Generator2& g2, const Generator3& g3,\n        const Generator4& g4, const Generator5& g5, const Generator6& g6,\n        const Generator7& g7) {\n  return internal::CartesianProductHolder7<Generator1, Generator2, Generator3,\n      Generator4, Generator5, Generator6, Generator7>(\n      g1, g2, g3, g4, g5, g6, g7);\n}\n\ntemplate <typename Generator1, typename Generator2, typename Generator3,\n    typename Generator4, typename Generator5, typename Generator6,\n    typename Generator7, typename Generator8>\ninternal::CartesianProductHolder8<Generator1, Generator2, Generator3,\n    Generator4, Generator5, Generator6, Generator7, Generator8> Combine(\n    const Generator1& g1, const Generator2& g2, const Generator3& g3,\n        const Generator4& g4, const Generator5& g5, const Generator6& g6,\n        const Generator7& g7, const Generator8& g8) {\n  return internal::CartesianProductHolder8<Generator1, Generator2, Generator3,\n      Generator4, Generator5, Generator6, Generator7, Generator8>(\n      g1, g2, g3, g4, g5, g6, g7, g8);\n}\n\ntemplate <typename Generator1, typename Generator2, typename Generator3,\n    typename Generator4, typename Generator5, typename Generator6,\n    typename Generator7, typename Generator8, typename Generator9>\ninternal::CartesianProductHolder9<Generator1, Generator2, Generator3,\n    Generator4, Generator5, Generator6, Generator7, Generator8,\n    Generator9> Combine(\n    const Generator1& g1, const Generator2& g2, const Generator3& g3,\n        const Generator4& g4, const Generator5& g5, const Generator6& g6,\n        const Generator7& g7, const Generator8& g8, const Generator9& g9) {\n  return internal::CartesianProductHolder9<Generator1, Generator2, Generator3,\n      Generator4, Generator5, Generator6, Generator7, Generator8, Generator9>(\n      g1, g2, g3, g4, g5, g6, g7, g8, g9);\n}\n\ntemplate <typename Generator1, typename Generator2, typename Generator3,\n    typename Generator4, typename Generator5, typename Generator6,\n    typename Generator7, typename Generator8, typename Generator9,\n    typename Generator10>\ninternal::CartesianProductHolder10<Generator1, Generator2, Generator3,\n    Generator4, Generator5, Generator6, Generator7, Generator8, Generator9,\n    Generator10> Combine(\n    const Generator1& g1, const Generator2& g2, const Generator3& g3,\n        const Generator4& g4, const Generator5& g5, const Generator6& g6,\n        const Generator7& g7, const Generator8& g8, const Generator9& g9,\n        const Generator10& g10) {\n  return internal::CartesianProductHolder10<Generator1, Generator2, Generator3,\n      Generator4, Generator5, Generator6, Generator7, Generator8, Generator9,\n      Generator10>(\n      g1, g2, g3, g4, g5, g6, g7, g8, g9, g10);\n}\n# endif  // GTEST_HAS_COMBINE\n\n\n\n# define TEST_P(test_case_name, test_name) \\\n  class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \\\n      : public test_case_name { \\\n   public: \\\n    GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \\\n    virtual void TestBody(); \\\n   private: \\\n    static int AddToRegistry() { \\\n      ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \\\n          GetTestCasePatternHolder<test_case_name>(\\\n              #test_case_name, __FILE__, __LINE__)->AddTestPattern(\\\n                  #test_case_name, \\\n                  #test_name, \\\n                  new ::testing::internal::TestMetaFactory< \\\n                      GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>()); \\\n      return 0; \\\n    } \\\n    static int gtest_registering_dummy_; \\\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(\\\n        GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \\\n  }; \\\n  int GTEST_TEST_CLASS_NAME_(test_case_name, \\\n                             test_name)::gtest_registering_dummy_ = \\\n      GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \\\n  void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()\n\n# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator) \\\n  ::testing::internal::ParamGenerator<test_case_name::ParamType> \\\n      gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \\\n  int gtest_##prefix##test_case_name##_dummy_ = \\\n      ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \\\n          GetTestCasePatternHolder<test_case_name>(\\\n              #test_case_name, __FILE__, __LINE__)->AddTestCaseInstantiation(\\\n                  #prefix, \\\n                  &gtest_##prefix##test_case_name##_EvalGenerator_, \\\n                  __FILE__, __LINE__)\n\n}  // namespace testing\n\n#endif  // GTEST_HAS_PARAM_TEST\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/gtest-param-test.h.pump",
    "content": "$$ -*- mode: c++; -*-\n$var n = 50  $$ Maximum length of Values arguments we want to support.\n$var maxtuple = 10  $$ Maximum number of Combine arguments we want to support.\n// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: vladl@google.com (Vlad Losev)\n//\n// Macros and functions for implementing parameterized tests\n// in Google C++ Testing Framework (Google Test)\n//\n// This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!\n//\n#ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_\n#define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_\n\n\n// Value-parameterized tests allow you to test your code with different\n// parameters without writing multiple copies of the same test.\n//\n// Here is how you use value-parameterized tests:\n\n#if 0\n\n// To write value-parameterized tests, first you should define a fixture\n// class. It is usually derived from testing::TestWithParam<T> (see below for\n// another inheritance scheme that's sometimes useful in more complicated\n// class hierarchies), where the type of your parameter values.\n// TestWithParam<T> is itself derived from testing::Test. T can be any\n// copyable type. If it's a raw pointer, you are responsible for managing the\n// lifespan of the pointed values.\n\nclass FooTest : public ::testing::TestWithParam<const char*> {\n  // You can implement all the usual class fixture members here.\n};\n\n// Then, use the TEST_P macro to define as many parameterized tests\n// for this fixture as you want. The _P suffix is for \"parameterized\"\n// or \"pattern\", whichever you prefer to think.\n\nTEST_P(FooTest, DoesBlah) {\n  // Inside a test, access the test parameter with the GetParam() method\n  // of the TestWithParam<T> class:\n  EXPECT_TRUE(foo.Blah(GetParam()));\n  ...\n}\n\nTEST_P(FooTest, HasBlahBlah) {\n  ...\n}\n\n// Finally, you can use INSTANTIATE_TEST_CASE_P to instantiate the test\n// case with any set of parameters you want. Google Test defines a number\n// of functions for generating test parameters. They return what we call\n// (surprise!) parameter generators. Here is a  summary of them, which\n// are all in the testing namespace:\n//\n//\n//  Range(begin, end [, step]) - Yields values {begin, begin+step,\n//                               begin+step+step, ...}. The values do not\n//                               include end. step defaults to 1.\n//  Values(v1, v2, ..., vN)    - Yields values {v1, v2, ..., vN}.\n//  ValuesIn(container)        - Yields values from a C-style array, an STL\n//  ValuesIn(begin,end)          container, or an iterator range [begin, end).\n//  Bool()                     - Yields sequence {false, true}.\n//  Combine(g1, g2, ..., gN)   - Yields all combinations (the Cartesian product\n//                               for the math savvy) of the values generated\n//                               by the N generators.\n//\n// For more details, see comments at the definitions of these functions below\n// in this file.\n//\n// The following statement will instantiate tests from the FooTest test case\n// each with parameter values \"meeny\", \"miny\", and \"moe\".\n\nINSTANTIATE_TEST_CASE_P(InstantiationName,\n                        FooTest,\n                        Values(\"meeny\", \"miny\", \"moe\"));\n\n// To distinguish different instances of the pattern, (yes, you\n// can instantiate it more then once) the first argument to the\n// INSTANTIATE_TEST_CASE_P macro is a prefix that will be added to the\n// actual test case name. Remember to pick unique prefixes for different\n// instantiations. The tests from the instantiation above will have\n// these names:\n//\n//    * InstantiationName/FooTest.DoesBlah/0 for \"meeny\"\n//    * InstantiationName/FooTest.DoesBlah/1 for \"miny\"\n//    * InstantiationName/FooTest.DoesBlah/2 for \"moe\"\n//    * InstantiationName/FooTest.HasBlahBlah/0 for \"meeny\"\n//    * InstantiationName/FooTest.HasBlahBlah/1 for \"miny\"\n//    * InstantiationName/FooTest.HasBlahBlah/2 for \"moe\"\n//\n// You can use these names in --gtest_filter.\n//\n// This statement will instantiate all tests from FooTest again, each\n// with parameter values \"cat\" and \"dog\":\n\nconst char* pets[] = {\"cat\", \"dog\"};\nINSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest, ValuesIn(pets));\n\n// The tests from the instantiation above will have these names:\n//\n//    * AnotherInstantiationName/FooTest.DoesBlah/0 for \"cat\"\n//    * AnotherInstantiationName/FooTest.DoesBlah/1 for \"dog\"\n//    * AnotherInstantiationName/FooTest.HasBlahBlah/0 for \"cat\"\n//    * AnotherInstantiationName/FooTest.HasBlahBlah/1 for \"dog\"\n//\n// Please note that INSTANTIATE_TEST_CASE_P will instantiate all tests\n// in the given test case, whether their definitions come before or\n// AFTER the INSTANTIATE_TEST_CASE_P statement.\n//\n// Please also note that generator expressions (including parameters to the\n// generators) are evaluated in InitGoogleTest(), after main() has started.\n// This allows the user on one hand, to adjust generator parameters in order\n// to dynamically determine a set of tests to run and on the other hand,\n// give the user a chance to inspect the generated tests with Google Test\n// reflection API before RUN_ALL_TESTS() is executed.\n//\n// You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc\n// for more examples.\n//\n// In the future, we plan to publish the API for defining new parameter\n// generators. But for now this interface remains part of the internal\n// implementation and is subject to change.\n//\n//\n// A parameterized test fixture must be derived from testing::Test and from\n// testing::WithParamInterface<T>, where T is the type of the parameter\n// values. Inheriting from TestWithParam<T> satisfies that requirement because\n// TestWithParam<T> inherits from both Test and WithParamInterface. In more\n// complicated hierarchies, however, it is occasionally useful to inherit\n// separately from Test and WithParamInterface. For example:\n\nclass BaseTest : public ::testing::Test {\n  // You can inherit all the usual members for a non-parameterized test\n  // fixture here.\n};\n\nclass DerivedTest : public BaseTest, public ::testing::WithParamInterface<int> {\n  // The usual test fixture members go here too.\n};\n\nTEST_F(BaseTest, HasFoo) {\n  // This is an ordinary non-parameterized test.\n}\n\nTEST_P(DerivedTest, DoesBlah) {\n  // GetParam works just the same here as if you inherit from TestWithParam.\n  EXPECT_TRUE(foo.Blah(GetParam()));\n}\n\n#endif  // 0\n\n#include \"gtest/internal/gtest-port.h\"\n\n#if !GTEST_OS_SYMBIAN\n# include <utility>\n#endif\n\n// scripts/fuse_gtest.py depends on gtest's own header being #included\n// *unconditionally*.  Therefore these #includes cannot be moved\n// inside #if GTEST_HAS_PARAM_TEST.\n#include \"gtest/internal/gtest-internal.h\"\n#include \"gtest/internal/gtest-param-util.h\"\n#include \"gtest/internal/gtest-param-util-generated.h\"\n\n#if GTEST_HAS_PARAM_TEST\n\nnamespace testing {\n\n// Functions producing parameter generators.\n//\n// Google Test uses these generators to produce parameters for value-\n// parameterized tests. When a parameterized test case is instantiated\n// with a particular generator, Google Test creates and runs tests\n// for each element in the sequence produced by the generator.\n//\n// In the following sample, tests from test case FooTest are instantiated\n// each three times with parameter values 3, 5, and 8:\n//\n// class FooTest : public TestWithParam<int> { ... };\n//\n// TEST_P(FooTest, TestThis) {\n// }\n// TEST_P(FooTest, TestThat) {\n// }\n// INSTANTIATE_TEST_CASE_P(TestSequence, FooTest, Values(3, 5, 8));\n//\n\n// Range() returns generators providing sequences of values in a range.\n//\n// Synopsis:\n// Range(start, end)\n//   - returns a generator producing a sequence of values {start, start+1,\n//     start+2, ..., }.\n// Range(start, end, step)\n//   - returns a generator producing a sequence of values {start, start+step,\n//     start+step+step, ..., }.\n// Notes:\n//   * The generated sequences never include end. For example, Range(1, 5)\n//     returns a generator producing a sequence {1, 2, 3, 4}. Range(1, 9, 2)\n//     returns a generator producing {1, 3, 5, 7}.\n//   * start and end must have the same type. That type may be any integral or\n//     floating-point type or a user defined type satisfying these conditions:\n//     * It must be assignable (have operator=() defined).\n//     * It must have operator+() (operator+(int-compatible type) for\n//       two-operand version).\n//     * It must have operator<() defined.\n//     Elements in the resulting sequences will also have that type.\n//   * Condition start < end must be satisfied in order for resulting sequences\n//     to contain any elements.\n//\ntemplate <typename T, typename IncrementT>\ninternal::ParamGenerator<T> Range(T start, T end, IncrementT step) {\n  return internal::ParamGenerator<T>(\n      new internal::RangeGenerator<T, IncrementT>(start, end, step));\n}\n\ntemplate <typename T>\ninternal::ParamGenerator<T> Range(T start, T end) {\n  return Range(start, end, 1);\n}\n\n// ValuesIn() function allows generation of tests with parameters coming from\n// a container.\n//\n// Synopsis:\n// ValuesIn(const T (&array)[N])\n//   - returns a generator producing sequences with elements from\n//     a C-style array.\n// ValuesIn(const Container& container)\n//   - returns a generator producing sequences with elements from\n//     an STL-style container.\n// ValuesIn(Iterator begin, Iterator end)\n//   - returns a generator producing sequences with elements from\n//     a range [begin, end) defined by a pair of STL-style iterators. These\n//     iterators can also be plain C pointers.\n//\n// Please note that ValuesIn copies the values from the containers\n// passed in and keeps them to generate tests in RUN_ALL_TESTS().\n//\n// Examples:\n//\n// This instantiates tests from test case StringTest\n// each with C-string values of \"foo\", \"bar\", and \"baz\":\n//\n// const char* strings[] = {\"foo\", \"bar\", \"baz\"};\n// INSTANTIATE_TEST_CASE_P(StringSequence, SrtingTest, ValuesIn(strings));\n//\n// This instantiates tests from test case StlStringTest\n// each with STL strings with values \"a\" and \"b\":\n//\n// ::std::vector< ::std::string> GetParameterStrings() {\n//   ::std::vector< ::std::string> v;\n//   v.push_back(\"a\");\n//   v.push_back(\"b\");\n//   return v;\n// }\n//\n// INSTANTIATE_TEST_CASE_P(CharSequence,\n//                         StlStringTest,\n//                         ValuesIn(GetParameterStrings()));\n//\n//\n// This will also instantiate tests from CharTest\n// each with parameter values 'a' and 'b':\n//\n// ::std::list<char> GetParameterChars() {\n//   ::std::list<char> list;\n//   list.push_back('a');\n//   list.push_back('b');\n//   return list;\n// }\n// ::std::list<char> l = GetParameterChars();\n// INSTANTIATE_TEST_CASE_P(CharSequence2,\n//                         CharTest,\n//                         ValuesIn(l.begin(), l.end()));\n//\ntemplate <typename ForwardIterator>\ninternal::ParamGenerator<\n  typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>\nValuesIn(ForwardIterator begin, ForwardIterator end) {\n  typedef typename ::testing::internal::IteratorTraits<ForwardIterator>\n      ::value_type ParamType;\n  return internal::ParamGenerator<ParamType>(\n      new internal::ValuesInIteratorRangeGenerator<ParamType>(begin, end));\n}\n\ntemplate <typename T, size_t N>\ninternal::ParamGenerator<T> ValuesIn(const T (&array)[N]) {\n  return ValuesIn(array, array + N);\n}\n\ntemplate <class Container>\ninternal::ParamGenerator<typename Container::value_type> ValuesIn(\n    const Container& container) {\n  return ValuesIn(container.begin(), container.end());\n}\n\n// Values() allows generating tests from explicitly specified list of\n// parameters.\n//\n// Synopsis:\n// Values(T v1, T v2, ..., T vN)\n//   - returns a generator producing sequences with elements v1, v2, ..., vN.\n//\n// For example, this instantiates tests from test case BarTest each\n// with values \"one\", \"two\", and \"three\":\n//\n// INSTANTIATE_TEST_CASE_P(NumSequence, BarTest, Values(\"one\", \"two\", \"three\"));\n//\n// This instantiates tests from test case BazTest each with values 1, 2, 3.5.\n// The exact type of values will depend on the type of parameter in BazTest.\n//\n// INSTANTIATE_TEST_CASE_P(FloatingNumbers, BazTest, Values(1, 2, 3.5));\n//\n// Currently, Values() supports from 1 to $n parameters.\n//\n$range i 1..n\n$for i [[\n$range j 1..i\n\ntemplate <$for j, [[typename T$j]]>\ninternal::ValueArray$i<$for j, [[T$j]]> Values($for j, [[T$j v$j]]) {\n  return internal::ValueArray$i<$for j, [[T$j]]>($for j, [[v$j]]);\n}\n\n]]\n\n// Bool() allows generating tests with parameters in a set of (false, true).\n//\n// Synopsis:\n// Bool()\n//   - returns a generator producing sequences with elements {false, true}.\n//\n// It is useful when testing code that depends on Boolean flags. Combinations\n// of multiple flags can be tested when several Bool()'s are combined using\n// Combine() function.\n//\n// In the following example all tests in the test case FlagDependentTest\n// will be instantiated twice with parameters false and true.\n//\n// class FlagDependentTest : public testing::TestWithParam<bool> {\n//   virtual void SetUp() {\n//     external_flag = GetParam();\n//   }\n// }\n// INSTANTIATE_TEST_CASE_P(BoolSequence, FlagDependentTest, Bool());\n//\ninline internal::ParamGenerator<bool> Bool() {\n  return Values(false, true);\n}\n\n# if GTEST_HAS_COMBINE\n// Combine() allows the user to combine two or more sequences to produce\n// values of a Cartesian product of those sequences' elements.\n//\n// Synopsis:\n// Combine(gen1, gen2, ..., genN)\n//   - returns a generator producing sequences with elements coming from\n//     the Cartesian product of elements from the sequences generated by\n//     gen1, gen2, ..., genN. The sequence elements will have a type of\n//     tuple<T1, T2, ..., TN> where T1, T2, ..., TN are the types\n//     of elements from sequences produces by gen1, gen2, ..., genN.\n//\n// Combine can have up to $maxtuple arguments. This number is currently limited\n// by the maximum number of elements in the tuple implementation used by Google\n// Test.\n//\n// Example:\n//\n// This will instantiate tests in test case AnimalTest each one with\n// the parameter values tuple(\"cat\", BLACK), tuple(\"cat\", WHITE),\n// tuple(\"dog\", BLACK), and tuple(\"dog\", WHITE):\n//\n// enum Color { BLACK, GRAY, WHITE };\n// class AnimalTest\n//     : public testing::TestWithParam<tuple<const char*, Color> > {...};\n//\n// TEST_P(AnimalTest, AnimalLooksNice) {...}\n//\n// INSTANTIATE_TEST_CASE_P(AnimalVariations, AnimalTest,\n//                         Combine(Values(\"cat\", \"dog\"),\n//                                 Values(BLACK, WHITE)));\n//\n// This will instantiate tests in FlagDependentTest with all variations of two\n// Boolean flags:\n//\n// class FlagDependentTest\n//     : public testing::TestWithParam<tuple<bool, bool> > {\n//   virtual void SetUp() {\n//     // Assigns external_flag_1 and external_flag_2 values from the tuple.\n//     tie(external_flag_1, external_flag_2) = GetParam();\n//   }\n// };\n//\n// TEST_P(FlagDependentTest, TestFeature1) {\n//   // Test your code using external_flag_1 and external_flag_2 here.\n// }\n// INSTANTIATE_TEST_CASE_P(TwoBoolSequence, FlagDependentTest,\n//                         Combine(Bool(), Bool()));\n//\n$range i 2..maxtuple\n$for i [[\n$range j 1..i\n\ntemplate <$for j, [[typename Generator$j]]>\ninternal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine(\n    $for j, [[const Generator$j& g$j]]) {\n  return internal::CartesianProductHolder$i<$for j, [[Generator$j]]>(\n      $for j, [[g$j]]);\n}\n\n]]\n# endif  // GTEST_HAS_COMBINE\n\n\n\n# define TEST_P(test_case_name, test_name) \\\n  class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \\\n      : public test_case_name { \\\n   public: \\\n    GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \\\n    virtual void TestBody(); \\\n   private: \\\n    static int AddToRegistry() { \\\n      ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \\\n          GetTestCasePatternHolder<test_case_name>(\\\n              #test_case_name, __FILE__, __LINE__)->AddTestPattern(\\\n                  #test_case_name, \\\n                  #test_name, \\\n                  new ::testing::internal::TestMetaFactory< \\\n                      GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>()); \\\n      return 0; \\\n    } \\\n    static int gtest_registering_dummy_; \\\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(\\\n        GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \\\n  }; \\\n  int GTEST_TEST_CLASS_NAME_(test_case_name, \\\n                             test_name)::gtest_registering_dummy_ = \\\n      GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \\\n  void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()\n\n# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator) \\\n  ::testing::internal::ParamGenerator<test_case_name::ParamType> \\\n      gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \\\n  int gtest_##prefix##test_case_name##_dummy_ = \\\n      ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \\\n          GetTestCasePatternHolder<test_case_name>(\\\n              #test_case_name, __FILE__, __LINE__)->AddTestCaseInstantiation(\\\n                  #prefix, \\\n                  &gtest_##prefix##test_case_name##_EvalGenerator_, \\\n                  __FILE__, __LINE__)\n\n}  // namespace testing\n\n#endif  // GTEST_HAS_PARAM_TEST\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/gtest-printers.h",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Test - The Google C++ Testing Framework\n//\n// This file implements a universal value printer that can print a\n// value of any type T:\n//\n//   void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_ptr);\n//\n// A user can teach this function how to print a class type T by\n// defining either operator<<() or PrintTo() in the namespace that\n// defines T.  More specifically, the FIRST defined function in the\n// following list will be used (assuming T is defined in namespace\n// foo):\n//\n//   1. foo::PrintTo(const T&, ostream*)\n//   2. operator<<(ostream&, const T&) defined in either foo or the\n//      global namespace.\n//\n// If none of the above is defined, it will print the debug string of\n// the value if it is a protocol buffer, or print the raw bytes in the\n// value otherwise.\n//\n// To aid debugging: when T is a reference type, the address of the\n// value is also printed; when T is a (const) char pointer, both the\n// pointer value and the NUL-terminated string it points to are\n// printed.\n//\n// We also provide some convenient wrappers:\n//\n//   // Prints a value to a string.  For a (const or not) char\n//   // pointer, the NUL-terminated string (but not the pointer) is\n//   // printed.\n//   std::string ::testing::PrintToString(const T& value);\n//\n//   // Prints a value tersely: for a reference type, the referenced\n//   // value (but not the address) is printed; for a (const or not) char\n//   // pointer, the NUL-terminated string (but not the pointer) is\n//   // printed.\n//   void ::testing::internal::UniversalTersePrint(const T& value, ostream*);\n//\n//   // Prints value using the type inferred by the compiler.  The difference\n//   // from UniversalTersePrint() is that this function prints both the\n//   // pointer and the NUL-terminated string for a (const or not) char pointer.\n//   void ::testing::internal::UniversalPrint(const T& value, ostream*);\n//\n//   // Prints the fields of a tuple tersely to a string vector, one\n//   // element for each field. Tuple support must be enabled in\n//   // gtest-port.h.\n//   std::vector<string> UniversalTersePrintTupleFieldsToStrings(\n//       const Tuple& value);\n//\n// Known limitation:\n//\n// The print primitives print the elements of an STL-style container\n// using the compiler-inferred type of *iter where iter is a\n// const_iterator of the container.  When const_iterator is an input\n// iterator but not a forward iterator, this inferred type may not\n// match value_type, and the print output may be incorrect.  In\n// practice, this is rarely a problem as for most containers\n// const_iterator is a forward iterator.  We'll fix this if there's an\n// actual need for it.  Note that this fix cannot rely on value_type\n// being defined as many user-defined container types don't have\n// value_type.\n\n#ifndef GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_\n#define GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_\n\n#include <ostream>  // NOLINT\n#include <sstream>\n#include <string>\n#include <utility>\n#include <vector>\n#include \"gtest/internal/gtest-port.h\"\n#include \"gtest/internal/gtest-internal.h\"\n\nnamespace testing {\n\n// Definitions in the 'internal' and 'internal2' name spaces are\n// subject to change without notice.  DO NOT USE THEM IN USER CODE!\nnamespace internal2 {\n\n// Prints the given number of bytes in the given object to the given\n// ostream.\nGTEST_API_ void PrintBytesInObjectTo(const unsigned char* obj_bytes,\n                                     size_t count,\n                                     ::std::ostream* os);\n\n// For selecting which printer to use when a given type has neither <<\n// nor PrintTo().\nenum TypeKind {\n  kProtobuf,              // a protobuf type\n  kConvertibleToInteger,  // a type implicitly convertible to BiggestInt\n                          // (e.g. a named or unnamed enum type)\n  kOtherType              // anything else\n};\n\n// TypeWithoutFormatter<T, kTypeKind>::PrintValue(value, os) is called\n// by the universal printer to print a value of type T when neither\n// operator<< nor PrintTo() is defined for T, where kTypeKind is the\n// \"kind\" of T as defined by enum TypeKind.\ntemplate <typename T, TypeKind kTypeKind>\nclass TypeWithoutFormatter {\n public:\n  // This default version is called when kTypeKind is kOtherType.\n  static void PrintValue(const T& value, ::std::ostream* os) {\n    PrintBytesInObjectTo(reinterpret_cast<const unsigned char*>(&value),\n                         sizeof(value), os);\n  }\n};\n\n// We print a protobuf using its ShortDebugString() when the string\n// doesn't exceed this many characters; otherwise we print it using\n// DebugString() for better readability.\nconst size_t kProtobufOneLinerMaxLength = 50;\n\ntemplate <typename T>\nclass TypeWithoutFormatter<T, kProtobuf> {\n public:\n  static void PrintValue(const T& value, ::std::ostream* os) {\n    const ::testing::internal::string short_str = value.ShortDebugString();\n    const ::testing::internal::string pretty_str =\n        short_str.length() <= kProtobufOneLinerMaxLength ?\n        short_str : (\"\\n\" + value.DebugString());\n    *os << (\"<\" + pretty_str + \">\");\n  }\n};\n\ntemplate <typename T>\nclass TypeWithoutFormatter<T, kConvertibleToInteger> {\n public:\n  // Since T has no << operator or PrintTo() but can be implicitly\n  // converted to BiggestInt, we print it as a BiggestInt.\n  //\n  // Most likely T is an enum type (either named or unnamed), in which\n  // case printing it as an integer is the desired behavior.  In case\n  // T is not an enum, printing it as an integer is the best we can do\n  // given that it has no user-defined printer.\n  static void PrintValue(const T& value, ::std::ostream* os) {\n    const internal::BiggestInt kBigInt = value;\n    *os << kBigInt;\n  }\n};\n\n// Prints the given value to the given ostream.  If the value is a\n// protocol message, its debug string is printed; if it's an enum or\n// of a type implicitly convertible to BiggestInt, it's printed as an\n// integer; otherwise the bytes in the value are printed.  This is\n// what UniversalPrinter<T>::Print() does when it knows nothing about\n// type T and T has neither << operator nor PrintTo().\n//\n// A user can override this behavior for a class type Foo by defining\n// a << operator in the namespace where Foo is defined.\n//\n// We put this operator in namespace 'internal2' instead of 'internal'\n// to simplify the implementation, as much code in 'internal' needs to\n// use << in STL, which would conflict with our own << were it defined\n// in 'internal'.\n//\n// Note that this operator<< takes a generic std::basic_ostream<Char,\n// CharTraits> type instead of the more restricted std::ostream.  If\n// we define it to take an std::ostream instead, we'll get an\n// \"ambiguous overloads\" compiler error when trying to print a type\n// Foo that supports streaming to std::basic_ostream<Char,\n// CharTraits>, as the compiler cannot tell whether\n// operator<<(std::ostream&, const T&) or\n// operator<<(std::basic_stream<Char, CharTraits>, const Foo&) is more\n// specific.\ntemplate <typename Char, typename CharTraits, typename T>\n::std::basic_ostream<Char, CharTraits>& operator<<(\n    ::std::basic_ostream<Char, CharTraits>& os, const T& x) {\n  TypeWithoutFormatter<T,\n      (internal::IsAProtocolMessage<T>::value ? kProtobuf :\n       internal::ImplicitlyConvertible<const T&, internal::BiggestInt>::value ?\n       kConvertibleToInteger : kOtherType)>::PrintValue(x, &os);\n  return os;\n}\n\n}  // namespace internal2\n}  // namespace testing\n\n// This namespace MUST NOT BE NESTED IN ::testing, or the name look-up\n// magic needed for implementing UniversalPrinter won't work.\nnamespace testing_internal {\n\n// Used to print a value that is not an STL-style container when the\n// user doesn't define PrintTo() for it.\ntemplate <typename T>\nvoid DefaultPrintNonContainerTo(const T& value, ::std::ostream* os) {\n  // With the following statement, during unqualified name lookup,\n  // testing::internal2::operator<< appears as if it was declared in\n  // the nearest enclosing namespace that contains both\n  // ::testing_internal and ::testing::internal2, i.e. the global\n  // namespace.  For more details, refer to the C++ Standard section\n  // 7.3.4-1 [namespace.udir].  This allows us to fall back onto\n  // testing::internal2::operator<< in case T doesn't come with a <<\n  // operator.\n  //\n  // We cannot write 'using ::testing::internal2::operator<<;', which\n  // gcc 3.3 fails to compile due to a compiler bug.\n  using namespace ::testing::internal2;  // NOLINT\n\n  // Assuming T is defined in namespace foo, in the next statement,\n  // the compiler will consider all of:\n  //\n  //   1. foo::operator<< (thanks to Koenig look-up),\n  //   2. ::operator<< (as the current namespace is enclosed in ::),\n  //   3. testing::internal2::operator<< (thanks to the using statement above).\n  //\n  // The operator<< whose type matches T best will be picked.\n  //\n  // We deliberately allow #2 to be a candidate, as sometimes it's\n  // impossible to define #1 (e.g. when foo is ::std, defining\n  // anything in it is undefined behavior unless you are a compiler\n  // vendor.).\n  *os << value;\n}\n\n}  // namespace testing_internal\n\nnamespace testing {\nnamespace internal {\n\n// UniversalPrinter<T>::Print(value, ostream_ptr) prints the given\n// value to the given ostream.  The caller must ensure that\n// 'ostream_ptr' is not NULL, or the behavior is undefined.\n//\n// We define UniversalPrinter as a class template (as opposed to a\n// function template), as we need to partially specialize it for\n// reference types, which cannot be done with function templates.\ntemplate <typename T>\nclass UniversalPrinter;\n\ntemplate <typename T>\nvoid UniversalPrint(const T& value, ::std::ostream* os);\n\n// Used to print an STL-style container when the user doesn't define\n// a PrintTo() for it.\ntemplate <typename C>\nvoid DefaultPrintTo(IsContainer /* dummy */,\n                    false_type /* is not a pointer */,\n                    const C& container, ::std::ostream* os) {\n  const size_t kMaxCount = 32;  // The maximum number of elements to print.\n  *os << '{';\n  size_t count = 0;\n  for (typename C::const_iterator it = container.begin();\n       it != container.end(); ++it, ++count) {\n    if (count > 0) {\n      *os << ',';\n      if (count == kMaxCount) {  // Enough has been printed.\n        *os << \" ...\";\n        break;\n      }\n    }\n    *os << ' ';\n    // We cannot call PrintTo(*it, os) here as PrintTo() doesn't\n    // handle *it being a native array.\n    internal::UniversalPrint(*it, os);\n  }\n\n  if (count > 0) {\n    *os << ' ';\n  }\n  *os << '}';\n}\n\n// Used to print a pointer that is neither a char pointer nor a member\n// pointer, when the user doesn't define PrintTo() for it.  (A member\n// variable pointer or member function pointer doesn't really point to\n// a location in the address space.  Their representation is\n// implementation-defined.  Therefore they will be printed as raw\n// bytes.)\ntemplate <typename T>\nvoid DefaultPrintTo(IsNotContainer /* dummy */,\n                    true_type /* is a pointer */,\n                    T* p, ::std::ostream* os) {\n  if (p == NULL) {\n    *os << \"NULL\";\n  } else {\n    // C++ doesn't allow casting from a function pointer to any object\n    // pointer.\n    //\n    // IsTrue() silences warnings: \"Condition is always true\",\n    // \"unreachable code\".\n    if (IsTrue(ImplicitlyConvertible<T*, const void*>::value)) {\n      // T is not a function type.  We just call << to print p,\n      // relying on ADL to pick up user-defined << for their pointer\n      // types, if any.\n      *os << p;\n    } else {\n      // T is a function type, so '*os << p' doesn't do what we want\n      // (it just prints p as bool).  We want to print p as a const\n      // void*.  However, we cannot cast it to const void* directly,\n      // even using reinterpret_cast, as earlier versions of gcc\n      // (e.g. 3.4.5) cannot compile the cast when p is a function\n      // pointer.  Casting to UInt64 first solves the problem.\n      *os << reinterpret_cast<const void*>(\n          reinterpret_cast<internal::UInt64>(p));\n    }\n  }\n}\n\n// Used to print a non-container, non-pointer value when the user\n// doesn't define PrintTo() for it.\ntemplate <typename T>\nvoid DefaultPrintTo(IsNotContainer /* dummy */,\n                    false_type /* is not a pointer */,\n                    const T& value, ::std::ostream* os) {\n  ::testing_internal::DefaultPrintNonContainerTo(value, os);\n}\n\n// Prints the given value using the << operator if it has one;\n// otherwise prints the bytes in it.  This is what\n// UniversalPrinter<T>::Print() does when PrintTo() is not specialized\n// or overloaded for type T.\n//\n// A user can override this behavior for a class type Foo by defining\n// an overload of PrintTo() in the namespace where Foo is defined.  We\n// give the user this option as sometimes defining a << operator for\n// Foo is not desirable (e.g. the coding style may prevent doing it,\n// or there is already a << operator but it doesn't do what the user\n// wants).\ntemplate <typename T>\nvoid PrintTo(const T& value, ::std::ostream* os) {\n  // DefaultPrintTo() is overloaded.  The type of its first two\n  // arguments determine which version will be picked.  If T is an\n  // STL-style container, the version for container will be called; if\n  // T is a pointer, the pointer version will be called; otherwise the\n  // generic version will be called.\n  //\n  // Note that we check for container types here, prior to we check\n  // for protocol message types in our operator<<.  The rationale is:\n  //\n  // For protocol messages, we want to give people a chance to\n  // override Google Mock's format by defining a PrintTo() or\n  // operator<<.  For STL containers, other formats can be\n  // incompatible with Google Mock's format for the container\n  // elements; therefore we check for container types here to ensure\n  // that our format is used.\n  //\n  // The second argument of DefaultPrintTo() is needed to bypass a bug\n  // in Symbian's C++ compiler that prevents it from picking the right\n  // overload between:\n  //\n  //   PrintTo(const T& x, ...);\n  //   PrintTo(T* x, ...);\n  DefaultPrintTo(IsContainerTest<T>(0), is_pointer<T>(), value, os);\n}\n\n// The following list of PrintTo() overloads tells\n// UniversalPrinter<T>::Print() how to print standard types (built-in\n// types, strings, plain arrays, and pointers).\n\n// Overloads for various char types.\nGTEST_API_ void PrintTo(unsigned char c, ::std::ostream* os);\nGTEST_API_ void PrintTo(signed char c, ::std::ostream* os);\ninline void PrintTo(char c, ::std::ostream* os) {\n  // When printing a plain char, we always treat it as unsigned.  This\n  // way, the output won't be affected by whether the compiler thinks\n  // char is signed or not.\n  PrintTo(static_cast<unsigned char>(c), os);\n}\n\n// Overloads for other simple built-in types.\ninline void PrintTo(bool x, ::std::ostream* os) {\n  *os << (x ? \"true\" : \"false\");\n}\n\n// Overload for wchar_t type.\n// Prints a wchar_t as a symbol if it is printable or as its internal\n// code otherwise and also as its decimal code (except for L'\\0').\n// The L'\\0' char is printed as \"L'\\\\0'\". The decimal code is printed\n// as signed integer when wchar_t is implemented by the compiler\n// as a signed type and is printed as an unsigned integer when wchar_t\n// is implemented as an unsigned type.\nGTEST_API_ void PrintTo(wchar_t wc, ::std::ostream* os);\n\n// Overloads for C strings.\nGTEST_API_ void PrintTo(const char* s, ::std::ostream* os);\ninline void PrintTo(char* s, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<const char*>(s), os);\n}\n\n// signed/unsigned char is often used for representing binary data, so\n// we print pointers to it as void* to be safe.\ninline void PrintTo(const signed char* s, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<const void*>(s), os);\n}\ninline void PrintTo(signed char* s, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<const void*>(s), os);\n}\ninline void PrintTo(const unsigned char* s, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<const void*>(s), os);\n}\ninline void PrintTo(unsigned char* s, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<const void*>(s), os);\n}\n\n// MSVC can be configured to define wchar_t as a typedef of unsigned\n// short.  It defines _NATIVE_WCHAR_T_DEFINED when wchar_t is a native\n// type.  When wchar_t is a typedef, defining an overload for const\n// wchar_t* would cause unsigned short* be printed as a wide string,\n// possibly causing invalid memory accesses.\n#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)\n// Overloads for wide C strings\nGTEST_API_ void PrintTo(const wchar_t* s, ::std::ostream* os);\ninline void PrintTo(wchar_t* s, ::std::ostream* os) {\n  PrintTo(ImplicitCast_<const wchar_t*>(s), os);\n}\n#endif\n\n// Overload for C arrays.  Multi-dimensional arrays are printed\n// properly.\n\n// Prints the given number of elements in an array, without printing\n// the curly braces.\ntemplate <typename T>\nvoid PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) {\n  UniversalPrint(a[0], os);\n  for (size_t i = 1; i != count; i++) {\n    *os << \", \";\n    UniversalPrint(a[i], os);\n  }\n}\n\n// Overloads for ::string and ::std::string.\n#if GTEST_HAS_GLOBAL_STRING\nGTEST_API_ void PrintStringTo(const ::string&s, ::std::ostream* os);\ninline void PrintTo(const ::string& s, ::std::ostream* os) {\n  PrintStringTo(s, os);\n}\n#endif  // GTEST_HAS_GLOBAL_STRING\n\nGTEST_API_ void PrintStringTo(const ::std::string&s, ::std::ostream* os);\ninline void PrintTo(const ::std::string& s, ::std::ostream* os) {\n  PrintStringTo(s, os);\n}\n\n// Overloads for ::wstring and ::std::wstring.\n#if GTEST_HAS_GLOBAL_WSTRING\nGTEST_API_ void PrintWideStringTo(const ::wstring&s, ::std::ostream* os);\ninline void PrintTo(const ::wstring& s, ::std::ostream* os) {\n  PrintWideStringTo(s, os);\n}\n#endif  // GTEST_HAS_GLOBAL_WSTRING\n\n#if GTEST_HAS_STD_WSTRING\nGTEST_API_ void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os);\ninline void PrintTo(const ::std::wstring& s, ::std::ostream* os) {\n  PrintWideStringTo(s, os);\n}\n#endif  // GTEST_HAS_STD_WSTRING\n\n#if GTEST_HAS_TR1_TUPLE\n// Overload for ::std::tr1::tuple.  Needed for printing function arguments,\n// which are packed as tuples.\n\n// Helper function for printing a tuple.  T must be instantiated with\n// a tuple type.\ntemplate <typename T>\nvoid PrintTupleTo(const T& t, ::std::ostream* os);\n\n// Overloaded PrintTo() for tuples of various arities.  We support\n// tuples of up-to 10 fields.  The following implementation works\n// regardless of whether tr1::tuple is implemented using the\n// non-standard variadic template feature or not.\n\ninline void PrintTo(const ::std::tr1::tuple<>& t, ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n\ntemplate <typename T1>\nvoid PrintTo(const ::std::tr1::tuple<T1>& t, ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n\ntemplate <typename T1, typename T2>\nvoid PrintTo(const ::std::tr1::tuple<T1, T2>& t, ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n\ntemplate <typename T1, typename T2, typename T3>\nvoid PrintTo(const ::std::tr1::tuple<T1, T2, T3>& t, ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4>\nvoid PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4>& t, ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5>\nvoid PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5>& t,\n             ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n          typename T6>\nvoid PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6>& t,\n             ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n          typename T6, typename T7>\nvoid PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7>& t,\n             ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n          typename T6, typename T7, typename T8>\nvoid PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8>& t,\n             ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n          typename T6, typename T7, typename T8, typename T9>\nvoid PrintTo(const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9>& t,\n             ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n          typename T6, typename T7, typename T8, typename T9, typename T10>\nvoid PrintTo(\n    const ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& t,\n    ::std::ostream* os) {\n  PrintTupleTo(t, os);\n}\n#endif  // GTEST_HAS_TR1_TUPLE\n\n// Overload for std::pair.\ntemplate <typename T1, typename T2>\nvoid PrintTo(const ::std::pair<T1, T2>& value, ::std::ostream* os) {\n  *os << '(';\n  // We cannot use UniversalPrint(value.first, os) here, as T1 may be\n  // a reference type.  The same for printing value.second.\n  UniversalPrinter<T1>::Print(value.first, os);\n  *os << \", \";\n  UniversalPrinter<T2>::Print(value.second, os);\n  *os << ')';\n}\n\n// Implements printing a non-reference type T by letting the compiler\n// pick the right overload of PrintTo() for T.\ntemplate <typename T>\nclass UniversalPrinter {\n public:\n  // MSVC warns about adding const to a function type, so we want to\n  // disable the warning.\n#ifdef _MSC_VER\n# pragma warning(push)          // Saves the current warning state.\n# pragma warning(disable:4180)  // Temporarily disables warning 4180.\n#endif  // _MSC_VER\n\n  // Note: we deliberately don't call this PrintTo(), as that name\n  // conflicts with ::testing::internal::PrintTo in the body of the\n  // function.\n  static void Print(const T& value, ::std::ostream* os) {\n    // By default, ::testing::internal::PrintTo() is used for printing\n    // the value.\n    //\n    // Thanks to Koenig look-up, if T is a class and has its own\n    // PrintTo() function defined in its namespace, that function will\n    // be visible here.  Since it is more specific than the generic ones\n    // in ::testing::internal, it will be picked by the compiler in the\n    // following statement - exactly what we want.\n    PrintTo(value, os);\n  }\n\n#ifdef _MSC_VER\n# pragma warning(pop)           // Restores the warning state.\n#endif  // _MSC_VER\n};\n\n// UniversalPrintArray(begin, len, os) prints an array of 'len'\n// elements, starting at address 'begin'.\ntemplate <typename T>\nvoid UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) {\n  if (len == 0) {\n    *os << \"{}\";\n  } else {\n    *os << \"{ \";\n    const size_t kThreshold = 18;\n    const size_t kChunkSize = 8;\n    // If the array has more than kThreshold elements, we'll have to\n    // omit some details by printing only the first and the last\n    // kChunkSize elements.\n    // TODO(wan@google.com): let the user control the threshold using a flag.\n    if (len <= kThreshold) {\n      PrintRawArrayTo(begin, len, os);\n    } else {\n      PrintRawArrayTo(begin, kChunkSize, os);\n      *os << \", ..., \";\n      PrintRawArrayTo(begin + len - kChunkSize, kChunkSize, os);\n    }\n    *os << \" }\";\n  }\n}\n// This overload prints a (const) char array compactly.\nGTEST_API_ void UniversalPrintArray(\n    const char* begin, size_t len, ::std::ostream* os);\n\n// This overload prints a (const) wchar_t array compactly.\nGTEST_API_ void UniversalPrintArray(\n    const wchar_t* begin, size_t len, ::std::ostream* os);\n\n// Implements printing an array type T[N].\ntemplate <typename T, size_t N>\nclass UniversalPrinter<T[N]> {\n public:\n  // Prints the given array, omitting some elements when there are too\n  // many.\n  static void Print(const T (&a)[N], ::std::ostream* os) {\n    UniversalPrintArray(a, N, os);\n  }\n};\n\n// Implements printing a reference type T&.\ntemplate <typename T>\nclass UniversalPrinter<T&> {\n public:\n  // MSVC warns about adding const to a function type, so we want to\n  // disable the warning.\n#ifdef _MSC_VER\n# pragma warning(push)          // Saves the current warning state.\n# pragma warning(disable:4180)  // Temporarily disables warning 4180.\n#endif  // _MSC_VER\n\n  static void Print(const T& value, ::std::ostream* os) {\n    // Prints the address of the value.  We use reinterpret_cast here\n    // as static_cast doesn't compile when T is a function type.\n    *os << \"@\" << reinterpret_cast<const void*>(&value) << \" \";\n\n    // Then prints the value itself.\n    UniversalPrint(value, os);\n  }\n\n#ifdef _MSC_VER\n# pragma warning(pop)           // Restores the warning state.\n#endif  // _MSC_VER\n};\n\n// Prints a value tersely: for a reference type, the referenced value\n// (but not the address) is printed; for a (const) char pointer, the\n// NUL-terminated string (but not the pointer) is printed.\n\ntemplate <typename T>\nclass UniversalTersePrinter {\n public:\n  static void Print(const T& value, ::std::ostream* os) {\n    UniversalPrint(value, os);\n  }\n};\ntemplate <typename T>\nclass UniversalTersePrinter<T&> {\n public:\n  static void Print(const T& value, ::std::ostream* os) {\n    UniversalPrint(value, os);\n  }\n};\ntemplate <typename T, size_t N>\nclass UniversalTersePrinter<T[N]> {\n public:\n  static void Print(const T (&value)[N], ::std::ostream* os) {\n    UniversalPrinter<T[N]>::Print(value, os);\n  }\n};\ntemplate <>\nclass UniversalTersePrinter<const char*> {\n public:\n  static void Print(const char* str, ::std::ostream* os) {\n    if (str == NULL) {\n      *os << \"NULL\";\n    } else {\n      UniversalPrint(string(str), os);\n    }\n  }\n};\ntemplate <>\nclass UniversalTersePrinter<char*> {\n public:\n  static void Print(char* str, ::std::ostream* os) {\n    UniversalTersePrinter<const char*>::Print(str, os);\n  }\n};\n\n#if GTEST_HAS_STD_WSTRING\ntemplate <>\nclass UniversalTersePrinter<const wchar_t*> {\n public:\n  static void Print(const wchar_t* str, ::std::ostream* os) {\n    if (str == NULL) {\n      *os << \"NULL\";\n    } else {\n      UniversalPrint(::std::wstring(str), os);\n    }\n  }\n};\n#endif\n\ntemplate <>\nclass UniversalTersePrinter<wchar_t*> {\n public:\n  static void Print(wchar_t* str, ::std::ostream* os) {\n    UniversalTersePrinter<const wchar_t*>::Print(str, os);\n  }\n};\n\ntemplate <typename T>\nvoid UniversalTersePrint(const T& value, ::std::ostream* os) {\n  UniversalTersePrinter<T>::Print(value, os);\n}\n\n// Prints a value using the type inferred by the compiler.  The\n// difference between this and UniversalTersePrint() is that for a\n// (const) char pointer, this prints both the pointer and the\n// NUL-terminated string.\ntemplate <typename T>\nvoid UniversalPrint(const T& value, ::std::ostream* os) {\n  // A workarond for the bug in VC++ 7.1 that prevents us from instantiating\n  // UniversalPrinter with T directly.\n  typedef T T1;\n  UniversalPrinter<T1>::Print(value, os);\n}\n\n#if GTEST_HAS_TR1_TUPLE\ntypedef ::std::vector<string> Strings;\n\n// This helper template allows PrintTo() for tuples and\n// UniversalTersePrintTupleFieldsToStrings() to be defined by\n// induction on the number of tuple fields.  The idea is that\n// TuplePrefixPrinter<N>::PrintPrefixTo(t, os) prints the first N\n// fields in tuple t, and can be defined in terms of\n// TuplePrefixPrinter<N - 1>.\n\n// The inductive case.\ntemplate <size_t N>\nstruct TuplePrefixPrinter {\n  // Prints the first N fields of a tuple.\n  template <typename Tuple>\n  static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) {\n    TuplePrefixPrinter<N - 1>::PrintPrefixTo(t, os);\n    *os << \", \";\n    UniversalPrinter<typename ::std::tr1::tuple_element<N - 1, Tuple>::type>\n        ::Print(::std::tr1::get<N - 1>(t), os);\n  }\n\n  // Tersely prints the first N fields of a tuple to a string vector,\n  // one element for each field.\n  template <typename Tuple>\n  static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) {\n    TuplePrefixPrinter<N - 1>::TersePrintPrefixToStrings(t, strings);\n    ::std::stringstream ss;\n    UniversalTersePrint(::std::tr1::get<N - 1>(t), &ss);\n    strings->push_back(ss.str());\n  }\n};\n\n// Base cases.\ntemplate <>\nstruct TuplePrefixPrinter<0> {\n  template <typename Tuple>\n  static void PrintPrefixTo(const Tuple&, ::std::ostream*) {}\n\n  template <typename Tuple>\n  static void TersePrintPrefixToStrings(const Tuple&, Strings*) {}\n};\n// We have to specialize the entire TuplePrefixPrinter<> class\n// template here, even though the definition of\n// TersePrintPrefixToStrings() is the same as the generic version, as\n// Embarcadero (formerly CodeGear, formerly Borland) C++ doesn't\n// support specializing a method template of a class template.\ntemplate <>\nstruct TuplePrefixPrinter<1> {\n  template <typename Tuple>\n  static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) {\n    UniversalPrinter<typename ::std::tr1::tuple_element<0, Tuple>::type>::\n        Print(::std::tr1::get<0>(t), os);\n  }\n\n  template <typename Tuple>\n  static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) {\n    ::std::stringstream ss;\n    UniversalTersePrint(::std::tr1::get<0>(t), &ss);\n    strings->push_back(ss.str());\n  }\n};\n\n// Helper function for printing a tuple.  T must be instantiated with\n// a tuple type.\ntemplate <typename T>\nvoid PrintTupleTo(const T& t, ::std::ostream* os) {\n  *os << \"(\";\n  TuplePrefixPrinter< ::std::tr1::tuple_size<T>::value>::\n      PrintPrefixTo(t, os);\n  *os << \")\";\n}\n\n// Prints the fields of a tuple tersely to a string vector, one\n// element for each field.  See the comment before\n// UniversalTersePrint() for how we define \"tersely\".\ntemplate <typename Tuple>\nStrings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) {\n  Strings result;\n  TuplePrefixPrinter< ::std::tr1::tuple_size<Tuple>::value>::\n      TersePrintPrefixToStrings(value, &result);\n  return result;\n}\n#endif  // GTEST_HAS_TR1_TUPLE\n\n}  // namespace internal\n\ntemplate <typename T>\n::std::string PrintToString(const T& value) {\n  ::std::stringstream ss;\n  internal::UniversalTersePrinter<T>::Print(value, &ss);\n  return ss.str();\n}\n\n}  // namespace testing\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/gtest-spi.h",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// Utilities for testing Google Test itself and code that uses Google Test\n// (e.g. frameworks built on top of Google Test).\n\n#ifndef GTEST_INCLUDE_GTEST_GTEST_SPI_H_\n#define GTEST_INCLUDE_GTEST_GTEST_SPI_H_\n\n#include \"gtest/gtest.h\"\n\nnamespace testing {\n\n// This helper class can be used to mock out Google Test failure reporting\n// so that we can test Google Test or code that builds on Google Test.\n//\n// An object of this class appends a TestPartResult object to the\n// TestPartResultArray object given in the constructor whenever a Google Test\n// failure is reported. It can either intercept only failures that are\n// generated in the same thread that created this object or it can intercept\n// all generated failures. The scope of this mock object can be controlled with\n// the second argument to the two arguments constructor.\nclass GTEST_API_ ScopedFakeTestPartResultReporter\n    : public TestPartResultReporterInterface {\n public:\n  // The two possible mocking modes of this object.\n  enum InterceptMode {\n    INTERCEPT_ONLY_CURRENT_THREAD,  // Intercepts only thread local failures.\n    INTERCEPT_ALL_THREADS           // Intercepts all failures.\n  };\n\n  // The c'tor sets this object as the test part result reporter used\n  // by Google Test.  The 'result' parameter specifies where to report the\n  // results. This reporter will only catch failures generated in the current\n  // thread. DEPRECATED\n  explicit ScopedFakeTestPartResultReporter(TestPartResultArray* result);\n\n  // Same as above, but you can choose the interception scope of this object.\n  ScopedFakeTestPartResultReporter(InterceptMode intercept_mode,\n                                   TestPartResultArray* result);\n\n  // The d'tor restores the previous test part result reporter.\n  virtual ~ScopedFakeTestPartResultReporter();\n\n  // Appends the TestPartResult object to the TestPartResultArray\n  // received in the constructor.\n  //\n  // This method is from the TestPartResultReporterInterface\n  // interface.\n  virtual void ReportTestPartResult(const TestPartResult& result);\n private:\n  void Init();\n\n  const InterceptMode intercept_mode_;\n  TestPartResultReporterInterface* old_reporter_;\n  TestPartResultArray* const result_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedFakeTestPartResultReporter);\n};\n\nnamespace internal {\n\n// A helper class for implementing EXPECT_FATAL_FAILURE() and\n// EXPECT_NONFATAL_FAILURE().  Its destructor verifies that the given\n// TestPartResultArray contains exactly one failure that has the given\n// type and contains the given substring.  If that's not the case, a\n// non-fatal failure will be generated.\nclass GTEST_API_ SingleFailureChecker {\n public:\n  // The constructor remembers the arguments.\n  SingleFailureChecker(const TestPartResultArray* results,\n                       TestPartResult::Type type,\n                       const string& substr);\n  ~SingleFailureChecker();\n private:\n  const TestPartResultArray* const results_;\n  const TestPartResult::Type type_;\n  const string substr_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker);\n};\n\n}  // namespace internal\n\n}  // namespace testing\n\n// A set of macros for testing Google Test assertions or code that's expected\n// to generate Google Test fatal failures.  It verifies that the given\n// statement will cause exactly one fatal Google Test failure with 'substr'\n// being part of the failure message.\n//\n// There are two different versions of this macro. EXPECT_FATAL_FAILURE only\n// affects and considers failures generated in the current thread and\n// EXPECT_FATAL_FAILURE_ON_ALL_THREADS does the same but for all threads.\n//\n// The verification of the assertion is done correctly even when the statement\n// throws an exception or aborts the current function.\n//\n// Known restrictions:\n//   - 'statement' cannot reference local non-static variables or\n//     non-static members of the current object.\n//   - 'statement' cannot return a value.\n//   - You cannot stream a failure message to this macro.\n//\n// Note that even though the implementations of the following two\n// macros are much alike, we cannot refactor them to use a common\n// helper macro, due to some peculiarity in how the preprocessor\n// works.  The AcceptsMacroThatExpandsToUnprotectedComma test in\n// gtest_unittest.cc will fail to compile if we do that.\n#define EXPECT_FATAL_FAILURE(statement, substr) \\\n  do { \\\n    class GTestExpectFatalFailureHelper {\\\n     public:\\\n      static void Execute() { statement; }\\\n    };\\\n    ::testing::TestPartResultArray gtest_failures;\\\n    ::testing::internal::SingleFailureChecker gtest_checker(\\\n        &gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr));\\\n    {\\\n      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\\\n          ::testing::ScopedFakeTestPartResultReporter:: \\\n          INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\\\n      GTestExpectFatalFailureHelper::Execute();\\\n    }\\\n  } while (::testing::internal::AlwaysFalse())\n\n#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \\\n  do { \\\n    class GTestExpectFatalFailureHelper {\\\n     public:\\\n      static void Execute() { statement; }\\\n    };\\\n    ::testing::TestPartResultArray gtest_failures;\\\n    ::testing::internal::SingleFailureChecker gtest_checker(\\\n        &gtest_failures, ::testing::TestPartResult::kFatalFailure, (substr));\\\n    {\\\n      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\\\n          ::testing::ScopedFakeTestPartResultReporter:: \\\n          INTERCEPT_ALL_THREADS, &gtest_failures);\\\n      GTestExpectFatalFailureHelper::Execute();\\\n    }\\\n  } while (::testing::internal::AlwaysFalse())\n\n// A macro for testing Google Test assertions or code that's expected to\n// generate Google Test non-fatal failures.  It asserts that the given\n// statement will cause exactly one non-fatal Google Test failure with 'substr'\n// being part of the failure message.\n//\n// There are two different versions of this macro. EXPECT_NONFATAL_FAILURE only\n// affects and considers failures generated in the current thread and\n// EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS does the same but for all threads.\n//\n// 'statement' is allowed to reference local variables and members of\n// the current object.\n//\n// The verification of the assertion is done correctly even when the statement\n// throws an exception or aborts the current function.\n//\n// Known restrictions:\n//   - You cannot stream a failure message to this macro.\n//\n// Note that even though the implementations of the following two\n// macros are much alike, we cannot refactor them to use a common\n// helper macro, due to some peculiarity in how the preprocessor\n// works.  If we do that, the code won't compile when the user gives\n// EXPECT_NONFATAL_FAILURE() a statement that contains a macro that\n// expands to code containing an unprotected comma.  The\n// AcceptsMacroThatExpandsToUnprotectedComma test in gtest_unittest.cc\n// catches that.\n//\n// For the same reason, we have to write\n//   if (::testing::internal::AlwaysTrue()) { statement; }\n// instead of\n//   GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)\n// to avoid an MSVC warning on unreachable code.\n#define EXPECT_NONFATAL_FAILURE(statement, substr) \\\n  do {\\\n    ::testing::TestPartResultArray gtest_failures;\\\n    ::testing::internal::SingleFailureChecker gtest_checker(\\\n        &gtest_failures, ::testing::TestPartResult::kNonFatalFailure, \\\n        (substr));\\\n    {\\\n      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\\\n          ::testing::ScopedFakeTestPartResultReporter:: \\\n          INTERCEPT_ONLY_CURRENT_THREAD, &gtest_failures);\\\n      if (::testing::internal::AlwaysTrue()) { statement; }\\\n    }\\\n  } while (::testing::internal::AlwaysFalse())\n\n#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \\\n  do {\\\n    ::testing::TestPartResultArray gtest_failures;\\\n    ::testing::internal::SingleFailureChecker gtest_checker(\\\n        &gtest_failures, ::testing::TestPartResult::kNonFatalFailure, \\\n        (substr));\\\n    {\\\n      ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\\\n          ::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS, \\\n          &gtest_failures);\\\n      if (::testing::internal::AlwaysTrue()) { statement; }\\\n    }\\\n  } while (::testing::internal::AlwaysFalse())\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_SPI_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/gtest-test-part.h",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: mheule@google.com (Markus Heule)\n//\n\n#ifndef GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_\n#define GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_\n\n#include <iosfwd>\n#include <vector>\n#include \"gtest/internal/gtest-internal.h\"\n#include \"gtest/internal/gtest-string.h\"\n\nnamespace testing {\n\n// A copyable object representing the result of a test part (i.e. an\n// assertion or an explicit FAIL(), ADD_FAILURE(), or SUCCESS()).\n//\n// Don't inherit from TestPartResult as its destructor is not virtual.\nclass GTEST_API_ TestPartResult {\n public:\n  // The possible outcomes of a test part (i.e. an assertion or an\n  // explicit SUCCEED(), FAIL(), or ADD_FAILURE()).\n  enum Type {\n    kSuccess,          // Succeeded.\n    kNonFatalFailure,  // Failed but the test can continue.\n    kFatalFailure      // Failed and the test should be terminated.\n  };\n\n  // C'tor.  TestPartResult does NOT have a default constructor.\n  // Always use this constructor (with parameters) to create a\n  // TestPartResult object.\n  TestPartResult(Type a_type,\n                 const char* a_file_name,\n                 int a_line_number,\n                 const char* a_message)\n      : type_(a_type),\n        file_name_(a_file_name == NULL ? \"\" : a_file_name),\n        line_number_(a_line_number),\n        summary_(ExtractSummary(a_message)),\n        message_(a_message) {\n  }\n\n  // Gets the outcome of the test part.\n  Type type() const { return type_; }\n\n  // Gets the name of the source file where the test part took place, or\n  // NULL if it's unknown.\n  const char* file_name() const {\n    return file_name_.empty() ? NULL : file_name_.c_str();\n  }\n\n  // Gets the line in the source file where the test part took place,\n  // or -1 if it's unknown.\n  int line_number() const { return line_number_; }\n\n  // Gets the summary of the failure message.\n  const char* summary() const { return summary_.c_str(); }\n\n  // Gets the message associated with the test part.\n  const char* message() const { return message_.c_str(); }\n\n  // Returns true iff the test part passed.\n  bool passed() const { return type_ == kSuccess; }\n\n  // Returns true iff the test part failed.\n  bool failed() const { return type_ != kSuccess; }\n\n  // Returns true iff the test part non-fatally failed.\n  bool nonfatally_failed() const { return type_ == kNonFatalFailure; }\n\n  // Returns true iff the test part fatally failed.\n  bool fatally_failed() const { return type_ == kFatalFailure; }\n\n private:\n  Type type_;\n\n  // Gets the summary of the failure message by omitting the stack\n  // trace in it.\n  static std::string ExtractSummary(const char* message);\n\n  // The name of the source file where the test part took place, or\n  // \"\" if the source file is unknown.\n  std::string file_name_;\n  // The line in the source file where the test part took place, or -1\n  // if the line number is unknown.\n  int line_number_;\n  std::string summary_;  // The test failure summary.\n  std::string message_;  // The test failure message.\n};\n\n// Prints a TestPartResult object.\nstd::ostream& operator<<(std::ostream& os, const TestPartResult& result);\n\n// An array of TestPartResult objects.\n//\n// Don't inherit from TestPartResultArray as its destructor is not\n// virtual.\nclass GTEST_API_ TestPartResultArray {\n public:\n  TestPartResultArray() {}\n\n  // Appends the given TestPartResult to the array.\n  void Append(const TestPartResult& result);\n\n  // Returns the TestPartResult at the given index (0-based).\n  const TestPartResult& GetTestPartResult(int index) const;\n\n  // Returns the number of TestPartResult objects in the array.\n  int size() const;\n\n private:\n  std::vector<TestPartResult> array_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestPartResultArray);\n};\n\n// This interface knows how to report a test part result.\nclass TestPartResultReporterInterface {\n public:\n  virtual ~TestPartResultReporterInterface() {}\n\n  virtual void ReportTestPartResult(const TestPartResult& result) = 0;\n};\n\nnamespace internal {\n\n// This helper class is used by {ASSERT|EXPECT}_NO_FATAL_FAILURE to check if a\n// statement generates new fatal failures. To do so it registers itself as the\n// current test part result reporter. Besides checking if fatal failures were\n// reported, it only delegates the reporting to the former result reporter.\n// The original result reporter is restored in the destructor.\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nclass GTEST_API_ HasNewFatalFailureHelper\n    : public TestPartResultReporterInterface {\n public:\n  HasNewFatalFailureHelper();\n  virtual ~HasNewFatalFailureHelper();\n  virtual void ReportTestPartResult(const TestPartResult& result);\n  bool has_new_fatal_failure() const { return has_new_fatal_failure_; }\n private:\n  bool has_new_fatal_failure_;\n  TestPartResultReporterInterface* original_reporter_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(HasNewFatalFailureHelper);\n};\n\n}  // namespace internal\n\n}  // namespace testing\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/gtest-typed-test.h",
    "content": "// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#ifndef GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_\n#define GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_\n\n// This header implements typed tests and type-parameterized tests.\n\n// Typed (aka type-driven) tests repeat the same test for types in a\n// list.  You must know which types you want to test with when writing\n// typed tests. Here's how you do it:\n\n#if 0\n\n// First, define a fixture class template.  It should be parameterized\n// by a type.  Remember to derive it from testing::Test.\ntemplate <typename T>\nclass FooTest : public testing::Test {\n public:\n  ...\n  typedef std::list<T> List;\n  static T shared_;\n  T value_;\n};\n\n// Next, associate a list of types with the test case, which will be\n// repeated for each type in the list.  The typedef is necessary for\n// the macro to parse correctly.\ntypedef testing::Types<char, int, unsigned int> MyTypes;\nTYPED_TEST_CASE(FooTest, MyTypes);\n\n// If the type list contains only one type, you can write that type\n// directly without Types<...>:\n//   TYPED_TEST_CASE(FooTest, int);\n\n// Then, use TYPED_TEST() instead of TEST_F() to define as many typed\n// tests for this test case as you want.\nTYPED_TEST(FooTest, DoesBlah) {\n  // Inside a test, refer to TypeParam to get the type parameter.\n  // Since we are inside a derived class template, C++ requires use to\n  // visit the members of FooTest via 'this'.\n  TypeParam n = this->value_;\n\n  // To visit static members of the fixture, add the TestFixture::\n  // prefix.\n  n += TestFixture::shared_;\n\n  // To refer to typedefs in the fixture, add the \"typename\n  // TestFixture::\" prefix.\n  typename TestFixture::List values;\n  values.push_back(n);\n  ...\n}\n\nTYPED_TEST(FooTest, HasPropertyA) { ... }\n\n#endif  // 0\n\n// Type-parameterized tests are abstract test patterns parameterized\n// by a type.  Compared with typed tests, type-parameterized tests\n// allow you to define the test pattern without knowing what the type\n// parameters are.  The defined pattern can be instantiated with\n// different types any number of times, in any number of translation\n// units.\n//\n// If you are designing an interface or concept, you can define a\n// suite of type-parameterized tests to verify properties that any\n// valid implementation of the interface/concept should have.  Then,\n// each implementation can easily instantiate the test suite to verify\n// that it conforms to the requirements, without having to write\n// similar tests repeatedly.  Here's an example:\n\n#if 0\n\n// First, define a fixture class template.  It should be parameterized\n// by a type.  Remember to derive it from testing::Test.\ntemplate <typename T>\nclass FooTest : public testing::Test {\n  ...\n};\n\n// Next, declare that you will define a type-parameterized test case\n// (the _P suffix is for \"parameterized\" or \"pattern\", whichever you\n// prefer):\nTYPED_TEST_CASE_P(FooTest);\n\n// Then, use TYPED_TEST_P() to define as many type-parameterized tests\n// for this type-parameterized test case as you want.\nTYPED_TEST_P(FooTest, DoesBlah) {\n  // Inside a test, refer to TypeParam to get the type parameter.\n  TypeParam n = 0;\n  ...\n}\n\nTYPED_TEST_P(FooTest, HasPropertyA) { ... }\n\n// Now the tricky part: you need to register all test patterns before\n// you can instantiate them.  The first argument of the macro is the\n// test case name; the rest are the names of the tests in this test\n// case.\nREGISTER_TYPED_TEST_CASE_P(FooTest,\n                           DoesBlah, HasPropertyA);\n\n// Finally, you are free to instantiate the pattern with the types you\n// want.  If you put the above code in a header file, you can #include\n// it in multiple C++ source files and instantiate it multiple times.\n//\n// To distinguish different instances of the pattern, the first\n// argument to the INSTANTIATE_* macro is a prefix that will be added\n// to the actual test case name.  Remember to pick unique prefixes for\n// different instances.\ntypedef testing::Types<char, int, unsigned int> MyTypes;\nINSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes);\n\n// If the type list contains only one type, you can write that type\n// directly without Types<...>:\n//   INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, int);\n\n#endif  // 0\n\n#include \"gtest/internal/gtest-port.h\"\n#include \"gtest/internal/gtest-type-util.h\"\n\n// Implements typed tests.\n\n#if GTEST_HAS_TYPED_TEST\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Expands to the name of the typedef for the type parameters of the\n// given test case.\n# define GTEST_TYPE_PARAMS_(TestCaseName) gtest_type_params_##TestCaseName##_\n\n// The 'Types' template argument below must have spaces around it\n// since some compilers may choke on '>>' when passing a template\n// instance (e.g. Types<int>)\n# define TYPED_TEST_CASE(CaseName, Types) \\\n  typedef ::testing::internal::TypeList< Types >::type \\\n      GTEST_TYPE_PARAMS_(CaseName)\n\n# define TYPED_TEST(CaseName, TestName) \\\n  template <typename gtest_TypeParam_> \\\n  class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \\\n      : public CaseName<gtest_TypeParam_> { \\\n   private: \\\n    typedef CaseName<gtest_TypeParam_> TestFixture; \\\n    typedef gtest_TypeParam_ TypeParam; \\\n    virtual void TestBody(); \\\n  }; \\\n  bool gtest_##CaseName##_##TestName##_registered_ GTEST_ATTRIBUTE_UNUSED_ = \\\n      ::testing::internal::TypeParameterizedTest< \\\n          CaseName, \\\n          ::testing::internal::TemplateSel< \\\n              GTEST_TEST_CLASS_NAME_(CaseName, TestName)>, \\\n          GTEST_TYPE_PARAMS_(CaseName)>::Register(\\\n              \"\", #CaseName, #TestName, 0); \\\n  template <typename gtest_TypeParam_> \\\n  void GTEST_TEST_CLASS_NAME_(CaseName, TestName)<gtest_TypeParam_>::TestBody()\n\n#endif  // GTEST_HAS_TYPED_TEST\n\n// Implements type-parameterized tests.\n\n#if GTEST_HAS_TYPED_TEST_P\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Expands to the namespace name that the type-parameterized tests for\n// the given type-parameterized test case are defined in.  The exact\n// name of the namespace is subject to change without notice.\n# define GTEST_CASE_NAMESPACE_(TestCaseName) \\\n  gtest_case_##TestCaseName##_\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Expands to the name of the variable used to remember the names of\n// the defined tests in the given test case.\n# define GTEST_TYPED_TEST_CASE_P_STATE_(TestCaseName) \\\n  gtest_typed_test_case_p_state_##TestCaseName##_\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE DIRECTLY.\n//\n// Expands to the name of the variable used to remember the names of\n// the registered tests in the given test case.\n# define GTEST_REGISTERED_TEST_NAMES_(TestCaseName) \\\n  gtest_registered_test_names_##TestCaseName##_\n\n// The variables defined in the type-parameterized test macros are\n// static as typically these macros are used in a .h file that can be\n// #included in multiple translation units linked together.\n# define TYPED_TEST_CASE_P(CaseName) \\\n  static ::testing::internal::TypedTestCasePState \\\n      GTEST_TYPED_TEST_CASE_P_STATE_(CaseName)\n\n# define TYPED_TEST_P(CaseName, TestName) \\\n  namespace GTEST_CASE_NAMESPACE_(CaseName) { \\\n  template <typename gtest_TypeParam_> \\\n  class TestName : public CaseName<gtest_TypeParam_> { \\\n   private: \\\n    typedef CaseName<gtest_TypeParam_> TestFixture; \\\n    typedef gtest_TypeParam_ TypeParam; \\\n    virtual void TestBody(); \\\n  }; \\\n  static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \\\n      GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).AddTestName(\\\n          __FILE__, __LINE__, #CaseName, #TestName); \\\n  } \\\n  template <typename gtest_TypeParam_> \\\n  void GTEST_CASE_NAMESPACE_(CaseName)::TestName<gtest_TypeParam_>::TestBody()\n\n# define REGISTER_TYPED_TEST_CASE_P(CaseName, ...) \\\n  namespace GTEST_CASE_NAMESPACE_(CaseName) { \\\n  typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \\\n  } \\\n  static const char* const GTEST_REGISTERED_TEST_NAMES_(CaseName) = \\\n      GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).VerifyRegisteredTestNames(\\\n          __FILE__, __LINE__, #__VA_ARGS__)\n\n// The 'Types' template argument below must have spaces around it\n// since some compilers may choke on '>>' when passing a template\n// instance (e.g. Types<int>)\n# define INSTANTIATE_TYPED_TEST_CASE_P(Prefix, CaseName, Types) \\\n  bool gtest_##Prefix##_##CaseName GTEST_ATTRIBUTE_UNUSED_ = \\\n      ::testing::internal::TypeParameterizedTestCase<CaseName, \\\n          GTEST_CASE_NAMESPACE_(CaseName)::gtest_AllTests_, \\\n          ::testing::internal::TypeList< Types >::type>::Register(\\\n              #Prefix, #CaseName, GTEST_REGISTERED_TEST_NAMES_(CaseName))\n\n#endif  // GTEST_HAS_TYPED_TEST_P\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/gtest.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// The Google C++ Testing Framework (Google Test)\n//\n// This header file defines the public API for Google Test.  It should be\n// included by any test program that uses Google Test.\n//\n// IMPORTANT NOTE: Due to limitation of the C++ language, we have to\n// leave some internal implementation details in this header file.\n// They are clearly marked by comments like this:\n//\n//   // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n//\n// Such code is NOT meant to be used by a user directly, and is subject\n// to CHANGE WITHOUT NOTICE.  Therefore DO NOT DEPEND ON IT in a user\n// program!\n//\n// Acknowledgment: Google Test borrowed the idea of automatic test\n// registration from Barthelemy Dagenais' (barthelemy@prologique.com)\n// easyUnit framework.\n\n#ifndef GTEST_INCLUDE_GTEST_GTEST_H_\n#define GTEST_INCLUDE_GTEST_GTEST_H_\n\n#include <limits>\n#include <ostream>\n#include <vector>\n\n#include \"gtest/internal/gtest-internal.h\"\n#include \"gtest/internal/gtest-string.h\"\n#include \"gtest/gtest-death-test.h\"\n#include \"gtest/gtest-message.h\"\n#include \"gtest/gtest-param-test.h\"\n#include \"gtest/gtest-printers.h\"\n#include \"gtest/gtest_prod.h\"\n#include \"gtest/gtest-test-part.h\"\n#include \"gtest/gtest-typed-test.h\"\n\n// Depending on the platform, different string classes are available.\n// On Linux, in addition to ::std::string, Google also makes use of\n// class ::string, which has the same interface as ::std::string, but\n// has a different implementation.\n//\n// The user can define GTEST_HAS_GLOBAL_STRING to 1 to indicate that\n// ::string is available AND is a distinct type to ::std::string, or\n// define it to 0 to indicate otherwise.\n//\n// If the user's ::std::string and ::string are the same class due to\n// aliasing, he should define GTEST_HAS_GLOBAL_STRING to 0.\n//\n// If the user doesn't define GTEST_HAS_GLOBAL_STRING, it is defined\n// heuristically.\n\nnamespace testing {\n\n// Declares the flags.\n\n// This flag temporary enables the disabled tests.\nGTEST_DECLARE_bool_(also_run_disabled_tests);\n\n// This flag brings the debugger on an assertion failure.\nGTEST_DECLARE_bool_(break_on_failure);\n\n// This flag controls whether Google Test catches all test-thrown exceptions\n// and logs them as failures.\nGTEST_DECLARE_bool_(catch_exceptions);\n\n// This flag enables using colors in terminal output. Available values are\n// \"yes\" to enable colors, \"no\" (disable colors), or \"auto\" (the default)\n// to let Google Test decide.\nGTEST_DECLARE_string_(color);\n\n// This flag sets up the filter to select by name using a glob pattern\n// the tests to run. If the filter is not given all tests are executed.\nGTEST_DECLARE_string_(filter);\n\n// This flag causes the Google Test to list tests. None of the tests listed\n// are actually run if the flag is provided.\nGTEST_DECLARE_bool_(list_tests);\n\n// This flag controls whether Google Test emits a detailed XML report to a file\n// in addition to its normal textual output.\nGTEST_DECLARE_string_(output);\n\n// This flags control whether Google Test prints the elapsed time for each\n// test.\nGTEST_DECLARE_bool_(print_time);\n\n// This flag specifies the random number seed.\nGTEST_DECLARE_int32_(random_seed);\n\n// This flag sets how many times the tests are repeated. The default value\n// is 1. If the value is -1 the tests are repeating forever.\nGTEST_DECLARE_int32_(repeat);\n\n// This flag controls whether Google Test includes Google Test internal\n// stack frames in failure stack traces.\nGTEST_DECLARE_bool_(show_internal_stack_frames);\n\n// When this flag is specified, tests' order is randomized on every iteration.\nGTEST_DECLARE_bool_(shuffle);\n\n// This flag specifies the maximum number of stack frames to be\n// printed in a failure message.\nGTEST_DECLARE_int32_(stack_trace_depth);\n\n// When this flag is specified, a failed assertion will throw an\n// exception if exceptions are enabled, or exit the program with a\n// non-zero code otherwise.\nGTEST_DECLARE_bool_(throw_on_failure);\n\n// When this flag is set with a \"host:port\" string, on supported\n// platforms test results are streamed to the specified port on\n// the specified host machine.\nGTEST_DECLARE_string_(stream_result_to);\n\n// The upper limit for valid stack trace depths.\nconst int kMaxStackTraceDepth = 100;\n\nnamespace internal {\n\nclass AssertHelper;\nclass DefaultGlobalTestPartResultReporter;\nclass ExecDeathTest;\nclass NoExecDeathTest;\nclass FinalSuccessChecker;\nclass GTestFlagSaver;\nclass StreamingListenerTest;\nclass TestResultAccessor;\nclass TestEventListenersAccessor;\nclass TestEventRepeater;\nclass UnitTestRecordPropertyTestHelper;\nclass WindowsDeathTest;\nclass UnitTestImpl* GetUnitTestImpl();\nvoid ReportFailureInUnknownLocation(TestPartResult::Type result_type,\n                                    const std::string& message);\n\n}  // namespace internal\n\n// The friend relationship of some of these classes is cyclic.\n// If we don't forward declare them the compiler might confuse the classes\n// in friendship clauses with same named classes on the scope.\nclass Test;\nclass TestCase;\nclass TestInfo;\nclass UnitTest;\n\n// A class for indicating whether an assertion was successful.  When\n// the assertion wasn't successful, the AssertionResult object\n// remembers a non-empty message that describes how it failed.\n//\n// To create an instance of this class, use one of the factory functions\n// (AssertionSuccess() and AssertionFailure()).\n//\n// This class is useful for two purposes:\n//   1. Defining predicate functions to be used with Boolean test assertions\n//      EXPECT_TRUE/EXPECT_FALSE and their ASSERT_ counterparts\n//   2. Defining predicate-format functions to be\n//      used with predicate assertions (ASSERT_PRED_FORMAT*, etc).\n//\n// For example, if you define IsEven predicate:\n//\n//   testing::AssertionResult IsEven(int n) {\n//     if ((n % 2) == 0)\n//       return testing::AssertionSuccess();\n//     else\n//       return testing::AssertionFailure() << n << \" is odd\";\n//   }\n//\n// Then the failed expectation EXPECT_TRUE(IsEven(Fib(5)))\n// will print the message\n//\n//   Value of: IsEven(Fib(5))\n//     Actual: false (5 is odd)\n//   Expected: true\n//\n// instead of a more opaque\n//\n//   Value of: IsEven(Fib(5))\n//     Actual: false\n//   Expected: true\n//\n// in case IsEven is a simple Boolean predicate.\n//\n// If you expect your predicate to be reused and want to support informative\n// messages in EXPECT_FALSE and ASSERT_FALSE (negative assertions show up\n// about half as often as positive ones in our tests), supply messages for\n// both success and failure cases:\n//\n//   testing::AssertionResult IsEven(int n) {\n//     if ((n % 2) == 0)\n//       return testing::AssertionSuccess() << n << \" is even\";\n//     else\n//       return testing::AssertionFailure() << n << \" is odd\";\n//   }\n//\n// Then a statement EXPECT_FALSE(IsEven(Fib(6))) will print\n//\n//   Value of: IsEven(Fib(6))\n//     Actual: true (8 is even)\n//   Expected: false\n//\n// NB: Predicates that support negative Boolean assertions have reduced\n// performance in positive ones so be careful not to use them in tests\n// that have lots (tens of thousands) of positive Boolean assertions.\n//\n// To use this class with EXPECT_PRED_FORMAT assertions such as:\n//\n//   // Verifies that Foo() returns an even number.\n//   EXPECT_PRED_FORMAT1(IsEven, Foo());\n//\n// you need to define:\n//\n//   testing::AssertionResult IsEven(const char* expr, int n) {\n//     if ((n % 2) == 0)\n//       return testing::AssertionSuccess();\n//     else\n//       return testing::AssertionFailure()\n//         << \"Expected: \" << expr << \" is even\\n  Actual: it's \" << n;\n//   }\n//\n// If Foo() returns 5, you will see the following message:\n//\n//   Expected: Foo() is even\n//     Actual: it's 5\n//\nclass GTEST_API_ AssertionResult {\n public:\n  // Copy constructor.\n  // Used in EXPECT_TRUE/FALSE(assertion_result).\n  AssertionResult(const AssertionResult& other);\n  // Used in the EXPECT_TRUE/FALSE(bool_expression).\n  explicit AssertionResult(bool success) : success_(success) {}\n\n  // Returns true iff the assertion succeeded.\n  operator bool() const { return success_; }  // NOLINT\n\n  // Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.\n  AssertionResult operator!() const;\n\n  // Returns the text streamed into this AssertionResult. Test assertions\n  // use it when they fail (i.e., the predicate's outcome doesn't match the\n  // assertion's expectation). When nothing has been streamed into the\n  // object, returns an empty string.\n  const char* message() const {\n    return message_.get() != NULL ?  message_->c_str() : \"\";\n  }\n  // TODO(vladl@google.com): Remove this after making sure no clients use it.\n  // Deprecated; please use message() instead.\n  const char* failure_message() const { return message(); }\n\n  // Streams a custom failure message into this object.\n  template <typename T> AssertionResult& operator<<(const T& value) {\n    AppendMessage(Message() << value);\n    return *this;\n  }\n\n  // Allows streaming basic output manipulators such as endl or flush into\n  // this object.\n  AssertionResult& operator<<(\n      ::std::ostream& (*basic_manipulator)(::std::ostream& stream)) {\n    AppendMessage(Message() << basic_manipulator);\n    return *this;\n  }\n\n private:\n  // Appends the contents of message to message_.\n  void AppendMessage(const Message& a_message) {\n    if (message_.get() == NULL)\n      message_.reset(new ::std::string);\n    message_->append(a_message.GetString().c_str());\n  }\n\n  // Stores result of the assertion predicate.\n  bool success_;\n  // Stores the message describing the condition in case the expectation\n  // construct is not satisfied with the predicate's outcome.\n  // Referenced via a pointer to avoid taking too much stack frame space\n  // with test assertions.\n  internal::scoped_ptr< ::std::string> message_;\n\n  GTEST_DISALLOW_ASSIGN_(AssertionResult);\n};\n\n// Makes a successful assertion result.\nGTEST_API_ AssertionResult AssertionSuccess();\n\n// Makes a failed assertion result.\nGTEST_API_ AssertionResult AssertionFailure();\n\n// Makes a failed assertion result with the given failure message.\n// Deprecated; use AssertionFailure() << msg.\nGTEST_API_ AssertionResult AssertionFailure(const Message& msg);\n\n// The abstract class that all tests inherit from.\n//\n// In Google Test, a unit test program contains one or many TestCases, and\n// each TestCase contains one or many Tests.\n//\n// When you define a test using the TEST macro, you don't need to\n// explicitly derive from Test - the TEST macro automatically does\n// this for you.\n//\n// The only time you derive from Test is when defining a test fixture\n// to be used a TEST_F.  For example:\n//\n//   class FooTest : public testing::Test {\n//    protected:\n//     virtual void SetUp() { ... }\n//     virtual void TearDown() { ... }\n//     ...\n//   };\n//\n//   TEST_F(FooTest, Bar) { ... }\n//   TEST_F(FooTest, Baz) { ... }\n//\n// Test is not copyable.\nclass GTEST_API_ Test {\n public:\n  friend class TestInfo;\n\n  // Defines types for pointers to functions that set up and tear down\n  // a test case.\n  typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc;\n  typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc;\n\n  // The d'tor is virtual as we intend to inherit from Test.\n  virtual ~Test();\n\n  // Sets up the stuff shared by all tests in this test case.\n  //\n  // Google Test will call Foo::SetUpTestCase() before running the first\n  // test in test case Foo.  Hence a sub-class can define its own\n  // SetUpTestCase() method to shadow the one defined in the super\n  // class.\n  static void SetUpTestCase() {}\n\n  // Tears down the stuff shared by all tests in this test case.\n  //\n  // Google Test will call Foo::TearDownTestCase() after running the last\n  // test in test case Foo.  Hence a sub-class can define its own\n  // TearDownTestCase() method to shadow the one defined in the super\n  // class.\n  static void TearDownTestCase() {}\n\n  // Returns true iff the current test has a fatal failure.\n  static bool HasFatalFailure();\n\n  // Returns true iff the current test has a non-fatal failure.\n  static bool HasNonfatalFailure();\n\n  // Returns true iff the current test has a (either fatal or\n  // non-fatal) failure.\n  static bool HasFailure() { return HasFatalFailure() || HasNonfatalFailure(); }\n\n  // Logs a property for the current test, test case, or for the entire\n  // invocation of the test program when used outside of the context of a\n  // test case.  Only the last value for a given key is remembered.  These\n  // are public static so they can be called from utility functions that are\n  // not members of the test fixture.  Calls to RecordProperty made during\n  // lifespan of the test (from the moment its constructor starts to the\n  // moment its destructor finishes) will be output in XML as attributes of\n  // the <testcase> element.  Properties recorded from fixture's\n  // SetUpTestCase or TearDownTestCase are logged as attributes of the\n  // corresponding <testsuite> element.  Calls to RecordProperty made in the\n  // global context (before or after invocation of RUN_ALL_TESTS and from\n  // SetUp/TearDown method of Environment objects registered with Google\n  // Test) will be output as attributes of the <testsuites> element.\n  static void RecordProperty(const std::string& key, const std::string& value);\n  static void RecordProperty(const std::string& key, int value);\n\n protected:\n  // Creates a Test object.\n  Test();\n\n  // Sets up the test fixture.\n  virtual void SetUp();\n\n  // Tears down the test fixture.\n  virtual void TearDown();\n\n private:\n  // Returns true iff the current test has the same fixture class as\n  // the first test in the current test case.\n  static bool HasSameFixtureClass();\n\n  // Runs the test after the test fixture has been set up.\n  //\n  // A sub-class must implement this to define the test logic.\n  //\n  // DO NOT OVERRIDE THIS FUNCTION DIRECTLY IN A USER PROGRAM.\n  // Instead, use the TEST or TEST_F macro.\n  virtual void TestBody() = 0;\n\n  // Sets up, executes, and tears down the test.\n  void Run();\n\n  // Deletes self.  We deliberately pick an unusual name for this\n  // internal method to avoid clashing with names used in user TESTs.\n  void DeleteSelf_() { delete this; }\n\n  // Uses a GTestFlagSaver to save and restore all Google Test flags.\n  const internal::GTestFlagSaver* const gtest_flag_saver_;\n\n  // Often a user mis-spells SetUp() as Setup() and spends a long time\n  // wondering why it is never called by Google Test.  The declaration of\n  // the following method is solely for catching such an error at\n  // compile time:\n  //\n  //   - The return type is deliberately chosen to be not void, so it\n  //   will be a conflict if a user declares void Setup() in his test\n  //   fixture.\n  //\n  //   - This method is private, so it will be another compiler error\n  //   if a user calls it from his test fixture.\n  //\n  // DO NOT OVERRIDE THIS FUNCTION.\n  //\n  // If you see an error about overriding the following function or\n  // about it being private, you have mis-spelled SetUp() as Setup().\n  struct Setup_should_be_spelled_SetUp {};\n  virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; }\n\n  // We disallow copying Tests.\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(Test);\n};\n\ntypedef internal::TimeInMillis TimeInMillis;\n\n// A copyable object representing a user specified test property which can be\n// output as a key/value string pair.\n//\n// Don't inherit from TestProperty as its destructor is not virtual.\nclass TestProperty {\n public:\n  // C'tor.  TestProperty does NOT have a default constructor.\n  // Always use this constructor (with parameters) to create a\n  // TestProperty object.\n  TestProperty(const std::string& a_key, const std::string& a_value) :\n    key_(a_key), value_(a_value) {\n  }\n\n  // Gets the user supplied key.\n  const char* key() const {\n    return key_.c_str();\n  }\n\n  // Gets the user supplied value.\n  const char* value() const {\n    return value_.c_str();\n  }\n\n  // Sets a new value, overriding the one supplied in the constructor.\n  void SetValue(const std::string& new_value) {\n    value_ = new_value;\n  }\n\n private:\n  // The key supplied by the user.\n  std::string key_;\n  // The value supplied by the user.\n  std::string value_;\n};\n\n// The result of a single Test.  This includes a list of\n// TestPartResults, a list of TestProperties, a count of how many\n// death tests there are in the Test, and how much time it took to run\n// the Test.\n//\n// TestResult is not copyable.\nclass GTEST_API_ TestResult {\n public:\n  // Creates an empty TestResult.\n  TestResult();\n\n  // D'tor.  Do not inherit from TestResult.\n  ~TestResult();\n\n  // Gets the number of all test parts.  This is the sum of the number\n  // of successful test parts and the number of failed test parts.\n  int total_part_count() const;\n\n  // Returns the number of the test properties.\n  int test_property_count() const;\n\n  // Returns true iff the test passed (i.e. no test part failed).\n  bool Passed() const { return !Failed(); }\n\n  // Returns true iff the test failed.\n  bool Failed() const;\n\n  // Returns true iff the test fatally failed.\n  bool HasFatalFailure() const;\n\n  // Returns true iff the test has a non-fatal failure.\n  bool HasNonfatalFailure() const;\n\n  // Returns the elapsed time, in milliseconds.\n  TimeInMillis elapsed_time() const { return elapsed_time_; }\n\n  // Returns the i-th test part result among all the results. i can range\n  // from 0 to test_property_count() - 1. If i is not in that range, aborts\n  // the program.\n  const TestPartResult& GetTestPartResult(int i) const;\n\n  // Returns the i-th test property. i can range from 0 to\n  // test_property_count() - 1. If i is not in that range, aborts the\n  // program.\n  const TestProperty& GetTestProperty(int i) const;\n\n private:\n  friend class TestInfo;\n  friend class TestCase;\n  friend class UnitTest;\n  friend class internal::DefaultGlobalTestPartResultReporter;\n  friend class internal::ExecDeathTest;\n  friend class internal::TestResultAccessor;\n  friend class internal::UnitTestImpl;\n  friend class internal::WindowsDeathTest;\n\n  // Gets the vector of TestPartResults.\n  const std::vector<TestPartResult>& test_part_results() const {\n    return test_part_results_;\n  }\n\n  // Gets the vector of TestProperties.\n  const std::vector<TestProperty>& test_properties() const {\n    return test_properties_;\n  }\n\n  // Sets the elapsed time.\n  void set_elapsed_time(TimeInMillis elapsed) { elapsed_time_ = elapsed; }\n\n  // Adds a test property to the list. The property is validated and may add\n  // a non-fatal failure if invalid (e.g., if it conflicts with reserved\n  // key names). If a property is already recorded for the same key, the\n  // value will be updated, rather than storing multiple values for the same\n  // key.  xml_element specifies the element for which the property is being\n  // recorded and is used for validation.\n  void RecordProperty(const std::string& xml_element,\n                      const TestProperty& test_property);\n\n  // Adds a failure if the key is a reserved attribute of Google Test\n  // testcase tags.  Returns true if the property is valid.\n  // TODO(russr): Validate attribute names are legal and human readable.\n  static bool ValidateTestProperty(const std::string& xml_element,\n                                   const TestProperty& test_property);\n\n  // Adds a test part result to the list.\n  void AddTestPartResult(const TestPartResult& test_part_result);\n\n  // Returns the death test count.\n  int death_test_count() const { return death_test_count_; }\n\n  // Increments the death test count, returning the new count.\n  int increment_death_test_count() { return ++death_test_count_; }\n\n  // Clears the test part results.\n  void ClearTestPartResults();\n\n  // Clears the object.\n  void Clear();\n\n  // Protects mutable state of the property vector and of owned\n  // properties, whose values may be updated.\n  internal::Mutex test_properites_mutex_;\n\n  // The vector of TestPartResults\n  std::vector<TestPartResult> test_part_results_;\n  // The vector of TestProperties\n  std::vector<TestProperty> test_properties_;\n  // Running count of death tests.\n  int death_test_count_;\n  // The elapsed time, in milliseconds.\n  TimeInMillis elapsed_time_;\n\n  // We disallow copying TestResult.\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestResult);\n};  // class TestResult\n\n// A TestInfo object stores the following information about a test:\n//\n//   Test case name\n//   Test name\n//   Whether the test should be run\n//   A function pointer that creates the test object when invoked\n//   Test result\n//\n// The constructor of TestInfo registers itself with the UnitTest\n// singleton such that the RUN_ALL_TESTS() macro knows which tests to\n// run.\nclass GTEST_API_ TestInfo {\n public:\n  // Destructs a TestInfo object.  This function is not virtual, so\n  // don't inherit from TestInfo.\n  ~TestInfo();\n\n  // Returns the test case name.\n  const char* test_case_name() const { return test_case_name_.c_str(); }\n\n  // Returns the test name.\n  const char* name() const { return name_.c_str(); }\n\n  // Returns the name of the parameter type, or NULL if this is not a typed\n  // or a type-parameterized test.\n  const char* type_param() const {\n    if (type_param_.get() != NULL)\n      return type_param_->c_str();\n    return NULL;\n  }\n\n  // Returns the text representation of the value parameter, or NULL if this\n  // is not a value-parameterized test.\n  const char* value_param() const {\n    if (value_param_.get() != NULL)\n      return value_param_->c_str();\n    return NULL;\n  }\n\n  // Returns true if this test should run, that is if the test is not\n  // disabled (or it is disabled but the also_run_disabled_tests flag has\n  // been specified) and its full name matches the user-specified filter.\n  //\n  // Google Test allows the user to filter the tests by their full names.\n  // The full name of a test Bar in test case Foo is defined as\n  // \"Foo.Bar\".  Only the tests that match the filter will run.\n  //\n  // A filter is a colon-separated list of glob (not regex) patterns,\n  // optionally followed by a '-' and a colon-separated list of\n  // negative patterns (tests to exclude).  A test is run if it\n  // matches one of the positive patterns and does not match any of\n  // the negative patterns.\n  //\n  // For example, *A*:Foo.* is a filter that matches any string that\n  // contains the character 'A' or starts with \"Foo.\".\n  bool should_run() const { return should_run_; }\n\n  // Returns true iff this test will appear in the XML report.\n  bool is_reportable() const {\n    // For now, the XML report includes all tests matching the filter.\n    // In the future, we may trim tests that are excluded because of\n    // sharding.\n    return matches_filter_;\n  }\n\n  // Returns the result of the test.\n  const TestResult* result() const { return &result_; }\n\n private:\n#if GTEST_HAS_DEATH_TEST\n  friend class internal::DefaultDeathTestFactory;\n#endif  // GTEST_HAS_DEATH_TEST\n  friend class Test;\n  friend class TestCase;\n  friend class internal::UnitTestImpl;\n  friend class internal::StreamingListenerTest;\n  friend TestInfo* internal::MakeAndRegisterTestInfo(\n      const char* test_case_name,\n      const char* name,\n      const char* type_param,\n      const char* value_param,\n      internal::TypeId fixture_class_id,\n      Test::SetUpTestCaseFunc set_up_tc,\n      Test::TearDownTestCaseFunc tear_down_tc,\n      internal::TestFactoryBase* factory);\n\n  // Constructs a TestInfo object. The newly constructed instance assumes\n  // ownership of the factory object.\n  TestInfo(const std::string& test_case_name,\n           const std::string& name,\n           const char* a_type_param,   // NULL if not a type-parameterized test\n           const char* a_value_param,  // NULL if not a value-parameterized test\n           internal::TypeId fixture_class_id,\n           internal::TestFactoryBase* factory);\n\n  // Increments the number of death tests encountered in this test so\n  // far.\n  int increment_death_test_count() {\n    return result_.increment_death_test_count();\n  }\n\n  // Creates the test object, runs it, records its result, and then\n  // deletes it.\n  void Run();\n\n  static void ClearTestResult(TestInfo* test_info) {\n    test_info->result_.Clear();\n  }\n\n  // These fields are immutable properties of the test.\n  const std::string test_case_name_;     // Test case name\n  const std::string name_;               // Test name\n  // Name of the parameter type, or NULL if this is not a typed or a\n  // type-parameterized test.\n  const internal::scoped_ptr<const ::std::string> type_param_;\n  // Text representation of the value parameter, or NULL if this is not a\n  // value-parameterized test.\n  const internal::scoped_ptr<const ::std::string> value_param_;\n  const internal::TypeId fixture_class_id_;   // ID of the test fixture class\n  bool should_run_;                 // True iff this test should run\n  bool is_disabled_;                // True iff this test is disabled\n  bool matches_filter_;             // True if this test matches the\n                                    // user-specified filter.\n  internal::TestFactoryBase* const factory_;  // The factory that creates\n                                              // the test object\n\n  // This field is mutable and needs to be reset before running the\n  // test for the second time.\n  TestResult result_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo);\n};\n\n// A test case, which consists of a vector of TestInfos.\n//\n// TestCase is not copyable.\nclass GTEST_API_ TestCase {\n public:\n  // Creates a TestCase with the given name.\n  //\n  // TestCase does NOT have a default constructor.  Always use this\n  // constructor to create a TestCase object.\n  //\n  // Arguments:\n  //\n  //   name:         name of the test case\n  //   a_type_param: the name of the test's type parameter, or NULL if\n  //                 this is not a type-parameterized test.\n  //   set_up_tc:    pointer to the function that sets up the test case\n  //   tear_down_tc: pointer to the function that tears down the test case\n  TestCase(const char* name, const char* a_type_param,\n           Test::SetUpTestCaseFunc set_up_tc,\n           Test::TearDownTestCaseFunc tear_down_tc);\n\n  // Destructor of TestCase.\n  virtual ~TestCase();\n\n  // Gets the name of the TestCase.\n  const char* name() const { return name_.c_str(); }\n\n  // Returns the name of the parameter type, or NULL if this is not a\n  // type-parameterized test case.\n  const char* type_param() const {\n    if (type_param_.get() != NULL)\n      return type_param_->c_str();\n    return NULL;\n  }\n\n  // Returns true if any test in this test case should run.\n  bool should_run() const { return should_run_; }\n\n  // Gets the number of successful tests in this test case.\n  int successful_test_count() const;\n\n  // Gets the number of failed tests in this test case.\n  int failed_test_count() const;\n\n  // Gets the number of disabled tests that will be reported in the XML report.\n  int reportable_disabled_test_count() const;\n\n  // Gets the number of disabled tests in this test case.\n  int disabled_test_count() const;\n\n  // Gets the number of tests to be printed in the XML report.\n  int reportable_test_count() const;\n\n  // Get the number of tests in this test case that should run.\n  int test_to_run_count() const;\n\n  // Gets the number of all tests in this test case.\n  int total_test_count() const;\n\n  // Returns true iff the test case passed.\n  bool Passed() const { return !Failed(); }\n\n  // Returns true iff the test case failed.\n  bool Failed() const { return failed_test_count() > 0; }\n\n  // Returns the elapsed time, in milliseconds.\n  TimeInMillis elapsed_time() const { return elapsed_time_; }\n\n  // Returns the i-th test among all the tests. i can range from 0 to\n  // total_test_count() - 1. If i is not in that range, returns NULL.\n  const TestInfo* GetTestInfo(int i) const;\n\n  // Returns the TestResult that holds test properties recorded during\n  // execution of SetUpTestCase and TearDownTestCase.\n  const TestResult& ad_hoc_test_result() const { return ad_hoc_test_result_; }\n\n private:\n  friend class Test;\n  friend class internal::UnitTestImpl;\n\n  // Gets the (mutable) vector of TestInfos in this TestCase.\n  std::vector<TestInfo*>& test_info_list() { return test_info_list_; }\n\n  // Gets the (immutable) vector of TestInfos in this TestCase.\n  const std::vector<TestInfo*>& test_info_list() const {\n    return test_info_list_;\n  }\n\n  // Returns the i-th test among all the tests. i can range from 0 to\n  // total_test_count() - 1. If i is not in that range, returns NULL.\n  TestInfo* GetMutableTestInfo(int i);\n\n  // Sets the should_run member.\n  void set_should_run(bool should) { should_run_ = should; }\n\n  // Adds a TestInfo to this test case.  Will delete the TestInfo upon\n  // destruction of the TestCase object.\n  void AddTestInfo(TestInfo * test_info);\n\n  // Clears the results of all tests in this test case.\n  void ClearResult();\n\n  // Clears the results of all tests in the given test case.\n  static void ClearTestCaseResult(TestCase* test_case) {\n    test_case->ClearResult();\n  }\n\n  // Runs every test in this TestCase.\n  void Run();\n\n  // Runs SetUpTestCase() for this TestCase.  This wrapper is needed\n  // for catching exceptions thrown from SetUpTestCase().\n  void RunSetUpTestCase() { (*set_up_tc_)(); }\n\n  // Runs TearDownTestCase() for this TestCase.  This wrapper is\n  // needed for catching exceptions thrown from TearDownTestCase().\n  void RunTearDownTestCase() { (*tear_down_tc_)(); }\n\n  // Returns true iff test passed.\n  static bool TestPassed(const TestInfo* test_info) {\n    return test_info->should_run() && test_info->result()->Passed();\n  }\n\n  // Returns true iff test failed.\n  static bool TestFailed(const TestInfo* test_info) {\n    return test_info->should_run() && test_info->result()->Failed();\n  }\n\n  // Returns true iff the test is disabled and will be reported in the XML\n  // report.\n  static bool TestReportableDisabled(const TestInfo* test_info) {\n    return test_info->is_reportable() && test_info->is_disabled_;\n  }\n\n  // Returns true iff test is disabled.\n  static bool TestDisabled(const TestInfo* test_info) {\n    return test_info->is_disabled_;\n  }\n\n  // Returns true iff this test will appear in the XML report.\n  static bool TestReportable(const TestInfo* test_info) {\n    return test_info->is_reportable();\n  }\n\n  // Returns true if the given test should run.\n  static bool ShouldRunTest(const TestInfo* test_info) {\n    return test_info->should_run();\n  }\n\n  // Shuffles the tests in this test case.\n  void ShuffleTests(internal::Random* random);\n\n  // Restores the test order to before the first shuffle.\n  void UnshuffleTests();\n\n  // Name of the test case.\n  std::string name_;\n  // Name of the parameter type, or NULL if this is not a typed or a\n  // type-parameterized test.\n  const internal::scoped_ptr<const ::std::string> type_param_;\n  // The vector of TestInfos in their original order.  It owns the\n  // elements in the vector.\n  std::vector<TestInfo*> test_info_list_;\n  // Provides a level of indirection for the test list to allow easy\n  // shuffling and restoring the test order.  The i-th element in this\n  // vector is the index of the i-th test in the shuffled test list.\n  std::vector<int> test_indices_;\n  // Pointer to the function that sets up the test case.\n  Test::SetUpTestCaseFunc set_up_tc_;\n  // Pointer to the function that tears down the test case.\n  Test::TearDownTestCaseFunc tear_down_tc_;\n  // True iff any test in this test case should run.\n  bool should_run_;\n  // Elapsed time, in milliseconds.\n  TimeInMillis elapsed_time_;\n  // Holds test properties recorded during execution of SetUpTestCase and\n  // TearDownTestCase.\n  TestResult ad_hoc_test_result_;\n\n  // We disallow copying TestCases.\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestCase);\n};\n\n// An Environment object is capable of setting up and tearing down an\n// environment.  The user should subclass this to define his own\n// environment(s).\n//\n// An Environment object does the set-up and tear-down in virtual\n// methods SetUp() and TearDown() instead of the constructor and the\n// destructor, as:\n//\n//   1. You cannot safely throw from a destructor.  This is a problem\n//      as in some cases Google Test is used where exceptions are enabled, and\n//      we may want to implement ASSERT_* using exceptions where they are\n//      available.\n//   2. You cannot use ASSERT_* directly in a constructor or\n//      destructor.\nclass Environment {\n public:\n  // The d'tor is virtual as we need to subclass Environment.\n  virtual ~Environment() {}\n\n  // Override this to define how to set up the environment.\n  virtual void SetUp() {}\n\n  // Override this to define how to tear down the environment.\n  virtual void TearDown() {}\n private:\n  // If you see an error about overriding the following function or\n  // about it being private, you have mis-spelled SetUp() as Setup().\n  struct Setup_should_be_spelled_SetUp {};\n  virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; }\n};\n\n// The interface for tracing execution of tests. The methods are organized in\n// the order the corresponding events are fired.\nclass TestEventListener {\n public:\n  virtual ~TestEventListener() {}\n\n  // Fired before any test activity starts.\n  virtual void OnTestProgramStart(const UnitTest& unit_test) = 0;\n\n  // Fired before each iteration of tests starts.  There may be more than\n  // one iteration if GTEST_FLAG(repeat) is set. iteration is the iteration\n  // index, starting from 0.\n  virtual void OnTestIterationStart(const UnitTest& unit_test,\n                                    int iteration) = 0;\n\n  // Fired before environment set-up for each iteration of tests starts.\n  virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test) = 0;\n\n  // Fired after environment set-up for each iteration of tests ends.\n  virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) = 0;\n\n  // Fired before the test case starts.\n  virtual void OnTestCaseStart(const TestCase& test_case) = 0;\n\n  // Fired before the test starts.\n  virtual void OnTestStart(const TestInfo& test_info) = 0;\n\n  // Fired after a failed assertion or a SUCCEED() invocation.\n  virtual void OnTestPartResult(const TestPartResult& test_part_result) = 0;\n\n  // Fired after the test ends.\n  virtual void OnTestEnd(const TestInfo& test_info) = 0;\n\n  // Fired after the test case ends.\n  virtual void OnTestCaseEnd(const TestCase& test_case) = 0;\n\n  // Fired before environment tear-down for each iteration of tests starts.\n  virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test) = 0;\n\n  // Fired after environment tear-down for each iteration of tests ends.\n  virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) = 0;\n\n  // Fired after each iteration of tests finishes.\n  virtual void OnTestIterationEnd(const UnitTest& unit_test,\n                                  int iteration) = 0;\n\n  // Fired after all test activities have ended.\n  virtual void OnTestProgramEnd(const UnitTest& unit_test) = 0;\n};\n\n// The convenience class for users who need to override just one or two\n// methods and are not concerned that a possible change to a signature of\n// the methods they override will not be caught during the build.  For\n// comments about each method please see the definition of TestEventListener\n// above.\nclass EmptyTestEventListener : public TestEventListener {\n public:\n  virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {}\n  virtual void OnTestIterationStart(const UnitTest& /*unit_test*/,\n                                    int /*iteration*/) {}\n  virtual void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) {}\n  virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {}\n  virtual void OnTestCaseStart(const TestCase& /*test_case*/) {}\n  virtual void OnTestStart(const TestInfo& /*test_info*/) {}\n  virtual void OnTestPartResult(const TestPartResult& /*test_part_result*/) {}\n  virtual void OnTestEnd(const TestInfo& /*test_info*/) {}\n  virtual void OnTestCaseEnd(const TestCase& /*test_case*/) {}\n  virtual void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) {}\n  virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {}\n  virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/,\n                                  int /*iteration*/) {}\n  virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {}\n};\n\n// TestEventListeners lets users add listeners to track events in Google Test.\nclass GTEST_API_ TestEventListeners {\n public:\n  TestEventListeners();\n  ~TestEventListeners();\n\n  // Appends an event listener to the end of the list. Google Test assumes\n  // the ownership of the listener (i.e. it will delete the listener when\n  // the test program finishes).\n  void Append(TestEventListener* listener);\n\n  // Removes the given event listener from the list and returns it.  It then\n  // becomes the caller's responsibility to delete the listener. Returns\n  // NULL if the listener is not found in the list.\n  TestEventListener* Release(TestEventListener* listener);\n\n  // Returns the standard listener responsible for the default console\n  // output.  Can be removed from the listeners list to shut down default\n  // console output.  Note that removing this object from the listener list\n  // with Release transfers its ownership to the caller and makes this\n  // function return NULL the next time.\n  TestEventListener* default_result_printer() const {\n    return default_result_printer_;\n  }\n\n  // Returns the standard listener responsible for the default XML output\n  // controlled by the --gtest_output=xml flag.  Can be removed from the\n  // listeners list by users who want to shut down the default XML output\n  // controlled by this flag and substitute it with custom one.  Note that\n  // removing this object from the listener list with Release transfers its\n  // ownership to the caller and makes this function return NULL the next\n  // time.\n  TestEventListener* default_xml_generator() const {\n    return default_xml_generator_;\n  }\n\n private:\n  friend class TestCase;\n  friend class TestInfo;\n  friend class internal::DefaultGlobalTestPartResultReporter;\n  friend class internal::NoExecDeathTest;\n  friend class internal::TestEventListenersAccessor;\n  friend class internal::UnitTestImpl;\n\n  // Returns repeater that broadcasts the TestEventListener events to all\n  // subscribers.\n  TestEventListener* repeater();\n\n  // Sets the default_result_printer attribute to the provided listener.\n  // The listener is also added to the listener list and previous\n  // default_result_printer is removed from it and deleted. The listener can\n  // also be NULL in which case it will not be added to the list. Does\n  // nothing if the previous and the current listener objects are the same.\n  void SetDefaultResultPrinter(TestEventListener* listener);\n\n  // Sets the default_xml_generator attribute to the provided listener.  The\n  // listener is also added to the listener list and previous\n  // default_xml_generator is removed from it and deleted. The listener can\n  // also be NULL in which case it will not be added to the list. Does\n  // nothing if the previous and the current listener objects are the same.\n  void SetDefaultXmlGenerator(TestEventListener* listener);\n\n  // Controls whether events will be forwarded by the repeater to the\n  // listeners in the list.\n  bool EventForwardingEnabled() const;\n  void SuppressEventForwarding();\n\n  // The actual list of listeners.\n  internal::TestEventRepeater* repeater_;\n  // Listener responsible for the standard result output.\n  TestEventListener* default_result_printer_;\n  // Listener responsible for the creation of the XML output file.\n  TestEventListener* default_xml_generator_;\n\n  // We disallow copying TestEventListeners.\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventListeners);\n};\n\n// A UnitTest consists of a vector of TestCases.\n//\n// This is a singleton class.  The only instance of UnitTest is\n// created when UnitTest::GetInstance() is first called.  This\n// instance is never deleted.\n//\n// UnitTest is not copyable.\n//\n// This class is thread-safe as long as the methods are called\n// according to their specification.\nclass GTEST_API_ UnitTest {\n public:\n  // Gets the singleton UnitTest object.  The first time this method\n  // is called, a UnitTest object is constructed and returned.\n  // Consecutive calls will return the same object.\n  static UnitTest* GetInstance();\n\n  // Runs all tests in this UnitTest object and prints the result.\n  // Returns 0 if successful, or 1 otherwise.\n  //\n  // This method can only be called from the main thread.\n  //\n  // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n  int Run() GTEST_MUST_USE_RESULT_;\n\n  // Returns the working directory when the first TEST() or TEST_F()\n  // was executed.  The UnitTest object owns the string.\n  const char* original_working_dir() const;\n\n  // Returns the TestCase object for the test that's currently running,\n  // or NULL if no test is running.\n  const TestCase* current_test_case() const\n      GTEST_LOCK_EXCLUDED_(mutex_);\n\n  // Returns the TestInfo object for the test that's currently running,\n  // or NULL if no test is running.\n  const TestInfo* current_test_info() const\n      GTEST_LOCK_EXCLUDED_(mutex_);\n\n  // Returns the random seed used at the start of the current test run.\n  int random_seed() const;\n\n#if GTEST_HAS_PARAM_TEST\n  // Returns the ParameterizedTestCaseRegistry object used to keep track of\n  // value-parameterized tests and instantiate and register them.\n  //\n  // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n  internal::ParameterizedTestCaseRegistry& parameterized_test_registry()\n      GTEST_LOCK_EXCLUDED_(mutex_);\n#endif  // GTEST_HAS_PARAM_TEST\n\n  // Gets the number of successful test cases.\n  int successful_test_case_count() const;\n\n  // Gets the number of failed test cases.\n  int failed_test_case_count() const;\n\n  // Gets the number of all test cases.\n  int total_test_case_count() const;\n\n  // Gets the number of all test cases that contain at least one test\n  // that should run.\n  int test_case_to_run_count() const;\n\n  // Gets the number of successful tests.\n  int successful_test_count() const;\n\n  // Gets the number of failed tests.\n  int failed_test_count() const;\n\n  // Gets the number of disabled tests that will be reported in the XML report.\n  int reportable_disabled_test_count() const;\n\n  // Gets the number of disabled tests.\n  int disabled_test_count() const;\n\n  // Gets the number of tests to be printed in the XML report.\n  int reportable_test_count() const;\n\n  // Gets the number of all tests.\n  int total_test_count() const;\n\n  // Gets the number of tests that should run.\n  int test_to_run_count() const;\n\n  // Gets the time of the test program start, in ms from the start of the\n  // UNIX epoch.\n  TimeInMillis start_timestamp() const;\n\n  // Gets the elapsed time, in milliseconds.\n  TimeInMillis elapsed_time() const;\n\n  // Returns true iff the unit test passed (i.e. all test cases passed).\n  bool Passed() const;\n\n  // Returns true iff the unit test failed (i.e. some test case failed\n  // or something outside of all tests failed).\n  bool Failed() const;\n\n  // Gets the i-th test case among all the test cases. i can range from 0 to\n  // total_test_case_count() - 1. If i is not in that range, returns NULL.\n  const TestCase* GetTestCase(int i) const;\n\n  // Returns the TestResult containing information on test failures and\n  // properties logged outside of individual test cases.\n  const TestResult& ad_hoc_test_result() const;\n\n  // Returns the list of event listeners that can be used to track events\n  // inside Google Test.\n  TestEventListeners& listeners();\n\n private:\n  // Registers and returns a global test environment.  When a test\n  // program is run, all global test environments will be set-up in\n  // the order they were registered.  After all tests in the program\n  // have finished, all global test environments will be torn-down in\n  // the *reverse* order they were registered.\n  //\n  // The UnitTest object takes ownership of the given environment.\n  //\n  // This method can only be called from the main thread.\n  Environment* AddEnvironment(Environment* env);\n\n  // Adds a TestPartResult to the current TestResult object.  All\n  // Google Test assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc)\n  // eventually call this to report their results.  The user code\n  // should use the assertion macros instead of calling this directly.\n  void AddTestPartResult(TestPartResult::Type result_type,\n                         const char* file_name,\n                         int line_number,\n                         const std::string& message,\n                         const std::string& os_stack_trace)\n      GTEST_LOCK_EXCLUDED_(mutex_);\n\n  // Adds a TestProperty to the current TestResult object when invoked from\n  // inside a test, to current TestCase's ad_hoc_test_result_ when invoked\n  // from SetUpTestCase or TearDownTestCase, or to the global property set\n  // when invoked elsewhere.  If the result already contains a property with\n  // the same key, the value will be updated.\n  void RecordProperty(const std::string& key, const std::string& value);\n\n  // Gets the i-th test case among all the test cases. i can range from 0 to\n  // total_test_case_count() - 1. If i is not in that range, returns NULL.\n  TestCase* GetMutableTestCase(int i);\n\n  // Accessors for the implementation object.\n  internal::UnitTestImpl* impl() { return impl_; }\n  const internal::UnitTestImpl* impl() const { return impl_; }\n\n  // These classes and funcions are friends as they need to access private\n  // members of UnitTest.\n  friend class Test;\n  friend class internal::AssertHelper;\n  friend class internal::ScopedTrace;\n  friend class internal::StreamingListenerTest;\n  friend class internal::UnitTestRecordPropertyTestHelper;\n  friend Environment* AddGlobalTestEnvironment(Environment* env);\n  friend internal::UnitTestImpl* internal::GetUnitTestImpl();\n  friend void internal::ReportFailureInUnknownLocation(\n      TestPartResult::Type result_type,\n      const std::string& message);\n\n  // Creates an empty UnitTest.\n  UnitTest();\n\n  // D'tor\n  virtual ~UnitTest();\n\n  // Pushes a trace defined by SCOPED_TRACE() on to the per-thread\n  // Google Test trace stack.\n  void PushGTestTrace(const internal::TraceInfo& trace)\n      GTEST_LOCK_EXCLUDED_(mutex_);\n\n  // Pops a trace from the per-thread Google Test trace stack.\n  void PopGTestTrace()\n      GTEST_LOCK_EXCLUDED_(mutex_);\n\n  // Protects mutable state in *impl_.  This is mutable as some const\n  // methods need to lock it too.\n  mutable internal::Mutex mutex_;\n\n  // Opaque implementation object.  This field is never changed once\n  // the object is constructed.  We don't mark it as const here, as\n  // doing so will cause a warning in the constructor of UnitTest.\n  // Mutable state in *impl_ is protected by mutex_.\n  internal::UnitTestImpl* impl_;\n\n  // We disallow copying UnitTest.\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTest);\n};\n\n// A convenient wrapper for adding an environment for the test\n// program.\n//\n// You should call this before RUN_ALL_TESTS() is called, probably in\n// main().  If you use gtest_main, you need to call this before main()\n// starts for it to take effect.  For example, you can define a global\n// variable like this:\n//\n//   testing::Environment* const foo_env =\n//       testing::AddGlobalTestEnvironment(new FooEnvironment);\n//\n// However, we strongly recommend you to write your own main() and\n// call AddGlobalTestEnvironment() there, as relying on initialization\n// of global variables makes the code harder to read and may cause\n// problems when you register multiple environments from different\n// translation units and the environments have dependencies among them\n// (remember that the compiler doesn't guarantee the order in which\n// global variables from different translation units are initialized).\ninline Environment* AddGlobalTestEnvironment(Environment* env) {\n  return UnitTest::GetInstance()->AddEnvironment(env);\n}\n\n// Initializes Google Test.  This must be called before calling\n// RUN_ALL_TESTS().  In particular, it parses a command line for the\n// flags that Google Test recognizes.  Whenever a Google Test flag is\n// seen, it is removed from argv, and *argc is decremented.\n//\n// No value is returned.  Instead, the Google Test flag variables are\n// updated.\n//\n// Calling the function for the second time has no user-visible effect.\nGTEST_API_ void InitGoogleTest(int* argc, char** argv);\n\n// This overloaded version can be used in Windows programs compiled in\n// UNICODE mode.\nGTEST_API_ void InitGoogleTest(int* argc, wchar_t** argv);\n\nnamespace internal {\n\n// FormatForComparison<ToPrint, OtherOperand>::Format(value) formats a\n// value of type ToPrint that is an operand of a comparison assertion\n// (e.g. ASSERT_EQ).  OtherOperand is the type of the other operand in\n// the comparison, and is used to help determine the best way to\n// format the value.  In particular, when the value is a C string\n// (char pointer) and the other operand is an STL string object, we\n// want to format the C string as a string, since we know it is\n// compared by value with the string object.  If the value is a char\n// pointer but the other operand is not an STL string object, we don't\n// know whether the pointer is supposed to point to a NUL-terminated\n// string, and thus want to print it as a pointer to be safe.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n\n// The default case.\ntemplate <typename ToPrint, typename OtherOperand>\nclass FormatForComparison {\n public:\n  static ::std::string Format(const ToPrint& value) {\n    return ::testing::PrintToString(value);\n  }\n};\n\n// Array.\ntemplate <typename ToPrint, size_t N, typename OtherOperand>\nclass FormatForComparison<ToPrint[N], OtherOperand> {\n public:\n  static ::std::string Format(const ToPrint* value) {\n    return FormatForComparison<const ToPrint*, OtherOperand>::Format(value);\n  }\n};\n\n// By default, print C string as pointers to be safe, as we don't know\n// whether they actually point to a NUL-terminated string.\n\n#define GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(CharType)                \\\n  template <typename OtherOperand>                                      \\\n  class FormatForComparison<CharType*, OtherOperand> {                  \\\n   public:                                                              \\\n    static ::std::string Format(CharType* value) {                      \\\n      return ::testing::PrintToString(static_cast<const void*>(value)); \\\n    }                                                                   \\\n  }\n\nGTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char);\nGTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char);\nGTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(wchar_t);\nGTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const wchar_t);\n\n#undef GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_\n\n// If a C string is compared with an STL string object, we know it's meant\n// to point to a NUL-terminated string, and thus can print it as a string.\n\n#define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType) \\\n  template <>                                                           \\\n  class FormatForComparison<CharType*, OtherStringType> {               \\\n   public:                                                              \\\n    static ::std::string Format(CharType* value) {                      \\\n      return ::testing::PrintToString(value);                           \\\n    }                                                                   \\\n  }\n\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::std::string);\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::std::string);\n\n#if GTEST_HAS_GLOBAL_STRING\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::string);\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::string);\n#endif\n\n#if GTEST_HAS_GLOBAL_WSTRING\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::wstring);\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::wstring);\n#endif\n\n#if GTEST_HAS_STD_WSTRING\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::std::wstring);\nGTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::std::wstring);\n#endif\n\n#undef GTEST_IMPL_FORMAT_C_STRING_AS_STRING_\n\n// Formats a comparison assertion (e.g. ASSERT_EQ, EXPECT_LT, and etc)\n// operand to be used in a failure message.  The type (but not value)\n// of the other operand may affect the format.  This allows us to\n// print a char* as a raw pointer when it is compared against another\n// char* or void*, and print it as a C string when it is compared\n// against an std::string object, for example.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\ntemplate <typename T1, typename T2>\nstd::string FormatForComparisonFailureMessage(\n    const T1& value, const T2& /* other_operand */) {\n  return FormatForComparison<T1, T2>::Format(value);\n}\n\n// The helper function for {ASSERT|EXPECT}_EQ.\ntemplate <typename T1, typename T2>\nAssertionResult CmpHelperEQ(const char* expected_expression,\n                            const char* actual_expression,\n                            const T1& expected,\n                            const T2& actual) {\n#ifdef _MSC_VER\n# pragma warning(push)          // Saves the current warning state.\n# pragma warning(disable:4389)  // Temporarily disables warning on\n                                // signed/unsigned mismatch.\n#endif\n\n  if (expected == actual) {\n    return AssertionSuccess();\n  }\n\n#ifdef _MSC_VER\n# pragma warning(pop)          // Restores the warning state.\n#endif\n\n  return EqFailure(expected_expression,\n                   actual_expression,\n                   FormatForComparisonFailureMessage(expected, actual),\n                   FormatForComparisonFailureMessage(actual, expected),\n                   false);\n}\n\n// With this overloaded version, we allow anonymous enums to be used\n// in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous enums\n// can be implicitly cast to BiggestInt.\nGTEST_API_ AssertionResult CmpHelperEQ(const char* expected_expression,\n                                       const char* actual_expression,\n                                       BiggestInt expected,\n                                       BiggestInt actual);\n\n// The helper class for {ASSERT|EXPECT}_EQ.  The template argument\n// lhs_is_null_literal is true iff the first argument to ASSERT_EQ()\n// is a null pointer literal.  The following default implementation is\n// for lhs_is_null_literal being false.\ntemplate <bool lhs_is_null_literal>\nclass EqHelper {\n public:\n  // This templatized version is for the general case.\n  template <typename T1, typename T2>\n  static AssertionResult Compare(const char* expected_expression,\n                                 const char* actual_expression,\n                                 const T1& expected,\n                                 const T2& actual) {\n    return CmpHelperEQ(expected_expression, actual_expression, expected,\n                       actual);\n  }\n\n  // With this overloaded version, we allow anonymous enums to be used\n  // in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous\n  // enums can be implicitly cast to BiggestInt.\n  //\n  // Even though its body looks the same as the above version, we\n  // cannot merge the two, as it will make anonymous enums unhappy.\n  static AssertionResult Compare(const char* expected_expression,\n                                 const char* actual_expression,\n                                 BiggestInt expected,\n                                 BiggestInt actual) {\n    return CmpHelperEQ(expected_expression, actual_expression, expected,\n                       actual);\n  }\n};\n\n// This specialization is used when the first argument to ASSERT_EQ()\n// is a null pointer literal, like NULL, false, or 0.\ntemplate <>\nclass EqHelper<true> {\n public:\n  // We define two overloaded versions of Compare().  The first\n  // version will be picked when the second argument to ASSERT_EQ() is\n  // NOT a pointer, e.g. ASSERT_EQ(0, AnIntFunction()) or\n  // EXPECT_EQ(false, a_bool).\n  template <typename T1, typename T2>\n  static AssertionResult Compare(\n      const char* expected_expression,\n      const char* actual_expression,\n      const T1& expected,\n      const T2& actual,\n      // The following line prevents this overload from being considered if T2\n      // is not a pointer type.  We need this because ASSERT_EQ(NULL, my_ptr)\n      // expands to Compare(\"\", \"\", NULL, my_ptr), which requires a conversion\n      // to match the Secret* in the other overload, which would otherwise make\n      // this template match better.\n      typename EnableIf<!is_pointer<T2>::value>::type* = 0) {\n    return CmpHelperEQ(expected_expression, actual_expression, expected,\n                       actual);\n  }\n\n  // This version will be picked when the second argument to ASSERT_EQ() is a\n  // pointer, e.g. ASSERT_EQ(NULL, a_pointer).\n  template <typename T>\n  static AssertionResult Compare(\n      const char* expected_expression,\n      const char* actual_expression,\n      // We used to have a second template parameter instead of Secret*.  That\n      // template parameter would deduce to 'long', making this a better match\n      // than the first overload even without the first overload's EnableIf.\n      // Unfortunately, gcc with -Wconversion-null warns when \"passing NULL to\n      // non-pointer argument\" (even a deduced integral argument), so the old\n      // implementation caused warnings in user code.\n      Secret* /* expected (NULL) */,\n      T* actual) {\n    // We already know that 'expected' is a null pointer.\n    return CmpHelperEQ(expected_expression, actual_expression,\n                       static_cast<T*>(NULL), actual);\n  }\n};\n\n// A macro for implementing the helper functions needed to implement\n// ASSERT_?? and EXPECT_??.  It is here just to avoid copy-and-paste\n// of similar code.\n//\n// For each templatized helper function, we also define an overloaded\n// version for BiggestInt in order to reduce code bloat and allow\n// anonymous enums to be used with {ASSERT|EXPECT}_?? when compiled\n// with gcc 4.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n#define GTEST_IMPL_CMP_HELPER_(op_name, op)\\\ntemplate <typename T1, typename T2>\\\nAssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \\\n                                   const T1& val1, const T2& val2) {\\\n  if (val1 op val2) {\\\n    return AssertionSuccess();\\\n  } else {\\\n    return AssertionFailure() \\\n        << \"Expected: (\" << expr1 << \") \" #op \" (\" << expr2\\\n        << \"), actual: \" << FormatForComparisonFailureMessage(val1, val2)\\\n        << \" vs \" << FormatForComparisonFailureMessage(val2, val1);\\\n  }\\\n}\\\nGTEST_API_ AssertionResult CmpHelper##op_name(\\\n    const char* expr1, const char* expr2, BiggestInt val1, BiggestInt val2)\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\n\n// Implements the helper function for {ASSERT|EXPECT}_NE\nGTEST_IMPL_CMP_HELPER_(NE, !=);\n// Implements the helper function for {ASSERT|EXPECT}_LE\nGTEST_IMPL_CMP_HELPER_(LE, <=);\n// Implements the helper function for {ASSERT|EXPECT}_LT\nGTEST_IMPL_CMP_HELPER_(LT, <);\n// Implements the helper function for {ASSERT|EXPECT}_GE\nGTEST_IMPL_CMP_HELPER_(GE, >=);\n// Implements the helper function for {ASSERT|EXPECT}_GT\nGTEST_IMPL_CMP_HELPER_(GT, >);\n\n#undef GTEST_IMPL_CMP_HELPER_\n\n// The helper function for {ASSERT|EXPECT}_STREQ.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nGTEST_API_ AssertionResult CmpHelperSTREQ(const char* expected_expression,\n                                          const char* actual_expression,\n                                          const char* expected,\n                                          const char* actual);\n\n// The helper function for {ASSERT|EXPECT}_STRCASEEQ.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nGTEST_API_ AssertionResult CmpHelperSTRCASEEQ(const char* expected_expression,\n                                              const char* actual_expression,\n                                              const char* expected,\n                                              const char* actual);\n\n// The helper function for {ASSERT|EXPECT}_STRNE.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nGTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,\n                                          const char* s2_expression,\n                                          const char* s1,\n                                          const char* s2);\n\n// The helper function for {ASSERT|EXPECT}_STRCASENE.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nGTEST_API_ AssertionResult CmpHelperSTRCASENE(const char* s1_expression,\n                                              const char* s2_expression,\n                                              const char* s1,\n                                              const char* s2);\n\n\n// Helper function for *_STREQ on wide strings.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nGTEST_API_ AssertionResult CmpHelperSTREQ(const char* expected_expression,\n                                          const char* actual_expression,\n                                          const wchar_t* expected,\n                                          const wchar_t* actual);\n\n// Helper function for *_STRNE on wide strings.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nGTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression,\n                                          const char* s2_expression,\n                                          const wchar_t* s1,\n                                          const wchar_t* s2);\n\n}  // namespace internal\n\n// IsSubstring() and IsNotSubstring() are intended to be used as the\n// first argument to {EXPECT,ASSERT}_PRED_FORMAT2(), not by\n// themselves.  They check whether needle is a substring of haystack\n// (NULL is considered a substring of itself only), and return an\n// appropriate error message when they fail.\n//\n// The {needle,haystack}_expr arguments are the stringified\n// expressions that generated the two real arguments.\nGTEST_API_ AssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const char* needle, const char* haystack);\nGTEST_API_ AssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const wchar_t* needle, const wchar_t* haystack);\nGTEST_API_ AssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const char* needle, const char* haystack);\nGTEST_API_ AssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const wchar_t* needle, const wchar_t* haystack);\nGTEST_API_ AssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::string& needle, const ::std::string& haystack);\nGTEST_API_ AssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::string& needle, const ::std::string& haystack);\n\n#if GTEST_HAS_STD_WSTRING\nGTEST_API_ AssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::wstring& needle, const ::std::wstring& haystack);\nGTEST_API_ AssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::wstring& needle, const ::std::wstring& haystack);\n#endif  // GTEST_HAS_STD_WSTRING\n\nnamespace internal {\n\n// Helper template function for comparing floating-points.\n//\n// Template parameter:\n//\n//   RawType: the raw floating-point type (either float or double)\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\ntemplate <typename RawType>\nAssertionResult CmpHelperFloatingPointEQ(const char* expected_expression,\n                                         const char* actual_expression,\n                                         RawType expected,\n                                         RawType actual) {\n  const FloatingPoint<RawType> lhs(expected), rhs(actual);\n\n  if (lhs.AlmostEquals(rhs)) {\n    return AssertionSuccess();\n  }\n\n  ::std::stringstream expected_ss;\n  expected_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)\n              << expected;\n\n  ::std::stringstream actual_ss;\n  actual_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)\n            << actual;\n\n  return EqFailure(expected_expression,\n                   actual_expression,\n                   StringStreamToString(&expected_ss),\n                   StringStreamToString(&actual_ss),\n                   false);\n}\n\n// Helper function for implementing ASSERT_NEAR.\n//\n// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.\nGTEST_API_ AssertionResult DoubleNearPredFormat(const char* expr1,\n                                                const char* expr2,\n                                                const char* abs_error_expr,\n                                                double val1,\n                                                double val2,\n                                                double abs_error);\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n// A class that enables one to stream messages to assertion macros\nclass GTEST_API_ AssertHelper {\n public:\n  // Constructor.\n  AssertHelper(TestPartResult::Type type,\n               const char* file,\n               int line,\n               const char* message);\n  ~AssertHelper();\n\n  // Message assignment is a semantic trick to enable assertion\n  // streaming; see the GTEST_MESSAGE_ macro below.\n  void operator=(const Message& message) const;\n\n private:\n  // We put our data in a struct so that the size of the AssertHelper class can\n  // be as small as possible.  This is important because gcc is incapable of\n  // re-using stack space even for temporary variables, so every EXPECT_EQ\n  // reserves stack space for another AssertHelper.\n  struct AssertHelperData {\n    AssertHelperData(TestPartResult::Type t,\n                     const char* srcfile,\n                     int line_num,\n                     const char* msg)\n        : type(t), file(srcfile), line(line_num), message(msg) { }\n\n    TestPartResult::Type const type;\n    const char* const file;\n    int const line;\n    std::string const message;\n\n   private:\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelperData);\n  };\n\n  AssertHelperData* const data_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper);\n};\n\n}  // namespace internal\n\n#if GTEST_HAS_PARAM_TEST\n// The pure interface class that all value-parameterized tests inherit from.\n// A value-parameterized class must inherit from both ::testing::Test and\n// ::testing::WithParamInterface. In most cases that just means inheriting\n// from ::testing::TestWithParam, but more complicated test hierarchies\n// may need to inherit from Test and WithParamInterface at different levels.\n//\n// This interface has support for accessing the test parameter value via\n// the GetParam() method.\n//\n// Use it with one of the parameter generator defining functions, like Range(),\n// Values(), ValuesIn(), Bool(), and Combine().\n//\n// class FooTest : public ::testing::TestWithParam<int> {\n//  protected:\n//   FooTest() {\n//     // Can use GetParam() here.\n//   }\n//   virtual ~FooTest() {\n//     // Can use GetParam() here.\n//   }\n//   virtual void SetUp() {\n//     // Can use GetParam() here.\n//   }\n//   virtual void TearDown {\n//     // Can use GetParam() here.\n//   }\n// };\n// TEST_P(FooTest, DoesBar) {\n//   // Can use GetParam() method here.\n//   Foo foo;\n//   ASSERT_TRUE(foo.DoesBar(GetParam()));\n// }\n// INSTANTIATE_TEST_CASE_P(OneToTenRange, FooTest, ::testing::Range(1, 10));\n\ntemplate <typename T>\nclass WithParamInterface {\n public:\n  typedef T ParamType;\n  virtual ~WithParamInterface() {}\n\n  // The current parameter value. Is also available in the test fixture's\n  // constructor. This member function is non-static, even though it only\n  // references static data, to reduce the opportunity for incorrect uses\n  // like writing 'WithParamInterface<bool>::GetParam()' for a test that\n  // uses a fixture whose parameter type is int.\n  const ParamType& GetParam() const {\n    GTEST_CHECK_(parameter_ != NULL)\n        << \"GetParam() can only be called inside a value-parameterized test \"\n        << \"-- did you intend to write TEST_P instead of TEST_F?\";\n    return *parameter_;\n  }\n\n private:\n  // Sets parameter value. The caller is responsible for making sure the value\n  // remains alive and unchanged throughout the current test.\n  static void SetParam(const ParamType* parameter) {\n    parameter_ = parameter;\n  }\n\n  // Static value used for accessing parameter during a test lifetime.\n  static const ParamType* parameter_;\n\n  // TestClass must be a subclass of WithParamInterface<T> and Test.\n  template <class TestClass> friend class internal::ParameterizedTestFactory;\n};\n\ntemplate <typename T>\nconst T* WithParamInterface<T>::parameter_ = NULL;\n\n// Most value-parameterized classes can ignore the existence of\n// WithParamInterface, and can just inherit from ::testing::TestWithParam.\n\ntemplate <typename T>\nclass TestWithParam : public Test, public WithParamInterface<T> {\n};\n\n#endif  // GTEST_HAS_PARAM_TEST\n\n// Macros for indicating success/failure in test code.\n\n// ADD_FAILURE unconditionally adds a failure to the current test.\n// SUCCEED generates a success - it doesn't automatically make the\n// current test successful, as a test is only successful when it has\n// no failure.\n//\n// EXPECT_* verifies that a certain condition is satisfied.  If not,\n// it behaves like ADD_FAILURE.  In particular:\n//\n//   EXPECT_TRUE  verifies that a Boolean condition is true.\n//   EXPECT_FALSE verifies that a Boolean condition is false.\n//\n// FAIL and ASSERT_* are similar to ADD_FAILURE and EXPECT_*, except\n// that they will also abort the current function on failure.  People\n// usually want the fail-fast behavior of FAIL and ASSERT_*, but those\n// writing data-driven tests often find themselves using ADD_FAILURE\n// and EXPECT_* more.\n\n// Generates a nonfatal failure with a generic message.\n#define ADD_FAILURE() GTEST_NONFATAL_FAILURE_(\"Failed\")\n\n// Generates a nonfatal failure at the given source file location with\n// a generic message.\n#define ADD_FAILURE_AT(file, line) \\\n  GTEST_MESSAGE_AT_(file, line, \"Failed\", \\\n                    ::testing::TestPartResult::kNonFatalFailure)\n\n// Generates a fatal failure with a generic message.\n#define GTEST_FAIL() GTEST_FATAL_FAILURE_(\"Failed\")\n\n// Define this macro to 1 to omit the definition of FAIL(), which is a\n// generic name and clashes with some other libraries.\n#if !GTEST_DONT_DEFINE_FAIL\n# define FAIL() GTEST_FAIL()\n#endif\n\n// Generates a success with a generic message.\n#define GTEST_SUCCEED() GTEST_SUCCESS_(\"Succeeded\")\n\n// Define this macro to 1 to omit the definition of SUCCEED(), which\n// is a generic name and clashes with some other libraries.\n#if !GTEST_DONT_DEFINE_SUCCEED\n# define SUCCEED() GTEST_SUCCEED()\n#endif\n\n// Macros for testing exceptions.\n//\n//    * {ASSERT|EXPECT}_THROW(statement, expected_exception):\n//         Tests that the statement throws the expected exception.\n//    * {ASSERT|EXPECT}_NO_THROW(statement):\n//         Tests that the statement doesn't throw any exception.\n//    * {ASSERT|EXPECT}_ANY_THROW(statement):\n//         Tests that the statement throws an exception.\n\n#define EXPECT_THROW(statement, expected_exception) \\\n  GTEST_TEST_THROW_(statement, expected_exception, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_NO_THROW(statement) \\\n  GTEST_TEST_NO_THROW_(statement, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_ANY_THROW(statement) \\\n  GTEST_TEST_ANY_THROW_(statement, GTEST_NONFATAL_FAILURE_)\n#define ASSERT_THROW(statement, expected_exception) \\\n  GTEST_TEST_THROW_(statement, expected_exception, GTEST_FATAL_FAILURE_)\n#define ASSERT_NO_THROW(statement) \\\n  GTEST_TEST_NO_THROW_(statement, GTEST_FATAL_FAILURE_)\n#define ASSERT_ANY_THROW(statement) \\\n  GTEST_TEST_ANY_THROW_(statement, GTEST_FATAL_FAILURE_)\n\n// Boolean assertions. Condition can be either a Boolean expression or an\n// AssertionResult. For more information on how to use AssertionResult with\n// these macros see comments on that class.\n#define EXPECT_TRUE(condition) \\\n  GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \\\n                      GTEST_NONFATAL_FAILURE_)\n#define EXPECT_FALSE(condition) \\\n  GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \\\n                      GTEST_NONFATAL_FAILURE_)\n#define ASSERT_TRUE(condition) \\\n  GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \\\n                      GTEST_FATAL_FAILURE_)\n#define ASSERT_FALSE(condition) \\\n  GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \\\n                      GTEST_FATAL_FAILURE_)\n\n// Includes the auto-generated header that implements a family of\n// generic predicate assertion macros.\n#include \"gtest/gtest_pred_impl.h\"\n\n// Macros for testing equalities and inequalities.\n//\n//    * {ASSERT|EXPECT}_EQ(expected, actual): Tests that expected == actual\n//    * {ASSERT|EXPECT}_NE(v1, v2):           Tests that v1 != v2\n//    * {ASSERT|EXPECT}_LT(v1, v2):           Tests that v1 < v2\n//    * {ASSERT|EXPECT}_LE(v1, v2):           Tests that v1 <= v2\n//    * {ASSERT|EXPECT}_GT(v1, v2):           Tests that v1 > v2\n//    * {ASSERT|EXPECT}_GE(v1, v2):           Tests that v1 >= v2\n//\n// When they are not, Google Test prints both the tested expressions and\n// their actual values.  The values must be compatible built-in types,\n// or you will get a compiler error.  By \"compatible\" we mean that the\n// values can be compared by the respective operator.\n//\n// Note:\n//\n//   1. It is possible to make a user-defined type work with\n//   {ASSERT|EXPECT}_??(), but that requires overloading the\n//   comparison operators and is thus discouraged by the Google C++\n//   Usage Guide.  Therefore, you are advised to use the\n//   {ASSERT|EXPECT}_TRUE() macro to assert that two objects are\n//   equal.\n//\n//   2. The {ASSERT|EXPECT}_??() macros do pointer comparisons on\n//   pointers (in particular, C strings).  Therefore, if you use it\n//   with two C strings, you are testing how their locations in memory\n//   are related, not how their content is related.  To compare two C\n//   strings by content, use {ASSERT|EXPECT}_STR*().\n//\n//   3. {ASSERT|EXPECT}_EQ(expected, actual) is preferred to\n//   {ASSERT|EXPECT}_TRUE(expected == actual), as the former tells you\n//   what the actual value is when it fails, and similarly for the\n//   other comparisons.\n//\n//   4. Do not depend on the order in which {ASSERT|EXPECT}_??()\n//   evaluate their arguments, which is undefined.\n//\n//   5. These macros evaluate their arguments exactly once.\n//\n// Examples:\n//\n//   EXPECT_NE(5, Foo());\n//   EXPECT_EQ(NULL, a_pointer);\n//   ASSERT_LT(i, array_size);\n//   ASSERT_GT(records.size(), 0) << \"There is no record left.\";\n\n#define EXPECT_EQ(expected, actual) \\\n  EXPECT_PRED_FORMAT2(::testing::internal:: \\\n                      EqHelper<GTEST_IS_NULL_LITERAL_(expected)>::Compare, \\\n                      expected, actual)\n#define EXPECT_NE(expected, actual) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, expected, actual)\n#define EXPECT_LE(val1, val2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)\n#define EXPECT_LT(val1, val2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)\n#define EXPECT_GE(val1, val2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)\n#define EXPECT_GT(val1, val2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)\n\n#define GTEST_ASSERT_EQ(expected, actual) \\\n  ASSERT_PRED_FORMAT2(::testing::internal:: \\\n                      EqHelper<GTEST_IS_NULL_LITERAL_(expected)>::Compare, \\\n                      expected, actual)\n#define GTEST_ASSERT_NE(val1, val2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)\n#define GTEST_ASSERT_LE(val1, val2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2)\n#define GTEST_ASSERT_LT(val1, val2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2)\n#define GTEST_ASSERT_GE(val1, val2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2)\n#define GTEST_ASSERT_GT(val1, val2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2)\n\n// Define macro GTEST_DONT_DEFINE_ASSERT_XY to 1 to omit the definition of\n// ASSERT_XY(), which clashes with some users' own code.\n\n#if !GTEST_DONT_DEFINE_ASSERT_EQ\n# define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)\n#endif\n\n#if !GTEST_DONT_DEFINE_ASSERT_NE\n# define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)\n#endif\n\n#if !GTEST_DONT_DEFINE_ASSERT_LE\n# define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2)\n#endif\n\n#if !GTEST_DONT_DEFINE_ASSERT_LT\n# define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2)\n#endif\n\n#if !GTEST_DONT_DEFINE_ASSERT_GE\n# define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2)\n#endif\n\n#if !GTEST_DONT_DEFINE_ASSERT_GT\n# define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2)\n#endif\n\n// C-string Comparisons.  All tests treat NULL and any non-NULL string\n// as different.  Two NULLs are equal.\n//\n//    * {ASSERT|EXPECT}_STREQ(s1, s2):     Tests that s1 == s2\n//    * {ASSERT|EXPECT}_STRNE(s1, s2):     Tests that s1 != s2\n//    * {ASSERT|EXPECT}_STRCASEEQ(s1, s2): Tests that s1 == s2, ignoring case\n//    * {ASSERT|EXPECT}_STRCASENE(s1, s2): Tests that s1 != s2, ignoring case\n//\n// For wide or narrow string objects, you can use the\n// {ASSERT|EXPECT}_??() macros.\n//\n// Don't depend on the order in which the arguments are evaluated,\n// which is undefined.\n//\n// These macros evaluate their arguments exactly once.\n\n#define EXPECT_STREQ(expected, actual) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, expected, actual)\n#define EXPECT_STRNE(s1, s2) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)\n#define EXPECT_STRCASEEQ(expected, actual) \\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, expected, actual)\n#define EXPECT_STRCASENE(s1, s2)\\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)\n\n#define ASSERT_STREQ(expected, actual) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, expected, actual)\n#define ASSERT_STRNE(s1, s2) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2)\n#define ASSERT_STRCASEEQ(expected, actual) \\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, expected, actual)\n#define ASSERT_STRCASENE(s1, s2)\\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2)\n\n// Macros for comparing floating-point numbers.\n//\n//    * {ASSERT|EXPECT}_FLOAT_EQ(expected, actual):\n//         Tests that two float values are almost equal.\n//    * {ASSERT|EXPECT}_DOUBLE_EQ(expected, actual):\n//         Tests that two double values are almost equal.\n//    * {ASSERT|EXPECT}_NEAR(v1, v2, abs_error):\n//         Tests that v1 and v2 are within the given distance to each other.\n//\n// Google Test uses ULP-based comparison to automatically pick a default\n// error bound that is appropriate for the operands.  See the\n// FloatingPoint template class in gtest-internal.h if you are\n// interested in the implementation details.\n\n#define EXPECT_FLOAT_EQ(expected, actual)\\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \\\n                      expected, actual)\n\n#define EXPECT_DOUBLE_EQ(expected, actual)\\\n  EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \\\n                      expected, actual)\n\n#define ASSERT_FLOAT_EQ(expected, actual)\\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<float>, \\\n                      expected, actual)\n\n#define ASSERT_DOUBLE_EQ(expected, actual)\\\n  ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ<double>, \\\n                      expected, actual)\n\n#define EXPECT_NEAR(val1, val2, abs_error)\\\n  EXPECT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \\\n                      val1, val2, abs_error)\n\n#define ASSERT_NEAR(val1, val2, abs_error)\\\n  ASSERT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \\\n                      val1, val2, abs_error)\n\n// These predicate format functions work on floating-point values, and\n// can be used in {ASSERT|EXPECT}_PRED_FORMAT2*(), e.g.\n//\n//   EXPECT_PRED_FORMAT2(testing::DoubleLE, Foo(), 5.0);\n\n// Asserts that val1 is less than, or almost equal to, val2.  Fails\n// otherwise.  In particular, it fails if either val1 or val2 is NaN.\nGTEST_API_ AssertionResult FloatLE(const char* expr1, const char* expr2,\n                                   float val1, float val2);\nGTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2,\n                                    double val1, double val2);\n\n\n#if GTEST_OS_WINDOWS\n\n// Macros that test for HRESULT failure and success, these are only useful\n// on Windows, and rely on Windows SDK macros and APIs to compile.\n//\n//    * {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}(expr)\n//\n// When expr unexpectedly fails or succeeds, Google Test prints the\n// expected result and the actual result with both a human-readable\n// string representation of the error, if available, as well as the\n// hex result code.\n# define EXPECT_HRESULT_SUCCEEDED(expr) \\\n    EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))\n\n# define ASSERT_HRESULT_SUCCEEDED(expr) \\\n    ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr))\n\n# define EXPECT_HRESULT_FAILED(expr) \\\n    EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))\n\n# define ASSERT_HRESULT_FAILED(expr) \\\n    ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr))\n\n#endif  // GTEST_OS_WINDOWS\n\n// Macros that execute statement and check that it doesn't generate new fatal\n// failures in the current thread.\n//\n//   * {ASSERT|EXPECT}_NO_FATAL_FAILURE(statement);\n//\n// Examples:\n//\n//   EXPECT_NO_FATAL_FAILURE(Process());\n//   ASSERT_NO_FATAL_FAILURE(Process()) << \"Process() failed\";\n//\n#define ASSERT_NO_FATAL_FAILURE(statement) \\\n    GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_FATAL_FAILURE_)\n#define EXPECT_NO_FATAL_FAILURE(statement) \\\n    GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_)\n\n// Causes a trace (including the source file path, the current line\n// number, and the given message) to be included in every test failure\n// message generated by code in the current scope.  The effect is\n// undone when the control leaves the current scope.\n//\n// The message argument can be anything streamable to std::ostream.\n//\n// In the implementation, we include the current line number as part\n// of the dummy variable name, thus allowing multiple SCOPED_TRACE()s\n// to appear in the same block - as long as they are on different\n// lines.\n#define SCOPED_TRACE(message) \\\n  ::testing::internal::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\\\n    __FILE__, __LINE__, ::testing::Message() << (message))\n\n// Compile-time assertion for type equality.\n// StaticAssertTypeEq<type1, type2>() compiles iff type1 and type2 are\n// the same type.  The value it returns is not interesting.\n//\n// Instead of making StaticAssertTypeEq a class template, we make it a\n// function template that invokes a helper class template.  This\n// prevents a user from misusing StaticAssertTypeEq<T1, T2> by\n// defining objects of that type.\n//\n// CAVEAT:\n//\n// When used inside a method of a class template,\n// StaticAssertTypeEq<T1, T2>() is effective ONLY IF the method is\n// instantiated.  For example, given:\n//\n//   template <typename T> class Foo {\n//    public:\n//     void Bar() { testing::StaticAssertTypeEq<int, T>(); }\n//   };\n//\n// the code:\n//\n//   void Test1() { Foo<bool> foo; }\n//\n// will NOT generate a compiler error, as Foo<bool>::Bar() is never\n// actually instantiated.  Instead, you need:\n//\n//   void Test2() { Foo<bool> foo; foo.Bar(); }\n//\n// to cause a compiler error.\ntemplate <typename T1, typename T2>\nbool StaticAssertTypeEq() {\n  (void)internal::StaticAssertTypeEqHelper<T1, T2>();\n  return true;\n}\n\n// Defines a test.\n//\n// The first parameter is the name of the test case, and the second\n// parameter is the name of the test within the test case.\n//\n// The convention is to end the test case name with \"Test\".  For\n// example, a test case for the Foo class can be named FooTest.\n//\n// The user should put his test code between braces after using this\n// macro.  Example:\n//\n//   TEST(FooTest, InitializesCorrectly) {\n//     Foo foo;\n//     EXPECT_TRUE(foo.StatusIsOK());\n//   }\n\n// Note that we call GetTestTypeId() instead of GetTypeId<\n// ::testing::Test>() here to get the type ID of testing::Test.  This\n// is to work around a suspected linker bug when using Google Test as\n// a framework on Mac OS X.  The bug causes GetTypeId<\n// ::testing::Test>() to return different values depending on whether\n// the call is from the Google Test framework itself or from user test\n// code.  GetTestTypeId() is guaranteed to always return the same\n// value, as it always calls GetTypeId<>() from the Google Test\n// framework.\n#define GTEST_TEST(test_case_name, test_name)\\\n  GTEST_TEST_(test_case_name, test_name, \\\n              ::testing::Test, ::testing::internal::GetTestTypeId())\n\n// Define this macro to 1 to omit the definition of TEST(), which\n// is a generic name and clashes with some other libraries.\n#if !GTEST_DONT_DEFINE_TEST\n# define TEST(test_case_name, test_name) GTEST_TEST(test_case_name, test_name)\n#endif\n\n// Defines a test that uses a test fixture.\n//\n// The first parameter is the name of the test fixture class, which\n// also doubles as the test case name.  The second parameter is the\n// name of the test within the test case.\n//\n// A test fixture class must be declared earlier.  The user should put\n// his test code between braces after using this macro.  Example:\n//\n//   class FooTest : public testing::Test {\n//    protected:\n//     virtual void SetUp() { b_.AddElement(3); }\n//\n//     Foo a_;\n//     Foo b_;\n//   };\n//\n//   TEST_F(FooTest, InitializesCorrectly) {\n//     EXPECT_TRUE(a_.StatusIsOK());\n//   }\n//\n//   TEST_F(FooTest, ReturnsElementCountCorrectly) {\n//     EXPECT_EQ(0, a_.size());\n//     EXPECT_EQ(1, b_.size());\n//   }\n\n#define TEST_F(test_fixture, test_name)\\\n  GTEST_TEST_(test_fixture, test_name, test_fixture, \\\n              ::testing::internal::GetTypeId<test_fixture>())\n\n}  // namespace testing\n\n// Use this function in main() to run all tests.  It returns 0 if all\n// tests are successful, or 1 otherwise.\n//\n// RUN_ALL_TESTS() should be invoked after the command line has been\n// parsed by InitGoogleTest().\n//\n// This function was formerly a macro; thus, it is in the global\n// namespace and has an all-caps name.\nint RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_;\n\ninline int RUN_ALL_TESTS() {\n  return ::testing::UnitTest::GetInstance()->Run();\n}\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/gtest_pred_impl.h",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file is AUTOMATICALLY GENERATED on 10/31/2011 by command\n// 'gen_gtest_pred_impl.py 5'.  DO NOT EDIT BY HAND!\n//\n// Implements a family of generic predicate assertion macros.\n\n#ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_\n#define GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_\n\n// Makes sure this header is not included before gtest.h.\n#ifndef GTEST_INCLUDE_GTEST_GTEST_H_\n# error Do not include gtest_pred_impl.h directly.  Include gtest.h instead.\n#endif  // GTEST_INCLUDE_GTEST_GTEST_H_\n\n// This header implements a family of generic predicate assertion\n// macros:\n//\n//   ASSERT_PRED_FORMAT1(pred_format, v1)\n//   ASSERT_PRED_FORMAT2(pred_format, v1, v2)\n//   ...\n//\n// where pred_format is a function or functor that takes n (in the\n// case of ASSERT_PRED_FORMATn) values and their source expression\n// text, and returns a testing::AssertionResult.  See the definition\n// of ASSERT_EQ in gtest.h for an example.\n//\n// If you don't care about formatting, you can use the more\n// restrictive version:\n//\n//   ASSERT_PRED1(pred, v1)\n//   ASSERT_PRED2(pred, v1, v2)\n//   ...\n//\n// where pred is an n-ary function or functor that returns bool,\n// and the values v1, v2, ..., must support the << operator for\n// streaming to std::ostream.\n//\n// We also define the EXPECT_* variations.\n//\n// For now we only support predicates whose arity is at most 5.\n// Please email googletestframework@googlegroups.com if you need\n// support for higher arities.\n\n// GTEST_ASSERT_ is the basic statement to which all of the assertions\n// in this file reduce.  Don't use this in your code.\n\n#define GTEST_ASSERT_(expression, on_failure) \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n  if (const ::testing::AssertionResult gtest_ar = (expression)) \\\n    ; \\\n  else \\\n    on_failure(gtest_ar.failure_message())\n\n\n// Helper function for implementing {EXPECT|ASSERT}_PRED1.  Don't use\n// this in your code.\ntemplate <typename Pred,\n          typename T1>\nAssertionResult AssertPred1Helper(const char* pred_text,\n                                  const char* e1,\n                                  Pred pred,\n                                  const T1& v1) {\n  if (pred(v1)) return AssertionSuccess();\n\n  return AssertionFailure() << pred_text << \"(\"\n                            << e1 << \") evaluates to false, where\"\n                            << \"\\n\" << e1 << \" evaluates to \" << v1;\n}\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT1.\n// Don't use this in your code.\n#define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure)\\\n  GTEST_ASSERT_(pred_format(#v1, v1), \\\n                on_failure)\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED1.  Don't use\n// this in your code.\n#define GTEST_PRED1_(pred, v1, on_failure)\\\n  GTEST_ASSERT_(::testing::AssertPred1Helper(#pred, \\\n                                             #v1, \\\n                                             pred, \\\n                                             v1), on_failure)\n\n// Unary predicate assertion macros.\n#define EXPECT_PRED_FORMAT1(pred_format, v1) \\\n  GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_PRED1(pred, v1) \\\n  GTEST_PRED1_(pred, v1, GTEST_NONFATAL_FAILURE_)\n#define ASSERT_PRED_FORMAT1(pred_format, v1) \\\n  GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_FATAL_FAILURE_)\n#define ASSERT_PRED1(pred, v1) \\\n  GTEST_PRED1_(pred, v1, GTEST_FATAL_FAILURE_)\n\n\n\n// Helper function for implementing {EXPECT|ASSERT}_PRED2.  Don't use\n// this in your code.\ntemplate <typename Pred,\n          typename T1,\n          typename T2>\nAssertionResult AssertPred2Helper(const char* pred_text,\n                                  const char* e1,\n                                  const char* e2,\n                                  Pred pred,\n                                  const T1& v1,\n                                  const T2& v2) {\n  if (pred(v1, v2)) return AssertionSuccess();\n\n  return AssertionFailure() << pred_text << \"(\"\n                            << e1 << \", \"\n                            << e2 << \") evaluates to false, where\"\n                            << \"\\n\" << e1 << \" evaluates to \" << v1\n                            << \"\\n\" << e2 << \" evaluates to \" << v2;\n}\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2.\n// Don't use this in your code.\n#define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)\\\n  GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), \\\n                on_failure)\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED2.  Don't use\n// this in your code.\n#define GTEST_PRED2_(pred, v1, v2, on_failure)\\\n  GTEST_ASSERT_(::testing::AssertPred2Helper(#pred, \\\n                                             #v1, \\\n                                             #v2, \\\n                                             pred, \\\n                                             v1, \\\n                                             v2), on_failure)\n\n// Binary predicate assertion macros.\n#define EXPECT_PRED_FORMAT2(pred_format, v1, v2) \\\n  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_PRED2(pred, v1, v2) \\\n  GTEST_PRED2_(pred, v1, v2, GTEST_NONFATAL_FAILURE_)\n#define ASSERT_PRED_FORMAT2(pred_format, v1, v2) \\\n  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)\n#define ASSERT_PRED2(pred, v1, v2) \\\n  GTEST_PRED2_(pred, v1, v2, GTEST_FATAL_FAILURE_)\n\n\n\n// Helper function for implementing {EXPECT|ASSERT}_PRED3.  Don't use\n// this in your code.\ntemplate <typename Pred,\n          typename T1,\n          typename T2,\n          typename T3>\nAssertionResult AssertPred3Helper(const char* pred_text,\n                                  const char* e1,\n                                  const char* e2,\n                                  const char* e3,\n                                  Pred pred,\n                                  const T1& v1,\n                                  const T2& v2,\n                                  const T3& v3) {\n  if (pred(v1, v2, v3)) return AssertionSuccess();\n\n  return AssertionFailure() << pred_text << \"(\"\n                            << e1 << \", \"\n                            << e2 << \", \"\n                            << e3 << \") evaluates to false, where\"\n                            << \"\\n\" << e1 << \" evaluates to \" << v1\n                            << \"\\n\" << e2 << \" evaluates to \" << v2\n                            << \"\\n\" << e3 << \" evaluates to \" << v3;\n}\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT3.\n// Don't use this in your code.\n#define GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, on_failure)\\\n  GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3), \\\n                on_failure)\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED3.  Don't use\n// this in your code.\n#define GTEST_PRED3_(pred, v1, v2, v3, on_failure)\\\n  GTEST_ASSERT_(::testing::AssertPred3Helper(#pred, \\\n                                             #v1, \\\n                                             #v2, \\\n                                             #v3, \\\n                                             pred, \\\n                                             v1, \\\n                                             v2, \\\n                                             v3), on_failure)\n\n// Ternary predicate assertion macros.\n#define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3) \\\n  GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_PRED3(pred, v1, v2, v3) \\\n  GTEST_PRED3_(pred, v1, v2, v3, GTEST_NONFATAL_FAILURE_)\n#define ASSERT_PRED_FORMAT3(pred_format, v1, v2, v3) \\\n  GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_FATAL_FAILURE_)\n#define ASSERT_PRED3(pred, v1, v2, v3) \\\n  GTEST_PRED3_(pred, v1, v2, v3, GTEST_FATAL_FAILURE_)\n\n\n\n// Helper function for implementing {EXPECT|ASSERT}_PRED4.  Don't use\n// this in your code.\ntemplate <typename Pred,\n          typename T1,\n          typename T2,\n          typename T3,\n          typename T4>\nAssertionResult AssertPred4Helper(const char* pred_text,\n                                  const char* e1,\n                                  const char* e2,\n                                  const char* e3,\n                                  const char* e4,\n                                  Pred pred,\n                                  const T1& v1,\n                                  const T2& v2,\n                                  const T3& v3,\n                                  const T4& v4) {\n  if (pred(v1, v2, v3, v4)) return AssertionSuccess();\n\n  return AssertionFailure() << pred_text << \"(\"\n                            << e1 << \", \"\n                            << e2 << \", \"\n                            << e3 << \", \"\n                            << e4 << \") evaluates to false, where\"\n                            << \"\\n\" << e1 << \" evaluates to \" << v1\n                            << \"\\n\" << e2 << \" evaluates to \" << v2\n                            << \"\\n\" << e3 << \" evaluates to \" << v3\n                            << \"\\n\" << e4 << \" evaluates to \" << v4;\n}\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT4.\n// Don't use this in your code.\n#define GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, on_failure)\\\n  GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4), \\\n                on_failure)\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED4.  Don't use\n// this in your code.\n#define GTEST_PRED4_(pred, v1, v2, v3, v4, on_failure)\\\n  GTEST_ASSERT_(::testing::AssertPred4Helper(#pred, \\\n                                             #v1, \\\n                                             #v2, \\\n                                             #v3, \\\n                                             #v4, \\\n                                             pred, \\\n                                             v1, \\\n                                             v2, \\\n                                             v3, \\\n                                             v4), on_failure)\n\n// 4-ary predicate assertion macros.\n#define EXPECT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \\\n  GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_PRED4(pred, v1, v2, v3, v4) \\\n  GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_)\n#define ASSERT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \\\n  GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)\n#define ASSERT_PRED4(pred, v1, v2, v3, v4) \\\n  GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_FATAL_FAILURE_)\n\n\n\n// Helper function for implementing {EXPECT|ASSERT}_PRED5.  Don't use\n// this in your code.\ntemplate <typename Pred,\n          typename T1,\n          typename T2,\n          typename T3,\n          typename T4,\n          typename T5>\nAssertionResult AssertPred5Helper(const char* pred_text,\n                                  const char* e1,\n                                  const char* e2,\n                                  const char* e3,\n                                  const char* e4,\n                                  const char* e5,\n                                  Pred pred,\n                                  const T1& v1,\n                                  const T2& v2,\n                                  const T3& v3,\n                                  const T4& v4,\n                                  const T5& v5) {\n  if (pred(v1, v2, v3, v4, v5)) return AssertionSuccess();\n\n  return AssertionFailure() << pred_text << \"(\"\n                            << e1 << \", \"\n                            << e2 << \", \"\n                            << e3 << \", \"\n                            << e4 << \", \"\n                            << e5 << \") evaluates to false, where\"\n                            << \"\\n\" << e1 << \" evaluates to \" << v1\n                            << \"\\n\" << e2 << \" evaluates to \" << v2\n                            << \"\\n\" << e3 << \" evaluates to \" << v3\n                            << \"\\n\" << e4 << \" evaluates to \" << v4\n                            << \"\\n\" << e5 << \" evaluates to \" << v5;\n}\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT5.\n// Don't use this in your code.\n#define GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, on_failure)\\\n  GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, #v5, v1, v2, v3, v4, v5), \\\n                on_failure)\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED5.  Don't use\n// this in your code.\n#define GTEST_PRED5_(pred, v1, v2, v3, v4, v5, on_failure)\\\n  GTEST_ASSERT_(::testing::AssertPred5Helper(#pred, \\\n                                             #v1, \\\n                                             #v2, \\\n                                             #v3, \\\n                                             #v4, \\\n                                             #v5, \\\n                                             pred, \\\n                                             v1, \\\n                                             v2, \\\n                                             v3, \\\n                                             v4, \\\n                                             v5), on_failure)\n\n// 5-ary predicate assertion macros.\n#define EXPECT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \\\n  GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_PRED5(pred, v1, v2, v3, v4, v5) \\\n  GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_)\n#define ASSERT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \\\n  GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)\n#define ASSERT_PRED5(pred, v1, v2, v3, v4, v5) \\\n  GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_)\n\n\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/gtest_prod.h",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// Google C++ Testing Framework definitions useful in production code.\n\n#ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_\n#define GTEST_INCLUDE_GTEST_GTEST_PROD_H_\n\n// When you need to test the private or protected members of a class,\n// use the FRIEND_TEST macro to declare your tests as friends of the\n// class.  For example:\n//\n// class MyClass {\n//  private:\n//   void MyMethod();\n//   FRIEND_TEST(MyClassTest, MyMethod);\n// };\n//\n// class MyClassTest : public testing::Test {\n//   // ...\n// };\n//\n// TEST_F(MyClassTest, MyMethod) {\n//   // Can call MyClass::MyMethod() here.\n// }\n\n#define FRIEND_TEST(test_case_name, test_name)\\\nfriend class test_case_name##_##test_name##_Test\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_PROD_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/internal/gtest-death-test-internal.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)\n//\n// The Google C++ Testing Framework (Google Test)\n//\n// This header file defines internal utilities needed for implementing\n// death tests.  They are subject to change without notice.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_\n\n#include \"gtest/internal/gtest-internal.h\"\n\n#include <stdio.h>\n\nnamespace testing {\nnamespace internal {\n\nGTEST_DECLARE_string_(internal_run_death_test);\n\n// Names of the flags (needed for parsing Google Test flags).\nconst char kDeathTestStyleFlag[] = \"death_test_style\";\nconst char kDeathTestUseFork[] = \"death_test_use_fork\";\nconst char kInternalRunDeathTestFlag[] = \"internal_run_death_test\";\n\n#if GTEST_HAS_DEATH_TEST\n\n// DeathTest is a class that hides much of the complexity of the\n// GTEST_DEATH_TEST_ macro.  It is abstract; its static Create method\n// returns a concrete class that depends on the prevailing death test\n// style, as defined by the --gtest_death_test_style and/or\n// --gtest_internal_run_death_test flags.\n\n// In describing the results of death tests, these terms are used with\n// the corresponding definitions:\n//\n// exit status:  The integer exit information in the format specified\n//               by wait(2)\n// exit code:    The integer code passed to exit(3), _exit(2), or\n//               returned from main()\nclass GTEST_API_ DeathTest {\n public:\n  // Create returns false if there was an error determining the\n  // appropriate action to take for the current death test; for example,\n  // if the gtest_death_test_style flag is set to an invalid value.\n  // The LastMessage method will return a more detailed message in that\n  // case.  Otherwise, the DeathTest pointer pointed to by the \"test\"\n  // argument is set.  If the death test should be skipped, the pointer\n  // is set to NULL; otherwise, it is set to the address of a new concrete\n  // DeathTest object that controls the execution of the current test.\n  static bool Create(const char* statement, const RE* regex,\n                     const char* file, int line, DeathTest** test);\n  DeathTest();\n  virtual ~DeathTest() { }\n\n  // A helper class that aborts a death test when it's deleted.\n  class ReturnSentinel {\n   public:\n    explicit ReturnSentinel(DeathTest* test) : test_(test) { }\n    ~ReturnSentinel() { test_->Abort(TEST_ENCOUNTERED_RETURN_STATEMENT); }\n   private:\n    DeathTest* const test_;\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(ReturnSentinel);\n  } GTEST_ATTRIBUTE_UNUSED_;\n\n  // An enumeration of possible roles that may be taken when a death\n  // test is encountered.  EXECUTE means that the death test logic should\n  // be executed immediately.  OVERSEE means that the program should prepare\n  // the appropriate environment for a child process to execute the death\n  // test, then wait for it to complete.\n  enum TestRole { OVERSEE_TEST, EXECUTE_TEST };\n\n  // An enumeration of the three reasons that a test might be aborted.\n  enum AbortReason {\n    TEST_ENCOUNTERED_RETURN_STATEMENT,\n    TEST_THREW_EXCEPTION,\n    TEST_DID_NOT_DIE\n  };\n\n  // Assumes one of the above roles.\n  virtual TestRole AssumeRole() = 0;\n\n  // Waits for the death test to finish and returns its status.\n  virtual int Wait() = 0;\n\n  // Returns true if the death test passed; that is, the test process\n  // exited during the test, its exit status matches a user-supplied\n  // predicate, and its stderr output matches a user-supplied regular\n  // expression.\n  // The user-supplied predicate may be a macro expression rather\n  // than a function pointer or functor, or else Wait and Passed could\n  // be combined.\n  virtual bool Passed(bool exit_status_ok) = 0;\n\n  // Signals that the death test did not die as expected.\n  virtual void Abort(AbortReason reason) = 0;\n\n  // Returns a human-readable outcome message regarding the outcome of\n  // the last death test.\n  static const char* LastMessage();\n\n  static void set_last_death_test_message(const std::string& message);\n\n private:\n  // A string containing a description of the outcome of the last death test.\n  static std::string last_death_test_message_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(DeathTest);\n};\n\n// Factory interface for death tests.  May be mocked out for testing.\nclass DeathTestFactory {\n public:\n  virtual ~DeathTestFactory() { }\n  virtual bool Create(const char* statement, const RE* regex,\n                      const char* file, int line, DeathTest** test) = 0;\n};\n\n// A concrete DeathTestFactory implementation for normal use.\nclass DefaultDeathTestFactory : public DeathTestFactory {\n public:\n  virtual bool Create(const char* statement, const RE* regex,\n                      const char* file, int line, DeathTest** test);\n};\n\n// Returns true if exit_status describes a process that was terminated\n// by a signal, or exited normally with a nonzero exit code.\nGTEST_API_ bool ExitedUnsuccessfully(int exit_status);\n\n// Traps C++ exceptions escaping statement and reports them as test\n// failures. Note that trapping SEH exceptions is not implemented here.\n# if GTEST_HAS_EXCEPTIONS\n#  define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \\\n  try { \\\n    GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \\\n  } catch (const ::std::exception& gtest_exception) { \\\n    fprintf(\\\n        stderr, \\\n        \"\\n%s: Caught std::exception-derived exception escaping the \" \\\n        \"death test statement. Exception message: %s\\n\", \\\n        ::testing::internal::FormatFileLocation(__FILE__, __LINE__).c_str(), \\\n        gtest_exception.what()); \\\n    fflush(stderr); \\\n    death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \\\n  } catch (...) { \\\n    death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \\\n  }\n\n# else\n#  define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \\\n  GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement)\n\n# endif\n\n// This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*,\n// ASSERT_EXIT*, and EXPECT_EXIT*.\n# define GTEST_DEATH_TEST_(statement, predicate, regex, fail) \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n  if (::testing::internal::AlwaysTrue()) { \\\n    const ::testing::internal::RE& gtest_regex = (regex); \\\n    ::testing::internal::DeathTest* gtest_dt; \\\n    if (!::testing::internal::DeathTest::Create(#statement, &gtest_regex, \\\n        __FILE__, __LINE__, &gtest_dt)) { \\\n      goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \\\n    } \\\n    if (gtest_dt != NULL) { \\\n      ::testing::internal::scoped_ptr< ::testing::internal::DeathTest> \\\n          gtest_dt_ptr(gtest_dt); \\\n      switch (gtest_dt->AssumeRole()) { \\\n        case ::testing::internal::DeathTest::OVERSEE_TEST: \\\n          if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) { \\\n            goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \\\n          } \\\n          break; \\\n        case ::testing::internal::DeathTest::EXECUTE_TEST: { \\\n          ::testing::internal::DeathTest::ReturnSentinel \\\n              gtest_sentinel(gtest_dt); \\\n          GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, gtest_dt); \\\n          gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \\\n          break; \\\n        } \\\n        default: \\\n          break; \\\n      } \\\n    } \\\n  } else \\\n    GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__): \\\n      fail(::testing::internal::DeathTest::LastMessage())\n// The symbol \"fail\" here expands to something into which a message\n// can be streamed.\n\n// This macro is for implementing ASSERT/EXPECT_DEBUG_DEATH when compiled in\n// NDEBUG mode. In this case we need the statements to be executed, the regex is\n// ignored, and the macro must accept a streamed message even though the message\n// is never printed.\n# define GTEST_EXECUTE_STATEMENT_(statement, regex) \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n  if (::testing::internal::AlwaysTrue()) { \\\n     GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \\\n  } else \\\n    ::testing::Message()\n\n// A class representing the parsed contents of the\n// --gtest_internal_run_death_test flag, as it existed when\n// RUN_ALL_TESTS was called.\nclass InternalRunDeathTestFlag {\n public:\n  InternalRunDeathTestFlag(const std::string& a_file,\n                           int a_line,\n                           int an_index,\n                           int a_write_fd)\n      : file_(a_file), line_(a_line), index_(an_index),\n        write_fd_(a_write_fd) {}\n\n  ~InternalRunDeathTestFlag() {\n    if (write_fd_ >= 0)\n      posix::Close(write_fd_);\n  }\n\n  const std::string& file() const { return file_; }\n  int line() const { return line_; }\n  int index() const { return index_; }\n  int write_fd() const { return write_fd_; }\n\n private:\n  std::string file_;\n  int line_;\n  int index_;\n  int write_fd_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(InternalRunDeathTestFlag);\n};\n\n// Returns a newly created InternalRunDeathTestFlag object with fields\n// initialized from the GTEST_FLAG(internal_run_death_test) flag if\n// the flag is specified; otherwise returns NULL.\nInternalRunDeathTestFlag* ParseInternalRunDeathTestFlag();\n\n#else  // GTEST_HAS_DEATH_TEST\n\n// This macro is used for implementing macros such as\n// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where\n// death tests are not supported. Those macros must compile on such systems\n// iff EXPECT_DEATH and ASSERT_DEATH compile with the same parameters on\n// systems that support death tests. This allows one to write such a macro\n// on a system that does not support death tests and be sure that it will\n// compile on a death-test supporting system.\n//\n// Parameters:\n//   statement -  A statement that a macro such as EXPECT_DEATH would test\n//                for program termination. This macro has to make sure this\n//                statement is compiled but not executed, to ensure that\n//                EXPECT_DEATH_IF_SUPPORTED compiles with a certain\n//                parameter iff EXPECT_DEATH compiles with it.\n//   regex     -  A regex that a macro such as EXPECT_DEATH would use to test\n//                the output of statement.  This parameter has to be\n//                compiled but not evaluated by this macro, to ensure that\n//                this macro only accepts expressions that a macro such as\n//                EXPECT_DEATH would accept.\n//   terminator - Must be an empty statement for EXPECT_DEATH_IF_SUPPORTED\n//                and a return statement for ASSERT_DEATH_IF_SUPPORTED.\n//                This ensures that ASSERT_DEATH_IF_SUPPORTED will not\n//                compile inside functions where ASSERT_DEATH doesn't\n//                compile.\n//\n//  The branch that has an always false condition is used to ensure that\n//  statement and regex are compiled (and thus syntactically correct) but\n//  never executed. The unreachable code macro protects the terminator\n//  statement from generating an 'unreachable code' warning in case\n//  statement unconditionally returns or throws. The Message constructor at\n//  the end allows the syntax of streaming additional messages into the\n//  macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH.\n# define GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, terminator) \\\n    GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n    if (::testing::internal::AlwaysTrue()) { \\\n      GTEST_LOG_(WARNING) \\\n          << \"Death tests are not supported on this platform.\\n\" \\\n          << \"Statement '\" #statement \"' cannot be verified.\"; \\\n    } else if (::testing::internal::AlwaysFalse()) { \\\n      ::testing::internal::RE::PartialMatch(\".*\", (regex)); \\\n      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \\\n      terminator; \\\n    } else \\\n      ::testing::Message()\n\n#endif  // GTEST_HAS_DEATH_TEST\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/internal/gtest-filepath.h",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: keith.ray@gmail.com (Keith Ray)\n//\n// Google Test filepath utilities\n//\n// This header file declares classes and functions used internally by\n// Google Test.  They are subject to change without notice.\n//\n// This file is #included in <gtest/internal/gtest-internal.h>.\n// Do not include this header file separately!\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_\n\n#include \"gtest/internal/gtest-string.h\"\n\nnamespace testing {\nnamespace internal {\n\n// FilePath - a class for file and directory pathname manipulation which\n// handles platform-specific conventions (like the pathname separator).\n// Used for helper functions for naming files in a directory for xml output.\n// Except for Set methods, all methods are const or static, which provides an\n// \"immutable value object\" -- useful for peace of mind.\n// A FilePath with a value ending in a path separator (\"like/this/\") represents\n// a directory, otherwise it is assumed to represent a file. In either case,\n// it may or may not represent an actual file or directory in the file system.\n// Names are NOT checked for syntax correctness -- no checking for illegal\n// characters, malformed paths, etc.\n\nclass GTEST_API_ FilePath {\n public:\n  FilePath() : pathname_(\"\") { }\n  FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) { }\n\n  explicit FilePath(const std::string& pathname) : pathname_(pathname) {\n    Normalize();\n  }\n\n  FilePath& operator=(const FilePath& rhs) {\n    Set(rhs);\n    return *this;\n  }\n\n  void Set(const FilePath& rhs) {\n    pathname_ = rhs.pathname_;\n  }\n\n  const std::string& string() const { return pathname_; }\n  const char* c_str() const { return pathname_.c_str(); }\n\n  // Returns the current working directory, or \"\" if unsuccessful.\n  static FilePath GetCurrentDir();\n\n  // Given directory = \"dir\", base_name = \"test\", number = 0,\n  // extension = \"xml\", returns \"dir/test.xml\". If number is greater\n  // than zero (e.g., 12), returns \"dir/test_12.xml\".\n  // On Windows platform, uses \\ as the separator rather than /.\n  static FilePath MakeFileName(const FilePath& directory,\n                               const FilePath& base_name,\n                               int number,\n                               const char* extension);\n\n  // Given directory = \"dir\", relative_path = \"test.xml\",\n  // returns \"dir/test.xml\".\n  // On Windows, uses \\ as the separator rather than /.\n  static FilePath ConcatPaths(const FilePath& directory,\n                              const FilePath& relative_path);\n\n  // Returns a pathname for a file that does not currently exist. The pathname\n  // will be directory/base_name.extension or\n  // directory/base_name_<number>.extension if directory/base_name.extension\n  // already exists. The number will be incremented until a pathname is found\n  // that does not already exist.\n  // Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.\n  // There could be a race condition if two or more processes are calling this\n  // function at the same time -- they could both pick the same filename.\n  static FilePath GenerateUniqueFileName(const FilePath& directory,\n                                         const FilePath& base_name,\n                                         const char* extension);\n\n  // Returns true iff the path is \"\".\n  bool IsEmpty() const { return pathname_.empty(); }\n\n  // If input name has a trailing separator character, removes it and returns\n  // the name, otherwise return the name string unmodified.\n  // On Windows platform, uses \\ as the separator, other platforms use /.\n  FilePath RemoveTrailingPathSeparator() const;\n\n  // Returns a copy of the FilePath with the directory part removed.\n  // Example: FilePath(\"path/to/file\").RemoveDirectoryName() returns\n  // FilePath(\"file\"). If there is no directory part (\"just_a_file\"), it returns\n  // the FilePath unmodified. If there is no file part (\"just_a_dir/\") it\n  // returns an empty FilePath (\"\").\n  // On Windows platform, '\\' is the path separator, otherwise it is '/'.\n  FilePath RemoveDirectoryName() const;\n\n  // RemoveFileName returns the directory path with the filename removed.\n  // Example: FilePath(\"path/to/file\").RemoveFileName() returns \"path/to/\".\n  // If the FilePath is \"a_file\" or \"/a_file\", RemoveFileName returns\n  // FilePath(\"./\") or, on Windows, FilePath(\".\\\\\"). If the filepath does\n  // not have a file, like \"just/a/dir/\", it returns the FilePath unmodified.\n  // On Windows platform, '\\' is the path separator, otherwise it is '/'.\n  FilePath RemoveFileName() const;\n\n  // Returns a copy of the FilePath with the case-insensitive extension removed.\n  // Example: FilePath(\"dir/file.exe\").RemoveExtension(\"EXE\") returns\n  // FilePath(\"dir/file\"). If a case-insensitive extension is not\n  // found, returns a copy of the original FilePath.\n  FilePath RemoveExtension(const char* extension) const;\n\n  // Creates directories so that path exists. Returns true if successful or if\n  // the directories already exist; returns false if unable to create\n  // directories for any reason. Will also return false if the FilePath does\n  // not represent a directory (that is, it doesn't end with a path separator).\n  bool CreateDirectoriesRecursively() const;\n\n  // Create the directory so that path exists. Returns true if successful or\n  // if the directory already exists; returns false if unable to create the\n  // directory for any reason, including if the parent directory does not\n  // exist. Not named \"CreateDirectory\" because that's a macro on Windows.\n  bool CreateFolder() const;\n\n  // Returns true if FilePath describes something in the file-system,\n  // either a file, directory, or whatever, and that something exists.\n  bool FileOrDirectoryExists() const;\n\n  // Returns true if pathname describes a directory in the file-system\n  // that exists.\n  bool DirectoryExists() const;\n\n  // Returns true if FilePath ends with a path separator, which indicates that\n  // it is intended to represent a directory. Returns false otherwise.\n  // This does NOT check that a directory (or file) actually exists.\n  bool IsDirectory() const;\n\n  // Returns true if pathname describes a root directory. (Windows has one\n  // root directory per disk drive.)\n  bool IsRootDirectory() const;\n\n  // Returns true if pathname describes an absolute path.\n  bool IsAbsolutePath() const;\n\n private:\n  // Replaces multiple consecutive separators with a single separator.\n  // For example, \"bar///foo\" becomes \"bar/foo\". Does not eliminate other\n  // redundancies that might be in a pathname involving \".\" or \"..\".\n  //\n  // A pathname with multiple consecutive separators may occur either through\n  // user error or as a result of some scripts or APIs that generate a pathname\n  // with a trailing separator. On other platforms the same API or script\n  // may NOT generate a pathname with a trailing \"/\". Then elsewhere that\n  // pathname may have another \"/\" and pathname components added to it,\n  // without checking for the separator already being there.\n  // The script language and operating system may allow paths like \"foo//bar\"\n  // but some of the functions in FilePath will not handle that correctly. In\n  // particular, RemoveTrailingPathSeparator() only removes one separator, and\n  // it is called in CreateDirectoriesRecursively() assuming that it will change\n  // a pathname from directory syntax (trailing separator) to filename syntax.\n  //\n  // On Windows this method also replaces the alternate path separator '/' with\n  // the primary path separator '\\\\', so that for example \"bar\\\\/\\\\foo\" becomes\n  // \"bar\\\\foo\".\n\n  void Normalize();\n\n  // Returns a pointer to the last occurence of a valid path separator in\n  // the FilePath. On Windows, for example, both '/' and '\\' are valid path\n  // separators. Returns NULL if no path separator was found.\n  const char* FindLastPathSeparator() const;\n\n  std::string pathname_;\n};  // class FilePath\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/internal/gtest-internal.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)\n//\n// The Google C++ Testing Framework (Google Test)\n//\n// This header file declares functions and macros used internally by\n// Google Test.  They are subject to change without notice.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_\n\n#include \"gtest/internal/gtest-port.h\"\n\n#if GTEST_OS_LINUX\n# include <stdlib.h>\n# include <sys/types.h>\n# include <sys/wait.h>\n# include <unistd.h>\n#endif  // GTEST_OS_LINUX\n\n#if GTEST_HAS_EXCEPTIONS\n# include <stdexcept>\n#endif\n\n#include <ctype.h>\n#include <float.h>\n#include <string.h>\n#include <iomanip>\n#include <limits>\n#include <set>\n\n#include \"gtest/gtest-message.h\"\n#include \"gtest/internal/gtest-string.h\"\n#include \"gtest/internal/gtest-filepath.h\"\n#include \"gtest/internal/gtest-type-util.h\"\n\n// Due to C++ preprocessor weirdness, we need double indirection to\n// concatenate two tokens when one of them is __LINE__.  Writing\n//\n//   foo ## __LINE__\n//\n// will result in the token foo__LINE__, instead of foo followed by\n// the current line number.  For more details, see\n// http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.6\n#define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar)\n#define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar\n\nclass ProtocolMessage;\nnamespace proto2 { class Message; }\n\nnamespace testing {\n\n// Forward declarations.\n\nclass AssertionResult;                 // Result of an assertion.\nclass Message;                         // Represents a failure message.\nclass Test;                            // Represents a test.\nclass TestInfo;                        // Information about a test.\nclass TestPartResult;                  // Result of a test part.\nclass UnitTest;                        // A collection of test cases.\n\ntemplate <typename T>\n::std::string PrintToString(const T& value);\n\nnamespace internal {\n\nstruct TraceInfo;                      // Information about a trace point.\nclass ScopedTrace;                     // Implements scoped trace.\nclass TestInfoImpl;                    // Opaque implementation of TestInfo\nclass UnitTestImpl;                    // Opaque implementation of UnitTest\n\n// How many times InitGoogleTest() has been called.\nGTEST_API_ extern int g_init_gtest_count;\n\n// The text used in failure messages to indicate the start of the\n// stack trace.\nGTEST_API_ extern const char kStackTraceMarker[];\n\n// Two overloaded helpers for checking at compile time whether an\n// expression is a null pointer literal (i.e. NULL or any 0-valued\n// compile-time integral constant).  Their return values have\n// different sizes, so we can use sizeof() to test which version is\n// picked by the compiler.  These helpers have no implementations, as\n// we only need their signatures.\n//\n// Given IsNullLiteralHelper(x), the compiler will pick the first\n// version if x can be implicitly converted to Secret*, and pick the\n// second version otherwise.  Since Secret is a secret and incomplete\n// type, the only expression a user can write that has type Secret* is\n// a null pointer literal.  Therefore, we know that x is a null\n// pointer literal if and only if the first version is picked by the\n// compiler.\nchar IsNullLiteralHelper(Secret* p);\nchar (&IsNullLiteralHelper(...))[2];  // NOLINT\n\n// A compile-time bool constant that is true if and only if x is a\n// null pointer literal (i.e. NULL or any 0-valued compile-time\n// integral constant).\n#ifdef GTEST_ELLIPSIS_NEEDS_POD_\n// We lose support for NULL detection where the compiler doesn't like\n// passing non-POD classes through ellipsis (...).\n# define GTEST_IS_NULL_LITERAL_(x) false\n#else\n# define GTEST_IS_NULL_LITERAL_(x) \\\n    (sizeof(::testing::internal::IsNullLiteralHelper(x)) == 1)\n#endif  // GTEST_ELLIPSIS_NEEDS_POD_\n\n// Appends the user-supplied message to the Google-Test-generated message.\nGTEST_API_ std::string AppendUserMessage(\n    const std::string& gtest_msg, const Message& user_msg);\n\n#if GTEST_HAS_EXCEPTIONS\n\n// This exception is thrown by (and only by) a failed Google Test\n// assertion when GTEST_FLAG(throw_on_failure) is true (if exceptions\n// are enabled).  We derive it from std::runtime_error, which is for\n// errors presumably detectable only at run time.  Since\n// std::runtime_error inherits from std::exception, many testing\n// frameworks know how to extract and print the message inside it.\nclass GTEST_API_ GoogleTestFailureException : public ::std::runtime_error {\n public:\n  explicit GoogleTestFailureException(const TestPartResult& failure);\n};\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n// A helper class for creating scoped traces in user programs.\nclass GTEST_API_ ScopedTrace {\n public:\n  // The c'tor pushes the given source file location and message onto\n  // a trace stack maintained by Google Test.\n  ScopedTrace(const char* file, int line, const Message& message);\n\n  // The d'tor pops the info pushed by the c'tor.\n  //\n  // Note that the d'tor is not virtual in order to be efficient.\n  // Don't inherit from ScopedTrace!\n  ~ScopedTrace();\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace);\n} GTEST_ATTRIBUTE_UNUSED_;  // A ScopedTrace object does its job in its\n                            // c'tor and d'tor.  Therefore it doesn't\n                            // need to be used otherwise.\n\n// Constructs and returns the message for an equality assertion\n// (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure.\n//\n// The first four parameters are the expressions used in the assertion\n// and their values, as strings.  For example, for ASSERT_EQ(foo, bar)\n// where foo is 5 and bar is 6, we have:\n//\n//   expected_expression: \"foo\"\n//   actual_expression:   \"bar\"\n//   expected_value:      \"5\"\n//   actual_value:        \"6\"\n//\n// The ignoring_case parameter is true iff the assertion is a\n// *_STRCASEEQ*.  When it's true, the string \" (ignoring case)\" will\n// be inserted into the message.\nGTEST_API_ AssertionResult EqFailure(const char* expected_expression,\n                                     const char* actual_expression,\n                                     const std::string& expected_value,\n                                     const std::string& actual_value,\n                                     bool ignoring_case);\n\n// Constructs a failure message for Boolean assertions such as EXPECT_TRUE.\nGTEST_API_ std::string GetBoolAssertionFailureMessage(\n    const AssertionResult& assertion_result,\n    const char* expression_text,\n    const char* actual_predicate_value,\n    const char* expected_predicate_value);\n\n// This template class represents an IEEE floating-point number\n// (either single-precision or double-precision, depending on the\n// template parameters).\n//\n// The purpose of this class is to do more sophisticated number\n// comparison.  (Due to round-off error, etc, it's very unlikely that\n// two floating-points will be equal exactly.  Hence a naive\n// comparison by the == operation often doesn't work.)\n//\n// Format of IEEE floating-point:\n//\n//   The most-significant bit being the leftmost, an IEEE\n//   floating-point looks like\n//\n//     sign_bit exponent_bits fraction_bits\n//\n//   Here, sign_bit is a single bit that designates the sign of the\n//   number.\n//\n//   For float, there are 8 exponent bits and 23 fraction bits.\n//\n//   For double, there are 11 exponent bits and 52 fraction bits.\n//\n//   More details can be found at\n//   http://en.wikipedia.org/wiki/IEEE_floating-point_standard.\n//\n// Template parameter:\n//\n//   RawType: the raw floating-point type (either float or double)\ntemplate <typename RawType>\nclass FloatingPoint {\n public:\n  // Defines the unsigned integer type that has the same size as the\n  // floating point number.\n  typedef typename TypeWithSize<sizeof(RawType)>::UInt Bits;\n\n  // Constants.\n\n  // # of bits in a number.\n  static const size_t kBitCount = 8*sizeof(RawType);\n\n  // # of fraction bits in a number.\n  static const size_t kFractionBitCount =\n    std::numeric_limits<RawType>::digits - 1;\n\n  // # of exponent bits in a number.\n  static const size_t kExponentBitCount = kBitCount - 1 - kFractionBitCount;\n\n  // The mask for the sign bit.\n  static const Bits kSignBitMask = static_cast<Bits>(1) << (kBitCount - 1);\n\n  // The mask for the fraction bits.\n  static const Bits kFractionBitMask =\n    ~static_cast<Bits>(0) >> (kExponentBitCount + 1);\n\n  // The mask for the exponent bits.\n  static const Bits kExponentBitMask = ~(kSignBitMask | kFractionBitMask);\n\n  // How many ULP's (Units in the Last Place) we want to tolerate when\n  // comparing two numbers.  The larger the value, the more error we\n  // allow.  A 0 value means that two numbers must be exactly the same\n  // to be considered equal.\n  //\n  // The maximum error of a single floating-point operation is 0.5\n  // units in the last place.  On Intel CPU's, all floating-point\n  // calculations are done with 80-bit precision, while double has 64\n  // bits.  Therefore, 4 should be enough for ordinary use.\n  //\n  // See the following article for more details on ULP:\n  // http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/\n  static const size_t kMaxUlps = 4;\n\n  // Constructs a FloatingPoint from a raw floating-point number.\n  //\n  // On an Intel CPU, passing a non-normalized NAN (Not a Number)\n  // around may change its bits, although the new value is guaranteed\n  // to be also a NAN.  Therefore, don't expect this constructor to\n  // preserve the bits in x when x is a NAN.\n  explicit FloatingPoint(const RawType& x) { u_.value_ = x; }\n\n  // Static methods\n\n  // Reinterprets a bit pattern as a floating-point number.\n  //\n  // This function is needed to test the AlmostEquals() method.\n  static RawType ReinterpretBits(const Bits bits) {\n    FloatingPoint fp(0);\n    fp.u_.bits_ = bits;\n    return fp.u_.value_;\n  }\n\n  // Returns the floating-point number that represent positive infinity.\n  static RawType Infinity() {\n    return ReinterpretBits(kExponentBitMask);\n  }\n\n  // Returns the maximum representable finite floating-point number.\n  static RawType Max();\n\n  // Non-static methods\n\n  // Returns the bits that represents this number.\n  const Bits &bits() const { return u_.bits_; }\n\n  // Returns the exponent bits of this number.\n  Bits exponent_bits() const { return kExponentBitMask & u_.bits_; }\n\n  // Returns the fraction bits of this number.\n  Bits fraction_bits() const { return kFractionBitMask & u_.bits_; }\n\n  // Returns the sign bit of this number.\n  Bits sign_bit() const { return kSignBitMask & u_.bits_; }\n\n  // Returns true iff this is NAN (not a number).\n  bool is_nan() const {\n    // It's a NAN if the exponent bits are all ones and the fraction\n    // bits are not entirely zeros.\n    return (exponent_bits() == kExponentBitMask) && (fraction_bits() != 0);\n  }\n\n  // Returns true iff this number is at most kMaxUlps ULP's away from\n  // rhs.  In particular, this function:\n  //\n  //   - returns false if either number is (or both are) NAN.\n  //   - treats really large numbers as almost equal to infinity.\n  //   - thinks +0.0 and -0.0 are 0 DLP's apart.\n  bool AlmostEquals(const FloatingPoint& rhs) const {\n    // The IEEE standard says that any comparison operation involving\n    // a NAN must return false.\n    if (is_nan() || rhs.is_nan()) return false;\n\n    return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_)\n        <= kMaxUlps;\n  }\n\n private:\n  // The data type used to store the actual floating-point number.\n  union FloatingPointUnion {\n    RawType value_;  // The raw floating-point number.\n    Bits bits_;      // The bits that represent the number.\n  };\n\n  // Converts an integer from the sign-and-magnitude representation to\n  // the biased representation.  More precisely, let N be 2 to the\n  // power of (kBitCount - 1), an integer x is represented by the\n  // unsigned number x + N.\n  //\n  // For instance,\n  //\n  //   -N + 1 (the most negative number representable using\n  //          sign-and-magnitude) is represented by 1;\n  //   0      is represented by N; and\n  //   N - 1  (the biggest number representable using\n  //          sign-and-magnitude) is represented by 2N - 1.\n  //\n  // Read http://en.wikipedia.org/wiki/Signed_number_representations\n  // for more details on signed number representations.\n  static Bits SignAndMagnitudeToBiased(const Bits &sam) {\n    if (kSignBitMask & sam) {\n      // sam represents a negative number.\n      return ~sam + 1;\n    } else {\n      // sam represents a positive number.\n      return kSignBitMask | sam;\n    }\n  }\n\n  // Given two numbers in the sign-and-magnitude representation,\n  // returns the distance between them as an unsigned number.\n  static Bits DistanceBetweenSignAndMagnitudeNumbers(const Bits &sam1,\n                                                     const Bits &sam2) {\n    const Bits biased1 = SignAndMagnitudeToBiased(sam1);\n    const Bits biased2 = SignAndMagnitudeToBiased(sam2);\n    return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1);\n  }\n\n  FloatingPointUnion u_;\n};\n\n// We cannot use std::numeric_limits<T>::max() as it clashes with the max()\n// macro defined by <windows.h>.\ntemplate <>\ninline float FloatingPoint<float>::Max() { return FLT_MAX; }\ntemplate <>\ninline double FloatingPoint<double>::Max() { return DBL_MAX; }\n\n// Typedefs the instances of the FloatingPoint template class that we\n// care to use.\ntypedef FloatingPoint<float> Float;\ntypedef FloatingPoint<double> Double;\n\n// In order to catch the mistake of putting tests that use different\n// test fixture classes in the same test case, we need to assign\n// unique IDs to fixture classes and compare them.  The TypeId type is\n// used to hold such IDs.  The user should treat TypeId as an opaque\n// type: the only operation allowed on TypeId values is to compare\n// them for equality using the == operator.\ntypedef const void* TypeId;\n\ntemplate <typename T>\nclass TypeIdHelper {\n public:\n  // dummy_ must not have a const type.  Otherwise an overly eager\n  // compiler (e.g. MSVC 7.1 & 8.0) may try to merge\n  // TypeIdHelper<T>::dummy_ for different Ts as an \"optimization\".\n  static bool dummy_;\n};\n\ntemplate <typename T>\nbool TypeIdHelper<T>::dummy_ = false;\n\n// GetTypeId<T>() returns the ID of type T.  Different values will be\n// returned for different types.  Calling the function twice with the\n// same type argument is guaranteed to return the same ID.\ntemplate <typename T>\nTypeId GetTypeId() {\n  // The compiler is required to allocate a different\n  // TypeIdHelper<T>::dummy_ variable for each T used to instantiate\n  // the template.  Therefore, the address of dummy_ is guaranteed to\n  // be unique.\n  return &(TypeIdHelper<T>::dummy_);\n}\n\n// Returns the type ID of ::testing::Test.  Always call this instead\n// of GetTypeId< ::testing::Test>() to get the type ID of\n// ::testing::Test, as the latter may give the wrong result due to a\n// suspected linker bug when compiling Google Test as a Mac OS X\n// framework.\nGTEST_API_ TypeId GetTestTypeId();\n\n// Defines the abstract factory interface that creates instances\n// of a Test object.\nclass TestFactoryBase {\n public:\n  virtual ~TestFactoryBase() {}\n\n  // Creates a test instance to run. The instance is both created and destroyed\n  // within TestInfoImpl::Run()\n  virtual Test* CreateTest() = 0;\n\n protected:\n  TestFactoryBase() {}\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestFactoryBase);\n};\n\n// This class provides implementation of TeastFactoryBase interface.\n// It is used in TEST and TEST_F macros.\ntemplate <class TestClass>\nclass TestFactoryImpl : public TestFactoryBase {\n public:\n  virtual Test* CreateTest() { return new TestClass; }\n};\n\n#if GTEST_OS_WINDOWS\n\n// Predicate-formatters for implementing the HRESULT checking macros\n// {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}\n// We pass a long instead of HRESULT to avoid causing an\n// include dependency for the HRESULT type.\nGTEST_API_ AssertionResult IsHRESULTSuccess(const char* expr,\n                                            long hr);  // NOLINT\nGTEST_API_ AssertionResult IsHRESULTFailure(const char* expr,\n                                            long hr);  // NOLINT\n\n#endif  // GTEST_OS_WINDOWS\n\n// Types of SetUpTestCase() and TearDownTestCase() functions.\ntypedef void (*SetUpTestCaseFunc)();\ntypedef void (*TearDownTestCaseFunc)();\n\n// Creates a new TestInfo object and registers it with Google Test;\n// returns the created object.\n//\n// Arguments:\n//\n//   test_case_name:   name of the test case\n//   name:             name of the test\n//   type_param        the name of the test's type parameter, or NULL if\n//                     this is not a typed or a type-parameterized test.\n//   value_param       text representation of the test's value parameter,\n//                     or NULL if this is not a type-parameterized test.\n//   fixture_class_id: ID of the test fixture class\n//   set_up_tc:        pointer to the function that sets up the test case\n//   tear_down_tc:     pointer to the function that tears down the test case\n//   factory:          pointer to the factory that creates a test object.\n//                     The newly created TestInfo instance will assume\n//                     ownership of the factory object.\nGTEST_API_ TestInfo* MakeAndRegisterTestInfo(\n    const char* test_case_name,\n    const char* name,\n    const char* type_param,\n    const char* value_param,\n    TypeId fixture_class_id,\n    SetUpTestCaseFunc set_up_tc,\n    TearDownTestCaseFunc tear_down_tc,\n    TestFactoryBase* factory);\n\n// If *pstr starts with the given prefix, modifies *pstr to be right\n// past the prefix and returns true; otherwise leaves *pstr unchanged\n// and returns false.  None of pstr, *pstr, and prefix can be NULL.\nGTEST_API_ bool SkipPrefix(const char* prefix, const char** pstr);\n\n#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P\n\n// State of the definition of a type-parameterized test case.\nclass GTEST_API_ TypedTestCasePState {\n public:\n  TypedTestCasePState() : registered_(false) {}\n\n  // Adds the given test name to defined_test_names_ and return true\n  // if the test case hasn't been registered; otherwise aborts the\n  // program.\n  bool AddTestName(const char* file, int line, const char* case_name,\n                   const char* test_name) {\n    if (registered_) {\n      fprintf(stderr, \"%s Test %s must be defined before \"\n              \"REGISTER_TYPED_TEST_CASE_P(%s, ...).\\n\",\n              FormatFileLocation(file, line).c_str(), test_name, case_name);\n      fflush(stderr);\n      posix::Abort();\n    }\n    defined_test_names_.insert(test_name);\n    return true;\n  }\n\n  // Verifies that registered_tests match the test names in\n  // defined_test_names_; returns registered_tests if successful, or\n  // aborts the program otherwise.\n  const char* VerifyRegisteredTestNames(\n      const char* file, int line, const char* registered_tests);\n\n private:\n  bool registered_;\n  ::std::set<const char*> defined_test_names_;\n};\n\n// Skips to the first non-space char after the first comma in 'str';\n// returns NULL if no comma is found in 'str'.\ninline const char* SkipComma(const char* str) {\n  const char* comma = strchr(str, ',');\n  if (comma == NULL) {\n    return NULL;\n  }\n  while (IsSpace(*(++comma))) {}\n  return comma;\n}\n\n// Returns the prefix of 'str' before the first comma in it; returns\n// the entire string if it contains no comma.\ninline std::string GetPrefixUntilComma(const char* str) {\n  const char* comma = strchr(str, ',');\n  return comma == NULL ? str : std::string(str, comma);\n}\n\n// TypeParameterizedTest<Fixture, TestSel, Types>::Register()\n// registers a list of type-parameterized tests with Google Test.  The\n// return value is insignificant - we just need to return something\n// such that we can call this function in a namespace scope.\n//\n// Implementation note: The GTEST_TEMPLATE_ macro declares a template\n// template parameter.  It's defined in gtest-type-util.h.\ntemplate <GTEST_TEMPLATE_ Fixture, class TestSel, typename Types>\nclass TypeParameterizedTest {\n public:\n  // 'index' is the index of the test in the type list 'Types'\n  // specified in INSTANTIATE_TYPED_TEST_CASE_P(Prefix, TestCase,\n  // Types).  Valid values for 'index' are [0, N - 1] where N is the\n  // length of Types.\n  static bool Register(const char* prefix, const char* case_name,\n                       const char* test_names, int index) {\n    typedef typename Types::Head Type;\n    typedef Fixture<Type> FixtureClass;\n    typedef typename GTEST_BIND_(TestSel, Type) TestClass;\n\n    // First, registers the first type-parameterized test in the type\n    // list.\n    MakeAndRegisterTestInfo(\n        (std::string(prefix) + (prefix[0] == '\\0' ? \"\" : \"/\") + case_name + \"/\"\n         + StreamableToString(index)).c_str(),\n        GetPrefixUntilComma(test_names).c_str(),\n        GetTypeName<Type>().c_str(),\n        NULL,  // No value parameter.\n        GetTypeId<FixtureClass>(),\n        TestClass::SetUpTestCase,\n        TestClass::TearDownTestCase,\n        new TestFactoryImpl<TestClass>);\n\n    // Next, recurses (at compile time) with the tail of the type list.\n    return TypeParameterizedTest<Fixture, TestSel, typename Types::Tail>\n        ::Register(prefix, case_name, test_names, index + 1);\n  }\n};\n\n// The base case for the compile time recursion.\ntemplate <GTEST_TEMPLATE_ Fixture, class TestSel>\nclass TypeParameterizedTest<Fixture, TestSel, Types0> {\n public:\n  static bool Register(const char* /*prefix*/, const char* /*case_name*/,\n                       const char* /*test_names*/, int /*index*/) {\n    return true;\n  }\n};\n\n// TypeParameterizedTestCase<Fixture, Tests, Types>::Register()\n// registers *all combinations* of 'Tests' and 'Types' with Google\n// Test.  The return value is insignificant - we just need to return\n// something such that we can call this function in a namespace scope.\ntemplate <GTEST_TEMPLATE_ Fixture, typename Tests, typename Types>\nclass TypeParameterizedTestCase {\n public:\n  static bool Register(const char* prefix, const char* case_name,\n                       const char* test_names) {\n    typedef typename Tests::Head Head;\n\n    // First, register the first test in 'Test' for each type in 'Types'.\n    TypeParameterizedTest<Fixture, Head, Types>::Register(\n        prefix, case_name, test_names, 0);\n\n    // Next, recurses (at compile time) with the tail of the test list.\n    return TypeParameterizedTestCase<Fixture, typename Tests::Tail, Types>\n        ::Register(prefix, case_name, SkipComma(test_names));\n  }\n};\n\n// The base case for the compile time recursion.\ntemplate <GTEST_TEMPLATE_ Fixture, typename Types>\nclass TypeParameterizedTestCase<Fixture, Templates0, Types> {\n public:\n  static bool Register(const char* /*prefix*/, const char* /*case_name*/,\n                       const char* /*test_names*/) {\n    return true;\n  }\n};\n\n#endif  // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P\n\n// Returns the current OS stack trace as an std::string.\n//\n// The maximum number of stack frames to be included is specified by\n// the gtest_stack_trace_depth flag.  The skip_count parameter\n// specifies the number of top frames to be skipped, which doesn't\n// count against the number of frames to be included.\n//\n// For example, if Foo() calls Bar(), which in turn calls\n// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in\n// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.\nGTEST_API_ std::string GetCurrentOsStackTraceExceptTop(\n    UnitTest* unit_test, int skip_count);\n\n// Helpers for suppressing warnings on unreachable code or constant\n// condition.\n\n// Always returns true.\nGTEST_API_ bool AlwaysTrue();\n\n// Always returns false.\ninline bool AlwaysFalse() { return !AlwaysTrue(); }\n\n// Helper for suppressing false warning from Clang on a const char*\n// variable declared in a conditional expression always being NULL in\n// the else branch.\nstruct GTEST_API_ ConstCharPtr {\n  ConstCharPtr(const char* str) : value(str) {}\n  operator bool() const { return true; }\n  const char* value;\n};\n\n// A simple Linear Congruential Generator for generating random\n// numbers with a uniform distribution.  Unlike rand() and srand(), it\n// doesn't use global state (and therefore can't interfere with user\n// code).  Unlike rand_r(), it's portable.  An LCG isn't very random,\n// but it's good enough for our purposes.\nclass GTEST_API_ Random {\n public:\n  static const UInt32 kMaxRange = 1u << 31;\n\n  explicit Random(UInt32 seed) : state_(seed) {}\n\n  void Reseed(UInt32 seed) { state_ = seed; }\n\n  // Generates a random number from [0, range).  Crashes if 'range' is\n  // 0 or greater than kMaxRange.\n  UInt32 Generate(UInt32 range);\n\n private:\n  UInt32 state_;\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(Random);\n};\n\n// Defining a variable of type CompileAssertTypesEqual<T1, T2> will cause a\n// compiler error iff T1 and T2 are different types.\ntemplate <typename T1, typename T2>\nstruct CompileAssertTypesEqual;\n\ntemplate <typename T>\nstruct CompileAssertTypesEqual<T, T> {\n};\n\n// Removes the reference from a type if it is a reference type,\n// otherwise leaves it unchanged.  This is the same as\n// tr1::remove_reference, which is not widely available yet.\ntemplate <typename T>\nstruct RemoveReference { typedef T type; };  // NOLINT\ntemplate <typename T>\nstruct RemoveReference<T&> { typedef T type; };  // NOLINT\n\n// A handy wrapper around RemoveReference that works when the argument\n// T depends on template parameters.\n#define GTEST_REMOVE_REFERENCE_(T) \\\n    typename ::testing::internal::RemoveReference<T>::type\n\n// Removes const from a type if it is a const type, otherwise leaves\n// it unchanged.  This is the same as tr1::remove_const, which is not\n// widely available yet.\ntemplate <typename T>\nstruct RemoveConst { typedef T type; };  // NOLINT\ntemplate <typename T>\nstruct RemoveConst<const T> { typedef T type; };  // NOLINT\n\n// MSVC 8.0, Sun C++, and IBM XL C++ have a bug which causes the above\n// definition to fail to remove the const in 'const int[3]' and 'const\n// char[3][4]'.  The following specialization works around the bug.\ntemplate <typename T, size_t N>\nstruct RemoveConst<const T[N]> {\n  typedef typename RemoveConst<T>::type type[N];\n};\n\n#if defined(_MSC_VER) && _MSC_VER < 1400\n// This is the only specialization that allows VC++ 7.1 to remove const in\n// 'const int[3] and 'const int[3][4]'.  However, it causes trouble with GCC\n// and thus needs to be conditionally compiled.\ntemplate <typename T, size_t N>\nstruct RemoveConst<T[N]> {\n  typedef typename RemoveConst<T>::type type[N];\n};\n#endif\n\n// A handy wrapper around RemoveConst that works when the argument\n// T depends on template parameters.\n#define GTEST_REMOVE_CONST_(T) \\\n    typename ::testing::internal::RemoveConst<T>::type\n\n// Turns const U&, U&, const U, and U all into U.\n#define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \\\n    GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T))\n\n// Adds reference to a type if it is not a reference type,\n// otherwise leaves it unchanged.  This is the same as\n// tr1::add_reference, which is not widely available yet.\ntemplate <typename T>\nstruct AddReference { typedef T& type; };  // NOLINT\ntemplate <typename T>\nstruct AddReference<T&> { typedef T& type; };  // NOLINT\n\n// A handy wrapper around AddReference that works when the argument T\n// depends on template parameters.\n#define GTEST_ADD_REFERENCE_(T) \\\n    typename ::testing::internal::AddReference<T>::type\n\n// Adds a reference to const on top of T as necessary.  For example,\n// it transforms\n//\n//   char         ==> const char&\n//   const char   ==> const char&\n//   char&        ==> const char&\n//   const char&  ==> const char&\n//\n// The argument T must depend on some template parameters.\n#define GTEST_REFERENCE_TO_CONST_(T) \\\n    GTEST_ADD_REFERENCE_(const GTEST_REMOVE_REFERENCE_(T))\n\n// ImplicitlyConvertible<From, To>::value is a compile-time bool\n// constant that's true iff type From can be implicitly converted to\n// type To.\ntemplate <typename From, typename To>\nclass ImplicitlyConvertible {\n private:\n  // We need the following helper functions only for their types.\n  // They have no implementations.\n\n  // MakeFrom() is an expression whose type is From.  We cannot simply\n  // use From(), as the type From may not have a public default\n  // constructor.\n  static From MakeFrom();\n\n  // These two functions are overloaded.  Given an expression\n  // Helper(x), the compiler will pick the first version if x can be\n  // implicitly converted to type To; otherwise it will pick the\n  // second version.\n  //\n  // The first version returns a value of size 1, and the second\n  // version returns a value of size 2.  Therefore, by checking the\n  // size of Helper(x), which can be done at compile time, we can tell\n  // which version of Helper() is used, and hence whether x can be\n  // implicitly converted to type To.\n  static char Helper(To);\n  static char (&Helper(...))[2];  // NOLINT\n\n  // We have to put the 'public' section after the 'private' section,\n  // or MSVC refuses to compile the code.\n public:\n  // MSVC warns about implicitly converting from double to int for\n  // possible loss of data, so we need to temporarily disable the\n  // warning.\n#ifdef _MSC_VER\n# pragma warning(push)          // Saves the current warning state.\n# pragma warning(disable:4244)  // Temporarily disables warning 4244.\n\n  static const bool value =\n      sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1;\n# pragma warning(pop)           // Restores the warning state.\n#elif defined(__BORLANDC__)\n  // C++Builder cannot use member overload resolution during template\n  // instantiation.  The simplest workaround is to use its C++0x type traits\n  // functions (C++Builder 2009 and above only).\n  static const bool value = __is_convertible(From, To);\n#else\n  static const bool value =\n      sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1;\n#endif  // _MSV_VER\n};\ntemplate <typename From, typename To>\nconst bool ImplicitlyConvertible<From, To>::value;\n\n// IsAProtocolMessage<T>::value is a compile-time bool constant that's\n// true iff T is type ProtocolMessage, proto2::Message, or a subclass\n// of those.\ntemplate <typename T>\nstruct IsAProtocolMessage\n    : public bool_constant<\n  ImplicitlyConvertible<const T*, const ::ProtocolMessage*>::value ||\n  ImplicitlyConvertible<const T*, const ::proto2::Message*>::value> {\n};\n\n// When the compiler sees expression IsContainerTest<C>(0), if C is an\n// STL-style container class, the first overload of IsContainerTest\n// will be viable (since both C::iterator* and C::const_iterator* are\n// valid types and NULL can be implicitly converted to them).  It will\n// be picked over the second overload as 'int' is a perfect match for\n// the type of argument 0.  If C::iterator or C::const_iterator is not\n// a valid type, the first overload is not viable, and the second\n// overload will be picked.  Therefore, we can determine whether C is\n// a container class by checking the type of IsContainerTest<C>(0).\n// The value of the expression is insignificant.\n//\n// Note that we look for both C::iterator and C::const_iterator.  The\n// reason is that C++ injects the name of a class as a member of the\n// class itself (e.g. you can refer to class iterator as either\n// 'iterator' or 'iterator::iterator').  If we look for C::iterator\n// only, for example, we would mistakenly think that a class named\n// iterator is an STL container.\n//\n// Also note that the simpler approach of overloading\n// IsContainerTest(typename C::const_iterator*) and\n// IsContainerTest(...) doesn't work with Visual Age C++ and Sun C++.\ntypedef int IsContainer;\ntemplate <class C>\nIsContainer IsContainerTest(int /* dummy */,\n                            typename C::iterator* /* it */ = NULL,\n                            typename C::const_iterator* /* const_it */ = NULL) {\n  return 0;\n}\n\ntypedef char IsNotContainer;\ntemplate <class C>\nIsNotContainer IsContainerTest(long /* dummy */) { return '\\0'; }\n\n// EnableIf<condition>::type is void when 'Cond' is true, and\n// undefined when 'Cond' is false.  To use SFINAE to make a function\n// overload only apply when a particular expression is true, add\n// \"typename EnableIf<expression>::type* = 0\" as the last parameter.\ntemplate<bool> struct EnableIf;\ntemplate<> struct EnableIf<true> { typedef void type; };  // NOLINT\n\n// Utilities for native arrays.\n\n// ArrayEq() compares two k-dimensional native arrays using the\n// elements' operator==, where k can be any integer >= 0.  When k is\n// 0, ArrayEq() degenerates into comparing a single pair of values.\n\ntemplate <typename T, typename U>\nbool ArrayEq(const T* lhs, size_t size, const U* rhs);\n\n// This generic version is used when k is 0.\ntemplate <typename T, typename U>\ninline bool ArrayEq(const T& lhs, const U& rhs) { return lhs == rhs; }\n\n// This overload is used when k >= 1.\ntemplate <typename T, typename U, size_t N>\ninline bool ArrayEq(const T(&lhs)[N], const U(&rhs)[N]) {\n  return internal::ArrayEq(lhs, N, rhs);\n}\n\n// This helper reduces code bloat.  If we instead put its logic inside\n// the previous ArrayEq() function, arrays with different sizes would\n// lead to different copies of the template code.\ntemplate <typename T, typename U>\nbool ArrayEq(const T* lhs, size_t size, const U* rhs) {\n  for (size_t i = 0; i != size; i++) {\n    if (!internal::ArrayEq(lhs[i], rhs[i]))\n      return false;\n  }\n  return true;\n}\n\n// Finds the first element in the iterator range [begin, end) that\n// equals elem.  Element may be a native array type itself.\ntemplate <typename Iter, typename Element>\nIter ArrayAwareFind(Iter begin, Iter end, const Element& elem) {\n  for (Iter it = begin; it != end; ++it) {\n    if (internal::ArrayEq(*it, elem))\n      return it;\n  }\n  return end;\n}\n\n// CopyArray() copies a k-dimensional native array using the elements'\n// operator=, where k can be any integer >= 0.  When k is 0,\n// CopyArray() degenerates into copying a single value.\n\ntemplate <typename T, typename U>\nvoid CopyArray(const T* from, size_t size, U* to);\n\n// This generic version is used when k is 0.\ntemplate <typename T, typename U>\ninline void CopyArray(const T& from, U* to) { *to = from; }\n\n// This overload is used when k >= 1.\ntemplate <typename T, typename U, size_t N>\ninline void CopyArray(const T(&from)[N], U(*to)[N]) {\n  internal::CopyArray(from, N, *to);\n}\n\n// This helper reduces code bloat.  If we instead put its logic inside\n// the previous CopyArray() function, arrays with different sizes\n// would lead to different copies of the template code.\ntemplate <typename T, typename U>\nvoid CopyArray(const T* from, size_t size, U* to) {\n  for (size_t i = 0; i != size; i++) {\n    internal::CopyArray(from[i], to + i);\n  }\n}\n\n// The relation between an NativeArray object (see below) and the\n// native array it represents.\nenum RelationToSource {\n  kReference,  // The NativeArray references the native array.\n  kCopy        // The NativeArray makes a copy of the native array and\n               // owns the copy.\n};\n\n// Adapts a native array to a read-only STL-style container.  Instead\n// of the complete STL container concept, this adaptor only implements\n// members useful for Google Mock's container matchers.  New members\n// should be added as needed.  To simplify the implementation, we only\n// support Element being a raw type (i.e. having no top-level const or\n// reference modifier).  It's the client's responsibility to satisfy\n// this requirement.  Element can be an array type itself (hence\n// multi-dimensional arrays are supported).\ntemplate <typename Element>\nclass NativeArray {\n public:\n  // STL-style container typedefs.\n  typedef Element value_type;\n  typedef Element* iterator;\n  typedef const Element* const_iterator;\n\n  // Constructs from a native array.\n  NativeArray(const Element* array, size_t count, RelationToSource relation) {\n    Init(array, count, relation);\n  }\n\n  // Copy constructor.\n  NativeArray(const NativeArray& rhs) {\n    Init(rhs.array_, rhs.size_, rhs.relation_to_source_);\n  }\n\n  ~NativeArray() {\n    // Ensures that the user doesn't instantiate NativeArray with a\n    // const or reference type.\n    static_cast<void>(StaticAssertTypeEqHelper<Element,\n        GTEST_REMOVE_REFERENCE_AND_CONST_(Element)>());\n    if (relation_to_source_ == kCopy)\n      delete[] array_;\n  }\n\n  // STL-style container methods.\n  size_t size() const { return size_; }\n  const_iterator begin() const { return array_; }\n  const_iterator end() const { return array_ + size_; }\n  bool operator==(const NativeArray& rhs) const {\n    return size() == rhs.size() &&\n        ArrayEq(begin(), size(), rhs.begin());\n  }\n\n private:\n  // Initializes this object; makes a copy of the input array if\n  // 'relation' is kCopy.\n  void Init(const Element* array, size_t a_size, RelationToSource relation) {\n    if (relation == kReference) {\n      array_ = array;\n    } else {\n      Element* const copy = new Element[a_size];\n      CopyArray(array, a_size, copy);\n      array_ = copy;\n    }\n    size_ = a_size;\n    relation_to_source_ = relation;\n  }\n\n  const Element* array_;\n  size_t size_;\n  RelationToSource relation_to_source_;\n\n  GTEST_DISALLOW_ASSIGN_(NativeArray);\n};\n\n}  // namespace internal\n}  // namespace testing\n\n#define GTEST_MESSAGE_AT_(file, line, message, result_type) \\\n  ::testing::internal::AssertHelper(result_type, file, line, message) \\\n    = ::testing::Message()\n\n#define GTEST_MESSAGE_(message, result_type) \\\n  GTEST_MESSAGE_AT_(__FILE__, __LINE__, message, result_type)\n\n#define GTEST_FATAL_FAILURE_(message) \\\n  return GTEST_MESSAGE_(message, ::testing::TestPartResult::kFatalFailure)\n\n#define GTEST_NONFATAL_FAILURE_(message) \\\n  GTEST_MESSAGE_(message, ::testing::TestPartResult::kNonFatalFailure)\n\n#define GTEST_SUCCESS_(message) \\\n  GTEST_MESSAGE_(message, ::testing::TestPartResult::kSuccess)\n\n// Suppresses MSVC warnings 4072 (unreachable code) for the code following\n// statement if it returns or throws (or doesn't return or throw in some\n// situations).\n#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \\\n  if (::testing::internal::AlwaysTrue()) { statement; }\n\n#define GTEST_TEST_THROW_(statement, expected_exception, fail) \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n  if (::testing::internal::ConstCharPtr gtest_msg = \"\") { \\\n    bool gtest_caught_expected = false; \\\n    try { \\\n      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \\\n    } \\\n    catch (expected_exception const&) { \\\n      gtest_caught_expected = true; \\\n    } \\\n    catch (...) { \\\n      gtest_msg.value = \\\n          \"Expected: \" #statement \" throws an exception of type \" \\\n          #expected_exception \".\\n  Actual: it throws a different type.\"; \\\n      goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \\\n    } \\\n    if (!gtest_caught_expected) { \\\n      gtest_msg.value = \\\n          \"Expected: \" #statement \" throws an exception of type \" \\\n          #expected_exception \".\\n  Actual: it throws nothing.\"; \\\n      goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \\\n    } \\\n  } else \\\n    GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \\\n      fail(gtest_msg.value)\n\n#define GTEST_TEST_NO_THROW_(statement, fail) \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n  if (::testing::internal::AlwaysTrue()) { \\\n    try { \\\n      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \\\n    } \\\n    catch (std::exception &e) {\\\n      FAIL() << \"EXCEPTION CAUGHT: \" << e.what() << \"\\n\";\\\n      goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \\\n    }\\\n    catch (...) { \\\n      goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \\\n    } \\\n  } else \\\n    GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \\\n      fail(\"Expected: \" #statement \" doesn't throw an exception.\\n\" \\\n           \"  Actual: it throws.\")\n\n#define GTEST_TEST_ANY_THROW_(statement, fail) \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n  if (::testing::internal::AlwaysTrue()) { \\\n    bool gtest_caught_any = false; \\\n    try { \\\n      GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \\\n    } \\\n    catch (...) { \\\n      gtest_caught_any = true; \\\n    } \\\n    if (!gtest_caught_any) { \\\n      goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \\\n    } \\\n  } else \\\n    GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \\\n      fail(\"Expected: \" #statement \" throws an exception.\\n\" \\\n           \"  Actual: it doesn't.\")\n\n\n// Implements Boolean test assertions such as EXPECT_TRUE. expression can be\n// either a boolean expression or an AssertionResult. text is a textual\n// represenation of expression as it was passed into the EXPECT_TRUE.\n#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n  if (const ::testing::AssertionResult gtest_ar_ = \\\n      ::testing::AssertionResult(expression)) \\\n    ; \\\n  else \\\n    fail(::testing::internal::GetBoolAssertionFailureMessage(\\\n        gtest_ar_, text, #actual, #expected).c_str())\n\n#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n  if (::testing::internal::AlwaysTrue()) { \\\n    ::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \\\n    GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \\\n    if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \\\n      goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \\\n    } \\\n  } else \\\n    GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \\\n      fail(\"Expected: \" #statement \" doesn't generate new fatal \" \\\n           \"failures in the current thread.\\n\" \\\n           \"  Actual: it does.\")\n\n// Expands to the name of the class that implements the given test.\n#define GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \\\n  test_case_name##_##test_name##_Test\n\n// Helper macro for defining tests.\n#define GTEST_TEST_(test_case_name, test_name, parent_class, parent_id)\\\nclass GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public parent_class {\\\n public:\\\n  GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\\\n private:\\\n  virtual void TestBody();\\\n  static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;\\\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(\\\n      GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\\\n};\\\n\\\n::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_case_name, test_name)\\\n  ::test_info_ =\\\n    ::testing::internal::MakeAndRegisterTestInfo(\\\n        #test_case_name, #test_name, NULL, NULL, \\\n        (parent_id), \\\n        parent_class::SetUpTestCase, \\\n        parent_class::TearDownTestCase, \\\n        new ::testing::internal::TestFactoryImpl<\\\n            GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\\\nvoid GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody()\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/internal/gtest-linked_ptr.h",
    "content": "// Copyright 2003 Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: Dan Egnor (egnor@google.com)\n//\n// A \"smart\" pointer type with reference tracking.  Every pointer to a\n// particular object is kept on a circular linked list.  When the last pointer\n// to an object is destroyed or reassigned, the object is deleted.\n//\n// Used properly, this deletes the object when the last reference goes away.\n// There are several caveats:\n// - Like all reference counting schemes, cycles lead to leaks.\n// - Each smart pointer is actually two pointers (8 bytes instead of 4).\n// - Every time a pointer is assigned, the entire list of pointers to that\n//   object is traversed.  This class is therefore NOT SUITABLE when there\n//   will often be more than two or three pointers to a particular object.\n// - References are only tracked as long as linked_ptr<> objects are copied.\n//   If a linked_ptr<> is converted to a raw pointer and back, BAD THINGS\n//   will happen (double deletion).\n//\n// A good use of this class is storing object references in STL containers.\n// You can safely put linked_ptr<> in a vector<>.\n// Other uses may not be as good.\n//\n// Note: If you use an incomplete type with linked_ptr<>, the class\n// *containing* linked_ptr<> must have a constructor and destructor (even\n// if they do nothing!).\n//\n// Bill Gibbons suggested we use something like this.\n//\n// Thread Safety:\n//   Unlike other linked_ptr implementations, in this implementation\n//   a linked_ptr object is thread-safe in the sense that:\n//     - it's safe to copy linked_ptr objects concurrently,\n//     - it's safe to copy *from* a linked_ptr and read its underlying\n//       raw pointer (e.g. via get()) concurrently, and\n//     - it's safe to write to two linked_ptrs that point to the same\n//       shared object concurrently.\n// TODO(wan@google.com): rename this to safe_linked_ptr to avoid\n// confusion with normal linked_ptr.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_\n\n#include <stdlib.h>\n#include <assert.h>\n\n#include \"gtest/internal/gtest-port.h\"\n\nnamespace testing {\nnamespace internal {\n\n// Protects copying of all linked_ptr objects.\nGTEST_API_ GTEST_DECLARE_STATIC_MUTEX_(g_linked_ptr_mutex);\n\n// This is used internally by all instances of linked_ptr<>.  It needs to be\n// a non-template class because different types of linked_ptr<> can refer to\n// the same object (linked_ptr<Superclass>(obj) vs linked_ptr<Subclass>(obj)).\n// So, it needs to be possible for different types of linked_ptr to participate\n// in the same circular linked list, so we need a single class type here.\n//\n// DO NOT USE THIS CLASS DIRECTLY YOURSELF.  Use linked_ptr<T>.\nclass linked_ptr_internal {\n public:\n  // Create a new circle that includes only this instance.\n  void join_new() {\n    next_ = this;\n  }\n\n  // Many linked_ptr operations may change p.link_ for some linked_ptr\n  // variable p in the same circle as this object.  Therefore we need\n  // to prevent two such operations from occurring concurrently.\n  //\n  // Note that different types of linked_ptr objects can coexist in a\n  // circle (e.g. linked_ptr<Base>, linked_ptr<Derived1>, and\n  // linked_ptr<Derived2>).  Therefore we must use a single mutex to\n  // protect all linked_ptr objects.  This can create serious\n  // contention in production code, but is acceptable in a testing\n  // framework.\n\n  // Join an existing circle.\n  void join(linked_ptr_internal const* ptr)\n      GTEST_LOCK_EXCLUDED_(g_linked_ptr_mutex) {\n    MutexLock lock(&g_linked_ptr_mutex);\n\n    linked_ptr_internal const* p = ptr;\n    while (p->next_ != ptr) p = p->next_;\n    p->next_ = this;\n    next_ = ptr;\n  }\n\n  // Leave whatever circle we're part of.  Returns true if we were the\n  // last member of the circle.  Once this is done, you can join() another.\n  bool depart()\n      GTEST_LOCK_EXCLUDED_(g_linked_ptr_mutex) {\n    MutexLock lock(&g_linked_ptr_mutex);\n\n    if (next_ == this) return true;\n    linked_ptr_internal const* p = next_;\n    while (p->next_ != this) p = p->next_;\n    p->next_ = next_;\n    return false;\n  }\n\n private:\n  mutable linked_ptr_internal const* next_;\n};\n\ntemplate <typename T>\nclass linked_ptr {\n public:\n  typedef T element_type;\n\n  // Take over ownership of a raw pointer.  This should happen as soon as\n  // possible after the object is created.\n  explicit linked_ptr(T* ptr = NULL) { capture(ptr); }\n  ~linked_ptr() { depart(); }\n\n  // Copy an existing linked_ptr<>, adding ourselves to the list of references.\n  template <typename U> linked_ptr(linked_ptr<U> const& ptr) { copy(&ptr); }\n  linked_ptr(linked_ptr const& ptr) {  // NOLINT\n    assert(&ptr != this);\n    copy(&ptr);\n  }\n\n  // Assignment releases the old value and acquires the new.\n  template <typename U> linked_ptr& operator=(linked_ptr<U> const& ptr) {\n    depart();\n    copy(&ptr);\n    return *this;\n  }\n\n  linked_ptr& operator=(linked_ptr const& ptr) {\n    if (&ptr != this) {\n      depart();\n      copy(&ptr);\n    }\n    return *this;\n  }\n\n  // Smart pointer members.\n  void reset(T* ptr = NULL) {\n    depart();\n    capture(ptr);\n  }\n  T* get() const { return value_; }\n  T* operator->() const { return value_; }\n  T& operator*() const { return *value_; }\n\n  bool operator==(T* p) const { return value_ == p; }\n  bool operator!=(T* p) const { return value_ != p; }\n  template <typename U>\n  bool operator==(linked_ptr<U> const& ptr) const {\n    return value_ == ptr.get();\n  }\n  template <typename U>\n  bool operator!=(linked_ptr<U> const& ptr) const {\n    return value_ != ptr.get();\n  }\n\n private:\n  template <typename U>\n  friend class linked_ptr;\n\n  T* value_;\n  linked_ptr_internal link_;\n\n  void depart() {\n    if (link_.depart()) delete value_;\n  }\n\n  void capture(T* ptr) {\n    value_ = ptr;\n    link_.join_new();\n  }\n\n  template <typename U> void copy(linked_ptr<U> const* ptr) {\n    value_ = ptr->get();\n    if (value_)\n      link_.join(&ptr->link_);\n    else\n      link_.join_new();\n  }\n};\n\ntemplate<typename T> inline\nbool operator==(T* ptr, const linked_ptr<T>& x) {\n  return ptr == x.get();\n}\n\ntemplate<typename T> inline\nbool operator!=(T* ptr, const linked_ptr<T>& x) {\n  return ptr != x.get();\n}\n\n// A function to convert T* into linked_ptr<T>\n// Doing e.g. make_linked_ptr(new FooBarBaz<type>(arg)) is a shorter notation\n// for linked_ptr<FooBarBaz<type> >(new FooBarBaz<type>(arg))\ntemplate <typename T>\nlinked_ptr<T> make_linked_ptr(T* ptr) {\n  return linked_ptr<T>(ptr);\n}\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/internal/gtest-param-util-generated.h",
    "content": "// This file was GENERATED by command:\n//     pump.py gtest-param-util-generated.h.pump\n// DO NOT EDIT BY HAND!!!\n\n// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n\n// Type and function utilities for implementing parameterized tests.\n// This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!\n//\n// Currently Google Test supports at most 50 arguments in Values,\n// and at most 10 arguments in Combine. Please contact\n// googletestframework@googlegroups.com if you need more.\n// Please note that the number of arguments to Combine is limited\n// by the maximum arity of the implementation of tr1::tuple which is\n// currently set at 10.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_\n\n// scripts/fuse_gtest.py depends on gtest's own header being #included\n// *unconditionally*.  Therefore these #includes cannot be moved\n// inside #if GTEST_HAS_PARAM_TEST.\n#include \"gtest/internal/gtest-param-util.h\"\n#include \"gtest/internal/gtest-port.h\"\n\n#if GTEST_HAS_PARAM_TEST\n\nnamespace testing {\n\n// Forward declarations of ValuesIn(), which is implemented in\n// include/gtest/gtest-param-test.h.\ntemplate <typename ForwardIterator>\ninternal::ParamGenerator<\n  typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>\nValuesIn(ForwardIterator begin, ForwardIterator end);\n\ntemplate <typename T, size_t N>\ninternal::ParamGenerator<T> ValuesIn(const T (&array)[N]);\n\ntemplate <class Container>\ninternal::ParamGenerator<typename Container::value_type> ValuesIn(\n    const Container& container);\n\nnamespace internal {\n\n// Used in the Values() function to provide polymorphic capabilities.\ntemplate <typename T1>\nclass ValueArray1 {\n public:\n  explicit ValueArray1(T1 v1) : v1_(v1) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const { return ValuesIn(&v1_, &v1_ + 1); }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray1& other);\n\n  const T1 v1_;\n};\n\ntemplate <typename T1, typename T2>\nclass ValueArray2 {\n public:\n  ValueArray2(T1 v1, T2 v2) : v1_(v1), v2_(v2) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray2& other);\n\n  const T1 v1_;\n  const T2 v2_;\n};\n\ntemplate <typename T1, typename T2, typename T3>\nclass ValueArray3 {\n public:\n  ValueArray3(T1 v1, T2 v2, T3 v3) : v1_(v1), v2_(v2), v3_(v3) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray3& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4>\nclass ValueArray4 {\n public:\n  ValueArray4(T1 v1, T2 v2, T3 v3, T4 v4) : v1_(v1), v2_(v2), v3_(v3),\n      v4_(v4) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray4& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5>\nclass ValueArray5 {\n public:\n  ValueArray5(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) : v1_(v1), v2_(v2), v3_(v3),\n      v4_(v4), v5_(v5) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray5& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6>\nclass ValueArray6 {\n public:\n  ValueArray6(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) : v1_(v1), v2_(v2),\n      v3_(v3), v4_(v4), v5_(v5), v6_(v6) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray6& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7>\nclass ValueArray7 {\n public:\n  ValueArray7(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7) : v1_(v1),\n      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray7& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8>\nclass ValueArray8 {\n public:\n  ValueArray8(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,\n      T8 v8) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray8& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9>\nclass ValueArray9 {\n public:\n  ValueArray9(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,\n      T9 v9) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray9& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10>\nclass ValueArray10 {\n public:\n  ValueArray10(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9), v10_(v10) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray10& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11>\nclass ValueArray11 {\n public:\n  ValueArray11(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),\n      v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray11& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12>\nclass ValueArray12 {\n public:\n  ValueArray12(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),\n      v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray12& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13>\nclass ValueArray13 {\n public:\n  ValueArray13(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),\n      v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),\n      v12_(v12), v13_(v13) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray13& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14>\nclass ValueArray14 {\n public:\n  ValueArray14(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14) : v1_(v1), v2_(v2), v3_(v3),\n      v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),\n      v11_(v11), v12_(v12), v13_(v13), v14_(v14) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray14& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15>\nclass ValueArray15 {\n public:\n  ValueArray15(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15) : v1_(v1), v2_(v2),\n      v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),\n      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray15& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16>\nclass ValueArray16 {\n public:\n  ValueArray16(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16) : v1_(v1),\n      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),\n      v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),\n      v16_(v16) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray16& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17>\nclass ValueArray17 {\n public:\n  ValueArray17(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16,\n      T17 v17) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),\n      v15_(v15), v16_(v16), v17_(v17) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray17& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18>\nclass ValueArray18 {\n public:\n  ValueArray18(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),\n      v15_(v15), v16_(v16), v17_(v17), v18_(v18) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray18& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19>\nclass ValueArray19 {\n public:\n  ValueArray19(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),\n      v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13),\n      v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray19& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20>\nclass ValueArray20 {\n public:\n  ValueArray20(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),\n      v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12),\n      v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18),\n      v19_(v19), v20_(v20) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray20& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21>\nclass ValueArray21 {\n public:\n  ValueArray21(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),\n      v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),\n      v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17),\n      v18_(v18), v19_(v19), v20_(v20), v21_(v21) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray21& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22>\nclass ValueArray22 {\n public:\n  ValueArray22(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22) : v1_(v1), v2_(v2), v3_(v3),\n      v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),\n      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),\n      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray22& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23>\nclass ValueArray23 {\n public:\n  ValueArray23(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23) : v1_(v1), v2_(v2),\n      v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),\n      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),\n      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),\n      v23_(v23) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray23& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24>\nclass ValueArray24 {\n public:\n  ValueArray24(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24) : v1_(v1),\n      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),\n      v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),\n      v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21),\n      v22_(v22), v23_(v23), v24_(v24) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray24& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25>\nclass ValueArray25 {\n public:\n  ValueArray25(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24,\n      T25 v25) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),\n      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),\n      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray25& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26>\nclass ValueArray26 {\n public:\n  ValueArray26(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),\n      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),\n      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray26& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27>\nclass ValueArray27 {\n public:\n  ValueArray27(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),\n      v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13),\n      v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19),\n      v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25),\n      v26_(v26), v27_(v27) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray27& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28>\nclass ValueArray28 {\n public:\n  ValueArray28(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),\n      v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12),\n      v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18),\n      v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24),\n      v25_(v25), v26_(v26), v27_(v27), v28_(v28) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray28& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29>\nclass ValueArray29 {\n public:\n  ValueArray29(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),\n      v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),\n      v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17),\n      v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23),\n      v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray29& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30>\nclass ValueArray30 {\n public:\n  ValueArray30(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30) : v1_(v1), v2_(v2), v3_(v3),\n      v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),\n      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),\n      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),\n      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),\n      v29_(v29), v30_(v30) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray30& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31>\nclass ValueArray31 {\n public:\n  ValueArray31(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31) : v1_(v1), v2_(v2),\n      v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),\n      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),\n      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),\n      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),\n      v29_(v29), v30_(v30), v31_(v31) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray31& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32>\nclass ValueArray32 {\n public:\n  ValueArray32(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32) : v1_(v1),\n      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),\n      v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),\n      v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21),\n      v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27),\n      v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray32& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33>\nclass ValueArray33 {\n public:\n  ValueArray33(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32,\n      T33 v33) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),\n      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),\n      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),\n      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),\n      v33_(v33) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray33& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34>\nclass ValueArray34 {\n public:\n  ValueArray34(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),\n      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),\n      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),\n      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),\n      v33_(v33), v34_(v34) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray34& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35>\nclass ValueArray35 {\n public:\n  ValueArray35(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),\n      v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13),\n      v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19),\n      v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25),\n      v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31),\n      v32_(v32), v33_(v33), v34_(v34), v35_(v35) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray35& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36>\nclass ValueArray36 {\n public:\n  ValueArray36(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),\n      v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12),\n      v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18),\n      v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24),\n      v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30),\n      v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35), v36_(v36) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray36& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37>\nclass ValueArray37 {\n public:\n  ValueArray37(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),\n      v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),\n      v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17),\n      v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23),\n      v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29),\n      v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35),\n      v36_(v36), v37_(v37) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray37& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38>\nclass ValueArray38 {\n public:\n  ValueArray38(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38) : v1_(v1), v2_(v2), v3_(v3),\n      v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),\n      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),\n      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),\n      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),\n      v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34),\n      v35_(v35), v36_(v36), v37_(v37), v38_(v38) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray38& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39>\nclass ValueArray39 {\n public:\n  ValueArray39(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39) : v1_(v1), v2_(v2),\n      v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),\n      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),\n      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),\n      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),\n      v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34),\n      v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray39& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40>\nclass ValueArray40 {\n public:\n  ValueArray40(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40) : v1_(v1),\n      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),\n      v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),\n      v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21),\n      v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27),\n      v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33),\n      v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39),\n      v40_(v40) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_), static_cast<T>(v40_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray40& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n  const T40 v40_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41>\nclass ValueArray41 {\n public:\n  ValueArray41(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40,\n      T41 v41) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),\n      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),\n      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),\n      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),\n      v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38),\n      v39_(v39), v40_(v40), v41_(v41) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray41& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n  const T40 v40_;\n  const T41 v41_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42>\nclass ValueArray42 {\n public:\n  ValueArray42(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n      T42 v42) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),\n      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),\n      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),\n      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),\n      v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38),\n      v39_(v39), v40_(v40), v41_(v41), v42_(v42) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),\n        static_cast<T>(v42_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray42& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n  const T40 v40_;\n  const T41 v41_;\n  const T42 v42_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43>\nclass ValueArray43 {\n public:\n  ValueArray43(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n      T42 v42, T43 v43) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6),\n      v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13),\n      v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19),\n      v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25),\n      v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31),\n      v32_(v32), v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37),\n      v38_(v38), v39_(v39), v40_(v40), v41_(v41), v42_(v42), v43_(v43) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),\n        static_cast<T>(v42_), static_cast<T>(v43_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray43& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n  const T40 v40_;\n  const T41 v41_;\n  const T42 v42_;\n  const T43 v43_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44>\nclass ValueArray44 {\n public:\n  ValueArray44(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n      T42 v42, T43 v43, T44 v44) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5),\n      v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12),\n      v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18),\n      v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24),\n      v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30),\n      v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35), v36_(v36),\n      v37_(v37), v38_(v38), v39_(v39), v40_(v40), v41_(v41), v42_(v42),\n      v43_(v43), v44_(v44) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),\n        static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray44& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n  const T40 v40_;\n  const T41 v41_;\n  const T42 v42_;\n  const T43 v43_;\n  const T44 v44_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45>\nclass ValueArray45 {\n public:\n  ValueArray45(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n      T42 v42, T43 v43, T44 v44, T45 v45) : v1_(v1), v2_(v2), v3_(v3), v4_(v4),\n      v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11),\n      v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17),\n      v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23),\n      v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29),\n      v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35),\n      v36_(v36), v37_(v37), v38_(v38), v39_(v39), v40_(v40), v41_(v41),\n      v42_(v42), v43_(v43), v44_(v44), v45_(v45) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),\n        static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),\n        static_cast<T>(v45_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray45& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n  const T40 v40_;\n  const T41 v41_;\n  const T42 v42_;\n  const T43 v43_;\n  const T44 v44_;\n  const T45 v45_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46>\nclass ValueArray46 {\n public:\n  ValueArray46(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n      T42 v42, T43 v43, T44 v44, T45 v45, T46 v46) : v1_(v1), v2_(v2), v3_(v3),\n      v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),\n      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),\n      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),\n      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),\n      v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34),\n      v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39), v40_(v40),\n      v41_(v41), v42_(v42), v43_(v43), v44_(v44), v45_(v45), v46_(v46) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),\n        static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),\n        static_cast<T>(v45_), static_cast<T>(v46_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray46& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n  const T40 v40_;\n  const T41 v41_;\n  const T42 v42_;\n  const T43 v43_;\n  const T44 v44_;\n  const T45 v45_;\n  const T46 v46_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47>\nclass ValueArray47 {\n public:\n  ValueArray47(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n      T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47) : v1_(v1), v2_(v2),\n      v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10),\n      v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16),\n      v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22),\n      v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28),\n      v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34),\n      v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39), v40_(v40),\n      v41_(v41), v42_(v42), v43_(v43), v44_(v44), v45_(v45), v46_(v46),\n      v47_(v47) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),\n        static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),\n        static_cast<T>(v45_), static_cast<T>(v46_), static_cast<T>(v47_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray47& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n  const T40 v40_;\n  const T41 v41_;\n  const T42 v42_;\n  const T43 v43_;\n  const T44 v44_;\n  const T45 v45_;\n  const T46 v46_;\n  const T47 v47_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48>\nclass ValueArray48 {\n public:\n  ValueArray48(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n      T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47, T48 v48) : v1_(v1),\n      v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9),\n      v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15),\n      v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21),\n      v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27),\n      v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33),\n      v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39),\n      v40_(v40), v41_(v41), v42_(v42), v43_(v43), v44_(v44), v45_(v45),\n      v46_(v46), v47_(v47), v48_(v48) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),\n        static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),\n        static_cast<T>(v45_), static_cast<T>(v46_), static_cast<T>(v47_),\n        static_cast<T>(v48_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray48& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n  const T40 v40_;\n  const T41 v41_;\n  const T42 v42_;\n  const T43 v43_;\n  const T44 v44_;\n  const T45 v45_;\n  const T46 v46_;\n  const T47 v47_;\n  const T48 v48_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48, typename T49>\nclass ValueArray49 {\n public:\n  ValueArray49(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n      T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47, T48 v48,\n      T49 v49) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),\n      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),\n      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),\n      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),\n      v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38),\n      v39_(v39), v40_(v40), v41_(v41), v42_(v42), v43_(v43), v44_(v44),\n      v45_(v45), v46_(v46), v47_(v47), v48_(v48), v49_(v49) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),\n        static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),\n        static_cast<T>(v45_), static_cast<T>(v46_), static_cast<T>(v47_),\n        static_cast<T>(v48_), static_cast<T>(v49_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray49& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n  const T40 v40_;\n  const T41 v41_;\n  const T42 v42_;\n  const T43 v43_;\n  const T44 v44_;\n  const T45 v45_;\n  const T46 v46_;\n  const T47 v47_;\n  const T48 v48_;\n  const T49 v49_;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48, typename T49, typename T50>\nclass ValueArray50 {\n public:\n  ValueArray50(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,\n      T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,\n      T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,\n      T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,\n      T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,\n      T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47, T48 v48, T49 v49,\n      T50 v50) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7),\n      v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14),\n      v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20),\n      v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26),\n      v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32),\n      v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38),\n      v39_(v39), v40_(v40), v41_(v41), v42_(v42), v43_(v43), v44_(v44),\n      v45_(v45), v46_(v46), v47_(v47), v48_(v48), v49_(v49), v50_(v50) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {static_cast<T>(v1_), static_cast<T>(v2_),\n        static_cast<T>(v3_), static_cast<T>(v4_), static_cast<T>(v5_),\n        static_cast<T>(v6_), static_cast<T>(v7_), static_cast<T>(v8_),\n        static_cast<T>(v9_), static_cast<T>(v10_), static_cast<T>(v11_),\n        static_cast<T>(v12_), static_cast<T>(v13_), static_cast<T>(v14_),\n        static_cast<T>(v15_), static_cast<T>(v16_), static_cast<T>(v17_),\n        static_cast<T>(v18_), static_cast<T>(v19_), static_cast<T>(v20_),\n        static_cast<T>(v21_), static_cast<T>(v22_), static_cast<T>(v23_),\n        static_cast<T>(v24_), static_cast<T>(v25_), static_cast<T>(v26_),\n        static_cast<T>(v27_), static_cast<T>(v28_), static_cast<T>(v29_),\n        static_cast<T>(v30_), static_cast<T>(v31_), static_cast<T>(v32_),\n        static_cast<T>(v33_), static_cast<T>(v34_), static_cast<T>(v35_),\n        static_cast<T>(v36_), static_cast<T>(v37_), static_cast<T>(v38_),\n        static_cast<T>(v39_), static_cast<T>(v40_), static_cast<T>(v41_),\n        static_cast<T>(v42_), static_cast<T>(v43_), static_cast<T>(v44_),\n        static_cast<T>(v45_), static_cast<T>(v46_), static_cast<T>(v47_),\n        static_cast<T>(v48_), static_cast<T>(v49_), static_cast<T>(v50_)};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray50& other);\n\n  const T1 v1_;\n  const T2 v2_;\n  const T3 v3_;\n  const T4 v4_;\n  const T5 v5_;\n  const T6 v6_;\n  const T7 v7_;\n  const T8 v8_;\n  const T9 v9_;\n  const T10 v10_;\n  const T11 v11_;\n  const T12 v12_;\n  const T13 v13_;\n  const T14 v14_;\n  const T15 v15_;\n  const T16 v16_;\n  const T17 v17_;\n  const T18 v18_;\n  const T19 v19_;\n  const T20 v20_;\n  const T21 v21_;\n  const T22 v22_;\n  const T23 v23_;\n  const T24 v24_;\n  const T25 v25_;\n  const T26 v26_;\n  const T27 v27_;\n  const T28 v28_;\n  const T29 v29_;\n  const T30 v30_;\n  const T31 v31_;\n  const T32 v32_;\n  const T33 v33_;\n  const T34 v34_;\n  const T35 v35_;\n  const T36 v36_;\n  const T37 v37_;\n  const T38 v38_;\n  const T39 v39_;\n  const T40 v40_;\n  const T41 v41_;\n  const T42 v42_;\n  const T43 v43_;\n  const T44 v44_;\n  const T45 v45_;\n  const T46 v46_;\n  const T47 v47_;\n  const T48 v48_;\n  const T49 v49_;\n  const T50 v50_;\n};\n\n# if GTEST_HAS_COMBINE\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Generates values from the Cartesian product of values produced\n// by the argument generators.\n//\ntemplate <typename T1, typename T2>\nclass CartesianProductGenerator2\n    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2> > {\n public:\n  typedef ::std::tr1::tuple<T1, T2> ParamType;\n\n  CartesianProductGenerator2(const ParamGenerator<T1>& g1,\n      const ParamGenerator<T2>& g2)\n      : g1_(g1), g2_(g2) {}\n  virtual ~CartesianProductGenerator2() {}\n\n  virtual ParamIteratorInterface<ParamType>* Begin() const {\n    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin());\n  }\n  virtual ParamIteratorInterface<ParamType>* End() const {\n    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end());\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<ParamType> {\n   public:\n    Iterator(const ParamGeneratorInterface<ParamType>* base,\n      const ParamGenerator<T1>& g1,\n      const typename ParamGenerator<T1>::iterator& current1,\n      const ParamGenerator<T2>& g2,\n      const typename ParamGenerator<T2>::iterator& current2)\n        : base_(base),\n          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),\n          begin2_(g2.begin()), end2_(g2.end()), current2_(current2)    {\n      ComputeCurrentValue();\n    }\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {\n      return base_;\n    }\n    // Advance should not be called on beyond-of-range iterators\n    // so no component iterators must be beyond end of range, either.\n    virtual void Advance() {\n      assert(!AtEnd());\n      ++current2_;\n      if (current2_ == end2_) {\n        current2_ = begin2_;\n        ++current1_;\n      }\n      ComputeCurrentValue();\n    }\n    virtual ParamIteratorInterface<ParamType>* Clone() const {\n      return new Iterator(*this);\n    }\n    virtual const ParamType* Current() const { return &current_value_; }\n    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const Iterator* typed_other =\n          CheckedDowncastToActualType<const Iterator>(&other);\n      // We must report iterators equal if they both point beyond their\n      // respective ranges. That can happen in a variety of fashions,\n      // so we have to consult AtEnd().\n      return (AtEnd() && typed_other->AtEnd()) ||\n         (\n          current1_ == typed_other->current1_ &&\n          current2_ == typed_other->current2_);\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : base_(other.base_),\n        begin1_(other.begin1_),\n        end1_(other.end1_),\n        current1_(other.current1_),\n        begin2_(other.begin2_),\n        end2_(other.end2_),\n        current2_(other.current2_) {\n      ComputeCurrentValue();\n    }\n\n    void ComputeCurrentValue() {\n      if (!AtEnd())\n        current_value_ = ParamType(*current1_, *current2_);\n    }\n    bool AtEnd() const {\n      // We must report iterator past the end of the range when either of the\n      // component iterators has reached the end of its range.\n      return\n          current1_ == end1_ ||\n          current2_ == end2_;\n    }\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<ParamType>* const base_;\n    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.\n    // current[i]_ is the actual traversing iterator.\n    const typename ParamGenerator<T1>::iterator begin1_;\n    const typename ParamGenerator<T1>::iterator end1_;\n    typename ParamGenerator<T1>::iterator current1_;\n    const typename ParamGenerator<T2>::iterator begin2_;\n    const typename ParamGenerator<T2>::iterator end2_;\n    typename ParamGenerator<T2>::iterator current2_;\n    ParamType current_value_;\n  };  // class CartesianProductGenerator2::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductGenerator2& other);\n\n  const ParamGenerator<T1> g1_;\n  const ParamGenerator<T2> g2_;\n};  // class CartesianProductGenerator2\n\n\ntemplate <typename T1, typename T2, typename T3>\nclass CartesianProductGenerator3\n    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3> > {\n public:\n  typedef ::std::tr1::tuple<T1, T2, T3> ParamType;\n\n  CartesianProductGenerator3(const ParamGenerator<T1>& g1,\n      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3)\n      : g1_(g1), g2_(g2), g3_(g3) {}\n  virtual ~CartesianProductGenerator3() {}\n\n  virtual ParamIteratorInterface<ParamType>* Begin() const {\n    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,\n        g3_.begin());\n  }\n  virtual ParamIteratorInterface<ParamType>* End() const {\n    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end());\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<ParamType> {\n   public:\n    Iterator(const ParamGeneratorInterface<ParamType>* base,\n      const ParamGenerator<T1>& g1,\n      const typename ParamGenerator<T1>::iterator& current1,\n      const ParamGenerator<T2>& g2,\n      const typename ParamGenerator<T2>::iterator& current2,\n      const ParamGenerator<T3>& g3,\n      const typename ParamGenerator<T3>::iterator& current3)\n        : base_(base),\n          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),\n          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),\n          begin3_(g3.begin()), end3_(g3.end()), current3_(current3)    {\n      ComputeCurrentValue();\n    }\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {\n      return base_;\n    }\n    // Advance should not be called on beyond-of-range iterators\n    // so no component iterators must be beyond end of range, either.\n    virtual void Advance() {\n      assert(!AtEnd());\n      ++current3_;\n      if (current3_ == end3_) {\n        current3_ = begin3_;\n        ++current2_;\n      }\n      if (current2_ == end2_) {\n        current2_ = begin2_;\n        ++current1_;\n      }\n      ComputeCurrentValue();\n    }\n    virtual ParamIteratorInterface<ParamType>* Clone() const {\n      return new Iterator(*this);\n    }\n    virtual const ParamType* Current() const { return &current_value_; }\n    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const Iterator* typed_other =\n          CheckedDowncastToActualType<const Iterator>(&other);\n      // We must report iterators equal if they both point beyond their\n      // respective ranges. That can happen in a variety of fashions,\n      // so we have to consult AtEnd().\n      return (AtEnd() && typed_other->AtEnd()) ||\n         (\n          current1_ == typed_other->current1_ &&\n          current2_ == typed_other->current2_ &&\n          current3_ == typed_other->current3_);\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : base_(other.base_),\n        begin1_(other.begin1_),\n        end1_(other.end1_),\n        current1_(other.current1_),\n        begin2_(other.begin2_),\n        end2_(other.end2_),\n        current2_(other.current2_),\n        begin3_(other.begin3_),\n        end3_(other.end3_),\n        current3_(other.current3_) {\n      ComputeCurrentValue();\n    }\n\n    void ComputeCurrentValue() {\n      if (!AtEnd())\n        current_value_ = ParamType(*current1_, *current2_, *current3_);\n    }\n    bool AtEnd() const {\n      // We must report iterator past the end of the range when either of the\n      // component iterators has reached the end of its range.\n      return\n          current1_ == end1_ ||\n          current2_ == end2_ ||\n          current3_ == end3_;\n    }\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<ParamType>* const base_;\n    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.\n    // current[i]_ is the actual traversing iterator.\n    const typename ParamGenerator<T1>::iterator begin1_;\n    const typename ParamGenerator<T1>::iterator end1_;\n    typename ParamGenerator<T1>::iterator current1_;\n    const typename ParamGenerator<T2>::iterator begin2_;\n    const typename ParamGenerator<T2>::iterator end2_;\n    typename ParamGenerator<T2>::iterator current2_;\n    const typename ParamGenerator<T3>::iterator begin3_;\n    const typename ParamGenerator<T3>::iterator end3_;\n    typename ParamGenerator<T3>::iterator current3_;\n    ParamType current_value_;\n  };  // class CartesianProductGenerator3::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductGenerator3& other);\n\n  const ParamGenerator<T1> g1_;\n  const ParamGenerator<T2> g2_;\n  const ParamGenerator<T3> g3_;\n};  // class CartesianProductGenerator3\n\n\ntemplate <typename T1, typename T2, typename T3, typename T4>\nclass CartesianProductGenerator4\n    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4> > {\n public:\n  typedef ::std::tr1::tuple<T1, T2, T3, T4> ParamType;\n\n  CartesianProductGenerator4(const ParamGenerator<T1>& g1,\n      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,\n      const ParamGenerator<T4>& g4)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4) {}\n  virtual ~CartesianProductGenerator4() {}\n\n  virtual ParamIteratorInterface<ParamType>* Begin() const {\n    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,\n        g3_.begin(), g4_, g4_.begin());\n  }\n  virtual ParamIteratorInterface<ParamType>* End() const {\n    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),\n        g4_, g4_.end());\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<ParamType> {\n   public:\n    Iterator(const ParamGeneratorInterface<ParamType>* base,\n      const ParamGenerator<T1>& g1,\n      const typename ParamGenerator<T1>::iterator& current1,\n      const ParamGenerator<T2>& g2,\n      const typename ParamGenerator<T2>::iterator& current2,\n      const ParamGenerator<T3>& g3,\n      const typename ParamGenerator<T3>::iterator& current3,\n      const ParamGenerator<T4>& g4,\n      const typename ParamGenerator<T4>::iterator& current4)\n        : base_(base),\n          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),\n          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),\n          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),\n          begin4_(g4.begin()), end4_(g4.end()), current4_(current4)    {\n      ComputeCurrentValue();\n    }\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {\n      return base_;\n    }\n    // Advance should not be called on beyond-of-range iterators\n    // so no component iterators must be beyond end of range, either.\n    virtual void Advance() {\n      assert(!AtEnd());\n      ++current4_;\n      if (current4_ == end4_) {\n        current4_ = begin4_;\n        ++current3_;\n      }\n      if (current3_ == end3_) {\n        current3_ = begin3_;\n        ++current2_;\n      }\n      if (current2_ == end2_) {\n        current2_ = begin2_;\n        ++current1_;\n      }\n      ComputeCurrentValue();\n    }\n    virtual ParamIteratorInterface<ParamType>* Clone() const {\n      return new Iterator(*this);\n    }\n    virtual const ParamType* Current() const { return &current_value_; }\n    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const Iterator* typed_other =\n          CheckedDowncastToActualType<const Iterator>(&other);\n      // We must report iterators equal if they both point beyond their\n      // respective ranges. That can happen in a variety of fashions,\n      // so we have to consult AtEnd().\n      return (AtEnd() && typed_other->AtEnd()) ||\n         (\n          current1_ == typed_other->current1_ &&\n          current2_ == typed_other->current2_ &&\n          current3_ == typed_other->current3_ &&\n          current4_ == typed_other->current4_);\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : base_(other.base_),\n        begin1_(other.begin1_),\n        end1_(other.end1_),\n        current1_(other.current1_),\n        begin2_(other.begin2_),\n        end2_(other.end2_),\n        current2_(other.current2_),\n        begin3_(other.begin3_),\n        end3_(other.end3_),\n        current3_(other.current3_),\n        begin4_(other.begin4_),\n        end4_(other.end4_),\n        current4_(other.current4_) {\n      ComputeCurrentValue();\n    }\n\n    void ComputeCurrentValue() {\n      if (!AtEnd())\n        current_value_ = ParamType(*current1_, *current2_, *current3_,\n            *current4_);\n    }\n    bool AtEnd() const {\n      // We must report iterator past the end of the range when either of the\n      // component iterators has reached the end of its range.\n      return\n          current1_ == end1_ ||\n          current2_ == end2_ ||\n          current3_ == end3_ ||\n          current4_ == end4_;\n    }\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<ParamType>* const base_;\n    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.\n    // current[i]_ is the actual traversing iterator.\n    const typename ParamGenerator<T1>::iterator begin1_;\n    const typename ParamGenerator<T1>::iterator end1_;\n    typename ParamGenerator<T1>::iterator current1_;\n    const typename ParamGenerator<T2>::iterator begin2_;\n    const typename ParamGenerator<T2>::iterator end2_;\n    typename ParamGenerator<T2>::iterator current2_;\n    const typename ParamGenerator<T3>::iterator begin3_;\n    const typename ParamGenerator<T3>::iterator end3_;\n    typename ParamGenerator<T3>::iterator current3_;\n    const typename ParamGenerator<T4>::iterator begin4_;\n    const typename ParamGenerator<T4>::iterator end4_;\n    typename ParamGenerator<T4>::iterator current4_;\n    ParamType current_value_;\n  };  // class CartesianProductGenerator4::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductGenerator4& other);\n\n  const ParamGenerator<T1> g1_;\n  const ParamGenerator<T2> g2_;\n  const ParamGenerator<T3> g3_;\n  const ParamGenerator<T4> g4_;\n};  // class CartesianProductGenerator4\n\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5>\nclass CartesianProductGenerator5\n    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5> > {\n public:\n  typedef ::std::tr1::tuple<T1, T2, T3, T4, T5> ParamType;\n\n  CartesianProductGenerator5(const ParamGenerator<T1>& g1,\n      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,\n      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5) {}\n  virtual ~CartesianProductGenerator5() {}\n\n  virtual ParamIteratorInterface<ParamType>* Begin() const {\n    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,\n        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin());\n  }\n  virtual ParamIteratorInterface<ParamType>* End() const {\n    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),\n        g4_, g4_.end(), g5_, g5_.end());\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<ParamType> {\n   public:\n    Iterator(const ParamGeneratorInterface<ParamType>* base,\n      const ParamGenerator<T1>& g1,\n      const typename ParamGenerator<T1>::iterator& current1,\n      const ParamGenerator<T2>& g2,\n      const typename ParamGenerator<T2>::iterator& current2,\n      const ParamGenerator<T3>& g3,\n      const typename ParamGenerator<T3>::iterator& current3,\n      const ParamGenerator<T4>& g4,\n      const typename ParamGenerator<T4>::iterator& current4,\n      const ParamGenerator<T5>& g5,\n      const typename ParamGenerator<T5>::iterator& current5)\n        : base_(base),\n          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),\n          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),\n          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),\n          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),\n          begin5_(g5.begin()), end5_(g5.end()), current5_(current5)    {\n      ComputeCurrentValue();\n    }\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {\n      return base_;\n    }\n    // Advance should not be called on beyond-of-range iterators\n    // so no component iterators must be beyond end of range, either.\n    virtual void Advance() {\n      assert(!AtEnd());\n      ++current5_;\n      if (current5_ == end5_) {\n        current5_ = begin5_;\n        ++current4_;\n      }\n      if (current4_ == end4_) {\n        current4_ = begin4_;\n        ++current3_;\n      }\n      if (current3_ == end3_) {\n        current3_ = begin3_;\n        ++current2_;\n      }\n      if (current2_ == end2_) {\n        current2_ = begin2_;\n        ++current1_;\n      }\n      ComputeCurrentValue();\n    }\n    virtual ParamIteratorInterface<ParamType>* Clone() const {\n      return new Iterator(*this);\n    }\n    virtual const ParamType* Current() const { return &current_value_; }\n    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const Iterator* typed_other =\n          CheckedDowncastToActualType<const Iterator>(&other);\n      // We must report iterators equal if they both point beyond their\n      // respective ranges. That can happen in a variety of fashions,\n      // so we have to consult AtEnd().\n      return (AtEnd() && typed_other->AtEnd()) ||\n         (\n          current1_ == typed_other->current1_ &&\n          current2_ == typed_other->current2_ &&\n          current3_ == typed_other->current3_ &&\n          current4_ == typed_other->current4_ &&\n          current5_ == typed_other->current5_);\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : base_(other.base_),\n        begin1_(other.begin1_),\n        end1_(other.end1_),\n        current1_(other.current1_),\n        begin2_(other.begin2_),\n        end2_(other.end2_),\n        current2_(other.current2_),\n        begin3_(other.begin3_),\n        end3_(other.end3_),\n        current3_(other.current3_),\n        begin4_(other.begin4_),\n        end4_(other.end4_),\n        current4_(other.current4_),\n        begin5_(other.begin5_),\n        end5_(other.end5_),\n        current5_(other.current5_) {\n      ComputeCurrentValue();\n    }\n\n    void ComputeCurrentValue() {\n      if (!AtEnd())\n        current_value_ = ParamType(*current1_, *current2_, *current3_,\n            *current4_, *current5_);\n    }\n    bool AtEnd() const {\n      // We must report iterator past the end of the range when either of the\n      // component iterators has reached the end of its range.\n      return\n          current1_ == end1_ ||\n          current2_ == end2_ ||\n          current3_ == end3_ ||\n          current4_ == end4_ ||\n          current5_ == end5_;\n    }\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<ParamType>* const base_;\n    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.\n    // current[i]_ is the actual traversing iterator.\n    const typename ParamGenerator<T1>::iterator begin1_;\n    const typename ParamGenerator<T1>::iterator end1_;\n    typename ParamGenerator<T1>::iterator current1_;\n    const typename ParamGenerator<T2>::iterator begin2_;\n    const typename ParamGenerator<T2>::iterator end2_;\n    typename ParamGenerator<T2>::iterator current2_;\n    const typename ParamGenerator<T3>::iterator begin3_;\n    const typename ParamGenerator<T3>::iterator end3_;\n    typename ParamGenerator<T3>::iterator current3_;\n    const typename ParamGenerator<T4>::iterator begin4_;\n    const typename ParamGenerator<T4>::iterator end4_;\n    typename ParamGenerator<T4>::iterator current4_;\n    const typename ParamGenerator<T5>::iterator begin5_;\n    const typename ParamGenerator<T5>::iterator end5_;\n    typename ParamGenerator<T5>::iterator current5_;\n    ParamType current_value_;\n  };  // class CartesianProductGenerator5::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductGenerator5& other);\n\n  const ParamGenerator<T1> g1_;\n  const ParamGenerator<T2> g2_;\n  const ParamGenerator<T3> g3_;\n  const ParamGenerator<T4> g4_;\n  const ParamGenerator<T5> g5_;\n};  // class CartesianProductGenerator5\n\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6>\nclass CartesianProductGenerator6\n    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5,\n        T6> > {\n public:\n  typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6> ParamType;\n\n  CartesianProductGenerator6(const ParamGenerator<T1>& g1,\n      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,\n      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,\n      const ParamGenerator<T6>& g6)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6) {}\n  virtual ~CartesianProductGenerator6() {}\n\n  virtual ParamIteratorInterface<ParamType>* Begin() const {\n    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,\n        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin());\n  }\n  virtual ParamIteratorInterface<ParamType>* End() const {\n    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),\n        g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end());\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<ParamType> {\n   public:\n    Iterator(const ParamGeneratorInterface<ParamType>* base,\n      const ParamGenerator<T1>& g1,\n      const typename ParamGenerator<T1>::iterator& current1,\n      const ParamGenerator<T2>& g2,\n      const typename ParamGenerator<T2>::iterator& current2,\n      const ParamGenerator<T3>& g3,\n      const typename ParamGenerator<T3>::iterator& current3,\n      const ParamGenerator<T4>& g4,\n      const typename ParamGenerator<T4>::iterator& current4,\n      const ParamGenerator<T5>& g5,\n      const typename ParamGenerator<T5>::iterator& current5,\n      const ParamGenerator<T6>& g6,\n      const typename ParamGenerator<T6>::iterator& current6)\n        : base_(base),\n          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),\n          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),\n          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),\n          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),\n          begin5_(g5.begin()), end5_(g5.end()), current5_(current5),\n          begin6_(g6.begin()), end6_(g6.end()), current6_(current6)    {\n      ComputeCurrentValue();\n    }\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {\n      return base_;\n    }\n    // Advance should not be called on beyond-of-range iterators\n    // so no component iterators must be beyond end of range, either.\n    virtual void Advance() {\n      assert(!AtEnd());\n      ++current6_;\n      if (current6_ == end6_) {\n        current6_ = begin6_;\n        ++current5_;\n      }\n      if (current5_ == end5_) {\n        current5_ = begin5_;\n        ++current4_;\n      }\n      if (current4_ == end4_) {\n        current4_ = begin4_;\n        ++current3_;\n      }\n      if (current3_ == end3_) {\n        current3_ = begin3_;\n        ++current2_;\n      }\n      if (current2_ == end2_) {\n        current2_ = begin2_;\n        ++current1_;\n      }\n      ComputeCurrentValue();\n    }\n    virtual ParamIteratorInterface<ParamType>* Clone() const {\n      return new Iterator(*this);\n    }\n    virtual const ParamType* Current() const { return &current_value_; }\n    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const Iterator* typed_other =\n          CheckedDowncastToActualType<const Iterator>(&other);\n      // We must report iterators equal if they both point beyond their\n      // respective ranges. That can happen in a variety of fashions,\n      // so we have to consult AtEnd().\n      return (AtEnd() && typed_other->AtEnd()) ||\n         (\n          current1_ == typed_other->current1_ &&\n          current2_ == typed_other->current2_ &&\n          current3_ == typed_other->current3_ &&\n          current4_ == typed_other->current4_ &&\n          current5_ == typed_other->current5_ &&\n          current6_ == typed_other->current6_);\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : base_(other.base_),\n        begin1_(other.begin1_),\n        end1_(other.end1_),\n        current1_(other.current1_),\n        begin2_(other.begin2_),\n        end2_(other.end2_),\n        current2_(other.current2_),\n        begin3_(other.begin3_),\n        end3_(other.end3_),\n        current3_(other.current3_),\n        begin4_(other.begin4_),\n        end4_(other.end4_),\n        current4_(other.current4_),\n        begin5_(other.begin5_),\n        end5_(other.end5_),\n        current5_(other.current5_),\n        begin6_(other.begin6_),\n        end6_(other.end6_),\n        current6_(other.current6_) {\n      ComputeCurrentValue();\n    }\n\n    void ComputeCurrentValue() {\n      if (!AtEnd())\n        current_value_ = ParamType(*current1_, *current2_, *current3_,\n            *current4_, *current5_, *current6_);\n    }\n    bool AtEnd() const {\n      // We must report iterator past the end of the range when either of the\n      // component iterators has reached the end of its range.\n      return\n          current1_ == end1_ ||\n          current2_ == end2_ ||\n          current3_ == end3_ ||\n          current4_ == end4_ ||\n          current5_ == end5_ ||\n          current6_ == end6_;\n    }\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<ParamType>* const base_;\n    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.\n    // current[i]_ is the actual traversing iterator.\n    const typename ParamGenerator<T1>::iterator begin1_;\n    const typename ParamGenerator<T1>::iterator end1_;\n    typename ParamGenerator<T1>::iterator current1_;\n    const typename ParamGenerator<T2>::iterator begin2_;\n    const typename ParamGenerator<T2>::iterator end2_;\n    typename ParamGenerator<T2>::iterator current2_;\n    const typename ParamGenerator<T3>::iterator begin3_;\n    const typename ParamGenerator<T3>::iterator end3_;\n    typename ParamGenerator<T3>::iterator current3_;\n    const typename ParamGenerator<T4>::iterator begin4_;\n    const typename ParamGenerator<T4>::iterator end4_;\n    typename ParamGenerator<T4>::iterator current4_;\n    const typename ParamGenerator<T5>::iterator begin5_;\n    const typename ParamGenerator<T5>::iterator end5_;\n    typename ParamGenerator<T5>::iterator current5_;\n    const typename ParamGenerator<T6>::iterator begin6_;\n    const typename ParamGenerator<T6>::iterator end6_;\n    typename ParamGenerator<T6>::iterator current6_;\n    ParamType current_value_;\n  };  // class CartesianProductGenerator6::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductGenerator6& other);\n\n  const ParamGenerator<T1> g1_;\n  const ParamGenerator<T2> g2_;\n  const ParamGenerator<T3> g3_;\n  const ParamGenerator<T4> g4_;\n  const ParamGenerator<T5> g5_;\n  const ParamGenerator<T6> g6_;\n};  // class CartesianProductGenerator6\n\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7>\nclass CartesianProductGenerator7\n    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6,\n        T7> > {\n public:\n  typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7> ParamType;\n\n  CartesianProductGenerator7(const ParamGenerator<T1>& g1,\n      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,\n      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,\n      const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7) {}\n  virtual ~CartesianProductGenerator7() {}\n\n  virtual ParamIteratorInterface<ParamType>* Begin() const {\n    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,\n        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,\n        g7_.begin());\n  }\n  virtual ParamIteratorInterface<ParamType>* End() const {\n    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),\n        g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end());\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<ParamType> {\n   public:\n    Iterator(const ParamGeneratorInterface<ParamType>* base,\n      const ParamGenerator<T1>& g1,\n      const typename ParamGenerator<T1>::iterator& current1,\n      const ParamGenerator<T2>& g2,\n      const typename ParamGenerator<T2>::iterator& current2,\n      const ParamGenerator<T3>& g3,\n      const typename ParamGenerator<T3>::iterator& current3,\n      const ParamGenerator<T4>& g4,\n      const typename ParamGenerator<T4>::iterator& current4,\n      const ParamGenerator<T5>& g5,\n      const typename ParamGenerator<T5>::iterator& current5,\n      const ParamGenerator<T6>& g6,\n      const typename ParamGenerator<T6>::iterator& current6,\n      const ParamGenerator<T7>& g7,\n      const typename ParamGenerator<T7>::iterator& current7)\n        : base_(base),\n          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),\n          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),\n          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),\n          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),\n          begin5_(g5.begin()), end5_(g5.end()), current5_(current5),\n          begin6_(g6.begin()), end6_(g6.end()), current6_(current6),\n          begin7_(g7.begin()), end7_(g7.end()), current7_(current7)    {\n      ComputeCurrentValue();\n    }\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {\n      return base_;\n    }\n    // Advance should not be called on beyond-of-range iterators\n    // so no component iterators must be beyond end of range, either.\n    virtual void Advance() {\n      assert(!AtEnd());\n      ++current7_;\n      if (current7_ == end7_) {\n        current7_ = begin7_;\n        ++current6_;\n      }\n      if (current6_ == end6_) {\n        current6_ = begin6_;\n        ++current5_;\n      }\n      if (current5_ == end5_) {\n        current5_ = begin5_;\n        ++current4_;\n      }\n      if (current4_ == end4_) {\n        current4_ = begin4_;\n        ++current3_;\n      }\n      if (current3_ == end3_) {\n        current3_ = begin3_;\n        ++current2_;\n      }\n      if (current2_ == end2_) {\n        current2_ = begin2_;\n        ++current1_;\n      }\n      ComputeCurrentValue();\n    }\n    virtual ParamIteratorInterface<ParamType>* Clone() const {\n      return new Iterator(*this);\n    }\n    virtual const ParamType* Current() const { return &current_value_; }\n    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const Iterator* typed_other =\n          CheckedDowncastToActualType<const Iterator>(&other);\n      // We must report iterators equal if they both point beyond their\n      // respective ranges. That can happen in a variety of fashions,\n      // so we have to consult AtEnd().\n      return (AtEnd() && typed_other->AtEnd()) ||\n         (\n          current1_ == typed_other->current1_ &&\n          current2_ == typed_other->current2_ &&\n          current3_ == typed_other->current3_ &&\n          current4_ == typed_other->current4_ &&\n          current5_ == typed_other->current5_ &&\n          current6_ == typed_other->current6_ &&\n          current7_ == typed_other->current7_);\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : base_(other.base_),\n        begin1_(other.begin1_),\n        end1_(other.end1_),\n        current1_(other.current1_),\n        begin2_(other.begin2_),\n        end2_(other.end2_),\n        current2_(other.current2_),\n        begin3_(other.begin3_),\n        end3_(other.end3_),\n        current3_(other.current3_),\n        begin4_(other.begin4_),\n        end4_(other.end4_),\n        current4_(other.current4_),\n        begin5_(other.begin5_),\n        end5_(other.end5_),\n        current5_(other.current5_),\n        begin6_(other.begin6_),\n        end6_(other.end6_),\n        current6_(other.current6_),\n        begin7_(other.begin7_),\n        end7_(other.end7_),\n        current7_(other.current7_) {\n      ComputeCurrentValue();\n    }\n\n    void ComputeCurrentValue() {\n      if (!AtEnd())\n        current_value_ = ParamType(*current1_, *current2_, *current3_,\n            *current4_, *current5_, *current6_, *current7_);\n    }\n    bool AtEnd() const {\n      // We must report iterator past the end of the range when either of the\n      // component iterators has reached the end of its range.\n      return\n          current1_ == end1_ ||\n          current2_ == end2_ ||\n          current3_ == end3_ ||\n          current4_ == end4_ ||\n          current5_ == end5_ ||\n          current6_ == end6_ ||\n          current7_ == end7_;\n    }\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<ParamType>* const base_;\n    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.\n    // current[i]_ is the actual traversing iterator.\n    const typename ParamGenerator<T1>::iterator begin1_;\n    const typename ParamGenerator<T1>::iterator end1_;\n    typename ParamGenerator<T1>::iterator current1_;\n    const typename ParamGenerator<T2>::iterator begin2_;\n    const typename ParamGenerator<T2>::iterator end2_;\n    typename ParamGenerator<T2>::iterator current2_;\n    const typename ParamGenerator<T3>::iterator begin3_;\n    const typename ParamGenerator<T3>::iterator end3_;\n    typename ParamGenerator<T3>::iterator current3_;\n    const typename ParamGenerator<T4>::iterator begin4_;\n    const typename ParamGenerator<T4>::iterator end4_;\n    typename ParamGenerator<T4>::iterator current4_;\n    const typename ParamGenerator<T5>::iterator begin5_;\n    const typename ParamGenerator<T5>::iterator end5_;\n    typename ParamGenerator<T5>::iterator current5_;\n    const typename ParamGenerator<T6>::iterator begin6_;\n    const typename ParamGenerator<T6>::iterator end6_;\n    typename ParamGenerator<T6>::iterator current6_;\n    const typename ParamGenerator<T7>::iterator begin7_;\n    const typename ParamGenerator<T7>::iterator end7_;\n    typename ParamGenerator<T7>::iterator current7_;\n    ParamType current_value_;\n  };  // class CartesianProductGenerator7::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductGenerator7& other);\n\n  const ParamGenerator<T1> g1_;\n  const ParamGenerator<T2> g2_;\n  const ParamGenerator<T3> g3_;\n  const ParamGenerator<T4> g4_;\n  const ParamGenerator<T5> g5_;\n  const ParamGenerator<T6> g6_;\n  const ParamGenerator<T7> g7_;\n};  // class CartesianProductGenerator7\n\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8>\nclass CartesianProductGenerator8\n    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6,\n        T7, T8> > {\n public:\n  typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8> ParamType;\n\n  CartesianProductGenerator8(const ParamGenerator<T1>& g1,\n      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,\n      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,\n      const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7,\n      const ParamGenerator<T8>& g8)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7),\n          g8_(g8) {}\n  virtual ~CartesianProductGenerator8() {}\n\n  virtual ParamIteratorInterface<ParamType>* Begin() const {\n    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,\n        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,\n        g7_.begin(), g8_, g8_.begin());\n  }\n  virtual ParamIteratorInterface<ParamType>* End() const {\n    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),\n        g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end(), g8_,\n        g8_.end());\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<ParamType> {\n   public:\n    Iterator(const ParamGeneratorInterface<ParamType>* base,\n      const ParamGenerator<T1>& g1,\n      const typename ParamGenerator<T1>::iterator& current1,\n      const ParamGenerator<T2>& g2,\n      const typename ParamGenerator<T2>::iterator& current2,\n      const ParamGenerator<T3>& g3,\n      const typename ParamGenerator<T3>::iterator& current3,\n      const ParamGenerator<T4>& g4,\n      const typename ParamGenerator<T4>::iterator& current4,\n      const ParamGenerator<T5>& g5,\n      const typename ParamGenerator<T5>::iterator& current5,\n      const ParamGenerator<T6>& g6,\n      const typename ParamGenerator<T6>::iterator& current6,\n      const ParamGenerator<T7>& g7,\n      const typename ParamGenerator<T7>::iterator& current7,\n      const ParamGenerator<T8>& g8,\n      const typename ParamGenerator<T8>::iterator& current8)\n        : base_(base),\n          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),\n          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),\n          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),\n          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),\n          begin5_(g5.begin()), end5_(g5.end()), current5_(current5),\n          begin6_(g6.begin()), end6_(g6.end()), current6_(current6),\n          begin7_(g7.begin()), end7_(g7.end()), current7_(current7),\n          begin8_(g8.begin()), end8_(g8.end()), current8_(current8)    {\n      ComputeCurrentValue();\n    }\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {\n      return base_;\n    }\n    // Advance should not be called on beyond-of-range iterators\n    // so no component iterators must be beyond end of range, either.\n    virtual void Advance() {\n      assert(!AtEnd());\n      ++current8_;\n      if (current8_ == end8_) {\n        current8_ = begin8_;\n        ++current7_;\n      }\n      if (current7_ == end7_) {\n        current7_ = begin7_;\n        ++current6_;\n      }\n      if (current6_ == end6_) {\n        current6_ = begin6_;\n        ++current5_;\n      }\n      if (current5_ == end5_) {\n        current5_ = begin5_;\n        ++current4_;\n      }\n      if (current4_ == end4_) {\n        current4_ = begin4_;\n        ++current3_;\n      }\n      if (current3_ == end3_) {\n        current3_ = begin3_;\n        ++current2_;\n      }\n      if (current2_ == end2_) {\n        current2_ = begin2_;\n        ++current1_;\n      }\n      ComputeCurrentValue();\n    }\n    virtual ParamIteratorInterface<ParamType>* Clone() const {\n      return new Iterator(*this);\n    }\n    virtual const ParamType* Current() const { return &current_value_; }\n    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const Iterator* typed_other =\n          CheckedDowncastToActualType<const Iterator>(&other);\n      // We must report iterators equal if they both point beyond their\n      // respective ranges. That can happen in a variety of fashions,\n      // so we have to consult AtEnd().\n      return (AtEnd() && typed_other->AtEnd()) ||\n         (\n          current1_ == typed_other->current1_ &&\n          current2_ == typed_other->current2_ &&\n          current3_ == typed_other->current3_ &&\n          current4_ == typed_other->current4_ &&\n          current5_ == typed_other->current5_ &&\n          current6_ == typed_other->current6_ &&\n          current7_ == typed_other->current7_ &&\n          current8_ == typed_other->current8_);\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : base_(other.base_),\n        begin1_(other.begin1_),\n        end1_(other.end1_),\n        current1_(other.current1_),\n        begin2_(other.begin2_),\n        end2_(other.end2_),\n        current2_(other.current2_),\n        begin3_(other.begin3_),\n        end3_(other.end3_),\n        current3_(other.current3_),\n        begin4_(other.begin4_),\n        end4_(other.end4_),\n        current4_(other.current4_),\n        begin5_(other.begin5_),\n        end5_(other.end5_),\n        current5_(other.current5_),\n        begin6_(other.begin6_),\n        end6_(other.end6_),\n        current6_(other.current6_),\n        begin7_(other.begin7_),\n        end7_(other.end7_),\n        current7_(other.current7_),\n        begin8_(other.begin8_),\n        end8_(other.end8_),\n        current8_(other.current8_) {\n      ComputeCurrentValue();\n    }\n\n    void ComputeCurrentValue() {\n      if (!AtEnd())\n        current_value_ = ParamType(*current1_, *current2_, *current3_,\n            *current4_, *current5_, *current6_, *current7_, *current8_);\n    }\n    bool AtEnd() const {\n      // We must report iterator past the end of the range when either of the\n      // component iterators has reached the end of its range.\n      return\n          current1_ == end1_ ||\n          current2_ == end2_ ||\n          current3_ == end3_ ||\n          current4_ == end4_ ||\n          current5_ == end5_ ||\n          current6_ == end6_ ||\n          current7_ == end7_ ||\n          current8_ == end8_;\n    }\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<ParamType>* const base_;\n    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.\n    // current[i]_ is the actual traversing iterator.\n    const typename ParamGenerator<T1>::iterator begin1_;\n    const typename ParamGenerator<T1>::iterator end1_;\n    typename ParamGenerator<T1>::iterator current1_;\n    const typename ParamGenerator<T2>::iterator begin2_;\n    const typename ParamGenerator<T2>::iterator end2_;\n    typename ParamGenerator<T2>::iterator current2_;\n    const typename ParamGenerator<T3>::iterator begin3_;\n    const typename ParamGenerator<T3>::iterator end3_;\n    typename ParamGenerator<T3>::iterator current3_;\n    const typename ParamGenerator<T4>::iterator begin4_;\n    const typename ParamGenerator<T4>::iterator end4_;\n    typename ParamGenerator<T4>::iterator current4_;\n    const typename ParamGenerator<T5>::iterator begin5_;\n    const typename ParamGenerator<T5>::iterator end5_;\n    typename ParamGenerator<T5>::iterator current5_;\n    const typename ParamGenerator<T6>::iterator begin6_;\n    const typename ParamGenerator<T6>::iterator end6_;\n    typename ParamGenerator<T6>::iterator current6_;\n    const typename ParamGenerator<T7>::iterator begin7_;\n    const typename ParamGenerator<T7>::iterator end7_;\n    typename ParamGenerator<T7>::iterator current7_;\n    const typename ParamGenerator<T8>::iterator begin8_;\n    const typename ParamGenerator<T8>::iterator end8_;\n    typename ParamGenerator<T8>::iterator current8_;\n    ParamType current_value_;\n  };  // class CartesianProductGenerator8::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductGenerator8& other);\n\n  const ParamGenerator<T1> g1_;\n  const ParamGenerator<T2> g2_;\n  const ParamGenerator<T3> g3_;\n  const ParamGenerator<T4> g4_;\n  const ParamGenerator<T5> g5_;\n  const ParamGenerator<T6> g6_;\n  const ParamGenerator<T7> g7_;\n  const ParamGenerator<T8> g8_;\n};  // class CartesianProductGenerator8\n\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9>\nclass CartesianProductGenerator9\n    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6,\n        T7, T8, T9> > {\n public:\n  typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9> ParamType;\n\n  CartesianProductGenerator9(const ParamGenerator<T1>& g1,\n      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,\n      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,\n      const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7,\n      const ParamGenerator<T8>& g8, const ParamGenerator<T9>& g9)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),\n          g9_(g9) {}\n  virtual ~CartesianProductGenerator9() {}\n\n  virtual ParamIteratorInterface<ParamType>* Begin() const {\n    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,\n        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,\n        g7_.begin(), g8_, g8_.begin(), g9_, g9_.begin());\n  }\n  virtual ParamIteratorInterface<ParamType>* End() const {\n    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),\n        g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end(), g8_,\n        g8_.end(), g9_, g9_.end());\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<ParamType> {\n   public:\n    Iterator(const ParamGeneratorInterface<ParamType>* base,\n      const ParamGenerator<T1>& g1,\n      const typename ParamGenerator<T1>::iterator& current1,\n      const ParamGenerator<T2>& g2,\n      const typename ParamGenerator<T2>::iterator& current2,\n      const ParamGenerator<T3>& g3,\n      const typename ParamGenerator<T3>::iterator& current3,\n      const ParamGenerator<T4>& g4,\n      const typename ParamGenerator<T4>::iterator& current4,\n      const ParamGenerator<T5>& g5,\n      const typename ParamGenerator<T5>::iterator& current5,\n      const ParamGenerator<T6>& g6,\n      const typename ParamGenerator<T6>::iterator& current6,\n      const ParamGenerator<T7>& g7,\n      const typename ParamGenerator<T7>::iterator& current7,\n      const ParamGenerator<T8>& g8,\n      const typename ParamGenerator<T8>::iterator& current8,\n      const ParamGenerator<T9>& g9,\n      const typename ParamGenerator<T9>::iterator& current9)\n        : base_(base),\n          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),\n          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),\n          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),\n          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),\n          begin5_(g5.begin()), end5_(g5.end()), current5_(current5),\n          begin6_(g6.begin()), end6_(g6.end()), current6_(current6),\n          begin7_(g7.begin()), end7_(g7.end()), current7_(current7),\n          begin8_(g8.begin()), end8_(g8.end()), current8_(current8),\n          begin9_(g9.begin()), end9_(g9.end()), current9_(current9)    {\n      ComputeCurrentValue();\n    }\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {\n      return base_;\n    }\n    // Advance should not be called on beyond-of-range iterators\n    // so no component iterators must be beyond end of range, either.\n    virtual void Advance() {\n      assert(!AtEnd());\n      ++current9_;\n      if (current9_ == end9_) {\n        current9_ = begin9_;\n        ++current8_;\n      }\n      if (current8_ == end8_) {\n        current8_ = begin8_;\n        ++current7_;\n      }\n      if (current7_ == end7_) {\n        current7_ = begin7_;\n        ++current6_;\n      }\n      if (current6_ == end6_) {\n        current6_ = begin6_;\n        ++current5_;\n      }\n      if (current5_ == end5_) {\n        current5_ = begin5_;\n        ++current4_;\n      }\n      if (current4_ == end4_) {\n        current4_ = begin4_;\n        ++current3_;\n      }\n      if (current3_ == end3_) {\n        current3_ = begin3_;\n        ++current2_;\n      }\n      if (current2_ == end2_) {\n        current2_ = begin2_;\n        ++current1_;\n      }\n      ComputeCurrentValue();\n    }\n    virtual ParamIteratorInterface<ParamType>* Clone() const {\n      return new Iterator(*this);\n    }\n    virtual const ParamType* Current() const { return &current_value_; }\n    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const Iterator* typed_other =\n          CheckedDowncastToActualType<const Iterator>(&other);\n      // We must report iterators equal if they both point beyond their\n      // respective ranges. That can happen in a variety of fashions,\n      // so we have to consult AtEnd().\n      return (AtEnd() && typed_other->AtEnd()) ||\n         (\n          current1_ == typed_other->current1_ &&\n          current2_ == typed_other->current2_ &&\n          current3_ == typed_other->current3_ &&\n          current4_ == typed_other->current4_ &&\n          current5_ == typed_other->current5_ &&\n          current6_ == typed_other->current6_ &&\n          current7_ == typed_other->current7_ &&\n          current8_ == typed_other->current8_ &&\n          current9_ == typed_other->current9_);\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : base_(other.base_),\n        begin1_(other.begin1_),\n        end1_(other.end1_),\n        current1_(other.current1_),\n        begin2_(other.begin2_),\n        end2_(other.end2_),\n        current2_(other.current2_),\n        begin3_(other.begin3_),\n        end3_(other.end3_),\n        current3_(other.current3_),\n        begin4_(other.begin4_),\n        end4_(other.end4_),\n        current4_(other.current4_),\n        begin5_(other.begin5_),\n        end5_(other.end5_),\n        current5_(other.current5_),\n        begin6_(other.begin6_),\n        end6_(other.end6_),\n        current6_(other.current6_),\n        begin7_(other.begin7_),\n        end7_(other.end7_),\n        current7_(other.current7_),\n        begin8_(other.begin8_),\n        end8_(other.end8_),\n        current8_(other.current8_),\n        begin9_(other.begin9_),\n        end9_(other.end9_),\n        current9_(other.current9_) {\n      ComputeCurrentValue();\n    }\n\n    void ComputeCurrentValue() {\n      if (!AtEnd())\n        current_value_ = ParamType(*current1_, *current2_, *current3_,\n            *current4_, *current5_, *current6_, *current7_, *current8_,\n            *current9_);\n    }\n    bool AtEnd() const {\n      // We must report iterator past the end of the range when either of the\n      // component iterators has reached the end of its range.\n      return\n          current1_ == end1_ ||\n          current2_ == end2_ ||\n          current3_ == end3_ ||\n          current4_ == end4_ ||\n          current5_ == end5_ ||\n          current6_ == end6_ ||\n          current7_ == end7_ ||\n          current8_ == end8_ ||\n          current9_ == end9_;\n    }\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<ParamType>* const base_;\n    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.\n    // current[i]_ is the actual traversing iterator.\n    const typename ParamGenerator<T1>::iterator begin1_;\n    const typename ParamGenerator<T1>::iterator end1_;\n    typename ParamGenerator<T1>::iterator current1_;\n    const typename ParamGenerator<T2>::iterator begin2_;\n    const typename ParamGenerator<T2>::iterator end2_;\n    typename ParamGenerator<T2>::iterator current2_;\n    const typename ParamGenerator<T3>::iterator begin3_;\n    const typename ParamGenerator<T3>::iterator end3_;\n    typename ParamGenerator<T3>::iterator current3_;\n    const typename ParamGenerator<T4>::iterator begin4_;\n    const typename ParamGenerator<T4>::iterator end4_;\n    typename ParamGenerator<T4>::iterator current4_;\n    const typename ParamGenerator<T5>::iterator begin5_;\n    const typename ParamGenerator<T5>::iterator end5_;\n    typename ParamGenerator<T5>::iterator current5_;\n    const typename ParamGenerator<T6>::iterator begin6_;\n    const typename ParamGenerator<T6>::iterator end6_;\n    typename ParamGenerator<T6>::iterator current6_;\n    const typename ParamGenerator<T7>::iterator begin7_;\n    const typename ParamGenerator<T7>::iterator end7_;\n    typename ParamGenerator<T7>::iterator current7_;\n    const typename ParamGenerator<T8>::iterator begin8_;\n    const typename ParamGenerator<T8>::iterator end8_;\n    typename ParamGenerator<T8>::iterator current8_;\n    const typename ParamGenerator<T9>::iterator begin9_;\n    const typename ParamGenerator<T9>::iterator end9_;\n    typename ParamGenerator<T9>::iterator current9_;\n    ParamType current_value_;\n  };  // class CartesianProductGenerator9::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductGenerator9& other);\n\n  const ParamGenerator<T1> g1_;\n  const ParamGenerator<T2> g2_;\n  const ParamGenerator<T3> g3_;\n  const ParamGenerator<T4> g4_;\n  const ParamGenerator<T5> g5_;\n  const ParamGenerator<T6> g6_;\n  const ParamGenerator<T7> g7_;\n  const ParamGenerator<T8> g8_;\n  const ParamGenerator<T9> g9_;\n};  // class CartesianProductGenerator9\n\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10>\nclass CartesianProductGenerator10\n    : public ParamGeneratorInterface< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6,\n        T7, T8, T9, T10> > {\n public:\n  typedef ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> ParamType;\n\n  CartesianProductGenerator10(const ParamGenerator<T1>& g1,\n      const ParamGenerator<T2>& g2, const ParamGenerator<T3>& g3,\n      const ParamGenerator<T4>& g4, const ParamGenerator<T5>& g5,\n      const ParamGenerator<T6>& g6, const ParamGenerator<T7>& g7,\n      const ParamGenerator<T8>& g8, const ParamGenerator<T9>& g9,\n      const ParamGenerator<T10>& g10)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),\n          g9_(g9), g10_(g10) {}\n  virtual ~CartesianProductGenerator10() {}\n\n  virtual ParamIteratorInterface<ParamType>* Begin() const {\n    return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_,\n        g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_,\n        g7_.begin(), g8_, g8_.begin(), g9_, g9_.begin(), g10_, g10_.begin());\n  }\n  virtual ParamIteratorInterface<ParamType>* End() const {\n    return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(),\n        g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end(), g8_,\n        g8_.end(), g9_, g9_.end(), g10_, g10_.end());\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<ParamType> {\n   public:\n    Iterator(const ParamGeneratorInterface<ParamType>* base,\n      const ParamGenerator<T1>& g1,\n      const typename ParamGenerator<T1>::iterator& current1,\n      const ParamGenerator<T2>& g2,\n      const typename ParamGenerator<T2>::iterator& current2,\n      const ParamGenerator<T3>& g3,\n      const typename ParamGenerator<T3>::iterator& current3,\n      const ParamGenerator<T4>& g4,\n      const typename ParamGenerator<T4>::iterator& current4,\n      const ParamGenerator<T5>& g5,\n      const typename ParamGenerator<T5>::iterator& current5,\n      const ParamGenerator<T6>& g6,\n      const typename ParamGenerator<T6>::iterator& current6,\n      const ParamGenerator<T7>& g7,\n      const typename ParamGenerator<T7>::iterator& current7,\n      const ParamGenerator<T8>& g8,\n      const typename ParamGenerator<T8>::iterator& current8,\n      const ParamGenerator<T9>& g9,\n      const typename ParamGenerator<T9>::iterator& current9,\n      const ParamGenerator<T10>& g10,\n      const typename ParamGenerator<T10>::iterator& current10)\n        : base_(base),\n          begin1_(g1.begin()), end1_(g1.end()), current1_(current1),\n          begin2_(g2.begin()), end2_(g2.end()), current2_(current2),\n          begin3_(g3.begin()), end3_(g3.end()), current3_(current3),\n          begin4_(g4.begin()), end4_(g4.end()), current4_(current4),\n          begin5_(g5.begin()), end5_(g5.end()), current5_(current5),\n          begin6_(g6.begin()), end6_(g6.end()), current6_(current6),\n          begin7_(g7.begin()), end7_(g7.end()), current7_(current7),\n          begin8_(g8.begin()), end8_(g8.end()), current8_(current8),\n          begin9_(g9.begin()), end9_(g9.end()), current9_(current9),\n          begin10_(g10.begin()), end10_(g10.end()), current10_(current10)    {\n      ComputeCurrentValue();\n    }\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {\n      return base_;\n    }\n    // Advance should not be called on beyond-of-range iterators\n    // so no component iterators must be beyond end of range, either.\n    virtual void Advance() {\n      assert(!AtEnd());\n      ++current10_;\n      if (current10_ == end10_) {\n        current10_ = begin10_;\n        ++current9_;\n      }\n      if (current9_ == end9_) {\n        current9_ = begin9_;\n        ++current8_;\n      }\n      if (current8_ == end8_) {\n        current8_ = begin8_;\n        ++current7_;\n      }\n      if (current7_ == end7_) {\n        current7_ = begin7_;\n        ++current6_;\n      }\n      if (current6_ == end6_) {\n        current6_ = begin6_;\n        ++current5_;\n      }\n      if (current5_ == end5_) {\n        current5_ = begin5_;\n        ++current4_;\n      }\n      if (current4_ == end4_) {\n        current4_ = begin4_;\n        ++current3_;\n      }\n      if (current3_ == end3_) {\n        current3_ = begin3_;\n        ++current2_;\n      }\n      if (current2_ == end2_) {\n        current2_ = begin2_;\n        ++current1_;\n      }\n      ComputeCurrentValue();\n    }\n    virtual ParamIteratorInterface<ParamType>* Clone() const {\n      return new Iterator(*this);\n    }\n    virtual const ParamType* Current() const { return &current_value_; }\n    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const Iterator* typed_other =\n          CheckedDowncastToActualType<const Iterator>(&other);\n      // We must report iterators equal if they both point beyond their\n      // respective ranges. That can happen in a variety of fashions,\n      // so we have to consult AtEnd().\n      return (AtEnd() && typed_other->AtEnd()) ||\n         (\n          current1_ == typed_other->current1_ &&\n          current2_ == typed_other->current2_ &&\n          current3_ == typed_other->current3_ &&\n          current4_ == typed_other->current4_ &&\n          current5_ == typed_other->current5_ &&\n          current6_ == typed_other->current6_ &&\n          current7_ == typed_other->current7_ &&\n          current8_ == typed_other->current8_ &&\n          current9_ == typed_other->current9_ &&\n          current10_ == typed_other->current10_);\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : base_(other.base_),\n        begin1_(other.begin1_),\n        end1_(other.end1_),\n        current1_(other.current1_),\n        begin2_(other.begin2_),\n        end2_(other.end2_),\n        current2_(other.current2_),\n        begin3_(other.begin3_),\n        end3_(other.end3_),\n        current3_(other.current3_),\n        begin4_(other.begin4_),\n        end4_(other.end4_),\n        current4_(other.current4_),\n        begin5_(other.begin5_),\n        end5_(other.end5_),\n        current5_(other.current5_),\n        begin6_(other.begin6_),\n        end6_(other.end6_),\n        current6_(other.current6_),\n        begin7_(other.begin7_),\n        end7_(other.end7_),\n        current7_(other.current7_),\n        begin8_(other.begin8_),\n        end8_(other.end8_),\n        current8_(other.current8_),\n        begin9_(other.begin9_),\n        end9_(other.end9_),\n        current9_(other.current9_),\n        begin10_(other.begin10_),\n        end10_(other.end10_),\n        current10_(other.current10_) {\n      ComputeCurrentValue();\n    }\n\n    void ComputeCurrentValue() {\n      if (!AtEnd())\n        current_value_ = ParamType(*current1_, *current2_, *current3_,\n            *current4_, *current5_, *current6_, *current7_, *current8_,\n            *current9_, *current10_);\n    }\n    bool AtEnd() const {\n      // We must report iterator past the end of the range when either of the\n      // component iterators has reached the end of its range.\n      return\n          current1_ == end1_ ||\n          current2_ == end2_ ||\n          current3_ == end3_ ||\n          current4_ == end4_ ||\n          current5_ == end5_ ||\n          current6_ == end6_ ||\n          current7_ == end7_ ||\n          current8_ == end8_ ||\n          current9_ == end9_ ||\n          current10_ == end10_;\n    }\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<ParamType>* const base_;\n    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.\n    // current[i]_ is the actual traversing iterator.\n    const typename ParamGenerator<T1>::iterator begin1_;\n    const typename ParamGenerator<T1>::iterator end1_;\n    typename ParamGenerator<T1>::iterator current1_;\n    const typename ParamGenerator<T2>::iterator begin2_;\n    const typename ParamGenerator<T2>::iterator end2_;\n    typename ParamGenerator<T2>::iterator current2_;\n    const typename ParamGenerator<T3>::iterator begin3_;\n    const typename ParamGenerator<T3>::iterator end3_;\n    typename ParamGenerator<T3>::iterator current3_;\n    const typename ParamGenerator<T4>::iterator begin4_;\n    const typename ParamGenerator<T4>::iterator end4_;\n    typename ParamGenerator<T4>::iterator current4_;\n    const typename ParamGenerator<T5>::iterator begin5_;\n    const typename ParamGenerator<T5>::iterator end5_;\n    typename ParamGenerator<T5>::iterator current5_;\n    const typename ParamGenerator<T6>::iterator begin6_;\n    const typename ParamGenerator<T6>::iterator end6_;\n    typename ParamGenerator<T6>::iterator current6_;\n    const typename ParamGenerator<T7>::iterator begin7_;\n    const typename ParamGenerator<T7>::iterator end7_;\n    typename ParamGenerator<T7>::iterator current7_;\n    const typename ParamGenerator<T8>::iterator begin8_;\n    const typename ParamGenerator<T8>::iterator end8_;\n    typename ParamGenerator<T8>::iterator current8_;\n    const typename ParamGenerator<T9>::iterator begin9_;\n    const typename ParamGenerator<T9>::iterator end9_;\n    typename ParamGenerator<T9>::iterator current9_;\n    const typename ParamGenerator<T10>::iterator begin10_;\n    const typename ParamGenerator<T10>::iterator end10_;\n    typename ParamGenerator<T10>::iterator current10_;\n    ParamType current_value_;\n  };  // class CartesianProductGenerator10::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductGenerator10& other);\n\n  const ParamGenerator<T1> g1_;\n  const ParamGenerator<T2> g2_;\n  const ParamGenerator<T3> g3_;\n  const ParamGenerator<T4> g4_;\n  const ParamGenerator<T5> g5_;\n  const ParamGenerator<T6> g6_;\n  const ParamGenerator<T7> g7_;\n  const ParamGenerator<T8> g8_;\n  const ParamGenerator<T9> g9_;\n  const ParamGenerator<T10> g10_;\n};  // class CartesianProductGenerator10\n\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Helper classes providing Combine() with polymorphic features. They allow\n// casting CartesianProductGeneratorN<T> to ParamGenerator<U> if T is\n// convertible to U.\n//\ntemplate <class Generator1, class Generator2>\nclass CartesianProductHolder2 {\n public:\nCartesianProductHolder2(const Generator1& g1, const Generator2& g2)\n      : g1_(g1), g2_(g2) {}\n  template <typename T1, typename T2>\n  operator ParamGenerator< ::std::tr1::tuple<T1, T2> >() const {\n    return ParamGenerator< ::std::tr1::tuple<T1, T2> >(\n        new CartesianProductGenerator2<T1, T2>(\n        static_cast<ParamGenerator<T1> >(g1_),\n        static_cast<ParamGenerator<T2> >(g2_)));\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductHolder2& other);\n\n  const Generator1 g1_;\n  const Generator2 g2_;\n};  // class CartesianProductHolder2\n\ntemplate <class Generator1, class Generator2, class Generator3>\nclass CartesianProductHolder3 {\n public:\nCartesianProductHolder3(const Generator1& g1, const Generator2& g2,\n    const Generator3& g3)\n      : g1_(g1), g2_(g2), g3_(g3) {}\n  template <typename T1, typename T2, typename T3>\n  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3> >() const {\n    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3> >(\n        new CartesianProductGenerator3<T1, T2, T3>(\n        static_cast<ParamGenerator<T1> >(g1_),\n        static_cast<ParamGenerator<T2> >(g2_),\n        static_cast<ParamGenerator<T3> >(g3_)));\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductHolder3& other);\n\n  const Generator1 g1_;\n  const Generator2 g2_;\n  const Generator3 g3_;\n};  // class CartesianProductHolder3\n\ntemplate <class Generator1, class Generator2, class Generator3,\n    class Generator4>\nclass CartesianProductHolder4 {\n public:\nCartesianProductHolder4(const Generator1& g1, const Generator2& g2,\n    const Generator3& g3, const Generator4& g4)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4) {}\n  template <typename T1, typename T2, typename T3, typename T4>\n  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4> >() const {\n    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4> >(\n        new CartesianProductGenerator4<T1, T2, T3, T4>(\n        static_cast<ParamGenerator<T1> >(g1_),\n        static_cast<ParamGenerator<T2> >(g2_),\n        static_cast<ParamGenerator<T3> >(g3_),\n        static_cast<ParamGenerator<T4> >(g4_)));\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductHolder4& other);\n\n  const Generator1 g1_;\n  const Generator2 g2_;\n  const Generator3 g3_;\n  const Generator4 g4_;\n};  // class CartesianProductHolder4\n\ntemplate <class Generator1, class Generator2, class Generator3,\n    class Generator4, class Generator5>\nclass CartesianProductHolder5 {\n public:\nCartesianProductHolder5(const Generator1& g1, const Generator2& g2,\n    const Generator3& g3, const Generator4& g4, const Generator5& g5)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5) {}\n  template <typename T1, typename T2, typename T3, typename T4, typename T5>\n  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5> >() const {\n    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5> >(\n        new CartesianProductGenerator5<T1, T2, T3, T4, T5>(\n        static_cast<ParamGenerator<T1> >(g1_),\n        static_cast<ParamGenerator<T2> >(g2_),\n        static_cast<ParamGenerator<T3> >(g3_),\n        static_cast<ParamGenerator<T4> >(g4_),\n        static_cast<ParamGenerator<T5> >(g5_)));\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductHolder5& other);\n\n  const Generator1 g1_;\n  const Generator2 g2_;\n  const Generator3 g3_;\n  const Generator4 g4_;\n  const Generator5 g5_;\n};  // class CartesianProductHolder5\n\ntemplate <class Generator1, class Generator2, class Generator3,\n    class Generator4, class Generator5, class Generator6>\nclass CartesianProductHolder6 {\n public:\nCartesianProductHolder6(const Generator1& g1, const Generator2& g2,\n    const Generator3& g3, const Generator4& g4, const Generator5& g5,\n    const Generator6& g6)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6) {}\n  template <typename T1, typename T2, typename T3, typename T4, typename T5,\n      typename T6>\n  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6> >() const {\n    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6> >(\n        new CartesianProductGenerator6<T1, T2, T3, T4, T5, T6>(\n        static_cast<ParamGenerator<T1> >(g1_),\n        static_cast<ParamGenerator<T2> >(g2_),\n        static_cast<ParamGenerator<T3> >(g3_),\n        static_cast<ParamGenerator<T4> >(g4_),\n        static_cast<ParamGenerator<T5> >(g5_),\n        static_cast<ParamGenerator<T6> >(g6_)));\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductHolder6& other);\n\n  const Generator1 g1_;\n  const Generator2 g2_;\n  const Generator3 g3_;\n  const Generator4 g4_;\n  const Generator5 g5_;\n  const Generator6 g6_;\n};  // class CartesianProductHolder6\n\ntemplate <class Generator1, class Generator2, class Generator3,\n    class Generator4, class Generator5, class Generator6, class Generator7>\nclass CartesianProductHolder7 {\n public:\nCartesianProductHolder7(const Generator1& g1, const Generator2& g2,\n    const Generator3& g3, const Generator4& g4, const Generator5& g5,\n    const Generator6& g6, const Generator7& g7)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7) {}\n  template <typename T1, typename T2, typename T3, typename T4, typename T5,\n      typename T6, typename T7>\n  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6,\n      T7> >() const {\n    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7> >(\n        new CartesianProductGenerator7<T1, T2, T3, T4, T5, T6, T7>(\n        static_cast<ParamGenerator<T1> >(g1_),\n        static_cast<ParamGenerator<T2> >(g2_),\n        static_cast<ParamGenerator<T3> >(g3_),\n        static_cast<ParamGenerator<T4> >(g4_),\n        static_cast<ParamGenerator<T5> >(g5_),\n        static_cast<ParamGenerator<T6> >(g6_),\n        static_cast<ParamGenerator<T7> >(g7_)));\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductHolder7& other);\n\n  const Generator1 g1_;\n  const Generator2 g2_;\n  const Generator3 g3_;\n  const Generator4 g4_;\n  const Generator5 g5_;\n  const Generator6 g6_;\n  const Generator7 g7_;\n};  // class CartesianProductHolder7\n\ntemplate <class Generator1, class Generator2, class Generator3,\n    class Generator4, class Generator5, class Generator6, class Generator7,\n    class Generator8>\nclass CartesianProductHolder8 {\n public:\nCartesianProductHolder8(const Generator1& g1, const Generator2& g2,\n    const Generator3& g3, const Generator4& g4, const Generator5& g5,\n    const Generator6& g6, const Generator7& g7, const Generator8& g8)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7),\n          g8_(g8) {}\n  template <typename T1, typename T2, typename T3, typename T4, typename T5,\n      typename T6, typename T7, typename T8>\n  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7,\n      T8> >() const {\n    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8> >(\n        new CartesianProductGenerator8<T1, T2, T3, T4, T5, T6, T7, T8>(\n        static_cast<ParamGenerator<T1> >(g1_),\n        static_cast<ParamGenerator<T2> >(g2_),\n        static_cast<ParamGenerator<T3> >(g3_),\n        static_cast<ParamGenerator<T4> >(g4_),\n        static_cast<ParamGenerator<T5> >(g5_),\n        static_cast<ParamGenerator<T6> >(g6_),\n        static_cast<ParamGenerator<T7> >(g7_),\n        static_cast<ParamGenerator<T8> >(g8_)));\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductHolder8& other);\n\n  const Generator1 g1_;\n  const Generator2 g2_;\n  const Generator3 g3_;\n  const Generator4 g4_;\n  const Generator5 g5_;\n  const Generator6 g6_;\n  const Generator7 g7_;\n  const Generator8 g8_;\n};  // class CartesianProductHolder8\n\ntemplate <class Generator1, class Generator2, class Generator3,\n    class Generator4, class Generator5, class Generator6, class Generator7,\n    class Generator8, class Generator9>\nclass CartesianProductHolder9 {\n public:\nCartesianProductHolder9(const Generator1& g1, const Generator2& g2,\n    const Generator3& g3, const Generator4& g4, const Generator5& g5,\n    const Generator6& g6, const Generator7& g7, const Generator8& g8,\n    const Generator9& g9)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),\n          g9_(g9) {}\n  template <typename T1, typename T2, typename T3, typename T4, typename T5,\n      typename T6, typename T7, typename T8, typename T9>\n  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8,\n      T9> >() const {\n    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8,\n        T9> >(\n        new CartesianProductGenerator9<T1, T2, T3, T4, T5, T6, T7, T8, T9>(\n        static_cast<ParamGenerator<T1> >(g1_),\n        static_cast<ParamGenerator<T2> >(g2_),\n        static_cast<ParamGenerator<T3> >(g3_),\n        static_cast<ParamGenerator<T4> >(g4_),\n        static_cast<ParamGenerator<T5> >(g5_),\n        static_cast<ParamGenerator<T6> >(g6_),\n        static_cast<ParamGenerator<T7> >(g7_),\n        static_cast<ParamGenerator<T8> >(g8_),\n        static_cast<ParamGenerator<T9> >(g9_)));\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductHolder9& other);\n\n  const Generator1 g1_;\n  const Generator2 g2_;\n  const Generator3 g3_;\n  const Generator4 g4_;\n  const Generator5 g5_;\n  const Generator6 g6_;\n  const Generator7 g7_;\n  const Generator8 g8_;\n  const Generator9 g9_;\n};  // class CartesianProductHolder9\n\ntemplate <class Generator1, class Generator2, class Generator3,\n    class Generator4, class Generator5, class Generator6, class Generator7,\n    class Generator8, class Generator9, class Generator10>\nclass CartesianProductHolder10 {\n public:\nCartesianProductHolder10(const Generator1& g1, const Generator2& g2,\n    const Generator3& g3, const Generator4& g4, const Generator5& g5,\n    const Generator6& g6, const Generator7& g7, const Generator8& g8,\n    const Generator9& g9, const Generator10& g10)\n      : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8),\n          g9_(g9), g10_(g10) {}\n  template <typename T1, typename T2, typename T3, typename T4, typename T5,\n      typename T6, typename T7, typename T8, typename T9, typename T10>\n  operator ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8,\n      T9, T10> >() const {\n    return ParamGenerator< ::std::tr1::tuple<T1, T2, T3, T4, T5, T6, T7, T8,\n        T9, T10> >(\n        new CartesianProductGenerator10<T1, T2, T3, T4, T5, T6, T7, T8, T9,\n            T10>(\n        static_cast<ParamGenerator<T1> >(g1_),\n        static_cast<ParamGenerator<T2> >(g2_),\n        static_cast<ParamGenerator<T3> >(g3_),\n        static_cast<ParamGenerator<T4> >(g4_),\n        static_cast<ParamGenerator<T5> >(g5_),\n        static_cast<ParamGenerator<T6> >(g6_),\n        static_cast<ParamGenerator<T7> >(g7_),\n        static_cast<ParamGenerator<T8> >(g8_),\n        static_cast<ParamGenerator<T9> >(g9_),\n        static_cast<ParamGenerator<T10> >(g10_)));\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductHolder10& other);\n\n  const Generator1 g1_;\n  const Generator2 g2_;\n  const Generator3 g3_;\n  const Generator4 g4_;\n  const Generator5 g5_;\n  const Generator6 g6_;\n  const Generator7 g7_;\n  const Generator8 g8_;\n  const Generator9 g9_;\n  const Generator10 g10_;\n};  // class CartesianProductHolder10\n\n# endif  // GTEST_HAS_COMBINE\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  //  GTEST_HAS_PARAM_TEST\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/internal/gtest-param-util-generated.h.pump",
    "content": "$$ -*- mode: c++; -*-\n$var n = 50  $$ Maximum length of Values arguments we want to support.\n$var maxtuple = 10  $$ Maximum number of Combine arguments we want to support.\n// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n\n// Type and function utilities for implementing parameterized tests.\n// This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!\n//\n// Currently Google Test supports at most $n arguments in Values,\n// and at most $maxtuple arguments in Combine. Please contact\n// googletestframework@googlegroups.com if you need more.\n// Please note that the number of arguments to Combine is limited\n// by the maximum arity of the implementation of tr1::tuple which is\n// currently set at $maxtuple.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_\n\n// scripts/fuse_gtest.py depends on gtest's own header being #included\n// *unconditionally*.  Therefore these #includes cannot be moved\n// inside #if GTEST_HAS_PARAM_TEST.\n#include \"gtest/internal/gtest-param-util.h\"\n#include \"gtest/internal/gtest-port.h\"\n\n#if GTEST_HAS_PARAM_TEST\n\nnamespace testing {\n\n// Forward declarations of ValuesIn(), which is implemented in\n// include/gtest/gtest-param-test.h.\ntemplate <typename ForwardIterator>\ninternal::ParamGenerator<\n  typename ::testing::internal::IteratorTraits<ForwardIterator>::value_type>\nValuesIn(ForwardIterator begin, ForwardIterator end);\n\ntemplate <typename T, size_t N>\ninternal::ParamGenerator<T> ValuesIn(const T (&array)[N]);\n\ntemplate <class Container>\ninternal::ParamGenerator<typename Container::value_type> ValuesIn(\n    const Container& container);\n\nnamespace internal {\n\n// Used in the Values() function to provide polymorphic capabilities.\ntemplate <typename T1>\nclass ValueArray1 {\n public:\n  explicit ValueArray1(T1 v1) : v1_(v1) {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const { return ValuesIn(&v1_, &v1_ + 1); }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray1& other);\n\n  const T1 v1_;\n};\n\n$range i 2..n\n$for i [[\n$range j 1..i\n\ntemplate <$for j, [[typename T$j]]>\nclass ValueArray$i {\n public:\n  ValueArray$i($for j, [[T$j v$j]]) : $for j, [[v$(j)_(v$j)]] {}\n\n  template <typename T>\n  operator ParamGenerator<T>() const {\n    const T array[] = {$for j, [[static_cast<T>(v$(j)_)]]};\n    return ValuesIn(array);\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const ValueArray$i& other);\n\n$for j [[\n\n  const T$j v$(j)_;\n]]\n\n};\n\n]]\n\n# if GTEST_HAS_COMBINE\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Generates values from the Cartesian product of values produced\n// by the argument generators.\n//\n$range i 2..maxtuple\n$for i [[\n$range j 1..i\n$range k 2..i\n\ntemplate <$for j, [[typename T$j]]>\nclass CartesianProductGenerator$i\n    : public ParamGeneratorInterface< ::std::tr1::tuple<$for j, [[T$j]]> > {\n public:\n  typedef ::std::tr1::tuple<$for j, [[T$j]]> ParamType;\n\n  CartesianProductGenerator$i($for j, [[const ParamGenerator<T$j>& g$j]])\n      : $for j, [[g$(j)_(g$j)]] {}\n  virtual ~CartesianProductGenerator$i() {}\n\n  virtual ParamIteratorInterface<ParamType>* Begin() const {\n    return new Iterator(this, $for j, [[g$(j)_, g$(j)_.begin()]]);\n  }\n  virtual ParamIteratorInterface<ParamType>* End() const {\n    return new Iterator(this, $for j, [[g$(j)_, g$(j)_.end()]]);\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<ParamType> {\n   public:\n    Iterator(const ParamGeneratorInterface<ParamType>* base, $for j, [[\n\n      const ParamGenerator<T$j>& g$j,\n      const typename ParamGenerator<T$j>::iterator& current$(j)]])\n        : base_(base),\n$for j, [[\n\n          begin$(j)_(g$j.begin()), end$(j)_(g$j.end()), current$(j)_(current$j)\n]]    {\n      ComputeCurrentValue();\n    }\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<ParamType>* BaseGenerator() const {\n      return base_;\n    }\n    // Advance should not be called on beyond-of-range iterators\n    // so no component iterators must be beyond end of range, either.\n    virtual void Advance() {\n      assert(!AtEnd());\n      ++current$(i)_;\n\n$for k [[\n      if (current$(i+2-k)_ == end$(i+2-k)_) {\n        current$(i+2-k)_ = begin$(i+2-k)_;\n        ++current$(i+2-k-1)_;\n      }\n\n]]\n      ComputeCurrentValue();\n    }\n    virtual ParamIteratorInterface<ParamType>* Clone() const {\n      return new Iterator(*this);\n    }\n    virtual const ParamType* Current() const { return &current_value_; }\n    virtual bool Equals(const ParamIteratorInterface<ParamType>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const Iterator* typed_other =\n          CheckedDowncastToActualType<const Iterator>(&other);\n      // We must report iterators equal if they both point beyond their\n      // respective ranges. That can happen in a variety of fashions,\n      // so we have to consult AtEnd().\n      return (AtEnd() && typed_other->AtEnd()) ||\n         ($for j  && [[\n\n          current$(j)_ == typed_other->current$(j)_\n]]);\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : base_(other.base_), $for j, [[\n\n        begin$(j)_(other.begin$(j)_),\n        end$(j)_(other.end$(j)_),\n        current$(j)_(other.current$(j)_)\n]] {\n      ComputeCurrentValue();\n    }\n\n    void ComputeCurrentValue() {\n      if (!AtEnd())\n        current_value_ = ParamType($for j, [[*current$(j)_]]);\n    }\n    bool AtEnd() const {\n      // We must report iterator past the end of the range when either of the\n      // component iterators has reached the end of its range.\n      return\n$for j  || [[\n\n          current$(j)_ == end$(j)_\n]];\n    }\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<ParamType>* const base_;\n    // begin[i]_ and end[i]_ define the i-th range that Iterator traverses.\n    // current[i]_ is the actual traversing iterator.\n$for j [[\n\n    const typename ParamGenerator<T$j>::iterator begin$(j)_;\n    const typename ParamGenerator<T$j>::iterator end$(j)_;\n    typename ParamGenerator<T$j>::iterator current$(j)_;\n]]\n\n    ParamType current_value_;\n  };  // class CartesianProductGenerator$i::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductGenerator$i& other);\n\n\n$for j [[\n  const ParamGenerator<T$j> g$(j)_;\n\n]]\n};  // class CartesianProductGenerator$i\n\n\n]]\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Helper classes providing Combine() with polymorphic features. They allow\n// casting CartesianProductGeneratorN<T> to ParamGenerator<U> if T is\n// convertible to U.\n//\n$range i 2..maxtuple\n$for i [[\n$range j 1..i\n\ntemplate <$for j, [[class Generator$j]]>\nclass CartesianProductHolder$i {\n public:\nCartesianProductHolder$i($for j, [[const Generator$j& g$j]])\n      : $for j, [[g$(j)_(g$j)]] {}\n  template <$for j, [[typename T$j]]>\n  operator ParamGenerator< ::std::tr1::tuple<$for j, [[T$j]]> >() const {\n    return ParamGenerator< ::std::tr1::tuple<$for j, [[T$j]]> >(\n        new CartesianProductGenerator$i<$for j, [[T$j]]>(\n$for j,[[\n\n        static_cast<ParamGenerator<T$j> >(g$(j)_)\n]]));\n  }\n\n private:\n  // No implementation - assignment is unsupported.\n  void operator=(const CartesianProductHolder$i& other);\n\n\n$for j [[\n  const Generator$j g$(j)_;\n\n]]\n};  // class CartesianProductHolder$i\n\n]]\n\n# endif  // GTEST_HAS_COMBINE\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  //  GTEST_HAS_PARAM_TEST\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/internal/gtest-param-util.h",
    "content": "// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n\n// Type and function utilities for implementing parameterized tests.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_\n\n#include <iterator>\n#include <utility>\n#include <vector>\n\n// scripts/fuse_gtest.py depends on gtest's own header being #included\n// *unconditionally*.  Therefore these #includes cannot be moved\n// inside #if GTEST_HAS_PARAM_TEST.\n#include \"gtest/internal/gtest-internal.h\"\n#include \"gtest/internal/gtest-linked_ptr.h\"\n#include \"gtest/internal/gtest-port.h\"\n#include \"gtest/gtest-printers.h\"\n\n#if GTEST_HAS_PARAM_TEST\n\nnamespace testing {\nnamespace internal {\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Outputs a message explaining invalid registration of different\n// fixture class for the same test case. This may happen when\n// TEST_P macro is used to define two tests with the same name\n// but in different namespaces.\nGTEST_API_ void ReportInvalidTestCaseType(const char* test_case_name,\n                                          const char* file, int line);\n\ntemplate <typename> class ParamGeneratorInterface;\ntemplate <typename> class ParamGenerator;\n\n// Interface for iterating over elements provided by an implementation\n// of ParamGeneratorInterface<T>.\ntemplate <typename T>\nclass ParamIteratorInterface {\n public:\n  virtual ~ParamIteratorInterface() {}\n  // A pointer to the base generator instance.\n  // Used only for the purposes of iterator comparison\n  // to make sure that two iterators belong to the same generator.\n  virtual const ParamGeneratorInterface<T>* BaseGenerator() const = 0;\n  // Advances iterator to point to the next element\n  // provided by the generator. The caller is responsible\n  // for not calling Advance() on an iterator equal to\n  // BaseGenerator()->End().\n  virtual void Advance() = 0;\n  // Clones the iterator object. Used for implementing copy semantics\n  // of ParamIterator<T>.\n  virtual ParamIteratorInterface* Clone() const = 0;\n  // Dereferences the current iterator and provides (read-only) access\n  // to the pointed value. It is the caller's responsibility not to call\n  // Current() on an iterator equal to BaseGenerator()->End().\n  // Used for implementing ParamGenerator<T>::operator*().\n  virtual const T* Current() const = 0;\n  // Determines whether the given iterator and other point to the same\n  // element in the sequence generated by the generator.\n  // Used for implementing ParamGenerator<T>::operator==().\n  virtual bool Equals(const ParamIteratorInterface& other) const = 0;\n};\n\n// Class iterating over elements provided by an implementation of\n// ParamGeneratorInterface<T>. It wraps ParamIteratorInterface<T>\n// and implements the const forward iterator concept.\ntemplate <typename T>\nclass ParamIterator {\n public:\n  typedef T value_type;\n  typedef const T& reference;\n  typedef ptrdiff_t difference_type;\n\n  // ParamIterator assumes ownership of the impl_ pointer.\n  ParamIterator(const ParamIterator& other) : impl_(other.impl_->Clone()) {}\n  ParamIterator& operator=(const ParamIterator& other) {\n    if (this != &other)\n      impl_.reset(other.impl_->Clone());\n    return *this;\n  }\n\n  const T& operator*() const { return *impl_->Current(); }\n  const T* operator->() const { return impl_->Current(); }\n  // Prefix version of operator++.\n  ParamIterator& operator++() {\n    impl_->Advance();\n    return *this;\n  }\n  // Postfix version of operator++.\n  ParamIterator operator++(int /*unused*/) {\n    ParamIteratorInterface<T>* clone = impl_->Clone();\n    impl_->Advance();\n    return ParamIterator(clone);\n  }\n  bool operator==(const ParamIterator& other) const {\n    return impl_.get() == other.impl_.get() || impl_->Equals(*other.impl_);\n  }\n  bool operator!=(const ParamIterator& other) const {\n    return !(*this == other);\n  }\n\n private:\n  friend class ParamGenerator<T>;\n  explicit ParamIterator(ParamIteratorInterface<T>* impl) : impl_(impl) {}\n  scoped_ptr<ParamIteratorInterface<T> > impl_;\n};\n\n// ParamGeneratorInterface<T> is the binary interface to access generators\n// defined in other translation units.\ntemplate <typename T>\nclass ParamGeneratorInterface {\n public:\n  typedef T ParamType;\n\n  virtual ~ParamGeneratorInterface() {}\n\n  // Generator interface definition\n  virtual ParamIteratorInterface<T>* Begin() const = 0;\n  virtual ParamIteratorInterface<T>* End() const = 0;\n};\n\n// Wraps ParamGeneratorInterface<T> and provides general generator syntax\n// compatible with the STL Container concept.\n// This class implements copy initialization semantics and the contained\n// ParamGeneratorInterface<T> instance is shared among all copies\n// of the original object. This is possible because that instance is immutable.\ntemplate<typename T>\nclass ParamGenerator {\n public:\n  typedef ParamIterator<T> iterator;\n\n  explicit ParamGenerator(ParamGeneratorInterface<T>* impl) : impl_(impl) {}\n  ParamGenerator(const ParamGenerator& other) : impl_(other.impl_) {}\n\n  ParamGenerator& operator=(const ParamGenerator& other) {\n    impl_ = other.impl_;\n    return *this;\n  }\n\n  iterator begin() const { return iterator(impl_->Begin()); }\n  iterator end() const { return iterator(impl_->End()); }\n\n private:\n  linked_ptr<const ParamGeneratorInterface<T> > impl_;\n};\n\n// Generates values from a range of two comparable values. Can be used to\n// generate sequences of user-defined types that implement operator+() and\n// operator<().\n// This class is used in the Range() function.\ntemplate <typename T, typename IncrementT>\nclass RangeGenerator : public ParamGeneratorInterface<T> {\n public:\n  RangeGenerator(T begin, T end, IncrementT step)\n      : begin_(begin), end_(end),\n        step_(step), end_index_(CalculateEndIndex(begin, end, step)) {}\n  virtual ~RangeGenerator() {}\n\n  virtual ParamIteratorInterface<T>* Begin() const {\n    return new Iterator(this, begin_, 0, step_);\n  }\n  virtual ParamIteratorInterface<T>* End() const {\n    return new Iterator(this, end_, end_index_, step_);\n  }\n\n private:\n  class Iterator : public ParamIteratorInterface<T> {\n   public:\n    Iterator(const ParamGeneratorInterface<T>* base, T value, int index,\n             IncrementT step)\n        : base_(base), value_(value), index_(index), step_(step) {}\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<T>* BaseGenerator() const {\n      return base_;\n    }\n    virtual void Advance() {\n      value_ = value_ + step_;\n      index_++;\n    }\n    virtual ParamIteratorInterface<T>* Clone() const {\n      return new Iterator(*this);\n    }\n    virtual const T* Current() const { return &value_; }\n    virtual bool Equals(const ParamIteratorInterface<T>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      const int other_index =\n          CheckedDowncastToActualType<const Iterator>(&other)->index_;\n      return index_ == other_index;\n    }\n\n   private:\n    Iterator(const Iterator& other)\n        : ParamIteratorInterface<T>(),\n          base_(other.base_), value_(other.value_), index_(other.index_),\n          step_(other.step_) {}\n\n    // No implementation - assignment is unsupported.\n    void operator=(const Iterator& other);\n\n    const ParamGeneratorInterface<T>* const base_;\n    T value_;\n    int index_;\n    const IncrementT step_;\n  };  // class RangeGenerator::Iterator\n\n  static int CalculateEndIndex(const T& begin,\n                               const T& end,\n                               const IncrementT& step) {\n    int end_index = 0;\n    for (T i = begin; i < end; i = i + step)\n      end_index++;\n    return end_index;\n  }\n\n  // No implementation - assignment is unsupported.\n  void operator=(const RangeGenerator& other);\n\n  const T begin_;\n  const T end_;\n  const IncrementT step_;\n  // The index for the end() iterator. All the elements in the generated\n  // sequence are indexed (0-based) to aid iterator comparison.\n  const int end_index_;\n};  // class RangeGenerator\n\n\n// Generates values from a pair of STL-style iterators. Used in the\n// ValuesIn() function. The elements are copied from the source range\n// since the source can be located on the stack, and the generator\n// is likely to persist beyond that stack frame.\ntemplate <typename T>\nclass ValuesInIteratorRangeGenerator : public ParamGeneratorInterface<T> {\n public:\n  template <typename ForwardIterator>\n  ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end)\n      : container_(begin, end) {}\n  virtual ~ValuesInIteratorRangeGenerator() {}\n\n  virtual ParamIteratorInterface<T>* Begin() const {\n    return new Iterator(this, container_.begin());\n  }\n  virtual ParamIteratorInterface<T>* End() const {\n    return new Iterator(this, container_.end());\n  }\n\n private:\n  typedef typename ::std::vector<T> ContainerType;\n\n  class Iterator : public ParamIteratorInterface<T> {\n   public:\n    Iterator(const ParamGeneratorInterface<T>* base,\n             typename ContainerType::const_iterator iterator)\n        : base_(base), iterator_(iterator) {}\n    virtual ~Iterator() {}\n\n    virtual const ParamGeneratorInterface<T>* BaseGenerator() const {\n      return base_;\n    }\n    virtual void Advance() {\n      ++iterator_;\n      value_.reset();\n    }\n    virtual ParamIteratorInterface<T>* Clone() const {\n      return new Iterator(*this);\n    }\n    // We need to use cached value referenced by iterator_ because *iterator_\n    // can return a temporary object (and of type other then T), so just\n    // having \"return &*iterator_;\" doesn't work.\n    // value_ is updated here and not in Advance() because Advance()\n    // can advance iterator_ beyond the end of the range, and we cannot\n    // detect that fact. The client code, on the other hand, is\n    // responsible for not calling Current() on an out-of-range iterator.\n    virtual const T* Current() const {\n      if (value_.get() == NULL)\n        value_.reset(new T(*iterator_));\n      return value_.get();\n    }\n    virtual bool Equals(const ParamIteratorInterface<T>& other) const {\n      // Having the same base generator guarantees that the other\n      // iterator is of the same type and we can downcast.\n      GTEST_CHECK_(BaseGenerator() == other.BaseGenerator())\n          << \"The program attempted to compare iterators \"\n          << \"from different generators.\" << std::endl;\n      return iterator_ ==\n          CheckedDowncastToActualType<const Iterator>(&other)->iterator_;\n    }\n\n   private:\n    Iterator(const Iterator& other)\n          // The explicit constructor call suppresses a false warning\n          // emitted by gcc when supplied with the -Wextra option.\n        : ParamIteratorInterface<T>(),\n          base_(other.base_),\n          iterator_(other.iterator_) {}\n\n    const ParamGeneratorInterface<T>* const base_;\n    typename ContainerType::const_iterator iterator_;\n    // A cached value of *iterator_. We keep it here to allow access by\n    // pointer in the wrapping iterator's operator->().\n    // value_ needs to be mutable to be accessed in Current().\n    // Use of scoped_ptr helps manage cached value's lifetime,\n    // which is bound by the lifespan of the iterator itself.\n    mutable scoped_ptr<const T> value_;\n  };  // class ValuesInIteratorRangeGenerator::Iterator\n\n  // No implementation - assignment is unsupported.\n  void operator=(const ValuesInIteratorRangeGenerator& other);\n\n  const ContainerType container_;\n};  // class ValuesInIteratorRangeGenerator\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Stores a parameter value and later creates tests parameterized with that\n// value.\ntemplate <class TestClass>\nclass ParameterizedTestFactory : public TestFactoryBase {\n public:\n  typedef typename TestClass::ParamType ParamType;\n  explicit ParameterizedTestFactory(ParamType parameter) :\n      parameter_(parameter) {}\n  virtual Test* CreateTest() {\n    TestClass::SetParam(&parameter_);\n    return new TestClass();\n  }\n\n private:\n  const ParamType parameter_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestFactory);\n};\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// TestMetaFactoryBase is a base class for meta-factories that create\n// test factories for passing into MakeAndRegisterTestInfo function.\ntemplate <class ParamType>\nclass TestMetaFactoryBase {\n public:\n  virtual ~TestMetaFactoryBase() {}\n\n  virtual TestFactoryBase* CreateTestFactory(ParamType parameter) = 0;\n};\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// TestMetaFactory creates test factories for passing into\n// MakeAndRegisterTestInfo function. Since MakeAndRegisterTestInfo receives\n// ownership of test factory pointer, same factory object cannot be passed\n// into that method twice. But ParameterizedTestCaseInfo is going to call\n// it for each Test/Parameter value combination. Thus it needs meta factory\n// creator class.\ntemplate <class TestCase>\nclass TestMetaFactory\n    : public TestMetaFactoryBase<typename TestCase::ParamType> {\n public:\n  typedef typename TestCase::ParamType ParamType;\n\n  TestMetaFactory() {}\n\n  virtual TestFactoryBase* CreateTestFactory(ParamType parameter) {\n    return new ParameterizedTestFactory<TestCase>(parameter);\n  }\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestMetaFactory);\n};\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// ParameterizedTestCaseInfoBase is a generic interface\n// to ParameterizedTestCaseInfo classes. ParameterizedTestCaseInfoBase\n// accumulates test information provided by TEST_P macro invocations\n// and generators provided by INSTANTIATE_TEST_CASE_P macro invocations\n// and uses that information to register all resulting test instances\n// in RegisterTests method. The ParameterizeTestCaseRegistry class holds\n// a collection of pointers to the ParameterizedTestCaseInfo objects\n// and calls RegisterTests() on each of them when asked.\nclass ParameterizedTestCaseInfoBase {\n public:\n  virtual ~ParameterizedTestCaseInfoBase() {}\n\n  // Base part of test case name for display purposes.\n  virtual const string& GetTestCaseName() const = 0;\n  // Test case id to verify identity.\n  virtual TypeId GetTestCaseTypeId() const = 0;\n  // UnitTest class invokes this method to register tests in this\n  // test case right before running them in RUN_ALL_TESTS macro.\n  // This method should not be called more then once on any single\n  // instance of a ParameterizedTestCaseInfoBase derived class.\n  virtual void RegisterTests() = 0;\n\n protected:\n  ParameterizedTestCaseInfoBase() {}\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseInfoBase);\n};\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// ParameterizedTestCaseInfo accumulates tests obtained from TEST_P\n// macro invocations for a particular test case and generators\n// obtained from INSTANTIATE_TEST_CASE_P macro invocations for that\n// test case. It registers tests with all values generated by all\n// generators when asked.\ntemplate <class TestCase>\nclass ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase {\n public:\n  // ParamType and GeneratorCreationFunc are private types but are required\n  // for declarations of public methods AddTestPattern() and\n  // AddTestCaseInstantiation().\n  typedef typename TestCase::ParamType ParamType;\n  // A function that returns an instance of appropriate generator type.\n  typedef ParamGenerator<ParamType>(GeneratorCreationFunc)();\n\n  explicit ParameterizedTestCaseInfo(const char* name)\n      : test_case_name_(name) {}\n\n  // Test case base name for display purposes.\n  virtual const string& GetTestCaseName() const { return test_case_name_; }\n  // Test case id to verify identity.\n  virtual TypeId GetTestCaseTypeId() const { return GetTypeId<TestCase>(); }\n  // TEST_P macro uses AddTestPattern() to record information\n  // about a single test in a LocalTestInfo structure.\n  // test_case_name is the base name of the test case (without invocation\n  // prefix). test_base_name is the name of an individual test without\n  // parameter index. For the test SequenceA/FooTest.DoBar/1 FooTest is\n  // test case base name and DoBar is test base name.\n  void AddTestPattern(const char* test_case_name,\n                      const char* test_base_name,\n                      TestMetaFactoryBase<ParamType>* meta_factory) {\n    tests_.push_back(linked_ptr<TestInfo>(new TestInfo(test_case_name,\n                                                       test_base_name,\n                                                       meta_factory)));\n  }\n  // INSTANTIATE_TEST_CASE_P macro uses AddGenerator() to record information\n  // about a generator.\n  int AddTestCaseInstantiation(const string& instantiation_name,\n                               GeneratorCreationFunc* func,\n                               const char* /* file */,\n                               int /* line */) {\n    instantiations_.push_back(::std::make_pair(instantiation_name, func));\n    return 0;  // Return value used only to run this method in namespace scope.\n  }\n  // UnitTest class invokes this method to register tests in this test case\n  // test cases right before running tests in RUN_ALL_TESTS macro.\n  // This method should not be called more then once on any single\n  // instance of a ParameterizedTestCaseInfoBase derived class.\n  // UnitTest has a guard to prevent from calling this method more then once.\n  virtual void RegisterTests() {\n    for (typename TestInfoContainer::iterator test_it = tests_.begin();\n         test_it != tests_.end(); ++test_it) {\n      linked_ptr<TestInfo> test_info = *test_it;\n      for (typename InstantiationContainer::iterator gen_it =\n               instantiations_.begin(); gen_it != instantiations_.end();\n               ++gen_it) {\n        const string& instantiation_name = gen_it->first;\n        ParamGenerator<ParamType> generator((*gen_it->second)());\n\n        string test_case_name;\n        if ( !instantiation_name.empty() )\n          test_case_name = instantiation_name + \"/\";\n        test_case_name += test_info->test_case_base_name;\n\n        int i = 0;\n        for (typename ParamGenerator<ParamType>::iterator param_it =\n                 generator.begin();\n             param_it != generator.end(); ++param_it, ++i) {\n          Message test_name_stream;\n          test_name_stream << test_info->test_base_name << \"/\" << i;\n          MakeAndRegisterTestInfo(\n              test_case_name.c_str(),\n              test_name_stream.GetString().c_str(),\n              NULL,  // No type parameter.\n              PrintToString(*param_it).c_str(),\n              GetTestCaseTypeId(),\n              TestCase::SetUpTestCase,\n              TestCase::TearDownTestCase,\n              test_info->test_meta_factory->CreateTestFactory(*param_it));\n        }  // for param_it\n      }  // for gen_it\n    }  // for test_it\n  }  // RegisterTests\n\n private:\n  // LocalTestInfo structure keeps information about a single test registered\n  // with TEST_P macro.\n  struct TestInfo {\n    TestInfo(const char* a_test_case_base_name,\n             const char* a_test_base_name,\n             TestMetaFactoryBase<ParamType>* a_test_meta_factory) :\n        test_case_base_name(a_test_case_base_name),\n        test_base_name(a_test_base_name),\n        test_meta_factory(a_test_meta_factory) {}\n\n    const string test_case_base_name;\n    const string test_base_name;\n    const scoped_ptr<TestMetaFactoryBase<ParamType> > test_meta_factory;\n  };\n  typedef ::std::vector<linked_ptr<TestInfo> > TestInfoContainer;\n  // Keeps pairs of <Instantiation name, Sequence generator creation function>\n  // received from INSTANTIATE_TEST_CASE_P macros.\n  typedef ::std::vector<std::pair<string, GeneratorCreationFunc*> >\n      InstantiationContainer;\n\n  const string test_case_name_;\n  TestInfoContainer tests_;\n  InstantiationContainer instantiations_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseInfo);\n};  // class ParameterizedTestCaseInfo\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// ParameterizedTestCaseRegistry contains a map of ParameterizedTestCaseInfoBase\n// classes accessed by test case names. TEST_P and INSTANTIATE_TEST_CASE_P\n// macros use it to locate their corresponding ParameterizedTestCaseInfo\n// descriptors.\nclass ParameterizedTestCaseRegistry {\n public:\n  ParameterizedTestCaseRegistry() {}\n  ~ParameterizedTestCaseRegistry() {\n    for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();\n         it != test_case_infos_.end(); ++it) {\n      delete *it;\n    }\n  }\n\n  // Looks up or creates and returns a structure containing information about\n  // tests and instantiations of a particular test case.\n  template <class TestCase>\n  ParameterizedTestCaseInfo<TestCase>* GetTestCasePatternHolder(\n      const char* test_case_name,\n      const char* file,\n      int line) {\n    ParameterizedTestCaseInfo<TestCase>* typed_test_info = NULL;\n    for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();\n         it != test_case_infos_.end(); ++it) {\n      if ((*it)->GetTestCaseName() == test_case_name) {\n        if ((*it)->GetTestCaseTypeId() != GetTypeId<TestCase>()) {\n          // Complain about incorrect usage of Google Test facilities\n          // and terminate the program since we cannot guaranty correct\n          // test case setup and tear-down in this case.\n          ReportInvalidTestCaseType(test_case_name,  file, line);\n          posix::Abort();\n        } else {\n          // At this point we are sure that the object we found is of the same\n          // type we are looking for, so we downcast it to that type\n          // without further checks.\n          typed_test_info = CheckedDowncastToActualType<\n              ParameterizedTestCaseInfo<TestCase> >(*it);\n        }\n        break;\n      }\n    }\n    if (typed_test_info == NULL) {\n      typed_test_info = new ParameterizedTestCaseInfo<TestCase>(test_case_name);\n      test_case_infos_.push_back(typed_test_info);\n    }\n    return typed_test_info;\n  }\n  void RegisterTests() {\n    for (TestCaseInfoContainer::iterator it = test_case_infos_.begin();\n         it != test_case_infos_.end(); ++it) {\n      (*it)->RegisterTests();\n    }\n  }\n\n private:\n  typedef ::std::vector<ParameterizedTestCaseInfoBase*> TestCaseInfoContainer;\n\n  TestCaseInfoContainer test_case_infos_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseRegistry);\n};\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  //  GTEST_HAS_PARAM_TEST\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/internal/gtest-port.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: wan@google.com (Zhanyong Wan)\n//\n// Low-level types and utilities for porting Google Test to various\n// platforms.  They are subject to change without notice.  DO NOT USE\n// THEM IN USER CODE.\n//\n// This file is fundamental to Google Test.  All other Google Test source\n// files are expected to #include this.  Therefore, it cannot #include\n// any other Google Test header.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_\n\n// The user can define the following macros in the build script to\n// control Google Test's behavior.  If the user doesn't define a macro\n// in this list, Google Test will define it.\n//\n//   GTEST_HAS_CLONE          - Define it to 1/0 to indicate that clone(2)\n//                              is/isn't available.\n//   GTEST_HAS_EXCEPTIONS     - Define it to 1/0 to indicate that exceptions\n//                              are enabled.\n//   GTEST_HAS_GLOBAL_STRING  - Define it to 1/0 to indicate that ::string\n//                              is/isn't available (some systems define\n//                              ::string, which is different to std::string).\n//   GTEST_HAS_GLOBAL_WSTRING - Define it to 1/0 to indicate that ::string\n//                              is/isn't available (some systems define\n//                              ::wstring, which is different to std::wstring).\n//   GTEST_HAS_POSIX_RE       - Define it to 1/0 to indicate that POSIX regular\n//                              expressions are/aren't available.\n//   GTEST_HAS_PTHREAD        - Define it to 1/0 to indicate that <pthread.h>\n//                              is/isn't available.\n//   GTEST_HAS_RTTI           - Define it to 1/0 to indicate that RTTI is/isn't\n//                              enabled.\n//   GTEST_HAS_STD_WSTRING    - Define it to 1/0 to indicate that\n//                              std::wstring does/doesn't work (Google Test can\n//                              be used where std::wstring is unavailable).\n//   GTEST_HAS_TR1_TUPLE      - Define it to 1/0 to indicate tr1::tuple\n//                              is/isn't available.\n//   GTEST_HAS_SEH            - Define it to 1/0 to indicate whether the\n//                              compiler supports Microsoft's \"Structured\n//                              Exception Handling\".\n//   GTEST_HAS_STREAM_REDIRECTION\n//                            - Define it to 1/0 to indicate whether the\n//                              platform supports I/O stream redirection using\n//                              dup() and dup2().\n//   GTEST_USE_OWN_TR1_TUPLE  - Define it to 1/0 to indicate whether Google\n//                              Test's own tr1 tuple implementation should be\n//                              used.  Unused when the user sets\n//                              GTEST_HAS_TR1_TUPLE to 0.\n//   GTEST_LANG_CXX11         - Define it to 1/0 to indicate that Google Test\n//                              is building in C++11/C++98 mode.\n//   GTEST_LINKED_AS_SHARED_LIBRARY\n//                            - Define to 1 when compiling tests that use\n//                              Google Test as a shared library (known as\n//                              DLL on Windows).\n//   GTEST_CREATE_SHARED_LIBRARY\n//                            - Define to 1 when compiling Google Test itself\n//                              as a shared library.\n\n// This header defines the following utilities:\n//\n// Macros indicating the current platform (defined to 1 if compiled on\n// the given platform; otherwise undefined):\n//   GTEST_OS_AIX      - IBM AIX\n//   GTEST_OS_CYGWIN   - Cygwin\n//   GTEST_OS_HPUX     - HP-UX\n//   GTEST_OS_LINUX    - Linux\n//     GTEST_OS_LINUX_ANDROID - Google Android\n//   GTEST_OS_MAC      - Mac OS X\n//     GTEST_OS_IOS    - iOS\n//       GTEST_OS_IOS_SIMULATOR - iOS simulator\n//   GTEST_OS_NACL     - Google Native Client (NaCl)\n//   GTEST_OS_OPENBSD  - OpenBSD\n//   GTEST_OS_QNX      - QNX\n//   GTEST_OS_SOLARIS  - Sun Solaris\n//   GTEST_OS_SYMBIAN  - Symbian\n//   GTEST_OS_WINDOWS  - Windows (Desktop, MinGW, or Mobile)\n//     GTEST_OS_WINDOWS_DESKTOP  - Windows Desktop\n//     GTEST_OS_WINDOWS_MINGW    - MinGW\n//     GTEST_OS_WINDOWS_MOBILE   - Windows Mobile\n//   GTEST_OS_ZOS      - z/OS\n//\n// Among the platforms, Cygwin, Linux, Max OS X, and Windows have the\n// most stable support.  Since core members of the Google Test project\n// don't have access to other platforms, support for them may be less\n// stable.  If you notice any problems on your platform, please notify\n// googletestframework@googlegroups.com (patches for fixing them are\n// even more welcome!).\n//\n// Note that it is possible that none of the GTEST_OS_* macros are defined.\n//\n// Macros indicating available Google Test features (defined to 1 if\n// the corresponding feature is supported; otherwise undefined):\n//   GTEST_HAS_COMBINE      - the Combine() function (for value-parameterized\n//                            tests)\n//   GTEST_HAS_DEATH_TEST   - death tests\n//   GTEST_HAS_PARAM_TEST   - value-parameterized tests\n//   GTEST_HAS_TYPED_TEST   - typed tests\n//   GTEST_HAS_TYPED_TEST_P - type-parameterized tests\n//   GTEST_USES_POSIX_RE    - enhanced POSIX regex is used. Do not confuse with\n//                            GTEST_HAS_POSIX_RE (see above) which users can\n//                            define themselves.\n//   GTEST_USES_SIMPLE_RE   - our own simple regex is used;\n//                            the above two are mutually exclusive.\n//   GTEST_CAN_COMPARE_NULL - accepts untyped NULL in EXPECT_EQ().\n//\n// Macros for basic C++ coding:\n//   GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning.\n//   GTEST_ATTRIBUTE_UNUSED_  - declares that a class' instances or a\n//                              variable don't have to be used.\n//   GTEST_DISALLOW_ASSIGN_   - disables operator=.\n//   GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=.\n//   GTEST_MUST_USE_RESULT_   - declares that a function's result must be used.\n//\n// Synchronization:\n//   Mutex, MutexLock, ThreadLocal, GetThreadCount()\n//                  - synchronization primitives.\n//   GTEST_IS_THREADSAFE - defined to 1 to indicate that the above\n//                         synchronization primitives have real implementations\n//                         and Google Test is thread-safe; or 0 otherwise.\n//\n// Template meta programming:\n//   is_pointer     - as in TR1; needed on Symbian and IBM XL C/C++ only.\n//   IteratorTraits - partial implementation of std::iterator_traits, which\n//                    is not available in libCstd when compiled with Sun C++.\n//\n// Smart pointers:\n//   scoped_ptr     - as in TR2.\n//\n// Regular expressions:\n//   RE             - a simple regular expression class using the POSIX\n//                    Extended Regular Expression syntax on UNIX-like\n//                    platforms, or a reduced regular exception syntax on\n//                    other platforms, including Windows.\n//\n// Logging:\n//   GTEST_LOG_()   - logs messages at the specified severity level.\n//   LogToStderr()  - directs all log messages to stderr.\n//   FlushInfoLog() - flushes informational log messages.\n//\n// Stdout and stderr capturing:\n//   CaptureStdout()     - starts capturing stdout.\n//   GetCapturedStdout() - stops capturing stdout and returns the captured\n//                         string.\n//   CaptureStderr()     - starts capturing stderr.\n//   GetCapturedStderr() - stops capturing stderr and returns the captured\n//                         string.\n//\n// Integer types:\n//   TypeWithSize   - maps an integer to a int type.\n//   Int32, UInt32, Int64, UInt64, TimeInMillis\n//                  - integers of known sizes.\n//   BiggestInt     - the biggest signed integer type.\n//\n// Command-line utilities:\n//   GTEST_FLAG()       - references a flag.\n//   GTEST_DECLARE_*()  - declares a flag.\n//   GTEST_DEFINE_*()   - defines a flag.\n//   GetInjectableArgvs() - returns the command line as a vector of strings.\n//\n// Environment variable utilities:\n//   GetEnv()             - gets the value of an environment variable.\n//   BoolFromGTestEnv()   - parses a bool environment variable.\n//   Int32FromGTestEnv()  - parses an Int32 environment variable.\n//   StringFromGTestEnv() - parses a string environment variable.\n\n#include <ctype.h>   // for isspace, etc\n#include <stddef.h>  // for ptrdiff_t\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n#ifndef _WIN32_WCE\n# include <sys/types.h>\n# include <sys/stat.h>\n#endif  // !_WIN32_WCE\n\n#if defined __APPLE__\n# include <AvailabilityMacros.h>\n# include <TargetConditionals.h>\n#endif\n\n#include <iostream>  // NOLINT\n#include <sstream>  // NOLINT\n#include <string>  // NOLINT\n\n#define GTEST_DEV_EMAIL_ \"googletestframework@@googlegroups.com\"\n#define GTEST_FLAG_PREFIX_ \"gtest_\"\n#define GTEST_FLAG_PREFIX_DASH_ \"gtest-\"\n#define GTEST_FLAG_PREFIX_UPPER_ \"GTEST_\"\n#define GTEST_NAME_ \"Google Test\"\n#define GTEST_PROJECT_URL_ \"http://code.google.com/p/googletest/\"\n\n// Determines the version of gcc that is used to compile this.\n#ifdef __GNUC__\n// 40302 means version 4.3.2.\n# define GTEST_GCC_VER_ \\\n    (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)\n#endif  // __GNUC__\n\n// Determines the platform on which Google Test is compiled.\n#ifdef __CYGWIN__\n# define GTEST_OS_CYGWIN 1\n#elif defined __SYMBIAN32__\n# define GTEST_OS_SYMBIAN 1\n#elif defined _WIN32\n# define GTEST_OS_WINDOWS 1\n# ifdef _WIN32_WCE\n#  define GTEST_OS_WINDOWS_MOBILE 1\n# elif defined(__MINGW__) || defined(__MINGW32__)\n#  define GTEST_OS_WINDOWS_MINGW 1\n# else\n#  define GTEST_OS_WINDOWS_DESKTOP 1\n# endif  // _WIN32_WCE\n#elif defined __APPLE__\n# define GTEST_OS_MAC 1\n# if TARGET_OS_IPHONE\n#  define GTEST_OS_IOS 1\n#  if TARGET_IPHONE_SIMULATOR\n#   define GTEST_OS_IOS_SIMULATOR 1\n#  endif\n# endif\n#elif defined __linux__\n# define GTEST_OS_LINUX 1\n# if defined __ANDROID__\n#  define GTEST_OS_LINUX_ANDROID 1\n# endif\n#elif defined __MVS__\n# define GTEST_OS_ZOS 1\n#elif defined(__sun) && defined(__SVR4)\n# define GTEST_OS_SOLARIS 1\n#elif defined(_AIX)\n# define GTEST_OS_AIX 1\n#elif defined(__hpux)\n# define GTEST_OS_HPUX 1\n#elif defined __native_client__\n# define GTEST_OS_NACL 1\n#elif defined __OpenBSD__\n# define GTEST_OS_OPENBSD 1\n#elif defined __QNX__\n# define GTEST_OS_QNX 1\n#endif  // __CYGWIN__\n\n#ifndef GTEST_LANG_CXX11\n// gcc and clang define __GXX_EXPERIMENTAL_CXX0X__ when\n// -std={c,gnu}++{0x,11} is passed.  The C++11 standard specifies a\n// value for __cplusplus, and recent versions of clang, gcc, and\n// probably other compilers set that too in C++11 mode.\n# if __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L\n// Compiling in at least C++11 mode.\n#  define GTEST_LANG_CXX11 1\n# else\n#  define GTEST_LANG_CXX11 0\n# endif\n#endif\n\n// Brings in definitions for functions used in the testing::internal::posix\n// namespace (read, write, close, chdir, isatty, stat). We do not currently\n// use them on Windows Mobile.\n#if !GTEST_OS_WINDOWS\n// This assumes that non-Windows OSes provide unistd.h. For OSes where this\n// is not the case, we need to include headers that provide the functions\n// mentioned above.\n# include <unistd.h>\n# include <strings.h>\n#elif !GTEST_OS_WINDOWS_MOBILE\n# include <direct.h>\n# include <io.h>\n#endif\n\n#if GTEST_OS_LINUX_ANDROID\n// Used to define __ANDROID_API__ matching the target NDK API level.\n#  include <android/api-level.h>  // NOLINT\n#endif\n\n// Defines this to true iff Google Test can use POSIX regular expressions.\n#ifndef GTEST_HAS_POSIX_RE\n# if GTEST_OS_LINUX_ANDROID\n// On Android, <regex.h> is only available starting with Gingerbread.\n#  define GTEST_HAS_POSIX_RE (__ANDROID_API__ >= 9)\n# else\n#  define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS)\n# endif\n#endif\n\n#if GTEST_HAS_POSIX_RE\n\n// On some platforms, <regex.h> needs someone to define size_t, and\n// won't compile otherwise.  We can #include it here as we already\n// included <stdlib.h>, which is guaranteed to define size_t through\n// <stddef.h>.\n# include <regex.h>  // NOLINT\n\n# define GTEST_USES_POSIX_RE 1\n\n#elif GTEST_OS_WINDOWS\n\n// <regex.h> is not available on Windows.  Use our own simple regex\n// implementation instead.\n# define GTEST_USES_SIMPLE_RE 1\n\n#else\n\n// <regex.h> may not be available on this platform.  Use our own\n// simple regex implementation instead.\n# define GTEST_USES_SIMPLE_RE 1\n\n#endif  // GTEST_HAS_POSIX_RE\n\n#ifndef GTEST_HAS_EXCEPTIONS\n// The user didn't tell us whether exceptions are enabled, so we need\n// to figure it out.\n# if defined(_MSC_VER) || defined(__BORLANDC__)\n// MSVC's and C++Builder's implementations of the STL use the _HAS_EXCEPTIONS\n// macro to enable exceptions, so we'll do the same.\n// Assumes that exceptions are enabled by default.\n#  ifndef _HAS_EXCEPTIONS\n#   define _HAS_EXCEPTIONS 1\n#  endif  // _HAS_EXCEPTIONS\n#  define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS\n# elif defined(__GNUC__) && __EXCEPTIONS\n// gcc defines __EXCEPTIONS to 1 iff exceptions are enabled.\n#  define GTEST_HAS_EXCEPTIONS 1\n# elif defined(__SUNPRO_CC)\n// Sun Pro CC supports exceptions.  However, there is no compile-time way of\n// detecting whether they are enabled or not.  Therefore, we assume that\n// they are enabled unless the user tells us otherwise.\n#  define GTEST_HAS_EXCEPTIONS 1\n# elif defined(__IBMCPP__) && __EXCEPTIONS\n// xlC defines __EXCEPTIONS to 1 iff exceptions are enabled.\n#  define GTEST_HAS_EXCEPTIONS 1\n# elif defined(__HP_aCC)\n// Exception handling is in effect by default in HP aCC compiler. It has to\n// be turned of by +noeh compiler option if desired.\n#  define GTEST_HAS_EXCEPTIONS 1\n# else\n// For other compilers, we assume exceptions are disabled to be\n// conservative.\n#  define GTEST_HAS_EXCEPTIONS 0\n# endif  // defined(_MSC_VER) || defined(__BORLANDC__)\n#endif  // GTEST_HAS_EXCEPTIONS\n\n#if !defined(GTEST_HAS_STD_STRING)\n// Even though we don't use this macro any longer, we keep it in case\n// some clients still depend on it.\n# define GTEST_HAS_STD_STRING 1\n#elif !GTEST_HAS_STD_STRING\n// The user told us that ::std::string isn't available.\n# error \"Google Test cannot be used where ::std::string isn't available.\"\n#endif  // !defined(GTEST_HAS_STD_STRING)\n\n#ifndef GTEST_HAS_GLOBAL_STRING\n// The user didn't tell us whether ::string is available, so we need\n// to figure it out.\n\n# define GTEST_HAS_GLOBAL_STRING 0\n\n#endif  // GTEST_HAS_GLOBAL_STRING\n\n#ifndef GTEST_HAS_STD_WSTRING\n// The user didn't tell us whether ::std::wstring is available, so we need\n// to figure it out.\n// TODO(wan@google.com): uses autoconf to detect whether ::std::wstring\n//   is available.\n\n// Cygwin 1.7 and below doesn't support ::std::wstring.\n// Solaris' libc++ doesn't support it either.  Android has\n// no support for it at least as recent as Froyo (2.2).\n# define GTEST_HAS_STD_WSTRING \\\n    (!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS))\n\n#endif  // GTEST_HAS_STD_WSTRING\n\n#ifndef GTEST_HAS_GLOBAL_WSTRING\n// The user didn't tell us whether ::wstring is available, so we need\n// to figure it out.\n# define GTEST_HAS_GLOBAL_WSTRING \\\n    (GTEST_HAS_STD_WSTRING && GTEST_HAS_GLOBAL_STRING)\n#endif  // GTEST_HAS_GLOBAL_WSTRING\n\n// Determines whether RTTI is available.\n#ifndef GTEST_HAS_RTTI\n// The user didn't tell us whether RTTI is enabled, so we need to\n// figure it out.\n\n# ifdef _MSC_VER\n\n#  ifdef _CPPRTTI  // MSVC defines this macro iff RTTI is enabled.\n#   define GTEST_HAS_RTTI 1\n#  else\n#   define GTEST_HAS_RTTI 0\n#  endif\n\n// Starting with version 4.3.2, gcc defines __GXX_RTTI iff RTTI is enabled.\n# elif defined(__GNUC__) && (GTEST_GCC_VER_ >= 40302)\n\n#  ifdef __GXX_RTTI\n// When building against STLport with the Android NDK and with\n// -frtti -fno-exceptions, the build fails at link time with undefined\n// references to __cxa_bad_typeid. Note sure if STL or toolchain bug,\n// so disable RTTI when detected.\n#   if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR) && \\\n       !defined(__EXCEPTIONS)\n#    define GTEST_HAS_RTTI 0\n#   else\n#    define GTEST_HAS_RTTI 1\n#   endif  // GTEST_OS_LINUX_ANDROID && __STLPORT_MAJOR && !__EXCEPTIONS\n#  else\n#   define GTEST_HAS_RTTI 0\n#  endif  // __GXX_RTTI\n\n// Clang defines __GXX_RTTI starting with version 3.0, but its manual recommends\n// using has_feature instead. has_feature(cxx_rtti) is supported since 2.7, the\n// first version with C++ support.\n# elif defined(__clang__)\n\n#  define GTEST_HAS_RTTI __has_feature(cxx_rtti)\n\n// Starting with version 9.0 IBM Visual Age defines __RTTI_ALL__ to 1 if\n// both the typeid and dynamic_cast features are present.\n# elif defined(__IBMCPP__) && (__IBMCPP__ >= 900)\n\n#  ifdef __RTTI_ALL__\n#   define GTEST_HAS_RTTI 1\n#  else\n#   define GTEST_HAS_RTTI 0\n#  endif\n\n# else\n\n// For all other compilers, we assume RTTI is enabled.\n#  define GTEST_HAS_RTTI 1\n\n# endif  // _MSC_VER\n\n#endif  // GTEST_HAS_RTTI\n\n// It's this header's responsibility to #include <typeinfo> when RTTI\n// is enabled.\n#if GTEST_HAS_RTTI\n# include <typeinfo>\n#endif\n\n// Determines whether Google Test can use the pthreads library.\n#ifndef GTEST_HAS_PTHREAD\n// The user didn't tell us explicitly, so we assume pthreads support is\n// available on Linux and Mac.\n//\n// To disable threading support in Google Test, add -DGTEST_HAS_PTHREAD=0\n// to your compiler flags.\n# define GTEST_HAS_PTHREAD (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX \\\n    || GTEST_OS_QNX)\n#endif  // GTEST_HAS_PTHREAD\n\n#if GTEST_HAS_PTHREAD\n// gtest-port.h guarantees to #include <pthread.h> when GTEST_HAS_PTHREAD is\n// true.\n# include <pthread.h>  // NOLINT\n\n// For timespec and nanosleep, used below.\n# include <time.h>  // NOLINT\n#endif\n\n// Determines whether Google Test can use tr1/tuple.  You can define\n// this macro to 0 to prevent Google Test from using tuple (any\n// feature depending on tuple with be disabled in this mode).\n#ifndef GTEST_HAS_TR1_TUPLE\n# if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR)\n// STLport, provided with the Android NDK, has neither <tr1/tuple> or <tuple>.\n#  define GTEST_HAS_TR1_TUPLE 0\n# else\n// The user didn't tell us not to do it, so we assume it's OK.\n#  define GTEST_HAS_TR1_TUPLE 1\n# endif\n#endif  // GTEST_HAS_TR1_TUPLE\n\n// Determines whether Google Test's own tr1 tuple implementation\n// should be used.\n#ifndef GTEST_USE_OWN_TR1_TUPLE\n// The user didn't tell us, so we need to figure it out.\n\n// We use our own TR1 tuple if we aren't sure the user has an\n// implementation of it already.  At this time, libstdc++ 4.0.0+ and\n// MSVC 2010 are the only mainstream standard libraries that come\n// with a TR1 tuple implementation.  NVIDIA's CUDA NVCC compiler\n// pretends to be GCC by defining __GNUC__ and friends, but cannot\n// compile GCC's tuple implementation.  MSVC 2008 (9.0) provides TR1\n// tuple in a 323 MB Feature Pack download, which we cannot assume the\n// user has.  QNX's QCC compiler is a modified GCC but it doesn't\n// support TR1 tuple.  libc++ only provides std::tuple, in C++11 mode,\n// and it can be used with some compilers that define __GNUC__.\n# if (defined(__GNUC__) && !defined(__CUDACC__) && (GTEST_GCC_VER_ >= 40000) \\\n      && !GTEST_OS_QNX && !defined(_LIBCPP_VERSION)) || _MSC_VER >= 1600\n#  define GTEST_ENV_HAS_TR1_TUPLE_ 1\n# endif\n\n// C++11 specifies that <tuple> provides std::tuple. Use that if gtest is used\n// in C++11 mode and libstdc++ isn't very old (binaries targeting OS X 10.6\n// can build with clang but need to use gcc4.2's libstdc++).\n# if GTEST_LANG_CXX11 && (!defined(__GLIBCXX__) || __GLIBCXX__ > 20110325)\n#  define GTEST_ENV_HAS_STD_TUPLE_ 1\n# endif\n\n# if GTEST_ENV_HAS_TR1_TUPLE_ || GTEST_ENV_HAS_STD_TUPLE_\n#  define GTEST_USE_OWN_TR1_TUPLE 0\n# else\n#  define GTEST_USE_OWN_TR1_TUPLE 1\n# endif\n\n#endif  // GTEST_USE_OWN_TR1_TUPLE\n\n// To avoid conditional compilation everywhere, we make it\n// gtest-port.h's responsibility to #include the header implementing\n// tr1/tuple.\n#if GTEST_HAS_TR1_TUPLE\n\n# if GTEST_USE_OWN_TR1_TUPLE\n#  include \"gtest/internal/gtest-tuple.h\"\n# elif GTEST_ENV_HAS_STD_TUPLE_\n#  include <tuple>\n// C++11 puts its tuple into the ::std namespace rather than\n// ::std::tr1.  gtest expects tuple to live in ::std::tr1, so put it there.\n// This causes undefined behavior, but supported compilers react in\n// the way we intend.\nnamespace std {\nnamespace tr1 {\nusing ::std::get;\nusing ::std::make_tuple;\nusing ::std::tuple;\nusing ::std::tuple_element;\nusing ::std::tuple_size;\n}\n}\n\n# elif GTEST_OS_SYMBIAN\n\n// On Symbian, BOOST_HAS_TR1_TUPLE causes Boost's TR1 tuple library to\n// use STLport's tuple implementation, which unfortunately doesn't\n// work as the copy of STLport distributed with Symbian is incomplete.\n// By making sure BOOST_HAS_TR1_TUPLE is undefined, we force Boost to\n// use its own tuple implementation.\n#  ifdef BOOST_HAS_TR1_TUPLE\n#   undef BOOST_HAS_TR1_TUPLE\n#  endif  // BOOST_HAS_TR1_TUPLE\n\n// This prevents <boost/tr1/detail/config.hpp>, which defines\n// BOOST_HAS_TR1_TUPLE, from being #included by Boost's <tuple>.\n#  define BOOST_TR1_DETAIL_CONFIG_HPP_INCLUDED\n#  include <tuple>\n\n# elif defined(__GNUC__) && (GTEST_GCC_VER_ >= 40000)\n// GCC 4.0+ implements tr1/tuple in the <tr1/tuple> header.  This does\n// not conform to the TR1 spec, which requires the header to be <tuple>.\n\n#  if !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302\n// Until version 4.3.2, gcc has a bug that causes <tr1/functional>,\n// which is #included by <tr1/tuple>, to not compile when RTTI is\n// disabled.  _TR1_FUNCTIONAL is the header guard for\n// <tr1/functional>.  Hence the following #define is a hack to prevent\n// <tr1/functional> from being included.\n#   define _TR1_FUNCTIONAL 1\n#   include <tr1/tuple>\n#   undef _TR1_FUNCTIONAL  // Allows the user to #include\n                        // <tr1/functional> if he chooses to.\n#  else\n#   include <tr1/tuple>  // NOLINT\n#  endif  // !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302\n\n# else\n// If the compiler is not GCC 4.0+, we assume the user is using a\n// spec-conforming TR1 implementation.\n#  include <tuple>  // NOLINT\n# endif  // GTEST_USE_OWN_TR1_TUPLE\n\n#endif  // GTEST_HAS_TR1_TUPLE\n\n// Determines whether clone(2) is supported.\n// Usually it will only be available on Linux, excluding\n// Linux on the Itanium architecture.\n// Also see http://linux.die.net/man/2/clone.\n#ifndef GTEST_HAS_CLONE\n// The user didn't tell us, so we need to figure it out.\n\n# if GTEST_OS_LINUX && !defined(__ia64__)\n#  if GTEST_OS_LINUX_ANDROID\n// On Android, clone() is only available on ARM starting with Gingerbread.\n#    if defined(__arm__) && __ANDROID_API__ >= 9\n#     define GTEST_HAS_CLONE 1\n#    else\n#     define GTEST_HAS_CLONE 0\n#    endif\n#  else\n#   define GTEST_HAS_CLONE 1\n#  endif\n# else\n#  define GTEST_HAS_CLONE 0\n# endif  // GTEST_OS_LINUX && !defined(__ia64__)\n\n#endif  // GTEST_HAS_CLONE\n\n// Determines whether to support stream redirection. This is used to test\n// output correctness and to implement death tests.\n#ifndef GTEST_HAS_STREAM_REDIRECTION\n// By default, we assume that stream redirection is supported on all\n// platforms except known mobile ones.\n# if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN\n#  define GTEST_HAS_STREAM_REDIRECTION 0\n# else\n#  define GTEST_HAS_STREAM_REDIRECTION 1\n# endif  // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_SYMBIAN\n#endif  // GTEST_HAS_STREAM_REDIRECTION\n\n// Determines whether to support death tests.\n// Google Test does not support death tests for VC 7.1 and earlier as\n// abort() in a VC 7.1 application compiled as GUI in debug config\n// pops up a dialog window that cannot be suppressed programmatically.\n#if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \\\n     (GTEST_OS_MAC && !GTEST_OS_IOS) || GTEST_OS_IOS_SIMULATOR || \\\n     (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || \\\n     GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \\\n     GTEST_OS_OPENBSD || GTEST_OS_QNX)\n# define GTEST_HAS_DEATH_TEST 1\n# include <vector>  // NOLINT\n#endif\n\n// We don't support MSVC 7.1 with exceptions disabled now.  Therefore\n// all the compilers we care about are adequate for supporting\n// value-parameterized tests.\n#define GTEST_HAS_PARAM_TEST 1\n\n// Determines whether to support type-driven tests.\n\n// Typed tests need <typeinfo> and variadic macros, which GCC, VC++ 8.0,\n// Sun Pro CC, IBM Visual Age, and HP aCC support.\n#if defined(__GNUC__) || (_MSC_VER >= 1400) || defined(__SUNPRO_CC) || \\\n    defined(__IBMCPP__) || defined(__HP_aCC)\n# define GTEST_HAS_TYPED_TEST 1\n# define GTEST_HAS_TYPED_TEST_P 1\n#endif\n\n// Determines whether to support Combine(). This only makes sense when\n// value-parameterized tests are enabled.  The implementation doesn't\n// work on Sun Studio since it doesn't understand templated conversion\n// operators.\n#if GTEST_HAS_PARAM_TEST && GTEST_HAS_TR1_TUPLE && !defined(__SUNPRO_CC)\n# define GTEST_HAS_COMBINE 1\n#endif\n\n// Determines whether the system compiler uses UTF-16 for encoding wide strings.\n#define GTEST_WIDE_STRING_USES_UTF16_ \\\n    (GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_SYMBIAN || GTEST_OS_AIX)\n\n// Determines whether test results can be streamed to a socket.\n#if GTEST_OS_LINUX\n# define GTEST_CAN_STREAM_RESULTS_ 1\n#endif\n\n// Defines some utility macros.\n\n// The GNU compiler emits a warning if nested \"if\" statements are followed by\n// an \"else\" statement and braces are not used to explicitly disambiguate the\n// \"else\" binding.  This leads to problems with code like:\n//\n//   if (gate)\n//     ASSERT_*(condition) << \"Some message\";\n//\n// The \"switch (0) case 0:\" idiom is used to suppress this.\n#ifdef __INTEL_COMPILER\n# define GTEST_AMBIGUOUS_ELSE_BLOCKER_\n#else\n# define GTEST_AMBIGUOUS_ELSE_BLOCKER_ switch (0) case 0: default:  // NOLINT\n#endif\n\n// Use this annotation at the end of a struct/class definition to\n// prevent the compiler from optimizing away instances that are never\n// used.  This is useful when all interesting logic happens inside the\n// c'tor and / or d'tor.  Example:\n//\n//   struct Foo {\n//     Foo() { ... }\n//   } GTEST_ATTRIBUTE_UNUSED_;\n//\n// Also use it after a variable or parameter declaration to tell the\n// compiler the variable/parameter does not have to be used.\n#if defined(__GNUC__) && !defined(COMPILER_ICC)\n# define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused))\n#else\n# define GTEST_ATTRIBUTE_UNUSED_\n#endif\n\n// A macro to disallow operator=\n// This should be used in the private: declarations for a class.\n#define GTEST_DISALLOW_ASSIGN_(type)\\\n  void operator=(type const &)\n\n// A macro to disallow copy constructor and operator=\n// This should be used in the private: declarations for a class.\n#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)\\\n  type(type const &);\\\n  GTEST_DISALLOW_ASSIGN_(type)\n\n// Tell the compiler to warn about unused return values for functions declared\n// with this macro.  The macro should be used on function declarations\n// following the argument list:\n//\n//   Sprocket* AllocateSprocket() GTEST_MUST_USE_RESULT_;\n#if defined(__GNUC__) && (GTEST_GCC_VER_ >= 30400) && !defined(COMPILER_ICC)\n# define GTEST_MUST_USE_RESULT_ __attribute__ ((warn_unused_result))\n#else\n# define GTEST_MUST_USE_RESULT_\n#endif  // __GNUC__ && (GTEST_GCC_VER_ >= 30400) && !COMPILER_ICC\n\n// Determine whether the compiler supports Microsoft's Structured Exception\n// Handling.  This is supported by several Windows compilers but generally\n// does not exist on any other system.\n#ifndef GTEST_HAS_SEH\n// The user didn't tell us, so we need to figure it out.\n\n# if defined(_MSC_VER) || defined(__BORLANDC__)\n// These two compilers are known to support SEH.\n#  define GTEST_HAS_SEH 1\n# else\n// Assume no SEH.\n#  define GTEST_HAS_SEH 0\n# endif\n\n#endif  // GTEST_HAS_SEH\n\n#ifdef _MSC_VER\n\n# if GTEST_LINKED_AS_SHARED_LIBRARY\n#  define GTEST_API_ __declspec(dllimport)\n# elif GTEST_CREATE_SHARED_LIBRARY\n#  define GTEST_API_ __declspec(dllexport)\n# endif\n\n#endif  // _MSC_VER\n\n#ifndef GTEST_API_\n# define GTEST_API_\n#endif\n\n#ifdef __GNUC__\n// Ask the compiler to never inline a given function.\n# define GTEST_NO_INLINE_ __attribute__((noinline))\n#else\n# define GTEST_NO_INLINE_\n#endif\n\n// _LIBCPP_VERSION is defined by the libc++ library from the LLVM project.\n#if defined(__GLIBCXX__) || defined(_LIBCPP_VERSION)\n# define GTEST_HAS_CXXABI_H_ 1\n#else\n# define GTEST_HAS_CXXABI_H_ 0\n#endif\n\nnamespace testing {\n\nclass Message;\n\nnamespace internal {\n\n// A secret type that Google Test users don't know about.  It has no\n// definition on purpose.  Therefore it's impossible to create a\n// Secret object, which is what we want.\nclass Secret;\n\n// The GTEST_COMPILE_ASSERT_ macro can be used to verify that a compile time\n// expression is true. For example, you could use it to verify the\n// size of a static array:\n//\n//   GTEST_COMPILE_ASSERT_(ARRAYSIZE(content_type_names) == CONTENT_NUM_TYPES,\n//                         content_type_names_incorrect_size);\n//\n// or to make sure a struct is smaller than a certain size:\n//\n//   GTEST_COMPILE_ASSERT_(sizeof(foo) < 128, foo_too_large);\n//\n// The second argument to the macro is the name of the variable. If\n// the expression is false, most compilers will issue a warning/error\n// containing the name of the variable.\n\ntemplate <bool>\nstruct CompileAssert {\n};\n\n#define GTEST_COMPILE_ASSERT_(expr, msg) \\\n  typedef ::testing::internal::CompileAssert<(static_cast<bool>(expr))> \\\n      msg[static_cast<bool>(expr) ? 1 : -1] GTEST_ATTRIBUTE_UNUSED_\n\n// Implementation details of GTEST_COMPILE_ASSERT_:\n//\n// - GTEST_COMPILE_ASSERT_ works by defining an array type that has -1\n//   elements (and thus is invalid) when the expression is false.\n//\n// - The simpler definition\n//\n//    #define GTEST_COMPILE_ASSERT_(expr, msg) typedef char msg[(expr) ? 1 : -1]\n//\n//   does not work, as gcc supports variable-length arrays whose sizes\n//   are determined at run-time (this is gcc's extension and not part\n//   of the C++ standard).  As a result, gcc fails to reject the\n//   following code with the simple definition:\n//\n//     int foo;\n//     GTEST_COMPILE_ASSERT_(foo, msg); // not supposed to compile as foo is\n//                                      // not a compile-time constant.\n//\n// - By using the type CompileAssert<(bool(expr))>, we ensures that\n//   expr is a compile-time constant.  (Template arguments must be\n//   determined at compile-time.)\n//\n// - The outter parentheses in CompileAssert<(bool(expr))> are necessary\n//   to work around a bug in gcc 3.4.4 and 4.0.1.  If we had written\n//\n//     CompileAssert<bool(expr)>\n//\n//   instead, these compilers will refuse to compile\n//\n//     GTEST_COMPILE_ASSERT_(5 > 0, some_message);\n//\n//   (They seem to think the \">\" in \"5 > 0\" marks the end of the\n//   template argument list.)\n//\n// - The array size is (bool(expr) ? 1 : -1), instead of simply\n//\n//     ((expr) ? 1 : -1).\n//\n//   This is to avoid running into a bug in MS VC 7.1, which\n//   causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1.\n\n// StaticAssertTypeEqHelper is used by StaticAssertTypeEq defined in gtest.h.\n//\n// This template is declared, but intentionally undefined.\ntemplate <typename T1, typename T2>\nstruct StaticAssertTypeEqHelper;\n\ntemplate <typename T>\nstruct StaticAssertTypeEqHelper<T, T> {};\n\n#if GTEST_HAS_GLOBAL_STRING\ntypedef ::string string;\n#else\ntypedef ::std::string string;\n#endif  // GTEST_HAS_GLOBAL_STRING\n\n#if GTEST_HAS_GLOBAL_WSTRING\ntypedef ::wstring wstring;\n#elif GTEST_HAS_STD_WSTRING\ntypedef ::std::wstring wstring;\n#endif  // GTEST_HAS_GLOBAL_WSTRING\n\n// A helper for suppressing warnings on constant condition.  It just\n// returns 'condition'.\nGTEST_API_ bool IsTrue(bool condition);\n\n// Defines scoped_ptr.\n\n// This implementation of scoped_ptr is PARTIAL - it only contains\n// enough stuff to satisfy Google Test's need.\ntemplate <typename T>\nclass scoped_ptr {\n public:\n  typedef T element_type;\n\n  explicit scoped_ptr(T* p = NULL) : ptr_(p) {}\n  ~scoped_ptr() { reset(); }\n\n  T& operator*() const { return *ptr_; }\n  T* operator->() const { return ptr_; }\n  T* get() const { return ptr_; }\n\n  T* release() {\n    T* const ptr = ptr_;\n    ptr_ = NULL;\n    return ptr;\n  }\n\n  void reset(T* p = NULL) {\n    if (p != ptr_) {\n      if (IsTrue(sizeof(T) > 0)) {  // Makes sure T is a complete type.\n        delete ptr_;\n      }\n      ptr_ = p;\n    }\n  }\n\n private:\n  T* ptr_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(scoped_ptr);\n};\n\n// Defines RE.\n\n// A simple C++ wrapper for <regex.h>.  It uses the POSIX Extended\n// Regular Expression syntax.\nclass GTEST_API_ RE {\n public:\n  // A copy constructor is required by the Standard to initialize object\n  // references from r-values.\n  RE(const RE& other) { Init(other.pattern()); }\n\n  // Constructs an RE from a string.\n  RE(const ::std::string& regex) { Init(regex.c_str()); }  // NOLINT\n\n#if GTEST_HAS_GLOBAL_STRING\n\n  RE(const ::string& regex) { Init(regex.c_str()); }  // NOLINT\n\n#endif  // GTEST_HAS_GLOBAL_STRING\n\n  RE(const char* regex) { Init(regex); }  // NOLINT\n  ~RE();\n\n  // Returns the string representation of the regex.\n  const char* pattern() const { return pattern_; }\n\n  // FullMatch(str, re) returns true iff regular expression re matches\n  // the entire str.\n  // PartialMatch(str, re) returns true iff regular expression re\n  // matches a substring of str (including str itself).\n  //\n  // TODO(wan@google.com): make FullMatch() and PartialMatch() work\n  // when str contains NUL characters.\n  static bool FullMatch(const ::std::string& str, const RE& re) {\n    return FullMatch(str.c_str(), re);\n  }\n  static bool PartialMatch(const ::std::string& str, const RE& re) {\n    return PartialMatch(str.c_str(), re);\n  }\n\n#if GTEST_HAS_GLOBAL_STRING\n\n  static bool FullMatch(const ::string& str, const RE& re) {\n    return FullMatch(str.c_str(), re);\n  }\n  static bool PartialMatch(const ::string& str, const RE& re) {\n    return PartialMatch(str.c_str(), re);\n  }\n\n#endif  // GTEST_HAS_GLOBAL_STRING\n\n  static bool FullMatch(const char* str, const RE& re);\n  static bool PartialMatch(const char* str, const RE& re);\n\n private:\n  void Init(const char* regex);\n\n  // We use a const char* instead of an std::string, as Google Test used to be\n  // used where std::string is not available.  TODO(wan@google.com): change to\n  // std::string.\n  const char* pattern_;\n  bool is_valid_;\n\n#if GTEST_USES_POSIX_RE\n\n  regex_t full_regex_;     // For FullMatch().\n  regex_t partial_regex_;  // For PartialMatch().\n\n#else  // GTEST_USES_SIMPLE_RE\n\n  const char* full_pattern_;  // For FullMatch();\n\n#endif\n\n  GTEST_DISALLOW_ASSIGN_(RE);\n};\n\n// Formats a source file path and a line number as they would appear\n// in an error message from the compiler used to compile this code.\nGTEST_API_ ::std::string FormatFileLocation(const char* file, int line);\n\n// Formats a file location for compiler-independent XML output.\n// Although this function is not platform dependent, we put it next to\n// FormatFileLocation in order to contrast the two functions.\nGTEST_API_ ::std::string FormatCompilerIndependentFileLocation(const char* file,\n                                                               int line);\n\n// Defines logging utilities:\n//   GTEST_LOG_(severity) - logs messages at the specified severity level. The\n//                          message itself is streamed into the macro.\n//   LogToStderr()  - directs all log messages to stderr.\n//   FlushInfoLog() - flushes informational log messages.\n\nenum GTestLogSeverity {\n  GTEST_INFO,\n  GTEST_WARNING,\n  GTEST_ERROR,\n  GTEST_FATAL\n};\n\n// Formats log entry severity, provides a stream object for streaming the\n// log message, and terminates the message with a newline when going out of\n// scope.\nclass GTEST_API_ GTestLog {\n public:\n  GTestLog(GTestLogSeverity severity, const char* file, int line);\n\n  // Flushes the buffers and, if severity is GTEST_FATAL, aborts the program.\n  ~GTestLog();\n\n  ::std::ostream& GetStream() { return ::std::cerr; }\n\n private:\n  const GTestLogSeverity severity_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestLog);\n};\n\n#define GTEST_LOG_(severity) \\\n    ::testing::internal::GTestLog(::testing::internal::GTEST_##severity, \\\n                                  __FILE__, __LINE__).GetStream()\n\ninline void LogToStderr() {}\ninline void FlushInfoLog() { fflush(NULL); }\n\n// INTERNAL IMPLEMENTATION - DO NOT USE.\n//\n// GTEST_CHECK_ is an all-mode assert. It aborts the program if the condition\n// is not satisfied.\n//  Synopsys:\n//    GTEST_CHECK_(boolean_condition);\n//     or\n//    GTEST_CHECK_(boolean_condition) << \"Additional message\";\n//\n//    This checks the condition and if the condition is not satisfied\n//    it prints message about the condition violation, including the\n//    condition itself, plus additional message streamed into it, if any,\n//    and then it aborts the program. It aborts the program irrespective of\n//    whether it is built in the debug mode or not.\n#define GTEST_CHECK_(condition) \\\n    GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\n    if (::testing::internal::IsTrue(condition)) \\\n      ; \\\n    else \\\n      GTEST_LOG_(FATAL) << \"Condition \" #condition \" failed. \"\n\n// An all-mode assert to verify that the given POSIX-style function\n// call returns 0 (indicating success).  Known limitation: this\n// doesn't expand to a balanced 'if' statement, so enclose the macro\n// in {} if you need to use it as the only statement in an 'if'\n// branch.\n#define GTEST_CHECK_POSIX_SUCCESS_(posix_call) \\\n  if (const int gtest_error = (posix_call)) \\\n    GTEST_LOG_(FATAL) << #posix_call << \"failed with error \" \\\n                      << gtest_error\n\n// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.\n//\n// Use ImplicitCast_ as a safe version of static_cast for upcasting in\n// the type hierarchy (e.g. casting a Foo* to a SuperclassOfFoo* or a\n// const Foo*).  When you use ImplicitCast_, the compiler checks that\n// the cast is safe.  Such explicit ImplicitCast_s are necessary in\n// surprisingly many situations where C++ demands an exact type match\n// instead of an argument type convertable to a target type.\n//\n// The syntax for using ImplicitCast_ is the same as for static_cast:\n//\n//   ImplicitCast_<ToType>(expr)\n//\n// ImplicitCast_ would have been part of the C++ standard library,\n// but the proposal was submitted too late.  It will probably make\n// its way into the language in the future.\n//\n// This relatively ugly name is intentional. It prevents clashes with\n// similar functions users may have (e.g., implicit_cast). The internal\n// namespace alone is not enough because the function can be found by ADL.\ntemplate<typename To>\ninline To ImplicitCast_(To x) { return x; }\n\n// When you upcast (that is, cast a pointer from type Foo to type\n// SuperclassOfFoo), it's fine to use ImplicitCast_<>, since upcasts\n// always succeed.  When you downcast (that is, cast a pointer from\n// type Foo to type SubclassOfFoo), static_cast<> isn't safe, because\n// how do you know the pointer is really of type SubclassOfFoo?  It\n// could be a bare Foo, or of type DifferentSubclassOfFoo.  Thus,\n// when you downcast, you should use this macro.  In debug mode, we\n// use dynamic_cast<> to double-check the downcast is legal (we die\n// if it's not).  In normal mode, we do the efficient static_cast<>\n// instead.  Thus, it's important to test in debug mode to make sure\n// the cast is legal!\n//    This is the only place in the code we should use dynamic_cast<>.\n// In particular, you SHOULDN'T be using dynamic_cast<> in order to\n// do RTTI (eg code like this:\n//    if (dynamic_cast<Subclass1>(foo)) HandleASubclass1Object(foo);\n//    if (dynamic_cast<Subclass2>(foo)) HandleASubclass2Object(foo);\n// You should design the code some other way not to need this.\n//\n// This relatively ugly name is intentional. It prevents clashes with\n// similar functions users may have (e.g., down_cast). The internal\n// namespace alone is not enough because the function can be found by ADL.\ntemplate<typename To, typename From>  // use like this: DownCast_<T*>(foo);\ninline To DownCast_(From* f) {  // so we only accept pointers\n  // Ensures that To is a sub-type of From *.  This test is here only\n  // for compile-time type checking, and has no overhead in an\n  // optimized build at run-time, as it will be optimized away\n  // completely.\n  if (false) {\n    const To to = NULL;\n    ::testing::internal::ImplicitCast_<From*>(to);\n  }\n\n#if GTEST_HAS_RTTI\n  // RTTI: debug mode only!\n  GTEST_CHECK_(f == NULL || dynamic_cast<To>(f) != NULL);\n#endif\n  return static_cast<To>(f);\n}\n\n// Downcasts the pointer of type Base to Derived.\n// Derived must be a subclass of Base. The parameter MUST\n// point to a class of type Derived, not any subclass of it.\n// When RTTI is available, the function performs a runtime\n// check to enforce this.\ntemplate <class Derived, class Base>\nDerived* CheckedDowncastToActualType(Base* base) {\n#if GTEST_HAS_RTTI\n  GTEST_CHECK_(typeid(*base) == typeid(Derived));\n  return dynamic_cast<Derived*>(base);  // NOLINT\n#else\n  return static_cast<Derived*>(base);  // Poor man's downcast.\n#endif\n}\n\n#if GTEST_HAS_STREAM_REDIRECTION\n\n// Defines the stderr capturer:\n//   CaptureStdout     - starts capturing stdout.\n//   GetCapturedStdout - stops capturing stdout and returns the captured string.\n//   CaptureStderr     - starts capturing stderr.\n//   GetCapturedStderr - stops capturing stderr and returns the captured string.\n//\nGTEST_API_ void CaptureStdout();\nGTEST_API_ std::string GetCapturedStdout();\nGTEST_API_ void CaptureStderr();\nGTEST_API_ std::string GetCapturedStderr();\n\n#endif  // GTEST_HAS_STREAM_REDIRECTION\n\n\n#if GTEST_HAS_DEATH_TEST\n\nconst ::std::vector<testing::internal::string>& GetInjectableArgvs();\nvoid SetInjectableArgvs(const ::std::vector<testing::internal::string>*\n                             new_argvs);\n\n// A copy of all command line arguments.  Set by InitGoogleTest().\nextern ::std::vector<testing::internal::string> g_argvs;\n\n#endif  // GTEST_HAS_DEATH_TEST\n\n// Defines synchronization primitives.\n\n#if GTEST_HAS_PTHREAD\n\n// Sleeps for (roughly) n milli-seconds.  This function is only for\n// testing Google Test's own constructs.  Don't use it in user tests,\n// either directly or indirectly.\ninline void SleepMilliseconds(int n) {\n  const timespec time = {\n    0,                  // 0 seconds.\n    n * 1000L * 1000L,  // And n ms.\n  };\n  nanosleep(&time, NULL);\n}\n\n// Allows a controller thread to pause execution of newly created\n// threads until notified.  Instances of this class must be created\n// and destroyed in the controller thread.\n//\n// This class is only for testing Google Test's own constructs. Do not\n// use it in user tests, either directly or indirectly.\nclass Notification {\n public:\n  Notification() : notified_(false) {\n    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, NULL));\n  }\n  ~Notification() {\n    pthread_mutex_destroy(&mutex_);\n  }\n\n  // Notifies all threads created with this notification to start. Must\n  // be called from the controller thread.\n  void Notify() {\n    pthread_mutex_lock(&mutex_);\n    notified_ = true;\n    pthread_mutex_unlock(&mutex_);\n  }\n\n  // Blocks until the controller thread notifies. Must be called from a test\n  // thread.\n  void WaitForNotification() {\n    for (;;) {\n      pthread_mutex_lock(&mutex_);\n      const bool notified = notified_;\n      pthread_mutex_unlock(&mutex_);\n      if (notified)\n        break;\n      SleepMilliseconds(10);\n    }\n  }\n\n private:\n  pthread_mutex_t mutex_;\n  bool notified_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification);\n};\n\n// As a C-function, ThreadFuncWithCLinkage cannot be templated itself.\n// Consequently, it cannot select a correct instantiation of ThreadWithParam\n// in order to call its Run(). Introducing ThreadWithParamBase as a\n// non-templated base class for ThreadWithParam allows us to bypass this\n// problem.\nclass ThreadWithParamBase {\n public:\n  virtual ~ThreadWithParamBase() {}\n  virtual void Run() = 0;\n};\n\n// pthread_create() accepts a pointer to a function type with the C linkage.\n// According to the Standard (7.5/1), function types with different linkages\n// are different even if they are otherwise identical.  Some compilers (for\n// example, SunStudio) treat them as different types.  Since class methods\n// cannot be defined with C-linkage we need to define a free C-function to\n// pass into pthread_create().\nextern \"C\" inline void* ThreadFuncWithCLinkage(void* thread) {\n  static_cast<ThreadWithParamBase*>(thread)->Run();\n  return NULL;\n}\n\n// Helper class for testing Google Test's multi-threading constructs.\n// To use it, write:\n//\n//   void ThreadFunc(int param) { /* Do things with param */ }\n//   Notification thread_can_start;\n//   ...\n//   // The thread_can_start parameter is optional; you can supply NULL.\n//   ThreadWithParam<int> thread(&ThreadFunc, 5, &thread_can_start);\n//   thread_can_start.Notify();\n//\n// These classes are only for testing Google Test's own constructs. Do\n// not use them in user tests, either directly or indirectly.\ntemplate <typename T>\nclass ThreadWithParam : public ThreadWithParamBase {\n public:\n  typedef void (*UserThreadFunc)(T);\n\n  ThreadWithParam(\n      UserThreadFunc func, T param, Notification* thread_can_start)\n      : func_(func),\n        param_(param),\n        thread_can_start_(thread_can_start),\n        finished_(false) {\n    ThreadWithParamBase* const base = this;\n    // The thread can be created only after all fields except thread_\n    // have been initialized.\n    GTEST_CHECK_POSIX_SUCCESS_(\n        pthread_create(&thread_, 0, &ThreadFuncWithCLinkage, base));\n  }\n  ~ThreadWithParam() { Join(); }\n\n  void Join() {\n    if (!finished_) {\n      GTEST_CHECK_POSIX_SUCCESS_(pthread_join(thread_, 0));\n      finished_ = true;\n    }\n  }\n\n  virtual void Run() {\n    if (thread_can_start_ != NULL)\n      thread_can_start_->WaitForNotification();\n    func_(param_);\n  }\n\n private:\n  const UserThreadFunc func_;  // User-supplied thread function.\n  const T param_;  // User-supplied parameter to the thread function.\n  // When non-NULL, used to block execution until the controller thread\n  // notifies.\n  Notification* const thread_can_start_;\n  bool finished_;  // true iff we know that the thread function has finished.\n  pthread_t thread_;  // The native thread object.\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam);\n};\n\n// MutexBase and Mutex implement mutex on pthreads-based platforms. They\n// are used in conjunction with class MutexLock:\n//\n//   Mutex mutex;\n//   ...\n//   MutexLock lock(&mutex);  // Acquires the mutex and releases it at the end\n//                            // of the current scope.\n//\n// MutexBase implements behavior for both statically and dynamically\n// allocated mutexes.  Do not use MutexBase directly.  Instead, write\n// the following to define a static mutex:\n//\n//   GTEST_DEFINE_STATIC_MUTEX_(g_some_mutex);\n//\n// You can forward declare a static mutex like this:\n//\n//   GTEST_DECLARE_STATIC_MUTEX_(g_some_mutex);\n//\n// To create a dynamic mutex, just define an object of type Mutex.\nclass MutexBase {\n public:\n  // Acquires this mutex.\n  void Lock() {\n    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&mutex_));\n    owner_ = pthread_self();\n    has_owner_ = true;\n  }\n\n  // Releases this mutex.\n  void Unlock() {\n    // Since the lock is being released the owner_ field should no longer be\n    // considered valid. We don't protect writing to has_owner_ here, as it's\n    // the caller's responsibility to ensure that the current thread holds the\n    // mutex when this is called.\n    has_owner_ = false;\n    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_unlock(&mutex_));\n  }\n\n  // Does nothing if the current thread holds the mutex. Otherwise, crashes\n  // with high probability.\n  void AssertHeld() const {\n    GTEST_CHECK_(has_owner_ && pthread_equal(owner_, pthread_self()))\n        << \"The current thread is not holding the mutex @\" << this;\n  }\n\n  // A static mutex may be used before main() is entered.  It may even\n  // be used before the dynamic initialization stage.  Therefore we\n  // must be able to initialize a static mutex object at link time.\n  // This means MutexBase has to be a POD and its member variables\n  // have to be public.\n public:\n  pthread_mutex_t mutex_;  // The underlying pthread mutex.\n  // has_owner_ indicates whether the owner_ field below contains a valid thread\n  // ID and is therefore safe to inspect (e.g., to use in pthread_equal()). All\n  // accesses to the owner_ field should be protected by a check of this field.\n  // An alternative might be to memset() owner_ to all zeros, but there's no\n  // guarantee that a zero'd pthread_t is necessarily invalid or even different\n  // from pthread_self().\n  bool has_owner_;\n  pthread_t owner_;  // The thread holding the mutex.\n};\n\n// Forward-declares a static mutex.\n# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \\\n    extern ::testing::internal::MutexBase mutex\n\n// Defines and statically (i.e. at link time) initializes a static mutex.\n// The initialization list here does not explicitly initialize each field,\n// instead relying on default initialization for the unspecified fields. In\n// particular, the owner_ field (a pthread_t) is not explicitly initialized.\n// This allows initialization to work whether pthread_t is a scalar or struct.\n// The flag -Wmissing-field-initializers must not be specified for this to work.\n# define GTEST_DEFINE_STATIC_MUTEX_(mutex) \\\n    ::testing::internal::MutexBase mutex = { PTHREAD_MUTEX_INITIALIZER, false }\n\n// The Mutex class can only be used for mutexes created at runtime. It\n// shares its API with MutexBase otherwise.\nclass Mutex : public MutexBase {\n public:\n  Mutex() {\n    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, NULL));\n    has_owner_ = false;\n  }\n  ~Mutex() {\n    GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&mutex_));\n  }\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex);\n};\n\n// We cannot name this class MutexLock as the ctor declaration would\n// conflict with a macro named MutexLock, which is defined on some\n// platforms.  Hence the typedef trick below.\nclass GTestMutexLock {\n public:\n  explicit GTestMutexLock(MutexBase* mutex)\n      : mutex_(mutex) { mutex_->Lock(); }\n\n  ~GTestMutexLock() { mutex_->Unlock(); }\n\n private:\n  MutexBase* const mutex_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock);\n};\n\ntypedef GTestMutexLock MutexLock;\n\n// Helpers for ThreadLocal.\n\n// pthread_key_create() requires DeleteThreadLocalValue() to have\n// C-linkage.  Therefore it cannot be templatized to access\n// ThreadLocal<T>.  Hence the need for class\n// ThreadLocalValueHolderBase.\nclass ThreadLocalValueHolderBase {\n public:\n  virtual ~ThreadLocalValueHolderBase() {}\n};\n\n// Called by pthread to delete thread-local data stored by\n// pthread_setspecific().\nextern \"C\" inline void DeleteThreadLocalValue(void* value_holder) {\n  delete static_cast<ThreadLocalValueHolderBase*>(value_holder);\n}\n\n// Implements thread-local storage on pthreads-based systems.\n//\n//   // Thread 1\n//   ThreadLocal<int> tl(100);  // 100 is the default value for each thread.\n//\n//   // Thread 2\n//   tl.set(150);  // Changes the value for thread 2 only.\n//   EXPECT_EQ(150, tl.get());\n//\n//   // Thread 1\n//   EXPECT_EQ(100, tl.get());  // In thread 1, tl has the original value.\n//   tl.set(200);\n//   EXPECT_EQ(200, tl.get());\n//\n// The template type argument T must have a public copy constructor.\n// In addition, the default ThreadLocal constructor requires T to have\n// a public default constructor.\n//\n// An object managed for a thread by a ThreadLocal instance is deleted\n// when the thread exits.  Or, if the ThreadLocal instance dies in\n// that thread, when the ThreadLocal dies.  It's the user's\n// responsibility to ensure that all other threads using a ThreadLocal\n// have exited when it dies, or the per-thread objects for those\n// threads will not be deleted.\n//\n// Google Test only uses global ThreadLocal objects.  That means they\n// will die after main() has returned.  Therefore, no per-thread\n// object managed by Google Test will be leaked as long as all threads\n// using Google Test have exited when main() returns.\ntemplate <typename T>\nclass ThreadLocal {\n public:\n  ThreadLocal() : key_(CreateKey()),\n                  default_() {}\n  explicit ThreadLocal(const T& value) : key_(CreateKey()),\n                                         default_(value) {}\n\n  ~ThreadLocal() {\n    // Destroys the managed object for the current thread, if any.\n    DeleteThreadLocalValue(pthread_getspecific(key_));\n\n    // Releases resources associated with the key.  This will *not*\n    // delete managed objects for other threads.\n    GTEST_CHECK_POSIX_SUCCESS_(pthread_key_delete(key_));\n  }\n\n  T* pointer() { return GetOrCreateValue(); }\n  const T* pointer() const { return GetOrCreateValue(); }\n  const T& get() const { return *pointer(); }\n  void set(const T& value) { *pointer() = value; }\n\n private:\n  // Holds a value of type T.\n  class ValueHolder : public ThreadLocalValueHolderBase {\n   public:\n    explicit ValueHolder(const T& value) : value_(value) {}\n\n    T* pointer() { return &value_; }\n\n   private:\n    T value_;\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder);\n  };\n\n  static pthread_key_t CreateKey() {\n    pthread_key_t key;\n    // When a thread exits, DeleteThreadLocalValue() will be called on\n    // the object managed for that thread.\n    GTEST_CHECK_POSIX_SUCCESS_(\n        pthread_key_create(&key, &DeleteThreadLocalValue));\n    return key;\n  }\n\n  T* GetOrCreateValue() const {\n    ThreadLocalValueHolderBase* const holder =\n        static_cast<ThreadLocalValueHolderBase*>(pthread_getspecific(key_));\n    if (holder != NULL) {\n      return CheckedDowncastToActualType<ValueHolder>(holder)->pointer();\n    }\n\n    ValueHolder* const new_holder = new ValueHolder(default_);\n    ThreadLocalValueHolderBase* const holder_base = new_holder;\n    GTEST_CHECK_POSIX_SUCCESS_(pthread_setspecific(key_, holder_base));\n    return new_holder->pointer();\n  }\n\n  // A key pthreads uses for looking up per-thread values.\n  const pthread_key_t key_;\n  const T default_;  // The default value for each thread.\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal);\n};\n\n# define GTEST_IS_THREADSAFE 1\n\n#else  // GTEST_HAS_PTHREAD\n\n// A dummy implementation of synchronization primitives (mutex, lock,\n// and thread-local variable).  Necessary for compiling Google Test where\n// mutex is not supported - using Google Test in multiple threads is not\n// supported on such platforms.\n\nclass Mutex {\n public:\n  Mutex() {}\n  void Lock() {}\n  void Unlock() {}\n  void AssertHeld() const {}\n};\n\n# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \\\n  extern ::testing::internal::Mutex mutex\n\n# define GTEST_DEFINE_STATIC_MUTEX_(mutex) ::testing::internal::Mutex mutex\n\nclass GTestMutexLock {\n public:\n  explicit GTestMutexLock(Mutex*) {}  // NOLINT\n};\n\ntypedef GTestMutexLock MutexLock;\n\ntemplate <typename T>\nclass ThreadLocal {\n public:\n  ThreadLocal() : value_() {}\n  explicit ThreadLocal(const T& value) : value_(value) {}\n  T* pointer() { return &value_; }\n  const T* pointer() const { return &value_; }\n  const T& get() const { return value_; }\n  void set(const T& value) { value_ = value; }\n private:\n  T value_;\n};\n\n// The above synchronization primitives have dummy implementations.\n// Therefore Google Test is not thread-safe.\n# define GTEST_IS_THREADSAFE 0\n\n#endif  // GTEST_HAS_PTHREAD\n\n// Returns the number of threads running in the process, or 0 to indicate that\n// we cannot detect it.\nGTEST_API_ size_t GetThreadCount();\n\n// Passing non-POD classes through ellipsis (...) crashes the ARM\n// compiler and generates a warning in Sun Studio.  The Nokia Symbian\n// and the IBM XL C/C++ compiler try to instantiate a copy constructor\n// for objects passed through ellipsis (...), failing for uncopyable\n// objects.  We define this to ensure that only POD is passed through\n// ellipsis on these systems.\n#if defined(__SYMBIAN32__) || defined(__IBMCPP__) || defined(__SUNPRO_CC)\n// We lose support for NULL detection where the compiler doesn't like\n// passing non-POD classes through ellipsis (...).\n# define GTEST_ELLIPSIS_NEEDS_POD_ 1\n#else\n# define GTEST_CAN_COMPARE_NULL 1\n#endif\n\n// The Nokia Symbian and IBM XL C/C++ compilers cannot decide between\n// const T& and const T* in a function template.  These compilers\n// _can_ decide between class template specializations for T and T*,\n// so a tr1::type_traits-like is_pointer works.\n#if defined(__SYMBIAN32__) || defined(__IBMCPP__)\n# define GTEST_NEEDS_IS_POINTER_ 1\n#endif\n\ntemplate <bool bool_value>\nstruct bool_constant {\n  typedef bool_constant<bool_value> type;\n  static const bool value = bool_value;\n};\ntemplate <bool bool_value> const bool bool_constant<bool_value>::value;\n\ntypedef bool_constant<false> false_type;\ntypedef bool_constant<true> true_type;\n\ntemplate <typename T>\nstruct is_pointer : public false_type {};\n\ntemplate <typename T>\nstruct is_pointer<T*> : public true_type {};\n\ntemplate <typename Iterator>\nstruct IteratorTraits {\n  typedef typename Iterator::value_type value_type;\n};\n\ntemplate <typename T>\nstruct IteratorTraits<T*> {\n  typedef T value_type;\n};\n\ntemplate <typename T>\nstruct IteratorTraits<const T*> {\n  typedef T value_type;\n};\n\n#if GTEST_OS_WINDOWS\n# define GTEST_PATH_SEP_ \"\\\\\"\n# define GTEST_HAS_ALT_PATH_SEP_ 1\n// The biggest signed integer type the compiler supports.\ntypedef __int64 BiggestInt;\n#else\n# define GTEST_PATH_SEP_ \"/\"\n# define GTEST_HAS_ALT_PATH_SEP_ 0\ntypedef long long BiggestInt;  // NOLINT\n#endif  // GTEST_OS_WINDOWS\n\n// Utilities for char.\n\n// isspace(int ch) and friends accept an unsigned char or EOF.  char\n// may be signed, depending on the compiler (or compiler flags).\n// Therefore we need to cast a char to unsigned char before calling\n// isspace(), etc.\n\ninline bool IsAlpha(char ch) {\n  return isalpha(static_cast<unsigned char>(ch)) != 0;\n}\ninline bool IsAlNum(char ch) {\n  return isalnum(static_cast<unsigned char>(ch)) != 0;\n}\ninline bool IsDigit(char ch) {\n  return isdigit(static_cast<unsigned char>(ch)) != 0;\n}\ninline bool IsLower(char ch) {\n  return islower(static_cast<unsigned char>(ch)) != 0;\n}\ninline bool IsSpace(char ch) {\n  return isspace(static_cast<unsigned char>(ch)) != 0;\n}\ninline bool IsUpper(char ch) {\n  return isupper(static_cast<unsigned char>(ch)) != 0;\n}\ninline bool IsXDigit(char ch) {\n  return isxdigit(static_cast<unsigned char>(ch)) != 0;\n}\ninline bool IsXDigit(wchar_t ch) {\n  const unsigned char low_byte = static_cast<unsigned char>(ch);\n  return ch == low_byte && isxdigit(low_byte) != 0;\n}\n\ninline char ToLower(char ch) {\n  return static_cast<char>(tolower(static_cast<unsigned char>(ch)));\n}\ninline char ToUpper(char ch) {\n  return static_cast<char>(toupper(static_cast<unsigned char>(ch)));\n}\n\n// The testing::internal::posix namespace holds wrappers for common\n// POSIX functions.  These wrappers hide the differences between\n// Windows/MSVC and POSIX systems.  Since some compilers define these\n// standard functions as macros, the wrapper cannot have the same name\n// as the wrapped function.\n\nnamespace posix {\n\n// Functions with a different name on Windows.\n\n#if GTEST_OS_WINDOWS\n\ntypedef struct _stat StatStruct;\n\n# ifdef __BORLANDC__\ninline int IsATTY(int fd) { return isatty(fd); }\ninline int StrCaseCmp(const char* s1, const char* s2) {\n  return stricmp(s1, s2);\n}\ninline char* StrDup(const char* src) { return strdup(src); }\n# else  // !__BORLANDC__\n#  if GTEST_OS_WINDOWS_MOBILE\ninline int IsATTY(int /* fd */) { return 0; }\n#  else\ninline int IsATTY(int fd) { return _isatty(fd); }\n#  endif  // GTEST_OS_WINDOWS_MOBILE\ninline int StrCaseCmp(const char* s1, const char* s2) {\n  return _stricmp(s1, s2);\n}\ninline char* StrDup(const char* src) { return _strdup(src); }\n# endif  // __BORLANDC__\n\n# if GTEST_OS_WINDOWS_MOBILE\ninline int FileNo(FILE* file) { return reinterpret_cast<int>(_fileno(file)); }\n// Stat(), RmDir(), and IsDir() are not needed on Windows CE at this\n// time and thus not defined there.\n# else\ninline int FileNo(FILE* file) { return _fileno(file); }\ninline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf); }\ninline int RmDir(const char* dir) { return _rmdir(dir); }\ninline bool IsDir(const StatStruct& st) {\n  return (_S_IFDIR & st.st_mode) != 0;\n}\n# endif  // GTEST_OS_WINDOWS_MOBILE\n\n#else\n\ntypedef struct stat StatStruct;\n\ninline int FileNo(FILE* file) { return fileno(file); }\ninline int IsATTY(int fd) { return isatty(fd); }\ninline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); }\ninline int StrCaseCmp(const char* s1, const char* s2) {\n  return strcasecmp(s1, s2);\n}\ninline char* StrDup(const char* src) { return strdup(src); }\ninline int RmDir(const char* dir) { return rmdir(dir); }\ninline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); }\n\n#endif  // GTEST_OS_WINDOWS\n\n// Functions deprecated by MSVC 8.0.\n\n#ifdef _MSC_VER\n// Temporarily disable warning 4996 (deprecated function).\n# pragma warning(push)\n# pragma warning(disable:4996)\n#endif\n\ninline const char* StrNCpy(char* dest, const char* src, size_t n) {\n  return strncpy(dest, src, n);\n}\n\n// ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and\n// StrError() aren't needed on Windows CE at this time and thus not\n// defined there.\n\n#if !GTEST_OS_WINDOWS_MOBILE\ninline int ChDir(const char* dir) { return chdir(dir); }\n#endif\ninline FILE* FOpen(const char* path, const char* mode) {\n  return fopen(path, mode);\n}\n#if !GTEST_OS_WINDOWS_MOBILE\ninline FILE *FReopen(const char* path, const char* mode, FILE* stream) {\n  return freopen(path, mode, stream);\n}\ninline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }\n#endif\ninline int FClose(FILE* fp) { return fclose(fp); }\n#if !GTEST_OS_WINDOWS_MOBILE\ninline int Read(int fd, void* buf, unsigned int count) {\n  return static_cast<int>(read(fd, buf, count));\n}\ninline int Write(int fd, const void* buf, unsigned int count) {\n  return static_cast<int>(write(fd, buf, count));\n}\ninline int Close(int fd) { return close(fd); }\ninline const char* StrError(int errnum) { return strerror(errnum); }\n#endif\ninline const char* GetEnv(const char* name) {\n#if GTEST_OS_WINDOWS_MOBILE\n  // We are on Windows CE, which has no environment variables.\n  return NULL;\n#elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)\n  // Environment variables which we programmatically clear will be set to the\n  // empty string rather than unset (NULL).  Handle that case.\n  const char* const env = getenv(name);\n  return (env != NULL && env[0] != '\\0') ? env : NULL;\n#else\n  return getenv(name);\n#endif\n}\n\n#ifdef _MSC_VER\n# pragma warning(pop)  // Restores the warning state.\n#endif\n\n#if GTEST_OS_WINDOWS_MOBILE\n// Windows CE has no C library. The abort() function is used in\n// several places in Google Test. This implementation provides a reasonable\n// imitation of standard behaviour.\nvoid Abort();\n#else\ninline void Abort() { abort(); }\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\n}  // namespace posix\n\n// MSVC \"deprecates\" snprintf and issues warnings wherever it is used.  In\n// order to avoid these warnings, we need to use _snprintf or _snprintf_s on\n// MSVC-based platforms.  We map the GTEST_SNPRINTF_ macro to the appropriate\n// function in order to achieve that.  We use macro definition here because\n// snprintf is a variadic function.\n#if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE\n// MSVC 2005 and above support variadic macros.\n# define GTEST_SNPRINTF_(buffer, size, format, ...) \\\n     _snprintf_s(buffer, size, size, format, __VA_ARGS__)\n#elif defined(_MSC_VER)\n// Windows CE does not define _snprintf_s and MSVC prior to 2005 doesn't\n// complain about _snprintf.\n# define GTEST_SNPRINTF_ _snprintf\n#else\n# define GTEST_SNPRINTF_ snprintf\n#endif\n\n// The maximum number a BiggestInt can represent.  This definition\n// works no matter BiggestInt is represented in one's complement or\n// two's complement.\n//\n// We cannot rely on numeric_limits in STL, as __int64 and long long\n// are not part of standard C++ and numeric_limits doesn't need to be\n// defined for them.\nconst BiggestInt kMaxBiggestInt =\n    ~(static_cast<BiggestInt>(1) << (8*sizeof(BiggestInt) - 1));\n\n// This template class serves as a compile-time function from size to\n// type.  It maps a size in bytes to a primitive type with that\n// size. e.g.\n//\n//   TypeWithSize<4>::UInt\n//\n// is typedef-ed to be unsigned int (unsigned integer made up of 4\n// bytes).\n//\n// Such functionality should belong to STL, but I cannot find it\n// there.\n//\n// Google Test uses this class in the implementation of floating-point\n// comparison.\n//\n// For now it only handles UInt (unsigned int) as that's all Google Test\n// needs.  Other types can be easily added in the future if need\n// arises.\ntemplate <size_t size>\nclass TypeWithSize {\n public:\n  // This prevents the user from using TypeWithSize<N> with incorrect\n  // values of N.\n  typedef void UInt;\n};\n\n// The specialization for size 4.\ntemplate <>\nclass TypeWithSize<4> {\n public:\n  // unsigned int has size 4 in both gcc and MSVC.\n  //\n  // As base/basictypes.h doesn't compile on Windows, we cannot use\n  // uint32, uint64, and etc here.\n  typedef int Int;\n  typedef unsigned int UInt;\n};\n\n// The specialization for size 8.\ntemplate <>\nclass TypeWithSize<8> {\n public:\n#if GTEST_OS_WINDOWS\n  typedef __int64 Int;\n  typedef unsigned __int64 UInt;\n#else\n  typedef long long Int;  // NOLINT\n  typedef unsigned long long UInt;  // NOLINT\n#endif  // GTEST_OS_WINDOWS\n};\n\n// Integer types of known sizes.\ntypedef TypeWithSize<4>::Int Int32;\ntypedef TypeWithSize<4>::UInt UInt32;\ntypedef TypeWithSize<8>::Int Int64;\ntypedef TypeWithSize<8>::UInt UInt64;\ntypedef TypeWithSize<8>::Int TimeInMillis;  // Represents time in milliseconds.\n\n// Utilities for command line flags and environment variables.\n\n// Macro for referencing flags.\n#define GTEST_FLAG(name) FLAGS_gtest_##name\n\n// Macros for declaring flags.\n#define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name)\n#define GTEST_DECLARE_int32_(name) \\\n    GTEST_API_ extern ::testing::internal::Int32 GTEST_FLAG(name)\n#define GTEST_DECLARE_string_(name) \\\n    GTEST_API_ extern ::std::string GTEST_FLAG(name)\n\n// Macros for defining flags.\n#define GTEST_DEFINE_bool_(name, default_val, doc) \\\n    GTEST_API_ bool GTEST_FLAG(name) = (default_val)\n#define GTEST_DEFINE_int32_(name, default_val, doc) \\\n    GTEST_API_ ::testing::internal::Int32 GTEST_FLAG(name) = (default_val)\n#define GTEST_DEFINE_string_(name, default_val, doc) \\\n    GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val)\n\n// Thread annotations\n#define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks)\n#define GTEST_LOCK_EXCLUDED_(locks)\n\n// Parses 'str' for a 32-bit signed integer.  If successful, writes the result\n// to *value and returns true; otherwise leaves *value unchanged and returns\n// false.\n// TODO(chandlerc): Find a better way to refactor flag and environment parsing\n// out of both gtest-port.cc and gtest.cc to avoid exporting this utility\n// function.\nbool ParseInt32(const Message& src_text, const char* str, Int32* value);\n\n// Parses a bool/Int32/string from the environment variable\n// corresponding to the given Google Test flag.\nbool BoolFromGTestEnv(const char* flag, bool default_val);\nGTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val);\nconst char* StringFromGTestEnv(const char* flag, const char* default_val);\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/internal/gtest-string.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee)\n//\n// The Google C++ Testing Framework (Google Test)\n//\n// This header file declares the String class and functions used internally by\n// Google Test.  They are subject to change without notice. They should not used\n// by code external to Google Test.\n//\n// This header file is #included by <gtest/internal/gtest-internal.h>.\n// It should not be #included by other files.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_\n\n#ifdef __BORLANDC__\n// string.h is not guaranteed to provide strcpy on C++ Builder.\n# include <mem.h>\n#endif\n\n#include <string.h>\n#include <string>\n\n#include \"gtest/internal/gtest-port.h\"\n\nnamespace testing {\nnamespace internal {\n\n// String - an abstract class holding static string utilities.\nclass GTEST_API_ String {\n public:\n  // Static utility methods\n\n  // Clones a 0-terminated C string, allocating memory using new.  The\n  // caller is responsible for deleting the return value using\n  // delete[].  Returns the cloned string, or NULL if the input is\n  // NULL.\n  //\n  // This is different from strdup() in string.h, which allocates\n  // memory using malloc().\n  static const char* CloneCString(const char* c_str);\n\n#if GTEST_OS_WINDOWS_MOBILE\n  // Windows CE does not have the 'ANSI' versions of Win32 APIs. To be\n  // able to pass strings to Win32 APIs on CE we need to convert them\n  // to 'Unicode', UTF-16.\n\n  // Creates a UTF-16 wide string from the given ANSI string, allocating\n  // memory using new. The caller is responsible for deleting the return\n  // value using delete[]. Returns the wide string, or NULL if the\n  // input is NULL.\n  //\n  // The wide string is created using the ANSI codepage (CP_ACP) to\n  // match the behaviour of the ANSI versions of Win32 calls and the\n  // C runtime.\n  static LPCWSTR AnsiToUtf16(const char* c_str);\n\n  // Creates an ANSI string from the given wide string, allocating\n  // memory using new. The caller is responsible for deleting the return\n  // value using delete[]. Returns the ANSI string, or NULL if the\n  // input is NULL.\n  //\n  // The returned string is created using the ANSI codepage (CP_ACP) to\n  // match the behaviour of the ANSI versions of Win32 calls and the\n  // C runtime.\n  static const char* Utf16ToAnsi(LPCWSTR utf16_str);\n#endif\n\n  // Compares two C strings.  Returns true iff they have the same content.\n  //\n  // Unlike strcmp(), this function can handle NULL argument(s).  A\n  // NULL C string is considered different to any non-NULL C string,\n  // including the empty string.\n  static bool CStringEquals(const char* lhs, const char* rhs);\n\n  // Converts a wide C string to a String using the UTF-8 encoding.\n  // NULL will be converted to \"(null)\".  If an error occurred during\n  // the conversion, \"(failed to convert from wide string)\" is\n  // returned.\n  static std::string ShowWideCString(const wchar_t* wide_c_str);\n\n  // Compares two wide C strings.  Returns true iff they have the same\n  // content.\n  //\n  // Unlike wcscmp(), this function can handle NULL argument(s).  A\n  // NULL C string is considered different to any non-NULL C string,\n  // including the empty string.\n  static bool WideCStringEquals(const wchar_t* lhs, const wchar_t* rhs);\n\n  // Compares two C strings, ignoring case.  Returns true iff they\n  // have the same content.\n  //\n  // Unlike strcasecmp(), this function can handle NULL argument(s).\n  // A NULL C string is considered different to any non-NULL C string,\n  // including the empty string.\n  static bool CaseInsensitiveCStringEquals(const char* lhs,\n                                           const char* rhs);\n\n  // Compares two wide C strings, ignoring case.  Returns true iff they\n  // have the same content.\n  //\n  // Unlike wcscasecmp(), this function can handle NULL argument(s).\n  // A NULL C string is considered different to any non-NULL wide C string,\n  // including the empty string.\n  // NB: The implementations on different platforms slightly differ.\n  // On windows, this method uses _wcsicmp which compares according to LC_CTYPE\n  // environment variable. On GNU platform this method uses wcscasecmp\n  // which compares according to LC_CTYPE category of the current locale.\n  // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the\n  // current locale.\n  static bool CaseInsensitiveWideCStringEquals(const wchar_t* lhs,\n                                               const wchar_t* rhs);\n\n  // Returns true iff the given string ends with the given suffix, ignoring\n  // case. Any string is considered to end with an empty suffix.\n  static bool EndsWithCaseInsensitive(\n      const std::string& str, const std::string& suffix);\n\n  // Formats an int value as \"%02d\".\n  static std::string FormatIntWidth2(int value);  // \"%02d\" for width == 2\n\n  // Formats an int value as \"%X\".\n  static std::string FormatHexInt(int value);\n\n  // Formats a byte as \"%02X\".\n  static std::string FormatByte(unsigned char value);\n\n private:\n  String();  // Not meant to be instantiated.\n};  // class String\n\n// Gets the content of the stringstream's buffer as an std::string.  Each '\\0'\n// character in the buffer is replaced with \"\\\\0\".\nGTEST_API_ std::string StringStreamToString(::std::stringstream* stream);\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/internal/gtest-tuple.h",
    "content": "// This file was GENERATED by command:\n//     pump.py gtest-tuple.h.pump\n// DO NOT EDIT BY HAND!!!\n\n// Copyright 2009 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Implements a subset of TR1 tuple needed by Google Test and Google Mock.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_\n\n#include <utility>  // For ::std::pair.\n\n// The compiler used in Symbian has a bug that prevents us from declaring the\n// tuple template as a friend (it complains that tuple is redefined).  This\n// hack bypasses the bug by declaring the members that should otherwise be\n// private as public.\n// Sun Studio versions < 12 also have the above bug.\n#if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)\n# define GTEST_DECLARE_TUPLE_AS_FRIEND_ public:\n#else\n# define GTEST_DECLARE_TUPLE_AS_FRIEND_ \\\n    template <GTEST_10_TYPENAMES_(U)> friend class tuple; \\\n   private:\n#endif\n\n// GTEST_n_TUPLE_(T) is the type of an n-tuple.\n#define GTEST_0_TUPLE_(T) tuple<>\n#define GTEST_1_TUPLE_(T) tuple<T##0, void, void, void, void, void, void, \\\n    void, void, void>\n#define GTEST_2_TUPLE_(T) tuple<T##0, T##1, void, void, void, void, void, \\\n    void, void, void>\n#define GTEST_3_TUPLE_(T) tuple<T##0, T##1, T##2, void, void, void, void, \\\n    void, void, void>\n#define GTEST_4_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, void, void, void, \\\n    void, void, void>\n#define GTEST_5_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, void, void, \\\n    void, void, void>\n#define GTEST_6_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, void, \\\n    void, void, void>\n#define GTEST_7_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \\\n    void, void, void>\n#define GTEST_8_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \\\n    T##7, void, void>\n#define GTEST_9_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \\\n    T##7, T##8, void>\n#define GTEST_10_TUPLE_(T) tuple<T##0, T##1, T##2, T##3, T##4, T##5, T##6, \\\n    T##7, T##8, T##9>\n\n// GTEST_n_TYPENAMES_(T) declares a list of n typenames.\n#define GTEST_0_TYPENAMES_(T)\n#define GTEST_1_TYPENAMES_(T) typename T##0\n#define GTEST_2_TYPENAMES_(T) typename T##0, typename T##1\n#define GTEST_3_TYPENAMES_(T) typename T##0, typename T##1, typename T##2\n#define GTEST_4_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \\\n    typename T##3\n#define GTEST_5_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \\\n    typename T##3, typename T##4\n#define GTEST_6_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \\\n    typename T##3, typename T##4, typename T##5\n#define GTEST_7_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \\\n    typename T##3, typename T##4, typename T##5, typename T##6\n#define GTEST_8_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \\\n    typename T##3, typename T##4, typename T##5, typename T##6, typename T##7\n#define GTEST_9_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \\\n    typename T##3, typename T##4, typename T##5, typename T##6, \\\n    typename T##7, typename T##8\n#define GTEST_10_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \\\n    typename T##3, typename T##4, typename T##5, typename T##6, \\\n    typename T##7, typename T##8, typename T##9\n\n// In theory, defining stuff in the ::std namespace is undefined\n// behavior.  We can do this as we are playing the role of a standard\n// library vendor.\nnamespace std {\nnamespace tr1 {\n\ntemplate <typename T0 = void, typename T1 = void, typename T2 = void,\n    typename T3 = void, typename T4 = void, typename T5 = void,\n    typename T6 = void, typename T7 = void, typename T8 = void,\n    typename T9 = void>\nclass tuple;\n\n// Anything in namespace gtest_internal is Google Test's INTERNAL\n// IMPLEMENTATION DETAIL and MUST NOT BE USED DIRECTLY in user code.\nnamespace gtest_internal {\n\n// ByRef<T>::type is T if T is a reference; otherwise it's const T&.\ntemplate <typename T>\nstruct ByRef { typedef const T& type; };  // NOLINT\ntemplate <typename T>\nstruct ByRef<T&> { typedef T& type; };  // NOLINT\n\n// A handy wrapper for ByRef.\n#define GTEST_BY_REF_(T) typename ::std::tr1::gtest_internal::ByRef<T>::type\n\n// AddRef<T>::type is T if T is a reference; otherwise it's T&.  This\n// is the same as tr1::add_reference<T>::type.\ntemplate <typename T>\nstruct AddRef { typedef T& type; };  // NOLINT\ntemplate <typename T>\nstruct AddRef<T&> { typedef T& type; };  // NOLINT\n\n// A handy wrapper for AddRef.\n#define GTEST_ADD_REF_(T) typename ::std::tr1::gtest_internal::AddRef<T>::type\n\n// A helper for implementing get<k>().\ntemplate <int k> class Get;\n\n// A helper for implementing tuple_element<k, T>.  kIndexValid is true\n// iff k < the number of fields in tuple type T.\ntemplate <bool kIndexValid, int kIndex, class Tuple>\nstruct TupleElement;\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nstruct TupleElement<true, 0, GTEST_10_TUPLE_(T) > {\n  typedef T0 type;\n};\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nstruct TupleElement<true, 1, GTEST_10_TUPLE_(T) > {\n  typedef T1 type;\n};\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nstruct TupleElement<true, 2, GTEST_10_TUPLE_(T) > {\n  typedef T2 type;\n};\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nstruct TupleElement<true, 3, GTEST_10_TUPLE_(T) > {\n  typedef T3 type;\n};\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nstruct TupleElement<true, 4, GTEST_10_TUPLE_(T) > {\n  typedef T4 type;\n};\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nstruct TupleElement<true, 5, GTEST_10_TUPLE_(T) > {\n  typedef T5 type;\n};\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nstruct TupleElement<true, 6, GTEST_10_TUPLE_(T) > {\n  typedef T6 type;\n};\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nstruct TupleElement<true, 7, GTEST_10_TUPLE_(T) > {\n  typedef T7 type;\n};\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nstruct TupleElement<true, 8, GTEST_10_TUPLE_(T) > {\n  typedef T8 type;\n};\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nstruct TupleElement<true, 9, GTEST_10_TUPLE_(T) > {\n  typedef T9 type;\n};\n\n}  // namespace gtest_internal\n\ntemplate <>\nclass tuple<> {\n public:\n  tuple() {}\n  tuple(const tuple& /* t */)  {}\n  tuple& operator=(const tuple& /* t */) { return *this; }\n};\n\ntemplate <GTEST_1_TYPENAMES_(T)>\nclass GTEST_1_TUPLE_(T) {\n public:\n  template <int k> friend class gtest_internal::Get;\n\n  tuple() : f0_() {}\n\n  explicit tuple(GTEST_BY_REF_(T0) f0) : f0_(f0) {}\n\n  tuple(const tuple& t) : f0_(t.f0_) {}\n\n  template <GTEST_1_TYPENAMES_(U)>\n  tuple(const GTEST_1_TUPLE_(U)& t) : f0_(t.f0_) {}\n\n  tuple& operator=(const tuple& t) { return CopyFrom(t); }\n\n  template <GTEST_1_TYPENAMES_(U)>\n  tuple& operator=(const GTEST_1_TUPLE_(U)& t) {\n    return CopyFrom(t);\n  }\n\n  GTEST_DECLARE_TUPLE_AS_FRIEND_\n\n  template <GTEST_1_TYPENAMES_(U)>\n  tuple& CopyFrom(const GTEST_1_TUPLE_(U)& t) {\n    f0_ = t.f0_;\n    return *this;\n  }\n\n  T0 f0_;\n};\n\ntemplate <GTEST_2_TYPENAMES_(T)>\nclass GTEST_2_TUPLE_(T) {\n public:\n  template <int k> friend class gtest_internal::Get;\n\n  tuple() : f0_(), f1_() {}\n\n  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1) : f0_(f0),\n      f1_(f1) {}\n\n  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_) {}\n\n  template <GTEST_2_TYPENAMES_(U)>\n  tuple(const GTEST_2_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_) {}\n  template <typename U0, typename U1>\n  tuple(const ::std::pair<U0, U1>& p) : f0_(p.first), f1_(p.second) {}\n\n  tuple& operator=(const tuple& t) { return CopyFrom(t); }\n\n  template <GTEST_2_TYPENAMES_(U)>\n  tuple& operator=(const GTEST_2_TUPLE_(U)& t) {\n    return CopyFrom(t);\n  }\n  template <typename U0, typename U1>\n  tuple& operator=(const ::std::pair<U0, U1>& p) {\n    f0_ = p.first;\n    f1_ = p.second;\n    return *this;\n  }\n\n  GTEST_DECLARE_TUPLE_AS_FRIEND_\n\n  template <GTEST_2_TYPENAMES_(U)>\n  tuple& CopyFrom(const GTEST_2_TUPLE_(U)& t) {\n    f0_ = t.f0_;\n    f1_ = t.f1_;\n    return *this;\n  }\n\n  T0 f0_;\n  T1 f1_;\n};\n\ntemplate <GTEST_3_TYPENAMES_(T)>\nclass GTEST_3_TUPLE_(T) {\n public:\n  template <int k> friend class gtest_internal::Get;\n\n  tuple() : f0_(), f1_(), f2_() {}\n\n  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,\n      GTEST_BY_REF_(T2) f2) : f0_(f0), f1_(f1), f2_(f2) {}\n\n  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_) {}\n\n  template <GTEST_3_TYPENAMES_(U)>\n  tuple(const GTEST_3_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_) {}\n\n  tuple& operator=(const tuple& t) { return CopyFrom(t); }\n\n  template <GTEST_3_TYPENAMES_(U)>\n  tuple& operator=(const GTEST_3_TUPLE_(U)& t) {\n    return CopyFrom(t);\n  }\n\n  GTEST_DECLARE_TUPLE_AS_FRIEND_\n\n  template <GTEST_3_TYPENAMES_(U)>\n  tuple& CopyFrom(const GTEST_3_TUPLE_(U)& t) {\n    f0_ = t.f0_;\n    f1_ = t.f1_;\n    f2_ = t.f2_;\n    return *this;\n  }\n\n  T0 f0_;\n  T1 f1_;\n  T2 f2_;\n};\n\ntemplate <GTEST_4_TYPENAMES_(T)>\nclass GTEST_4_TUPLE_(T) {\n public:\n  template <int k> friend class gtest_internal::Get;\n\n  tuple() : f0_(), f1_(), f2_(), f3_() {}\n\n  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,\n      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3) : f0_(f0), f1_(f1), f2_(f2),\n      f3_(f3) {}\n\n  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_) {}\n\n  template <GTEST_4_TYPENAMES_(U)>\n  tuple(const GTEST_4_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),\n      f3_(t.f3_) {}\n\n  tuple& operator=(const tuple& t) { return CopyFrom(t); }\n\n  template <GTEST_4_TYPENAMES_(U)>\n  tuple& operator=(const GTEST_4_TUPLE_(U)& t) {\n    return CopyFrom(t);\n  }\n\n  GTEST_DECLARE_TUPLE_AS_FRIEND_\n\n  template <GTEST_4_TYPENAMES_(U)>\n  tuple& CopyFrom(const GTEST_4_TUPLE_(U)& t) {\n    f0_ = t.f0_;\n    f1_ = t.f1_;\n    f2_ = t.f2_;\n    f3_ = t.f3_;\n    return *this;\n  }\n\n  T0 f0_;\n  T1 f1_;\n  T2 f2_;\n  T3 f3_;\n};\n\ntemplate <GTEST_5_TYPENAMES_(T)>\nclass GTEST_5_TUPLE_(T) {\n public:\n  template <int k> friend class gtest_internal::Get;\n\n  tuple() : f0_(), f1_(), f2_(), f3_(), f4_() {}\n\n  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,\n      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3,\n      GTEST_BY_REF_(T4) f4) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4) {}\n\n  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),\n      f4_(t.f4_) {}\n\n  template <GTEST_5_TYPENAMES_(U)>\n  tuple(const GTEST_5_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),\n      f3_(t.f3_), f4_(t.f4_) {}\n\n  tuple& operator=(const tuple& t) { return CopyFrom(t); }\n\n  template <GTEST_5_TYPENAMES_(U)>\n  tuple& operator=(const GTEST_5_TUPLE_(U)& t) {\n    return CopyFrom(t);\n  }\n\n  GTEST_DECLARE_TUPLE_AS_FRIEND_\n\n  template <GTEST_5_TYPENAMES_(U)>\n  tuple& CopyFrom(const GTEST_5_TUPLE_(U)& t) {\n    f0_ = t.f0_;\n    f1_ = t.f1_;\n    f2_ = t.f2_;\n    f3_ = t.f3_;\n    f4_ = t.f4_;\n    return *this;\n  }\n\n  T0 f0_;\n  T1 f1_;\n  T2 f2_;\n  T3 f3_;\n  T4 f4_;\n};\n\ntemplate <GTEST_6_TYPENAMES_(T)>\nclass GTEST_6_TUPLE_(T) {\n public:\n  template <int k> friend class gtest_internal::Get;\n\n  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_() {}\n\n  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,\n      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,\n      GTEST_BY_REF_(T5) f5) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),\n      f5_(f5) {}\n\n  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),\n      f4_(t.f4_), f5_(t.f5_) {}\n\n  template <GTEST_6_TYPENAMES_(U)>\n  tuple(const GTEST_6_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),\n      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_) {}\n\n  tuple& operator=(const tuple& t) { return CopyFrom(t); }\n\n  template <GTEST_6_TYPENAMES_(U)>\n  tuple& operator=(const GTEST_6_TUPLE_(U)& t) {\n    return CopyFrom(t);\n  }\n\n  GTEST_DECLARE_TUPLE_AS_FRIEND_\n\n  template <GTEST_6_TYPENAMES_(U)>\n  tuple& CopyFrom(const GTEST_6_TUPLE_(U)& t) {\n    f0_ = t.f0_;\n    f1_ = t.f1_;\n    f2_ = t.f2_;\n    f3_ = t.f3_;\n    f4_ = t.f4_;\n    f5_ = t.f5_;\n    return *this;\n  }\n\n  T0 f0_;\n  T1 f1_;\n  T2 f2_;\n  T3 f3_;\n  T4 f4_;\n  T5 f5_;\n};\n\ntemplate <GTEST_7_TYPENAMES_(T)>\nclass GTEST_7_TUPLE_(T) {\n public:\n  template <int k> friend class gtest_internal::Get;\n\n  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_() {}\n\n  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,\n      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,\n      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6) : f0_(f0), f1_(f1), f2_(f2),\n      f3_(f3), f4_(f4), f5_(f5), f6_(f6) {}\n\n  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),\n      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_) {}\n\n  template <GTEST_7_TYPENAMES_(U)>\n  tuple(const GTEST_7_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),\n      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_) {}\n\n  tuple& operator=(const tuple& t) { return CopyFrom(t); }\n\n  template <GTEST_7_TYPENAMES_(U)>\n  tuple& operator=(const GTEST_7_TUPLE_(U)& t) {\n    return CopyFrom(t);\n  }\n\n  GTEST_DECLARE_TUPLE_AS_FRIEND_\n\n  template <GTEST_7_TYPENAMES_(U)>\n  tuple& CopyFrom(const GTEST_7_TUPLE_(U)& t) {\n    f0_ = t.f0_;\n    f1_ = t.f1_;\n    f2_ = t.f2_;\n    f3_ = t.f3_;\n    f4_ = t.f4_;\n    f5_ = t.f5_;\n    f6_ = t.f6_;\n    return *this;\n  }\n\n  T0 f0_;\n  T1 f1_;\n  T2 f2_;\n  T3 f3_;\n  T4 f4_;\n  T5 f5_;\n  T6 f6_;\n};\n\ntemplate <GTEST_8_TYPENAMES_(T)>\nclass GTEST_8_TUPLE_(T) {\n public:\n  template <int k> friend class gtest_internal::Get;\n\n  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_() {}\n\n  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,\n      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,\n      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6,\n      GTEST_BY_REF_(T7) f7) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),\n      f5_(f5), f6_(f6), f7_(f7) {}\n\n  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),\n      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_) {}\n\n  template <GTEST_8_TYPENAMES_(U)>\n  tuple(const GTEST_8_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),\n      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_) {}\n\n  tuple& operator=(const tuple& t) { return CopyFrom(t); }\n\n  template <GTEST_8_TYPENAMES_(U)>\n  tuple& operator=(const GTEST_8_TUPLE_(U)& t) {\n    return CopyFrom(t);\n  }\n\n  GTEST_DECLARE_TUPLE_AS_FRIEND_\n\n  template <GTEST_8_TYPENAMES_(U)>\n  tuple& CopyFrom(const GTEST_8_TUPLE_(U)& t) {\n    f0_ = t.f0_;\n    f1_ = t.f1_;\n    f2_ = t.f2_;\n    f3_ = t.f3_;\n    f4_ = t.f4_;\n    f5_ = t.f5_;\n    f6_ = t.f6_;\n    f7_ = t.f7_;\n    return *this;\n  }\n\n  T0 f0_;\n  T1 f1_;\n  T2 f2_;\n  T3 f3_;\n  T4 f4_;\n  T5 f5_;\n  T6 f6_;\n  T7 f7_;\n};\n\ntemplate <GTEST_9_TYPENAMES_(T)>\nclass GTEST_9_TUPLE_(T) {\n public:\n  template <int k> friend class gtest_internal::Get;\n\n  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_(), f8_() {}\n\n  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,\n      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,\n      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6, GTEST_BY_REF_(T7) f7,\n      GTEST_BY_REF_(T8) f8) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4),\n      f5_(f5), f6_(f6), f7_(f7), f8_(f8) {}\n\n  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),\n      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_) {}\n\n  template <GTEST_9_TYPENAMES_(U)>\n  tuple(const GTEST_9_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),\n      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_) {}\n\n  tuple& operator=(const tuple& t) { return CopyFrom(t); }\n\n  template <GTEST_9_TYPENAMES_(U)>\n  tuple& operator=(const GTEST_9_TUPLE_(U)& t) {\n    return CopyFrom(t);\n  }\n\n  GTEST_DECLARE_TUPLE_AS_FRIEND_\n\n  template <GTEST_9_TYPENAMES_(U)>\n  tuple& CopyFrom(const GTEST_9_TUPLE_(U)& t) {\n    f0_ = t.f0_;\n    f1_ = t.f1_;\n    f2_ = t.f2_;\n    f3_ = t.f3_;\n    f4_ = t.f4_;\n    f5_ = t.f5_;\n    f6_ = t.f6_;\n    f7_ = t.f7_;\n    f8_ = t.f8_;\n    return *this;\n  }\n\n  T0 f0_;\n  T1 f1_;\n  T2 f2_;\n  T3 f3_;\n  T4 f4_;\n  T5 f5_;\n  T6 f6_;\n  T7 f7_;\n  T8 f8_;\n};\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nclass tuple {\n public:\n  template <int k> friend class gtest_internal::Get;\n\n  tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_(), f8_(),\n      f9_() {}\n\n  explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1,\n      GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4,\n      GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6, GTEST_BY_REF_(T7) f7,\n      GTEST_BY_REF_(T8) f8, GTEST_BY_REF_(T9) f9) : f0_(f0), f1_(f1), f2_(f2),\n      f3_(f3), f4_(f4), f5_(f5), f6_(f6), f7_(f7), f8_(f8), f9_(f9) {}\n\n  tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_),\n      f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_), f9_(t.f9_) {}\n\n  template <GTEST_10_TYPENAMES_(U)>\n  tuple(const GTEST_10_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_),\n      f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_),\n      f9_(t.f9_) {}\n\n  tuple& operator=(const tuple& t) { return CopyFrom(t); }\n\n  template <GTEST_10_TYPENAMES_(U)>\n  tuple& operator=(const GTEST_10_TUPLE_(U)& t) {\n    return CopyFrom(t);\n  }\n\n  GTEST_DECLARE_TUPLE_AS_FRIEND_\n\n  template <GTEST_10_TYPENAMES_(U)>\n  tuple& CopyFrom(const GTEST_10_TUPLE_(U)& t) {\n    f0_ = t.f0_;\n    f1_ = t.f1_;\n    f2_ = t.f2_;\n    f3_ = t.f3_;\n    f4_ = t.f4_;\n    f5_ = t.f5_;\n    f6_ = t.f6_;\n    f7_ = t.f7_;\n    f8_ = t.f8_;\n    f9_ = t.f9_;\n    return *this;\n  }\n\n  T0 f0_;\n  T1 f1_;\n  T2 f2_;\n  T3 f3_;\n  T4 f4_;\n  T5 f5_;\n  T6 f6_;\n  T7 f7_;\n  T8 f8_;\n  T9 f9_;\n};\n\n// 6.1.3.2 Tuple creation functions.\n\n// Known limitations: we don't support passing an\n// std::tr1::reference_wrapper<T> to make_tuple().  And we don't\n// implement tie().\n\ninline tuple<> make_tuple() { return tuple<>(); }\n\ntemplate <GTEST_1_TYPENAMES_(T)>\ninline GTEST_1_TUPLE_(T) make_tuple(const T0& f0) {\n  return GTEST_1_TUPLE_(T)(f0);\n}\n\ntemplate <GTEST_2_TYPENAMES_(T)>\ninline GTEST_2_TUPLE_(T) make_tuple(const T0& f0, const T1& f1) {\n  return GTEST_2_TUPLE_(T)(f0, f1);\n}\n\ntemplate <GTEST_3_TYPENAMES_(T)>\ninline GTEST_3_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2) {\n  return GTEST_3_TUPLE_(T)(f0, f1, f2);\n}\n\ntemplate <GTEST_4_TYPENAMES_(T)>\ninline GTEST_4_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,\n    const T3& f3) {\n  return GTEST_4_TUPLE_(T)(f0, f1, f2, f3);\n}\n\ntemplate <GTEST_5_TYPENAMES_(T)>\ninline GTEST_5_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,\n    const T3& f3, const T4& f4) {\n  return GTEST_5_TUPLE_(T)(f0, f1, f2, f3, f4);\n}\n\ntemplate <GTEST_6_TYPENAMES_(T)>\ninline GTEST_6_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,\n    const T3& f3, const T4& f4, const T5& f5) {\n  return GTEST_6_TUPLE_(T)(f0, f1, f2, f3, f4, f5);\n}\n\ntemplate <GTEST_7_TYPENAMES_(T)>\ninline GTEST_7_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,\n    const T3& f3, const T4& f4, const T5& f5, const T6& f6) {\n  return GTEST_7_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6);\n}\n\ntemplate <GTEST_8_TYPENAMES_(T)>\ninline GTEST_8_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,\n    const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7) {\n  return GTEST_8_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7);\n}\n\ntemplate <GTEST_9_TYPENAMES_(T)>\ninline GTEST_9_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,\n    const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7,\n    const T8& f8) {\n  return GTEST_9_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7, f8);\n}\n\ntemplate <GTEST_10_TYPENAMES_(T)>\ninline GTEST_10_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2,\n    const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7,\n    const T8& f8, const T9& f9) {\n  return GTEST_10_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7, f8, f9);\n}\n\n// 6.1.3.3 Tuple helper classes.\n\ntemplate <typename Tuple> struct tuple_size;\n\ntemplate <GTEST_0_TYPENAMES_(T)>\nstruct tuple_size<GTEST_0_TUPLE_(T) > {\n  static const int value = 0;\n};\n\ntemplate <GTEST_1_TYPENAMES_(T)>\nstruct tuple_size<GTEST_1_TUPLE_(T) > {\n  static const int value = 1;\n};\n\ntemplate <GTEST_2_TYPENAMES_(T)>\nstruct tuple_size<GTEST_2_TUPLE_(T) > {\n  static const int value = 2;\n};\n\ntemplate <GTEST_3_TYPENAMES_(T)>\nstruct tuple_size<GTEST_3_TUPLE_(T) > {\n  static const int value = 3;\n};\n\ntemplate <GTEST_4_TYPENAMES_(T)>\nstruct tuple_size<GTEST_4_TUPLE_(T) > {\n  static const int value = 4;\n};\n\ntemplate <GTEST_5_TYPENAMES_(T)>\nstruct tuple_size<GTEST_5_TUPLE_(T) > {\n  static const int value = 5;\n};\n\ntemplate <GTEST_6_TYPENAMES_(T)>\nstruct tuple_size<GTEST_6_TUPLE_(T) > {\n  static const int value = 6;\n};\n\ntemplate <GTEST_7_TYPENAMES_(T)>\nstruct tuple_size<GTEST_7_TUPLE_(T) > {\n  static const int value = 7;\n};\n\ntemplate <GTEST_8_TYPENAMES_(T)>\nstruct tuple_size<GTEST_8_TUPLE_(T) > {\n  static const int value = 8;\n};\n\ntemplate <GTEST_9_TYPENAMES_(T)>\nstruct tuple_size<GTEST_9_TUPLE_(T) > {\n  static const int value = 9;\n};\n\ntemplate <GTEST_10_TYPENAMES_(T)>\nstruct tuple_size<GTEST_10_TUPLE_(T) > {\n  static const int value = 10;\n};\n\ntemplate <int k, class Tuple>\nstruct tuple_element {\n  typedef typename gtest_internal::TupleElement<\n      k < (tuple_size<Tuple>::value), k, Tuple>::type type;\n};\n\n#define GTEST_TUPLE_ELEMENT_(k, Tuple) typename tuple_element<k, Tuple >::type\n\n// 6.1.3.4 Element access.\n\nnamespace gtest_internal {\n\ntemplate <>\nclass Get<0> {\n public:\n  template <class Tuple>\n  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(0, Tuple))\n  Field(Tuple& t) { return t.f0_; }  // NOLINT\n\n  template <class Tuple>\n  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(0, Tuple))\n  ConstField(const Tuple& t) { return t.f0_; }\n};\n\ntemplate <>\nclass Get<1> {\n public:\n  template <class Tuple>\n  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(1, Tuple))\n  Field(Tuple& t) { return t.f1_; }  // NOLINT\n\n  template <class Tuple>\n  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(1, Tuple))\n  ConstField(const Tuple& t) { return t.f1_; }\n};\n\ntemplate <>\nclass Get<2> {\n public:\n  template <class Tuple>\n  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(2, Tuple))\n  Field(Tuple& t) { return t.f2_; }  // NOLINT\n\n  template <class Tuple>\n  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(2, Tuple))\n  ConstField(const Tuple& t) { return t.f2_; }\n};\n\ntemplate <>\nclass Get<3> {\n public:\n  template <class Tuple>\n  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(3, Tuple))\n  Field(Tuple& t) { return t.f3_; }  // NOLINT\n\n  template <class Tuple>\n  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(3, Tuple))\n  ConstField(const Tuple& t) { return t.f3_; }\n};\n\ntemplate <>\nclass Get<4> {\n public:\n  template <class Tuple>\n  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(4, Tuple))\n  Field(Tuple& t) { return t.f4_; }  // NOLINT\n\n  template <class Tuple>\n  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(4, Tuple))\n  ConstField(const Tuple& t) { return t.f4_; }\n};\n\ntemplate <>\nclass Get<5> {\n public:\n  template <class Tuple>\n  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(5, Tuple))\n  Field(Tuple& t) { return t.f5_; }  // NOLINT\n\n  template <class Tuple>\n  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(5, Tuple))\n  ConstField(const Tuple& t) { return t.f5_; }\n};\n\ntemplate <>\nclass Get<6> {\n public:\n  template <class Tuple>\n  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(6, Tuple))\n  Field(Tuple& t) { return t.f6_; }  // NOLINT\n\n  template <class Tuple>\n  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(6, Tuple))\n  ConstField(const Tuple& t) { return t.f6_; }\n};\n\ntemplate <>\nclass Get<7> {\n public:\n  template <class Tuple>\n  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(7, Tuple))\n  Field(Tuple& t) { return t.f7_; }  // NOLINT\n\n  template <class Tuple>\n  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(7, Tuple))\n  ConstField(const Tuple& t) { return t.f7_; }\n};\n\ntemplate <>\nclass Get<8> {\n public:\n  template <class Tuple>\n  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(8, Tuple))\n  Field(Tuple& t) { return t.f8_; }  // NOLINT\n\n  template <class Tuple>\n  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(8, Tuple))\n  ConstField(const Tuple& t) { return t.f8_; }\n};\n\ntemplate <>\nclass Get<9> {\n public:\n  template <class Tuple>\n  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(9, Tuple))\n  Field(Tuple& t) { return t.f9_; }  // NOLINT\n\n  template <class Tuple>\n  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(9, Tuple))\n  ConstField(const Tuple& t) { return t.f9_; }\n};\n\n}  // namespace gtest_internal\n\ntemplate <int k, GTEST_10_TYPENAMES_(T)>\nGTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_10_TUPLE_(T)))\nget(GTEST_10_TUPLE_(T)& t) {\n  return gtest_internal::Get<k>::Field(t);\n}\n\ntemplate <int k, GTEST_10_TYPENAMES_(T)>\nGTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(k,  GTEST_10_TUPLE_(T)))\nget(const GTEST_10_TUPLE_(T)& t) {\n  return gtest_internal::Get<k>::ConstField(t);\n}\n\n// 6.1.3.5 Relational operators\n\n// We only implement == and !=, as we don't have a need for the rest yet.\n\nnamespace gtest_internal {\n\n// SameSizeTuplePrefixComparator<k, k>::Eq(t1, t2) returns true if the\n// first k fields of t1 equals the first k fields of t2.\n// SameSizeTuplePrefixComparator(k1, k2) would be a compiler error if\n// k1 != k2.\ntemplate <int kSize1, int kSize2>\nstruct SameSizeTuplePrefixComparator;\n\ntemplate <>\nstruct SameSizeTuplePrefixComparator<0, 0> {\n  template <class Tuple1, class Tuple2>\n  static bool Eq(const Tuple1& /* t1 */, const Tuple2& /* t2 */) {\n    return true;\n  }\n};\n\ntemplate <int k>\nstruct SameSizeTuplePrefixComparator<k, k> {\n  template <class Tuple1, class Tuple2>\n  static bool Eq(const Tuple1& t1, const Tuple2& t2) {\n    return SameSizeTuplePrefixComparator<k - 1, k - 1>::Eq(t1, t2) &&\n        ::std::tr1::get<k - 1>(t1) == ::std::tr1::get<k - 1>(t2);\n  }\n};\n\n}  // namespace gtest_internal\n\ntemplate <GTEST_10_TYPENAMES_(T), GTEST_10_TYPENAMES_(U)>\ninline bool operator==(const GTEST_10_TUPLE_(T)& t,\n                       const GTEST_10_TUPLE_(U)& u) {\n  return gtest_internal::SameSizeTuplePrefixComparator<\n      tuple_size<GTEST_10_TUPLE_(T) >::value,\n      tuple_size<GTEST_10_TUPLE_(U) >::value>::Eq(t, u);\n}\n\ntemplate <GTEST_10_TYPENAMES_(T), GTEST_10_TYPENAMES_(U)>\ninline bool operator!=(const GTEST_10_TUPLE_(T)& t,\n                       const GTEST_10_TUPLE_(U)& u) { return !(t == u); }\n\n// 6.1.4 Pairs.\n// Unimplemented.\n\n}  // namespace tr1\n}  // namespace std\n\n#undef GTEST_0_TUPLE_\n#undef GTEST_1_TUPLE_\n#undef GTEST_2_TUPLE_\n#undef GTEST_3_TUPLE_\n#undef GTEST_4_TUPLE_\n#undef GTEST_5_TUPLE_\n#undef GTEST_6_TUPLE_\n#undef GTEST_7_TUPLE_\n#undef GTEST_8_TUPLE_\n#undef GTEST_9_TUPLE_\n#undef GTEST_10_TUPLE_\n\n#undef GTEST_0_TYPENAMES_\n#undef GTEST_1_TYPENAMES_\n#undef GTEST_2_TYPENAMES_\n#undef GTEST_3_TYPENAMES_\n#undef GTEST_4_TYPENAMES_\n#undef GTEST_5_TYPENAMES_\n#undef GTEST_6_TYPENAMES_\n#undef GTEST_7_TYPENAMES_\n#undef GTEST_8_TYPENAMES_\n#undef GTEST_9_TYPENAMES_\n#undef GTEST_10_TYPENAMES_\n\n#undef GTEST_DECLARE_TUPLE_AS_FRIEND_\n#undef GTEST_BY_REF_\n#undef GTEST_ADD_REF_\n#undef GTEST_TUPLE_ELEMENT_\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/internal/gtest-tuple.h.pump",
    "content": "$$ -*- mode: c++; -*-\n$var n = 10  $$ Maximum number of tuple fields we want to support.\n$$ This meta comment fixes auto-indentation in Emacs. }}\n// Copyright 2009 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Implements a subset of TR1 tuple needed by Google Test and Google Mock.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_\n\n#include <utility>  // For ::std::pair.\n\n// The compiler used in Symbian has a bug that prevents us from declaring the\n// tuple template as a friend (it complains that tuple is redefined).  This\n// hack bypasses the bug by declaring the members that should otherwise be\n// private as public.\n// Sun Studio versions < 12 also have the above bug.\n#if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590)\n# define GTEST_DECLARE_TUPLE_AS_FRIEND_ public:\n#else\n# define GTEST_DECLARE_TUPLE_AS_FRIEND_ \\\n    template <GTEST_$(n)_TYPENAMES_(U)> friend class tuple; \\\n   private:\n#endif\n\n\n$range i 0..n-1\n$range j 0..n\n$range k 1..n\n// GTEST_n_TUPLE_(T) is the type of an n-tuple.\n#define GTEST_0_TUPLE_(T) tuple<>\n\n$for k [[\n$range m 0..k-1\n$range m2 k..n-1\n#define GTEST_$(k)_TUPLE_(T) tuple<$for m, [[T##$m]]$for m2 [[, void]]>\n\n]]\n\n// GTEST_n_TYPENAMES_(T) declares a list of n typenames.\n\n$for j [[\n$range m 0..j-1\n#define GTEST_$(j)_TYPENAMES_(T) $for m, [[typename T##$m]]\n\n\n]]\n\n// In theory, defining stuff in the ::std namespace is undefined\n// behavior.  We can do this as we are playing the role of a standard\n// library vendor.\nnamespace std {\nnamespace tr1 {\n\ntemplate <$for i, [[typename T$i = void]]>\nclass tuple;\n\n// Anything in namespace gtest_internal is Google Test's INTERNAL\n// IMPLEMENTATION DETAIL and MUST NOT BE USED DIRECTLY in user code.\nnamespace gtest_internal {\n\n// ByRef<T>::type is T if T is a reference; otherwise it's const T&.\ntemplate <typename T>\nstruct ByRef { typedef const T& type; };  // NOLINT\ntemplate <typename T>\nstruct ByRef<T&> { typedef T& type; };  // NOLINT\n\n// A handy wrapper for ByRef.\n#define GTEST_BY_REF_(T) typename ::std::tr1::gtest_internal::ByRef<T>::type\n\n// AddRef<T>::type is T if T is a reference; otherwise it's T&.  This\n// is the same as tr1::add_reference<T>::type.\ntemplate <typename T>\nstruct AddRef { typedef T& type; };  // NOLINT\ntemplate <typename T>\nstruct AddRef<T&> { typedef T& type; };  // NOLINT\n\n// A handy wrapper for AddRef.\n#define GTEST_ADD_REF_(T) typename ::std::tr1::gtest_internal::AddRef<T>::type\n\n// A helper for implementing get<k>().\ntemplate <int k> class Get;\n\n// A helper for implementing tuple_element<k, T>.  kIndexValid is true\n// iff k < the number of fields in tuple type T.\ntemplate <bool kIndexValid, int kIndex, class Tuple>\nstruct TupleElement;\n\n\n$for i [[\ntemplate <GTEST_$(n)_TYPENAMES_(T)>\nstruct TupleElement<true, $i, GTEST_$(n)_TUPLE_(T) > {\n  typedef T$i type;\n};\n\n\n]]\n}  // namespace gtest_internal\n\ntemplate <>\nclass tuple<> {\n public:\n  tuple() {}\n  tuple(const tuple& /* t */)  {}\n  tuple& operator=(const tuple& /* t */) { return *this; }\n};\n\n\n$for k [[\n$range m 0..k-1\ntemplate <GTEST_$(k)_TYPENAMES_(T)>\nclass $if k < n [[GTEST_$(k)_TUPLE_(T)]] $else [[tuple]] {\n public:\n  template <int k> friend class gtest_internal::Get;\n\n  tuple() : $for m, [[f$(m)_()]] {}\n\n  explicit tuple($for m, [[GTEST_BY_REF_(T$m) f$m]]) : [[]]\n$for m, [[f$(m)_(f$m)]] {}\n\n  tuple(const tuple& t) : $for m, [[f$(m)_(t.f$(m)_)]] {}\n\n  template <GTEST_$(k)_TYPENAMES_(U)>\n  tuple(const GTEST_$(k)_TUPLE_(U)& t) : $for m, [[f$(m)_(t.f$(m)_)]] {}\n\n$if k == 2 [[\n  template <typename U0, typename U1>\n  tuple(const ::std::pair<U0, U1>& p) : f0_(p.first), f1_(p.second) {}\n\n]]\n\n  tuple& operator=(const tuple& t) { return CopyFrom(t); }\n\n  template <GTEST_$(k)_TYPENAMES_(U)>\n  tuple& operator=(const GTEST_$(k)_TUPLE_(U)& t) {\n    return CopyFrom(t);\n  }\n\n$if k == 2 [[\n  template <typename U0, typename U1>\n  tuple& operator=(const ::std::pair<U0, U1>& p) {\n    f0_ = p.first;\n    f1_ = p.second;\n    return *this;\n  }\n\n]]\n\n  GTEST_DECLARE_TUPLE_AS_FRIEND_\n\n  template <GTEST_$(k)_TYPENAMES_(U)>\n  tuple& CopyFrom(const GTEST_$(k)_TUPLE_(U)& t) {\n\n$for m [[\n    f$(m)_ = t.f$(m)_;\n\n]]\n    return *this;\n  }\n\n\n$for m [[\n  T$m f$(m)_;\n\n]]\n};\n\n\n]]\n// 6.1.3.2 Tuple creation functions.\n\n// Known limitations: we don't support passing an\n// std::tr1::reference_wrapper<T> to make_tuple().  And we don't\n// implement tie().\n\ninline tuple<> make_tuple() { return tuple<>(); }\n\n$for k [[\n$range m 0..k-1\n\ntemplate <GTEST_$(k)_TYPENAMES_(T)>\ninline GTEST_$(k)_TUPLE_(T) make_tuple($for m, [[const T$m& f$m]]) {\n  return GTEST_$(k)_TUPLE_(T)($for m, [[f$m]]);\n}\n\n]]\n\n// 6.1.3.3 Tuple helper classes.\n\ntemplate <typename Tuple> struct tuple_size;\n\n\n$for j [[\ntemplate <GTEST_$(j)_TYPENAMES_(T)>\nstruct tuple_size<GTEST_$(j)_TUPLE_(T) > {\n  static const int value = $j;\n};\n\n\n]]\ntemplate <int k, class Tuple>\nstruct tuple_element {\n  typedef typename gtest_internal::TupleElement<\n      k < (tuple_size<Tuple>::value), k, Tuple>::type type;\n};\n\n#define GTEST_TUPLE_ELEMENT_(k, Tuple) typename tuple_element<k, Tuple >::type\n\n// 6.1.3.4 Element access.\n\nnamespace gtest_internal {\n\n\n$for i [[\ntemplate <>\nclass Get<$i> {\n public:\n  template <class Tuple>\n  static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_($i, Tuple))\n  Field(Tuple& t) { return t.f$(i)_; }  // NOLINT\n\n  template <class Tuple>\n  static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_($i, Tuple))\n  ConstField(const Tuple& t) { return t.f$(i)_; }\n};\n\n\n]]\n}  // namespace gtest_internal\n\ntemplate <int k, GTEST_$(n)_TYPENAMES_(T)>\nGTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_$(n)_TUPLE_(T)))\nget(GTEST_$(n)_TUPLE_(T)& t) {\n  return gtest_internal::Get<k>::Field(t);\n}\n\ntemplate <int k, GTEST_$(n)_TYPENAMES_(T)>\nGTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(k,  GTEST_$(n)_TUPLE_(T)))\nget(const GTEST_$(n)_TUPLE_(T)& t) {\n  return gtest_internal::Get<k>::ConstField(t);\n}\n\n// 6.1.3.5 Relational operators\n\n// We only implement == and !=, as we don't have a need for the rest yet.\n\nnamespace gtest_internal {\n\n// SameSizeTuplePrefixComparator<k, k>::Eq(t1, t2) returns true if the\n// first k fields of t1 equals the first k fields of t2.\n// SameSizeTuplePrefixComparator(k1, k2) would be a compiler error if\n// k1 != k2.\ntemplate <int kSize1, int kSize2>\nstruct SameSizeTuplePrefixComparator;\n\ntemplate <>\nstruct SameSizeTuplePrefixComparator<0, 0> {\n  template <class Tuple1, class Tuple2>\n  static bool Eq(const Tuple1& /* t1 */, const Tuple2& /* t2 */) {\n    return true;\n  }\n};\n\ntemplate <int k>\nstruct SameSizeTuplePrefixComparator<k, k> {\n  template <class Tuple1, class Tuple2>\n  static bool Eq(const Tuple1& t1, const Tuple2& t2) {\n    return SameSizeTuplePrefixComparator<k - 1, k - 1>::Eq(t1, t2) &&\n        ::std::tr1::get<k - 1>(t1) == ::std::tr1::get<k - 1>(t2);\n  }\n};\n\n}  // namespace gtest_internal\n\ntemplate <GTEST_$(n)_TYPENAMES_(T), GTEST_$(n)_TYPENAMES_(U)>\ninline bool operator==(const GTEST_$(n)_TUPLE_(T)& t,\n                       const GTEST_$(n)_TUPLE_(U)& u) {\n  return gtest_internal::SameSizeTuplePrefixComparator<\n      tuple_size<GTEST_$(n)_TUPLE_(T) >::value,\n      tuple_size<GTEST_$(n)_TUPLE_(U) >::value>::Eq(t, u);\n}\n\ntemplate <GTEST_$(n)_TYPENAMES_(T), GTEST_$(n)_TYPENAMES_(U)>\ninline bool operator!=(const GTEST_$(n)_TUPLE_(T)& t,\n                       const GTEST_$(n)_TUPLE_(U)& u) { return !(t == u); }\n\n// 6.1.4 Pairs.\n// Unimplemented.\n\n}  // namespace tr1\n}  // namespace std\n\n\n$for j [[\n#undef GTEST_$(j)_TUPLE_\n\n]]\n\n\n$for j [[\n#undef GTEST_$(j)_TYPENAMES_\n\n]]\n\n#undef GTEST_DECLARE_TUPLE_AS_FRIEND_\n#undef GTEST_BY_REF_\n#undef GTEST_ADD_REF_\n#undef GTEST_TUPLE_ELEMENT_\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/internal/gtest-type-util.h",
    "content": "// This file was GENERATED by command:\n//     pump.py gtest-type-util.h.pump\n// DO NOT EDIT BY HAND!!!\n\n// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Type utilities needed for implementing typed and type-parameterized\n// tests.  This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!\n//\n// Currently we support at most 50 types in a list, and at most 50\n// type-parameterized tests in one type-parameterized test case.\n// Please contact googletestframework@googlegroups.com if you need\n// more.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_\n\n#include \"gtest/internal/gtest-port.h\"\n\n// #ifdef __GNUC__ is too general here.  It is possible to use gcc without using\n// libstdc++ (which is where cxxabi.h comes from).\n# if GTEST_HAS_CXXABI_H_\n#  include <cxxabi.h>\n# elif defined(__HP_aCC)\n#  include <acxx_demangle.h>\n# endif  // GTEST_HASH_CXXABI_H_\n\nnamespace testing {\nnamespace internal {\n\n// GetTypeName<T>() returns a human-readable name of type T.\n// NB: This function is also used in Google Mock, so don't move it inside of\n// the typed-test-only section below.\ntemplate <typename T>\nstd::string GetTypeName() {\n# if GTEST_HAS_RTTI\n\n  const char* const name = typeid(T).name();\n#  if GTEST_HAS_CXXABI_H_ || defined(__HP_aCC)\n  int status = 0;\n  // gcc's implementation of typeid(T).name() mangles the type name,\n  // so we have to demangle it.\n#   if GTEST_HAS_CXXABI_H_\n  using abi::__cxa_demangle;\n#   endif  // GTEST_HAS_CXXABI_H_\n  char* const readable_name = __cxa_demangle(name, 0, 0, &status);\n  const std::string name_str(status == 0 ? readable_name : name);\n  free(readable_name);\n  return name_str;\n#  else\n  return name;\n#  endif  // GTEST_HAS_CXXABI_H_ || __HP_aCC\n\n# else\n\n  return \"<type>\";\n\n# endif  // GTEST_HAS_RTTI\n}\n\n#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P\n\n// AssertyTypeEq<T1, T2>::type is defined iff T1 and T2 are the same\n// type.  This can be used as a compile-time assertion to ensure that\n// two types are equal.\n\ntemplate <typename T1, typename T2>\nstruct AssertTypeEq;\n\ntemplate <typename T>\nstruct AssertTypeEq<T, T> {\n  typedef bool type;\n};\n\n// A unique type used as the default value for the arguments of class\n// template Types.  This allows us to simulate variadic templates\n// (e.g. Types<int>, Type<int, double>, and etc), which C++ doesn't\n// support directly.\nstruct None {};\n\n// The following family of struct and struct templates are used to\n// represent type lists.  In particular, TypesN<T1, T2, ..., TN>\n// represents a type list with N types (T1, T2, ..., and TN) in it.\n// Except for Types0, every struct in the family has two member types:\n// Head for the first type in the list, and Tail for the rest of the\n// list.\n\n// The empty type list.\nstruct Types0 {};\n\n// Type lists of length 1, 2, 3, and so on.\n\ntemplate <typename T1>\nstruct Types1 {\n  typedef T1 Head;\n  typedef Types0 Tail;\n};\ntemplate <typename T1, typename T2>\nstruct Types2 {\n  typedef T1 Head;\n  typedef Types1<T2> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3>\nstruct Types3 {\n  typedef T1 Head;\n  typedef Types2<T2, T3> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4>\nstruct Types4 {\n  typedef T1 Head;\n  typedef Types3<T2, T3, T4> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5>\nstruct Types5 {\n  typedef T1 Head;\n  typedef Types4<T2, T3, T4, T5> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6>\nstruct Types6 {\n  typedef T1 Head;\n  typedef Types5<T2, T3, T4, T5, T6> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7>\nstruct Types7 {\n  typedef T1 Head;\n  typedef Types6<T2, T3, T4, T5, T6, T7> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8>\nstruct Types8 {\n  typedef T1 Head;\n  typedef Types7<T2, T3, T4, T5, T6, T7, T8> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9>\nstruct Types9 {\n  typedef T1 Head;\n  typedef Types8<T2, T3, T4, T5, T6, T7, T8, T9> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10>\nstruct Types10 {\n  typedef T1 Head;\n  typedef Types9<T2, T3, T4, T5, T6, T7, T8, T9, T10> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11>\nstruct Types11 {\n  typedef T1 Head;\n  typedef Types10<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12>\nstruct Types12 {\n  typedef T1 Head;\n  typedef Types11<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13>\nstruct Types13 {\n  typedef T1 Head;\n  typedef Types12<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14>\nstruct Types14 {\n  typedef T1 Head;\n  typedef Types13<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15>\nstruct Types15 {\n  typedef T1 Head;\n  typedef Types14<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16>\nstruct Types16 {\n  typedef T1 Head;\n  typedef Types15<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17>\nstruct Types17 {\n  typedef T1 Head;\n  typedef Types16<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18>\nstruct Types18 {\n  typedef T1 Head;\n  typedef Types17<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19>\nstruct Types19 {\n  typedef T1 Head;\n  typedef Types18<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20>\nstruct Types20 {\n  typedef T1 Head;\n  typedef Types19<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21>\nstruct Types21 {\n  typedef T1 Head;\n  typedef Types20<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22>\nstruct Types22 {\n  typedef T1 Head;\n  typedef Types21<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23>\nstruct Types23 {\n  typedef T1 Head;\n  typedef Types22<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24>\nstruct Types24 {\n  typedef T1 Head;\n  typedef Types23<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25>\nstruct Types25 {\n  typedef T1 Head;\n  typedef Types24<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26>\nstruct Types26 {\n  typedef T1 Head;\n  typedef Types25<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27>\nstruct Types27 {\n  typedef T1 Head;\n  typedef Types26<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28>\nstruct Types28 {\n  typedef T1 Head;\n  typedef Types27<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29>\nstruct Types29 {\n  typedef T1 Head;\n  typedef Types28<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30>\nstruct Types30 {\n  typedef T1 Head;\n  typedef Types29<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31>\nstruct Types31 {\n  typedef T1 Head;\n  typedef Types30<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32>\nstruct Types32 {\n  typedef T1 Head;\n  typedef Types31<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33>\nstruct Types33 {\n  typedef T1 Head;\n  typedef Types32<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34>\nstruct Types34 {\n  typedef T1 Head;\n  typedef Types33<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35>\nstruct Types35 {\n  typedef T1 Head;\n  typedef Types34<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36>\nstruct Types36 {\n  typedef T1 Head;\n  typedef Types35<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37>\nstruct Types37 {\n  typedef T1 Head;\n  typedef Types36<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38>\nstruct Types38 {\n  typedef T1 Head;\n  typedef Types37<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39>\nstruct Types39 {\n  typedef T1 Head;\n  typedef Types38<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40>\nstruct Types40 {\n  typedef T1 Head;\n  typedef Types39<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41>\nstruct Types41 {\n  typedef T1 Head;\n  typedef Types40<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42>\nstruct Types42 {\n  typedef T1 Head;\n  typedef Types41<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43>\nstruct Types43 {\n  typedef T1 Head;\n  typedef Types42<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,\n      T43> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44>\nstruct Types44 {\n  typedef T1 Head;\n  typedef Types43<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n      T44> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45>\nstruct Types45 {\n  typedef T1 Head;\n  typedef Types44<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n      T44, T45> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46>\nstruct Types46 {\n  typedef T1 Head;\n  typedef Types45<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n      T44, T45, T46> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47>\nstruct Types47 {\n  typedef T1 Head;\n  typedef Types46<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n      T44, T45, T46, T47> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48>\nstruct Types48 {\n  typedef T1 Head;\n  typedef Types47<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n      T44, T45, T46, T47, T48> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48, typename T49>\nstruct Types49 {\n  typedef T1 Head;\n  typedef Types48<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n      T44, T45, T46, T47, T48, T49> Tail;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48, typename T49, typename T50>\nstruct Types50 {\n  typedef T1 Head;\n  typedef Types49<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n      T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n      T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n      T44, T45, T46, T47, T48, T49, T50> Tail;\n};\n\n\n}  // namespace internal\n\n// We don't want to require the users to write TypesN<...> directly,\n// as that would require them to count the length.  Types<...> is much\n// easier to write, but generates horrible messages when there is a\n// compiler error, as gcc insists on printing out each template\n// argument, even if it has the default value (this means Types<int>\n// will appear as Types<int, None, None, ..., None> in the compiler\n// errors).\n//\n// Our solution is to combine the best part of the two approaches: a\n// user would write Types<T1, ..., TN>, and Google Test will translate\n// that to TypesN<T1, ..., TN> internally to make error messages\n// readable.  The translation is done by the 'type' member of the\n// Types template.\ntemplate <typename T1 = internal::None, typename T2 = internal::None,\n    typename T3 = internal::None, typename T4 = internal::None,\n    typename T5 = internal::None, typename T6 = internal::None,\n    typename T7 = internal::None, typename T8 = internal::None,\n    typename T9 = internal::None, typename T10 = internal::None,\n    typename T11 = internal::None, typename T12 = internal::None,\n    typename T13 = internal::None, typename T14 = internal::None,\n    typename T15 = internal::None, typename T16 = internal::None,\n    typename T17 = internal::None, typename T18 = internal::None,\n    typename T19 = internal::None, typename T20 = internal::None,\n    typename T21 = internal::None, typename T22 = internal::None,\n    typename T23 = internal::None, typename T24 = internal::None,\n    typename T25 = internal::None, typename T26 = internal::None,\n    typename T27 = internal::None, typename T28 = internal::None,\n    typename T29 = internal::None, typename T30 = internal::None,\n    typename T31 = internal::None, typename T32 = internal::None,\n    typename T33 = internal::None, typename T34 = internal::None,\n    typename T35 = internal::None, typename T36 = internal::None,\n    typename T37 = internal::None, typename T38 = internal::None,\n    typename T39 = internal::None, typename T40 = internal::None,\n    typename T41 = internal::None, typename T42 = internal::None,\n    typename T43 = internal::None, typename T44 = internal::None,\n    typename T45 = internal::None, typename T46 = internal::None,\n    typename T47 = internal::None, typename T48 = internal::None,\n    typename T49 = internal::None, typename T50 = internal::None>\nstruct Types {\n  typedef internal::Types50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41, T42, T43, T44, T45, T46, T47, T48, T49, T50> type;\n};\n\ntemplate <>\nstruct Types<internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types0 type;\n};\ntemplate <typename T1>\nstruct Types<T1, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types1<T1> type;\n};\ntemplate <typename T1, typename T2>\nstruct Types<T1, T2, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types2<T1, T2> type;\n};\ntemplate <typename T1, typename T2, typename T3>\nstruct Types<T1, T2, T3, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None> {\n  typedef internal::Types3<T1, T2, T3> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4>\nstruct Types<T1, T2, T3, T4, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None> {\n  typedef internal::Types4<T1, T2, T3, T4> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5>\nstruct Types<T1, T2, T3, T4, T5, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None> {\n  typedef internal::Types5<T1, T2, T3, T4, T5> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6>\nstruct Types<T1, T2, T3, T4, T5, T6, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types6<T1, T2, T3, T4, T5, T6> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types7<T1, T2, T3, T4, T5, T6, T7> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None> {\n  typedef internal::Types8<T1, T2, T3, T4, T5, T6, T7, T8> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None> {\n  typedef internal::Types9<T1, T2, T3, T4, T5, T6, T7, T8, T9> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None> {\n  typedef internal::Types10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,\n      T12> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None> {\n  typedef internal::Types14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None> {\n  typedef internal::Types15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None> {\n  typedef internal::Types19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None> {\n  typedef internal::Types20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None> {\n  typedef internal::Types21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None> {\n  typedef internal::Types25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None> {\n  typedef internal::Types26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25,\n      T26> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None> {\n  typedef internal::Types30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None> {\n  typedef internal::Types31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None> {\n  typedef internal::Types35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None> {\n  typedef internal::Types36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None> {\n  typedef internal::Types37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, T39, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39,\n      T40> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None, internal::None> {\n  typedef internal::Types41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, internal::None,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None> {\n  typedef internal::Types42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41, T42> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None, internal::None> {\n  typedef internal::Types43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41, T42, T43> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None, internal::None> {\n  typedef internal::Types44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41, T42, T43, T44> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,\n    internal::None, internal::None, internal::None, internal::None,\n    internal::None> {\n  typedef internal::Types45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41, T42, T43, T44, T45> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,\n    T46, internal::None, internal::None, internal::None, internal::None> {\n  typedef internal::Types46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41, T42, T43, T44, T45, T46> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,\n    T46, T47, internal::None, internal::None, internal::None> {\n  typedef internal::Types47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41, T42, T43, T44, T45, T46, T47> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,\n    T46, T47, T48, internal::None, internal::None> {\n  typedef internal::Types48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41, T42, T43, T44, T45, T46, T47, T48> type;\n};\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48, typename T49>\nstruct Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,\n    T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29, T30,\n    T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44, T45,\n    T46, T47, T48, T49, internal::None> {\n  typedef internal::Types49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41, T42, T43, T44, T45, T46, T47, T48, T49> type;\n};\n\nnamespace internal {\n\n# define GTEST_TEMPLATE_ template <typename T> class\n\n// The template \"selector\" struct TemplateSel<Tmpl> is used to\n// represent Tmpl, which must be a class template with one type\n// parameter, as a type.  TemplateSel<Tmpl>::Bind<T>::type is defined\n// as the type Tmpl<T>.  This allows us to actually instantiate the\n// template \"selected\" by TemplateSel<Tmpl>.\n//\n// This trick is necessary for simulating typedef for class templates,\n// which C++ doesn't support directly.\ntemplate <GTEST_TEMPLATE_ Tmpl>\nstruct TemplateSel {\n  template <typename T>\n  struct Bind {\n    typedef Tmpl<T> type;\n  };\n};\n\n# define GTEST_BIND_(TmplSel, T) \\\n  TmplSel::template Bind<T>::type\n\n// A unique struct template used as the default value for the\n// arguments of class template Templates.  This allows us to simulate\n// variadic templates (e.g. Templates<int>, Templates<int, double>,\n// and etc), which C++ doesn't support directly.\ntemplate <typename T>\nstruct NoneT {};\n\n// The following family of struct and struct templates are used to\n// represent template lists.  In particular, TemplatesN<T1, T2, ...,\n// TN> represents a list of N templates (T1, T2, ..., and TN).  Except\n// for Templates0, every struct in the family has two member types:\n// Head for the selector of the first template in the list, and Tail\n// for the rest of the list.\n\n// The empty template list.\nstruct Templates0 {};\n\n// Template lists of length 1, 2, 3, and so on.\n\ntemplate <GTEST_TEMPLATE_ T1>\nstruct Templates1 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates0 Tail;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2>\nstruct Templates2 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates1<T2> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3>\nstruct Templates3 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates2<T2, T3> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4>\nstruct Templates4 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates3<T2, T3, T4> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5>\nstruct Templates5 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates4<T2, T3, T4, T5> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6>\nstruct Templates6 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates5<T2, T3, T4, T5, T6> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7>\nstruct Templates7 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates6<T2, T3, T4, T5, T6, T7> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8>\nstruct Templates8 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates7<T2, T3, T4, T5, T6, T7, T8> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9>\nstruct Templates9 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates8<T2, T3, T4, T5, T6, T7, T8, T9> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10>\nstruct Templates10 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates9<T2, T3, T4, T5, T6, T7, T8, T9, T10> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11>\nstruct Templates11 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates10<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12>\nstruct Templates12 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates11<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13>\nstruct Templates13 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates12<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14>\nstruct Templates14 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates13<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15>\nstruct Templates15 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates14<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16>\nstruct Templates16 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates15<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17>\nstruct Templates17 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates16<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18>\nstruct Templates18 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates17<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19>\nstruct Templates19 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates18<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20>\nstruct Templates20 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates19<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21>\nstruct Templates21 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates20<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22>\nstruct Templates22 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates21<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23>\nstruct Templates23 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates22<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24>\nstruct Templates24 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates23<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25>\nstruct Templates25 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates24<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26>\nstruct Templates26 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates25<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27>\nstruct Templates27 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates26<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28>\nstruct Templates28 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates27<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29>\nstruct Templates29 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates28<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30>\nstruct Templates30 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates29<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31>\nstruct Templates31 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates30<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32>\nstruct Templates32 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates31<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33>\nstruct Templates33 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates32<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34>\nstruct Templates34 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates33<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35>\nstruct Templates35 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates34<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36>\nstruct Templates36 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates35<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37>\nstruct Templates37 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates36<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38>\nstruct Templates38 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates37<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39>\nstruct Templates39 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates38<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40>\nstruct Templates40 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates39<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41>\nstruct Templates41 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates40<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42>\nstruct Templates42 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates41<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,\n      T42> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43>\nstruct Templates43 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates42<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,\n      T43> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44>\nstruct Templates44 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates43<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,\n      T43, T44> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45>\nstruct Templates45 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates44<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,\n      T43, T44, T45> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,\n    GTEST_TEMPLATE_ T46>\nstruct Templates46 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates45<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,\n      T43, T44, T45, T46> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,\n    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47>\nstruct Templates47 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates46<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,\n      T43, T44, T45, T46, T47> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,\n    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48>\nstruct Templates48 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates47<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,\n      T43, T44, T45, T46, T47, T48> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,\n    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48,\n    GTEST_TEMPLATE_ T49>\nstruct Templates49 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates48<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,\n      T43, T44, T45, T46, T47, T48, T49> Tail;\n};\n\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,\n    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48,\n    GTEST_TEMPLATE_ T49, GTEST_TEMPLATE_ T50>\nstruct Templates50 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates49<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n      T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n      T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42,\n      T43, T44, T45, T46, T47, T48, T49, T50> Tail;\n};\n\n\n// We don't want to require the users to write TemplatesN<...> directly,\n// as that would require them to count the length.  Templates<...> is much\n// easier to write, but generates horrible messages when there is a\n// compiler error, as gcc insists on printing out each template\n// argument, even if it has the default value (this means Templates<list>\n// will appear as Templates<list, NoneT, NoneT, ..., NoneT> in the compiler\n// errors).\n//\n// Our solution is to combine the best part of the two approaches: a\n// user would write Templates<T1, ..., TN>, and Google Test will translate\n// that to TemplatesN<T1, ..., TN> internally to make error messages\n// readable.  The translation is done by the 'type' member of the\n// Templates template.\ntemplate <GTEST_TEMPLATE_ T1 = NoneT, GTEST_TEMPLATE_ T2 = NoneT,\n    GTEST_TEMPLATE_ T3 = NoneT, GTEST_TEMPLATE_ T4 = NoneT,\n    GTEST_TEMPLATE_ T5 = NoneT, GTEST_TEMPLATE_ T6 = NoneT,\n    GTEST_TEMPLATE_ T7 = NoneT, GTEST_TEMPLATE_ T8 = NoneT,\n    GTEST_TEMPLATE_ T9 = NoneT, GTEST_TEMPLATE_ T10 = NoneT,\n    GTEST_TEMPLATE_ T11 = NoneT, GTEST_TEMPLATE_ T12 = NoneT,\n    GTEST_TEMPLATE_ T13 = NoneT, GTEST_TEMPLATE_ T14 = NoneT,\n    GTEST_TEMPLATE_ T15 = NoneT, GTEST_TEMPLATE_ T16 = NoneT,\n    GTEST_TEMPLATE_ T17 = NoneT, GTEST_TEMPLATE_ T18 = NoneT,\n    GTEST_TEMPLATE_ T19 = NoneT, GTEST_TEMPLATE_ T20 = NoneT,\n    GTEST_TEMPLATE_ T21 = NoneT, GTEST_TEMPLATE_ T22 = NoneT,\n    GTEST_TEMPLATE_ T23 = NoneT, GTEST_TEMPLATE_ T24 = NoneT,\n    GTEST_TEMPLATE_ T25 = NoneT, GTEST_TEMPLATE_ T26 = NoneT,\n    GTEST_TEMPLATE_ T27 = NoneT, GTEST_TEMPLATE_ T28 = NoneT,\n    GTEST_TEMPLATE_ T29 = NoneT, GTEST_TEMPLATE_ T30 = NoneT,\n    GTEST_TEMPLATE_ T31 = NoneT, GTEST_TEMPLATE_ T32 = NoneT,\n    GTEST_TEMPLATE_ T33 = NoneT, GTEST_TEMPLATE_ T34 = NoneT,\n    GTEST_TEMPLATE_ T35 = NoneT, GTEST_TEMPLATE_ T36 = NoneT,\n    GTEST_TEMPLATE_ T37 = NoneT, GTEST_TEMPLATE_ T38 = NoneT,\n    GTEST_TEMPLATE_ T39 = NoneT, GTEST_TEMPLATE_ T40 = NoneT,\n    GTEST_TEMPLATE_ T41 = NoneT, GTEST_TEMPLATE_ T42 = NoneT,\n    GTEST_TEMPLATE_ T43 = NoneT, GTEST_TEMPLATE_ T44 = NoneT,\n    GTEST_TEMPLATE_ T45 = NoneT, GTEST_TEMPLATE_ T46 = NoneT,\n    GTEST_TEMPLATE_ T47 = NoneT, GTEST_TEMPLATE_ T48 = NoneT,\n    GTEST_TEMPLATE_ T49 = NoneT, GTEST_TEMPLATE_ T50 = NoneT>\nstruct Templates {\n  typedef Templates50<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,\n      T42, T43, T44, T45, T46, T47, T48, T49, T50> type;\n};\n\ntemplate <>\nstruct Templates<NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT> {\n  typedef Templates0 type;\n};\ntemplate <GTEST_TEMPLATE_ T1>\nstruct Templates<T1, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT> {\n  typedef Templates1<T1> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2>\nstruct Templates<T1, T2, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT> {\n  typedef Templates2<T1, T2> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3>\nstruct Templates<T1, T2, T3, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates3<T1, T2, T3> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4>\nstruct Templates<T1, T2, T3, T4, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates4<T1, T2, T3, T4> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5>\nstruct Templates<T1, T2, T3, T4, T5, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates5<T1, T2, T3, T4, T5> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6>\nstruct Templates<T1, T2, T3, T4, T5, T6, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates6<T1, T2, T3, T4, T5, T6> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates7<T1, T2, T3, T4, T5, T6, T7> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates8<T1, T2, T3, T4, T5, T6, T7, T8> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates9<T1, T2, T3, T4, T5, T6, T7, T8, T9> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates10<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates11<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates12<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates13<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates14<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates16<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates17<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates18<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates19<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates20<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates21<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT> {\n  typedef Templates22<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT> {\n  typedef Templates23<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT> {\n  typedef Templates24<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT> {\n  typedef Templates25<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT> {\n  typedef Templates26<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT> {\n  typedef Templates27<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT> {\n  typedef Templates28<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT> {\n  typedef Templates29<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates30<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates31<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates32<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates33<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates34<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates35<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates36<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, NoneT, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates37<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, NoneT, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates38<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates39<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, NoneT, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates40<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, NoneT, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates41<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, NoneT,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates42<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,\n      T42> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates43<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,\n      T42, T43> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,\n    NoneT, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates44<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,\n      T42, T43, T44> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,\n    T45, NoneT, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates45<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,\n      T42, T43, T44, T45> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,\n    GTEST_TEMPLATE_ T46>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,\n    T45, T46, NoneT, NoneT, NoneT, NoneT> {\n  typedef Templates46<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,\n      T42, T43, T44, T45, T46> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,\n    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,\n    T45, T46, T47, NoneT, NoneT, NoneT> {\n  typedef Templates47<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,\n      T42, T43, T44, T45, T46, T47> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,\n    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,\n    T45, T46, T47, T48, NoneT, NoneT> {\n  typedef Templates48<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,\n      T42, T43, T44, T45, T46, T47, T48> type;\n};\ntemplate <GTEST_TEMPLATE_ T1, GTEST_TEMPLATE_ T2, GTEST_TEMPLATE_ T3,\n    GTEST_TEMPLATE_ T4, GTEST_TEMPLATE_ T5, GTEST_TEMPLATE_ T6,\n    GTEST_TEMPLATE_ T7, GTEST_TEMPLATE_ T8, GTEST_TEMPLATE_ T9,\n    GTEST_TEMPLATE_ T10, GTEST_TEMPLATE_ T11, GTEST_TEMPLATE_ T12,\n    GTEST_TEMPLATE_ T13, GTEST_TEMPLATE_ T14, GTEST_TEMPLATE_ T15,\n    GTEST_TEMPLATE_ T16, GTEST_TEMPLATE_ T17, GTEST_TEMPLATE_ T18,\n    GTEST_TEMPLATE_ T19, GTEST_TEMPLATE_ T20, GTEST_TEMPLATE_ T21,\n    GTEST_TEMPLATE_ T22, GTEST_TEMPLATE_ T23, GTEST_TEMPLATE_ T24,\n    GTEST_TEMPLATE_ T25, GTEST_TEMPLATE_ T26, GTEST_TEMPLATE_ T27,\n    GTEST_TEMPLATE_ T28, GTEST_TEMPLATE_ T29, GTEST_TEMPLATE_ T30,\n    GTEST_TEMPLATE_ T31, GTEST_TEMPLATE_ T32, GTEST_TEMPLATE_ T33,\n    GTEST_TEMPLATE_ T34, GTEST_TEMPLATE_ T35, GTEST_TEMPLATE_ T36,\n    GTEST_TEMPLATE_ T37, GTEST_TEMPLATE_ T38, GTEST_TEMPLATE_ T39,\n    GTEST_TEMPLATE_ T40, GTEST_TEMPLATE_ T41, GTEST_TEMPLATE_ T42,\n    GTEST_TEMPLATE_ T43, GTEST_TEMPLATE_ T44, GTEST_TEMPLATE_ T45,\n    GTEST_TEMPLATE_ T46, GTEST_TEMPLATE_ T47, GTEST_TEMPLATE_ T48,\n    GTEST_TEMPLATE_ T49>\nstruct Templates<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14,\n    T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28, T29,\n    T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43, T44,\n    T45, T46, T47, T48, T49, NoneT> {\n  typedef Templates49<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n      T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27,\n      T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41,\n      T42, T43, T44, T45, T46, T47, T48, T49> type;\n};\n\n// The TypeList template makes it possible to use either a single type\n// or a Types<...> list in TYPED_TEST_CASE() and\n// INSTANTIATE_TYPED_TEST_CASE_P().\n\ntemplate <typename T>\nstruct TypeList {\n  typedef Types1<T> type;\n};\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n    typename T6, typename T7, typename T8, typename T9, typename T10,\n    typename T11, typename T12, typename T13, typename T14, typename T15,\n    typename T16, typename T17, typename T18, typename T19, typename T20,\n    typename T21, typename T22, typename T23, typename T24, typename T25,\n    typename T26, typename T27, typename T28, typename T29, typename T30,\n    typename T31, typename T32, typename T33, typename T34, typename T35,\n    typename T36, typename T37, typename T38, typename T39, typename T40,\n    typename T41, typename T42, typename T43, typename T44, typename T45,\n    typename T46, typename T47, typename T48, typename T49, typename T50>\nstruct TypeList<Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13,\n    T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, T28,\n    T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40, T41, T42, T43,\n    T44, T45, T46, T47, T48, T49, T50> > {\n  typedef typename Types<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,\n      T13, T14, T15, T16, T17, T18, T19, T20, T21, T22, T23, T24, T25, T26,\n      T27, T28, T29, T30, T31, T32, T33, T34, T35, T36, T37, T38, T39, T40,\n      T41, T42, T43, T44, T45, T46, T47, T48, T49, T50>::type type;\n};\n\n#endif  // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_\n"
  },
  {
    "path": "ext/gtest/include/gtest/internal/gtest-type-util.h.pump",
    "content": "$$ -*- mode: c++; -*-\n$var n = 50  $$ Maximum length of type lists we want to support.\n// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Type utilities needed for implementing typed and type-parameterized\n// tests.  This file is generated by a SCRIPT.  DO NOT EDIT BY HAND!\n//\n// Currently we support at most $n types in a list, and at most $n\n// type-parameterized tests in one type-parameterized test case.\n// Please contact googletestframework@googlegroups.com if you need\n// more.\n\n#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_\n#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_\n\n#include \"gtest/internal/gtest-port.h\"\n\n// #ifdef __GNUC__ is too general here.  It is possible to use gcc without using\n// libstdc++ (which is where cxxabi.h comes from).\n# if GTEST_HAS_CXXABI_H_\n#  include <cxxabi.h>\n# elif defined(__HP_aCC)\n#  include <acxx_demangle.h>\n# endif  // GTEST_HASH_CXXABI_H_\n\nnamespace testing {\nnamespace internal {\n\n// GetTypeName<T>() returns a human-readable name of type T.\n// NB: This function is also used in Google Mock, so don't move it inside of\n// the typed-test-only section below.\ntemplate <typename T>\nstd::string GetTypeName() {\n# if GTEST_HAS_RTTI\n\n  const char* const name = typeid(T).name();\n#  if GTEST_HAS_CXXABI_H_ || defined(__HP_aCC)\n  int status = 0;\n  // gcc's implementation of typeid(T).name() mangles the type name,\n  // so we have to demangle it.\n#   if GTEST_HAS_CXXABI_H_\n  using abi::__cxa_demangle;\n#   endif  // GTEST_HAS_CXXABI_H_\n  char* const readable_name = __cxa_demangle(name, 0, 0, &status);\n  const std::string name_str(status == 0 ? readable_name : name);\n  free(readable_name);\n  return name_str;\n#  else\n  return name;\n#  endif  // GTEST_HAS_CXXABI_H_ || __HP_aCC\n\n# else\n\n  return \"<type>\";\n\n# endif  // GTEST_HAS_RTTI\n}\n\n#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P\n\n// AssertyTypeEq<T1, T2>::type is defined iff T1 and T2 are the same\n// type.  This can be used as a compile-time assertion to ensure that\n// two types are equal.\n\ntemplate <typename T1, typename T2>\nstruct AssertTypeEq;\n\ntemplate <typename T>\nstruct AssertTypeEq<T, T> {\n  typedef bool type;\n};\n\n// A unique type used as the default value for the arguments of class\n// template Types.  This allows us to simulate variadic templates\n// (e.g. Types<int>, Type<int, double>, and etc), which C++ doesn't\n// support directly.\nstruct None {};\n\n// The following family of struct and struct templates are used to\n// represent type lists.  In particular, TypesN<T1, T2, ..., TN>\n// represents a type list with N types (T1, T2, ..., and TN) in it.\n// Except for Types0, every struct in the family has two member types:\n// Head for the first type in the list, and Tail for the rest of the\n// list.\n\n// The empty type list.\nstruct Types0 {};\n\n// Type lists of length 1, 2, 3, and so on.\n\ntemplate <typename T1>\nstruct Types1 {\n  typedef T1 Head;\n  typedef Types0 Tail;\n};\n\n$range i 2..n\n\n$for i [[\n$range j 1..i\n$range k 2..i\ntemplate <$for j, [[typename T$j]]>\nstruct Types$i {\n  typedef T1 Head;\n  typedef Types$(i-1)<$for k, [[T$k]]> Tail;\n};\n\n\n]]\n\n}  // namespace internal\n\n// We don't want to require the users to write TypesN<...> directly,\n// as that would require them to count the length.  Types<...> is much\n// easier to write, but generates horrible messages when there is a\n// compiler error, as gcc insists on printing out each template\n// argument, even if it has the default value (this means Types<int>\n// will appear as Types<int, None, None, ..., None> in the compiler\n// errors).\n//\n// Our solution is to combine the best part of the two approaches: a\n// user would write Types<T1, ..., TN>, and Google Test will translate\n// that to TypesN<T1, ..., TN> internally to make error messages\n// readable.  The translation is done by the 'type' member of the\n// Types template.\n\n$range i 1..n\ntemplate <$for i, [[typename T$i = internal::None]]>\nstruct Types {\n  typedef internal::Types$n<$for i, [[T$i]]> type;\n};\n\ntemplate <>\nstruct Types<$for i, [[internal::None]]> {\n  typedef internal::Types0 type;\n};\n\n$range i 1..n-1\n$for i [[\n$range j 1..i\n$range k i+1..n\ntemplate <$for j, [[typename T$j]]>\nstruct Types<$for j, [[T$j]]$for k[[, internal::None]]> {\n  typedef internal::Types$i<$for j, [[T$j]]> type;\n};\n\n]]\n\nnamespace internal {\n\n# define GTEST_TEMPLATE_ template <typename T> class\n\n// The template \"selector\" struct TemplateSel<Tmpl> is used to\n// represent Tmpl, which must be a class template with one type\n// parameter, as a type.  TemplateSel<Tmpl>::Bind<T>::type is defined\n// as the type Tmpl<T>.  This allows us to actually instantiate the\n// template \"selected\" by TemplateSel<Tmpl>.\n//\n// This trick is necessary for simulating typedef for class templates,\n// which C++ doesn't support directly.\ntemplate <GTEST_TEMPLATE_ Tmpl>\nstruct TemplateSel {\n  template <typename T>\n  struct Bind {\n    typedef Tmpl<T> type;\n  };\n};\n\n# define GTEST_BIND_(TmplSel, T) \\\n  TmplSel::template Bind<T>::type\n\n// A unique struct template used as the default value for the\n// arguments of class template Templates.  This allows us to simulate\n// variadic templates (e.g. Templates<int>, Templates<int, double>,\n// and etc), which C++ doesn't support directly.\ntemplate <typename T>\nstruct NoneT {};\n\n// The following family of struct and struct templates are used to\n// represent template lists.  In particular, TemplatesN<T1, T2, ...,\n// TN> represents a list of N templates (T1, T2, ..., and TN).  Except\n// for Templates0, every struct in the family has two member types:\n// Head for the selector of the first template in the list, and Tail\n// for the rest of the list.\n\n// The empty template list.\nstruct Templates0 {};\n\n// Template lists of length 1, 2, 3, and so on.\n\ntemplate <GTEST_TEMPLATE_ T1>\nstruct Templates1 {\n  typedef TemplateSel<T1> Head;\n  typedef Templates0 Tail;\n};\n\n$range i 2..n\n\n$for i [[\n$range j 1..i\n$range k 2..i\ntemplate <$for j, [[GTEST_TEMPLATE_ T$j]]>\nstruct Templates$i {\n  typedef TemplateSel<T1> Head;\n  typedef Templates$(i-1)<$for k, [[T$k]]> Tail;\n};\n\n\n]]\n\n// We don't want to require the users to write TemplatesN<...> directly,\n// as that would require them to count the length.  Templates<...> is much\n// easier to write, but generates horrible messages when there is a\n// compiler error, as gcc insists on printing out each template\n// argument, even if it has the default value (this means Templates<list>\n// will appear as Templates<list, NoneT, NoneT, ..., NoneT> in the compiler\n// errors).\n//\n// Our solution is to combine the best part of the two approaches: a\n// user would write Templates<T1, ..., TN>, and Google Test will translate\n// that to TemplatesN<T1, ..., TN> internally to make error messages\n// readable.  The translation is done by the 'type' member of the\n// Templates template.\n\n$range i 1..n\ntemplate <$for i, [[GTEST_TEMPLATE_ T$i = NoneT]]>\nstruct Templates {\n  typedef Templates$n<$for i, [[T$i]]> type;\n};\n\ntemplate <>\nstruct Templates<$for i, [[NoneT]]> {\n  typedef Templates0 type;\n};\n\n$range i 1..n-1\n$for i [[\n$range j 1..i\n$range k i+1..n\ntemplate <$for j, [[GTEST_TEMPLATE_ T$j]]>\nstruct Templates<$for j, [[T$j]]$for k[[, NoneT]]> {\n  typedef Templates$i<$for j, [[T$j]]> type;\n};\n\n]]\n\n// The TypeList template makes it possible to use either a single type\n// or a Types<...> list in TYPED_TEST_CASE() and\n// INSTANTIATE_TYPED_TEST_CASE_P().\n\ntemplate <typename T>\nstruct TypeList {\n  typedef Types1<T> type;\n};\n\n\n$range i 1..n\ntemplate <$for i, [[typename T$i]]>\nstruct TypeList<Types<$for i, [[T$i]]> > {\n  typedef typename Types<$for i, [[T$i]]>::type type;\n};\n\n#endif  // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_\n"
  },
  {
    "path": "ext/gtest/m4/acx_pthread.m4",
    "content": "# This was retrieved from\n#    http://svn.0pointer.de/viewvc/trunk/common/acx_pthread.m4?revision=1277&root=avahi\n# See also (perhaps for new versions?)\n#    http://svn.0pointer.de/viewvc/trunk/common/acx_pthread.m4?root=avahi\n#\n# We've rewritten the inconsistency check code (from avahi), to work\n# more broadly.  In particular, it no longer assumes ld accepts -zdefs.\n# This caused a restructing of the code, but the functionality has only\n# changed a little.\n\ndnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])\ndnl\ndnl @summary figure out how to build C programs using POSIX threads\ndnl\ndnl This macro figures out how to build C programs using POSIX threads.\ndnl It sets the PTHREAD_LIBS output variable to the threads library and\ndnl linker flags, and the PTHREAD_CFLAGS output variable to any special\ndnl C compiler flags that are needed. (The user can also force certain\ndnl compiler flags/libs to be tested by setting these environment\ndnl variables.)\ndnl\ndnl Also sets PTHREAD_CC to any special C compiler that is needed for\ndnl multi-threaded programs (defaults to the value of CC otherwise).\ndnl (This is necessary on AIX to use the special cc_r compiler alias.)\ndnl\ndnl NOTE: You are assumed to not only compile your program with these\ndnl flags, but also link it with them as well. e.g. you should link\ndnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS\ndnl $LIBS\ndnl\ndnl If you are only building threads programs, you may wish to use\ndnl these variables in your default LIBS, CFLAGS, and CC:\ndnl\ndnl        LIBS=\"$PTHREAD_LIBS $LIBS\"\ndnl        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\ndnl        CC=\"$PTHREAD_CC\"\ndnl\ndnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute\ndnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to\ndnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).\ndnl\ndnl ACTION-IF-FOUND is a list of shell commands to run if a threads\ndnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to\ndnl run it if it is not found. If ACTION-IF-FOUND is not specified, the\ndnl default action will define HAVE_PTHREAD.\ndnl\ndnl Please let the authors know if this macro fails on any platform, or\ndnl if you have any other suggestions or comments. This macro was based\ndnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with\ndnl help from M. Frigo), as well as ac_pthread and hb_pthread macros\ndnl posted by Alejandro Forero Cuervo to the autoconf macro repository.\ndnl We are also grateful for the helpful feedback of numerous users.\ndnl\ndnl @category InstalledPackages\ndnl @author Steven G. Johnson <stevenj@alum.mit.edu>\ndnl @version 2006-05-29\ndnl @license GPLWithACException\ndnl \ndnl Checks for GCC shared/pthread inconsistency based on work by\ndnl Marcin Owsiany <marcin@owsiany.pl>\n\n\nAC_DEFUN([ACX_PTHREAD], [\nAC_REQUIRE([AC_CANONICAL_HOST])\nAC_LANG_SAVE\nAC_LANG_C\nacx_pthread_ok=no\n\n# We used to check for pthread.h first, but this fails if pthread.h\n# requires special compiler flags (e.g. on True64 or Sequent).\n# It gets checked for in the link test anyway.\n\n# First of all, check if the user has set any of the PTHREAD_LIBS,\n# etcetera environment variables, and if threads linking works using\n# them:\nif test x\"$PTHREAD_LIBS$PTHREAD_CFLAGS\" != x; then\n        save_CFLAGS=\"$CFLAGS\"\n        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n        save_LIBS=\"$LIBS\"\n        LIBS=\"$PTHREAD_LIBS $LIBS\"\n        AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])\n        AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)\n        AC_MSG_RESULT($acx_pthread_ok)\n        if test x\"$acx_pthread_ok\" = xno; then\n                PTHREAD_LIBS=\"\"\n                PTHREAD_CFLAGS=\"\"\n        fi\n        LIBS=\"$save_LIBS\"\n        CFLAGS=\"$save_CFLAGS\"\nfi\n\n# We must check for the threads library under a number of different\n# names; the ordering is very important because some systems\n# (e.g. DEC) have both -lpthread and -lpthreads, where one of the\n# libraries is broken (non-POSIX).\n\n# Create a list of thread flags to try.  Items starting with a \"-\" are\n# C compiler flags, and other items are library names, except for \"none\"\n# which indicates that we try without any flags at all, and \"pthread-config\"\n# which is a program returning the flags for the Pth emulation library.\n\nacx_pthread_flags=\"pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config\"\n\n# The ordering *is* (sometimes) important.  Some notes on the\n# individual items follow:\n\n# pthreads: AIX (must check this before -lpthread)\n# none: in case threads are in libc; should be tried before -Kthread and\n#       other compiler flags to prevent continual compiler warnings\n# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)\n# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)\n# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)\n# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)\n# -pthreads: Solaris/gcc\n# -mthreads: Mingw32/gcc, Lynx/gcc\n# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it\n#      doesn't hurt to check since this sometimes defines pthreads too;\n#      also defines -D_REENTRANT)\n#      ... -mt is also the pthreads flag for HP/aCC\n# pthread: Linux, etcetera\n# --thread-safe: KAI C++\n# pthread-config: use pthread-config program (for GNU Pth library)\n\ncase \"${host_cpu}-${host_os}\" in\n        *solaris*)\n\n        # On Solaris (at least, for some versions), libc contains stubbed\n        # (non-functional) versions of the pthreads routines, so link-based\n        # tests will erroneously succeed.  (We need to link with -pthreads/-mt/\n        # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather\n        # a function called by this macro, so we could check for that, but\n        # who knows whether they'll stub that too in a future libc.)  So,\n        # we'll just look for -pthreads and -lpthread first:\n\n        acx_pthread_flags=\"-pthreads pthread -mt -pthread $acx_pthread_flags\"\n        ;;\nesac\n\nif test x\"$acx_pthread_ok\" = xno; then\nfor flag in $acx_pthread_flags; do\n\n        case $flag in\n                none)\n                AC_MSG_CHECKING([whether pthreads work without any flags])\n                ;;\n\n                -*)\n                AC_MSG_CHECKING([whether pthreads work with $flag])\n                PTHREAD_CFLAGS=\"$flag\"\n                ;;\n\n\t\tpthread-config)\n\t\tAC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)\n\t\tif test x\"$acx_pthread_config\" = xno; then continue; fi\n\t\tPTHREAD_CFLAGS=\"`pthread-config --cflags`\"\n\t\tPTHREAD_LIBS=\"`pthread-config --ldflags` `pthread-config --libs`\"\n\t\t;;\n\n                *)\n                AC_MSG_CHECKING([for the pthreads library -l$flag])\n                PTHREAD_LIBS=\"-l$flag\"\n                ;;\n        esac\n\n        save_LIBS=\"$LIBS\"\n        save_CFLAGS=\"$CFLAGS\"\n        LIBS=\"$PTHREAD_LIBS $LIBS\"\n        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n\n        # Check for various functions.  We must include pthread.h,\n        # since some functions may be macros.  (On the Sequent, we\n        # need a special flag -Kthread to make this header compile.)\n        # We check for pthread_join because it is in -lpthread on IRIX\n        # while pthread_create is in libc.  We check for pthread_attr_init\n        # due to DEC craziness with -lpthreads.  We check for\n        # pthread_cleanup_push because it is one of the few pthread\n        # functions on Solaris that doesn't have a non-functional libc stub.\n        # We try pthread_create on general principles.\n        AC_TRY_LINK([#include <pthread.h>],\n                    [pthread_t th; pthread_join(th, 0);\n                     pthread_attr_init(0); pthread_cleanup_push(0, 0);\n                     pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],\n                    [acx_pthread_ok=yes])\n\n        LIBS=\"$save_LIBS\"\n        CFLAGS=\"$save_CFLAGS\"\n\n        AC_MSG_RESULT($acx_pthread_ok)\n        if test \"x$acx_pthread_ok\" = xyes; then\n                break;\n        fi\n\n        PTHREAD_LIBS=\"\"\n        PTHREAD_CFLAGS=\"\"\ndone\nfi\n\n# Various other checks:\nif test \"x$acx_pthread_ok\" = xyes; then\n        save_LIBS=\"$LIBS\"\n        LIBS=\"$PTHREAD_LIBS $LIBS\"\n        save_CFLAGS=\"$CFLAGS\"\n        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n\n        # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.\n\tAC_MSG_CHECKING([for joinable pthread attribute])\n\tattr_name=unknown\n\tfor attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do\n\t    AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],\n                        [attr_name=$attr; break])\n\tdone\n        AC_MSG_RESULT($attr_name)\n        if test \"$attr_name\" != PTHREAD_CREATE_JOINABLE; then\n            AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,\n                               [Define to necessary symbol if this constant\n                                uses a non-standard name on your system.])\n        fi\n\n        AC_MSG_CHECKING([if more special flags are required for pthreads])\n        flag=no\n        case \"${host_cpu}-${host_os}\" in\n            *-aix* | *-freebsd* | *-darwin*) flag=\"-D_THREAD_SAFE\";;\n            *solaris* | *-osf* | *-hpux*) flag=\"-D_REENTRANT\";;\n        esac\n        AC_MSG_RESULT(${flag})\n        if test \"x$flag\" != xno; then\n            PTHREAD_CFLAGS=\"$flag $PTHREAD_CFLAGS\"\n        fi\n\n        LIBS=\"$save_LIBS\"\n        CFLAGS=\"$save_CFLAGS\"\n        # More AIX lossage: must compile with xlc_r or cc_r\n\tif test x\"$GCC\" != xyes; then\n          AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})\n        else\n          PTHREAD_CC=$CC\n\tfi\n\n\t# The next part tries to detect GCC inconsistency with -shared on some\n\t# architectures and systems. The problem is that in certain\n\t# configurations, when -shared is specified, GCC \"forgets\" to\n\t# internally use various flags which are still necessary.\n\t\n\t#\n\t# Prepare the flags\n\t#\n\tsave_CFLAGS=\"$CFLAGS\"\n\tsave_LIBS=\"$LIBS\"\n\tsave_CC=\"$CC\"\n\t\n\t# Try with the flags determined by the earlier checks.\n\t#\n\t# -Wl,-z,defs forces link-time symbol resolution, so that the\n\t# linking checks with -shared actually have any value\n\t#\n\t# FIXME: -fPIC is required for -shared on many architectures,\n\t# so we specify it here, but the right way would probably be to\n\t# properly detect whether it is actually required.\n\tCFLAGS=\"-shared -fPIC -Wl,-z,defs $CFLAGS $PTHREAD_CFLAGS\"\n\tLIBS=\"$PTHREAD_LIBS $LIBS\"\n\tCC=\"$PTHREAD_CC\"\n\t\n\t# In order not to create several levels of indentation, we test\n\t# the value of \"$done\" until we find the cure or run out of ideas.\n\tdone=\"no\"\n\t\n\t# First, make sure the CFLAGS we added are actually accepted by our\n\t# compiler.  If not (and OS X's ld, for instance, does not accept -z),\n\t# then we can't do this test.\n\tif test x\"$done\" = xno; then\n\t   AC_MSG_CHECKING([whether to check for GCC pthread/shared inconsistencies])\n\t   AC_TRY_LINK(,, , [done=yes])\n\t\n\t   if test \"x$done\" = xyes ; then\n\t      AC_MSG_RESULT([no])\n\t   else\n\t      AC_MSG_RESULT([yes])\n\t   fi\n\tfi\n\t\n\tif test x\"$done\" = xno; then\n\t   AC_MSG_CHECKING([whether -pthread is sufficient with -shared])\n\t   AC_TRY_LINK([#include <pthread.h>],\n\t      [pthread_t th; pthread_join(th, 0);\n\t      pthread_attr_init(0); pthread_cleanup_push(0, 0);\n\t      pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],\n\t      [done=yes])\n\t   \n\t   if test \"x$done\" = xyes; then\n\t      AC_MSG_RESULT([yes])\n\t   else\n\t      AC_MSG_RESULT([no])\n\t   fi\n\tfi\n\t\n\t#\n\t# Linux gcc on some architectures such as mips/mipsel forgets\n\t# about -lpthread\n\t#\n\tif test x\"$done\" = xno; then\n\t   AC_MSG_CHECKING([whether -lpthread fixes that])\n\t   LIBS=\"-lpthread $PTHREAD_LIBS $save_LIBS\"\n\t   AC_TRY_LINK([#include <pthread.h>],\n\t      [pthread_t th; pthread_join(th, 0);\n\t      pthread_attr_init(0); pthread_cleanup_push(0, 0);\n\t      pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],\n\t      [done=yes])\n\t\n\t   if test \"x$done\" = xyes; then\n\t      AC_MSG_RESULT([yes])\n\t      PTHREAD_LIBS=\"-lpthread $PTHREAD_LIBS\"\n\t   else\n\t      AC_MSG_RESULT([no])\n\t   fi\n\tfi\n\t#\n\t# FreeBSD 4.10 gcc forgets to use -lc_r instead of -lc\n\t#\n\tif test x\"$done\" = xno; then\n\t   AC_MSG_CHECKING([whether -lc_r fixes that])\n\t   LIBS=\"-lc_r $PTHREAD_LIBS $save_LIBS\"\n\t   AC_TRY_LINK([#include <pthread.h>],\n\t       [pthread_t th; pthread_join(th, 0);\n\t        pthread_attr_init(0); pthread_cleanup_push(0, 0);\n\t        pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],\n\t       [done=yes])\n\t\n\t   if test \"x$done\" = xyes; then\n\t      AC_MSG_RESULT([yes])\n\t      PTHREAD_LIBS=\"-lc_r $PTHREAD_LIBS\"\n\t   else\n\t      AC_MSG_RESULT([no])\n\t   fi\n\tfi\n\tif test x\"$done\" = xno; then\n\t   # OK, we have run out of ideas\n\t   AC_MSG_WARN([Impossible to determine how to use pthreads with shared libraries])\n\t\n\t   # so it's not safe to assume that we may use pthreads\n\t   acx_pthread_ok=no\n\tfi\n\t\n\tCFLAGS=\"$save_CFLAGS\"\n\tLIBS=\"$save_LIBS\"\n\tCC=\"$save_CC\"\nelse\n        PTHREAD_CC=\"$CC\"\nfi\n\nAC_SUBST(PTHREAD_LIBS)\nAC_SUBST(PTHREAD_CFLAGS)\nAC_SUBST(PTHREAD_CC)\n\n# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:\nif test x\"$acx_pthread_ok\" = xyes; then\n        ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])\n        :\nelse\n        acx_pthread_ok=no\n        $2\nfi\nAC_LANG_RESTORE\n])dnl ACX_PTHREAD\n"
  },
  {
    "path": "ext/gtest/m4/gtest.m4",
    "content": "dnl GTEST_LIB_CHECK([minimum version [,\ndnl                  action if found [,action if not found]]])\ndnl\ndnl Check for the presence of the Google Test library, optionally at a minimum\ndnl version, and indicate a viable version with the HAVE_GTEST flag. It defines\ndnl standard variables for substitution including GTEST_CPPFLAGS,\ndnl GTEST_CXXFLAGS, GTEST_LDFLAGS, and GTEST_LIBS. It also defines\ndnl GTEST_VERSION as the version of Google Test found. Finally, it provides\ndnl optional custom action slots in the event GTEST is found or not.\nAC_DEFUN([GTEST_LIB_CHECK],\n[\ndnl Provide a flag to enable or disable Google Test usage.\nAC_ARG_ENABLE([gtest],\n  [AS_HELP_STRING([--enable-gtest],\n                  [Enable tests using the Google C++ Testing Framework.\n                  (Default is enabled.)])],\n  [],\n  [enable_gtest=])\nAC_ARG_VAR([GTEST_CONFIG],\n           [The exact path of Google Test's 'gtest-config' script.])\nAC_ARG_VAR([GTEST_CPPFLAGS],\n           [C-like preprocessor flags for Google Test.])\nAC_ARG_VAR([GTEST_CXXFLAGS],\n           [C++ compile flags for Google Test.])\nAC_ARG_VAR([GTEST_LDFLAGS],\n           [Linker path and option flags for Google Test.])\nAC_ARG_VAR([GTEST_LIBS],\n           [Library linking flags for Google Test.])\nAC_ARG_VAR([GTEST_VERSION],\n           [The version of Google Test available.])\nHAVE_GTEST=\"no\"\nAS_IF([test \"x${enable_gtest}\" != \"xno\"],\n  [AC_MSG_CHECKING([for 'gtest-config'])\n   AS_IF([test \"x${enable_gtest}\" != \"xyes\"],\n     [AS_IF([test -x \"${enable_gtest}/scripts/gtest-config\"],\n        [GTEST_CONFIG=\"${enable_gtest}/scripts/gtest-config\"],\n        [GTEST_CONFIG=\"${enable_gtest}/bin/gtest-config\"])\n      AS_IF([test -x \"${GTEST_CONFIG}\"], [],\n        [AC_MSG_RESULT([no])\n         AC_MSG_ERROR([dnl\nUnable to locate either a built or installed Google Test.\nThe specific location '${enable_gtest}' was provided for a built or installed\nGoogle Test, but no 'gtest-config' script could be found at this location.])\n         ])],\n     [AC_PATH_PROG([GTEST_CONFIG], [gtest-config])])\n   AS_IF([test -x \"${GTEST_CONFIG}\"],\n     [AC_MSG_RESULT([${GTEST_CONFIG}])\n      m4_ifval([$1],\n        [_gtest_min_version=\"--min-version=$1\"\n         AC_MSG_CHECKING([for Google Test at least version >= $1])],\n        [_gtest_min_version=\"--min-version=0\"\n         AC_MSG_CHECKING([for Google Test])])\n      AS_IF([${GTEST_CONFIG} ${_gtest_min_version}],\n        [AC_MSG_RESULT([yes])\n         HAVE_GTEST='yes'],\n        [AC_MSG_RESULT([no])])],\n     [AC_MSG_RESULT([no])])\n   AS_IF([test \"x${HAVE_GTEST}\" = \"xyes\"],\n     [GTEST_CPPFLAGS=`${GTEST_CONFIG} --cppflags`\n      GTEST_CXXFLAGS=`${GTEST_CONFIG} --cxxflags`\n      GTEST_LDFLAGS=`${GTEST_CONFIG} --ldflags`\n      GTEST_LIBS=`${GTEST_CONFIG} --libs`\n      GTEST_VERSION=`${GTEST_CONFIG} --version`\n      AC_DEFINE([HAVE_GTEST],[1],[Defined when Google Test is available.])],\n     [AS_IF([test \"x${enable_gtest}\" = \"xyes\"],\n        [AC_MSG_ERROR([dnl\nGoogle Test was enabled, but no viable version could be found.])\n         ])])])\nAC_SUBST([HAVE_GTEST])\nAM_CONDITIONAL([HAVE_GTEST],[test \"x$HAVE_GTEST\" = \"xyes\"])\nAS_IF([test \"x$HAVE_GTEST\" = \"xyes\"],\n  [m4_ifval([$2], [$2])],\n  [m4_ifval([$3], [$3])])\n])\n"
  },
  {
    "path": "ext/gtest/make/Makefile",
    "content": "# A sample Makefile for building Google Test and using it in user\n# tests.  Please tweak it to suit your environment and project.  You\n# may want to move it to your project's root directory.\n#\n# SYNOPSIS:\n#\n#   make [all]  - makes everything.\n#   make TARGET - makes the given target.\n#   make clean  - removes all files generated by make.\n\n# Please tweak the following variable definitions as needed by your\n# project, except GTEST_HEADERS, which you can use in your own targets\n# but shouldn't modify.\n\n# Points to the root of Google Test, relative to where this file is.\n# Remember to tweak this if you move this file.\nGTEST_DIR = ..\n\n# Where to find user code.\nUSER_DIR = ../samples\n\n# Flags passed to the preprocessor.\n# Set Google Test's header directory as a system directory, such that\n# the compiler doesn't generate warnings in Google Test headers.\nCPPFLAGS += -isystem $(GTEST_DIR)/include\n\n# Flags passed to the C++ compiler.\nCXXFLAGS += -g -Wall -Wextra -pthread\n\n# All tests produced by this Makefile.  Remember to add new tests you\n# created to the list.\nTESTS = sample1_unittest\n\n# All Google Test headers.  Usually you shouldn't change this\n# definition.\nGTEST_HEADERS = $(GTEST_DIR)/include/gtest/*.h \\\n                $(GTEST_DIR)/include/gtest/internal/*.h\n\n# House-keeping build targets.\n\nall : $(TESTS)\n\nclean :\n\trm -f $(TESTS) gtest.a gtest_main.a *.o\n\n# Builds gtest.a and gtest_main.a.\n\n# Usually you shouldn't tweak such internal variables, indicated by a\n# trailing _.\nGTEST_SRCS_ = $(GTEST_DIR)/src/*.cc $(GTEST_DIR)/src/*.h $(GTEST_HEADERS)\n\n# For simplicity and to avoid depending on Google Test's\n# implementation details, the dependencies specified below are\n# conservative and not optimized.  This is fine as Google Test\n# compiles fast and for ordinary users its source rarely changes.\ngtest-all.o : $(GTEST_SRCS_)\n\t$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \\\n            $(GTEST_DIR)/src/gtest-all.cc\n\ngtest_main.o : $(GTEST_SRCS_)\n\t$(CXX) $(CPPFLAGS) -I$(GTEST_DIR) $(CXXFLAGS) -c \\\n            $(GTEST_DIR)/src/gtest_main.cc\n\ngtest.a : gtest-all.o\n\t$(AR) $(ARFLAGS) $@ $^\n\ngtest_main.a : gtest-all.o gtest_main.o\n\t$(AR) $(ARFLAGS) $@ $^\n\n# Builds a sample test.  A test should link with either gtest.a or\n# gtest_main.a, depending on whether it defines its own main()\n# function.\n\nsample1.o : $(USER_DIR)/sample1.cc $(USER_DIR)/sample1.h $(GTEST_HEADERS)\n\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/sample1.cc\n\nsample1_unittest.o : $(USER_DIR)/sample1_unittest.cc \\\n                     $(USER_DIR)/sample1.h $(GTEST_HEADERS)\n\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(USER_DIR)/sample1_unittest.cc\n\nsample1_unittest : sample1.o sample1_unittest.o gtest_main.a\n\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -lpthread $^ -o $@\n"
  },
  {
    "path": "ext/gtest/msvc/gtest-md.sln",
    "content": "Microsoft Visual Studio Solution File, Format Version 8.00\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"gtest-md\", \"gtest-md.vcproj\", \"{C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"gtest_main-md\", \"gtest_main-md.vcproj\", \"{3AF54C8A-10BF-4332-9147-F68ED9862033}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"gtest_prod_test-md\", \"gtest_prod_test-md.vcproj\", \"{24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"gtest_unittest-md\", \"gtest_unittest-md.vcproj\", \"{4D9FDFB5-986A-4139-823C-F4EE0ED481A2}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\tEndProjectSection\r\nEndProject\r\nGlobal\r\n\tGlobalSection(SolutionConfiguration) = preSolution\r\n\t\tDebug = Debug\r\n\t\tRelease = Release\r\n\tEndGlobalSection\r\n\tGlobalSection(ProjectConfiguration) = postSolution\r\n\t\t{C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Debug.ActiveCfg = Debug|Win32\r\n\t\t{C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Debug.Build.0 = Debug|Win32\r\n\t\t{C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Release.ActiveCfg = Release|Win32\r\n\t\t{C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}.Release.Build.0 = Release|Win32\r\n\t\t{3AF54C8A-10BF-4332-9147-F68ED9862033}.Debug.ActiveCfg = Debug|Win32\r\n\t\t{3AF54C8A-10BF-4332-9147-F68ED9862033}.Debug.Build.0 = Debug|Win32\r\n\t\t{3AF54C8A-10BF-4332-9147-F68ED9862033}.Release.ActiveCfg = Release|Win32\r\n\t\t{3AF54C8A-10BF-4332-9147-F68ED9862033}.Release.Build.0 = Release|Win32\r\n\t\t{24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Debug.ActiveCfg = Debug|Win32\r\n\t\t{24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Debug.Build.0 = Debug|Win32\r\n\t\t{24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Release.ActiveCfg = Release|Win32\r\n\t\t{24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}.Release.Build.0 = Release|Win32\r\n\t\t{4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Debug.ActiveCfg = Debug|Win32\r\n\t\t{4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Debug.Build.0 = Debug|Win32\r\n\t\t{4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Release.ActiveCfg = Release|Win32\r\n\t\t{4D9FDFB5-986A-4139-823C-F4EE0ED481A2}.Release.Build.0 = Release|Win32\r\n\tEndGlobalSection\r\n\tGlobalSection(ExtensibilityGlobals) = postSolution\r\n\tEndGlobalSection\r\n\tGlobalSection(ExtensibilityAddIns) = postSolution\r\n\tEndGlobalSection\r\nEndGlobal\r\n"
  },
  {
    "path": "ext/gtest/msvc/gtest-md.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"7.10\"\r\n\tName=\"gtest-md\"\r\n\tProjectGUID=\"{C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}\"\r\n\tKeyword=\"Win32Proj\">\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"/>\r\n\t</Platforms>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\tCharacterSet=\"2\"\r\n\t\t\tReferencesPath=\"\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_LIB\"\r\n\t\t\t\tMinimalRebuild=\"TRUE\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"3\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"4\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtestd.lib\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\tCharacterSet=\"2\"\r\n\t\t\tReferencesPath=\"&quot;..\\include&quot;;&quot;..&quot;\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_LIB\"\r\n\t\t\t\tRuntimeLibrary=\"2\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"3\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtest.lib\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\">\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\src\\gtest-all.cc\">\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\">\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "ext/gtest/msvc/gtest.sln",
    "content": "Microsoft Visual Studio Solution File, Format Version 8.00\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"gtest\", \"gtest.vcproj\", \"{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"gtest_main\", \"gtest_main.vcproj\", \"{3AF54C8A-10BF-4332-9147-F68ED9862032}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"gtest_unittest\", \"gtest_unittest.vcproj\", \"{4D9FDFB5-986A-4139-823C-F4EE0ED481A1}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\tEndProjectSection\r\nEndProject\r\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"gtest_prod_test\", \"gtest_prod_test.vcproj\", \"{24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}\"\r\n\tProjectSection(ProjectDependencies) = postProject\r\n\tEndProjectSection\r\nEndProject\r\nGlobal\r\n\tGlobalSection(SolutionConfiguration) = preSolution\r\n\t\tDebug = Debug\r\n\t\tRelease = Release\r\n\tEndGlobalSection\r\n\tGlobalSection(ProjectConfiguration) = postSolution\r\n\t\t{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug.ActiveCfg = Debug|Win32\r\n\t\t{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Debug.Build.0 = Debug|Win32\r\n\t\t{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release.ActiveCfg = Release|Win32\r\n\t\t{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}.Release.Build.0 = Release|Win32\r\n\t\t{3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug.ActiveCfg = Debug|Win32\r\n\t\t{3AF54C8A-10BF-4332-9147-F68ED9862032}.Debug.Build.0 = Debug|Win32\r\n\t\t{3AF54C8A-10BF-4332-9147-F68ED9862032}.Release.ActiveCfg = Release|Win32\r\n\t\t{3AF54C8A-10BF-4332-9147-F68ED9862032}.Release.Build.0 = Release|Win32\r\n\t\t{4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Debug.ActiveCfg = Debug|Win32\r\n\t\t{4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Debug.Build.0 = Debug|Win32\r\n\t\t{4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Release.ActiveCfg = Release|Win32\r\n\t\t{4D9FDFB5-986A-4139-823C-F4EE0ED481A1}.Release.Build.0 = Release|Win32\r\n\t\t{24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Debug.ActiveCfg = Debug|Win32\r\n\t\t{24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Debug.Build.0 = Debug|Win32\r\n\t\t{24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Release.ActiveCfg = Release|Win32\r\n\t\t{24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}.Release.Build.0 = Release|Win32\r\n\tEndGlobalSection\r\n\tGlobalSection(ExtensibilityGlobals) = postSolution\r\n\tEndGlobalSection\r\n\tGlobalSection(ExtensibilityAddIns) = postSolution\r\n\tEndGlobalSection\r\nEndGlobal\r\n"
  },
  {
    "path": "ext/gtest/msvc/gtest.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"7.10\"\r\n\tName=\"gtest\"\r\n\tProjectGUID=\"{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}\"\r\n\tKeyword=\"Win32Proj\">\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"/>\r\n\t</Platforms>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\tCharacterSet=\"2\"\r\n\t\t\tReferencesPath=\"\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_LIB\"\r\n\t\t\t\tMinimalRebuild=\"TRUE\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"5\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"4\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtestd.lib\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\tCharacterSet=\"2\"\r\n\t\t\tReferencesPath=\"&quot;..\\include&quot;;&quot;..&quot;\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_LIB\"\r\n\t\t\t\tRuntimeLibrary=\"4\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"3\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtest.lib\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\">\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\src\\gtest-all.cc\">\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\">\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "ext/gtest/msvc/gtest_main-md.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"7.10\"\r\n\tName=\"gtest_main-md\"\r\n\tProjectGUID=\"{3AF54C8A-10BF-4332-9147-F68ED9862033}\"\r\n\tKeyword=\"Win32Proj\">\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"/>\r\n\t</Platforms>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\tCharacterSet=\"2\"\r\n\t\t\tReferencesPath=\"\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_LIB\"\r\n\t\t\t\tMinimalRebuild=\"TRUE\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"3\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"4\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/$(ProjectName)d.lib\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\tCharacterSet=\"2\"\r\n\t\t\tReferencesPath=\"&quot;..\\include&quot;;&quot;..&quot;\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_LIB\"\r\n\t\t\t\tRuntimeLibrary=\"2\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"3\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/$(ProjectName).lib\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t\t<ProjectReference\r\n\t\t\tReferencedProjectIdentifier=\"{C8F6C172-56F2-4E76-B5FA-C3B423B31BE8}\"\r\n\t\t\tName=\"gtest-md\"/>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\">\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\src\\gtest_main.cc\">\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\">\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "ext/gtest/msvc/gtest_main.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"7.10\"\r\n\tName=\"gtest_main\"\r\n\tProjectGUID=\"{3AF54C8A-10BF-4332-9147-F68ED9862032}\"\r\n\tKeyword=\"Win32Proj\">\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"/>\r\n\t</Platforms>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\tCharacterSet=\"2\"\r\n\t\t\tReferencesPath=\"\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_LIB\"\r\n\t\t\t\tMinimalRebuild=\"TRUE\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"5\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"4\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/$(ProjectName)d.lib\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"4\"\r\n\t\t\tCharacterSet=\"2\"\r\n\t\t\tReferencesPath=\"&quot;..\\include&quot;;&quot;..&quot;\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_LIB\"\r\n\t\t\t\tRuntimeLibrary=\"4\"\r\n\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"3\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLibrarianTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/$(ProjectName).lib\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t\t<ProjectReference\r\n\t\t\tReferencedProjectIdentifier=\"{C8F6C172-56F2-4E76-B5FA-C3B423B31BE7}\"\r\n\t\t\tName=\"gtest\"/>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\">\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\src\\gtest_main.cc\">\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\">\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "ext/gtest/msvc/gtest_prod_test-md.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"7.10\"\r\n\tName=\"gtest_prod_test-md\"\r\n\tProjectGUID=\"{24848551-EF4F-47E8-9A9D-EA4D49BC3ECB}\"\r\n\tKeyword=\"Win32Proj\">\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"/>\r\n\t</Platforms>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\tCharacterSet=\"2\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_CONSOLE\"\r\n\t\t\t\tMinimalRebuild=\"TRUE\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"3\"\r\n\t\t\t\tUsePrecompiledHeader=\"3\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"4\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtest_prod_test.exe\"\r\n\t\t\t\tLinkIncremental=\"2\"\r\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\r\n\t\t\t\tProgramDatabaseFile=\"$(OutDir)/gtest_prod_test.pdb\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tTargetMachine=\"1\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\tCharacterSet=\"2\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_CONSOLE\"\r\n\t\t\t\tRuntimeLibrary=\"2\"\r\n\t\t\t\tUsePrecompiledHeader=\"3\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"3\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtest_prod_test.exe\"\r\n\t\t\t\tLinkIncremental=\"1\"\r\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tOptimizeReferences=\"2\"\r\n\t\t\t\tEnableCOMDATFolding=\"2\"\r\n\t\t\t\tTargetMachine=\"1\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t\t<ProjectReference\r\n\t\t\tReferencedProjectIdentifier=\"{3AF54C8A-10BF-4332-9147-F68ED9862033}\"\r\n\t\t\tName=\"gtest_main-md\"/>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\">\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\test\\gtest_prod_test.cc\">\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\test\\production.cc\">\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\">\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\test\\production.h\">\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "ext/gtest/msvc/gtest_prod_test.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"7.10\"\r\n\tName=\"gtest_prod_test\"\r\n\tProjectGUID=\"{24848551-EF4F-47E8-9A9D-EA4D49BC3ECA}\"\r\n\tKeyword=\"Win32Proj\">\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"/>\r\n\t</Platforms>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\tCharacterSet=\"2\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_CONSOLE\"\r\n\t\t\t\tMinimalRebuild=\"TRUE\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"5\"\r\n\t\t\t\tUsePrecompiledHeader=\"3\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"4\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtest_prod_test.exe\"\r\n\t\t\t\tLinkIncremental=\"2\"\r\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\r\n\t\t\t\tProgramDatabaseFile=\"$(OutDir)/gtest_prod_test.pdb\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tTargetMachine=\"1\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\tCharacterSet=\"2\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_CONSOLE\"\r\n\t\t\t\tRuntimeLibrary=\"4\"\r\n\t\t\t\tUsePrecompiledHeader=\"3\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"3\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtest_prod_test.exe\"\r\n\t\t\t\tLinkIncremental=\"1\"\r\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tOptimizeReferences=\"2\"\r\n\t\t\t\tEnableCOMDATFolding=\"2\"\r\n\t\t\t\tTargetMachine=\"1\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t\t<ProjectReference\r\n\t\t\tReferencedProjectIdentifier=\"{3AF54C8A-10BF-4332-9147-F68ED9862032}\"\r\n\t\t\tName=\"gtest_main\"/>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\">\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\test\\gtest_prod_test.cc\">\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\test\\production.cc\">\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\">\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\test\\production.h\">\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "ext/gtest/msvc/gtest_unittest-md.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"7.10\"\r\n\tName=\"gtest_unittest-md\"\r\n\tProjectGUID=\"{4D9FDFB5-986A-4139-823C-F4EE0ED481A2}\"\r\n\tKeyword=\"Win32Proj\">\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"/>\r\n\t</Platforms>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\tCharacterSet=\"2\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_CONSOLE\"\r\n\t\t\t\tMinimalRebuild=\"TRUE\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"3\"\r\n\t\t\t\tUsePrecompiledHeader=\"3\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"4\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtest_unittest.exe\"\r\n\t\t\t\tLinkIncremental=\"2\"\r\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\r\n\t\t\t\tProgramDatabaseFile=\"$(OutDir)/gtest_unittest.pdb\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tTargetMachine=\"1\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\tCharacterSet=\"2\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_CONSOLE\"\r\n\t\t\t\tRuntimeLibrary=\"2\"\r\n\t\t\t\tUsePrecompiledHeader=\"3\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"3\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtest_unittest.exe\"\r\n\t\t\t\tLinkIncremental=\"1\"\r\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tOptimizeReferences=\"2\"\r\n\t\t\t\tEnableCOMDATFolding=\"2\"\r\n\t\t\t\tTargetMachine=\"1\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t\t<ProjectReference\r\n\t\t\tReferencedProjectIdentifier=\"{3AF54C8A-10BF-4332-9147-F68ED9862033}\"\r\n\t\t\tName=\"gtest_main-md\"/>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\">\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\test\\gtest_unittest.cc\">\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tOptimization=\"1\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tBasicRuntimeChecks=\"0\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\t\t\tDebugInformationFormat=\"3\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\">\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "ext/gtest/msvc/gtest_unittest.vcproj",
    "content": "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\r\n<VisualStudioProject\r\n\tProjectType=\"Visual C++\"\r\n\tVersion=\"7.10\"\r\n\tName=\"gtest_unittest\"\r\n\tProjectGUID=\"{4D9FDFB5-986A-4139-823C-F4EE0ED481A1}\"\r\n\tKeyword=\"Win32Proj\">\r\n\t<Platforms>\r\n\t\t<Platform\r\n\t\t\tName=\"Win32\"/>\r\n\t</Platforms>\r\n\t<Configurations>\r\n\t\t<Configuration\r\n\t\t\tName=\"Debug|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\tCharacterSet=\"2\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tOptimization=\"0\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;_DEBUG;_CONSOLE\"\r\n\t\t\t\tMinimalRebuild=\"TRUE\"\r\n\t\t\t\tBasicRuntimeChecks=\"3\"\r\n\t\t\t\tRuntimeLibrary=\"5\"\r\n\t\t\t\tUsePrecompiledHeader=\"3\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"4\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtest_unittest.exe\"\r\n\t\t\t\tLinkIncremental=\"2\"\r\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\r\n\t\t\t\tProgramDatabaseFile=\"$(OutDir)/gtest_unittest.pdb\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tTargetMachine=\"1\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t\t<Configuration\r\n\t\t\tName=\"Release|Win32\"\r\n\t\t\tOutputDirectory=\"$(SolutionName)/$(ConfigurationName)\"\r\n\t\t\tIntermediateDirectory=\"$(OutDir)/$(ProjectName)\"\r\n\t\t\tConfigurationType=\"1\"\r\n\t\t\tCharacterSet=\"2\">\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\tPreprocessorDefinitions=\"WIN32;NDEBUG;_CONSOLE\"\r\n\t\t\t\tRuntimeLibrary=\"4\"\r\n\t\t\t\tUsePrecompiledHeader=\"3\"\r\n\t\t\t\tWarningLevel=\"3\"\r\n\t\t\t\tDetect64BitPortabilityProblems=\"FALSE\"\r\n\t\t\t\tDebugInformationFormat=\"3\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCCustomBuildTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCLinkerTool\"\r\n\t\t\t\tOutputFile=\"$(OutDir)/gtest_unittest.exe\"\r\n\t\t\t\tLinkIncremental=\"1\"\r\n\t\t\t\tGenerateDebugInformation=\"TRUE\"\r\n\t\t\t\tSubSystem=\"1\"\r\n\t\t\t\tOptimizeReferences=\"2\"\r\n\t\t\t\tEnableCOMDATFolding=\"2\"\r\n\t\t\t\tTargetMachine=\"1\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCMIDLTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPostBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCPreLinkEventTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCResourceCompilerTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebServiceProxyGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCXMLDataGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCWebDeploymentTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCManagedWrapperGeneratorTool\"/>\r\n\t\t\t<Tool\r\n\t\t\t\tName=\"VCAuxiliaryManagedWrapperGeneratorTool\"/>\r\n\t\t</Configuration>\r\n\t</Configurations>\r\n\t<References>\r\n\t\t<ProjectReference\r\n\t\t\tReferencedProjectIdentifier=\"{3AF54C8A-10BF-4332-9147-F68ED9862032}\"\r\n\t\t\tName=\"gtest_main\"/>\r\n\t</References>\r\n\t<Files>\r\n\t\t<Filter\r\n\t\t\tName=\"Source Files\"\r\n\t\t\tFilter=\"cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx\"\r\n\t\t\tUniqueIdentifier=\"{4FC737F1-C7A5-4376-A066-2A32D752A2FF}\">\r\n\t\t\t<File\r\n\t\t\t\tRelativePath=\"..\\test\\gtest_unittest.cc\">\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Debug|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tOptimization=\"1\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tBasicRuntimeChecks=\"0\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"\r\n\t\t\t\t\t\tDebugInformationFormat=\"3\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t\t<FileConfiguration\r\n\t\t\t\t\tName=\"Release|Win32\">\r\n\t\t\t\t\t<Tool\r\n\t\t\t\t\t\tName=\"VCCLCompilerTool\"\r\n\t\t\t\t\t\tAdditionalIncludeDirectories=\"&quot;..&quot;;&quot;..\\include&quot;\"\r\n\t\t\t\t\t\tUsePrecompiledHeader=\"0\"/>\r\n\t\t\t\t</FileConfiguration>\r\n\t\t\t</File>\r\n\t\t</Filter>\r\n\t\t<Filter\r\n\t\t\tName=\"Header Files\"\r\n\t\t\tFilter=\"h;hpp;hxx;hm;inl;inc;xsd\"\r\n\t\t\tUniqueIdentifier=\"{93995380-89BD-4b04-88EB-625FBE52EBFB}\">\r\n\t\t</Filter>\r\n\t</Files>\r\n\t<Globals>\r\n\t</Globals>\r\n</VisualStudioProject>\r\n"
  },
  {
    "path": "ext/gtest/samples/prime_tables.h",
    "content": "// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n// Author: vladl@google.com (Vlad Losev)\n\n// This provides interface PrimeTable that determines whether a number is a\n// prime and determines a next prime number. This interface is used\n// in Google Test samples demonstrating use of parameterized tests.\n\n#ifndef GTEST_SAMPLES_PRIME_TABLES_H_\n#define GTEST_SAMPLES_PRIME_TABLES_H_\n\n#include <algorithm>\n\n// The prime table interface.\nclass PrimeTable {\n public:\n  virtual ~PrimeTable() {}\n\n  // Returns true iff n is a prime number.\n  virtual bool IsPrime(int n) const = 0;\n\n  // Returns the smallest prime number greater than p; or returns -1\n  // if the next prime is beyond the capacity of the table.\n  virtual int GetNextPrime(int p) const = 0;\n};\n\n// Implementation #1 calculates the primes on-the-fly.\nclass OnTheFlyPrimeTable : public PrimeTable {\n public:\n  virtual bool IsPrime(int n) const {\n    if (n <= 1) return false;\n\n    for (int i = 2; i*i <= n; i++) {\n      // n is divisible by an integer other than 1 and itself.\n      if ((n % i) == 0) return false;\n    }\n\n    return true;\n  }\n\n  virtual int GetNextPrime(int p) const {\n    for (int n = p + 1; n > 0; n++) {\n      if (IsPrime(n)) return n;\n    }\n\n    return -1;\n  }\n};\n\n// Implementation #2 pre-calculates the primes and stores the result\n// in an array.\nclass PreCalculatedPrimeTable : public PrimeTable {\n public:\n  // 'max' specifies the maximum number the prime table holds.\n  explicit PreCalculatedPrimeTable(int max)\n      : is_prime_size_(max + 1), is_prime_(new bool[max + 1]) {\n    CalculatePrimesUpTo(max);\n  }\n  virtual ~PreCalculatedPrimeTable() { delete[] is_prime_; }\n\n  virtual bool IsPrime(int n) const {\n    return 0 <= n && n < is_prime_size_ && is_prime_[n];\n  }\n\n  virtual int GetNextPrime(int p) const {\n    for (int n = p + 1; n < is_prime_size_; n++) {\n      if (is_prime_[n]) return n;\n    }\n\n    return -1;\n  }\n\n private:\n  void CalculatePrimesUpTo(int max) {\n    ::std::fill(is_prime_, is_prime_ + is_prime_size_, true);\n    is_prime_[0] = is_prime_[1] = false;\n\n    for (int i = 2; i <= max; i++) {\n      if (!is_prime_[i]) continue;\n\n      // Marks all multiples of i (except i itself) as non-prime.\n      for (int j = 2*i; j <= max; j += i) {\n        is_prime_[j] = false;\n      }\n    }\n  }\n\n  const int is_prime_size_;\n  bool* const is_prime_;\n\n  // Disables compiler warning \"assignment operator could not be generated.\"\n  void operator=(const PreCalculatedPrimeTable& rhs);\n};\n\n#endif  // GTEST_SAMPLES_PRIME_TABLES_H_\n"
  },
  {
    "path": "ext/gtest/samples/sample1.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A sample program demonstrating using Google C++ testing framework.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"sample1.h\"\n\n// Returns n! (the factorial of n).  For negative n, n! is defined to be 1.\nint Factorial(int n) {\n  int result = 1;\n  for (int i = 1; i <= n; i++) {\n    result *= i;\n  }\n\n  return result;\n}\n\n// Returns true iff n is a prime number.\nbool IsPrime(int n) {\n  // Trivial case 1: small numbers\n  if (n <= 1) return false;\n\n  // Trivial case 2: even numbers\n  if (n % 2 == 0) return n == 2;\n\n  // Now, we have that n is odd and n >= 3.\n\n  // Try to divide n by every odd number i, starting from 3\n  for (int i = 3; ; i += 2) {\n    // We only have to try i up to the squre root of n\n    if (i > n/i) break;\n\n    // Now, we have i <= n/i < n.\n    // If n is divisible by i, n is not prime.\n    if (n % i == 0) return false;\n  }\n\n  // n has no integer factor in the range (1, n), and thus is prime.\n  return true;\n}\n"
  },
  {
    "path": "ext/gtest/samples/sample1.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A sample program demonstrating using Google C++ testing framework.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#ifndef GTEST_SAMPLES_SAMPLE1_H_\n#define GTEST_SAMPLES_SAMPLE1_H_\n\n// Returns n! (the factorial of n).  For negative n, n! is defined to be 1.\nint Factorial(int n);\n\n// Returns true iff n is a prime number.\nbool IsPrime(int n);\n\n#endif  // GTEST_SAMPLES_SAMPLE1_H_\n"
  },
  {
    "path": "ext/gtest/samples/sample10_unittest.cc",
    "content": "// Copyright 2009 Google Inc. All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n\n// This sample shows how to use Google Test listener API to implement\n// a primitive leak checker.\n\n#include <stdio.h>\n#include <stdlib.h>\n\n#include \"gtest/gtest.h\"\n\nusing ::testing::EmptyTestEventListener;\nusing ::testing::InitGoogleTest;\nusing ::testing::Test;\nusing ::testing::TestCase;\nusing ::testing::TestEventListeners;\nusing ::testing::TestInfo;\nusing ::testing::TestPartResult;\nusing ::testing::UnitTest;\n\nnamespace {\n\n// We will track memory used by this class.\nclass Water {\n public:\n  // Normal Water declarations go here.\n\n  // operator new and operator delete help us control water allocation.\n  void* operator new(size_t allocation_size) {\n    allocated_++;\n    return malloc(allocation_size);\n  }\n\n  void operator delete(void* block, size_t /* allocation_size */) {\n    allocated_--;\n    free(block);\n  }\n\n  static int allocated() { return allocated_; }\n\n private:\n  static int allocated_;\n};\n\nint Water::allocated_ = 0;\n\n// This event listener monitors how many Water objects are created and\n// destroyed by each test, and reports a failure if a test leaks some Water\n// objects. It does this by comparing the number of live Water objects at\n// the beginning of a test and at the end of a test.\nclass LeakChecker : public EmptyTestEventListener {\n private:\n  // Called before a test starts.\n  virtual void OnTestStart(const TestInfo& /* test_info */) {\n    initially_allocated_ = Water::allocated();\n  }\n\n  // Called after a test ends.\n  virtual void OnTestEnd(const TestInfo& /* test_info */) {\n    int difference = Water::allocated() - initially_allocated_;\n\n    // You can generate a failure in any event handler except\n    // OnTestPartResult. Just use an appropriate Google Test assertion to do\n    // it.\n    EXPECT_LE(difference, 0) << \"Leaked \" << difference << \" unit(s) of Water!\";\n  }\n\n  int initially_allocated_;\n};\n\nTEST(ListenersTest, DoesNotLeak) {\n  Water* water = new Water;\n  delete water;\n}\n\n// This should fail when the --check_for_leaks command line flag is\n// specified.\nTEST(ListenersTest, LeaksWater) {\n  Water* water = new Water;\n  EXPECT_TRUE(water != NULL);\n}\n\n}  // namespace\n\nint main(int argc, char **argv) {\n  InitGoogleTest(&argc, argv);\n\n  bool check_for_leaks = false;\n  if (argc > 1 && strcmp(argv[1], \"--check_for_leaks\") == 0 )\n    check_for_leaks = true;\n  else\n    printf(\"%s\\n\", \"Run this program with --check_for_leaks to enable \"\n           \"custom leak checking in the tests.\");\n\n  // If we are given the --check_for_leaks command line flag, installs the\n  // leak checker.\n  if (check_for_leaks) {\n    TestEventListeners& listeners = UnitTest::GetInstance()->listeners();\n\n    // Adds the leak checker to the end of the test event listener list,\n    // after the default text output printer and the default XML report\n    // generator.\n    //\n    // The order is important - it ensures that failures generated in the\n    // leak checker's OnTestEnd() method are processed by the text and XML\n    // printers *before* their OnTestEnd() methods are called, such that\n    // they are attributed to the right test. Remember that a listener\n    // receives an OnXyzStart event *after* listeners preceding it in the\n    // list received that event, and receives an OnXyzEnd event *before*\n    // listeners preceding it.\n    //\n    // We don't need to worry about deleting the new listener later, as\n    // Google Test will do it.\n    listeners.Append(new LeakChecker);\n  }\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "ext/gtest/samples/sample1_unittest.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A sample program demonstrating using Google C++ testing framework.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n\n// This sample shows how to write a simple unit test for a function,\n// using Google C++ testing framework.\n//\n// Writing a unit test using Google C++ testing framework is easy as 1-2-3:\n\n\n// Step 1. Include necessary header files such that the stuff your\n// test logic needs is declared.\n//\n// Don't forget gtest.h, which declares the testing framework.\n\n#include <limits.h>\n#include \"sample1.h\"\n#include \"gtest/gtest.h\"\n\n\n// Step 2. Use the TEST macro to define your tests.\n//\n// TEST has two parameters: the test case name and the test name.\n// After using the macro, you should define your test logic between a\n// pair of braces.  You can use a bunch of macros to indicate the\n// success or failure of a test.  EXPECT_TRUE and EXPECT_EQ are\n// examples of such macros.  For a complete list, see gtest.h.\n//\n// <TechnicalDetails>\n//\n// In Google Test, tests are grouped into test cases.  This is how we\n// keep test code organized.  You should put logically related tests\n// into the same test case.\n//\n// The test case name and the test name should both be valid C++\n// identifiers.  And you should not use underscore (_) in the names.\n//\n// Google Test guarantees that each test you define is run exactly\n// once, but it makes no guarantee on the order the tests are\n// executed.  Therefore, you should write your tests in such a way\n// that their results don't depend on their order.\n//\n// </TechnicalDetails>\n\n\n// Tests Factorial().\n\n// Tests factorial of negative numbers.\nTEST(FactorialTest, Negative) {\n  // This test is named \"Negative\", and belongs to the \"FactorialTest\"\n  // test case.\n  EXPECT_EQ(1, Factorial(-5));\n  EXPECT_EQ(1, Factorial(-1));\n  EXPECT_GT(Factorial(-10), 0);\n\n  // <TechnicalDetails>\n  //\n  // EXPECT_EQ(expected, actual) is the same as\n  //\n  //   EXPECT_TRUE((expected) == (actual))\n  //\n  // except that it will print both the expected value and the actual\n  // value when the assertion fails.  This is very helpful for\n  // debugging.  Therefore in this case EXPECT_EQ is preferred.\n  //\n  // On the other hand, EXPECT_TRUE accepts any Boolean expression,\n  // and is thus more general.\n  //\n  // </TechnicalDetails>\n}\n\n// Tests factorial of 0.\nTEST(FactorialTest, Zero) {\n  EXPECT_EQ(1, Factorial(0));\n}\n\n// Tests factorial of positive numbers.\nTEST(FactorialTest, Positive) {\n  EXPECT_EQ(1, Factorial(1));\n  EXPECT_EQ(2, Factorial(2));\n  EXPECT_EQ(6, Factorial(3));\n  EXPECT_EQ(40320, Factorial(8));\n}\n\n\n// Tests IsPrime()\n\n// Tests negative input.\nTEST(IsPrimeTest, Negative) {\n  // This test belongs to the IsPrimeTest test case.\n\n  EXPECT_FALSE(IsPrime(-1));\n  EXPECT_FALSE(IsPrime(-2));\n  EXPECT_FALSE(IsPrime(INT_MIN));\n}\n\n// Tests some trivial cases.\nTEST(IsPrimeTest, Trivial) {\n  EXPECT_FALSE(IsPrime(0));\n  EXPECT_FALSE(IsPrime(1));\n  EXPECT_TRUE(IsPrime(2));\n  EXPECT_TRUE(IsPrime(3));\n}\n\n// Tests positive input.\nTEST(IsPrimeTest, Positive) {\n  EXPECT_FALSE(IsPrime(4));\n  EXPECT_TRUE(IsPrime(5));\n  EXPECT_FALSE(IsPrime(6));\n  EXPECT_TRUE(IsPrime(23));\n}\n\n// Step 3. Call RUN_ALL_TESTS() in main().\n//\n// We do this by linking in src/gtest_main.cc file, which consists of\n// a main() function which calls RUN_ALL_TESTS() for us.\n//\n// This runs all the tests you've defined, prints the result, and\n// returns 0 if successful, or 1 otherwise.\n//\n// Did you notice that we didn't register the tests?  The\n// RUN_ALL_TESTS() macro magically knows about all the tests we\n// defined.  Isn't this convenient?\n"
  },
  {
    "path": "ext/gtest/samples/sample2.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A sample program demonstrating using Google C++ testing framework.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"sample2.h\"\n\n#include <string.h>\n\n// Clones a 0-terminated C string, allocating memory using new.\nconst char* MyString::CloneCString(const char* a_c_string) {\n  if (a_c_string == NULL) return NULL;\n\n  const size_t len = strlen(a_c_string);\n  char* const clone = new char[ len + 1 ];\n  memcpy(clone, a_c_string, len + 1);\n\n  return clone;\n}\n\n// Sets the 0-terminated C string this MyString object\n// represents.\nvoid MyString::Set(const char* a_c_string) {\n  // Makes sure this works when c_string == c_string_\n  const char* const temp = MyString::CloneCString(a_c_string);\n  delete[] c_string_;\n  c_string_ = temp;\n}\n"
  },
  {
    "path": "ext/gtest/samples/sample2.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A sample program demonstrating using Google C++ testing framework.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#ifndef GTEST_SAMPLES_SAMPLE2_H_\n#define GTEST_SAMPLES_SAMPLE2_H_\n\n#include <string.h>\n\n\n// A simple string class.\nclass MyString {\n private:\n  const char* c_string_;\n  const MyString& operator=(const MyString& rhs);\n\n public:\n  // Clones a 0-terminated C string, allocating memory using new.\n  static const char* CloneCString(const char* a_c_string);\n\n  ////////////////////////////////////////////////////////////\n  //\n  // C'tors\n\n  // The default c'tor constructs a NULL string.\n  MyString() : c_string_(NULL) {}\n\n  // Constructs a MyString by cloning a 0-terminated C string.\n  explicit MyString(const char* a_c_string) : c_string_(NULL) {\n    Set(a_c_string);\n  }\n\n  // Copy c'tor\n  MyString(const MyString& string) : c_string_(NULL) {\n    Set(string.c_string_);\n  }\n\n  ////////////////////////////////////////////////////////////\n  //\n  // D'tor.  MyString is intended to be a final class, so the d'tor\n  // doesn't need to be virtual.\n  ~MyString() { delete[] c_string_; }\n\n  // Gets the 0-terminated C string this MyString object represents.\n  const char* c_string() const { return c_string_; }\n\n  size_t Length() const {\n    return c_string_ == NULL ? 0 : strlen(c_string_);\n  }\n\n  // Sets the 0-terminated C string this MyString object represents.\n  void Set(const char* c_string);\n};\n\n\n#endif  // GTEST_SAMPLES_SAMPLE2_H_\n"
  },
  {
    "path": "ext/gtest/samples/sample2_unittest.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A sample program demonstrating using Google C++ testing framework.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n\n// This sample shows how to write a more complex unit test for a class\n// that has multiple member functions.\n//\n// Usually, it's a good idea to have one test for each method in your\n// class.  You don't have to do that exactly, but it helps to keep\n// your tests organized.  You may also throw in additional tests as\n// needed.\n\n#include \"sample2.h\"\n#include \"gtest/gtest.h\"\n\n// In this example, we test the MyString class (a simple string).\n\n// Tests the default c'tor.\nTEST(MyString, DefaultConstructor) {\n  const MyString s;\n\n  // Asserts that s.c_string() returns NULL.\n  //\n  // <TechnicalDetails>\n  //\n  // If we write NULL instead of\n  //\n  //   static_cast<const char *>(NULL)\n  //\n  // in this assertion, it will generate a warning on gcc 3.4.  The\n  // reason is that EXPECT_EQ needs to know the types of its\n  // arguments in order to print them when it fails.  Since NULL is\n  // #defined as 0, the compiler will use the formatter function for\n  // int to print it.  However, gcc thinks that NULL should be used as\n  // a pointer, not an int, and therefore complains.\n  //\n  // The root of the problem is C++'s lack of distinction between the\n  // integer number 0 and the null pointer constant.  Unfortunately,\n  // we have to live with this fact.\n  //\n  // </TechnicalDetails>\n  EXPECT_STREQ(NULL, s.c_string());\n\n  EXPECT_EQ(0u, s.Length());\n}\n\nconst char kHelloString[] = \"Hello, world!\";\n\n// Tests the c'tor that accepts a C string.\nTEST(MyString, ConstructorFromCString) {\n  const MyString s(kHelloString);\n  EXPECT_EQ(0, strcmp(s.c_string(), kHelloString));\n  EXPECT_EQ(sizeof(kHelloString)/sizeof(kHelloString[0]) - 1,\n            s.Length());\n}\n\n// Tests the copy c'tor.\nTEST(MyString, CopyConstructor) {\n  const MyString s1(kHelloString);\n  const MyString s2 = s1;\n  EXPECT_EQ(0, strcmp(s2.c_string(), kHelloString));\n}\n\n// Tests the Set method.\nTEST(MyString, Set) {\n  MyString s;\n\n  s.Set(kHelloString);\n  EXPECT_EQ(0, strcmp(s.c_string(), kHelloString));\n\n  // Set should work when the input pointer is the same as the one\n  // already in the MyString object.\n  s.Set(s.c_string());\n  EXPECT_EQ(0, strcmp(s.c_string(), kHelloString));\n\n  // Can we set the MyString to NULL?\n  s.Set(NULL);\n  EXPECT_STREQ(NULL, s.c_string());\n}\n"
  },
  {
    "path": "ext/gtest/samples/sample3-inl.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A sample program demonstrating using Google C++ testing framework.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#ifndef GTEST_SAMPLES_SAMPLE3_INL_H_\n#define GTEST_SAMPLES_SAMPLE3_INL_H_\n\n#include <stddef.h>\n\n\n// Queue is a simple queue implemented as a singled-linked list.\n//\n// The element type must support copy constructor.\ntemplate <typename E>  // E is the element type\nclass Queue;\n\n// QueueNode is a node in a Queue, which consists of an element of\n// type E and a pointer to the next node.\ntemplate <typename E>  // E is the element type\nclass QueueNode {\n  friend class Queue<E>;\n\n public:\n  // Gets the element in this node.\n  const E& element() const { return element_; }\n\n  // Gets the next node in the queue.\n  QueueNode* next() { return next_; }\n  const QueueNode* next() const { return next_; }\n\n private:\n  // Creates a node with a given element value.  The next pointer is\n  // set to NULL.\n  explicit QueueNode(const E& an_element) : element_(an_element), next_(NULL) {}\n\n  // We disable the default assignment operator and copy c'tor.\n  const QueueNode& operator = (const QueueNode&);\n  QueueNode(const QueueNode&);\n\n  E element_;\n  QueueNode* next_;\n};\n\ntemplate <typename E>  // E is the element type.\nclass Queue {\n public:\n  // Creates an empty queue.\n  Queue() : head_(NULL), last_(NULL), size_(0) {}\n\n  // D'tor.  Clears the queue.\n  ~Queue() { Clear(); }\n\n  // Clears the queue.\n  void Clear() {\n    if (size_ > 0) {\n      // 1. Deletes every node.\n      QueueNode<E>* node = head_;\n      QueueNode<E>* next = node->next();\n      for (; ;) {\n        delete node;\n        node = next;\n        if (node == NULL) break;\n        next = node->next();\n      }\n\n      // 2. Resets the member variables.\n      head_ = last_ = NULL;\n      size_ = 0;\n    }\n  }\n\n  // Gets the number of elements.\n  size_t Size() const { return size_; }\n\n  // Gets the first element of the queue, or NULL if the queue is empty.\n  QueueNode<E>* Head() { return head_; }\n  const QueueNode<E>* Head() const { return head_; }\n\n  // Gets the last element of the queue, or NULL if the queue is empty.\n  QueueNode<E>* Last() { return last_; }\n  const QueueNode<E>* Last() const { return last_; }\n\n  // Adds an element to the end of the queue.  A copy of the element is\n  // created using the copy constructor, and then stored in the queue.\n  // Changes made to the element in the queue doesn't affect the source\n  // object, and vice versa.\n  void Enqueue(const E& element) {\n    QueueNode<E>* new_node = new QueueNode<E>(element);\n\n    if (size_ == 0) {\n      head_ = last_ = new_node;\n      size_ = 1;\n    } else {\n      last_->next_ = new_node;\n      last_ = new_node;\n      size_++;\n    }\n  }\n\n  // Removes the head of the queue and returns it.  Returns NULL if\n  // the queue is empty.\n  E* Dequeue() {\n    if (size_ == 0) {\n      return NULL;\n    }\n\n    const QueueNode<E>* const old_head = head_;\n    head_ = head_->next_;\n    size_--;\n    if (size_ == 0) {\n      last_ = NULL;\n    }\n\n    E* element = new E(old_head->element());\n    delete old_head;\n\n    return element;\n  }\n\n  // Applies a function/functor on each element of the queue, and\n  // returns the result in a new queue.  The original queue is not\n  // affected.\n  template <typename F>\n  Queue* Map(F function) const {\n    Queue* new_queue = new Queue();\n    for (const QueueNode<E>* node = head_; node != NULL; node = node->next_) {\n      new_queue->Enqueue(function(node->element()));\n    }\n\n    return new_queue;\n  }\n\n private:\n  QueueNode<E>* head_;  // The first node of the queue.\n  QueueNode<E>* last_;  // The last node of the queue.\n  size_t size_;  // The number of elements in the queue.\n\n  // We disallow copying a queue.\n  Queue(const Queue&);\n  const Queue& operator = (const Queue&);\n};\n\n#endif  // GTEST_SAMPLES_SAMPLE3_INL_H_\n"
  },
  {
    "path": "ext/gtest/samples/sample3_unittest.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A sample program demonstrating using Google C++ testing framework.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n\n// In this example, we use a more advanced feature of Google Test called\n// test fixture.\n//\n// A test fixture is a place to hold objects and functions shared by\n// all tests in a test case.  Using a test fixture avoids duplicating\n// the test code necessary to initialize and cleanup those common\n// objects for each test.  It is also useful for defining sub-routines\n// that your tests need to invoke a lot.\n//\n// <TechnicalDetails>\n//\n// The tests share the test fixture in the sense of code sharing, not\n// data sharing.  Each test is given its own fresh copy of the\n// fixture.  You cannot expect the data modified by one test to be\n// passed on to another test, which is a bad idea.\n//\n// The reason for this design is that tests should be independent and\n// repeatable.  In particular, a test should not fail as the result of\n// another test's failure.  If one test depends on info produced by\n// another test, then the two tests should really be one big test.\n//\n// The macros for indicating the success/failure of a test\n// (EXPECT_TRUE, FAIL, etc) need to know what the current test is\n// (when Google Test prints the test result, it tells you which test\n// each failure belongs to).  Technically, these macros invoke a\n// member function of the Test class.  Therefore, you cannot use them\n// in a global function.  That's why you should put test sub-routines\n// in a test fixture.\n//\n// </TechnicalDetails>\n\n#include \"sample3-inl.h\"\n#include \"gtest/gtest.h\"\n\n// To use a test fixture, derive a class from testing::Test.\nclass QueueTest : public testing::Test {\n protected:  // You should make the members protected s.t. they can be\n             // accessed from sub-classes.\n\n  // virtual void SetUp() will be called before each test is run.  You\n  // should define it if you need to initialize the varaibles.\n  // Otherwise, this can be skipped.\n  virtual void SetUp() {\n    q1_.Enqueue(1);\n    q2_.Enqueue(2);\n    q2_.Enqueue(3);\n  }\n\n  // virtual void TearDown() will be called after each test is run.\n  // You should define it if there is cleanup work to do.  Otherwise,\n  // you don't have to provide it.\n  //\n  // virtual void TearDown() {\n  // }\n\n  // A helper function that some test uses.\n  static int Double(int n) {\n    return 2*n;\n  }\n\n  // A helper function for testing Queue::Map().\n  void MapTester(const Queue<int> * q) {\n    // Creates a new queue, where each element is twice as big as the\n    // corresponding one in q.\n    const Queue<int> * const new_q = q->Map(Double);\n\n    // Verifies that the new queue has the same size as q.\n    ASSERT_EQ(q->Size(), new_q->Size());\n\n    // Verifies the relationship between the elements of the two queues.\n    for ( const QueueNode<int> * n1 = q->Head(), * n2 = new_q->Head();\n          n1 != NULL; n1 = n1->next(), n2 = n2->next() ) {\n      EXPECT_EQ(2 * n1->element(), n2->element());\n    }\n\n    delete new_q;\n  }\n\n  // Declares the variables your tests want to use.\n  Queue<int> q0_;\n  Queue<int> q1_;\n  Queue<int> q2_;\n};\n\n// When you have a test fixture, you define a test using TEST_F\n// instead of TEST.\n\n// Tests the default c'tor.\nTEST_F(QueueTest, DefaultConstructor) {\n  // You can access data in the test fixture here.\n  EXPECT_EQ(0u, q0_.Size());\n}\n\n// Tests Dequeue().\nTEST_F(QueueTest, Dequeue) {\n  int * n = q0_.Dequeue();\n  EXPECT_TRUE(n == NULL);\n\n  n = q1_.Dequeue();\n  ASSERT_TRUE(n != NULL);\n  EXPECT_EQ(1, *n);\n  EXPECT_EQ(0u, q1_.Size());\n  delete n;\n\n  n = q2_.Dequeue();\n  ASSERT_TRUE(n != NULL);\n  EXPECT_EQ(2, *n);\n  EXPECT_EQ(1u, q2_.Size());\n  delete n;\n}\n\n// Tests the Queue::Map() function.\nTEST_F(QueueTest, Map) {\n  MapTester(&q0_);\n  MapTester(&q1_);\n  MapTester(&q2_);\n}\n"
  },
  {
    "path": "ext/gtest/samples/sample4.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A sample program demonstrating using Google C++ testing framework.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include <stdio.h>\n\n#include \"sample4.h\"\n\n// Returns the current counter value, and increments it.\nint Counter::Increment() {\n  return counter_++;\n}\n\n// Prints the current counter value to STDOUT.\nvoid Counter::Print() const {\n  printf(\"%d\", counter_);\n}\n"
  },
  {
    "path": "ext/gtest/samples/sample4.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A sample program demonstrating using Google C++ testing framework.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#ifndef GTEST_SAMPLES_SAMPLE4_H_\n#define GTEST_SAMPLES_SAMPLE4_H_\n\n// A simple monotonic counter.\nclass Counter {\n private:\n  int counter_;\n\n public:\n  // Creates a counter that starts at 0.\n  Counter() : counter_(0) {}\n\n  // Returns the current counter value, and increments it.\n  int Increment();\n\n  // Prints the current counter value to STDOUT.\n  void Print() const;\n};\n\n#endif  // GTEST_SAMPLES_SAMPLE4_H_\n"
  },
  {
    "path": "ext/gtest/samples/sample4_unittest.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"gtest/gtest.h\"\n#include \"sample4.h\"\n\n// Tests the Increment() method.\nTEST(Counter, Increment) {\n  Counter c;\n\n  // EXPECT_EQ() evaluates its arguments exactly once, so they\n  // can have side effects.\n\n  EXPECT_EQ(0, c.Increment());\n  EXPECT_EQ(1, c.Increment());\n  EXPECT_EQ(2, c.Increment());\n}\n"
  },
  {
    "path": "ext/gtest/samples/sample5_unittest.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// This sample teaches how to reuse a test fixture in multiple test\n// cases by deriving sub-fixtures from it.\n//\n// When you define a test fixture, you specify the name of the test\n// case that will use this fixture.  Therefore, a test fixture can\n// be used by only one test case.\n//\n// Sometimes, more than one test cases may want to use the same or\n// slightly different test fixtures.  For example, you may want to\n// make sure that all tests for a GUI library don't leak important\n// system resources like fonts and brushes.  In Google Test, you do\n// this by putting the shared logic in a super (as in \"super class\")\n// test fixture, and then have each test case use a fixture derived\n// from this super fixture.\n\n#include <limits.h>\n#include <time.h>\n#include \"sample3-inl.h\"\n#include \"gtest/gtest.h\"\n#include \"sample1.h\"\n\n// In this sample, we want to ensure that every test finishes within\n// ~5 seconds.  If a test takes longer to run, we consider it a\n// failure.\n//\n// We put the code for timing a test in a test fixture called\n// \"QuickTest\".  QuickTest is intended to be the super fixture that\n// other fixtures derive from, therefore there is no test case with\n// the name \"QuickTest\".  This is OK.\n//\n// Later, we will derive multiple test fixtures from QuickTest.\nclass QuickTest : public testing::Test {\n protected:\n  // Remember that SetUp() is run immediately before a test starts.\n  // This is a good place to record the start time.\n  virtual void SetUp() {\n    start_time_ = time(NULL);\n  }\n\n  // TearDown() is invoked immediately after a test finishes.  Here we\n  // check if the test was too slow.\n  virtual void TearDown() {\n    // Gets the time when the test finishes\n    const time_t end_time = time(NULL);\n\n    // Asserts that the test took no more than ~5 seconds.  Did you\n    // know that you can use assertions in SetUp() and TearDown() as\n    // well?\n    EXPECT_TRUE(end_time - start_time_ <= 5) << \"The test took too long.\";\n  }\n\n  // The UTC time (in seconds) when the test starts\n  time_t start_time_;\n};\n\n\n// We derive a fixture named IntegerFunctionTest from the QuickTest\n// fixture.  All tests using this fixture will be automatically\n// required to be quick.\nclass IntegerFunctionTest : public QuickTest {\n  // We don't need any more logic than already in the QuickTest fixture.\n  // Therefore the body is empty.\n};\n\n\n// Now we can write tests in the IntegerFunctionTest test case.\n\n// Tests Factorial()\nTEST_F(IntegerFunctionTest, Factorial) {\n  // Tests factorial of negative numbers.\n  EXPECT_EQ(1, Factorial(-5));\n  EXPECT_EQ(1, Factorial(-1));\n  EXPECT_GT(Factorial(-10), 0);\n\n  // Tests factorial of 0.\n  EXPECT_EQ(1, Factorial(0));\n\n  // Tests factorial of positive numbers.\n  EXPECT_EQ(1, Factorial(1));\n  EXPECT_EQ(2, Factorial(2));\n  EXPECT_EQ(6, Factorial(3));\n  EXPECT_EQ(40320, Factorial(8));\n}\n\n\n// Tests IsPrime()\nTEST_F(IntegerFunctionTest, IsPrime) {\n  // Tests negative input.\n  EXPECT_FALSE(IsPrime(-1));\n  EXPECT_FALSE(IsPrime(-2));\n  EXPECT_FALSE(IsPrime(INT_MIN));\n\n  // Tests some trivial cases.\n  EXPECT_FALSE(IsPrime(0));\n  EXPECT_FALSE(IsPrime(1));\n  EXPECT_TRUE(IsPrime(2));\n  EXPECT_TRUE(IsPrime(3));\n\n  // Tests positive input.\n  EXPECT_FALSE(IsPrime(4));\n  EXPECT_TRUE(IsPrime(5));\n  EXPECT_FALSE(IsPrime(6));\n  EXPECT_TRUE(IsPrime(23));\n}\n\n\n// The next test case (named \"QueueTest\") also needs to be quick, so\n// we derive another fixture from QuickTest.\n//\n// The QueueTest test fixture has some logic and shared objects in\n// addition to what's in QuickTest already.  We define the additional\n// stuff inside the body of the test fixture, as usual.\nclass QueueTest : public QuickTest {\n protected:\n  virtual void SetUp() {\n    // First, we need to set up the super fixture (QuickTest).\n    QuickTest::SetUp();\n\n    // Second, some additional setup for this fixture.\n    q1_.Enqueue(1);\n    q2_.Enqueue(2);\n    q2_.Enqueue(3);\n  }\n\n  // By default, TearDown() inherits the behavior of\n  // QuickTest::TearDown().  As we have no additional cleaning work\n  // for QueueTest, we omit it here.\n  //\n  // virtual void TearDown() {\n  //   QuickTest::TearDown();\n  // }\n\n  Queue<int> q0_;\n  Queue<int> q1_;\n  Queue<int> q2_;\n};\n\n\n// Now, let's write tests using the QueueTest fixture.\n\n// Tests the default constructor.\nTEST_F(QueueTest, DefaultConstructor) {\n  EXPECT_EQ(0u, q0_.Size());\n}\n\n// Tests Dequeue().\nTEST_F(QueueTest, Dequeue) {\n  int* n = q0_.Dequeue();\n  EXPECT_TRUE(n == NULL);\n\n  n = q1_.Dequeue();\n  EXPECT_TRUE(n != NULL);\n  EXPECT_EQ(1, *n);\n  EXPECT_EQ(0u, q1_.Size());\n  delete n;\n\n  n = q2_.Dequeue();\n  EXPECT_TRUE(n != NULL);\n  EXPECT_EQ(2, *n);\n  EXPECT_EQ(1u, q2_.Size());\n  delete n;\n}\n\n// If necessary, you can derive further test fixtures from a derived\n// fixture itself.  For example, you can derive another fixture from\n// QueueTest.  Google Test imposes no limit on how deep the hierarchy\n// can be.  In practice, however, you probably don't want it to be too\n// deep as to be confusing.\n"
  },
  {
    "path": "ext/gtest/samples/sample6_unittest.cc",
    "content": "// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// This sample shows how to test common properties of multiple\n// implementations of the same interface (aka interface tests).\n\n// The interface and its implementations are in this header.\n#include \"prime_tables.h\"\n\n#include \"gtest/gtest.h\"\n\n// First, we define some factory functions for creating instances of\n// the implementations.  You may be able to skip this step if all your\n// implementations can be constructed the same way.\n\ntemplate <class T>\nPrimeTable* CreatePrimeTable();\n\ntemplate <>\nPrimeTable* CreatePrimeTable<OnTheFlyPrimeTable>() {\n  return new OnTheFlyPrimeTable;\n}\n\ntemplate <>\nPrimeTable* CreatePrimeTable<PreCalculatedPrimeTable>() {\n  return new PreCalculatedPrimeTable(10000);\n}\n\n// Then we define a test fixture class template.\ntemplate <class T>\nclass PrimeTableTest : public testing::Test {\n protected:\n  // The ctor calls the factory function to create a prime table\n  // implemented by T.\n  PrimeTableTest() : table_(CreatePrimeTable<T>()) {}\n\n  virtual ~PrimeTableTest() { delete table_; }\n\n  // Note that we test an implementation via the base interface\n  // instead of the actual implementation class.  This is important\n  // for keeping the tests close to the real world scenario, where the\n  // implementation is invoked via the base interface.  It avoids\n  // got-yas where the implementation class has a method that shadows\n  // a method with the same name (but slightly different argument\n  // types) in the base interface, for example.\n  PrimeTable* const table_;\n};\n\n#if GTEST_HAS_TYPED_TEST\n\nusing testing::Types;\n\n// Google Test offers two ways for reusing tests for different types.\n// The first is called \"typed tests\".  You should use it if you\n// already know *all* the types you are gonna exercise when you write\n// the tests.\n\n// To write a typed test case, first use\n//\n//   TYPED_TEST_CASE(TestCaseName, TypeList);\n//\n// to declare it and specify the type parameters.  As with TEST_F,\n// TestCaseName must match the test fixture name.\n\n// The list of types we want to test.\ntypedef Types<OnTheFlyPrimeTable, PreCalculatedPrimeTable> Implementations;\n\nTYPED_TEST_CASE(PrimeTableTest, Implementations);\n\n// Then use TYPED_TEST(TestCaseName, TestName) to define a typed test,\n// similar to TEST_F.\nTYPED_TEST(PrimeTableTest, ReturnsFalseForNonPrimes) {\n  // Inside the test body, you can refer to the type parameter by\n  // TypeParam, and refer to the fixture class by TestFixture.  We\n  // don't need them in this example.\n\n  // Since we are in the template world, C++ requires explicitly\n  // writing 'this->' when referring to members of the fixture class.\n  // This is something you have to learn to live with.\n  EXPECT_FALSE(this->table_->IsPrime(-5));\n  EXPECT_FALSE(this->table_->IsPrime(0));\n  EXPECT_FALSE(this->table_->IsPrime(1));\n  EXPECT_FALSE(this->table_->IsPrime(4));\n  EXPECT_FALSE(this->table_->IsPrime(6));\n  EXPECT_FALSE(this->table_->IsPrime(100));\n}\n\nTYPED_TEST(PrimeTableTest, ReturnsTrueForPrimes) {\n  EXPECT_TRUE(this->table_->IsPrime(2));\n  EXPECT_TRUE(this->table_->IsPrime(3));\n  EXPECT_TRUE(this->table_->IsPrime(5));\n  EXPECT_TRUE(this->table_->IsPrime(7));\n  EXPECT_TRUE(this->table_->IsPrime(11));\n  EXPECT_TRUE(this->table_->IsPrime(131));\n}\n\nTYPED_TEST(PrimeTableTest, CanGetNextPrime) {\n  EXPECT_EQ(2, this->table_->GetNextPrime(0));\n  EXPECT_EQ(3, this->table_->GetNextPrime(2));\n  EXPECT_EQ(5, this->table_->GetNextPrime(3));\n  EXPECT_EQ(7, this->table_->GetNextPrime(5));\n  EXPECT_EQ(11, this->table_->GetNextPrime(7));\n  EXPECT_EQ(131, this->table_->GetNextPrime(128));\n}\n\n// That's it!  Google Test will repeat each TYPED_TEST for each type\n// in the type list specified in TYPED_TEST_CASE.  Sit back and be\n// happy that you don't have to define them multiple times.\n\n#endif  // GTEST_HAS_TYPED_TEST\n\n#if GTEST_HAS_TYPED_TEST_P\n\nusing testing::Types;\n\n// Sometimes, however, you don't yet know all the types that you want\n// to test when you write the tests.  For example, if you are the\n// author of an interface and expect other people to implement it, you\n// might want to write a set of tests to make sure each implementation\n// conforms to some basic requirements, but you don't know what\n// implementations will be written in the future.\n//\n// How can you write the tests without committing to the type\n// parameters?  That's what \"type-parameterized tests\" can do for you.\n// It is a bit more involved than typed tests, but in return you get a\n// test pattern that can be reused in many contexts, which is a big\n// win.  Here's how you do it:\n\n// First, define a test fixture class template.  Here we just reuse\n// the PrimeTableTest fixture defined earlier:\n\ntemplate <class T>\nclass PrimeTableTest2 : public PrimeTableTest<T> {\n};\n\n// Then, declare the test case.  The argument is the name of the test\n// fixture, and also the name of the test case (as usual).  The _P\n// suffix is for \"parameterized\" or \"pattern\".\nTYPED_TEST_CASE_P(PrimeTableTest2);\n\n// Next, use TYPED_TEST_P(TestCaseName, TestName) to define a test,\n// similar to what you do with TEST_F.\nTYPED_TEST_P(PrimeTableTest2, ReturnsFalseForNonPrimes) {\n  EXPECT_FALSE(this->table_->IsPrime(-5));\n  EXPECT_FALSE(this->table_->IsPrime(0));\n  EXPECT_FALSE(this->table_->IsPrime(1));\n  EXPECT_FALSE(this->table_->IsPrime(4));\n  EXPECT_FALSE(this->table_->IsPrime(6));\n  EXPECT_FALSE(this->table_->IsPrime(100));\n}\n\nTYPED_TEST_P(PrimeTableTest2, ReturnsTrueForPrimes) {\n  EXPECT_TRUE(this->table_->IsPrime(2));\n  EXPECT_TRUE(this->table_->IsPrime(3));\n  EXPECT_TRUE(this->table_->IsPrime(5));\n  EXPECT_TRUE(this->table_->IsPrime(7));\n  EXPECT_TRUE(this->table_->IsPrime(11));\n  EXPECT_TRUE(this->table_->IsPrime(131));\n}\n\nTYPED_TEST_P(PrimeTableTest2, CanGetNextPrime) {\n  EXPECT_EQ(2, this->table_->GetNextPrime(0));\n  EXPECT_EQ(3, this->table_->GetNextPrime(2));\n  EXPECT_EQ(5, this->table_->GetNextPrime(3));\n  EXPECT_EQ(7, this->table_->GetNextPrime(5));\n  EXPECT_EQ(11, this->table_->GetNextPrime(7));\n  EXPECT_EQ(131, this->table_->GetNextPrime(128));\n}\n\n// Type-parameterized tests involve one extra step: you have to\n// enumerate the tests you defined:\nREGISTER_TYPED_TEST_CASE_P(\n    PrimeTableTest2,  // The first argument is the test case name.\n    // The rest of the arguments are the test names.\n    ReturnsFalseForNonPrimes, ReturnsTrueForPrimes, CanGetNextPrime);\n\n// At this point the test pattern is done.  However, you don't have\n// any real test yet as you haven't said which types you want to run\n// the tests with.\n\n// To turn the abstract test pattern into real tests, you instantiate\n// it with a list of types.  Usually the test pattern will be defined\n// in a .h file, and anyone can #include and instantiate it.  You can\n// even instantiate it more than once in the same program.  To tell\n// different instances apart, you give each of them a name, which will\n// become part of the test case name and can be used in test filters.\n\n// The list of types we want to test.  Note that it doesn't have to be\n// defined at the time we write the TYPED_TEST_P()s.\ntypedef Types<OnTheFlyPrimeTable, PreCalculatedPrimeTable>\n    PrimeTableImplementations;\nINSTANTIATE_TYPED_TEST_CASE_P(OnTheFlyAndPreCalculated,    // Instance name\n                              PrimeTableTest2,             // Test case name\n                              PrimeTableImplementations);  // Type list\n\n#endif  // GTEST_HAS_TYPED_TEST_P\n"
  },
  {
    "path": "ext/gtest/samples/sample7_unittest.cc",
    "content": "// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n\n// This sample shows how to test common properties of multiple\n// implementations of an interface (aka interface tests) using\n// value-parameterized tests. Each test in the test case has\n// a parameter that is an interface pointer to an implementation\n// tested.\n\n// The interface and its implementations are in this header.\n#include \"prime_tables.h\"\n\n#include \"gtest/gtest.h\"\n\n#if GTEST_HAS_PARAM_TEST\n\nusing ::testing::TestWithParam;\nusing ::testing::Values;\n\n// As a general rule, to prevent a test from affecting the tests that come\n// after it, you should create and destroy the tested objects for each test\n// instead of reusing them.  In this sample we will define a simple factory\n// function for PrimeTable objects.  We will instantiate objects in test's\n// SetUp() method and delete them in TearDown() method.\ntypedef PrimeTable* CreatePrimeTableFunc();\n\nPrimeTable* CreateOnTheFlyPrimeTable() {\n  return new OnTheFlyPrimeTable();\n}\n\ntemplate <size_t max_precalculated>\nPrimeTable* CreatePreCalculatedPrimeTable() {\n  return new PreCalculatedPrimeTable(max_precalculated);\n}\n\n// Inside the test body, fixture constructor, SetUp(), and TearDown() you\n// can refer to the test parameter by GetParam().  In this case, the test\n// parameter is a factory function which we call in fixture's SetUp() to\n// create and store an instance of PrimeTable.\nclass PrimeTableTest : public TestWithParam<CreatePrimeTableFunc*> {\n public:\n  virtual ~PrimeTableTest() { delete table_; }\n  virtual void SetUp() { table_ = (*GetParam())(); }\n  virtual void TearDown() {\n    delete table_;\n    table_ = NULL;\n  }\n\n protected:\n  PrimeTable* table_;\n};\n\nTEST_P(PrimeTableTest, ReturnsFalseForNonPrimes) {\n  EXPECT_FALSE(table_->IsPrime(-5));\n  EXPECT_FALSE(table_->IsPrime(0));\n  EXPECT_FALSE(table_->IsPrime(1));\n  EXPECT_FALSE(table_->IsPrime(4));\n  EXPECT_FALSE(table_->IsPrime(6));\n  EXPECT_FALSE(table_->IsPrime(100));\n}\n\nTEST_P(PrimeTableTest, ReturnsTrueForPrimes) {\n  EXPECT_TRUE(table_->IsPrime(2));\n  EXPECT_TRUE(table_->IsPrime(3));\n  EXPECT_TRUE(table_->IsPrime(5));\n  EXPECT_TRUE(table_->IsPrime(7));\n  EXPECT_TRUE(table_->IsPrime(11));\n  EXPECT_TRUE(table_->IsPrime(131));\n}\n\nTEST_P(PrimeTableTest, CanGetNextPrime) {\n  EXPECT_EQ(2, table_->GetNextPrime(0));\n  EXPECT_EQ(3, table_->GetNextPrime(2));\n  EXPECT_EQ(5, table_->GetNextPrime(3));\n  EXPECT_EQ(7, table_->GetNextPrime(5));\n  EXPECT_EQ(11, table_->GetNextPrime(7));\n  EXPECT_EQ(131, table_->GetNextPrime(128));\n}\n\n// In order to run value-parameterized tests, you need to instantiate them,\n// or bind them to a list of values which will be used as test parameters.\n// You can instantiate them in a different translation module, or even\n// instantiate them several times.\n//\n// Here, we instantiate our tests with a list of two PrimeTable object\n// factory functions:\nINSTANTIATE_TEST_CASE_P(\n    OnTheFlyAndPreCalculated,\n    PrimeTableTest,\n    Values(&CreateOnTheFlyPrimeTable, &CreatePreCalculatedPrimeTable<1000>));\n\n#else\n\n// Google Test may not support value-parameterized tests with some\n// compilers. If we use conditional compilation to compile out all\n// code referring to the gtest_main library, MSVC linker will not link\n// that library at all and consequently complain about missing entry\n// point defined in that library (fatal error LNK1561: entry point\n// must be defined). This dummy test keeps gtest_main linked in.\nTEST(DummyTest, ValueParameterizedTestsAreNotSupportedOnThisPlatform) {}\n\n#endif  // GTEST_HAS_PARAM_TEST\n"
  },
  {
    "path": "ext/gtest/samples/sample8_unittest.cc",
    "content": "// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n\n// This sample shows how to test code relying on some global flag variables.\n// Combine() helps with generating all possible combinations of such flags,\n// and each test is given one combination as a parameter.\n\n// Use class definitions to test from this header.\n#include \"prime_tables.h\"\n\n#include \"gtest/gtest.h\"\n\n#if GTEST_HAS_COMBINE\n\n// Suppose we want to introduce a new, improved implementation of PrimeTable\n// which combines speed of PrecalcPrimeTable and versatility of\n// OnTheFlyPrimeTable (see prime_tables.h). Inside it instantiates both\n// PrecalcPrimeTable and OnTheFlyPrimeTable and uses the one that is more\n// appropriate under the circumstances. But in low memory conditions, it can be\n// told to instantiate without PrecalcPrimeTable instance at all and use only\n// OnTheFlyPrimeTable.\nclass HybridPrimeTable : public PrimeTable {\n public:\n  HybridPrimeTable(bool force_on_the_fly, int max_precalculated)\n      : on_the_fly_impl_(new OnTheFlyPrimeTable),\n        precalc_impl_(force_on_the_fly ? NULL :\n                          new PreCalculatedPrimeTable(max_precalculated)),\n        max_precalculated_(max_precalculated) {}\n  virtual ~HybridPrimeTable() {\n    delete on_the_fly_impl_;\n    delete precalc_impl_;\n  }\n\n  virtual bool IsPrime(int n) const {\n    if (precalc_impl_ != NULL && n < max_precalculated_)\n      return precalc_impl_->IsPrime(n);\n    else\n      return on_the_fly_impl_->IsPrime(n);\n  }\n\n  virtual int GetNextPrime(int p) const {\n    int next_prime = -1;\n    if (precalc_impl_ != NULL && p < max_precalculated_)\n      next_prime = precalc_impl_->GetNextPrime(p);\n\n    return next_prime != -1 ? next_prime : on_the_fly_impl_->GetNextPrime(p);\n  }\n\n private:\n  OnTheFlyPrimeTable* on_the_fly_impl_;\n  PreCalculatedPrimeTable* precalc_impl_;\n  int max_precalculated_;\n};\n\nusing ::testing::TestWithParam;\nusing ::testing::Bool;\nusing ::testing::Values;\nusing ::testing::Combine;\n\n// To test all code paths for HybridPrimeTable we must test it with numbers\n// both within and outside PreCalculatedPrimeTable's capacity and also with\n// PreCalculatedPrimeTable disabled. We do this by defining fixture which will\n// accept different combinations of parameters for instantiating a\n// HybridPrimeTable instance.\nclass PrimeTableTest : public TestWithParam< ::std::tr1::tuple<bool, int> > {\n protected:\n  virtual void SetUp() {\n    // This can be written as\n    //\n    // bool force_on_the_fly;\n    // int max_precalculated;\n    // tie(force_on_the_fly, max_precalculated) = GetParam();\n    //\n    // once the Google C++ Style Guide allows use of ::std::tr1::tie.\n    //\n    bool force_on_the_fly = ::std::tr1::get<0>(GetParam());\n    int max_precalculated = ::std::tr1::get<1>(GetParam());\n    table_ = new HybridPrimeTable(force_on_the_fly, max_precalculated);\n  }\n  virtual void TearDown() {\n    delete table_;\n    table_ = NULL;\n  }\n  HybridPrimeTable* table_;\n};\n\nTEST_P(PrimeTableTest, ReturnsFalseForNonPrimes) {\n  // Inside the test body, you can refer to the test parameter by GetParam().\n  // In this case, the test parameter is a PrimeTable interface pointer which\n  // we can use directly.\n  // Please note that you can also save it in the fixture's SetUp() method\n  // or constructor and use saved copy in the tests.\n\n  EXPECT_FALSE(table_->IsPrime(-5));\n  EXPECT_FALSE(table_->IsPrime(0));\n  EXPECT_FALSE(table_->IsPrime(1));\n  EXPECT_FALSE(table_->IsPrime(4));\n  EXPECT_FALSE(table_->IsPrime(6));\n  EXPECT_FALSE(table_->IsPrime(100));\n}\n\nTEST_P(PrimeTableTest, ReturnsTrueForPrimes) {\n  EXPECT_TRUE(table_->IsPrime(2));\n  EXPECT_TRUE(table_->IsPrime(3));\n  EXPECT_TRUE(table_->IsPrime(5));\n  EXPECT_TRUE(table_->IsPrime(7));\n  EXPECT_TRUE(table_->IsPrime(11));\n  EXPECT_TRUE(table_->IsPrime(131));\n}\n\nTEST_P(PrimeTableTest, CanGetNextPrime) {\n  EXPECT_EQ(2, table_->GetNextPrime(0));\n  EXPECT_EQ(3, table_->GetNextPrime(2));\n  EXPECT_EQ(5, table_->GetNextPrime(3));\n  EXPECT_EQ(7, table_->GetNextPrime(5));\n  EXPECT_EQ(11, table_->GetNextPrime(7));\n  EXPECT_EQ(131, table_->GetNextPrime(128));\n}\n\n// In order to run value-parameterized tests, you need to instantiate them,\n// or bind them to a list of values which will be used as test parameters.\n// You can instantiate them in a different translation module, or even\n// instantiate them several times.\n//\n// Here, we instantiate our tests with a list of parameters. We must combine\n// all variations of the boolean flag suppressing PrecalcPrimeTable and some\n// meaningful values for tests. We choose a small value (1), and a value that\n// will put some of the tested numbers beyond the capability of the\n// PrecalcPrimeTable instance and some inside it (10). Combine will produce all\n// possible combinations.\nINSTANTIATE_TEST_CASE_P(MeaningfulTestParameters,\n                        PrimeTableTest,\n                        Combine(Bool(), Values(1, 10)));\n\n#else\n\n// Google Test may not support Combine() with some compilers. If we\n// use conditional compilation to compile out all code referring to\n// the gtest_main library, MSVC linker will not link that library at\n// all and consequently complain about missing entry point defined in\n// that library (fatal error LNK1561: entry point must be\n// defined). This dummy test keeps gtest_main linked in.\nTEST(DummyTest, CombineIsNotSupportedOnThisPlatform) {}\n\n#endif  // GTEST_HAS_COMBINE\n"
  },
  {
    "path": "ext/gtest/samples/sample9_unittest.cc",
    "content": "// Copyright 2009 Google Inc. All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n\n// This sample shows how to use Google Test listener API to implement\n// an alternative console output and how to use the UnitTest reflection API\n// to enumerate test cases and tests and to inspect their results.\n\n#include <stdio.h>\n\n#include \"gtest/gtest.h\"\n\nusing ::testing::EmptyTestEventListener;\nusing ::testing::InitGoogleTest;\nusing ::testing::Test;\nusing ::testing::TestCase;\nusing ::testing::TestEventListeners;\nusing ::testing::TestInfo;\nusing ::testing::TestPartResult;\nusing ::testing::UnitTest;\n\nnamespace {\n\n// Provides alternative output mode which produces minimal amount of\n// information about tests.\nclass TersePrinter : public EmptyTestEventListener {\n private:\n  // Called before any test activity starts.\n  virtual void OnTestProgramStart(const UnitTest& /* unit_test */) {}\n\n  // Called after all test activities have ended.\n  virtual void OnTestProgramEnd(const UnitTest& unit_test) {\n    fprintf(stdout, \"TEST %s\\n\", unit_test.Passed() ? \"PASSED\" : \"FAILED\");\n    fflush(stdout);\n  }\n\n  // Called before a test starts.\n  virtual void OnTestStart(const TestInfo& test_info) {\n    fprintf(stdout,\n            \"*** Test %s.%s starting.\\n\",\n            test_info.test_case_name(),\n            test_info.name());\n    fflush(stdout);\n  }\n\n  // Called after a failed assertion or a SUCCEED() invocation.\n  virtual void OnTestPartResult(const TestPartResult& test_part_result) {\n    fprintf(stdout,\n            \"%s in %s:%d\\n%s\\n\",\n            test_part_result.failed() ? \"*** Failure\" : \"Success\",\n            test_part_result.file_name(),\n            test_part_result.line_number(),\n            test_part_result.summary());\n    fflush(stdout);\n  }\n\n  // Called after a test ends.\n  virtual void OnTestEnd(const TestInfo& test_info) {\n    fprintf(stdout,\n            \"*** Test %s.%s ending.\\n\",\n            test_info.test_case_name(),\n            test_info.name());\n    fflush(stdout);\n  }\n};  // class TersePrinter\n\nTEST(CustomOutputTest, PrintsMessage) {\n  printf(\"Printing something from the test body...\\n\");\n}\n\nTEST(CustomOutputTest, Succeeds) {\n  SUCCEED() << \"SUCCEED() has been invoked from here\";\n}\n\nTEST(CustomOutputTest, Fails) {\n  EXPECT_EQ(1, 2)\n      << \"This test fails in order to demonstrate alternative failure messages\";\n}\n\n}  // namespace\n\nint main(int argc, char **argv) {\n  InitGoogleTest(&argc, argv);\n\n  bool terse_output = false;\n  if (argc > 1 && strcmp(argv[1], \"--terse_output\") == 0 )\n    terse_output = true;\n  else\n    printf(\"%s\\n\", \"Run this program with --terse_output to change the way \"\n           \"it prints its output.\");\n\n  UnitTest& unit_test = *UnitTest::GetInstance();\n\n  // If we are given the --terse_output command line flag, suppresses the\n  // standard output and attaches own result printer.\n  if (terse_output) {\n    TestEventListeners& listeners = unit_test.listeners();\n\n    // Removes the default console output listener from the list so it will\n    // not receive events from Google Test and won't print any output. Since\n    // this operation transfers ownership of the listener to the caller we\n    // have to delete it as well.\n    delete listeners.Release(listeners.default_result_printer());\n\n    // Adds the custom output listener to the list. It will now receive\n    // events from Google Test and print the alternative output. We don't\n    // have to worry about deleting it since Google Test assumes ownership\n    // over it after adding it to the list.\n    listeners.Append(new TersePrinter);\n  }\n  int ret_val = RUN_ALL_TESTS();\n\n  // This is an example of using the UnitTest reflection API to inspect test\n  // results. Here we discount failures from the tests we expected to fail.\n  int unexpectedly_failed_tests = 0;\n  for (int i = 0; i < unit_test.total_test_case_count(); ++i) {\n    const TestCase& test_case = *unit_test.GetTestCase(i);\n    for (int j = 0; j < test_case.total_test_count(); ++j) {\n      const TestInfo& test_info = *test_case.GetTestInfo(j);\n      // Counts failed tests that were not meant to fail (those without\n      // 'Fails' in the name).\n      if (test_info.result()->Failed() &&\n          strcmp(test_info.name(), \"Fails\") != 0) {\n        unexpectedly_failed_tests++;\n      }\n    }\n  }\n\n  // Test that were meant to fail should not affect the test program outcome.\n  if (unexpectedly_failed_tests == 0)\n    ret_val = 0;\n\n  return ret_val;\n}\n"
  },
  {
    "path": "ext/gtest/scripts/fuse_gtest_files.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2009, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"fuse_gtest_files.py v0.2.0\nFuses Google Test source code into a .h file and a .cc file.\n\nSYNOPSIS\n       fuse_gtest_files.py [GTEST_ROOT_DIR] OUTPUT_DIR\n\n       Scans GTEST_ROOT_DIR for Google Test source code, and generates\n       two files: OUTPUT_DIR/gtest/gtest.h and OUTPUT_DIR/gtest/gtest-all.cc.\n       Then you can build your tests by adding OUTPUT_DIR to the include\n       search path and linking with OUTPUT_DIR/gtest/gtest-all.cc.  These\n       two files contain everything you need to use Google Test.  Hence\n       you can \"install\" Google Test by copying them to wherever you want.\n\n       GTEST_ROOT_DIR can be omitted and defaults to the parent\n       directory of the directory holding this script.\n\nEXAMPLES\n       ./fuse_gtest_files.py fused_gtest\n       ./fuse_gtest_files.py path/to/unpacked/gtest fused_gtest\n\nThis tool is experimental.  In particular, it assumes that there is no\nconditional inclusion of Google Test headers.  Please report any\nproblems to googletestframework@googlegroups.com.  You can read\nhttp://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide for\nmore information.\n\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport re\nimport sets\nimport sys\n\n# We assume that this file is in the scripts/ directory in the Google\n# Test root directory.\nDEFAULT_GTEST_ROOT_DIR = os.path.join(os.path.dirname(__file__), '..')\n\n# Regex for matching '#include \"gtest/...\"'.\nINCLUDE_GTEST_FILE_REGEX = re.compile(r'^\\s*#\\s*include\\s*\"(gtest/.+)\"')\n\n# Regex for matching '#include \"src/...\"'.\nINCLUDE_SRC_FILE_REGEX = re.compile(r'^\\s*#\\s*include\\s*\"(src/.+)\"')\n\n# Where to find the source seed files.\nGTEST_H_SEED = 'include/gtest/gtest.h'\nGTEST_SPI_H_SEED = 'include/gtest/gtest-spi.h'\nGTEST_ALL_CC_SEED = 'src/gtest-all.cc'\n\n# Where to put the generated files.\nGTEST_H_OUTPUT = 'gtest/gtest.h'\nGTEST_ALL_CC_OUTPUT = 'gtest/gtest-all.cc'\n\n\ndef VerifyFileExists(directory, relative_path):\n  \"\"\"Verifies that the given file exists; aborts on failure.\n\n  relative_path is the file path relative to the given directory.\n  \"\"\"\n\n  if not os.path.isfile(os.path.join(directory, relative_path)):\n    print 'ERROR: Cannot find %s in directory %s.' % (relative_path,\n                                                      directory)\n    print ('Please either specify a valid project root directory '\n           'or omit it on the command line.')\n    sys.exit(1)\n\n\ndef ValidateGTestRootDir(gtest_root):\n  \"\"\"Makes sure gtest_root points to a valid gtest root directory.\n\n  The function aborts the program on failure.\n  \"\"\"\n\n  VerifyFileExists(gtest_root, GTEST_H_SEED)\n  VerifyFileExists(gtest_root, GTEST_ALL_CC_SEED)\n\n\ndef VerifyOutputFile(output_dir, relative_path):\n  \"\"\"Verifies that the given output file path is valid.\n\n  relative_path is relative to the output_dir directory.\n  \"\"\"\n\n  # Makes sure the output file either doesn't exist or can be overwritten.\n  output_file = os.path.join(output_dir, relative_path)\n  if os.path.exists(output_file):\n    # TODO(wan@google.com): The following user-interaction doesn't\n    # work with automated processes.  We should provide a way for the\n    # Makefile to force overwriting the files.\n    print ('%s already exists in directory %s - overwrite it? (y/N) ' %\n           (relative_path, output_dir))\n    answer = sys.stdin.readline().strip()\n    if answer not in ['y', 'Y']:\n      print 'ABORTED.'\n      sys.exit(1)\n\n  # Makes sure the directory holding the output file exists; creates\n  # it and all its ancestors if necessary.\n  parent_directory = os.path.dirname(output_file)\n  if not os.path.isdir(parent_directory):\n    os.makedirs(parent_directory)\n\n\ndef ValidateOutputDir(output_dir):\n  \"\"\"Makes sure output_dir points to a valid output directory.\n\n  The function aborts the program on failure.\n  \"\"\"\n\n  VerifyOutputFile(output_dir, GTEST_H_OUTPUT)\n  VerifyOutputFile(output_dir, GTEST_ALL_CC_OUTPUT)\n\n\ndef FuseGTestH(gtest_root, output_dir):\n  \"\"\"Scans folder gtest_root to generate gtest/gtest.h in output_dir.\"\"\"\n\n  output_file = file(os.path.join(output_dir, GTEST_H_OUTPUT), 'w')\n  processed_files = sets.Set()  # Holds all gtest headers we've processed.\n\n  def ProcessFile(gtest_header_path):\n    \"\"\"Processes the given gtest header file.\"\"\"\n\n    # We don't process the same header twice.\n    if gtest_header_path in processed_files:\n      return\n\n    processed_files.add(gtest_header_path)\n\n    # Reads each line in the given gtest header.\n    for line in file(os.path.join(gtest_root, gtest_header_path), 'r'):\n      m = INCLUDE_GTEST_FILE_REGEX.match(line)\n      if m:\n        # It's '#include \"gtest/...\"' - let's process it recursively.\n        ProcessFile('include/' + m.group(1))\n      else:\n        # Otherwise we copy the line unchanged to the output file.\n        output_file.write(line)\n\n  ProcessFile(GTEST_H_SEED)\n  output_file.close()\n\n\ndef FuseGTestAllCcToFile(gtest_root, output_file):\n  \"\"\"Scans folder gtest_root to generate gtest/gtest-all.cc in output_file.\"\"\"\n\n  processed_files = sets.Set()\n\n  def ProcessFile(gtest_source_file):\n    \"\"\"Processes the given gtest source file.\"\"\"\n\n    # We don't process the same #included file twice.\n    if gtest_source_file in processed_files:\n      return\n\n    processed_files.add(gtest_source_file)\n\n    # Reads each line in the given gtest source file.\n    for line in file(os.path.join(gtest_root, gtest_source_file), 'r'):\n      m = INCLUDE_GTEST_FILE_REGEX.match(line)\n      if m:\n        if 'include/' + m.group(1) == GTEST_SPI_H_SEED:\n          # It's '#include \"gtest/gtest-spi.h\"'.  This file is not\n          # #included by \"gtest/gtest.h\", so we need to process it.\n          ProcessFile(GTEST_SPI_H_SEED)\n        else:\n          # It's '#include \"gtest/foo.h\"' where foo is not gtest-spi.\n          # We treat it as '#include \"gtest/gtest.h\"', as all other\n          # gtest headers are being fused into gtest.h and cannot be\n          # #included directly.\n\n          # There is no need to #include \"gtest/gtest.h\" more than once.\n          if not GTEST_H_SEED in processed_files:\n            processed_files.add(GTEST_H_SEED)\n            output_file.write('#include \"%s\"\\n' % (GTEST_H_OUTPUT,))\n      else:\n        m = INCLUDE_SRC_FILE_REGEX.match(line)\n        if m:\n          # It's '#include \"src/foo\"' - let's process it recursively.\n          ProcessFile(m.group(1))\n        else:\n          output_file.write(line)\n\n  ProcessFile(GTEST_ALL_CC_SEED)\n\n\ndef FuseGTestAllCc(gtest_root, output_dir):\n  \"\"\"Scans folder gtest_root to generate gtest/gtest-all.cc in output_dir.\"\"\"\n\n  output_file = file(os.path.join(output_dir, GTEST_ALL_CC_OUTPUT), 'w')\n  FuseGTestAllCcToFile(gtest_root, output_file)\n  output_file.close()\n\n\ndef FuseGTest(gtest_root, output_dir):\n  \"\"\"Fuses gtest.h and gtest-all.cc.\"\"\"\n\n  ValidateGTestRootDir(gtest_root)\n  ValidateOutputDir(output_dir)\n\n  FuseGTestH(gtest_root, output_dir)\n  FuseGTestAllCc(gtest_root, output_dir)\n\n\ndef main():\n  argc = len(sys.argv)\n  if argc == 2:\n    # fuse_gtest_files.py OUTPUT_DIR\n    FuseGTest(DEFAULT_GTEST_ROOT_DIR, sys.argv[1])\n  elif argc == 3:\n    # fuse_gtest_files.py GTEST_ROOT_DIR OUTPUT_DIR\n    FuseGTest(sys.argv[1], sys.argv[2])\n  else:\n    print __doc__\n    sys.exit(1)\n\n\nif __name__ == '__main__':\n  main()\n"
  },
  {
    "path": "ext/gtest/scripts/gen_gtest_pred_impl.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2006, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"gen_gtest_pred_impl.py v0.1\n\nGenerates the implementation of Google Test predicate assertions and\naccompanying tests.\n\nUsage:\n\n  gen_gtest_pred_impl.py MAX_ARITY\n\nwhere MAX_ARITY is a positive integer.\n\nThe command generates the implementation of up-to MAX_ARITY-ary\npredicate assertions, and writes it to file gtest_pred_impl.h in the\ndirectory where the script is.  It also generates the accompanying\nunit test in file gtest_pred_impl_unittest.cc.\n\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport sys\nimport time\n\n# Where this script is.\nSCRIPT_DIR = os.path.dirname(sys.argv[0])\n\n# Where to store the generated header.\nHEADER = os.path.join(SCRIPT_DIR, '../include/gtest/gtest_pred_impl.h')\n\n# Where to store the generated unit test.\nUNIT_TEST = os.path.join(SCRIPT_DIR, '../test/gtest_pred_impl_unittest.cc')\n\n\ndef HeaderPreamble(n):\n  \"\"\"Returns the preamble for the header file.\n\n  Args:\n    n:  the maximum arity of the predicate macros to be generated.\n  \"\"\"\n\n  # A map that defines the values used in the preamble template.\n  DEFS = {\n    'today' : time.strftime('%m/%d/%Y'),\n    'year' : time.strftime('%Y'),\n    'command' : '%s %s' % (os.path.basename(sys.argv[0]), n),\n    'n' : n\n    }\n\n  return (\n\"\"\"// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file is AUTOMATICALLY GENERATED on %(today)s by command\n// '%(command)s'.  DO NOT EDIT BY HAND!\n//\n// Implements a family of generic predicate assertion macros.\n\n#ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_\n#define GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_\n\n// Makes sure this header is not included before gtest.h.\n#ifndef GTEST_INCLUDE_GTEST_GTEST_H_\n# error Do not include gtest_pred_impl.h directly.  Include gtest.h instead.\n#endif  // GTEST_INCLUDE_GTEST_GTEST_H_\n\n// This header implements a family of generic predicate assertion\n// macros:\n//\n//   ASSERT_PRED_FORMAT1(pred_format, v1)\n//   ASSERT_PRED_FORMAT2(pred_format, v1, v2)\n//   ...\n//\n// where pred_format is a function or functor that takes n (in the\n// case of ASSERT_PRED_FORMATn) values and their source expression\n// text, and returns a testing::AssertionResult.  See the definition\n// of ASSERT_EQ in gtest.h for an example.\n//\n// If you don't care about formatting, you can use the more\n// restrictive version:\n//\n//   ASSERT_PRED1(pred, v1)\n//   ASSERT_PRED2(pred, v1, v2)\n//   ...\n//\n// where pred is an n-ary function or functor that returns bool,\n// and the values v1, v2, ..., must support the << operator for\n// streaming to std::ostream.\n//\n// We also define the EXPECT_* variations.\n//\n// For now we only support predicates whose arity is at most %(n)s.\n// Please email googletestframework@googlegroups.com if you need\n// support for higher arities.\n\n// GTEST_ASSERT_ is the basic statement to which all of the assertions\n// in this file reduce.  Don't use this in your code.\n\n#define GTEST_ASSERT_(expression, on_failure) \\\\\n  GTEST_AMBIGUOUS_ELSE_BLOCKER_ \\\\\n  if (const ::testing::AssertionResult gtest_ar = (expression)) \\\\\n    ; \\\\\n  else \\\\\n    on_failure(gtest_ar.failure_message())\n\"\"\" % DEFS)\n\n\ndef Arity(n):\n  \"\"\"Returns the English name of the given arity.\"\"\"\n\n  if n < 0:\n    return None\n  elif n <= 3:\n    return ['nullary', 'unary', 'binary', 'ternary'][n]\n  else:\n    return '%s-ary' % n\n\n\ndef Title(word):\n  \"\"\"Returns the given word in title case.  The difference between\n  this and string's title() method is that Title('4-ary') is '4-ary'\n  while '4-ary'.title() is '4-Ary'.\"\"\"\n\n  return word[0].upper() + word[1:]\n\n\ndef OneTo(n):\n  \"\"\"Returns the list [1, 2, 3, ..., n].\"\"\"\n\n  return range(1, n + 1)\n\n\ndef Iter(n, format, sep=''):\n  \"\"\"Given a positive integer n, a format string that contains 0 or\n  more '%s' format specs, and optionally a separator string, returns\n  the join of n strings, each formatted with the format string on an\n  iterator ranged from 1 to n.\n\n  Example:\n\n  Iter(3, 'v%s', sep=', ') returns 'v1, v2, v3'.\n  \"\"\"\n\n  # How many '%s' specs are in format?\n  spec_count = len(format.split('%s')) - 1\n  return sep.join([format % (spec_count * (i,)) for i in OneTo(n)])\n\n\ndef ImplementationForArity(n):\n  \"\"\"Returns the implementation of n-ary predicate assertions.\"\"\"\n\n  # A map the defines the values used in the implementation template.\n  DEFS = {\n    'n' : str(n),\n    'vs' : Iter(n, 'v%s', sep=', '),\n    'vts' : Iter(n, '#v%s', sep=', '),\n    'arity' : Arity(n),\n    'Arity' : Title(Arity(n))\n    }\n\n  impl = \"\"\"\n\n// Helper function for implementing {EXPECT|ASSERT}_PRED%(n)s.  Don't use\n// this in your code.\ntemplate <typename Pred\"\"\" % DEFS\n\n  impl += Iter(n, \"\"\",\n          typename T%s\"\"\")\n\n  impl += \"\"\">\nAssertionResult AssertPred%(n)sHelper(const char* pred_text\"\"\" % DEFS\n\n  impl += Iter(n, \"\"\",\n                                  const char* e%s\"\"\")\n\n  impl += \"\"\",\n                                  Pred pred\"\"\"\n\n  impl += Iter(n, \"\"\",\n                                  const T%s& v%s\"\"\")\n\n  impl += \"\"\") {\n  if (pred(%(vs)s)) return AssertionSuccess();\n\n\"\"\" % DEFS\n\n  impl += '  return AssertionFailure() << pred_text << \"(\"'\n\n  impl += Iter(n, \"\"\"\n                            << e%s\"\"\", sep=' << \", \"')\n\n  impl += ' << \") evaluates to false, where\"'\n\n  impl += Iter(n, \"\"\"\n                            << \"\\\\n\" << e%s << \" evaluates to \" << v%s\"\"\")\n\n  impl += \"\"\";\n}\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT%(n)s.\n// Don't use this in your code.\n#define GTEST_PRED_FORMAT%(n)s_(pred_format, %(vs)s, on_failure)\\\\\n  GTEST_ASSERT_(pred_format(%(vts)s, %(vs)s), \\\\\n                on_failure)\n\n// Internal macro for implementing {EXPECT|ASSERT}_PRED%(n)s.  Don't use\n// this in your code.\n#define GTEST_PRED%(n)s_(pred, %(vs)s, on_failure)\\\\\n  GTEST_ASSERT_(::testing::AssertPred%(n)sHelper(#pred\"\"\" % DEFS\n\n  impl += Iter(n, \"\"\", \\\\\n                                             #v%s\"\"\")\n\n  impl += \"\"\", \\\\\n                                             pred\"\"\"\n\n  impl += Iter(n, \"\"\", \\\\\n                                             v%s\"\"\")\n\n  impl += \"\"\"), on_failure)\n\n// %(Arity)s predicate assertion macros.\n#define EXPECT_PRED_FORMAT%(n)s(pred_format, %(vs)s) \\\\\n  GTEST_PRED_FORMAT%(n)s_(pred_format, %(vs)s, GTEST_NONFATAL_FAILURE_)\n#define EXPECT_PRED%(n)s(pred, %(vs)s) \\\\\n  GTEST_PRED%(n)s_(pred, %(vs)s, GTEST_NONFATAL_FAILURE_)\n#define ASSERT_PRED_FORMAT%(n)s(pred_format, %(vs)s) \\\\\n  GTEST_PRED_FORMAT%(n)s_(pred_format, %(vs)s, GTEST_FATAL_FAILURE_)\n#define ASSERT_PRED%(n)s(pred, %(vs)s) \\\\\n  GTEST_PRED%(n)s_(pred, %(vs)s, GTEST_FATAL_FAILURE_)\n\n\"\"\" % DEFS\n\n  return impl\n\n\ndef HeaderPostamble():\n  \"\"\"Returns the postamble for the header file.\"\"\"\n\n  return \"\"\"\n\n#endif  // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_\n\"\"\"\n\n\ndef GenerateFile(path, content):\n  \"\"\"Given a file path and a content string, overwrites it with the\n  given content.\"\"\"\n\n  print 'Updating file %s . . .' % path\n\n  f = file(path, 'w+')\n  print >>f, content,\n  f.close()\n\n  print 'File %s has been updated.' % path\n\n\ndef GenerateHeader(n):\n  \"\"\"Given the maximum arity n, updates the header file that implements\n  the predicate assertions.\"\"\"\n\n  GenerateFile(HEADER,\n               HeaderPreamble(n)\n               + ''.join([ImplementationForArity(i) for i in OneTo(n)])\n               + HeaderPostamble())\n\n\ndef UnitTestPreamble():\n  \"\"\"Returns the preamble for the unit test file.\"\"\"\n\n  # A map that defines the values used in the preamble template.\n  DEFS = {\n    'today' : time.strftime('%m/%d/%Y'),\n    'year' : time.strftime('%Y'),\n    'command' : '%s %s' % (os.path.basename(sys.argv[0]), sys.argv[1]),\n    }\n\n  return (\n\"\"\"// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file is AUTOMATICALLY GENERATED on %(today)s by command\n// '%(command)s'.  DO NOT EDIT BY HAND!\n\n// Regression test for gtest_pred_impl.h\n//\n// This file is generated by a script and quite long.  If you intend to\n// learn how Google Test works by reading its unit tests, read\n// gtest_unittest.cc instead.\n//\n// This is intended as a regression test for the Google Test predicate\n// assertions.  We compile it as part of the gtest_unittest target\n// only to keep the implementation tidy and compact, as it is quite\n// involved to set up the stage for testing Google Test using Google\n// Test itself.\n//\n// Currently, gtest_unittest takes ~11 seconds to run in the testing\n// daemon.  In the future, if it grows too large and needs much more\n// time to finish, we should consider separating this file into a\n// stand-alone regression test.\n\n#include <iostream>\n\n#include \"gtest/gtest.h\"\n#include \"gtest/gtest-spi.h\"\n\n// A user-defined data type.\nstruct Bool {\n  explicit Bool(int val) : value(val != 0) {}\n\n  bool operator>(int n) const { return value > Bool(n).value; }\n\n  Bool operator+(const Bool& rhs) const { return Bool(value + rhs.value); }\n\n  bool operator==(const Bool& rhs) const { return value == rhs.value; }\n\n  bool value;\n};\n\n// Enables Bool to be used in assertions.\nstd::ostream& operator<<(std::ostream& os, const Bool& x) {\n  return os << (x.value ? \"true\" : \"false\");\n}\n\n\"\"\" % DEFS)\n\n\ndef TestsForArity(n):\n  \"\"\"Returns the tests for n-ary predicate assertions.\"\"\"\n\n  # A map that defines the values used in the template for the tests.\n  DEFS = {\n    'n' : n,\n    'es' : Iter(n, 'e%s', sep=', '),\n    'vs' : Iter(n, 'v%s', sep=', '),\n    'vts' : Iter(n, '#v%s', sep=', '),\n    'tvs' : Iter(n, 'T%s v%s', sep=', '),\n    'int_vs' : Iter(n, 'int v%s', sep=', '),\n    'Bool_vs' : Iter(n, 'Bool v%s', sep=', '),\n    'types' : Iter(n, 'typename T%s', sep=', '),\n    'v_sum' : Iter(n, 'v%s', sep=' + '),\n    'arity' : Arity(n),\n    'Arity' : Title(Arity(n)),\n    }\n\n  tests = (\n\"\"\"// Sample functions/functors for testing %(arity)s predicate assertions.\n\n// A %(arity)s predicate function.\ntemplate <%(types)s>\nbool PredFunction%(n)s(%(tvs)s) {\n  return %(v_sum)s > 0;\n}\n\n// The following two functions are needed to circumvent a bug in\n// gcc 2.95.3, which sometimes has problem with the above template\n// function.\nbool PredFunction%(n)sInt(%(int_vs)s) {\n  return %(v_sum)s > 0;\n}\nbool PredFunction%(n)sBool(%(Bool_vs)s) {\n  return %(v_sum)s > 0;\n}\n\"\"\" % DEFS)\n\n  tests += \"\"\"\n// A %(arity)s predicate functor.\nstruct PredFunctor%(n)s {\n  template <%(types)s>\n  bool operator()(\"\"\" % DEFS\n\n  tests += Iter(n, 'const T%s& v%s', sep=\"\"\",\n                  \"\"\")\n\n  tests += \"\"\") {\n    return %(v_sum)s > 0;\n  }\n};\n\"\"\" % DEFS\n\n  tests += \"\"\"\n// A %(arity)s predicate-formatter function.\ntemplate <%(types)s>\ntesting::AssertionResult PredFormatFunction%(n)s(\"\"\" % DEFS\n\n  tests += Iter(n, 'const char* e%s', sep=\"\"\",\n                                             \"\"\")\n\n  tests += Iter(n, \"\"\",\n                                             const T%s& v%s\"\"\")\n\n  tests += \"\"\") {\n  if (PredFunction%(n)s(%(vs)s))\n    return testing::AssertionSuccess();\n\n  return testing::AssertionFailure()\n      << \"\"\" % DEFS\n\n  tests += Iter(n, 'e%s', sep=' << \" + \" << ')\n\n  tests += \"\"\"\n      << \" is expected to be positive, but evaluates to \"\n      << %(v_sum)s << \".\";\n}\n\"\"\" % DEFS\n\n  tests += \"\"\"\n// A %(arity)s predicate-formatter functor.\nstruct PredFormatFunctor%(n)s {\n  template <%(types)s>\n  testing::AssertionResult operator()(\"\"\" % DEFS\n\n  tests += Iter(n, 'const char* e%s', sep=\"\"\",\n                                      \"\"\")\n\n  tests += Iter(n, \"\"\",\n                                      const T%s& v%s\"\"\")\n\n  tests += \"\"\") const {\n    return PredFormatFunction%(n)s(%(es)s, %(vs)s);\n  }\n};\n\"\"\" % DEFS\n\n  tests += \"\"\"\n// Tests for {EXPECT|ASSERT}_PRED_FORMAT%(n)s.\n\nclass Predicate%(n)sTest : public testing::Test {\n protected:\n  virtual void SetUp() {\n    expected_to_finish_ = true;\n    finished_ = false;\"\"\" % DEFS\n\n  tests += \"\"\"\n    \"\"\" + Iter(n, 'n%s_ = ') + \"\"\"0;\n  }\n\"\"\"\n\n  tests += \"\"\"\n  virtual void TearDown() {\n    // Verifies that each of the predicate's arguments was evaluated\n    // exactly once.\"\"\"\n\n  tests += ''.join([\"\"\"\n    EXPECT_EQ(1, n%s_) <<\n        \"The predicate assertion didn't evaluate argument %s \"\n        \"exactly once.\";\"\"\" % (i, i + 1) for i in OneTo(n)])\n\n  tests += \"\"\"\n\n    // Verifies that the control flow in the test function is expected.\n    if (expected_to_finish_ && !finished_) {\n      FAIL() << \"The predicate assertion unexpactedly aborted the test.\";\n    } else if (!expected_to_finish_ && finished_) {\n      FAIL() << \"The failed predicate assertion didn't abort the test \"\n                \"as expected.\";\n    }\n  }\n\n  // true iff the test function is expected to run to finish.\n  static bool expected_to_finish_;\n\n  // true iff the test function did run to finish.\n  static bool finished_;\n\"\"\" % DEFS\n\n  tests += Iter(n, \"\"\"\n  static int n%s_;\"\"\")\n\n  tests += \"\"\"\n};\n\nbool Predicate%(n)sTest::expected_to_finish_;\nbool Predicate%(n)sTest::finished_;\n\"\"\" % DEFS\n\n  tests += Iter(n, \"\"\"int Predicate%%(n)sTest::n%s_;\n\"\"\") % DEFS\n\n  tests += \"\"\"\ntypedef Predicate%(n)sTest EXPECT_PRED_FORMAT%(n)sTest;\ntypedef Predicate%(n)sTest ASSERT_PRED_FORMAT%(n)sTest;\ntypedef Predicate%(n)sTest EXPECT_PRED%(n)sTest;\ntypedef Predicate%(n)sTest ASSERT_PRED%(n)sTest;\n\"\"\" % DEFS\n\n  def GenTest(use_format, use_assert, expect_failure,\n              use_functor, use_user_type):\n    \"\"\"Returns the test for a predicate assertion macro.\n\n    Args:\n      use_format:     true iff the assertion is a *_PRED_FORMAT*.\n      use_assert:     true iff the assertion is a ASSERT_*.\n      expect_failure: true iff the assertion is expected to fail.\n      use_functor:    true iff the first argument of the assertion is\n                      a functor (as opposed to a function)\n      use_user_type:  true iff the predicate functor/function takes\n                      argument(s) of a user-defined type.\n\n    Example:\n\n      GenTest(1, 0, 0, 1, 0) returns a test that tests the behavior\n      of a successful EXPECT_PRED_FORMATn() that takes a functor\n      whose arguments have built-in types.\"\"\"\n\n    if use_assert:\n      assrt = 'ASSERT'  # 'assert' is reserved, so we cannot use\n                        # that identifier here.\n    else:\n      assrt = 'EXPECT'\n\n    assertion = assrt + '_PRED'\n\n    if use_format:\n      pred_format = 'PredFormat'\n      assertion += '_FORMAT'\n    else:\n      pred_format = 'Pred'\n\n    assertion += '%(n)s' % DEFS\n\n    if use_functor:\n      pred_format_type = 'functor'\n      pred_format += 'Functor%(n)s()'\n    else:\n      pred_format_type = 'function'\n      pred_format += 'Function%(n)s'\n      if not use_format:\n        if use_user_type:\n          pred_format += 'Bool'\n        else:\n          pred_format += 'Int'\n\n    test_name = pred_format_type.title()\n\n    if use_user_type:\n      arg_type = 'user-defined type (Bool)'\n      test_name += 'OnUserType'\n      if expect_failure:\n        arg = 'Bool(n%s_++)'\n      else:\n        arg = 'Bool(++n%s_)'\n    else:\n      arg_type = 'built-in type (int)'\n      test_name += 'OnBuiltInType'\n      if expect_failure:\n        arg = 'n%s_++'\n      else:\n        arg = '++n%s_'\n\n    if expect_failure:\n      successful_or_failed = 'failed'\n      expected_or_not = 'expected.'\n      test_name +=  'Failure'\n    else:\n      successful_or_failed = 'successful'\n      expected_or_not = 'UNEXPECTED!'\n      test_name +=  'Success'\n\n    # A map that defines the values used in the test template.\n    defs = DEFS.copy()\n    defs.update({\n      'assert' : assrt,\n      'assertion' : assertion,\n      'test_name' : test_name,\n      'pf_type' : pred_format_type,\n      'pf' : pred_format,\n      'arg_type' : arg_type,\n      'arg' : arg,\n      'successful' : successful_or_failed,\n      'expected' : expected_or_not,\n      })\n\n    test = \"\"\"\n// Tests a %(successful)s %(assertion)s where the\n// predicate-formatter is a %(pf_type)s on a %(arg_type)s.\nTEST_F(%(assertion)sTest, %(test_name)s) {\"\"\" % defs\n\n    indent = (len(assertion) + 3)*' '\n    extra_indent = ''\n\n    if expect_failure:\n      extra_indent = '  '\n      if use_assert:\n        test += \"\"\"\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\"\"\"\n      else:\n        test += \"\"\"\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\"\"\"\n\n    test += '\\n' + extra_indent + \"\"\"  %(assertion)s(%(pf)s\"\"\" % defs\n\n    test = test % defs\n    test += Iter(n, ',\\n' + indent + extra_indent + '%(arg)s' % defs)\n    test += ');\\n' + extra_indent + '  finished_ = true;\\n'\n\n    if expect_failure:\n      test += '  }, \"\");\\n'\n\n    test += '}\\n'\n    return test\n\n  # Generates tests for all 2**6 = 64 combinations.\n  tests += ''.join([GenTest(use_format, use_assert, expect_failure,\n                            use_functor, use_user_type)\n                    for use_format in [0, 1]\n                    for use_assert in [0, 1]\n                    for expect_failure in [0, 1]\n                    for use_functor in [0, 1]\n                    for use_user_type in [0, 1]\n                    ])\n\n  return tests\n\n\ndef UnitTestPostamble():\n  \"\"\"Returns the postamble for the tests.\"\"\"\n\n  return ''\n\n\ndef GenerateUnitTest(n):\n  \"\"\"Returns the tests for up-to n-ary predicate assertions.\"\"\"\n\n  GenerateFile(UNIT_TEST,\n               UnitTestPreamble()\n               + ''.join([TestsForArity(i) for i in OneTo(n)])\n               + UnitTestPostamble())\n\n\ndef _Main():\n  \"\"\"The entry point of the script.  Generates the header file and its\n  unit test.\"\"\"\n\n  if len(sys.argv) != 2:\n    print __doc__\n    print 'Author: ' + __author__\n    sys.exit(1)\n\n  n = int(sys.argv[1])\n  GenerateHeader(n)\n  GenerateUnitTest(n)\n\n\nif __name__ == '__main__':\n  _Main()\n"
  },
  {
    "path": "ext/gtest/scripts/gtest-config.in",
    "content": "#!/bin/sh\n\n# These variables are automatically filled in by the configure script.\nname=\"@PACKAGE_TARNAME@\"\nversion=\"@PACKAGE_VERSION@\"\n\nshow_usage()\n{\n  echo \"Usage: gtest-config [OPTIONS...]\"\n}\n\nshow_help()\n{\n  show_usage\n  cat <<\\EOF\n\nThe `gtest-config' script provides access to the necessary compile and linking\nflags to connect with Google C++ Testing Framework, both in a build prior to\ninstallation, and on the system proper after installation. The installation\noverrides may be issued in combination with any other queries, but will only\naffect installation queries if called on a built but not installed gtest. The\ninstallation queries may not be issued with any other types of queries, and\nonly one installation query may be made at a time. The version queries and\ncompiler flag queries may be combined as desired but not mixed. Different\nversion queries are always combined with logical \"and\" semantics, and only the\nlast of any particular query is used while all previous ones ignored. All\nversions must be specified as a sequence of numbers separated by periods.\nCompiler flag queries output the union of the sets of flags when combined.\n\n Examples:\n  gtest-config --min-version=1.0 || echo \"Insufficient Google Test version.\"\n\n  g++ $(gtest-config --cppflags --cxxflags) -o foo.o -c foo.cpp\n  g++ $(gtest-config --ldflags --libs) -o foo foo.o\n\n  # When using a built but not installed Google Test:\n  g++ $(../../my_gtest_build/scripts/gtest-config ...) ...\n\n  # When using an installed Google Test, but with installation overrides:\n  export GTEST_PREFIX=\"/opt\"\n  g++ $(gtest-config --libdir=\"/opt/lib64\" ...) ...\n\n Help:\n  --usage                    brief usage information\n  --help                     display this help message\n\n Installation Overrides:\n  --prefix=<dir>             overrides the installation prefix\n  --exec-prefix=<dir>        overrides the executable installation prefix\n  --libdir=<dir>             overrides the library installation prefix\n  --includedir=<dir>         overrides the header file installation prefix\n\n Installation Queries:\n  --prefix                   installation prefix\n  --exec-prefix              executable installation prefix\n  --libdir                   library installation directory\n  --includedir               header file installation directory\n  --version                  the version of the Google Test installation\n\n Version Queries:\n  --min-version=VERSION      return 0 if the version is at least VERSION\n  --exact-version=VERSION    return 0 if the version is exactly VERSION\n  --max-version=VERSION      return 0 if the version is at most VERSION\n\n Compilation Flag Queries:\n  --cppflags                 compile flags specific to the C-like preprocessors\n  --cxxflags                 compile flags appropriate for C++ programs\n  --ldflags                  linker flags\n  --libs                     libraries for linking\n\nEOF\n}\n\n# This function bounds our version with a min and a max. It uses some clever\n# POSIX-compliant variable expansion to portably do all the work in the shell\n# and avoid any dependency on a particular \"sed\" or \"awk\" implementation.\n# Notable is that it will only ever compare the first 3 components of versions.\n# Further components will be cleanly stripped off. All versions must be\n# unadorned, so \"v1.0\" will *not* work. The minimum version must be in $1, and\n# the max in $2. TODO(chandlerc@google.com): If this ever breaks, we should\n# investigate expanding this via autom4te from AS_VERSION_COMPARE rather than\n# continuing to maintain our own shell version.\ncheck_versions()\n{\n  major_version=${version%%.*}\n  minor_version=\"0\"\n  point_version=\"0\"\n  if test \"${version#*.}\" != \"${version}\"; then\n    minor_version=${version#*.}\n    minor_version=${minor_version%%.*}\n  fi\n  if test \"${version#*.*.}\" != \"${version}\"; then\n    point_version=${version#*.*.}\n    point_version=${point_version%%.*}\n  fi\n\n  min_version=\"$1\"\n  min_major_version=${min_version%%.*}\n  min_minor_version=\"0\"\n  min_point_version=\"0\"\n  if test \"${min_version#*.}\" != \"${min_version}\"; then\n    min_minor_version=${min_version#*.}\n    min_minor_version=${min_minor_version%%.*}\n  fi\n  if test \"${min_version#*.*.}\" != \"${min_version}\"; then\n    min_point_version=${min_version#*.*.}\n    min_point_version=${min_point_version%%.*}\n  fi\n\n  max_version=\"$2\"\n  max_major_version=${max_version%%.*}\n  max_minor_version=\"0\"\n  max_point_version=\"0\"\n  if test \"${max_version#*.}\" != \"${max_version}\"; then\n    max_minor_version=${max_version#*.}\n    max_minor_version=${max_minor_version%%.*}\n  fi\n  if test \"${max_version#*.*.}\" != \"${max_version}\"; then\n    max_point_version=${max_version#*.*.}\n    max_point_version=${max_point_version%%.*}\n  fi\n\n  test $(($major_version)) -lt $(($min_major_version)) && exit 1\n  if test $(($major_version)) -eq $(($min_major_version)); then\n    test $(($minor_version)) -lt $(($min_minor_version)) && exit 1\n    if test $(($minor_version)) -eq $(($min_minor_version)); then\n      test $(($point_version)) -lt $(($min_point_version)) && exit 1\n    fi\n  fi\n\n  test $(($major_version)) -gt $(($max_major_version)) && exit 1\n  if test $(($major_version)) -eq $(($max_major_version)); then\n    test $(($minor_version)) -gt $(($max_minor_version)) && exit 1\n    if test $(($minor_version)) -eq $(($max_minor_version)); then\n      test $(($point_version)) -gt $(($max_point_version)) && exit 1\n    fi\n  fi\n\n  exit 0\n}\n\n# Show the usage line when no arguments are specified.\nif test $# -eq 0; then\n  show_usage\n  exit 1\nfi\n\nwhile test $# -gt 0; do\n  case $1 in\n    --usage)          show_usage;         exit 0;;\n    --help)           show_help;          exit 0;;\n\n    # Installation overrides\n    --prefix=*)       GTEST_PREFIX=${1#--prefix=};;\n    --exec-prefix=*)  GTEST_EXEC_PREFIX=${1#--exec-prefix=};;\n    --libdir=*)       GTEST_LIBDIR=${1#--libdir=};;\n    --includedir=*)   GTEST_INCLUDEDIR=${1#--includedir=};;\n\n    # Installation queries\n    --prefix|--exec-prefix|--libdir|--includedir|--version)\n      if test -n \"${do_query}\"; then\n        show_usage\n        exit 1\n      fi\n      do_query=${1#--}\n      ;;\n\n    # Version checking\n    --min-version=*)\n      do_check_versions=yes\n      min_version=${1#--min-version=}\n      ;;\n    --max-version=*)\n      do_check_versions=yes\n      max_version=${1#--max-version=}\n      ;;\n    --exact-version=*)\n      do_check_versions=yes\n      exact_version=${1#--exact-version=}\n      ;;\n\n    # Compiler flag output\n    --cppflags)       echo_cppflags=yes;;\n    --cxxflags)       echo_cxxflags=yes;;\n    --ldflags)        echo_ldflags=yes;;\n    --libs)           echo_libs=yes;;\n\n    # Everything else is an error\n    *)                show_usage;         exit 1;;\n  esac\n  shift\ndone\n\n# These have defaults filled in by the configure script but can also be\n# overridden by environment variables or command line parameters.\nprefix=\"${GTEST_PREFIX:-@prefix@}\"\nexec_prefix=\"${GTEST_EXEC_PREFIX:-@exec_prefix@}\"\nlibdir=\"${GTEST_LIBDIR:-@libdir@}\"\nincludedir=\"${GTEST_INCLUDEDIR:-@includedir@}\"\n\n# We try and detect if our binary is not located at its installed location. If\n# it's not, we provide variables pointing to the source and build tree rather\n# than to the install tree. This allows building against a just-built gtest\n# rather than an installed gtest.\nbindir=\"@bindir@\"\nthis_relative_bindir=`dirname $0`\nthis_bindir=`cd ${this_relative_bindir}; pwd -P`\nif test \"${this_bindir}\" = \"${this_bindir%${bindir}}\"; then\n  # The path to the script doesn't end in the bindir sequence from Autoconf,\n  # assume that we are in a build tree.\n  build_dir=`dirname ${this_bindir}`\n  src_dir=`cd ${this_bindir}; cd @top_srcdir@; pwd -P`\n\n  # TODO(chandlerc@google.com): This is a dangerous dependency on libtool, we\n  # should work to remove it, and/or remove libtool altogether, replacing it\n  # with direct references to the library and a link path.\n  gtest_libs=\"${build_dir}/lib/libgtest.la @PTHREAD_CFLAGS@ @PTHREAD_LIBS@\"\n  gtest_ldflags=\"\"\n\n  # We provide hooks to include from either the source or build dir, where the\n  # build dir is always preferred. This will potentially allow us to write\n  # build rules for generated headers and have them automatically be preferred\n  # over provided versions.\n  gtest_cppflags=\"-I${build_dir}/include -I${src_dir}/include\"\n  gtest_cxxflags=\"@PTHREAD_CFLAGS@\"\nelse\n  # We're using an installed gtest, although it may be staged under some\n  # prefix. Assume (as our own libraries do) that we can resolve the prefix,\n  # and are present in the dynamic link paths.\n  gtest_ldflags=\"-L${libdir}\"\n  gtest_libs=\"-l${name} @PTHREAD_CFLAGS@ @PTHREAD_LIBS@\"\n  gtest_cppflags=\"-I${includedir}\"\n  gtest_cxxflags=\"@PTHREAD_CFLAGS@\"\nfi\n\n# Do an installation query if requested.\nif test -n \"$do_query\"; then\n  case $do_query in\n    prefix)           echo $prefix;       exit 0;;\n    exec-prefix)      echo $exec_prefix;  exit 0;;\n    libdir)           echo $libdir;       exit 0;;\n    includedir)       echo $includedir;   exit 0;;\n    version)          echo $version;      exit 0;;\n    *)                show_usage;         exit 1;;\n  esac\nfi\n\n# Do a version check if requested.\nif test \"$do_check_versions\" = \"yes\"; then\n  # Make sure we didn't receive a bad combination of parameters.\n  test \"$echo_cppflags\" = \"yes\" && show_usage && exit 1\n  test \"$echo_cxxflags\" = \"yes\" && show_usage && exit 1\n  test \"$echo_ldflags\" = \"yes\"  && show_usage && exit 1\n  test \"$echo_libs\" = \"yes\"     && show_usage && exit 1\n\n  if test \"$exact_version\" != \"\"; then\n    check_versions $exact_version $exact_version\n    # unreachable\n  else\n    check_versions ${min_version:-0.0.0} ${max_version:-9999.9999.9999}\n    # unreachable\n  fi\nfi\n\n# Do the output in the correct order so that these can be used in-line of\n# a compiler invocation.\noutput=\"\"\ntest \"$echo_cppflags\" = \"yes\" && output=\"$output $gtest_cppflags\"\ntest \"$echo_cxxflags\" = \"yes\" && output=\"$output $gtest_cxxflags\"\ntest \"$echo_ldflags\" = \"yes\"  && output=\"$output $gtest_ldflags\"\ntest \"$echo_libs\" = \"yes\"     && output=\"$output $gtest_libs\"\necho $output\n\nexit 0\n"
  },
  {
    "path": "ext/gtest/scripts/pump.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2008, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"pump v0.2.0 - Pretty Useful for Meta Programming.\n\nA tool for preprocessor meta programming.  Useful for generating\nrepetitive boilerplate code.  Especially useful for writing C++\nclasses, functions, macros, and templates that need to work with\nvarious number of arguments.\n\nUSAGE:\n       pump.py SOURCE_FILE\n\nEXAMPLES:\n       pump.py foo.cc.pump\n         Converts foo.cc.pump to foo.cc.\n\nGRAMMAR:\n       CODE ::= ATOMIC_CODE*\n       ATOMIC_CODE ::= $var ID = EXPRESSION\n           | $var ID = [[ CODE ]]\n           | $range ID EXPRESSION..EXPRESSION\n           | $for ID SEPARATOR [[ CODE ]]\n           | $($)\n           | $ID\n           | $(EXPRESSION)\n           | $if EXPRESSION [[ CODE ]] ELSE_BRANCH\n           | [[ CODE ]]\n           | RAW_CODE\n       SEPARATOR ::= RAW_CODE | EMPTY\n       ELSE_BRANCH ::= $else [[ CODE ]]\n           | $elif EXPRESSION [[ CODE ]] ELSE_BRANCH\n           | EMPTY\n       EXPRESSION has Python syntax.\n\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport re\nimport sys\n\n\nTOKEN_TABLE = [\n    (re.compile(r'\\$var\\s+'), '$var'),\n    (re.compile(r'\\$elif\\s+'), '$elif'),\n    (re.compile(r'\\$else\\s+'), '$else'),\n    (re.compile(r'\\$for\\s+'), '$for'),\n    (re.compile(r'\\$if\\s+'), '$if'),\n    (re.compile(r'\\$range\\s+'), '$range'),\n    (re.compile(r'\\$[_A-Za-z]\\w*'), '$id'),\n    (re.compile(r'\\$\\(\\$\\)'), '$($)'),\n    (re.compile(r'\\$'), '$'),\n    (re.compile(r'\\[\\[\\n?'), '[['),\n    (re.compile(r'\\]\\]\\n?'), ']]'),\n    ]\n\n\nclass Cursor:\n  \"\"\"Represents a position (line and column) in a text file.\"\"\"\n\n  def __init__(self, line=-1, column=-1):\n    self.line = line\n    self.column = column\n\n  def __eq__(self, rhs):\n    return self.line == rhs.line and self.column == rhs.column\n\n  def __ne__(self, rhs):\n    return not self == rhs\n\n  def __lt__(self, rhs):\n    return self.line < rhs.line or (\n        self.line == rhs.line and self.column < rhs.column)\n\n  def __le__(self, rhs):\n    return self < rhs or self == rhs\n\n  def __gt__(self, rhs):\n    return rhs < self\n\n  def __ge__(self, rhs):\n    return rhs <= self\n\n  def __str__(self):\n    if self == Eof():\n      return 'EOF'\n    else:\n      return '%s(%s)' % (self.line + 1, self.column)\n\n  def __add__(self, offset):\n    return Cursor(self.line, self.column + offset)\n\n  def __sub__(self, offset):\n    return Cursor(self.line, self.column - offset)\n\n  def Clone(self):\n    \"\"\"Returns a copy of self.\"\"\"\n\n    return Cursor(self.line, self.column)\n\n\n# Special cursor to indicate the end-of-file.\ndef Eof():\n  \"\"\"Returns the special cursor to denote the end-of-file.\"\"\"\n  return Cursor(-1, -1)\n\n\nclass Token:\n  \"\"\"Represents a token in a Pump source file.\"\"\"\n\n  def __init__(self, start=None, end=None, value=None, token_type=None):\n    if start is None:\n      self.start = Eof()\n    else:\n      self.start = start\n    if end is None:\n      self.end = Eof()\n    else:\n      self.end = end\n    self.value = value\n    self.token_type = token_type\n\n  def __str__(self):\n    return 'Token @%s: \\'%s\\' type=%s' % (\n        self.start, self.value, self.token_type)\n\n  def Clone(self):\n    \"\"\"Returns a copy of self.\"\"\"\n\n    return Token(self.start.Clone(), self.end.Clone(), self.value,\n                 self.token_type)\n\n\ndef StartsWith(lines, pos, string):\n  \"\"\"Returns True iff the given position in lines starts with 'string'.\"\"\"\n\n  return lines[pos.line][pos.column:].startswith(string)\n\n\ndef FindFirstInLine(line, token_table):\n  best_match_start = -1\n  for (regex, token_type) in token_table:\n    m = regex.search(line)\n    if m:\n      # We found regex in lines\n      if best_match_start < 0 or m.start() < best_match_start:\n        best_match_start = m.start()\n        best_match_length = m.end() - m.start()\n        best_match_token_type = token_type\n\n  if best_match_start < 0:\n    return None\n\n  return (best_match_start, best_match_length, best_match_token_type)\n\n\ndef FindFirst(lines, token_table, cursor):\n  \"\"\"Finds the first occurrence of any string in strings in lines.\"\"\"\n\n  start = cursor.Clone()\n  cur_line_number = cursor.line\n  for line in lines[start.line:]:\n    if cur_line_number == start.line:\n      line = line[start.column:]\n    m = FindFirstInLine(line, token_table)\n    if m:\n      # We found a regex in line.\n      (start_column, length, token_type) = m\n      if cur_line_number == start.line:\n        start_column += start.column\n      found_start = Cursor(cur_line_number, start_column)\n      found_end = found_start + length\n      return MakeToken(lines, found_start, found_end, token_type)\n    cur_line_number += 1\n  # We failed to find str in lines\n  return None\n\n\ndef SubString(lines, start, end):\n  \"\"\"Returns a substring in lines.\"\"\"\n\n  if end == Eof():\n    end = Cursor(len(lines) - 1, len(lines[-1]))\n\n  if start >= end:\n    return ''\n\n  if start.line == end.line:\n    return lines[start.line][start.column:end.column]\n\n  result_lines = ([lines[start.line][start.column:]] +\n                  lines[start.line + 1:end.line] +\n                  [lines[end.line][:end.column]])\n  return ''.join(result_lines)\n\n\ndef StripMetaComments(str):\n  \"\"\"Strip meta comments from each line in the given string.\"\"\"\n\n  # First, completely remove lines containing nothing but a meta\n  # comment, including the trailing \\n.\n  str = re.sub(r'^\\s*\\$\\$.*\\n', '', str)\n\n  # Then, remove meta comments from contentful lines.\n  return re.sub(r'\\s*\\$\\$.*', '', str)\n\n\ndef MakeToken(lines, start, end, token_type):\n  \"\"\"Creates a new instance of Token.\"\"\"\n\n  return Token(start, end, SubString(lines, start, end), token_type)\n\n\ndef ParseToken(lines, pos, regex, token_type):\n  line = lines[pos.line][pos.column:]\n  m = regex.search(line)\n  if m and not m.start():\n    return MakeToken(lines, pos, pos + m.end(), token_type)\n  else:\n    print 'ERROR: %s expected at %s.' % (token_type, pos)\n    sys.exit(1)\n\n\nID_REGEX = re.compile(r'[_A-Za-z]\\w*')\nEQ_REGEX = re.compile(r'=')\nREST_OF_LINE_REGEX = re.compile(r'.*?(?=$|\\$\\$)')\nOPTIONAL_WHITE_SPACES_REGEX = re.compile(r'\\s*')\nWHITE_SPACE_REGEX = re.compile(r'\\s')\nDOT_DOT_REGEX = re.compile(r'\\.\\.')\n\n\ndef Skip(lines, pos, regex):\n  line = lines[pos.line][pos.column:]\n  m = re.search(regex, line)\n  if m and not m.start():\n    return pos + m.end()\n  else:\n    return pos\n\n\ndef SkipUntil(lines, pos, regex, token_type):\n  line = lines[pos.line][pos.column:]\n  m = re.search(regex, line)\n  if m:\n    return pos + m.start()\n  else:\n    print ('ERROR: %s expected on line %s after column %s.' %\n           (token_type, pos.line + 1, pos.column))\n    sys.exit(1)\n\n\ndef ParseExpTokenInParens(lines, pos):\n  def ParseInParens(pos):\n    pos = Skip(lines, pos, OPTIONAL_WHITE_SPACES_REGEX)\n    pos = Skip(lines, pos, r'\\(')\n    pos = Parse(pos)\n    pos = Skip(lines, pos, r'\\)')\n    return pos\n\n  def Parse(pos):\n    pos = SkipUntil(lines, pos, r'\\(|\\)', ')')\n    if SubString(lines, pos, pos + 1) == '(':\n      pos = Parse(pos + 1)\n      pos = Skip(lines, pos, r'\\)')\n      return Parse(pos)\n    else:\n      return pos\n\n  start = pos.Clone()\n  pos = ParseInParens(pos)\n  return MakeToken(lines, start, pos, 'exp')\n\n\ndef RStripNewLineFromToken(token):\n  if token.value.endswith('\\n'):\n    return Token(token.start, token.end, token.value[:-1], token.token_type)\n  else:\n    return token\n\n\ndef TokenizeLines(lines, pos):\n  while True:\n    found = FindFirst(lines, TOKEN_TABLE, pos)\n    if not found:\n      yield MakeToken(lines, pos, Eof(), 'code')\n      return\n\n    if found.start == pos:\n      prev_token = None\n      prev_token_rstripped = None\n    else:\n      prev_token = MakeToken(lines, pos, found.start, 'code')\n      prev_token_rstripped = RStripNewLineFromToken(prev_token)\n\n    if found.token_type == '$var':\n      if prev_token_rstripped:\n        yield prev_token_rstripped\n      yield found\n      id_token = ParseToken(lines, found.end, ID_REGEX, 'id')\n      yield id_token\n      pos = Skip(lines, id_token.end, OPTIONAL_WHITE_SPACES_REGEX)\n\n      eq_token = ParseToken(lines, pos, EQ_REGEX, '=')\n      yield eq_token\n      pos = Skip(lines, eq_token.end, r'\\s*')\n\n      if SubString(lines, pos, pos + 2) != '[[':\n        exp_token = ParseToken(lines, pos, REST_OF_LINE_REGEX, 'exp')\n        yield exp_token\n        pos = Cursor(exp_token.end.line + 1, 0)\n    elif found.token_type == '$for':\n      if prev_token_rstripped:\n        yield prev_token_rstripped\n      yield found\n      id_token = ParseToken(lines, found.end, ID_REGEX, 'id')\n      yield id_token\n      pos = Skip(lines, id_token.end, WHITE_SPACE_REGEX)\n    elif found.token_type == '$range':\n      if prev_token_rstripped:\n        yield prev_token_rstripped\n      yield found\n      id_token = ParseToken(lines, found.end, ID_REGEX, 'id')\n      yield id_token\n      pos = Skip(lines, id_token.end, OPTIONAL_WHITE_SPACES_REGEX)\n\n      dots_pos = SkipUntil(lines, pos, DOT_DOT_REGEX, '..')\n      yield MakeToken(lines, pos, dots_pos, 'exp')\n      yield MakeToken(lines, dots_pos, dots_pos + 2, '..')\n      pos = dots_pos + 2\n      new_pos = Cursor(pos.line + 1, 0)\n      yield MakeToken(lines, pos, new_pos, 'exp')\n      pos = new_pos\n    elif found.token_type == '$':\n      if prev_token:\n        yield prev_token\n      yield found\n      exp_token = ParseExpTokenInParens(lines, found.end)\n      yield exp_token\n      pos = exp_token.end\n    elif (found.token_type == ']]' or found.token_type == '$if' or\n          found.token_type == '$elif' or found.token_type == '$else'):\n      if prev_token_rstripped:\n        yield prev_token_rstripped\n      yield found\n      pos = found.end\n    else:\n      if prev_token:\n        yield prev_token\n      yield found\n      pos = found.end\n\n\ndef Tokenize(s):\n  \"\"\"A generator that yields the tokens in the given string.\"\"\"\n  if s != '':\n    lines = s.splitlines(True)\n    for token in TokenizeLines(lines, Cursor(0, 0)):\n      yield token\n\n\nclass CodeNode:\n  def __init__(self, atomic_code_list=None):\n    self.atomic_code = atomic_code_list\n\n\nclass VarNode:\n  def __init__(self, identifier=None, atomic_code=None):\n    self.identifier = identifier\n    self.atomic_code = atomic_code\n\n\nclass RangeNode:\n  def __init__(self, identifier=None, exp1=None, exp2=None):\n    self.identifier = identifier\n    self.exp1 = exp1\n    self.exp2 = exp2\n\n\nclass ForNode:\n  def __init__(self, identifier=None, sep=None, code=None):\n    self.identifier = identifier\n    self.sep = sep\n    self.code = code\n\n\nclass ElseNode:\n  def __init__(self, else_branch=None):\n    self.else_branch = else_branch\n\n\nclass IfNode:\n  def __init__(self, exp=None, then_branch=None, else_branch=None):\n    self.exp = exp\n    self.then_branch = then_branch\n    self.else_branch = else_branch\n\n\nclass RawCodeNode:\n  def __init__(self, token=None):\n    self.raw_code = token\n\n\nclass LiteralDollarNode:\n  def __init__(self, token):\n    self.token = token\n\n\nclass ExpNode:\n  def __init__(self, token, python_exp):\n    self.token = token\n    self.python_exp = python_exp\n\n\ndef PopFront(a_list):\n  head = a_list[0]\n  a_list[:1] = []\n  return head\n\n\ndef PushFront(a_list, elem):\n  a_list[:0] = [elem]\n\n\ndef PopToken(a_list, token_type=None):\n  token = PopFront(a_list)\n  if token_type is not None and token.token_type != token_type:\n    print 'ERROR: %s expected at %s' % (token_type, token.start)\n    print 'ERROR: %s found instead' % (token,)\n    sys.exit(1)\n\n  return token\n\n\ndef PeekToken(a_list):\n  if not a_list:\n    return None\n\n  return a_list[0]\n\n\ndef ParseExpNode(token):\n  python_exp = re.sub(r'([_A-Za-z]\\w*)', r'self.GetValue(\"\\1\")', token.value)\n  return ExpNode(token, python_exp)\n\n\ndef ParseElseNode(tokens):\n  def Pop(token_type=None):\n    return PopToken(tokens, token_type)\n\n  next = PeekToken(tokens)\n  if not next:\n    return None\n  if next.token_type == '$else':\n    Pop('$else')\n    Pop('[[')\n    code_node = ParseCodeNode(tokens)\n    Pop(']]')\n    return code_node\n  elif next.token_type == '$elif':\n    Pop('$elif')\n    exp = Pop('code')\n    Pop('[[')\n    code_node = ParseCodeNode(tokens)\n    Pop(']]')\n    inner_else_node = ParseElseNode(tokens)\n    return CodeNode([IfNode(ParseExpNode(exp), code_node, inner_else_node)])\n  elif not next.value.strip():\n    Pop('code')\n    return ParseElseNode(tokens)\n  else:\n    return None\n\n\ndef ParseAtomicCodeNode(tokens):\n  def Pop(token_type=None):\n    return PopToken(tokens, token_type)\n\n  head = PopFront(tokens)\n  t = head.token_type\n  if t == 'code':\n    return RawCodeNode(head)\n  elif t == '$var':\n    id_token = Pop('id')\n    Pop('=')\n    next = PeekToken(tokens)\n    if next.token_type == 'exp':\n      exp_token = Pop()\n      return VarNode(id_token, ParseExpNode(exp_token))\n    Pop('[[')\n    code_node = ParseCodeNode(tokens)\n    Pop(']]')\n    return VarNode(id_token, code_node)\n  elif t == '$for':\n    id_token = Pop('id')\n    next_token = PeekToken(tokens)\n    if next_token.token_type == 'code':\n      sep_token = next_token\n      Pop('code')\n    else:\n      sep_token = None\n    Pop('[[')\n    code_node = ParseCodeNode(tokens)\n    Pop(']]')\n    return ForNode(id_token, sep_token, code_node)\n  elif t == '$if':\n    exp_token = Pop('code')\n    Pop('[[')\n    code_node = ParseCodeNode(tokens)\n    Pop(']]')\n    else_node = ParseElseNode(tokens)\n    return IfNode(ParseExpNode(exp_token), code_node, else_node)\n  elif t == '$range':\n    id_token = Pop('id')\n    exp1_token = Pop('exp')\n    Pop('..')\n    exp2_token = Pop('exp')\n    return RangeNode(id_token, ParseExpNode(exp1_token),\n                     ParseExpNode(exp2_token))\n  elif t == '$id':\n    return ParseExpNode(Token(head.start + 1, head.end, head.value[1:], 'id'))\n  elif t == '$($)':\n    return LiteralDollarNode(head)\n  elif t == '$':\n    exp_token = Pop('exp')\n    return ParseExpNode(exp_token)\n  elif t == '[[':\n    code_node = ParseCodeNode(tokens)\n    Pop(']]')\n    return code_node\n  else:\n    PushFront(tokens, head)\n    return None\n\n\ndef ParseCodeNode(tokens):\n  atomic_code_list = []\n  while True:\n    if not tokens:\n      break\n    atomic_code_node = ParseAtomicCodeNode(tokens)\n    if atomic_code_node:\n      atomic_code_list.append(atomic_code_node)\n    else:\n      break\n  return CodeNode(atomic_code_list)\n\n\ndef ParseToAST(pump_src_text):\n  \"\"\"Convert the given Pump source text into an AST.\"\"\"\n  tokens = list(Tokenize(pump_src_text))\n  code_node = ParseCodeNode(tokens)\n  return code_node\n\n\nclass Env:\n  def __init__(self):\n    self.variables = []\n    self.ranges = []\n\n  def Clone(self):\n    clone = Env()\n    clone.variables = self.variables[:]\n    clone.ranges = self.ranges[:]\n    return clone\n\n  def PushVariable(self, var, value):\n    # If value looks like an int, store it as an int.\n    try:\n      int_value = int(value)\n      if ('%s' % int_value) == value:\n        value = int_value\n    except Exception:\n      pass\n    self.variables[:0] = [(var, value)]\n\n  def PopVariable(self):\n    self.variables[:1] = []\n\n  def PushRange(self, var, lower, upper):\n    self.ranges[:0] = [(var, lower, upper)]\n\n  def PopRange(self):\n    self.ranges[:1] = []\n\n  def GetValue(self, identifier):\n    for (var, value) in self.variables:\n      if identifier == var:\n        return value\n\n    print 'ERROR: meta variable %s is undefined.' % (identifier,)\n    sys.exit(1)\n\n  def EvalExp(self, exp):\n    try:\n      result = eval(exp.python_exp)\n    except Exception, e:\n      print 'ERROR: caught exception %s: %s' % (e.__class__.__name__, e)\n      print ('ERROR: failed to evaluate meta expression %s at %s' %\n             (exp.python_exp, exp.token.start))\n      sys.exit(1)\n    return result\n\n  def GetRange(self, identifier):\n    for (var, lower, upper) in self.ranges:\n      if identifier == var:\n        return (lower, upper)\n\n    print 'ERROR: range %s is undefined.' % (identifier,)\n    sys.exit(1)\n\n\nclass Output:\n  def __init__(self):\n    self.string = ''\n\n  def GetLastLine(self):\n    index = self.string.rfind('\\n')\n    if index < 0:\n      return ''\n\n    return self.string[index + 1:]\n\n  def Append(self, s):\n    self.string += s\n\n\ndef RunAtomicCode(env, node, output):\n  if isinstance(node, VarNode):\n    identifier = node.identifier.value.strip()\n    result = Output()\n    RunAtomicCode(env.Clone(), node.atomic_code, result)\n    value = result.string\n    env.PushVariable(identifier, value)\n  elif isinstance(node, RangeNode):\n    identifier = node.identifier.value.strip()\n    lower = int(env.EvalExp(node.exp1))\n    upper = int(env.EvalExp(node.exp2))\n    env.PushRange(identifier, lower, upper)\n  elif isinstance(node, ForNode):\n    identifier = node.identifier.value.strip()\n    if node.sep is None:\n      sep = ''\n    else:\n      sep = node.sep.value\n    (lower, upper) = env.GetRange(identifier)\n    for i in range(lower, upper + 1):\n      new_env = env.Clone()\n      new_env.PushVariable(identifier, i)\n      RunCode(new_env, node.code, output)\n      if i != upper:\n        output.Append(sep)\n  elif isinstance(node, RawCodeNode):\n    output.Append(node.raw_code.value)\n  elif isinstance(node, IfNode):\n    cond = env.EvalExp(node.exp)\n    if cond:\n      RunCode(env.Clone(), node.then_branch, output)\n    elif node.else_branch is not None:\n      RunCode(env.Clone(), node.else_branch, output)\n  elif isinstance(node, ExpNode):\n    value = env.EvalExp(node)\n    output.Append('%s' % (value,))\n  elif isinstance(node, LiteralDollarNode):\n    output.Append('$')\n  elif isinstance(node, CodeNode):\n    RunCode(env.Clone(), node, output)\n  else:\n    print 'BAD'\n    print node\n    sys.exit(1)\n\n\ndef RunCode(env, code_node, output):\n  for atomic_code in code_node.atomic_code:\n    RunAtomicCode(env, atomic_code, output)\n\n\ndef IsSingleLineComment(cur_line):\n  return '//' in cur_line\n\n\ndef IsInPreprocessorDirective(prev_lines, cur_line):\n  if cur_line.lstrip().startswith('#'):\n    return True\n  return prev_lines and prev_lines[-1].endswith('\\\\')\n\n\ndef WrapComment(line, output):\n  loc = line.find('//')\n  before_comment = line[:loc].rstrip()\n  if before_comment == '':\n    indent = loc\n  else:\n    output.append(before_comment)\n    indent = len(before_comment) - len(before_comment.lstrip())\n  prefix = indent*' ' + '// '\n  max_len = 80 - len(prefix)\n  comment = line[loc + 2:].strip()\n  segs = [seg for seg in re.split(r'(\\w+\\W*)', comment) if seg != '']\n  cur_line = ''\n  for seg in segs:\n    if len((cur_line + seg).rstrip()) < max_len:\n      cur_line += seg\n    else:\n      if cur_line.strip() != '':\n        output.append(prefix + cur_line.rstrip())\n      cur_line = seg.lstrip()\n  if cur_line.strip() != '':\n    output.append(prefix + cur_line.strip())\n\n\ndef WrapCode(line, line_concat, output):\n  indent = len(line) - len(line.lstrip())\n  prefix = indent*' '  # Prefix of the current line\n  max_len = 80 - indent - len(line_concat)  # Maximum length of the current line\n  new_prefix = prefix + 4*' '  # Prefix of a continuation line\n  new_max_len = max_len - 4  # Maximum length of a continuation line\n  # Prefers to wrap a line after a ',' or ';'.\n  segs = [seg for seg in re.split(r'([^,;]+[,;]?)', line.strip()) if seg != '']\n  cur_line = ''  # The current line without leading spaces.\n  for seg in segs:\n    # If the line is still too long, wrap at a space.\n    while cur_line == '' and len(seg.strip()) > max_len:\n      seg = seg.lstrip()\n      split_at = seg.rfind(' ', 0, max_len)\n      output.append(prefix + seg[:split_at].strip() + line_concat)\n      seg = seg[split_at + 1:]\n      prefix = new_prefix\n      max_len = new_max_len\n\n    if len((cur_line + seg).rstrip()) < max_len:\n      cur_line = (cur_line + seg).lstrip()\n    else:\n      output.append(prefix + cur_line.rstrip() + line_concat)\n      prefix = new_prefix\n      max_len = new_max_len\n      cur_line = seg.lstrip()\n  if cur_line.strip() != '':\n    output.append(prefix + cur_line.strip())\n\n\ndef WrapPreprocessorDirective(line, output):\n  WrapCode(line, ' \\\\', output)\n\n\ndef WrapPlainCode(line, output):\n  WrapCode(line, '', output)\n\n\ndef IsMultiLineIWYUPragma(line):\n  return re.search(r'/\\* IWYU pragma: ', line)\n\n\ndef IsHeaderGuardIncludeOrOneLineIWYUPragma(line):\n  return (re.match(r'^#(ifndef|define|endif\\s*//)\\s*[\\w_]+\\s*$', line) or\n          re.match(r'^#include\\s', line) or\n          # Don't break IWYU pragmas, either; that causes iwyu.py problems.\n          re.search(r'// IWYU pragma: ', line))\n\n\ndef WrapLongLine(line, output):\n  line = line.rstrip()\n  if len(line) <= 80:\n    output.append(line)\n  elif IsSingleLineComment(line):\n    if IsHeaderGuardIncludeOrOneLineIWYUPragma(line):\n      # The style guide made an exception to allow long header guard lines,\n      # includes and IWYU pragmas.\n      output.append(line)\n    else:\n      WrapComment(line, output)\n  elif IsInPreprocessorDirective(output, line):\n    if IsHeaderGuardIncludeOrOneLineIWYUPragma(line):\n      # The style guide made an exception to allow long header guard lines,\n      # includes and IWYU pragmas.\n      output.append(line)\n    else:\n      WrapPreprocessorDirective(line, output)\n  elif IsMultiLineIWYUPragma(line):\n    output.append(line)\n  else:\n    WrapPlainCode(line, output)\n\n\ndef BeautifyCode(string):\n  lines = string.splitlines()\n  output = []\n  for line in lines:\n    WrapLongLine(line, output)\n  output2 = [line.rstrip() for line in output]\n  return '\\n'.join(output2) + '\\n'\n\n\ndef ConvertFromPumpSource(src_text):\n  \"\"\"Return the text generated from the given Pump source text.\"\"\"\n  ast = ParseToAST(StripMetaComments(src_text))\n  output = Output()\n  RunCode(Env(), ast, output)\n  return BeautifyCode(output.string)\n\n\ndef main(argv):\n  if len(argv) == 1:\n    print __doc__\n    sys.exit(1)\n\n  file_path = argv[-1]\n  output_str = ConvertFromPumpSource(file(file_path, 'r').read())\n  if file_path.endswith('.pump'):\n    output_file_path = file_path[:-5]\n  else:\n    output_file_path = '-'\n  if output_file_path == '-':\n    print output_str,\n  else:\n    output_file = file(output_file_path, 'w')\n    output_file.write('// This file was GENERATED by command:\\n')\n    output_file.write('//     %s %s\\n' %\n                      (os.path.basename(__file__), os.path.basename(file_path)))\n    output_file.write('// DO NOT EDIT BY HAND!!!\\n\\n')\n    output_file.write(output_str)\n    output_file.close()\n\n\nif __name__ == '__main__':\n  main(sys.argv)\n"
  },
  {
    "path": "ext/gtest/scripts/test/Makefile",
    "content": "# A Makefile for fusing Google Test and building a sample test against it.\n#\n# SYNOPSIS:\n#\n#   make [all]  - makes everything.\n#   make TARGET - makes the given target.\n#   make check  - makes everything and runs the built sample test.\n#   make clean  - removes all files generated by make.\n\n# Points to the root of fused Google Test, relative to where this file is.\nFUSED_GTEST_DIR = output\n\n# Paths to the fused gtest files.\nFUSED_GTEST_H = $(FUSED_GTEST_DIR)/gtest/gtest.h\nFUSED_GTEST_ALL_CC = $(FUSED_GTEST_DIR)/gtest/gtest-all.cc\n\n# Where to find the sample test.\nSAMPLE_DIR = ../../samples\n\n# Where to find gtest_main.cc.\nGTEST_MAIN_CC = ../../src/gtest_main.cc\n\n# Flags passed to the preprocessor.\n# We have no idea here whether pthreads is available in the system, so\n# disable its use.\nCPPFLAGS += -I$(FUSED_GTEST_DIR) -DGTEST_HAS_PTHREAD=0\n\n# Flags passed to the C++ compiler.\nCXXFLAGS += -g\n\nall : sample1_unittest\n\ncheck : all\n\t./sample1_unittest\n\nclean :\n\trm -rf $(FUSED_GTEST_DIR) sample1_unittest *.o\n\n$(FUSED_GTEST_H) :\n\t../fuse_gtest_files.py $(FUSED_GTEST_DIR)\n\n$(FUSED_GTEST_ALL_CC) :\n\t../fuse_gtest_files.py $(FUSED_GTEST_DIR)\n\ngtest-all.o : $(FUSED_GTEST_H) $(FUSED_GTEST_ALL_CC)\n\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(FUSED_GTEST_DIR)/gtest/gtest-all.cc\n\ngtest_main.o : $(FUSED_GTEST_H) $(GTEST_MAIN_CC)\n\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(GTEST_MAIN_CC)\n\nsample1.o : $(SAMPLE_DIR)/sample1.cc $(SAMPLE_DIR)/sample1.h\n\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1.cc\n\nsample1_unittest.o : $(SAMPLE_DIR)/sample1_unittest.cc \\\n                     $(SAMPLE_DIR)/sample1.h $(FUSED_GTEST_H)\n\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/sample1_unittest.cc\n\nsample1_unittest : sample1.o sample1_unittest.o gtest-all.o gtest_main.o\n\t$(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $@\n"
  },
  {
    "path": "ext/gtest/scripts/upload.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2007 Google Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\n\"\"\"Tool for uploading diffs from a version control system to the codereview app.\n\nUsage summary: upload.py [options] [-- diff_options]\n\nDiff options are passed to the diff command of the underlying system.\n\nSupported version control systems:\n  Git\n  Mercurial\n  Subversion\n\nIt is important for Git/Mercurial users to specify a tree/node/branch to diff\nagainst by using the '--rev' option.\n\"\"\"\n# This code is derived from appcfg.py in the App Engine SDK (open source),\n# and from ASPN recipe #146306.\n\nimport cookielib\nimport getpass\nimport logging\nimport md5\nimport mimetypes\nimport optparse\nimport os\nimport re\nimport socket\nimport subprocess\nimport sys\nimport urllib\nimport urllib2\nimport urlparse\n\ntry:\n  import readline\nexcept ImportError:\n  pass\n\n# The logging verbosity:\n#  0: Errors only.\n#  1: Status messages.\n#  2: Info logs.\n#  3: Debug logs.\nverbosity = 1\n\n# Max size of patch or base file.\nMAX_UPLOAD_SIZE = 900 * 1024\n\n\ndef GetEmail(prompt):\n  \"\"\"Prompts the user for their email address and returns it.\n\n  The last used email address is saved to a file and offered up as a suggestion\n  to the user. If the user presses enter without typing in anything the last\n  used email address is used. If the user enters a new address, it is saved\n  for next time we prompt.\n\n  \"\"\"\n  last_email_file_name = os.path.expanduser(\"~/.last_codereview_email_address\")\n  last_email = \"\"\n  if os.path.exists(last_email_file_name):\n    try:\n      last_email_file = open(last_email_file_name, \"r\")\n      last_email = last_email_file.readline().strip(\"\\n\")\n      last_email_file.close()\n      prompt += \" [%s]\" % last_email\n    except IOError, e:\n      pass\n  email = raw_input(prompt + \": \").strip()\n  if email:\n    try:\n      last_email_file = open(last_email_file_name, \"w\")\n      last_email_file.write(email)\n      last_email_file.close()\n    except IOError, e:\n      pass\n  else:\n    email = last_email\n  return email\n\n\ndef StatusUpdate(msg):\n  \"\"\"Print a status message to stdout.\n\n  If 'verbosity' is greater than 0, print the message.\n\n  Args:\n    msg: The string to print.\n  \"\"\"\n  if verbosity > 0:\n    print msg\n\n\ndef ErrorExit(msg):\n  \"\"\"Print an error message to stderr and exit.\"\"\"\n  print >>sys.stderr, msg\n  sys.exit(1)\n\n\nclass ClientLoginError(urllib2.HTTPError):\n  \"\"\"Raised to indicate there was an error authenticating with ClientLogin.\"\"\"\n\n  def __init__(self, url, code, msg, headers, args):\n    urllib2.HTTPError.__init__(self, url, code, msg, headers, None)\n    self.args = args\n    self.reason = args[\"Error\"]\n\n\nclass AbstractRpcServer(object):\n  \"\"\"Provides a common interface for a simple RPC server.\"\"\"\n\n  def __init__(self, host, auth_function, host_override=None, extra_headers={},\n               save_cookies=False):\n    \"\"\"Creates a new HttpRpcServer.\n\n    Args:\n      host: The host to send requests to.\n      auth_function: A function that takes no arguments and returns an\n        (email, password) tuple when called. Will be called if authentication\n        is required.\n      host_override: The host header to send to the server (defaults to host).\n      extra_headers: A dict of extra headers to append to every request.\n      save_cookies: If True, save the authentication cookies to local disk.\n        If False, use an in-memory cookiejar instead.  Subclasses must\n        implement this functionality.  Defaults to False.\n    \"\"\"\n    self.host = host\n    self.host_override = host_override\n    self.auth_function = auth_function\n    self.authenticated = False\n    self.extra_headers = extra_headers\n    self.save_cookies = save_cookies\n    self.opener = self._GetOpener()\n    if self.host_override:\n      logging.info(\"Server: %s; Host: %s\", self.host, self.host_override)\n    else:\n      logging.info(\"Server: %s\", self.host)\n\n  def _GetOpener(self):\n    \"\"\"Returns an OpenerDirector for making HTTP requests.\n\n    Returns:\n      A urllib2.OpenerDirector object.\n    \"\"\"\n    raise NotImplementedError()\n\n  def _CreateRequest(self, url, data=None):\n    \"\"\"Creates a new urllib request.\"\"\"\n    logging.debug(\"Creating request for: '%s' with payload:\\n%s\", url, data)\n    req = urllib2.Request(url, data=data)\n    if self.host_override:\n      req.add_header(\"Host\", self.host_override)\n    for key, value in self.extra_headers.iteritems():\n      req.add_header(key, value)\n    return req\n\n  def _GetAuthToken(self, email, password):\n    \"\"\"Uses ClientLogin to authenticate the user, returning an auth token.\n\n    Args:\n      email:    The user's email address\n      password: The user's password\n\n    Raises:\n      ClientLoginError: If there was an error authenticating with ClientLogin.\n      HTTPError: If there was some other form of HTTP error.\n\n    Returns:\n      The authentication token returned by ClientLogin.\n    \"\"\"\n    account_type = \"GOOGLE\"\n    if self.host.endswith(\".google.com\"):\n      # Needed for use inside Google.\n      account_type = \"HOSTED\"\n    req = self._CreateRequest(\n        url=\"https://www.google.com/accounts/ClientLogin\",\n        data=urllib.urlencode({\n            \"Email\": email,\n            \"Passwd\": password,\n            \"service\": \"ah\",\n            \"source\": \"rietveld-codereview-upload\",\n            \"accountType\": account_type,\n        }),\n    )\n    try:\n      response = self.opener.open(req)\n      response_body = response.read()\n      response_dict = dict(x.split(\"=\")\n                           for x in response_body.split(\"\\n\") if x)\n      return response_dict[\"Auth\"]\n    except urllib2.HTTPError, e:\n      if e.code == 403:\n        body = e.read()\n        response_dict = dict(x.split(\"=\", 1) for x in body.split(\"\\n\") if x)\n        raise ClientLoginError(req.get_full_url(), e.code, e.msg,\n                               e.headers, response_dict)\n      else:\n        raise\n\n  def _GetAuthCookie(self, auth_token):\n    \"\"\"Fetches authentication cookies for an authentication token.\n\n    Args:\n      auth_token: The authentication token returned by ClientLogin.\n\n    Raises:\n      HTTPError: If there was an error fetching the authentication cookies.\n    \"\"\"\n    # This is a dummy value to allow us to identify when we're successful.\n    continue_location = \"http://localhost/\"\n    args = {\"continue\": continue_location, \"auth\": auth_token}\n    req = self._CreateRequest(\"http://%s/_ah/login?%s\" %\n                              (self.host, urllib.urlencode(args)))\n    try:\n      response = self.opener.open(req)\n    except urllib2.HTTPError, e:\n      response = e\n    if (response.code != 302 or\n        response.info()[\"location\"] != continue_location):\n      raise urllib2.HTTPError(req.get_full_url(), response.code, response.msg,\n                              response.headers, response.fp)\n    self.authenticated = True\n\n  def _Authenticate(self):\n    \"\"\"Authenticates the user.\n\n    The authentication process works as follows:\n     1) We get a username and password from the user\n     2) We use ClientLogin to obtain an AUTH token for the user\n        (see http://code.google.com/apis/accounts/AuthForInstalledApps.html).\n     3) We pass the auth token to /_ah/login on the server to obtain an\n        authentication cookie. If login was successful, it tries to redirect\n        us to the URL we provided.\n\n    If we attempt to access the upload API without first obtaining an\n    authentication cookie, it returns a 401 response and directs us to\n    authenticate ourselves with ClientLogin.\n    \"\"\"\n    for i in range(3):\n      credentials = self.auth_function()\n      try:\n        auth_token = self._GetAuthToken(credentials[0], credentials[1])\n      except ClientLoginError, e:\n        if e.reason == \"BadAuthentication\":\n          print >>sys.stderr, \"Invalid username or password.\"\n          continue\n        if e.reason == \"CaptchaRequired\":\n          print >>sys.stderr, (\n              \"Please go to\\n\"\n              \"https://www.google.com/accounts/DisplayUnlockCaptcha\\n\"\n              \"and verify you are a human.  Then try again.\")\n          break\n        if e.reason == \"NotVerified\":\n          print >>sys.stderr, \"Account not verified.\"\n          break\n        if e.reason == \"TermsNotAgreed\":\n          print >>sys.stderr, \"User has not agreed to TOS.\"\n          break\n        if e.reason == \"AccountDeleted\":\n          print >>sys.stderr, \"The user account has been deleted.\"\n          break\n        if e.reason == \"AccountDisabled\":\n          print >>sys.stderr, \"The user account has been disabled.\"\n          break\n        if e.reason == \"ServiceDisabled\":\n          print >>sys.stderr, (\"The user's access to the service has been \"\n                               \"disabled.\")\n          break\n        if e.reason == \"ServiceUnavailable\":\n          print >>sys.stderr, \"The service is not available; try again later.\"\n          break\n        raise\n      self._GetAuthCookie(auth_token)\n      return\n\n  def Send(self, request_path, payload=None,\n           content_type=\"application/octet-stream\",\n           timeout=None,\n           **kwargs):\n    \"\"\"Sends an RPC and returns the response.\n\n    Args:\n      request_path: The path to send the request to, eg /api/appversion/create.\n      payload: The body of the request, or None to send an empty request.\n      content_type: The Content-Type header to use.\n      timeout: timeout in seconds; default None i.e. no timeout.\n        (Note: for large requests on OS X, the timeout doesn't work right.)\n      kwargs: Any keyword arguments are converted into query string parameters.\n\n    Returns:\n      The response body, as a string.\n    \"\"\"\n    # TODO: Don't require authentication.  Let the server say\n    # whether it is necessary.\n    if not self.authenticated:\n      self._Authenticate()\n\n    old_timeout = socket.getdefaulttimeout()\n    socket.setdefaulttimeout(timeout)\n    try:\n      tries = 0\n      while True:\n        tries += 1\n        args = dict(kwargs)\n        url = \"http://%s%s\" % (self.host, request_path)\n        if args:\n          url += \"?\" + urllib.urlencode(args)\n        req = self._CreateRequest(url=url, data=payload)\n        req.add_header(\"Content-Type\", content_type)\n        try:\n          f = self.opener.open(req)\n          response = f.read()\n          f.close()\n          return response\n        except urllib2.HTTPError, e:\n          if tries > 3:\n            raise\n          elif e.code == 401:\n            self._Authenticate()\n##           elif e.code >= 500 and e.code < 600:\n##             # Server Error - try again.\n##             continue\n          else:\n            raise\n    finally:\n      socket.setdefaulttimeout(old_timeout)\n\n\nclass HttpRpcServer(AbstractRpcServer):\n  \"\"\"Provides a simplified RPC-style interface for HTTP requests.\"\"\"\n\n  def _Authenticate(self):\n    \"\"\"Save the cookie jar after authentication.\"\"\"\n    super(HttpRpcServer, self)._Authenticate()\n    if self.save_cookies:\n      StatusUpdate(\"Saving authentication cookies to %s\" % self.cookie_file)\n      self.cookie_jar.save()\n\n  def _GetOpener(self):\n    \"\"\"Returns an OpenerDirector that supports cookies and ignores redirects.\n\n    Returns:\n      A urllib2.OpenerDirector object.\n    \"\"\"\n    opener = urllib2.OpenerDirector()\n    opener.add_handler(urllib2.ProxyHandler())\n    opener.add_handler(urllib2.UnknownHandler())\n    opener.add_handler(urllib2.HTTPHandler())\n    opener.add_handler(urllib2.HTTPDefaultErrorHandler())\n    opener.add_handler(urllib2.HTTPSHandler())\n    opener.add_handler(urllib2.HTTPErrorProcessor())\n    if self.save_cookies:\n      self.cookie_file = os.path.expanduser(\"~/.codereview_upload_cookies\")\n      self.cookie_jar = cookielib.MozillaCookieJar(self.cookie_file)\n      if os.path.exists(self.cookie_file):\n        try:\n          self.cookie_jar.load()\n          self.authenticated = True\n          StatusUpdate(\"Loaded authentication cookies from %s\" %\n                       self.cookie_file)\n        except (cookielib.LoadError, IOError):\n          # Failed to load cookies - just ignore them.\n          pass\n      else:\n        # Create an empty cookie file with mode 600\n        fd = os.open(self.cookie_file, os.O_CREAT, 0600)\n        os.close(fd)\n      # Always chmod the cookie file\n      os.chmod(self.cookie_file, 0600)\n    else:\n      # Don't save cookies across runs of update.py.\n      self.cookie_jar = cookielib.CookieJar()\n    opener.add_handler(urllib2.HTTPCookieProcessor(self.cookie_jar))\n    return opener\n\n\nparser = optparse.OptionParser(usage=\"%prog [options] [-- diff_options]\")\nparser.add_option(\"-y\", \"--assume_yes\", action=\"store_true\",\n                  dest=\"assume_yes\", default=False,\n                  help=\"Assume that the answer to yes/no questions is 'yes'.\")\n# Logging\ngroup = parser.add_option_group(\"Logging options\")\ngroup.add_option(\"-q\", \"--quiet\", action=\"store_const\", const=0,\n                 dest=\"verbose\", help=\"Print errors only.\")\ngroup.add_option(\"-v\", \"--verbose\", action=\"store_const\", const=2,\n                 dest=\"verbose\", default=1,\n                 help=\"Print info level logs (default).\")\ngroup.add_option(\"--noisy\", action=\"store_const\", const=3,\n                 dest=\"verbose\", help=\"Print all logs.\")\n# Review server\ngroup = parser.add_option_group(\"Review server options\")\ngroup.add_option(\"-s\", \"--server\", action=\"store\", dest=\"server\",\n                 default=\"codereview.appspot.com\",\n                 metavar=\"SERVER\",\n                 help=(\"The server to upload to. The format is host[:port]. \"\n                       \"Defaults to 'codereview.appspot.com'.\"))\ngroup.add_option(\"-e\", \"--email\", action=\"store\", dest=\"email\",\n                 metavar=\"EMAIL\", default=None,\n                 help=\"The username to use. Will prompt if omitted.\")\ngroup.add_option(\"-H\", \"--host\", action=\"store\", dest=\"host\",\n                 metavar=\"HOST\", default=None,\n                 help=\"Overrides the Host header sent with all RPCs.\")\ngroup.add_option(\"--no_cookies\", action=\"store_false\",\n                 dest=\"save_cookies\", default=True,\n                 help=\"Do not save authentication cookies to local disk.\")\n# Issue\ngroup = parser.add_option_group(\"Issue options\")\ngroup.add_option(\"-d\", \"--description\", action=\"store\", dest=\"description\",\n                 metavar=\"DESCRIPTION\", default=None,\n                 help=\"Optional description when creating an issue.\")\ngroup.add_option(\"-f\", \"--description_file\", action=\"store\",\n                 dest=\"description_file\", metavar=\"DESCRIPTION_FILE\",\n                 default=None,\n                 help=\"Optional path of a file that contains \"\n                      \"the description when creating an issue.\")\ngroup.add_option(\"-r\", \"--reviewers\", action=\"store\", dest=\"reviewers\",\n                 metavar=\"REVIEWERS\", default=None,\n                 help=\"Add reviewers (comma separated email addresses).\")\ngroup.add_option(\"--cc\", action=\"store\", dest=\"cc\",\n                 metavar=\"CC\", default=None,\n                 help=\"Add CC (comma separated email addresses).\")\n# Upload options\ngroup = parser.add_option_group(\"Patch options\")\ngroup.add_option(\"-m\", \"--message\", action=\"store\", dest=\"message\",\n                 metavar=\"MESSAGE\", default=None,\n                 help=\"A message to identify the patch. \"\n                      \"Will prompt if omitted.\")\ngroup.add_option(\"-i\", \"--issue\", type=\"int\", action=\"store\",\n                 metavar=\"ISSUE\", default=None,\n                 help=\"Issue number to which to add. Defaults to new issue.\")\ngroup.add_option(\"--download_base\", action=\"store_true\",\n                 dest=\"download_base\", default=False,\n                 help=\"Base files will be downloaded by the server \"\n                 \"(side-by-side diffs may not work on files with CRs).\")\ngroup.add_option(\"--rev\", action=\"store\", dest=\"revision\",\n                 metavar=\"REV\", default=None,\n                 help=\"Branch/tree/revision to diff against (used by DVCS).\")\ngroup.add_option(\"--send_mail\", action=\"store_true\",\n                 dest=\"send_mail\", default=False,\n                 help=\"Send notification email to reviewers.\")\n\n\ndef GetRpcServer(options):\n  \"\"\"Returns an instance of an AbstractRpcServer.\n\n  Returns:\n    A new AbstractRpcServer, on which RPC calls can be made.\n  \"\"\"\n\n  rpc_server_class = HttpRpcServer\n\n  def GetUserCredentials():\n    \"\"\"Prompts the user for a username and password.\"\"\"\n    email = options.email\n    if email is None:\n      email = GetEmail(\"Email (login for uploading to %s)\" % options.server)\n    password = getpass.getpass(\"Password for %s: \" % email)\n    return (email, password)\n\n  # If this is the dev_appserver, use fake authentication.\n  host = (options.host or options.server).lower()\n  if host == \"localhost\" or host.startswith(\"localhost:\"):\n    email = options.email\n    if email is None:\n      email = \"test@example.com\"\n      logging.info(\"Using debug user %s.  Override with --email\" % email)\n    server = rpc_server_class(\n        options.server,\n        lambda: (email, \"password\"),\n        host_override=options.host,\n        extra_headers={\"Cookie\":\n                       'dev_appserver_login=\"%s:False\"' % email},\n        save_cookies=options.save_cookies)\n    # Don't try to talk to ClientLogin.\n    server.authenticated = True\n    return server\n\n  return rpc_server_class(options.server, GetUserCredentials,\n                          host_override=options.host,\n                          save_cookies=options.save_cookies)\n\n\ndef EncodeMultipartFormData(fields, files):\n  \"\"\"Encode form fields for multipart/form-data.\n\n  Args:\n    fields: A sequence of (name, value) elements for regular form fields.\n    files: A sequence of (name, filename, value) elements for data to be\n           uploaded as files.\n  Returns:\n    (content_type, body) ready for httplib.HTTP instance.\n\n  Source:\n    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306\n  \"\"\"\n  BOUNDARY = '-M-A-G-I-C---B-O-U-N-D-A-R-Y-'\n  CRLF = '\\r\\n'\n  lines = []\n  for (key, value) in fields:\n    lines.append('--' + BOUNDARY)\n    lines.append('Content-Disposition: form-data; name=\"%s\"' % key)\n    lines.append('')\n    lines.append(value)\n  for (key, filename, value) in files:\n    lines.append('--' + BOUNDARY)\n    lines.append('Content-Disposition: form-data; name=\"%s\"; filename=\"%s\"' %\n             (key, filename))\n    lines.append('Content-Type: %s' % GetContentType(filename))\n    lines.append('')\n    lines.append(value)\n  lines.append('--' + BOUNDARY + '--')\n  lines.append('')\n  body = CRLF.join(lines)\n  content_type = 'multipart/form-data; boundary=%s' % BOUNDARY\n  return content_type, body\n\n\ndef GetContentType(filename):\n  \"\"\"Helper to guess the content-type from the filename.\"\"\"\n  return mimetypes.guess_type(filename)[0] or 'application/octet-stream'\n\n\n# Use a shell for subcommands on Windows to get a PATH search.\nuse_shell = sys.platform.startswith(\"win\")\n\ndef RunShellWithReturnCode(command, print_output=False,\n                           universal_newlines=True):\n  \"\"\"Executes a command and returns the output from stdout and the return code.\n\n  Args:\n    command: Command to execute.\n    print_output: If True, the output is printed to stdout.\n                  If False, both stdout and stderr are ignored.\n    universal_newlines: Use universal_newlines flag (default: True).\n\n  Returns:\n    Tuple (output, return code)\n  \"\"\"\n  logging.info(\"Running %s\", command)\n  p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE,\n                       shell=use_shell, universal_newlines=universal_newlines)\n  if print_output:\n    output_array = []\n    while True:\n      line = p.stdout.readline()\n      if not line:\n        break\n      print line.strip(\"\\n\")\n      output_array.append(line)\n    output = \"\".join(output_array)\n  else:\n    output = p.stdout.read()\n  p.wait()\n  errout = p.stderr.read()\n  if print_output and errout:\n    print >>sys.stderr, errout\n  p.stdout.close()\n  p.stderr.close()\n  return output, p.returncode\n\n\ndef RunShell(command, silent_ok=False, universal_newlines=True,\n             print_output=False):\n  data, retcode = RunShellWithReturnCode(command, print_output,\n                                         universal_newlines)\n  if retcode:\n    ErrorExit(\"Got error status from %s:\\n%s\" % (command, data))\n  if not silent_ok and not data:\n    ErrorExit(\"No output from %s\" % command)\n  return data\n\n\nclass VersionControlSystem(object):\n  \"\"\"Abstract base class providing an interface to the VCS.\"\"\"\n\n  def __init__(self, options):\n    \"\"\"Constructor.\n\n    Args:\n      options: Command line options.\n    \"\"\"\n    self.options = options\n\n  def GenerateDiff(self, args):\n    \"\"\"Return the current diff as a string.\n\n    Args:\n      args: Extra arguments to pass to the diff command.\n    \"\"\"\n    raise NotImplementedError(\n        \"abstract method -- subclass %s must override\" % self.__class__)\n\n  def GetUnknownFiles(self):\n    \"\"\"Return a list of files unknown to the VCS.\"\"\"\n    raise NotImplementedError(\n        \"abstract method -- subclass %s must override\" % self.__class__)\n\n  def CheckForUnknownFiles(self):\n    \"\"\"Show an \"are you sure?\" prompt if there are unknown files.\"\"\"\n    unknown_files = self.GetUnknownFiles()\n    if unknown_files:\n      print \"The following files are not added to version control:\"\n      for line in unknown_files:\n        print line\n      prompt = \"Are you sure to continue?(y/N) \"\n      answer = raw_input(prompt).strip()\n      if answer != \"y\":\n        ErrorExit(\"User aborted\")\n\n  def GetBaseFile(self, filename):\n    \"\"\"Get the content of the upstream version of a file.\n\n    Returns:\n      A tuple (base_content, new_content, is_binary, status)\n        base_content: The contents of the base file.\n        new_content: For text files, this is empty.  For binary files, this is\n          the contents of the new file, since the diff output won't contain\n          information to reconstruct the current file.\n        is_binary: True iff the file is binary.\n        status: The status of the file.\n    \"\"\"\n\n    raise NotImplementedError(\n        \"abstract method -- subclass %s must override\" % self.__class__)\n\n\n  def GetBaseFiles(self, diff):\n    \"\"\"Helper that calls GetBase file for each file in the patch.\n\n    Returns:\n      A dictionary that maps from filename to GetBaseFile's tuple.  Filenames\n      are retrieved based on lines that start with \"Index:\" or\n      \"Property changes on:\".\n    \"\"\"\n    files = {}\n    for line in diff.splitlines(True):\n      if line.startswith('Index:') or line.startswith('Property changes on:'):\n        unused, filename = line.split(':', 1)\n        # On Windows if a file has property changes its filename uses '\\'\n        # instead of '/'.\n        filename = filename.strip().replace('\\\\', '/')\n        files[filename] = self.GetBaseFile(filename)\n    return files\n\n\n  def UploadBaseFiles(self, issue, rpc_server, patch_list, patchset, options,\n                      files):\n    \"\"\"Uploads the base files (and if necessary, the current ones as well).\"\"\"\n\n    def UploadFile(filename, file_id, content, is_binary, status, is_base):\n      \"\"\"Uploads a file to the server.\"\"\"\n      file_too_large = False\n      if is_base:\n        type = \"base\"\n      else:\n        type = \"current\"\n      if len(content) > MAX_UPLOAD_SIZE:\n        print (\"Not uploading the %s file for %s because it's too large.\" %\n               (type, filename))\n        file_too_large = True\n        content = \"\"\n      checksum = md5.new(content).hexdigest()\n      if options.verbose > 0 and not file_too_large:\n        print \"Uploading %s file for %s\" % (type, filename)\n      url = \"/%d/upload_content/%d/%d\" % (int(issue), int(patchset), file_id)\n      form_fields = [(\"filename\", filename),\n                     (\"status\", status),\n                     (\"checksum\", checksum),\n                     (\"is_binary\", str(is_binary)),\n                     (\"is_current\", str(not is_base)),\n                    ]\n      if file_too_large:\n        form_fields.append((\"file_too_large\", \"1\"))\n      if options.email:\n        form_fields.append((\"user\", options.email))\n      ctype, body = EncodeMultipartFormData(form_fields,\n                                            [(\"data\", filename, content)])\n      response_body = rpc_server.Send(url, body,\n                                      content_type=ctype)\n      if not response_body.startswith(\"OK\"):\n        StatusUpdate(\"  --> %s\" % response_body)\n        sys.exit(1)\n\n    patches = dict()\n    [patches.setdefault(v, k) for k, v in patch_list]\n    for filename in patches.keys():\n      base_content, new_content, is_binary, status = files[filename]\n      file_id_str = patches.get(filename)\n      if file_id_str.find(\"nobase\") != -1:\n        base_content = None\n        file_id_str = file_id_str[file_id_str.rfind(\"_\") + 1:]\n      file_id = int(file_id_str)\n      if base_content != None:\n        UploadFile(filename, file_id, base_content, is_binary, status, True)\n      if new_content != None:\n        UploadFile(filename, file_id, new_content, is_binary, status, False)\n\n  def IsImage(self, filename):\n    \"\"\"Returns true if the filename has an image extension.\"\"\"\n    mimetype =  mimetypes.guess_type(filename)[0]\n    if not mimetype:\n      return False\n    return mimetype.startswith(\"image/\")\n\n\nclass SubversionVCS(VersionControlSystem):\n  \"\"\"Implementation of the VersionControlSystem interface for Subversion.\"\"\"\n\n  def __init__(self, options):\n    super(SubversionVCS, self).__init__(options)\n    if self.options.revision:\n      match = re.match(r\"(\\d+)(:(\\d+))?\", self.options.revision)\n      if not match:\n        ErrorExit(\"Invalid Subversion revision %s.\" % self.options.revision)\n      self.rev_start = match.group(1)\n      self.rev_end = match.group(3)\n    else:\n      self.rev_start = self.rev_end = None\n    # Cache output from \"svn list -r REVNO dirname\".\n    # Keys: dirname, Values: 2-tuple (ouput for start rev and end rev).\n    self.svnls_cache = {}\n    # SVN base URL is required to fetch files deleted in an older revision.\n    # Result is cached to not guess it over and over again in GetBaseFile().\n    required = self.options.download_base or self.options.revision is not None\n    self.svn_base = self._GuessBase(required)\n\n  def GuessBase(self, required):\n    \"\"\"Wrapper for _GuessBase.\"\"\"\n    return self.svn_base\n\n  def _GuessBase(self, required):\n    \"\"\"Returns the SVN base URL.\n\n    Args:\n      required: If true, exits if the url can't be guessed, otherwise None is\n        returned.\n    \"\"\"\n    info = RunShell([\"svn\", \"info\"])\n    for line in info.splitlines():\n      words = line.split()\n      if len(words) == 2 and words[0] == \"URL:\":\n        url = words[1]\n        scheme, netloc, path, params, query, fragment = urlparse.urlparse(url)\n        username, netloc = urllib.splituser(netloc)\n        if username:\n          logging.info(\"Removed username from base URL\")\n        if netloc.endswith(\"svn.python.org\"):\n          if netloc == \"svn.python.org\":\n            if path.startswith(\"/projects/\"):\n              path = path[9:]\n          elif netloc != \"pythondev@svn.python.org\":\n            ErrorExit(\"Unrecognized Python URL: %s\" % url)\n          base = \"http://svn.python.org/view/*checkout*%s/\" % path\n          logging.info(\"Guessed Python base = %s\", base)\n        elif netloc.endswith(\"svn.collab.net\"):\n          if path.startswith(\"/repos/\"):\n            path = path[6:]\n          base = \"http://svn.collab.net/viewvc/*checkout*%s/\" % path\n          logging.info(\"Guessed CollabNet base = %s\", base)\n        elif netloc.endswith(\".googlecode.com\"):\n          path = path + \"/\"\n          base = urlparse.urlunparse((\"http\", netloc, path, params,\n                                      query, fragment))\n          logging.info(\"Guessed Google Code base = %s\", base)\n        else:\n          path = path + \"/\"\n          base = urlparse.urlunparse((scheme, netloc, path, params,\n                                      query, fragment))\n          logging.info(\"Guessed base = %s\", base)\n        return base\n    if required:\n      ErrorExit(\"Can't find URL in output from svn info\")\n    return None\n\n  def GenerateDiff(self, args):\n    cmd = [\"svn\", \"diff\"]\n    if self.options.revision:\n      cmd += [\"-r\", self.options.revision]\n    cmd.extend(args)\n    data = RunShell(cmd)\n    count = 0\n    for line in data.splitlines():\n      if line.startswith(\"Index:\") or line.startswith(\"Property changes on:\"):\n        count += 1\n        logging.info(line)\n    if not count:\n      ErrorExit(\"No valid patches found in output from svn diff\")\n    return data\n\n  def _CollapseKeywords(self, content, keyword_str):\n    \"\"\"Collapses SVN keywords.\"\"\"\n    # svn cat translates keywords but svn diff doesn't. As a result of this\n    # behavior patching.PatchChunks() fails with a chunk mismatch error.\n    # This part was originally written by the Review Board development team\n    # who had the same problem (http://reviews.review-board.org/r/276/).\n    # Mapping of keywords to known aliases\n    svn_keywords = {\n      # Standard keywords\n      'Date':                ['Date', 'LastChangedDate'],\n      'Revision':            ['Revision', 'LastChangedRevision', 'Rev'],\n      'Author':              ['Author', 'LastChangedBy'],\n      'HeadURL':             ['HeadURL', 'URL'],\n      'Id':                  ['Id'],\n\n      # Aliases\n      'LastChangedDate':     ['LastChangedDate', 'Date'],\n      'LastChangedRevision': ['LastChangedRevision', 'Rev', 'Revision'],\n      'LastChangedBy':       ['LastChangedBy', 'Author'],\n      'URL':                 ['URL', 'HeadURL'],\n    }\n\n    def repl(m):\n       if m.group(2):\n         return \"$%s::%s$\" % (m.group(1), \" \" * len(m.group(3)))\n       return \"$%s$\" % m.group(1)\n    keywords = [keyword\n                for name in keyword_str.split(\" \")\n                for keyword in svn_keywords.get(name, [])]\n    return re.sub(r\"\\$(%s):(:?)([^\\$]+)\\$\" % '|'.join(keywords), repl, content)\n\n  def GetUnknownFiles(self):\n    status = RunShell([\"svn\", \"status\", \"--ignore-externals\"], silent_ok=True)\n    unknown_files = []\n    for line in status.split(\"\\n\"):\n      if line and line[0] == \"?\":\n        unknown_files.append(line)\n    return unknown_files\n\n  def ReadFile(self, filename):\n    \"\"\"Returns the contents of a file.\"\"\"\n    file = open(filename, 'rb')\n    result = \"\"\n    try:\n      result = file.read()\n    finally:\n      file.close()\n    return result\n\n  def GetStatus(self, filename):\n    \"\"\"Returns the status of a file.\"\"\"\n    if not self.options.revision:\n      status = RunShell([\"svn\", \"status\", \"--ignore-externals\", filename])\n      if not status:\n        ErrorExit(\"svn status returned no output for %s\" % filename)\n      status_lines = status.splitlines()\n      # If file is in a cl, the output will begin with\n      # \"\\n--- Changelist 'cl_name':\\n\".  See\n      # http://svn.collab.net/repos/svn/trunk/notes/changelist-design.txt\n      if (len(status_lines) == 3 and\n          not status_lines[0] and\n          status_lines[1].startswith(\"--- Changelist\")):\n        status = status_lines[2]\n      else:\n        status = status_lines[0]\n    # If we have a revision to diff against we need to run \"svn list\"\n    # for the old and the new revision and compare the results to get\n    # the correct status for a file.\n    else:\n      dirname, relfilename = os.path.split(filename)\n      if dirname not in self.svnls_cache:\n        cmd = [\"svn\", \"list\", \"-r\", self.rev_start, dirname or \".\"]\n        out, returncode = RunShellWithReturnCode(cmd)\n        if returncode:\n          ErrorExit(\"Failed to get status for %s.\" % filename)\n        old_files = out.splitlines()\n        args = [\"svn\", \"list\"]\n        if self.rev_end:\n          args += [\"-r\", self.rev_end]\n        cmd = args + [dirname or \".\"]\n        out, returncode = RunShellWithReturnCode(cmd)\n        if returncode:\n          ErrorExit(\"Failed to run command %s\" % cmd)\n        self.svnls_cache[dirname] = (old_files, out.splitlines())\n      old_files, new_files = self.svnls_cache[dirname]\n      if relfilename in old_files and relfilename not in new_files:\n        status = \"D   \"\n      elif relfilename in old_files and relfilename in new_files:\n        status = \"M   \"\n      else:\n        status = \"A   \"\n    return status\n\n  def GetBaseFile(self, filename):\n    status = self.GetStatus(filename)\n    base_content = None\n    new_content = None\n\n    # If a file is copied its status will be \"A  +\", which signifies\n    # \"addition-with-history\".  See \"svn st\" for more information.  We need to\n    # upload the original file or else diff parsing will fail if the file was\n    # edited.\n    if status[0] == \"A\" and status[3] != \"+\":\n      # We'll need to upload the new content if we're adding a binary file\n      # since diff's output won't contain it.\n      mimetype = RunShell([\"svn\", \"propget\", \"svn:mime-type\", filename],\n                          silent_ok=True)\n      base_content = \"\"\n      is_binary = mimetype and not mimetype.startswith(\"text/\")\n      if is_binary and self.IsImage(filename):\n        new_content = self.ReadFile(filename)\n    elif (status[0] in (\"M\", \"D\", \"R\") or\n          (status[0] == \"A\" and status[3] == \"+\") or  # Copied file.\n          (status[0] == \" \" and status[1] == \"M\")):  # Property change.\n      args = []\n      if self.options.revision:\n        url = \"%s/%s@%s\" % (self.svn_base, filename, self.rev_start)\n      else:\n        # Don't change filename, it's needed later.\n        url = filename\n        args += [\"-r\", \"BASE\"]\n      cmd = [\"svn\"] + args + [\"propget\", \"svn:mime-type\", url]\n      mimetype, returncode = RunShellWithReturnCode(cmd)\n      if returncode:\n        # File does not exist in the requested revision.\n        # Reset mimetype, it contains an error message.\n        mimetype = \"\"\n      get_base = False\n      is_binary = mimetype and not mimetype.startswith(\"text/\")\n      if status[0] == \" \":\n        # Empty base content just to force an upload.\n        base_content = \"\"\n      elif is_binary:\n        if self.IsImage(filename):\n          get_base = True\n          if status[0] == \"M\":\n            if not self.rev_end:\n              new_content = self.ReadFile(filename)\n            else:\n              url = \"%s/%s@%s\" % (self.svn_base, filename, self.rev_end)\n              new_content = RunShell([\"svn\", \"cat\", url],\n                                     universal_newlines=True, silent_ok=True)\n        else:\n          base_content = \"\"\n      else:\n        get_base = True\n\n      if get_base:\n        if is_binary:\n          universal_newlines = False\n        else:\n          universal_newlines = True\n        if self.rev_start:\n          # \"svn cat -r REV delete_file.txt\" doesn't work. cat requires\n          # the full URL with \"@REV\" appended instead of using \"-r\" option.\n          url = \"%s/%s@%s\" % (self.svn_base, filename, self.rev_start)\n          base_content = RunShell([\"svn\", \"cat\", url],\n                                  universal_newlines=universal_newlines,\n                                  silent_ok=True)\n        else:\n          base_content = RunShell([\"svn\", \"cat\", filename],\n                                  universal_newlines=universal_newlines,\n                                  silent_ok=True)\n        if not is_binary:\n          args = []\n          if self.rev_start:\n            url = \"%s/%s@%s\" % (self.svn_base, filename, self.rev_start)\n          else:\n            url = filename\n            args += [\"-r\", \"BASE\"]\n          cmd = [\"svn\"] + args + [\"propget\", \"svn:keywords\", url]\n          keywords, returncode = RunShellWithReturnCode(cmd)\n          if keywords and not returncode:\n            base_content = self._CollapseKeywords(base_content, keywords)\n    else:\n      StatusUpdate(\"svn status returned unexpected output: %s\" % status)\n      sys.exit(1)\n    return base_content, new_content, is_binary, status[0:5]\n\n\nclass GitVCS(VersionControlSystem):\n  \"\"\"Implementation of the VersionControlSystem interface for Git.\"\"\"\n\n  def __init__(self, options):\n    super(GitVCS, self).__init__(options)\n    # Map of filename -> hash of base file.\n    self.base_hashes = {}\n\n  def GenerateDiff(self, extra_args):\n    # This is more complicated than svn's GenerateDiff because we must convert\n    # the diff output to include an svn-style \"Index:\" line as well as record\n    # the hashes of the base files, so we can upload them along with our diff.\n    if self.options.revision:\n      extra_args = [self.options.revision] + extra_args\n    gitdiff = RunShell([\"git\", \"diff\", \"--full-index\"] + extra_args)\n    svndiff = []\n    filecount = 0\n    filename = None\n    for line in gitdiff.splitlines():\n      match = re.match(r\"diff --git a/(.*) b/.*$\", line)\n      if match:\n        filecount += 1\n        filename = match.group(1)\n        svndiff.append(\"Index: %s\\n\" % filename)\n      else:\n        # The \"index\" line in a git diff looks like this (long hashes elided):\n        #   index 82c0d44..b2cee3f 100755\n        # We want to save the left hash, as that identifies the base file.\n        match = re.match(r\"index (\\w+)\\.\\.\", line)\n        if match:\n          self.base_hashes[filename] = match.group(1)\n      svndiff.append(line + \"\\n\")\n    if not filecount:\n      ErrorExit(\"No valid patches found in output from git diff\")\n    return \"\".join(svndiff)\n\n  def GetUnknownFiles(self):\n    status = RunShell([\"git\", \"ls-files\", \"--exclude-standard\", \"--others\"],\n                      silent_ok=True)\n    return status.splitlines()\n\n  def GetBaseFile(self, filename):\n    hash = self.base_hashes[filename]\n    base_content = None\n    new_content = None\n    is_binary = False\n    if hash == \"0\" * 40:  # All-zero hash indicates no base file.\n      status = \"A\"\n      base_content = \"\"\n    else:\n      status = \"M\"\n      base_content, returncode = RunShellWithReturnCode([\"git\", \"show\", hash])\n      if returncode:\n        ErrorExit(\"Got error status from 'git show %s'\" % hash)\n    return (base_content, new_content, is_binary, status)\n\n\nclass MercurialVCS(VersionControlSystem):\n  \"\"\"Implementation of the VersionControlSystem interface for Mercurial.\"\"\"\n\n  def __init__(self, options, repo_dir):\n    super(MercurialVCS, self).__init__(options)\n    # Absolute path to repository (we can be in a subdir)\n    self.repo_dir = os.path.normpath(repo_dir)\n    # Compute the subdir\n    cwd = os.path.normpath(os.getcwd())\n    assert cwd.startswith(self.repo_dir)\n    self.subdir = cwd[len(self.repo_dir):].lstrip(r\"\\/\")\n    if self.options.revision:\n      self.base_rev = self.options.revision\n    else:\n      self.base_rev = RunShell([\"hg\", \"parent\", \"-q\"]).split(':')[1].strip()\n\n  def _GetRelPath(self, filename):\n    \"\"\"Get relative path of a file according to the current directory,\n    given its logical path in the repo.\"\"\"\n    assert filename.startswith(self.subdir), filename\n    return filename[len(self.subdir):].lstrip(r\"\\/\")\n\n  def GenerateDiff(self, extra_args):\n    # If no file specified, restrict to the current subdir\n    extra_args = extra_args or [\".\"]\n    cmd = [\"hg\", \"diff\", \"--git\", \"-r\", self.base_rev] + extra_args\n    data = RunShell(cmd, silent_ok=True)\n    svndiff = []\n    filecount = 0\n    for line in data.splitlines():\n      m = re.match(\"diff --git a/(\\S+) b/(\\S+)\", line)\n      if m:\n        # Modify line to make it look like as it comes from svn diff.\n        # With this modification no changes on the server side are required\n        # to make upload.py work with Mercurial repos.\n        # NOTE: for proper handling of moved/copied files, we have to use\n        # the second filename.\n        filename = m.group(2)\n        svndiff.append(\"Index: %s\" % filename)\n        svndiff.append(\"=\" * 67)\n        filecount += 1\n        logging.info(line)\n      else:\n        svndiff.append(line)\n    if not filecount:\n      ErrorExit(\"No valid patches found in output from hg diff\")\n    return \"\\n\".join(svndiff) + \"\\n\"\n\n  def GetUnknownFiles(self):\n    \"\"\"Return a list of files unknown to the VCS.\"\"\"\n    args = []\n    status = RunShell([\"hg\", \"status\", \"--rev\", self.base_rev, \"-u\", \".\"],\n        silent_ok=True)\n    unknown_files = []\n    for line in status.splitlines():\n      st, fn = line.split(\" \", 1)\n      if st == \"?\":\n        unknown_files.append(fn)\n    return unknown_files\n\n  def GetBaseFile(self, filename):\n    # \"hg status\" and \"hg cat\" both take a path relative to the current subdir\n    # rather than to the repo root, but \"hg diff\" has given us the full path\n    # to the repo root.\n    base_content = \"\"\n    new_content = None\n    is_binary = False\n    oldrelpath = relpath = self._GetRelPath(filename)\n    # \"hg status -C\" returns two lines for moved/copied files, one otherwise\n    out = RunShell([\"hg\", \"status\", \"-C\", \"--rev\", self.base_rev, relpath])\n    out = out.splitlines()\n    # HACK: strip error message about missing file/directory if it isn't in\n    # the working copy\n    if out[0].startswith('%s: ' % relpath):\n      out = out[1:]\n    if len(out) > 1:\n      # Moved/copied => considered as modified, use old filename to\n      # retrieve base contents\n      oldrelpath = out[1].strip()\n      status = \"M\"\n    else:\n      status, _ = out[0].split(' ', 1)\n    if status != \"A\":\n      base_content = RunShell([\"hg\", \"cat\", \"-r\", self.base_rev, oldrelpath],\n        silent_ok=True)\n      is_binary = \"\\0\" in base_content  # Mercurial's heuristic\n    if status != \"R\":\n      new_content = open(relpath, \"rb\").read()\n      is_binary = is_binary or \"\\0\" in new_content\n    if is_binary and base_content:\n      # Fetch again without converting newlines\n      base_content = RunShell([\"hg\", \"cat\", \"-r\", self.base_rev, oldrelpath],\n        silent_ok=True, universal_newlines=False)\n    if not is_binary or not self.IsImage(relpath):\n      new_content = None\n    return base_content, new_content, is_binary, status\n\n\n# NOTE: The SplitPatch function is duplicated in engine.py, keep them in sync.\ndef SplitPatch(data):\n  \"\"\"Splits a patch into separate pieces for each file.\n\n  Args:\n    data: A string containing the output of svn diff.\n\n  Returns:\n    A list of 2-tuple (filename, text) where text is the svn diff output\n      pertaining to filename.\n  \"\"\"\n  patches = []\n  filename = None\n  diff = []\n  for line in data.splitlines(True):\n    new_filename = None\n    if line.startswith('Index:'):\n      unused, new_filename = line.split(':', 1)\n      new_filename = new_filename.strip()\n    elif line.startswith('Property changes on:'):\n      unused, temp_filename = line.split(':', 1)\n      # When a file is modified, paths use '/' between directories, however\n      # when a property is modified '\\' is used on Windows.  Make them the same\n      # otherwise the file shows up twice.\n      temp_filename = temp_filename.strip().replace('\\\\', '/')\n      if temp_filename != filename:\n        # File has property changes but no modifications, create a new diff.\n        new_filename = temp_filename\n    if new_filename:\n      if filename and diff:\n        patches.append((filename, ''.join(diff)))\n      filename = new_filename\n      diff = [line]\n      continue\n    if diff is not None:\n      diff.append(line)\n  if filename and diff:\n    patches.append((filename, ''.join(diff)))\n  return patches\n\n\ndef UploadSeparatePatches(issue, rpc_server, patchset, data, options):\n  \"\"\"Uploads a separate patch for each file in the diff output.\n\n  Returns a list of [patch_key, filename] for each file.\n  \"\"\"\n  patches = SplitPatch(data)\n  rv = []\n  for patch in patches:\n    if len(patch[1]) > MAX_UPLOAD_SIZE:\n      print (\"Not uploading the patch for \" + patch[0] +\n             \" because the file is too large.\")\n      continue\n    form_fields = [(\"filename\", patch[0])]\n    if not options.download_base:\n      form_fields.append((\"content_upload\", \"1\"))\n    files = [(\"data\", \"data.diff\", patch[1])]\n    ctype, body = EncodeMultipartFormData(form_fields, files)\n    url = \"/%d/upload_patch/%d\" % (int(issue), int(patchset))\n    print \"Uploading patch for \" + patch[0]\n    response_body = rpc_server.Send(url, body, content_type=ctype)\n    lines = response_body.splitlines()\n    if not lines or lines[0] != \"OK\":\n      StatusUpdate(\"  --> %s\" % response_body)\n      sys.exit(1)\n    rv.append([lines[1], patch[0]])\n  return rv\n\n\ndef GuessVCS(options):\n  \"\"\"Helper to guess the version control system.\n\n  This examines the current directory, guesses which VersionControlSystem\n  we're using, and returns an instance of the appropriate class.  Exit with an\n  error if we can't figure it out.\n\n  Returns:\n    A VersionControlSystem instance. Exits if the VCS can't be guessed.\n  \"\"\"\n  # Mercurial has a command to get the base directory of a repository\n  # Try running it, but don't die if we don't have hg installed.\n  # NOTE: we try Mercurial first as it can sit on top of an SVN working copy.\n  try:\n    out, returncode = RunShellWithReturnCode([\"hg\", \"root\"])\n    if returncode == 0:\n      return MercurialVCS(options, out.strip())\n  except OSError, (errno, message):\n    if errno != 2:  # ENOENT -- they don't have hg installed.\n      raise\n\n  # Subversion has a .svn in all working directories.\n  if os.path.isdir('.svn'):\n    logging.info(\"Guessed VCS = Subversion\")\n    return SubversionVCS(options)\n\n  # Git has a command to test if you're in a git tree.\n  # Try running it, but don't die if we don't have git installed.\n  try:\n    out, returncode = RunShellWithReturnCode([\"git\", \"rev-parse\",\n                                              \"--is-inside-work-tree\"])\n    if returncode == 0:\n      return GitVCS(options)\n  except OSError, (errno, message):\n    if errno != 2:  # ENOENT -- they don't have git installed.\n      raise\n\n  ErrorExit((\"Could not guess version control system. \"\n             \"Are you in a working copy directory?\"))\n\n\ndef RealMain(argv, data=None):\n  \"\"\"The real main function.\n\n  Args:\n    argv: Command line arguments.\n    data: Diff contents. If None (default) the diff is generated by\n      the VersionControlSystem implementation returned by GuessVCS().\n\n  Returns:\n    A 2-tuple (issue id, patchset id).\n    The patchset id is None if the base files are not uploaded by this\n    script (applies only to SVN checkouts).\n  \"\"\"\n  logging.basicConfig(format=(\"%(asctime).19s %(levelname)s %(filename)s:\"\n                              \"%(lineno)s %(message)s \"))\n  os.environ['LC_ALL'] = 'C'\n  options, args = parser.parse_args(argv[1:])\n  global verbosity\n  verbosity = options.verbose\n  if verbosity >= 3:\n    logging.getLogger().setLevel(logging.DEBUG)\n  elif verbosity >= 2:\n    logging.getLogger().setLevel(logging.INFO)\n  vcs = GuessVCS(options)\n  if isinstance(vcs, SubversionVCS):\n    # base field is only allowed for Subversion.\n    # Note: Fetching base files may become deprecated in future releases.\n    base = vcs.GuessBase(options.download_base)\n  else:\n    base = None\n  if not base and options.download_base:\n    options.download_base = True\n    logging.info(\"Enabled upload of base file\")\n  if not options.assume_yes:\n    vcs.CheckForUnknownFiles()\n  if data is None:\n    data = vcs.GenerateDiff(args)\n  files = vcs.GetBaseFiles(data)\n  if verbosity >= 1:\n    print \"Upload server:\", options.server, \"(change with -s/--server)\"\n  if options.issue:\n    prompt = \"Message describing this patch set: \"\n  else:\n    prompt = \"New issue subject: \"\n  message = options.message or raw_input(prompt).strip()\n  if not message:\n    ErrorExit(\"A non-empty message is required\")\n  rpc_server = GetRpcServer(options)\n  form_fields = [(\"subject\", message)]\n  if base:\n    form_fields.append((\"base\", base))\n  if options.issue:\n    form_fields.append((\"issue\", str(options.issue)))\n  if options.email:\n    form_fields.append((\"user\", options.email))\n  if options.reviewers:\n    for reviewer in options.reviewers.split(','):\n      if \"@\" in reviewer and not reviewer.split(\"@\")[1].count(\".\") == 1:\n        ErrorExit(\"Invalid email address: %s\" % reviewer)\n    form_fields.append((\"reviewers\", options.reviewers))\n  if options.cc:\n    for cc in options.cc.split(','):\n      if \"@\" in cc and not cc.split(\"@\")[1].count(\".\") == 1:\n        ErrorExit(\"Invalid email address: %s\" % cc)\n    form_fields.append((\"cc\", options.cc))\n  description = options.description\n  if options.description_file:\n    if options.description:\n      ErrorExit(\"Can't specify description and description_file\")\n    file = open(options.description_file, 'r')\n    description = file.read()\n    file.close()\n  if description:\n    form_fields.append((\"description\", description))\n  # Send a hash of all the base file so the server can determine if a copy\n  # already exists in an earlier patchset.\n  base_hashes = \"\"\n  for file, info in files.iteritems():\n    if not info[0] is None:\n      checksum = md5.new(info[0]).hexdigest()\n      if base_hashes:\n        base_hashes += \"|\"\n      base_hashes += checksum + \":\" + file\n  form_fields.append((\"base_hashes\", base_hashes))\n  # If we're uploading base files, don't send the email before the uploads, so\n  # that it contains the file status.\n  if options.send_mail and options.download_base:\n    form_fields.append((\"send_mail\", \"1\"))\n  if not options.download_base:\n    form_fields.append((\"content_upload\", \"1\"))\n  if len(data) > MAX_UPLOAD_SIZE:\n    print \"Patch is large, so uploading file patches separately.\"\n    uploaded_diff_file = []\n    form_fields.append((\"separate_patches\", \"1\"))\n  else:\n    uploaded_diff_file = [(\"data\", \"data.diff\", data)]\n  ctype, body = EncodeMultipartFormData(form_fields, uploaded_diff_file)\n  response_body = rpc_server.Send(\"/upload\", body, content_type=ctype)\n  patchset = None\n  if not options.download_base or not uploaded_diff_file:\n    lines = response_body.splitlines()\n    if len(lines) >= 2:\n      msg = lines[0]\n      patchset = lines[1].strip()\n      patches = [x.split(\" \", 1) for x in lines[2:]]\n    else:\n      msg = response_body\n  else:\n    msg = response_body\n  StatusUpdate(msg)\n  if not response_body.startswith(\"Issue created.\") and \\\n  not response_body.startswith(\"Issue updated.\"):\n    sys.exit(0)\n  issue = msg[msg.rfind(\"/\")+1:]\n\n  if not uploaded_diff_file:\n    result = UploadSeparatePatches(issue, rpc_server, patchset, data, options)\n    if not options.download_base:\n      patches = result\n\n  if not options.download_base:\n    vcs.UploadBaseFiles(issue, rpc_server, patches, patchset, options, files)\n    if options.send_mail:\n      rpc_server.Send(\"/\" + issue + \"/mail\", payload=\"\")\n  return issue, patchset\n\n\ndef main():\n  try:\n    RealMain(sys.argv)\n  except KeyboardInterrupt:\n    print\n    StatusUpdate(\"Interrupted.\")\n    sys.exit(1)\n\n\nif __name__ == \"__main__\":\n  main()\n"
  },
  {
    "path": "ext/gtest/scripts/upload_gtest.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2009, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"upload_gtest.py v0.1.0 -- uploads a Google Test patch for review.\n\nThis simple wrapper passes all command line flags and\n--cc=googletestframework@googlegroups.com to upload.py.\n\nUSAGE: upload_gtest.py [options for upload.py]\n\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport sys\n\nCC_FLAG = '--cc='\nGTEST_GROUP = 'googletestframework@googlegroups.com'\n\n\ndef main():\n  # Finds the path to upload.py, assuming it is in the same directory\n  # as this file.\n  my_dir = os.path.dirname(os.path.abspath(__file__))\n  upload_py_path = os.path.join(my_dir, 'upload.py')\n\n  # Adds Google Test discussion group to the cc line if it's not there\n  # already.\n  upload_py_argv = [upload_py_path]\n  found_cc_flag = False\n  for arg in sys.argv[1:]:\n    if arg.startswith(CC_FLAG):\n      found_cc_flag = True\n      cc_line = arg[len(CC_FLAG):]\n      cc_list = [addr for addr in cc_line.split(',') if addr]\n      if GTEST_GROUP not in cc_list:\n        cc_list.append(GTEST_GROUP)\n      upload_py_argv.append(CC_FLAG + ','.join(cc_list))\n    else:\n      upload_py_argv.append(arg)\n\n  if not found_cc_flag:\n    upload_py_argv.append(CC_FLAG + GTEST_GROUP)\n\n  # Invokes upload.py with the modified command line flags.\n  os.execv(upload_py_path, upload_py_argv)\n\n\nif __name__ == '__main__':\n  main()\n"
  },
  {
    "path": "ext/gtest/src/gtest-all.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: mheule@google.com (Markus Heule)\n//\n// Google C++ Testing Framework (Google Test)\n//\n// Sometimes it's desirable to build Google Test by compiling a single file.\n// This file serves this purpose.\n\n// This line ensures that gtest.h can be compiled on its own, even\n// when it's fused.\n#include \"gtest/gtest.h\"\n\n// The following lines pull in the real gtest *.cc files.\n#include \"src/gtest.cc\"\n#include \"src/gtest-death-test.cc\"\n#include \"src/gtest-filepath.cc\"\n#include \"src/gtest-port.cc\"\n#include \"src/gtest-printers.cc\"\n#include \"src/gtest-test-part.cc\"\n#include \"src/gtest-typed-test.cc\"\n"
  },
  {
    "path": "ext/gtest/src/gtest-death-test.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan), vladl@google.com (Vlad Losev)\n//\n// This file implements death tests.\n\n#include \"gtest/gtest-death-test.h\"\n#include \"gtest/internal/gtest-port.h\"\n\n#if GTEST_HAS_DEATH_TEST\n\n# if GTEST_OS_MAC\n#  include <crt_externs.h>\n# endif  // GTEST_OS_MAC\n\n# include <errno.h>\n# include <fcntl.h>\n# include <limits.h>\n\n# if GTEST_OS_LINUX\n#  include <signal.h>\n# endif  // GTEST_OS_LINUX\n\n# include <stdarg.h>\n\n# if GTEST_OS_WINDOWS\n#  include <windows.h>\n# else\n#  include <sys/mman.h>\n#  include <sys/wait.h>\n# endif  // GTEST_OS_WINDOWS\n\n# if GTEST_OS_QNX\n#  include <spawn.h>\n# endif  // GTEST_OS_QNX\n\n#endif  // GTEST_HAS_DEATH_TEST\n\n#include \"gtest/gtest-message.h\"\n#include \"gtest/internal/gtest-string.h\"\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick is to\n// prevent a user from accidentally including gtest-internal-inl.h in\n// his code.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\nnamespace testing {\n\n// Constants.\n\n// The default death test style.\nstatic const char kDefaultDeathTestStyle[] = \"fast\";\n\nGTEST_DEFINE_string_(\n    death_test_style,\n    internal::StringFromGTestEnv(\"death_test_style\", kDefaultDeathTestStyle),\n    \"Indicates how to run a death test in a forked child process: \"\n    \"\\\"threadsafe\\\" (child process re-executes the test binary \"\n    \"from the beginning, running only the specific death test) or \"\n    \"\\\"fast\\\" (child process runs the death test immediately \"\n    \"after forking).\");\n\nGTEST_DEFINE_bool_(\n    death_test_use_fork,\n    internal::BoolFromGTestEnv(\"death_test_use_fork\", false),\n    \"Instructs to use fork()/_exit() instead of clone() in death tests. \"\n    \"Ignored and always uses fork() on POSIX systems where clone() is not \"\n    \"implemented. Useful when running under valgrind or similar tools if \"\n    \"those do not support clone(). Valgrind 3.3.1 will just fail if \"\n    \"it sees an unsupported combination of clone() flags. \"\n    \"It is not recommended to use this flag w/o valgrind though it will \"\n    \"work in 99% of the cases. Once valgrind is fixed, this flag will \"\n    \"most likely be removed.\");\n\nnamespace internal {\nGTEST_DEFINE_string_(\n    internal_run_death_test, \"\",\n    \"Indicates the file, line number, temporal index of \"\n    \"the single death test to run, and a file descriptor to \"\n    \"which a success code may be sent, all separated by \"\n    \"the '|' characters.  This flag is specified if and only if the current \"\n    \"process is a sub-process launched for running a thread-safe \"\n    \"death test.  FOR INTERNAL USE ONLY.\");\n}  // namespace internal\n\n#if GTEST_HAS_DEATH_TEST\n\nnamespace internal {\n\n// Valid only for fast death tests. Indicates the code is running in the\n// child process of a fast style death test.\nstatic bool g_in_fast_death_test_child = false;\n\n// Returns a Boolean value indicating whether the caller is currently\n// executing in the context of the death test child process.  Tools such as\n// Valgrind heap checkers may need this to modify their behavior in death\n// tests.  IMPORTANT: This is an internal utility.  Using it may break the\n// implementation of death tests.  User code MUST NOT use it.\nbool InDeathTestChild() {\n# if GTEST_OS_WINDOWS\n\n  // On Windows, death tests are thread-safe regardless of the value of the\n  // death_test_style flag.\n  return !GTEST_FLAG(internal_run_death_test).empty();\n\n# else\n\n  if (GTEST_FLAG(death_test_style) == \"threadsafe\")\n    return !GTEST_FLAG(internal_run_death_test).empty();\n  else\n    return g_in_fast_death_test_child;\n#endif\n}\n\n}  // namespace internal\n\n// ExitedWithCode constructor.\nExitedWithCode::ExitedWithCode(int exit_code) : exit_code_(exit_code) {\n}\n\n// ExitedWithCode function-call operator.\nbool ExitedWithCode::operator()(int exit_status) const {\n# if GTEST_OS_WINDOWS\n\n  return exit_status == exit_code_;\n\n# else\n\n  return WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == exit_code_;\n\n# endif  // GTEST_OS_WINDOWS\n}\n\n# if !GTEST_OS_WINDOWS\n// KilledBySignal constructor.\nKilledBySignal::KilledBySignal(int signum) : signum_(signum) {\n}\n\n// KilledBySignal function-call operator.\nbool KilledBySignal::operator()(int exit_status) const {\n  return WIFSIGNALED(exit_status) && WTERMSIG(exit_status) == signum_;\n}\n# endif  // !GTEST_OS_WINDOWS\n\nnamespace internal {\n\n// Utilities needed for death tests.\n\n// Generates a textual description of a given exit code, in the format\n// specified by wait(2).\nstatic std::string ExitSummary(int exit_code) {\n  Message m;\n\n# if GTEST_OS_WINDOWS\n\n  m << \"Exited with exit status \" << exit_code;\n\n# else\n\n  if (WIFEXITED(exit_code)) {\n    m << \"Exited with exit status \" << WEXITSTATUS(exit_code);\n  } else if (WIFSIGNALED(exit_code)) {\n    m << \"Terminated by signal \" << WTERMSIG(exit_code);\n  }\n#  ifdef WCOREDUMP\n  if (WCOREDUMP(exit_code)) {\n    m << \" (core dumped)\";\n  }\n#  endif\n# endif  // GTEST_OS_WINDOWS\n\n  return m.GetString();\n}\n\n// Returns true if exit_status describes a process that was terminated\n// by a signal, or exited normally with a nonzero exit code.\nbool ExitedUnsuccessfully(int exit_status) {\n  return !ExitedWithCode(0)(exit_status);\n}\n\n# if !GTEST_OS_WINDOWS\n// Generates a textual failure message when a death test finds more than\n// one thread running, or cannot determine the number of threads, prior\n// to executing the given statement.  It is the responsibility of the\n// caller not to pass a thread_count of 1.\nstatic std::string DeathTestThreadWarning(size_t thread_count) {\n  Message msg;\n  msg << \"Death tests use fork(), which is unsafe particularly\"\n      << \" in a threaded context. For this test, \" << GTEST_NAME_ << \" \";\n  if (thread_count == 0)\n    msg << \"couldn't detect the number of threads.\";\n  else\n    msg << \"detected \" << thread_count << \" threads.\";\n  return msg.GetString();\n}\n# endif  // !GTEST_OS_WINDOWS\n\n// Flag characters for reporting a death test that did not die.\nstatic const char kDeathTestLived = 'L';\nstatic const char kDeathTestReturned = 'R';\nstatic const char kDeathTestThrew = 'T';\nstatic const char kDeathTestInternalError = 'I';\n\n// An enumeration describing all of the possible ways that a death test can\n// conclude.  DIED means that the process died while executing the test\n// code; LIVED means that process lived beyond the end of the test code;\n// RETURNED means that the test statement attempted to execute a return\n// statement, which is not allowed; THREW means that the test statement\n// returned control by throwing an exception.  IN_PROGRESS means the test\n// has not yet concluded.\n// TODO(vladl@google.com): Unify names and possibly values for\n// AbortReason, DeathTestOutcome, and flag characters above.\nenum DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW };\n\n// Routine for aborting the program which is safe to call from an\n// exec-style death test child process, in which case the error\n// message is propagated back to the parent process.  Otherwise, the\n// message is simply printed to stderr.  In either case, the program\n// then exits with status 1.\nvoid DeathTestAbort(const std::string& message) {\n  // On a POSIX system, this function may be called from a threadsafe-style\n  // death test child process, which operates on a very small stack.  Use\n  // the heap for any additional non-minuscule memory requirements.\n  const InternalRunDeathTestFlag* const flag =\n      GetUnitTestImpl()->internal_run_death_test_flag();\n  if (flag != NULL) {\n    FILE* parent = posix::FDOpen(flag->write_fd(), \"w\");\n    fputc(kDeathTestInternalError, parent);\n    fprintf(parent, \"%s\", message.c_str());\n    fflush(parent);\n    _exit(1);\n  } else {\n    fprintf(stderr, \"%s\", message.c_str());\n    fflush(stderr);\n    posix::Abort();\n  }\n}\n\n// A replacement for CHECK that calls DeathTestAbort if the assertion\n// fails.\n# define GTEST_DEATH_TEST_CHECK_(expression) \\\n  do { \\\n    if (!::testing::internal::IsTrue(expression)) { \\\n      DeathTestAbort( \\\n          ::std::string(\"CHECK failed: File \") + __FILE__ +  \", line \" \\\n          + ::testing::internal::StreamableToString(__LINE__) + \": \" \\\n          + #expression); \\\n    } \\\n  } while (::testing::internal::AlwaysFalse())\n\n// This macro is similar to GTEST_DEATH_TEST_CHECK_, but it is meant for\n// evaluating any system call that fulfills two conditions: it must return\n// -1 on failure, and set errno to EINTR when it is interrupted and\n// should be tried again.  The macro expands to a loop that repeatedly\n// evaluates the expression as long as it evaluates to -1 and sets\n// errno to EINTR.  If the expression evaluates to -1 but errno is\n// something other than EINTR, DeathTestAbort is called.\n# define GTEST_DEATH_TEST_CHECK_SYSCALL_(expression) \\\n  do { \\\n    int gtest_retval; \\\n    do { \\\n      gtest_retval = (expression); \\\n    } while (gtest_retval == -1 && errno == EINTR); \\\n    if (gtest_retval == -1) { \\\n      DeathTestAbort( \\\n          ::std::string(\"CHECK failed: File \") + __FILE__ + \", line \" \\\n          + ::testing::internal::StreamableToString(__LINE__) + \": \" \\\n          + #expression + \" != -1\"); \\\n    } \\\n  } while (::testing::internal::AlwaysFalse())\n\n// Returns the message describing the last system error in errno.\nstd::string GetLastErrnoDescription() {\n    return errno == 0 ? \"\" : posix::StrError(errno);\n}\n\n// This is called from a death test parent process to read a failure\n// message from the death test child process and log it with the FATAL\n// severity. On Windows, the message is read from a pipe handle. On other\n// platforms, it is read from a file descriptor.\nstatic void FailFromInternalError(int fd) {\n  Message error;\n  char buffer[256];\n  int num_read;\n\n  do {\n    while ((num_read = posix::Read(fd, buffer, 255)) > 0) {\n      buffer[num_read] = '\\0';\n      error << buffer;\n    }\n  } while (num_read == -1 && errno == EINTR);\n\n  if (num_read == 0) {\n    GTEST_LOG_(FATAL) << error.GetString();\n  } else {\n    const int last_error = errno;\n    GTEST_LOG_(FATAL) << \"Error while reading death test internal: \"\n                      << GetLastErrnoDescription() << \" [\" << last_error << \"]\";\n  }\n}\n\n// Death test constructor.  Increments the running death test count\n// for the current test.\nDeathTest::DeathTest() {\n  TestInfo* const info = GetUnitTestImpl()->current_test_info();\n  if (info == NULL) {\n    DeathTestAbort(\"Cannot run a death test outside of a TEST or \"\n                   \"TEST_F construct\");\n  }\n}\n\n// Creates and returns a death test by dispatching to the current\n// death test factory.\nbool DeathTest::Create(const char* statement, const RE* regex,\n                       const char* file, int line, DeathTest** test) {\n  return GetUnitTestImpl()->death_test_factory()->Create(\n      statement, regex, file, line, test);\n}\n\nconst char* DeathTest::LastMessage() {\n  return last_death_test_message_.c_str();\n}\n\nvoid DeathTest::set_last_death_test_message(const std::string& message) {\n  last_death_test_message_ = message;\n}\n\nstd::string DeathTest::last_death_test_message_;\n\n// Provides cross platform implementation for some death functionality.\nclass DeathTestImpl : public DeathTest {\n protected:\n  DeathTestImpl(const char* a_statement, const RE* a_regex)\n      : statement_(a_statement),\n        regex_(a_regex),\n        spawned_(false),\n        status_(-1),\n        outcome_(IN_PROGRESS),\n        read_fd_(-1),\n        write_fd_(-1) {}\n\n  // read_fd_ is expected to be closed and cleared by a derived class.\n  ~DeathTestImpl() { GTEST_DEATH_TEST_CHECK_(read_fd_ == -1); }\n\n  void Abort(AbortReason reason);\n  virtual bool Passed(bool status_ok);\n\n  const char* statement() const { return statement_; }\n  const RE* regex() const { return regex_; }\n  bool spawned() const { return spawned_; }\n  void set_spawned(bool is_spawned) { spawned_ = is_spawned; }\n  int status() const { return status_; }\n  void set_status(int a_status) { status_ = a_status; }\n  DeathTestOutcome outcome() const { return outcome_; }\n  void set_outcome(DeathTestOutcome an_outcome) { outcome_ = an_outcome; }\n  int read_fd() const { return read_fd_; }\n  void set_read_fd(int fd) { read_fd_ = fd; }\n  int write_fd() const { return write_fd_; }\n  void set_write_fd(int fd) { write_fd_ = fd; }\n\n  // Called in the parent process only. Reads the result code of the death\n  // test child process via a pipe, interprets it to set the outcome_\n  // member, and closes read_fd_.  Outputs diagnostics and terminates in\n  // case of unexpected codes.\n  void ReadAndInterpretStatusByte();\n\n private:\n  // The textual content of the code this object is testing.  This class\n  // doesn't own this string and should not attempt to delete it.\n  const char* const statement_;\n  // The regular expression which test output must match.  DeathTestImpl\n  // doesn't own this object and should not attempt to delete it.\n  const RE* const regex_;\n  // True if the death test child process has been successfully spawned.\n  bool spawned_;\n  // The exit status of the child process.\n  int status_;\n  // How the death test concluded.\n  DeathTestOutcome outcome_;\n  // Descriptor to the read end of the pipe to the child process.  It is\n  // always -1 in the child process.  The child keeps its write end of the\n  // pipe in write_fd_.\n  int read_fd_;\n  // Descriptor to the child's write end of the pipe to the parent process.\n  // It is always -1 in the parent process.  The parent keeps its end of the\n  // pipe in read_fd_.\n  int write_fd_;\n};\n\n// Called in the parent process only. Reads the result code of the death\n// test child process via a pipe, interprets it to set the outcome_\n// member, and closes read_fd_.  Outputs diagnostics and terminates in\n// case of unexpected codes.\nvoid DeathTestImpl::ReadAndInterpretStatusByte() {\n  char flag;\n  int bytes_read;\n\n  // The read() here blocks until data is available (signifying the\n  // failure of the death test) or until the pipe is closed (signifying\n  // its success), so it's okay to call this in the parent before\n  // the child process has exited.\n  do {\n    bytes_read = posix::Read(read_fd(), &flag, 1);\n  } while (bytes_read == -1 && errno == EINTR);\n\n  if (bytes_read == 0) {\n    set_outcome(DIED);\n  } else if (bytes_read == 1) {\n    switch (flag) {\n      case kDeathTestReturned:\n        set_outcome(RETURNED);\n        break;\n      case kDeathTestThrew:\n        set_outcome(THREW);\n        break;\n      case kDeathTestLived:\n        set_outcome(LIVED);\n        break;\n      case kDeathTestInternalError:\n        FailFromInternalError(read_fd());  // Does not return.\n        break;\n      default:\n        GTEST_LOG_(FATAL) << \"Death test child process reported \"\n                          << \"unexpected status byte (\"\n                          << static_cast<unsigned int>(flag) << \")\";\n    }\n  } else {\n    GTEST_LOG_(FATAL) << \"Read from death test child process failed: \"\n                      << GetLastErrnoDescription();\n  }\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Close(read_fd()));\n  set_read_fd(-1);\n}\n\n// Signals that the death test code which should have exited, didn't.\n// Should be called only in a death test child process.\n// Writes a status byte to the child's status file descriptor, then\n// calls _exit(1).\nvoid DeathTestImpl::Abort(AbortReason reason) {\n  // The parent process considers the death test to be a failure if\n  // it finds any data in our pipe.  So, here we write a single flag byte\n  // to the pipe, then exit.\n  const char status_ch =\n      reason == TEST_DID_NOT_DIE ? kDeathTestLived :\n      reason == TEST_THREW_EXCEPTION ? kDeathTestThrew : kDeathTestReturned;\n\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Write(write_fd(), &status_ch, 1));\n  // We are leaking the descriptor here because on some platforms (i.e.,\n  // when built as Windows DLL), destructors of global objects will still\n  // run after calling _exit(). On such systems, write_fd_ will be\n  // indirectly closed from the destructor of UnitTestImpl, causing double\n  // close if it is also closed here. On debug configurations, double close\n  // may assert. As there are no in-process buffers to flush here, we are\n  // relying on the OS to close the descriptor after the process terminates\n  // when the destructors are not run.\n  _exit(1);  // Exits w/o any normal exit hooks (we were supposed to crash)\n}\n\n// Returns an indented copy of stderr output for a death test.\n// This makes distinguishing death test output lines from regular log lines\n// much easier.\nstatic ::std::string FormatDeathTestOutput(const ::std::string& output) {\n  ::std::string ret;\n  for (size_t at = 0; ; ) {\n    const size_t line_end = output.find('\\n', at);\n    ret += \"[  DEATH   ] \";\n    if (line_end == ::std::string::npos) {\n      ret += output.substr(at);\n      break;\n    }\n    ret += output.substr(at, line_end + 1 - at);\n    at = line_end + 1;\n  }\n  return ret;\n}\n\n// Assesses the success or failure of a death test, using both private\n// members which have previously been set, and one argument:\n//\n// Private data members:\n//   outcome:  An enumeration describing how the death test\n//             concluded: DIED, LIVED, THREW, or RETURNED.  The death test\n//             fails in the latter three cases.\n//   status:   The exit status of the child process. On *nix, it is in the\n//             in the format specified by wait(2). On Windows, this is the\n//             value supplied to the ExitProcess() API or a numeric code\n//             of the exception that terminated the program.\n//   regex:    A regular expression object to be applied to\n//             the test's captured standard error output; the death test\n//             fails if it does not match.\n//\n// Argument:\n//   status_ok: true if exit_status is acceptable in the context of\n//              this particular death test, which fails if it is false\n//\n// Returns true iff all of the above conditions are met.  Otherwise, the\n// first failing condition, in the order given above, is the one that is\n// reported. Also sets the last death test message string.\nbool DeathTestImpl::Passed(bool status_ok) {\n  if (!spawned())\n    return false;\n\n  const std::string error_message = GetCapturedStderr();\n\n  bool success = false;\n  Message buffer;\n\n  buffer << \"Death test: \" << statement() << \"\\n\";\n  switch (outcome()) {\n    case LIVED:\n      buffer << \"    Result: failed to die.\\n\"\n             << \" Error msg:\\n\" << FormatDeathTestOutput(error_message);\n      break;\n    case THREW:\n      buffer << \"    Result: threw an exception.\\n\"\n             << \" Error msg:\\n\" << FormatDeathTestOutput(error_message);\n      break;\n    case RETURNED:\n      buffer << \"    Result: illegal return in test statement.\\n\"\n             << \" Error msg:\\n\" << FormatDeathTestOutput(error_message);\n      break;\n    case DIED:\n      if (status_ok) {\n        const bool matched = RE::PartialMatch(error_message.c_str(), *regex());\n        if (matched) {\n          success = true;\n        } else {\n          buffer << \"    Result: died but not with expected error.\\n\"\n                 << \"  Expected: \" << regex()->pattern() << \"\\n\"\n                 << \"Actual msg:\\n\" << FormatDeathTestOutput(error_message);\n        }\n      } else {\n        buffer << \"    Result: died but not with expected exit code:\\n\"\n               << \"            \" << ExitSummary(status()) << \"\\n\"\n               << \"Actual msg:\\n\" << FormatDeathTestOutput(error_message);\n      }\n      break;\n    case IN_PROGRESS:\n    default:\n      GTEST_LOG_(FATAL)\n          << \"DeathTest::Passed somehow called before conclusion of test\";\n  }\n\n  DeathTest::set_last_death_test_message(buffer.GetString());\n  return success;\n}\n\n# if GTEST_OS_WINDOWS\n// WindowsDeathTest implements death tests on Windows. Due to the\n// specifics of starting new processes on Windows, death tests there are\n// always threadsafe, and Google Test considers the\n// --gtest_death_test_style=fast setting to be equivalent to\n// --gtest_death_test_style=threadsafe there.\n//\n// A few implementation notes:  Like the Linux version, the Windows\n// implementation uses pipes for child-to-parent communication. But due to\n// the specifics of pipes on Windows, some extra steps are required:\n//\n// 1. The parent creates a communication pipe and stores handles to both\n//    ends of it.\n// 2. The parent starts the child and provides it with the information\n//    necessary to acquire the handle to the write end of the pipe.\n// 3. The child acquires the write end of the pipe and signals the parent\n//    using a Windows event.\n// 4. Now the parent can release the write end of the pipe on its side. If\n//    this is done before step 3, the object's reference count goes down to\n//    0 and it is destroyed, preventing the child from acquiring it. The\n//    parent now has to release it, or read operations on the read end of\n//    the pipe will not return when the child terminates.\n// 5. The parent reads child's output through the pipe (outcome code and\n//    any possible error messages) from the pipe, and its stderr and then\n//    determines whether to fail the test.\n//\n// Note: to distinguish Win32 API calls from the local method and function\n// calls, the former are explicitly resolved in the global namespace.\n//\nclass WindowsDeathTest : public DeathTestImpl {\n public:\n  WindowsDeathTest(const char* a_statement,\n                   const RE* a_regex,\n                   const char* file,\n                   int line)\n      : DeathTestImpl(a_statement, a_regex), file_(file), line_(line) {}\n\n  // All of these virtual functions are inherited from DeathTest.\n  virtual int Wait();\n  virtual TestRole AssumeRole();\n\n private:\n  // The name of the file in which the death test is located.\n  const char* const file_;\n  // The line number on which the death test is located.\n  const int line_;\n  // Handle to the write end of the pipe to the child process.\n  AutoHandle write_handle_;\n  // Child process handle.\n  AutoHandle child_handle_;\n  // Event the child process uses to signal the parent that it has\n  // acquired the handle to the write end of the pipe. After seeing this\n  // event the parent can release its own handles to make sure its\n  // ReadFile() calls return when the child terminates.\n  AutoHandle event_handle_;\n};\n\n// Waits for the child in a death test to exit, returning its exit\n// status, or 0 if no child process exists.  As a side effect, sets the\n// outcome data member.\nint WindowsDeathTest::Wait() {\n  if (!spawned())\n    return 0;\n\n  // Wait until the child either signals that it has acquired the write end\n  // of the pipe or it dies.\n  const HANDLE wait_handles[2] = { child_handle_.Get(), event_handle_.Get() };\n  switch (::WaitForMultipleObjects(2,\n                                   wait_handles,\n                                   FALSE,  // Waits for any of the handles.\n                                   INFINITE)) {\n    case WAIT_OBJECT_0:\n    case WAIT_OBJECT_0 + 1:\n      break;\n    default:\n      GTEST_DEATH_TEST_CHECK_(false);  // Should not get here.\n  }\n\n  // The child has acquired the write end of the pipe or exited.\n  // We release the handle on our side and continue.\n  write_handle_.Reset();\n  event_handle_.Reset();\n\n  ReadAndInterpretStatusByte();\n\n  // Waits for the child process to exit if it haven't already. This\n  // returns immediately if the child has already exited, regardless of\n  // whether previous calls to WaitForMultipleObjects synchronized on this\n  // handle or not.\n  GTEST_DEATH_TEST_CHECK_(\n      WAIT_OBJECT_0 == ::WaitForSingleObject(child_handle_.Get(),\n                                             INFINITE));\n  DWORD status_code;\n  GTEST_DEATH_TEST_CHECK_(\n      ::GetExitCodeProcess(child_handle_.Get(), &status_code) != FALSE);\n  child_handle_.Reset();\n  set_status(static_cast<int>(status_code));\n  return status();\n}\n\n// The AssumeRole process for a Windows death test.  It creates a child\n// process with the same executable as the current process to run the\n// death test.  The child process is given the --gtest_filter and\n// --gtest_internal_run_death_test flags such that it knows to run the\n// current death test only.\nDeathTest::TestRole WindowsDeathTest::AssumeRole() {\n  const UnitTestImpl* const impl = GetUnitTestImpl();\n  const InternalRunDeathTestFlag* const flag =\n      impl->internal_run_death_test_flag();\n  const TestInfo* const info = impl->current_test_info();\n  const int death_test_index = info->result()->death_test_count();\n\n  if (flag != NULL) {\n    // ParseInternalRunDeathTestFlag() has performed all the necessary\n    // processing.\n    set_write_fd(flag->write_fd());\n    return EXECUTE_TEST;\n  }\n\n  // WindowsDeathTest uses an anonymous pipe to communicate results of\n  // a death test.\n  SECURITY_ATTRIBUTES handles_are_inheritable = {\n    sizeof(SECURITY_ATTRIBUTES), NULL, TRUE };\n  HANDLE read_handle, write_handle;\n  GTEST_DEATH_TEST_CHECK_(\n      ::CreatePipe(&read_handle, &write_handle, &handles_are_inheritable,\n                   0)  // Default buffer size.\n      != FALSE);\n  set_read_fd(::_open_osfhandle(reinterpret_cast<intptr_t>(read_handle),\n                                O_RDONLY));\n  write_handle_.Reset(write_handle);\n  event_handle_.Reset(::CreateEvent(\n      &handles_are_inheritable,\n      TRUE,    // The event will automatically reset to non-signaled state.\n      FALSE,   // The initial state is non-signalled.\n      NULL));  // The even is unnamed.\n  GTEST_DEATH_TEST_CHECK_(event_handle_.Get() != NULL);\n  const std::string filter_flag =\n      std::string(\"--\") + GTEST_FLAG_PREFIX_ + kFilterFlag + \"=\" +\n      info->test_case_name() + \".\" + info->name();\n  const std::string internal_flag =\n      std::string(\"--\") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag +\n      \"=\" + file_ + \"|\" + StreamableToString(line_) + \"|\" +\n      StreamableToString(death_test_index) + \"|\" +\n      StreamableToString(static_cast<unsigned int>(::GetCurrentProcessId())) +\n      // size_t has the same width as pointers on both 32-bit and 64-bit\n      // Windows platforms.\n      // See http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx.\n      \"|\" + StreamableToString(reinterpret_cast<size_t>(write_handle)) +\n      \"|\" + StreamableToString(reinterpret_cast<size_t>(event_handle_.Get()));\n\n  char executable_path[_MAX_PATH + 1];  // NOLINT\n  GTEST_DEATH_TEST_CHECK_(\n      _MAX_PATH + 1 != ::GetModuleFileNameA(NULL,\n                                            executable_path,\n                                            _MAX_PATH));\n\n  std::string command_line =\n      std::string(::GetCommandLineA()) + \" \" + filter_flag + \" \\\"\" +\n      internal_flag + \"\\\"\";\n\n  DeathTest::set_last_death_test_message(\"\");\n\n  CaptureStderr();\n  // Flush the log buffers since the log streams are shared with the child.\n  FlushInfoLog();\n\n  // The child process will share the standard handles with the parent.\n  STARTUPINFOA startup_info;\n  memset(&startup_info, 0, sizeof(STARTUPINFO));\n  startup_info.dwFlags = STARTF_USESTDHANDLES;\n  startup_info.hStdInput = ::GetStdHandle(STD_INPUT_HANDLE);\n  startup_info.hStdOutput = ::GetStdHandle(STD_OUTPUT_HANDLE);\n  startup_info.hStdError = ::GetStdHandle(STD_ERROR_HANDLE);\n\n  PROCESS_INFORMATION process_info;\n  GTEST_DEATH_TEST_CHECK_(::CreateProcessA(\n      executable_path,\n      const_cast<char*>(command_line.c_str()),\n      NULL,   // Retuned process handle is not inheritable.\n      NULL,   // Retuned thread handle is not inheritable.\n      TRUE,   // Child inherits all inheritable handles (for write_handle_).\n      0x0,    // Default creation flags.\n      NULL,   // Inherit the parent's environment.\n      UnitTest::GetInstance()->original_working_dir(),\n      &startup_info,\n      &process_info) != FALSE);\n  child_handle_.Reset(process_info.hProcess);\n  ::CloseHandle(process_info.hThread);\n  set_spawned(true);\n  return OVERSEE_TEST;\n}\n# else  // We are not on Windows.\n\n// ForkingDeathTest provides implementations for most of the abstract\n// methods of the DeathTest interface.  Only the AssumeRole method is\n// left undefined.\nclass ForkingDeathTest : public DeathTestImpl {\n public:\n  ForkingDeathTest(const char* statement, const RE* regex);\n\n  // All of these virtual functions are inherited from DeathTest.\n  virtual int Wait();\n\n protected:\n  void set_child_pid(pid_t child_pid) { child_pid_ = child_pid; }\n\n private:\n  // PID of child process during death test; 0 in the child process itself.\n  pid_t child_pid_;\n};\n\n// Constructs a ForkingDeathTest.\nForkingDeathTest::ForkingDeathTest(const char* a_statement, const RE* a_regex)\n    : DeathTestImpl(a_statement, a_regex),\n      child_pid_(-1) {}\n\n// Waits for the child in a death test to exit, returning its exit\n// status, or 0 if no child process exists.  As a side effect, sets the\n// outcome data member.\nint ForkingDeathTest::Wait() {\n  if (!spawned())\n    return 0;\n\n  ReadAndInterpretStatusByte();\n\n  int status_value;\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(waitpid(child_pid_, &status_value, 0));\n  set_status(status_value);\n  return status_value;\n}\n\n// A concrete death test class that forks, then immediately runs the test\n// in the child process.\nclass NoExecDeathTest : public ForkingDeathTest {\n public:\n  NoExecDeathTest(const char* a_statement, const RE* a_regex) :\n      ForkingDeathTest(a_statement, a_regex) { }\n  virtual TestRole AssumeRole();\n};\n\n// The AssumeRole process for a fork-and-run death test.  It implements a\n// straightforward fork, with a simple pipe to transmit the status byte.\nDeathTest::TestRole NoExecDeathTest::AssumeRole() {\n  const size_t thread_count = GetThreadCount();\n  if (thread_count != 1) {\n    GTEST_LOG_(WARNING) << DeathTestThreadWarning(thread_count);\n  }\n\n  int pipe_fd[2];\n  GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1);\n\n  DeathTest::set_last_death_test_message(\"\");\n  CaptureStderr();\n  // When we fork the process below, the log file buffers are copied, but the\n  // file descriptors are shared.  We flush all log files here so that closing\n  // the file descriptors in the child process doesn't throw off the\n  // synchronization between descriptors and buffers in the parent process.\n  // This is as close to the fork as possible to avoid a race condition in case\n  // there are multiple threads running before the death test, and another\n  // thread writes to the log file.\n  FlushInfoLog();\n\n  const pid_t child_pid = fork();\n  GTEST_DEATH_TEST_CHECK_(child_pid != -1);\n  set_child_pid(child_pid);\n  if (child_pid == 0) {\n    GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[0]));\n    set_write_fd(pipe_fd[1]);\n    // Redirects all logging to stderr in the child process to prevent\n    // concurrent writes to the log files.  We capture stderr in the parent\n    // process and append the child process' output to a log.\n    LogToStderr();\n    // Event forwarding to the listeners of event listener API mush be shut\n    // down in death test subprocesses.\n    GetUnitTestImpl()->listeners()->SuppressEventForwarding();\n    g_in_fast_death_test_child = true;\n    return EXECUTE_TEST;\n  } else {\n    GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1]));\n    set_read_fd(pipe_fd[0]);\n    set_spawned(true);\n    return OVERSEE_TEST;\n  }\n}\n\n// A concrete death test class that forks and re-executes the main\n// program from the beginning, with command-line flags set that cause\n// only this specific death test to be run.\nclass ExecDeathTest : public ForkingDeathTest {\n public:\n  ExecDeathTest(const char* a_statement, const RE* a_regex,\n                const char* file, int line) :\n      ForkingDeathTest(a_statement, a_regex), file_(file), line_(line) { }\n  virtual TestRole AssumeRole();\n private:\n  static ::std::vector<testing::internal::string>\n  GetArgvsForDeathTestChildProcess() {\n    ::std::vector<testing::internal::string> args = GetInjectableArgvs();\n    return args;\n  }\n  // The name of the file in which the death test is located.\n  const char* const file_;\n  // The line number on which the death test is located.\n  const int line_;\n};\n\n// Utility class for accumulating command-line arguments.\nclass Arguments {\n public:\n  Arguments() {\n    args_.push_back(NULL);\n  }\n\n  ~Arguments() {\n    for (std::vector<char*>::iterator i = args_.begin(); i != args_.end();\n         ++i) {\n      free(*i);\n    }\n  }\n  void AddArgument(const char* argument) {\n    args_.insert(args_.end() - 1, posix::StrDup(argument));\n  }\n\n  template <typename Str>\n  void AddArguments(const ::std::vector<Str>& arguments) {\n    for (typename ::std::vector<Str>::const_iterator i = arguments.begin();\n         i != arguments.end();\n         ++i) {\n      args_.insert(args_.end() - 1, posix::StrDup(i->c_str()));\n    }\n  }\n  char* const* Argv() {\n    return &args_[0];\n  }\n\n private:\n  std::vector<char*> args_;\n};\n\n// A struct that encompasses the arguments to the child process of a\n// threadsafe-style death test process.\nstruct ExecDeathTestArgs {\n  char* const* argv;  // Command-line arguments for the child's call to exec\n  int close_fd;       // File descriptor to close; the read end of a pipe\n};\n\n#  if GTEST_OS_MAC\ninline char** GetEnviron() {\n  // When Google Test is built as a framework on MacOS X, the environ variable\n  // is unavailable. Apple's documentation (man environ) recommends using\n  // _NSGetEnviron() instead.\n  return *_NSGetEnviron();\n}\n#  else\n// Some POSIX platforms expect you to declare environ. extern \"C\" makes\n// it reside in the global namespace.\nextern \"C\" char** environ;\ninline char** GetEnviron() { return environ; }\n#  endif  // GTEST_OS_MAC\n\n#  if !GTEST_OS_QNX\n// The main function for a threadsafe-style death test child process.\n// This function is called in a clone()-ed process and thus must avoid\n// any potentially unsafe operations like malloc or libc functions.\nstatic int ExecDeathTestChildMain(void* child_arg) {\n  ExecDeathTestArgs* const args = static_cast<ExecDeathTestArgs*>(child_arg);\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(close(args->close_fd));\n\n  // We need to execute the test program in the same environment where\n  // it was originally invoked.  Therefore we change to the original\n  // working directory first.\n  const char* const original_dir =\n      UnitTest::GetInstance()->original_working_dir();\n  // We can safely call chdir() as it's a direct system call.\n  if (chdir(original_dir) != 0) {\n    DeathTestAbort(std::string(\"chdir(\\\"\") + original_dir + \"\\\") failed: \" +\n                   GetLastErrnoDescription());\n    return EXIT_FAILURE;\n  }\n\n  // We can safely call execve() as it's a direct system call.  We\n  // cannot use execvp() as it's a libc function and thus potentially\n  // unsafe.  Since execve() doesn't search the PATH, the user must\n  // invoke the test program via a valid path that contains at least\n  // one path separator.\n  execve(args->argv[0], args->argv, GetEnviron());\n  DeathTestAbort(std::string(\"execve(\") + args->argv[0] + \", ...) in \" +\n                 original_dir + \" failed: \" +\n                 GetLastErrnoDescription());\n  return EXIT_FAILURE;\n}\n#  endif  // !GTEST_OS_QNX\n\n// Two utility routines that together determine the direction the stack\n// grows.\n// This could be accomplished more elegantly by a single recursive\n// function, but we want to guard against the unlikely possibility of\n// a smart compiler optimizing the recursion away.\n//\n// GTEST_NO_INLINE_ is required to prevent GCC 4.6 from inlining\n// StackLowerThanAddress into StackGrowsDown, which then doesn't give\n// correct answer.\nvoid StackLowerThanAddress(const void* ptr, bool* result) GTEST_NO_INLINE_;\nvoid StackLowerThanAddress(const void* ptr, bool* result) {\n  int dummy;\n  *result = (&dummy < ptr);\n}\n\nbool StackGrowsDown() {\n  int dummy;\n  bool result;\n  StackLowerThanAddress(&dummy, &result);\n  return result;\n}\n\n// Spawns a child process with the same executable as the current process in\n// a thread-safe manner and instructs it to run the death test.  The\n// implementation uses fork(2) + exec.  On systems where clone(2) is\n// available, it is used instead, being slightly more thread-safe.  On QNX,\n// fork supports only single-threaded environments, so this function uses\n// spawn(2) there instead.  The function dies with an error message if\n// anything goes wrong.\nstatic pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) {\n  ExecDeathTestArgs args = { argv, close_fd };\n  pid_t child_pid = -1;\n\n#  if GTEST_OS_QNX\n  // Obtains the current directory and sets it to be closed in the child\n  // process.\n  const int cwd_fd = open(\".\", O_RDONLY);\n  GTEST_DEATH_TEST_CHECK_(cwd_fd != -1);\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(fcntl(cwd_fd, F_SETFD, FD_CLOEXEC));\n  // We need to execute the test program in the same environment where\n  // it was originally invoked.  Therefore we change to the original\n  // working directory first.\n  const char* const original_dir =\n      UnitTest::GetInstance()->original_working_dir();\n  // We can safely call chdir() as it's a direct system call.\n  if (chdir(original_dir) != 0) {\n    DeathTestAbort(std::string(\"chdir(\\\"\") + original_dir + \"\\\") failed: \" +\n                   GetLastErrnoDescription());\n    return EXIT_FAILURE;\n  }\n\n  int fd_flags;\n  // Set close_fd to be closed after spawn.\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(fd_flags = fcntl(close_fd, F_GETFD));\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(fcntl(close_fd, F_SETFD,\n                                        fd_flags | FD_CLOEXEC));\n  struct inheritance inherit = {0};\n  // spawn is a system call.\n  child_pid = spawn(args.argv[0], 0, NULL, &inherit, args.argv, GetEnviron());\n  // Restores the current working directory.\n  GTEST_DEATH_TEST_CHECK_(fchdir(cwd_fd) != -1);\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(close(cwd_fd));\n\n#  else   // GTEST_OS_QNX\n#   if GTEST_OS_LINUX\n  // When a SIGPROF signal is received while fork() or clone() are executing,\n  // the process may hang. To avoid this, we ignore SIGPROF here and re-enable\n  // it after the call to fork()/clone() is complete.\n  struct sigaction saved_sigprof_action;\n  struct sigaction ignore_sigprof_action;\n  memset(&ignore_sigprof_action, 0, sizeof(ignore_sigprof_action));\n  sigemptyset(&ignore_sigprof_action.sa_mask);\n  ignore_sigprof_action.sa_handler = SIG_IGN;\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(sigaction(\n      SIGPROF, &ignore_sigprof_action, &saved_sigprof_action));\n#   endif  // GTEST_OS_LINUX\n\n#   if GTEST_HAS_CLONE\n  const bool use_fork = GTEST_FLAG(death_test_use_fork);\n\n  if (!use_fork) {\n    static const bool stack_grows_down = StackGrowsDown();\n    const size_t stack_size = getpagesize();\n    // MMAP_ANONYMOUS is not defined on Mac, so we use MAP_ANON instead.\n    void* const stack = mmap(NULL, stack_size, PROT_READ | PROT_WRITE,\n                             MAP_ANON | MAP_PRIVATE, -1, 0);\n    GTEST_DEATH_TEST_CHECK_(stack != MAP_FAILED);\n\n    // Maximum stack alignment in bytes:  For a downward-growing stack, this\n    // amount is subtracted from size of the stack space to get an address\n    // that is within the stack space and is aligned on all systems we care\n    // about.  As far as I know there is no ABI with stack alignment greater\n    // than 64.  We assume stack and stack_size already have alignment of\n    // kMaxStackAlignment.\n    const size_t kMaxStackAlignment = 64;\n    void* const stack_top =\n        static_cast<char*>(stack) +\n            (stack_grows_down ? stack_size - kMaxStackAlignment : 0);\n    GTEST_DEATH_TEST_CHECK_(stack_size > kMaxStackAlignment &&\n        reinterpret_cast<intptr_t>(stack_top) % kMaxStackAlignment == 0);\n\n    child_pid = clone(&ExecDeathTestChildMain, stack_top, SIGCHLD, &args);\n\n    GTEST_DEATH_TEST_CHECK_(munmap(stack, stack_size) != -1);\n  }\n#   else\n  const bool use_fork = true;\n#   endif  // GTEST_HAS_CLONE\n\n  if (use_fork && (child_pid = fork()) == 0) {\n      ExecDeathTestChildMain(&args);\n      _exit(0);\n  }\n#  endif  // GTEST_OS_QNX\n#  if GTEST_OS_LINUX\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(\n      sigaction(SIGPROF, &saved_sigprof_action, NULL));\n#  endif  // GTEST_OS_LINUX\n\n  GTEST_DEATH_TEST_CHECK_(child_pid != -1);\n  return child_pid;\n}\n\n// The AssumeRole process for a fork-and-exec death test.  It re-executes the\n// main program from the beginning, setting the --gtest_filter\n// and --gtest_internal_run_death_test flags to cause only the current\n// death test to be re-run.\nDeathTest::TestRole ExecDeathTest::AssumeRole() {\n  const UnitTestImpl* const impl = GetUnitTestImpl();\n  const InternalRunDeathTestFlag* const flag =\n      impl->internal_run_death_test_flag();\n  const TestInfo* const info = impl->current_test_info();\n  const int death_test_index = info->result()->death_test_count();\n\n  if (flag != NULL) {\n    set_write_fd(flag->write_fd());\n    return EXECUTE_TEST;\n  }\n\n  int pipe_fd[2];\n  GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1);\n  // Clear the close-on-exec flag on the write end of the pipe, lest\n  // it be closed when the child process does an exec:\n  GTEST_DEATH_TEST_CHECK_(fcntl(pipe_fd[1], F_SETFD, 0) != -1);\n\n  const std::string filter_flag =\n      std::string(\"--\") + GTEST_FLAG_PREFIX_ + kFilterFlag + \"=\"\n      + info->test_case_name() + \".\" + info->name();\n  const std::string internal_flag =\n      std::string(\"--\") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + \"=\"\n      + file_ + \"|\" + StreamableToString(line_) + \"|\"\n      + StreamableToString(death_test_index) + \"|\"\n      + StreamableToString(pipe_fd[1]);\n  Arguments args;\n  args.AddArguments(GetArgvsForDeathTestChildProcess());\n  args.AddArgument(filter_flag.c_str());\n  args.AddArgument(internal_flag.c_str());\n\n  DeathTest::set_last_death_test_message(\"\");\n\n  CaptureStderr();\n  // See the comment in NoExecDeathTest::AssumeRole for why the next line\n  // is necessary.\n  FlushInfoLog();\n\n  const pid_t child_pid = ExecDeathTestSpawnChild(args.Argv(), pipe_fd[0]);\n  GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1]));\n  set_child_pid(child_pid);\n  set_read_fd(pipe_fd[0]);\n  set_spawned(true);\n  return OVERSEE_TEST;\n}\n\n# endif  // !GTEST_OS_WINDOWS\n\n// Creates a concrete DeathTest-derived class that depends on the\n// --gtest_death_test_style flag, and sets the pointer pointed to\n// by the \"test\" argument to its address.  If the test should be\n// skipped, sets that pointer to NULL.  Returns true, unless the\n// flag is set to an invalid value.\nbool DefaultDeathTestFactory::Create(const char* statement, const RE* regex,\n                                     const char* file, int line,\n                                     DeathTest** test) {\n  UnitTestImpl* const impl = GetUnitTestImpl();\n  const InternalRunDeathTestFlag* const flag =\n      impl->internal_run_death_test_flag();\n  const int death_test_index = impl->current_test_info()\n      ->increment_death_test_count();\n\n  if (flag != NULL) {\n    if (death_test_index > flag->index()) {\n      DeathTest::set_last_death_test_message(\n          \"Death test count (\" + StreamableToString(death_test_index)\n          + \") somehow exceeded expected maximum (\"\n          + StreamableToString(flag->index()) + \")\");\n      return false;\n    }\n\n    if (!(flag->file() == file && flag->line() == line &&\n          flag->index() == death_test_index)) {\n      *test = NULL;\n      return true;\n    }\n  }\n\n# if GTEST_OS_WINDOWS\n\n  if (GTEST_FLAG(death_test_style) == \"threadsafe\" ||\n      GTEST_FLAG(death_test_style) == \"fast\") {\n    *test = new WindowsDeathTest(statement, regex, file, line);\n  }\n\n# else\n\n  if (GTEST_FLAG(death_test_style) == \"threadsafe\") {\n    *test = new ExecDeathTest(statement, regex, file, line);\n  } else if (GTEST_FLAG(death_test_style) == \"fast\") {\n    *test = new NoExecDeathTest(statement, regex);\n  }\n\n# endif  // GTEST_OS_WINDOWS\n\n  else {  // NOLINT - this is more readable than unbalanced brackets inside #if.\n    DeathTest::set_last_death_test_message(\n        \"Unknown death test style \\\"\" + GTEST_FLAG(death_test_style)\n        + \"\\\" encountered\");\n    return false;\n  }\n\n  return true;\n}\n\n// Splits a given string on a given delimiter, populating a given\n// vector with the fields.  GTEST_HAS_DEATH_TEST implies that we have\n// ::std::string, so we can use it here.\nstatic void SplitString(const ::std::string& str, char delimiter,\n                        ::std::vector< ::std::string>* dest) {\n  ::std::vector< ::std::string> parsed;\n  ::std::string::size_type pos = 0;\n  while (::testing::internal::AlwaysTrue()) {\n    const ::std::string::size_type colon = str.find(delimiter, pos);\n    if (colon == ::std::string::npos) {\n      parsed.push_back(str.substr(pos));\n      break;\n    } else {\n      parsed.push_back(str.substr(pos, colon - pos));\n      pos = colon + 1;\n    }\n  }\n  dest->swap(parsed);\n}\n\n# if GTEST_OS_WINDOWS\n// Recreates the pipe and event handles from the provided parameters,\n// signals the event, and returns a file descriptor wrapped around the pipe\n// handle. This function is called in the child process only.\nint GetStatusFileDescriptor(unsigned int parent_process_id,\n                            size_t write_handle_as_size_t,\n                            size_t event_handle_as_size_t) {\n  AutoHandle parent_process_handle(::OpenProcess(PROCESS_DUP_HANDLE,\n                                                   FALSE,  // Non-inheritable.\n                                                   parent_process_id));\n  if (parent_process_handle.Get() == INVALID_HANDLE_VALUE) {\n    DeathTestAbort(\"Unable to open parent process \" +\n                   StreamableToString(parent_process_id));\n  }\n\n  // TODO(vladl@google.com): Replace the following check with a\n  // compile-time assertion when available.\n  GTEST_CHECK_(sizeof(HANDLE) <= sizeof(size_t));\n\n  const HANDLE write_handle =\n      reinterpret_cast<HANDLE>(write_handle_as_size_t);\n  HANDLE dup_write_handle;\n\n  // The newly initialized handle is accessible only in in the parent\n  // process. To obtain one accessible within the child, we need to use\n  // DuplicateHandle.\n  if (!::DuplicateHandle(parent_process_handle.Get(), write_handle,\n                         ::GetCurrentProcess(), &dup_write_handle,\n                         0x0,    // Requested privileges ignored since\n                                 // DUPLICATE_SAME_ACCESS is used.\n                         FALSE,  // Request non-inheritable handler.\n                         DUPLICATE_SAME_ACCESS)) {\n    DeathTestAbort(\"Unable to duplicate the pipe handle \" +\n                   StreamableToString(write_handle_as_size_t) +\n                   \" from the parent process \" +\n                   StreamableToString(parent_process_id));\n  }\n\n  const HANDLE event_handle = reinterpret_cast<HANDLE>(event_handle_as_size_t);\n  HANDLE dup_event_handle;\n\n  if (!::DuplicateHandle(parent_process_handle.Get(), event_handle,\n                         ::GetCurrentProcess(), &dup_event_handle,\n                         0x0,\n                         FALSE,\n                         DUPLICATE_SAME_ACCESS)) {\n    DeathTestAbort(\"Unable to duplicate the event handle \" +\n                   StreamableToString(event_handle_as_size_t) +\n                   \" from the parent process \" +\n                   StreamableToString(parent_process_id));\n  }\n\n  const int write_fd =\n      ::_open_osfhandle(reinterpret_cast<intptr_t>(dup_write_handle), O_APPEND);\n  if (write_fd == -1) {\n    DeathTestAbort(\"Unable to convert pipe handle \" +\n                   StreamableToString(write_handle_as_size_t) +\n                   \" to a file descriptor\");\n  }\n\n  // Signals the parent that the write end of the pipe has been acquired\n  // so the parent can release its own write end.\n  ::SetEvent(dup_event_handle);\n\n  return write_fd;\n}\n# endif  // GTEST_OS_WINDOWS\n\n// Returns a newly created InternalRunDeathTestFlag object with fields\n// initialized from the GTEST_FLAG(internal_run_death_test) flag if\n// the flag is specified; otherwise returns NULL.\nInternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() {\n  if (GTEST_FLAG(internal_run_death_test) == \"\") return NULL;\n\n  // GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we\n  // can use it here.\n  int line = -1;\n  int index = -1;\n  ::std::vector< ::std::string> fields;\n  SplitString(GTEST_FLAG(internal_run_death_test).c_str(), '|', &fields);\n  int write_fd = -1;\n\n# if GTEST_OS_WINDOWS\n\n  unsigned int parent_process_id = 0;\n  size_t write_handle_as_size_t = 0;\n  size_t event_handle_as_size_t = 0;\n\n  if (fields.size() != 6\n      || !ParseNaturalNumber(fields[1], &line)\n      || !ParseNaturalNumber(fields[2], &index)\n      || !ParseNaturalNumber(fields[3], &parent_process_id)\n      || !ParseNaturalNumber(fields[4], &write_handle_as_size_t)\n      || !ParseNaturalNumber(fields[5], &event_handle_as_size_t)) {\n    DeathTestAbort(\"Bad --gtest_internal_run_death_test flag: \" +\n                   GTEST_FLAG(internal_run_death_test));\n  }\n  write_fd = GetStatusFileDescriptor(parent_process_id,\n                                     write_handle_as_size_t,\n                                     event_handle_as_size_t);\n# else\n\n  if (fields.size() != 4\n      || !ParseNaturalNumber(fields[1], &line)\n      || !ParseNaturalNumber(fields[2], &index)\n      || !ParseNaturalNumber(fields[3], &write_fd)) {\n    DeathTestAbort(\"Bad --gtest_internal_run_death_test flag: \"\n        + GTEST_FLAG(internal_run_death_test));\n  }\n\n# endif  // GTEST_OS_WINDOWS\n\n  return new InternalRunDeathTestFlag(fields[0], line, index, write_fd);\n}\n\n}  // namespace internal\n\n#endif  // GTEST_HAS_DEATH_TEST\n\n}  // namespace testing\n"
  },
  {
    "path": "ext/gtest/src/gtest-filepath.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: keith.ray@gmail.com (Keith Ray)\n\n#include \"gtest/gtest-message.h\"\n#include \"gtest/internal/gtest-filepath.h\"\n#include \"gtest/internal/gtest-port.h\"\n\n#include <stdlib.h>\n\n#if GTEST_OS_WINDOWS_MOBILE\n# include <windows.h>\n#elif GTEST_OS_WINDOWS\n# include <direct.h>\n# include <io.h>\n#elif GTEST_OS_SYMBIAN\n// Symbian OpenC has PATH_MAX in sys/syslimits.h\n# include <sys/syslimits.h>\n#else\n# include <limits.h>\n# include <climits>  // Some Linux distributions define PATH_MAX here.\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\n#if GTEST_OS_WINDOWS\n# define GTEST_PATH_MAX_ _MAX_PATH\n#elif defined(PATH_MAX)\n# define GTEST_PATH_MAX_ PATH_MAX\n#elif defined(_XOPEN_PATH_MAX)\n# define GTEST_PATH_MAX_ _XOPEN_PATH_MAX\n#else\n# define GTEST_PATH_MAX_ _POSIX_PATH_MAX\n#endif  // GTEST_OS_WINDOWS\n\n#include \"gtest/internal/gtest-string.h\"\n\nnamespace testing {\nnamespace internal {\n\n#if GTEST_OS_WINDOWS\n// On Windows, '\\\\' is the standard path separator, but many tools and the\n// Windows API also accept '/' as an alternate path separator. Unless otherwise\n// noted, a file path can contain either kind of path separators, or a mixture\n// of them.\nconst char kPathSeparator = '\\\\';\nconst char kAlternatePathSeparator = '/';\nconst char kPathSeparatorString[] = \"\\\\\";\nconst char kAlternatePathSeparatorString[] = \"/\";\n# if GTEST_OS_WINDOWS_MOBILE\n// Windows CE doesn't have a current directory. You should not use\n// the current directory in tests on Windows CE, but this at least\n// provides a reasonable fallback.\nconst char kCurrentDirectoryString[] = \"\\\\\";\n// Windows CE doesn't define INVALID_FILE_ATTRIBUTES\nconst DWORD kInvalidFileAttributes = 0xffffffff;\n# else\nconst char kCurrentDirectoryString[] = \".\\\\\";\n# endif  // GTEST_OS_WINDOWS_MOBILE\n#else\nconst char kPathSeparator = '/';\nconst char kPathSeparatorString[] = \"/\";\nconst char kCurrentDirectoryString[] = \"./\";\n#endif  // GTEST_OS_WINDOWS\n\n// Returns whether the given character is a valid path separator.\nstatic bool IsPathSeparator(char c) {\n#if GTEST_HAS_ALT_PATH_SEP_\n  return (c == kPathSeparator) || (c == kAlternatePathSeparator);\n#else\n  return c == kPathSeparator;\n#endif\n}\n\n// Returns the current working directory, or \"\" if unsuccessful.\nFilePath FilePath::GetCurrentDir() {\n#if GTEST_OS_WINDOWS_MOBILE\n  // Windows CE doesn't have a current directory, so we just return\n  // something reasonable.\n  return FilePath(kCurrentDirectoryString);\n#elif GTEST_OS_WINDOWS\n  char cwd[GTEST_PATH_MAX_ + 1] = { '\\0' };\n  return FilePath(_getcwd(cwd, sizeof(cwd)) == NULL ? \"\" : cwd);\n#else\n  char cwd[GTEST_PATH_MAX_ + 1] = { '\\0' };\n  return FilePath(getcwd(cwd, sizeof(cwd)) == NULL ? \"\" : cwd);\n#endif  // GTEST_OS_WINDOWS_MOBILE\n}\n\n// Returns a copy of the FilePath with the case-insensitive extension removed.\n// Example: FilePath(\"dir/file.exe\").RemoveExtension(\"EXE\") returns\n// FilePath(\"dir/file\"). If a case-insensitive extension is not\n// found, returns a copy of the original FilePath.\nFilePath FilePath::RemoveExtension(const char* extension) const {\n  const std::string dot_extension = std::string(\".\") + extension;\n  if (String::EndsWithCaseInsensitive(pathname_, dot_extension)) {\n    return FilePath(pathname_.substr(\n        0, pathname_.length() - dot_extension.length()));\n  }\n  return *this;\n}\n\n// Returns a pointer to the last occurence of a valid path separator in\n// the FilePath. On Windows, for example, both '/' and '\\' are valid path\n// separators. Returns NULL if no path separator was found.\nconst char* FilePath::FindLastPathSeparator() const {\n  const char* const last_sep = strrchr(c_str(), kPathSeparator);\n#if GTEST_HAS_ALT_PATH_SEP_\n  const char* const last_alt_sep = strrchr(c_str(), kAlternatePathSeparator);\n  // Comparing two pointers of which only one is NULL is undefined.\n  if (last_alt_sep != NULL &&\n      (last_sep == NULL || last_alt_sep > last_sep)) {\n    return last_alt_sep;\n  }\n#endif\n  return last_sep;\n}\n\n// Returns a copy of the FilePath with the directory part removed.\n// Example: FilePath(\"path/to/file\").RemoveDirectoryName() returns\n// FilePath(\"file\"). If there is no directory part (\"just_a_file\"), it returns\n// the FilePath unmodified. If there is no file part (\"just_a_dir/\") it\n// returns an empty FilePath (\"\").\n// On Windows platform, '\\' is the path separator, otherwise it is '/'.\nFilePath FilePath::RemoveDirectoryName() const {\n  const char* const last_sep = FindLastPathSeparator();\n  return last_sep ? FilePath(last_sep + 1) : *this;\n}\n\n// RemoveFileName returns the directory path with the filename removed.\n// Example: FilePath(\"path/to/file\").RemoveFileName() returns \"path/to/\".\n// If the FilePath is \"a_file\" or \"/a_file\", RemoveFileName returns\n// FilePath(\"./\") or, on Windows, FilePath(\".\\\\\"). If the filepath does\n// not have a file, like \"just/a/dir/\", it returns the FilePath unmodified.\n// On Windows platform, '\\' is the path separator, otherwise it is '/'.\nFilePath FilePath::RemoveFileName() const {\n  const char* const last_sep = FindLastPathSeparator();\n  std::string dir;\n  if (last_sep) {\n    dir = std::string(c_str(), last_sep + 1 - c_str());\n  } else {\n    dir = kCurrentDirectoryString;\n  }\n  return FilePath(dir);\n}\n\n// Helper functions for naming files in a directory for xml output.\n\n// Given directory = \"dir\", base_name = \"test\", number = 0,\n// extension = \"xml\", returns \"dir/test.xml\". If number is greater\n// than zero (e.g., 12), returns \"dir/test_12.xml\".\n// On Windows platform, uses \\ as the separator rather than /.\nFilePath FilePath::MakeFileName(const FilePath& directory,\n                                const FilePath& base_name,\n                                int number,\n                                const char* extension) {\n  std::string file;\n  if (number == 0) {\n    file = base_name.string() + \".\" + extension;\n  } else {\n    file = base_name.string() + \"_\" + StreamableToString(number)\n        + \".\" + extension;\n  }\n  return ConcatPaths(directory, FilePath(file));\n}\n\n// Given directory = \"dir\", relative_path = \"test.xml\", returns \"dir/test.xml\".\n// On Windows, uses \\ as the separator rather than /.\nFilePath FilePath::ConcatPaths(const FilePath& directory,\n                               const FilePath& relative_path) {\n  if (directory.IsEmpty())\n    return relative_path;\n  const FilePath dir(directory.RemoveTrailingPathSeparator());\n  return FilePath(dir.string() + kPathSeparator + relative_path.string());\n}\n\n// Returns true if pathname describes something findable in the file-system,\n// either a file, directory, or whatever.\nbool FilePath::FileOrDirectoryExists() const {\n#if GTEST_OS_WINDOWS_MOBILE\n  LPCWSTR unicode = String::AnsiToUtf16(pathname_.c_str());\n  const DWORD attributes = GetFileAttributes(unicode);\n  delete [] unicode;\n  return attributes != kInvalidFileAttributes;\n#else\n  posix::StatStruct file_stat;\n  return posix::Stat(pathname_.c_str(), &file_stat) == 0;\n#endif  // GTEST_OS_WINDOWS_MOBILE\n}\n\n// Returns true if pathname describes a directory in the file-system\n// that exists.\nbool FilePath::DirectoryExists() const {\n  bool result = false;\n#if GTEST_OS_WINDOWS\n  // Don't strip off trailing separator if path is a root directory on\n  // Windows (like \"C:\\\\\").\n  const FilePath& path(IsRootDirectory() ? *this :\n                                           RemoveTrailingPathSeparator());\n#else\n  const FilePath& path(*this);\n#endif\n\n#if GTEST_OS_WINDOWS_MOBILE\n  LPCWSTR unicode = String::AnsiToUtf16(path.c_str());\n  const DWORD attributes = GetFileAttributes(unicode);\n  delete [] unicode;\n  if ((attributes != kInvalidFileAttributes) &&\n      (attributes & FILE_ATTRIBUTE_DIRECTORY)) {\n    result = true;\n  }\n#else\n  posix::StatStruct file_stat;\n  result = posix::Stat(path.c_str(), &file_stat) == 0 &&\n      posix::IsDir(file_stat);\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\n  return result;\n}\n\n// Returns true if pathname describes a root directory. (Windows has one\n// root directory per disk drive.)\nbool FilePath::IsRootDirectory() const {\n#if GTEST_OS_WINDOWS\n  // TODO(wan@google.com): on Windows a network share like\n  // \\\\server\\share can be a root directory, although it cannot be the\n  // current directory.  Handle this properly.\n  return pathname_.length() == 3 && IsAbsolutePath();\n#else\n  return pathname_.length() == 1 && IsPathSeparator(pathname_.c_str()[0]);\n#endif\n}\n\n// Returns true if pathname describes an absolute path.\nbool FilePath::IsAbsolutePath() const {\n  const char* const name = pathname_.c_str();\n#if GTEST_OS_WINDOWS\n  return pathname_.length() >= 3 &&\n     ((name[0] >= 'a' && name[0] <= 'z') ||\n      (name[0] >= 'A' && name[0] <= 'Z')) &&\n     name[1] == ':' &&\n     IsPathSeparator(name[2]);\n#else\n  return IsPathSeparator(name[0]);\n#endif\n}\n\n// Returns a pathname for a file that does not currently exist. The pathname\n// will be directory/base_name.extension or\n// directory/base_name_<number>.extension if directory/base_name.extension\n// already exists. The number will be incremented until a pathname is found\n// that does not already exist.\n// Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'.\n// There could be a race condition if two or more processes are calling this\n// function at the same time -- they could both pick the same filename.\nFilePath FilePath::GenerateUniqueFileName(const FilePath& directory,\n                                          const FilePath& base_name,\n                                          const char* extension) {\n  FilePath full_pathname;\n  int number = 0;\n  do {\n    full_pathname.Set(MakeFileName(directory, base_name, number++, extension));\n  } while (full_pathname.FileOrDirectoryExists());\n  return full_pathname;\n}\n\n// Returns true if FilePath ends with a path separator, which indicates that\n// it is intended to represent a directory. Returns false otherwise.\n// This does NOT check that a directory (or file) actually exists.\nbool FilePath::IsDirectory() const {\n  return !pathname_.empty() &&\n         IsPathSeparator(pathname_.c_str()[pathname_.length() - 1]);\n}\n\n// Create directories so that path exists. Returns true if successful or if\n// the directories already exist; returns false if unable to create directories\n// for any reason.\nbool FilePath::CreateDirectoriesRecursively() const {\n  if (!this->IsDirectory()) {\n    return false;\n  }\n\n  if (pathname_.length() == 0 || this->DirectoryExists()) {\n    return true;\n  }\n\n  const FilePath parent(this->RemoveTrailingPathSeparator().RemoveFileName());\n  return parent.CreateDirectoriesRecursively() && this->CreateFolder();\n}\n\n// Create the directory so that path exists. Returns true if successful or\n// if the directory already exists; returns false if unable to create the\n// directory for any reason, including if the parent directory does not\n// exist. Not named \"CreateDirectory\" because that's a macro on Windows.\nbool FilePath::CreateFolder() const {\n#if GTEST_OS_WINDOWS_MOBILE\n  FilePath removed_sep(this->RemoveTrailingPathSeparator());\n  LPCWSTR unicode = String::AnsiToUtf16(removed_sep.c_str());\n  int result = CreateDirectory(unicode, NULL) ? 0 : -1;\n  delete [] unicode;\n#elif GTEST_OS_WINDOWS\n  int result = _mkdir(pathname_.c_str());\n#else\n  int result = mkdir(pathname_.c_str(), 0777);\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\n  if (result == -1) {\n    return this->DirectoryExists();  // An error is OK if the directory exists.\n  }\n  return true;  // No error.\n}\n\n// If input name has a trailing separator character, remove it and return the\n// name, otherwise return the name string unmodified.\n// On Windows platform, uses \\ as the separator, other platforms use /.\nFilePath FilePath::RemoveTrailingPathSeparator() const {\n  return IsDirectory()\n      ? FilePath(pathname_.substr(0, pathname_.length() - 1))\n      : *this;\n}\n\n// Removes any redundant separators that might be in the pathname.\n// For example, \"bar///foo\" becomes \"bar/foo\". Does not eliminate other\n// redundancies that might be in a pathname involving \".\" or \"..\".\n// TODO(wan@google.com): handle Windows network shares (e.g. \\\\server\\share).\nvoid FilePath::Normalize() {\n  if (pathname_.c_str() == NULL) {\n    pathname_ = \"\";\n    return;\n  }\n  const char* src = pathname_.c_str();\n  char* const dest = new char[pathname_.length() + 1];\n  char* dest_ptr = dest;\n  memset(dest_ptr, 0, pathname_.length() + 1);\n\n  while (*src != '\\0') {\n    *dest_ptr = *src;\n    if (!IsPathSeparator(*src)) {\n      src++;\n    } else {\n#if GTEST_HAS_ALT_PATH_SEP_\n      if (*dest_ptr == kAlternatePathSeparator) {\n        *dest_ptr = kPathSeparator;\n      }\n#endif\n      while (IsPathSeparator(*src))\n        src++;\n    }\n    dest_ptr++;\n  }\n  *dest_ptr = '\\0';\n  pathname_ = dest;\n  delete[] dest;\n}\n\n}  // namespace internal\n}  // namespace testing\n"
  },
  {
    "path": "ext/gtest/src/gtest-internal-inl.h",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Utility functions and classes used by the Google C++ testing framework.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// This file contains purely Google Test's internal implementation.  Please\n// DO NOT #INCLUDE IT IN A USER PROGRAM.\n\n#ifndef GTEST_SRC_GTEST_INTERNAL_INL_H_\n#define GTEST_SRC_GTEST_INTERNAL_INL_H_\n\n// GTEST_IMPLEMENTATION_ is defined to 1 iff the current translation unit is\n// part of Google Test's implementation; otherwise it's undefined.\n#if !GTEST_IMPLEMENTATION_\n// A user is trying to include this from his code - just say no.\n# error \"gtest-internal-inl.h is part of Google Test's internal implementation.\"\n# error \"It must not be included except by Google Test itself.\"\n#endif  // GTEST_IMPLEMENTATION_\n\n#ifndef _WIN32_WCE\n# include <errno.h>\n#endif  // !_WIN32_WCE\n#include <stddef.h>\n#include <stdlib.h>  // For strtoll/_strtoul64/malloc/free.\n#include <string.h>  // For memmove.\n\n#include <algorithm>\n#include <string>\n#include <vector>\n\n#include \"gtest/internal/gtest-port.h\"\n\n#if GTEST_CAN_STREAM_RESULTS_\n# include <arpa/inet.h>  // NOLINT\n# include <netdb.h>  // NOLINT\n#endif\n\n#if GTEST_OS_WINDOWS\n# include <windows.h>  // NOLINT\n#endif  // GTEST_OS_WINDOWS\n\n#include \"gtest/gtest.h\"  // NOLINT\n#include \"gtest/gtest-spi.h\"\n\nnamespace testing {\n\n// Declares the flags.\n//\n// We don't want the users to modify this flag in the code, but want\n// Google Test's own unit tests to be able to access it. Therefore we\n// declare it here as opposed to in gtest.h.\nGTEST_DECLARE_bool_(death_test_use_fork);\n\nnamespace internal {\n\n// The value of GetTestTypeId() as seen from within the Google Test\n// library.  This is solely for testing GetTestTypeId().\nGTEST_API_ extern const TypeId kTestTypeIdInGoogleTest;\n\n// Names of the flags (needed for parsing Google Test flags).\nconst char kAlsoRunDisabledTestsFlag[] = \"also_run_disabled_tests\";\nconst char kBreakOnFailureFlag[] = \"break_on_failure\";\nconst char kCatchExceptionsFlag[] = \"catch_exceptions\";\nconst char kColorFlag[] = \"color\";\nconst char kFilterFlag[] = \"filter\";\nconst char kListTestsFlag[] = \"list_tests\";\nconst char kOutputFlag[] = \"output\";\nconst char kPrintTimeFlag[] = \"print_time\";\nconst char kRandomSeedFlag[] = \"random_seed\";\nconst char kRepeatFlag[] = \"repeat\";\nconst char kShuffleFlag[] = \"shuffle\";\nconst char kStackTraceDepthFlag[] = \"stack_trace_depth\";\nconst char kStreamResultToFlag[] = \"stream_result_to\";\nconst char kThrowOnFailureFlag[] = \"throw_on_failure\";\n\n// A valid random seed must be in [1, kMaxRandomSeed].\nconst int kMaxRandomSeed = 99999;\n\n// g_help_flag is true iff the --help flag or an equivalent form is\n// specified on the command line.\nGTEST_API_ extern bool g_help_flag;\n\n// Returns the current time in milliseconds.\nGTEST_API_ TimeInMillis GetTimeInMillis();\n\n// Returns true iff Google Test should use colors in the output.\nGTEST_API_ bool ShouldUseColor(bool stdout_is_tty);\n\n// Formats the given time in milliseconds as seconds.\nGTEST_API_ std::string FormatTimeInMillisAsSeconds(TimeInMillis ms);\n\n// Converts the given time in milliseconds to a date string in the ISO 8601\n// format, without the timezone information.  N.B.: due to the use the\n// non-reentrant localtime() function, this function is not thread safe.  Do\n// not use it in any code that can be called from multiple threads.\nGTEST_API_ std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms);\n\n// Parses a string for an Int32 flag, in the form of \"--flag=value\".\n//\n// On success, stores the value of the flag in *value, and returns\n// true.  On failure, returns false without changing *value.\nGTEST_API_ bool ParseInt32Flag(\n    const char* str, const char* flag, Int32* value);\n\n// Returns a random seed in range [1, kMaxRandomSeed] based on the\n// given --gtest_random_seed flag value.\ninline int GetRandomSeedFromFlag(Int32 random_seed_flag) {\n  const unsigned int raw_seed = (random_seed_flag == 0) ?\n      static_cast<unsigned int>(GetTimeInMillis()) :\n      static_cast<unsigned int>(random_seed_flag);\n\n  // Normalizes the actual seed to range [1, kMaxRandomSeed] such that\n  // it's easy to type.\n  const int normalized_seed =\n      static_cast<int>((raw_seed - 1U) %\n                       static_cast<unsigned int>(kMaxRandomSeed)) + 1;\n  return normalized_seed;\n}\n\n// Returns the first valid random seed after 'seed'.  The behavior is\n// undefined if 'seed' is invalid.  The seed after kMaxRandomSeed is\n// considered to be 1.\ninline int GetNextRandomSeed(int seed) {\n  GTEST_CHECK_(1 <= seed && seed <= kMaxRandomSeed)\n      << \"Invalid random seed \" << seed << \" - must be in [1, \"\n      << kMaxRandomSeed << \"].\";\n  const int next_seed = seed + 1;\n  return (next_seed > kMaxRandomSeed) ? 1 : next_seed;\n}\n\n// This class saves the values of all Google Test flags in its c'tor, and\n// restores them in its d'tor.\nclass GTestFlagSaver {\n public:\n  // The c'tor.\n  GTestFlagSaver() {\n    also_run_disabled_tests_ = GTEST_FLAG(also_run_disabled_tests);\n    break_on_failure_ = GTEST_FLAG(break_on_failure);\n    catch_exceptions_ = GTEST_FLAG(catch_exceptions);\n    color_ = GTEST_FLAG(color);\n    death_test_style_ = GTEST_FLAG(death_test_style);\n    death_test_use_fork_ = GTEST_FLAG(death_test_use_fork);\n    filter_ = GTEST_FLAG(filter);\n    internal_run_death_test_ = GTEST_FLAG(internal_run_death_test);\n    list_tests_ = GTEST_FLAG(list_tests);\n    output_ = GTEST_FLAG(output);\n    print_time_ = GTEST_FLAG(print_time);\n    random_seed_ = GTEST_FLAG(random_seed);\n    repeat_ = GTEST_FLAG(repeat);\n    shuffle_ = GTEST_FLAG(shuffle);\n    stack_trace_depth_ = GTEST_FLAG(stack_trace_depth);\n    stream_result_to_ = GTEST_FLAG(stream_result_to);\n    throw_on_failure_ = GTEST_FLAG(throw_on_failure);\n  }\n\n  // The d'tor is not virtual.  DO NOT INHERIT FROM THIS CLASS.\n  ~GTestFlagSaver() {\n    GTEST_FLAG(also_run_disabled_tests) = also_run_disabled_tests_;\n    GTEST_FLAG(break_on_failure) = break_on_failure_;\n    GTEST_FLAG(catch_exceptions) = catch_exceptions_;\n    GTEST_FLAG(color) = color_;\n    GTEST_FLAG(death_test_style) = death_test_style_;\n    GTEST_FLAG(death_test_use_fork) = death_test_use_fork_;\n    GTEST_FLAG(filter) = filter_;\n    GTEST_FLAG(internal_run_death_test) = internal_run_death_test_;\n    GTEST_FLAG(list_tests) = list_tests_;\n    GTEST_FLAG(output) = output_;\n    GTEST_FLAG(print_time) = print_time_;\n    GTEST_FLAG(random_seed) = random_seed_;\n    GTEST_FLAG(repeat) = repeat_;\n    GTEST_FLAG(shuffle) = shuffle_;\n    GTEST_FLAG(stack_trace_depth) = stack_trace_depth_;\n    GTEST_FLAG(stream_result_to) = stream_result_to_;\n    GTEST_FLAG(throw_on_failure) = throw_on_failure_;\n  }\n\n private:\n  // Fields for saving the original values of flags.\n  bool also_run_disabled_tests_;\n  bool break_on_failure_;\n  bool catch_exceptions_;\n  std::string color_;\n  std::string death_test_style_;\n  bool death_test_use_fork_;\n  std::string filter_;\n  std::string internal_run_death_test_;\n  bool list_tests_;\n  std::string output_;\n  bool print_time_;\n  internal::Int32 random_seed_;\n  internal::Int32 repeat_;\n  bool shuffle_;\n  internal::Int32 stack_trace_depth_;\n  std::string stream_result_to_;\n  bool throw_on_failure_;\n} GTEST_ATTRIBUTE_UNUSED_;\n\n// Converts a Unicode code point to a narrow string in UTF-8 encoding.\n// code_point parameter is of type UInt32 because wchar_t may not be\n// wide enough to contain a code point.\n// If the code_point is not a valid Unicode code point\n// (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted\n// to \"(Invalid Unicode 0xXXXXXXXX)\".\nGTEST_API_ std::string CodePointToUtf8(UInt32 code_point);\n\n// Converts a wide string to a narrow string in UTF-8 encoding.\n// The wide string is assumed to have the following encoding:\n//   UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin, Symbian OS)\n//   UTF-32 if sizeof(wchar_t) == 4 (on Linux)\n// Parameter str points to a null-terminated wide string.\n// Parameter num_chars may additionally limit the number\n// of wchar_t characters processed. -1 is used when the entire string\n// should be processed.\n// If the string contains code points that are not valid Unicode code points\n// (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output\n// as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding\n// and contains invalid UTF-16 surrogate pairs, values in those pairs\n// will be encoded as individual Unicode characters from Basic Normal Plane.\nGTEST_API_ std::string WideStringToUtf8(const wchar_t* str, int num_chars);\n\n// Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file\n// if the variable is present. If a file already exists at this location, this\n// function will write over it. If the variable is present, but the file cannot\n// be created, prints an error and exits.\nvoid WriteToShardStatusFileIfNeeded();\n\n// Checks whether sharding is enabled by examining the relevant\n// environment variable values. If the variables are present,\n// but inconsistent (e.g., shard_index >= total_shards), prints\n// an error and exits. If in_subprocess_for_death_test, sharding is\n// disabled because it must only be applied to the original test\n// process. Otherwise, we could filter out death tests we intended to execute.\nGTEST_API_ bool ShouldShard(const char* total_shards_str,\n                            const char* shard_index_str,\n                            bool in_subprocess_for_death_test);\n\n// Parses the environment variable var as an Int32. If it is unset,\n// returns default_val. If it is not an Int32, prints an error and\n// and aborts.\nGTEST_API_ Int32 Int32FromEnvOrDie(const char* env_var, Int32 default_val);\n\n// Given the total number of shards, the shard index, and the test id,\n// returns true iff the test should be run on this shard. The test id is\n// some arbitrary but unique non-negative integer assigned to each test\n// method. Assumes that 0 <= shard_index < total_shards.\nGTEST_API_ bool ShouldRunTestOnShard(\n    int total_shards, int shard_index, int test_id);\n\n// STL container utilities.\n\n// Returns the number of elements in the given container that satisfy\n// the given predicate.\ntemplate <class Container, typename Predicate>\ninline int CountIf(const Container& c, Predicate predicate) {\n  // Implemented as an explicit loop since std::count_if() in libCstd on\n  // Solaris has a non-standard signature.\n  int count = 0;\n  for (typename Container::const_iterator it = c.begin(); it != c.end(); ++it) {\n    if (predicate(*it))\n      ++count;\n  }\n  return count;\n}\n\n// Applies a function/functor to each element in the container.\ntemplate <class Container, typename Functor>\nvoid ForEach(const Container& c, Functor functor) {\n  std::for_each(c.begin(), c.end(), functor);\n}\n\n// Returns the i-th element of the vector, or default_value if i is not\n// in range [0, v.size()).\ntemplate <typename E>\ninline E GetElementOr(const std::vector<E>& v, int i, E default_value) {\n  return (i < 0 || i >= static_cast<int>(v.size())) ? default_value : v[i];\n}\n\n// Performs an in-place shuffle of a range of the vector's elements.\n// 'begin' and 'end' are element indices as an STL-style range;\n// i.e. [begin, end) are shuffled, where 'end' == size() means to\n// shuffle to the end of the vector.\ntemplate <typename E>\nvoid ShuffleRange(internal::Random* random, int begin, int end,\n                  std::vector<E>* v) {\n  const int size = static_cast<int>(v->size());\n  GTEST_CHECK_(0 <= begin && begin <= size)\n      << \"Invalid shuffle range start \" << begin << \": must be in range [0, \"\n      << size << \"].\";\n  GTEST_CHECK_(begin <= end && end <= size)\n      << \"Invalid shuffle range finish \" << end << \": must be in range [\"\n      << begin << \", \" << size << \"].\";\n\n  // Fisher-Yates shuffle, from\n  // http://en.wikipedia.org/wiki/Fisher-Yates_shuffle\n  for (int range_width = end - begin; range_width >= 2; range_width--) {\n    const int last_in_range = begin + range_width - 1;\n    const int selected = begin + random->Generate(range_width);\n    std::swap((*v)[selected], (*v)[last_in_range]);\n  }\n}\n\n// Performs an in-place shuffle of the vector's elements.\ntemplate <typename E>\ninline void Shuffle(internal::Random* random, std::vector<E>* v) {\n  ShuffleRange(random, 0, static_cast<int>(v->size()), v);\n}\n\n// A function for deleting an object.  Handy for being used as a\n// functor.\ntemplate <typename T>\nstatic void Delete(T* x) {\n  delete x;\n}\n\n// A predicate that checks the key of a TestProperty against a known key.\n//\n// TestPropertyKeyIs is copyable.\nclass TestPropertyKeyIs {\n public:\n  // Constructor.\n  //\n  // TestPropertyKeyIs has NO default constructor.\n  explicit TestPropertyKeyIs(const std::string& key) : key_(key) {}\n\n  // Returns true iff the test name of test property matches on key_.\n  bool operator()(const TestProperty& test_property) const {\n    return test_property.key() == key_;\n  }\n\n private:\n  std::string key_;\n};\n\n// Class UnitTestOptions.\n//\n// This class contains functions for processing options the user\n// specifies when running the tests.  It has only static members.\n//\n// In most cases, the user can specify an option using either an\n// environment variable or a command line flag.  E.g. you can set the\n// test filter using either GTEST_FILTER or --gtest_filter.  If both\n// the variable and the flag are present, the latter overrides the\n// former.\nclass GTEST_API_ UnitTestOptions {\n public:\n  // Functions for processing the gtest_output flag.\n\n  // Returns the output format, or \"\" for normal printed output.\n  static std::string GetOutputFormat();\n\n  // Returns the absolute path of the requested output file, or the\n  // default (test_detail.xml in the original working directory) if\n  // none was explicitly specified.\n  static std::string GetAbsolutePathToOutputFile();\n\n  // Functions for processing the gtest_filter flag.\n\n  // Returns true iff the wildcard pattern matches the string.  The\n  // first ':' or '\\0' character in pattern marks the end of it.\n  //\n  // This recursive algorithm isn't very efficient, but is clear and\n  // works well enough for matching test names, which are short.\n  static bool PatternMatchesString(const char *pattern, const char *str);\n\n  // Returns true iff the user-specified filter matches the test case\n  // name and the test name.\n  static bool FilterMatchesTest(const std::string &test_case_name,\n                                const std::string &test_name);\n\n#if GTEST_OS_WINDOWS\n  // Function for supporting the gtest_catch_exception flag.\n\n  // Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the\n  // given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.\n  // This function is useful as an __except condition.\n  static int GTestShouldProcessSEH(DWORD exception_code);\n#endif  // GTEST_OS_WINDOWS\n\n  // Returns true if \"name\" matches the ':' separated list of glob-style\n  // filters in \"filter\".\n  static bool MatchesFilter(const std::string& name, const char* filter);\n};\n\n// Returns the current application's name, removing directory path if that\n// is present.  Used by UnitTestOptions::GetOutputFile.\nGTEST_API_ FilePath GetCurrentExecutableName();\n\n// The role interface for getting the OS stack trace as a string.\nclass OsStackTraceGetterInterface {\n public:\n  OsStackTraceGetterInterface() {}\n  virtual ~OsStackTraceGetterInterface() {}\n\n  // Returns the current OS stack trace as an std::string.  Parameters:\n  //\n  //   max_depth  - the maximum number of stack frames to be included\n  //                in the trace.\n  //   skip_count - the number of top frames to be skipped; doesn't count\n  //                against max_depth.\n  virtual string CurrentStackTrace(int max_depth, int skip_count) = 0;\n\n  // UponLeavingGTest() should be called immediately before Google Test calls\n  // user code. It saves some information about the current stack that\n  // CurrentStackTrace() will use to find and hide Google Test stack frames.\n  virtual void UponLeavingGTest() = 0;\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetterInterface);\n};\n\n// A working implementation of the OsStackTraceGetterInterface interface.\nclass OsStackTraceGetter : public OsStackTraceGetterInterface {\n public:\n  OsStackTraceGetter() : caller_frame_(NULL) {}\n\n  virtual string CurrentStackTrace(int max_depth, int skip_count)\n      GTEST_LOCK_EXCLUDED_(mutex_);\n\n  virtual void UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_);\n\n  // This string is inserted in place of stack frames that are part of\n  // Google Test's implementation.\n  static const char* const kElidedFramesMarker;\n\n private:\n  Mutex mutex_;  // protects all internal state\n\n  // We save the stack frame below the frame that calls user code.\n  // We do this because the address of the frame immediately below\n  // the user code changes between the call to UponLeavingGTest()\n  // and any calls to CurrentStackTrace() from within the user code.\n  void* caller_frame_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetter);\n};\n\n// Information about a Google Test trace point.\nstruct TraceInfo {\n  const char* file;\n  int line;\n  std::string message;\n};\n\n// This is the default global test part result reporter used in UnitTestImpl.\n// This class should only be used by UnitTestImpl.\nclass DefaultGlobalTestPartResultReporter\n  : public TestPartResultReporterInterface {\n public:\n  explicit DefaultGlobalTestPartResultReporter(UnitTestImpl* unit_test);\n  // Implements the TestPartResultReporterInterface. Reports the test part\n  // result in the current test.\n  virtual void ReportTestPartResult(const TestPartResult& result);\n\n private:\n  UnitTestImpl* const unit_test_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultGlobalTestPartResultReporter);\n};\n\n// This is the default per thread test part result reporter used in\n// UnitTestImpl. This class should only be used by UnitTestImpl.\nclass DefaultPerThreadTestPartResultReporter\n    : public TestPartResultReporterInterface {\n public:\n  explicit DefaultPerThreadTestPartResultReporter(UnitTestImpl* unit_test);\n  // Implements the TestPartResultReporterInterface. The implementation just\n  // delegates to the current global test part result reporter of *unit_test_.\n  virtual void ReportTestPartResult(const TestPartResult& result);\n\n private:\n  UnitTestImpl* const unit_test_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultPerThreadTestPartResultReporter);\n};\n\n// The private implementation of the UnitTest class.  We don't protect\n// the methods under a mutex, as this class is not accessible by a\n// user and the UnitTest class that delegates work to this class does\n// proper locking.\nclass GTEST_API_ UnitTestImpl {\n public:\n  explicit UnitTestImpl(UnitTest* parent);\n  virtual ~UnitTestImpl();\n\n  // There are two different ways to register your own TestPartResultReporter.\n  // You can register your own repoter to listen either only for test results\n  // from the current thread or for results from all threads.\n  // By default, each per-thread test result repoter just passes a new\n  // TestPartResult to the global test result reporter, which registers the\n  // test part result for the currently running test.\n\n  // Returns the global test part result reporter.\n  TestPartResultReporterInterface* GetGlobalTestPartResultReporter();\n\n  // Sets the global test part result reporter.\n  void SetGlobalTestPartResultReporter(\n      TestPartResultReporterInterface* reporter);\n\n  // Returns the test part result reporter for the current thread.\n  TestPartResultReporterInterface* GetTestPartResultReporterForCurrentThread();\n\n  // Sets the test part result reporter for the current thread.\n  void SetTestPartResultReporterForCurrentThread(\n      TestPartResultReporterInterface* reporter);\n\n  // Gets the number of successful test cases.\n  int successful_test_case_count() const;\n\n  // Gets the number of failed test cases.\n  int failed_test_case_count() const;\n\n  // Gets the number of all test cases.\n  int total_test_case_count() const;\n\n  // Gets the number of all test cases that contain at least one test\n  // that should run.\n  int test_case_to_run_count() const;\n\n  // Gets the number of successful tests.\n  int successful_test_count() const;\n\n  // Gets the number of failed tests.\n  int failed_test_count() const;\n\n  // Gets the number of disabled tests that will be reported in the XML report.\n  int reportable_disabled_test_count() const;\n\n  // Gets the number of disabled tests.\n  int disabled_test_count() const;\n\n  // Gets the number of tests to be printed in the XML report.\n  int reportable_test_count() const;\n\n  // Gets the number of all tests.\n  int total_test_count() const;\n\n  // Gets the number of tests that should run.\n  int test_to_run_count() const;\n\n  // Gets the time of the test program start, in ms from the start of the\n  // UNIX epoch.\n  TimeInMillis start_timestamp() const { return start_timestamp_; }\n\n  // Gets the elapsed time, in milliseconds.\n  TimeInMillis elapsed_time() const { return elapsed_time_; }\n\n  // Returns true iff the unit test passed (i.e. all test cases passed).\n  bool Passed() const { return !Failed(); }\n\n  // Returns true iff the unit test failed (i.e. some test case failed\n  // or something outside of all tests failed).\n  bool Failed() const {\n    return failed_test_case_count() > 0 || ad_hoc_test_result()->Failed();\n  }\n\n  // Gets the i-th test case among all the test cases. i can range from 0 to\n  // total_test_case_count() - 1. If i is not in that range, returns NULL.\n  const TestCase* GetTestCase(int i) const {\n    const int index = GetElementOr(test_case_indices_, i, -1);\n    return index < 0 ? NULL : test_cases_[i];\n  }\n\n  // Gets the i-th test case among all the test cases. i can range from 0 to\n  // total_test_case_count() - 1. If i is not in that range, returns NULL.\n  TestCase* GetMutableTestCase(int i) {\n    const int index = GetElementOr(test_case_indices_, i, -1);\n    return index < 0 ? NULL : test_cases_[index];\n  }\n\n  // Provides access to the event listener list.\n  TestEventListeners* listeners() { return &listeners_; }\n\n  // Returns the TestResult for the test that's currently running, or\n  // the TestResult for the ad hoc test if no test is running.\n  TestResult* current_test_result();\n\n  // Returns the TestResult for the ad hoc test.\n  const TestResult* ad_hoc_test_result() const { return &ad_hoc_test_result_; }\n\n  // Sets the OS stack trace getter.\n  //\n  // Does nothing if the input and the current OS stack trace getter\n  // are the same; otherwise, deletes the old getter and makes the\n  // input the current getter.\n  void set_os_stack_trace_getter(OsStackTraceGetterInterface* getter);\n\n  // Returns the current OS stack trace getter if it is not NULL;\n  // otherwise, creates an OsStackTraceGetter, makes it the current\n  // getter, and returns it.\n  OsStackTraceGetterInterface* os_stack_trace_getter();\n\n  // Returns the current OS stack trace as an std::string.\n  //\n  // The maximum number of stack frames to be included is specified by\n  // the gtest_stack_trace_depth flag.  The skip_count parameter\n  // specifies the number of top frames to be skipped, which doesn't\n  // count against the number of frames to be included.\n  //\n  // For example, if Foo() calls Bar(), which in turn calls\n  // CurrentOsStackTraceExceptTop(1), Foo() will be included in the\n  // trace but Bar() and CurrentOsStackTraceExceptTop() won't.\n  std::string CurrentOsStackTraceExceptTop(int skip_count) GTEST_NO_INLINE_;\n\n  // Finds and returns a TestCase with the given name.  If one doesn't\n  // exist, creates one and returns it.\n  //\n  // Arguments:\n  //\n  //   test_case_name: name of the test case\n  //   type_param:     the name of the test's type parameter, or NULL if\n  //                   this is not a typed or a type-parameterized test.\n  //   set_up_tc:      pointer to the function that sets up the test case\n  //   tear_down_tc:   pointer to the function that tears down the test case\n  TestCase* GetTestCase(const char* test_case_name,\n                        const char* type_param,\n                        Test::SetUpTestCaseFunc set_up_tc,\n                        Test::TearDownTestCaseFunc tear_down_tc);\n\n  // Adds a TestInfo to the unit test.\n  //\n  // Arguments:\n  //\n  //   set_up_tc:    pointer to the function that sets up the test case\n  //   tear_down_tc: pointer to the function that tears down the test case\n  //   test_info:    the TestInfo object\n  void AddTestInfo(Test::SetUpTestCaseFunc set_up_tc,\n                   Test::TearDownTestCaseFunc tear_down_tc,\n                   TestInfo* test_info) {\n    // In order to support thread-safe death tests, we need to\n    // remember the original working directory when the test program\n    // was first invoked.  We cannot do this in RUN_ALL_TESTS(), as\n    // the user may have changed the current directory before calling\n    // RUN_ALL_TESTS().  Therefore we capture the current directory in\n    // AddTestInfo(), which is called to register a TEST or TEST_F\n    // before main() is reached.\n    if (original_working_dir_.IsEmpty()) {\n      original_working_dir_.Set(FilePath::GetCurrentDir());\n      GTEST_CHECK_(!original_working_dir_.IsEmpty())\n          << \"Failed to get the current working directory.\";\n    }\n\n    GetTestCase(test_info->test_case_name(),\n                test_info->type_param(),\n                set_up_tc,\n                tear_down_tc)->AddTestInfo(test_info);\n  }\n\n#if GTEST_HAS_PARAM_TEST\n  // Returns ParameterizedTestCaseRegistry object used to keep track of\n  // value-parameterized tests and instantiate and register them.\n  internal::ParameterizedTestCaseRegistry& parameterized_test_registry() {\n    return parameterized_test_registry_;\n  }\n#endif  // GTEST_HAS_PARAM_TEST\n\n  // Sets the TestCase object for the test that's currently running.\n  void set_current_test_case(TestCase* a_current_test_case) {\n    current_test_case_ = a_current_test_case;\n  }\n\n  // Sets the TestInfo object for the test that's currently running.  If\n  // current_test_info is NULL, the assertion results will be stored in\n  // ad_hoc_test_result_.\n  void set_current_test_info(TestInfo* a_current_test_info) {\n    current_test_info_ = a_current_test_info;\n  }\n\n  // Registers all parameterized tests defined using TEST_P and\n  // INSTANTIATE_TEST_CASE_P, creating regular tests for each test/parameter\n  // combination. This method can be called more then once; it has guards\n  // protecting from registering the tests more then once.  If\n  // value-parameterized tests are disabled, RegisterParameterizedTests is\n  // present but does nothing.\n  void RegisterParameterizedTests();\n\n  // Runs all tests in this UnitTest object, prints the result, and\n  // returns true if all tests are successful.  If any exception is\n  // thrown during a test, this test is considered to be failed, but\n  // the rest of the tests will still be run.\n  bool RunAllTests();\n\n  // Clears the results of all tests, except the ad hoc tests.\n  void ClearNonAdHocTestResult() {\n    ForEach(test_cases_, TestCase::ClearTestCaseResult);\n  }\n\n  // Clears the results of ad-hoc test assertions.\n  void ClearAdHocTestResult() {\n    ad_hoc_test_result_.Clear();\n  }\n\n  // Adds a TestProperty to the current TestResult object when invoked in a\n  // context of a test or a test case, or to the global property set. If the\n  // result already contains a property with the same key, the value will be\n  // updated.\n  void RecordProperty(const TestProperty& test_property);\n\n  enum ReactionToSharding {\n    HONOR_SHARDING_PROTOCOL,\n    IGNORE_SHARDING_PROTOCOL\n  };\n\n  // Matches the full name of each test against the user-specified\n  // filter to decide whether the test should run, then records the\n  // result in each TestCase and TestInfo object.\n  // If shard_tests == HONOR_SHARDING_PROTOCOL, further filters tests\n  // based on sharding variables in the environment.\n  // Returns the number of tests that should run.\n  int FilterTests(ReactionToSharding shard_tests);\n\n  // Prints the names of the tests matching the user-specified filter flag.\n  void ListTestsMatchingFilter();\n\n  const TestCase* current_test_case() const { return current_test_case_; }\n  TestInfo* current_test_info() { return current_test_info_; }\n  const TestInfo* current_test_info() const { return current_test_info_; }\n\n  // Returns the vector of environments that need to be set-up/torn-down\n  // before/after the tests are run.\n  std::vector<Environment*>& environments() { return environments_; }\n\n  // Getters for the per-thread Google Test trace stack.\n  std::vector<TraceInfo>& gtest_trace_stack() {\n    return *(gtest_trace_stack_.pointer());\n  }\n  const std::vector<TraceInfo>& gtest_trace_stack() const {\n    return gtest_trace_stack_.get();\n  }\n\n#if GTEST_HAS_DEATH_TEST\n  void InitDeathTestSubprocessControlInfo() {\n    internal_run_death_test_flag_.reset(ParseInternalRunDeathTestFlag());\n  }\n  // Returns a pointer to the parsed --gtest_internal_run_death_test\n  // flag, or NULL if that flag was not specified.\n  // This information is useful only in a death test child process.\n  // Must not be called before a call to InitGoogleTest.\n  const InternalRunDeathTestFlag* internal_run_death_test_flag() const {\n    return internal_run_death_test_flag_.get();\n  }\n\n  // Returns a pointer to the current death test factory.\n  internal::DeathTestFactory* death_test_factory() {\n    return death_test_factory_.get();\n  }\n\n  void SuppressTestEventsIfInSubprocess();\n\n  friend class ReplaceDeathTestFactory;\n#endif  // GTEST_HAS_DEATH_TEST\n\n  // Initializes the event listener performing XML output as specified by\n  // UnitTestOptions. Must not be called before InitGoogleTest.\n  void ConfigureXmlOutput();\n\n#if GTEST_CAN_STREAM_RESULTS_\n  // Initializes the event listener for streaming test results to a socket.\n  // Must not be called before InitGoogleTest.\n  void ConfigureStreamingOutput();\n#endif\n\n  // Performs initialization dependent upon flag values obtained in\n  // ParseGoogleTestFlagsOnly.  Is called from InitGoogleTest after the call to\n  // ParseGoogleTestFlagsOnly.  In case a user neglects to call InitGoogleTest\n  // this function is also called from RunAllTests.  Since this function can be\n  // called more than once, it has to be idempotent.\n  void PostFlagParsingInit();\n\n  // Gets the random seed used at the start of the current test iteration.\n  int random_seed() const { return random_seed_; }\n\n  // Gets the random number generator.\n  internal::Random* random() { return &random_; }\n\n  // Shuffles all test cases, and the tests within each test case,\n  // making sure that death tests are still run first.\n  void ShuffleTests();\n\n  // Restores the test cases and tests to their order before the first shuffle.\n  void UnshuffleTests();\n\n  // Returns the value of GTEST_FLAG(catch_exceptions) at the moment\n  // UnitTest::Run() starts.\n  bool catch_exceptions() const { return catch_exceptions_; }\n\n private:\n  friend class ::testing::UnitTest;\n\n  // Used by UnitTest::Run() to capture the state of\n  // GTEST_FLAG(catch_exceptions) at the moment it starts.\n  void set_catch_exceptions(bool value) { catch_exceptions_ = value; }\n\n  // The UnitTest object that owns this implementation object.\n  UnitTest* const parent_;\n\n  // The working directory when the first TEST() or TEST_F() was\n  // executed.\n  internal::FilePath original_working_dir_;\n\n  // The default test part result reporters.\n  DefaultGlobalTestPartResultReporter default_global_test_part_result_reporter_;\n  DefaultPerThreadTestPartResultReporter\n      default_per_thread_test_part_result_reporter_;\n\n  // Points to (but doesn't own) the global test part result reporter.\n  TestPartResultReporterInterface* global_test_part_result_repoter_;\n\n  // Protects read and write access to global_test_part_result_reporter_.\n  internal::Mutex global_test_part_result_reporter_mutex_;\n\n  // Points to (but doesn't own) the per-thread test part result reporter.\n  internal::ThreadLocal<TestPartResultReporterInterface*>\n      per_thread_test_part_result_reporter_;\n\n  // The vector of environments that need to be set-up/torn-down\n  // before/after the tests are run.\n  std::vector<Environment*> environments_;\n\n  // The vector of TestCases in their original order.  It owns the\n  // elements in the vector.\n  std::vector<TestCase*> test_cases_;\n\n  // Provides a level of indirection for the test case list to allow\n  // easy shuffling and restoring the test case order.  The i-th\n  // element of this vector is the index of the i-th test case in the\n  // shuffled order.\n  std::vector<int> test_case_indices_;\n\n#if GTEST_HAS_PARAM_TEST\n  // ParameterizedTestRegistry object used to register value-parameterized\n  // tests.\n  internal::ParameterizedTestCaseRegistry parameterized_test_registry_;\n\n  // Indicates whether RegisterParameterizedTests() has been called already.\n  bool parameterized_tests_registered_;\n#endif  // GTEST_HAS_PARAM_TEST\n\n  // Index of the last death test case registered.  Initially -1.\n  int last_death_test_case_;\n\n  // This points to the TestCase for the currently running test.  It\n  // changes as Google Test goes through one test case after another.\n  // When no test is running, this is set to NULL and Google Test\n  // stores assertion results in ad_hoc_test_result_.  Initially NULL.\n  TestCase* current_test_case_;\n\n  // This points to the TestInfo for the currently running test.  It\n  // changes as Google Test goes through one test after another.  When\n  // no test is running, this is set to NULL and Google Test stores\n  // assertion results in ad_hoc_test_result_.  Initially NULL.\n  TestInfo* current_test_info_;\n\n  // Normally, a user only writes assertions inside a TEST or TEST_F,\n  // or inside a function called by a TEST or TEST_F.  Since Google\n  // Test keeps track of which test is current running, it can\n  // associate such an assertion with the test it belongs to.\n  //\n  // If an assertion is encountered when no TEST or TEST_F is running,\n  // Google Test attributes the assertion result to an imaginary \"ad hoc\"\n  // test, and records the result in ad_hoc_test_result_.\n  TestResult ad_hoc_test_result_;\n\n  // The list of event listeners that can be used to track events inside\n  // Google Test.\n  TestEventListeners listeners_;\n\n  // The OS stack trace getter.  Will be deleted when the UnitTest\n  // object is destructed.  By default, an OsStackTraceGetter is used,\n  // but the user can set this field to use a custom getter if that is\n  // desired.\n  OsStackTraceGetterInterface* os_stack_trace_getter_;\n\n  // True iff PostFlagParsingInit() has been called.\n  bool post_flag_parse_init_performed_;\n\n  // The random number seed used at the beginning of the test run.\n  int random_seed_;\n\n  // Our random number generator.\n  internal::Random random_;\n\n  // The time of the test program start, in ms from the start of the\n  // UNIX epoch.\n  TimeInMillis start_timestamp_;\n\n  // How long the test took to run, in milliseconds.\n  TimeInMillis elapsed_time_;\n\n#if GTEST_HAS_DEATH_TEST\n  // The decomposed components of the gtest_internal_run_death_test flag,\n  // parsed when RUN_ALL_TESTS is called.\n  internal::scoped_ptr<InternalRunDeathTestFlag> internal_run_death_test_flag_;\n  internal::scoped_ptr<internal::DeathTestFactory> death_test_factory_;\n#endif  // GTEST_HAS_DEATH_TEST\n\n  // A per-thread stack of traces created by the SCOPED_TRACE() macro.\n  internal::ThreadLocal<std::vector<TraceInfo> > gtest_trace_stack_;\n\n  // The value of GTEST_FLAG(catch_exceptions) at the moment RunAllTests()\n  // starts.\n  bool catch_exceptions_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTestImpl);\n};  // class UnitTestImpl\n\n// Convenience function for accessing the global UnitTest\n// implementation object.\ninline UnitTestImpl* GetUnitTestImpl() {\n  return UnitTest::GetInstance()->impl();\n}\n\n#if GTEST_USES_SIMPLE_RE\n\n// Internal helper functions for implementing the simple regular\n// expression matcher.\nGTEST_API_ bool IsInSet(char ch, const char* str);\nGTEST_API_ bool IsAsciiDigit(char ch);\nGTEST_API_ bool IsAsciiPunct(char ch);\nGTEST_API_ bool IsRepeat(char ch);\nGTEST_API_ bool IsAsciiWhiteSpace(char ch);\nGTEST_API_ bool IsAsciiWordChar(char ch);\nGTEST_API_ bool IsValidEscape(char ch);\nGTEST_API_ bool AtomMatchesChar(bool escaped, char pattern, char ch);\nGTEST_API_ bool ValidateRegex(const char* regex);\nGTEST_API_ bool MatchRegexAtHead(const char* regex, const char* str);\nGTEST_API_ bool MatchRepetitionAndRegexAtHead(\n    bool escaped, char ch, char repeat, const char* regex, const char* str);\nGTEST_API_ bool MatchRegexAnywhere(const char* regex, const char* str);\n\n#endif  // GTEST_USES_SIMPLE_RE\n\n// Parses the command line for Google Test flags, without initializing\n// other parts of Google Test.\nGTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, char** argv);\nGTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv);\n\n#if GTEST_HAS_DEATH_TEST\n\n// Returns the message describing the last system error, regardless of the\n// platform.\nGTEST_API_ std::string GetLastErrnoDescription();\n\n# if GTEST_OS_WINDOWS\n// Provides leak-safe Windows kernel handle ownership.\nclass AutoHandle {\n public:\n  AutoHandle() : handle_(INVALID_HANDLE_VALUE) {}\n  explicit AutoHandle(HANDLE handle) : handle_(handle) {}\n\n  ~AutoHandle() { Reset(); }\n\n  HANDLE Get() const { return handle_; }\n  void Reset() { Reset(INVALID_HANDLE_VALUE); }\n  void Reset(HANDLE handle) {\n    if (handle != handle_) {\n      if (handle_ != INVALID_HANDLE_VALUE)\n        ::CloseHandle(handle_);\n      handle_ = handle;\n    }\n  }\n\n private:\n  HANDLE handle_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(AutoHandle);\n};\n# endif  // GTEST_OS_WINDOWS\n\n// Attempts to parse a string into a positive integer pointed to by the\n// number parameter.  Returns true if that is possible.\n// GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we can use\n// it here.\ntemplate <typename Integer>\nbool ParseNaturalNumber(const ::std::string& str, Integer* number) {\n  // Fail fast if the given string does not begin with a digit;\n  // this bypasses strtoXXX's \"optional leading whitespace and plus\n  // or minus sign\" semantics, which are undesirable here.\n  if (str.empty() || !IsDigit(str[0])) {\n    return false;\n  }\n  errno = 0;\n\n  char* end;\n  // BiggestConvertible is the largest integer type that system-provided\n  // string-to-number conversion routines can return.\n\n# if GTEST_OS_WINDOWS && !defined(__GNUC__)\n\n  // MSVC and C++ Builder define __int64 instead of the standard long long.\n  typedef unsigned __int64 BiggestConvertible;\n  const BiggestConvertible parsed = _strtoui64(str.c_str(), &end, 10);\n\n# else\n\n  typedef unsigned long long BiggestConvertible;  // NOLINT\n  const BiggestConvertible parsed = strtoull(str.c_str(), &end, 10);\n\n# endif  // GTEST_OS_WINDOWS && !defined(__GNUC__)\n\n  const bool parse_success = *end == '\\0' && errno == 0;\n\n  // TODO(vladl@google.com): Convert this to compile time assertion when it is\n  // available.\n  GTEST_CHECK_(sizeof(Integer) <= sizeof(parsed));\n\n  const Integer result = static_cast<Integer>(parsed);\n  if (parse_success && static_cast<BiggestConvertible>(result) == parsed) {\n    *number = result;\n    return true;\n  }\n  return false;\n}\n#endif  // GTEST_HAS_DEATH_TEST\n\n// TestResult contains some private methods that should be hidden from\n// Google Test user but are required for testing. This class allow our tests\n// to access them.\n//\n// This class is supplied only for the purpose of testing Google Test's own\n// constructs. Do not use it in user tests, either directly or indirectly.\nclass TestResultAccessor {\n public:\n  static void RecordProperty(TestResult* test_result,\n                             const std::string& xml_element,\n                             const TestProperty& property) {\n    test_result->RecordProperty(xml_element, property);\n  }\n\n  static void ClearTestPartResults(TestResult* test_result) {\n    test_result->ClearTestPartResults();\n  }\n\n  static const std::vector<testing::TestPartResult>& test_part_results(\n      const TestResult& test_result) {\n    return test_result.test_part_results();\n  }\n};\n\n#if GTEST_CAN_STREAM_RESULTS_\n\n// Streams test results to the given port on the given host machine.\nclass StreamingListener : public EmptyTestEventListener {\n public:\n  // Abstract base class for writing strings to a socket.\n  class AbstractSocketWriter {\n   public:\n    virtual ~AbstractSocketWriter() {}\n\n    // Sends a string to the socket.\n    virtual void Send(const string& message) = 0;\n\n    // Closes the socket.\n    virtual void CloseConnection() {}\n\n    // Sends a string and a newline to the socket.\n    void SendLn(const string& message) {\n      Send(message + \"\\n\");\n    }\n  };\n\n  // Concrete class for actually writing strings to a socket.\n  class SocketWriter : public AbstractSocketWriter {\n   public:\n    SocketWriter(const string& host, const string& port)\n        : sockfd_(-1), host_name_(host), port_num_(port) {\n      MakeConnection();\n    }\n\n    virtual ~SocketWriter() {\n      if (sockfd_ != -1)\n        CloseConnection();\n    }\n\n    // Sends a string to the socket.\n    virtual void Send(const string& message) {\n      GTEST_CHECK_(sockfd_ != -1)\n          << \"Send() can be called only when there is a connection.\";\n\n      const int len = static_cast<int>(message.length());\n      if (write(sockfd_, message.c_str(), len) != len) {\n        GTEST_LOG_(WARNING)\n            << \"stream_result_to: failed to stream to \"\n            << host_name_ << \":\" << port_num_;\n      }\n    }\n\n   private:\n    // Creates a client socket and connects to the server.\n    void MakeConnection();\n\n    // Closes the socket.\n    void CloseConnection() {\n      GTEST_CHECK_(sockfd_ != -1)\n          << \"CloseConnection() can be called only when there is a connection.\";\n\n      close(sockfd_);\n      sockfd_ = -1;\n    }\n\n    int sockfd_;  // socket file descriptor\n    const string host_name_;\n    const string port_num_;\n\n    GTEST_DISALLOW_COPY_AND_ASSIGN_(SocketWriter);\n  };  // class SocketWriter\n\n  // Escapes '=', '&', '%', and '\\n' characters in str as \"%xx\".\n  static string UrlEncode(const char* str);\n\n  StreamingListener(const string& host, const string& port)\n      : socket_writer_(new SocketWriter(host, port)) { Start(); }\n\n  explicit StreamingListener(AbstractSocketWriter* socket_writer)\n      : socket_writer_(socket_writer) { Start(); }\n\n  void OnTestProgramStart(const UnitTest& /* unit_test */) {\n    SendLn(\"event=TestProgramStart\");\n  }\n\n  void OnTestProgramEnd(const UnitTest& unit_test) {\n    // Note that Google Test current only report elapsed time for each\n    // test iteration, not for the entire test program.\n    SendLn(\"event=TestProgramEnd&passed=\" + FormatBool(unit_test.Passed()));\n\n    // Notify the streaming server to stop.\n    socket_writer_->CloseConnection();\n  }\n\n  void OnTestIterationStart(const UnitTest& /* unit_test */, int iteration) {\n    SendLn(\"event=TestIterationStart&iteration=\" +\n           StreamableToString(iteration));\n  }\n\n  void OnTestIterationEnd(const UnitTest& unit_test, int /* iteration */) {\n    SendLn(\"event=TestIterationEnd&passed=\" +\n           FormatBool(unit_test.Passed()) + \"&elapsed_time=\" +\n           StreamableToString(unit_test.elapsed_time()) + \"ms\");\n  }\n\n  void OnTestCaseStart(const TestCase& test_case) {\n    SendLn(std::string(\"event=TestCaseStart&name=\") + test_case.name());\n  }\n\n  void OnTestCaseEnd(const TestCase& test_case) {\n    SendLn(\"event=TestCaseEnd&passed=\" + FormatBool(test_case.Passed())\n           + \"&elapsed_time=\" + StreamableToString(test_case.elapsed_time())\n           + \"ms\");\n  }\n\n  void OnTestStart(const TestInfo& test_info) {\n    SendLn(std::string(\"event=TestStart&name=\") + test_info.name());\n  }\n\n  void OnTestEnd(const TestInfo& test_info) {\n    SendLn(\"event=TestEnd&passed=\" +\n           FormatBool((test_info.result())->Passed()) +\n           \"&elapsed_time=\" +\n           StreamableToString((test_info.result())->elapsed_time()) + \"ms\");\n  }\n\n  void OnTestPartResult(const TestPartResult& test_part_result) {\n    const char* file_name = test_part_result.file_name();\n    if (file_name == NULL)\n      file_name = \"\";\n    SendLn(\"event=TestPartResult&file=\" + UrlEncode(file_name) +\n           \"&line=\" + StreamableToString(test_part_result.line_number()) +\n           \"&message=\" + UrlEncode(test_part_result.message()));\n  }\n\n private:\n  // Sends the given message and a newline to the socket.\n  void SendLn(const string& message) { socket_writer_->SendLn(message); }\n\n  // Called at the start of streaming to notify the receiver what\n  // protocol we are using.\n  void Start() { SendLn(\"gtest_streaming_protocol_version=1.0\"); }\n\n  string FormatBool(bool value) { return value ? \"1\" : \"0\"; }\n\n  const scoped_ptr<AbstractSocketWriter> socket_writer_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamingListener);\n};  // class StreamingListener\n\n#endif  // GTEST_CAN_STREAM_RESULTS_\n\n}  // namespace internal\n}  // namespace testing\n\n#endif  // GTEST_SRC_GTEST_INTERNAL_INL_H_\n"
  },
  {
    "path": "ext/gtest/src/gtest-port.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"gtest/internal/gtest-port.h\"\n\n#include <limits.h>\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n\n#if GTEST_OS_WINDOWS_MOBILE\n# include <windows.h>  // For TerminateProcess()\n#elif GTEST_OS_WINDOWS\n# include <io.h>\n# include <sys/stat.h>\n#else\n# include <unistd.h>\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\n#if GTEST_OS_MAC\n# include <mach/mach_init.h>\n# include <mach/task.h>\n# include <mach/vm_map.h>\n#endif  // GTEST_OS_MAC\n\n#if GTEST_OS_QNX\n# include <devctl.h>\n# include <sys/procfs.h>\n#endif  // GTEST_OS_QNX\n\n#include \"gtest/gtest-spi.h\"\n#include \"gtest/gtest-message.h\"\n#include \"gtest/internal/gtest-internal.h\"\n#include \"gtest/internal/gtest-string.h\"\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick is to\n// prevent a user from accidentally including gtest-internal-inl.h in\n// his code.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\nnamespace testing {\nnamespace internal {\n\n#if defined(_MSC_VER) || defined(__BORLANDC__)\n// MSVC and C++Builder do not provide a definition of STDERR_FILENO.\nconst int kStdOutFileno = 1;\nconst int kStdErrFileno = 2;\n#else\nconst int kStdOutFileno = STDOUT_FILENO;\nconst int kStdErrFileno = STDERR_FILENO;\n#endif  // _MSC_VER\n\n#if GTEST_OS_MAC\n\n// Returns the number of threads running in the process, or 0 to indicate that\n// we cannot detect it.\nsize_t GetThreadCount() {\n  const task_t task = mach_task_self();\n  mach_msg_type_number_t thread_count;\n  thread_act_array_t thread_list;\n  const kern_return_t status = task_threads(task, &thread_list, &thread_count);\n  if (status == KERN_SUCCESS) {\n    // task_threads allocates resources in thread_list and we need to free them\n    // to avoid leaks.\n    vm_deallocate(task,\n                  reinterpret_cast<vm_address_t>(thread_list),\n                  sizeof(thread_t) * thread_count);\n    return static_cast<size_t>(thread_count);\n  } else {\n    return 0;\n  }\n}\n\n#elif GTEST_OS_QNX\n\n// Returns the number of threads running in the process, or 0 to indicate that\n// we cannot detect it.\nsize_t GetThreadCount() {\n  const int fd = open(\"/proc/self/as\", O_RDONLY);\n  if (fd < 0) {\n    return 0;\n  }\n  procfs_info process_info;\n  const int status =\n      devctl(fd, DCMD_PROC_INFO, &process_info, sizeof(process_info), NULL);\n  close(fd);\n  if (status == EOK) {\n    return static_cast<size_t>(process_info.num_threads);\n  } else {\n    return 0;\n  }\n}\n\n#else\n\nsize_t GetThreadCount() {\n  // There's no portable way to detect the number of threads, so we just\n  // return 0 to indicate that we cannot detect it.\n  return 0;\n}\n\n#endif  // GTEST_OS_MAC\n\n#if GTEST_USES_POSIX_RE\n\n// Implements RE.  Currently only needed for death tests.\n\nRE::~RE() {\n  if (is_valid_) {\n    // regfree'ing an invalid regex might crash because the content\n    // of the regex is undefined. Since the regex's are essentially\n    // the same, one cannot be valid (or invalid) without the other\n    // being so too.\n    regfree(&partial_regex_);\n    regfree(&full_regex_);\n  }\n  free(const_cast<char*>(pattern_));\n}\n\n// Returns true iff regular expression re matches the entire str.\nbool RE::FullMatch(const char* str, const RE& re) {\n  if (!re.is_valid_) return false;\n\n  regmatch_t match;\n  return regexec(&re.full_regex_, str, 1, &match, 0) == 0;\n}\n\n// Returns true iff regular expression re matches a substring of str\n// (including str itself).\nbool RE::PartialMatch(const char* str, const RE& re) {\n  if (!re.is_valid_) return false;\n\n  regmatch_t match;\n  return regexec(&re.partial_regex_, str, 1, &match, 0) == 0;\n}\n\n// Initializes an RE from its string representation.\nvoid RE::Init(const char* regex) {\n  pattern_ = posix::StrDup(regex);\n\n  // Reserves enough bytes to hold the regular expression used for a\n  // full match.\n  const size_t full_regex_len = strlen(regex) + 10;\n  char* const full_pattern = new char[full_regex_len];\n\n  snprintf(full_pattern, full_regex_len, \"^(%s)$\", regex);\n  is_valid_ = regcomp(&full_regex_, full_pattern, REG_EXTENDED) == 0;\n  // We want to call regcomp(&partial_regex_, ...) even if the\n  // previous expression returns false.  Otherwise partial_regex_ may\n  // not be properly initialized can may cause trouble when it's\n  // freed.\n  //\n  // Some implementation of POSIX regex (e.g. on at least some\n  // versions of Cygwin) doesn't accept the empty string as a valid\n  // regex.  We change it to an equivalent form \"()\" to be safe.\n  if (is_valid_) {\n    const char* const partial_regex = (*regex == '\\0') ? \"()\" : regex;\n    is_valid_ = regcomp(&partial_regex_, partial_regex, REG_EXTENDED) == 0;\n  }\n  EXPECT_TRUE(is_valid_)\n      << \"Regular expression \\\"\" << regex\n      << \"\\\" is not a valid POSIX Extended regular expression.\";\n\n  delete[] full_pattern;\n}\n\n#elif GTEST_USES_SIMPLE_RE\n\n// Returns true iff ch appears anywhere in str (excluding the\n// terminating '\\0' character).\nbool IsInSet(char ch, const char* str) {\n  return ch != '\\0' && strchr(str, ch) != NULL;\n}\n\n// Returns true iff ch belongs to the given classification.  Unlike\n// similar functions in <ctype.h>, these aren't affected by the\n// current locale.\nbool IsAsciiDigit(char ch) { return '0' <= ch && ch <= '9'; }\nbool IsAsciiPunct(char ch) {\n  return IsInSet(ch, \"^-!\\\"#$%&'()*+,./:;<=>?@[\\\\]_`{|}~\");\n}\nbool IsRepeat(char ch) { return IsInSet(ch, \"?*+\"); }\nbool IsAsciiWhiteSpace(char ch) { return IsInSet(ch, \" \\f\\n\\r\\t\\v\"); }\nbool IsAsciiWordChar(char ch) {\n  return ('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z') ||\n      ('0' <= ch && ch <= '9') || ch == '_';\n}\n\n// Returns true iff \"\\\\c\" is a supported escape sequence.\nbool IsValidEscape(char c) {\n  return (IsAsciiPunct(c) || IsInSet(c, \"dDfnrsStvwW\"));\n}\n\n// Returns true iff the given atom (specified by escaped and pattern)\n// matches ch.  The result is undefined if the atom is invalid.\nbool AtomMatchesChar(bool escaped, char pattern_char, char ch) {\n  if (escaped) {  // \"\\\\p\" where p is pattern_char.\n    switch (pattern_char) {\n      case 'd': return IsAsciiDigit(ch);\n      case 'D': return !IsAsciiDigit(ch);\n      case 'f': return ch == '\\f';\n      case 'n': return ch == '\\n';\n      case 'r': return ch == '\\r';\n      case 's': return IsAsciiWhiteSpace(ch);\n      case 'S': return !IsAsciiWhiteSpace(ch);\n      case 't': return ch == '\\t';\n      case 'v': return ch == '\\v';\n      case 'w': return IsAsciiWordChar(ch);\n      case 'W': return !IsAsciiWordChar(ch);\n    }\n    return IsAsciiPunct(pattern_char) && pattern_char == ch;\n  }\n\n  return (pattern_char == '.' && ch != '\\n') || pattern_char == ch;\n}\n\n// Helper function used by ValidateRegex() to format error messages.\nstd::string FormatRegexSyntaxError(const char* regex, int index) {\n  return (Message() << \"Syntax error at index \" << index\n          << \" in simple regular expression \\\"\" << regex << \"\\\": \").GetString();\n}\n\n// Generates non-fatal failures and returns false if regex is invalid;\n// otherwise returns true.\nbool ValidateRegex(const char* regex) {\n  if (regex == NULL) {\n    // TODO(wan@google.com): fix the source file location in the\n    // assertion failures to match where the regex is used in user\n    // code.\n    ADD_FAILURE() << \"NULL is not a valid simple regular expression.\";\n    return false;\n  }\n\n  bool is_valid = true;\n\n  // True iff ?, *, or + can follow the previous atom.\n  bool prev_repeatable = false;\n  for (int i = 0; regex[i]; i++) {\n    if (regex[i] == '\\\\') {  // An escape sequence\n      i++;\n      if (regex[i] == '\\0') {\n        ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1)\n                      << \"'\\\\' cannot appear at the end.\";\n        return false;\n      }\n\n      if (!IsValidEscape(regex[i])) {\n        ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1)\n                      << \"invalid escape sequence \\\"\\\\\" << regex[i] << \"\\\".\";\n        is_valid = false;\n      }\n      prev_repeatable = true;\n    } else {  // Not an escape sequence.\n      const char ch = regex[i];\n\n      if (ch == '^' && i > 0) {\n        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)\n                      << \"'^' can only appear at the beginning.\";\n        is_valid = false;\n      } else if (ch == '$' && regex[i + 1] != '\\0') {\n        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)\n                      << \"'$' can only appear at the end.\";\n        is_valid = false;\n      } else if (IsInSet(ch, \"()[]{}|\")) {\n        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)\n                      << \"'\" << ch << \"' is unsupported.\";\n        is_valid = false;\n      } else if (IsRepeat(ch) && !prev_repeatable) {\n        ADD_FAILURE() << FormatRegexSyntaxError(regex, i)\n                      << \"'\" << ch << \"' can only follow a repeatable token.\";\n        is_valid = false;\n      }\n\n      prev_repeatable = !IsInSet(ch, \"^$?*+\");\n    }\n  }\n\n  return is_valid;\n}\n\n// Matches a repeated regex atom followed by a valid simple regular\n// expression.  The regex atom is defined as c if escaped is false,\n// or \\c otherwise.  repeat is the repetition meta character (?, *,\n// or +).  The behavior is undefined if str contains too many\n// characters to be indexable by size_t, in which case the test will\n// probably time out anyway.  We are fine with this limitation as\n// std::string has it too.\nbool MatchRepetitionAndRegexAtHead(\n    bool escaped, char c, char repeat, const char* regex,\n    const char* str) {\n  const size_t min_count = (repeat == '+') ? 1 : 0;\n  const size_t max_count = (repeat == '?') ? 1 :\n      static_cast<size_t>(-1) - 1;\n  // We cannot call numeric_limits::max() as it conflicts with the\n  // max() macro on Windows.\n\n  for (size_t i = 0; i <= max_count; ++i) {\n    // We know that the atom matches each of the first i characters in str.\n    if (i >= min_count && MatchRegexAtHead(regex, str + i)) {\n      // We have enough matches at the head, and the tail matches too.\n      // Since we only care about *whether* the pattern matches str\n      // (as opposed to *how* it matches), there is no need to find a\n      // greedy match.\n      return true;\n    }\n    if (str[i] == '\\0' || !AtomMatchesChar(escaped, c, str[i]))\n      return false;\n  }\n  return false;\n}\n\n// Returns true iff regex matches a prefix of str.  regex must be a\n// valid simple regular expression and not start with \"^\", or the\n// result is undefined.\nbool MatchRegexAtHead(const char* regex, const char* str) {\n  if (*regex == '\\0')  // An empty regex matches a prefix of anything.\n    return true;\n\n  // \"$\" only matches the end of a string.  Note that regex being\n  // valid guarantees that there's nothing after \"$\" in it.\n  if (*regex == '$')\n    return *str == '\\0';\n\n  // Is the first thing in regex an escape sequence?\n  const bool escaped = *regex == '\\\\';\n  if (escaped)\n    ++regex;\n  if (IsRepeat(regex[1])) {\n    // MatchRepetitionAndRegexAtHead() calls MatchRegexAtHead(), so\n    // here's an indirect recursion.  It terminates as the regex gets\n    // shorter in each recursion.\n    return MatchRepetitionAndRegexAtHead(\n        escaped, regex[0], regex[1], regex + 2, str);\n  } else {\n    // regex isn't empty, isn't \"$\", and doesn't start with a\n    // repetition.  We match the first atom of regex with the first\n    // character of str and recurse.\n    return (*str != '\\0') && AtomMatchesChar(escaped, *regex, *str) &&\n        MatchRegexAtHead(regex + 1, str + 1);\n  }\n}\n\n// Returns true iff regex matches any substring of str.  regex must be\n// a valid simple regular expression, or the result is undefined.\n//\n// The algorithm is recursive, but the recursion depth doesn't exceed\n// the regex length, so we won't need to worry about running out of\n// stack space normally.  In rare cases the time complexity can be\n// exponential with respect to the regex length + the string length,\n// but usually it's must faster (often close to linear).\nbool MatchRegexAnywhere(const char* regex, const char* str) {\n  if (regex == NULL || str == NULL)\n    return false;\n\n  if (*regex == '^')\n    return MatchRegexAtHead(regex + 1, str);\n\n  // A successful match can be anywhere in str.\n  do {\n    if (MatchRegexAtHead(regex, str))\n      return true;\n  } while (*str++ != '\\0');\n  return false;\n}\n\n// Implements the RE class.\n\nRE::~RE() {\n  free(const_cast<char*>(pattern_));\n  free(const_cast<char*>(full_pattern_));\n}\n\n// Returns true iff regular expression re matches the entire str.\nbool RE::FullMatch(const char* str, const RE& re) {\n  return re.is_valid_ && MatchRegexAnywhere(re.full_pattern_, str);\n}\n\n// Returns true iff regular expression re matches a substring of str\n// (including str itself).\nbool RE::PartialMatch(const char* str, const RE& re) {\n  return re.is_valid_ && MatchRegexAnywhere(re.pattern_, str);\n}\n\n// Initializes an RE from its string representation.\nvoid RE::Init(const char* regex) {\n  pattern_ = full_pattern_ = NULL;\n  if (regex != NULL) {\n    pattern_ = posix::StrDup(regex);\n  }\n\n  is_valid_ = ValidateRegex(regex);\n  if (!is_valid_) {\n    // No need to calculate the full pattern when the regex is invalid.\n    return;\n  }\n\n  const size_t len = strlen(regex);\n  // Reserves enough bytes to hold the regular expression used for a\n  // full match: we need space to prepend a '^', append a '$', and\n  // terminate the string with '\\0'.\n  char* buffer = static_cast<char*>(malloc(len + 3));\n  full_pattern_ = buffer;\n\n  if (*regex != '^')\n    *buffer++ = '^';  // Makes sure full_pattern_ starts with '^'.\n\n  // We don't use snprintf or strncpy, as they trigger a warning when\n  // compiled with VC++ 8.0.\n  memcpy(buffer, regex, len);\n  buffer += len;\n\n  if (len == 0 || regex[len - 1] != '$')\n    *buffer++ = '$';  // Makes sure full_pattern_ ends with '$'.\n\n  *buffer = '\\0';\n}\n\n#endif  // GTEST_USES_POSIX_RE\n\nconst char kUnknownFile[] = \"unknown file\";\n\n// Formats a source file path and a line number as they would appear\n// in an error message from the compiler used to compile this code.\nGTEST_API_ ::std::string FormatFileLocation(const char* file, int line) {\n  const std::string file_name(file == NULL ? kUnknownFile : file);\n\n  if (line < 0) {\n    return file_name + \":\";\n  }\n#ifdef _MSC_VER\n  return file_name + \"(\" + StreamableToString(line) + \"):\";\n#else\n  return file_name + \":\" + StreamableToString(line) + \":\";\n#endif  // _MSC_VER\n}\n\n// Formats a file location for compiler-independent XML output.\n// Although this function is not platform dependent, we put it next to\n// FormatFileLocation in order to contrast the two functions.\n// Note that FormatCompilerIndependentFileLocation() does NOT append colon\n// to the file location it produces, unlike FormatFileLocation().\nGTEST_API_ ::std::string FormatCompilerIndependentFileLocation(\n    const char* file, int line) {\n  const std::string file_name(file == NULL ? kUnknownFile : file);\n\n  if (line < 0)\n    return file_name;\n  else\n    return file_name + \":\" + StreamableToString(line);\n}\n\n\nGTestLog::GTestLog(GTestLogSeverity severity, const char* file, int line)\n    : severity_(severity) {\n  const char* const marker =\n      severity == GTEST_INFO ?    \"[  INFO ]\" :\n      severity == GTEST_WARNING ? \"[WARNING]\" :\n      severity == GTEST_ERROR ?   \"[ ERROR ]\" : \"[ FATAL ]\";\n  GetStream() << ::std::endl << marker << \" \"\n              << FormatFileLocation(file, line).c_str() << \": \";\n}\n\n// Flushes the buffers and, if severity is GTEST_FATAL, aborts the program.\nGTestLog::~GTestLog() {\n  GetStream() << ::std::endl;\n  if (severity_ == GTEST_FATAL) {\n    fflush(stderr);\n    posix::Abort();\n  }\n}\n// Disable Microsoft deprecation warnings for POSIX functions called from\n// this class (creat, dup, dup2, and close)\n#ifdef _MSC_VER\n# pragma warning(push)\n# pragma warning(disable: 4996)\n#endif  // _MSC_VER\n\n#if GTEST_HAS_STREAM_REDIRECTION\n\n// Object that captures an output stream (stdout/stderr).\nclass CapturedStream {\n public:\n  // The ctor redirects the stream to a temporary file.\n  explicit CapturedStream(int fd) : fd_(fd), uncaptured_fd_(dup(fd)) {\n# if GTEST_OS_WINDOWS\n    char temp_dir_path[MAX_PATH + 1] = { '\\0' };  // NOLINT\n    char temp_file_path[MAX_PATH + 1] = { '\\0' };  // NOLINT\n\n    ::GetTempPathA(sizeof(temp_dir_path), temp_dir_path);\n    const UINT success = ::GetTempFileNameA(temp_dir_path,\n                                            \"gtest_redir\",\n                                            0,  // Generate unique file name.\n                                            temp_file_path);\n    GTEST_CHECK_(success != 0)\n        << \"Unable to create a temporary file in \" << temp_dir_path;\n    const int captured_fd = creat(temp_file_path, _S_IREAD | _S_IWRITE);\n    GTEST_CHECK_(captured_fd != -1) << \"Unable to open temporary file \"\n                                    << temp_file_path;\n    filename_ = temp_file_path;\n# else\n    // There's no guarantee that a test has write access to the current\n    // directory, so we create the temporary file in the /tmp directory\n    // instead. We use /tmp on most systems, and /sdcard on Android.\n    // That's because Android doesn't have /tmp.\n#  if GTEST_OS_LINUX_ANDROID\n    // Note: Android applications are expected to call the framework's\n    // Context.getExternalStorageDirectory() method through JNI to get\n    // the location of the world-writable SD Card directory. However,\n    // this requires a Context handle, which cannot be retrieved\n    // globally from native code. Doing so also precludes running the\n    // code as part of a regular standalone executable, which doesn't\n    // run in a Dalvik process (e.g. when running it through 'adb shell').\n    //\n    // The location /sdcard is directly accessible from native code\n    // and is the only location (unofficially) supported by the Android\n    // team. It's generally a symlink to the real SD Card mount point\n    // which can be /mnt/sdcard, /mnt/sdcard0, /system/media/sdcard, or\n    // other OEM-customized locations. Never rely on these, and always\n    // use /sdcard.\n    char name_template[] = \"/sdcard/gtest_captured_stream.XXXXXX\";\n#  else\n    char name_template[] = \"/tmp/captured_stream.XXXXXX\";\n#  endif  // GTEST_OS_LINUX_ANDROID\n    const int captured_fd = mkstemp(name_template);\n    filename_ = name_template;\n# endif  // GTEST_OS_WINDOWS\n    fflush(NULL);\n    dup2(captured_fd, fd_);\n    close(captured_fd);\n  }\n\n  ~CapturedStream() {\n    remove(filename_.c_str());\n  }\n\n  std::string GetCapturedString() {\n    if (uncaptured_fd_ != -1) {\n      // Restores the original stream.\n      fflush(NULL);\n      dup2(uncaptured_fd_, fd_);\n      close(uncaptured_fd_);\n      uncaptured_fd_ = -1;\n    }\n\n    FILE* const file = posix::FOpen(filename_.c_str(), \"r\");\n    const std::string content = ReadEntireFile(file);\n    posix::FClose(file);\n    return content;\n  }\n\n private:\n  // Reads the entire content of a file as an std::string.\n  static std::string ReadEntireFile(FILE* file);\n\n  // Returns the size (in bytes) of a file.\n  static size_t GetFileSize(FILE* file);\n\n  const int fd_;  // A stream to capture.\n  int uncaptured_fd_;\n  // Name of the temporary file holding the stderr output.\n  ::std::string filename_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(CapturedStream);\n};\n\n// Returns the size (in bytes) of a file.\nsize_t CapturedStream::GetFileSize(FILE* file) {\n  fseek(file, 0, SEEK_END);\n  return static_cast<size_t>(ftell(file));\n}\n\n// Reads the entire content of a file as a string.\nstd::string CapturedStream::ReadEntireFile(FILE* file) {\n  const size_t file_size = GetFileSize(file);\n  char* const buffer = new char[file_size];\n\n  size_t bytes_last_read = 0;  // # of bytes read in the last fread()\n  size_t bytes_read = 0;       // # of bytes read so far\n\n  fseek(file, 0, SEEK_SET);\n\n  // Keeps reading the file until we cannot read further or the\n  // pre-determined file size is reached.\n  do {\n    bytes_last_read = fread(buffer+bytes_read, 1, file_size-bytes_read, file);\n    bytes_read += bytes_last_read;\n  } while (bytes_last_read > 0 && bytes_read < file_size);\n\n  const std::string content(buffer, bytes_read);\n  delete[] buffer;\n\n  return content;\n}\n\n# ifdef _MSC_VER\n#  pragma warning(pop)\n# endif  // _MSC_VER\n\nstatic CapturedStream* g_captured_stderr = NULL;\nstatic CapturedStream* g_captured_stdout = NULL;\n\n// Starts capturing an output stream (stdout/stderr).\nvoid CaptureStream(int fd, const char* stream_name, CapturedStream** stream) {\n  if (*stream != NULL) {\n    GTEST_LOG_(FATAL) << \"Only one \" << stream_name\n                      << \" capturer can exist at a time.\";\n  }\n  *stream = new CapturedStream(fd);\n}\n\n// Stops capturing the output stream and returns the captured string.\nstd::string GetCapturedStream(CapturedStream** captured_stream) {\n  const std::string content = (*captured_stream)->GetCapturedString();\n\n  delete *captured_stream;\n  *captured_stream = NULL;\n\n  return content;\n}\n\n// Starts capturing stdout.\nvoid CaptureStdout() {\n  CaptureStream(kStdOutFileno, \"stdout\", &g_captured_stdout);\n}\n\n// Starts capturing stderr.\nvoid CaptureStderr() {\n  CaptureStream(kStdErrFileno, \"stderr\", &g_captured_stderr);\n}\n\n// Stops capturing stdout and returns the captured string.\nstd::string GetCapturedStdout() {\n  return GetCapturedStream(&g_captured_stdout);\n}\n\n// Stops capturing stderr and returns the captured string.\nstd::string GetCapturedStderr() {\n  return GetCapturedStream(&g_captured_stderr);\n}\n\n#endif  // GTEST_HAS_STREAM_REDIRECTION\n\n#if GTEST_HAS_DEATH_TEST\n\n// A copy of all command line arguments.  Set by InitGoogleTest().\n::std::vector<testing::internal::string> g_argvs;\n\nstatic const ::std::vector<testing::internal::string>* g_injected_test_argvs =\n                                        NULL;  // Owned.\n\nvoid SetInjectableArgvs(const ::std::vector<testing::internal::string>* argvs) {\n  if (g_injected_test_argvs != argvs)\n    delete g_injected_test_argvs;\n  g_injected_test_argvs = argvs;\n}\n\nconst ::std::vector<testing::internal::string>& GetInjectableArgvs() {\n  if (g_injected_test_argvs != NULL) {\n    return *g_injected_test_argvs;\n  }\n  return g_argvs;\n}\n#endif  // GTEST_HAS_DEATH_TEST\n\n#if GTEST_OS_WINDOWS_MOBILE\nnamespace posix {\nvoid Abort() {\n  DebugBreak();\n  TerminateProcess(GetCurrentProcess(), 1);\n}\n}  // namespace posix\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\n// Returns the name of the environment variable corresponding to the\n// given flag.  For example, FlagToEnvVar(\"foo\") will return\n// \"GTEST_FOO\" in the open-source version.\nstatic std::string FlagToEnvVar(const char* flag) {\n  const std::string full_flag =\n      (Message() << GTEST_FLAG_PREFIX_ << flag).GetString();\n\n  Message env_var;\n  for (size_t i = 0; i != full_flag.length(); i++) {\n    env_var << ToUpper(full_flag.c_str()[i]);\n  }\n\n  return env_var.GetString();\n}\n\n// Parses 'str' for a 32-bit signed integer.  If successful, writes\n// the result to *value and returns true; otherwise leaves *value\n// unchanged and returns false.\nbool ParseInt32(const Message& src_text, const char* str, Int32* value) {\n  // Parses the environment variable as a decimal integer.\n  char* end = NULL;\n  const long long_value = strtol(str, &end, 10);  // NOLINT\n\n  // Has strtol() consumed all characters in the string?\n  if (*end != '\\0') {\n    // No - an invalid character was encountered.\n    Message msg;\n    msg << \"WARNING: \" << src_text\n        << \" is expected to be a 32-bit integer, but actually\"\n        << \" has value \\\"\" << str << \"\\\".\\n\";\n    printf(\"%s\", msg.GetString().c_str());\n    fflush(stdout);\n    return false;\n  }\n\n  // Is the parsed value in the range of an Int32?\n  const Int32 result = static_cast<Int32>(long_value);\n  if (long_value == LONG_MAX || long_value == LONG_MIN ||\n      // The parsed value overflows as a long.  (strtol() returns\n      // LONG_MAX or LONG_MIN when the input overflows.)\n      result != long_value\n      // The parsed value overflows as an Int32.\n      ) {\n    Message msg;\n    msg << \"WARNING: \" << src_text\n        << \" is expected to be a 32-bit integer, but actually\"\n        << \" has value \" << str << \", which overflows.\\n\";\n    printf(\"%s\", msg.GetString().c_str());\n    fflush(stdout);\n    return false;\n  }\n\n  *value = result;\n  return true;\n}\n\n// Reads and returns the Boolean environment variable corresponding to\n// the given flag; if it's not set, returns default_value.\n//\n// The value is considered true iff it's not \"0\".\nbool BoolFromGTestEnv(const char* flag, bool default_value) {\n  const std::string env_var = FlagToEnvVar(flag);\n  const char* const string_value = posix::GetEnv(env_var.c_str());\n  return string_value == NULL ?\n      default_value : strcmp(string_value, \"0\") != 0;\n}\n\n// Reads and returns a 32-bit integer stored in the environment\n// variable corresponding to the given flag; if it isn't set or\n// doesn't represent a valid 32-bit integer, returns default_value.\nInt32 Int32FromGTestEnv(const char* flag, Int32 default_value) {\n  const std::string env_var = FlagToEnvVar(flag);\n  const char* const string_value = posix::GetEnv(env_var.c_str());\n  if (string_value == NULL) {\n    // The environment variable is not set.\n    return default_value;\n  }\n\n  Int32 result = default_value;\n  if (!ParseInt32(Message() << \"Environment variable \" << env_var,\n                  string_value, &result)) {\n    printf(\"The default value %s is used.\\n\",\n           (Message() << default_value).GetString().c_str());\n    fflush(stdout);\n    return default_value;\n  }\n\n  return result;\n}\n\n// Reads and returns the string environment variable corresponding to\n// the given flag; if it's not set, returns default_value.\nconst char* StringFromGTestEnv(const char* flag, const char* default_value) {\n  const std::string env_var = FlagToEnvVar(flag);\n  const char* const value = posix::GetEnv(env_var.c_str());\n  return value == NULL ? default_value : value;\n}\n\n}  // namespace internal\n}  // namespace testing\n"
  },
  {
    "path": "ext/gtest/src/gtest-printers.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Test - The Google C++ Testing Framework\n//\n// This file implements a universal value printer that can print a\n// value of any type T:\n//\n//   void ::testing::internal::UniversalPrinter<T>::Print(value, ostream_ptr);\n//\n// It uses the << operator when possible, and prints the bytes in the\n// object otherwise.  A user can override its behavior for a class\n// type Foo by defining either operator<<(::std::ostream&, const Foo&)\n// or void PrintTo(const Foo&, ::std::ostream*) in the namespace that\n// defines Foo.\n\n#include \"gtest/gtest-printers.h\"\n#include <ctype.h>\n#include <stdio.h>\n#include <ostream>  // NOLINT\n#include <string>\n#include \"gtest/internal/gtest-port.h\"\n\nnamespace testing {\n\nnamespace {\n\nusing ::std::ostream;\n\n// Prints a segment of bytes in the given object.\nvoid PrintByteSegmentInObjectTo(const unsigned char* obj_bytes, size_t start,\n                                size_t count, ostream* os) {\n  char text[5] = \"\";\n  for (size_t i = 0; i != count; i++) {\n    const size_t j = start + i;\n    if (i != 0) {\n      // Organizes the bytes into groups of 2 for easy parsing by\n      // human.\n      if ((j % 2) == 0)\n        *os << ' ';\n      else\n        *os << '-';\n    }\n    GTEST_SNPRINTF_(text, sizeof(text), \"%02X\", obj_bytes[j]);\n    *os << text;\n  }\n}\n\n// Prints the bytes in the given value to the given ostream.\nvoid PrintBytesInObjectToImpl(const unsigned char* obj_bytes, size_t count,\n                              ostream* os) {\n  // Tells the user how big the object is.\n  *os << count << \"-byte object <\";\n\n  const size_t kThreshold = 132;\n  const size_t kChunkSize = 64;\n  // If the object size is bigger than kThreshold, we'll have to omit\n  // some details by printing only the first and the last kChunkSize\n  // bytes.\n  // TODO(wan): let the user control the threshold using a flag.\n  if (count < kThreshold) {\n    PrintByteSegmentInObjectTo(obj_bytes, 0, count, os);\n  } else {\n    PrintByteSegmentInObjectTo(obj_bytes, 0, kChunkSize, os);\n    *os << \" ... \";\n    // Rounds up to 2-byte boundary.\n    const size_t resume_pos = (count - kChunkSize + 1)/2*2;\n    PrintByteSegmentInObjectTo(obj_bytes, resume_pos, count - resume_pos, os);\n  }\n  *os << \">\";\n}\n\n}  // namespace\n\nnamespace internal2 {\n\n// Delegates to PrintBytesInObjectToImpl() to print the bytes in the\n// given object.  The delegation simplifies the implementation, which\n// uses the << operator and thus is easier done outside of the\n// ::testing::internal namespace, which contains a << operator that\n// sometimes conflicts with the one in STL.\nvoid PrintBytesInObjectTo(const unsigned char* obj_bytes, size_t count,\n                          ostream* os) {\n  PrintBytesInObjectToImpl(obj_bytes, count, os);\n}\n\n}  // namespace internal2\n\nnamespace internal {\n\n// Depending on the value of a char (or wchar_t), we print it in one\n// of three formats:\n//   - as is if it's a printable ASCII (e.g. 'a', '2', ' '),\n//   - as a hexidecimal escape sequence (e.g. '\\x7F'), or\n//   - as a special escape sequence (e.g. '\\r', '\\n').\nenum CharFormat {\n  kAsIs,\n  kHexEscape,\n  kSpecialEscape\n};\n\n// Returns true if c is a printable ASCII character.  We test the\n// value of c directly instead of calling isprint(), which is buggy on\n// Windows Mobile.\ninline bool IsPrintableAscii(wchar_t c) {\n  return 0x20 <= c && c <= 0x7E;\n}\n\n// Prints a wide or narrow char c as a character literal without the\n// quotes, escaping it when necessary; returns how c was formatted.\n// The template argument UnsignedChar is the unsigned version of Char,\n// which is the type of c.\ntemplate <typename UnsignedChar, typename Char>\nstatic CharFormat PrintAsCharLiteralTo(Char c, ostream* os) {\n  switch (static_cast<wchar_t>(c)) {\n    case L'\\0':\n      *os << \"\\\\0\";\n      break;\n    case L'\\'':\n      *os << \"\\\\'\";\n      break;\n    case L'\\\\':\n      *os << \"\\\\\\\\\";\n      break;\n    case L'\\a':\n      *os << \"\\\\a\";\n      break;\n    case L'\\b':\n      *os << \"\\\\b\";\n      break;\n    case L'\\f':\n      *os << \"\\\\f\";\n      break;\n    case L'\\n':\n      *os << \"\\\\n\";\n      break;\n    case L'\\r':\n      *os << \"\\\\r\";\n      break;\n    case L'\\t':\n      *os << \"\\\\t\";\n      break;\n    case L'\\v':\n      *os << \"\\\\v\";\n      break;\n    default:\n      if (IsPrintableAscii(c)) {\n        *os << static_cast<char>(c);\n        return kAsIs;\n      } else {\n        *os << \"\\\\x\" + String::FormatHexInt(static_cast<UnsignedChar>(c));\n        return kHexEscape;\n      }\n  }\n  return kSpecialEscape;\n}\n\n// Prints a wchar_t c as if it's part of a string literal, escaping it when\n// necessary; returns how c was formatted.\nstatic CharFormat PrintAsStringLiteralTo(wchar_t c, ostream* os) {\n  switch (c) {\n    case L'\\'':\n      *os << \"'\";\n      return kAsIs;\n    case L'\"':\n      *os << \"\\\\\\\"\";\n      return kSpecialEscape;\n    default:\n      return PrintAsCharLiteralTo<wchar_t>(c, os);\n  }\n}\n\n// Prints a char c as if it's part of a string literal, escaping it when\n// necessary; returns how c was formatted.\nstatic CharFormat PrintAsStringLiteralTo(char c, ostream* os) {\n  return PrintAsStringLiteralTo(\n      static_cast<wchar_t>(static_cast<unsigned char>(c)), os);\n}\n\n// Prints a wide or narrow character c and its code.  '\\0' is printed\n// as \"'\\\\0'\", other unprintable characters are also properly escaped\n// using the standard C++ escape sequence.  The template argument\n// UnsignedChar is the unsigned version of Char, which is the type of c.\ntemplate <typename UnsignedChar, typename Char>\nvoid PrintCharAndCodeTo(Char c, ostream* os) {\n  // First, print c as a literal in the most readable form we can find.\n  *os << ((sizeof(c) > 1) ? \"L'\" : \"'\");\n  const CharFormat format = PrintAsCharLiteralTo<UnsignedChar>(c, os);\n  *os << \"'\";\n\n  // To aid user debugging, we also print c's code in decimal, unless\n  // it's 0 (in which case c was printed as '\\\\0', making the code\n  // obvious).\n  if (c == 0)\n    return;\n  *os << \" (\" << static_cast<int>(c);\n\n  // For more convenience, we print c's code again in hexidecimal,\n  // unless c was already printed in the form '\\x##' or the code is in\n  // [1, 9].\n  if (format == kHexEscape || (1 <= c && c <= 9)) {\n    // Do nothing.\n  } else {\n    *os << \", 0x\" << String::FormatHexInt(static_cast<UnsignedChar>(c));\n  }\n  *os << \")\";\n}\n\nvoid PrintTo(unsigned char c, ::std::ostream* os) {\n  PrintCharAndCodeTo<unsigned char>(c, os);\n}\nvoid PrintTo(signed char c, ::std::ostream* os) {\n  PrintCharAndCodeTo<unsigned char>(c, os);\n}\n\n// Prints a wchar_t as a symbol if it is printable or as its internal\n// code otherwise and also as its code.  L'\\0' is printed as \"L'\\\\0'\".\nvoid PrintTo(wchar_t wc, ostream* os) {\n  PrintCharAndCodeTo<wchar_t>(wc, os);\n}\n\n// Prints the given array of characters to the ostream.  CharType must be either\n// char or wchar_t.\n// The array starts at begin, the length is len, it may include '\\0' characters\n// and may not be NUL-terminated.\ntemplate <typename CharType>\nstatic void PrintCharsAsStringTo(\n    const CharType* begin, size_t len, ostream* os) {\n  const char* const kQuoteBegin = sizeof(CharType) == 1 ? \"\\\"\" : \"L\\\"\";\n  *os << kQuoteBegin;\n  bool is_previous_hex = false;\n  for (size_t index = 0; index < len; ++index) {\n    const CharType cur = begin[index];\n    if (is_previous_hex && IsXDigit(cur)) {\n      // Previous character is of '\\x..' form and this character can be\n      // interpreted as another hexadecimal digit in its number. Break string to\n      // disambiguate.\n      *os << \"\\\" \" << kQuoteBegin;\n    }\n    is_previous_hex = PrintAsStringLiteralTo(cur, os) == kHexEscape;\n  }\n  *os << \"\\\"\";\n}\n\n// Prints a (const) char/wchar_t array of 'len' elements, starting at address\n// 'begin'.  CharType must be either char or wchar_t.\ntemplate <typename CharType>\nstatic void UniversalPrintCharArray(\n    const CharType* begin, size_t len, ostream* os) {\n  // The code\n  //   const char kFoo[] = \"foo\";\n  // generates an array of 4, not 3, elements, with the last one being '\\0'.\n  //\n  // Therefore when printing a char array, we don't print the last element if\n  // it's '\\0', such that the output matches the string literal as it's\n  // written in the source code.\n  if (len > 0 && begin[len - 1] == '\\0') {\n    PrintCharsAsStringTo(begin, len - 1, os);\n    return;\n  }\n\n  // If, however, the last element in the array is not '\\0', e.g.\n  //    const char kFoo[] = { 'f', 'o', 'o' };\n  // we must print the entire array.  We also print a message to indicate\n  // that the array is not NUL-terminated.\n  PrintCharsAsStringTo(begin, len, os);\n  *os << \" (no terminating NUL)\";\n}\n\n// Prints a (const) char array of 'len' elements, starting at address 'begin'.\nvoid UniversalPrintArray(const char* begin, size_t len, ostream* os) {\n  UniversalPrintCharArray(begin, len, os);\n}\n\n// Prints a (const) wchar_t array of 'len' elements, starting at address\n// 'begin'.\nvoid UniversalPrintArray(const wchar_t* begin, size_t len, ostream* os) {\n  UniversalPrintCharArray(begin, len, os);\n}\n\n// Prints the given C string to the ostream.\nvoid PrintTo(const char* s, ostream* os) {\n  if (s == NULL) {\n    *os << \"NULL\";\n  } else {\n    *os << ImplicitCast_<const void*>(s) << \" pointing to \";\n    PrintCharsAsStringTo(s, strlen(s), os);\n  }\n}\n\n// MSVC compiler can be configured to define whar_t as a typedef\n// of unsigned short. Defining an overload for const wchar_t* in that case\n// would cause pointers to unsigned shorts be printed as wide strings,\n// possibly accessing more memory than intended and causing invalid\n// memory accesses. MSVC defines _NATIVE_WCHAR_T_DEFINED symbol when\n// wchar_t is implemented as a native type.\n#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)\n// Prints the given wide C string to the ostream.\nvoid PrintTo(const wchar_t* s, ostream* os) {\n  if (s == NULL) {\n    *os << \"NULL\";\n  } else {\n    *os << ImplicitCast_<const void*>(s) << \" pointing to \";\n    PrintCharsAsStringTo(s, wcslen(s), os);\n  }\n}\n#endif  // wchar_t is native\n\n// Prints a ::string object.\n#if GTEST_HAS_GLOBAL_STRING\nvoid PrintStringTo(const ::string& s, ostream* os) {\n  PrintCharsAsStringTo(s.data(), s.size(), os);\n}\n#endif  // GTEST_HAS_GLOBAL_STRING\n\nvoid PrintStringTo(const ::std::string& s, ostream* os) {\n  PrintCharsAsStringTo(s.data(), s.size(), os);\n}\n\n// Prints a ::wstring object.\n#if GTEST_HAS_GLOBAL_WSTRING\nvoid PrintWideStringTo(const ::wstring& s, ostream* os) {\n  PrintCharsAsStringTo(s.data(), s.size(), os);\n}\n#endif  // GTEST_HAS_GLOBAL_WSTRING\n\n#if GTEST_HAS_STD_WSTRING\nvoid PrintWideStringTo(const ::std::wstring& s, ostream* os) {\n  PrintCharsAsStringTo(s.data(), s.size(), os);\n}\n#endif  // GTEST_HAS_STD_WSTRING\n\n}  // namespace internal\n\n}  // namespace testing\n"
  },
  {
    "path": "ext/gtest/src/gtest-test-part.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: mheule@google.com (Markus Heule)\n//\n// The Google C++ Testing Framework (Google Test)\n\n#include \"gtest/gtest-test-part.h\"\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick is to\n// prevent a user from accidentally including gtest-internal-inl.h in\n// his code.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\nnamespace testing {\n\nusing internal::GetUnitTestImpl;\n\n// Gets the summary of the failure message by omitting the stack trace\n// in it.\nstd::string TestPartResult::ExtractSummary(const char* message) {\n  const char* const stack_trace = strstr(message, internal::kStackTraceMarker);\n  return stack_trace == NULL ? message :\n      std::string(message, stack_trace);\n}\n\n// Prints a TestPartResult object.\nstd::ostream& operator<<(std::ostream& os, const TestPartResult& result) {\n  return os\n      << result.file_name() << \":\" << result.line_number() << \": \"\n      << (result.type() == TestPartResult::kSuccess ? \"Success\" :\n          result.type() == TestPartResult::kFatalFailure ? \"Fatal failure\" :\n          \"Non-fatal failure\") << \":\\n\"\n      << result.message() << std::endl;\n}\n\n// Appends a TestPartResult to the array.\nvoid TestPartResultArray::Append(const TestPartResult& result) {\n  array_.push_back(result);\n}\n\n// Returns the TestPartResult at the given index (0-based).\nconst TestPartResult& TestPartResultArray::GetTestPartResult(int index) const {\n  if (index < 0 || index >= size()) {\n    printf(\"\\nInvalid index (%d) into TestPartResultArray.\\n\", index);\n    internal::posix::Abort();\n  }\n\n  return array_[index];\n}\n\n// Returns the number of TestPartResult objects in the array.\nint TestPartResultArray::size() const {\n  return static_cast<int>(array_.size());\n}\n\nnamespace internal {\n\nHasNewFatalFailureHelper::HasNewFatalFailureHelper()\n    : has_new_fatal_failure_(false),\n      original_reporter_(GetUnitTestImpl()->\n                         GetTestPartResultReporterForCurrentThread()) {\n  GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread(this);\n}\n\nHasNewFatalFailureHelper::~HasNewFatalFailureHelper() {\n  GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread(\n      original_reporter_);\n}\n\nvoid HasNewFatalFailureHelper::ReportTestPartResult(\n    const TestPartResult& result) {\n  if (result.fatally_failed())\n    has_new_fatal_failure_ = true;\n  original_reporter_->ReportTestPartResult(result);\n}\n\n}  // namespace internal\n\n}  // namespace testing\n"
  },
  {
    "path": "ext/gtest/src/gtest-typed-test.cc",
    "content": "// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"gtest/gtest-typed-test.h\"\n#include \"gtest/gtest.h\"\n\nnamespace testing {\nnamespace internal {\n\n#if GTEST_HAS_TYPED_TEST_P\n\n// Skips to the first non-space char in str. Returns an empty string if str\n// contains only whitespace characters.\nstatic const char* SkipSpaces(const char* str) {\n  while (IsSpace(*str))\n    str++;\n  return str;\n}\n\n// Verifies that registered_tests match the test names in\n// defined_test_names_; returns registered_tests if successful, or\n// aborts the program otherwise.\nconst char* TypedTestCasePState::VerifyRegisteredTestNames(\n    const char* file, int line, const char* registered_tests) {\n  typedef ::std::set<const char*>::const_iterator DefinedTestIter;\n  registered_ = true;\n\n  // Skip initial whitespace in registered_tests since some\n  // preprocessors prefix stringizied literals with whitespace.\n  registered_tests = SkipSpaces(registered_tests);\n\n  Message errors;\n  ::std::set<std::string> tests;\n  for (const char* names = registered_tests; names != NULL;\n       names = SkipComma(names)) {\n    const std::string name = GetPrefixUntilComma(names);\n    if (tests.count(name) != 0) {\n      errors << \"Test \" << name << \" is listed more than once.\\n\";\n      continue;\n    }\n\n    bool found = false;\n    for (DefinedTestIter it = defined_test_names_.begin();\n         it != defined_test_names_.end();\n         ++it) {\n      if (name == *it) {\n        found = true;\n        break;\n      }\n    }\n\n    if (found) {\n      tests.insert(name);\n    } else {\n      errors << \"No test named \" << name\n             << \" can be found in this test case.\\n\";\n    }\n  }\n\n  for (DefinedTestIter it = defined_test_names_.begin();\n       it != defined_test_names_.end();\n       ++it) {\n    if (tests.count(*it) == 0) {\n      errors << \"You forgot to list test \" << *it << \".\\n\";\n    }\n  }\n\n  const std::string& errors_str = errors.GetString();\n  if (errors_str != \"\") {\n    fprintf(stderr, \"%s %s\", FormatFileLocation(file, line).c_str(),\n            errors_str.c_str());\n    fflush(stderr);\n    posix::Abort();\n  }\n\n  return registered_tests;\n}\n\n#endif  // GTEST_HAS_TYPED_TEST_P\n\n}  // namespace internal\n}  // namespace testing\n"
  },
  {
    "path": "ext/gtest/src/gtest.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// The Google C++ Testing Framework (Google Test)\n\n#include \"gtest/gtest.h\"\n#include \"gtest/gtest-spi.h\"\n\n#include <ctype.h>\n#include <math.h>\n#include <stdarg.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <time.h>\n#include <wchar.h>\n#include <wctype.h>\n\n#include <algorithm>\n#include <iomanip>\n#include <limits>\n#include <ostream>  // NOLINT\n#include <sstream>\n#include <vector>\n\n#if GTEST_OS_LINUX\n\n// TODO(kenton@google.com): Use autoconf to detect availability of\n// gettimeofday().\n# define GTEST_HAS_GETTIMEOFDAY_ 1\n\n# include <fcntl.h>  // NOLINT\n# include <limits.h>  // NOLINT\n# include <sched.h>  // NOLINT\n// Declares vsnprintf().  This header is not available on Windows.\n# include <strings.h>  // NOLINT\n# include <sys/mman.h>  // NOLINT\n# include <sys/time.h>  // NOLINT\n# include <unistd.h>  // NOLINT\n# include <string>\n\n#elif GTEST_OS_SYMBIAN\n# define GTEST_HAS_GETTIMEOFDAY_ 1\n# include <sys/time.h>  // NOLINT\n\n#elif GTEST_OS_ZOS\n# define GTEST_HAS_GETTIMEOFDAY_ 1\n# include <sys/time.h>  // NOLINT\n\n// On z/OS we additionally need strings.h for strcasecmp.\n# include <strings.h>  // NOLINT\n\n#elif GTEST_OS_WINDOWS_MOBILE  // We are on Windows CE.\n\n# include <windows.h>  // NOLINT\n\n#elif GTEST_OS_WINDOWS  // We are on Windows proper.\n\n# include <io.h>  // NOLINT\n# include <sys/timeb.h>  // NOLINT\n# include <sys/types.h>  // NOLINT\n# include <sys/stat.h>  // NOLINT\n\n# if GTEST_OS_WINDOWS_MINGW\n// MinGW has gettimeofday() but not _ftime64().\n// TODO(kenton@google.com): Use autoconf to detect availability of\n//   gettimeofday().\n// TODO(kenton@google.com): There are other ways to get the time on\n//   Windows, like GetTickCount() or GetSystemTimeAsFileTime().  MinGW\n//   supports these.  consider using them instead.\n#  define GTEST_HAS_GETTIMEOFDAY_ 1\n#  include <sys/time.h>  // NOLINT\n# endif  // GTEST_OS_WINDOWS_MINGW\n\n// cpplint thinks that the header is already included, so we want to\n// silence it.\n# include <windows.h>  // NOLINT\n\n#else\n\n// Assume other platforms have gettimeofday().\n// TODO(kenton@google.com): Use autoconf to detect availability of\n//   gettimeofday().\n# define GTEST_HAS_GETTIMEOFDAY_ 1\n\n// cpplint thinks that the header is already included, so we want to\n// silence it.\n# include <sys/time.h>  // NOLINT\n# include <unistd.h>  // NOLINT\n\n#endif  // GTEST_OS_LINUX\n\n#if GTEST_HAS_EXCEPTIONS\n# include <stdexcept>\n#endif\n\n#if GTEST_CAN_STREAM_RESULTS_\n# include <arpa/inet.h>  // NOLINT\n# include <netdb.h>  // NOLINT\n#endif\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick is to\n// prevent a user from accidentally including gtest-internal-inl.h in\n// his code.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\n#if GTEST_OS_WINDOWS\n# define vsnprintf _vsnprintf\n#endif  // GTEST_OS_WINDOWS\n\nnamespace testing {\n\nusing internal::CountIf;\nusing internal::ForEach;\nusing internal::GetElementOr;\nusing internal::Shuffle;\n\n// Constants.\n\n// A test whose test case name or test name matches this filter is\n// disabled and not run.\nstatic const char kDisableTestFilter[] = \"DISABLED_*:*/DISABLED_*\";\n\n// A test case whose name matches this filter is considered a death\n// test case and will be run before test cases whose name doesn't\n// match this filter.\nstatic const char kDeathTestCaseFilter[] = \"*DeathTest:*DeathTest/*\";\n\n// A test filter that matches everything.\nstatic const char kUniversalFilter[] = \"*\";\n\n// The default output file for XML output.\nstatic const char kDefaultOutputFile[] = \"test_detail.xml\";\n\n// The environment variable name for the test shard index.\nstatic const char kTestShardIndex[] = \"GTEST_SHARD_INDEX\";\n// The environment variable name for the total number of test shards.\nstatic const char kTestTotalShards[] = \"GTEST_TOTAL_SHARDS\";\n// The environment variable name for the test shard status file.\nstatic const char kTestShardStatusFile[] = \"GTEST_SHARD_STATUS_FILE\";\n\nnamespace internal {\n\n// The text used in failure messages to indicate the start of the\n// stack trace.\nconst char kStackTraceMarker[] = \"\\nStack trace:\\n\";\n\n// g_help_flag is true iff the --help flag or an equivalent form is\n// specified on the command line.\nbool g_help_flag = false;\n\n}  // namespace internal\n\nstatic const char* GetDefaultFilter() {\n  return kUniversalFilter;\n}\n\nGTEST_DEFINE_bool_(\n    also_run_disabled_tests,\n    internal::BoolFromGTestEnv(\"also_run_disabled_tests\", false),\n    \"Run disabled tests too, in addition to the tests normally being run.\");\n\nGTEST_DEFINE_bool_(\n    break_on_failure,\n    internal::BoolFromGTestEnv(\"break_on_failure\", false),\n    \"True iff a failed assertion should be a debugger break-point.\");\n\nGTEST_DEFINE_bool_(\n    catch_exceptions,\n    internal::BoolFromGTestEnv(\"catch_exceptions\", true),\n    \"True iff \" GTEST_NAME_\n    \" should catch exceptions and treat them as test failures.\");\n\nGTEST_DEFINE_string_(\n    color,\n    internal::StringFromGTestEnv(\"color\", \"auto\"),\n    \"Whether to use colors in the output.  Valid values: yes, no, \"\n    \"and auto.  'auto' means to use colors if the output is \"\n    \"being sent to a terminal and the TERM environment variable \"\n    \"is set to a terminal type that supports colors.\");\n\nGTEST_DEFINE_string_(\n    filter,\n    internal::StringFromGTestEnv(\"filter\", GetDefaultFilter()),\n    \"A colon-separated list of glob (not regex) patterns \"\n    \"for filtering the tests to run, optionally followed by a \"\n    \"'-' and a : separated list of negative patterns (tests to \"\n    \"exclude).  A test is run if it matches one of the positive \"\n    \"patterns and does not match any of the negative patterns.\");\n\nGTEST_DEFINE_bool_(list_tests, false,\n                   \"List all tests without running them.\");\n\nGTEST_DEFINE_string_(\n    output,\n    internal::StringFromGTestEnv(\"output\", \"\"),\n    \"A format (currently must be \\\"xml\\\"), optionally followed \"\n    \"by a colon and an output file name or directory. A directory \"\n    \"is indicated by a trailing pathname separator. \"\n    \"Examples: \\\"xml:filename.xml\\\", \\\"xml::directoryname/\\\". \"\n    \"If a directory is specified, output files will be created \"\n    \"within that directory, with file-names based on the test \"\n    \"executable's name and, if necessary, made unique by adding \"\n    \"digits.\");\n\nGTEST_DEFINE_bool_(\n    print_time,\n    internal::BoolFromGTestEnv(\"print_time\", true),\n    \"True iff \" GTEST_NAME_\n    \" should display elapsed time in text output.\");\n\nGTEST_DEFINE_int32_(\n    random_seed,\n    internal::Int32FromGTestEnv(\"random_seed\", 0),\n    \"Random number seed to use when shuffling test orders.  Must be in range \"\n    \"[1, 99999], or 0 to use a seed based on the current time.\");\n\nGTEST_DEFINE_int32_(\n    repeat,\n    internal::Int32FromGTestEnv(\"repeat\", 1),\n    \"How many times to repeat each test.  Specify a negative number \"\n    \"for repeating forever.  Useful for shaking out flaky tests.\");\n\nGTEST_DEFINE_bool_(\n    show_internal_stack_frames, false,\n    \"True iff \" GTEST_NAME_ \" should include internal stack frames when \"\n    \"printing test failure stack traces.\");\n\nGTEST_DEFINE_bool_(\n    shuffle,\n    internal::BoolFromGTestEnv(\"shuffle\", false),\n    \"True iff \" GTEST_NAME_\n    \" should randomize tests' order on every run.\");\n\nGTEST_DEFINE_int32_(\n    stack_trace_depth,\n    internal::Int32FromGTestEnv(\"stack_trace_depth\", kMaxStackTraceDepth),\n    \"The maximum number of stack frames to print when an \"\n    \"assertion fails.  The valid range is 0 through 100, inclusive.\");\n\nGTEST_DEFINE_string_(\n    stream_result_to,\n    internal::StringFromGTestEnv(\"stream_result_to\", \"\"),\n    \"This flag specifies the host name and the port number on which to stream \"\n    \"test results. Example: \\\"localhost:555\\\". The flag is effective only on \"\n    \"Linux.\");\n\nGTEST_DEFINE_bool_(\n    throw_on_failure,\n    internal::BoolFromGTestEnv(\"throw_on_failure\", false),\n    \"When this flag is specified, a failed assertion will throw an exception \"\n    \"if exceptions are enabled or exit the program with a non-zero code \"\n    \"otherwise.\");\n\nnamespace internal {\n\n// Generates a random number from [0, range), using a Linear\n// Congruential Generator (LCG).  Crashes if 'range' is 0 or greater\n// than kMaxRange.\nUInt32 Random::Generate(UInt32 range) {\n  // These constants are the same as are used in glibc's rand(3).\n  state_ = (1103515245U*state_ + 12345U) % kMaxRange;\n\n  GTEST_CHECK_(range > 0)\n      << \"Cannot generate a number in the range [0, 0).\";\n  GTEST_CHECK_(range <= kMaxRange)\n      << \"Generation of a number in [0, \" << range << \") was requested, \"\n      << \"but this can only generate numbers in [0, \" << kMaxRange << \").\";\n\n  // Converting via modulus introduces a bit of downward bias, but\n  // it's simple, and a linear congruential generator isn't too good\n  // to begin with.\n  return state_ % range;\n}\n\n// GTestIsInitialized() returns true iff the user has initialized\n// Google Test.  Useful for catching the user mistake of not initializing\n// Google Test before calling RUN_ALL_TESTS().\n//\n// A user must call testing::InitGoogleTest() to initialize Google\n// Test.  g_init_gtest_count is set to the number of times\n// InitGoogleTest() has been called.  We don't protect this variable\n// under a mutex as it is only accessed in the main thread.\nGTEST_API_ int g_init_gtest_count = 0;\nstatic bool GTestIsInitialized() { return g_init_gtest_count != 0; }\n\n// Iterates over a vector of TestCases, keeping a running sum of the\n// results of calling a given int-returning method on each.\n// Returns the sum.\nstatic int SumOverTestCaseList(const std::vector<TestCase*>& case_list,\n                               int (TestCase::*method)() const) {\n  int sum = 0;\n  for (size_t i = 0; i < case_list.size(); i++) {\n    sum += (case_list[i]->*method)();\n  }\n  return sum;\n}\n\n// Returns true iff the test case passed.\nstatic bool TestCasePassed(const TestCase* test_case) {\n  return test_case->should_run() && test_case->Passed();\n}\n\n// Returns true iff the test case failed.\nstatic bool TestCaseFailed(const TestCase* test_case) {\n  return test_case->should_run() && test_case->Failed();\n}\n\n// Returns true iff test_case contains at least one test that should\n// run.\nstatic bool ShouldRunTestCase(const TestCase* test_case) {\n  return test_case->should_run();\n}\n\n// AssertHelper constructor.\nAssertHelper::AssertHelper(TestPartResult::Type type,\n                           const char* file,\n                           int line,\n                           const char* message)\n    : data_(new AssertHelperData(type, file, line, message)) {\n}\n\nAssertHelper::~AssertHelper() {\n  delete data_;\n}\n\n// Message assignment, for assertion streaming support.\nvoid AssertHelper::operator=(const Message& message) const {\n  UnitTest::GetInstance()->\n    AddTestPartResult(data_->type, data_->file, data_->line,\n                      AppendUserMessage(data_->message, message),\n                      UnitTest::GetInstance()->impl()\n                      ->CurrentOsStackTraceExceptTop(1)\n                      // Skips the stack frame for this function itself.\n                      );  // NOLINT\n}\n\n// Mutex for linked pointers.\nGTEST_API_ GTEST_DEFINE_STATIC_MUTEX_(g_linked_ptr_mutex);\n\n// Application pathname gotten in InitGoogleTest.\nstd::string g_executable_path;\n\n// Returns the current application's name, removing directory path if that\n// is present.\nFilePath GetCurrentExecutableName() {\n  FilePath result;\n\n#if GTEST_OS_WINDOWS\n  result.Set(FilePath(g_executable_path).RemoveExtension(\"exe\"));\n#else\n  result.Set(FilePath(g_executable_path));\n#endif  // GTEST_OS_WINDOWS\n\n  return result.RemoveDirectoryName();\n}\n\n// Functions for processing the gtest_output flag.\n\n// Returns the output format, or \"\" for normal printed output.\nstd::string UnitTestOptions::GetOutputFormat() {\n  const char* const gtest_output_flag = GTEST_FLAG(output).c_str();\n  if (gtest_output_flag == NULL) return std::string(\"\");\n\n  const char* const colon = strchr(gtest_output_flag, ':');\n  return (colon == NULL) ?\n      std::string(gtest_output_flag) :\n      std::string(gtest_output_flag, colon - gtest_output_flag);\n}\n\n// Returns the name of the requested output file, or the default if none\n// was explicitly specified.\nstd::string UnitTestOptions::GetAbsolutePathToOutputFile() {\n  const char* const gtest_output_flag = GTEST_FLAG(output).c_str();\n  if (gtest_output_flag == NULL)\n    return \"\";\n\n  const char* const colon = strchr(gtest_output_flag, ':');\n  if (colon == NULL)\n    return internal::FilePath::ConcatPaths(\n        internal::FilePath(\n            UnitTest::GetInstance()->original_working_dir()),\n        internal::FilePath(kDefaultOutputFile)).string();\n\n  internal::FilePath output_name(colon + 1);\n  if (!output_name.IsAbsolutePath())\n    // TODO(wan@google.com): on Windows \\some\\path is not an absolute\n    // path (as its meaning depends on the current drive), yet the\n    // following logic for turning it into an absolute path is wrong.\n    // Fix it.\n    output_name = internal::FilePath::ConcatPaths(\n        internal::FilePath(UnitTest::GetInstance()->original_working_dir()),\n        internal::FilePath(colon + 1));\n\n  if (!output_name.IsDirectory())\n    return output_name.string();\n\n  internal::FilePath result(internal::FilePath::GenerateUniqueFileName(\n      output_name, internal::GetCurrentExecutableName(),\n      GetOutputFormat().c_str()));\n  return result.string();\n}\n\n// Returns true iff the wildcard pattern matches the string.  The\n// first ':' or '\\0' character in pattern marks the end of it.\n//\n// This recursive algorithm isn't very efficient, but is clear and\n// works well enough for matching test names, which are short.\nbool UnitTestOptions::PatternMatchesString(const char *pattern,\n                                           const char *str) {\n  switch (*pattern) {\n    case '\\0':\n    case ':':  // Either ':' or '\\0' marks the end of the pattern.\n      return *str == '\\0';\n    case '?':  // Matches any single character.\n      return *str != '\\0' && PatternMatchesString(pattern + 1, str + 1);\n    case '*':  // Matches any string (possibly empty) of characters.\n      return (*str != '\\0' && PatternMatchesString(pattern, str + 1)) ||\n          PatternMatchesString(pattern + 1, str);\n    default:  // Non-special character.  Matches itself.\n      return *pattern == *str &&\n          PatternMatchesString(pattern + 1, str + 1);\n  }\n}\n\nbool UnitTestOptions::MatchesFilter(\n    const std::string& name, const char* filter) {\n  const char *cur_pattern = filter;\n  for (;;) {\n    if (PatternMatchesString(cur_pattern, name.c_str())) {\n      return true;\n    }\n\n    // Finds the next pattern in the filter.\n    cur_pattern = strchr(cur_pattern, ':');\n\n    // Returns if no more pattern can be found.\n    if (cur_pattern == NULL) {\n      return false;\n    }\n\n    // Skips the pattern separater (the ':' character).\n    cur_pattern++;\n  }\n}\n\n// Returns true iff the user-specified filter matches the test case\n// name and the test name.\nbool UnitTestOptions::FilterMatchesTest(const std::string &test_case_name,\n                                        const std::string &test_name) {\n  const std::string& full_name = test_case_name + \".\" + test_name.c_str();\n\n  // Split --gtest_filter at '-', if there is one, to separate into\n  // positive filter and negative filter portions\n  const char* const p = GTEST_FLAG(filter).c_str();\n  const char* const dash = strchr(p, '-');\n  std::string positive;\n  std::string negative;\n  if (dash == NULL) {\n    positive = GTEST_FLAG(filter).c_str();  // Whole string is a positive filter\n    negative = \"\";\n  } else {\n    positive = std::string(p, dash);   // Everything up to the dash\n    negative = std::string(dash + 1);  // Everything after the dash\n    if (positive.empty()) {\n      // Treat '-test1' as the same as '*-test1'\n      positive = kUniversalFilter;\n    }\n  }\n\n  // A filter is a colon-separated list of patterns.  It matches a\n  // test if any pattern in it matches the test.\n  return (MatchesFilter(full_name, positive.c_str()) &&\n          !MatchesFilter(full_name, negative.c_str()));\n}\n\n#if GTEST_HAS_SEH\n// Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the\n// given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise.\n// This function is useful as an __except condition.\nint UnitTestOptions::GTestShouldProcessSEH(DWORD exception_code) {\n  // Google Test should handle a SEH exception if:\n  //   1. the user wants it to, AND\n  //   2. this is not a breakpoint exception, AND\n  //   3. this is not a C++ exception (VC++ implements them via SEH,\n  //      apparently).\n  //\n  // SEH exception code for C++ exceptions.\n  // (see http://support.microsoft.com/kb/185294 for more information).\n  const DWORD kCxxExceptionCode = 0xe06d7363;\n\n  bool should_handle = true;\n\n  if (!GTEST_FLAG(catch_exceptions))\n    should_handle = false;\n  else if (exception_code == EXCEPTION_BREAKPOINT)\n    should_handle = false;\n  else if (exception_code == kCxxExceptionCode)\n    should_handle = false;\n\n  return should_handle ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH;\n}\n#endif  // GTEST_HAS_SEH\n\n}  // namespace internal\n\n// The c'tor sets this object as the test part result reporter used by\n// Google Test.  The 'result' parameter specifies where to report the\n// results. Intercepts only failures from the current thread.\nScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter(\n    TestPartResultArray* result)\n    : intercept_mode_(INTERCEPT_ONLY_CURRENT_THREAD),\n      result_(result) {\n  Init();\n}\n\n// The c'tor sets this object as the test part result reporter used by\n// Google Test.  The 'result' parameter specifies where to report the\n// results.\nScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter(\n    InterceptMode intercept_mode, TestPartResultArray* result)\n    : intercept_mode_(intercept_mode),\n      result_(result) {\n  Init();\n}\n\nvoid ScopedFakeTestPartResultReporter::Init() {\n  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();\n  if (intercept_mode_ == INTERCEPT_ALL_THREADS) {\n    old_reporter_ = impl->GetGlobalTestPartResultReporter();\n    impl->SetGlobalTestPartResultReporter(this);\n  } else {\n    old_reporter_ = impl->GetTestPartResultReporterForCurrentThread();\n    impl->SetTestPartResultReporterForCurrentThread(this);\n  }\n}\n\n// The d'tor restores the test part result reporter used by Google Test\n// before.\nScopedFakeTestPartResultReporter::~ScopedFakeTestPartResultReporter() {\n  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();\n  if (intercept_mode_ == INTERCEPT_ALL_THREADS) {\n    impl->SetGlobalTestPartResultReporter(old_reporter_);\n  } else {\n    impl->SetTestPartResultReporterForCurrentThread(old_reporter_);\n  }\n}\n\n// Increments the test part result count and remembers the result.\n// This method is from the TestPartResultReporterInterface interface.\nvoid ScopedFakeTestPartResultReporter::ReportTestPartResult(\n    const TestPartResult& result) {\n  result_->Append(result);\n}\n\nnamespace internal {\n\n// Returns the type ID of ::testing::Test.  We should always call this\n// instead of GetTypeId< ::testing::Test>() to get the type ID of\n// testing::Test.  This is to work around a suspected linker bug when\n// using Google Test as a framework on Mac OS X.  The bug causes\n// GetTypeId< ::testing::Test>() to return different values depending\n// on whether the call is from the Google Test framework itself or\n// from user test code.  GetTestTypeId() is guaranteed to always\n// return the same value, as it always calls GetTypeId<>() from the\n// gtest.cc, which is within the Google Test framework.\nTypeId GetTestTypeId() {\n  return GetTypeId<Test>();\n}\n\n// The value of GetTestTypeId() as seen from within the Google Test\n// library.  This is solely for testing GetTestTypeId().\nextern const TypeId kTestTypeIdInGoogleTest = GetTestTypeId();\n\n// This predicate-formatter checks that 'results' contains a test part\n// failure of the given type and that the failure message contains the\n// given substring.\nAssertionResult HasOneFailure(const char* /* results_expr */,\n                              const char* /* type_expr */,\n                              const char* /* substr_expr */,\n                              const TestPartResultArray& results,\n                              TestPartResult::Type type,\n                              const string& substr) {\n  const std::string expected(type == TestPartResult::kFatalFailure ?\n                        \"1 fatal failure\" :\n                        \"1 non-fatal failure\");\n  Message msg;\n  if (results.size() != 1) {\n    msg << \"Expected: \" << expected << \"\\n\"\n        << \"  Actual: \" << results.size() << \" failures\";\n    for (int i = 0; i < results.size(); i++) {\n      msg << \"\\n\" << results.GetTestPartResult(i);\n    }\n    return AssertionFailure() << msg;\n  }\n\n  const TestPartResult& r = results.GetTestPartResult(0);\n  if (r.type() != type) {\n    return AssertionFailure() << \"Expected: \" << expected << \"\\n\"\n                              << \"  Actual:\\n\"\n                              << r;\n  }\n\n  if (strstr(r.message(), substr.c_str()) == NULL) {\n    return AssertionFailure() << \"Expected: \" << expected << \" containing \\\"\"\n                              << substr << \"\\\"\\n\"\n                              << \"  Actual:\\n\"\n                              << r;\n  }\n\n  return AssertionSuccess();\n}\n\n// The constructor of SingleFailureChecker remembers where to look up\n// test part results, what type of failure we expect, and what\n// substring the failure message should contain.\nSingleFailureChecker:: SingleFailureChecker(\n    const TestPartResultArray* results,\n    TestPartResult::Type type,\n    const string& substr)\n    : results_(results),\n      type_(type),\n      substr_(substr) {}\n\n// The destructor of SingleFailureChecker verifies that the given\n// TestPartResultArray contains exactly one failure that has the given\n// type and contains the given substring.  If that's not the case, a\n// non-fatal failure will be generated.\nSingleFailureChecker::~SingleFailureChecker() {\n  EXPECT_PRED_FORMAT3(HasOneFailure, *results_, type_, substr_);\n}\n\nDefaultGlobalTestPartResultReporter::DefaultGlobalTestPartResultReporter(\n    UnitTestImpl* unit_test) : unit_test_(unit_test) {}\n\nvoid DefaultGlobalTestPartResultReporter::ReportTestPartResult(\n    const TestPartResult& result) {\n  unit_test_->current_test_result()->AddTestPartResult(result);\n  unit_test_->listeners()->repeater()->OnTestPartResult(result);\n}\n\nDefaultPerThreadTestPartResultReporter::DefaultPerThreadTestPartResultReporter(\n    UnitTestImpl* unit_test) : unit_test_(unit_test) {}\n\nvoid DefaultPerThreadTestPartResultReporter::ReportTestPartResult(\n    const TestPartResult& result) {\n  unit_test_->GetGlobalTestPartResultReporter()->ReportTestPartResult(result);\n}\n\n// Returns the global test part result reporter.\nTestPartResultReporterInterface*\nUnitTestImpl::GetGlobalTestPartResultReporter() {\n  internal::MutexLock lock(&global_test_part_result_reporter_mutex_);\n  return global_test_part_result_repoter_;\n}\n\n// Sets the global test part result reporter.\nvoid UnitTestImpl::SetGlobalTestPartResultReporter(\n    TestPartResultReporterInterface* reporter) {\n  internal::MutexLock lock(&global_test_part_result_reporter_mutex_);\n  global_test_part_result_repoter_ = reporter;\n}\n\n// Returns the test part result reporter for the current thread.\nTestPartResultReporterInterface*\nUnitTestImpl::GetTestPartResultReporterForCurrentThread() {\n  return per_thread_test_part_result_reporter_.get();\n}\n\n// Sets the test part result reporter for the current thread.\nvoid UnitTestImpl::SetTestPartResultReporterForCurrentThread(\n    TestPartResultReporterInterface* reporter) {\n  per_thread_test_part_result_reporter_.set(reporter);\n}\n\n// Gets the number of successful test cases.\nint UnitTestImpl::successful_test_case_count() const {\n  return CountIf(test_cases_, TestCasePassed);\n}\n\n// Gets the number of failed test cases.\nint UnitTestImpl::failed_test_case_count() const {\n  return CountIf(test_cases_, TestCaseFailed);\n}\n\n// Gets the number of all test cases.\nint UnitTestImpl::total_test_case_count() const {\n  return static_cast<int>(test_cases_.size());\n}\n\n// Gets the number of all test cases that contain at least one test\n// that should run.\nint UnitTestImpl::test_case_to_run_count() const {\n  return CountIf(test_cases_, ShouldRunTestCase);\n}\n\n// Gets the number of successful tests.\nint UnitTestImpl::successful_test_count() const {\n  return SumOverTestCaseList(test_cases_, &TestCase::successful_test_count);\n}\n\n// Gets the number of failed tests.\nint UnitTestImpl::failed_test_count() const {\n  return SumOverTestCaseList(test_cases_, &TestCase::failed_test_count);\n}\n\n// Gets the number of disabled tests that will be reported in the XML report.\nint UnitTestImpl::reportable_disabled_test_count() const {\n  return SumOverTestCaseList(test_cases_,\n                             &TestCase::reportable_disabled_test_count);\n}\n\n// Gets the number of disabled tests.\nint UnitTestImpl::disabled_test_count() const {\n  return SumOverTestCaseList(test_cases_, &TestCase::disabled_test_count);\n}\n\n// Gets the number of tests to be printed in the XML report.\nint UnitTestImpl::reportable_test_count() const {\n  return SumOverTestCaseList(test_cases_, &TestCase::reportable_test_count);\n}\n\n// Gets the number of all tests.\nint UnitTestImpl::total_test_count() const {\n  return SumOverTestCaseList(test_cases_, &TestCase::total_test_count);\n}\n\n// Gets the number of tests that should run.\nint UnitTestImpl::test_to_run_count() const {\n  return SumOverTestCaseList(test_cases_, &TestCase::test_to_run_count);\n}\n\n// Returns the current OS stack trace as an std::string.\n//\n// The maximum number of stack frames to be included is specified by\n// the gtest_stack_trace_depth flag.  The skip_count parameter\n// specifies the number of top frames to be skipped, which doesn't\n// count against the number of frames to be included.\n//\n// For example, if Foo() calls Bar(), which in turn calls\n// CurrentOsStackTraceExceptTop(1), Foo() will be included in the\n// trace but Bar() and CurrentOsStackTraceExceptTop() won't.\nstd::string UnitTestImpl::CurrentOsStackTraceExceptTop(int skip_count) {\n  (void)skip_count;\n  return \"\";\n}\n\n// Returns the current time in milliseconds.\nTimeInMillis GetTimeInMillis() {\n#if GTEST_OS_WINDOWS_MOBILE || defined(__BORLANDC__)\n  // Difference between 1970-01-01 and 1601-01-01 in milliseconds.\n  // http://analogous.blogspot.com/2005/04/epoch.html\n  const TimeInMillis kJavaEpochToWinFileTimeDelta =\n    static_cast<TimeInMillis>(116444736UL) * 100000UL;\n  const DWORD kTenthMicrosInMilliSecond = 10000;\n\n  SYSTEMTIME now_systime;\n  FILETIME now_filetime;\n  ULARGE_INTEGER now_int64;\n  // TODO(kenton@google.com): Shouldn't this just use\n  //   GetSystemTimeAsFileTime()?\n  GetSystemTime(&now_systime);\n  if (SystemTimeToFileTime(&now_systime, &now_filetime)) {\n    now_int64.LowPart = now_filetime.dwLowDateTime;\n    now_int64.HighPart = now_filetime.dwHighDateTime;\n    now_int64.QuadPart = (now_int64.QuadPart / kTenthMicrosInMilliSecond) -\n      kJavaEpochToWinFileTimeDelta;\n    return now_int64.QuadPart;\n  }\n  return 0;\n#elif GTEST_OS_WINDOWS && !GTEST_HAS_GETTIMEOFDAY_\n  __timeb64 now;\n\n# ifdef _MSC_VER\n\n  // MSVC 8 deprecates _ftime64(), so we want to suppress warning 4996\n  // (deprecated function) there.\n  // TODO(kenton@google.com): Use GetTickCount()?  Or use\n  //   SystemTimeToFileTime()\n#  pragma warning(push)          // Saves the current warning state.\n#  pragma warning(disable:4996)  // Temporarily disables warning 4996.\n  _ftime64(&now);\n#  pragma warning(pop)           // Restores the warning state.\n# else\n\n  _ftime64(&now);\n\n# endif  // _MSC_VER\n\n  return static_cast<TimeInMillis>(now.time) * 1000 + now.millitm;\n#elif GTEST_HAS_GETTIMEOFDAY_\n  struct timeval now;\n  gettimeofday(&now, NULL);\n  return static_cast<TimeInMillis>(now.tv_sec) * 1000 + now.tv_usec / 1000;\n#else\n# error \"Don't know how to get the current time on your system.\"\n#endif\n}\n\n// Utilities\n\n// class String.\n\n#if GTEST_OS_WINDOWS_MOBILE\n// Creates a UTF-16 wide string from the given ANSI string, allocating\n// memory using new. The caller is responsible for deleting the return\n// value using delete[]. Returns the wide string, or NULL if the\n// input is NULL.\nLPCWSTR String::AnsiToUtf16(const char* ansi) {\n  if (!ansi) return NULL;\n  const int length = strlen(ansi);\n  const int unicode_length =\n      MultiByteToWideChar(CP_ACP, 0, ansi, length,\n                          NULL, 0);\n  WCHAR* unicode = new WCHAR[unicode_length + 1];\n  MultiByteToWideChar(CP_ACP, 0, ansi, length,\n                      unicode, unicode_length);\n  unicode[unicode_length] = 0;\n  return unicode;\n}\n\n// Creates an ANSI string from the given wide string, allocating\n// memory using new. The caller is responsible for deleting the return\n// value using delete[]. Returns the ANSI string, or NULL if the\n// input is NULL.\nconst char* String::Utf16ToAnsi(LPCWSTR utf16_str)  {\n  if (!utf16_str) return NULL;\n  const int ansi_length =\n      WideCharToMultiByte(CP_ACP, 0, utf16_str, -1,\n                          NULL, 0, NULL, NULL);\n  char* ansi = new char[ansi_length + 1];\n  WideCharToMultiByte(CP_ACP, 0, utf16_str, -1,\n                      ansi, ansi_length, NULL, NULL);\n  ansi[ansi_length] = 0;\n  return ansi;\n}\n\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\n// Compares two C strings.  Returns true iff they have the same content.\n//\n// Unlike strcmp(), this function can handle NULL argument(s).  A NULL\n// C string is considered different to any non-NULL C string,\n// including the empty string.\nbool String::CStringEquals(const char * lhs, const char * rhs) {\n  if ( lhs == NULL ) return rhs == NULL;\n\n  if ( rhs == NULL ) return false;\n\n  return strcmp(lhs, rhs) == 0;\n}\n\n#if GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING\n\n// Converts an array of wide chars to a narrow string using the UTF-8\n// encoding, and streams the result to the given Message object.\nstatic void StreamWideCharsToMessage(const wchar_t* wstr, size_t length,\n                                     Message* msg) {\n  for (size_t i = 0; i != length; ) {  // NOLINT\n    if (wstr[i] != L'\\0') {\n      *msg << WideStringToUtf8(wstr + i, static_cast<int>(length - i));\n      while (i != length && wstr[i] != L'\\0')\n        i++;\n    } else {\n      *msg << '\\0';\n      i++;\n    }\n  }\n}\n\n#endif  // GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING\n\n}  // namespace internal\n\n// Constructs an empty Message.\n// We allocate the stringstream separately because otherwise each use of\n// ASSERT/EXPECT in a procedure adds over 200 bytes to the procedure's\n// stack frame leading to huge stack frames in some cases; gcc does not reuse\n// the stack space.\nMessage::Message() : ss_(new ::std::stringstream) {\n  // By default, we want there to be enough precision when printing\n  // a double to a Message.\n  *ss_ << std::setprecision(std::numeric_limits<double>::digits10 + 2);\n}\n\n// These two overloads allow streaming a wide C string to a Message\n// using the UTF-8 encoding.\nMessage& Message::operator <<(const wchar_t* wide_c_str) {\n  return *this << internal::String::ShowWideCString(wide_c_str);\n}\nMessage& Message::operator <<(wchar_t* wide_c_str) {\n  return *this << internal::String::ShowWideCString(wide_c_str);\n}\n\n#if GTEST_HAS_STD_WSTRING\n// Converts the given wide string to a narrow string using the UTF-8\n// encoding, and streams the result to this Message object.\nMessage& Message::operator <<(const ::std::wstring& wstr) {\n  internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this);\n  return *this;\n}\n#endif  // GTEST_HAS_STD_WSTRING\n\n#if GTEST_HAS_GLOBAL_WSTRING\n// Converts the given wide string to a narrow string using the UTF-8\n// encoding, and streams the result to this Message object.\nMessage& Message::operator <<(const ::wstring& wstr) {\n  internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this);\n  return *this;\n}\n#endif  // GTEST_HAS_GLOBAL_WSTRING\n\n// Gets the text streamed to this object so far as an std::string.\n// Each '\\0' character in the buffer is replaced with \"\\\\0\".\nstd::string Message::GetString() const {\n  return internal::StringStreamToString(ss_.get());\n}\n\n// AssertionResult constructors.\n// Used in EXPECT_TRUE/FALSE(assertion_result).\nAssertionResult::AssertionResult(const AssertionResult& other)\n    : success_(other.success_),\n      message_(other.message_.get() != NULL ?\n               new ::std::string(*other.message_) :\n               static_cast< ::std::string*>(NULL)) {\n}\n\n// Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE.\nAssertionResult AssertionResult::operator!() const {\n  AssertionResult negation(!success_);\n  if (message_.get() != NULL)\n    negation << *message_;\n  return negation;\n}\n\n// Makes a successful assertion result.\nAssertionResult AssertionSuccess() {\n  return AssertionResult(true);\n}\n\n// Makes a failed assertion result.\nAssertionResult AssertionFailure() {\n  return AssertionResult(false);\n}\n\n// Makes a failed assertion result with the given failure message.\n// Deprecated; use AssertionFailure() << message.\nAssertionResult AssertionFailure(const Message& message) {\n  return AssertionFailure() << message;\n}\n\nnamespace internal {\n\n// Constructs and returns the message for an equality assertion\n// (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure.\n//\n// The first four parameters are the expressions used in the assertion\n// and their values, as strings.  For example, for ASSERT_EQ(foo, bar)\n// where foo is 5 and bar is 6, we have:\n//\n//   expected_expression: \"foo\"\n//   actual_expression:   \"bar\"\n//   expected_value:      \"5\"\n//   actual_value:        \"6\"\n//\n// The ignoring_case parameter is true iff the assertion is a\n// *_STRCASEEQ*.  When it's true, the string \" (ignoring case)\" will\n// be inserted into the message.\nAssertionResult EqFailure(const char* expected_expression,\n                          const char* actual_expression,\n                          const std::string& expected_value,\n                          const std::string& actual_value,\n                          bool ignoring_case) {\n  Message msg;\n  msg << \"Value of: \" << actual_expression;\n  if (actual_value != actual_expression) {\n    msg << \"\\n  Actual: \" << actual_value;\n  }\n\n  msg << \"\\nExpected: \" << expected_expression;\n  if (ignoring_case) {\n    msg << \" (ignoring case)\";\n  }\n  if (expected_value != expected_expression) {\n    msg << \"\\nWhich is: \" << expected_value;\n  }\n\n  return AssertionFailure() << msg;\n}\n\n// Constructs a failure message for Boolean assertions such as EXPECT_TRUE.\nstd::string GetBoolAssertionFailureMessage(\n    const AssertionResult& assertion_result,\n    const char* expression_text,\n    const char* actual_predicate_value,\n    const char* expected_predicate_value) {\n  const char* actual_message = assertion_result.message();\n  Message msg;\n  msg << \"Value of: \" << expression_text\n      << \"\\n  Actual: \" << actual_predicate_value;\n  if (actual_message[0] != '\\0')\n    msg << \" (\" << actual_message << \")\";\n  msg << \"\\nExpected: \" << expected_predicate_value;\n  return msg.GetString();\n}\n\n// Helper function for implementing ASSERT_NEAR.\nAssertionResult DoubleNearPredFormat(const char* expr1,\n                                     const char* expr2,\n                                     const char* abs_error_expr,\n                                     double val1,\n                                     double val2,\n                                     double abs_error) {\n  const double diff = fabs(val1 - val2);\n  if (diff <= abs_error) return AssertionSuccess();\n\n  // TODO(wan): do not print the value of an expression if it's\n  // already a literal.\n  return AssertionFailure()\n      << \"The difference between \" << expr1 << \" and \" << expr2\n      << \" is \" << diff << \", which exceeds \" << abs_error_expr << \", where\\n\"\n      << expr1 << \" evaluates to \" << val1 << \",\\n\"\n      << expr2 << \" evaluates to \" << val2 << \", and\\n\"\n      << abs_error_expr << \" evaluates to \" << abs_error << \".\";\n}\n\n\n// Helper template for implementing FloatLE() and DoubleLE().\ntemplate <typename RawType>\nAssertionResult FloatingPointLE(const char* expr1,\n                                const char* expr2,\n                                RawType val1,\n                                RawType val2) {\n  // Returns success if val1 is less than val2,\n  if (val1 < val2) {\n    return AssertionSuccess();\n  }\n\n  // or if val1 is almost equal to val2.\n  const FloatingPoint<RawType> lhs(val1), rhs(val2);\n  if (lhs.AlmostEquals(rhs)) {\n    return AssertionSuccess();\n  }\n\n  // Note that the above two checks will both fail if either val1 or\n  // val2 is NaN, as the IEEE floating-point standard requires that\n  // any predicate involving a NaN must return false.\n\n  ::std::stringstream val1_ss;\n  val1_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)\n          << val1;\n\n  ::std::stringstream val2_ss;\n  val2_ss << std::setprecision(std::numeric_limits<RawType>::digits10 + 2)\n          << val2;\n\n  return AssertionFailure()\n      << \"Expected: (\" << expr1 << \") <= (\" << expr2 << \")\\n\"\n      << \"  Actual: \" << StringStreamToString(&val1_ss) << \" vs \"\n      << StringStreamToString(&val2_ss);\n}\n\n}  // namespace internal\n\n// Asserts that val1 is less than, or almost equal to, val2.  Fails\n// otherwise.  In particular, it fails if either val1 or val2 is NaN.\nAssertionResult FloatLE(const char* expr1, const char* expr2,\n                        float val1, float val2) {\n  return internal::FloatingPointLE<float>(expr1, expr2, val1, val2);\n}\n\n// Asserts that val1 is less than, or almost equal to, val2.  Fails\n// otherwise.  In particular, it fails if either val1 or val2 is NaN.\nAssertionResult DoubleLE(const char* expr1, const char* expr2,\n                         double val1, double val2) {\n  return internal::FloatingPointLE<double>(expr1, expr2, val1, val2);\n}\n\nnamespace internal {\n\n// The helper function for {ASSERT|EXPECT}_EQ with int or enum\n// arguments.\nAssertionResult CmpHelperEQ(const char* expected_expression,\n                            const char* actual_expression,\n                            BiggestInt expected,\n                            BiggestInt actual) {\n  if (expected == actual) {\n    return AssertionSuccess();\n  }\n\n  return EqFailure(expected_expression,\n                   actual_expression,\n                   FormatForComparisonFailureMessage(expected, actual),\n                   FormatForComparisonFailureMessage(actual, expected),\n                   false);\n}\n\n// A macro for implementing the helper functions needed to implement\n// ASSERT_?? and EXPECT_?? with integer or enum arguments.  It is here\n// just to avoid copy-and-paste of similar code.\n#define GTEST_IMPL_CMP_HELPER_(op_name, op)\\\nAssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \\\n                                   BiggestInt val1, BiggestInt val2) {\\\n  if (val1 op val2) {\\\n    return AssertionSuccess();\\\n  } else {\\\n    return AssertionFailure() \\\n        << \"Expected: (\" << expr1 << \") \" #op \" (\" << expr2\\\n        << \"), actual: \" << FormatForComparisonFailureMessage(val1, val2)\\\n        << \" vs \" << FormatForComparisonFailureMessage(val2, val1);\\\n  }\\\n}\n\n// Implements the helper function for {ASSERT|EXPECT}_NE with int or\n// enum arguments.\nGTEST_IMPL_CMP_HELPER_(NE, !=)\n// Implements the helper function for {ASSERT|EXPECT}_LE with int or\n// enum arguments.\nGTEST_IMPL_CMP_HELPER_(LE, <=)\n// Implements the helper function for {ASSERT|EXPECT}_LT with int or\n// enum arguments.\nGTEST_IMPL_CMP_HELPER_(LT, < )\n// Implements the helper function for {ASSERT|EXPECT}_GE with int or\n// enum arguments.\nGTEST_IMPL_CMP_HELPER_(GE, >=)\n// Implements the helper function for {ASSERT|EXPECT}_GT with int or\n// enum arguments.\nGTEST_IMPL_CMP_HELPER_(GT, > )\n\n#undef GTEST_IMPL_CMP_HELPER_\n\n// The helper function for {ASSERT|EXPECT}_STREQ.\nAssertionResult CmpHelperSTREQ(const char* expected_expression,\n                               const char* actual_expression,\n                               const char* expected,\n                               const char* actual) {\n  if (String::CStringEquals(expected, actual)) {\n    return AssertionSuccess();\n  }\n\n  return EqFailure(expected_expression,\n                   actual_expression,\n                   PrintToString(expected),\n                   PrintToString(actual),\n                   false);\n}\n\n// The helper function for {ASSERT|EXPECT}_STRCASEEQ.\nAssertionResult CmpHelperSTRCASEEQ(const char* expected_expression,\n                                   const char* actual_expression,\n                                   const char* expected,\n                                   const char* actual) {\n  if (String::CaseInsensitiveCStringEquals(expected, actual)) {\n    return AssertionSuccess();\n  }\n\n  return EqFailure(expected_expression,\n                   actual_expression,\n                   PrintToString(expected),\n                   PrintToString(actual),\n                   true);\n}\n\n// The helper function for {ASSERT|EXPECT}_STRNE.\nAssertionResult CmpHelperSTRNE(const char* s1_expression,\n                               const char* s2_expression,\n                               const char* s1,\n                               const char* s2) {\n  if (!String::CStringEquals(s1, s2)) {\n    return AssertionSuccess();\n  } else {\n    return AssertionFailure() << \"Expected: (\" << s1_expression << \") != (\"\n                              << s2_expression << \"), actual: \\\"\"\n                              << s1 << \"\\\" vs \\\"\" << s2 << \"\\\"\";\n  }\n}\n\n// The helper function for {ASSERT|EXPECT}_STRCASENE.\nAssertionResult CmpHelperSTRCASENE(const char* s1_expression,\n                                   const char* s2_expression,\n                                   const char* s1,\n                                   const char* s2) {\n  if (!String::CaseInsensitiveCStringEquals(s1, s2)) {\n    return AssertionSuccess();\n  } else {\n    return AssertionFailure()\n        << \"Expected: (\" << s1_expression << \") != (\"\n        << s2_expression << \") (ignoring case), actual: \\\"\"\n        << s1 << \"\\\" vs \\\"\" << s2 << \"\\\"\";\n  }\n}\n\n}  // namespace internal\n\nnamespace {\n\n// Helper functions for implementing IsSubString() and IsNotSubstring().\n\n// This group of overloaded functions return true iff needle is a\n// substring of haystack.  NULL is considered a substring of itself\n// only.\n\nbool IsSubstringPred(const char* needle, const char* haystack) {\n  if (needle == NULL || haystack == NULL)\n    return needle == haystack;\n\n  return strstr(haystack, needle) != NULL;\n}\n\nbool IsSubstringPred(const wchar_t* needle, const wchar_t* haystack) {\n  if (needle == NULL || haystack == NULL)\n    return needle == haystack;\n\n  return wcsstr(haystack, needle) != NULL;\n}\n\n// StringType here can be either ::std::string or ::std::wstring.\ntemplate <typename StringType>\nbool IsSubstringPred(const StringType& needle,\n                     const StringType& haystack) {\n  return haystack.find(needle) != StringType::npos;\n}\n\n// This function implements either IsSubstring() or IsNotSubstring(),\n// depending on the value of the expected_to_be_substring parameter.\n// StringType here can be const char*, const wchar_t*, ::std::string,\n// or ::std::wstring.\ntemplate <typename StringType>\nAssertionResult IsSubstringImpl(\n    bool expected_to_be_substring,\n    const char* needle_expr, const char* haystack_expr,\n    const StringType& needle, const StringType& haystack) {\n  if (IsSubstringPred(needle, haystack) == expected_to_be_substring)\n    return AssertionSuccess();\n\n  const bool is_wide_string = sizeof(needle[0]) > 1;\n  const char* const begin_string_quote = is_wide_string ? \"L\\\"\" : \"\\\"\";\n  return AssertionFailure()\n      << \"Value of: \" << needle_expr << \"\\n\"\n      << \"  Actual: \" << begin_string_quote << needle << \"\\\"\\n\"\n      << \"Expected: \" << (expected_to_be_substring ? \"\" : \"not \")\n      << \"a substring of \" << haystack_expr << \"\\n\"\n      << \"Which is: \" << begin_string_quote << haystack << \"\\\"\";\n}\n\n}  // namespace\n\n// IsSubstring() and IsNotSubstring() check whether needle is a\n// substring of haystack (NULL is considered a substring of itself\n// only), and return an appropriate error message when they fail.\n\nAssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const char* needle, const char* haystack) {\n  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);\n}\n\nAssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const wchar_t* needle, const wchar_t* haystack) {\n  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);\n}\n\nAssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const char* needle, const char* haystack) {\n  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);\n}\n\nAssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const wchar_t* needle, const wchar_t* haystack) {\n  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);\n}\n\nAssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::string& needle, const ::std::string& haystack) {\n  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);\n}\n\nAssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::string& needle, const ::std::string& haystack) {\n  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);\n}\n\n#if GTEST_HAS_STD_WSTRING\nAssertionResult IsSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::wstring& needle, const ::std::wstring& haystack) {\n  return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack);\n}\n\nAssertionResult IsNotSubstring(\n    const char* needle_expr, const char* haystack_expr,\n    const ::std::wstring& needle, const ::std::wstring& haystack) {\n  return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack);\n}\n#endif  // GTEST_HAS_STD_WSTRING\n\nnamespace internal {\n\n#if GTEST_OS_WINDOWS\n\nnamespace {\n\n// Helper function for IsHRESULT{SuccessFailure} predicates\nAssertionResult HRESULTFailureHelper(const char* expr,\n                                     const char* expected,\n                                     long hr) {  // NOLINT\n# if GTEST_OS_WINDOWS_MOBILE\n\n  // Windows CE doesn't support FormatMessage.\n  const char error_text[] = \"\";\n\n# else\n\n  // Looks up the human-readable system message for the HRESULT code\n  // and since we're not passing any params to FormatMessage, we don't\n  // want inserts expanded.\n  const DWORD kFlags = FORMAT_MESSAGE_FROM_SYSTEM |\n                       FORMAT_MESSAGE_IGNORE_INSERTS;\n  const DWORD kBufSize = 4096;\n  // Gets the system's human readable message string for this HRESULT.\n  char error_text[kBufSize] = { '\\0' };\n  DWORD message_length = ::FormatMessageA(kFlags,\n                                          0,  // no source, we're asking system\n                                          hr,  // the error\n                                          0,  // no line width restrictions\n                                          error_text,  // output buffer\n                                          kBufSize,  // buf size\n                                          NULL);  // no arguments for inserts\n  // Trims tailing white space (FormatMessage leaves a trailing CR-LF)\n  for (; message_length && IsSpace(error_text[message_length - 1]);\n          --message_length) {\n    error_text[message_length - 1] = '\\0';\n  }\n\n# endif  // GTEST_OS_WINDOWS_MOBILE\n\n  const std::string error_hex(\"0x\" + String::FormatHexInt(hr));\n  return ::testing::AssertionFailure()\n      << \"Expected: \" << expr << \" \" << expected << \".\\n\"\n      << \"  Actual: \" << error_hex << \" \" << error_text << \"\\n\";\n}\n\n}  // namespace\n\nAssertionResult IsHRESULTSuccess(const char* expr, long hr) {  // NOLINT\n  if (SUCCEEDED(hr)) {\n    return AssertionSuccess();\n  }\n  return HRESULTFailureHelper(expr, \"succeeds\", hr);\n}\n\nAssertionResult IsHRESULTFailure(const char* expr, long hr) {  // NOLINT\n  if (FAILED(hr)) {\n    return AssertionSuccess();\n  }\n  return HRESULTFailureHelper(expr, \"fails\", hr);\n}\n\n#endif  // GTEST_OS_WINDOWS\n\n// Utility functions for encoding Unicode text (wide strings) in\n// UTF-8.\n\n// A Unicode code-point can have upto 21 bits, and is encoded in UTF-8\n// like this:\n//\n// Code-point length   Encoding\n//   0 -  7 bits       0xxxxxxx\n//   8 - 11 bits       110xxxxx 10xxxxxx\n//  12 - 16 bits       1110xxxx 10xxxxxx 10xxxxxx\n//  17 - 21 bits       11110xxx 10xxxxxx 10xxxxxx 10xxxxxx\n\n// The maximum code-point a one-byte UTF-8 sequence can represent.\nconst UInt32 kMaxCodePoint1 = (static_cast<UInt32>(1) <<  7) - 1;\n\n// The maximum code-point a two-byte UTF-8 sequence can represent.\nconst UInt32 kMaxCodePoint2 = (static_cast<UInt32>(1) << (5 + 6)) - 1;\n\n// The maximum code-point a three-byte UTF-8 sequence can represent.\nconst UInt32 kMaxCodePoint3 = (static_cast<UInt32>(1) << (4 + 2*6)) - 1;\n\n// The maximum code-point a four-byte UTF-8 sequence can represent.\nconst UInt32 kMaxCodePoint4 = (static_cast<UInt32>(1) << (3 + 3*6)) - 1;\n\n// Chops off the n lowest bits from a bit pattern.  Returns the n\n// lowest bits.  As a side effect, the original bit pattern will be\n// shifted to the right by n bits.\ninline UInt32 ChopLowBits(UInt32* bits, int n) {\n  const UInt32 low_bits = *bits & ((static_cast<UInt32>(1) << n) - 1);\n  *bits >>= n;\n  return low_bits;\n}\n\n// Converts a Unicode code point to a narrow string in UTF-8 encoding.\n// code_point parameter is of type UInt32 because wchar_t may not be\n// wide enough to contain a code point.\n// If the code_point is not a valid Unicode code point\n// (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted\n// to \"(Invalid Unicode 0xXXXXXXXX)\".\nstd::string CodePointToUtf8(UInt32 code_point) {\n  if (code_point > kMaxCodePoint4) {\n    return \"(Invalid Unicode 0x\" + String::FormatHexInt(code_point) + \")\";\n  }\n\n  char str[5];  // Big enough for the largest valid code point.\n  if (code_point <= kMaxCodePoint1) {\n    str[1] = '\\0';\n    str[0] = static_cast<char>(code_point);                          // 0xxxxxxx\n  } else if (code_point <= kMaxCodePoint2) {\n    str[2] = '\\0';\n    str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx\n    str[0] = static_cast<char>(0xC0 | code_point);                   // 110xxxxx\n  } else if (code_point <= kMaxCodePoint3) {\n    str[3] = '\\0';\n    str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx\n    str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx\n    str[0] = static_cast<char>(0xE0 | code_point);                   // 1110xxxx\n  } else {  // code_point <= kMaxCodePoint4\n    str[4] = '\\0';\n    str[3] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx\n    str[2] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx\n    str[1] = static_cast<char>(0x80 | ChopLowBits(&code_point, 6));  // 10xxxxxx\n    str[0] = static_cast<char>(0xF0 | code_point);                   // 11110xxx\n  }\n  return str;\n}\n\n// The following two functions only make sense if the the system\n// uses UTF-16 for wide string encoding. All supported systems\n// with 16 bit wchar_t (Windows, Cygwin, Symbian OS) do use UTF-16.\n\n// Determines if the arguments constitute UTF-16 surrogate pair\n// and thus should be combined into a single Unicode code point\n// using CreateCodePointFromUtf16SurrogatePair.\ninline bool IsUtf16SurrogatePair(wchar_t first, wchar_t second) {\n  return sizeof(wchar_t) == 2 &&\n      (first & 0xFC00) == 0xD800 && (second & 0xFC00) == 0xDC00;\n}\n\n// Creates a Unicode code point from UTF16 surrogate pair.\ninline UInt32 CreateCodePointFromUtf16SurrogatePair(wchar_t first,\n                                                    wchar_t second) {\n  const UInt32 mask = (1 << 10) - 1;\n  return (sizeof(wchar_t) == 2) ?\n      (((first & mask) << 10) | (second & mask)) + 0x10000 :\n      // This function should not be called when the condition is\n      // false, but we provide a sensible default in case it is.\n      static_cast<UInt32>(first);\n}\n\n// Converts a wide string to a narrow string in UTF-8 encoding.\n// The wide string is assumed to have the following encoding:\n//   UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin, Symbian OS)\n//   UTF-32 if sizeof(wchar_t) == 4 (on Linux)\n// Parameter str points to a null-terminated wide string.\n// Parameter num_chars may additionally limit the number\n// of wchar_t characters processed. -1 is used when the entire string\n// should be processed.\n// If the string contains code points that are not valid Unicode code points\n// (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output\n// as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding\n// and contains invalid UTF-16 surrogate pairs, values in those pairs\n// will be encoded as individual Unicode characters from Basic Normal Plane.\nstd::string WideStringToUtf8(const wchar_t* str, int num_chars) {\n  if (num_chars == -1)\n    num_chars = static_cast<int>(wcslen(str));\n\n  ::std::stringstream stream;\n  for (int i = 0; i < num_chars; ++i) {\n    UInt32 unicode_code_point;\n\n    if (str[i] == L'\\0') {\n      break;\n    } else if (i + 1 < num_chars && IsUtf16SurrogatePair(str[i], str[i + 1])) {\n      unicode_code_point = CreateCodePointFromUtf16SurrogatePair(str[i],\n                                                                 str[i + 1]);\n      i++;\n    } else {\n      unicode_code_point = static_cast<UInt32>(str[i]);\n    }\n\n    stream << CodePointToUtf8(unicode_code_point);\n  }\n  return StringStreamToString(&stream);\n}\n\n// Converts a wide C string to an std::string using the UTF-8 encoding.\n// NULL will be converted to \"(null)\".\nstd::string String::ShowWideCString(const wchar_t * wide_c_str) {\n  if (wide_c_str == NULL)  return \"(null)\";\n\n  return internal::WideStringToUtf8(wide_c_str, -1);\n}\n\n// Compares two wide C strings.  Returns true iff they have the same\n// content.\n//\n// Unlike wcscmp(), this function can handle NULL argument(s).  A NULL\n// C string is considered different to any non-NULL C string,\n// including the empty string.\nbool String::WideCStringEquals(const wchar_t * lhs, const wchar_t * rhs) {\n  if (lhs == NULL) return rhs == NULL;\n\n  if (rhs == NULL) return false;\n\n  return wcscmp(lhs, rhs) == 0;\n}\n\n// Helper function for *_STREQ on wide strings.\nAssertionResult CmpHelperSTREQ(const char* expected_expression,\n                               const char* actual_expression,\n                               const wchar_t* expected,\n                               const wchar_t* actual) {\n  if (String::WideCStringEquals(expected, actual)) {\n    return AssertionSuccess();\n  }\n\n  return EqFailure(expected_expression,\n                   actual_expression,\n                   PrintToString(expected),\n                   PrintToString(actual),\n                   false);\n}\n\n// Helper function for *_STRNE on wide strings.\nAssertionResult CmpHelperSTRNE(const char* s1_expression,\n                               const char* s2_expression,\n                               const wchar_t* s1,\n                               const wchar_t* s2) {\n  if (!String::WideCStringEquals(s1, s2)) {\n    return AssertionSuccess();\n  }\n\n  return AssertionFailure() << \"Expected: (\" << s1_expression << \") != (\"\n                            << s2_expression << \"), actual: \"\n                            << PrintToString(s1)\n                            << \" vs \" << PrintToString(s2);\n}\n\n// Compares two C strings, ignoring case.  Returns true iff they have\n// the same content.\n//\n// Unlike strcasecmp(), this function can handle NULL argument(s).  A\n// NULL C string is considered different to any non-NULL C string,\n// including the empty string.\nbool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) {\n  if (lhs == NULL)\n    return rhs == NULL;\n  if (rhs == NULL)\n    return false;\n  return posix::StrCaseCmp(lhs, rhs) == 0;\n}\n\n  // Compares two wide C strings, ignoring case.  Returns true iff they\n  // have the same content.\n  //\n  // Unlike wcscasecmp(), this function can handle NULL argument(s).\n  // A NULL C string is considered different to any non-NULL wide C string,\n  // including the empty string.\n  // NB: The implementations on different platforms slightly differ.\n  // On windows, this method uses _wcsicmp which compares according to LC_CTYPE\n  // environment variable. On GNU platform this method uses wcscasecmp\n  // which compares according to LC_CTYPE category of the current locale.\n  // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the\n  // current locale.\nbool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs,\n                                              const wchar_t* rhs) {\n  if (lhs == NULL) return rhs == NULL;\n\n  if (rhs == NULL) return false;\n\n#if GTEST_OS_WINDOWS\n  return _wcsicmp(lhs, rhs) == 0;\n#elif GTEST_OS_LINUX && !GTEST_OS_LINUX_ANDROID\n  return wcscasecmp(lhs, rhs) == 0;\n#else\n  // Android, Mac OS X and Cygwin don't define wcscasecmp.\n  // Other unknown OSes may not define it either.\n  wint_t left, right;\n  do {\n    left = towlower(*lhs++);\n    right = towlower(*rhs++);\n  } while (left && left == right);\n  return left == right;\n#endif  // OS selector\n}\n\n// Returns true iff str ends with the given suffix, ignoring case.\n// Any string is considered to end with an empty suffix.\nbool String::EndsWithCaseInsensitive(\n    const std::string& str, const std::string& suffix) {\n  const size_t str_len = str.length();\n  const size_t suffix_len = suffix.length();\n  return (str_len >= suffix_len) &&\n         CaseInsensitiveCStringEquals(str.c_str() + str_len - suffix_len,\n                                      suffix.c_str());\n}\n\n// Formats an int value as \"%02d\".\nstd::string String::FormatIntWidth2(int value) {\n  std::stringstream ss;\n  ss << std::setfill('0') << std::setw(2) << value;\n  return ss.str();\n}\n\n// Formats an int value as \"%X\".\nstd::string String::FormatHexInt(int value) {\n  std::stringstream ss;\n  ss << std::hex << std::uppercase << value;\n  return ss.str();\n}\n\n// Formats a byte as \"%02X\".\nstd::string String::FormatByte(unsigned char value) {\n  std::stringstream ss;\n  ss << std::setfill('0') << std::setw(2) << std::hex << std::uppercase\n     << static_cast<unsigned int>(value);\n  return ss.str();\n}\n\n// Converts the buffer in a stringstream to an std::string, converting NUL\n// bytes to \"\\\\0\" along the way.\nstd::string StringStreamToString(::std::stringstream* ss) {\n  const ::std::string& str = ss->str();\n  const char* const start = str.c_str();\n  const char* const end = start + str.length();\n\n  std::string result;\n  result.reserve(2 * (end - start));\n  for (const char* ch = start; ch != end; ++ch) {\n    if (*ch == '\\0') {\n      result += \"\\\\0\";  // Replaces NUL with \"\\\\0\";\n    } else {\n      result += *ch;\n    }\n  }\n\n  return result;\n}\n\n// Appends the user-supplied message to the Google-Test-generated message.\nstd::string AppendUserMessage(const std::string& gtest_msg,\n                              const Message& user_msg) {\n  // Appends the user message if it's non-empty.\n  const std::string user_msg_string = user_msg.GetString();\n  if (user_msg_string.empty()) {\n    return gtest_msg;\n  }\n\n  return gtest_msg + \"\\n\" + user_msg_string;\n}\n\n}  // namespace internal\n\n// class TestResult\n\n// Creates an empty TestResult.\nTestResult::TestResult()\n    : death_test_count_(0),\n      elapsed_time_(0) {\n}\n\n// D'tor.\nTestResult::~TestResult() {\n}\n\n// Returns the i-th test part result among all the results. i can\n// range from 0 to total_part_count() - 1. If i is not in that range,\n// aborts the program.\nconst TestPartResult& TestResult::GetTestPartResult(int i) const {\n  if (i < 0 || i >= total_part_count())\n    internal::posix::Abort();\n  return test_part_results_.at(i);\n}\n\n// Returns the i-th test property. i can range from 0 to\n// test_property_count() - 1. If i is not in that range, aborts the\n// program.\nconst TestProperty& TestResult::GetTestProperty(int i) const {\n  if (i < 0 || i >= test_property_count())\n    internal::posix::Abort();\n  return test_properties_.at(i);\n}\n\n// Clears the test part results.\nvoid TestResult::ClearTestPartResults() {\n  test_part_results_.clear();\n}\n\n// Adds a test part result to the list.\nvoid TestResult::AddTestPartResult(const TestPartResult& test_part_result) {\n  test_part_results_.push_back(test_part_result);\n}\n\n// Adds a test property to the list. If a property with the same key as the\n// supplied property is already represented, the value of this test_property\n// replaces the old value for that key.\nvoid TestResult::RecordProperty(const std::string& xml_element,\n                                const TestProperty& test_property) {\n  if (!ValidateTestProperty(xml_element, test_property)) {\n    return;\n  }\n  internal::MutexLock lock(&test_properites_mutex_);\n  const std::vector<TestProperty>::iterator property_with_matching_key =\n      std::find_if(test_properties_.begin(), test_properties_.end(),\n                   internal::TestPropertyKeyIs(test_property.key()));\n  if (property_with_matching_key == test_properties_.end()) {\n    test_properties_.push_back(test_property);\n    return;\n  }\n  property_with_matching_key->SetValue(test_property.value());\n}\n\n// The list of reserved attributes used in the <testsuites> element of XML\n// output.\nstatic const char* const kReservedTestSuitesAttributes[] = {\n  \"disabled\",\n  \"errors\",\n  \"failures\",\n  \"name\",\n  \"random_seed\",\n  \"tests\",\n  \"time\",\n  \"timestamp\"\n};\n\n// The list of reserved attributes used in the <testsuite> element of XML\n// output.\nstatic const char* const kReservedTestSuiteAttributes[] = {\n  \"disabled\",\n  \"errors\",\n  \"failures\",\n  \"name\",\n  \"tests\",\n  \"time\"\n};\n\n// The list of reserved attributes used in the <testcase> element of XML output.\nstatic const char* const kReservedTestCaseAttributes[] = {\n  \"classname\",\n  \"name\",\n  \"status\",\n  \"time\",\n  \"type_param\",\n  \"value_param\"\n};\n\ntemplate <int kSize>\nstd::vector<std::string> ArrayAsVector(const char* const (&array)[kSize]) {\n  return std::vector<std::string>(array, array + kSize);\n}\n\nstatic std::vector<std::string> GetReservedAttributesForElement(\n    const std::string& xml_element) {\n  if (xml_element == \"testsuites\") {\n    return ArrayAsVector(kReservedTestSuitesAttributes);\n  } else if (xml_element == \"testsuite\") {\n    return ArrayAsVector(kReservedTestSuiteAttributes);\n  } else if (xml_element == \"testcase\") {\n    return ArrayAsVector(kReservedTestCaseAttributes);\n  } else {\n    GTEST_CHECK_(false) << \"Unrecognized xml_element provided: \" << xml_element;\n  }\n  // This code is unreachable but some compilers may not realizes that.\n  return std::vector<std::string>();\n}\n\nstatic std::string FormatWordList(const std::vector<std::string>& words) {\n  Message word_list;\n  for (size_t i = 0; i < words.size(); ++i) {\n    if (i > 0 && words.size() > 2) {\n      word_list << \", \";\n    }\n    if (i == words.size() - 1) {\n      word_list << \"and \";\n    }\n    word_list << \"'\" << words[i] << \"'\";\n  }\n  return word_list.GetString();\n}\n\nbool ValidateTestPropertyName(const std::string& property_name,\n                              const std::vector<std::string>& reserved_names) {\n  if (std::find(reserved_names.begin(), reserved_names.end(), property_name) !=\n          reserved_names.end()) {\n    ADD_FAILURE() << \"Reserved key used in RecordProperty(): \" << property_name\n                  << \" (\" << FormatWordList(reserved_names)\n                  << \" are reserved by \" << GTEST_NAME_ << \")\";\n    return false;\n  }\n  return true;\n}\n\n// Adds a failure if the key is a reserved attribute of the element named\n// xml_element.  Returns true if the property is valid.\nbool TestResult::ValidateTestProperty(const std::string& xml_element,\n                                      const TestProperty& test_property) {\n  return ValidateTestPropertyName(test_property.key(),\n                                  GetReservedAttributesForElement(xml_element));\n}\n\n// Clears the object.\nvoid TestResult::Clear() {\n  test_part_results_.clear();\n  test_properties_.clear();\n  death_test_count_ = 0;\n  elapsed_time_ = 0;\n}\n\n// Returns true iff the test failed.\nbool TestResult::Failed() const {\n  for (int i = 0; i < total_part_count(); ++i) {\n    if (GetTestPartResult(i).failed())\n      return true;\n  }\n  return false;\n}\n\n// Returns true iff the test part fatally failed.\nstatic bool TestPartFatallyFailed(const TestPartResult& result) {\n  return result.fatally_failed();\n}\n\n// Returns true iff the test fatally failed.\nbool TestResult::HasFatalFailure() const {\n  return CountIf(test_part_results_, TestPartFatallyFailed) > 0;\n}\n\n// Returns true iff the test part non-fatally failed.\nstatic bool TestPartNonfatallyFailed(const TestPartResult& result) {\n  return result.nonfatally_failed();\n}\n\n// Returns true iff the test has a non-fatal failure.\nbool TestResult::HasNonfatalFailure() const {\n  return CountIf(test_part_results_, TestPartNonfatallyFailed) > 0;\n}\n\n// Gets the number of all test parts.  This is the sum of the number\n// of successful test parts and the number of failed test parts.\nint TestResult::total_part_count() const {\n  return static_cast<int>(test_part_results_.size());\n}\n\n// Returns the number of the test properties.\nint TestResult::test_property_count() const {\n  return static_cast<int>(test_properties_.size());\n}\n\n// class Test\n\n// Creates a Test object.\n\n// The c'tor saves the values of all Google Test flags.\nTest::Test()\n    : gtest_flag_saver_(new internal::GTestFlagSaver) {\n}\n\n// The d'tor restores the values of all Google Test flags.\nTest::~Test() {\n  delete gtest_flag_saver_;\n}\n\n// Sets up the test fixture.\n//\n// A sub-class may override this.\nvoid Test::SetUp() {\n}\n\n// Tears down the test fixture.\n//\n// A sub-class may override this.\nvoid Test::TearDown() {\n}\n\n// Allows user supplied key value pairs to be recorded for later output.\nvoid Test::RecordProperty(const std::string& key, const std::string& value) {\n  UnitTest::GetInstance()->RecordProperty(key, value);\n}\n\n// Allows user supplied key value pairs to be recorded for later output.\nvoid Test::RecordProperty(const std::string& key, int value) {\n  Message value_message;\n  value_message << value;\n  RecordProperty(key, value_message.GetString().c_str());\n}\n\nnamespace internal {\n\nvoid ReportFailureInUnknownLocation(TestPartResult::Type result_type,\n                                    const std::string& message) {\n  // This function is a friend of UnitTest and as such has access to\n  // AddTestPartResult.\n  UnitTest::GetInstance()->AddTestPartResult(\n      result_type,\n      NULL,  // No info about the source file where the exception occurred.\n      -1,    // We have no info on which line caused the exception.\n      message,\n      \"\");   // No stack trace, either.\n}\n\n}  // namespace internal\n\n// Google Test requires all tests in the same test case to use the same test\n// fixture class.  This function checks if the current test has the\n// same fixture class as the first test in the current test case.  If\n// yes, it returns true; otherwise it generates a Google Test failure and\n// returns false.\nbool Test::HasSameFixtureClass() {\n  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();\n  const TestCase* const test_case = impl->current_test_case();\n\n  // Info about the first test in the current test case.\n  const TestInfo* const first_test_info = test_case->test_info_list()[0];\n  const internal::TypeId first_fixture_id = first_test_info->fixture_class_id_;\n  const char* const first_test_name = first_test_info->name();\n\n  // Info about the current test.\n  const TestInfo* const this_test_info = impl->current_test_info();\n  const internal::TypeId this_fixture_id = this_test_info->fixture_class_id_;\n  const char* const this_test_name = this_test_info->name();\n\n  if (this_fixture_id != first_fixture_id) {\n    // Is the first test defined using TEST?\n    const bool first_is_TEST = first_fixture_id == internal::GetTestTypeId();\n    // Is this test defined using TEST?\n    const bool this_is_TEST = this_fixture_id == internal::GetTestTypeId();\n\n    if (first_is_TEST || this_is_TEST) {\n      // The user mixed TEST and TEST_F in this test case - we'll tell\n      // him/her how to fix it.\n\n      // Gets the name of the TEST and the name of the TEST_F.  Note\n      // that first_is_TEST and this_is_TEST cannot both be true, as\n      // the fixture IDs are different for the two tests.\n      const char* const TEST_name =\n          first_is_TEST ? first_test_name : this_test_name;\n      const char* const TEST_F_name =\n          first_is_TEST ? this_test_name : first_test_name;\n\n      ADD_FAILURE()\n          << \"All tests in the same test case must use the same test fixture\\n\"\n          << \"class, so mixing TEST_F and TEST in the same test case is\\n\"\n          << \"illegal.  In test case \" << this_test_info->test_case_name()\n          << \",\\n\"\n          << \"test \" << TEST_F_name << \" is defined using TEST_F but\\n\"\n          << \"test \" << TEST_name << \" is defined using TEST.  You probably\\n\"\n          << \"want to change the TEST to TEST_F or move it to another test\\n\"\n          << \"case.\";\n    } else {\n      // The user defined two fixture classes with the same name in\n      // two namespaces - we'll tell him/her how to fix it.\n      ADD_FAILURE()\n          << \"All tests in the same test case must use the same test fixture\\n\"\n          << \"class.  However, in test case \"\n          << this_test_info->test_case_name() << \",\\n\"\n          << \"you defined test \" << first_test_name\n          << \" and test \" << this_test_name << \"\\n\"\n          << \"using two different test fixture classes.  This can happen if\\n\"\n          << \"the two classes are from different namespaces or translation\\n\"\n          << \"units and have the same name.  You should probably rename one\\n\"\n          << \"of the classes to put the tests into different test cases.\";\n    }\n    return false;\n  }\n\n  return true;\n}\n\n#if GTEST_HAS_SEH\n\n// Adds an \"exception thrown\" fatal failure to the current test.  This\n// function returns its result via an output parameter pointer because VC++\n// prohibits creation of objects with destructors on stack in functions\n// using __try (see error C2712).\nstatic std::string* FormatSehExceptionMessage(DWORD exception_code,\n                                              const char* location) {\n  Message message;\n  message << \"SEH exception with code 0x\" << std::setbase(16) <<\n    exception_code << std::setbase(10) << \" thrown in \" << location << \".\";\n\n  return new std::string(message.GetString());\n}\n\n#endif  // GTEST_HAS_SEH\n\nnamespace internal {\n\n#if GTEST_HAS_EXCEPTIONS\n\n// Adds an \"exception thrown\" fatal failure to the current test.\nstatic std::string FormatCxxExceptionMessage(const char* description,\n                                             const char* location) {\n  Message message;\n  if (description != NULL) {\n    message << \"C++ exception with description \\\"\" << description << \"\\\"\";\n  } else {\n    message << \"Unknown C++ exception\";\n  }\n  message << \" thrown in \" << location << \".\";\n\n  return message.GetString();\n}\n\nstatic std::string PrintTestPartResultToString(\n    const TestPartResult& test_part_result);\n\nGoogleTestFailureException::GoogleTestFailureException(\n    const TestPartResult& failure)\n    : ::std::runtime_error(PrintTestPartResultToString(failure).c_str()) {}\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n// We put these helper functions in the internal namespace as IBM's xlC\n// compiler rejects the code if they were declared static.\n\n// Runs the given method and handles SEH exceptions it throws, when\n// SEH is supported; returns the 0-value for type Result in case of an\n// SEH exception.  (Microsoft compilers cannot handle SEH and C++\n// exceptions in the same function.  Therefore, we provide a separate\n// wrapper function for handling SEH exceptions.)\ntemplate <class T, typename Result>\nResult HandleSehExceptionsInMethodIfSupported(\n    T* object, Result (T::*method)(), const char* location) {\n#if GTEST_HAS_SEH\n  __try {\n    return (object->*method)();\n  } __except (internal::UnitTestOptions::GTestShouldProcessSEH(  // NOLINT\n      GetExceptionCode())) {\n    // We create the exception message on the heap because VC++ prohibits\n    // creation of objects with destructors on stack in functions using __try\n    // (see error C2712).\n    std::string* exception_message = FormatSehExceptionMessage(\n        GetExceptionCode(), location);\n    internal::ReportFailureInUnknownLocation(TestPartResult::kFatalFailure,\n                                             *exception_message);\n    delete exception_message;\n    return static_cast<Result>(0);\n  }\n#else\n  (void)location;\n  return (object->*method)();\n#endif  // GTEST_HAS_SEH\n}\n\n// Runs the given method and catches and reports C++ and/or SEH-style\n// exceptions, if they are supported; returns the 0-value for type\n// Result in case of an SEH exception.\ntemplate <class T, typename Result>\nResult HandleExceptionsInMethodIfSupported(\n    T* object, Result (T::*method)(), const char* location) {\n  // NOTE: The user code can affect the way in which Google Test handles\n  // exceptions by setting GTEST_FLAG(catch_exceptions), but only before\n  // RUN_ALL_TESTS() starts. It is technically possible to check the flag\n  // after the exception is caught and either report or re-throw the\n  // exception based on the flag's value:\n  //\n  // try {\n  //   // Perform the test method.\n  // } catch (...) {\n  //   if (GTEST_FLAG(catch_exceptions))\n  //     // Report the exception as failure.\n  //   else\n  //     throw;  // Re-throws the original exception.\n  // }\n  //\n  // However, the purpose of this flag is to allow the program to drop into\n  // the debugger when the exception is thrown. On most platforms, once the\n  // control enters the catch block, the exception origin information is\n  // lost and the debugger will stop the program at the point of the\n  // re-throw in this function -- instead of at the point of the original\n  // throw statement in the code under test.  For this reason, we perform\n  // the check early, sacrificing the ability to affect Google Test's\n  // exception handling in the method where the exception is thrown.\n  if (internal::GetUnitTestImpl()->catch_exceptions()) {\n#if GTEST_HAS_EXCEPTIONS\n    try {\n      return HandleSehExceptionsInMethodIfSupported(object, method, location);\n    } catch (const internal::GoogleTestFailureException&) {  // NOLINT\n      // This exception type can only be thrown by a failed Google\n      // Test assertion with the intention of letting another testing\n      // framework catch it.  Therefore we just re-throw it.\n      throw;\n    } catch (const std::exception& e) {  // NOLINT\n      internal::ReportFailureInUnknownLocation(\n          TestPartResult::kFatalFailure,\n          FormatCxxExceptionMessage(e.what(), location));\n    } catch (...) {  // NOLINT\n      internal::ReportFailureInUnknownLocation(\n          TestPartResult::kFatalFailure,\n          FormatCxxExceptionMessage(NULL, location));\n    }\n    return static_cast<Result>(0);\n#else\n    return HandleSehExceptionsInMethodIfSupported(object, method, location);\n#endif  // GTEST_HAS_EXCEPTIONS\n  } else {\n    return (object->*method)();\n  }\n}\n\n}  // namespace internal\n\n// Runs the test and updates the test result.\nvoid Test::Run() {\n  if (!HasSameFixtureClass()) return;\n\n  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();\n  impl->os_stack_trace_getter()->UponLeavingGTest();\n  internal::HandleExceptionsInMethodIfSupported(this, &Test::SetUp, \"SetUp()\");\n  // We will run the test only if SetUp() was successful.\n  if (!HasFatalFailure()) {\n    impl->os_stack_trace_getter()->UponLeavingGTest();\n    internal::HandleExceptionsInMethodIfSupported(\n        this, &Test::TestBody, \"the test body\");\n  }\n\n  // However, we want to clean up as much as possible.  Hence we will\n  // always call TearDown(), even if SetUp() or the test body has\n  // failed.\n  impl->os_stack_trace_getter()->UponLeavingGTest();\n  internal::HandleExceptionsInMethodIfSupported(\n      this, &Test::TearDown, \"TearDown()\");\n}\n\n// Returns true iff the current test has a fatal failure.\nbool Test::HasFatalFailure() {\n  return internal::GetUnitTestImpl()->current_test_result()->HasFatalFailure();\n}\n\n// Returns true iff the current test has a non-fatal failure.\nbool Test::HasNonfatalFailure() {\n  return internal::GetUnitTestImpl()->current_test_result()->\n      HasNonfatalFailure();\n}\n\n// class TestInfo\n\n// Constructs a TestInfo object. It assumes ownership of the test factory\n// object.\nTestInfo::TestInfo(const std::string& a_test_case_name,\n                   const std::string& a_name,\n                   const char* a_type_param,\n                   const char* a_value_param,\n                   internal::TypeId fixture_class_id,\n                   internal::TestFactoryBase* factory)\n    : test_case_name_(a_test_case_name),\n      name_(a_name),\n      type_param_(a_type_param ? new std::string(a_type_param) : NULL),\n      value_param_(a_value_param ? new std::string(a_value_param) : NULL),\n      fixture_class_id_(fixture_class_id),\n      should_run_(false),\n      is_disabled_(false),\n      matches_filter_(false),\n      factory_(factory),\n      result_() {}\n\n// Destructs a TestInfo object.\nTestInfo::~TestInfo() { delete factory_; }\n\nnamespace internal {\n\n// Creates a new TestInfo object and registers it with Google Test;\n// returns the created object.\n//\n// Arguments:\n//\n//   test_case_name:   name of the test case\n//   name:             name of the test\n//   type_param:       the name of the test's type parameter, or NULL if\n//                     this is not a typed or a type-parameterized test.\n//   value_param:      text representation of the test's value parameter,\n//                     or NULL if this is not a value-parameterized test.\n//   fixture_class_id: ID of the test fixture class\n//   set_up_tc:        pointer to the function that sets up the test case\n//   tear_down_tc:     pointer to the function that tears down the test case\n//   factory:          pointer to the factory that creates a test object.\n//                     The newly created TestInfo instance will assume\n//                     ownership of the factory object.\nTestInfo* MakeAndRegisterTestInfo(\n    const char* test_case_name,\n    const char* name,\n    const char* type_param,\n    const char* value_param,\n    TypeId fixture_class_id,\n    SetUpTestCaseFunc set_up_tc,\n    TearDownTestCaseFunc tear_down_tc,\n    TestFactoryBase* factory) {\n  TestInfo* const test_info =\n      new TestInfo(test_case_name, name, type_param, value_param,\n                   fixture_class_id, factory);\n  GetUnitTestImpl()->AddTestInfo(set_up_tc, tear_down_tc, test_info);\n  return test_info;\n}\n\n#if GTEST_HAS_PARAM_TEST\nvoid ReportInvalidTestCaseType(const char* test_case_name,\n                               const char* file, int line) {\n  Message errors;\n  errors\n      << \"Attempted redefinition of test case \" << test_case_name << \".\\n\"\n      << \"All tests in the same test case must use the same test fixture\\n\"\n      << \"class.  However, in test case \" << test_case_name << \", you tried\\n\"\n      << \"to define a test using a fixture class different from the one\\n\"\n      << \"used earlier. This can happen if the two fixture classes are\\n\"\n      << \"from different namespaces and have the same name. You should\\n\"\n      << \"probably rename one of the classes to put the tests into different\\n\"\n      << \"test cases.\";\n\n  fprintf(stderr, \"%s %s\", FormatFileLocation(file, line).c_str(),\n          errors.GetString().c_str());\n}\n#endif  // GTEST_HAS_PARAM_TEST\n\n}  // namespace internal\n\nnamespace {\n\n// A predicate that checks the test name of a TestInfo against a known\n// value.\n//\n// This is used for implementation of the TestCase class only.  We put\n// it in the anonymous namespace to prevent polluting the outer\n// namespace.\n//\n// TestNameIs is copyable.\nclass TestNameIs {\n public:\n  // Constructor.\n  //\n  // TestNameIs has NO default constructor.\n  explicit TestNameIs(const char* name)\n      : name_(name) {}\n\n  // Returns true iff the test name of test_info matches name_.\n  bool operator()(const TestInfo * test_info) const {\n    return test_info && test_info->name() == name_;\n  }\n\n private:\n  std::string name_;\n};\n\n}  // namespace\n\nnamespace internal {\n\n// This method expands all parameterized tests registered with macros TEST_P\n// and INSTANTIATE_TEST_CASE_P into regular tests and registers those.\n// This will be done just once during the program runtime.\nvoid UnitTestImpl::RegisterParameterizedTests() {\n#if GTEST_HAS_PARAM_TEST\n  if (!parameterized_tests_registered_) {\n    parameterized_test_registry_.RegisterTests();\n    parameterized_tests_registered_ = true;\n  }\n#endif\n}\n\n}  // namespace internal\n\n// Creates the test object, runs it, records its result, and then\n// deletes it.\nvoid TestInfo::Run() {\n  if (!should_run_) return;\n\n  // Tells UnitTest where to store test result.\n  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();\n  impl->set_current_test_info(this);\n\n  TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();\n\n  // Notifies the unit test event listeners that a test is about to start.\n  repeater->OnTestStart(*this);\n\n  const TimeInMillis start = internal::GetTimeInMillis();\n\n  impl->os_stack_trace_getter()->UponLeavingGTest();\n\n  // Creates the test object.\n  Test* const test = internal::HandleExceptionsInMethodIfSupported(\n      factory_, &internal::TestFactoryBase::CreateTest,\n      \"the test fixture's constructor\");\n\n  // Runs the test only if the test object was created and its\n  // constructor didn't generate a fatal failure.\n  if ((test != NULL) && !Test::HasFatalFailure()) {\n    // This doesn't throw as all user code that can throw are wrapped into\n    // exception handling code.\n    test->Run();\n  }\n\n  // Deletes the test object.\n  impl->os_stack_trace_getter()->UponLeavingGTest();\n  internal::HandleExceptionsInMethodIfSupported(\n      test, &Test::DeleteSelf_, \"the test fixture's destructor\");\n\n  result_.set_elapsed_time(internal::GetTimeInMillis() - start);\n\n  // Notifies the unit test event listener that a test has just finished.\n  repeater->OnTestEnd(*this);\n\n  // Tells UnitTest to stop associating assertion results to this\n  // test.\n  impl->set_current_test_info(NULL);\n}\n\n// class TestCase\n\n// Gets the number of successful tests in this test case.\nint TestCase::successful_test_count() const {\n  return CountIf(test_info_list_, TestPassed);\n}\n\n// Gets the number of failed tests in this test case.\nint TestCase::failed_test_count() const {\n  return CountIf(test_info_list_, TestFailed);\n}\n\n// Gets the number of disabled tests that will be reported in the XML report.\nint TestCase::reportable_disabled_test_count() const {\n  return CountIf(test_info_list_, TestReportableDisabled);\n}\n\n// Gets the number of disabled tests in this test case.\nint TestCase::disabled_test_count() const {\n  return CountIf(test_info_list_, TestDisabled);\n}\n\n// Gets the number of tests to be printed in the XML report.\nint TestCase::reportable_test_count() const {\n  return CountIf(test_info_list_, TestReportable);\n}\n\n// Get the number of tests in this test case that should run.\nint TestCase::test_to_run_count() const {\n  return CountIf(test_info_list_, ShouldRunTest);\n}\n\n// Gets the number of all tests.\nint TestCase::total_test_count() const {\n  return static_cast<int>(test_info_list_.size());\n}\n\n// Creates a TestCase with the given name.\n//\n// Arguments:\n//\n//   name:         name of the test case\n//   a_type_param: the name of the test case's type parameter, or NULL if\n//                 this is not a typed or a type-parameterized test case.\n//   set_up_tc:    pointer to the function that sets up the test case\n//   tear_down_tc: pointer to the function that tears down the test case\nTestCase::TestCase(const char* a_name, const char* a_type_param,\n                   Test::SetUpTestCaseFunc set_up_tc,\n                   Test::TearDownTestCaseFunc tear_down_tc)\n    : name_(a_name),\n      type_param_(a_type_param ? new std::string(a_type_param) : NULL),\n      set_up_tc_(set_up_tc),\n      tear_down_tc_(tear_down_tc),\n      should_run_(false),\n      elapsed_time_(0) {\n}\n\n// Destructor of TestCase.\nTestCase::~TestCase() {\n  // Deletes every Test in the collection.\n  ForEach(test_info_list_, internal::Delete<TestInfo>);\n}\n\n// Returns the i-th test among all the tests. i can range from 0 to\n// total_test_count() - 1. If i is not in that range, returns NULL.\nconst TestInfo* TestCase::GetTestInfo(int i) const {\n  const int index = GetElementOr(test_indices_, i, -1);\n  return index < 0 ? NULL : test_info_list_[index];\n}\n\n// Returns the i-th test among all the tests. i can range from 0 to\n// total_test_count() - 1. If i is not in that range, returns NULL.\nTestInfo* TestCase::GetMutableTestInfo(int i) {\n  const int index = GetElementOr(test_indices_, i, -1);\n  return index < 0 ? NULL : test_info_list_[index];\n}\n\n// Adds a test to this test case.  Will delete the test upon\n// destruction of the TestCase object.\nvoid TestCase::AddTestInfo(TestInfo * test_info) {\n  test_info_list_.push_back(test_info);\n  test_indices_.push_back(static_cast<int>(test_indices_.size()));\n}\n\n// Runs every test in this TestCase.\nvoid TestCase::Run() {\n  if (!should_run_) return;\n\n  internal::UnitTestImpl* const impl = internal::GetUnitTestImpl();\n  impl->set_current_test_case(this);\n\n  TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater();\n\n  repeater->OnTestCaseStart(*this);\n  impl->os_stack_trace_getter()->UponLeavingGTest();\n  internal::HandleExceptionsInMethodIfSupported(\n      this, &TestCase::RunSetUpTestCase, \"SetUpTestCase()\");\n\n  const internal::TimeInMillis start = internal::GetTimeInMillis();\n  for (int i = 0; i < total_test_count(); i++) {\n    GetMutableTestInfo(i)->Run();\n  }\n  elapsed_time_ = internal::GetTimeInMillis() - start;\n\n  impl->os_stack_trace_getter()->UponLeavingGTest();\n  internal::HandleExceptionsInMethodIfSupported(\n      this, &TestCase::RunTearDownTestCase, \"TearDownTestCase()\");\n\n  repeater->OnTestCaseEnd(*this);\n  impl->set_current_test_case(NULL);\n}\n\n// Clears the results of all tests in this test case.\nvoid TestCase::ClearResult() {\n  ad_hoc_test_result_.Clear();\n  ForEach(test_info_list_, TestInfo::ClearTestResult);\n}\n\n// Shuffles the tests in this test case.\nvoid TestCase::ShuffleTests(internal::Random* random) {\n  Shuffle(random, &test_indices_);\n}\n\n// Restores the test order to before the first shuffle.\nvoid TestCase::UnshuffleTests() {\n  for (size_t i = 0; i < test_indices_.size(); i++) {\n    test_indices_[i] = static_cast<int>(i);\n  }\n}\n\n// Formats a countable noun.  Depending on its quantity, either the\n// singular form or the plural form is used. e.g.\n//\n// FormatCountableNoun(1, \"formula\", \"formuli\") returns \"1 formula\".\n// FormatCountableNoun(5, \"book\", \"books\") returns \"5 books\".\nstatic std::string FormatCountableNoun(int count,\n                                       const char * singular_form,\n                                       const char * plural_form) {\n  return internal::StreamableToString(count) + \" \" +\n      (count == 1 ? singular_form : plural_form);\n}\n\n// Formats the count of tests.\nstatic std::string FormatTestCount(int test_count) {\n  return FormatCountableNoun(test_count, \"test\", \"tests\");\n}\n\n// Formats the count of test cases.\nstatic std::string FormatTestCaseCount(int test_case_count) {\n  return FormatCountableNoun(test_case_count, \"test case\", \"test cases\");\n}\n\n// Converts a TestPartResult::Type enum to human-friendly string\n// representation.  Both kNonFatalFailure and kFatalFailure are translated\n// to \"Failure\", as the user usually doesn't care about the difference\n// between the two when viewing the test result.\nstatic const char * TestPartResultTypeToString(TestPartResult::Type type) {\n  switch (type) {\n    case TestPartResult::kSuccess:\n      return \"Success\";\n\n    case TestPartResult::kNonFatalFailure:\n    case TestPartResult::kFatalFailure:\n#ifdef _MSC_VER\n      return \"error: \";\n#else\n      return \"Failure\\n\";\n#endif\n    default:\n      return \"Unknown result type\";\n  }\n}\n\nnamespace internal {\n\n// Prints a TestPartResult to an std::string.\nstatic std::string PrintTestPartResultToString(\n    const TestPartResult& test_part_result) {\n  return (Message()\n          << internal::FormatFileLocation(test_part_result.file_name(),\n                                          test_part_result.line_number())\n          << \" \" << TestPartResultTypeToString(test_part_result.type())\n          << test_part_result.message()).GetString();\n}\n\n// Prints a TestPartResult.\nstatic void PrintTestPartResult(const TestPartResult& test_part_result) {\n  const std::string& result =\n      PrintTestPartResultToString(test_part_result);\n  printf(\"%s\\n\", result.c_str());\n  fflush(stdout);\n  // If the test program runs in Visual Studio or a debugger, the\n  // following statements add the test part result message to the Output\n  // window such that the user can double-click on it to jump to the\n  // corresponding source code location; otherwise they do nothing.\n#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE\n  // We don't call OutputDebugString*() on Windows Mobile, as printing\n  // to stdout is done by OutputDebugString() there already - we don't\n  // want the same message printed twice.\n  ::OutputDebugStringA(result.c_str());\n  ::OutputDebugStringA(\"\\n\");\n#endif\n}\n\n// class PrettyUnitTestResultPrinter\n\nenum GTestColor {\n  COLOR_DEFAULT,\n  COLOR_RED,\n  COLOR_GREEN,\n  COLOR_YELLOW\n};\n\n#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE\n\n// Returns the character attribute for the given color.\nWORD GetColorAttribute(GTestColor color) {\n  switch (color) {\n    case COLOR_RED:    return FOREGROUND_RED;\n    case COLOR_GREEN:  return FOREGROUND_GREEN;\n    case COLOR_YELLOW: return FOREGROUND_RED | FOREGROUND_GREEN;\n    default:           return 0;\n  }\n}\n\n#else\n\n// Returns the ANSI color code for the given color.  COLOR_DEFAULT is\n// an invalid input.\nconst char* GetAnsiColorCode(GTestColor color) {\n  switch (color) {\n    case COLOR_RED:     return \"1\";\n    case COLOR_GREEN:   return \"2\";\n    case COLOR_YELLOW:  return \"3\";\n    default:            return NULL;\n  };\n}\n\n#endif  // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE\n\n// Returns true iff Google Test should use colors in the output.\nbool ShouldUseColor(bool stdout_is_tty) {\n  const char* const gtest_color = GTEST_FLAG(color).c_str();\n\n  if (String::CaseInsensitiveCStringEquals(gtest_color, \"auto\")) {\n#if GTEST_OS_WINDOWS\n    // On Windows the TERM variable is usually not set, but the\n    // console there does support colors.\n    return stdout_is_tty;\n#else\n    // On non-Windows platforms, we rely on the TERM variable.\n    const char* const term = posix::GetEnv(\"TERM\");\n    const bool term_supports_color =\n        String::CStringEquals(term, \"xterm\") ||\n        String::CStringEquals(term, \"xterm-color\") ||\n        String::CStringEquals(term, \"xterm-256color\") ||\n        String::CStringEquals(term, \"screen\") ||\n        String::CStringEquals(term, \"screen-256color\") ||\n        String::CStringEquals(term, \"linux\") ||\n        String::CStringEquals(term, \"cygwin\");\n    return stdout_is_tty && term_supports_color;\n#endif  // GTEST_OS_WINDOWS\n  }\n\n  return String::CaseInsensitiveCStringEquals(gtest_color, \"yes\") ||\n      String::CaseInsensitiveCStringEquals(gtest_color, \"true\") ||\n      String::CaseInsensitiveCStringEquals(gtest_color, \"t\") ||\n      String::CStringEquals(gtest_color, \"1\");\n  // We take \"yes\", \"true\", \"t\", and \"1\" as meaning \"yes\".  If the\n  // value is neither one of these nor \"auto\", we treat it as \"no\" to\n  // be conservative.\n}\n\n// Helpers for printing colored strings to stdout. Note that on Windows, we\n// cannot simply emit special characters and have the terminal change colors.\n// This routine must actually emit the characters rather than return a string\n// that would be colored when printed, as can be done on Linux.\nvoid ColoredPrintf(GTestColor color, const char* fmt, ...) {\n  va_list args;\n  va_start(args, fmt);\n\n#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS || GTEST_OS_IOS\n  const bool use_color = false;\n#else\n  static const bool in_color_mode =\n      ShouldUseColor(posix::IsATTY(posix::FileNo(stdout)) != 0);\n  const bool use_color = in_color_mode && (color != COLOR_DEFAULT);\n#endif  // GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS\n  // The '!= 0' comparison is necessary to satisfy MSVC 7.1.\n\n  if (!use_color) {\n    vprintf(fmt, args);\n    va_end(args);\n    return;\n  }\n\n#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE\n  const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);\n\n  // Gets the current text color.\n  CONSOLE_SCREEN_BUFFER_INFO buffer_info;\n  GetConsoleScreenBufferInfo(stdout_handle, &buffer_info);\n  const WORD old_color_attrs = buffer_info.wAttributes;\n\n  // We need to flush the stream buffers into the console before each\n  // SetConsoleTextAttribute call lest it affect the text that is already\n  // printed but has not yet reached the console.\n  fflush(stdout);\n  SetConsoleTextAttribute(stdout_handle,\n                          GetColorAttribute(color) | FOREGROUND_INTENSITY);\n  vprintf(fmt, args);\n\n  fflush(stdout);\n  // Restores the text color.\n  SetConsoleTextAttribute(stdout_handle, old_color_attrs);\n#else\n  printf(\"\\033[0;3%sm\", GetAnsiColorCode(color));\n  vprintf(fmt, args);\n  printf(\"\\033[m\");  // Resets the terminal to default.\n#endif  // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE\n  va_end(args);\n}\n\n// Text printed in Google Test's text output and --gunit_list_tests\n// output to label the type parameter and value parameter for a test.\nstatic const char kTypeParamLabel[] = \"TypeParam\";\nstatic const char kValueParamLabel[] = \"GetParam()\";\n\nvoid PrintFullTestCommentIfPresent(const TestInfo& test_info) {\n  const char* const type_param = test_info.type_param();\n  const char* const value_param = test_info.value_param();\n\n  if (type_param != NULL || value_param != NULL) {\n    printf(\", where \");\n    if (type_param != NULL) {\n      printf(\"%s = %s\", kTypeParamLabel, type_param);\n      if (value_param != NULL)\n        printf(\" and \");\n    }\n    if (value_param != NULL) {\n      printf(\"%s = %s\", kValueParamLabel, value_param);\n    }\n  }\n}\n\n// This class implements the TestEventListener interface.\n//\n// Class PrettyUnitTestResultPrinter is copyable.\nclass PrettyUnitTestResultPrinter : public TestEventListener {\n public:\n  PrettyUnitTestResultPrinter() {}\n  static void PrintTestName(const char * test_case, const char * test) {\n    printf(\"%s.%s\", test_case, test);\n  }\n\n  // The following methods override what's in the TestEventListener class.\n  virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {}\n  virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration);\n  virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test);\n  virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {}\n  virtual void OnTestCaseStart(const TestCase& test_case);\n  virtual void OnTestStart(const TestInfo& test_info);\n  virtual void OnTestPartResult(const TestPartResult& result);\n  virtual void OnTestEnd(const TestInfo& test_info);\n  virtual void OnTestCaseEnd(const TestCase& test_case);\n  virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test);\n  virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {}\n  virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);\n  virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {}\n\n private:\n  static void PrintFailedTests(const UnitTest& unit_test);\n};\n\n  // Fired before each iteration of tests starts.\nvoid PrettyUnitTestResultPrinter::OnTestIterationStart(\n    const UnitTest& unit_test, int iteration) {\n  if (GTEST_FLAG(repeat) != 1)\n    printf(\"\\nRepeating all tests (iteration %d) . . .\\n\\n\", iteration + 1);\n\n  const char* const filter = GTEST_FLAG(filter).c_str();\n\n  // Prints the filter if it's not *.  This reminds the user that some\n  // tests may be skipped.\n  if (!String::CStringEquals(filter, kUniversalFilter)) {\n    ColoredPrintf(COLOR_YELLOW,\n                  \"Note: %s filter = %s\\n\", GTEST_NAME_, filter);\n  }\n\n  if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) {\n    const Int32 shard_index = Int32FromEnvOrDie(kTestShardIndex, -1);\n    ColoredPrintf(COLOR_YELLOW,\n                  \"Note: This is test shard %d of %s.\\n\",\n                  static_cast<int>(shard_index) + 1,\n                  internal::posix::GetEnv(kTestTotalShards));\n  }\n\n  if (GTEST_FLAG(shuffle)) {\n    ColoredPrintf(COLOR_YELLOW,\n                  \"Note: Randomizing tests' orders with a seed of %d .\\n\",\n                  unit_test.random_seed());\n  }\n\n  ColoredPrintf(COLOR_GREEN,  \"[==========] \");\n  printf(\"Running %s from %s.\\n\",\n         FormatTestCount(unit_test.test_to_run_count()).c_str(),\n         FormatTestCaseCount(unit_test.test_case_to_run_count()).c_str());\n  fflush(stdout);\n}\n\nvoid PrettyUnitTestResultPrinter::OnEnvironmentsSetUpStart(\n    const UnitTest& /*unit_test*/) {\n  ColoredPrintf(COLOR_GREEN,  \"[----------] \");\n  printf(\"Global test environment set-up.\\n\");\n  fflush(stdout);\n}\n\nvoid PrettyUnitTestResultPrinter::OnTestCaseStart(const TestCase& test_case) {\n  const std::string counts =\n      FormatCountableNoun(test_case.test_to_run_count(), \"test\", \"tests\");\n  ColoredPrintf(COLOR_GREEN, \"[----------] \");\n  printf(\"%s from %s\", counts.c_str(), test_case.name());\n  if (test_case.type_param() == NULL) {\n    printf(\"\\n\");\n  } else {\n    printf(\", where %s = %s\\n\", kTypeParamLabel, test_case.type_param());\n  }\n  fflush(stdout);\n}\n\nvoid PrettyUnitTestResultPrinter::OnTestStart(const TestInfo& test_info) {\n  ColoredPrintf(COLOR_GREEN,  \"[ RUN      ] \");\n  PrintTestName(test_info.test_case_name(), test_info.name());\n  printf(\"\\n\");\n  fflush(stdout);\n}\n\n// Called after an assertion failure.\nvoid PrettyUnitTestResultPrinter::OnTestPartResult(\n    const TestPartResult& result) {\n  // If the test part succeeded, we don't need to do anything.\n  if (result.type() == TestPartResult::kSuccess)\n    return;\n\n  // Print failure message from the assertion (e.g. expected this and got that).\n  PrintTestPartResult(result);\n  fflush(stdout);\n}\n\nvoid PrettyUnitTestResultPrinter::OnTestEnd(const TestInfo& test_info) {\n  if (test_info.result()->Passed()) {\n    ColoredPrintf(COLOR_GREEN, \"[       OK ] \");\n  } else {\n    ColoredPrintf(COLOR_RED, \"[  FAILED  ] \");\n  }\n  PrintTestName(test_info.test_case_name(), test_info.name());\n  if (test_info.result()->Failed())\n    PrintFullTestCommentIfPresent(test_info);\n\n  if (GTEST_FLAG(print_time)) {\n    printf(\" (%s ms)\\n\", internal::StreamableToString(\n           test_info.result()->elapsed_time()).c_str());\n  } else {\n    printf(\"\\n\");\n  }\n  fflush(stdout);\n}\n\nvoid PrettyUnitTestResultPrinter::OnTestCaseEnd(const TestCase& test_case) {\n  if (!GTEST_FLAG(print_time)) return;\n\n  const std::string counts =\n      FormatCountableNoun(test_case.test_to_run_count(), \"test\", \"tests\");\n  ColoredPrintf(COLOR_GREEN, \"[----------] \");\n  printf(\"%s from %s (%s ms total)\\n\\n\",\n         counts.c_str(), test_case.name(),\n         internal::StreamableToString(test_case.elapsed_time()).c_str());\n  fflush(stdout);\n}\n\nvoid PrettyUnitTestResultPrinter::OnEnvironmentsTearDownStart(\n    const UnitTest& /*unit_test*/) {\n  ColoredPrintf(COLOR_GREEN,  \"[----------] \");\n  printf(\"Global test environment tear-down\\n\");\n  fflush(stdout);\n}\n\n// Internal helper for printing the list of failed tests.\nvoid PrettyUnitTestResultPrinter::PrintFailedTests(const UnitTest& unit_test) {\n  const int failed_test_count = unit_test.failed_test_count();\n  if (failed_test_count == 0) {\n    return;\n  }\n\n  for (int i = 0; i < unit_test.total_test_case_count(); ++i) {\n    const TestCase& test_case = *unit_test.GetTestCase(i);\n    if (!test_case.should_run() || (test_case.failed_test_count() == 0)) {\n      continue;\n    }\n    for (int j = 0; j < test_case.total_test_count(); ++j) {\n      const TestInfo& test_info = *test_case.GetTestInfo(j);\n      if (!test_info.should_run() || test_info.result()->Passed()) {\n        continue;\n      }\n      ColoredPrintf(COLOR_RED, \"[  FAILED  ] \");\n      printf(\"%s.%s\", test_case.name(), test_info.name());\n      PrintFullTestCommentIfPresent(test_info);\n      printf(\"\\n\");\n    }\n  }\n}\n\nvoid PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,\n                                                     int /*iteration*/) {\n  ColoredPrintf(COLOR_GREEN,  \"[==========] \");\n  printf(\"%s from %s ran.\",\n         FormatTestCount(unit_test.test_to_run_count()).c_str(),\n         FormatTestCaseCount(unit_test.test_case_to_run_count()).c_str());\n  if (GTEST_FLAG(print_time)) {\n    printf(\" (%s ms total)\",\n           internal::StreamableToString(unit_test.elapsed_time()).c_str());\n  }\n  printf(\"\\n\");\n  ColoredPrintf(COLOR_GREEN,  \"[  PASSED  ] \");\n  printf(\"%s.\\n\", FormatTestCount(unit_test.successful_test_count()).c_str());\n\n  int num_failures = unit_test.failed_test_count();\n  if (!unit_test.Passed()) {\n    const int failed_test_count = unit_test.failed_test_count();\n    ColoredPrintf(COLOR_RED,  \"[  FAILED  ] \");\n    printf(\"%s, listed below:\\n\", FormatTestCount(failed_test_count).c_str());\n    PrintFailedTests(unit_test);\n    printf(\"\\n%2d FAILED %s\\n\", num_failures,\n                        num_failures == 1 ? \"TEST\" : \"TESTS\");\n  }\n\n  int num_disabled = unit_test.reportable_disabled_test_count();\n  if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) {\n    if (!num_failures) {\n      printf(\"\\n\");  // Add a spacer if no FAILURE banner is displayed.\n    }\n    ColoredPrintf(COLOR_YELLOW,\n                  \"  YOU HAVE %d DISABLED %s\\n\\n\",\n                  num_disabled,\n                  num_disabled == 1 ? \"TEST\" : \"TESTS\");\n  }\n  // Ensure that Google Test output is printed before, e.g., heapchecker output.\n  fflush(stdout);\n}\n\n// End PrettyUnitTestResultPrinter\n\n// class TestEventRepeater\n//\n// This class forwards events to other event listeners.\nclass TestEventRepeater : public TestEventListener {\n public:\n  TestEventRepeater() : forwarding_enabled_(true) {}\n  virtual ~TestEventRepeater();\n  void Append(TestEventListener *listener);\n  TestEventListener* Release(TestEventListener* listener);\n\n  // Controls whether events will be forwarded to listeners_. Set to false\n  // in death test child processes.\n  bool forwarding_enabled() const { return forwarding_enabled_; }\n  void set_forwarding_enabled(bool enable) { forwarding_enabled_ = enable; }\n\n  virtual void OnTestProgramStart(const UnitTest& unit_test);\n  virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration);\n  virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test);\n  virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test);\n  virtual void OnTestCaseStart(const TestCase& test_case);\n  virtual void OnTestStart(const TestInfo& test_info);\n  virtual void OnTestPartResult(const TestPartResult& result);\n  virtual void OnTestEnd(const TestInfo& test_info);\n  virtual void OnTestCaseEnd(const TestCase& test_case);\n  virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test);\n  virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test);\n  virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);\n  virtual void OnTestProgramEnd(const UnitTest& unit_test);\n\n private:\n  // Controls whether events will be forwarded to listeners_. Set to false\n  // in death test child processes.\n  bool forwarding_enabled_;\n  // The list of listeners that receive events.\n  std::vector<TestEventListener*> listeners_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventRepeater);\n};\n\nTestEventRepeater::~TestEventRepeater() {\n  ForEach(listeners_, Delete<TestEventListener>);\n}\n\nvoid TestEventRepeater::Append(TestEventListener *listener) {\n  listeners_.push_back(listener);\n}\n\n// TODO(vladl@google.com): Factor the search functionality into Vector::Find.\nTestEventListener* TestEventRepeater::Release(TestEventListener *listener) {\n  for (size_t i = 0; i < listeners_.size(); ++i) {\n    if (listeners_[i] == listener) {\n      listeners_.erase(listeners_.begin() + i);\n      return listener;\n    }\n  }\n\n  return NULL;\n}\n\n// Since most methods are very similar, use macros to reduce boilerplate.\n// This defines a member that forwards the call to all listeners.\n#define GTEST_REPEATER_METHOD_(Name, Type) \\\nvoid TestEventRepeater::Name(const Type& parameter) { \\\n  if (forwarding_enabled_) { \\\n    for (size_t i = 0; i < listeners_.size(); i++) { \\\n      listeners_[i]->Name(parameter); \\\n    } \\\n  } \\\n}\n// This defines a member that forwards the call to all listeners in reverse\n// order.\n#define GTEST_REVERSE_REPEATER_METHOD_(Name, Type) \\\nvoid TestEventRepeater::Name(const Type& parameter) { \\\n  if (forwarding_enabled_) { \\\n    for (int i = static_cast<int>(listeners_.size()) - 1; i >= 0; i--) { \\\n      listeners_[i]->Name(parameter); \\\n    } \\\n  } \\\n}\n\nGTEST_REPEATER_METHOD_(OnTestProgramStart, UnitTest)\nGTEST_REPEATER_METHOD_(OnEnvironmentsSetUpStart, UnitTest)\nGTEST_REPEATER_METHOD_(OnTestCaseStart, TestCase)\nGTEST_REPEATER_METHOD_(OnTestStart, TestInfo)\nGTEST_REPEATER_METHOD_(OnTestPartResult, TestPartResult)\nGTEST_REPEATER_METHOD_(OnEnvironmentsTearDownStart, UnitTest)\nGTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsSetUpEnd, UnitTest)\nGTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsTearDownEnd, UnitTest)\nGTEST_REVERSE_REPEATER_METHOD_(OnTestEnd, TestInfo)\nGTEST_REVERSE_REPEATER_METHOD_(OnTestCaseEnd, TestCase)\nGTEST_REVERSE_REPEATER_METHOD_(OnTestProgramEnd, UnitTest)\n\n#undef GTEST_REPEATER_METHOD_\n#undef GTEST_REVERSE_REPEATER_METHOD_\n\nvoid TestEventRepeater::OnTestIterationStart(const UnitTest& unit_test,\n                                             int iteration) {\n  if (forwarding_enabled_) {\n    for (size_t i = 0; i < listeners_.size(); i++) {\n      listeners_[i]->OnTestIterationStart(unit_test, iteration);\n    }\n  }\n}\n\nvoid TestEventRepeater::OnTestIterationEnd(const UnitTest& unit_test,\n                                           int iteration) {\n  if (forwarding_enabled_) {\n    for (int i = static_cast<int>(listeners_.size()) - 1; i >= 0; i--) {\n      listeners_[i]->OnTestIterationEnd(unit_test, iteration);\n    }\n  }\n}\n\n// End TestEventRepeater\n\n// This class generates an XML output file.\nclass XmlUnitTestResultPrinter : public EmptyTestEventListener {\n public:\n  explicit XmlUnitTestResultPrinter(const char* output_file);\n\n  virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration);\n\n private:\n  // Is c a whitespace character that is normalized to a space character\n  // when it appears in an XML attribute value?\n  static bool IsNormalizableWhitespace(char c) {\n    return c == 0x9 || c == 0xA || c == 0xD;\n  }\n\n  // May c appear in a well-formed XML document?\n  static bool IsValidXmlCharacter(char c) {\n    return IsNormalizableWhitespace(c) || c >= 0x20;\n  }\n\n  // Returns an XML-escaped copy of the input string str.  If\n  // is_attribute is true, the text is meant to appear as an attribute\n  // value, and normalizable whitespace is preserved by replacing it\n  // with character references.\n  static std::string EscapeXml(const std::string& str, bool is_attribute);\n\n  // Returns the given string with all characters invalid in XML removed.\n  static std::string RemoveInvalidXmlCharacters(const std::string& str);\n\n  // Convenience wrapper around EscapeXml when str is an attribute value.\n  static std::string EscapeXmlAttribute(const std::string& str) {\n    return EscapeXml(str, true);\n  }\n\n  // Convenience wrapper around EscapeXml when str is not an attribute value.\n  static std::string EscapeXmlText(const char* str) {\n    return EscapeXml(str, false);\n  }\n\n  // Verifies that the given attribute belongs to the given element and\n  // streams the attribute as XML.\n  static void OutputXmlAttribute(std::ostream* stream,\n                                 const std::string& element_name,\n                                 const std::string& name,\n                                 const std::string& value);\n\n  // Streams an XML CDATA section, escaping invalid CDATA sequences as needed.\n  static void OutputXmlCDataSection(::std::ostream* stream, const char* data);\n\n  // Streams an XML representation of a TestInfo object.\n  static void OutputXmlTestInfo(::std::ostream* stream,\n                                const char* test_case_name,\n                                const TestInfo& test_info);\n\n  // Prints an XML representation of a TestCase object\n  static void PrintXmlTestCase(::std::ostream* stream,\n                               const TestCase& test_case);\n\n  // Prints an XML summary of unit_test to output stream out.\n  static void PrintXmlUnitTest(::std::ostream* stream,\n                               const UnitTest& unit_test);\n\n  // Produces a string representing the test properties in a result as space\n  // delimited XML attributes based on the property key=\"value\" pairs.\n  // When the std::string is not empty, it includes a space at the beginning,\n  // to delimit this attribute from prior attributes.\n  static std::string TestPropertiesAsXmlAttributes(const TestResult& result);\n\n  // The output file.\n  const std::string output_file_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(XmlUnitTestResultPrinter);\n};\n\n// Creates a new XmlUnitTestResultPrinter.\nXmlUnitTestResultPrinter::XmlUnitTestResultPrinter(const char* output_file)\n    : output_file_(output_file) {\n  if (output_file_.c_str() == NULL || output_file_.empty()) {\n    fprintf(stderr, \"XML output file may not be null\\n\");\n    fflush(stderr);\n    exit(EXIT_FAILURE);\n  }\n}\n\n// Called after the unit test ends.\nvoid XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test,\n                                                  int /*iteration*/) {\n  FILE* xmlout = NULL;\n  FilePath output_file(output_file_);\n  FilePath output_dir(output_file.RemoveFileName());\n\n  if (output_dir.CreateDirectoriesRecursively()) {\n    xmlout = posix::FOpen(output_file_.c_str(), \"w\");\n  }\n  if (xmlout == NULL) {\n    // TODO(wan): report the reason of the failure.\n    //\n    // We don't do it for now as:\n    //\n    //   1. There is no urgent need for it.\n    //   2. It's a bit involved to make the errno variable thread-safe on\n    //      all three operating systems (Linux, Windows, and Mac OS).\n    //   3. To interpret the meaning of errno in a thread-safe way,\n    //      we need the strerror_r() function, which is not available on\n    //      Windows.\n    fprintf(stderr,\n            \"Unable to open file \\\"%s\\\"\\n\",\n            output_file_.c_str());\n    fflush(stderr);\n    exit(EXIT_FAILURE);\n  }\n  std::stringstream stream;\n  PrintXmlUnitTest(&stream, unit_test);\n  fprintf(xmlout, \"%s\", StringStreamToString(&stream).c_str());\n  fclose(xmlout);\n}\n\n// Returns an XML-escaped copy of the input string str.  If is_attribute\n// is true, the text is meant to appear as an attribute value, and\n// normalizable whitespace is preserved by replacing it with character\n// references.\n//\n// Invalid XML characters in str, if any, are stripped from the output.\n// It is expected that most, if not all, of the text processed by this\n// module will consist of ordinary English text.\n// If this module is ever modified to produce version 1.1 XML output,\n// most invalid characters can be retained using character references.\n// TODO(wan): It might be nice to have a minimally invasive, human-readable\n// escaping scheme for invalid characters, rather than dropping them.\nstd::string XmlUnitTestResultPrinter::EscapeXml(\n    const std::string& str, bool is_attribute) {\n  Message m;\n\n  for (size_t i = 0; i < str.size(); ++i) {\n    const char ch = str[i];\n    switch (ch) {\n      case '<':\n        m << \"&lt;\";\n        break;\n      case '>':\n        m << \"&gt;\";\n        break;\n      case '&':\n        m << \"&amp;\";\n        break;\n      case '\\'':\n        if (is_attribute)\n          m << \"&apos;\";\n        else\n          m << '\\'';\n        break;\n      case '\"':\n        if (is_attribute)\n          m << \"&quot;\";\n        else\n          m << '\"';\n        break;\n      default:\n        if (IsValidXmlCharacter(ch)) {\n          if (is_attribute && IsNormalizableWhitespace(ch))\n            m << \"&#x\" << String::FormatByte(static_cast<unsigned char>(ch))\n              << \";\";\n          else\n            m << ch;\n        }\n        break;\n    }\n  }\n\n  return m.GetString();\n}\n\n// Returns the given string with all characters invalid in XML removed.\n// Currently invalid characters are dropped from the string. An\n// alternative is to replace them with certain characters such as . or ?.\nstd::string XmlUnitTestResultPrinter::RemoveInvalidXmlCharacters(\n    const std::string& str) {\n  std::string output;\n  output.reserve(str.size());\n  for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)\n    if (IsValidXmlCharacter(*it))\n      output.push_back(*it);\n\n  return output;\n}\n\n// The following routines generate an XML representation of a UnitTest\n// object.\n//\n// This is how Google Test concepts map to the DTD:\n//\n// <testsuites name=\"AllTests\">        <-- corresponds to a UnitTest object\n//   <testsuite name=\"testcase-name\">  <-- corresponds to a TestCase object\n//     <testcase name=\"test-name\">     <-- corresponds to a TestInfo object\n//       <failure message=\"...\">...</failure>\n//       <failure message=\"...\">...</failure>\n//       <failure message=\"...\">...</failure>\n//                                     <-- individual assertion failures\n//     </testcase>\n//   </testsuite>\n// </testsuites>\n\n// Formats the given time in milliseconds as seconds.\nstd::string FormatTimeInMillisAsSeconds(TimeInMillis ms) {\n  ::std::stringstream ss;\n  ss << ms/1000.0;\n  return ss.str();\n}\n\n// Converts the given epoch time in milliseconds to a date string in the ISO\n// 8601 format, without the timezone information.\nstd::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms) {\n  // Using non-reentrant version as localtime_r is not portable.\n  time_t seconds = static_cast<time_t>(ms / 1000);\n#ifdef _MSC_VER\n# pragma warning(push)          // Saves the current warning state.\n# pragma warning(disable:4996)  // Temporarily disables warning 4996\n                                // (function or variable may be unsafe).\n  const struct tm* const time_struct = localtime(&seconds);  // NOLINT\n# pragma warning(pop)           // Restores the warning state again.\n#else\n  const struct tm* const time_struct = localtime(&seconds);  // NOLINT\n#endif\n  if (time_struct == NULL)\n    return \"\";  // Invalid ms value\n\n  // YYYY-MM-DDThh:mm:ss\n  return StreamableToString(time_struct->tm_year + 1900) + \"-\" +\n      String::FormatIntWidth2(time_struct->tm_mon + 1) + \"-\" +\n      String::FormatIntWidth2(time_struct->tm_mday) + \"T\" +\n      String::FormatIntWidth2(time_struct->tm_hour) + \":\" +\n      String::FormatIntWidth2(time_struct->tm_min) + \":\" +\n      String::FormatIntWidth2(time_struct->tm_sec);\n}\n\n// Streams an XML CDATA section, escaping invalid CDATA sequences as needed.\nvoid XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream,\n                                                     const char* data) {\n  const char* segment = data;\n  *stream << \"<![CDATA[\";\n  for (;;) {\n    const char* const next_segment = strstr(segment, \"]]>\");\n    if (next_segment != NULL) {\n      stream->write(\n          segment, static_cast<std::streamsize>(next_segment - segment));\n      *stream << \"]]>]]&gt;<![CDATA[\";\n      segment = next_segment + strlen(\"]]>\");\n    } else {\n      *stream << segment;\n      break;\n    }\n  }\n  *stream << \"]]>\";\n}\n\nvoid XmlUnitTestResultPrinter::OutputXmlAttribute(\n    std::ostream* stream,\n    const std::string& element_name,\n    const std::string& name,\n    const std::string& value) {\n  const std::vector<std::string>& allowed_names =\n      GetReservedAttributesForElement(element_name);\n\n  GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) !=\n                   allowed_names.end())\n      << \"Attribute \" << name << \" is not allowed for element <\" << element_name\n      << \">.\";\n\n  *stream << \" \" << name << \"=\\\"\" << EscapeXmlAttribute(value) << \"\\\"\";\n}\n\n// Prints an XML representation of a TestInfo object.\n// TODO(wan): There is also value in printing properties with the plain printer.\nvoid XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream,\n                                                 const char* test_case_name,\n                                                 const TestInfo& test_info) {\n  const TestResult& result = *test_info.result();\n  const std::string kTestcase = \"testcase\";\n\n  *stream << \"    <testcase\";\n  OutputXmlAttribute(stream, kTestcase, \"name\", test_info.name());\n\n  if (test_info.value_param() != NULL) {\n    OutputXmlAttribute(stream, kTestcase, \"value_param\",\n                       test_info.value_param());\n  }\n  if (test_info.type_param() != NULL) {\n    OutputXmlAttribute(stream, kTestcase, \"type_param\", test_info.type_param());\n  }\n\n  OutputXmlAttribute(stream, kTestcase, \"status\",\n                     test_info.should_run() ? \"run\" : \"notrun\");\n  OutputXmlAttribute(stream, kTestcase, \"time\",\n                     FormatTimeInMillisAsSeconds(result.elapsed_time()));\n  OutputXmlAttribute(stream, kTestcase, \"classname\", test_case_name);\n  *stream << TestPropertiesAsXmlAttributes(result);\n\n  int failures = 0;\n  for (int i = 0; i < result.total_part_count(); ++i) {\n    const TestPartResult& part = result.GetTestPartResult(i);\n    if (part.failed()) {\n      if (++failures == 1) {\n        *stream << \">\\n\";\n      }\n      const string location = internal::FormatCompilerIndependentFileLocation(\n          part.file_name(), part.line_number());\n      const string summary = location + \"\\n\" + part.summary();\n      *stream << \"      <failure message=\\\"\"\n              << EscapeXmlAttribute(summary.c_str())\n              << \"\\\" type=\\\"\\\">\";\n      const string detail = location + \"\\n\" + part.message();\n      OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str());\n      *stream << \"</failure>\\n\";\n    }\n  }\n\n  if (failures == 0)\n    *stream << \" />\\n\";\n  else\n    *stream << \"    </testcase>\\n\";\n}\n\n// Prints an XML representation of a TestCase object\nvoid XmlUnitTestResultPrinter::PrintXmlTestCase(std::ostream* stream,\n                                                const TestCase& test_case) {\n  const std::string kTestsuite = \"testsuite\";\n  *stream << \"  <\" << kTestsuite;\n  OutputXmlAttribute(stream, kTestsuite, \"name\", test_case.name());\n  OutputXmlAttribute(stream, kTestsuite, \"tests\",\n                     StreamableToString(test_case.reportable_test_count()));\n  OutputXmlAttribute(stream, kTestsuite, \"failures\",\n                     StreamableToString(test_case.failed_test_count()));\n  OutputXmlAttribute(\n      stream, kTestsuite, \"disabled\",\n      StreamableToString(test_case.reportable_disabled_test_count()));\n  OutputXmlAttribute(stream, kTestsuite, \"errors\", \"0\");\n  OutputXmlAttribute(stream, kTestsuite, \"time\",\n                     FormatTimeInMillisAsSeconds(test_case.elapsed_time()));\n  *stream << TestPropertiesAsXmlAttributes(test_case.ad_hoc_test_result())\n          << \">\\n\";\n\n  for (int i = 0; i < test_case.total_test_count(); ++i) {\n    if (test_case.GetTestInfo(i)->is_reportable())\n      OutputXmlTestInfo(stream, test_case.name(), *test_case.GetTestInfo(i));\n  }\n  *stream << \"  </\" << kTestsuite << \">\\n\";\n}\n\n// Prints an XML summary of unit_test to output stream out.\nvoid XmlUnitTestResultPrinter::PrintXmlUnitTest(std::ostream* stream,\n                                                const UnitTest& unit_test) {\n  const std::string kTestsuites = \"testsuites\";\n\n  *stream << \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\";\n  *stream << \"<\" << kTestsuites;\n\n  OutputXmlAttribute(stream, kTestsuites, \"tests\",\n                     StreamableToString(unit_test.reportable_test_count()));\n  OutputXmlAttribute(stream, kTestsuites, \"failures\",\n                     StreamableToString(unit_test.failed_test_count()));\n  OutputXmlAttribute(\n      stream, kTestsuites, \"disabled\",\n      StreamableToString(unit_test.reportable_disabled_test_count()));\n  OutputXmlAttribute(stream, kTestsuites, \"errors\", \"0\");\n  OutputXmlAttribute(\n      stream, kTestsuites, \"timestamp\",\n      FormatEpochTimeInMillisAsIso8601(unit_test.start_timestamp()));\n  OutputXmlAttribute(stream, kTestsuites, \"time\",\n                     FormatTimeInMillisAsSeconds(unit_test.elapsed_time()));\n\n  if (GTEST_FLAG(shuffle)) {\n    OutputXmlAttribute(stream, kTestsuites, \"random_seed\",\n                       StreamableToString(unit_test.random_seed()));\n  }\n\n  *stream << TestPropertiesAsXmlAttributes(unit_test.ad_hoc_test_result());\n\n  OutputXmlAttribute(stream, kTestsuites, \"name\", \"AllTests\");\n  *stream << \">\\n\";\n\n  for (int i = 0; i < unit_test.total_test_case_count(); ++i) {\n    if (unit_test.GetTestCase(i)->reportable_test_count() > 0)\n      PrintXmlTestCase(stream, *unit_test.GetTestCase(i));\n  }\n  *stream << \"</\" << kTestsuites << \">\\n\";\n}\n\n// Produces a string representing the test properties in a result as space\n// delimited XML attributes based on the property key=\"value\" pairs.\nstd::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes(\n    const TestResult& result) {\n  Message attributes;\n  for (int i = 0; i < result.test_property_count(); ++i) {\n    const TestProperty& property = result.GetTestProperty(i);\n    attributes << \" \" << property.key() << \"=\"\n        << \"\\\"\" << EscapeXmlAttribute(property.value()) << \"\\\"\";\n  }\n  return attributes.GetString();\n}\n\n// End XmlUnitTestResultPrinter\n\n#if GTEST_CAN_STREAM_RESULTS_\n\n// Checks if str contains '=', '&', '%' or '\\n' characters. If yes,\n// replaces them by \"%xx\" where xx is their hexadecimal value. For\n// example, replaces \"=\" with \"%3D\".  This algorithm is O(strlen(str))\n// in both time and space -- important as the input str may contain an\n// arbitrarily long test failure message and stack trace.\nstring StreamingListener::UrlEncode(const char* str) {\n  string result;\n  result.reserve(strlen(str) + 1);\n  for (char ch = *str; ch != '\\0'; ch = *++str) {\n    switch (ch) {\n      case '%':\n      case '=':\n      case '&':\n      case '\\n':\n        result.append(\"%\" + String::FormatByte(static_cast<unsigned char>(ch)));\n        break;\n      default:\n        result.push_back(ch);\n        break;\n    }\n  }\n  return result;\n}\n\nvoid StreamingListener::SocketWriter::MakeConnection() {\n  GTEST_CHECK_(sockfd_ == -1)\n      << \"MakeConnection() can't be called when there is already a connection.\";\n\n  addrinfo hints;\n  memset(&hints, 0, sizeof(hints));\n  hints.ai_family = AF_UNSPEC;    // To allow both IPv4 and IPv6 addresses.\n  hints.ai_socktype = SOCK_STREAM;\n  addrinfo* servinfo = NULL;\n\n  // Use the getaddrinfo() to get a linked list of IP addresses for\n  // the given host name.\n  const int error_num = getaddrinfo(\n      host_name_.c_str(), port_num_.c_str(), &hints, &servinfo);\n  if (error_num != 0) {\n    GTEST_LOG_(WARNING) << \"stream_result_to: getaddrinfo() failed: \"\n                        << gai_strerror(error_num);\n  }\n\n  // Loop through all the results and connect to the first we can.\n  for (addrinfo* cur_addr = servinfo; sockfd_ == -1 && cur_addr != NULL;\n       cur_addr = cur_addr->ai_next) {\n    sockfd_ = socket(\n        cur_addr->ai_family, cur_addr->ai_socktype, cur_addr->ai_protocol);\n    if (sockfd_ != -1) {\n      // Connect the client socket to the server socket.\n      if (connect(sockfd_, cur_addr->ai_addr, cur_addr->ai_addrlen) == -1) {\n        close(sockfd_);\n        sockfd_ = -1;\n      }\n    }\n  }\n\n  freeaddrinfo(servinfo);  // all done with this structure\n\n  if (sockfd_ == -1) {\n    GTEST_LOG_(WARNING) << \"stream_result_to: failed to connect to \"\n                        << host_name_ << \":\" << port_num_;\n  }\n}\n\n// End of class Streaming Listener\n#endif  // GTEST_CAN_STREAM_RESULTS__\n\n// Class ScopedTrace\n\n// Pushes the given source file location and message onto a per-thread\n// trace stack maintained by Google Test.\nScopedTrace::ScopedTrace(const char* file, int line, const Message& message)\n    GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) {\n  TraceInfo trace;\n  trace.file = file;\n  trace.line = line;\n  trace.message = message.GetString();\n\n  UnitTest::GetInstance()->PushGTestTrace(trace);\n}\n\n// Pops the info pushed by the c'tor.\nScopedTrace::~ScopedTrace()\n    GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) {\n  UnitTest::GetInstance()->PopGTestTrace();\n}\n\n\n// class OsStackTraceGetter\n\n// Returns the current OS stack trace as an std::string.  Parameters:\n//\n//   max_depth  - the maximum number of stack frames to be included\n//                in the trace.\n//   skip_count - the number of top frames to be skipped; doesn't count\n//                against max_depth.\n//\nstring OsStackTraceGetter::CurrentStackTrace(int /* max_depth */,\n                                             int /* skip_count */)\n    GTEST_LOCK_EXCLUDED_(mutex_) {\n  return \"\";\n}\n\nvoid OsStackTraceGetter::UponLeavingGTest()\n    GTEST_LOCK_EXCLUDED_(mutex_) {\n}\n\nconst char* const\nOsStackTraceGetter::kElidedFramesMarker =\n    \"... \" GTEST_NAME_ \" internal frames ...\";\n\n// A helper class that creates the premature-exit file in its\n// constructor and deletes the file in its destructor.\nclass ScopedPrematureExitFile {\n public:\n  explicit ScopedPrematureExitFile(const char* premature_exit_filepath)\n      : premature_exit_filepath_(premature_exit_filepath) {\n    // If a path to the premature-exit file is specified...\n    if (premature_exit_filepath != NULL && *premature_exit_filepath != '\\0') {\n      // create the file with a single \"0\" character in it.  I/O\n      // errors are ignored as there's nothing better we can do and we\n      // don't want to fail the test because of this.\n      FILE* pfile = posix::FOpen(premature_exit_filepath, \"w\");\n      fwrite(\"0\", 1, 1, pfile);\n      fclose(pfile);\n    }\n  }\n\n  ~ScopedPrematureExitFile() {\n    if (premature_exit_filepath_ != NULL && *premature_exit_filepath_ != '\\0') {\n      remove(premature_exit_filepath_);\n    }\n  }\n\n private:\n  const char* const premature_exit_filepath_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedPrematureExitFile);\n};\n\n}  // namespace internal\n\n// class TestEventListeners\n\nTestEventListeners::TestEventListeners()\n    : repeater_(new internal::TestEventRepeater()),\n      default_result_printer_(NULL),\n      default_xml_generator_(NULL) {\n}\n\nTestEventListeners::~TestEventListeners() { delete repeater_; }\n\n// Returns the standard listener responsible for the default console\n// output.  Can be removed from the listeners list to shut down default\n// console output.  Note that removing this object from the listener list\n// with Release transfers its ownership to the user.\nvoid TestEventListeners::Append(TestEventListener* listener) {\n  repeater_->Append(listener);\n}\n\n// Removes the given event listener from the list and returns it.  It then\n// becomes the caller's responsibility to delete the listener. Returns\n// NULL if the listener is not found in the list.\nTestEventListener* TestEventListeners::Release(TestEventListener* listener) {\n  if (listener == default_result_printer_)\n    default_result_printer_ = NULL;\n  else if (listener == default_xml_generator_)\n    default_xml_generator_ = NULL;\n  return repeater_->Release(listener);\n}\n\n// Returns repeater that broadcasts the TestEventListener events to all\n// subscribers.\nTestEventListener* TestEventListeners::repeater() { return repeater_; }\n\n// Sets the default_result_printer attribute to the provided listener.\n// The listener is also added to the listener list and previous\n// default_result_printer is removed from it and deleted. The listener can\n// also be NULL in which case it will not be added to the list. Does\n// nothing if the previous and the current listener objects are the same.\nvoid TestEventListeners::SetDefaultResultPrinter(TestEventListener* listener) {\n  if (default_result_printer_ != listener) {\n    // It is an error to pass this method a listener that is already in the\n    // list.\n    delete Release(default_result_printer_);\n    default_result_printer_ = listener;\n    if (listener != NULL)\n      Append(listener);\n  }\n}\n\n// Sets the default_xml_generator attribute to the provided listener.  The\n// listener is also added to the listener list and previous\n// default_xml_generator is removed from it and deleted. The listener can\n// also be NULL in which case it will not be added to the list. Does\n// nothing if the previous and the current listener objects are the same.\nvoid TestEventListeners::SetDefaultXmlGenerator(TestEventListener* listener) {\n  if (default_xml_generator_ != listener) {\n    // It is an error to pass this method a listener that is already in the\n    // list.\n    delete Release(default_xml_generator_);\n    default_xml_generator_ = listener;\n    if (listener != NULL)\n      Append(listener);\n  }\n}\n\n// Controls whether events will be forwarded by the repeater to the\n// listeners in the list.\nbool TestEventListeners::EventForwardingEnabled() const {\n  return repeater_->forwarding_enabled();\n}\n\nvoid TestEventListeners::SuppressEventForwarding() {\n  repeater_->set_forwarding_enabled(false);\n}\n\n// class UnitTest\n\n// Gets the singleton UnitTest object.  The first time this method is\n// called, a UnitTest object is constructed and returned.  Consecutive\n// calls will return the same object.\n//\n// We don't protect this under mutex_ as a user is not supposed to\n// call this before main() starts, from which point on the return\n// value will never change.\nUnitTest* UnitTest::GetInstance() {\n  // When compiled with MSVC 7.1 in optimized mode, destroying the\n  // UnitTest object upon exiting the program messes up the exit code,\n  // causing successful tests to appear failed.  We have to use a\n  // different implementation in this case to bypass the compiler bug.\n  // This implementation makes the compiler happy, at the cost of\n  // leaking the UnitTest object.\n\n  // CodeGear C++Builder insists on a public destructor for the\n  // default implementation.  Use this implementation to keep good OO\n  // design with private destructor.\n\n#if (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)\n  static UnitTest* const instance = new UnitTest;\n  return instance;\n#else\n  static UnitTest instance;\n  return &instance;\n#endif  // (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__)\n}\n\n// Gets the number of successful test cases.\nint UnitTest::successful_test_case_count() const {\n  return impl()->successful_test_case_count();\n}\n\n// Gets the number of failed test cases.\nint UnitTest::failed_test_case_count() const {\n  return impl()->failed_test_case_count();\n}\n\n// Gets the number of all test cases.\nint UnitTest::total_test_case_count() const {\n  return impl()->total_test_case_count();\n}\n\n// Gets the number of all test cases that contain at least one test\n// that should run.\nint UnitTest::test_case_to_run_count() const {\n  return impl()->test_case_to_run_count();\n}\n\n// Gets the number of successful tests.\nint UnitTest::successful_test_count() const {\n  return impl()->successful_test_count();\n}\n\n// Gets the number of failed tests.\nint UnitTest::failed_test_count() const { return impl()->failed_test_count(); }\n\n// Gets the number of disabled tests that will be reported in the XML report.\nint UnitTest::reportable_disabled_test_count() const {\n  return impl()->reportable_disabled_test_count();\n}\n\n// Gets the number of disabled tests.\nint UnitTest::disabled_test_count() const {\n  return impl()->disabled_test_count();\n}\n\n// Gets the number of tests to be printed in the XML report.\nint UnitTest::reportable_test_count() const {\n  return impl()->reportable_test_count();\n}\n\n// Gets the number of all tests.\nint UnitTest::total_test_count() const { return impl()->total_test_count(); }\n\n// Gets the number of tests that should run.\nint UnitTest::test_to_run_count() const { return impl()->test_to_run_count(); }\n\n// Gets the time of the test program start, in ms from the start of the\n// UNIX epoch.\ninternal::TimeInMillis UnitTest::start_timestamp() const {\n    return impl()->start_timestamp();\n}\n\n// Gets the elapsed time, in milliseconds.\ninternal::TimeInMillis UnitTest::elapsed_time() const {\n  return impl()->elapsed_time();\n}\n\n// Returns true iff the unit test passed (i.e. all test cases passed).\nbool UnitTest::Passed() const { return impl()->Passed(); }\n\n// Returns true iff the unit test failed (i.e. some test case failed\n// or something outside of all tests failed).\nbool UnitTest::Failed() const { return impl()->Failed(); }\n\n// Gets the i-th test case among all the test cases. i can range from 0 to\n// total_test_case_count() - 1. If i is not in that range, returns NULL.\nconst TestCase* UnitTest::GetTestCase(int i) const {\n  return impl()->GetTestCase(i);\n}\n\n// Returns the TestResult containing information on test failures and\n// properties logged outside of individual test cases.\nconst TestResult& UnitTest::ad_hoc_test_result() const {\n  return *impl()->ad_hoc_test_result();\n}\n\n// Gets the i-th test case among all the test cases. i can range from 0 to\n// total_test_case_count() - 1. If i is not in that range, returns NULL.\nTestCase* UnitTest::GetMutableTestCase(int i) {\n  return impl()->GetMutableTestCase(i);\n}\n\n// Returns the list of event listeners that can be used to track events\n// inside Google Test.\nTestEventListeners& UnitTest::listeners() {\n  return *impl()->listeners();\n}\n\n// Registers and returns a global test environment.  When a test\n// program is run, all global test environments will be set-up in the\n// order they were registered.  After all tests in the program have\n// finished, all global test environments will be torn-down in the\n// *reverse* order they were registered.\n//\n// The UnitTest object takes ownership of the given environment.\n//\n// We don't protect this under mutex_, as we only support calling it\n// from the main thread.\nEnvironment* UnitTest::AddEnvironment(Environment* env) {\n  if (env == NULL) {\n    return NULL;\n  }\n\n  impl_->environments().push_back(env);\n  return env;\n}\n\n// Adds a TestPartResult to the current TestResult object.  All Google Test\n// assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc) eventually call\n// this to report their results.  The user code should use the\n// assertion macros instead of calling this directly.\nvoid UnitTest::AddTestPartResult(\n    TestPartResult::Type result_type,\n    const char* file_name,\n    int line_number,\n    const std::string& message,\n    const std::string& os_stack_trace) GTEST_LOCK_EXCLUDED_(mutex_) {\n  Message msg;\n  msg << message;\n\n  internal::MutexLock lock(&mutex_);\n  if (impl_->gtest_trace_stack().size() > 0) {\n    msg << \"\\n\" << GTEST_NAME_ << \" trace:\";\n\n    for (int i = static_cast<int>(impl_->gtest_trace_stack().size());\n         i > 0; --i) {\n      const internal::TraceInfo& trace = impl_->gtest_trace_stack()[i - 1];\n      msg << \"\\n\" << internal::FormatFileLocation(trace.file, trace.line)\n          << \" \" << trace.message;\n    }\n  }\n\n  if (os_stack_trace.c_str() != NULL && !os_stack_trace.empty()) {\n    msg << internal::kStackTraceMarker << os_stack_trace;\n  }\n\n  const TestPartResult result =\n    TestPartResult(result_type, file_name, line_number,\n                   msg.GetString().c_str());\n  impl_->GetTestPartResultReporterForCurrentThread()->\n      ReportTestPartResult(result);\n\n  if (result_type != TestPartResult::kSuccess) {\n    // gtest_break_on_failure takes precedence over\n    // gtest_throw_on_failure.  This allows a user to set the latter\n    // in the code (perhaps in order to use Google Test assertions\n    // with another testing framework) and specify the former on the\n    // command line for debugging.\n    if (GTEST_FLAG(break_on_failure)) {\n#if GTEST_OS_WINDOWS\n      // Using DebugBreak on Windows allows gtest to still break into a debugger\n      // when a failure happens and both the --gtest_break_on_failure and\n      // the --gtest_catch_exceptions flags are specified.\n      DebugBreak();\n#else\n      // Dereference NULL through a volatile pointer to prevent the compiler\n      // from removing. We use this rather than abort() or __builtin_trap() for\n      // portability: Symbian doesn't implement abort() well, and some debuggers\n      // don't correctly trap abort().\n      *static_cast<volatile int*>(NULL) = 1;\n#endif  // GTEST_OS_WINDOWS\n    } else if (GTEST_FLAG(throw_on_failure)) {\n#if GTEST_HAS_EXCEPTIONS\n      throw internal::GoogleTestFailureException(result);\n#else\n      // We cannot call abort() as it generates a pop-up in debug mode\n      // that cannot be suppressed in VC 7.1 or below.\n      exit(1);\n#endif\n    }\n  }\n}\n\n// Adds a TestProperty to the current TestResult object when invoked from\n// inside a test, to current TestCase's ad_hoc_test_result_ when invoked\n// from SetUpTestCase or TearDownTestCase, or to the global property set\n// when invoked elsewhere.  If the result already contains a property with\n// the same key, the value will be updated.\nvoid UnitTest::RecordProperty(const std::string& key,\n                              const std::string& value) {\n  impl_->RecordProperty(TestProperty(key, value));\n}\n\n// Runs all tests in this UnitTest object and prints the result.\n// Returns 0 if successful, or 1 otherwise.\n//\n// We don't protect this under mutex_, as we only support calling it\n// from the main thread.\nint UnitTest::Run() {\n  const bool in_death_test_child_process =\n      internal::GTEST_FLAG(internal_run_death_test).length() > 0;\n\n  // Google Test implements this protocol for catching that a test\n  // program exits before returning control to Google Test:\n  //\n  //   1. Upon start, Google Test creates a file whose absolute path\n  //      is specified by the environment variable\n  //      TEST_PREMATURE_EXIT_FILE.\n  //   2. When Google Test has finished its work, it deletes the file.\n  //\n  // This allows a test runner to set TEST_PREMATURE_EXIT_FILE before\n  // running a Google-Test-based test program and check the existence\n  // of the file at the end of the test execution to see if it has\n  // exited prematurely.\n\n  // If we are in the child process of a death test, don't\n  // create/delete the premature exit file, as doing so is unnecessary\n  // and will confuse the parent process.  Otherwise, create/delete\n  // the file upon entering/leaving this function.  If the program\n  // somehow exits before this function has a chance to return, the\n  // premature-exit file will be left undeleted, causing a test runner\n  // that understands the premature-exit-file protocol to report the\n  // test as having failed.\n  const internal::ScopedPrematureExitFile premature_exit_file(\n      in_death_test_child_process ?\n      NULL : internal::posix::GetEnv(\"TEST_PREMATURE_EXIT_FILE\"));\n\n  // Captures the value of GTEST_FLAG(catch_exceptions).  This value will be\n  // used for the duration of the program.\n  impl()->set_catch_exceptions(GTEST_FLAG(catch_exceptions));\n\n#if GTEST_HAS_SEH\n  // Either the user wants Google Test to catch exceptions thrown by the\n  // tests or this is executing in the context of death test child\n  // process. In either case the user does not want to see pop-up dialogs\n  // about crashes - they are expected.\n  if (impl()->catch_exceptions() || in_death_test_child_process) {\n# if !GTEST_OS_WINDOWS_MOBILE\n    // SetErrorMode doesn't exist on CE.\n    SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT |\n                 SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);\n# endif  // !GTEST_OS_WINDOWS_MOBILE\n\n# if (defined(_MSC_VER) || GTEST_OS_WINDOWS_MINGW) && !GTEST_OS_WINDOWS_MOBILE\n    // Death test children can be terminated with _abort().  On Windows,\n    // _abort() can show a dialog with a warning message.  This forces the\n    // abort message to go to stderr instead.\n    _set_error_mode(_OUT_TO_STDERR);\n# endif\n\n# if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE\n    // In the debug version, Visual Studio pops up a separate dialog\n    // offering a choice to debug the aborted program. We need to suppress\n    // this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement\n    // executed. Google Test will notify the user of any unexpected\n    // failure via stderr.\n    //\n    // VC++ doesn't define _set_abort_behavior() prior to the version 8.0.\n    // Users of prior VC versions shall suffer the agony and pain of\n    // clicking through the countless debug dialogs.\n    // TODO(vladl@google.com): find a way to suppress the abort dialog() in the\n    // debug mode when compiled with VC 7.1 or lower.\n    if (!GTEST_FLAG(break_on_failure))\n      _set_abort_behavior(\n          0x0,                                    // Clear the following flags:\n          _WRITE_ABORT_MSG | _CALL_REPORTFAULT);  // pop-up window, core dump.\n# endif\n  }\n#endif  // GTEST_HAS_SEH\n\n  return internal::HandleExceptionsInMethodIfSupported(\n      impl(),\n      &internal::UnitTestImpl::RunAllTests,\n      \"auxiliary test code (environments or event listeners)\") ? 0 : 1;\n}\n\n// Returns the working directory when the first TEST() or TEST_F() was\n// executed.\nconst char* UnitTest::original_working_dir() const {\n  return impl_->original_working_dir_.c_str();\n}\n\n// Returns the TestCase object for the test that's currently running,\n// or NULL if no test is running.\nconst TestCase* UnitTest::current_test_case() const\n    GTEST_LOCK_EXCLUDED_(mutex_) {\n  internal::MutexLock lock(&mutex_);\n  return impl_->current_test_case();\n}\n\n// Returns the TestInfo object for the test that's currently running,\n// or NULL if no test is running.\nconst TestInfo* UnitTest::current_test_info() const\n    GTEST_LOCK_EXCLUDED_(mutex_) {\n  internal::MutexLock lock(&mutex_);\n  return impl_->current_test_info();\n}\n\n// Returns the random seed used at the start of the current test run.\nint UnitTest::random_seed() const { return impl_->random_seed(); }\n\n#if GTEST_HAS_PARAM_TEST\n// Returns ParameterizedTestCaseRegistry object used to keep track of\n// value-parameterized tests and instantiate and register them.\ninternal::ParameterizedTestCaseRegistry&\n    UnitTest::parameterized_test_registry()\n        GTEST_LOCK_EXCLUDED_(mutex_) {\n  return impl_->parameterized_test_registry();\n}\n#endif  // GTEST_HAS_PARAM_TEST\n\n// Creates an empty UnitTest.\nUnitTest::UnitTest() {\n  impl_ = new internal::UnitTestImpl(this);\n}\n\n// Destructor of UnitTest.\nUnitTest::~UnitTest() {\n  delete impl_;\n}\n\n// Pushes a trace defined by SCOPED_TRACE() on to the per-thread\n// Google Test trace stack.\nvoid UnitTest::PushGTestTrace(const internal::TraceInfo& trace)\n    GTEST_LOCK_EXCLUDED_(mutex_) {\n  internal::MutexLock lock(&mutex_);\n  impl_->gtest_trace_stack().push_back(trace);\n}\n\n// Pops a trace from the per-thread Google Test trace stack.\nvoid UnitTest::PopGTestTrace()\n    GTEST_LOCK_EXCLUDED_(mutex_) {\n  internal::MutexLock lock(&mutex_);\n  impl_->gtest_trace_stack().pop_back();\n}\n\nnamespace internal {\n\nUnitTestImpl::UnitTestImpl(UnitTest* parent)\n    : parent_(parent),\n#ifdef _MSC_VER\n# pragma warning(push)                    // Saves the current warning state.\n# pragma warning(disable:4355)            // Temporarily disables warning 4355\n                                         // (using this in initializer).\n      default_global_test_part_result_reporter_(this),\n      default_per_thread_test_part_result_reporter_(this),\n# pragma warning(pop)                     // Restores the warning state again.\n#else\n      default_global_test_part_result_reporter_(this),\n      default_per_thread_test_part_result_reporter_(this),\n#endif  // _MSC_VER\n      global_test_part_result_repoter_(\n          &default_global_test_part_result_reporter_),\n      per_thread_test_part_result_reporter_(\n          &default_per_thread_test_part_result_reporter_),\n#if GTEST_HAS_PARAM_TEST\n      parameterized_test_registry_(),\n      parameterized_tests_registered_(false),\n#endif  // GTEST_HAS_PARAM_TEST\n      last_death_test_case_(-1),\n      current_test_case_(NULL),\n      current_test_info_(NULL),\n      ad_hoc_test_result_(),\n      os_stack_trace_getter_(NULL),\n      post_flag_parse_init_performed_(false),\n      random_seed_(0),  // Will be overridden by the flag before first use.\n      random_(0),  // Will be reseeded before first use.\n      start_timestamp_(0),\n      elapsed_time_(0),\n#if GTEST_HAS_DEATH_TEST\n      death_test_factory_(new DefaultDeathTestFactory),\n#endif\n      // Will be overridden by the flag before first use.\n      catch_exceptions_(false) {\n  listeners()->SetDefaultResultPrinter(new PrettyUnitTestResultPrinter);\n}\n\nUnitTestImpl::~UnitTestImpl() {\n  // Deletes every TestCase.\n  ForEach(test_cases_, internal::Delete<TestCase>);\n\n  // Deletes every Environment.\n  ForEach(environments_, internal::Delete<Environment>);\n\n  delete os_stack_trace_getter_;\n}\n\n// Adds a TestProperty to the current TestResult object when invoked in a\n// context of a test, to current test case's ad_hoc_test_result when invoke\n// from SetUpTestCase/TearDownTestCase, or to the global property set\n// otherwise.  If the result already contains a property with the same key,\n// the value will be updated.\nvoid UnitTestImpl::RecordProperty(const TestProperty& test_property) {\n  std::string xml_element;\n  TestResult* test_result;  // TestResult appropriate for property recording.\n\n  if (current_test_info_ != NULL) {\n    xml_element = \"testcase\";\n    test_result = &(current_test_info_->result_);\n  } else if (current_test_case_ != NULL) {\n    xml_element = \"testsuite\";\n    test_result = &(current_test_case_->ad_hoc_test_result_);\n  } else {\n    xml_element = \"testsuites\";\n    test_result = &ad_hoc_test_result_;\n  }\n  test_result->RecordProperty(xml_element, test_property);\n}\n\n#if GTEST_HAS_DEATH_TEST\n// Disables event forwarding if the control is currently in a death test\n// subprocess. Must not be called before InitGoogleTest.\nvoid UnitTestImpl::SuppressTestEventsIfInSubprocess() {\n  if (internal_run_death_test_flag_.get() != NULL)\n    listeners()->SuppressEventForwarding();\n}\n#endif  // GTEST_HAS_DEATH_TEST\n\n// Initializes event listeners performing XML output as specified by\n// UnitTestOptions. Must not be called before InitGoogleTest.\nvoid UnitTestImpl::ConfigureXmlOutput() {\n  const std::string& output_format = UnitTestOptions::GetOutputFormat();\n  if (output_format == \"xml\") {\n    listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter(\n        UnitTestOptions::GetAbsolutePathToOutputFile().c_str()));\n  } else if (output_format != \"\") {\n    printf(\"WARNING: unrecognized output format \\\"%s\\\" ignored.\\n\",\n           output_format.c_str());\n    fflush(stdout);\n  }\n}\n\n#if GTEST_CAN_STREAM_RESULTS_\n// Initializes event listeners for streaming test results in string form.\n// Must not be called before InitGoogleTest.\nvoid UnitTestImpl::ConfigureStreamingOutput() {\n  const std::string& target = GTEST_FLAG(stream_result_to);\n  if (!target.empty()) {\n    const size_t pos = target.find(':');\n    if (pos != std::string::npos) {\n      listeners()->Append(new StreamingListener(target.substr(0, pos),\n                                                target.substr(pos+1)));\n    } else {\n      printf(\"WARNING: unrecognized streaming target \\\"%s\\\" ignored.\\n\",\n             target.c_str());\n      fflush(stdout);\n    }\n  }\n}\n#endif  // GTEST_CAN_STREAM_RESULTS_\n\n// Performs initialization dependent upon flag values obtained in\n// ParseGoogleTestFlagsOnly.  Is called from InitGoogleTest after the call to\n// ParseGoogleTestFlagsOnly.  In case a user neglects to call InitGoogleTest\n// this function is also called from RunAllTests.  Since this function can be\n// called more than once, it has to be idempotent.\nvoid UnitTestImpl::PostFlagParsingInit() {\n  // Ensures that this function does not execute more than once.\n  if (!post_flag_parse_init_performed_) {\n    post_flag_parse_init_performed_ = true;\n\n#if GTEST_HAS_DEATH_TEST\n    InitDeathTestSubprocessControlInfo();\n    SuppressTestEventsIfInSubprocess();\n#endif  // GTEST_HAS_DEATH_TEST\n\n    // Registers parameterized tests. This makes parameterized tests\n    // available to the UnitTest reflection API without running\n    // RUN_ALL_TESTS.\n    RegisterParameterizedTests();\n\n    // Configures listeners for XML output. This makes it possible for users\n    // to shut down the default XML output before invoking RUN_ALL_TESTS.\n    ConfigureXmlOutput();\n\n#if GTEST_CAN_STREAM_RESULTS_\n    // Configures listeners for streaming test results to the specified server.\n    ConfigureStreamingOutput();\n#endif  // GTEST_CAN_STREAM_RESULTS_\n  }\n}\n\n// A predicate that checks the name of a TestCase against a known\n// value.\n//\n// This is used for implementation of the UnitTest class only.  We put\n// it in the anonymous namespace to prevent polluting the outer\n// namespace.\n//\n// TestCaseNameIs is copyable.\nclass TestCaseNameIs {\n public:\n  // Constructor.\n  explicit TestCaseNameIs(const std::string& name)\n      : name_(name) {}\n\n  // Returns true iff the name of test_case matches name_.\n  bool operator()(const TestCase* test_case) const {\n    return test_case != NULL && strcmp(test_case->name(), name_.c_str()) == 0;\n  }\n\n private:\n  std::string name_;\n};\n\n// Finds and returns a TestCase with the given name.  If one doesn't\n// exist, creates one and returns it.  It's the CALLER'S\n// RESPONSIBILITY to ensure that this function is only called WHEN THE\n// TESTS ARE NOT SHUFFLED.\n//\n// Arguments:\n//\n//   test_case_name: name of the test case\n//   type_param:     the name of the test case's type parameter, or NULL if\n//                   this is not a typed or a type-parameterized test case.\n//   set_up_tc:      pointer to the function that sets up the test case\n//   tear_down_tc:   pointer to the function that tears down the test case\nTestCase* UnitTestImpl::GetTestCase(const char* test_case_name,\n                                    const char* type_param,\n                                    Test::SetUpTestCaseFunc set_up_tc,\n                                    Test::TearDownTestCaseFunc tear_down_tc) {\n  // Can we find a TestCase with the given name?\n  const std::vector<TestCase*>::const_iterator test_case =\n      std::find_if(test_cases_.begin(), test_cases_.end(),\n                   TestCaseNameIs(test_case_name));\n\n  if (test_case != test_cases_.end())\n    return *test_case;\n\n  // No.  Let's create one.\n  TestCase* const new_test_case =\n      new TestCase(test_case_name, type_param, set_up_tc, tear_down_tc);\n\n  // Is this a death test case?\n  if (internal::UnitTestOptions::MatchesFilter(test_case_name,\n                                               kDeathTestCaseFilter)) {\n    // Yes.  Inserts the test case after the last death test case\n    // defined so far.  This only works when the test cases haven't\n    // been shuffled.  Otherwise we may end up running a death test\n    // after a non-death test.\n    ++last_death_test_case_;\n    test_cases_.insert(test_cases_.begin() + last_death_test_case_,\n                       new_test_case);\n  } else {\n    // No.  Appends to the end of the list.\n    test_cases_.push_back(new_test_case);\n  }\n\n  test_case_indices_.push_back(static_cast<int>(test_case_indices_.size()));\n  return new_test_case;\n}\n\n// Helpers for setting up / tearing down the given environment.  They\n// are for use in the ForEach() function.\nstatic void SetUpEnvironment(Environment* env) { env->SetUp(); }\nstatic void TearDownEnvironment(Environment* env) { env->TearDown(); }\n\n// Runs all tests in this UnitTest object, prints the result, and\n// returns true if all tests are successful.  If any exception is\n// thrown during a test, the test is considered to be failed, but the\n// rest of the tests will still be run.\n//\n// When parameterized tests are enabled, it expands and registers\n// parameterized tests first in RegisterParameterizedTests().\n// All other functions called from RunAllTests() may safely assume that\n// parameterized tests are ready to be counted and run.\nbool UnitTestImpl::RunAllTests() {\n  // Makes sure InitGoogleTest() was called.\n  if (!GTestIsInitialized()) {\n    printf(\"%s\",\n           \"\\nThis test program did NOT call ::testing::InitGoogleTest \"\n           \"before calling RUN_ALL_TESTS().  Please fix it.\\n\");\n    return false;\n  }\n\n  // Do not run any test if the --help flag was specified.\n  if (g_help_flag)\n    return true;\n\n  // Repeats the call to the post-flag parsing initialization in case the\n  // user didn't call InitGoogleTest.\n  PostFlagParsingInit();\n\n  // Even if sharding is not on, test runners may want to use the\n  // GTEST_SHARD_STATUS_FILE to query whether the test supports the sharding\n  // protocol.\n  internal::WriteToShardStatusFileIfNeeded();\n\n  // True iff we are in a subprocess for running a thread-safe-style\n  // death test.\n  bool in_subprocess_for_death_test = false;\n\n#if GTEST_HAS_DEATH_TEST\n  in_subprocess_for_death_test = (internal_run_death_test_flag_.get() != NULL);\n#endif  // GTEST_HAS_DEATH_TEST\n\n  const bool should_shard = ShouldShard(kTestTotalShards, kTestShardIndex,\n                                        in_subprocess_for_death_test);\n\n  // Compares the full test names with the filter to decide which\n  // tests to run.\n  const bool has_tests_to_run = FilterTests(should_shard\n                                              ? HONOR_SHARDING_PROTOCOL\n                                              : IGNORE_SHARDING_PROTOCOL) > 0;\n\n  // Lists the tests and exits if the --gtest_list_tests flag was specified.\n  if (GTEST_FLAG(list_tests)) {\n    // This must be called *after* FilterTests() has been called.\n    ListTestsMatchingFilter();\n    return true;\n  }\n\n  random_seed_ = GTEST_FLAG(shuffle) ?\n      GetRandomSeedFromFlag(GTEST_FLAG(random_seed)) : 0;\n\n  // True iff at least one test has failed.\n  bool failed = false;\n\n  TestEventListener* repeater = listeners()->repeater();\n\n  start_timestamp_ = GetTimeInMillis();\n  repeater->OnTestProgramStart(*parent_);\n\n  // How many times to repeat the tests?  We don't want to repeat them\n  // when we are inside the subprocess of a death test.\n  const int repeat = in_subprocess_for_death_test ? 1 : GTEST_FLAG(repeat);\n  // Repeats forever if the repeat count is negative.\n  const bool forever = repeat < 0;\n  for (int i = 0; forever || i != repeat; i++) {\n    // We want to preserve failures generated by ad-hoc test\n    // assertions executed before RUN_ALL_TESTS().\n    ClearNonAdHocTestResult();\n\n    const TimeInMillis start = GetTimeInMillis();\n\n    // Shuffles test cases and tests if requested.\n    if (has_tests_to_run && GTEST_FLAG(shuffle)) {\n      random()->Reseed(random_seed_);\n      // This should be done before calling OnTestIterationStart(),\n      // such that a test event listener can see the actual test order\n      // in the event.\n      ShuffleTests();\n    }\n\n    // Tells the unit test event listeners that the tests are about to start.\n    repeater->OnTestIterationStart(*parent_, i);\n\n    // Runs each test case if there is at least one test to run.\n    if (has_tests_to_run) {\n      // Sets up all environments beforehand.\n      repeater->OnEnvironmentsSetUpStart(*parent_);\n      ForEach(environments_, SetUpEnvironment);\n      repeater->OnEnvironmentsSetUpEnd(*parent_);\n\n      // Runs the tests only if there was no fatal failure during global\n      // set-up.\n      if (!Test::HasFatalFailure()) {\n        for (int test_index = 0; test_index < total_test_case_count();\n             test_index++) {\n          GetMutableTestCase(test_index)->Run();\n        }\n      }\n\n      // Tears down all environments in reverse order afterwards.\n      repeater->OnEnvironmentsTearDownStart(*parent_);\n      std::for_each(environments_.rbegin(), environments_.rend(),\n                    TearDownEnvironment);\n      repeater->OnEnvironmentsTearDownEnd(*parent_);\n    }\n\n    elapsed_time_ = GetTimeInMillis() - start;\n\n    // Tells the unit test event listener that the tests have just finished.\n    repeater->OnTestIterationEnd(*parent_, i);\n\n    // Gets the result and clears it.\n    if (!Passed()) {\n      failed = true;\n    }\n\n    // Restores the original test order after the iteration.  This\n    // allows the user to quickly repro a failure that happens in the\n    // N-th iteration without repeating the first (N - 1) iterations.\n    // This is not enclosed in \"if (GTEST_FLAG(shuffle)) { ... }\", in\n    // case the user somehow changes the value of the flag somewhere\n    // (it's always safe to unshuffle the tests).\n    UnshuffleTests();\n\n    if (GTEST_FLAG(shuffle)) {\n      // Picks a new random seed for each iteration.\n      random_seed_ = GetNextRandomSeed(random_seed_);\n    }\n  }\n\n  repeater->OnTestProgramEnd(*parent_);\n\n  return !failed;\n}\n\n// Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file\n// if the variable is present. If a file already exists at this location, this\n// function will write over it. If the variable is present, but the file cannot\n// be created, prints an error and exits.\nvoid WriteToShardStatusFileIfNeeded() {\n  const char* const test_shard_file = posix::GetEnv(kTestShardStatusFile);\n  if (test_shard_file != NULL) {\n    FILE* const file = posix::FOpen(test_shard_file, \"w\");\n    if (file == NULL) {\n      ColoredPrintf(COLOR_RED,\n                    \"Could not write to the test shard status file \\\"%s\\\" \"\n                    \"specified by the %s environment variable.\\n\",\n                    test_shard_file, kTestShardStatusFile);\n      fflush(stdout);\n      exit(EXIT_FAILURE);\n    }\n    fclose(file);\n  }\n}\n\n// Checks whether sharding is enabled by examining the relevant\n// environment variable values. If the variables are present,\n// but inconsistent (i.e., shard_index >= total_shards), prints\n// an error and exits. If in_subprocess_for_death_test, sharding is\n// disabled because it must only be applied to the original test\n// process. Otherwise, we could filter out death tests we intended to execute.\nbool ShouldShard(const char* total_shards_env,\n                 const char* shard_index_env,\n                 bool in_subprocess_for_death_test) {\n  if (in_subprocess_for_death_test) {\n    return false;\n  }\n\n  const Int32 total_shards = Int32FromEnvOrDie(total_shards_env, -1);\n  const Int32 shard_index = Int32FromEnvOrDie(shard_index_env, -1);\n\n  if (total_shards == -1 && shard_index == -1) {\n    return false;\n  } else if (total_shards == -1 && shard_index != -1) {\n    const Message msg = Message()\n      << \"Invalid environment variables: you have \"\n      << kTestShardIndex << \" = \" << shard_index\n      << \", but have left \" << kTestTotalShards << \" unset.\\n\";\n    ColoredPrintf(COLOR_RED, msg.GetString().c_str());\n    fflush(stdout);\n    exit(EXIT_FAILURE);\n  } else if (total_shards != -1 && shard_index == -1) {\n    const Message msg = Message()\n      << \"Invalid environment variables: you have \"\n      << kTestTotalShards << \" = \" << total_shards\n      << \", but have left \" << kTestShardIndex << \" unset.\\n\";\n    ColoredPrintf(COLOR_RED, msg.GetString().c_str());\n    fflush(stdout);\n    exit(EXIT_FAILURE);\n  } else if (shard_index < 0 || shard_index >= total_shards) {\n    const Message msg = Message()\n      << \"Invalid environment variables: we require 0 <= \"\n      << kTestShardIndex << \" < \" << kTestTotalShards\n      << \", but you have \" << kTestShardIndex << \"=\" << shard_index\n      << \", \" << kTestTotalShards << \"=\" << total_shards << \".\\n\";\n    ColoredPrintf(COLOR_RED, msg.GetString().c_str());\n    fflush(stdout);\n    exit(EXIT_FAILURE);\n  }\n\n  return total_shards > 1;\n}\n\n// Parses the environment variable var as an Int32. If it is unset,\n// returns default_val. If it is not an Int32, prints an error\n// and aborts.\nInt32 Int32FromEnvOrDie(const char* var, Int32 default_val) {\n  const char* str_val = posix::GetEnv(var);\n  if (str_val == NULL) {\n    return default_val;\n  }\n\n  Int32 result;\n  if (!ParseInt32(Message() << \"The value of environment variable \" << var,\n                  str_val, &result)) {\n    exit(EXIT_FAILURE);\n  }\n  return result;\n}\n\n// Given the total number of shards, the shard index, and the test id,\n// returns true iff the test should be run on this shard. The test id is\n// some arbitrary but unique non-negative integer assigned to each test\n// method. Assumes that 0 <= shard_index < total_shards.\nbool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id) {\n  return (test_id % total_shards) == shard_index;\n}\n\n// Compares the name of each test with the user-specified filter to\n// decide whether the test should be run, then records the result in\n// each TestCase and TestInfo object.\n// If shard_tests == true, further filters tests based on sharding\n// variables in the environment - see\n// http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide.\n// Returns the number of tests that should run.\nint UnitTestImpl::FilterTests(ReactionToSharding shard_tests) {\n  const Int32 total_shards = shard_tests == HONOR_SHARDING_PROTOCOL ?\n      Int32FromEnvOrDie(kTestTotalShards, -1) : -1;\n  const Int32 shard_index = shard_tests == HONOR_SHARDING_PROTOCOL ?\n      Int32FromEnvOrDie(kTestShardIndex, -1) : -1;\n\n  // num_runnable_tests are the number of tests that will\n  // run across all shards (i.e., match filter and are not disabled).\n  // num_selected_tests are the number of tests to be run on\n  // this shard.\n  int num_runnable_tests = 0;\n  int num_selected_tests = 0;\n  for (size_t i = 0; i < test_cases_.size(); i++) {\n    TestCase* const test_case = test_cases_[i];\n    const std::string &test_case_name = test_case->name();\n    test_case->set_should_run(false);\n\n    for (size_t j = 0; j < test_case->test_info_list().size(); j++) {\n      TestInfo* const test_info = test_case->test_info_list()[j];\n      const std::string test_name(test_info->name());\n      // A test is disabled if test case name or test name matches\n      // kDisableTestFilter.\n      const bool is_disabled =\n          internal::UnitTestOptions::MatchesFilter(test_case_name,\n                                                   kDisableTestFilter) ||\n          internal::UnitTestOptions::MatchesFilter(test_name,\n                                                   kDisableTestFilter);\n      test_info->is_disabled_ = is_disabled;\n\n      const bool matches_filter =\n          internal::UnitTestOptions::FilterMatchesTest(test_case_name,\n                                                       test_name);\n      test_info->matches_filter_ = matches_filter;\n\n      const bool is_runnable =\n          (GTEST_FLAG(also_run_disabled_tests) || !is_disabled) &&\n          matches_filter;\n\n      const bool is_selected = is_runnable &&\n          (shard_tests == IGNORE_SHARDING_PROTOCOL ||\n           ShouldRunTestOnShard(total_shards, shard_index,\n                                num_runnable_tests));\n\n      num_runnable_tests += is_runnable;\n      num_selected_tests += is_selected;\n\n      test_info->should_run_ = is_selected;\n      test_case->set_should_run(test_case->should_run() || is_selected);\n    }\n  }\n  return num_selected_tests;\n}\n\n// Prints the given C-string on a single line by replacing all '\\n'\n// characters with string \"\\\\n\".  If the output takes more than\n// max_length characters, only prints the first max_length characters\n// and \"...\".\nstatic void PrintOnOneLine(const char* str, int max_length) {\n  if (str != NULL) {\n    for (int i = 0; *str != '\\0'; ++str) {\n      if (i >= max_length) {\n        printf(\"...\");\n        break;\n      }\n      if (*str == '\\n') {\n        printf(\"\\\\n\");\n        i += 2;\n      } else {\n        printf(\"%c\", *str);\n        ++i;\n      }\n    }\n  }\n}\n\n// Prints the names of the tests matching the user-specified filter flag.\nvoid UnitTestImpl::ListTestsMatchingFilter() {\n  // Print at most this many characters for each type/value parameter.\n  const int kMaxParamLength = 250;\n\n  for (size_t i = 0; i < test_cases_.size(); i++) {\n    const TestCase* const test_case = test_cases_[i];\n    bool printed_test_case_name = false;\n\n    for (size_t j = 0; j < test_case->test_info_list().size(); j++) {\n      const TestInfo* const test_info =\n          test_case->test_info_list()[j];\n      if (test_info->matches_filter_) {\n        if (!printed_test_case_name) {\n          printed_test_case_name = true;\n          printf(\"%s.\", test_case->name());\n          if (test_case->type_param() != NULL) {\n            printf(\"  # %s = \", kTypeParamLabel);\n            // We print the type parameter on a single line to make\n            // the output easy to parse by a program.\n            PrintOnOneLine(test_case->type_param(), kMaxParamLength);\n          }\n          printf(\"\\n\");\n        }\n        printf(\"  %s\", test_info->name());\n        if (test_info->value_param() != NULL) {\n          printf(\"  # %s = \", kValueParamLabel);\n          // We print the value parameter on a single line to make the\n          // output easy to parse by a program.\n          PrintOnOneLine(test_info->value_param(), kMaxParamLength);\n        }\n        printf(\"\\n\");\n      }\n    }\n  }\n  fflush(stdout);\n}\n\n// Sets the OS stack trace getter.\n//\n// Does nothing if the input and the current OS stack trace getter are\n// the same; otherwise, deletes the old getter and makes the input the\n// current getter.\nvoid UnitTestImpl::set_os_stack_trace_getter(\n    OsStackTraceGetterInterface* getter) {\n  if (os_stack_trace_getter_ != getter) {\n    delete os_stack_trace_getter_;\n    os_stack_trace_getter_ = getter;\n  }\n}\n\n// Returns the current OS stack trace getter if it is not NULL;\n// otherwise, creates an OsStackTraceGetter, makes it the current\n// getter, and returns it.\nOsStackTraceGetterInterface* UnitTestImpl::os_stack_trace_getter() {\n  if (os_stack_trace_getter_ == NULL) {\n    os_stack_trace_getter_ = new OsStackTraceGetter;\n  }\n\n  return os_stack_trace_getter_;\n}\n\n// Returns the TestResult for the test that's currently running, or\n// the TestResult for the ad hoc test if no test is running.\nTestResult* UnitTestImpl::current_test_result() {\n  return current_test_info_ ?\n      &(current_test_info_->result_) : &ad_hoc_test_result_;\n}\n\n// Shuffles all test cases, and the tests within each test case,\n// making sure that death tests are still run first.\nvoid UnitTestImpl::ShuffleTests() {\n  // Shuffles the death test cases.\n  ShuffleRange(random(), 0, last_death_test_case_ + 1, &test_case_indices_);\n\n  // Shuffles the non-death test cases.\n  ShuffleRange(random(), last_death_test_case_ + 1,\n               static_cast<int>(test_cases_.size()), &test_case_indices_);\n\n  // Shuffles the tests inside each test case.\n  for (size_t i = 0; i < test_cases_.size(); i++) {\n    test_cases_[i]->ShuffleTests(random());\n  }\n}\n\n// Restores the test cases and tests to their order before the first shuffle.\nvoid UnitTestImpl::UnshuffleTests() {\n  for (size_t i = 0; i < test_cases_.size(); i++) {\n    // Unshuffles the tests in each test case.\n    test_cases_[i]->UnshuffleTests();\n    // Resets the index of each test case.\n    test_case_indices_[i] = static_cast<int>(i);\n  }\n}\n\n// Returns the current OS stack trace as an std::string.\n//\n// The maximum number of stack frames to be included is specified by\n// the gtest_stack_trace_depth flag.  The skip_count parameter\n// specifies the number of top frames to be skipped, which doesn't\n// count against the number of frames to be included.\n//\n// For example, if Foo() calls Bar(), which in turn calls\n// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in\n// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't.\nstd::string GetCurrentOsStackTraceExceptTop(UnitTest* /*unit_test*/,\n                                            int skip_count) {\n  // We pass skip_count + 1 to skip this wrapper function in addition\n  // to what the user really wants to skip.\n  return GetUnitTestImpl()->CurrentOsStackTraceExceptTop(skip_count + 1);\n}\n\n// Used by the GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_ macro to\n// suppress unreachable code warnings.\nnamespace {\nclass ClassUniqueToAlwaysTrue {};\n}\n\nbool IsTrue(bool condition) { return condition; }\n\nbool AlwaysTrue() {\n#if GTEST_HAS_EXCEPTIONS\n  // This condition is always false so AlwaysTrue() never actually throws,\n  // but it makes the compiler think that it may throw.\n  if (IsTrue(false))\n    throw ClassUniqueToAlwaysTrue();\n#endif  // GTEST_HAS_EXCEPTIONS\n  return true;\n}\n\n// If *pstr starts with the given prefix, modifies *pstr to be right\n// past the prefix and returns true; otherwise leaves *pstr unchanged\n// and returns false.  None of pstr, *pstr, and prefix can be NULL.\nbool SkipPrefix(const char* prefix, const char** pstr) {\n  const size_t prefix_len = strlen(prefix);\n  if (strncmp(*pstr, prefix, prefix_len) == 0) {\n    *pstr += prefix_len;\n    return true;\n  }\n  return false;\n}\n\n// Parses a string as a command line flag.  The string should have\n// the format \"--flag=value\".  When def_optional is true, the \"=value\"\n// part can be omitted.\n//\n// Returns the value of the flag, or NULL if the parsing failed.\nconst char* ParseFlagValue(const char* str,\n                           const char* flag,\n                           bool def_optional) {\n  // str and flag must not be NULL.\n  if (str == NULL || flag == NULL) return NULL;\n\n  // The flag must start with \"--\" followed by GTEST_FLAG_PREFIX_.\n  const std::string flag_str = std::string(\"--\") + GTEST_FLAG_PREFIX_ + flag;\n  const size_t flag_len = flag_str.length();\n  if (strncmp(str, flag_str.c_str(), flag_len) != 0) return NULL;\n\n  // Skips the flag name.\n  const char* flag_end = str + flag_len;\n\n  // When def_optional is true, it's OK to not have a \"=value\" part.\n  if (def_optional && (flag_end[0] == '\\0')) {\n    return flag_end;\n  }\n\n  // If def_optional is true and there are more characters after the\n  // flag name, or if def_optional is false, there must be a '=' after\n  // the flag name.\n  if (flag_end[0] != '=') return NULL;\n\n  // Returns the string after \"=\".\n  return flag_end + 1;\n}\n\n// Parses a string for a bool flag, in the form of either\n// \"--flag=value\" or \"--flag\".\n//\n// In the former case, the value is taken as true as long as it does\n// not start with '0', 'f', or 'F'.\n//\n// In the latter case, the value is taken as true.\n//\n// On success, stores the value of the flag in *value, and returns\n// true.  On failure, returns false without changing *value.\nbool ParseBoolFlag(const char* str, const char* flag, bool* value) {\n  // Gets the value of the flag as a string.\n  const char* const value_str = ParseFlagValue(str, flag, true);\n\n  // Aborts if the parsing failed.\n  if (value_str == NULL) return false;\n\n  // Converts the string value to a bool.\n  *value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F');\n  return true;\n}\n\n// Parses a string for an Int32 flag, in the form of\n// \"--flag=value\".\n//\n// On success, stores the value of the flag in *value, and returns\n// true.  On failure, returns false without changing *value.\nbool ParseInt32Flag(const char* str, const char* flag, Int32* value) {\n  // Gets the value of the flag as a string.\n  const char* const value_str = ParseFlagValue(str, flag, false);\n\n  // Aborts if the parsing failed.\n  if (value_str == NULL) return false;\n\n  // Sets *value to the value of the flag.\n  return ParseInt32(Message() << \"The value of flag --\" << flag,\n                    value_str, value);\n}\n\n// Parses a string for a string flag, in the form of\n// \"--flag=value\".\n//\n// On success, stores the value of the flag in *value, and returns\n// true.  On failure, returns false without changing *value.\nbool ParseStringFlag(const char* str, const char* flag, std::string* value) {\n  // Gets the value of the flag as a string.\n  const char* const value_str = ParseFlagValue(str, flag, false);\n\n  // Aborts if the parsing failed.\n  if (value_str == NULL) return false;\n\n  // Sets *value to the value of the flag.\n  *value = value_str;\n  return true;\n}\n\n// Determines whether a string has a prefix that Google Test uses for its\n// flags, i.e., starts with GTEST_FLAG_PREFIX_ or GTEST_FLAG_PREFIX_DASH_.\n// If Google Test detects that a command line flag has its prefix but is not\n// recognized, it will print its help message. Flags starting with\n// GTEST_INTERNAL_PREFIX_ followed by \"internal_\" are considered Google Test\n// internal flags and do not trigger the help message.\nstatic bool HasGoogleTestFlagPrefix(const char* str) {\n  return (SkipPrefix(\"--\", &str) ||\n          SkipPrefix(\"-\", &str) ||\n          SkipPrefix(\"/\", &str)) &&\n         !SkipPrefix(GTEST_FLAG_PREFIX_ \"internal_\", &str) &&\n         (SkipPrefix(GTEST_FLAG_PREFIX_, &str) ||\n          SkipPrefix(GTEST_FLAG_PREFIX_DASH_, &str));\n}\n\n// Prints a string containing code-encoded text.  The following escape\n// sequences can be used in the string to control the text color:\n//\n//   @@    prints a single '@' character.\n//   @R    changes the color to red.\n//   @G    changes the color to green.\n//   @Y    changes the color to yellow.\n//   @D    changes to the default terminal text color.\n//\n// TODO(wan@google.com): Write tests for this once we add stdout\n// capturing to Google Test.\nstatic void PrintColorEncoded(const char* str) {\n  GTestColor color = COLOR_DEFAULT;  // The current color.\n\n  // Conceptually, we split the string into segments divided by escape\n  // sequences.  Then we print one segment at a time.  At the end of\n  // each iteration, the str pointer advances to the beginning of the\n  // next segment.\n  for (;;) {\n    const char* p = strchr(str, '@');\n    if (p == NULL) {\n      ColoredPrintf(color, \"%s\", str);\n      return;\n    }\n\n    ColoredPrintf(color, \"%s\", std::string(str, p).c_str());\n\n    const char ch = p[1];\n    str = p + 2;\n    if (ch == '@') {\n      ColoredPrintf(color, \"@\");\n    } else if (ch == 'D') {\n      color = COLOR_DEFAULT;\n    } else if (ch == 'R') {\n      color = COLOR_RED;\n    } else if (ch == 'G') {\n      color = COLOR_GREEN;\n    } else if (ch == 'Y') {\n      color = COLOR_YELLOW;\n    } else {\n      --str;\n    }\n  }\n}\n\nstatic const char kColorEncodedHelpMessage[] =\n\"This program contains tests written using \" GTEST_NAME_ \". You can use the\\n\"\n\"following command line flags to control its behavior:\\n\"\n\"\\n\"\n\"Test Selection:\\n\"\n\"  @G--\" GTEST_FLAG_PREFIX_ \"list_tests@D\\n\"\n\"      List the names of all tests instead of running them. The name of\\n\"\n\"      TEST(Foo, Bar) is \\\"Foo.Bar\\\".\\n\"\n\"  @G--\" GTEST_FLAG_PREFIX_ \"filter=@YPOSTIVE_PATTERNS\"\n    \"[@G-@YNEGATIVE_PATTERNS]@D\\n\"\n\"      Run only the tests whose name matches one of the positive patterns but\\n\"\n\"      none of the negative patterns. '?' matches any single character; '*'\\n\"\n\"      matches any substring; ':' separates two patterns.\\n\"\n\"  @G--\" GTEST_FLAG_PREFIX_ \"also_run_disabled_tests@D\\n\"\n\"      Run all disabled tests too.\\n\"\n\"\\n\"\n\"Test Execution:\\n\"\n\"  @G--\" GTEST_FLAG_PREFIX_ \"repeat=@Y[COUNT]@D\\n\"\n\"      Run the tests repeatedly; use a negative count to repeat forever.\\n\"\n\"  @G--\" GTEST_FLAG_PREFIX_ \"shuffle@D\\n\"\n\"      Randomize tests' orders on every iteration.\\n\"\n\"  @G--\" GTEST_FLAG_PREFIX_ \"random_seed=@Y[NUMBER]@D\\n\"\n\"      Random number seed to use for shuffling test orders (between 1 and\\n\"\n\"      99999, or 0 to use a seed based on the current time).\\n\"\n\"\\n\"\n\"Test Output:\\n\"\n\"  @G--\" GTEST_FLAG_PREFIX_ \"color=@Y(@Gyes@Y|@Gno@Y|@Gauto@Y)@D\\n\"\n\"      Enable/disable colored output. The default is @Gauto@D.\\n\"\n\"  -@G-\" GTEST_FLAG_PREFIX_ \"print_time=0@D\\n\"\n\"      Don't print the elapsed time of each test.\\n\"\n\"  @G--\" GTEST_FLAG_PREFIX_ \"output=xml@Y[@G:@YDIRECTORY_PATH@G\"\n    GTEST_PATH_SEP_ \"@Y|@G:@YFILE_PATH]@D\\n\"\n\"      Generate an XML report in the given directory or with the given file\\n\"\n\"      name. @YFILE_PATH@D defaults to @Gtest_details.xml@D.\\n\"\n#if GTEST_CAN_STREAM_RESULTS_\n\"  @G--\" GTEST_FLAG_PREFIX_ \"stream_result_to=@YHOST@G:@YPORT@D\\n\"\n\"      Stream test results to the given server.\\n\"\n#endif  // GTEST_CAN_STREAM_RESULTS_\n\"\\n\"\n\"Assertion Behavior:\\n\"\n#if GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS\n\"  @G--\" GTEST_FLAG_PREFIX_ \"death_test_style=@Y(@Gfast@Y|@Gthreadsafe@Y)@D\\n\"\n\"      Set the default death test style.\\n\"\n#endif  // GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS\n\"  @G--\" GTEST_FLAG_PREFIX_ \"break_on_failure@D\\n\"\n\"      Turn assertion failures into debugger break-points.\\n\"\n\"  @G--\" GTEST_FLAG_PREFIX_ \"throw_on_failure@D\\n\"\n\"      Turn assertion failures into C++ exceptions.\\n\"\n\"  @G--\" GTEST_FLAG_PREFIX_ \"catch_exceptions=0@D\\n\"\n\"      Do not report exceptions as test failures. Instead, allow them\\n\"\n\"      to crash the program or throw a pop-up (on Windows).\\n\"\n\"\\n\"\n\"Except for @G--\" GTEST_FLAG_PREFIX_ \"list_tests@D, you can alternatively set \"\n    \"the corresponding\\n\"\n\"environment variable of a flag (all letters in upper-case). For example, to\\n\"\n\"disable colored text output, you can either specify @G--\" GTEST_FLAG_PREFIX_\n    \"color=no@D or set\\n\"\n\"the @G\" GTEST_FLAG_PREFIX_UPPER_ \"COLOR@D environment variable to @Gno@D.\\n\"\n\"\\n\"\n\"For more information, please read the \" GTEST_NAME_ \" documentation at\\n\"\n\"@G\" GTEST_PROJECT_URL_ \"@D. If you find a bug in \" GTEST_NAME_ \"\\n\"\n\"(not one in your own code or tests), please report it to\\n\"\n\"@G<\" GTEST_DEV_EMAIL_ \">@D.\\n\";\n\n// Parses the command line for Google Test flags, without initializing\n// other parts of Google Test.  The type parameter CharType can be\n// instantiated to either char or wchar_t.\ntemplate <typename CharType>\nvoid ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) {\n  for (int i = 1; i < *argc; i++) {\n    const std::string arg_string = StreamableToString(argv[i]);\n    const char* const arg = arg_string.c_str();\n\n    using internal::ParseBoolFlag;\n    using internal::ParseInt32Flag;\n    using internal::ParseStringFlag;\n\n    // Do we see a Google Test flag?\n    if (ParseBoolFlag(arg, kAlsoRunDisabledTestsFlag,\n                      &GTEST_FLAG(also_run_disabled_tests)) ||\n        ParseBoolFlag(arg, kBreakOnFailureFlag,\n                      &GTEST_FLAG(break_on_failure)) ||\n        ParseBoolFlag(arg, kCatchExceptionsFlag,\n                      &GTEST_FLAG(catch_exceptions)) ||\n        ParseStringFlag(arg, kColorFlag, &GTEST_FLAG(color)) ||\n        ParseStringFlag(arg, kDeathTestStyleFlag,\n                        &GTEST_FLAG(death_test_style)) ||\n        ParseBoolFlag(arg, kDeathTestUseFork,\n                      &GTEST_FLAG(death_test_use_fork)) ||\n        ParseStringFlag(arg, kFilterFlag, &GTEST_FLAG(filter)) ||\n        ParseStringFlag(arg, kInternalRunDeathTestFlag,\n                        &GTEST_FLAG(internal_run_death_test)) ||\n        ParseBoolFlag(arg, kListTestsFlag, &GTEST_FLAG(list_tests)) ||\n        ParseStringFlag(arg, kOutputFlag, &GTEST_FLAG(output)) ||\n        ParseBoolFlag(arg, kPrintTimeFlag, &GTEST_FLAG(print_time)) ||\n        ParseInt32Flag(arg, kRandomSeedFlag, &GTEST_FLAG(random_seed)) ||\n        ParseInt32Flag(arg, kRepeatFlag, &GTEST_FLAG(repeat)) ||\n        ParseBoolFlag(arg, kShuffleFlag, &GTEST_FLAG(shuffle)) ||\n        ParseInt32Flag(arg, kStackTraceDepthFlag,\n                       &GTEST_FLAG(stack_trace_depth)) ||\n        ParseStringFlag(arg, kStreamResultToFlag,\n                        &GTEST_FLAG(stream_result_to)) ||\n        ParseBoolFlag(arg, kThrowOnFailureFlag,\n                      &GTEST_FLAG(throw_on_failure))\n        ) {\n      // Yes.  Shift the remainder of the argv list left by one.  Note\n      // that argv has (*argc + 1) elements, the last one always being\n      // NULL.  The following loop moves the trailing NULL element as\n      // well.\n      for (int j = i; j != *argc; j++) {\n        argv[j] = argv[j + 1];\n      }\n\n      // Decrements the argument count.\n      (*argc)--;\n\n      // We also need to decrement the iterator as we just removed\n      // an element.\n      i--;\n    } else if (arg_string == \"--help\" || arg_string == \"-h\" ||\n               arg_string == \"-?\" || arg_string == \"/?\" ||\n               HasGoogleTestFlagPrefix(arg)) {\n      // Both help flag and unrecognized Google Test flags (excluding\n      // internal ones) trigger help display.\n      g_help_flag = true;\n    }\n  }\n\n  if (g_help_flag) {\n    // We print the help here instead of in RUN_ALL_TESTS(), as the\n    // latter may not be called at all if the user is using Google\n    // Test with another testing framework.\n    PrintColorEncoded(kColorEncodedHelpMessage);\n  }\n}\n\n// Parses the command line for Google Test flags, without initializing\n// other parts of Google Test.\nvoid ParseGoogleTestFlagsOnly(int* argc, char** argv) {\n  ParseGoogleTestFlagsOnlyImpl(argc, argv);\n}\nvoid ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv) {\n  ParseGoogleTestFlagsOnlyImpl(argc, argv);\n}\n\n// The internal implementation of InitGoogleTest().\n//\n// The type parameter CharType can be instantiated to either char or\n// wchar_t.\ntemplate <typename CharType>\nvoid InitGoogleTestImpl(int* argc, CharType** argv) {\n  g_init_gtest_count++;\n\n  // We don't want to run the initialization code twice.\n  if (g_init_gtest_count != 1) return;\n\n  if (*argc <= 0) return;\n\n  internal::g_executable_path = internal::StreamableToString(argv[0]);\n\n#if GTEST_HAS_DEATH_TEST\n\n  g_argvs.clear();\n  for (int i = 0; i != *argc; i++) {\n    g_argvs.push_back(StreamableToString(argv[i]));\n  }\n\n#endif  // GTEST_HAS_DEATH_TEST\n\n  ParseGoogleTestFlagsOnly(argc, argv);\n  GetUnitTestImpl()->PostFlagParsingInit();\n}\n\n}  // namespace internal\n\n// Initializes Google Test.  This must be called before calling\n// RUN_ALL_TESTS().  In particular, it parses a command line for the\n// flags that Google Test recognizes.  Whenever a Google Test flag is\n// seen, it is removed from argv, and *argc is decremented.\n//\n// No value is returned.  Instead, the Google Test flag variables are\n// updated.\n//\n// Calling the function for the second time has no user-visible effect.\nvoid InitGoogleTest(int* argc, char** argv) {\n  internal::InitGoogleTestImpl(argc, argv);\n}\n\n// This overloaded version can be used in Windows programs compiled in\n// UNICODE mode.\nvoid InitGoogleTest(int* argc, wchar_t** argv) {\n  internal::InitGoogleTestImpl(argc, argv);\n}\n\n}  // namespace testing\n"
  },
  {
    "path": "ext/gtest/src/gtest_main.cc",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <stdio.h>\n\n#include \"gtest/gtest.h\"\n\nGTEST_API_ int main(int argc, char **argv) {\n  printf(\"Running main() from gtest_main.cc\\n\");\n  testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest-death-test_ex_test.cc",
    "content": "// Copyright 2010, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n//\n// Tests that verify interaction of exceptions and death tests.\n\n#include \"gtest/gtest-death-test.h\"\n#include \"gtest/gtest.h\"\n\n#if GTEST_HAS_DEATH_TEST\n\n# if GTEST_HAS_SEH\n#  include <windows.h>          // For RaiseException().\n# endif\n\n# include \"gtest/gtest-spi.h\"\n\n# if GTEST_HAS_EXCEPTIONS\n\n#  include <exception>  // For std::exception.\n\n// Tests that death tests report thrown exceptions as failures and that the\n// exceptions do not escape death test macros.\nTEST(CxxExceptionDeathTest, ExceptionIsFailure) {\n  try {\n    EXPECT_NONFATAL_FAILURE(EXPECT_DEATH(throw 1, \"\"), \"threw an exception\");\n  } catch (...) {  // NOLINT\n    FAIL() << \"An exception escaped a death test macro invocation \"\n           << \"with catch_exceptions \"\n           << (testing::GTEST_FLAG(catch_exceptions) ? \"enabled\" : \"disabled\");\n  }\n}\n\nclass TestException : public std::exception {\n public:\n  virtual const char* what() const throw() { return \"exceptional message\"; }\n};\n\nTEST(CxxExceptionDeathTest, PrintsMessageForStdExceptions) {\n  // Verifies that the exception message is quoted in the failure text.\n  EXPECT_NONFATAL_FAILURE(EXPECT_DEATH(throw TestException(), \"\"),\n                          \"exceptional message\");\n  // Verifies that the location is mentioned in the failure text.\n  EXPECT_NONFATAL_FAILURE(EXPECT_DEATH(throw TestException(), \"\"),\n                          \"gtest-death-test_ex_test.cc\");\n}\n# endif  // GTEST_HAS_EXCEPTIONS\n\n# if GTEST_HAS_SEH\n// Tests that enabling interception of SEH exceptions with the\n// catch_exceptions flag does not interfere with SEH exceptions being\n// treated as death by death tests.\nTEST(SehExceptionDeasTest, CatchExceptionsDoesNotInterfere) {\n  EXPECT_DEATH(RaiseException(42, 0x0, 0, NULL), \"\")\n      << \"with catch_exceptions \"\n      << (testing::GTEST_FLAG(catch_exceptions) ? \"enabled\" : \"disabled\");\n}\n# endif\n\n#endif  // GTEST_HAS_DEATH_TEST\n\nint main(int argc, char** argv) {\n  testing::InitGoogleTest(&argc, argv);\n  testing::GTEST_FLAG(catch_exceptions) = GTEST_ENABLE_CATCH_EXCEPTIONS_ != 0;\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest-death-test_test.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// Tests for death tests.\n\n#include \"gtest/gtest-death-test.h\"\n#include \"gtest/gtest.h\"\n#include \"gtest/internal/gtest-filepath.h\"\n\nusing testing::internal::AlwaysFalse;\nusing testing::internal::AlwaysTrue;\n\n#if GTEST_HAS_DEATH_TEST\n\n# if GTEST_OS_WINDOWS\n#  include <direct.h>          // For chdir().\n# else\n#  include <unistd.h>\n#  include <sys/wait.h>        // For waitpid.\n# endif  // GTEST_OS_WINDOWS\n\n# include <limits.h>\n# include <signal.h>\n# include <stdio.h>\n\n# if GTEST_OS_LINUX\n#  include <sys/time.h>\n# endif  // GTEST_OS_LINUX\n\n# include \"gtest/gtest-spi.h\"\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick is to\n// prevent a user from accidentally including gtest-internal-inl.h in\n// his code.\n# define GTEST_IMPLEMENTATION_ 1\n# include \"src/gtest-internal-inl.h\"\n# undef GTEST_IMPLEMENTATION_\n\nnamespace posix = ::testing::internal::posix;\n\nusing testing::Message;\nusing testing::internal::DeathTest;\nusing testing::internal::DeathTestFactory;\nusing testing::internal::FilePath;\nusing testing::internal::GetLastErrnoDescription;\nusing testing::internal::GetUnitTestImpl;\nusing testing::internal::InDeathTestChild;\nusing testing::internal::ParseNaturalNumber;\n\nnamespace testing {\nnamespace internal {\n\n// A helper class whose objects replace the death test factory for a\n// single UnitTest object during their lifetimes.\nclass ReplaceDeathTestFactory {\n public:\n  explicit ReplaceDeathTestFactory(DeathTestFactory* new_factory)\n      : unit_test_impl_(GetUnitTestImpl()) {\n    old_factory_ = unit_test_impl_->death_test_factory_.release();\n    unit_test_impl_->death_test_factory_.reset(new_factory);\n  }\n\n  ~ReplaceDeathTestFactory() {\n    unit_test_impl_->death_test_factory_.release();\n    unit_test_impl_->death_test_factory_.reset(old_factory_);\n  }\n private:\n  // Prevents copying ReplaceDeathTestFactory objects.\n  ReplaceDeathTestFactory(const ReplaceDeathTestFactory&);\n  void operator=(const ReplaceDeathTestFactory&);\n\n  UnitTestImpl* unit_test_impl_;\n  DeathTestFactory* old_factory_;\n};\n\n}  // namespace internal\n}  // namespace testing\n\nvoid DieWithMessage(const ::std::string& message) {\n  fprintf(stderr, \"%s\", message.c_str());\n  fflush(stderr);  // Make sure the text is printed before the process exits.\n\n  // We call _exit() instead of exit(), as the former is a direct\n  // system call and thus safer in the presence of threads.  exit()\n  // will invoke user-defined exit-hooks, which may do dangerous\n  // things that conflict with death tests.\n  //\n  // Some compilers can recognize that _exit() never returns and issue the\n  // 'unreachable code' warning for code following this function, unless\n  // fooled by a fake condition.\n  if (AlwaysTrue())\n    _exit(1);\n}\n\nvoid DieInside(const ::std::string& function) {\n  DieWithMessage(\"death inside \" + function + \"().\");\n}\n\n// Tests that death tests work.\n\nclass TestForDeathTest : public testing::Test {\n protected:\n  TestForDeathTest() : original_dir_(FilePath::GetCurrentDir()) {}\n\n  virtual ~TestForDeathTest() {\n    posix::ChDir(original_dir_.c_str());\n  }\n\n  // A static member function that's expected to die.\n  static void StaticMemberFunction() { DieInside(\"StaticMemberFunction\"); }\n\n  // A method of the test fixture that may die.\n  void MemberFunction() {\n    if (should_die_)\n      DieInside(\"MemberFunction\");\n  }\n\n  // True iff MemberFunction() should die.\n  bool should_die_;\n  const FilePath original_dir_;\n};\n\n// A class with a member function that may die.\nclass MayDie {\n public:\n  explicit MayDie(bool should_die) : should_die_(should_die) {}\n\n  // A member function that may die.\n  void MemberFunction() const {\n    if (should_die_)\n      DieInside(\"MayDie::MemberFunction\");\n  }\n\n private:\n  // True iff MemberFunction() should die.\n  bool should_die_;\n};\n\n// A global function that's expected to die.\nvoid GlobalFunction() { DieInside(\"GlobalFunction\"); }\n\n// A non-void function that's expected to die.\nint NonVoidFunction() {\n  DieInside(\"NonVoidFunction\");\n  return 1;\n}\n\n// A unary function that may die.\nvoid DieIf(bool should_die) {\n  if (should_die)\n    DieInside(\"DieIf\");\n}\n\n// A binary function that may die.\nbool DieIfLessThan(int x, int y) {\n  if (x < y) {\n    DieInside(\"DieIfLessThan\");\n  }\n  return true;\n}\n\n// Tests that ASSERT_DEATH can be used outside a TEST, TEST_F, or test fixture.\nvoid DeathTestSubroutine() {\n  EXPECT_DEATH(GlobalFunction(), \"death.*GlobalFunction\");\n  ASSERT_DEATH(GlobalFunction(), \"death.*GlobalFunction\");\n}\n\n// Death in dbg, not opt.\nint DieInDebugElse12(int* sideeffect) {\n  if (sideeffect) *sideeffect = 12;\n\n# ifndef NDEBUG\n\n  DieInside(\"DieInDebugElse12\");\n\n# endif  // NDEBUG\n\n  return 12;\n}\n\n# if GTEST_OS_WINDOWS\n\n// Tests the ExitedWithCode predicate.\nTEST(ExitStatusPredicateTest, ExitedWithCode) {\n  // On Windows, the process's exit code is the same as its exit status,\n  // so the predicate just compares the its input with its parameter.\n  EXPECT_TRUE(testing::ExitedWithCode(0)(0));\n  EXPECT_TRUE(testing::ExitedWithCode(1)(1));\n  EXPECT_TRUE(testing::ExitedWithCode(42)(42));\n  EXPECT_FALSE(testing::ExitedWithCode(0)(1));\n  EXPECT_FALSE(testing::ExitedWithCode(1)(0));\n}\n\n# else\n\n// Returns the exit status of a process that calls _exit(2) with a\n// given exit code.  This is a helper function for the\n// ExitStatusPredicateTest test suite.\nstatic int NormalExitStatus(int exit_code) {\n  pid_t child_pid = fork();\n  if (child_pid == 0) {\n    _exit(exit_code);\n  }\n  int status;\n  waitpid(child_pid, &status, 0);\n  return status;\n}\n\n// Returns the exit status of a process that raises a given signal.\n// If the signal does not cause the process to die, then it returns\n// instead the exit status of a process that exits normally with exit\n// code 1.  This is a helper function for the ExitStatusPredicateTest\n// test suite.\nstatic int KilledExitStatus(int signum) {\n  pid_t child_pid = fork();\n  if (child_pid == 0) {\n    raise(signum);\n    _exit(1);\n  }\n  int status;\n  waitpid(child_pid, &status, 0);\n  return status;\n}\n\n// Tests the ExitedWithCode predicate.\nTEST(ExitStatusPredicateTest, ExitedWithCode) {\n  const int status0  = NormalExitStatus(0);\n  const int status1  = NormalExitStatus(1);\n  const int status42 = NormalExitStatus(42);\n  const testing::ExitedWithCode pred0(0);\n  const testing::ExitedWithCode pred1(1);\n  const testing::ExitedWithCode pred42(42);\n  EXPECT_PRED1(pred0,  status0);\n  EXPECT_PRED1(pred1,  status1);\n  EXPECT_PRED1(pred42, status42);\n  EXPECT_FALSE(pred0(status1));\n  EXPECT_FALSE(pred42(status0));\n  EXPECT_FALSE(pred1(status42));\n}\n\n// Tests the KilledBySignal predicate.\nTEST(ExitStatusPredicateTest, KilledBySignal) {\n  const int status_segv = KilledExitStatus(SIGSEGV);\n  const int status_kill = KilledExitStatus(SIGKILL);\n  const testing::KilledBySignal pred_segv(SIGSEGV);\n  const testing::KilledBySignal pred_kill(SIGKILL);\n  EXPECT_PRED1(pred_segv, status_segv);\n  EXPECT_PRED1(pred_kill, status_kill);\n  EXPECT_FALSE(pred_segv(status_kill));\n  EXPECT_FALSE(pred_kill(status_segv));\n}\n\n# endif  // GTEST_OS_WINDOWS\n\n// Tests that the death test macros expand to code which may or may not\n// be followed by operator<<, and that in either case the complete text\n// comprises only a single C++ statement.\nTEST_F(TestForDeathTest, SingleStatement) {\n  if (AlwaysFalse())\n    // This would fail if executed; this is a compilation test only\n    ASSERT_DEATH(return, \"\");\n\n  if (AlwaysTrue())\n    EXPECT_DEATH(_exit(1), \"\");\n  else\n    // This empty \"else\" branch is meant to ensure that EXPECT_DEATH\n    // doesn't expand into an \"if\" statement without an \"else\"\n    ;\n\n  if (AlwaysFalse())\n    ASSERT_DEATH(return, \"\") << \"did not die\";\n\n  if (AlwaysFalse())\n    ;\n  else\n    EXPECT_DEATH(_exit(1), \"\") << 1 << 2 << 3;\n}\n\nvoid DieWithEmbeddedNul() {\n  fprintf(stderr, \"Hello%cmy null world.\\n\", '\\0');\n  fflush(stderr);\n  _exit(1);\n}\n\n# if GTEST_USES_PCRE\n// Tests that EXPECT_DEATH and ASSERT_DEATH work when the error\n// message has a NUL character in it.\nTEST_F(TestForDeathTest, EmbeddedNulInMessage) {\n  // TODO(wan@google.com): <regex.h> doesn't support matching strings\n  // with embedded NUL characters - find a way to workaround it.\n  EXPECT_DEATH(DieWithEmbeddedNul(), \"my null world\");\n  ASSERT_DEATH(DieWithEmbeddedNul(), \"my null world\");\n}\n# endif  // GTEST_USES_PCRE\n\n// Tests that death test macros expand to code which interacts well with switch\n// statements.\nTEST_F(TestForDeathTest, SwitchStatement) {\n// Microsoft compiler usually complains about switch statements without\n// case labels. We suppress that warning for this test.\n# ifdef _MSC_VER\n#  pragma warning(push)\n#  pragma warning(disable: 4065)\n# endif  // _MSC_VER\n\n  switch (0)\n    default:\n      ASSERT_DEATH(_exit(1), \"\") << \"exit in default switch handler\";\n\n  switch (0)\n    case 0:\n      EXPECT_DEATH(_exit(1), \"\") << \"exit in switch case\";\n\n# ifdef _MSC_VER\n#  pragma warning(pop)\n# endif  // _MSC_VER\n}\n\n// Tests that a static member function can be used in a \"fast\" style\n// death test.\nTEST_F(TestForDeathTest, StaticMemberFunctionFastStyle) {\n  testing::GTEST_FLAG(death_test_style) = \"fast\";\n  ASSERT_DEATH(StaticMemberFunction(), \"death.*StaticMember\");\n}\n\n// Tests that a method of the test fixture can be used in a \"fast\"\n// style death test.\nTEST_F(TestForDeathTest, MemberFunctionFastStyle) {\n  testing::GTEST_FLAG(death_test_style) = \"fast\";\n  should_die_ = true;\n  EXPECT_DEATH(MemberFunction(), \"inside.*MemberFunction\");\n}\n\nvoid ChangeToRootDir() { posix::ChDir(GTEST_PATH_SEP_); }\n\n// Tests that death tests work even if the current directory has been\n// changed.\nTEST_F(TestForDeathTest, FastDeathTestInChangedDir) {\n  testing::GTEST_FLAG(death_test_style) = \"fast\";\n\n  ChangeToRootDir();\n  EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1), \"\");\n\n  ChangeToRootDir();\n  ASSERT_DEATH(_exit(1), \"\");\n}\n\n# if GTEST_OS_LINUX\nvoid SigprofAction(int, siginfo_t*, void*) { /* no op */ }\n\n// Sets SIGPROF action and ITIMER_PROF timer (interval: 1ms).\nvoid SetSigprofActionAndTimer() {\n  struct itimerval timer;\n  timer.it_interval.tv_sec = 0;\n  timer.it_interval.tv_usec = 1;\n  timer.it_value = timer.it_interval;\n  ASSERT_EQ(0, setitimer(ITIMER_PROF, &timer, NULL));\n  struct sigaction signal_action;\n  memset(&signal_action, 0, sizeof(signal_action));\n  sigemptyset(&signal_action.sa_mask);\n  signal_action.sa_sigaction = SigprofAction;\n  signal_action.sa_flags = SA_RESTART | SA_SIGINFO;\n  ASSERT_EQ(0, sigaction(SIGPROF, &signal_action, NULL));\n}\n\n// Disables ITIMER_PROF timer and ignores SIGPROF signal.\nvoid DisableSigprofActionAndTimer(struct sigaction* old_signal_action) {\n  struct itimerval timer;\n  timer.it_interval.tv_sec = 0;\n  timer.it_interval.tv_usec = 0;\n  timer.it_value = timer.it_interval;\n  ASSERT_EQ(0, setitimer(ITIMER_PROF, &timer, NULL));\n  struct sigaction signal_action;\n  memset(&signal_action, 0, sizeof(signal_action));\n  sigemptyset(&signal_action.sa_mask);\n  signal_action.sa_handler = SIG_IGN;\n  ASSERT_EQ(0, sigaction(SIGPROF, &signal_action, old_signal_action));\n}\n\n// Tests that death tests work when SIGPROF handler and timer are set.\nTEST_F(TestForDeathTest, FastSigprofActionSet) {\n  testing::GTEST_FLAG(death_test_style) = \"fast\";\n  SetSigprofActionAndTimer();\n  EXPECT_DEATH(_exit(1), \"\");\n  struct sigaction old_signal_action;\n  DisableSigprofActionAndTimer(&old_signal_action);\n  EXPECT_TRUE(old_signal_action.sa_sigaction == SigprofAction);\n}\n\nTEST_F(TestForDeathTest, ThreadSafeSigprofActionSet) {\n  testing::GTEST_FLAG(death_test_style) = \"threadsafe\";\n  SetSigprofActionAndTimer();\n  EXPECT_DEATH(_exit(1), \"\");\n  struct sigaction old_signal_action;\n  DisableSigprofActionAndTimer(&old_signal_action);\n  EXPECT_TRUE(old_signal_action.sa_sigaction == SigprofAction);\n}\n# endif  // GTEST_OS_LINUX\n\n// Repeats a representative sample of death tests in the \"threadsafe\" style:\n\nTEST_F(TestForDeathTest, StaticMemberFunctionThreadsafeStyle) {\n  testing::GTEST_FLAG(death_test_style) = \"threadsafe\";\n  ASSERT_DEATH(StaticMemberFunction(), \"death.*StaticMember\");\n}\n\nTEST_F(TestForDeathTest, MemberFunctionThreadsafeStyle) {\n  testing::GTEST_FLAG(death_test_style) = \"threadsafe\";\n  should_die_ = true;\n  EXPECT_DEATH(MemberFunction(), \"inside.*MemberFunction\");\n}\n\nTEST_F(TestForDeathTest, ThreadsafeDeathTestInLoop) {\n  testing::GTEST_FLAG(death_test_style) = \"threadsafe\";\n\n  for (int i = 0; i < 3; ++i)\n    EXPECT_EXIT(_exit(i), testing::ExitedWithCode(i), \"\") << \": i = \" << i;\n}\n\nTEST_F(TestForDeathTest, ThreadsafeDeathTestInChangedDir) {\n  testing::GTEST_FLAG(death_test_style) = \"threadsafe\";\n\n  ChangeToRootDir();\n  EXPECT_EXIT(_exit(1), testing::ExitedWithCode(1), \"\");\n\n  ChangeToRootDir();\n  ASSERT_DEATH(_exit(1), \"\");\n}\n\nTEST_F(TestForDeathTest, MixedStyles) {\n  testing::GTEST_FLAG(death_test_style) = \"threadsafe\";\n  EXPECT_DEATH(_exit(1), \"\");\n  testing::GTEST_FLAG(death_test_style) = \"fast\";\n  EXPECT_DEATH(_exit(1), \"\");\n}\n\n# if GTEST_HAS_CLONE && GTEST_HAS_PTHREAD\n\nnamespace {\n\nbool pthread_flag;\n\nvoid SetPthreadFlag() {\n  pthread_flag = true;\n}\n\n}  // namespace\n\nTEST_F(TestForDeathTest, DoesNotExecuteAtforkHooks) {\n  if (!testing::GTEST_FLAG(death_test_use_fork)) {\n    testing::GTEST_FLAG(death_test_style) = \"threadsafe\";\n    pthread_flag = false;\n    ASSERT_EQ(0, pthread_atfork(&SetPthreadFlag, NULL, NULL));\n    ASSERT_DEATH(_exit(1), \"\");\n    ASSERT_FALSE(pthread_flag);\n  }\n}\n\n# endif  // GTEST_HAS_CLONE && GTEST_HAS_PTHREAD\n\n// Tests that a method of another class can be used in a death test.\nTEST_F(TestForDeathTest, MethodOfAnotherClass) {\n  const MayDie x(true);\n  ASSERT_DEATH(x.MemberFunction(), \"MayDie\\\\:\\\\:MemberFunction\");\n}\n\n// Tests that a global function can be used in a death test.\nTEST_F(TestForDeathTest, GlobalFunction) {\n  EXPECT_DEATH(GlobalFunction(), \"GlobalFunction\");\n}\n\n// Tests that any value convertible to an RE works as a second\n// argument to EXPECT_DEATH.\nTEST_F(TestForDeathTest, AcceptsAnythingConvertibleToRE) {\n  static const char regex_c_str[] = \"GlobalFunction\";\n  EXPECT_DEATH(GlobalFunction(), regex_c_str);\n\n  const testing::internal::RE regex(regex_c_str);\n  EXPECT_DEATH(GlobalFunction(), regex);\n\n# if GTEST_HAS_GLOBAL_STRING\n\n  const string regex_str(regex_c_str);\n  EXPECT_DEATH(GlobalFunction(), regex_str);\n\n# endif  // GTEST_HAS_GLOBAL_STRING\n\n  const ::std::string regex_std_str(regex_c_str);\n  EXPECT_DEATH(GlobalFunction(), regex_std_str);\n}\n\n// Tests that a non-void function can be used in a death test.\nTEST_F(TestForDeathTest, NonVoidFunction) {\n  ASSERT_DEATH(NonVoidFunction(), \"NonVoidFunction\");\n}\n\n// Tests that functions that take parameter(s) can be used in a death test.\nTEST_F(TestForDeathTest, FunctionWithParameter) {\n  EXPECT_DEATH(DieIf(true), \"DieIf\\\\(\\\\)\");\n  EXPECT_DEATH(DieIfLessThan(2, 3), \"DieIfLessThan\");\n}\n\n// Tests that ASSERT_DEATH can be used outside a TEST, TEST_F, or test fixture.\nTEST_F(TestForDeathTest, OutsideFixture) {\n  DeathTestSubroutine();\n}\n\n// Tests that death tests can be done inside a loop.\nTEST_F(TestForDeathTest, InsideLoop) {\n  for (int i = 0; i < 5; i++) {\n    EXPECT_DEATH(DieIfLessThan(-1, i), \"DieIfLessThan\") << \"where i == \" << i;\n  }\n}\n\n// Tests that a compound statement can be used in a death test.\nTEST_F(TestForDeathTest, CompoundStatement) {\n  EXPECT_DEATH({  // NOLINT\n    const int x = 2;\n    const int y = x + 1;\n    DieIfLessThan(x, y);\n  },\n  \"DieIfLessThan\");\n}\n\n// Tests that code that doesn't die causes a death test to fail.\nTEST_F(TestForDeathTest, DoesNotDie) {\n  EXPECT_NONFATAL_FAILURE(EXPECT_DEATH(DieIf(false), \"DieIf\"),\n                          \"failed to die\");\n}\n\n// Tests that a death test fails when the error message isn't expected.\nTEST_F(TestForDeathTest, ErrorMessageMismatch) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_DEATH(DieIf(true), \"DieIfLessThan\") << \"End of death test message.\";\n  }, \"died but not with expected error\");\n}\n\n// On exit, *aborted will be true iff the EXPECT_DEATH() statement\n// aborted the function.\nvoid ExpectDeathTestHelper(bool* aborted) {\n  *aborted = true;\n  EXPECT_DEATH(DieIf(false), \"DieIf\");  // This assertion should fail.\n  *aborted = false;\n}\n\n// Tests that EXPECT_DEATH doesn't abort the test on failure.\nTEST_F(TestForDeathTest, EXPECT_DEATH) {\n  bool aborted = true;\n  EXPECT_NONFATAL_FAILURE(ExpectDeathTestHelper(&aborted),\n                          \"failed to die\");\n  EXPECT_FALSE(aborted);\n}\n\n// Tests that ASSERT_DEATH does abort the test on failure.\nTEST_F(TestForDeathTest, ASSERT_DEATH) {\n  static bool aborted;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    aborted = true;\n    ASSERT_DEATH(DieIf(false), \"DieIf\");  // This assertion should fail.\n    aborted = false;\n  }, \"failed to die\");\n  EXPECT_TRUE(aborted);\n}\n\n// Tests that EXPECT_DEATH evaluates the arguments exactly once.\nTEST_F(TestForDeathTest, SingleEvaluation) {\n  int x = 3;\n  EXPECT_DEATH(DieIf((++x) == 4), \"DieIf\");\n\n  const char* regex = \"DieIf\";\n  const char* regex_save = regex;\n  EXPECT_DEATH(DieIfLessThan(3, 4), regex++);\n  EXPECT_EQ(regex_save + 1, regex);\n}\n\n// Tests that run-away death tests are reported as failures.\nTEST_F(TestForDeathTest, RunawayIsFailure) {\n  EXPECT_NONFATAL_FAILURE(EXPECT_DEATH(static_cast<void>(0), \"Foo\"),\n                          \"failed to die.\");\n}\n\n// Tests that death tests report executing 'return' in the statement as\n// failure.\nTEST_F(TestForDeathTest, ReturnIsFailure) {\n  EXPECT_FATAL_FAILURE(ASSERT_DEATH(return, \"Bar\"),\n                       \"illegal return in test statement.\");\n}\n\n// Tests that EXPECT_DEBUG_DEATH works as expected, that is, you can stream a\n// message to it, and in debug mode it:\n// 1. Asserts on death.\n// 2. Has no side effect.\n//\n// And in opt mode, it:\n// 1.  Has side effects but does not assert.\nTEST_F(TestForDeathTest, TestExpectDebugDeath) {\n  int sideeffect = 0;\n\n  EXPECT_DEBUG_DEATH(DieInDebugElse12(&sideeffect), \"death.*DieInDebugElse12\")\n      << \"Must accept a streamed message\";\n\n# ifdef NDEBUG\n\n  // Checks that the assignment occurs in opt mode (sideeffect).\n  EXPECT_EQ(12, sideeffect);\n\n# else\n\n  // Checks that the assignment does not occur in dbg mode (no sideeffect).\n  EXPECT_EQ(0, sideeffect);\n\n# endif\n}\n\n// Tests that ASSERT_DEBUG_DEATH works as expected, that is, you can stream a\n// message to it, and in debug mode it:\n// 1. Asserts on death.\n// 2. Has no side effect.\n//\n// And in opt mode, it:\n// 1.  Has side effects but does not assert.\nTEST_F(TestForDeathTest, TestAssertDebugDeath) {\n  int sideeffect = 0;\n\n  ASSERT_DEBUG_DEATH(DieInDebugElse12(&sideeffect), \"death.*DieInDebugElse12\")\n      << \"Must accept a streamed message\";\n\n# ifdef NDEBUG\n\n  // Checks that the assignment occurs in opt mode (sideeffect).\n  EXPECT_EQ(12, sideeffect);\n\n# else\n\n  // Checks that the assignment does not occur in dbg mode (no sideeffect).\n  EXPECT_EQ(0, sideeffect);\n\n# endif\n}\n\n# ifndef NDEBUG\n\nvoid ExpectDebugDeathHelper(bool* aborted) {\n  *aborted = true;\n  EXPECT_DEBUG_DEATH(return, \"\") << \"This is expected to fail.\";\n  *aborted = false;\n}\n\n#  if GTEST_OS_WINDOWS\nTEST(PopUpDeathTest, DoesNotShowPopUpOnAbort) {\n  printf(\"This test should be considered failing if it shows \"\n         \"any pop-up dialogs.\\n\");\n  fflush(stdout);\n\n  EXPECT_DEATH({\n    testing::GTEST_FLAG(catch_exceptions) = false;\n    abort();\n  }, \"\");\n}\n#  endif  // GTEST_OS_WINDOWS\n\n// Tests that EXPECT_DEBUG_DEATH in debug mode does not abort\n// the function.\nTEST_F(TestForDeathTest, ExpectDebugDeathDoesNotAbort) {\n  bool aborted = true;\n  EXPECT_NONFATAL_FAILURE(ExpectDebugDeathHelper(&aborted), \"\");\n  EXPECT_FALSE(aborted);\n}\n\nvoid AssertDebugDeathHelper(bool* aborted) {\n  *aborted = true;\n  ASSERT_DEBUG_DEATH(return, \"\") << \"This is expected to fail.\";\n  *aborted = false;\n}\n\n// Tests that ASSERT_DEBUG_DEATH in debug mode aborts the function on\n// failure.\nTEST_F(TestForDeathTest, AssertDebugDeathAborts) {\n  static bool aborted;\n  aborted = false;\n  EXPECT_FATAL_FAILURE(AssertDebugDeathHelper(&aborted), \"\");\n  EXPECT_TRUE(aborted);\n}\n\n# endif  // _NDEBUG\n\n// Tests the *_EXIT family of macros, using a variety of predicates.\nstatic void TestExitMacros() {\n  EXPECT_EXIT(_exit(1),  testing::ExitedWithCode(1),  \"\");\n  ASSERT_EXIT(_exit(42), testing::ExitedWithCode(42), \"\");\n\n# if GTEST_OS_WINDOWS\n\n  // Of all signals effects on the process exit code, only those of SIGABRT\n  // are documented on Windows.\n  // See http://msdn.microsoft.com/en-us/library/dwwzkt4c(VS.71).aspx.\n  EXPECT_EXIT(raise(SIGABRT), testing::ExitedWithCode(3), \"\") << \"b_ar\";\n\n# else\n\n  EXPECT_EXIT(raise(SIGKILL), testing::KilledBySignal(SIGKILL), \"\") << \"foo\";\n  ASSERT_EXIT(raise(SIGUSR2), testing::KilledBySignal(SIGUSR2), \"\") << \"bar\";\n\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_EXIT(_exit(0), testing::KilledBySignal(SIGSEGV), \"\")\n      << \"This failure is expected, too.\";\n  }, \"This failure is expected, too.\");\n\n# endif  // GTEST_OS_WINDOWS\n\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_EXIT(raise(SIGSEGV), testing::ExitedWithCode(0), \"\")\n      << \"This failure is expected.\";\n  }, \"This failure is expected.\");\n}\n\nTEST_F(TestForDeathTest, ExitMacros) {\n  TestExitMacros();\n}\n\nTEST_F(TestForDeathTest, ExitMacrosUsingFork) {\n  testing::GTEST_FLAG(death_test_use_fork) = true;\n  TestExitMacros();\n}\n\nTEST_F(TestForDeathTest, InvalidStyle) {\n  testing::GTEST_FLAG(death_test_style) = \"rococo\";\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_DEATH(_exit(0), \"\") << \"This failure is expected.\";\n  }, \"This failure is expected.\");\n}\n\nTEST_F(TestForDeathTest, DeathTestFailedOutput) {\n  testing::GTEST_FLAG(death_test_style) = \"fast\";\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_DEATH(DieWithMessage(\"death\\n\"),\n                   \"expected message\"),\n      \"Actual msg:\\n\"\n      \"[  DEATH   ] death\\n\");\n}\n\nTEST_F(TestForDeathTest, DeathTestUnexpectedReturnOutput) {\n  testing::GTEST_FLAG(death_test_style) = \"fast\";\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_DEATH({\n          fprintf(stderr, \"returning\\n\");\n          fflush(stderr);\n          return;\n        }, \"\"),\n      \"    Result: illegal return in test statement.\\n\"\n      \" Error msg:\\n\"\n      \"[  DEATH   ] returning\\n\");\n}\n\nTEST_F(TestForDeathTest, DeathTestBadExitCodeOutput) {\n  testing::GTEST_FLAG(death_test_style) = \"fast\";\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_EXIT(DieWithMessage(\"exiting with rc 1\\n\"),\n                  testing::ExitedWithCode(3),\n                  \"expected message\"),\n      \"    Result: died but not with expected exit code:\\n\"\n      \"            Exited with exit status 1\\n\"\n      \"Actual msg:\\n\"\n      \"[  DEATH   ] exiting with rc 1\\n\");\n}\n\nTEST_F(TestForDeathTest, DeathTestMultiLineMatchFail) {\n  testing::GTEST_FLAG(death_test_style) = \"fast\";\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_DEATH(DieWithMessage(\"line 1\\nline 2\\nline 3\\n\"),\n                   \"line 1\\nxyz\\nline 3\\n\"),\n      \"Actual msg:\\n\"\n      \"[  DEATH   ] line 1\\n\"\n      \"[  DEATH   ] line 2\\n\"\n      \"[  DEATH   ] line 3\\n\");\n}\n\nTEST_F(TestForDeathTest, DeathTestMultiLineMatchPass) {\n  testing::GTEST_FLAG(death_test_style) = \"fast\";\n  EXPECT_DEATH(DieWithMessage(\"line 1\\nline 2\\nline 3\\n\"),\n               \"line 1\\nline 2\\nline 3\\n\");\n}\n\n// A DeathTestFactory that returns MockDeathTests.\nclass MockDeathTestFactory : public DeathTestFactory {\n public:\n  MockDeathTestFactory();\n  virtual bool Create(const char* statement,\n                      const ::testing::internal::RE* regex,\n                      const char* file, int line, DeathTest** test);\n\n  // Sets the parameters for subsequent calls to Create.\n  void SetParameters(bool create, DeathTest::TestRole role,\n                     int status, bool passed);\n\n  // Accessors.\n  int AssumeRoleCalls() const { return assume_role_calls_; }\n  int WaitCalls() const { return wait_calls_; }\n  int PassedCalls() const { return passed_args_.size(); }\n  bool PassedArgument(int n) const { return passed_args_[n]; }\n  int AbortCalls() const { return abort_args_.size(); }\n  DeathTest::AbortReason AbortArgument(int n) const {\n    return abort_args_[n];\n  }\n  bool TestDeleted() const { return test_deleted_; }\n\n private:\n  friend class MockDeathTest;\n  // If true, Create will return a MockDeathTest; otherwise it returns\n  // NULL.\n  bool create_;\n  // The value a MockDeathTest will return from its AssumeRole method.\n  DeathTest::TestRole role_;\n  // The value a MockDeathTest will return from its Wait method.\n  int status_;\n  // The value a MockDeathTest will return from its Passed method.\n  bool passed_;\n\n  // Number of times AssumeRole was called.\n  int assume_role_calls_;\n  // Number of times Wait was called.\n  int wait_calls_;\n  // The arguments to the calls to Passed since the last call to\n  // SetParameters.\n  std::vector<bool> passed_args_;\n  // The arguments to the calls to Abort since the last call to\n  // SetParameters.\n  std::vector<DeathTest::AbortReason> abort_args_;\n  // True if the last MockDeathTest returned by Create has been\n  // deleted.\n  bool test_deleted_;\n};\n\n\n// A DeathTest implementation useful in testing.  It returns values set\n// at its creation from its various inherited DeathTest methods, and\n// reports calls to those methods to its parent MockDeathTestFactory\n// object.\nclass MockDeathTest : public DeathTest {\n public:\n  MockDeathTest(MockDeathTestFactory *parent,\n                TestRole role, int status, bool passed) :\n      parent_(parent), role_(role), status_(status), passed_(passed) {\n  }\n  virtual ~MockDeathTest() {\n    parent_->test_deleted_ = true;\n  }\n  virtual TestRole AssumeRole() {\n    ++parent_->assume_role_calls_;\n    return role_;\n  }\n  virtual int Wait() {\n    ++parent_->wait_calls_;\n    return status_;\n  }\n  virtual bool Passed(bool exit_status_ok) {\n    parent_->passed_args_.push_back(exit_status_ok);\n    return passed_;\n  }\n  virtual void Abort(AbortReason reason) {\n    parent_->abort_args_.push_back(reason);\n  }\n\n private:\n  MockDeathTestFactory* const parent_;\n  const TestRole role_;\n  const int status_;\n  const bool passed_;\n};\n\n\n// MockDeathTestFactory constructor.\nMockDeathTestFactory::MockDeathTestFactory()\n    : create_(true),\n      role_(DeathTest::OVERSEE_TEST),\n      status_(0),\n      passed_(true),\n      assume_role_calls_(0),\n      wait_calls_(0),\n      passed_args_(),\n      abort_args_() {\n}\n\n\n// Sets the parameters for subsequent calls to Create.\nvoid MockDeathTestFactory::SetParameters(bool create,\n                                         DeathTest::TestRole role,\n                                         int status, bool passed) {\n  create_ = create;\n  role_ = role;\n  status_ = status;\n  passed_ = passed;\n\n  assume_role_calls_ = 0;\n  wait_calls_ = 0;\n  passed_args_.clear();\n  abort_args_.clear();\n}\n\n\n// Sets test to NULL (if create_ is false) or to the address of a new\n// MockDeathTest object with parameters taken from the last call\n// to SetParameters (if create_ is true).  Always returns true.\nbool MockDeathTestFactory::Create(const char* /*statement*/,\n                                  const ::testing::internal::RE* /*regex*/,\n                                  const char* /*file*/,\n                                  int /*line*/,\n                                  DeathTest** test) {\n  test_deleted_ = false;\n  if (create_) {\n    *test = new MockDeathTest(this, role_, status_, passed_);\n  } else {\n    *test = NULL;\n  }\n  return true;\n}\n\n// A test fixture for testing the logic of the GTEST_DEATH_TEST_ macro.\n// It installs a MockDeathTestFactory that is used for the duration\n// of the test case.\nclass MacroLogicDeathTest : public testing::Test {\n protected:\n  static testing::internal::ReplaceDeathTestFactory* replacer_;\n  static MockDeathTestFactory* factory_;\n\n  static void SetUpTestCase() {\n    factory_ = new MockDeathTestFactory;\n    replacer_ = new testing::internal::ReplaceDeathTestFactory(factory_);\n  }\n\n  static void TearDownTestCase() {\n    delete replacer_;\n    replacer_ = NULL;\n    delete factory_;\n    factory_ = NULL;\n  }\n\n  // Runs a death test that breaks the rules by returning.  Such a death\n  // test cannot be run directly from a test routine that uses a\n  // MockDeathTest, or the remainder of the routine will not be executed.\n  static void RunReturningDeathTest(bool* flag) {\n    ASSERT_DEATH({  // NOLINT\n      *flag = true;\n      return;\n    }, \"\");\n  }\n};\n\ntesting::internal::ReplaceDeathTestFactory* MacroLogicDeathTest::replacer_\n    = NULL;\nMockDeathTestFactory* MacroLogicDeathTest::factory_ = NULL;\n\n\n// Test that nothing happens when the factory doesn't return a DeathTest:\nTEST_F(MacroLogicDeathTest, NothingHappens) {\n  bool flag = false;\n  factory_->SetParameters(false, DeathTest::OVERSEE_TEST, 0, true);\n  EXPECT_DEATH(flag = true, \"\");\n  EXPECT_FALSE(flag);\n  EXPECT_EQ(0, factory_->AssumeRoleCalls());\n  EXPECT_EQ(0, factory_->WaitCalls());\n  EXPECT_EQ(0, factory_->PassedCalls());\n  EXPECT_EQ(0, factory_->AbortCalls());\n  EXPECT_FALSE(factory_->TestDeleted());\n}\n\n// Test that the parent process doesn't run the death test code,\n// and that the Passed method returns false when the (simulated)\n// child process exits with status 0:\nTEST_F(MacroLogicDeathTest, ChildExitsSuccessfully) {\n  bool flag = false;\n  factory_->SetParameters(true, DeathTest::OVERSEE_TEST, 0, true);\n  EXPECT_DEATH(flag = true, \"\");\n  EXPECT_FALSE(flag);\n  EXPECT_EQ(1, factory_->AssumeRoleCalls());\n  EXPECT_EQ(1, factory_->WaitCalls());\n  ASSERT_EQ(1, factory_->PassedCalls());\n  EXPECT_FALSE(factory_->PassedArgument(0));\n  EXPECT_EQ(0, factory_->AbortCalls());\n  EXPECT_TRUE(factory_->TestDeleted());\n}\n\n// Tests that the Passed method was given the argument \"true\" when\n// the (simulated) child process exits with status 1:\nTEST_F(MacroLogicDeathTest, ChildExitsUnsuccessfully) {\n  bool flag = false;\n  factory_->SetParameters(true, DeathTest::OVERSEE_TEST, 1, true);\n  EXPECT_DEATH(flag = true, \"\");\n  EXPECT_FALSE(flag);\n  EXPECT_EQ(1, factory_->AssumeRoleCalls());\n  EXPECT_EQ(1, factory_->WaitCalls());\n  ASSERT_EQ(1, factory_->PassedCalls());\n  EXPECT_TRUE(factory_->PassedArgument(0));\n  EXPECT_EQ(0, factory_->AbortCalls());\n  EXPECT_TRUE(factory_->TestDeleted());\n}\n\n// Tests that the (simulated) child process executes the death test\n// code, and is aborted with the correct AbortReason if it\n// executes a return statement.\nTEST_F(MacroLogicDeathTest, ChildPerformsReturn) {\n  bool flag = false;\n  factory_->SetParameters(true, DeathTest::EXECUTE_TEST, 0, true);\n  RunReturningDeathTest(&flag);\n  EXPECT_TRUE(flag);\n  EXPECT_EQ(1, factory_->AssumeRoleCalls());\n  EXPECT_EQ(0, factory_->WaitCalls());\n  EXPECT_EQ(0, factory_->PassedCalls());\n  EXPECT_EQ(1, factory_->AbortCalls());\n  EXPECT_EQ(DeathTest::TEST_ENCOUNTERED_RETURN_STATEMENT,\n            factory_->AbortArgument(0));\n  EXPECT_TRUE(factory_->TestDeleted());\n}\n\n// Tests that the (simulated) child process is aborted with the\n// correct AbortReason if it does not die.\nTEST_F(MacroLogicDeathTest, ChildDoesNotDie) {\n  bool flag = false;\n  factory_->SetParameters(true, DeathTest::EXECUTE_TEST, 0, true);\n  EXPECT_DEATH(flag = true, \"\");\n  EXPECT_TRUE(flag);\n  EXPECT_EQ(1, factory_->AssumeRoleCalls());\n  EXPECT_EQ(0, factory_->WaitCalls());\n  EXPECT_EQ(0, factory_->PassedCalls());\n  // This time there are two calls to Abort: one since the test didn't\n  // die, and another from the ReturnSentinel when it's destroyed.  The\n  // sentinel normally isn't destroyed if a test doesn't die, since\n  // _exit(2) is called in that case by ForkingDeathTest, but not by\n  // our MockDeathTest.\n  ASSERT_EQ(2, factory_->AbortCalls());\n  EXPECT_EQ(DeathTest::TEST_DID_NOT_DIE,\n            factory_->AbortArgument(0));\n  EXPECT_EQ(DeathTest::TEST_ENCOUNTERED_RETURN_STATEMENT,\n            factory_->AbortArgument(1));\n  EXPECT_TRUE(factory_->TestDeleted());\n}\n\n// Tests that a successful death test does not register a successful\n// test part.\nTEST(SuccessRegistrationDeathTest, NoSuccessPart) {\n  EXPECT_DEATH(_exit(1), \"\");\n  EXPECT_EQ(0, GetUnitTestImpl()->current_test_result()->total_part_count());\n}\n\nTEST(StreamingAssertionsDeathTest, DeathTest) {\n  EXPECT_DEATH(_exit(1), \"\") << \"unexpected failure\";\n  ASSERT_DEATH(_exit(1), \"\") << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_DEATH(_exit(0), \"\") << \"expected failure\";\n  }, \"expected failure\");\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_DEATH(_exit(0), \"\") << \"expected failure\";\n  }, \"expected failure\");\n}\n\n// Tests that GetLastErrnoDescription returns an empty string when the\n// last error is 0 and non-empty string when it is non-zero.\nTEST(GetLastErrnoDescription, GetLastErrnoDescriptionWorks) {\n  errno = ENOENT;\n  EXPECT_STRNE(\"\", GetLastErrnoDescription().c_str());\n  errno = 0;\n  EXPECT_STREQ(\"\", GetLastErrnoDescription().c_str());\n}\n\n# if GTEST_OS_WINDOWS\nTEST(AutoHandleTest, AutoHandleWorks) {\n  HANDLE handle = ::CreateEvent(NULL, FALSE, FALSE, NULL);\n  ASSERT_NE(INVALID_HANDLE_VALUE, handle);\n\n  // Tests that the AutoHandle is correctly initialized with a handle.\n  testing::internal::AutoHandle auto_handle(handle);\n  EXPECT_EQ(handle, auto_handle.Get());\n\n  // Tests that Reset assigns INVALID_HANDLE_VALUE.\n  // Note that this cannot verify whether the original handle is closed.\n  auto_handle.Reset();\n  EXPECT_EQ(INVALID_HANDLE_VALUE, auto_handle.Get());\n\n  // Tests that Reset assigns the new handle.\n  // Note that this cannot verify whether the original handle is closed.\n  handle = ::CreateEvent(NULL, FALSE, FALSE, NULL);\n  ASSERT_NE(INVALID_HANDLE_VALUE, handle);\n  auto_handle.Reset(handle);\n  EXPECT_EQ(handle, auto_handle.Get());\n\n  // Tests that AutoHandle contains INVALID_HANDLE_VALUE by default.\n  testing::internal::AutoHandle auto_handle2;\n  EXPECT_EQ(INVALID_HANDLE_VALUE, auto_handle2.Get());\n}\n# endif  // GTEST_OS_WINDOWS\n\n# if GTEST_OS_WINDOWS\ntypedef unsigned __int64 BiggestParsable;\ntypedef signed __int64 BiggestSignedParsable;\n# else\ntypedef unsigned long long BiggestParsable;\ntypedef signed long long BiggestSignedParsable;\n# endif  // GTEST_OS_WINDOWS\n\n// We cannot use std::numeric_limits<T>::max() as it clashes with the\n// max() macro defined by <windows.h>.\nconst BiggestParsable kBiggestParsableMax = ULLONG_MAX;\nconst BiggestSignedParsable kBiggestSignedParsableMax = LLONG_MAX;\n\nTEST(ParseNaturalNumberTest, RejectsInvalidFormat) {\n  BiggestParsable result = 0;\n\n  // Rejects non-numbers.\n  EXPECT_FALSE(ParseNaturalNumber(\"non-number string\", &result));\n\n  // Rejects numbers with whitespace prefix.\n  EXPECT_FALSE(ParseNaturalNumber(\" 123\", &result));\n\n  // Rejects negative numbers.\n  EXPECT_FALSE(ParseNaturalNumber(\"-123\", &result));\n\n  // Rejects numbers starting with a plus sign.\n  EXPECT_FALSE(ParseNaturalNumber(\"+123\", &result));\n  errno = 0;\n}\n\nTEST(ParseNaturalNumberTest, RejectsOverflownNumbers) {\n  BiggestParsable result = 0;\n\n  EXPECT_FALSE(ParseNaturalNumber(\"99999999999999999999999\", &result));\n\n  signed char char_result = 0;\n  EXPECT_FALSE(ParseNaturalNumber(\"200\", &char_result));\n  errno = 0;\n}\n\nTEST(ParseNaturalNumberTest, AcceptsValidNumbers) {\n  BiggestParsable result = 0;\n\n  result = 0;\n  ASSERT_TRUE(ParseNaturalNumber(\"123\", &result));\n  EXPECT_EQ(123U, result);\n\n  // Check 0 as an edge case.\n  result = 1;\n  ASSERT_TRUE(ParseNaturalNumber(\"0\", &result));\n  EXPECT_EQ(0U, result);\n\n  result = 1;\n  ASSERT_TRUE(ParseNaturalNumber(\"00000\", &result));\n  EXPECT_EQ(0U, result);\n}\n\nTEST(ParseNaturalNumberTest, AcceptsTypeLimits) {\n  Message msg;\n  msg << kBiggestParsableMax;\n\n  BiggestParsable result = 0;\n  EXPECT_TRUE(ParseNaturalNumber(msg.GetString(), &result));\n  EXPECT_EQ(kBiggestParsableMax, result);\n\n  Message msg2;\n  msg2 << kBiggestSignedParsableMax;\n\n  BiggestSignedParsable signed_result = 0;\n  EXPECT_TRUE(ParseNaturalNumber(msg2.GetString(), &signed_result));\n  EXPECT_EQ(kBiggestSignedParsableMax, signed_result);\n\n  Message msg3;\n  msg3 << INT_MAX;\n\n  int int_result = 0;\n  EXPECT_TRUE(ParseNaturalNumber(msg3.GetString(), &int_result));\n  EXPECT_EQ(INT_MAX, int_result);\n\n  Message msg4;\n  msg4 << UINT_MAX;\n\n  unsigned int uint_result = 0;\n  EXPECT_TRUE(ParseNaturalNumber(msg4.GetString(), &uint_result));\n  EXPECT_EQ(UINT_MAX, uint_result);\n}\n\nTEST(ParseNaturalNumberTest, WorksForShorterIntegers) {\n  short short_result = 0;\n  ASSERT_TRUE(ParseNaturalNumber(\"123\", &short_result));\n  EXPECT_EQ(123, short_result);\n\n  signed char char_result = 0;\n  ASSERT_TRUE(ParseNaturalNumber(\"123\", &char_result));\n  EXPECT_EQ(123, char_result);\n}\n\n# if GTEST_OS_WINDOWS\nTEST(EnvironmentTest, HandleFitsIntoSizeT) {\n  // TODO(vladl@google.com): Remove this test after this condition is verified\n  // in a static assertion in gtest-death-test.cc in the function\n  // GetStatusFileDescriptor.\n  ASSERT_TRUE(sizeof(HANDLE) <= sizeof(size_t));\n}\n# endif  // GTEST_OS_WINDOWS\n\n// Tests that EXPECT_DEATH_IF_SUPPORTED/ASSERT_DEATH_IF_SUPPORTED trigger\n// failures when death tests are available on the system.\nTEST(ConditionalDeathMacrosDeathTest, ExpectsDeathWhenDeathTestsAvailable) {\n  EXPECT_DEATH_IF_SUPPORTED(DieInside(\"CondDeathTestExpectMacro\"),\n                            \"death inside CondDeathTestExpectMacro\");\n  ASSERT_DEATH_IF_SUPPORTED(DieInside(\"CondDeathTestAssertMacro\"),\n                            \"death inside CondDeathTestAssertMacro\");\n\n  // Empty statement will not crash, which must trigger a failure.\n  EXPECT_NONFATAL_FAILURE(EXPECT_DEATH_IF_SUPPORTED(;, \"\"), \"\");\n  EXPECT_FATAL_FAILURE(ASSERT_DEATH_IF_SUPPORTED(;, \"\"), \"\");\n}\n\n#else\n\nusing testing::internal::CaptureStderr;\nusing testing::internal::GetCapturedStderr;\n\n// Tests that EXPECT_DEATH_IF_SUPPORTED/ASSERT_DEATH_IF_SUPPORTED are still\n// defined but do not trigger failures when death tests are not available on\n// the system.\nTEST(ConditionalDeathMacrosTest, WarnsWhenDeathTestsNotAvailable) {\n  // Empty statement will not crash, but that should not trigger a failure\n  // when death tests are not supported.\n  CaptureStderr();\n  EXPECT_DEATH_IF_SUPPORTED(;, \"\");\n  std::string output = GetCapturedStderr();\n  ASSERT_TRUE(NULL != strstr(output.c_str(),\n                             \"Death tests are not supported on this platform\"));\n  ASSERT_TRUE(NULL != strstr(output.c_str(), \";\"));\n\n  // The streamed message should not be printed as there is no test failure.\n  CaptureStderr();\n  EXPECT_DEATH_IF_SUPPORTED(;, \"\") << \"streamed message\";\n  output = GetCapturedStderr();\n  ASSERT_TRUE(NULL == strstr(output.c_str(), \"streamed message\"));\n\n  CaptureStderr();\n  ASSERT_DEATH_IF_SUPPORTED(;, \"\");  // NOLINT\n  output = GetCapturedStderr();\n  ASSERT_TRUE(NULL != strstr(output.c_str(),\n                             \"Death tests are not supported on this platform\"));\n  ASSERT_TRUE(NULL != strstr(output.c_str(), \";\"));\n\n  CaptureStderr();\n  ASSERT_DEATH_IF_SUPPORTED(;, \"\") << \"streamed message\";  // NOLINT\n  output = GetCapturedStderr();\n  ASSERT_TRUE(NULL == strstr(output.c_str(), \"streamed message\"));\n}\n\nvoid FuncWithAssert(int* n) {\n  ASSERT_DEATH_IF_SUPPORTED(return;, \"\");\n  (*n)++;\n}\n\n// Tests that ASSERT_DEATH_IF_SUPPORTED does not return from the current\n// function (as ASSERT_DEATH does) if death tests are not supported.\nTEST(ConditionalDeathMacrosTest, AssertDeatDoesNotReturnhIfUnsupported) {\n  int n = 0;\n  FuncWithAssert(&n);\n  EXPECT_EQ(1, n);\n}\n\nTEST(InDeathTestChildDeathTest, ReportsDeathTestCorrectlyInFastStyle) {\n  testing::GTEST_FLAG(death_test_style) = \"fast\";\n  EXPECT_FALSE(InDeathTestChild());\n  EXPECT_DEATH({\n    fprintf(stderr, InDeathTestChild() ? \"Inside\" : \"Outside\");\n    fflush(stderr);\n    _exit(1);\n  }, \"Inside\");\n}\n\nTEST(InDeathTestChildDeathTest, ReportsDeathTestCorrectlyInThreadSafeStyle) {\n  testing::GTEST_FLAG(death_test_style) = \"threadsafe\";\n  EXPECT_FALSE(InDeathTestChild());\n  EXPECT_DEATH({\n    fprintf(stderr, InDeathTestChild() ? \"Inside\" : \"Outside\");\n    fflush(stderr);\n    _exit(1);\n  }, \"Inside\");\n}\n\n#endif  // GTEST_HAS_DEATH_TEST\n\n// Tests that the death test macros expand to code which may or may not\n// be followed by operator<<, and that in either case the complete text\n// comprises only a single C++ statement.\n//\n// The syntax should work whether death tests are available or not.\nTEST(ConditionalDeathMacrosSyntaxDeathTest, SingleStatement) {\n  if (AlwaysFalse())\n    // This would fail if executed; this is a compilation test only\n    ASSERT_DEATH_IF_SUPPORTED(return, \"\");\n\n  if (AlwaysTrue())\n    EXPECT_DEATH_IF_SUPPORTED(_exit(1), \"\");\n  else\n    // This empty \"else\" branch is meant to ensure that EXPECT_DEATH\n    // doesn't expand into an \"if\" statement without an \"else\"\n    ;  // NOLINT\n\n  if (AlwaysFalse())\n    ASSERT_DEATH_IF_SUPPORTED(return, \"\") << \"did not die\";\n\n  if (AlwaysFalse())\n    ;  // NOLINT\n  else\n    EXPECT_DEATH_IF_SUPPORTED(_exit(1), \"\") << 1 << 2 << 3;\n}\n\n// Tests that conditional death test macros expand to code which interacts\n// well with switch statements.\nTEST(ConditionalDeathMacrosSyntaxDeathTest, SwitchStatement) {\n// Microsoft compiler usually complains about switch statements without\n// case labels. We suppress that warning for this test.\n#ifdef _MSC_VER\n# pragma warning(push)\n# pragma warning(disable: 4065)\n#endif  // _MSC_VER\n\n  switch (0)\n    default:\n      ASSERT_DEATH_IF_SUPPORTED(_exit(1), \"\")\n          << \"exit in default switch handler\";\n\n  switch (0)\n    case 0:\n      EXPECT_DEATH_IF_SUPPORTED(_exit(1), \"\") << \"exit in switch case\";\n\n#ifdef _MSC_VER\n# pragma warning(pop)\n#endif  // _MSC_VER\n}\n\n// Tests that a test case whose name ends with \"DeathTest\" works fine\n// on Windows.\nTEST(NotADeathTest, Test) {\n  SUCCEED();\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest-filepath_test.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: keith.ray@gmail.com (Keith Ray)\n//\n// Google Test filepath utilities\n//\n// This file tests classes and functions used internally by\n// Google Test.  They are subject to change without notice.\n//\n// This file is #included from gtest_unittest.cc, to avoid changing\n// build or make-files for some existing Google Test clients. Do not\n// #include this file anywhere else!\n\n#include \"gtest/internal/gtest-filepath.h\"\n#include \"gtest/gtest.h\"\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick is to\n// prevent a user from accidentally including gtest-internal-inl.h in\n// his code.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\n#if GTEST_OS_WINDOWS_MOBILE\n# include <windows.h>  // NOLINT\n#elif GTEST_OS_WINDOWS\n# include <direct.h>  // NOLINT\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\nnamespace testing {\nnamespace internal {\nnamespace {\n\n#if GTEST_OS_WINDOWS_MOBILE\n// TODO(wan@google.com): Move these to the POSIX adapter section in\n// gtest-port.h.\n\n// Windows CE doesn't have the remove C function.\nint remove(const char* path) {\n  LPCWSTR wpath = String::AnsiToUtf16(path);\n  int ret = DeleteFile(wpath) ? 0 : -1;\n  delete [] wpath;\n  return ret;\n}\n// Windows CE doesn't have the _rmdir C function.\nint _rmdir(const char* path) {\n  FilePath filepath(path);\n  LPCWSTR wpath = String::AnsiToUtf16(\n      filepath.RemoveTrailingPathSeparator().c_str());\n  int ret = RemoveDirectory(wpath) ? 0 : -1;\n  delete [] wpath;\n  return ret;\n}\n\n#else\n\nTEST(GetCurrentDirTest, ReturnsCurrentDir) {\n  const FilePath original_dir = FilePath::GetCurrentDir();\n  EXPECT_FALSE(original_dir.IsEmpty());\n\n  posix::ChDir(GTEST_PATH_SEP_);\n  const FilePath cwd = FilePath::GetCurrentDir();\n  posix::ChDir(original_dir.c_str());\n\n# if GTEST_OS_WINDOWS\n\n  // Skips the \":\".\n  const char* const cwd_without_drive = strchr(cwd.c_str(), ':');\n  ASSERT_TRUE(cwd_without_drive != NULL);\n  EXPECT_STREQ(GTEST_PATH_SEP_, cwd_without_drive + 1);\n\n# else\n\n  EXPECT_EQ(GTEST_PATH_SEP_, cwd.string());\n\n# endif\n}\n\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\nTEST(IsEmptyTest, ReturnsTrueForEmptyPath) {\n  EXPECT_TRUE(FilePath(\"\").IsEmpty());\n}\n\nTEST(IsEmptyTest, ReturnsFalseForNonEmptyPath) {\n  EXPECT_FALSE(FilePath(\"a\").IsEmpty());\n  EXPECT_FALSE(FilePath(\".\").IsEmpty());\n  EXPECT_FALSE(FilePath(\"a/b\").IsEmpty());\n  EXPECT_FALSE(FilePath(\"a\\\\b\\\\\").IsEmpty());\n}\n\n// RemoveDirectoryName \"\" -> \"\"\nTEST(RemoveDirectoryNameTest, WhenEmptyName) {\n  EXPECT_EQ(\"\", FilePath(\"\").RemoveDirectoryName().string());\n}\n\n// RemoveDirectoryName \"afile\" -> \"afile\"\nTEST(RemoveDirectoryNameTest, ButNoDirectory) {\n  EXPECT_EQ(\"afile\",\n      FilePath(\"afile\").RemoveDirectoryName().string());\n}\n\n// RemoveDirectoryName \"/afile\" -> \"afile\"\nTEST(RemoveDirectoryNameTest, RootFileShouldGiveFileName) {\n  EXPECT_EQ(\"afile\",\n      FilePath(GTEST_PATH_SEP_ \"afile\").RemoveDirectoryName().string());\n}\n\n// RemoveDirectoryName \"adir/\" -> \"\"\nTEST(RemoveDirectoryNameTest, WhereThereIsNoFileName) {\n  EXPECT_EQ(\"\",\n      FilePath(\"adir\" GTEST_PATH_SEP_).RemoveDirectoryName().string());\n}\n\n// RemoveDirectoryName \"adir/afile\" -> \"afile\"\nTEST(RemoveDirectoryNameTest, ShouldGiveFileName) {\n  EXPECT_EQ(\"afile\",\n      FilePath(\"adir\" GTEST_PATH_SEP_ \"afile\").RemoveDirectoryName().string());\n}\n\n// RemoveDirectoryName \"adir/subdir/afile\" -> \"afile\"\nTEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileName) {\n  EXPECT_EQ(\"afile\",\n      FilePath(\"adir\" GTEST_PATH_SEP_ \"subdir\" GTEST_PATH_SEP_ \"afile\")\n      .RemoveDirectoryName().string());\n}\n\n#if GTEST_HAS_ALT_PATH_SEP_\n\n// Tests that RemoveDirectoryName() works with the alternate separator\n// on Windows.\n\n// RemoveDirectoryName(\"/afile\") -> \"afile\"\nTEST(RemoveDirectoryNameTest, RootFileShouldGiveFileNameForAlternateSeparator) {\n  EXPECT_EQ(\"afile\", FilePath(\"/afile\").RemoveDirectoryName().string());\n}\n\n// RemoveDirectoryName(\"adir/\") -> \"\"\nTEST(RemoveDirectoryNameTest, WhereThereIsNoFileNameForAlternateSeparator) {\n  EXPECT_EQ(\"\", FilePath(\"adir/\").RemoveDirectoryName().string());\n}\n\n// RemoveDirectoryName(\"adir/afile\") -> \"afile\"\nTEST(RemoveDirectoryNameTest, ShouldGiveFileNameForAlternateSeparator) {\n  EXPECT_EQ(\"afile\", FilePath(\"adir/afile\").RemoveDirectoryName().string());\n}\n\n// RemoveDirectoryName(\"adir/subdir/afile\") -> \"afile\"\nTEST(RemoveDirectoryNameTest, ShouldAlsoGiveFileNameForAlternateSeparator) {\n  EXPECT_EQ(\"afile\",\n            FilePath(\"adir/subdir/afile\").RemoveDirectoryName().string());\n}\n\n#endif\n\n// RemoveFileName \"\" -> \"./\"\nTEST(RemoveFileNameTest, EmptyName) {\n#if GTEST_OS_WINDOWS_MOBILE\n  // On Windows CE, we use the root as the current directory.\n  EXPECT_EQ(GTEST_PATH_SEP_, FilePath(\"\").RemoveFileName().string());\n#else\n  EXPECT_EQ(\".\" GTEST_PATH_SEP_, FilePath(\"\").RemoveFileName().string());\n#endif\n}\n\n// RemoveFileName \"adir/\" -> \"adir/\"\nTEST(RemoveFileNameTest, ButNoFile) {\n  EXPECT_EQ(\"adir\" GTEST_PATH_SEP_,\n      FilePath(\"adir\" GTEST_PATH_SEP_).RemoveFileName().string());\n}\n\n// RemoveFileName \"adir/afile\" -> \"adir/\"\nTEST(RemoveFileNameTest, GivesDirName) {\n  EXPECT_EQ(\"adir\" GTEST_PATH_SEP_,\n            FilePath(\"adir\" GTEST_PATH_SEP_ \"afile\").RemoveFileName().string());\n}\n\n// RemoveFileName \"adir/subdir/afile\" -> \"adir/subdir/\"\nTEST(RemoveFileNameTest, GivesDirAndSubDirName) {\n  EXPECT_EQ(\"adir\" GTEST_PATH_SEP_ \"subdir\" GTEST_PATH_SEP_,\n      FilePath(\"adir\" GTEST_PATH_SEP_ \"subdir\" GTEST_PATH_SEP_ \"afile\")\n      .RemoveFileName().string());\n}\n\n// RemoveFileName \"/afile\" -> \"/\"\nTEST(RemoveFileNameTest, GivesRootDir) {\n  EXPECT_EQ(GTEST_PATH_SEP_,\n      FilePath(GTEST_PATH_SEP_ \"afile\").RemoveFileName().string());\n}\n\n#if GTEST_HAS_ALT_PATH_SEP_\n\n// Tests that RemoveFileName() works with the alternate separator on\n// Windows.\n\n// RemoveFileName(\"adir/\") -> \"adir/\"\nTEST(RemoveFileNameTest, ButNoFileForAlternateSeparator) {\n  EXPECT_EQ(\"adir\" GTEST_PATH_SEP_,\n            FilePath(\"adir/\").RemoveFileName().string());\n}\n\n// RemoveFileName(\"adir/afile\") -> \"adir/\"\nTEST(RemoveFileNameTest, GivesDirNameForAlternateSeparator) {\n  EXPECT_EQ(\"adir\" GTEST_PATH_SEP_,\n            FilePath(\"adir/afile\").RemoveFileName().string());\n}\n\n// RemoveFileName(\"adir/subdir/afile\") -> \"adir/subdir/\"\nTEST(RemoveFileNameTest, GivesDirAndSubDirNameForAlternateSeparator) {\n  EXPECT_EQ(\"adir\" GTEST_PATH_SEP_ \"subdir\" GTEST_PATH_SEP_,\n            FilePath(\"adir/subdir/afile\").RemoveFileName().string());\n}\n\n// RemoveFileName(\"/afile\") -> \"\\\"\nTEST(RemoveFileNameTest, GivesRootDirForAlternateSeparator) {\n  EXPECT_EQ(GTEST_PATH_SEP_, FilePath(\"/afile\").RemoveFileName().string());\n}\n\n#endif\n\nTEST(MakeFileNameTest, GenerateWhenNumberIsZero) {\n  FilePath actual = FilePath::MakeFileName(FilePath(\"foo\"), FilePath(\"bar\"),\n      0, \"xml\");\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar.xml\", actual.string());\n}\n\nTEST(MakeFileNameTest, GenerateFileNameNumberGtZero) {\n  FilePath actual = FilePath::MakeFileName(FilePath(\"foo\"), FilePath(\"bar\"),\n      12, \"xml\");\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar_12.xml\", actual.string());\n}\n\nTEST(MakeFileNameTest, GenerateFileNameWithSlashNumberIsZero) {\n  FilePath actual = FilePath::MakeFileName(FilePath(\"foo\" GTEST_PATH_SEP_),\n      FilePath(\"bar\"), 0, \"xml\");\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar.xml\", actual.string());\n}\n\nTEST(MakeFileNameTest, GenerateFileNameWithSlashNumberGtZero) {\n  FilePath actual = FilePath::MakeFileName(FilePath(\"foo\" GTEST_PATH_SEP_),\n      FilePath(\"bar\"), 12, \"xml\");\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar_12.xml\", actual.string());\n}\n\nTEST(MakeFileNameTest, GenerateWhenNumberIsZeroAndDirIsEmpty) {\n  FilePath actual = FilePath::MakeFileName(FilePath(\"\"), FilePath(\"bar\"),\n      0, \"xml\");\n  EXPECT_EQ(\"bar.xml\", actual.string());\n}\n\nTEST(MakeFileNameTest, GenerateWhenNumberIsNotZeroAndDirIsEmpty) {\n  FilePath actual = FilePath::MakeFileName(FilePath(\"\"), FilePath(\"bar\"),\n      14, \"xml\");\n  EXPECT_EQ(\"bar_14.xml\", actual.string());\n}\n\nTEST(ConcatPathsTest, WorksWhenDirDoesNotEndWithPathSep) {\n  FilePath actual = FilePath::ConcatPaths(FilePath(\"foo\"),\n                                          FilePath(\"bar.xml\"));\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar.xml\", actual.string());\n}\n\nTEST(ConcatPathsTest, WorksWhenPath1EndsWithPathSep) {\n  FilePath actual = FilePath::ConcatPaths(FilePath(\"foo\" GTEST_PATH_SEP_),\n                                          FilePath(\"bar.xml\"));\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar.xml\", actual.string());\n}\n\nTEST(ConcatPathsTest, Path1BeingEmpty) {\n  FilePath actual = FilePath::ConcatPaths(FilePath(\"\"),\n                                          FilePath(\"bar.xml\"));\n  EXPECT_EQ(\"bar.xml\", actual.string());\n}\n\nTEST(ConcatPathsTest, Path2BeingEmpty) {\n  FilePath actual = FilePath::ConcatPaths(FilePath(\"foo\"), FilePath(\"\"));\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_, actual.string());\n}\n\nTEST(ConcatPathsTest, BothPathBeingEmpty) {\n  FilePath actual = FilePath::ConcatPaths(FilePath(\"\"),\n                                          FilePath(\"\"));\n  EXPECT_EQ(\"\", actual.string());\n}\n\nTEST(ConcatPathsTest, Path1ContainsPathSep) {\n  FilePath actual = FilePath::ConcatPaths(FilePath(\"foo\" GTEST_PATH_SEP_ \"bar\"),\n                                          FilePath(\"foobar.xml\"));\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar\" GTEST_PATH_SEP_ \"foobar.xml\",\n            actual.string());\n}\n\nTEST(ConcatPathsTest, Path2ContainsPathSep) {\n  FilePath actual = FilePath::ConcatPaths(\n      FilePath(\"foo\" GTEST_PATH_SEP_),\n      FilePath(\"bar\" GTEST_PATH_SEP_ \"bar.xml\"));\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar\" GTEST_PATH_SEP_ \"bar.xml\",\n            actual.string());\n}\n\nTEST(ConcatPathsTest, Path2EndsWithPathSep) {\n  FilePath actual = FilePath::ConcatPaths(FilePath(\"foo\"),\n                                          FilePath(\"bar\" GTEST_PATH_SEP_));\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar\" GTEST_PATH_SEP_, actual.string());\n}\n\n// RemoveTrailingPathSeparator \"\" -> \"\"\nTEST(RemoveTrailingPathSeparatorTest, EmptyString) {\n  EXPECT_EQ(\"\", FilePath(\"\").RemoveTrailingPathSeparator().string());\n}\n\n// RemoveTrailingPathSeparator \"foo\" -> \"foo\"\nTEST(RemoveTrailingPathSeparatorTest, FileNoSlashString) {\n  EXPECT_EQ(\"foo\", FilePath(\"foo\").RemoveTrailingPathSeparator().string());\n}\n\n// RemoveTrailingPathSeparator \"foo/\" -> \"foo\"\nTEST(RemoveTrailingPathSeparatorTest, ShouldRemoveTrailingSeparator) {\n  EXPECT_EQ(\"foo\",\n      FilePath(\"foo\" GTEST_PATH_SEP_).RemoveTrailingPathSeparator().string());\n#if GTEST_HAS_ALT_PATH_SEP_\n  EXPECT_EQ(\"foo\", FilePath(\"foo/\").RemoveTrailingPathSeparator().string());\n#endif\n}\n\n// RemoveTrailingPathSeparator \"foo/bar/\" -> \"foo/bar/\"\nTEST(RemoveTrailingPathSeparatorTest, ShouldRemoveLastSeparator) {\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar\",\n            FilePath(\"foo\" GTEST_PATH_SEP_ \"bar\" GTEST_PATH_SEP_)\n                .RemoveTrailingPathSeparator().string());\n}\n\n// RemoveTrailingPathSeparator \"foo/bar\" -> \"foo/bar\"\nTEST(RemoveTrailingPathSeparatorTest, ShouldReturnUnmodified) {\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar\",\n            FilePath(\"foo\" GTEST_PATH_SEP_ \"bar\")\n                .RemoveTrailingPathSeparator().string());\n}\n\nTEST(DirectoryTest, RootDirectoryExists) {\n#if GTEST_OS_WINDOWS  // We are on Windows.\n  char current_drive[_MAX_PATH];  // NOLINT\n  current_drive[0] = static_cast<char>(_getdrive() + 'A' - 1);\n  current_drive[1] = ':';\n  current_drive[2] = '\\\\';\n  current_drive[3] = '\\0';\n  EXPECT_TRUE(FilePath(current_drive).DirectoryExists());\n#else\n  EXPECT_TRUE(FilePath(\"/\").DirectoryExists());\n#endif  // GTEST_OS_WINDOWS\n}\n\n#if GTEST_OS_WINDOWS\nTEST(DirectoryTest, RootOfWrongDriveDoesNotExists) {\n  const int saved_drive_ = _getdrive();\n  // Find a drive that doesn't exist. Start with 'Z' to avoid common ones.\n  for (char drive = 'Z'; drive >= 'A'; drive--)\n    if (_chdrive(drive - 'A' + 1) == -1) {\n      char non_drive[_MAX_PATH];  // NOLINT\n      non_drive[0] = drive;\n      non_drive[1] = ':';\n      non_drive[2] = '\\\\';\n      non_drive[3] = '\\0';\n      EXPECT_FALSE(FilePath(non_drive).DirectoryExists());\n      break;\n    }\n  _chdrive(saved_drive_);\n}\n#endif  // GTEST_OS_WINDOWS\n\n#if !GTEST_OS_WINDOWS_MOBILE\n// Windows CE _does_ consider an empty directory to exist.\nTEST(DirectoryTest, EmptyPathDirectoryDoesNotExist) {\n  EXPECT_FALSE(FilePath(\"\").DirectoryExists());\n}\n#endif  // !GTEST_OS_WINDOWS_MOBILE\n\nTEST(DirectoryTest, CurrentDirectoryExists) {\n#if GTEST_OS_WINDOWS  // We are on Windows.\n# ifndef _WIN32_CE  // Windows CE doesn't have a current directory.\n\n  EXPECT_TRUE(FilePath(\".\").DirectoryExists());\n  EXPECT_TRUE(FilePath(\".\\\\\").DirectoryExists());\n\n# endif  // _WIN32_CE\n#else\n  EXPECT_TRUE(FilePath(\".\").DirectoryExists());\n  EXPECT_TRUE(FilePath(\"./\").DirectoryExists());\n#endif  // GTEST_OS_WINDOWS\n}\n\n// \"foo/bar\" == foo//bar\" == \"foo///bar\"\nTEST(NormalizeTest, MultipleConsecutiveSepaparatorsInMidstring) {\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar\",\n            FilePath(\"foo\" GTEST_PATH_SEP_ \"bar\").string());\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar\",\n            FilePath(\"foo\" GTEST_PATH_SEP_ GTEST_PATH_SEP_ \"bar\").string());\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_ \"bar\",\n            FilePath(\"foo\" GTEST_PATH_SEP_ GTEST_PATH_SEP_\n                     GTEST_PATH_SEP_ \"bar\").string());\n}\n\n// \"/bar\" == //bar\" == \"///bar\"\nTEST(NormalizeTest, MultipleConsecutiveSepaparatorsAtStringStart) {\n  EXPECT_EQ(GTEST_PATH_SEP_ \"bar\",\n    FilePath(GTEST_PATH_SEP_ \"bar\").string());\n  EXPECT_EQ(GTEST_PATH_SEP_ \"bar\",\n    FilePath(GTEST_PATH_SEP_ GTEST_PATH_SEP_ \"bar\").string());\n  EXPECT_EQ(GTEST_PATH_SEP_ \"bar\",\n    FilePath(GTEST_PATH_SEP_ GTEST_PATH_SEP_ GTEST_PATH_SEP_ \"bar\").string());\n}\n\n// \"foo/\" == foo//\" == \"foo///\"\nTEST(NormalizeTest, MultipleConsecutiveSepaparatorsAtStringEnd) {\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_,\n    FilePath(\"foo\" GTEST_PATH_SEP_).string());\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_,\n    FilePath(\"foo\" GTEST_PATH_SEP_ GTEST_PATH_SEP_).string());\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_,\n    FilePath(\"foo\" GTEST_PATH_SEP_ GTEST_PATH_SEP_ GTEST_PATH_SEP_).string());\n}\n\n#if GTEST_HAS_ALT_PATH_SEP_\n\n// Tests that separators at the end of the string are normalized\n// regardless of their combination (e.g. \"foo\\\" ==\"foo/\\\" ==\n// \"foo\\\\/\").\nTEST(NormalizeTest, MixAlternateSeparatorAtStringEnd) {\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_,\n            FilePath(\"foo/\").string());\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_,\n            FilePath(\"foo\" GTEST_PATH_SEP_ \"/\").string());\n  EXPECT_EQ(\"foo\" GTEST_PATH_SEP_,\n            FilePath(\"foo//\" GTEST_PATH_SEP_).string());\n}\n\n#endif\n\nTEST(AssignmentOperatorTest, DefaultAssignedToNonDefault) {\n  FilePath default_path;\n  FilePath non_default_path(\"path\");\n  non_default_path = default_path;\n  EXPECT_EQ(\"\", non_default_path.string());\n  EXPECT_EQ(\"\", default_path.string());  // RHS var is unchanged.\n}\n\nTEST(AssignmentOperatorTest, NonDefaultAssignedToDefault) {\n  FilePath non_default_path(\"path\");\n  FilePath default_path;\n  default_path = non_default_path;\n  EXPECT_EQ(\"path\", default_path.string());\n  EXPECT_EQ(\"path\", non_default_path.string());  // RHS var is unchanged.\n}\n\nTEST(AssignmentOperatorTest, ConstAssignedToNonConst) {\n  const FilePath const_default_path(\"const_path\");\n  FilePath non_default_path(\"path\");\n  non_default_path = const_default_path;\n  EXPECT_EQ(\"const_path\", non_default_path.string());\n}\n\nclass DirectoryCreationTest : public Test {\n protected:\n  virtual void SetUp() {\n    testdata_path_.Set(FilePath(\n        TempDir() + GetCurrentExecutableName().string() +\n        \"_directory_creation\" GTEST_PATH_SEP_ \"test\" GTEST_PATH_SEP_));\n    testdata_file_.Set(testdata_path_.RemoveTrailingPathSeparator());\n\n    unique_file0_.Set(FilePath::MakeFileName(testdata_path_, FilePath(\"unique\"),\n        0, \"txt\"));\n    unique_file1_.Set(FilePath::MakeFileName(testdata_path_, FilePath(\"unique\"),\n        1, \"txt\"));\n\n    remove(testdata_file_.c_str());\n    remove(unique_file0_.c_str());\n    remove(unique_file1_.c_str());\n    posix::RmDir(testdata_path_.c_str());\n  }\n\n  virtual void TearDown() {\n    remove(testdata_file_.c_str());\n    remove(unique_file0_.c_str());\n    remove(unique_file1_.c_str());\n    posix::RmDir(testdata_path_.c_str());\n  }\n\n  std::string TempDir() const {\n#if GTEST_OS_WINDOWS_MOBILE\n    return \"\\\\temp\\\\\";\n#elif GTEST_OS_WINDOWS\n    const char* temp_dir = posix::GetEnv(\"TEMP\");\n    if (temp_dir == NULL || temp_dir[0] == '\\0')\n      return \"\\\\temp\\\\\";\n    else if (temp_dir[strlen(temp_dir) - 1] == '\\\\')\n      return temp_dir;\n    else\n      return std::string(temp_dir) + \"\\\\\";\n#elif GTEST_OS_LINUX_ANDROID\n    return \"/sdcard/\";\n#else\n    return \"/tmp/\";\n#endif  // GTEST_OS_WINDOWS_MOBILE\n  }\n\n  void CreateTextFile(const char* filename) {\n    FILE* f = posix::FOpen(filename, \"w\");\n    fprintf(f, \"text\\n\");\n    fclose(f);\n  }\n\n  // Strings representing a directory and a file, with identical paths\n  // except for the trailing separator character that distinquishes\n  // a directory named 'test' from a file named 'test'. Example names:\n  FilePath testdata_path_;  // \"/tmp/directory_creation/test/\"\n  FilePath testdata_file_;  // \"/tmp/directory_creation/test\"\n  FilePath unique_file0_;  // \"/tmp/directory_creation/test/unique.txt\"\n  FilePath unique_file1_;  // \"/tmp/directory_creation/test/unique_1.txt\"\n};\n\nTEST_F(DirectoryCreationTest, CreateDirectoriesRecursively) {\n  EXPECT_FALSE(testdata_path_.DirectoryExists()) << testdata_path_.string();\n  EXPECT_TRUE(testdata_path_.CreateDirectoriesRecursively());\n  EXPECT_TRUE(testdata_path_.DirectoryExists());\n}\n\nTEST_F(DirectoryCreationTest, CreateDirectoriesForAlreadyExistingPath) {\n  EXPECT_FALSE(testdata_path_.DirectoryExists()) << testdata_path_.string();\n  EXPECT_TRUE(testdata_path_.CreateDirectoriesRecursively());\n  // Call 'create' again... should still succeed.\n  EXPECT_TRUE(testdata_path_.CreateDirectoriesRecursively());\n}\n\nTEST_F(DirectoryCreationTest, CreateDirectoriesAndUniqueFilename) {\n  FilePath file_path(FilePath::GenerateUniqueFileName(testdata_path_,\n      FilePath(\"unique\"), \"txt\"));\n  EXPECT_EQ(unique_file0_.string(), file_path.string());\n  EXPECT_FALSE(file_path.FileOrDirectoryExists());  // file not there\n\n  testdata_path_.CreateDirectoriesRecursively();\n  EXPECT_FALSE(file_path.FileOrDirectoryExists());  // file still not there\n  CreateTextFile(file_path.c_str());\n  EXPECT_TRUE(file_path.FileOrDirectoryExists());\n\n  FilePath file_path2(FilePath::GenerateUniqueFileName(testdata_path_,\n      FilePath(\"unique\"), \"txt\"));\n  EXPECT_EQ(unique_file1_.string(), file_path2.string());\n  EXPECT_FALSE(file_path2.FileOrDirectoryExists());  // file not there\n  CreateTextFile(file_path2.c_str());\n  EXPECT_TRUE(file_path2.FileOrDirectoryExists());\n}\n\nTEST_F(DirectoryCreationTest, CreateDirectoriesFail) {\n  // force a failure by putting a file where we will try to create a directory.\n  CreateTextFile(testdata_file_.c_str());\n  EXPECT_TRUE(testdata_file_.FileOrDirectoryExists());\n  EXPECT_FALSE(testdata_file_.DirectoryExists());\n  EXPECT_FALSE(testdata_file_.CreateDirectoriesRecursively());\n}\n\nTEST(NoDirectoryCreationTest, CreateNoDirectoriesForDefaultXmlFile) {\n  const FilePath test_detail_xml(\"test_detail.xml\");\n  EXPECT_FALSE(test_detail_xml.CreateDirectoriesRecursively());\n}\n\nTEST(FilePathTest, DefaultConstructor) {\n  FilePath fp;\n  EXPECT_EQ(\"\", fp.string());\n}\n\nTEST(FilePathTest, CharAndCopyConstructors) {\n  const FilePath fp(\"spicy\");\n  EXPECT_EQ(\"spicy\", fp.string());\n\n  const FilePath fp_copy(fp);\n  EXPECT_EQ(\"spicy\", fp_copy.string());\n}\n\nTEST(FilePathTest, StringConstructor) {\n  const FilePath fp(std::string(\"cider\"));\n  EXPECT_EQ(\"cider\", fp.string());\n}\n\nTEST(FilePathTest, Set) {\n  const FilePath apple(\"apple\");\n  FilePath mac(\"mac\");\n  mac.Set(apple);  // Implement Set() since overloading operator= is forbidden.\n  EXPECT_EQ(\"apple\", mac.string());\n  EXPECT_EQ(\"apple\", apple.string());\n}\n\nTEST(FilePathTest, ToString) {\n  const FilePath file(\"drink\");\n  EXPECT_EQ(\"drink\", file.string());\n}\n\nTEST(FilePathTest, RemoveExtension) {\n  EXPECT_EQ(\"app\", FilePath(\"app.cc\").RemoveExtension(\"cc\").string());\n  EXPECT_EQ(\"app\", FilePath(\"app.exe\").RemoveExtension(\"exe\").string());\n  EXPECT_EQ(\"APP\", FilePath(\"APP.EXE\").RemoveExtension(\"exe\").string());\n}\n\nTEST(FilePathTest, RemoveExtensionWhenThereIsNoExtension) {\n  EXPECT_EQ(\"app\", FilePath(\"app\").RemoveExtension(\"exe\").string());\n}\n\nTEST(FilePathTest, IsDirectory) {\n  EXPECT_FALSE(FilePath(\"cola\").IsDirectory());\n  EXPECT_TRUE(FilePath(\"koala\" GTEST_PATH_SEP_).IsDirectory());\n#if GTEST_HAS_ALT_PATH_SEP_\n  EXPECT_TRUE(FilePath(\"koala/\").IsDirectory());\n#endif\n}\n\nTEST(FilePathTest, IsAbsolutePath) {\n  EXPECT_FALSE(FilePath(\"is\" GTEST_PATH_SEP_ \"relative\").IsAbsolutePath());\n  EXPECT_FALSE(FilePath(\"\").IsAbsolutePath());\n#if GTEST_OS_WINDOWS\n  EXPECT_TRUE(FilePath(\"c:\\\\\" GTEST_PATH_SEP_ \"is_not\"\n                       GTEST_PATH_SEP_ \"relative\").IsAbsolutePath());\n  EXPECT_FALSE(FilePath(\"c:foo\" GTEST_PATH_SEP_ \"bar\").IsAbsolutePath());\n  EXPECT_TRUE(FilePath(\"c:/\" GTEST_PATH_SEP_ \"is_not\"\n                       GTEST_PATH_SEP_ \"relative\").IsAbsolutePath());\n#else\n  EXPECT_TRUE(FilePath(GTEST_PATH_SEP_ \"is_not\" GTEST_PATH_SEP_ \"relative\")\n              .IsAbsolutePath());\n#endif  // GTEST_OS_WINDOWS\n}\n\nTEST(FilePathTest, IsRootDirectory) {\n#if GTEST_OS_WINDOWS\n  EXPECT_TRUE(FilePath(\"a:\\\\\").IsRootDirectory());\n  EXPECT_TRUE(FilePath(\"Z:/\").IsRootDirectory());\n  EXPECT_TRUE(FilePath(\"e://\").IsRootDirectory());\n  EXPECT_FALSE(FilePath(\"\").IsRootDirectory());\n  EXPECT_FALSE(FilePath(\"b:\").IsRootDirectory());\n  EXPECT_FALSE(FilePath(\"b:a\").IsRootDirectory());\n  EXPECT_FALSE(FilePath(\"8:/\").IsRootDirectory());\n  EXPECT_FALSE(FilePath(\"c|/\").IsRootDirectory());\n#else\n  EXPECT_TRUE(FilePath(\"/\").IsRootDirectory());\n  EXPECT_TRUE(FilePath(\"//\").IsRootDirectory());\n  EXPECT_FALSE(FilePath(\"\").IsRootDirectory());\n  EXPECT_FALSE(FilePath(\"\\\\\").IsRootDirectory());\n  EXPECT_FALSE(FilePath(\"/x\").IsRootDirectory());\n#endif\n}\n\n}  // namespace\n}  // namespace internal\n}  // namespace testing\n"
  },
  {
    "path": "ext/gtest/test/gtest-linked_ptr_test.cc",
    "content": "// Copyright 2003, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: Dan Egnor (egnor@google.com)\n// Ported to Windows: Vadim Berman (vadimb@google.com)\n\n#include \"gtest/internal/gtest-linked_ptr.h\"\n\n#include <stdlib.h>\n#include \"gtest/gtest.h\"\n\nnamespace {\n\nusing testing::Message;\nusing testing::internal::linked_ptr;\n\nint num;\nMessage* history = NULL;\n\n// Class which tracks allocation/deallocation\nclass A {\n public:\n  A(): mynum(num++) { *history << \"A\" << mynum << \" ctor\\n\"; }\n  virtual ~A() { *history << \"A\" << mynum << \" dtor\\n\"; }\n  virtual void Use() { *history << \"A\" << mynum << \" use\\n\"; }\n protected:\n  int mynum;\n};\n\n// Subclass\nclass B : public A {\n public:\n  B() { *history << \"B\" << mynum << \" ctor\\n\"; }\n  ~B() { *history << \"B\" << mynum << \" dtor\\n\"; }\n  virtual void Use() { *history << \"B\" << mynum << \" use\\n\"; }\n};\n\nclass LinkedPtrTest : public testing::Test {\n public:\n  LinkedPtrTest() {\n    num = 0;\n    history = new Message;\n  }\n\n  virtual ~LinkedPtrTest() {\n    delete history;\n    history = NULL;\n  }\n};\n\nTEST_F(LinkedPtrTest, GeneralTest) {\n  {\n    linked_ptr<A> a0, a1, a2;\n    // Use explicit function call notation here to suppress self-assign warning.\n    a0.operator=(a0);\n    a1 = a2;\n    ASSERT_EQ(a0.get(), static_cast<A*>(NULL));\n    ASSERT_EQ(a1.get(), static_cast<A*>(NULL));\n    ASSERT_EQ(a2.get(), static_cast<A*>(NULL));\n    ASSERT_TRUE(a0 == NULL);\n    ASSERT_TRUE(a1 == NULL);\n    ASSERT_TRUE(a2 == NULL);\n\n    {\n      linked_ptr<A> a3(new A);\n      a0 = a3;\n      ASSERT_TRUE(a0 == a3);\n      ASSERT_TRUE(a0 != NULL);\n      ASSERT_TRUE(a0.get() == a3);\n      ASSERT_TRUE(a0 == a3.get());\n      linked_ptr<A> a4(a0);\n      a1 = a4;\n      linked_ptr<A> a5(new A);\n      ASSERT_TRUE(a5.get() != a3);\n      ASSERT_TRUE(a5 != a3.get());\n      a2 = a5;\n      linked_ptr<B> b0(new B);\n      linked_ptr<A> a6(b0);\n      ASSERT_TRUE(b0 == a6);\n      ASSERT_TRUE(a6 == b0);\n      ASSERT_TRUE(b0 != NULL);\n      a5 = b0;\n      a5 = b0;\n      a3->Use();\n      a4->Use();\n      a5->Use();\n      a6->Use();\n      b0->Use();\n      (*b0).Use();\n      b0.get()->Use();\n    }\n\n    a0->Use();\n    a1->Use();\n    a2->Use();\n\n    a1 = a2;\n    a2.reset(new A);\n    a0.reset();\n\n    linked_ptr<A> a7;\n  }\n\n  ASSERT_STREQ(\n    \"A0 ctor\\n\"\n    \"A1 ctor\\n\"\n    \"A2 ctor\\n\"\n    \"B2 ctor\\n\"\n    \"A0 use\\n\"\n    \"A0 use\\n\"\n    \"B2 use\\n\"\n    \"B2 use\\n\"\n    \"B2 use\\n\"\n    \"B2 use\\n\"\n    \"B2 use\\n\"\n    \"B2 dtor\\n\"\n    \"A2 dtor\\n\"\n    \"A0 use\\n\"\n    \"A0 use\\n\"\n    \"A1 use\\n\"\n    \"A3 ctor\\n\"\n    \"A0 dtor\\n\"\n    \"A3 dtor\\n\"\n    \"A1 dtor\\n\",\n    history->GetString().c_str());\n}\n\n}  // Unnamed namespace\n"
  },
  {
    "path": "ext/gtest/test/gtest-listener_test.cc",
    "content": "// Copyright 2009 Google Inc. All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n//\n// The Google C++ Testing Framework (Google Test)\n//\n// This file verifies Google Test event listeners receive events at the\n// right times.\n\n#include \"gtest/gtest.h\"\n#include <vector>\n\nusing ::testing::AddGlobalTestEnvironment;\nusing ::testing::Environment;\nusing ::testing::InitGoogleTest;\nusing ::testing::Test;\nusing ::testing::TestCase;\nusing ::testing::TestEventListener;\nusing ::testing::TestInfo;\nusing ::testing::TestPartResult;\nusing ::testing::UnitTest;\n\n// Used by tests to register their events.\nstd::vector<std::string>* g_events = NULL;\n\nnamespace testing {\nnamespace internal {\n\nclass EventRecordingListener : public TestEventListener {\n public:\n  explicit EventRecordingListener(const char* name) : name_(name) {}\n\n protected:\n  virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {\n    g_events->push_back(GetFullMethodName(\"OnTestProgramStart\"));\n  }\n\n  virtual void OnTestIterationStart(const UnitTest& /*unit_test*/,\n                                    int iteration) {\n    Message message;\n    message << GetFullMethodName(\"OnTestIterationStart\")\n            << \"(\" << iteration << \")\";\n    g_events->push_back(message.GetString());\n  }\n\n  virtual void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) {\n    g_events->push_back(GetFullMethodName(\"OnEnvironmentsSetUpStart\"));\n  }\n\n  virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {\n    g_events->push_back(GetFullMethodName(\"OnEnvironmentsSetUpEnd\"));\n  }\n\n  virtual void OnTestCaseStart(const TestCase& /*test_case*/) {\n    g_events->push_back(GetFullMethodName(\"OnTestCaseStart\"));\n  }\n\n  virtual void OnTestStart(const TestInfo& /*test_info*/) {\n    g_events->push_back(GetFullMethodName(\"OnTestStart\"));\n  }\n\n  virtual void OnTestPartResult(const TestPartResult& /*test_part_result*/) {\n    g_events->push_back(GetFullMethodName(\"OnTestPartResult\"));\n  }\n\n  virtual void OnTestEnd(const TestInfo& /*test_info*/) {\n    g_events->push_back(GetFullMethodName(\"OnTestEnd\"));\n  }\n\n  virtual void OnTestCaseEnd(const TestCase& /*test_case*/) {\n    g_events->push_back(GetFullMethodName(\"OnTestCaseEnd\"));\n  }\n\n  virtual void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) {\n    g_events->push_back(GetFullMethodName(\"OnEnvironmentsTearDownStart\"));\n  }\n\n  virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {\n    g_events->push_back(GetFullMethodName(\"OnEnvironmentsTearDownEnd\"));\n  }\n\n  virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/,\n                                  int iteration) {\n    Message message;\n    message << GetFullMethodName(\"OnTestIterationEnd\")\n            << \"(\"  << iteration << \")\";\n    g_events->push_back(message.GetString());\n  }\n\n  virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {\n    g_events->push_back(GetFullMethodName(\"OnTestProgramEnd\"));\n  }\n\n private:\n  std::string GetFullMethodName(const char* name) {\n    return name_ + \".\" + name;\n  }\n\n  std::string name_;\n};\n\nclass EnvironmentInvocationCatcher : public Environment {\n protected:\n  virtual void SetUp() {\n    g_events->push_back(\"Environment::SetUp\");\n  }\n\n  virtual void TearDown() {\n    g_events->push_back(\"Environment::TearDown\");\n  }\n};\n\nclass ListenerTest : public Test {\n protected:\n  static void SetUpTestCase() {\n    g_events->push_back(\"ListenerTest::SetUpTestCase\");\n  }\n\n  static void TearDownTestCase() {\n    g_events->push_back(\"ListenerTest::TearDownTestCase\");\n  }\n\n  virtual void SetUp() {\n    g_events->push_back(\"ListenerTest::SetUp\");\n  }\n\n  virtual void TearDown() {\n    g_events->push_back(\"ListenerTest::TearDown\");\n  }\n};\n\nTEST_F(ListenerTest, DoesFoo) {\n  // Test execution order within a test case is not guaranteed so we are not\n  // recording the test name.\n  g_events->push_back(\"ListenerTest::* Test Body\");\n  SUCCEED();  // Triggers OnTestPartResult.\n}\n\nTEST_F(ListenerTest, DoesBar) {\n  g_events->push_back(\"ListenerTest::* Test Body\");\n  SUCCEED();  // Triggers OnTestPartResult.\n}\n\n}  // namespace internal\n\n}  // namespace testing\n\nusing ::testing::internal::EnvironmentInvocationCatcher;\nusing ::testing::internal::EventRecordingListener;\n\nvoid VerifyResults(const std::vector<std::string>& data,\n                   const char* const* expected_data,\n                   int expected_data_size) {\n  const int actual_size = data.size();\n  // If the following assertion fails, a new entry will be appended to\n  // data.  Hence we save data.size() first.\n  EXPECT_EQ(expected_data_size, actual_size);\n\n  // Compares the common prefix.\n  const int shorter_size = expected_data_size <= actual_size ?\n      expected_data_size : actual_size;\n  int i = 0;\n  for (; i < shorter_size; ++i) {\n    ASSERT_STREQ(expected_data[i], data[i].c_str())\n        << \"at position \" << i;\n  }\n\n  // Prints extra elements in the actual data.\n  for (; i < actual_size; ++i) {\n    printf(\"  Actual event #%d: %s\\n\", i, data[i].c_str());\n  }\n}\n\nint main(int argc, char **argv) {\n  std::vector<std::string> events;\n  g_events = &events;\n  InitGoogleTest(&argc, argv);\n\n  UnitTest::GetInstance()->listeners().Append(\n      new EventRecordingListener(\"1st\"));\n  UnitTest::GetInstance()->listeners().Append(\n      new EventRecordingListener(\"2nd\"));\n\n  AddGlobalTestEnvironment(new EnvironmentInvocationCatcher);\n\n  GTEST_CHECK_(events.size() == 0)\n      << \"AddGlobalTestEnvironment should not generate any events itself.\";\n\n  ::testing::GTEST_FLAG(repeat) = 2;\n  int ret_val = RUN_ALL_TESTS();\n\n  const char* const expected_events[] = {\n    \"1st.OnTestProgramStart\",\n    \"2nd.OnTestProgramStart\",\n    \"1st.OnTestIterationStart(0)\",\n    \"2nd.OnTestIterationStart(0)\",\n    \"1st.OnEnvironmentsSetUpStart\",\n    \"2nd.OnEnvironmentsSetUpStart\",\n    \"Environment::SetUp\",\n    \"2nd.OnEnvironmentsSetUpEnd\",\n    \"1st.OnEnvironmentsSetUpEnd\",\n    \"1st.OnTestCaseStart\",\n    \"2nd.OnTestCaseStart\",\n    \"ListenerTest::SetUpTestCase\",\n    \"1st.OnTestStart\",\n    \"2nd.OnTestStart\",\n    \"ListenerTest::SetUp\",\n    \"ListenerTest::* Test Body\",\n    \"1st.OnTestPartResult\",\n    \"2nd.OnTestPartResult\",\n    \"ListenerTest::TearDown\",\n    \"2nd.OnTestEnd\",\n    \"1st.OnTestEnd\",\n    \"1st.OnTestStart\",\n    \"2nd.OnTestStart\",\n    \"ListenerTest::SetUp\",\n    \"ListenerTest::* Test Body\",\n    \"1st.OnTestPartResult\",\n    \"2nd.OnTestPartResult\",\n    \"ListenerTest::TearDown\",\n    \"2nd.OnTestEnd\",\n    \"1st.OnTestEnd\",\n    \"ListenerTest::TearDownTestCase\",\n    \"2nd.OnTestCaseEnd\",\n    \"1st.OnTestCaseEnd\",\n    \"1st.OnEnvironmentsTearDownStart\",\n    \"2nd.OnEnvironmentsTearDownStart\",\n    \"Environment::TearDown\",\n    \"2nd.OnEnvironmentsTearDownEnd\",\n    \"1st.OnEnvironmentsTearDownEnd\",\n    \"2nd.OnTestIterationEnd(0)\",\n    \"1st.OnTestIterationEnd(0)\",\n    \"1st.OnTestIterationStart(1)\",\n    \"2nd.OnTestIterationStart(1)\",\n    \"1st.OnEnvironmentsSetUpStart\",\n    \"2nd.OnEnvironmentsSetUpStart\",\n    \"Environment::SetUp\",\n    \"2nd.OnEnvironmentsSetUpEnd\",\n    \"1st.OnEnvironmentsSetUpEnd\",\n    \"1st.OnTestCaseStart\",\n    \"2nd.OnTestCaseStart\",\n    \"ListenerTest::SetUpTestCase\",\n    \"1st.OnTestStart\",\n    \"2nd.OnTestStart\",\n    \"ListenerTest::SetUp\",\n    \"ListenerTest::* Test Body\",\n    \"1st.OnTestPartResult\",\n    \"2nd.OnTestPartResult\",\n    \"ListenerTest::TearDown\",\n    \"2nd.OnTestEnd\",\n    \"1st.OnTestEnd\",\n    \"1st.OnTestStart\",\n    \"2nd.OnTestStart\",\n    \"ListenerTest::SetUp\",\n    \"ListenerTest::* Test Body\",\n    \"1st.OnTestPartResult\",\n    \"2nd.OnTestPartResult\",\n    \"ListenerTest::TearDown\",\n    \"2nd.OnTestEnd\",\n    \"1st.OnTestEnd\",\n    \"ListenerTest::TearDownTestCase\",\n    \"2nd.OnTestCaseEnd\",\n    \"1st.OnTestCaseEnd\",\n    \"1st.OnEnvironmentsTearDownStart\",\n    \"2nd.OnEnvironmentsTearDownStart\",\n    \"Environment::TearDown\",\n    \"2nd.OnEnvironmentsTearDownEnd\",\n    \"1st.OnEnvironmentsTearDownEnd\",\n    \"2nd.OnTestIterationEnd(1)\",\n    \"1st.OnTestIterationEnd(1)\",\n    \"2nd.OnTestProgramEnd\",\n    \"1st.OnTestProgramEnd\"\n  };\n  VerifyResults(events,\n                expected_events,\n                sizeof(expected_events)/sizeof(expected_events[0]));\n\n  // We need to check manually for ad hoc test failures that happen after\n  // RUN_ALL_TESTS finishes.\n  if (UnitTest::GetInstance()->Failed())\n    ret_val = 1;\n\n  return ret_val;\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest-message_test.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// Tests for the Message class.\n\n#include \"gtest/gtest-message.h\"\n\n#include \"gtest/gtest.h\"\n\nnamespace {\n\nusing ::testing::Message;\n\n// Tests the testing::Message class\n\n// Tests the default constructor.\nTEST(MessageTest, DefaultConstructor) {\n  const Message msg;\n  EXPECT_EQ(\"\", msg.GetString());\n}\n\n// Tests the copy constructor.\nTEST(MessageTest, CopyConstructor) {\n  const Message msg1(\"Hello\");\n  const Message msg2(msg1);\n  EXPECT_EQ(\"Hello\", msg2.GetString());\n}\n\n// Tests constructing a Message from a C-string.\nTEST(MessageTest, ConstructsFromCString) {\n  Message msg(\"Hello\");\n  EXPECT_EQ(\"Hello\", msg.GetString());\n}\n\n// Tests streaming a float.\nTEST(MessageTest, StreamsFloat) {\n  const std::string s = (Message() << 1.23456F << \" \" << 2.34567F).GetString();\n  // Both numbers should be printed with enough precision.\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, \"1.234560\", s.c_str());\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, \" 2.345669\", s.c_str());\n}\n\n// Tests streaming a double.\nTEST(MessageTest, StreamsDouble) {\n  const std::string s = (Message() << 1260570880.4555497 << \" \"\n                                  << 1260572265.1954534).GetString();\n  // Both numbers should be printed with enough precision.\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, \"1260570880.45\", s.c_str());\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, \" 1260572265.19\", s.c_str());\n}\n\n// Tests streaming a non-char pointer.\nTEST(MessageTest, StreamsPointer) {\n  int n = 0;\n  int* p = &n;\n  EXPECT_NE(\"(null)\", (Message() << p).GetString());\n}\n\n// Tests streaming a NULL non-char pointer.\nTEST(MessageTest, StreamsNullPointer) {\n  int* p = NULL;\n  EXPECT_EQ(\"(null)\", (Message() << p).GetString());\n}\n\n// Tests streaming a C string.\nTEST(MessageTest, StreamsCString) {\n  EXPECT_EQ(\"Foo\", (Message() << \"Foo\").GetString());\n}\n\n// Tests streaming a NULL C string.\nTEST(MessageTest, StreamsNullCString) {\n  char* p = NULL;\n  EXPECT_EQ(\"(null)\", (Message() << p).GetString());\n}\n\n// Tests streaming std::string.\nTEST(MessageTest, StreamsString) {\n  const ::std::string str(\"Hello\");\n  EXPECT_EQ(\"Hello\", (Message() << str).GetString());\n}\n\n// Tests that we can output strings containing embedded NULs.\nTEST(MessageTest, StreamsStringWithEmbeddedNUL) {\n  const char char_array_with_nul[] =\n      \"Here's a NUL\\0 and some more string\";\n  const ::std::string string_with_nul(char_array_with_nul,\n                                      sizeof(char_array_with_nul) - 1);\n  EXPECT_EQ(\"Here's a NUL\\\\0 and some more string\",\n            (Message() << string_with_nul).GetString());\n}\n\n// Tests streaming a NUL char.\nTEST(MessageTest, StreamsNULChar) {\n  EXPECT_EQ(\"\\\\0\", (Message() << '\\0').GetString());\n}\n\n// Tests streaming int.\nTEST(MessageTest, StreamsInt) {\n  EXPECT_EQ(\"123\", (Message() << 123).GetString());\n}\n\n// Tests that basic IO manipulators (endl, ends, and flush) can be\n// streamed to Message.\nTEST(MessageTest, StreamsBasicIoManip) {\n  EXPECT_EQ(\"Line 1.\\nA NUL char \\\\0 in line 2.\",\n               (Message() << \"Line 1.\" << std::endl\n                         << \"A NUL char \" << std::ends << std::flush\n                         << \" in line 2.\").GetString());\n}\n\n// Tests Message::GetString()\nTEST(MessageTest, GetString) {\n  Message msg;\n  msg << 1 << \" lamb\";\n  EXPECT_EQ(\"1 lamb\", msg.GetString());\n}\n\n// Tests streaming a Message object to an ostream.\nTEST(MessageTest, StreamsToOStream) {\n  Message msg(\"Hello\");\n  ::std::stringstream ss;\n  ss << msg;\n  EXPECT_EQ(\"Hello\", testing::internal::StringStreamToString(&ss));\n}\n\n// Tests that a Message object doesn't take up too much stack space.\nTEST(MessageTest, DoesNotTakeUpMuchStackSpace) {\n  EXPECT_LE(sizeof(Message), 16U);\n}\n\n}  // namespace\n"
  },
  {
    "path": "ext/gtest/test/gtest-options_test.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: keith.ray@gmail.com (Keith Ray)\n//\n// Google Test UnitTestOptions tests\n//\n// This file tests classes and functions used internally by\n// Google Test.  They are subject to change without notice.\n//\n// This file is #included from gtest.cc, to avoid changing build or\n// make-files on Windows and other platforms. Do not #include this file\n// anywhere else!\n\n#include \"gtest/gtest.h\"\n\n#if GTEST_OS_WINDOWS_MOBILE\n# include <windows.h>\n#elif GTEST_OS_WINDOWS\n# include <direct.h>\n#endif  // GTEST_OS_WINDOWS_MOBILE\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick is to\n// prevent a user from accidentally including gtest-internal-inl.h in\n// his code.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\nnamespace testing {\nnamespace internal {\nnamespace {\n\n// Turns the given relative path into an absolute path.\nFilePath GetAbsolutePathOf(const FilePath& relative_path) {\n  return FilePath::ConcatPaths(FilePath::GetCurrentDir(), relative_path);\n}\n\n// Testing UnitTestOptions::GetOutputFormat/GetOutputFile.\n\nTEST(XmlOutputTest, GetOutputFormatDefault) {\n  GTEST_FLAG(output) = \"\";\n  EXPECT_STREQ(\"\", UnitTestOptions::GetOutputFormat().c_str());\n}\n\nTEST(XmlOutputTest, GetOutputFormat) {\n  GTEST_FLAG(output) = \"xml:filename\";\n  EXPECT_STREQ(\"xml\", UnitTestOptions::GetOutputFormat().c_str());\n}\n\nTEST(XmlOutputTest, GetOutputFileDefault) {\n  GTEST_FLAG(output) = \"\";\n  EXPECT_EQ(GetAbsolutePathOf(FilePath(\"test_detail.xml\")).string(),\n            UnitTestOptions::GetAbsolutePathToOutputFile());\n}\n\nTEST(XmlOutputTest, GetOutputFileSingleFile) {\n  GTEST_FLAG(output) = \"xml:filename.abc\";\n  EXPECT_EQ(GetAbsolutePathOf(FilePath(\"filename.abc\")).string(),\n            UnitTestOptions::GetAbsolutePathToOutputFile());\n}\n\nTEST(XmlOutputTest, GetOutputFileFromDirectoryPath) {\n  GTEST_FLAG(output) = \"xml:path\" GTEST_PATH_SEP_;\n  const std::string expected_output_file =\n      GetAbsolutePathOf(\n          FilePath(std::string(\"path\") + GTEST_PATH_SEP_ +\n                   GetCurrentExecutableName().string() + \".xml\")).string();\n  const std::string& output_file =\n      UnitTestOptions::GetAbsolutePathToOutputFile();\n#if GTEST_OS_WINDOWS\n  EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str());\n#else\n  EXPECT_EQ(expected_output_file, output_file.c_str());\n#endif\n}\n\nTEST(OutputFileHelpersTest, GetCurrentExecutableName) {\n  const std::string exe_str = GetCurrentExecutableName().string();\n#if GTEST_OS_WINDOWS\n  const bool success =\n      _strcmpi(\"gtest-options_test\", exe_str.c_str()) == 0 ||\n      _strcmpi(\"gtest-options-ex_test\", exe_str.c_str()) == 0 ||\n      _strcmpi(\"gtest_all_test\", exe_str.c_str()) == 0 ||\n      _strcmpi(\"gtest_dll_test\", exe_str.c_str()) == 0;\n#else\n  // TODO(wan@google.com): remove the hard-coded \"lt-\" prefix when\n  //   Chandler Carruth's libtool replacement is ready.\n  const bool success =\n      exe_str == \"gtest-options_test\" ||\n      exe_str == \"gtest_all_test\" ||\n      exe_str == \"lt-gtest_all_test\" ||\n      exe_str == \"gtest_dll_test\";\n#endif  // GTEST_OS_WINDOWS\n  if (!success)\n    FAIL() << \"GetCurrentExecutableName() returns \" << exe_str;\n}\n\nclass XmlOutputChangeDirTest : public Test {\n protected:\n  virtual void SetUp() {\n    original_working_dir_ = FilePath::GetCurrentDir();\n    posix::ChDir(\"..\");\n    // This will make the test fail if run from the root directory.\n    EXPECT_NE(original_working_dir_.string(),\n              FilePath::GetCurrentDir().string());\n  }\n\n  virtual void TearDown() {\n    posix::ChDir(original_working_dir_.string().c_str());\n  }\n\n  FilePath original_working_dir_;\n};\n\nTEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithDefault) {\n  GTEST_FLAG(output) = \"\";\n  EXPECT_EQ(FilePath::ConcatPaths(original_working_dir_,\n                                  FilePath(\"test_detail.xml\")).string(),\n            UnitTestOptions::GetAbsolutePathToOutputFile());\n}\n\nTEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithDefaultXML) {\n  GTEST_FLAG(output) = \"xml\";\n  EXPECT_EQ(FilePath::ConcatPaths(original_working_dir_,\n                                  FilePath(\"test_detail.xml\")).string(),\n            UnitTestOptions::GetAbsolutePathToOutputFile());\n}\n\nTEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativeFile) {\n  GTEST_FLAG(output) = \"xml:filename.abc\";\n  EXPECT_EQ(FilePath::ConcatPaths(original_working_dir_,\n                                  FilePath(\"filename.abc\")).string(),\n            UnitTestOptions::GetAbsolutePathToOutputFile());\n}\n\nTEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithRelativePath) {\n  GTEST_FLAG(output) = \"xml:path\" GTEST_PATH_SEP_;\n  const std::string expected_output_file =\n      FilePath::ConcatPaths(\n          original_working_dir_,\n          FilePath(std::string(\"path\") + GTEST_PATH_SEP_ +\n                   GetCurrentExecutableName().string() + \".xml\")).string();\n  const std::string& output_file =\n      UnitTestOptions::GetAbsolutePathToOutputFile();\n#if GTEST_OS_WINDOWS\n  EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str());\n#else\n  EXPECT_EQ(expected_output_file, output_file.c_str());\n#endif\n}\n\nTEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsoluteFile) {\n#if GTEST_OS_WINDOWS\n  GTEST_FLAG(output) = \"xml:c:\\\\tmp\\\\filename.abc\";\n  EXPECT_EQ(FilePath(\"c:\\\\tmp\\\\filename.abc\").string(),\n            UnitTestOptions::GetAbsolutePathToOutputFile());\n#else\n  GTEST_FLAG(output) =\"xml:/tmp/filename.abc\";\n  EXPECT_EQ(FilePath(\"/tmp/filename.abc\").string(),\n            UnitTestOptions::GetAbsolutePathToOutputFile());\n#endif\n}\n\nTEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsolutePath) {\n#if GTEST_OS_WINDOWS\n  const std::string path = \"c:\\\\tmp\\\\\";\n#else\n  const std::string path = \"/tmp/\";\n#endif\n\n  GTEST_FLAG(output) = \"xml:\" + path;\n  const std::string expected_output_file =\n      path + GetCurrentExecutableName().string() + \".xml\";\n  const std::string& output_file =\n      UnitTestOptions::GetAbsolutePathToOutputFile();\n\n#if GTEST_OS_WINDOWS\n  EXPECT_STRCASEEQ(expected_output_file.c_str(), output_file.c_str());\n#else\n  EXPECT_EQ(expected_output_file, output_file.c_str());\n#endif\n}\n\n}  // namespace\n}  // namespace internal\n}  // namespace testing\n"
  },
  {
    "path": "ext/gtest/test/gtest-param-test2_test.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n//\n// Tests for Google Test itself.  This verifies that the basic constructs of\n// Google Test work.\n\n#include \"gtest/gtest.h\"\n\n#include \"test/gtest-param-test_test.h\"\n\n#if GTEST_HAS_PARAM_TEST\n\nusing ::testing::Values;\nusing ::testing::internal::ParamGenerator;\n\n// Tests that generators defined in a different translation unit\n// are functional. The test using extern_gen is defined\n// in gtest-param-test_test.cc.\nParamGenerator<int> extern_gen = Values(33);\n\n// Tests that a parameterized test case can be defined in one translation unit\n// and instantiated in another. The test is defined in gtest-param-test_test.cc\n// and ExternalInstantiationTest fixture class is defined in\n// gtest-param-test_test.h.\nINSTANTIATE_TEST_CASE_P(MultiplesOf33,\n                        ExternalInstantiationTest,\n                        Values(33, 66));\n\n// Tests that a parameterized test case can be instantiated\n// in multiple translation units. Another instantiation is defined\n// in gtest-param-test_test.cc and InstantiationInMultipleTranslaionUnitsTest\n// fixture is defined in gtest-param-test_test.h\nINSTANTIATE_TEST_CASE_P(Sequence2,\n                        InstantiationInMultipleTranslaionUnitsTest,\n                        Values(42*3, 42*4, 42*5));\n\n#endif  // GTEST_HAS_PARAM_TEST\n"
  },
  {
    "path": "ext/gtest/test/gtest-param-test_test.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n//\n// Tests for Google Test itself. This file verifies that the parameter\n// generators objects produce correct parameter sequences and that\n// Google Test runtime instantiates correct tests from those sequences.\n\n#include \"gtest/gtest.h\"\n\n#if GTEST_HAS_PARAM_TEST\n\n# include <algorithm>\n# include <iostream>\n# include <list>\n# include <sstream>\n# include <string>\n# include <vector>\n\n// To include gtest-internal-inl.h.\n# define GTEST_IMPLEMENTATION_ 1\n# include \"src/gtest-internal-inl.h\"  // for UnitTestOptions\n# undef GTEST_IMPLEMENTATION_\n\n# include \"test/gtest-param-test_test.h\"\n\nusing ::std::vector;\nusing ::std::sort;\n\nusing ::testing::AddGlobalTestEnvironment;\nusing ::testing::Bool;\nusing ::testing::Message;\nusing ::testing::Range;\nusing ::testing::TestWithParam;\nusing ::testing::Values;\nusing ::testing::ValuesIn;\n\n# if GTEST_HAS_COMBINE\nusing ::testing::Combine;\nusing ::std::tr1::get;\nusing ::std::tr1::make_tuple;\nusing ::std::tr1::tuple;\n# endif  // GTEST_HAS_COMBINE\n\nusing ::testing::internal::ParamGenerator;\nusing ::testing::internal::UnitTestOptions;\n\n// Prints a value to a string.\n//\n// TODO(wan@google.com): remove PrintValue() when we move matchers and\n// EXPECT_THAT() from Google Mock to Google Test.  At that time, we\n// can write EXPECT_THAT(x, Eq(y)) to compare two tuples x and y, as\n// EXPECT_THAT() and the matchers know how to print tuples.\ntemplate <typename T>\n::std::string PrintValue(const T& value) {\n  ::std::stringstream stream;\n  stream << value;\n  return stream.str();\n}\n\n# if GTEST_HAS_COMBINE\n\n// These overloads allow printing tuples in our tests.  We cannot\n// define an operator<< for tuples, as that definition needs to be in\n// the std namespace in order to be picked up by Google Test via\n// Argument-Dependent Lookup, yet defining anything in the std\n// namespace in non-STL code is undefined behavior.\n\ntemplate <typename T1, typename T2>\n::std::string PrintValue(const tuple<T1, T2>& value) {\n  ::std::stringstream stream;\n  stream << \"(\" << get<0>(value) << \", \" << get<1>(value) << \")\";\n  return stream.str();\n}\n\ntemplate <typename T1, typename T2, typename T3>\n::std::string PrintValue(const tuple<T1, T2, T3>& value) {\n  ::std::stringstream stream;\n  stream << \"(\" << get<0>(value) << \", \" << get<1>(value)\n         << \", \"<< get<2>(value) << \")\";\n  return stream.str();\n}\n\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5,\n          typename T6, typename T7, typename T8, typename T9, typename T10>\n::std::string PrintValue(\n    const tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& value) {\n  ::std::stringstream stream;\n  stream << \"(\" << get<0>(value) << \", \" << get<1>(value)\n         << \", \"<< get<2>(value) << \", \" << get<3>(value)\n         << \", \"<< get<4>(value) << \", \" << get<5>(value)\n         << \", \"<< get<6>(value) << \", \" << get<7>(value)\n         << \", \"<< get<8>(value) << \", \" << get<9>(value) << \")\";\n  return stream.str();\n}\n\n# endif  // GTEST_HAS_COMBINE\n\n// Verifies that a sequence generated by the generator and accessed\n// via the iterator object matches the expected one using Google Test\n// assertions.\ntemplate <typename T, size_t N>\nvoid VerifyGenerator(const ParamGenerator<T>& generator,\n                     const T (&expected_values)[N]) {\n  typename ParamGenerator<T>::iterator it = generator.begin();\n  for (size_t i = 0; i < N; ++i) {\n    ASSERT_FALSE(it == generator.end())\n        << \"At element \" << i << \" when accessing via an iterator \"\n        << \"created with the copy constructor.\\n\";\n    // We cannot use EXPECT_EQ() here as the values may be tuples,\n    // which don't support <<.\n    EXPECT_TRUE(expected_values[i] == *it)\n        << \"where i is \" << i\n        << \", expected_values[i] is \" << PrintValue(expected_values[i])\n        << \", *it is \" << PrintValue(*it)\n        << \", and 'it' is an iterator created with the copy constructor.\\n\";\n    it++;\n  }\n  EXPECT_TRUE(it == generator.end())\n        << \"At the presumed end of sequence when accessing via an iterator \"\n        << \"created with the copy constructor.\\n\";\n\n  // Test the iterator assignment. The following lines verify that\n  // the sequence accessed via an iterator initialized via the\n  // assignment operator (as opposed to a copy constructor) matches\n  // just the same.\n  it = generator.begin();\n  for (size_t i = 0; i < N; ++i) {\n    ASSERT_FALSE(it == generator.end())\n        << \"At element \" << i << \" when accessing via an iterator \"\n        << \"created with the assignment operator.\\n\";\n    EXPECT_TRUE(expected_values[i] == *it)\n        << \"where i is \" << i\n        << \", expected_values[i] is \" << PrintValue(expected_values[i])\n        << \", *it is \" << PrintValue(*it)\n        << \", and 'it' is an iterator created with the copy constructor.\\n\";\n    it++;\n  }\n  EXPECT_TRUE(it == generator.end())\n        << \"At the presumed end of sequence when accessing via an iterator \"\n        << \"created with the assignment operator.\\n\";\n}\n\ntemplate <typename T>\nvoid VerifyGeneratorIsEmpty(const ParamGenerator<T>& generator) {\n  typename ParamGenerator<T>::iterator it = generator.begin();\n  EXPECT_TRUE(it == generator.end());\n\n  it = generator.begin();\n  EXPECT_TRUE(it == generator.end());\n}\n\n// Generator tests. They test that each of the provided generator functions\n// generates an expected sequence of values. The general test pattern\n// instantiates a generator using one of the generator functions,\n// checks the sequence produced by the generator using its iterator API,\n// and then resets the iterator back to the beginning of the sequence\n// and checks the sequence again.\n\n// Tests that iterators produced by generator functions conform to the\n// ForwardIterator concept.\nTEST(IteratorTest, ParamIteratorConformsToForwardIteratorConcept) {\n  const ParamGenerator<int> gen = Range(0, 10);\n  ParamGenerator<int>::iterator it = gen.begin();\n\n  // Verifies that iterator initialization works as expected.\n  ParamGenerator<int>::iterator it2 = it;\n  EXPECT_TRUE(*it == *it2) << \"Initialized iterators must point to the \"\n                           << \"element same as its source points to\";\n\n  // Verifies that iterator assignment works as expected.\n  it++;\n  EXPECT_FALSE(*it == *it2);\n  it2 = it;\n  EXPECT_TRUE(*it == *it2) << \"Assigned iterators must point to the \"\n                           << \"element same as its source points to\";\n\n  // Verifies that prefix operator++() returns *this.\n  EXPECT_EQ(&it, &(++it)) << \"Result of the prefix operator++ must be \"\n                          << \"refer to the original object\";\n\n  // Verifies that the result of the postfix operator++ points to the value\n  // pointed to by the original iterator.\n  int original_value = *it;  // Have to compute it outside of macro call to be\n                             // unaffected by the parameter evaluation order.\n  EXPECT_EQ(original_value, *(it++));\n\n  // Verifies that prefix and postfix operator++() advance an iterator\n  // all the same.\n  it2 = it;\n  it++;\n  ++it2;\n  EXPECT_TRUE(*it == *it2);\n}\n\n// Tests that Range() generates the expected sequence.\nTEST(RangeTest, IntRangeWithDefaultStep) {\n  const ParamGenerator<int> gen = Range(0, 3);\n  const int expected_values[] = {0, 1, 2};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Edge case. Tests that Range() generates the single element sequence\n// as expected when provided with range limits that are equal.\nTEST(RangeTest, IntRangeSingleValue) {\n  const ParamGenerator<int> gen = Range(0, 1);\n  const int expected_values[] = {0};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Edge case. Tests that Range() with generates empty sequence when\n// supplied with an empty range.\nTEST(RangeTest, IntRangeEmpty) {\n  const ParamGenerator<int> gen = Range(0, 0);\n  VerifyGeneratorIsEmpty(gen);\n}\n\n// Tests that Range() with custom step (greater then one) generates\n// the expected sequence.\nTEST(RangeTest, IntRangeWithCustomStep) {\n  const ParamGenerator<int> gen = Range(0, 9, 3);\n  const int expected_values[] = {0, 3, 6};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Tests that Range() with custom step (greater then one) generates\n// the expected sequence when the last element does not fall on the\n// upper range limit. Sequences generated by Range() must not have\n// elements beyond the range limits.\nTEST(RangeTest, IntRangeWithCustomStepOverUpperBound) {\n  const ParamGenerator<int> gen = Range(0, 4, 3);\n  const int expected_values[] = {0, 3};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Verifies that Range works with user-defined types that define\n// copy constructor, operator=(), operator+(), and operator<().\nclass DogAdder {\n public:\n  explicit DogAdder(const char* a_value) : value_(a_value) {}\n  DogAdder(const DogAdder& other) : value_(other.value_.c_str()) {}\n\n  DogAdder operator=(const DogAdder& other) {\n    if (this != &other)\n      value_ = other.value_;\n    return *this;\n  }\n  DogAdder operator+(const DogAdder& other) const {\n    Message msg;\n    msg << value_.c_str() << other.value_.c_str();\n    return DogAdder(msg.GetString().c_str());\n  }\n  bool operator<(const DogAdder& other) const {\n    return value_ < other.value_;\n  }\n  const std::string& value() const { return value_; }\n\n private:\n  std::string value_;\n};\n\nTEST(RangeTest, WorksWithACustomType) {\n  const ParamGenerator<DogAdder> gen =\n      Range(DogAdder(\"cat\"), DogAdder(\"catdogdog\"), DogAdder(\"dog\"));\n  ParamGenerator<DogAdder>::iterator it = gen.begin();\n\n  ASSERT_FALSE(it == gen.end());\n  EXPECT_STREQ(\"cat\", it->value().c_str());\n\n  ASSERT_FALSE(++it == gen.end());\n  EXPECT_STREQ(\"catdog\", it->value().c_str());\n\n  EXPECT_TRUE(++it == gen.end());\n}\n\nclass IntWrapper {\n public:\n  explicit IntWrapper(int a_value) : value_(a_value) {}\n  IntWrapper(const IntWrapper& other) : value_(other.value_) {}\n\n  IntWrapper operator=(const IntWrapper& other) {\n    value_ = other.value_;\n    return *this;\n  }\n  // operator+() adds a different type.\n  IntWrapper operator+(int other) const { return IntWrapper(value_ + other); }\n  bool operator<(const IntWrapper& other) const {\n    return value_ < other.value_;\n  }\n  int value() const { return value_; }\n\n private:\n  int value_;\n};\n\nTEST(RangeTest, WorksWithACustomTypeWithDifferentIncrementType) {\n  const ParamGenerator<IntWrapper> gen = Range(IntWrapper(0), IntWrapper(2));\n  ParamGenerator<IntWrapper>::iterator it = gen.begin();\n\n  ASSERT_FALSE(it == gen.end());\n  EXPECT_EQ(0, it->value());\n\n  ASSERT_FALSE(++it == gen.end());\n  EXPECT_EQ(1, it->value());\n\n  EXPECT_TRUE(++it == gen.end());\n}\n\n// Tests that ValuesIn() with an array parameter generates\n// the expected sequence.\nTEST(ValuesInTest, ValuesInArray) {\n  int array[] = {3, 5, 8};\n  const ParamGenerator<int> gen = ValuesIn(array);\n  VerifyGenerator(gen, array);\n}\n\n// Tests that ValuesIn() with a const array parameter generates\n// the expected sequence.\nTEST(ValuesInTest, ValuesInConstArray) {\n  const int array[] = {3, 5, 8};\n  const ParamGenerator<int> gen = ValuesIn(array);\n  VerifyGenerator(gen, array);\n}\n\n// Edge case. Tests that ValuesIn() with an array parameter containing a\n// single element generates the single element sequence.\nTEST(ValuesInTest, ValuesInSingleElementArray) {\n  int array[] = {42};\n  const ParamGenerator<int> gen = ValuesIn(array);\n  VerifyGenerator(gen, array);\n}\n\n// Tests that ValuesIn() generates the expected sequence for an STL\n// container (vector).\nTEST(ValuesInTest, ValuesInVector) {\n  typedef ::std::vector<int> ContainerType;\n  ContainerType values;\n  values.push_back(3);\n  values.push_back(5);\n  values.push_back(8);\n  const ParamGenerator<int> gen = ValuesIn(values);\n\n  const int expected_values[] = {3, 5, 8};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Tests that ValuesIn() generates the expected sequence.\nTEST(ValuesInTest, ValuesInIteratorRange) {\n  typedef ::std::vector<int> ContainerType;\n  ContainerType values;\n  values.push_back(3);\n  values.push_back(5);\n  values.push_back(8);\n  const ParamGenerator<int> gen = ValuesIn(values.begin(), values.end());\n\n  const int expected_values[] = {3, 5, 8};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Edge case. Tests that ValuesIn() provided with an iterator range specifying a\n// single value generates a single-element sequence.\nTEST(ValuesInTest, ValuesInSingleElementIteratorRange) {\n  typedef ::std::vector<int> ContainerType;\n  ContainerType values;\n  values.push_back(42);\n  const ParamGenerator<int> gen = ValuesIn(values.begin(), values.end());\n\n  const int expected_values[] = {42};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Edge case. Tests that ValuesIn() provided with an empty iterator range\n// generates an empty sequence.\nTEST(ValuesInTest, ValuesInEmptyIteratorRange) {\n  typedef ::std::vector<int> ContainerType;\n  ContainerType values;\n  const ParamGenerator<int> gen = ValuesIn(values.begin(), values.end());\n\n  VerifyGeneratorIsEmpty(gen);\n}\n\n// Tests that the Values() generates the expected sequence.\nTEST(ValuesTest, ValuesWorks) {\n  const ParamGenerator<int> gen = Values(3, 5, 8);\n\n  const int expected_values[] = {3, 5, 8};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Tests that Values() generates the expected sequences from elements of\n// different types convertible to ParamGenerator's parameter type.\nTEST(ValuesTest, ValuesWorksForValuesOfCompatibleTypes) {\n  const ParamGenerator<double> gen = Values(3, 5.0f, 8.0);\n\n  const double expected_values[] = {3.0, 5.0, 8.0};\n  VerifyGenerator(gen, expected_values);\n}\n\nTEST(ValuesTest, ValuesWorksForMaxLengthList) {\n  const ParamGenerator<int> gen = Values(\n      10, 20, 30, 40, 50, 60, 70, 80, 90, 100,\n      110, 120, 130, 140, 150, 160, 170, 180, 190, 200,\n      210, 220, 230, 240, 250, 260, 270, 280, 290, 300,\n      310, 320, 330, 340, 350, 360, 370, 380, 390, 400,\n      410, 420, 430, 440, 450, 460, 470, 480, 490, 500);\n\n  const int expected_values[] = {\n      10, 20, 30, 40, 50, 60, 70, 80, 90, 100,\n      110, 120, 130, 140, 150, 160, 170, 180, 190, 200,\n      210, 220, 230, 240, 250, 260, 270, 280, 290, 300,\n      310, 320, 330, 340, 350, 360, 370, 380, 390, 400,\n      410, 420, 430, 440, 450, 460, 470, 480, 490, 500};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Edge case test. Tests that single-parameter Values() generates the sequence\n// with the single value.\nTEST(ValuesTest, ValuesWithSingleParameter) {\n  const ParamGenerator<int> gen = Values(42);\n\n  const int expected_values[] = {42};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Tests that Bool() generates sequence (false, true).\nTEST(BoolTest, BoolWorks) {\n  const ParamGenerator<bool> gen = Bool();\n\n  const bool expected_values[] = {false, true};\n  VerifyGenerator(gen, expected_values);\n}\n\n# if GTEST_HAS_COMBINE\n\n// Tests that Combine() with two parameters generates the expected sequence.\nTEST(CombineTest, CombineWithTwoParameters) {\n  const char* foo = \"foo\";\n  const char* bar = \"bar\";\n  const ParamGenerator<tuple<const char*, int> > gen =\n      Combine(Values(foo, bar), Values(3, 4));\n\n  tuple<const char*, int> expected_values[] = {\n    make_tuple(foo, 3), make_tuple(foo, 4),\n    make_tuple(bar, 3), make_tuple(bar, 4)};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Tests that Combine() with three parameters generates the expected sequence.\nTEST(CombineTest, CombineWithThreeParameters) {\n  const ParamGenerator<tuple<int, int, int> > gen = Combine(Values(0, 1),\n                                                            Values(3, 4),\n                                                            Values(5, 6));\n  tuple<int, int, int> expected_values[] = {\n    make_tuple(0, 3, 5), make_tuple(0, 3, 6),\n    make_tuple(0, 4, 5), make_tuple(0, 4, 6),\n    make_tuple(1, 3, 5), make_tuple(1, 3, 6),\n    make_tuple(1, 4, 5), make_tuple(1, 4, 6)};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Tests that the Combine() with the first parameter generating a single value\n// sequence generates a sequence with the number of elements equal to the\n// number of elements in the sequence generated by the second parameter.\nTEST(CombineTest, CombineWithFirstParameterSingleValue) {\n  const ParamGenerator<tuple<int, int> > gen = Combine(Values(42),\n                                                       Values(0, 1));\n\n  tuple<int, int> expected_values[] = {make_tuple(42, 0), make_tuple(42, 1)};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Tests that the Combine() with the second parameter generating a single value\n// sequence generates a sequence with the number of elements equal to the\n// number of elements in the sequence generated by the first parameter.\nTEST(CombineTest, CombineWithSecondParameterSingleValue) {\n  const ParamGenerator<tuple<int, int> > gen = Combine(Values(0, 1),\n                                                       Values(42));\n\n  tuple<int, int> expected_values[] = {make_tuple(0, 42), make_tuple(1, 42)};\n  VerifyGenerator(gen, expected_values);\n}\n\n// Tests that when the first parameter produces an empty sequence,\n// Combine() produces an empty sequence, too.\nTEST(CombineTest, CombineWithFirstParameterEmptyRange) {\n  const ParamGenerator<tuple<int, int> > gen = Combine(Range(0, 0),\n                                                       Values(0, 1));\n  VerifyGeneratorIsEmpty(gen);\n}\n\n// Tests that when the second parameter produces an empty sequence,\n// Combine() produces an empty sequence, too.\nTEST(CombineTest, CombineWithSecondParameterEmptyRange) {\n  const ParamGenerator<tuple<int, int> > gen = Combine(Values(0, 1),\n                                                       Range(1, 1));\n  VerifyGeneratorIsEmpty(gen);\n}\n\n// Edge case. Tests that combine works with the maximum number\n// of parameters supported by Google Test (currently 10).\nTEST(CombineTest, CombineWithMaxNumberOfParameters) {\n  const char* foo = \"foo\";\n  const char* bar = \"bar\";\n  const ParamGenerator<tuple<const char*, int, int, int, int, int, int, int,\n                             int, int> > gen = Combine(Values(foo, bar),\n                                                       Values(1), Values(2),\n                                                       Values(3), Values(4),\n                                                       Values(5), Values(6),\n                                                       Values(7), Values(8),\n                                                       Values(9));\n\n  tuple<const char*, int, int, int, int, int, int, int, int, int>\n      expected_values[] = {make_tuple(foo, 1, 2, 3, 4, 5, 6, 7, 8, 9),\n                           make_tuple(bar, 1, 2, 3, 4, 5, 6, 7, 8, 9)};\n  VerifyGenerator(gen, expected_values);\n}\n\n# endif  // GTEST_HAS_COMBINE\n\n// Tests that an generator produces correct sequence after being\n// assigned from another generator.\nTEST(ParamGeneratorTest, AssignmentWorks) {\n  ParamGenerator<int> gen = Values(1, 2);\n  const ParamGenerator<int> gen2 = Values(3, 4);\n  gen = gen2;\n\n  const int expected_values[] = {3, 4};\n  VerifyGenerator(gen, expected_values);\n}\n\n// This test verifies that the tests are expanded and run as specified:\n// one test per element from the sequence produced by the generator\n// specified in INSTANTIATE_TEST_CASE_P. It also verifies that the test's\n// fixture constructor, SetUp(), and TearDown() have run and have been\n// supplied with the correct parameters.\n\n// The use of environment object allows detection of the case where no test\n// case functionality is run at all. In this case TestCaseTearDown will not\n// be able to detect missing tests, naturally.\ntemplate <int kExpectedCalls>\nclass TestGenerationEnvironment : public ::testing::Environment {\n public:\n  static TestGenerationEnvironment* Instance() {\n    static TestGenerationEnvironment* instance = new TestGenerationEnvironment;\n    return instance;\n  }\n\n  void FixtureConstructorExecuted() { fixture_constructor_count_++; }\n  void SetUpExecuted() { set_up_count_++; }\n  void TearDownExecuted() { tear_down_count_++; }\n  void TestBodyExecuted() { test_body_count_++; }\n\n  virtual void TearDown() {\n    // If all MultipleTestGenerationTest tests have been de-selected\n    // by the filter flag, the following checks make no sense.\n    bool perform_check = false;\n\n    for (int i = 0; i < kExpectedCalls; ++i) {\n      Message msg;\n      msg << \"TestsExpandedAndRun/\" << i;\n      if (UnitTestOptions::FilterMatchesTest(\n             \"TestExpansionModule/MultipleTestGenerationTest\",\n              msg.GetString().c_str())) {\n        perform_check = true;\n      }\n    }\n    if (perform_check) {\n      EXPECT_EQ(kExpectedCalls, fixture_constructor_count_)\n          << \"Fixture constructor of ParamTestGenerationTest test case \"\n          << \"has not been run as expected.\";\n      EXPECT_EQ(kExpectedCalls, set_up_count_)\n          << \"Fixture SetUp method of ParamTestGenerationTest test case \"\n          << \"has not been run as expected.\";\n      EXPECT_EQ(kExpectedCalls, tear_down_count_)\n          << \"Fixture TearDown method of ParamTestGenerationTest test case \"\n          << \"has not been run as expected.\";\n      EXPECT_EQ(kExpectedCalls, test_body_count_)\n          << \"Test in ParamTestGenerationTest test case \"\n          << \"has not been run as expected.\";\n    }\n  }\n\n private:\n  TestGenerationEnvironment() : fixture_constructor_count_(0), set_up_count_(0),\n                                tear_down_count_(0), test_body_count_(0) {}\n\n  int fixture_constructor_count_;\n  int set_up_count_;\n  int tear_down_count_;\n  int test_body_count_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestGenerationEnvironment);\n};\n\nconst int test_generation_params[] = {36, 42, 72};\n\nclass TestGenerationTest : public TestWithParam<int> {\n public:\n  enum {\n    PARAMETER_COUNT =\n        sizeof(test_generation_params)/sizeof(test_generation_params[0])\n  };\n\n  typedef TestGenerationEnvironment<PARAMETER_COUNT> Environment;\n\n  TestGenerationTest() {\n    Environment::Instance()->FixtureConstructorExecuted();\n    current_parameter_ = GetParam();\n  }\n  virtual void SetUp() {\n    Environment::Instance()->SetUpExecuted();\n    EXPECT_EQ(current_parameter_, GetParam());\n  }\n  virtual void TearDown() {\n    Environment::Instance()->TearDownExecuted();\n    EXPECT_EQ(current_parameter_, GetParam());\n  }\n\n  static void SetUpTestCase() {\n    bool all_tests_in_test_case_selected = true;\n\n    for (int i = 0; i < PARAMETER_COUNT; ++i) {\n      Message test_name;\n      test_name << \"TestsExpandedAndRun/\" << i;\n      if ( !UnitTestOptions::FilterMatchesTest(\n                \"TestExpansionModule/MultipleTestGenerationTest\",\n                test_name.GetString())) {\n        all_tests_in_test_case_selected = false;\n      }\n    }\n    EXPECT_TRUE(all_tests_in_test_case_selected)\n        << \"When running the TestGenerationTest test case all of its tests\\n\"\n        << \"must be selected by the filter flag for the test case to pass.\\n\"\n        << \"If not all of them are enabled, we can't reliably conclude\\n\"\n        << \"that the correct number of tests have been generated.\";\n\n    collected_parameters_.clear();\n  }\n\n  static void TearDownTestCase() {\n    vector<int> expected_values(test_generation_params,\n                                test_generation_params + PARAMETER_COUNT);\n    // Test execution order is not guaranteed by Google Test,\n    // so the order of values in collected_parameters_ can be\n    // different and we have to sort to compare.\n    sort(expected_values.begin(), expected_values.end());\n    sort(collected_parameters_.begin(), collected_parameters_.end());\n\n    EXPECT_TRUE(collected_parameters_ == expected_values);\n  }\n\n protected:\n  int current_parameter_;\n  static vector<int> collected_parameters_;\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(TestGenerationTest);\n};\nvector<int> TestGenerationTest::collected_parameters_;\n\nTEST_P(TestGenerationTest, TestsExpandedAndRun) {\n  Environment::Instance()->TestBodyExecuted();\n  EXPECT_EQ(current_parameter_, GetParam());\n  collected_parameters_.push_back(GetParam());\n}\nINSTANTIATE_TEST_CASE_P(TestExpansionModule, TestGenerationTest,\n                        ValuesIn(test_generation_params));\n\n// This test verifies that the element sequence (third parameter of\n// INSTANTIATE_TEST_CASE_P) is evaluated in InitGoogleTest() and neither at\n// the call site of INSTANTIATE_TEST_CASE_P nor in RUN_ALL_TESTS().  For\n// that, we declare param_value_ to be a static member of\n// GeneratorEvaluationTest and initialize it to 0.  We set it to 1 in\n// main(), just before invocation of InitGoogleTest().  After calling\n// InitGoogleTest(), we set the value to 2.  If the sequence is evaluated\n// before or after InitGoogleTest, INSTANTIATE_TEST_CASE_P will create a\n// test with parameter other than 1, and the test body will fail the\n// assertion.\nclass GeneratorEvaluationTest : public TestWithParam<int> {\n public:\n  static int param_value() { return param_value_; }\n  static void set_param_value(int param_value) { param_value_ = param_value; }\n\n private:\n  static int param_value_;\n};\nint GeneratorEvaluationTest::param_value_ = 0;\n\nTEST_P(GeneratorEvaluationTest, GeneratorsEvaluatedInMain) {\n  EXPECT_EQ(1, GetParam());\n}\nINSTANTIATE_TEST_CASE_P(GenEvalModule,\n                        GeneratorEvaluationTest,\n                        Values(GeneratorEvaluationTest::param_value()));\n\n// Tests that generators defined in a different translation unit are\n// functional. Generator extern_gen is defined in gtest-param-test_test2.cc.\nextern ParamGenerator<int> extern_gen;\nclass ExternalGeneratorTest : public TestWithParam<int> {};\nTEST_P(ExternalGeneratorTest, ExternalGenerator) {\n  // Sequence produced by extern_gen contains only a single value\n  // which we verify here.\n  EXPECT_EQ(GetParam(), 33);\n}\nINSTANTIATE_TEST_CASE_P(ExternalGeneratorModule,\n                        ExternalGeneratorTest,\n                        extern_gen);\n\n// Tests that a parameterized test case can be defined in one translation\n// unit and instantiated in another. This test will be instantiated in\n// gtest-param-test_test2.cc. ExternalInstantiationTest fixture class is\n// defined in gtest-param-test_test.h.\nTEST_P(ExternalInstantiationTest, IsMultipleOf33) {\n  EXPECT_EQ(0, GetParam() % 33);\n}\n\n// Tests that a parameterized test case can be instantiated with multiple\n// generators.\nclass MultipleInstantiationTest : public TestWithParam<int> {};\nTEST_P(MultipleInstantiationTest, AllowsMultipleInstances) {\n}\nINSTANTIATE_TEST_CASE_P(Sequence1, MultipleInstantiationTest, Values(1, 2));\nINSTANTIATE_TEST_CASE_P(Sequence2, MultipleInstantiationTest, Range(3, 5));\n\n// Tests that a parameterized test case can be instantiated\n// in multiple translation units. This test will be instantiated\n// here and in gtest-param-test_test2.cc.\n// InstantiationInMultipleTranslationUnitsTest fixture class\n// is defined in gtest-param-test_test.h.\nTEST_P(InstantiationInMultipleTranslaionUnitsTest, IsMultipleOf42) {\n  EXPECT_EQ(0, GetParam() % 42);\n}\nINSTANTIATE_TEST_CASE_P(Sequence1,\n                        InstantiationInMultipleTranslaionUnitsTest,\n                        Values(42, 42*2));\n\n// Tests that each iteration of parameterized test runs in a separate test\n// object.\nclass SeparateInstanceTest : public TestWithParam<int> {\n public:\n  SeparateInstanceTest() : count_(0) {}\n\n  static void TearDownTestCase() {\n    EXPECT_GE(global_count_, 2)\n        << \"If some (but not all) SeparateInstanceTest tests have been \"\n        << \"filtered out this test will fail. Make sure that all \"\n        << \"GeneratorEvaluationTest are selected or de-selected together \"\n        << \"by the test filter.\";\n  }\n\n protected:\n  int count_;\n  static int global_count_;\n};\nint SeparateInstanceTest::global_count_ = 0;\n\nTEST_P(SeparateInstanceTest, TestsRunInSeparateInstances) {\n  EXPECT_EQ(0, count_++);\n  global_count_++;\n}\nINSTANTIATE_TEST_CASE_P(FourElemSequence, SeparateInstanceTest, Range(1, 4));\n\n// Tests that all instantiations of a test have named appropriately. Test\n// defined with TEST_P(TestCaseName, TestName) and instantiated with\n// INSTANTIATE_TEST_CASE_P(SequenceName, TestCaseName, generator) must be named\n// SequenceName/TestCaseName.TestName/i, where i is the 0-based index of the\n// sequence element used to instantiate the test.\nclass NamingTest : public TestWithParam<int> {};\n\nTEST_P(NamingTest, TestsReportCorrectNamesAndParameters) {\n  const ::testing::TestInfo* const test_info =\n     ::testing::UnitTest::GetInstance()->current_test_info();\n\n  EXPECT_STREQ(\"ZeroToFiveSequence/NamingTest\", test_info->test_case_name());\n\n  Message index_stream;\n  index_stream << \"TestsReportCorrectNamesAndParameters/\" << GetParam();\n  EXPECT_STREQ(index_stream.GetString().c_str(), test_info->name());\n\n  EXPECT_EQ(::testing::PrintToString(GetParam()), test_info->value_param());\n}\n\nINSTANTIATE_TEST_CASE_P(ZeroToFiveSequence, NamingTest, Range(0, 5));\n\n// Class that cannot be streamed into an ostream.  It needs to be copyable\n// (and, in case of MSVC, also assignable) in order to be a test parameter\n// type.  Its default copy constructor and assignment operator do exactly\n// what we need.\nclass Unstreamable {\n public:\n  explicit Unstreamable(int value) : value_(value) {}\n\n private:\n  int value_;\n};\n\nclass CommentTest : public TestWithParam<Unstreamable> {};\n\nTEST_P(CommentTest, TestsCorrectlyReportUnstreamableParams) {\n  const ::testing::TestInfo* const test_info =\n     ::testing::UnitTest::GetInstance()->current_test_info();\n\n  EXPECT_EQ(::testing::PrintToString(GetParam()), test_info->value_param());\n}\n\nINSTANTIATE_TEST_CASE_P(InstantiationWithComments,\n                        CommentTest,\n                        Values(Unstreamable(1)));\n\n// Verify that we can create a hierarchy of test fixtures, where the base\n// class fixture is not parameterized and the derived class is. In this case\n// ParameterizedDerivedTest inherits from NonParameterizedBaseTest.  We\n// perform simple tests on both.\nclass NonParameterizedBaseTest : public ::testing::Test {\n public:\n  NonParameterizedBaseTest() : n_(17) { }\n protected:\n  int n_;\n};\n\nclass ParameterizedDerivedTest : public NonParameterizedBaseTest,\n                                 public ::testing::WithParamInterface<int> {\n protected:\n  ParameterizedDerivedTest() : count_(0) { }\n  int count_;\n  static int global_count_;\n};\n\nint ParameterizedDerivedTest::global_count_ = 0;\n\nTEST_F(NonParameterizedBaseTest, FixtureIsInitialized) {\n  EXPECT_EQ(17, n_);\n}\n\nTEST_P(ParameterizedDerivedTest, SeesSequence) {\n  EXPECT_EQ(17, n_);\n  EXPECT_EQ(0, count_++);\n  EXPECT_EQ(GetParam(), global_count_++);\n}\n\nclass ParameterizedDeathTest : public ::testing::TestWithParam<int> { };\n\nTEST_F(ParameterizedDeathTest, GetParamDiesFromTestF) {\n  EXPECT_DEATH_IF_SUPPORTED(GetParam(),\n                            \".* value-parameterized test .*\");\n}\n\nINSTANTIATE_TEST_CASE_P(RangeZeroToFive, ParameterizedDerivedTest, Range(0, 5));\n\n#endif  // GTEST_HAS_PARAM_TEST\n\nTEST(CompileTest, CombineIsDefinedOnlyWhenGtestHasParamTestIsDefined) {\n#if GTEST_HAS_COMBINE && !GTEST_HAS_PARAM_TEST\n  FAIL() << \"GTEST_HAS_COMBINE is defined while GTEST_HAS_PARAM_TEST is not\\n\"\n#endif\n}\n\nint main(int argc, char **argv) {\n#if GTEST_HAS_PARAM_TEST\n  // Used in TestGenerationTest test case.\n  AddGlobalTestEnvironment(TestGenerationTest::Environment::Instance());\n  // Used in GeneratorEvaluationTest test case. Tests that the updated value\n  // will be picked up for instantiating tests in GeneratorEvaluationTest.\n  GeneratorEvaluationTest::set_param_value(1);\n#endif  // GTEST_HAS_PARAM_TEST\n\n  ::testing::InitGoogleTest(&argc, argv);\n\n#if GTEST_HAS_PARAM_TEST\n  // Used in GeneratorEvaluationTest test case. Tests that value updated\n  // here will NOT be used for instantiating tests in\n  // GeneratorEvaluationTest.\n  GeneratorEvaluationTest::set_param_value(2);\n#endif  // GTEST_HAS_PARAM_TEST\n\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest-param-test_test.h",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: vladl@google.com (Vlad Losev)\n//\n// The Google C++ Testing Framework (Google Test)\n//\n// This header file provides classes and functions used internally\n// for testing Google Test itself.\n\n#ifndef GTEST_TEST_GTEST_PARAM_TEST_TEST_H_\n#define GTEST_TEST_GTEST_PARAM_TEST_TEST_H_\n\n#include \"gtest/gtest.h\"\n\n#if GTEST_HAS_PARAM_TEST\n\n// Test fixture for testing definition and instantiation of a test\n// in separate translation units.\nclass ExternalInstantiationTest : public ::testing::TestWithParam<int> {\n};\n\n// Test fixture for testing instantiation of a test in multiple\n// translation units.\nclass InstantiationInMultipleTranslaionUnitsTest\n    : public ::testing::TestWithParam<int> {\n};\n\n#endif  // GTEST_HAS_PARAM_TEST\n\n#endif  // GTEST_TEST_GTEST_PARAM_TEST_TEST_H_\n"
  },
  {
    "path": "ext/gtest/test/gtest-port_test.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Authors: vladl@google.com (Vlad Losev), wan@google.com (Zhanyong Wan)\n//\n// This file tests the internal cross-platform support utilities.\n\n#include \"gtest/internal/gtest-port.h\"\n\n#include <stdio.h>\n\n#if GTEST_OS_MAC\n# include <time.h>\n#endif  // GTEST_OS_MAC\n\n#include <list>\n#include <utility>  // For std::pair and std::make_pair.\n#include <vector>\n\n#include \"gtest/gtest.h\"\n#include \"gtest/gtest-spi.h\"\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick is to\n// prevent a user from accidentally including gtest-internal-inl.h in\n// his code.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\nusing std::make_pair;\nusing std::pair;\n\nnamespace testing {\nnamespace internal {\n\nTEST(IsXDigitTest, WorksForNarrowAscii) {\n  EXPECT_TRUE(IsXDigit('0'));\n  EXPECT_TRUE(IsXDigit('9'));\n  EXPECT_TRUE(IsXDigit('A'));\n  EXPECT_TRUE(IsXDigit('F'));\n  EXPECT_TRUE(IsXDigit('a'));\n  EXPECT_TRUE(IsXDigit('f'));\n\n  EXPECT_FALSE(IsXDigit('-'));\n  EXPECT_FALSE(IsXDigit('g'));\n  EXPECT_FALSE(IsXDigit('G'));\n}\n\nTEST(IsXDigitTest, ReturnsFalseForNarrowNonAscii) {\n  EXPECT_FALSE(IsXDigit(static_cast<char>(0x80)));\n  EXPECT_FALSE(IsXDigit(static_cast<char>('0' | 0x80)));\n}\n\nTEST(IsXDigitTest, WorksForWideAscii) {\n  EXPECT_TRUE(IsXDigit(L'0'));\n  EXPECT_TRUE(IsXDigit(L'9'));\n  EXPECT_TRUE(IsXDigit(L'A'));\n  EXPECT_TRUE(IsXDigit(L'F'));\n  EXPECT_TRUE(IsXDigit(L'a'));\n  EXPECT_TRUE(IsXDigit(L'f'));\n\n  EXPECT_FALSE(IsXDigit(L'-'));\n  EXPECT_FALSE(IsXDigit(L'g'));\n  EXPECT_FALSE(IsXDigit(L'G'));\n}\n\nTEST(IsXDigitTest, ReturnsFalseForWideNonAscii) {\n  EXPECT_FALSE(IsXDigit(static_cast<wchar_t>(0x80)));\n  EXPECT_FALSE(IsXDigit(static_cast<wchar_t>(L'0' | 0x80)));\n  EXPECT_FALSE(IsXDigit(static_cast<wchar_t>(L'0' | 0x100)));\n}\n\nclass Base {\n public:\n  // Copy constructor and assignment operator do exactly what we need, so we\n  // use them.\n  Base() : member_(0) {}\n  explicit Base(int n) : member_(n) {}\n  virtual ~Base() {}\n  int member() { return member_; }\n\n private:\n  int member_;\n};\n\nclass Derived : public Base {\n public:\n  explicit Derived(int n) : Base(n) {}\n};\n\nTEST(ImplicitCastTest, ConvertsPointers) {\n  Derived derived(0);\n  EXPECT_TRUE(&derived == ::testing::internal::ImplicitCast_<Base*>(&derived));\n}\n\nTEST(ImplicitCastTest, CanUseInheritance) {\n  Derived derived(1);\n  Base base = ::testing::internal::ImplicitCast_<Base>(derived);\n  EXPECT_EQ(derived.member(), base.member());\n}\n\nclass Castable {\n public:\n  explicit Castable(bool* converted) : converted_(converted) {}\n  operator Base() {\n    *converted_ = true;\n    return Base();\n  }\n\n private:\n  bool* converted_;\n};\n\nTEST(ImplicitCastTest, CanUseNonConstCastOperator) {\n  bool converted = false;\n  Castable castable(&converted);\n  Base base = ::testing::internal::ImplicitCast_<Base>(castable);\n  EXPECT_TRUE(converted);\n}\n\nclass ConstCastable {\n public:\n  explicit ConstCastable(bool* converted) : converted_(converted) {}\n  operator Base() const {\n    *converted_ = true;\n    return Base();\n  }\n\n private:\n  bool* converted_;\n};\n\nTEST(ImplicitCastTest, CanUseConstCastOperatorOnConstValues) {\n  bool converted = false;\n  const ConstCastable const_castable(&converted);\n  Base base = ::testing::internal::ImplicitCast_<Base>(const_castable);\n  EXPECT_TRUE(converted);\n}\n\nclass ConstAndNonConstCastable {\n public:\n  ConstAndNonConstCastable(bool* converted, bool* const_converted)\n      : converted_(converted), const_converted_(const_converted) {}\n  operator Base() {\n    *converted_ = true;\n    return Base();\n  }\n  operator Base() const {\n    *const_converted_ = true;\n    return Base();\n  }\n\n private:\n  bool* converted_;\n  bool* const_converted_;\n};\n\nTEST(ImplicitCastTest, CanSelectBetweenConstAndNonConstCasrAppropriately) {\n  bool converted = false;\n  bool const_converted = false;\n  ConstAndNonConstCastable castable(&converted, &const_converted);\n  Base base = ::testing::internal::ImplicitCast_<Base>(castable);\n  EXPECT_TRUE(converted);\n  EXPECT_FALSE(const_converted);\n\n  converted = false;\n  const_converted = false;\n  const ConstAndNonConstCastable const_castable(&converted, &const_converted);\n  base = ::testing::internal::ImplicitCast_<Base>(const_castable);\n  EXPECT_FALSE(converted);\n  EXPECT_TRUE(const_converted);\n}\n\nclass To {\n public:\n  To(bool* converted) { *converted = true; }  // NOLINT\n};\n\nTEST(ImplicitCastTest, CanUseImplicitConstructor) {\n  bool converted = false;\n  To to = ::testing::internal::ImplicitCast_<To>(&converted);\n  (void)to;\n  EXPECT_TRUE(converted);\n}\n\nTEST(IteratorTraitsTest, WorksForSTLContainerIterators) {\n  StaticAssertTypeEq<int,\n      IteratorTraits< ::std::vector<int>::const_iterator>::value_type>();\n  StaticAssertTypeEq<bool,\n      IteratorTraits< ::std::list<bool>::iterator>::value_type>();\n}\n\nTEST(IteratorTraitsTest, WorksForPointerToNonConst) {\n  StaticAssertTypeEq<char, IteratorTraits<char*>::value_type>();\n  StaticAssertTypeEq<const void*, IteratorTraits<const void**>::value_type>();\n}\n\nTEST(IteratorTraitsTest, WorksForPointerToConst) {\n  StaticAssertTypeEq<char, IteratorTraits<const char*>::value_type>();\n  StaticAssertTypeEq<const void*,\n      IteratorTraits<const void* const*>::value_type>();\n}\n\n// Tests that the element_type typedef is available in scoped_ptr and refers\n// to the parameter type.\nTEST(ScopedPtrTest, DefinesElementType) {\n  StaticAssertTypeEq<int, ::testing::internal::scoped_ptr<int>::element_type>();\n}\n\n// TODO(vladl@google.com): Implement THE REST of scoped_ptr tests.\n\nTEST(GtestCheckSyntaxTest, BehavesLikeASingleStatement) {\n  if (AlwaysFalse())\n    GTEST_CHECK_(false) << \"This should never be executed; \"\n                           \"It's a compilation test only.\";\n\n  if (AlwaysTrue())\n    GTEST_CHECK_(true);\n  else\n    ;  // NOLINT\n\n  if (AlwaysFalse())\n    ;  // NOLINT\n  else\n    GTEST_CHECK_(true) << \"\";\n}\n\nTEST(GtestCheckSyntaxTest, WorksWithSwitch) {\n  switch (0) {\n    case 1:\n      break;\n    default:\n      GTEST_CHECK_(true);\n  }\n\n  switch (0)\n    case 0:\n      GTEST_CHECK_(true) << \"Check failed in switch case\";\n}\n\n// Verifies behavior of FormatFileLocation.\nTEST(FormatFileLocationTest, FormatsFileLocation) {\n  EXPECT_PRED_FORMAT2(IsSubstring, \"foo.cc\", FormatFileLocation(\"foo.cc\", 42));\n  EXPECT_PRED_FORMAT2(IsSubstring, \"42\", FormatFileLocation(\"foo.cc\", 42));\n}\n\nTEST(FormatFileLocationTest, FormatsUnknownFile) {\n  EXPECT_PRED_FORMAT2(\n      IsSubstring, \"unknown file\", FormatFileLocation(NULL, 42));\n  EXPECT_PRED_FORMAT2(IsSubstring, \"42\", FormatFileLocation(NULL, 42));\n}\n\nTEST(FormatFileLocationTest, FormatsUknownLine) {\n  EXPECT_EQ(\"foo.cc:\", FormatFileLocation(\"foo.cc\", -1));\n}\n\nTEST(FormatFileLocationTest, FormatsUknownFileAndLine) {\n  EXPECT_EQ(\"unknown file:\", FormatFileLocation(NULL, -1));\n}\n\n// Verifies behavior of FormatCompilerIndependentFileLocation.\nTEST(FormatCompilerIndependentFileLocationTest, FormatsFileLocation) {\n  EXPECT_EQ(\"foo.cc:42\", FormatCompilerIndependentFileLocation(\"foo.cc\", 42));\n}\n\nTEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFile) {\n  EXPECT_EQ(\"unknown file:42\",\n            FormatCompilerIndependentFileLocation(NULL, 42));\n}\n\nTEST(FormatCompilerIndependentFileLocationTest, FormatsUknownLine) {\n  EXPECT_EQ(\"foo.cc\", FormatCompilerIndependentFileLocation(\"foo.cc\", -1));\n}\n\nTEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFileAndLine) {\n  EXPECT_EQ(\"unknown file\", FormatCompilerIndependentFileLocation(NULL, -1));\n}\n\n#if GTEST_OS_MAC || GTEST_OS_QNX\nvoid* ThreadFunc(void* data) {\n  pthread_mutex_t* mutex = static_cast<pthread_mutex_t*>(data);\n  pthread_mutex_lock(mutex);\n  pthread_mutex_unlock(mutex);\n  return NULL;\n}\n\nTEST(GetThreadCountTest, ReturnsCorrectValue) {\n  EXPECT_EQ(1U, GetThreadCount());\n  pthread_mutex_t mutex;\n  pthread_attr_t  attr;\n  pthread_t       thread_id;\n\n  // TODO(vladl@google.com): turn mutex into internal::Mutex for automatic\n  // destruction.\n  pthread_mutex_init(&mutex, NULL);\n  pthread_mutex_lock(&mutex);\n  ASSERT_EQ(0, pthread_attr_init(&attr));\n  ASSERT_EQ(0, pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE));\n\n  const int status = pthread_create(&thread_id, &attr, &ThreadFunc, &mutex);\n  ASSERT_EQ(0, pthread_attr_destroy(&attr));\n  ASSERT_EQ(0, status);\n  EXPECT_EQ(2U, GetThreadCount());\n  pthread_mutex_unlock(&mutex);\n\n  void* dummy;\n  ASSERT_EQ(0, pthread_join(thread_id, &dummy));\n\n# if GTEST_OS_MAC\n\n  // MacOS X may not immediately report the updated thread count after\n  // joining a thread, causing flakiness in this test. To counter that, we\n  // wait for up to .5 seconds for the OS to report the correct value.\n  for (int i = 0; i < 5; ++i) {\n    if (GetThreadCount() == 1)\n      break;\n\n    SleepMilliseconds(100);\n  }\n\n# endif  // GTEST_OS_MAC\n\n  EXPECT_EQ(1U, GetThreadCount());\n  pthread_mutex_destroy(&mutex);\n}\n#else\nTEST(GetThreadCountTest, ReturnsZeroWhenUnableToCountThreads) {\n  EXPECT_EQ(0U, GetThreadCount());\n}\n#endif  // GTEST_OS_MAC || GTEST_OS_QNX\n\nTEST(GtestCheckDeathTest, DiesWithCorrectOutputOnFailure) {\n  const bool a_false_condition = false;\n  const char regex[] =\n#ifdef _MSC_VER\n     \"gtest-port_test\\\\.cc\\\\(\\\\d+\\\\):\"\n#elif GTEST_USES_POSIX_RE\n     \"gtest-port_test\\\\.cc:[0-9]+\"\n#else\n     \"gtest-port_test\\\\.cc:\\\\d+\"\n#endif  // _MSC_VER\n     \".*a_false_condition.*Extra info.*\";\n\n  EXPECT_DEATH_IF_SUPPORTED(GTEST_CHECK_(a_false_condition) << \"Extra info\",\n                            regex);\n}\n\n#if GTEST_HAS_DEATH_TEST\n\nTEST(GtestCheckDeathTest, LivesSilentlyOnSuccess) {\n  EXPECT_EXIT({\n      GTEST_CHECK_(true) << \"Extra info\";\n      ::std::cerr << \"Success\\n\";\n      exit(0); },\n      ::testing::ExitedWithCode(0), \"Success\");\n}\n\n#endif  // GTEST_HAS_DEATH_TEST\n\n// Verifies that Google Test choose regular expression engine appropriate to\n// the platform. The test will produce compiler errors in case of failure.\n// For simplicity, we only cover the most important platforms here.\nTEST(RegexEngineSelectionTest, SelectsCorrectRegexEngine) {\n#if GTEST_HAS_POSIX_RE\n\n  EXPECT_TRUE(GTEST_USES_POSIX_RE);\n\n#else\n\n  EXPECT_TRUE(GTEST_USES_SIMPLE_RE);\n\n#endif\n}\n\n#if GTEST_USES_POSIX_RE\n\n# if GTEST_HAS_TYPED_TEST\n\ntemplate <typename Str>\nclass RETest : public ::testing::Test {};\n\n// Defines StringTypes as the list of all string types that class RE\n// supports.\ntypedef testing::Types<\n    ::std::string,\n#  if GTEST_HAS_GLOBAL_STRING\n    ::string,\n#  endif  // GTEST_HAS_GLOBAL_STRING\n    const char*> StringTypes;\n\nTYPED_TEST_CASE(RETest, StringTypes);\n\n// Tests RE's implicit constructors.\nTYPED_TEST(RETest, ImplicitConstructorWorks) {\n  const RE empty(TypeParam(\"\"));\n  EXPECT_STREQ(\"\", empty.pattern());\n\n  const RE simple(TypeParam(\"hello\"));\n  EXPECT_STREQ(\"hello\", simple.pattern());\n\n  const RE normal(TypeParam(\".*(\\\\w+)\"));\n  EXPECT_STREQ(\".*(\\\\w+)\", normal.pattern());\n}\n\n// Tests that RE's constructors reject invalid regular expressions.\nTYPED_TEST(RETest, RejectsInvalidRegex) {\n  EXPECT_NONFATAL_FAILURE({\n    const RE invalid(TypeParam(\"?\"));\n  }, \"\\\"?\\\" is not a valid POSIX Extended regular expression.\");\n}\n\n// Tests RE::FullMatch().\nTYPED_TEST(RETest, FullMatchWorks) {\n  const RE empty(TypeParam(\"\"));\n  EXPECT_TRUE(RE::FullMatch(TypeParam(\"\"), empty));\n  EXPECT_FALSE(RE::FullMatch(TypeParam(\"a\"), empty));\n\n  const RE re(TypeParam(\"a.*z\"));\n  EXPECT_TRUE(RE::FullMatch(TypeParam(\"az\"), re));\n  EXPECT_TRUE(RE::FullMatch(TypeParam(\"axyz\"), re));\n  EXPECT_FALSE(RE::FullMatch(TypeParam(\"baz\"), re));\n  EXPECT_FALSE(RE::FullMatch(TypeParam(\"azy\"), re));\n}\n\n// Tests RE::PartialMatch().\nTYPED_TEST(RETest, PartialMatchWorks) {\n  const RE empty(TypeParam(\"\"));\n  EXPECT_TRUE(RE::PartialMatch(TypeParam(\"\"), empty));\n  EXPECT_TRUE(RE::PartialMatch(TypeParam(\"a\"), empty));\n\n  const RE re(TypeParam(\"a.*z\"));\n  EXPECT_TRUE(RE::PartialMatch(TypeParam(\"az\"), re));\n  EXPECT_TRUE(RE::PartialMatch(TypeParam(\"axyz\"), re));\n  EXPECT_TRUE(RE::PartialMatch(TypeParam(\"baz\"), re));\n  EXPECT_TRUE(RE::PartialMatch(TypeParam(\"azy\"), re));\n  EXPECT_FALSE(RE::PartialMatch(TypeParam(\"zza\"), re));\n}\n\n# endif  // GTEST_HAS_TYPED_TEST\n\n#elif GTEST_USES_SIMPLE_RE\n\nTEST(IsInSetTest, NulCharIsNotInAnySet) {\n  EXPECT_FALSE(IsInSet('\\0', \"\"));\n  EXPECT_FALSE(IsInSet('\\0', \"\\0\"));\n  EXPECT_FALSE(IsInSet('\\0', \"a\"));\n}\n\nTEST(IsInSetTest, WorksForNonNulChars) {\n  EXPECT_FALSE(IsInSet('a', \"Ab\"));\n  EXPECT_FALSE(IsInSet('c', \"\"));\n\n  EXPECT_TRUE(IsInSet('b', \"bcd\"));\n  EXPECT_TRUE(IsInSet('b', \"ab\"));\n}\n\nTEST(IsAsciiDigitTest, IsFalseForNonDigit) {\n  EXPECT_FALSE(IsAsciiDigit('\\0'));\n  EXPECT_FALSE(IsAsciiDigit(' '));\n  EXPECT_FALSE(IsAsciiDigit('+'));\n  EXPECT_FALSE(IsAsciiDigit('-'));\n  EXPECT_FALSE(IsAsciiDigit('.'));\n  EXPECT_FALSE(IsAsciiDigit('a'));\n}\n\nTEST(IsAsciiDigitTest, IsTrueForDigit) {\n  EXPECT_TRUE(IsAsciiDigit('0'));\n  EXPECT_TRUE(IsAsciiDigit('1'));\n  EXPECT_TRUE(IsAsciiDigit('5'));\n  EXPECT_TRUE(IsAsciiDigit('9'));\n}\n\nTEST(IsAsciiPunctTest, IsFalseForNonPunct) {\n  EXPECT_FALSE(IsAsciiPunct('\\0'));\n  EXPECT_FALSE(IsAsciiPunct(' '));\n  EXPECT_FALSE(IsAsciiPunct('\\n'));\n  EXPECT_FALSE(IsAsciiPunct('a'));\n  EXPECT_FALSE(IsAsciiPunct('0'));\n}\n\nTEST(IsAsciiPunctTest, IsTrueForPunct) {\n  for (const char* p = \"^-!\\\"#$%&'()*+,./:;<=>?@[\\\\]_`{|}~\"; *p; p++) {\n    EXPECT_PRED1(IsAsciiPunct, *p);\n  }\n}\n\nTEST(IsRepeatTest, IsFalseForNonRepeatChar) {\n  EXPECT_FALSE(IsRepeat('\\0'));\n  EXPECT_FALSE(IsRepeat(' '));\n  EXPECT_FALSE(IsRepeat('a'));\n  EXPECT_FALSE(IsRepeat('1'));\n  EXPECT_FALSE(IsRepeat('-'));\n}\n\nTEST(IsRepeatTest, IsTrueForRepeatChar) {\n  EXPECT_TRUE(IsRepeat('?'));\n  EXPECT_TRUE(IsRepeat('*'));\n  EXPECT_TRUE(IsRepeat('+'));\n}\n\nTEST(IsAsciiWhiteSpaceTest, IsFalseForNonWhiteSpace) {\n  EXPECT_FALSE(IsAsciiWhiteSpace('\\0'));\n  EXPECT_FALSE(IsAsciiWhiteSpace('a'));\n  EXPECT_FALSE(IsAsciiWhiteSpace('1'));\n  EXPECT_FALSE(IsAsciiWhiteSpace('+'));\n  EXPECT_FALSE(IsAsciiWhiteSpace('_'));\n}\n\nTEST(IsAsciiWhiteSpaceTest, IsTrueForWhiteSpace) {\n  EXPECT_TRUE(IsAsciiWhiteSpace(' '));\n  EXPECT_TRUE(IsAsciiWhiteSpace('\\n'));\n  EXPECT_TRUE(IsAsciiWhiteSpace('\\r'));\n  EXPECT_TRUE(IsAsciiWhiteSpace('\\t'));\n  EXPECT_TRUE(IsAsciiWhiteSpace('\\v'));\n  EXPECT_TRUE(IsAsciiWhiteSpace('\\f'));\n}\n\nTEST(IsAsciiWordCharTest, IsFalseForNonWordChar) {\n  EXPECT_FALSE(IsAsciiWordChar('\\0'));\n  EXPECT_FALSE(IsAsciiWordChar('+'));\n  EXPECT_FALSE(IsAsciiWordChar('.'));\n  EXPECT_FALSE(IsAsciiWordChar(' '));\n  EXPECT_FALSE(IsAsciiWordChar('\\n'));\n}\n\nTEST(IsAsciiWordCharTest, IsTrueForLetter) {\n  EXPECT_TRUE(IsAsciiWordChar('a'));\n  EXPECT_TRUE(IsAsciiWordChar('b'));\n  EXPECT_TRUE(IsAsciiWordChar('A'));\n  EXPECT_TRUE(IsAsciiWordChar('Z'));\n}\n\nTEST(IsAsciiWordCharTest, IsTrueForDigit) {\n  EXPECT_TRUE(IsAsciiWordChar('0'));\n  EXPECT_TRUE(IsAsciiWordChar('1'));\n  EXPECT_TRUE(IsAsciiWordChar('7'));\n  EXPECT_TRUE(IsAsciiWordChar('9'));\n}\n\nTEST(IsAsciiWordCharTest, IsTrueForUnderscore) {\n  EXPECT_TRUE(IsAsciiWordChar('_'));\n}\n\nTEST(IsValidEscapeTest, IsFalseForNonPrintable) {\n  EXPECT_FALSE(IsValidEscape('\\0'));\n  EXPECT_FALSE(IsValidEscape('\\007'));\n}\n\nTEST(IsValidEscapeTest, IsFalseForDigit) {\n  EXPECT_FALSE(IsValidEscape('0'));\n  EXPECT_FALSE(IsValidEscape('9'));\n}\n\nTEST(IsValidEscapeTest, IsFalseForWhiteSpace) {\n  EXPECT_FALSE(IsValidEscape(' '));\n  EXPECT_FALSE(IsValidEscape('\\n'));\n}\n\nTEST(IsValidEscapeTest, IsFalseForSomeLetter) {\n  EXPECT_FALSE(IsValidEscape('a'));\n  EXPECT_FALSE(IsValidEscape('Z'));\n}\n\nTEST(IsValidEscapeTest, IsTrueForPunct) {\n  EXPECT_TRUE(IsValidEscape('.'));\n  EXPECT_TRUE(IsValidEscape('-'));\n  EXPECT_TRUE(IsValidEscape('^'));\n  EXPECT_TRUE(IsValidEscape('$'));\n  EXPECT_TRUE(IsValidEscape('('));\n  EXPECT_TRUE(IsValidEscape(']'));\n  EXPECT_TRUE(IsValidEscape('{'));\n  EXPECT_TRUE(IsValidEscape('|'));\n}\n\nTEST(IsValidEscapeTest, IsTrueForSomeLetter) {\n  EXPECT_TRUE(IsValidEscape('d'));\n  EXPECT_TRUE(IsValidEscape('D'));\n  EXPECT_TRUE(IsValidEscape('s'));\n  EXPECT_TRUE(IsValidEscape('S'));\n  EXPECT_TRUE(IsValidEscape('w'));\n  EXPECT_TRUE(IsValidEscape('W'));\n}\n\nTEST(AtomMatchesCharTest, EscapedPunct) {\n  EXPECT_FALSE(AtomMatchesChar(true, '\\\\', '\\0'));\n  EXPECT_FALSE(AtomMatchesChar(true, '\\\\', ' '));\n  EXPECT_FALSE(AtomMatchesChar(true, '_', '.'));\n  EXPECT_FALSE(AtomMatchesChar(true, '.', 'a'));\n\n  EXPECT_TRUE(AtomMatchesChar(true, '\\\\', '\\\\'));\n  EXPECT_TRUE(AtomMatchesChar(true, '_', '_'));\n  EXPECT_TRUE(AtomMatchesChar(true, '+', '+'));\n  EXPECT_TRUE(AtomMatchesChar(true, '.', '.'));\n}\n\nTEST(AtomMatchesCharTest, Escaped_d) {\n  EXPECT_FALSE(AtomMatchesChar(true, 'd', '\\0'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'd', 'a'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'd', '.'));\n\n  EXPECT_TRUE(AtomMatchesChar(true, 'd', '0'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'd', '9'));\n}\n\nTEST(AtomMatchesCharTest, Escaped_D) {\n  EXPECT_FALSE(AtomMatchesChar(true, 'D', '0'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'D', '9'));\n\n  EXPECT_TRUE(AtomMatchesChar(true, 'D', '\\0'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'D', 'a'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'D', '-'));\n}\n\nTEST(AtomMatchesCharTest, Escaped_s) {\n  EXPECT_FALSE(AtomMatchesChar(true, 's', '\\0'));\n  EXPECT_FALSE(AtomMatchesChar(true, 's', 'a'));\n  EXPECT_FALSE(AtomMatchesChar(true, 's', '.'));\n  EXPECT_FALSE(AtomMatchesChar(true, 's', '9'));\n\n  EXPECT_TRUE(AtomMatchesChar(true, 's', ' '));\n  EXPECT_TRUE(AtomMatchesChar(true, 's', '\\n'));\n  EXPECT_TRUE(AtomMatchesChar(true, 's', '\\t'));\n}\n\nTEST(AtomMatchesCharTest, Escaped_S) {\n  EXPECT_FALSE(AtomMatchesChar(true, 'S', ' '));\n  EXPECT_FALSE(AtomMatchesChar(true, 'S', '\\r'));\n\n  EXPECT_TRUE(AtomMatchesChar(true, 'S', '\\0'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'S', 'a'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'S', '9'));\n}\n\nTEST(AtomMatchesCharTest, Escaped_w) {\n  EXPECT_FALSE(AtomMatchesChar(true, 'w', '\\0'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'w', '+'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'w', ' '));\n  EXPECT_FALSE(AtomMatchesChar(true, 'w', '\\n'));\n\n  EXPECT_TRUE(AtomMatchesChar(true, 'w', '0'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'w', 'b'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'w', 'C'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'w', '_'));\n}\n\nTEST(AtomMatchesCharTest, Escaped_W) {\n  EXPECT_FALSE(AtomMatchesChar(true, 'W', 'A'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'W', 'b'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'W', '9'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'W', '_'));\n\n  EXPECT_TRUE(AtomMatchesChar(true, 'W', '\\0'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'W', '*'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'W', '\\n'));\n}\n\nTEST(AtomMatchesCharTest, EscapedWhiteSpace) {\n  EXPECT_FALSE(AtomMatchesChar(true, 'f', '\\0'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'f', '\\n'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'n', '\\0'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'n', '\\r'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'r', '\\0'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'r', 'a'));\n  EXPECT_FALSE(AtomMatchesChar(true, 't', '\\0'));\n  EXPECT_FALSE(AtomMatchesChar(true, 't', 't'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'v', '\\0'));\n  EXPECT_FALSE(AtomMatchesChar(true, 'v', '\\f'));\n\n  EXPECT_TRUE(AtomMatchesChar(true, 'f', '\\f'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'n', '\\n'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'r', '\\r'));\n  EXPECT_TRUE(AtomMatchesChar(true, 't', '\\t'));\n  EXPECT_TRUE(AtomMatchesChar(true, 'v', '\\v'));\n}\n\nTEST(AtomMatchesCharTest, UnescapedDot) {\n  EXPECT_FALSE(AtomMatchesChar(false, '.', '\\n'));\n\n  EXPECT_TRUE(AtomMatchesChar(false, '.', '\\0'));\n  EXPECT_TRUE(AtomMatchesChar(false, '.', '.'));\n  EXPECT_TRUE(AtomMatchesChar(false, '.', 'a'));\n  EXPECT_TRUE(AtomMatchesChar(false, '.', ' '));\n}\n\nTEST(AtomMatchesCharTest, UnescapedChar) {\n  EXPECT_FALSE(AtomMatchesChar(false, 'a', '\\0'));\n  EXPECT_FALSE(AtomMatchesChar(false, 'a', 'b'));\n  EXPECT_FALSE(AtomMatchesChar(false, '$', 'a'));\n\n  EXPECT_TRUE(AtomMatchesChar(false, '$', '$'));\n  EXPECT_TRUE(AtomMatchesChar(false, '5', '5'));\n  EXPECT_TRUE(AtomMatchesChar(false, 'Z', 'Z'));\n}\n\nTEST(ValidateRegexTest, GeneratesFailureAndReturnsFalseForInvalid) {\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(NULL)),\n                          \"NULL is not a valid simple regular expression\");\n  EXPECT_NONFATAL_FAILURE(\n      ASSERT_FALSE(ValidateRegex(\"a\\\\\")),\n      \"Syntax error at index 1 in simple regular expression \\\"a\\\\\\\": \");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"a\\\\\")),\n                          \"'\\\\' cannot appear at the end\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"\\\\n\\\\\")),\n                          \"'\\\\' cannot appear at the end\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"\\\\s\\\\hb\")),\n                          \"invalid escape sequence \\\"\\\\h\\\"\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"^^\")),\n                          \"'^' can only appear at the beginning\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\".*^b\")),\n                          \"'^' can only appear at the beginning\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"$$\")),\n                          \"'$' can only appear at the end\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"^$a\")),\n                          \"'$' can only appear at the end\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"a(b\")),\n                          \"'(' is unsupported\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"ab)\")),\n                          \"')' is unsupported\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"[ab\")),\n                          \"'[' is unsupported\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"a{2\")),\n                          \"'{' is unsupported\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"?\")),\n                          \"'?' can only follow a repeatable token\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"^*\")),\n                          \"'*' can only follow a repeatable token\");\n  EXPECT_NONFATAL_FAILURE(ASSERT_FALSE(ValidateRegex(\"5*+\")),\n                          \"'+' can only follow a repeatable token\");\n}\n\nTEST(ValidateRegexTest, ReturnsTrueForValid) {\n  EXPECT_TRUE(ValidateRegex(\"\"));\n  EXPECT_TRUE(ValidateRegex(\"a\"));\n  EXPECT_TRUE(ValidateRegex(\".*\"));\n  EXPECT_TRUE(ValidateRegex(\"^a_+\"));\n  EXPECT_TRUE(ValidateRegex(\"^a\\\\t\\\\&?\"));\n  EXPECT_TRUE(ValidateRegex(\"09*$\"));\n  EXPECT_TRUE(ValidateRegex(\"^Z$\"));\n  EXPECT_TRUE(ValidateRegex(\"a\\\\^Z\\\\$\\\\(\\\\)\\\\|\\\\[\\\\]\\\\{\\\\}\"));\n}\n\nTEST(MatchRepetitionAndRegexAtHeadTest, WorksForZeroOrOne) {\n  EXPECT_FALSE(MatchRepetitionAndRegexAtHead(false, 'a', '?', \"a\", \"ba\"));\n  // Repeating more than once.\n  EXPECT_FALSE(MatchRepetitionAndRegexAtHead(false, 'a', '?', \"b\", \"aab\"));\n\n  // Repeating zero times.\n  EXPECT_TRUE(MatchRepetitionAndRegexAtHead(false, 'a', '?', \"b\", \"ba\"));\n  // Repeating once.\n  EXPECT_TRUE(MatchRepetitionAndRegexAtHead(false, 'a', '?', \"b\", \"ab\"));\n  EXPECT_TRUE(MatchRepetitionAndRegexAtHead(false, '#', '?', \".\", \"##\"));\n}\n\nTEST(MatchRepetitionAndRegexAtHeadTest, WorksForZeroOrMany) {\n  EXPECT_FALSE(MatchRepetitionAndRegexAtHead(false, '.', '*', \"a$\", \"baab\"));\n\n  // Repeating zero times.\n  EXPECT_TRUE(MatchRepetitionAndRegexAtHead(false, '.', '*', \"b\", \"bc\"));\n  // Repeating once.\n  EXPECT_TRUE(MatchRepetitionAndRegexAtHead(false, '.', '*', \"b\", \"abc\"));\n  // Repeating more than once.\n  EXPECT_TRUE(MatchRepetitionAndRegexAtHead(true, 'w', '*', \"-\", \"ab_1-g\"));\n}\n\nTEST(MatchRepetitionAndRegexAtHeadTest, WorksForOneOrMany) {\n  EXPECT_FALSE(MatchRepetitionAndRegexAtHead(false, '.', '+', \"a$\", \"baab\"));\n  // Repeating zero times.\n  EXPECT_FALSE(MatchRepetitionAndRegexAtHead(false, '.', '+', \"b\", \"bc\"));\n\n  // Repeating once.\n  EXPECT_TRUE(MatchRepetitionAndRegexAtHead(false, '.', '+', \"b\", \"abc\"));\n  // Repeating more than once.\n  EXPECT_TRUE(MatchRepetitionAndRegexAtHead(true, 'w', '+', \"-\", \"ab_1-g\"));\n}\n\nTEST(MatchRegexAtHeadTest, ReturnsTrueForEmptyRegex) {\n  EXPECT_TRUE(MatchRegexAtHead(\"\", \"\"));\n  EXPECT_TRUE(MatchRegexAtHead(\"\", \"ab\"));\n}\n\nTEST(MatchRegexAtHeadTest, WorksWhenDollarIsInRegex) {\n  EXPECT_FALSE(MatchRegexAtHead(\"$\", \"a\"));\n\n  EXPECT_TRUE(MatchRegexAtHead(\"$\", \"\"));\n  EXPECT_TRUE(MatchRegexAtHead(\"a$\", \"a\"));\n}\n\nTEST(MatchRegexAtHeadTest, WorksWhenRegexStartsWithEscapeSequence) {\n  EXPECT_FALSE(MatchRegexAtHead(\"\\\\w\", \"+\"));\n  EXPECT_FALSE(MatchRegexAtHead(\"\\\\W\", \"ab\"));\n\n  EXPECT_TRUE(MatchRegexAtHead(\"\\\\sa\", \"\\nab\"));\n  EXPECT_TRUE(MatchRegexAtHead(\"\\\\d\", \"1a\"));\n}\n\nTEST(MatchRegexAtHeadTest, WorksWhenRegexStartsWithRepetition) {\n  EXPECT_FALSE(MatchRegexAtHead(\".+a\", \"abc\"));\n  EXPECT_FALSE(MatchRegexAtHead(\"a?b\", \"aab\"));\n\n  EXPECT_TRUE(MatchRegexAtHead(\".*a\", \"bc12-ab\"));\n  EXPECT_TRUE(MatchRegexAtHead(\"a?b\", \"b\"));\n  EXPECT_TRUE(MatchRegexAtHead(\"a?b\", \"ab\"));\n}\n\nTEST(MatchRegexAtHeadTest,\n     WorksWhenRegexStartsWithRepetionOfEscapeSequence) {\n  EXPECT_FALSE(MatchRegexAtHead(\"\\\\.+a\", \"abc\"));\n  EXPECT_FALSE(MatchRegexAtHead(\"\\\\s?b\", \"  b\"));\n\n  EXPECT_TRUE(MatchRegexAtHead(\"\\\\(*a\", \"((((ab\"));\n  EXPECT_TRUE(MatchRegexAtHead(\"\\\\^?b\", \"^b\"));\n  EXPECT_TRUE(MatchRegexAtHead(\"\\\\\\\\?b\", \"b\"));\n  EXPECT_TRUE(MatchRegexAtHead(\"\\\\\\\\?b\", \"\\\\b\"));\n}\n\nTEST(MatchRegexAtHeadTest, MatchesSequentially) {\n  EXPECT_FALSE(MatchRegexAtHead(\"ab.*c\", \"acabc\"));\n\n  EXPECT_TRUE(MatchRegexAtHead(\"ab.*c\", \"ab-fsc\"));\n}\n\nTEST(MatchRegexAnywhereTest, ReturnsFalseWhenStringIsNull) {\n  EXPECT_FALSE(MatchRegexAnywhere(\"\", NULL));\n}\n\nTEST(MatchRegexAnywhereTest, WorksWhenRegexStartsWithCaret) {\n  EXPECT_FALSE(MatchRegexAnywhere(\"^a\", \"ba\"));\n  EXPECT_FALSE(MatchRegexAnywhere(\"^$\", \"a\"));\n\n  EXPECT_TRUE(MatchRegexAnywhere(\"^a\", \"ab\"));\n  EXPECT_TRUE(MatchRegexAnywhere(\"^\", \"ab\"));\n  EXPECT_TRUE(MatchRegexAnywhere(\"^$\", \"\"));\n}\n\nTEST(MatchRegexAnywhereTest, ReturnsFalseWhenNoMatch) {\n  EXPECT_FALSE(MatchRegexAnywhere(\"a\", \"bcde123\"));\n  EXPECT_FALSE(MatchRegexAnywhere(\"a.+a\", \"--aa88888888\"));\n}\n\nTEST(MatchRegexAnywhereTest, ReturnsTrueWhenMatchingPrefix) {\n  EXPECT_TRUE(MatchRegexAnywhere(\"\\\\w+\", \"ab1_ - 5\"));\n  EXPECT_TRUE(MatchRegexAnywhere(\".*=\", \"=\"));\n  EXPECT_TRUE(MatchRegexAnywhere(\"x.*ab?.*bc\", \"xaaabc\"));\n}\n\nTEST(MatchRegexAnywhereTest, ReturnsTrueWhenMatchingNonPrefix) {\n  EXPECT_TRUE(MatchRegexAnywhere(\"\\\\w+\", \"$$$ ab1_ - 5\"));\n  EXPECT_TRUE(MatchRegexAnywhere(\"\\\\.+=\", \"=  ...=\"));\n}\n\n// Tests RE's implicit constructors.\nTEST(RETest, ImplicitConstructorWorks) {\n  const RE empty(\"\");\n  EXPECT_STREQ(\"\", empty.pattern());\n\n  const RE simple(\"hello\");\n  EXPECT_STREQ(\"hello\", simple.pattern());\n}\n\n// Tests that RE's constructors reject invalid regular expressions.\nTEST(RETest, RejectsInvalidRegex) {\n  EXPECT_NONFATAL_FAILURE({\n    const RE normal(NULL);\n  }, \"NULL is not a valid simple regular expression\");\n\n  EXPECT_NONFATAL_FAILURE({\n    const RE normal(\".*(\\\\w+\");\n  }, \"'(' is unsupported\");\n\n  EXPECT_NONFATAL_FAILURE({\n    const RE invalid(\"^?\");\n  }, \"'?' can only follow a repeatable token\");\n}\n\n// Tests RE::FullMatch().\nTEST(RETest, FullMatchWorks) {\n  const RE empty(\"\");\n  EXPECT_TRUE(RE::FullMatch(\"\", empty));\n  EXPECT_FALSE(RE::FullMatch(\"a\", empty));\n\n  const RE re1(\"a\");\n  EXPECT_TRUE(RE::FullMatch(\"a\", re1));\n\n  const RE re(\"a.*z\");\n  EXPECT_TRUE(RE::FullMatch(\"az\", re));\n  EXPECT_TRUE(RE::FullMatch(\"axyz\", re));\n  EXPECT_FALSE(RE::FullMatch(\"baz\", re));\n  EXPECT_FALSE(RE::FullMatch(\"azy\", re));\n}\n\n// Tests RE::PartialMatch().\nTEST(RETest, PartialMatchWorks) {\n  const RE empty(\"\");\n  EXPECT_TRUE(RE::PartialMatch(\"\", empty));\n  EXPECT_TRUE(RE::PartialMatch(\"a\", empty));\n\n  const RE re(\"a.*z\");\n  EXPECT_TRUE(RE::PartialMatch(\"az\", re));\n  EXPECT_TRUE(RE::PartialMatch(\"axyz\", re));\n  EXPECT_TRUE(RE::PartialMatch(\"baz\", re));\n  EXPECT_TRUE(RE::PartialMatch(\"azy\", re));\n  EXPECT_FALSE(RE::PartialMatch(\"zza\", re));\n}\n\n#endif  // GTEST_USES_POSIX_RE\n\n#if !GTEST_OS_WINDOWS_MOBILE\n\nTEST(CaptureTest, CapturesStdout) {\n  CaptureStdout();\n  fprintf(stdout, \"abc\");\n  EXPECT_STREQ(\"abc\", GetCapturedStdout().c_str());\n\n  CaptureStdout();\n  fprintf(stdout, \"def%cghi\", '\\0');\n  EXPECT_EQ(::std::string(\"def\\0ghi\", 7), ::std::string(GetCapturedStdout()));\n}\n\nTEST(CaptureTest, CapturesStderr) {\n  CaptureStderr();\n  fprintf(stderr, \"jkl\");\n  EXPECT_STREQ(\"jkl\", GetCapturedStderr().c_str());\n\n  CaptureStderr();\n  fprintf(stderr, \"jkl%cmno\", '\\0');\n  EXPECT_EQ(::std::string(\"jkl\\0mno\", 7), ::std::string(GetCapturedStderr()));\n}\n\n// Tests that stdout and stderr capture don't interfere with each other.\nTEST(CaptureTest, CapturesStdoutAndStderr) {\n  CaptureStdout();\n  CaptureStderr();\n  fprintf(stdout, \"pqr\");\n  fprintf(stderr, \"stu\");\n  EXPECT_STREQ(\"pqr\", GetCapturedStdout().c_str());\n  EXPECT_STREQ(\"stu\", GetCapturedStderr().c_str());\n}\n\nTEST(CaptureDeathTest, CannotReenterStdoutCapture) {\n  CaptureStdout();\n  EXPECT_DEATH_IF_SUPPORTED(CaptureStdout(),\n                            \"Only one stdout capturer can exist at a time\");\n  GetCapturedStdout();\n\n  // We cannot test stderr capturing using death tests as they use it\n  // themselves.\n}\n\n#endif  // !GTEST_OS_WINDOWS_MOBILE\n\nTEST(ThreadLocalTest, DefaultConstructorInitializesToDefaultValues) {\n  ThreadLocal<int> t1;\n  EXPECT_EQ(0, t1.get());\n\n  ThreadLocal<void*> t2;\n  EXPECT_TRUE(t2.get() == NULL);\n}\n\nTEST(ThreadLocalTest, SingleParamConstructorInitializesToParam) {\n  ThreadLocal<int> t1(123);\n  EXPECT_EQ(123, t1.get());\n\n  int i = 0;\n  ThreadLocal<int*> t2(&i);\n  EXPECT_EQ(&i, t2.get());\n}\n\nclass NoDefaultContructor {\n public:\n  explicit NoDefaultContructor(const char*) {}\n  NoDefaultContructor(const NoDefaultContructor&) {}\n};\n\nTEST(ThreadLocalTest, ValueDefaultContructorIsNotRequiredForParamVersion) {\n  ThreadLocal<NoDefaultContructor> bar(NoDefaultContructor(\"foo\"));\n  bar.pointer();\n}\n\nTEST(ThreadLocalTest, GetAndPointerReturnSameValue) {\n  ThreadLocal<std::string> thread_local_string;\n\n  EXPECT_EQ(thread_local_string.pointer(), &(thread_local_string.get()));\n\n  // Verifies the condition still holds after calling set.\n  thread_local_string.set(\"foo\");\n  EXPECT_EQ(thread_local_string.pointer(), &(thread_local_string.get()));\n}\n\nTEST(ThreadLocalTest, PointerAndConstPointerReturnSameValue) {\n  ThreadLocal<std::string> thread_local_string;\n  const ThreadLocal<std::string>& const_thread_local_string =\n      thread_local_string;\n\n  EXPECT_EQ(thread_local_string.pointer(), const_thread_local_string.pointer());\n\n  thread_local_string.set(\"foo\");\n  EXPECT_EQ(thread_local_string.pointer(), const_thread_local_string.pointer());\n}\n\n#if GTEST_IS_THREADSAFE\n\nvoid AddTwo(int* param) { *param += 2; }\n\nTEST(ThreadWithParamTest, ConstructorExecutesThreadFunc) {\n  int i = 40;\n  ThreadWithParam<int*> thread(&AddTwo, &i, NULL);\n  thread.Join();\n  EXPECT_EQ(42, i);\n}\n\nTEST(MutexDeathTest, AssertHeldShouldAssertWhenNotLocked) {\n  // AssertHeld() is flaky only in the presence of multiple threads accessing\n  // the lock. In this case, the test is robust.\n  EXPECT_DEATH_IF_SUPPORTED({\n    Mutex m;\n    { MutexLock lock(&m); }\n    m.AssertHeld();\n  },\n  \"thread .*hold\");\n}\n\nTEST(MutexTest, AssertHeldShouldNotAssertWhenLocked) {\n  Mutex m;\n  MutexLock lock(&m);\n  m.AssertHeld();\n}\n\nclass AtomicCounterWithMutex {\n public:\n  explicit AtomicCounterWithMutex(Mutex* mutex) :\n    value_(0), mutex_(mutex), random_(42) {}\n\n  void Increment() {\n    MutexLock lock(mutex_);\n    int temp = value_;\n    {\n      // Locking a mutex puts up a memory barrier, preventing reads and\n      // writes to value_ rearranged when observed from other threads.\n      //\n      // We cannot use Mutex and MutexLock here or rely on their memory\n      // barrier functionality as we are testing them here.\n      pthread_mutex_t memory_barrier_mutex;\n      GTEST_CHECK_POSIX_SUCCESS_(\n          pthread_mutex_init(&memory_barrier_mutex, NULL));\n      GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&memory_barrier_mutex));\n\n      SleepMilliseconds(random_.Generate(30));\n\n      GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_unlock(&memory_barrier_mutex));\n      GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&memory_barrier_mutex));\n    }\n    value_ = temp + 1;\n  }\n  int value() const { return value_; }\n\n private:\n  volatile int value_;\n  Mutex* const mutex_;  // Protects value_.\n  Random       random_;\n};\n\nvoid CountingThreadFunc(pair<AtomicCounterWithMutex*, int> param) {\n  for (int i = 0; i < param.second; ++i)\n      param.first->Increment();\n}\n\n// Tests that the mutex only lets one thread at a time to lock it.\nTEST(MutexTest, OnlyOneThreadCanLockAtATime) {\n  Mutex mutex;\n  AtomicCounterWithMutex locked_counter(&mutex);\n\n  typedef ThreadWithParam<pair<AtomicCounterWithMutex*, int> > ThreadType;\n  const int kCycleCount = 20;\n  const int kThreadCount = 7;\n  scoped_ptr<ThreadType> counting_threads[kThreadCount];\n  Notification threads_can_start;\n  // Creates and runs kThreadCount threads that increment locked_counter\n  // kCycleCount times each.\n  for (int i = 0; i < kThreadCount; ++i) {\n    counting_threads[i].reset(new ThreadType(&CountingThreadFunc,\n                                             make_pair(&locked_counter,\n                                                       kCycleCount),\n                                             &threads_can_start));\n  }\n  threads_can_start.Notify();\n  for (int i = 0; i < kThreadCount; ++i)\n    counting_threads[i]->Join();\n\n  // If the mutex lets more than one thread to increment the counter at a\n  // time, they are likely to encounter a race condition and have some\n  // increments overwritten, resulting in the lower then expected counter\n  // value.\n  EXPECT_EQ(kCycleCount * kThreadCount, locked_counter.value());\n}\n\ntemplate <typename T>\nvoid RunFromThread(void (func)(T), T param) {\n  ThreadWithParam<T> thread(func, param, NULL);\n  thread.Join();\n}\n\nvoid RetrieveThreadLocalValue(\n    pair<ThreadLocal<std::string>*, std::string*> param) {\n  *param.second = param.first->get();\n}\n\nTEST(ThreadLocalTest, ParameterizedConstructorSetsDefault) {\n  ThreadLocal<std::string> thread_local_string(\"foo\");\n  EXPECT_STREQ(\"foo\", thread_local_string.get().c_str());\n\n  thread_local_string.set(\"bar\");\n  EXPECT_STREQ(\"bar\", thread_local_string.get().c_str());\n\n  std::string result;\n  RunFromThread(&RetrieveThreadLocalValue,\n                make_pair(&thread_local_string, &result));\n  EXPECT_STREQ(\"foo\", result.c_str());\n}\n\n// DestructorTracker keeps track of whether its instances have been\n// destroyed.\nstatic std::vector<bool> g_destroyed;\n\nclass DestructorTracker {\n public:\n  DestructorTracker() : index_(GetNewIndex()) {}\n  DestructorTracker(const DestructorTracker& /* rhs */)\n      : index_(GetNewIndex()) {}\n  ~DestructorTracker() {\n    // We never access g_destroyed concurrently, so we don't need to\n    // protect the write operation under a mutex.\n    g_destroyed[index_] = true;\n  }\n\n private:\n  static int GetNewIndex() {\n    g_destroyed.push_back(false);\n    return g_destroyed.size() - 1;\n  }\n  const int index_;\n};\n\ntypedef ThreadLocal<DestructorTracker>* ThreadParam;\n\nvoid CallThreadLocalGet(ThreadParam thread_local_param) {\n  thread_local_param->get();\n}\n\n// Tests that when a ThreadLocal object dies in a thread, it destroys\n// the managed object for that thread.\nTEST(ThreadLocalTest, DestroysManagedObjectForOwnThreadWhenDying) {\n  g_destroyed.clear();\n\n  {\n    // The next line default constructs a DestructorTracker object as\n    // the default value of objects managed by thread_local_tracker.\n    ThreadLocal<DestructorTracker> thread_local_tracker;\n    ASSERT_EQ(1U, g_destroyed.size());\n    ASSERT_FALSE(g_destroyed[0]);\n\n    // This creates another DestructorTracker object for the main thread.\n    thread_local_tracker.get();\n    ASSERT_EQ(2U, g_destroyed.size());\n    ASSERT_FALSE(g_destroyed[0]);\n    ASSERT_FALSE(g_destroyed[1]);\n  }\n\n  // Now thread_local_tracker has died.  It should have destroyed both the\n  // default value shared by all threads and the value for the main\n  // thread.\n  ASSERT_EQ(2U, g_destroyed.size());\n  EXPECT_TRUE(g_destroyed[0]);\n  EXPECT_TRUE(g_destroyed[1]);\n\n  g_destroyed.clear();\n}\n\n// Tests that when a thread exits, the thread-local object for that\n// thread is destroyed.\nTEST(ThreadLocalTest, DestroysManagedObjectAtThreadExit) {\n  g_destroyed.clear();\n\n  {\n    // The next line default constructs a DestructorTracker object as\n    // the default value of objects managed by thread_local_tracker.\n    ThreadLocal<DestructorTracker> thread_local_tracker;\n    ASSERT_EQ(1U, g_destroyed.size());\n    ASSERT_FALSE(g_destroyed[0]);\n\n    // This creates another DestructorTracker object in the new thread.\n    ThreadWithParam<ThreadParam> thread(\n        &CallThreadLocalGet, &thread_local_tracker, NULL);\n    thread.Join();\n\n    // Now the new thread has exited.  The per-thread object for it\n    // should have been destroyed.\n    ASSERT_EQ(2U, g_destroyed.size());\n    ASSERT_FALSE(g_destroyed[0]);\n    ASSERT_TRUE(g_destroyed[1]);\n  }\n\n  // Now thread_local_tracker has died.  The default value should have been\n  // destroyed too.\n  ASSERT_EQ(2U, g_destroyed.size());\n  EXPECT_TRUE(g_destroyed[0]);\n  EXPECT_TRUE(g_destroyed[1]);\n\n  g_destroyed.clear();\n}\n\nTEST(ThreadLocalTest, ThreadLocalMutationsAffectOnlyCurrentThread) {\n  ThreadLocal<std::string> thread_local_string;\n  thread_local_string.set(\"Foo\");\n  EXPECT_STREQ(\"Foo\", thread_local_string.get().c_str());\n\n  std::string result;\n  RunFromThread(&RetrieveThreadLocalValue,\n                make_pair(&thread_local_string, &result));\n  EXPECT_TRUE(result.empty());\n}\n\n#endif  // GTEST_IS_THREADSAFE\n\n}  // namespace internal\n}  // namespace testing\n"
  },
  {
    "path": "ext/gtest/test/gtest-printers_test.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Google Test - The Google C++ Testing Framework\n//\n// This file tests the universal value printer.\n\n#include \"gtest/gtest-printers.h\"\n\n#include <ctype.h>\n#include <limits.h>\n#include <string.h>\n#include <algorithm>\n#include <deque>\n#include <list>\n#include <map>\n#include <set>\n#include <sstream>\n#include <string>\n#include <utility>\n#include <vector>\n\n#include \"gtest/gtest.h\"\n\n// hash_map and hash_set are available under Visual C++.\n#if _MSC_VER\n# define GTEST_HAS_HASH_MAP_ 1  // Indicates that hash_map is available.\n# include <hash_map>            // NOLINT\n# define GTEST_HAS_HASH_SET_ 1  // Indicates that hash_set is available.\n# include <hash_set>            // NOLINT\n#endif  // GTEST_OS_WINDOWS\n\n// Some user-defined types for testing the universal value printer.\n\n// An anonymous enum type.\nenum AnonymousEnum {\n  kAE1 = -1,\n  kAE2 = 1\n};\n\n// An enum without a user-defined printer.\nenum EnumWithoutPrinter {\n  kEWP1 = -2,\n  kEWP2 = 42\n};\n\n// An enum with a << operator.\nenum EnumWithStreaming {\n  kEWS1 = 10\n};\n\nstd::ostream& operator<<(std::ostream& os, EnumWithStreaming e) {\n  return os << (e == kEWS1 ? \"kEWS1\" : \"invalid\");\n}\n\n// An enum with a PrintTo() function.\nenum EnumWithPrintTo {\n  kEWPT1 = 1\n};\n\nvoid PrintTo(EnumWithPrintTo e, std::ostream* os) {\n  *os << (e == kEWPT1 ? \"kEWPT1\" : \"invalid\");\n}\n\n// A class implicitly convertible to BiggestInt.\nclass BiggestIntConvertible {\n public:\n  operator ::testing::internal::BiggestInt() const { return 42; }\n};\n\n// A user-defined unprintable class template in the global namespace.\ntemplate <typename T>\nclass UnprintableTemplateInGlobal {\n public:\n  UnprintableTemplateInGlobal() : value_() {}\n private:\n  T value_;\n};\n\n// A user-defined streamable type in the global namespace.\nclass StreamableInGlobal {\n public:\n  virtual ~StreamableInGlobal() {}\n};\n\ninline void operator<<(::std::ostream& os, const StreamableInGlobal& /* x */) {\n  os << \"StreamableInGlobal\";\n}\n\nvoid operator<<(::std::ostream& os, const StreamableInGlobal* /* x */) {\n  os << \"StreamableInGlobal*\";\n}\n\nnamespace foo {\n\n// A user-defined unprintable type in a user namespace.\nclass UnprintableInFoo {\n public:\n  UnprintableInFoo() : z_(0) { memcpy(xy_, \"\\xEF\\x12\\x0\\x0\\x34\\xAB\\x0\\x0\", 8); }\n private:\n  char xy_[8];\n  double z_;\n};\n\n// A user-defined printable type in a user-chosen namespace.\nstruct PrintableViaPrintTo {\n  PrintableViaPrintTo() : value() {}\n  int value;\n};\n\nvoid PrintTo(const PrintableViaPrintTo& x, ::std::ostream* os) {\n  *os << \"PrintableViaPrintTo: \" << x.value;\n}\n\n// A type with a user-defined << for printing its pointer.\nstruct PointerPrintable {\n};\n\n::std::ostream& operator<<(::std::ostream& os,\n                           const PointerPrintable* /* x */) {\n  return os << \"PointerPrintable*\";\n}\n\n// A user-defined printable class template in a user-chosen namespace.\ntemplate <typename T>\nclass PrintableViaPrintToTemplate {\n public:\n  explicit PrintableViaPrintToTemplate(const T& a_value) : value_(a_value) {}\n\n  const T& value() const { return value_; }\n private:\n  T value_;\n};\n\ntemplate <typename T>\nvoid PrintTo(const PrintableViaPrintToTemplate<T>& x, ::std::ostream* os) {\n  *os << \"PrintableViaPrintToTemplate: \" << x.value();\n}\n\n// A user-defined streamable class template in a user namespace.\ntemplate <typename T>\nclass StreamableTemplateInFoo {\n public:\n  StreamableTemplateInFoo() : value_() {}\n\n  const T& value() const { return value_; }\n private:\n  T value_;\n};\n\ntemplate <typename T>\ninline ::std::ostream& operator<<(::std::ostream& os,\n                                  const StreamableTemplateInFoo<T>& x) {\n  return os << \"StreamableTemplateInFoo: \" << x.value();\n}\n\n}  // namespace foo\n\nnamespace testing {\nnamespace gtest_printers_test {\n\nusing ::std::deque;\nusing ::std::list;\nusing ::std::make_pair;\nusing ::std::map;\nusing ::std::multimap;\nusing ::std::multiset;\nusing ::std::pair;\nusing ::std::set;\nusing ::std::vector;\nusing ::testing::PrintToString;\nusing ::testing::internal::FormatForComparisonFailureMessage;\nusing ::testing::internal::ImplicitCast_;\nusing ::testing::internal::NativeArray;\nusing ::testing::internal::RE;\nusing ::testing::internal::Strings;\nusing ::testing::internal::UniversalPrint;\nusing ::testing::internal::UniversalPrinter;\nusing ::testing::internal::UniversalTersePrint;\nusing ::testing::internal::UniversalTersePrintTupleFieldsToStrings;\nusing ::testing::internal::kReference;\nusing ::testing::internal::string;\n\n#if GTEST_HAS_TR1_TUPLE\nusing ::std::tr1::make_tuple;\nusing ::std::tr1::tuple;\n#endif\n\n// The hash_* classes are not part of the C++ standard.  STLport\n// defines them in namespace std.  MSVC defines them in ::stdext.  GCC\n// defines them in ::.\n#ifdef _STLP_HASH_MAP  // We got <hash_map> from STLport.\nusing ::std::hash_map;\nusing ::std::hash_set;\nusing ::std::hash_multimap;\nusing ::std::hash_multiset;\n#elif _MSC_VER\nusing ::stdext::hash_map;\nusing ::stdext::hash_set;\nusing ::stdext::hash_multimap;\nusing ::stdext::hash_multiset;\n#endif\n\n// Prints a value to a string using the universal value printer.  This\n// is a helper for testing UniversalPrinter<T>::Print() for various types.\ntemplate <typename T>\nstring Print(const T& value) {\n  ::std::stringstream ss;\n  UniversalPrinter<T>::Print(value, &ss);\n  return ss.str();\n}\n\n// Prints a value passed by reference to a string, using the universal\n// value printer.  This is a helper for testing\n// UniversalPrinter<T&>::Print() for various types.\ntemplate <typename T>\nstring PrintByRef(const T& value) {\n  ::std::stringstream ss;\n  UniversalPrinter<T&>::Print(value, &ss);\n  return ss.str();\n}\n\n// Tests printing various enum types.\n\nTEST(PrintEnumTest, AnonymousEnum) {\n  EXPECT_EQ(\"-1\", Print(kAE1));\n  EXPECT_EQ(\"1\", Print(kAE2));\n}\n\nTEST(PrintEnumTest, EnumWithoutPrinter) {\n  EXPECT_EQ(\"-2\", Print(kEWP1));\n  EXPECT_EQ(\"42\", Print(kEWP2));\n}\n\nTEST(PrintEnumTest, EnumWithStreaming) {\n  EXPECT_EQ(\"kEWS1\", Print(kEWS1));\n  EXPECT_EQ(\"invalid\", Print(static_cast<EnumWithStreaming>(0)));\n}\n\nTEST(PrintEnumTest, EnumWithPrintTo) {\n  EXPECT_EQ(\"kEWPT1\", Print(kEWPT1));\n  EXPECT_EQ(\"invalid\", Print(static_cast<EnumWithPrintTo>(0)));\n}\n\n// Tests printing a class implicitly convertible to BiggestInt.\n\nTEST(PrintClassTest, BiggestIntConvertible) {\n  EXPECT_EQ(\"42\", Print(BiggestIntConvertible()));\n}\n\n// Tests printing various char types.\n\n// char.\nTEST(PrintCharTest, PlainChar) {\n  EXPECT_EQ(\"'\\\\0'\", Print('\\0'));\n  EXPECT_EQ(\"'\\\\'' (39, 0x27)\", Print('\\''));\n  EXPECT_EQ(\"'\\\"' (34, 0x22)\", Print('\"'));\n  EXPECT_EQ(\"'?' (63, 0x3F)\", Print('?'));\n  EXPECT_EQ(\"'\\\\\\\\' (92, 0x5C)\", Print('\\\\'));\n  EXPECT_EQ(\"'\\\\a' (7)\", Print('\\a'));\n  EXPECT_EQ(\"'\\\\b' (8)\", Print('\\b'));\n  EXPECT_EQ(\"'\\\\f' (12, 0xC)\", Print('\\f'));\n  EXPECT_EQ(\"'\\\\n' (10, 0xA)\", Print('\\n'));\n  EXPECT_EQ(\"'\\\\r' (13, 0xD)\", Print('\\r'));\n  EXPECT_EQ(\"'\\\\t' (9)\", Print('\\t'));\n  EXPECT_EQ(\"'\\\\v' (11, 0xB)\", Print('\\v'));\n  EXPECT_EQ(\"'\\\\x7F' (127)\", Print('\\x7F'));\n  EXPECT_EQ(\"'\\\\xFF' (255)\", Print('\\xFF'));\n  EXPECT_EQ(\"' ' (32, 0x20)\", Print(' '));\n  EXPECT_EQ(\"'a' (97, 0x61)\", Print('a'));\n}\n\n// signed char.\nTEST(PrintCharTest, SignedChar) {\n  EXPECT_EQ(\"'\\\\0'\", Print(static_cast<signed char>('\\0')));\n  EXPECT_EQ(\"'\\\\xCE' (-50)\",\n            Print(static_cast<signed char>(-50)));\n}\n\n// unsigned char.\nTEST(PrintCharTest, UnsignedChar) {\n  EXPECT_EQ(\"'\\\\0'\", Print(static_cast<unsigned char>('\\0')));\n  EXPECT_EQ(\"'b' (98, 0x62)\",\n            Print(static_cast<unsigned char>('b')));\n}\n\n// Tests printing other simple, built-in types.\n\n// bool.\nTEST(PrintBuiltInTypeTest, Bool) {\n  EXPECT_EQ(\"false\", Print(false));\n  EXPECT_EQ(\"true\", Print(true));\n}\n\n// wchar_t.\nTEST(PrintBuiltInTypeTest, Wchar_t) {\n  EXPECT_EQ(\"L'\\\\0'\", Print(L'\\0'));\n  EXPECT_EQ(\"L'\\\\'' (39, 0x27)\", Print(L'\\''));\n  EXPECT_EQ(\"L'\\\"' (34, 0x22)\", Print(L'\"'));\n  EXPECT_EQ(\"L'?' (63, 0x3F)\", Print(L'?'));\n  EXPECT_EQ(\"L'\\\\\\\\' (92, 0x5C)\", Print(L'\\\\'));\n  EXPECT_EQ(\"L'\\\\a' (7)\", Print(L'\\a'));\n  EXPECT_EQ(\"L'\\\\b' (8)\", Print(L'\\b'));\n  EXPECT_EQ(\"L'\\\\f' (12, 0xC)\", Print(L'\\f'));\n  EXPECT_EQ(\"L'\\\\n' (10, 0xA)\", Print(L'\\n'));\n  EXPECT_EQ(\"L'\\\\r' (13, 0xD)\", Print(L'\\r'));\n  EXPECT_EQ(\"L'\\\\t' (9)\", Print(L'\\t'));\n  EXPECT_EQ(\"L'\\\\v' (11, 0xB)\", Print(L'\\v'));\n  EXPECT_EQ(\"L'\\\\x7F' (127)\", Print(L'\\x7F'));\n  EXPECT_EQ(\"L'\\\\xFF' (255)\", Print(L'\\xFF'));\n  EXPECT_EQ(\"L' ' (32, 0x20)\", Print(L' '));\n  EXPECT_EQ(\"L'a' (97, 0x61)\", Print(L'a'));\n  EXPECT_EQ(\"L'\\\\x576' (1398)\", Print(static_cast<wchar_t>(0x576)));\n  EXPECT_EQ(\"L'\\\\xC74D' (51021)\", Print(static_cast<wchar_t>(0xC74D)));\n}\n\n// Test that Int64 provides more storage than wchar_t.\nTEST(PrintTypeSizeTest, Wchar_t) {\n  EXPECT_LT(sizeof(wchar_t), sizeof(testing::internal::Int64));\n}\n\n// Various integer types.\nTEST(PrintBuiltInTypeTest, Integer) {\n  EXPECT_EQ(\"'\\\\xFF' (255)\", Print(static_cast<unsigned char>(255)));  // uint8\n  EXPECT_EQ(\"'\\\\x80' (-128)\", Print(static_cast<signed char>(-128)));  // int8\n  EXPECT_EQ(\"65535\", Print(USHRT_MAX));  // uint16\n  EXPECT_EQ(\"-32768\", Print(SHRT_MIN));  // int16\n  EXPECT_EQ(\"4294967295\", Print(UINT_MAX));  // uint32\n  EXPECT_EQ(\"-2147483648\", Print(INT_MIN));  // int32\n  EXPECT_EQ(\"18446744073709551615\",\n            Print(static_cast<testing::internal::UInt64>(-1)));  // uint64\n  EXPECT_EQ(\"-9223372036854775808\",\n            Print(static_cast<testing::internal::Int64>(1) << 63));  // int64\n}\n\n// Size types.\nTEST(PrintBuiltInTypeTest, Size_t) {\n  EXPECT_EQ(\"1\", Print(sizeof('a')));  // size_t.\n#if !GTEST_OS_WINDOWS\n  // Windows has no ssize_t type.\n  EXPECT_EQ(\"-2\", Print(static_cast<ssize_t>(-2)));  // ssize_t.\n#endif  // !GTEST_OS_WINDOWS\n}\n\n// Floating-points.\nTEST(PrintBuiltInTypeTest, FloatingPoints) {\n  EXPECT_EQ(\"1.5\", Print(1.5f));   // float\n  EXPECT_EQ(\"-2.5\", Print(-2.5));  // double\n}\n\n// Since ::std::stringstream::operator<<(const void *) formats the pointer\n// output differently with different compilers, we have to create the expected\n// output first and use it as our expectation.\nstatic string PrintPointer(const void *p) {\n  ::std::stringstream expected_result_stream;\n  expected_result_stream << p;\n  return expected_result_stream.str();\n}\n\n// Tests printing C strings.\n\n// const char*.\nTEST(PrintCStringTest, Const) {\n  const char* p = \"World\";\n  EXPECT_EQ(PrintPointer(p) + \" pointing to \\\"World\\\"\", Print(p));\n}\n\n// char*.\nTEST(PrintCStringTest, NonConst) {\n  char p[] = \"Hi\";\n  EXPECT_EQ(PrintPointer(p) + \" pointing to \\\"Hi\\\"\",\n            Print(static_cast<char*>(p)));\n}\n\n// NULL C string.\nTEST(PrintCStringTest, Null) {\n  const char* p = NULL;\n  EXPECT_EQ(\"NULL\", Print(p));\n}\n\n// Tests that C strings are escaped properly.\nTEST(PrintCStringTest, EscapesProperly) {\n  const char* p = \"'\\\"?\\\\\\a\\b\\f\\n\\r\\t\\v\\x7F\\xFF a\";\n  EXPECT_EQ(PrintPointer(p) + \" pointing to \\\"'\\\\\\\"?\\\\\\\\\\\\a\\\\b\\\\f\"\n            \"\\\\n\\\\r\\\\t\\\\v\\\\x7F\\\\xFF a\\\"\",\n            Print(p));\n}\n\n\n\n// MSVC compiler can be configured to define whar_t as a typedef\n// of unsigned short. Defining an overload for const wchar_t* in that case\n// would cause pointers to unsigned shorts be printed as wide strings,\n// possibly accessing more memory than intended and causing invalid\n// memory accesses. MSVC defines _NATIVE_WCHAR_T_DEFINED symbol when\n// wchar_t is implemented as a native type.\n#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)\n\n// const wchar_t*.\nTEST(PrintWideCStringTest, Const) {\n  const wchar_t* p = L\"World\";\n  EXPECT_EQ(PrintPointer(p) + \" pointing to L\\\"World\\\"\", Print(p));\n}\n\n// wchar_t*.\nTEST(PrintWideCStringTest, NonConst) {\n  wchar_t p[] = L\"Hi\";\n  EXPECT_EQ(PrintPointer(p) + \" pointing to L\\\"Hi\\\"\",\n            Print(static_cast<wchar_t*>(p)));\n}\n\n// NULL wide C string.\nTEST(PrintWideCStringTest, Null) {\n  const wchar_t* p = NULL;\n  EXPECT_EQ(\"NULL\", Print(p));\n}\n\n// Tests that wide C strings are escaped properly.\nTEST(PrintWideCStringTest, EscapesProperly) {\n  const wchar_t s[] = {'\\'', '\"', '?', '\\\\', '\\a', '\\b', '\\f', '\\n', '\\r',\n                       '\\t', '\\v', 0xD3, 0x576, 0x8D3, 0xC74D, ' ', 'a', '\\0'};\n  EXPECT_EQ(PrintPointer(s) + \" pointing to L\\\"'\\\\\\\"?\\\\\\\\\\\\a\\\\b\\\\f\"\n            \"\\\\n\\\\r\\\\t\\\\v\\\\xD3\\\\x576\\\\x8D3\\\\xC74D a\\\"\",\n            Print(static_cast<const wchar_t*>(s)));\n}\n#endif  // native wchar_t\n\n// Tests printing pointers to other char types.\n\n// signed char*.\nTEST(PrintCharPointerTest, SignedChar) {\n  signed char* p = reinterpret_cast<signed char*>(0x1234);\n  EXPECT_EQ(PrintPointer(p), Print(p));\n  p = NULL;\n  EXPECT_EQ(\"NULL\", Print(p));\n}\n\n// const signed char*.\nTEST(PrintCharPointerTest, ConstSignedChar) {\n  signed char* p = reinterpret_cast<signed char*>(0x1234);\n  EXPECT_EQ(PrintPointer(p), Print(p));\n  p = NULL;\n  EXPECT_EQ(\"NULL\", Print(p));\n}\n\n// unsigned char*.\nTEST(PrintCharPointerTest, UnsignedChar) {\n  unsigned char* p = reinterpret_cast<unsigned char*>(0x1234);\n  EXPECT_EQ(PrintPointer(p), Print(p));\n  p = NULL;\n  EXPECT_EQ(\"NULL\", Print(p));\n}\n\n// const unsigned char*.\nTEST(PrintCharPointerTest, ConstUnsignedChar) {\n  const unsigned char* p = reinterpret_cast<const unsigned char*>(0x1234);\n  EXPECT_EQ(PrintPointer(p), Print(p));\n  p = NULL;\n  EXPECT_EQ(\"NULL\", Print(p));\n}\n\n// Tests printing pointers to simple, built-in types.\n\n// bool*.\nTEST(PrintPointerToBuiltInTypeTest, Bool) {\n  bool* p = reinterpret_cast<bool*>(0xABCD);\n  EXPECT_EQ(PrintPointer(p), Print(p));\n  p = NULL;\n  EXPECT_EQ(\"NULL\", Print(p));\n}\n\n// void*.\nTEST(PrintPointerToBuiltInTypeTest, Void) {\n  void* p = reinterpret_cast<void*>(0xABCD);\n  EXPECT_EQ(PrintPointer(p), Print(p));\n  p = NULL;\n  EXPECT_EQ(\"NULL\", Print(p));\n}\n\n// const void*.\nTEST(PrintPointerToBuiltInTypeTest, ConstVoid) {\n  const void* p = reinterpret_cast<const void*>(0xABCD);\n  EXPECT_EQ(PrintPointer(p), Print(p));\n  p = NULL;\n  EXPECT_EQ(\"NULL\", Print(p));\n}\n\n// Tests printing pointers to pointers.\nTEST(PrintPointerToPointerTest, IntPointerPointer) {\n  int** p = reinterpret_cast<int**>(0xABCD);\n  EXPECT_EQ(PrintPointer(p), Print(p));\n  p = NULL;\n  EXPECT_EQ(\"NULL\", Print(p));\n}\n\n// Tests printing (non-member) function pointers.\n\nvoid MyFunction(int /* n */) {}\n\nTEST(PrintPointerTest, NonMemberFunctionPointer) {\n  // We cannot directly cast &MyFunction to const void* because the\n  // standard disallows casting between pointers to functions and\n  // pointers to objects, and some compilers (e.g. GCC 3.4) enforce\n  // this limitation.\n  EXPECT_EQ(\n      PrintPointer(reinterpret_cast<const void*>(\n          reinterpret_cast<internal::BiggestInt>(&MyFunction))),\n      Print(&MyFunction));\n  int (*p)(bool) = NULL;  // NOLINT\n  EXPECT_EQ(\"NULL\", Print(p));\n}\n\n// An assertion predicate determining whether a one string is a prefix for\n// another.\ntemplate <typename StringType>\nAssertionResult HasPrefix(const StringType& str, const StringType& prefix) {\n  if (str.find(prefix, 0) == 0)\n    return AssertionSuccess();\n\n  const bool is_wide_string = sizeof(prefix[0]) > 1;\n  const char* const begin_string_quote = is_wide_string ? \"L\\\"\" : \"\\\"\";\n  return AssertionFailure()\n      << begin_string_quote << prefix << \"\\\" is not a prefix of \"\n      << begin_string_quote << str << \"\\\"\\n\";\n}\n\n// Tests printing member variable pointers.  Although they are called\n// pointers, they don't point to a location in the address space.\n// Their representation is implementation-defined.  Thus they will be\n// printed as raw bytes.\n\nstruct Foo {\n public:\n  virtual ~Foo() {}\n  int MyMethod(char x) { return x + 1; }\n  virtual char MyVirtualMethod(int /* n */) { return 'a'; }\n\n  int value;\n};\n\nTEST(PrintPointerTest, MemberVariablePointer) {\n  EXPECT_TRUE(HasPrefix(Print(&Foo::value),\n                        Print(sizeof(&Foo::value)) + \"-byte object \"));\n  int (Foo::*p) = NULL;  // NOLINT\n  EXPECT_TRUE(HasPrefix(Print(p),\n                        Print(sizeof(p)) + \"-byte object \"));\n}\n\n// Tests printing member function pointers.  Although they are called\n// pointers, they don't point to a location in the address space.\n// Their representation is implementation-defined.  Thus they will be\n// printed as raw bytes.\nTEST(PrintPointerTest, MemberFunctionPointer) {\n  EXPECT_TRUE(HasPrefix(Print(&Foo::MyMethod),\n                        Print(sizeof(&Foo::MyMethod)) + \"-byte object \"));\n  EXPECT_TRUE(\n      HasPrefix(Print(&Foo::MyVirtualMethod),\n                Print(sizeof((&Foo::MyVirtualMethod))) + \"-byte object \"));\n  int (Foo::*p)(char) = NULL;  // NOLINT\n  EXPECT_TRUE(HasPrefix(Print(p),\n                        Print(sizeof(p)) + \"-byte object \"));\n}\n\n// Tests printing C arrays.\n\n// The difference between this and Print() is that it ensures that the\n// argument is a reference to an array.\ntemplate <typename T, size_t N>\nstring PrintArrayHelper(T (&a)[N]) {\n  return Print(a);\n}\n\n// One-dimensional array.\nTEST(PrintArrayTest, OneDimensionalArray) {\n  int a[5] = { 1, 2, 3, 4, 5 };\n  EXPECT_EQ(\"{ 1, 2, 3, 4, 5 }\", PrintArrayHelper(a));\n}\n\n// Two-dimensional array.\nTEST(PrintArrayTest, TwoDimensionalArray) {\n  int a[2][5] = {\n    { 1, 2, 3, 4, 5 },\n    { 6, 7, 8, 9, 0 }\n  };\n  EXPECT_EQ(\"{ { 1, 2, 3, 4, 5 }, { 6, 7, 8, 9, 0 } }\", PrintArrayHelper(a));\n}\n\n// Array of const elements.\nTEST(PrintArrayTest, ConstArray) {\n  const bool a[1] = { false };\n  EXPECT_EQ(\"{ false }\", PrintArrayHelper(a));\n}\n\n// char array without terminating NUL.\nTEST(PrintArrayTest, CharArrayWithNoTerminatingNul) {\n  // Array a contains '\\0' in the middle and doesn't end with '\\0'.\n  char a[] = { 'H', '\\0', 'i' };\n  EXPECT_EQ(\"\\\"H\\\\0i\\\" (no terminating NUL)\", PrintArrayHelper(a));\n}\n\n// const char array with terminating NUL.\nTEST(PrintArrayTest, ConstCharArrayWithTerminatingNul) {\n  const char a[] = \"\\0Hi\";\n  EXPECT_EQ(\"\\\"\\\\0Hi\\\"\", PrintArrayHelper(a));\n}\n\n// const wchar_t array without terminating NUL.\nTEST(PrintArrayTest, WCharArrayWithNoTerminatingNul) {\n  // Array a contains '\\0' in the middle and doesn't end with '\\0'.\n  const wchar_t a[] = { L'H', L'\\0', L'i' };\n  EXPECT_EQ(\"L\\\"H\\\\0i\\\" (no terminating NUL)\", PrintArrayHelper(a));\n}\n\n// wchar_t array with terminating NUL.\nTEST(PrintArrayTest, WConstCharArrayWithTerminatingNul) {\n  const wchar_t a[] = L\"\\0Hi\";\n  EXPECT_EQ(\"L\\\"\\\\0Hi\\\"\", PrintArrayHelper(a));\n}\n\n// Array of objects.\nTEST(PrintArrayTest, ObjectArray) {\n  string a[3] = { \"Hi\", \"Hello\", \"Ni hao\" };\n  EXPECT_EQ(\"{ \\\"Hi\\\", \\\"Hello\\\", \\\"Ni hao\\\" }\", PrintArrayHelper(a));\n}\n\n// Array with many elements.\nTEST(PrintArrayTest, BigArray) {\n  int a[100] = { 1, 2, 3 };\n  EXPECT_EQ(\"{ 1, 2, 3, 0, 0, 0, 0, 0, ..., 0, 0, 0, 0, 0, 0, 0, 0 }\",\n            PrintArrayHelper(a));\n}\n\n// Tests printing ::string and ::std::string.\n\n#if GTEST_HAS_GLOBAL_STRING\n// ::string.\nTEST(PrintStringTest, StringInGlobalNamespace) {\n  const char s[] = \"'\\\"?\\\\\\a\\b\\f\\n\\0\\r\\t\\v\\x7F\\xFF a\";\n  const ::string str(s, sizeof(s));\n  EXPECT_EQ(\"\\\"'\\\\\\\"?\\\\\\\\\\\\a\\\\b\\\\f\\\\n\\\\0\\\\r\\\\t\\\\v\\\\x7F\\\\xFF a\\\\0\\\"\",\n            Print(str));\n}\n#endif  // GTEST_HAS_GLOBAL_STRING\n\n// ::std::string.\nTEST(PrintStringTest, StringInStdNamespace) {\n  const char s[] = \"'\\\"?\\\\\\a\\b\\f\\n\\0\\r\\t\\v\\x7F\\xFF a\";\n  const ::std::string str(s, sizeof(s));\n  EXPECT_EQ(\"\\\"'\\\\\\\"?\\\\\\\\\\\\a\\\\b\\\\f\\\\n\\\\0\\\\r\\\\t\\\\v\\\\x7F\\\\xFF a\\\\0\\\"\",\n            Print(str));\n}\n\nTEST(PrintStringTest, StringAmbiguousHex) {\n  // \"\\x6BANANA\" is ambiguous, it can be interpreted as starting with either of:\n  // '\\x6', '\\x6B', or '\\x6BA'.\n\n  // a hex escaping sequence following by a decimal digit\n  EXPECT_EQ(\"\\\"0\\\\x12\\\" \\\"3\\\"\", Print(::std::string(\"0\\x12\" \"3\")));\n  // a hex escaping sequence following by a hex digit (lower-case)\n  EXPECT_EQ(\"\\\"mm\\\\x6\\\" \\\"bananas\\\"\", Print(::std::string(\"mm\\x6\" \"bananas\")));\n  // a hex escaping sequence following by a hex digit (upper-case)\n  EXPECT_EQ(\"\\\"NOM\\\\x6\\\" \\\"BANANA\\\"\", Print(::std::string(\"NOM\\x6\" \"BANANA\")));\n  // a hex escaping sequence following by a non-xdigit\n  EXPECT_EQ(\"\\\"!\\\\x5-!\\\"\", Print(::std::string(\"!\\x5-!\")));\n}\n\n// Tests printing ::wstring and ::std::wstring.\n\n#if GTEST_HAS_GLOBAL_WSTRING\n// ::wstring.\nTEST(PrintWideStringTest, StringInGlobalNamespace) {\n  const wchar_t s[] = L\"'\\\"?\\\\\\a\\b\\f\\n\\0\\r\\t\\v\\xD3\\x576\\x8D3\\xC74D a\";\n  const ::wstring str(s, sizeof(s)/sizeof(wchar_t));\n  EXPECT_EQ(\"L\\\"'\\\\\\\"?\\\\\\\\\\\\a\\\\b\\\\f\\\\n\\\\0\\\\r\\\\t\\\\v\"\n            \"\\\\xD3\\\\x576\\\\x8D3\\\\xC74D a\\\\0\\\"\",\n            Print(str));\n}\n#endif  // GTEST_HAS_GLOBAL_WSTRING\n\n#if GTEST_HAS_STD_WSTRING\n// ::std::wstring.\nTEST(PrintWideStringTest, StringInStdNamespace) {\n  const wchar_t s[] = L\"'\\\"?\\\\\\a\\b\\f\\n\\0\\r\\t\\v\\xD3\\x576\\x8D3\\xC74D a\";\n  const ::std::wstring str(s, sizeof(s)/sizeof(wchar_t));\n  EXPECT_EQ(\"L\\\"'\\\\\\\"?\\\\\\\\\\\\a\\\\b\\\\f\\\\n\\\\0\\\\r\\\\t\\\\v\"\n            \"\\\\xD3\\\\x576\\\\x8D3\\\\xC74D a\\\\0\\\"\",\n            Print(str));\n}\n\nTEST(PrintWideStringTest, StringAmbiguousHex) {\n  // same for wide strings.\n  EXPECT_EQ(\"L\\\"0\\\\x12\\\" L\\\"3\\\"\", Print(::std::wstring(L\"0\\x12\" L\"3\")));\n  EXPECT_EQ(\"L\\\"mm\\\\x6\\\" L\\\"bananas\\\"\",\n            Print(::std::wstring(L\"mm\\x6\" L\"bananas\")));\n  EXPECT_EQ(\"L\\\"NOM\\\\x6\\\" L\\\"BANANA\\\"\",\n            Print(::std::wstring(L\"NOM\\x6\" L\"BANANA\")));\n  EXPECT_EQ(\"L\\\"!\\\\x5-!\\\"\", Print(::std::wstring(L\"!\\x5-!\")));\n}\n#endif  // GTEST_HAS_STD_WSTRING\n\n// Tests printing types that support generic streaming (i.e. streaming\n// to std::basic_ostream<Char, CharTraits> for any valid Char and\n// CharTraits types).\n\n// Tests printing a non-template type that supports generic streaming.\n\nclass AllowsGenericStreaming {};\n\ntemplate <typename Char, typename CharTraits>\nstd::basic_ostream<Char, CharTraits>& operator<<(\n    std::basic_ostream<Char, CharTraits>& os,\n    const AllowsGenericStreaming& /* a */) {\n  return os << \"AllowsGenericStreaming\";\n}\n\nTEST(PrintTypeWithGenericStreamingTest, NonTemplateType) {\n  AllowsGenericStreaming a;\n  EXPECT_EQ(\"AllowsGenericStreaming\", Print(a));\n}\n\n// Tests printing a template type that supports generic streaming.\n\ntemplate <typename T>\nclass AllowsGenericStreamingTemplate {};\n\ntemplate <typename Char, typename CharTraits, typename T>\nstd::basic_ostream<Char, CharTraits>& operator<<(\n    std::basic_ostream<Char, CharTraits>& os,\n    const AllowsGenericStreamingTemplate<T>& /* a */) {\n  return os << \"AllowsGenericStreamingTemplate\";\n}\n\nTEST(PrintTypeWithGenericStreamingTest, TemplateType) {\n  AllowsGenericStreamingTemplate<int> a;\n  EXPECT_EQ(\"AllowsGenericStreamingTemplate\", Print(a));\n}\n\n// Tests printing a type that supports generic streaming and can be\n// implicitly converted to another printable type.\n\ntemplate <typename T>\nclass AllowsGenericStreamingAndImplicitConversionTemplate {\n public:\n  operator bool() const { return false; }\n};\n\ntemplate <typename Char, typename CharTraits, typename T>\nstd::basic_ostream<Char, CharTraits>& operator<<(\n    std::basic_ostream<Char, CharTraits>& os,\n    const AllowsGenericStreamingAndImplicitConversionTemplate<T>& /* a */) {\n  return os << \"AllowsGenericStreamingAndImplicitConversionTemplate\";\n}\n\nTEST(PrintTypeWithGenericStreamingTest, TypeImplicitlyConvertible) {\n  AllowsGenericStreamingAndImplicitConversionTemplate<int> a;\n  EXPECT_EQ(\"AllowsGenericStreamingAndImplicitConversionTemplate\", Print(a));\n}\n\n#if GTEST_HAS_STRING_PIECE_\n\n// Tests printing StringPiece.\n\nTEST(PrintStringPieceTest, SimpleStringPiece) {\n  const StringPiece sp = \"Hello\";\n  EXPECT_EQ(\"\\\"Hello\\\"\", Print(sp));\n}\n\nTEST(PrintStringPieceTest, UnprintableCharacters) {\n  const char str[] = \"NUL (\\0) and \\r\\t\";\n  const StringPiece sp(str, sizeof(str) - 1);\n  EXPECT_EQ(\"\\\"NUL (\\\\0) and \\\\r\\\\t\\\"\", Print(sp));\n}\n\n#endif  // GTEST_HAS_STRING_PIECE_\n\n// Tests printing STL containers.\n\nTEST(PrintStlContainerTest, EmptyDeque) {\n  deque<char> empty;\n  EXPECT_EQ(\"{}\", Print(empty));\n}\n\nTEST(PrintStlContainerTest, NonEmptyDeque) {\n  deque<int> non_empty;\n  non_empty.push_back(1);\n  non_empty.push_back(3);\n  EXPECT_EQ(\"{ 1, 3 }\", Print(non_empty));\n}\n\n#if GTEST_HAS_HASH_MAP_\n\nTEST(PrintStlContainerTest, OneElementHashMap) {\n  hash_map<int, char> map1;\n  map1[1] = 'a';\n  EXPECT_EQ(\"{ (1, 'a' (97, 0x61)) }\", Print(map1));\n}\n\nTEST(PrintStlContainerTest, HashMultiMap) {\n  hash_multimap<int, bool> map1;\n  map1.insert(make_pair(5, true));\n  map1.insert(make_pair(5, false));\n\n  // Elements of hash_multimap can be printed in any order.\n  const string result = Print(map1);\n  EXPECT_TRUE(result == \"{ (5, true), (5, false) }\" ||\n              result == \"{ (5, false), (5, true) }\")\n                  << \" where Print(map1) returns \\\"\" << result << \"\\\".\";\n}\n\n#endif  // GTEST_HAS_HASH_MAP_\n\n#if GTEST_HAS_HASH_SET_\n\nTEST(PrintStlContainerTest, HashSet) {\n  hash_set<string> set1;\n  set1.insert(\"hello\");\n  EXPECT_EQ(\"{ \\\"hello\\\" }\", Print(set1));\n}\n\nTEST(PrintStlContainerTest, HashMultiSet) {\n  const int kSize = 5;\n  int a[kSize] = { 1, 1, 2, 5, 1 };\n  hash_multiset<int> set1(a, a + kSize);\n\n  // Elements of hash_multiset can be printed in any order.\n  const string result = Print(set1);\n  const string expected_pattern = \"{ d, d, d, d, d }\";  // d means a digit.\n\n  // Verifies the result matches the expected pattern; also extracts\n  // the numbers in the result.\n  ASSERT_EQ(expected_pattern.length(), result.length());\n  std::vector<int> numbers;\n  for (size_t i = 0; i != result.length(); i++) {\n    if (expected_pattern[i] == 'd') {\n      ASSERT_NE(isdigit(static_cast<unsigned char>(result[i])), 0);\n      numbers.push_back(result[i] - '0');\n    } else {\n      EXPECT_EQ(expected_pattern[i], result[i]) << \" where result is \"\n                                                << result;\n    }\n  }\n\n  // Makes sure the result contains the right numbers.\n  std::sort(numbers.begin(), numbers.end());\n  std::sort(a, a + kSize);\n  EXPECT_TRUE(std::equal(a, a + kSize, numbers.begin()));\n}\n\n#endif  // GTEST_HAS_HASH_SET_\n\nTEST(PrintStlContainerTest, List) {\n  const string a[] = {\n    \"hello\",\n    \"world\"\n  };\n  const list<string> strings(a, a + 2);\n  EXPECT_EQ(\"{ \\\"hello\\\", \\\"world\\\" }\", Print(strings));\n}\n\nTEST(PrintStlContainerTest, Map) {\n  map<int, bool> map1;\n  map1[1] = true;\n  map1[5] = false;\n  map1[3] = true;\n  EXPECT_EQ(\"{ (1, true), (3, true), (5, false) }\", Print(map1));\n}\n\nTEST(PrintStlContainerTest, MultiMap) {\n  multimap<bool, int> map1;\n  // The make_pair template function would deduce the type as\n  // pair<bool, int> here, and since the key part in a multimap has to\n  // be constant, without a templated ctor in the pair class (as in\n  // libCstd on Solaris), make_pair call would fail to compile as no\n  // implicit conversion is found.  Thus explicit typename is used\n  // here instead.\n  map1.insert(pair<const bool, int>(true, 0));\n  map1.insert(pair<const bool, int>(true, 1));\n  map1.insert(pair<const bool, int>(false, 2));\n  EXPECT_EQ(\"{ (false, 2), (true, 0), (true, 1) }\", Print(map1));\n}\n\nTEST(PrintStlContainerTest, Set) {\n  const unsigned int a[] = { 3, 0, 5 };\n  set<unsigned int> set1(a, a + 3);\n  EXPECT_EQ(\"{ 0, 3, 5 }\", Print(set1));\n}\n\nTEST(PrintStlContainerTest, MultiSet) {\n  const int a[] = { 1, 1, 2, 5, 1 };\n  multiset<int> set1(a, a + 5);\n  EXPECT_EQ(\"{ 1, 1, 1, 2, 5 }\", Print(set1));\n}\n\nTEST(PrintStlContainerTest, Pair) {\n  pair<const bool, int> p(true, 5);\n  EXPECT_EQ(\"(true, 5)\", Print(p));\n}\n\nTEST(PrintStlContainerTest, Vector) {\n  vector<int> v;\n  v.push_back(1);\n  v.push_back(2);\n  EXPECT_EQ(\"{ 1, 2 }\", Print(v));\n}\n\nTEST(PrintStlContainerTest, LongSequence) {\n  const int a[100] = { 1, 2, 3 };\n  const vector<int> v(a, a + 100);\n  EXPECT_EQ(\"{ 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \"\n            \"0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ... }\", Print(v));\n}\n\nTEST(PrintStlContainerTest, NestedContainer) {\n  const int a1[] = { 1, 2 };\n  const int a2[] = { 3, 4, 5 };\n  const list<int> l1(a1, a1 + 2);\n  const list<int> l2(a2, a2 + 3);\n\n  vector<list<int> > v;\n  v.push_back(l1);\n  v.push_back(l2);\n  EXPECT_EQ(\"{ { 1, 2 }, { 3, 4, 5 } }\", Print(v));\n}\n\nTEST(PrintStlContainerTest, OneDimensionalNativeArray) {\n  const int a[3] = { 1, 2, 3 };\n  NativeArray<int> b(a, 3, kReference);\n  EXPECT_EQ(\"{ 1, 2, 3 }\", Print(b));\n}\n\nTEST(PrintStlContainerTest, TwoDimensionalNativeArray) {\n  const int a[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } };\n  NativeArray<int[3]> b(a, 2, kReference);\n  EXPECT_EQ(\"{ { 1, 2, 3 }, { 4, 5, 6 } }\", Print(b));\n}\n\n// Tests that a class named iterator isn't treated as a container.\n\nstruct iterator {\n  char x;\n};\n\nTEST(PrintStlContainerTest, Iterator) {\n  iterator it = {};\n  EXPECT_EQ(\"1-byte object <00>\", Print(it));\n}\n\n// Tests that a class named const_iterator isn't treated as a container.\n\nstruct const_iterator {\n  char x;\n};\n\nTEST(PrintStlContainerTest, ConstIterator) {\n  const_iterator it = {};\n  EXPECT_EQ(\"1-byte object <00>\", Print(it));\n}\n\n#if GTEST_HAS_TR1_TUPLE\n// Tests printing tuples.\n\n// Tuples of various arities.\nTEST(PrintTupleTest, VariousSizes) {\n  tuple<> t0;\n  EXPECT_EQ(\"()\", Print(t0));\n\n  tuple<int> t1(5);\n  EXPECT_EQ(\"(5)\", Print(t1));\n\n  tuple<char, bool> t2('a', true);\n  EXPECT_EQ(\"('a' (97, 0x61), true)\", Print(t2));\n\n  tuple<bool, int, int> t3(false, 2, 3);\n  EXPECT_EQ(\"(false, 2, 3)\", Print(t3));\n\n  tuple<bool, int, int, int> t4(false, 2, 3, 4);\n  EXPECT_EQ(\"(false, 2, 3, 4)\", Print(t4));\n\n  tuple<bool, int, int, int, bool> t5(false, 2, 3, 4, true);\n  EXPECT_EQ(\"(false, 2, 3, 4, true)\", Print(t5));\n\n  tuple<bool, int, int, int, bool, int> t6(false, 2, 3, 4, true, 6);\n  EXPECT_EQ(\"(false, 2, 3, 4, true, 6)\", Print(t6));\n\n  tuple<bool, int, int, int, bool, int, int> t7(false, 2, 3, 4, true, 6, 7);\n  EXPECT_EQ(\"(false, 2, 3, 4, true, 6, 7)\", Print(t7));\n\n  tuple<bool, int, int, int, bool, int, int, bool> t8(\n      false, 2, 3, 4, true, 6, 7, true);\n  EXPECT_EQ(\"(false, 2, 3, 4, true, 6, 7, true)\", Print(t8));\n\n  tuple<bool, int, int, int, bool, int, int, bool, int> t9(\n      false, 2, 3, 4, true, 6, 7, true, 9);\n  EXPECT_EQ(\"(false, 2, 3, 4, true, 6, 7, true, 9)\", Print(t9));\n\n  const char* const str = \"8\";\n  // VC++ 2010's implementation of tuple of C++0x is deficient, requiring\n  // an explicit type cast of NULL to be used.\n  tuple<bool, char, short, testing::internal::Int32,  // NOLINT\n      testing::internal::Int64, float, double, const char*, void*, string>\n      t10(false, 'a', 3, 4, 5, 1.5F, -2.5, str,\n          ImplicitCast_<void*>(NULL), \"10\");\n  EXPECT_EQ(\"(false, 'a' (97, 0x61), 3, 4, 5, 1.5, -2.5, \" + PrintPointer(str) +\n            \" pointing to \\\"8\\\", NULL, \\\"10\\\")\",\n            Print(t10));\n}\n\n// Nested tuples.\nTEST(PrintTupleTest, NestedTuple) {\n  tuple<tuple<int, bool>, char> nested(make_tuple(5, true), 'a');\n  EXPECT_EQ(\"((5, true), 'a' (97, 0x61))\", Print(nested));\n}\n\n#endif  // GTEST_HAS_TR1_TUPLE\n\n// Tests printing user-defined unprintable types.\n\n// Unprintable types in the global namespace.\nTEST(PrintUnprintableTypeTest, InGlobalNamespace) {\n  EXPECT_EQ(\"1-byte object <00>\",\n            Print(UnprintableTemplateInGlobal<char>()));\n}\n\n// Unprintable types in a user namespace.\nTEST(PrintUnprintableTypeTest, InUserNamespace) {\n  EXPECT_EQ(\"16-byte object <EF-12 00-00 34-AB 00-00 00-00 00-00 00-00 00-00>\",\n            Print(::foo::UnprintableInFoo()));\n}\n\n// Unprintable types are that too big to be printed completely.\n\nstruct Big {\n  Big() { memset(array, 0, sizeof(array)); }\n  char array[257];\n};\n\nTEST(PrintUnpritableTypeTest, BigObject) {\n  EXPECT_EQ(\"257-byte object <00-00 00-00 00-00 00-00 00-00 00-00 \"\n            \"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 \"\n            \"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 \"\n            \"00-00 00-00 00-00 00-00 00-00 00-00 ... 00-00 00-00 00-00 \"\n            \"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 \"\n            \"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 \"\n            \"00-00 00-00 00-00 00-00 00-00 00-00 00-00 00-00 00>\",\n            Print(Big()));\n}\n\n// Tests printing user-defined streamable types.\n\n// Streamable types in the global namespace.\nTEST(PrintStreamableTypeTest, InGlobalNamespace) {\n  StreamableInGlobal x;\n  EXPECT_EQ(\"StreamableInGlobal\", Print(x));\n  EXPECT_EQ(\"StreamableInGlobal*\", Print(&x));\n}\n\n// Printable template types in a user namespace.\nTEST(PrintStreamableTypeTest, TemplateTypeInUserNamespace) {\n  EXPECT_EQ(\"StreamableTemplateInFoo: 0\",\n            Print(::foo::StreamableTemplateInFoo<int>()));\n}\n\n// Tests printing user-defined types that have a PrintTo() function.\nTEST(PrintPrintableTypeTest, InUserNamespace) {\n  EXPECT_EQ(\"PrintableViaPrintTo: 0\",\n            Print(::foo::PrintableViaPrintTo()));\n}\n\n// Tests printing a pointer to a user-defined type that has a <<\n// operator for its pointer.\nTEST(PrintPrintableTypeTest, PointerInUserNamespace) {\n  ::foo::PointerPrintable x;\n  EXPECT_EQ(\"PointerPrintable*\", Print(&x));\n}\n\n// Tests printing user-defined class template that have a PrintTo() function.\nTEST(PrintPrintableTypeTest, TemplateInUserNamespace) {\n  EXPECT_EQ(\"PrintableViaPrintToTemplate: 5\",\n            Print(::foo::PrintableViaPrintToTemplate<int>(5)));\n}\n\n#if GTEST_HAS_PROTOBUF_\n\n// Tests printing a protocol message.\nTEST(PrintProtocolMessageTest, PrintsShortDebugString) {\n  testing::internal::TestMessage msg;\n  msg.set_member(\"yes\");\n  EXPECT_EQ(\"<member:\\\"yes\\\">\", Print(msg));\n}\n\n// Tests printing a short proto2 message.\nTEST(PrintProto2MessageTest, PrintsShortDebugStringWhenItIsShort) {\n  testing::internal::FooMessage msg;\n  msg.set_int_field(2);\n  msg.set_string_field(\"hello\");\n  EXPECT_PRED2(RE::FullMatch, Print(msg),\n               \"<int_field:\\\\s*2\\\\s+string_field:\\\\s*\\\"hello\\\">\");\n}\n\n// Tests printing a long proto2 message.\nTEST(PrintProto2MessageTest, PrintsDebugStringWhenItIsLong) {\n  testing::internal::FooMessage msg;\n  msg.set_int_field(2);\n  msg.set_string_field(\"hello\");\n  msg.add_names(\"peter\");\n  msg.add_names(\"paul\");\n  msg.add_names(\"mary\");\n  EXPECT_PRED2(RE::FullMatch, Print(msg),\n               \"<\\n\"\n               \"int_field:\\\\s*2\\n\"\n               \"string_field:\\\\s*\\\"hello\\\"\\n\"\n               \"names:\\\\s*\\\"peter\\\"\\n\"\n               \"names:\\\\s*\\\"paul\\\"\\n\"\n               \"names:\\\\s*\\\"mary\\\"\\n\"\n               \">\");\n}\n\n#endif  // GTEST_HAS_PROTOBUF_\n\n// Tests that the universal printer prints both the address and the\n// value of a reference.\nTEST(PrintReferenceTest, PrintsAddressAndValue) {\n  int n = 5;\n  EXPECT_EQ(\"@\" + PrintPointer(&n) + \" 5\", PrintByRef(n));\n\n  int a[2][3] = {\n    { 0, 1, 2 },\n    { 3, 4, 5 }\n  };\n  EXPECT_EQ(\"@\" + PrintPointer(a) + \" { { 0, 1, 2 }, { 3, 4, 5 } }\",\n            PrintByRef(a));\n\n  const ::foo::UnprintableInFoo x;\n  EXPECT_EQ(\"@\" + PrintPointer(&x) + \" 16-byte object \"\n            \"<EF-12 00-00 34-AB 00-00 00-00 00-00 00-00 00-00>\",\n            PrintByRef(x));\n}\n\n// Tests that the universal printer prints a function pointer passed by\n// reference.\nTEST(PrintReferenceTest, HandlesFunctionPointer) {\n  void (*fp)(int n) = &MyFunction;\n  const string fp_pointer_string =\n      PrintPointer(reinterpret_cast<const void*>(&fp));\n  // We cannot directly cast &MyFunction to const void* because the\n  // standard disallows casting between pointers to functions and\n  // pointers to objects, and some compilers (e.g. GCC 3.4) enforce\n  // this limitation.\n  const string fp_string = PrintPointer(reinterpret_cast<const void*>(\n      reinterpret_cast<internal::BiggestInt>(fp)));\n  EXPECT_EQ(\"@\" + fp_pointer_string + \" \" + fp_string,\n            PrintByRef(fp));\n}\n\n// Tests that the universal printer prints a member function pointer\n// passed by reference.\nTEST(PrintReferenceTest, HandlesMemberFunctionPointer) {\n  int (Foo::*p)(char ch) = &Foo::MyMethod;\n  EXPECT_TRUE(HasPrefix(\n      PrintByRef(p),\n      \"@\" + PrintPointer(reinterpret_cast<const void*>(&p)) + \" \" +\n          Print(sizeof(p)) + \"-byte object \"));\n\n  char (Foo::*p2)(int n) = &Foo::MyVirtualMethod;\n  EXPECT_TRUE(HasPrefix(\n      PrintByRef(p2),\n      \"@\" + PrintPointer(reinterpret_cast<const void*>(&p2)) + \" \" +\n          Print(sizeof(p2)) + \"-byte object \"));\n}\n\n// Tests that the universal printer prints a member variable pointer\n// passed by reference.\nTEST(PrintReferenceTest, HandlesMemberVariablePointer) {\n  int (Foo::*p) = &Foo::value;  // NOLINT\n  EXPECT_TRUE(HasPrefix(\n      PrintByRef(p),\n      \"@\" + PrintPointer(&p) + \" \" + Print(sizeof(p)) + \"-byte object \"));\n}\n\n// Tests that FormatForComparisonFailureMessage(), which is used to print\n// an operand in a comparison assertion (e.g. ASSERT_EQ) when the assertion\n// fails, formats the operand in the desired way.\n\n// scalar\nTEST(FormatForComparisonFailureMessageTest, WorksForScalar) {\n  EXPECT_STREQ(\"123\",\n               FormatForComparisonFailureMessage(123, 124).c_str());\n}\n\n// non-char pointer\nTEST(FormatForComparisonFailureMessageTest, WorksForNonCharPointer) {\n  int n = 0;\n  EXPECT_EQ(PrintPointer(&n),\n            FormatForComparisonFailureMessage(&n, &n).c_str());\n}\n\n// non-char array\nTEST(FormatForComparisonFailureMessageTest, FormatsNonCharArrayAsPointer) {\n  // In expression 'array == x', 'array' is compared by pointer.\n  // Therefore we want to print an array operand as a pointer.\n  int n[] = { 1, 2, 3 };\n  EXPECT_EQ(PrintPointer(n),\n            FormatForComparisonFailureMessage(n, n).c_str());\n}\n\n// Tests formatting a char pointer when it's compared with another pointer.\n// In this case we want to print it as a raw pointer, as the comparision is by\n// pointer.\n\n// char pointer vs pointer\nTEST(FormatForComparisonFailureMessageTest, WorksForCharPointerVsPointer) {\n  // In expression 'p == x', where 'p' and 'x' are (const or not) char\n  // pointers, the operands are compared by pointer.  Therefore we\n  // want to print 'p' as a pointer instead of a C string (we don't\n  // even know if it's supposed to point to a valid C string).\n\n  // const char*\n  const char* s = \"hello\";\n  EXPECT_EQ(PrintPointer(s),\n            FormatForComparisonFailureMessage(s, s).c_str());\n\n  // char*\n  char ch = 'a';\n  EXPECT_EQ(PrintPointer(&ch),\n            FormatForComparisonFailureMessage(&ch, &ch).c_str());\n}\n\n// wchar_t pointer vs pointer\nTEST(FormatForComparisonFailureMessageTest, WorksForWCharPointerVsPointer) {\n  // In expression 'p == x', where 'p' and 'x' are (const or not) char\n  // pointers, the operands are compared by pointer.  Therefore we\n  // want to print 'p' as a pointer instead of a wide C string (we don't\n  // even know if it's supposed to point to a valid wide C string).\n\n  // const wchar_t*\n  const wchar_t* s = L\"hello\";\n  EXPECT_EQ(PrintPointer(s),\n            FormatForComparisonFailureMessage(s, s).c_str());\n\n  // wchar_t*\n  wchar_t ch = L'a';\n  EXPECT_EQ(PrintPointer(&ch),\n            FormatForComparisonFailureMessage(&ch, &ch).c_str());\n}\n\n// Tests formatting a char pointer when it's compared to a string object.\n// In this case we want to print the char pointer as a C string.\n\n#if GTEST_HAS_GLOBAL_STRING\n// char pointer vs ::string\nTEST(FormatForComparisonFailureMessageTest, WorksForCharPointerVsString) {\n  const char* s = \"hello \\\"world\";\n  EXPECT_STREQ(\"\\\"hello \\\\\\\"world\\\"\",  // The string content should be escaped.\n               FormatForComparisonFailureMessage(s, ::string()).c_str());\n\n  // char*\n  char str[] = \"hi\\1\";\n  char* p = str;\n  EXPECT_STREQ(\"\\\"hi\\\\x1\\\"\",  // The string content should be escaped.\n               FormatForComparisonFailureMessage(p, ::string()).c_str());\n}\n#endif\n\n// char pointer vs std::string\nTEST(FormatForComparisonFailureMessageTest, WorksForCharPointerVsStdString) {\n  const char* s = \"hello \\\"world\";\n  EXPECT_STREQ(\"\\\"hello \\\\\\\"world\\\"\",  // The string content should be escaped.\n               FormatForComparisonFailureMessage(s, ::std::string()).c_str());\n\n  // char*\n  char str[] = \"hi\\1\";\n  char* p = str;\n  EXPECT_STREQ(\"\\\"hi\\\\x1\\\"\",  // The string content should be escaped.\n               FormatForComparisonFailureMessage(p, ::std::string()).c_str());\n}\n\n#if GTEST_HAS_GLOBAL_WSTRING\n// wchar_t pointer vs ::wstring\nTEST(FormatForComparisonFailureMessageTest, WorksForWCharPointerVsWString) {\n  const wchar_t* s = L\"hi \\\"world\";\n  EXPECT_STREQ(\"L\\\"hi \\\\\\\"world\\\"\",  // The string content should be escaped.\n               FormatForComparisonFailureMessage(s, ::wstring()).c_str());\n\n  // wchar_t*\n  wchar_t str[] = L\"hi\\1\";\n  wchar_t* p = str;\n  EXPECT_STREQ(\"L\\\"hi\\\\x1\\\"\",  // The string content should be escaped.\n               FormatForComparisonFailureMessage(p, ::wstring()).c_str());\n}\n#endif\n\n#if GTEST_HAS_STD_WSTRING\n// wchar_t pointer vs std::wstring\nTEST(FormatForComparisonFailureMessageTest, WorksForWCharPointerVsStdWString) {\n  const wchar_t* s = L\"hi \\\"world\";\n  EXPECT_STREQ(\"L\\\"hi \\\\\\\"world\\\"\",  // The string content should be escaped.\n               FormatForComparisonFailureMessage(s, ::std::wstring()).c_str());\n\n  // wchar_t*\n  wchar_t str[] = L\"hi\\1\";\n  wchar_t* p = str;\n  EXPECT_STREQ(\"L\\\"hi\\\\x1\\\"\",  // The string content should be escaped.\n               FormatForComparisonFailureMessage(p, ::std::wstring()).c_str());\n}\n#endif\n\n// Tests formatting a char array when it's compared with a pointer or array.\n// In this case we want to print the array as a row pointer, as the comparison\n// is by pointer.\n\n// char array vs pointer\nTEST(FormatForComparisonFailureMessageTest, WorksForCharArrayVsPointer) {\n  char str[] = \"hi \\\"world\\\"\";\n  char* p = NULL;\n  EXPECT_EQ(PrintPointer(str),\n            FormatForComparisonFailureMessage(str, p).c_str());\n}\n\n// char array vs char array\nTEST(FormatForComparisonFailureMessageTest, WorksForCharArrayVsCharArray) {\n  const char str[] = \"hi \\\"world\\\"\";\n  EXPECT_EQ(PrintPointer(str),\n            FormatForComparisonFailureMessage(str, str).c_str());\n}\n\n// wchar_t array vs pointer\nTEST(FormatForComparisonFailureMessageTest, WorksForWCharArrayVsPointer) {\n  wchar_t str[] = L\"hi \\\"world\\\"\";\n  wchar_t* p = NULL;\n  EXPECT_EQ(PrintPointer(str),\n            FormatForComparisonFailureMessage(str, p).c_str());\n}\n\n// wchar_t array vs wchar_t array\nTEST(FormatForComparisonFailureMessageTest, WorksForWCharArrayVsWCharArray) {\n  const wchar_t str[] = L\"hi \\\"world\\\"\";\n  EXPECT_EQ(PrintPointer(str),\n            FormatForComparisonFailureMessage(str, str).c_str());\n}\n\n// Tests formatting a char array when it's compared with a string object.\n// In this case we want to print the array as a C string.\n\n#if GTEST_HAS_GLOBAL_STRING\n// char array vs string\nTEST(FormatForComparisonFailureMessageTest, WorksForCharArrayVsString) {\n  const char str[] = \"hi \\\"w\\0rld\\\"\";\n  EXPECT_STREQ(\"\\\"hi \\\\\\\"w\\\"\",  // The content should be escaped.\n                                // Embedded NUL terminates the string.\n               FormatForComparisonFailureMessage(str, ::string()).c_str());\n}\n#endif\n\n// char array vs std::string\nTEST(FormatForComparisonFailureMessageTest, WorksForCharArrayVsStdString) {\n  const char str[] = \"hi \\\"world\\\"\";\n  EXPECT_STREQ(\"\\\"hi \\\\\\\"world\\\\\\\"\\\"\",  // The content should be escaped.\n               FormatForComparisonFailureMessage(str, ::std::string()).c_str());\n}\n\n#if GTEST_HAS_GLOBAL_WSTRING\n// wchar_t array vs wstring\nTEST(FormatForComparisonFailureMessageTest, WorksForWCharArrayVsWString) {\n  const wchar_t str[] = L\"hi \\\"world\\\"\";\n  EXPECT_STREQ(\"L\\\"hi \\\\\\\"world\\\\\\\"\\\"\",  // The content should be escaped.\n               FormatForComparisonFailureMessage(str, ::wstring()).c_str());\n}\n#endif\n\n#if GTEST_HAS_STD_WSTRING\n// wchar_t array vs std::wstring\nTEST(FormatForComparisonFailureMessageTest, WorksForWCharArrayVsStdWString) {\n  const wchar_t str[] = L\"hi \\\"w\\0rld\\\"\";\n  EXPECT_STREQ(\n      \"L\\\"hi \\\\\\\"w\\\"\",  // The content should be escaped.\n                        // Embedded NUL terminates the string.\n      FormatForComparisonFailureMessage(str, ::std::wstring()).c_str());\n}\n#endif\n\n// Useful for testing PrintToString().  We cannot use EXPECT_EQ()\n// there as its implementation uses PrintToString().  The caller must\n// ensure that 'value' has no side effect.\n#define EXPECT_PRINT_TO_STRING_(value, expected_string)         \\\n  EXPECT_TRUE(PrintToString(value) == (expected_string))        \\\n      << \" where \" #value \" prints as \" << (PrintToString(value))\n\nTEST(PrintToStringTest, WorksForScalar) {\n  EXPECT_PRINT_TO_STRING_(123, \"123\");\n}\n\nTEST(PrintToStringTest, WorksForPointerToConstChar) {\n  const char* p = \"hello\";\n  EXPECT_PRINT_TO_STRING_(p, \"\\\"hello\\\"\");\n}\n\nTEST(PrintToStringTest, WorksForPointerToNonConstChar) {\n  char s[] = \"hello\";\n  char* p = s;\n  EXPECT_PRINT_TO_STRING_(p, \"\\\"hello\\\"\");\n}\n\nTEST(PrintToStringTest, EscapesForPointerToConstChar) {\n  const char* p = \"hello\\n\";\n  EXPECT_PRINT_TO_STRING_(p, \"\\\"hello\\\\n\\\"\");\n}\n\nTEST(PrintToStringTest, EscapesForPointerToNonConstChar) {\n  char s[] = \"hello\\1\";\n  char* p = s;\n  EXPECT_PRINT_TO_STRING_(p, \"\\\"hello\\\\x1\\\"\");\n}\n\nTEST(PrintToStringTest, WorksForArray) {\n  int n[3] = { 1, 2, 3 };\n  EXPECT_PRINT_TO_STRING_(n, \"{ 1, 2, 3 }\");\n}\n\nTEST(PrintToStringTest, WorksForCharArray) {\n  char s[] = \"hello\";\n  EXPECT_PRINT_TO_STRING_(s, \"\\\"hello\\\"\");\n}\n\nTEST(PrintToStringTest, WorksForCharArrayWithEmbeddedNul) {\n  const char str_with_nul[] = \"hello\\0 world\";\n  EXPECT_PRINT_TO_STRING_(str_with_nul, \"\\\"hello\\\\0 world\\\"\");\n\n  char mutable_str_with_nul[] = \"hello\\0 world\";\n  EXPECT_PRINT_TO_STRING_(mutable_str_with_nul, \"\\\"hello\\\\0 world\\\"\");\n}\n\n#undef EXPECT_PRINT_TO_STRING_\n\nTEST(UniversalTersePrintTest, WorksForNonReference) {\n  ::std::stringstream ss;\n  UniversalTersePrint(123, &ss);\n  EXPECT_EQ(\"123\", ss.str());\n}\n\nTEST(UniversalTersePrintTest, WorksForReference) {\n  const int& n = 123;\n  ::std::stringstream ss;\n  UniversalTersePrint(n, &ss);\n  EXPECT_EQ(\"123\", ss.str());\n}\n\nTEST(UniversalTersePrintTest, WorksForCString) {\n  const char* s1 = \"abc\";\n  ::std::stringstream ss1;\n  UniversalTersePrint(s1, &ss1);\n  EXPECT_EQ(\"\\\"abc\\\"\", ss1.str());\n\n  char* s2 = const_cast<char*>(s1);\n  ::std::stringstream ss2;\n  UniversalTersePrint(s2, &ss2);\n  EXPECT_EQ(\"\\\"abc\\\"\", ss2.str());\n\n  const char* s3 = NULL;\n  ::std::stringstream ss3;\n  UniversalTersePrint(s3, &ss3);\n  EXPECT_EQ(\"NULL\", ss3.str());\n}\n\nTEST(UniversalPrintTest, WorksForNonReference) {\n  ::std::stringstream ss;\n  UniversalPrint(123, &ss);\n  EXPECT_EQ(\"123\", ss.str());\n}\n\nTEST(UniversalPrintTest, WorksForReference) {\n  const int& n = 123;\n  ::std::stringstream ss;\n  UniversalPrint(n, &ss);\n  EXPECT_EQ(\"123\", ss.str());\n}\n\nTEST(UniversalPrintTest, WorksForCString) {\n  const char* s1 = \"abc\";\n  ::std::stringstream ss1;\n  UniversalPrint(s1, &ss1);\n  EXPECT_EQ(PrintPointer(s1) + \" pointing to \\\"abc\\\"\", string(ss1.str()));\n\n  char* s2 = const_cast<char*>(s1);\n  ::std::stringstream ss2;\n  UniversalPrint(s2, &ss2);\n  EXPECT_EQ(PrintPointer(s2) + \" pointing to \\\"abc\\\"\", string(ss2.str()));\n\n  const char* s3 = NULL;\n  ::std::stringstream ss3;\n  UniversalPrint(s3, &ss3);\n  EXPECT_EQ(\"NULL\", ss3.str());\n}\n\nTEST(UniversalPrintTest, WorksForCharArray) {\n  const char str[] = \"\\\"Line\\0 1\\\"\\nLine 2\";\n  ::std::stringstream ss1;\n  UniversalPrint(str, &ss1);\n  EXPECT_EQ(\"\\\"\\\\\\\"Line\\\\0 1\\\\\\\"\\\\nLine 2\\\"\", ss1.str());\n\n  const char mutable_str[] = \"\\\"Line\\0 1\\\"\\nLine 2\";\n  ::std::stringstream ss2;\n  UniversalPrint(mutable_str, &ss2);\n  EXPECT_EQ(\"\\\"\\\\\\\"Line\\\\0 1\\\\\\\"\\\\nLine 2\\\"\", ss2.str());\n}\n\n#if GTEST_HAS_TR1_TUPLE\n\nTEST(UniversalTersePrintTupleFieldsToStringsTest, PrintsEmptyTuple) {\n  Strings result = UniversalTersePrintTupleFieldsToStrings(make_tuple());\n  EXPECT_EQ(0u, result.size());\n}\n\nTEST(UniversalTersePrintTupleFieldsToStringsTest, PrintsOneTuple) {\n  Strings result = UniversalTersePrintTupleFieldsToStrings(make_tuple(1));\n  ASSERT_EQ(1u, result.size());\n  EXPECT_EQ(\"1\", result[0]);\n}\n\nTEST(UniversalTersePrintTupleFieldsToStringsTest, PrintsTwoTuple) {\n  Strings result = UniversalTersePrintTupleFieldsToStrings(make_tuple(1, 'a'));\n  ASSERT_EQ(2u, result.size());\n  EXPECT_EQ(\"1\", result[0]);\n  EXPECT_EQ(\"'a' (97, 0x61)\", result[1]);\n}\n\nTEST(UniversalTersePrintTupleFieldsToStringsTest, PrintsTersely) {\n  const int n = 1;\n  Strings result = UniversalTersePrintTupleFieldsToStrings(\n      tuple<const int&, const char*>(n, \"a\"));\n  ASSERT_EQ(2u, result.size());\n  EXPECT_EQ(\"1\", result[0]);\n  EXPECT_EQ(\"\\\"a\\\"\", result[1]);\n}\n\n#endif  // GTEST_HAS_TR1_TUPLE\n\n}  // namespace gtest_printers_test\n}  // namespace testing\n"
  },
  {
    "path": "ext/gtest/test/gtest-test-part_test.cc",
    "content": "// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: mheule@google.com (Markus Heule)\n//\n\n#include \"gtest/gtest-test-part.h\"\n\n#include \"gtest/gtest.h\"\n\nusing testing::Message;\nusing testing::Test;\nusing testing::TestPartResult;\nusing testing::TestPartResultArray;\n\nnamespace {\n\n// Tests the TestPartResult class.\n\n// The test fixture for testing TestPartResult.\nclass TestPartResultTest : public Test {\n protected:\n  TestPartResultTest()\n      : r1_(TestPartResult::kSuccess, \"foo/bar.cc\", 10, \"Success!\"),\n        r2_(TestPartResult::kNonFatalFailure, \"foo/bar.cc\", -1, \"Failure!\"),\n        r3_(TestPartResult::kFatalFailure, NULL, -1, \"Failure!\") {}\n\n  TestPartResult r1_, r2_, r3_;\n};\n\n\nTEST_F(TestPartResultTest, ConstructorWorks) {\n  Message message;\n  message << \"something is terribly wrong\";\n  message << static_cast<const char*>(testing::internal::kStackTraceMarker);\n  message << \"some unimportant stack trace\";\n\n  const TestPartResult result(TestPartResult::kNonFatalFailure,\n                              \"some_file.cc\",\n                              42,\n                              message.GetString().c_str());\n\n  EXPECT_EQ(TestPartResult::kNonFatalFailure, result.type());\n  EXPECT_STREQ(\"some_file.cc\", result.file_name());\n  EXPECT_EQ(42, result.line_number());\n  EXPECT_STREQ(message.GetString().c_str(), result.message());\n  EXPECT_STREQ(\"something is terribly wrong\", result.summary());\n}\n\nTEST_F(TestPartResultTest, ResultAccessorsWork) {\n  const TestPartResult success(TestPartResult::kSuccess,\n                               \"file.cc\",\n                               42,\n                               \"message\");\n  EXPECT_TRUE(success.passed());\n  EXPECT_FALSE(success.failed());\n  EXPECT_FALSE(success.nonfatally_failed());\n  EXPECT_FALSE(success.fatally_failed());\n\n  const TestPartResult nonfatal_failure(TestPartResult::kNonFatalFailure,\n                                        \"file.cc\",\n                                        42,\n                                        \"message\");\n  EXPECT_FALSE(nonfatal_failure.passed());\n  EXPECT_TRUE(nonfatal_failure.failed());\n  EXPECT_TRUE(nonfatal_failure.nonfatally_failed());\n  EXPECT_FALSE(nonfatal_failure.fatally_failed());\n\n  const TestPartResult fatal_failure(TestPartResult::kFatalFailure,\n                                     \"file.cc\",\n                                     42,\n                                     \"message\");\n  EXPECT_FALSE(fatal_failure.passed());\n  EXPECT_TRUE(fatal_failure.failed());\n  EXPECT_FALSE(fatal_failure.nonfatally_failed());\n  EXPECT_TRUE(fatal_failure.fatally_failed());\n}\n\n// Tests TestPartResult::type().\nTEST_F(TestPartResultTest, type) {\n  EXPECT_EQ(TestPartResult::kSuccess, r1_.type());\n  EXPECT_EQ(TestPartResult::kNonFatalFailure, r2_.type());\n  EXPECT_EQ(TestPartResult::kFatalFailure, r3_.type());\n}\n\n// Tests TestPartResult::file_name().\nTEST_F(TestPartResultTest, file_name) {\n  EXPECT_STREQ(\"foo/bar.cc\", r1_.file_name());\n  EXPECT_STREQ(NULL, r3_.file_name());\n}\n\n// Tests TestPartResult::line_number().\nTEST_F(TestPartResultTest, line_number) {\n  EXPECT_EQ(10, r1_.line_number());\n  EXPECT_EQ(-1, r2_.line_number());\n}\n\n// Tests TestPartResult::message().\nTEST_F(TestPartResultTest, message) {\n  EXPECT_STREQ(\"Success!\", r1_.message());\n}\n\n// Tests TestPartResult::passed().\nTEST_F(TestPartResultTest, Passed) {\n  EXPECT_TRUE(r1_.passed());\n  EXPECT_FALSE(r2_.passed());\n  EXPECT_FALSE(r3_.passed());\n}\n\n// Tests TestPartResult::failed().\nTEST_F(TestPartResultTest, Failed) {\n  EXPECT_FALSE(r1_.failed());\n  EXPECT_TRUE(r2_.failed());\n  EXPECT_TRUE(r3_.failed());\n}\n\n// Tests TestPartResult::fatally_failed().\nTEST_F(TestPartResultTest, FatallyFailed) {\n  EXPECT_FALSE(r1_.fatally_failed());\n  EXPECT_FALSE(r2_.fatally_failed());\n  EXPECT_TRUE(r3_.fatally_failed());\n}\n\n// Tests TestPartResult::nonfatally_failed().\nTEST_F(TestPartResultTest, NonfatallyFailed) {\n  EXPECT_FALSE(r1_.nonfatally_failed());\n  EXPECT_TRUE(r2_.nonfatally_failed());\n  EXPECT_FALSE(r3_.nonfatally_failed());\n}\n\n// Tests the TestPartResultArray class.\n\nclass TestPartResultArrayTest : public Test {\n protected:\n  TestPartResultArrayTest()\n      : r1_(TestPartResult::kNonFatalFailure, \"foo/bar.cc\", -1, \"Failure 1\"),\n        r2_(TestPartResult::kFatalFailure, \"foo/bar.cc\", -1, \"Failure 2\") {}\n\n  const TestPartResult r1_, r2_;\n};\n\n// Tests that TestPartResultArray initially has size 0.\nTEST_F(TestPartResultArrayTest, InitialSizeIsZero) {\n  TestPartResultArray results;\n  EXPECT_EQ(0, results.size());\n}\n\n// Tests that TestPartResultArray contains the given TestPartResult\n// after one Append() operation.\nTEST_F(TestPartResultArrayTest, ContainsGivenResultAfterAppend) {\n  TestPartResultArray results;\n  results.Append(r1_);\n  EXPECT_EQ(1, results.size());\n  EXPECT_STREQ(\"Failure 1\", results.GetTestPartResult(0).message());\n}\n\n// Tests that TestPartResultArray contains the given TestPartResults\n// after two Append() operations.\nTEST_F(TestPartResultArrayTest, ContainsGivenResultsAfterTwoAppends) {\n  TestPartResultArray results;\n  results.Append(r1_);\n  results.Append(r2_);\n  EXPECT_EQ(2, results.size());\n  EXPECT_STREQ(\"Failure 1\", results.GetTestPartResult(0).message());\n  EXPECT_STREQ(\"Failure 2\", results.GetTestPartResult(1).message());\n}\n\ntypedef TestPartResultArrayTest TestPartResultArrayDeathTest;\n\n// Tests that the program dies when GetTestPartResult() is called with\n// an invalid index.\nTEST_F(TestPartResultArrayDeathTest, DiesWhenIndexIsOutOfBound) {\n  TestPartResultArray results;\n  results.Append(r1_);\n\n  EXPECT_DEATH_IF_SUPPORTED(results.GetTestPartResult(-1), \"\");\n  EXPECT_DEATH_IF_SUPPORTED(results.GetTestPartResult(1), \"\");\n}\n\n// TODO(mheule@google.com): Add a test for the class HasNewFatalFailureHelper.\n\n}  // namespace\n"
  },
  {
    "path": "ext/gtest/test/gtest-tuple_test.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"gtest/internal/gtest-tuple.h\"\n#include <utility>\n#include \"gtest/gtest.h\"\n\nnamespace {\n\nusing ::std::tr1::get;\nusing ::std::tr1::make_tuple;\nusing ::std::tr1::tuple;\nusing ::std::tr1::tuple_element;\nusing ::std::tr1::tuple_size;\nusing ::testing::StaticAssertTypeEq;\n\n// Tests that tuple_element<K, tuple<T0, T1, ..., TN> >::type returns TK.\nTEST(tuple_element_Test, ReturnsElementType) {\n  StaticAssertTypeEq<int, tuple_element<0, tuple<int, char> >::type>();\n  StaticAssertTypeEq<int&, tuple_element<1, tuple<double, int&> >::type>();\n  StaticAssertTypeEq<bool, tuple_element<2, tuple<double, int, bool> >::type>();\n}\n\n// Tests that tuple_size<T>::value gives the number of fields in tuple\n// type T.\nTEST(tuple_size_Test, ReturnsNumberOfFields) {\n  EXPECT_EQ(0, +tuple_size<tuple<> >::value);\n  EXPECT_EQ(1, +tuple_size<tuple<void*> >::value);\n  EXPECT_EQ(1, +tuple_size<tuple<char> >::value);\n  EXPECT_EQ(1, +(tuple_size<tuple<tuple<int, double> > >::value));\n  EXPECT_EQ(2, +(tuple_size<tuple<int&, const char> >::value));\n  EXPECT_EQ(3, +(tuple_size<tuple<char*, void, const bool&> >::value));\n}\n\n// Tests comparing a tuple with itself.\nTEST(ComparisonTest, ComparesWithSelf) {\n  const tuple<int, char, bool> a(5, 'a', false);\n\n  EXPECT_TRUE(a == a);\n  EXPECT_FALSE(a != a);\n}\n\n// Tests comparing two tuples with the same value.\nTEST(ComparisonTest, ComparesEqualTuples) {\n  const tuple<int, bool> a(5, true), b(5, true);\n\n  EXPECT_TRUE(a == b);\n  EXPECT_FALSE(a != b);\n}\n\n// Tests comparing two different tuples that have no reference fields.\nTEST(ComparisonTest, ComparesUnequalTuplesWithoutReferenceFields) {\n  typedef tuple<const int, char> FooTuple;\n\n  const FooTuple a(0, 'x');\n  const FooTuple b(1, 'a');\n\n  EXPECT_TRUE(a != b);\n  EXPECT_FALSE(a == b);\n\n  const FooTuple c(1, 'b');\n\n  EXPECT_TRUE(b != c);\n  EXPECT_FALSE(b == c);\n}\n\n// Tests comparing two different tuples that have reference fields.\nTEST(ComparisonTest, ComparesUnequalTuplesWithReferenceFields) {\n  typedef tuple<int&, const char&> FooTuple;\n\n  int i = 5;\n  const char ch = 'a';\n  const FooTuple a(i, ch);\n\n  int j = 6;\n  const FooTuple b(j, ch);\n\n  EXPECT_TRUE(a != b);\n  EXPECT_FALSE(a == b);\n\n  j = 5;\n  const char ch2 = 'b';\n  const FooTuple c(j, ch2);\n\n  EXPECT_TRUE(b != c);\n  EXPECT_FALSE(b == c);\n}\n\n// Tests that a tuple field with a reference type is an alias of the\n// variable it's supposed to reference.\nTEST(ReferenceFieldTest, IsAliasOfReferencedVariable) {\n  int n = 0;\n  tuple<bool, int&> t(true, n);\n\n  n = 1;\n  EXPECT_EQ(n, get<1>(t))\n      << \"Changing a underlying variable should update the reference field.\";\n\n  // Makes sure that the implementation doesn't do anything funny with\n  // the & operator for the return type of get<>().\n  EXPECT_EQ(&n, &(get<1>(t)))\n      << \"The address of a reference field should equal the address of \"\n      << \"the underlying variable.\";\n\n  get<1>(t) = 2;\n  EXPECT_EQ(2, n)\n      << \"Changing a reference field should update the underlying variable.\";\n}\n\n// Tests that tuple's default constructor default initializes each field.\n// This test needs to compile without generating warnings.\nTEST(TupleConstructorTest, DefaultConstructorDefaultInitializesEachField) {\n  // The TR1 report requires that tuple's default constructor default\n  // initializes each field, even if it's a primitive type.  If the\n  // implementation forgets to do this, this test will catch it by\n  // generating warnings about using uninitialized variables (assuming\n  // a decent compiler).\n\n  tuple<> empty;\n\n  tuple<int> a1, b1;\n  b1 = a1;\n  EXPECT_EQ(0, get<0>(b1));\n\n  tuple<int, double> a2, b2;\n  b2 = a2;\n  EXPECT_EQ(0, get<0>(b2));\n  EXPECT_EQ(0.0, get<1>(b2));\n\n  tuple<double, char, bool*> a3, b3;\n  b3 = a3;\n  EXPECT_EQ(0.0, get<0>(b3));\n  EXPECT_EQ('\\0', get<1>(b3));\n  EXPECT_TRUE(get<2>(b3) == NULL);\n\n  tuple<int, int, int, int, int, int, int, int, int, int> a10, b10;\n  b10 = a10;\n  EXPECT_EQ(0, get<0>(b10));\n  EXPECT_EQ(0, get<1>(b10));\n  EXPECT_EQ(0, get<2>(b10));\n  EXPECT_EQ(0, get<3>(b10));\n  EXPECT_EQ(0, get<4>(b10));\n  EXPECT_EQ(0, get<5>(b10));\n  EXPECT_EQ(0, get<6>(b10));\n  EXPECT_EQ(0, get<7>(b10));\n  EXPECT_EQ(0, get<8>(b10));\n  EXPECT_EQ(0, get<9>(b10));\n}\n\n// Tests constructing a tuple from its fields.\nTEST(TupleConstructorTest, ConstructsFromFields) {\n  int n = 1;\n  // Reference field.\n  tuple<int&> a(n);\n  EXPECT_EQ(&n, &(get<0>(a)));\n\n  // Non-reference fields.\n  tuple<int, char> b(5, 'a');\n  EXPECT_EQ(5, get<0>(b));\n  EXPECT_EQ('a', get<1>(b));\n\n  // Const reference field.\n  const int m = 2;\n  tuple<bool, const int&> c(true, m);\n  EXPECT_TRUE(get<0>(c));\n  EXPECT_EQ(&m, &(get<1>(c)));\n}\n\n// Tests tuple's copy constructor.\nTEST(TupleConstructorTest, CopyConstructor) {\n  tuple<double, bool> a(0.0, true);\n  tuple<double, bool> b(a);\n\n  EXPECT_DOUBLE_EQ(0.0, get<0>(b));\n  EXPECT_TRUE(get<1>(b));\n}\n\n// Tests constructing a tuple from another tuple that has a compatible\n// but different type.\nTEST(TupleConstructorTest, ConstructsFromDifferentTupleType) {\n  tuple<int, int, char> a(0, 1, 'a');\n  tuple<double, long, int> b(a);\n\n  EXPECT_DOUBLE_EQ(0.0, get<0>(b));\n  EXPECT_EQ(1, get<1>(b));\n  EXPECT_EQ('a', get<2>(b));\n}\n\n// Tests constructing a 2-tuple from an std::pair.\nTEST(TupleConstructorTest, ConstructsFromPair) {\n  ::std::pair<int, char> a(1, 'a');\n  tuple<int, char> b(a);\n  tuple<int, const char&> c(a);\n}\n\n// Tests assigning a tuple to another tuple with the same type.\nTEST(TupleAssignmentTest, AssignsToSameTupleType) {\n  const tuple<int, long> a(5, 7L);\n  tuple<int, long> b;\n  b = a;\n  EXPECT_EQ(5, get<0>(b));\n  EXPECT_EQ(7L, get<1>(b));\n}\n\n// Tests assigning a tuple to another tuple with a different but\n// compatible type.\nTEST(TupleAssignmentTest, AssignsToDifferentTupleType) {\n  const tuple<int, long, bool> a(1, 7L, true);\n  tuple<long, int, bool> b;\n  b = a;\n  EXPECT_EQ(1L, get<0>(b));\n  EXPECT_EQ(7, get<1>(b));\n  EXPECT_TRUE(get<2>(b));\n}\n\n// Tests assigning an std::pair to a 2-tuple.\nTEST(TupleAssignmentTest, AssignsFromPair) {\n  const ::std::pair<int, bool> a(5, true);\n  tuple<int, bool> b;\n  b = a;\n  EXPECT_EQ(5, get<0>(b));\n  EXPECT_TRUE(get<1>(b));\n\n  tuple<long, bool> c;\n  c = a;\n  EXPECT_EQ(5L, get<0>(c));\n  EXPECT_TRUE(get<1>(c));\n}\n\n// A fixture for testing big tuples.\nclass BigTupleTest : public testing::Test {\n protected:\n  typedef tuple<int, int, int, int, int, int, int, int, int, int> BigTuple;\n\n  BigTupleTest() :\n      a_(1, 0, 0, 0, 0, 0, 0, 0, 0, 2),\n      b_(1, 0, 0, 0, 0, 0, 0, 0, 0, 3) {}\n\n  BigTuple a_, b_;\n};\n\n// Tests constructing big tuples.\nTEST_F(BigTupleTest, Construction) {\n  BigTuple a;\n  BigTuple b(b_);\n}\n\n// Tests that get<N>(t) returns the N-th (0-based) field of tuple t.\nTEST_F(BigTupleTest, get) {\n  EXPECT_EQ(1, get<0>(a_));\n  EXPECT_EQ(2, get<9>(a_));\n\n  // Tests that get() works on a const tuple too.\n  const BigTuple a(a_);\n  EXPECT_EQ(1, get<0>(a));\n  EXPECT_EQ(2, get<9>(a));\n}\n\n// Tests comparing big tuples.\nTEST_F(BigTupleTest, Comparisons) {\n  EXPECT_TRUE(a_ == a_);\n  EXPECT_FALSE(a_ != a_);\n\n  EXPECT_TRUE(a_ != b_);\n  EXPECT_FALSE(a_ == b_);\n}\n\nTEST(MakeTupleTest, WorksForScalarTypes) {\n  tuple<bool, int> a;\n  a = make_tuple(true, 5);\n  EXPECT_TRUE(get<0>(a));\n  EXPECT_EQ(5, get<1>(a));\n\n  tuple<char, int, long> b;\n  b = make_tuple('a', 'b', 5);\n  EXPECT_EQ('a', get<0>(b));\n  EXPECT_EQ('b', get<1>(b));\n  EXPECT_EQ(5, get<2>(b));\n}\n\nTEST(MakeTupleTest, WorksForPointers) {\n  int a[] = { 1, 2, 3, 4 };\n  const char* const str = \"hi\";\n  int* const p = a;\n\n  tuple<const char*, int*> t;\n  t = make_tuple(str, p);\n  EXPECT_EQ(str, get<0>(t));\n  EXPECT_EQ(p, get<1>(t));\n}\n\n}  // namespace\n"
  },
  {
    "path": "ext/gtest/test/gtest-typed-test2_test.cc",
    "content": "// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include <vector>\n\n#include \"test/gtest-typed-test_test.h\"\n#include \"gtest/gtest.h\"\n\n#if GTEST_HAS_TYPED_TEST_P\n\n// Tests that the same type-parameterized test case can be\n// instantiated in different translation units linked together.\n// (ContainerTest is also instantiated in gtest-typed-test_test.cc.)\nINSTANTIATE_TYPED_TEST_CASE_P(Vector, ContainerTest,\n                              testing::Types<std::vector<int> >);\n\n#endif  // GTEST_HAS_TYPED_TEST_P\n"
  },
  {
    "path": "ext/gtest/test/gtest-typed-test_test.cc",
    "content": "// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include <set>\n#include <vector>\n\n#include \"test/gtest-typed-test_test.h\"\n#include \"gtest/gtest.h\"\n\nusing testing::Test;\n\n// Used for testing that SetUpTestCase()/TearDownTestCase(), fixture\n// ctor/dtor, and SetUp()/TearDown() work correctly in typed tests and\n// type-parameterized test.\ntemplate <typename T>\nclass CommonTest : public Test {\n  // For some technical reason, SetUpTestCase() and TearDownTestCase()\n  // must be public.\n public:\n  static void SetUpTestCase() {\n    shared_ = new T(5);\n  }\n\n  static void TearDownTestCase() {\n    delete shared_;\n    shared_ = NULL;\n  }\n\n  // This 'protected:' is optional.  There's no harm in making all\n  // members of this fixture class template public.\n protected:\n  // We used to use std::list here, but switched to std::vector since\n  // MSVC's <list> doesn't compile cleanly with /W4.\n  typedef std::vector<T> Vector;\n  typedef std::set<int> IntSet;\n\n  CommonTest() : value_(1) {}\n\n  virtual ~CommonTest() { EXPECT_EQ(3, value_); }\n\n  virtual void SetUp() {\n    EXPECT_EQ(1, value_);\n    value_++;\n  }\n\n  virtual void TearDown() {\n    EXPECT_EQ(2, value_);\n    value_++;\n  }\n\n  T value_;\n  static T* shared_;\n};\n\ntemplate <typename T>\nT* CommonTest<T>::shared_ = NULL;\n\n// This #ifdef block tests typed tests.\n#if GTEST_HAS_TYPED_TEST\n\nusing testing::Types;\n\n// Tests that SetUpTestCase()/TearDownTestCase(), fixture ctor/dtor,\n// and SetUp()/TearDown() work correctly in typed tests\n\ntypedef Types<char, int> TwoTypes;\nTYPED_TEST_CASE(CommonTest, TwoTypes);\n\nTYPED_TEST(CommonTest, ValuesAreCorrect) {\n  // Static members of the fixture class template can be visited via\n  // the TestFixture:: prefix.\n  EXPECT_EQ(5, *TestFixture::shared_);\n\n  // Typedefs in the fixture class template can be visited via the\n  // \"typename TestFixture::\" prefix.\n  typename TestFixture::Vector empty;\n  EXPECT_EQ(0U, empty.size());\n\n  typename TestFixture::IntSet empty2;\n  EXPECT_EQ(0U, empty2.size());\n\n  // Non-static members of the fixture class must be visited via\n  // 'this', as required by C++ for class templates.\n  EXPECT_EQ(2, this->value_);\n}\n\n// The second test makes sure shared_ is not deleted after the first\n// test.\nTYPED_TEST(CommonTest, ValuesAreStillCorrect) {\n  // Static members of the fixture class template can also be visited\n  // via 'this'.\n  ASSERT_TRUE(this->shared_ != NULL);\n  EXPECT_EQ(5, *this->shared_);\n\n  // TypeParam can be used to refer to the type parameter.\n  EXPECT_EQ(static_cast<TypeParam>(2), this->value_);\n}\n\n// Tests that multiple TYPED_TEST_CASE's can be defined in the same\n// translation unit.\n\ntemplate <typename T>\nclass TypedTest1 : public Test {\n};\n\n// Verifies that the second argument of TYPED_TEST_CASE can be a\n// single type.\nTYPED_TEST_CASE(TypedTest1, int);\nTYPED_TEST(TypedTest1, A) {}\n\ntemplate <typename T>\nclass TypedTest2 : public Test {\n};\n\n// Verifies that the second argument of TYPED_TEST_CASE can be a\n// Types<...> type list.\nTYPED_TEST_CASE(TypedTest2, Types<int>);\n\n// This also verifies that tests from different typed test cases can\n// share the same name.\nTYPED_TEST(TypedTest2, A) {}\n\n// Tests that a typed test case can be defined in a namespace.\n\nnamespace library1 {\n\ntemplate <typename T>\nclass NumericTest : public Test {\n};\n\ntypedef Types<int, long> NumericTypes;\nTYPED_TEST_CASE(NumericTest, NumericTypes);\n\nTYPED_TEST(NumericTest, DefaultIsZero) {\n  EXPECT_EQ(0, TypeParam());\n}\n\n}  // namespace library1\n\n#endif  // GTEST_HAS_TYPED_TEST\n\n// This #ifdef block tests type-parameterized tests.\n#if GTEST_HAS_TYPED_TEST_P\n\nusing testing::Types;\nusing testing::internal::TypedTestCasePState;\n\n// Tests TypedTestCasePState.\n\nclass TypedTestCasePStateTest : public Test {\n protected:\n  virtual void SetUp() {\n    state_.AddTestName(\"foo.cc\", 0, \"FooTest\", \"A\");\n    state_.AddTestName(\"foo.cc\", 0, \"FooTest\", \"B\");\n    state_.AddTestName(\"foo.cc\", 0, \"FooTest\", \"C\");\n  }\n\n  TypedTestCasePState state_;\n};\n\nTEST_F(TypedTestCasePStateTest, SucceedsForMatchingList) {\n  const char* tests = \"A, B, C\";\n  EXPECT_EQ(tests,\n            state_.VerifyRegisteredTestNames(\"foo.cc\", 1, tests));\n}\n\n// Makes sure that the order of the tests and spaces around the names\n// don't matter.\nTEST_F(TypedTestCasePStateTest, IgnoresOrderAndSpaces) {\n  const char* tests = \"A,C,   B\";\n  EXPECT_EQ(tests,\n            state_.VerifyRegisteredTestNames(\"foo.cc\", 1, tests));\n}\n\ntypedef TypedTestCasePStateTest TypedTestCasePStateDeathTest;\n\nTEST_F(TypedTestCasePStateDeathTest, DetectsDuplicates) {\n  EXPECT_DEATH_IF_SUPPORTED(\n      state_.VerifyRegisteredTestNames(\"foo.cc\", 1, \"A, B, A, C\"),\n      \"foo\\\\.cc.1.?: Test A is listed more than once\\\\.\");\n}\n\nTEST_F(TypedTestCasePStateDeathTest, DetectsExtraTest) {\n  EXPECT_DEATH_IF_SUPPORTED(\n      state_.VerifyRegisteredTestNames(\"foo.cc\", 1, \"A, B, C, D\"),\n      \"foo\\\\.cc.1.?: No test named D can be found in this test case\\\\.\");\n}\n\nTEST_F(TypedTestCasePStateDeathTest, DetectsMissedTest) {\n  EXPECT_DEATH_IF_SUPPORTED(\n      state_.VerifyRegisteredTestNames(\"foo.cc\", 1, \"A, C\"),\n      \"foo\\\\.cc.1.?: You forgot to list test B\\\\.\");\n}\n\n// Tests that defining a test for a parameterized test case generates\n// a run-time error if the test case has been registered.\nTEST_F(TypedTestCasePStateDeathTest, DetectsTestAfterRegistration) {\n  state_.VerifyRegisteredTestNames(\"foo.cc\", 1, \"A, B, C\");\n  EXPECT_DEATH_IF_SUPPORTED(\n      state_.AddTestName(\"foo.cc\", 2, \"FooTest\", \"D\"),\n      \"foo\\\\.cc.2.?: Test D must be defined before REGISTER_TYPED_TEST_CASE_P\"\n      \"\\\\(FooTest, \\\\.\\\\.\\\\.\\\\)\\\\.\");\n}\n\n// Tests that SetUpTestCase()/TearDownTestCase(), fixture ctor/dtor,\n// and SetUp()/TearDown() work correctly in type-parameterized tests.\n\ntemplate <typename T>\nclass DerivedTest : public CommonTest<T> {\n};\n\nTYPED_TEST_CASE_P(DerivedTest);\n\nTYPED_TEST_P(DerivedTest, ValuesAreCorrect) {\n  // Static members of the fixture class template can be visited via\n  // the TestFixture:: prefix.\n  EXPECT_EQ(5, *TestFixture::shared_);\n\n  // Non-static members of the fixture class must be visited via\n  // 'this', as required by C++ for class templates.\n  EXPECT_EQ(2, this->value_);\n}\n\n// The second test makes sure shared_ is not deleted after the first\n// test.\nTYPED_TEST_P(DerivedTest, ValuesAreStillCorrect) {\n  // Static members of the fixture class template can also be visited\n  // via 'this'.\n  ASSERT_TRUE(this->shared_ != NULL);\n  EXPECT_EQ(5, *this->shared_);\n  EXPECT_EQ(2, this->value_);\n}\n\nREGISTER_TYPED_TEST_CASE_P(DerivedTest,\n                           ValuesAreCorrect, ValuesAreStillCorrect);\n\ntypedef Types<short, long> MyTwoTypes;\nINSTANTIATE_TYPED_TEST_CASE_P(My, DerivedTest, MyTwoTypes);\n\n// Tests that multiple TYPED_TEST_CASE_P's can be defined in the same\n// translation unit.\n\ntemplate <typename T>\nclass TypedTestP1 : public Test {\n};\n\nTYPED_TEST_CASE_P(TypedTestP1);\n\n// For testing that the code between TYPED_TEST_CASE_P() and\n// TYPED_TEST_P() is not enclosed in a namespace.\ntypedef int IntAfterTypedTestCaseP;\n\nTYPED_TEST_P(TypedTestP1, A) {}\nTYPED_TEST_P(TypedTestP1, B) {}\n\n// For testing that the code between TYPED_TEST_P() and\n// REGISTER_TYPED_TEST_CASE_P() is not enclosed in a namespace.\ntypedef int IntBeforeRegisterTypedTestCaseP;\n\nREGISTER_TYPED_TEST_CASE_P(TypedTestP1, A, B);\n\ntemplate <typename T>\nclass TypedTestP2 : public Test {\n};\n\nTYPED_TEST_CASE_P(TypedTestP2);\n\n// This also verifies that tests from different type-parameterized\n// test cases can share the same name.\nTYPED_TEST_P(TypedTestP2, A) {}\n\nREGISTER_TYPED_TEST_CASE_P(TypedTestP2, A);\n\n// Verifies that the code between TYPED_TEST_CASE_P() and\n// REGISTER_TYPED_TEST_CASE_P() is not enclosed in a namespace.\nIntAfterTypedTestCaseP after = 0;\nIntBeforeRegisterTypedTestCaseP before = 0;\n\n// Verifies that the last argument of INSTANTIATE_TYPED_TEST_CASE_P()\n// can be either a single type or a Types<...> type list.\nINSTANTIATE_TYPED_TEST_CASE_P(Int, TypedTestP1, int);\nINSTANTIATE_TYPED_TEST_CASE_P(Int, TypedTestP2, Types<int>);\n\n// Tests that the same type-parameterized test case can be\n// instantiated more than once in the same translation unit.\nINSTANTIATE_TYPED_TEST_CASE_P(Double, TypedTestP2, Types<double>);\n\n// Tests that the same type-parameterized test case can be\n// instantiated in different translation units linked together.\n// (ContainerTest is also instantiated in gtest-typed-test_test.cc.)\ntypedef Types<std::vector<double>, std::set<char> > MyContainers;\nINSTANTIATE_TYPED_TEST_CASE_P(My, ContainerTest, MyContainers);\n\n// Tests that a type-parameterized test case can be defined and\n// instantiated in a namespace.\n\nnamespace library2 {\n\ntemplate <typename T>\nclass NumericTest : public Test {\n};\n\nTYPED_TEST_CASE_P(NumericTest);\n\nTYPED_TEST_P(NumericTest, DefaultIsZero) {\n  EXPECT_EQ(0, TypeParam());\n}\n\nTYPED_TEST_P(NumericTest, ZeroIsLessThanOne) {\n  EXPECT_LT(TypeParam(0), TypeParam(1));\n}\n\nREGISTER_TYPED_TEST_CASE_P(NumericTest,\n                           DefaultIsZero, ZeroIsLessThanOne);\ntypedef Types<int, double> NumericTypes;\nINSTANTIATE_TYPED_TEST_CASE_P(My, NumericTest, NumericTypes);\n\n}  // namespace library2\n\n#endif  // GTEST_HAS_TYPED_TEST_P\n\n#if !defined(GTEST_HAS_TYPED_TEST) && !defined(GTEST_HAS_TYPED_TEST_P)\n\n// Google Test may not support type-parameterized tests with some\n// compilers. If we use conditional compilation to compile out all\n// code referring to the gtest_main library, MSVC linker will not link\n// that library at all and consequently complain about missing entry\n// point defined in that library (fatal error LNK1561: entry point\n// must be defined). This dummy test keeps gtest_main linked in.\nTEST(DummyTest, TypedTestsAreNotSupportedOnThisPlatform) {}\n\n#endif  // #if !defined(GTEST_HAS_TYPED_TEST) && !defined(GTEST_HAS_TYPED_TEST_P)\n"
  },
  {
    "path": "ext/gtest/test/gtest-typed-test_test.h",
    "content": "// Copyright 2008 Google Inc.\n// All Rights Reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#ifndef GTEST_TEST_GTEST_TYPED_TEST_TEST_H_\n#define GTEST_TEST_GTEST_TYPED_TEST_TEST_H_\n\n#include \"gtest/gtest.h\"\n\n#if GTEST_HAS_TYPED_TEST_P\n\nusing testing::Test;\n\n// For testing that the same type-parameterized test case can be\n// instantiated in different translation units linked together.\n// ContainerTest will be instantiated in both gtest-typed-test_test.cc\n// and gtest-typed-test2_test.cc.\n\ntemplate <typename T>\nclass ContainerTest : public Test {\n};\n\nTYPED_TEST_CASE_P(ContainerTest);\n\nTYPED_TEST_P(ContainerTest, CanBeDefaultConstructed) {\n  TypeParam container;\n}\n\nTYPED_TEST_P(ContainerTest, InitialSizeIsZero) {\n  TypeParam container;\n  EXPECT_EQ(0U, container.size());\n}\n\nREGISTER_TYPED_TEST_CASE_P(ContainerTest,\n                           CanBeDefaultConstructed, InitialSizeIsZero);\n\n#endif  // GTEST_HAS_TYPED_TEST_P\n\n#endif  // GTEST_TEST_GTEST_TYPED_TEST_TEST_H_\n"
  },
  {
    "path": "ext/gtest/test/gtest-unittest-api_test.cc",
    "content": "// Copyright 2009 Google Inc.  All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n//\n// The Google C++ Testing Framework (Google Test)\n//\n// This file contains tests verifying correctness of data provided via\n// UnitTest's public methods.\n\n#include \"gtest/gtest.h\"\n\n#include <string.h>  // For strcmp.\n#include <algorithm>\n\nusing ::testing::InitGoogleTest;\n\nnamespace testing {\nnamespace internal {\n\ntemplate <typename T>\nstruct LessByName {\n  bool operator()(const T* a, const T* b) {\n    return strcmp(a->name(), b->name()) < 0;\n  }\n};\n\nclass UnitTestHelper {\n public:\n  // Returns the array of pointers to all test cases sorted by the test case\n  // name.  The caller is responsible for deleting the array.\n  static TestCase const** const GetSortedTestCases() {\n    UnitTest& unit_test = *UnitTest::GetInstance();\n    TestCase const** const test_cases =\n        new const TestCase*[unit_test.total_test_case_count()];\n\n    for (int i = 0; i < unit_test.total_test_case_count(); ++i)\n      test_cases[i] = unit_test.GetTestCase(i);\n\n    std::sort(test_cases,\n              test_cases + unit_test.total_test_case_count(),\n              LessByName<TestCase>());\n    return test_cases;\n  }\n\n  // Returns the test case by its name.  The caller doesn't own the returned\n  // pointer.\n  static const TestCase* FindTestCase(const char* name) {\n    UnitTest& unit_test = *UnitTest::GetInstance();\n    for (int i = 0; i < unit_test.total_test_case_count(); ++i) {\n      const TestCase* test_case = unit_test.GetTestCase(i);\n      if (0 == strcmp(test_case->name(), name))\n        return test_case;\n    }\n    return NULL;\n  }\n\n  // Returns the array of pointers to all tests in a particular test case\n  // sorted by the test name.  The caller is responsible for deleting the\n  // array.\n  static TestInfo const** const GetSortedTests(const TestCase* test_case) {\n    TestInfo const** const tests =\n        new const TestInfo*[test_case->total_test_count()];\n\n    for (int i = 0; i < test_case->total_test_count(); ++i)\n      tests[i] = test_case->GetTestInfo(i);\n\n    std::sort(tests, tests + test_case->total_test_count(),\n              LessByName<TestInfo>());\n    return tests;\n  }\n};\n\n#if GTEST_HAS_TYPED_TEST\ntemplate <typename T> class TestCaseWithCommentTest : public Test {};\nTYPED_TEST_CASE(TestCaseWithCommentTest, Types<int>);\nTYPED_TEST(TestCaseWithCommentTest, Dummy) {}\n\nconst int kTypedTestCases = 1;\nconst int kTypedTests = 1;\n#else\nconst int kTypedTestCases = 0;\nconst int kTypedTests = 0;\n#endif  // GTEST_HAS_TYPED_TEST\n\n// We can only test the accessors that do not change value while tests run.\n// Since tests can be run in any order, the values the accessors that track\n// test execution (such as failed_test_count) can not be predicted.\nTEST(ApiTest, UnitTestImmutableAccessorsWork) {\n  UnitTest* unit_test = UnitTest::GetInstance();\n\n  ASSERT_EQ(2 + kTypedTestCases, unit_test->total_test_case_count());\n  EXPECT_EQ(1 + kTypedTestCases, unit_test->test_case_to_run_count());\n  EXPECT_EQ(2, unit_test->disabled_test_count());\n  EXPECT_EQ(5 + kTypedTests, unit_test->total_test_count());\n  EXPECT_EQ(3 + kTypedTests, unit_test->test_to_run_count());\n\n  const TestCase** const test_cases = UnitTestHelper::GetSortedTestCases();\n\n  EXPECT_STREQ(\"ApiTest\", test_cases[0]->name());\n  EXPECT_STREQ(\"DISABLED_Test\", test_cases[1]->name());\n#if GTEST_HAS_TYPED_TEST\n  EXPECT_STREQ(\"TestCaseWithCommentTest/0\", test_cases[2]->name());\n#endif  // GTEST_HAS_TYPED_TEST\n\n  delete[] test_cases;\n\n  // The following lines initiate actions to verify certain methods in\n  // FinalSuccessChecker::TearDown.\n\n  // Records a test property to verify TestResult::GetTestProperty().\n  RecordProperty(\"key\", \"value\");\n}\n\nAssertionResult IsNull(const char* str) {\n  if (str != NULL) {\n    return testing::AssertionFailure() << \"argument is \" << str;\n  }\n  return AssertionSuccess();\n}\n\nTEST(ApiTest, TestCaseImmutableAccessorsWork) {\n  const TestCase* test_case = UnitTestHelper::FindTestCase(\"ApiTest\");\n  ASSERT_TRUE(test_case != NULL);\n\n  EXPECT_STREQ(\"ApiTest\", test_case->name());\n  EXPECT_TRUE(IsNull(test_case->type_param()));\n  EXPECT_TRUE(test_case->should_run());\n  EXPECT_EQ(1, test_case->disabled_test_count());\n  EXPECT_EQ(3, test_case->test_to_run_count());\n  ASSERT_EQ(4, test_case->total_test_count());\n\n  const TestInfo** tests = UnitTestHelper::GetSortedTests(test_case);\n\n  EXPECT_STREQ(\"DISABLED_Dummy1\", tests[0]->name());\n  EXPECT_STREQ(\"ApiTest\", tests[0]->test_case_name());\n  EXPECT_TRUE(IsNull(tests[0]->value_param()));\n  EXPECT_TRUE(IsNull(tests[0]->type_param()));\n  EXPECT_FALSE(tests[0]->should_run());\n\n  EXPECT_STREQ(\"TestCaseDisabledAccessorsWork\", tests[1]->name());\n  EXPECT_STREQ(\"ApiTest\", tests[1]->test_case_name());\n  EXPECT_TRUE(IsNull(tests[1]->value_param()));\n  EXPECT_TRUE(IsNull(tests[1]->type_param()));\n  EXPECT_TRUE(tests[1]->should_run());\n\n  EXPECT_STREQ(\"TestCaseImmutableAccessorsWork\", tests[2]->name());\n  EXPECT_STREQ(\"ApiTest\", tests[2]->test_case_name());\n  EXPECT_TRUE(IsNull(tests[2]->value_param()));\n  EXPECT_TRUE(IsNull(tests[2]->type_param()));\n  EXPECT_TRUE(tests[2]->should_run());\n\n  EXPECT_STREQ(\"UnitTestImmutableAccessorsWork\", tests[3]->name());\n  EXPECT_STREQ(\"ApiTest\", tests[3]->test_case_name());\n  EXPECT_TRUE(IsNull(tests[3]->value_param()));\n  EXPECT_TRUE(IsNull(tests[3]->type_param()));\n  EXPECT_TRUE(tests[3]->should_run());\n\n  delete[] tests;\n  tests = NULL;\n\n#if GTEST_HAS_TYPED_TEST\n  test_case = UnitTestHelper::FindTestCase(\"TestCaseWithCommentTest/0\");\n  ASSERT_TRUE(test_case != NULL);\n\n  EXPECT_STREQ(\"TestCaseWithCommentTest/0\", test_case->name());\n  EXPECT_STREQ(GetTypeName<int>().c_str(), test_case->type_param());\n  EXPECT_TRUE(test_case->should_run());\n  EXPECT_EQ(0, test_case->disabled_test_count());\n  EXPECT_EQ(1, test_case->test_to_run_count());\n  ASSERT_EQ(1, test_case->total_test_count());\n\n  tests = UnitTestHelper::GetSortedTests(test_case);\n\n  EXPECT_STREQ(\"Dummy\", tests[0]->name());\n  EXPECT_STREQ(\"TestCaseWithCommentTest/0\", tests[0]->test_case_name());\n  EXPECT_TRUE(IsNull(tests[0]->value_param()));\n  EXPECT_STREQ(GetTypeName<int>().c_str(), tests[0]->type_param());\n  EXPECT_TRUE(tests[0]->should_run());\n\n  delete[] tests;\n#endif  // GTEST_HAS_TYPED_TEST\n}\n\nTEST(ApiTest, TestCaseDisabledAccessorsWork) {\n  const TestCase* test_case = UnitTestHelper::FindTestCase(\"DISABLED_Test\");\n  ASSERT_TRUE(test_case != NULL);\n\n  EXPECT_STREQ(\"DISABLED_Test\", test_case->name());\n  EXPECT_TRUE(IsNull(test_case->type_param()));\n  EXPECT_FALSE(test_case->should_run());\n  EXPECT_EQ(1, test_case->disabled_test_count());\n  EXPECT_EQ(0, test_case->test_to_run_count());\n  ASSERT_EQ(1, test_case->total_test_count());\n\n  const TestInfo* const test_info = test_case->GetTestInfo(0);\n  EXPECT_STREQ(\"Dummy2\", test_info->name());\n  EXPECT_STREQ(\"DISABLED_Test\", test_info->test_case_name());\n  EXPECT_TRUE(IsNull(test_info->value_param()));\n  EXPECT_TRUE(IsNull(test_info->type_param()));\n  EXPECT_FALSE(test_info->should_run());\n}\n\n// These two tests are here to provide support for testing\n// test_case_to_run_count, disabled_test_count, and test_to_run_count.\nTEST(ApiTest, DISABLED_Dummy1) {}\nTEST(DISABLED_Test, Dummy2) {}\n\nclass FinalSuccessChecker : public Environment {\n protected:\n  virtual void TearDown() {\n    UnitTest* unit_test = UnitTest::GetInstance();\n\n    EXPECT_EQ(1 + kTypedTestCases, unit_test->successful_test_case_count());\n    EXPECT_EQ(3 + kTypedTests, unit_test->successful_test_count());\n    EXPECT_EQ(0, unit_test->failed_test_case_count());\n    EXPECT_EQ(0, unit_test->failed_test_count());\n    EXPECT_TRUE(unit_test->Passed());\n    EXPECT_FALSE(unit_test->Failed());\n    ASSERT_EQ(2 + kTypedTestCases, unit_test->total_test_case_count());\n\n    const TestCase** const test_cases = UnitTestHelper::GetSortedTestCases();\n\n    EXPECT_STREQ(\"ApiTest\", test_cases[0]->name());\n    EXPECT_TRUE(IsNull(test_cases[0]->type_param()));\n    EXPECT_TRUE(test_cases[0]->should_run());\n    EXPECT_EQ(1, test_cases[0]->disabled_test_count());\n    ASSERT_EQ(4, test_cases[0]->total_test_count());\n    EXPECT_EQ(3, test_cases[0]->successful_test_count());\n    EXPECT_EQ(0, test_cases[0]->failed_test_count());\n    EXPECT_TRUE(test_cases[0]->Passed());\n    EXPECT_FALSE(test_cases[0]->Failed());\n\n    EXPECT_STREQ(\"DISABLED_Test\", test_cases[1]->name());\n    EXPECT_TRUE(IsNull(test_cases[1]->type_param()));\n    EXPECT_FALSE(test_cases[1]->should_run());\n    EXPECT_EQ(1, test_cases[1]->disabled_test_count());\n    ASSERT_EQ(1, test_cases[1]->total_test_count());\n    EXPECT_EQ(0, test_cases[1]->successful_test_count());\n    EXPECT_EQ(0, test_cases[1]->failed_test_count());\n\n#if GTEST_HAS_TYPED_TEST\n    EXPECT_STREQ(\"TestCaseWithCommentTest/0\", test_cases[2]->name());\n    EXPECT_STREQ(GetTypeName<int>().c_str(), test_cases[2]->type_param());\n    EXPECT_TRUE(test_cases[2]->should_run());\n    EXPECT_EQ(0, test_cases[2]->disabled_test_count());\n    ASSERT_EQ(1, test_cases[2]->total_test_count());\n    EXPECT_EQ(1, test_cases[2]->successful_test_count());\n    EXPECT_EQ(0, test_cases[2]->failed_test_count());\n    EXPECT_TRUE(test_cases[2]->Passed());\n    EXPECT_FALSE(test_cases[2]->Failed());\n#endif  // GTEST_HAS_TYPED_TEST\n\n    const TestCase* test_case = UnitTestHelper::FindTestCase(\"ApiTest\");\n    const TestInfo** tests = UnitTestHelper::GetSortedTests(test_case);\n    EXPECT_STREQ(\"DISABLED_Dummy1\", tests[0]->name());\n    EXPECT_STREQ(\"ApiTest\", tests[0]->test_case_name());\n    EXPECT_FALSE(tests[0]->should_run());\n\n    EXPECT_STREQ(\"TestCaseDisabledAccessorsWork\", tests[1]->name());\n    EXPECT_STREQ(\"ApiTest\", tests[1]->test_case_name());\n    EXPECT_TRUE(IsNull(tests[1]->value_param()));\n    EXPECT_TRUE(IsNull(tests[1]->type_param()));\n    EXPECT_TRUE(tests[1]->should_run());\n    EXPECT_TRUE(tests[1]->result()->Passed());\n    EXPECT_EQ(0, tests[1]->result()->test_property_count());\n\n    EXPECT_STREQ(\"TestCaseImmutableAccessorsWork\", tests[2]->name());\n    EXPECT_STREQ(\"ApiTest\", tests[2]->test_case_name());\n    EXPECT_TRUE(IsNull(tests[2]->value_param()));\n    EXPECT_TRUE(IsNull(tests[2]->type_param()));\n    EXPECT_TRUE(tests[2]->should_run());\n    EXPECT_TRUE(tests[2]->result()->Passed());\n    EXPECT_EQ(0, tests[2]->result()->test_property_count());\n\n    EXPECT_STREQ(\"UnitTestImmutableAccessorsWork\", tests[3]->name());\n    EXPECT_STREQ(\"ApiTest\", tests[3]->test_case_name());\n    EXPECT_TRUE(IsNull(tests[3]->value_param()));\n    EXPECT_TRUE(IsNull(tests[3]->type_param()));\n    EXPECT_TRUE(tests[3]->should_run());\n    EXPECT_TRUE(tests[3]->result()->Passed());\n    EXPECT_EQ(1, tests[3]->result()->test_property_count());\n    const TestProperty& property = tests[3]->result()->GetTestProperty(0);\n    EXPECT_STREQ(\"key\", property.key());\n    EXPECT_STREQ(\"value\", property.value());\n\n    delete[] tests;\n\n#if GTEST_HAS_TYPED_TEST\n    test_case = UnitTestHelper::FindTestCase(\"TestCaseWithCommentTest/0\");\n    tests = UnitTestHelper::GetSortedTests(test_case);\n\n    EXPECT_STREQ(\"Dummy\", tests[0]->name());\n    EXPECT_STREQ(\"TestCaseWithCommentTest/0\", tests[0]->test_case_name());\n    EXPECT_TRUE(IsNull(tests[0]->value_param()));\n    EXPECT_STREQ(GetTypeName<int>().c_str(), tests[0]->type_param());\n    EXPECT_TRUE(tests[0]->should_run());\n    EXPECT_TRUE(tests[0]->result()->Passed());\n    EXPECT_EQ(0, tests[0]->result()->test_property_count());\n\n    delete[] tests;\n#endif  // GTEST_HAS_TYPED_TEST\n    delete[] test_cases;\n  }\n};\n\n}  // namespace internal\n}  // namespace testing\n\nint main(int argc, char **argv) {\n  InitGoogleTest(&argc, argv);\n\n  AddGlobalTestEnvironment(new testing::internal::FinalSuccessChecker());\n\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest_all_test.cc",
    "content": "// Copyright 2009, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// Tests for Google C++ Testing Framework (Google Test)\n//\n// Sometimes it's desirable to build most of Google Test's own tests\n// by compiling a single file.  This file serves this purpose.\n#include \"test/gtest-filepath_test.cc\"\n#include \"test/gtest-linked_ptr_test.cc\"\n#include \"test/gtest-message_test.cc\"\n#include \"test/gtest-options_test.cc\"\n#include \"test/gtest-port_test.cc\"\n#include \"test/gtest_pred_impl_unittest.cc\"\n#include \"test/gtest_prod_test.cc\"\n#include \"test/gtest-test-part_test.cc\"\n#include \"test/gtest-typed-test_test.cc\"\n#include \"test/gtest-typed-test2_test.cc\"\n#include \"test/gtest_unittest.cc\"\n#include \"test/production.cc\"\n"
  },
  {
    "path": "ext/gtest/test/gtest_break_on_failure_unittest.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2006, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Unit test for Google Test's break-on-failure mode.\n\nA user can ask Google Test to seg-fault when an assertion fails, using\neither the GTEST_BREAK_ON_FAILURE environment variable or the\n--gtest_break_on_failure flag.  This script tests such functionality\nby invoking gtest_break_on_failure_unittest_ (a program written with\nGoogle Test) with different environments and command line flags.\n\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport gtest_test_utils\nimport os\nimport sys\n\n\n# Constants.\n\nIS_WINDOWS = os.name == 'nt'\n\n# The environment variable for enabling/disabling the break-on-failure mode.\nBREAK_ON_FAILURE_ENV_VAR = 'GTEST_BREAK_ON_FAILURE'\n\n# The command line flag for enabling/disabling the break-on-failure mode.\nBREAK_ON_FAILURE_FLAG = 'gtest_break_on_failure'\n\n# The environment variable for enabling/disabling the throw-on-failure mode.\nTHROW_ON_FAILURE_ENV_VAR = 'GTEST_THROW_ON_FAILURE'\n\n# The environment variable for enabling/disabling the catch-exceptions mode.\nCATCH_EXCEPTIONS_ENV_VAR = 'GTEST_CATCH_EXCEPTIONS'\n\n# Path to the gtest_break_on_failure_unittest_ program.\nEXE_PATH = gtest_test_utils.GetTestExecutablePath(\n    'gtest_break_on_failure_unittest_')\n\n\nenviron = gtest_test_utils.environ\nSetEnvVar = gtest_test_utils.SetEnvVar\n\n# Tests in this file run a Google-Test-based test program and expect it\n# to terminate prematurely.  Therefore they are incompatible with\n# the premature-exit-file protocol by design.  Unset the\n# premature-exit filepath to prevent Google Test from creating\n# the file.\nSetEnvVar(gtest_test_utils.PREMATURE_EXIT_FILE_ENV_VAR, None)\n\n\ndef Run(command):\n  \"\"\"Runs a command; returns 1 if it was killed by a signal, or 0 otherwise.\"\"\"\n\n  p = gtest_test_utils.Subprocess(command, env=environ)\n  if p.terminated_by_signal:\n    return 1\n  else:\n    return 0\n\n\n# The tests.\n\n\nclass GTestBreakOnFailureUnitTest(gtest_test_utils.TestCase):\n  \"\"\"Tests using the GTEST_BREAK_ON_FAILURE environment variable or\n  the --gtest_break_on_failure flag to turn assertion failures into\n  segmentation faults.\n  \"\"\"\n\n  def RunAndVerify(self, env_var_value, flag_value, expect_seg_fault):\n    \"\"\"Runs gtest_break_on_failure_unittest_ and verifies that it does\n    (or does not) have a seg-fault.\n\n    Args:\n      env_var_value:    value of the GTEST_BREAK_ON_FAILURE environment\n                        variable; None if the variable should be unset.\n      flag_value:       value of the --gtest_break_on_failure flag;\n                        None if the flag should not be present.\n      expect_seg_fault: 1 if the program is expected to generate a seg-fault;\n                        0 otherwise.\n    \"\"\"\n\n    SetEnvVar(BREAK_ON_FAILURE_ENV_VAR, env_var_value)\n\n    if env_var_value is None:\n      env_var_value_msg = ' is not set'\n    else:\n      env_var_value_msg = '=' + env_var_value\n\n    if flag_value is None:\n      flag = ''\n    elif flag_value == '0':\n      flag = '--%s=0' % BREAK_ON_FAILURE_FLAG\n    else:\n      flag = '--%s' % BREAK_ON_FAILURE_FLAG\n\n    command = [EXE_PATH]\n    if flag:\n      command.append(flag)\n\n    if expect_seg_fault:\n      should_or_not = 'should'\n    else:\n      should_or_not = 'should not'\n\n    has_seg_fault = Run(command)\n\n    SetEnvVar(BREAK_ON_FAILURE_ENV_VAR, None)\n\n    msg = ('when %s%s, an assertion failure in \"%s\" %s cause a seg-fault.' %\n           (BREAK_ON_FAILURE_ENV_VAR, env_var_value_msg, ' '.join(command),\n            should_or_not))\n    self.assert_(has_seg_fault == expect_seg_fault, msg)\n\n  def testDefaultBehavior(self):\n    \"\"\"Tests the behavior of the default mode.\"\"\"\n\n    self.RunAndVerify(env_var_value=None,\n                      flag_value=None,\n                      expect_seg_fault=0)\n\n  def testEnvVar(self):\n    \"\"\"Tests using the GTEST_BREAK_ON_FAILURE environment variable.\"\"\"\n\n    self.RunAndVerify(env_var_value='0',\n                      flag_value=None,\n                      expect_seg_fault=0)\n    self.RunAndVerify(env_var_value='1',\n                      flag_value=None,\n                      expect_seg_fault=1)\n\n  def testFlag(self):\n    \"\"\"Tests using the --gtest_break_on_failure flag.\"\"\"\n\n    self.RunAndVerify(env_var_value=None,\n                      flag_value='0',\n                      expect_seg_fault=0)\n    self.RunAndVerify(env_var_value=None,\n                      flag_value='1',\n                      expect_seg_fault=1)\n\n  def testFlagOverridesEnvVar(self):\n    \"\"\"Tests that the flag overrides the environment variable.\"\"\"\n\n    self.RunAndVerify(env_var_value='0',\n                      flag_value='0',\n                      expect_seg_fault=0)\n    self.RunAndVerify(env_var_value='0',\n                      flag_value='1',\n                      expect_seg_fault=1)\n    self.RunAndVerify(env_var_value='1',\n                      flag_value='0',\n                      expect_seg_fault=0)\n    self.RunAndVerify(env_var_value='1',\n                      flag_value='1',\n                      expect_seg_fault=1)\n\n  def testBreakOnFailureOverridesThrowOnFailure(self):\n    \"\"\"Tests that gtest_break_on_failure overrides gtest_throw_on_failure.\"\"\"\n\n    SetEnvVar(THROW_ON_FAILURE_ENV_VAR, '1')\n    try:\n      self.RunAndVerify(env_var_value=None,\n                        flag_value='1',\n                        expect_seg_fault=1)\n    finally:\n      SetEnvVar(THROW_ON_FAILURE_ENV_VAR, None)\n\n  if IS_WINDOWS:\n    def testCatchExceptionsDoesNotInterfere(self):\n      \"\"\"Tests that gtest_catch_exceptions doesn't interfere.\"\"\"\n\n      SetEnvVar(CATCH_EXCEPTIONS_ENV_VAR, '1')\n      try:\n        self.RunAndVerify(env_var_value='1',\n                          flag_value='1',\n                          expect_seg_fault=1)\n      finally:\n        SetEnvVar(CATCH_EXCEPTIONS_ENV_VAR, None)\n\n\nif __name__ == '__main__':\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "ext/gtest/test/gtest_break_on_failure_unittest_.cc",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Unit test for Google Test's break-on-failure mode.\n//\n// A user can ask Google Test to seg-fault when an assertion fails, using\n// either the GTEST_BREAK_ON_FAILURE environment variable or the\n// --gtest_break_on_failure flag.  This file is used for testing such\n// functionality.\n//\n// This program will be invoked from a Python unit test.  It is\n// expected to fail.  Don't run it directly.\n\n#include \"gtest/gtest.h\"\n\n#if GTEST_OS_WINDOWS\n# include <windows.h>\n# include <stdlib.h>\n#endif\n\nnamespace {\n\n// A test that's expected to fail.\nTEST(Foo, Bar) {\n  EXPECT_EQ(2, 3);\n}\n\n#if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE\n// On Windows Mobile global exception handlers are not supported.\nLONG WINAPI ExitWithExceptionCode(\n    struct _EXCEPTION_POINTERS* exception_pointers) {\n  exit(exception_pointers->ExceptionRecord->ExceptionCode);\n}\n#endif\n\n}  // namespace\n\nint main(int argc, char **argv) {\n#if GTEST_OS_WINDOWS\n  // Suppresses display of the Windows error dialog upon encountering\n  // a general protection fault (segment violation).\n  SetErrorMode(SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS);\n\n# if GTEST_HAS_SEH && !GTEST_OS_WINDOWS_MOBILE\n\n  // The default unhandled exception filter does not always exit\n  // with the exception code as exit code - for example it exits with\n  // 0 for EXCEPTION_ACCESS_VIOLATION and 1 for EXCEPTION_BREAKPOINT\n  // if the application is compiled in debug mode. Thus we use our own\n  // filter which always exits with the exception code for unhandled\n  // exceptions.\n  SetUnhandledExceptionFilter(ExitWithExceptionCode);\n\n# endif\n#endif\n\n  testing::InitGoogleTest(&argc, argv);\n\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest_catch_exceptions_test.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2010 Google Inc.  All Rights Reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Tests Google Test's exception catching behavior.\n\nThis script invokes gtest_catch_exceptions_test_ and\ngtest_catch_exceptions_ex_test_ (programs written with\nGoogle Test) and verifies their output.\n\"\"\"\n\n__author__ = 'vladl@google.com (Vlad Losev)'\n\nimport os\n\nimport gtest_test_utils\n\n# Constants.\nFLAG_PREFIX = '--gtest_'\nLIST_TESTS_FLAG = FLAG_PREFIX + 'list_tests'\nNO_CATCH_EXCEPTIONS_FLAG = FLAG_PREFIX + 'catch_exceptions=0'\nFILTER_FLAG = FLAG_PREFIX + 'filter'\n\n# Path to the gtest_catch_exceptions_ex_test_ binary, compiled with\n# exceptions enabled.\nEX_EXE_PATH = gtest_test_utils.GetTestExecutablePath(\n    'gtest_catch_exceptions_ex_test_')\n\n# Path to the gtest_catch_exceptions_test_ binary, compiled with\n# exceptions disabled.\nEXE_PATH = gtest_test_utils.GetTestExecutablePath(\n    'gtest_catch_exceptions_no_ex_test_')\n\nenviron = gtest_test_utils.environ\nSetEnvVar = gtest_test_utils.SetEnvVar\n\n# Tests in this file run a Google-Test-based test program and expect it\n# to terminate prematurely.  Therefore they are incompatible with\n# the premature-exit-file protocol by design.  Unset the\n# premature-exit filepath to prevent Google Test from creating\n# the file.\nSetEnvVar(gtest_test_utils.PREMATURE_EXIT_FILE_ENV_VAR, None)\n\nTEST_LIST = gtest_test_utils.Subprocess(\n    [EXE_PATH, LIST_TESTS_FLAG], env=environ).output\n\nSUPPORTS_SEH_EXCEPTIONS = 'ThrowsSehException' in TEST_LIST\n\nif SUPPORTS_SEH_EXCEPTIONS:\n  BINARY_OUTPUT = gtest_test_utils.Subprocess([EXE_PATH], env=environ).output\n\nEX_BINARY_OUTPUT = gtest_test_utils.Subprocess(\n    [EX_EXE_PATH], env=environ).output\n\n\n# The tests.\nif SUPPORTS_SEH_EXCEPTIONS:\n  # pylint:disable-msg=C6302\n  class CatchSehExceptionsTest(gtest_test_utils.TestCase):\n    \"\"\"Tests exception-catching behavior.\"\"\"\n\n\n    def TestSehExceptions(self, test_output):\n      self.assert_('SEH exception with code 0x2a thrown '\n                   'in the test fixture\\'s constructor'\n                   in test_output)\n      self.assert_('SEH exception with code 0x2a thrown '\n                   'in the test fixture\\'s destructor'\n                   in test_output)\n      self.assert_('SEH exception with code 0x2a thrown in SetUpTestCase()'\n                   in test_output)\n      self.assert_('SEH exception with code 0x2a thrown in TearDownTestCase()'\n                   in test_output)\n      self.assert_('SEH exception with code 0x2a thrown in SetUp()'\n                   in test_output)\n      self.assert_('SEH exception with code 0x2a thrown in TearDown()'\n                   in test_output)\n      self.assert_('SEH exception with code 0x2a thrown in the test body'\n                   in test_output)\n\n    def testCatchesSehExceptionsWithCxxExceptionsEnabled(self):\n      self.TestSehExceptions(EX_BINARY_OUTPUT)\n\n    def testCatchesSehExceptionsWithCxxExceptionsDisabled(self):\n      self.TestSehExceptions(BINARY_OUTPUT)\n\n\nclass CatchCxxExceptionsTest(gtest_test_utils.TestCase):\n  \"\"\"Tests C++ exception-catching behavior.\n\n     Tests in this test case verify that:\n     * C++ exceptions are caught and logged as C++ (not SEH) exceptions\n     * Exception thrown affect the remainder of the test work flow in the\n       expected manner.\n  \"\"\"\n\n  def testCatchesCxxExceptionsInFixtureConstructor(self):\n    self.assert_('C++ exception with description '\n                 '\"Standard C++ exception\" thrown '\n                 'in the test fixture\\'s constructor'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('unexpected' not in EX_BINARY_OUTPUT,\n                 'This failure belongs in this test only if '\n                 '\"CxxExceptionInConstructorTest\" (no quotes) '\n                 'appears on the same line as words \"called unexpectedly\"')\n\n  if ('CxxExceptionInDestructorTest.ThrowsExceptionInDestructor' in\n      EX_BINARY_OUTPUT):\n\n    def testCatchesCxxExceptionsInFixtureDestructor(self):\n      self.assert_('C++ exception with description '\n                   '\"Standard C++ exception\" thrown '\n                   'in the test fixture\\'s destructor'\n                   in EX_BINARY_OUTPUT)\n      self.assert_('CxxExceptionInDestructorTest::TearDownTestCase() '\n                   'called as expected.'\n                   in EX_BINARY_OUTPUT)\n\n  def testCatchesCxxExceptionsInSetUpTestCase(self):\n    self.assert_('C++ exception with description \"Standard C++ exception\"'\n                 ' thrown in SetUpTestCase()'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInConstructorTest::TearDownTestCase() '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInSetUpTestCaseTest constructor '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInSetUpTestCaseTest destructor '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInSetUpTestCaseTest::SetUp() '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInSetUpTestCaseTest::TearDown() '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInSetUpTestCaseTest test body '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n\n  def testCatchesCxxExceptionsInTearDownTestCase(self):\n    self.assert_('C++ exception with description \"Standard C++ exception\"'\n                 ' thrown in TearDownTestCase()'\n                 in EX_BINARY_OUTPUT)\n\n  def testCatchesCxxExceptionsInSetUp(self):\n    self.assert_('C++ exception with description \"Standard C++ exception\"'\n                 ' thrown in SetUp()'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInSetUpTest::TearDownTestCase() '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInSetUpTest destructor '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInSetUpTest::TearDown() '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('unexpected' not in EX_BINARY_OUTPUT,\n                 'This failure belongs in this test only if '\n                 '\"CxxExceptionInSetUpTest\" (no quotes) '\n                 'appears on the same line as words \"called unexpectedly\"')\n\n  def testCatchesCxxExceptionsInTearDown(self):\n    self.assert_('C++ exception with description \"Standard C++ exception\"'\n                 ' thrown in TearDown()'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInTearDownTest::TearDownTestCase() '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInTearDownTest destructor '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n\n  def testCatchesCxxExceptionsInTestBody(self):\n    self.assert_('C++ exception with description \"Standard C++ exception\"'\n                 ' thrown in the test body'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInTestBodyTest::TearDownTestCase() '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInTestBodyTest destructor '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n    self.assert_('CxxExceptionInTestBodyTest::TearDown() '\n                 'called as expected.'\n                 in EX_BINARY_OUTPUT)\n\n  def testCatchesNonStdCxxExceptions(self):\n    self.assert_('Unknown C++ exception thrown in the test body'\n                 in EX_BINARY_OUTPUT)\n\n  def testUnhandledCxxExceptionsAbortTheProgram(self):\n    # Filters out SEH exception tests on Windows. Unhandled SEH exceptions\n    # cause tests to show pop-up windows there.\n    FITLER_OUT_SEH_TESTS_FLAG = FILTER_FLAG + '=-*Seh*'\n    # By default, Google Test doesn't catch the exceptions.\n    uncaught_exceptions_ex_binary_output = gtest_test_utils.Subprocess(\n        [EX_EXE_PATH,\n         NO_CATCH_EXCEPTIONS_FLAG,\n         FITLER_OUT_SEH_TESTS_FLAG],\n        env=environ).output\n\n    self.assert_('Unhandled C++ exception terminating the program'\n                 in uncaught_exceptions_ex_binary_output)\n    self.assert_('unexpected' not in uncaught_exceptions_ex_binary_output)\n\n\nif __name__ == '__main__':\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "ext/gtest/test/gtest_catch_exceptions_test_.cc",
    "content": "// Copyright 2010, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: vladl@google.com (Vlad Losev)\n//\n// Tests for Google Test itself. Tests in this file throw C++ or SEH\n// exceptions, and the output is verified by gtest_catch_exceptions_test.py.\n\n#include \"gtest/gtest.h\"\n\n#include <stdio.h>  // NOLINT\n#include <stdlib.h>  // For exit().\n\n#if GTEST_HAS_SEH\n# include <windows.h>\n#endif\n\n#if GTEST_HAS_EXCEPTIONS\n# include <exception>  // For set_terminate().\n# include <stdexcept>\n#endif\n\nusing testing::Test;\n\n#if GTEST_HAS_SEH\n\nclass SehExceptionInConstructorTest : public Test {\n public:\n  SehExceptionInConstructorTest() { RaiseException(42, 0, 0, NULL); }\n};\n\nTEST_F(SehExceptionInConstructorTest, ThrowsExceptionInConstructor) {}\n\nclass SehExceptionInDestructorTest : public Test {\n public:\n  ~SehExceptionInDestructorTest() { RaiseException(42, 0, 0, NULL); }\n};\n\nTEST_F(SehExceptionInDestructorTest, ThrowsExceptionInDestructor) {}\n\nclass SehExceptionInSetUpTestCaseTest : public Test {\n public:\n  static void SetUpTestCase() { RaiseException(42, 0, 0, NULL); }\n};\n\nTEST_F(SehExceptionInSetUpTestCaseTest, ThrowsExceptionInSetUpTestCase) {}\n\nclass SehExceptionInTearDownTestCaseTest : public Test {\n public:\n  static void TearDownTestCase() { RaiseException(42, 0, 0, NULL); }\n};\n\nTEST_F(SehExceptionInTearDownTestCaseTest, ThrowsExceptionInTearDownTestCase) {}\n\nclass SehExceptionInSetUpTest : public Test {\n protected:\n  virtual void SetUp() { RaiseException(42, 0, 0, NULL); }\n};\n\nTEST_F(SehExceptionInSetUpTest, ThrowsExceptionInSetUp) {}\n\nclass SehExceptionInTearDownTest : public Test {\n protected:\n  virtual void TearDown() { RaiseException(42, 0, 0, NULL); }\n};\n\nTEST_F(SehExceptionInTearDownTest, ThrowsExceptionInTearDown) {}\n\nTEST(SehExceptionTest, ThrowsSehException) {\n  RaiseException(42, 0, 0, NULL);\n}\n\n#endif  // GTEST_HAS_SEH\n\n#if GTEST_HAS_EXCEPTIONS\n\nclass CxxExceptionInConstructorTest : public Test {\n public:\n  CxxExceptionInConstructorTest() {\n    // Without this macro VC++ complains about unreachable code at the end of\n    // the constructor.\n    GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(\n        throw std::runtime_error(\"Standard C++ exception\"));\n  }\n\n  static void TearDownTestCase() {\n    printf(\"%s\",\n           \"CxxExceptionInConstructorTest::TearDownTestCase() \"\n           \"called as expected.\\n\");\n  }\n\n protected:\n  ~CxxExceptionInConstructorTest() {\n    ADD_FAILURE() << \"CxxExceptionInConstructorTest destructor \"\n                  << \"called unexpectedly.\";\n  }\n\n  virtual void SetUp() {\n    ADD_FAILURE() << \"CxxExceptionInConstructorTest::SetUp() \"\n                  << \"called unexpectedly.\";\n  }\n\n  virtual void TearDown() {\n    ADD_FAILURE() << \"CxxExceptionInConstructorTest::TearDown() \"\n                  << \"called unexpectedly.\";\n  }\n};\n\nTEST_F(CxxExceptionInConstructorTest, ThrowsExceptionInConstructor) {\n  ADD_FAILURE() << \"CxxExceptionInConstructorTest test body \"\n                << \"called unexpectedly.\";\n}\n\n// Exceptions in destructors are not supported in C++11.\n#if !defined(__GXX_EXPERIMENTAL_CXX0X__) &&  __cplusplus < 201103L\nclass CxxExceptionInDestructorTest : public Test {\n public:\n  static void TearDownTestCase() {\n    printf(\"%s\",\n           \"CxxExceptionInDestructorTest::TearDownTestCase() \"\n           \"called as expected.\\n\");\n  }\n\n protected:\n  ~CxxExceptionInDestructorTest() {\n    GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(\n        throw std::runtime_error(\"Standard C++ exception\"));\n  }\n};\n\nTEST_F(CxxExceptionInDestructorTest, ThrowsExceptionInDestructor) {}\n#endif  // C++11 mode\n\nclass CxxExceptionInSetUpTestCaseTest : public Test {\n public:\n  CxxExceptionInSetUpTestCaseTest() {\n    printf(\"%s\",\n           \"CxxExceptionInSetUpTestCaseTest constructor \"\n           \"called as expected.\\n\");\n  }\n\n  static void SetUpTestCase() {\n    throw std::runtime_error(\"Standard C++ exception\");\n  }\n\n  static void TearDownTestCase() {\n    printf(\"%s\",\n           \"CxxExceptionInSetUpTestCaseTest::TearDownTestCase() \"\n           \"called as expected.\\n\");\n  }\n\n protected:\n  ~CxxExceptionInSetUpTestCaseTest() {\n    printf(\"%s\",\n           \"CxxExceptionInSetUpTestCaseTest destructor \"\n           \"called as expected.\\n\");\n  }\n\n  virtual void SetUp() {\n    printf(\"%s\",\n           \"CxxExceptionInSetUpTestCaseTest::SetUp() \"\n           \"called as expected.\\n\");\n  }\n\n  virtual void TearDown() {\n    printf(\"%s\",\n           \"CxxExceptionInSetUpTestCaseTest::TearDown() \"\n           \"called as expected.\\n\");\n  }\n};\n\nTEST_F(CxxExceptionInSetUpTestCaseTest, ThrowsExceptionInSetUpTestCase) {\n  printf(\"%s\",\n         \"CxxExceptionInSetUpTestCaseTest test body \"\n         \"called as expected.\\n\");\n}\n\nclass CxxExceptionInTearDownTestCaseTest : public Test {\n public:\n  static void TearDownTestCase() {\n    throw std::runtime_error(\"Standard C++ exception\");\n  }\n};\n\nTEST_F(CxxExceptionInTearDownTestCaseTest, ThrowsExceptionInTearDownTestCase) {}\n\nclass CxxExceptionInSetUpTest : public Test {\n public:\n  static void TearDownTestCase() {\n    printf(\"%s\",\n           \"CxxExceptionInSetUpTest::TearDownTestCase() \"\n           \"called as expected.\\n\");\n  }\n\n protected:\n  ~CxxExceptionInSetUpTest() {\n    printf(\"%s\",\n           \"CxxExceptionInSetUpTest destructor \"\n           \"called as expected.\\n\");\n  }\n\n  virtual void SetUp() { throw std::runtime_error(\"Standard C++ exception\"); }\n\n  virtual void TearDown() {\n    printf(\"%s\",\n           \"CxxExceptionInSetUpTest::TearDown() \"\n           \"called as expected.\\n\");\n  }\n};\n\nTEST_F(CxxExceptionInSetUpTest, ThrowsExceptionInSetUp) {\n  ADD_FAILURE() << \"CxxExceptionInSetUpTest test body \"\n                << \"called unexpectedly.\";\n}\n\nclass CxxExceptionInTearDownTest : public Test {\n public:\n  static void TearDownTestCase() {\n    printf(\"%s\",\n           \"CxxExceptionInTearDownTest::TearDownTestCase() \"\n           \"called as expected.\\n\");\n  }\n\n protected:\n  ~CxxExceptionInTearDownTest() {\n    printf(\"%s\",\n           \"CxxExceptionInTearDownTest destructor \"\n           \"called as expected.\\n\");\n  }\n\n  virtual void TearDown() {\n    throw std::runtime_error(\"Standard C++ exception\");\n  }\n};\n\nTEST_F(CxxExceptionInTearDownTest, ThrowsExceptionInTearDown) {}\n\nclass CxxExceptionInTestBodyTest : public Test {\n public:\n  static void TearDownTestCase() {\n    printf(\"%s\",\n           \"CxxExceptionInTestBodyTest::TearDownTestCase() \"\n           \"called as expected.\\n\");\n  }\n\n protected:\n  ~CxxExceptionInTestBodyTest() {\n    printf(\"%s\",\n           \"CxxExceptionInTestBodyTest destructor \"\n           \"called as expected.\\n\");\n  }\n\n  virtual void TearDown() {\n    printf(\"%s\",\n           \"CxxExceptionInTestBodyTest::TearDown() \"\n           \"called as expected.\\n\");\n  }\n};\n\nTEST_F(CxxExceptionInTestBodyTest, ThrowsStdCxxException) {\n  throw std::runtime_error(\"Standard C++ exception\");\n}\n\nTEST(CxxExceptionTest, ThrowsNonStdCxxException) {\n  throw \"C-string\";\n}\n\n// This terminate handler aborts the program using exit() rather than abort().\n// This avoids showing pop-ups on Windows systems and core dumps on Unix-like\n// ones.\nvoid TerminateHandler() {\n  fprintf(stderr, \"%s\\n\", \"Unhandled C++ exception terminating the program.\");\n  fflush(NULL);\n  exit(3);\n}\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\nint main(int argc, char** argv) {\n#if GTEST_HAS_EXCEPTIONS\n  std::set_terminate(&TerminateHandler);\n#endif\n  testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest_color_test.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2008, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Verifies that Google Test correctly determines whether to use colors.\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport gtest_test_utils\n\n\nIS_WINDOWS = os.name = 'nt'\n\nCOLOR_ENV_VAR = 'GTEST_COLOR'\nCOLOR_FLAG = 'gtest_color'\nCOMMAND = gtest_test_utils.GetTestExecutablePath('gtest_color_test_')\n\n\ndef SetEnvVar(env_var, value):\n  \"\"\"Sets the env variable to 'value'; unsets it when 'value' is None.\"\"\"\n\n  if value is not None:\n    os.environ[env_var] = value\n  elif env_var in os.environ:\n    del os.environ[env_var]\n\n\ndef UsesColor(term, color_env_var, color_flag):\n  \"\"\"Runs gtest_color_test_ and returns its exit code.\"\"\"\n\n  SetEnvVar('TERM', term)\n  SetEnvVar(COLOR_ENV_VAR, color_env_var)\n\n  if color_flag is None:\n    args = []\n  else:\n    args = ['--%s=%s' % (COLOR_FLAG, color_flag)]\n  p = gtest_test_utils.Subprocess([COMMAND] + args)\n  return not p.exited or p.exit_code\n\n\nclass GTestColorTest(gtest_test_utils.TestCase):\n  def testNoEnvVarNoFlag(self):\n    \"\"\"Tests the case when there's neither GTEST_COLOR nor --gtest_color.\"\"\"\n\n    if not IS_WINDOWS:\n      self.assert_(not UsesColor('dumb', None, None))\n      self.assert_(not UsesColor('emacs', None, None))\n      self.assert_(not UsesColor('xterm-mono', None, None))\n      self.assert_(not UsesColor('unknown', None, None))\n      self.assert_(not UsesColor(None, None, None))\n    self.assert_(UsesColor('linux', None, None))\n    self.assert_(UsesColor('cygwin', None, None))\n    self.assert_(UsesColor('xterm', None, None))\n    self.assert_(UsesColor('xterm-color', None, None))\n    self.assert_(UsesColor('xterm-256color', None, None))\n\n  def testFlagOnly(self):\n    \"\"\"Tests the case when there's --gtest_color but not GTEST_COLOR.\"\"\"\n\n    self.assert_(not UsesColor('dumb', None, 'no'))\n    self.assert_(not UsesColor('xterm-color', None, 'no'))\n    if not IS_WINDOWS:\n      self.assert_(not UsesColor('emacs', None, 'auto'))\n    self.assert_(UsesColor('xterm', None, 'auto'))\n    self.assert_(UsesColor('dumb', None, 'yes'))\n    self.assert_(UsesColor('xterm', None, 'yes'))\n\n  def testEnvVarOnly(self):\n    \"\"\"Tests the case when there's GTEST_COLOR but not --gtest_color.\"\"\"\n\n    self.assert_(not UsesColor('dumb', 'no', None))\n    self.assert_(not UsesColor('xterm-color', 'no', None))\n    if not IS_WINDOWS:\n      self.assert_(not UsesColor('dumb', 'auto', None))\n    self.assert_(UsesColor('xterm-color', 'auto', None))\n    self.assert_(UsesColor('dumb', 'yes', None))\n    self.assert_(UsesColor('xterm-color', 'yes', None))\n\n  def testEnvVarAndFlag(self):\n    \"\"\"Tests the case when there are both GTEST_COLOR and --gtest_color.\"\"\"\n\n    self.assert_(not UsesColor('xterm-color', 'no', 'no'))\n    self.assert_(UsesColor('dumb', 'no', 'yes'))\n    self.assert_(UsesColor('xterm-color', 'no', 'auto'))\n\n  def testAliasesOfYesAndNo(self):\n    \"\"\"Tests using aliases in specifying --gtest_color.\"\"\"\n\n    self.assert_(UsesColor('dumb', None, 'true'))\n    self.assert_(UsesColor('dumb', None, 'YES'))\n    self.assert_(UsesColor('dumb', None, 'T'))\n    self.assert_(UsesColor('dumb', None, '1'))\n\n    self.assert_(not UsesColor('xterm', None, 'f'))\n    self.assert_(not UsesColor('xterm', None, 'false'))\n    self.assert_(not UsesColor('xterm', None, '0'))\n    self.assert_(not UsesColor('xterm', None, 'unknown'))\n\n\nif __name__ == '__main__':\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "ext/gtest/test/gtest_color_test_.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// A helper program for testing how Google Test determines whether to use\n// colors in the output.  It prints \"YES\" and returns 1 if Google Test\n// decides to use colors, and prints \"NO\" and returns 0 otherwise.\n\n#include <stdio.h>\n\n#include \"gtest/gtest.h\"\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick is to\n// prevent a user from accidentally including gtest-internal-inl.h in\n// his code.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\nusing testing::internal::ShouldUseColor;\n\n// The purpose of this is to ensure that the UnitTest singleton is\n// created before main() is entered, and thus that ShouldUseColor()\n// works the same way as in a real Google-Test-based test.  We don't actual\n// run the TEST itself.\nTEST(GTestColorTest, Dummy) {\n}\n\nint main(int argc, char** argv) {\n  testing::InitGoogleTest(&argc, argv);\n\n  if (ShouldUseColor(true)) {\n    // Google Test decides to use colors in the output (assuming it\n    // goes to a TTY).\n    printf(\"YES\\n\");\n    return 1;\n  } else {\n    // Google Test decides not to use colors in the output.\n    printf(\"NO\\n\");\n    return 0;\n  }\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest_env_var_test.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2008, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Verifies that Google Test correctly parses environment variables.\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport gtest_test_utils\n\n\nIS_WINDOWS = os.name == 'nt'\nIS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'\n\nCOMMAND = gtest_test_utils.GetTestExecutablePath('gtest_env_var_test_')\n\nenviron = os.environ.copy()\n\n\ndef AssertEq(expected, actual):\n  if expected != actual:\n    print 'Expected: %s' % (expected,)\n    print '  Actual: %s' % (actual,)\n    raise AssertionError\n\n\ndef SetEnvVar(env_var, value):\n  \"\"\"Sets the env variable to 'value'; unsets it when 'value' is None.\"\"\"\n\n  if value is not None:\n    environ[env_var] = value\n  elif env_var in environ:\n    del environ[env_var]\n\n\ndef GetFlag(flag):\n  \"\"\"Runs gtest_env_var_test_ and returns its output.\"\"\"\n\n  args = [COMMAND]\n  if flag is not None:\n    args += [flag]\n  return gtest_test_utils.Subprocess(args, env=environ).output\n\n\ndef TestFlag(flag, test_val, default_val):\n  \"\"\"Verifies that the given flag is affected by the corresponding env var.\"\"\"\n\n  env_var = 'GTEST_' + flag.upper()\n  SetEnvVar(env_var, test_val)\n  AssertEq(test_val, GetFlag(flag))\n  SetEnvVar(env_var, None)\n  AssertEq(default_val, GetFlag(flag))\n\n\nclass GTestEnvVarTest(gtest_test_utils.TestCase):\n  def testEnvVarAffectsFlag(self):\n    \"\"\"Tests that environment variable should affect the corresponding flag.\"\"\"\n\n    TestFlag('break_on_failure', '1', '0')\n    TestFlag('color', 'yes', 'auto')\n    TestFlag('filter', 'FooTest.Bar', '*')\n    TestFlag('output', 'xml:tmp/foo.xml', '')\n    TestFlag('print_time', '0', '1')\n    TestFlag('repeat', '999', '1')\n    TestFlag('throw_on_failure', '1', '0')\n    TestFlag('death_test_style', 'threadsafe', 'fast')\n    TestFlag('catch_exceptions', '0', '1')\n\n    if IS_LINUX:\n      TestFlag('death_test_use_fork', '1', '0')\n      TestFlag('stack_trace_depth', '0', '100')\n\n\nif __name__ == '__main__':\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "ext/gtest/test/gtest_env_var_test_.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// A helper program for testing that Google Test parses the environment\n// variables correctly.\n\n#include \"gtest/gtest.h\"\n\n#include <iostream>\n\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\nusing ::std::cout;\n\nnamespace testing {\n\n// The purpose of this is to make the test more realistic by ensuring\n// that the UnitTest singleton is created before main() is entered.\n// We don't actual run the TEST itself.\nTEST(GTestEnvVarTest, Dummy) {\n}\n\nvoid PrintFlag(const char* flag) {\n  if (strcmp(flag, \"break_on_failure\") == 0) {\n    cout << GTEST_FLAG(break_on_failure);\n    return;\n  }\n\n  if (strcmp(flag, \"catch_exceptions\") == 0) {\n    cout << GTEST_FLAG(catch_exceptions);\n    return;\n  }\n\n  if (strcmp(flag, \"color\") == 0) {\n    cout << GTEST_FLAG(color);\n    return;\n  }\n\n  if (strcmp(flag, \"death_test_style\") == 0) {\n    cout << GTEST_FLAG(death_test_style);\n    return;\n  }\n\n  if (strcmp(flag, \"death_test_use_fork\") == 0) {\n    cout << GTEST_FLAG(death_test_use_fork);\n    return;\n  }\n\n  if (strcmp(flag, \"filter\") == 0) {\n    cout << GTEST_FLAG(filter);\n    return;\n  }\n\n  if (strcmp(flag, \"output\") == 0) {\n    cout << GTEST_FLAG(output);\n    return;\n  }\n\n  if (strcmp(flag, \"print_time\") == 0) {\n    cout << GTEST_FLAG(print_time);\n    return;\n  }\n\n  if (strcmp(flag, \"repeat\") == 0) {\n    cout << GTEST_FLAG(repeat);\n    return;\n  }\n\n  if (strcmp(flag, \"stack_trace_depth\") == 0) {\n    cout << GTEST_FLAG(stack_trace_depth);\n    return;\n  }\n\n  if (strcmp(flag, \"throw_on_failure\") == 0) {\n    cout << GTEST_FLAG(throw_on_failure);\n    return;\n  }\n\n  cout << \"Invalid flag name \" << flag\n       << \".  Valid names are break_on_failure, color, filter, etc.\\n\";\n  exit(1);\n}\n\n}  // namespace testing\n\nint main(int argc, char** argv) {\n  testing::InitGoogleTest(&argc, argv);\n\n  if (argc != 2) {\n    cout << \"Usage: gtest_env_var_test_ NAME_OF_FLAG\\n\";\n    return 1;\n  }\n\n  testing::PrintFlag(argv[1]);\n  return 0;\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest_environment_test.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// Tests using global test environments.\n\n#include <stdlib.h>\n#include <stdio.h>\n#include \"gtest/gtest.h\"\n\n#define GTEST_IMPLEMENTATION_ 1  // Required for the next #include.\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\nnamespace testing {\nGTEST_DECLARE_string_(filter);\n}\n\nnamespace {\n\nenum FailureType {\n  NO_FAILURE, NON_FATAL_FAILURE, FATAL_FAILURE\n};\n\n// For testing using global test environments.\nclass MyEnvironment : public testing::Environment {\n public:\n  MyEnvironment() { Reset(); }\n\n  // Depending on the value of failure_in_set_up_, SetUp() will\n  // generate a non-fatal failure, generate a fatal failure, or\n  // succeed.\n  virtual void SetUp() {\n    set_up_was_run_ = true;\n\n    switch (failure_in_set_up_) {\n      case NON_FATAL_FAILURE:\n        ADD_FAILURE() << \"Expected non-fatal failure in global set-up.\";\n        break;\n      case FATAL_FAILURE:\n        FAIL() << \"Expected fatal failure in global set-up.\";\n        break;\n      default:\n        break;\n    }\n  }\n\n  // Generates a non-fatal failure.\n  virtual void TearDown() {\n    tear_down_was_run_ = true;\n    ADD_FAILURE() << \"Expected non-fatal failure in global tear-down.\";\n  }\n\n  // Resets the state of the environment s.t. it can be reused.\n  void Reset() {\n    failure_in_set_up_ = NO_FAILURE;\n    set_up_was_run_ = false;\n    tear_down_was_run_ = false;\n  }\n\n  // We call this function to set the type of failure SetUp() should\n  // generate.\n  void set_failure_in_set_up(FailureType type) {\n    failure_in_set_up_ = type;\n  }\n\n  // Was SetUp() run?\n  bool set_up_was_run() const { return set_up_was_run_; }\n\n  // Was TearDown() run?\n  bool tear_down_was_run() const { return tear_down_was_run_; }\n\n private:\n  FailureType failure_in_set_up_;\n  bool set_up_was_run_;\n  bool tear_down_was_run_;\n};\n\n// Was the TEST run?\nbool test_was_run;\n\n// The sole purpose of this TEST is to enable us to check whether it\n// was run.\nTEST(FooTest, Bar) {\n  test_was_run = true;\n}\n\n// Prints the message and aborts the program if condition is false.\nvoid Check(bool condition, const char* msg) {\n  if (!condition) {\n    printf(\"FAILED: %s\\n\", msg);\n    testing::internal::posix::Abort();\n  }\n}\n\n// Runs the tests.  Return true iff successful.\n//\n// The 'failure' parameter specifies the type of failure that should\n// be generated by the global set-up.\nint RunAllTests(MyEnvironment* env, FailureType failure) {\n  env->Reset();\n  env->set_failure_in_set_up(failure);\n  test_was_run = false;\n  testing::internal::GetUnitTestImpl()->ClearAdHocTestResult();\n  return RUN_ALL_TESTS();\n}\n\n}  // namespace\n\nint main(int argc, char **argv) {\n  testing::InitGoogleTest(&argc, argv);\n\n  // Registers a global test environment, and verifies that the\n  // registration function returns its argument.\n  MyEnvironment* const env = new MyEnvironment;\n  Check(testing::AddGlobalTestEnvironment(env) == env,\n        \"AddGlobalTestEnvironment() should return its argument.\");\n\n  // Verifies that RUN_ALL_TESTS() runs the tests when the global\n  // set-up is successful.\n  Check(RunAllTests(env, NO_FAILURE) != 0,\n        \"RUN_ALL_TESTS() should return non-zero, as the global tear-down \"\n        \"should generate a failure.\");\n  Check(test_was_run,\n        \"The tests should run, as the global set-up should generate no \"\n        \"failure\");\n  Check(env->tear_down_was_run(),\n        \"The global tear-down should run, as the global set-up was run.\");\n\n  // Verifies that RUN_ALL_TESTS() runs the tests when the global\n  // set-up generates no fatal failure.\n  Check(RunAllTests(env, NON_FATAL_FAILURE) != 0,\n        \"RUN_ALL_TESTS() should return non-zero, as both the global set-up \"\n        \"and the global tear-down should generate a non-fatal failure.\");\n  Check(test_was_run,\n        \"The tests should run, as the global set-up should generate no \"\n        \"fatal failure.\");\n  Check(env->tear_down_was_run(),\n        \"The global tear-down should run, as the global set-up was run.\");\n\n  // Verifies that RUN_ALL_TESTS() runs no test when the global set-up\n  // generates a fatal failure.\n  Check(RunAllTests(env, FATAL_FAILURE) != 0,\n        \"RUN_ALL_TESTS() should return non-zero, as the global set-up \"\n        \"should generate a fatal failure.\");\n  Check(!test_was_run,\n        \"The tests should not run, as the global set-up should generate \"\n        \"a fatal failure.\");\n  Check(env->tear_down_was_run(),\n        \"The global tear-down should run, as the global set-up was run.\");\n\n  // Verifies that RUN_ALL_TESTS() doesn't do global set-up or\n  // tear-down when there is no test to run.\n  testing::GTEST_FLAG(filter) = \"-*\";\n  Check(RunAllTests(env, NO_FAILURE) == 0,\n        \"RUN_ALL_TESTS() should return zero, as there is no test to run.\");\n  Check(!env->set_up_was_run(),\n        \"The global set-up should not run, as there is no test to run.\");\n  Check(!env->tear_down_was_run(),\n        \"The global tear-down should not run, \"\n        \"as the global set-up was not run.\");\n\n  printf(\"PASS\\n\");\n  return 0;\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest_filter_unittest.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2005 Google Inc. All Rights Reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Unit test for Google Test test filters.\n\nA user can specify which test(s) in a Google Test program to run via either\nthe GTEST_FILTER environment variable or the --gtest_filter flag.\nThis script tests such functionality by invoking\ngtest_filter_unittest_ (a program written with Google Test) with different\nenvironments and command line flags.\n\nNote that test sharding may also influence which tests are filtered. Therefore,\nwe test that here also.\n\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport re\nimport sets\nimport sys\n\nimport gtest_test_utils\n\n# Constants.\n\n# Checks if this platform can pass empty environment variables to child\n# processes.  We set an env variable to an empty string and invoke a python\n# script in a subprocess to print whether the variable is STILL in\n# os.environ.  We then use 'eval' to parse the child's output so that an\n# exception is thrown if the input is anything other than 'True' nor 'False'.\nos.environ['EMPTY_VAR'] = ''\nchild = gtest_test_utils.Subprocess(\n    [sys.executable, '-c', 'import os; print \\'EMPTY_VAR\\' in os.environ'])\nCAN_PASS_EMPTY_ENV = eval(child.output)\n\n\n# Check if this platform can unset environment variables in child processes.\n# We set an env variable to a non-empty string, unset it, and invoke\n# a python script in a subprocess to print whether the variable\n# is NO LONGER in os.environ.\n# We use 'eval' to parse the child's output so that an exception\n# is thrown if the input is neither 'True' nor 'False'.\nos.environ['UNSET_VAR'] = 'X'\ndel os.environ['UNSET_VAR']\nchild = gtest_test_utils.Subprocess(\n    [sys.executable, '-c', 'import os; print \\'UNSET_VAR\\' not in os.environ'])\nCAN_UNSET_ENV = eval(child.output)\n\n\n# Checks if we should test with an empty filter. This doesn't\n# make sense on platforms that cannot pass empty env variables (Win32)\n# and on platforms that cannot unset variables (since we cannot tell\n# the difference between \"\" and NULL -- Borland and Solaris < 5.10)\nCAN_TEST_EMPTY_FILTER = (CAN_PASS_EMPTY_ENV and CAN_UNSET_ENV)\n\n\n# The environment variable for specifying the test filters.\nFILTER_ENV_VAR = 'GTEST_FILTER'\n\n# The environment variables for test sharding.\nTOTAL_SHARDS_ENV_VAR = 'GTEST_TOTAL_SHARDS'\nSHARD_INDEX_ENV_VAR = 'GTEST_SHARD_INDEX'\nSHARD_STATUS_FILE_ENV_VAR = 'GTEST_SHARD_STATUS_FILE'\n\n# The command line flag for specifying the test filters.\nFILTER_FLAG = 'gtest_filter'\n\n# The command line flag for including disabled tests.\nALSO_RUN_DISABED_TESTS_FLAG = 'gtest_also_run_disabled_tests'\n\n# Command to run the gtest_filter_unittest_ program.\nCOMMAND = gtest_test_utils.GetTestExecutablePath('gtest_filter_unittest_')\n\n# Regex for determining whether parameterized tests are enabled in the binary.\nPARAM_TEST_REGEX = re.compile(r'/ParamTest')\n\n# Regex for parsing test case names from Google Test's output.\nTEST_CASE_REGEX = re.compile(r'^\\[\\-+\\] \\d+ tests? from (\\w+(/\\w+)?)')\n\n# Regex for parsing test names from Google Test's output.\nTEST_REGEX = re.compile(r'^\\[\\s*RUN\\s*\\].*\\.(\\w+(/\\w+)?)')\n\n# The command line flag to tell Google Test to output the list of tests it\n# will run.\nLIST_TESTS_FLAG = '--gtest_list_tests'\n\n# Indicates whether Google Test supports death tests.\nSUPPORTS_DEATH_TESTS = 'HasDeathTest' in gtest_test_utils.Subprocess(\n    [COMMAND, LIST_TESTS_FLAG]).output\n\n# Full names of all tests in gtest_filter_unittests_.\nPARAM_TESTS = [\n    'SeqP/ParamTest.TestX/0',\n    'SeqP/ParamTest.TestX/1',\n    'SeqP/ParamTest.TestY/0',\n    'SeqP/ParamTest.TestY/1',\n    'SeqQ/ParamTest.TestX/0',\n    'SeqQ/ParamTest.TestX/1',\n    'SeqQ/ParamTest.TestY/0',\n    'SeqQ/ParamTest.TestY/1',\n    ]\n\nDISABLED_TESTS = [\n    'BarTest.DISABLED_TestFour',\n    'BarTest.DISABLED_TestFive',\n    'BazTest.DISABLED_TestC',\n    'DISABLED_FoobarTest.Test1',\n    'DISABLED_FoobarTest.DISABLED_Test2',\n    'DISABLED_FoobarbazTest.TestA',\n    ]\n\nif SUPPORTS_DEATH_TESTS:\n  DEATH_TESTS = [\n    'HasDeathTest.Test1',\n    'HasDeathTest.Test2',\n    ]\nelse:\n  DEATH_TESTS = []\n\n# All the non-disabled tests.\nACTIVE_TESTS = [\n    'FooTest.Abc',\n    'FooTest.Xyz',\n\n    'BarTest.TestOne',\n    'BarTest.TestTwo',\n    'BarTest.TestThree',\n\n    'BazTest.TestOne',\n    'BazTest.TestA',\n    'BazTest.TestB',\n    ] + DEATH_TESTS + PARAM_TESTS\n\nparam_tests_present = None\n\n# Utilities.\n\nenviron = os.environ.copy()\n\n\ndef SetEnvVar(env_var, value):\n  \"\"\"Sets the env variable to 'value'; unsets it when 'value' is None.\"\"\"\n\n  if value is not None:\n    environ[env_var] = value\n  elif env_var in environ:\n    del environ[env_var]\n\n\ndef RunAndReturnOutput(args = None):\n  \"\"\"Runs the test program and returns its output.\"\"\"\n\n  return gtest_test_utils.Subprocess([COMMAND] + (args or []),\n                                     env=environ).output\n\n\ndef RunAndExtractTestList(args = None):\n  \"\"\"Runs the test program and returns its exit code and a list of tests run.\"\"\"\n\n  p = gtest_test_utils.Subprocess([COMMAND] + (args or []), env=environ)\n  tests_run = []\n  test_case = ''\n  test = ''\n  for line in p.output.split('\\n'):\n    match = TEST_CASE_REGEX.match(line)\n    if match is not None:\n      test_case = match.group(1)\n    else:\n      match = TEST_REGEX.match(line)\n      if match is not None:\n        test = match.group(1)\n        tests_run.append(test_case + '.' + test)\n  return (tests_run, p.exit_code)\n\n\ndef InvokeWithModifiedEnv(extra_env, function, *args, **kwargs):\n  \"\"\"Runs the given function and arguments in a modified environment.\"\"\"\n  try:\n    original_env = environ.copy()\n    environ.update(extra_env)\n    return function(*args, **kwargs)\n  finally:\n    environ.clear()\n    environ.update(original_env)\n\n\ndef RunWithSharding(total_shards, shard_index, command):\n  \"\"\"Runs a test program shard and returns exit code and a list of tests run.\"\"\"\n\n  extra_env = {SHARD_INDEX_ENV_VAR: str(shard_index),\n               TOTAL_SHARDS_ENV_VAR: str(total_shards)}\n  return InvokeWithModifiedEnv(extra_env, RunAndExtractTestList, command)\n\n# The unit test.\n\n\nclass GTestFilterUnitTest(gtest_test_utils.TestCase):\n  \"\"\"Tests the env variable or the command line flag to filter tests.\"\"\"\n\n  # Utilities.\n\n  def AssertSetEqual(self, lhs, rhs):\n    \"\"\"Asserts that two sets are equal.\"\"\"\n\n    for elem in lhs:\n      self.assert_(elem in rhs, '%s in %s' % (elem, rhs))\n\n    for elem in rhs:\n      self.assert_(elem in lhs, '%s in %s' % (elem, lhs))\n\n  def AssertPartitionIsValid(self, set_var, list_of_sets):\n    \"\"\"Asserts that list_of_sets is a valid partition of set_var.\"\"\"\n\n    full_partition = []\n    for slice_var in list_of_sets:\n      full_partition.extend(slice_var)\n    self.assertEqual(len(set_var), len(full_partition))\n    self.assertEqual(sets.Set(set_var), sets.Set(full_partition))\n\n  def AdjustForParameterizedTests(self, tests_to_run):\n    \"\"\"Adjust tests_to_run in case value parameterized tests are disabled.\"\"\"\n\n    global param_tests_present\n    if not param_tests_present:\n      return list(sets.Set(tests_to_run) - sets.Set(PARAM_TESTS))\n    else:\n      return tests_to_run\n\n  def RunAndVerify(self, gtest_filter, tests_to_run):\n    \"\"\"Checks that the binary runs correct set of tests for a given filter.\"\"\"\n\n    tests_to_run = self.AdjustForParameterizedTests(tests_to_run)\n\n    # First, tests using the environment variable.\n\n    # Windows removes empty variables from the environment when passing it\n    # to a new process.  This means it is impossible to pass an empty filter\n    # into a process using the environment variable.  However, we can still\n    # test the case when the variable is not supplied (i.e., gtest_filter is\n    # None).\n    # pylint: disable-msg=C6403\n    if CAN_TEST_EMPTY_FILTER or gtest_filter != '':\n      SetEnvVar(FILTER_ENV_VAR, gtest_filter)\n      tests_run = RunAndExtractTestList()[0]\n      SetEnvVar(FILTER_ENV_VAR, None)\n      self.AssertSetEqual(tests_run, tests_to_run)\n    # pylint: enable-msg=C6403\n\n    # Next, tests using the command line flag.\n\n    if gtest_filter is None:\n      args = []\n    else:\n      args = ['--%s=%s' % (FILTER_FLAG, gtest_filter)]\n\n    tests_run = RunAndExtractTestList(args)[0]\n    self.AssertSetEqual(tests_run, tests_to_run)\n\n  def RunAndVerifyWithSharding(self, gtest_filter, total_shards, tests_to_run,\n                               args=None, check_exit_0=False):\n    \"\"\"Checks that binary runs correct tests for the given filter and shard.\n\n    Runs all shards of gtest_filter_unittest_ with the given filter, and\n    verifies that the right set of tests were run. The union of tests run\n    on each shard should be identical to tests_to_run, without duplicates.\n\n    Args:\n      gtest_filter: A filter to apply to the tests.\n      total_shards: A total number of shards to split test run into.\n      tests_to_run: A set of tests expected to run.\n      args   :      Arguments to pass to the to the test binary.\n      check_exit_0: When set to a true value, make sure that all shards\n                    return 0.\n    \"\"\"\n\n    tests_to_run = self.AdjustForParameterizedTests(tests_to_run)\n\n    # Windows removes empty variables from the environment when passing it\n    # to a new process.  This means it is impossible to pass an empty filter\n    # into a process using the environment variable.  However, we can still\n    # test the case when the variable is not supplied (i.e., gtest_filter is\n    # None).\n    # pylint: disable-msg=C6403\n    if CAN_TEST_EMPTY_FILTER or gtest_filter != '':\n      SetEnvVar(FILTER_ENV_VAR, gtest_filter)\n      partition = []\n      for i in range(0, total_shards):\n        (tests_run, exit_code) = RunWithSharding(total_shards, i, args)\n        if check_exit_0:\n          self.assertEqual(0, exit_code)\n        partition.append(tests_run)\n\n      self.AssertPartitionIsValid(tests_to_run, partition)\n      SetEnvVar(FILTER_ENV_VAR, None)\n    # pylint: enable-msg=C6403\n\n  def RunAndVerifyAllowingDisabled(self, gtest_filter, tests_to_run):\n    \"\"\"Checks that the binary runs correct set of tests for the given filter.\n\n    Runs gtest_filter_unittest_ with the given filter, and enables\n    disabled tests. Verifies that the right set of tests were run.\n\n    Args:\n      gtest_filter: A filter to apply to the tests.\n      tests_to_run: A set of tests expected to run.\n    \"\"\"\n\n    tests_to_run = self.AdjustForParameterizedTests(tests_to_run)\n\n    # Construct the command line.\n    args = ['--%s' % ALSO_RUN_DISABED_TESTS_FLAG]\n    if gtest_filter is not None:\n      args.append('--%s=%s' % (FILTER_FLAG, gtest_filter))\n\n    tests_run = RunAndExtractTestList(args)[0]\n    self.AssertSetEqual(tests_run, tests_to_run)\n\n  def setUp(self):\n    \"\"\"Sets up test case.\n\n    Determines whether value-parameterized tests are enabled in the binary and\n    sets the flags accordingly.\n    \"\"\"\n\n    global param_tests_present\n    if param_tests_present is None:\n      param_tests_present = PARAM_TEST_REGEX.search(\n          RunAndReturnOutput()) is not None\n\n  def testDefaultBehavior(self):\n    \"\"\"Tests the behavior of not specifying the filter.\"\"\"\n\n    self.RunAndVerify(None, ACTIVE_TESTS)\n\n  def testDefaultBehaviorWithShards(self):\n    \"\"\"Tests the behavior without the filter, with sharding enabled.\"\"\"\n\n    self.RunAndVerifyWithSharding(None, 1, ACTIVE_TESTS)\n    self.RunAndVerifyWithSharding(None, 2, ACTIVE_TESTS)\n    self.RunAndVerifyWithSharding(None, len(ACTIVE_TESTS) - 1, ACTIVE_TESTS)\n    self.RunAndVerifyWithSharding(None, len(ACTIVE_TESTS), ACTIVE_TESTS)\n    self.RunAndVerifyWithSharding(None, len(ACTIVE_TESTS) + 1, ACTIVE_TESTS)\n\n  def testEmptyFilter(self):\n    \"\"\"Tests an empty filter.\"\"\"\n\n    self.RunAndVerify('', [])\n    self.RunAndVerifyWithSharding('', 1, [])\n    self.RunAndVerifyWithSharding('', 2, [])\n\n  def testBadFilter(self):\n    \"\"\"Tests a filter that matches nothing.\"\"\"\n\n    self.RunAndVerify('BadFilter', [])\n    self.RunAndVerifyAllowingDisabled('BadFilter', [])\n\n  def testFullName(self):\n    \"\"\"Tests filtering by full name.\"\"\"\n\n    self.RunAndVerify('FooTest.Xyz', ['FooTest.Xyz'])\n    self.RunAndVerifyAllowingDisabled('FooTest.Xyz', ['FooTest.Xyz'])\n    self.RunAndVerifyWithSharding('FooTest.Xyz', 5, ['FooTest.Xyz'])\n\n  def testUniversalFilters(self):\n    \"\"\"Tests filters that match everything.\"\"\"\n\n    self.RunAndVerify('*', ACTIVE_TESTS)\n    self.RunAndVerify('*.*', ACTIVE_TESTS)\n    self.RunAndVerifyWithSharding('*.*', len(ACTIVE_TESTS) - 3, ACTIVE_TESTS)\n    self.RunAndVerifyAllowingDisabled('*', ACTIVE_TESTS + DISABLED_TESTS)\n    self.RunAndVerifyAllowingDisabled('*.*', ACTIVE_TESTS + DISABLED_TESTS)\n\n  def testFilterByTestCase(self):\n    \"\"\"Tests filtering by test case name.\"\"\"\n\n    self.RunAndVerify('FooTest.*', ['FooTest.Abc', 'FooTest.Xyz'])\n\n    BAZ_TESTS = ['BazTest.TestOne', 'BazTest.TestA', 'BazTest.TestB']\n    self.RunAndVerify('BazTest.*', BAZ_TESTS)\n    self.RunAndVerifyAllowingDisabled('BazTest.*',\n                                      BAZ_TESTS + ['BazTest.DISABLED_TestC'])\n\n  def testFilterByTest(self):\n    \"\"\"Tests filtering by test name.\"\"\"\n\n    self.RunAndVerify('*.TestOne', ['BarTest.TestOne', 'BazTest.TestOne'])\n\n  def testFilterDisabledTests(self):\n    \"\"\"Select only the disabled tests to run.\"\"\"\n\n    self.RunAndVerify('DISABLED_FoobarTest.Test1', [])\n    self.RunAndVerifyAllowingDisabled('DISABLED_FoobarTest.Test1',\n                                      ['DISABLED_FoobarTest.Test1'])\n\n    self.RunAndVerify('*DISABLED_*', [])\n    self.RunAndVerifyAllowingDisabled('*DISABLED_*', DISABLED_TESTS)\n\n    self.RunAndVerify('*.DISABLED_*', [])\n    self.RunAndVerifyAllowingDisabled('*.DISABLED_*', [\n        'BarTest.DISABLED_TestFour',\n        'BarTest.DISABLED_TestFive',\n        'BazTest.DISABLED_TestC',\n        'DISABLED_FoobarTest.DISABLED_Test2',\n        ])\n\n    self.RunAndVerify('DISABLED_*', [])\n    self.RunAndVerifyAllowingDisabled('DISABLED_*', [\n        'DISABLED_FoobarTest.Test1',\n        'DISABLED_FoobarTest.DISABLED_Test2',\n        'DISABLED_FoobarbazTest.TestA',\n        ])\n\n  def testWildcardInTestCaseName(self):\n    \"\"\"Tests using wildcard in the test case name.\"\"\"\n\n    self.RunAndVerify('*a*.*', [\n        'BarTest.TestOne',\n        'BarTest.TestTwo',\n        'BarTest.TestThree',\n\n        'BazTest.TestOne',\n        'BazTest.TestA',\n        'BazTest.TestB', ] + DEATH_TESTS + PARAM_TESTS)\n\n  def testWildcardInTestName(self):\n    \"\"\"Tests using wildcard in the test name.\"\"\"\n\n    self.RunAndVerify('*.*A*', ['FooTest.Abc', 'BazTest.TestA'])\n\n  def testFilterWithoutDot(self):\n    \"\"\"Tests a filter that has no '.' in it.\"\"\"\n\n    self.RunAndVerify('*z*', [\n        'FooTest.Xyz',\n\n        'BazTest.TestOne',\n        'BazTest.TestA',\n        'BazTest.TestB',\n        ])\n\n  def testTwoPatterns(self):\n    \"\"\"Tests filters that consist of two patterns.\"\"\"\n\n    self.RunAndVerify('Foo*.*:*A*', [\n        'FooTest.Abc',\n        'FooTest.Xyz',\n\n        'BazTest.TestA',\n        ])\n\n    # An empty pattern + a non-empty one\n    self.RunAndVerify(':*A*', ['FooTest.Abc', 'BazTest.TestA'])\n\n  def testThreePatterns(self):\n    \"\"\"Tests filters that consist of three patterns.\"\"\"\n\n    self.RunAndVerify('*oo*:*A*:*One', [\n        'FooTest.Abc',\n        'FooTest.Xyz',\n\n        'BarTest.TestOne',\n\n        'BazTest.TestOne',\n        'BazTest.TestA',\n        ])\n\n    # The 2nd pattern is empty.\n    self.RunAndVerify('*oo*::*One', [\n        'FooTest.Abc',\n        'FooTest.Xyz',\n\n        'BarTest.TestOne',\n\n        'BazTest.TestOne',\n        ])\n\n    # The last 2 patterns are empty.\n    self.RunAndVerify('*oo*::', [\n        'FooTest.Abc',\n        'FooTest.Xyz',\n        ])\n\n  def testNegativeFilters(self):\n    self.RunAndVerify('*-BazTest.TestOne', [\n        'FooTest.Abc',\n        'FooTest.Xyz',\n\n        'BarTest.TestOne',\n        'BarTest.TestTwo',\n        'BarTest.TestThree',\n\n        'BazTest.TestA',\n        'BazTest.TestB',\n        ] + DEATH_TESTS + PARAM_TESTS)\n\n    self.RunAndVerify('*-FooTest.Abc:BazTest.*', [\n        'FooTest.Xyz',\n\n        'BarTest.TestOne',\n        'BarTest.TestTwo',\n        'BarTest.TestThree',\n        ] + DEATH_TESTS + PARAM_TESTS)\n\n    self.RunAndVerify('BarTest.*-BarTest.TestOne', [\n        'BarTest.TestTwo',\n        'BarTest.TestThree',\n        ])\n\n    # Tests without leading '*'.\n    self.RunAndVerify('-FooTest.Abc:FooTest.Xyz:BazTest.*', [\n        'BarTest.TestOne',\n        'BarTest.TestTwo',\n        'BarTest.TestThree',\n        ] + DEATH_TESTS + PARAM_TESTS)\n\n    # Value parameterized tests.\n    self.RunAndVerify('*/*', PARAM_TESTS)\n\n    # Value parameterized tests filtering by the sequence name.\n    self.RunAndVerify('SeqP/*', [\n        'SeqP/ParamTest.TestX/0',\n        'SeqP/ParamTest.TestX/1',\n        'SeqP/ParamTest.TestY/0',\n        'SeqP/ParamTest.TestY/1',\n        ])\n\n    # Value parameterized tests filtering by the test name.\n    self.RunAndVerify('*/0', [\n        'SeqP/ParamTest.TestX/0',\n        'SeqP/ParamTest.TestY/0',\n        'SeqQ/ParamTest.TestX/0',\n        'SeqQ/ParamTest.TestY/0',\n        ])\n\n  def testFlagOverridesEnvVar(self):\n    \"\"\"Tests that the filter flag overrides the filtering env. variable.\"\"\"\n\n    SetEnvVar(FILTER_ENV_VAR, 'Foo*')\n    args = ['--%s=%s' % (FILTER_FLAG, '*One')]\n    tests_run = RunAndExtractTestList(args)[0]\n    SetEnvVar(FILTER_ENV_VAR, None)\n\n    self.AssertSetEqual(tests_run, ['BarTest.TestOne', 'BazTest.TestOne'])\n\n  def testShardStatusFileIsCreated(self):\n    \"\"\"Tests that the shard file is created if specified in the environment.\"\"\"\n\n    shard_status_file = os.path.join(gtest_test_utils.GetTempDir(),\n                                     'shard_status_file')\n    self.assert_(not os.path.exists(shard_status_file))\n\n    extra_env = {SHARD_STATUS_FILE_ENV_VAR: shard_status_file}\n    try:\n      InvokeWithModifiedEnv(extra_env, RunAndReturnOutput)\n    finally:\n      self.assert_(os.path.exists(shard_status_file))\n      os.remove(shard_status_file)\n\n  def testShardStatusFileIsCreatedWithListTests(self):\n    \"\"\"Tests that the shard file is created with the \"list_tests\" flag.\"\"\"\n\n    shard_status_file = os.path.join(gtest_test_utils.GetTempDir(),\n                                     'shard_status_file2')\n    self.assert_(not os.path.exists(shard_status_file))\n\n    extra_env = {SHARD_STATUS_FILE_ENV_VAR: shard_status_file}\n    try:\n      output = InvokeWithModifiedEnv(extra_env,\n                                     RunAndReturnOutput,\n                                     [LIST_TESTS_FLAG])\n    finally:\n      # This assertion ensures that Google Test enumerated the tests as\n      # opposed to running them.\n      self.assert_('[==========]' not in output,\n                   'Unexpected output during test enumeration.\\n'\n                   'Please ensure that LIST_TESTS_FLAG is assigned the\\n'\n                   'correct flag value for listing Google Test tests.')\n\n      self.assert_(os.path.exists(shard_status_file))\n      os.remove(shard_status_file)\n\n  if SUPPORTS_DEATH_TESTS:\n    def testShardingWorksWithDeathTests(self):\n      \"\"\"Tests integration with death tests and sharding.\"\"\"\n\n      gtest_filter = 'HasDeathTest.*:SeqP/*'\n      expected_tests = [\n          'HasDeathTest.Test1',\n          'HasDeathTest.Test2',\n\n          'SeqP/ParamTest.TestX/0',\n          'SeqP/ParamTest.TestX/1',\n          'SeqP/ParamTest.TestY/0',\n          'SeqP/ParamTest.TestY/1',\n          ]\n\n      for flag in ['--gtest_death_test_style=threadsafe',\n                   '--gtest_death_test_style=fast']:\n        self.RunAndVerifyWithSharding(gtest_filter, 3, expected_tests,\n                                      check_exit_0=True, args=[flag])\n        self.RunAndVerifyWithSharding(gtest_filter, 5, expected_tests,\n                                      check_exit_0=True, args=[flag])\n\nif __name__ == '__main__':\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "ext/gtest/test/gtest_filter_unittest_.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Unit test for Google Test test filters.\n//\n// A user can specify which test(s) in a Google Test program to run via\n// either the GTEST_FILTER environment variable or the --gtest_filter\n// flag.  This is used for testing such functionality.\n//\n// The program will be invoked from a Python unit test.  Don't run it\n// directly.\n\n#include \"gtest/gtest.h\"\n\nnamespace {\n\n// Test case FooTest.\n\nclass FooTest : public testing::Test {\n};\n\nTEST_F(FooTest, Abc) {\n}\n\nTEST_F(FooTest, Xyz) {\n  FAIL() << \"Expected failure.\";\n}\n\n// Test case BarTest.\n\nTEST(BarTest, TestOne) {\n}\n\nTEST(BarTest, TestTwo) {\n}\n\nTEST(BarTest, TestThree) {\n}\n\nTEST(BarTest, DISABLED_TestFour) {\n  FAIL() << \"Expected failure.\";\n}\n\nTEST(BarTest, DISABLED_TestFive) {\n  FAIL() << \"Expected failure.\";\n}\n\n// Test case BazTest.\n\nTEST(BazTest, TestOne) {\n  FAIL() << \"Expected failure.\";\n}\n\nTEST(BazTest, TestA) {\n}\n\nTEST(BazTest, TestB) {\n}\n\nTEST(BazTest, DISABLED_TestC) {\n  FAIL() << \"Expected failure.\";\n}\n\n// Test case HasDeathTest\n\nTEST(HasDeathTest, Test1) {\n  EXPECT_DEATH_IF_SUPPORTED(exit(1), \".*\");\n}\n\n// We need at least two death tests to make sure that the all death tests\n// aren't on the first shard.\nTEST(HasDeathTest, Test2) {\n  EXPECT_DEATH_IF_SUPPORTED(exit(1), \".*\");\n}\n\n// Test case FoobarTest\n\nTEST(DISABLED_FoobarTest, Test1) {\n  FAIL() << \"Expected failure.\";\n}\n\nTEST(DISABLED_FoobarTest, DISABLED_Test2) {\n  FAIL() << \"Expected failure.\";\n}\n\n// Test case FoobarbazTest\n\nTEST(DISABLED_FoobarbazTest, TestA) {\n  FAIL() << \"Expected failure.\";\n}\n\n#if GTEST_HAS_PARAM_TEST\nclass ParamTest : public testing::TestWithParam<int> {\n};\n\nTEST_P(ParamTest, TestX) {\n}\n\nTEST_P(ParamTest, TestY) {\n}\n\nINSTANTIATE_TEST_CASE_P(SeqP, ParamTest, testing::Values(1, 2));\nINSTANTIATE_TEST_CASE_P(SeqQ, ParamTest, testing::Values(5, 6));\n#endif  // GTEST_HAS_PARAM_TEST\n\n}  // namespace\n\nint main(int argc, char **argv) {\n  ::testing::InitGoogleTest(&argc, argv);\n\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest_help_test.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2009, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Tests the --help flag of Google C++ Testing Framework.\n\nSYNOPSIS\n       gtest_help_test.py --build_dir=BUILD/DIR\n         # where BUILD/DIR contains the built gtest_help_test_ file.\n       gtest_help_test.py\n\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport re\nimport gtest_test_utils\n\n\nIS_LINUX = os.name == 'posix' and os.uname()[0] == 'Linux'\nIS_WINDOWS = os.name == 'nt'\n\nPROGRAM_PATH = gtest_test_utils.GetTestExecutablePath('gtest_help_test_')\nFLAG_PREFIX = '--gtest_'\nDEATH_TEST_STYLE_FLAG = FLAG_PREFIX + 'death_test_style'\nSTREAM_RESULT_TO_FLAG = FLAG_PREFIX + 'stream_result_to'\nUNKNOWN_FLAG = FLAG_PREFIX + 'unknown_flag_for_testing'\nLIST_TESTS_FLAG = FLAG_PREFIX + 'list_tests'\nINCORRECT_FLAG_VARIANTS = [re.sub('^--', '-', LIST_TESTS_FLAG),\n                           re.sub('^--', '/', LIST_TESTS_FLAG),\n                           re.sub('_', '-', LIST_TESTS_FLAG)]\nINTERNAL_FLAG_FOR_TESTING = FLAG_PREFIX + 'internal_flag_for_testing'\n\nSUPPORTS_DEATH_TESTS = \"DeathTest\" in gtest_test_utils.Subprocess(\n    [PROGRAM_PATH, LIST_TESTS_FLAG]).output\n\n# The help message must match this regex.\nHELP_REGEX = re.compile(\n    FLAG_PREFIX + r'list_tests.*' +\n    FLAG_PREFIX + r'filter=.*' +\n    FLAG_PREFIX + r'also_run_disabled_tests.*' +\n    FLAG_PREFIX + r'repeat=.*' +\n    FLAG_PREFIX + r'shuffle.*' +\n    FLAG_PREFIX + r'random_seed=.*' +\n    FLAG_PREFIX + r'color=.*' +\n    FLAG_PREFIX + r'print_time.*' +\n    FLAG_PREFIX + r'output=.*' +\n    FLAG_PREFIX + r'break_on_failure.*' +\n    FLAG_PREFIX + r'throw_on_failure.*' +\n    FLAG_PREFIX + r'catch_exceptions=0.*',\n    re.DOTALL)\n\n\ndef RunWithFlag(flag):\n  \"\"\"Runs gtest_help_test_ with the given flag.\n\n  Returns:\n    the exit code and the text output as a tuple.\n  Args:\n    flag: the command-line flag to pass to gtest_help_test_, or None.\n  \"\"\"\n\n  if flag is None:\n    command = [PROGRAM_PATH]\n  else:\n    command = [PROGRAM_PATH, flag]\n  child = gtest_test_utils.Subprocess(command)\n  return child.exit_code, child.output\n\n\nclass GTestHelpTest(gtest_test_utils.TestCase):\n  \"\"\"Tests the --help flag and its equivalent forms.\"\"\"\n\n  def TestHelpFlag(self, flag):\n    \"\"\"Verifies correct behavior when help flag is specified.\n\n    The right message must be printed and the tests must\n    skipped when the given flag is specified.\n\n    Args:\n      flag:  A flag to pass to the binary or None.\n    \"\"\"\n\n    exit_code, output = RunWithFlag(flag)\n    self.assertEquals(0, exit_code)\n    self.assert_(HELP_REGEX.search(output), output)\n\n    if IS_LINUX:\n      self.assert_(STREAM_RESULT_TO_FLAG in output, output)\n    else:\n      self.assert_(STREAM_RESULT_TO_FLAG not in output, output)\n\n    if SUPPORTS_DEATH_TESTS and not IS_WINDOWS:\n      self.assert_(DEATH_TEST_STYLE_FLAG in output, output)\n    else:\n      self.assert_(DEATH_TEST_STYLE_FLAG not in output, output)\n\n  def TestNonHelpFlag(self, flag):\n    \"\"\"Verifies correct behavior when no help flag is specified.\n\n    Verifies that when no help flag is specified, the tests are run\n    and the help message is not printed.\n\n    Args:\n      flag:  A flag to pass to the binary or None.\n    \"\"\"\n\n    exit_code, output = RunWithFlag(flag)\n    self.assert_(exit_code != 0)\n    self.assert_(not HELP_REGEX.search(output), output)\n\n  def testPrintsHelpWithFullFlag(self):\n    self.TestHelpFlag('--help')\n\n  def testPrintsHelpWithShortFlag(self):\n    self.TestHelpFlag('-h')\n\n  def testPrintsHelpWithQuestionFlag(self):\n    self.TestHelpFlag('-?')\n\n  def testPrintsHelpWithWindowsStyleQuestionFlag(self):\n    self.TestHelpFlag('/?')\n\n  def testPrintsHelpWithUnrecognizedGoogleTestFlag(self):\n    self.TestHelpFlag(UNKNOWN_FLAG)\n\n  def testPrintsHelpWithIncorrectFlagStyle(self):\n    for incorrect_flag in INCORRECT_FLAG_VARIANTS:\n      self.TestHelpFlag(incorrect_flag)\n\n  def testRunsTestsWithoutHelpFlag(self):\n    \"\"\"Verifies that when no help flag is specified, the tests are run\n    and the help message is not printed.\"\"\"\n\n    self.TestNonHelpFlag(None)\n\n  def testRunsTestsWithGtestInternalFlag(self):\n    \"\"\"Verifies that the tests are run and no help message is printed when\n    a flag starting with Google Test prefix and 'internal_' is supplied.\"\"\"\n\n    self.TestNonHelpFlag(INTERNAL_FLAG_FOR_TESTING)\n\n\nif __name__ == '__main__':\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "ext/gtest/test/gtest_help_test_.cc",
    "content": "// Copyright 2009, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// This program is meant to be run by gtest_help_test.py.  Do not run\n// it directly.\n\n#include \"gtest/gtest.h\"\n\n// When a help flag is specified, this program should skip the tests\n// and exit with 0; otherwise the following test will be executed,\n// causing this program to exit with a non-zero code.\nTEST(HelpFlagTest, ShouldNotBeRun) {\n  ASSERT_TRUE(false) << \"Tests shouldn't be run when --help is specified.\";\n}\n\n#if GTEST_HAS_DEATH_TEST\nTEST(DeathTest, UsedByPythonScriptToDetectSupportForDeathTestsInThisBinary) {}\n#endif\n"
  },
  {
    "path": "ext/gtest/test/gtest_list_tests_unittest.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2006, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Unit test for Google Test's --gtest_list_tests flag.\n\nA user can ask Google Test to list all tests by specifying the\n--gtest_list_tests flag.  This script tests such functionality\nby invoking gtest_list_tests_unittest_ (a program written with\nGoogle Test) the command line flags.\n\"\"\"\n\n__author__ = 'phanna@google.com (Patrick Hanna)'\n\nimport gtest_test_utils\nimport re\n\n\n# Constants.\n\n# The command line flag for enabling/disabling listing all tests.\nLIST_TESTS_FLAG = 'gtest_list_tests'\n\n# Path to the gtest_list_tests_unittest_ program.\nEXE_PATH = gtest_test_utils.GetTestExecutablePath('gtest_list_tests_unittest_')\n\n# The expected output when running gtest_list_tests_unittest_ with\n# --gtest_list_tests\nEXPECTED_OUTPUT_NO_FILTER_RE = re.compile(r\"\"\"FooDeathTest\\.\n  Test1\nFoo\\.\n  Bar1\n  Bar2\n  DISABLED_Bar3\nAbc\\.\n  Xyz\n  Def\nFooBar\\.\n  Baz\nFooTest\\.\n  Test1\n  DISABLED_Test2\n  Test3\nTypedTest/0\\.  # TypeParam = (VeryLo{245}|class VeryLo{239})\\.\\.\\.\n  TestA\n  TestB\nTypedTest/1\\.  # TypeParam = int\\s*\\*\n  TestA\n  TestB\nTypedTest/2\\.  # TypeParam = .*MyArray<bool,\\s*42>\n  TestA\n  TestB\nMy/TypeParamTest/0\\.  # TypeParam = (VeryLo{245}|class VeryLo{239})\\.\\.\\.\n  TestA\n  TestB\nMy/TypeParamTest/1\\.  # TypeParam = int\\s*\\*\n  TestA\n  TestB\nMy/TypeParamTest/2\\.  # TypeParam = .*MyArray<bool,\\s*42>\n  TestA\n  TestB\nMyInstantiation/ValueParamTest\\.\n  TestA/0  # GetParam\\(\\) = one line\n  TestA/1  # GetParam\\(\\) = two\\\\nlines\n  TestA/2  # GetParam\\(\\) = a very\\\\nlo{241}\\.\\.\\.\n  TestB/0  # GetParam\\(\\) = one line\n  TestB/1  # GetParam\\(\\) = two\\\\nlines\n  TestB/2  # GetParam\\(\\) = a very\\\\nlo{241}\\.\\.\\.\n\"\"\")\n\n# The expected output when running gtest_list_tests_unittest_ with\n# --gtest_list_tests and --gtest_filter=Foo*.\nEXPECTED_OUTPUT_FILTER_FOO_RE = re.compile(r\"\"\"FooDeathTest\\.\n  Test1\nFoo\\.\n  Bar1\n  Bar2\n  DISABLED_Bar3\nFooBar\\.\n  Baz\nFooTest\\.\n  Test1\n  DISABLED_Test2\n  Test3\n\"\"\")\n\n# Utilities.\n\n\ndef Run(args):\n  \"\"\"Runs gtest_list_tests_unittest_ and returns the list of tests printed.\"\"\"\n\n  return gtest_test_utils.Subprocess([EXE_PATH] + args,\n                                     capture_stderr=False).output\n\n\n# The unit test.\n\nclass GTestListTestsUnitTest(gtest_test_utils.TestCase):\n  \"\"\"Tests using the --gtest_list_tests flag to list all tests.\"\"\"\n\n  def RunAndVerify(self, flag_value, expected_output_re, other_flag):\n    \"\"\"Runs gtest_list_tests_unittest_ and verifies that it prints\n    the correct tests.\n\n    Args:\n      flag_value:         value of the --gtest_list_tests flag;\n                          None if the flag should not be present.\n      expected_output_re: regular expression that matches the expected\n                          output after running command;\n      other_flag:         a different flag to be passed to command\n                          along with gtest_list_tests;\n                          None if the flag should not be present.\n    \"\"\"\n\n    if flag_value is None:\n      flag = ''\n      flag_expression = 'not set'\n    elif flag_value == '0':\n      flag = '--%s=0' % LIST_TESTS_FLAG\n      flag_expression = '0'\n    else:\n      flag = '--%s' % LIST_TESTS_FLAG\n      flag_expression = '1'\n\n    args = [flag]\n\n    if other_flag is not None:\n      args += [other_flag]\n\n    output = Run(args)\n\n    if expected_output_re:\n      self.assert_(\n          expected_output_re.match(output),\n          ('when %s is %s, the output of \"%s\" is \"%s\",\\n'\n           'which does not match regex \"%s\"' %\n           (LIST_TESTS_FLAG, flag_expression, ' '.join(args), output,\n            expected_output_re.pattern)))\n    else:\n      self.assert_(\n          not EXPECTED_OUTPUT_NO_FILTER_RE.match(output),\n          ('when %s is %s, the output of \"%s\" is \"%s\"'%\n           (LIST_TESTS_FLAG, flag_expression, ' '.join(args), output)))\n\n  def testDefaultBehavior(self):\n    \"\"\"Tests the behavior of the default mode.\"\"\"\n\n    self.RunAndVerify(flag_value=None,\n                      expected_output_re=None,\n                      other_flag=None)\n\n  def testFlag(self):\n    \"\"\"Tests using the --gtest_list_tests flag.\"\"\"\n\n    self.RunAndVerify(flag_value='0',\n                      expected_output_re=None,\n                      other_flag=None)\n    self.RunAndVerify(flag_value='1',\n                      expected_output_re=EXPECTED_OUTPUT_NO_FILTER_RE,\n                      other_flag=None)\n\n  def testOverrideNonFilterFlags(self):\n    \"\"\"Tests that --gtest_list_tests overrides the non-filter flags.\"\"\"\n\n    self.RunAndVerify(flag_value='1',\n                      expected_output_re=EXPECTED_OUTPUT_NO_FILTER_RE,\n                      other_flag='--gtest_break_on_failure')\n\n  def testWithFilterFlags(self):\n    \"\"\"Tests that --gtest_list_tests takes into account the\n    --gtest_filter flag.\"\"\"\n\n    self.RunAndVerify(flag_value='1',\n                      expected_output_re=EXPECTED_OUTPUT_FILTER_FOO_RE,\n                      other_flag='--gtest_filter=Foo*')\n\n\nif __name__ == '__main__':\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "ext/gtest/test/gtest_list_tests_unittest_.cc",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: phanna@google.com (Patrick Hanna)\n\n// Unit test for Google Test's --gtest_list_tests flag.\n//\n// A user can ask Google Test to list all tests that will run\n// so that when using a filter, a user will know what\n// tests to look for. The tests will not be run after listing.\n//\n// This program will be invoked from a Python unit test.\n// Don't run it directly.\n\n#include \"gtest/gtest.h\"\n\n// Several different test cases and tests that will be listed.\nTEST(Foo, Bar1) {\n}\n\nTEST(Foo, Bar2) {\n}\n\nTEST(Foo, DISABLED_Bar3) {\n}\n\nTEST(Abc, Xyz) {\n}\n\nTEST(Abc, Def) {\n}\n\nTEST(FooBar, Baz) {\n}\n\nclass FooTest : public testing::Test {\n};\n\nTEST_F(FooTest, Test1) {\n}\n\nTEST_F(FooTest, DISABLED_Test2) {\n}\n\nTEST_F(FooTest, Test3) {\n}\n\nTEST(FooDeathTest, Test1) {\n}\n\n// A group of value-parameterized tests.\n\nclass MyType {\n public:\n  explicit MyType(const std::string& a_value) : value_(a_value) {}\n\n  const std::string& value() const { return value_; }\n\n private:\n  std::string value_;\n};\n\n// Teaches Google Test how to print a MyType.\nvoid PrintTo(const MyType& x, std::ostream* os) {\n  *os << x.value();\n}\n\nclass ValueParamTest : public testing::TestWithParam<MyType> {\n};\n\nTEST_P(ValueParamTest, TestA) {\n}\n\nTEST_P(ValueParamTest, TestB) {\n}\n\nINSTANTIATE_TEST_CASE_P(\n    MyInstantiation, ValueParamTest,\n    testing::Values(MyType(\"one line\"),\n                    MyType(\"two\\nlines\"),\n                    MyType(\"a very\\nloooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong line\")));  // NOLINT\n\n// A group of typed tests.\n\n// A deliberately long type name for testing the line-truncating\n// behavior when printing a type parameter.\nclass VeryLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooogName {  // NOLINT\n};\n\ntemplate <typename T>\nclass TypedTest : public testing::Test {\n};\n\ntemplate <typename T, int kSize>\nclass MyArray {\n};\n\ntypedef testing::Types<VeryLoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooogName,  // NOLINT\n                       int*, MyArray<bool, 42> > MyTypes;\n\nTYPED_TEST_CASE(TypedTest, MyTypes);\n\nTYPED_TEST(TypedTest, TestA) {\n}\n\nTYPED_TEST(TypedTest, TestB) {\n}\n\n// A group of type-parameterized tests.\n\ntemplate <typename T>\nclass TypeParamTest : public testing::Test {\n};\n\nTYPED_TEST_CASE_P(TypeParamTest);\n\nTYPED_TEST_P(TypeParamTest, TestA) {\n}\n\nTYPED_TEST_P(TypeParamTest, TestB) {\n}\n\nREGISTER_TYPED_TEST_CASE_P(TypeParamTest, TestA, TestB);\n\nINSTANTIATE_TYPED_TEST_CASE_P(My, TypeParamTest, MyTypes);\n\nint main(int argc, char **argv) {\n  ::testing::InitGoogleTest(&argc, argv);\n\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest_main_unittest.cc",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"gtest/gtest.h\"\n\n// Tests that we don't have to define main() when we link to\n// gtest_main instead of gtest.\n\nnamespace {\n\nTEST(GTestMainTest, ShouldSucceed) {\n}\n\n}  // namespace\n\n// We are using the main() function defined in src/gtest_main.cc, so\n// we don't define it here.\n"
  },
  {
    "path": "ext/gtest/test/gtest_no_test_unittest.cc",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Tests that a Google Test program that has no test defined can run\n// successfully.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"gtest/gtest.h\"\n\nint main(int argc, char **argv) {\n  testing::InitGoogleTest(&argc, argv);\n\n  // An ad-hoc assertion outside of all tests.\n  //\n  // This serves three purposes:\n  //\n  // 1. It verifies that an ad-hoc assertion can be executed even if\n  //    no test is defined.\n  // 2. It verifies that a failed ad-hoc assertion causes the test\n  //    program to fail.\n  // 3. We had a bug where the XML output won't be generated if an\n  //    assertion is executed before RUN_ALL_TESTS() is called, even\n  //    though --gtest_output=xml is specified.  This makes sure the\n  //    bug is fixed and doesn't regress.\n  EXPECT_EQ(1, 2);\n\n  // The above EXPECT_EQ() should cause RUN_ALL_TESTS() to return non-zero.\n  return RUN_ALL_TESTS() ? 0 : 1;\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest_output_test.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2008, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Tests the text output of Google C++ Testing Framework.\n\nSYNOPSIS\n       gtest_output_test.py --build_dir=BUILD/DIR --gengolden\n         # where BUILD/DIR contains the built gtest_output_test_ file.\n       gtest_output_test.py --gengolden\n       gtest_output_test.py\n\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport re\nimport sys\nimport gtest_test_utils\n\n\n# The flag for generating the golden file\nGENGOLDEN_FLAG = '--gengolden'\nCATCH_EXCEPTIONS_ENV_VAR_NAME = 'GTEST_CATCH_EXCEPTIONS'\n\nIS_WINDOWS = os.name == 'nt'\n\n# TODO(vladl@google.com): remove the _lin suffix.\nGOLDEN_NAME = 'gtest_output_test_golden_lin.txt'\n\nPROGRAM_PATH = gtest_test_utils.GetTestExecutablePath('gtest_output_test_')\n\n# At least one command we exercise must not have the\n# --gtest_internal_skip_environment_and_ad_hoc_tests flag.\nCOMMAND_LIST_TESTS = ({}, [PROGRAM_PATH, '--gtest_list_tests'])\nCOMMAND_WITH_COLOR = ({}, [PROGRAM_PATH, '--gtest_color=yes'])\nCOMMAND_WITH_TIME = ({}, [PROGRAM_PATH,\n                          '--gtest_print_time',\n                          '--gtest_internal_skip_environment_and_ad_hoc_tests',\n                          '--gtest_filter=FatalFailureTest.*:LoggingTest.*'])\nCOMMAND_WITH_DISABLED = (\n    {}, [PROGRAM_PATH,\n         '--gtest_also_run_disabled_tests',\n         '--gtest_internal_skip_environment_and_ad_hoc_tests',\n         '--gtest_filter=*DISABLED_*'])\nCOMMAND_WITH_SHARDING = (\n    {'GTEST_SHARD_INDEX': '1', 'GTEST_TOTAL_SHARDS': '2'},\n    [PROGRAM_PATH,\n     '--gtest_internal_skip_environment_and_ad_hoc_tests',\n     '--gtest_filter=PassingTest.*'])\n\nGOLDEN_PATH = os.path.join(gtest_test_utils.GetSourceDir(), GOLDEN_NAME)\n\n\ndef ToUnixLineEnding(s):\n  \"\"\"Changes all Windows/Mac line endings in s to UNIX line endings.\"\"\"\n\n  return s.replace('\\r\\n', '\\n').replace('\\r', '\\n')\n\n\ndef RemoveLocations(test_output):\n  \"\"\"Removes all file location info from a Google Test program's output.\n\n  Args:\n       test_output:  the output of a Google Test program.\n\n  Returns:\n       output with all file location info (in the form of\n       'DIRECTORY/FILE_NAME:LINE_NUMBER: 'or\n       'DIRECTORY\\\\FILE_NAME(LINE_NUMBER): ') replaced by\n       'FILE_NAME:#: '.\n  \"\"\"\n\n  return re.sub(r'.*[/\\\\](.+)(\\:\\d+|\\(\\d+\\))\\: ', r'\\1:#: ', test_output)\n\n\ndef RemoveStackTraceDetails(output):\n  \"\"\"Removes all stack traces from a Google Test program's output.\"\"\"\n\n  # *? means \"find the shortest string that matches\".\n  return re.sub(r'Stack trace:(.|\\n)*?\\n\\n',\n                'Stack trace: (omitted)\\n\\n', output)\n\n\ndef RemoveStackTraces(output):\n  \"\"\"Removes all traces of stack traces from a Google Test program's output.\"\"\"\n\n  # *? means \"find the shortest string that matches\".\n  return re.sub(r'Stack trace:(.|\\n)*?\\n\\n', '', output)\n\n\ndef RemoveTime(output):\n  \"\"\"Removes all time information from a Google Test program's output.\"\"\"\n\n  return re.sub(r'\\(\\d+ ms', '(? ms', output)\n\n\ndef RemoveTypeInfoDetails(test_output):\n  \"\"\"Removes compiler-specific type info from Google Test program's output.\n\n  Args:\n       test_output:  the output of a Google Test program.\n\n  Returns:\n       output with type information normalized to canonical form.\n  \"\"\"\n\n  # some compilers output the name of type 'unsigned int' as 'unsigned'\n  return re.sub(r'unsigned int', 'unsigned', test_output)\n\n\ndef NormalizeToCurrentPlatform(test_output):\n  \"\"\"Normalizes platform specific output details for easier comparison.\"\"\"\n\n  if IS_WINDOWS:\n    # Removes the color information that is not present on Windows.\n    test_output = re.sub('\\x1b\\\\[(0;3\\d)?m', '', test_output)\n    # Changes failure message headers into the Windows format.\n    test_output = re.sub(r': Failure\\n', r': error: ', test_output)\n    # Changes file(line_number) to file:line_number.\n    test_output = re.sub(r'((\\w|\\.)+)\\((\\d+)\\):', r'\\1:\\3:', test_output)\n\n  return test_output\n\n\ndef RemoveTestCounts(output):\n  \"\"\"Removes test counts from a Google Test program's output.\"\"\"\n\n  output = re.sub(r'\\d+ tests?, listed below',\n                  '? tests, listed below', output)\n  output = re.sub(r'\\d+ FAILED TESTS',\n                  '? FAILED TESTS', output)\n  output = re.sub(r'\\d+ tests? from \\d+ test cases?',\n                  '? tests from ? test cases', output)\n  output = re.sub(r'\\d+ tests? from ([a-zA-Z_])',\n                  r'? tests from \\1', output)\n  return re.sub(r'\\d+ tests?\\.', '? tests.', output)\n\n\ndef RemoveMatchingTests(test_output, pattern):\n  \"\"\"Removes output of specified tests from a Google Test program's output.\n\n  This function strips not only the beginning and the end of a test but also\n  all output in between.\n\n  Args:\n    test_output:       A string containing the test output.\n    pattern:           A regex string that matches names of test cases or\n                       tests to remove.\n\n  Returns:\n    Contents of test_output with tests whose names match pattern removed.\n  \"\"\"\n\n  test_output = re.sub(\n      r'.*\\[ RUN      \\] .*%s(.|\\n)*?\\[(  FAILED  |       OK )\\] .*%s.*\\n' % (\n          pattern, pattern),\n      '',\n      test_output)\n  return re.sub(r'.*%s.*\\n' % pattern, '', test_output)\n\n\ndef NormalizeOutput(output):\n  \"\"\"Normalizes output (the output of gtest_output_test_.exe).\"\"\"\n\n  output = ToUnixLineEnding(output)\n  output = RemoveLocations(output)\n  output = RemoveStackTraceDetails(output)\n  output = RemoveTime(output)\n  return output\n\n\ndef GetShellCommandOutput(env_cmd):\n  \"\"\"Runs a command in a sub-process, and returns its output in a string.\n\n  Args:\n    env_cmd: The shell command. A 2-tuple where element 0 is a dict of extra\n             environment variables to set, and element 1 is a string with\n             the command and any flags.\n\n  Returns:\n    A string with the command's combined standard and diagnostic output.\n  \"\"\"\n\n  # Spawns cmd in a sub-process, and gets its standard I/O file objects.\n  # Set and save the environment properly.\n  environ = os.environ.copy()\n  environ.update(env_cmd[0])\n  p = gtest_test_utils.Subprocess(env_cmd[1], env=environ)\n\n  return p.output\n\n\ndef GetCommandOutput(env_cmd):\n  \"\"\"Runs a command and returns its output with all file location\n  info stripped off.\n\n  Args:\n    env_cmd:  The shell command. A 2-tuple where element 0 is a dict of extra\n              environment variables to set, and element 1 is a string with\n              the command and any flags.\n  \"\"\"\n\n  # Disables exception pop-ups on Windows.\n  environ, cmdline = env_cmd\n  environ = dict(environ)  # Ensures we are modifying a copy.\n  environ[CATCH_EXCEPTIONS_ENV_VAR_NAME] = '1'\n  return NormalizeOutput(GetShellCommandOutput((environ, cmdline)))\n\n\ndef GetOutputOfAllCommands():\n  \"\"\"Returns concatenated output from several representative commands.\"\"\"\n\n  return (GetCommandOutput(COMMAND_WITH_COLOR) +\n          GetCommandOutput(COMMAND_WITH_TIME) +\n          GetCommandOutput(COMMAND_WITH_DISABLED) +\n          GetCommandOutput(COMMAND_WITH_SHARDING))\n\n\ntest_list = GetShellCommandOutput(COMMAND_LIST_TESTS)\nSUPPORTS_DEATH_TESTS = 'DeathTest' in test_list\nSUPPORTS_TYPED_TESTS = 'TypedTest' in test_list\nSUPPORTS_THREADS = 'ExpectFailureWithThreadsTest' in test_list\nSUPPORTS_STACK_TRACES = False\n\nCAN_GENERATE_GOLDEN_FILE = (SUPPORTS_DEATH_TESTS and\n                            SUPPORTS_TYPED_TESTS and\n                            SUPPORTS_THREADS)\n\n\nclass GTestOutputTest(gtest_test_utils.TestCase):\n  def RemoveUnsupportedTests(self, test_output):\n    if not SUPPORTS_DEATH_TESTS:\n      test_output = RemoveMatchingTests(test_output, 'DeathTest')\n    if not SUPPORTS_TYPED_TESTS:\n      test_output = RemoveMatchingTests(test_output, 'TypedTest')\n      test_output = RemoveMatchingTests(test_output, 'TypedDeathTest')\n      test_output = RemoveMatchingTests(test_output, 'TypeParamDeathTest')\n    if not SUPPORTS_THREADS:\n      test_output = RemoveMatchingTests(test_output,\n                                        'ExpectFailureWithThreadsTest')\n      test_output = RemoveMatchingTests(test_output,\n                                        'ScopedFakeTestPartResultReporterTest')\n      test_output = RemoveMatchingTests(test_output,\n                                        'WorksConcurrently')\n    if not SUPPORTS_STACK_TRACES:\n      test_output = RemoveStackTraces(test_output)\n\n    return test_output\n\n  def testOutput(self):\n    output = GetOutputOfAllCommands()\n\n    golden_file = open(GOLDEN_PATH, 'rb')\n    # A mis-configured source control system can cause \\r appear in EOL\n    # sequences when we read the golden file irrespective of an operating\n    # system used. Therefore, we need to strip those \\r's from newlines\n    # unconditionally.\n    golden = ToUnixLineEnding(golden_file.read())\n    golden_file.close()\n\n    # We want the test to pass regardless of certain features being\n    # supported or not.\n\n    # We still have to remove type name specifics in all cases.\n    normalized_actual = RemoveTypeInfoDetails(output)\n    normalized_golden = RemoveTypeInfoDetails(golden)\n\n    if CAN_GENERATE_GOLDEN_FILE:\n      self.assertEqual(normalized_golden, normalized_actual)\n    else:\n      normalized_actual = NormalizeToCurrentPlatform(\n          RemoveTestCounts(normalized_actual))\n      normalized_golden = NormalizeToCurrentPlatform(\n          RemoveTestCounts(self.RemoveUnsupportedTests(normalized_golden)))\n\n      # This code is very handy when debugging golden file differences:\n      if os.getenv('DEBUG_GTEST_OUTPUT_TEST'):\n        open(os.path.join(\n            gtest_test_utils.GetSourceDir(),\n            '_gtest_output_test_normalized_actual.txt'), 'wb').write(\n                normalized_actual)\n        open(os.path.join(\n            gtest_test_utils.GetSourceDir(),\n            '_gtest_output_test_normalized_golden.txt'), 'wb').write(\n                normalized_golden)\n\n      self.assertEqual(normalized_golden, normalized_actual)\n\n\nif __name__ == '__main__':\n  if sys.argv[1:] == [GENGOLDEN_FLAG]:\n    if CAN_GENERATE_GOLDEN_FILE:\n      output = GetOutputOfAllCommands()\n      golden_file = open(GOLDEN_PATH, 'wb')\n      golden_file.write(output)\n      golden_file.close()\n    else:\n      message = (\n          \"\"\"Unable to write a golden file when compiled in an environment\nthat does not support all the required features (death tests, typed tests,\nand multiple threads).  Please generate the golden file using a binary built\nwith those features enabled.\"\"\")\n\n      sys.stderr.write(message)\n      sys.exit(1)\n  else:\n    gtest_test_utils.Main()\n"
  },
  {
    "path": "ext/gtest/test/gtest_output_test_.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// The purpose of this file is to generate Google Test output under\n// various conditions.  The output will then be verified by\n// gtest_output_test.py to ensure that Google Test generates the\n// desired messages.  Therefore, most tests in this file are MEANT TO\n// FAIL.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"gtest/gtest-spi.h\"\n#include \"gtest/gtest.h\"\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick is to\n// prevent a user from accidentally including gtest-internal-inl.h in\n// his code.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\n#include <stdlib.h>\n\n#if GTEST_IS_THREADSAFE\nusing testing::ScopedFakeTestPartResultReporter;\nusing testing::TestPartResultArray;\n\nusing testing::internal::Notification;\nusing testing::internal::ThreadWithParam;\n#endif\n\nnamespace posix = ::testing::internal::posix;\nusing testing::internal::scoped_ptr;\n\n// Tests catching fatal failures.\n\n// A subroutine used by the following test.\nvoid TestEq1(int x) {\n  ASSERT_EQ(1, x);\n}\n\n// This function calls a test subroutine, catches the fatal failure it\n// generates, and then returns early.\nvoid TryTestSubroutine() {\n  // Calls a subrountine that yields a fatal failure.\n  TestEq1(2);\n\n  // Catches the fatal failure and aborts the test.\n  //\n  // The testing::Test:: prefix is necessary when calling\n  // HasFatalFailure() outside of a TEST, TEST_F, or test fixture.\n  if (testing::Test::HasFatalFailure()) return;\n\n  // If we get here, something is wrong.\n  FAIL() << \"This should never be reached.\";\n}\n\nTEST(PassingTest, PassingTest1) {\n}\n\nTEST(PassingTest, PassingTest2) {\n}\n\n// Tests that parameters of failing parameterized tests are printed in the\n// failing test summary.\nclass FailingParamTest : public testing::TestWithParam<int> {};\n\nTEST_P(FailingParamTest, Fails) {\n  EXPECT_EQ(1, GetParam());\n}\n\n// This generates a test which will fail. Google Test is expected to print\n// its parameter when it outputs the list of all failed tests.\nINSTANTIATE_TEST_CASE_P(PrintingFailingParams,\n                        FailingParamTest,\n                        testing::Values(2));\n\nstatic const char kGoldenString[] = \"\\\"Line\\0 1\\\"\\nLine 2\";\n\nTEST(NonfatalFailureTest, EscapesStringOperands) {\n  std::string actual = \"actual \\\"string\\\"\";\n  EXPECT_EQ(kGoldenString, actual);\n\n  const char* golden = kGoldenString;\n  EXPECT_EQ(golden, actual);\n}\n\n// Tests catching a fatal failure in a subroutine.\nTEST(FatalFailureTest, FatalFailureInSubroutine) {\n  printf(\"(expecting a failure that x should be 1)\\n\");\n\n  TryTestSubroutine();\n}\n\n// Tests catching a fatal failure in a nested subroutine.\nTEST(FatalFailureTest, FatalFailureInNestedSubroutine) {\n  printf(\"(expecting a failure that x should be 1)\\n\");\n\n  // Calls a subrountine that yields a fatal failure.\n  TryTestSubroutine();\n\n  // Catches the fatal failure and aborts the test.\n  //\n  // When calling HasFatalFailure() inside a TEST, TEST_F, or test\n  // fixture, the testing::Test:: prefix is not needed.\n  if (HasFatalFailure()) return;\n\n  // If we get here, something is wrong.\n  FAIL() << \"This should never be reached.\";\n}\n\n// Tests HasFatalFailure() after a failed EXPECT check.\nTEST(FatalFailureTest, NonfatalFailureInSubroutine) {\n  printf(\"(expecting a failure on false)\\n\");\n  EXPECT_TRUE(false);  // Generates a nonfatal failure\n  ASSERT_FALSE(HasFatalFailure());  // This should succeed.\n}\n\n// Tests interleaving user logging and Google Test assertions.\nTEST(LoggingTest, InterleavingLoggingAndAssertions) {\n  static const int a[4] = {\n    3, 9, 2, 6\n  };\n\n  printf(\"(expecting 2 failures on (3) >= (a[i]))\\n\");\n  for (int i = 0; i < static_cast<int>(sizeof(a)/sizeof(*a)); i++) {\n    printf(\"i == %d\\n\", i);\n    EXPECT_GE(3, a[i]);\n  }\n}\n\n// Tests the SCOPED_TRACE macro.\n\n// A helper function for testing SCOPED_TRACE.\nvoid SubWithoutTrace(int n) {\n  EXPECT_EQ(1, n);\n  ASSERT_EQ(2, n);\n}\n\n// Another helper function for testing SCOPED_TRACE.\nvoid SubWithTrace(int n) {\n  SCOPED_TRACE(testing::Message() << \"n = \" << n);\n\n  SubWithoutTrace(n);\n}\n\n// Tests that SCOPED_TRACE() obeys lexical scopes.\nTEST(SCOPED_TRACETest, ObeysScopes) {\n  printf(\"(expected to fail)\\n\");\n\n  // There should be no trace before SCOPED_TRACE() is invoked.\n  ADD_FAILURE() << \"This failure is expected, and shouldn't have a trace.\";\n\n  {\n    SCOPED_TRACE(\"Expected trace\");\n    // After SCOPED_TRACE(), a failure in the current scope should contain\n    // the trace.\n    ADD_FAILURE() << \"This failure is expected, and should have a trace.\";\n  }\n\n  // Once the control leaves the scope of the SCOPED_TRACE(), there\n  // should be no trace again.\n  ADD_FAILURE() << \"This failure is expected, and shouldn't have a trace.\";\n}\n\n// Tests that SCOPED_TRACE works inside a loop.\nTEST(SCOPED_TRACETest, WorksInLoop) {\n  printf(\"(expected to fail)\\n\");\n\n  for (int i = 1; i <= 2; i++) {\n    SCOPED_TRACE(testing::Message() << \"i = \" << i);\n\n    SubWithoutTrace(i);\n  }\n}\n\n// Tests that SCOPED_TRACE works in a subroutine.\nTEST(SCOPED_TRACETest, WorksInSubroutine) {\n  printf(\"(expected to fail)\\n\");\n\n  SubWithTrace(1);\n  SubWithTrace(2);\n}\n\n// Tests that SCOPED_TRACE can be nested.\nTEST(SCOPED_TRACETest, CanBeNested) {\n  printf(\"(expected to fail)\\n\");\n\n  SCOPED_TRACE(\"\");  // A trace without a message.\n\n  SubWithTrace(2);\n}\n\n// Tests that multiple SCOPED_TRACEs can be used in the same scope.\nTEST(SCOPED_TRACETest, CanBeRepeated) {\n  printf(\"(expected to fail)\\n\");\n\n  SCOPED_TRACE(\"A\");\n  ADD_FAILURE()\n      << \"This failure is expected, and should contain trace point A.\";\n\n  SCOPED_TRACE(\"B\");\n  ADD_FAILURE()\n      << \"This failure is expected, and should contain trace point A and B.\";\n\n  {\n    SCOPED_TRACE(\"C\");\n    ADD_FAILURE() << \"This failure is expected, and should \"\n                  << \"contain trace point A, B, and C.\";\n  }\n\n  SCOPED_TRACE(\"D\");\n  ADD_FAILURE() << \"This failure is expected, and should \"\n                << \"contain trace point A, B, and D.\";\n}\n\n#if GTEST_IS_THREADSAFE\n// Tests that SCOPED_TRACE()s can be used concurrently from multiple\n// threads.  Namely, an assertion should be affected by\n// SCOPED_TRACE()s in its own thread only.\n\n// Here's the sequence of actions that happen in the test:\n//\n//   Thread A (main)                | Thread B (spawned)\n//   ===============================|================================\n//   spawns thread B                |\n//   -------------------------------+--------------------------------\n//   waits for n1                   | SCOPED_TRACE(\"Trace B\");\n//                                  | generates failure #1\n//                                  | notifies n1\n//   -------------------------------+--------------------------------\n//   SCOPED_TRACE(\"Trace A\");       | waits for n2\n//   generates failure #2           |\n//   notifies n2                    |\n//   -------------------------------|--------------------------------\n//   waits for n3                   | generates failure #3\n//                                  | trace B dies\n//                                  | generates failure #4\n//                                  | notifies n3\n//   -------------------------------|--------------------------------\n//   generates failure #5           | finishes\n//   trace A dies                   |\n//   generates failure #6           |\n//   -------------------------------|--------------------------------\n//   waits for thread B to finish   |\n\nstruct CheckPoints {\n  Notification n1;\n  Notification n2;\n  Notification n3;\n};\n\nstatic void ThreadWithScopedTrace(CheckPoints* check_points) {\n  {\n    SCOPED_TRACE(\"Trace B\");\n    ADD_FAILURE()\n        << \"Expected failure #1 (in thread B, only trace B alive).\";\n    check_points->n1.Notify();\n    check_points->n2.WaitForNotification();\n\n    ADD_FAILURE()\n        << \"Expected failure #3 (in thread B, trace A & B both alive).\";\n  }  // Trace B dies here.\n  ADD_FAILURE()\n      << \"Expected failure #4 (in thread B, only trace A alive).\";\n  check_points->n3.Notify();\n}\n\nTEST(SCOPED_TRACETest, WorksConcurrently) {\n  printf(\"(expecting 6 failures)\\n\");\n\n  CheckPoints check_points;\n  ThreadWithParam<CheckPoints*> thread(&ThreadWithScopedTrace,\n                                       &check_points,\n                                       NULL);\n  check_points.n1.WaitForNotification();\n\n  {\n    SCOPED_TRACE(\"Trace A\");\n    ADD_FAILURE()\n        << \"Expected failure #2 (in thread A, trace A & B both alive).\";\n    check_points.n2.Notify();\n    check_points.n3.WaitForNotification();\n\n    ADD_FAILURE()\n        << \"Expected failure #5 (in thread A, only trace A alive).\";\n  }  // Trace A dies here.\n  ADD_FAILURE()\n      << \"Expected failure #6 (in thread A, no trace alive).\";\n  thread.Join();\n}\n#endif  // GTEST_IS_THREADSAFE\n\nTEST(DisabledTestsWarningTest,\n     DISABLED_AlsoRunDisabledTestsFlagSuppressesWarning) {\n  // This test body is intentionally empty.  Its sole purpose is for\n  // verifying that the --gtest_also_run_disabled_tests flag\n  // suppresses the \"YOU HAVE 12 DISABLED TESTS\" warning at the end of\n  // the test output.\n}\n\n// Tests using assertions outside of TEST and TEST_F.\n//\n// This function creates two failures intentionally.\nvoid AdHocTest() {\n  printf(\"The non-test part of the code is expected to have 2 failures.\\n\\n\");\n  EXPECT_TRUE(false);\n  EXPECT_EQ(2, 3);\n}\n\n// Runs all TESTs, all TEST_Fs, and the ad hoc test.\nint RunAllTests() {\n  AdHocTest();\n  return RUN_ALL_TESTS();\n}\n\n// Tests non-fatal failures in the fixture constructor.\nclass NonFatalFailureInFixtureConstructorTest : public testing::Test {\n protected:\n  NonFatalFailureInFixtureConstructorTest() {\n    printf(\"(expecting 5 failures)\\n\");\n    ADD_FAILURE() << \"Expected failure #1, in the test fixture c'tor.\";\n  }\n\n  ~NonFatalFailureInFixtureConstructorTest() {\n    ADD_FAILURE() << \"Expected failure #5, in the test fixture d'tor.\";\n  }\n\n  virtual void SetUp() {\n    ADD_FAILURE() << \"Expected failure #2, in SetUp().\";\n  }\n\n  virtual void TearDown() {\n    ADD_FAILURE() << \"Expected failure #4, in TearDown.\";\n  }\n};\n\nTEST_F(NonFatalFailureInFixtureConstructorTest, FailureInConstructor) {\n  ADD_FAILURE() << \"Expected failure #3, in the test body.\";\n}\n\n// Tests fatal failures in the fixture constructor.\nclass FatalFailureInFixtureConstructorTest : public testing::Test {\n protected:\n  FatalFailureInFixtureConstructorTest() {\n    printf(\"(expecting 2 failures)\\n\");\n    Init();\n  }\n\n  ~FatalFailureInFixtureConstructorTest() {\n    ADD_FAILURE() << \"Expected failure #2, in the test fixture d'tor.\";\n  }\n\n  virtual void SetUp() {\n    ADD_FAILURE() << \"UNEXPECTED failure in SetUp().  \"\n                  << \"We should never get here, as the test fixture c'tor \"\n                  << \"had a fatal failure.\";\n  }\n\n  virtual void TearDown() {\n    ADD_FAILURE() << \"UNEXPECTED failure in TearDown().  \"\n                  << \"We should never get here, as the test fixture c'tor \"\n                  << \"had a fatal failure.\";\n  }\n\n private:\n  void Init() {\n    FAIL() << \"Expected failure #1, in the test fixture c'tor.\";\n  }\n};\n\nTEST_F(FatalFailureInFixtureConstructorTest, FailureInConstructor) {\n  ADD_FAILURE() << \"UNEXPECTED failure in the test body.  \"\n                << \"We should never get here, as the test fixture c'tor \"\n                << \"had a fatal failure.\";\n}\n\n// Tests non-fatal failures in SetUp().\nclass NonFatalFailureInSetUpTest : public testing::Test {\n protected:\n  virtual ~NonFatalFailureInSetUpTest() {\n    Deinit();\n  }\n\n  virtual void SetUp() {\n    printf(\"(expecting 4 failures)\\n\");\n    ADD_FAILURE() << \"Expected failure #1, in SetUp().\";\n  }\n\n  virtual void TearDown() {\n    FAIL() << \"Expected failure #3, in TearDown().\";\n  }\n private:\n  void Deinit() {\n    FAIL() << \"Expected failure #4, in the test fixture d'tor.\";\n  }\n};\n\nTEST_F(NonFatalFailureInSetUpTest, FailureInSetUp) {\n  FAIL() << \"Expected failure #2, in the test function.\";\n}\n\n// Tests fatal failures in SetUp().\nclass FatalFailureInSetUpTest : public testing::Test {\n protected:\n  virtual ~FatalFailureInSetUpTest() {\n    Deinit();\n  }\n\n  virtual void SetUp() {\n    printf(\"(expecting 3 failures)\\n\");\n    FAIL() << \"Expected failure #1, in SetUp().\";\n  }\n\n  virtual void TearDown() {\n    FAIL() << \"Expected failure #2, in TearDown().\";\n  }\n private:\n  void Deinit() {\n    FAIL() << \"Expected failure #3, in the test fixture d'tor.\";\n  }\n};\n\nTEST_F(FatalFailureInSetUpTest, FailureInSetUp) {\n  FAIL() << \"UNEXPECTED failure in the test function.  \"\n         << \"We should never get here, as SetUp() failed.\";\n}\n\nTEST(AddFailureAtTest, MessageContainsSpecifiedFileAndLineNumber) {\n  ADD_FAILURE_AT(\"foo.cc\", 42) << \"Expected failure in foo.cc\";\n}\n\n#if GTEST_IS_THREADSAFE\n\n// A unary function that may die.\nvoid DieIf(bool should_die) {\n  GTEST_CHECK_(!should_die) << \" - death inside DieIf().\";\n}\n\n// Tests running death tests in a multi-threaded context.\n\n// Used for coordination between the main and the spawn thread.\nstruct SpawnThreadNotifications {\n  SpawnThreadNotifications() {}\n\n  Notification spawn_thread_started;\n  Notification spawn_thread_ok_to_terminate;\n\n private:\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(SpawnThreadNotifications);\n};\n\n// The function to be executed in the thread spawn by the\n// MultipleThreads test (below).\nstatic void ThreadRoutine(SpawnThreadNotifications* notifications) {\n  // Signals the main thread that this thread has started.\n  notifications->spawn_thread_started.Notify();\n\n  // Waits for permission to finish from the main thread.\n  notifications->spawn_thread_ok_to_terminate.WaitForNotification();\n}\n\n// This is a death-test test, but it's not named with a DeathTest\n// suffix.  It starts threads which might interfere with later\n// death tests, so it must run after all other death tests.\nclass DeathTestAndMultiThreadsTest : public testing::Test {\n protected:\n  // Starts a thread and waits for it to begin.\n  virtual void SetUp() {\n    thread_.reset(new ThreadWithParam<SpawnThreadNotifications*>(\n        &ThreadRoutine, &notifications_, NULL));\n    notifications_.spawn_thread_started.WaitForNotification();\n  }\n  // Tells the thread to finish, and reaps it.\n  // Depending on the version of the thread library in use,\n  // a manager thread might still be left running that will interfere\n  // with later death tests.  This is unfortunate, but this class\n  // cleans up after itself as best it can.\n  virtual void TearDown() {\n    notifications_.spawn_thread_ok_to_terminate.Notify();\n  }\n\n private:\n  SpawnThreadNotifications notifications_;\n  scoped_ptr<ThreadWithParam<SpawnThreadNotifications*> > thread_;\n};\n\n#endif  // GTEST_IS_THREADSAFE\n\n// The MixedUpTestCaseTest test case verifies that Google Test will fail a\n// test if it uses a different fixture class than what other tests in\n// the same test case use.  It deliberately contains two fixture\n// classes with the same name but defined in different namespaces.\n\n// The MixedUpTestCaseWithSameTestNameTest test case verifies that\n// when the user defines two tests with the same test case name AND\n// same test name (but in different namespaces), the second test will\n// fail.\n\nnamespace foo {\n\nclass MixedUpTestCaseTest : public testing::Test {\n};\n\nTEST_F(MixedUpTestCaseTest, FirstTestFromNamespaceFoo) {}\nTEST_F(MixedUpTestCaseTest, SecondTestFromNamespaceFoo) {}\n\nclass MixedUpTestCaseWithSameTestNameTest : public testing::Test {\n};\n\nTEST_F(MixedUpTestCaseWithSameTestNameTest,\n       TheSecondTestWithThisNameShouldFail) {}\n\n}  // namespace foo\n\nnamespace bar {\n\nclass MixedUpTestCaseTest : public testing::Test {\n};\n\n// The following two tests are expected to fail.  We rely on the\n// golden file to check that Google Test generates the right error message.\nTEST_F(MixedUpTestCaseTest, ThisShouldFail) {}\nTEST_F(MixedUpTestCaseTest, ThisShouldFailToo) {}\n\nclass MixedUpTestCaseWithSameTestNameTest : public testing::Test {\n};\n\n// Expected to fail.  We rely on the golden file to check that Google Test\n// generates the right error message.\nTEST_F(MixedUpTestCaseWithSameTestNameTest,\n       TheSecondTestWithThisNameShouldFail) {}\n\n}  // namespace bar\n\n// The following two test cases verify that Google Test catches the user\n// error of mixing TEST and TEST_F in the same test case.  The first\n// test case checks the scenario where TEST_F appears before TEST, and\n// the second one checks where TEST appears before TEST_F.\n\nclass TEST_F_before_TEST_in_same_test_case : public testing::Test {\n};\n\nTEST_F(TEST_F_before_TEST_in_same_test_case, DefinedUsingTEST_F) {}\n\n// Expected to fail.  We rely on the golden file to check that Google Test\n// generates the right error message.\nTEST(TEST_F_before_TEST_in_same_test_case, DefinedUsingTESTAndShouldFail) {}\n\nclass TEST_before_TEST_F_in_same_test_case : public testing::Test {\n};\n\nTEST(TEST_before_TEST_F_in_same_test_case, DefinedUsingTEST) {}\n\n// Expected to fail.  We rely on the golden file to check that Google Test\n// generates the right error message.\nTEST_F(TEST_before_TEST_F_in_same_test_case, DefinedUsingTEST_FAndShouldFail) {\n}\n\n// Used for testing EXPECT_NONFATAL_FAILURE() and EXPECT_FATAL_FAILURE().\nint global_integer = 0;\n\n// Tests that EXPECT_NONFATAL_FAILURE() can reference global variables.\nTEST(ExpectNonfatalFailureTest, CanReferenceGlobalVariables) {\n  global_integer = 0;\n  EXPECT_NONFATAL_FAILURE({\n    EXPECT_EQ(1, global_integer) << \"Expected non-fatal failure.\";\n  }, \"Expected non-fatal failure.\");\n}\n\n// Tests that EXPECT_NONFATAL_FAILURE() can reference local variables\n// (static or not).\nTEST(ExpectNonfatalFailureTest, CanReferenceLocalVariables) {\n  int m = 0;\n  static int n;\n  n = 1;\n  EXPECT_NONFATAL_FAILURE({\n    EXPECT_EQ(m, n) << \"Expected non-fatal failure.\";\n  }, \"Expected non-fatal failure.\");\n}\n\n// Tests that EXPECT_NONFATAL_FAILURE() succeeds when there is exactly\n// one non-fatal failure and no fatal failure.\nTEST(ExpectNonfatalFailureTest, SucceedsWhenThereIsOneNonfatalFailure) {\n  EXPECT_NONFATAL_FAILURE({\n    ADD_FAILURE() << \"Expected non-fatal failure.\";\n  }, \"Expected non-fatal failure.\");\n}\n\n// Tests that EXPECT_NONFATAL_FAILURE() fails when there is no\n// non-fatal failure.\nTEST(ExpectNonfatalFailureTest, FailsWhenThereIsNoNonfatalFailure) {\n  printf(\"(expecting a failure)\\n\");\n  EXPECT_NONFATAL_FAILURE({\n  }, \"\");\n}\n\n// Tests that EXPECT_NONFATAL_FAILURE() fails when there are two\n// non-fatal failures.\nTEST(ExpectNonfatalFailureTest, FailsWhenThereAreTwoNonfatalFailures) {\n  printf(\"(expecting a failure)\\n\");\n  EXPECT_NONFATAL_FAILURE({\n    ADD_FAILURE() << \"Expected non-fatal failure 1.\";\n    ADD_FAILURE() << \"Expected non-fatal failure 2.\";\n  }, \"\");\n}\n\n// Tests that EXPECT_NONFATAL_FAILURE() fails when there is one fatal\n// failure.\nTEST(ExpectNonfatalFailureTest, FailsWhenThereIsOneFatalFailure) {\n  printf(\"(expecting a failure)\\n\");\n  EXPECT_NONFATAL_FAILURE({\n    FAIL() << \"Expected fatal failure.\";\n  }, \"\");\n}\n\n// Tests that EXPECT_NONFATAL_FAILURE() fails when the statement being\n// tested returns.\nTEST(ExpectNonfatalFailureTest, FailsWhenStatementReturns) {\n  printf(\"(expecting a failure)\\n\");\n  EXPECT_NONFATAL_FAILURE({\n    return;\n  }, \"\");\n}\n\n#if GTEST_HAS_EXCEPTIONS\n\n// Tests that EXPECT_NONFATAL_FAILURE() fails when the statement being\n// tested throws.\nTEST(ExpectNonfatalFailureTest, FailsWhenStatementThrows) {\n  printf(\"(expecting a failure)\\n\");\n  try {\n    EXPECT_NONFATAL_FAILURE({\n      throw 0;\n    }, \"\");\n  } catch(int) {  // NOLINT\n  }\n}\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n// Tests that EXPECT_FATAL_FAILURE() can reference global variables.\nTEST(ExpectFatalFailureTest, CanReferenceGlobalVariables) {\n  global_integer = 0;\n  EXPECT_FATAL_FAILURE({\n    ASSERT_EQ(1, global_integer) << \"Expected fatal failure.\";\n  }, \"Expected fatal failure.\");\n}\n\n// Tests that EXPECT_FATAL_FAILURE() can reference local static\n// variables.\nTEST(ExpectFatalFailureTest, CanReferenceLocalStaticVariables) {\n  static int n;\n  n = 1;\n  EXPECT_FATAL_FAILURE({\n    ASSERT_EQ(0, n) << \"Expected fatal failure.\";\n  }, \"Expected fatal failure.\");\n}\n\n// Tests that EXPECT_FATAL_FAILURE() succeeds when there is exactly\n// one fatal failure and no non-fatal failure.\nTEST(ExpectFatalFailureTest, SucceedsWhenThereIsOneFatalFailure) {\n  EXPECT_FATAL_FAILURE({\n    FAIL() << \"Expected fatal failure.\";\n  }, \"Expected fatal failure.\");\n}\n\n// Tests that EXPECT_FATAL_FAILURE() fails when there is no fatal\n// failure.\nTEST(ExpectFatalFailureTest, FailsWhenThereIsNoFatalFailure) {\n  printf(\"(expecting a failure)\\n\");\n  EXPECT_FATAL_FAILURE({\n  }, \"\");\n}\n\n// A helper for generating a fatal failure.\nvoid FatalFailure() {\n  FAIL() << \"Expected fatal failure.\";\n}\n\n// Tests that EXPECT_FATAL_FAILURE() fails when there are two\n// fatal failures.\nTEST(ExpectFatalFailureTest, FailsWhenThereAreTwoFatalFailures) {\n  printf(\"(expecting a failure)\\n\");\n  EXPECT_FATAL_FAILURE({\n    FatalFailure();\n    FatalFailure();\n  }, \"\");\n}\n\n// Tests that EXPECT_FATAL_FAILURE() fails when there is one non-fatal\n// failure.\nTEST(ExpectFatalFailureTest, FailsWhenThereIsOneNonfatalFailure) {\n  printf(\"(expecting a failure)\\n\");\n  EXPECT_FATAL_FAILURE({\n    ADD_FAILURE() << \"Expected non-fatal failure.\";\n  }, \"\");\n}\n\n// Tests that EXPECT_FATAL_FAILURE() fails when the statement being\n// tested returns.\nTEST(ExpectFatalFailureTest, FailsWhenStatementReturns) {\n  printf(\"(expecting a failure)\\n\");\n  EXPECT_FATAL_FAILURE({\n    return;\n  }, \"\");\n}\n\n#if GTEST_HAS_EXCEPTIONS\n\n// Tests that EXPECT_FATAL_FAILURE() fails when the statement being\n// tested throws.\nTEST(ExpectFatalFailureTest, FailsWhenStatementThrows) {\n  printf(\"(expecting a failure)\\n\");\n  try {\n    EXPECT_FATAL_FAILURE({\n      throw 0;\n    }, \"\");\n  } catch(int) {  // NOLINT\n  }\n}\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n// This #ifdef block tests the output of typed tests.\n#if GTEST_HAS_TYPED_TEST\n\ntemplate <typename T>\nclass TypedTest : public testing::Test {\n};\n\nTYPED_TEST_CASE(TypedTest, testing::Types<int>);\n\nTYPED_TEST(TypedTest, Success) {\n  EXPECT_EQ(0, TypeParam());\n}\n\nTYPED_TEST(TypedTest, Failure) {\n  EXPECT_EQ(1, TypeParam()) << \"Expected failure\";\n}\n\n#endif  // GTEST_HAS_TYPED_TEST\n\n// This #ifdef block tests the output of type-parameterized tests.\n#if GTEST_HAS_TYPED_TEST_P\n\ntemplate <typename T>\nclass TypedTestP : public testing::Test {\n};\n\nTYPED_TEST_CASE_P(TypedTestP);\n\nTYPED_TEST_P(TypedTestP, Success) {\n  EXPECT_EQ(0U, TypeParam());\n}\n\nTYPED_TEST_P(TypedTestP, Failure) {\n  EXPECT_EQ(1U, TypeParam()) << \"Expected failure\";\n}\n\nREGISTER_TYPED_TEST_CASE_P(TypedTestP, Success, Failure);\n\ntypedef testing::Types<unsigned char, unsigned int> UnsignedTypes;\nINSTANTIATE_TYPED_TEST_CASE_P(Unsigned, TypedTestP, UnsignedTypes);\n\n#endif  // GTEST_HAS_TYPED_TEST_P\n\n#if GTEST_HAS_DEATH_TEST\n\n// We rely on the golden file to verify that tests whose test case\n// name ends with DeathTest are run first.\n\nTEST(ADeathTest, ShouldRunFirst) {\n}\n\n# if GTEST_HAS_TYPED_TEST\n\n// We rely on the golden file to verify that typed tests whose test\n// case name ends with DeathTest are run first.\n\ntemplate <typename T>\nclass ATypedDeathTest : public testing::Test {\n};\n\ntypedef testing::Types<int, double> NumericTypes;\nTYPED_TEST_CASE(ATypedDeathTest, NumericTypes);\n\nTYPED_TEST(ATypedDeathTest, ShouldRunFirst) {\n}\n\n# endif  // GTEST_HAS_TYPED_TEST\n\n# if GTEST_HAS_TYPED_TEST_P\n\n\n// We rely on the golden file to verify that type-parameterized tests\n// whose test case name ends with DeathTest are run first.\n\ntemplate <typename T>\nclass ATypeParamDeathTest : public testing::Test {\n};\n\nTYPED_TEST_CASE_P(ATypeParamDeathTest);\n\nTYPED_TEST_P(ATypeParamDeathTest, ShouldRunFirst) {\n}\n\nREGISTER_TYPED_TEST_CASE_P(ATypeParamDeathTest, ShouldRunFirst);\n\nINSTANTIATE_TYPED_TEST_CASE_P(My, ATypeParamDeathTest, NumericTypes);\n\n# endif  // GTEST_HAS_TYPED_TEST_P\n\n#endif  // GTEST_HAS_DEATH_TEST\n\n// Tests various failure conditions of\n// EXPECT_{,NON}FATAL_FAILURE{,_ON_ALL_THREADS}.\nclass ExpectFailureTest : public testing::Test {\n public:  // Must be public and not protected due to a bug in g++ 3.4.2.\n  enum FailureMode {\n    FATAL_FAILURE,\n    NONFATAL_FAILURE\n  };\n  static void AddFailure(FailureMode failure) {\n    if (failure == FATAL_FAILURE) {\n      FAIL() << \"Expected fatal failure.\";\n    } else {\n      ADD_FAILURE() << \"Expected non-fatal failure.\";\n    }\n  }\n};\n\nTEST_F(ExpectFailureTest, ExpectFatalFailure) {\n  // Expected fatal failure, but succeeds.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_FATAL_FAILURE(SUCCEED(), \"Expected fatal failure.\");\n  // Expected fatal failure, but got a non-fatal failure.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_FATAL_FAILURE(AddFailure(NONFATAL_FAILURE), \"Expected non-fatal \"\n                       \"failure.\");\n  // Wrong message.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_FATAL_FAILURE(AddFailure(FATAL_FAILURE), \"Some other fatal failure \"\n                       \"expected.\");\n}\n\nTEST_F(ExpectFailureTest, ExpectNonFatalFailure) {\n  // Expected non-fatal failure, but succeeds.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_NONFATAL_FAILURE(SUCCEED(), \"Expected non-fatal failure.\");\n  // Expected non-fatal failure, but got a fatal failure.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_NONFATAL_FAILURE(AddFailure(FATAL_FAILURE), \"Expected fatal failure.\");\n  // Wrong message.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_NONFATAL_FAILURE(AddFailure(NONFATAL_FAILURE), \"Some other non-fatal \"\n                          \"failure.\");\n}\n\n#if GTEST_IS_THREADSAFE\n\nclass ExpectFailureWithThreadsTest : public ExpectFailureTest {\n protected:\n  static void AddFailureInOtherThread(FailureMode failure) {\n    ThreadWithParam<FailureMode> thread(&AddFailure, failure, NULL);\n    thread.Join();\n  }\n};\n\nTEST_F(ExpectFailureWithThreadsTest, ExpectFatalFailure) {\n  // We only intercept the current thread.\n  printf(\"(expecting 2 failures)\\n\");\n  EXPECT_FATAL_FAILURE(AddFailureInOtherThread(FATAL_FAILURE),\n                       \"Expected fatal failure.\");\n}\n\nTEST_F(ExpectFailureWithThreadsTest, ExpectNonFatalFailure) {\n  // We only intercept the current thread.\n  printf(\"(expecting 2 failures)\\n\");\n  EXPECT_NONFATAL_FAILURE(AddFailureInOtherThread(NONFATAL_FAILURE),\n                          \"Expected non-fatal failure.\");\n}\n\ntypedef ExpectFailureWithThreadsTest ScopedFakeTestPartResultReporterTest;\n\n// Tests that the ScopedFakeTestPartResultReporter only catches failures from\n// the current thread if it is instantiated with INTERCEPT_ONLY_CURRENT_THREAD.\nTEST_F(ScopedFakeTestPartResultReporterTest, InterceptOnlyCurrentThread) {\n  printf(\"(expecting 2 failures)\\n\");\n  TestPartResultArray results;\n  {\n    ScopedFakeTestPartResultReporter reporter(\n        ScopedFakeTestPartResultReporter::INTERCEPT_ONLY_CURRENT_THREAD,\n        &results);\n    AddFailureInOtherThread(FATAL_FAILURE);\n    AddFailureInOtherThread(NONFATAL_FAILURE);\n  }\n  // The two failures should not have been intercepted.\n  EXPECT_EQ(0, results.size()) << \"This shouldn't fail.\";\n}\n\n#endif  // GTEST_IS_THREADSAFE\n\nTEST_F(ExpectFailureTest, ExpectFatalFailureOnAllThreads) {\n  // Expected fatal failure, but succeeds.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_FATAL_FAILURE_ON_ALL_THREADS(SUCCEED(), \"Expected fatal failure.\");\n  // Expected fatal failure, but got a non-fatal failure.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_FATAL_FAILURE_ON_ALL_THREADS(AddFailure(NONFATAL_FAILURE),\n                                      \"Expected non-fatal failure.\");\n  // Wrong message.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_FATAL_FAILURE_ON_ALL_THREADS(AddFailure(FATAL_FAILURE),\n                                      \"Some other fatal failure expected.\");\n}\n\nTEST_F(ExpectFailureTest, ExpectNonFatalFailureOnAllThreads) {\n  // Expected non-fatal failure, but succeeds.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(SUCCEED(), \"Expected non-fatal \"\n                                         \"failure.\");\n  // Expected non-fatal failure, but got a fatal failure.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(AddFailure(FATAL_FAILURE),\n                                         \"Expected fatal failure.\");\n  // Wrong message.\n  printf(\"(expecting 1 failure)\\n\");\n  EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(AddFailure(NONFATAL_FAILURE),\n                                         \"Some other non-fatal failure.\");\n}\n\n\n// Two test environments for testing testing::AddGlobalTestEnvironment().\n\nclass FooEnvironment : public testing::Environment {\n public:\n  virtual void SetUp() {\n    printf(\"%s\", \"FooEnvironment::SetUp() called.\\n\");\n  }\n\n  virtual void TearDown() {\n    printf(\"%s\", \"FooEnvironment::TearDown() called.\\n\");\n    FAIL() << \"Expected fatal failure.\";\n  }\n};\n\nclass BarEnvironment : public testing::Environment {\n public:\n  virtual void SetUp() {\n    printf(\"%s\", \"BarEnvironment::SetUp() called.\\n\");\n  }\n\n  virtual void TearDown() {\n    printf(\"%s\", \"BarEnvironment::TearDown() called.\\n\");\n    ADD_FAILURE() << \"Expected non-fatal failure.\";\n  }\n};\n\nbool GTEST_FLAG(internal_skip_environment_and_ad_hoc_tests) = false;\n\n// The main function.\n//\n// The idea is to use Google Test to run all the tests we have defined (some\n// of them are intended to fail), and then compare the test results\n// with the \"golden\" file.\nint main(int argc, char **argv) {\n  testing::GTEST_FLAG(print_time) = false;\n\n  // We just run the tests, knowing some of them are intended to fail.\n  // We will use a separate Python script to compare the output of\n  // this program with the golden file.\n\n  // It's hard to test InitGoogleTest() directly, as it has many\n  // global side effects.  The following line serves as a sanity test\n  // for it.\n  testing::InitGoogleTest(&argc, argv);\n  if (argc >= 2 &&\n      (std::string(argv[1]) ==\n       \"--gtest_internal_skip_environment_and_ad_hoc_tests\"))\n    GTEST_FLAG(internal_skip_environment_and_ad_hoc_tests) = true;\n\n#if GTEST_HAS_DEATH_TEST\n  if (testing::internal::GTEST_FLAG(internal_run_death_test) != \"\") {\n    // Skip the usual output capturing if we're running as the child\n    // process of an threadsafe-style death test.\n# if GTEST_OS_WINDOWS\n    posix::FReopen(\"nul:\", \"w\", stdout);\n# else\n    posix::FReopen(\"/dev/null\", \"w\", stdout);\n# endif  // GTEST_OS_WINDOWS\n    return RUN_ALL_TESTS();\n  }\n#endif  // GTEST_HAS_DEATH_TEST\n\n  if (GTEST_FLAG(internal_skip_environment_and_ad_hoc_tests))\n    return RUN_ALL_TESTS();\n\n  // Registers two global test environments.\n  // The golden file verifies that they are set up in the order they\n  // are registered, and torn down in the reverse order.\n  testing::AddGlobalTestEnvironment(new FooEnvironment);\n  testing::AddGlobalTestEnvironment(new BarEnvironment);\n\n  return RunAllTests();\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest_output_test_golden_lin.txt",
    "content": "The non-test part of the code is expected to have 2 failures.\n\ngtest_output_test_.cc:#: Failure\nValue of: false\n  Actual: false\nExpected: true\ngtest_output_test_.cc:#: Failure\nValue of: 3\nExpected: 2\n\u001b[0;32m[==========] \u001b[mRunning 63 tests from 28 test cases.\n\u001b[0;32m[----------] \u001b[mGlobal test environment set-up.\nFooEnvironment::SetUp() called.\nBarEnvironment::SetUp() called.\n\u001b[0;32m[----------] \u001b[m1 test from ADeathTest\n\u001b[0;32m[ RUN      ] \u001b[mADeathTest.ShouldRunFirst\n\u001b[0;32m[       OK ] \u001b[mADeathTest.ShouldRunFirst\n\u001b[0;32m[----------] \u001b[m1 test from ATypedDeathTest/0, where TypeParam = int\n\u001b[0;32m[ RUN      ] \u001b[mATypedDeathTest/0.ShouldRunFirst\n\u001b[0;32m[       OK ] \u001b[mATypedDeathTest/0.ShouldRunFirst\n\u001b[0;32m[----------] \u001b[m1 test from ATypedDeathTest/1, where TypeParam = double\n\u001b[0;32m[ RUN      ] \u001b[mATypedDeathTest/1.ShouldRunFirst\n\u001b[0;32m[       OK ] \u001b[mATypedDeathTest/1.ShouldRunFirst\n\u001b[0;32m[----------] \u001b[m1 test from My/ATypeParamDeathTest/0, where TypeParam = int\n\u001b[0;32m[ RUN      ] \u001b[mMy/ATypeParamDeathTest/0.ShouldRunFirst\n\u001b[0;32m[       OK ] \u001b[mMy/ATypeParamDeathTest/0.ShouldRunFirst\n\u001b[0;32m[----------] \u001b[m1 test from My/ATypeParamDeathTest/1, where TypeParam = double\n\u001b[0;32m[ RUN      ] \u001b[mMy/ATypeParamDeathTest/1.ShouldRunFirst\n\u001b[0;32m[       OK ] \u001b[mMy/ATypeParamDeathTest/1.ShouldRunFirst\n\u001b[0;32m[----------] \u001b[m2 tests from PassingTest\n\u001b[0;32m[ RUN      ] \u001b[mPassingTest.PassingTest1\n\u001b[0;32m[       OK ] \u001b[mPassingTest.PassingTest1\n\u001b[0;32m[ RUN      ] \u001b[mPassingTest.PassingTest2\n\u001b[0;32m[       OK ] \u001b[mPassingTest.PassingTest2\n\u001b[0;32m[----------] \u001b[m1 test from NonfatalFailureTest\n\u001b[0;32m[ RUN      ] \u001b[mNonfatalFailureTest.EscapesStringOperands\ngtest_output_test_.cc:#: Failure\nValue of: actual\n  Actual: \"actual \\\"string\\\"\"\nExpected: kGoldenString\nWhich is: \"\\\"Line\"\ngtest_output_test_.cc:#: Failure\nValue of: actual\n  Actual: \"actual \\\"string\\\"\"\nExpected: golden\nWhich is: \"\\\"Line\"\n\u001b[0;31m[  FAILED  ] \u001b[mNonfatalFailureTest.EscapesStringOperands\n\u001b[0;32m[----------] \u001b[m3 tests from FatalFailureTest\n\u001b[0;32m[ RUN      ] \u001b[mFatalFailureTest.FatalFailureInSubroutine\n(expecting a failure that x should be 1)\ngtest_output_test_.cc:#: Failure\nValue of: x\n  Actual: 2\nExpected: 1\n\u001b[0;31m[  FAILED  ] \u001b[mFatalFailureTest.FatalFailureInSubroutine\n\u001b[0;32m[ RUN      ] \u001b[mFatalFailureTest.FatalFailureInNestedSubroutine\n(expecting a failure that x should be 1)\ngtest_output_test_.cc:#: Failure\nValue of: x\n  Actual: 2\nExpected: 1\n\u001b[0;31m[  FAILED  ] \u001b[mFatalFailureTest.FatalFailureInNestedSubroutine\n\u001b[0;32m[ RUN      ] \u001b[mFatalFailureTest.NonfatalFailureInSubroutine\n(expecting a failure on false)\ngtest_output_test_.cc:#: Failure\nValue of: false\n  Actual: false\nExpected: true\n\u001b[0;31m[  FAILED  ] \u001b[mFatalFailureTest.NonfatalFailureInSubroutine\n\u001b[0;32m[----------] \u001b[m1 test from LoggingTest\n\u001b[0;32m[ RUN      ] \u001b[mLoggingTest.InterleavingLoggingAndAssertions\n(expecting 2 failures on (3) >= (a[i]))\ni == 0\ni == 1\ngtest_output_test_.cc:#: Failure\nExpected: (3) >= (a[i]), actual: 3 vs 9\ni == 2\ni == 3\ngtest_output_test_.cc:#: Failure\nExpected: (3) >= (a[i]), actual: 3 vs 6\n\u001b[0;31m[  FAILED  ] \u001b[mLoggingTest.InterleavingLoggingAndAssertions\n\u001b[0;32m[----------] \u001b[m6 tests from SCOPED_TRACETest\n\u001b[0;32m[ RUN      ] \u001b[mSCOPED_TRACETest.ObeysScopes\n(expected to fail)\ngtest_output_test_.cc:#: Failure\nFailed\nThis failure is expected, and shouldn't have a trace.\ngtest_output_test_.cc:#: Failure\nFailed\nThis failure is expected, and should have a trace.\nGoogle Test trace:\ngtest_output_test_.cc:#: Expected trace\ngtest_output_test_.cc:#: Failure\nFailed\nThis failure is expected, and shouldn't have a trace.\n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.ObeysScopes\n\u001b[0;32m[ RUN      ] \u001b[mSCOPED_TRACETest.WorksInLoop\n(expected to fail)\ngtest_output_test_.cc:#: Failure\nValue of: n\n  Actual: 1\nExpected: 2\nGoogle Test trace:\ngtest_output_test_.cc:#: i = 1\ngtest_output_test_.cc:#: Failure\nValue of: n\n  Actual: 2\nExpected: 1\nGoogle Test trace:\ngtest_output_test_.cc:#: i = 2\n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.WorksInLoop\n\u001b[0;32m[ RUN      ] \u001b[mSCOPED_TRACETest.WorksInSubroutine\n(expected to fail)\ngtest_output_test_.cc:#: Failure\nValue of: n\n  Actual: 1\nExpected: 2\nGoogle Test trace:\ngtest_output_test_.cc:#: n = 1\ngtest_output_test_.cc:#: Failure\nValue of: n\n  Actual: 2\nExpected: 1\nGoogle Test trace:\ngtest_output_test_.cc:#: n = 2\n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.WorksInSubroutine\n\u001b[0;32m[ RUN      ] \u001b[mSCOPED_TRACETest.CanBeNested\n(expected to fail)\ngtest_output_test_.cc:#: Failure\nValue of: n\n  Actual: 2\nExpected: 1\nGoogle Test trace:\ngtest_output_test_.cc:#: n = 2\ngtest_output_test_.cc:#: \n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.CanBeNested\n\u001b[0;32m[ RUN      ] \u001b[mSCOPED_TRACETest.CanBeRepeated\n(expected to fail)\ngtest_output_test_.cc:#: Failure\nFailed\nThis failure is expected, and should contain trace point A.\nGoogle Test trace:\ngtest_output_test_.cc:#: A\ngtest_output_test_.cc:#: Failure\nFailed\nThis failure is expected, and should contain trace point A and B.\nGoogle Test trace:\ngtest_output_test_.cc:#: B\ngtest_output_test_.cc:#: A\ngtest_output_test_.cc:#: Failure\nFailed\nThis failure is expected, and should contain trace point A, B, and C.\nGoogle Test trace:\ngtest_output_test_.cc:#: C\ngtest_output_test_.cc:#: B\ngtest_output_test_.cc:#: A\ngtest_output_test_.cc:#: Failure\nFailed\nThis failure is expected, and should contain trace point A, B, and D.\nGoogle Test trace:\ngtest_output_test_.cc:#: D\ngtest_output_test_.cc:#: B\ngtest_output_test_.cc:#: A\n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.CanBeRepeated\n\u001b[0;32m[ RUN      ] \u001b[mSCOPED_TRACETest.WorksConcurrently\n(expecting 6 failures)\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #1 (in thread B, only trace B alive).\nGoogle Test trace:\ngtest_output_test_.cc:#: Trace B\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #2 (in thread A, trace A & B both alive).\nGoogle Test trace:\ngtest_output_test_.cc:#: Trace A\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #3 (in thread B, trace A & B both alive).\nGoogle Test trace:\ngtest_output_test_.cc:#: Trace B\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #4 (in thread B, only trace A alive).\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #5 (in thread A, only trace A alive).\nGoogle Test trace:\ngtest_output_test_.cc:#: Trace A\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #6 (in thread A, no trace alive).\n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.WorksConcurrently\n\u001b[0;32m[----------] \u001b[m1 test from NonFatalFailureInFixtureConstructorTest\n\u001b[0;32m[ RUN      ] \u001b[mNonFatalFailureInFixtureConstructorTest.FailureInConstructor\n(expecting 5 failures)\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #1, in the test fixture c'tor.\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #2, in SetUp().\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #3, in the test body.\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #4, in TearDown.\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #5, in the test fixture d'tor.\n\u001b[0;31m[  FAILED  ] \u001b[mNonFatalFailureInFixtureConstructorTest.FailureInConstructor\n\u001b[0;32m[----------] \u001b[m1 test from FatalFailureInFixtureConstructorTest\n\u001b[0;32m[ RUN      ] \u001b[mFatalFailureInFixtureConstructorTest.FailureInConstructor\n(expecting 2 failures)\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #1, in the test fixture c'tor.\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #2, in the test fixture d'tor.\n\u001b[0;31m[  FAILED  ] \u001b[mFatalFailureInFixtureConstructorTest.FailureInConstructor\n\u001b[0;32m[----------] \u001b[m1 test from NonFatalFailureInSetUpTest\n\u001b[0;32m[ RUN      ] \u001b[mNonFatalFailureInSetUpTest.FailureInSetUp\n(expecting 4 failures)\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #1, in SetUp().\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #2, in the test function.\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #3, in TearDown().\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #4, in the test fixture d'tor.\n\u001b[0;31m[  FAILED  ] \u001b[mNonFatalFailureInSetUpTest.FailureInSetUp\n\u001b[0;32m[----------] \u001b[m1 test from FatalFailureInSetUpTest\n\u001b[0;32m[ RUN      ] \u001b[mFatalFailureInSetUpTest.FailureInSetUp\n(expecting 3 failures)\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #1, in SetUp().\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #2, in TearDown().\ngtest_output_test_.cc:#: Failure\nFailed\nExpected failure #3, in the test fixture d'tor.\n\u001b[0;31m[  FAILED  ] \u001b[mFatalFailureInSetUpTest.FailureInSetUp\n\u001b[0;32m[----------] \u001b[m1 test from AddFailureAtTest\n\u001b[0;32m[ RUN      ] \u001b[mAddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber\nfoo.cc:42: Failure\nFailed\nExpected failure in foo.cc\n\u001b[0;31m[  FAILED  ] \u001b[mAddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber\n\u001b[0;32m[----------] \u001b[m4 tests from MixedUpTestCaseTest\n\u001b[0;32m[ RUN      ] \u001b[mMixedUpTestCaseTest.FirstTestFromNamespaceFoo\n\u001b[0;32m[       OK ] \u001b[mMixedUpTestCaseTest.FirstTestFromNamespaceFoo\n\u001b[0;32m[ RUN      ] \u001b[mMixedUpTestCaseTest.SecondTestFromNamespaceFoo\n\u001b[0;32m[       OK ] \u001b[mMixedUpTestCaseTest.SecondTestFromNamespaceFoo\n\u001b[0;32m[ RUN      ] \u001b[mMixedUpTestCaseTest.ThisShouldFail\ngtest.cc:#: Failure\nFailed\nAll tests in the same test case must use the same test fixture\nclass.  However, in test case MixedUpTestCaseTest,\nyou defined test FirstTestFromNamespaceFoo and test ThisShouldFail\nusing two different test fixture classes.  This can happen if\nthe two classes are from different namespaces or translation\nunits and have the same name.  You should probably rename one\nof the classes to put the tests into different test cases.\n\u001b[0;31m[  FAILED  ] \u001b[mMixedUpTestCaseTest.ThisShouldFail\n\u001b[0;32m[ RUN      ] \u001b[mMixedUpTestCaseTest.ThisShouldFailToo\ngtest.cc:#: Failure\nFailed\nAll tests in the same test case must use the same test fixture\nclass.  However, in test case MixedUpTestCaseTest,\nyou defined test FirstTestFromNamespaceFoo and test ThisShouldFailToo\nusing two different test fixture classes.  This can happen if\nthe two classes are from different namespaces or translation\nunits and have the same name.  You should probably rename one\nof the classes to put the tests into different test cases.\n\u001b[0;31m[  FAILED  ] \u001b[mMixedUpTestCaseTest.ThisShouldFailToo\n\u001b[0;32m[----------] \u001b[m2 tests from MixedUpTestCaseWithSameTestNameTest\n\u001b[0;32m[ RUN      ] \u001b[mMixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail\n\u001b[0;32m[       OK ] \u001b[mMixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail\n\u001b[0;32m[ RUN      ] \u001b[mMixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail\ngtest.cc:#: Failure\nFailed\nAll tests in the same test case must use the same test fixture\nclass.  However, in test case MixedUpTestCaseWithSameTestNameTest,\nyou defined test TheSecondTestWithThisNameShouldFail and test TheSecondTestWithThisNameShouldFail\nusing two different test fixture classes.  This can happen if\nthe two classes are from different namespaces or translation\nunits and have the same name.  You should probably rename one\nof the classes to put the tests into different test cases.\n\u001b[0;31m[  FAILED  ] \u001b[mMixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail\n\u001b[0;32m[----------] \u001b[m2 tests from TEST_F_before_TEST_in_same_test_case\n\u001b[0;32m[ RUN      ] \u001b[mTEST_F_before_TEST_in_same_test_case.DefinedUsingTEST_F\n\u001b[0;32m[       OK ] \u001b[mTEST_F_before_TEST_in_same_test_case.DefinedUsingTEST_F\n\u001b[0;32m[ RUN      ] \u001b[mTEST_F_before_TEST_in_same_test_case.DefinedUsingTESTAndShouldFail\ngtest.cc:#: Failure\nFailed\nAll tests in the same test case must use the same test fixture\nclass, so mixing TEST_F and TEST in the same test case is\nillegal.  In test case TEST_F_before_TEST_in_same_test_case,\ntest DefinedUsingTEST_F is defined using TEST_F but\ntest DefinedUsingTESTAndShouldFail is defined using TEST.  You probably\nwant to change the TEST to TEST_F or move it to another test\ncase.\n\u001b[0;31m[  FAILED  ] \u001b[mTEST_F_before_TEST_in_same_test_case.DefinedUsingTESTAndShouldFail\n\u001b[0;32m[----------] \u001b[m2 tests from TEST_before_TEST_F_in_same_test_case\n\u001b[0;32m[ RUN      ] \u001b[mTEST_before_TEST_F_in_same_test_case.DefinedUsingTEST\n\u001b[0;32m[       OK ] \u001b[mTEST_before_TEST_F_in_same_test_case.DefinedUsingTEST\n\u001b[0;32m[ RUN      ] \u001b[mTEST_before_TEST_F_in_same_test_case.DefinedUsingTEST_FAndShouldFail\ngtest.cc:#: Failure\nFailed\nAll tests in the same test case must use the same test fixture\nclass, so mixing TEST_F and TEST in the same test case is\nillegal.  In test case TEST_before_TEST_F_in_same_test_case,\ntest DefinedUsingTEST_FAndShouldFail is defined using TEST_F but\ntest DefinedUsingTEST is defined using TEST.  You probably\nwant to change the TEST to TEST_F or move it to another test\ncase.\n\u001b[0;31m[  FAILED  ] \u001b[mTEST_before_TEST_F_in_same_test_case.DefinedUsingTEST_FAndShouldFail\n\u001b[0;32m[----------] \u001b[m8 tests from ExpectNonfatalFailureTest\n\u001b[0;32m[ RUN      ] \u001b[mExpectNonfatalFailureTest.CanReferenceGlobalVariables\n\u001b[0;32m[       OK ] \u001b[mExpectNonfatalFailureTest.CanReferenceGlobalVariables\n\u001b[0;32m[ RUN      ] \u001b[mExpectNonfatalFailureTest.CanReferenceLocalVariables\n\u001b[0;32m[       OK ] \u001b[mExpectNonfatalFailureTest.CanReferenceLocalVariables\n\u001b[0;32m[ RUN      ] \u001b[mExpectNonfatalFailureTest.SucceedsWhenThereIsOneNonfatalFailure\n\u001b[0;32m[       OK ] \u001b[mExpectNonfatalFailureTest.SucceedsWhenThereIsOneNonfatalFailure\n\u001b[0;32m[ RUN      ] \u001b[mExpectNonfatalFailureTest.FailsWhenThereIsNoNonfatalFailure\n(expecting a failure)\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure\n  Actual: 0 failures\n\u001b[0;31m[  FAILED  ] \u001b[mExpectNonfatalFailureTest.FailsWhenThereIsNoNonfatalFailure\n\u001b[0;32m[ RUN      ] \u001b[mExpectNonfatalFailureTest.FailsWhenThereAreTwoNonfatalFailures\n(expecting a failure)\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure\n  Actual: 2 failures\ngtest_output_test_.cc:#: Non-fatal failure:\nFailed\nExpected non-fatal failure 1.\n\ngtest_output_test_.cc:#: Non-fatal failure:\nFailed\nExpected non-fatal failure 2.\n\n\u001b[0;31m[  FAILED  ] \u001b[mExpectNonfatalFailureTest.FailsWhenThereAreTwoNonfatalFailures\n\u001b[0;32m[ RUN      ] \u001b[mExpectNonfatalFailureTest.FailsWhenThereIsOneFatalFailure\n(expecting a failure)\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure\n  Actual:\ngtest_output_test_.cc:#: Fatal failure:\nFailed\nExpected fatal failure.\n\n\u001b[0;31m[  FAILED  ] \u001b[mExpectNonfatalFailureTest.FailsWhenThereIsOneFatalFailure\n\u001b[0;32m[ RUN      ] \u001b[mExpectNonfatalFailureTest.FailsWhenStatementReturns\n(expecting a failure)\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure\n  Actual: 0 failures\n\u001b[0;31m[  FAILED  ] \u001b[mExpectNonfatalFailureTest.FailsWhenStatementReturns\n\u001b[0;32m[ RUN      ] \u001b[mExpectNonfatalFailureTest.FailsWhenStatementThrows\n(expecting a failure)\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure\n  Actual: 0 failures\n\u001b[0;31m[  FAILED  ] \u001b[mExpectNonfatalFailureTest.FailsWhenStatementThrows\n\u001b[0;32m[----------] \u001b[m8 tests from ExpectFatalFailureTest\n\u001b[0;32m[ RUN      ] \u001b[mExpectFatalFailureTest.CanReferenceGlobalVariables\n\u001b[0;32m[       OK ] \u001b[mExpectFatalFailureTest.CanReferenceGlobalVariables\n\u001b[0;32m[ RUN      ] \u001b[mExpectFatalFailureTest.CanReferenceLocalStaticVariables\n\u001b[0;32m[       OK ] \u001b[mExpectFatalFailureTest.CanReferenceLocalStaticVariables\n\u001b[0;32m[ RUN      ] \u001b[mExpectFatalFailureTest.SucceedsWhenThereIsOneFatalFailure\n\u001b[0;32m[       OK ] \u001b[mExpectFatalFailureTest.SucceedsWhenThereIsOneFatalFailure\n\u001b[0;32m[ RUN      ] \u001b[mExpectFatalFailureTest.FailsWhenThereIsNoFatalFailure\n(expecting a failure)\ngtest.cc:#: Failure\nExpected: 1 fatal failure\n  Actual: 0 failures\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFatalFailureTest.FailsWhenThereIsNoFatalFailure\n\u001b[0;32m[ RUN      ] \u001b[mExpectFatalFailureTest.FailsWhenThereAreTwoFatalFailures\n(expecting a failure)\ngtest.cc:#: Failure\nExpected: 1 fatal failure\n  Actual: 2 failures\ngtest_output_test_.cc:#: Fatal failure:\nFailed\nExpected fatal failure.\n\ngtest_output_test_.cc:#: Fatal failure:\nFailed\nExpected fatal failure.\n\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFatalFailureTest.FailsWhenThereAreTwoFatalFailures\n\u001b[0;32m[ RUN      ] \u001b[mExpectFatalFailureTest.FailsWhenThereIsOneNonfatalFailure\n(expecting a failure)\ngtest.cc:#: Failure\nExpected: 1 fatal failure\n  Actual:\ngtest_output_test_.cc:#: Non-fatal failure:\nFailed\nExpected non-fatal failure.\n\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFatalFailureTest.FailsWhenThereIsOneNonfatalFailure\n\u001b[0;32m[ RUN      ] \u001b[mExpectFatalFailureTest.FailsWhenStatementReturns\n(expecting a failure)\ngtest.cc:#: Failure\nExpected: 1 fatal failure\n  Actual: 0 failures\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFatalFailureTest.FailsWhenStatementReturns\n\u001b[0;32m[ RUN      ] \u001b[mExpectFatalFailureTest.FailsWhenStatementThrows\n(expecting a failure)\ngtest.cc:#: Failure\nExpected: 1 fatal failure\n  Actual: 0 failures\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFatalFailureTest.FailsWhenStatementThrows\n\u001b[0;32m[----------] \u001b[m2 tests from TypedTest/0, where TypeParam = int\n\u001b[0;32m[ RUN      ] \u001b[mTypedTest/0.Success\n\u001b[0;32m[       OK ] \u001b[mTypedTest/0.Success\n\u001b[0;32m[ RUN      ] \u001b[mTypedTest/0.Failure\ngtest_output_test_.cc:#: Failure\nValue of: TypeParam()\n  Actual: 0\nExpected: 1\nExpected failure\n\u001b[0;31m[  FAILED  ] \u001b[mTypedTest/0.Failure, where TypeParam = int\n\u001b[0;32m[----------] \u001b[m2 tests from Unsigned/TypedTestP/0, where TypeParam = unsigned char\n\u001b[0;32m[ RUN      ] \u001b[mUnsigned/TypedTestP/0.Success\n\u001b[0;32m[       OK ] \u001b[mUnsigned/TypedTestP/0.Success\n\u001b[0;32m[ RUN      ] \u001b[mUnsigned/TypedTestP/0.Failure\ngtest_output_test_.cc:#: Failure\nValue of: TypeParam()\n  Actual: '\\0'\nExpected: 1U\nWhich is: 1\nExpected failure\n\u001b[0;31m[  FAILED  ] \u001b[mUnsigned/TypedTestP/0.Failure, where TypeParam = unsigned char\n\u001b[0;32m[----------] \u001b[m2 tests from Unsigned/TypedTestP/1, where TypeParam = unsigned int\n\u001b[0;32m[ RUN      ] \u001b[mUnsigned/TypedTestP/1.Success\n\u001b[0;32m[       OK ] \u001b[mUnsigned/TypedTestP/1.Success\n\u001b[0;32m[ RUN      ] \u001b[mUnsigned/TypedTestP/1.Failure\ngtest_output_test_.cc:#: Failure\nValue of: TypeParam()\n  Actual: 0\nExpected: 1U\nWhich is: 1\nExpected failure\n\u001b[0;31m[  FAILED  ] \u001b[mUnsigned/TypedTestP/1.Failure, where TypeParam = unsigned int\n\u001b[0;32m[----------] \u001b[m4 tests from ExpectFailureTest\n\u001b[0;32m[ RUN      ] \u001b[mExpectFailureTest.ExpectFatalFailure\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 fatal failure\n  Actual:\ngtest_output_test_.cc:#: Success:\nSucceeded\n\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 fatal failure\n  Actual:\ngtest_output_test_.cc:#: Non-fatal failure:\nFailed\nExpected non-fatal failure.\n\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 fatal failure containing \"Some other fatal failure expected.\"\n  Actual:\ngtest_output_test_.cc:#: Fatal failure:\nFailed\nExpected fatal failure.\n\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureTest.ExpectFatalFailure\n\u001b[0;32m[ RUN      ] \u001b[mExpectFailureTest.ExpectNonFatalFailure\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure\n  Actual:\ngtest_output_test_.cc:#: Success:\nSucceeded\n\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure\n  Actual:\ngtest_output_test_.cc:#: Fatal failure:\nFailed\nExpected fatal failure.\n\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure containing \"Some other non-fatal failure.\"\n  Actual:\ngtest_output_test_.cc:#: Non-fatal failure:\nFailed\nExpected non-fatal failure.\n\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureTest.ExpectNonFatalFailure\n\u001b[0;32m[ RUN      ] \u001b[mExpectFailureTest.ExpectFatalFailureOnAllThreads\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 fatal failure\n  Actual:\ngtest_output_test_.cc:#: Success:\nSucceeded\n\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 fatal failure\n  Actual:\ngtest_output_test_.cc:#: Non-fatal failure:\nFailed\nExpected non-fatal failure.\n\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 fatal failure containing \"Some other fatal failure expected.\"\n  Actual:\ngtest_output_test_.cc:#: Fatal failure:\nFailed\nExpected fatal failure.\n\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureTest.ExpectFatalFailureOnAllThreads\n\u001b[0;32m[ RUN      ] \u001b[mExpectFailureTest.ExpectNonFatalFailureOnAllThreads\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure\n  Actual:\ngtest_output_test_.cc:#: Success:\nSucceeded\n\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure\n  Actual:\ngtest_output_test_.cc:#: Fatal failure:\nFailed\nExpected fatal failure.\n\n(expecting 1 failure)\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure containing \"Some other non-fatal failure.\"\n  Actual:\ngtest_output_test_.cc:#: Non-fatal failure:\nFailed\nExpected non-fatal failure.\n\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureTest.ExpectNonFatalFailureOnAllThreads\n\u001b[0;32m[----------] \u001b[m2 tests from ExpectFailureWithThreadsTest\n\u001b[0;32m[ RUN      ] \u001b[mExpectFailureWithThreadsTest.ExpectFatalFailure\n(expecting 2 failures)\ngtest_output_test_.cc:#: Failure\nFailed\nExpected fatal failure.\ngtest.cc:#: Failure\nExpected: 1 fatal failure\n  Actual: 0 failures\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureWithThreadsTest.ExpectFatalFailure\n\u001b[0;32m[ RUN      ] \u001b[mExpectFailureWithThreadsTest.ExpectNonFatalFailure\n(expecting 2 failures)\ngtest_output_test_.cc:#: Failure\nFailed\nExpected non-fatal failure.\ngtest.cc:#: Failure\nExpected: 1 non-fatal failure\n  Actual: 0 failures\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureWithThreadsTest.ExpectNonFatalFailure\n\u001b[0;32m[----------] \u001b[m1 test from ScopedFakeTestPartResultReporterTest\n\u001b[0;32m[ RUN      ] \u001b[mScopedFakeTestPartResultReporterTest.InterceptOnlyCurrentThread\n(expecting 2 failures)\ngtest_output_test_.cc:#: Failure\nFailed\nExpected fatal failure.\ngtest_output_test_.cc:#: Failure\nFailed\nExpected non-fatal failure.\n\u001b[0;31m[  FAILED  ] \u001b[mScopedFakeTestPartResultReporterTest.InterceptOnlyCurrentThread\n\u001b[0;32m[----------] \u001b[m1 test from PrintingFailingParams/FailingParamTest\n\u001b[0;32m[ RUN      ] \u001b[mPrintingFailingParams/FailingParamTest.Fails/0\ngtest_output_test_.cc:#: Failure\nValue of: GetParam()\n  Actual: 2\nExpected: 1\n\u001b[0;31m[  FAILED  ] \u001b[mPrintingFailingParams/FailingParamTest.Fails/0, where GetParam() = 2\n\u001b[0;32m[----------] \u001b[mGlobal test environment tear-down\nBarEnvironment::TearDown() called.\ngtest_output_test_.cc:#: Failure\nFailed\nExpected non-fatal failure.\nFooEnvironment::TearDown() called.\ngtest_output_test_.cc:#: Failure\nFailed\nExpected fatal failure.\n\u001b[0;32m[==========] \u001b[m63 tests from 28 test cases ran.\n\u001b[0;32m[  PASSED  ] \u001b[m21 tests.\n\u001b[0;31m[  FAILED  ] \u001b[m42 tests, listed below:\n\u001b[0;31m[  FAILED  ] \u001b[mNonfatalFailureTest.EscapesStringOperands\n\u001b[0;31m[  FAILED  ] \u001b[mFatalFailureTest.FatalFailureInSubroutine\n\u001b[0;31m[  FAILED  ] \u001b[mFatalFailureTest.FatalFailureInNestedSubroutine\n\u001b[0;31m[  FAILED  ] \u001b[mFatalFailureTest.NonfatalFailureInSubroutine\n\u001b[0;31m[  FAILED  ] \u001b[mLoggingTest.InterleavingLoggingAndAssertions\n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.ObeysScopes\n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.WorksInLoop\n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.WorksInSubroutine\n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.CanBeNested\n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.CanBeRepeated\n\u001b[0;31m[  FAILED  ] \u001b[mSCOPED_TRACETest.WorksConcurrently\n\u001b[0;31m[  FAILED  ] \u001b[mNonFatalFailureInFixtureConstructorTest.FailureInConstructor\n\u001b[0;31m[  FAILED  ] \u001b[mFatalFailureInFixtureConstructorTest.FailureInConstructor\n\u001b[0;31m[  FAILED  ] \u001b[mNonFatalFailureInSetUpTest.FailureInSetUp\n\u001b[0;31m[  FAILED  ] \u001b[mFatalFailureInSetUpTest.FailureInSetUp\n\u001b[0;31m[  FAILED  ] \u001b[mAddFailureAtTest.MessageContainsSpecifiedFileAndLineNumber\n\u001b[0;31m[  FAILED  ] \u001b[mMixedUpTestCaseTest.ThisShouldFail\n\u001b[0;31m[  FAILED  ] \u001b[mMixedUpTestCaseTest.ThisShouldFailToo\n\u001b[0;31m[  FAILED  ] \u001b[mMixedUpTestCaseWithSameTestNameTest.TheSecondTestWithThisNameShouldFail\n\u001b[0;31m[  FAILED  ] \u001b[mTEST_F_before_TEST_in_same_test_case.DefinedUsingTESTAndShouldFail\n\u001b[0;31m[  FAILED  ] \u001b[mTEST_before_TEST_F_in_same_test_case.DefinedUsingTEST_FAndShouldFail\n\u001b[0;31m[  FAILED  ] \u001b[mExpectNonfatalFailureTest.FailsWhenThereIsNoNonfatalFailure\n\u001b[0;31m[  FAILED  ] \u001b[mExpectNonfatalFailureTest.FailsWhenThereAreTwoNonfatalFailures\n\u001b[0;31m[  FAILED  ] \u001b[mExpectNonfatalFailureTest.FailsWhenThereIsOneFatalFailure\n\u001b[0;31m[  FAILED  ] \u001b[mExpectNonfatalFailureTest.FailsWhenStatementReturns\n\u001b[0;31m[  FAILED  ] \u001b[mExpectNonfatalFailureTest.FailsWhenStatementThrows\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFatalFailureTest.FailsWhenThereIsNoFatalFailure\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFatalFailureTest.FailsWhenThereAreTwoFatalFailures\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFatalFailureTest.FailsWhenThereIsOneNonfatalFailure\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFatalFailureTest.FailsWhenStatementReturns\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFatalFailureTest.FailsWhenStatementThrows\n\u001b[0;31m[  FAILED  ] \u001b[mTypedTest/0.Failure, where TypeParam = int\n\u001b[0;31m[  FAILED  ] \u001b[mUnsigned/TypedTestP/0.Failure, where TypeParam = unsigned char\n\u001b[0;31m[  FAILED  ] \u001b[mUnsigned/TypedTestP/1.Failure, where TypeParam = unsigned int\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureTest.ExpectFatalFailure\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureTest.ExpectNonFatalFailure\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureTest.ExpectFatalFailureOnAllThreads\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureTest.ExpectNonFatalFailureOnAllThreads\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureWithThreadsTest.ExpectFatalFailure\n\u001b[0;31m[  FAILED  ] \u001b[mExpectFailureWithThreadsTest.ExpectNonFatalFailure\n\u001b[0;31m[  FAILED  ] \u001b[mScopedFakeTestPartResultReporterTest.InterceptOnlyCurrentThread\n\u001b[0;31m[  FAILED  ] \u001b[mPrintingFailingParams/FailingParamTest.Fails/0, where GetParam() = 2\n\n42 FAILED TESTS\n\u001b[0;33m  YOU HAVE 1 DISABLED TEST\n\n\u001b[mNote: Google Test filter = FatalFailureTest.*:LoggingTest.*\n[==========] Running 4 tests from 2 test cases.\n[----------] Global test environment set-up.\n[----------] 3 tests from FatalFailureTest\n[ RUN      ] FatalFailureTest.FatalFailureInSubroutine\n(expecting a failure that x should be 1)\ngtest_output_test_.cc:#: Failure\nValue of: x\n  Actual: 2\nExpected: 1\n[  FAILED  ] FatalFailureTest.FatalFailureInSubroutine (? ms)\n[ RUN      ] FatalFailureTest.FatalFailureInNestedSubroutine\n(expecting a failure that x should be 1)\ngtest_output_test_.cc:#: Failure\nValue of: x\n  Actual: 2\nExpected: 1\n[  FAILED  ] FatalFailureTest.FatalFailureInNestedSubroutine (? ms)\n[ RUN      ] FatalFailureTest.NonfatalFailureInSubroutine\n(expecting a failure on false)\ngtest_output_test_.cc:#: Failure\nValue of: false\n  Actual: false\nExpected: true\n[  FAILED  ] FatalFailureTest.NonfatalFailureInSubroutine (? ms)\n[----------] 3 tests from FatalFailureTest (? ms total)\n\n[----------] 1 test from LoggingTest\n[ RUN      ] LoggingTest.InterleavingLoggingAndAssertions\n(expecting 2 failures on (3) >= (a[i]))\ni == 0\ni == 1\ngtest_output_test_.cc:#: Failure\nExpected: (3) >= (a[i]), actual: 3 vs 9\ni == 2\ni == 3\ngtest_output_test_.cc:#: Failure\nExpected: (3) >= (a[i]), actual: 3 vs 6\n[  FAILED  ] LoggingTest.InterleavingLoggingAndAssertions (? ms)\n[----------] 1 test from LoggingTest (? ms total)\n\n[----------] Global test environment tear-down\n[==========] 4 tests from 2 test cases ran. (? ms total)\n[  PASSED  ] 0 tests.\n[  FAILED  ] 4 tests, listed below:\n[  FAILED  ] FatalFailureTest.FatalFailureInSubroutine\n[  FAILED  ] FatalFailureTest.FatalFailureInNestedSubroutine\n[  FAILED  ] FatalFailureTest.NonfatalFailureInSubroutine\n[  FAILED  ] LoggingTest.InterleavingLoggingAndAssertions\n\n 4 FAILED TESTS\nNote: Google Test filter = *DISABLED_*\n[==========] Running 1 test from 1 test case.\n[----------] Global test environment set-up.\n[----------] 1 test from DisabledTestsWarningTest\n[ RUN      ] DisabledTestsWarningTest.DISABLED_AlsoRunDisabledTestsFlagSuppressesWarning\n[       OK ] DisabledTestsWarningTest.DISABLED_AlsoRunDisabledTestsFlagSuppressesWarning\n[----------] Global test environment tear-down\n[==========] 1 test from 1 test case ran.\n[  PASSED  ] 1 test.\nNote: Google Test filter = PassingTest.*\nNote: This is test shard 2 of 2.\n[==========] Running 1 test from 1 test case.\n[----------] Global test environment set-up.\n[----------] 1 test from PassingTest\n[ RUN      ] PassingTest.PassingTest2\n[       OK ] PassingTest.PassingTest2\n[----------] Global test environment tear-down\n[==========] 1 test from 1 test case ran.\n[  PASSED  ] 1 test.\n"
  },
  {
    "path": "ext/gtest/test/gtest_pred_impl_unittest.cc",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file is AUTOMATICALLY GENERATED on 10/31/2011 by command\n// 'gen_gtest_pred_impl.py 5'.  DO NOT EDIT BY HAND!\n\n// Regression test for gtest_pred_impl.h\n//\n// This file is generated by a script and quite long.  If you intend to\n// learn how Google Test works by reading its unit tests, read\n// gtest_unittest.cc instead.\n//\n// This is intended as a regression test for the Google Test predicate\n// assertions.  We compile it as part of the gtest_unittest target\n// only to keep the implementation tidy and compact, as it is quite\n// involved to set up the stage for testing Google Test using Google\n// Test itself.\n//\n// Currently, gtest_unittest takes ~11 seconds to run in the testing\n// daemon.  In the future, if it grows too large and needs much more\n// time to finish, we should consider separating this file into a\n// stand-alone regression test.\n\n#include <iostream>\n\n#include \"gtest/gtest.h\"\n#include \"gtest/gtest-spi.h\"\n\n// A user-defined data type.\nstruct Bool {\n  explicit Bool(int val) : value(val != 0) {}\n\n  bool operator>(int n) const { return value > Bool(n).value; }\n\n  Bool operator+(const Bool& rhs) const { return Bool(value + rhs.value); }\n\n  bool operator==(const Bool& rhs) const { return value == rhs.value; }\n\n  bool value;\n};\n\n// Enables Bool to be used in assertions.\nstd::ostream& operator<<(std::ostream& os, const Bool& x) {\n  return os << (x.value ? \"true\" : \"false\");\n}\n\n// Sample functions/functors for testing unary predicate assertions.\n\n// A unary predicate function.\ntemplate <typename T1>\nbool PredFunction1(T1 v1) {\n  return v1 > 0;\n}\n\n// The following two functions are needed to circumvent a bug in\n// gcc 2.95.3, which sometimes has problem with the above template\n// function.\nbool PredFunction1Int(int v1) {\n  return v1 > 0;\n}\nbool PredFunction1Bool(Bool v1) {\n  return v1 > 0;\n}\n\n// A unary predicate functor.\nstruct PredFunctor1 {\n  template <typename T1>\n  bool operator()(const T1& v1) {\n    return v1 > 0;\n  }\n};\n\n// A unary predicate-formatter function.\ntemplate <typename T1>\ntesting::AssertionResult PredFormatFunction1(const char* e1,\n                                             const T1& v1) {\n  if (PredFunction1(v1))\n    return testing::AssertionSuccess();\n\n  return testing::AssertionFailure()\n      << e1\n      << \" is expected to be positive, but evaluates to \"\n      << v1 << \".\";\n}\n\n// A unary predicate-formatter functor.\nstruct PredFormatFunctor1 {\n  template <typename T1>\n  testing::AssertionResult operator()(const char* e1,\n                                      const T1& v1) const {\n    return PredFormatFunction1(e1, v1);\n  }\n};\n\n// Tests for {EXPECT|ASSERT}_PRED_FORMAT1.\n\nclass Predicate1Test : public testing::Test {\n protected:\n  virtual void SetUp() {\n    expected_to_finish_ = true;\n    finished_ = false;\n    n1_ = 0;\n  }\n\n  virtual void TearDown() {\n    // Verifies that each of the predicate's arguments was evaluated\n    // exactly once.\n    EXPECT_EQ(1, n1_) <<\n        \"The predicate assertion didn't evaluate argument 2 \"\n        \"exactly once.\";\n\n    // Verifies that the control flow in the test function is expected.\n    if (expected_to_finish_ && !finished_) {\n      FAIL() << \"The predicate assertion unexpactedly aborted the test.\";\n    } else if (!expected_to_finish_ && finished_) {\n      FAIL() << \"The failed predicate assertion didn't abort the test \"\n                \"as expected.\";\n    }\n  }\n\n  // true iff the test function is expected to run to finish.\n  static bool expected_to_finish_;\n\n  // true iff the test function did run to finish.\n  static bool finished_;\n\n  static int n1_;\n};\n\nbool Predicate1Test::expected_to_finish_;\nbool Predicate1Test::finished_;\nint Predicate1Test::n1_;\n\ntypedef Predicate1Test EXPECT_PRED_FORMAT1Test;\ntypedef Predicate1Test ASSERT_PRED_FORMAT1Test;\ntypedef Predicate1Test EXPECT_PRED1Test;\ntypedef Predicate1Test ASSERT_PRED1Test;\n\n// Tests a successful EXPECT_PRED1 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED1Test, FunctionOnBuiltInTypeSuccess) {\n  EXPECT_PRED1(PredFunction1Int,\n               ++n1_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED1 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED1Test, FunctionOnUserTypeSuccess) {\n  EXPECT_PRED1(PredFunction1Bool,\n               Bool(++n1_));\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED1 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED1Test, FunctorOnBuiltInTypeSuccess) {\n  EXPECT_PRED1(PredFunctor1(),\n               ++n1_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED1 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED1Test, FunctorOnUserTypeSuccess) {\n  EXPECT_PRED1(PredFunctor1(),\n               Bool(++n1_));\n  finished_ = true;\n}\n\n// Tests a failed EXPECT_PRED1 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED1Test, FunctionOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED1(PredFunction1Int,\n                 n1_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED1 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED1Test, FunctionOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED1(PredFunction1Bool,\n                 Bool(n1_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED1 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED1Test, FunctorOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED1(PredFunctor1(),\n                 n1_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED1 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED1Test, FunctorOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED1(PredFunctor1(),\n                 Bool(n1_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful ASSERT_PRED1 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED1Test, FunctionOnBuiltInTypeSuccess) {\n  ASSERT_PRED1(PredFunction1Int,\n               ++n1_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED1 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED1Test, FunctionOnUserTypeSuccess) {\n  ASSERT_PRED1(PredFunction1Bool,\n               Bool(++n1_));\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED1 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED1Test, FunctorOnBuiltInTypeSuccess) {\n  ASSERT_PRED1(PredFunctor1(),\n               ++n1_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED1 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED1Test, FunctorOnUserTypeSuccess) {\n  ASSERT_PRED1(PredFunctor1(),\n               Bool(++n1_));\n  finished_ = true;\n}\n\n// Tests a failed ASSERT_PRED1 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED1Test, FunctionOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED1(PredFunction1Int,\n                 n1_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED1 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED1Test, FunctionOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED1(PredFunction1Bool,\n                 Bool(n1_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED1 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED1Test, FunctorOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED1(PredFunctor1(),\n                 n1_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED1 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED1Test, FunctorOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED1(PredFunctor1(),\n                 Bool(n1_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful EXPECT_PRED_FORMAT1 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnBuiltInTypeSuccess) {\n  EXPECT_PRED_FORMAT1(PredFormatFunction1,\n                      ++n1_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT1 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnUserTypeSuccess) {\n  EXPECT_PRED_FORMAT1(PredFormatFunction1,\n                      Bool(++n1_));\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT1 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnBuiltInTypeSuccess) {\n  EXPECT_PRED_FORMAT1(PredFormatFunctor1(),\n                      ++n1_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT1 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnUserTypeSuccess) {\n  EXPECT_PRED_FORMAT1(PredFormatFunctor1(),\n                      Bool(++n1_));\n  finished_ = true;\n}\n\n// Tests a failed EXPECT_PRED_FORMAT1 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT1(PredFormatFunction1,\n                        n1_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT1 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT1Test, FunctionOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT1(PredFormatFunction1,\n                        Bool(n1_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT1 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT1(PredFormatFunctor1(),\n                        n1_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT1 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT1Test, FunctorOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT1(PredFormatFunctor1(),\n                        Bool(n1_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful ASSERT_PRED_FORMAT1 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnBuiltInTypeSuccess) {\n  ASSERT_PRED_FORMAT1(PredFormatFunction1,\n                      ++n1_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT1 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnUserTypeSuccess) {\n  ASSERT_PRED_FORMAT1(PredFormatFunction1,\n                      Bool(++n1_));\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT1 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnBuiltInTypeSuccess) {\n  ASSERT_PRED_FORMAT1(PredFormatFunctor1(),\n                      ++n1_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT1 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnUserTypeSuccess) {\n  ASSERT_PRED_FORMAT1(PredFormatFunctor1(),\n                      Bool(++n1_));\n  finished_ = true;\n}\n\n// Tests a failed ASSERT_PRED_FORMAT1 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT1(PredFormatFunction1,\n                        n1_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT1 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT1Test, FunctionOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT1(PredFormatFunction1,\n                        Bool(n1_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT1 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT1(PredFormatFunctor1(),\n                        n1_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT1 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT1Test, FunctorOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT1(PredFormatFunctor1(),\n                        Bool(n1_++));\n    finished_ = true;\n  }, \"\");\n}\n// Sample functions/functors for testing binary predicate assertions.\n\n// A binary predicate function.\ntemplate <typename T1, typename T2>\nbool PredFunction2(T1 v1, T2 v2) {\n  return v1 + v2 > 0;\n}\n\n// The following two functions are needed to circumvent a bug in\n// gcc 2.95.3, which sometimes has problem with the above template\n// function.\nbool PredFunction2Int(int v1, int v2) {\n  return v1 + v2 > 0;\n}\nbool PredFunction2Bool(Bool v1, Bool v2) {\n  return v1 + v2 > 0;\n}\n\n// A binary predicate functor.\nstruct PredFunctor2 {\n  template <typename T1, typename T2>\n  bool operator()(const T1& v1,\n                  const T2& v2) {\n    return v1 + v2 > 0;\n  }\n};\n\n// A binary predicate-formatter function.\ntemplate <typename T1, typename T2>\ntesting::AssertionResult PredFormatFunction2(const char* e1,\n                                             const char* e2,\n                                             const T1& v1,\n                                             const T2& v2) {\n  if (PredFunction2(v1, v2))\n    return testing::AssertionSuccess();\n\n  return testing::AssertionFailure()\n      << e1 << \" + \" << e2\n      << \" is expected to be positive, but evaluates to \"\n      << v1 + v2 << \".\";\n}\n\n// A binary predicate-formatter functor.\nstruct PredFormatFunctor2 {\n  template <typename T1, typename T2>\n  testing::AssertionResult operator()(const char* e1,\n                                      const char* e2,\n                                      const T1& v1,\n                                      const T2& v2) const {\n    return PredFormatFunction2(e1, e2, v1, v2);\n  }\n};\n\n// Tests for {EXPECT|ASSERT}_PRED_FORMAT2.\n\nclass Predicate2Test : public testing::Test {\n protected:\n  virtual void SetUp() {\n    expected_to_finish_ = true;\n    finished_ = false;\n    n1_ = n2_ = 0;\n  }\n\n  virtual void TearDown() {\n    // Verifies that each of the predicate's arguments was evaluated\n    // exactly once.\n    EXPECT_EQ(1, n1_) <<\n        \"The predicate assertion didn't evaluate argument 2 \"\n        \"exactly once.\";\n    EXPECT_EQ(1, n2_) <<\n        \"The predicate assertion didn't evaluate argument 3 \"\n        \"exactly once.\";\n\n    // Verifies that the control flow in the test function is expected.\n    if (expected_to_finish_ && !finished_) {\n      FAIL() << \"The predicate assertion unexpactedly aborted the test.\";\n    } else if (!expected_to_finish_ && finished_) {\n      FAIL() << \"The failed predicate assertion didn't abort the test \"\n                \"as expected.\";\n    }\n  }\n\n  // true iff the test function is expected to run to finish.\n  static bool expected_to_finish_;\n\n  // true iff the test function did run to finish.\n  static bool finished_;\n\n  static int n1_;\n  static int n2_;\n};\n\nbool Predicate2Test::expected_to_finish_;\nbool Predicate2Test::finished_;\nint Predicate2Test::n1_;\nint Predicate2Test::n2_;\n\ntypedef Predicate2Test EXPECT_PRED_FORMAT2Test;\ntypedef Predicate2Test ASSERT_PRED_FORMAT2Test;\ntypedef Predicate2Test EXPECT_PRED2Test;\ntypedef Predicate2Test ASSERT_PRED2Test;\n\n// Tests a successful EXPECT_PRED2 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED2Test, FunctionOnBuiltInTypeSuccess) {\n  EXPECT_PRED2(PredFunction2Int,\n               ++n1_,\n               ++n2_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED2 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED2Test, FunctionOnUserTypeSuccess) {\n  EXPECT_PRED2(PredFunction2Bool,\n               Bool(++n1_),\n               Bool(++n2_));\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED2 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED2Test, FunctorOnBuiltInTypeSuccess) {\n  EXPECT_PRED2(PredFunctor2(),\n               ++n1_,\n               ++n2_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED2 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED2Test, FunctorOnUserTypeSuccess) {\n  EXPECT_PRED2(PredFunctor2(),\n               Bool(++n1_),\n               Bool(++n2_));\n  finished_ = true;\n}\n\n// Tests a failed EXPECT_PRED2 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED2Test, FunctionOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED2(PredFunction2Int,\n                 n1_++,\n                 n2_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED2 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED2Test, FunctionOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED2(PredFunction2Bool,\n                 Bool(n1_++),\n                 Bool(n2_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED2 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED2Test, FunctorOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED2(PredFunctor2(),\n                 n1_++,\n                 n2_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED2 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED2Test, FunctorOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED2(PredFunctor2(),\n                 Bool(n1_++),\n                 Bool(n2_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful ASSERT_PRED2 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED2Test, FunctionOnBuiltInTypeSuccess) {\n  ASSERT_PRED2(PredFunction2Int,\n               ++n1_,\n               ++n2_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED2 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED2Test, FunctionOnUserTypeSuccess) {\n  ASSERT_PRED2(PredFunction2Bool,\n               Bool(++n1_),\n               Bool(++n2_));\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED2 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED2Test, FunctorOnBuiltInTypeSuccess) {\n  ASSERT_PRED2(PredFunctor2(),\n               ++n1_,\n               ++n2_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED2 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED2Test, FunctorOnUserTypeSuccess) {\n  ASSERT_PRED2(PredFunctor2(),\n               Bool(++n1_),\n               Bool(++n2_));\n  finished_ = true;\n}\n\n// Tests a failed ASSERT_PRED2 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED2Test, FunctionOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED2(PredFunction2Int,\n                 n1_++,\n                 n2_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED2 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED2Test, FunctionOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED2(PredFunction2Bool,\n                 Bool(n1_++),\n                 Bool(n2_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED2 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED2Test, FunctorOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED2(PredFunctor2(),\n                 n1_++,\n                 n2_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED2 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED2Test, FunctorOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED2(PredFunctor2(),\n                 Bool(n1_++),\n                 Bool(n2_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful EXPECT_PRED_FORMAT2 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnBuiltInTypeSuccess) {\n  EXPECT_PRED_FORMAT2(PredFormatFunction2,\n                      ++n1_,\n                      ++n2_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT2 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnUserTypeSuccess) {\n  EXPECT_PRED_FORMAT2(PredFormatFunction2,\n                      Bool(++n1_),\n                      Bool(++n2_));\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT2 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnBuiltInTypeSuccess) {\n  EXPECT_PRED_FORMAT2(PredFormatFunctor2(),\n                      ++n1_,\n                      ++n2_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT2 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnUserTypeSuccess) {\n  EXPECT_PRED_FORMAT2(PredFormatFunctor2(),\n                      Bool(++n1_),\n                      Bool(++n2_));\n  finished_ = true;\n}\n\n// Tests a failed EXPECT_PRED_FORMAT2 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT2(PredFormatFunction2,\n                        n1_++,\n                        n2_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT2 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT2Test, FunctionOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT2(PredFormatFunction2,\n                        Bool(n1_++),\n                        Bool(n2_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT2 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT2(PredFormatFunctor2(),\n                        n1_++,\n                        n2_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT2 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT2Test, FunctorOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT2(PredFormatFunctor2(),\n                        Bool(n1_++),\n                        Bool(n2_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful ASSERT_PRED_FORMAT2 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnBuiltInTypeSuccess) {\n  ASSERT_PRED_FORMAT2(PredFormatFunction2,\n                      ++n1_,\n                      ++n2_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT2 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnUserTypeSuccess) {\n  ASSERT_PRED_FORMAT2(PredFormatFunction2,\n                      Bool(++n1_),\n                      Bool(++n2_));\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT2 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnBuiltInTypeSuccess) {\n  ASSERT_PRED_FORMAT2(PredFormatFunctor2(),\n                      ++n1_,\n                      ++n2_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT2 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnUserTypeSuccess) {\n  ASSERT_PRED_FORMAT2(PredFormatFunctor2(),\n                      Bool(++n1_),\n                      Bool(++n2_));\n  finished_ = true;\n}\n\n// Tests a failed ASSERT_PRED_FORMAT2 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT2(PredFormatFunction2,\n                        n1_++,\n                        n2_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT2 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT2Test, FunctionOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT2(PredFormatFunction2,\n                        Bool(n1_++),\n                        Bool(n2_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT2 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT2(PredFormatFunctor2(),\n                        n1_++,\n                        n2_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT2 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT2Test, FunctorOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT2(PredFormatFunctor2(),\n                        Bool(n1_++),\n                        Bool(n2_++));\n    finished_ = true;\n  }, \"\");\n}\n// Sample functions/functors for testing ternary predicate assertions.\n\n// A ternary predicate function.\ntemplate <typename T1, typename T2, typename T3>\nbool PredFunction3(T1 v1, T2 v2, T3 v3) {\n  return v1 + v2 + v3 > 0;\n}\n\n// The following two functions are needed to circumvent a bug in\n// gcc 2.95.3, which sometimes has problem with the above template\n// function.\nbool PredFunction3Int(int v1, int v2, int v3) {\n  return v1 + v2 + v3 > 0;\n}\nbool PredFunction3Bool(Bool v1, Bool v2, Bool v3) {\n  return v1 + v2 + v3 > 0;\n}\n\n// A ternary predicate functor.\nstruct PredFunctor3 {\n  template <typename T1, typename T2, typename T3>\n  bool operator()(const T1& v1,\n                  const T2& v2,\n                  const T3& v3) {\n    return v1 + v2 + v3 > 0;\n  }\n};\n\n// A ternary predicate-formatter function.\ntemplate <typename T1, typename T2, typename T3>\ntesting::AssertionResult PredFormatFunction3(const char* e1,\n                                             const char* e2,\n                                             const char* e3,\n                                             const T1& v1,\n                                             const T2& v2,\n                                             const T3& v3) {\n  if (PredFunction3(v1, v2, v3))\n    return testing::AssertionSuccess();\n\n  return testing::AssertionFailure()\n      << e1 << \" + \" << e2 << \" + \" << e3\n      << \" is expected to be positive, but evaluates to \"\n      << v1 + v2 + v3 << \".\";\n}\n\n// A ternary predicate-formatter functor.\nstruct PredFormatFunctor3 {\n  template <typename T1, typename T2, typename T3>\n  testing::AssertionResult operator()(const char* e1,\n                                      const char* e2,\n                                      const char* e3,\n                                      const T1& v1,\n                                      const T2& v2,\n                                      const T3& v3) const {\n    return PredFormatFunction3(e1, e2, e3, v1, v2, v3);\n  }\n};\n\n// Tests for {EXPECT|ASSERT}_PRED_FORMAT3.\n\nclass Predicate3Test : public testing::Test {\n protected:\n  virtual void SetUp() {\n    expected_to_finish_ = true;\n    finished_ = false;\n    n1_ = n2_ = n3_ = 0;\n  }\n\n  virtual void TearDown() {\n    // Verifies that each of the predicate's arguments was evaluated\n    // exactly once.\n    EXPECT_EQ(1, n1_) <<\n        \"The predicate assertion didn't evaluate argument 2 \"\n        \"exactly once.\";\n    EXPECT_EQ(1, n2_) <<\n        \"The predicate assertion didn't evaluate argument 3 \"\n        \"exactly once.\";\n    EXPECT_EQ(1, n3_) <<\n        \"The predicate assertion didn't evaluate argument 4 \"\n        \"exactly once.\";\n\n    // Verifies that the control flow in the test function is expected.\n    if (expected_to_finish_ && !finished_) {\n      FAIL() << \"The predicate assertion unexpactedly aborted the test.\";\n    } else if (!expected_to_finish_ && finished_) {\n      FAIL() << \"The failed predicate assertion didn't abort the test \"\n                \"as expected.\";\n    }\n  }\n\n  // true iff the test function is expected to run to finish.\n  static bool expected_to_finish_;\n\n  // true iff the test function did run to finish.\n  static bool finished_;\n\n  static int n1_;\n  static int n2_;\n  static int n3_;\n};\n\nbool Predicate3Test::expected_to_finish_;\nbool Predicate3Test::finished_;\nint Predicate3Test::n1_;\nint Predicate3Test::n2_;\nint Predicate3Test::n3_;\n\ntypedef Predicate3Test EXPECT_PRED_FORMAT3Test;\ntypedef Predicate3Test ASSERT_PRED_FORMAT3Test;\ntypedef Predicate3Test EXPECT_PRED3Test;\ntypedef Predicate3Test ASSERT_PRED3Test;\n\n// Tests a successful EXPECT_PRED3 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED3Test, FunctionOnBuiltInTypeSuccess) {\n  EXPECT_PRED3(PredFunction3Int,\n               ++n1_,\n               ++n2_,\n               ++n3_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED3 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED3Test, FunctionOnUserTypeSuccess) {\n  EXPECT_PRED3(PredFunction3Bool,\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_));\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED3 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED3Test, FunctorOnBuiltInTypeSuccess) {\n  EXPECT_PRED3(PredFunctor3(),\n               ++n1_,\n               ++n2_,\n               ++n3_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED3 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED3Test, FunctorOnUserTypeSuccess) {\n  EXPECT_PRED3(PredFunctor3(),\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_));\n  finished_ = true;\n}\n\n// Tests a failed EXPECT_PRED3 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED3Test, FunctionOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED3(PredFunction3Int,\n                 n1_++,\n                 n2_++,\n                 n3_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED3 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED3Test, FunctionOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED3(PredFunction3Bool,\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED3 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED3Test, FunctorOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED3(PredFunctor3(),\n                 n1_++,\n                 n2_++,\n                 n3_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED3 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED3Test, FunctorOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED3(PredFunctor3(),\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful ASSERT_PRED3 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED3Test, FunctionOnBuiltInTypeSuccess) {\n  ASSERT_PRED3(PredFunction3Int,\n               ++n1_,\n               ++n2_,\n               ++n3_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED3 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED3Test, FunctionOnUserTypeSuccess) {\n  ASSERT_PRED3(PredFunction3Bool,\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_));\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED3 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED3Test, FunctorOnBuiltInTypeSuccess) {\n  ASSERT_PRED3(PredFunctor3(),\n               ++n1_,\n               ++n2_,\n               ++n3_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED3 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED3Test, FunctorOnUserTypeSuccess) {\n  ASSERT_PRED3(PredFunctor3(),\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_));\n  finished_ = true;\n}\n\n// Tests a failed ASSERT_PRED3 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED3Test, FunctionOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED3(PredFunction3Int,\n                 n1_++,\n                 n2_++,\n                 n3_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED3 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED3Test, FunctionOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED3(PredFunction3Bool,\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED3 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED3Test, FunctorOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED3(PredFunctor3(),\n                 n1_++,\n                 n2_++,\n                 n3_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED3 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED3Test, FunctorOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED3(PredFunctor3(),\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful EXPECT_PRED_FORMAT3 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnBuiltInTypeSuccess) {\n  EXPECT_PRED_FORMAT3(PredFormatFunction3,\n                      ++n1_,\n                      ++n2_,\n                      ++n3_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT3 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnUserTypeSuccess) {\n  EXPECT_PRED_FORMAT3(PredFormatFunction3,\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_));\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT3 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnBuiltInTypeSuccess) {\n  EXPECT_PRED_FORMAT3(PredFormatFunctor3(),\n                      ++n1_,\n                      ++n2_,\n                      ++n3_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT3 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnUserTypeSuccess) {\n  EXPECT_PRED_FORMAT3(PredFormatFunctor3(),\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_));\n  finished_ = true;\n}\n\n// Tests a failed EXPECT_PRED_FORMAT3 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT3(PredFormatFunction3,\n                        n1_++,\n                        n2_++,\n                        n3_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT3 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT3Test, FunctionOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT3(PredFormatFunction3,\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT3 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT3(PredFormatFunctor3(),\n                        n1_++,\n                        n2_++,\n                        n3_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT3 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT3Test, FunctorOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT3(PredFormatFunctor3(),\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful ASSERT_PRED_FORMAT3 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnBuiltInTypeSuccess) {\n  ASSERT_PRED_FORMAT3(PredFormatFunction3,\n                      ++n1_,\n                      ++n2_,\n                      ++n3_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT3 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnUserTypeSuccess) {\n  ASSERT_PRED_FORMAT3(PredFormatFunction3,\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_));\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT3 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnBuiltInTypeSuccess) {\n  ASSERT_PRED_FORMAT3(PredFormatFunctor3(),\n                      ++n1_,\n                      ++n2_,\n                      ++n3_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT3 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnUserTypeSuccess) {\n  ASSERT_PRED_FORMAT3(PredFormatFunctor3(),\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_));\n  finished_ = true;\n}\n\n// Tests a failed ASSERT_PRED_FORMAT3 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT3(PredFormatFunction3,\n                        n1_++,\n                        n2_++,\n                        n3_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT3 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT3Test, FunctionOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT3(PredFormatFunction3,\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT3 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT3(PredFormatFunctor3(),\n                        n1_++,\n                        n2_++,\n                        n3_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT3 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT3Test, FunctorOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT3(PredFormatFunctor3(),\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++));\n    finished_ = true;\n  }, \"\");\n}\n// Sample functions/functors for testing 4-ary predicate assertions.\n\n// A 4-ary predicate function.\ntemplate <typename T1, typename T2, typename T3, typename T4>\nbool PredFunction4(T1 v1, T2 v2, T3 v3, T4 v4) {\n  return v1 + v2 + v3 + v4 > 0;\n}\n\n// The following two functions are needed to circumvent a bug in\n// gcc 2.95.3, which sometimes has problem with the above template\n// function.\nbool PredFunction4Int(int v1, int v2, int v3, int v4) {\n  return v1 + v2 + v3 + v4 > 0;\n}\nbool PredFunction4Bool(Bool v1, Bool v2, Bool v3, Bool v4) {\n  return v1 + v2 + v3 + v4 > 0;\n}\n\n// A 4-ary predicate functor.\nstruct PredFunctor4 {\n  template <typename T1, typename T2, typename T3, typename T4>\n  bool operator()(const T1& v1,\n                  const T2& v2,\n                  const T3& v3,\n                  const T4& v4) {\n    return v1 + v2 + v3 + v4 > 0;\n  }\n};\n\n// A 4-ary predicate-formatter function.\ntemplate <typename T1, typename T2, typename T3, typename T4>\ntesting::AssertionResult PredFormatFunction4(const char* e1,\n                                             const char* e2,\n                                             const char* e3,\n                                             const char* e4,\n                                             const T1& v1,\n                                             const T2& v2,\n                                             const T3& v3,\n                                             const T4& v4) {\n  if (PredFunction4(v1, v2, v3, v4))\n    return testing::AssertionSuccess();\n\n  return testing::AssertionFailure()\n      << e1 << \" + \" << e2 << \" + \" << e3 << \" + \" << e4\n      << \" is expected to be positive, but evaluates to \"\n      << v1 + v2 + v3 + v4 << \".\";\n}\n\n// A 4-ary predicate-formatter functor.\nstruct PredFormatFunctor4 {\n  template <typename T1, typename T2, typename T3, typename T4>\n  testing::AssertionResult operator()(const char* e1,\n                                      const char* e2,\n                                      const char* e3,\n                                      const char* e4,\n                                      const T1& v1,\n                                      const T2& v2,\n                                      const T3& v3,\n                                      const T4& v4) const {\n    return PredFormatFunction4(e1, e2, e3, e4, v1, v2, v3, v4);\n  }\n};\n\n// Tests for {EXPECT|ASSERT}_PRED_FORMAT4.\n\nclass Predicate4Test : public testing::Test {\n protected:\n  virtual void SetUp() {\n    expected_to_finish_ = true;\n    finished_ = false;\n    n1_ = n2_ = n3_ = n4_ = 0;\n  }\n\n  virtual void TearDown() {\n    // Verifies that each of the predicate's arguments was evaluated\n    // exactly once.\n    EXPECT_EQ(1, n1_) <<\n        \"The predicate assertion didn't evaluate argument 2 \"\n        \"exactly once.\";\n    EXPECT_EQ(1, n2_) <<\n        \"The predicate assertion didn't evaluate argument 3 \"\n        \"exactly once.\";\n    EXPECT_EQ(1, n3_) <<\n        \"The predicate assertion didn't evaluate argument 4 \"\n        \"exactly once.\";\n    EXPECT_EQ(1, n4_) <<\n        \"The predicate assertion didn't evaluate argument 5 \"\n        \"exactly once.\";\n\n    // Verifies that the control flow in the test function is expected.\n    if (expected_to_finish_ && !finished_) {\n      FAIL() << \"The predicate assertion unexpactedly aborted the test.\";\n    } else if (!expected_to_finish_ && finished_) {\n      FAIL() << \"The failed predicate assertion didn't abort the test \"\n                \"as expected.\";\n    }\n  }\n\n  // true iff the test function is expected to run to finish.\n  static bool expected_to_finish_;\n\n  // true iff the test function did run to finish.\n  static bool finished_;\n\n  static int n1_;\n  static int n2_;\n  static int n3_;\n  static int n4_;\n};\n\nbool Predicate4Test::expected_to_finish_;\nbool Predicate4Test::finished_;\nint Predicate4Test::n1_;\nint Predicate4Test::n2_;\nint Predicate4Test::n3_;\nint Predicate4Test::n4_;\n\ntypedef Predicate4Test EXPECT_PRED_FORMAT4Test;\ntypedef Predicate4Test ASSERT_PRED_FORMAT4Test;\ntypedef Predicate4Test EXPECT_PRED4Test;\ntypedef Predicate4Test ASSERT_PRED4Test;\n\n// Tests a successful EXPECT_PRED4 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED4Test, FunctionOnBuiltInTypeSuccess) {\n  EXPECT_PRED4(PredFunction4Int,\n               ++n1_,\n               ++n2_,\n               ++n3_,\n               ++n4_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED4 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED4Test, FunctionOnUserTypeSuccess) {\n  EXPECT_PRED4(PredFunction4Bool,\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_),\n               Bool(++n4_));\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED4 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED4Test, FunctorOnBuiltInTypeSuccess) {\n  EXPECT_PRED4(PredFunctor4(),\n               ++n1_,\n               ++n2_,\n               ++n3_,\n               ++n4_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED4 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED4Test, FunctorOnUserTypeSuccess) {\n  EXPECT_PRED4(PredFunctor4(),\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_),\n               Bool(++n4_));\n  finished_ = true;\n}\n\n// Tests a failed EXPECT_PRED4 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED4Test, FunctionOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED4(PredFunction4Int,\n                 n1_++,\n                 n2_++,\n                 n3_++,\n                 n4_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED4 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED4Test, FunctionOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED4(PredFunction4Bool,\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++),\n                 Bool(n4_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED4 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED4Test, FunctorOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED4(PredFunctor4(),\n                 n1_++,\n                 n2_++,\n                 n3_++,\n                 n4_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED4 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED4Test, FunctorOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED4(PredFunctor4(),\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++),\n                 Bool(n4_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful ASSERT_PRED4 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED4Test, FunctionOnBuiltInTypeSuccess) {\n  ASSERT_PRED4(PredFunction4Int,\n               ++n1_,\n               ++n2_,\n               ++n3_,\n               ++n4_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED4 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED4Test, FunctionOnUserTypeSuccess) {\n  ASSERT_PRED4(PredFunction4Bool,\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_),\n               Bool(++n4_));\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED4 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED4Test, FunctorOnBuiltInTypeSuccess) {\n  ASSERT_PRED4(PredFunctor4(),\n               ++n1_,\n               ++n2_,\n               ++n3_,\n               ++n4_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED4 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED4Test, FunctorOnUserTypeSuccess) {\n  ASSERT_PRED4(PredFunctor4(),\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_),\n               Bool(++n4_));\n  finished_ = true;\n}\n\n// Tests a failed ASSERT_PRED4 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED4Test, FunctionOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED4(PredFunction4Int,\n                 n1_++,\n                 n2_++,\n                 n3_++,\n                 n4_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED4 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED4Test, FunctionOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED4(PredFunction4Bool,\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++),\n                 Bool(n4_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED4 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED4Test, FunctorOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED4(PredFunctor4(),\n                 n1_++,\n                 n2_++,\n                 n3_++,\n                 n4_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED4 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED4Test, FunctorOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED4(PredFunctor4(),\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++),\n                 Bool(n4_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful EXPECT_PRED_FORMAT4 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnBuiltInTypeSuccess) {\n  EXPECT_PRED_FORMAT4(PredFormatFunction4,\n                      ++n1_,\n                      ++n2_,\n                      ++n3_,\n                      ++n4_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT4 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnUserTypeSuccess) {\n  EXPECT_PRED_FORMAT4(PredFormatFunction4,\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_),\n                      Bool(++n4_));\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT4 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnBuiltInTypeSuccess) {\n  EXPECT_PRED_FORMAT4(PredFormatFunctor4(),\n                      ++n1_,\n                      ++n2_,\n                      ++n3_,\n                      ++n4_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT4 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnUserTypeSuccess) {\n  EXPECT_PRED_FORMAT4(PredFormatFunctor4(),\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_),\n                      Bool(++n4_));\n  finished_ = true;\n}\n\n// Tests a failed EXPECT_PRED_FORMAT4 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT4(PredFormatFunction4,\n                        n1_++,\n                        n2_++,\n                        n3_++,\n                        n4_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT4 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT4Test, FunctionOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT4(PredFormatFunction4,\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++),\n                        Bool(n4_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT4 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT4(PredFormatFunctor4(),\n                        n1_++,\n                        n2_++,\n                        n3_++,\n                        n4_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT4 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT4Test, FunctorOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT4(PredFormatFunctor4(),\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++),\n                        Bool(n4_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful ASSERT_PRED_FORMAT4 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnBuiltInTypeSuccess) {\n  ASSERT_PRED_FORMAT4(PredFormatFunction4,\n                      ++n1_,\n                      ++n2_,\n                      ++n3_,\n                      ++n4_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT4 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnUserTypeSuccess) {\n  ASSERT_PRED_FORMAT4(PredFormatFunction4,\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_),\n                      Bool(++n4_));\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT4 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnBuiltInTypeSuccess) {\n  ASSERT_PRED_FORMAT4(PredFormatFunctor4(),\n                      ++n1_,\n                      ++n2_,\n                      ++n3_,\n                      ++n4_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT4 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnUserTypeSuccess) {\n  ASSERT_PRED_FORMAT4(PredFormatFunctor4(),\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_),\n                      Bool(++n4_));\n  finished_ = true;\n}\n\n// Tests a failed ASSERT_PRED_FORMAT4 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT4(PredFormatFunction4,\n                        n1_++,\n                        n2_++,\n                        n3_++,\n                        n4_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT4 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT4Test, FunctionOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT4(PredFormatFunction4,\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++),\n                        Bool(n4_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT4 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT4(PredFormatFunctor4(),\n                        n1_++,\n                        n2_++,\n                        n3_++,\n                        n4_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT4 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT4Test, FunctorOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT4(PredFormatFunctor4(),\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++),\n                        Bool(n4_++));\n    finished_ = true;\n  }, \"\");\n}\n// Sample functions/functors for testing 5-ary predicate assertions.\n\n// A 5-ary predicate function.\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5>\nbool PredFunction5(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) {\n  return v1 + v2 + v3 + v4 + v5 > 0;\n}\n\n// The following two functions are needed to circumvent a bug in\n// gcc 2.95.3, which sometimes has problem with the above template\n// function.\nbool PredFunction5Int(int v1, int v2, int v3, int v4, int v5) {\n  return v1 + v2 + v3 + v4 + v5 > 0;\n}\nbool PredFunction5Bool(Bool v1, Bool v2, Bool v3, Bool v4, Bool v5) {\n  return v1 + v2 + v3 + v4 + v5 > 0;\n}\n\n// A 5-ary predicate functor.\nstruct PredFunctor5 {\n  template <typename T1, typename T2, typename T3, typename T4, typename T5>\n  bool operator()(const T1& v1,\n                  const T2& v2,\n                  const T3& v3,\n                  const T4& v4,\n                  const T5& v5) {\n    return v1 + v2 + v3 + v4 + v5 > 0;\n  }\n};\n\n// A 5-ary predicate-formatter function.\ntemplate <typename T1, typename T2, typename T3, typename T4, typename T5>\ntesting::AssertionResult PredFormatFunction5(const char* e1,\n                                             const char* e2,\n                                             const char* e3,\n                                             const char* e4,\n                                             const char* e5,\n                                             const T1& v1,\n                                             const T2& v2,\n                                             const T3& v3,\n                                             const T4& v4,\n                                             const T5& v5) {\n  if (PredFunction5(v1, v2, v3, v4, v5))\n    return testing::AssertionSuccess();\n\n  return testing::AssertionFailure()\n      << e1 << \" + \" << e2 << \" + \" << e3 << \" + \" << e4 << \" + \" << e5\n      << \" is expected to be positive, but evaluates to \"\n      << v1 + v2 + v3 + v4 + v5 << \".\";\n}\n\n// A 5-ary predicate-formatter functor.\nstruct PredFormatFunctor5 {\n  template <typename T1, typename T2, typename T3, typename T4, typename T5>\n  testing::AssertionResult operator()(const char* e1,\n                                      const char* e2,\n                                      const char* e3,\n                                      const char* e4,\n                                      const char* e5,\n                                      const T1& v1,\n                                      const T2& v2,\n                                      const T3& v3,\n                                      const T4& v4,\n                                      const T5& v5) const {\n    return PredFormatFunction5(e1, e2, e3, e4, e5, v1, v2, v3, v4, v5);\n  }\n};\n\n// Tests for {EXPECT|ASSERT}_PRED_FORMAT5.\n\nclass Predicate5Test : public testing::Test {\n protected:\n  virtual void SetUp() {\n    expected_to_finish_ = true;\n    finished_ = false;\n    n1_ = n2_ = n3_ = n4_ = n5_ = 0;\n  }\n\n  virtual void TearDown() {\n    // Verifies that each of the predicate's arguments was evaluated\n    // exactly once.\n    EXPECT_EQ(1, n1_) <<\n        \"The predicate assertion didn't evaluate argument 2 \"\n        \"exactly once.\";\n    EXPECT_EQ(1, n2_) <<\n        \"The predicate assertion didn't evaluate argument 3 \"\n        \"exactly once.\";\n    EXPECT_EQ(1, n3_) <<\n        \"The predicate assertion didn't evaluate argument 4 \"\n        \"exactly once.\";\n    EXPECT_EQ(1, n4_) <<\n        \"The predicate assertion didn't evaluate argument 5 \"\n        \"exactly once.\";\n    EXPECT_EQ(1, n5_) <<\n        \"The predicate assertion didn't evaluate argument 6 \"\n        \"exactly once.\";\n\n    // Verifies that the control flow in the test function is expected.\n    if (expected_to_finish_ && !finished_) {\n      FAIL() << \"The predicate assertion unexpactedly aborted the test.\";\n    } else if (!expected_to_finish_ && finished_) {\n      FAIL() << \"The failed predicate assertion didn't abort the test \"\n                \"as expected.\";\n    }\n  }\n\n  // true iff the test function is expected to run to finish.\n  static bool expected_to_finish_;\n\n  // true iff the test function did run to finish.\n  static bool finished_;\n\n  static int n1_;\n  static int n2_;\n  static int n3_;\n  static int n4_;\n  static int n5_;\n};\n\nbool Predicate5Test::expected_to_finish_;\nbool Predicate5Test::finished_;\nint Predicate5Test::n1_;\nint Predicate5Test::n2_;\nint Predicate5Test::n3_;\nint Predicate5Test::n4_;\nint Predicate5Test::n5_;\n\ntypedef Predicate5Test EXPECT_PRED_FORMAT5Test;\ntypedef Predicate5Test ASSERT_PRED_FORMAT5Test;\ntypedef Predicate5Test EXPECT_PRED5Test;\ntypedef Predicate5Test ASSERT_PRED5Test;\n\n// Tests a successful EXPECT_PRED5 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED5Test, FunctionOnBuiltInTypeSuccess) {\n  EXPECT_PRED5(PredFunction5Int,\n               ++n1_,\n               ++n2_,\n               ++n3_,\n               ++n4_,\n               ++n5_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED5 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED5Test, FunctionOnUserTypeSuccess) {\n  EXPECT_PRED5(PredFunction5Bool,\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_),\n               Bool(++n4_),\n               Bool(++n5_));\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED5 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED5Test, FunctorOnBuiltInTypeSuccess) {\n  EXPECT_PRED5(PredFunctor5(),\n               ++n1_,\n               ++n2_,\n               ++n3_,\n               ++n4_,\n               ++n5_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED5 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED5Test, FunctorOnUserTypeSuccess) {\n  EXPECT_PRED5(PredFunctor5(),\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_),\n               Bool(++n4_),\n               Bool(++n5_));\n  finished_ = true;\n}\n\n// Tests a failed EXPECT_PRED5 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED5Test, FunctionOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED5(PredFunction5Int,\n                 n1_++,\n                 n2_++,\n                 n3_++,\n                 n4_++,\n                 n5_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED5 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED5Test, FunctionOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED5(PredFunction5Bool,\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++),\n                 Bool(n4_++),\n                 Bool(n5_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED5 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED5Test, FunctorOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED5(PredFunctor5(),\n                 n1_++,\n                 n2_++,\n                 n3_++,\n                 n4_++,\n                 n5_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED5 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED5Test, FunctorOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED5(PredFunctor5(),\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++),\n                 Bool(n4_++),\n                 Bool(n5_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful ASSERT_PRED5 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED5Test, FunctionOnBuiltInTypeSuccess) {\n  ASSERT_PRED5(PredFunction5Int,\n               ++n1_,\n               ++n2_,\n               ++n3_,\n               ++n4_,\n               ++n5_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED5 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED5Test, FunctionOnUserTypeSuccess) {\n  ASSERT_PRED5(PredFunction5Bool,\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_),\n               Bool(++n4_),\n               Bool(++n5_));\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED5 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED5Test, FunctorOnBuiltInTypeSuccess) {\n  ASSERT_PRED5(PredFunctor5(),\n               ++n1_,\n               ++n2_,\n               ++n3_,\n               ++n4_,\n               ++n5_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED5 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED5Test, FunctorOnUserTypeSuccess) {\n  ASSERT_PRED5(PredFunctor5(),\n               Bool(++n1_),\n               Bool(++n2_),\n               Bool(++n3_),\n               Bool(++n4_),\n               Bool(++n5_));\n  finished_ = true;\n}\n\n// Tests a failed ASSERT_PRED5 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED5Test, FunctionOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED5(PredFunction5Int,\n                 n1_++,\n                 n2_++,\n                 n3_++,\n                 n4_++,\n                 n5_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED5 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED5Test, FunctionOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED5(PredFunction5Bool,\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++),\n                 Bool(n4_++),\n                 Bool(n5_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED5 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED5Test, FunctorOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED5(PredFunctor5(),\n                 n1_++,\n                 n2_++,\n                 n3_++,\n                 n4_++,\n                 n5_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED5 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED5Test, FunctorOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED5(PredFunctor5(),\n                 Bool(n1_++),\n                 Bool(n2_++),\n                 Bool(n3_++),\n                 Bool(n4_++),\n                 Bool(n5_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful EXPECT_PRED_FORMAT5 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnBuiltInTypeSuccess) {\n  EXPECT_PRED_FORMAT5(PredFormatFunction5,\n                      ++n1_,\n                      ++n2_,\n                      ++n3_,\n                      ++n4_,\n                      ++n5_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT5 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnUserTypeSuccess) {\n  EXPECT_PRED_FORMAT5(PredFormatFunction5,\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_),\n                      Bool(++n4_),\n                      Bool(++n5_));\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT5 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnBuiltInTypeSuccess) {\n  EXPECT_PRED_FORMAT5(PredFormatFunctor5(),\n                      ++n1_,\n                      ++n2_,\n                      ++n3_,\n                      ++n4_,\n                      ++n5_);\n  finished_ = true;\n}\n\n// Tests a successful EXPECT_PRED_FORMAT5 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnUserTypeSuccess) {\n  EXPECT_PRED_FORMAT5(PredFormatFunctor5(),\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_),\n                      Bool(++n4_),\n                      Bool(++n5_));\n  finished_ = true;\n}\n\n// Tests a failed EXPECT_PRED_FORMAT5 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT5(PredFormatFunction5,\n                        n1_++,\n                        n2_++,\n                        n3_++,\n                        n4_++,\n                        n5_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT5 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT5Test, FunctionOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT5(PredFormatFunction5,\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++),\n                        Bool(n4_++),\n                        Bool(n5_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT5 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnBuiltInTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT5(PredFormatFunctor5(),\n                        n1_++,\n                        n2_++,\n                        n3_++,\n                        n4_++,\n                        n5_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed EXPECT_PRED_FORMAT5 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(EXPECT_PRED_FORMAT5Test, FunctorOnUserTypeFailure) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT5(PredFormatFunctor5(),\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++),\n                        Bool(n4_++),\n                        Bool(n5_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a successful ASSERT_PRED_FORMAT5 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnBuiltInTypeSuccess) {\n  ASSERT_PRED_FORMAT5(PredFormatFunction5,\n                      ++n1_,\n                      ++n2_,\n                      ++n3_,\n                      ++n4_,\n                      ++n5_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT5 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnUserTypeSuccess) {\n  ASSERT_PRED_FORMAT5(PredFormatFunction5,\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_),\n                      Bool(++n4_),\n                      Bool(++n5_));\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT5 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnBuiltInTypeSuccess) {\n  ASSERT_PRED_FORMAT5(PredFormatFunctor5(),\n                      ++n1_,\n                      ++n2_,\n                      ++n3_,\n                      ++n4_,\n                      ++n5_);\n  finished_ = true;\n}\n\n// Tests a successful ASSERT_PRED_FORMAT5 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnUserTypeSuccess) {\n  ASSERT_PRED_FORMAT5(PredFormatFunctor5(),\n                      Bool(++n1_),\n                      Bool(++n2_),\n                      Bool(++n3_),\n                      Bool(++n4_),\n                      Bool(++n5_));\n  finished_ = true;\n}\n\n// Tests a failed ASSERT_PRED_FORMAT5 where the\n// predicate-formatter is a function on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT5(PredFormatFunction5,\n                        n1_++,\n                        n2_++,\n                        n3_++,\n                        n4_++,\n                        n5_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT5 where the\n// predicate-formatter is a function on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT5Test, FunctionOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT5(PredFormatFunction5,\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++),\n                        Bool(n4_++),\n                        Bool(n5_++));\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT5 where the\n// predicate-formatter is a functor on a built-in type (int).\nTEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnBuiltInTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT5(PredFormatFunctor5(),\n                        n1_++,\n                        n2_++,\n                        n3_++,\n                        n4_++,\n                        n5_++);\n    finished_ = true;\n  }, \"\");\n}\n\n// Tests a failed ASSERT_PRED_FORMAT5 where the\n// predicate-formatter is a functor on a user-defined type (Bool).\nTEST_F(ASSERT_PRED_FORMAT5Test, FunctorOnUserTypeFailure) {\n  expected_to_finish_ = false;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT5(PredFormatFunctor5(),\n                        Bool(n1_++),\n                        Bool(n2_++),\n                        Bool(n3_++),\n                        Bool(n4_++),\n                        Bool(n5_++));\n    finished_ = true;\n  }, \"\");\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest_premature_exit_test.cc",
    "content": "// Copyright 2013, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// Tests that Google Test manipulates the premature-exit-detection\n// file correctly.\n\n#include <stdio.h>\n\n#include \"gtest/gtest.h\"\n\nusing ::testing::InitGoogleTest;\nusing ::testing::Test;\nusing ::testing::internal::posix::GetEnv;\nusing ::testing::internal::posix::Stat;\nusing ::testing::internal::posix::StatStruct;\n\nnamespace {\n\n// Is the TEST_PREMATURE_EXIT_FILE environment variable expected to be\n// set?\nconst bool kTestPrematureExitFileEnvVarShouldBeSet = false;\n\nclass PrematureExitTest : public Test {\n public:\n  // Returns true iff the given file exists.\n  static bool FileExists(const char* filepath) {\n    StatStruct stat;\n    return Stat(filepath, &stat) == 0;\n  }\n\n protected:\n  PrematureExitTest() {\n    premature_exit_file_path_ = GetEnv(\"TEST_PREMATURE_EXIT_FILE\");\n\n    // Normalize NULL to \"\" for ease of handling.\n    if (premature_exit_file_path_ == NULL) {\n      premature_exit_file_path_ = \"\";\n    }\n  }\n\n  // Returns true iff the premature-exit file exists.\n  bool PrematureExitFileExists() const {\n    return FileExists(premature_exit_file_path_);\n  }\n\n  const char* premature_exit_file_path_;\n};\n\ntypedef PrematureExitTest PrematureExitDeathTest;\n\n// Tests that:\n//   - the premature-exit file exists during the execution of a\n//     death test (EXPECT_DEATH*), and\n//   - a death test doesn't interfere with the main test process's\n//     handling of the premature-exit file.\nTEST_F(PrematureExitDeathTest, FileExistsDuringExecutionOfDeathTest) {\n  if (*premature_exit_file_path_ == '\\0') {\n    return;\n  }\n\n  EXPECT_DEATH_IF_SUPPORTED({\n      // If the file exists, crash the process such that the main test\n      // process will catch the (expected) crash and report a success;\n      // otherwise don't crash, which will cause the main test process\n      // to report that the death test has failed.\n      if (PrematureExitFileExists()) {\n        exit(1);\n      }\n    }, \"\");\n}\n\n// Tests that TEST_PREMATURE_EXIT_FILE is set where it's expected to\n// be set.\nTEST_F(PrematureExitTest, TestPrematureExitFileEnvVarIsSet) {\n  if (kTestPrematureExitFileEnvVarShouldBeSet) {\n    const char* const filepath = GetEnv(\"TEST_PREMATURE_EXIT_FILE\");\n    ASSERT_TRUE(filepath != NULL);\n    ASSERT_NE(*filepath, '\\0');\n  }\n}\n\n// Tests that the premature-exit file exists during the execution of a\n// normal (non-death) test.\nTEST_F(PrematureExitTest, PrematureExitFileExistsDuringTestExecution) {\n  if (*premature_exit_file_path_ == '\\0') {\n    return;\n  }\n\n  EXPECT_TRUE(PrematureExitFileExists())\n      << \" file \" << premature_exit_file_path_\n      << \" should exist during test execution, but doesn't.\";\n}\n\n}  // namespace\n\nint main(int argc, char **argv) {\n  InitGoogleTest(&argc, argv);\n  const int exit_code = RUN_ALL_TESTS();\n\n  // Test that the premature-exit file is deleted upon return from\n  // RUN_ALL_TESTS().\n  const char* const filepath = GetEnv(\"TEST_PREMATURE_EXIT_FILE\");\n  if (filepath != NULL && *filepath != '\\0') {\n    if (PrematureExitTest::FileExists(filepath)) {\n      printf(\n          \"File %s shouldn't exist after the test program finishes, but does.\",\n          filepath);\n      return 1;\n    }\n  }\n\n  return exit_code;\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest_prod_test.cc",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// Unit test for include/gtest/gtest_prod.h.\n\n#include \"gtest/gtest.h\"\n#include \"test/production.h\"\n\n// Tests that private members can be accessed from a TEST declared as\n// a friend of the class.\nTEST(PrivateCodeTest, CanAccessPrivateMembers) {\n  PrivateCode a;\n  EXPECT_EQ(0, a.x_);\n\n  a.set_x(1);\n  EXPECT_EQ(1, a.x_);\n}\n\ntypedef testing::Test PrivateCodeFixtureTest;\n\n// Tests that private members can be accessed from a TEST_F declared\n// as a friend of the class.\nTEST_F(PrivateCodeFixtureTest, CanAccessPrivateMembers) {\n  PrivateCode a;\n  EXPECT_EQ(0, a.x_);\n\n  a.set_x(2);\n  EXPECT_EQ(2, a.x_);\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest_repeat_test.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Tests the --gtest_repeat=number flag.\n\n#include <stdlib.h>\n#include <iostream>\n#include \"gtest/gtest.h\"\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick is to\n// prevent a user from accidentally including gtest-internal-inl.h in\n// his code.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\nnamespace testing {\n\nGTEST_DECLARE_string_(death_test_style);\nGTEST_DECLARE_string_(filter);\nGTEST_DECLARE_int32_(repeat);\n\n}  // namespace testing\n\nusing testing::GTEST_FLAG(death_test_style);\nusing testing::GTEST_FLAG(filter);\nusing testing::GTEST_FLAG(repeat);\n\nnamespace {\n\n// We need this when we are testing Google Test itself and therefore\n// cannot use Google Test assertions.\n#define GTEST_CHECK_INT_EQ_(expected, actual) \\\n  do {\\\n    const int expected_val = (expected);\\\n    const int actual_val = (actual);\\\n    if (::testing::internal::IsTrue(expected_val != actual_val)) {\\\n      ::std::cout << \"Value of: \" #actual \"\\n\"\\\n                  << \"  Actual: \" << actual_val << \"\\n\"\\\n                  << \"Expected: \" #expected \"\\n\"\\\n                  << \"Which is: \" << expected_val << \"\\n\";\\\n      ::testing::internal::posix::Abort();\\\n    }\\\n  } while (::testing::internal::AlwaysFalse())\n\n\n// Used for verifying that global environment set-up and tear-down are\n// inside the gtest_repeat loop.\n\nint g_environment_set_up_count = 0;\nint g_environment_tear_down_count = 0;\n\nclass MyEnvironment : public testing::Environment {\n public:\n  MyEnvironment() {}\n  virtual void SetUp() { g_environment_set_up_count++; }\n  virtual void TearDown() { g_environment_tear_down_count++; }\n};\n\n// A test that should fail.\n\nint g_should_fail_count = 0;\n\nTEST(FooTest, ShouldFail) {\n  g_should_fail_count++;\n  EXPECT_EQ(0, 1) << \"Expected failure.\";\n}\n\n// A test that should pass.\n\nint g_should_pass_count = 0;\n\nTEST(FooTest, ShouldPass) {\n  g_should_pass_count++;\n}\n\n// A test that contains a thread-safe death test and a fast death\n// test.  It should pass.\n\nint g_death_test_count = 0;\n\nTEST(BarDeathTest, ThreadSafeAndFast) {\n  g_death_test_count++;\n\n  GTEST_FLAG(death_test_style) = \"threadsafe\";\n  EXPECT_DEATH_IF_SUPPORTED(::testing::internal::posix::Abort(), \"\");\n\n  GTEST_FLAG(death_test_style) = \"fast\";\n  EXPECT_DEATH_IF_SUPPORTED(::testing::internal::posix::Abort(), \"\");\n}\n\n#if GTEST_HAS_PARAM_TEST\nint g_param_test_count = 0;\n\nconst int kNumberOfParamTests = 10;\n\nclass MyParamTest : public testing::TestWithParam<int> {};\n\nTEST_P(MyParamTest, ShouldPass) {\n  // TODO(vladl@google.com): Make parameter value checking robust\n  //                         WRT order of tests.\n  GTEST_CHECK_INT_EQ_(g_param_test_count % kNumberOfParamTests, GetParam());\n  g_param_test_count++;\n}\nINSTANTIATE_TEST_CASE_P(MyParamSequence,\n                        MyParamTest,\n                        testing::Range(0, kNumberOfParamTests));\n#endif  // GTEST_HAS_PARAM_TEST\n\n// Resets the count for each test.\nvoid ResetCounts() {\n  g_environment_set_up_count = 0;\n  g_environment_tear_down_count = 0;\n  g_should_fail_count = 0;\n  g_should_pass_count = 0;\n  g_death_test_count = 0;\n#if GTEST_HAS_PARAM_TEST\n  g_param_test_count = 0;\n#endif  // GTEST_HAS_PARAM_TEST\n}\n\n// Checks that the count for each test is expected.\nvoid CheckCounts(int expected) {\n  GTEST_CHECK_INT_EQ_(expected, g_environment_set_up_count);\n  GTEST_CHECK_INT_EQ_(expected, g_environment_tear_down_count);\n  GTEST_CHECK_INT_EQ_(expected, g_should_fail_count);\n  GTEST_CHECK_INT_EQ_(expected, g_should_pass_count);\n  GTEST_CHECK_INT_EQ_(expected, g_death_test_count);\n#if GTEST_HAS_PARAM_TEST\n  GTEST_CHECK_INT_EQ_(expected * kNumberOfParamTests, g_param_test_count);\n#endif  // GTEST_HAS_PARAM_TEST\n}\n\n// Tests the behavior of Google Test when --gtest_repeat is not specified.\nvoid TestRepeatUnspecified() {\n  ResetCounts();\n  GTEST_CHECK_INT_EQ_(1, RUN_ALL_TESTS());\n  CheckCounts(1);\n}\n\n// Tests the behavior of Google Test when --gtest_repeat has the given value.\nvoid TestRepeat(int repeat) {\n  GTEST_FLAG(repeat) = repeat;\n\n  ResetCounts();\n  GTEST_CHECK_INT_EQ_(repeat > 0 ? 1 : 0, RUN_ALL_TESTS());\n  CheckCounts(repeat);\n}\n\n// Tests using --gtest_repeat when --gtest_filter specifies an empty\n// set of tests.\nvoid TestRepeatWithEmptyFilter(int repeat) {\n  GTEST_FLAG(repeat) = repeat;\n  GTEST_FLAG(filter) = \"None\";\n\n  ResetCounts();\n  GTEST_CHECK_INT_EQ_(0, RUN_ALL_TESTS());\n  CheckCounts(0);\n}\n\n// Tests using --gtest_repeat when --gtest_filter specifies a set of\n// successful tests.\nvoid TestRepeatWithFilterForSuccessfulTests(int repeat) {\n  GTEST_FLAG(repeat) = repeat;\n  GTEST_FLAG(filter) = \"*-*ShouldFail\";\n\n  ResetCounts();\n  GTEST_CHECK_INT_EQ_(0, RUN_ALL_TESTS());\n  GTEST_CHECK_INT_EQ_(repeat, g_environment_set_up_count);\n  GTEST_CHECK_INT_EQ_(repeat, g_environment_tear_down_count);\n  GTEST_CHECK_INT_EQ_(0, g_should_fail_count);\n  GTEST_CHECK_INT_EQ_(repeat, g_should_pass_count);\n  GTEST_CHECK_INT_EQ_(repeat, g_death_test_count);\n#if GTEST_HAS_PARAM_TEST\n  GTEST_CHECK_INT_EQ_(repeat * kNumberOfParamTests, g_param_test_count);\n#endif  // GTEST_HAS_PARAM_TEST\n}\n\n// Tests using --gtest_repeat when --gtest_filter specifies a set of\n// failed tests.\nvoid TestRepeatWithFilterForFailedTests(int repeat) {\n  GTEST_FLAG(repeat) = repeat;\n  GTEST_FLAG(filter) = \"*ShouldFail\";\n\n  ResetCounts();\n  GTEST_CHECK_INT_EQ_(1, RUN_ALL_TESTS());\n  GTEST_CHECK_INT_EQ_(repeat, g_environment_set_up_count);\n  GTEST_CHECK_INT_EQ_(repeat, g_environment_tear_down_count);\n  GTEST_CHECK_INT_EQ_(repeat, g_should_fail_count);\n  GTEST_CHECK_INT_EQ_(0, g_should_pass_count);\n  GTEST_CHECK_INT_EQ_(0, g_death_test_count);\n#if GTEST_HAS_PARAM_TEST\n  GTEST_CHECK_INT_EQ_(0, g_param_test_count);\n#endif  // GTEST_HAS_PARAM_TEST\n}\n\n}  // namespace\n\nint main(int argc, char **argv) {\n  testing::InitGoogleTest(&argc, argv);\n  testing::AddGlobalTestEnvironment(new MyEnvironment);\n\n  TestRepeatUnspecified();\n  TestRepeat(0);\n  TestRepeat(1);\n  TestRepeat(5);\n\n  TestRepeatWithEmptyFilter(2);\n  TestRepeatWithEmptyFilter(3);\n\n  TestRepeatWithFilterForSuccessfulTests(3);\n\n  TestRepeatWithFilterForFailedTests(4);\n\n  // It would be nice to verify that the tests indeed loop forever\n  // when GTEST_FLAG(repeat) is negative, but this test will be quite\n  // complicated to write.  Since this flag is for interactive\n  // debugging only and doesn't affect the normal test result, such a\n  // test would be an overkill.\n\n  printf(\"PASS\\n\");\n  return 0;\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest_shuffle_test.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2009 Google Inc. All Rights Reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Verifies that test shuffling works.\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport gtest_test_utils\n\n# Command to run the gtest_shuffle_test_ program.\nCOMMAND = gtest_test_utils.GetTestExecutablePath('gtest_shuffle_test_')\n\n# The environment variables for test sharding.\nTOTAL_SHARDS_ENV_VAR = 'GTEST_TOTAL_SHARDS'\nSHARD_INDEX_ENV_VAR = 'GTEST_SHARD_INDEX'\n\nTEST_FILTER = 'A*.A:A*.B:C*'\n\nALL_TESTS = []\nACTIVE_TESTS = []\nFILTERED_TESTS = []\nSHARDED_TESTS = []\n\nSHUFFLED_ALL_TESTS = []\nSHUFFLED_ACTIVE_TESTS = []\nSHUFFLED_FILTERED_TESTS = []\nSHUFFLED_SHARDED_TESTS = []\n\n\ndef AlsoRunDisabledTestsFlag():\n  return '--gtest_also_run_disabled_tests'\n\n\ndef FilterFlag(test_filter):\n  return '--gtest_filter=%s' % (test_filter,)\n\n\ndef RepeatFlag(n):\n  return '--gtest_repeat=%s' % (n,)\n\n\ndef ShuffleFlag():\n  return '--gtest_shuffle'\n\n\ndef RandomSeedFlag(n):\n  return '--gtest_random_seed=%s' % (n,)\n\n\ndef RunAndReturnOutput(extra_env, args):\n  \"\"\"Runs the test program and returns its output.\"\"\"\n\n  environ_copy = os.environ.copy()\n  environ_copy.update(extra_env)\n\n  return gtest_test_utils.Subprocess([COMMAND] + args, env=environ_copy).output\n\n\ndef GetTestsForAllIterations(extra_env, args):\n  \"\"\"Runs the test program and returns a list of test lists.\n\n  Args:\n    extra_env: a map from environment variables to their values\n    args: command line flags to pass to gtest_shuffle_test_\n\n  Returns:\n    A list where the i-th element is the list of tests run in the i-th\n    test iteration.\n  \"\"\"\n\n  test_iterations = []\n  for line in RunAndReturnOutput(extra_env, args).split('\\n'):\n    if line.startswith('----'):\n      tests = []\n      test_iterations.append(tests)\n    elif line.strip():\n      tests.append(line.strip())  # 'TestCaseName.TestName'\n\n  return test_iterations\n\n\ndef GetTestCases(tests):\n  \"\"\"Returns a list of test cases in the given full test names.\n\n  Args:\n    tests: a list of full test names\n\n  Returns:\n    A list of test cases from 'tests', in their original order.\n    Consecutive duplicates are removed.\n  \"\"\"\n\n  test_cases = []\n  for test in tests:\n    test_case = test.split('.')[0]\n    if not test_case in test_cases:\n      test_cases.append(test_case)\n\n  return test_cases\n\n\ndef CalculateTestLists():\n  \"\"\"Calculates the list of tests run under different flags.\"\"\"\n\n  if not ALL_TESTS:\n    ALL_TESTS.extend(\n        GetTestsForAllIterations({}, [AlsoRunDisabledTestsFlag()])[0])\n\n  if not ACTIVE_TESTS:\n    ACTIVE_TESTS.extend(GetTestsForAllIterations({}, [])[0])\n\n  if not FILTERED_TESTS:\n    FILTERED_TESTS.extend(\n        GetTestsForAllIterations({}, [FilterFlag(TEST_FILTER)])[0])\n\n  if not SHARDED_TESTS:\n    SHARDED_TESTS.extend(\n        GetTestsForAllIterations({TOTAL_SHARDS_ENV_VAR: '3',\n                                  SHARD_INDEX_ENV_VAR: '1'},\n                                 [])[0])\n\n  if not SHUFFLED_ALL_TESTS:\n    SHUFFLED_ALL_TESTS.extend(GetTestsForAllIterations(\n        {}, [AlsoRunDisabledTestsFlag(), ShuffleFlag(), RandomSeedFlag(1)])[0])\n\n  if not SHUFFLED_ACTIVE_TESTS:\n    SHUFFLED_ACTIVE_TESTS.extend(GetTestsForAllIterations(\n        {}, [ShuffleFlag(), RandomSeedFlag(1)])[0])\n\n  if not SHUFFLED_FILTERED_TESTS:\n    SHUFFLED_FILTERED_TESTS.extend(GetTestsForAllIterations(\n        {}, [ShuffleFlag(), RandomSeedFlag(1), FilterFlag(TEST_FILTER)])[0])\n\n  if not SHUFFLED_SHARDED_TESTS:\n    SHUFFLED_SHARDED_TESTS.extend(\n        GetTestsForAllIterations({TOTAL_SHARDS_ENV_VAR: '3',\n                                  SHARD_INDEX_ENV_VAR: '1'},\n                                 [ShuffleFlag(), RandomSeedFlag(1)])[0])\n\n\nclass GTestShuffleUnitTest(gtest_test_utils.TestCase):\n  \"\"\"Tests test shuffling.\"\"\"\n\n  def setUp(self):\n    CalculateTestLists()\n\n  def testShufflePreservesNumberOfTests(self):\n    self.assertEqual(len(ALL_TESTS), len(SHUFFLED_ALL_TESTS))\n    self.assertEqual(len(ACTIVE_TESTS), len(SHUFFLED_ACTIVE_TESTS))\n    self.assertEqual(len(FILTERED_TESTS), len(SHUFFLED_FILTERED_TESTS))\n    self.assertEqual(len(SHARDED_TESTS), len(SHUFFLED_SHARDED_TESTS))\n\n  def testShuffleChangesTestOrder(self):\n    self.assert_(SHUFFLED_ALL_TESTS != ALL_TESTS, SHUFFLED_ALL_TESTS)\n    self.assert_(SHUFFLED_ACTIVE_TESTS != ACTIVE_TESTS, SHUFFLED_ACTIVE_TESTS)\n    self.assert_(SHUFFLED_FILTERED_TESTS != FILTERED_TESTS,\n                 SHUFFLED_FILTERED_TESTS)\n    self.assert_(SHUFFLED_SHARDED_TESTS != SHARDED_TESTS,\n                 SHUFFLED_SHARDED_TESTS)\n\n  def testShuffleChangesTestCaseOrder(self):\n    self.assert_(GetTestCases(SHUFFLED_ALL_TESTS) != GetTestCases(ALL_TESTS),\n                 GetTestCases(SHUFFLED_ALL_TESTS))\n    self.assert_(\n        GetTestCases(SHUFFLED_ACTIVE_TESTS) != GetTestCases(ACTIVE_TESTS),\n        GetTestCases(SHUFFLED_ACTIVE_TESTS))\n    self.assert_(\n        GetTestCases(SHUFFLED_FILTERED_TESTS) != GetTestCases(FILTERED_TESTS),\n        GetTestCases(SHUFFLED_FILTERED_TESTS))\n    self.assert_(\n        GetTestCases(SHUFFLED_SHARDED_TESTS) != GetTestCases(SHARDED_TESTS),\n        GetTestCases(SHUFFLED_SHARDED_TESTS))\n\n  def testShuffleDoesNotRepeatTest(self):\n    for test in SHUFFLED_ALL_TESTS:\n      self.assertEqual(1, SHUFFLED_ALL_TESTS.count(test),\n                       '%s appears more than once' % (test,))\n    for test in SHUFFLED_ACTIVE_TESTS:\n      self.assertEqual(1, SHUFFLED_ACTIVE_TESTS.count(test),\n                       '%s appears more than once' % (test,))\n    for test in SHUFFLED_FILTERED_TESTS:\n      self.assertEqual(1, SHUFFLED_FILTERED_TESTS.count(test),\n                       '%s appears more than once' % (test,))\n    for test in SHUFFLED_SHARDED_TESTS:\n      self.assertEqual(1, SHUFFLED_SHARDED_TESTS.count(test),\n                       '%s appears more than once' % (test,))\n\n  def testShuffleDoesNotCreateNewTest(self):\n    for test in SHUFFLED_ALL_TESTS:\n      self.assert_(test in ALL_TESTS, '%s is an invalid test' % (test,))\n    for test in SHUFFLED_ACTIVE_TESTS:\n      self.assert_(test in ACTIVE_TESTS, '%s is an invalid test' % (test,))\n    for test in SHUFFLED_FILTERED_TESTS:\n      self.assert_(test in FILTERED_TESTS, '%s is an invalid test' % (test,))\n    for test in SHUFFLED_SHARDED_TESTS:\n      self.assert_(test in SHARDED_TESTS, '%s is an invalid test' % (test,))\n\n  def testShuffleIncludesAllTests(self):\n    for test in ALL_TESTS:\n      self.assert_(test in SHUFFLED_ALL_TESTS, '%s is missing' % (test,))\n    for test in ACTIVE_TESTS:\n      self.assert_(test in SHUFFLED_ACTIVE_TESTS, '%s is missing' % (test,))\n    for test in FILTERED_TESTS:\n      self.assert_(test in SHUFFLED_FILTERED_TESTS, '%s is missing' % (test,))\n    for test in SHARDED_TESTS:\n      self.assert_(test in SHUFFLED_SHARDED_TESTS, '%s is missing' % (test,))\n\n  def testShuffleLeavesDeathTestsAtFront(self):\n    non_death_test_found = False\n    for test in SHUFFLED_ACTIVE_TESTS:\n      if 'DeathTest.' in test:\n        self.assert_(not non_death_test_found,\n                     '%s appears after a non-death test' % (test,))\n      else:\n        non_death_test_found = True\n\n  def _VerifyTestCasesDoNotInterleave(self, tests):\n    test_cases = []\n    for test in tests:\n      [test_case, _] = test.split('.')\n      if test_cases and test_cases[-1] != test_case:\n        test_cases.append(test_case)\n        self.assertEqual(1, test_cases.count(test_case),\n                         'Test case %s is not grouped together in %s' %\n                         (test_case, tests))\n\n  def testShuffleDoesNotInterleaveTestCases(self):\n    self._VerifyTestCasesDoNotInterleave(SHUFFLED_ALL_TESTS)\n    self._VerifyTestCasesDoNotInterleave(SHUFFLED_ACTIVE_TESTS)\n    self._VerifyTestCasesDoNotInterleave(SHUFFLED_FILTERED_TESTS)\n    self._VerifyTestCasesDoNotInterleave(SHUFFLED_SHARDED_TESTS)\n\n  def testShuffleRestoresOrderAfterEachIteration(self):\n    # Get the test lists in all 3 iterations, using random seed 1, 2,\n    # and 3 respectively.  Google Test picks a different seed in each\n    # iteration, and this test depends on the current implementation\n    # picking successive numbers.  This dependency is not ideal, but\n    # makes the test much easier to write.\n    [tests_in_iteration1, tests_in_iteration2, tests_in_iteration3] = (\n        GetTestsForAllIterations(\n            {}, [ShuffleFlag(), RandomSeedFlag(1), RepeatFlag(3)]))\n\n    # Make sure running the tests with random seed 1 gets the same\n    # order as in iteration 1 above.\n    [tests_with_seed1] = GetTestsForAllIterations(\n        {}, [ShuffleFlag(), RandomSeedFlag(1)])\n    self.assertEqual(tests_in_iteration1, tests_with_seed1)\n\n    # Make sure running the tests with random seed 2 gets the same\n    # order as in iteration 2 above.  Success means that Google Test\n    # correctly restores the test order before re-shuffling at the\n    # beginning of iteration 2.\n    [tests_with_seed2] = GetTestsForAllIterations(\n        {}, [ShuffleFlag(), RandomSeedFlag(2)])\n    self.assertEqual(tests_in_iteration2, tests_with_seed2)\n\n    # Make sure running the tests with random seed 3 gets the same\n    # order as in iteration 3 above.  Success means that Google Test\n    # correctly restores the test order before re-shuffling at the\n    # beginning of iteration 3.\n    [tests_with_seed3] = GetTestsForAllIterations(\n        {}, [ShuffleFlag(), RandomSeedFlag(3)])\n    self.assertEqual(tests_in_iteration3, tests_with_seed3)\n\n  def testShuffleGeneratesNewOrderInEachIteration(self):\n    [tests_in_iteration1, tests_in_iteration2, tests_in_iteration3] = (\n        GetTestsForAllIterations(\n            {}, [ShuffleFlag(), RandomSeedFlag(1), RepeatFlag(3)]))\n\n    self.assert_(tests_in_iteration1 != tests_in_iteration2,\n                 tests_in_iteration1)\n    self.assert_(tests_in_iteration1 != tests_in_iteration3,\n                 tests_in_iteration1)\n    self.assert_(tests_in_iteration2 != tests_in_iteration3,\n                 tests_in_iteration2)\n\n  def testShuffleShardedTestsPreservesPartition(self):\n    # If we run M tests on N shards, the same M tests should be run in\n    # total, regardless of the random seeds used by the shards.\n    [tests1] = GetTestsForAllIterations({TOTAL_SHARDS_ENV_VAR: '3',\n                                         SHARD_INDEX_ENV_VAR: '0'},\n                                        [ShuffleFlag(), RandomSeedFlag(1)])\n    [tests2] = GetTestsForAllIterations({TOTAL_SHARDS_ENV_VAR: '3',\n                                         SHARD_INDEX_ENV_VAR: '1'},\n                                        [ShuffleFlag(), RandomSeedFlag(20)])\n    [tests3] = GetTestsForAllIterations({TOTAL_SHARDS_ENV_VAR: '3',\n                                         SHARD_INDEX_ENV_VAR: '2'},\n                                        [ShuffleFlag(), RandomSeedFlag(25)])\n    sorted_sharded_tests = tests1 + tests2 + tests3\n    sorted_sharded_tests.sort()\n    sorted_active_tests = []\n    sorted_active_tests.extend(ACTIVE_TESTS)\n    sorted_active_tests.sort()\n    self.assertEqual(sorted_active_tests, sorted_sharded_tests)\n\nif __name__ == '__main__':\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "ext/gtest/test/gtest_shuffle_test_.cc",
    "content": "// Copyright 2009, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Verifies that test shuffling works.\n\n#include \"gtest/gtest.h\"\n\nnamespace {\n\nusing ::testing::EmptyTestEventListener;\nusing ::testing::InitGoogleTest;\nusing ::testing::Message;\nusing ::testing::Test;\nusing ::testing::TestEventListeners;\nusing ::testing::TestInfo;\nusing ::testing::UnitTest;\nusing ::testing::internal::scoped_ptr;\n\n// The test methods are empty, as the sole purpose of this program is\n// to print the test names before/after shuffling.\n\nclass A : public Test {};\nTEST_F(A, A) {}\nTEST_F(A, B) {}\n\nTEST(ADeathTest, A) {}\nTEST(ADeathTest, B) {}\nTEST(ADeathTest, C) {}\n\nTEST(B, A) {}\nTEST(B, B) {}\nTEST(B, C) {}\nTEST(B, DISABLED_D) {}\nTEST(B, DISABLED_E) {}\n\nTEST(BDeathTest, A) {}\nTEST(BDeathTest, B) {}\n\nTEST(C, A) {}\nTEST(C, B) {}\nTEST(C, C) {}\nTEST(C, DISABLED_D) {}\n\nTEST(CDeathTest, A) {}\n\nTEST(DISABLED_D, A) {}\nTEST(DISABLED_D, DISABLED_B) {}\n\n// This printer prints the full test names only, starting each test\n// iteration with a \"----\" marker.\nclass TestNamePrinter : public EmptyTestEventListener {\n public:\n  virtual void OnTestIterationStart(const UnitTest& /* unit_test */,\n                                    int /* iteration */) {\n    printf(\"----\\n\");\n  }\n\n  virtual void OnTestStart(const TestInfo& test_info) {\n    printf(\"%s.%s\\n\", test_info.test_case_name(), test_info.name());\n  }\n};\n\n}  // namespace\n\nint main(int argc, char **argv) {\n  InitGoogleTest(&argc, argv);\n\n  // Replaces the default printer with TestNamePrinter, which prints\n  // the test name only.\n  TestEventListeners& listeners = UnitTest::GetInstance()->listeners();\n  delete listeners.Release(listeners.default_result_printer());\n  listeners.Append(new TestNamePrinter);\n\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest_sole_header_test.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: mheule@google.com (Markus Heule)\n//\n// This test verifies that it's possible to use Google Test by including\n// the gtest.h header file alone.\n\n#include \"gtest/gtest.h\"\n\nnamespace {\n\nvoid Subroutine() {\n  EXPECT_EQ(42, 42);\n}\n\nTEST(NoFatalFailureTest, ExpectNoFatalFailure) {\n  EXPECT_NO_FATAL_FAILURE(;);\n  EXPECT_NO_FATAL_FAILURE(SUCCEED());\n  EXPECT_NO_FATAL_FAILURE(Subroutine());\n  EXPECT_NO_FATAL_FAILURE({ SUCCEED(); });\n}\n\nTEST(NoFatalFailureTest, AssertNoFatalFailure) {\n  ASSERT_NO_FATAL_FAILURE(;);\n  ASSERT_NO_FATAL_FAILURE(SUCCEED());\n  ASSERT_NO_FATAL_FAILURE(Subroutine());\n  ASSERT_NO_FATAL_FAILURE({ SUCCEED(); });\n}\n\n}  // namespace\n"
  },
  {
    "path": "ext/gtest/test/gtest_stress_test.cc",
    "content": "// Copyright 2007, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Tests that SCOPED_TRACE() and various Google Test assertions can be\n// used in a large number of threads concurrently.\n\n#include \"gtest/gtest.h\"\n\n#include <iostream>\n#include <vector>\n\n// We must define this macro in order to #include\n// gtest-internal-inl.h.  This is how Google Test prevents a user from\n// accidentally depending on its internal implementation.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\n#if GTEST_IS_THREADSAFE\n\nnamespace testing {\nnamespace {\n\nusing internal::Notification;\nusing internal::TestPropertyKeyIs;\nusing internal::ThreadWithParam;\nusing internal::scoped_ptr;\n\n// In order to run tests in this file, for platforms where Google Test is\n// thread safe, implement ThreadWithParam. See the description of its API\n// in gtest-port.h, where it is defined for already supported platforms.\n\n// How many threads to create?\nconst int kThreadCount = 50;\n\nstd::string IdToKey(int id, const char* suffix) {\n  Message key;\n  key << \"key_\" << id << \"_\" << suffix;\n  return key.GetString();\n}\n\nstd::string IdToString(int id) {\n  Message id_message;\n  id_message << id;\n  return id_message.GetString();\n}\n\nvoid ExpectKeyAndValueWereRecordedForId(\n    const std::vector<TestProperty>& properties,\n    int id, const char* suffix) {\n  TestPropertyKeyIs matches_key(IdToKey(id, suffix).c_str());\n  const std::vector<TestProperty>::const_iterator property =\n      std::find_if(properties.begin(), properties.end(), matches_key);\n  ASSERT_TRUE(property != properties.end())\n      << \"expecting \" << suffix << \" value for id \" << id;\n  EXPECT_STREQ(IdToString(id).c_str(), property->value());\n}\n\n// Calls a large number of Google Test assertions, where exactly one of them\n// will fail.\nvoid ManyAsserts(int id) {\n  GTEST_LOG_(INFO) << \"Thread #\" << id << \" running...\";\n\n  SCOPED_TRACE(Message() << \"Thread #\" << id);\n\n  for (int i = 0; i < kThreadCount; i++) {\n    SCOPED_TRACE(Message() << \"Iteration #\" << i);\n\n    // A bunch of assertions that should succeed.\n    EXPECT_TRUE(true);\n    ASSERT_FALSE(false) << \"This shouldn't fail.\";\n    EXPECT_STREQ(\"a\", \"a\");\n    ASSERT_LE(5, 6);\n    EXPECT_EQ(i, i) << \"This shouldn't fail.\";\n\n    // RecordProperty() should interact safely with other threads as well.\n    // The shared_key forces property updates.\n    Test::RecordProperty(IdToKey(id, \"string\").c_str(), IdToString(id).c_str());\n    Test::RecordProperty(IdToKey(id, \"int\").c_str(), id);\n    Test::RecordProperty(\"shared_key\", IdToString(id).c_str());\n\n    // This assertion should fail kThreadCount times per thread.  It\n    // is for testing whether Google Test can handle failed assertions in a\n    // multi-threaded context.\n    EXPECT_LT(i, 0) << \"This should always fail.\";\n  }\n}\n\nvoid CheckTestFailureCount(int expected_failures) {\n  const TestInfo* const info = UnitTest::GetInstance()->current_test_info();\n  const TestResult* const result = info->result();\n  GTEST_CHECK_(expected_failures == result->total_part_count())\n      << \"Logged \" << result->total_part_count() << \" failures \"\n      << \" vs. \" << expected_failures << \" expected\";\n}\n\n// Tests using SCOPED_TRACE() and Google Test assertions in many threads\n// concurrently.\nTEST(StressTest, CanUseScopedTraceAndAssertionsInManyThreads) {\n  {\n    scoped_ptr<ThreadWithParam<int> > threads[kThreadCount];\n    Notification threads_can_start;\n    for (int i = 0; i != kThreadCount; i++)\n      threads[i].reset(new ThreadWithParam<int>(&ManyAsserts,\n                                                i,\n                                                &threads_can_start));\n\n    threads_can_start.Notify();\n\n    // Blocks until all the threads are done.\n    for (int i = 0; i != kThreadCount; i++)\n      threads[i]->Join();\n  }\n\n  // Ensures that kThreadCount*kThreadCount failures have been reported.\n  const TestInfo* const info = UnitTest::GetInstance()->current_test_info();\n  const TestResult* const result = info->result();\n\n  std::vector<TestProperty> properties;\n  // We have no access to the TestResult's list of properties but we can\n  // copy them one by one.\n  for (int i = 0; i < result->test_property_count(); ++i)\n    properties.push_back(result->GetTestProperty(i));\n\n  EXPECT_EQ(kThreadCount * 2 + 1, result->test_property_count())\n      << \"String and int values recorded on each thread, \"\n      << \"as well as one shared_key\";\n  for (int i = 0; i < kThreadCount; ++i) {\n    ExpectKeyAndValueWereRecordedForId(properties, i, \"string\");\n    ExpectKeyAndValueWereRecordedForId(properties, i, \"int\");\n  }\n  CheckTestFailureCount(kThreadCount*kThreadCount);\n}\n\nvoid FailingThread(bool is_fatal) {\n  if (is_fatal)\n    FAIL() << \"Fatal failure in some other thread. \"\n           << \"(This failure is expected.)\";\n  else\n    ADD_FAILURE() << \"Non-fatal failure in some other thread. \"\n                  << \"(This failure is expected.)\";\n}\n\nvoid GenerateFatalFailureInAnotherThread(bool is_fatal) {\n  ThreadWithParam<bool> thread(&FailingThread, is_fatal, NULL);\n  thread.Join();\n}\n\nTEST(NoFatalFailureTest, ExpectNoFatalFailureIgnoresFailuresInOtherThreads) {\n  EXPECT_NO_FATAL_FAILURE(GenerateFatalFailureInAnotherThread(true));\n  // We should only have one failure (the one from\n  // GenerateFatalFailureInAnotherThread()), since the EXPECT_NO_FATAL_FAILURE\n  // should succeed.\n  CheckTestFailureCount(1);\n}\n\nvoid AssertNoFatalFailureIgnoresFailuresInOtherThreads() {\n  ASSERT_NO_FATAL_FAILURE(GenerateFatalFailureInAnotherThread(true));\n}\nTEST(NoFatalFailureTest, AssertNoFatalFailureIgnoresFailuresInOtherThreads) {\n  // Using a subroutine, to make sure, that the test continues.\n  AssertNoFatalFailureIgnoresFailuresInOtherThreads();\n  // We should only have one failure (the one from\n  // GenerateFatalFailureInAnotherThread()), since the EXPECT_NO_FATAL_FAILURE\n  // should succeed.\n  CheckTestFailureCount(1);\n}\n\nTEST(FatalFailureTest, ExpectFatalFailureIgnoresFailuresInOtherThreads) {\n  // This statement should fail, since the current thread doesn't generate a\n  // fatal failure, only another one does.\n  EXPECT_FATAL_FAILURE(GenerateFatalFailureInAnotherThread(true), \"expected\");\n  CheckTestFailureCount(2);\n}\n\nTEST(FatalFailureOnAllThreadsTest, ExpectFatalFailureOnAllThreads) {\n  // This statement should succeed, because failures in all threads are\n  // considered.\n  EXPECT_FATAL_FAILURE_ON_ALL_THREADS(\n      GenerateFatalFailureInAnotherThread(true), \"expected\");\n  CheckTestFailureCount(0);\n  // We need to add a failure, because main() checks that there are failures.\n  // But when only this test is run, we shouldn't have any failures.\n  ADD_FAILURE() << \"This is an expected non-fatal failure.\";\n}\n\nTEST(NonFatalFailureTest, ExpectNonFatalFailureIgnoresFailuresInOtherThreads) {\n  // This statement should fail, since the current thread doesn't generate a\n  // fatal failure, only another one does.\n  EXPECT_NONFATAL_FAILURE(GenerateFatalFailureInAnotherThread(false),\n                          \"expected\");\n  CheckTestFailureCount(2);\n}\n\nTEST(NonFatalFailureOnAllThreadsTest, ExpectNonFatalFailureOnAllThreads) {\n  // This statement should succeed, because failures in all threads are\n  // considered.\n  EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(\n      GenerateFatalFailureInAnotherThread(false), \"expected\");\n  CheckTestFailureCount(0);\n  // We need to add a failure, because main() checks that there are failures,\n  // But when only this test is run, we shouldn't have any failures.\n  ADD_FAILURE() << \"This is an expected non-fatal failure.\";\n}\n\n}  // namespace\n}  // namespace testing\n\nint main(int argc, char **argv) {\n  testing::InitGoogleTest(&argc, argv);\n\n  const int result = RUN_ALL_TESTS();  // Expected to fail.\n  GTEST_CHECK_(result == 1) << \"RUN_ALL_TESTS() did not fail as expected\";\n\n  printf(\"\\nPASS\\n\");\n  return 0;\n}\n\n#else\nTEST(StressTest,\n     DISABLED_ThreadSafetyTestsAreSkippedWhenGoogleTestIsNotThreadSafe) {\n}\n\nint main(int argc, char **argv) {\n  testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n#endif  // GTEST_IS_THREADSAFE\n"
  },
  {
    "path": "ext/gtest/test/gtest_test_utils.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2006, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Unit test utilities for Google C++ Testing Framework.\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport atexit\nimport os\nimport shutil\nimport sys\nimport tempfile\nimport unittest\n_test_module = unittest\n\n# Suppresses the 'Import not at the top of the file' lint complaint.\n# pylint: disable-msg=C6204\ntry:\n  import subprocess\n  _SUBPROCESS_MODULE_AVAILABLE = True\nexcept:\n  import popen2\n  _SUBPROCESS_MODULE_AVAILABLE = False\n# pylint: enable-msg=C6204\n\nGTEST_OUTPUT_VAR_NAME = 'GTEST_OUTPUT'\n\nIS_WINDOWS = os.name == 'nt'\nIS_CYGWIN = os.name == 'posix' and 'CYGWIN' in os.uname()[0]\n\n# The environment variable for specifying the path to the premature-exit file.\nPREMATURE_EXIT_FILE_ENV_VAR = 'TEST_PREMATURE_EXIT_FILE'\n\nenviron = os.environ.copy()\n\n\ndef SetEnvVar(env_var, value):\n  \"\"\"Sets/unsets an environment variable to a given value.\"\"\"\n\n  if value is not None:\n    environ[env_var] = value\n  elif env_var in environ:\n    del environ[env_var]\n\n\n# Here we expose a class from a particular module, depending on the\n# environment. The comment suppresses the 'Invalid variable name' lint\n# complaint.\nTestCase = _test_module.TestCase  # pylint: disable-msg=C6409\n\n# Initially maps a flag to its default value. After\n# _ParseAndStripGTestFlags() is called, maps a flag to its actual value.\n_flag_map = {'source_dir': os.path.dirname(sys.argv[0]),\n             'build_dir': os.path.dirname(sys.argv[0])}\n_gtest_flags_are_parsed = False\n\n\ndef _ParseAndStripGTestFlags(argv):\n  \"\"\"Parses and strips Google Test flags from argv.  This is idempotent.\"\"\"\n\n  # Suppresses the lint complaint about a global variable since we need it\n  # here to maintain module-wide state.\n  global _gtest_flags_are_parsed  # pylint: disable-msg=W0603\n  if _gtest_flags_are_parsed:\n    return\n\n  _gtest_flags_are_parsed = True\n  for flag in _flag_map:\n    # The environment variable overrides the default value.\n    if flag.upper() in os.environ:\n      _flag_map[flag] = os.environ[flag.upper()]\n\n    # The command line flag overrides the environment variable.\n    i = 1  # Skips the program name.\n    while i < len(argv):\n      prefix = '--' + flag + '='\n      if argv[i].startswith(prefix):\n        _flag_map[flag] = argv[i][len(prefix):]\n        del argv[i]\n        break\n      else:\n        # We don't increment i in case we just found a --gtest_* flag\n        # and removed it from argv.\n        i += 1\n\n\ndef GetFlag(flag):\n  \"\"\"Returns the value of the given flag.\"\"\"\n\n  # In case GetFlag() is called before Main(), we always call\n  # _ParseAndStripGTestFlags() here to make sure the --gtest_* flags\n  # are parsed.\n  _ParseAndStripGTestFlags(sys.argv)\n\n  return _flag_map[flag]\n\n\ndef GetSourceDir():\n  \"\"\"Returns the absolute path of the directory where the .py files are.\"\"\"\n\n  return os.path.abspath(GetFlag('source_dir'))\n\n\ndef GetBuildDir():\n  \"\"\"Returns the absolute path of the directory where the test binaries are.\"\"\"\n\n  return os.path.abspath(GetFlag('build_dir'))\n\n\n_temp_dir = None\n\ndef _RemoveTempDir():\n  if _temp_dir:\n    shutil.rmtree(_temp_dir, ignore_errors=True)\n\natexit.register(_RemoveTempDir)\n\n\ndef GetTempDir():\n  \"\"\"Returns a directory for temporary files.\"\"\"\n\n  global _temp_dir\n  if not _temp_dir:\n    _temp_dir = tempfile.mkdtemp()\n  return _temp_dir\n\n\ndef GetTestExecutablePath(executable_name, build_dir=None):\n  \"\"\"Returns the absolute path of the test binary given its name.\n\n  The function will print a message and abort the program if the resulting file\n  doesn't exist.\n\n  Args:\n    executable_name: name of the test binary that the test script runs.\n    build_dir:       directory where to look for executables, by default\n                     the result of GetBuildDir().\n\n  Returns:\n    The absolute path of the test binary.\n  \"\"\"\n\n  path = os.path.abspath(os.path.join(build_dir or GetBuildDir(),\n                                      executable_name))\n  if (IS_WINDOWS or IS_CYGWIN) and not path.endswith('.exe'):\n    path += '.exe'\n\n  if not os.path.exists(path):\n    message = (\n        'Unable to find the test binary. Please make sure to provide path\\n'\n        'to the binary via the --build_dir flag or the BUILD_DIR\\n'\n        'environment variable.')\n    print >> sys.stderr, message\n    sys.exit(1)\n\n  return path\n\n\ndef GetExitStatus(exit_code):\n  \"\"\"Returns the argument to exit(), or -1 if exit() wasn't called.\n\n  Args:\n    exit_code: the result value of os.system(command).\n  \"\"\"\n\n  if os.name == 'nt':\n    # On Windows, os.WEXITSTATUS() doesn't work and os.system() returns\n    # the argument to exit() directly.\n    return exit_code\n  else:\n    # On Unix, os.WEXITSTATUS() must be used to extract the exit status\n    # from the result of os.system().\n    if os.WIFEXITED(exit_code):\n      return os.WEXITSTATUS(exit_code)\n    else:\n      return -1\n\n\nclass Subprocess:\n  def __init__(self, command, working_dir=None, capture_stderr=True, env=None):\n    \"\"\"Changes into a specified directory, if provided, and executes a command.\n\n    Restores the old directory afterwards.\n\n    Args:\n      command:        The command to run, in the form of sys.argv.\n      working_dir:    The directory to change into.\n      capture_stderr: Determines whether to capture stderr in the output member\n                      or to discard it.\n      env:            Dictionary with environment to pass to the subprocess.\n\n    Returns:\n      An object that represents outcome of the executed process. It has the\n      following attributes:\n        terminated_by_signal   True iff the child process has been terminated\n                               by a signal.\n        signal                 Sygnal that terminated the child process.\n        exited                 True iff the child process exited normally.\n        exit_code              The code with which the child process exited.\n        output                 Child process's stdout and stderr output\n                               combined in a string.\n    \"\"\"\n\n    # The subprocess module is the preferrable way of running programs\n    # since it is available and behaves consistently on all platforms,\n    # including Windows. But it is only available starting in python 2.4.\n    # In earlier python versions, we revert to the popen2 module, which is\n    # available in python 2.0 and later but doesn't provide required\n    # functionality (Popen4) under Windows. This allows us to support Mac\n    # OS X 10.4 Tiger, which has python 2.3 installed.\n    if _SUBPROCESS_MODULE_AVAILABLE:\n      if capture_stderr:\n        stderr = subprocess.STDOUT\n      else:\n        stderr = subprocess.PIPE\n\n      p = subprocess.Popen(command,\n                           stdout=subprocess.PIPE, stderr=stderr,\n                           cwd=working_dir, universal_newlines=True, env=env)\n      # communicate returns a tuple with the file obect for the child's\n      # output.\n      self.output = p.communicate()[0]\n      self._return_code = p.returncode\n    else:\n      old_dir = os.getcwd()\n\n      def _ReplaceEnvDict(dest, src):\n        # Changes made by os.environ.clear are not inheritable by child\n        # processes until Python 2.6. To produce inheritable changes we have\n        # to delete environment items with the del statement.\n        for key in dest.keys():\n          del dest[key]\n        dest.update(src)\n\n      # When 'env' is not None, backup the environment variables and replace\n      # them with the passed 'env'. When 'env' is None, we simply use the\n      # current 'os.environ' for compatibility with the subprocess.Popen\n      # semantics used above.\n      if env is not None:\n        old_environ = os.environ.copy()\n        _ReplaceEnvDict(os.environ, env)\n\n      try:\n        if working_dir is not None:\n          os.chdir(working_dir)\n        if capture_stderr:\n          p = popen2.Popen4(command)\n        else:\n          p = popen2.Popen3(command)\n        p.tochild.close()\n        self.output = p.fromchild.read()\n        ret_code = p.wait()\n      finally:\n        os.chdir(old_dir)\n\n        # Restore the old environment variables\n        # if they were replaced.\n        if env is not None:\n          _ReplaceEnvDict(os.environ, old_environ)\n\n      # Converts ret_code to match the semantics of\n      # subprocess.Popen.returncode.\n      if os.WIFSIGNALED(ret_code):\n        self._return_code = -os.WTERMSIG(ret_code)\n      else:  # os.WIFEXITED(ret_code) should return True here.\n        self._return_code = os.WEXITSTATUS(ret_code)\n\n    if self._return_code < 0:\n      self.terminated_by_signal = True\n      self.exited = False\n      self.signal = -self._return_code\n    else:\n      self.terminated_by_signal = False\n      self.exited = True\n      self.exit_code = self._return_code\n\n\ndef Main():\n  \"\"\"Runs the unit test.\"\"\"\n\n  # We must call _ParseAndStripGTestFlags() before calling\n  # unittest.main().  Otherwise the latter will be confused by the\n  # --gtest_* flags.\n  _ParseAndStripGTestFlags(sys.argv)\n  # The tested binaries should not be writing XML output files unless the\n  # script explicitly instructs them to.\n  # TODO(vladl@google.com): Move this into Subprocess when we implement\n  # passing environment into it as a parameter.\n  if GTEST_OUTPUT_VAR_NAME in os.environ:\n    del os.environ[GTEST_OUTPUT_VAR_NAME]\n\n  _test_module.main()\n"
  },
  {
    "path": "ext/gtest/test/gtest_throw_on_failure_ex_test.cc",
    "content": "// Copyright 2009, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Tests Google Test's throw-on-failure mode with exceptions enabled.\n\n#include \"gtest/gtest.h\"\n\n#include <stdlib.h>\n#include <stdio.h>\n#include <string.h>\n#include <stdexcept>\n\n// Prints the given failure message and exits the program with\n// non-zero.  We use this instead of a Google Test assertion to\n// indicate a failure, as the latter is been tested and cannot be\n// relied on.\nvoid Fail(const char* msg) {\n  printf(\"FAILURE: %s\\n\", msg);\n  fflush(stdout);\n  exit(1);\n}\n\n// Tests that an assertion failure throws a subclass of\n// std::runtime_error.\nvoid TestFailureThrowsRuntimeError() {\n  testing::GTEST_FLAG(throw_on_failure) = true;\n\n  // A successful assertion shouldn't throw.\n  try {\n    EXPECT_EQ(3, 3);\n  } catch(...) {\n    Fail(\"A successful assertion wrongfully threw.\");\n  }\n\n  // A failed assertion should throw a subclass of std::runtime_error.\n  try {\n    EXPECT_EQ(2, 3) << \"Expected failure\";\n  } catch(const std::runtime_error& e) {\n    if (strstr(e.what(), \"Expected failure\") != NULL)\n      return;\n\n    printf(\"%s\",\n           \"A failed assertion did throw an exception of the right type, \"\n           \"but the message is incorrect.  Instead of containing \\\"Expected \"\n           \"failure\\\", it is:\\n\");\n    Fail(e.what());\n  } catch(...) {\n    Fail(\"A failed assertion threw the wrong type of exception.\");\n  }\n  Fail(\"A failed assertion should've thrown but didn't.\");\n}\n\nint main(int argc, char** argv) {\n  testing::InitGoogleTest(&argc, argv);\n\n  // We want to ensure that people can use Google Test assertions in\n  // other testing frameworks, as long as they initialize Google Test\n  // properly and set the thrown-on-failure mode.  Therefore, we don't\n  // use Google Test's constructs for defining and running tests\n  // (e.g. TEST and RUN_ALL_TESTS) here.\n\n  TestFailureThrowsRuntimeError();\n  return 0;\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest_throw_on_failure_test.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2009, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Tests Google Test's throw-on-failure mode with exceptions disabled.\n\nThis script invokes gtest_throw_on_failure_test_ (a program written with\nGoogle Test) with different environments and command line flags.\n\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport os\nimport gtest_test_utils\n\n\n# Constants.\n\n# The command line flag for enabling/disabling the throw-on-failure mode.\nTHROW_ON_FAILURE = 'gtest_throw_on_failure'\n\n# Path to the gtest_throw_on_failure_test_ program, compiled with\n# exceptions disabled.\nEXE_PATH = gtest_test_utils.GetTestExecutablePath(\n    'gtest_throw_on_failure_test_')\n\n\n# Utilities.\n\n\ndef SetEnvVar(env_var, value):\n  \"\"\"Sets an environment variable to a given value; unsets it when the\n  given value is None.\n  \"\"\"\n\n  env_var = env_var.upper()\n  if value is not None:\n    os.environ[env_var] = value\n  elif env_var in os.environ:\n    del os.environ[env_var]\n\n\ndef Run(command):\n  \"\"\"Runs a command; returns True/False if its exit code is/isn't 0.\"\"\"\n\n  print 'Running \"%s\". . .' % ' '.join(command)\n  p = gtest_test_utils.Subprocess(command)\n  return p.exited and p.exit_code == 0\n\n\n# The tests.  TODO(wan@google.com): refactor the class to share common\n# logic with code in gtest_break_on_failure_unittest.py.\nclass ThrowOnFailureTest(gtest_test_utils.TestCase):\n  \"\"\"Tests the throw-on-failure mode.\"\"\"\n\n  def RunAndVerify(self, env_var_value, flag_value, should_fail):\n    \"\"\"Runs gtest_throw_on_failure_test_ and verifies that it does\n    (or does not) exit with a non-zero code.\n\n    Args:\n      env_var_value:    value of the GTEST_BREAK_ON_FAILURE environment\n                        variable; None if the variable should be unset.\n      flag_value:       value of the --gtest_break_on_failure flag;\n                        None if the flag should not be present.\n      should_fail:      True iff the program is expected to fail.\n    \"\"\"\n\n    SetEnvVar(THROW_ON_FAILURE, env_var_value)\n\n    if env_var_value is None:\n      env_var_value_msg = ' is not set'\n    else:\n      env_var_value_msg = '=' + env_var_value\n\n    if flag_value is None:\n      flag = ''\n    elif flag_value == '0':\n      flag = '--%s=0' % THROW_ON_FAILURE\n    else:\n      flag = '--%s' % THROW_ON_FAILURE\n\n    command = [EXE_PATH]\n    if flag:\n      command.append(flag)\n\n    if should_fail:\n      should_or_not = 'should'\n    else:\n      should_or_not = 'should not'\n\n    failed = not Run(command)\n\n    SetEnvVar(THROW_ON_FAILURE, None)\n\n    msg = ('when %s%s, an assertion failure in \"%s\" %s cause a non-zero '\n           'exit code.' %\n           (THROW_ON_FAILURE, env_var_value_msg, ' '.join(command),\n            should_or_not))\n    self.assert_(failed == should_fail, msg)\n\n  def testDefaultBehavior(self):\n    \"\"\"Tests the behavior of the default mode.\"\"\"\n\n    self.RunAndVerify(env_var_value=None, flag_value=None, should_fail=False)\n\n  def testThrowOnFailureEnvVar(self):\n    \"\"\"Tests using the GTEST_THROW_ON_FAILURE environment variable.\"\"\"\n\n    self.RunAndVerify(env_var_value='0',\n                      flag_value=None,\n                      should_fail=False)\n    self.RunAndVerify(env_var_value='1',\n                      flag_value=None,\n                      should_fail=True)\n\n  def testThrowOnFailureFlag(self):\n    \"\"\"Tests using the --gtest_throw_on_failure flag.\"\"\"\n\n    self.RunAndVerify(env_var_value=None,\n                      flag_value='0',\n                      should_fail=False)\n    self.RunAndVerify(env_var_value=None,\n                      flag_value='1',\n                      should_fail=True)\n\n  def testThrowOnFailureFlagOverridesEnvVar(self):\n    \"\"\"Tests that --gtest_throw_on_failure overrides GTEST_THROW_ON_FAILURE.\"\"\"\n\n    self.RunAndVerify(env_var_value='0',\n                      flag_value='0',\n                      should_fail=False)\n    self.RunAndVerify(env_var_value='0',\n                      flag_value='1',\n                      should_fail=True)\n    self.RunAndVerify(env_var_value='1',\n                      flag_value='0',\n                      should_fail=False)\n    self.RunAndVerify(env_var_value='1',\n                      flag_value='1',\n                      should_fail=True)\n\n\nif __name__ == '__main__':\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "ext/gtest/test/gtest_throw_on_failure_test_.cc",
    "content": "// Copyright 2009, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n// Tests Google Test's throw-on-failure mode with exceptions disabled.\n//\n// This program must be compiled with exceptions disabled.  It will be\n// invoked by gtest_throw_on_failure_test.py, and is expected to exit\n// with non-zero in the throw-on-failure mode or 0 otherwise.\n\n#include \"gtest/gtest.h\"\n\n#include <stdio.h>                      // for fflush, fprintf, NULL, etc.\n#include <stdlib.h>                     // for exit\n#include <exception>                    // for set_terminate\n\n// This terminate handler aborts the program using exit() rather than abort().\n// This avoids showing pop-ups on Windows systems and core dumps on Unix-like\n// ones.\nvoid TerminateHandler() {\n  fprintf(stderr, \"%s\\n\", \"Unhandled C++ exception terminating the program.\");\n  fflush(NULL);\n  exit(1);\n}\n\nint main(int argc, char** argv) {\n#if GTEST_HAS_EXCEPTIONS\n  std::set_terminate(&TerminateHandler);\n#endif\n  testing::InitGoogleTest(&argc, argv);\n\n  // We want to ensure that people can use Google Test assertions in\n  // other testing frameworks, as long as they initialize Google Test\n  // properly and set the throw-on-failure mode.  Therefore, we don't\n  // use Google Test's constructs for defining and running tests\n  // (e.g. TEST and RUN_ALL_TESTS) here.\n\n  // In the throw-on-failure mode with exceptions disabled, this\n  // assertion will cause the program to exit with a non-zero code.\n  EXPECT_EQ(2, 3);\n\n  // When not in the throw-on-failure mode, the control will reach\n  // here.\n  return 0;\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest_uninitialized_test.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2008, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Verifies that Google Test warns the user when not initialized properly.\"\"\"\n\n__author__ = 'wan@google.com (Zhanyong Wan)'\n\nimport gtest_test_utils\n\n\nCOMMAND = gtest_test_utils.GetTestExecutablePath('gtest_uninitialized_test_')\n\n\ndef Assert(condition):\n  if not condition:\n    raise AssertionError\n\n\ndef AssertEq(expected, actual):\n  if expected != actual:\n    print 'Expected: %s' % (expected,)\n    print '  Actual: %s' % (actual,)\n    raise AssertionError\n\n\ndef TestExitCodeAndOutput(command):\n  \"\"\"Runs the given command and verifies its exit code and output.\"\"\"\n\n  # Verifies that 'command' exits with code 1.\n  p = gtest_test_utils.Subprocess(command)\n  Assert(p.exited)\n  AssertEq(1, p.exit_code)\n  Assert('InitGoogleTest' in p.output)\n\n\nclass GTestUninitializedTest(gtest_test_utils.TestCase):\n  def testExitCodeAndOutput(self):\n    TestExitCodeAndOutput(COMMAND)\n\n\nif __name__ == '__main__':\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "ext/gtest/test/gtest_uninitialized_test_.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n\n#include \"gtest/gtest.h\"\n\nTEST(DummyTest, Dummy) {\n  // This test doesn't verify anything.  We just need it to create a\n  // realistic stage for testing the behavior of Google Test when\n  // RUN_ALL_TESTS() is called without testing::InitGoogleTest() being\n  // called first.\n}\n\nint main() {\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest_unittest.cc",
    "content": "// Copyright 2005, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// Tests for Google Test itself.  This verifies that the basic constructs of\n// Google Test work.\n\n#include \"gtest/gtest.h\"\n\n// Verifies that the command line flag variables can be accessed\n// in code once <gtest/gtest.h> has been #included.\n// Do not move it after other #includes.\nTEST(CommandLineFlagsTest, CanBeAccessedInCodeOnceGTestHIsIncluded) {\n  bool dummy = testing::GTEST_FLAG(also_run_disabled_tests)\n      || testing::GTEST_FLAG(break_on_failure)\n      || testing::GTEST_FLAG(catch_exceptions)\n      || testing::GTEST_FLAG(color) != \"unknown\"\n      || testing::GTEST_FLAG(filter) != \"unknown\"\n      || testing::GTEST_FLAG(list_tests)\n      || testing::GTEST_FLAG(output) != \"unknown\"\n      || testing::GTEST_FLAG(print_time)\n      || testing::GTEST_FLAG(random_seed)\n      || testing::GTEST_FLAG(repeat) > 0\n      || testing::GTEST_FLAG(show_internal_stack_frames)\n      || testing::GTEST_FLAG(shuffle)\n      || testing::GTEST_FLAG(stack_trace_depth) > 0\n      || testing::GTEST_FLAG(stream_result_to) != \"unknown\"\n      || testing::GTEST_FLAG(throw_on_failure);\n  EXPECT_TRUE(dummy || !dummy);  // Suppresses warning that dummy is unused.\n}\n\n#include <limits.h>  // For INT_MAX.\n#include <stdlib.h>\n#include <string.h>\n#include <time.h>\n\n#include <map>\n#include <vector>\n#include <ostream>\n\n#include \"gtest/gtest-spi.h\"\n\n// Indicates that this translation unit is part of Google Test's\n// implementation.  It must come before gtest-internal-inl.h is\n// included, or there will be a compiler error.  This trick is to\n// prevent a user from accidentally including gtest-internal-inl.h in\n// his code.\n#define GTEST_IMPLEMENTATION_ 1\n#include \"src/gtest-internal-inl.h\"\n#undef GTEST_IMPLEMENTATION_\n\nnamespace testing {\nnamespace internal {\n\n#if GTEST_CAN_STREAM_RESULTS_\n\nclass StreamingListenerTest : public Test {\n public:\n  class FakeSocketWriter : public StreamingListener::AbstractSocketWriter {\n   public:\n    // Sends a string to the socket.\n    virtual void Send(const string& message) { output_ += message; }\n\n    string output_;\n  };\n\n  StreamingListenerTest()\n      : fake_sock_writer_(new FakeSocketWriter),\n        streamer_(fake_sock_writer_),\n        test_info_obj_(\"FooTest\", \"Bar\", NULL, NULL, 0, NULL) {}\n\n protected:\n  string* output() { return &(fake_sock_writer_->output_); }\n\n  FakeSocketWriter* const fake_sock_writer_;\n  StreamingListener streamer_;\n  UnitTest unit_test_;\n  TestInfo test_info_obj_;  // The name test_info_ was taken by testing::Test.\n};\n\nTEST_F(StreamingListenerTest, OnTestProgramEnd) {\n  *output() = \"\";\n  streamer_.OnTestProgramEnd(unit_test_);\n  EXPECT_EQ(\"event=TestProgramEnd&passed=1\\n\", *output());\n}\n\nTEST_F(StreamingListenerTest, OnTestIterationEnd) {\n  *output() = \"\";\n  streamer_.OnTestIterationEnd(unit_test_, 42);\n  EXPECT_EQ(\"event=TestIterationEnd&passed=1&elapsed_time=0ms\\n\", *output());\n}\n\nTEST_F(StreamingListenerTest, OnTestCaseStart) {\n  *output() = \"\";\n  streamer_.OnTestCaseStart(TestCase(\"FooTest\", \"Bar\", NULL, NULL));\n  EXPECT_EQ(\"event=TestCaseStart&name=FooTest\\n\", *output());\n}\n\nTEST_F(StreamingListenerTest, OnTestCaseEnd) {\n  *output() = \"\";\n  streamer_.OnTestCaseEnd(TestCase(\"FooTest\", \"Bar\", NULL, NULL));\n  EXPECT_EQ(\"event=TestCaseEnd&passed=1&elapsed_time=0ms\\n\", *output());\n}\n\nTEST_F(StreamingListenerTest, OnTestStart) {\n  *output() = \"\";\n  streamer_.OnTestStart(test_info_obj_);\n  EXPECT_EQ(\"event=TestStart&name=Bar\\n\", *output());\n}\n\nTEST_F(StreamingListenerTest, OnTestEnd) {\n  *output() = \"\";\n  streamer_.OnTestEnd(test_info_obj_);\n  EXPECT_EQ(\"event=TestEnd&passed=1&elapsed_time=0ms\\n\", *output());\n}\n\nTEST_F(StreamingListenerTest, OnTestPartResult) {\n  *output() = \"\";\n  streamer_.OnTestPartResult(TestPartResult(\n      TestPartResult::kFatalFailure, \"foo.cc\", 42, \"failed=\\n&%\"));\n\n  // Meta characters in the failure message should be properly escaped.\n  EXPECT_EQ(\n      \"event=TestPartResult&file=foo.cc&line=42&message=failed%3D%0A%26%25\\n\",\n      *output());\n}\n\n#endif  // GTEST_CAN_STREAM_RESULTS_\n\n// Provides access to otherwise private parts of the TestEventListeners class\n// that are needed to test it.\nclass TestEventListenersAccessor {\n public:\n  static TestEventListener* GetRepeater(TestEventListeners* listeners) {\n    return listeners->repeater();\n  }\n\n  static void SetDefaultResultPrinter(TestEventListeners* listeners,\n                                      TestEventListener* listener) {\n    listeners->SetDefaultResultPrinter(listener);\n  }\n  static void SetDefaultXmlGenerator(TestEventListeners* listeners,\n                                     TestEventListener* listener) {\n    listeners->SetDefaultXmlGenerator(listener);\n  }\n\n  static bool EventForwardingEnabled(const TestEventListeners& listeners) {\n    return listeners.EventForwardingEnabled();\n  }\n\n  static void SuppressEventForwarding(TestEventListeners* listeners) {\n    listeners->SuppressEventForwarding();\n  }\n};\n\nclass UnitTestRecordPropertyTestHelper : public Test {\n protected:\n  UnitTestRecordPropertyTestHelper() {}\n\n  // Forwards to UnitTest::RecordProperty() to bypass access controls.\n  void UnitTestRecordProperty(const char* key, const std::string& value) {\n    unit_test_.RecordProperty(key, value);\n  }\n\n  UnitTest unit_test_;\n};\n\n}  // namespace internal\n}  // namespace testing\n\nusing testing::AssertionFailure;\nusing testing::AssertionResult;\nusing testing::AssertionSuccess;\nusing testing::DoubleLE;\nusing testing::EmptyTestEventListener;\nusing testing::Environment;\nusing testing::FloatLE;\nusing testing::GTEST_FLAG(also_run_disabled_tests);\nusing testing::GTEST_FLAG(break_on_failure);\nusing testing::GTEST_FLAG(catch_exceptions);\nusing testing::GTEST_FLAG(color);\nusing testing::GTEST_FLAG(death_test_use_fork);\nusing testing::GTEST_FLAG(filter);\nusing testing::GTEST_FLAG(list_tests);\nusing testing::GTEST_FLAG(output);\nusing testing::GTEST_FLAG(print_time);\nusing testing::GTEST_FLAG(random_seed);\nusing testing::GTEST_FLAG(repeat);\nusing testing::GTEST_FLAG(show_internal_stack_frames);\nusing testing::GTEST_FLAG(shuffle);\nusing testing::GTEST_FLAG(stack_trace_depth);\nusing testing::GTEST_FLAG(stream_result_to);\nusing testing::GTEST_FLAG(throw_on_failure);\nusing testing::IsNotSubstring;\nusing testing::IsSubstring;\nusing testing::Message;\nusing testing::ScopedFakeTestPartResultReporter;\nusing testing::StaticAssertTypeEq;\nusing testing::Test;\nusing testing::TestCase;\nusing testing::TestEventListeners;\nusing testing::TestInfo;\nusing testing::TestPartResult;\nusing testing::TestPartResultArray;\nusing testing::TestProperty;\nusing testing::TestResult;\nusing testing::TimeInMillis;\nusing testing::UnitTest;\nusing testing::kMaxStackTraceDepth;\nusing testing::internal::AddReference;\nusing testing::internal::AlwaysFalse;\nusing testing::internal::AlwaysTrue;\nusing testing::internal::AppendUserMessage;\nusing testing::internal::ArrayAwareFind;\nusing testing::internal::ArrayEq;\nusing testing::internal::CodePointToUtf8;\nusing testing::internal::CompileAssertTypesEqual;\nusing testing::internal::CopyArray;\nusing testing::internal::CountIf;\nusing testing::internal::EqFailure;\nusing testing::internal::FloatingPoint;\nusing testing::internal::ForEach;\nusing testing::internal::FormatEpochTimeInMillisAsIso8601;\nusing testing::internal::FormatTimeInMillisAsSeconds;\nusing testing::internal::GTestFlagSaver;\nusing testing::internal::GetCurrentOsStackTraceExceptTop;\nusing testing::internal::GetElementOr;\nusing testing::internal::GetNextRandomSeed;\nusing testing::internal::GetRandomSeedFromFlag;\nusing testing::internal::GetTestTypeId;\nusing testing::internal::GetTimeInMillis;\nusing testing::internal::GetTypeId;\nusing testing::internal::GetUnitTestImpl;\nusing testing::internal::ImplicitlyConvertible;\nusing testing::internal::Int32;\nusing testing::internal::Int32FromEnvOrDie;\nusing testing::internal::IsAProtocolMessage;\nusing testing::internal::IsContainer;\nusing testing::internal::IsContainerTest;\nusing testing::internal::IsNotContainer;\nusing testing::internal::NativeArray;\nusing testing::internal::ParseInt32Flag;\nusing testing::internal::RemoveConst;\nusing testing::internal::RemoveReference;\nusing testing::internal::ShouldRunTestOnShard;\nusing testing::internal::ShouldShard;\nusing testing::internal::ShouldUseColor;\nusing testing::internal::Shuffle;\nusing testing::internal::ShuffleRange;\nusing testing::internal::SkipPrefix;\nusing testing::internal::StreamableToString;\nusing testing::internal::String;\nusing testing::internal::TestEventListenersAccessor;\nusing testing::internal::TestResultAccessor;\nusing testing::internal::UInt32;\nusing testing::internal::WideStringToUtf8;\nusing testing::internal::kCopy;\nusing testing::internal::kMaxRandomSeed;\nusing testing::internal::kReference;\nusing testing::internal::kTestTypeIdInGoogleTest;\nusing testing::internal::scoped_ptr;\n\n#if GTEST_HAS_STREAM_REDIRECTION\nusing testing::internal::CaptureStdout;\nusing testing::internal::GetCapturedStdout;\n#endif\n\n#if GTEST_IS_THREADSAFE\nusing testing::internal::ThreadWithParam;\n#endif\n\nclass TestingVector : public std::vector<int> {\n};\n\n::std::ostream& operator<<(::std::ostream& os,\n                           const TestingVector& vector) {\n  os << \"{ \";\n  for (size_t i = 0; i < vector.size(); i++) {\n    os << vector[i] << \" \";\n  }\n  os << \"}\";\n  return os;\n}\n\n// This line tests that we can define tests in an unnamed namespace.\nnamespace {\n\nTEST(GetRandomSeedFromFlagTest, HandlesZero) {\n  const int seed = GetRandomSeedFromFlag(0);\n  EXPECT_LE(1, seed);\n  EXPECT_LE(seed, static_cast<int>(kMaxRandomSeed));\n}\n\nTEST(GetRandomSeedFromFlagTest, PreservesValidSeed) {\n  EXPECT_EQ(1, GetRandomSeedFromFlag(1));\n  EXPECT_EQ(2, GetRandomSeedFromFlag(2));\n  EXPECT_EQ(kMaxRandomSeed - 1, GetRandomSeedFromFlag(kMaxRandomSeed - 1));\n  EXPECT_EQ(static_cast<int>(kMaxRandomSeed),\n            GetRandomSeedFromFlag(kMaxRandomSeed));\n}\n\nTEST(GetRandomSeedFromFlagTest, NormalizesInvalidSeed) {\n  const int seed1 = GetRandomSeedFromFlag(-1);\n  EXPECT_LE(1, seed1);\n  EXPECT_LE(seed1, static_cast<int>(kMaxRandomSeed));\n\n  const int seed2 = GetRandomSeedFromFlag(kMaxRandomSeed + 1);\n  EXPECT_LE(1, seed2);\n  EXPECT_LE(seed2, static_cast<int>(kMaxRandomSeed));\n}\n\nTEST(GetNextRandomSeedTest, WorksForValidInput) {\n  EXPECT_EQ(2, GetNextRandomSeed(1));\n  EXPECT_EQ(3, GetNextRandomSeed(2));\n  EXPECT_EQ(static_cast<int>(kMaxRandomSeed),\n            GetNextRandomSeed(kMaxRandomSeed - 1));\n  EXPECT_EQ(1, GetNextRandomSeed(kMaxRandomSeed));\n\n  // We deliberately don't test GetNextRandomSeed() with invalid\n  // inputs, as that requires death tests, which are expensive.  This\n  // is fine as GetNextRandomSeed() is internal and has a\n  // straightforward definition.\n}\n\nstatic void ClearCurrentTestPartResults() {\n  TestResultAccessor::ClearTestPartResults(\n      GetUnitTestImpl()->current_test_result());\n}\n\n// Tests GetTypeId.\n\nTEST(GetTypeIdTest, ReturnsSameValueForSameType) {\n  EXPECT_EQ(GetTypeId<int>(), GetTypeId<int>());\n  EXPECT_EQ(GetTypeId<Test>(), GetTypeId<Test>());\n}\n\nclass SubClassOfTest : public Test {};\nclass AnotherSubClassOfTest : public Test {};\n\nTEST(GetTypeIdTest, ReturnsDifferentValuesForDifferentTypes) {\n  EXPECT_NE(GetTypeId<int>(), GetTypeId<const int>());\n  EXPECT_NE(GetTypeId<int>(), GetTypeId<char>());\n  EXPECT_NE(GetTypeId<int>(), GetTestTypeId());\n  EXPECT_NE(GetTypeId<SubClassOfTest>(), GetTestTypeId());\n  EXPECT_NE(GetTypeId<AnotherSubClassOfTest>(), GetTestTypeId());\n  EXPECT_NE(GetTypeId<AnotherSubClassOfTest>(), GetTypeId<SubClassOfTest>());\n}\n\n// Verifies that GetTestTypeId() returns the same value, no matter it\n// is called from inside Google Test or outside of it.\nTEST(GetTestTypeIdTest, ReturnsTheSameValueInsideOrOutsideOfGoogleTest) {\n  EXPECT_EQ(kTestTypeIdInGoogleTest, GetTestTypeId());\n}\n\n// Tests FormatTimeInMillisAsSeconds().\n\nTEST(FormatTimeInMillisAsSecondsTest, FormatsZero) {\n  EXPECT_EQ(\"0\", FormatTimeInMillisAsSeconds(0));\n}\n\nTEST(FormatTimeInMillisAsSecondsTest, FormatsPositiveNumber) {\n  EXPECT_EQ(\"0.003\", FormatTimeInMillisAsSeconds(3));\n  EXPECT_EQ(\"0.01\", FormatTimeInMillisAsSeconds(10));\n  EXPECT_EQ(\"0.2\", FormatTimeInMillisAsSeconds(200));\n  EXPECT_EQ(\"1.2\", FormatTimeInMillisAsSeconds(1200));\n  EXPECT_EQ(\"3\", FormatTimeInMillisAsSeconds(3000));\n}\n\nTEST(FormatTimeInMillisAsSecondsTest, FormatsNegativeNumber) {\n  EXPECT_EQ(\"-0.003\", FormatTimeInMillisAsSeconds(-3));\n  EXPECT_EQ(\"-0.01\", FormatTimeInMillisAsSeconds(-10));\n  EXPECT_EQ(\"-0.2\", FormatTimeInMillisAsSeconds(-200));\n  EXPECT_EQ(\"-1.2\", FormatTimeInMillisAsSeconds(-1200));\n  EXPECT_EQ(\"-3\", FormatTimeInMillisAsSeconds(-3000));\n}\n\n// Tests FormatEpochTimeInMillisAsIso8601().  The correctness of conversion\n// for particular dates below was verified in Python using\n// datetime.datetime.fromutctimestamp(<timetamp>/1000).\n\n// FormatEpochTimeInMillisAsIso8601 depends on the current timezone, so we\n// have to set up a particular timezone to obtain predictable results.\nclass FormatEpochTimeInMillisAsIso8601Test : public Test {\n public:\n  // On Cygwin, GCC doesn't allow unqualified integer literals to exceed\n  // 32 bits, even when 64-bit integer types are available.  We have to\n  // force the constants to have a 64-bit type here.\n  static const TimeInMillis kMillisPerSec = 1000;\n\n private:\n  virtual void SetUp() {\n    saved_tz_ = NULL;\n#if _MSC_VER\n# pragma warning(push)          // Saves the current warning state.\n# pragma warning(disable:4996)  // Temporarily disables warning 4996\n                                // (function or variable may be unsafe\n                                // for getenv, function is deprecated for\n                                // strdup).\n    if (getenv(\"TZ\"))\n      saved_tz_ = strdup(getenv(\"TZ\"));\n# pragma warning(pop)           // Restores the warning state again.\n#else\n    if (getenv(\"TZ\"))\n      saved_tz_ = strdup(getenv(\"TZ\"));\n#endif\n\n    // Set up the time zone for FormatEpochTimeInMillisAsIso8601 to use.  We\n    // cannot use the local time zone because the function's output depends\n    // on the time zone.\n    SetTimeZone(\"UTC+00\");\n  }\n\n  virtual void TearDown() {\n    SetTimeZone(saved_tz_);\n    free(const_cast<char*>(saved_tz_));\n    saved_tz_ = NULL;\n  }\n\n  static void SetTimeZone(const char* time_zone) {\n    // tzset() distinguishes between the TZ variable being present and empty\n    // and not being present, so we have to consider the case of time_zone\n    // being NULL.\n#if _MSC_VER\n    // ...Unless it's MSVC, whose standard library's _putenv doesn't\n    // distinguish between an empty and a missing variable.\n    const std::string env_var =\n        std::string(\"TZ=\") + (time_zone ? time_zone : \"\");\n    _putenv(env_var.c_str());\n# pragma warning(push)          // Saves the current warning state.\n# pragma warning(disable:4996)  // Temporarily disables warning 4996\n                                // (function is deprecated).\n    tzset();\n# pragma warning(pop)           // Restores the warning state again.\n#else\n    if (time_zone) {\n      setenv((\"TZ\"), time_zone, 1);\n    } else {\n      unsetenv(\"TZ\");\n    }\n    tzset();\n#endif\n  }\n\n  const char* saved_tz_;\n};\n\nconst TimeInMillis FormatEpochTimeInMillisAsIso8601Test::kMillisPerSec;\n\nTEST_F(FormatEpochTimeInMillisAsIso8601Test, PrintsTwoDigitSegments) {\n  EXPECT_EQ(\"2011-10-31T18:52:42\",\n            FormatEpochTimeInMillisAsIso8601(1320087162 * kMillisPerSec));\n}\n\nTEST_F(FormatEpochTimeInMillisAsIso8601Test, MillisecondsDoNotAffectResult) {\n  EXPECT_EQ(\n      \"2011-10-31T18:52:42\",\n      FormatEpochTimeInMillisAsIso8601(1320087162 * kMillisPerSec + 234));\n}\n\nTEST_F(FormatEpochTimeInMillisAsIso8601Test, PrintsLeadingZeroes) {\n  EXPECT_EQ(\"2011-09-03T05:07:02\",\n            FormatEpochTimeInMillisAsIso8601(1315026422 * kMillisPerSec));\n}\n\nTEST_F(FormatEpochTimeInMillisAsIso8601Test, Prints24HourTime) {\n  EXPECT_EQ(\"2011-09-28T17:08:22\",\n            FormatEpochTimeInMillisAsIso8601(1317229702 * kMillisPerSec));\n}\n\nTEST_F(FormatEpochTimeInMillisAsIso8601Test, PrintsEpochStart) {\n  EXPECT_EQ(\"1970-01-01T00:00:00\", FormatEpochTimeInMillisAsIso8601(0));\n}\n\n#if GTEST_CAN_COMPARE_NULL\n\n# ifdef __BORLANDC__\n// Silences warnings: \"Condition is always true\", \"Unreachable code\"\n#  pragma option push -w-ccc -w-rch\n# endif\n\n// Tests that GTEST_IS_NULL_LITERAL_(x) is true when x is a null\n// pointer literal.\nTEST(NullLiteralTest, IsTrueForNullLiterals) {\n  EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(NULL));\n  EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0));\n  EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0U));\n  EXPECT_TRUE(GTEST_IS_NULL_LITERAL_(0L));\n}\n\n// Tests that GTEST_IS_NULL_LITERAL_(x) is false when x is not a null\n// pointer literal.\nTEST(NullLiteralTest, IsFalseForNonNullLiterals) {\n  EXPECT_FALSE(GTEST_IS_NULL_LITERAL_(1));\n  EXPECT_FALSE(GTEST_IS_NULL_LITERAL_(0.0));\n  EXPECT_FALSE(GTEST_IS_NULL_LITERAL_('a'));\n  EXPECT_FALSE(GTEST_IS_NULL_LITERAL_(static_cast<void*>(NULL)));\n}\n\n# ifdef __BORLANDC__\n// Restores warnings after previous \"#pragma option push\" suppressed them.\n#  pragma option pop\n# endif\n\n#endif  // GTEST_CAN_COMPARE_NULL\n//\n// Tests CodePointToUtf8().\n\n// Tests that the NUL character L'\\0' is encoded correctly.\nTEST(CodePointToUtf8Test, CanEncodeNul) {\n  EXPECT_EQ(\"\", CodePointToUtf8(L'\\0'));\n}\n\n// Tests that ASCII characters are encoded correctly.\nTEST(CodePointToUtf8Test, CanEncodeAscii) {\n  EXPECT_EQ(\"a\", CodePointToUtf8(L'a'));\n  EXPECT_EQ(\"Z\", CodePointToUtf8(L'Z'));\n  EXPECT_EQ(\"&\", CodePointToUtf8(L'&'));\n  EXPECT_EQ(\"\\x7F\", CodePointToUtf8(L'\\x7F'));\n}\n\n// Tests that Unicode code-points that have 8 to 11 bits are encoded\n// as 110xxxxx 10xxxxxx.\nTEST(CodePointToUtf8Test, CanEncode8To11Bits) {\n  // 000 1101 0011 => 110-00011 10-010011\n  EXPECT_EQ(\"\\xC3\\x93\", CodePointToUtf8(L'\\xD3'));\n\n  // 101 0111 0110 => 110-10101 10-110110\n  // Some compilers (e.g., GCC on MinGW) cannot handle non-ASCII codepoints\n  // in wide strings and wide chars. In order to accomodate them, we have to\n  // introduce such character constants as integers.\n  EXPECT_EQ(\"\\xD5\\xB6\",\n            CodePointToUtf8(static_cast<wchar_t>(0x576)));\n}\n\n// Tests that Unicode code-points that have 12 to 16 bits are encoded\n// as 1110xxxx 10xxxxxx 10xxxxxx.\nTEST(CodePointToUtf8Test, CanEncode12To16Bits) {\n  // 0000 1000 1101 0011 => 1110-0000 10-100011 10-010011\n  EXPECT_EQ(\"\\xE0\\xA3\\x93\",\n            CodePointToUtf8(static_cast<wchar_t>(0x8D3)));\n\n  // 1100 0111 0100 1101 => 1110-1100 10-011101 10-001101\n  EXPECT_EQ(\"\\xEC\\x9D\\x8D\",\n            CodePointToUtf8(static_cast<wchar_t>(0xC74D)));\n}\n\n#if !GTEST_WIDE_STRING_USES_UTF16_\n// Tests in this group require a wchar_t to hold > 16 bits, and thus\n// are skipped on Windows, Cygwin, and Symbian, where a wchar_t is\n// 16-bit wide. This code may not compile on those systems.\n\n// Tests that Unicode code-points that have 17 to 21 bits are encoded\n// as 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx.\nTEST(CodePointToUtf8Test, CanEncode17To21Bits) {\n  // 0 0001 0000 1000 1101 0011 => 11110-000 10-010000 10-100011 10-010011\n  EXPECT_EQ(\"\\xF0\\x90\\xA3\\x93\", CodePointToUtf8(L'\\x108D3'));\n\n  // 0 0001 0000 0100 0000 0000 => 11110-000 10-010000 10-010000 10-000000\n  EXPECT_EQ(\"\\xF0\\x90\\x90\\x80\", CodePointToUtf8(L'\\x10400'));\n\n  // 1 0000 1000 0110 0011 0100 => 11110-100 10-001000 10-011000 10-110100\n  EXPECT_EQ(\"\\xF4\\x88\\x98\\xB4\", CodePointToUtf8(L'\\x108634'));\n}\n\n// Tests that encoding an invalid code-point generates the expected result.\nTEST(CodePointToUtf8Test, CanEncodeInvalidCodePoint) {\n  EXPECT_EQ(\"(Invalid Unicode 0x1234ABCD)\", CodePointToUtf8(L'\\x1234ABCD'));\n}\n\n#endif  // !GTEST_WIDE_STRING_USES_UTF16_\n\n// Tests WideStringToUtf8().\n\n// Tests that the NUL character L'\\0' is encoded correctly.\nTEST(WideStringToUtf8Test, CanEncodeNul) {\n  EXPECT_STREQ(\"\", WideStringToUtf8(L\"\", 0).c_str());\n  EXPECT_STREQ(\"\", WideStringToUtf8(L\"\", -1).c_str());\n}\n\n// Tests that ASCII strings are encoded correctly.\nTEST(WideStringToUtf8Test, CanEncodeAscii) {\n  EXPECT_STREQ(\"a\", WideStringToUtf8(L\"a\", 1).c_str());\n  EXPECT_STREQ(\"ab\", WideStringToUtf8(L\"ab\", 2).c_str());\n  EXPECT_STREQ(\"a\", WideStringToUtf8(L\"a\", -1).c_str());\n  EXPECT_STREQ(\"ab\", WideStringToUtf8(L\"ab\", -1).c_str());\n}\n\n// Tests that Unicode code-points that have 8 to 11 bits are encoded\n// as 110xxxxx 10xxxxxx.\nTEST(WideStringToUtf8Test, CanEncode8To11Bits) {\n  // 000 1101 0011 => 110-00011 10-010011\n  EXPECT_STREQ(\"\\xC3\\x93\", WideStringToUtf8(L\"\\xD3\", 1).c_str());\n  EXPECT_STREQ(\"\\xC3\\x93\", WideStringToUtf8(L\"\\xD3\", -1).c_str());\n\n  // 101 0111 0110 => 110-10101 10-110110\n  const wchar_t s[] = { 0x576, '\\0' };\n  EXPECT_STREQ(\"\\xD5\\xB6\", WideStringToUtf8(s, 1).c_str());\n  EXPECT_STREQ(\"\\xD5\\xB6\", WideStringToUtf8(s, -1).c_str());\n}\n\n// Tests that Unicode code-points that have 12 to 16 bits are encoded\n// as 1110xxxx 10xxxxxx 10xxxxxx.\nTEST(WideStringToUtf8Test, CanEncode12To16Bits) {\n  // 0000 1000 1101 0011 => 1110-0000 10-100011 10-010011\n  const wchar_t s1[] = { 0x8D3, '\\0' };\n  EXPECT_STREQ(\"\\xE0\\xA3\\x93\", WideStringToUtf8(s1, 1).c_str());\n  EXPECT_STREQ(\"\\xE0\\xA3\\x93\", WideStringToUtf8(s1, -1).c_str());\n\n  // 1100 0111 0100 1101 => 1110-1100 10-011101 10-001101\n  const wchar_t s2[] = { 0xC74D, '\\0' };\n  EXPECT_STREQ(\"\\xEC\\x9D\\x8D\", WideStringToUtf8(s2, 1).c_str());\n  EXPECT_STREQ(\"\\xEC\\x9D\\x8D\", WideStringToUtf8(s2, -1).c_str());\n}\n\n// Tests that the conversion stops when the function encounters \\0 character.\nTEST(WideStringToUtf8Test, StopsOnNulCharacter) {\n  EXPECT_STREQ(\"ABC\", WideStringToUtf8(L\"ABC\\0XYZ\", 100).c_str());\n}\n\n// Tests that the conversion stops when the function reaches the limit\n// specified by the 'length' parameter.\nTEST(WideStringToUtf8Test, StopsWhenLengthLimitReached) {\n  EXPECT_STREQ(\"ABC\", WideStringToUtf8(L\"ABCDEF\", 3).c_str());\n}\n\n#if !GTEST_WIDE_STRING_USES_UTF16_\n// Tests that Unicode code-points that have 17 to 21 bits are encoded\n// as 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx. This code may not compile\n// on the systems using UTF-16 encoding.\nTEST(WideStringToUtf8Test, CanEncode17To21Bits) {\n  // 0 0001 0000 1000 1101 0011 => 11110-000 10-010000 10-100011 10-010011\n  EXPECT_STREQ(\"\\xF0\\x90\\xA3\\x93\", WideStringToUtf8(L\"\\x108D3\", 1).c_str());\n  EXPECT_STREQ(\"\\xF0\\x90\\xA3\\x93\", WideStringToUtf8(L\"\\x108D3\", -1).c_str());\n\n  // 1 0000 1000 0110 0011 0100 => 11110-100 10-001000 10-011000 10-110100\n  EXPECT_STREQ(\"\\xF4\\x88\\x98\\xB4\", WideStringToUtf8(L\"\\x108634\", 1).c_str());\n  EXPECT_STREQ(\"\\xF4\\x88\\x98\\xB4\", WideStringToUtf8(L\"\\x108634\", -1).c_str());\n}\n\n// Tests that encoding an invalid code-point generates the expected result.\nTEST(WideStringToUtf8Test, CanEncodeInvalidCodePoint) {\n  EXPECT_STREQ(\"(Invalid Unicode 0xABCDFF)\",\n               WideStringToUtf8(L\"\\xABCDFF\", -1).c_str());\n}\n#else  // !GTEST_WIDE_STRING_USES_UTF16_\n// Tests that surrogate pairs are encoded correctly on the systems using\n// UTF-16 encoding in the wide strings.\nTEST(WideStringToUtf8Test, CanEncodeValidUtf16SUrrogatePairs) {\n  const wchar_t s[] = { 0xD801, 0xDC00, '\\0' };\n  EXPECT_STREQ(\"\\xF0\\x90\\x90\\x80\", WideStringToUtf8(s, -1).c_str());\n}\n\n// Tests that encoding an invalid UTF-16 surrogate pair\n// generates the expected result.\nTEST(WideStringToUtf8Test, CanEncodeInvalidUtf16SurrogatePair) {\n  // Leading surrogate is at the end of the string.\n  const wchar_t s1[] = { 0xD800, '\\0' };\n  EXPECT_STREQ(\"\\xED\\xA0\\x80\", WideStringToUtf8(s1, -1).c_str());\n  // Leading surrogate is not followed by the trailing surrogate.\n  const wchar_t s2[] = { 0xD800, 'M', '\\0' };\n  EXPECT_STREQ(\"\\xED\\xA0\\x80M\", WideStringToUtf8(s2, -1).c_str());\n  // Trailing surrogate appearas without a leading surrogate.\n  const wchar_t s3[] = { 0xDC00, 'P', 'Q', 'R', '\\0' };\n  EXPECT_STREQ(\"\\xED\\xB0\\x80PQR\", WideStringToUtf8(s3, -1).c_str());\n}\n#endif  // !GTEST_WIDE_STRING_USES_UTF16_\n\n// Tests that codepoint concatenation works correctly.\n#if !GTEST_WIDE_STRING_USES_UTF16_\nTEST(WideStringToUtf8Test, ConcatenatesCodepointsCorrectly) {\n  const wchar_t s[] = { 0x108634, 0xC74D, '\\n', 0x576, 0x8D3, 0x108634, '\\0'};\n  EXPECT_STREQ(\n      \"\\xF4\\x88\\x98\\xB4\"\n          \"\\xEC\\x9D\\x8D\"\n          \"\\n\"\n          \"\\xD5\\xB6\"\n          \"\\xE0\\xA3\\x93\"\n          \"\\xF4\\x88\\x98\\xB4\",\n      WideStringToUtf8(s, -1).c_str());\n}\n#else\nTEST(WideStringToUtf8Test, ConcatenatesCodepointsCorrectly) {\n  const wchar_t s[] = { 0xC74D, '\\n', 0x576, 0x8D3, '\\0'};\n  EXPECT_STREQ(\n      \"\\xEC\\x9D\\x8D\" \"\\n\" \"\\xD5\\xB6\" \"\\xE0\\xA3\\x93\",\n      WideStringToUtf8(s, -1).c_str());\n}\n#endif  // !GTEST_WIDE_STRING_USES_UTF16_\n\n// Tests the Random class.\n\nTEST(RandomDeathTest, GeneratesCrashesOnInvalidRange) {\n  testing::internal::Random random(42);\n  EXPECT_DEATH_IF_SUPPORTED(\n      random.Generate(0),\n      \"Cannot generate a number in the range \\\\[0, 0\\\\)\");\n  EXPECT_DEATH_IF_SUPPORTED(\n      random.Generate(testing::internal::Random::kMaxRange + 1),\n      \"Generation of a number in \\\\[0, 2147483649\\\\) was requested, \"\n      \"but this can only generate numbers in \\\\[0, 2147483648\\\\)\");\n}\n\nTEST(RandomTest, GeneratesNumbersWithinRange) {\n  const UInt32 kRange = 10000;\n  testing::internal::Random random(12345);\n  for (int i = 0; i < 10; i++) {\n    EXPECT_LT(random.Generate(kRange), kRange) << \" for iteration \" << i;\n  }\n\n  testing::internal::Random random2(testing::internal::Random::kMaxRange);\n  for (int i = 0; i < 10; i++) {\n    EXPECT_LT(random2.Generate(kRange), kRange) << \" for iteration \" << i;\n  }\n}\n\nTEST(RandomTest, RepeatsWhenReseeded) {\n  const int kSeed = 123;\n  const int kArraySize = 10;\n  const UInt32 kRange = 10000;\n  UInt32 values[kArraySize];\n\n  testing::internal::Random random(kSeed);\n  for (int i = 0; i < kArraySize; i++) {\n    values[i] = random.Generate(kRange);\n  }\n\n  random.Reseed(kSeed);\n  for (int i = 0; i < kArraySize; i++) {\n    EXPECT_EQ(values[i], random.Generate(kRange)) << \" for iteration \" << i;\n  }\n}\n\n// Tests STL container utilities.\n\n// Tests CountIf().\n\nstatic bool IsPositive(int n) { return n > 0; }\n\nTEST(ContainerUtilityTest, CountIf) {\n  std::vector<int> v;\n  EXPECT_EQ(0, CountIf(v, IsPositive));  // Works for an empty container.\n\n  v.push_back(-1);\n  v.push_back(0);\n  EXPECT_EQ(0, CountIf(v, IsPositive));  // Works when no value satisfies.\n\n  v.push_back(2);\n  v.push_back(-10);\n  v.push_back(10);\n  EXPECT_EQ(2, CountIf(v, IsPositive));\n}\n\n// Tests ForEach().\n\nstatic int g_sum = 0;\nstatic void Accumulate(int n) { g_sum += n; }\n\nTEST(ContainerUtilityTest, ForEach) {\n  std::vector<int> v;\n  g_sum = 0;\n  ForEach(v, Accumulate);\n  EXPECT_EQ(0, g_sum);  // Works for an empty container;\n\n  g_sum = 0;\n  v.push_back(1);\n  ForEach(v, Accumulate);\n  EXPECT_EQ(1, g_sum);  // Works for a container with one element.\n\n  g_sum = 0;\n  v.push_back(20);\n  v.push_back(300);\n  ForEach(v, Accumulate);\n  EXPECT_EQ(321, g_sum);\n}\n\n// Tests GetElementOr().\nTEST(ContainerUtilityTest, GetElementOr) {\n  std::vector<char> a;\n  EXPECT_EQ('x', GetElementOr(a, 0, 'x'));\n\n  a.push_back('a');\n  a.push_back('b');\n  EXPECT_EQ('a', GetElementOr(a, 0, 'x'));\n  EXPECT_EQ('b', GetElementOr(a, 1, 'x'));\n  EXPECT_EQ('x', GetElementOr(a, -2, 'x'));\n  EXPECT_EQ('x', GetElementOr(a, 2, 'x'));\n}\n\nTEST(ContainerUtilityDeathTest, ShuffleRange) {\n  std::vector<int> a;\n  a.push_back(0);\n  a.push_back(1);\n  a.push_back(2);\n  testing::internal::Random random(1);\n\n  EXPECT_DEATH_IF_SUPPORTED(\n      ShuffleRange(&random, -1, 1, &a),\n      \"Invalid shuffle range start -1: must be in range \\\\[0, 3\\\\]\");\n  EXPECT_DEATH_IF_SUPPORTED(\n      ShuffleRange(&random, 4, 4, &a),\n      \"Invalid shuffle range start 4: must be in range \\\\[0, 3\\\\]\");\n  EXPECT_DEATH_IF_SUPPORTED(\n      ShuffleRange(&random, 3, 2, &a),\n      \"Invalid shuffle range finish 2: must be in range \\\\[3, 3\\\\]\");\n  EXPECT_DEATH_IF_SUPPORTED(\n      ShuffleRange(&random, 3, 4, &a),\n      \"Invalid shuffle range finish 4: must be in range \\\\[3, 3\\\\]\");\n}\n\nclass VectorShuffleTest : public Test {\n protected:\n  static const int kVectorSize = 20;\n\n  VectorShuffleTest() : random_(1) {\n    for (int i = 0; i < kVectorSize; i++) {\n      vector_.push_back(i);\n    }\n  }\n\n  static bool VectorIsCorrupt(const TestingVector& vector) {\n    if (kVectorSize != static_cast<int>(vector.size())) {\n      return true;\n    }\n\n    bool found_in_vector[kVectorSize] = { false };\n    for (size_t i = 0; i < vector.size(); i++) {\n      const int e = vector[i];\n      if (e < 0 || e >= kVectorSize || found_in_vector[e]) {\n        return true;\n      }\n      found_in_vector[e] = true;\n    }\n\n    // Vector size is correct, elements' range is correct, no\n    // duplicate elements.  Therefore no corruption has occurred.\n    return false;\n  }\n\n  static bool VectorIsNotCorrupt(const TestingVector& vector) {\n    return !VectorIsCorrupt(vector);\n  }\n\n  static bool RangeIsShuffled(const TestingVector& vector, int begin, int end) {\n    for (int i = begin; i < end; i++) {\n      if (i != vector[i]) {\n        return true;\n      }\n    }\n    return false;\n  }\n\n  static bool RangeIsUnshuffled(\n      const TestingVector& vector, int begin, int end) {\n    return !RangeIsShuffled(vector, begin, end);\n  }\n\n  static bool VectorIsShuffled(const TestingVector& vector) {\n    return RangeIsShuffled(vector, 0, static_cast<int>(vector.size()));\n  }\n\n  static bool VectorIsUnshuffled(const TestingVector& vector) {\n    return !VectorIsShuffled(vector);\n  }\n\n  testing::internal::Random random_;\n  TestingVector vector_;\n};  // class VectorShuffleTest\n\nconst int VectorShuffleTest::kVectorSize;\n\nTEST_F(VectorShuffleTest, HandlesEmptyRange) {\n  // Tests an empty range at the beginning...\n  ShuffleRange(&random_, 0, 0, &vector_);\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  ASSERT_PRED1(VectorIsUnshuffled, vector_);\n\n  // ...in the middle...\n  ShuffleRange(&random_, kVectorSize/2, kVectorSize/2, &vector_);\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  ASSERT_PRED1(VectorIsUnshuffled, vector_);\n\n  // ...at the end...\n  ShuffleRange(&random_, kVectorSize - 1, kVectorSize - 1, &vector_);\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  ASSERT_PRED1(VectorIsUnshuffled, vector_);\n\n  // ...and past the end.\n  ShuffleRange(&random_, kVectorSize, kVectorSize, &vector_);\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  ASSERT_PRED1(VectorIsUnshuffled, vector_);\n}\n\nTEST_F(VectorShuffleTest, HandlesRangeOfSizeOne) {\n  // Tests a size one range at the beginning...\n  ShuffleRange(&random_, 0, 1, &vector_);\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  ASSERT_PRED1(VectorIsUnshuffled, vector_);\n\n  // ...in the middle...\n  ShuffleRange(&random_, kVectorSize/2, kVectorSize/2 + 1, &vector_);\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  ASSERT_PRED1(VectorIsUnshuffled, vector_);\n\n  // ...and at the end.\n  ShuffleRange(&random_, kVectorSize - 1, kVectorSize, &vector_);\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  ASSERT_PRED1(VectorIsUnshuffled, vector_);\n}\n\n// Because we use our own random number generator and a fixed seed,\n// we can guarantee that the following \"random\" tests will succeed.\n\nTEST_F(VectorShuffleTest, ShufflesEntireVector) {\n  Shuffle(&random_, &vector_);\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  EXPECT_FALSE(VectorIsUnshuffled(vector_)) << vector_;\n\n  // Tests the first and last elements in particular to ensure that\n  // there are no off-by-one problems in our shuffle algorithm.\n  EXPECT_NE(0, vector_[0]);\n  EXPECT_NE(kVectorSize - 1, vector_[kVectorSize - 1]);\n}\n\nTEST_F(VectorShuffleTest, ShufflesStartOfVector) {\n  const int kRangeSize = kVectorSize/2;\n\n  ShuffleRange(&random_, 0, kRangeSize, &vector_);\n\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  EXPECT_PRED3(RangeIsShuffled, vector_, 0, kRangeSize);\n  EXPECT_PRED3(RangeIsUnshuffled, vector_, kRangeSize, kVectorSize);\n}\n\nTEST_F(VectorShuffleTest, ShufflesEndOfVector) {\n  const int kRangeSize = kVectorSize / 2;\n  ShuffleRange(&random_, kRangeSize, kVectorSize, &vector_);\n\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  EXPECT_PRED3(RangeIsUnshuffled, vector_, 0, kRangeSize);\n  EXPECT_PRED3(RangeIsShuffled, vector_, kRangeSize, kVectorSize);\n}\n\nTEST_F(VectorShuffleTest, ShufflesMiddleOfVector) {\n  int kRangeSize = kVectorSize/3;\n  ShuffleRange(&random_, kRangeSize, 2*kRangeSize, &vector_);\n\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  EXPECT_PRED3(RangeIsUnshuffled, vector_, 0, kRangeSize);\n  EXPECT_PRED3(RangeIsShuffled, vector_, kRangeSize, 2*kRangeSize);\n  EXPECT_PRED3(RangeIsUnshuffled, vector_, 2*kRangeSize, kVectorSize);\n}\n\nTEST_F(VectorShuffleTest, ShufflesRepeatably) {\n  TestingVector vector2;\n  for (int i = 0; i < kVectorSize; i++) {\n    vector2.push_back(i);\n  }\n\n  random_.Reseed(1234);\n  Shuffle(&random_, &vector_);\n  random_.Reseed(1234);\n  Shuffle(&random_, &vector2);\n\n  ASSERT_PRED1(VectorIsNotCorrupt, vector_);\n  ASSERT_PRED1(VectorIsNotCorrupt, vector2);\n\n  for (int i = 0; i < kVectorSize; i++) {\n    EXPECT_EQ(vector_[i], vector2[i]) << \" where i is \" << i;\n  }\n}\n\n// Tests the size of the AssertHelper class.\n\nTEST(AssertHelperTest, AssertHelperIsSmall) {\n  // To avoid breaking clients that use lots of assertions in one\n  // function, we cannot grow the size of AssertHelper.\n  EXPECT_LE(sizeof(testing::internal::AssertHelper), sizeof(void*));\n}\n\n// Tests String::EndsWithCaseInsensitive().\nTEST(StringTest, EndsWithCaseInsensitive) {\n  EXPECT_TRUE(String::EndsWithCaseInsensitive(\"foobar\", \"BAR\"));\n  EXPECT_TRUE(String::EndsWithCaseInsensitive(\"foobaR\", \"bar\"));\n  EXPECT_TRUE(String::EndsWithCaseInsensitive(\"foobar\", \"\"));\n  EXPECT_TRUE(String::EndsWithCaseInsensitive(\"\", \"\"));\n\n  EXPECT_FALSE(String::EndsWithCaseInsensitive(\"Foobar\", \"foo\"));\n  EXPECT_FALSE(String::EndsWithCaseInsensitive(\"foobar\", \"Foo\"));\n  EXPECT_FALSE(String::EndsWithCaseInsensitive(\"\", \"foo\"));\n}\n\n// C++Builder's preprocessor is buggy; it fails to expand macros that\n// appear in macro parameters after wide char literals.  Provide an alias\n// for NULL as a workaround.\nstatic const wchar_t* const kNull = NULL;\n\n// Tests String::CaseInsensitiveWideCStringEquals\nTEST(StringTest, CaseInsensitiveWideCStringEquals) {\n  EXPECT_TRUE(String::CaseInsensitiveWideCStringEquals(NULL, NULL));\n  EXPECT_FALSE(String::CaseInsensitiveWideCStringEquals(kNull, L\"\"));\n  EXPECT_FALSE(String::CaseInsensitiveWideCStringEquals(L\"\", kNull));\n  EXPECT_FALSE(String::CaseInsensitiveWideCStringEquals(kNull, L\"foobar\"));\n  EXPECT_FALSE(String::CaseInsensitiveWideCStringEquals(L\"foobar\", kNull));\n  EXPECT_TRUE(String::CaseInsensitiveWideCStringEquals(L\"foobar\", L\"foobar\"));\n  EXPECT_TRUE(String::CaseInsensitiveWideCStringEquals(L\"foobar\", L\"FOOBAR\"));\n  EXPECT_TRUE(String::CaseInsensitiveWideCStringEquals(L\"FOOBAR\", L\"foobar\"));\n}\n\n#if GTEST_OS_WINDOWS\n\n// Tests String::ShowWideCString().\nTEST(StringTest, ShowWideCString) {\n  EXPECT_STREQ(\"(null)\",\n               String::ShowWideCString(NULL).c_str());\n  EXPECT_STREQ(\"\", String::ShowWideCString(L\"\").c_str());\n  EXPECT_STREQ(\"foo\", String::ShowWideCString(L\"foo\").c_str());\n}\n\n# if GTEST_OS_WINDOWS_MOBILE\nTEST(StringTest, AnsiAndUtf16Null) {\n  EXPECT_EQ(NULL, String::AnsiToUtf16(NULL));\n  EXPECT_EQ(NULL, String::Utf16ToAnsi(NULL));\n}\n\nTEST(StringTest, AnsiAndUtf16ConvertBasic) {\n  const char* ansi = String::Utf16ToAnsi(L\"str\");\n  EXPECT_STREQ(\"str\", ansi);\n  delete [] ansi;\n  const WCHAR* utf16 = String::AnsiToUtf16(\"str\");\n  EXPECT_EQ(0, wcsncmp(L\"str\", utf16, 3));\n  delete [] utf16;\n}\n\nTEST(StringTest, AnsiAndUtf16ConvertPathChars) {\n  const char* ansi = String::Utf16ToAnsi(L\".:\\\\ \\\"*?\");\n  EXPECT_STREQ(\".:\\\\ \\\"*?\", ansi);\n  delete [] ansi;\n  const WCHAR* utf16 = String::AnsiToUtf16(\".:\\\\ \\\"*?\");\n  EXPECT_EQ(0, wcsncmp(L\".:\\\\ \\\"*?\", utf16, 3));\n  delete [] utf16;\n}\n# endif  // GTEST_OS_WINDOWS_MOBILE\n\n#endif  // GTEST_OS_WINDOWS\n\n// Tests TestProperty construction.\nTEST(TestPropertyTest, StringValue) {\n  TestProperty property(\"key\", \"1\");\n  EXPECT_STREQ(\"key\", property.key());\n  EXPECT_STREQ(\"1\", property.value());\n}\n\n// Tests TestProperty replacing a value.\nTEST(TestPropertyTest, ReplaceStringValue) {\n  TestProperty property(\"key\", \"1\");\n  EXPECT_STREQ(\"1\", property.value());\n  property.SetValue(\"2\");\n  EXPECT_STREQ(\"2\", property.value());\n}\n\n// AddFatalFailure() and AddNonfatalFailure() must be stand-alone\n// functions (i.e. their definitions cannot be inlined at the call\n// sites), or C++Builder won't compile the code.\nstatic void AddFatalFailure() {\n  FAIL() << \"Expected fatal failure.\";\n}\n\nstatic void AddNonfatalFailure() {\n  ADD_FAILURE() << \"Expected non-fatal failure.\";\n}\n\nclass ScopedFakeTestPartResultReporterTest : public Test {\n public:  // Must be public and not protected due to a bug in g++ 3.4.2.\n  enum FailureMode {\n    FATAL_FAILURE,\n    NONFATAL_FAILURE\n  };\n  static void AddFailure(FailureMode failure) {\n    if (failure == FATAL_FAILURE) {\n      AddFatalFailure();\n    } else {\n      AddNonfatalFailure();\n    }\n  }\n};\n\n// Tests that ScopedFakeTestPartResultReporter intercepts test\n// failures.\nTEST_F(ScopedFakeTestPartResultReporterTest, InterceptsTestFailures) {\n  TestPartResultArray results;\n  {\n    ScopedFakeTestPartResultReporter reporter(\n        ScopedFakeTestPartResultReporter::INTERCEPT_ONLY_CURRENT_THREAD,\n        &results);\n    AddFailure(NONFATAL_FAILURE);\n    AddFailure(FATAL_FAILURE);\n  }\n\n  EXPECT_EQ(2, results.size());\n  EXPECT_TRUE(results.GetTestPartResult(0).nonfatally_failed());\n  EXPECT_TRUE(results.GetTestPartResult(1).fatally_failed());\n}\n\nTEST_F(ScopedFakeTestPartResultReporterTest, DeprecatedConstructor) {\n  TestPartResultArray results;\n  {\n    // Tests, that the deprecated constructor still works.\n    ScopedFakeTestPartResultReporter reporter(&results);\n    AddFailure(NONFATAL_FAILURE);\n  }\n  EXPECT_EQ(1, results.size());\n}\n\n#if GTEST_IS_THREADSAFE\n\nclass ScopedFakeTestPartResultReporterWithThreadsTest\n  : public ScopedFakeTestPartResultReporterTest {\n protected:\n  static void AddFailureInOtherThread(FailureMode failure) {\n    ThreadWithParam<FailureMode> thread(&AddFailure, failure, NULL);\n    thread.Join();\n  }\n};\n\nTEST_F(ScopedFakeTestPartResultReporterWithThreadsTest,\n       InterceptsTestFailuresInAllThreads) {\n  TestPartResultArray results;\n  {\n    ScopedFakeTestPartResultReporter reporter(\n        ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS, &results);\n    AddFailure(NONFATAL_FAILURE);\n    AddFailure(FATAL_FAILURE);\n    AddFailureInOtherThread(NONFATAL_FAILURE);\n    AddFailureInOtherThread(FATAL_FAILURE);\n  }\n\n  EXPECT_EQ(4, results.size());\n  EXPECT_TRUE(results.GetTestPartResult(0).nonfatally_failed());\n  EXPECT_TRUE(results.GetTestPartResult(1).fatally_failed());\n  EXPECT_TRUE(results.GetTestPartResult(2).nonfatally_failed());\n  EXPECT_TRUE(results.GetTestPartResult(3).fatally_failed());\n}\n\n#endif  // GTEST_IS_THREADSAFE\n\n// Tests EXPECT_FATAL_FAILURE{,ON_ALL_THREADS}.  Makes sure that they\n// work even if the failure is generated in a called function rather than\n// the current context.\n\ntypedef ScopedFakeTestPartResultReporterTest ExpectFatalFailureTest;\n\nTEST_F(ExpectFatalFailureTest, CatchesFatalFaliure) {\n  EXPECT_FATAL_FAILURE(AddFatalFailure(), \"Expected fatal failure.\");\n}\n\n#if GTEST_HAS_GLOBAL_STRING\nTEST_F(ExpectFatalFailureTest, AcceptsStringObject) {\n  EXPECT_FATAL_FAILURE(AddFatalFailure(), ::string(\"Expected fatal failure.\"));\n}\n#endif\n\nTEST_F(ExpectFatalFailureTest, AcceptsStdStringObject) {\n  EXPECT_FATAL_FAILURE(AddFatalFailure(),\n                       ::std::string(\"Expected fatal failure.\"));\n}\n\nTEST_F(ExpectFatalFailureTest, CatchesFatalFailureOnAllThreads) {\n  // We have another test below to verify that the macro catches fatal\n  // failures generated on another thread.\n  EXPECT_FATAL_FAILURE_ON_ALL_THREADS(AddFatalFailure(),\n                                      \"Expected fatal failure.\");\n}\n\n#ifdef __BORLANDC__\n// Silences warnings: \"Condition is always true\"\n# pragma option push -w-ccc\n#endif\n\n// Tests that EXPECT_FATAL_FAILURE() can be used in a non-void\n// function even when the statement in it contains ASSERT_*.\n\nint NonVoidFunction() {\n  EXPECT_FATAL_FAILURE(ASSERT_TRUE(false), \"\");\n  EXPECT_FATAL_FAILURE_ON_ALL_THREADS(FAIL(), \"\");\n  return 0;\n}\n\nTEST_F(ExpectFatalFailureTest, CanBeUsedInNonVoidFunction) {\n  NonVoidFunction();\n}\n\n// Tests that EXPECT_FATAL_FAILURE(statement, ...) doesn't abort the\n// current function even though 'statement' generates a fatal failure.\n\nvoid DoesNotAbortHelper(bool* aborted) {\n  EXPECT_FATAL_FAILURE(ASSERT_TRUE(false), \"\");\n  EXPECT_FATAL_FAILURE_ON_ALL_THREADS(FAIL(), \"\");\n\n  *aborted = false;\n}\n\n#ifdef __BORLANDC__\n// Restores warnings after previous \"#pragma option push\" suppressed them.\n# pragma option pop\n#endif\n\nTEST_F(ExpectFatalFailureTest, DoesNotAbort) {\n  bool aborted = true;\n  DoesNotAbortHelper(&aborted);\n  EXPECT_FALSE(aborted);\n}\n\n// Tests that the EXPECT_FATAL_FAILURE{,_ON_ALL_THREADS} accepts a\n// statement that contains a macro which expands to code containing an\n// unprotected comma.\n\nstatic int global_var = 0;\n#define GTEST_USE_UNPROTECTED_COMMA_ global_var++, global_var++\n\nTEST_F(ExpectFatalFailureTest, AcceptsMacroThatExpandsToUnprotectedComma) {\n#ifndef __BORLANDC__\n  // ICE's in C++Builder.\n  EXPECT_FATAL_FAILURE({\n    GTEST_USE_UNPROTECTED_COMMA_;\n    AddFatalFailure();\n  }, \"\");\n#endif\n\n  EXPECT_FATAL_FAILURE_ON_ALL_THREADS({\n    GTEST_USE_UNPROTECTED_COMMA_;\n    AddFatalFailure();\n  }, \"\");\n}\n\n// Tests EXPECT_NONFATAL_FAILURE{,ON_ALL_THREADS}.\n\ntypedef ScopedFakeTestPartResultReporterTest ExpectNonfatalFailureTest;\n\nTEST_F(ExpectNonfatalFailureTest, CatchesNonfatalFailure) {\n  EXPECT_NONFATAL_FAILURE(AddNonfatalFailure(),\n                          \"Expected non-fatal failure.\");\n}\n\n#if GTEST_HAS_GLOBAL_STRING\nTEST_F(ExpectNonfatalFailureTest, AcceptsStringObject) {\n  EXPECT_NONFATAL_FAILURE(AddNonfatalFailure(),\n                          ::string(\"Expected non-fatal failure.\"));\n}\n#endif\n\nTEST_F(ExpectNonfatalFailureTest, AcceptsStdStringObject) {\n  EXPECT_NONFATAL_FAILURE(AddNonfatalFailure(),\n                          ::std::string(\"Expected non-fatal failure.\"));\n}\n\nTEST_F(ExpectNonfatalFailureTest, CatchesNonfatalFailureOnAllThreads) {\n  // We have another test below to verify that the macro catches\n  // non-fatal failures generated on another thread.\n  EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(AddNonfatalFailure(),\n                                         \"Expected non-fatal failure.\");\n}\n\n// Tests that the EXPECT_NONFATAL_FAILURE{,_ON_ALL_THREADS} accepts a\n// statement that contains a macro which expands to code containing an\n// unprotected comma.\nTEST_F(ExpectNonfatalFailureTest, AcceptsMacroThatExpandsToUnprotectedComma) {\n  EXPECT_NONFATAL_FAILURE({\n    GTEST_USE_UNPROTECTED_COMMA_;\n    AddNonfatalFailure();\n  }, \"\");\n\n  EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS({\n    GTEST_USE_UNPROTECTED_COMMA_;\n    AddNonfatalFailure();\n  }, \"\");\n}\n\n#if GTEST_IS_THREADSAFE\n\ntypedef ScopedFakeTestPartResultReporterWithThreadsTest\n    ExpectFailureWithThreadsTest;\n\nTEST_F(ExpectFailureWithThreadsTest, ExpectFatalFailureOnAllThreads) {\n  EXPECT_FATAL_FAILURE_ON_ALL_THREADS(AddFailureInOtherThread(FATAL_FAILURE),\n                                      \"Expected fatal failure.\");\n}\n\nTEST_F(ExpectFailureWithThreadsTest, ExpectNonFatalFailureOnAllThreads) {\n  EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(\n      AddFailureInOtherThread(NONFATAL_FAILURE), \"Expected non-fatal failure.\");\n}\n\n#endif  // GTEST_IS_THREADSAFE\n\n// Tests the TestProperty class.\n\nTEST(TestPropertyTest, ConstructorWorks) {\n  const TestProperty property(\"key\", \"value\");\n  EXPECT_STREQ(\"key\", property.key());\n  EXPECT_STREQ(\"value\", property.value());\n}\n\nTEST(TestPropertyTest, SetValue) {\n  TestProperty property(\"key\", \"value_1\");\n  EXPECT_STREQ(\"key\", property.key());\n  property.SetValue(\"value_2\");\n  EXPECT_STREQ(\"key\", property.key());\n  EXPECT_STREQ(\"value_2\", property.value());\n}\n\n// Tests the TestResult class\n\n// The test fixture for testing TestResult.\nclass TestResultTest : public Test {\n protected:\n  typedef std::vector<TestPartResult> TPRVector;\n\n  // We make use of 2 TestPartResult objects,\n  TestPartResult * pr1, * pr2;\n\n  // ... and 3 TestResult objects.\n  TestResult * r0, * r1, * r2;\n\n  virtual void SetUp() {\n    // pr1 is for success.\n    pr1 = new TestPartResult(TestPartResult::kSuccess,\n                             \"foo/bar.cc\",\n                             10,\n                             \"Success!\");\n\n    // pr2 is for fatal failure.\n    pr2 = new TestPartResult(TestPartResult::kFatalFailure,\n                             \"foo/bar.cc\",\n                             -1,  // This line number means \"unknown\"\n                             \"Failure!\");\n\n    // Creates the TestResult objects.\n    r0 = new TestResult();\n    r1 = new TestResult();\n    r2 = new TestResult();\n\n    // In order to test TestResult, we need to modify its internal\n    // state, in particular the TestPartResult vector it holds.\n    // test_part_results() returns a const reference to this vector.\n    // We cast it to a non-const object s.t. it can be modified (yes,\n    // this is a hack).\n    TPRVector* results1 = const_cast<TPRVector*>(\n        &TestResultAccessor::test_part_results(*r1));\n    TPRVector* results2 = const_cast<TPRVector*>(\n        &TestResultAccessor::test_part_results(*r2));\n\n    // r0 is an empty TestResult.\n\n    // r1 contains a single SUCCESS TestPartResult.\n    results1->push_back(*pr1);\n\n    // r2 contains a SUCCESS, and a FAILURE.\n    results2->push_back(*pr1);\n    results2->push_back(*pr2);\n  }\n\n  virtual void TearDown() {\n    delete pr1;\n    delete pr2;\n\n    delete r0;\n    delete r1;\n    delete r2;\n  }\n\n  // Helper that compares two two TestPartResults.\n  static void CompareTestPartResult(const TestPartResult& expected,\n                                    const TestPartResult& actual) {\n    EXPECT_EQ(expected.type(), actual.type());\n    EXPECT_STREQ(expected.file_name(), actual.file_name());\n    EXPECT_EQ(expected.line_number(), actual.line_number());\n    EXPECT_STREQ(expected.summary(), actual.summary());\n    EXPECT_STREQ(expected.message(), actual.message());\n    EXPECT_EQ(expected.passed(), actual.passed());\n    EXPECT_EQ(expected.failed(), actual.failed());\n    EXPECT_EQ(expected.nonfatally_failed(), actual.nonfatally_failed());\n    EXPECT_EQ(expected.fatally_failed(), actual.fatally_failed());\n  }\n};\n\n// Tests TestResult::total_part_count().\nTEST_F(TestResultTest, total_part_count) {\n  ASSERT_EQ(0, r0->total_part_count());\n  ASSERT_EQ(1, r1->total_part_count());\n  ASSERT_EQ(2, r2->total_part_count());\n}\n\n// Tests TestResult::Passed().\nTEST_F(TestResultTest, Passed) {\n  ASSERT_TRUE(r0->Passed());\n  ASSERT_TRUE(r1->Passed());\n  ASSERT_FALSE(r2->Passed());\n}\n\n// Tests TestResult::Failed().\nTEST_F(TestResultTest, Failed) {\n  ASSERT_FALSE(r0->Failed());\n  ASSERT_FALSE(r1->Failed());\n  ASSERT_TRUE(r2->Failed());\n}\n\n// Tests TestResult::GetTestPartResult().\n\ntypedef TestResultTest TestResultDeathTest;\n\nTEST_F(TestResultDeathTest, GetTestPartResult) {\n  CompareTestPartResult(*pr1, r2->GetTestPartResult(0));\n  CompareTestPartResult(*pr2, r2->GetTestPartResult(1));\n  EXPECT_DEATH_IF_SUPPORTED(r2->GetTestPartResult(2), \"\");\n  EXPECT_DEATH_IF_SUPPORTED(r2->GetTestPartResult(-1), \"\");\n}\n\n// Tests TestResult has no properties when none are added.\nTEST(TestResultPropertyTest, NoPropertiesFoundWhenNoneAreAdded) {\n  TestResult test_result;\n  ASSERT_EQ(0, test_result.test_property_count());\n}\n\n// Tests TestResult has the expected property when added.\nTEST(TestResultPropertyTest, OnePropertyFoundWhenAdded) {\n  TestResult test_result;\n  TestProperty property(\"key_1\", \"1\");\n  TestResultAccessor::RecordProperty(&test_result, \"testcase\", property);\n  ASSERT_EQ(1, test_result.test_property_count());\n  const TestProperty& actual_property = test_result.GetTestProperty(0);\n  EXPECT_STREQ(\"key_1\", actual_property.key());\n  EXPECT_STREQ(\"1\", actual_property.value());\n}\n\n// Tests TestResult has multiple properties when added.\nTEST(TestResultPropertyTest, MultiplePropertiesFoundWhenAdded) {\n  TestResult test_result;\n  TestProperty property_1(\"key_1\", \"1\");\n  TestProperty property_2(\"key_2\", \"2\");\n  TestResultAccessor::RecordProperty(&test_result, \"testcase\", property_1);\n  TestResultAccessor::RecordProperty(&test_result, \"testcase\", property_2);\n  ASSERT_EQ(2, test_result.test_property_count());\n  const TestProperty& actual_property_1 = test_result.GetTestProperty(0);\n  EXPECT_STREQ(\"key_1\", actual_property_1.key());\n  EXPECT_STREQ(\"1\", actual_property_1.value());\n\n  const TestProperty& actual_property_2 = test_result.GetTestProperty(1);\n  EXPECT_STREQ(\"key_2\", actual_property_2.key());\n  EXPECT_STREQ(\"2\", actual_property_2.value());\n}\n\n// Tests TestResult::RecordProperty() overrides values for duplicate keys.\nTEST(TestResultPropertyTest, OverridesValuesForDuplicateKeys) {\n  TestResult test_result;\n  TestProperty property_1_1(\"key_1\", \"1\");\n  TestProperty property_2_1(\"key_2\", \"2\");\n  TestProperty property_1_2(\"key_1\", \"12\");\n  TestProperty property_2_2(\"key_2\", \"22\");\n  TestResultAccessor::RecordProperty(&test_result, \"testcase\", property_1_1);\n  TestResultAccessor::RecordProperty(&test_result, \"testcase\", property_2_1);\n  TestResultAccessor::RecordProperty(&test_result, \"testcase\", property_1_2);\n  TestResultAccessor::RecordProperty(&test_result, \"testcase\", property_2_2);\n\n  ASSERT_EQ(2, test_result.test_property_count());\n  const TestProperty& actual_property_1 = test_result.GetTestProperty(0);\n  EXPECT_STREQ(\"key_1\", actual_property_1.key());\n  EXPECT_STREQ(\"12\", actual_property_1.value());\n\n  const TestProperty& actual_property_2 = test_result.GetTestProperty(1);\n  EXPECT_STREQ(\"key_2\", actual_property_2.key());\n  EXPECT_STREQ(\"22\", actual_property_2.value());\n}\n\n// Tests TestResult::GetTestProperty().\nTEST(TestResultPropertyTest, GetTestProperty) {\n  TestResult test_result;\n  TestProperty property_1(\"key_1\", \"1\");\n  TestProperty property_2(\"key_2\", \"2\");\n  TestProperty property_3(\"key_3\", \"3\");\n  TestResultAccessor::RecordProperty(&test_result, \"testcase\", property_1);\n  TestResultAccessor::RecordProperty(&test_result, \"testcase\", property_2);\n  TestResultAccessor::RecordProperty(&test_result, \"testcase\", property_3);\n\n  const TestProperty& fetched_property_1 = test_result.GetTestProperty(0);\n  const TestProperty& fetched_property_2 = test_result.GetTestProperty(1);\n  const TestProperty& fetched_property_3 = test_result.GetTestProperty(2);\n\n  EXPECT_STREQ(\"key_1\", fetched_property_1.key());\n  EXPECT_STREQ(\"1\", fetched_property_1.value());\n\n  EXPECT_STREQ(\"key_2\", fetched_property_2.key());\n  EXPECT_STREQ(\"2\", fetched_property_2.value());\n\n  EXPECT_STREQ(\"key_3\", fetched_property_3.key());\n  EXPECT_STREQ(\"3\", fetched_property_3.value());\n\n  EXPECT_DEATH_IF_SUPPORTED(test_result.GetTestProperty(3), \"\");\n  EXPECT_DEATH_IF_SUPPORTED(test_result.GetTestProperty(-1), \"\");\n}\n\n// Tests that GTestFlagSaver works on Windows and Mac.\n\nclass GTestFlagSaverTest : public Test {\n protected:\n  // Saves the Google Test flags such that we can restore them later, and\n  // then sets them to their default values.  This will be called\n  // before the first test in this test case is run.\n  static void SetUpTestCase() {\n    saver_ = new GTestFlagSaver;\n\n    GTEST_FLAG(also_run_disabled_tests) = false;\n    GTEST_FLAG(break_on_failure) = false;\n    GTEST_FLAG(catch_exceptions) = false;\n    GTEST_FLAG(death_test_use_fork) = false;\n    GTEST_FLAG(color) = \"auto\";\n    GTEST_FLAG(filter) = \"\";\n    GTEST_FLAG(list_tests) = false;\n    GTEST_FLAG(output) = \"\";\n    GTEST_FLAG(print_time) = true;\n    GTEST_FLAG(random_seed) = 0;\n    GTEST_FLAG(repeat) = 1;\n    GTEST_FLAG(shuffle) = false;\n    GTEST_FLAG(stack_trace_depth) = kMaxStackTraceDepth;\n    GTEST_FLAG(stream_result_to) = \"\";\n    GTEST_FLAG(throw_on_failure) = false;\n  }\n\n  // Restores the Google Test flags that the tests have modified.  This will\n  // be called after the last test in this test case is run.\n  static void TearDownTestCase() {\n    delete saver_;\n    saver_ = NULL;\n  }\n\n  // Verifies that the Google Test flags have their default values, and then\n  // modifies each of them.\n  void VerifyAndModifyFlags() {\n    EXPECT_FALSE(GTEST_FLAG(also_run_disabled_tests));\n    EXPECT_FALSE(GTEST_FLAG(break_on_failure));\n    EXPECT_FALSE(GTEST_FLAG(catch_exceptions));\n    EXPECT_STREQ(\"auto\", GTEST_FLAG(color).c_str());\n    EXPECT_FALSE(GTEST_FLAG(death_test_use_fork));\n    EXPECT_STREQ(\"\", GTEST_FLAG(filter).c_str());\n    EXPECT_FALSE(GTEST_FLAG(list_tests));\n    EXPECT_STREQ(\"\", GTEST_FLAG(output).c_str());\n    EXPECT_TRUE(GTEST_FLAG(print_time));\n    EXPECT_EQ(0, GTEST_FLAG(random_seed));\n    EXPECT_EQ(1, GTEST_FLAG(repeat));\n    EXPECT_FALSE(GTEST_FLAG(shuffle));\n    EXPECT_EQ(kMaxStackTraceDepth, GTEST_FLAG(stack_trace_depth));\n    EXPECT_STREQ(\"\", GTEST_FLAG(stream_result_to).c_str());\n    EXPECT_FALSE(GTEST_FLAG(throw_on_failure));\n\n    GTEST_FLAG(also_run_disabled_tests) = true;\n    GTEST_FLAG(break_on_failure) = true;\n    GTEST_FLAG(catch_exceptions) = true;\n    GTEST_FLAG(color) = \"no\";\n    GTEST_FLAG(death_test_use_fork) = true;\n    GTEST_FLAG(filter) = \"abc\";\n    GTEST_FLAG(list_tests) = true;\n    GTEST_FLAG(output) = \"xml:foo.xml\";\n    GTEST_FLAG(print_time) = false;\n    GTEST_FLAG(random_seed) = 1;\n    GTEST_FLAG(repeat) = 100;\n    GTEST_FLAG(shuffle) = true;\n    GTEST_FLAG(stack_trace_depth) = 1;\n    GTEST_FLAG(stream_result_to) = \"localhost:1234\";\n    GTEST_FLAG(throw_on_failure) = true;\n  }\n\n private:\n  // For saving Google Test flags during this test case.\n  static GTestFlagSaver* saver_;\n};\n\nGTestFlagSaver* GTestFlagSaverTest::saver_ = NULL;\n\n// Google Test doesn't guarantee the order of tests.  The following two\n// tests are designed to work regardless of their order.\n\n// Modifies the Google Test flags in the test body.\nTEST_F(GTestFlagSaverTest, ModifyGTestFlags) {\n  VerifyAndModifyFlags();\n}\n\n// Verifies that the Google Test flags in the body of the previous test were\n// restored to their original values.\nTEST_F(GTestFlagSaverTest, VerifyGTestFlags) {\n  VerifyAndModifyFlags();\n}\n\n// Sets an environment variable with the given name to the given\n// value.  If the value argument is \"\", unsets the environment\n// variable.  The caller must ensure that both arguments are not NULL.\nstatic void SetEnv(const char* name, const char* value) {\n#if GTEST_OS_WINDOWS_MOBILE\n  // Environment variables are not supported on Windows CE.\n  return;\n#elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9)\n  // C++Builder's putenv only stores a pointer to its parameter; we have to\n  // ensure that the string remains valid as long as it might be needed.\n  // We use an std::map to do so.\n  static std::map<std::string, std::string*> added_env;\n\n  // Because putenv stores a pointer to the string buffer, we can't delete the\n  // previous string (if present) until after it's replaced.\n  std::string *prev_env = NULL;\n  if (added_env.find(name) != added_env.end()) {\n    prev_env = added_env[name];\n  }\n  added_env[name] = new std::string(\n      (Message() << name << \"=\" << value).GetString());\n\n  // The standard signature of putenv accepts a 'char*' argument. Other\n  // implementations, like C++Builder's, accept a 'const char*'.\n  // We cast away the 'const' since that would work for both variants.\n  putenv(const_cast<char*>(added_env[name]->c_str()));\n  delete prev_env;\n#elif GTEST_OS_WINDOWS  // If we are on Windows proper.\n  _putenv((Message() << name << \"=\" << value).GetString().c_str());\n#else\n  if (*value == '\\0') {\n    unsetenv(name);\n  } else {\n    setenv(name, value, 1);\n  }\n#endif  // GTEST_OS_WINDOWS_MOBILE\n}\n\n#if !GTEST_OS_WINDOWS_MOBILE\n// Environment variables are not supported on Windows CE.\n\nusing testing::internal::Int32FromGTestEnv;\n\n// Tests Int32FromGTestEnv().\n\n// Tests that Int32FromGTestEnv() returns the default value when the\n// environment variable is not set.\nTEST(Int32FromGTestEnvTest, ReturnsDefaultWhenVariableIsNotSet) {\n  SetEnv(GTEST_FLAG_PREFIX_UPPER_ \"TEMP\", \"\");\n  EXPECT_EQ(10, Int32FromGTestEnv(\"temp\", 10));\n}\n\n// Tests that Int32FromGTestEnv() returns the default value when the\n// environment variable overflows as an Int32.\nTEST(Int32FromGTestEnvTest, ReturnsDefaultWhenValueOverflows) {\n  printf(\"(expecting 2 warnings)\\n\");\n\n  SetEnv(GTEST_FLAG_PREFIX_UPPER_ \"TEMP\", \"12345678987654321\");\n  EXPECT_EQ(20, Int32FromGTestEnv(\"temp\", 20));\n\n  SetEnv(GTEST_FLAG_PREFIX_UPPER_ \"TEMP\", \"-12345678987654321\");\n  EXPECT_EQ(30, Int32FromGTestEnv(\"temp\", 30));\n}\n\n// Tests that Int32FromGTestEnv() returns the default value when the\n// environment variable does not represent a valid decimal integer.\nTEST(Int32FromGTestEnvTest, ReturnsDefaultWhenValueIsInvalid) {\n  printf(\"(expecting 2 warnings)\\n\");\n\n  SetEnv(GTEST_FLAG_PREFIX_UPPER_ \"TEMP\", \"A1\");\n  EXPECT_EQ(40, Int32FromGTestEnv(\"temp\", 40));\n\n  SetEnv(GTEST_FLAG_PREFIX_UPPER_ \"TEMP\", \"12X\");\n  EXPECT_EQ(50, Int32FromGTestEnv(\"temp\", 50));\n}\n\n// Tests that Int32FromGTestEnv() parses and returns the value of the\n// environment variable when it represents a valid decimal integer in\n// the range of an Int32.\nTEST(Int32FromGTestEnvTest, ParsesAndReturnsValidValue) {\n  SetEnv(GTEST_FLAG_PREFIX_UPPER_ \"TEMP\", \"123\");\n  EXPECT_EQ(123, Int32FromGTestEnv(\"temp\", 0));\n\n  SetEnv(GTEST_FLAG_PREFIX_UPPER_ \"TEMP\", \"-321\");\n  EXPECT_EQ(-321, Int32FromGTestEnv(\"temp\", 0));\n}\n#endif  // !GTEST_OS_WINDOWS_MOBILE\n\n// Tests ParseInt32Flag().\n\n// Tests that ParseInt32Flag() returns false and doesn't change the\n// output value when the flag has wrong format\nTEST(ParseInt32FlagTest, ReturnsFalseForInvalidFlag) {\n  Int32 value = 123;\n  EXPECT_FALSE(ParseInt32Flag(\"--a=100\", \"b\", &value));\n  EXPECT_EQ(123, value);\n\n  EXPECT_FALSE(ParseInt32Flag(\"a=100\", \"a\", &value));\n  EXPECT_EQ(123, value);\n}\n\n// Tests that ParseInt32Flag() returns false and doesn't change the\n// output value when the flag overflows as an Int32.\nTEST(ParseInt32FlagTest, ReturnsDefaultWhenValueOverflows) {\n  printf(\"(expecting 2 warnings)\\n\");\n\n  Int32 value = 123;\n  EXPECT_FALSE(ParseInt32Flag(\"--abc=12345678987654321\", \"abc\", &value));\n  EXPECT_EQ(123, value);\n\n  EXPECT_FALSE(ParseInt32Flag(\"--abc=-12345678987654321\", \"abc\", &value));\n  EXPECT_EQ(123, value);\n}\n\n// Tests that ParseInt32Flag() returns false and doesn't change the\n// output value when the flag does not represent a valid decimal\n// integer.\nTEST(ParseInt32FlagTest, ReturnsDefaultWhenValueIsInvalid) {\n  printf(\"(expecting 2 warnings)\\n\");\n\n  Int32 value = 123;\n  EXPECT_FALSE(ParseInt32Flag(\"--abc=A1\", \"abc\", &value));\n  EXPECT_EQ(123, value);\n\n  EXPECT_FALSE(ParseInt32Flag(\"--abc=12X\", \"abc\", &value));\n  EXPECT_EQ(123, value);\n}\n\n// Tests that ParseInt32Flag() parses the value of the flag and\n// returns true when the flag represents a valid decimal integer in\n// the range of an Int32.\nTEST(ParseInt32FlagTest, ParsesAndReturnsValidValue) {\n  Int32 value = 123;\n  EXPECT_TRUE(ParseInt32Flag(\"--\" GTEST_FLAG_PREFIX_ \"abc=456\", \"abc\", &value));\n  EXPECT_EQ(456, value);\n\n  EXPECT_TRUE(ParseInt32Flag(\"--\" GTEST_FLAG_PREFIX_ \"abc=-789\",\n                             \"abc\", &value));\n  EXPECT_EQ(-789, value);\n}\n\n// Tests that Int32FromEnvOrDie() parses the value of the var or\n// returns the correct default.\n// Environment variables are not supported on Windows CE.\n#if !GTEST_OS_WINDOWS_MOBILE\nTEST(Int32FromEnvOrDieTest, ParsesAndReturnsValidValue) {\n  EXPECT_EQ(333, Int32FromEnvOrDie(GTEST_FLAG_PREFIX_UPPER_ \"UnsetVar\", 333));\n  SetEnv(GTEST_FLAG_PREFIX_UPPER_ \"UnsetVar\", \"123\");\n  EXPECT_EQ(123, Int32FromEnvOrDie(GTEST_FLAG_PREFIX_UPPER_ \"UnsetVar\", 333));\n  SetEnv(GTEST_FLAG_PREFIX_UPPER_ \"UnsetVar\", \"-123\");\n  EXPECT_EQ(-123, Int32FromEnvOrDie(GTEST_FLAG_PREFIX_UPPER_ \"UnsetVar\", 333));\n}\n#endif  // !GTEST_OS_WINDOWS_MOBILE\n\n// Tests that Int32FromEnvOrDie() aborts with an error message\n// if the variable is not an Int32.\nTEST(Int32FromEnvOrDieDeathTest, AbortsOnFailure) {\n  SetEnv(GTEST_FLAG_PREFIX_UPPER_ \"VAR\", \"xxx\");\n  EXPECT_DEATH_IF_SUPPORTED(\n      Int32FromEnvOrDie(GTEST_FLAG_PREFIX_UPPER_ \"VAR\", 123),\n      \".*\");\n}\n\n// Tests that Int32FromEnvOrDie() aborts with an error message\n// if the variable cannot be represnted by an Int32.\nTEST(Int32FromEnvOrDieDeathTest, AbortsOnInt32Overflow) {\n  SetEnv(GTEST_FLAG_PREFIX_UPPER_ \"VAR\", \"1234567891234567891234\");\n  EXPECT_DEATH_IF_SUPPORTED(\n      Int32FromEnvOrDie(GTEST_FLAG_PREFIX_UPPER_ \"VAR\", 123),\n      \".*\");\n}\n\n// Tests that ShouldRunTestOnShard() selects all tests\n// where there is 1 shard.\nTEST(ShouldRunTestOnShardTest, IsPartitionWhenThereIsOneShard) {\n  EXPECT_TRUE(ShouldRunTestOnShard(1, 0, 0));\n  EXPECT_TRUE(ShouldRunTestOnShard(1, 0, 1));\n  EXPECT_TRUE(ShouldRunTestOnShard(1, 0, 2));\n  EXPECT_TRUE(ShouldRunTestOnShard(1, 0, 3));\n  EXPECT_TRUE(ShouldRunTestOnShard(1, 0, 4));\n}\n\nclass ShouldShardTest : public testing::Test {\n protected:\n  virtual void SetUp() {\n    index_var_ = GTEST_FLAG_PREFIX_UPPER_ \"INDEX\";\n    total_var_ = GTEST_FLAG_PREFIX_UPPER_ \"TOTAL\";\n  }\n\n  virtual void TearDown() {\n    SetEnv(index_var_, \"\");\n    SetEnv(total_var_, \"\");\n  }\n\n  const char* index_var_;\n  const char* total_var_;\n};\n\n// Tests that sharding is disabled if neither of the environment variables\n// are set.\nTEST_F(ShouldShardTest, ReturnsFalseWhenNeitherEnvVarIsSet) {\n  SetEnv(index_var_, \"\");\n  SetEnv(total_var_, \"\");\n\n  EXPECT_FALSE(ShouldShard(total_var_, index_var_, false));\n  EXPECT_FALSE(ShouldShard(total_var_, index_var_, true));\n}\n\n// Tests that sharding is not enabled if total_shards  == 1.\nTEST_F(ShouldShardTest, ReturnsFalseWhenTotalShardIsOne) {\n  SetEnv(index_var_, \"0\");\n  SetEnv(total_var_, \"1\");\n  EXPECT_FALSE(ShouldShard(total_var_, index_var_, false));\n  EXPECT_FALSE(ShouldShard(total_var_, index_var_, true));\n}\n\n// Tests that sharding is enabled if total_shards > 1 and\n// we are not in a death test subprocess.\n// Environment variables are not supported on Windows CE.\n#if !GTEST_OS_WINDOWS_MOBILE\nTEST_F(ShouldShardTest, WorksWhenShardEnvVarsAreValid) {\n  SetEnv(index_var_, \"4\");\n  SetEnv(total_var_, \"22\");\n  EXPECT_TRUE(ShouldShard(total_var_, index_var_, false));\n  EXPECT_FALSE(ShouldShard(total_var_, index_var_, true));\n\n  SetEnv(index_var_, \"8\");\n  SetEnv(total_var_, \"9\");\n  EXPECT_TRUE(ShouldShard(total_var_, index_var_, false));\n  EXPECT_FALSE(ShouldShard(total_var_, index_var_, true));\n\n  SetEnv(index_var_, \"0\");\n  SetEnv(total_var_, \"9\");\n  EXPECT_TRUE(ShouldShard(total_var_, index_var_, false));\n  EXPECT_FALSE(ShouldShard(total_var_, index_var_, true));\n}\n#endif  // !GTEST_OS_WINDOWS_MOBILE\n\n// Tests that we exit in error if the sharding values are not valid.\n\ntypedef ShouldShardTest ShouldShardDeathTest;\n\nTEST_F(ShouldShardDeathTest, AbortsWhenShardingEnvVarsAreInvalid) {\n  SetEnv(index_var_, \"4\");\n  SetEnv(total_var_, \"4\");\n  EXPECT_DEATH_IF_SUPPORTED(ShouldShard(total_var_, index_var_, false), \".*\");\n\n  SetEnv(index_var_, \"4\");\n  SetEnv(total_var_, \"-2\");\n  EXPECT_DEATH_IF_SUPPORTED(ShouldShard(total_var_, index_var_, false), \".*\");\n\n  SetEnv(index_var_, \"5\");\n  SetEnv(total_var_, \"\");\n  EXPECT_DEATH_IF_SUPPORTED(ShouldShard(total_var_, index_var_, false), \".*\");\n\n  SetEnv(index_var_, \"\");\n  SetEnv(total_var_, \"5\");\n  EXPECT_DEATH_IF_SUPPORTED(ShouldShard(total_var_, index_var_, false), \".*\");\n}\n\n// Tests that ShouldRunTestOnShard is a partition when 5\n// shards are used.\nTEST(ShouldRunTestOnShardTest, IsPartitionWhenThereAreFiveShards) {\n  // Choose an arbitrary number of tests and shards.\n  const int num_tests = 17;\n  const int num_shards = 5;\n\n  // Check partitioning: each test should be on exactly 1 shard.\n  for (int test_id = 0; test_id < num_tests; test_id++) {\n    int prev_selected_shard_index = -1;\n    for (int shard_index = 0; shard_index < num_shards; shard_index++) {\n      if (ShouldRunTestOnShard(num_shards, shard_index, test_id)) {\n        if (prev_selected_shard_index < 0) {\n          prev_selected_shard_index = shard_index;\n        } else {\n          ADD_FAILURE() << \"Shard \" << prev_selected_shard_index << \" and \"\n            << shard_index << \" are both selected to run test \" << test_id;\n        }\n      }\n    }\n  }\n\n  // Check balance: This is not required by the sharding protocol, but is a\n  // desirable property for performance.\n  for (int shard_index = 0; shard_index < num_shards; shard_index++) {\n    int num_tests_on_shard = 0;\n    for (int test_id = 0; test_id < num_tests; test_id++) {\n      num_tests_on_shard +=\n        ShouldRunTestOnShard(num_shards, shard_index, test_id);\n    }\n    EXPECT_GE(num_tests_on_shard, num_tests / num_shards);\n  }\n}\n\n// For the same reason we are not explicitly testing everything in the\n// Test class, there are no separate tests for the following classes\n// (except for some trivial cases):\n//\n//   TestCase, UnitTest, UnitTestResultPrinter.\n//\n// Similarly, there are no separate tests for the following macros:\n//\n//   TEST, TEST_F, RUN_ALL_TESTS\n\nTEST(UnitTestTest, CanGetOriginalWorkingDir) {\n  ASSERT_TRUE(UnitTest::GetInstance()->original_working_dir() != NULL);\n  EXPECT_STRNE(UnitTest::GetInstance()->original_working_dir(), \"\");\n}\n\nTEST(UnitTestTest, ReturnsPlausibleTimestamp) {\n  EXPECT_LT(0, UnitTest::GetInstance()->start_timestamp());\n  EXPECT_LE(UnitTest::GetInstance()->start_timestamp(), GetTimeInMillis());\n}\n\n// When a property using a reserved key is supplied to this function, it\n// tests that a non-fatal failure is added, a fatal failure is not added,\n// and that the property is not recorded.\nvoid ExpectNonFatalFailureRecordingPropertyWithReservedKey(\n    const TestResult& test_result, const char* key) {\n  EXPECT_NONFATAL_FAILURE(Test::RecordProperty(key, \"1\"), \"Reserved key\");\n  ASSERT_EQ(0, test_result.test_property_count()) << \"Property for key '\" << key\n                                                  << \"' recorded unexpectedly.\";\n}\n\nvoid ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(\n    const char* key) {\n  const TestInfo* test_info = UnitTest::GetInstance()->current_test_info();\n  ASSERT_TRUE(test_info != NULL);\n  ExpectNonFatalFailureRecordingPropertyWithReservedKey(*test_info->result(),\n                                                        key);\n}\n\nvoid ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(\n    const char* key) {\n  const TestCase* test_case = UnitTest::GetInstance()->current_test_case();\n  ASSERT_TRUE(test_case != NULL);\n  ExpectNonFatalFailureRecordingPropertyWithReservedKey(\n      test_case->ad_hoc_test_result(), key);\n}\n\nvoid ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(\n    const char* key) {\n  ExpectNonFatalFailureRecordingPropertyWithReservedKey(\n      UnitTest::GetInstance()->ad_hoc_test_result(), key);\n}\n\n// Tests that property recording functions in UnitTest outside of tests\n// functions correcly.  Creating a separate instance of UnitTest ensures it\n// is in a state similar to the UnitTest's singleton's between tests.\nclass UnitTestRecordPropertyTest :\n    public testing::internal::UnitTestRecordPropertyTestHelper {\n public:\n  static void SetUpTestCase() {\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(\n        \"disabled\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(\n        \"errors\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(\n        \"failures\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(\n        \"name\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(\n        \"tests\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTestCase(\n        \"time\");\n\n    Test::RecordProperty(\"test_case_key_1\", \"1\");\n    const TestCase* test_case = UnitTest::GetInstance()->current_test_case();\n    ASSERT_TRUE(test_case != NULL);\n\n    ASSERT_EQ(1, test_case->ad_hoc_test_result().test_property_count());\n    EXPECT_STREQ(\"test_case_key_1\",\n                 test_case->ad_hoc_test_result().GetTestProperty(0).key());\n    EXPECT_STREQ(\"1\",\n                 test_case->ad_hoc_test_result().GetTestProperty(0).value());\n  }\n};\n\n// Tests TestResult has the expected property when added.\nTEST_F(UnitTestRecordPropertyTest, OnePropertyFoundWhenAdded) {\n  UnitTestRecordProperty(\"key_1\", \"1\");\n\n  ASSERT_EQ(1, unit_test_.ad_hoc_test_result().test_property_count());\n\n  EXPECT_STREQ(\"key_1\",\n               unit_test_.ad_hoc_test_result().GetTestProperty(0).key());\n  EXPECT_STREQ(\"1\",\n               unit_test_.ad_hoc_test_result().GetTestProperty(0).value());\n}\n\n// Tests TestResult has multiple properties when added.\nTEST_F(UnitTestRecordPropertyTest, MultiplePropertiesFoundWhenAdded) {\n  UnitTestRecordProperty(\"key_1\", \"1\");\n  UnitTestRecordProperty(\"key_2\", \"2\");\n\n  ASSERT_EQ(2, unit_test_.ad_hoc_test_result().test_property_count());\n\n  EXPECT_STREQ(\"key_1\",\n               unit_test_.ad_hoc_test_result().GetTestProperty(0).key());\n  EXPECT_STREQ(\"1\", unit_test_.ad_hoc_test_result().GetTestProperty(0).value());\n\n  EXPECT_STREQ(\"key_2\",\n               unit_test_.ad_hoc_test_result().GetTestProperty(1).key());\n  EXPECT_STREQ(\"2\", unit_test_.ad_hoc_test_result().GetTestProperty(1).value());\n}\n\n// Tests TestResult::RecordProperty() overrides values for duplicate keys.\nTEST_F(UnitTestRecordPropertyTest, OverridesValuesForDuplicateKeys) {\n  UnitTestRecordProperty(\"key_1\", \"1\");\n  UnitTestRecordProperty(\"key_2\", \"2\");\n  UnitTestRecordProperty(\"key_1\", \"12\");\n  UnitTestRecordProperty(\"key_2\", \"22\");\n\n  ASSERT_EQ(2, unit_test_.ad_hoc_test_result().test_property_count());\n\n  EXPECT_STREQ(\"key_1\",\n               unit_test_.ad_hoc_test_result().GetTestProperty(0).key());\n  EXPECT_STREQ(\"12\",\n               unit_test_.ad_hoc_test_result().GetTestProperty(0).value());\n\n  EXPECT_STREQ(\"key_2\",\n               unit_test_.ad_hoc_test_result().GetTestProperty(1).key());\n  EXPECT_STREQ(\"22\",\n               unit_test_.ad_hoc_test_result().GetTestProperty(1).value());\n}\n\nTEST_F(UnitTestRecordPropertyTest,\n       AddFailureInsideTestsWhenUsingTestCaseReservedKeys) {\n  ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(\n      \"name\");\n  ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(\n      \"value_param\");\n  ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(\n      \"type_param\");\n  ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(\n      \"status\");\n  ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(\n      \"time\");\n  ExpectNonFatalFailureRecordingPropertyWithReservedKeyForCurrentTest(\n      \"classname\");\n}\n\nTEST_F(UnitTestRecordPropertyTest,\n       AddRecordWithReservedKeysGeneratesCorrectPropertyList) {\n  EXPECT_NONFATAL_FAILURE(\n      Test::RecordProperty(\"name\", \"1\"),\n      \"'classname', 'name', 'status', 'time', 'type_param', and 'value_param'\"\n      \" are reserved\");\n}\n\nclass UnitTestRecordPropertyTestEnvironment : public Environment {\n public:\n  virtual void TearDown() {\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(\n        \"tests\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(\n        \"failures\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(\n        \"disabled\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(\n        \"errors\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(\n        \"name\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(\n        \"timestamp\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(\n        \"time\");\n    ExpectNonFatalFailureRecordingPropertyWithReservedKeyOutsideOfTestCase(\n        \"random_seed\");\n  }\n};\n\n// This will test property recording outside of any test or test case.\nstatic Environment* record_property_env =\n    AddGlobalTestEnvironment(new UnitTestRecordPropertyTestEnvironment);\n\n// This group of tests is for predicate assertions (ASSERT_PRED*, etc)\n// of various arities.  They do not attempt to be exhaustive.  Rather,\n// view them as smoke tests that can be easily reviewed and verified.\n// A more complete set of tests for predicate assertions can be found\n// in gtest_pred_impl_unittest.cc.\n\n// First, some predicates and predicate-formatters needed by the tests.\n\n// Returns true iff the argument is an even number.\nbool IsEven(int n) {\n  return (n % 2) == 0;\n}\n\n// A functor that returns true iff the argument is an even number.\nstruct IsEvenFunctor {\n  bool operator()(int n) { return IsEven(n); }\n};\n\n// A predicate-formatter function that asserts the argument is an even\n// number.\nAssertionResult AssertIsEven(const char* expr, int n) {\n  if (IsEven(n)) {\n    return AssertionSuccess();\n  }\n\n  Message msg;\n  msg << expr << \" evaluates to \" << n << \", which is not even.\";\n  return AssertionFailure(msg);\n}\n\n// A predicate function that returns AssertionResult for use in\n// EXPECT/ASSERT_TRUE/FALSE.\nAssertionResult ResultIsEven(int n) {\n  if (IsEven(n))\n    return AssertionSuccess() << n << \" is even\";\n  else\n    return AssertionFailure() << n << \" is odd\";\n}\n\n// A predicate function that returns AssertionResult but gives no\n// explanation why it succeeds. Needed for testing that\n// EXPECT/ASSERT_FALSE handles such functions correctly.\nAssertionResult ResultIsEvenNoExplanation(int n) {\n  if (IsEven(n))\n    return AssertionSuccess();\n  else\n    return AssertionFailure() << n << \" is odd\";\n}\n\n// A predicate-formatter functor that asserts the argument is an even\n// number.\nstruct AssertIsEvenFunctor {\n  AssertionResult operator()(const char* expr, int n) {\n    return AssertIsEven(expr, n);\n  }\n};\n\n// Returns true iff the sum of the arguments is an even number.\nbool SumIsEven2(int n1, int n2) {\n  return IsEven(n1 + n2);\n}\n\n// A functor that returns true iff the sum of the arguments is an even\n// number.\nstruct SumIsEven3Functor {\n  bool operator()(int n1, int n2, int n3) {\n    return IsEven(n1 + n2 + n3);\n  }\n};\n\n// A predicate-formatter function that asserts the sum of the\n// arguments is an even number.\nAssertionResult AssertSumIsEven4(\n    const char* e1, const char* e2, const char* e3, const char* e4,\n    int n1, int n2, int n3, int n4) {\n  const int sum = n1 + n2 + n3 + n4;\n  if (IsEven(sum)) {\n    return AssertionSuccess();\n  }\n\n  Message msg;\n  msg << e1 << \" + \" << e2 << \" + \" << e3 << \" + \" << e4\n      << \" (\" << n1 << \" + \" << n2 << \" + \" << n3 << \" + \" << n4\n      << \") evaluates to \" << sum << \", which is not even.\";\n  return AssertionFailure(msg);\n}\n\n// A predicate-formatter functor that asserts the sum of the arguments\n// is an even number.\nstruct AssertSumIsEven5Functor {\n  AssertionResult operator()(\n      const char* e1, const char* e2, const char* e3, const char* e4,\n      const char* e5, int n1, int n2, int n3, int n4, int n5) {\n    const int sum = n1 + n2 + n3 + n4 + n5;\n    if (IsEven(sum)) {\n      return AssertionSuccess();\n    }\n\n    Message msg;\n    msg << e1 << \" + \" << e2 << \" + \" << e3 << \" + \" << e4 << \" + \" << e5\n        << \" (\"\n        << n1 << \" + \" << n2 << \" + \" << n3 << \" + \" << n4 << \" + \" << n5\n        << \") evaluates to \" << sum << \", which is not even.\";\n    return AssertionFailure(msg);\n  }\n};\n\n\n// Tests unary predicate assertions.\n\n// Tests unary predicate assertions that don't use a custom formatter.\nTEST(Pred1Test, WithoutFormat) {\n  // Success cases.\n  EXPECT_PRED1(IsEvenFunctor(), 2) << \"This failure is UNEXPECTED!\";\n  ASSERT_PRED1(IsEven, 4);\n\n  // Failure cases.\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED1(IsEven, 5) << \"This failure is expected.\";\n  }, \"This failure is expected.\");\n  EXPECT_FATAL_FAILURE(ASSERT_PRED1(IsEvenFunctor(), 5),\n                       \"evaluates to false\");\n}\n\n// Tests unary predicate assertions that use a custom formatter.\nTEST(Pred1Test, WithFormat) {\n  // Success cases.\n  EXPECT_PRED_FORMAT1(AssertIsEven, 2);\n  ASSERT_PRED_FORMAT1(AssertIsEvenFunctor(), 4)\n    << \"This failure is UNEXPECTED!\";\n\n  // Failure cases.\n  const int n = 5;\n  EXPECT_NONFATAL_FAILURE(EXPECT_PRED_FORMAT1(AssertIsEvenFunctor(), n),\n                          \"n evaluates to 5, which is not even.\");\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT1(AssertIsEven, 5) << \"This failure is expected.\";\n  }, \"This failure is expected.\");\n}\n\n// Tests that unary predicate assertions evaluates their arguments\n// exactly once.\nTEST(Pred1Test, SingleEvaluationOnFailure) {\n  // A success case.\n  static int n = 0;\n  EXPECT_PRED1(IsEven, n++);\n  EXPECT_EQ(1, n) << \"The argument is not evaluated exactly once.\";\n\n  // A failure case.\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT1(AssertIsEvenFunctor(), n++)\n        << \"This failure is expected.\";\n  }, \"This failure is expected.\");\n  EXPECT_EQ(2, n) << \"The argument is not evaluated exactly once.\";\n}\n\n\n// Tests predicate assertions whose arity is >= 2.\n\n// Tests predicate assertions that don't use a custom formatter.\nTEST(PredTest, WithoutFormat) {\n  // Success cases.\n  ASSERT_PRED2(SumIsEven2, 2, 4) << \"This failure is UNEXPECTED!\";\n  EXPECT_PRED3(SumIsEven3Functor(), 4, 6, 8);\n\n  // Failure cases.\n  const int n1 = 1;\n  const int n2 = 2;\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED2(SumIsEven2, n1, n2) << \"This failure is expected.\";\n  }, \"This failure is expected.\");\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED3(SumIsEven3Functor(), 1, 2, 4);\n  }, \"evaluates to false\");\n}\n\n// Tests predicate assertions that use a custom formatter.\nTEST(PredTest, WithFormat) {\n  // Success cases.\n  ASSERT_PRED_FORMAT4(AssertSumIsEven4, 4, 6, 8, 10) <<\n    \"This failure is UNEXPECTED!\";\n  EXPECT_PRED_FORMAT5(AssertSumIsEven5Functor(), 2, 4, 6, 8, 10);\n\n  // Failure cases.\n  const int n1 = 1;\n  const int n2 = 2;\n  const int n3 = 4;\n  const int n4 = 6;\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT4(AssertSumIsEven4, n1, n2, n3, n4);\n  }, \"evaluates to 13, which is not even.\");\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT5(AssertSumIsEven5Functor(), 1, 2, 4, 6, 8)\n        << \"This failure is expected.\";\n  }, \"This failure is expected.\");\n}\n\n// Tests that predicate assertions evaluates their arguments\n// exactly once.\nTEST(PredTest, SingleEvaluationOnFailure) {\n  // A success case.\n  int n1 = 0;\n  int n2 = 0;\n  EXPECT_PRED2(SumIsEven2, n1++, n2++);\n  EXPECT_EQ(1, n1) << \"Argument 1 is not evaluated exactly once.\";\n  EXPECT_EQ(1, n2) << \"Argument 2 is not evaluated exactly once.\";\n\n  // Another success case.\n  n1 = n2 = 0;\n  int n3 = 0;\n  int n4 = 0;\n  int n5 = 0;\n  ASSERT_PRED_FORMAT5(AssertSumIsEven5Functor(),\n                      n1++, n2++, n3++, n4++, n5++)\n                        << \"This failure is UNEXPECTED!\";\n  EXPECT_EQ(1, n1) << \"Argument 1 is not evaluated exactly once.\";\n  EXPECT_EQ(1, n2) << \"Argument 2 is not evaluated exactly once.\";\n  EXPECT_EQ(1, n3) << \"Argument 3 is not evaluated exactly once.\";\n  EXPECT_EQ(1, n4) << \"Argument 4 is not evaluated exactly once.\";\n  EXPECT_EQ(1, n5) << \"Argument 5 is not evaluated exactly once.\";\n\n  // A failure case.\n  n1 = n2 = n3 = 0;\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED3(SumIsEven3Functor(), ++n1, n2++, n3++)\n        << \"This failure is expected.\";\n  }, \"This failure is expected.\");\n  EXPECT_EQ(1, n1) << \"Argument 1 is not evaluated exactly once.\";\n  EXPECT_EQ(1, n2) << \"Argument 2 is not evaluated exactly once.\";\n  EXPECT_EQ(1, n3) << \"Argument 3 is not evaluated exactly once.\";\n\n  // Another failure case.\n  n1 = n2 = n3 = n4 = 0;\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT4(AssertSumIsEven4, ++n1, n2++, n3++, n4++);\n  }, \"evaluates to 1, which is not even.\");\n  EXPECT_EQ(1, n1) << \"Argument 1 is not evaluated exactly once.\";\n  EXPECT_EQ(1, n2) << \"Argument 2 is not evaluated exactly once.\";\n  EXPECT_EQ(1, n3) << \"Argument 3 is not evaluated exactly once.\";\n  EXPECT_EQ(1, n4) << \"Argument 4 is not evaluated exactly once.\";\n}\n\n\n// Some helper functions for testing using overloaded/template\n// functions with ASSERT_PREDn and EXPECT_PREDn.\n\nbool IsPositive(double x) {\n  return x > 0;\n}\n\ntemplate <typename T>\nbool IsNegative(T x) {\n  return x < 0;\n}\n\ntemplate <typename T1, typename T2>\nbool GreaterThan(T1 x1, T2 x2) {\n  return x1 > x2;\n}\n\n// Tests that overloaded functions can be used in *_PRED* as long as\n// their types are explicitly specified.\nTEST(PredicateAssertionTest, AcceptsOverloadedFunction) {\n  // C++Builder requires C-style casts rather than static_cast.\n  EXPECT_PRED1((bool (*)(int))(IsPositive), 5);  // NOLINT\n  ASSERT_PRED1((bool (*)(double))(IsPositive), 6.0);  // NOLINT\n}\n\n// Tests that template functions can be used in *_PRED* as long as\n// their types are explicitly specified.\nTEST(PredicateAssertionTest, AcceptsTemplateFunction) {\n  EXPECT_PRED1(IsNegative<int>, -5);\n  // Makes sure that we can handle templates with more than one\n  // parameter.\n  ASSERT_PRED2((GreaterThan<int, int>), 5, 0);\n}\n\n\n// Some helper functions for testing using overloaded/template\n// functions with ASSERT_PRED_FORMATn and EXPECT_PRED_FORMATn.\n\nAssertionResult IsPositiveFormat(const char* /* expr */, int n) {\n  return n > 0 ? AssertionSuccess() :\n      AssertionFailure(Message() << \"Failure\");\n}\n\nAssertionResult IsPositiveFormat(const char* /* expr */, double x) {\n  return x > 0 ? AssertionSuccess() :\n      AssertionFailure(Message() << \"Failure\");\n}\n\ntemplate <typename T>\nAssertionResult IsNegativeFormat(const char* /* expr */, T x) {\n  return x < 0 ? AssertionSuccess() :\n      AssertionFailure(Message() << \"Failure\");\n}\n\ntemplate <typename T1, typename T2>\nAssertionResult EqualsFormat(const char* /* expr1 */, const char* /* expr2 */,\n                             const T1& x1, const T2& x2) {\n  return x1 == x2 ? AssertionSuccess() :\n      AssertionFailure(Message() << \"Failure\");\n}\n\n// Tests that overloaded functions can be used in *_PRED_FORMAT*\n// without explicitly specifying their types.\nTEST(PredicateFormatAssertionTest, AcceptsOverloadedFunction) {\n  EXPECT_PRED_FORMAT1(IsPositiveFormat, 5);\n  ASSERT_PRED_FORMAT1(IsPositiveFormat, 6.0);\n}\n\n// Tests that template functions can be used in *_PRED_FORMAT* without\n// explicitly specifying their types.\nTEST(PredicateFormatAssertionTest, AcceptsTemplateFunction) {\n  EXPECT_PRED_FORMAT1(IsNegativeFormat, -5);\n  ASSERT_PRED_FORMAT2(EqualsFormat, 3, 3);\n}\n\n\n// Tests string assertions.\n\n// Tests ASSERT_STREQ with non-NULL arguments.\nTEST(StringAssertionTest, ASSERT_STREQ) {\n  const char * const p1 = \"good\";\n  ASSERT_STREQ(p1, p1);\n\n  // Let p2 have the same content as p1, but be at a different address.\n  const char p2[] = \"good\";\n  ASSERT_STREQ(p1, p2);\n\n  EXPECT_FATAL_FAILURE(ASSERT_STREQ(\"bad\", \"good\"),\n                       \"Expected: \\\"bad\\\"\");\n}\n\n// Tests ASSERT_STREQ with NULL arguments.\nTEST(StringAssertionTest, ASSERT_STREQ_Null) {\n  ASSERT_STREQ(static_cast<const char *>(NULL), NULL);\n  EXPECT_FATAL_FAILURE(ASSERT_STREQ(NULL, \"non-null\"),\n                       \"non-null\");\n}\n\n// Tests ASSERT_STREQ with NULL arguments.\nTEST(StringAssertionTest, ASSERT_STREQ_Null2) {\n  EXPECT_FATAL_FAILURE(ASSERT_STREQ(\"non-null\", NULL),\n                       \"non-null\");\n}\n\n// Tests ASSERT_STRNE.\nTEST(StringAssertionTest, ASSERT_STRNE) {\n  ASSERT_STRNE(\"hi\", \"Hi\");\n  ASSERT_STRNE(\"Hi\", NULL);\n  ASSERT_STRNE(NULL, \"Hi\");\n  ASSERT_STRNE(\"\", NULL);\n  ASSERT_STRNE(NULL, \"\");\n  ASSERT_STRNE(\"\", \"Hi\");\n  ASSERT_STRNE(\"Hi\", \"\");\n  EXPECT_FATAL_FAILURE(ASSERT_STRNE(\"Hi\", \"Hi\"),\n                       \"\\\"Hi\\\" vs \\\"Hi\\\"\");\n}\n\n// Tests ASSERT_STRCASEEQ.\nTEST(StringAssertionTest, ASSERT_STRCASEEQ) {\n  ASSERT_STRCASEEQ(\"hi\", \"Hi\");\n  ASSERT_STRCASEEQ(static_cast<const char *>(NULL), NULL);\n\n  ASSERT_STRCASEEQ(\"\", \"\");\n  EXPECT_FATAL_FAILURE(ASSERT_STRCASEEQ(\"Hi\", \"hi2\"),\n                       \"(ignoring case)\");\n}\n\n// Tests ASSERT_STRCASENE.\nTEST(StringAssertionTest, ASSERT_STRCASENE) {\n  ASSERT_STRCASENE(\"hi1\", \"Hi2\");\n  ASSERT_STRCASENE(\"Hi\", NULL);\n  ASSERT_STRCASENE(NULL, \"Hi\");\n  ASSERT_STRCASENE(\"\", NULL);\n  ASSERT_STRCASENE(NULL, \"\");\n  ASSERT_STRCASENE(\"\", \"Hi\");\n  ASSERT_STRCASENE(\"Hi\", \"\");\n  EXPECT_FATAL_FAILURE(ASSERT_STRCASENE(\"Hi\", \"hi\"),\n                       \"(ignoring case)\");\n}\n\n// Tests *_STREQ on wide strings.\nTEST(StringAssertionTest, STREQ_Wide) {\n  // NULL strings.\n  ASSERT_STREQ(static_cast<const wchar_t *>(NULL), NULL);\n\n  // Empty strings.\n  ASSERT_STREQ(L\"\", L\"\");\n\n  // Non-null vs NULL.\n  EXPECT_NONFATAL_FAILURE(EXPECT_STREQ(L\"non-null\", NULL),\n                          \"non-null\");\n\n  // Equal strings.\n  EXPECT_STREQ(L\"Hi\", L\"Hi\");\n\n  // Unequal strings.\n  EXPECT_NONFATAL_FAILURE(EXPECT_STREQ(L\"abc\", L\"Abc\"),\n                          \"Abc\");\n\n  // Strings containing wide characters.\n  EXPECT_NONFATAL_FAILURE(EXPECT_STREQ(L\"abc\\x8119\", L\"abc\\x8120\"),\n                          \"abc\");\n\n  // The streaming variation.\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_STREQ(L\"abc\\x8119\", L\"abc\\x8121\") << \"Expected failure\";\n  }, \"Expected failure\");\n}\n\n// Tests *_STRNE on wide strings.\nTEST(StringAssertionTest, STRNE_Wide) {\n  // NULL strings.\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_STRNE(static_cast<const wchar_t *>(NULL), NULL);\n  }, \"\");\n\n  // Empty strings.\n  EXPECT_NONFATAL_FAILURE(EXPECT_STRNE(L\"\", L\"\"),\n                          \"L\\\"\\\"\");\n\n  // Non-null vs NULL.\n  ASSERT_STRNE(L\"non-null\", NULL);\n\n  // Equal strings.\n  EXPECT_NONFATAL_FAILURE(EXPECT_STRNE(L\"Hi\", L\"Hi\"),\n                          \"L\\\"Hi\\\"\");\n\n  // Unequal strings.\n  EXPECT_STRNE(L\"abc\", L\"Abc\");\n\n  // Strings containing wide characters.\n  EXPECT_NONFATAL_FAILURE(EXPECT_STRNE(L\"abc\\x8119\", L\"abc\\x8119\"),\n                          \"abc\");\n\n  // The streaming variation.\n  ASSERT_STRNE(L\"abc\\x8119\", L\"abc\\x8120\") << \"This shouldn't happen\";\n}\n\n// Tests for ::testing::IsSubstring().\n\n// Tests that IsSubstring() returns the correct result when the input\n// argument type is const char*.\nTEST(IsSubstringTest, ReturnsCorrectResultForCString) {\n  EXPECT_FALSE(IsSubstring(\"\", \"\", NULL, \"a\"));\n  EXPECT_FALSE(IsSubstring(\"\", \"\", \"b\", NULL));\n  EXPECT_FALSE(IsSubstring(\"\", \"\", \"needle\", \"haystack\"));\n\n  EXPECT_TRUE(IsSubstring(\"\", \"\", static_cast<const char*>(NULL), NULL));\n  EXPECT_TRUE(IsSubstring(\"\", \"\", \"needle\", \"two needles\"));\n}\n\n// Tests that IsSubstring() returns the correct result when the input\n// argument type is const wchar_t*.\nTEST(IsSubstringTest, ReturnsCorrectResultForWideCString) {\n  EXPECT_FALSE(IsSubstring(\"\", \"\", kNull, L\"a\"));\n  EXPECT_FALSE(IsSubstring(\"\", \"\", L\"b\", kNull));\n  EXPECT_FALSE(IsSubstring(\"\", \"\", L\"needle\", L\"haystack\"));\n\n  EXPECT_TRUE(IsSubstring(\"\", \"\", static_cast<const wchar_t*>(NULL), NULL));\n  EXPECT_TRUE(IsSubstring(\"\", \"\", L\"needle\", L\"two needles\"));\n}\n\n// Tests that IsSubstring() generates the correct message when the input\n// argument type is const char*.\nTEST(IsSubstringTest, GeneratesCorrectMessageForCString) {\n  EXPECT_STREQ(\"Value of: needle_expr\\n\"\n               \"  Actual: \\\"needle\\\"\\n\"\n               \"Expected: a substring of haystack_expr\\n\"\n               \"Which is: \\\"haystack\\\"\",\n               IsSubstring(\"needle_expr\", \"haystack_expr\",\n                           \"needle\", \"haystack\").failure_message());\n}\n\n// Tests that IsSubstring returns the correct result when the input\n// argument type is ::std::string.\nTEST(IsSubstringTest, ReturnsCorrectResultsForStdString) {\n  EXPECT_TRUE(IsSubstring(\"\", \"\", std::string(\"hello\"), \"ahellob\"));\n  EXPECT_FALSE(IsSubstring(\"\", \"\", \"hello\", std::string(\"world\")));\n}\n\n#if GTEST_HAS_STD_WSTRING\n// Tests that IsSubstring returns the correct result when the input\n// argument type is ::std::wstring.\nTEST(IsSubstringTest, ReturnsCorrectResultForStdWstring) {\n  EXPECT_TRUE(IsSubstring(\"\", \"\", ::std::wstring(L\"needle\"), L\"two needles\"));\n  EXPECT_FALSE(IsSubstring(\"\", \"\", L\"needle\", ::std::wstring(L\"haystack\")));\n}\n\n// Tests that IsSubstring() generates the correct message when the input\n// argument type is ::std::wstring.\nTEST(IsSubstringTest, GeneratesCorrectMessageForWstring) {\n  EXPECT_STREQ(\"Value of: needle_expr\\n\"\n               \"  Actual: L\\\"needle\\\"\\n\"\n               \"Expected: a substring of haystack_expr\\n\"\n               \"Which is: L\\\"haystack\\\"\",\n               IsSubstring(\n                   \"needle_expr\", \"haystack_expr\",\n                   ::std::wstring(L\"needle\"), L\"haystack\").failure_message());\n}\n\n#endif  // GTEST_HAS_STD_WSTRING\n\n// Tests for ::testing::IsNotSubstring().\n\n// Tests that IsNotSubstring() returns the correct result when the input\n// argument type is const char*.\nTEST(IsNotSubstringTest, ReturnsCorrectResultForCString) {\n  EXPECT_TRUE(IsNotSubstring(\"\", \"\", \"needle\", \"haystack\"));\n  EXPECT_FALSE(IsNotSubstring(\"\", \"\", \"needle\", \"two needles\"));\n}\n\n// Tests that IsNotSubstring() returns the correct result when the input\n// argument type is const wchar_t*.\nTEST(IsNotSubstringTest, ReturnsCorrectResultForWideCString) {\n  EXPECT_TRUE(IsNotSubstring(\"\", \"\", L\"needle\", L\"haystack\"));\n  EXPECT_FALSE(IsNotSubstring(\"\", \"\", L\"needle\", L\"two needles\"));\n}\n\n// Tests that IsNotSubstring() generates the correct message when the input\n// argument type is const wchar_t*.\nTEST(IsNotSubstringTest, GeneratesCorrectMessageForWideCString) {\n  EXPECT_STREQ(\"Value of: needle_expr\\n\"\n               \"  Actual: L\\\"needle\\\"\\n\"\n               \"Expected: not a substring of haystack_expr\\n\"\n               \"Which is: L\\\"two needles\\\"\",\n               IsNotSubstring(\n                   \"needle_expr\", \"haystack_expr\",\n                   L\"needle\", L\"two needles\").failure_message());\n}\n\n// Tests that IsNotSubstring returns the correct result when the input\n// argument type is ::std::string.\nTEST(IsNotSubstringTest, ReturnsCorrectResultsForStdString) {\n  EXPECT_FALSE(IsNotSubstring(\"\", \"\", std::string(\"hello\"), \"ahellob\"));\n  EXPECT_TRUE(IsNotSubstring(\"\", \"\", \"hello\", std::string(\"world\")));\n}\n\n// Tests that IsNotSubstring() generates the correct message when the input\n// argument type is ::std::string.\nTEST(IsNotSubstringTest, GeneratesCorrectMessageForStdString) {\n  EXPECT_STREQ(\"Value of: needle_expr\\n\"\n               \"  Actual: \\\"needle\\\"\\n\"\n               \"Expected: not a substring of haystack_expr\\n\"\n               \"Which is: \\\"two needles\\\"\",\n               IsNotSubstring(\n                   \"needle_expr\", \"haystack_expr\",\n                   ::std::string(\"needle\"), \"two needles\").failure_message());\n}\n\n#if GTEST_HAS_STD_WSTRING\n\n// Tests that IsNotSubstring returns the correct result when the input\n// argument type is ::std::wstring.\nTEST(IsNotSubstringTest, ReturnsCorrectResultForStdWstring) {\n  EXPECT_FALSE(\n      IsNotSubstring(\"\", \"\", ::std::wstring(L\"needle\"), L\"two needles\"));\n  EXPECT_TRUE(IsNotSubstring(\"\", \"\", L\"needle\", ::std::wstring(L\"haystack\")));\n}\n\n#endif  // GTEST_HAS_STD_WSTRING\n\n// Tests floating-point assertions.\n\ntemplate <typename RawType>\nclass FloatingPointTest : public Test {\n protected:\n  // Pre-calculated numbers to be used by the tests.\n  struct TestValues {\n    RawType close_to_positive_zero;\n    RawType close_to_negative_zero;\n    RawType further_from_negative_zero;\n\n    RawType close_to_one;\n    RawType further_from_one;\n\n    RawType infinity;\n    RawType close_to_infinity;\n    RawType further_from_infinity;\n\n    RawType nan1;\n    RawType nan2;\n  };\n\n  typedef typename testing::internal::FloatingPoint<RawType> Floating;\n  typedef typename Floating::Bits Bits;\n\n  virtual void SetUp() {\n    const size_t max_ulps = Floating::kMaxUlps;\n\n    // The bits that represent 0.0.\n    const Bits zero_bits = Floating(0).bits();\n\n    // Makes some numbers close to 0.0.\n    values_.close_to_positive_zero = Floating::ReinterpretBits(\n        zero_bits + max_ulps/2);\n    values_.close_to_negative_zero = -Floating::ReinterpretBits(\n        zero_bits + max_ulps - max_ulps/2);\n    values_.further_from_negative_zero = -Floating::ReinterpretBits(\n        zero_bits + max_ulps + 1 - max_ulps/2);\n\n    // The bits that represent 1.0.\n    const Bits one_bits = Floating(1).bits();\n\n    // Makes some numbers close to 1.0.\n    values_.close_to_one = Floating::ReinterpretBits(one_bits + max_ulps);\n    values_.further_from_one = Floating::ReinterpretBits(\n        one_bits + max_ulps + 1);\n\n    // +infinity.\n    values_.infinity = Floating::Infinity();\n\n    // The bits that represent +infinity.\n    const Bits infinity_bits = Floating(values_.infinity).bits();\n\n    // Makes some numbers close to infinity.\n    values_.close_to_infinity = Floating::ReinterpretBits(\n        infinity_bits - max_ulps);\n    values_.further_from_infinity = Floating::ReinterpretBits(\n        infinity_bits - max_ulps - 1);\n\n    // Makes some NAN's.  Sets the most significant bit of the fraction so that\n    // our NaN's are quiet; trying to process a signaling NaN would raise an\n    // exception if our environment enables floating point exceptions.\n    values_.nan1 = Floating::ReinterpretBits(Floating::kExponentBitMask\n        | (static_cast<Bits>(1) << (Floating::kFractionBitCount - 1)) | 1);\n    values_.nan2 = Floating::ReinterpretBits(Floating::kExponentBitMask\n        | (static_cast<Bits>(1) << (Floating::kFractionBitCount - 1)) | 200);\n  }\n\n  void TestSize() {\n    EXPECT_EQ(sizeof(RawType), sizeof(Bits));\n  }\n\n  static TestValues values_;\n};\n\ntemplate <typename RawType>\ntypename FloatingPointTest<RawType>::TestValues\n    FloatingPointTest<RawType>::values_;\n\n// Instantiates FloatingPointTest for testing *_FLOAT_EQ.\ntypedef FloatingPointTest<float> FloatTest;\n\n// Tests that the size of Float::Bits matches the size of float.\nTEST_F(FloatTest, Size) {\n  TestSize();\n}\n\n// Tests comparing with +0 and -0.\nTEST_F(FloatTest, Zeros) {\n  EXPECT_FLOAT_EQ(0.0, -0.0);\n  EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(-0.0, 1.0),\n                          \"1.0\");\n  EXPECT_FATAL_FAILURE(ASSERT_FLOAT_EQ(0.0, 1.5),\n                       \"1.5\");\n}\n\n// Tests comparing numbers close to 0.\n//\n// This ensures that *_FLOAT_EQ handles the sign correctly and no\n// overflow occurs when comparing numbers whose absolute value is very\n// small.\nTEST_F(FloatTest, AlmostZeros) {\n  // In C++Builder, names within local classes (such as used by\n  // EXPECT_FATAL_FAILURE) cannot be resolved against static members of the\n  // scoping class.  Use a static local alias as a workaround.\n  // We use the assignment syntax since some compilers, like Sun Studio,\n  // don't allow initializing references using construction syntax\n  // (parentheses).\n  static const FloatTest::TestValues& v = this->values_;\n\n  EXPECT_FLOAT_EQ(0.0, v.close_to_positive_zero);\n  EXPECT_FLOAT_EQ(-0.0, v.close_to_negative_zero);\n  EXPECT_FLOAT_EQ(v.close_to_positive_zero, v.close_to_negative_zero);\n\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_FLOAT_EQ(v.close_to_positive_zero,\n                    v.further_from_negative_zero);\n  }, \"v.further_from_negative_zero\");\n}\n\n// Tests comparing numbers close to each other.\nTEST_F(FloatTest, SmallDiff) {\n  EXPECT_FLOAT_EQ(1.0, values_.close_to_one);\n  EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(1.0, values_.further_from_one),\n                          \"values_.further_from_one\");\n}\n\n// Tests comparing numbers far apart.\nTEST_F(FloatTest, LargeDiff) {\n  EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(2.5, 3.0),\n                          \"3.0\");\n}\n\n// Tests comparing with infinity.\n//\n// This ensures that no overflow occurs when comparing numbers whose\n// absolute value is very large.\nTEST_F(FloatTest, Infinity) {\n  EXPECT_FLOAT_EQ(values_.infinity, values_.close_to_infinity);\n  EXPECT_FLOAT_EQ(-values_.infinity, -values_.close_to_infinity);\n#if !GTEST_OS_SYMBIAN\n  // Nokia's STLport crashes if we try to output infinity or NaN.\n  EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(values_.infinity, -values_.infinity),\n                          \"-values_.infinity\");\n\n  // This is interesting as the representations of infinity and nan1\n  // are only 1 DLP apart.\n  EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(values_.infinity, values_.nan1),\n                          \"values_.nan1\");\n#endif  // !GTEST_OS_SYMBIAN\n}\n\n// Tests that comparing with NAN always returns false.\nTEST_F(FloatTest, NaN) {\n#if !GTEST_OS_SYMBIAN\n// Nokia's STLport crashes if we try to output infinity or NaN.\n\n  // In C++Builder, names within local classes (such as used by\n  // EXPECT_FATAL_FAILURE) cannot be resolved against static members of the\n  // scoping class.  Use a static local alias as a workaround.\n  // We use the assignment syntax since some compilers, like Sun Studio,\n  // don't allow initializing references using construction syntax\n  // (parentheses).\n  static const FloatTest::TestValues& v = this->values_;\n\n  EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(v.nan1, v.nan1),\n                          \"v.nan1\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(v.nan1, v.nan2),\n                          \"v.nan2\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(1.0, v.nan1),\n                          \"v.nan1\");\n\n  EXPECT_FATAL_FAILURE(ASSERT_FLOAT_EQ(v.nan1, v.infinity),\n                       \"v.infinity\");\n#endif  // !GTEST_OS_SYMBIAN\n}\n\n// Tests that *_FLOAT_EQ are reflexive.\nTEST_F(FloatTest, Reflexive) {\n  EXPECT_FLOAT_EQ(0.0, 0.0);\n  EXPECT_FLOAT_EQ(1.0, 1.0);\n  ASSERT_FLOAT_EQ(values_.infinity, values_.infinity);\n}\n\n// Tests that *_FLOAT_EQ are commutative.\nTEST_F(FloatTest, Commutative) {\n  // We already tested EXPECT_FLOAT_EQ(1.0, values_.close_to_one).\n  EXPECT_FLOAT_EQ(values_.close_to_one, 1.0);\n\n  // We already tested EXPECT_FLOAT_EQ(1.0, values_.further_from_one).\n  EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(values_.further_from_one, 1.0),\n                          \"1.0\");\n}\n\n// Tests EXPECT_NEAR.\nTEST_F(FloatTest, EXPECT_NEAR) {\n  EXPECT_NEAR(-1.0f, -1.1f, 0.2f);\n  EXPECT_NEAR(2.0f, 3.0f, 1.0f);\n  EXPECT_NONFATAL_FAILURE(EXPECT_NEAR(1.0f,1.5f, 0.25f),  // NOLINT\n                          \"The difference between 1.0f and 1.5f is 0.5, \"\n                          \"which exceeds 0.25f\");\n  // To work around a bug in gcc 2.95.0, there is intentionally no\n  // space after the first comma in the previous line.\n}\n\n// Tests ASSERT_NEAR.\nTEST_F(FloatTest, ASSERT_NEAR) {\n  ASSERT_NEAR(-1.0f, -1.1f, 0.2f);\n  ASSERT_NEAR(2.0f, 3.0f, 1.0f);\n  EXPECT_FATAL_FAILURE(ASSERT_NEAR(1.0f,1.5f, 0.25f),  // NOLINT\n                       \"The difference between 1.0f and 1.5f is 0.5, \"\n                       \"which exceeds 0.25f\");\n  // To work around a bug in gcc 2.95.0, there is intentionally no\n  // space after the first comma in the previous line.\n}\n\n// Tests the cases where FloatLE() should succeed.\nTEST_F(FloatTest, FloatLESucceeds) {\n  EXPECT_PRED_FORMAT2(FloatLE, 1.0f, 2.0f);  // When val1 < val2,\n  ASSERT_PRED_FORMAT2(FloatLE, 1.0f, 1.0f);  // val1 == val2,\n\n  // or when val1 is greater than, but almost equals to, val2.\n  EXPECT_PRED_FORMAT2(FloatLE, values_.close_to_positive_zero, 0.0f);\n}\n\n// Tests the cases where FloatLE() should fail.\nTEST_F(FloatTest, FloatLEFails) {\n  // When val1 is greater than val2 by a large margin,\n  EXPECT_NONFATAL_FAILURE(EXPECT_PRED_FORMAT2(FloatLE, 2.0f, 1.0f),\n                          \"(2.0f) <= (1.0f)\");\n\n  // or by a small yet non-negligible margin,\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT2(FloatLE, values_.further_from_one, 1.0f);\n  }, \"(values_.further_from_one) <= (1.0f)\");\n\n#if !GTEST_OS_SYMBIAN && !defined(__BORLANDC__)\n  // Nokia's STLport crashes if we try to output infinity or NaN.\n  // C++Builder gives bad results for ordered comparisons involving NaNs\n  // due to compiler bugs.\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT2(FloatLE, values_.nan1, values_.infinity);\n  }, \"(values_.nan1) <= (values_.infinity)\");\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT2(FloatLE, -values_.infinity, values_.nan1);\n  }, \"(-values_.infinity) <= (values_.nan1)\");\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT2(FloatLE, values_.nan1, values_.nan1);\n  }, \"(values_.nan1) <= (values_.nan1)\");\n#endif  // !GTEST_OS_SYMBIAN && !defined(__BORLANDC__)\n}\n\n// Instantiates FloatingPointTest for testing *_DOUBLE_EQ.\ntypedef FloatingPointTest<double> DoubleTest;\n\n// Tests that the size of Double::Bits matches the size of double.\nTEST_F(DoubleTest, Size) {\n  TestSize();\n}\n\n// Tests comparing with +0 and -0.\nTEST_F(DoubleTest, Zeros) {\n  EXPECT_DOUBLE_EQ(0.0, -0.0);\n  EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(-0.0, 1.0),\n                          \"1.0\");\n  EXPECT_FATAL_FAILURE(ASSERT_DOUBLE_EQ(0.0, 1.0),\n                       \"1.0\");\n}\n\n// Tests comparing numbers close to 0.\n//\n// This ensures that *_DOUBLE_EQ handles the sign correctly and no\n// overflow occurs when comparing numbers whose absolute value is very\n// small.\nTEST_F(DoubleTest, AlmostZeros) {\n  // In C++Builder, names within local classes (such as used by\n  // EXPECT_FATAL_FAILURE) cannot be resolved against static members of the\n  // scoping class.  Use a static local alias as a workaround.\n  // We use the assignment syntax since some compilers, like Sun Studio,\n  // don't allow initializing references using construction syntax\n  // (parentheses).\n  static const DoubleTest::TestValues& v = this->values_;\n\n  EXPECT_DOUBLE_EQ(0.0, v.close_to_positive_zero);\n  EXPECT_DOUBLE_EQ(-0.0, v.close_to_negative_zero);\n  EXPECT_DOUBLE_EQ(v.close_to_positive_zero, v.close_to_negative_zero);\n\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_DOUBLE_EQ(v.close_to_positive_zero,\n                     v.further_from_negative_zero);\n  }, \"v.further_from_negative_zero\");\n}\n\n// Tests comparing numbers close to each other.\nTEST_F(DoubleTest, SmallDiff) {\n  EXPECT_DOUBLE_EQ(1.0, values_.close_to_one);\n  EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(1.0, values_.further_from_one),\n                          \"values_.further_from_one\");\n}\n\n// Tests comparing numbers far apart.\nTEST_F(DoubleTest, LargeDiff) {\n  EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(2.0, 3.0),\n                          \"3.0\");\n}\n\n// Tests comparing with infinity.\n//\n// This ensures that no overflow occurs when comparing numbers whose\n// absolute value is very large.\nTEST_F(DoubleTest, Infinity) {\n  EXPECT_DOUBLE_EQ(values_.infinity, values_.close_to_infinity);\n  EXPECT_DOUBLE_EQ(-values_.infinity, -values_.close_to_infinity);\n#if !GTEST_OS_SYMBIAN\n  // Nokia's STLport crashes if we try to output infinity or NaN.\n  EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(values_.infinity, -values_.infinity),\n                          \"-values_.infinity\");\n\n  // This is interesting as the representations of infinity_ and nan1_\n  // are only 1 DLP apart.\n  EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(values_.infinity, values_.nan1),\n                          \"values_.nan1\");\n#endif  // !GTEST_OS_SYMBIAN\n}\n\n// Tests that comparing with NAN always returns false.\nTEST_F(DoubleTest, NaN) {\n#if !GTEST_OS_SYMBIAN\n  // In C++Builder, names within local classes (such as used by\n  // EXPECT_FATAL_FAILURE) cannot be resolved against static members of the\n  // scoping class.  Use a static local alias as a workaround.\n  // We use the assignment syntax since some compilers, like Sun Studio,\n  // don't allow initializing references using construction syntax\n  // (parentheses).\n  static const DoubleTest::TestValues& v = this->values_;\n\n  // Nokia's STLport crashes if we try to output infinity or NaN.\n  EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(v.nan1, v.nan1),\n                          \"v.nan1\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(v.nan1, v.nan2), \"v.nan2\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(1.0, v.nan1), \"v.nan1\");\n  EXPECT_FATAL_FAILURE(ASSERT_DOUBLE_EQ(v.nan1, v.infinity),\n                       \"v.infinity\");\n#endif  // !GTEST_OS_SYMBIAN\n}\n\n// Tests that *_DOUBLE_EQ are reflexive.\nTEST_F(DoubleTest, Reflexive) {\n  EXPECT_DOUBLE_EQ(0.0, 0.0);\n  EXPECT_DOUBLE_EQ(1.0, 1.0);\n#if !GTEST_OS_SYMBIAN\n  // Nokia's STLport crashes if we try to output infinity or NaN.\n  ASSERT_DOUBLE_EQ(values_.infinity, values_.infinity);\n#endif  // !GTEST_OS_SYMBIAN\n}\n\n// Tests that *_DOUBLE_EQ are commutative.\nTEST_F(DoubleTest, Commutative) {\n  // We already tested EXPECT_DOUBLE_EQ(1.0, values_.close_to_one).\n  EXPECT_DOUBLE_EQ(values_.close_to_one, 1.0);\n\n  // We already tested EXPECT_DOUBLE_EQ(1.0, values_.further_from_one).\n  EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(values_.further_from_one, 1.0),\n                          \"1.0\");\n}\n\n// Tests EXPECT_NEAR.\nTEST_F(DoubleTest, EXPECT_NEAR) {\n  EXPECT_NEAR(-1.0, -1.1, 0.2);\n  EXPECT_NEAR(2.0, 3.0, 1.0);\n  EXPECT_NONFATAL_FAILURE(EXPECT_NEAR(1.0, 1.5, 0.25),  // NOLINT\n                          \"The difference between 1.0 and 1.5 is 0.5, \"\n                          \"which exceeds 0.25\");\n  // To work around a bug in gcc 2.95.0, there is intentionally no\n  // space after the first comma in the previous statement.\n}\n\n// Tests ASSERT_NEAR.\nTEST_F(DoubleTest, ASSERT_NEAR) {\n  ASSERT_NEAR(-1.0, -1.1, 0.2);\n  ASSERT_NEAR(2.0, 3.0, 1.0);\n  EXPECT_FATAL_FAILURE(ASSERT_NEAR(1.0, 1.5, 0.25),  // NOLINT\n                       \"The difference between 1.0 and 1.5 is 0.5, \"\n                       \"which exceeds 0.25\");\n  // To work around a bug in gcc 2.95.0, there is intentionally no\n  // space after the first comma in the previous statement.\n}\n\n// Tests the cases where DoubleLE() should succeed.\nTEST_F(DoubleTest, DoubleLESucceeds) {\n  EXPECT_PRED_FORMAT2(DoubleLE, 1.0, 2.0);  // When val1 < val2,\n  ASSERT_PRED_FORMAT2(DoubleLE, 1.0, 1.0);  // val1 == val2,\n\n  // or when val1 is greater than, but almost equals to, val2.\n  EXPECT_PRED_FORMAT2(DoubleLE, values_.close_to_positive_zero, 0.0);\n}\n\n// Tests the cases where DoubleLE() should fail.\nTEST_F(DoubleTest, DoubleLEFails) {\n  // When val1 is greater than val2 by a large margin,\n  EXPECT_NONFATAL_FAILURE(EXPECT_PRED_FORMAT2(DoubleLE, 2.0, 1.0),\n                          \"(2.0) <= (1.0)\");\n\n  // or by a small yet non-negligible margin,\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT2(DoubleLE, values_.further_from_one, 1.0);\n  }, \"(values_.further_from_one) <= (1.0)\");\n\n#if !GTEST_OS_SYMBIAN && !defined(__BORLANDC__)\n  // Nokia's STLport crashes if we try to output infinity or NaN.\n  // C++Builder gives bad results for ordered comparisons involving NaNs\n  // due to compiler bugs.\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT2(DoubleLE, values_.nan1, values_.infinity);\n  }, \"(values_.nan1) <= (values_.infinity)\");\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_PRED_FORMAT2(DoubleLE, -values_.infinity, values_.nan1);\n  }, \" (-values_.infinity) <= (values_.nan1)\");\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_PRED_FORMAT2(DoubleLE, values_.nan1, values_.nan1);\n  }, \"(values_.nan1) <= (values_.nan1)\");\n#endif  // !GTEST_OS_SYMBIAN && !defined(__BORLANDC__)\n}\n\n\n// Verifies that a test or test case whose name starts with DISABLED_ is\n// not run.\n\n// A test whose name starts with DISABLED_.\n// Should not run.\nTEST(DisabledTest, DISABLED_TestShouldNotRun) {\n  FAIL() << \"Unexpected failure: Disabled test should not be run.\";\n}\n\n// A test whose name does not start with DISABLED_.\n// Should run.\nTEST(DisabledTest, NotDISABLED_TestShouldRun) {\n  EXPECT_EQ(1, 1);\n}\n\n// A test case whose name starts with DISABLED_.\n// Should not run.\nTEST(DISABLED_TestCase, TestShouldNotRun) {\n  FAIL() << \"Unexpected failure: Test in disabled test case should not be run.\";\n}\n\n// A test case and test whose names start with DISABLED_.\n// Should not run.\nTEST(DISABLED_TestCase, DISABLED_TestShouldNotRun) {\n  FAIL() << \"Unexpected failure: Test in disabled test case should not be run.\";\n}\n\n// Check that when all tests in a test case are disabled, SetupTestCase() and\n// TearDownTestCase() are not called.\nclass DisabledTestsTest : public Test {\n protected:\n  static void SetUpTestCase() {\n    FAIL() << \"Unexpected failure: All tests disabled in test case. \"\n              \"SetupTestCase() should not be called.\";\n  }\n\n  static void TearDownTestCase() {\n    FAIL() << \"Unexpected failure: All tests disabled in test case. \"\n              \"TearDownTestCase() should not be called.\";\n  }\n};\n\nTEST_F(DisabledTestsTest, DISABLED_TestShouldNotRun_1) {\n  FAIL() << \"Unexpected failure: Disabled test should not be run.\";\n}\n\nTEST_F(DisabledTestsTest, DISABLED_TestShouldNotRun_2) {\n  FAIL() << \"Unexpected failure: Disabled test should not be run.\";\n}\n\n// Tests that disabled typed tests aren't run.\n\n#if GTEST_HAS_TYPED_TEST\n\ntemplate <typename T>\nclass TypedTest : public Test {\n};\n\ntypedef testing::Types<int, double> NumericTypes;\nTYPED_TEST_CASE(TypedTest, NumericTypes);\n\nTYPED_TEST(TypedTest, DISABLED_ShouldNotRun) {\n  FAIL() << \"Unexpected failure: Disabled typed test should not run.\";\n}\n\ntemplate <typename T>\nclass DISABLED_TypedTest : public Test {\n};\n\nTYPED_TEST_CASE(DISABLED_TypedTest, NumericTypes);\n\nTYPED_TEST(DISABLED_TypedTest, ShouldNotRun) {\n  FAIL() << \"Unexpected failure: Disabled typed test should not run.\";\n}\n\n#endif  // GTEST_HAS_TYPED_TEST\n\n// Tests that disabled type-parameterized tests aren't run.\n\n#if GTEST_HAS_TYPED_TEST_P\n\ntemplate <typename T>\nclass TypedTestP : public Test {\n};\n\nTYPED_TEST_CASE_P(TypedTestP);\n\nTYPED_TEST_P(TypedTestP, DISABLED_ShouldNotRun) {\n  FAIL() << \"Unexpected failure: \"\n         << \"Disabled type-parameterized test should not run.\";\n}\n\nREGISTER_TYPED_TEST_CASE_P(TypedTestP, DISABLED_ShouldNotRun);\n\nINSTANTIATE_TYPED_TEST_CASE_P(My, TypedTestP, NumericTypes);\n\ntemplate <typename T>\nclass DISABLED_TypedTestP : public Test {\n};\n\nTYPED_TEST_CASE_P(DISABLED_TypedTestP);\n\nTYPED_TEST_P(DISABLED_TypedTestP, ShouldNotRun) {\n  FAIL() << \"Unexpected failure: \"\n         << \"Disabled type-parameterized test should not run.\";\n}\n\nREGISTER_TYPED_TEST_CASE_P(DISABLED_TypedTestP, ShouldNotRun);\n\nINSTANTIATE_TYPED_TEST_CASE_P(My, DISABLED_TypedTestP, NumericTypes);\n\n#endif  // GTEST_HAS_TYPED_TEST_P\n\n// Tests that assertion macros evaluate their arguments exactly once.\n\nclass SingleEvaluationTest : public Test {\n public:  // Must be public and not protected due to a bug in g++ 3.4.2.\n  // This helper function is needed by the FailedASSERT_STREQ test\n  // below.  It's public to work around C++Builder's bug with scoping local\n  // classes.\n  static void CompareAndIncrementCharPtrs() {\n    ASSERT_STREQ(p1_++, p2_++);\n  }\n\n  // This helper function is needed by the FailedASSERT_NE test below.  It's\n  // public to work around C++Builder's bug with scoping local classes.\n  static void CompareAndIncrementInts() {\n    ASSERT_NE(a_++, b_++);\n  }\n\n protected:\n  SingleEvaluationTest() {\n    p1_ = s1_;\n    p2_ = s2_;\n    a_ = 0;\n    b_ = 0;\n  }\n\n  static const char* const s1_;\n  static const char* const s2_;\n  static const char* p1_;\n  static const char* p2_;\n\n  static int a_;\n  static int b_;\n};\n\nconst char* const SingleEvaluationTest::s1_ = \"01234\";\nconst char* const SingleEvaluationTest::s2_ = \"abcde\";\nconst char* SingleEvaluationTest::p1_;\nconst char* SingleEvaluationTest::p2_;\nint SingleEvaluationTest::a_;\nint SingleEvaluationTest::b_;\n\n// Tests that when ASSERT_STREQ fails, it evaluates its arguments\n// exactly once.\nTEST_F(SingleEvaluationTest, FailedASSERT_STREQ) {\n  EXPECT_FATAL_FAILURE(SingleEvaluationTest::CompareAndIncrementCharPtrs(),\n                       \"p2_++\");\n  EXPECT_EQ(s1_ + 1, p1_);\n  EXPECT_EQ(s2_ + 1, p2_);\n}\n\n// Tests that string assertion arguments are evaluated exactly once.\nTEST_F(SingleEvaluationTest, ASSERT_STR) {\n  // successful EXPECT_STRNE\n  EXPECT_STRNE(p1_++, p2_++);\n  EXPECT_EQ(s1_ + 1, p1_);\n  EXPECT_EQ(s2_ + 1, p2_);\n\n  // failed EXPECT_STRCASEEQ\n  EXPECT_NONFATAL_FAILURE(EXPECT_STRCASEEQ(p1_++, p2_++),\n                          \"ignoring case\");\n  EXPECT_EQ(s1_ + 2, p1_);\n  EXPECT_EQ(s2_ + 2, p2_);\n}\n\n// Tests that when ASSERT_NE fails, it evaluates its arguments exactly\n// once.\nTEST_F(SingleEvaluationTest, FailedASSERT_NE) {\n  EXPECT_FATAL_FAILURE(SingleEvaluationTest::CompareAndIncrementInts(),\n                       \"(a_++) != (b_++)\");\n  EXPECT_EQ(1, a_);\n  EXPECT_EQ(1, b_);\n}\n\n// Tests that assertion arguments are evaluated exactly once.\nTEST_F(SingleEvaluationTest, OtherCases) {\n  // successful EXPECT_TRUE\n  EXPECT_TRUE(0 == a_++);  // NOLINT\n  EXPECT_EQ(1, a_);\n\n  // failed EXPECT_TRUE\n  EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(-1 == a_++), \"-1 == a_++\");\n  EXPECT_EQ(2, a_);\n\n  // successful EXPECT_GT\n  EXPECT_GT(a_++, b_++);\n  EXPECT_EQ(3, a_);\n  EXPECT_EQ(1, b_);\n\n  // failed EXPECT_LT\n  EXPECT_NONFATAL_FAILURE(EXPECT_LT(a_++, b_++), \"(a_++) < (b_++)\");\n  EXPECT_EQ(4, a_);\n  EXPECT_EQ(2, b_);\n\n  // successful ASSERT_TRUE\n  ASSERT_TRUE(0 < a_++);  // NOLINT\n  EXPECT_EQ(5, a_);\n\n  // successful ASSERT_GT\n  ASSERT_GT(a_++, b_++);\n  EXPECT_EQ(6, a_);\n  EXPECT_EQ(3, b_);\n}\n\n#if GTEST_HAS_EXCEPTIONS\n\nvoid ThrowAnInteger() {\n  throw 1;\n}\n\n// Tests that assertion arguments are evaluated exactly once.\nTEST_F(SingleEvaluationTest, ExceptionTests) {\n  // successful EXPECT_THROW\n  EXPECT_THROW({  // NOLINT\n    a_++;\n    ThrowAnInteger();\n  }, int);\n  EXPECT_EQ(1, a_);\n\n  // failed EXPECT_THROW, throws different\n  EXPECT_NONFATAL_FAILURE(EXPECT_THROW({  // NOLINT\n    a_++;\n    ThrowAnInteger();\n  }, bool), \"throws a different type\");\n  EXPECT_EQ(2, a_);\n\n  // failed EXPECT_THROW, throws nothing\n  EXPECT_NONFATAL_FAILURE(EXPECT_THROW(a_++, bool), \"throws nothing\");\n  EXPECT_EQ(3, a_);\n\n  // successful EXPECT_NO_THROW\n  EXPECT_NO_THROW(a_++);\n  EXPECT_EQ(4, a_);\n\n  // failed EXPECT_NO_THROW\n  EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW({  // NOLINT\n    a_++;\n    ThrowAnInteger();\n  }), \"it throws\");\n  EXPECT_EQ(5, a_);\n\n  // successful EXPECT_ANY_THROW\n  EXPECT_ANY_THROW({  // NOLINT\n    a_++;\n    ThrowAnInteger();\n  });\n  EXPECT_EQ(6, a_);\n\n  // failed EXPECT_ANY_THROW\n  EXPECT_NONFATAL_FAILURE(EXPECT_ANY_THROW(a_++), \"it doesn't\");\n  EXPECT_EQ(7, a_);\n}\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n// Tests {ASSERT|EXPECT}_NO_FATAL_FAILURE.\nclass NoFatalFailureTest : public Test {\n protected:\n  void Succeeds() {}\n  void FailsNonFatal() {\n    ADD_FAILURE() << \"some non-fatal failure\";\n  }\n  void Fails() {\n    FAIL() << \"some fatal failure\";\n  }\n\n  void DoAssertNoFatalFailureOnFails() {\n    ASSERT_NO_FATAL_FAILURE(Fails());\n    ADD_FAILURE() << \"shold not reach here.\";\n  }\n\n  void DoExpectNoFatalFailureOnFails() {\n    EXPECT_NO_FATAL_FAILURE(Fails());\n    ADD_FAILURE() << \"other failure\";\n  }\n};\n\nTEST_F(NoFatalFailureTest, NoFailure) {\n  EXPECT_NO_FATAL_FAILURE(Succeeds());\n  ASSERT_NO_FATAL_FAILURE(Succeeds());\n}\n\nTEST_F(NoFatalFailureTest, NonFatalIsNoFailure) {\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_NO_FATAL_FAILURE(FailsNonFatal()),\n      \"some non-fatal failure\");\n  EXPECT_NONFATAL_FAILURE(\n      ASSERT_NO_FATAL_FAILURE(FailsNonFatal()),\n      \"some non-fatal failure\");\n}\n\nTEST_F(NoFatalFailureTest, AssertNoFatalFailureOnFatalFailure) {\n  TestPartResultArray gtest_failures;\n  {\n    ScopedFakeTestPartResultReporter gtest_reporter(&gtest_failures);\n    DoAssertNoFatalFailureOnFails();\n  }\n  ASSERT_EQ(2, gtest_failures.size());\n  EXPECT_EQ(TestPartResult::kFatalFailure,\n            gtest_failures.GetTestPartResult(0).type());\n  EXPECT_EQ(TestPartResult::kFatalFailure,\n            gtest_failures.GetTestPartResult(1).type());\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, \"some fatal failure\",\n                      gtest_failures.GetTestPartResult(0).message());\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, \"it does\",\n                      gtest_failures.GetTestPartResult(1).message());\n}\n\nTEST_F(NoFatalFailureTest, ExpectNoFatalFailureOnFatalFailure) {\n  TestPartResultArray gtest_failures;\n  {\n    ScopedFakeTestPartResultReporter gtest_reporter(&gtest_failures);\n    DoExpectNoFatalFailureOnFails();\n  }\n  ASSERT_EQ(3, gtest_failures.size());\n  EXPECT_EQ(TestPartResult::kFatalFailure,\n            gtest_failures.GetTestPartResult(0).type());\n  EXPECT_EQ(TestPartResult::kNonFatalFailure,\n            gtest_failures.GetTestPartResult(1).type());\n  EXPECT_EQ(TestPartResult::kNonFatalFailure,\n            gtest_failures.GetTestPartResult(2).type());\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, \"some fatal failure\",\n                      gtest_failures.GetTestPartResult(0).message());\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, \"it does\",\n                      gtest_failures.GetTestPartResult(1).message());\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, \"other failure\",\n                      gtest_failures.GetTestPartResult(2).message());\n}\n\nTEST_F(NoFatalFailureTest, MessageIsStreamable) {\n  TestPartResultArray gtest_failures;\n  {\n    ScopedFakeTestPartResultReporter gtest_reporter(&gtest_failures);\n    EXPECT_NO_FATAL_FAILURE(FAIL() << \"foo\") << \"my message\";\n  }\n  ASSERT_EQ(2, gtest_failures.size());\n  EXPECT_EQ(TestPartResult::kNonFatalFailure,\n            gtest_failures.GetTestPartResult(0).type());\n  EXPECT_EQ(TestPartResult::kNonFatalFailure,\n            gtest_failures.GetTestPartResult(1).type());\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, \"foo\",\n                      gtest_failures.GetTestPartResult(0).message());\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, \"my message\",\n                      gtest_failures.GetTestPartResult(1).message());\n}\n\n// Tests non-string assertions.\n\n// Tests EqFailure(), used for implementing *EQ* assertions.\nTEST(AssertionTest, EqFailure) {\n  const std::string foo_val(\"5\"), bar_val(\"6\");\n  const std::string msg1(\n      EqFailure(\"foo\", \"bar\", foo_val, bar_val, false)\n      .failure_message());\n  EXPECT_STREQ(\n      \"Value of: bar\\n\"\n      \"  Actual: 6\\n\"\n      \"Expected: foo\\n\"\n      \"Which is: 5\",\n      msg1.c_str());\n\n  const std::string msg2(\n      EqFailure(\"foo\", \"6\", foo_val, bar_val, false)\n      .failure_message());\n  EXPECT_STREQ(\n      \"Value of: 6\\n\"\n      \"Expected: foo\\n\"\n      \"Which is: 5\",\n      msg2.c_str());\n\n  const std::string msg3(\n      EqFailure(\"5\", \"bar\", foo_val, bar_val, false)\n      .failure_message());\n  EXPECT_STREQ(\n      \"Value of: bar\\n\"\n      \"  Actual: 6\\n\"\n      \"Expected: 5\",\n      msg3.c_str());\n\n  const std::string msg4(\n      EqFailure(\"5\", \"6\", foo_val, bar_val, false).failure_message());\n  EXPECT_STREQ(\n      \"Value of: 6\\n\"\n      \"Expected: 5\",\n      msg4.c_str());\n\n  const std::string msg5(\n      EqFailure(\"foo\", \"bar\",\n                std::string(\"\\\"x\\\"\"), std::string(\"\\\"y\\\"\"),\n                true).failure_message());\n  EXPECT_STREQ(\n      \"Value of: bar\\n\"\n      \"  Actual: \\\"y\\\"\\n\"\n      \"Expected: foo (ignoring case)\\n\"\n      \"Which is: \\\"x\\\"\",\n      msg5.c_str());\n}\n\n// Tests AppendUserMessage(), used for implementing the *EQ* macros.\nTEST(AssertionTest, AppendUserMessage) {\n  const std::string foo(\"foo\");\n\n  Message msg;\n  EXPECT_STREQ(\"foo\",\n               AppendUserMessage(foo, msg).c_str());\n\n  msg << \"bar\";\n  EXPECT_STREQ(\"foo\\nbar\",\n               AppendUserMessage(foo, msg).c_str());\n}\n\n#ifdef __BORLANDC__\n// Silences warnings: \"Condition is always true\", \"Unreachable code\"\n# pragma option push -w-ccc -w-rch\n#endif\n\n// Tests ASSERT_TRUE.\nTEST(AssertionTest, ASSERT_TRUE) {\n  ASSERT_TRUE(2 > 1);  // NOLINT\n  EXPECT_FATAL_FAILURE(ASSERT_TRUE(2 < 1),\n                       \"2 < 1\");\n}\n\n// Tests ASSERT_TRUE(predicate) for predicates returning AssertionResult.\nTEST(AssertionTest, AssertTrueWithAssertionResult) {\n  ASSERT_TRUE(ResultIsEven(2));\n#ifndef __BORLANDC__\n  // ICE's in C++Builder.\n  EXPECT_FATAL_FAILURE(ASSERT_TRUE(ResultIsEven(3)),\n                       \"Value of: ResultIsEven(3)\\n\"\n                       \"  Actual: false (3 is odd)\\n\"\n                       \"Expected: true\");\n#endif\n  ASSERT_TRUE(ResultIsEvenNoExplanation(2));\n  EXPECT_FATAL_FAILURE(ASSERT_TRUE(ResultIsEvenNoExplanation(3)),\n                       \"Value of: ResultIsEvenNoExplanation(3)\\n\"\n                       \"  Actual: false (3 is odd)\\n\"\n                       \"Expected: true\");\n}\n\n// Tests ASSERT_FALSE.\nTEST(AssertionTest, ASSERT_FALSE) {\n  ASSERT_FALSE(2 < 1);  // NOLINT\n  EXPECT_FATAL_FAILURE(ASSERT_FALSE(2 > 1),\n                       \"Value of: 2 > 1\\n\"\n                       \"  Actual: true\\n\"\n                       \"Expected: false\");\n}\n\n// Tests ASSERT_FALSE(predicate) for predicates returning AssertionResult.\nTEST(AssertionTest, AssertFalseWithAssertionResult) {\n  ASSERT_FALSE(ResultIsEven(3));\n#ifndef __BORLANDC__\n  // ICE's in C++Builder.\n  EXPECT_FATAL_FAILURE(ASSERT_FALSE(ResultIsEven(2)),\n                       \"Value of: ResultIsEven(2)\\n\"\n                       \"  Actual: true (2 is even)\\n\"\n                       \"Expected: false\");\n#endif\n  ASSERT_FALSE(ResultIsEvenNoExplanation(3));\n  EXPECT_FATAL_FAILURE(ASSERT_FALSE(ResultIsEvenNoExplanation(2)),\n                       \"Value of: ResultIsEvenNoExplanation(2)\\n\"\n                       \"  Actual: true\\n\"\n                       \"Expected: false\");\n}\n\n#ifdef __BORLANDC__\n// Restores warnings after previous \"#pragma option push\" supressed them\n# pragma option pop\n#endif\n\n// Tests using ASSERT_EQ on double values.  The purpose is to make\n// sure that the specialization we did for integer and anonymous enums\n// isn't used for double arguments.\nTEST(ExpectTest, ASSERT_EQ_Double) {\n  // A success.\n  ASSERT_EQ(5.6, 5.6);\n\n  // A failure.\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(5.1, 5.2),\n                       \"5.1\");\n}\n\n// Tests ASSERT_EQ.\nTEST(AssertionTest, ASSERT_EQ) {\n  ASSERT_EQ(5, 2 + 3);\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(5, 2*3),\n                       \"Value of: 2*3\\n\"\n                       \"  Actual: 6\\n\"\n                       \"Expected: 5\");\n}\n\n// Tests ASSERT_EQ(NULL, pointer).\n#if GTEST_CAN_COMPARE_NULL\nTEST(AssertionTest, ASSERT_EQ_NULL) {\n  // A success.\n  const char* p = NULL;\n  // Some older GCC versions may issue a spurious waring in this or the next\n  // assertion statement. This warning should not be suppressed with\n  // static_cast since the test verifies the ability to use bare NULL as the\n  // expected parameter to the macro.\n  ASSERT_EQ(NULL, p);\n\n  // A failure.\n  static int n = 0;\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(NULL, &n),\n                       \"Value of: &n\\n\");\n}\n#endif  // GTEST_CAN_COMPARE_NULL\n\n// Tests ASSERT_EQ(0, non_pointer).  Since the literal 0 can be\n// treated as a null pointer by the compiler, we need to make sure\n// that ASSERT_EQ(0, non_pointer) isn't interpreted by Google Test as\n// ASSERT_EQ(static_cast<void*>(NULL), non_pointer).\nTEST(ExpectTest, ASSERT_EQ_0) {\n  int n = 0;\n\n  // A success.\n  ASSERT_EQ(0, n);\n\n  // A failure.\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(0, 5.6),\n                       \"Expected: 0\");\n}\n\n// Tests ASSERT_NE.\nTEST(AssertionTest, ASSERT_NE) {\n  ASSERT_NE(6, 7);\n  EXPECT_FATAL_FAILURE(ASSERT_NE('a', 'a'),\n                       \"Expected: ('a') != ('a'), \"\n                       \"actual: 'a' (97, 0x61) vs 'a' (97, 0x61)\");\n}\n\n// Tests ASSERT_LE.\nTEST(AssertionTest, ASSERT_LE) {\n  ASSERT_LE(2, 3);\n  ASSERT_LE(2, 2);\n  EXPECT_FATAL_FAILURE(ASSERT_LE(2, 0),\n                       \"Expected: (2) <= (0), actual: 2 vs 0\");\n}\n\n// Tests ASSERT_LT.\nTEST(AssertionTest, ASSERT_LT) {\n  ASSERT_LT(2, 3);\n  EXPECT_FATAL_FAILURE(ASSERT_LT(2, 2),\n                       \"Expected: (2) < (2), actual: 2 vs 2\");\n}\n\n// Tests ASSERT_GE.\nTEST(AssertionTest, ASSERT_GE) {\n  ASSERT_GE(2, 1);\n  ASSERT_GE(2, 2);\n  EXPECT_FATAL_FAILURE(ASSERT_GE(2, 3),\n                       \"Expected: (2) >= (3), actual: 2 vs 3\");\n}\n\n// Tests ASSERT_GT.\nTEST(AssertionTest, ASSERT_GT) {\n  ASSERT_GT(2, 1);\n  EXPECT_FATAL_FAILURE(ASSERT_GT(2, 2),\n                       \"Expected: (2) > (2), actual: 2 vs 2\");\n}\n\n#if GTEST_HAS_EXCEPTIONS\n\nvoid ThrowNothing() {}\n\n// Tests ASSERT_THROW.\nTEST(AssertionTest, ASSERT_THROW) {\n  ASSERT_THROW(ThrowAnInteger(), int);\n\n# ifndef __BORLANDC__\n\n  // ICE's in C++Builder 2007 and 2009.\n  EXPECT_FATAL_FAILURE(\n      ASSERT_THROW(ThrowAnInteger(), bool),\n      \"Expected: ThrowAnInteger() throws an exception of type bool.\\n\"\n      \"  Actual: it throws a different type.\");\n# endif\n\n  EXPECT_FATAL_FAILURE(\n      ASSERT_THROW(ThrowNothing(), bool),\n      \"Expected: ThrowNothing() throws an exception of type bool.\\n\"\n      \"  Actual: it throws nothing.\");\n}\n\n// Tests ASSERT_NO_THROW.\nTEST(AssertionTest, ASSERT_NO_THROW) {\n  ASSERT_NO_THROW(ThrowNothing());\n  EXPECT_FATAL_FAILURE(ASSERT_NO_THROW(ThrowAnInteger()),\n                       \"Expected: ThrowAnInteger() doesn't throw an exception.\"\n                       \"\\n  Actual: it throws.\");\n}\n\n// Tests ASSERT_ANY_THROW.\nTEST(AssertionTest, ASSERT_ANY_THROW) {\n  ASSERT_ANY_THROW(ThrowAnInteger());\n  EXPECT_FATAL_FAILURE(\n      ASSERT_ANY_THROW(ThrowNothing()),\n      \"Expected: ThrowNothing() throws an exception.\\n\"\n      \"  Actual: it doesn't.\");\n}\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n// Makes sure we deal with the precedence of <<.  This test should\n// compile.\nTEST(AssertionTest, AssertPrecedence) {\n  ASSERT_EQ(1 < 2, true);\n  bool false_value = false;\n  ASSERT_EQ(true && false_value, false);\n}\n\n// A subroutine used by the following test.\nvoid TestEq1(int x) {\n  ASSERT_EQ(1, x);\n}\n\n// Tests calling a test subroutine that's not part of a fixture.\nTEST(AssertionTest, NonFixtureSubroutine) {\n  EXPECT_FATAL_FAILURE(TestEq1(2),\n                       \"Value of: x\");\n}\n\n// An uncopyable class.\nclass Uncopyable {\n public:\n  explicit Uncopyable(int a_value) : value_(a_value) {}\n\n  int value() const { return value_; }\n  bool operator==(const Uncopyable& rhs) const {\n    return value() == rhs.value();\n  }\n private:\n  // This constructor deliberately has no implementation, as we don't\n  // want this class to be copyable.\n  Uncopyable(const Uncopyable&);  // NOLINT\n\n  int value_;\n};\n\n::std::ostream& operator<<(::std::ostream& os, const Uncopyable& value) {\n  return os << value.value();\n}\n\n\nbool IsPositiveUncopyable(const Uncopyable& x) {\n  return x.value() > 0;\n}\n\n// A subroutine used by the following test.\nvoid TestAssertNonPositive() {\n  Uncopyable y(-1);\n  ASSERT_PRED1(IsPositiveUncopyable, y);\n}\n// A subroutine used by the following test.\nvoid TestAssertEqualsUncopyable() {\n  Uncopyable x(5);\n  Uncopyable y(-1);\n  ASSERT_EQ(x, y);\n}\n\n// Tests that uncopyable objects can be used in assertions.\nTEST(AssertionTest, AssertWorksWithUncopyableObject) {\n  Uncopyable x(5);\n  ASSERT_PRED1(IsPositiveUncopyable, x);\n  ASSERT_EQ(x, x);\n  EXPECT_FATAL_FAILURE(TestAssertNonPositive(),\n    \"IsPositiveUncopyable(y) evaluates to false, where\\ny evaluates to -1\");\n  EXPECT_FATAL_FAILURE(TestAssertEqualsUncopyable(),\n    \"Value of: y\\n  Actual: -1\\nExpected: x\\nWhich is: 5\");\n}\n\n// Tests that uncopyable objects can be used in expects.\nTEST(AssertionTest, ExpectWorksWithUncopyableObject) {\n  Uncopyable x(5);\n  EXPECT_PRED1(IsPositiveUncopyable, x);\n  Uncopyable y(-1);\n  EXPECT_NONFATAL_FAILURE(EXPECT_PRED1(IsPositiveUncopyable, y),\n    \"IsPositiveUncopyable(y) evaluates to false, where\\ny evaluates to -1\");\n  EXPECT_EQ(x, x);\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(x, y),\n    \"Value of: y\\n  Actual: -1\\nExpected: x\\nWhich is: 5\");\n}\n\nenum NamedEnum {\n  kE1 = 0,\n  kE2 = 1\n};\n\nTEST(AssertionTest, NamedEnum) {\n  EXPECT_EQ(kE1, kE1);\n  EXPECT_LT(kE1, kE2);\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(kE1, kE2), \"Which is: 0\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(kE1, kE2), \"Actual: 1\");\n}\n\n// The version of gcc used in XCode 2.2 has a bug and doesn't allow\n// anonymous enums in assertions.  Therefore the following test is not\n// done on Mac.\n// Sun Studio and HP aCC also reject this code.\n#if !GTEST_OS_MAC && !defined(__SUNPRO_CC) && !defined(__HP_aCC)\n\n// Tests using assertions with anonymous enums.\nenum {\n  kCaseA = -1,\n\n# if GTEST_OS_LINUX\n\n  // We want to test the case where the size of the anonymous enum is\n  // larger than sizeof(int), to make sure our implementation of the\n  // assertions doesn't truncate the enums.  However, MSVC\n  // (incorrectly) doesn't allow an enum value to exceed the range of\n  // an int, so this has to be conditionally compiled.\n  //\n  // On Linux, kCaseB and kCaseA have the same value when truncated to\n  // int size.  We want to test whether this will confuse the\n  // assertions.\n  kCaseB = testing::internal::kMaxBiggestInt,\n\n# else\n\n  kCaseB = INT_MAX,\n\n# endif  // GTEST_OS_LINUX\n\n  kCaseC = 42\n};\n\nTEST(AssertionTest, AnonymousEnum) {\n# if GTEST_OS_LINUX\n\n  EXPECT_EQ(static_cast<int>(kCaseA), static_cast<int>(kCaseB));\n\n# endif  // GTEST_OS_LINUX\n\n  EXPECT_EQ(kCaseA, kCaseA);\n  EXPECT_NE(kCaseA, kCaseB);\n  EXPECT_LT(kCaseA, kCaseB);\n  EXPECT_LE(kCaseA, kCaseB);\n  EXPECT_GT(kCaseB, kCaseA);\n  EXPECT_GE(kCaseA, kCaseA);\n  EXPECT_NONFATAL_FAILURE(EXPECT_GE(kCaseA, kCaseB),\n                          \"(kCaseA) >= (kCaseB)\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_GE(kCaseA, kCaseC),\n                          \"-1 vs 42\");\n\n  ASSERT_EQ(kCaseA, kCaseA);\n  ASSERT_NE(kCaseA, kCaseB);\n  ASSERT_LT(kCaseA, kCaseB);\n  ASSERT_LE(kCaseA, kCaseB);\n  ASSERT_GT(kCaseB, kCaseA);\n  ASSERT_GE(kCaseA, kCaseA);\n\n# ifndef __BORLANDC__\n\n  // ICE's in C++Builder.\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseB),\n                       \"Value of: kCaseB\");\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseC),\n                       \"Actual: 42\");\n# endif\n\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(kCaseA, kCaseC),\n                       \"Which is: -1\");\n}\n\n#endif  // !GTEST_OS_MAC && !defined(__SUNPRO_CC)\n\n#if GTEST_OS_WINDOWS\n\nstatic HRESULT UnexpectedHRESULTFailure() {\n  return E_UNEXPECTED;\n}\n\nstatic HRESULT OkHRESULTSuccess() {\n  return S_OK;\n}\n\nstatic HRESULT FalseHRESULTSuccess() {\n  return S_FALSE;\n}\n\n// HRESULT assertion tests test both zero and non-zero\n// success codes as well as failure message for each.\n//\n// Windows CE doesn't support message texts.\nTEST(HRESULTAssertionTest, EXPECT_HRESULT_SUCCEEDED) {\n  EXPECT_HRESULT_SUCCEEDED(S_OK);\n  EXPECT_HRESULT_SUCCEEDED(S_FALSE);\n\n  EXPECT_NONFATAL_FAILURE(EXPECT_HRESULT_SUCCEEDED(UnexpectedHRESULTFailure()),\n    \"Expected: (UnexpectedHRESULTFailure()) succeeds.\\n\"\n    \"  Actual: 0x8000FFFF\");\n}\n\nTEST(HRESULTAssertionTest, ASSERT_HRESULT_SUCCEEDED) {\n  ASSERT_HRESULT_SUCCEEDED(S_OK);\n  ASSERT_HRESULT_SUCCEEDED(S_FALSE);\n\n  EXPECT_FATAL_FAILURE(ASSERT_HRESULT_SUCCEEDED(UnexpectedHRESULTFailure()),\n    \"Expected: (UnexpectedHRESULTFailure()) succeeds.\\n\"\n    \"  Actual: 0x8000FFFF\");\n}\n\nTEST(HRESULTAssertionTest, EXPECT_HRESULT_FAILED) {\n  EXPECT_HRESULT_FAILED(E_UNEXPECTED);\n\n  EXPECT_NONFATAL_FAILURE(EXPECT_HRESULT_FAILED(OkHRESULTSuccess()),\n    \"Expected: (OkHRESULTSuccess()) fails.\\n\"\n    \"  Actual: 0x0\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_HRESULT_FAILED(FalseHRESULTSuccess()),\n    \"Expected: (FalseHRESULTSuccess()) fails.\\n\"\n    \"  Actual: 0x1\");\n}\n\nTEST(HRESULTAssertionTest, ASSERT_HRESULT_FAILED) {\n  ASSERT_HRESULT_FAILED(E_UNEXPECTED);\n\n# ifndef __BORLANDC__\n\n  // ICE's in C++Builder 2007 and 2009.\n  EXPECT_FATAL_FAILURE(ASSERT_HRESULT_FAILED(OkHRESULTSuccess()),\n    \"Expected: (OkHRESULTSuccess()) fails.\\n\"\n    \"  Actual: 0x0\");\n# endif\n\n  EXPECT_FATAL_FAILURE(ASSERT_HRESULT_FAILED(FalseHRESULTSuccess()),\n    \"Expected: (FalseHRESULTSuccess()) fails.\\n\"\n    \"  Actual: 0x1\");\n}\n\n// Tests that streaming to the HRESULT macros works.\nTEST(HRESULTAssertionTest, Streaming) {\n  EXPECT_HRESULT_SUCCEEDED(S_OK) << \"unexpected failure\";\n  ASSERT_HRESULT_SUCCEEDED(S_OK) << \"unexpected failure\";\n  EXPECT_HRESULT_FAILED(E_UNEXPECTED) << \"unexpected failure\";\n  ASSERT_HRESULT_FAILED(E_UNEXPECTED) << \"unexpected failure\";\n\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_HRESULT_SUCCEEDED(E_UNEXPECTED) << \"expected failure\",\n      \"expected failure\");\n\n# ifndef __BORLANDC__\n\n  // ICE's in C++Builder 2007 and 2009.\n  EXPECT_FATAL_FAILURE(\n      ASSERT_HRESULT_SUCCEEDED(E_UNEXPECTED) << \"expected failure\",\n      \"expected failure\");\n# endif\n\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_HRESULT_FAILED(S_OK) << \"expected failure\",\n      \"expected failure\");\n\n  EXPECT_FATAL_FAILURE(\n      ASSERT_HRESULT_FAILED(S_OK) << \"expected failure\",\n      \"expected failure\");\n}\n\n#endif  // GTEST_OS_WINDOWS\n\n#ifdef __BORLANDC__\n// Silences warnings: \"Condition is always true\", \"Unreachable code\"\n# pragma option push -w-ccc -w-rch\n#endif\n\n// Tests that the assertion macros behave like single statements.\nTEST(AssertionSyntaxTest, BasicAssertionsBehavesLikeSingleStatement) {\n  if (AlwaysFalse())\n    ASSERT_TRUE(false) << \"This should never be executed; \"\n                          \"It's a compilation test only.\";\n\n  if (AlwaysTrue())\n    EXPECT_FALSE(false);\n  else\n    ;  // NOLINT\n\n  if (AlwaysFalse())\n    ASSERT_LT(1, 3);\n\n  if (AlwaysFalse())\n    ;  // NOLINT\n  else\n    EXPECT_GT(3, 2) << \"\";\n}\n\n#if GTEST_HAS_EXCEPTIONS\n// Tests that the compiler will not complain about unreachable code in the\n// EXPECT_THROW/EXPECT_ANY_THROW/EXPECT_NO_THROW macros.\nTEST(ExpectThrowTest, DoesNotGenerateUnreachableCodeWarning) {\n  int n = 0;\n\n  EXPECT_THROW(throw 1, int);\n  EXPECT_NONFATAL_FAILURE(EXPECT_THROW(n++, int), \"\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_THROW(throw 1, const char*), \"\");\n  EXPECT_NO_THROW(n++);\n  EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW(throw 1), \"\");\n  EXPECT_ANY_THROW(throw 1);\n  EXPECT_NONFATAL_FAILURE(EXPECT_ANY_THROW(n++), \"\");\n}\n\nTEST(AssertionSyntaxTest, ExceptionAssertionsBehavesLikeSingleStatement) {\n  if (AlwaysFalse())\n    EXPECT_THROW(ThrowNothing(), bool);\n\n  if (AlwaysTrue())\n    EXPECT_THROW(ThrowAnInteger(), int);\n  else\n    ;  // NOLINT\n\n  if (AlwaysFalse())\n    EXPECT_NO_THROW(ThrowAnInteger());\n\n  if (AlwaysTrue())\n    EXPECT_NO_THROW(ThrowNothing());\n  else\n    ;  // NOLINT\n\n  if (AlwaysFalse())\n    EXPECT_ANY_THROW(ThrowNothing());\n\n  if (AlwaysTrue())\n    EXPECT_ANY_THROW(ThrowAnInteger());\n  else\n    ;  // NOLINT\n}\n#endif  // GTEST_HAS_EXCEPTIONS\n\nTEST(AssertionSyntaxTest, NoFatalFailureAssertionsBehavesLikeSingleStatement) {\n  if (AlwaysFalse())\n    EXPECT_NO_FATAL_FAILURE(FAIL()) << \"This should never be executed. \"\n                                    << \"It's a compilation test only.\";\n  else\n    ;  // NOLINT\n\n  if (AlwaysFalse())\n    ASSERT_NO_FATAL_FAILURE(FAIL()) << \"\";\n  else\n    ;  // NOLINT\n\n  if (AlwaysTrue())\n    EXPECT_NO_FATAL_FAILURE(SUCCEED());\n  else\n    ;  // NOLINT\n\n  if (AlwaysFalse())\n    ;  // NOLINT\n  else\n    ASSERT_NO_FATAL_FAILURE(SUCCEED());\n}\n\n// Tests that the assertion macros work well with switch statements.\nTEST(AssertionSyntaxTest, WorksWithSwitch) {\n  switch (0) {\n    case 1:\n      break;\n    default:\n      ASSERT_TRUE(true);\n  }\n\n  switch (0)\n    case 0:\n      EXPECT_FALSE(false) << \"EXPECT_FALSE failed in switch case\";\n\n  // Binary assertions are implemented using a different code path\n  // than the Boolean assertions.  Hence we test them separately.\n  switch (0) {\n    case 1:\n    default:\n      ASSERT_EQ(1, 1) << \"ASSERT_EQ failed in default switch handler\";\n  }\n\n  switch (0)\n    case 0:\n      EXPECT_NE(1, 2);\n}\n\n#if GTEST_HAS_EXCEPTIONS\n\nvoid ThrowAString() {\n    throw \"std::string\";\n}\n\n// Test that the exception assertion macros compile and work with const\n// type qualifier.\nTEST(AssertionSyntaxTest, WorksWithConst) {\n    ASSERT_THROW(ThrowAString(), const char*);\n\n    EXPECT_THROW(ThrowAString(), const char*);\n}\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n}  // namespace\n\nnamespace testing {\n\n// Tests that Google Test tracks SUCCEED*.\nTEST(SuccessfulAssertionTest, SUCCEED) {\n  SUCCEED();\n  SUCCEED() << \"OK\";\n  EXPECT_EQ(2, GetUnitTestImpl()->current_test_result()->total_part_count());\n}\n\n// Tests that Google Test doesn't track successful EXPECT_*.\nTEST(SuccessfulAssertionTest, EXPECT) {\n  EXPECT_TRUE(true);\n  EXPECT_EQ(0, GetUnitTestImpl()->current_test_result()->total_part_count());\n}\n\n// Tests that Google Test doesn't track successful EXPECT_STR*.\nTEST(SuccessfulAssertionTest, EXPECT_STR) {\n  EXPECT_STREQ(\"\", \"\");\n  EXPECT_EQ(0, GetUnitTestImpl()->current_test_result()->total_part_count());\n}\n\n// Tests that Google Test doesn't track successful ASSERT_*.\nTEST(SuccessfulAssertionTest, ASSERT) {\n  ASSERT_TRUE(true);\n  EXPECT_EQ(0, GetUnitTestImpl()->current_test_result()->total_part_count());\n}\n\n// Tests that Google Test doesn't track successful ASSERT_STR*.\nTEST(SuccessfulAssertionTest, ASSERT_STR) {\n  ASSERT_STREQ(\"\", \"\");\n  EXPECT_EQ(0, GetUnitTestImpl()->current_test_result()->total_part_count());\n}\n\n}  // namespace testing\n\nnamespace {\n\n// Tests the message streaming variation of assertions.\n\nTEST(AssertionWithMessageTest, EXPECT) {\n  EXPECT_EQ(1, 1) << \"This should succeed.\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_NE(1, 1) << \"Expected failure #1.\",\n                          \"Expected failure #1\");\n  EXPECT_LE(1, 2) << \"This should succeed.\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_LT(1, 0) << \"Expected failure #2.\",\n                          \"Expected failure #2.\");\n  EXPECT_GE(1, 0) << \"This should succeed.\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_GT(1, 2) << \"Expected failure #3.\",\n                          \"Expected failure #3.\");\n\n  EXPECT_STREQ(\"1\", \"1\") << \"This should succeed.\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_STRNE(\"1\", \"1\") << \"Expected failure #4.\",\n                          \"Expected failure #4.\");\n  EXPECT_STRCASEEQ(\"a\", \"A\") << \"This should succeed.\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_STRCASENE(\"a\", \"A\") << \"Expected failure #5.\",\n                          \"Expected failure #5.\");\n\n  EXPECT_FLOAT_EQ(1, 1) << \"This should succeed.\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_DOUBLE_EQ(1, 1.2) << \"Expected failure #6.\",\n                          \"Expected failure #6.\");\n  EXPECT_NEAR(1, 1.1, 0.2) << \"This should succeed.\";\n}\n\nTEST(AssertionWithMessageTest, ASSERT) {\n  ASSERT_EQ(1, 1) << \"This should succeed.\";\n  ASSERT_NE(1, 2) << \"This should succeed.\";\n  ASSERT_LE(1, 2) << \"This should succeed.\";\n  ASSERT_LT(1, 2) << \"This should succeed.\";\n  ASSERT_GE(1, 0) << \"This should succeed.\";\n  EXPECT_FATAL_FAILURE(ASSERT_GT(1, 2) << \"Expected failure.\",\n                       \"Expected failure.\");\n}\n\nTEST(AssertionWithMessageTest, ASSERT_STR) {\n  ASSERT_STREQ(\"1\", \"1\") << \"This should succeed.\";\n  ASSERT_STRNE(\"1\", \"2\") << \"This should succeed.\";\n  ASSERT_STRCASEEQ(\"a\", \"A\") << \"This should succeed.\";\n  EXPECT_FATAL_FAILURE(ASSERT_STRCASENE(\"a\", \"A\") << \"Expected failure.\",\n                       \"Expected failure.\");\n}\n\nTEST(AssertionWithMessageTest, ASSERT_FLOATING) {\n  ASSERT_FLOAT_EQ(1, 1) << \"This should succeed.\";\n  ASSERT_DOUBLE_EQ(1, 1) << \"This should succeed.\";\n  EXPECT_FATAL_FAILURE(ASSERT_NEAR(1,1.2, 0.1) << \"Expect failure.\",  // NOLINT\n                       \"Expect failure.\");\n  // To work around a bug in gcc 2.95.0, there is intentionally no\n  // space after the first comma in the previous statement.\n}\n\n// Tests using ASSERT_FALSE with a streamed message.\nTEST(AssertionWithMessageTest, ASSERT_FALSE) {\n  ASSERT_FALSE(false) << \"This shouldn't fail.\";\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_FALSE(true) << \"Expected failure: \" << 2 << \" > \" << 1\n                       << \" evaluates to \" << true;\n  }, \"Expected failure\");\n}\n\n// Tests using FAIL with a streamed message.\nTEST(AssertionWithMessageTest, FAIL) {\n  EXPECT_FATAL_FAILURE(FAIL() << 0,\n                       \"0\");\n}\n\n// Tests using SUCCEED with a streamed message.\nTEST(AssertionWithMessageTest, SUCCEED) {\n  SUCCEED() << \"Success == \" << 1;\n}\n\n// Tests using ASSERT_TRUE with a streamed message.\nTEST(AssertionWithMessageTest, ASSERT_TRUE) {\n  ASSERT_TRUE(true) << \"This should succeed.\";\n  ASSERT_TRUE(true) << true;\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_TRUE(false) << static_cast<const char *>(NULL)\n                       << static_cast<char *>(NULL);\n  }, \"(null)(null)\");\n}\n\n#if GTEST_OS_WINDOWS\n// Tests using wide strings in assertion messages.\nTEST(AssertionWithMessageTest, WideStringMessage) {\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_TRUE(false) << L\"This failure is expected.\\x8119\";\n  }, \"This failure is expected.\");\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_EQ(1, 2) << \"This failure is \"\n                    << L\"expected too.\\x8120\";\n  }, \"This failure is expected too.\");\n}\n#endif  // GTEST_OS_WINDOWS\n\n// Tests EXPECT_TRUE.\nTEST(ExpectTest, EXPECT_TRUE) {\n  EXPECT_TRUE(true) << \"Intentional success\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(false) << \"Intentional failure #1.\",\n                          \"Intentional failure #1.\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(false) << \"Intentional failure #2.\",\n                          \"Intentional failure #2.\");\n  EXPECT_TRUE(2 > 1);  // NOLINT\n  EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(2 < 1),\n                          \"Value of: 2 < 1\\n\"\n                          \"  Actual: false\\n\"\n                          \"Expected: true\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(2 > 3),\n                          \"2 > 3\");\n}\n\n// Tests EXPECT_TRUE(predicate) for predicates returning AssertionResult.\nTEST(ExpectTest, ExpectTrueWithAssertionResult) {\n  EXPECT_TRUE(ResultIsEven(2));\n  EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(ResultIsEven(3)),\n                          \"Value of: ResultIsEven(3)\\n\"\n                          \"  Actual: false (3 is odd)\\n\"\n                          \"Expected: true\");\n  EXPECT_TRUE(ResultIsEvenNoExplanation(2));\n  EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(ResultIsEvenNoExplanation(3)),\n                          \"Value of: ResultIsEvenNoExplanation(3)\\n\"\n                          \"  Actual: false (3 is odd)\\n\"\n                          \"Expected: true\");\n}\n\n// Tests EXPECT_FALSE with a streamed message.\nTEST(ExpectTest, EXPECT_FALSE) {\n  EXPECT_FALSE(2 < 1);  // NOLINT\n  EXPECT_FALSE(false) << \"Intentional success\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_FALSE(true) << \"Intentional failure #1.\",\n                          \"Intentional failure #1.\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_FALSE(true) << \"Intentional failure #2.\",\n                          \"Intentional failure #2.\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_FALSE(2 > 1),\n                          \"Value of: 2 > 1\\n\"\n                          \"  Actual: true\\n\"\n                          \"Expected: false\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_FALSE(2 < 3),\n                          \"2 < 3\");\n}\n\n// Tests EXPECT_FALSE(predicate) for predicates returning AssertionResult.\nTEST(ExpectTest, ExpectFalseWithAssertionResult) {\n  EXPECT_FALSE(ResultIsEven(3));\n  EXPECT_NONFATAL_FAILURE(EXPECT_FALSE(ResultIsEven(2)),\n                          \"Value of: ResultIsEven(2)\\n\"\n                          \"  Actual: true (2 is even)\\n\"\n                          \"Expected: false\");\n  EXPECT_FALSE(ResultIsEvenNoExplanation(3));\n  EXPECT_NONFATAL_FAILURE(EXPECT_FALSE(ResultIsEvenNoExplanation(2)),\n                          \"Value of: ResultIsEvenNoExplanation(2)\\n\"\n                          \"  Actual: true\\n\"\n                          \"Expected: false\");\n}\n\n#ifdef __BORLANDC__\n// Restores warnings after previous \"#pragma option push\" supressed them\n# pragma option pop\n#endif\n\n// Tests EXPECT_EQ.\nTEST(ExpectTest, EXPECT_EQ) {\n  EXPECT_EQ(5, 2 + 3);\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(5, 2*3),\n                          \"Value of: 2*3\\n\"\n                          \"  Actual: 6\\n\"\n                          \"Expected: 5\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(5, 2 - 3),\n                          \"2 - 3\");\n}\n\n// Tests using EXPECT_EQ on double values.  The purpose is to make\n// sure that the specialization we did for integer and anonymous enums\n// isn't used for double arguments.\nTEST(ExpectTest, EXPECT_EQ_Double) {\n  // A success.\n  EXPECT_EQ(5.6, 5.6);\n\n  // A failure.\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(5.1, 5.2),\n                          \"5.1\");\n}\n\n#if GTEST_CAN_COMPARE_NULL\n// Tests EXPECT_EQ(NULL, pointer).\nTEST(ExpectTest, EXPECT_EQ_NULL) {\n  // A success.\n  const char* p = NULL;\n  // Some older GCC versions may issue a spurious warning in this or the next\n  // assertion statement. This warning should not be suppressed with\n  // static_cast since the test verifies the ability to use bare NULL as the\n  // expected parameter to the macro.\n  EXPECT_EQ(NULL, p);\n\n  // A failure.\n  int n = 0;\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(NULL, &n),\n                          \"Value of: &n\\n\");\n}\n#endif  // GTEST_CAN_COMPARE_NULL\n\n// Tests EXPECT_EQ(0, non_pointer).  Since the literal 0 can be\n// treated as a null pointer by the compiler, we need to make sure\n// that EXPECT_EQ(0, non_pointer) isn't interpreted by Google Test as\n// EXPECT_EQ(static_cast<void*>(NULL), non_pointer).\nTEST(ExpectTest, EXPECT_EQ_0) {\n  int n = 0;\n\n  // A success.\n  EXPECT_EQ(0, n);\n\n  // A failure.\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(0, 5.6),\n                          \"Expected: 0\");\n}\n\n// Tests EXPECT_NE.\nTEST(ExpectTest, EXPECT_NE) {\n  EXPECT_NE(6, 7);\n\n  EXPECT_NONFATAL_FAILURE(EXPECT_NE('a', 'a'),\n                          \"Expected: ('a') != ('a'), \"\n                          \"actual: 'a' (97, 0x61) vs 'a' (97, 0x61)\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_NE(2, 2),\n                          \"2\");\n  char* const p0 = NULL;\n  EXPECT_NONFATAL_FAILURE(EXPECT_NE(p0, p0),\n                          \"p0\");\n  // Only way to get the Nokia compiler to compile the cast\n  // is to have a separate void* variable first. Putting\n  // the two casts on the same line doesn't work, neither does\n  // a direct C-style to char*.\n  void* pv1 = (void*)0x1234;  // NOLINT\n  char* const p1 = reinterpret_cast<char*>(pv1);\n  EXPECT_NONFATAL_FAILURE(EXPECT_NE(p1, p1),\n                          \"p1\");\n}\n\n// Tests EXPECT_LE.\nTEST(ExpectTest, EXPECT_LE) {\n  EXPECT_LE(2, 3);\n  EXPECT_LE(2, 2);\n  EXPECT_NONFATAL_FAILURE(EXPECT_LE(2, 0),\n                          \"Expected: (2) <= (0), actual: 2 vs 0\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_LE(1.1, 0.9),\n                          \"(1.1) <= (0.9)\");\n}\n\n// Tests EXPECT_LT.\nTEST(ExpectTest, EXPECT_LT) {\n  EXPECT_LT(2, 3);\n  EXPECT_NONFATAL_FAILURE(EXPECT_LT(2, 2),\n                          \"Expected: (2) < (2), actual: 2 vs 2\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_LT(2, 1),\n                          \"(2) < (1)\");\n}\n\n// Tests EXPECT_GE.\nTEST(ExpectTest, EXPECT_GE) {\n  EXPECT_GE(2, 1);\n  EXPECT_GE(2, 2);\n  EXPECT_NONFATAL_FAILURE(EXPECT_GE(2, 3),\n                          \"Expected: (2) >= (3), actual: 2 vs 3\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_GE(0.9, 1.1),\n                          \"(0.9) >= (1.1)\");\n}\n\n// Tests EXPECT_GT.\nTEST(ExpectTest, EXPECT_GT) {\n  EXPECT_GT(2, 1);\n  EXPECT_NONFATAL_FAILURE(EXPECT_GT(2, 2),\n                          \"Expected: (2) > (2), actual: 2 vs 2\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_GT(2, 3),\n                          \"(2) > (3)\");\n}\n\n#if GTEST_HAS_EXCEPTIONS\n\n// Tests EXPECT_THROW.\nTEST(ExpectTest, EXPECT_THROW) {\n  EXPECT_THROW(ThrowAnInteger(), int);\n  EXPECT_NONFATAL_FAILURE(EXPECT_THROW(ThrowAnInteger(), bool),\n                          \"Expected: ThrowAnInteger() throws an exception of \"\n                          \"type bool.\\n  Actual: it throws a different type.\");\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_THROW(ThrowNothing(), bool),\n      \"Expected: ThrowNothing() throws an exception of type bool.\\n\"\n      \"  Actual: it throws nothing.\");\n}\n\n// Tests EXPECT_NO_THROW.\nTEST(ExpectTest, EXPECT_NO_THROW) {\n  EXPECT_NO_THROW(ThrowNothing());\n  EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW(ThrowAnInteger()),\n                          \"Expected: ThrowAnInteger() doesn't throw an \"\n                          \"exception.\\n  Actual: it throws.\");\n}\n\n// Tests EXPECT_ANY_THROW.\nTEST(ExpectTest, EXPECT_ANY_THROW) {\n  EXPECT_ANY_THROW(ThrowAnInteger());\n  EXPECT_NONFATAL_FAILURE(\n      EXPECT_ANY_THROW(ThrowNothing()),\n      \"Expected: ThrowNothing() throws an exception.\\n\"\n      \"  Actual: it doesn't.\");\n}\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n// Make sure we deal with the precedence of <<.\nTEST(ExpectTest, ExpectPrecedence) {\n  EXPECT_EQ(1 < 2, true);\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(true, true && false),\n                          \"Value of: true && false\");\n}\n\n\n// Tests the StreamableToString() function.\n\n// Tests using StreamableToString() on a scalar.\nTEST(StreamableToStringTest, Scalar) {\n  EXPECT_STREQ(\"5\", StreamableToString(5).c_str());\n}\n\n// Tests using StreamableToString() on a non-char pointer.\nTEST(StreamableToStringTest, Pointer) {\n  int n = 0;\n  int* p = &n;\n  EXPECT_STRNE(\"(null)\", StreamableToString(p).c_str());\n}\n\n// Tests using StreamableToString() on a NULL non-char pointer.\nTEST(StreamableToStringTest, NullPointer) {\n  int* p = NULL;\n  EXPECT_STREQ(\"(null)\", StreamableToString(p).c_str());\n}\n\n// Tests using StreamableToString() on a C string.\nTEST(StreamableToStringTest, CString) {\n  EXPECT_STREQ(\"Foo\", StreamableToString(\"Foo\").c_str());\n}\n\n// Tests using StreamableToString() on a NULL C string.\nTEST(StreamableToStringTest, NullCString) {\n  char* p = NULL;\n  EXPECT_STREQ(\"(null)\", StreamableToString(p).c_str());\n}\n\n// Tests using streamable values as assertion messages.\n\n// Tests using std::string as an assertion message.\nTEST(StreamableTest, string) {\n  static const std::string str(\n      \"This failure message is a std::string, and is expected.\");\n  EXPECT_FATAL_FAILURE(FAIL() << str,\n                       str.c_str());\n}\n\n// Tests that we can output strings containing embedded NULs.\n// Limited to Linux because we can only do this with std::string's.\nTEST(StreamableTest, stringWithEmbeddedNUL) {\n  static const char char_array_with_nul[] =\n      \"Here's a NUL\\0 and some more string\";\n  static const std::string string_with_nul(char_array_with_nul,\n                                           sizeof(char_array_with_nul)\n                                           - 1);  // drops the trailing NUL\n  EXPECT_FATAL_FAILURE(FAIL() << string_with_nul,\n                       \"Here's a NUL\\\\0 and some more string\");\n}\n\n// Tests that we can output a NUL char.\nTEST(StreamableTest, NULChar) {\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    FAIL() << \"A NUL\" << '\\0' << \" and some more string\";\n  }, \"A NUL\\\\0 and some more string\");\n}\n\n// Tests using int as an assertion message.\nTEST(StreamableTest, int) {\n  EXPECT_FATAL_FAILURE(FAIL() << 900913,\n                       \"900913\");\n}\n\n// Tests using NULL char pointer as an assertion message.\n//\n// In MSVC, streaming a NULL char * causes access violation.  Google Test\n// implemented a workaround (substituting \"(null)\" for NULL).  This\n// tests whether the workaround works.\nTEST(StreamableTest, NullCharPtr) {\n  EXPECT_FATAL_FAILURE(FAIL() << static_cast<const char*>(NULL),\n                       \"(null)\");\n}\n\n// Tests that basic IO manipulators (endl, ends, and flush) can be\n// streamed to testing::Message.\nTEST(StreamableTest, BasicIoManip) {\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    FAIL() << \"Line 1.\" << std::endl\n           << \"A NUL char \" << std::ends << std::flush << \" in line 2.\";\n  }, \"Line 1.\\nA NUL char \\\\0 in line 2.\");\n}\n\n// Tests the macros that haven't been covered so far.\n\nvoid AddFailureHelper(bool* aborted) {\n  *aborted = true;\n  ADD_FAILURE() << \"Intentional failure.\";\n  *aborted = false;\n}\n\n// Tests ADD_FAILURE.\nTEST(MacroTest, ADD_FAILURE) {\n  bool aborted = true;\n  EXPECT_NONFATAL_FAILURE(AddFailureHelper(&aborted),\n                          \"Intentional failure.\");\n  EXPECT_FALSE(aborted);\n}\n\n// Tests ADD_FAILURE_AT.\nTEST(MacroTest, ADD_FAILURE_AT) {\n  // Verifies that ADD_FAILURE_AT does generate a nonfatal failure and\n  // the failure message contains the user-streamed part.\n  EXPECT_NONFATAL_FAILURE(ADD_FAILURE_AT(\"foo.cc\", 42) << \"Wrong!\", \"Wrong!\");\n\n  // Verifies that the user-streamed part is optional.\n  EXPECT_NONFATAL_FAILURE(ADD_FAILURE_AT(\"foo.cc\", 42), \"Failed\");\n\n  // Unfortunately, we cannot verify that the failure message contains\n  // the right file path and line number the same way, as\n  // EXPECT_NONFATAL_FAILURE() doesn't get to see the file path and\n  // line number.  Instead, we do that in gtest_output_test_.cc.\n}\n\n// Tests FAIL.\nTEST(MacroTest, FAIL) {\n  EXPECT_FATAL_FAILURE(FAIL(),\n                       \"Failed\");\n  EXPECT_FATAL_FAILURE(FAIL() << \"Intentional failure.\",\n                       \"Intentional failure.\");\n}\n\n// Tests SUCCEED\nTEST(MacroTest, SUCCEED) {\n  SUCCEED();\n  SUCCEED() << \"Explicit success.\";\n}\n\n// Tests for EXPECT_EQ() and ASSERT_EQ().\n//\n// These tests fail *intentionally*, s.t. the failure messages can be\n// generated and tested.\n//\n// We have different tests for different argument types.\n\n// Tests using bool values in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, Bool) {\n  EXPECT_EQ(true,  true);\n  EXPECT_FATAL_FAILURE({\n      bool false_value = false;\n      ASSERT_EQ(false_value, true);\n    }, \"Value of: true\");\n}\n\n// Tests using int values in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, Int) {\n  ASSERT_EQ(32, 32);\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(32, 33),\n                          \"33\");\n}\n\n// Tests using time_t values in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, Time_T) {\n  EXPECT_EQ(static_cast<time_t>(0),\n            static_cast<time_t>(0));\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(static_cast<time_t>(0),\n                                 static_cast<time_t>(1234)),\n                       \"1234\");\n}\n\n// Tests using char values in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, Char) {\n  ASSERT_EQ('z', 'z');\n  const char ch = 'b';\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ('\\0', ch),\n                          \"ch\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ('a', ch),\n                          \"ch\");\n}\n\n// Tests using wchar_t values in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, WideChar) {\n  EXPECT_EQ(L'b', L'b');\n\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(L'\\0', L'x'),\n                          \"Value of: L'x'\\n\"\n                          \"  Actual: L'x' (120, 0x78)\\n\"\n                          \"Expected: L'\\0'\\n\"\n                          \"Which is: L'\\0' (0, 0x0)\");\n\n  static wchar_t wchar;\n  wchar = L'b';\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(L'a', wchar),\n                          \"wchar\");\n  wchar = 0x8119;\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(static_cast<wchar_t>(0x8120), wchar),\n                       \"Value of: wchar\");\n}\n\n// Tests using ::std::string values in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, StdString) {\n  // Compares a const char* to an std::string that has identical\n  // content.\n  ASSERT_EQ(\"Test\", ::std::string(\"Test\"));\n\n  // Compares two identical std::strings.\n  static const ::std::string str1(\"A * in the middle\");\n  static const ::std::string str2(str1);\n  EXPECT_EQ(str1, str2);\n\n  // Compares a const char* to an std::string that has different\n  // content\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(\"Test\", ::std::string(\"test\")),\n                          \"\\\"test\\\"\");\n\n  // Compares an std::string to a char* that has different content.\n  char* const p1 = const_cast<char*>(\"foo\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(::std::string(\"bar\"), p1),\n                          \"p1\");\n\n  // Compares two std::strings that have different contents, one of\n  // which having a NUL character in the middle.  This should fail.\n  static ::std::string str3(str1);\n  str3.at(2) = '\\0';\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(str1, str3),\n                       \"Value of: str3\\n\"\n                       \"  Actual: \\\"A \\\\0 in the middle\\\"\");\n}\n\n#if GTEST_HAS_STD_WSTRING\n\n// Tests using ::std::wstring values in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, StdWideString) {\n  // Compares two identical std::wstrings.\n  const ::std::wstring wstr1(L\"A * in the middle\");\n  const ::std::wstring wstr2(wstr1);\n  ASSERT_EQ(wstr1, wstr2);\n\n  // Compares an std::wstring to a const wchar_t* that has identical\n  // content.\n  const wchar_t kTestX8119[] = { 'T', 'e', 's', 't', 0x8119, '\\0' };\n  EXPECT_EQ(::std::wstring(kTestX8119), kTestX8119);\n\n  // Compares an std::wstring to a const wchar_t* that has different\n  // content.\n  const wchar_t kTestX8120[] = { 'T', 'e', 's', 't', 0x8120, '\\0' };\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_EQ(::std::wstring(kTestX8119), kTestX8120);\n  }, \"kTestX8120\");\n\n  // Compares two std::wstrings that have different contents, one of\n  // which having a NUL character in the middle.\n  ::std::wstring wstr3(wstr1);\n  wstr3.at(2) = L'\\0';\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(wstr1, wstr3),\n                          \"wstr3\");\n\n  // Compares a wchar_t* to an std::wstring that has different\n  // content.\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_EQ(const_cast<wchar_t*>(L\"foo\"), ::std::wstring(L\"bar\"));\n  }, \"\");\n}\n\n#endif  // GTEST_HAS_STD_WSTRING\n\n#if GTEST_HAS_GLOBAL_STRING\n// Tests using ::string values in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, GlobalString) {\n  // Compares a const char* to a ::string that has identical content.\n  EXPECT_EQ(\"Test\", ::string(\"Test\"));\n\n  // Compares two identical ::strings.\n  const ::string str1(\"A * in the middle\");\n  const ::string str2(str1);\n  ASSERT_EQ(str1, str2);\n\n  // Compares a ::string to a const char* that has different content.\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(::string(\"Test\"), \"test\"),\n                          \"test\");\n\n  // Compares two ::strings that have different contents, one of which\n  // having a NUL character in the middle.\n  ::string str3(str1);\n  str3.at(2) = '\\0';\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(str1, str3),\n                          \"str3\");\n\n  // Compares a ::string to a char* that has different content.\n  EXPECT_FATAL_FAILURE({  // NOLINT\n    ASSERT_EQ(::string(\"bar\"), const_cast<char*>(\"foo\"));\n  }, \"\");\n}\n\n#endif  // GTEST_HAS_GLOBAL_STRING\n\n#if GTEST_HAS_GLOBAL_WSTRING\n\n// Tests using ::wstring values in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, GlobalWideString) {\n  // Compares two identical ::wstrings.\n  static const ::wstring wstr1(L\"A * in the middle\");\n  static const ::wstring wstr2(wstr1);\n  EXPECT_EQ(wstr1, wstr2);\n\n  // Compares a const wchar_t* to a ::wstring that has identical content.\n  const wchar_t kTestX8119[] = { 'T', 'e', 's', 't', 0x8119, '\\0' };\n  ASSERT_EQ(kTestX8119, ::wstring(kTestX8119));\n\n  // Compares a const wchar_t* to a ::wstring that has different\n  // content.\n  const wchar_t kTestX8120[] = { 'T', 'e', 's', 't', 0x8120, '\\0' };\n  EXPECT_NONFATAL_FAILURE({  // NOLINT\n    EXPECT_EQ(kTestX8120, ::wstring(kTestX8119));\n  }, \"Test\\\\x8119\");\n\n  // Compares a wchar_t* to a ::wstring that has different content.\n  wchar_t* const p1 = const_cast<wchar_t*>(L\"foo\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, ::wstring(L\"bar\")),\n                          \"bar\");\n\n  // Compares two ::wstrings that have different contents, one of which\n  // having a NUL character in the middle.\n  static ::wstring wstr3;\n  wstr3 = wstr1;\n  wstr3.at(2) = L'\\0';\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(wstr1, wstr3),\n                       \"wstr3\");\n}\n\n#endif  // GTEST_HAS_GLOBAL_WSTRING\n\n// Tests using char pointers in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, CharPointer) {\n  char* const p0 = NULL;\n  // Only way to get the Nokia compiler to compile the cast\n  // is to have a separate void* variable first. Putting\n  // the two casts on the same line doesn't work, neither does\n  // a direct C-style to char*.\n  void* pv1 = (void*)0x1234;  // NOLINT\n  void* pv2 = (void*)0xABC0;  // NOLINT\n  char* const p1 = reinterpret_cast<char*>(pv1);\n  char* const p2 = reinterpret_cast<char*>(pv2);\n  ASSERT_EQ(p1, p1);\n\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p0, p2),\n                          \"Value of: p2\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, p2),\n                          \"p2\");\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(reinterpret_cast<char*>(0x1234),\n                                 reinterpret_cast<char*>(0xABC0)),\n                       \"ABC0\");\n}\n\n// Tests using wchar_t pointers in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, WideCharPointer) {\n  wchar_t* const p0 = NULL;\n  // Only way to get the Nokia compiler to compile the cast\n  // is to have a separate void* variable first. Putting\n  // the two casts on the same line doesn't work, neither does\n  // a direct C-style to char*.\n  void* pv1 = (void*)0x1234;  // NOLINT\n  void* pv2 = (void*)0xABC0;  // NOLINT\n  wchar_t* const p1 = reinterpret_cast<wchar_t*>(pv1);\n  wchar_t* const p2 = reinterpret_cast<wchar_t*>(pv2);\n  EXPECT_EQ(p0, p0);\n\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p0, p2),\n                          \"Value of: p2\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p1, p2),\n                          \"p2\");\n  void* pv3 = (void*)0x1234;  // NOLINT\n  void* pv4 = (void*)0xABC0;  // NOLINT\n  const wchar_t* p3 = reinterpret_cast<const wchar_t*>(pv3);\n  const wchar_t* p4 = reinterpret_cast<const wchar_t*>(pv4);\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(p3, p4),\n                          \"p4\");\n}\n\n// Tests using other types of pointers in {EXPECT|ASSERT}_EQ.\nTEST(EqAssertionTest, OtherPointer) {\n  ASSERT_EQ(static_cast<const int*>(NULL),\n            static_cast<const int*>(NULL));\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(static_cast<const int*>(NULL),\n                                 reinterpret_cast<const int*>(0x1234)),\n                       \"0x1234\");\n}\n\n// A class that supports binary comparison operators but not streaming.\nclass UnprintableChar {\n public:\n  explicit UnprintableChar(char ch) : char_(ch) {}\n\n  bool operator==(const UnprintableChar& rhs) const {\n    return char_ == rhs.char_;\n  }\n  bool operator!=(const UnprintableChar& rhs) const {\n    return char_ != rhs.char_;\n  }\n  bool operator<(const UnprintableChar& rhs) const {\n    return char_ < rhs.char_;\n  }\n  bool operator<=(const UnprintableChar& rhs) const {\n    return char_ <= rhs.char_;\n  }\n  bool operator>(const UnprintableChar& rhs) const {\n    return char_ > rhs.char_;\n  }\n  bool operator>=(const UnprintableChar& rhs) const {\n    return char_ >= rhs.char_;\n  }\n\n private:\n  char char_;\n};\n\n// Tests that ASSERT_EQ() and friends don't require the arguments to\n// be printable.\nTEST(ComparisonAssertionTest, AcceptsUnprintableArgs) {\n  const UnprintableChar x('x'), y('y');\n  ASSERT_EQ(x, x);\n  EXPECT_NE(x, y);\n  ASSERT_LT(x, y);\n  EXPECT_LE(x, y);\n  ASSERT_GT(y, x);\n  EXPECT_GE(x, x);\n\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(x, y), \"1-byte object <78>\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(x, y), \"1-byte object <79>\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_LT(y, y), \"1-byte object <79>\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_GT(x, y), \"1-byte object <78>\");\n  EXPECT_NONFATAL_FAILURE(EXPECT_GT(x, y), \"1-byte object <79>\");\n\n  // Code tested by EXPECT_FATAL_FAILURE cannot reference local\n  // variables, so we have to write UnprintableChar('x') instead of x.\n#ifndef __BORLANDC__\n  // ICE's in C++Builder.\n  EXPECT_FATAL_FAILURE(ASSERT_NE(UnprintableChar('x'), UnprintableChar('x')),\n                       \"1-byte object <78>\");\n  EXPECT_FATAL_FAILURE(ASSERT_LE(UnprintableChar('y'), UnprintableChar('x')),\n                       \"1-byte object <78>\");\n#endif\n  EXPECT_FATAL_FAILURE(ASSERT_LE(UnprintableChar('y'), UnprintableChar('x')),\n                       \"1-byte object <79>\");\n  EXPECT_FATAL_FAILURE(ASSERT_GE(UnprintableChar('x'), UnprintableChar('y')),\n                       \"1-byte object <78>\");\n  EXPECT_FATAL_FAILURE(ASSERT_GE(UnprintableChar('x'), UnprintableChar('y')),\n                       \"1-byte object <79>\");\n}\n\n// Tests the FRIEND_TEST macro.\n\n// This class has a private member we want to test.  We will test it\n// both in a TEST and in a TEST_F.\nclass Foo {\n public:\n  Foo() {}\n\n private:\n  int Bar() const { return 1; }\n\n  // Declares the friend tests that can access the private member\n  // Bar().\n  FRIEND_TEST(FRIEND_TEST_Test, TEST);\n  FRIEND_TEST(FRIEND_TEST_Test2, TEST_F);\n};\n\n// Tests that the FRIEND_TEST declaration allows a TEST to access a\n// class's private members.  This should compile.\nTEST(FRIEND_TEST_Test, TEST) {\n  ASSERT_EQ(1, Foo().Bar());\n}\n\n// The fixture needed to test using FRIEND_TEST with TEST_F.\nclass FRIEND_TEST_Test2 : public Test {\n protected:\n  Foo foo;\n};\n\n// Tests that the FRIEND_TEST declaration allows a TEST_F to access a\n// class's private members.  This should compile.\nTEST_F(FRIEND_TEST_Test2, TEST_F) {\n  ASSERT_EQ(1, foo.Bar());\n}\n\n// Tests the life cycle of Test objects.\n\n// The test fixture for testing the life cycle of Test objects.\n//\n// This class counts the number of live test objects that uses this\n// fixture.\nclass TestLifeCycleTest : public Test {\n protected:\n  // Constructor.  Increments the number of test objects that uses\n  // this fixture.\n  TestLifeCycleTest() { count_++; }\n\n  // Destructor.  Decrements the number of test objects that uses this\n  // fixture.\n  ~TestLifeCycleTest() { count_--; }\n\n  // Returns the number of live test objects that uses this fixture.\n  int count() const { return count_; }\n\n private:\n  static int count_;\n};\n\nint TestLifeCycleTest::count_ = 0;\n\n// Tests the life cycle of test objects.\nTEST_F(TestLifeCycleTest, Test1) {\n  // There should be only one test object in this test case that's\n  // currently alive.\n  ASSERT_EQ(1, count());\n}\n\n// Tests the life cycle of test objects.\nTEST_F(TestLifeCycleTest, Test2) {\n  // After Test1 is done and Test2 is started, there should still be\n  // only one live test object, as the object for Test1 should've been\n  // deleted.\n  ASSERT_EQ(1, count());\n}\n\n}  // namespace\n\n// Tests that the copy constructor works when it is NOT optimized away by\n// the compiler.\nTEST(AssertionResultTest, CopyConstructorWorksWhenNotOptimied) {\n  // Checks that the copy constructor doesn't try to dereference NULL pointers\n  // in the source object.\n  AssertionResult r1 = AssertionSuccess();\n  AssertionResult r2 = r1;\n  // The following line is added to prevent the compiler from optimizing\n  // away the constructor call.\n  r1 << \"abc\";\n\n  AssertionResult r3 = r1;\n  EXPECT_EQ(static_cast<bool>(r3), static_cast<bool>(r1));\n  EXPECT_STREQ(\"abc\", r1.message());\n}\n\n// Tests that AssertionSuccess and AssertionFailure construct\n// AssertionResult objects as expected.\nTEST(AssertionResultTest, ConstructionWorks) {\n  AssertionResult r1 = AssertionSuccess();\n  EXPECT_TRUE(r1);\n  EXPECT_STREQ(\"\", r1.message());\n\n  AssertionResult r2 = AssertionSuccess() << \"abc\";\n  EXPECT_TRUE(r2);\n  EXPECT_STREQ(\"abc\", r2.message());\n\n  AssertionResult r3 = AssertionFailure();\n  EXPECT_FALSE(r3);\n  EXPECT_STREQ(\"\", r3.message());\n\n  AssertionResult r4 = AssertionFailure() << \"def\";\n  EXPECT_FALSE(r4);\n  EXPECT_STREQ(\"def\", r4.message());\n\n  AssertionResult r5 = AssertionFailure(Message() << \"ghi\");\n  EXPECT_FALSE(r5);\n  EXPECT_STREQ(\"ghi\", r5.message());\n}\n\n// Tests that the negation flips the predicate result but keeps the message.\nTEST(AssertionResultTest, NegationWorks) {\n  AssertionResult r1 = AssertionSuccess() << \"abc\";\n  EXPECT_FALSE(!r1);\n  EXPECT_STREQ(\"abc\", (!r1).message());\n\n  AssertionResult r2 = AssertionFailure() << \"def\";\n  EXPECT_TRUE(!r2);\n  EXPECT_STREQ(\"def\", (!r2).message());\n}\n\nTEST(AssertionResultTest, StreamingWorks) {\n  AssertionResult r = AssertionSuccess();\n  r << \"abc\" << 'd' << 0 << true;\n  EXPECT_STREQ(\"abcd0true\", r.message());\n}\n\nTEST(AssertionResultTest, CanStreamOstreamManipulators) {\n  AssertionResult r = AssertionSuccess();\n  r << \"Data\" << std::endl << std::flush << std::ends << \"Will be visible\";\n  EXPECT_STREQ(\"Data\\n\\\\0Will be visible\", r.message());\n}\n\n// Tests streaming a user type whose definition and operator << are\n// both in the global namespace.\nclass Base {\n public:\n  explicit Base(int an_x) : x_(an_x) {}\n  int x() const { return x_; }\n private:\n  int x_;\n};\nstd::ostream& operator<<(std::ostream& os,\n                         const Base& val) {\n  return os << val.x();\n}\nstd::ostream& operator<<(std::ostream& os,\n                         const Base* pointer) {\n  return os << \"(\" << pointer->x() << \")\";\n}\n\nTEST(MessageTest, CanStreamUserTypeInGlobalNameSpace) {\n  Message msg;\n  Base a(1);\n\n  msg << a << &a;  // Uses ::operator<<.\n  EXPECT_STREQ(\"1(1)\", msg.GetString().c_str());\n}\n\n// Tests streaming a user type whose definition and operator<< are\n// both in an unnamed namespace.\nnamespace {\nclass MyTypeInUnnamedNameSpace : public Base {\n public:\n  explicit MyTypeInUnnamedNameSpace(int an_x): Base(an_x) {}\n};\nstd::ostream& operator<<(std::ostream& os,\n                         const MyTypeInUnnamedNameSpace& val) {\n  return os << val.x();\n}\nstd::ostream& operator<<(std::ostream& os,\n                         const MyTypeInUnnamedNameSpace* pointer) {\n  return os << \"(\" << pointer->x() << \")\";\n}\n}  // namespace\n\nTEST(MessageTest, CanStreamUserTypeInUnnamedNameSpace) {\n  Message msg;\n  MyTypeInUnnamedNameSpace a(1);\n\n  msg << a << &a;  // Uses <unnamed_namespace>::operator<<.\n  EXPECT_STREQ(\"1(1)\", msg.GetString().c_str());\n}\n\n// Tests streaming a user type whose definition and operator<< are\n// both in a user namespace.\nnamespace namespace1 {\nclass MyTypeInNameSpace1 : public Base {\n public:\n  explicit MyTypeInNameSpace1(int an_x): Base(an_x) {}\n};\nstd::ostream& operator<<(std::ostream& os,\n                         const MyTypeInNameSpace1& val) {\n  return os << val.x();\n}\nstd::ostream& operator<<(std::ostream& os,\n                         const MyTypeInNameSpace1* pointer) {\n  return os << \"(\" << pointer->x() << \")\";\n}\n}  // namespace namespace1\n\nTEST(MessageTest, CanStreamUserTypeInUserNameSpace) {\n  Message msg;\n  namespace1::MyTypeInNameSpace1 a(1);\n\n  msg << a << &a;  // Uses namespace1::operator<<.\n  EXPECT_STREQ(\"1(1)\", msg.GetString().c_str());\n}\n\n// Tests streaming a user type whose definition is in a user namespace\n// but whose operator<< is in the global namespace.\nnamespace namespace2 {\nclass MyTypeInNameSpace2 : public ::Base {\n public:\n  explicit MyTypeInNameSpace2(int an_x): Base(an_x) {}\n};\n}  // namespace namespace2\nstd::ostream& operator<<(std::ostream& os,\n                         const namespace2::MyTypeInNameSpace2& val) {\n  return os << val.x();\n}\nstd::ostream& operator<<(std::ostream& os,\n                         const namespace2::MyTypeInNameSpace2* pointer) {\n  return os << \"(\" << pointer->x() << \")\";\n}\n\nTEST(MessageTest, CanStreamUserTypeInUserNameSpaceWithStreamOperatorInGlobal) {\n  Message msg;\n  namespace2::MyTypeInNameSpace2 a(1);\n\n  msg << a << &a;  // Uses ::operator<<.\n  EXPECT_STREQ(\"1(1)\", msg.GetString().c_str());\n}\n\n// Tests streaming NULL pointers to testing::Message.\nTEST(MessageTest, NullPointers) {\n  Message msg;\n  char* const p1 = NULL;\n  unsigned char* const p2 = NULL;\n  int* p3 = NULL;\n  double* p4 = NULL;\n  bool* p5 = NULL;\n  Message* p6 = NULL;\n\n  msg << p1 << p2 << p3 << p4 << p5 << p6;\n  ASSERT_STREQ(\"(null)(null)(null)(null)(null)(null)\",\n               msg.GetString().c_str());\n}\n\n// Tests streaming wide strings to testing::Message.\nTEST(MessageTest, WideStrings) {\n  // Streams a NULL of type const wchar_t*.\n  const wchar_t* const_wstr = NULL;\n  EXPECT_STREQ(\"(null)\",\n               (Message() << const_wstr).GetString().c_str());\n\n  // Streams a NULL of type wchar_t*.\n  wchar_t* wstr = NULL;\n  EXPECT_STREQ(\"(null)\",\n               (Message() << wstr).GetString().c_str());\n\n  // Streams a non-NULL of type const wchar_t*.\n  const_wstr = L\"abc\\x8119\";\n  EXPECT_STREQ(\"abc\\xe8\\x84\\x99\",\n               (Message() << const_wstr).GetString().c_str());\n\n  // Streams a non-NULL of type wchar_t*.\n  wstr = const_cast<wchar_t*>(const_wstr);\n  EXPECT_STREQ(\"abc\\xe8\\x84\\x99\",\n               (Message() << wstr).GetString().c_str());\n}\n\n\n// This line tests that we can define tests in the testing namespace.\nnamespace testing {\n\n// Tests the TestInfo class.\n\nclass TestInfoTest : public Test {\n protected:\n  static const TestInfo* GetTestInfo(const char* test_name) {\n    const TestCase* const test_case = GetUnitTestImpl()->\n        GetTestCase(\"TestInfoTest\", \"\", NULL, NULL);\n\n    for (int i = 0; i < test_case->total_test_count(); ++i) {\n      const TestInfo* const test_info = test_case->GetTestInfo(i);\n      if (strcmp(test_name, test_info->name()) == 0)\n        return test_info;\n    }\n    return NULL;\n  }\n\n  static const TestResult* GetTestResult(\n      const TestInfo* test_info) {\n    return test_info->result();\n  }\n};\n\n// Tests TestInfo::test_case_name() and TestInfo::name().\nTEST_F(TestInfoTest, Names) {\n  const TestInfo* const test_info = GetTestInfo(\"Names\");\n\n  ASSERT_STREQ(\"TestInfoTest\", test_info->test_case_name());\n  ASSERT_STREQ(\"Names\", test_info->name());\n}\n\n// Tests TestInfo::result().\nTEST_F(TestInfoTest, result) {\n  const TestInfo* const test_info = GetTestInfo(\"result\");\n\n  // Initially, there is no TestPartResult for this test.\n  ASSERT_EQ(0, GetTestResult(test_info)->total_part_count());\n\n  // After the previous assertion, there is still none.\n  ASSERT_EQ(0, GetTestResult(test_info)->total_part_count());\n}\n\n// Tests setting up and tearing down a test case.\n\nclass SetUpTestCaseTest : public Test {\n protected:\n  // This will be called once before the first test in this test case\n  // is run.\n  static void SetUpTestCase() {\n    printf(\"Setting up the test case . . .\\n\");\n\n    // Initializes some shared resource.  In this simple example, we\n    // just create a C string.  More complex stuff can be done if\n    // desired.\n    shared_resource_ = \"123\";\n\n    // Increments the number of test cases that have been set up.\n    counter_++;\n\n    // SetUpTestCase() should be called only once.\n    EXPECT_EQ(1, counter_);\n  }\n\n  // This will be called once after the last test in this test case is\n  // run.\n  static void TearDownTestCase() {\n    printf(\"Tearing down the test case . . .\\n\");\n\n    // Decrements the number of test cases that have been set up.\n    counter_--;\n\n    // TearDownTestCase() should be called only once.\n    EXPECT_EQ(0, counter_);\n\n    // Cleans up the shared resource.\n    shared_resource_ = NULL;\n  }\n\n  // This will be called before each test in this test case.\n  virtual void SetUp() {\n    // SetUpTestCase() should be called only once, so counter_ should\n    // always be 1.\n    EXPECT_EQ(1, counter_);\n  }\n\n  // Number of test cases that have been set up.\n  static int counter_;\n\n  // Some resource to be shared by all tests in this test case.\n  static const char* shared_resource_;\n};\n\nint SetUpTestCaseTest::counter_ = 0;\nconst char* SetUpTestCaseTest::shared_resource_ = NULL;\n\n// A test that uses the shared resource.\nTEST_F(SetUpTestCaseTest, Test1) {\n  EXPECT_STRNE(NULL, shared_resource_);\n}\n\n// Another test that uses the shared resource.\nTEST_F(SetUpTestCaseTest, Test2) {\n  EXPECT_STREQ(\"123\", shared_resource_);\n}\n\n// The InitGoogleTestTest test case tests testing::InitGoogleTest().\n\n// The Flags struct stores a copy of all Google Test flags.\nstruct Flags {\n  // Constructs a Flags struct where each flag has its default value.\n  Flags() : also_run_disabled_tests(false),\n            break_on_failure(false),\n            catch_exceptions(false),\n            death_test_use_fork(false),\n            filter(\"\"),\n            list_tests(false),\n            output(\"\"),\n            print_time(true),\n            random_seed(0),\n            repeat(1),\n            shuffle(false),\n            stack_trace_depth(kMaxStackTraceDepth),\n            stream_result_to(\"\"),\n            throw_on_failure(false) {}\n\n  // Factory methods.\n\n  // Creates a Flags struct where the gtest_also_run_disabled_tests flag has\n  // the given value.\n  static Flags AlsoRunDisabledTests(bool also_run_disabled_tests) {\n    Flags flags;\n    flags.also_run_disabled_tests = also_run_disabled_tests;\n    return flags;\n  }\n\n  // Creates a Flags struct where the gtest_break_on_failure flag has\n  // the given value.\n  static Flags BreakOnFailure(bool break_on_failure) {\n    Flags flags;\n    flags.break_on_failure = break_on_failure;\n    return flags;\n  }\n\n  // Creates a Flags struct where the gtest_catch_exceptions flag has\n  // the given value.\n  static Flags CatchExceptions(bool catch_exceptions) {\n    Flags flags;\n    flags.catch_exceptions = catch_exceptions;\n    return flags;\n  }\n\n  // Creates a Flags struct where the gtest_death_test_use_fork flag has\n  // the given value.\n  static Flags DeathTestUseFork(bool death_test_use_fork) {\n    Flags flags;\n    flags.death_test_use_fork = death_test_use_fork;\n    return flags;\n  }\n\n  // Creates a Flags struct where the gtest_filter flag has the given\n  // value.\n  static Flags Filter(const char* filter) {\n    Flags flags;\n    flags.filter = filter;\n    return flags;\n  }\n\n  // Creates a Flags struct where the gtest_list_tests flag has the\n  // given value.\n  static Flags ListTests(bool list_tests) {\n    Flags flags;\n    flags.list_tests = list_tests;\n    return flags;\n  }\n\n  // Creates a Flags struct where the gtest_output flag has the given\n  // value.\n  static Flags Output(const char* output) {\n    Flags flags;\n    flags.output = output;\n    return flags;\n  }\n\n  // Creates a Flags struct where the gtest_print_time flag has the given\n  // value.\n  static Flags PrintTime(bool print_time) {\n    Flags flags;\n    flags.print_time = print_time;\n    return flags;\n  }\n\n  // Creates a Flags struct where the gtest_random_seed flag has\n  // the given value.\n  static Flags RandomSeed(Int32 random_seed) {\n    Flags flags;\n    flags.random_seed = random_seed;\n    return flags;\n  }\n\n  // Creates a Flags struct where the gtest_repeat flag has the given\n  // value.\n  static Flags Repeat(Int32 repeat) {\n    Flags flags;\n    flags.repeat = repeat;\n    return flags;\n  }\n\n  // Creates a Flags struct where the gtest_shuffle flag has\n  // the given value.\n  static Flags Shuffle(bool shuffle) {\n    Flags flags;\n    flags.shuffle = shuffle;\n    return flags;\n  }\n\n  // Creates a Flags struct where the GTEST_FLAG(stack_trace_depth) flag has\n  // the given value.\n  static Flags StackTraceDepth(Int32 stack_trace_depth) {\n    Flags flags;\n    flags.stack_trace_depth = stack_trace_depth;\n    return flags;\n  }\n\n  // Creates a Flags struct where the GTEST_FLAG(stream_result_to) flag has\n  // the given value.\n  static Flags StreamResultTo(const char* stream_result_to) {\n    Flags flags;\n    flags.stream_result_to = stream_result_to;\n    return flags;\n  }\n\n  // Creates a Flags struct where the gtest_throw_on_failure flag has\n  // the given value.\n  static Flags ThrowOnFailure(bool throw_on_failure) {\n    Flags flags;\n    flags.throw_on_failure = throw_on_failure;\n    return flags;\n  }\n\n  // These fields store the flag values.\n  bool also_run_disabled_tests;\n  bool break_on_failure;\n  bool catch_exceptions;\n  bool death_test_use_fork;\n  const char* filter;\n  bool list_tests;\n  const char* output;\n  bool print_time;\n  Int32 random_seed;\n  Int32 repeat;\n  bool shuffle;\n  Int32 stack_trace_depth;\n  const char* stream_result_to;\n  bool throw_on_failure;\n};\n\n// Fixture for testing InitGoogleTest().\nclass InitGoogleTestTest : public Test {\n protected:\n  // Clears the flags before each test.\n  virtual void SetUp() {\n    GTEST_FLAG(also_run_disabled_tests) = false;\n    GTEST_FLAG(break_on_failure) = false;\n    GTEST_FLAG(catch_exceptions) = false;\n    GTEST_FLAG(death_test_use_fork) = false;\n    GTEST_FLAG(filter) = \"\";\n    GTEST_FLAG(list_tests) = false;\n    GTEST_FLAG(output) = \"\";\n    GTEST_FLAG(print_time) = true;\n    GTEST_FLAG(random_seed) = 0;\n    GTEST_FLAG(repeat) = 1;\n    GTEST_FLAG(shuffle) = false;\n    GTEST_FLAG(stack_trace_depth) = kMaxStackTraceDepth;\n    GTEST_FLAG(stream_result_to) = \"\";\n    GTEST_FLAG(throw_on_failure) = false;\n  }\n\n  // Asserts that two narrow or wide string arrays are equal.\n  template <typename CharType>\n  static void AssertStringArrayEq(size_t size1, CharType** array1,\n                                  size_t size2, CharType** array2) {\n    ASSERT_EQ(size1, size2) << \" Array sizes different.\";\n\n    for (size_t i = 0; i != size1; i++) {\n      ASSERT_STREQ(array1[i], array2[i]) << \" where i == \" << i;\n    }\n  }\n\n  // Verifies that the flag values match the expected values.\n  static void CheckFlags(const Flags& expected) {\n    EXPECT_EQ(expected.also_run_disabled_tests,\n              GTEST_FLAG(also_run_disabled_tests));\n    EXPECT_EQ(expected.break_on_failure, GTEST_FLAG(break_on_failure));\n    EXPECT_EQ(expected.catch_exceptions, GTEST_FLAG(catch_exceptions));\n    EXPECT_EQ(expected.death_test_use_fork, GTEST_FLAG(death_test_use_fork));\n    EXPECT_STREQ(expected.filter, GTEST_FLAG(filter).c_str());\n    EXPECT_EQ(expected.list_tests, GTEST_FLAG(list_tests));\n    EXPECT_STREQ(expected.output, GTEST_FLAG(output).c_str());\n    EXPECT_EQ(expected.print_time, GTEST_FLAG(print_time));\n    EXPECT_EQ(expected.random_seed, GTEST_FLAG(random_seed));\n    EXPECT_EQ(expected.repeat, GTEST_FLAG(repeat));\n    EXPECT_EQ(expected.shuffle, GTEST_FLAG(shuffle));\n    EXPECT_EQ(expected.stack_trace_depth, GTEST_FLAG(stack_trace_depth));\n    EXPECT_STREQ(expected.stream_result_to,\n                 GTEST_FLAG(stream_result_to).c_str());\n    EXPECT_EQ(expected.throw_on_failure, GTEST_FLAG(throw_on_failure));\n  }\n\n  // Parses a command line (specified by argc1 and argv1), then\n  // verifies that the flag values are expected and that the\n  // recognized flags are removed from the command line.\n  template <typename CharType>\n  static void TestParsingFlags(int argc1, const CharType** argv1,\n                               int argc2, const CharType** argv2,\n                               const Flags& expected, bool should_print_help) {\n    const bool saved_help_flag = ::testing::internal::g_help_flag;\n    ::testing::internal::g_help_flag = false;\n\n#if GTEST_HAS_STREAM_REDIRECTION\n    CaptureStdout();\n#endif\n\n    // Parses the command line.\n    internal::ParseGoogleTestFlagsOnly(&argc1, const_cast<CharType**>(argv1));\n\n#if GTEST_HAS_STREAM_REDIRECTION\n    const std::string captured_stdout = GetCapturedStdout();\n#endif\n\n    // Verifies the flag values.\n    CheckFlags(expected);\n\n    // Verifies that the recognized flags are removed from the command\n    // line.\n    AssertStringArrayEq(argc1 + 1, argv1, argc2 + 1, argv2);\n\n    // ParseGoogleTestFlagsOnly should neither set g_help_flag nor print the\n    // help message for the flags it recognizes.\n    EXPECT_EQ(should_print_help, ::testing::internal::g_help_flag);\n\n#if GTEST_HAS_STREAM_REDIRECTION\n    const char* const expected_help_fragment =\n        \"This program contains tests written using\";\n    if (should_print_help) {\n      EXPECT_PRED_FORMAT2(IsSubstring, expected_help_fragment, captured_stdout);\n    } else {\n      EXPECT_PRED_FORMAT2(IsNotSubstring,\n                          expected_help_fragment, captured_stdout);\n    }\n#endif  // GTEST_HAS_STREAM_REDIRECTION\n\n    ::testing::internal::g_help_flag = saved_help_flag;\n  }\n\n  // This macro wraps TestParsingFlags s.t. the user doesn't need\n  // to specify the array sizes.\n\n#define GTEST_TEST_PARSING_FLAGS_(argv1, argv2, expected, should_print_help) \\\n  TestParsingFlags(sizeof(argv1)/sizeof(*argv1) - 1, argv1, \\\n                   sizeof(argv2)/sizeof(*argv2) - 1, argv2, \\\n                   expected, should_print_help)\n};\n\n// Tests parsing an empty command line.\nTEST_F(InitGoogleTestTest, Empty) {\n  const char* argv[] = {\n    NULL\n  };\n\n  const char* argv2[] = {\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), false);\n}\n\n// Tests parsing a command line that has no flag.\nTEST_F(InitGoogleTestTest, NoFlag) {\n  const char* argv[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), false);\n}\n\n// Tests parsing a bad --gtest_filter flag.\nTEST_F(InitGoogleTestTest, FilterBad) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_filter\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    \"--gtest_filter\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(\"\"), true);\n}\n\n// Tests parsing an empty --gtest_filter flag.\nTEST_F(InitGoogleTestTest, FilterEmpty) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_filter=\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(\"\"), false);\n}\n\n// Tests parsing a non-empty --gtest_filter flag.\nTEST_F(InitGoogleTestTest, FilterNonEmpty) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_filter=abc\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(\"abc\"), false);\n}\n\n// Tests parsing --gtest_break_on_failure.\nTEST_F(InitGoogleTestTest, BreakOnFailureWithoutValue) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_break_on_failure\",\n    NULL\n};\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(true), false);\n}\n\n// Tests parsing --gtest_break_on_failure=0.\nTEST_F(InitGoogleTestTest, BreakOnFailureFalse_0) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_break_on_failure=0\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(false), false);\n}\n\n// Tests parsing --gtest_break_on_failure=f.\nTEST_F(InitGoogleTestTest, BreakOnFailureFalse_f) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_break_on_failure=f\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(false), false);\n}\n\n// Tests parsing --gtest_break_on_failure=F.\nTEST_F(InitGoogleTestTest, BreakOnFailureFalse_F) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_break_on_failure=F\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(false), false);\n}\n\n// Tests parsing a --gtest_break_on_failure flag that has a \"true\"\n// definition.\nTEST_F(InitGoogleTestTest, BreakOnFailureTrue) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_break_on_failure=1\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::BreakOnFailure(true), false);\n}\n\n// Tests parsing --gtest_catch_exceptions.\nTEST_F(InitGoogleTestTest, CatchExceptions) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_catch_exceptions\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::CatchExceptions(true), false);\n}\n\n// Tests parsing --gtest_death_test_use_fork.\nTEST_F(InitGoogleTestTest, DeathTestUseFork) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_death_test_use_fork\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::DeathTestUseFork(true), false);\n}\n\n// Tests having the same flag twice with different values.  The\n// expected behavior is that the one coming last takes precedence.\nTEST_F(InitGoogleTestTest, DuplicatedFlags) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_filter=a\",\n    \"--gtest_filter=b\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Filter(\"b\"), false);\n}\n\n// Tests having an unrecognized flag on the command line.\nTEST_F(InitGoogleTestTest, UnrecognizedFlag) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_break_on_failure\",\n    \"bar\",  // Unrecognized by Google Test.\n    \"--gtest_filter=b\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    \"bar\",\n    NULL\n  };\n\n  Flags flags;\n  flags.break_on_failure = true;\n  flags.filter = \"b\";\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, flags, false);\n}\n\n// Tests having a --gtest_list_tests flag\nTEST_F(InitGoogleTestTest, ListTestsFlag) {\n    const char* argv[] = {\n      \"foo.exe\",\n      \"--gtest_list_tests\",\n      NULL\n    };\n\n    const char* argv2[] = {\n      \"foo.exe\",\n      NULL\n    };\n\n    GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(true), false);\n}\n\n// Tests having a --gtest_list_tests flag with a \"true\" value\nTEST_F(InitGoogleTestTest, ListTestsTrue) {\n    const char* argv[] = {\n      \"foo.exe\",\n      \"--gtest_list_tests=1\",\n      NULL\n    };\n\n    const char* argv2[] = {\n      \"foo.exe\",\n      NULL\n    };\n\n    GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(true), false);\n}\n\n// Tests having a --gtest_list_tests flag with a \"false\" value\nTEST_F(InitGoogleTestTest, ListTestsFalse) {\n    const char* argv[] = {\n      \"foo.exe\",\n      \"--gtest_list_tests=0\",\n      NULL\n    };\n\n    const char* argv2[] = {\n      \"foo.exe\",\n      NULL\n    };\n\n    GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(false), false);\n}\n\n// Tests parsing --gtest_list_tests=f.\nTEST_F(InitGoogleTestTest, ListTestsFalse_f) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_list_tests=f\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(false), false);\n}\n\n// Tests parsing --gtest_list_tests=F.\nTEST_F(InitGoogleTestTest, ListTestsFalse_F) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_list_tests=F\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ListTests(false), false);\n}\n\n// Tests parsing --gtest_output (invalid).\nTEST_F(InitGoogleTestTest, OutputEmpty) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_output\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    \"--gtest_output\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags(), true);\n}\n\n// Tests parsing --gtest_output=xml\nTEST_F(InitGoogleTestTest, OutputXml) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_output=xml\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Output(\"xml\"), false);\n}\n\n// Tests parsing --gtest_output=xml:file\nTEST_F(InitGoogleTestTest, OutputXmlFile) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_output=xml:file\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Output(\"xml:file\"), false);\n}\n\n// Tests parsing --gtest_output=xml:directory/path/\nTEST_F(InitGoogleTestTest, OutputXmlDirectory) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_output=xml:directory/path/\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2,\n                            Flags::Output(\"xml:directory/path/\"), false);\n}\n\n// Tests having a --gtest_print_time flag\nTEST_F(InitGoogleTestTest, PrintTimeFlag) {\n    const char* argv[] = {\n      \"foo.exe\",\n      \"--gtest_print_time\",\n      NULL\n    };\n\n    const char* argv2[] = {\n      \"foo.exe\",\n      NULL\n    };\n\n    GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(true), false);\n}\n\n// Tests having a --gtest_print_time flag with a \"true\" value\nTEST_F(InitGoogleTestTest, PrintTimeTrue) {\n    const char* argv[] = {\n      \"foo.exe\",\n      \"--gtest_print_time=1\",\n      NULL\n    };\n\n    const char* argv2[] = {\n      \"foo.exe\",\n      NULL\n    };\n\n    GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(true), false);\n}\n\n// Tests having a --gtest_print_time flag with a \"false\" value\nTEST_F(InitGoogleTestTest, PrintTimeFalse) {\n    const char* argv[] = {\n      \"foo.exe\",\n      \"--gtest_print_time=0\",\n      NULL\n    };\n\n    const char* argv2[] = {\n      \"foo.exe\",\n      NULL\n    };\n\n    GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(false), false);\n}\n\n// Tests parsing --gtest_print_time=f.\nTEST_F(InitGoogleTestTest, PrintTimeFalse_f) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_print_time=f\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(false), false);\n}\n\n// Tests parsing --gtest_print_time=F.\nTEST_F(InitGoogleTestTest, PrintTimeFalse_F) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_print_time=F\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::PrintTime(false), false);\n}\n\n// Tests parsing --gtest_random_seed=number\nTEST_F(InitGoogleTestTest, RandomSeed) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_random_seed=1000\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::RandomSeed(1000), false);\n}\n\n// Tests parsing --gtest_repeat=number\nTEST_F(InitGoogleTestTest, Repeat) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_repeat=1000\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Repeat(1000), false);\n}\n\n// Tests having a --gtest_also_run_disabled_tests flag\nTEST_F(InitGoogleTestTest, AlsoRunDisabledTestsFlag) {\n    const char* argv[] = {\n      \"foo.exe\",\n      \"--gtest_also_run_disabled_tests\",\n      NULL\n    };\n\n    const char* argv2[] = {\n      \"foo.exe\",\n      NULL\n    };\n\n    GTEST_TEST_PARSING_FLAGS_(argv, argv2,\n                              Flags::AlsoRunDisabledTests(true), false);\n}\n\n// Tests having a --gtest_also_run_disabled_tests flag with a \"true\" value\nTEST_F(InitGoogleTestTest, AlsoRunDisabledTestsTrue) {\n    const char* argv[] = {\n      \"foo.exe\",\n      \"--gtest_also_run_disabled_tests=1\",\n      NULL\n    };\n\n    const char* argv2[] = {\n      \"foo.exe\",\n      NULL\n    };\n\n    GTEST_TEST_PARSING_FLAGS_(argv, argv2,\n                              Flags::AlsoRunDisabledTests(true), false);\n}\n\n// Tests having a --gtest_also_run_disabled_tests flag with a \"false\" value\nTEST_F(InitGoogleTestTest, AlsoRunDisabledTestsFalse) {\n    const char* argv[] = {\n      \"foo.exe\",\n      \"--gtest_also_run_disabled_tests=0\",\n      NULL\n    };\n\n    const char* argv2[] = {\n      \"foo.exe\",\n      NULL\n    };\n\n    GTEST_TEST_PARSING_FLAGS_(argv, argv2,\n                              Flags::AlsoRunDisabledTests(false), false);\n}\n\n// Tests parsing --gtest_shuffle.\nTEST_F(InitGoogleTestTest, ShuffleWithoutValue) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_shuffle\",\n    NULL\n};\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Shuffle(true), false);\n}\n\n// Tests parsing --gtest_shuffle=0.\nTEST_F(InitGoogleTestTest, ShuffleFalse_0) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_shuffle=0\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Shuffle(false), false);\n}\n\n// Tests parsing a --gtest_shuffle flag that has a \"true\"\n// definition.\nTEST_F(InitGoogleTestTest, ShuffleTrue) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_shuffle=1\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::Shuffle(true), false);\n}\n\n// Tests parsing --gtest_stack_trace_depth=number.\nTEST_F(InitGoogleTestTest, StackTraceDepth) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_stack_trace_depth=5\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::StackTraceDepth(5), false);\n}\n\nTEST_F(InitGoogleTestTest, StreamResultTo) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_stream_result_to=localhost:1234\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(\n      argv, argv2, Flags::StreamResultTo(\"localhost:1234\"), false);\n}\n\n// Tests parsing --gtest_throw_on_failure.\nTEST_F(InitGoogleTestTest, ThrowOnFailureWithoutValue) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_throw_on_failure\",\n    NULL\n};\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ThrowOnFailure(true), false);\n}\n\n// Tests parsing --gtest_throw_on_failure=0.\nTEST_F(InitGoogleTestTest, ThrowOnFailureFalse_0) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_throw_on_failure=0\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ThrowOnFailure(false), false);\n}\n\n// Tests parsing a --gtest_throw_on_failure flag that has a \"true\"\n// definition.\nTEST_F(InitGoogleTestTest, ThrowOnFailureTrue) {\n  const char* argv[] = {\n    \"foo.exe\",\n    \"--gtest_throw_on_failure=1\",\n    NULL\n  };\n\n  const char* argv2[] = {\n    \"foo.exe\",\n    NULL\n  };\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, Flags::ThrowOnFailure(true), false);\n}\n\n#if GTEST_OS_WINDOWS\n// Tests parsing wide strings.\nTEST_F(InitGoogleTestTest, WideStrings) {\n  const wchar_t* argv[] = {\n    L\"foo.exe\",\n    L\"--gtest_filter=Foo*\",\n    L\"--gtest_list_tests=1\",\n    L\"--gtest_break_on_failure\",\n    L\"--non_gtest_flag\",\n    NULL\n  };\n\n  const wchar_t* argv2[] = {\n    L\"foo.exe\",\n    L\"--non_gtest_flag\",\n    NULL\n  };\n\n  Flags expected_flags;\n  expected_flags.break_on_failure = true;\n  expected_flags.filter = \"Foo*\";\n  expected_flags.list_tests = true;\n\n  GTEST_TEST_PARSING_FLAGS_(argv, argv2, expected_flags, false);\n}\n#endif  // GTEST_OS_WINDOWS\n\n// Tests current_test_info() in UnitTest.\nclass CurrentTestInfoTest : public Test {\n protected:\n  // Tests that current_test_info() returns NULL before the first test in\n  // the test case is run.\n  static void SetUpTestCase() {\n    // There should be no tests running at this point.\n    const TestInfo* test_info =\n      UnitTest::GetInstance()->current_test_info();\n    EXPECT_TRUE(test_info == NULL)\n        << \"There should be no tests running at this point.\";\n  }\n\n  // Tests that current_test_info() returns NULL after the last test in\n  // the test case has run.\n  static void TearDownTestCase() {\n    const TestInfo* test_info =\n      UnitTest::GetInstance()->current_test_info();\n    EXPECT_TRUE(test_info == NULL)\n        << \"There should be no tests running at this point.\";\n  }\n};\n\n// Tests that current_test_info() returns TestInfo for currently running\n// test by checking the expected test name against the actual one.\nTEST_F(CurrentTestInfoTest, WorksForFirstTestInATestCase) {\n  const TestInfo* test_info =\n    UnitTest::GetInstance()->current_test_info();\n  ASSERT_TRUE(NULL != test_info)\n      << \"There is a test running so we should have a valid TestInfo.\";\n  EXPECT_STREQ(\"CurrentTestInfoTest\", test_info->test_case_name())\n      << \"Expected the name of the currently running test case.\";\n  EXPECT_STREQ(\"WorksForFirstTestInATestCase\", test_info->name())\n      << \"Expected the name of the currently running test.\";\n}\n\n// Tests that current_test_info() returns TestInfo for currently running\n// test by checking the expected test name against the actual one.  We\n// use this test to see that the TestInfo object actually changed from\n// the previous invocation.\nTEST_F(CurrentTestInfoTest, WorksForSecondTestInATestCase) {\n  const TestInfo* test_info =\n    UnitTest::GetInstance()->current_test_info();\n  ASSERT_TRUE(NULL != test_info)\n      << \"There is a test running so we should have a valid TestInfo.\";\n  EXPECT_STREQ(\"CurrentTestInfoTest\", test_info->test_case_name())\n      << \"Expected the name of the currently running test case.\";\n  EXPECT_STREQ(\"WorksForSecondTestInATestCase\", test_info->name())\n      << \"Expected the name of the currently running test.\";\n}\n\n}  // namespace testing\n\n// These two lines test that we can define tests in a namespace that\n// has the name \"testing\" and is nested in another namespace.\nnamespace my_namespace {\nnamespace testing {\n\n// Makes sure that TEST knows to use ::testing::Test instead of\n// ::my_namespace::testing::Test.\nclass Test {};\n\n// Makes sure that an assertion knows to use ::testing::Message instead of\n// ::my_namespace::testing::Message.\nclass Message {};\n\n// Makes sure that an assertion knows to use\n// ::testing::AssertionResult instead of\n// ::my_namespace::testing::AssertionResult.\nclass AssertionResult {};\n\n// Tests that an assertion that should succeed works as expected.\nTEST(NestedTestingNamespaceTest, Success) {\n  EXPECT_EQ(1, 1) << \"This shouldn't fail.\";\n}\n\n// Tests that an assertion that should fail works as expected.\nTEST(NestedTestingNamespaceTest, Failure) {\n  EXPECT_FATAL_FAILURE(FAIL() << \"This failure is expected.\",\n                       \"This failure is expected.\");\n}\n\n}  // namespace testing\n}  // namespace my_namespace\n\n// Tests that one can call superclass SetUp and TearDown methods--\n// that is, that they are not private.\n// No tests are based on this fixture; the test \"passes\" if it compiles\n// successfully.\nclass ProtectedFixtureMethodsTest : public Test {\n protected:\n  virtual void SetUp() {\n    Test::SetUp();\n  }\n  virtual void TearDown() {\n    Test::TearDown();\n  }\n};\n\n// StreamingAssertionsTest tests the streaming versions of a representative\n// sample of assertions.\nTEST(StreamingAssertionsTest, Unconditional) {\n  SUCCEED() << \"expected success\";\n  EXPECT_NONFATAL_FAILURE(ADD_FAILURE() << \"expected failure\",\n                          \"expected failure\");\n  EXPECT_FATAL_FAILURE(FAIL() << \"expected failure\",\n                       \"expected failure\");\n}\n\n#ifdef __BORLANDC__\n// Silences warnings: \"Condition is always true\", \"Unreachable code\"\n# pragma option push -w-ccc -w-rch\n#endif\n\nTEST(StreamingAssertionsTest, Truth) {\n  EXPECT_TRUE(true) << \"unexpected failure\";\n  ASSERT_TRUE(true) << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(false) << \"expected failure\",\n                          \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_TRUE(false) << \"expected failure\",\n                       \"expected failure\");\n}\n\nTEST(StreamingAssertionsTest, Truth2) {\n  EXPECT_FALSE(false) << \"unexpected failure\";\n  ASSERT_FALSE(false) << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_FALSE(true) << \"expected failure\",\n                          \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_FALSE(true) << \"expected failure\",\n                       \"expected failure\");\n}\n\n#ifdef __BORLANDC__\n// Restores warnings after previous \"#pragma option push\" supressed them\n# pragma option pop\n#endif\n\nTEST(StreamingAssertionsTest, IntegerEquals) {\n  EXPECT_EQ(1, 1) << \"unexpected failure\";\n  ASSERT_EQ(1, 1) << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_EQ(1, 2) << \"expected failure\",\n                          \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_EQ(1, 2) << \"expected failure\",\n                       \"expected failure\");\n}\n\nTEST(StreamingAssertionsTest, IntegerLessThan) {\n  EXPECT_LT(1, 2) << \"unexpected failure\";\n  ASSERT_LT(1, 2) << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_LT(2, 1) << \"expected failure\",\n                          \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_LT(2, 1) << \"expected failure\",\n                       \"expected failure\");\n}\n\nTEST(StreamingAssertionsTest, StringsEqual) {\n  EXPECT_STREQ(\"foo\", \"foo\") << \"unexpected failure\";\n  ASSERT_STREQ(\"foo\", \"foo\") << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_STREQ(\"foo\", \"bar\") << \"expected failure\",\n                          \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_STREQ(\"foo\", \"bar\") << \"expected failure\",\n                       \"expected failure\");\n}\n\nTEST(StreamingAssertionsTest, StringsNotEqual) {\n  EXPECT_STRNE(\"foo\", \"bar\") << \"unexpected failure\";\n  ASSERT_STRNE(\"foo\", \"bar\") << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_STRNE(\"foo\", \"foo\") << \"expected failure\",\n                          \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_STRNE(\"foo\", \"foo\") << \"expected failure\",\n                       \"expected failure\");\n}\n\nTEST(StreamingAssertionsTest, StringsEqualIgnoringCase) {\n  EXPECT_STRCASEEQ(\"foo\", \"FOO\") << \"unexpected failure\";\n  ASSERT_STRCASEEQ(\"foo\", \"FOO\") << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_STRCASEEQ(\"foo\", \"bar\") << \"expected failure\",\n                          \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_STRCASEEQ(\"foo\", \"bar\") << \"expected failure\",\n                       \"expected failure\");\n}\n\nTEST(StreamingAssertionsTest, StringNotEqualIgnoringCase) {\n  EXPECT_STRCASENE(\"foo\", \"bar\") << \"unexpected failure\";\n  ASSERT_STRCASENE(\"foo\", \"bar\") << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_STRCASENE(\"foo\", \"FOO\") << \"expected failure\",\n                          \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_STRCASENE(\"bar\", \"BAR\") << \"expected failure\",\n                       \"expected failure\");\n}\n\nTEST(StreamingAssertionsTest, FloatingPointEquals) {\n  EXPECT_FLOAT_EQ(1.0, 1.0) << \"unexpected failure\";\n  ASSERT_FLOAT_EQ(1.0, 1.0) << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_FLOAT_EQ(0.0, 1.0) << \"expected failure\",\n                          \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_FLOAT_EQ(0.0, 1.0) << \"expected failure\",\n                       \"expected failure\");\n}\n\n#if GTEST_HAS_EXCEPTIONS\n\nTEST(StreamingAssertionsTest, Throw) {\n  EXPECT_THROW(ThrowAnInteger(), int) << \"unexpected failure\";\n  ASSERT_THROW(ThrowAnInteger(), int) << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_THROW(ThrowAnInteger(), bool) <<\n                          \"expected failure\", \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_THROW(ThrowAnInteger(), bool) <<\n                       \"expected failure\", \"expected failure\");\n}\n\nTEST(StreamingAssertionsTest, NoThrow) {\n  EXPECT_NO_THROW(ThrowNothing()) << \"unexpected failure\";\n  ASSERT_NO_THROW(ThrowNothing()) << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_NO_THROW(ThrowAnInteger()) <<\n                          \"expected failure\", \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_NO_THROW(ThrowAnInteger()) <<\n                       \"expected failure\", \"expected failure\");\n}\n\nTEST(StreamingAssertionsTest, AnyThrow) {\n  EXPECT_ANY_THROW(ThrowAnInteger()) << \"unexpected failure\";\n  ASSERT_ANY_THROW(ThrowAnInteger()) << \"unexpected failure\";\n  EXPECT_NONFATAL_FAILURE(EXPECT_ANY_THROW(ThrowNothing()) <<\n                          \"expected failure\", \"expected failure\");\n  EXPECT_FATAL_FAILURE(ASSERT_ANY_THROW(ThrowNothing()) <<\n                       \"expected failure\", \"expected failure\");\n}\n\n#endif  // GTEST_HAS_EXCEPTIONS\n\n// Tests that Google Test correctly decides whether to use colors in the output.\n\nTEST(ColoredOutputTest, UsesColorsWhenGTestColorFlagIsYes) {\n  GTEST_FLAG(color) = \"yes\";\n\n  SetEnv(\"TERM\", \"xterm\");  // TERM supports colors.\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n  EXPECT_TRUE(ShouldUseColor(false));  // Stdout is not a TTY.\n\n  SetEnv(\"TERM\", \"dumb\");  // TERM doesn't support colors.\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n  EXPECT_TRUE(ShouldUseColor(false));  // Stdout is not a TTY.\n}\n\nTEST(ColoredOutputTest, UsesColorsWhenGTestColorFlagIsAliasOfYes) {\n  SetEnv(\"TERM\", \"dumb\");  // TERM doesn't support colors.\n\n  GTEST_FLAG(color) = \"True\";\n  EXPECT_TRUE(ShouldUseColor(false));  // Stdout is not a TTY.\n\n  GTEST_FLAG(color) = \"t\";\n  EXPECT_TRUE(ShouldUseColor(false));  // Stdout is not a TTY.\n\n  GTEST_FLAG(color) = \"1\";\n  EXPECT_TRUE(ShouldUseColor(false));  // Stdout is not a TTY.\n}\n\nTEST(ColoredOutputTest, UsesNoColorWhenGTestColorFlagIsNo) {\n  GTEST_FLAG(color) = \"no\";\n\n  SetEnv(\"TERM\", \"xterm\");  // TERM supports colors.\n  EXPECT_FALSE(ShouldUseColor(true));  // Stdout is a TTY.\n  EXPECT_FALSE(ShouldUseColor(false));  // Stdout is not a TTY.\n\n  SetEnv(\"TERM\", \"dumb\");  // TERM doesn't support colors.\n  EXPECT_FALSE(ShouldUseColor(true));  // Stdout is a TTY.\n  EXPECT_FALSE(ShouldUseColor(false));  // Stdout is not a TTY.\n}\n\nTEST(ColoredOutputTest, UsesNoColorWhenGTestColorFlagIsInvalid) {\n  SetEnv(\"TERM\", \"xterm\");  // TERM supports colors.\n\n  GTEST_FLAG(color) = \"F\";\n  EXPECT_FALSE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  GTEST_FLAG(color) = \"0\";\n  EXPECT_FALSE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  GTEST_FLAG(color) = \"unknown\";\n  EXPECT_FALSE(ShouldUseColor(true));  // Stdout is a TTY.\n}\n\nTEST(ColoredOutputTest, UsesColorsWhenStdoutIsTty) {\n  GTEST_FLAG(color) = \"auto\";\n\n  SetEnv(\"TERM\", \"xterm\");  // TERM supports colors.\n  EXPECT_FALSE(ShouldUseColor(false));  // Stdout is not a TTY.\n  EXPECT_TRUE(ShouldUseColor(true));    // Stdout is a TTY.\n}\n\nTEST(ColoredOutputTest, UsesColorsWhenTermSupportsColors) {\n  GTEST_FLAG(color) = \"auto\";\n\n#if GTEST_OS_WINDOWS\n  // On Windows, we ignore the TERM variable as it's usually not set.\n\n  SetEnv(\"TERM\", \"dumb\");\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"\");\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"xterm\");\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n#else\n  // On non-Windows platforms, we rely on TERM to determine if the\n  // terminal supports colors.\n\n  SetEnv(\"TERM\", \"dumb\");  // TERM doesn't support colors.\n  EXPECT_FALSE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"emacs\");  // TERM doesn't support colors.\n  EXPECT_FALSE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"vt100\");  // TERM doesn't support colors.\n  EXPECT_FALSE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"xterm-mono\");  // TERM doesn't support colors.\n  EXPECT_FALSE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"xterm\");  // TERM supports colors.\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"xterm-color\");  // TERM supports colors.\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"xterm-256color\");  // TERM supports colors.\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"screen\");  // TERM supports colors.\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"screen-256color\");  // TERM supports colors.\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"linux\");  // TERM supports colors.\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n\n  SetEnv(\"TERM\", \"cygwin\");  // TERM supports colors.\n  EXPECT_TRUE(ShouldUseColor(true));  // Stdout is a TTY.\n#endif  // GTEST_OS_WINDOWS\n}\n\n// Verifies that StaticAssertTypeEq works in a namespace scope.\n\nstatic bool dummy1 GTEST_ATTRIBUTE_UNUSED_ = StaticAssertTypeEq<bool, bool>();\nstatic bool dummy2 GTEST_ATTRIBUTE_UNUSED_ =\n    StaticAssertTypeEq<const int, const int>();\n\n// Verifies that StaticAssertTypeEq works in a class.\n\ntemplate <typename T>\nclass StaticAssertTypeEqTestHelper {\n public:\n  StaticAssertTypeEqTestHelper() { StaticAssertTypeEq<bool, T>(); }\n};\n\nTEST(StaticAssertTypeEqTest, WorksInClass) {\n  StaticAssertTypeEqTestHelper<bool>();\n}\n\n// Verifies that StaticAssertTypeEq works inside a function.\n\ntypedef int IntAlias;\n\nTEST(StaticAssertTypeEqTest, CompilesForEqualTypes) {\n  StaticAssertTypeEq<int, IntAlias>();\n  StaticAssertTypeEq<int*, IntAlias*>();\n}\n\nTEST(GetCurrentOsStackTraceExceptTopTest, ReturnsTheStackTrace) {\n  testing::UnitTest* const unit_test = testing::UnitTest::GetInstance();\n\n  // We don't have a stack walker in Google Test yet.\n  EXPECT_STREQ(\"\", GetCurrentOsStackTraceExceptTop(unit_test, 0).c_str());\n  EXPECT_STREQ(\"\", GetCurrentOsStackTraceExceptTop(unit_test, 1).c_str());\n}\n\nTEST(HasNonfatalFailureTest, ReturnsFalseWhenThereIsNoFailure) {\n  EXPECT_FALSE(HasNonfatalFailure());\n}\n\nstatic void FailFatally() { FAIL(); }\n\nTEST(HasNonfatalFailureTest, ReturnsFalseWhenThereIsOnlyFatalFailure) {\n  FailFatally();\n  const bool has_nonfatal_failure = HasNonfatalFailure();\n  ClearCurrentTestPartResults();\n  EXPECT_FALSE(has_nonfatal_failure);\n}\n\nTEST(HasNonfatalFailureTest, ReturnsTrueWhenThereIsNonfatalFailure) {\n  ADD_FAILURE();\n  const bool has_nonfatal_failure = HasNonfatalFailure();\n  ClearCurrentTestPartResults();\n  EXPECT_TRUE(has_nonfatal_failure);\n}\n\nTEST(HasNonfatalFailureTest, ReturnsTrueWhenThereAreFatalAndNonfatalFailures) {\n  FailFatally();\n  ADD_FAILURE();\n  const bool has_nonfatal_failure = HasNonfatalFailure();\n  ClearCurrentTestPartResults();\n  EXPECT_TRUE(has_nonfatal_failure);\n}\n\n// A wrapper for calling HasNonfatalFailure outside of a test body.\nstatic bool HasNonfatalFailureHelper() {\n  return testing::Test::HasNonfatalFailure();\n}\n\nTEST(HasNonfatalFailureTest, WorksOutsideOfTestBody) {\n  EXPECT_FALSE(HasNonfatalFailureHelper());\n}\n\nTEST(HasNonfatalFailureTest, WorksOutsideOfTestBody2) {\n  ADD_FAILURE();\n  const bool has_nonfatal_failure = HasNonfatalFailureHelper();\n  ClearCurrentTestPartResults();\n  EXPECT_TRUE(has_nonfatal_failure);\n}\n\nTEST(HasFailureTest, ReturnsFalseWhenThereIsNoFailure) {\n  EXPECT_FALSE(HasFailure());\n}\n\nTEST(HasFailureTest, ReturnsTrueWhenThereIsFatalFailure) {\n  FailFatally();\n  const bool has_failure = HasFailure();\n  ClearCurrentTestPartResults();\n  EXPECT_TRUE(has_failure);\n}\n\nTEST(HasFailureTest, ReturnsTrueWhenThereIsNonfatalFailure) {\n  ADD_FAILURE();\n  const bool has_failure = HasFailure();\n  ClearCurrentTestPartResults();\n  EXPECT_TRUE(has_failure);\n}\n\nTEST(HasFailureTest, ReturnsTrueWhenThereAreFatalAndNonfatalFailures) {\n  FailFatally();\n  ADD_FAILURE();\n  const bool has_failure = HasFailure();\n  ClearCurrentTestPartResults();\n  EXPECT_TRUE(has_failure);\n}\n\n// A wrapper for calling HasFailure outside of a test body.\nstatic bool HasFailureHelper() { return testing::Test::HasFailure(); }\n\nTEST(HasFailureTest, WorksOutsideOfTestBody) {\n  EXPECT_FALSE(HasFailureHelper());\n}\n\nTEST(HasFailureTest, WorksOutsideOfTestBody2) {\n  ADD_FAILURE();\n  const bool has_failure = HasFailureHelper();\n  ClearCurrentTestPartResults();\n  EXPECT_TRUE(has_failure);\n}\n\nclass TestListener : public EmptyTestEventListener {\n public:\n  TestListener() : on_start_counter_(NULL), is_destroyed_(NULL) {}\n  TestListener(int* on_start_counter, bool* is_destroyed)\n      : on_start_counter_(on_start_counter),\n        is_destroyed_(is_destroyed) {}\n\n  virtual ~TestListener() {\n    if (is_destroyed_)\n      *is_destroyed_ = true;\n  }\n\n protected:\n  virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {\n    if (on_start_counter_ != NULL)\n      (*on_start_counter_)++;\n  }\n\n private:\n  int* on_start_counter_;\n  bool* is_destroyed_;\n};\n\n// Tests the constructor.\nTEST(TestEventListenersTest, ConstructionWorks) {\n  TestEventListeners listeners;\n\n  EXPECT_TRUE(TestEventListenersAccessor::GetRepeater(&listeners) != NULL);\n  EXPECT_TRUE(listeners.default_result_printer() == NULL);\n  EXPECT_TRUE(listeners.default_xml_generator() == NULL);\n}\n\n// Tests that the TestEventListeners destructor deletes all the listeners it\n// owns.\nTEST(TestEventListenersTest, DestructionWorks) {\n  bool default_result_printer_is_destroyed = false;\n  bool default_xml_printer_is_destroyed = false;\n  bool extra_listener_is_destroyed = false;\n  TestListener* default_result_printer = new TestListener(\n      NULL, &default_result_printer_is_destroyed);\n  TestListener* default_xml_printer = new TestListener(\n      NULL, &default_xml_printer_is_destroyed);\n  TestListener* extra_listener = new TestListener(\n      NULL, &extra_listener_is_destroyed);\n\n  {\n    TestEventListeners listeners;\n    TestEventListenersAccessor::SetDefaultResultPrinter(&listeners,\n                                                        default_result_printer);\n    TestEventListenersAccessor::SetDefaultXmlGenerator(&listeners,\n                                                       default_xml_printer);\n    listeners.Append(extra_listener);\n  }\n  EXPECT_TRUE(default_result_printer_is_destroyed);\n  EXPECT_TRUE(default_xml_printer_is_destroyed);\n  EXPECT_TRUE(extra_listener_is_destroyed);\n}\n\n// Tests that a listener Append'ed to a TestEventListeners list starts\n// receiving events.\nTEST(TestEventListenersTest, Append) {\n  int on_start_counter = 0;\n  bool is_destroyed = false;\n  TestListener* listener = new TestListener(&on_start_counter, &is_destroyed);\n  {\n    TestEventListeners listeners;\n    listeners.Append(listener);\n    TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(\n        *UnitTest::GetInstance());\n    EXPECT_EQ(1, on_start_counter);\n  }\n  EXPECT_TRUE(is_destroyed);\n}\n\n// Tests that listeners receive events in the order they were appended to\n// the list, except for *End requests, which must be received in the reverse\n// order.\nclass SequenceTestingListener : public EmptyTestEventListener {\n public:\n  SequenceTestingListener(std::vector<std::string>* vector, const char* id)\n      : vector_(vector), id_(id) {}\n\n protected:\n  virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {\n    vector_->push_back(GetEventDescription(\"OnTestProgramStart\"));\n  }\n\n  virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {\n    vector_->push_back(GetEventDescription(\"OnTestProgramEnd\"));\n  }\n\n  virtual void OnTestIterationStart(const UnitTest& /*unit_test*/,\n                                    int /*iteration*/) {\n    vector_->push_back(GetEventDescription(\"OnTestIterationStart\"));\n  }\n\n  virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/,\n                                  int /*iteration*/) {\n    vector_->push_back(GetEventDescription(\"OnTestIterationEnd\"));\n  }\n\n private:\n  std::string GetEventDescription(const char* method) {\n    Message message;\n    message << id_ << \".\" << method;\n    return message.GetString();\n  }\n\n  std::vector<std::string>* vector_;\n  const char* const id_;\n\n  GTEST_DISALLOW_COPY_AND_ASSIGN_(SequenceTestingListener);\n};\n\nTEST(EventListenerTest, AppendKeepsOrder) {\n  std::vector<std::string> vec;\n  TestEventListeners listeners;\n  listeners.Append(new SequenceTestingListener(&vec, \"1st\"));\n  listeners.Append(new SequenceTestingListener(&vec, \"2nd\"));\n  listeners.Append(new SequenceTestingListener(&vec, \"3rd\"));\n\n  TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(\n      *UnitTest::GetInstance());\n  ASSERT_EQ(3U, vec.size());\n  EXPECT_STREQ(\"1st.OnTestProgramStart\", vec[0].c_str());\n  EXPECT_STREQ(\"2nd.OnTestProgramStart\", vec[1].c_str());\n  EXPECT_STREQ(\"3rd.OnTestProgramStart\", vec[2].c_str());\n\n  vec.clear();\n  TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramEnd(\n      *UnitTest::GetInstance());\n  ASSERT_EQ(3U, vec.size());\n  EXPECT_STREQ(\"3rd.OnTestProgramEnd\", vec[0].c_str());\n  EXPECT_STREQ(\"2nd.OnTestProgramEnd\", vec[1].c_str());\n  EXPECT_STREQ(\"1st.OnTestProgramEnd\", vec[2].c_str());\n\n  vec.clear();\n  TestEventListenersAccessor::GetRepeater(&listeners)->OnTestIterationStart(\n      *UnitTest::GetInstance(), 0);\n  ASSERT_EQ(3U, vec.size());\n  EXPECT_STREQ(\"1st.OnTestIterationStart\", vec[0].c_str());\n  EXPECT_STREQ(\"2nd.OnTestIterationStart\", vec[1].c_str());\n  EXPECT_STREQ(\"3rd.OnTestIterationStart\", vec[2].c_str());\n\n  vec.clear();\n  TestEventListenersAccessor::GetRepeater(&listeners)->OnTestIterationEnd(\n      *UnitTest::GetInstance(), 0);\n  ASSERT_EQ(3U, vec.size());\n  EXPECT_STREQ(\"3rd.OnTestIterationEnd\", vec[0].c_str());\n  EXPECT_STREQ(\"2nd.OnTestIterationEnd\", vec[1].c_str());\n  EXPECT_STREQ(\"1st.OnTestIterationEnd\", vec[2].c_str());\n}\n\n// Tests that a listener removed from a TestEventListeners list stops receiving\n// events and is not deleted when the list is destroyed.\nTEST(TestEventListenersTest, Release) {\n  int on_start_counter = 0;\n  bool is_destroyed = false;\n  // Although Append passes the ownership of this object to the list,\n  // the following calls release it, and we need to delete it before the\n  // test ends.\n  TestListener* listener = new TestListener(&on_start_counter, &is_destroyed);\n  {\n    TestEventListeners listeners;\n    listeners.Append(listener);\n    EXPECT_EQ(listener, listeners.Release(listener));\n    TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(\n        *UnitTest::GetInstance());\n    EXPECT_TRUE(listeners.Release(listener) == NULL);\n  }\n  EXPECT_EQ(0, on_start_counter);\n  EXPECT_FALSE(is_destroyed);\n  delete listener;\n}\n\n// Tests that no events are forwarded when event forwarding is disabled.\nTEST(EventListenerTest, SuppressEventForwarding) {\n  int on_start_counter = 0;\n  TestListener* listener = new TestListener(&on_start_counter, NULL);\n\n  TestEventListeners listeners;\n  listeners.Append(listener);\n  ASSERT_TRUE(TestEventListenersAccessor::EventForwardingEnabled(listeners));\n  TestEventListenersAccessor::SuppressEventForwarding(&listeners);\n  ASSERT_FALSE(TestEventListenersAccessor::EventForwardingEnabled(listeners));\n  TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(\n      *UnitTest::GetInstance());\n  EXPECT_EQ(0, on_start_counter);\n}\n\n// Tests that events generated by Google Test are not forwarded in\n// death test subprocesses.\nTEST(EventListenerDeathTest, EventsNotForwardedInDeathTestSubprecesses) {\n  EXPECT_DEATH_IF_SUPPORTED({\n      GTEST_CHECK_(TestEventListenersAccessor::EventForwardingEnabled(\n          *GetUnitTestImpl()->listeners())) << \"expected failure\";},\n      \"expected failure\");\n}\n\n// Tests that a listener installed via SetDefaultResultPrinter() starts\n// receiving events and is returned via default_result_printer() and that\n// the previous default_result_printer is removed from the list and deleted.\nTEST(EventListenerTest, default_result_printer) {\n  int on_start_counter = 0;\n  bool is_destroyed = false;\n  TestListener* listener = new TestListener(&on_start_counter, &is_destroyed);\n\n  TestEventListeners listeners;\n  TestEventListenersAccessor::SetDefaultResultPrinter(&listeners, listener);\n\n  EXPECT_EQ(listener, listeners.default_result_printer());\n\n  TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(\n      *UnitTest::GetInstance());\n\n  EXPECT_EQ(1, on_start_counter);\n\n  // Replacing default_result_printer with something else should remove it\n  // from the list and destroy it.\n  TestEventListenersAccessor::SetDefaultResultPrinter(&listeners, NULL);\n\n  EXPECT_TRUE(listeners.default_result_printer() == NULL);\n  EXPECT_TRUE(is_destroyed);\n\n  // After broadcasting an event the counter is still the same, indicating\n  // the listener is not in the list anymore.\n  TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(\n      *UnitTest::GetInstance());\n  EXPECT_EQ(1, on_start_counter);\n}\n\n// Tests that the default_result_printer listener stops receiving events\n// when removed via Release and that is not owned by the list anymore.\nTEST(EventListenerTest, RemovingDefaultResultPrinterWorks) {\n  int on_start_counter = 0;\n  bool is_destroyed = false;\n  // Although Append passes the ownership of this object to the list,\n  // the following calls release it, and we need to delete it before the\n  // test ends.\n  TestListener* listener = new TestListener(&on_start_counter, &is_destroyed);\n  {\n    TestEventListeners listeners;\n    TestEventListenersAccessor::SetDefaultResultPrinter(&listeners, listener);\n\n    EXPECT_EQ(listener, listeners.Release(listener));\n    EXPECT_TRUE(listeners.default_result_printer() == NULL);\n    EXPECT_FALSE(is_destroyed);\n\n    // Broadcasting events now should not affect default_result_printer.\n    TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(\n        *UnitTest::GetInstance());\n    EXPECT_EQ(0, on_start_counter);\n  }\n  // Destroying the list should not affect the listener now, too.\n  EXPECT_FALSE(is_destroyed);\n  delete listener;\n}\n\n// Tests that a listener installed via SetDefaultXmlGenerator() starts\n// receiving events and is returned via default_xml_generator() and that\n// the previous default_xml_generator is removed from the list and deleted.\nTEST(EventListenerTest, default_xml_generator) {\n  int on_start_counter = 0;\n  bool is_destroyed = false;\n  TestListener* listener = new TestListener(&on_start_counter, &is_destroyed);\n\n  TestEventListeners listeners;\n  TestEventListenersAccessor::SetDefaultXmlGenerator(&listeners, listener);\n\n  EXPECT_EQ(listener, listeners.default_xml_generator());\n\n  TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(\n      *UnitTest::GetInstance());\n\n  EXPECT_EQ(1, on_start_counter);\n\n  // Replacing default_xml_generator with something else should remove it\n  // from the list and destroy it.\n  TestEventListenersAccessor::SetDefaultXmlGenerator(&listeners, NULL);\n\n  EXPECT_TRUE(listeners.default_xml_generator() == NULL);\n  EXPECT_TRUE(is_destroyed);\n\n  // After broadcasting an event the counter is still the same, indicating\n  // the listener is not in the list anymore.\n  TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(\n      *UnitTest::GetInstance());\n  EXPECT_EQ(1, on_start_counter);\n}\n\n// Tests that the default_xml_generator listener stops receiving events\n// when removed via Release and that is not owned by the list anymore.\nTEST(EventListenerTest, RemovingDefaultXmlGeneratorWorks) {\n  int on_start_counter = 0;\n  bool is_destroyed = false;\n  // Although Append passes the ownership of this object to the list,\n  // the following calls release it, and we need to delete it before the\n  // test ends.\n  TestListener* listener = new TestListener(&on_start_counter, &is_destroyed);\n  {\n    TestEventListeners listeners;\n    TestEventListenersAccessor::SetDefaultXmlGenerator(&listeners, listener);\n\n    EXPECT_EQ(listener, listeners.Release(listener));\n    EXPECT_TRUE(listeners.default_xml_generator() == NULL);\n    EXPECT_FALSE(is_destroyed);\n\n    // Broadcasting events now should not affect default_xml_generator.\n    TestEventListenersAccessor::GetRepeater(&listeners)->OnTestProgramStart(\n        *UnitTest::GetInstance());\n    EXPECT_EQ(0, on_start_counter);\n  }\n  // Destroying the list should not affect the listener now, too.\n  EXPECT_FALSE(is_destroyed);\n  delete listener;\n}\n\n// Sanity tests to ensure that the alternative, verbose spellings of\n// some of the macros work.  We don't test them thoroughly as that\n// would be quite involved.  Since their implementations are\n// straightforward, and they are rarely used, we'll just rely on the\n// users to tell us when they are broken.\nGTEST_TEST(AlternativeNameTest, Works) {  // GTEST_TEST is the same as TEST.\n  GTEST_SUCCEED() << \"OK\";  // GTEST_SUCCEED is the same as SUCCEED.\n\n  // GTEST_FAIL is the same as FAIL.\n  EXPECT_FATAL_FAILURE(GTEST_FAIL() << \"An expected failure\",\n                       \"An expected failure\");\n\n  // GTEST_ASSERT_XY is the same as ASSERT_XY.\n\n  GTEST_ASSERT_EQ(0, 0);\n  EXPECT_FATAL_FAILURE(GTEST_ASSERT_EQ(0, 1) << \"An expected failure\",\n                       \"An expected failure\");\n  EXPECT_FATAL_FAILURE(GTEST_ASSERT_EQ(1, 0) << \"An expected failure\",\n                       \"An expected failure\");\n\n  GTEST_ASSERT_NE(0, 1);\n  GTEST_ASSERT_NE(1, 0);\n  EXPECT_FATAL_FAILURE(GTEST_ASSERT_NE(0, 0) << \"An expected failure\",\n                       \"An expected failure\");\n\n  GTEST_ASSERT_LE(0, 0);\n  GTEST_ASSERT_LE(0, 1);\n  EXPECT_FATAL_FAILURE(GTEST_ASSERT_LE(1, 0) << \"An expected failure\",\n                       \"An expected failure\");\n\n  GTEST_ASSERT_LT(0, 1);\n  EXPECT_FATAL_FAILURE(GTEST_ASSERT_LT(0, 0) << \"An expected failure\",\n                       \"An expected failure\");\n  EXPECT_FATAL_FAILURE(GTEST_ASSERT_LT(1, 0) << \"An expected failure\",\n                       \"An expected failure\");\n\n  GTEST_ASSERT_GE(0, 0);\n  GTEST_ASSERT_GE(1, 0);\n  EXPECT_FATAL_FAILURE(GTEST_ASSERT_GE(0, 1) << \"An expected failure\",\n                       \"An expected failure\");\n\n  GTEST_ASSERT_GT(1, 0);\n  EXPECT_FATAL_FAILURE(GTEST_ASSERT_GT(0, 1) << \"An expected failure\",\n                       \"An expected failure\");\n  EXPECT_FATAL_FAILURE(GTEST_ASSERT_GT(1, 1) << \"An expected failure\",\n                       \"An expected failure\");\n}\n\n// Tests for internal utilities necessary for implementation of the universal\n// printing.\n// TODO(vladl@google.com): Find a better home for them.\n\nclass ConversionHelperBase {};\nclass ConversionHelperDerived : public ConversionHelperBase {};\n\n// Tests that IsAProtocolMessage<T>::value is a compile-time constant.\nTEST(IsAProtocolMessageTest, ValueIsCompileTimeConstant) {\n  GTEST_COMPILE_ASSERT_(IsAProtocolMessage<ProtocolMessage>::value,\n                        const_true);\n  GTEST_COMPILE_ASSERT_(!IsAProtocolMessage<int>::value, const_false);\n}\n\n// Tests that IsAProtocolMessage<T>::value is true when T is\n// proto2::Message or a sub-class of it.\nTEST(IsAProtocolMessageTest, ValueIsTrueWhenTypeIsAProtocolMessage) {\n  EXPECT_TRUE(IsAProtocolMessage< ::proto2::Message>::value);\n  EXPECT_TRUE(IsAProtocolMessage<ProtocolMessage>::value);\n}\n\n// Tests that IsAProtocolMessage<T>::value is false when T is neither\n// ProtocolMessage nor a sub-class of it.\nTEST(IsAProtocolMessageTest, ValueIsFalseWhenTypeIsNotAProtocolMessage) {\n  EXPECT_FALSE(IsAProtocolMessage<int>::value);\n  EXPECT_FALSE(IsAProtocolMessage<const ConversionHelperBase>::value);\n}\n\n// Tests that CompileAssertTypesEqual compiles when the type arguments are\n// equal.\nTEST(CompileAssertTypesEqual, CompilesWhenTypesAreEqual) {\n  CompileAssertTypesEqual<void, void>();\n  CompileAssertTypesEqual<int*, int*>();\n}\n\n// Tests that RemoveReference does not affect non-reference types.\nTEST(RemoveReferenceTest, DoesNotAffectNonReferenceType) {\n  CompileAssertTypesEqual<int, RemoveReference<int>::type>();\n  CompileAssertTypesEqual<const char, RemoveReference<const char>::type>();\n}\n\n// Tests that RemoveReference removes reference from reference types.\nTEST(RemoveReferenceTest, RemovesReference) {\n  CompileAssertTypesEqual<int, RemoveReference<int&>::type>();\n  CompileAssertTypesEqual<const char, RemoveReference<const char&>::type>();\n}\n\n// Tests GTEST_REMOVE_REFERENCE_.\n\ntemplate <typename T1, typename T2>\nvoid TestGTestRemoveReference() {\n  CompileAssertTypesEqual<T1, GTEST_REMOVE_REFERENCE_(T2)>();\n}\n\nTEST(RemoveReferenceTest, MacroVersion) {\n  TestGTestRemoveReference<int, int>();\n  TestGTestRemoveReference<const char, const char&>();\n}\n\n\n// Tests that RemoveConst does not affect non-const types.\nTEST(RemoveConstTest, DoesNotAffectNonConstType) {\n  CompileAssertTypesEqual<int, RemoveConst<int>::type>();\n  CompileAssertTypesEqual<char&, RemoveConst<char&>::type>();\n}\n\n// Tests that RemoveConst removes const from const types.\nTEST(RemoveConstTest, RemovesConst) {\n  CompileAssertTypesEqual<int, RemoveConst<const int>::type>();\n  CompileAssertTypesEqual<char[2], RemoveConst<const char[2]>::type>();\n  CompileAssertTypesEqual<char[2][3], RemoveConst<const char[2][3]>::type>();\n}\n\n// Tests GTEST_REMOVE_CONST_.\n\ntemplate <typename T1, typename T2>\nvoid TestGTestRemoveConst() {\n  CompileAssertTypesEqual<T1, GTEST_REMOVE_CONST_(T2)>();\n}\n\nTEST(RemoveConstTest, MacroVersion) {\n  TestGTestRemoveConst<int, int>();\n  TestGTestRemoveConst<double&, double&>();\n  TestGTestRemoveConst<char, const char>();\n}\n\n// Tests GTEST_REMOVE_REFERENCE_AND_CONST_.\n\ntemplate <typename T1, typename T2>\nvoid TestGTestRemoveReferenceAndConst() {\n  CompileAssertTypesEqual<T1, GTEST_REMOVE_REFERENCE_AND_CONST_(T2)>();\n}\n\nTEST(RemoveReferenceToConstTest, Works) {\n  TestGTestRemoveReferenceAndConst<int, int>();\n  TestGTestRemoveReferenceAndConst<double, double&>();\n  TestGTestRemoveReferenceAndConst<char, const char>();\n  TestGTestRemoveReferenceAndConst<char, const char&>();\n  TestGTestRemoveReferenceAndConst<const char*, const char*>();\n}\n\n// Tests that AddReference does not affect reference types.\nTEST(AddReferenceTest, DoesNotAffectReferenceType) {\n  CompileAssertTypesEqual<int&, AddReference<int&>::type>();\n  CompileAssertTypesEqual<const char&, AddReference<const char&>::type>();\n}\n\n// Tests that AddReference adds reference to non-reference types.\nTEST(AddReferenceTest, AddsReference) {\n  CompileAssertTypesEqual<int&, AddReference<int>::type>();\n  CompileAssertTypesEqual<const char&, AddReference<const char>::type>();\n}\n\n// Tests GTEST_ADD_REFERENCE_.\n\ntemplate <typename T1, typename T2>\nvoid TestGTestAddReference() {\n  CompileAssertTypesEqual<T1, GTEST_ADD_REFERENCE_(T2)>();\n}\n\nTEST(AddReferenceTest, MacroVersion) {\n  TestGTestAddReference<int&, int>();\n  TestGTestAddReference<const char&, const char&>();\n}\n\n// Tests GTEST_REFERENCE_TO_CONST_.\n\ntemplate <typename T1, typename T2>\nvoid TestGTestReferenceToConst() {\n  CompileAssertTypesEqual<T1, GTEST_REFERENCE_TO_CONST_(T2)>();\n}\n\nTEST(GTestReferenceToConstTest, Works) {\n  TestGTestReferenceToConst<const char&, char>();\n  TestGTestReferenceToConst<const int&, const int>();\n  TestGTestReferenceToConst<const double&, double>();\n  TestGTestReferenceToConst<const std::string&, const std::string&>();\n}\n\n// Tests that ImplicitlyConvertible<T1, T2>::value is a compile-time constant.\nTEST(ImplicitlyConvertibleTest, ValueIsCompileTimeConstant) {\n  GTEST_COMPILE_ASSERT_((ImplicitlyConvertible<int, int>::value), const_true);\n  GTEST_COMPILE_ASSERT_((!ImplicitlyConvertible<void*, int*>::value),\n                        const_false);\n}\n\n// Tests that ImplicitlyConvertible<T1, T2>::value is true when T1 can\n// be implicitly converted to T2.\nTEST(ImplicitlyConvertibleTest, ValueIsTrueWhenConvertible) {\n  EXPECT_TRUE((ImplicitlyConvertible<int, double>::value));\n  EXPECT_TRUE((ImplicitlyConvertible<double, int>::value));\n  EXPECT_TRUE((ImplicitlyConvertible<int*, void*>::value));\n  EXPECT_TRUE((ImplicitlyConvertible<int*, const int*>::value));\n  EXPECT_TRUE((ImplicitlyConvertible<ConversionHelperDerived&,\n                                     const ConversionHelperBase&>::value));\n  EXPECT_TRUE((ImplicitlyConvertible<const ConversionHelperBase,\n                                     ConversionHelperBase>::value));\n}\n\n// Tests that ImplicitlyConvertible<T1, T2>::value is false when T1\n// cannot be implicitly converted to T2.\nTEST(ImplicitlyConvertibleTest, ValueIsFalseWhenNotConvertible) {\n  EXPECT_FALSE((ImplicitlyConvertible<double, int*>::value));\n  EXPECT_FALSE((ImplicitlyConvertible<void*, int*>::value));\n  EXPECT_FALSE((ImplicitlyConvertible<const int*, int*>::value));\n  EXPECT_FALSE((ImplicitlyConvertible<ConversionHelperBase&,\n                                      ConversionHelperDerived&>::value));\n}\n\n// Tests IsContainerTest.\n\nclass NonContainer {};\n\nTEST(IsContainerTestTest, WorksForNonContainer) {\n  EXPECT_EQ(sizeof(IsNotContainer), sizeof(IsContainerTest<int>(0)));\n  EXPECT_EQ(sizeof(IsNotContainer), sizeof(IsContainerTest<char[5]>(0)));\n  EXPECT_EQ(sizeof(IsNotContainer), sizeof(IsContainerTest<NonContainer>(0)));\n}\n\nTEST(IsContainerTestTest, WorksForContainer) {\n  EXPECT_EQ(sizeof(IsContainer),\n            sizeof(IsContainerTest<std::vector<bool> >(0)));\n  EXPECT_EQ(sizeof(IsContainer),\n            sizeof(IsContainerTest<std::map<int, double> >(0)));\n}\n\n// Tests ArrayEq().\n\nTEST(ArrayEqTest, WorksForDegeneratedArrays) {\n  EXPECT_TRUE(ArrayEq(5, 5L));\n  EXPECT_FALSE(ArrayEq('a', 0));\n}\n\nTEST(ArrayEqTest, WorksForOneDimensionalArrays) {\n  // Note that a and b are distinct but compatible types.\n  const int a[] = { 0, 1 };\n  long b[] = { 0, 1 };\n  EXPECT_TRUE(ArrayEq(a, b));\n  EXPECT_TRUE(ArrayEq(a, 2, b));\n\n  b[0] = 2;\n  EXPECT_FALSE(ArrayEq(a, b));\n  EXPECT_FALSE(ArrayEq(a, 1, b));\n}\n\nTEST(ArrayEqTest, WorksForTwoDimensionalArrays) {\n  const char a[][3] = { \"hi\", \"lo\" };\n  const char b[][3] = { \"hi\", \"lo\" };\n  const char c[][3] = { \"hi\", \"li\" };\n\n  EXPECT_TRUE(ArrayEq(a, b));\n  EXPECT_TRUE(ArrayEq(a, 2, b));\n\n  EXPECT_FALSE(ArrayEq(a, c));\n  EXPECT_FALSE(ArrayEq(a, 2, c));\n}\n\n// Tests ArrayAwareFind().\n\nTEST(ArrayAwareFindTest, WorksForOneDimensionalArray) {\n  const char a[] = \"hello\";\n  EXPECT_EQ(a + 4, ArrayAwareFind(a, a + 5, 'o'));\n  EXPECT_EQ(a + 5, ArrayAwareFind(a, a + 5, 'x'));\n}\n\nTEST(ArrayAwareFindTest, WorksForTwoDimensionalArray) {\n  int a[][2] = { { 0, 1 }, { 2, 3 }, { 4, 5 } };\n  const int b[2] = { 2, 3 };\n  EXPECT_EQ(a + 1, ArrayAwareFind(a, a + 3, b));\n\n  const int c[2] = { 6, 7 };\n  EXPECT_EQ(a + 3, ArrayAwareFind(a, a + 3, c));\n}\n\n// Tests CopyArray().\n\nTEST(CopyArrayTest, WorksForDegeneratedArrays) {\n  int n = 0;\n  CopyArray('a', &n);\n  EXPECT_EQ('a', n);\n}\n\nTEST(CopyArrayTest, WorksForOneDimensionalArrays) {\n  const char a[3] = \"hi\";\n  int b[3];\n#ifndef __BORLANDC__  // C++Builder cannot compile some array size deductions.\n  CopyArray(a, &b);\n  EXPECT_TRUE(ArrayEq(a, b));\n#endif\n\n  int c[3];\n  CopyArray(a, 3, c);\n  EXPECT_TRUE(ArrayEq(a, c));\n}\n\nTEST(CopyArrayTest, WorksForTwoDimensionalArrays) {\n  const int a[2][3] = { { 0, 1, 2 }, { 3, 4, 5 } };\n  int b[2][3];\n#ifndef __BORLANDC__  // C++Builder cannot compile some array size deductions.\n  CopyArray(a, &b);\n  EXPECT_TRUE(ArrayEq(a, b));\n#endif\n\n  int c[2][3];\n  CopyArray(a, 2, c);\n  EXPECT_TRUE(ArrayEq(a, c));\n}\n\n// Tests NativeArray.\n\nTEST(NativeArrayTest, ConstructorFromArrayWorks) {\n  const int a[3] = { 0, 1, 2 };\n  NativeArray<int> na(a, 3, kReference);\n  EXPECT_EQ(3U, na.size());\n  EXPECT_EQ(a, na.begin());\n}\n\nTEST(NativeArrayTest, CreatesAndDeletesCopyOfArrayWhenAskedTo) {\n  typedef int Array[2];\n  Array* a = new Array[1];\n  (*a)[0] = 0;\n  (*a)[1] = 1;\n  NativeArray<int> na(*a, 2, kCopy);\n  EXPECT_NE(*a, na.begin());\n  delete[] a;\n  EXPECT_EQ(0, na.begin()[0]);\n  EXPECT_EQ(1, na.begin()[1]);\n\n  // We rely on the heap checker to verify that na deletes the copy of\n  // array.\n}\n\nTEST(NativeArrayTest, TypeMembersAreCorrect) {\n  StaticAssertTypeEq<char, NativeArray<char>::value_type>();\n  StaticAssertTypeEq<int[2], NativeArray<int[2]>::value_type>();\n\n  StaticAssertTypeEq<const char*, NativeArray<char>::const_iterator>();\n  StaticAssertTypeEq<const bool(*)[2], NativeArray<bool[2]>::const_iterator>();\n}\n\nTEST(NativeArrayTest, MethodsWork) {\n  const int a[3] = { 0, 1, 2 };\n  NativeArray<int> na(a, 3, kCopy);\n  ASSERT_EQ(3U, na.size());\n  EXPECT_EQ(3, na.end() - na.begin());\n\n  NativeArray<int>::const_iterator it = na.begin();\n  EXPECT_EQ(0, *it);\n  ++it;\n  EXPECT_EQ(1, *it);\n  it++;\n  EXPECT_EQ(2, *it);\n  ++it;\n  EXPECT_EQ(na.end(), it);\n\n  EXPECT_TRUE(na == na);\n\n  NativeArray<int> na2(a, 3, kReference);\n  EXPECT_TRUE(na == na2);\n\n  const int b1[3] = { 0, 1, 1 };\n  const int b2[4] = { 0, 1, 2, 3 };\n  EXPECT_FALSE(na == NativeArray<int>(b1, 3, kReference));\n  EXPECT_FALSE(na == NativeArray<int>(b2, 4, kCopy));\n}\n\nTEST(NativeArrayTest, WorksForTwoDimensionalArray) {\n  const char a[2][3] = { \"hi\", \"lo\" };\n  NativeArray<char[3]> na(a, 2, kReference);\n  ASSERT_EQ(2U, na.size());\n  EXPECT_EQ(a, na.begin());\n}\n\n// Tests SkipPrefix().\n\nTEST(SkipPrefixTest, SkipsWhenPrefixMatches) {\n  const char* const str = \"hello\";\n\n  const char* p = str;\n  EXPECT_TRUE(SkipPrefix(\"\", &p));\n  EXPECT_EQ(str, p);\n\n  p = str;\n  EXPECT_TRUE(SkipPrefix(\"hell\", &p));\n  EXPECT_EQ(str + 4, p);\n}\n\nTEST(SkipPrefixTest, DoesNotSkipWhenPrefixDoesNotMatch) {\n  const char* const str = \"world\";\n\n  const char* p = str;\n  EXPECT_FALSE(SkipPrefix(\"W\", &p));\n  EXPECT_EQ(str, p);\n\n  p = str;\n  EXPECT_FALSE(SkipPrefix(\"world!\", &p));\n  EXPECT_EQ(str, p);\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest_xml_outfile1_test_.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: keith.ray@gmail.com (Keith Ray)\n//\n// gtest_xml_outfile1_test_ writes some xml via TestProperty used by\n// gtest_xml_outfiles_test.py\n\n#include \"gtest/gtest.h\"\n\nclass PropertyOne : public testing::Test {\n protected:\n  virtual void SetUp() {\n    RecordProperty(\"SetUpProp\", 1);\n  }\n  virtual void TearDown() {\n    RecordProperty(\"TearDownProp\", 1);\n  }\n};\n\nTEST_F(PropertyOne, TestSomeProperties) {\n  RecordProperty(\"TestSomeProperty\", 1);\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest_xml_outfile2_test_.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: keith.ray@gmail.com (Keith Ray)\n//\n// gtest_xml_outfile2_test_ writes some xml via TestProperty used by\n// gtest_xml_outfiles_test.py\n\n#include \"gtest/gtest.h\"\n\nclass PropertyTwo : public testing::Test {\n protected:\n  virtual void SetUp() {\n    RecordProperty(\"SetUpProp\", 2);\n  }\n  virtual void TearDown() {\n    RecordProperty(\"TearDownProp\", 2);\n  }\n};\n\nTEST_F(PropertyTwo, TestSomeProperties) {\n  RecordProperty(\"TestSomeProperty\", 2);\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest_xml_outfiles_test.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2008, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Unit test for the gtest_xml_output module.\"\"\"\n\n__author__ = \"keith.ray@gmail.com (Keith Ray)\"\n\nimport os\nfrom xml.dom import minidom, Node\n\nimport gtest_test_utils\nimport gtest_xml_test_utils\n\n\nGTEST_OUTPUT_SUBDIR = \"xml_outfiles\"\nGTEST_OUTPUT_1_TEST = \"gtest_xml_outfile1_test_\"\nGTEST_OUTPUT_2_TEST = \"gtest_xml_outfile2_test_\"\n\nEXPECTED_XML_1 = \"\"\"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<testsuites tests=\"1\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\" timestamp=\"*\" name=\"AllTests\">\n  <testsuite name=\"PropertyOne\" tests=\"1\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\">\n    <testcase name=\"TestSomeProperties\" status=\"run\" time=\"*\" classname=\"PropertyOne\" SetUpProp=\"1\" TestSomeProperty=\"1\" TearDownProp=\"1\" />\n  </testsuite>\n</testsuites>\n\"\"\"\n\nEXPECTED_XML_2 = \"\"\"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<testsuites tests=\"1\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\" timestamp=\"*\" name=\"AllTests\">\n  <testsuite name=\"PropertyTwo\" tests=\"1\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\">\n    <testcase name=\"TestSomeProperties\" status=\"run\" time=\"*\" classname=\"PropertyTwo\" SetUpProp=\"2\" TestSomeProperty=\"2\" TearDownProp=\"2\" />\n  </testsuite>\n</testsuites>\n\"\"\"\n\n\nclass GTestXMLOutFilesTest(gtest_xml_test_utils.GTestXMLTestCase):\n  \"\"\"Unit test for Google Test's XML output functionality.\"\"\"\n\n  def setUp(self):\n    # We want the trailing '/' that the last \"\" provides in os.path.join, for\n    # telling Google Test to create an output directory instead of a single file\n    # for xml output.\n    self.output_dir_ = os.path.join(gtest_test_utils.GetTempDir(),\n                                    GTEST_OUTPUT_SUBDIR, \"\")\n    self.DeleteFilesAndDir()\n\n  def tearDown(self):\n    self.DeleteFilesAndDir()\n\n  def DeleteFilesAndDir(self):\n    try:\n      os.remove(os.path.join(self.output_dir_, GTEST_OUTPUT_1_TEST + \".xml\"))\n    except os.error:\n      pass\n    try:\n      os.remove(os.path.join(self.output_dir_, GTEST_OUTPUT_2_TEST + \".xml\"))\n    except os.error:\n      pass\n    try:\n      os.rmdir(self.output_dir_)\n    except os.error:\n      pass\n\n  def testOutfile1(self):\n    self._TestOutFile(GTEST_OUTPUT_1_TEST, EXPECTED_XML_1)\n\n  def testOutfile2(self):\n    self._TestOutFile(GTEST_OUTPUT_2_TEST, EXPECTED_XML_2)\n\n  def _TestOutFile(self, test_name, expected_xml):\n    gtest_prog_path = gtest_test_utils.GetTestExecutablePath(test_name)\n    command = [gtest_prog_path, \"--gtest_output=xml:%s\" % self.output_dir_]\n    p = gtest_test_utils.Subprocess(command,\n                                    working_dir=gtest_test_utils.GetTempDir())\n    self.assert_(p.exited)\n    self.assertEquals(0, p.exit_code)\n\n    # TODO(wan@google.com): libtool causes the built test binary to be\n    #   named lt-gtest_xml_outfiles_test_ instead of\n    #   gtest_xml_outfiles_test_.  To account for this possibillity, we\n    #   allow both names in the following code.  We should remove this\n    #   hack when Chandler Carruth's libtool replacement tool is ready.\n    output_file_name1 = test_name + \".xml\"\n    output_file1 = os.path.join(self.output_dir_, output_file_name1)\n    output_file_name2 = 'lt-' + output_file_name1\n    output_file2 = os.path.join(self.output_dir_, output_file_name2)\n    self.assert_(os.path.isfile(output_file1) or os.path.isfile(output_file2),\n                 output_file1)\n\n    expected = minidom.parseString(expected_xml)\n    if os.path.isfile(output_file1):\n      actual = minidom.parse(output_file1)\n    else:\n      actual = minidom.parse(output_file2)\n    self.NormalizeXml(actual.documentElement)\n    self.AssertEquivalentNodes(expected.documentElement,\n                               actual.documentElement)\n    expected.unlink()\n    actual.unlink()\n\n\nif __name__ == \"__main__\":\n  os.environ[\"GTEST_STACK_TRACE_DEPTH\"] = \"0\"\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "ext/gtest/test/gtest_xml_output_unittest.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2006, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Unit test for the gtest_xml_output module\"\"\"\n\n__author__ = 'eefacm@gmail.com (Sean Mcafee)'\n\nimport datetime\nimport errno\nimport os\nimport re\nimport sys\nfrom xml.dom import minidom, Node\n\nimport gtest_test_utils\nimport gtest_xml_test_utils\n\n\nGTEST_FILTER_FLAG = '--gtest_filter'\nGTEST_LIST_TESTS_FLAG = '--gtest_list_tests'\nGTEST_OUTPUT_FLAG         = \"--gtest_output\"\nGTEST_DEFAULT_OUTPUT_FILE = \"test_detail.xml\"\nGTEST_PROGRAM_NAME = \"gtest_xml_output_unittest_\"\n\nSUPPORTS_STACK_TRACES = False\n\nif SUPPORTS_STACK_TRACES:\n  STACK_TRACE_TEMPLATE = '\\nStack trace:\\n*'\nelse:\n  STACK_TRACE_TEMPLATE = ''\n\nEXPECTED_NON_EMPTY_XML = \"\"\"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<testsuites tests=\"23\" failures=\"4\" disabled=\"2\" errors=\"0\" time=\"*\" timestamp=\"*\" name=\"AllTests\" ad_hoc_property=\"42\">\n  <testsuite name=\"SuccessfulTest\" tests=\"1\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\">\n    <testcase name=\"Succeeds\" status=\"run\" time=\"*\" classname=\"SuccessfulTest\"/>\n  </testsuite>\n  <testsuite name=\"FailedTest\" tests=\"1\" failures=\"1\" disabled=\"0\" errors=\"0\" time=\"*\">\n    <testcase name=\"Fails\" status=\"run\" time=\"*\" classname=\"FailedTest\">\n      <failure message=\"gtest_xml_output_unittest_.cc:*&#x0A;Value of: 2&#x0A;Expected: 1\" type=\"\"><![CDATA[gtest_xml_output_unittest_.cc:*\nValue of: 2\nExpected: 1%(stack)s]]></failure>\n    </testcase>\n  </testsuite>\n  <testsuite name=\"MixedResultTest\" tests=\"3\" failures=\"1\" disabled=\"1\" errors=\"0\" time=\"*\">\n    <testcase name=\"Succeeds\" status=\"run\" time=\"*\" classname=\"MixedResultTest\"/>\n    <testcase name=\"Fails\" status=\"run\" time=\"*\" classname=\"MixedResultTest\">\n      <failure message=\"gtest_xml_output_unittest_.cc:*&#x0A;Value of: 2&#x0A;Expected: 1\" type=\"\"><![CDATA[gtest_xml_output_unittest_.cc:*\nValue of: 2\nExpected: 1%(stack)s]]></failure>\n      <failure message=\"gtest_xml_output_unittest_.cc:*&#x0A;Value of: 3&#x0A;Expected: 2\" type=\"\"><![CDATA[gtest_xml_output_unittest_.cc:*\nValue of: 3\nExpected: 2%(stack)s]]></failure>\n    </testcase>\n    <testcase name=\"DISABLED_test\" status=\"notrun\" time=\"*\" classname=\"MixedResultTest\"/>\n  </testsuite>\n  <testsuite name=\"XmlQuotingTest\" tests=\"1\" failures=\"1\" disabled=\"0\" errors=\"0\" time=\"*\">\n    <testcase name=\"OutputsCData\" status=\"run\" time=\"*\" classname=\"XmlQuotingTest\">\n      <failure message=\"gtest_xml_output_unittest_.cc:*&#x0A;Failed&#x0A;XML output: &lt;?xml encoding=&quot;utf-8&quot;&gt;&lt;top&gt;&lt;![CDATA[cdata text]]&gt;&lt;/top&gt;\" type=\"\"><![CDATA[gtest_xml_output_unittest_.cc:*\nFailed\nXML output: <?xml encoding=\"utf-8\"><top><![CDATA[cdata text]]>]]&gt;<![CDATA[</top>%(stack)s]]></failure>\n    </testcase>\n  </testsuite>\n  <testsuite name=\"InvalidCharactersTest\" tests=\"1\" failures=\"1\" disabled=\"0\" errors=\"0\" time=\"*\">\n    <testcase name=\"InvalidCharactersInMessage\" status=\"run\" time=\"*\" classname=\"InvalidCharactersTest\">\n      <failure message=\"gtest_xml_output_unittest_.cc:*&#x0A;Failed&#x0A;Invalid characters in brackets []\" type=\"\"><![CDATA[gtest_xml_output_unittest_.cc:*\nFailed\nInvalid characters in brackets []%(stack)s]]></failure>\n    </testcase>\n  </testsuite>\n  <testsuite name=\"DisabledTest\" tests=\"1\" failures=\"0\" disabled=\"1\" errors=\"0\" time=\"*\">\n    <testcase name=\"DISABLED_test_not_run\" status=\"notrun\" time=\"*\" classname=\"DisabledTest\"/>\n  </testsuite>\n  <testsuite name=\"PropertyRecordingTest\" tests=\"4\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\" SetUpTestCase=\"yes\" TearDownTestCase=\"aye\">\n    <testcase name=\"OneProperty\" status=\"run\" time=\"*\" classname=\"PropertyRecordingTest\" key_1=\"1\"/>\n    <testcase name=\"IntValuedProperty\" status=\"run\" time=\"*\" classname=\"PropertyRecordingTest\" key_int=\"1\"/>\n    <testcase name=\"ThreeProperties\" status=\"run\" time=\"*\" classname=\"PropertyRecordingTest\" key_1=\"1\" key_2=\"2\" key_3=\"3\"/>\n    <testcase name=\"TwoValuesForOneKeyUsesLastValue\" status=\"run\" time=\"*\" classname=\"PropertyRecordingTest\" key_1=\"2\"/>\n  </testsuite>\n  <testsuite name=\"NoFixtureTest\" tests=\"3\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\">\n     <testcase name=\"RecordProperty\" status=\"run\" time=\"*\" classname=\"NoFixtureTest\" key=\"1\"/>\n     <testcase name=\"ExternalUtilityThatCallsRecordIntValuedProperty\" status=\"run\" time=\"*\" classname=\"NoFixtureTest\" key_for_utility_int=\"1\"/>\n     <testcase name=\"ExternalUtilityThatCallsRecordStringValuedProperty\" status=\"run\" time=\"*\" classname=\"NoFixtureTest\" key_for_utility_string=\"1\"/>\n  </testsuite>\n  <testsuite name=\"Single/ValueParamTest\" tests=\"4\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\">\n    <testcase name=\"HasValueParamAttribute/0\" value_param=\"33\" status=\"run\" time=\"*\" classname=\"Single/ValueParamTest\" />\n    <testcase name=\"HasValueParamAttribute/1\" value_param=\"42\" status=\"run\" time=\"*\" classname=\"Single/ValueParamTest\" />\n    <testcase name=\"AnotherTestThatHasValueParamAttribute/0\" value_param=\"33\" status=\"run\" time=\"*\" classname=\"Single/ValueParamTest\" />\n    <testcase name=\"AnotherTestThatHasValueParamAttribute/1\" value_param=\"42\" status=\"run\" time=\"*\" classname=\"Single/ValueParamTest\" />\n  </testsuite>\n  <testsuite name=\"TypedTest/0\" tests=\"1\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\">\n    <testcase name=\"HasTypeParamAttribute\" type_param=\"*\" status=\"run\" time=\"*\" classname=\"TypedTest/0\" />\n  </testsuite>\n  <testsuite name=\"TypedTest/1\" tests=\"1\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\">\n    <testcase name=\"HasTypeParamAttribute\" type_param=\"*\" status=\"run\" time=\"*\" classname=\"TypedTest/1\" />\n  </testsuite>\n  <testsuite name=\"Single/TypeParameterizedTestCase/0\" tests=\"1\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\">\n    <testcase name=\"HasTypeParamAttribute\" type_param=\"*\" status=\"run\" time=\"*\" classname=\"Single/TypeParameterizedTestCase/0\" />\n  </testsuite>\n  <testsuite name=\"Single/TypeParameterizedTestCase/1\" tests=\"1\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\">\n    <testcase name=\"HasTypeParamAttribute\" type_param=\"*\" status=\"run\" time=\"*\" classname=\"Single/TypeParameterizedTestCase/1\" />\n  </testsuite>\n</testsuites>\"\"\" % {'stack': STACK_TRACE_TEMPLATE}\n\nEXPECTED_FILTERED_TEST_XML = \"\"\"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<testsuites tests=\"1\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\"\n            timestamp=\"*\" name=\"AllTests\" ad_hoc_property=\"42\">\n  <testsuite name=\"SuccessfulTest\" tests=\"1\" failures=\"0\" disabled=\"0\"\n             errors=\"0\" time=\"*\">\n    <testcase name=\"Succeeds\" status=\"run\" time=\"*\" classname=\"SuccessfulTest\"/>\n  </testsuite>\n</testsuites>\"\"\"\n\nEXPECTED_EMPTY_XML = \"\"\"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<testsuites tests=\"0\" failures=\"0\" disabled=\"0\" errors=\"0\" time=\"*\"\n            timestamp=\"*\" name=\"AllTests\">\n</testsuites>\"\"\"\n\nGTEST_PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath(GTEST_PROGRAM_NAME)\n\nSUPPORTS_TYPED_TESTS = 'TypedTest' in gtest_test_utils.Subprocess(\n    [GTEST_PROGRAM_PATH, GTEST_LIST_TESTS_FLAG], capture_stderr=False).output\n\n\nclass GTestXMLOutputUnitTest(gtest_xml_test_utils.GTestXMLTestCase):\n  \"\"\"\n  Unit test for Google Test's XML output functionality.\n  \"\"\"\n\n  # This test currently breaks on platforms that do not support typed and\n  # type-parameterized tests, so we don't run it under them.\n  if SUPPORTS_TYPED_TESTS:\n    def testNonEmptyXmlOutput(self):\n      \"\"\"\n      Runs a test program that generates a non-empty XML output, and\n      tests that the XML output is expected.\n      \"\"\"\n      self._TestXmlOutput(GTEST_PROGRAM_NAME, EXPECTED_NON_EMPTY_XML, 1)\n\n  def testEmptyXmlOutput(self):\n    \"\"\"Verifies XML output for a Google Test binary without actual tests.\n\n    Runs a test program that generates an empty XML output, and\n    tests that the XML output is expected.\n    \"\"\"\n\n    self._TestXmlOutput('gtest_no_test_unittest', EXPECTED_EMPTY_XML, 0)\n\n  def testTimestampValue(self):\n    \"\"\"Checks whether the timestamp attribute in the XML output is valid.\n\n    Runs a test program that generates an empty XML output, and checks if\n    the timestamp attribute in the testsuites tag is valid.\n    \"\"\"\n    actual = self._GetXmlOutput('gtest_no_test_unittest', [], 0)\n    date_time_str = actual.documentElement.getAttributeNode('timestamp').value\n    # datetime.strptime() is only available in Python 2.5+ so we have to\n    # parse the expected datetime manually.\n    match = re.match(r'(\\d+)-(\\d\\d)-(\\d\\d)T(\\d\\d):(\\d\\d):(\\d\\d)', date_time_str)\n    self.assertTrue(\n        re.match,\n        'XML datettime string %s has incorrect format' % date_time_str)\n    date_time_from_xml = datetime.datetime(\n        year=int(match.group(1)), month=int(match.group(2)),\n        day=int(match.group(3)), hour=int(match.group(4)),\n        minute=int(match.group(5)), second=int(match.group(6)))\n\n    time_delta = abs(datetime.datetime.now() - date_time_from_xml)\n    # timestamp value should be near the current local time\n    self.assertTrue(time_delta < datetime.timedelta(seconds=600),\n                    'time_delta is %s' % time_delta)\n    actual.unlink()\n\n  def testDefaultOutputFile(self):\n    \"\"\"\n    Confirms that Google Test produces an XML output file with the expected\n    default name if no name is explicitly specified.\n    \"\"\"\n    output_file = os.path.join(gtest_test_utils.GetTempDir(),\n                               GTEST_DEFAULT_OUTPUT_FILE)\n    gtest_prog_path = gtest_test_utils.GetTestExecutablePath(\n        'gtest_no_test_unittest')\n    try:\n      os.remove(output_file)\n    except OSError, e:\n      if e.errno != errno.ENOENT:\n        raise\n\n    p = gtest_test_utils.Subprocess(\n        [gtest_prog_path, '%s=xml' % GTEST_OUTPUT_FLAG],\n        working_dir=gtest_test_utils.GetTempDir())\n    self.assert_(p.exited)\n    self.assertEquals(0, p.exit_code)\n    self.assert_(os.path.isfile(output_file))\n\n  def testSuppressedXmlOutput(self):\n    \"\"\"\n    Tests that no XML file is generated if the default XML listener is\n    shut down before RUN_ALL_TESTS is invoked.\n    \"\"\"\n\n    xml_path = os.path.join(gtest_test_utils.GetTempDir(),\n                            GTEST_PROGRAM_NAME + 'out.xml')\n    if os.path.isfile(xml_path):\n      os.remove(xml_path)\n\n    command = [GTEST_PROGRAM_PATH,\n               '%s=xml:%s' % (GTEST_OUTPUT_FLAG, xml_path),\n               '--shut_down_xml']\n    p = gtest_test_utils.Subprocess(command)\n    if p.terminated_by_signal:\n      # p.signal is avalable only if p.terminated_by_signal is True.\n      self.assertFalse(\n          p.terminated_by_signal,\n          '%s was killed by signal %d' % (GTEST_PROGRAM_NAME, p.signal))\n    else:\n      self.assert_(p.exited)\n      self.assertEquals(1, p.exit_code,\n                        \"'%s' exited with code %s, which doesn't match \"\n                        'the expected exit code %s.'\n                        % (command, p.exit_code, 1))\n\n    self.assert_(not os.path.isfile(xml_path))\n\n  def testFilteredTestXmlOutput(self):\n    \"\"\"Verifies XML output when a filter is applied.\n\n    Runs a test program that executes only some tests and verifies that\n    non-selected tests do not show up in the XML output.\n    \"\"\"\n\n    self._TestXmlOutput(GTEST_PROGRAM_NAME, EXPECTED_FILTERED_TEST_XML, 0,\n                        extra_args=['%s=SuccessfulTest.*' % GTEST_FILTER_FLAG])\n\n  def _GetXmlOutput(self, gtest_prog_name, extra_args, expected_exit_code):\n    \"\"\"\n    Returns the xml output generated by running the program gtest_prog_name.\n    Furthermore, the program's exit code must be expected_exit_code.\n    \"\"\"\n    xml_path = os.path.join(gtest_test_utils.GetTempDir(),\n                            gtest_prog_name + 'out.xml')\n    gtest_prog_path = gtest_test_utils.GetTestExecutablePath(gtest_prog_name)\n\n    command = ([gtest_prog_path, '%s=xml:%s' % (GTEST_OUTPUT_FLAG, xml_path)] +\n               extra_args)\n    p = gtest_test_utils.Subprocess(command)\n    if p.terminated_by_signal:\n      self.assert_(False,\n                   '%s was killed by signal %d' % (gtest_prog_name, p.signal))\n    else:\n      self.assert_(p.exited)\n      self.assertEquals(expected_exit_code, p.exit_code,\n                        \"'%s' exited with code %s, which doesn't match \"\n                        'the expected exit code %s.'\n                        % (command, p.exit_code, expected_exit_code))\n    actual = minidom.parse(xml_path)\n    return actual\n\n  def _TestXmlOutput(self, gtest_prog_name, expected_xml,\n                     expected_exit_code, extra_args=None):\n    \"\"\"\n    Asserts that the XML document generated by running the program\n    gtest_prog_name matches expected_xml, a string containing another\n    XML document.  Furthermore, the program's exit code must be\n    expected_exit_code.\n    \"\"\"\n\n    actual = self._GetXmlOutput(gtest_prog_name, extra_args or [],\n                                expected_exit_code)\n    expected = minidom.parseString(expected_xml)\n    self.NormalizeXml(actual.documentElement)\n    self.AssertEquivalentNodes(expected.documentElement,\n                               actual.documentElement)\n    expected.unlink()\n    actual.unlink()\n\n\nif __name__ == '__main__':\n  os.environ['GTEST_STACK_TRACE_DEPTH'] = '1'\n  gtest_test_utils.Main()\n"
  },
  {
    "path": "ext/gtest/test/gtest_xml_output_unittest_.cc",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: eefacm@gmail.com (Sean Mcafee)\n\n// Unit test for Google Test XML output.\n//\n// A user can specify XML output in a Google Test program to run via\n// either the GTEST_OUTPUT environment variable or the --gtest_output\n// flag.  This is used for testing such functionality.\n//\n// This program will be invoked from a Python unit test.  Don't run it\n// directly.\n\n#include \"gtest/gtest.h\"\n\nusing ::testing::InitGoogleTest;\nusing ::testing::TestEventListeners;\nusing ::testing::TestWithParam;\nusing ::testing::UnitTest;\nusing ::testing::Test;\nusing ::testing::Values;\n\nclass SuccessfulTest : public Test {\n};\n\nTEST_F(SuccessfulTest, Succeeds) {\n  SUCCEED() << \"This is a success.\";\n  ASSERT_EQ(1, 1);\n}\n\nclass FailedTest : public Test {\n};\n\nTEST_F(FailedTest, Fails) {\n  ASSERT_EQ(1, 2);\n}\n\nclass DisabledTest : public Test {\n};\n\nTEST_F(DisabledTest, DISABLED_test_not_run) {\n  FAIL() << \"Unexpected failure: Disabled test should not be run\";\n}\n\nTEST(MixedResultTest, Succeeds) {\n  EXPECT_EQ(1, 1);\n  ASSERT_EQ(1, 1);\n}\n\nTEST(MixedResultTest, Fails) {\n  EXPECT_EQ(1, 2);\n  ASSERT_EQ(2, 3);\n}\n\nTEST(MixedResultTest, DISABLED_test) {\n  FAIL() << \"Unexpected failure: Disabled test should not be run\";\n}\n\nTEST(XmlQuotingTest, OutputsCData) {\n  FAIL() << \"XML output: \"\n            \"<?xml encoding=\\\"utf-8\\\"><top><![CDATA[cdata text]]></top>\";\n}\n\n// Helps to test that invalid characters produced by test code do not make\n// it into the XML file.\nTEST(InvalidCharactersTest, InvalidCharactersInMessage) {\n  FAIL() << \"Invalid characters in brackets [\\x1\\x2]\";\n}\n\nclass PropertyRecordingTest : public Test {\n public:\n  static void SetUpTestCase() { RecordProperty(\"SetUpTestCase\", \"yes\"); }\n  static void TearDownTestCase() { RecordProperty(\"TearDownTestCase\", \"aye\"); }\n};\n\nTEST_F(PropertyRecordingTest, OneProperty) {\n  RecordProperty(\"key_1\", \"1\");\n}\n\nTEST_F(PropertyRecordingTest, IntValuedProperty) {\n  RecordProperty(\"key_int\", 1);\n}\n\nTEST_F(PropertyRecordingTest, ThreeProperties) {\n  RecordProperty(\"key_1\", \"1\");\n  RecordProperty(\"key_2\", \"2\");\n  RecordProperty(\"key_3\", \"3\");\n}\n\nTEST_F(PropertyRecordingTest, TwoValuesForOneKeyUsesLastValue) {\n  RecordProperty(\"key_1\", \"1\");\n  RecordProperty(\"key_1\", \"2\");\n}\n\nTEST(NoFixtureTest, RecordProperty) {\n  RecordProperty(\"key\", \"1\");\n}\n\nvoid ExternalUtilityThatCallsRecordProperty(const std::string& key, int value) {\n  testing::Test::RecordProperty(key, value);\n}\n\nvoid ExternalUtilityThatCallsRecordProperty(const std::string& key,\n                                            const std::string& value) {\n  testing::Test::RecordProperty(key, value);\n}\n\nTEST(NoFixtureTest, ExternalUtilityThatCallsRecordIntValuedProperty) {\n  ExternalUtilityThatCallsRecordProperty(\"key_for_utility_int\", 1);\n}\n\nTEST(NoFixtureTest, ExternalUtilityThatCallsRecordStringValuedProperty) {\n  ExternalUtilityThatCallsRecordProperty(\"key_for_utility_string\", \"1\");\n}\n\n// Verifies that the test parameter value is output in the 'value_param'\n// XML attribute for value-parameterized tests.\nclass ValueParamTest : public TestWithParam<int> {};\nTEST_P(ValueParamTest, HasValueParamAttribute) {}\nTEST_P(ValueParamTest, AnotherTestThatHasValueParamAttribute) {}\nINSTANTIATE_TEST_CASE_P(Single, ValueParamTest, Values(33, 42));\n\n#if GTEST_HAS_TYPED_TEST\n// Verifies that the type parameter name is output in the 'type_param'\n// XML attribute for typed tests.\ntemplate <typename T> class TypedTest : public Test {};\ntypedef testing::Types<int, long> TypedTestTypes;\nTYPED_TEST_CASE(TypedTest, TypedTestTypes);\nTYPED_TEST(TypedTest, HasTypeParamAttribute) {}\n#endif\n\n#if GTEST_HAS_TYPED_TEST_P\n// Verifies that the type parameter name is output in the 'type_param'\n// XML attribute for type-parameterized tests.\ntemplate <typename T> class TypeParameterizedTestCase : public Test {};\nTYPED_TEST_CASE_P(TypeParameterizedTestCase);\nTYPED_TEST_P(TypeParameterizedTestCase, HasTypeParamAttribute) {}\nREGISTER_TYPED_TEST_CASE_P(TypeParameterizedTestCase, HasTypeParamAttribute);\ntypedef testing::Types<int, long> TypeParameterizedTestCaseTypes;\nINSTANTIATE_TYPED_TEST_CASE_P(Single,\n                              TypeParameterizedTestCase,\n                              TypeParameterizedTestCaseTypes);\n#endif\n\nint main(int argc, char** argv) {\n  InitGoogleTest(&argc, argv);\n\n  if (argc > 1 && strcmp(argv[1], \"--shut_down_xml\") == 0) {\n    TestEventListeners& listeners = UnitTest::GetInstance()->listeners();\n    delete listeners.Release(listeners.default_xml_generator());\n  }\n  testing::Test::RecordProperty(\"ad_hoc_property\", \"42\");\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "ext/gtest/test/gtest_xml_test_utils.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2006, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"Unit test utilities for gtest_xml_output\"\"\"\n\n__author__ = 'eefacm@gmail.com (Sean Mcafee)'\n\nimport re\nfrom xml.dom import minidom, Node\n\nimport gtest_test_utils\n\n\nGTEST_OUTPUT_FLAG         = '--gtest_output'\nGTEST_DEFAULT_OUTPUT_FILE = 'test_detail.xml'\n\nclass GTestXMLTestCase(gtest_test_utils.TestCase):\n  \"\"\"\n  Base class for tests of Google Test's XML output functionality.\n  \"\"\"\n\n\n  def AssertEquivalentNodes(self, expected_node, actual_node):\n    \"\"\"\n    Asserts that actual_node (a DOM node object) is equivalent to\n    expected_node (another DOM node object), in that either both of\n    them are CDATA nodes and have the same value, or both are DOM\n    elements and actual_node meets all of the following conditions:\n\n    *  It has the same tag name as expected_node.\n    *  It has the same set of attributes as expected_node, each with\n       the same value as the corresponding attribute of expected_node.\n       Exceptions are any attribute named \"time\", which needs only be\n       convertible to a floating-point number and any attribute named\n       \"type_param\" which only has to be non-empty.\n    *  It has an equivalent set of child nodes (including elements and\n       CDATA sections) as expected_node.  Note that we ignore the\n       order of the children as they are not guaranteed to be in any\n       particular order.\n    \"\"\"\n\n    if expected_node.nodeType == Node.CDATA_SECTION_NODE:\n      self.assertEquals(Node.CDATA_SECTION_NODE, actual_node.nodeType)\n      self.assertEquals(expected_node.nodeValue, actual_node.nodeValue)\n      return\n\n    self.assertEquals(Node.ELEMENT_NODE, actual_node.nodeType)\n    self.assertEquals(Node.ELEMENT_NODE, expected_node.nodeType)\n    self.assertEquals(expected_node.tagName, actual_node.tagName)\n\n    expected_attributes = expected_node.attributes\n    actual_attributes   = actual_node  .attributes\n    self.assertEquals(\n        expected_attributes.length, actual_attributes.length,\n        'attribute numbers differ in element %s:\\nExpected: %r\\nActual: %r' % (\n            actual_node.tagName, expected_attributes.keys(),\n            actual_attributes.keys()))\n    for i in range(expected_attributes.length):\n      expected_attr = expected_attributes.item(i)\n      actual_attr   = actual_attributes.get(expected_attr.name)\n      self.assert_(\n          actual_attr is not None,\n          'expected attribute %s not found in element %s' %\n          (expected_attr.name, actual_node.tagName))\n      self.assertEquals(\n          expected_attr.value, actual_attr.value,\n          ' values of attribute %s in element %s differ: %s vs %s' %\n          (expected_attr.name, actual_node.tagName,\n           expected_attr.value, actual_attr.value))\n\n    expected_children = self._GetChildren(expected_node)\n    actual_children = self._GetChildren(actual_node)\n    self.assertEquals(\n        len(expected_children), len(actual_children),\n        'number of child elements differ in element ' + actual_node.tagName)\n    for child_id, child in expected_children.iteritems():\n      self.assert_(child_id in actual_children,\n                   '<%s> is not in <%s> (in element %s)' %\n                   (child_id, actual_children, actual_node.tagName))\n      self.AssertEquivalentNodes(child, actual_children[child_id])\n\n  identifying_attribute = {\n    'testsuites': 'name',\n    'testsuite': 'name',\n    'testcase':  'name',\n    'failure':   'message',\n    }\n\n  def _GetChildren(self, element):\n    \"\"\"\n    Fetches all of the child nodes of element, a DOM Element object.\n    Returns them as the values of a dictionary keyed by the IDs of the\n    children.  For <testsuites>, <testsuite> and <testcase> elements, the ID\n    is the value of their \"name\" attribute; for <failure> elements, it is\n    the value of the \"message\" attribute; CDATA sections and non-whitespace\n    text nodes are concatenated into a single CDATA section with ID\n    \"detail\".  An exception is raised if any element other than the above\n    four is encountered, if two child elements with the same identifying\n    attributes are encountered, or if any other type of node is encountered.\n    \"\"\"\n\n    children = {}\n    for child in element.childNodes:\n      if child.nodeType == Node.ELEMENT_NODE:\n        self.assert_(child.tagName in self.identifying_attribute,\n                     'Encountered unknown element <%s>' % child.tagName)\n        childID = child.getAttribute(self.identifying_attribute[child.tagName])\n        self.assert_(childID not in children)\n        children[childID] = child\n      elif child.nodeType in [Node.TEXT_NODE, Node.CDATA_SECTION_NODE]:\n        if 'detail' not in children:\n          if (child.nodeType == Node.CDATA_SECTION_NODE or\n              not child.nodeValue.isspace()):\n            children['detail'] = child.ownerDocument.createCDATASection(\n                child.nodeValue)\n        else:\n          children['detail'].nodeValue += child.nodeValue\n      else:\n        self.fail('Encountered unexpected node type %d' % child.nodeType)\n    return children\n\n  def NormalizeXml(self, element):\n    \"\"\"\n    Normalizes Google Test's XML output to eliminate references to transient\n    information that may change from run to run.\n\n    *  The \"time\" attribute of <testsuites>, <testsuite> and <testcase>\n       elements is replaced with a single asterisk, if it contains\n       only digit characters.\n    *  The \"timestamp\" attribute of <testsuites> elements is replaced with a\n       single asterisk, if it contains a valid ISO8601 datetime value.\n    *  The \"type_param\" attribute of <testcase> elements is replaced with a\n       single asterisk (if it sn non-empty) as it is the type name returned\n       by the compiler and is platform dependent.\n    *  The line info reported in the first line of the \"message\"\n       attribute and CDATA section of <failure> elements is replaced with the\n       file's basename and a single asterisk for the line number.\n    *  The directory names in file paths are removed.\n    *  The stack traces are removed.\n    \"\"\"\n\n    if element.tagName == 'testsuites':\n      timestamp = element.getAttributeNode('timestamp')\n      timestamp.value = re.sub(r'^\\d{4}-\\d\\d-\\d\\dT\\d\\d:\\d\\d:\\d\\d$',\n                               '*', timestamp.value)\n    if element.tagName in ('testsuites', 'testsuite', 'testcase'):\n      time = element.getAttributeNode('time')\n      time.value = re.sub(r'^\\d+(\\.\\d+)?$', '*', time.value)\n      type_param = element.getAttributeNode('type_param')\n      if type_param and type_param.value:\n        type_param.value = '*'\n    elif element.tagName == 'failure':\n      source_line_pat = r'^.*[/\\\\](.*:)\\d+\\n'\n      # Replaces the source line information with a normalized form.\n      message = element.getAttributeNode('message')\n      message.value = re.sub(source_line_pat, '\\\\1*\\n', message.value)\n      for child in element.childNodes:\n        if child.nodeType == Node.CDATA_SECTION_NODE:\n          # Replaces the source line information with a normalized form.\n          cdata = re.sub(source_line_pat, '\\\\1*\\n', child.nodeValue)\n          # Removes the actual stack trace.\n          child.nodeValue = re.sub(r'\\nStack trace:\\n(.|\\n)*',\n                                   '', cdata)\n    for child in element.childNodes:\n      if child.nodeType == Node.ELEMENT_NODE:\n        self.NormalizeXml(child)\n"
  },
  {
    "path": "ext/gtest/test/production.cc",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// This is part of the unit test for include/gtest/gtest_prod.h.\n\n#include \"production.h\"\n\nPrivateCode::PrivateCode() : x_(0) {}\n"
  },
  {
    "path": "ext/gtest/test/production.h",
    "content": "// Copyright 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: wan@google.com (Zhanyong Wan)\n//\n// This is part of the unit test for include/gtest/gtest_prod.h.\n\n#ifndef GTEST_TEST_PRODUCTION_H_\n#define GTEST_TEST_PRODUCTION_H_\n\n#include \"gtest/gtest_prod.h\"\n\nclass PrivateCode {\n public:\n  // Declares a friend test that does not use a fixture.\n  FRIEND_TEST(PrivateCodeTest, CanAccessPrivateMembers);\n\n  // Declares a friend test that uses a fixture.\n  FRIEND_TEST(PrivateCodeFixtureTest, CanAccessPrivateMembers);\n\n  PrivateCode();\n\n  int x() const { return x_; }\n private:\n  void set_x(int an_x) { x_ = an_x; }\n  int x_;\n};\n\n#endif  // GTEST_TEST_PRODUCTION_H_\n"
  },
  {
    "path": "ext/gtest/xcode/Config/DebugProject.xcconfig",
    "content": "//\n//  DebugProject.xcconfig\n//\n//  These are Debug Configuration project settings for the gtest framework and\n//  examples. It is set in the \"Based On:\" dropdown in the \"Project\" info\n//  dialog.\n//  This file is based on the Xcode Configuration files in:\n//  http://code.google.com/p/google-toolbox-for-mac/\n// \n\n#include \"General.xcconfig\"\n\n// No optimization\nGCC_OPTIMIZATION_LEVEL = 0\n\n// Deployment postprocessing is what triggers Xcode to strip, turn it off\nDEPLOYMENT_POSTPROCESSING = NO\n\n// Dead code stripping off\nDEAD_CODE_STRIPPING = NO\n\n// Debug symbols should be on obviously\nGCC_GENERATE_DEBUGGING_SYMBOLS = YES\n\n// Define the DEBUG macro in all debug builds\nOTHER_CFLAGS = $(OTHER_CFLAGS) -DDEBUG=1\n\n// These are turned off to avoid STL incompatibilities with client code\n// // Turns on special C++ STL checks to \"encourage\" good STL use\n// GCC_PREPROCESSOR_DEFINITIONS = $(GCC_PREPROCESSOR_DEFINITIONS) _GLIBCXX_DEBUG_PEDANTIC _GLIBCXX_DEBUG _GLIBCPP_CONCEPT_CHECKS\n"
  },
  {
    "path": "ext/gtest/xcode/Config/FrameworkTarget.xcconfig",
    "content": "//\n//  FrameworkTarget.xcconfig\n//\n//  These are Framework target settings for the gtest framework and examples. It\n//  is set in the \"Based On:\" dropdown in the \"Target\" info dialog.\n//  This file is based on the Xcode Configuration files in:\n//  http://code.google.com/p/google-toolbox-for-mac/\n// \n\n// Dynamic libs need to be position independent\nGCC_DYNAMIC_NO_PIC = NO\n\n// Dynamic libs should not have their external symbols stripped.\nSTRIP_STYLE = non-global\n\n// Let the user install by specifying the $DSTROOT with xcodebuild\nSKIP_INSTALL = NO\n"
  },
  {
    "path": "ext/gtest/xcode/Config/General.xcconfig",
    "content": "//\n//  General.xcconfig\n//\n//  These are General configuration settings for the gtest framework and\n//  examples.\n//  This file is based on the Xcode Configuration files in:\n//  http://code.google.com/p/google-toolbox-for-mac/\n// \n\n// Build for PPC and Intel, 32- and 64-bit\nARCHS = i386 x86_64 ppc ppc64\n\n// Zerolink prevents link warnings so turn it off\nZERO_LINK = NO\n\n// Prebinding considered unhelpful in 10.3 and later\nPREBINDING = NO\n\n// Strictest warning policy\nWARNING_CFLAGS = -Wall -Werror -Wendif-labels -Wnewline-eof -Wno-sign-compare -Wshadow\n\n// Work around Xcode bugs by using external strip. See:\n// http://lists.apple.com/archives/Xcode-users/2006/Feb/msg00050.html\nSEPARATE_STRIP = YES\n\n// Force C99 dialect\nGCC_C_LANGUAGE_STANDARD = c99\n\n// not sure why apple defaults this on, but it's pretty risky\nALWAYS_SEARCH_USER_PATHS = NO\n\n// Turn on position dependent code for most cases (overridden where appropriate)\nGCC_DYNAMIC_NO_PIC = YES\n\n// Default SDK and minimum OS version is 10.4\nSDKROOT = $(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk\nMACOSX_DEPLOYMENT_TARGET = 10.4\nGCC_VERSION = 4.0\n\n// VERSIONING BUILD SETTINGS (used in Info.plist)\nGTEST_VERSIONINFO_ABOUT =  © 2008 Google Inc.\n"
  },
  {
    "path": "ext/gtest/xcode/Config/ReleaseProject.xcconfig",
    "content": "//\n//  ReleaseProject.xcconfig\n//\n//  These are Release Configuration project settings for the gtest framework\n//  and examples. It is set in the \"Based On:\" dropdown in the \"Project\" info\n//  dialog.\n//  This file is based on the Xcode Configuration files in:\n//  http://code.google.com/p/google-toolbox-for-mac/\n// \n\n#include \"General.xcconfig\"\n\n// subconfig/Release.xcconfig\n\n// Optimize for space and size (Apple recommendation)\nGCC_OPTIMIZATION_LEVEL = s\n\n// Deploment postprocessing is what triggers Xcode to strip\nDEPLOYMENT_POSTPROCESSING = YES\n\n// No symbols\nGCC_GENERATE_DEBUGGING_SYMBOLS = NO\n\n// Dead code strip does not affect ObjC code but can help for C\nDEAD_CODE_STRIPPING = YES\n\n// NDEBUG is used by things like assert.h, so define it for general compat.\n// ASSERT going away in release tends to create unused vars.\nOTHER_CFLAGS = $(OTHER_CFLAGS) -DNDEBUG=1 -Wno-unused-variable\n\n// When we strip we want to strip all symbols in release, but save externals.\nSTRIP_STYLE = all\n"
  },
  {
    "path": "ext/gtest/xcode/Config/StaticLibraryTarget.xcconfig",
    "content": "//\n//  StaticLibraryTarget.xcconfig\n//\n//  These are static library target settings for libgtest.a. It\n//  is set in the \"Based On:\" dropdown in the \"Target\" info dialog.\n//  This file is based on the Xcode Configuration files in:\n//  http://code.google.com/p/google-toolbox-for-mac/\n// \n\n// Static libs can be included in bundles so make them position independent\nGCC_DYNAMIC_NO_PIC = NO\n\n// Static libs should not have their internal globals or external symbols\n// stripped.\nSTRIP_STYLE = debugging\n\n// Let the user install by specifying the $DSTROOT with xcodebuild\nSKIP_INSTALL = NO\n"
  },
  {
    "path": "ext/gtest/xcode/Config/TestTarget.xcconfig",
    "content": "//\n//  TestTarget.xcconfig\n//\n//  These are Test target settings for the gtest framework and examples. It\n//  is set in the \"Based On:\" dropdown in the \"Target\" info dialog.\n\nPRODUCT_NAME = $(TARGET_NAME)\nHEADER_SEARCH_PATHS = ../include\n"
  },
  {
    "path": "ext/gtest/xcode/Resources/Info.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>CFBundleDevelopmentRegion</key>\n\t<string>English</string>\n\t<key>CFBundleExecutable</key>\n\t<string>${EXECUTABLE_NAME}</string>\n\t<key>CFBundleIconFile</key>\n\t<string></string>\n\t<key>CFBundleIdentifier</key>\n\t<string>com.google.${PRODUCT_NAME}</string>\n\t<key>CFBundleInfoDictionaryVersion</key>\n\t<string>6.0</string>\n\t<key>CFBundlePackageType</key>\n\t<string>FMWK</string>\n\t<key>CFBundleSignature</key>\n\t<string>????</string>\n\t<key>CFBundleVersion</key>\n\t<string>GTEST_VERSIONINFO_LONG</string>\n\t<key>CFBundleShortVersionString</key>\n\t<string>GTEST_VERSIONINFO_SHORT</string>\n\t<key>CFBundleGetInfoString</key>\n\t<string>${PRODUCT_NAME} GTEST_VERSIONINFO_LONG, ${GTEST_VERSIONINFO_ABOUT}</string>\n\t<key>NSHumanReadableCopyright</key>\n\t<string>${GTEST_VERSIONINFO_ABOUT}</string>\n\t<key>CSResourcesFileMapped</key>\n\t<true/>\n</dict>\n</plist>\n"
  },
  {
    "path": "ext/gtest/xcode/Samples/FrameworkSample/Info.plist",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n\t<key>CFBundleDevelopmentRegion</key>\n\t<string>English</string>\n\t<key>CFBundleExecutable</key>\n\t<string>${EXECUTABLE_NAME}</string>\n\t<key>CFBundleIconFile</key>\n\t<string></string>\n\t<key>CFBundleIdentifier</key>\n\t<string>com.google.gtest.${PRODUCT_NAME:identifier}</string>\n\t<key>CFBundleInfoDictionaryVersion</key>\n\t<string>6.0</string>\n\t<key>CFBundleName</key>\n\t<string>${PRODUCT_NAME}</string>\n\t<key>CFBundlePackageType</key>\n\t<string>FMWK</string>\n\t<key>CFBundleShortVersionString</key>\n\t<string>1.0</string>\n\t<key>CFBundleSignature</key>\n\t<string>????</string>\n\t<key>CFBundleVersion</key>\n\t<string>1.0</string>\n\t<key>CSResourcesFileMapped</key>\n\t<true/>\n</dict>\n</plist>\n"
  },
  {
    "path": "ext/gtest/xcode/Samples/FrameworkSample/WidgetFramework.xcodeproj/project.pbxproj",
    "content": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 42;\n\tobjects = {\n\n/* Begin PBXAggregateTarget section */\n\t\t4024D162113D7D2400C7059E /* Test */ = {\n\t\t\tisa = PBXAggregateTarget;\n\t\t\tbuildConfigurationList = 4024D169113D7D4600C7059E /* Build configuration list for PBXAggregateTarget \"Test\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t4024D161113D7D2400C7059E /* ShellScript */,\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t4024D166113D7D3100C7059E /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = Test;\n\t\t\tproductName = TestAndBuild;\n\t\t};\n\t\t4024D1E9113D83FF00C7059E /* TestAndBuild */ = {\n\t\t\tisa = PBXAggregateTarget;\n\t\t\tbuildConfigurationList = 4024D1F0113D842B00C7059E /* Build configuration list for PBXAggregateTarget \"TestAndBuild\" */;\n\t\t\tbuildPhases = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t4024D1ED113D840900C7059E /* PBXTargetDependency */,\n\t\t\t\t4024D1EF113D840D00C7059E /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = TestAndBuild;\n\t\t\tproductName = TestAndBuild;\n\t\t};\n/* End PBXAggregateTarget section */\n\n/* Begin PBXBuildFile section */\n\t\t3B7EB1250E5AEE3500C7F239 /* widget.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3B7EB1230E5AEE3500C7F239 /* widget.cc */; };\n\t\t3B7EB1260E5AEE3500C7F239 /* widget.h in Headers */ = {isa = PBXBuildFile; fileRef = 3B7EB1240E5AEE3500C7F239 /* widget.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t3B7EB1280E5AEE4600C7F239 /* widget_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3B7EB1270E5AEE4600C7F239 /* widget_test.cc */; };\n\t\t3B7EB1480E5AF3B400C7F239 /* Widget.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8D07F2C80486CC7A007CD1D0 /* Widget.framework */; };\n\t\t4024D188113D7D7800C7059E /* libgtest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4024D185113D7D5500C7059E /* libgtest.a */; };\n\t\t4024D189113D7D7A00C7059E /* libgtest_main.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4024D183113D7D5500C7059E /* libgtest_main.a */; };\n/* End PBXBuildFile section */\n\n/* Begin PBXContainerItemProxy section */\n\t\t3B07BDF00E3F3FAE00647869 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 8D07F2BC0486CC7A007CD1D0;\n\t\t\tremoteInfo = gTestExample;\n\t\t};\n\t\t4024D165113D7D3100C7059E /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 3B07BDE90E3F3F9E00647869;\n\t\t\tremoteInfo = WidgetFrameworkTest;\n\t\t};\n\t\t4024D1EC113D840900C7059E /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 8D07F2BC0486CC7A007CD1D0;\n\t\t\tremoteInfo = WidgetFramework;\n\t\t};\n\t\t4024D1EE113D840D00C7059E /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 4024D162113D7D2400C7059E;\n\t\t\tremoteInfo = Test;\n\t\t};\n/* End PBXContainerItemProxy section */\n\n/* Begin PBXFileReference section */\n\t\t3B07BDEA0E3F3F9E00647869 /* WidgetFrameworkTest */ = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.executable\"; includeInIndex = 0; path = WidgetFrameworkTest; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t3B7EB1230E5AEE3500C7F239 /* widget.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = widget.cc; sourceTree = \"<group>\"; };\n\t\t3B7EB1240E5AEE3500C7F239 /* widget.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = widget.h; sourceTree = \"<group>\"; };\n\t\t3B7EB1270E5AEE4600C7F239 /* widget_test.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = widget_test.cc; sourceTree = \"<group>\"; };\n\t\t4024D183113D7D5500C7059E /* libgtest_main.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libgtest_main.a; path = /usr/local/lib/libgtest_main.a; sourceTree = \"<absolute>\"; };\n\t\t4024D185113D7D5500C7059E /* libgtest.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libgtest.a; path = /usr/local/lib/libgtest.a; sourceTree = \"<absolute>\"; };\n\t\t4024D1E2113D838200C7059E /* runtests.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = runtests.sh; sourceTree = \"<group>\"; };\n\t\t8D07F2C70486CC7A007CD1D0 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = \"<group>\"; };\n\t\t8D07F2C80486CC7A007CD1D0 /* Widget.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Widget.framework; sourceTree = BUILT_PRODUCTS_DIR; };\n/* End PBXFileReference section */\n\n/* Begin PBXFrameworksBuildPhase section */\n\t\t3B07BDE80E3F3F9E00647869 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t4024D189113D7D7A00C7059E /* libgtest_main.a in Frameworks */,\n\t\t\t\t4024D188113D7D7800C7059E /* libgtest.a in Frameworks */,\n\t\t\t\t3B7EB1480E5AF3B400C7F239 /* Widget.framework in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t8D07F2C30486CC7A007CD1D0 /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXFrameworksBuildPhase section */\n\n/* Begin PBXGroup section */\n\t\t034768DDFF38A45A11DB9C8B /* Products */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8D07F2C80486CC7A007CD1D0 /* Widget.framework */,\n\t\t\t\t3B07BDEA0E3F3F9E00647869 /* WidgetFrameworkTest */,\n\t\t\t);\n\t\t\tname = Products;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t0867D691FE84028FC02AAC07 /* gTestExample */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4024D1E1113D836C00C7059E /* Scripts */,\n\t\t\t\t08FB77ACFE841707C02AAC07 /* Source */,\n\t\t\t\t089C1665FE841158C02AAC07 /* Resources */,\n\t\t\t\t3B07BE350E4094E400647869 /* Test */,\n\t\t\t\t0867D69AFE84028FC02AAC07 /* External Frameworks and Libraries */,\n\t\t\t\t034768DDFF38A45A11DB9C8B /* Products */,\n\t\t\t);\n\t\t\tname = gTestExample;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t0867D69AFE84028FC02AAC07 /* External Frameworks and Libraries */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4024D183113D7D5500C7059E /* libgtest_main.a */,\n\t\t\t\t4024D185113D7D5500C7059E /* libgtest.a */,\n\t\t\t);\n\t\t\tname = \"External Frameworks and Libraries\";\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t089C1665FE841158C02AAC07 /* Resources */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t8D07F2C70486CC7A007CD1D0 /* Info.plist */,\n\t\t\t);\n\t\t\tname = Resources;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t08FB77ACFE841707C02AAC07 /* Source */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t3B7EB1230E5AEE3500C7F239 /* widget.cc */,\n\t\t\t\t3B7EB1240E5AEE3500C7F239 /* widget.h */,\n\t\t\t);\n\t\t\tname = Source;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t3B07BE350E4094E400647869 /* Test */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t3B7EB1270E5AEE4600C7F239 /* widget_test.cc */,\n\t\t\t);\n\t\t\tname = Test;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t4024D1E1113D836C00C7059E /* Scripts */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4024D1E2113D838200C7059E /* runtests.sh */,\n\t\t\t);\n\t\t\tname = Scripts;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n/* End PBXGroup section */\n\n/* Begin PBXHeadersBuildPhase section */\n\t\t8D07F2BD0486CC7A007CD1D0 /* Headers */ = {\n\t\t\tisa = PBXHeadersBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t3B7EB1260E5AEE3500C7F239 /* widget.h in Headers */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXHeadersBuildPhase section */\n\n/* Begin PBXNativeTarget section */\n\t\t3B07BDE90E3F3F9E00647869 /* WidgetFrameworkTest */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 3B07BDF40E3F3FB600647869 /* Build configuration list for PBXNativeTarget \"WidgetFrameworkTest\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t3B07BDE70E3F3F9E00647869 /* Sources */,\n\t\t\t\t3B07BDE80E3F3F9E00647869 /* Frameworks */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t3B07BDF10E3F3FAE00647869 /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = WidgetFrameworkTest;\n\t\t\tproductName = gTestExampleTest;\n\t\t\tproductReference = 3B07BDEA0E3F3F9E00647869 /* WidgetFrameworkTest */;\n\t\t\tproductType = \"com.apple.product-type.tool\";\n\t\t};\n\t\t8D07F2BC0486CC7A007CD1D0 /* WidgetFramework */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 4FADC24208B4156D00ABE55E /* Build configuration list for PBXNativeTarget \"WidgetFramework\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t8D07F2C10486CC7A007CD1D0 /* Sources */,\n\t\t\t\t8D07F2C30486CC7A007CD1D0 /* Frameworks */,\n\t\t\t\t8D07F2BD0486CC7A007CD1D0 /* Headers */,\n\t\t\t\t8D07F2BF0486CC7A007CD1D0 /* Resources */,\n\t\t\t\t8D07F2C50486CC7A007CD1D0 /* Rez */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = WidgetFramework;\n\t\t\tproductInstallPath = \"$(HOME)/Library/Frameworks\";\n\t\t\tproductName = gTestExample;\n\t\t\tproductReference = 8D07F2C80486CC7A007CD1D0 /* Widget.framework */;\n\t\t\tproductType = \"com.apple.product-type.framework\";\n\t\t};\n/* End PBXNativeTarget section */\n\n/* Begin PBXProject section */\n\t\t0867D690FE84028FC02AAC07 /* Project object */ = {\n\t\t\tisa = PBXProject;\n\t\t\tbuildConfigurationList = 4FADC24608B4156D00ABE55E /* Build configuration list for PBXProject \"WidgetFramework\" */;\n\t\t\tcompatibilityVersion = \"Xcode 2.4\";\n\t\t\thasScannedForEncodings = 1;\n\t\t\tmainGroup = 0867D691FE84028FC02AAC07 /* gTestExample */;\n\t\t\tproductRefGroup = 034768DDFF38A45A11DB9C8B /* Products */;\n\t\t\tprojectDirPath = \"\";\n\t\t\tprojectRoot = \"\";\n\t\t\ttargets = (\n\t\t\t\t8D07F2BC0486CC7A007CD1D0 /* WidgetFramework */,\n\t\t\t\t3B07BDE90E3F3F9E00647869 /* WidgetFrameworkTest */,\n\t\t\t\t4024D162113D7D2400C7059E /* Test */,\n\t\t\t\t4024D1E9113D83FF00C7059E /* TestAndBuild */,\n\t\t\t);\n\t\t};\n/* End PBXProject section */\n\n/* Begin PBXResourcesBuildPhase section */\n\t\t8D07F2BF0486CC7A007CD1D0 /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXResourcesBuildPhase section */\n\n/* Begin PBXRezBuildPhase section */\n\t\t8D07F2C50486CC7A007CD1D0 /* Rez */ = {\n\t\t\tisa = PBXRezBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXRezBuildPhase section */\n\n/* Begin PBXShellScriptBuildPhase section */\n\t\t4024D161113D7D2400C7059E /* ShellScript */ = {\n\t\t\tisa = PBXShellScriptBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tinputPaths = (\n\t\t\t);\n\t\t\toutputPaths = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t\tshellPath = /bin/sh;\n\t\t\tshellScript = \"/bin/bash $SRCROOT/runtests.sh $BUILT_PRODUCTS_DIR/WidgetFrameworkTest\\n\";\n\t\t};\n/* End PBXShellScriptBuildPhase section */\n\n/* Begin PBXSourcesBuildPhase section */\n\t\t3B07BDE70E3F3F9E00647869 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t3B7EB1280E5AEE4600C7F239 /* widget_test.cc in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t8D07F2C10486CC7A007CD1D0 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t3B7EB1250E5AEE3500C7F239 /* widget.cc in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXSourcesBuildPhase section */\n\n/* Begin PBXTargetDependency section */\n\t\t3B07BDF10E3F3FAE00647869 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 8D07F2BC0486CC7A007CD1D0 /* WidgetFramework */;\n\t\t\ttargetProxy = 3B07BDF00E3F3FAE00647869 /* PBXContainerItemProxy */;\n\t\t};\n\t\t4024D166113D7D3100C7059E /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 3B07BDE90E3F3F9E00647869 /* WidgetFrameworkTest */;\n\t\t\ttargetProxy = 4024D165113D7D3100C7059E /* PBXContainerItemProxy */;\n\t\t};\n\t\t4024D1ED113D840900C7059E /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 8D07F2BC0486CC7A007CD1D0 /* WidgetFramework */;\n\t\t\ttargetProxy = 4024D1EC113D840900C7059E /* PBXContainerItemProxy */;\n\t\t};\n\t\t4024D1EF113D840D00C7059E /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 4024D162113D7D2400C7059E /* Test */;\n\t\t\ttargetProxy = 4024D1EE113D840D00C7059E /* PBXContainerItemProxy */;\n\t\t};\n/* End PBXTargetDependency section */\n\n/* Begin XCBuildConfiguration section */\n\t\t3B07BDEC0E3F3F9F00647869 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tPRODUCT_NAME = WidgetFrameworkTest;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t3B07BDED0E3F3F9F00647869 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tPRODUCT_NAME = WidgetFrameworkTest;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t4024D163113D7D2400C7059E /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tPRODUCT_NAME = TestAndBuild;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t4024D164113D7D2400C7059E /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tPRODUCT_NAME = TestAndBuild;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t4024D1EA113D83FF00C7059E /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tPRODUCT_NAME = TestAndBuild;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t4024D1EB113D83FF00C7059E /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tPRODUCT_NAME = TestAndBuild;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t4FADC24308B4156D00ABE55E /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tDYLIB_COMPATIBILITY_VERSION = 1;\n\t\t\t\tDYLIB_CURRENT_VERSION = 1;\n\t\t\t\tFRAMEWORK_VERSION = A;\n\t\t\t\tINFOPLIST_FILE = Info.plist;\n\t\t\t\tINSTALL_PATH = \"@loader_path/../Frameworks\";\n\t\t\t\tPRODUCT_NAME = Widget;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t4FADC24408B4156D00ABE55E /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tDYLIB_COMPATIBILITY_VERSION = 1;\n\t\t\t\tDYLIB_CURRENT_VERSION = 1;\n\t\t\t\tFRAMEWORK_VERSION = A;\n\t\t\t\tINFOPLIST_FILE = Info.plist;\n\t\t\t\tINSTALL_PATH = \"@loader_path/../Frameworks\";\n\t\t\t\tPRODUCT_NAME = Widget;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t4FADC24708B4156D00ABE55E /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tGCC_VERSION = 4.0;\n\t\t\t\tSDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t4FADC24808B4156D00ABE55E /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tGCC_VERSION = 4.0;\n\t\t\t\tSDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n/* End XCBuildConfiguration section */\n\n/* Begin XCConfigurationList section */\n\t\t3B07BDF40E3F3FB600647869 /* Build configuration list for PBXNativeTarget \"WidgetFrameworkTest\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t3B07BDEC0E3F3F9F00647869 /* Debug */,\n\t\t\t\t3B07BDED0E3F3F9F00647869 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t4024D169113D7D4600C7059E /* Build configuration list for PBXAggregateTarget \"Test\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t4024D163113D7D2400C7059E /* Debug */,\n\t\t\t\t4024D164113D7D2400C7059E /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t4024D1F0113D842B00C7059E /* Build configuration list for PBXAggregateTarget \"TestAndBuild\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t4024D1EA113D83FF00C7059E /* Debug */,\n\t\t\t\t4024D1EB113D83FF00C7059E /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t4FADC24208B4156D00ABE55E /* Build configuration list for PBXNativeTarget \"WidgetFramework\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t4FADC24308B4156D00ABE55E /* Debug */,\n\t\t\t\t4FADC24408B4156D00ABE55E /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t4FADC24608B4156D00ABE55E /* Build configuration list for PBXProject \"WidgetFramework\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t4FADC24708B4156D00ABE55E /* Debug */,\n\t\t\t\t4FADC24808B4156D00ABE55E /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n/* End XCConfigurationList section */\n\t};\n\trootObject = 0867D690FE84028FC02AAC07 /* Project object */;\n}\n"
  },
  {
    "path": "ext/gtest/xcode/Samples/FrameworkSample/runtests.sh",
    "content": "#!/bin/bash\n#\n# Copyright 2008, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n# Executes the samples and tests for the Google Test Framework.\n\n# Help the dynamic linker find the path to the libraries.\nexport DYLD_FRAMEWORK_PATH=$BUILT_PRODUCTS_DIR\nexport DYLD_LIBRARY_PATH=$BUILT_PRODUCTS_DIR\n\n# Create some executables.\ntest_executables=$@\n\n# Now execute each one in turn keeping track of how many succeeded and failed.\nsucceeded=0\nfailed=0\nfailed_list=()\nfor test in ${test_executables[*]}; do\n  \"$test\"\n  result=$?\n  if [ $result -eq 0 ]; then\n    succeeded=$(( $succeeded + 1 ))\n  else\n    failed=$(( failed + 1 ))\n    failed_list=\"$failed_list $test\"\n  fi\ndone\n\n# Report the successes and failures to the console.\necho \"Tests complete with $succeeded successes and $failed failures.\"\nif [ $failed -ne 0 ]; then\n  echo \"The following tests failed:\"\n  echo $failed_list\nfi\nexit $failed\n"
  },
  {
    "path": "ext/gtest/xcode/Samples/FrameworkSample/widget.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: preston.a.jackson@gmail.com (Preston Jackson)\n//\n// Google Test - FrameworkSample\n// widget.cc\n//\n\n// Widget is a very simple class used for demonstrating the use of gtest\n\n#include \"widget.h\"\n\nWidget::Widget(int number, const std::string& name)\n    : number_(number),\n      name_(name) {}\n\nWidget::~Widget() {}\n\nfloat Widget::GetFloatValue() const {\n  return number_;\n}\n\nint Widget::GetIntValue() const {\n  return static_cast<int>(number_);\n}\n\nstd::string Widget::GetStringValue() const {\n  return name_;\n}\n\nvoid Widget::GetCharPtrValue(char* buffer, size_t max_size) const {\n  // Copy the char* representation of name_ into buffer, up to max_size.\n  strncpy(buffer, name_.c_str(), max_size-1);\n  buffer[max_size-1] = '\\0';\n  return;\n}\n"
  },
  {
    "path": "ext/gtest/xcode/Samples/FrameworkSample/widget.h",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: preston.a.jackson@gmail.com (Preston Jackson)\n//\n// Google Test - FrameworkSample\n// widget.h\n//\n\n// Widget is a very simple class used for demonstrating the use of gtest. It\n// simply stores two values a string and an integer, which are returned via\n// public accessors in multiple forms.\n\n#import <string>\n\nclass Widget {\n public:\n  Widget(int number, const std::string& name);\n  ~Widget();\n\n  // Public accessors to number data\n  float GetFloatValue() const;\n  int GetIntValue() const;\n\n  // Public accessors to the string data\n  std::string GetStringValue() const;\n  void GetCharPtrValue(char* buffer, size_t max_size) const;\n\n private:\n  // Data members\n  float number_;\n  std::string name_;\n};\n"
  },
  {
    "path": "ext/gtest/xcode/Samples/FrameworkSample/widget_test.cc",
    "content": "// Copyright 2008, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Author: preston.a.jackson@gmail.com (Preston Jackson)\n//\n// Google Test - FrameworkSample\n// widget_test.cc\n//\n\n// This is a simple test file for the Widget class in the Widget.framework\n\n#include <string>\n#include \"gtest/gtest.h\"\n\n#include <Widget/widget.h>\n\n// This test verifies that the constructor sets the internal state of the\n// Widget class correctly.\nTEST(WidgetInitializerTest, TestConstructor) {\n  Widget widget(1.0f, \"name\");\n  EXPECT_FLOAT_EQ(1.0f, widget.GetFloatValue());\n  EXPECT_EQ(std::string(\"name\"), widget.GetStringValue());\n}\n\n// This test verifies the conversion of the float and string values to int and\n// char*, respectively.\nTEST(WidgetInitializerTest, TestConversion) {\n  Widget widget(1.0f, \"name\");\n  EXPECT_EQ(1, widget.GetIntValue());\n\n  size_t max_size = 128;\n  char buffer[max_size];\n  widget.GetCharPtrValue(buffer, max_size);\n  EXPECT_STREQ(\"name\", buffer);\n}\n\n// Use the Google Test main that is linked into the framework. It does something\n// like this:\n// int main(int argc, char** argv) {\n//   testing::InitGoogleTest(&argc, argv);\n//   return RUN_ALL_TESTS();\n// }\n"
  },
  {
    "path": "ext/gtest/xcode/Scripts/runtests.sh",
    "content": "#!/bin/bash\n#\n# Copyright 2008, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n# Executes the samples and tests for the Google Test Framework.\n\n# Help the dynamic linker find the path to the libraries.\nexport DYLD_FRAMEWORK_PATH=$BUILT_PRODUCTS_DIR\nexport DYLD_LIBRARY_PATH=$BUILT_PRODUCTS_DIR\n\n# Create some executables.\ntest_executables=(\"$BUILT_PRODUCTS_DIR/gtest_unittest-framework\"\n                  \"$BUILT_PRODUCTS_DIR/gtest_unittest\"\n                  \"$BUILT_PRODUCTS_DIR/sample1_unittest-framework\"\n                  \"$BUILT_PRODUCTS_DIR/sample1_unittest-static\")\n\n# Now execute each one in turn keeping track of how many succeeded and failed. \nsucceeded=0\nfailed=0\nfailed_list=()\nfor test in ${test_executables[*]}; do\n  \"$test\"\n  result=$?\n  if [ $result -eq 0 ]; then\n    succeeded=$(( $succeeded + 1 ))\n  else\n    failed=$(( failed + 1 ))\n    failed_list=\"$failed_list $test\"\n  fi\ndone\n\n# Report the successes and failures to the console.\necho \"Tests complete with $succeeded successes and $failed failures.\"\nif [ $failed -ne 0 ]; then\n  echo \"The following tests failed:\"\n  echo $failed_list\nfi\nexit $failed\n"
  },
  {
    "path": "ext/gtest/xcode/Scripts/versiongenerate.py",
    "content": "#!/usr/bin/env python\n#\n# Copyright 2008, Google Inc.\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"A script to prepare version informtion for use the gtest Info.plist file.\n\n  This script extracts the version information from the configure.ac file and\n  uses it to generate a header file containing the same information. The\n  #defines in this header file will be included in during the generation of\n  the Info.plist of the framework, giving the correct value to the version\n  shown in the Finder.\n\n  This script makes the following assumptions (these are faults of the script,\n  not problems with the Autoconf):\n    1. The AC_INIT macro will be contained within the first 1024 characters\n       of configure.ac\n    2. The version string will be 3 integers separated by periods and will be\n       surrounded by squre brackets, \"[\" and \"]\" (e.g. [1.0.1]). The first\n       segment represents the major version, the second represents the minor\n       version and the third represents the fix version.\n    3. No \")\" character exists between the opening \"(\" and closing \")\" of\n       AC_INIT, including in comments and character strings.\n\"\"\"\n\nimport sys\nimport re\n\n# Read the command line argument (the output directory for Version.h)\nif (len(sys.argv) < 3):\n  print \"Usage: versiongenerate.py input_dir output_dir\"\n  sys.exit(1)\nelse:\n  input_dir = sys.argv[1]\n  output_dir = sys.argv[2]\n\n# Read the first 1024 characters of the configure.ac file\nconfig_file = open(\"%s/configure.ac\" % input_dir, 'r')\nbuffer_size = 1024\nopening_string = config_file.read(buffer_size)\nconfig_file.close()\n\n# Extract the version string from the AC_INIT macro\n#   The following init_expression means:\n#     Extract three integers separated by periods and surrounded by squre\n#     brackets(e.g. \"[1.0.1]\") between \"AC_INIT(\" and \")\". Do not be greedy\n#     (*? is the non-greedy flag) since that would pull in everything between\n#     the first \"(\" and the last \")\" in the file.\nversion_expression = re.compile(r\"AC_INIT\\(.*?\\[(\\d+)\\.(\\d+)\\.(\\d+)\\].*?\\)\",\n                                re.DOTALL)\nversion_values = version_expression.search(opening_string)\nmajor_version = version_values.group(1)\nminor_version = version_values.group(2)\nfix_version = version_values.group(3)\n\n# Write the version information to a header file to be included in the\n# Info.plist file.\nfile_data = \"\"\"//\n// DO NOT MODIFY THIS FILE (but you can delete it)\n//\n// This file is autogenerated by the versiongenerate.py script. This script\n// is executed in a \"Run Script\" build phase when creating gtest.framework. This\n// header file is not used during compilation of C-source. Rather, it simply\n// defines some version strings for substitution in the Info.plist. Because of\n// this, we are not not restricted to C-syntax nor are we using include guards.\n//\n\n#define GTEST_VERSIONINFO_SHORT %s.%s\n#define GTEST_VERSIONINFO_LONG %s.%s.%s\n\n\"\"\" % (major_version, minor_version, major_version, minor_version, fix_version)\nversion_file = open(\"%s/Version.h\" % output_dir, 'w')\nversion_file.write(file_data)\nversion_file.close()\n"
  },
  {
    "path": "ext/gtest/xcode/gtest.xcodeproj/project.pbxproj",
    "content": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 46;\n\tobjects = {\n\n/* Begin PBXAggregateTarget section */\n\t\t3B238F5F0E828B5400846E11 /* Check */ = {\n\t\t\tisa = PBXAggregateTarget;\n\t\t\tbuildConfigurationList = 3B238FA30E828BB600846E11 /* Build configuration list for PBXAggregateTarget \"Check\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t3B238F5E0E828B5400846E11 /* ShellScript */,\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t40899F9D0FFA740F000B29AE /* PBXTargetDependency */,\n\t\t\t\t40C849F7101A43440083642A /* PBXTargetDependency */,\n\t\t\t\t4089A0980FFAD34A000B29AE /* PBXTargetDependency */,\n\t\t\t\t40C849F9101A43490083642A /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = Check;\n\t\t\tproductName = Check;\n\t\t};\n\t\t40C44ADC0E3798F4008FCC51 /* Version Info */ = {\n\t\t\tisa = PBXAggregateTarget;\n\t\t\tbuildConfigurationList = 40C44AE40E379905008FCC51 /* Build configuration list for PBXAggregateTarget \"Version Info\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t40C44ADB0E3798F4008FCC51 /* Generate Version.h */,\n\t\t\t);\n\t\t\tcomments = \"The generation of Version.h must be performed in its own target. Since the Info.plist is preprocessed before any of the other build phases in gtest, the Version.h file would not be ready if included as a build phase of that target.\";\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = \"Version Info\";\n\t\t\tproductName = Version.h;\n\t\t};\n/* End PBXAggregateTarget section */\n\n/* Begin PBXBuildFile section */\n\t\t224A12A30E9EADCC00BD17FD /* gtest-test-part.h in Headers */ = {isa = PBXBuildFile; fileRef = 224A12A20E9EADCC00BD17FD /* gtest-test-part.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t3BF6F2A00E79B5AD000F2EEE /* gtest-type-util.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 3BF6F29F0E79B5AD000F2EEE /* gtest-type-util.h */; };\n\t\t3BF6F2A50E79B616000F2EEE /* gtest-typed-test.h in Headers */ = {isa = PBXBuildFile; fileRef = 3BF6F2A40E79B616000F2EEE /* gtest-typed-test.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t404884380E2F799B00CF7658 /* gtest-death-test.h in Headers */ = {isa = PBXBuildFile; fileRef = 404883DB0E2F799B00CF7658 /* gtest-death-test.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t404884390E2F799B00CF7658 /* gtest-message.h in Headers */ = {isa = PBXBuildFile; fileRef = 404883DC0E2F799B00CF7658 /* gtest-message.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t4048843A0E2F799B00CF7658 /* gtest-spi.h in Headers */ = {isa = PBXBuildFile; fileRef = 404883DD0E2F799B00CF7658 /* gtest-spi.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t4048843B0E2F799B00CF7658 /* gtest.h in Headers */ = {isa = PBXBuildFile; fileRef = 404883DE0E2F799B00CF7658 /* gtest.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t4048843C0E2F799B00CF7658 /* gtest_pred_impl.h in Headers */ = {isa = PBXBuildFile; fileRef = 404883DF0E2F799B00CF7658 /* gtest_pred_impl.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t4048843D0E2F799B00CF7658 /* gtest_prod.h in Headers */ = {isa = PBXBuildFile; fileRef = 404883E00E2F799B00CF7658 /* gtest_prod.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t404884500E2F799B00CF7658 /* README in Resources */ = {isa = PBXBuildFile; fileRef = 404883F60E2F799B00CF7658 /* README */; };\n\t\t404884A00E2F7BE600CF7658 /* gtest-death-test-internal.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 404883E20E2F799B00CF7658 /* gtest-death-test-internal.h */; };\n\t\t404884A10E2F7BE600CF7658 /* gtest-filepath.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 404883E30E2F799B00CF7658 /* gtest-filepath.h */; };\n\t\t404884A20E2F7BE600CF7658 /* gtest-internal.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 404883E40E2F799B00CF7658 /* gtest-internal.h */; };\n\t\t404884A30E2F7BE600CF7658 /* gtest-port.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 404883E50E2F799B00CF7658 /* gtest-port.h */; };\n\t\t404884A40E2F7BE600CF7658 /* gtest-string.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 404883E60E2F799B00CF7658 /* gtest-string.h */; };\n\t\t404884AC0E2F7CD900CF7658 /* CHANGES in Resources */ = {isa = PBXBuildFile; fileRef = 404884A90E2F7CD900CF7658 /* CHANGES */; };\n\t\t404884AD0E2F7CD900CF7658 /* CONTRIBUTORS in Resources */ = {isa = PBXBuildFile; fileRef = 404884AA0E2F7CD900CF7658 /* CONTRIBUTORS */; };\n\t\t404884AE0E2F7CD900CF7658 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 404884AB0E2F7CD900CF7658 /* LICENSE */; };\n\t\t40899F3A0FFA70D4000B29AE /* gtest-all.cc in Sources */ = {isa = PBXBuildFile; fileRef = 224A12A10E9EADA700BD17FD /* gtest-all.cc */; };\n\t\t40899F500FFA7281000B29AE /* gtest-tuple.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 40899F4D0FFA7271000B29AE /* gtest-tuple.h */; };\n\t\t40899F530FFA72A0000B29AE /* gtest_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3B238C120E7FE13C00846E11 /* gtest_unittest.cc */; };\n\t\t4089A0440FFAD1BE000B29AE /* sample1.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4089A02C0FFACF7F000B29AE /* sample1.cc */; };\n\t\t4089A0460FFAD1BE000B29AE /* sample1_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4089A02E0FFACF7F000B29AE /* sample1_unittest.cc */; };\n\t\t40C848FF101A21150083642A /* gtest-all.cc in Sources */ = {isa = PBXBuildFile; fileRef = 224A12A10E9EADA700BD17FD /* gtest-all.cc */; };\n\t\t40C84915101A21DF0083642A /* gtest_main.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4048840D0E2F799B00CF7658 /* gtest_main.cc */; };\n\t\t40C84916101A235B0083642A /* libgtest_main.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 40C8490B101A217E0083642A /* libgtest_main.a */; };\n\t\t40C84921101A23AD0083642A /* libgtest_main.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 40C8490B101A217E0083642A /* libgtest_main.a */; };\n\t\t40C84978101A36540083642A /* libgtest_main.a in Resources */ = {isa = PBXBuildFile; fileRef = 40C8490B101A217E0083642A /* libgtest_main.a */; };\n\t\t40C84980101A36850083642A /* gtest_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3B238C120E7FE13C00846E11 /* gtest_unittest.cc */; };\n\t\t40C84982101A36850083642A /* libgtest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 40C848FA101A209C0083642A /* libgtest.a */; };\n\t\t40C84983101A36850083642A /* libgtest_main.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 40C8490B101A217E0083642A /* libgtest_main.a */; };\n\t\t40C8498F101A36A60083642A /* sample1.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4089A02C0FFACF7F000B29AE /* sample1.cc */; };\n\t\t40C84990101A36A60083642A /* sample1_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4089A02E0FFACF7F000B29AE /* sample1_unittest.cc */; };\n\t\t40C84992101A36A60083642A /* libgtest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 40C848FA101A209C0083642A /* libgtest.a */; };\n\t\t40C84993101A36A60083642A /* libgtest_main.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 40C8490B101A217E0083642A /* libgtest_main.a */; };\n\t\t40C849A2101A37050083642A /* gtest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4539C8FF0EC27F6400A70F4C /* gtest.framework */; };\n\t\t40C849A4101A37150083642A /* gtest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4539C8FF0EC27F6400A70F4C /* gtest.framework */; };\n\t\t4539C9340EC280AE00A70F4C /* gtest-param-test.h in Headers */ = {isa = PBXBuildFile; fileRef = 4539C9330EC280AE00A70F4C /* gtest-param-test.h */; settings = {ATTRIBUTES = (Public, ); }; };\n\t\t4539C9380EC280E200A70F4C /* gtest-linked_ptr.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 4539C9350EC280E200A70F4C /* gtest-linked_ptr.h */; };\n\t\t4539C9390EC280E200A70F4C /* gtest-param-util-generated.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 4539C9360EC280E200A70F4C /* gtest-param-util-generated.h */; };\n\t\t4539C93A0EC280E200A70F4C /* gtest-param-util.h in Copy Headers Internal */ = {isa = PBXBuildFile; fileRef = 4539C9370EC280E200A70F4C /* gtest-param-util.h */; };\n\t\t4567C8181264FF71007740BE /* gtest-printers.h in Headers */ = {isa = PBXBuildFile; fileRef = 4567C8171264FF71007740BE /* gtest-printers.h */; settings = {ATTRIBUTES = (Public, ); }; };\n/* End PBXBuildFile section */\n\n/* Begin PBXContainerItemProxy section */\n\t\t40899F9C0FFA740F000B29AE /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 40899F420FFA7184000B29AE;\n\t\t\tremoteInfo = gtest_unittest;\n\t\t};\n\t\t4089A0970FFAD34A000B29AE /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 4089A0120FFACEFC000B29AE;\n\t\t\tremoteInfo = sample1_unittest;\n\t\t};\n\t\t408BEC0F1046CFE900DEF522 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 40C848F9101A209C0083642A;\n\t\t\tremoteInfo = \"gtest-static\";\n\t\t};\n\t\t40C44AE50E379922008FCC51 /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 40C44ADC0E3798F4008FCC51;\n\t\t\tremoteInfo = Version.h;\n\t\t};\n\t\t40C8497C101A36850083642A /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 40C848F9101A209C0083642A;\n\t\t\tremoteInfo = \"gtest-static\";\n\t\t};\n\t\t40C8497E101A36850083642A /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 40C8490A101A217E0083642A;\n\t\t\tremoteInfo = \"gtest_main-static\";\n\t\t};\n\t\t40C8498B101A36A60083642A /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 40C848F9101A209C0083642A;\n\t\t\tremoteInfo = \"gtest-static\";\n\t\t};\n\t\t40C8498D101A36A60083642A /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 40C8490A101A217E0083642A;\n\t\t\tremoteInfo = \"gtest_main-static\";\n\t\t};\n\t\t40C8499B101A36DC0083642A /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 40C8490A101A217E0083642A;\n\t\t\tremoteInfo = \"gtest_main-static\";\n\t\t};\n\t\t40C8499D101A36E50083642A /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 8D07F2BC0486CC7A007CD1D0;\n\t\t\tremoteInfo = \"gtest-framework\";\n\t\t};\n\t\t40C8499F101A36F10083642A /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 8D07F2BC0486CC7A007CD1D0;\n\t\t\tremoteInfo = \"gtest-framework\";\n\t\t};\n\t\t40C849F6101A43440083642A /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 40C8497A101A36850083642A;\n\t\t\tremoteInfo = \"gtest_unittest-static\";\n\t\t};\n\t\t40C849F8101A43490083642A /* PBXContainerItemProxy */ = {\n\t\t\tisa = PBXContainerItemProxy;\n\t\t\tcontainerPortal = 0867D690FE84028FC02AAC07 /* Project object */;\n\t\t\tproxyType = 1;\n\t\t\tremoteGlobalIDString = 40C84989101A36A60083642A;\n\t\t\tremoteInfo = \"sample1_unittest-static\";\n\t\t};\n/* End PBXContainerItemProxy section */\n\n/* Begin PBXCopyFilesBuildPhase section */\n\t\t404884A50E2F7C0400CF7658 /* Copy Headers Internal */ = {\n\t\t\tisa = PBXCopyFilesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tdstPath = Headers/internal;\n\t\t\tdstSubfolderSpec = 6;\n\t\t\tfiles = (\n\t\t\t\t404884A00E2F7BE600CF7658 /* gtest-death-test-internal.h in Copy Headers Internal */,\n\t\t\t\t404884A10E2F7BE600CF7658 /* gtest-filepath.h in Copy Headers Internal */,\n\t\t\t\t404884A20E2F7BE600CF7658 /* gtest-internal.h in Copy Headers Internal */,\n\t\t\t\t4539C9380EC280E200A70F4C /* gtest-linked_ptr.h in Copy Headers Internal */,\n\t\t\t\t4539C9390EC280E200A70F4C /* gtest-param-util-generated.h in Copy Headers Internal */,\n\t\t\t\t4539C93A0EC280E200A70F4C /* gtest-param-util.h in Copy Headers Internal */,\n\t\t\t\t404884A30E2F7BE600CF7658 /* gtest-port.h in Copy Headers Internal */,\n\t\t\t\t404884A40E2F7BE600CF7658 /* gtest-string.h in Copy Headers Internal */,\n\t\t\t\t40899F500FFA7281000B29AE /* gtest-tuple.h in Copy Headers Internal */,\n\t\t\t\t3BF6F2A00E79B5AD000F2EEE /* gtest-type-util.h in Copy Headers Internal */,\n\t\t\t);\n\t\t\tname = \"Copy Headers Internal\";\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXCopyFilesBuildPhase section */\n\n/* Begin PBXFileReference section */\n\t\t224A12A10E9EADA700BD17FD /* gtest-all.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = \"gtest-all.cc\"; sourceTree = \"<group>\"; };\n\t\t224A12A20E9EADCC00BD17FD /* gtest-test-part.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = \"gtest-test-part.h\"; sourceTree = \"<group>\"; };\n\t\t3B238C120E7FE13C00846E11 /* gtest_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = gtest_unittest.cc; sourceTree = \"<group>\"; };\n\t\t3B87D2100E96B92E000D1852 /* runtests.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = runtests.sh; sourceTree = \"<group>\"; };\n\t\t3BF6F29F0E79B5AD000F2EEE /* gtest-type-util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-type-util.h\"; sourceTree = \"<group>\"; };\n\t\t3BF6F2A40E79B616000F2EEE /* gtest-typed-test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-typed-test.h\"; sourceTree = \"<group>\"; };\n\t\t403EE37C0E377822004BD1E2 /* versiongenerate.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = versiongenerate.py; sourceTree = \"<group>\"; };\n\t\t404883DB0E2F799B00CF7658 /* gtest-death-test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-death-test.h\"; sourceTree = \"<group>\"; };\n\t\t404883DC0E2F799B00CF7658 /* gtest-message.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-message.h\"; sourceTree = \"<group>\"; };\n\t\t404883DD0E2F799B00CF7658 /* gtest-spi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-spi.h\"; sourceTree = \"<group>\"; };\n\t\t404883DE0E2F799B00CF7658 /* gtest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gtest.h; sourceTree = \"<group>\"; };\n\t\t404883DF0E2F799B00CF7658 /* gtest_pred_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gtest_pred_impl.h; sourceTree = \"<group>\"; };\n\t\t404883E00E2F799B00CF7658 /* gtest_prod.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gtest_prod.h; sourceTree = \"<group>\"; };\n\t\t404883E20E2F799B00CF7658 /* gtest-death-test-internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-death-test-internal.h\"; sourceTree = \"<group>\"; };\n\t\t404883E30E2F799B00CF7658 /* gtest-filepath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-filepath.h\"; sourceTree = \"<group>\"; };\n\t\t404883E40E2F799B00CF7658 /* gtest-internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-internal.h\"; sourceTree = \"<group>\"; };\n\t\t404883E50E2F799B00CF7658 /* gtest-port.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-port.h\"; sourceTree = \"<group>\"; };\n\t\t404883E60E2F799B00CF7658 /* gtest-string.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-string.h\"; sourceTree = \"<group>\"; };\n\t\t404883F60E2F799B00CF7658 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = README; path = ../README; sourceTree = SOURCE_ROOT; };\n\t\t4048840D0E2F799B00CF7658 /* gtest_main.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = gtest_main.cc; sourceTree = \"<group>\"; };\n\t\t404884A90E2F7CD900CF7658 /* CHANGES */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CHANGES; path = ../CHANGES; sourceTree = SOURCE_ROOT; };\n\t\t404884AA0E2F7CD900CF7658 /* CONTRIBUTORS */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = CONTRIBUTORS; path = ../CONTRIBUTORS; sourceTree = SOURCE_ROOT; };\n\t\t404884AB0E2F7CD900CF7658 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = SOURCE_ROOT; };\n\t\t40899F430FFA7184000B29AE /* gtest_unittest-framework */ = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.executable\"; includeInIndex = 0; path = \"gtest_unittest-framework\"; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t40899F4D0FFA7271000B29AE /* gtest-tuple.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-tuple.h\"; sourceTree = \"<group>\"; };\n\t\t40899FB30FFA7567000B29AE /* StaticLibraryTarget.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = StaticLibraryTarget.xcconfig; sourceTree = \"<group>\"; };\n\t\t4089A0130FFACEFC000B29AE /* sample1_unittest-framework */ = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.executable\"; includeInIndex = 0; path = \"sample1_unittest-framework\"; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t4089A02C0FFACF7F000B29AE /* sample1.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sample1.cc; sourceTree = \"<group>\"; };\n\t\t4089A02D0FFACF7F000B29AE /* sample1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sample1.h; sourceTree = \"<group>\"; };\n\t\t4089A02E0FFACF7F000B29AE /* sample1_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sample1_unittest.cc; sourceTree = \"<group>\"; };\n\t\t40C848FA101A209C0083642A /* libgtest.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libgtest.a; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t40C8490B101A217E0083642A /* libgtest_main.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libgtest_main.a; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t40C84987101A36850083642A /* gtest_unittest */ = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.executable\"; includeInIndex = 0; path = gtest_unittest; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t40C84997101A36A60083642A /* sample1_unittest-static */ = {isa = PBXFileReference; explicitFileType = \"compiled.mach-o.executable\"; includeInIndex = 0; path = \"sample1_unittest-static\"; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t40D4CDF10E30E07400294801 /* DebugProject.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = DebugProject.xcconfig; sourceTree = \"<group>\"; };\n\t\t40D4CDF20E30E07400294801 /* FrameworkTarget.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = FrameworkTarget.xcconfig; sourceTree = \"<group>\"; };\n\t\t40D4CDF30E30E07400294801 /* General.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = General.xcconfig; sourceTree = \"<group>\"; };\n\t\t40D4CDF40E30E07400294801 /* ReleaseProject.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ReleaseProject.xcconfig; sourceTree = \"<group>\"; };\n\t\t40D4CF510E30F5E200294801 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = \"<group>\"; };\n\t\t4539C8FF0EC27F6400A70F4C /* gtest.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = gtest.framework; sourceTree = BUILT_PRODUCTS_DIR; };\n\t\t4539C9330EC280AE00A70F4C /* gtest-param-test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-param-test.h\"; sourceTree = \"<group>\"; };\n\t\t4539C9350EC280E200A70F4C /* gtest-linked_ptr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-linked_ptr.h\"; sourceTree = \"<group>\"; };\n\t\t4539C9360EC280E200A70F4C /* gtest-param-util-generated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-param-util-generated.h\"; sourceTree = \"<group>\"; };\n\t\t4539C9370EC280E200A70F4C /* gtest-param-util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-param-util.h\"; sourceTree = \"<group>\"; };\n\t\t4567C8171264FF71007740BE /* gtest-printers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = \"gtest-printers.h\"; sourceTree = \"<group>\"; };\n/* End PBXFileReference section */\n\n/* Begin PBXFrameworksBuildPhase section */\n\t\t40899F410FFA7184000B29AE /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t40C849A4101A37150083642A /* gtest.framework in Frameworks */,\n\t\t\t\t40C84916101A235B0083642A /* libgtest_main.a in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t4089A0110FFACEFC000B29AE /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t40C849A2101A37050083642A /* gtest.framework in Frameworks */,\n\t\t\t\t40C84921101A23AD0083642A /* libgtest_main.a in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t40C84981101A36850083642A /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t40C84982101A36850083642A /* libgtest.a in Frameworks */,\n\t\t\t\t40C84983101A36850083642A /* libgtest_main.a in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t40C84991101A36A60083642A /* Frameworks */ = {\n\t\t\tisa = PBXFrameworksBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t40C84992101A36A60083642A /* libgtest.a in Frameworks */,\n\t\t\t\t40C84993101A36A60083642A /* libgtest_main.a in Frameworks */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXFrameworksBuildPhase section */\n\n/* Begin PBXGroup section */\n\t\t034768DDFF38A45A11DB9C8B /* Products */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4539C8FF0EC27F6400A70F4C /* gtest.framework */,\n\t\t\t\t40C848FA101A209C0083642A /* libgtest.a */,\n\t\t\t\t40C8490B101A217E0083642A /* libgtest_main.a */,\n\t\t\t\t40899F430FFA7184000B29AE /* gtest_unittest-framework */,\n\t\t\t\t40C84987101A36850083642A /* gtest_unittest */,\n\t\t\t\t4089A0130FFACEFC000B29AE /* sample1_unittest-framework */,\n\t\t\t\t40C84997101A36A60083642A /* sample1_unittest-static */,\n\t\t\t);\n\t\t\tname = Products;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t0867D691FE84028FC02AAC07 /* gtest */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t40D4CDF00E30E07400294801 /* Config */,\n\t\t\t\t08FB77ACFE841707C02AAC07 /* Source */,\n\t\t\t\t40D4CF4E0E30F5E200294801 /* Resources */,\n\t\t\t\t403EE37B0E377822004BD1E2 /* Scripts */,\n\t\t\t\t034768DDFF38A45A11DB9C8B /* Products */,\n\t\t\t);\n\t\t\tname = gtest;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t08FB77ACFE841707C02AAC07 /* Source */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t404884A90E2F7CD900CF7658 /* CHANGES */,\n\t\t\t\t404884AA0E2F7CD900CF7658 /* CONTRIBUTORS */,\n\t\t\t\t404884AB0E2F7CD900CF7658 /* LICENSE */,\n\t\t\t\t404883F60E2F799B00CF7658 /* README */,\n\t\t\t\t404883D90E2F799B00CF7658 /* include */,\n\t\t\t\t4089A02F0FFACF84000B29AE /* samples */,\n\t\t\t\t404884070E2F799B00CF7658 /* src */,\n\t\t\t\t3B238BF00E7FE13B00846E11 /* test */,\n\t\t\t);\n\t\t\tname = Source;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t3B238BF00E7FE13B00846E11 /* test */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t3B238C120E7FE13C00846E11 /* gtest_unittest.cc */,\n\t\t\t);\n\t\t\tname = test;\n\t\t\tpath = ../test;\n\t\t\tsourceTree = SOURCE_ROOT;\n\t\t};\n\t\t403EE37B0E377822004BD1E2 /* Scripts */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t403EE37C0E377822004BD1E2 /* versiongenerate.py */,\n\t\t\t\t3B87D2100E96B92E000D1852 /* runtests.sh */,\n\t\t\t);\n\t\t\tpath = Scripts;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t404883D90E2F799B00CF7658 /* include */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t404883DA0E2F799B00CF7658 /* gtest */,\n\t\t\t);\n\t\t\tname = include;\n\t\t\tpath = ../include;\n\t\t\tsourceTree = SOURCE_ROOT;\n\t\t};\n\t\t404883DA0E2F799B00CF7658 /* gtest */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t404883E10E2F799B00CF7658 /* internal */,\n\t\t\t\t224A12A20E9EADCC00BD17FD /* gtest-test-part.h */,\n\t\t\t\t404883DB0E2F799B00CF7658 /* gtest-death-test.h */,\n\t\t\t\t404883DC0E2F799B00CF7658 /* gtest-message.h */,\n\t\t\t\t4539C9330EC280AE00A70F4C /* gtest-param-test.h */,\n\t\t\t\t4567C8171264FF71007740BE /* gtest-printers.h */,\n\t\t\t\t404883DD0E2F799B00CF7658 /* gtest-spi.h */,\n\t\t\t\t404883DE0E2F799B00CF7658 /* gtest.h */,\n\t\t\t\t404883DF0E2F799B00CF7658 /* gtest_pred_impl.h */,\n\t\t\t\t404883E00E2F799B00CF7658 /* gtest_prod.h */,\n\t\t\t\t3BF6F2A40E79B616000F2EEE /* gtest-typed-test.h */,\n\t\t\t);\n\t\t\tpath = gtest;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t404883E10E2F799B00CF7658 /* internal */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t404883E20E2F799B00CF7658 /* gtest-death-test-internal.h */,\n\t\t\t\t404883E30E2F799B00CF7658 /* gtest-filepath.h */,\n\t\t\t\t404883E40E2F799B00CF7658 /* gtest-internal.h */,\n\t\t\t\t4539C9350EC280E200A70F4C /* gtest-linked_ptr.h */,\n\t\t\t\t4539C9360EC280E200A70F4C /* gtest-param-util-generated.h */,\n\t\t\t\t4539C9370EC280E200A70F4C /* gtest-param-util.h */,\n\t\t\t\t404883E50E2F799B00CF7658 /* gtest-port.h */,\n\t\t\t\t404883E60E2F799B00CF7658 /* gtest-string.h */,\n\t\t\t\t40899F4D0FFA7271000B29AE /* gtest-tuple.h */,\n\t\t\t\t3BF6F29F0E79B5AD000F2EEE /* gtest-type-util.h */,\n\t\t\t);\n\t\t\tpath = internal;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t404884070E2F799B00CF7658 /* src */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t224A12A10E9EADA700BD17FD /* gtest-all.cc */,\n\t\t\t\t4048840D0E2F799B00CF7658 /* gtest_main.cc */,\n\t\t\t);\n\t\t\tname = src;\n\t\t\tpath = ../src;\n\t\t\tsourceTree = SOURCE_ROOT;\n\t\t};\n\t\t4089A02F0FFACF84000B29AE /* samples */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t4089A02C0FFACF7F000B29AE /* sample1.cc */,\n\t\t\t\t4089A02D0FFACF7F000B29AE /* sample1.h */,\n\t\t\t\t4089A02E0FFACF7F000B29AE /* sample1_unittest.cc */,\n\t\t\t);\n\t\t\tname = samples;\n\t\t\tpath = ../samples;\n\t\t\tsourceTree = SOURCE_ROOT;\n\t\t};\n\t\t40D4CDF00E30E07400294801 /* Config */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t40D4CDF10E30E07400294801 /* DebugProject.xcconfig */,\n\t\t\t\t40D4CDF20E30E07400294801 /* FrameworkTarget.xcconfig */,\n\t\t\t\t40D4CDF30E30E07400294801 /* General.xcconfig */,\n\t\t\t\t40D4CDF40E30E07400294801 /* ReleaseProject.xcconfig */,\n\t\t\t\t40899FB30FFA7567000B29AE /* StaticLibraryTarget.xcconfig */,\n\t\t\t);\n\t\t\tpath = Config;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n\t\t40D4CF4E0E30F5E200294801 /* Resources */ = {\n\t\t\tisa = PBXGroup;\n\t\t\tchildren = (\n\t\t\t\t40D4CF510E30F5E200294801 /* Info.plist */,\n\t\t\t);\n\t\t\tpath = Resources;\n\t\t\tsourceTree = \"<group>\";\n\t\t};\n/* End PBXGroup section */\n\n/* Begin PBXHeadersBuildPhase section */\n\t\t8D07F2BD0486CC7A007CD1D0 /* Headers */ = {\n\t\t\tisa = PBXHeadersBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t404884380E2F799B00CF7658 /* gtest-death-test.h in Headers */,\n\t\t\t\t404884390E2F799B00CF7658 /* gtest-message.h in Headers */,\n\t\t\t\t4539C9340EC280AE00A70F4C /* gtest-param-test.h in Headers */,\n\t\t\t\t4567C8181264FF71007740BE /* gtest-printers.h in Headers */,\n\t\t\t\t3BF6F2A50E79B616000F2EEE /* gtest-typed-test.h in Headers */,\n\t\t\t\t4048843A0E2F799B00CF7658 /* gtest-spi.h in Headers */,\n\t\t\t\t4048843B0E2F799B00CF7658 /* gtest.h in Headers */,\n\t\t\t\t4048843C0E2F799B00CF7658 /* gtest_pred_impl.h in Headers */,\n\t\t\t\t4048843D0E2F799B00CF7658 /* gtest_prod.h in Headers */,\n\t\t\t\t224A12A30E9EADCC00BD17FD /* gtest-test-part.h in Headers */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXHeadersBuildPhase section */\n\n/* Begin PBXNativeTarget section */\n\t\t40899F420FFA7184000B29AE /* gtest_unittest-framework */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 40899F4A0FFA71BC000B29AE /* Build configuration list for PBXNativeTarget \"gtest_unittest-framework\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t40899F400FFA7184000B29AE /* Sources */,\n\t\t\t\t40899F410FFA7184000B29AE /* Frameworks */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t40C849A0101A36F10083642A /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = \"gtest_unittest-framework\";\n\t\t\tproductName = gtest_unittest;\n\t\t\tproductReference = 40899F430FFA7184000B29AE /* gtest_unittest-framework */;\n\t\t\tproductType = \"com.apple.product-type.tool\";\n\t\t};\n\t\t4089A0120FFACEFC000B29AE /* sample1_unittest-framework */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 4089A0240FFACF01000B29AE /* Build configuration list for PBXNativeTarget \"sample1_unittest-framework\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t4089A0100FFACEFC000B29AE /* Sources */,\n\t\t\t\t4089A0110FFACEFC000B29AE /* Frameworks */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t40C8499E101A36E50083642A /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = \"sample1_unittest-framework\";\n\t\t\tproductName = sample1_unittest;\n\t\t\tproductReference = 4089A0130FFACEFC000B29AE /* sample1_unittest-framework */;\n\t\t\tproductType = \"com.apple.product-type.tool\";\n\t\t};\n\t\t40C848F9101A209C0083642A /* gtest-static */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 40C84902101A212E0083642A /* Build configuration list for PBXNativeTarget \"gtest-static\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t40C848F7101A209C0083642A /* Sources */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = \"gtest-static\";\n\t\t\tproductName = \"gtest-static\";\n\t\t\tproductReference = 40C848FA101A209C0083642A /* libgtest.a */;\n\t\t\tproductType = \"com.apple.product-type.library.static\";\n\t\t};\n\t\t40C8490A101A217E0083642A /* gtest_main-static */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 40C84912101A21D20083642A /* Build configuration list for PBXNativeTarget \"gtest_main-static\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t40C84908101A217E0083642A /* Sources */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t);\n\t\t\tname = \"gtest_main-static\";\n\t\t\tproductName = \"gtest_main-static\";\n\t\t\tproductReference = 40C8490B101A217E0083642A /* libgtest_main.a */;\n\t\t\tproductType = \"com.apple.product-type.library.static\";\n\t\t};\n\t\t40C8497A101A36850083642A /* gtest_unittest-static */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 40C84984101A36850083642A /* Build configuration list for PBXNativeTarget \"gtest_unittest-static\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t40C8497F101A36850083642A /* Sources */,\n\t\t\t\t40C84981101A36850083642A /* Frameworks */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t40C8497B101A36850083642A /* PBXTargetDependency */,\n\t\t\t\t40C8497D101A36850083642A /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = \"gtest_unittest-static\";\n\t\t\tproductName = gtest_unittest;\n\t\t\tproductReference = 40C84987101A36850083642A /* gtest_unittest */;\n\t\t\tproductType = \"com.apple.product-type.tool\";\n\t\t};\n\t\t40C84989101A36A60083642A /* sample1_unittest-static */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 40C84994101A36A60083642A /* Build configuration list for PBXNativeTarget \"sample1_unittest-static\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t40C8498E101A36A60083642A /* Sources */,\n\t\t\t\t40C84991101A36A60083642A /* Frameworks */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t40C8498A101A36A60083642A /* PBXTargetDependency */,\n\t\t\t\t40C8498C101A36A60083642A /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = \"sample1_unittest-static\";\n\t\t\tproductName = sample1_unittest;\n\t\t\tproductReference = 40C84997101A36A60083642A /* sample1_unittest-static */;\n\t\t\tproductType = \"com.apple.product-type.tool\";\n\t\t};\n\t\t8D07F2BC0486CC7A007CD1D0 /* gtest-framework */ = {\n\t\t\tisa = PBXNativeTarget;\n\t\t\tbuildConfigurationList = 4FADC24208B4156D00ABE55E /* Build configuration list for PBXNativeTarget \"gtest-framework\" */;\n\t\t\tbuildPhases = (\n\t\t\t\t8D07F2C10486CC7A007CD1D0 /* Sources */,\n\t\t\t\t8D07F2BD0486CC7A007CD1D0 /* Headers */,\n\t\t\t\t404884A50E2F7C0400CF7658 /* Copy Headers Internal */,\n\t\t\t\t8D07F2BF0486CC7A007CD1D0 /* Resources */,\n\t\t\t);\n\t\t\tbuildRules = (\n\t\t\t);\n\t\t\tdependencies = (\n\t\t\t\t40C44AE60E379922008FCC51 /* PBXTargetDependency */,\n\t\t\t\t408BEC101046CFE900DEF522 /* PBXTargetDependency */,\n\t\t\t\t40C8499C101A36DC0083642A /* PBXTargetDependency */,\n\t\t\t);\n\t\t\tname = \"gtest-framework\";\n\t\t\tproductInstallPath = \"$(HOME)/Library/Frameworks\";\n\t\t\tproductName = gtest;\n\t\t\tproductReference = 4539C8FF0EC27F6400A70F4C /* gtest.framework */;\n\t\t\tproductType = \"com.apple.product-type.framework\";\n\t\t};\n/* End PBXNativeTarget section */\n\n/* Begin PBXProject section */\n\t\t0867D690FE84028FC02AAC07 /* Project object */ = {\n\t\t\tisa = PBXProject;\n\t\t\tattributes = {\n\t\t\t\tLastUpgradeCheck = 0460;\n\t\t\t};\n\t\t\tbuildConfigurationList = 4FADC24608B4156D00ABE55E /* Build configuration list for PBXProject \"gtest\" */;\n\t\t\tcompatibilityVersion = \"Xcode 3.2\";\n\t\t\tdevelopmentRegion = English;\n\t\t\thasScannedForEncodings = 1;\n\t\t\tknownRegions = (\n\t\t\t\tEnglish,\n\t\t\t\tJapanese,\n\t\t\t\tFrench,\n\t\t\t\tGerman,\n\t\t\t\ten,\n\t\t\t);\n\t\t\tmainGroup = 0867D691FE84028FC02AAC07 /* gtest */;\n\t\t\tproductRefGroup = 034768DDFF38A45A11DB9C8B /* Products */;\n\t\t\tprojectDirPath = \"\";\n\t\t\tprojectRoot = \"\";\n\t\t\ttargets = (\n\t\t\t\t8D07F2BC0486CC7A007CD1D0 /* gtest-framework */,\n\t\t\t\t40C848F9101A209C0083642A /* gtest-static */,\n\t\t\t\t40C8490A101A217E0083642A /* gtest_main-static */,\n\t\t\t\t40899F420FFA7184000B29AE /* gtest_unittest-framework */,\n\t\t\t\t40C8497A101A36850083642A /* gtest_unittest-static */,\n\t\t\t\t4089A0120FFACEFC000B29AE /* sample1_unittest-framework */,\n\t\t\t\t40C84989101A36A60083642A /* sample1_unittest-static */,\n\t\t\t\t3B238F5F0E828B5400846E11 /* Check */,\n\t\t\t\t40C44ADC0E3798F4008FCC51 /* Version Info */,\n\t\t\t);\n\t\t};\n/* End PBXProject section */\n\n/* Begin PBXResourcesBuildPhase section */\n\t\t8D07F2BF0486CC7A007CD1D0 /* Resources */ = {\n\t\t\tisa = PBXResourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t404884500E2F799B00CF7658 /* README in Resources */,\n\t\t\t\t404884AC0E2F7CD900CF7658 /* CHANGES in Resources */,\n\t\t\t\t404884AD0E2F7CD900CF7658 /* CONTRIBUTORS in Resources */,\n\t\t\t\t404884AE0E2F7CD900CF7658 /* LICENSE in Resources */,\n\t\t\t\t40C84978101A36540083642A /* libgtest_main.a in Resources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXResourcesBuildPhase section */\n\n/* Begin PBXShellScriptBuildPhase section */\n\t\t3B238F5E0E828B5400846E11 /* ShellScript */ = {\n\t\t\tisa = PBXShellScriptBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tinputPaths = (\n\t\t\t);\n\t\t\toutputPaths = (\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t\tshellPath = /bin/sh;\n\t\t\tshellScript = \"# Remember, this \\\"Run Script\\\" build phase will be executed from $SRCROOT\\n/bin/bash Scripts/runtests.sh\";\n\t\t};\n\t\t40C44ADB0E3798F4008FCC51 /* Generate Version.h */ = {\n\t\t\tisa = PBXShellScriptBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t);\n\t\t\tinputPaths = (\n\t\t\t\t\"$(SRCROOT)/Scripts/versiongenerate.py\",\n\t\t\t\t\"$(SRCROOT)/../configure.ac\",\n\t\t\t);\n\t\t\tname = \"Generate Version.h\";\n\t\t\toutputPaths = (\n\t\t\t\t\"$(PROJECT_TEMP_DIR)/Version.h\",\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t\tshellPath = /bin/sh;\n\t\t\tshellScript = \"# Remember, this \\\"Run Script\\\" build phase will be executed from $SRCROOT\\n/usr/bin/python Scripts/versiongenerate.py ../ $PROJECT_TEMP_DIR\";\n\t\t};\n/* End PBXShellScriptBuildPhase section */\n\n/* Begin PBXSourcesBuildPhase section */\n\t\t40899F400FFA7184000B29AE /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t40899F530FFA72A0000B29AE /* gtest_unittest.cc in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t4089A0100FFACEFC000B29AE /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t4089A0440FFAD1BE000B29AE /* sample1.cc in Sources */,\n\t\t\t\t4089A0460FFAD1BE000B29AE /* sample1_unittest.cc in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t40C848F7101A209C0083642A /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t40C848FF101A21150083642A /* gtest-all.cc in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t40C84908101A217E0083642A /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t40C84915101A21DF0083642A /* gtest_main.cc in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t40C8497F101A36850083642A /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t40C84980101A36850083642A /* gtest_unittest.cc in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t40C8498E101A36A60083642A /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t40C8498F101A36A60083642A /* sample1.cc in Sources */,\n\t\t\t\t40C84990101A36A60083642A /* sample1_unittest.cc in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n\t\t8D07F2C10486CC7A007CD1D0 /* Sources */ = {\n\t\t\tisa = PBXSourcesBuildPhase;\n\t\t\tbuildActionMask = 2147483647;\n\t\t\tfiles = (\n\t\t\t\t40899F3A0FFA70D4000B29AE /* gtest-all.cc in Sources */,\n\t\t\t);\n\t\t\trunOnlyForDeploymentPostprocessing = 0;\n\t\t};\n/* End PBXSourcesBuildPhase section */\n\n/* Begin PBXTargetDependency section */\n\t\t40899F9D0FFA740F000B29AE /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 40899F420FFA7184000B29AE /* gtest_unittest-framework */;\n\t\t\ttargetProxy = 40899F9C0FFA740F000B29AE /* PBXContainerItemProxy */;\n\t\t};\n\t\t4089A0980FFAD34A000B29AE /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 4089A0120FFACEFC000B29AE /* sample1_unittest-framework */;\n\t\t\ttargetProxy = 4089A0970FFAD34A000B29AE /* PBXContainerItemProxy */;\n\t\t};\n\t\t408BEC101046CFE900DEF522 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 40C848F9101A209C0083642A /* gtest-static */;\n\t\t\ttargetProxy = 408BEC0F1046CFE900DEF522 /* PBXContainerItemProxy */;\n\t\t};\n\t\t40C44AE60E379922008FCC51 /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 40C44ADC0E3798F4008FCC51 /* Version Info */;\n\t\t\ttargetProxy = 40C44AE50E379922008FCC51 /* PBXContainerItemProxy */;\n\t\t};\n\t\t40C8497B101A36850083642A /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 40C848F9101A209C0083642A /* gtest-static */;\n\t\t\ttargetProxy = 40C8497C101A36850083642A /* PBXContainerItemProxy */;\n\t\t};\n\t\t40C8497D101A36850083642A /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 40C8490A101A217E0083642A /* gtest_main-static */;\n\t\t\ttargetProxy = 40C8497E101A36850083642A /* PBXContainerItemProxy */;\n\t\t};\n\t\t40C8498A101A36A60083642A /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 40C848F9101A209C0083642A /* gtest-static */;\n\t\t\ttargetProxy = 40C8498B101A36A60083642A /* PBXContainerItemProxy */;\n\t\t};\n\t\t40C8498C101A36A60083642A /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 40C8490A101A217E0083642A /* gtest_main-static */;\n\t\t\ttargetProxy = 40C8498D101A36A60083642A /* PBXContainerItemProxy */;\n\t\t};\n\t\t40C8499C101A36DC0083642A /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 40C8490A101A217E0083642A /* gtest_main-static */;\n\t\t\ttargetProxy = 40C8499B101A36DC0083642A /* PBXContainerItemProxy */;\n\t\t};\n\t\t40C8499E101A36E50083642A /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 8D07F2BC0486CC7A007CD1D0 /* gtest-framework */;\n\t\t\ttargetProxy = 40C8499D101A36E50083642A /* PBXContainerItemProxy */;\n\t\t};\n\t\t40C849A0101A36F10083642A /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 8D07F2BC0486CC7A007CD1D0 /* gtest-framework */;\n\t\t\ttargetProxy = 40C8499F101A36F10083642A /* PBXContainerItemProxy */;\n\t\t};\n\t\t40C849F7101A43440083642A /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 40C8497A101A36850083642A /* gtest_unittest-static */;\n\t\t\ttargetProxy = 40C849F6101A43440083642A /* PBXContainerItemProxy */;\n\t\t};\n\t\t40C849F9101A43490083642A /* PBXTargetDependency */ = {\n\t\t\tisa = PBXTargetDependency;\n\t\t\ttarget = 40C84989101A36A60083642A /* sample1_unittest-static */;\n\t\t\ttargetProxy = 40C849F8101A43490083642A /* PBXContainerItemProxy */;\n\t\t};\n/* End PBXTargetDependency section */\n\n/* Begin XCBuildConfiguration section */\n\t\t3B238F600E828B5400846E11 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tCOPY_PHASE_STRIP = NO;\n\t\t\t\tGCC_DYNAMIC_NO_PIC = NO;\n\t\t\t\tGCC_OPTIMIZATION_LEVEL = 0;\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tPRODUCT_NAME = Check;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t3B238F610E828B5400846E11 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tCOPY_PHASE_STRIP = YES;\n\t\t\t\tDEBUG_INFORMATION_FORMAT = \"dwarf-with-dsym\";\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tPRODUCT_NAME = Check;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t\tZERO_LINK = NO;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t40899F450FFA7185000B29AE /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tHEADER_SEARCH_PATHS = ../;\n\t\t\t\tPRODUCT_NAME = \"gtest_unittest-framework\";\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t40899F460FFA7185000B29AE /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tHEADER_SEARCH_PATHS = ../;\n\t\t\t\tPRODUCT_NAME = \"gtest_unittest-framework\";\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t4089A0150FFACEFD000B29AE /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tPRODUCT_NAME = \"sample1_unittest-framework\";\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t4089A0160FFACEFD000B29AE /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tPRODUCT_NAME = \"sample1_unittest-framework\";\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t40C44ADF0E3798F4008FCC51 /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 10.7;\n\t\t\t\tPRODUCT_NAME = gtest;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t\tTARGET_NAME = gtest;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t40C44AE00E3798F4008FCC51 /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tMACOSX_DEPLOYMENT_TARGET = 10.7;\n\t\t\t\tPRODUCT_NAME = gtest;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t\tTARGET_NAME = gtest;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t40C848FB101A209D0083642A /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 40899FB30FFA7567000B29AE /* StaticLibraryTarget.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tGCC_INLINES_ARE_PRIVATE_EXTERN = YES;\n\t\t\t\tGCC_SYMBOLS_PRIVATE_EXTERN = YES;\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tHEADER_SEARCH_PATHS = (\n\t\t\t\t\t../,\n\t\t\t\t\t../include/,\n\t\t\t\t);\n\t\t\t\tPRODUCT_NAME = gtest;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t40C848FC101A209D0083642A /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 40899FB30FFA7567000B29AE /* StaticLibraryTarget.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tGCC_INLINES_ARE_PRIVATE_EXTERN = YES;\n\t\t\t\tGCC_SYMBOLS_PRIVATE_EXTERN = YES;\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tHEADER_SEARCH_PATHS = (\n\t\t\t\t\t../,\n\t\t\t\t\t../include/,\n\t\t\t\t);\n\t\t\t\tPRODUCT_NAME = gtest;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t40C8490E101A217F0083642A /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 40899FB30FFA7567000B29AE /* StaticLibraryTarget.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tHEADER_SEARCH_PATHS = (\n\t\t\t\t\t../,\n\t\t\t\t\t../include/,\n\t\t\t\t);\n\t\t\t\tPRODUCT_NAME = gtest_main;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t40C8490F101A217F0083642A /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 40899FB30FFA7567000B29AE /* StaticLibraryTarget.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tHEADER_SEARCH_PATHS = (\n\t\t\t\t\t../,\n\t\t\t\t\t../include/,\n\t\t\t\t);\n\t\t\t\tPRODUCT_NAME = gtest_main;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t40C84985101A36850083642A /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tHEADER_SEARCH_PATHS = ../;\n\t\t\t\tPRODUCT_NAME = gtest_unittest;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t40C84986101A36850083642A /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tHEADER_SEARCH_PATHS = ../;\n\t\t\t\tPRODUCT_NAME = gtest_unittest;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t40C84995101A36A60083642A /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tPRODUCT_NAME = \"sample1_unittest-static\";\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t40C84996101A36A60083642A /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbuildSettings = {\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tPRODUCT_NAME = \"sample1_unittest-static\";\n\t\t\t\tSDKROOT = macosx;\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t4FADC24308B4156D00ABE55E /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 40D4CDF20E30E07400294801 /* FrameworkTarget.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tDYLIB_COMPATIBILITY_VERSION = 1;\n\t\t\t\tDYLIB_CURRENT_VERSION = 1;\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tHEADER_SEARCH_PATHS = (\n\t\t\t\t\t../,\n\t\t\t\t\t../include/,\n\t\t\t\t);\n\t\t\t\tINFOPLIST_FILE = Resources/Info.plist;\n\t\t\t\tINFOPLIST_PREFIX_HEADER = \"$(PROJECT_TEMP_DIR)/Version.h\";\n\t\t\t\tINFOPLIST_PREPROCESS = YES;\n\t\t\t\tPRODUCT_NAME = gtest;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t\tVERSIONING_SYSTEM = \"apple-generic\";\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t4FADC24408B4156D00ABE55E /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 40D4CDF20E30E07400294801 /* FrameworkTarget.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t\tCOMBINE_HIDPI_IMAGES = YES;\n\t\t\t\tDYLIB_COMPATIBILITY_VERSION = 1;\n\t\t\t\tDYLIB_CURRENT_VERSION = 1;\n\t\t\t\tGCC_VERSION = com.apple.compilers.llvm.clang.1_0;\n\t\t\t\tHEADER_SEARCH_PATHS = (\n\t\t\t\t\t../,\n\t\t\t\t\t../include/,\n\t\t\t\t);\n\t\t\t\tINFOPLIST_FILE = Resources/Info.plist;\n\t\t\t\tINFOPLIST_PREFIX_HEADER = \"$(PROJECT_TEMP_DIR)/Version.h\";\n\t\t\t\tINFOPLIST_PREPROCESS = YES;\n\t\t\t\tPRODUCT_NAME = gtest;\n\t\t\t\tSDKROOT = macosx;\n\t\t\t\tVERSIONING_SYSTEM = \"apple-generic\";\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n\t\t4FADC24708B4156D00ABE55E /* Debug */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 40D4CDF10E30E07400294801 /* DebugProject.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t};\n\t\t\tname = Debug;\n\t\t};\n\t\t4FADC24808B4156D00ABE55E /* Release */ = {\n\t\t\tisa = XCBuildConfiguration;\n\t\t\tbaseConfigurationReference = 40D4CDF40E30E07400294801 /* ReleaseProject.xcconfig */;\n\t\t\tbuildSettings = {\n\t\t\t};\n\t\t\tname = Release;\n\t\t};\n/* End XCBuildConfiguration section */\n\n/* Begin XCConfigurationList section */\n\t\t3B238FA30E828BB600846E11 /* Build configuration list for PBXAggregateTarget \"Check\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t3B238F600E828B5400846E11 /* Debug */,\n\t\t\t\t3B238F610E828B5400846E11 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t40899F4A0FFA71BC000B29AE /* Build configuration list for PBXNativeTarget \"gtest_unittest-framework\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t40899F450FFA7185000B29AE /* Debug */,\n\t\t\t\t40899F460FFA7185000B29AE /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t4089A0240FFACF01000B29AE /* Build configuration list for PBXNativeTarget \"sample1_unittest-framework\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t4089A0150FFACEFD000B29AE /* Debug */,\n\t\t\t\t4089A0160FFACEFD000B29AE /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t40C44AE40E379905008FCC51 /* Build configuration list for PBXAggregateTarget \"Version Info\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t40C44ADF0E3798F4008FCC51 /* Debug */,\n\t\t\t\t40C44AE00E3798F4008FCC51 /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t40C84902101A212E0083642A /* Build configuration list for PBXNativeTarget \"gtest-static\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t40C848FB101A209D0083642A /* Debug */,\n\t\t\t\t40C848FC101A209D0083642A /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t40C84912101A21D20083642A /* Build configuration list for PBXNativeTarget \"gtest_main-static\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t40C8490E101A217F0083642A /* Debug */,\n\t\t\t\t40C8490F101A217F0083642A /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t40C84984101A36850083642A /* Build configuration list for PBXNativeTarget \"gtest_unittest-static\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t40C84985101A36850083642A /* Debug */,\n\t\t\t\t40C84986101A36850083642A /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t40C84994101A36A60083642A /* Build configuration list for PBXNativeTarget \"sample1_unittest-static\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t40C84995101A36A60083642A /* Debug */,\n\t\t\t\t40C84996101A36A60083642A /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t4FADC24208B4156D00ABE55E /* Build configuration list for PBXNativeTarget \"gtest-framework\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t4FADC24308B4156D00ABE55E /* Debug */,\n\t\t\t\t4FADC24408B4156D00ABE55E /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n\t\t4FADC24608B4156D00ABE55E /* Build configuration list for PBXProject \"gtest\" */ = {\n\t\t\tisa = XCConfigurationList;\n\t\t\tbuildConfigurations = (\n\t\t\t\t4FADC24708B4156D00ABE55E /* Debug */,\n\t\t\t\t4FADC24808B4156D00ABE55E /* Release */,\n\t\t\t);\n\t\t\tdefaultConfigurationIsVisible = 0;\n\t\t\tdefaultConfigurationName = Release;\n\t\t};\n/* End XCConfigurationList section */\n\t};\n\trootObject = 0867D690FE84028FC02AAC07 /* Project object */;\n}\n"
  },
  {
    "path": "ext/protobuf/CMakeLists.txt",
    "content": "# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n# This cmake file builds protoc, the protobuf compiler.\n# We also build libprotobuf.a and libprotobuf-lite.a, the protobuf runtime\n# support libraries.\n\n# The files in protobuf-3.0.0/ are unmodified versions of google source files.\n# To save some space and time, we have remove directories which are not\n# needed by MySQL:\n#   protobuf-3.0.0/gmock/\n#   protobuf-3.0.0/benchmarks/\n#   protobuf-3.0.0/examples/\n#   protobuf-3.0.0/objectivec/\n\n\nSET(PROTOBUF_MSVC_DISABLED_WARNINGS \"/wd4018 /wd4005 /wd4244 /wd4267 /wd4065\")\n\nenable_language(CXX)\ninclude(CheckCXXCompilerFlag)\n\n# Turn off some warning flags when compiling protobuf\nCHECK_CXX_COMPILER_FLAG(\"-Wno-sign-compare\" HAVE_NO_SIGN_COMPARE)\nIF(HAVE_NO_SIGN_COMPARE)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-sign-compare\")\nENDIF()\n\nCHECK_CXX_COMPILER_FLAG(\"-Wno-unused-local-typedefs\" HAVE_NO_UNUSED_TYPEDEFS)\nIF(HAVE_NO_UNUSED_TYPEDEFS)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs\")\nENDIF()\n\nCHECK_CXX_COMPILER_FLAG(\"-Wno-ignored-qualifiers\" HAVE_NO_IGNORED_QUALIFIERS)\nIF(HAVE_NO_IGNORED_QUALIFIERS)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-ignored-qualifiers\")\nENDIF()\n\nCHECK_CXX_COMPILER_FLAG(\"-Wno-return-type\" HAVE_NO_RETURN_TYPE)\nIF(HAVE_NO_RETURN_TYPE)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-return-type\")\nENDIF()\n\nCHECK_CXX_COMPILER_FLAG(\"-Wno-unused-function\" HAVE_NO_UNUSED_FUNCTION)\nIF(HAVE_NO_UNUSED_FUNCTION)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-unused-function\")\nENDIF()\n\nCHECK_CXX_COMPILER_FLAG(\"-Wmaybe-uninitialized\" HAVE_MAYBE_UNINITIALIZED)\nIF(HAVE_MAYBE_UNINITIALIZED)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized\")\nENDIF()\n\nCHECK_CXX_COMPILER_FLAG(\"-Wunused-but-set-parameter\" HAVE_UNUSED_BUT_SET)\nIF(HAVE_UNUSED_BUT_SET)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-unused-but-set-parameter\")\nENDIF()\n\nCHECK_CXX_COMPILER_FLAG(\"-Wunused-parameter\" HAVE_UNUSED)\nIF(HAVE_UNUSED)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-unused-parameter\")\nENDIF()\n\nCHECK_CXX_COMPILER_FLAG(\"-Wshadow\" HAVE_SHADOW)\nIF(HAVE_SHADOW)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-shadow\")\nENDIF()\n\nCHECK_CXX_COMPILER_FLAG(\"-Wconversion\" HAVE_CONVERSION)\nIF(HAVE_CONVERSION)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-conversion\")\nENDIF()\n\nCHECK_CXX_COMPILER_FLAG(\"-Wpedantic\" HAVE_PEDANTIC)\nIF(HAVE_PEDANTIC)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-pedantic\")\nENDIF()\n\nCHECK_CXX_COMPILER_FLAG(\"-Werror\" HAVE_ERROR)\nIF(HAVE_ERROR)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-error\")\nENDIF()\n\nCHECK_CXX_COMPILER_FLAG(\"-Wenum-compare\" HAVE_EC)\nIF(HAVE_EC)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-enum-compare\")\nENDIF()\n\nCHECK_CXX_COMPILER_FLAG(\"-Wdeprecated-declarations\" HAVE_DD)\nIF(HAVE_DD)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations\")\nENDIF()\n\n# silence\n# runtime error: null pointer passed as argument 1, which is declared to never be null\n# /usr/include/string.h:43:28: note: nonnull attribute specified here\nCHECK_CXX_COMPILER_FLAG(\"-fno-sanitize=nonnull-attribute\" HAVE_NO_SANITIZE_NONULL_ATTRIBUTE)\nIF(HAVE_NO_SANITIZE_NONULL_ATTRIBUTE)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -fno-sanitize=nonnull-attribute\")\nENDIF()\n\nset(CMAKE_POSITION_INDEPENDENT_CODE ON)\nADD_SUBDIRECTORY(protobuf-3.0.0/cmake)\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/BUILD",
    "content": "# Bazel (http://bazel.io/) BUILD file for Protobuf.\n\nlicenses([\"notice\"])\n\n################################################################################\n# Protobuf Runtime Library\n################################################################################\n\nCOPTS = [\n    \"-DHAVE_PTHREAD\",\n    \"-Wall\",\n    \"-Wwrite-strings\",\n    \"-Woverloaded-virtual\",\n    \"-Wno-sign-compare\",\n    \"-Wno-error=unused-function\",\n]\n\nconfig_setting(\n    name = \"android\",\n    values = {\n        \"crosstool_top\": \"//external:android/crosstool\",\n    },\n)\n\n# Android builds do not need to link in a separate pthread library.\nLINK_OPTS = select({\n    \":android\": [],\n    \"//conditions:default\": [\"-lpthread\"],\n})\n\nload(\n    \"protobuf\",\n    \"cc_proto_library\",\n    \"py_proto_library\",\n    \"internal_copied_filegroup\",\n    \"internal_gen_well_known_protos_java\",\n    \"internal_protobuf_py_tests\",\n)\n\nconfig_setting(\n    name = \"ios_armv7\",\n    values = {\n        \"ios_cpu\": \"armv7\",\n    },\n)\n\nconfig_setting(\n    name = \"ios_armv7s\",\n    values = {\n        \"ios_cpu\": \"armv7s\",\n    },\n)\n\nconfig_setting(\n    name = \"ios_arm64\",\n    values = {\n        \"ios_cpu\": \"arm64\",\n    },\n)\n\nIOS_ARM_COPTS = COPTS + [\n    \"-DOS_IOS\",\n    \"-miphoneos-version-min=7.0\",\n    \"-arch armv7\",\n    \"-arch armv7s\",\n    \"-arch arm64\",\n    \"-D__thread=\",\n    \"-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.2.sdk/\",\n]\n\ncc_library(\n    name = \"protobuf_lite\",\n    srcs = [\n        # AUTOGEN(protobuf_lite_srcs)\n        \"src/google/protobuf/arena.cc\",\n        \"src/google/protobuf/arenastring.cc\",\n        \"src/google/protobuf/extension_set.cc\",\n        \"src/google/protobuf/generated_message_util.cc\",\n        \"src/google/protobuf/io/coded_stream.cc\",\n        \"src/google/protobuf/io/zero_copy_stream.cc\",\n        \"src/google/protobuf/io/zero_copy_stream_impl_lite.cc\",\n        \"src/google/protobuf/message_lite.cc\",\n        \"src/google/protobuf/repeated_field.cc\",\n        \"src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc\",\n        \"src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc\",\n        \"src/google/protobuf/stubs/bytestream.cc\",\n        \"src/google/protobuf/stubs/common.cc\",\n        \"src/google/protobuf/stubs/int128.cc\",\n        \"src/google/protobuf/stubs/once.cc\",\n        \"src/google/protobuf/stubs/status.cc\",\n        \"src/google/protobuf/stubs/statusor.cc\",\n        \"src/google/protobuf/stubs/stringpiece.cc\",\n        \"src/google/protobuf/stubs/stringprintf.cc\",\n        \"src/google/protobuf/stubs/structurally_valid.cc\",\n        \"src/google/protobuf/stubs/strutil.cc\",\n        \"src/google/protobuf/stubs/time.cc\",\n        \"src/google/protobuf/wire_format_lite.cc\",\n    ],\n    hdrs = glob([\"src/google/protobuf/**/*.h\"]),\n    copts = select({\n        \":ios_armv7\": IOS_ARM_COPTS,\n        \":ios_armv7s\": IOS_ARM_COPTS,\n        \":ios_arm64\": IOS_ARM_COPTS,\n        \"//conditions:default\": COPTS,\n    }),\n    includes = [\"src/\"],\n    linkopts = LINK_OPTS,\n    visibility = [\"//visibility:public\"],\n)\n\ncc_library(\n    name = \"protobuf\",\n    srcs = [\n        # AUTOGEN(protobuf_srcs)\n        \"src/google/protobuf/any.cc\",\n        \"src/google/protobuf/any.pb.cc\",\n        \"src/google/protobuf/api.pb.cc\",\n        \"src/google/protobuf/compiler/importer.cc\",\n        \"src/google/protobuf/compiler/parser.cc\",\n        \"src/google/protobuf/descriptor.cc\",\n        \"src/google/protobuf/descriptor.pb.cc\",\n        \"src/google/protobuf/descriptor_database.cc\",\n        \"src/google/protobuf/duration.pb.cc\",\n        \"src/google/protobuf/dynamic_message.cc\",\n        \"src/google/protobuf/empty.pb.cc\",\n        \"src/google/protobuf/extension_set_heavy.cc\",\n        \"src/google/protobuf/field_mask.pb.cc\",\n        \"src/google/protobuf/generated_message_reflection.cc\",\n        \"src/google/protobuf/io/gzip_stream.cc\",\n        \"src/google/protobuf/io/printer.cc\",\n        \"src/google/protobuf/io/strtod.cc\",\n        \"src/google/protobuf/io/tokenizer.cc\",\n        \"src/google/protobuf/io/zero_copy_stream_impl.cc\",\n        \"src/google/protobuf/map_field.cc\",\n        \"src/google/protobuf/message.cc\",\n        \"src/google/protobuf/reflection_ops.cc\",\n        \"src/google/protobuf/service.cc\",\n        \"src/google/protobuf/source_context.pb.cc\",\n        \"src/google/protobuf/struct.pb.cc\",\n        \"src/google/protobuf/stubs/mathlimits.cc\",\n        \"src/google/protobuf/stubs/substitute.cc\",\n        \"src/google/protobuf/text_format.cc\",\n        \"src/google/protobuf/timestamp.pb.cc\",\n        \"src/google/protobuf/type.pb.cc\",\n        \"src/google/protobuf/unknown_field_set.cc\",\n        \"src/google/protobuf/util/field_comparator.cc\",\n        \"src/google/protobuf/util/field_mask_util.cc\",\n        \"src/google/protobuf/util/internal/datapiece.cc\",\n        \"src/google/protobuf/util/internal/default_value_objectwriter.cc\",\n        \"src/google/protobuf/util/internal/error_listener.cc\",\n        \"src/google/protobuf/util/internal/field_mask_utility.cc\",\n        \"src/google/protobuf/util/internal/json_escaping.cc\",\n        \"src/google/protobuf/util/internal/json_objectwriter.cc\",\n        \"src/google/protobuf/util/internal/json_stream_parser.cc\",\n        \"src/google/protobuf/util/internal/object_writer.cc\",\n        \"src/google/protobuf/util/internal/proto_writer.cc\",\n        \"src/google/protobuf/util/internal/protostream_objectsource.cc\",\n        \"src/google/protobuf/util/internal/protostream_objectwriter.cc\",\n        \"src/google/protobuf/util/internal/type_info.cc\",\n        \"src/google/protobuf/util/internal/type_info_test_helper.cc\",\n        \"src/google/protobuf/util/internal/utility.cc\",\n        \"src/google/protobuf/util/json_util.cc\",\n        \"src/google/protobuf/util/message_differencer.cc\",\n        \"src/google/protobuf/util/time_util.cc\",\n        \"src/google/protobuf/util/type_resolver_util.cc\",\n        \"src/google/protobuf/wire_format.cc\",\n        \"src/google/protobuf/wrappers.pb.cc\",\n    ],\n    hdrs = glob([\"src/**/*.h\"]),\n    copts = select({\n        \":ios_armv7\": IOS_ARM_COPTS,\n        \":ios_armv7s\": IOS_ARM_COPTS,\n        \":ios_arm64\": IOS_ARM_COPTS,\n        \"//conditions:default\": COPTS,\n    }),\n    includes = [\"src/\"],\n    linkopts = LINK_OPTS,\n    visibility = [\"//visibility:public\"],\n    deps = [\":protobuf_lite\"],\n)\n\nobjc_library(\n    name = \"protobuf_objc\",\n    hdrs = [\"objectivec/GPBProtocolBuffers.h\"],\n    includes = [\"objectivec\"],\n    non_arc_srcs = [\"objectivec/GPBProtocolBuffers.m\"],\n    visibility = [\"//visibility:public\"],\n)\n\nRELATIVE_WELL_KNOWN_PROTOS = [\n    # AUTOGEN(well_known_protos)\n    \"google/protobuf/any.proto\",\n    \"google/protobuf/api.proto\",\n    \"google/protobuf/compiler/plugin.proto\",\n    \"google/protobuf/descriptor.proto\",\n    \"google/protobuf/duration.proto\",\n    \"google/protobuf/empty.proto\",\n    \"google/protobuf/field_mask.proto\",\n    \"google/protobuf/source_context.proto\",\n    \"google/protobuf/struct.proto\",\n    \"google/protobuf/timestamp.proto\",\n    \"google/protobuf/type.proto\",\n    \"google/protobuf/wrappers.proto\",\n]\n\nWELL_KNOWN_PROTOS = [\"src/\" + s for s in RELATIVE_WELL_KNOWN_PROTOS]\n\nfilegroup(\n    name = \"well_known_protos\",\n    srcs = WELL_KNOWN_PROTOS,\n    visibility = [\"//visibility:public\"],\n)\n\ncc_proto_library(\n    name = \"cc_wkt_protos\",\n    srcs = WELL_KNOWN_PROTOS,\n    include = \"src\",\n    default_runtime = \":protobuf\",\n    internal_bootstrap_hack = 1,\n    protoc = \":protoc\",\n    visibility = [\"//visibility:public\"],\n)\n\n################################################################################\n# Protocol Buffers Compiler\n################################################################################\n\ncc_library(\n    name = \"protoc_lib\",\n    srcs = [\n        # AUTOGEN(protoc_lib_srcs)\n        \"src/google/protobuf/compiler/code_generator.cc\",\n        \"src/google/protobuf/compiler/command_line_interface.cc\",\n        \"src/google/protobuf/compiler/cpp/cpp_enum.cc\",\n        \"src/google/protobuf/compiler/cpp/cpp_enum_field.cc\",\n        \"src/google/protobuf/compiler/cpp/cpp_extension.cc\",\n        \"src/google/protobuf/compiler/cpp/cpp_field.cc\",\n        \"src/google/protobuf/compiler/cpp/cpp_file.cc\",\n        \"src/google/protobuf/compiler/cpp/cpp_generator.cc\",\n        \"src/google/protobuf/compiler/cpp/cpp_helpers.cc\",\n        \"src/google/protobuf/compiler/cpp/cpp_map_field.cc\",\n        \"src/google/protobuf/compiler/cpp/cpp_message.cc\",\n        \"src/google/protobuf/compiler/cpp/cpp_message_field.cc\",\n        \"src/google/protobuf/compiler/cpp/cpp_primitive_field.cc\",\n        \"src/google/protobuf/compiler/cpp/cpp_service.cc\",\n        \"src/google/protobuf/compiler/cpp/cpp_string_field.cc\",\n        \"src/google/protobuf/compiler/csharp/csharp_doc_comment.cc\",\n        \"src/google/protobuf/compiler/csharp/csharp_enum.cc\",\n        \"src/google/protobuf/compiler/csharp/csharp_enum_field.cc\",\n        \"src/google/protobuf/compiler/csharp/csharp_field_base.cc\",\n        \"src/google/protobuf/compiler/csharp/csharp_generator.cc\",\n        \"src/google/protobuf/compiler/csharp/csharp_helpers.cc\",\n        \"src/google/protobuf/compiler/csharp/csharp_map_field.cc\",\n        \"src/google/protobuf/compiler/csharp/csharp_message.cc\",\n        \"src/google/protobuf/compiler/csharp/csharp_message_field.cc\",\n        \"src/google/protobuf/compiler/csharp/csharp_primitive_field.cc\",\n        \"src/google/protobuf/compiler/csharp/csharp_reflection_class.cc\",\n        \"src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc\",\n        \"src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc\",\n        \"src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc\",\n        \"src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc\",\n        \"src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc\",\n        \"src/google/protobuf/compiler/java/java_context.cc\",\n        \"src/google/protobuf/compiler/java/java_doc_comment.cc\",\n        \"src/google/protobuf/compiler/java/java_enum.cc\",\n        \"src/google/protobuf/compiler/java/java_enum_field.cc\",\n        \"src/google/protobuf/compiler/java/java_enum_field_lite.cc\",\n        \"src/google/protobuf/compiler/java/java_enum_lite.cc\",\n        \"src/google/protobuf/compiler/java/java_extension.cc\",\n        \"src/google/protobuf/compiler/java/java_extension_lite.cc\",\n        \"src/google/protobuf/compiler/java/java_field.cc\",\n        \"src/google/protobuf/compiler/java/java_file.cc\",\n        \"src/google/protobuf/compiler/java/java_generator.cc\",\n        \"src/google/protobuf/compiler/java/java_generator_factory.cc\",\n        \"src/google/protobuf/compiler/java/java_helpers.cc\",\n        \"src/google/protobuf/compiler/java/java_lazy_message_field.cc\",\n        \"src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc\",\n        \"src/google/protobuf/compiler/java/java_map_field.cc\",\n        \"src/google/protobuf/compiler/java/java_map_field_lite.cc\",\n        \"src/google/protobuf/compiler/java/java_message.cc\",\n        \"src/google/protobuf/compiler/java/java_message_builder.cc\",\n        \"src/google/protobuf/compiler/java/java_message_builder_lite.cc\",\n        \"src/google/protobuf/compiler/java/java_message_field.cc\",\n        \"src/google/protobuf/compiler/java/java_message_field_lite.cc\",\n        \"src/google/protobuf/compiler/java/java_message_lite.cc\",\n        \"src/google/protobuf/compiler/java/java_name_resolver.cc\",\n        \"src/google/protobuf/compiler/java/java_primitive_field.cc\",\n        \"src/google/protobuf/compiler/java/java_primitive_field_lite.cc\",\n        \"src/google/protobuf/compiler/java/java_service.cc\",\n        \"src/google/protobuf/compiler/java/java_shared_code_generator.cc\",\n        \"src/google/protobuf/compiler/java/java_string_field.cc\",\n        \"src/google/protobuf/compiler/java/java_string_field_lite.cc\",\n        \"src/google/protobuf/compiler/javanano/javanano_enum.cc\",\n        \"src/google/protobuf/compiler/javanano/javanano_enum_field.cc\",\n        \"src/google/protobuf/compiler/javanano/javanano_extension.cc\",\n        \"src/google/protobuf/compiler/javanano/javanano_field.cc\",\n        \"src/google/protobuf/compiler/javanano/javanano_file.cc\",\n        \"src/google/protobuf/compiler/javanano/javanano_generator.cc\",\n        \"src/google/protobuf/compiler/javanano/javanano_helpers.cc\",\n        \"src/google/protobuf/compiler/javanano/javanano_map_field.cc\",\n        \"src/google/protobuf/compiler/javanano/javanano_message.cc\",\n        \"src/google/protobuf/compiler/javanano/javanano_message_field.cc\",\n        \"src/google/protobuf/compiler/javanano/javanano_primitive_field.cc\",\n        \"src/google/protobuf/compiler/js/js_generator.cc\",\n        \"src/google/protobuf/compiler/objectivec/objectivec_enum.cc\",\n        \"src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc\",\n        \"src/google/protobuf/compiler/objectivec/objectivec_extension.cc\",\n        \"src/google/protobuf/compiler/objectivec/objectivec_field.cc\",\n        \"src/google/protobuf/compiler/objectivec/objectivec_file.cc\",\n        \"src/google/protobuf/compiler/objectivec/objectivec_generator.cc\",\n        \"src/google/protobuf/compiler/objectivec/objectivec_helpers.cc\",\n        \"src/google/protobuf/compiler/objectivec/objectivec_map_field.cc\",\n        \"src/google/protobuf/compiler/objectivec/objectivec_message.cc\",\n        \"src/google/protobuf/compiler/objectivec/objectivec_message_field.cc\",\n        \"src/google/protobuf/compiler/objectivec/objectivec_oneof.cc\",\n        \"src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc\",\n        \"src/google/protobuf/compiler/plugin.cc\",\n        \"src/google/protobuf/compiler/plugin.pb.cc\",\n        \"src/google/protobuf/compiler/python/python_generator.cc\",\n        \"src/google/protobuf/compiler/ruby/ruby_generator.cc\",\n        \"src/google/protobuf/compiler/subprocess.cc\",\n        \"src/google/protobuf/compiler/zip_writer.cc\",\n    ],\n    copts = COPTS,\n    includes = [\"src/\"],\n    linkopts = LINK_OPTS,\n    visibility = [\"//visibility:public\"],\n    deps = [\":protobuf\"],\n)\n\ncc_binary(\n    name = \"protoc\",\n    srcs = [\"src/google/protobuf/compiler/main.cc\"],\n    linkopts = LINK_OPTS,\n    visibility = [\"//visibility:public\"],\n    deps = [\":protoc_lib\"],\n)\n\n################################################################################\n# Tests\n################################################################################\n\nRELATIVE_LITE_TEST_PROTOS = [\n    # AUTOGEN(lite_test_protos)\n    \"google/protobuf/map_lite_unittest.proto\",\n    \"google/protobuf/unittest_import_lite.proto\",\n    \"google/protobuf/unittest_import_public_lite.proto\",\n    \"google/protobuf/unittest_lite.proto\",\n    \"google/protobuf/unittest_no_arena_lite.proto\",\n]\n\nLITE_TEST_PROTOS = [\"src/\" + s for s in RELATIVE_LITE_TEST_PROTOS]\n\nRELATIVE_TEST_PROTOS = [\n    # AUTOGEN(test_protos)\n    \"google/protobuf/any_test.proto\",\n    \"google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto\",\n    \"google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto\",\n    \"google/protobuf/map_proto2_unittest.proto\",\n    \"google/protobuf/map_unittest.proto\",\n    \"google/protobuf/unittest.proto\",\n    \"google/protobuf/unittest_arena.proto\",\n    \"google/protobuf/unittest_custom_options.proto\",\n    \"google/protobuf/unittest_drop_unknown_fields.proto\",\n    \"google/protobuf/unittest_embed_optimize_for.proto\",\n    \"google/protobuf/unittest_empty.proto\",\n    \"google/protobuf/unittest_enormous_descriptor.proto\",\n    \"google/protobuf/unittest_import.proto\",\n    \"google/protobuf/unittest_import_public.proto\",\n    \"google/protobuf/unittest_lite_imports_nonlite.proto\",\n    \"google/protobuf/unittest_mset.proto\",\n    \"google/protobuf/unittest_mset_wire_format.proto\",\n    \"google/protobuf/unittest_no_arena.proto\",\n    \"google/protobuf/unittest_no_arena_import.proto\",\n    \"google/protobuf/unittest_no_field_presence.proto\",\n    \"google/protobuf/unittest_no_generic_services.proto\",\n    \"google/protobuf/unittest_optimize_for.proto\",\n    \"google/protobuf/unittest_preserve_unknown_enum.proto\",\n    \"google/protobuf/unittest_preserve_unknown_enum2.proto\",\n    \"google/protobuf/unittest_proto3_arena.proto\",\n    \"google/protobuf/unittest_proto3_arena_lite.proto\",\n    \"google/protobuf/unittest_proto3_lite.proto\",\n    \"google/protobuf/unittest_well_known_types.proto\",\n    \"google/protobuf/util/internal/testdata/anys.proto\",\n    \"google/protobuf/util/internal/testdata/books.proto\",\n    \"google/protobuf/util/internal/testdata/default_value.proto\",\n    \"google/protobuf/util/internal/testdata/default_value_test.proto\",\n    \"google/protobuf/util/internal/testdata/field_mask.proto\",\n    \"google/protobuf/util/internal/testdata/maps.proto\",\n    \"google/protobuf/util/internal/testdata/oneofs.proto\",\n    \"google/protobuf/util/internal/testdata/struct.proto\",\n    \"google/protobuf/util/internal/testdata/timestamp_duration.proto\",\n    \"google/protobuf/util/json_format_proto3.proto\",\n    \"google/protobuf/util/message_differencer_unittest.proto\",\n]\n\nTEST_PROTOS = [\"src/\" + s for s in RELATIVE_TEST_PROTOS]\n\ncc_proto_library(\n    name = \"cc_test_protos\",\n    srcs = LITE_TEST_PROTOS + TEST_PROTOS,\n    include = \"src\",\n    default_runtime = \":protobuf\",\n    protoc = \":protoc\",\n    deps = [\":cc_wkt_protos\"],\n)\n\nCOMMON_TEST_SRCS = [\n    # AUTOGEN(common_test_srcs)\n    \"src/google/protobuf/arena_test_util.cc\",\n    \"src/google/protobuf/map_test_util.cc\",\n    \"src/google/protobuf/test_util.cc\",\n    \"src/google/protobuf/testing/file.cc\",\n    \"src/google/protobuf/testing/googletest.cc\",\n]\n\ncc_binary(\n    name = \"test_plugin\",\n    srcs = [\n        # AUTOGEN(test_plugin_srcs)\n        \"src/google/protobuf/compiler/mock_code_generator.cc\",\n        \"src/google/protobuf/compiler/test_plugin.cc\",\n        \"src/google/protobuf/testing/file.cc\",\n    ],\n    deps = [\n        \":protobuf\",\n        \":protoc_lib\",\n        \"//external:gtest\",\n    ],\n)\n\ncc_test(\n    name = \"protobuf_test\",\n    srcs = COMMON_TEST_SRCS + [\n        # AUTOGEN(test_srcs)\n        \"src/google/protobuf/any_test.cc\",\n        \"src/google/protobuf/arena_unittest.cc\",\n        \"src/google/protobuf/arenastring_unittest.cc\",\n        \"src/google/protobuf/compiler/command_line_interface_unittest.cc\",\n        \"src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc\",\n        \"src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc\",\n        \"src/google/protobuf/compiler/cpp/cpp_unittest.cc\",\n        \"src/google/protobuf/compiler/cpp/metadata_test.cc\",\n        \"src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc\",\n        \"src/google/protobuf/compiler/importer_unittest.cc\",\n        \"src/google/protobuf/compiler/java/java_doc_comment_unittest.cc\",\n        \"src/google/protobuf/compiler/java/java_plugin_unittest.cc\",\n        \"src/google/protobuf/compiler/mock_code_generator.cc\",\n        \"src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc\",\n        \"src/google/protobuf/compiler/parser_unittest.cc\",\n        \"src/google/protobuf/compiler/python/python_plugin_unittest.cc\",\n        \"src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc\",\n        \"src/google/protobuf/descriptor_database_unittest.cc\",\n        \"src/google/protobuf/descriptor_unittest.cc\",\n        \"src/google/protobuf/drop_unknown_fields_test.cc\",\n        \"src/google/protobuf/dynamic_message_unittest.cc\",\n        \"src/google/protobuf/extension_set_unittest.cc\",\n        \"src/google/protobuf/generated_message_reflection_unittest.cc\",\n        \"src/google/protobuf/io/coded_stream_unittest.cc\",\n        \"src/google/protobuf/io/printer_unittest.cc\",\n        \"src/google/protobuf/io/tokenizer_unittest.cc\",\n        \"src/google/protobuf/io/zero_copy_stream_unittest.cc\",\n        \"src/google/protobuf/map_field_test.cc\",\n        \"src/google/protobuf/map_test.cc\",\n        \"src/google/protobuf/message_unittest.cc\",\n        \"src/google/protobuf/no_field_presence_test.cc\",\n        \"src/google/protobuf/preserve_unknown_enum_test.cc\",\n        \"src/google/protobuf/proto3_arena_lite_unittest.cc\",\n        \"src/google/protobuf/proto3_arena_unittest.cc\",\n        \"src/google/protobuf/proto3_lite_unittest.cc\",\n        \"src/google/protobuf/reflection_ops_unittest.cc\",\n        \"src/google/protobuf/repeated_field_reflection_unittest.cc\",\n        \"src/google/protobuf/repeated_field_unittest.cc\",\n        \"src/google/protobuf/stubs/bytestream_unittest.cc\",\n        \"src/google/protobuf/stubs/common_unittest.cc\",\n        \"src/google/protobuf/stubs/int128_unittest.cc\",\n        \"src/google/protobuf/stubs/once_unittest.cc\",\n        \"src/google/protobuf/stubs/status_test.cc\",\n        \"src/google/protobuf/stubs/statusor_test.cc\",\n        \"src/google/protobuf/stubs/stringpiece_unittest.cc\",\n        \"src/google/protobuf/stubs/stringprintf_unittest.cc\",\n        \"src/google/protobuf/stubs/structurally_valid_unittest.cc\",\n        \"src/google/protobuf/stubs/strutil_unittest.cc\",\n        \"src/google/protobuf/stubs/template_util_unittest.cc\",\n        \"src/google/protobuf/stubs/time_test.cc\",\n        \"src/google/protobuf/stubs/type_traits_unittest.cc\",\n        \"src/google/protobuf/text_format_unittest.cc\",\n        \"src/google/protobuf/unknown_field_set_unittest.cc\",\n        \"src/google/protobuf/util/field_comparator_test.cc\",\n        \"src/google/protobuf/util/field_mask_util_test.cc\",\n        \"src/google/protobuf/util/internal/default_value_objectwriter_test.cc\",\n        \"src/google/protobuf/util/internal/json_objectwriter_test.cc\",\n        \"src/google/protobuf/util/internal/json_stream_parser_test.cc\",\n        \"src/google/protobuf/util/internal/protostream_objectsource_test.cc\",\n        \"src/google/protobuf/util/internal/protostream_objectwriter_test.cc\",\n        \"src/google/protobuf/util/internal/type_info_test_helper.cc\",\n        \"src/google/protobuf/util/json_util_test.cc\",\n        \"src/google/protobuf/util/message_differencer_unittest.cc\",\n        \"src/google/protobuf/util/time_util_test.cc\",\n        \"src/google/protobuf/util/type_resolver_util_test.cc\",\n        \"src/google/protobuf/well_known_types_unittest.cc\",\n        \"src/google/protobuf/wire_format_unittest.cc\",\n    ],\n    copts = COPTS,\n    data = [\n        \":test_plugin\",\n    ] + glob([\n        \"src/google/protobuf/**/*\",\n    ]),\n    includes = [\n        \"src/\",\n    ],\n    linkopts = LINK_OPTS,\n    deps = [\n        \":cc_test_protos\",\n        \":protobuf\",\n        \":protoc_lib\",\n        \"//external:gtest_main\",\n    ],\n)\n\n################################################################################\n# Java support\n################################################################################\ninternal_gen_well_known_protos_java(\n    srcs = WELL_KNOWN_PROTOS,\n)\n\njava_library(\n    name = \"protobuf_java\",\n    srcs = glob([\n        \"java/core/src/main/java/com/google/protobuf/*.java\",\n    ]) + [\n        \":gen_well_known_protos_java\",\n    ],\n    visibility = [\"//visibility:public\"],\n)\n\njava_library(\n    name = \"protobuf_java_util\",\n    srcs = glob([\n        \"java/util/src/main/java/com/google/protobuf/util/*.java\",\n    ]),\n    deps = [\n        \"protobuf_java\",\n        \"//external:gson\",\n        \"//external:guava\",\n    ],\n    visibility = [\"//visibility:public\"],\n)\n\n################################################################################\n# Python support\n################################################################################\n\npy_library(\n    name = \"python_srcs\",\n    srcs = glob(\n        [\n            \"python/google/protobuf/*.py\",\n            \"python/google/protobuf/**/*.py\",\n        ],\n        exclude = [\n            \"python/google/protobuf/__init__.py\",\n            \"python/google/protobuf/**/__init__.py\",\n            \"python/google/protobuf/internal/*_test.py\",\n            \"python/google/protobuf/internal/test_util.py\",\n        ],\n    ),\n    srcs_version = \"PY2AND3\",\n    imports = [\"python\"],\n)\n\ncc_binary(\n    name = \"internal/_api_implementation.so\",\n    srcs = [\"python/google/protobuf/internal/api_implementation.cc\"],\n    copts = COPTS + [\n        \"-DPYTHON_PROTO2_CPP_IMPL_V2\",\n    ],\n    linkshared = 1,\n    linkstatic = 1,\n    deps = select({\n        \"//conditions:default\": [],\n        \":use_fast_cpp_protos\": [\"//external:python_headers\"],\n    }),\n)\n\ncc_binary(\n    name = \"pyext/_message.so\",\n    srcs = glob([\n        \"python/google/protobuf/pyext/*.cc\",\n        \"python/google/protobuf/pyext/*.h\",\n    ]),\n    copts = COPTS + [\n        \"-DGOOGLE_PROTOBUF_HAS_ONEOF=1\",\n    ] + select({\n        \"//conditions:default\": [],\n        \":allow_oversize_protos\": [\"-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1\"],\n    }),\n    includes = [\n        \"python/\",\n        \"src/\",\n    ],\n    linkshared = 1,\n    linkstatic = 1,\n    deps = [\n        \":protobuf\",\n    ] + select({\n        \"//conditions:default\": [],\n        \":use_fast_cpp_protos\": [\"//external:python_headers\"],\n    }),\n)\n\nconfig_setting(\n    name = \"use_fast_cpp_protos\",\n    values = {\n        \"define\": \"use_fast_cpp_protos=true\",\n    },\n)\n\nconfig_setting(\n    name = \"allow_oversize_protos\",\n    values = {\n        \"define\": \"allow_oversize_protos=true\",\n    },\n)\n\n# Copy the builtin proto files from src/google/protobuf to\n# python/google/protobuf. This way, the generated Python sources will be in the\n# same directory as the Python runtime sources. This is necessary for the\n# modules to be imported correctly since they are all part of the same Python\n# package.\ninternal_copied_filegroup(\n    name = \"protos_python\",\n    srcs = WELL_KNOWN_PROTOS,\n    strip_prefix = \"src\",\n    dest = \"python\",\n)\n\n# TODO(dzc): Remove this once py_proto_library can have labels in srcs, in\n# which case we can simply add :protos_python in srcs.\nCOPIED_WELL_KNOWN_PROTOS = [\"python/\" + s for s in RELATIVE_WELL_KNOWN_PROTOS]\n\npy_proto_library(\n    name = \"protobuf_python\",\n    srcs = COPIED_WELL_KNOWN_PROTOS,\n    include = \"python\",\n    data = select({\n        \"//conditions:default\": [],\n        \":use_fast_cpp_protos\": [\n            \":internal/_api_implementation.so\",\n            \":pyext/_message.so\",\n        ],\n    }),\n    default_runtime = \"\",\n    protoc = \":protoc\",\n    py_libs = [\n        \":python_srcs\",\n        \"//external:six\"\n    ],\n    srcs_version = \"PY2AND3\",\n    visibility = [\"//visibility:public\"],\n)\n\n# Copy the test proto files from src/google/protobuf to\n# python/google/protobuf. This way, the generated Python sources will be in the\n# same directory as the Python runtime sources. This is necessary for the\n# modules to be imported correctly by the tests since they are all part of the\n# same Python package.\ninternal_copied_filegroup(\n    name = \"protos_python_test\",\n    srcs = LITE_TEST_PROTOS + TEST_PROTOS,\n    strip_prefix = \"src\",\n    dest = \"python\",\n)\n\n# TODO(dzc): Remove this once py_proto_library can have labels in srcs, in\n# which case we can simply add :protos_python_test in srcs.\nCOPIED_LITE_TEST_PROTOS = [\"python/\" + s for s in RELATIVE_LITE_TEST_PROTOS]\nCOPIED_TEST_PROTOS = [\"python/\" + s for s in RELATIVE_TEST_PROTOS]\n\npy_proto_library(\n    name = \"python_common_test_protos\",\n    srcs = COPIED_LITE_TEST_PROTOS + COPIED_TEST_PROTOS,\n    include = \"python\",\n    default_runtime = \"\",\n    protoc = \":protoc\",\n    srcs_version = \"PY2AND3\",\n    deps = [\":protobuf_python\"],\n)\n\npy_proto_library(\n    name = \"python_specific_test_protos\",\n    srcs = glob([\n        \"python/google/protobuf/internal/*.proto\",\n        \"python/google/protobuf/internal/import_test_package/*.proto\",\n    ]),\n    include = \"python\",\n    default_runtime = \":protobuf_python\",\n    protoc = \":protoc\",\n    srcs_version = \"PY2AND3\",\n    deps = [\":python_common_test_protos\"],\n)\n\npy_library(\n    name = \"python_tests\",\n    srcs = glob(\n        [\n            \"python/google/protobuf/internal/*_test.py\",\n            \"python/google/protobuf/internal/test_util.py\",\n            \"python/google/protobuf/internal/import_test_package/__init__.py\",\n        ],\n    ),\n    imports = [\"python\"],\n    srcs_version = \"PY2AND3\",\n    deps = [\n        \":protobuf_python\",\n        \":python_common_test_protos\",\n        \":python_specific_test_protos\",\n    ],\n)\n\ninternal_protobuf_py_tests(\n    name = \"python_tests_batch\",\n    data = glob([\n        \"src/google/protobuf/**/*\",\n    ]),\n    modules = [\n        \"descriptor_database_test\",\n        \"descriptor_pool_test\",\n        \"descriptor_test\",\n        \"generator_test\",\n        \"json_format_test\",\n        \"message_factory_test\",\n        \"message_test\",\n        \"proto_builder_test\",\n        \"reflection_test\",\n        \"service_reflection_test\",\n        \"symbol_database_test\",\n        \"text_encoding_test\",\n        \"text_format_test\",\n        \"unknown_fields_test\",\n        \"wire_format_test\",\n    ],\n    deps = [\":python_tests\"],\n)\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/CHANGES.txt",
    "content": "2016-07-27 version 3.0.0 (C++/Java/Python/Ruby/Objective-C/C#/JavaScript/Lite)\r\n  General\r\n  * This log only contains changes since the beta-4 release. Summarized change\r\n    log since the last stable release (v2.6.1) can be found in the github\r\n    release page.\r\n\r\n  Compatibility Notice\r\n  * v3.0.0 is the first API stable release of the v3.x series. We do not expect\r\n    any future API breaking changes.\r\n  * For C++, Java Lite and Objective-C, source level compatibility is\r\n    guaranteed.  Upgrading from v3.0.0 to newer minor version releases will be\r\n    source compatible. For example, if your code compiles against protobuf\r\n    v3.0.0, it will continue to compile after you upgrade protobuf library to\r\n    v3.1.0.\r\n  * For other languages, both source level compatibility and binary level\r\n    compatibility are guaranteed. For example, if you have a Java binary built\r\n    against protobuf v3.0.0. After switching the protobuf runtime binary to\r\n    v3.1.0, your built binary should continue to work.\r\n  * Compatibility is only guaranteed for documented API and documented\r\n    behaviors. If you are using undocumented API (e.g., use anything in the C++\r\n    internal namespace), it can be broken by minor version releases in an\r\n    undetermined manner.\r\n\r\n  Ruby\r\n  * When you assign a string field `a.string_field = \"X\"`, we now call\r\n    #encode(UTF-8) on the string and freeze the copy. This saves you from\r\n    needing to ensure the string is already encoded as UTF-8. It also prevents\r\n    you from mutating the string after it has been assigned (this is how we\r\n    ensure it stays valid UTF-8).\r\n  * The generated file for `foo.proto` is now `foo_pb.rb` instead of just\r\n    `foo.rb`. This makes it easier to see which imports/requires are from\r\n    protobuf generated code, and also prevents conflicts with any `foo.rb` file\r\n    you might have written directly in Ruby. It is a backward-incompatible\r\n    change: you will need to update all of your `require` statements.\r\n  * For package names like `foo_bar`, we now translate this to the Ruby module\r\n    `FooBar`. This is more idiomatic Ruby than what we used to do (`Foo_bar`).\r\n\r\n  JavaScript\r\n  * Scalar fields like numbers and boolean now return defaults instead of\r\n    `undefined` or `null` when they are unset. You can test for presence\r\n    explicitly by calling `hasFoo()`, which we now generate for scalar fields.\r\n\r\n  Java Lite\r\n  * Java Lite is now implemented as a separate plugin, maintained in the\r\n    `javalite` branch. Both lite runtime and protoc artifacts will be available\r\n    in Maven.\r\n\r\n  C#\r\n  * Target platforms now .NET 4.5, selected portable subsets and .NET Core.\r\n  * legacy_enum_values option is no longer supported.\r\n\r\n2016-07-15 version 3.0.0-beta-4 (C++/Java/Python/Ruby/Objective-C/C#/JavaScript)\r\n  General\r\n  * Added a deterministic serialization API for C++. The deterministic\r\n    serialization guarantees that given a binary, equal messages will be\r\n    serialized to the same bytes. This allows applications like MapReduce to\r\n    group equal messages based on the serialized bytes. The deterministic\r\n    serialization is, however, NOT canonical across languages; it is also\r\n    unstable across different builds with schema changes due to unknown fields.\r\n    Users who need canonical serialization, e.g. persistent storage in a\r\n    canonical form, fingerprinting, etc, should define their own\r\n    canonicalization specification and implement the serializer using reflection\r\n    APIs rather than relying on this API.\r\n  * Added OneofOptions. You can now define custom options for oneof groups.\r\n      import \"google/protobuf/descriptor.proto\";\r\n      extend google.protobuf.OneofOptions {\r\n        optional int32 my_oneof_extension = 12345;\r\n      }\r\n      message Foo {\r\n        oneof oneof_group {\r\n          (my_oneof_extension) = 54321;\r\n          ...\r\n        }\r\n      }\r\n\r\n  C++ (beta)\r\n  * Introduced a deterministic serialization API in\r\n    CodedOutputStream::SetSerializationDeterministic(bool). See the notes about\r\n    deterministic serialization in the General section.\r\n  * Added google::protobuf::Map::swap() to swap two map fields.\r\n  * Fixed a memory leak when calling Reflection::ReleaseMessage() on a message\r\n    allocated on arena.\r\n  * Improved error reporting when parsing text format protos.\r\n  * JSON\r\n      - Added a new parser option to ignore unknown fields when parsing JSON.\r\n      - Added convenient methods for message to/from JSON conversion.\r\n  * Various performance optimizations.\r\n\r\n  Java (beta)\r\n  * File option \"java_generate_equals_and_hash\" is now deprecated. equals() and\r\n    hashCode() methods are generated by default.\r\n  * Added a new JSON printer option \"omittingInsignificantWhitespace\" to produce\r\n    a more compact JSON output. The printer will pretty-print by default.\r\n  * Updated Java runtime to be compatible with 2.5.0/2.6.1 generated protos.\r\n\r\n  Python (beta)\r\n  * Added support to pretty print Any messages in text format.\r\n  * Added a flag to ignore unknown fields when parsing JSON.\r\n  * Bugfix: \"@type\" field of a JSON Any message is now correctly put before\r\n    other fields.\r\n\r\n  Objective-C (beta)\r\n  * Updated the code to support compiling with more compiler warnings\r\n    enabled. (Issue 1616)\r\n  * Exposing more detailed errors for parsing failures. (PR 1623)\r\n  * Small (breaking) change to the naming of some methods on the support classes\r\n    for map<>. There were collisions with the system provided KVO support, so\r\n    the names were changed to avoid those issues.  (PR 1699)\r\n  * Fixed for proper Swift bridging of error handling during parsing. (PR 1712)\r\n  * Complete support for generating sources that will go into a Framework and\r\n    depend on generated sources from other Frameworks. (Issue 1457)\r\n\r\n  C# (beta)\r\n  * RepeatedField optimizations.\r\n  * Support for .NET Core.\r\n  * Minor bug fixes.\r\n  * Ability to format a single value in JsonFormatter (advanced usage only).\r\n  * Modifications to attributes applied to generated code.\r\n\r\n  Javascript (alpha)\r\n  * Maps now have a real map API instead of being treated as repeated fields.\r\n  * Well-known types are now provided in the google-protobuf package, and the\r\n    code generator knows to require() them from that package.\r\n  * Bugfix: non-canonical varints are correctly decoded.\r\n\r\n  Ruby (alpha)\r\n  * Accessors for oneof fields now return default values instead of nil.\r\n\r\n  Java Lite\r\n  * Java lite support is removed from protocol compiler. It will be supported\r\n    as a protocol compiler plugin in a separate code branch.\r\n\r\n2016-05-16 version 3.0.0-beta-3 (C++/Java/Python/Ruby/Nano/Objective-C/C#/JavaScript)\r\n  General\r\n  * Supported Proto3 lite-runtime in C++/Java for mobile platforms.\r\n  * Any type now supports APIs to specify prefixes other than\r\n    type.googleapis.com\r\n  * Removed javanano_use_deprecated_package option; Nano will always has its own\r\n    \".nano\" package.\r\n\r\n  C++ (Beta)\r\n  * Improved hash maps.\r\n      - Improved hash maps comments. In particular, please note that equal hash\r\n        maps will not necessarily have the same iteration order and\r\n        serialization.\r\n      - Added a new hash maps implementation that will become the default in a\r\n        later release.\r\n  * Arenas\r\n      - Several inlined methods in Arena were moved to out-of-line to improve\r\n        build performance and code size.\r\n      - Added SpaceAllocatedAndUsed() to report both space used and allocated\r\n      - Added convenient class UnsafeArenaAllocatedRepeatedPtrFieldBackInserter\r\n  * Any\r\n      - Allow custom type URL prefixes in Any packing.\r\n      - TextFormat now expand the Any type rather than printing bytes.\r\n  * Performance optimizations and various bug fixes.\r\n\r\n  Java (Beta)\r\n  * Introduced an ExperimentalApi annotation. Annotated APIs are experimental\r\n    and are subject to change in a backward incompatible way in future releases.\r\n  * Introduced zero-copy serialization as an ExperimentalApi\r\n      - Introduction of the `ByteOutput` interface. This is similar to\r\n        `OutputStream` but provides semantics for lazy writing (i.e. no\r\n        immediate copy required) of fields that are considered to be immutable.\r\n      - `ByteString` now supports writing to a `ByteOutput`, which will directly\r\n        expose the internals of the `ByteString` (i.e. `byte[]` or `ByteBuffer`)\r\n        to the `ByteOutput` without copying.\r\n      - `CodedOutputStream` now supports writing to a `ByteOutput`. `ByteString`\r\n        instances that are too large to fit in the internal buffer will be\r\n        (lazily) written to the `ByteOutput` directly.\r\n      - This allows applications using large `ByteString` fields to avoid\r\n        duplication of these fields entirely. Such an application can supply a\r\n        `ByteOutput` that chains together the chunks received from\r\n        `CodedOutputStream` before forwarding them onto the IO system.\r\n  * Other related changes to `CodedOutputStream`\r\n      - Additional use of `sun.misc.Unsafe` where possible to perform fast\r\n        access to `byte[]` and `ByteBuffer` values and avoiding unnecessary\r\n        range checking.\r\n      - `ByteBuffer`-backed `CodedOutputStream` now writes directly to the\r\n        `ByteBuffer` rather than to an intermediate array.\r\n  * Improved lite-runtime.\r\n      - Lite protos now implement deep equals/hashCode/toString\r\n      - Significantly improved the performance of Builder#mergeFrom() and\r\n        Builder#mergeDelimitedFrom()\r\n  * Various bug fixes and small feature enhancement.\r\n      - Fixed stack overflow when in hashCode() for infinite recursive oneofs.\r\n      - Fixed the lazy field parsing in lite to merge rather than overwrite.\r\n      - TextFormat now supports reporting line/column numbers on errors.\r\n      - Updated to add appropriate @Override for better compiler errors.\r\n\r\n  Python (Beta)\r\n  * Added JSON format for Any, Struct, Value and ListValue\r\n  * [ ] is now accepted for both repeated scalar fields and repeated message\r\n    fields in text format parser.\r\n  * Numerical field name is now supported in text format.\r\n  * Added DiscardUnknownFields API for python protobuf message.\r\n\r\n  Objective-C (Beta)\r\n  * Proto comments now come over as HeaderDoc comments in the generated sources\r\n    so Xcode can pick them up and display them.\r\n  * The library headers have been updated to use HeaderDoc comments so Xcode can\r\n    pick them up and display them.\r\n  * The per message and per field overhead in both generated code and runtime\r\n    object sizes was reduced.\r\n  * Generated code now include deprecated annotations when the proto file\r\n    included them.\r\n\r\n  C# (Beta)\r\n  In general: some changes are breaking, which require regenerating messages.\r\n  Most user-written code will not be impacted *except* for the renaming of enum\r\n  values.\r\n\r\n  * Allow custom type URL prefixes in `Any` packing, and ignore them when\r\n    unpacking\r\n  * `protoc` is now in a separate NuGet package (Google.Protobuf.Tools)\r\n  * New option: `internal_access` to generate internal classes\r\n  * Enum values are now PascalCased, and if there's a prefix which matches the\r\n    name of the enum, that is removed (so an enum `COLOR` with a value\r\n    `COLOR_BLUE` would generate a value of just `Blue`). An option\r\n    (`legacy_enum_values`) is temporarily available to disable this, but the\r\n    option will be removed for GA.\r\n  * `json_name` option is now honored\r\n  * If group tags are encountered when parsing, they are validated more\r\n    thoroughly (although we don't support actual groups)\r\n  * NuGet dependencies are better specified\r\n  * Breaking: `Preconditions` is renamed to `ProtoPreconditions`\r\n  * Breaking: `GeneratedCodeInfo` is renamed to `GeneratedClrTypeInfo`\r\n  * `JsonFormatter` now allows writing to a `TextWriter`\r\n  * New interface, `ICustomDiagnosticMessage` to allow more compact\r\n    representations from `ToString`\r\n  * `CodedInputStream` and `CodedOutputStream` now implement `IDisposable`,\r\n    which simply disposes of the streams they were constructed with\r\n  * Map fields no longer support null values (in line with other languages)\r\n  * Improvements in JSON formatting and parsing\r\n\r\n  Javascript (Alpha)\r\n  * Better support for \"bytes\" fields: bytes fields can be read as either a\r\n    base64 string or UInt8Array (in environments where TypedArray is supported).\r\n  * New support for CommonJS imports.  This should make it easier to use the\r\n    JavaScript support in Node.js and tools like WebPack.  See js/README.md for\r\n    more information.\r\n  * Some significant internal refactoring to simplify and modularize the code.\r\n\r\n  Ruby (Alpha)\r\n  * JSON serialization now properly uses camelCased names, with a runtime option\r\n    that will preserve original names from .proto files instead.\r\n  * Well-known types are now included in the distribution.\r\n  * Release now includes binary gems for Windows, Mac, and Linux instead of just\r\n    source gems.\r\n  * Bugfix for serializing oneofs.\r\n\r\n  C++/Java Lite (Alpha)\r\n    A new \"lite\" generator parameter was introduced in the protoc for C++ and\r\n    Java for Proto3 syntax messages. Example usage:\r\n\r\n     ./protoc --cpp_out=lite:$OUTPUT_PATH foo.proto\r\n\r\n    The protoc will treat the current input and all the transitive dependencies\r\n    as LITE. The same generator parameter must be used to generate the\r\n    dependencies.\r\n\r\n    In Proto3 syntax files, \"optimized_for=LITE_RUNTIME\" is no longer supported.\r\n\r\n\r\n2015-12-30 version 3.0.0-beta-2 (C++/Java/Python/Ruby/Nano/Objective-C/C#/JavaScript)\r\n  General\r\n  * Introduced a new language implementation: JavaScript.\r\n  * Added a new field option \"json_name\". By default proto field names are\r\n    converted to \"lowerCamelCase\" in proto3 JSON format. This option can be\r\n    used to override this behavior and specify a different JSON name for the\r\n    field.\r\n  * Added conformance tests to ensure implementations are following proto3 JSON\r\n    specification.\r\n\r\n  C++ (Beta)\r\n  * Various bug fixes and improvements to the JSON support utility:\r\n      - Duplicate map keys in JSON are now rejected (i.e., translation will\r\n        fail).\r\n      - Fixed wire-format for google.protobuf.Value/ListValue.\r\n      - Fixed precision loss when converting google.protobuf.Timestamp.\r\n      - Fixed a bug when parsing invalid UTF-8 code points.\r\n      - Fixed a memory leak.\r\n      - Reduced call stack usage.\r\n\r\n  Java (Beta)\r\n  * Cleaned up some unused methods on CodedOutputStream.\r\n  * Presized lists for packed fields during parsing in the lite runtime to\r\n    reduce allocations and improve performance.\r\n  * Improved the performance of unknown fields in the lite runtime.\r\n  * Introduced UnsafeByteStrings to support zero-copy ByteString creation.\r\n  * Various bug fixes and improvements to the JSON support utility:\r\n      - Fixed a thread-safety bug.\r\n      - Added a new option “preservingProtoFieldNames” to JsonFormat.\r\n      - Added a new option “includingDefaultValueFields” to JsonFormat.\r\n      - Updated the JSON utility to comply with proto3 JSON specification.\r\n\r\n  Python (Beta)\r\n  * Added proto3 JSON format utility. It includes support for all field types\r\n    and a few well-known types except for Any and Struct.\r\n  * Added runtime support for Any, Timestamp, Duration and FieldMask.\r\n  * [ ] is now accepted for repeated scalar fields in text format parser.\r\n  * Map fields now have proper O(1) performance for lookup/insert/delete\r\n    when using the Python/C++ implementation. They were previously using O(n)\r\n    search-based algorithms because the C++ reflection interface didn't\r\n    support true map operations.\r\n\r\n  Objective-C (Beta)\r\n  * Various bug-fixes and code tweaks to pass more strict compiler warnings.\r\n  * Now has conformance test coverage and is passing all tests.\r\n\r\n  C# (Beta)\r\n  * Various bug-fixes.\r\n  * Code generation: Files generated in directories based on namespace.\r\n  * Code generation: Include comments from .proto files in XML doc\r\n    comments (naively)\r\n  * Code generation: Change organization/naming of \"reflection class\" (access\r\n    to file descriptor)\r\n  * Code generation and library: Add Parser property to MessageDescriptor,\r\n    and introduce a non-generic parser type.\r\n  * Library: Added TypeRegistry to support JSON parsing/formatting of Any.\r\n  * Library: Added Any.Pack/Unpack support.\r\n  * Library: Implemented JSON parsing.\r\n\r\n  Javascript (Alpha)\r\n  * Added proto3 support for JavaScript. The runtime is written in pure\r\n    JavaScript and works in browsers and in Node.js. To generate JavaScript\r\n    code for your proto, invoke protoc with \"--js_out\". See js/README.md\r\n    for more build instructions.\r\n\r\n2015-08-26 version 3.0.0-beta-1 (C++/Java/Python/Ruby/Nano/Objective-C/C#)\r\n  About Beta\r\n  * This is the first beta release of protobuf v3.0.0. Not all languages\r\n    have reached beta stage. Languages not marked as beta are still in\r\n    alpha (i.e., be prepared for API breaking changes).\r\n\r\n  General\r\n  * Proto3 JSON is supported in several languages (fully supported in C++\r\n    and Java, partially supported in Ruby/C#). The JSON spec is defined in\r\n    the proto3 language guide:\r\n\r\n      https://developers.google.com/protocol-buffers/docs/proto3#json\r\n\r\n    We will publish a more detailed spec to define the exact behavior of\r\n    proto3-conformant JSON serializers and parsers. Until then, do not rely\r\n    on specific behaviors of the implementation if it’s not documented in\r\n    the above spec. More specifically, the behavior is not yet finalized for\r\n    the following:\r\n      - Parsing invalid JSON input (e.g., input with trailing commas).\r\n      - Non-camelCase names in JSON input.\r\n      - The same field appears multiple times in JSON input.\r\n      - JSON arrays contain “null” values.\r\n      - The message has unknown fields.\r\n\r\n  * Proto3 now enforces strict UTF-8 checking. Parsing will fail if a string\r\n    field contains non UTF-8 data.\r\n\r\n  C++ (Beta)\r\n  * Introduced new utility functions/classes in the google/protobuf/util\r\n    directory:\r\n      - MessageDifferencer: compare two proto messages and report their\r\n                            differences.\r\n      - JsonUtil: support converting protobuf binary format to/from JSON.\r\n      - TimeUtil: utility functions to work with well-known types Timestamp\r\n                  and Duration.\r\n      - FieldMaskUtil: utility functions to work with FieldMask.\r\n\r\n  * Performance optimization of arena construction and destruction.\r\n  * Bug fixes for arena and maps support.\r\n  * Changed to use cmake for Windows Visual Studio builds.\r\n  * Added Bazel support.\r\n\r\n  Java (Beta)\r\n  * Introduced a new util package that will be distributed as a separate\r\n    artifact in maven. It contains:\r\n      - JsonFormat: convert proto messages to/from JSON.\r\n      - TimeUtil: utility functions to work with Timestamp and Duration.\r\n      - FieldMaskUtil: utility functions to work with FieldMask.\r\n\r\n  * The static PARSER in each generated message is deprecated, and it will\r\n    be removed in a future release. A static parser() getter is generated\r\n    for each message type instead.\r\n  * Performance optimizations for String fields serialization.\r\n  * Performance optimizations for Lite runtime on Android:\r\n      - Reduced allocations\r\n      - Reduced method overhead after ProGuarding\r\n      - Reduced code size after ProGuarding\r\n\r\n  Python (Alpha)\r\n  * Removed legacy Python 2.5 support.\r\n  * Moved to a single Python 2.x/3.x-compatible codebase, instead of using 2to3.\r\n  * Fixed build/tests on Python 2.6, 2.7, 3.3, and 3.4.\r\n      - Pure-Python works on all four.\r\n      - Python/C++ implementation works on all but 3.4, due to changes in the\r\n        Python/C++ API in 3.4.\r\n  * Some preliminary work has been done to allow for multiple DescriptorPools\r\n    with Python/C++.\r\n\r\n  Ruby (Alpha)\r\n  * Many bugfixes:\r\n      - fixed parsing/serialization of bytes, sint, sfixed types\r\n      - other parser bugfixes\r\n      - fixed memory leak affecting Ruby 2.2\r\n\r\n  JavaNano (Alpha)\r\n  * JavaNano generated code now will be put in a nano package by default to\r\n    avoid conflicts with Java generated code.\r\n\r\n  Objective-C (Alpha)\r\n  * Added non-null markup to ObjC library. Requires SDK 8.4+ to build.\r\n  * Many bugfixes:\r\n      - Removed the class/enum filter.\r\n      - Renamed some internal types to avoid conflicts with the well-known types\r\n        protos.\r\n      - Added missing support for parsing repeated primitive fields in packed or\r\n        unpacked forms.\r\n      - Added *Count for repeated and map<> fields to avoid auto-create when\r\n        checking for them being set.\r\n\r\n  C# (Alpha)\r\n  * Namespace changed to Google.Protobuf (and NuGet package will be named\r\n    correspondingly).\r\n  * Target platforms now .NET 4.5 and selected portable subsets only.\r\n  * Removed lite runtime.\r\n  * Reimplementation to use mutable message types.\r\n  * Null references used to represent \"no value\" for message type fields.\r\n  * Proto3 semantics supported; proto2 files are prohibited for C# codegen.\r\n    Most proto3 features supported:\r\n      - JSON formatting (a.k.a. serialization to JSON), including well-known\r\n        types (except for Any).\r\n      - Wrapper types mapped to nullable value types (or string/ByteString\r\n        allowing nullability). JSON parsing is not supported yet.\r\n      - maps\r\n      - oneof\r\n      - enum unknown value preservation\r\n\r\n2015-05-25 version 3.0.0-alpha-3 (Objective-C/C#):\r\n  General\r\n  * Introduced two new language implementations (Objective-C, C#) to proto3.\r\n  * Explicit \"optional\" keyword are disallowed in proto3 syntax, as fields are\r\n    optional by default.\r\n  * Group fields are no longer supported in proto3 syntax.\r\n  * Changed repeated primitive fields to use packed serialization by default in\r\n    proto3 (implemented for C++, Java, Python in this release).  The user can\r\n    still disable packed serialization by setting packed to false for now.\r\n  * Added well-known type protos (any.proto, empty.proto, timestamp.proto,\r\n    duration.proto, etc.). Users can import and use these protos just like\r\n    regular proto files. Additional runtime support will be added for them in\r\n    future releases (in the form of utility helper functions, or having them\r\n    replaced by language specific types in generated code).\r\n  * Added a \"reserved\" keyword in both proto2 and proto3 syntax. User can use\r\n    this keyword to declare reserved field numbers and names to prevent them\r\n    from being reused by other fields in the same message.\r\n\r\n    To reserve field numbers, add a reserved declaration in your message:\r\n\r\n      message TestMessage {\r\n        reserved 2, 15, 9 to 11, 3;\r\n      }\r\n\r\n    This reserves field numbers 2, 3, 9, 10, 11 and 15. If a user uses any of\r\n    these as field numbers, the protocol buffer compiler will report an error.\r\n\r\n    Field names can also be reserved:\r\n\r\n      message TestMessage {\r\n        reserved \"foo\", \"bar\";\r\n      }\r\n\r\n  * Various bug fixes since 3.0.0-alpha-2\r\n\r\n  Objective-C\r\n    Objective-C includes a code generator and a native objective-c runtime\r\n    library.  By adding “--objc_out” to protoc, the code generator will generate\r\n    a header(*.pbobjc.h) and an implementation file(*.pbobjc.m) for each proto\r\n    file.\r\n\r\n    In this first release, the generated interface provides: enums, messages,\r\n    field support(single, repeated, map, oneof), proto2 and proto3 syntax\r\n    support, parsing and serialization. It’s  compatible with ARC and non-ARC\r\n    usage. Besides, user can also access it via the swift bridging header.\r\n\r\n    See objectivec/README.md for details.\r\n\r\n  C#\r\n    * C# protobufs are based on project\r\n      https://github.com/jskeet/protobuf-csharp-port. The original project was\r\n      frozen and all the new development will happen here.\r\n    * Codegen plugin for C# was completely rewritten to C++ and is now an\r\n      integral part of protoc.\r\n    * Some refactorings and cleanup has been applied to the C# runtime library.\r\n    * Only proto2 is supported in C# at the moment, proto3 support is in\r\n      progress and will likely bring significant breaking changes to the API.\r\n\r\n    See csharp/README.md for details.\r\n\r\n  C++\r\n    * Added runtime support for Any type. To use Any in your proto file, first\r\n      import the definition of Any:\r\n\r\n        // foo.proto\r\n        import \"google/protobuf/any.proto\";\r\n        message Foo {\r\n          google.protobuf.Any any_field = 1;\r\n        }\r\n        message Bar {\r\n          int32 value = 1;\r\n        }\r\n\r\n      Then in C++ you can access the Any field using PackFrom()/UnpackTo()\r\n      methods:\r\n\r\n        Foo foo;\r\n        Bar bar = ...;\r\n        foo.mutable_any_field()->PackFrom(bar);\r\n        ...\r\n        if (foo.any_field().IsType<Bar>()) {\r\n          foo.any_field().UnpackTo(&bar);\r\n          ...\r\n        }\r\n    * In text format, entries of a map field will be sorted by key.\r\n\r\n  Java\r\n    * Continued optimizations on the lite runtime to improve performance for\r\n      Android.\r\n\r\n  Python\r\n    * Added map support.\r\n      - maps now have a dict-like interface (msg.map_field[key] = value)\r\n      - existing code that modifies maps via the repeated field interface\r\n        will need to be updated.\r\n\r\n  Ruby\r\n    * Improvements to RepeatedField's emulation of the Ruby Array API.\r\n    * Various speedups and internal cleanups.\r\n\r\n2015-02-26 version 3.0.0-alpha-2 (Python/Ruby/JavaNano):\r\n  General\r\n  * Introduced three new language implementations (Ruby, JavaNano, and\r\n    Python) to proto3.\r\n  * Various bug fixes since 3.0.0-alpha-1\r\n\r\n  Python:\r\n    Python has received several updates, most notably support for proto3\r\n    semantics in any .proto file that declares syntax=\"proto3\".\r\n    Messages declared in proto3 files no longer represent field presence\r\n    for scalar fields (number, enums, booleans, or strings).  You can\r\n    no longer call HasField() for such fields, and they are serialized\r\n    based on whether they have a non-zero/empty/false value.\r\n\r\n    One other notable change is in the C++-accelerated implementation.\r\n    Descriptor objects (which describe the protobuf schema and allow\r\n    reflection over it) are no longer duplicated between the Python\r\n    and C++ layers.  The Python descriptors are now simple wrappers\r\n    around the C++ descriptors.  This change should significantly\r\n    reduce the memory usage of programs that use a lot of message\r\n    types.\r\n\r\n  Ruby:\r\n    We have added proto3 support for Ruby via a native C extension.\r\n\r\n    The Ruby extension itself is included in the ruby/ directory, and details on\r\n    building and installing the extension are in ruby/README.md. The extension\r\n    will also be published as a Ruby gem. Code generator support is included as\r\n    part of `protoc` with the `--ruby_out` flag.\r\n\r\n    The Ruby extension implements a user-friendly DSL to define message types\r\n    (also generated by the code generator from `.proto` files).  Once a message\r\n    type is defined, the user may create instances of the message that behave in\r\n    ways idiomatic to Ruby. For example:\r\n\r\n    - Message fields are present as ordinary Ruby properties (getter method\r\n      `foo` and setter method `foo=`).\r\n    - Repeated field elements are stored in a container that acts like a native\r\n      Ruby array, and map elements are stored in a container that acts like a\r\n      native Ruby hashmap.\r\n    - The usual well-known methods, such as `#to_s`, `#dup`, and the like, are\r\n      present.\r\n\r\n    Unlike several existing third-party Ruby extensions for protobuf, this\r\n    extension is built on a \"strongly-typed\" philosophy: message fields and\r\n    array/map containers will throw exceptions eagerly when values of the\r\n    incorrect type are inserted.\r\n\r\n    See ruby/README.md for details.\r\n\r\n  JavaNano:\r\n    JavaNano is a special code generator and runtime library designed especially\r\n    for resource-restricted systems, like Android. It is very resource-friendly\r\n    in both the amount of code and the runtime overhead. Here is an an overview\r\n    of JavaNano features compared with the official Java protobuf:\r\n\r\n    - No descriptors or message builders.\r\n    - All messages are mutable; fields are public Java fields.\r\n    - For optional fields only, encapsulation behind setter/getter/hazzer/\r\n      clearer functions is opt-in, which provide proper 'has' state support.\r\n    - For proto2, if not opted in, has state (field presence) is not available.\r\n      Serialization outputs all fields not equal to their defaults.\r\n      The behavior is consistent with proto3 semantics.\r\n    - Required fields (proto2 only) are always serialized.\r\n    - Enum constants are integers; protection against invalid values only\r\n      when parsing from the wire.\r\n    - Enum constants can be generated into container interfaces bearing\r\n      the enum's name (so the referencing code is in Java style).\r\n    - CodedInputByteBufferNano can only take byte[] (not InputStream).\r\n    - Similarly CodedOutputByteBufferNano can only write to byte[].\r\n    - Repeated fields are in arrays, not ArrayList or Vector. Null array\r\n      elements are allowed and silently ignored.\r\n    - Full support for serializing/deserializing repeated packed fields.\r\n    - Support  extensions (in proto2).\r\n    - Unset messages/groups are null, not an immutable empty default\r\n      instance.\r\n    - toByteArray(...) and mergeFrom(...) are now static functions of\r\n      MessageNano.\r\n    - The 'bytes' type translates to the Java type byte[].\r\n\r\n    See javanano/README.txt for details.\r\n\r\n2014-12-01 version 3.0.0-alpha-1 (C++/Java):\r\n\r\n  General\r\n  * Introduced Protocol Buffers language version 3 (aka proto3).\r\n\r\n    When protobuf was initially opensourced it implemented Protocol Buffers\r\n    language version 2 (aka proto2), which is why the version number\r\n    started from v2.0.0. From v3.0.0, a new language version (proto3) is\r\n    introduced while the old version (proto2) will continue to be supported.\r\n\r\n    The main intent of introducing proto3 is to clean up protobuf before\r\n    pushing the language as the foundation of Google's new API platform.\r\n    In proto3, the language is simplified, both for ease of use and  to\r\n    make it available in a wider range of programming languages. At the\r\n    same time a few features are added to better support common idioms\r\n    found in APIs.\r\n\r\n    The following are the main new features in language version 3:\r\n\r\n      1. Removal of field presence logic for primitive value fields, removal\r\n         of required fields, and removal of default values. This makes proto3\r\n         significantly easier to implement with open struct representations,\r\n         as in languages like Android Java, Objective C, or Go.\r\n      2. Removal of unknown fields.\r\n      3. Removal of extensions, which are instead replaced by a new standard\r\n         type called Any.\r\n      4. Fix semantics for unknown enum values.\r\n      5. Addition of maps.\r\n      6. Addition of a small set of standard types for representation of time,\r\n         dynamic data, etc.\r\n      7. A well-defined encoding in JSON as an alternative to binary proto\r\n         encoding.\r\n\r\n    This release (v3.0.0-alpha-1) includes partial proto3 support for C++ and\r\n    Java. Items 6 (well-known types) and 7 (JSON format) in the above feature\r\n    list are not implemented.\r\n\r\n    A new notion \"syntax\" is introduced to specify whether a .proto file\r\n    uses proto2 or proto3:\r\n\r\n      // foo.proto\r\n      syntax = \"proto3\";\r\n      message Bar {...}\r\n\r\n    If omitted, the protocol compiler will generate a warning and \"proto2\" will\r\n    be used as the default. This warning will be turned into an error in a\r\n    future release.\r\n\r\n    We recommend that new Protocol Buffers users use proto3. However, we do not\r\n    generally recommend that existing users migrate from proto2 from proto3 due\r\n    to API incompatibility, and we will continue to support proto2 for a long\r\n    time.\r\n\r\n  * Added support for map fields (implemented in C++/Java for both proto2 and\r\n    proto3).\r\n\r\n    Map fields can be declared using the following syntax:\r\n\r\n      message Foo {\r\n        map<string, string> values = 1;\r\n      }\r\n\r\n    Data of a map field will be stored in memory as an unordered map and it\r\n    can be accessed through generated accessors.\r\n\r\n  C++\r\n  * Added arena allocation support (for both proto2 and proto3).\r\n\r\n    Profiling shows memory allocation and deallocation constitutes a significant\r\n    fraction of CPU-time spent in protobuf code and arena allocation is a\r\n    technique introduced to reduce this cost. With arena allocation, new\r\n    objects will be allocated from a large piece of preallocated memory and\r\n    deallocation of these objects is almost free. Early adoption shows 20% to\r\n    50% improvement in some Google binaries.\r\n\r\n    To enable arena support, add the following option to your .proto file:\r\n\r\n      option cc_enable_arenas = true;\r\n\r\n    Protocol compiler will generate additional code to make the generated\r\n    message classes work with arenas. This does not change the existing API\r\n    of protobuf messages and does not affect wire format. Your existing code\r\n    should continue to work after adding this option. In the future we will\r\n    make this option enabled by default.\r\n\r\n    To actually take advantage of arena allocation, you need to use the arena\r\n    APIs when creating messages. A quick example of using the arena API:\r\n\r\n      {\r\n        google::protobuf::Arena arena;\r\n        // Allocate a protobuf message in the arena.\r\n        MyMessage* message = Arena::CreateMessage<MyMessage>(&arena);\r\n        // All submessages will be allocated in the same arena.\r\n        if (!message->ParseFromString(data)) {\r\n          // Deal with malformed input data.\r\n        }\r\n        // Must not delete the message here. It will be deleted automatically\r\n        // when the arena is destroyed.\r\n      }\r\n\r\n    Currently arena does not work with map fields. Enabling arena in a .proto\r\n    file containing map fields will result in compile errors in the generated\r\n    code. This will be addressed in a future release.\r\n\r\n2014-10-20 version 2.6.1:\r\n\r\n  C++\r\n  * Added atomicops support for Solaris.\r\n  * Released memory allocated by InitializeDefaultRepeatedFields() and\r\n    GetEmptyString(). Some memory sanitizers reported them as memory leaks.\r\n\r\n  Java\r\n  * Updated DynamicMessage.setField() to handle repeated enum values\r\n    correctly.\r\n  * Fixed a bug that caused NullPointerException to be thrown when\r\n    converting manually constructed FileDescriptorProto to\r\n    FileDescriptor.\r\n\r\n  Python\r\n  * Fixed WhichOneof() to work with de-serialized protobuf messages.\r\n  * Fixed a missing file problem of Python C++ implementation.\r\n\r\n2014-08-15 version 2.6.0:\r\n\r\n  General\r\n  * Added oneofs(unions) feature. Fields in the same oneof will share\r\n    memory and at most one field can be set at the same time. Use the\r\n    oneof keyword to define a oneof like:\r\n      message SampleMessage {\r\n        oneof test_oneof {\r\n          string name = 4;\r\n          YourMessage sub_message = 9;\r\n        }\r\n      }\r\n  * Files, services, enums, messages, methods and enum values can be marked\r\n    as deprecated now.\r\n  * Added Support for list values, including lists of messages, when\r\n    parsing text-formatted protos in C++ and Java.\r\n      For example:  foo: [1, 2, 3]\r\n\r\n  C++\r\n  * Enhanced customization on TestFormat printing.\r\n  * Added SwapFields() in reflection API to swap a subset of fields.\r\n    Added SetAllocatedMessage() in reflection API.\r\n  * Repeated primitive extensions are now packable. The\r\n    [packed=true] option only affects serializers. Therefore, it is\r\n    possible to switch a repeated extension field to packed format\r\n    without breaking backwards-compatibility.\r\n  * Various speed optimizations.\r\n\r\n  Java\r\n  * writeTo() method in ByteString can now write a substring to an\r\n    output stream. Added endWith() method for ByteString.\r\n  * ByteString and ByteBuffer are now supported in CodedInputStream\r\n    and CodedOutputStream.\r\n  * java_generate_equals_and_hash can now be used with the LITE_RUNTIME.\r\n\r\n  Python\r\n  * A new C++-backed extension module (aka \"cpp api v2\") that replaces the\r\n    old (\"cpp api v1\") one.  Much faster than the pure Python code.  This one\r\n    resolves many bugs and is recommended for general use over the\r\n    pure Python when possible.\r\n  * Descriptors now have enum_types_by_name and extension_types_by_name dict\r\n    attributes.\r\n  * Support for Python 3.\r\n\r\n2013-02-27 version 2.5.0:\r\n\r\n  General\r\n  * New notion \"import public\" that allows a proto file to forward the content\r\n    it imports to its importers. For example,\r\n      // foo.proto\r\n      import public \"bar.proto\";\r\n      import \"baz.proto\";\r\n\r\n      // qux.proto\r\n      import \"foo.proto\";\r\n      // Stuff defined in bar.proto may be used in this file, but stuff from\r\n      // baz.proto may NOT be used without importing it explicitly.\r\n    This is useful for moving proto files. To move a proto file, just leave\r\n    a single \"import public\" in the old proto file.\r\n  * New enum option \"allow_alias\" that specifies whether different symbols can\r\n    be assigned the same numeric value. Default value is \"true\". Setting it to\r\n    false causes the compiler to reject enum definitions where multiple symbols\r\n    have the same numeric value.\r\n    Note: We plan to flip the default value to \"false\" in a future release.\r\n    Projects using enum aliases should set the option to \"true\" in their .proto\r\n    files.\r\n\r\n  C++\r\n  * New generated method set_allocated_foo(Type* foo) for message and string\r\n    fields. This method allows you to set the field to a pre-allocated object\r\n    and the containing message takes the ownership of that object.\r\n  * Added SetAllocatedExtension() and ReleaseExtension() to extensions API.\r\n  * Custom options are now formatted correctly when descriptors are printed in\r\n    text format.\r\n  * Various speed optimizations.\r\n\r\n  Java\r\n  * Comments in proto files are now collected and put into generated code as\r\n    comments for corresponding classes and data members.\r\n  * Added Parser to parse directly into messages without a Builder. For\r\n    example,\r\n      Foo foo = Foo.PARSER.ParseFrom(input);\r\n    Using Parser is ~25% faster than using Builder to parse messages.\r\n  * Added getters/setters to access the underlying ByteString of a string field\r\n    directly.\r\n  * ByteString now supports more operations: substring(), prepend(), and\r\n    append(). The implementation of ByteString uses a binary tree structure\r\n    to support these operations efficiently.\r\n  * New method findInitializationErrors() that lists all missing required\r\n    fields.\r\n  * Various code size and speed optimizations.\r\n\r\n  Python\r\n  * Added support for dynamic message creation. DescriptorDatabase,\r\n    DescriptorPool, and MessageFactory work like their C++ counterparts to\r\n    simplify Descriptor construction from *DescriptorProtos, and MessageFactory\r\n    provides a message instance from a Descriptor.\r\n  * Added pickle support for protobuf messages.\r\n  * Unknown fields are now preserved after parsing.\r\n  * Fixed bug where custom options were not correctly populated. Custom\r\n    options can be accessed now.\r\n  * Added EnumTypeWrapper that provides better accessibility to enum types.\r\n  * Added ParseMessage(descriptor, bytes) to generate a new Message instance\r\n    from a descriptor and a byte string.\r\n\r\n2011-05-01 version 2.4.1:\r\n\r\n  C++\r\n  * Fixed the friendship problem for old compilers to make the library now gcc 3\r\n    compatible again.\r\n  * Fixed vcprojects/extract_includes.bat to extract compiler/plugin.h.\r\n\r\n  Java\r\n  * Removed usages of JDK 1.6 only features to make the library now JDK 1.5\r\n    compatible again.\r\n  * Fixed a bug about negative enum values.\r\n  * serialVersionUID is now defined in generated messages for java serializing.\r\n  * Fixed protoc to use java.lang.Object, which makes \"Object\" now a valid\r\n    message name again.\r\n\r\n  Python\r\n  * Experimental C++ implementation now requires C++ protobuf library installed.\r\n    See the README.txt in the python directory for details.\r\n\r\n2011-02-02 version 2.4.0:\r\n\r\n  General\r\n  * The RPC (cc|java|py)_generic_services default value is now false instead of\r\n    true.\r\n  * Custom options can have aggregate types. For example,\r\n      message MyOption {\r\n        optional string comment = 1;\r\n        optional string author = 2;\r\n      }\r\n      extend google.protobuf.FieldOptions {\r\n        optional MyOption myoption = 12345;\r\n      }\r\n    This option can now be set as follows:\r\n      message SomeType {\r\n        optional int32 field = 1 [(myoption) = { comment:'x' author:'y' }];\r\n      }\r\n\r\n  C++\r\n  * Various speed and code size optimizations.\r\n  * Added a release_foo() method on string and message fields.\r\n  * Fixed gzip_output_stream sub-stream handling.\r\n\r\n  Java\r\n  * Builders now maintain sub-builders for sub-messages. Use getFooBuilder() to\r\n    get the builder for the sub-message \"foo\". This allows you to repeatedly\r\n    modify deeply-nested sub-messages without rebuilding them.\r\n  * Builder.build() no longer invalidates the Builder for generated messages\r\n    (You may continue to modify it and then build another message).\r\n  * Code generator will generate efficient equals() and hashCode()\r\n    implementations if new option java_generate_equals_and_hash is enabled.\r\n    (Otherwise, reflection-based implementations are used.)\r\n  * Generated messages now implement Serializable.\r\n  * Fields with [deprecated=true] will be marked with @Deprecated in Java.\r\n  * Added lazy conversion of UTF-8 encoded strings to String objects to improve\r\n    performance.\r\n  * Various optimizations.\r\n  * Enum value can be accessed directly, instead of calling getNumber() on the\r\n    enum member.\r\n  * For each enum value, an integer constant is also generated with the suffix\r\n    _VALUE.\r\n\r\n  Python\r\n  * Added an experimental  C++ implementation for Python messages via a Python\r\n    extension. Implementation type is controlled by an environment variable\r\n    PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION (valid values: \"cpp\" and \"python\")\r\n    The default value is currently \"python\" but will be changed to \"cpp\" in\r\n    future release.\r\n  * Improved performance on message instantiation significantly.\r\n    Most of the work on message instantiation is done just once per message\r\n    class, instead of once per message instance.\r\n  * Improved performance on text message parsing.\r\n  * Allow add() to forward keyword arguments to the concrete class.\r\n      E.g. instead of\r\n        item = repeated_field.add()\r\n        item.foo = bar\r\n        item.baz = quux\r\n      You can do:\r\n        repeated_field.add(foo=bar, baz=quux)\r\n  * Added a sort() interface to the BaseContainer.\r\n  * Added an extend() method to repeated composite fields.\r\n  * Added UTF8 debug string support.\r\n\r\n2010-01-08 version 2.3.0:\r\n\r\n  General\r\n  * Parsers for repeated numeric fields now always accept both packed and\r\n    unpacked input.  The [packed=true] option only affects serializers.\r\n    Therefore, it is possible to switch a field to packed format without\r\n    breaking backwards-compatibility -- as long as all parties are using\r\n    protobuf 2.3.0 or above, at least.\r\n  * The generic RPC service code generated by the C++, Java, and Python\r\n    generators can be disabled via file options:\r\n      option cc_generic_services = false;\r\n      option java_generic_services = false;\r\n      option py_generic_services = false;\r\n    This allows plugins to generate alternative code, possibly specific to some\r\n    particular RPC implementation.\r\n\r\n  protoc\r\n  * Now supports a plugin system for code generators.  Plugins can generate\r\n    code for new languages or inject additional code into the output of other\r\n    code generators.  Plugins are just binaries which accept a protocol buffer\r\n    on stdin and write a protocol buffer to stdout, so they may be written in\r\n    any language.  See src/google/protobuf/compiler/plugin.proto.\r\n    **WARNING**:  Plugins are experimental.  The interface may change in a\r\n    future version.\r\n  * If the output location ends in .zip or .jar, protoc will write its output\r\n    to a zip/jar archive instead of a directory.  For example:\r\n      protoc --java_out=myproto_srcs.jar --python_out=myproto.zip myproto.proto\r\n    Currently the archive contents are not compressed, though this could change\r\n    in the future.\r\n  * inf, -inf, and nan can now be used as default values for float and double\r\n    fields.\r\n\r\n  C++\r\n  * Various speed and code size optimizations.\r\n  * DynamicMessageFactory is now fully thread-safe.\r\n  * Message::Utf8DebugString() method is like DebugString() but avoids escaping\r\n    UTF-8 bytes.\r\n  * Compiled-in message types can now contain dynamic extensions, through use\r\n    of CodedInputStream::SetExtensionRegistry().\r\n  * Now compiles shared libraries (DLLs) by default on Cygwin and MinGW, to\r\n    match other platforms.  Use --disable-shared to avoid this.\r\n\r\n  Java\r\n  * parseDelimitedFrom() and mergeDelimitedFrom() now detect EOF and return\r\n    false/null instead of throwing an exception.\r\n  * Fixed some initialization ordering bugs.\r\n  * Fixes for OpenJDK 7.\r\n\r\n  Python\r\n  * 10-25 times faster than 2.2.0, still pure-Python.\r\n  * Calling a mutating method on a sub-message always instantiates the message\r\n    in its parent even if the mutating method doesn't actually mutate anything\r\n    (e.g. parsing from an empty string).\r\n  * Expanded descriptors a bit.\r\n\r\n2009-08-11 version 2.2.0:\r\n\r\n  C++\r\n  * Lite mode:  The \"optimize_for = LITE_RUNTIME\" option causes the compiler\r\n    to generate code which only depends libprotobuf-lite, which is much smaller\r\n    than libprotobuf but lacks descriptors, reflection, and some other features.\r\n  * Fixed bug where Message.Swap(Message) was only implemented for\r\n    optimize_for_speed.  Swap now properly implemented in both modes\r\n    (Issue 91).\r\n  * Added RemoveLast and SwapElements(index1, index2) to Reflection\r\n    interface for repeated elements.\r\n  * Added Swap(Message) to Reflection interface.\r\n  * Floating-point literals in generated code that are intended to be\r\n    single-precision now explicitly have 'f' suffix to avoid pedantic warnings\r\n    produced by some compilers.\r\n  * The [deprecated=true] option now causes the C++ code generator to generate\r\n    a GCC-style deprecation annotation (no-op on other compilers).\r\n  * google::protobuf::GetEnumDescriptor<SomeGeneratedEnumType>() returns the\r\n    EnumDescriptor for that type -- useful for templates which cannot call\r\n    SomeGeneratedEnumType_descriptor().\r\n  * Various optimizations and obscure bug fixes.\r\n\r\n  Java\r\n  * Lite mode:  The \"optimize_for = LITE_RUNTIME\" option causes the compiler\r\n    to generate code which only depends libprotobuf-lite, which is much smaller\r\n    than libprotobuf but lacks descriptors, reflection, and some other features.\r\n  * Lots of style cleanups.\r\n\r\n  Python\r\n  * Fixed endianness bug with floats and doubles.\r\n  * Text format parsing support.\r\n  * Fix bug with parsing packed repeated fields in embedded messages.\r\n  * Ability to initialize fields by passing keyword args to constructor.\r\n  * Support iterators in extend and __setslice__ for containers.\r\n\r\n2009-05-13 version 2.1.0:\r\n\r\n  General\r\n  * Repeated fields of primitive types (types other that string, group, and\r\n    nested messages) may now use the option [packed = true] to get a more\r\n    efficient encoding.  In the new encoding, the entire list is written\r\n    as a single byte blob using the \"length-delimited\" wire type.  Within\r\n    this blob, the individual values are encoded the same way they would\r\n    be normally except without a tag before each value (thus, they are\r\n    tightly \"packed\").\r\n  * For each field, the generated code contains an integer constant assigned\r\n    to the field number.  For example, the .proto file:\r\n      message Foo { optional int bar_baz = 123; }\r\n    would generate the following constants, all with the integer value 123:\r\n      C++:     Foo::kBarBazFieldNumber\r\n      Java:    Foo.BAR_BAZ_FIELD_NUMBER\r\n      Python:  Foo.BAR_BAZ_FIELD_NUMBER\r\n    Constants are also generated for extensions, with the same naming scheme.\r\n    These constants may be used as switch cases.\r\n  * Updated bundled Google Test to version 1.3.0.  Google Test is now bundled\r\n    in its verbatim form as a nested autoconf package, so you can drop in any\r\n    other version of Google Test if needed.\r\n  * optimize_for = SPEED is now the default, by popular demand.  Use\r\n    optimize_for = CODE_SIZE if code size is more important in your app.\r\n  * It is now an error to define a default value for a repeated field.\r\n    Previously, this was silently ignored (it had no effect on the generated\r\n    code).\r\n  * Fields can now be marked deprecated like:\r\n      optional int32 foo = 1 [deprecated = true];\r\n    Currently this does not have any actual effect, but in the future the code\r\n    generators may generate deprecation annotations in each language.\r\n  * Cross-compiling should now be possible using the --with-protoc option to\r\n    configure.  See README.txt for more info.\r\n\r\n  protoc\r\n  * --error_format=msvs option causes errors to be printed in Visual Studio\r\n    format, which should allow them to be clicked on in the build log to go\r\n    directly to the error location.\r\n  * The type name resolver will no longer resolve type names to fields.  For\r\n    example, this now works:\r\n      message Foo {}\r\n      message Bar {\r\n        optional int32 Foo = 1;\r\n        optional Foo baz = 2;\r\n      }\r\n    Previously, the type of \"baz\" would resolve to \"Bar.Foo\", and you'd get\r\n    an error because Bar.Foo is a field, not a type.  Now the type of \"baz\"\r\n    resolves to the message type Foo.  This change is unlikely to make a\r\n    difference to anyone who follows the Protocol Buffers style guide.\r\n\r\n  C++\r\n  * Several optimizations, including but not limited to:\r\n    - Serialization, especially to flat arrays, is 10%-50% faster, possibly\r\n      more for small objects.\r\n    - Several descriptor operations which previously required locking no longer\r\n      do.\r\n    - Descriptors are now constructed lazily on first use, rather than at\r\n      process startup time.  This should save memory in programs which do not\r\n      use descriptors or reflection.\r\n    - UnknownFieldSet completely redesigned to be more efficient (especially in\r\n      terms of memory usage).\r\n    - Various optimizations to reduce code size (though the serialization speed\r\n      optimizations increased code size).\r\n  * Message interface has method ParseFromBoundedZeroCopyStream() which parses\r\n    a limited number of bytes from an input stream rather than parsing until\r\n    EOF.\r\n  * GzipInputStream and GzipOutputStream support reading/writing gzip- or\r\n    zlib-compressed streams if zlib is available.\r\n    (google/protobuf/io/gzip_stream.h)\r\n  * DescriptorPool::FindAllExtensions() and corresponding\r\n    DescriptorDatabase::FindAllExtensions() can be used to enumerate all\r\n    extensions of a given type.\r\n  * For each enum type Foo, protoc will generate functions:\r\n      const string& Foo_Name(Foo value);\r\n      bool Foo_Parse(const string& name, Foo* result);\r\n    The former returns the name of the enum constant corresponding to the given\r\n    value while the latter finds the value corresponding to a name.\r\n  * RepeatedField and RepeatedPtrField now have back-insertion iterators.\r\n  * String fields now have setters that take a char* and a size, in addition\r\n    to the existing ones that took char* or const string&.\r\n  * DescriptorPool::AllowUnknownDependencies() may be used to tell\r\n    DescriptorPool to create placeholder descriptors for unknown entities\r\n    referenced in a FileDescriptorProto.  This can allow you to parse a .proto\r\n    file without having access to other .proto files that it imports, for\r\n    example.\r\n  * Updated gtest to latest version.  The gtest package is now included as a\r\n    nested autoconf package, so it should be able to drop new versions into the\r\n    \"gtest\" subdirectory without modification.\r\n\r\n  Java\r\n  * Fixed bug where Message.mergeFrom(Message) failed to merge extensions.\r\n  * Message interface has new method toBuilder() which is equivalent to\r\n    newBuilderForType().mergeFrom(this).\r\n  * All enums now implement the ProtocolMessageEnum interface.\r\n  * Setting a field to null now throws NullPointerException.\r\n  * Fixed tendency for TextFormat's parsing to overflow the stack when\r\n    parsing large string values.  The underlying problem is with Java's\r\n    regex implementation (which unfortunately uses recursive backtracking\r\n    rather than building an NFA).  Worked around by making use of possessive\r\n    quantifiers.\r\n  * Generated service classes now also generate pure interfaces.  For a service\r\n    Foo, Foo.Interface is a pure interface containing all of the service's\r\n    defined methods.  Foo.newReflectiveService() can be called to wrap an\r\n    instance of this interface in a class that implements the generic\r\n    RpcService interface, which provides reflection support that is usually\r\n    needed by RPC server implementations.\r\n  * RPC interfaces now support blocking operation in addition to non-blocking.\r\n    The protocol compiler generates separate blocking and non-blocking stubs\r\n    which operate against separate blocking and non-blocking RPC interfaces.\r\n    RPC implementations will have to implement the new interfaces in order to\r\n    support blocking mode.\r\n  * New I/O methods parseDelimitedFrom(), mergeDelimitedFrom(), and\r\n    writeDelimitedTo() read and write \"delimited\" messages from/to a stream,\r\n    meaning that the message size precedes the data.  This way, you can write\r\n    multiple messages to a stream without having to worry about delimiting\r\n    them yourself.\r\n  * Throw a more descriptive exception when build() is double-called.\r\n  * Add a method to query whether CodedInputStream is at the end of the input\r\n    stream.\r\n  * Add a method to reset a CodedInputStream's size counter; useful when\r\n    reading many messages with the same stream.\r\n  * equals() and hashCode() now account for unknown fields.\r\n\r\n  Python\r\n  * Added slicing support for repeated scalar fields. Added slice retrieval and\r\n    removal of repeated composite fields.\r\n  * Updated RPC interfaces to allow for blocking operation.  A client may\r\n    now pass None for a callback when making an RPC, in which case the\r\n    call will block until the response is received, and the response\r\n    object will be returned directly to the caller.  This interface change\r\n    cannot be used in practice until RPC implementations are updated to\r\n    implement it.\r\n  * Changes to input_stream.py should make protobuf compatible with appengine.\r\n\r\n2008-11-25 version 2.0.3:\r\n\r\n  protoc\r\n  * Enum values may now have custom options, using syntax similar to field\r\n    options.\r\n  * Fixed bug where .proto files which use custom options but don't actually\r\n    define them (i.e. they import another .proto file defining the options)\r\n    had to explicitly import descriptor.proto.\r\n  * Adjacent string literals in .proto files will now be concatenated, like in\r\n    C.\r\n  * If an input file is a Windows absolute path (e.g. \"C:\\foo\\bar.proto\") and\r\n    the import path only contains \".\" (or contains \".\" but does not contain\r\n    the file), protoc incorrectly thought that the file was under \".\", because\r\n    it thought that the path was relative (since it didn't start with a slash).\r\n    This has been fixed.\r\n\r\n  C++\r\n  * Generated message classes now have a Swap() method which efficiently swaps\r\n    the contents of two objects.\r\n  * All message classes now have a SpaceUsed() method which returns an estimate\r\n    of the number of bytes of allocated memory currently owned by the object.\r\n    This is particularly useful when you are reusing a single message object\r\n    to improve performance but want to make sure it doesn't bloat up too large.\r\n  * New method Message::SerializeAsString() returns a string containing the\r\n    serialized data.  May be more convenient than calling\r\n    SerializeToString(string*).\r\n  * In debug mode, log error messages when string-type fields are found to\r\n    contain bytes that are not valid UTF-8.\r\n  * Fixed bug where a message with multiple extension ranges couldn't parse\r\n    extensions.\r\n  * Fixed bug where MergeFrom(const Message&) didn't do anything if invoked on\r\n    a message that contained no fields (but possibly contained extensions).\r\n  * Fixed ShortDebugString() to not be O(n^2).  Durr.\r\n  * Fixed crash in TextFormat parsing if the first token in the input caused a\r\n    tokenization error.\r\n  * Fixed obscure bugs in zero_copy_stream_impl.cc.\r\n  * Added support for HP C++ on Tru64.\r\n  * Only build tests on \"make check\", not \"make\".\r\n  * Fixed alignment issue that caused crashes when using DynamicMessage on\r\n    64-bit Sparc machines.\r\n  * Simplify template usage to work with MSVC 2003.\r\n  * Work around GCC 4.3.x x86_64 compiler bug that caused crashes on startup.\r\n    (This affected Fedora 9 in particular.)\r\n  * Now works on \"Solaris 10 using recent Sun Studio\".\r\n\r\n  Java\r\n  * New overload of mergeFrom() which parses a slice of a byte array instead\r\n    of the whole thing.\r\n  * New method ByteString.asReadOnlyByteBuffer() does what it sounds like.\r\n  * Improved performance of isInitialized() when optimizing for code size.\r\n\r\n  Python\r\n  * Corrected ListFields() signature in Message base class to match what\r\n    subclasses actually implement.\r\n  * Some minor refactoring.\r\n  * Don't pass self as first argument to superclass constructor (no longer\r\n    allowed in Python 2.6).\r\n\r\n2008-09-29 version 2.0.2:\r\n\r\n  General\r\n  * License changed from Apache 2.0 to New BSD.\r\n  * It is now possible to define custom \"options\", which are basically\r\n    annotations which may be placed on definitions in a .proto file.\r\n    For example, you might define a field option called \"foo\" like so:\r\n      import \"google/protobuf/descriptor.proto\"\r\n      extend google.protobuf.FieldOptions {\r\n        optional string foo = 12345;\r\n      }\r\n    Then you annotate a field using the \"foo\" option:\r\n      message MyMessage {\r\n        optional int32 some_field = 1 [(foo) = \"bar\"]\r\n      }\r\n    The value of this option is then visible via the message's\r\n    Descriptor:\r\n      const FieldDescriptor* field =\r\n        MyMessage::descriptor()->FindFieldByName(\"some_field\");\r\n      assert(field->options().GetExtension(foo) == \"bar\");\r\n    This feature has been implemented and tested in C++ and Java.\r\n    Other languages may or may not need to do extra work to support\r\n    custom options, depending on how they construct descriptors.\r\n\r\n  C++\r\n  * Fixed some GCC warnings that only occur when using -pedantic.\r\n  * Improved static initialization code, making ordering more\r\n    predictable among other things.\r\n  * TextFormat will no longer accept messages which contain multiple\r\n    instances of a singular field.  Previously, the latter instance\r\n    would overwrite the former.\r\n  * Now works on systems that don't have hash_map.\r\n\r\n  Java\r\n  * Print @Override annotation in generated code where appropriate.\r\n\r\n  Python\r\n  * Strings now use the \"unicode\" type rather than the \"str\" type.\r\n    String fields may still be assigned ASCII \"str\" values; they will\r\n    automatically be converted.\r\n  * Adding a property to an object representing a repeated field now\r\n    raises an exception.  For example:\r\n      # No longer works (and never should have).\r\n      message.some_repeated_field.foo = 1\r\n\r\n  Windows\r\n  * We now build static libraries rather than DLLs by default on MSVC.\r\n    See vsprojects/readme.txt for more information.\r\n\r\n2008-08-15 version 2.0.1:\r\n\r\n  protoc\r\n  * New flags --encode and --decode can be used to convert between protobuf text\r\n    format and binary format from the command-line.\r\n  * New flag --descriptor_set_out can be used to write FileDescriptorProtos for\r\n    all parsed files directly into a single output file.  This is particularly\r\n    useful if you wish to parse .proto files from programs written in languages\r\n    other than C++: just run protoc as a background process and have it output\r\n    a FileDescriptorList, then parse that natively.\r\n  * Improved error message when an enum value's name conflicts with another\r\n    symbol defined in the enum type's scope, e.g. if two enum types declared\r\n    in the same scope have values with the same name.  This is disallowed for\r\n    compatibility with C++, but this wasn't clear from the error.\r\n  * Fixed absolute output paths on Windows.\r\n  * Allow trailing slashes in --proto_path mappings.\r\n\r\n  C++\r\n  * Reflection objects are now per-class rather than per-instance.  To make this\r\n    possible, the Reflection interface had to be changed such that all methods\r\n    take the Message instance as a parameter.  This change improves performance\r\n    significantly in memory-bandwidth-limited use cases, since it makes the\r\n    message objects smaller.  Note that source-incompatible interface changes\r\n    like this will not be made again after the library leaves beta.\r\n  * Heuristically detect sub-messages when printing unknown fields.\r\n  * Fix static initialization ordering bug that caused crashes at startup when\r\n    compiling on Mac with static linking.\r\n  * Fixed TokenizerTest when compiling with -DNDEBUG on Linux.\r\n  * Fixed incorrect definition of kint32min.\r\n  * Fix bytes type setter to work with byte sequences with embedded NULLs.\r\n  * Other irrelevant tweaks.\r\n\r\n  Java\r\n  * Fixed UnknownFieldSet's parsing of varints larger than 32 bits.\r\n  * Fixed TextFormat's parsing of \"inf\" and \"nan\".\r\n  * Fixed TextFormat's parsing of comments.\r\n  * Added info to Java POM that will be required when we upload the\r\n    package to a Maven repo.\r\n\r\n  Python\r\n  * MergeFrom(message) and CopyFrom(message) are now implemented.\r\n  * SerializeToString() raises an exception if the message is missing required\r\n    fields.\r\n  * Code organization improvements.\r\n  * Fixed doc comments for RpcController and RpcChannel, which had somehow been\r\n    swapped.\r\n  * Fixed text_format_test on Windows where floating-point exponents sometimes\r\n    contain extra zeros.\r\n  * Fix Python service CallMethod() implementation.\r\n\r\n  Other\r\n  * Improved readmes.\r\n  * VIM syntax highlighting improvements.\r\n\r\n2008-07-07 version 2.0.0:\r\n\r\n  * First public release.\r\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/CONTRIBUTORS.txt",
    "content": "This file contains a list of people who have made large contributions\r\nto the public version of Protocol Buffers.\r\n\r\nOriginal Protocol Buffers design and implementation:\r\n  Sanjay Ghemawat <sanjay@google.com>\r\n  Jeff Dean <jeff@google.com>\r\n  Daniel Dulitz <daniel@google.com>\r\n  Craig Silverstein\r\n  Paul Haahr <haahr@google.com>\r\n  Corey Anderson <corin@google.com>\r\n  (and many others)\r\n\r\nProto2 C++ and Java primary author:\r\n  Kenton Varda <kenton@google.com>\r\n\r\nProto2 Python primary authors:\r\n  Will Robinson <robinson@google.com>\r\n  Petar Petrov <petar@google.com>\r\n\r\nJava Nano primary authors:\r\n  Brian Duff <bduff@google.com>\r\n  Tom Chao <chaot@google.com>\r\n  Max Cai <maxtroy@google.com>\r\n  Ulas Kirazci <ulas@google.com>\r\n\r\nLarge code contributions:\r\n  Jason Hsueh <jasonh@google.com>\r\n  Joseph Schorr <jschorr@google.com>\r\n  Wenbo Zhu <wenboz@google.com>\r\n\r\nLarge quantity of code reviews:\r\n  Scott Bruce <sbruce@google.com>\r\n  Frank Yellin\r\n  Neal Norwitz <nnorwitz@google.com>\r\n  Jeffrey Yasskin <jyasskin@google.com>\r\n  Ambrose Feinstein <ambrose@google.com>\r\n\r\nDocumentation:\r\n  Lisa Carey <lcarey@google.com>\r\n\r\nMaven packaging:\r\n  Gregory Kick <gak@google.com>\r\n\r\nPatch contributors:\r\n  Kevin Ko <kevin.s.ko@gmail.com>\r\n    * Small patch to handle trailing slashes in --proto_path flag.\r\n  Johan Euphrosine <proppy@aminche.com>\r\n    * Small patch to fix Python CallMethod().\r\n  Ulrich Kunitz <kune@deine-taler.de>\r\n    * Small optimizations to Python serialization.\r\n  Leandro Lucarella <llucax@gmail.com>\r\n    * VI syntax highlighting tweaks.\r\n    * Fix compiler to not make output executable.\r\n  Dilip Joseph <dilip.antony.joseph@gmail.com>\r\n    * Heuristic detection of sub-messages when printing unknown fields in\r\n      text format.\r\n  Brian Atkinson <nairb774@gmail.com>\r\n    * Added @Override annotation to generated Java code where appropriate.\r\n  Vincent Choinière <Choiniere.Vincent@hydro.qc.ca>\r\n    * Tru64 support.\r\n  Monty Taylor <monty.taylor@gmail.com>\r\n    * Solaris 10 + Sun Studio fixes.\r\n  Alek Storm <alek.storm@gmail.com>\r\n    * Slicing support for repeated scalar fields for the Python API.\r\n  Oleg Smolsky <oleg.smolsky@gmail.com>\r\n    * MS Visual Studio error format option.\r\n    * Detect unordered_map in stl_hash.m4.\r\n  Brian Olson <brianolson@google.com>\r\n    * gzip/zlib I/O support.\r\n  Michael Poole <mdpoole@troilus.org>\r\n    * Fixed warnings about generated constructors not explicitly initializing\r\n      all fields (only present with certain compiler settings).\r\n    * Added generation of field number constants.\r\n  Wink Saville <wink@google.com>\r\n    * Fixed initialization ordering problem in logging code.\r\n  Will Pierce <willp@nuclei.com>\r\n    * Small patch improving performance of in Python serialization.\r\n  Alexandre Vassalotti <alexandre@peadrop.com>\r\n    * Emacs mode for Protocol Buffers (editors/protobuf-mode.el).\r\n  Scott Stafford <scott.stafford@gmail.com>\r\n    * Added Swap(), SwapElements(), and RemoveLast() to Reflection interface.\r\n  Alexander Melnikov <alm@sibmail.ru>\r\n    * HPUX support.\r\n  Oliver Jowett <oliver.jowett@gmail.com>\r\n    * Detect whether zlib is new enough in configure script.\r\n    * Fixes for Solaris 10 32/64-bit confusion.\r\n  Evan Jones <evanj@mit.edu>\r\n    * Optimize Java serialization code when writing a small message to a stream.\r\n    * Optimize Java serialization of strings so that UTF-8 encoding happens only\r\n      once per string per serialization call.\r\n    * Clean up some Java warnings.\r\n    * Fix bug with permanent callbacks that delete themselves when run.\r\n  Michael Kucharski <m.kucharski@gmail.com>\r\n    * Added CodedInputStream.getTotalBytesRead().\r\n  Kacper Kowalik <xarthisius.kk@gmail.com>\r\n    * Fixed m4/acx_pthread.m4 problem for some Linux distributions.\r\n  William Orr <will@worrbase.com>\r\n    * Fixed detection of sched_yield on Solaris.\r\n    * Added atomicops for Solaris\r\n  Andrew Paprocki <andrew@ishiboo.com>\r\n    * Fixed minor IBM xlC compiler build issues\r\n    * Added atomicops for AIX (POWER)\r\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/LICENSE",
    "content": "This license applies to all parts of Protocol Buffers except the following:\n\n  - Atomicops support for generic gcc, located in\n    src/google/protobuf/stubs/atomicops_internals_generic_gcc.h.\n    This file is copyrighted by Red Hat Inc.\n\n  - Atomicops support for AIX/POWER, located in\n    src/google/protobuf/stubs/atomicops_internals_power.h.\n    This file is copyrighted by Bloomberg Finance LP.\n\nCopyright 2014, Google Inc.  All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n    * Redistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above\ncopyright notice, this list of conditions and the following disclaimer\nin the documentation and/or other materials provided with the\ndistribution.\n    * Neither the name of Google Inc. nor the names of its\ncontributors may be used to endorse or promote products derived from\nthis software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\nA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\nOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\nSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\nLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nCode generated by the Protocol Buffer compiler is owned by the owner\nof the input file used when generating it.  This code is not\nstandalone and requires a support library to be linked with it.  This\nsupport library is itself covered by the above license.\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/Makefile.am",
    "content": "## Process this file with automake to produce Makefile.in\n\nACLOCAL_AMFLAGS = -I m4\n\nAUTOMAKE_OPTIONS = foreign\n\n# Build . before src so that our all-local and clean-local hooks kicks in at\n# the right time.\nSUBDIRS = . src\n\n# Always include gmock in distributions.\nDIST_SUBDIRS = $(subdirs) src conformance benchmarks\n\n# Build gmock before we build protobuf tests.  We don't add gmock to SUBDIRS\n# because then \"make check\" would also build and run all of gmock's own tests,\n# which takes a lot of time and is generally not useful to us.  Also, we don't\n# want \"make install\" to recurse into gmock since we don't want to overwrite\n# the installed version of gmock if there is one.\ncheck-local:\n\t@echo \"Making lib/libgmock.a lib/libgmock_main.a in gmock\"\n\t@cd gmock && $(MAKE) $(AM_MAKEFLAGS) lib/libgmock.la lib/libgmock_main.la\n\t@cd gmock/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la\n\n# We would like to clean gmock when \"make clean\" is invoked.  But we have to\n# be careful because clean-local is also invoked during \"make distclean\", but\n# \"make distclean\" already recurses into gmock because it's listed among the\n# DIST_SUBDIRS.  distclean will delete gmock/Makefile, so if we then try to\n# cd to the directory again and \"make clean\" it will fail.  So, check that the\n# Makefile exists before recursing.\nclean-local:\n\t@if test -e gmock/Makefile; then \\\n\t  echo \"Making clean in gmock\"; \\\n\t  cd gmock && $(MAKE) $(AM_MAKEFLAGS) clean; \\\n\tfi; \\\n\tif test -e conformance/Makefile; then \\\n\t  echo \"Making clean in conformance\"; \\\n\t  cd conformance && $(MAKE) $(AM_MAKEFLAGS) clean; \\\n\tfi; \\\n\tif test -e benchmarks/Makefile; then \\\n\t  echo \"Making clean in benchmarks\"; \\\n\t  cd benchmarks && $(MAKE) $(AM_MAKEFLAGS) clean; \\\n\tfi; \\\n\tif test -e objectivec/DevTools; then \\\n\t  echo \"Cleaning any ObjC pyc files\"; \\\n\t  rm -f objectivec/DevTools/*.pyc; \\\n\tfi\n\npkgconfigdir = $(libdir)/pkgconfig\npkgconfig_DATA = protobuf.pc protobuf-lite.pc\n\ncsharp_EXTRA_DIST=                                                           \\\n  csharp/.gitignore                                                          \\\n  csharp/CHANGES.txt                                                         \\\n  csharp/Google.Protobuf.Tools.nuspec                                        \\\n  csharp/README.md                                                           \\\n  csharp/build_packages.bat                                                  \\\n  csharp/buildall.sh                                                         \\\n  csharp/generate_protos.sh                                                  \\\n  csharp/keys/Google.Protobuf.public.snk                                     \\\n  csharp/keys/Google.Protobuf.snk                                            \\\n  csharp/keys/README.md                                                      \\\n  csharp/protos/unittest_issues.proto                                        \\\n  csharp/src/AddressBook/AddPerson.cs                                        \\\n  csharp/src/AddressBook/Addressbook.cs                                      \\\n  csharp/src/AddressBook/AddressBook.xproj                                   \\\n  csharp/src/AddressBook/ListPeople.cs                                       \\\n  csharp/src/AddressBook/Program.cs                                          \\\n  csharp/src/AddressBook/SampleUsage.cs                                      \\\n  csharp/src/AddressBook/project.json                                        \\\n  csharp/src/Google.Protobuf.Conformance/Conformance.cs                      \\\n  csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.xproj   \\\n  csharp/src/Google.Protobuf.Conformance/Program.cs                          \\\n  csharp/src/Google.Protobuf.Conformance/project.json                        \\\n  csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.xproj         \\\n  csharp/src/Google.Protobuf.JsonDump/Program.cs                             \\\n  csharp/src/Google.Protobuf.JsonDump/project.json                           \\\n  csharp/src/Google.Protobuf.Test/ByteStringTest.cs                          \\\n  csharp/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs              \\\n  csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs                    \\\n  csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs                   \\\n  csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs                \\\n  csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs           \\\n  csharp/src/Google.Protobuf.Test/Compatibility/PropertyInfoExtensionsTest.cs \\\n  csharp/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs        \\\n  csharp/src/Google.Protobuf.Test/DeprecatedMemberTest.cs                    \\\n  csharp/src/Google.Protobuf.Test/EqualityTester.cs                          \\\n  csharp/src/Google.Protobuf.Test/FieldCodecTest.cs                          \\\n  csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs                    \\\n  csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj                 \\\n  csharp/src/Google.Protobuf.Test/IssuesTest.cs                              \\\n  csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs                       \\\n  csharp/src/Google.Protobuf.Test/JsonParserTest.cs                          \\\n  csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs                       \\\n  csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs              \\\n  csharp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs              \\\n  csharp/src/Google.Protobuf.Test/Reflection/TypeRegistryTest.cs             \\\n  csharp/src/Google.Protobuf.Test/SampleEnum.cs                              \\\n  csharp/src/Google.Protobuf.Test/SampleMessages.cs                          \\\n  csharp/src/Google.Protobuf.Test/TestCornerCases.cs                         \\\n  csharp/src/Google.Protobuf.Test/TestProtos/ForeignMessagePartial.cs        \\\n  csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs            \\\n  csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs         \\\n  csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs   \\\n  csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs               \\\n  csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs               \\\n  csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs       \\\n  csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs                  \\\n  csharp/src/Google.Protobuf.Test/WellKnownTypes/DurationTest.cs             \\\n  csharp/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs            \\\n  csharp/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs            \\\n  csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs             \\\n  csharp/src/Google.Protobuf.Test/project.json                               \\\n  csharp/src/Google.Protobuf.sln                                             \\\n  csharp/src/Google.Protobuf/ByteArray.cs                                    \\\n  csharp/src/Google.Protobuf/ByteString.cs                                   \\\n  csharp/src/Google.Protobuf/CodedInputStream.cs                             \\\n  csharp/src/Google.Protobuf/CodedOutputStream.ComputeSize.cs                \\\n  csharp/src/Google.Protobuf/CodedOutputStream.cs                            \\\n  csharp/src/Google.Protobuf/Collections/MapField.cs                         \\\n  csharp/src/Google.Protobuf/Collections/ReadOnlyDictionary.cs               \\\n  csharp/src/Google.Protobuf/Collections/RepeatedField.cs                    \\\n  csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs         \\\n  csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs                 \\\n  csharp/src/Google.Protobuf/FieldCodec.cs                                   \\\n  csharp/src/Google.Protobuf/FrameworkPortability.cs                         \\\n  csharp/src/Google.Protobuf/Google.Protobuf.xproj                           \\\n  csharp/src/Google.Protobuf/ICustomDiagnosticMessage.cs                     \\\n  csharp/src/Google.Protobuf/IDeepCloneable.cs                               \\\n  csharp/src/Google.Protobuf/IMessage.cs                                     \\\n  csharp/src/Google.Protobuf/InvalidJsonException.cs                         \\\n  csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs               \\\n  csharp/src/Google.Protobuf/JsonFormatter.cs                                \\\n  csharp/src/Google.Protobuf/JsonParser.cs                                   \\\n  csharp/src/Google.Protobuf/JsonToken.cs                                    \\\n  csharp/src/Google.Protobuf/JsonTokenizer.cs                                \\\n  csharp/src/Google.Protobuf/LimitedInputStream.cs                           \\\n  csharp/src/Google.Protobuf/MessageExtensions.cs                            \\\n  csharp/src/Google.Protobuf/MessageParser.cs                                \\\n  csharp/src/Google.Protobuf/ProtoPreconditions.cs                           \\\n  csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs                      \\\n  csharp/src/Google.Protobuf/Reflection/Descriptor.cs                        \\\n  csharp/src/Google.Protobuf/Reflection/DescriptorBase.cs                    \\\n  csharp/src/Google.Protobuf/Reflection/DescriptorPool.cs                    \\\n  csharp/src/Google.Protobuf/Reflection/DescriptorUtil.cs                    \\\n  csharp/src/Google.Protobuf/Reflection/DescriptorValidationException.cs     \\\n  csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs                    \\\n  csharp/src/Google.Protobuf/Reflection/EnumValueDescriptor.cs               \\\n  csharp/src/Google.Protobuf/Reflection/FieldAccessorBase.cs                 \\\n  csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs                   \\\n  csharp/src/Google.Protobuf/Reflection/FieldType.cs                         \\\n  csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs                    \\\n  csharp/src/Google.Protobuf/Reflection/GeneratedClrTypeInfo.cs              \\\n  csharp/src/Google.Protobuf/Reflection/IDescriptor.cs                       \\\n  csharp/src/Google.Protobuf/Reflection/IFieldAccessor.cs                    \\\n  csharp/src/Google.Protobuf/Reflection/MapFieldAccessor.cs                  \\\n  csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs                 \\\n  csharp/src/Google.Protobuf/Reflection/MethodDescriptor.cs                  \\\n  csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs                     \\\n  csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs                   \\\n  csharp/src/Google.Protobuf/Reflection/OriginalNameAttribute.cs             \\\n  csharp/src/Google.Protobuf/Reflection/PackageDescriptor.cs                 \\\n  csharp/src/Google.Protobuf/Reflection/PartialClasses.cs                    \\\n  csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs                    \\\n  csharp/src/Google.Protobuf/Reflection/RepeatedFieldAccessor.cs             \\\n  csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs                 \\\n  csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs               \\\n  csharp/src/Google.Protobuf/Reflection/TypeRegistry.cs                      \\\n  csharp/src/Google.Protobuf/WellKnownTypes/Any.cs                           \\\n  csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs                    \\\n  csharp/src/Google.Protobuf/WellKnownTypes/Api.cs                           \\\n  csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs                      \\\n  csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs               \\\n  csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs                         \\\n  csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs                     \\\n  csharp/src/Google.Protobuf/WellKnownTypes/FieldMaskPartial.cs              \\\n  csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs                 \\\n  csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs                        \\\n  csharp/src/Google.Protobuf/WellKnownTypes/TimeExtensions.cs                \\\n  csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs                     \\\n  csharp/src/Google.Protobuf/WellKnownTypes/TimestampPartial.cs              \\\n  csharp/src/Google.Protobuf/WellKnownTypes/Type.cs                          \\\n  csharp/src/Google.Protobuf/WellKnownTypes/ValuePartial.cs                  \\\n  csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs                      \\\n  csharp/src/Google.Protobuf/WellKnownTypes/WrappersPartial.cs               \\\n  csharp/src/Google.Protobuf/WireFormat.cs                                   \\\n  csharp/src/Google.Protobuf/project.json                                    \\\n  csharp/src/packages/repositories.config\n\njava_EXTRA_DIST=                                                                   \\\n  java/README.md                                                                   \\\n  java/core/generate-sources-build.xml                                             \\\n  java/core/generate-test-sources-build.xml                                        \\\n  java/core/pom.xml                                                                \\\n  java/core/src/main/java/com/google/protobuf/AbstractMessage.java                 \\\n  java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java             \\\n  java/core/src/main/java/com/google/protobuf/AbstractParser.java                  \\\n  java/core/src/main/java/com/google/protobuf/AbstractProtobufList.java            \\\n  java/core/src/main/java/com/google/protobuf/BlockingRpcChannel.java              \\\n  java/core/src/main/java/com/google/protobuf/BlockingService.java                 \\\n  java/core/src/main/java/com/google/protobuf/BooleanArrayList.java                \\\n  java/core/src/main/java/com/google/protobuf/ByteBufferWriter.java                \\\n  java/core/src/main/java/com/google/protobuf/ByteOutput.java                      \\\n  java/core/src/main/java/com/google/protobuf/ByteString.java                      \\\n  java/core/src/main/java/com/google/protobuf/CodedInputStream.java                \\\n  java/core/src/main/java/com/google/protobuf/CodedOutputStream.java               \\\n  java/core/src/main/java/com/google/protobuf/Descriptors.java                     \\\n  java/core/src/main/java/com/google/protobuf/DoubleArrayList.java                 \\\n  java/core/src/main/java/com/google/protobuf/DynamicMessage.java                  \\\n  java/core/src/main/java/com/google/protobuf/ExperimentalApi.java                 \\\n  java/core/src/main/java/com/google/protobuf/Extension.java                       \\\n  java/core/src/main/java/com/google/protobuf/ExtensionLite.java                   \\\n  java/core/src/main/java/com/google/protobuf/ExtensionRegistry.java               \\\n  java/core/src/main/java/com/google/protobuf/ExtensionRegistryFactory.java        \\\n  java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java           \\\n  java/core/src/main/java/com/google/protobuf/FieldSet.java                        \\\n  java/core/src/main/java/com/google/protobuf/FloatArrayList.java                  \\\n  java/core/src/main/java/com/google/protobuf/GeneratedMessage.java                \\\n  java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java            \\\n  java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java              \\\n  java/core/src/main/java/com/google/protobuf/IntArrayList.java                    \\\n  java/core/src/main/java/com/google/protobuf/Internal.java                        \\\n  java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java  \\\n  java/core/src/main/java/com/google/protobuf/LazyField.java                       \\\n  java/core/src/main/java/com/google/protobuf/LazyFieldLite.java                   \\\n  java/core/src/main/java/com/google/protobuf/LazyStringArrayList.java             \\\n  java/core/src/main/java/com/google/protobuf/LazyStringList.java                  \\\n  java/core/src/main/java/com/google/protobuf/LongArrayList.java                   \\\n  java/core/src/main/java/com/google/protobuf/MapEntry.java                        \\\n  java/core/src/main/java/com/google/protobuf/MapEntryLite.java                    \\\n  java/core/src/main/java/com/google/protobuf/MapField.java                        \\\n  java/core/src/main/java/com/google/protobuf/MapFieldLite.java                    \\\n  java/core/src/main/java/com/google/protobuf/Message.java                         \\\n  java/core/src/main/java/com/google/protobuf/MessageLite.java                     \\\n  java/core/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java            \\\n  java/core/src/main/java/com/google/protobuf/MessageLiteToString.java             \\\n  java/core/src/main/java/com/google/protobuf/MessageOrBuilder.java                \\\n  java/core/src/main/java/com/google/protobuf/MessageReflection.java               \\\n  java/core/src/main/java/com/google/protobuf/MutabilityOracle.java                \\\n  java/core/src/main/java/com/google/protobuf/NioByteString.java                   \\\n  java/core/src/main/java/com/google/protobuf/Parser.java                          \\\n  java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java               \\\n  java/core/src/main/java/com/google/protobuf/ProtocolMessageEnum.java             \\\n  java/core/src/main/java/com/google/protobuf/ProtocolStringList.java              \\\n  java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java            \\\n  java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilderV3.java          \\\n  java/core/src/main/java/com/google/protobuf/RopeByteString.java                  \\\n  java/core/src/main/java/com/google/protobuf/RpcCallback.java                     \\\n  java/core/src/main/java/com/google/protobuf/RpcChannel.java                      \\\n  java/core/src/main/java/com/google/protobuf/RpcController.java                   \\\n  java/core/src/main/java/com/google/protobuf/RpcUtil.java                         \\\n  java/core/src/main/java/com/google/protobuf/Service.java                         \\\n  java/core/src/main/java/com/google/protobuf/ServiceException.java                \\\n  java/core/src/main/java/com/google/protobuf/SingleFieldBuilder.java              \\\n  java/core/src/main/java/com/google/protobuf/SingleFieldBuilderV3.java            \\\n  java/core/src/main/java/com/google/protobuf/SmallSortedMap.java                  \\\n  java/core/src/main/java/com/google/protobuf/TextFormat.java                      \\\n  java/core/src/main/java/com/google/protobuf/TextFormatEscaper.java               \\\n  java/core/src/main/java/com/google/protobuf/TextFormatParseInfoTree.java         \\\n  java/core/src/main/java/com/google/protobuf/TextFormatParseLocation.java         \\\n  java/core/src/main/java/com/google/protobuf/UninitializedMessageException.java   \\\n  java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java                 \\\n  java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java             \\\n  java/core/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java      \\\n  java/core/src/main/java/com/google/protobuf/UnsafeByteOperations.java            \\\n  java/core/src/main/java/com/google/protobuf/UnsafeUtil.java                      \\\n  java/core/src/main/java/com/google/protobuf/Utf8.java                            \\\n  java/core/src/main/java/com/google/protobuf/WireFormat.java                      \\\n  java/core/src/test/java/com/google/protobuf/AbstractMessageTest.java             \\\n  java/core/src/test/java/com/google/protobuf/AnyTest.java                         \\\n  java/core/src/test/java/com/google/protobuf/BooleanArrayListTest.java            \\\n  java/core/src/test/java/com/google/protobuf/BoundedByteStringTest.java           \\\n  java/core/src/test/java/com/google/protobuf/ByteBufferWriterTest.java            \\\n  java/core/src/test/java/com/google/protobuf/ByteStringTest.java                  \\\n  java/core/src/test/java/com/google/protobuf/CheckUtf8Test.java                   \\\n  java/core/src/test/java/com/google/protobuf/CodedInputStreamTest.java            \\\n  java/core/src/test/java/com/google/protobuf/CodedOutputStreamTest.java           \\\n  java/core/src/test/java/com/google/protobuf/DeprecatedFieldTest.java             \\\n  java/core/src/test/java/com/google/protobuf/DescriptorsTest.java                 \\\n  java/core/src/test/java/com/google/protobuf/DoubleArrayListTest.java             \\\n  java/core/src/test/java/com/google/protobuf/DynamicMessageTest.java              \\\n  java/core/src/test/java/com/google/protobuf/EnumTest.java                        \\\n  java/core/src/test/java/com/google/protobuf/ExtensionRegistryFactoryTest.java    \\\n  java/core/src/test/java/com/google/protobuf/FieldPresenceTest.java               \\\n  java/core/src/test/java/com/google/protobuf/FloatArrayListTest.java              \\\n  java/core/src/test/java/com/google/protobuf/ForceFieldBuildersPreRun.java        \\\n  java/core/src/test/java/com/google/protobuf/GeneratedMessageTest.java            \\\n  java/core/src/test/java/com/google/protobuf/IntArrayListTest.java                \\\n  java/core/src/test/java/com/google/protobuf/IsValidUtf8Test.java                 \\\n  java/core/src/test/java/com/google/protobuf/IsValidUtf8TestUtil.java             \\\n  java/core/src/test/java/com/google/protobuf/LazyFieldLiteTest.java               \\\n  java/core/src/test/java/com/google/protobuf/LazyFieldTest.java                   \\\n  java/core/src/test/java/com/google/protobuf/LazyMessageLiteTest.java             \\\n  java/core/src/test/java/com/google/protobuf/LazyStringArrayListTest.java         \\\n  java/core/src/test/java/com/google/protobuf/LazyStringEndToEndTest.java          \\\n  java/core/src/test/java/com/google/protobuf/LiteEqualsAndHashTest.java           \\\n  java/core/src/test/java/com/google/protobuf/LiteTest.java                        \\\n  java/core/src/test/java/com/google/protobuf/LiteralByteStringTest.java           \\\n  java/core/src/test/java/com/google/protobuf/LongArrayListTest.java               \\\n  java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java            \\\n  java/core/src/test/java/com/google/protobuf/MapForProto2Test.java                \\\n  java/core/src/test/java/com/google/protobuf/MapTest.java                         \\\n  java/core/src/test/java/com/google/protobuf/MessageTest.java                     \\\n  java/core/src/test/java/com/google/protobuf/NestedBuildersTest.java              \\\n  java/core/src/test/java/com/google/protobuf/NioByteStringTest.java               \\\n  java/core/src/test/java/com/google/protobuf/ParseExceptionsTest.java             \\\n  java/core/src/test/java/com/google/protobuf/ParserTest.java                      \\\n  java/core/src/test/java/com/google/protobuf/ProtobufArrayListTest.java           \\\n  java/core/src/test/java/com/google/protobuf/RepeatedFieldBuilderV3Test.java      \\\n  java/core/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java     \\\n  java/core/src/test/java/com/google/protobuf/RopeByteStringTest.java              \\\n  java/core/src/test/java/com/google/protobuf/ServiceTest.java                     \\\n  java/core/src/test/java/com/google/protobuf/SingleFieldBuilderV3Test.java        \\\n  java/core/src/test/java/com/google/protobuf/SmallSortedMapTest.java              \\\n  java/core/src/test/java/com/google/protobuf/TestBadIdentifiers.java              \\\n  java/core/src/test/java/com/google/protobuf/TestUtil.java                        \\\n  java/core/src/test/java/com/google/protobuf/TestUtilLite.java                    \\\n  java/core/src/test/java/com/google/protobuf/TextFormatParseInfoTreeTest.java     \\\n  java/core/src/test/java/com/google/protobuf/TextFormatParseLocationTest.java     \\\n  java/core/src/test/java/com/google/protobuf/TextFormatTest.java                  \\\n  java/core/src/test/java/com/google/protobuf/UnknownEnumValueTest.java            \\\n  java/core/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java         \\\n  java/core/src/test/java/com/google/protobuf/UnknownFieldSetTest.java             \\\n  java/core/src/test/java/com/google/protobuf/UnmodifiableLazyStringListTest.java  \\\n  java/core/src/test/java/com/google/protobuf/WellKnownTypesTest.java              \\\n  java/core/src/test/java/com/google/protobuf/WireFormatTest.java                  \\\n  java/core/src/test/proto/com/google/protobuf/any_test.proto                      \\\n  java/core/src/test/proto/com/google/protobuf/field_presence_test.proto           \\\n  java/core/src/test/proto/com/google/protobuf/lazy_fields_lite.proto              \\\n  java/core/src/test/proto/com/google/protobuf/lite_equals_and_hash.proto          \\\n  java/core/src/test/proto/com/google/protobuf/map_for_proto2_lite_test.proto      \\\n  java/core/src/test/proto/com/google/protobuf/map_for_proto2_test.proto           \\\n  java/core/src/test/proto/com/google/protobuf/map_initialization_order_test.proto \\\n  java/core/src/test/proto/com/google/protobuf/map_test.proto                      \\\n  java/core/src/test/proto/com/google/protobuf/multiple_files_test.proto           \\\n  java/core/src/test/proto/com/google/protobuf/nested_builders_test.proto          \\\n  java/core/src/test/proto/com/google/protobuf/nested_extension.proto              \\\n  java/core/src/test/proto/com/google/protobuf/nested_extension_lite.proto         \\\n  java/core/src/test/proto/com/google/protobuf/non_nested_extension.proto          \\\n  java/core/src/test/proto/com/google/protobuf/non_nested_extension_lite.proto     \\\n  java/core/src/test/proto/com/google/protobuf/outer_class_name_test.proto         \\\n  java/core/src/test/proto/com/google/protobuf/outer_class_name_test2.proto        \\\n  java/core/src/test/proto/com/google/protobuf/outer_class_name_test3.proto        \\\n  java/core/src/test/proto/com/google/protobuf/test_bad_identifiers.proto          \\\n  java/core/src/test/proto/com/google/protobuf/test_check_utf8.proto               \\\n  java/core/src/test/proto/com/google/protobuf/test_check_utf8_size.proto          \\\n  java/core/src/test/proto/com/google/protobuf/test_custom_options.proto           \\\n  java/core/src/test/proto/com/google/protobuf/test_extra_interfaces.proto         \\\n  java/lite/generate-sources-build.xml                                             \\\n  java/lite/generate-test-sources-build.xml                                        \\\n  java/lite/pom.xml                                                                \\\n  java/pom.xml                                                                     \\\n  java/util/pom.xml                                                                \\\n  java/util/src/main/java/com/google/protobuf/util/Durations.java                  \\\n  java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java              \\\n  java/util/src/main/java/com/google/protobuf/util/FieldMaskUtil.java              \\\n  java/util/src/main/java/com/google/protobuf/util/JsonFormat.java                 \\\n  java/util/src/main/java/com/google/protobuf/util/TimeUtil.java                   \\\n  java/util/src/main/java/com/google/protobuf/util/Timestamps.java                 \\\n  java/util/src/test/java/com/google/protobuf/util/FieldMaskTreeTest.java          \\\n  java/util/src/test/java/com/google/protobuf/util/FieldMaskUtilTest.java          \\\n  java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java             \\\n  java/util/src/test/java/com/google/protobuf/util/TimeUtilTest.java               \\\n  java/util/src/test/proto/com/google/protobuf/util/json_test.proto\n\njavanano_EXTRA_DIST=                                                                      \\\n  javanano/src/main/java/com/google/protobuf/nano/CodedOutputByteBufferNano.java          \\\n  javanano/src/main/java/com/google/protobuf/nano/FieldData.java                          \\\n  javanano/src/main/java/com/google/protobuf/nano/FieldArray.java                         \\\n  javanano/src/main/java/com/google/protobuf/nano/WireFormatNano.java                     \\\n  javanano/src/main/java/com/google/protobuf/nano/Extension.java                          \\\n  javanano/src/main/java/com/google/protobuf/nano/CodedInputByteBufferNano.java           \\\n  javanano/src/main/java/com/google/protobuf/nano/UnknownFieldData.java                   \\\n  javanano/src/main/java/com/google/protobuf/nano/MessageNano.java                        \\\n  javanano/src/main/java/com/google/protobuf/nano/InternalNano.java                       \\\n  javanano/src/main/java/com/google/protobuf/nano/InvalidProtocolBufferNanoException.java \\\n  javanano/src/main/java/com/google/protobuf/nano/MapFactories.java                       \\\n  javanano/src/main/java/com/google/protobuf/nano/ExtendableMessageNano.java              \\\n  javanano/src/main/java/com/google/protobuf/nano/MessageNanoPrinter.java                 \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_accessors_nano.proto           \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_enum_class_nano.proto          \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_reference_types_nano.proto     \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_extension_repeated_nano.proto  \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_has_nano.proto                 \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_nano.proto                     \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_multiple_nameclash_nano.proto  \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_single_nano.proto              \\\n  javanano/src/test/java/com/google/protobuf/nano/NanoTest.java                           \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_simple_nano.proto              \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_import_nano.proto              \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_repeated_merge_nano.proto      \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_extension_nano.proto           \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_repeated_packables_nano.proto  \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_extension_singular_nano.proto  \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_recursive_nano.proto           \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_extension_packed_nano.proto    \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_enum_validity_nano.proto       \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_stringutf8_nano.proto          \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_multiple_nano.proto            \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_enum_class_multiple_nano.proto \\\n  javanano/src/test/java/com/google/protobuf/nano/map_test.proto                          \\\n  javanano/README.md                                                                      \\\n  javanano/pom.xml\n\nobjectivec_EXTRA_DIST=                                                       \\\n  objectivec/DevTools/check_version_stamps.sh                                \\\n  objectivec/DevTools/compile_testing_protos.sh                              \\\n  objectivec/DevTools/full_mac_build.sh                                      \\\n  objectivec/DevTools/pddm.py                                                \\\n  objectivec/DevTools/pddm_tests.py                                          \\\n  objectivec/generate_well_known_types.sh                                    \\\n  objectivec/google/protobuf/Any.pbobjc.h                                    \\\n  objectivec/google/protobuf/Any.pbobjc.m                                    \\\n  objectivec/google/protobuf/Api.pbobjc.h                                    \\\n  objectivec/google/protobuf/Api.pbobjc.m                                    \\\n  objectivec/google/protobuf/Duration.pbobjc.h                               \\\n  objectivec/google/protobuf/Duration.pbobjc.m                               \\\n  objectivec/google/protobuf/Empty.pbobjc.h                                  \\\n  objectivec/google/protobuf/Empty.pbobjc.m                                  \\\n  objectivec/google/protobuf/FieldMask.pbobjc.h                              \\\n  objectivec/google/protobuf/FieldMask.pbobjc.m                              \\\n  objectivec/google/protobuf/SourceContext.pbobjc.h                          \\\n  objectivec/google/protobuf/SourceContext.pbobjc.m                          \\\n  objectivec/google/protobuf/Struct.pbobjc.h                                 \\\n  objectivec/google/protobuf/Struct.pbobjc.m                                 \\\n  objectivec/google/protobuf/Timestamp.pbobjc.h                              \\\n  objectivec/google/protobuf/Timestamp.pbobjc.m                              \\\n  objectivec/google/protobuf/Type.pbobjc.h                                   \\\n  objectivec/google/protobuf/Type.pbobjc.m                                   \\\n  objectivec/google/protobuf/Wrappers.pbobjc.h                               \\\n  objectivec/google/protobuf/Wrappers.pbobjc.m                               \\\n  objectivec/GPBArray.h                                                      \\\n  objectivec/GPBArray.m                                                      \\\n  objectivec/GPBArray_PackagePrivate.h                                       \\\n  objectivec/GPBBootstrap.h                                                  \\\n  objectivec/GPBCodedInputStream.h                                           \\\n  objectivec/GPBCodedInputStream.m                                           \\\n  objectivec/GPBCodedInputStream_PackagePrivate.h                            \\\n  objectivec/GPBCodedOutputStream.h                                          \\\n  objectivec/GPBCodedOutputStream.m                                          \\\n  objectivec/GPBCodedOutputStream_PackagePrivate.h                           \\\n  objectivec/GPBDescriptor.h                                                 \\\n  objectivec/GPBDescriptor.m                                                 \\\n  objectivec/GPBDescriptor_PackagePrivate.h                                  \\\n  objectivec/GPBDictionary.h                                                 \\\n  objectivec/GPBDictionary.m                                                 \\\n  objectivec/GPBDictionary_PackagePrivate.h                                  \\\n  objectivec/GPBExtensionInternals.h                                         \\\n  objectivec/GPBExtensionInternals.m                                         \\\n  objectivec/GPBExtensionRegistry.h                                          \\\n  objectivec/GPBExtensionRegistry.m                                          \\\n  objectivec/GPBMessage.h                                                    \\\n  objectivec/GPBMessage.m                                                    \\\n  objectivec/GPBMessage_PackagePrivate.h                                     \\\n  objectivec/GPBProtocolBuffers.h                                            \\\n  objectivec/GPBProtocolBuffers.m                                            \\\n  objectivec/GPBProtocolBuffers_RuntimeSupport.h                             \\\n  objectivec/GPBRootObject.h                                                 \\\n  objectivec/GPBRootObject.m                                                 \\\n  objectivec/GPBRootObject_PackagePrivate.h                                  \\\n  objectivec/GPBRuntimeTypes.h                                               \\\n  objectivec/GPBUnknownField.h                                               \\\n  objectivec/GPBUnknownField.m                                               \\\n  objectivec/GPBUnknownField_PackagePrivate.h                                \\\n  objectivec/GPBUnknownFieldSet.h                                            \\\n  objectivec/GPBUnknownFieldSet.m                                            \\\n  objectivec/GPBUnknownFieldSet_PackagePrivate.h                             \\\n  objectivec/GPBUtilities.h                                                  \\\n  objectivec/GPBUtilities.m                                                  \\\n  objectivec/GPBUtilities_PackagePrivate.h                                   \\\n  objectivec/GPBWellKnownTypes.h                                             \\\n  objectivec/GPBWellKnownTypes.m                                             \\\n  objectivec/GPBWireFormat.h                                                 \\\n  objectivec/GPBWireFormat.m                                                 \\\n  objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj                   \\\n  objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/contents.xcworkspacedata \\\n  objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings \\\n  objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme \\\n  objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme \\\n  objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj                   \\\n  objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/contents.xcworkspacedata \\\n  objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings \\\n  objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme \\\n  objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme \\\n  objectivec/README.md                                                       \\\n  objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.pbxproj \\\n  objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata \\\n  objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/OSXCocoaPodsTester.xcscheme \\\n  objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.h \\\n  objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.m \\\n  objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json \\\n  objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Base.lproj/MainMenu.xib \\\n  objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Info.plist \\\n  objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/main.m    \\\n  objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-framework            \\\n  objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-static               \\\n  objectivec/Tests/CocoaPods/README.md                                       \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-framework            \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-static               \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.pbxproj \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/iOSCocoaPodsTester.xcscheme \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.h \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.m \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/LaunchScreen.storyboard \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/Main.storyboard \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Info.plist \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.h \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.m \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/main.m    \\\n  objectivec/Tests/CocoaPods/run_tests.sh                                    \\\n  objectivec/Tests/golden_message                                            \\\n  objectivec/Tests/golden_packed_fields_message                              \\\n  objectivec/Tests/GPBARCUnittestProtos.m                                    \\\n  objectivec/Tests/GPBArrayTests.m                                           \\\n  objectivec/Tests/GPBCodedInputStreamTests.m                                \\\n  objectivec/Tests/GPBCodedOuputStreamTests.m                                \\\n  objectivec/Tests/GPBConcurrencyTests.m                                     \\\n  objectivec/Tests/GPBDescriptorTests.m                                      \\\n  objectivec/Tests/GPBDictionaryTests+Bool.m                                 \\\n  objectivec/Tests/GPBDictionaryTests+Int32.m                                \\\n  objectivec/Tests/GPBDictionaryTests+Int64.m                                \\\n  objectivec/Tests/GPBDictionaryTests+String.m                               \\\n  objectivec/Tests/GPBDictionaryTests+UInt32.m                               \\\n  objectivec/Tests/GPBDictionaryTests+UInt64.m                               \\\n  objectivec/Tests/GPBDictionaryTests.pddm                                   \\\n  objectivec/Tests/GPBMessageTests+Merge.m                                   \\\n  objectivec/Tests/GPBMessageTests+Runtime.m                                 \\\n  objectivec/Tests/GPBMessageTests+Serialization.m                           \\\n  objectivec/Tests/GPBMessageTests.m                                         \\\n  objectivec/Tests/GPBObjectiveCPlusPlusTest.mm                              \\\n  objectivec/Tests/GPBPerfTests.m                                            \\\n  objectivec/Tests/GPBSwiftTests.swift                                       \\\n  objectivec/Tests/GPBTestUtilities.h                                        \\\n  objectivec/Tests/GPBTestUtilities.m                                        \\\n  objectivec/Tests/GPBUnittestProtos.m                                       \\\n  objectivec/Tests/GPBUnknownFieldSetTest.m                                  \\\n  objectivec/Tests/GPBUtilitiesTests.m                                       \\\n  objectivec/Tests/GPBWellKnownTypesTest.m                                   \\\n  objectivec/Tests/GPBWireFormatTests.m                                      \\\n  objectivec/Tests/iOSTestHarness/AppDelegate.m                              \\\n  objectivec/Tests/iOSTestHarness/en.lproj/InfoPlist.strings                 \\\n  objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/Contents.json      \\\n  objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6.png          \\\n  objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6_2x.png       \\\n  objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7.png          \\\n  objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7_2x.png       \\\n  objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6.png        \\\n  objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6_2x.png     \\\n  objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_2x.png     \\\n  objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_3x.png     \\\n  objectivec/Tests/iOSTestHarness/Images.xcassets/LaunchImage.launchimage/Contents.json \\\n  objectivec/Tests/iOSTestHarness/Info.plist                                  \\\n  objectivec/Tests/iOSTestHarness/LaunchScreen.xib                            \\\n  objectivec/Tests/text_format_map_unittest_data.txt                          \\\n  objectivec/Tests/text_format_unittest_data.txt                              \\\n  objectivec/Tests/unittest_cycle.proto                                       \\\n  objectivec/Tests/unittest_objc.proto                                        \\\n  objectivec/Tests/unittest_objc_startup.proto                                \\\n  objectivec/Tests/unittest_runtime_proto2.proto                              \\\n  objectivec/Tests/unittest_runtime_proto3.proto                              \\\n  objectivec/Tests/UnitTests-Bridging-Header.h                                \\\n  objectivec/Tests/UnitTests-Info.plist                                       \\\n  Protobuf.podspec\n\npython_EXTRA_DIST=                                                           \\\n  python/MANIFEST.in                                                         \\\n  python/google/__init__.py                                                  \\\n  python/google/protobuf/__init__.py                                         \\\n  python/google/protobuf/descriptor.py                                       \\\n  python/google/protobuf/descriptor_database.py                              \\\n  python/google/protobuf/descriptor_pool.py                                  \\\n  python/google/protobuf/internal/__init__.py                                \\\n  python/google/protobuf/internal/_parameterized.py                          \\\n  python/google/protobuf/internal/any_test.proto                             \\\n  python/google/protobuf/internal/any_test.proto                             \\\n  python/google/protobuf/internal/api_implementation.cc                      \\\n  python/google/protobuf/internal/api_implementation.py                      \\\n  python/google/protobuf/internal/containers.py                              \\\n  python/google/protobuf/internal/decoder.py                                 \\\n  python/google/protobuf/internal/descriptor_database_test.py                \\\n  python/google/protobuf/internal/descriptor_pool_test.py                    \\\n  python/google/protobuf/internal/descriptor_pool_test1.proto                \\\n  python/google/protobuf/internal/descriptor_pool_test2.proto                \\\n  python/google/protobuf/internal/descriptor_test.py                         \\\n  python/google/protobuf/internal/encoder.py                                 \\\n  python/google/protobuf/internal/enum_type_wrapper.py                       \\\n  python/google/protobuf/internal/factory_test1.proto                        \\\n  python/google/protobuf/internal/factory_test2.proto                        \\\n  python/google/protobuf/internal/file_options_test.proto                    \\\n  python/google/protobuf/internal/generator_test.py                          \\\n  python/google/protobuf/internal/import_test_package/__init__.py            \\\n  python/google/protobuf/internal/import_test_package/inner.proto            \\\n  python/google/protobuf/internal/import_test_package/outer.proto            \\\n  python/google/protobuf/internal/json_format_test.py                        \\\n  python/google/protobuf/internal/message_factory_test.py                    \\\n  python/google/protobuf/internal/message_listener.py                        \\\n  python/google/protobuf/internal/message_set_extensions.proto               \\\n  python/google/protobuf/internal/message_test.py                            \\\n  python/google/protobuf/internal/missing_enum_values.proto                  \\\n  python/google/protobuf/internal/more_extensions.proto                      \\\n  python/google/protobuf/internal/more_extensions_dynamic.proto              \\\n  python/google/protobuf/internal/more_messages.proto                        \\\n  python/google/protobuf/internal/packed_field_test.proto                    \\\n  python/google/protobuf/internal/proto_builder_test.py                      \\\n  python/google/protobuf/internal/python_message.py                          \\\n  python/google/protobuf/internal/reflection_test.py                         \\\n  python/google/protobuf/internal/service_reflection_test.py                 \\\n  python/google/protobuf/internal/symbol_database_test.py                    \\\n  python/google/protobuf/internal/test_bad_identifiers.proto                 \\\n  python/google/protobuf/internal/test_util.py                               \\\n  python/google/protobuf/internal/text_encoding_test.py                      \\\n  python/google/protobuf/internal/text_format_test.py                        \\\n  python/google/protobuf/internal/type_checkers.py                           \\\n  python/google/protobuf/internal/unknown_fields_test.py                     \\\n  python/google/protobuf/internal/well_known_types.py                        \\\n  python/google/protobuf/internal/well_known_types.py                        \\\n  python/google/protobuf/internal/well_known_types_test.py                   \\\n  python/google/protobuf/internal/well_known_types_test.py                   \\\n  python/google/protobuf/internal/wire_format.py                             \\\n  python/google/protobuf/internal/wire_format_test.py                        \\\n  python/google/protobuf/json_format.py                                      \\\n  python/google/protobuf/message.py                                          \\\n  python/google/protobuf/message_factory.py                                  \\\n  python/google/protobuf/proto_builder.py                                    \\\n  python/google/protobuf/pyext/README                                        \\\n  python/google/protobuf/pyext/__init__.py                                   \\\n  python/google/protobuf/pyext/cpp_message.py                                \\\n  python/google/protobuf/pyext/descriptor.cc                                 \\\n  python/google/protobuf/pyext/descriptor.h                                  \\\n  python/google/protobuf/pyext/descriptor_containers.cc                      \\\n  python/google/protobuf/pyext/descriptor_containers.h                       \\\n  python/google/protobuf/pyext/descriptor_database.cc                        \\\n  python/google/protobuf/pyext/descriptor_database.h                         \\\n  python/google/protobuf/pyext/descriptor_pool.cc                            \\\n  python/google/protobuf/pyext/descriptor_pool.h                             \\\n  python/google/protobuf/pyext/extension_dict.cc                             \\\n  python/google/protobuf/pyext/extension_dict.h                              \\\n  python/google/protobuf/pyext/map_container.cc                              \\\n  python/google/protobuf/pyext/map_container.h                               \\\n  python/google/protobuf/pyext/message.cc                                    \\\n  python/google/protobuf/pyext/message.h                                     \\\n  python/google/protobuf/pyext/message_module.cc                             \\\n  python/google/protobuf/pyext/proto2_api_test.proto                         \\\n  python/google/protobuf/pyext/python.proto                                  \\\n  python/google/protobuf/pyext/python_protobuf.h                             \\\n  python/google/protobuf/pyext/repeated_composite_container.cc               \\\n  python/google/protobuf/pyext/repeated_composite_container.h                \\\n  python/google/protobuf/pyext/repeated_scalar_container.cc                  \\\n  python/google/protobuf/pyext/repeated_scalar_container.h                   \\\n  python/google/protobuf/pyext/scoped_pyobject_ptr.h                         \\\n  python/google/protobuf/reflection.py                                       \\\n  python/google/protobuf/service.py                                          \\\n  python/google/protobuf/service_reflection.py                               \\\n  python/google/protobuf/symbol_database.py                                  \\\n  python/google/protobuf/text_encoding.py                                    \\\n  python/google/protobuf/text_format.py                                      \\\n  python/mox.py                                                              \\\n  python/setup.py                                                            \\\n  python/stubout.py                                                          \\\n  python/tox.ini                                                             \\\n  python/README.md\n\nruby_EXTRA_DIST=                                                             \\\n  ruby/Gemfile                                                               \\\n  ruby/Gemfile.lock                                                          \\\n  ruby/.gitignore                                                            \\\n  ruby/README.md                                                             \\\n  ruby/Rakefile                                                              \\\n  ruby/ext/google/protobuf_c/defs.c                                          \\\n  ruby/ext/google/protobuf_c/encode_decode.c                                 \\\n  ruby/ext/google/protobuf_c/extconf.rb                                      \\\n  ruby/ext/google/protobuf_c/map.c                                           \\\n  ruby/ext/google/protobuf_c/message.c                                       \\\n  ruby/ext/google/protobuf_c/protobuf.c                                      \\\n  ruby/ext/google/protobuf_c/protobuf.h                                      \\\n  ruby/ext/google/protobuf_c/repeated_field.c                                \\\n  ruby/ext/google/protobuf_c/storage.c                                       \\\n  ruby/ext/google/protobuf_c/upb.c                                           \\\n  ruby/ext/google/protobuf_c/upb.h                                           \\\n  ruby/google-protobuf.gemspec                                               \\\n  ruby/lib/google/protobuf/message_exts.rb                                   \\\n  ruby/lib/google/protobuf/repeated_field.rb                                 \\\n  ruby/lib/google/protobuf.rb                                                \\\n  ruby/pom.xml                                                               \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyBuilder.java              \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyDescriptor.java           \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyDescriptorPool.java       \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyEnumBuilderContext.java   \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyEnumDescriptor.java       \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyEnum.java                 \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyFieldDescriptor.java      \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyMap.java                  \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyMessageBuilderContext.java \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.java              \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyOneofBuilderContext.java  \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyOneofDescriptor.java      \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyProtobuf.java             \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyRepeatedField.java        \\\n  ruby/src/main/java/com/google/protobuf/jruby/SentinelOuterClass.java       \\\n  ruby/src/main/java/com/google/protobuf/jruby/Utils.java                    \\\n  ruby/src/main/java/google/ProtobufJavaService.java                         \\\n  ruby/src/main/sentinel.proto                                               \\\n  ruby/tests/basic.rb                                                        \\\n  ruby/tests/repeated_field_test.rb                                          \\\n  ruby/tests/stress.rb                                                       \\\n  ruby/tests/generated_code.proto                                            \\\n  ruby/tests/test_import.proto                                               \\\n  ruby/tests/generated_code_test.rb                                          \\\n  ruby/travis-test.sh\n\njs_EXTRA_DIST=                              \\\n  js/README.md                              \\\n  js/binary/arith.js                        \\\n  js/binary/arith_test.js                   \\\n  js/binary/constants.js                    \\\n  js/binary/decoder.js                      \\\n  js/binary/decoder_test.js                 \\\n  js/binary/encoder.js                      \\\n  js/binary/proto_test.js                   \\\n  js/binary/reader.js                       \\\n  js/binary/reader_test.js                  \\\n  js/binary/utils.js                        \\\n  js/binary/utils_test.js                   \\\n  js/binary/writer.js                       \\\n  js/binary/writer_test.js                  \\\n  js/commonjs/export.js                     \\\n  js/commonjs/export_asserts.js             \\\n  js/commonjs/export_testdeps.js            \\\n  js/commonjs/import_test.js                \\\n  js/commonjs/jasmine.json                  \\\n  js/commonjs/rewrite_tests_for_commonjs.js \\\n  js/commonjs/test6/test6.proto             \\\n  js/commonjs/test7/test7.proto             \\\n  js/data.proto                             \\\n  js/debug.js                               \\\n  js/debug_test.js                          \\\n  js/gulpfile.js                            \\\n  js/jasmine.json                           \\\n  js/map.js                                 \\\n  js/message.js                             \\\n  js/message_test.js                        \\\n  js/node_loader.js                         \\\n  js/package.json                           \\\n  js/proto3_test.js                         \\\n  js/proto3_test.proto                      \\\n  js/test.proto                             \\\n  js/test2.proto                            \\\n  js/test3.proto                            \\\n  js/test4.proto                            \\\n  js/test5.proto                            \\\n  js/test_bootstrap.js                      \\\n  js/testbinary.proto                       \\\n  js/testempty.proto\n\nall_EXTRA_DIST=$(csharp_EXTRA_DIST) $(java_EXTRA_DIST) $(javanano_EXTRA_DIST) $(objectivec_EXTRA_DIST) $(python_EXTRA_DIST) $(ruby_EXTRA_DIST) $(js_EXTRA_DIST)\n\nEXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST)   \\\n  autogen.sh                             \\\n  generate_descriptor_proto.sh           \\\n  README.md                              \\\n  LICENSE                                \\\n  CONTRIBUTORS.txt                       \\\n  CHANGES.txt                            \\\n  update_file_lists.sh                   \\\n  BUILD                                  \\\n  gmock.BUILD                            \\\n  WORKSPACE                              \\\n  cmake/CMakeLists.txt                   \\\n  cmake/README.md                        \\\n  cmake/examples.cmake                   \\\n  cmake/extract_includes.bat.in          \\\n  cmake/install.cmake                    \\\n  cmake/libprotobuf.cmake                \\\n  cmake/libprotobuf-lite.cmake           \\\n  cmake/libprotoc.cmake                  \\\n  cmake/protobuf-config-version.cmake.in \\\n  cmake/protobuf-config.cmake.in         \\\n  cmake/protobuf-module.cmake.in         \\\n  cmake/protobuf-options.cmake           \\\n  cmake/protoc.cmake                     \\\n  cmake/tests.cmake                      \\\n  editors/README.txt                     \\\n  editors/proto.vim                      \\\n  editors/protobuf-mode.el               \\\n  examples/CMakeLists.txt                \\\n  examples/README.txt                    \\\n  examples/Makefile                      \\\n  examples/addressbook.proto             \\\n  examples/add_person.cc                 \\\n  examples/add_person.go                 \\\n  examples/add_person_test.go            \\\n  examples/list_people.cc                \\\n  examples/list_people.go                \\\n  examples/AddPerson.java                \\\n  examples/CMakeLists.txt                \\\n  examples/ListPeople.java               \\\n  examples/add_person.py                 \\\n  examples/list_people.py                \\\n  examples/list_people_test.go           \\\n  protobuf.bzl                           \\\n  six.BUILD                              \\\n  util/python/BUILD\n\n# Deletes all the files generated by autogen.sh.\nMAINTAINERCLEANFILES =   \\\n  aclocal.m4             \\\n  ar-lib                 \\\n  config.guess           \\\n  config.sub             \\\n  configure              \\\n  depcomp                \\\n  install-sh             \\\n  ltmain.sh              \\\n  Makefile.in            \\\n  missing                \\\n  mkinstalldirs          \\\n  config.h.in            \\\n  stamp.h.in             \\\n  m4/ltsugar.m4          \\\n  m4/libtool.m4          \\\n  m4/ltversion.m4        \\\n  m4/lt~obsolete.m4      \\\n  m4/ltoptions.m4\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/Makefile.in",
    "content": "# Makefile.in generated by automake 1.14.1 from Makefile.am.\n# @configure_input@\n\n# Copyright (C) 1994-2013 Free Software Foundation, Inc.\n\n# This Makefile.in is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY, to the extent permitted by law; without\n# even the implied warranty of MERCHANTABILITY or FITNESS FOR A\n# PARTICULAR PURPOSE.\n\n@SET_MAKE@\n\nVPATH = @srcdir@\nam__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'\nam__make_running_with_option = \\\n  case $${target_option-} in \\\n      ?) ;; \\\n      *) echo \"am__make_running_with_option: internal error: invalid\" \\\n              \"target option '$${target_option-}' specified\" >&2; \\\n         exit 1;; \\\n  esac; \\\n  has_opt=no; \\\n  sane_makeflags=$$MAKEFLAGS; \\\n  if $(am__is_gnu_make); then \\\n    sane_makeflags=$$MFLAGS; \\\n  else \\\n    case $$MAKEFLAGS in \\\n      *\\\\[\\ \\\t]*) \\\n        bs=\\\\; \\\n        sane_makeflags=`printf '%s\\n' \"$$MAKEFLAGS\" \\\n          | sed \"s/$$bs$$bs[$$bs $$bs\t]*//g\"`;; \\\n    esac; \\\n  fi; \\\n  skip_next=no; \\\n  strip_trailopt () \\\n  { \\\n    flg=`printf '%s\\n' \"$$flg\" | sed \"s/$$1.*$$//\"`; \\\n  }; \\\n  for flg in $$sane_makeflags; do \\\n    test $$skip_next = yes && { skip_next=no; continue; }; \\\n    case $$flg in \\\n      *=*|--*) continue;; \\\n        -*I) strip_trailopt 'I'; skip_next=yes;; \\\n      -*I?*) strip_trailopt 'I';; \\\n        -*O) strip_trailopt 'O'; skip_next=yes;; \\\n      -*O?*) strip_trailopt 'O';; \\\n        -*l) strip_trailopt 'l'; skip_next=yes;; \\\n      -*l?*) strip_trailopt 'l';; \\\n      -[dEDm]) skip_next=yes;; \\\n      -[JT]) skip_next=yes;; \\\n    esac; \\\n    case $$flg in \\\n      *$$target_option*) has_opt=yes; break;; \\\n    esac; \\\n  done; \\\n  test $$has_opt = yes\nam__make_dryrun = (target_option=n; $(am__make_running_with_option))\nam__make_keepgoing = (target_option=k; $(am__make_running_with_option))\npkgdatadir = $(datadir)/@PACKAGE@\npkgincludedir = $(includedir)/@PACKAGE@\npkglibdir = $(libdir)/@PACKAGE@\npkglibexecdir = $(libexecdir)/@PACKAGE@\nam__cd = CDPATH=\"$${ZSH_VERSION+.}$(PATH_SEPARATOR)\" && cd\ninstall_sh_DATA = $(install_sh) -c -m 644\ninstall_sh_PROGRAM = $(install_sh) -c\ninstall_sh_SCRIPT = $(install_sh) -c\nINSTALL_HEADER = $(INSTALL_DATA)\ntransform = $(program_transform_name)\nNORMAL_INSTALL = :\nPRE_INSTALL = :\nPOST_INSTALL = :\nNORMAL_UNINSTALL = :\nPRE_UNINSTALL = :\nPOST_UNINSTALL = :\nbuild_triplet = @build@\nhost_triplet = @host@\ntarget_triplet = @target@\nsubdir = .\nDIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \\\n\t$(top_srcdir)/configure $(am__configure_deps) \\\n\t$(srcdir)/config.h.in $(srcdir)/protobuf.pc.in \\\n\t$(srcdir)/protobuf-lite.pc.in ar-lib compile config.guess \\\n\tconfig.sub depcomp install-sh missing ltmain.sh\nACLOCAL_M4 = $(top_srcdir)/aclocal.m4\nam__aclocal_m4_deps = $(top_srcdir)/m4/ac_system_extensions.m4 \\\n\t$(top_srcdir)/m4/acx_check_suncc.m4 \\\n\t$(top_srcdir)/m4/acx_pthread.m4 $(top_srcdir)/m4/libtool.m4 \\\n\t$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \\\n\t$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \\\n\t$(top_srcdir)/m4/stl_hash.m4 $(top_srcdir)/configure.ac\nam__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \\\n\t$(ACLOCAL_M4)\nam__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \\\n configure.lineno config.status.lineno\nmkinstalldirs = $(install_sh) -d\nCONFIG_HEADER = config.h\nCONFIG_CLEAN_FILES = protobuf.pc protobuf-lite.pc\nCONFIG_CLEAN_VPATH_FILES =\nAM_V_P = $(am__v_P_@AM_V@)\nam__v_P_ = $(am__v_P_@AM_DEFAULT_V@)\nam__v_P_0 = false\nam__v_P_1 = :\nAM_V_GEN = $(am__v_GEN_@AM_V@)\nam__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)\nam__v_GEN_0 = @echo \"  GEN     \" $@;\nam__v_GEN_1 = \nAM_V_at = $(am__v_at_@AM_V@)\nam__v_at_ = $(am__v_at_@AM_DEFAULT_V@)\nam__v_at_0 = @\nam__v_at_1 = \nSOURCES =\nDIST_SOURCES =\nRECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \\\n\tctags-recursive dvi-recursive html-recursive info-recursive \\\n\tinstall-data-recursive install-dvi-recursive \\\n\tinstall-exec-recursive install-html-recursive \\\n\tinstall-info-recursive install-pdf-recursive \\\n\tinstall-ps-recursive install-recursive installcheck-recursive \\\n\tinstalldirs-recursive pdf-recursive ps-recursive \\\n\ttags-recursive uninstall-recursive\nam__can_run_installinfo = \\\n  case $$AM_UPDATE_INFO_DIR in \\\n    n|no|NO) false;; \\\n    *) (install-info --version) >/dev/null 2>&1;; \\\n  esac\nam__vpath_adj_setup = srcdirstrip=`echo \"$(srcdir)\" | sed 's|.|.|g'`;\nam__vpath_adj = case $$p in \\\n    $(srcdir)/*) f=`echo \"$$p\" | sed \"s|^$$srcdirstrip/||\"`;; \\\n    *) f=$$p;; \\\n  esac;\nam__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;\nam__install_max = 40\nam__nobase_strip_setup = \\\n  srcdirstrip=`echo \"$(srcdir)\" | sed 's/[].[^$$\\\\*|]/\\\\\\\\&/g'`\nam__nobase_strip = \\\n  for p in $$list; do echo \"$$p\"; done | sed -e \"s|$$srcdirstrip/||\"\nam__nobase_list = $(am__nobase_strip_setup); \\\n  for p in $$list; do echo \"$$p $$p\"; done | \\\n  sed \"s| $$srcdirstrip/| |;\"' / .*\\//!s/ .*/ ./; s,\\( .*\\)/[^/]*$$,\\1,' | \\\n  $(AWK) 'BEGIN { files[\".\"] = \"\" } { files[$$2] = files[$$2] \" \" $$1; \\\n    if (++n[$$2] == $(am__install_max)) \\\n      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = \"\" } } \\\n    END { for (dir in files) print dir, files[dir] }'\nam__base_list = \\\n  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\\n/ /g' | \\\n  sed '$$!N;$$!N;$$!N;$$!N;s/\\n/ /g'\nam__uninstall_files_from_dir = { \\\n  test -z \"$$files\" \\\n    || { test ! -d \"$$dir\" && test ! -f \"$$dir\" && test ! -r \"$$dir\"; } \\\n    || { echo \" ( cd '$$dir' && rm -f\" $$files \")\"; \\\n         $(am__cd) \"$$dir\" && rm -f $$files; }; \\\n  }\nam__installdirs = \"$(DESTDIR)$(pkgconfigdir)\"\nDATA = $(pkgconfig_DATA)\nRECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive\t\\\n  distclean-recursive maintainer-clean-recursive\nam__recursive_targets = \\\n  $(RECURSIVE_TARGETS) \\\n  $(RECURSIVE_CLEAN_TARGETS) \\\n  $(am__extra_recursive_targets)\nAM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \\\n\tcscope distdir dist dist-all distcheck\nam__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \\\n\t$(LISP)config.h.in\n# Read a list of newline-separated strings from the standard input,\n# and print each of them once, without duplicates.  Input order is\n# *not* preserved.\nam__uniquify_input = $(AWK) '\\\n  BEGIN { nonempty = 0; } \\\n  { items[$$0] = 1; nonempty = 1; } \\\n  END { if (nonempty) { for (i in items) print i; }; } \\\n'\n# Make sure the list of sources is unique.  This is necessary because,\n# e.g., the same source file might be shared among _SOURCES variables\n# for different programs/libraries.\nam__define_uniq_tagged_files = \\\n  list='$(am__tagged_files)'; \\\n  unique=`for i in $$list; do \\\n    if test -f \"$$i\"; then echo $$i; else echo $(srcdir)/$$i; fi; \\\n  done | $(am__uniquify_input)`\nETAGS = etags\nCTAGS = ctags\nCSCOPE = cscope\nDISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)\ndistdir = $(PACKAGE)-$(VERSION)\ntop_distdir = $(distdir)\nam__remove_distdir = \\\n  if test -d \"$(distdir)\"; then \\\n    find \"$(distdir)\" -type d ! -perm -200 -exec chmod u+w {} ';' \\\n      && rm -rf \"$(distdir)\" \\\n      || { sleep 5 && rm -rf \"$(distdir)\"; }; \\\n  else :; fi\nam__post_remove_distdir = $(am__remove_distdir)\nam__relativize = \\\n  dir0=`pwd`; \\\n  sed_first='s,^\\([^/]*\\)/.*$$,\\1,'; \\\n  sed_rest='s,^[^/]*/*,,'; \\\n  sed_last='s,^.*/\\([^/]*\\)$$,\\1,'; \\\n  sed_butlast='s,/*[^/]*$$,,'; \\\n  while test -n \"$$dir1\"; do \\\n    first=`echo \"$$dir1\" | sed -e \"$$sed_first\"`; \\\n    if test \"$$first\" != \".\"; then \\\n      if test \"$$first\" = \"..\"; then \\\n        dir2=`echo \"$$dir0\" | sed -e \"$$sed_last\"`/\"$$dir2\"; \\\n        dir0=`echo \"$$dir0\" | sed -e \"$$sed_butlast\"`; \\\n      else \\\n        first2=`echo \"$$dir2\" | sed -e \"$$sed_first\"`; \\\n        if test \"$$first2\" = \"$$first\"; then \\\n          dir2=`echo \"$$dir2\" | sed -e \"$$sed_rest\"`; \\\n        else \\\n          dir2=\"../$$dir2\"; \\\n        fi; \\\n        dir0=\"$$dir0\"/\"$$first\"; \\\n      fi; \\\n    fi; \\\n    dir1=`echo \"$$dir1\" | sed -e \"$$sed_rest\"`; \\\n  done; \\\n  reldir=\"$$dir2\"\nDIST_ARCHIVES = $(distdir).tar.gz\nGZIP_ENV = --best\nDIST_TARGETS = dist-gzip\ndistuninstallcheck_listfiles = find . -type f -print\nam__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \\\n  | sed 's|^\\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'\ndistcleancheck_listfiles = find . -type f -print\nACLOCAL = @ACLOCAL@\nAMTAR = @AMTAR@\nAM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@\nAR = @AR@\nAUTOCONF = @AUTOCONF@\nAUTOHEADER = @AUTOHEADER@\nAUTOMAKE = @AUTOMAKE@\nAWK = @AWK@\nCC = @CC@\nCCDEPMODE = @CCDEPMODE@\nCFLAGS = @CFLAGS@\nCPPFLAGS = @CPPFLAGS@\nCXX = @CXX@\nCXXCPP = @CXXCPP@\nCXXDEPMODE = @CXXDEPMODE@\nCXXFLAGS = @CXXFLAGS@\nCYGPATH_W = @CYGPATH_W@\nDEFS = @DEFS@\nDEPDIR = @DEPDIR@\nDIST_LANG = @DIST_LANG@\nDLLTOOL = @DLLTOOL@\nDSYMUTIL = @DSYMUTIL@\nDUMPBIN = @DUMPBIN@\nECHO_C = @ECHO_C@\nECHO_N = @ECHO_N@\nECHO_T = @ECHO_T@\nEGREP = @EGREP@\nEXEEXT = @EXEEXT@\nFGREP = @FGREP@\nGREP = @GREP@\nINSTALL = @INSTALL@\nINSTALL_DATA = @INSTALL_DATA@\nINSTALL_PROGRAM = @INSTALL_PROGRAM@\nINSTALL_SCRIPT = @INSTALL_SCRIPT@\nINSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@\nISAINFO = @ISAINFO@\nLD = @LD@\nLDFLAGS = @LDFLAGS@\nLIBOBJS = @LIBOBJS@\nLIBS = @LIBS@\nLIBTOOL = @LIBTOOL@\nLIPO = @LIPO@\nLN_S = @LN_S@\nLTLIBOBJS = @LTLIBOBJS@\nMAINT = @MAINT@\nMAKEINFO = @MAKEINFO@\nMANIFEST_TOOL = @MANIFEST_TOOL@\nMKDIR_P = @MKDIR_P@\nNM = @NM@\nNMEDIT = @NMEDIT@\nOBJC = @OBJC@\nOBJCDEPMODE = @OBJCDEPMODE@\nOBJCFLAGS = @OBJCFLAGS@\nOBJDUMP = @OBJDUMP@\nOBJEXT = @OBJEXT@\nOTOOL = @OTOOL@\nOTOOL64 = @OTOOL64@\nPACKAGE = @PACKAGE@\nPACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@\nPACKAGE_NAME = @PACKAGE_NAME@\nPACKAGE_STRING = @PACKAGE_STRING@\nPACKAGE_TARNAME = @PACKAGE_TARNAME@\nPACKAGE_URL = @PACKAGE_URL@\nPACKAGE_VERSION = @PACKAGE_VERSION@\nPATH_SEPARATOR = @PATH_SEPARATOR@\nPOW_LIB = @POW_LIB@\nPROTOBUF_OPT_FLAG = @PROTOBUF_OPT_FLAG@\nPROTOC = @PROTOC@\nPTHREAD_CC = @PTHREAD_CC@\nPTHREAD_CFLAGS = @PTHREAD_CFLAGS@\nPTHREAD_LIBS = @PTHREAD_LIBS@\nRANLIB = @RANLIB@\nSED = @SED@\nSET_MAKE = @SET_MAKE@\nSHELL = @SHELL@\nSTRIP = @STRIP@\nVERSION = @VERSION@\nabs_builddir = @abs_builddir@\nabs_srcdir = @abs_srcdir@\nabs_top_builddir = @abs_top_builddir@\nabs_top_srcdir = @abs_top_srcdir@\nac_ct_AR = @ac_ct_AR@\nac_ct_CC = @ac_ct_CC@\nac_ct_CXX = @ac_ct_CXX@\nac_ct_DUMPBIN = @ac_ct_DUMPBIN@\nac_ct_OBJC = @ac_ct_OBJC@\nacx_pthread_config = @acx_pthread_config@\nam__include = @am__include@\nam__leading_dot = @am__leading_dot@\nam__quote = @am__quote@\nam__tar = @am__tar@\nam__untar = @am__untar@\nbindir = @bindir@\nbuild = @build@\nbuild_alias = @build_alias@\nbuild_cpu = @build_cpu@\nbuild_os = @build_os@\nbuild_vendor = @build_vendor@\nbuilddir = @builddir@\ndatadir = @datadir@\ndatarootdir = @datarootdir@\ndocdir = @docdir@\ndvidir = @dvidir@\nexec_prefix = @exec_prefix@\nhost = @host@\nhost_alias = @host_alias@\nhost_cpu = @host_cpu@\nhost_os = @host_os@\nhost_vendor = @host_vendor@\nhtmldir = @htmldir@\nincludedir = @includedir@\ninfodir = @infodir@\ninstall_sh = @install_sh@\nlibdir = @libdir@\nlibexecdir = @libexecdir@\nlocaledir = @localedir@\nlocalstatedir = @localstatedir@\nmandir = @mandir@\nmkdir_p = @mkdir_p@\noldincludedir = @oldincludedir@\npdfdir = @pdfdir@\nprefix = @prefix@\nprogram_transform_name = @program_transform_name@\npsdir = @psdir@\nsbindir = @sbindir@\nsharedstatedir = @sharedstatedir@\nsrcdir = @srcdir@\nsubdirs = @subdirs@\nsysconfdir = @sysconfdir@\ntarget = @target@\ntarget_alias = @target_alias@\ntarget_cpu = @target_cpu@\ntarget_os = @target_os@\ntarget_vendor = @target_vendor@\ntop_build_prefix = @top_build_prefix@\ntop_builddir = @top_builddir@\ntop_srcdir = @top_srcdir@\nACLOCAL_AMFLAGS = -I m4\nAUTOMAKE_OPTIONS = foreign\n\n# Build . before src so that our all-local and clean-local hooks kicks in at\n# the right time.\nSUBDIRS = . src\n\n# Always include gmock in distributions.\nDIST_SUBDIRS = $(subdirs) src conformance benchmarks\npkgconfigdir = $(libdir)/pkgconfig\npkgconfig_DATA = protobuf.pc protobuf-lite.pc\ncsharp_EXTRA_DIST = \\\n  csharp/.gitignore                                                          \\\n  csharp/CHANGES.txt                                                         \\\n  csharp/Google.Protobuf.Tools.nuspec                                        \\\n  csharp/README.md                                                           \\\n  csharp/build_packages.bat                                                  \\\n  csharp/buildall.sh                                                         \\\n  csharp/generate_protos.sh                                                  \\\n  csharp/keys/Google.Protobuf.public.snk                                     \\\n  csharp/keys/Google.Protobuf.snk                                            \\\n  csharp/keys/README.md                                                      \\\n  csharp/protos/unittest_issues.proto                                        \\\n  csharp/src/AddressBook/AddPerson.cs                                        \\\n  csharp/src/AddressBook/Addressbook.cs                                      \\\n  csharp/src/AddressBook/AddressBook.xproj                                   \\\n  csharp/src/AddressBook/ListPeople.cs                                       \\\n  csharp/src/AddressBook/Program.cs                                          \\\n  csharp/src/AddressBook/SampleUsage.cs                                      \\\n  csharp/src/AddressBook/project.json                                        \\\n  csharp/src/Google.Protobuf.Conformance/Conformance.cs                      \\\n  csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.xproj   \\\n  csharp/src/Google.Protobuf.Conformance/Program.cs                          \\\n  csharp/src/Google.Protobuf.Conformance/project.json                        \\\n  csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.xproj         \\\n  csharp/src/Google.Protobuf.JsonDump/Program.cs                             \\\n  csharp/src/Google.Protobuf.JsonDump/project.json                           \\\n  csharp/src/Google.Protobuf.Test/ByteStringTest.cs                          \\\n  csharp/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs              \\\n  csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs                    \\\n  csharp/src/Google.Protobuf.Test/CodedOutputStreamTest.cs                   \\\n  csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs                \\\n  csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs           \\\n  csharp/src/Google.Protobuf.Test/Compatibility/PropertyInfoExtensionsTest.cs \\\n  csharp/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs        \\\n  csharp/src/Google.Protobuf.Test/DeprecatedMemberTest.cs                    \\\n  csharp/src/Google.Protobuf.Test/EqualityTester.cs                          \\\n  csharp/src/Google.Protobuf.Test/FieldCodecTest.cs                          \\\n  csharp/src/Google.Protobuf.Test/GeneratedMessageTest.cs                    \\\n  csharp/src/Google.Protobuf.Test/Google.Protobuf.Test.xproj                 \\\n  csharp/src/Google.Protobuf.Test/IssuesTest.cs                              \\\n  csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs                       \\\n  csharp/src/Google.Protobuf.Test/JsonParserTest.cs                          \\\n  csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs                       \\\n  csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs              \\\n  csharp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs              \\\n  csharp/src/Google.Protobuf.Test/Reflection/TypeRegistryTest.cs             \\\n  csharp/src/Google.Protobuf.Test/SampleEnum.cs                              \\\n  csharp/src/Google.Protobuf.Test/SampleMessages.cs                          \\\n  csharp/src/Google.Protobuf.Test/TestCornerCases.cs                         \\\n  csharp/src/Google.Protobuf.Test/TestProtos/ForeignMessagePartial.cs        \\\n  csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs            \\\n  csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs         \\\n  csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs   \\\n  csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs               \\\n  csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs               \\\n  csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs       \\\n  csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs                  \\\n  csharp/src/Google.Protobuf.Test/WellKnownTypes/DurationTest.cs             \\\n  csharp/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs            \\\n  csharp/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs            \\\n  csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs             \\\n  csharp/src/Google.Protobuf.Test/project.json                               \\\n  csharp/src/Google.Protobuf.sln                                             \\\n  csharp/src/Google.Protobuf/ByteArray.cs                                    \\\n  csharp/src/Google.Protobuf/ByteString.cs                                   \\\n  csharp/src/Google.Protobuf/CodedInputStream.cs                             \\\n  csharp/src/Google.Protobuf/CodedOutputStream.ComputeSize.cs                \\\n  csharp/src/Google.Protobuf/CodedOutputStream.cs                            \\\n  csharp/src/Google.Protobuf/Collections/MapField.cs                         \\\n  csharp/src/Google.Protobuf/Collections/ReadOnlyDictionary.cs               \\\n  csharp/src/Google.Protobuf/Collections/RepeatedField.cs                    \\\n  csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs         \\\n  csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs                 \\\n  csharp/src/Google.Protobuf/FieldCodec.cs                                   \\\n  csharp/src/Google.Protobuf/FrameworkPortability.cs                         \\\n  csharp/src/Google.Protobuf/Google.Protobuf.xproj                           \\\n  csharp/src/Google.Protobuf/ICustomDiagnosticMessage.cs                     \\\n  csharp/src/Google.Protobuf/IDeepCloneable.cs                               \\\n  csharp/src/Google.Protobuf/IMessage.cs                                     \\\n  csharp/src/Google.Protobuf/InvalidJsonException.cs                         \\\n  csharp/src/Google.Protobuf/InvalidProtocolBufferException.cs               \\\n  csharp/src/Google.Protobuf/JsonFormatter.cs                                \\\n  csharp/src/Google.Protobuf/JsonParser.cs                                   \\\n  csharp/src/Google.Protobuf/JsonToken.cs                                    \\\n  csharp/src/Google.Protobuf/JsonTokenizer.cs                                \\\n  csharp/src/Google.Protobuf/LimitedInputStream.cs                           \\\n  csharp/src/Google.Protobuf/MessageExtensions.cs                            \\\n  csharp/src/Google.Protobuf/MessageParser.cs                                \\\n  csharp/src/Google.Protobuf/ProtoPreconditions.cs                           \\\n  csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs                      \\\n  csharp/src/Google.Protobuf/Reflection/Descriptor.cs                        \\\n  csharp/src/Google.Protobuf/Reflection/DescriptorBase.cs                    \\\n  csharp/src/Google.Protobuf/Reflection/DescriptorPool.cs                    \\\n  csharp/src/Google.Protobuf/Reflection/DescriptorUtil.cs                    \\\n  csharp/src/Google.Protobuf/Reflection/DescriptorValidationException.cs     \\\n  csharp/src/Google.Protobuf/Reflection/EnumDescriptor.cs                    \\\n  csharp/src/Google.Protobuf/Reflection/EnumValueDescriptor.cs               \\\n  csharp/src/Google.Protobuf/Reflection/FieldAccessorBase.cs                 \\\n  csharp/src/Google.Protobuf/Reflection/FieldDescriptor.cs                   \\\n  csharp/src/Google.Protobuf/Reflection/FieldType.cs                         \\\n  csharp/src/Google.Protobuf/Reflection/FileDescriptor.cs                    \\\n  csharp/src/Google.Protobuf/Reflection/GeneratedClrTypeInfo.cs              \\\n  csharp/src/Google.Protobuf/Reflection/IDescriptor.cs                       \\\n  csharp/src/Google.Protobuf/Reflection/IFieldAccessor.cs                    \\\n  csharp/src/Google.Protobuf/Reflection/MapFieldAccessor.cs                  \\\n  csharp/src/Google.Protobuf/Reflection/MessageDescriptor.cs                 \\\n  csharp/src/Google.Protobuf/Reflection/MethodDescriptor.cs                  \\\n  csharp/src/Google.Protobuf/Reflection/OneofAccessor.cs                     \\\n  csharp/src/Google.Protobuf/Reflection/OneofDescriptor.cs                   \\\n  csharp/src/Google.Protobuf/Reflection/OriginalNameAttribute.cs             \\\n  csharp/src/Google.Protobuf/Reflection/PackageDescriptor.cs                 \\\n  csharp/src/Google.Protobuf/Reflection/PartialClasses.cs                    \\\n  csharp/src/Google.Protobuf/Reflection/ReflectionUtil.cs                    \\\n  csharp/src/Google.Protobuf/Reflection/RepeatedFieldAccessor.cs             \\\n  csharp/src/Google.Protobuf/Reflection/ServiceDescriptor.cs                 \\\n  csharp/src/Google.Protobuf/Reflection/SingleFieldAccessor.cs               \\\n  csharp/src/Google.Protobuf/Reflection/TypeRegistry.cs                      \\\n  csharp/src/Google.Protobuf/WellKnownTypes/Any.cs                           \\\n  csharp/src/Google.Protobuf/WellKnownTypes/AnyPartial.cs                    \\\n  csharp/src/Google.Protobuf/WellKnownTypes/Api.cs                           \\\n  csharp/src/Google.Protobuf/WellKnownTypes/Duration.cs                      \\\n  csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs               \\\n  csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs                         \\\n  csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs                     \\\n  csharp/src/Google.Protobuf/WellKnownTypes/FieldMaskPartial.cs              \\\n  csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs                 \\\n  csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs                        \\\n  csharp/src/Google.Protobuf/WellKnownTypes/TimeExtensions.cs                \\\n  csharp/src/Google.Protobuf/WellKnownTypes/Timestamp.cs                     \\\n  csharp/src/Google.Protobuf/WellKnownTypes/TimestampPartial.cs              \\\n  csharp/src/Google.Protobuf/WellKnownTypes/Type.cs                          \\\n  csharp/src/Google.Protobuf/WellKnownTypes/ValuePartial.cs                  \\\n  csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs                      \\\n  csharp/src/Google.Protobuf/WellKnownTypes/WrappersPartial.cs               \\\n  csharp/src/Google.Protobuf/WireFormat.cs                                   \\\n  csharp/src/Google.Protobuf/project.json                                    \\\n  csharp/src/packages/repositories.config\n\njava_EXTRA_DIST = \\\n  java/README.md                                                                   \\\n  java/core/generate-sources-build.xml                                             \\\n  java/core/generate-test-sources-build.xml                                        \\\n  java/core/pom.xml                                                                \\\n  java/core/src/main/java/com/google/protobuf/AbstractMessage.java                 \\\n  java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java             \\\n  java/core/src/main/java/com/google/protobuf/AbstractParser.java                  \\\n  java/core/src/main/java/com/google/protobuf/AbstractProtobufList.java            \\\n  java/core/src/main/java/com/google/protobuf/BlockingRpcChannel.java              \\\n  java/core/src/main/java/com/google/protobuf/BlockingService.java                 \\\n  java/core/src/main/java/com/google/protobuf/BooleanArrayList.java                \\\n  java/core/src/main/java/com/google/protobuf/ByteBufferWriter.java                \\\n  java/core/src/main/java/com/google/protobuf/ByteOutput.java                      \\\n  java/core/src/main/java/com/google/protobuf/ByteString.java                      \\\n  java/core/src/main/java/com/google/protobuf/CodedInputStream.java                \\\n  java/core/src/main/java/com/google/protobuf/CodedOutputStream.java               \\\n  java/core/src/main/java/com/google/protobuf/Descriptors.java                     \\\n  java/core/src/main/java/com/google/protobuf/DoubleArrayList.java                 \\\n  java/core/src/main/java/com/google/protobuf/DynamicMessage.java                  \\\n  java/core/src/main/java/com/google/protobuf/ExperimentalApi.java                 \\\n  java/core/src/main/java/com/google/protobuf/Extension.java                       \\\n  java/core/src/main/java/com/google/protobuf/ExtensionLite.java                   \\\n  java/core/src/main/java/com/google/protobuf/ExtensionRegistry.java               \\\n  java/core/src/main/java/com/google/protobuf/ExtensionRegistryFactory.java        \\\n  java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java           \\\n  java/core/src/main/java/com/google/protobuf/FieldSet.java                        \\\n  java/core/src/main/java/com/google/protobuf/FloatArrayList.java                  \\\n  java/core/src/main/java/com/google/protobuf/GeneratedMessage.java                \\\n  java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java            \\\n  java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java              \\\n  java/core/src/main/java/com/google/protobuf/IntArrayList.java                    \\\n  java/core/src/main/java/com/google/protobuf/Internal.java                        \\\n  java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java  \\\n  java/core/src/main/java/com/google/protobuf/LazyField.java                       \\\n  java/core/src/main/java/com/google/protobuf/LazyFieldLite.java                   \\\n  java/core/src/main/java/com/google/protobuf/LazyStringArrayList.java             \\\n  java/core/src/main/java/com/google/protobuf/LazyStringList.java                  \\\n  java/core/src/main/java/com/google/protobuf/LongArrayList.java                   \\\n  java/core/src/main/java/com/google/protobuf/MapEntry.java                        \\\n  java/core/src/main/java/com/google/protobuf/MapEntryLite.java                    \\\n  java/core/src/main/java/com/google/protobuf/MapField.java                        \\\n  java/core/src/main/java/com/google/protobuf/MapFieldLite.java                    \\\n  java/core/src/main/java/com/google/protobuf/Message.java                         \\\n  java/core/src/main/java/com/google/protobuf/MessageLite.java                     \\\n  java/core/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java            \\\n  java/core/src/main/java/com/google/protobuf/MessageLiteToString.java             \\\n  java/core/src/main/java/com/google/protobuf/MessageOrBuilder.java                \\\n  java/core/src/main/java/com/google/protobuf/MessageReflection.java               \\\n  java/core/src/main/java/com/google/protobuf/MutabilityOracle.java                \\\n  java/core/src/main/java/com/google/protobuf/NioByteString.java                   \\\n  java/core/src/main/java/com/google/protobuf/Parser.java                          \\\n  java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java               \\\n  java/core/src/main/java/com/google/protobuf/ProtocolMessageEnum.java             \\\n  java/core/src/main/java/com/google/protobuf/ProtocolStringList.java              \\\n  java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java            \\\n  java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilderV3.java          \\\n  java/core/src/main/java/com/google/protobuf/RopeByteString.java                  \\\n  java/core/src/main/java/com/google/protobuf/RpcCallback.java                     \\\n  java/core/src/main/java/com/google/protobuf/RpcChannel.java                      \\\n  java/core/src/main/java/com/google/protobuf/RpcController.java                   \\\n  java/core/src/main/java/com/google/protobuf/RpcUtil.java                         \\\n  java/core/src/main/java/com/google/protobuf/Service.java                         \\\n  java/core/src/main/java/com/google/protobuf/ServiceException.java                \\\n  java/core/src/main/java/com/google/protobuf/SingleFieldBuilder.java              \\\n  java/core/src/main/java/com/google/protobuf/SingleFieldBuilderV3.java            \\\n  java/core/src/main/java/com/google/protobuf/SmallSortedMap.java                  \\\n  java/core/src/main/java/com/google/protobuf/TextFormat.java                      \\\n  java/core/src/main/java/com/google/protobuf/TextFormatEscaper.java               \\\n  java/core/src/main/java/com/google/protobuf/TextFormatParseInfoTree.java         \\\n  java/core/src/main/java/com/google/protobuf/TextFormatParseLocation.java         \\\n  java/core/src/main/java/com/google/protobuf/UninitializedMessageException.java   \\\n  java/core/src/main/java/com/google/protobuf/UnknownFieldSet.java                 \\\n  java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java             \\\n  java/core/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java      \\\n  java/core/src/main/java/com/google/protobuf/UnsafeByteOperations.java            \\\n  java/core/src/main/java/com/google/protobuf/UnsafeUtil.java                      \\\n  java/core/src/main/java/com/google/protobuf/Utf8.java                            \\\n  java/core/src/main/java/com/google/protobuf/WireFormat.java                      \\\n  java/core/src/test/java/com/google/protobuf/AbstractMessageTest.java             \\\n  java/core/src/test/java/com/google/protobuf/AnyTest.java                         \\\n  java/core/src/test/java/com/google/protobuf/BooleanArrayListTest.java            \\\n  java/core/src/test/java/com/google/protobuf/BoundedByteStringTest.java           \\\n  java/core/src/test/java/com/google/protobuf/ByteBufferWriterTest.java            \\\n  java/core/src/test/java/com/google/protobuf/ByteStringTest.java                  \\\n  java/core/src/test/java/com/google/protobuf/CheckUtf8Test.java                   \\\n  java/core/src/test/java/com/google/protobuf/CodedInputStreamTest.java            \\\n  java/core/src/test/java/com/google/protobuf/CodedOutputStreamTest.java           \\\n  java/core/src/test/java/com/google/protobuf/DeprecatedFieldTest.java             \\\n  java/core/src/test/java/com/google/protobuf/DescriptorsTest.java                 \\\n  java/core/src/test/java/com/google/protobuf/DoubleArrayListTest.java             \\\n  java/core/src/test/java/com/google/protobuf/DynamicMessageTest.java              \\\n  java/core/src/test/java/com/google/protobuf/EnumTest.java                        \\\n  java/core/src/test/java/com/google/protobuf/ExtensionRegistryFactoryTest.java    \\\n  java/core/src/test/java/com/google/protobuf/FieldPresenceTest.java               \\\n  java/core/src/test/java/com/google/protobuf/FloatArrayListTest.java              \\\n  java/core/src/test/java/com/google/protobuf/ForceFieldBuildersPreRun.java        \\\n  java/core/src/test/java/com/google/protobuf/GeneratedMessageTest.java            \\\n  java/core/src/test/java/com/google/protobuf/IntArrayListTest.java                \\\n  java/core/src/test/java/com/google/protobuf/IsValidUtf8Test.java                 \\\n  java/core/src/test/java/com/google/protobuf/IsValidUtf8TestUtil.java             \\\n  java/core/src/test/java/com/google/protobuf/LazyFieldLiteTest.java               \\\n  java/core/src/test/java/com/google/protobuf/LazyFieldTest.java                   \\\n  java/core/src/test/java/com/google/protobuf/LazyMessageLiteTest.java             \\\n  java/core/src/test/java/com/google/protobuf/LazyStringArrayListTest.java         \\\n  java/core/src/test/java/com/google/protobuf/LazyStringEndToEndTest.java          \\\n  java/core/src/test/java/com/google/protobuf/LiteEqualsAndHashTest.java           \\\n  java/core/src/test/java/com/google/protobuf/LiteTest.java                        \\\n  java/core/src/test/java/com/google/protobuf/LiteralByteStringTest.java           \\\n  java/core/src/test/java/com/google/protobuf/LongArrayListTest.java               \\\n  java/core/src/test/java/com/google/protobuf/MapForProto2LiteTest.java            \\\n  java/core/src/test/java/com/google/protobuf/MapForProto2Test.java                \\\n  java/core/src/test/java/com/google/protobuf/MapTest.java                         \\\n  java/core/src/test/java/com/google/protobuf/MessageTest.java                     \\\n  java/core/src/test/java/com/google/protobuf/NestedBuildersTest.java              \\\n  java/core/src/test/java/com/google/protobuf/NioByteStringTest.java               \\\n  java/core/src/test/java/com/google/protobuf/ParseExceptionsTest.java             \\\n  java/core/src/test/java/com/google/protobuf/ParserTest.java                      \\\n  java/core/src/test/java/com/google/protobuf/ProtobufArrayListTest.java           \\\n  java/core/src/test/java/com/google/protobuf/RepeatedFieldBuilderV3Test.java      \\\n  java/core/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java     \\\n  java/core/src/test/java/com/google/protobuf/RopeByteStringTest.java              \\\n  java/core/src/test/java/com/google/protobuf/ServiceTest.java                     \\\n  java/core/src/test/java/com/google/protobuf/SingleFieldBuilderV3Test.java        \\\n  java/core/src/test/java/com/google/protobuf/SmallSortedMapTest.java              \\\n  java/core/src/test/java/com/google/protobuf/TestBadIdentifiers.java              \\\n  java/core/src/test/java/com/google/protobuf/TestUtil.java                        \\\n  java/core/src/test/java/com/google/protobuf/TestUtilLite.java                    \\\n  java/core/src/test/java/com/google/protobuf/TextFormatParseInfoTreeTest.java     \\\n  java/core/src/test/java/com/google/protobuf/TextFormatParseLocationTest.java     \\\n  java/core/src/test/java/com/google/protobuf/TextFormatTest.java                  \\\n  java/core/src/test/java/com/google/protobuf/UnknownEnumValueTest.java            \\\n  java/core/src/test/java/com/google/protobuf/UnknownFieldSetLiteTest.java         \\\n  java/core/src/test/java/com/google/protobuf/UnknownFieldSetTest.java             \\\n  java/core/src/test/java/com/google/protobuf/UnmodifiableLazyStringListTest.java  \\\n  java/core/src/test/java/com/google/protobuf/WellKnownTypesTest.java              \\\n  java/core/src/test/java/com/google/protobuf/WireFormatTest.java                  \\\n  java/core/src/test/proto/com/google/protobuf/any_test.proto                      \\\n  java/core/src/test/proto/com/google/protobuf/field_presence_test.proto           \\\n  java/core/src/test/proto/com/google/protobuf/lazy_fields_lite.proto              \\\n  java/core/src/test/proto/com/google/protobuf/lite_equals_and_hash.proto          \\\n  java/core/src/test/proto/com/google/protobuf/map_for_proto2_lite_test.proto      \\\n  java/core/src/test/proto/com/google/protobuf/map_for_proto2_test.proto           \\\n  java/core/src/test/proto/com/google/protobuf/map_initialization_order_test.proto \\\n  java/core/src/test/proto/com/google/protobuf/map_test.proto                      \\\n  java/core/src/test/proto/com/google/protobuf/multiple_files_test.proto           \\\n  java/core/src/test/proto/com/google/protobuf/nested_builders_test.proto          \\\n  java/core/src/test/proto/com/google/protobuf/nested_extension.proto              \\\n  java/core/src/test/proto/com/google/protobuf/nested_extension_lite.proto         \\\n  java/core/src/test/proto/com/google/protobuf/non_nested_extension.proto          \\\n  java/core/src/test/proto/com/google/protobuf/non_nested_extension_lite.proto     \\\n  java/core/src/test/proto/com/google/protobuf/outer_class_name_test.proto         \\\n  java/core/src/test/proto/com/google/protobuf/outer_class_name_test2.proto        \\\n  java/core/src/test/proto/com/google/protobuf/outer_class_name_test3.proto        \\\n  java/core/src/test/proto/com/google/protobuf/test_bad_identifiers.proto          \\\n  java/core/src/test/proto/com/google/protobuf/test_check_utf8.proto               \\\n  java/core/src/test/proto/com/google/protobuf/test_check_utf8_size.proto          \\\n  java/core/src/test/proto/com/google/protobuf/test_custom_options.proto           \\\n  java/core/src/test/proto/com/google/protobuf/test_extra_interfaces.proto         \\\n  java/lite/generate-sources-build.xml                                             \\\n  java/lite/generate-test-sources-build.xml                                        \\\n  java/lite/pom.xml                                                                \\\n  java/pom.xml                                                                     \\\n  java/util/pom.xml                                                                \\\n  java/util/src/main/java/com/google/protobuf/util/Durations.java                  \\\n  java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java              \\\n  java/util/src/main/java/com/google/protobuf/util/FieldMaskUtil.java              \\\n  java/util/src/main/java/com/google/protobuf/util/JsonFormat.java                 \\\n  java/util/src/main/java/com/google/protobuf/util/TimeUtil.java                   \\\n  java/util/src/main/java/com/google/protobuf/util/Timestamps.java                 \\\n  java/util/src/test/java/com/google/protobuf/util/FieldMaskTreeTest.java          \\\n  java/util/src/test/java/com/google/protobuf/util/FieldMaskUtilTest.java          \\\n  java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java             \\\n  java/util/src/test/java/com/google/protobuf/util/TimeUtilTest.java               \\\n  java/util/src/test/proto/com/google/protobuf/util/json_test.proto\n\njavanano_EXTRA_DIST = \\\n  javanano/src/main/java/com/google/protobuf/nano/CodedOutputByteBufferNano.java          \\\n  javanano/src/main/java/com/google/protobuf/nano/FieldData.java                          \\\n  javanano/src/main/java/com/google/protobuf/nano/FieldArray.java                         \\\n  javanano/src/main/java/com/google/protobuf/nano/WireFormatNano.java                     \\\n  javanano/src/main/java/com/google/protobuf/nano/Extension.java                          \\\n  javanano/src/main/java/com/google/protobuf/nano/CodedInputByteBufferNano.java           \\\n  javanano/src/main/java/com/google/protobuf/nano/UnknownFieldData.java                   \\\n  javanano/src/main/java/com/google/protobuf/nano/MessageNano.java                        \\\n  javanano/src/main/java/com/google/protobuf/nano/InternalNano.java                       \\\n  javanano/src/main/java/com/google/protobuf/nano/InvalidProtocolBufferNanoException.java \\\n  javanano/src/main/java/com/google/protobuf/nano/MapFactories.java                       \\\n  javanano/src/main/java/com/google/protobuf/nano/ExtendableMessageNano.java              \\\n  javanano/src/main/java/com/google/protobuf/nano/MessageNanoPrinter.java                 \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_accessors_nano.proto           \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_enum_class_nano.proto          \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_reference_types_nano.proto     \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_extension_repeated_nano.proto  \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_has_nano.proto                 \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_nano.proto                     \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_multiple_nameclash_nano.proto  \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_single_nano.proto              \\\n  javanano/src/test/java/com/google/protobuf/nano/NanoTest.java                           \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_simple_nano.proto              \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_import_nano.proto              \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_repeated_merge_nano.proto      \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_extension_nano.proto           \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_repeated_packables_nano.proto  \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_extension_singular_nano.proto  \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_recursive_nano.proto           \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_extension_packed_nano.proto    \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_enum_validity_nano.proto       \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_stringutf8_nano.proto          \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_multiple_nano.proto            \\\n  javanano/src/test/java/com/google/protobuf/nano/unittest_enum_class_multiple_nano.proto \\\n  javanano/src/test/java/com/google/protobuf/nano/map_test.proto                          \\\n  javanano/README.md                                                                      \\\n  javanano/pom.xml\n\nobjectivec_EXTRA_DIST = \\\n  objectivec/DevTools/check_version_stamps.sh                                \\\n  objectivec/DevTools/compile_testing_protos.sh                              \\\n  objectivec/DevTools/full_mac_build.sh                                      \\\n  objectivec/DevTools/pddm.py                                                \\\n  objectivec/DevTools/pddm_tests.py                                          \\\n  objectivec/generate_well_known_types.sh                                    \\\n  objectivec/google/protobuf/Any.pbobjc.h                                    \\\n  objectivec/google/protobuf/Any.pbobjc.m                                    \\\n  objectivec/google/protobuf/Api.pbobjc.h                                    \\\n  objectivec/google/protobuf/Api.pbobjc.m                                    \\\n  objectivec/google/protobuf/Duration.pbobjc.h                               \\\n  objectivec/google/protobuf/Duration.pbobjc.m                               \\\n  objectivec/google/protobuf/Empty.pbobjc.h                                  \\\n  objectivec/google/protobuf/Empty.pbobjc.m                                  \\\n  objectivec/google/protobuf/FieldMask.pbobjc.h                              \\\n  objectivec/google/protobuf/FieldMask.pbobjc.m                              \\\n  objectivec/google/protobuf/SourceContext.pbobjc.h                          \\\n  objectivec/google/protobuf/SourceContext.pbobjc.m                          \\\n  objectivec/google/protobuf/Struct.pbobjc.h                                 \\\n  objectivec/google/protobuf/Struct.pbobjc.m                                 \\\n  objectivec/google/protobuf/Timestamp.pbobjc.h                              \\\n  objectivec/google/protobuf/Timestamp.pbobjc.m                              \\\n  objectivec/google/protobuf/Type.pbobjc.h                                   \\\n  objectivec/google/protobuf/Type.pbobjc.m                                   \\\n  objectivec/google/protobuf/Wrappers.pbobjc.h                               \\\n  objectivec/google/protobuf/Wrappers.pbobjc.m                               \\\n  objectivec/GPBArray.h                                                      \\\n  objectivec/GPBArray.m                                                      \\\n  objectivec/GPBArray_PackagePrivate.h                                       \\\n  objectivec/GPBBootstrap.h                                                  \\\n  objectivec/GPBCodedInputStream.h                                           \\\n  objectivec/GPBCodedInputStream.m                                           \\\n  objectivec/GPBCodedInputStream_PackagePrivate.h                            \\\n  objectivec/GPBCodedOutputStream.h                                          \\\n  objectivec/GPBCodedOutputStream.m                                          \\\n  objectivec/GPBCodedOutputStream_PackagePrivate.h                           \\\n  objectivec/GPBDescriptor.h                                                 \\\n  objectivec/GPBDescriptor.m                                                 \\\n  objectivec/GPBDescriptor_PackagePrivate.h                                  \\\n  objectivec/GPBDictionary.h                                                 \\\n  objectivec/GPBDictionary.m                                                 \\\n  objectivec/GPBDictionary_PackagePrivate.h                                  \\\n  objectivec/GPBExtensionInternals.h                                         \\\n  objectivec/GPBExtensionInternals.m                                         \\\n  objectivec/GPBExtensionRegistry.h                                          \\\n  objectivec/GPBExtensionRegistry.m                                          \\\n  objectivec/GPBMessage.h                                                    \\\n  objectivec/GPBMessage.m                                                    \\\n  objectivec/GPBMessage_PackagePrivate.h                                     \\\n  objectivec/GPBProtocolBuffers.h                                            \\\n  objectivec/GPBProtocolBuffers.m                                            \\\n  objectivec/GPBProtocolBuffers_RuntimeSupport.h                             \\\n  objectivec/GPBRootObject.h                                                 \\\n  objectivec/GPBRootObject.m                                                 \\\n  objectivec/GPBRootObject_PackagePrivate.h                                  \\\n  objectivec/GPBRuntimeTypes.h                                               \\\n  objectivec/GPBUnknownField.h                                               \\\n  objectivec/GPBUnknownField.m                                               \\\n  objectivec/GPBUnknownField_PackagePrivate.h                                \\\n  objectivec/GPBUnknownFieldSet.h                                            \\\n  objectivec/GPBUnknownFieldSet.m                                            \\\n  objectivec/GPBUnknownFieldSet_PackagePrivate.h                             \\\n  objectivec/GPBUtilities.h                                                  \\\n  objectivec/GPBUtilities.m                                                  \\\n  objectivec/GPBUtilities_PackagePrivate.h                                   \\\n  objectivec/GPBWellKnownTypes.h                                             \\\n  objectivec/GPBWellKnownTypes.m                                             \\\n  objectivec/GPBWireFormat.h                                                 \\\n  objectivec/GPBWireFormat.m                                                 \\\n  objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj                   \\\n  objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/contents.xcworkspacedata \\\n  objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings \\\n  objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme \\\n  objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme \\\n  objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj                   \\\n  objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/contents.xcworkspacedata \\\n  objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings \\\n  objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme \\\n  objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme \\\n  objectivec/README.md                                                       \\\n  objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.pbxproj \\\n  objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata \\\n  objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/OSXCocoaPodsTester.xcscheme \\\n  objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.h \\\n  objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.m \\\n  objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json \\\n  objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Base.lproj/MainMenu.xib \\\n  objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Info.plist \\\n  objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/main.m    \\\n  objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-framework            \\\n  objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-static               \\\n  objectivec/Tests/CocoaPods/README.md                                       \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-framework            \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-static               \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.pbxproj \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/iOSCocoaPodsTester.xcscheme \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.h \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.m \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/LaunchScreen.storyboard \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/Main.storyboard \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Info.plist \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.h \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.m \\\n  objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/main.m    \\\n  objectivec/Tests/CocoaPods/run_tests.sh                                    \\\n  objectivec/Tests/golden_message                                            \\\n  objectivec/Tests/golden_packed_fields_message                              \\\n  objectivec/Tests/GPBARCUnittestProtos.m                                    \\\n  objectivec/Tests/GPBArrayTests.m                                           \\\n  objectivec/Tests/GPBCodedInputStreamTests.m                                \\\n  objectivec/Tests/GPBCodedOuputStreamTests.m                                \\\n  objectivec/Tests/GPBConcurrencyTests.m                                     \\\n  objectivec/Tests/GPBDescriptorTests.m                                      \\\n  objectivec/Tests/GPBDictionaryTests+Bool.m                                 \\\n  objectivec/Tests/GPBDictionaryTests+Int32.m                                \\\n  objectivec/Tests/GPBDictionaryTests+Int64.m                                \\\n  objectivec/Tests/GPBDictionaryTests+String.m                               \\\n  objectivec/Tests/GPBDictionaryTests+UInt32.m                               \\\n  objectivec/Tests/GPBDictionaryTests+UInt64.m                               \\\n  objectivec/Tests/GPBDictionaryTests.pddm                                   \\\n  objectivec/Tests/GPBMessageTests+Merge.m                                   \\\n  objectivec/Tests/GPBMessageTests+Runtime.m                                 \\\n  objectivec/Tests/GPBMessageTests+Serialization.m                           \\\n  objectivec/Tests/GPBMessageTests.m                                         \\\n  objectivec/Tests/GPBObjectiveCPlusPlusTest.mm                              \\\n  objectivec/Tests/GPBPerfTests.m                                            \\\n  objectivec/Tests/GPBSwiftTests.swift                                       \\\n  objectivec/Tests/GPBTestUtilities.h                                        \\\n  objectivec/Tests/GPBTestUtilities.m                                        \\\n  objectivec/Tests/GPBUnittestProtos.m                                       \\\n  objectivec/Tests/GPBUnknownFieldSetTest.m                                  \\\n  objectivec/Tests/GPBUtilitiesTests.m                                       \\\n  objectivec/Tests/GPBWellKnownTypesTest.m                                   \\\n  objectivec/Tests/GPBWireFormatTests.m                                      \\\n  objectivec/Tests/iOSTestHarness/AppDelegate.m                              \\\n  objectivec/Tests/iOSTestHarness/en.lproj/InfoPlist.strings                 \\\n  objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/Contents.json      \\\n  objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6.png          \\\n  objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6_2x.png       \\\n  objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7.png          \\\n  objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7_2x.png       \\\n  objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6.png        \\\n  objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6_2x.png     \\\n  objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_2x.png     \\\n  objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_3x.png     \\\n  objectivec/Tests/iOSTestHarness/Images.xcassets/LaunchImage.launchimage/Contents.json \\\n  objectivec/Tests/iOSTestHarness/Info.plist                                  \\\n  objectivec/Tests/iOSTestHarness/LaunchScreen.xib                            \\\n  objectivec/Tests/text_format_map_unittest_data.txt                          \\\n  objectivec/Tests/text_format_unittest_data.txt                              \\\n  objectivec/Tests/unittest_cycle.proto                                       \\\n  objectivec/Tests/unittest_objc.proto                                        \\\n  objectivec/Tests/unittest_objc_startup.proto                                \\\n  objectivec/Tests/unittest_runtime_proto2.proto                              \\\n  objectivec/Tests/unittest_runtime_proto3.proto                              \\\n  objectivec/Tests/UnitTests-Bridging-Header.h                                \\\n  objectivec/Tests/UnitTests-Info.plist                                       \\\n  Protobuf.podspec\n\npython_EXTRA_DIST = \\\n  python/MANIFEST.in                                                         \\\n  python/google/__init__.py                                                  \\\n  python/google/protobuf/__init__.py                                         \\\n  python/google/protobuf/descriptor.py                                       \\\n  python/google/protobuf/descriptor_database.py                              \\\n  python/google/protobuf/descriptor_pool.py                                  \\\n  python/google/protobuf/internal/__init__.py                                \\\n  python/google/protobuf/internal/_parameterized.py                          \\\n  python/google/protobuf/internal/any_test.proto                             \\\n  python/google/protobuf/internal/any_test.proto                             \\\n  python/google/protobuf/internal/api_implementation.cc                      \\\n  python/google/protobuf/internal/api_implementation.py                      \\\n  python/google/protobuf/internal/containers.py                              \\\n  python/google/protobuf/internal/decoder.py                                 \\\n  python/google/protobuf/internal/descriptor_database_test.py                \\\n  python/google/protobuf/internal/descriptor_pool_test.py                    \\\n  python/google/protobuf/internal/descriptor_pool_test1.proto                \\\n  python/google/protobuf/internal/descriptor_pool_test2.proto                \\\n  python/google/protobuf/internal/descriptor_test.py                         \\\n  python/google/protobuf/internal/encoder.py                                 \\\n  python/google/protobuf/internal/enum_type_wrapper.py                       \\\n  python/google/protobuf/internal/factory_test1.proto                        \\\n  python/google/protobuf/internal/factory_test2.proto                        \\\n  python/google/protobuf/internal/file_options_test.proto                    \\\n  python/google/protobuf/internal/generator_test.py                          \\\n  python/google/protobuf/internal/import_test_package/__init__.py            \\\n  python/google/protobuf/internal/import_test_package/inner.proto            \\\n  python/google/protobuf/internal/import_test_package/outer.proto            \\\n  python/google/protobuf/internal/json_format_test.py                        \\\n  python/google/protobuf/internal/message_factory_test.py                    \\\n  python/google/protobuf/internal/message_listener.py                        \\\n  python/google/protobuf/internal/message_set_extensions.proto               \\\n  python/google/protobuf/internal/message_test.py                            \\\n  python/google/protobuf/internal/missing_enum_values.proto                  \\\n  python/google/protobuf/internal/more_extensions.proto                      \\\n  python/google/protobuf/internal/more_extensions_dynamic.proto              \\\n  python/google/protobuf/internal/more_messages.proto                        \\\n  python/google/protobuf/internal/packed_field_test.proto                    \\\n  python/google/protobuf/internal/proto_builder_test.py                      \\\n  python/google/protobuf/internal/python_message.py                          \\\n  python/google/protobuf/internal/reflection_test.py                         \\\n  python/google/protobuf/internal/service_reflection_test.py                 \\\n  python/google/protobuf/internal/symbol_database_test.py                    \\\n  python/google/protobuf/internal/test_bad_identifiers.proto                 \\\n  python/google/protobuf/internal/test_util.py                               \\\n  python/google/protobuf/internal/text_encoding_test.py                      \\\n  python/google/protobuf/internal/text_format_test.py                        \\\n  python/google/protobuf/internal/type_checkers.py                           \\\n  python/google/protobuf/internal/unknown_fields_test.py                     \\\n  python/google/protobuf/internal/well_known_types.py                        \\\n  python/google/protobuf/internal/well_known_types.py                        \\\n  python/google/protobuf/internal/well_known_types_test.py                   \\\n  python/google/protobuf/internal/well_known_types_test.py                   \\\n  python/google/protobuf/internal/wire_format.py                             \\\n  python/google/protobuf/internal/wire_format_test.py                        \\\n  python/google/protobuf/json_format.py                                      \\\n  python/google/protobuf/message.py                                          \\\n  python/google/protobuf/message_factory.py                                  \\\n  python/google/protobuf/proto_builder.py                                    \\\n  python/google/protobuf/pyext/README                                        \\\n  python/google/protobuf/pyext/__init__.py                                   \\\n  python/google/protobuf/pyext/cpp_message.py                                \\\n  python/google/protobuf/pyext/descriptor.cc                                 \\\n  python/google/protobuf/pyext/descriptor.h                                  \\\n  python/google/protobuf/pyext/descriptor_containers.cc                      \\\n  python/google/protobuf/pyext/descriptor_containers.h                       \\\n  python/google/protobuf/pyext/descriptor_database.cc                        \\\n  python/google/protobuf/pyext/descriptor_database.h                         \\\n  python/google/protobuf/pyext/descriptor_pool.cc                            \\\n  python/google/protobuf/pyext/descriptor_pool.h                             \\\n  python/google/protobuf/pyext/extension_dict.cc                             \\\n  python/google/protobuf/pyext/extension_dict.h                              \\\n  python/google/protobuf/pyext/map_container.cc                              \\\n  python/google/protobuf/pyext/map_container.h                               \\\n  python/google/protobuf/pyext/message.cc                                    \\\n  python/google/protobuf/pyext/message.h                                     \\\n  python/google/protobuf/pyext/message_module.cc                             \\\n  python/google/protobuf/pyext/proto2_api_test.proto                         \\\n  python/google/protobuf/pyext/python.proto                                  \\\n  python/google/protobuf/pyext/python_protobuf.h                             \\\n  python/google/protobuf/pyext/repeated_composite_container.cc               \\\n  python/google/protobuf/pyext/repeated_composite_container.h                \\\n  python/google/protobuf/pyext/repeated_scalar_container.cc                  \\\n  python/google/protobuf/pyext/repeated_scalar_container.h                   \\\n  python/google/protobuf/pyext/scoped_pyobject_ptr.h                         \\\n  python/google/protobuf/reflection.py                                       \\\n  python/google/protobuf/service.py                                          \\\n  python/google/protobuf/service_reflection.py                               \\\n  python/google/protobuf/symbol_database.py                                  \\\n  python/google/protobuf/text_encoding.py                                    \\\n  python/google/protobuf/text_format.py                                      \\\n  python/mox.py                                                              \\\n  python/setup.py                                                            \\\n  python/stubout.py                                                          \\\n  python/tox.ini                                                             \\\n  python/README.md\n\nruby_EXTRA_DIST = \\\n  ruby/Gemfile                                                               \\\n  ruby/Gemfile.lock                                                          \\\n  ruby/.gitignore                                                            \\\n  ruby/README.md                                                             \\\n  ruby/Rakefile                                                              \\\n  ruby/ext/google/protobuf_c/defs.c                                          \\\n  ruby/ext/google/protobuf_c/encode_decode.c                                 \\\n  ruby/ext/google/protobuf_c/extconf.rb                                      \\\n  ruby/ext/google/protobuf_c/map.c                                           \\\n  ruby/ext/google/protobuf_c/message.c                                       \\\n  ruby/ext/google/protobuf_c/protobuf.c                                      \\\n  ruby/ext/google/protobuf_c/protobuf.h                                      \\\n  ruby/ext/google/protobuf_c/repeated_field.c                                \\\n  ruby/ext/google/protobuf_c/storage.c                                       \\\n  ruby/ext/google/protobuf_c/upb.c                                           \\\n  ruby/ext/google/protobuf_c/upb.h                                           \\\n  ruby/google-protobuf.gemspec                                               \\\n  ruby/lib/google/protobuf/message_exts.rb                                   \\\n  ruby/lib/google/protobuf/repeated_field.rb                                 \\\n  ruby/lib/google/protobuf.rb                                                \\\n  ruby/pom.xml                                                               \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyBuilder.java              \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyDescriptor.java           \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyDescriptorPool.java       \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyEnumBuilderContext.java   \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyEnumDescriptor.java       \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyEnum.java                 \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyFieldDescriptor.java      \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyMap.java                  \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyMessageBuilderContext.java \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.java              \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyOneofBuilderContext.java  \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyOneofDescriptor.java      \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyProtobuf.java             \\\n  ruby/src/main/java/com/google/protobuf/jruby/RubyRepeatedField.java        \\\n  ruby/src/main/java/com/google/protobuf/jruby/SentinelOuterClass.java       \\\n  ruby/src/main/java/com/google/protobuf/jruby/Utils.java                    \\\n  ruby/src/main/java/google/ProtobufJavaService.java                         \\\n  ruby/src/main/sentinel.proto                                               \\\n  ruby/tests/basic.rb                                                        \\\n  ruby/tests/repeated_field_test.rb                                          \\\n  ruby/tests/stress.rb                                                       \\\n  ruby/tests/generated_code.proto                                            \\\n  ruby/tests/test_import.proto                                               \\\n  ruby/tests/generated_code_test.rb                                          \\\n  ruby/travis-test.sh\n\njs_EXTRA_DIST = \\\n  js/README.md                              \\\n  js/binary/arith.js                        \\\n  js/binary/arith_test.js                   \\\n  js/binary/constants.js                    \\\n  js/binary/decoder.js                      \\\n  js/binary/decoder_test.js                 \\\n  js/binary/encoder.js                      \\\n  js/binary/proto_test.js                   \\\n  js/binary/reader.js                       \\\n  js/binary/reader_test.js                  \\\n  js/binary/utils.js                        \\\n  js/binary/utils_test.js                   \\\n  js/binary/writer.js                       \\\n  js/binary/writer_test.js                  \\\n  js/commonjs/export.js                     \\\n  js/commonjs/export_asserts.js             \\\n  js/commonjs/export_testdeps.js            \\\n  js/commonjs/import_test.js                \\\n  js/commonjs/jasmine.json                  \\\n  js/commonjs/rewrite_tests_for_commonjs.js \\\n  js/commonjs/test6/test6.proto             \\\n  js/commonjs/test7/test7.proto             \\\n  js/data.proto                             \\\n  js/debug.js                               \\\n  js/debug_test.js                          \\\n  js/gulpfile.js                            \\\n  js/jasmine.json                           \\\n  js/map.js                                 \\\n  js/message.js                             \\\n  js/message_test.js                        \\\n  js/node_loader.js                         \\\n  js/package.json                           \\\n  js/proto3_test.js                         \\\n  js/proto3_test.proto                      \\\n  js/test.proto                             \\\n  js/test2.proto                            \\\n  js/test3.proto                            \\\n  js/test4.proto                            \\\n  js/test5.proto                            \\\n  js/test_bootstrap.js                      \\\n  js/testbinary.proto                       \\\n  js/testempty.proto\n\nall_EXTRA_DIST = $(csharp_EXTRA_DIST) $(java_EXTRA_DIST) $(javanano_EXTRA_DIST) $(objectivec_EXTRA_DIST) $(python_EXTRA_DIST) $(ruby_EXTRA_DIST) $(js_EXTRA_DIST)\nEXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST)   \\\n  autogen.sh                             \\\n  generate_descriptor_proto.sh           \\\n  README.md                              \\\n  LICENSE                                \\\n  CONTRIBUTORS.txt                       \\\n  CHANGES.txt                            \\\n  update_file_lists.sh                   \\\n  BUILD                                  \\\n  gmock.BUILD                            \\\n  WORKSPACE                              \\\n  cmake/CMakeLists.txt                   \\\n  cmake/README.md                        \\\n  cmake/examples.cmake                   \\\n  cmake/extract_includes.bat.in          \\\n  cmake/install.cmake                    \\\n  cmake/libprotobuf.cmake                \\\n  cmake/libprotobuf-lite.cmake           \\\n  cmake/libprotoc.cmake                  \\\n  cmake/protobuf-config-version.cmake.in \\\n  cmake/protobuf-config.cmake.in         \\\n  cmake/protobuf-module.cmake.in         \\\n  cmake/protobuf-options.cmake           \\\n  cmake/protoc.cmake                     \\\n  cmake/tests.cmake                      \\\n  editors/README.txt                     \\\n  editors/proto.vim                      \\\n  editors/protobuf-mode.el               \\\n  examples/CMakeLists.txt                \\\n  examples/README.txt                    \\\n  examples/Makefile                      \\\n  examples/addressbook.proto             \\\n  examples/add_person.cc                 \\\n  examples/add_person.go                 \\\n  examples/add_person_test.go            \\\n  examples/list_people.cc                \\\n  examples/list_people.go                \\\n  examples/AddPerson.java                \\\n  examples/CMakeLists.txt                \\\n  examples/ListPeople.java               \\\n  examples/add_person.py                 \\\n  examples/list_people.py                \\\n  examples/list_people_test.go           \\\n  protobuf.bzl                           \\\n  six.BUILD                              \\\n  util/python/BUILD\n\n\n# Deletes all the files generated by autogen.sh.\nMAINTAINERCLEANFILES = \\\n  aclocal.m4             \\\n  ar-lib                 \\\n  config.guess           \\\n  config.sub             \\\n  configure              \\\n  depcomp                \\\n  install-sh             \\\n  ltmain.sh              \\\n  Makefile.in            \\\n  missing                \\\n  mkinstalldirs          \\\n  config.h.in            \\\n  stamp.h.in             \\\n  m4/ltsugar.m4          \\\n  m4/libtool.m4          \\\n  m4/ltversion.m4        \\\n  m4/lt~obsolete.m4      \\\n  m4/ltoptions.m4\n\nall: config.h\n\t$(MAKE) $(AM_MAKEFLAGS) all-recursive\n\n.SUFFIXES:\nam--refresh: Makefile\n\t@:\n$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)\n\t@for dep in $?; do \\\n\t  case '$(am__configure_deps)' in \\\n\t    *$$dep*) \\\n\t      echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \\\n\t      $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \\\n\t\t&& exit 0; \\\n\t      exit 1;; \\\n\t  esac; \\\n\tdone; \\\n\techo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \\\n\t$(am__cd) $(top_srcdir) && \\\n\t  $(AUTOMAKE) --foreign Makefile\n.PRECIOUS: Makefile\nMakefile: $(srcdir)/Makefile.in $(top_builddir)/config.status\n\t@case '$?' in \\\n\t  *config.status*) \\\n\t    echo ' $(SHELL) ./config.status'; \\\n\t    $(SHELL) ./config.status;; \\\n\t  *) \\\n\t    echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \\\n\t    cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \\\n\tesac;\n\n$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)\n\t$(SHELL) ./config.status --recheck\n\n$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)\n\t$(am__cd) $(srcdir) && $(AUTOCONF)\n$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)\n\t$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)\n$(am__aclocal_m4_deps):\n\nconfig.h: stamp-h1\n\t@test -f $@ || rm -f stamp-h1\n\t@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1\n\nstamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status\n\t@rm -f stamp-h1\n\tcd $(top_builddir) && $(SHELL) ./config.status config.h\n$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) \n\t($(am__cd) $(top_srcdir) && $(AUTOHEADER))\n\trm -f stamp-h1\n\ttouch $@\n\ndistclean-hdr:\n\t-rm -f config.h stamp-h1\nprotobuf.pc: $(top_builddir)/config.status $(srcdir)/protobuf.pc.in\n\tcd $(top_builddir) && $(SHELL) ./config.status $@\nprotobuf-lite.pc: $(top_builddir)/config.status $(srcdir)/protobuf-lite.pc.in\n\tcd $(top_builddir) && $(SHELL) ./config.status $@\n\nmostlyclean-libtool:\n\t-rm -f *.lo\n\nclean-libtool:\n\t-rm -rf .libs _libs\n\ndistclean-libtool:\n\t-rm -f libtool config.lt\ninstall-pkgconfigDATA: $(pkgconfig_DATA)\n\t@$(NORMAL_INSTALL)\n\t@list='$(pkgconfig_DATA)'; test -n \"$(pkgconfigdir)\" || list=; \\\n\tif test -n \"$$list\"; then \\\n\t  echo \" $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'\"; \\\n\t  $(MKDIR_P) \"$(DESTDIR)$(pkgconfigdir)\" || exit 1; \\\n\tfi; \\\n\tfor p in $$list; do \\\n\t  if test -f \"$$p\"; then d=; else d=\"$(srcdir)/\"; fi; \\\n\t  echo \"$$d$$p\"; \\\n\tdone | $(am__base_list) | \\\n\twhile read files; do \\\n\t  echo \" $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'\"; \\\n\t  $(INSTALL_DATA) $$files \"$(DESTDIR)$(pkgconfigdir)\" || exit $$?; \\\n\tdone\n\nuninstall-pkgconfigDATA:\n\t@$(NORMAL_UNINSTALL)\n\t@list='$(pkgconfig_DATA)'; test -n \"$(pkgconfigdir)\" || list=; \\\n\tfiles=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \\\n\tdir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir)\n\n# This directory's subdirectories are mostly independent; you can cd\n# into them and run 'make' without going through this Makefile.\n# To change the values of 'make' variables: instead of editing Makefiles,\n# (1) if the variable is set in 'config.status', edit 'config.status'\n#     (which will cause the Makefiles to be regenerated when you run 'make');\n# (2) otherwise, pass the desired values on the 'make' command line.\n$(am__recursive_targets):\n\t@fail=; \\\n\tif $(am__make_keepgoing); then \\\n\t  failcom='fail=yes'; \\\n\telse \\\n\t  failcom='exit 1'; \\\n\tfi; \\\n\tdot_seen=no; \\\n\ttarget=`echo $@ | sed s/-recursive//`; \\\n\tcase \"$@\" in \\\n\t  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \\\n\t  *) list='$(SUBDIRS)' ;; \\\n\tesac; \\\n\tfor subdir in $$list; do \\\n\t  echo \"Making $$target in $$subdir\"; \\\n\t  if test \"$$subdir\" = \".\"; then \\\n\t    dot_seen=yes; \\\n\t    local_target=\"$$target-am\"; \\\n\t  else \\\n\t    local_target=\"$$target\"; \\\n\t  fi; \\\n\t  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \\\n\t  || eval $$failcom; \\\n\tdone; \\\n\tif test \"$$dot_seen\" = \"no\"; then \\\n\t  $(MAKE) $(AM_MAKEFLAGS) \"$$target-am\" || exit 1; \\\n\tfi; test -z \"$$fail\"\n\nID: $(am__tagged_files)\n\t$(am__define_uniq_tagged_files); mkid -fID $$unique\ntags: tags-recursive\nTAGS: tags\n\ntags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)\n\tset x; \\\n\there=`pwd`; \\\n\tif ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \\\n\t  include_option=--etags-include; \\\n\t  empty_fix=.; \\\n\telse \\\n\t  include_option=--include; \\\n\t  empty_fix=; \\\n\tfi; \\\n\tlist='$(SUBDIRS)'; for subdir in $$list; do \\\n\t  if test \"$$subdir\" = .; then :; else \\\n\t    test ! -f $$subdir/TAGS || \\\n\t      set \"$$@\" \"$$include_option=$$here/$$subdir/TAGS\"; \\\n\t  fi; \\\n\tdone; \\\n\t$(am__define_uniq_tagged_files); \\\n\tshift; \\\n\tif test -z \"$(ETAGS_ARGS)$$*$$unique\"; then :; else \\\n\t  test -n \"$$unique\" || unique=$$empty_fix; \\\n\t  if test $$# -gt 0; then \\\n\t    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \\\n\t      \"$$@\" $$unique; \\\n\t  else \\\n\t    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \\\n\t      $$unique; \\\n\t  fi; \\\n\tfi\nctags: ctags-recursive\n\nCTAGS: ctags\nctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)\n\t$(am__define_uniq_tagged_files); \\\n\ttest -z \"$(CTAGS_ARGS)$$unique\" \\\n\t  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \\\n\t     $$unique\n\nGTAGS:\n\there=`$(am__cd) $(top_builddir) && pwd` \\\n\t  && $(am__cd) $(top_srcdir) \\\n\t  && gtags -i $(GTAGS_ARGS) \"$$here\"\ncscope: cscope.files\n\ttest ! -s cscope.files \\\n\t  || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)\nclean-cscope:\n\t-rm -f cscope.files\ncscope.files: clean-cscope cscopelist\ncscopelist: cscopelist-recursive\n\ncscopelist-am: $(am__tagged_files)\n\tlist='$(am__tagged_files)'; \\\n\tcase \"$(srcdir)\" in \\\n\t  [\\\\/]* | ?:[\\\\/]*) sdir=\"$(srcdir)\" ;; \\\n\t  *) sdir=$(subdir)/$(srcdir) ;; \\\n\tesac; \\\n\tfor i in $$list; do \\\n\t  if test -f \"$$i\"; then \\\n\t    echo \"$(subdir)/$$i\"; \\\n\t  else \\\n\t    echo \"$$sdir/$$i\"; \\\n\t  fi; \\\n\tdone >> $(top_builddir)/cscope.files\n\ndistclean-tags:\n\t-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags\n\t-rm -f cscope.out cscope.in.out cscope.po.out cscope.files\n\ndistdir: $(DISTFILES)\n\t$(am__remove_distdir)\n\ttest -d \"$(distdir)\" || mkdir \"$(distdir)\"\n\t@srcdirstrip=`echo \"$(srcdir)\" | sed 's/[].[^$$\\\\*]/\\\\\\\\&/g'`; \\\n\ttopsrcdirstrip=`echo \"$(top_srcdir)\" | sed 's/[].[^$$\\\\*]/\\\\\\\\&/g'`; \\\n\tlist='$(DISTFILES)'; \\\n\t  dist_files=`for file in $$list; do echo $$file; done | \\\n\t  sed -e \"s|^$$srcdirstrip/||;t\" \\\n\t      -e \"s|^$$topsrcdirstrip/|$(top_builddir)/|;t\"`; \\\n\tcase $$dist_files in \\\n\t  */*) $(MKDIR_P) `echo \"$$dist_files\" | \\\n\t\t\t   sed '/\\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \\\n\t\t\t   sort -u` ;; \\\n\tesac; \\\n\tfor file in $$dist_files; do \\\n\t  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \\\n\t  if test -d $$d/$$file; then \\\n\t    dir=`echo \"/$$file\" | sed -e 's,/[^/]*$$,,'`; \\\n\t    if test -d \"$(distdir)/$$file\"; then \\\n\t      find \"$(distdir)/$$file\" -type d ! -perm -700 -exec chmod u+rwx {} \\;; \\\n\t    fi; \\\n\t    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \\\n\t      cp -fpR $(srcdir)/$$file \"$(distdir)$$dir\" || exit 1; \\\n\t      find \"$(distdir)/$$file\" -type d ! -perm -700 -exec chmod u+rwx {} \\;; \\\n\t    fi; \\\n\t    cp -fpR $$d/$$file \"$(distdir)$$dir\" || exit 1; \\\n\t  else \\\n\t    test -f \"$(distdir)/$$file\" \\\n\t    || cp -p $$d/$$file \"$(distdir)/$$file\" \\\n\t    || exit 1; \\\n\t  fi; \\\n\tdone\n\t@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \\\n\t  if test \"$$subdir\" = .; then :; else \\\n\t    $(am__make_dryrun) \\\n\t      || test -d \"$(distdir)/$$subdir\" \\\n\t      || $(MKDIR_P) \"$(distdir)/$$subdir\" \\\n\t      || exit 1; \\\n\t    dir1=$$subdir; dir2=\"$(distdir)/$$subdir\"; \\\n\t    $(am__relativize); \\\n\t    new_distdir=$$reldir; \\\n\t    dir1=$$subdir; dir2=\"$(top_distdir)\"; \\\n\t    $(am__relativize); \\\n\t    new_top_distdir=$$reldir; \\\n\t    echo \" (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=\"$$new_top_distdir\" distdir=\"$$new_distdir\" \\\\\"; \\\n\t    echo \"     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)\"; \\\n\t    ($(am__cd) $$subdir && \\\n\t      $(MAKE) $(AM_MAKEFLAGS) \\\n\t        top_distdir=\"$$new_top_distdir\" \\\n\t        distdir=\"$$new_distdir\" \\\n\t\tam__remove_distdir=: \\\n\t\tam__skip_length_check=: \\\n\t\tam__skip_mode_fix=: \\\n\t        distdir) \\\n\t      || exit 1; \\\n\t  fi; \\\n\tdone\n\t-test -n \"$(am__skip_mode_fix)\" \\\n\t|| find \"$(distdir)\" -type d ! -perm -755 \\\n\t\t-exec chmod u+rwx,go+rx {} \\; -o \\\n\t  ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \\; -o \\\n\t  ! -type d ! -perm -400 -exec chmod a+r {} \\; -o \\\n\t  ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \\; \\\n\t|| chmod -R a+r \"$(distdir)\"\ndist-gzip: distdir\n\ttardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz\n\t$(am__post_remove_distdir)\n\ndist-bzip2: distdir\n\ttardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2\n\t$(am__post_remove_distdir)\n\ndist-lzip: distdir\n\ttardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz\n\t$(am__post_remove_distdir)\n\ndist-xz: distdir\n\ttardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz\n\t$(am__post_remove_distdir)\n\ndist-tarZ: distdir\n\t@echo WARNING: \"Support for shar distribution archives is\" \\\n\t               \"deprecated.\" >&2\n\t@echo WARNING: \"It will be removed altogether in Automake 2.0\" >&2\n\ttardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z\n\t$(am__post_remove_distdir)\n\ndist-shar: distdir\n\t@echo WARNING: \"Support for distribution archives compressed with\" \\\n\t\t       \"legacy program 'compress' is deprecated.\" >&2\n\t@echo WARNING: \"It will be removed altogether in Automake 2.0\" >&2\n\tshar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz\n\t$(am__post_remove_distdir)\n\ndist-zip: distdir\n\t-rm -f $(distdir).zip\n\tzip -rq $(distdir).zip $(distdir)\n\t$(am__post_remove_distdir)\n\ndist dist-all:\n\t$(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'\n\t$(am__post_remove_distdir)\n\n# This target untars the dist file and tries a VPATH configuration.  Then\n# it guarantees that the distribution is self-contained by making another\n# tarfile.\ndistcheck: dist\n\tcase '$(DIST_ARCHIVES)' in \\\n\t*.tar.gz*) \\\n\t  GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\\\n\t*.tar.bz2*) \\\n\t  bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\\\n\t*.tar.lz*) \\\n\t  lzip -dc $(distdir).tar.lz | $(am__untar) ;;\\\n\t*.tar.xz*) \\\n\t  xz -dc $(distdir).tar.xz | $(am__untar) ;;\\\n\t*.tar.Z*) \\\n\t  uncompress -c $(distdir).tar.Z | $(am__untar) ;;\\\n\t*.shar.gz*) \\\n\t  GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\\\n\t*.zip*) \\\n\t  unzip $(distdir).zip ;;\\\n\tesac\n\tchmod -R a-w $(distdir)\n\tchmod u+w $(distdir)\n\tmkdir $(distdir)/_build $(distdir)/_inst\n\tchmod a-w $(distdir)\n\ttest -d $(distdir)/_build || exit 0; \\\n\tdc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\\\/]:[\\\\/],/,'` \\\n\t  && dc_destdir=\"$${TMPDIR-/tmp}/am-dc-$$$$/\" \\\n\t  && am__cwd=`pwd` \\\n\t  && $(am__cd) $(distdir)/_build \\\n\t  && ../configure \\\n\t    $(AM_DISTCHECK_CONFIGURE_FLAGS) \\\n\t    $(DISTCHECK_CONFIGURE_FLAGS) \\\n\t    --srcdir=.. --prefix=\"$$dc_install_base\" \\\n\t  && $(MAKE) $(AM_MAKEFLAGS) \\\n\t  && $(MAKE) $(AM_MAKEFLAGS) dvi \\\n\t  && $(MAKE) $(AM_MAKEFLAGS) check \\\n\t  && $(MAKE) $(AM_MAKEFLAGS) install \\\n\t  && $(MAKE) $(AM_MAKEFLAGS) installcheck \\\n\t  && $(MAKE) $(AM_MAKEFLAGS) uninstall \\\n\t  && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir=\"$$dc_install_base\" \\\n\t        distuninstallcheck \\\n\t  && chmod -R a-w \"$$dc_install_base\" \\\n\t  && ({ \\\n\t       (cd ../.. && umask 077 && mkdir \"$$dc_destdir\") \\\n\t       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR=\"$$dc_destdir\" install \\\n\t       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR=\"$$dc_destdir\" uninstall \\\n\t       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR=\"$$dc_destdir\" \\\n\t            distuninstallcheck_dir=\"$$dc_destdir\" distuninstallcheck; \\\n\t      } || { rm -rf \"$$dc_destdir\"; exit 1; }) \\\n\t  && rm -rf \"$$dc_destdir\" \\\n\t  && $(MAKE) $(AM_MAKEFLAGS) dist \\\n\t  && rm -rf $(DIST_ARCHIVES) \\\n\t  && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \\\n\t  && cd \"$$am__cwd\" \\\n\t  || exit 1\n\t$(am__post_remove_distdir)\n\t@(echo \"$(distdir) archives ready for distribution: \"; \\\n\t  list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \\\n\t  sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'\ndistuninstallcheck:\n\t@test -n '$(distuninstallcheck_dir)' || { \\\n\t  echo 'ERROR: trying to run $@ with an empty' \\\n\t       '$$(distuninstallcheck_dir)' >&2; \\\n\t  exit 1; \\\n\t}; \\\n\t$(am__cd) '$(distuninstallcheck_dir)' || { \\\n\t  echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \\\n\t  exit 1; \\\n\t}; \\\n\ttest `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \\\n\t   || { echo \"ERROR: files left after uninstall:\" ; \\\n\t        if test -n \"$(DESTDIR)\"; then \\\n\t          echo \"  (check DESTDIR support)\"; \\\n\t        fi ; \\\n\t        $(distuninstallcheck_listfiles) ; \\\n\t        exit 1; } >&2\ndistcleancheck: distclean\n\t@if test '$(srcdir)' = . ; then \\\n\t  echo \"ERROR: distcleancheck can only run from a VPATH build\" ; \\\n\t  exit 1 ; \\\n\tfi\n\t@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \\\n\t  || { echo \"ERROR: files left in build directory after distclean:\" ; \\\n\t       $(distcleancheck_listfiles) ; \\\n\t       exit 1; } >&2\ncheck-am: all-am\n\t$(MAKE) $(AM_MAKEFLAGS) check-local\ncheck: check-recursive\nall-am: Makefile $(DATA) config.h\ninstalldirs: installdirs-recursive\ninstalldirs-am:\n\tfor dir in \"$(DESTDIR)$(pkgconfigdir)\"; do \\\n\t  test -z \"$$dir\" || $(MKDIR_P) \"$$dir\"; \\\n\tdone\ninstall: install-recursive\ninstall-exec: install-exec-recursive\ninstall-data: install-data-recursive\nuninstall: uninstall-recursive\n\ninstall-am: all-am\n\t@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am\n\ninstallcheck: installcheck-recursive\ninstall-strip:\n\tif test -z '$(STRIP)'; then \\\n\t  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM=\"$(INSTALL_STRIP_PROGRAM)\" \\\n\t    install_sh_PROGRAM=\"$(INSTALL_STRIP_PROGRAM)\" INSTALL_STRIP_FLAG=-s \\\n\t      install; \\\n\telse \\\n\t  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM=\"$(INSTALL_STRIP_PROGRAM)\" \\\n\t    install_sh_PROGRAM=\"$(INSTALL_STRIP_PROGRAM)\" INSTALL_STRIP_FLAG=-s \\\n\t    \"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'\" install; \\\n\tfi\nmostlyclean-generic:\n\nclean-generic:\n\ndistclean-generic:\n\t-test -z \"$(CONFIG_CLEAN_FILES)\" || rm -f $(CONFIG_CLEAN_FILES)\n\t-test . = \"$(srcdir)\" || test -z \"$(CONFIG_CLEAN_VPATH_FILES)\" || rm -f $(CONFIG_CLEAN_VPATH_FILES)\n\nmaintainer-clean-generic:\n\t@echo \"This command is intended for maintainers to use\"\n\t@echo \"it deletes files that may require special tools to rebuild.\"\n\t-test -z \"$(MAINTAINERCLEANFILES)\" || rm -f $(MAINTAINERCLEANFILES)\nclean: clean-recursive\n\nclean-am: clean-generic clean-libtool clean-local mostlyclean-am\n\ndistclean: distclean-recursive\n\t-rm -f $(am__CONFIG_DISTCLEAN_FILES)\n\t-rm -f Makefile\ndistclean-am: clean-am distclean-generic distclean-hdr \\\n\tdistclean-libtool distclean-tags\n\ndvi: dvi-recursive\n\ndvi-am:\n\nhtml: html-recursive\n\nhtml-am:\n\ninfo: info-recursive\n\ninfo-am:\n\ninstall-data-am: install-pkgconfigDATA\n\ninstall-dvi: install-dvi-recursive\n\ninstall-dvi-am:\n\ninstall-exec-am:\n\ninstall-html: install-html-recursive\n\ninstall-html-am:\n\ninstall-info: install-info-recursive\n\ninstall-info-am:\n\ninstall-man:\n\ninstall-pdf: install-pdf-recursive\n\ninstall-pdf-am:\n\ninstall-ps: install-ps-recursive\n\ninstall-ps-am:\n\ninstallcheck-am:\n\nmaintainer-clean: maintainer-clean-recursive\n\t-rm -f $(am__CONFIG_DISTCLEAN_FILES)\n\t-rm -rf $(top_srcdir)/autom4te.cache\n\t-rm -f Makefile\nmaintainer-clean-am: distclean-am maintainer-clean-generic\n\nmostlyclean: mostlyclean-recursive\n\nmostlyclean-am: mostlyclean-generic mostlyclean-libtool\n\npdf: pdf-recursive\n\npdf-am:\n\nps: ps-recursive\n\nps-am:\n\nuninstall-am: uninstall-pkgconfigDATA\n\n.MAKE: $(am__recursive_targets) all check-am install-am install-strip\n\n.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \\\n\tam--refresh check check-am check-local clean clean-cscope \\\n\tclean-generic clean-libtool clean-local cscope cscopelist-am \\\n\tctags ctags-am dist dist-all dist-bzip2 dist-gzip dist-lzip \\\n\tdist-shar dist-tarZ dist-xz dist-zip distcheck distclean \\\n\tdistclean-generic distclean-hdr distclean-libtool \\\n\tdistclean-tags distcleancheck distdir distuninstallcheck dvi \\\n\tdvi-am html html-am info info-am install install-am \\\n\tinstall-data install-data-am install-dvi install-dvi-am \\\n\tinstall-exec install-exec-am install-html install-html-am \\\n\tinstall-info install-info-am install-man install-pdf \\\n\tinstall-pdf-am install-pkgconfigDATA install-ps install-ps-am \\\n\tinstall-strip installcheck installcheck-am installdirs \\\n\tinstalldirs-am maintainer-clean maintainer-clean-generic \\\n\tmostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \\\n\tps ps-am tags tags-am uninstall uninstall-am \\\n\tuninstall-pkgconfigDATA\n\n\n# Build gmock before we build protobuf tests.  We don't add gmock to SUBDIRS\n# because then \"make check\" would also build and run all of gmock's own tests,\n# which takes a lot of time and is generally not useful to us.  Also, we don't\n# want \"make install\" to recurse into gmock since we don't want to overwrite\n# the installed version of gmock if there is one.\ncheck-local:\n\t@echo \"Making lib/libgmock.a lib/libgmock_main.a in gmock\"\n\t@cd gmock && $(MAKE) $(AM_MAKEFLAGS) lib/libgmock.la lib/libgmock_main.la\n\t@cd gmock/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la\n\n# We would like to clean gmock when \"make clean\" is invoked.  But we have to\n# be careful because clean-local is also invoked during \"make distclean\", but\n# \"make distclean\" already recurses into gmock because it's listed among the\n# DIST_SUBDIRS.  distclean will delete gmock/Makefile, so if we then try to\n# cd to the directory again and \"make clean\" it will fail.  So, check that the\n# Makefile exists before recursing.\nclean-local:\n\t@if test -e gmock/Makefile; then \\\n\t  echo \"Making clean in gmock\"; \\\n\t  cd gmock && $(MAKE) $(AM_MAKEFLAGS) clean; \\\n\tfi; \\\n\tif test -e conformance/Makefile; then \\\n\t  echo \"Making clean in conformance\"; \\\n\t  cd conformance && $(MAKE) $(AM_MAKEFLAGS) clean; \\\n\tfi; \\\n\tif test -e benchmarks/Makefile; then \\\n\t  echo \"Making clean in benchmarks\"; \\\n\t  cd benchmarks && $(MAKE) $(AM_MAKEFLAGS) clean; \\\n\tfi; \\\n\tif test -e objectivec/DevTools; then \\\n\t  echo \"Cleaning any ObjC pyc files\"; \\\n\t  rm -f objectivec/DevTools/*.pyc; \\\n\tfi\n\n# Tell versions [3.59,3.63) of GNU make to not export all variables.\n# Otherwise a system limit (for SysV at least) may be exceeded.\n.NOEXPORT:\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/README.md",
    "content": "Protocol Buffers - Google's data interchange format\n===================================================\n\n[![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https://travis-ci.org/google/protobuf) [![Build status](https://ci.appveyor.com/api/projects/status/73ctee6ua4w2ruin?svg=true)](https://ci.appveyor.com/project/protobuf/protobuf)\n\nCopyright 2008 Google Inc.\n\nhttps://developers.google.com/protocol-buffers/\n\nOverview\n--------\n\nProtocol Buffers (a.k.a., protobuf) are Google's language-neutral,\nplatform-neutral, extensible mechanism for serializing structured data. You\ncan find [protobuf's documentation on the Google Developers site](https://developers.google.com/protocol-buffers/).\n\nThis README file contains protobuf installation instructions. To install\nprotobuf, you need to install the protocol compiler (used to compile .proto\nfiles) and the protobuf runtime for your chosen programming language.\n\nProtocol Compiler Installation\n------------------------------\n\nThe protocol compiler is written in C++. If you are using C++, please follow\nthe [C++ Installation Instructions](src/README.md) to install protoc along\nwith the C++ runtime.\n\nFor non-C++ users, the simplest way to install the protocol compiler is to\ndownload a pre-built binary from our release page:\n\n  [https://github.com/google/protobuf/releases](https://github.com/google/protobuf/releases)\n\nIn the downloads section of each release, you can find pre-built binaries in\nzip packages: protoc-$VERSION-$PLATFORM.zip. It contains the protoc binary\nas well as a set of standard .proto files distributed along with protobuf.\n\nIf you are looking for an old version that is not available in the release\npage, check out the maven repo here:\n\n  [http://repo1.maven.org/maven2/com/google/protobuf/protoc/](http://repo1.maven.org/maven2/com/google/protobuf/protoc/)\n\nThese pre-built binaries are only provided for released versions. If you want\nto use the github master version at HEAD, or you need to modify protobuf code,\nor you are using C++, it's recommended to build your own protoc binary from\nsource.\n\nIf you would like to build protoc binary from source, see the [C++ Installation\nInstructions](src/README.md).\n\nProtobuf Runtime Installation\n-----------------------------\n\nProtobuf supports several different programming languages. For each programming\nlanguage, you can find instructions in the corresponding source directory about\nhow to install protobuf runtime for that specific language:\n\n| Language                             | Source                                                |\n|--------------------------------------|-------------------------------------------------------|\n| C++ (include C++ runtime and protoc) | [src](src)                                            |\n| Java                                 | [java](java)                                          |\n| Python                               | [python](python)                                      |\n| Objective-C                          | [objectivec](objectivec)                              |\n| C#                                   | [csharp](csharp)                                      |\n| JavaNano                             | [javanano](javanano)                                  |\n| JavaScript                           | [js](js)                                              |\n| Ruby                                 | [ruby](ruby)                                          |\n| Go                                   | [golang/protobuf](https://github.com/golang/protobuf) |\n| PHP                                  | TBD                                                   |\n\n\nUsage\n-----\n\nThe complete documentation for Protocol Buffers is available via the\nweb at:\n\n    https://developers.google.com/protocol-buffers/\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/WORKSPACE",
    "content": "new_http_archive(\n    name = \"gmock_archive\",\n    url = \"https://googlemock.googlecode.com/files/gmock-1.7.0.zip\",\n    sha256 = \"26fcbb5925b74ad5fc8c26b0495dfc96353f4d553492eb97e85a8a6d2f43095b\",\n    build_file = \"gmock.BUILD\",\n)\n\nnew_http_archive(\n    name = \"six_archive\",\n    url = \"https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55\",\n    sha256 = \"105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a\",\n    build_file = \"six.BUILD\",\n)\n\nbind(\n    name = \"python_headers\",\n    actual = \"//util/python:python_headers\",\n)\n\nbind(\n    name = \"gtest\",\n    actual = \"@gmock_archive//:gtest\",\n)\n\nbind(\n    name = \"gtest_main\",\n    actual = \"@gmock_archive//:gtest_main\",\n)\n\nbind(\n    name = \"six\",\n    actual = \"@six_archive//:six\",\n)\n\nmaven_jar(\n  name = \"guava_maven\",\n  artifact = \"com.google.guava:guava:18.0\",\n)\n\nbind(\n    name = \"guava\",\n    actual = \"@guava_maven//jar\",\n)\n\nmaven_jar(\n  name = \"gson_maven\",\n  artifact = \"com.google.code.gson:gson:2.3\",\n)\n\nbind(\n    name = \"gson\",\n    actual = \"@gson_maven//jar\",\n)\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/aclocal.m4",
    "content": "# generated automatically by aclocal 1.14.1 -*- Autoconf -*-\n\n# Copyright (C) 1996-2013 Free Software Foundation, Inc.\n\n# This file is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY, to the extent permitted by law; without\n# even the implied warranty of MERCHANTABILITY or FITNESS FOR A\n# PARTICULAR PURPOSE.\n\nm4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])\nm4_ifndef([AC_AUTOCONF_VERSION],\n  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl\nm4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,\n[m4_warning([this file was generated for autoconf 2.69.\nYou have another version of autoconf.  It may work, but is not guaranteed to.\nIf you have problems, you may need to regenerate the build system entirely.\nTo do so, use the procedure documented by the package, typically 'autoreconf'.])])\n\n# Copyright (C) 2002-2013 Free Software Foundation, Inc.\n#\n# This file is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n# AM_AUTOMAKE_VERSION(VERSION)\n# ----------------------------\n# Automake X.Y traces this macro to ensure aclocal.m4 has been\n# generated from the m4 files accompanying Automake X.Y.\n# (This private macro should not be called outside this file.)\nAC_DEFUN([AM_AUTOMAKE_VERSION],\n[am__api_version='1.14'\ndnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to\ndnl require some minimum version.  Point them to the right macro.\nm4_if([$1], [1.14.1], [],\n      [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl\n])\n\n# _AM_AUTOCONF_VERSION(VERSION)\n# -----------------------------\n# aclocal traces this macro to find the Autoconf version.\n# This is a private macro too.  Using m4_define simplifies\n# the logic in aclocal, which can simply ignore this definition.\nm4_define([_AM_AUTOCONF_VERSION], [])\n\n# AM_SET_CURRENT_AUTOMAKE_VERSION\n# -------------------------------\n# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.\n# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.\nAC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],\n[AM_AUTOMAKE_VERSION([1.14.1])dnl\nm4_ifndef([AC_AUTOCONF_VERSION],\n  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl\n_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])\n\n# Copyright (C) 2011-2013 Free Software Foundation, Inc.\n#\n# This file is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n# AM_PROG_AR([ACT-IF-FAIL])\n# -------------------------\n# Try to determine the archiver interface, and trigger the ar-lib wrapper\n# if it is needed.  If the detection of archiver interface fails, run\n# ACT-IF-FAIL (default is to abort configure with a proper error message).\nAC_DEFUN([AM_PROG_AR],\n[AC_BEFORE([$0], [LT_INIT])dnl\nAC_BEFORE([$0], [AC_PROG_LIBTOOL])dnl\nAC_REQUIRE([AM_AUX_DIR_EXPAND])dnl\nAC_REQUIRE_AUX_FILE([ar-lib])dnl\nAC_CHECK_TOOLS([AR], [ar lib \"link -lib\"], [false])\n: ${AR=ar}\n\nAC_CACHE_CHECK([the archiver ($AR) interface], [am_cv_ar_interface],\n  [AC_LANG_PUSH([C])\n   am_cv_ar_interface=ar\n   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int some_variable = 0;]])],\n     [am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&AS_MESSAGE_LOG_FD'\n      AC_TRY_EVAL([am_ar_try])\n      if test \"$ac_status\" -eq 0; then\n        am_cv_ar_interface=ar\n      else\n        am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&AS_MESSAGE_LOG_FD'\n        AC_TRY_EVAL([am_ar_try])\n        if test \"$ac_status\" -eq 0; then\n          am_cv_ar_interface=lib\n        else\n          am_cv_ar_interface=unknown\n        fi\n      fi\n      rm -f conftest.lib libconftest.a\n     ])\n   AC_LANG_POP([C])])\n\ncase $am_cv_ar_interface in\nar)\n  ;;\nlib)\n  # Microsoft lib, so override with the ar-lib wrapper script.\n  # FIXME: It is wrong to rewrite AR.\n  # But if we don't then we get into trouble of one sort or another.\n  # A longer-term fix would be to have automake use am__AR in this case,\n  # and then we could set am__AR=\"$am_aux_dir/ar-lib \\$(AR)\" or something\n  # similar.\n  AR=\"$am_aux_dir/ar-lib $AR\"\n  ;;\nunknown)\n  m4_default([$1],\n             [AC_MSG_ERROR([could not determine $AR interface])])\n  ;;\nesac\nAC_SUBST([AR])dnl\n])\n\n# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-\n\n# Copyright (C) 2001-2013 Free Software Foundation, Inc.\n#\n# This file is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets\n# $ac_aux_dir to '$srcdir/foo'.  In other projects, it is set to\n# '$srcdir', '$srcdir/..', or '$srcdir/../..'.\n#\n# Of course, Automake must honor this variable whenever it calls a\n# tool from the auxiliary directory.  The problem is that $srcdir (and\n# therefore $ac_aux_dir as well) can be either absolute or relative,\n# depending on how configure is run.  This is pretty annoying, since\n# it makes $ac_aux_dir quite unusable in subdirectories: in the top\n# source directory, any form will work fine, but in subdirectories a\n# relative path needs to be adjusted first.\n#\n# $ac_aux_dir/missing\n#    fails when called from a subdirectory if $ac_aux_dir is relative\n# $top_srcdir/$ac_aux_dir/missing\n#    fails if $ac_aux_dir is absolute,\n#    fails when called from a subdirectory in a VPATH build with\n#          a relative $ac_aux_dir\n#\n# The reason of the latter failure is that $top_srcdir and $ac_aux_dir\n# are both prefixed by $srcdir.  In an in-source build this is usually\n# harmless because $srcdir is '.', but things will broke when you\n# start a VPATH build or use an absolute $srcdir.\n#\n# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,\n# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:\n#   am_aux_dir='\\$(top_srcdir)/'`expr \"$ac_aux_dir\" : \"$srcdir//*\\(.*\\)\"`\n# and then we would define $MISSING as\n#   MISSING=\"\\${SHELL} $am_aux_dir/missing\"\n# This will work as long as MISSING is not called from configure, because\n# unfortunately $(top_srcdir) has no meaning in configure.\n# However there are other variables, like CC, which are often used in\n# configure, and could therefore not use this \"fixed\" $ac_aux_dir.\n#\n# Another solution, used here, is to always expand $ac_aux_dir to an\n# absolute PATH.  The drawback is that using absolute paths prevent a\n# configured tree to be moved without reconfiguration.\n\nAC_DEFUN([AM_AUX_DIR_EXPAND],\n[dnl Rely on autoconf to set up CDPATH properly.\nAC_PREREQ([2.50])dnl\n# expand $ac_aux_dir to an absolute path\nam_aux_dir=`cd $ac_aux_dir && pwd`\n])\n\n# AM_CONDITIONAL                                            -*- Autoconf -*-\n\n# Copyright (C) 1997-2013 Free Software Foundation, Inc.\n#\n# This file is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n# AM_CONDITIONAL(NAME, SHELL-CONDITION)\n# -------------------------------------\n# Define a conditional.\nAC_DEFUN([AM_CONDITIONAL],\n[AC_PREREQ([2.52])dnl\n m4_if([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],\n       [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl\nAC_SUBST([$1_TRUE])dnl\nAC_SUBST([$1_FALSE])dnl\n_AM_SUBST_NOTMAKE([$1_TRUE])dnl\n_AM_SUBST_NOTMAKE([$1_FALSE])dnl\nm4_define([_AM_COND_VALUE_$1], [$2])dnl\nif $2; then\n  $1_TRUE=\n  $1_FALSE='#'\nelse\n  $1_TRUE='#'\n  $1_FALSE=\nfi\nAC_CONFIG_COMMANDS_PRE(\n[if test -z \"${$1_TRUE}\" && test -z \"${$1_FALSE}\"; then\n  AC_MSG_ERROR([[conditional \"$1\" was never defined.\nUsually this means the macro was only invoked conditionally.]])\nfi])])\n\n# Copyright (C) 1999-2013 Free Software Foundation, Inc.\n#\n# This file is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n\n# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be\n# written in clear, in which case automake, when reading aclocal.m4,\n# will think it sees a *use*, and therefore will trigger all it's\n# C support machinery.  Also note that it means that autoscan, seeing\n# CC etc. in the Makefile, will ask for an AC_PROG_CC use...\n\n\n# _AM_DEPENDENCIES(NAME)\n# ----------------------\n# See how the compiler implements dependency checking.\n# NAME is \"CC\", \"CXX\", \"OBJC\", \"OBJCXX\", \"UPC\", or \"GJC\".\n# We try a few techniques and use that to set a single cache variable.\n#\n# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was\n# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular\n# dependency, and given that the user is not expected to run this macro,\n# just rely on AC_PROG_CC.\nAC_DEFUN([_AM_DEPENDENCIES],\n[AC_REQUIRE([AM_SET_DEPDIR])dnl\nAC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl\nAC_REQUIRE([AM_MAKE_INCLUDE])dnl\nAC_REQUIRE([AM_DEP_TRACK])dnl\n\nm4_if([$1], [CC],   [depcc=\"$CC\"   am_compiler_list=],\n      [$1], [CXX],  [depcc=\"$CXX\"  am_compiler_list=],\n      [$1], [OBJC], [depcc=\"$OBJC\" am_compiler_list='gcc3 gcc'],\n      [$1], [OBJCXX], [depcc=\"$OBJCXX\" am_compiler_list='gcc3 gcc'],\n      [$1], [UPC],  [depcc=\"$UPC\"  am_compiler_list=],\n      [$1], [GCJ],  [depcc=\"$GCJ\"  am_compiler_list='gcc3 gcc'],\n                    [depcc=\"$$1\"   am_compiler_list=])\n\nAC_CACHE_CHECK([dependency style of $depcc],\n               [am_cv_$1_dependencies_compiler_type],\n[if test -z \"$AMDEP_TRUE\" && test -f \"$am_depcomp\"; then\n  # We make a subdir and do the tests there.  Otherwise we can end up\n  # making bogus files that we don't know about and never remove.  For\n  # instance it was reported that on HP-UX the gcc test will end up\n  # making a dummy file named 'D' -- because '-MD' means \"put the output\n  # in D\".\n  rm -rf conftest.dir\n  mkdir conftest.dir\n  # Copy depcomp to subdir because otherwise we won't find it if we're\n  # using a relative directory.\n  cp \"$am_depcomp\" conftest.dir\n  cd conftest.dir\n  # We will build objects and dependencies in a subdirectory because\n  # it helps to detect inapplicable dependency modes.  For instance\n  # both Tru64's cc and ICC support -MD to output dependencies as a\n  # side effect of compilation, but ICC will put the dependencies in\n  # the current directory while Tru64 will put them in the object\n  # directory.\n  mkdir sub\n\n  am_cv_$1_dependencies_compiler_type=none\n  if test \"$am_compiler_list\" = \"\"; then\n     am_compiler_list=`sed -n ['s/^#*\\([a-zA-Z0-9]*\\))$/\\1/p'] < ./depcomp`\n  fi\n  am__universal=false\n  m4_case([$1], [CC],\n    [case \" $depcc \" in #(\n     *\\ -arch\\ *\\ -arch\\ *) am__universal=true ;;\n     esac],\n    [CXX],\n    [case \" $depcc \" in #(\n     *\\ -arch\\ *\\ -arch\\ *) am__universal=true ;;\n     esac])\n\n  for depmode in $am_compiler_list; do\n    # Setup a source with many dependencies, because some compilers\n    # like to wrap large dependency lists on column 80 (with \\), and\n    # we should not choose a depcomp mode which is confused by this.\n    #\n    # We need to recreate these files for each test, as the compiler may\n    # overwrite some of them when testing with obscure command lines.\n    # This happens at least with the AIX C compiler.\n    : > sub/conftest.c\n    for i in 1 2 3 4 5 6; do\n      echo '#include \"conftst'$i'.h\"' >> sub/conftest.c\n      # Using \": > sub/conftst$i.h\" creates only sub/conftst1.h with\n      # Solaris 10 /bin/sh.\n      echo '/* dummy */' > sub/conftst$i.h\n    done\n    echo \"${am__include} ${am__quote}sub/conftest.Po${am__quote}\" > confmf\n\n    # We check with '-c' and '-o' for the sake of the \"dashmstdout\"\n    # mode.  It turns out that the SunPro C++ compiler does not properly\n    # handle '-M -o', and we need to detect this.  Also, some Intel\n    # versions had trouble with output in subdirs.\n    am__obj=sub/conftest.${OBJEXT-o}\n    am__minus_obj=\"-o $am__obj\"\n    case $depmode in\n    gcc)\n      # This depmode causes a compiler race in universal mode.\n      test \"$am__universal\" = false || continue\n      ;;\n    nosideeffect)\n      # After this tag, mechanisms are not by side-effect, so they'll\n      # only be used when explicitly requested.\n      if test \"x$enable_dependency_tracking\" = xyes; then\n\tcontinue\n      else\n\tbreak\n      fi\n      ;;\n    msvc7 | msvc7msys | msvisualcpp | msvcmsys)\n      # This compiler won't grok '-c -o', but also, the minuso test has\n      # not run yet.  These depmodes are late enough in the game, and\n      # so weak that their functioning should not be impacted.\n      am__obj=conftest.${OBJEXT-o}\n      am__minus_obj=\n      ;;\n    none) break ;;\n    esac\n    if depmode=$depmode \\\n       source=sub/conftest.c object=$am__obj \\\n       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \\\n       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \\\n         >/dev/null 2>conftest.err &&\n       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&\n       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&\n       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&\n       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then\n      # icc doesn't choke on unknown options, it will just issue warnings\n      # or remarks (even with -Werror).  So we grep stderr for any message\n      # that says an option was ignored or not supported.\n      # When given -MP, icc 7.0 and 7.1 complain thusly:\n      #   icc: Command line warning: ignoring option '-M'; no argument required\n      # The diagnosis changed in icc 8.0:\n      #   icc: Command line remark: option '-MP' not supported\n      if (grep 'ignoring option' conftest.err ||\n          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else\n        am_cv_$1_dependencies_compiler_type=$depmode\n        break\n      fi\n    fi\n  done\n\n  cd ..\n  rm -rf conftest.dir\nelse\n  am_cv_$1_dependencies_compiler_type=none\nfi\n])\nAC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])\nAM_CONDITIONAL([am__fastdep$1], [\n  test \"x$enable_dependency_tracking\" != xno \\\n  && test \"$am_cv_$1_dependencies_compiler_type\" = gcc3])\n])\n\n\n# AM_SET_DEPDIR\n# -------------\n# Choose a directory name for dependency files.\n# This macro is AC_REQUIREd in _AM_DEPENDENCIES.\nAC_DEFUN([AM_SET_DEPDIR],\n[AC_REQUIRE([AM_SET_LEADING_DOT])dnl\nAC_SUBST([DEPDIR], [\"${am__leading_dot}deps\"])dnl\n])\n\n\n# AM_DEP_TRACK\n# ------------\nAC_DEFUN([AM_DEP_TRACK],\n[AC_ARG_ENABLE([dependency-tracking], [dnl\nAS_HELP_STRING(\n  [--enable-dependency-tracking],\n  [do not reject slow dependency extractors])\nAS_HELP_STRING(\n  [--disable-dependency-tracking],\n  [speeds up one-time build])])\nif test \"x$enable_dependency_tracking\" != xno; then\n  am_depcomp=\"$ac_aux_dir/depcomp\"\n  AMDEPBACKSLASH='\\'\n  am__nodep='_no'\nfi\nAM_CONDITIONAL([AMDEP], [test \"x$enable_dependency_tracking\" != xno])\nAC_SUBST([AMDEPBACKSLASH])dnl\n_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl\nAC_SUBST([am__nodep])dnl\n_AM_SUBST_NOTMAKE([am__nodep])dnl\n])\n\n# Generate code to set up dependency tracking.              -*- Autoconf -*-\n\n# Copyright (C) 1999-2013 Free Software Foundation, Inc.\n#\n# This file is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n\n# _AM_OUTPUT_DEPENDENCY_COMMANDS\n# ------------------------------\nAC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],\n[{\n  # Older Autoconf quotes --file arguments for eval, but not when files\n  # are listed without --file.  Let's play safe and only enable the eval\n  # if we detect the quoting.\n  case $CONFIG_FILES in\n  *\\'*) eval set x \"$CONFIG_FILES\" ;;\n  *)   set x $CONFIG_FILES ;;\n  esac\n  shift\n  for mf\n  do\n    # Strip MF so we end up with the name of the file.\n    mf=`echo \"$mf\" | sed -e 's/:.*$//'`\n    # Check whether this is an Automake generated Makefile or not.\n    # We used to match only the files named 'Makefile.in', but\n    # some people rename them; so instead we look at the file content.\n    # Grep'ing the first line is not enough: some people post-process\n    # each Makefile.in and add a new line on top of each file to say so.\n    # Grep'ing the whole file is not good either: AIX grep has a line\n    # limit of 2048, but all sed's we know have understand at least 4000.\n    if sed -n 's,^#.*generated by automake.*,X,p' \"$mf\" | grep X >/dev/null 2>&1; then\n      dirpart=`AS_DIRNAME(\"$mf\")`\n    else\n      continue\n    fi\n    # Extract the definition of DEPDIR, am__include, and am__quote\n    # from the Makefile without running 'make'.\n    DEPDIR=`sed -n 's/^DEPDIR = //p' < \"$mf\"`\n    test -z \"$DEPDIR\" && continue\n    am__include=`sed -n 's/^am__include = //p' < \"$mf\"`\n    test -z \"$am__include\" && continue\n    am__quote=`sed -n 's/^am__quote = //p' < \"$mf\"`\n    # Find all dependency output files, they are included files with\n    # $(DEPDIR) in their names.  We invoke sed twice because it is the\n    # simplest approach to changing $(DEPDIR) to its actual value in the\n    # expansion.\n    for file in `sed -n \"\n      s/^$am__include $am__quote\\(.*(DEPDIR).*\\)$am__quote\"'$/\\1/p' <\"$mf\" | \\\n\t sed -e 's/\\$(DEPDIR)/'\"$DEPDIR\"'/g'`; do\n      # Make sure the directory exists.\n      test -f \"$dirpart/$file\" && continue\n      fdir=`AS_DIRNAME([\"$file\"])`\n      AS_MKDIR_P([$dirpart/$fdir])\n      # echo \"creating $dirpart/$file\"\n      echo '# dummy' > \"$dirpart/$file\"\n    done\n  done\n}\n])# _AM_OUTPUT_DEPENDENCY_COMMANDS\n\n\n# AM_OUTPUT_DEPENDENCY_COMMANDS\n# -----------------------------\n# This macro should only be invoked once -- use via AC_REQUIRE.\n#\n# This code is only required when automatic dependency tracking\n# is enabled.  FIXME.  This creates each '.P' file that we will\n# need in order to bootstrap the dependency handling code.\nAC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],\n[AC_CONFIG_COMMANDS([depfiles],\n     [test x\"$AMDEP_TRUE\" != x\"\" || _AM_OUTPUT_DEPENDENCY_COMMANDS],\n     [AMDEP_TRUE=\"$AMDEP_TRUE\" ac_aux_dir=\"$ac_aux_dir\"])\n])\n\n# Do all the work for Automake.                             -*- Autoconf -*-\n\n# Copyright (C) 1996-2013 Free Software Foundation, Inc.\n#\n# This file is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n# This macro actually does too much.  Some checks are only needed if\n# your package does certain things.  But this isn't really a big deal.\n\ndnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O.\nm4_define([AC_PROG_CC],\nm4_defn([AC_PROG_CC])\n[_AM_PROG_CC_C_O\n])\n\n# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])\n# AM_INIT_AUTOMAKE([OPTIONS])\n# -----------------------------------------------\n# The call with PACKAGE and VERSION arguments is the old style\n# call (pre autoconf-2.50), which is being phased out.  PACKAGE\n# and VERSION should now be passed to AC_INIT and removed from\n# the call to AM_INIT_AUTOMAKE.\n# We support both call styles for the transition.  After\n# the next Automake release, Autoconf can make the AC_INIT\n# arguments mandatory, and then we can depend on a new Autoconf\n# release and drop the old call support.\nAC_DEFUN([AM_INIT_AUTOMAKE],\n[AC_PREREQ([2.65])dnl\ndnl Autoconf wants to disallow AM_ names.  We explicitly allow\ndnl the ones we care about.\nm4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl\nAC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl\nAC_REQUIRE([AC_PROG_INSTALL])dnl\nif test \"`cd $srcdir && pwd`\" != \"`pwd`\"; then\n  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output\n  # is not polluted with repeated \"-I.\"\n  AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl\n  # test to see if srcdir already configured\n  if test -f $srcdir/config.status; then\n    AC_MSG_ERROR([source directory already configured; run \"make distclean\" there first])\n  fi\nfi\n\n# test whether we have cygpath\nif test -z \"$CYGPATH_W\"; then\n  if (cygpath --version) >/dev/null 2>/dev/null; then\n    CYGPATH_W='cygpath -w'\n  else\n    CYGPATH_W=echo\n  fi\nfi\nAC_SUBST([CYGPATH_W])\n\n# Define the identity of the package.\ndnl Distinguish between old-style and new-style calls.\nm4_ifval([$2],\n[AC_DIAGNOSE([obsolete],\n             [$0: two- and three-arguments forms are deprecated.])\nm4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl\n AC_SUBST([PACKAGE], [$1])dnl\n AC_SUBST([VERSION], [$2])],\n[_AM_SET_OPTIONS([$1])dnl\ndnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.\nm4_if(\n  m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),\n  [ok:ok],,\n  [m4_fatal([AC_INIT should be called with package and version arguments])])dnl\n AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl\n AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl\n\n_AM_IF_OPTION([no-define],,\n[AC_DEFINE_UNQUOTED([PACKAGE], [\"$PACKAGE\"], [Name of package])\n AC_DEFINE_UNQUOTED([VERSION], [\"$VERSION\"], [Version number of package])])dnl\n\n# Some tools Automake needs.\nAC_REQUIRE([AM_SANITY_CHECK])dnl\nAC_REQUIRE([AC_ARG_PROGRAM])dnl\nAM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])\nAM_MISSING_PROG([AUTOCONF], [autoconf])\nAM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])\nAM_MISSING_PROG([AUTOHEADER], [autoheader])\nAM_MISSING_PROG([MAKEINFO], [makeinfo])\nAC_REQUIRE([AM_PROG_INSTALL_SH])dnl\nAC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl\nAC_REQUIRE([AC_PROG_MKDIR_P])dnl\n# For better backward compatibility.  To be removed once Automake 1.9.x\n# dies out for good.  For more background, see:\n# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>\n# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>\nAC_SUBST([mkdir_p], ['$(MKDIR_P)'])\n# We need awk for the \"check\" target.  The system \"awk\" is bad on\n# some platforms.\nAC_REQUIRE([AC_PROG_AWK])dnl\nAC_REQUIRE([AC_PROG_MAKE_SET])dnl\nAC_REQUIRE([AM_SET_LEADING_DOT])dnl\n_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],\n\t      [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],\n\t\t\t     [_AM_PROG_TAR([v7])])])\n_AM_IF_OPTION([no-dependencies],,\n[AC_PROVIDE_IFELSE([AC_PROG_CC],\n\t\t  [_AM_DEPENDENCIES([CC])],\n\t\t  [m4_define([AC_PROG_CC],\n\t\t\t     m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl\nAC_PROVIDE_IFELSE([AC_PROG_CXX],\n\t\t  [_AM_DEPENDENCIES([CXX])],\n\t\t  [m4_define([AC_PROG_CXX],\n\t\t\t     m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl\nAC_PROVIDE_IFELSE([AC_PROG_OBJC],\n\t\t  [_AM_DEPENDENCIES([OBJC])],\n\t\t  [m4_define([AC_PROG_OBJC],\n\t\t\t     m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl\nAC_PROVIDE_IFELSE([AC_PROG_OBJCXX],\n\t\t  [_AM_DEPENDENCIES([OBJCXX])],\n\t\t  [m4_define([AC_PROG_OBJCXX],\n\t\t\t     m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl\n])\nAC_REQUIRE([AM_SILENT_RULES])dnl\ndnl The testsuite driver may need to know about EXEEXT, so add the\ndnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This\ndnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.\nAC_CONFIG_COMMANDS_PRE(dnl\n[m4_provide_if([_AM_COMPILER_EXEEXT],\n  [AM_CONDITIONAL([am__EXEEXT], [test -n \"$EXEEXT\"])])])dnl\n\n# POSIX will say in a future version that running \"rm -f\" with no argument\n# is OK; and we want to be able to make that assumption in our Makefile\n# recipes.  So use an aggressive probe to check that the usage we want is\n# actually supported \"in the wild\" to an acceptable degree.\n# See automake bug#10828.\n# To make any issue more visible, cause the running configure to be aborted\n# by default if the 'rm' program in use doesn't match our expectations; the\n# user can still override this though.\nif rm -f && rm -fr && rm -rf; then : OK; else\n  cat >&2 <<'END'\nOops!\n\nYour 'rm' program seems unable to run without file operands specified\non the command line, even when the '-f' option is present.  This is contrary\nto the behaviour of most rm programs out there, and not conforming with\nthe upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>\n\nPlease tell bug-automake@gnu.org about your system, including the value\nof your $PATH and any error possibly output before this message.  This\ncan help us improve future automake versions.\n\nEND\n  if test x\"$ACCEPT_INFERIOR_RM_PROGRAM\" = x\"yes\"; then\n    echo 'Configuration will proceed anyway, since you have set the' >&2\n    echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to \"yes\"' >&2\n    echo >&2\n  else\n    cat >&2 <<'END'\nAborting the configuration process, to ensure you take notice of the issue.\n\nYou can download and install GNU coreutils to get an 'rm' implementation\nthat behaves properly: <http://www.gnu.org/software/coreutils/>.\n\nIf you want to complete the configuration process using your problematic\n'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM\nto \"yes\", and re-run configure.\n\nEND\n    AC_MSG_ERROR([Your 'rm' program is bad, sorry.])\n  fi\nfi])\n\ndnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not\ndnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further\ndnl mangled by Autoconf and run in a shell conditional statement.\nm4_define([_AC_COMPILER_EXEEXT],\nm4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])\n\n# When config.status generates a header, we must update the stamp-h file.\n# This file resides in the same directory as the config header\n# that is generated.  The stamp files are numbered to have different names.\n\n# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the\n# loop where config.status creates the headers, so we can generate\n# our stamp files there.\nAC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],\n[# Compute $1's index in $config_headers.\n_am_arg=$1\n_am_stamp_count=1\nfor _am_header in $config_headers :; do\n  case $_am_header in\n    $_am_arg | $_am_arg:* )\n      break ;;\n    * )\n      _am_stamp_count=`expr $_am_stamp_count + 1` ;;\n  esac\ndone\necho \"timestamp for $_am_arg\" >`AS_DIRNAME([\"$_am_arg\"])`/stamp-h[]$_am_stamp_count])\n\n# Copyright (C) 2001-2013 Free Software Foundation, Inc.\n#\n# This file is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n# AM_PROG_INSTALL_SH\n# ------------------\n# Define $install_sh.\nAC_DEFUN([AM_PROG_INSTALL_SH],\n[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl\nif test x\"${install_sh}\" != xset; then\n  case $am_aux_dir in\n  *\\ * | *\\\t*)\n    install_sh=\"\\${SHELL} '$am_aux_dir/install-sh'\" ;;\n  *)\n    install_sh=\"\\${SHELL} $am_aux_dir/install-sh\"\n  esac\nfi\nAC_SUBST([install_sh])])\n\n# Copyright (C) 2003-2013 Free Software Foundation, Inc.\n#\n# This file is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n# Check whether the underlying file-system supports filenames\n# with a leading dot.  For instance MS-DOS doesn't.\nAC_DEFUN([AM_SET_LEADING_DOT],\n[rm -rf .tst 2>/dev/null\nmkdir .tst 2>/dev/null\nif test -d .tst; then\n  am__leading_dot=.\nelse\n  am__leading_dot=_\nfi\nrmdir .tst 2>/dev/null\nAC_SUBST([am__leading_dot])])\n\n# Add --enable-maintainer-mode option to configure.         -*- Autoconf -*-\n# From Jim Meyering\n\n# Copyright (C) 1996-2013 Free Software Foundation, Inc.\n#\n# This file is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n# AM_MAINTAINER_MODE([DEFAULT-MODE])\n# ----------------------------------\n# Control maintainer-specific portions of Makefiles.\n# Default is to disable them, unless 'enable' is passed literally.\n# For symmetry, 'disable' may be passed as well.  Anyway, the user\n# can override the default with the --enable/--disable switch.\nAC_DEFUN([AM_MAINTAINER_MODE],\n[m4_case(m4_default([$1], [disable]),\n       [enable], [m4_define([am_maintainer_other], [disable])],\n       [disable], [m4_define([am_maintainer_other], [enable])],\n       [m4_define([am_maintainer_other], [enable])\n        m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])])\nAC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])\n  dnl maintainer-mode's default is 'disable' unless 'enable' is passed\n  AC_ARG_ENABLE([maintainer-mode],\n    [AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode],\n      am_maintainer_other[ make rules and dependencies not useful\n      (and sometimes confusing) to the casual installer])],\n    [USE_MAINTAINER_MODE=$enableval],\n    [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes]))\n  AC_MSG_RESULT([$USE_MAINTAINER_MODE])\n  AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes])\n  MAINT=$MAINTAINER_MODE_TRUE\n  AC_SUBST([MAINT])dnl\n]\n)\n\n# Check to see how 'make' treats includes.\t            -*- Autoconf -*-\n\n# Copyright (C) 2001-2013 Free Software Foundation, Inc.\n#\n# This file is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n# AM_MAKE_INCLUDE()\n# -----------------\n# Check to see how make treats includes.\nAC_DEFUN([AM_MAKE_INCLUDE],\n[am_make=${MAKE-make}\ncat > confinc << 'END'\nam__doit:\n\t@echo this is the am__doit target\n.PHONY: am__doit\nEND\n# If we don't find an include directive, just comment out the code.\nAC_MSG_CHECKING([for style of include used by $am_make])\nam__include=\"#\"\nam__quote=\n_am_result=none\n# First try GNU make style include.\necho \"include confinc\" > confmf\n# Ignore all kinds of additional output from 'make'.\ncase `$am_make -s -f confmf 2> /dev/null` in #(\n*the\\ am__doit\\ target*)\n  am__include=include\n  am__quote=\n  _am_result=GNU\n  ;;\nesac\n# Now try BSD make style include.\nif test \"$am__include\" = \"#\"; then\n   echo '.include \"confinc\"' > confmf\n   case `$am_make -s -f confmf 2> /dev/null` in #(\n   *the\\ am__doit\\ target*)\n     am__include=.include\n     am__quote=\"\\\"\"\n     _am_result=BSD\n     ;;\n   esac\nfi\nAC_SUBST([am__include])\nAC_SUBST([am__quote])\nAC_MSG_RESULT([$_am_result])\nrm -f confinc confmf\n])\n\n# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-\n\n# Copyright (C) 1997-2013 Free Software Foundation, Inc.\n#\n# This file is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n# AM_MISSING_PROG(NAME, PROGRAM)\n# ------------------------------\nAC_DEFUN([AM_MISSING_PROG],\n[AC_REQUIRE([AM_MISSING_HAS_RUN])\n$1=${$1-\"${am_missing_run}$2\"}\nAC_SUBST($1)])\n\n# AM_MISSING_HAS_RUN\n# ------------------\n# Define MISSING if not defined so far and test if it is modern enough.\n# If it is, set am_missing_run to use it, otherwise, to nothing.\nAC_DEFUN([AM_MISSING_HAS_RUN],\n[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl\nAC_REQUIRE_AUX_FILE([missing])dnl\nif test x\"${MISSING+set}\" != xset; then\n  case $am_aux_dir in\n  *\\ * | *\\\t*)\n    MISSING=\"\\${SHELL} \\\"$am_aux_dir/missing\\\"\" ;;\n  *)\n    MISSING=\"\\${SHELL} $am_aux_dir/missing\" ;;\n  esac\nfi\n# Use eval to expand $SHELL\nif eval \"$MISSING --is-lightweight\"; then\n  am_missing_run=\"$MISSING \"\nelse\n  am_missing_run=\n  AC_MSG_WARN(['missing' script is too old or missing])\nfi\n])\n\n# Helper functions for option handling.                     -*- Autoconf -*-\n\n# Copyright (C) 2001-2013 Free Software Foundation, Inc.\n#\n# This file is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n# _AM_MANGLE_OPTION(NAME)\n# -----------------------\nAC_DEFUN([_AM_MANGLE_OPTION],\n[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])\n\n# _AM_SET_OPTION(NAME)\n# --------------------\n# Set option NAME.  Presently that only means defining a flag for this option.\nAC_DEFUN([_AM_SET_OPTION],\n[m4_define(_AM_MANGLE_OPTION([$1]), [1])])\n\n# _AM_SET_OPTIONS(OPTIONS)\n# ------------------------\n# OPTIONS is a space-separated list of Automake options.\nAC_DEFUN([_AM_SET_OPTIONS],\n[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])\n\n# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])\n# -------------------------------------------\n# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.\nAC_DEFUN([_AM_IF_OPTION],\n[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])\n\n# Copyright (C) 1999-2013 Free Software Foundation, Inc.\n#\n# This file is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n# _AM_PROG_CC_C_O\n# ---------------\n# Like AC_PROG_CC_C_O, but changed for automake.  We rewrite AC_PROG_CC\n# to automatically call this.\nAC_DEFUN([_AM_PROG_CC_C_O],\n[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl\nAC_REQUIRE_AUX_FILE([compile])dnl\nAC_LANG_PUSH([C])dnl\nAC_CACHE_CHECK(\n  [whether $CC understands -c and -o together],\n  [am_cv_prog_cc_c_o],\n  [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])\n  # Make sure it works both with $CC and with simple cc.\n  # Following AC_PROG_CC_C_O, we do the test twice because some\n  # compilers refuse to overwrite an existing .o file with -o,\n  # though they will create one.\n  am_cv_prog_cc_c_o=yes\n  for am_i in 1 2; do\n    if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \\\n         && test -f conftest2.$ac_objext; then\n      : OK\n    else\n      am_cv_prog_cc_c_o=no\n      break\n    fi\n  done\n  rm -f core conftest*\n  unset am_i])\nif test \"$am_cv_prog_cc_c_o\" != yes; then\n   # Losing compiler, so override with the script.\n   # FIXME: It is wrong to rewrite CC.\n   # But if we don't then we get into trouble of one sort or another.\n   # A longer-term fix would be to have automake use am__CC in this case,\n   # and then we could set am__CC=\"\\$(top_srcdir)/compile \\$(CC)\"\n   CC=\"$am_aux_dir/compile $CC\"\nfi\nAC_LANG_POP([C])])\n\n# For backward compatibility.\nAC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])\n\n# Copyright (C) 2001-2013 Free Software Foundation, Inc.\n#\n# This file is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n# AM_RUN_LOG(COMMAND)\n# -------------------\n# Run COMMAND, save the exit status in ac_status, and log it.\n# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)\nAC_DEFUN([AM_RUN_LOG],\n[{ echo \"$as_me:$LINENO: $1\" >&AS_MESSAGE_LOG_FD\n   ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD\n   ac_status=$?\n   echo \"$as_me:$LINENO: \\$? = $ac_status\" >&AS_MESSAGE_LOG_FD\n   (exit $ac_status); }])\n\n# Check to make sure that the build environment is sane.    -*- Autoconf -*-\n\n# Copyright (C) 1996-2013 Free Software Foundation, Inc.\n#\n# This file is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n# AM_SANITY_CHECK\n# ---------------\nAC_DEFUN([AM_SANITY_CHECK],\n[AC_MSG_CHECKING([whether build environment is sane])\n# Reject unsafe characters in $srcdir or the absolute working directory\n# name.  Accept space and tab only in the latter.\nam_lf='\n'\ncase `pwd` in\n  *[[\\\\\\\"\\#\\$\\&\\'\\`$am_lf]]*)\n    AC_MSG_ERROR([unsafe absolute working directory name]);;\nesac\ncase $srcdir in\n  *[[\\\\\\\"\\#\\$\\&\\'\\`$am_lf\\ \\\t]]*)\n    AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;\nesac\n\n# Do 'set' in a subshell so we don't clobber the current shell's\n# arguments.  Must try -L first in case configure is actually a\n# symlink; some systems play weird games with the mod time of symlinks\n# (eg FreeBSD returns the mod time of the symlink's containing\n# directory).\nif (\n   am_has_slept=no\n   for am_try in 1 2; do\n     echo \"timestamp, slept: $am_has_slept\" > conftest.file\n     set X `ls -Lt \"$srcdir/configure\" conftest.file 2> /dev/null`\n     if test \"$[*]\" = \"X\"; then\n\t# -L didn't work.\n\tset X `ls -t \"$srcdir/configure\" conftest.file`\n     fi\n     if test \"$[*]\" != \"X $srcdir/configure conftest.file\" \\\n\t&& test \"$[*]\" != \"X conftest.file $srcdir/configure\"; then\n\n\t# If neither matched, then we have a broken ls.  This can happen\n\t# if, for instance, CONFIG_SHELL is bash and it inherits a\n\t# broken ls alias from the environment.  This has actually\n\t# happened.  Such a system could not be considered \"sane\".\n\tAC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken\n  alias in your environment])\n     fi\n     if test \"$[2]\" = conftest.file || test $am_try -eq 2; then\n       break\n     fi\n     # Just in case.\n     sleep 1\n     am_has_slept=yes\n   done\n   test \"$[2]\" = conftest.file\n   )\nthen\n   # Ok.\n   :\nelse\n   AC_MSG_ERROR([newly created file is older than distributed files!\nCheck your system clock])\nfi\nAC_MSG_RESULT([yes])\n# If we didn't sleep, we still need to ensure time stamps of config.status and\n# generated files are strictly newer.\nam_sleep_pid=\nif grep 'slept: no' conftest.file >/dev/null 2>&1; then\n  ( sleep 1 ) &\n  am_sleep_pid=$!\nfi\nAC_CONFIG_COMMANDS_PRE(\n  [AC_MSG_CHECKING([that generated files are newer than configure])\n   if test -n \"$am_sleep_pid\"; then\n     # Hide warnings about reused PIDs.\n     wait $am_sleep_pid 2>/dev/null\n   fi\n   AC_MSG_RESULT([done])])\nrm -f conftest.file\n])\n\n# Copyright (C) 2009-2013 Free Software Foundation, Inc.\n#\n# This file is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n# AM_SILENT_RULES([DEFAULT])\n# --------------------------\n# Enable less verbose build rules; with the default set to DEFAULT\n# (\"yes\" being less verbose, \"no\" or empty being verbose).\nAC_DEFUN([AM_SILENT_RULES],\n[AC_ARG_ENABLE([silent-rules], [dnl\nAS_HELP_STRING(\n  [--enable-silent-rules],\n  [less verbose build output (undo: \"make V=1\")])\nAS_HELP_STRING(\n  [--disable-silent-rules],\n  [verbose build output (undo: \"make V=0\")])dnl\n])\ncase $enable_silent_rules in @%:@ (((\n  yes) AM_DEFAULT_VERBOSITY=0;;\n   no) AM_DEFAULT_VERBOSITY=1;;\n    *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;\nesac\ndnl\ndnl A few 'make' implementations (e.g., NonStop OS and NextStep)\ndnl do not support nested variable expansions.\ndnl See automake bug#9928 and bug#10237.\nam_make=${MAKE-make}\nAC_CACHE_CHECK([whether $am_make supports nested variables],\n   [am_cv_make_support_nested_variables],\n   [if AS_ECHO([['TRUE=$(BAR$(V))\nBAR0=false\nBAR1=true\nV=1\nam__doit:\n\t@$(TRUE)\n.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then\n  am_cv_make_support_nested_variables=yes\nelse\n  am_cv_make_support_nested_variables=no\nfi])\nif test $am_cv_make_support_nested_variables = yes; then\n  dnl Using '$V' instead of '$(V)' breaks IRIX make.\n  AM_V='$(V)'\n  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'\nelse\n  AM_V=$AM_DEFAULT_VERBOSITY\n  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY\nfi\nAC_SUBST([AM_V])dnl\nAM_SUBST_NOTMAKE([AM_V])dnl\nAC_SUBST([AM_DEFAULT_V])dnl\nAM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl\nAC_SUBST([AM_DEFAULT_VERBOSITY])dnl\nAM_BACKSLASH='\\'\nAC_SUBST([AM_BACKSLASH])dnl\n_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl\n])\n\n# Copyright (C) 2001-2013 Free Software Foundation, Inc.\n#\n# This file is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n# AM_PROG_INSTALL_STRIP\n# ---------------------\n# One issue with vendor 'install' (even GNU) is that you can't\n# specify the program used to strip binaries.  This is especially\n# annoying in cross-compiling environments, where the build's strip\n# is unlikely to handle the host's binaries.\n# Fortunately install-sh will honor a STRIPPROG variable, so we\n# always use install-sh in \"make install-strip\", and initialize\n# STRIPPROG with the value of the STRIP variable (set by the user).\nAC_DEFUN([AM_PROG_INSTALL_STRIP],\n[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl\n# Installed binaries are usually stripped using 'strip' when the user\n# run \"make install-strip\".  However 'strip' might not be the right\n# tool to use in cross-compilation environments, therefore Automake\n# will honor the 'STRIP' environment variable to overrule this program.\ndnl Don't test for $cross_compiling = yes, because it might be 'maybe'.\nif test \"$cross_compiling\" != no; then\n  AC_CHECK_TOOL([STRIP], [strip], :)\nfi\nINSTALL_STRIP_PROGRAM=\"\\$(install_sh) -c -s\"\nAC_SUBST([INSTALL_STRIP_PROGRAM])])\n\n# Copyright (C) 2006-2013 Free Software Foundation, Inc.\n#\n# This file is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n# _AM_SUBST_NOTMAKE(VARIABLE)\n# ---------------------------\n# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.\n# This macro is traced by Automake.\nAC_DEFUN([_AM_SUBST_NOTMAKE])\n\n# AM_SUBST_NOTMAKE(VARIABLE)\n# --------------------------\n# Public sister of _AM_SUBST_NOTMAKE.\nAC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])\n\n# Check how to create a tarball.                            -*- Autoconf -*-\n\n# Copyright (C) 2004-2013 Free Software Foundation, Inc.\n#\n# This file is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n# _AM_PROG_TAR(FORMAT)\n# --------------------\n# Check how to create a tarball in format FORMAT.\n# FORMAT should be one of 'v7', 'ustar', or 'pax'.\n#\n# Substitute a variable $(am__tar) that is a command\n# writing to stdout a FORMAT-tarball containing the directory\n# $tardir.\n#     tardir=directory && $(am__tar) > result.tar\n#\n# Substitute a variable $(am__untar) that extract such\n# a tarball read from stdin.\n#     $(am__untar) < result.tar\n#\nAC_DEFUN([_AM_PROG_TAR],\n[# Always define AMTAR for backward compatibility.  Yes, it's still used\n# in the wild :-(  We should find a proper way to deprecate it ...\nAC_SUBST([AMTAR], ['$${TAR-tar}'])\n\n# We'll loop over all known methods to create a tar archive until one works.\n_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'\n\nm4_if([$1], [v7],\n  [am__tar='$${TAR-tar} chof - \"$$tardir\"' am__untar='$${TAR-tar} xf -'],\n\n  [m4_case([$1],\n    [ustar],\n     [# The POSIX 1988 'ustar' format is defined with fixed-size fields.\n      # There is notably a 21 bits limit for the UID and the GID.  In fact,\n      # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343\n      # and bug#13588).\n      am_max_uid=2097151 # 2^21 - 1\n      am_max_gid=$am_max_uid\n      # The $UID and $GID variables are not portable, so we need to resort\n      # to the POSIX-mandated id(1) utility.  Errors in the 'id' calls\n      # below are definitely unexpected, so allow the users to see them\n      # (that is, avoid stderr redirection).\n      am_uid=`id -u || echo unknown`\n      am_gid=`id -g || echo unknown`\n      AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])\n      if test $am_uid -le $am_max_uid; then\n         AC_MSG_RESULT([yes])\n      else\n         AC_MSG_RESULT([no])\n         _am_tools=none\n      fi\n      AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])\n      if test $am_gid -le $am_max_gid; then\n         AC_MSG_RESULT([yes])\n      else\n        AC_MSG_RESULT([no])\n        _am_tools=none\n      fi],\n\n  [pax],\n    [],\n\n  [m4_fatal([Unknown tar format])])\n\n  AC_MSG_CHECKING([how to create a $1 tar archive])\n\n  # Go ahead even if we have the value already cached.  We do so because we\n  # need to set the values for the 'am__tar' and 'am__untar' variables.\n  _am_tools=${am_cv_prog_tar_$1-$_am_tools}\n\n  for _am_tool in $_am_tools; do\n    case $_am_tool in\n    gnutar)\n      for _am_tar in tar gnutar gtar; do\n        AM_RUN_LOG([$_am_tar --version]) && break\n      done\n      am__tar=\"$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - \"'\"$$tardir\"'\n      am__tar_=\"$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - \"'\"$tardir\"'\n      am__untar=\"$_am_tar -xf -\"\n      ;;\n    plaintar)\n      # Must skip GNU tar: if it does not support --format= it doesn't create\n      # ustar tarball either.\n      (tar --version) >/dev/null 2>&1 && continue\n      am__tar='tar chf - \"$$tardir\"'\n      am__tar_='tar chf - \"$tardir\"'\n      am__untar='tar xf -'\n      ;;\n    pax)\n      am__tar='pax -L -x $1 -w \"$$tardir\"'\n      am__tar_='pax -L -x $1 -w \"$tardir\"'\n      am__untar='pax -r'\n      ;;\n    cpio)\n      am__tar='find \"$$tardir\" -print | cpio -o -H $1 -L'\n      am__tar_='find \"$tardir\" -print | cpio -o -H $1 -L'\n      am__untar='cpio -i -H $1 -d'\n      ;;\n    none)\n      am__tar=false\n      am__tar_=false\n      am__untar=false\n      ;;\n    esac\n\n    # If the value was cached, stop now.  We just wanted to have am__tar\n    # and am__untar set.\n    test -n \"${am_cv_prog_tar_$1}\" && break\n\n    # tar/untar a dummy directory, and stop if the command works.\n    rm -rf conftest.dir\n    mkdir conftest.dir\n    echo GrepMe > conftest.dir/file\n    AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])\n    rm -rf conftest.dir\n    if test -s conftest.tar; then\n      AM_RUN_LOG([$am__untar <conftest.tar])\n      AM_RUN_LOG([cat conftest.dir/file])\n      grep GrepMe conftest.dir/file >/dev/null 2>&1 && break\n    fi\n  done\n  rm -rf conftest.dir\n\n  AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])\n  AC_MSG_RESULT([$am_cv_prog_tar_$1])])\n\nAC_SUBST([am__tar])\nAC_SUBST([am__untar])\n]) # _AM_PROG_TAR\n\nm4_include([m4/ac_system_extensions.m4])\nm4_include([m4/acx_check_suncc.m4])\nm4_include([m4/acx_pthread.m4])\nm4_include([m4/libtool.m4])\nm4_include([m4/ltoptions.m4])\nm4_include([m4/ltsugar.m4])\nm4_include([m4/ltversion.m4])\nm4_include([m4/lt~obsolete.m4])\nm4_include([m4/stl_hash.m4])\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/ar-lib",
    "content": "#! /bin/sh\n# Wrapper for Microsoft lib.exe\n\nme=ar-lib\nscriptversion=2012-03-01.08; # UTC\n\n# Copyright (C) 2010-2013 Free Software Foundation, Inc.\n# Written by Peter Rosin <peda@lysator.liu.se>.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 2, or (at your option)\n# any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\n# As a special exception to the GNU General Public License, if you\n# distribute this file as part of a program that contains a\n# configuration script generated by Autoconf, you may include it under\n# the same distribution terms that you use for the rest of that program.\n\n# This file is maintained in Automake, please report\n# bugs to <bug-automake@gnu.org> or send patches to\n# <automake-patches@gnu.org>.\n\n\n# func_error message\nfunc_error ()\n{\n  echo \"$me: $1\" 1>&2\n  exit 1\n}\n\nfile_conv=\n\n# func_file_conv build_file\n# Convert a $build file to $host form and store it in $file\n# Currently only supports Windows hosts.\nfunc_file_conv ()\n{\n  file=$1\n  case $file in\n    / | /[!/]*) # absolute file, and not a UNC file\n      if test -z \"$file_conv\"; then\n\t# lazily determine how to convert abs files\n\tcase `uname -s` in\n\t  MINGW*)\n\t    file_conv=mingw\n\t    ;;\n\t  CYGWIN*)\n\t    file_conv=cygwin\n\t    ;;\n\t  *)\n\t    file_conv=wine\n\t    ;;\n\tesac\n      fi\n      case $file_conv in\n\tmingw)\n\t  file=`cmd //C echo \"$file \" | sed -e 's/\"\\(.*\\) \" *$/\\1/'`\n\t  ;;\n\tcygwin)\n\t  file=`cygpath -m \"$file\" || echo \"$file\"`\n\t  ;;\n\twine)\n\t  file=`winepath -w \"$file\" || echo \"$file\"`\n\t  ;;\n      esac\n      ;;\n  esac\n}\n\n# func_at_file at_file operation archive\n# Iterate over all members in AT_FILE performing OPERATION on ARCHIVE\n# for each of them.\n# When interpreting the content of the @FILE, do NOT use func_file_conv,\n# since the user would need to supply preconverted file names to\n# binutils ar, at least for MinGW.\nfunc_at_file ()\n{\n  operation=$2\n  archive=$3\n  at_file_contents=`cat \"$1\"`\n  eval set x \"$at_file_contents\"\n  shift\n\n  for member\n  do\n    $AR -NOLOGO $operation:\"$member\" \"$archive\" || exit $?\n  done\n}\n\ncase $1 in\n  '')\n     func_error \"no command.  Try '$0 --help' for more information.\"\n     ;;\n  -h | --h*)\n    cat <<EOF\nUsage: $me [--help] [--version] PROGRAM ACTION ARCHIVE [MEMBER...]\n\nMembers may be specified in a file named with @FILE.\nEOF\n    exit $?\n    ;;\n  -v | --v*)\n    echo \"$me, version $scriptversion\"\n    exit $?\n    ;;\nesac\n\nif test $# -lt 3; then\n  func_error \"you must specify a program, an action and an archive\"\nfi\n\nAR=$1\nshift\nwhile :\ndo\n  if test $# -lt 2; then\n    func_error \"you must specify a program, an action and an archive\"\n  fi\n  case $1 in\n    -lib | -LIB \\\n    | -ltcg | -LTCG \\\n    | -machine* | -MACHINE* \\\n    | -subsystem* | -SUBSYSTEM* \\\n    | -verbose | -VERBOSE \\\n    | -wx* | -WX* )\n      AR=\"$AR $1\"\n      shift\n      ;;\n    *)\n      action=$1\n      shift\n      break\n      ;;\n  esac\ndone\norig_archive=$1\nshift\nfunc_file_conv \"$orig_archive\"\narchive=$file\n\n# strip leading dash in $action\naction=${action#-}\n\ndelete=\nextract=\nlist=\nquick=\nreplace=\nindex=\ncreate=\n\nwhile test -n \"$action\"\ndo\n  case $action in\n    d*) delete=yes  ;;\n    x*) extract=yes ;;\n    t*) list=yes    ;;\n    q*) quick=yes   ;;\n    r*) replace=yes ;;\n    s*) index=yes   ;;\n    S*)             ;; # the index is always updated implicitly\n    c*) create=yes  ;;\n    u*)             ;; # TODO: don't ignore the update modifier\n    v*)             ;; # TODO: don't ignore the verbose modifier\n    *)\n      func_error \"unknown action specified\"\n      ;;\n  esac\n  action=${action#?}\ndone\n\ncase $delete$extract$list$quick$replace,$index in\n  yes,* | ,yes)\n    ;;\n  yesyes*)\n    func_error \"more than one action specified\"\n    ;;\n  *)\n    func_error \"no action specified\"\n    ;;\nesac\n\nif test -n \"$delete\"; then\n  if test ! -f \"$orig_archive\"; then\n    func_error \"archive not found\"\n  fi\n  for member\n  do\n    case $1 in\n      @*)\n        func_at_file \"${1#@}\" -REMOVE \"$archive\"\n        ;;\n      *)\n        func_file_conv \"$1\"\n        $AR -NOLOGO -REMOVE:\"$file\" \"$archive\" || exit $?\n        ;;\n    esac\n  done\n\nelif test -n \"$extract\"; then\n  if test ! -f \"$orig_archive\"; then\n    func_error \"archive not found\"\n  fi\n  if test $# -gt 0; then\n    for member\n    do\n      case $1 in\n        @*)\n          func_at_file \"${1#@}\" -EXTRACT \"$archive\"\n          ;;\n        *)\n          func_file_conv \"$1\"\n          $AR -NOLOGO -EXTRACT:\"$file\" \"$archive\" || exit $?\n          ;;\n      esac\n    done\n  else\n    $AR -NOLOGO -LIST \"$archive\" | sed -e 's/\\\\/\\\\\\\\/g' | while read member\n    do\n      $AR -NOLOGO -EXTRACT:\"$member\" \"$archive\" || exit $?\n    done\n  fi\n\nelif test -n \"$quick$replace\"; then\n  if test ! -f \"$orig_archive\"; then\n    if test -z \"$create\"; then\n      echo \"$me: creating $orig_archive\"\n    fi\n    orig_archive=\n  else\n    orig_archive=$archive\n  fi\n\n  for member\n  do\n    case $1 in\n    @*)\n      func_file_conv \"${1#@}\"\n      set x \"$@\" \"@$file\"\n      ;;\n    *)\n      func_file_conv \"$1\"\n      set x \"$@\" \"$file\"\n      ;;\n    esac\n    shift\n    shift\n  done\n\n  if test -n \"$orig_archive\"; then\n    $AR -NOLOGO -OUT:\"$archive\" \"$orig_archive\" \"$@\" || exit $?\n  else\n    $AR -NOLOGO -OUT:\"$archive\" \"$@\" || exit $?\n  fi\n\nelif test -n \"$list\"; then\n  if test ! -f \"$orig_archive\"; then\n    func_error \"archive not found\"\n  fi\n  $AR -NOLOGO -LIST \"$archive\" || exit $?\nfi\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/autogen.sh",
    "content": "#!/bin/sh\n\n# Run this script to generate the configure script and other files that will\n# be included in the distribution.  These files are not checked in because they\n# are automatically generated.\n\nset -e\n\nif [ ! -z \"$@\" ]; then\n  for argument in \"$@\"; do\n    case $argument in\n\t  # make curl silent\n      \"-s\")\n        curlopts=\"-s\"\n        ;;\n    esac\n  done\nfi\n\n\n# Check that we're being run from the right directory.\nif test ! -f src/google/protobuf/stubs/common.h; then\n  cat >&2 << __EOF__\nCould not find source code.  Make sure you are running this script from the\nroot of the distribution tree.\n__EOF__\n  exit 1\nfi\n\n# Check that gmock is present.  Usually it is already there since the\n# directory is set up as an SVN external.\nif test ! -e gmock; then\n  echo \"Google Mock not present.  Fetching gmock-1.7.0 from the web...\"\n  curl $curlopts -O https://googlemock.googlecode.com/files/gmock-1.7.0.zip\n  unzip -q gmock-1.7.0.zip\n  rm gmock-1.7.0.zip\n  mv gmock-1.7.0 gmock\nfi\n\nset -ex\n\n# TODO(kenton):  Remove the \",no-obsolete\" part and fix the resulting warnings.\nautoreconf -f -i -Wall,no-obsolete\n\nrm -rf autom4te.cache config.h.in~\nexit 0\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/cmake/CMakeLists.txt",
    "content": "# Minimum CMake required\r\ncmake_minimum_required(VERSION 2.8.12)\r\n\r\nif(protobuf_VERBOSE)\r\n  message(STATUS \"Protocol Buffers Configuring...\")\r\nendif()\r\n\r\n# CMake policies\r\ncmake_policy(SET CMP0022 NEW)\r\nif(${CMAKE_VERSION} VERSION_GREATER \"3.0\")\r\n  cmake_policy(SET CMP0048 NEW)\r\nendif()\r\n\r\n# Project\r\nproject(protobuf C CXX)\r\n\r\n# Options\r\noption(protobuf_BUILD_TESTS \"Build tests\" OFF)\r\noption(protobuf_BUILD_EXAMPLES \"Build examples\" OFF)\r\nif (BUILD_SHARED_LIBS)\r\n  set(protobuf_BUILD_SHARED_LIBS_DEFAULT ON)\r\nelse (BUILD_SHARED_LIBS)\r\n  set(protobuf_BUILD_SHARED_LIBS_DEFAULT OFF)\r\nendif (BUILD_SHARED_LIBS)\r\noption(protobuf_BUILD_SHARED_LIBS \"Build Shared Libraries\" ${protobuf_BUILD_SHARED_LIBS_DEFAULT})\r\ninclude(CMakeDependentOption)\r\ncmake_dependent_option(protobuf_MSVC_STATIC_RUNTIME \"Link static runtime libraries\" ON\r\n  \"NOT protobuf_BUILD_SHARED_LIBS\" OFF)\r\nif (MSVC)\r\n  set(protobuf_WITH_ZLIB_DEFAULT OFF)\r\nelse (MSVC)\r\n  set(protobuf_WITH_ZLIB_DEFAULT OFF)\r\nendif (MSVC)\r\noption(protobuf_WITH_ZLIB \"Build with zlib support\" ${protobuf_WITH_ZLIB_DEFAULT})\r\nset(protobuf_DEBUG_POSTFIX \"d\"\r\n  CACHE STRING \"Default debug postfix\")\r\nmark_as_advanced(protobuf_DEBUG_POSTFIX)\r\n# User options\r\ninclude(protobuf-options.cmake)\r\n\r\n# Path to main configure script\r\nset(protobuf_CONFIGURE_SCRIPT \"../configure.ac\")\r\n\r\n# Parse configure script\r\nset(protobuf_AC_INIT_REGEX\r\n  \"^AC_INIT\\\\(\\\\[([^]]+)\\\\],\\\\[([^]]+)\\\\],\\\\[([^]]+)\\\\],\\\\[([^]]+)\\\\]\\\\)$\")\r\nfile(STRINGS \"${protobuf_CONFIGURE_SCRIPT}\" protobuf_AC_INIT_LINE\r\n  LIMIT_COUNT 1 REGEX \"^AC_INIT\")\r\n# Description\r\nstring(REGEX REPLACE        \"${protobuf_AC_INIT_REGEX}\" \"\\\\1\"\r\n    protobuf_DESCRIPTION    \"${protobuf_AC_INIT_LINE}\")\r\n# Version\r\nstring(REGEX REPLACE        \"${protobuf_AC_INIT_REGEX}\" \"\\\\2\"\r\n    protobuf_VERSION_STRING \"${protobuf_AC_INIT_LINE}\")\r\n# Contact\r\nstring(REGEX REPLACE        \"${protobuf_AC_INIT_REGEX}\" \"\\\\3\"\r\n    protobuf_CONTACT        \"${protobuf_AC_INIT_LINE}\")\r\n# Parse version tweaks\r\nset(protobuf_VERSION_REGEX \"^([0-9]+)\\\\.([0-9]+)\\\\.([0-9]+)-?(.*)$\")\r\nstring(REGEX REPLACE     \"${protobuf_VERSION_REGEX}\" \"\\\\1\"\r\n  protobuf_VERSION_MAJOR \"${protobuf_VERSION_STRING}\")\r\nstring(REGEX REPLACE     \"${protobuf_VERSION_REGEX}\" \"\\\\2\"\r\n  protobuf_VERSION_MINOR \"${protobuf_VERSION_STRING}\")\r\nstring(REGEX REPLACE     \"${protobuf_VERSION_REGEX}\" \"\\\\3\"\r\n  protobuf_VERSION_PATCH \"${protobuf_VERSION_STRING}\")\r\nstring(REGEX REPLACE     \"${protobuf_VERSION_REGEX}\" \"\\\\4\"\r\n  protobuf_VERSION_PRERELEASE \"${protobuf_VERSION_STRING}\")\r\n\r\n# Package version\r\nset(protobuf_VERSION\r\n  \"${protobuf_VERSION_MAJOR}.${protobuf_VERSION_MINOR}.${protobuf_VERSION_PATCH}\")\r\n\r\nif(protobuf_VERSION_PRERELEASE)\r\n  set(protobuf_VERSION \"${protobuf_VERSION}-${protobuf_VERSION_PRERELEASE}\")\r\nendif()\r\n\r\nif(protobuf_VERBOSE)\r\n  message(STATUS \"Configuration script parsing status [\")\r\n  message(STATUS \"  Description : ${protobuf_DESCRIPTION}\")\r\n  message(STATUS \"  Version     : ${protobuf_VERSION} (${protobuf_VERSION_STRING})\")\r\n  message(STATUS \"  Contact     : ${protobuf_CONTACT}\")\r\n  message(STATUS \"]\")\r\nendif()\r\n\r\nadd_definitions(-DGOOGLE_PROTOBUF_CMAKE_BUILD)\r\n\r\nfind_package(Threads REQUIRED)\r\nif (CMAKE_USE_PTHREADS_INIT)\r\n  add_definitions(-DHAVE_PTHREAD)\r\nendif (CMAKE_USE_PTHREADS_INIT)\r\n\r\nif (protobuf_WITH_ZLIB)\r\n  find_package(ZLIB)\r\n  if (ZLIB_FOUND)\r\n    set(HAVE_ZLIB 1)\r\n    # FindZLIB module define ZLIB_INCLUDE_DIRS variable\r\n    # Set ZLIB_INCLUDE_DIRECTORIES for compatible\r\n    set(ZLIB_INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIRECTORIES} ${ZLIB_INCLUDE_DIRS})\r\n    # Using imported target if exists\r\n    if (TARGET ZLIB::ZLIB)\r\n      set(ZLIB_LIBRARIES ZLIB::ZLIB)\r\n    endif (TARGET ZLIB::ZLIB)\r\n  else (ZLIB_FOUND)\r\n    set(HAVE_ZLIB 0)\r\n    # Explicitly set these to empty (override NOT_FOUND) so cmake doesn't\r\n    # complain when we use them later.\r\n    set(ZLIB_INCLUDE_DIRECTORIES)\r\n    set(ZLIB_LIBRARIES)\r\n  endif (ZLIB_FOUND)\r\nendif (protobuf_WITH_ZLIB)\r\n\r\nif (HAVE_ZLIB)\r\n  add_definitions(-DHAVE_ZLIB)\r\nendif (HAVE_ZLIB)\r\n\r\nif (protobuf_BUILD_SHARED_LIBS)\r\n  set(protobuf_SHARED_OR_STATIC \"SHARED\")\r\nelse (protobuf_BUILD_SHARED_LIBS)\r\n  set(protobuf_SHARED_OR_STATIC \"STATIC\")\r\n  # In case we are building static libraries, link also the runtime library statically\r\n  # so that MSVCR*.DLL is not required at runtime.\r\n  # https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx\r\n  # This is achieved by replacing msvc option /MD with /MT and /MDd with /MTd\r\n  # http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F\r\n\r\n  # W don't want to change it for the MySQL Router as we use \"/MD\" in the router libraries\r\n  if (0 AND MSVC AND protobuf_MSVC_STATIC_RUNTIME)\r\n    foreach(flag_var\r\n        CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE\r\n        CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)\r\n      if(${flag_var} MATCHES \"/MD\")\r\n        string(REGEX REPLACE \"/MD\" \"/MT\" ${flag_var} \"${${flag_var}}\")\r\n      endif(${flag_var} MATCHES \"/MD\")\r\n    endforeach(flag_var)\r\n  endif (0 AND MSVC AND protobuf_MSVC_STATIC_RUNTIME)\r\nendif (protobuf_BUILD_SHARED_LIBS)\r\n\r\nif (MSVC)\r\n  # Build with multiple processes\r\n  add_definitions(/MP)\r\n  add_definitions(/wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305)\r\n  # Allow big object\r\n  add_definitions(/bigobj)\r\n  string(REPLACE \"/\" \"\\\\\" PROTOBUF_SOURCE_WIN32_PATH ${protobuf_SOURCE_DIR})\r\n  string(REPLACE \"/\" \"\\\\\" PROTOBUF_BINARY_WIN32_PATH ${protobuf_BINARY_DIR})\r\n  configure_file(extract_includes.bat.in extract_includes.bat)\r\nendif (MSVC)\r\n\r\nget_filename_component(protobuf_source_dir ${protobuf_SOURCE_DIR} PATH)\r\n\r\ninclude_directories(\r\n  ${ZLIB_INCLUDE_DIRECTORIES}\r\n  ${protobuf_BINARY_DIR}\r\n  ${protobuf_source_dir}/src)\r\n\r\nif (MSVC)\r\n  # Add the \"lib\" prefix for generated .lib outputs.\r\n  set(LIB_PREFIX lib)\r\nelse (MSVC)\r\n  # When building with \"make\", \"lib\" prefix will be added automatically by\r\n  # the build tool.\r\n  set(LIB_PREFIX)\r\nendif (MSVC)\r\n\r\ninclude(libprotobuf-lite.cmake)\r\ninclude(libprotobuf.cmake)\r\ninclude(libprotoc.cmake)\r\ninclude(protoc.cmake)\r\n\r\nif (protobuf_BUILD_TESTS)\r\n  include(tests.cmake)\r\nendif (protobuf_BUILD_TESTS)\r\n\r\n#include(install.cmake)\r\n\r\nif (protobuf_BUILD_EXAMPLES)\r\n  include(examples.cmake)\r\nendif (protobuf_BUILD_EXAMPLES)\r\n\r\nif(protobuf_VERBOSE)\r\n    message(STATUS \"Protocol Buffers Configuring done\")\r\nendif()\r\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/cmake/README.md",
    "content": "This directory contains *CMake* files that can be used to build protobuf\nwith *MSVC* on *Windows*. You can build the project from *Command Prompt*\nand using an *Visual Studio* IDE.\n\nYou need to have [CMake](http://www.cmake.org), [Visual Studio](https://www.visualstudio.com)\nand optionally [Git](http://git-scm.com) installed on your computer before proceeding.\n\nMost of the instructions will be given to the *Сommand Prompt*, but the same\nactions can be performed using appropriate GUI tools.\n\nEnvironment Setup\n=================\n\nOpen the appropriate *Command Prompt* from the *Start* menu.\n\nFor example *VS2013 x64 Native Tools Command Prompt*:\n\n    C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\bin\\amd64>\n\nChange to your working directory:\n\n    C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\bin\\amd64>cd C:\\Path\\to\n    C:\\Path\\to>\n\nWhere *C:\\Path\\to* is path to your real working directory.\n\nCreate a folder where protobuf headers/libraries/binaries will be installed after built:\n\n    C:\\Path\\to>mkdir install\n\nIf *cmake* command is not available from *Command Prompt*, add it to system *PATH* variable:\n\n    C:\\Path\\to>set PATH=%PATH%;C:\\Program Files (x86)\\CMake\\bin\n\nIf *git* command is not available from *Command Prompt*, add it to system *PATH* variable:\n\n    C:\\Path\\to>set PATH=%PATH%;C:\\Program Files\\Git\\cmd\n\nGood. Now you are ready to continue.\n\nGetting Sources\n===============\n\nYou can get the latest stable source packages from the\n[releases](https://github.com/google/protobuf/releases) page.\nOr you can type:\n\n     C:\\Path\\to> git clone -b [release_tag] https://github.com/google/protobuf.git\n\nWhere *[release_tag]* is a git tag like *v3.0.0-beta-1* or a branch name like *master*\nif you want to get the latest code.\n\nGo to the project folder:\n\n     C:\\Path\\to>cd protobuf\n     C:\\Path\\to\\protobuf>\n\nProtobuf unit-tests require gmock to build. If you download protobuf source code\nfrom the *releases* page, the *gmock* directory should already be there. If you checkout\nthe code via `git clone`, this *gmock* directory won't exist and you will have to\ndownload it manually or skip building protobuf unit-tests.\n\nYou can download gmock as follows:\n\n     C:\\Path\\to\\protobuf>git clone -b release-1.7.0 https://github.com/google/googlemock.git gmock\n\nThen go to *gmock* folder and download gtest:\n\n     C:\\Path\\to\\protobuf>cd gmock\n     C:\\Path\\to\\protobuf\\gmock>git clone -b release-1.7.0 https://github.com/google/googletest.git gtest\n\nIf you absolutely don't want to build and run protobuf unit-tests, skip\nthis steps and use protobuf at your own risk.\n\nNow go to *cmake* folder in protobuf sources:\n\n     C:\\Path\\to\\protobuf\\gmock>cd ..\\cmake\n     C:\\Path\\to\\protobuf\\cmake>\n\nGood. Now you are ready to *CMake* configuration.\n\nCMake Configuration\n===================\n\n*CMake* supports a lot of different\n[generators](http://www.cmake.org/cmake/help/latest/manual/cmake-generators.7.html)\nfor various native build systems.\nWe are only interested in\n[Makefile](http://www.cmake.org/cmake/help/latest/manual/cmake-generators.7.html#makefile-generators)\nand\n[Visual Studio](http://www.cmake.org/cmake/help/latest/manual/cmake-generators.7.html#visual-studio-generators)\ngenerators.\n\nWe will use shadow building to separate the temporary files from the protobuf source code.\n\nCreate a temporary *build* folder and change your working directory to it:\n\n     C:\\Path\\to\\protobuf\\cmake>mkdir build & cd build\n     C:\\Path\\to\\protobuf\\cmake\\build>\n\nThe *Makefile* generator can build the project in only one configuration, so you need to build\na separate folder for each configuration.\n\nTo start using a *Release* configuration:\n\n     C:\\Path\\to\\protobuf\\cmake\\build>mkdir release & cd release\n     C:\\Path\\to\\protobuf\\cmake\\build\\release>cmake -G \"NMake Makefiles\" ^\n     -DCMAKE_BUILD_TYPE=Release ^\n     -DCMAKE_INSTALL_PREFIX=../../../../install ^\n     ../..\n\nIt will generate *nmake* *Makefile* in current directory.\n\nTo use *Debug* configuration:\n\n     C:\\Path\\to\\protobuf\\cmake\\build>mkdir debug & cd debug\n     C:\\Path\\to\\protobuf\\cmake\\build\\debug>cmake -G \"NMake Makefiles\" ^\n     -DCMAKE_BUILD_TYPE=Debug ^\n     -DCMAKE_INSTALL_PREFIX=../../../../install ^\n     ../..\n\nIt will generate *nmake* *Makefile* in current directory.\n\nTo create *Visual Studio* solution file:\n\n     C:\\Path\\to\\protobuf\\cmake\\build>mkdir solution & cd solution\n     C:\\Path\\to\\protobuf\\cmake\\build\\solution>cmake -G \"Visual Studio 12 2013 Win64\" ^\n     -DCMAKE_INSTALL_PREFIX=../../../../install ^\n     ../..\n\nIt will generate *Visual Studio* solution file *protobuf.sln* in current directory.\n\nIf the *gmock* directory does not exist, and you do not want to build protobuf unit tests,\nyou need to add *cmake* command argument `-Dprotobuf_BUILD_TESTS=OFF` to disable testing.\n\nCompiling\n=========\n\nTo compile protobuf:\n\n     C:\\Path\\to\\protobuf\\cmake\\build\\release>nmake\n\nor\n\n     C:\\Path\\to\\protobuf\\cmake\\build\\debug>nmake\n\nAnd wait for the compilation to finish.\n\nIf you prefer to use the IDE:\n\n  * Open the generated protobuf.sln file in Microsoft Visual Studio.\n  * Choose \"Debug\" or \"Release\" configuration as desired.\n  * From the Build menu, choose \"Build Solution\".\n\nAnd wait for the compilation to finish.\n\nTesting\n=======\n\nTo run unit-tests, first you must compile protobuf as described above.\nThen run:\n\n     C:\\Path\\to\\protobuf\\cmake\\build\\release>nmake check\n\nor\n\n     C:\\Path\\to\\protobuf\\cmake\\build\\debug>nmake check\n\nYou can also build project *check* from Visual Studio solution.\nYes, it may sound strange, but it works.\n\nYou should see output similar to:\n\n     Running main() from gmock_main.cc\n     [==========] Running 1546 tests from 165 test cases.\n     \n     ...\n     \n     [==========] 1546 tests from 165 test cases ran. (2529 ms total)\n     [  PASSED  ] 1546 tests.\n\nTo run specific tests:\n\n     C:\\Path\\to\\protobuf>cmake\\build\\release\\tests.exe --gtest_filter=AnyTest*\n     Running main() from gmock_main.cc\n     Note: Google Test filter = AnyTest*\n     [==========] Running 3 tests from 1 test case.\n     [----------] Global test environment set-up.\n     [----------] 3 tests from AnyTest\n     [ RUN      ] AnyTest.TestPackAndUnpack\n     [       OK ] AnyTest.TestPackAndUnpack (0 ms)\n     [ RUN      ] AnyTest.TestPackAndUnpackAny\n     [       OK ] AnyTest.TestPackAndUnpackAny (0 ms)\n     [ RUN      ] AnyTest.TestIs\n     [       OK ] AnyTest.TestIs (0 ms)\n     [----------] 3 tests from AnyTest (1 ms total)\n     \n     [----------] Global test environment tear-down\n     [==========] 3 tests from 1 test case ran. (2 ms total)\n     [  PASSED  ] 3 tests.\n\nNote that the tests must be run from the source folder.\n\nIf all tests are passed, safely continue.\n\nInstalling\n==========\n\nTo install protobuf to the specified *install* folder:\n\n     C:\\Path\\to\\protobuf\\cmake\\build\\release>nmake install\n\nor\n\n     C:\\Path\\to\\protobuf\\cmake\\build\\debug>nmake install\n\nYou can also build project *INSTALL* from Visual Studio solution.\nIt sounds not so strange and it works.\n\nThis will create the following folders under the *install* location:\n  * bin - that contains protobuf *protoc.exe* compiler;\n  * include - that contains C++ headers and protobuf *.proto files;\n  * lib - that contains linking libraries and *CMake* configuration files for *protobuf* package.\n\nNow you can if needed:\n  * Copy the contents of the include directory to wherever you want to put headers.\n  * Copy protoc.exe wherever you put build tools (probably somewhere in your PATH).\n  * Copy linking libraries libprotobuf[d].lib, libprotobuf-lite[d].lib, and libprotoc[d].lib wherever you put libraries.\n\nTo avoid conflicts between the MSVC debug and release runtime libraries, when\ncompiling a debug build of your application, you may need to link against a\ndebug build of libprotobufd.lib with \"d\" postfix.  Similarly, release builds should link against\nrelease libprotobuf.lib library.\n\nDLLs vs. static linking\n=======================\n\nStatic linking is now the default for the Protocol Buffer libraries.  Due to\nissues with Win32's use of a separate heap for each DLL, as well as binary\ncompatibility issues between different versions of MSVC's STL library, it is\nrecommended that you use static linkage only.  However, it is possible to\nbuild libprotobuf and libprotoc as DLLs if you really want.  To do this,\ndo the following:\n\n  * Add an additional flag `-Dprotobuf_BUILD_SHARED_LIBS=ON` when invoking cmake\n  * Follow the same steps as described in the above section.\n  * When compiling your project, make sure to `#define PROTOBUF_USE_DLLS`.\n\nWhen distributing your software to end users, we strongly recommend that you\ndo NOT install libprotobuf.dll or libprotoc.dll to any shared location.\nInstead, keep these libraries next to your binaries, in your application's\nown install directory.  C++ makes it very difficult to maintain binary\ncompatibility between releases, so it is likely that future versions of these\nlibraries will *not* be usable as drop-in replacements.\n\nIf your project is itself a DLL intended for use by third-party software, we\nrecommend that you do NOT expose protocol buffer objects in your library's\npublic interface, and that you statically link protocol buffers into your\nlibrary.\n\nZLib support\n============\n\nIf you want to include GzipInputStream and GzipOutputStream\n(google/protobuf/io/gzip_stream.h) in libprotobuf, you will need to do a few\nadditional steps.\n\nObtain a copy of the zlib library.  The pre-compiled DLL at zlib.net works.\nYou need prepare it:\n\n  * Make sure zlib's two headers are in your `C:\\Path\\to\\install\\include` path\n  * Make sure zlib's linking libraries (*.lib file) is in your\n    `C:\\Path\\to\\install\\lib` library path.\n\nYou can also compile it from source by yourself.\n\nGetting sources:\n\n     C:\\Path\\to>git clone -b v1.2.8 https://github.com/madler/zlib.git\n     C:\\Path\\to>cd zlib\n\nCompiling and Installing:\n\n     C:\\Path\\to\\zlib>mkdir build & cd build\n     C:\\Path\\to\\zlib\\build>mkdir release & cd release\n     C:\\Path\\to\\zlib\\build\\release>cmake -G \"NMake Makefiles\" -DCMAKE_BUILD_TYPE=Release ^\n     -DCMAKE_INSTALL_PREFIX=../../../install ../..\n     C:\\Path\\to\\zlib\\build\\release>nmake & nmake install\n\nYou can make *debug* version or use *Visual Studio* generator also as before for the\nprotobuf project.\n\nNow add *bin* folder from *install* to system *PATH*:\n\n     C:\\Path\\to>set PATH=%PATH%;C:\\Path\\to\\install\\bin\n\nYou need reconfigure protobuf with flag `-Dprotobuf_WITH_ZLIB=ON` when invoking cmake.\n\nNote that if you have compiled ZLIB yourself, as stated above,\nfurther disable the option `-Dprotobuf_MSVC_STATIC_RUNTIME=OFF`.\n\nIf it reports NOTFOUND for zlib_include or zlib_lib, you might haven't put\nthe headers or the .lib file in the right directory.\n\nBuild and testing protobuf as usual.\n\nNotes on Compiler Warnings\n==========================\n\nThe following warnings have been disabled while building the protobuf libraries\nand compiler.  You may have to disable some of them in your own project as\nwell, or live with them.\n\n* C4018 - 'expression' : signed/unsigned mismatch\n* C4146 - unary minus operator applied to unsigned type, result still unsigned\n* C4244 - Conversion from 'type1' to 'type2', possible loss of data.\n* C4251 - 'identifier' : class 'type' needs to have dll-interface to be used by\n  clients of class 'type2'\n* C4267 - Conversion from 'size_t' to 'type', possible loss of data.\n* C4305 - 'identifier' : truncation from 'type1' to 'type2'\n* C4355 - 'this' : used in base member initializer list\n* C4800 - 'type' : forcing value to bool 'true' or 'false' (performance warning)\n* C4996 - 'function': was declared deprecated\n\nC4251 is of particular note, if you are compiling the Protocol Buffer library\nas a DLL (see previous section).  The protocol buffer library uses templates in\nits public interfaces.  MSVC does not provide any reasonable way to export\ntemplate classes from a DLL.  However, in practice, it appears that exporting\ntemplates is not necessary anyway.  Since the complete definition of any\ntemplate is available in the header files, anyone importing the DLL will just\nend up compiling instances of the templates into their own binary.  The\nProtocol Buffer implementation does not rely on static template members being\nunique, so there should be no problem with this, but MSVC prints warning\nnevertheless.  So, we disable it.  Unfortunately, this warning will also be\nproduced when compiling code which merely uses protocol buffers, meaning you\nmay have to disable it in your code too.\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/cmake/examples.cmake",
    "content": "if(protobuf_VERBOSE)\n  message(STATUS \"Protocol Buffers Examples Configuring...\")\nendif()\n\nget_filename_component(examples_dir \"../examples\" ABSOLUTE)\n\nif(protobuf_VERBOSE)\n  message(STATUS \"Protocol Buffers Examples Configuring done\")\nendif()\ninclude(ExternalProject)\n\n# Internal utility function: Create a custom target representing a build of examples with custom options.\nfunction(add_examples_build NAME)\n\n  ExternalProject_Add(${NAME}\n    PREFIX ${NAME}\n    SOURCE_DIR \"${examples_dir}\"\n    BINARY_DIR ${NAME}\n    STAMP_DIR ${NAME}/logs\n    INSTALL_COMMAND \"\" #Skip\n    LOG_CONFIGURE 1\n    CMAKE_CACHE_ARGS \"-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}\"\n                     \"-Dprotobuf_VERBOSE:BOOL=${protobuf_VERBOSE}\"\n                     ${ARGN}\n  )\n  set_property(TARGET ${NAME} PROPERTY FOLDER \"Examples\")\n  set_property(TARGET ${NAME} PROPERTY EXCLUDE_FROM_ALL TRUE)\nendfunction()\n\n# Add examples as an external project.\n# sub_directory cannot be used because the find_package(protobuf) call would cause failures with redefined targets.\nadd_examples_build(examples \"-Dprotobuf_DIR:PATH=${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}\")\nadd_dependencies(examples libprotobuf protoc)\n\noption(protobuf_BUILD_EXAMPLES_MULTITEST \"Build Examples in multiple configurations. Useful for testing.\" OFF)\nmark_as_advanced(protobuf_BUILD_EXAMPLES_MULTITEST)\nif(protobuf_BUILD_EXAMPLES_MULTITEST)\n  set_property(GLOBAL PROPERTY USE_FOLDERS ON)\n\n  #Build using the legacy compatibility module.\n  add_examples_build(examples-legacy\n    \"-Dprotobuf_DIR:PATH=${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}\"\n    \"-Dprotobuf_MODULE_COMPATIBLE:BOOL=TRUE\"\n  )\n  add_dependencies(examples-legacy libprotobuf protoc)\n\n  #Build using the installed library.\n  add_examples_build(examples-installed\n    \"-Dprotobuf_DIR:PATH=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_CMAKEDIR}\"\n  )\n\n  #Build using the installed library in legacy compatibility mode.\n  add_examples_build(examples-installed-legacy\n    \"-Dprotobuf_DIR:PATH=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_CMAKEDIR}\"\n    \"-Dprotobuf_MODULE_COMPATIBLE:BOOL=TRUE\"\n  )\nendif()\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/cmake/extract_includes.bat.in",
    "content": "mkdir include\nmkdir include\\google\nmkdir include\\google\\protobuf\nmkdir include\\google\\protobuf\\compiler\nmkdir include\\google\\protobuf\\compiler\\cpp\nmkdir include\\google\\protobuf\\compiler\\csharp\nmkdir include\\google\\protobuf\\compiler\\java\nmkdir include\\google\\protobuf\\compiler\\javanano\nmkdir include\\google\\protobuf\\compiler\\js\nmkdir include\\google\\protobuf\\compiler\\objectivec\nmkdir include\\google\\protobuf\\compiler\\python\nmkdir include\\google\\protobuf\\compiler\\ruby\nmkdir include\\google\\protobuf\\io\nmkdir include\\google\\protobuf\\stubs\nmkdir include\\google\\protobuf\\util\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\any.h include\\google\\protobuf\\any.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\any.pb.h include\\google\\protobuf\\any.pb.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\api.pb.h include\\google\\protobuf\\api.pb.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\arena.h include\\google\\protobuf\\arena.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\arenastring.h include\\google\\protobuf\\arenastring.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\compiler\\code_generator.h include\\google\\protobuf\\compiler\\code_generator.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\compiler\\command_line_interface.h include\\google\\protobuf\\compiler\\command_line_interface.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\compiler\\cpp\\cpp_generator.h include\\google\\protobuf\\compiler\\cpp\\cpp_generator.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\compiler\\csharp\\csharp_generator.h include\\google\\protobuf\\compiler\\csharp\\csharp_generator.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\compiler\\csharp\\csharp_names.h include\\google\\protobuf\\compiler\\csharp\\csharp_names.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\compiler\\csharp\\csharp_options.h include\\google\\protobuf\\compiler\\csharp\\csharp_options.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\compiler\\importer.h include\\google\\protobuf\\compiler\\importer.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\compiler\\java\\java_generator.h include\\google\\protobuf\\compiler\\java\\java_generator.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\compiler\\java\\java_names.h include\\google\\protobuf\\compiler\\java\\java_names.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\compiler\\javanano\\javanano_generator.h include\\google\\protobuf\\compiler\\javanano\\javanano_generator.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\compiler\\js\\js_generator.h include\\google\\protobuf\\compiler\\js\\js_generator.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\compiler\\objectivec\\objectivec_generator.h include\\google\\protobuf\\compiler\\objectivec\\objectivec_generator.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\compiler\\objectivec\\objectivec_helpers.h include\\google\\protobuf\\compiler\\objectivec\\objectivec_helpers.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\compiler\\parser.h include\\google\\protobuf\\compiler\\parser.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\compiler\\plugin.h include\\google\\protobuf\\compiler\\plugin.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\compiler\\plugin.pb.h include\\google\\protobuf\\compiler\\plugin.pb.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\compiler\\python\\python_generator.h include\\google\\protobuf\\compiler\\python\\python_generator.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\compiler\\ruby\\ruby_generator.h include\\google\\protobuf\\compiler\\ruby\\ruby_generator.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\descriptor.h include\\google\\protobuf\\descriptor.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\descriptor.pb.h include\\google\\protobuf\\descriptor.pb.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\descriptor_database.h include\\google\\protobuf\\descriptor_database.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\duration.pb.h include\\google\\protobuf\\duration.pb.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\dynamic_message.h include\\google\\protobuf\\dynamic_message.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\empty.pb.h include\\google\\protobuf\\empty.pb.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\extension_set.h include\\google\\protobuf\\extension_set.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\field_mask.pb.h include\\google\\protobuf\\field_mask.pb.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\generated_enum_reflection.h include\\google\\protobuf\\generated_enum_reflection.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\generated_enum_util.h include\\google\\protobuf\\generated_enum_util.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\generated_message_reflection.h include\\google\\protobuf\\generated_message_reflection.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\generated_message_util.h include\\google\\protobuf\\generated_message_util.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\io\\coded_stream.h include\\google\\protobuf\\io\\coded_stream.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\io\\gzip_stream.h include\\google\\protobuf\\io\\gzip_stream.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\io\\printer.h include\\google\\protobuf\\io\\printer.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\io\\strtod.h include\\google\\protobuf\\io\\strtod.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\io\\tokenizer.h include\\google\\protobuf\\io\\tokenizer.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\io\\zero_copy_stream.h include\\google\\protobuf\\io\\zero_copy_stream.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\io\\zero_copy_stream_impl.h include\\google\\protobuf\\io\\zero_copy_stream_impl.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\io\\zero_copy_stream_impl_lite.h include\\google\\protobuf\\io\\zero_copy_stream_impl_lite.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\map.h include\\google\\protobuf\\map.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\map_entry.h include\\google\\protobuf\\map_entry.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\map_entry_lite.h include\\google\\protobuf\\map_entry_lite.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\map_field.h include\\google\\protobuf\\map_field.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\map_field_inl.h include\\google\\protobuf\\map_field_inl.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\map_field_lite.h include\\google\\protobuf\\map_field_lite.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\map_type_handler.h include\\google\\protobuf\\map_type_handler.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\message.h include\\google\\protobuf\\message.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\message_lite.h include\\google\\protobuf\\message_lite.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\metadata.h include\\google\\protobuf\\metadata.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\reflection.h include\\google\\protobuf\\reflection.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\reflection_ops.h include\\google\\protobuf\\reflection_ops.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\repeated_field.h include\\google\\protobuf\\repeated_field.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\repeated_field_reflection.h include\\google\\protobuf\\repeated_field_reflection.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\service.h include\\google\\protobuf\\service.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\source_context.pb.h include\\google\\protobuf\\source_context.pb.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\struct.pb.h include\\google\\protobuf\\struct.pb.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\atomic_sequence_num.h include\\google\\protobuf\\stubs\\atomic_sequence_num.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\atomicops.h include\\google\\protobuf\\stubs\\atomicops.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\atomicops_internals_arm64_gcc.h include\\google\\protobuf\\stubs\\atomicops_internals_arm64_gcc.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\atomicops_internals_arm_gcc.h include\\google\\protobuf\\stubs\\atomicops_internals_arm_gcc.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\atomicops_internals_arm_qnx.h include\\google\\protobuf\\stubs\\atomicops_internals_arm_qnx.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\atomicops_internals_atomicword_compat.h include\\google\\protobuf\\stubs\\atomicops_internals_atomicword_compat.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\atomicops_internals_generic_gcc.h include\\google\\protobuf\\stubs\\atomicops_internals_generic_gcc.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\atomicops_internals_macosx.h include\\google\\protobuf\\stubs\\atomicops_internals_macosx.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\atomicops_internals_mips_gcc.h include\\google\\protobuf\\stubs\\atomicops_internals_mips_gcc.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\atomicops_internals_pnacl.h include\\google\\protobuf\\stubs\\atomicops_internals_pnacl.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\atomicops_internals_power.h include\\google\\protobuf\\stubs\\atomicops_internals_power.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\atomicops_internals_solaris.h include\\google\\protobuf\\stubs\\atomicops_internals_solaris.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\atomicops_internals_tsan.h include\\google\\protobuf\\stubs\\atomicops_internals_tsan.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\atomicops_internals_x86_gcc.h include\\google\\protobuf\\stubs\\atomicops_internals_x86_gcc.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\atomicops_internals_x86_msvc.h include\\google\\protobuf\\stubs\\atomicops_internals_x86_msvc.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\bytestream.h include\\google\\protobuf\\stubs\\bytestream.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\callback.h include\\google\\protobuf\\stubs\\callback.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\casts.h include\\google\\protobuf\\stubs\\casts.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\common.h include\\google\\protobuf\\stubs\\common.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\fastmem.h include\\google\\protobuf\\stubs\\fastmem.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\hash.h include\\google\\protobuf\\stubs\\hash.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\logging.h include\\google\\protobuf\\stubs\\logging.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\macros.h include\\google\\protobuf\\stubs\\macros.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\mutex.h include\\google\\protobuf\\stubs\\mutex.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\once.h include\\google\\protobuf\\stubs\\once.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\platform_macros.h include\\google\\protobuf\\stubs\\platform_macros.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\port.h include\\google\\protobuf\\stubs\\port.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\scoped_ptr.h include\\google\\protobuf\\stubs\\scoped_ptr.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\shared_ptr.h include\\google\\protobuf\\stubs\\shared_ptr.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\singleton.h include\\google\\protobuf\\stubs\\singleton.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\status.h include\\google\\protobuf\\stubs\\status.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\stl_util.h include\\google\\protobuf\\stubs\\stl_util.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\stringpiece.h include\\google\\protobuf\\stubs\\stringpiece.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\template_util.h include\\google\\protobuf\\stubs\\template_util.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\stubs\\type_traits.h include\\google\\protobuf\\stubs\\type_traits.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\text_format.h include\\google\\protobuf\\text_format.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\timestamp.pb.h include\\google\\protobuf\\timestamp.pb.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\type.pb.h include\\google\\protobuf\\type.pb.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\unknown_field_set.h include\\google\\protobuf\\unknown_field_set.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\util\\field_comparator.h include\\google\\protobuf\\util\\field_comparator.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\util\\field_mask_util.h include\\google\\protobuf\\util\\field_mask_util.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\util\\json_util.h include\\google\\protobuf\\util\\json_util.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\util\\message_differencer.h include\\google\\protobuf\\util\\message_differencer.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\util\\time_util.h include\\google\\protobuf\\util\\time_util.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\util\\type_resolver.h include\\google\\protobuf\\util\\type_resolver.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\util\\type_resolver_util.h include\\google\\protobuf\\util\\type_resolver_util.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\wire_format.h include\\google\\protobuf\\wire_format.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\wire_format_lite.h include\\google\\protobuf\\wire_format_lite.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\wire_format_lite_inl.h include\\google\\protobuf\\wire_format_lite_inl.h\ncopy ${PROTOBUF_SOURCE_WIN32_PATH}\\..\\src\\google\\protobuf\\wrappers.pb.h include\\google\\protobuf\\wrappers.pb.h\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/cmake/install.cmake",
    "content": "include(GNUInstallDirs)\n\nforeach(_library\n  libprotobuf-lite\n  libprotobuf\n  libprotoc)\n  set_property(TARGET ${_library}\n    PROPERTY INTERFACE_INCLUDE_DIRECTORIES\n    $<BUILD_INTERFACE:${protobuf_source_dir}/src>\n    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)\n  install(TARGETS ${_library} EXPORT protobuf-targets\n    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${_library}\n    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${_library}\n    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${_library})\nendforeach()\n\ninstall(TARGETS protoc EXPORT protobuf-targets\n  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc)\n\nfile(STRINGS extract_includes.bat.in _extract_strings\n  REGEX \"^copy\")\nforeach(_extract_string ${_extract_strings})\n  string(REPLACE \"copy \\${PROTOBUF_SOURCE_WIN32_PATH}\\\\\" \"\"\n    _extract_string ${_extract_string})\n  string(REPLACE \"\\\\\" \"/\" _extract_string ${_extract_string})\n  string(REGEX MATCH \"^[^ ]+\"\n    _extract_from ${_extract_string})\n  string(REGEX REPLACE \"^${_extract_from} ([^$]+)\" \"\\\\1\"\n    _extract_to ${_extract_string})\n  get_filename_component(_extract_from \"${protobuf_SOURCE_DIR}/${_extract_from}\" ABSOLUTE)\n  get_filename_component(_extract_name ${_extract_to} NAME)\n  get_filename_component(_extract_to ${_extract_to} PATH)\n  string(REPLACE \"include/\" \"${CMAKE_INSTALL_INCLUDEDIR}/\"\n    _extract_to \"${_extract_to}\")\n  if(EXISTS \"${_extract_from}\")\n    install(FILES \"${_extract_from}\"\n      DESTINATION \"${_extract_to}\"\n      COMPONENT protobuf-headers\n      RENAME \"${_extract_name}\")\n  else()\n    message(AUTHOR_WARNING \"The file \\\"${_extract_from}\\\" is listed in \"\n      \"\\\"${protobuf_SOURCE_DIR}/cmake/extract_includes.bat.in\\\" \"\n      \"but there not exists. The file will not be installed.\")\n  endif()\nendforeach()\n\n# Internal function for parsing auto tools scripts\nfunction(_protobuf_auto_list FILE_NAME VARIABLE)\n  file(STRINGS ${FILE_NAME} _strings)\n  set(_list)\n  foreach(_string ${_strings})\n    set(_found)\n    string(REGEX MATCH \"^[ \\t]*${VARIABLE}[ \\t]*=[ \\t]*\" _found \"${_string}\")\n    if(_found)\n      string(LENGTH \"${_found}\" _length)\n      string(SUBSTRING \"${_string}\" ${_length} -1 _draft_list)\n      foreach(_item ${_draft_list})\n        string(STRIP \"${_item}\" _item)\n        list(APPEND _list \"${_item}\")\n      endforeach()\n    endif()\n  endforeach()\n  set(${VARIABLE} ${_list} PARENT_SCOPE)\nendfunction()\n\n# Install well-known type proto files\n_protobuf_auto_list(\"../src/Makefile.am\" nobase_dist_proto_DATA)\nforeach(_file ${nobase_dist_proto_DATA})\n  get_filename_component(_file_from \"../src/${_file}\" ABSOLUTE)\n  get_filename_component(_file_name ${_file} NAME)\n  get_filename_component(_file_path ${_file} PATH)\n  if(EXISTS \"${_file_from}\")\n    install(FILES \"${_file_from}\"\n      DESTINATION \"${CMAKE_INSTALL_INCLUDEDIR}/${_file_path}\"\n      COMPONENT protobuf-protos\n      RENAME \"${_file_name}\")\n  else()\n    message(AUTHOR_WARNING \"The file \\\"${_file_from}\\\" is listed in \"\n      \"\\\"${protobuf_SOURCE_DIR}/../src/Makefile.am\\\" as nobase_dist_proto_DATA \"\n      \"but there not exists. The file will not be installed.\")\n  endif()\nendforeach()\n\n# Install configuration\nset(_cmakedir_desc \"Directory relative to CMAKE_INSTALL to install the cmake configuration files\")\nif(NOT MSVC)\n  set(CMAKE_INSTALL_CMAKEDIR \"${CMAKE_INSTALL_LIBDIR}/cmake/protobuf\" CACHE STRING \"${_cmakedir_desc}\")\nelse()\n  set(CMAKE_INSTALL_CMAKEDIR \"cmake\" CACHE STRING \"${_cmakedir_desc}\")\nendif()\nmark_as_advanced(CMAKE_INSTALL_CMAKEDIR)\n\nconfigure_file(protobuf-config.cmake.in\n  ${CMAKE_INSTALL_CMAKEDIR}/protobuf-config.cmake @ONLY)\nconfigure_file(protobuf-config-version.cmake.in\n  ${CMAKE_INSTALL_CMAKEDIR}/protobuf-config-version.cmake @ONLY)\nconfigure_file(protobuf-module.cmake.in\n  ${CMAKE_INSTALL_CMAKEDIR}/protobuf-module.cmake @ONLY)\nconfigure_file(protobuf-options.cmake\n  ${CMAKE_INSTALL_CMAKEDIR}/protobuf-options.cmake @ONLY)\n\n# Allows the build directory to be used as a find directory.\nexport(TARGETS libprotobuf-lite libprotobuf libprotoc protoc\n  NAMESPACE protobuf::\n  FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake\n)\n\ninstall(EXPORT protobuf-targets\n  DESTINATION \"${CMAKE_INSTALL_CMAKEDIR}\"\n  NAMESPACE protobuf::\n  COMPONENT protobuf-export)\n\ninstall(DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}/\n  DESTINATION \"${CMAKE_INSTALL_CMAKEDIR}\"\n  COMPONENT protobuf-export\n  PATTERN protobuf-targets.cmake EXCLUDE\n)\n\noption(protobuf_INSTALL_EXAMPLES \"Install the examples folder\" OFF)\nif(protobuf_INSTALL_EXAMPLES)\n  install(DIRECTORY ../examples/ DESTINATION examples\n    COMPONENT protobuf-examples)\nendif()\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/cmake/libprotobuf-lite.cmake",
    "content": "set(libprotobuf_lite_files\n  ${protobuf_source_dir}/src/google/protobuf/arena.cc\n  ${protobuf_source_dir}/src/google/protobuf/arenastring.cc\n  ${protobuf_source_dir}/src/google/protobuf/extension_set.cc\n  ${protobuf_source_dir}/src/google/protobuf/generated_message_util.cc\n  ${protobuf_source_dir}/src/google/protobuf/io/coded_stream.cc\n  ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream.cc\n  ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc\n  ${protobuf_source_dir}/src/google/protobuf/message_lite.cc\n  ${protobuf_source_dir}/src/google/protobuf/repeated_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/bytestream.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/common.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/int128.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/once.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/status.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/statusor.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/stringpiece.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/stringprintf.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/structurally_valid.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/strutil.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/time.cc\n  ${protobuf_source_dir}/src/google/protobuf/wire_format_lite.cc\n)\n\nadd_library(libprotobuf-lite ${protobuf_SHARED_OR_STATIC}\n  ${libprotobuf_lite_files})\ntarget_link_libraries(libprotobuf-lite ${CMAKE_THREAD_LIBS_INIT})\ntarget_include_directories(libprotobuf-lite PUBLIC ${protobuf_source_dir}/src)\nif(MSVC AND protobuf_BUILD_SHARED_LIBS)\n  target_compile_definitions(libprotobuf-lite\n    PUBLIC  PROTOBUF_USE_DLLS\n    PRIVATE LIBPROTOBUF_EXPORTS)\nendif()\nset_target_properties(libprotobuf-lite PROPERTIES\n    OUTPUT_NAME ${LIB_PREFIX}protobuf-lite\n    DEBUG_POSTFIX \"${protobuf_DEBUG_POSTFIX}\")\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/cmake/libprotobuf.cmake",
    "content": "set(libprotobuf_files\n  ${protobuf_source_dir}/src/google/protobuf/any.cc\n  ${protobuf_source_dir}/src/google/protobuf/any.pb.cc\n  ${protobuf_source_dir}/src/google/protobuf/api.pb.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/importer.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/parser.cc\n  ${protobuf_source_dir}/src/google/protobuf/descriptor.cc\n  ${protobuf_source_dir}/src/google/protobuf/descriptor.pb.cc\n  ${protobuf_source_dir}/src/google/protobuf/descriptor_database.cc\n  ${protobuf_source_dir}/src/google/protobuf/duration.pb.cc\n  ${protobuf_source_dir}/src/google/protobuf/dynamic_message.cc\n  ${protobuf_source_dir}/src/google/protobuf/empty.pb.cc\n  ${protobuf_source_dir}/src/google/protobuf/extension_set_heavy.cc\n  ${protobuf_source_dir}/src/google/protobuf/field_mask.pb.cc\n  ${protobuf_source_dir}/src/google/protobuf/generated_message_reflection.cc\n  ${protobuf_source_dir}/src/google/protobuf/io/gzip_stream.cc\n  ${protobuf_source_dir}/src/google/protobuf/io/printer.cc\n  ${protobuf_source_dir}/src/google/protobuf/io/strtod.cc\n  ${protobuf_source_dir}/src/google/protobuf/io/tokenizer.cc\n  ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl.cc\n  ${protobuf_source_dir}/src/google/protobuf/map_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/message.cc\n  ${protobuf_source_dir}/src/google/protobuf/reflection_ops.cc\n  ${protobuf_source_dir}/src/google/protobuf/service.cc\n  ${protobuf_source_dir}/src/google/protobuf/source_context.pb.cc\n  ${protobuf_source_dir}/src/google/protobuf/struct.pb.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/mathlimits.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/substitute.cc\n  ${protobuf_source_dir}/src/google/protobuf/text_format.cc\n  ${protobuf_source_dir}/src/google/protobuf/timestamp.pb.cc\n  ${protobuf_source_dir}/src/google/protobuf/type.pb.cc\n  ${protobuf_source_dir}/src/google/protobuf/unknown_field_set.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/field_comparator.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/field_mask_util.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/internal/datapiece.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/internal/default_value_objectwriter.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/internal/error_listener.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/internal/field_mask_utility.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/internal/json_escaping.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/internal/json_objectwriter.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/internal/json_stream_parser.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/internal/object_writer.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/internal/proto_writer.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectsource.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectwriter.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/internal/type_info.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/internal/type_info_test_helper.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/internal/utility.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/json_util.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/message_differencer.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/time_util.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/type_resolver_util.cc\n  ${protobuf_source_dir}/src/google/protobuf/wire_format.cc\n  ${protobuf_source_dir}/src/google/protobuf/wrappers.pb.cc\n)\n\nadd_library(libprotobuf_3_0 ${protobuf_SHARED_OR_STATIC}\n  ${libprotobuf_lite_files} ${libprotobuf_files})\ntarget_link_libraries(libprotobuf_3_0 ${CMAKE_THREAD_LIBS_INIT} ${ZLIB_LIBRARIES})\ntarget_include_directories(libprotobuf_3_0 PUBLIC ${protobuf_source_dir}/src)\nif(MSVC AND protobuf_BUILD_SHARED_LIBS)\n  target_compile_definitions(libprotobuf_3_0\n    PUBLIC  PROTOBUF_USE_DLLS\n    PRIVATE LIBPROTOBUF_EXPORTS)\nendif()\nset_target_properties(libprotobuf_3_0 PROPERTIES\n    OUTPUT_NAME ${LIB_PREFIX}protobuf\n    DEBUG_POSTFIX \"${protobuf_DEBUG_POSTFIX}\")\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/cmake/libprotoc.cmake",
    "content": "set(libprotoc_files\n  ${protobuf_source_dir}/src/google/protobuf/compiler/code_generator.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/command_line_interface.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_enum.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_enum_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_extension.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_file.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_generator.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_helpers.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_map_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_message.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_message_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_service.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_string_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_enum.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_enum_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_field_base.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_generator.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_helpers.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_map_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_message.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_message_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_context.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_doc_comment.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_field_lite.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_lite.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_extension.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_extension_lite.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_file.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_generator.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_generator_factory.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_helpers.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_lazy_message_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_map_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_map_field_lite.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_builder.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_builder_lite.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_field_lite.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_lite.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_name_resolver.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_primitive_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_primitive_field_lite.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_service.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_shared_code_generator.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_string_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_string_field_lite.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_enum.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_enum_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_extension.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_file.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_generator.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_helpers.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_map_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_message.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_message_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/js/js_generator.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_extension.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_file.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_generator.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_message.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/plugin.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/plugin.pb.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/python/python_generator.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/ruby/ruby_generator.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/subprocess.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/zip_writer.cc\n)\n\nadd_library(libprotoc_3_0 ${protobuf_SHARED_OR_STATIC}\n  ${libprotoc_files})\ntarget_link_libraries(libprotoc_3_0 libprotobuf_3_0)\nif(MSVC AND protobuf_BUILD_SHARED_LIBS)\n  target_compile_definitions(libprotoc_3_0\n    PUBLIC  PROTOBUF_USE_DLLS\n    PRIVATE LIBPROTOC_EXPORTS)\nendif()\nset_target_properties(libprotoc_3_0 PROPERTIES\n    COMPILE_DEFINITIONS LIBPROTOC_EXPORTS\n    OUTPUT_NAME ${LIB_PREFIX}protoc\n    DEBUG_POSTFIX \"${protobuf_DEBUG_POSTFIX}\")\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/cmake/protobuf-config-version.cmake.in",
    "content": "set(PACKAGE_VERSION \"@protobuf_VERSION@\")\nset(${PACKAGE_FIND_NAME}_VERSION_PRERELEASE \"@protobuf_VERSION_PRERELEASE@\" PARENT_SCOPE)\n\n# Prerelease versions cannot be passed in directly via the find_package command,\n# so we allow users to specify it in a variable\nif(NOT DEFINED \"${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE\")\n  set(\"${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE}\" \"\")\nelse()\n  set(PACKAGE_FIND_VERSION ${PACKAGE_FIND_VERSION}-${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE})\nendif()\nset(PACKAGE_FIND_VERSION_PRERELEASE \"${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE}\")\n\n# VERSION_EQUAL ignores the prerelease strings, so we use STREQUAL.\nif(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)\n  set(PACKAGE_VERSION_EXACT TRUE)\nendif()\n\nset(PACKAGE_VERSION_COMPATIBLE TRUE) #Assume true until shown otherwise\n\nif(NOT PACKAGE_FIND_VERSION_MAJOR EQUAL \"@protobuf_VERSION_MAJOR@\")\n  set(PACKAGE_VERSION_COMPATIBLE FALSE)\nelseif(PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)\n  set(PACKAGE_VERSION_COMPATIBLE FALSE)\nelseif(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)\n  # Do not match prerelease versions to non-prerelease version requests.\n  if(NOT \"@protobuf_VERSION_PRERELEASE@\" STREQUAL \"\" AND PACKAGE_FIND_VERSION_PRERELEASE STREQUAL \"\")\n    message(AUTHOR_WARNING \"To use this prerelease version of ${PACKAGE_FIND_NAME}, set ${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE to '@protobuf_VERSION_PRERELEASE@' or greater.\")\n    set(PACKAGE_VERSION_COMPATIBLE FALSE)\n  endif()\n\n  # Not robustly SemVer compliant, but protobuf never uses '.' separated prerelease identifiers.\n  if(PACKAGE_FIND_VERSION_PRERELEASE STRGREATER \"@protobuf_VERSION_PRERELEASE@\")\n    set(PACKAGE_VERSION_COMPATIBLE FALSE)\n  endif()\nendif()\n\n# Check and save build options used to create this package\nmacro(_check_and_save_build_option OPTION VALUE)\n  if(DEFINED ${PACKAGE_FIND_NAME}_${OPTION} AND\n    NOT ${PACKAGE_FIND_NAME}_${OPTION} EQUAL VALUE)\n    set(PACKAGE_VERSION_UNSUITABLE TRUE)\n  endif()\n  set(${PACKAGE_FIND_NAME}_${OPTION} ${VALUE})\nendmacro()\n_check_and_save_build_option(WITH_ZLIB @protobuf_WITH_ZLIB@)\n_check_and_save_build_option(MSVC_STATIC_RUNTIME @protobuf_MSVC_STATIC_RUNTIME@)\n_check_and_save_build_option(BUILD_SHARED_LIBS @protobuf_BUILD_SHARED_LIBS@)\n\n# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:\nif(NOT \"${CMAKE_SIZEOF_VOID_P}\" STREQUAL \"\" AND NOT \"@CMAKE_SIZEOF_VOID_P@\" STREQUAL \"\")\n  # check that the installed version has the same 32/64bit-ness as the one which is currently searching:\n  if(NOT CMAKE_SIZEOF_VOID_P STREQUAL \"@CMAKE_SIZEOF_VOID_P@\")\n    math(EXPR installedBits \"@CMAKE_SIZEOF_VOID_P@ * 8\")\n    set(PACKAGE_VERSION \"${PACKAGE_VERSION} (${installedBits}bit)\")\n    set(PACKAGE_VERSION_UNSUITABLE TRUE)\n  endif()\nendif()\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/cmake/protobuf-config.cmake.in",
    "content": "# User options\ninclude(\"${CMAKE_CURRENT_LIST_DIR}/protobuf-options.cmake\")\n\n# Imported targets\ninclude(\"${CMAKE_CURRENT_LIST_DIR}/protobuf-targets.cmake\")\n\n# CMake FindProtobuf module compatible file\nif(protobuf_MODULE_COMPATIBLE)\n  include(\"${CMAKE_CURRENT_LIST_DIR}/protobuf-module.cmake\")\nendif()\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/cmake/protobuf-module.cmake.in",
    "content": "# Functions\n\nfunction(PROTOBUF_GENERATE_CPP SRCS HDRS)\n  if(NOT ARGN)\n    message(SEND_ERROR \"Error: PROTOBUF_GENERATE_CPP() called without any proto files\")\n    return()\n  endif()\n\n  if(PROTOBUF_GENERATE_CPP_APPEND_PATH)\n    # Create an include path for each file specified\n    foreach(FIL ${ARGN})\n      get_filename_component(ABS_FIL ${FIL} ABSOLUTE)\n      get_filename_component(ABS_PATH ${ABS_FIL} PATH)\n      list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)\n      if(${_contains_already} EQUAL -1)\n          list(APPEND _protobuf_include_path -I ${ABS_PATH})\n      endif()\n    endforeach()\n  else()\n    set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})\n  endif()\n\n  if(DEFINED Protobuf_IMPORT_DIRS)\n    foreach(DIR ${Protobuf_IMPORT_DIRS})\n      get_filename_component(ABS_PATH ${DIR} ABSOLUTE)\n      list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)\n      if(${_contains_already} EQUAL -1)\n          list(APPEND _protobuf_include_path -I ${ABS_PATH})\n      endif()\n    endforeach()\n  endif()\n\n  set(${SRCS})\n  set(${HDRS})\n  foreach(FIL ${ARGN})\n    get_filename_component(ABS_FIL ${FIL} ABSOLUTE)\n    get_filename_component(FIL_WE ${FIL} NAME_WE)\n\n    list(APPEND ${SRCS} \"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc\")\n    list(APPEND ${HDRS} \"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h\")\n\n    add_custom_command(\n      OUTPUT \"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc\"\n             \"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h\"\n      COMMAND  ${Protobuf_PROTOC_EXECUTABLE}\n      ARGS --cpp_out  ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL}\n      DEPENDS ${ABS_FIL} ${Protobuf_PROTOC_EXECUTABLE}\n      COMMENT \"Running C++ protocol buffer compiler on ${FIL}\"\n      VERBATIM )\n  endforeach()\n\n  set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE)\n  set(${SRCS} ${${SRCS}} PARENT_SCOPE)\n  set(${HDRS} ${${HDRS}} PARENT_SCOPE)\nendfunction()\n\nfunction(PROTOBUF_GENERATE_PYTHON SRCS)\n  if(NOT ARGN)\n    message(SEND_ERROR \"Error: PROTOBUF_GENERATE_PYTHON() called without any proto files\")\n    return()\n  endif()\n\n  if(PROTOBUF_GENERATE_CPP_APPEND_PATH)\n    # Create an include path for each file specified\n    foreach(FIL ${ARGN})\n      get_filename_component(ABS_FIL ${FIL} ABSOLUTE)\n      get_filename_component(ABS_PATH ${ABS_FIL} PATH)\n      list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)\n      if(${_contains_already} EQUAL -1)\n          list(APPEND _protobuf_include_path -I ${ABS_PATH})\n      endif()\n    endforeach()\n  else()\n    set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})\n  endif()\n\n  if(DEFINED Protobuf_IMPORT_DIRS)\n    foreach(DIR ${Protobuf_IMPORT_DIRS})\n      get_filename_component(ABS_PATH ${DIR} ABSOLUTE)\n      list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)\n      if(${_contains_already} EQUAL -1)\n          list(APPEND _protobuf_include_path -I ${ABS_PATH})\n      endif()\n    endforeach()\n  endif()\n\n  set(${SRCS})\n  foreach(FIL ${ARGN})\n    get_filename_component(ABS_FIL ${FIL} ABSOLUTE)\n    get_filename_component(FIL_WE ${FIL} NAME_WE)\n\n    list(APPEND ${SRCS} \"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py\")\n    add_custom_command(\n      OUTPUT \"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}_pb2.py\"\n      COMMAND  ${Protobuf_PROTOC_EXECUTABLE} --python_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL}\n      DEPENDS ${ABS_FIL} ${Protobuf_PROTOC_EXECUTABLE}\n      COMMENT \"Running Python protocol buffer compiler on ${FIL}\"\n      VERBATIM )\n  endforeach()\n\n  set(${SRCS} ${${SRCS}} PARENT_SCOPE)\nendfunction()\n\n# Environment\n\n# Backwards compatibility\n# Define camel case versions of input variables\nforeach(UPPER\n    PROTOBUF_SRC_ROOT_FOLDER\n    PROTOBUF_IMPORT_DIRS\n    PROTOBUF_DEBUG\n    PROTOBUF_LIBRARY\n    PROTOBUF_PROTOC_LIBRARY\n    PROTOBUF_INCLUDE_DIR\n    PROTOBUF_PROTOC_EXECUTABLE\n    PROTOBUF_LIBRARY_DEBUG\n    PROTOBUF_PROTOC_LIBRARY_DEBUG\n    PROTOBUF_LITE_LIBRARY\n    PROTOBUF_LITE_LIBRARY_DEBUG\n    )\n    if (DEFINED ${UPPER})\n        string(REPLACE \"PROTOBUF_\" \"Protobuf_\" Camel ${UPPER})\n        if (NOT DEFINED ${Camel})\n            set(${Camel} ${${UPPER}})\n        endif()\n    endif()\nendforeach()\n\nif(DEFINED Protobuf_SRC_ROOT_FOLDER)\n  message(AUTHOR_WARNING \"Variable Protobuf_SRC_ROOT_FOLDER defined, but not\"\n    \" used in CONFIG mode\")\nendif()\n\ninclude(SelectLibraryConfigurations)\n\n# Internal function: search for normal library as well as a debug one\n#    if the debug one is specified also include debug/optimized keywords\n#    in *_LIBRARIES variable\nfunction(_protobuf_find_libraries name filename)\n  if(${name}_LIBRARIES)\n    # Use result recorded by a previous call.\n  elseif(${name}_LIBRARY)\n    # Honor cache entry used by CMake 3.5 and lower.\n    set(${name}_LIBRARIES \"${${name}_LIBRARY}\" PARENT_SCOPE)\n  else()\n    get_target_property(${name}_LIBRARY_RELEASE protobuf::lib${filename}\n      LOCATION_RELEASE)\n    get_target_property(${name}_LIBRARY_DEBUG protobuf::lib${filename}\n      LOCATION_DEBUG)\n    endif()\n\n    select_library_configurations(${name})\n    set(${name}_LIBRARY ${${name}_LIBRARY} PARENT_SCOPE)\n    set(${name}_LIBRARIES ${${name}_LIBRARIES} PARENT_SCOPE)\n  endif()\nendfunction()\n\n# Internal function: find threads library\nfunction(_protobuf_find_threads)\n    set(CMAKE_THREAD_PREFER_PTHREAD TRUE)\n    find_package(Threads)\n    if(Threads_FOUND)\n        list(APPEND PROTOBUF_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})\n        set(PROTOBUF_LIBRARIES \"${PROTOBUF_LIBRARIES}\" PARENT_SCOPE)\n    endif()\nendfunction()\n\n#\n# Main.\n#\n\n# By default have PROTOBUF_GENERATE_CPP macro pass -I to protoc\n# for each directory where a proto file is referenced.\nif(NOT DEFINED PROTOBUF_GENERATE_CPP_APPEND_PATH)\n  set(PROTOBUF_GENERATE_CPP_APPEND_PATH TRUE)\nendif()\n\n# The Protobuf library\n_protobuf_find_libraries(Protobuf protobuf)\n\n# The Protobuf Lite library\n_protobuf_find_libraries(Protobuf_LITE protobuf-lite)\n\n# The Protobuf Protoc Library\n_protobuf_find_libraries(Protobuf_PROTOC protoc)\n\nif(UNIX)\n  _protobuf_find_threads()\nendif()\n\n# Set the include directory\nget_target_property(Protobuf_INCLUDE_DIRS protobuf::libprotobuf\n  INTERFACE_INCLUDE_DIRECTORIES)\n\n# Set the protoc Executable\nget_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc\n  IMPORTED_LOCATION_RELEASE)\nif(NOT EXISTS \"${Protobuf_PROTOC_EXECUTABLE}\")\n  get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc\n    IMPORTED_LOCATION_DEBUG)\nendif()\n\n# Version info variable\nset(Protobuf_VERSION \"@protobuf_VERSION@\")\n\ninclude(FindPackageHandleStandardArgs)\nFIND_PACKAGE_HANDLE_STANDARD_ARGS(Protobuf\n    REQUIRED_VARS Protobuf_PROTOC_EXECUTABLE Protobuf_LIBRARIES Protobuf_INCLUDE_DIRS\n    VERSION_VAR Protobuf_VERSION\n)\n\n# Backwards compatibility\n# Define upper case versions of output variables\nforeach(Camel\n    Protobuf_VERSION\n    Protobuf_SRC_ROOT_FOLDER\n    Protobuf_IMPORT_DIRS\n    Protobuf_DEBUG\n    Protobuf_INCLUDE_DIRS\n    Protobuf_LIBRARIES\n    Protobuf_PROTOC_LIBRARIES\n    Protobuf_LITE_LIBRARIES\n    Protobuf_LIBRARY\n    Protobuf_PROTOC_LIBRARY\n    Protobuf_INCLUDE_DIR\n    Protobuf_PROTOC_EXECUTABLE\n    Protobuf_LIBRARY_DEBUG\n    Protobuf_PROTOC_LIBRARY_DEBUG\n    Protobuf_LITE_LIBRARY\n    Protobuf_LITE_LIBRARY_DEBUG\n    )\n    string(TOUPPER ${Camel} UPPER)\n    set(${UPPER} ${${Camel}})\nendforeach()\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/cmake/protobuf-options.cmake",
    "content": "# Verbose output\noption(protobuf_VERBOSE \"Enable for verbose output\" OFF)\nmark_as_advanced(protobuf_VERBOSE)\n\n# FindProtobuf module compatibel\noption(protobuf_MODULE_COMPATIBLE \"CMake build-in FindProtobuf.cmake module compatible\" OFF)\nmark_as_advanced(protobuf_MODULE_COMPATIBLE)\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/cmake/protoc.cmake",
    "content": "set(protoc_files\n  ${protobuf_source_dir}/src/google/protobuf/compiler/main.cc\n)\n\nadd_executable(protoc_3_0 ${protoc_files})\nset_target_properties(protoc_3_0 PROPERTIES\n  OUTPUT_NAME protoc)\ntarget_link_libraries(protoc_3_0 libprotobuf_3_0 libprotoc_3_0)\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/cmake/tests.cmake",
    "content": "if (NOT EXISTS \"${PROJECT_SOURCE_DIR}/../gmock/CMakeLists.txt\")\n  message(FATAL_ERROR \"Cannot find gmock directory.\")\nendif()\n\noption(protobuf_ABSOLUTE_TEST_PLUGIN_PATH\n  \"Using absolute test_plugin path in tests\" ON)\nmark_as_advanced(protobuf_ABSOLUTE_TEST_PLUGIN_PATH)\n\ninclude_directories(\n  ${protobuf_source_dir}/gmock\n  ${protobuf_source_dir}/gmock/gtest\n  ${protobuf_source_dir}/gmock/gtest/include\n  ${protobuf_source_dir}/gmock/include\n)\n\nadd_library(gmock STATIC\n  ${protobuf_source_dir}/gmock/src/gmock-all.cc\n  ${protobuf_source_dir}/gmock/gtest/src/gtest-all.cc\n)\nadd_library(gmock_main STATIC ${protobuf_source_dir}/gmock/src/gmock_main.cc)\ntarget_link_libraries(gmock_main gmock)\n\nset(lite_test_protos\n  google/protobuf/map_lite_unittest.proto\n  google/protobuf/unittest_import_lite.proto\n  google/protobuf/unittest_import_public_lite.proto\n  google/protobuf/unittest_lite.proto\n  google/protobuf/unittest_no_arena_lite.proto\n)\n\nset(tests_protos\n  google/protobuf/any_test.proto\n  google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto\n  google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto\n  google/protobuf/map_proto2_unittest.proto\n  google/protobuf/map_unittest.proto\n  google/protobuf/unittest.proto\n  google/protobuf/unittest_arena.proto\n  google/protobuf/unittest_custom_options.proto\n  google/protobuf/unittest_drop_unknown_fields.proto\n  google/protobuf/unittest_embed_optimize_for.proto\n  google/protobuf/unittest_empty.proto\n  google/protobuf/unittest_import.proto\n  google/protobuf/unittest_import_public.proto\n  google/protobuf/unittest_lite_imports_nonlite.proto\n  google/protobuf/unittest_mset.proto\n  google/protobuf/unittest_mset_wire_format.proto\n  google/protobuf/unittest_no_arena.proto\n  google/protobuf/unittest_no_arena_import.proto\n  google/protobuf/unittest_no_field_presence.proto\n  google/protobuf/unittest_no_generic_services.proto\n  google/protobuf/unittest_optimize_for.proto\n  google/protobuf/unittest_preserve_unknown_enum.proto\n  google/protobuf/unittest_preserve_unknown_enum2.proto\n  google/protobuf/unittest_proto3_arena.proto\n  google/protobuf/unittest_proto3_arena_lite.proto\n  google/protobuf/unittest_proto3_lite.proto\n  google/protobuf/unittest_well_known_types.proto\n  google/protobuf/util/internal/testdata/anys.proto\n  google/protobuf/util/internal/testdata/books.proto\n  google/protobuf/util/internal/testdata/default_value.proto\n  google/protobuf/util/internal/testdata/default_value_test.proto\n  google/protobuf/util/internal/testdata/field_mask.proto\n  google/protobuf/util/internal/testdata/maps.proto\n  google/protobuf/util/internal/testdata/oneofs.proto\n  google/protobuf/util/internal/testdata/struct.proto\n  google/protobuf/util/internal/testdata/timestamp_duration.proto\n  google/protobuf/util/json_format_proto3.proto\n  google/protobuf/util/message_differencer_unittest.proto\n)\n\nmacro(compile_proto_file filename)\n  get_filename_component(dirname ${filename} PATH)\n  get_filename_component(basename ${filename} NAME_WE)\n  add_custom_command(\n    OUTPUT ${protobuf_source_dir}/src/${dirname}/${basename}.pb.cc\n    DEPENDS protoc ${protobuf_source_dir}/src/${dirname}/${basename}.proto\n    COMMAND protoc ${protobuf_source_dir}/src/${dirname}/${basename}.proto\n        --proto_path=${protobuf_source_dir}/src\n        --cpp_out=${protobuf_source_dir}/src\n  )\nendmacro(compile_proto_file)\n\nset(lite_test_proto_files)\nforeach(proto_file ${lite_test_protos})\n  compile_proto_file(${proto_file})\n  string(REPLACE .proto .pb.cc pb_file ${proto_file})\n  set(lite_test_proto_files ${lite_test_proto_files}\n      ${protobuf_source_dir}/src/${pb_file})\nendforeach(proto_file)\n\nset(tests_proto_files)\nforeach(proto_file ${tests_protos})\n  compile_proto_file(${proto_file})\n  string(REPLACE .proto .pb.cc pb_file ${proto_file})\n  set(tests_proto_files ${tests_proto_files}\n      ${protobuf_source_dir}/src/${pb_file})\nendforeach(proto_file)\n\nset(common_test_files\n  ${protobuf_source_dir}/src/google/protobuf/arena_test_util.cc\n  ${protobuf_source_dir}/src/google/protobuf/map_test_util.cc\n  ${protobuf_source_dir}/src/google/protobuf/test_util.cc\n  ${protobuf_source_dir}/src/google/protobuf/testing/file.cc\n  ${protobuf_source_dir}/src/google/protobuf/testing/googletest.cc\n)\n\nset(common_lite_test_files\n  ${protobuf_source_dir}/src/google/protobuf/arena_test_util.cc\n  ${protobuf_source_dir}/src/google/protobuf/map_lite_test_util.cc\n  ${protobuf_source_dir}/src/google/protobuf/test_util_lite.cc\n)\n\nset(tests_files\n  ${protobuf_source_dir}/src/google/protobuf/any_test.cc\n  ${protobuf_source_dir}/src/google/protobuf/arena_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/arenastring_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/command_line_interface_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/cpp/metadata_test.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/importer_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_doc_comment_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/java/java_plugin_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/mock_code_generator.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/parser_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/python/python_plugin_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/descriptor_database_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/descriptor_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/drop_unknown_fields_test.cc\n  ${protobuf_source_dir}/src/google/protobuf/dynamic_message_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/extension_set_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/generated_message_reflection_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/io/coded_stream_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/io/printer_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/io/tokenizer_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/map_field_test.cc\n  ${protobuf_source_dir}/src/google/protobuf/map_test.cc\n  ${protobuf_source_dir}/src/google/protobuf/message_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/no_field_presence_test.cc\n  ${protobuf_source_dir}/src/google/protobuf/preserve_unknown_enum_test.cc\n  ${protobuf_source_dir}/src/google/protobuf/proto3_arena_lite_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/proto3_arena_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/proto3_lite_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/reflection_ops_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/repeated_field_reflection_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/repeated_field_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/bytestream_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/common_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/int128_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/once_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/status_test.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/statusor_test.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/stringpiece_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/stringprintf_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/structurally_valid_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/strutil_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/template_util_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/time_test.cc\n  ${protobuf_source_dir}/src/google/protobuf/stubs/type_traits_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/text_format_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/unknown_field_set_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/field_comparator_test.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/field_mask_util_test.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/internal/default_value_objectwriter_test.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/internal/json_objectwriter_test.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/internal/json_stream_parser_test.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectsource_test.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectwriter_test.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/internal/type_info_test_helper.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/json_util_test.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/message_differencer_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/time_util_test.cc\n  ${protobuf_source_dir}/src/google/protobuf/util/type_resolver_util_test.cc\n  ${protobuf_source_dir}/src/google/protobuf/well_known_types_unittest.cc\n  ${protobuf_source_dir}/src/google/protobuf/wire_format_unittest.cc\n)\n\nif(protobuf_ABSOLUTE_TEST_PLUGIN_PATH)\n  add_compile_options(-DGOOGLE_PROTOBUF_TEST_PLUGIN_PATH=\"$<TARGET_FILE:test_plugin>\")\nendif()\n\nadd_executable(tests ${tests_files} ${common_test_files} ${tests_proto_files} ${lite_test_proto_files})\ntarget_link_libraries(tests libprotoc libprotobuf gmock_main)\n\nset(test_plugin_files\n  ${protobuf_source_dir}/src/google/protobuf/compiler/mock_code_generator.cc\n  ${protobuf_source_dir}/src/google/protobuf/testing/file.cc\n  ${protobuf_source_dir}/src/google/protobuf/testing/file.h\n  ${protobuf_source_dir}/src/google/protobuf/compiler/test_plugin.cc\n)\n\nadd_executable(test_plugin ${test_plugin_files})\ntarget_link_libraries(test_plugin libprotoc libprotobuf gmock)\n\nset(lite_test_files\n  ${protobuf_source_dir}/src/google/protobuf/lite_unittest.cc\n)\nadd_executable(lite-test ${lite_test_files} ${common_lite_test_files} ${lite_test_proto_files})\ntarget_link_libraries(lite-test libprotobuf-lite)\n\nset(lite_arena_test_files\n  ${protobuf_source_dir}/src/google/protobuf/lite_arena_unittest.cc\n)\nadd_executable(lite-arena-test ${lite_arena_test_files} ${common_lite_test_files} ${lite_test_proto_files})\ntarget_link_libraries(lite-arena-test libprotobuf-lite gmock_main)\n\nadd_custom_target(check\n  COMMAND tests\n  WORKING_DIRECTORY ${protobuf_source_dir})\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/compile",
    "content": "#! /bin/sh\n# Wrapper for compilers which do not understand '-c -o'.\n\nscriptversion=2012-10-14.11; # UTC\n\n# Copyright (C) 1999-2013 Free Software Foundation, Inc.\n# Written by Tom Tromey <tromey@cygnus.com>.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 2, or (at your option)\n# any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\n# As a special exception to the GNU General Public License, if you\n# distribute this file as part of a program that contains a\n# configuration script generated by Autoconf, you may include it under\n# the same distribution terms that you use for the rest of that program.\n\n# This file is maintained in Automake, please report\n# bugs to <bug-automake@gnu.org> or send patches to\n# <automake-patches@gnu.org>.\n\nnl='\n'\n\n# We need space, tab and new line, in precisely that order.  Quoting is\n# there to prevent tools from complaining about whitespace usage.\nIFS=\" \"\"\t$nl\"\n\nfile_conv=\n\n# func_file_conv build_file lazy\n# Convert a $build file to $host form and store it in $file\n# Currently only supports Windows hosts. If the determined conversion\n# type is listed in (the comma separated) LAZY, no conversion will\n# take place.\nfunc_file_conv ()\n{\n  file=$1\n  case $file in\n    / | /[!/]*) # absolute file, and not a UNC file\n      if test -z \"$file_conv\"; then\n\t# lazily determine how to convert abs files\n\tcase `uname -s` in\n\t  MINGW*)\n\t    file_conv=mingw\n\t    ;;\n\t  CYGWIN*)\n\t    file_conv=cygwin\n\t    ;;\n\t  *)\n\t    file_conv=wine\n\t    ;;\n\tesac\n      fi\n      case $file_conv/,$2, in\n\t*,$file_conv,*)\n\t  ;;\n\tmingw/*)\n\t  file=`cmd //C echo \"$file \" | sed -e 's/\"\\(.*\\) \" *$/\\1/'`\n\t  ;;\n\tcygwin/*)\n\t  file=`cygpath -m \"$file\" || echo \"$file\"`\n\t  ;;\n\twine/*)\n\t  file=`winepath -w \"$file\" || echo \"$file\"`\n\t  ;;\n      esac\n      ;;\n  esac\n}\n\n# func_cl_dashL linkdir\n# Make cl look for libraries in LINKDIR\nfunc_cl_dashL ()\n{\n  func_file_conv \"$1\"\n  if test -z \"$lib_path\"; then\n    lib_path=$file\n  else\n    lib_path=\"$lib_path;$file\"\n  fi\n  linker_opts=\"$linker_opts -LIBPATH:$file\"\n}\n\n# func_cl_dashl library\n# Do a library search-path lookup for cl\nfunc_cl_dashl ()\n{\n  lib=$1\n  found=no\n  save_IFS=$IFS\n  IFS=';'\n  for dir in $lib_path $LIB\n  do\n    IFS=$save_IFS\n    if $shared && test -f \"$dir/$lib.dll.lib\"; then\n      found=yes\n      lib=$dir/$lib.dll.lib\n      break\n    fi\n    if test -f \"$dir/$lib.lib\"; then\n      found=yes\n      lib=$dir/$lib.lib\n      break\n    fi\n    if test -f \"$dir/lib$lib.a\"; then\n      found=yes\n      lib=$dir/lib$lib.a\n      break\n    fi\n  done\n  IFS=$save_IFS\n\n  if test \"$found\" != yes; then\n    lib=$lib.lib\n  fi\n}\n\n# func_cl_wrapper cl arg...\n# Adjust compile command to suit cl\nfunc_cl_wrapper ()\n{\n  # Assume a capable shell\n  lib_path=\n  shared=:\n  linker_opts=\n  for arg\n  do\n    if test -n \"$eat\"; then\n      eat=\n    else\n      case $1 in\n\t-o)\n\t  # configure might choose to run compile as 'compile cc -o foo foo.c'.\n\t  eat=1\n\t  case $2 in\n\t    *.o | *.[oO][bB][jJ])\n\t      func_file_conv \"$2\"\n\t      set x \"$@\" -Fo\"$file\"\n\t      shift\n\t      ;;\n\t    *)\n\t      func_file_conv \"$2\"\n\t      set x \"$@\" -Fe\"$file\"\n\t      shift\n\t      ;;\n\t  esac\n\t  ;;\n\t-I)\n\t  eat=1\n\t  func_file_conv \"$2\" mingw\n\t  set x \"$@\" -I\"$file\"\n\t  shift\n\t  ;;\n\t-I*)\n\t  func_file_conv \"${1#-I}\" mingw\n\t  set x \"$@\" -I\"$file\"\n\t  shift\n\t  ;;\n\t-l)\n\t  eat=1\n\t  func_cl_dashl \"$2\"\n\t  set x \"$@\" \"$lib\"\n\t  shift\n\t  ;;\n\t-l*)\n\t  func_cl_dashl \"${1#-l}\"\n\t  set x \"$@\" \"$lib\"\n\t  shift\n\t  ;;\n\t-L)\n\t  eat=1\n\t  func_cl_dashL \"$2\"\n\t  ;;\n\t-L*)\n\t  func_cl_dashL \"${1#-L}\"\n\t  ;;\n\t-static)\n\t  shared=false\n\t  ;;\n\t-Wl,*)\n\t  arg=${1#-Wl,}\n\t  save_ifs=\"$IFS\"; IFS=','\n\t  for flag in $arg; do\n\t    IFS=\"$save_ifs\"\n\t    linker_opts=\"$linker_opts $flag\"\n\t  done\n\t  IFS=\"$save_ifs\"\n\t  ;;\n\t-Xlinker)\n\t  eat=1\n\t  linker_opts=\"$linker_opts $2\"\n\t  ;;\n\t-*)\n\t  set x \"$@\" \"$1\"\n\t  shift\n\t  ;;\n\t*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)\n\t  func_file_conv \"$1\"\n\t  set x \"$@\" -Tp\"$file\"\n\t  shift\n\t  ;;\n\t*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])\n\t  func_file_conv \"$1\" mingw\n\t  set x \"$@\" \"$file\"\n\t  shift\n\t  ;;\n\t*)\n\t  set x \"$@\" \"$1\"\n\t  shift\n\t  ;;\n      esac\n    fi\n    shift\n  done\n  if test -n \"$linker_opts\"; then\n    linker_opts=\"-link$linker_opts\"\n  fi\n  exec \"$@\" $linker_opts\n  exit 1\n}\n\neat=\n\ncase $1 in\n  '')\n     echo \"$0: No command.  Try '$0 --help' for more information.\" 1>&2\n     exit 1;\n     ;;\n  -h | --h*)\n    cat <<\\EOF\nUsage: compile [--help] [--version] PROGRAM [ARGS]\n\nWrapper for compilers which do not understand '-c -o'.\nRemove '-o dest.o' from ARGS, run PROGRAM with the remaining\narguments, and rename the output as expected.\n\nIf you are trying to build a whole package this is not the\nright script to run: please start by reading the file 'INSTALL'.\n\nReport bugs to <bug-automake@gnu.org>.\nEOF\n    exit $?\n    ;;\n  -v | --v*)\n    echo \"compile $scriptversion\"\n    exit $?\n    ;;\n  cl | *[/\\\\]cl | cl.exe | *[/\\\\]cl.exe )\n    func_cl_wrapper \"$@\"      # Doesn't return...\n    ;;\nesac\n\nofile=\ncfile=\n\nfor arg\ndo\n  if test -n \"$eat\"; then\n    eat=\n  else\n    case $1 in\n      -o)\n\t# configure might choose to run compile as 'compile cc -o foo foo.c'.\n\t# So we strip '-o arg' only if arg is an object.\n\teat=1\n\tcase $2 in\n\t  *.o | *.obj)\n\t    ofile=$2\n\t    ;;\n\t  *)\n\t    set x \"$@\" -o \"$2\"\n\t    shift\n\t    ;;\n\tesac\n\t;;\n      *.c)\n\tcfile=$1\n\tset x \"$@\" \"$1\"\n\tshift\n\t;;\n      *)\n\tset x \"$@\" \"$1\"\n\tshift\n\t;;\n    esac\n  fi\n  shift\ndone\n\nif test -z \"$ofile\" || test -z \"$cfile\"; then\n  # If no '-o' option was seen then we might have been invoked from a\n  # pattern rule where we don't need one.  That is ok -- this is a\n  # normal compilation that the losing compiler can handle.  If no\n  # '.c' file was seen then we are probably linking.  That is also\n  # ok.\n  exec \"$@\"\nfi\n\n# Name of file we expect compiler to create.\ncofile=`echo \"$cfile\" | sed 's|^.*[\\\\/]||; s|^[a-zA-Z]:||; s/\\.c$/.o/'`\n\n# Create the lock directory.\n# Note: use '[/\\\\:.-]' here to ensure that we don't use the same name\n# that we are using for the .o file.  Also, base the name on the expected\n# object file name, since that is what matters with a parallel build.\nlockdir=`echo \"$cofile\" | sed -e 's|[/\\\\:.-]|_|g'`.d\nwhile true; do\n  if mkdir \"$lockdir\" >/dev/null 2>&1; then\n    break\n  fi\n  sleep 1\ndone\n# FIXME: race condition here if user kills between mkdir and trap.\ntrap \"rmdir '$lockdir'; exit 1\" 1 2 15\n\n# Run the compile.\n\"$@\"\nret=$?\n\nif test -f \"$cofile\"; then\n  test \"$cofile\" = \"$ofile\" || mv \"$cofile\" \"$ofile\"\nelif test -f \"${cofile}bj\"; then\n  test \"${cofile}bj\" = \"$ofile\" || mv \"${cofile}bj\" \"$ofile\"\nfi\n\nrmdir \"$lockdir\"\nexit $ret\n\n# Local Variables:\n# mode: shell-script\n# sh-indentation: 2\n# eval: (add-hook 'write-file-hooks 'time-stamp)\n# time-stamp-start: \"scriptversion=\"\n# time-stamp-format: \"%:y-%02m-%02d.%02H\"\n# time-stamp-time-zone: \"UTC\"\n# time-stamp-end: \"; # UTC\"\n# End:\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/config.guess",
    "content": "#! /bin/sh\n# Attempt to guess a canonical system name.\n#   Copyright 1992-2013 Free Software Foundation, Inc.\n\ntimestamp='2013-06-10'\n\n# This file is free software; you can redistribute it and/or modify it\n# under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful, but\n# WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n# General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, see <http://www.gnu.org/licenses/>.\n#\n# As a special exception to the GNU General Public License, if you\n# distribute this file as part of a program that contains a\n# configuration script generated by Autoconf, you may include it under\n# the same distribution terms that you use for the rest of that\n# program.  This Exception is an additional permission under section 7\n# of the GNU General Public License, version 3 (\"GPLv3\").\n#\n# Originally written by Per Bothner.\n#\n# You can get the latest version of this script from:\n# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD\n#\n# Please send patches with a ChangeLog entry to config-patches@gnu.org.\n\n\nme=`echo \"$0\" | sed -e 's,.*/,,'`\n\nusage=\"\\\nUsage: $0 [OPTION]\n\nOutput the configuration name of the system \\`$me' is run on.\n\nOperation modes:\n  -h, --help         print this help, then exit\n  -t, --time-stamp   print date of last modification, then exit\n  -v, --version      print version number, then exit\n\nReport bugs and patches to <config-patches@gnu.org>.\"\n\nversion=\"\\\nGNU config.guess ($timestamp)\n\nOriginally written by Per Bothner.\nCopyright 1992-2013 Free Software Foundation, Inc.\n\nThis is free software; see the source for copying conditions.  There is NO\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\"\n\nhelp=\"\nTry \\`$me --help' for more information.\"\n\n# Parse command line\nwhile test $# -gt 0 ; do\n  case $1 in\n    --time-stamp | --time* | -t )\n       echo \"$timestamp\" ; exit ;;\n    --version | -v )\n       echo \"$version\" ; exit ;;\n    --help | --h* | -h )\n       echo \"$usage\"; exit ;;\n    -- )     # Stop option processing\n       shift; break ;;\n    - )\t# Use stdin as input.\n       break ;;\n    -* )\n       echo \"$me: invalid option $1$help\" >&2\n       exit 1 ;;\n    * )\n       break ;;\n  esac\ndone\n\nif test $# != 0; then\n  echo \"$me: too many arguments$help\" >&2\n  exit 1\nfi\n\ntrap 'exit 1' 1 2 15\n\n# CC_FOR_BUILD -- compiler used by this script. Note that the use of a\n# compiler to aid in system detection is discouraged as it requires\n# temporary files to be created and, as you can see below, it is a\n# headache to deal with in a portable fashion.\n\n# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still\n# use `HOST_CC' if defined, but it is deprecated.\n\n# Portable tmp directory creation inspired by the Autoconf team.\n\nset_cc_for_build='\ntrap \"exitcode=\\$?; (rm -f \\$tmpfiles 2>/dev/null; rmdir \\$tmp 2>/dev/null) && exit \\$exitcode\" 0 ;\ntrap \"rm -f \\$tmpfiles 2>/dev/null; rmdir \\$tmp 2>/dev/null; exit 1\" 1 2 13 15 ;\n: ${TMPDIR=/tmp} ;\n { tmp=`(umask 077 && mktemp -d \"$TMPDIR/cgXXXXXX\") 2>/dev/null` && test -n \"$tmp\" && test -d \"$tmp\" ; } ||\n { test -n \"$RANDOM\" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||\n { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo \"Warning: creating insecure temp directory\" >&2 ; } ||\n { echo \"$me: cannot create a temporary directory in $TMPDIR\" >&2 ; exit 1 ; } ;\ndummy=$tmp/dummy ;\ntmpfiles=\"$dummy.c $dummy.o $dummy.rel $dummy\" ;\ncase $CC_FOR_BUILD,$HOST_CC,$CC in\n ,,)    echo \"int x;\" > $dummy.c ;\n\tfor c in cc gcc c89 c99 ; do\n\t  if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then\n\t     CC_FOR_BUILD=\"$c\"; break ;\n\t  fi ;\n\tdone ;\n\tif test x\"$CC_FOR_BUILD\" = x ; then\n\t  CC_FOR_BUILD=no_compiler_found ;\n\tfi\n\t;;\n ,,*)   CC_FOR_BUILD=$CC ;;\n ,*,*)  CC_FOR_BUILD=$HOST_CC ;;\nesac ; set_cc_for_build= ;'\n\n# This is needed to find uname on a Pyramid OSx when run in the BSD universe.\n# (ghazi@noc.rutgers.edu 1994-08-24)\nif (test -f /.attbin/uname) >/dev/null 2>&1 ; then\n\tPATH=$PATH:/.attbin ; export PATH\nfi\n\nUNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown\nUNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown\nUNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown\nUNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown\n\ncase \"${UNAME_SYSTEM}\" in\nLinux|GNU|GNU/*)\n\t# If the system lacks a compiler, then just pick glibc.\n\t# We could probably try harder.\n\tLIBC=gnu\n\n\teval $set_cc_for_build\n\tcat <<-EOF > $dummy.c\n\t#include <features.h>\n\t#if defined(__UCLIBC__)\n\tLIBC=uclibc\n\t#elif defined(__dietlibc__)\n\tLIBC=dietlibc\n\t#else\n\tLIBC=gnu\n\t#endif\n\tEOF\n\teval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`\n\t;;\nesac\n\n# Note: order is significant - the case branches are not exclusive.\n\ncase \"${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}\" in\n    *:NetBSD:*:*)\n\t# NetBSD (nbsd) targets should (where applicable) match one or\n\t# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,\n\t# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently\n\t# switched to ELF, *-*-netbsd* would select the old\n\t# object file format.  This provides both forward\n\t# compatibility and a consistent mechanism for selecting the\n\t# object file format.\n\t#\n\t# Note: NetBSD doesn't particularly care about the vendor\n\t# portion of the name.  We always set it to \"unknown\".\n\tsysctl=\"sysctl -n hw.machine_arch\"\n\tUNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \\\n\t    /usr/sbin/$sysctl 2>/dev/null || echo unknown)`\n\tcase \"${UNAME_MACHINE_ARCH}\" in\n\t    armeb) machine=armeb-unknown ;;\n\t    arm*) machine=arm-unknown ;;\n\t    sh3el) machine=shl-unknown ;;\n\t    sh3eb) machine=sh-unknown ;;\n\t    sh5el) machine=sh5le-unknown ;;\n\t    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;\n\tesac\n\t# The Operating System including object format, if it has switched\n\t# to ELF recently, or will in the future.\n\tcase \"${UNAME_MACHINE_ARCH}\" in\n\t    arm*|i386|m68k|ns32k|sh3*|sparc|vax)\n\t\teval $set_cc_for_build\n\t\tif echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \\\n\t\t\t| grep -q __ELF__\n\t\tthen\n\t\t    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).\n\t\t    # Return netbsd for either.  FIX?\n\t\t    os=netbsd\n\t\telse\n\t\t    os=netbsdelf\n\t\tfi\n\t\t;;\n\t    *)\n\t\tos=netbsd\n\t\t;;\n\tesac\n\t# The OS release\n\t# Debian GNU/NetBSD machines have a different userland, and\n\t# thus, need a distinct triplet. However, they do not need\n\t# kernel version information, so it can be replaced with a\n\t# suitable tag, in the style of linux-gnu.\n\tcase \"${UNAME_VERSION}\" in\n\t    Debian*)\n\t\trelease='-gnu'\n\t\t;;\n\t    *)\n\t\trelease=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\\./'`\n\t\t;;\n\tesac\n\t# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:\n\t# contains redundant information, the shorter form:\n\t# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.\n\techo \"${machine}-${os}${release}\"\n\texit ;;\n    *:Bitrig:*:*)\n\tUNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`\n\techo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}\n\texit ;;\n    *:OpenBSD:*:*)\n\tUNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`\n\techo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}\n\texit ;;\n    *:ekkoBSD:*:*)\n\techo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}\n\texit ;;\n    *:SolidBSD:*:*)\n\techo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}\n\texit ;;\n    macppc:MirBSD:*:*)\n\techo powerpc-unknown-mirbsd${UNAME_RELEASE}\n\texit ;;\n    *:MirBSD:*:*)\n\techo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}\n\texit ;;\n    alpha:OSF1:*:*)\n\tcase $UNAME_RELEASE in\n\t*4.0)\n\t\tUNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`\n\t\t;;\n\t*5.*)\n\t\tUNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`\n\t\t;;\n\tesac\n\t# According to Compaq, /usr/sbin/psrinfo has been available on\n\t# OSF/1 and Tru64 systems produced since 1995.  I hope that\n\t# covers most systems running today.  This code pipes the CPU\n\t# types through head -n 1, so we only detect the type of CPU 0.\n\tALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \\(.*\\) processor.*$/\\1/p' | head -n 1`\n\tcase \"$ALPHA_CPU_TYPE\" in\n\t    \"EV4 (21064)\")\n\t\tUNAME_MACHINE=\"alpha\" ;;\n\t    \"EV4.5 (21064)\")\n\t\tUNAME_MACHINE=\"alpha\" ;;\n\t    \"LCA4 (21066/21068)\")\n\t\tUNAME_MACHINE=\"alpha\" ;;\n\t    \"EV5 (21164)\")\n\t\tUNAME_MACHINE=\"alphaev5\" ;;\n\t    \"EV5.6 (21164A)\")\n\t\tUNAME_MACHINE=\"alphaev56\" ;;\n\t    \"EV5.6 (21164PC)\")\n\t\tUNAME_MACHINE=\"alphapca56\" ;;\n\t    \"EV5.7 (21164PC)\")\n\t\tUNAME_MACHINE=\"alphapca57\" ;;\n\t    \"EV6 (21264)\")\n\t\tUNAME_MACHINE=\"alphaev6\" ;;\n\t    \"EV6.7 (21264A)\")\n\t\tUNAME_MACHINE=\"alphaev67\" ;;\n\t    \"EV6.8CB (21264C)\")\n\t\tUNAME_MACHINE=\"alphaev68\" ;;\n\t    \"EV6.8AL (21264B)\")\n\t\tUNAME_MACHINE=\"alphaev68\" ;;\n\t    \"EV6.8CX (21264D)\")\n\t\tUNAME_MACHINE=\"alphaev68\" ;;\n\t    \"EV6.9A (21264/EV69A)\")\n\t\tUNAME_MACHINE=\"alphaev69\" ;;\n\t    \"EV7 (21364)\")\n\t\tUNAME_MACHINE=\"alphaev7\" ;;\n\t    \"EV7.9 (21364A)\")\n\t\tUNAME_MACHINE=\"alphaev79\" ;;\n\tesac\n\t# A Pn.n version is a patched version.\n\t# A Vn.n version is a released version.\n\t# A Tn.n version is a released field test version.\n\t# A Xn.n version is an unreleased experimental baselevel.\n\t# 1.2 uses \"1.2\" for uname -r.\n\techo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`\n\t# Reset EXIT trap before exiting to avoid spurious non-zero exit code.\n\texitcode=$?\n\ttrap '' 0\n\texit $exitcode ;;\n    Alpha\\ *:Windows_NT*:*)\n\t# How do we know it's Interix rather than the generic POSIX subsystem?\n\t# Should we change UNAME_MACHINE based on the output of uname instead\n\t# of the specific Alpha model?\n\techo alpha-pc-interix\n\texit ;;\n    21064:Windows_NT:50:3)\n\techo alpha-dec-winnt3.5\n\texit ;;\n    Amiga*:UNIX_System_V:4.0:*)\n\techo m68k-unknown-sysv4\n\texit ;;\n    *:[Aa]miga[Oo][Ss]:*:*)\n\techo ${UNAME_MACHINE}-unknown-amigaos\n\texit ;;\n    *:[Mm]orph[Oo][Ss]:*:*)\n\techo ${UNAME_MACHINE}-unknown-morphos\n\texit ;;\n    *:OS/390:*:*)\n\techo i370-ibm-openedition\n\texit ;;\n    *:z/VM:*:*)\n\techo s390-ibm-zvmoe\n\texit ;;\n    *:OS400:*:*)\n\techo powerpc-ibm-os400\n\texit ;;\n    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)\n\techo arm-acorn-riscix${UNAME_RELEASE}\n\texit ;;\n    arm*:riscos:*:*|arm*:RISCOS:*:*)\n\techo arm-unknown-riscos\n\texit ;;\n    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)\n\techo hppa1.1-hitachi-hiuxmpp\n\texit ;;\n    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)\n\t# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.\n\tif test \"`(/bin/universe) 2>/dev/null`\" = att ; then\n\t\techo pyramid-pyramid-sysv3\n\telse\n\t\techo pyramid-pyramid-bsd\n\tfi\n\texit ;;\n    NILE*:*:*:dcosx)\n\techo pyramid-pyramid-svr4\n\texit ;;\n    DRS?6000:unix:4.0:6*)\n\techo sparc-icl-nx6\n\texit ;;\n    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)\n\tcase `/usr/bin/uname -p` in\n\t    sparc) echo sparc-icl-nx7; exit ;;\n\tesac ;;\n    s390x:SunOS:*:*)\n\techo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`\n\texit ;;\n    sun4H:SunOS:5.*:*)\n\techo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`\n\texit ;;\n    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)\n\techo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`\n\texit ;;\n    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)\n\techo i386-pc-auroraux${UNAME_RELEASE}\n\texit ;;\n    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)\n\teval $set_cc_for_build\n\tSUN_ARCH=\"i386\"\n\t# If there is a compiler, see if it is configured for 64-bit objects.\n\t# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.\n\t# This test works for both compilers.\n\tif [ \"$CC_FOR_BUILD\" != 'no_compiler_found' ]; then\n\t    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \\\n\t\t(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \\\n\t\tgrep IS_64BIT_ARCH >/dev/null\n\t    then\n\t\tSUN_ARCH=\"x86_64\"\n\t    fi\n\tfi\n\techo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`\n\texit ;;\n    sun4*:SunOS:6*:*)\n\t# According to config.sub, this is the proper way to canonicalize\n\t# SunOS6.  Hard to guess exactly what SunOS6 will be like, but\n\t# it's likely to be more like Solaris than SunOS4.\n\techo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`\n\texit ;;\n    sun4*:SunOS:*:*)\n\tcase \"`/usr/bin/arch -k`\" in\n\t    Series*|S4*)\n\t\tUNAME_RELEASE=`uname -v`\n\t\t;;\n\tesac\n\t# Japanese Language versions have a version number like `4.1.3-JL'.\n\techo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`\n\texit ;;\n    sun3*:SunOS:*:*)\n\techo m68k-sun-sunos${UNAME_RELEASE}\n\texit ;;\n    sun*:*:4.2BSD:*)\n\tUNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`\n\ttest \"x${UNAME_RELEASE}\" = \"x\" && UNAME_RELEASE=3\n\tcase \"`/bin/arch`\" in\n\t    sun3)\n\t\techo m68k-sun-sunos${UNAME_RELEASE}\n\t\t;;\n\t    sun4)\n\t\techo sparc-sun-sunos${UNAME_RELEASE}\n\t\t;;\n\tesac\n\texit ;;\n    aushp:SunOS:*:*)\n\techo sparc-auspex-sunos${UNAME_RELEASE}\n\texit ;;\n    # The situation for MiNT is a little confusing.  The machine name\n    # can be virtually everything (everything which is not\n    # \"atarist\" or \"atariste\" at least should have a processor\n    # > m68000).  The system name ranges from \"MiNT\" over \"FreeMiNT\"\n    # to the lowercase version \"mint\" (or \"freemint\").  Finally\n    # the system name \"TOS\" denotes a system which is actually not\n    # MiNT.  But MiNT is downward compatible to TOS, so this should\n    # be no problem.\n    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)\n\techo m68k-atari-mint${UNAME_RELEASE}\n\texit ;;\n    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)\n\techo m68k-atari-mint${UNAME_RELEASE}\n\texit ;;\n    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)\n\techo m68k-atari-mint${UNAME_RELEASE}\n\texit ;;\n    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)\n\techo m68k-milan-mint${UNAME_RELEASE}\n\texit ;;\n    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)\n\techo m68k-hades-mint${UNAME_RELEASE}\n\texit ;;\n    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)\n\techo m68k-unknown-mint${UNAME_RELEASE}\n\texit ;;\n    m68k:machten:*:*)\n\techo m68k-apple-machten${UNAME_RELEASE}\n\texit ;;\n    powerpc:machten:*:*)\n\techo powerpc-apple-machten${UNAME_RELEASE}\n\texit ;;\n    RISC*:Mach:*:*)\n\techo mips-dec-mach_bsd4.3\n\texit ;;\n    RISC*:ULTRIX:*:*)\n\techo mips-dec-ultrix${UNAME_RELEASE}\n\texit ;;\n    VAX*:ULTRIX*:*:*)\n\techo vax-dec-ultrix${UNAME_RELEASE}\n\texit ;;\n    2020:CLIX:*:* | 2430:CLIX:*:*)\n\techo clipper-intergraph-clix${UNAME_RELEASE}\n\texit ;;\n    mips:*:*:UMIPS | mips:*:*:RISCos)\n\teval $set_cc_for_build\n\tsed 's/^\t//' << EOF >$dummy.c\n#ifdef __cplusplus\n#include <stdio.h>  /* for printf() prototype */\n\tint main (int argc, char *argv[]) {\n#else\n\tint main (argc, argv) int argc; char *argv[]; {\n#endif\n\t#if defined (host_mips) && defined (MIPSEB)\n\t#if defined (SYSTYPE_SYSV)\n\t  printf (\"mips-mips-riscos%ssysv\\n\", argv[1]); exit (0);\n\t#endif\n\t#if defined (SYSTYPE_SVR4)\n\t  printf (\"mips-mips-riscos%ssvr4\\n\", argv[1]); exit (0);\n\t#endif\n\t#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)\n\t  printf (\"mips-mips-riscos%sbsd\\n\", argv[1]); exit (0);\n\t#endif\n\t#endif\n\t  exit (-1);\n\t}\nEOF\n\t$CC_FOR_BUILD -o $dummy $dummy.c &&\n\t  dummyarg=`echo \"${UNAME_RELEASE}\" | sed -n 's/\\([0-9]*\\).*/\\1/p'` &&\n\t  SYSTEM_NAME=`$dummy $dummyarg` &&\n\t    { echo \"$SYSTEM_NAME\"; exit; }\n\techo mips-mips-riscos${UNAME_RELEASE}\n\texit ;;\n    Motorola:PowerMAX_OS:*:*)\n\techo powerpc-motorola-powermax\n\texit ;;\n    Motorola:*:4.3:PL8-*)\n\techo powerpc-harris-powermax\n\texit ;;\n    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)\n\techo powerpc-harris-powermax\n\texit ;;\n    Night_Hawk:Power_UNIX:*:*)\n\techo powerpc-harris-powerunix\n\texit ;;\n    m88k:CX/UX:7*:*)\n\techo m88k-harris-cxux7\n\texit ;;\n    m88k:*:4*:R4*)\n\techo m88k-motorola-sysv4\n\texit ;;\n    m88k:*:3*:R3*)\n\techo m88k-motorola-sysv3\n\texit ;;\n    AViiON:dgux:*:*)\n\t# DG/UX returns AViiON for all architectures\n\tUNAME_PROCESSOR=`/usr/bin/uname -p`\n\tif [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]\n\tthen\n\t    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \\\n\t       [ ${TARGET_BINARY_INTERFACE}x = x ]\n\t    then\n\t\techo m88k-dg-dgux${UNAME_RELEASE}\n\t    else\n\t\techo m88k-dg-dguxbcs${UNAME_RELEASE}\n\t    fi\n\telse\n\t    echo i586-dg-dgux${UNAME_RELEASE}\n\tfi\n\texit ;;\n    M88*:DolphinOS:*:*)\t# DolphinOS (SVR3)\n\techo m88k-dolphin-sysv3\n\texit ;;\n    M88*:*:R3*:*)\n\t# Delta 88k system running SVR3\n\techo m88k-motorola-sysv3\n\texit ;;\n    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)\n\techo m88k-tektronix-sysv3\n\texit ;;\n    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)\n\techo m68k-tektronix-bsd\n\texit ;;\n    *:IRIX*:*:*)\n\techo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`\n\texit ;;\n    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.\n\techo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id\n\texit ;;               # Note that: echo \"'`uname -s`'\" gives 'AIX '\n    i*86:AIX:*:*)\n\techo i386-ibm-aix\n\texit ;;\n    ia64:AIX:*:*)\n\tif [ -x /usr/bin/oslevel ] ; then\n\t\tIBM_REV=`/usr/bin/oslevel`\n\telse\n\t\tIBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}\n\tfi\n\techo ${UNAME_MACHINE}-ibm-aix${IBM_REV}\n\texit ;;\n    *:AIX:2:3)\n\tif grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then\n\t\teval $set_cc_for_build\n\t\tsed 's/^\t\t//' << EOF >$dummy.c\n\t\t#include <sys/systemcfg.h>\n\n\t\tmain()\n\t\t\t{\n\t\t\tif (!__power_pc())\n\t\t\t\texit(1);\n\t\t\tputs(\"powerpc-ibm-aix3.2.5\");\n\t\t\texit(0);\n\t\t\t}\nEOF\n\t\tif $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`\n\t\tthen\n\t\t\techo \"$SYSTEM_NAME\"\n\t\telse\n\t\t\techo rs6000-ibm-aix3.2.5\n\t\tfi\n\telif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then\n\t\techo rs6000-ibm-aix3.2.4\n\telse\n\t\techo rs6000-ibm-aix3.2\n\tfi\n\texit ;;\n    *:AIX:*:[4567])\n\tIBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`\n\tif /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then\n\t\tIBM_ARCH=rs6000\n\telse\n\t\tIBM_ARCH=powerpc\n\tfi\n\tif [ -x /usr/bin/oslevel ] ; then\n\t\tIBM_REV=`/usr/bin/oslevel`\n\telse\n\t\tIBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}\n\tfi\n\techo ${IBM_ARCH}-ibm-aix${IBM_REV}\n\texit ;;\n    *:AIX:*:*)\n\techo rs6000-ibm-aix\n\texit ;;\n    ibmrt:4.4BSD:*|romp-ibm:BSD:*)\n\techo romp-ibm-bsd4.4\n\texit ;;\n    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and\n\techo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to\n\texit ;;                             # report: romp-ibm BSD 4.3\n    *:BOSX:*:*)\n\techo rs6000-bull-bosx\n\texit ;;\n    DPX/2?00:B.O.S.:*:*)\n\techo m68k-bull-sysv3\n\texit ;;\n    9000/[34]??:4.3bsd:1.*:*)\n\techo m68k-hp-bsd\n\texit ;;\n    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)\n\techo m68k-hp-bsd4.4\n\texit ;;\n    9000/[34678]??:HP-UX:*:*)\n\tHPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`\n\tcase \"${UNAME_MACHINE}\" in\n\t    9000/31? )            HP_ARCH=m68000 ;;\n\t    9000/[34]?? )         HP_ARCH=m68k ;;\n\t    9000/[678][0-9][0-9])\n\t\tif [ -x /usr/bin/getconf ]; then\n\t\t    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`\n\t\t    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`\n\t\t    case \"${sc_cpu_version}\" in\n\t\t      523) HP_ARCH=\"hppa1.0\" ;; # CPU_PA_RISC1_0\n\t\t      528) HP_ARCH=\"hppa1.1\" ;; # CPU_PA_RISC1_1\n\t\t      532)                      # CPU_PA_RISC2_0\n\t\t\tcase \"${sc_kernel_bits}\" in\n\t\t\t  32) HP_ARCH=\"hppa2.0n\" ;;\n\t\t\t  64) HP_ARCH=\"hppa2.0w\" ;;\n\t\t\t  '') HP_ARCH=\"hppa2.0\" ;;   # HP-UX 10.20\n\t\t\tesac ;;\n\t\t    esac\n\t\tfi\n\t\tif [ \"${HP_ARCH}\" = \"\" ]; then\n\t\t    eval $set_cc_for_build\n\t\t    sed 's/^\t\t//' << EOF >$dummy.c\n\n\t\t#define _HPUX_SOURCE\n\t\t#include <stdlib.h>\n\t\t#include <unistd.h>\n\n\t\tint main ()\n\t\t{\n\t\t#if defined(_SC_KERNEL_BITS)\n\t\t    long bits = sysconf(_SC_KERNEL_BITS);\n\t\t#endif\n\t\t    long cpu  = sysconf (_SC_CPU_VERSION);\n\n\t\t    switch (cpu)\n\t\t\t{\n\t\t\tcase CPU_PA_RISC1_0: puts (\"hppa1.0\"); break;\n\t\t\tcase CPU_PA_RISC1_1: puts (\"hppa1.1\"); break;\n\t\t\tcase CPU_PA_RISC2_0:\n\t\t#if defined(_SC_KERNEL_BITS)\n\t\t\t    switch (bits)\n\t\t\t\t{\n\t\t\t\tcase 64: puts (\"hppa2.0w\"); break;\n\t\t\t\tcase 32: puts (\"hppa2.0n\"); break;\n\t\t\t\tdefault: puts (\"hppa2.0\"); break;\n\t\t\t\t} break;\n\t\t#else  /* !defined(_SC_KERNEL_BITS) */\n\t\t\t    puts (\"hppa2.0\"); break;\n\t\t#endif\n\t\t\tdefault: puts (\"hppa1.0\"); break;\n\t\t\t}\n\t\t    exit (0);\n\t\t}\nEOF\n\t\t    (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`\n\t\t    test -z \"$HP_ARCH\" && HP_ARCH=hppa\n\t\tfi ;;\n\tesac\n\tif [ ${HP_ARCH} = \"hppa2.0w\" ]\n\tthen\n\t    eval $set_cc_for_build\n\n\t    # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating\n\t    # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler\n\t    # generating 64-bit code.  GNU and HP use different nomenclature:\n\t    #\n\t    # $ CC_FOR_BUILD=cc ./config.guess\n\t    # => hppa2.0w-hp-hpux11.23\n\t    # $ CC_FOR_BUILD=\"cc +DA2.0w\" ./config.guess\n\t    # => hppa64-hp-hpux11.23\n\n\t    if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |\n\t\tgrep -q __LP64__\n\t    then\n\t\tHP_ARCH=\"hppa2.0w\"\n\t    else\n\t\tHP_ARCH=\"hppa64\"\n\t    fi\n\tfi\n\techo ${HP_ARCH}-hp-hpux${HPUX_REV}\n\texit ;;\n    ia64:HP-UX:*:*)\n\tHPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`\n\techo ia64-hp-hpux${HPUX_REV}\n\texit ;;\n    3050*:HI-UX:*:*)\n\teval $set_cc_for_build\n\tsed 's/^\t//' << EOF >$dummy.c\n\t#include <unistd.h>\n\tint\n\tmain ()\n\t{\n\t  long cpu = sysconf (_SC_CPU_VERSION);\n\t  /* The order matters, because CPU_IS_HP_MC68K erroneously returns\n\t     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct\n\t     results, however.  */\n\t  if (CPU_IS_PA_RISC (cpu))\n\t    {\n\t      switch (cpu)\n\t\t{\n\t\t  case CPU_PA_RISC1_0: puts (\"hppa1.0-hitachi-hiuxwe2\"); break;\n\t\t  case CPU_PA_RISC1_1: puts (\"hppa1.1-hitachi-hiuxwe2\"); break;\n\t\t  case CPU_PA_RISC2_0: puts (\"hppa2.0-hitachi-hiuxwe2\"); break;\n\t\t  default: puts (\"hppa-hitachi-hiuxwe2\"); break;\n\t\t}\n\t    }\n\t  else if (CPU_IS_HP_MC68K (cpu))\n\t    puts (\"m68k-hitachi-hiuxwe2\");\n\t  else puts (\"unknown-hitachi-hiuxwe2\");\n\t  exit (0);\n\t}\nEOF\n\t$CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&\n\t\t{ echo \"$SYSTEM_NAME\"; exit; }\n\techo unknown-hitachi-hiuxwe2\n\texit ;;\n    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )\n\techo hppa1.1-hp-bsd\n\texit ;;\n    9000/8??:4.3bsd:*:*)\n\techo hppa1.0-hp-bsd\n\texit ;;\n    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)\n\techo hppa1.0-hp-mpeix\n\texit ;;\n    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )\n\techo hppa1.1-hp-osf\n\texit ;;\n    hp8??:OSF1:*:*)\n\techo hppa1.0-hp-osf\n\texit ;;\n    i*86:OSF1:*:*)\n\tif [ -x /usr/sbin/sysversion ] ; then\n\t    echo ${UNAME_MACHINE}-unknown-osf1mk\n\telse\n\t    echo ${UNAME_MACHINE}-unknown-osf1\n\tfi\n\texit ;;\n    parisc*:Lites*:*:*)\n\techo hppa1.1-hp-lites\n\texit ;;\n    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)\n\techo c1-convex-bsd\n\texit ;;\n    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)\n\tif getsysinfo -f scalar_acc\n\tthen echo c32-convex-bsd\n\telse echo c2-convex-bsd\n\tfi\n\texit ;;\n    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)\n\techo c34-convex-bsd\n\texit ;;\n    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)\n\techo c38-convex-bsd\n\texit ;;\n    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)\n\techo c4-convex-bsd\n\texit ;;\n    CRAY*Y-MP:*:*:*)\n\techo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\\.[^.]*$/.X/'\n\texit ;;\n    CRAY*[A-Z]90:*:*:*)\n\techo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \\\n\t| sed -e 's/CRAY.*\\([A-Z]90\\)/\\1/' \\\n\t      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \\\n\t      -e 's/\\.[^.]*$/.X/'\n\texit ;;\n    CRAY*TS:*:*:*)\n\techo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\\.[^.]*$/.X/'\n\texit ;;\n    CRAY*T3E:*:*:*)\n\techo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\\.[^.]*$/.X/'\n\texit ;;\n    CRAY*SV1:*:*:*)\n\techo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\\.[^.]*$/.X/'\n\texit ;;\n    *:UNICOS/mp:*:*)\n\techo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\\.[^.]*$/.X/'\n\texit ;;\n    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)\n\tFUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`\n\tFUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\\///'`\n\tFUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`\n\techo \"${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}\"\n\texit ;;\n    5000:UNIX_System_V:4.*:*)\n\tFUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\\///'`\n\tFUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`\n\techo \"sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}\"\n\texit ;;\n    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\\ Embedded/OS:*:*)\n\techo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}\n\texit ;;\n    sparc*:BSD/OS:*:*)\n\techo sparc-unknown-bsdi${UNAME_RELEASE}\n\texit ;;\n    *:BSD/OS:*:*)\n\techo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}\n\texit ;;\n    *:FreeBSD:*:*)\n\tUNAME_PROCESSOR=`/usr/bin/uname -p`\n\tcase ${UNAME_PROCESSOR} in\n\t    amd64)\n\t\techo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;\n\t    *)\n\t\techo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;\n\tesac\n\texit ;;\n    i*:CYGWIN*:*)\n\techo ${UNAME_MACHINE}-pc-cygwin\n\texit ;;\n    *:MINGW64*:*)\n\techo ${UNAME_MACHINE}-pc-mingw64\n\texit ;;\n    *:MINGW*:*)\n\techo ${UNAME_MACHINE}-pc-mingw32\n\texit ;;\n    i*:MSYS*:*)\n\techo ${UNAME_MACHINE}-pc-msys\n\texit ;;\n    i*:windows32*:*)\n\t# uname -m includes \"-pc\" on this system.\n\techo ${UNAME_MACHINE}-mingw32\n\texit ;;\n    i*:PW*:*)\n\techo ${UNAME_MACHINE}-pc-pw32\n\texit ;;\n    *:Interix*:*)\n\tcase ${UNAME_MACHINE} in\n\t    x86)\n\t\techo i586-pc-interix${UNAME_RELEASE}\n\t\texit ;;\n\t    authenticamd | genuineintel | EM64T)\n\t\techo x86_64-unknown-interix${UNAME_RELEASE}\n\t\texit ;;\n\t    IA64)\n\t\techo ia64-unknown-interix${UNAME_RELEASE}\n\t\texit ;;\n\tesac ;;\n    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)\n\techo i${UNAME_MACHINE}-pc-mks\n\texit ;;\n    8664:Windows_NT:*)\n\techo x86_64-pc-mks\n\texit ;;\n    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)\n\t# How do we know it's Interix rather than the generic POSIX subsystem?\n\t# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we\n\t# UNAME_MACHINE based on the output of uname instead of i386?\n\techo i586-pc-interix\n\texit ;;\n    i*:UWIN*:*)\n\techo ${UNAME_MACHINE}-pc-uwin\n\texit ;;\n    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)\n\techo x86_64-unknown-cygwin\n\texit ;;\n    p*:CYGWIN*:*)\n\techo powerpcle-unknown-cygwin\n\texit ;;\n    prep*:SunOS:5.*:*)\n\techo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`\n\texit ;;\n    *:GNU:*:*)\n\t# the GNU system\n\techo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`\n\texit ;;\n    *:GNU/*:*:*)\n\t# other systems with GNU libc and userland\n\techo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}\n\texit ;;\n    i*86:Minix:*:*)\n\techo ${UNAME_MACHINE}-pc-minix\n\texit ;;\n    aarch64:Linux:*:*)\n\techo ${UNAME_MACHINE}-unknown-linux-${LIBC}\n\texit ;;\n    aarch64_be:Linux:*:*)\n\tUNAME_MACHINE=aarch64_be\n\techo ${UNAME_MACHINE}-unknown-linux-${LIBC}\n\texit ;;\n    alpha:Linux:*:*)\n\tcase `sed -n '/^cpu model/s/^.*: \\(.*\\)/\\1/p' < /proc/cpuinfo` in\n\t  EV5)   UNAME_MACHINE=alphaev5 ;;\n\t  EV56)  UNAME_MACHINE=alphaev56 ;;\n\t  PCA56) UNAME_MACHINE=alphapca56 ;;\n\t  PCA57) UNAME_MACHINE=alphapca56 ;;\n\t  EV6)   UNAME_MACHINE=alphaev6 ;;\n\t  EV67)  UNAME_MACHINE=alphaev67 ;;\n\t  EV68*) UNAME_MACHINE=alphaev68 ;;\n\tesac\n\tobjdump --private-headers /bin/sh | grep -q ld.so.1\n\tif test \"$?\" = 0 ; then LIBC=\"gnulibc1\" ; fi\n\techo ${UNAME_MACHINE}-unknown-linux-${LIBC}\n\texit ;;\n    arc:Linux:*:* | arceb:Linux:*:*)\n\techo ${UNAME_MACHINE}-unknown-linux-${LIBC}\n\texit ;;\n    arm*:Linux:*:*)\n\teval $set_cc_for_build\n\tif echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \\\n\t    | grep -q __ARM_EABI__\n\tthen\n\t    echo ${UNAME_MACHINE}-unknown-linux-${LIBC}\n\telse\n\t    if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \\\n\t\t| grep -q __ARM_PCS_VFP\n\t    then\n\t\techo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi\n\t    else\n\t\techo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf\n\t    fi\n\tfi\n\texit ;;\n    avr32*:Linux:*:*)\n\techo ${UNAME_MACHINE}-unknown-linux-${LIBC}\n\texit ;;\n    cris:Linux:*:*)\n\techo ${UNAME_MACHINE}-axis-linux-${LIBC}\n\texit ;;\n    crisv32:Linux:*:*)\n\techo ${UNAME_MACHINE}-axis-linux-${LIBC}\n\texit ;;\n    frv:Linux:*:*)\n\techo ${UNAME_MACHINE}-unknown-linux-${LIBC}\n\texit ;;\n    hexagon:Linux:*:*)\n\techo ${UNAME_MACHINE}-unknown-linux-${LIBC}\n\texit ;;\n    i*86:Linux:*:*)\n\techo ${UNAME_MACHINE}-pc-linux-${LIBC}\n\texit ;;\n    ia64:Linux:*:*)\n\techo ${UNAME_MACHINE}-unknown-linux-${LIBC}\n\texit ;;\n    m32r*:Linux:*:*)\n\techo ${UNAME_MACHINE}-unknown-linux-${LIBC}\n\texit ;;\n    m68*:Linux:*:*)\n\techo ${UNAME_MACHINE}-unknown-linux-${LIBC}\n\texit ;;\n    mips:Linux:*:* | mips64:Linux:*:*)\n\teval $set_cc_for_build\n\tsed 's/^\t//' << EOF >$dummy.c\n\t#undef CPU\n\t#undef ${UNAME_MACHINE}\n\t#undef ${UNAME_MACHINE}el\n\t#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)\n\tCPU=${UNAME_MACHINE}el\n\t#else\n\t#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)\n\tCPU=${UNAME_MACHINE}\n\t#else\n\tCPU=\n\t#endif\n\t#endif\nEOF\n\teval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`\n\ttest x\"${CPU}\" != x && { echo \"${CPU}-unknown-linux-${LIBC}\"; exit; }\n\t;;\n    or1k:Linux:*:*)\n\techo ${UNAME_MACHINE}-unknown-linux-${LIBC}\n\texit ;;\n    or32:Linux:*:*)\n\techo ${UNAME_MACHINE}-unknown-linux-${LIBC}\n\texit ;;\n    padre:Linux:*:*)\n\techo sparc-unknown-linux-${LIBC}\n\texit ;;\n    parisc64:Linux:*:* | hppa64:Linux:*:*)\n\techo hppa64-unknown-linux-${LIBC}\n\texit ;;\n    parisc:Linux:*:* | hppa:Linux:*:*)\n\t# Look for CPU level\n\tcase `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in\n\t  PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;\n\t  PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;\n\t  *)    echo hppa-unknown-linux-${LIBC} ;;\n\tesac\n\texit ;;\n    ppc64:Linux:*:*)\n\techo powerpc64-unknown-linux-${LIBC}\n\texit ;;\n    ppc:Linux:*:*)\n\techo powerpc-unknown-linux-${LIBC}\n\texit ;;\n    ppc64le:Linux:*:*)\n\techo powerpc64le-unknown-linux-${LIBC}\n\texit ;;\n    ppcle:Linux:*:*)\n\techo powerpcle-unknown-linux-${LIBC}\n\texit ;;\n    s390:Linux:*:* | s390x:Linux:*:*)\n\techo ${UNAME_MACHINE}-ibm-linux-${LIBC}\n\texit ;;\n    sh64*:Linux:*:*)\n\techo ${UNAME_MACHINE}-unknown-linux-${LIBC}\n\texit ;;\n    sh*:Linux:*:*)\n\techo ${UNAME_MACHINE}-unknown-linux-${LIBC}\n\texit ;;\n    sparc:Linux:*:* | sparc64:Linux:*:*)\n\techo ${UNAME_MACHINE}-unknown-linux-${LIBC}\n\texit ;;\n    tile*:Linux:*:*)\n\techo ${UNAME_MACHINE}-unknown-linux-${LIBC}\n\texit ;;\n    vax:Linux:*:*)\n\techo ${UNAME_MACHINE}-dec-linux-${LIBC}\n\texit ;;\n    x86_64:Linux:*:*)\n\techo ${UNAME_MACHINE}-unknown-linux-${LIBC}\n\texit ;;\n    xtensa*:Linux:*:*)\n\techo ${UNAME_MACHINE}-unknown-linux-${LIBC}\n\texit ;;\n    i*86:DYNIX/ptx:4*:*)\n\t# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.\n\t# earlier versions are messed up and put the nodename in both\n\t# sysname and nodename.\n\techo i386-sequent-sysv4\n\texit ;;\n    i*86:UNIX_SV:4.2MP:2.*)\n\t# Unixware is an offshoot of SVR4, but it has its own version\n\t# number series starting with 2...\n\t# I am not positive that other SVR4 systems won't match this,\n\t# I just have to hope.  -- rms.\n\t# Use sysv4.2uw... so that sysv4* matches it.\n\techo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}\n\texit ;;\n    i*86:OS/2:*:*)\n\t# If we were able to find `uname', then EMX Unix compatibility\n\t# is probably installed.\n\techo ${UNAME_MACHINE}-pc-os2-emx\n\texit ;;\n    i*86:XTS-300:*:STOP)\n\techo ${UNAME_MACHINE}-unknown-stop\n\texit ;;\n    i*86:atheos:*:*)\n\techo ${UNAME_MACHINE}-unknown-atheos\n\texit ;;\n    i*86:syllable:*:*)\n\techo ${UNAME_MACHINE}-pc-syllable\n\texit ;;\n    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)\n\techo i386-unknown-lynxos${UNAME_RELEASE}\n\texit ;;\n    i*86:*DOS:*:*)\n\techo ${UNAME_MACHINE}-pc-msdosdjgpp\n\texit ;;\n    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)\n\tUNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\\/MP$//'`\n\tif grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then\n\t\techo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}\n\telse\n\t\techo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}\n\tfi\n\texit ;;\n    i*86:*:5:[678]*)\n\t# UnixWare 7.x, OpenUNIX and OpenServer 6.\n\tcase `/bin/uname -X | grep \"^Machine\"` in\n\t    *486*)\t     UNAME_MACHINE=i486 ;;\n\t    *Pentium)\t     UNAME_MACHINE=i586 ;;\n\t    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;\n\tesac\n\techo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}\n\texit ;;\n    i*86:*:3.2:*)\n\tif test -f /usr/options/cb.name; then\n\t\tUNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`\n\t\techo ${UNAME_MACHINE}-pc-isc$UNAME_REL\n\telif /bin/uname -X 2>/dev/null >/dev/null ; then\n\t\tUNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`\n\t\t(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486\n\t\t(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \\\n\t\t\t&& UNAME_MACHINE=i586\n\t\t(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \\\n\t\t\t&& UNAME_MACHINE=i686\n\t\t(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \\\n\t\t\t&& UNAME_MACHINE=i686\n\t\techo ${UNAME_MACHINE}-pc-sco$UNAME_REL\n\telse\n\t\techo ${UNAME_MACHINE}-pc-sysv32\n\tfi\n\texit ;;\n    pc:*:*:*)\n\t# Left here for compatibility:\n\t# uname -m prints for DJGPP always 'pc', but it prints nothing about\n\t# the processor, so we play safe by assuming i586.\n\t# Note: whatever this is, it MUST be the same as what config.sub\n\t# prints for the \"djgpp\" host, or else GDB configury will decide that\n\t# this is a cross-build.\n\techo i586-pc-msdosdjgpp\n\texit ;;\n    Intel:Mach:3*:*)\n\techo i386-pc-mach3\n\texit ;;\n    paragon:*:*:*)\n\techo i860-intel-osf1\n\texit ;;\n    i860:*:4.*:*) # i860-SVR4\n\tif grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then\n\t  echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4\n\telse # Add other i860-SVR4 vendors below as they are discovered.\n\t  echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4\n\tfi\n\texit ;;\n    mini*:CTIX:SYS*5:*)\n\t# \"miniframe\"\n\techo m68010-convergent-sysv\n\texit ;;\n    mc68k:UNIX:SYSTEM5:3.51m)\n\techo m68k-convergent-sysv\n\texit ;;\n    M680?0:D-NIX:5.3:*)\n\techo m68k-diab-dnix\n\texit ;;\n    M68*:*:R3V[5678]*:*)\n\ttest -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;\n    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)\n\tOS_REL=''\n\ttest -r /etc/.relid \\\n\t&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \\([0-9][0-9]\\).*/\\1/p' < /etc/.relid`\n\t/bin/uname -p 2>/dev/null | grep 86 >/dev/null \\\n\t  && { echo i486-ncr-sysv4.3${OS_REL}; exit; }\n\t/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \\\n\t  && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;\n    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)\n\t/bin/uname -p 2>/dev/null | grep 86 >/dev/null \\\n\t  && { echo i486-ncr-sysv4; exit; } ;;\n    NCR*:*:4.2:* | MPRAS*:*:4.2:*)\n\tOS_REL='.3'\n\ttest -r /etc/.relid \\\n\t    && OS_REL=.`sed -n 's/[^ ]* [^ ]* \\([0-9][0-9]\\).*/\\1/p' < /etc/.relid`\n\t/bin/uname -p 2>/dev/null | grep 86 >/dev/null \\\n\t    && { echo i486-ncr-sysv4.3${OS_REL}; exit; }\n\t/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \\\n\t    && { echo i586-ncr-sysv4.3${OS_REL}; exit; }\n\t/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \\\n\t    && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;\n    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)\n\techo m68k-unknown-lynxos${UNAME_RELEASE}\n\texit ;;\n    mc68030:UNIX_System_V:4.*:*)\n\techo m68k-atari-sysv4\n\texit ;;\n    TSUNAMI:LynxOS:2.*:*)\n\techo sparc-unknown-lynxos${UNAME_RELEASE}\n\texit ;;\n    rs6000:LynxOS:2.*:*)\n\techo rs6000-unknown-lynxos${UNAME_RELEASE}\n\texit ;;\n    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)\n\techo powerpc-unknown-lynxos${UNAME_RELEASE}\n\texit ;;\n    SM[BE]S:UNIX_SV:*:*)\n\techo mips-dde-sysv${UNAME_RELEASE}\n\texit ;;\n    RM*:ReliantUNIX-*:*:*)\n\techo mips-sni-sysv4\n\texit ;;\n    RM*:SINIX-*:*:*)\n\techo mips-sni-sysv4\n\texit ;;\n    *:SINIX-*:*:*)\n\tif uname -p 2>/dev/null >/dev/null ; then\n\t\tUNAME_MACHINE=`(uname -p) 2>/dev/null`\n\t\techo ${UNAME_MACHINE}-sni-sysv4\n\telse\n\t\techo ns32k-sni-sysv\n\tfi\n\texit ;;\n    PENTIUM:*:4.0*:*)\t# Unisys `ClearPath HMP IX 4000' SVR4/MP effort\n\t\t\t# says <Richard.M.Bartel@ccMail.Census.GOV>\n\techo i586-unisys-sysv4\n\texit ;;\n    *:UNIX_System_V:4*:FTX*)\n\t# From Gerald Hewes <hewes@openmarket.com>.\n\t# How about differentiating between stratus architectures? -djm\n\techo hppa1.1-stratus-sysv4\n\texit ;;\n    *:*:*:FTX*)\n\t# From seanf@swdc.stratus.com.\n\techo i860-stratus-sysv4\n\texit ;;\n    i*86:VOS:*:*)\n\t# From Paul.Green@stratus.com.\n\techo ${UNAME_MACHINE}-stratus-vos\n\texit ;;\n    *:VOS:*:*)\n\t# From Paul.Green@stratus.com.\n\techo hppa1.1-stratus-vos\n\texit ;;\n    mc68*:A/UX:*:*)\n\techo m68k-apple-aux${UNAME_RELEASE}\n\texit ;;\n    news*:NEWS-OS:6*:*)\n\techo mips-sony-newsos6\n\texit ;;\n    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)\n\tif [ -d /usr/nec ]; then\n\t\techo mips-nec-sysv${UNAME_RELEASE}\n\telse\n\t\techo mips-unknown-sysv${UNAME_RELEASE}\n\tfi\n\texit ;;\n    BeBox:BeOS:*:*)\t# BeOS running on hardware made by Be, PPC only.\n\techo powerpc-be-beos\n\texit ;;\n    BeMac:BeOS:*:*)\t# BeOS running on Mac or Mac clone, PPC only.\n\techo powerpc-apple-beos\n\texit ;;\n    BePC:BeOS:*:*)\t# BeOS running on Intel PC compatible.\n\techo i586-pc-beos\n\texit ;;\n    BePC:Haiku:*:*)\t# Haiku running on Intel PC compatible.\n\techo i586-pc-haiku\n\texit ;;\n    x86_64:Haiku:*:*)\n\techo x86_64-unknown-haiku\n\texit ;;\n    SX-4:SUPER-UX:*:*)\n\techo sx4-nec-superux${UNAME_RELEASE}\n\texit ;;\n    SX-5:SUPER-UX:*:*)\n\techo sx5-nec-superux${UNAME_RELEASE}\n\texit ;;\n    SX-6:SUPER-UX:*:*)\n\techo sx6-nec-superux${UNAME_RELEASE}\n\texit ;;\n    SX-7:SUPER-UX:*:*)\n\techo sx7-nec-superux${UNAME_RELEASE}\n\texit ;;\n    SX-8:SUPER-UX:*:*)\n\techo sx8-nec-superux${UNAME_RELEASE}\n\texit ;;\n    SX-8R:SUPER-UX:*:*)\n\techo sx8r-nec-superux${UNAME_RELEASE}\n\texit ;;\n    Power*:Rhapsody:*:*)\n\techo powerpc-apple-rhapsody${UNAME_RELEASE}\n\texit ;;\n    *:Rhapsody:*:*)\n\techo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}\n\texit ;;\n    *:Darwin:*:*)\n\tUNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown\n\teval $set_cc_for_build\n\tif test \"$UNAME_PROCESSOR\" = unknown ; then\n\t    UNAME_PROCESSOR=powerpc\n\tfi\n\tif [ \"$CC_FOR_BUILD\" != 'no_compiler_found' ]; then\n\t    if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \\\n\t\t(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \\\n\t\tgrep IS_64BIT_ARCH >/dev/null\n\t    then\n\t\tcase $UNAME_PROCESSOR in\n\t\t    i386) UNAME_PROCESSOR=x86_64 ;;\n\t\t    powerpc) UNAME_PROCESSOR=powerpc64 ;;\n\t\tesac\n\t    fi\n\tfi\n\techo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}\n\texit ;;\n    *:procnto*:*:* | *:QNX:[0123456789]*:*)\n\tUNAME_PROCESSOR=`uname -p`\n\tif test \"$UNAME_PROCESSOR\" = \"x86\"; then\n\t\tUNAME_PROCESSOR=i386\n\t\tUNAME_MACHINE=pc\n\tfi\n\techo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}\n\texit ;;\n    *:QNX:*:4*)\n\techo i386-pc-qnx\n\texit ;;\n    NEO-?:NONSTOP_KERNEL:*:*)\n\techo neo-tandem-nsk${UNAME_RELEASE}\n\texit ;;\n    NSE-*:NONSTOP_KERNEL:*:*)\n\techo nse-tandem-nsk${UNAME_RELEASE}\n\texit ;;\n    NSR-?:NONSTOP_KERNEL:*:*)\n\techo nsr-tandem-nsk${UNAME_RELEASE}\n\texit ;;\n    *:NonStop-UX:*:*)\n\techo mips-compaq-nonstopux\n\texit ;;\n    BS2000:POSIX*:*:*)\n\techo bs2000-siemens-sysv\n\texit ;;\n    DS/*:UNIX_System_V:*:*)\n\techo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}\n\texit ;;\n    *:Plan9:*:*)\n\t# \"uname -m\" is not consistent, so use $cputype instead. 386\n\t# is converted to i386 for consistency with other x86\n\t# operating systems.\n\tif test \"$cputype\" = \"386\"; then\n\t    UNAME_MACHINE=i386\n\telse\n\t    UNAME_MACHINE=\"$cputype\"\n\tfi\n\techo ${UNAME_MACHINE}-unknown-plan9\n\texit ;;\n    *:TOPS-10:*:*)\n\techo pdp10-unknown-tops10\n\texit ;;\n    *:TENEX:*:*)\n\techo pdp10-unknown-tenex\n\texit ;;\n    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)\n\techo pdp10-dec-tops20\n\texit ;;\n    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)\n\techo pdp10-xkl-tops20\n\texit ;;\n    *:TOPS-20:*:*)\n\techo pdp10-unknown-tops20\n\texit ;;\n    *:ITS:*:*)\n\techo pdp10-unknown-its\n\texit ;;\n    SEI:*:*:SEIUX)\n\techo mips-sei-seiux${UNAME_RELEASE}\n\texit ;;\n    *:DragonFly:*:*)\n\techo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`\n\texit ;;\n    *:*VMS:*:*)\n\tUNAME_MACHINE=`(uname -p) 2>/dev/null`\n\tcase \"${UNAME_MACHINE}\" in\n\t    A*) echo alpha-dec-vms ; exit ;;\n\t    I*) echo ia64-dec-vms ; exit ;;\n\t    V*) echo vax-dec-vms ; exit ;;\n\tesac ;;\n    *:XENIX:*:SysV)\n\techo i386-pc-xenix\n\texit ;;\n    i*86:skyos:*:*)\n\techo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'\n\texit ;;\n    i*86:rdos:*:*)\n\techo ${UNAME_MACHINE}-pc-rdos\n\texit ;;\n    i*86:AROS:*:*)\n\techo ${UNAME_MACHINE}-pc-aros\n\texit ;;\n    x86_64:VMkernel:*:*)\n\techo ${UNAME_MACHINE}-unknown-esx\n\texit ;;\nesac\n\neval $set_cc_for_build\ncat >$dummy.c <<EOF\n#ifdef _SEQUENT_\n# include <sys/types.h>\n# include <sys/utsname.h>\n#endif\nmain ()\n{\n#if defined (sony)\n#if defined (MIPSEB)\n  /* BFD wants \"bsd\" instead of \"newsos\".  Perhaps BFD should be changed,\n     I don't know....  */\n  printf (\"mips-sony-bsd\\n\"); exit (0);\n#else\n#include <sys/param.h>\n  printf (\"m68k-sony-newsos%s\\n\",\n#ifdef NEWSOS4\n\t\"4\"\n#else\n\t\"\"\n#endif\n\t); exit (0);\n#endif\n#endif\n\n#if defined (__arm) && defined (__acorn) && defined (__unix)\n  printf (\"arm-acorn-riscix\\n\"); exit (0);\n#endif\n\n#if defined (hp300) && !defined (hpux)\n  printf (\"m68k-hp-bsd\\n\"); exit (0);\n#endif\n\n#if defined (NeXT)\n#if !defined (__ARCHITECTURE__)\n#define __ARCHITECTURE__ \"m68k\"\n#endif\n  int version;\n  version=`(hostinfo | sed -n 's/.*NeXT Mach \\([0-9]*\\).*/\\1/p') 2>/dev/null`;\n  if (version < 4)\n    printf (\"%s-next-nextstep%d\\n\", __ARCHITECTURE__, version);\n  else\n    printf (\"%s-next-openstep%d\\n\", __ARCHITECTURE__, version);\n  exit (0);\n#endif\n\n#if defined (MULTIMAX) || defined (n16)\n#if defined (UMAXV)\n  printf (\"ns32k-encore-sysv\\n\"); exit (0);\n#else\n#if defined (CMU)\n  printf (\"ns32k-encore-mach\\n\"); exit (0);\n#else\n  printf (\"ns32k-encore-bsd\\n\"); exit (0);\n#endif\n#endif\n#endif\n\n#if defined (__386BSD__)\n  printf (\"i386-pc-bsd\\n\"); exit (0);\n#endif\n\n#if defined (sequent)\n#if defined (i386)\n  printf (\"i386-sequent-dynix\\n\"); exit (0);\n#endif\n#if defined (ns32000)\n  printf (\"ns32k-sequent-dynix\\n\"); exit (0);\n#endif\n#endif\n\n#if defined (_SEQUENT_)\n    struct utsname un;\n\n    uname(&un);\n\n    if (strncmp(un.version, \"V2\", 2) == 0) {\n\tprintf (\"i386-sequent-ptx2\\n\"); exit (0);\n    }\n    if (strncmp(un.version, \"V1\", 2) == 0) { /* XXX is V1 correct? */\n\tprintf (\"i386-sequent-ptx1\\n\"); exit (0);\n    }\n    printf (\"i386-sequent-ptx\\n\"); exit (0);\n\n#endif\n\n#if defined (vax)\n# if !defined (ultrix)\n#  include <sys/param.h>\n#  if defined (BSD)\n#   if BSD == 43\n      printf (\"vax-dec-bsd4.3\\n\"); exit (0);\n#   else\n#    if BSD == 199006\n      printf (\"vax-dec-bsd4.3reno\\n\"); exit (0);\n#    else\n      printf (\"vax-dec-bsd\\n\"); exit (0);\n#    endif\n#   endif\n#  else\n    printf (\"vax-dec-bsd\\n\"); exit (0);\n#  endif\n# else\n    printf (\"vax-dec-ultrix\\n\"); exit (0);\n# endif\n#endif\n\n#if defined (alliant) && defined (i860)\n  printf (\"i860-alliant-bsd\\n\"); exit (0);\n#endif\n\n  exit (1);\n}\nEOF\n\n$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&\n\t{ echo \"$SYSTEM_NAME\"; exit; }\n\n# Apollos put the system type in the environment.\n\ntest -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }\n\n# Convex versions that predate uname can use getsysinfo(1)\n\nif [ -x /usr/convex/getsysinfo ]\nthen\n    case `getsysinfo -f cpu_type` in\n    c1*)\n\techo c1-convex-bsd\n\texit ;;\n    c2*)\n\tif getsysinfo -f scalar_acc\n\tthen echo c32-convex-bsd\n\telse echo c2-convex-bsd\n\tfi\n\texit ;;\n    c34*)\n\techo c34-convex-bsd\n\texit ;;\n    c38*)\n\techo c38-convex-bsd\n\texit ;;\n    c4*)\n\techo c4-convex-bsd\n\texit ;;\n    esac\nfi\n\ncat >&2 <<EOF\n$0: unable to guess system type\n\nThis script, last modified $timestamp, has failed to recognize\nthe operating system you are using. It is advised that you\ndownload the most up to date version of the config scripts from\n\n  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD\nand\n  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD\n\nIf the version you run ($0) is already up to date, please\nsend the following data and any information you think might be\npertinent to <config-patches@gnu.org> in order to provide the needed\ninformation to handle your system.\n\nconfig.guess timestamp = $timestamp\n\nuname -m = `(uname -m) 2>/dev/null || echo unknown`\nuname -r = `(uname -r) 2>/dev/null || echo unknown`\nuname -s = `(uname -s) 2>/dev/null || echo unknown`\nuname -v = `(uname -v) 2>/dev/null || echo unknown`\n\n/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`\n/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`\n\nhostinfo               = `(hostinfo) 2>/dev/null`\n/bin/universe          = `(/bin/universe) 2>/dev/null`\n/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`\n/bin/arch              = `(/bin/arch) 2>/dev/null`\n/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`\n/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`\n\nUNAME_MACHINE = ${UNAME_MACHINE}\nUNAME_RELEASE = ${UNAME_RELEASE}\nUNAME_SYSTEM  = ${UNAME_SYSTEM}\nUNAME_VERSION = ${UNAME_VERSION}\nEOF\n\nexit 1\n\n# Local variables:\n# eval: (add-hook 'write-file-hooks 'time-stamp)\n# time-stamp-start: \"timestamp='\"\n# time-stamp-format: \"%:y-%02m-%02d\"\n# time-stamp-end: \"'\"\n# End:\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/config.h.in",
    "content": "/* config.h.in.  Generated from configure.ac by autoheader.  */\n\n/* the name of <hash_map> */\n#undef HASH_MAP_CLASS\n\n/* the location of <unordered_map> or <hash_map> */\n#undef HASH_MAP_H\n\n/* the namespace of hash_map/hash_set */\n#undef HASH_NAMESPACE\n\n/* the name of <hash_set> */\n#undef HASH_SET_CLASS\n\n/* the location of <unordered_set> or <hash_set> */\n#undef HASH_SET_H\n\n/* Define to 1 if you have the <dlfcn.h> header file. */\n#undef HAVE_DLFCN_H\n\n/* Define to 1 if you have the <fcntl.h> header file. */\n#undef HAVE_FCNTL_H\n\n/* Define to 1 if you have the `ftruncate' function. */\n#undef HAVE_FTRUNCATE\n\n/* define if the compiler has hash_map */\n#undef HAVE_HASH_MAP\n\n/* define if the compiler has hash_set */\n#undef HAVE_HASH_SET\n\n/* Define to 1 if you have the <inttypes.h> header file. */\n#undef HAVE_INTTYPES_H\n\n/* Define to 1 if you have the <limits.h> header file. */\n#undef HAVE_LIMITS_H\n\n/* Define to 1 if you have the <memory.h> header file. */\n#undef HAVE_MEMORY_H\n\n/* Define to 1 if you have the `memset' function. */\n#undef HAVE_MEMSET\n\n/* Define to 1 if you have the `mkdir' function. */\n#undef HAVE_MKDIR\n\n/* Define if you have POSIX threads libraries and header files. */\n#undef HAVE_PTHREAD\n\n/* Define to 1 if you have the <stdint.h> header file. */\n#undef HAVE_STDINT_H\n\n/* Define to 1 if you have the <stdlib.h> header file. */\n#undef HAVE_STDLIB_H\n\n/* Define to 1 if you have the `strchr' function. */\n#undef HAVE_STRCHR\n\n/* Define to 1 if you have the `strerror' function. */\n#undef HAVE_STRERROR\n\n/* Define to 1 if you have the <strings.h> header file. */\n#undef HAVE_STRINGS_H\n\n/* Define to 1 if you have the <string.h> header file. */\n#undef HAVE_STRING_H\n\n/* Define to 1 if you have the `strtol' function. */\n#undef HAVE_STRTOL\n\n/* Define to 1 if you have the <sys/stat.h> header file. */\n#undef HAVE_SYS_STAT_H\n\n/* Define to 1 if you have the <sys/types.h> header file. */\n#undef HAVE_SYS_TYPES_H\n\n/* Define to 1 if you have the <unistd.h> header file. */\n#undef HAVE_UNISTD_H\n\n/* Enable classes using zlib compression. */\n#undef HAVE_ZLIB\n\n/* Define to the sub-directory in which libtool stores uninstalled libraries.\n   */\n#undef LT_OBJDIR\n\n/* Name of package */\n#undef PACKAGE\n\n/* Define to the address where bug reports for this package should be sent. */\n#undef PACKAGE_BUGREPORT\n\n/* Define to the full name of this package. */\n#undef PACKAGE_NAME\n\n/* Define to the full name and version of this package. */\n#undef PACKAGE_STRING\n\n/* Define to the one symbol short name of this package. */\n#undef PACKAGE_TARNAME\n\n/* Define to the home page for this package. */\n#undef PACKAGE_URL\n\n/* Define to the version of this package. */\n#undef PACKAGE_VERSION\n\n/* Define to necessary symbol if this constant uses a non-standard name on\n   your system. */\n#undef PTHREAD_CREATE_JOINABLE\n\n/* Define to 1 if you have the ANSI C header files. */\n#undef STDC_HEADERS\n\n/* Enable extensions on AIX 3, Interix.  */\n#ifndef _ALL_SOURCE\n# undef _ALL_SOURCE\n#endif\n/* Enable GNU extensions on systems that have them.  */\n#ifndef _GNU_SOURCE\n# undef _GNU_SOURCE\n#endif\n/* Enable threading extensions on Solaris.  */\n#ifndef _POSIX_PTHREAD_SEMANTICS\n# undef _POSIX_PTHREAD_SEMANTICS\n#endif\n/* Enable extensions on HP NonStop.  */\n#ifndef _TANDEM_SOURCE\n# undef _TANDEM_SOURCE\n#endif\n/* Enable general extensions on Solaris.  */\n#ifndef __EXTENSIONS__\n# undef __EXTENSIONS__\n#endif\n\n\n/* Version number of package */\n#undef VERSION\n\n/* Define to 1 if on MINIX. */\n#undef _MINIX\n\n/* Define to 2 if the system does not provide POSIX.1 features except with\n   this defined. */\n#undef _POSIX_1_SOURCE\n\n/* Define to 1 if you need to in order for `stat' and other things to work. */\n#undef _POSIX_SOURCE\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/config.sub",
    "content": "#! /bin/sh\n# Configuration validation subroutine script.\n#   Copyright 1992-2013 Free Software Foundation, Inc.\n\ntimestamp='2013-08-10'\n\n# This file is free software; you can redistribute it and/or modify it\n# under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 3 of the License, or\n# (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful, but\n# WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n# General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, see <http://www.gnu.org/licenses/>.\n#\n# As a special exception to the GNU General Public License, if you\n# distribute this file as part of a program that contains a\n# configuration script generated by Autoconf, you may include it under\n# the same distribution terms that you use for the rest of that\n# program.  This Exception is an additional permission under section 7\n# of the GNU General Public License, version 3 (\"GPLv3\").\n\n\n# Please send patches with a ChangeLog entry to config-patches@gnu.org.\n#\n# Configuration subroutine to validate and canonicalize a configuration type.\n# Supply the specified configuration type as an argument.\n# If it is invalid, we print an error message on stderr and exit with code 1.\n# Otherwise, we print the canonical config type on stdout and succeed.\n\n# You can get the latest version of this script from:\n# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD\n\n# This file is supposed to be the same for all GNU packages\n# and recognize all the CPU types, system types and aliases\n# that are meaningful with *any* GNU software.\n# Each package is responsible for reporting which valid configurations\n# it does not support.  The user should be able to distinguish\n# a failure to support a valid configuration from a meaningless\n# configuration.\n\n# The goal of this file is to map all the various variations of a given\n# machine specification into a single specification in the form:\n#\tCPU_TYPE-MANUFACTURER-OPERATING_SYSTEM\n# or in some cases, the newer four-part form:\n#\tCPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM\n# It is wrong to echo any other type of specification.\n\nme=`echo \"$0\" | sed -e 's,.*/,,'`\n\nusage=\"\\\nUsage: $0 [OPTION] CPU-MFR-OPSYS\n       $0 [OPTION] ALIAS\n\nCanonicalize a configuration name.\n\nOperation modes:\n  -h, --help         print this help, then exit\n  -t, --time-stamp   print date of last modification, then exit\n  -v, --version      print version number, then exit\n\nReport bugs and patches to <config-patches@gnu.org>.\"\n\nversion=\"\\\nGNU config.sub ($timestamp)\n\nCopyright 1992-2013 Free Software Foundation, Inc.\n\nThis is free software; see the source for copying conditions.  There is NO\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\"\n\nhelp=\"\nTry \\`$me --help' for more information.\"\n\n# Parse command line\nwhile test $# -gt 0 ; do\n  case $1 in\n    --time-stamp | --time* | -t )\n       echo \"$timestamp\" ; exit ;;\n    --version | -v )\n       echo \"$version\" ; exit ;;\n    --help | --h* | -h )\n       echo \"$usage\"; exit ;;\n    -- )     # Stop option processing\n       shift; break ;;\n    - )\t# Use stdin as input.\n       break ;;\n    -* )\n       echo \"$me: invalid option $1$help\"\n       exit 1 ;;\n\n    *local*)\n       # First pass through any local machine types.\n       echo $1\n       exit ;;\n\n    * )\n       break ;;\n  esac\ndone\n\ncase $# in\n 0) echo \"$me: missing argument$help\" >&2\n    exit 1;;\n 1) ;;\n *) echo \"$me: too many arguments$help\" >&2\n    exit 1;;\nesac\n\n# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).\n# Here we must recognize all the valid KERNEL-OS combinations.\nmaybe_os=`echo $1 | sed 's/^\\(.*\\)-\\([^-]*-[^-]*\\)$/\\2/'`\ncase $maybe_os in\n  nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \\\n  linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \\\n  knetbsd*-gnu* | netbsd*-gnu* | \\\n  kopensolaris*-gnu* | \\\n  storm-chaos* | os2-emx* | rtmk-nova*)\n    os=-$maybe_os\n    basic_machine=`echo $1 | sed 's/^\\(.*\\)-\\([^-]*-[^-]*\\)$/\\1/'`\n    ;;\n  android-linux)\n    os=-linux-android\n    basic_machine=`echo $1 | sed 's/^\\(.*\\)-\\([^-]*-[^-]*\\)$/\\1/'`-unknown\n    ;;\n  *)\n    basic_machine=`echo $1 | sed 's/-[^-]*$//'`\n    if [ $basic_machine != $1 ]\n    then os=`echo $1 | sed 's/.*-/-/'`\n    else os=; fi\n    ;;\nesac\n\n### Let's recognize common machines as not being operating systems so\n### that things like config.sub decstation-3100 work.  We also\n### recognize some manufacturers as not being operating systems, so we\n### can provide default operating systems below.\ncase $os in\n\t-sun*os*)\n\t\t# Prevent following clause from handling this invalid input.\n\t\t;;\n\t-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \\\n\t-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \\\n\t-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \\\n\t-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\\\n\t-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \\\n\t-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \\\n\t-apple | -axis | -knuth | -cray | -microblaze*)\n\t\tos=\n\t\tbasic_machine=$1\n\t\t;;\n\t-bluegene*)\n\t\tos=-cnk\n\t\t;;\n\t-sim | -cisco | -oki | -wec | -winbond)\n\t\tos=\n\t\tbasic_machine=$1\n\t\t;;\n\t-scout)\n\t\t;;\n\t-wrs)\n\t\tos=-vxworks\n\t\tbasic_machine=$1\n\t\t;;\n\t-chorusos*)\n\t\tos=-chorusos\n\t\tbasic_machine=$1\n\t\t;;\n\t-chorusrdb)\n\t\tos=-chorusrdb\n\t\tbasic_machine=$1\n\t\t;;\n\t-hiux*)\n\t\tos=-hiuxwe2\n\t\t;;\n\t-sco6)\n\t\tos=-sco5v6\n\t\tbasic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`\n\t\t;;\n\t-sco5)\n\t\tos=-sco3.2v5\n\t\tbasic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`\n\t\t;;\n\t-sco4)\n\t\tos=-sco3.2v4\n\t\tbasic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`\n\t\t;;\n\t-sco3.2.[4-9]*)\n\t\tos=`echo $os | sed -e 's/sco3.2./sco3.2v/'`\n\t\tbasic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`\n\t\t;;\n\t-sco3.2v[4-9]*)\n\t\t# Don't forget version if it is 3.2v4 or newer.\n\t\tbasic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`\n\t\t;;\n\t-sco5v6*)\n\t\t# Don't forget version if it is 3.2v4 or newer.\n\t\tbasic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`\n\t\t;;\n\t-sco*)\n\t\tos=-sco3.2v2\n\t\tbasic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`\n\t\t;;\n\t-udk*)\n\t\tbasic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`\n\t\t;;\n\t-isc)\n\t\tos=-isc2.2\n\t\tbasic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`\n\t\t;;\n\t-clix*)\n\t\tbasic_machine=clipper-intergraph\n\t\t;;\n\t-isc*)\n\t\tbasic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`\n\t\t;;\n\t-lynx*178)\n\t\tos=-lynxos178\n\t\t;;\n\t-lynx*5)\n\t\tos=-lynxos5\n\t\t;;\n\t-lynx*)\n\t\tos=-lynxos\n\t\t;;\n\t-ptx*)\n\t\tbasic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`\n\t\t;;\n\t-windowsnt*)\n\t\tos=`echo $os | sed -e 's/windowsnt/winnt/'`\n\t\t;;\n\t-psos*)\n\t\tos=-psos\n\t\t;;\n\t-mint | -mint[0-9]*)\n\t\tbasic_machine=m68k-atari\n\t\tos=-mint\n\t\t;;\nesac\n\n# Decode aliases for certain CPU-COMPANY combinations.\ncase $basic_machine in\n\t# Recognize the basic CPU types without company name.\n\t# Some are omitted here because they have special meanings below.\n\t1750a | 580 \\\n\t| a29k \\\n\t| aarch64 | aarch64_be \\\n\t| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \\\n\t| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \\\n\t| am33_2.0 \\\n\t| arc | arceb \\\n\t| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \\\n\t| avr | avr32 \\\n\t| be32 | be64 \\\n\t| bfin \\\n\t| c4x | c8051 | clipper \\\n\t| d10v | d30v | dlx | dsp16xx \\\n\t| epiphany \\\n\t| fido | fr30 | frv \\\n\t| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \\\n\t| hexagon \\\n\t| i370 | i860 | i960 | ia64 \\\n\t| ip2k | iq2000 \\\n\t| le32 | le64 \\\n\t| lm32 \\\n\t| m32c | m32r | m32rle | m68000 | m68k | m88k \\\n\t| maxq | mb | microblaze | microblazeel | mcore | mep | metag \\\n\t| mips | mipsbe | mipseb | mipsel | mipsle \\\n\t| mips16 \\\n\t| mips64 | mips64el \\\n\t| mips64octeon | mips64octeonel \\\n\t| mips64orion | mips64orionel \\\n\t| mips64r5900 | mips64r5900el \\\n\t| mips64vr | mips64vrel \\\n\t| mips64vr4100 | mips64vr4100el \\\n\t| mips64vr4300 | mips64vr4300el \\\n\t| mips64vr5000 | mips64vr5000el \\\n\t| mips64vr5900 | mips64vr5900el \\\n\t| mipsisa32 | mipsisa32el \\\n\t| mipsisa32r2 | mipsisa32r2el \\\n\t| mipsisa64 | mipsisa64el \\\n\t| mipsisa64r2 | mipsisa64r2el \\\n\t| mipsisa64sb1 | mipsisa64sb1el \\\n\t| mipsisa64sr71k | mipsisa64sr71kel \\\n\t| mipsr5900 | mipsr5900el \\\n\t| mipstx39 | mipstx39el \\\n\t| mn10200 | mn10300 \\\n\t| moxie \\\n\t| mt \\\n\t| msp430 \\\n\t| nds32 | nds32le | nds32be \\\n\t| nios | nios2 | nios2eb | nios2el \\\n\t| ns16k | ns32k \\\n\t| open8 \\\n\t| or1k | or32 \\\n\t| pdp10 | pdp11 | pj | pjl \\\n\t| powerpc | powerpc64 | powerpc64le | powerpcle \\\n\t| pyramid \\\n\t| rl78 | rx \\\n\t| score \\\n\t| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \\\n\t| sh64 | sh64le \\\n\t| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \\\n\t| sparcv8 | sparcv9 | sparcv9b | sparcv9v \\\n\t| spu \\\n\t| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \\\n\t| ubicom32 \\\n\t| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \\\n\t| we32k \\\n\t| x86 | xc16x | xstormy16 | xtensa \\\n\t| z8k | z80)\n\t\tbasic_machine=$basic_machine-unknown\n\t\t;;\n\tc54x)\n\t\tbasic_machine=tic54x-unknown\n\t\t;;\n\tc55x)\n\t\tbasic_machine=tic55x-unknown\n\t\t;;\n\tc6x)\n\t\tbasic_machine=tic6x-unknown\n\t\t;;\n\tm6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)\n\t\tbasic_machine=$basic_machine-unknown\n\t\tos=-none\n\t\t;;\n\tm88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)\n\t\t;;\n\tms1)\n\t\tbasic_machine=mt-unknown\n\t\t;;\n\n\tstrongarm | thumb | xscale)\n\t\tbasic_machine=arm-unknown\n\t\t;;\n\txgate)\n\t\tbasic_machine=$basic_machine-unknown\n\t\tos=-none\n\t\t;;\n\txscaleeb)\n\t\tbasic_machine=armeb-unknown\n\t\t;;\n\n\txscaleel)\n\t\tbasic_machine=armel-unknown\n\t\t;;\n\n\t# We use `pc' rather than `unknown'\n\t# because (1) that's what they normally are, and\n\t# (2) the word \"unknown\" tends to confuse beginning users.\n\ti*86 | x86_64)\n\t  basic_machine=$basic_machine-pc\n\t  ;;\n\t# Object if more than one company name word.\n\t*-*-*)\n\t\techo Invalid configuration \\`$1\\': machine \\`$basic_machine\\' not recognized 1>&2\n\t\texit 1\n\t\t;;\n\t# Recognize the basic CPU types with company name.\n\t580-* \\\n\t| a29k-* \\\n\t| aarch64-* | aarch64_be-* \\\n\t| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \\\n\t| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \\\n\t| alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \\\n\t| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \\\n\t| avr-* | avr32-* \\\n\t| be32-* | be64-* \\\n\t| bfin-* | bs2000-* \\\n\t| c[123]* | c30-* | [cjt]90-* | c4x-* \\\n\t| c8051-* | clipper-* | craynv-* | cydra-* \\\n\t| d10v-* | d30v-* | dlx-* \\\n\t| elxsi-* \\\n\t| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \\\n\t| h8300-* | h8500-* \\\n\t| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \\\n\t| hexagon-* \\\n\t| i*86-* | i860-* | i960-* | ia64-* \\\n\t| ip2k-* | iq2000-* \\\n\t| le32-* | le64-* \\\n\t| lm32-* \\\n\t| m32c-* | m32r-* | m32rle-* \\\n\t| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \\\n\t| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \\\n\t| microblaze-* | microblazeel-* \\\n\t| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \\\n\t| mips16-* \\\n\t| mips64-* | mips64el-* \\\n\t| mips64octeon-* | mips64octeonel-* \\\n\t| mips64orion-* | mips64orionel-* \\\n\t| mips64r5900-* | mips64r5900el-* \\\n\t| mips64vr-* | mips64vrel-* \\\n\t| mips64vr4100-* | mips64vr4100el-* \\\n\t| mips64vr4300-* | mips64vr4300el-* \\\n\t| mips64vr5000-* | mips64vr5000el-* \\\n\t| mips64vr5900-* | mips64vr5900el-* \\\n\t| mipsisa32-* | mipsisa32el-* \\\n\t| mipsisa32r2-* | mipsisa32r2el-* \\\n\t| mipsisa64-* | mipsisa64el-* \\\n\t| mipsisa64r2-* | mipsisa64r2el-* \\\n\t| mipsisa64sb1-* | mipsisa64sb1el-* \\\n\t| mipsisa64sr71k-* | mipsisa64sr71kel-* \\\n\t| mipsr5900-* | mipsr5900el-* \\\n\t| mipstx39-* | mipstx39el-* \\\n\t| mmix-* \\\n\t| mt-* \\\n\t| msp430-* \\\n\t| nds32-* | nds32le-* | nds32be-* \\\n\t| nios-* | nios2-* | nios2eb-* | nios2el-* \\\n\t| none-* | np1-* | ns16k-* | ns32k-* \\\n\t| open8-* \\\n\t| orion-* \\\n\t| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \\\n\t| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \\\n\t| pyramid-* \\\n\t| rl78-* | romp-* | rs6000-* | rx-* \\\n\t| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \\\n\t| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \\\n\t| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \\\n\t| sparclite-* \\\n\t| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \\\n\t| tahoe-* \\\n\t| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \\\n\t| tile*-* \\\n\t| tron-* \\\n\t| ubicom32-* \\\n\t| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \\\n\t| vax-* \\\n\t| we32k-* \\\n\t| x86-* | x86_64-* | xc16x-* | xps100-* \\\n\t| xstormy16-* | xtensa*-* \\\n\t| ymp-* \\\n\t| z8k-* | z80-*)\n\t\t;;\n\t# Recognize the basic CPU types without company name, with glob match.\n\txtensa*)\n\t\tbasic_machine=$basic_machine-unknown\n\t\t;;\n\t# Recognize the various machine names and aliases which stand\n\t# for a CPU type and a company and sometimes even an OS.\n\t386bsd)\n\t\tbasic_machine=i386-unknown\n\t\tos=-bsd\n\t\t;;\n\t3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)\n\t\tbasic_machine=m68000-att\n\t\t;;\n\t3b*)\n\t\tbasic_machine=we32k-att\n\t\t;;\n\ta29khif)\n\t\tbasic_machine=a29k-amd\n\t\tos=-udi\n\t\t;;\n\tabacus)\n\t\tbasic_machine=abacus-unknown\n\t\t;;\n\tadobe68k)\n\t\tbasic_machine=m68010-adobe\n\t\tos=-scout\n\t\t;;\n\talliant | fx80)\n\t\tbasic_machine=fx80-alliant\n\t\t;;\n\taltos | altos3068)\n\t\tbasic_machine=m68k-altos\n\t\t;;\n\tam29k)\n\t\tbasic_machine=a29k-none\n\t\tos=-bsd\n\t\t;;\n\tamd64)\n\t\tbasic_machine=x86_64-pc\n\t\t;;\n\tamd64-*)\n\t\tbasic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`\n\t\t;;\n\tamdahl)\n\t\tbasic_machine=580-amdahl\n\t\tos=-sysv\n\t\t;;\n\tamiga | amiga-*)\n\t\tbasic_machine=m68k-unknown\n\t\t;;\n\tamigaos | amigados)\n\t\tbasic_machine=m68k-unknown\n\t\tos=-amigaos\n\t\t;;\n\tamigaunix | amix)\n\t\tbasic_machine=m68k-unknown\n\t\tos=-sysv4\n\t\t;;\n\tapollo68)\n\t\tbasic_machine=m68k-apollo\n\t\tos=-sysv\n\t\t;;\n\tapollo68bsd)\n\t\tbasic_machine=m68k-apollo\n\t\tos=-bsd\n\t\t;;\n\taros)\n\t\tbasic_machine=i386-pc\n\t\tos=-aros\n\t\t;;\n\taux)\n\t\tbasic_machine=m68k-apple\n\t\tos=-aux\n\t\t;;\n\tbalance)\n\t\tbasic_machine=ns32k-sequent\n\t\tos=-dynix\n\t\t;;\n\tblackfin)\n\t\tbasic_machine=bfin-unknown\n\t\tos=-linux\n\t\t;;\n\tblackfin-*)\n\t\tbasic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`\n\t\tos=-linux\n\t\t;;\n\tbluegene*)\n\t\tbasic_machine=powerpc-ibm\n\t\tos=-cnk\n\t\t;;\n\tc54x-*)\n\t\tbasic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`\n\t\t;;\n\tc55x-*)\n\t\tbasic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`\n\t\t;;\n\tc6x-*)\n\t\tbasic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`\n\t\t;;\n\tc90)\n\t\tbasic_machine=c90-cray\n\t\tos=-unicos\n\t\t;;\n\tcegcc)\n\t\tbasic_machine=arm-unknown\n\t\tos=-cegcc\n\t\t;;\n\tconvex-c1)\n\t\tbasic_machine=c1-convex\n\t\tos=-bsd\n\t\t;;\n\tconvex-c2)\n\t\tbasic_machine=c2-convex\n\t\tos=-bsd\n\t\t;;\n\tconvex-c32)\n\t\tbasic_machine=c32-convex\n\t\tos=-bsd\n\t\t;;\n\tconvex-c34)\n\t\tbasic_machine=c34-convex\n\t\tos=-bsd\n\t\t;;\n\tconvex-c38)\n\t\tbasic_machine=c38-convex\n\t\tos=-bsd\n\t\t;;\n\tcray | j90)\n\t\tbasic_machine=j90-cray\n\t\tos=-unicos\n\t\t;;\n\tcraynv)\n\t\tbasic_machine=craynv-cray\n\t\tos=-unicosmp\n\t\t;;\n\tcr16 | cr16-*)\n\t\tbasic_machine=cr16-unknown\n\t\tos=-elf\n\t\t;;\n\tcrds | unos)\n\t\tbasic_machine=m68k-crds\n\t\t;;\n\tcrisv32 | crisv32-* | etraxfs*)\n\t\tbasic_machine=crisv32-axis\n\t\t;;\n\tcris | cris-* | etrax*)\n\t\tbasic_machine=cris-axis\n\t\t;;\n\tcrx)\n\t\tbasic_machine=crx-unknown\n\t\tos=-elf\n\t\t;;\n\tda30 | da30-*)\n\t\tbasic_machine=m68k-da30\n\t\t;;\n\tdecstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)\n\t\tbasic_machine=mips-dec\n\t\t;;\n\tdecsystem10* | dec10*)\n\t\tbasic_machine=pdp10-dec\n\t\tos=-tops10\n\t\t;;\n\tdecsystem20* | dec20*)\n\t\tbasic_machine=pdp10-dec\n\t\tos=-tops20\n\t\t;;\n\tdelta | 3300 | motorola-3300 | motorola-delta \\\n\t      | 3300-motorola | delta-motorola)\n\t\tbasic_machine=m68k-motorola\n\t\t;;\n\tdelta88)\n\t\tbasic_machine=m88k-motorola\n\t\tos=-sysv3\n\t\t;;\n\tdicos)\n\t\tbasic_machine=i686-pc\n\t\tos=-dicos\n\t\t;;\n\tdjgpp)\n\t\tbasic_machine=i586-pc\n\t\tos=-msdosdjgpp\n\t\t;;\n\tdpx20 | dpx20-*)\n\t\tbasic_machine=rs6000-bull\n\t\tos=-bosx\n\t\t;;\n\tdpx2* | dpx2*-bull)\n\t\tbasic_machine=m68k-bull\n\t\tos=-sysv3\n\t\t;;\n\tebmon29k)\n\t\tbasic_machine=a29k-amd\n\t\tos=-ebmon\n\t\t;;\n\telxsi)\n\t\tbasic_machine=elxsi-elxsi\n\t\tos=-bsd\n\t\t;;\n\tencore | umax | mmax)\n\t\tbasic_machine=ns32k-encore\n\t\t;;\n\tes1800 | OSE68k | ose68k | ose | OSE)\n\t\tbasic_machine=m68k-ericsson\n\t\tos=-ose\n\t\t;;\n\tfx2800)\n\t\tbasic_machine=i860-alliant\n\t\t;;\n\tgenix)\n\t\tbasic_machine=ns32k-ns\n\t\t;;\n\tgmicro)\n\t\tbasic_machine=tron-gmicro\n\t\tos=-sysv\n\t\t;;\n\tgo32)\n\t\tbasic_machine=i386-pc\n\t\tos=-go32\n\t\t;;\n\th3050r* | hiux*)\n\t\tbasic_machine=hppa1.1-hitachi\n\t\tos=-hiuxwe2\n\t\t;;\n\th8300hms)\n\t\tbasic_machine=h8300-hitachi\n\t\tos=-hms\n\t\t;;\n\th8300xray)\n\t\tbasic_machine=h8300-hitachi\n\t\tos=-xray\n\t\t;;\n\th8500hms)\n\t\tbasic_machine=h8500-hitachi\n\t\tos=-hms\n\t\t;;\n\tharris)\n\t\tbasic_machine=m88k-harris\n\t\tos=-sysv3\n\t\t;;\n\thp300-*)\n\t\tbasic_machine=m68k-hp\n\t\t;;\n\thp300bsd)\n\t\tbasic_machine=m68k-hp\n\t\tos=-bsd\n\t\t;;\n\thp300hpux)\n\t\tbasic_machine=m68k-hp\n\t\tos=-hpux\n\t\t;;\n\thp3k9[0-9][0-9] | hp9[0-9][0-9])\n\t\tbasic_machine=hppa1.0-hp\n\t\t;;\n\thp9k2[0-9][0-9] | hp9k31[0-9])\n\t\tbasic_machine=m68000-hp\n\t\t;;\n\thp9k3[2-9][0-9])\n\t\tbasic_machine=m68k-hp\n\t\t;;\n\thp9k6[0-9][0-9] | hp6[0-9][0-9])\n\t\tbasic_machine=hppa1.0-hp\n\t\t;;\n\thp9k7[0-79][0-9] | hp7[0-79][0-9])\n\t\tbasic_machine=hppa1.1-hp\n\t\t;;\n\thp9k78[0-9] | hp78[0-9])\n\t\t# FIXME: really hppa2.0-hp\n\t\tbasic_machine=hppa1.1-hp\n\t\t;;\n\thp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)\n\t\t# FIXME: really hppa2.0-hp\n\t\tbasic_machine=hppa1.1-hp\n\t\t;;\n\thp9k8[0-9][13679] | hp8[0-9][13679])\n\t\tbasic_machine=hppa1.1-hp\n\t\t;;\n\thp9k8[0-9][0-9] | hp8[0-9][0-9])\n\t\tbasic_machine=hppa1.0-hp\n\t\t;;\n\thppa-next)\n\t\tos=-nextstep3\n\t\t;;\n\thppaosf)\n\t\tbasic_machine=hppa1.1-hp\n\t\tos=-osf\n\t\t;;\n\thppro)\n\t\tbasic_machine=hppa1.1-hp\n\t\tos=-proelf\n\t\t;;\n\ti370-ibm* | ibm*)\n\t\tbasic_machine=i370-ibm\n\t\t;;\n\ti*86v32)\n\t\tbasic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`\n\t\tos=-sysv32\n\t\t;;\n\ti*86v4*)\n\t\tbasic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`\n\t\tos=-sysv4\n\t\t;;\n\ti*86v)\n\t\tbasic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`\n\t\tos=-sysv\n\t\t;;\n\ti*86sol2)\n\t\tbasic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`\n\t\tos=-solaris2\n\t\t;;\n\ti386mach)\n\t\tbasic_machine=i386-mach\n\t\tos=-mach\n\t\t;;\n\ti386-vsta | vsta)\n\t\tbasic_machine=i386-unknown\n\t\tos=-vsta\n\t\t;;\n\tiris | iris4d)\n\t\tbasic_machine=mips-sgi\n\t\tcase $os in\n\t\t    -irix*)\n\t\t\t;;\n\t\t    *)\n\t\t\tos=-irix4\n\t\t\t;;\n\t\tesac\n\t\t;;\n\tisi68 | isi)\n\t\tbasic_machine=m68k-isi\n\t\tos=-sysv\n\t\t;;\n\tm68knommu)\n\t\tbasic_machine=m68k-unknown\n\t\tos=-linux\n\t\t;;\n\tm68knommu-*)\n\t\tbasic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`\n\t\tos=-linux\n\t\t;;\n\tm88k-omron*)\n\t\tbasic_machine=m88k-omron\n\t\t;;\n\tmagnum | m3230)\n\t\tbasic_machine=mips-mips\n\t\tos=-sysv\n\t\t;;\n\tmerlin)\n\t\tbasic_machine=ns32k-utek\n\t\tos=-sysv\n\t\t;;\n\tmicroblaze*)\n\t\tbasic_machine=microblaze-xilinx\n\t\t;;\n\tmingw64)\n\t\tbasic_machine=x86_64-pc\n\t\tos=-mingw64\n\t\t;;\n\tmingw32)\n\t\tbasic_machine=i686-pc\n\t\tos=-mingw32\n\t\t;;\n\tmingw32ce)\n\t\tbasic_machine=arm-unknown\n\t\tos=-mingw32ce\n\t\t;;\n\tminiframe)\n\t\tbasic_machine=m68000-convergent\n\t\t;;\n\t*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)\n\t\tbasic_machine=m68k-atari\n\t\tos=-mint\n\t\t;;\n\tmips3*-*)\n\t\tbasic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`\n\t\t;;\n\tmips3*)\n\t\tbasic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown\n\t\t;;\n\tmonitor)\n\t\tbasic_machine=m68k-rom68k\n\t\tos=-coff\n\t\t;;\n\tmorphos)\n\t\tbasic_machine=powerpc-unknown\n\t\tos=-morphos\n\t\t;;\n\tmsdos)\n\t\tbasic_machine=i386-pc\n\t\tos=-msdos\n\t\t;;\n\tms1-*)\n\t\tbasic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`\n\t\t;;\n\tmsys)\n\t\tbasic_machine=i686-pc\n\t\tos=-msys\n\t\t;;\n\tmvs)\n\t\tbasic_machine=i370-ibm\n\t\tos=-mvs\n\t\t;;\n\tnacl)\n\t\tbasic_machine=le32-unknown\n\t\tos=-nacl\n\t\t;;\n\tncr3000)\n\t\tbasic_machine=i486-ncr\n\t\tos=-sysv4\n\t\t;;\n\tnetbsd386)\n\t\tbasic_machine=i386-unknown\n\t\tos=-netbsd\n\t\t;;\n\tnetwinder)\n\t\tbasic_machine=armv4l-rebel\n\t\tos=-linux\n\t\t;;\n\tnews | news700 | news800 | news900)\n\t\tbasic_machine=m68k-sony\n\t\tos=-newsos\n\t\t;;\n\tnews1000)\n\t\tbasic_machine=m68030-sony\n\t\tos=-newsos\n\t\t;;\n\tnews-3600 | risc-news)\n\t\tbasic_machine=mips-sony\n\t\tos=-newsos\n\t\t;;\n\tnecv70)\n\t\tbasic_machine=v70-nec\n\t\tos=-sysv\n\t\t;;\n\tnext | m*-next )\n\t\tbasic_machine=m68k-next\n\t\tcase $os in\n\t\t    -nextstep* )\n\t\t\t;;\n\t\t    -ns2*)\n\t\t      os=-nextstep2\n\t\t\t;;\n\t\t    *)\n\t\t      os=-nextstep3\n\t\t\t;;\n\t\tesac\n\t\t;;\n\tnh3000)\n\t\tbasic_machine=m68k-harris\n\t\tos=-cxux\n\t\t;;\n\tnh[45]000)\n\t\tbasic_machine=m88k-harris\n\t\tos=-cxux\n\t\t;;\n\tnindy960)\n\t\tbasic_machine=i960-intel\n\t\tos=-nindy\n\t\t;;\n\tmon960)\n\t\tbasic_machine=i960-intel\n\t\tos=-mon960\n\t\t;;\n\tnonstopux)\n\t\tbasic_machine=mips-compaq\n\t\tos=-nonstopux\n\t\t;;\n\tnp1)\n\t\tbasic_machine=np1-gould\n\t\t;;\n\tneo-tandem)\n\t\tbasic_machine=neo-tandem\n\t\t;;\n\tnse-tandem)\n\t\tbasic_machine=nse-tandem\n\t\t;;\n\tnsr-tandem)\n\t\tbasic_machine=nsr-tandem\n\t\t;;\n\top50n-* | op60c-*)\n\t\tbasic_machine=hppa1.1-oki\n\t\tos=-proelf\n\t\t;;\n\topenrisc | openrisc-*)\n\t\tbasic_machine=or32-unknown\n\t\t;;\n\tos400)\n\t\tbasic_machine=powerpc-ibm\n\t\tos=-os400\n\t\t;;\n\tOSE68000 | ose68000)\n\t\tbasic_machine=m68000-ericsson\n\t\tos=-ose\n\t\t;;\n\tos68k)\n\t\tbasic_machine=m68k-none\n\t\tos=-os68k\n\t\t;;\n\tpa-hitachi)\n\t\tbasic_machine=hppa1.1-hitachi\n\t\tos=-hiuxwe2\n\t\t;;\n\tparagon)\n\t\tbasic_machine=i860-intel\n\t\tos=-osf\n\t\t;;\n\tparisc)\n\t\tbasic_machine=hppa-unknown\n\t\tos=-linux\n\t\t;;\n\tparisc-*)\n\t\tbasic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`\n\t\tos=-linux\n\t\t;;\n\tpbd)\n\t\tbasic_machine=sparc-tti\n\t\t;;\n\tpbb)\n\t\tbasic_machine=m68k-tti\n\t\t;;\n\tpc532 | pc532-*)\n\t\tbasic_machine=ns32k-pc532\n\t\t;;\n\tpc98)\n\t\tbasic_machine=i386-pc\n\t\t;;\n\tpc98-*)\n\t\tbasic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`\n\t\t;;\n\tpentium | p5 | k5 | k6 | nexgen | viac3)\n\t\tbasic_machine=i586-pc\n\t\t;;\n\tpentiumpro | p6 | 6x86 | athlon | athlon_*)\n\t\tbasic_machine=i686-pc\n\t\t;;\n\tpentiumii | pentium2 | pentiumiii | pentium3)\n\t\tbasic_machine=i686-pc\n\t\t;;\n\tpentium4)\n\t\tbasic_machine=i786-pc\n\t\t;;\n\tpentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)\n\t\tbasic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`\n\t\t;;\n\tpentiumpro-* | p6-* | 6x86-* | athlon-*)\n\t\tbasic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`\n\t\t;;\n\tpentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)\n\t\tbasic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`\n\t\t;;\n\tpentium4-*)\n\t\tbasic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`\n\t\t;;\n\tpn)\n\t\tbasic_machine=pn-gould\n\t\t;;\n\tpower)\tbasic_machine=power-ibm\n\t\t;;\n\tppc | ppcbe)\tbasic_machine=powerpc-unknown\n\t\t;;\n\tppc-* | ppcbe-*)\n\t\tbasic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`\n\t\t;;\n\tppcle | powerpclittle | ppc-le | powerpc-little)\n\t\tbasic_machine=powerpcle-unknown\n\t\t;;\n\tppcle-* | powerpclittle-*)\n\t\tbasic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`\n\t\t;;\n\tppc64)\tbasic_machine=powerpc64-unknown\n\t\t;;\n\tppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`\n\t\t;;\n\tppc64le | powerpc64little | ppc64-le | powerpc64-little)\n\t\tbasic_machine=powerpc64le-unknown\n\t\t;;\n\tppc64le-* | powerpc64little-*)\n\t\tbasic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`\n\t\t;;\n\tps2)\n\t\tbasic_machine=i386-ibm\n\t\t;;\n\tpw32)\n\t\tbasic_machine=i586-unknown\n\t\tos=-pw32\n\t\t;;\n\trdos | rdos64)\n\t\tbasic_machine=x86_64-pc\n\t\tos=-rdos\n\t\t;;\n\trdos32)\n\t\tbasic_machine=i386-pc\n\t\tos=-rdos\n\t\t;;\n\trom68k)\n\t\tbasic_machine=m68k-rom68k\n\t\tos=-coff\n\t\t;;\n\trm[46]00)\n\t\tbasic_machine=mips-siemens\n\t\t;;\n\trtpc | rtpc-*)\n\t\tbasic_machine=romp-ibm\n\t\t;;\n\ts390 | s390-*)\n\t\tbasic_machine=s390-ibm\n\t\t;;\n\ts390x | s390x-*)\n\t\tbasic_machine=s390x-ibm\n\t\t;;\n\tsa29200)\n\t\tbasic_machine=a29k-amd\n\t\tos=-udi\n\t\t;;\n\tsb1)\n\t\tbasic_machine=mipsisa64sb1-unknown\n\t\t;;\n\tsb1el)\n\t\tbasic_machine=mipsisa64sb1el-unknown\n\t\t;;\n\tsde)\n\t\tbasic_machine=mipsisa32-sde\n\t\tos=-elf\n\t\t;;\n\tsei)\n\t\tbasic_machine=mips-sei\n\t\tos=-seiux\n\t\t;;\n\tsequent)\n\t\tbasic_machine=i386-sequent\n\t\t;;\n\tsh)\n\t\tbasic_machine=sh-hitachi\n\t\tos=-hms\n\t\t;;\n\tsh5el)\n\t\tbasic_machine=sh5le-unknown\n\t\t;;\n\tsh64)\n\t\tbasic_machine=sh64-unknown\n\t\t;;\n\tsparclite-wrs | simso-wrs)\n\t\tbasic_machine=sparclite-wrs\n\t\tos=-vxworks\n\t\t;;\n\tsps7)\n\t\tbasic_machine=m68k-bull\n\t\tos=-sysv2\n\t\t;;\n\tspur)\n\t\tbasic_machine=spur-unknown\n\t\t;;\n\tst2000)\n\t\tbasic_machine=m68k-tandem\n\t\t;;\n\tstratus)\n\t\tbasic_machine=i860-stratus\n\t\tos=-sysv4\n\t\t;;\n\tstrongarm-* | thumb-*)\n\t\tbasic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`\n\t\t;;\n\tsun2)\n\t\tbasic_machine=m68000-sun\n\t\t;;\n\tsun2os3)\n\t\tbasic_machine=m68000-sun\n\t\tos=-sunos3\n\t\t;;\n\tsun2os4)\n\t\tbasic_machine=m68000-sun\n\t\tos=-sunos4\n\t\t;;\n\tsun3os3)\n\t\tbasic_machine=m68k-sun\n\t\tos=-sunos3\n\t\t;;\n\tsun3os4)\n\t\tbasic_machine=m68k-sun\n\t\tos=-sunos4\n\t\t;;\n\tsun4os3)\n\t\tbasic_machine=sparc-sun\n\t\tos=-sunos3\n\t\t;;\n\tsun4os4)\n\t\tbasic_machine=sparc-sun\n\t\tos=-sunos4\n\t\t;;\n\tsun4sol2)\n\t\tbasic_machine=sparc-sun\n\t\tos=-solaris2\n\t\t;;\n\tsun3 | sun3-*)\n\t\tbasic_machine=m68k-sun\n\t\t;;\n\tsun4)\n\t\tbasic_machine=sparc-sun\n\t\t;;\n\tsun386 | sun386i | roadrunner)\n\t\tbasic_machine=i386-sun\n\t\t;;\n\tsv1)\n\t\tbasic_machine=sv1-cray\n\t\tos=-unicos\n\t\t;;\n\tsymmetry)\n\t\tbasic_machine=i386-sequent\n\t\tos=-dynix\n\t\t;;\n\tt3e)\n\t\tbasic_machine=alphaev5-cray\n\t\tos=-unicos\n\t\t;;\n\tt90)\n\t\tbasic_machine=t90-cray\n\t\tos=-unicos\n\t\t;;\n\ttile*)\n\t\tbasic_machine=$basic_machine-unknown\n\t\tos=-linux-gnu\n\t\t;;\n\ttx39)\n\t\tbasic_machine=mipstx39-unknown\n\t\t;;\n\ttx39el)\n\t\tbasic_machine=mipstx39el-unknown\n\t\t;;\n\ttoad1)\n\t\tbasic_machine=pdp10-xkl\n\t\tos=-tops20\n\t\t;;\n\ttower | tower-32)\n\t\tbasic_machine=m68k-ncr\n\t\t;;\n\ttpf)\n\t\tbasic_machine=s390x-ibm\n\t\tos=-tpf\n\t\t;;\n\tudi29k)\n\t\tbasic_machine=a29k-amd\n\t\tos=-udi\n\t\t;;\n\tultra3)\n\t\tbasic_machine=a29k-nyu\n\t\tos=-sym1\n\t\t;;\n\tv810 | necv810)\n\t\tbasic_machine=v810-nec\n\t\tos=-none\n\t\t;;\n\tvaxv)\n\t\tbasic_machine=vax-dec\n\t\tos=-sysv\n\t\t;;\n\tvms)\n\t\tbasic_machine=vax-dec\n\t\tos=-vms\n\t\t;;\n\tvpp*|vx|vx-*)\n\t\tbasic_machine=f301-fujitsu\n\t\t;;\n\tvxworks960)\n\t\tbasic_machine=i960-wrs\n\t\tos=-vxworks\n\t\t;;\n\tvxworks68)\n\t\tbasic_machine=m68k-wrs\n\t\tos=-vxworks\n\t\t;;\n\tvxworks29k)\n\t\tbasic_machine=a29k-wrs\n\t\tos=-vxworks\n\t\t;;\n\tw65*)\n\t\tbasic_machine=w65-wdc\n\t\tos=-none\n\t\t;;\n\tw89k-*)\n\t\tbasic_machine=hppa1.1-winbond\n\t\tos=-proelf\n\t\t;;\n\txbox)\n\t\tbasic_machine=i686-pc\n\t\tos=-mingw32\n\t\t;;\n\txps | xps100)\n\t\tbasic_machine=xps100-honeywell\n\t\t;;\n\txscale-* | xscalee[bl]-*)\n\t\tbasic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`\n\t\t;;\n\tymp)\n\t\tbasic_machine=ymp-cray\n\t\tos=-unicos\n\t\t;;\n\tz8k-*-coff)\n\t\tbasic_machine=z8k-unknown\n\t\tos=-sim\n\t\t;;\n\tz80-*-coff)\n\t\tbasic_machine=z80-unknown\n\t\tos=-sim\n\t\t;;\n\tnone)\n\t\tbasic_machine=none-none\n\t\tos=-none\n\t\t;;\n\n# Here we handle the default manufacturer of certain CPU types.  It is in\n# some cases the only manufacturer, in others, it is the most popular.\n\tw89k)\n\t\tbasic_machine=hppa1.1-winbond\n\t\t;;\n\top50n)\n\t\tbasic_machine=hppa1.1-oki\n\t\t;;\n\top60c)\n\t\tbasic_machine=hppa1.1-oki\n\t\t;;\n\tromp)\n\t\tbasic_machine=romp-ibm\n\t\t;;\n\tmmix)\n\t\tbasic_machine=mmix-knuth\n\t\t;;\n\trs6000)\n\t\tbasic_machine=rs6000-ibm\n\t\t;;\n\tvax)\n\t\tbasic_machine=vax-dec\n\t\t;;\n\tpdp10)\n\t\t# there are many clones, so DEC is not a safe bet\n\t\tbasic_machine=pdp10-unknown\n\t\t;;\n\tpdp11)\n\t\tbasic_machine=pdp11-dec\n\t\t;;\n\twe32k)\n\t\tbasic_machine=we32k-att\n\t\t;;\n\tsh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)\n\t\tbasic_machine=sh-unknown\n\t\t;;\n\tsparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)\n\t\tbasic_machine=sparc-sun\n\t\t;;\n\tcydra)\n\t\tbasic_machine=cydra-cydrome\n\t\t;;\n\torion)\n\t\tbasic_machine=orion-highlevel\n\t\t;;\n\torion105)\n\t\tbasic_machine=clipper-highlevel\n\t\t;;\n\tmac | mpw | mac-mpw)\n\t\tbasic_machine=m68k-apple\n\t\t;;\n\tpmac | pmac-mpw)\n\t\tbasic_machine=powerpc-apple\n\t\t;;\n\t*-unknown)\n\t\t# Make sure to match an already-canonicalized machine name.\n\t\t;;\n\t*)\n\t\techo Invalid configuration \\`$1\\': machine \\`$basic_machine\\' not recognized 1>&2\n\t\texit 1\n\t\t;;\nesac\n\n# Here we canonicalize certain aliases for manufacturers.\ncase $basic_machine in\n\t*-digital*)\n\t\tbasic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`\n\t\t;;\n\t*-commodore*)\n\t\tbasic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`\n\t\t;;\n\t*)\n\t\t;;\nesac\n\n# Decode manufacturer-specific aliases for certain operating systems.\n\nif [ x\"$os\" != x\"\" ]\nthen\ncase $os in\n\t# First match some system type aliases\n\t# that might get confused with valid system types.\n\t# -solaris* is a basic system type, with this one exception.\n\t-auroraux)\n\t\tos=-auroraux\n\t\t;;\n\t-solaris1 | -solaris1.*)\n\t\tos=`echo $os | sed -e 's|solaris1|sunos4|'`\n\t\t;;\n\t-solaris)\n\t\tos=-solaris2\n\t\t;;\n\t-svr4*)\n\t\tos=-sysv4\n\t\t;;\n\t-unixware*)\n\t\tos=-sysv4.2uw\n\t\t;;\n\t-gnu/linux*)\n\t\tos=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`\n\t\t;;\n\t# First accept the basic system types.\n\t# The portable systems comes first.\n\t# Each alternative MUST END IN A *, to match a version number.\n\t# -sysv* is not here because it comes later, after sysvr4.\n\t-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \\\n\t      | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\\\n\t      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \\\n\t      | -sym* | -kopensolaris* | -plan9* \\\n\t      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \\\n\t      | -aos* | -aros* \\\n\t      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \\\n\t      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \\\n\t      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \\\n\t      | -bitrig* | -openbsd* | -solidbsd* \\\n\t      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \\\n\t      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \\\n\t      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \\\n\t      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \\\n\t      | -chorusos* | -chorusrdb* | -cegcc* \\\n\t      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \\\n\t      | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \\\n\t      | -linux-newlib* | -linux-musl* | -linux-uclibc* \\\n\t      | -uxpv* | -beos* | -mpeix* | -udk* \\\n\t      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \\\n\t      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \\\n\t      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \\\n\t      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \\\n\t      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \\\n\t      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \\\n\t      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)\n\t# Remember, each alternative MUST END IN *, to match a version number.\n\t\t;;\n\t-qnx*)\n\t\tcase $basic_machine in\n\t\t    x86-* | i*86-*)\n\t\t\t;;\n\t\t    *)\n\t\t\tos=-nto$os\n\t\t\t;;\n\t\tesac\n\t\t;;\n\t-nto-qnx*)\n\t\t;;\n\t-nto*)\n\t\tos=`echo $os | sed -e 's|nto|nto-qnx|'`\n\t\t;;\n\t-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \\\n\t      | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \\\n\t      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)\n\t\t;;\n\t-mac*)\n\t\tos=`echo $os | sed -e 's|mac|macos|'`\n\t\t;;\n\t-linux-dietlibc)\n\t\tos=-linux-dietlibc\n\t\t;;\n\t-linux*)\n\t\tos=`echo $os | sed -e 's|linux|linux-gnu|'`\n\t\t;;\n\t-sunos5*)\n\t\tos=`echo $os | sed -e 's|sunos5|solaris2|'`\n\t\t;;\n\t-sunos6*)\n\t\tos=`echo $os | sed -e 's|sunos6|solaris3|'`\n\t\t;;\n\t-opened*)\n\t\tos=-openedition\n\t\t;;\n\t-os400*)\n\t\tos=-os400\n\t\t;;\n\t-wince*)\n\t\tos=-wince\n\t\t;;\n\t-osfrose*)\n\t\tos=-osfrose\n\t\t;;\n\t-osf*)\n\t\tos=-osf\n\t\t;;\n\t-utek*)\n\t\tos=-bsd\n\t\t;;\n\t-dynix*)\n\t\tos=-bsd\n\t\t;;\n\t-acis*)\n\t\tos=-aos\n\t\t;;\n\t-atheos*)\n\t\tos=-atheos\n\t\t;;\n\t-syllable*)\n\t\tos=-syllable\n\t\t;;\n\t-386bsd)\n\t\tos=-bsd\n\t\t;;\n\t-ctix* | -uts*)\n\t\tos=-sysv\n\t\t;;\n\t-nova*)\n\t\tos=-rtmk-nova\n\t\t;;\n\t-ns2 )\n\t\tos=-nextstep2\n\t\t;;\n\t-nsk*)\n\t\tos=-nsk\n\t\t;;\n\t# Preserve the version number of sinix5.\n\t-sinix5.*)\n\t\tos=`echo $os | sed -e 's|sinix|sysv|'`\n\t\t;;\n\t-sinix*)\n\t\tos=-sysv4\n\t\t;;\n\t-tpf*)\n\t\tos=-tpf\n\t\t;;\n\t-triton*)\n\t\tos=-sysv3\n\t\t;;\n\t-oss*)\n\t\tos=-sysv3\n\t\t;;\n\t-svr4)\n\t\tos=-sysv4\n\t\t;;\n\t-svr3)\n\t\tos=-sysv3\n\t\t;;\n\t-sysvr4)\n\t\tos=-sysv4\n\t\t;;\n\t# This must come after -sysvr4.\n\t-sysv*)\n\t\t;;\n\t-ose*)\n\t\tos=-ose\n\t\t;;\n\t-es1800*)\n\t\tos=-ose\n\t\t;;\n\t-xenix)\n\t\tos=-xenix\n\t\t;;\n\t-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)\n\t\tos=-mint\n\t\t;;\n\t-aros*)\n\t\tos=-aros\n\t\t;;\n\t-zvmoe)\n\t\tos=-zvmoe\n\t\t;;\n\t-dicos*)\n\t\tos=-dicos\n\t\t;;\n\t-nacl*)\n\t\t;;\n\t-none)\n\t\t;;\n\t*)\n\t\t# Get rid of the `-' at the beginning of $os.\n\t\tos=`echo $os | sed 's/[^-]*-//'`\n\t\techo Invalid configuration \\`$1\\': system \\`$os\\' not recognized 1>&2\n\t\texit 1\n\t\t;;\nesac\nelse\n\n# Here we handle the default operating systems that come with various machines.\n# The value should be what the vendor currently ships out the door with their\n# machine or put another way, the most popular os provided with the machine.\n\n# Note that if you're going to try to match \"-MANUFACTURER\" here (say,\n# \"-sun\"), then you have to tell the case statement up towards the top\n# that MANUFACTURER isn't an operating system.  Otherwise, code above\n# will signal an error saying that MANUFACTURER isn't an operating\n# system, and we'll never get to this point.\n\ncase $basic_machine in\n\tscore-*)\n\t\tos=-elf\n\t\t;;\n\tspu-*)\n\t\tos=-elf\n\t\t;;\n\t*-acorn)\n\t\tos=-riscix1.2\n\t\t;;\n\tarm*-rebel)\n\t\tos=-linux\n\t\t;;\n\tarm*-semi)\n\t\tos=-aout\n\t\t;;\n\tc4x-* | tic4x-*)\n\t\tos=-coff\n\t\t;;\n\tc8051-*)\n\t\tos=-elf\n\t\t;;\n\thexagon-*)\n\t\tos=-elf\n\t\t;;\n\ttic54x-*)\n\t\tos=-coff\n\t\t;;\n\ttic55x-*)\n\t\tos=-coff\n\t\t;;\n\ttic6x-*)\n\t\tos=-coff\n\t\t;;\n\t# This must come before the *-dec entry.\n\tpdp10-*)\n\t\tos=-tops20\n\t\t;;\n\tpdp11-*)\n\t\tos=-none\n\t\t;;\n\t*-dec | vax-*)\n\t\tos=-ultrix4.2\n\t\t;;\n\tm68*-apollo)\n\t\tos=-domain\n\t\t;;\n\ti386-sun)\n\t\tos=-sunos4.0.2\n\t\t;;\n\tm68000-sun)\n\t\tos=-sunos3\n\t\t;;\n\tm68*-cisco)\n\t\tos=-aout\n\t\t;;\n\tmep-*)\n\t\tos=-elf\n\t\t;;\n\tmips*-cisco)\n\t\tos=-elf\n\t\t;;\n\tmips*-*)\n\t\tos=-elf\n\t\t;;\n\tor1k-*)\n\t\tos=-elf\n\t\t;;\n\tor32-*)\n\t\tos=-coff\n\t\t;;\n\t*-tti)\t# must be before sparc entry or we get the wrong os.\n\t\tos=-sysv3\n\t\t;;\n\tsparc-* | *-sun)\n\t\tos=-sunos4.1.1\n\t\t;;\n\t*-be)\n\t\tos=-beos\n\t\t;;\n\t*-haiku)\n\t\tos=-haiku\n\t\t;;\n\t*-ibm)\n\t\tos=-aix\n\t\t;;\n\t*-knuth)\n\t\tos=-mmixware\n\t\t;;\n\t*-wec)\n\t\tos=-proelf\n\t\t;;\n\t*-winbond)\n\t\tos=-proelf\n\t\t;;\n\t*-oki)\n\t\tos=-proelf\n\t\t;;\n\t*-hp)\n\t\tos=-hpux\n\t\t;;\n\t*-hitachi)\n\t\tos=-hiux\n\t\t;;\n\ti860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)\n\t\tos=-sysv\n\t\t;;\n\t*-cbm)\n\t\tos=-amigaos\n\t\t;;\n\t*-dg)\n\t\tos=-dgux\n\t\t;;\n\t*-dolphin)\n\t\tos=-sysv3\n\t\t;;\n\tm68k-ccur)\n\t\tos=-rtu\n\t\t;;\n\tm88k-omron*)\n\t\tos=-luna\n\t\t;;\n\t*-next )\n\t\tos=-nextstep\n\t\t;;\n\t*-sequent)\n\t\tos=-ptx\n\t\t;;\n\t*-crds)\n\t\tos=-unos\n\t\t;;\n\t*-ns)\n\t\tos=-genix\n\t\t;;\n\ti370-*)\n\t\tos=-mvs\n\t\t;;\n\t*-next)\n\t\tos=-nextstep3\n\t\t;;\n\t*-gould)\n\t\tos=-sysv\n\t\t;;\n\t*-highlevel)\n\t\tos=-bsd\n\t\t;;\n\t*-encore)\n\t\tos=-bsd\n\t\t;;\n\t*-sgi)\n\t\tos=-irix\n\t\t;;\n\t*-siemens)\n\t\tos=-sysv4\n\t\t;;\n\t*-masscomp)\n\t\tos=-rtu\n\t\t;;\n\tf30[01]-fujitsu | f700-fujitsu)\n\t\tos=-uxpv\n\t\t;;\n\t*-rom68k)\n\t\tos=-coff\n\t\t;;\n\t*-*bug)\n\t\tos=-coff\n\t\t;;\n\t*-apple)\n\t\tos=-macos\n\t\t;;\n\t*-atari*)\n\t\tos=-mint\n\t\t;;\n\t*)\n\t\tos=-none\n\t\t;;\nesac\nfi\n\n# Here we handle the case where we know the os, and the CPU type, but not the\n# manufacturer.  We pick the logical manufacturer.\nvendor=unknown\ncase $basic_machine in\n\t*-unknown)\n\t\tcase $os in\n\t\t\t-riscix*)\n\t\t\t\tvendor=acorn\n\t\t\t\t;;\n\t\t\t-sunos*)\n\t\t\t\tvendor=sun\n\t\t\t\t;;\n\t\t\t-cnk*|-aix*)\n\t\t\t\tvendor=ibm\n\t\t\t\t;;\n\t\t\t-beos*)\n\t\t\t\tvendor=be\n\t\t\t\t;;\n\t\t\t-hpux*)\n\t\t\t\tvendor=hp\n\t\t\t\t;;\n\t\t\t-mpeix*)\n\t\t\t\tvendor=hp\n\t\t\t\t;;\n\t\t\t-hiux*)\n\t\t\t\tvendor=hitachi\n\t\t\t\t;;\n\t\t\t-unos*)\n\t\t\t\tvendor=crds\n\t\t\t\t;;\n\t\t\t-dgux*)\n\t\t\t\tvendor=dg\n\t\t\t\t;;\n\t\t\t-luna*)\n\t\t\t\tvendor=omron\n\t\t\t\t;;\n\t\t\t-genix*)\n\t\t\t\tvendor=ns\n\t\t\t\t;;\n\t\t\t-mvs* | -opened*)\n\t\t\t\tvendor=ibm\n\t\t\t\t;;\n\t\t\t-os400*)\n\t\t\t\tvendor=ibm\n\t\t\t\t;;\n\t\t\t-ptx*)\n\t\t\t\tvendor=sequent\n\t\t\t\t;;\n\t\t\t-tpf*)\n\t\t\t\tvendor=ibm\n\t\t\t\t;;\n\t\t\t-vxsim* | -vxworks* | -windiss*)\n\t\t\t\tvendor=wrs\n\t\t\t\t;;\n\t\t\t-aux*)\n\t\t\t\tvendor=apple\n\t\t\t\t;;\n\t\t\t-hms*)\n\t\t\t\tvendor=hitachi\n\t\t\t\t;;\n\t\t\t-mpw* | -macos*)\n\t\t\t\tvendor=apple\n\t\t\t\t;;\n\t\t\t-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)\n\t\t\t\tvendor=atari\n\t\t\t\t;;\n\t\t\t-vos*)\n\t\t\t\tvendor=stratus\n\t\t\t\t;;\n\t\tesac\n\t\tbasic_machine=`echo $basic_machine | sed \"s/unknown/$vendor/\"`\n\t\t;;\nesac\n\necho $basic_machine$os\nexit\n\n# Local variables:\n# eval: (add-hook 'write-file-hooks 'time-stamp)\n# time-stamp-start: \"timestamp='\"\n# time-stamp-format: \"%:y-%02m-%02d\"\n# time-stamp-end: \"'\"\n# End:\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/configure",
    "content": "#! /bin/sh\n# Guess values for system-dependent variables and create Makefiles.\n# Generated by GNU Autoconf 2.69 for Protocol Buffers 3.0.0.\n#\n# Report bugs to <protobuf@googlegroups.com>.\n#\n#\n# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.\n#\n#\n# This configure script is free software; the Free Software Foundation\n# gives unlimited permission to copy, distribute and modify it.\n## -------------------- ##\n## M4sh Initialization. ##\n## -------------------- ##\n\n# Be more Bourne compatible\nDUALCASE=1; export DUALCASE # for MKS sh\nif test -n \"${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :\n  emulate sh\n  NULLCMD=:\n  # Pre-4.2 versions of Zsh do word splitting on ${1+\"$@\"}, which\n  # is contrary to our usage.  Disable this feature.\n  alias -g '${1+\"$@\"}'='\"$@\"'\n  setopt NO_GLOB_SUBST\nelse\n  case `(set -o) 2>/dev/null` in #(\n  *posix*) :\n    set -o posix ;; #(\n  *) :\n     ;;\nesac\nfi\n\n\nas_nl='\n'\nexport as_nl\n# Printing a long string crashes Solaris 7 /usr/bin/printf.\nas_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'\nas_echo=$as_echo$as_echo$as_echo$as_echo$as_echo\nas_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo\n# Prefer a ksh shell builtin over an external printf program on Solaris,\n# but without wasting forks for bash or zsh.\nif test -z \"$BASH_VERSION$ZSH_VERSION\" \\\n    && (test \"X`print -r -- $as_echo`\" = \"X$as_echo\") 2>/dev/null; then\n  as_echo='print -r --'\n  as_echo_n='print -rn --'\nelif (test \"X`printf %s $as_echo`\" = \"X$as_echo\") 2>/dev/null; then\n  as_echo='printf %s\\n'\n  as_echo_n='printf %s'\nelse\n  if test \"X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`\" = \"X-n $as_echo\"; then\n    as_echo_body='eval /usr/ucb/echo -n \"$1$as_nl\"'\n    as_echo_n='/usr/ucb/echo -n'\n  else\n    as_echo_body='eval expr \"X$1\" : \"X\\\\(.*\\\\)\"'\n    as_echo_n_body='eval\n      arg=$1;\n      case $arg in #(\n      *\"$as_nl\"*)\n\texpr \"X$arg\" : \"X\\\\(.*\\\\)$as_nl\";\n\targ=`expr \"X$arg\" : \".*$as_nl\\\\(.*\\\\)\"`;;\n      esac;\n      expr \"X$arg\" : \"X\\\\(.*\\\\)\" | tr -d \"$as_nl\"\n    '\n    export as_echo_n_body\n    as_echo_n='sh -c $as_echo_n_body as_echo'\n  fi\n  export as_echo_body\n  as_echo='sh -c $as_echo_body as_echo'\nfi\n\n# The user is always right.\nif test \"${PATH_SEPARATOR+set}\" != set; then\n  PATH_SEPARATOR=:\n  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {\n    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||\n      PATH_SEPARATOR=';'\n  }\nfi\n\n\n# IFS\n# We need space, tab and new line, in precisely that order.  Quoting is\n# there to prevent editors from complaining about space-tab.\n# (If _AS_PATH_WALK were called with IFS unset, it would disable word\n# splitting by setting IFS to empty value.)\nIFS=\" \"\"\t$as_nl\"\n\n# Find who we are.  Look in the path if we contain no directory separator.\nas_myself=\ncase $0 in #((\n  *[\\\\/]* ) as_myself=$0 ;;\n  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    test -r \"$as_dir/$0\" && as_myself=$as_dir/$0 && break\n  done\nIFS=$as_save_IFS\n\n     ;;\nesac\n# We did not find ourselves, most probably we were run as `sh COMMAND'\n# in which case we are not to be found in the path.\nif test \"x$as_myself\" = x; then\n  as_myself=$0\nfi\nif test ! -f \"$as_myself\"; then\n  $as_echo \"$as_myself: error: cannot find myself; rerun with an absolute file name\" >&2\n  exit 1\nfi\n\n# Unset variables that we do not need and which cause bugs (e.g. in\n# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the \"|| exit 1\"\n# suppresses any \"Segmentation fault\" message there.  '((' could\n# trigger a bug in pdksh 5.2.14.\nfor as_var in BASH_ENV ENV MAIL MAILPATH\ndo eval test x\\${$as_var+set} = xset \\\n  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :\ndone\nPS1='$ '\nPS2='> '\nPS4='+ '\n\n# NLS nuisances.\nLC_ALL=C\nexport LC_ALL\nLANGUAGE=C\nexport LANGUAGE\n\n# CDPATH.\n(unset CDPATH) >/dev/null 2>&1 && unset CDPATH\n\n# Use a proper internal environment variable to ensure we don't fall\n  # into an infinite loop, continuously re-executing ourselves.\n  if test x\"${_as_can_reexec}\" != xno && test \"x$CONFIG_SHELL\" != x; then\n    _as_can_reexec=no; export _as_can_reexec;\n    # We cannot yet assume a decent shell, so we have to provide a\n# neutralization value for shells without unset; and this also\n# works around shells that cannot unset nonexistent variables.\n# Preserve -v and -x to the replacement shell.\nBASH_ENV=/dev/null\nENV=/dev/null\n(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV\ncase $- in # ((((\n  *v*x* | *x*v* ) as_opts=-vx ;;\n  *v* ) as_opts=-v ;;\n  *x* ) as_opts=-x ;;\n  * ) as_opts= ;;\nesac\nexec $CONFIG_SHELL $as_opts \"$as_myself\" ${1+\"$@\"}\n# Admittedly, this is quite paranoid, since all the known shells bail\n# out after a failed `exec'.\n$as_echo \"$0: could not re-execute with $CONFIG_SHELL\" >&2\nas_fn_exit 255\n  fi\n  # We don't want this to propagate to other subprocesses.\n          { _as_can_reexec=; unset _as_can_reexec;}\nif test \"x$CONFIG_SHELL\" = x; then\n  as_bourne_compatible=\"if test -n \\\"\\${ZSH_VERSION+set}\\\" && (emulate sh) >/dev/null 2>&1; then :\n  emulate sh\n  NULLCMD=:\n  # Pre-4.2 versions of Zsh do word splitting on \\${1+\\\"\\$@\\\"}, which\n  # is contrary to our usage.  Disable this feature.\n  alias -g '\\${1+\\\"\\$@\\\"}'='\\\"\\$@\\\"'\n  setopt NO_GLOB_SUBST\nelse\n  case \\`(set -o) 2>/dev/null\\` in #(\n  *posix*) :\n    set -o posix ;; #(\n  *) :\n     ;;\nesac\nfi\n\"\n  as_required=\"as_fn_return () { (exit \\$1); }\nas_fn_success () { as_fn_return 0; }\nas_fn_failure () { as_fn_return 1; }\nas_fn_ret_success () { return 0; }\nas_fn_ret_failure () { return 1; }\n\nexitcode=0\nas_fn_success || { exitcode=1; echo as_fn_success failed.; }\nas_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }\nas_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }\nas_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }\nif ( set x; as_fn_ret_success y && test x = \\\"\\$1\\\" ); then :\n\nelse\n  exitcode=1; echo positional parameters were not saved.\nfi\ntest x\\$exitcode = x0 || exit 1\ntest -x / || exit 1\"\n  as_suggested=\"  as_lineno_1=\";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested\" as_lineno_1a=\\$LINENO\n  as_lineno_2=\";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested\" as_lineno_2a=\\$LINENO\n  eval 'test \\\"x\\$as_lineno_1'\\$as_run'\\\" != \\\"x\\$as_lineno_2'\\$as_run'\\\" &&\n  test \\\"x\\`expr \\$as_lineno_1'\\$as_run' + 1\\`\\\" = \\\"x\\$as_lineno_2'\\$as_run'\\\"' || exit 1\ntest \\$(( 1 + 1 )) = 2 || exit 1\n\n  test -n \\\"\\${ZSH_VERSION+set}\\${BASH_VERSION+set}\\\" || (\n    ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'\n    ECHO=\\$ECHO\\$ECHO\\$ECHO\\$ECHO\\$ECHO\n    ECHO=\\$ECHO\\$ECHO\\$ECHO\\$ECHO\\$ECHO\\$ECHO\n    PATH=/empty FPATH=/empty; export PATH FPATH\n    test \\\"X\\`printf %s \\$ECHO\\`\\\" = \\\"X\\$ECHO\\\" \\\\\n      || test \\\"X\\`print -r -- \\$ECHO\\`\\\" = \\\"X\\$ECHO\\\" ) || exit 1\"\n  if (eval \"$as_required\") 2>/dev/null; then :\n  as_have_required=yes\nelse\n  as_have_required=no\nfi\n  if test x$as_have_required = xyes && (eval \"$as_suggested\") 2>/dev/null; then :\n\nelse\n  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nas_found=false\nfor as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n  as_found=:\n  case $as_dir in #(\n\t /*)\n\t   for as_base in sh bash ksh sh5; do\n\t     # Try only shells that exist, to save several forks.\n\t     as_shell=$as_dir/$as_base\n\t     if { test -f \"$as_shell\" || test -f \"$as_shell.exe\"; } &&\n\t\t    { $as_echo \"$as_bourne_compatible\"\"$as_required\" | as_run=a \"$as_shell\"; } 2>/dev/null; then :\n  CONFIG_SHELL=$as_shell as_have_required=yes\n\t\t   if { $as_echo \"$as_bourne_compatible\"\"$as_suggested\" | as_run=a \"$as_shell\"; } 2>/dev/null; then :\n  break 2\nfi\nfi\n\t   done;;\n       esac\n  as_found=false\ndone\n$as_found || { if { test -f \"$SHELL\" || test -f \"$SHELL.exe\"; } &&\n\t      { $as_echo \"$as_bourne_compatible\"\"$as_required\" | as_run=a \"$SHELL\"; } 2>/dev/null; then :\n  CONFIG_SHELL=$SHELL as_have_required=yes\nfi; }\nIFS=$as_save_IFS\n\n\n      if test \"x$CONFIG_SHELL\" != x; then :\n  export CONFIG_SHELL\n             # We cannot yet assume a decent shell, so we have to provide a\n# neutralization value for shells without unset; and this also\n# works around shells that cannot unset nonexistent variables.\n# Preserve -v and -x to the replacement shell.\nBASH_ENV=/dev/null\nENV=/dev/null\n(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV\ncase $- in # ((((\n  *v*x* | *x*v* ) as_opts=-vx ;;\n  *v* ) as_opts=-v ;;\n  *x* ) as_opts=-x ;;\n  * ) as_opts= ;;\nesac\nexec $CONFIG_SHELL $as_opts \"$as_myself\" ${1+\"$@\"}\n# Admittedly, this is quite paranoid, since all the known shells bail\n# out after a failed `exec'.\n$as_echo \"$0: could not re-execute with $CONFIG_SHELL\" >&2\nexit 255\nfi\n\n    if test x$as_have_required = xno; then :\n  $as_echo \"$0: This script requires a shell more modern than all\"\n  $as_echo \"$0: the shells that I found on your system.\"\n  if test x${ZSH_VERSION+set} = xset ; then\n    $as_echo \"$0: In particular, zsh $ZSH_VERSION has bugs and should\"\n    $as_echo \"$0: be upgraded to zsh 4.3.4 or later.\"\n  else\n    $as_echo \"$0: Please tell bug-autoconf@gnu.org and\n$0: protobuf@googlegroups.com about your system, including\n$0: any error possibly output before this message. Then\n$0: install a modern shell, or manually run the script\n$0: under such a shell if you do have one.\"\n  fi\n  exit 1\nfi\nfi\nfi\nSHELL=${CONFIG_SHELL-/bin/sh}\nexport SHELL\n# Unset more variables known to interfere with behavior of common tools.\nCLICOLOR_FORCE= GREP_OPTIONS=\nunset CLICOLOR_FORCE GREP_OPTIONS\n\n## --------------------- ##\n## M4sh Shell Functions. ##\n## --------------------- ##\n# as_fn_unset VAR\n# ---------------\n# Portably unset VAR.\nas_fn_unset ()\n{\n  { eval $1=; unset $1;}\n}\nas_unset=as_fn_unset\n\n# as_fn_set_status STATUS\n# -----------------------\n# Set $? to STATUS, without forking.\nas_fn_set_status ()\n{\n  return $1\n} # as_fn_set_status\n\n# as_fn_exit STATUS\n# -----------------\n# Exit the shell with STATUS, even in a \"trap 0\" or \"set -e\" context.\nas_fn_exit ()\n{\n  set +e\n  as_fn_set_status $1\n  exit $1\n} # as_fn_exit\n\n# as_fn_mkdir_p\n# -------------\n# Create \"$as_dir\" as a directory, including parents if necessary.\nas_fn_mkdir_p ()\n{\n\n  case $as_dir in #(\n  -*) as_dir=./$as_dir;;\n  esac\n  test -d \"$as_dir\" || eval $as_mkdir_p || {\n    as_dirs=\n    while :; do\n      case $as_dir in #(\n      *\\'*) as_qdir=`$as_echo \"$as_dir\" | sed \"s/'/'\\\\\\\\\\\\\\\\''/g\"`;; #'(\n      *) as_qdir=$as_dir;;\n      esac\n      as_dirs=\"'$as_qdir' $as_dirs\"\n      as_dir=`$as_dirname -- \"$as_dir\" ||\n$as_expr X\"$as_dir\" : 'X\\(.*[^/]\\)//*[^/][^/]*/*$' \\| \\\n\t X\"$as_dir\" : 'X\\(//\\)[^/]' \\| \\\n\t X\"$as_dir\" : 'X\\(//\\)$' \\| \\\n\t X\"$as_dir\" : 'X\\(/\\)' \\| . 2>/dev/null ||\n$as_echo X\"$as_dir\" |\n    sed '/^X\\(.*[^/]\\)\\/\\/*[^/][^/]*\\/*$/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\(\\/\\/\\)[^/].*/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\(\\/\\/\\)$/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\(\\/\\).*/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  s/.*/./; q'`\n      test -d \"$as_dir\" && break\n    done\n    test -z \"$as_dirs\" || eval \"mkdir $as_dirs\"\n  } || test -d \"$as_dir\" || as_fn_error $? \"cannot create directory $as_dir\"\n\n\n} # as_fn_mkdir_p\n\n# as_fn_executable_p FILE\n# -----------------------\n# Test if FILE is an executable regular file.\nas_fn_executable_p ()\n{\n  test -f \"$1\" && test -x \"$1\"\n} # as_fn_executable_p\n# as_fn_append VAR VALUE\n# ----------------------\n# Append the text in VALUE to the end of the definition contained in VAR. Take\n# advantage of any shell optimizations that allow amortized linear growth over\n# repeated appends, instead of the typical quadratic growth present in naive\n# implementations.\nif (eval \"as_var=1; as_var+=2; test x\\$as_var = x12\") 2>/dev/null; then :\n  eval 'as_fn_append ()\n  {\n    eval $1+=\\$2\n  }'\nelse\n  as_fn_append ()\n  {\n    eval $1=\\$$1\\$2\n  }\nfi # as_fn_append\n\n# as_fn_arith ARG...\n# ------------------\n# Perform arithmetic evaluation on the ARGs, and store the result in the\n# global $as_val. Take advantage of shells that can avoid forks. The arguments\n# must be portable across $(()) and expr.\nif (eval \"test \\$(( 1 + 1 )) = 2\") 2>/dev/null; then :\n  eval 'as_fn_arith ()\n  {\n    as_val=$(( $* ))\n  }'\nelse\n  as_fn_arith ()\n  {\n    as_val=`expr \"$@\" || test $? -eq 1`\n  }\nfi # as_fn_arith\n\n\n# as_fn_error STATUS ERROR [LINENO LOG_FD]\n# ----------------------------------------\n# Output \"`basename $0`: error: ERROR\" to stderr. If LINENO and LOG_FD are\n# provided, also output the error to LOG_FD, referencing LINENO. Then exit the\n# script with STATUS, using 1 if that was 0.\nas_fn_error ()\n{\n  as_status=$1; test $as_status -eq 0 && as_status=1\n  if test \"$4\"; then\n    as_lineno=${as_lineno-\"$3\"} as_lineno_stack=as_lineno_stack=$as_lineno_stack\n    $as_echo \"$as_me:${as_lineno-$LINENO}: error: $2\" >&$4\n  fi\n  $as_echo \"$as_me: error: $2\" >&2\n  as_fn_exit $as_status\n} # as_fn_error\n\nif expr a : '\\(a\\)' >/dev/null 2>&1 &&\n   test \"X`expr 00001 : '.*\\(...\\)'`\" = X001; then\n  as_expr=expr\nelse\n  as_expr=false\nfi\n\nif (basename -- /) >/dev/null 2>&1 && test \"X`basename -- / 2>&1`\" = \"X/\"; then\n  as_basename=basename\nelse\n  as_basename=false\nfi\n\nif (as_dir=`dirname -- /` && test \"X$as_dir\" = X/) >/dev/null 2>&1; then\n  as_dirname=dirname\nelse\n  as_dirname=false\nfi\n\nas_me=`$as_basename -- \"$0\" ||\n$as_expr X/\"$0\" : '.*/\\([^/][^/]*\\)/*$' \\| \\\n\t X\"$0\" : 'X\\(//\\)$' \\| \\\n\t X\"$0\" : 'X\\(/\\)' \\| . 2>/dev/null ||\n$as_echo X/\"$0\" |\n    sed '/^.*\\/\\([^/][^/]*\\)\\/*$/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\/\\(\\/\\/\\)$/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\/\\(\\/\\).*/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  s/.*/./; q'`\n\n# Avoid depending upon Character Ranges.\nas_cr_letters='abcdefghijklmnopqrstuvwxyz'\nas_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'\nas_cr_Letters=$as_cr_letters$as_cr_LETTERS\nas_cr_digits='0123456789'\nas_cr_alnum=$as_cr_Letters$as_cr_digits\n\n\n  as_lineno_1=$LINENO as_lineno_1a=$LINENO\n  as_lineno_2=$LINENO as_lineno_2a=$LINENO\n  eval 'test \"x$as_lineno_1'$as_run'\" != \"x$as_lineno_2'$as_run'\" &&\n  test \"x`expr $as_lineno_1'$as_run' + 1`\" = \"x$as_lineno_2'$as_run'\"' || {\n  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)\n  sed -n '\n    p\n    /[$]LINENO/=\n  ' <$as_myself |\n    sed '\n      s/[$]LINENO.*/&-/\n      t lineno\n      b\n      :lineno\n      N\n      :loop\n      s/[$]LINENO\\([^'$as_cr_alnum'_].*\\n\\)\\(.*\\)/\\2\\1\\2/\n      t loop\n      s/-\\n.*//\n    ' >$as_me.lineno &&\n  chmod +x \"$as_me.lineno\" ||\n    { $as_echo \"$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell\" >&2; as_fn_exit 1; }\n\n  # If we had to re-execute with $CONFIG_SHELL, we're ensured to have\n  # already done that, so ensure we don't try to do so again and fall\n  # in an infinite loop.  This has already happened in practice.\n  _as_can_reexec=no; export _as_can_reexec\n  # Don't try to exec as it changes $[0], causing all sort of problems\n  # (the dirname of $[0] is not the place where we might find the\n  # original and so on.  Autoconf is especially sensitive to this).\n  . \"./$as_me.lineno\"\n  # Exit status is that of the last command.\n  exit\n}\n\nECHO_C= ECHO_N= ECHO_T=\ncase `echo -n x` in #(((((\n-n*)\n  case `echo 'xy\\c'` in\n  *c*) ECHO_T='\t';;\t# ECHO_T is single tab character.\n  xy)  ECHO_C='\\c';;\n  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null\n       ECHO_T='\t';;\n  esac;;\n*)\n  ECHO_N='-n';;\nesac\n\nrm -f conf$$ conf$$.exe conf$$.file\nif test -d conf$$.dir; then\n  rm -f conf$$.dir/conf$$.file\nelse\n  rm -f conf$$.dir\n  mkdir conf$$.dir 2>/dev/null\nfi\nif (echo >conf$$.file) 2>/dev/null; then\n  if ln -s conf$$.file conf$$ 2>/dev/null; then\n    as_ln_s='ln -s'\n    # ... but there are two gotchas:\n    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.\n    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.\n    # In both cases, we have to default to `cp -pR'.\n    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||\n      as_ln_s='cp -pR'\n  elif ln conf$$.file conf$$ 2>/dev/null; then\n    as_ln_s=ln\n  else\n    as_ln_s='cp -pR'\n  fi\nelse\n  as_ln_s='cp -pR'\nfi\nrm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file\nrmdir conf$$.dir 2>/dev/null\n\nif mkdir -p . 2>/dev/null; then\n  as_mkdir_p='mkdir -p \"$as_dir\"'\nelse\n  test -d ./-p && rmdir ./-p\n  as_mkdir_p=false\nfi\n\nas_test_x='test -x'\nas_executable_p=as_fn_executable_p\n\n# Sed expression to map a string onto a valid CPP name.\nas_tr_cpp=\"eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'\"\n\n# Sed expression to map a string onto a valid variable name.\nas_tr_sh=\"eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'\"\n\nSHELL=${CONFIG_SHELL-/bin/sh}\n\n\ntest -n \"$DJDIR\" || exec 7<&0 </dev/null\nexec 6>&1\n\n# Name of the host.\n# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,\n# so uname gets run too.\nac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`\n\n#\n# Initializations.\n#\nac_default_prefix=/usr/local\nac_clean_files=\nac_config_libobj_dir=.\nLIBOBJS=\ncross_compiling=no\nsubdirs=\nMFLAGS=\nMAKEFLAGS=\n\n# Identity of this package.\nPACKAGE_NAME='Protocol Buffers'\nPACKAGE_TARNAME='protobuf'\nPACKAGE_VERSION='3.0.0'\nPACKAGE_STRING='Protocol Buffers 3.0.0'\nPACKAGE_BUGREPORT='protobuf@googlegroups.com'\nPACKAGE_URL=''\n\nac_unique_file=\"src/google/protobuf/message.cc\"\n# Factoring default headers for most tests.\nac_includes_default=\"\\\n#include <stdio.h>\n#ifdef HAVE_SYS_TYPES_H\n# include <sys/types.h>\n#endif\n#ifdef HAVE_SYS_STAT_H\n# include <sys/stat.h>\n#endif\n#ifdef STDC_HEADERS\n# include <stdlib.h>\n# include <stddef.h>\n#else\n# ifdef HAVE_STDLIB_H\n#  include <stdlib.h>\n# endif\n#endif\n#ifdef HAVE_STRING_H\n# if !defined STDC_HEADERS && defined HAVE_MEMORY_H\n#  include <memory.h>\n# endif\n# include <string.h>\n#endif\n#ifdef HAVE_STRINGS_H\n# include <strings.h>\n#endif\n#ifdef HAVE_INTTYPES_H\n# include <inttypes.h>\n#endif\n#ifdef HAVE_STDINT_H\n# include <stdint.h>\n#endif\n#ifdef HAVE_UNISTD_H\n# include <unistd.h>\n#endif\"\n\nenable_option_checking=no\nac_subst_vars='am__EXEEXT_FALSE\nam__EXEEXT_TRUE\nLTLIBOBJS\nsubdirs\nOBJC_CONFORMANCE_TEST_FALSE\nOBJC_CONFORMANCE_TEST_TRUE\nHAVE_PTHREAD_FALSE\nHAVE_PTHREAD_TRUE\nPTHREAD_CFLAGS\nPTHREAD_LIBS\nPTHREAD_CC\nacx_pthread_config\nUSE_EXTERNAL_PROTOC_FALSE\nUSE_EXTERNAL_PROTOC_TRUE\nPROTOC\nHAVE_ZLIB_FALSE\nHAVE_ZLIB_TRUE\nPOW_LIB\nLIBOBJS\nOTOOL64\nOTOOL\nLIPO\nNMEDIT\nDSYMUTIL\nMANIFEST_TOOL\nRANLIB\nDLLTOOL\nOBJDUMP\nLN_S\nNM\nac_ct_DUMPBIN\nDUMPBIN\nLD\nFGREP\nSED\nLIBTOOL\nISAINFO\nPROTOBUF_OPT_FLAG\nam__fastdepOBJC_FALSE\nam__fastdepOBJC_TRUE\nOBJCDEPMODE\nac_ct_OBJC\nOBJCFLAGS\nOBJC\nGCC_FALSE\nGCC_TRUE\nac_ct_AR\nAR\nEGREP\nGREP\nCXXCPP\nam__fastdepCXX_FALSE\nam__fastdepCXX_TRUE\nCXXDEPMODE\nac_ct_CXX\nCXXFLAGS\nCXX\nam__fastdepCC_FALSE\nam__fastdepCC_TRUE\nCCDEPMODE\nam__nodep\nAMDEPBACKSLASH\nAMDEP_FALSE\nAMDEP_TRUE\nam__quote\nam__include\nDEPDIR\nOBJEXT\nEXEEXT\nac_ct_CC\nCPPFLAGS\nLDFLAGS\nCFLAGS\nCC\nAM_BACKSLASH\nAM_DEFAULT_VERBOSITY\nAM_DEFAULT_V\nAM_V\nam__untar\nam__tar\nAMTAR\nam__leading_dot\nSET_MAKE\nAWK\nmkdir_p\nMKDIR_P\nINSTALL_STRIP_PROGRAM\nSTRIP\ninstall_sh\nMAKEINFO\nAUTOHEADER\nAUTOMAKE\nAUTOCONF\nACLOCAL\nVERSION\nPACKAGE\nCYGPATH_W\nam__isrc\nINSTALL_DATA\nINSTALL_SCRIPT\nINSTALL_PROGRAM\ntarget_os\ntarget_vendor\ntarget_cpu\ntarget\nhost_os\nhost_vendor\nhost_cpu\nhost\nbuild_os\nbuild_vendor\nbuild_cpu\nbuild\nDIST_LANG\nMAINT\nMAINTAINER_MODE_FALSE\nMAINTAINER_MODE_TRUE\ntarget_alias\nhost_alias\nbuild_alias\nLIBS\nECHO_T\nECHO_N\nECHO_C\nDEFS\nmandir\nlocaledir\nlibdir\npsdir\npdfdir\ndvidir\nhtmldir\ninfodir\ndocdir\noldincludedir\nincludedir\nlocalstatedir\nsharedstatedir\nsysconfdir\ndatadir\ndatarootdir\nlibexecdir\nsbindir\nbindir\nprogram_transform_name\nprefix\nexec_prefix\nPACKAGE_URL\nPACKAGE_BUGREPORT\nPACKAGE_STRING\nPACKAGE_VERSION\nPACKAGE_TARNAME\nPACKAGE_NAME\nPATH_SEPARATOR\nSHELL'\nac_subst_files=''\nac_user_opts='\nenable_option_checking\nenable_maintainer_mode\nenable_silent_rules\nwith_zlib\nwith_protoc\nenable_dependency_tracking\nenable_64bit_solaris\nenable_shared\nenable_static\nwith_pic\nenable_fast_install\nwith_gnu_ld\nwith_sysroot\nenable_libtool_lock\n'\n      ac_precious_vars='build_alias\nhost_alias\ntarget_alias\nDIST_LANG\nCC\nCFLAGS\nLDFLAGS\nLIBS\nCPPFLAGS\nCXX\nCXXFLAGS\nCCC\nCXXCPP\nOBJC\nOBJCFLAGS'\nac_subdirs_all='gmock'\n\n# Initialize some variables set by options.\nac_init_help=\nac_init_version=false\nac_unrecognized_opts=\nac_unrecognized_sep=\n# The variables have the same names as the options, with\n# dashes changed to underlines.\ncache_file=/dev/null\nexec_prefix=NONE\nno_create=\nno_recursion=\nprefix=NONE\nprogram_prefix=NONE\nprogram_suffix=NONE\nprogram_transform_name=s,x,x,\nsilent=\nsite=\nsrcdir=\nverbose=\nx_includes=NONE\nx_libraries=NONE\n\n# Installation directory options.\n# These are left unexpanded so users can \"make install exec_prefix=/foo\"\n# and all the variables that are supposed to be based on exec_prefix\n# by default will actually change.\n# Use braces instead of parens because sh, perl, etc. also accept them.\n# (The list follows the same order as the GNU Coding Standards.)\nbindir='${exec_prefix}/bin'\nsbindir='${exec_prefix}/sbin'\nlibexecdir='${exec_prefix}/libexec'\ndatarootdir='${prefix}/share'\ndatadir='${datarootdir}'\nsysconfdir='${prefix}/etc'\nsharedstatedir='${prefix}/com'\nlocalstatedir='${prefix}/var'\nincludedir='${prefix}/include'\noldincludedir='/usr/include'\ndocdir='${datarootdir}/doc/${PACKAGE_TARNAME}'\ninfodir='${datarootdir}/info'\nhtmldir='${docdir}'\ndvidir='${docdir}'\npdfdir='${docdir}'\npsdir='${docdir}'\nlibdir='${exec_prefix}/lib'\nlocaledir='${datarootdir}/locale'\nmandir='${datarootdir}/man'\n\nac_prev=\nac_dashdash=\nfor ac_option\ndo\n  # If the previous option needs an argument, assign it.\n  if test -n \"$ac_prev\"; then\n    eval $ac_prev=\\$ac_option\n    ac_prev=\n    continue\n  fi\n\n  case $ac_option in\n  *=?*) ac_optarg=`expr \"X$ac_option\" : '[^=]*=\\(.*\\)'` ;;\n  *=)   ac_optarg= ;;\n  *)    ac_optarg=yes ;;\n  esac\n\n  # Accept the important Cygnus configure options, so we can diagnose typos.\n\n  case $ac_dashdash$ac_option in\n  --)\n    ac_dashdash=yes ;;\n\n  -bindir | --bindir | --bindi | --bind | --bin | --bi)\n    ac_prev=bindir ;;\n  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)\n    bindir=$ac_optarg ;;\n\n  -build | --build | --buil | --bui | --bu)\n    ac_prev=build_alias ;;\n  -build=* | --build=* | --buil=* | --bui=* | --bu=*)\n    build_alias=$ac_optarg ;;\n\n  -cache-file | --cache-file | --cache-fil | --cache-fi \\\n  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)\n    ac_prev=cache_file ;;\n  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \\\n  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)\n    cache_file=$ac_optarg ;;\n\n  --config-cache | -C)\n    cache_file=config.cache ;;\n\n  -datadir | --datadir | --datadi | --datad)\n    ac_prev=datadir ;;\n  -datadir=* | --datadir=* | --datadi=* | --datad=*)\n    datadir=$ac_optarg ;;\n\n  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \\\n  | --dataroo | --dataro | --datar)\n    ac_prev=datarootdir ;;\n  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \\\n  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)\n    datarootdir=$ac_optarg ;;\n\n  -disable-* | --disable-*)\n    ac_useropt=`expr \"x$ac_option\" : 'x-*disable-\\(.*\\)'`\n    # Reject names that are not valid shell variable names.\n    expr \"x$ac_useropt\" : \".*[^-+._$as_cr_alnum]\" >/dev/null &&\n      as_fn_error $? \"invalid feature name: $ac_useropt\"\n    ac_useropt_orig=$ac_useropt\n    ac_useropt=`$as_echo \"$ac_useropt\" | sed 's/[-+.]/_/g'`\n    case $ac_user_opts in\n      *\"\n\"enable_$ac_useropt\"\n\"*) ;;\n      *) ac_unrecognized_opts=\"$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig\"\n\t ac_unrecognized_sep=', ';;\n    esac\n    eval enable_$ac_useropt=no ;;\n\n  -docdir | --docdir | --docdi | --doc | --do)\n    ac_prev=docdir ;;\n  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)\n    docdir=$ac_optarg ;;\n\n  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)\n    ac_prev=dvidir ;;\n  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)\n    dvidir=$ac_optarg ;;\n\n  -enable-* | --enable-*)\n    ac_useropt=`expr \"x$ac_option\" : 'x-*enable-\\([^=]*\\)'`\n    # Reject names that are not valid shell variable names.\n    expr \"x$ac_useropt\" : \".*[^-+._$as_cr_alnum]\" >/dev/null &&\n      as_fn_error $? \"invalid feature name: $ac_useropt\"\n    ac_useropt_orig=$ac_useropt\n    ac_useropt=`$as_echo \"$ac_useropt\" | sed 's/[-+.]/_/g'`\n    case $ac_user_opts in\n      *\"\n\"enable_$ac_useropt\"\n\"*) ;;\n      *) ac_unrecognized_opts=\"$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig\"\n\t ac_unrecognized_sep=', ';;\n    esac\n    eval enable_$ac_useropt=\\$ac_optarg ;;\n\n  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \\\n  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \\\n  | --exec | --exe | --ex)\n    ac_prev=exec_prefix ;;\n  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \\\n  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \\\n  | --exec=* | --exe=* | --ex=*)\n    exec_prefix=$ac_optarg ;;\n\n  -gas | --gas | --ga | --g)\n    # Obsolete; use --with-gas.\n    with_gas=yes ;;\n\n  -help | --help | --hel | --he | -h)\n    ac_init_help=long ;;\n  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)\n    ac_init_help=recursive ;;\n  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)\n    ac_init_help=short ;;\n\n  -host | --host | --hos | --ho)\n    ac_prev=host_alias ;;\n  -host=* | --host=* | --hos=* | --ho=*)\n    host_alias=$ac_optarg ;;\n\n  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)\n    ac_prev=htmldir ;;\n  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \\\n  | --ht=*)\n    htmldir=$ac_optarg ;;\n\n  -includedir | --includedir | --includedi | --included | --include \\\n  | --includ | --inclu | --incl | --inc)\n    ac_prev=includedir ;;\n  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \\\n  | --includ=* | --inclu=* | --incl=* | --inc=*)\n    includedir=$ac_optarg ;;\n\n  -infodir | --infodir | --infodi | --infod | --info | --inf)\n    ac_prev=infodir ;;\n  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)\n    infodir=$ac_optarg ;;\n\n  -libdir | --libdir | --libdi | --libd)\n    ac_prev=libdir ;;\n  -libdir=* | --libdir=* | --libdi=* | --libd=*)\n    libdir=$ac_optarg ;;\n\n  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \\\n  | --libexe | --libex | --libe)\n    ac_prev=libexecdir ;;\n  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \\\n  | --libexe=* | --libex=* | --libe=*)\n    libexecdir=$ac_optarg ;;\n\n  -localedir | --localedir | --localedi | --localed | --locale)\n    ac_prev=localedir ;;\n  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)\n    localedir=$ac_optarg ;;\n\n  -localstatedir | --localstatedir | --localstatedi | --localstated \\\n  | --localstate | --localstat | --localsta | --localst | --locals)\n    ac_prev=localstatedir ;;\n  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \\\n  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)\n    localstatedir=$ac_optarg ;;\n\n  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)\n    ac_prev=mandir ;;\n  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)\n    mandir=$ac_optarg ;;\n\n  -nfp | --nfp | --nf)\n    # Obsolete; use --without-fp.\n    with_fp=no ;;\n\n  -no-create | --no-create | --no-creat | --no-crea | --no-cre \\\n  | --no-cr | --no-c | -n)\n    no_create=yes ;;\n\n  -no-recursion | --no-recursion | --no-recursio | --no-recursi \\\n  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)\n    no_recursion=yes ;;\n\n  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \\\n  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \\\n  | --oldin | --oldi | --old | --ol | --o)\n    ac_prev=oldincludedir ;;\n  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \\\n  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \\\n  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)\n    oldincludedir=$ac_optarg ;;\n\n  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)\n    ac_prev=prefix ;;\n  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)\n    prefix=$ac_optarg ;;\n\n  -program-prefix | --program-prefix | --program-prefi | --program-pref \\\n  | --program-pre | --program-pr | --program-p)\n    ac_prev=program_prefix ;;\n  -program-prefix=* | --program-prefix=* | --program-prefi=* \\\n  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)\n    program_prefix=$ac_optarg ;;\n\n  -program-suffix | --program-suffix | --program-suffi | --program-suff \\\n  | --program-suf | --program-su | --program-s)\n    ac_prev=program_suffix ;;\n  -program-suffix=* | --program-suffix=* | --program-suffi=* \\\n  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)\n    program_suffix=$ac_optarg ;;\n\n  -program-transform-name | --program-transform-name \\\n  | --program-transform-nam | --program-transform-na \\\n  | --program-transform-n | --program-transform- \\\n  | --program-transform | --program-transfor \\\n  | --program-transfo | --program-transf \\\n  | --program-trans | --program-tran \\\n  | --progr-tra | --program-tr | --program-t)\n    ac_prev=program_transform_name ;;\n  -program-transform-name=* | --program-transform-name=* \\\n  | --program-transform-nam=* | --program-transform-na=* \\\n  | --program-transform-n=* | --program-transform-=* \\\n  | --program-transform=* | --program-transfor=* \\\n  | --program-transfo=* | --program-transf=* \\\n  | --program-trans=* | --program-tran=* \\\n  | --progr-tra=* | --program-tr=* | --program-t=*)\n    program_transform_name=$ac_optarg ;;\n\n  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)\n    ac_prev=pdfdir ;;\n  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)\n    pdfdir=$ac_optarg ;;\n\n  -psdir | --psdir | --psdi | --psd | --ps)\n    ac_prev=psdir ;;\n  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)\n    psdir=$ac_optarg ;;\n\n  -q | -quiet | --quiet | --quie | --qui | --qu | --q \\\n  | -silent | --silent | --silen | --sile | --sil)\n    silent=yes ;;\n\n  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)\n    ac_prev=sbindir ;;\n  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \\\n  | --sbi=* | --sb=*)\n    sbindir=$ac_optarg ;;\n\n  -sharedstatedir | --sharedstatedir | --sharedstatedi \\\n  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \\\n  | --sharedst | --shareds | --shared | --share | --shar \\\n  | --sha | --sh)\n    ac_prev=sharedstatedir ;;\n  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \\\n  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \\\n  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \\\n  | --sha=* | --sh=*)\n    sharedstatedir=$ac_optarg ;;\n\n  -site | --site | --sit)\n    ac_prev=site ;;\n  -site=* | --site=* | --sit=*)\n    site=$ac_optarg ;;\n\n  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)\n    ac_prev=srcdir ;;\n  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)\n    srcdir=$ac_optarg ;;\n\n  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \\\n  | --syscon | --sysco | --sysc | --sys | --sy)\n    ac_prev=sysconfdir ;;\n  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \\\n  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)\n    sysconfdir=$ac_optarg ;;\n\n  -target | --target | --targe | --targ | --tar | --ta | --t)\n    ac_prev=target_alias ;;\n  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)\n    target_alias=$ac_optarg ;;\n\n  -v | -verbose | --verbose | --verbos | --verbo | --verb)\n    verbose=yes ;;\n\n  -version | --version | --versio | --versi | --vers | -V)\n    ac_init_version=: ;;\n\n  -with-* | --with-*)\n    ac_useropt=`expr \"x$ac_option\" : 'x-*with-\\([^=]*\\)'`\n    # Reject names that are not valid shell variable names.\n    expr \"x$ac_useropt\" : \".*[^-+._$as_cr_alnum]\" >/dev/null &&\n      as_fn_error $? \"invalid package name: $ac_useropt\"\n    ac_useropt_orig=$ac_useropt\n    ac_useropt=`$as_echo \"$ac_useropt\" | sed 's/[-+.]/_/g'`\n    case $ac_user_opts in\n      *\"\n\"with_$ac_useropt\"\n\"*) ;;\n      *) ac_unrecognized_opts=\"$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig\"\n\t ac_unrecognized_sep=', ';;\n    esac\n    eval with_$ac_useropt=\\$ac_optarg ;;\n\n  -without-* | --without-*)\n    ac_useropt=`expr \"x$ac_option\" : 'x-*without-\\(.*\\)'`\n    # Reject names that are not valid shell variable names.\n    expr \"x$ac_useropt\" : \".*[^-+._$as_cr_alnum]\" >/dev/null &&\n      as_fn_error $? \"invalid package name: $ac_useropt\"\n    ac_useropt_orig=$ac_useropt\n    ac_useropt=`$as_echo \"$ac_useropt\" | sed 's/[-+.]/_/g'`\n    case $ac_user_opts in\n      *\"\n\"with_$ac_useropt\"\n\"*) ;;\n      *) ac_unrecognized_opts=\"$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig\"\n\t ac_unrecognized_sep=', ';;\n    esac\n    eval with_$ac_useropt=no ;;\n\n  --x)\n    # Obsolete; use --with-x.\n    with_x=yes ;;\n\n  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \\\n  | --x-incl | --x-inc | --x-in | --x-i)\n    ac_prev=x_includes ;;\n  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \\\n  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)\n    x_includes=$ac_optarg ;;\n\n  -x-libraries | --x-libraries | --x-librarie | --x-librari \\\n  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)\n    ac_prev=x_libraries ;;\n  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \\\n  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)\n    x_libraries=$ac_optarg ;;\n\n  -*) as_fn_error $? \"unrecognized option: \\`$ac_option'\nTry \\`$0 --help' for more information\"\n    ;;\n\n  *=*)\n    ac_envvar=`expr \"x$ac_option\" : 'x\\([^=]*\\)='`\n    # Reject names that are not valid shell variable names.\n    case $ac_envvar in #(\n      '' | [0-9]* | *[!_$as_cr_alnum]* )\n      as_fn_error $? \"invalid variable name: \\`$ac_envvar'\" ;;\n    esac\n    eval $ac_envvar=\\$ac_optarg\n    export $ac_envvar ;;\n\n  *)\n    # FIXME: should be removed in autoconf 3.0.\n    $as_echo \"$as_me: WARNING: you should use --build, --host, --target\" >&2\n    expr \"x$ac_option\" : \".*[^-._$as_cr_alnum]\" >/dev/null &&\n      $as_echo \"$as_me: WARNING: invalid host type: $ac_option\" >&2\n    : \"${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}\"\n    ;;\n\n  esac\ndone\n\nif test -n \"$ac_prev\"; then\n  ac_option=--`echo $ac_prev | sed 's/_/-/g'`\n  as_fn_error $? \"missing argument to $ac_option\"\nfi\n\nif test -n \"$ac_unrecognized_opts\"; then\n  case $enable_option_checking in\n    no) ;;\n    fatal) as_fn_error $? \"unrecognized options: $ac_unrecognized_opts\" ;;\n    *)     $as_echo \"$as_me: WARNING: unrecognized options: $ac_unrecognized_opts\" >&2 ;;\n  esac\nfi\n\n# Check all directory arguments for consistency.\nfor ac_var in\texec_prefix prefix bindir sbindir libexecdir datarootdir \\\n\t\tdatadir sysconfdir sharedstatedir localstatedir includedir \\\n\t\toldincludedir docdir infodir htmldir dvidir pdfdir psdir \\\n\t\tlibdir localedir mandir\ndo\n  eval ac_val=\\$$ac_var\n  # Remove trailing slashes.\n  case $ac_val in\n    */ )\n      ac_val=`expr \"X$ac_val\" : 'X\\(.*[^/]\\)' \\| \"X$ac_val\" : 'X\\(.*\\)'`\n      eval $ac_var=\\$ac_val;;\n  esac\n  # Be sure to have absolute directory names.\n  case $ac_val in\n    [\\\\/$]* | ?:[\\\\/]* )  continue;;\n    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;\n  esac\n  as_fn_error $? \"expected an absolute directory name for --$ac_var: $ac_val\"\ndone\n\n# There might be people who depend on the old broken behavior: `$host'\n# used to hold the argument of --host etc.\n# FIXME: To remove some day.\nbuild=$build_alias\nhost=$host_alias\ntarget=$target_alias\n\n# FIXME: To remove some day.\nif test \"x$host_alias\" != x; then\n  if test \"x$build_alias\" = x; then\n    cross_compiling=maybe\n  elif test \"x$build_alias\" != \"x$host_alias\"; then\n    cross_compiling=yes\n  fi\nfi\n\nac_tool_prefix=\ntest -n \"$host_alias\" && ac_tool_prefix=$host_alias-\n\ntest \"$silent\" = yes && exec 6>/dev/null\n\n\nac_pwd=`pwd` && test -n \"$ac_pwd\" &&\nac_ls_di=`ls -di .` &&\nac_pwd_ls_di=`cd \"$ac_pwd\" && ls -di .` ||\n  as_fn_error $? \"working directory cannot be determined\"\ntest \"X$ac_ls_di\" = \"X$ac_pwd_ls_di\" ||\n  as_fn_error $? \"pwd does not report name of working directory\"\n\n\n# Find the source files, if location was not specified.\nif test -z \"$srcdir\"; then\n  ac_srcdir_defaulted=yes\n  # Try the directory containing this script, then the parent directory.\n  ac_confdir=`$as_dirname -- \"$as_myself\" ||\n$as_expr X\"$as_myself\" : 'X\\(.*[^/]\\)//*[^/][^/]*/*$' \\| \\\n\t X\"$as_myself\" : 'X\\(//\\)[^/]' \\| \\\n\t X\"$as_myself\" : 'X\\(//\\)$' \\| \\\n\t X\"$as_myself\" : 'X\\(/\\)' \\| . 2>/dev/null ||\n$as_echo X\"$as_myself\" |\n    sed '/^X\\(.*[^/]\\)\\/\\/*[^/][^/]*\\/*$/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\(\\/\\/\\)[^/].*/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\(\\/\\/\\)$/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\(\\/\\).*/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  s/.*/./; q'`\n  srcdir=$ac_confdir\n  if test ! -r \"$srcdir/$ac_unique_file\"; then\n    srcdir=..\n  fi\nelse\n  ac_srcdir_defaulted=no\nfi\nif test ! -r \"$srcdir/$ac_unique_file\"; then\n  test \"$ac_srcdir_defaulted\" = yes && srcdir=\"$ac_confdir or ..\"\n  as_fn_error $? \"cannot find sources ($ac_unique_file) in $srcdir\"\nfi\nac_msg=\"sources are in $srcdir, but \\`cd $srcdir' does not work\"\nac_abs_confdir=`(\n\tcd \"$srcdir\" && test -r \"./$ac_unique_file\" || as_fn_error $? \"$ac_msg\"\n\tpwd)`\n# When building in place, set srcdir=.\nif test \"$ac_abs_confdir\" = \"$ac_pwd\"; then\n  srcdir=.\nfi\n# Remove unnecessary trailing slashes from srcdir.\n# Double slashes in file names in object file debugging info\n# mess up M-x gdb in Emacs.\ncase $srcdir in\n*/) srcdir=`expr \"X$srcdir\" : 'X\\(.*[^/]\\)' \\| \"X$srcdir\" : 'X\\(.*\\)'`;;\nesac\nfor ac_var in $ac_precious_vars; do\n  eval ac_env_${ac_var}_set=\\${${ac_var}+set}\n  eval ac_env_${ac_var}_value=\\$${ac_var}\n  eval ac_cv_env_${ac_var}_set=\\${${ac_var}+set}\n  eval ac_cv_env_${ac_var}_value=\\$${ac_var}\ndone\n\n#\n# Report the --help message.\n#\nif test \"$ac_init_help\" = \"long\"; then\n  # Omit some internal or obsolete options to make the list less imposing.\n  # This message is too long to be a string in the A/UX 3.1 sh.\n  cat <<_ACEOF\n\\`configure' configures Protocol Buffers 3.0.0 to adapt to many kinds of systems.\n\nUsage: $0 [OPTION]... [VAR=VALUE]...\n\nTo assign environment variables (e.g., CC, CFLAGS...), specify them as\nVAR=VALUE.  See below for descriptions of some of the useful variables.\n\nDefaults for the options are specified in brackets.\n\nConfiguration:\n  -h, --help              display this help and exit\n      --help=short        display options specific to this package\n      --help=recursive    display the short help of all the included packages\n  -V, --version           display version information and exit\n  -q, --quiet, --silent   do not print \\`checking ...' messages\n      --cache-file=FILE   cache test results in FILE [disabled]\n  -C, --config-cache      alias for \\`--cache-file=config.cache'\n  -n, --no-create         do not create output files\n      --srcdir=DIR        find the sources in DIR [configure dir or \\`..']\n\nInstallation directories:\n  --prefix=PREFIX         install architecture-independent files in PREFIX\n                          [$ac_default_prefix]\n  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX\n                          [PREFIX]\n\nBy default, \\`make install' will install all the files in\n\\`$ac_default_prefix/bin', \\`$ac_default_prefix/lib' etc.  You can specify\nan installation prefix other than \\`$ac_default_prefix' using \\`--prefix',\nfor instance \\`--prefix=\\$HOME'.\n\nFor better control, use the options below.\n\nFine tuning of the installation directories:\n  --bindir=DIR            user executables [EPREFIX/bin]\n  --sbindir=DIR           system admin executables [EPREFIX/sbin]\n  --libexecdir=DIR        program executables [EPREFIX/libexec]\n  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]\n  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]\n  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]\n  --libdir=DIR            object code libraries [EPREFIX/lib]\n  --includedir=DIR        C header files [PREFIX/include]\n  --oldincludedir=DIR     C header files for non-gcc [/usr/include]\n  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]\n  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]\n  --infodir=DIR           info documentation [DATAROOTDIR/info]\n  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]\n  --mandir=DIR            man documentation [DATAROOTDIR/man]\n  --docdir=DIR            documentation root [DATAROOTDIR/doc/protobuf]\n  --htmldir=DIR           html documentation [DOCDIR]\n  --dvidir=DIR            dvi documentation [DOCDIR]\n  --pdfdir=DIR            pdf documentation [DOCDIR]\n  --psdir=DIR             ps documentation [DOCDIR]\n_ACEOF\n\n  cat <<\\_ACEOF\n\nProgram names:\n  --program-prefix=PREFIX            prepend PREFIX to installed program names\n  --program-suffix=SUFFIX            append SUFFIX to installed program names\n  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names\n\nSystem types:\n  --build=BUILD     configure for building on BUILD [guessed]\n  --host=HOST       cross-compile to build programs to run on HOST [BUILD]\n  --target=TARGET   configure for building compilers for TARGET [HOST]\n_ACEOF\nfi\n\nif test -n \"$ac_init_help\"; then\n  case $ac_init_help in\n     short | recursive ) echo \"Configuration of Protocol Buffers 3.0.0:\";;\n   esac\n  cat <<\\_ACEOF\n\nOptional Features:\n  --disable-option-checking  ignore unrecognized --enable/--with options\n  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)\n  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]\n  --disable-maintainer-mode\n                          disable make rules and dependencies not useful (and\n                          sometimes confusing) to the casual installer\n  --enable-silent-rules   less verbose build output (undo: \"make V=1\")\n  --disable-silent-rules  verbose build output (undo: \"make V=0\")\n  --enable-dependency-tracking\n                          do not reject slow dependency extractors\n  --disable-dependency-tracking\n                          speeds up one-time build\n  --disable-64bit-solaris Build 64 bit binary on Solaris [default=on]\n  --enable-shared[=PKGS]  build shared libraries [default=yes]\n  --enable-static[=PKGS]  build static libraries [default=yes]\n  --enable-fast-install[=PKGS]\n                          optimize for fast installation [default=yes]\n  --disable-libtool-lock  avoid locking (might break parallel builds)\n\nOptional Packages:\n  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]\n  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)\n  --with-zlib             include classes for streaming compressed data in and\n                          out [default=check]\n  --with-protoc=COMMAND   use the given protoc command instead of building a\n                          new one when building tests (useful for\n                          cross-compiling)\n  --with-pic[=PKGS]       try to use only PIC/non-PIC objects [default=use\n                          both]\n  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]\n  --with-sysroot=DIR Search for dependent libraries within DIR\n                        (or the compiler's sysroot if not specified).\n\nSome influential environment variables:\n  DIST_LANG   language to include in the distribution package (i.e., make\n              dist)\n  CC          C compiler command\n  CFLAGS      C compiler flags\n  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a\n              nonstandard directory <lib dir>\n  LIBS        libraries to pass to the linker, e.g. -l<library>\n  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if\n              you have headers in a nonstandard directory <include dir>\n  CXX         C++ compiler command\n  CXXFLAGS    C++ compiler flags\n  CXXCPP      C++ preprocessor\n  OBJC        Objective C compiler command\n  OBJCFLAGS   Objective C compiler flags\n\nUse these variables to override the choices made by `configure' or to help\nit to find libraries and programs with nonstandard names/locations.\n\nReport bugs to <protobuf@googlegroups.com>.\n_ACEOF\nac_status=$?\nfi\n\nif test \"$ac_init_help\" = \"recursive\"; then\n  # If there are subdirs, report their specific --help.\n  for ac_dir in : $ac_subdirs_all; do test \"x$ac_dir\" = x: && continue\n    test -d \"$ac_dir\" ||\n      { cd \"$srcdir\" && ac_pwd=`pwd` && srcdir=. && test -d \"$ac_dir\"; } ||\n      continue\n    ac_builddir=.\n\ncase \"$ac_dir\" in\n.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;\n*)\n  ac_dir_suffix=/`$as_echo \"$ac_dir\" | sed 's|^\\.[\\\\/]||'`\n  # A \"..\" for each directory in $ac_dir_suffix.\n  ac_top_builddir_sub=`$as_echo \"$ac_dir_suffix\" | sed 's|/[^\\\\/]*|/..|g;s|/||'`\n  case $ac_top_builddir_sub in\n  \"\") ac_top_builddir_sub=. ac_top_build_prefix= ;;\n  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;\n  esac ;;\nesac\nac_abs_top_builddir=$ac_pwd\nac_abs_builddir=$ac_pwd$ac_dir_suffix\n# for backward compatibility:\nac_top_builddir=$ac_top_build_prefix\n\ncase $srcdir in\n  .)  # We are building in place.\n    ac_srcdir=.\n    ac_top_srcdir=$ac_top_builddir_sub\n    ac_abs_top_srcdir=$ac_pwd ;;\n  [\\\\/]* | ?:[\\\\/]* )  # Absolute name.\n    ac_srcdir=$srcdir$ac_dir_suffix;\n    ac_top_srcdir=$srcdir\n    ac_abs_top_srcdir=$srcdir ;;\n  *) # Relative name.\n    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix\n    ac_top_srcdir=$ac_top_build_prefix$srcdir\n    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;\nesac\nac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix\n\n    cd \"$ac_dir\" || { ac_status=$?; continue; }\n    # Check for guested configure.\n    if test -f \"$ac_srcdir/configure.gnu\"; then\n      echo &&\n      $SHELL \"$ac_srcdir/configure.gnu\" --help=recursive\n    elif test -f \"$ac_srcdir/configure\"; then\n      echo &&\n      $SHELL \"$ac_srcdir/configure\" --help=recursive\n    else\n      $as_echo \"$as_me: WARNING: no configuration information is in $ac_dir\" >&2\n    fi || ac_status=$?\n    cd \"$ac_pwd\" || { ac_status=$?; break; }\n  done\nfi\n\ntest -n \"$ac_init_help\" && exit $ac_status\nif $ac_init_version; then\n  cat <<\\_ACEOF\nProtocol Buffers configure 3.0.0\ngenerated by GNU Autoconf 2.69\n\nCopyright (C) 2012 Free Software Foundation, Inc.\nThis configure script is free software; the Free Software Foundation\ngives unlimited permission to copy, distribute and modify it.\n_ACEOF\n  exit\nfi\n\n## ------------------------ ##\n## Autoconf initialization. ##\n## ------------------------ ##\n\n# ac_fn_c_try_compile LINENO\n# --------------------------\n# Try to compile conftest.$ac_ext, and return whether this succeeded.\nac_fn_c_try_compile ()\n{\n  as_lineno=${as_lineno-\"$1\"} as_lineno_stack=as_lineno_stack=$as_lineno_stack\n  rm -f conftest.$ac_objext\n  if { { ac_try=\"$ac_compile\"\ncase \"(($ac_try\" in\n  *\\\"* | *\\`* | *\\\\*) ac_try_echo=\\$ac_try;;\n  *) ac_try_echo=$ac_try;;\nesac\neval ac_try_echo=\"\\\"\\$as_me:${as_lineno-$LINENO}: $ac_try_echo\\\"\"\n$as_echo \"$ac_try_echo\"; } >&5\n  (eval \"$ac_compile\") 2>conftest.err\n  ac_status=$?\n  if test -s conftest.err; then\n    grep -v '^ *+' conftest.err >conftest.er1\n    cat conftest.er1 >&5\n    mv -f conftest.er1 conftest.err\n  fi\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; } && {\n\t test -z \"$ac_c_werror_flag\" ||\n\t test ! -s conftest.err\n       } && test -s conftest.$ac_objext; then :\n  ac_retval=0\nelse\n  $as_echo \"$as_me: failed program was:\" >&5\nsed 's/^/| /' conftest.$ac_ext >&5\n\n\tac_retval=1\nfi\n  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno\n  as_fn_set_status $ac_retval\n\n} # ac_fn_c_try_compile\n\n# ac_fn_cxx_try_compile LINENO\n# ----------------------------\n# Try to compile conftest.$ac_ext, and return whether this succeeded.\nac_fn_cxx_try_compile ()\n{\n  as_lineno=${as_lineno-\"$1\"} as_lineno_stack=as_lineno_stack=$as_lineno_stack\n  rm -f conftest.$ac_objext\n  if { { ac_try=\"$ac_compile\"\ncase \"(($ac_try\" in\n  *\\\"* | *\\`* | *\\\\*) ac_try_echo=\\$ac_try;;\n  *) ac_try_echo=$ac_try;;\nesac\neval ac_try_echo=\"\\\"\\$as_me:${as_lineno-$LINENO}: $ac_try_echo\\\"\"\n$as_echo \"$ac_try_echo\"; } >&5\n  (eval \"$ac_compile\") 2>conftest.err\n  ac_status=$?\n  if test -s conftest.err; then\n    grep -v '^ *+' conftest.err >conftest.er1\n    cat conftest.er1 >&5\n    mv -f conftest.er1 conftest.err\n  fi\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; } && {\n\t test -z \"$ac_cxx_werror_flag\" ||\n\t test ! -s conftest.err\n       } && test -s conftest.$ac_objext; then :\n  ac_retval=0\nelse\n  $as_echo \"$as_me: failed program was:\" >&5\nsed 's/^/| /' conftest.$ac_ext >&5\n\n\tac_retval=1\nfi\n  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno\n  as_fn_set_status $ac_retval\n\n} # ac_fn_cxx_try_compile\n\n# ac_fn_cxx_try_cpp LINENO\n# ------------------------\n# Try to preprocess conftest.$ac_ext, and return whether this succeeded.\nac_fn_cxx_try_cpp ()\n{\n  as_lineno=${as_lineno-\"$1\"} as_lineno_stack=as_lineno_stack=$as_lineno_stack\n  if { { ac_try=\"$ac_cpp conftest.$ac_ext\"\ncase \"(($ac_try\" in\n  *\\\"* | *\\`* | *\\\\*) ac_try_echo=\\$ac_try;;\n  *) ac_try_echo=$ac_try;;\nesac\neval ac_try_echo=\"\\\"\\$as_me:${as_lineno-$LINENO}: $ac_try_echo\\\"\"\n$as_echo \"$ac_try_echo\"; } >&5\n  (eval \"$ac_cpp conftest.$ac_ext\") 2>conftest.err\n  ac_status=$?\n  if test -s conftest.err; then\n    grep -v '^ *+' conftest.err >conftest.er1\n    cat conftest.er1 >&5\n    mv -f conftest.er1 conftest.err\n  fi\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; } > conftest.i && {\n\t test -z \"$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag\" ||\n\t test ! -s conftest.err\n       }; then :\n  ac_retval=0\nelse\n  $as_echo \"$as_me: failed program was:\" >&5\nsed 's/^/| /' conftest.$ac_ext >&5\n\n    ac_retval=1\nfi\n  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno\n  as_fn_set_status $ac_retval\n\n} # ac_fn_cxx_try_cpp\n\n# ac_fn_cxx_check_header_mongrel LINENO HEADER VAR INCLUDES\n# ---------------------------------------------------------\n# Tests whether HEADER exists, giving a warning if it cannot be compiled using\n# the include files in INCLUDES and setting the cache variable VAR\n# accordingly.\nac_fn_cxx_check_header_mongrel ()\n{\n  as_lineno=${as_lineno-\"$1\"} as_lineno_stack=as_lineno_stack=$as_lineno_stack\n  if eval \\${$3+:} false; then :\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $2\" >&5\n$as_echo_n \"checking for $2... \" >&6; }\nif eval \\${$3+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nfi\neval ac_res=\\$$3\n\t       { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_res\" >&5\n$as_echo \"$ac_res\" >&6; }\nelse\n  # Is the header compilable?\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking $2 usability\" >&5\n$as_echo_n \"checking $2 usability... \" >&6; }\ncat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n$4\n#include <$2>\n_ACEOF\nif ac_fn_cxx_try_compile \"$LINENO\"; then :\n  ac_header_compiler=yes\nelse\n  ac_header_compiler=no\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler\" >&5\n$as_echo \"$ac_header_compiler\" >&6; }\n\n# Is the header present?\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking $2 presence\" >&5\n$as_echo_n \"checking $2 presence... \" >&6; }\ncat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <$2>\n_ACEOF\nif ac_fn_cxx_try_cpp \"$LINENO\"; then :\n  ac_header_preproc=yes\nelse\n  ac_header_preproc=no\nfi\nrm -f conftest.err conftest.i conftest.$ac_ext\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc\" >&5\n$as_echo \"$ac_header_preproc\" >&6; }\n\n# So?  What about this header?\ncase $ac_header_compiler:$ac_header_preproc:$ac_cxx_preproc_warn_flag in #((\n  yes:no: )\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!\" >&5\n$as_echo \"$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!\" >&2;}\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result\" >&5\n$as_echo \"$as_me: WARNING: $2: proceeding with the compiler's result\" >&2;}\n    ;;\n  no:yes:* )\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled\" >&5\n$as_echo \"$as_me: WARNING: $2: present but cannot be compiled\" >&2;}\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?\" >&5\n$as_echo \"$as_me: WARNING: $2:     check for missing prerequisite headers?\" >&2;}\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation\" >&5\n$as_echo \"$as_me: WARNING: $2: see the Autoconf documentation\" >&2;}\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \\\"Present But Cannot Be Compiled\\\"\" >&5\n$as_echo \"$as_me: WARNING: $2:     section \\\"Present But Cannot Be Compiled\\\"\" >&2;}\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result\" >&5\n$as_echo \"$as_me: WARNING: $2: proceeding with the compiler's result\" >&2;}\n( $as_echo \"## ---------------------------------------- ##\n## Report this to protobuf@googlegroups.com ##\n## ---------------------------------------- ##\"\n     ) | sed \"s/^/$as_me: WARNING:     /\" >&2\n    ;;\nesac\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $2\" >&5\n$as_echo_n \"checking for $2... \" >&6; }\nif eval \\${$3+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  eval \"$3=\\$ac_header_compiler\"\nfi\neval ac_res=\\$$3\n\t       { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_res\" >&5\n$as_echo \"$ac_res\" >&6; }\nfi\n  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno\n\n} # ac_fn_cxx_check_header_mongrel\n\n# ac_fn_cxx_try_run LINENO\n# ------------------------\n# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes\n# that executables *can* be run.\nac_fn_cxx_try_run ()\n{\n  as_lineno=${as_lineno-\"$1\"} as_lineno_stack=as_lineno_stack=$as_lineno_stack\n  if { { ac_try=\"$ac_link\"\ncase \"(($ac_try\" in\n  *\\\"* | *\\`* | *\\\\*) ac_try_echo=\\$ac_try;;\n  *) ac_try_echo=$ac_try;;\nesac\neval ac_try_echo=\"\\\"\\$as_me:${as_lineno-$LINENO}: $ac_try_echo\\\"\"\n$as_echo \"$ac_try_echo\"; } >&5\n  (eval \"$ac_link\") 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'\n  { { case \"(($ac_try\" in\n  *\\\"* | *\\`* | *\\\\*) ac_try_echo=\\$ac_try;;\n  *) ac_try_echo=$ac_try;;\nesac\neval ac_try_echo=\"\\\"\\$as_me:${as_lineno-$LINENO}: $ac_try_echo\\\"\"\n$as_echo \"$ac_try_echo\"; } >&5\n  (eval \"$ac_try\") 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; }; }; then :\n  ac_retval=0\nelse\n  $as_echo \"$as_me: program exited with status $ac_status\" >&5\n       $as_echo \"$as_me: failed program was:\" >&5\nsed 's/^/| /' conftest.$ac_ext >&5\n\n       ac_retval=$ac_status\nfi\n  rm -rf conftest.dSYM conftest_ipa8_conftest.oo\n  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno\n  as_fn_set_status $ac_retval\n\n} # ac_fn_cxx_try_run\n\n# ac_fn_cxx_check_header_compile LINENO HEADER VAR INCLUDES\n# ---------------------------------------------------------\n# Tests whether HEADER exists and can be compiled using the include files in\n# INCLUDES, setting the cache variable VAR accordingly.\nac_fn_cxx_check_header_compile ()\n{\n  as_lineno=${as_lineno-\"$1\"} as_lineno_stack=as_lineno_stack=$as_lineno_stack\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $2\" >&5\n$as_echo_n \"checking for $2... \" >&6; }\nif eval \\${$3+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n$4\n#include <$2>\n_ACEOF\nif ac_fn_cxx_try_compile \"$LINENO\"; then :\n  eval \"$3=yes\"\nelse\n  eval \"$3=no\"\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\nfi\neval ac_res=\\$$3\n\t       { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_res\" >&5\n$as_echo \"$ac_res\" >&6; }\n  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno\n\n} # ac_fn_cxx_check_header_compile\n\n# ac_fn_objc_try_compile LINENO\n# -----------------------------\n# Try to compile conftest.$ac_ext, and return whether this succeeded.\nac_fn_objc_try_compile ()\n{\n  as_lineno=${as_lineno-\"$1\"} as_lineno_stack=as_lineno_stack=$as_lineno_stack\n  rm -f conftest.$ac_objext\n  if { { ac_try=\"$ac_compile\"\ncase \"(($ac_try\" in\n  *\\\"* | *\\`* | *\\\\*) ac_try_echo=\\$ac_try;;\n  *) ac_try_echo=$ac_try;;\nesac\neval ac_try_echo=\"\\\"\\$as_me:${as_lineno-$LINENO}: $ac_try_echo\\\"\"\n$as_echo \"$ac_try_echo\"; } >&5\n  (eval \"$ac_compile\") 2>conftest.err\n  ac_status=$?\n  if test -s conftest.err; then\n    grep -v '^ *+' conftest.err >conftest.er1\n    cat conftest.er1 >&5\n    mv -f conftest.er1 conftest.err\n  fi\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; } && {\n\t test -z \"$ac_objc_werror_flag\" ||\n\t test ! -s conftest.err\n       } && test -s conftest.$ac_objext; then :\n  ac_retval=0\nelse\n  $as_echo \"$as_me: failed program was:\" >&5\nsed 's/^/| /' conftest.$ac_ext >&5\n\n\tac_retval=1\nfi\n  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno\n  as_fn_set_status $ac_retval\n\n} # ac_fn_objc_try_compile\n\n# ac_fn_cxx_check_decl LINENO SYMBOL VAR INCLUDES\n# -----------------------------------------------\n# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR\n# accordingly.\nac_fn_cxx_check_decl ()\n{\n  as_lineno=${as_lineno-\"$1\"} as_lineno_stack=as_lineno_stack=$as_lineno_stack\n  as_decl_name=`echo $2|sed 's/ *(.*//'`\n  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared\" >&5\n$as_echo_n \"checking whether $as_decl_name is declared... \" >&6; }\nif eval \\${$3+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n$4\nint\nmain ()\n{\n#ifndef $as_decl_name\n#ifdef __cplusplus\n  (void) $as_decl_use;\n#else\n  (void) $as_decl_name;\n#endif\n#endif\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_cxx_try_compile \"$LINENO\"; then :\n  eval \"$3=yes\"\nelse\n  eval \"$3=no\"\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\nfi\neval ac_res=\\$$3\n\t       { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_res\" >&5\n$as_echo \"$ac_res\" >&6; }\n  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno\n\n} # ac_fn_cxx_check_decl\n\n# ac_fn_c_try_link LINENO\n# -----------------------\n# Try to link conftest.$ac_ext, and return whether this succeeded.\nac_fn_c_try_link ()\n{\n  as_lineno=${as_lineno-\"$1\"} as_lineno_stack=as_lineno_stack=$as_lineno_stack\n  rm -f conftest.$ac_objext conftest$ac_exeext\n  if { { ac_try=\"$ac_link\"\ncase \"(($ac_try\" in\n  *\\\"* | *\\`* | *\\\\*) ac_try_echo=\\$ac_try;;\n  *) ac_try_echo=$ac_try;;\nesac\neval ac_try_echo=\"\\\"\\$as_me:${as_lineno-$LINENO}: $ac_try_echo\\\"\"\n$as_echo \"$ac_try_echo\"; } >&5\n  (eval \"$ac_link\") 2>conftest.err\n  ac_status=$?\n  if test -s conftest.err; then\n    grep -v '^ *+' conftest.err >conftest.er1\n    cat conftest.er1 >&5\n    mv -f conftest.er1 conftest.err\n  fi\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; } && {\n\t test -z \"$ac_c_werror_flag\" ||\n\t test ! -s conftest.err\n       } && test -s conftest$ac_exeext && {\n\t test \"$cross_compiling\" = yes ||\n\t test -x conftest$ac_exeext\n       }; then :\n  ac_retval=0\nelse\n  $as_echo \"$as_me: failed program was:\" >&5\nsed 's/^/| /' conftest.$ac_ext >&5\n\n\tac_retval=1\nfi\n  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information\n  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would\n  # interfere with the next link command; also delete a directory that is\n  # left behind by Apple's compiler.  We do this before executing the actions.\n  rm -rf conftest.dSYM conftest_ipa8_conftest.oo\n  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno\n  as_fn_set_status $ac_retval\n\n} # ac_fn_c_try_link\n\n# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES\n# -------------------------------------------------------\n# Tests whether HEADER exists and can be compiled using the include files in\n# INCLUDES, setting the cache variable VAR accordingly.\nac_fn_c_check_header_compile ()\n{\n  as_lineno=${as_lineno-\"$1\"} as_lineno_stack=as_lineno_stack=$as_lineno_stack\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $2\" >&5\n$as_echo_n \"checking for $2... \" >&6; }\nif eval \\${$3+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n$4\n#include <$2>\n_ACEOF\nif ac_fn_c_try_compile \"$LINENO\"; then :\n  eval \"$3=yes\"\nelse\n  eval \"$3=no\"\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\nfi\neval ac_res=\\$$3\n\t       { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_res\" >&5\n$as_echo \"$ac_res\" >&6; }\n  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno\n\n} # ac_fn_c_check_header_compile\n\n# ac_fn_c_check_func LINENO FUNC VAR\n# ----------------------------------\n# Tests whether FUNC exists, setting the cache variable VAR accordingly\nac_fn_c_check_func ()\n{\n  as_lineno=${as_lineno-\"$1\"} as_lineno_stack=as_lineno_stack=$as_lineno_stack\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $2\" >&5\n$as_echo_n \"checking for $2... \" >&6; }\nif eval \\${$3+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n/* Define $2 to an innocuous variant, in case <limits.h> declares $2.\n   For example, HP-UX 11i <limits.h> declares gettimeofday.  */\n#define $2 innocuous_$2\n\n/* System header to define __stub macros and hopefully few prototypes,\n    which can conflict with char $2 (); below.\n    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since\n    <limits.h> exists even on freestanding compilers.  */\n\n#ifdef __STDC__\n# include <limits.h>\n#else\n# include <assert.h>\n#endif\n\n#undef $2\n\n/* Override any GCC internal prototype to avoid an error.\n   Use char because int might match the return type of a GCC\n   builtin and then its argument prototype would still apply.  */\n#ifdef __cplusplus\nextern \"C\"\n#endif\nchar $2 ();\n/* The GNU C library defines this for functions which it implements\n    to always fail with ENOSYS.  Some functions are actually named\n    something starting with __ and the normal name is an alias.  */\n#if defined __stub_$2 || defined __stub___$2\nchoke me\n#endif\n\nint\nmain ()\n{\nreturn $2 ();\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_link \"$LINENO\"; then :\n  eval \"$3=yes\"\nelse\n  eval \"$3=no\"\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\nfi\neval ac_res=\\$$3\n\t       { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_res\" >&5\n$as_echo \"$ac_res\" >&6; }\n  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno\n\n} # ac_fn_c_check_func\n\n# ac_fn_cxx_try_link LINENO\n# -------------------------\n# Try to link conftest.$ac_ext, and return whether this succeeded.\nac_fn_cxx_try_link ()\n{\n  as_lineno=${as_lineno-\"$1\"} as_lineno_stack=as_lineno_stack=$as_lineno_stack\n  rm -f conftest.$ac_objext conftest$ac_exeext\n  if { { ac_try=\"$ac_link\"\ncase \"(($ac_try\" in\n  *\\\"* | *\\`* | *\\\\*) ac_try_echo=\\$ac_try;;\n  *) ac_try_echo=$ac_try;;\nesac\neval ac_try_echo=\"\\\"\\$as_me:${as_lineno-$LINENO}: $ac_try_echo\\\"\"\n$as_echo \"$ac_try_echo\"; } >&5\n  (eval \"$ac_link\") 2>conftest.err\n  ac_status=$?\n  if test -s conftest.err; then\n    grep -v '^ *+' conftest.err >conftest.er1\n    cat conftest.er1 >&5\n    mv -f conftest.er1 conftest.err\n  fi\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; } && {\n\t test -z \"$ac_cxx_werror_flag\" ||\n\t test ! -s conftest.err\n       } && test -s conftest$ac_exeext && {\n\t test \"$cross_compiling\" = yes ||\n\t test -x conftest$ac_exeext\n       }; then :\n  ac_retval=0\nelse\n  $as_echo \"$as_me: failed program was:\" >&5\nsed 's/^/| /' conftest.$ac_ext >&5\n\n\tac_retval=1\nfi\n  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information\n  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would\n  # interfere with the next link command; also delete a directory that is\n  # left behind by Apple's compiler.  We do this before executing the actions.\n  rm -rf conftest.dSYM conftest_ipa8_conftest.oo\n  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno\n  as_fn_set_status $ac_retval\n\n} # ac_fn_cxx_try_link\n\n# ac_fn_cxx_check_func LINENO FUNC VAR\n# ------------------------------------\n# Tests whether FUNC exists, setting the cache variable VAR accordingly\nac_fn_cxx_check_func ()\n{\n  as_lineno=${as_lineno-\"$1\"} as_lineno_stack=as_lineno_stack=$as_lineno_stack\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $2\" >&5\n$as_echo_n \"checking for $2... \" >&6; }\nif eval \\${$3+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n/* Define $2 to an innocuous variant, in case <limits.h> declares $2.\n   For example, HP-UX 11i <limits.h> declares gettimeofday.  */\n#define $2 innocuous_$2\n\n/* System header to define __stub macros and hopefully few prototypes,\n    which can conflict with char $2 (); below.\n    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since\n    <limits.h> exists even on freestanding compilers.  */\n\n#ifdef __STDC__\n# include <limits.h>\n#else\n# include <assert.h>\n#endif\n\n#undef $2\n\n/* Override any GCC internal prototype to avoid an error.\n   Use char because int might match the return type of a GCC\n   builtin and then its argument prototype would still apply.  */\n#ifdef __cplusplus\nextern \"C\"\n#endif\nchar $2 ();\n/* The GNU C library defines this for functions which it implements\n    to always fail with ENOSYS.  Some functions are actually named\n    something starting with __ and the normal name is an alias.  */\n#if defined __stub_$2 || defined __stub___$2\nchoke me\n#endif\n\nint\nmain ()\n{\nreturn $2 ();\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_cxx_try_link \"$LINENO\"; then :\n  eval \"$3=yes\"\nelse\n  eval \"$3=no\"\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\nfi\neval ac_res=\\$$3\n\t       { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_res\" >&5\n$as_echo \"$ac_res\" >&6; }\n  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno\n\n} # ac_fn_cxx_check_func\ncat >config.log <<_ACEOF\nThis file contains any messages produced by compilers while\nrunning configure, to aid debugging if configure makes a mistake.\n\nIt was created by Protocol Buffers $as_me 3.0.0, which was\ngenerated by GNU Autoconf 2.69.  Invocation command line was\n\n  $ $0 $@\n\n_ACEOF\nexec 5>>config.log\n{\ncat <<_ASUNAME\n## --------- ##\n## Platform. ##\n## --------- ##\n\nhostname = `(hostname || uname -n) 2>/dev/null | sed 1q`\nuname -m = `(uname -m) 2>/dev/null || echo unknown`\nuname -r = `(uname -r) 2>/dev/null || echo unknown`\nuname -s = `(uname -s) 2>/dev/null || echo unknown`\nuname -v = `(uname -v) 2>/dev/null || echo unknown`\n\n/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`\n/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`\n\n/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`\n/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`\n/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`\n/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`\n/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`\n/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`\n/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`\n\n_ASUNAME\n\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    $as_echo \"PATH: $as_dir\"\n  done\nIFS=$as_save_IFS\n\n} >&5\n\ncat >&5 <<_ACEOF\n\n\n## ----------- ##\n## Core tests. ##\n## ----------- ##\n\n_ACEOF\n\n\n# Keep a trace of the command line.\n# Strip out --no-create and --no-recursion so they do not pile up.\n# Strip out --silent because we don't want to record it for future runs.\n# Also quote any args containing shell meta-characters.\n# Make two passes to allow for proper duplicate-argument suppression.\nac_configure_args=\nac_configure_args0=\nac_configure_args1=\nac_must_keep_next=false\nfor ac_pass in 1 2\ndo\n  for ac_arg\n  do\n    case $ac_arg in\n    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;\n    -q | -quiet | --quiet | --quie | --qui | --qu | --q \\\n    | -silent | --silent | --silen | --sile | --sil)\n      continue ;;\n    *\\'*)\n      ac_arg=`$as_echo \"$ac_arg\" | sed \"s/'/'\\\\\\\\\\\\\\\\''/g\"` ;;\n    esac\n    case $ac_pass in\n    1) as_fn_append ac_configure_args0 \" '$ac_arg'\" ;;\n    2)\n      as_fn_append ac_configure_args1 \" '$ac_arg'\"\n      if test $ac_must_keep_next = true; then\n\tac_must_keep_next=false # Got value, back to normal.\n      else\n\tcase $ac_arg in\n\t  *=* | --config-cache | -C | -disable-* | --disable-* \\\n\t  | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \\\n\t  | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \\\n\t  | -with-* | --with-* | -without-* | --without-* | --x)\n\t    case \"$ac_configure_args0 \" in\n\t      \"$ac_configure_args1\"*\" '$ac_arg' \"* ) continue ;;\n\t    esac\n\t    ;;\n\t  -* ) ac_must_keep_next=true ;;\n\tesac\n      fi\n      as_fn_append ac_configure_args \" '$ac_arg'\"\n      ;;\n    esac\n  done\ndone\n{ ac_configure_args0=; unset ac_configure_args0;}\n{ ac_configure_args1=; unset ac_configure_args1;}\n\n# When interrupted or exit'd, cleanup temporary files, and complete\n# config.log.  We remove comments because anyway the quotes in there\n# would cause problems or look ugly.\n# WARNING: Use '\\'' to represent an apostrophe within the trap.\n# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.\ntrap 'exit_status=$?\n  # Save into config.log some information that might help in debugging.\n  {\n    echo\n\n    $as_echo \"## ---------------- ##\n## Cache variables. ##\n## ---------------- ##\"\n    echo\n    # The following way of writing the cache mishandles newlines in values,\n(\n  for ac_var in `(set) 2>&1 | sed -n '\\''s/^\\([a-zA-Z_][a-zA-Z0-9_]*\\)=.*/\\1/p'\\''`; do\n    eval ac_val=\\$$ac_var\n    case $ac_val in #(\n    *${as_nl}*)\n      case $ac_var in #(\n      *_cv_*) { $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline\" >&5\n$as_echo \"$as_me: WARNING: cache variable $ac_var contains a newline\" >&2;} ;;\n      esac\n      case $ac_var in #(\n      _ | IFS | as_nl) ;; #(\n      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(\n      *) { eval $ac_var=; unset $ac_var;} ;;\n      esac ;;\n    esac\n  done\n  (set) 2>&1 |\n    case $as_nl`(ac_space='\\'' '\\''; set) 2>&1` in #(\n    *${as_nl}ac_space=\\ *)\n      sed -n \\\n\t\"s/'\\''/'\\''\\\\\\\\'\\'''\\''/g;\n\t  s/^\\\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\\\)=\\\\(.*\\\\)/\\\\1='\\''\\\\2'\\''/p\"\n      ;; #(\n    *)\n      sed -n \"/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p\"\n      ;;\n    esac |\n    sort\n)\n    echo\n\n    $as_echo \"## ----------------- ##\n## Output variables. ##\n## ----------------- ##\"\n    echo\n    for ac_var in $ac_subst_vars\n    do\n      eval ac_val=\\$$ac_var\n      case $ac_val in\n      *\\'\\''*) ac_val=`$as_echo \"$ac_val\" | sed \"s/'\\''/'\\''\\\\\\\\\\\\\\\\'\\'''\\''/g\"`;;\n      esac\n      $as_echo \"$ac_var='\\''$ac_val'\\''\"\n    done | sort\n    echo\n\n    if test -n \"$ac_subst_files\"; then\n      $as_echo \"## ------------------- ##\n## File substitutions. ##\n## ------------------- ##\"\n      echo\n      for ac_var in $ac_subst_files\n      do\n\teval ac_val=\\$$ac_var\n\tcase $ac_val in\n\t*\\'\\''*) ac_val=`$as_echo \"$ac_val\" | sed \"s/'\\''/'\\''\\\\\\\\\\\\\\\\'\\'''\\''/g\"`;;\n\tesac\n\t$as_echo \"$ac_var='\\''$ac_val'\\''\"\n      done | sort\n      echo\n    fi\n\n    if test -s confdefs.h; then\n      $as_echo \"## ----------- ##\n## confdefs.h. ##\n## ----------- ##\"\n      echo\n      cat confdefs.h\n      echo\n    fi\n    test \"$ac_signal\" != 0 &&\n      $as_echo \"$as_me: caught signal $ac_signal\"\n    $as_echo \"$as_me: exit $exit_status\"\n  } >&5\n  rm -f core *.core core.conftest.* &&\n    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&\n    exit $exit_status\n' 0\nfor ac_signal in 1 2 13 15; do\n  trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal\ndone\nac_signal=0\n\n# confdefs.h avoids OS command line length limits that DEFS can exceed.\nrm -f -r conftest* confdefs.h\n\n$as_echo \"/* confdefs.h */\" > confdefs.h\n\n# Predefined preprocessor variables.\n\ncat >>confdefs.h <<_ACEOF\n#define PACKAGE_NAME \"$PACKAGE_NAME\"\n_ACEOF\n\ncat >>confdefs.h <<_ACEOF\n#define PACKAGE_TARNAME \"$PACKAGE_TARNAME\"\n_ACEOF\n\ncat >>confdefs.h <<_ACEOF\n#define PACKAGE_VERSION \"$PACKAGE_VERSION\"\n_ACEOF\n\ncat >>confdefs.h <<_ACEOF\n#define PACKAGE_STRING \"$PACKAGE_STRING\"\n_ACEOF\n\ncat >>confdefs.h <<_ACEOF\n#define PACKAGE_BUGREPORT \"$PACKAGE_BUGREPORT\"\n_ACEOF\n\ncat >>confdefs.h <<_ACEOF\n#define PACKAGE_URL \"$PACKAGE_URL\"\n_ACEOF\n\n\n# Let the site file select an alternate cache file if it wants to.\n# Prefer an explicitly selected file to automatically selected ones.\nac_site_file1=NONE\nac_site_file2=NONE\nif test -n \"$CONFIG_SITE\"; then\n  # We do not want a PATH search for config.site.\n  case $CONFIG_SITE in #((\n    -*)  ac_site_file1=./$CONFIG_SITE;;\n    */*) ac_site_file1=$CONFIG_SITE;;\n    *)   ac_site_file1=./$CONFIG_SITE;;\n  esac\nelif test \"x$prefix\" != xNONE; then\n  ac_site_file1=$prefix/share/config.site\n  ac_site_file2=$prefix/etc/config.site\nelse\n  ac_site_file1=$ac_default_prefix/share/config.site\n  ac_site_file2=$ac_default_prefix/etc/config.site\nfi\nfor ac_site_file in \"$ac_site_file1\" \"$ac_site_file2\"\ndo\n  test \"x$ac_site_file\" = xNONE && continue\n  if test /dev/null != \"$ac_site_file\" && test -r \"$ac_site_file\"; then\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file\" >&5\n$as_echo \"$as_me: loading site script $ac_site_file\" >&6;}\n    sed 's/^/| /' \"$ac_site_file\" >&5\n    . \"$ac_site_file\" \\\n      || { { $as_echo \"$as_me:${as_lineno-$LINENO}: error: in \\`$ac_pwd':\" >&5\n$as_echo \"$as_me: error: in \\`$ac_pwd':\" >&2;}\nas_fn_error $? \"failed to load site script $ac_site_file\nSee \\`config.log' for more details\" \"$LINENO\" 5; }\n  fi\ndone\n\nif test -r \"$cache_file\"; then\n  # Some versions of bash will fail to source /dev/null (special files\n  # actually), so we avoid doing that.  DJGPP emulates it as a regular file.\n  if test /dev/null != \"$cache_file\" && test -f \"$cache_file\"; then\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: loading cache $cache_file\" >&5\n$as_echo \"$as_me: loading cache $cache_file\" >&6;}\n    case $cache_file in\n      [\\\\/]* | ?:[\\\\/]* ) . \"$cache_file\";;\n      *)                      . \"./$cache_file\";;\n    esac\n  fi\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: creating cache $cache_file\" >&5\n$as_echo \"$as_me: creating cache $cache_file\" >&6;}\n  >$cache_file\nfi\n\n# Check that the precious variables saved in the cache have kept the same\n# value.\nac_cache_corrupted=false\nfor ac_var in $ac_precious_vars; do\n  eval ac_old_set=\\$ac_cv_env_${ac_var}_set\n  eval ac_new_set=\\$ac_env_${ac_var}_set\n  eval ac_old_val=\\$ac_cv_env_${ac_var}_value\n  eval ac_new_val=\\$ac_env_${ac_var}_value\n  case $ac_old_set,$ac_new_set in\n    set,)\n      { $as_echo \"$as_me:${as_lineno-$LINENO}: error: \\`$ac_var' was set to \\`$ac_old_val' in the previous run\" >&5\n$as_echo \"$as_me: error: \\`$ac_var' was set to \\`$ac_old_val' in the previous run\" >&2;}\n      ac_cache_corrupted=: ;;\n    ,set)\n      { $as_echo \"$as_me:${as_lineno-$LINENO}: error: \\`$ac_var' was not set in the previous run\" >&5\n$as_echo \"$as_me: error: \\`$ac_var' was not set in the previous run\" >&2;}\n      ac_cache_corrupted=: ;;\n    ,);;\n    *)\n      if test \"x$ac_old_val\" != \"x$ac_new_val\"; then\n\t# differences in whitespace do not lead to failure.\n\tac_old_val_w=`echo x $ac_old_val`\n\tac_new_val_w=`echo x $ac_new_val`\n\tif test \"$ac_old_val_w\" != \"$ac_new_val_w\"; then\n\t  { $as_echo \"$as_me:${as_lineno-$LINENO}: error: \\`$ac_var' has changed since the previous run:\" >&5\n$as_echo \"$as_me: error: \\`$ac_var' has changed since the previous run:\" >&2;}\n\t  ac_cache_corrupted=:\n\telse\n\t  { $as_echo \"$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \\`$ac_var' since the previous run:\" >&5\n$as_echo \"$as_me: warning: ignoring whitespace changes in \\`$ac_var' since the previous run:\" >&2;}\n\t  eval $ac_var=\\$ac_old_val\n\tfi\n\t{ $as_echo \"$as_me:${as_lineno-$LINENO}:   former value:  \\`$ac_old_val'\" >&5\n$as_echo \"$as_me:   former value:  \\`$ac_old_val'\" >&2;}\n\t{ $as_echo \"$as_me:${as_lineno-$LINENO}:   current value: \\`$ac_new_val'\" >&5\n$as_echo \"$as_me:   current value: \\`$ac_new_val'\" >&2;}\n      fi;;\n  esac\n  # Pass precious variables to config.status.\n  if test \"$ac_new_set\" = set; then\n    case $ac_new_val in\n    *\\'*) ac_arg=$ac_var=`$as_echo \"$ac_new_val\" | sed \"s/'/'\\\\\\\\\\\\\\\\''/g\"` ;;\n    *) ac_arg=$ac_var=$ac_new_val ;;\n    esac\n    case \" $ac_configure_args \" in\n      *\" '$ac_arg' \"*) ;; # Avoid dups.  Use of quotes ensures accuracy.\n      *) as_fn_append ac_configure_args \" '$ac_arg'\" ;;\n    esac\n  fi\ndone\nif $ac_cache_corrupted; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: error: in \\`$ac_pwd':\" >&5\n$as_echo \"$as_me: error: in \\`$ac_pwd':\" >&2;}\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build\" >&5\n$as_echo \"$as_me: error: changes in the environment can compromise the build\" >&2;}\n  as_fn_error $? \"run \\`make distclean' and/or \\`rm $cache_file' and start over\" \"$LINENO\" 5\nfi\n## -------------------- ##\n## Main body of script. ##\n## -------------------- ##\n\nac_ext=c\nac_cpp='$CPP $CPPFLAGS'\nac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_c_compiler_gnu\n\n\n\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles\" >&5\n$as_echo_n \"checking whether to enable maintainer-specific portions of Makefiles... \" >&6; }\n    # Check whether --enable-maintainer-mode was given.\nif test \"${enable_maintainer_mode+set}\" = set; then :\n  enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval\nelse\n  USE_MAINTAINER_MODE=yes\nfi\n\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE\" >&5\n$as_echo \"$USE_MAINTAINER_MODE\" >&6; }\n   if test $USE_MAINTAINER_MODE = yes; then\n  MAINTAINER_MODE_TRUE=\n  MAINTAINER_MODE_FALSE='#'\nelse\n  MAINTAINER_MODE_TRUE='#'\n  MAINTAINER_MODE_FALSE=\nfi\n\n  MAINT=$MAINTAINER_MODE_TRUE\n\n\n\n\n# The config file is generated but not used by the source code, since we only\n# need very few of them, e.g. HAVE_PTHREAD and HAVE_ZLIB. Those macros are\n# passed down in CXXFLAGS manually in src/Makefile.am\nac_config_headers=\"$ac_config_headers config.h\"\n\n\n\n\ncase \"$DIST_LANG\" in\n  \"\") DIST_LANG=all ;;\n  all | cpp | csharp | java | python | javanano | objectivec | ruby | js) ;;\n  *) { { $as_echo \"$as_me:${as_lineno-$LINENO}: error: in \\`$ac_pwd':\" >&5\n$as_echo \"$as_me: error: in \\`$ac_pwd':\" >&2;}\nas_fn_error $? \"unknown language: $DIST_LANG\nSee \\`config.log' for more details\" \"$LINENO\" 5; } ;;\nesac\n\n\n# autoconf's default CXXFLAGS are usually \"-g -O2\".  These aren't necessarily\n# the best choice for libprotobuf.\nif test \"x${ac_cv_env_CFLAGS_set}\" = \"x\"; then :\n  CFLAGS=\"\"\nfi\nif test \"x${ac_cv_env_CXXFLAGS_set}\" = \"x\"; then :\n  CXXFLAGS=\"\"\nfi\n\nac_aux_dir=\nfor ac_dir in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"; do\n  if test -f \"$ac_dir/install-sh\"; then\n    ac_aux_dir=$ac_dir\n    ac_install_sh=\"$ac_aux_dir/install-sh -c\"\n    break\n  elif test -f \"$ac_dir/install.sh\"; then\n    ac_aux_dir=$ac_dir\n    ac_install_sh=\"$ac_aux_dir/install.sh -c\"\n    break\n  elif test -f \"$ac_dir/shtool\"; then\n    ac_aux_dir=$ac_dir\n    ac_install_sh=\"$ac_aux_dir/shtool install -c\"\n    break\n  fi\ndone\nif test -z \"$ac_aux_dir\"; then\n  as_fn_error $? \"cannot find install-sh, install.sh, or shtool in \\\"$srcdir\\\" \\\"$srcdir/..\\\" \\\"$srcdir/../..\\\"\" \"$LINENO\" 5\nfi\n\n# These three variables are undocumented and unsupported,\n# and are intended to be withdrawn in a future Autoconf release.\n# They can cause serious problems if a builder's source tree is in a directory\n# whose full name contains unusual characters.\nac_config_guess=\"$SHELL $ac_aux_dir/config.guess\"  # Please don't use this var.\nac_config_sub=\"$SHELL $ac_aux_dir/config.sub\"  # Please don't use this var.\nac_configure=\"$SHELL $ac_aux_dir/configure\"  # Please don't use this var.\n\n\n# Make sure we can run config.sub.\n$SHELL \"$ac_aux_dir/config.sub\" sun4 >/dev/null 2>&1 ||\n  as_fn_error $? \"cannot run $SHELL $ac_aux_dir/config.sub\" \"$LINENO\" 5\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking build system type\" >&5\n$as_echo_n \"checking build system type... \" >&6; }\nif ${ac_cv_build+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  ac_build_alias=$build_alias\ntest \"x$ac_build_alias\" = x &&\n  ac_build_alias=`$SHELL \"$ac_aux_dir/config.guess\"`\ntest \"x$ac_build_alias\" = x &&\n  as_fn_error $? \"cannot guess build type; you must specify one\" \"$LINENO\" 5\nac_cv_build=`$SHELL \"$ac_aux_dir/config.sub\" $ac_build_alias` ||\n  as_fn_error $? \"$SHELL $ac_aux_dir/config.sub $ac_build_alias failed\" \"$LINENO\" 5\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_build\" >&5\n$as_echo \"$ac_cv_build\" >&6; }\ncase $ac_cv_build in\n*-*-*) ;;\n*) as_fn_error $? \"invalid value of canonical build\" \"$LINENO\" 5;;\nesac\nbuild=$ac_cv_build\nac_save_IFS=$IFS; IFS='-'\nset x $ac_cv_build\nshift\nbuild_cpu=$1\nbuild_vendor=$2\nshift; shift\n# Remember, the first character of IFS is used to create $*,\n# except with old shells:\nbuild_os=$*\nIFS=$ac_save_IFS\ncase $build_os in *\\ *) build_os=`echo \"$build_os\" | sed 's/ /-/g'`;; esac\n\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking host system type\" >&5\n$as_echo_n \"checking host system type... \" >&6; }\nif ${ac_cv_host+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test \"x$host_alias\" = x; then\n  ac_cv_host=$ac_cv_build\nelse\n  ac_cv_host=`$SHELL \"$ac_aux_dir/config.sub\" $host_alias` ||\n    as_fn_error $? \"$SHELL $ac_aux_dir/config.sub $host_alias failed\" \"$LINENO\" 5\nfi\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_host\" >&5\n$as_echo \"$ac_cv_host\" >&6; }\ncase $ac_cv_host in\n*-*-*) ;;\n*) as_fn_error $? \"invalid value of canonical host\" \"$LINENO\" 5;;\nesac\nhost=$ac_cv_host\nac_save_IFS=$IFS; IFS='-'\nset x $ac_cv_host\nshift\nhost_cpu=$1\nhost_vendor=$2\nshift; shift\n# Remember, the first character of IFS is used to create $*,\n# except with old shells:\nhost_os=$*\nIFS=$ac_save_IFS\ncase $host_os in *\\ *) host_os=`echo \"$host_os\" | sed 's/ /-/g'`;; esac\n\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking target system type\" >&5\n$as_echo_n \"checking target system type... \" >&6; }\nif ${ac_cv_target+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test \"x$target_alias\" = x; then\n  ac_cv_target=$ac_cv_host\nelse\n  ac_cv_target=`$SHELL \"$ac_aux_dir/config.sub\" $target_alias` ||\n    as_fn_error $? \"$SHELL $ac_aux_dir/config.sub $target_alias failed\" \"$LINENO\" 5\nfi\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_target\" >&5\n$as_echo \"$ac_cv_target\" >&6; }\ncase $ac_cv_target in\n*-*-*) ;;\n*) as_fn_error $? \"invalid value of canonical target\" \"$LINENO\" 5;;\nesac\ntarget=$ac_cv_target\nac_save_IFS=$IFS; IFS='-'\nset x $ac_cv_target\nshift\ntarget_cpu=$1\ntarget_vendor=$2\nshift; shift\n# Remember, the first character of IFS is used to create $*,\n# except with old shells:\ntarget_os=$*\nIFS=$ac_save_IFS\ncase $target_os in *\\ *) target_os=`echo \"$target_os\" | sed 's/ /-/g'`;; esac\n\n\n# The aliases save the names the user supplied, while $host etc.\n# will get canonicalized.\ntest -n \"$target_alias\" &&\n  test \"$program_prefix$program_suffix$program_transform_name\" = \\\n    NONENONEs,x,x, &&\n  program_prefix=${target_alias}-\n\nam__api_version='1.14'\n\n# Find a good install program.  We prefer a C program (faster),\n# so one script is as good as another.  But avoid the broken or\n# incompatible versions:\n# SysV /etc/install, /usr/sbin/install\n# SunOS /usr/etc/install\n# IRIX /sbin/install\n# AIX /bin/install\n# AmigaOS /C/install, which installs bootblocks on floppy discs\n# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag\n# AFS /usr/afsws/bin/install, which mishandles nonexistent args\n# SVR4 /usr/ucb/install, which tries to use the nonexistent group \"staff\"\n# OS/2's system install, which has a completely different semantic\n# ./install, which can be erroneously created by make from ./install.sh.\n# Reject install programs that cannot install multiple files.\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install\" >&5\n$as_echo_n \"checking for a BSD-compatible install... \" >&6; }\nif test -z \"$INSTALL\"; then\nif ${ac_cv_path_install+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    # Account for people who put trailing slashes in PATH elements.\ncase $as_dir/ in #((\n  ./ | .// | /[cC]/* | \\\n  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \\\n  ?:[\\\\/]os2[\\\\/]install[\\\\/]* | ?:[\\\\/]OS2[\\\\/]INSTALL[\\\\/]* | \\\n  /usr/ucb/* ) ;;\n  *)\n    # OSF1 and SCO ODT 3.0 have their own names for install.\n    # Don't use installbsd from OSF since it installs stuff as root\n    # by default.\n    for ac_prog in ginstall scoinst install; do\n      for ac_exec_ext in '' $ac_executable_extensions; do\n\tif as_fn_executable_p \"$as_dir/$ac_prog$ac_exec_ext\"; then\n\t  if test $ac_prog = install &&\n\t    grep dspmsg \"$as_dir/$ac_prog$ac_exec_ext\" >/dev/null 2>&1; then\n\t    # AIX install.  It has an incompatible calling convention.\n\t    :\n\t  elif test $ac_prog = install &&\n\t    grep pwplus \"$as_dir/$ac_prog$ac_exec_ext\" >/dev/null 2>&1; then\n\t    # program-specific install script used by HP pwplus--don't use.\n\t    :\n\t  else\n\t    rm -rf conftest.one conftest.two conftest.dir\n\t    echo one > conftest.one\n\t    echo two > conftest.two\n\t    mkdir conftest.dir\n\t    if \"$as_dir/$ac_prog$ac_exec_ext\" -c conftest.one conftest.two \"`pwd`/conftest.dir\" &&\n\t      test -s conftest.one && test -s conftest.two &&\n\t      test -s conftest.dir/conftest.one &&\n\t      test -s conftest.dir/conftest.two\n\t    then\n\t      ac_cv_path_install=\"$as_dir/$ac_prog$ac_exec_ext -c\"\n\t      break 3\n\t    fi\n\t  fi\n\tfi\n      done\n    done\n    ;;\nesac\n\n  done\nIFS=$as_save_IFS\n\nrm -rf conftest.one conftest.two conftest.dir\n\nfi\n  if test \"${ac_cv_path_install+set}\" = set; then\n    INSTALL=$ac_cv_path_install\n  else\n    # As a last resort, use the slow shell script.  Don't cache a\n    # value for INSTALL within a source directory, because that will\n    # break other packages using the cache if that directory is\n    # removed, or if the value is a relative name.\n    INSTALL=$ac_install_sh\n  fi\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $INSTALL\" >&5\n$as_echo \"$INSTALL\" >&6; }\n\n# Use test -z because SunOS4 sh mishandles braces in ${var-val}.\n# It thinks the first close brace ends the variable substitution.\ntest -z \"$INSTALL_PROGRAM\" && INSTALL_PROGRAM='${INSTALL}'\n\ntest -z \"$INSTALL_SCRIPT\" && INSTALL_SCRIPT='${INSTALL}'\n\ntest -z \"$INSTALL_DATA\" && INSTALL_DATA='${INSTALL} -m 644'\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether build environment is sane\" >&5\n$as_echo_n \"checking whether build environment is sane... \" >&6; }\n# Reject unsafe characters in $srcdir or the absolute working directory\n# name.  Accept space and tab only in the latter.\nam_lf='\n'\ncase `pwd` in\n  *[\\\\\\\"\\#\\$\\&\\'\\`$am_lf]*)\n    as_fn_error $? \"unsafe absolute working directory name\" \"$LINENO\" 5;;\nesac\ncase $srcdir in\n  *[\\\\\\\"\\#\\$\\&\\'\\`$am_lf\\ \\\t]*)\n    as_fn_error $? \"unsafe srcdir value: '$srcdir'\" \"$LINENO\" 5;;\nesac\n\n# Do 'set' in a subshell so we don't clobber the current shell's\n# arguments.  Must try -L first in case configure is actually a\n# symlink; some systems play weird games with the mod time of symlinks\n# (eg FreeBSD returns the mod time of the symlink's containing\n# directory).\nif (\n   am_has_slept=no\n   for am_try in 1 2; do\n     echo \"timestamp, slept: $am_has_slept\" > conftest.file\n     set X `ls -Lt \"$srcdir/configure\" conftest.file 2> /dev/null`\n     if test \"$*\" = \"X\"; then\n\t# -L didn't work.\n\tset X `ls -t \"$srcdir/configure\" conftest.file`\n     fi\n     if test \"$*\" != \"X $srcdir/configure conftest.file\" \\\n\t&& test \"$*\" != \"X conftest.file $srcdir/configure\"; then\n\n\t# If neither matched, then we have a broken ls.  This can happen\n\t# if, for instance, CONFIG_SHELL is bash and it inherits a\n\t# broken ls alias from the environment.  This has actually\n\t# happened.  Such a system could not be considered \"sane\".\n\tas_fn_error $? \"ls -t appears to fail.  Make sure there is not a broken\n  alias in your environment\" \"$LINENO\" 5\n     fi\n     if test \"$2\" = conftest.file || test $am_try -eq 2; then\n       break\n     fi\n     # Just in case.\n     sleep 1\n     am_has_slept=yes\n   done\n   test \"$2\" = conftest.file\n   )\nthen\n   # Ok.\n   :\nelse\n   as_fn_error $? \"newly created file is older than distributed files!\nCheck your system clock\" \"$LINENO\" 5\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: yes\" >&5\n$as_echo \"yes\" >&6; }\n# If we didn't sleep, we still need to ensure time stamps of config.status and\n# generated files are strictly newer.\nam_sleep_pid=\nif grep 'slept: no' conftest.file >/dev/null 2>&1; then\n  ( sleep 1 ) &\n  am_sleep_pid=$!\nfi\n\nrm -f conftest.file\n\ntest \"$program_prefix\" != NONE &&\n  program_transform_name=\"s&^&$program_prefix&;$program_transform_name\"\n# Use a double $ so make ignores it.\ntest \"$program_suffix\" != NONE &&\n  program_transform_name=\"s&\\$&$program_suffix&;$program_transform_name\"\n# Double any \\ or $.\n# By default was `s,x,x', remove it if useless.\nac_script='s/[\\\\$]/&&/g;s/;s,x,x,$//'\nprogram_transform_name=`$as_echo \"$program_transform_name\" | sed \"$ac_script\"`\n\n# expand $ac_aux_dir to an absolute path\nam_aux_dir=`cd $ac_aux_dir && pwd`\n\nif test x\"${MISSING+set}\" != xset; then\n  case $am_aux_dir in\n  *\\ * | *\\\t*)\n    MISSING=\"\\${SHELL} \\\"$am_aux_dir/missing\\\"\" ;;\n  *)\n    MISSING=\"\\${SHELL} $am_aux_dir/missing\" ;;\n  esac\nfi\n# Use eval to expand $SHELL\nif eval \"$MISSING --is-lightweight\"; then\n  am_missing_run=\"$MISSING \"\nelse\n  am_missing_run=\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing\" >&5\n$as_echo \"$as_me: WARNING: 'missing' script is too old or missing\" >&2;}\nfi\n\nif test x\"${install_sh}\" != xset; then\n  case $am_aux_dir in\n  *\\ * | *\\\t*)\n    install_sh=\"\\${SHELL} '$am_aux_dir/install-sh'\" ;;\n  *)\n    install_sh=\"\\${SHELL} $am_aux_dir/install-sh\"\n  esac\nfi\n\n# Installed binaries are usually stripped using 'strip' when the user\n# run \"make install-strip\".  However 'strip' might not be the right\n# tool to use in cross-compilation environments, therefore Automake\n# will honor the 'STRIP' environment variable to overrule this program.\nif test \"$cross_compiling\" != no; then\n  if test -n \"$ac_tool_prefix\"; then\n  # Extract the first word of \"${ac_tool_prefix}strip\", so it can be a program name with args.\nset dummy ${ac_tool_prefix}strip; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_STRIP+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$STRIP\"; then\n  ac_cv_prog_STRIP=\"$STRIP\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_STRIP=\"${ac_tool_prefix}strip\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nSTRIP=$ac_cv_prog_STRIP\nif test -n \"$STRIP\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $STRIP\" >&5\n$as_echo \"$STRIP\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\nfi\nif test -z \"$ac_cv_prog_STRIP\"; then\n  ac_ct_STRIP=$STRIP\n  # Extract the first word of \"strip\", so it can be a program name with args.\nset dummy strip; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_ac_ct_STRIP+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$ac_ct_STRIP\"; then\n  ac_cv_prog_ac_ct_STRIP=\"$ac_ct_STRIP\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_ac_ct_STRIP=\"strip\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP\nif test -n \"$ac_ct_STRIP\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP\" >&5\n$as_echo \"$ac_ct_STRIP\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n  if test \"x$ac_ct_STRIP\" = x; then\n    STRIP=\":\"\n  else\n    case $cross_compiling:$ac_tool_warned in\nyes:)\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet\" >&5\n$as_echo \"$as_me: WARNING: using cross tools not prefixed with host triplet\" >&2;}\nac_tool_warned=yes ;;\nesac\n    STRIP=$ac_ct_STRIP\n  fi\nelse\n  STRIP=\"$ac_cv_prog_STRIP\"\nfi\n\nfi\nINSTALL_STRIP_PROGRAM=\"\\$(install_sh) -c -s\"\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p\" >&5\n$as_echo_n \"checking for a thread-safe mkdir -p... \" >&6; }\nif test -z \"$MKDIR_P\"; then\n  if ${ac_cv_path_mkdir+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_prog in mkdir gmkdir; do\n\t for ac_exec_ext in '' $ac_executable_extensions; do\n\t   as_fn_executable_p \"$as_dir/$ac_prog$ac_exec_ext\" || continue\n\t   case `\"$as_dir/$ac_prog$ac_exec_ext\" --version 2>&1` in #(\n\t     'mkdir (GNU coreutils) '* | \\\n\t     'mkdir (coreutils) '* | \\\n\t     'mkdir (fileutils) '4.1*)\n\t       ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext\n\t       break 3;;\n\t   esac\n\t done\n       done\n  done\nIFS=$as_save_IFS\n\nfi\n\n  test -d ./--version && rmdir ./--version\n  if test \"${ac_cv_path_mkdir+set}\" = set; then\n    MKDIR_P=\"$ac_cv_path_mkdir -p\"\n  else\n    # As a last resort, use the slow shell script.  Don't cache a\n    # value for MKDIR_P within a source directory, because that will\n    # break other packages using the cache if that directory is\n    # removed, or if the value is a relative name.\n    MKDIR_P=\"$ac_install_sh -d\"\n  fi\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $MKDIR_P\" >&5\n$as_echo \"$MKDIR_P\" >&6; }\n\nfor ac_prog in gawk mawk nawk awk\ndo\n  # Extract the first word of \"$ac_prog\", so it can be a program name with args.\nset dummy $ac_prog; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_AWK+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$AWK\"; then\n  ac_cv_prog_AWK=\"$AWK\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_AWK=\"$ac_prog\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nAWK=$ac_cv_prog_AWK\nif test -n \"$AWK\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $AWK\" >&5\n$as_echo \"$AWK\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\n  test -n \"$AWK\" && break\ndone\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \\$(MAKE)\" >&5\n$as_echo_n \"checking whether ${MAKE-make} sets \\$(MAKE)... \" >&6; }\nset x ${MAKE-make}\nac_make=`$as_echo \"$2\" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`\nif eval \\${ac_cv_prog_make_${ac_make}_set+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  cat >conftest.make <<\\_ACEOF\nSHELL = /bin/sh\nall:\n\t@echo '@@@%%%=$(MAKE)=@@@%%%'\n_ACEOF\n# GNU make sometimes prints \"make[1]: Entering ...\", which would confuse us.\ncase `${MAKE-make} -f conftest.make 2>/dev/null` in\n  *@@@%%%=?*=@@@%%%*)\n    eval ac_cv_prog_make_${ac_make}_set=yes;;\n  *)\n    eval ac_cv_prog_make_${ac_make}_set=no;;\nesac\nrm -f conftest.make\nfi\nif eval test \\$ac_cv_prog_make_${ac_make}_set = yes; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: yes\" >&5\n$as_echo \"yes\" >&6; }\n  SET_MAKE=\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\n  SET_MAKE=\"MAKE=${MAKE-make}\"\nfi\n\nrm -rf .tst 2>/dev/null\nmkdir .tst 2>/dev/null\nif test -d .tst; then\n  am__leading_dot=.\nelse\n  am__leading_dot=_\nfi\nrmdir .tst 2>/dev/null\n\n# Check whether --enable-silent-rules was given.\nif test \"${enable_silent_rules+set}\" = set; then :\n  enableval=$enable_silent_rules;\nfi\n\ncase $enable_silent_rules in # (((\n  yes) AM_DEFAULT_VERBOSITY=0;;\n   no) AM_DEFAULT_VERBOSITY=1;;\n    *) AM_DEFAULT_VERBOSITY=1;;\nesac\nam_make=${MAKE-make}\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables\" >&5\n$as_echo_n \"checking whether $am_make supports nested variables... \" >&6; }\nif ${am_cv_make_support_nested_variables+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if $as_echo 'TRUE=$(BAR$(V))\nBAR0=false\nBAR1=true\nV=1\nam__doit:\n\t@$(TRUE)\n.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then\n  am_cv_make_support_nested_variables=yes\nelse\n  am_cv_make_support_nested_variables=no\nfi\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables\" >&5\n$as_echo \"$am_cv_make_support_nested_variables\" >&6; }\nif test $am_cv_make_support_nested_variables = yes; then\n    AM_V='$(V)'\n  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'\nelse\n  AM_V=$AM_DEFAULT_VERBOSITY\n  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY\nfi\nAM_BACKSLASH='\\'\n\nif test \"`cd $srcdir && pwd`\" != \"`pwd`\"; then\n  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output\n  # is not polluted with repeated \"-I.\"\n  am__isrc=' -I$(srcdir)'\n  # test to see if srcdir already configured\n  if test -f $srcdir/config.status; then\n    as_fn_error $? \"source directory already configured; run \\\"make distclean\\\" there first\" \"$LINENO\" 5\n  fi\nfi\n\n# test whether we have cygpath\nif test -z \"$CYGPATH_W\"; then\n  if (cygpath --version) >/dev/null 2>/dev/null; then\n    CYGPATH_W='cygpath -w'\n  else\n    CYGPATH_W=echo\n  fi\nfi\n\n\n# Define the identity of the package.\n PACKAGE='protobuf'\n VERSION='3.0.0'\n\n\ncat >>confdefs.h <<_ACEOF\n#define PACKAGE \"$PACKAGE\"\n_ACEOF\n\n\ncat >>confdefs.h <<_ACEOF\n#define VERSION \"$VERSION\"\n_ACEOF\n\n# Some tools Automake needs.\n\nACLOCAL=${ACLOCAL-\"${am_missing_run}aclocal-${am__api_version}\"}\n\n\nAUTOCONF=${AUTOCONF-\"${am_missing_run}autoconf\"}\n\n\nAUTOMAKE=${AUTOMAKE-\"${am_missing_run}automake-${am__api_version}\"}\n\n\nAUTOHEADER=${AUTOHEADER-\"${am_missing_run}autoheader\"}\n\n\nMAKEINFO=${MAKEINFO-\"${am_missing_run}makeinfo\"}\n\n# For better backward compatibility.  To be removed once Automake 1.9.x\n# dies out for good.  For more background, see:\n# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>\n# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>\nmkdir_p='$(MKDIR_P)'\n\n# We need awk for the \"check\" target.  The system \"awk\" is bad on\n# some platforms.\n# Always define AMTAR for backward compatibility.  Yes, it's still used\n# in the wild :-(  We should find a proper way to deprecate it ...\nAMTAR='$${TAR-tar}'\n\n\n# We'll loop over all known methods to create a tar archive until one works.\n_am_tools='gnutar plaintar pax cpio none'\n\n# The POSIX 1988 'ustar' format is defined with fixed-size fields.\n      # There is notably a 21 bits limit for the UID and the GID.  In fact,\n      # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343\n      # and bug#13588).\n      am_max_uid=2097151 # 2^21 - 1\n      am_max_gid=$am_max_uid\n      # The $UID and $GID variables are not portable, so we need to resort\n      # to the POSIX-mandated id(1) utility.  Errors in the 'id' calls\n      # below are definitely unexpected, so allow the users to see them\n      # (that is, avoid stderr redirection).\n      am_uid=`id -u || echo unknown`\n      am_gid=`id -g || echo unknown`\n      { $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether UID '$am_uid' is supported by ustar format\" >&5\n$as_echo_n \"checking whether UID '$am_uid' is supported by ustar format... \" >&6; }\n      if test $am_uid -le $am_max_uid; then\n         { $as_echo \"$as_me:${as_lineno-$LINENO}: result: yes\" >&5\n$as_echo \"yes\" >&6; }\n      else\n         { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\n         _am_tools=none\n      fi\n      { $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether GID '$am_gid' is supported by ustar format\" >&5\n$as_echo_n \"checking whether GID '$am_gid' is supported by ustar format... \" >&6; }\n      if test $am_gid -le $am_max_gid; then\n         { $as_echo \"$as_me:${as_lineno-$LINENO}: result: yes\" >&5\n$as_echo \"yes\" >&6; }\n      else\n        { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\n        _am_tools=none\n      fi\n\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking how to create a ustar tar archive\" >&5\n$as_echo_n \"checking how to create a ustar tar archive... \" >&6; }\n\n  # Go ahead even if we have the value already cached.  We do so because we\n  # need to set the values for the 'am__tar' and 'am__untar' variables.\n  _am_tools=${am_cv_prog_tar_ustar-$_am_tools}\n\n  for _am_tool in $_am_tools; do\n    case $_am_tool in\n    gnutar)\n      for _am_tar in tar gnutar gtar; do\n        { echo \"$as_me:$LINENO: $_am_tar --version\" >&5\n   ($_am_tar --version) >&5 2>&5\n   ac_status=$?\n   echo \"$as_me:$LINENO: \\$? = $ac_status\" >&5\n   (exit $ac_status); } && break\n      done\n      am__tar=\"$_am_tar --format=ustar -chf - \"'\"$$tardir\"'\n      am__tar_=\"$_am_tar --format=ustar -chf - \"'\"$tardir\"'\n      am__untar=\"$_am_tar -xf -\"\n      ;;\n    plaintar)\n      # Must skip GNU tar: if it does not support --format= it doesn't create\n      # ustar tarball either.\n      (tar --version) >/dev/null 2>&1 && continue\n      am__tar='tar chf - \"$$tardir\"'\n      am__tar_='tar chf - \"$tardir\"'\n      am__untar='tar xf -'\n      ;;\n    pax)\n      am__tar='pax -L -x ustar -w \"$$tardir\"'\n      am__tar_='pax -L -x ustar -w \"$tardir\"'\n      am__untar='pax -r'\n      ;;\n    cpio)\n      am__tar='find \"$$tardir\" -print | cpio -o -H ustar -L'\n      am__tar_='find \"$tardir\" -print | cpio -o -H ustar -L'\n      am__untar='cpio -i -H ustar -d'\n      ;;\n    none)\n      am__tar=false\n      am__tar_=false\n      am__untar=false\n      ;;\n    esac\n\n    # If the value was cached, stop now.  We just wanted to have am__tar\n    # and am__untar set.\n    test -n \"${am_cv_prog_tar_ustar}\" && break\n\n    # tar/untar a dummy directory, and stop if the command works.\n    rm -rf conftest.dir\n    mkdir conftest.dir\n    echo GrepMe > conftest.dir/file\n    { echo \"$as_me:$LINENO: tardir=conftest.dir && eval $am__tar_ >conftest.tar\" >&5\n   (tardir=conftest.dir && eval $am__tar_ >conftest.tar) >&5 2>&5\n   ac_status=$?\n   echo \"$as_me:$LINENO: \\$? = $ac_status\" >&5\n   (exit $ac_status); }\n    rm -rf conftest.dir\n    if test -s conftest.tar; then\n      { echo \"$as_me:$LINENO: $am__untar <conftest.tar\" >&5\n   ($am__untar <conftest.tar) >&5 2>&5\n   ac_status=$?\n   echo \"$as_me:$LINENO: \\$? = $ac_status\" >&5\n   (exit $ac_status); }\n      { echo \"$as_me:$LINENO: cat conftest.dir/file\" >&5\n   (cat conftest.dir/file) >&5 2>&5\n   ac_status=$?\n   echo \"$as_me:$LINENO: \\$? = $ac_status\" >&5\n   (exit $ac_status); }\n      grep GrepMe conftest.dir/file >/dev/null 2>&1 && break\n    fi\n  done\n  rm -rf conftest.dir\n\n  if ${am_cv_prog_tar_ustar+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  am_cv_prog_tar_ustar=$_am_tool\nfi\n\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_tar_ustar\" >&5\n$as_echo \"$am_cv_prog_tar_ustar\" >&6; }\n\n\n\n\n\n\n# POSIX will say in a future version that running \"rm -f\" with no argument\n# is OK; and we want to be able to make that assumption in our Makefile\n# recipes.  So use an aggressive probe to check that the usage we want is\n# actually supported \"in the wild\" to an acceptable degree.\n# See automake bug#10828.\n# To make any issue more visible, cause the running configure to be aborted\n# by default if the 'rm' program in use doesn't match our expectations; the\n# user can still override this though.\nif rm -f && rm -fr && rm -rf; then : OK; else\n  cat >&2 <<'END'\nOops!\n\nYour 'rm' program seems unable to run without file operands specified\non the command line, even when the '-f' option is present.  This is contrary\nto the behaviour of most rm programs out there, and not conforming with\nthe upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>\n\nPlease tell bug-automake@gnu.org about your system, including the value\nof your $PATH and any error possibly output before this message.  This\ncan help us improve future automake versions.\n\nEND\n  if test x\"$ACCEPT_INFERIOR_RM_PROGRAM\" = x\"yes\"; then\n    echo 'Configuration will proceed anyway, since you have set the' >&2\n    echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to \"yes\"' >&2\n    echo >&2\n  else\n    cat >&2 <<'END'\nAborting the configuration process, to ensure you take notice of the issue.\n\nYou can download and install GNU coreutils to get an 'rm' implementation\nthat behaves properly: <http://www.gnu.org/software/coreutils/>.\n\nIf you want to complete the configuration process using your problematic\n'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM\nto \"yes\", and re-run configure.\n\nEND\n    as_fn_error $? \"Your 'rm' program is bad, sorry.\" \"$LINENO\" 5\n  fi\nfi\n\n\n# Check whether --with-zlib was given.\nif test \"${with_zlib+set}\" = set; then :\n  withval=$with_zlib;\nelse\n  with_zlib=check\nfi\n\n\n\n# Check whether --with-protoc was given.\nif test \"${with_protoc+set}\" = set; then :\n  withval=$with_protoc;\nelse\n  with_protoc=no\nfi\n\n\n# Checks for programs.\nac_ext=c\nac_cpp='$CPP $CPPFLAGS'\nac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_c_compiler_gnu\nif test -n \"$ac_tool_prefix\"; then\n  # Extract the first word of \"${ac_tool_prefix}gcc\", so it can be a program name with args.\nset dummy ${ac_tool_prefix}gcc; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_CC+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$CC\"; then\n  ac_cv_prog_CC=\"$CC\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_CC=\"${ac_tool_prefix}gcc\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nCC=$ac_cv_prog_CC\nif test -n \"$CC\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $CC\" >&5\n$as_echo \"$CC\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\nfi\nif test -z \"$ac_cv_prog_CC\"; then\n  ac_ct_CC=$CC\n  # Extract the first word of \"gcc\", so it can be a program name with args.\nset dummy gcc; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_ac_ct_CC+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$ac_ct_CC\"; then\n  ac_cv_prog_ac_ct_CC=\"$ac_ct_CC\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_ac_ct_CC=\"gcc\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nac_ct_CC=$ac_cv_prog_ac_ct_CC\nif test -n \"$ac_ct_CC\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC\" >&5\n$as_echo \"$ac_ct_CC\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n  if test \"x$ac_ct_CC\" = x; then\n    CC=\"\"\n  else\n    case $cross_compiling:$ac_tool_warned in\nyes:)\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet\" >&5\n$as_echo \"$as_me: WARNING: using cross tools not prefixed with host triplet\" >&2;}\nac_tool_warned=yes ;;\nesac\n    CC=$ac_ct_CC\n  fi\nelse\n  CC=\"$ac_cv_prog_CC\"\nfi\n\nif test -z \"$CC\"; then\n          if test -n \"$ac_tool_prefix\"; then\n    # Extract the first word of \"${ac_tool_prefix}cc\", so it can be a program name with args.\nset dummy ${ac_tool_prefix}cc; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_CC+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$CC\"; then\n  ac_cv_prog_CC=\"$CC\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_CC=\"${ac_tool_prefix}cc\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nCC=$ac_cv_prog_CC\nif test -n \"$CC\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $CC\" >&5\n$as_echo \"$CC\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\n  fi\nfi\nif test -z \"$CC\"; then\n  # Extract the first word of \"cc\", so it can be a program name with args.\nset dummy cc; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_CC+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$CC\"; then\n  ac_cv_prog_CC=\"$CC\" # Let the user override the test.\nelse\n  ac_prog_rejected=no\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    if test \"$as_dir/$ac_word$ac_exec_ext\" = \"/usr/ucb/cc\"; then\n       ac_prog_rejected=yes\n       continue\n     fi\n    ac_cv_prog_CC=\"cc\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nif test $ac_prog_rejected = yes; then\n  # We found a bogon in the path, so make sure we never use it.\n  set dummy $ac_cv_prog_CC\n  shift\n  if test $# != 0; then\n    # We chose a different compiler from the bogus one.\n    # However, it has the same basename, so the bogon will be chosen\n    # first if we set CC to just the basename; use the full file name.\n    shift\n    ac_cv_prog_CC=\"$as_dir/$ac_word${1+' '}$@\"\n  fi\nfi\nfi\nfi\nCC=$ac_cv_prog_CC\nif test -n \"$CC\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $CC\" >&5\n$as_echo \"$CC\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\nfi\nif test -z \"$CC\"; then\n  if test -n \"$ac_tool_prefix\"; then\n  for ac_prog in cl.exe\n  do\n    # Extract the first word of \"$ac_tool_prefix$ac_prog\", so it can be a program name with args.\nset dummy $ac_tool_prefix$ac_prog; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_CC+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$CC\"; then\n  ac_cv_prog_CC=\"$CC\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_CC=\"$ac_tool_prefix$ac_prog\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nCC=$ac_cv_prog_CC\nif test -n \"$CC\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $CC\" >&5\n$as_echo \"$CC\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\n    test -n \"$CC\" && break\n  done\nfi\nif test -z \"$CC\"; then\n  ac_ct_CC=$CC\n  for ac_prog in cl.exe\ndo\n  # Extract the first word of \"$ac_prog\", so it can be a program name with args.\nset dummy $ac_prog; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_ac_ct_CC+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$ac_ct_CC\"; then\n  ac_cv_prog_ac_ct_CC=\"$ac_ct_CC\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_ac_ct_CC=\"$ac_prog\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nac_ct_CC=$ac_cv_prog_ac_ct_CC\nif test -n \"$ac_ct_CC\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC\" >&5\n$as_echo \"$ac_ct_CC\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\n  test -n \"$ac_ct_CC\" && break\ndone\n\n  if test \"x$ac_ct_CC\" = x; then\n    CC=\"\"\n  else\n    case $cross_compiling:$ac_tool_warned in\nyes:)\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet\" >&5\n$as_echo \"$as_me: WARNING: using cross tools not prefixed with host triplet\" >&2;}\nac_tool_warned=yes ;;\nesac\n    CC=$ac_ct_CC\n  fi\nfi\n\nfi\n\n\ntest -z \"$CC\" && { { $as_echo \"$as_me:${as_lineno-$LINENO}: error: in \\`$ac_pwd':\" >&5\n$as_echo \"$as_me: error: in \\`$ac_pwd':\" >&2;}\nas_fn_error $? \"no acceptable C compiler found in \\$PATH\nSee \\`config.log' for more details\" \"$LINENO\" 5; }\n\n# Provide some information about the compiler.\n$as_echo \"$as_me:${as_lineno-$LINENO}: checking for C compiler version\" >&5\nset X $ac_compile\nac_compiler=$2\nfor ac_option in --version -v -V -qversion; do\n  { { ac_try=\"$ac_compiler $ac_option >&5\"\ncase \"(($ac_try\" in\n  *\\\"* | *\\`* | *\\\\*) ac_try_echo=\\$ac_try;;\n  *) ac_try_echo=$ac_try;;\nesac\neval ac_try_echo=\"\\\"\\$as_me:${as_lineno-$LINENO}: $ac_try_echo\\\"\"\n$as_echo \"$ac_try_echo\"; } >&5\n  (eval \"$ac_compiler $ac_option >&5\") 2>conftest.err\n  ac_status=$?\n  if test -s conftest.err; then\n    sed '10a\\\n... rest of stderr output deleted ...\n         10q' conftest.err >conftest.er1\n    cat conftest.er1 >&5\n  fi\n  rm -f conftest.er1 conftest.err\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; }\ndone\n\ncat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nac_clean_files_save=$ac_clean_files\nac_clean_files=\"$ac_clean_files a.out a.out.dSYM a.exe b.out\"\n# Try to create an executable without -o first, disregard a.out.\n# It will help us diagnose broken compilers, and finding out an intuition\n# of exeext.\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether the C compiler works\" >&5\n$as_echo_n \"checking whether the C compiler works... \" >&6; }\nac_link_default=`$as_echo \"$ac_link\" | sed 's/ -o *conftest[^ ]*//'`\n\n# The possible output files:\nac_files=\"a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*\"\n\nac_rmfiles=\nfor ac_file in $ac_files\ndo\n  case $ac_file in\n    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;\n    * ) ac_rmfiles=\"$ac_rmfiles $ac_file\";;\n  esac\ndone\nrm -f $ac_rmfiles\n\nif { { ac_try=\"$ac_link_default\"\ncase \"(($ac_try\" in\n  *\\\"* | *\\`* | *\\\\*) ac_try_echo=\\$ac_try;;\n  *) ac_try_echo=$ac_try;;\nesac\neval ac_try_echo=\"\\\"\\$as_me:${as_lineno-$LINENO}: $ac_try_echo\\\"\"\n$as_echo \"$ac_try_echo\"; } >&5\n  (eval \"$ac_link_default\") 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; }; then :\n  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.\n# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'\n# in a Makefile.  We should not override ac_cv_exeext if it was cached,\n# so that the user can short-circuit this test for compilers unknown to\n# Autoconf.\nfor ac_file in $ac_files ''\ndo\n  test -f \"$ac_file\" || continue\n  case $ac_file in\n    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )\n\t;;\n    [ab].out )\n\t# We found the default executable, but exeext='' is most\n\t# certainly right.\n\tbreak;;\n    *.* )\n\tif test \"${ac_cv_exeext+set}\" = set && test \"$ac_cv_exeext\" != no;\n\tthen :; else\n\t   ac_cv_exeext=`expr \"$ac_file\" : '[^.]*\\(\\..*\\)'`\n\tfi\n\t# We set ac_cv_exeext here because the later test for it is not\n\t# safe: cross compilers may not add the suffix if given an `-o'\n\t# argument, so we may need to know it at that point already.\n\t# Even if this section looks crufty: it has the advantage of\n\t# actually working.\n\tbreak;;\n    * )\n\tbreak;;\n  esac\ndone\ntest \"$ac_cv_exeext\" = no && ac_cv_exeext=\n\nelse\n  ac_file=''\nfi\nif test -z \"$ac_file\"; then :\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\n$as_echo \"$as_me: failed program was:\" >&5\nsed 's/^/| /' conftest.$ac_ext >&5\n\n{ { $as_echo \"$as_me:${as_lineno-$LINENO}: error: in \\`$ac_pwd':\" >&5\n$as_echo \"$as_me: error: in \\`$ac_pwd':\" >&2;}\nas_fn_error 77 \"C compiler cannot create executables\nSee \\`config.log' for more details\" \"$LINENO\" 5; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: yes\" >&5\n$as_echo \"yes\" >&6; }\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name\" >&5\n$as_echo_n \"checking for C compiler default output file name... \" >&6; }\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_file\" >&5\n$as_echo \"$ac_file\" >&6; }\nac_exeext=$ac_cv_exeext\n\nrm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out\nac_clean_files=$ac_clean_files_save\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for suffix of executables\" >&5\n$as_echo_n \"checking for suffix of executables... \" >&6; }\nif { { ac_try=\"$ac_link\"\ncase \"(($ac_try\" in\n  *\\\"* | *\\`* | *\\\\*) ac_try_echo=\\$ac_try;;\n  *) ac_try_echo=$ac_try;;\nesac\neval ac_try_echo=\"\\\"\\$as_me:${as_lineno-$LINENO}: $ac_try_echo\\\"\"\n$as_echo \"$ac_try_echo\"; } >&5\n  (eval \"$ac_link\") 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; }; then :\n  # If both `conftest.exe' and `conftest' are `present' (well, observable)\n# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will\n# work properly (i.e., refer to `conftest.exe'), while it won't with\n# `rm'.\nfor ac_file in conftest.exe conftest conftest.*; do\n  test -f \"$ac_file\" || continue\n  case $ac_file in\n    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;\n    *.* ) ac_cv_exeext=`expr \"$ac_file\" : '[^.]*\\(\\..*\\)'`\n\t  break;;\n    * ) break;;\n  esac\ndone\nelse\n  { { $as_echo \"$as_me:${as_lineno-$LINENO}: error: in \\`$ac_pwd':\" >&5\n$as_echo \"$as_me: error: in \\`$ac_pwd':\" >&2;}\nas_fn_error $? \"cannot compute suffix of executables: cannot compile and link\nSee \\`config.log' for more details\" \"$LINENO\" 5; }\nfi\nrm -f conftest conftest$ac_cv_exeext\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext\" >&5\n$as_echo \"$ac_cv_exeext\" >&6; }\n\nrm -f conftest.$ac_ext\nEXEEXT=$ac_cv_exeext\nac_exeext=$EXEEXT\ncat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <stdio.h>\nint\nmain ()\n{\nFILE *f = fopen (\"conftest.out\", \"w\");\n return ferror (f) || fclose (f) != 0;\n\n  ;\n  return 0;\n}\n_ACEOF\nac_clean_files=\"$ac_clean_files conftest.out\"\n# Check that the compiler produces executables we can run.  If not, either\n# the compiler is broken, or we cross compile.\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling\" >&5\n$as_echo_n \"checking whether we are cross compiling... \" >&6; }\nif test \"$cross_compiling\" != yes; then\n  { { ac_try=\"$ac_link\"\ncase \"(($ac_try\" in\n  *\\\"* | *\\`* | *\\\\*) ac_try_echo=\\$ac_try;;\n  *) ac_try_echo=$ac_try;;\nesac\neval ac_try_echo=\"\\\"\\$as_me:${as_lineno-$LINENO}: $ac_try_echo\\\"\"\n$as_echo \"$ac_try_echo\"; } >&5\n  (eval \"$ac_link\") 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; }\n  if { ac_try='./conftest$ac_cv_exeext'\n  { { case \"(($ac_try\" in\n  *\\\"* | *\\`* | *\\\\*) ac_try_echo=\\$ac_try;;\n  *) ac_try_echo=$ac_try;;\nesac\neval ac_try_echo=\"\\\"\\$as_me:${as_lineno-$LINENO}: $ac_try_echo\\\"\"\n$as_echo \"$ac_try_echo\"; } >&5\n  (eval \"$ac_try\") 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; }; }; then\n    cross_compiling=no\n  else\n    if test \"$cross_compiling\" = maybe; then\n\tcross_compiling=yes\n    else\n\t{ { $as_echo \"$as_me:${as_lineno-$LINENO}: error: in \\`$ac_pwd':\" >&5\n$as_echo \"$as_me: error: in \\`$ac_pwd':\" >&2;}\nas_fn_error $? \"cannot run C compiled programs.\nIf you meant to cross compile, use \\`--host'.\nSee \\`config.log' for more details\" \"$LINENO\" 5; }\n    fi\n  fi\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $cross_compiling\" >&5\n$as_echo \"$cross_compiling\" >&6; }\n\nrm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out\nac_clean_files=$ac_clean_files_save\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for suffix of object files\" >&5\n$as_echo_n \"checking for suffix of object files... \" >&6; }\nif ${ac_cv_objext+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nrm -f conftest.o conftest.obj\nif { { ac_try=\"$ac_compile\"\ncase \"(($ac_try\" in\n  *\\\"* | *\\`* | *\\\\*) ac_try_echo=\\$ac_try;;\n  *) ac_try_echo=$ac_try;;\nesac\neval ac_try_echo=\"\\\"\\$as_me:${as_lineno-$LINENO}: $ac_try_echo\\\"\"\n$as_echo \"$ac_try_echo\"; } >&5\n  (eval \"$ac_compile\") 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; }; then :\n  for ac_file in conftest.o conftest.obj conftest.*; do\n  test -f \"$ac_file\" || continue;\n  case $ac_file in\n    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;\n    *) ac_cv_objext=`expr \"$ac_file\" : '.*\\.\\(.*\\)'`\n       break;;\n  esac\ndone\nelse\n  $as_echo \"$as_me: failed program was:\" >&5\nsed 's/^/| /' conftest.$ac_ext >&5\n\n{ { $as_echo \"$as_me:${as_lineno-$LINENO}: error: in \\`$ac_pwd':\" >&5\n$as_echo \"$as_me: error: in \\`$ac_pwd':\" >&2;}\nas_fn_error $? \"cannot compute suffix of object files: cannot compile\nSee \\`config.log' for more details\" \"$LINENO\" 5; }\nfi\nrm -f conftest.$ac_cv_objext conftest.$ac_ext\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext\" >&5\n$as_echo \"$ac_cv_objext\" >&6; }\nOBJEXT=$ac_cv_objext\nac_objext=$OBJEXT\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler\" >&5\n$as_echo_n \"checking whether we are using the GNU C compiler... \" >&6; }\nif ${ac_cv_c_compiler_gnu+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n#ifndef __GNUC__\n       choke me\n#endif\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_compile \"$LINENO\"; then :\n  ac_compiler_gnu=yes\nelse\n  ac_compiler_gnu=no\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\nac_cv_c_compiler_gnu=$ac_compiler_gnu\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu\" >&5\n$as_echo \"$ac_cv_c_compiler_gnu\" >&6; }\nif test $ac_compiler_gnu = yes; then\n  GCC=yes\nelse\n  GCC=\nfi\nac_test_CFLAGS=${CFLAGS+set}\nac_save_CFLAGS=$CFLAGS\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g\" >&5\n$as_echo_n \"checking whether $CC accepts -g... \" >&6; }\nif ${ac_cv_prog_cc_g+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  ac_save_c_werror_flag=$ac_c_werror_flag\n   ac_c_werror_flag=yes\n   ac_cv_prog_cc_g=no\n   CFLAGS=\"-g\"\n   cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_compile \"$LINENO\"; then :\n  ac_cv_prog_cc_g=yes\nelse\n  CFLAGS=\"\"\n      cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_compile \"$LINENO\"; then :\n\nelse\n  ac_c_werror_flag=$ac_save_c_werror_flag\n\t CFLAGS=\"-g\"\n\t cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_compile \"$LINENO\"; then :\n  ac_cv_prog_cc_g=yes\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\n   ac_c_werror_flag=$ac_save_c_werror_flag\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g\" >&5\n$as_echo \"$ac_cv_prog_cc_g\" >&6; }\nif test \"$ac_test_CFLAGS\" = set; then\n  CFLAGS=$ac_save_CFLAGS\nelif test $ac_cv_prog_cc_g = yes; then\n  if test \"$GCC\" = yes; then\n    CFLAGS=\"-g -O2\"\n  else\n    CFLAGS=\"-g\"\n  fi\nelse\n  if test \"$GCC\" = yes; then\n    CFLAGS=\"-O2\"\n  else\n    CFLAGS=\n  fi\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89\" >&5\n$as_echo_n \"checking for $CC option to accept ISO C89... \" >&6; }\nif ${ac_cv_prog_cc_c89+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  ac_cv_prog_cc_c89=no\nac_save_CC=$CC\ncat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <stdarg.h>\n#include <stdio.h>\nstruct stat;\n/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */\nstruct buf { int x; };\nFILE * (*rcsopen) (struct buf *, struct stat *, int);\nstatic char *e (p, i)\n     char **p;\n     int i;\n{\n  return p[i];\n}\nstatic char *f (char * (*g) (char **, int), char **p, ...)\n{\n  char *s;\n  va_list v;\n  va_start (v,p);\n  s = g (p, va_arg (v,int));\n  va_end (v);\n  return s;\n}\n\n/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has\n   function prototypes and stuff, but not '\\xHH' hex character constants.\n   These don't provoke an error unfortunately, instead are silently treated\n   as 'x'.  The following induces an error, until -std is added to get\n   proper ANSI mode.  Curiously '\\x00'!='x' always comes out true, for an\n   array size at least.  It's necessary to write '\\x00'==0 to get something\n   that's true only with -std.  */\nint osf4_cc_array ['\\x00' == 0 ? 1 : -1];\n\n/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters\n   inside strings and character constants.  */\n#define FOO(x) 'x'\nint xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];\n\nint test (int i, double x);\nstruct s1 {int (*f) (int a);};\nstruct s2 {int (*f) (double a);};\nint pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);\nint argc;\nchar **argv;\nint\nmain ()\n{\nreturn f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];\n  ;\n  return 0;\n}\n_ACEOF\nfor ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \\\n\t-Ae \"-Aa -D_HPUX_SOURCE\" \"-Xc -D__EXTENSIONS__\"\ndo\n  CC=\"$ac_save_CC $ac_arg\"\n  if ac_fn_c_try_compile \"$LINENO\"; then :\n  ac_cv_prog_cc_c89=$ac_arg\nfi\nrm -f core conftest.err conftest.$ac_objext\n  test \"x$ac_cv_prog_cc_c89\" != \"xno\" && break\ndone\nrm -f conftest.$ac_ext\nCC=$ac_save_CC\n\nfi\n# AC_CACHE_VAL\ncase \"x$ac_cv_prog_cc_c89\" in\n  x)\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: result: none needed\" >&5\n$as_echo \"none needed\" >&6; } ;;\n  xno)\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: result: unsupported\" >&5\n$as_echo \"unsupported\" >&6; } ;;\n  *)\n    CC=\"$CC $ac_cv_prog_cc_c89\"\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89\" >&5\n$as_echo \"$ac_cv_prog_cc_c89\" >&6; } ;;\nesac\nif test \"x$ac_cv_prog_cc_c89\" != xno; then :\n\nfi\n\nac_ext=c\nac_cpp='$CPP $CPPFLAGS'\nac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_c_compiler_gnu\n\nac_ext=c\nac_cpp='$CPP $CPPFLAGS'\nac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_c_compiler_gnu\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together\" >&5\n$as_echo_n \"checking whether $CC understands -c and -o together... \" >&6; }\nif ${am_cv_prog_cc_c_o+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\n  # Make sure it works both with $CC and with simple cc.\n  # Following AC_PROG_CC_C_O, we do the test twice because some\n  # compilers refuse to overwrite an existing .o file with -o,\n  # though they will create one.\n  am_cv_prog_cc_c_o=yes\n  for am_i in 1 2; do\n    if { echo \"$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext\" >&5\n   ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5\n   ac_status=$?\n   echo \"$as_me:$LINENO: \\$? = $ac_status\" >&5\n   (exit $ac_status); } \\\n         && test -f conftest2.$ac_objext; then\n      : OK\n    else\n      am_cv_prog_cc_c_o=no\n      break\n    fi\n  done\n  rm -f core conftest*\n  unset am_i\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o\" >&5\n$as_echo \"$am_cv_prog_cc_c_o\" >&6; }\nif test \"$am_cv_prog_cc_c_o\" != yes; then\n   # Losing compiler, so override with the script.\n   # FIXME: It is wrong to rewrite CC.\n   # But if we don't then we get into trouble of one sort or another.\n   # A longer-term fix would be to have automake use am__CC in this case,\n   # and then we could set am__CC=\"\\$(top_srcdir)/compile \\$(CC)\"\n   CC=\"$am_aux_dir/compile $CC\"\nfi\nac_ext=c\nac_cpp='$CPP $CPPFLAGS'\nac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_c_compiler_gnu\n\nDEPDIR=\"${am__leading_dot}deps\"\n\nac_config_commands=\"$ac_config_commands depfiles\"\n\n\nam_make=${MAKE-make}\ncat > confinc << 'END'\nam__doit:\n\t@echo this is the am__doit target\n.PHONY: am__doit\nEND\n# If we don't find an include directive, just comment out the code.\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make\" >&5\n$as_echo_n \"checking for style of include used by $am_make... \" >&6; }\nam__include=\"#\"\nam__quote=\n_am_result=none\n# First try GNU make style include.\necho \"include confinc\" > confmf\n# Ignore all kinds of additional output from 'make'.\ncase `$am_make -s -f confmf 2> /dev/null` in #(\n*the\\ am__doit\\ target*)\n  am__include=include\n  am__quote=\n  _am_result=GNU\n  ;;\nesac\n# Now try BSD make style include.\nif test \"$am__include\" = \"#\"; then\n   echo '.include \"confinc\"' > confmf\n   case `$am_make -s -f confmf 2> /dev/null` in #(\n   *the\\ am__doit\\ target*)\n     am__include=.include\n     am__quote=\"\\\"\"\n     _am_result=BSD\n     ;;\n   esac\nfi\n\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $_am_result\" >&5\n$as_echo \"$_am_result\" >&6; }\nrm -f confinc confmf\n\n# Check whether --enable-dependency-tracking was given.\nif test \"${enable_dependency_tracking+set}\" = set; then :\n  enableval=$enable_dependency_tracking;\nfi\n\nif test \"x$enable_dependency_tracking\" != xno; then\n  am_depcomp=\"$ac_aux_dir/depcomp\"\n  AMDEPBACKSLASH='\\'\n  am__nodep='_no'\nfi\n if test \"x$enable_dependency_tracking\" != xno; then\n  AMDEP_TRUE=\n  AMDEP_FALSE='#'\nelse\n  AMDEP_TRUE='#'\n  AMDEP_FALSE=\nfi\n\n\n\ndepcc=\"$CC\"   am_compiler_list=\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc\" >&5\n$as_echo_n \"checking dependency style of $depcc... \" >&6; }\nif ${am_cv_CC_dependencies_compiler_type+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -z \"$AMDEP_TRUE\" && test -f \"$am_depcomp\"; then\n  # We make a subdir and do the tests there.  Otherwise we can end up\n  # making bogus files that we don't know about and never remove.  For\n  # instance it was reported that on HP-UX the gcc test will end up\n  # making a dummy file named 'D' -- because '-MD' means \"put the output\n  # in D\".\n  rm -rf conftest.dir\n  mkdir conftest.dir\n  # Copy depcomp to subdir because otherwise we won't find it if we're\n  # using a relative directory.\n  cp \"$am_depcomp\" conftest.dir\n  cd conftest.dir\n  # We will build objects and dependencies in a subdirectory because\n  # it helps to detect inapplicable dependency modes.  For instance\n  # both Tru64's cc and ICC support -MD to output dependencies as a\n  # side effect of compilation, but ICC will put the dependencies in\n  # the current directory while Tru64 will put them in the object\n  # directory.\n  mkdir sub\n\n  am_cv_CC_dependencies_compiler_type=none\n  if test \"$am_compiler_list\" = \"\"; then\n     am_compiler_list=`sed -n 's/^#*\\([a-zA-Z0-9]*\\))$/\\1/p' < ./depcomp`\n  fi\n  am__universal=false\n  case \" $depcc \" in #(\n     *\\ -arch\\ *\\ -arch\\ *) am__universal=true ;;\n     esac\n\n  for depmode in $am_compiler_list; do\n    # Setup a source with many dependencies, because some compilers\n    # like to wrap large dependency lists on column 80 (with \\), and\n    # we should not choose a depcomp mode which is confused by this.\n    #\n    # We need to recreate these files for each test, as the compiler may\n    # overwrite some of them when testing with obscure command lines.\n    # This happens at least with the AIX C compiler.\n    : > sub/conftest.c\n    for i in 1 2 3 4 5 6; do\n      echo '#include \"conftst'$i'.h\"' >> sub/conftest.c\n      # Using \": > sub/conftst$i.h\" creates only sub/conftst1.h with\n      # Solaris 10 /bin/sh.\n      echo '/* dummy */' > sub/conftst$i.h\n    done\n    echo \"${am__include} ${am__quote}sub/conftest.Po${am__quote}\" > confmf\n\n    # We check with '-c' and '-o' for the sake of the \"dashmstdout\"\n    # mode.  It turns out that the SunPro C++ compiler does not properly\n    # handle '-M -o', and we need to detect this.  Also, some Intel\n    # versions had trouble with output in subdirs.\n    am__obj=sub/conftest.${OBJEXT-o}\n    am__minus_obj=\"-o $am__obj\"\n    case $depmode in\n    gcc)\n      # This depmode causes a compiler race in universal mode.\n      test \"$am__universal\" = false || continue\n      ;;\n    nosideeffect)\n      # After this tag, mechanisms are not by side-effect, so they'll\n      # only be used when explicitly requested.\n      if test \"x$enable_dependency_tracking\" = xyes; then\n\tcontinue\n      else\n\tbreak\n      fi\n      ;;\n    msvc7 | msvc7msys | msvisualcpp | msvcmsys)\n      # This compiler won't grok '-c -o', but also, the minuso test has\n      # not run yet.  These depmodes are late enough in the game, and\n      # so weak that their functioning should not be impacted.\n      am__obj=conftest.${OBJEXT-o}\n      am__minus_obj=\n      ;;\n    none) break ;;\n    esac\n    if depmode=$depmode \\\n       source=sub/conftest.c object=$am__obj \\\n       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \\\n       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \\\n         >/dev/null 2>conftest.err &&\n       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&\n       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&\n       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&\n       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then\n      # icc doesn't choke on unknown options, it will just issue warnings\n      # or remarks (even with -Werror).  So we grep stderr for any message\n      # that says an option was ignored or not supported.\n      # When given -MP, icc 7.0 and 7.1 complain thusly:\n      #   icc: Command line warning: ignoring option '-M'; no argument required\n      # The diagnosis changed in icc 8.0:\n      #   icc: Command line remark: option '-MP' not supported\n      if (grep 'ignoring option' conftest.err ||\n          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else\n        am_cv_CC_dependencies_compiler_type=$depmode\n        break\n      fi\n    fi\n  done\n\n  cd ..\n  rm -rf conftest.dir\nelse\n  am_cv_CC_dependencies_compiler_type=none\nfi\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type\" >&5\n$as_echo \"$am_cv_CC_dependencies_compiler_type\" >&6; }\nCCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type\n\n if\n  test \"x$enable_dependency_tracking\" != xno \\\n  && test \"$am_cv_CC_dependencies_compiler_type\" = gcc3; then\n  am__fastdepCC_TRUE=\n  am__fastdepCC_FALSE='#'\nelse\n  am__fastdepCC_TRUE='#'\n  am__fastdepCC_FALSE=\nfi\n\n\nac_ext=cpp\nac_cpp='$CXXCPP $CPPFLAGS'\nac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_cxx_compiler_gnu\nif test -z \"$CXX\"; then\n  if test -n \"$CCC\"; then\n    CXX=$CCC\n  else\n    if test -n \"$ac_tool_prefix\"; then\n  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC\n  do\n    # Extract the first word of \"$ac_tool_prefix$ac_prog\", so it can be a program name with args.\nset dummy $ac_tool_prefix$ac_prog; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_CXX+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$CXX\"; then\n  ac_cv_prog_CXX=\"$CXX\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_CXX=\"$ac_tool_prefix$ac_prog\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nCXX=$ac_cv_prog_CXX\nif test -n \"$CXX\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $CXX\" >&5\n$as_echo \"$CXX\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\n    test -n \"$CXX\" && break\n  done\nfi\nif test -z \"$CXX\"; then\n  ac_ct_CXX=$CXX\n  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC\ndo\n  # Extract the first word of \"$ac_prog\", so it can be a program name with args.\nset dummy $ac_prog; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_ac_ct_CXX+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$ac_ct_CXX\"; then\n  ac_cv_prog_ac_ct_CXX=\"$ac_ct_CXX\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_ac_ct_CXX=\"$ac_prog\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nac_ct_CXX=$ac_cv_prog_ac_ct_CXX\nif test -n \"$ac_ct_CXX\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX\" >&5\n$as_echo \"$ac_ct_CXX\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\n  test -n \"$ac_ct_CXX\" && break\ndone\n\n  if test \"x$ac_ct_CXX\" = x; then\n    CXX=\"g++\"\n  else\n    case $cross_compiling:$ac_tool_warned in\nyes:)\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet\" >&5\n$as_echo \"$as_me: WARNING: using cross tools not prefixed with host triplet\" >&2;}\nac_tool_warned=yes ;;\nesac\n    CXX=$ac_ct_CXX\n  fi\nfi\n\n  fi\nfi\n# Provide some information about the compiler.\n$as_echo \"$as_me:${as_lineno-$LINENO}: checking for C++ compiler version\" >&5\nset X $ac_compile\nac_compiler=$2\nfor ac_option in --version -v -V -qversion; do\n  { { ac_try=\"$ac_compiler $ac_option >&5\"\ncase \"(($ac_try\" in\n  *\\\"* | *\\`* | *\\\\*) ac_try_echo=\\$ac_try;;\n  *) ac_try_echo=$ac_try;;\nesac\neval ac_try_echo=\"\\\"\\$as_me:${as_lineno-$LINENO}: $ac_try_echo\\\"\"\n$as_echo \"$ac_try_echo\"; } >&5\n  (eval \"$ac_compiler $ac_option >&5\") 2>conftest.err\n  ac_status=$?\n  if test -s conftest.err; then\n    sed '10a\\\n... rest of stderr output deleted ...\n         10q' conftest.err >conftest.er1\n    cat conftest.er1 >&5\n  fi\n  rm -f conftest.er1 conftest.err\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; }\ndone\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler\" >&5\n$as_echo_n \"checking whether we are using the GNU C++ compiler... \" >&6; }\nif ${ac_cv_cxx_compiler_gnu+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n#ifndef __GNUC__\n       choke me\n#endif\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_cxx_try_compile \"$LINENO\"; then :\n  ac_compiler_gnu=yes\nelse\n  ac_compiler_gnu=no\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\nac_cv_cxx_compiler_gnu=$ac_compiler_gnu\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu\" >&5\n$as_echo \"$ac_cv_cxx_compiler_gnu\" >&6; }\nif test $ac_compiler_gnu = yes; then\n  GXX=yes\nelse\n  GXX=\nfi\nac_test_CXXFLAGS=${CXXFLAGS+set}\nac_save_CXXFLAGS=$CXXFLAGS\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g\" >&5\n$as_echo_n \"checking whether $CXX accepts -g... \" >&6; }\nif ${ac_cv_prog_cxx_g+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  ac_save_cxx_werror_flag=$ac_cxx_werror_flag\n   ac_cxx_werror_flag=yes\n   ac_cv_prog_cxx_g=no\n   CXXFLAGS=\"-g\"\n   cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_cxx_try_compile \"$LINENO\"; then :\n  ac_cv_prog_cxx_g=yes\nelse\n  CXXFLAGS=\"\"\n      cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_cxx_try_compile \"$LINENO\"; then :\n\nelse\n  ac_cxx_werror_flag=$ac_save_cxx_werror_flag\n\t CXXFLAGS=\"-g\"\n\t cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_cxx_try_compile \"$LINENO\"; then :\n  ac_cv_prog_cxx_g=yes\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\n   ac_cxx_werror_flag=$ac_save_cxx_werror_flag\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g\" >&5\n$as_echo \"$ac_cv_prog_cxx_g\" >&6; }\nif test \"$ac_test_CXXFLAGS\" = set; then\n  CXXFLAGS=$ac_save_CXXFLAGS\nelif test $ac_cv_prog_cxx_g = yes; then\n  if test \"$GXX\" = yes; then\n    CXXFLAGS=\"-g -O2\"\n  else\n    CXXFLAGS=\"-g\"\n  fi\nelse\n  if test \"$GXX\" = yes; then\n    CXXFLAGS=\"-O2\"\n  else\n    CXXFLAGS=\n  fi\nfi\nac_ext=c\nac_cpp='$CPP $CPPFLAGS'\nac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_c_compiler_gnu\n\ndepcc=\"$CXX\"  am_compiler_list=\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc\" >&5\n$as_echo_n \"checking dependency style of $depcc... \" >&6; }\nif ${am_cv_CXX_dependencies_compiler_type+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -z \"$AMDEP_TRUE\" && test -f \"$am_depcomp\"; then\n  # We make a subdir and do the tests there.  Otherwise we can end up\n  # making bogus files that we don't know about and never remove.  For\n  # instance it was reported that on HP-UX the gcc test will end up\n  # making a dummy file named 'D' -- because '-MD' means \"put the output\n  # in D\".\n  rm -rf conftest.dir\n  mkdir conftest.dir\n  # Copy depcomp to subdir because otherwise we won't find it if we're\n  # using a relative directory.\n  cp \"$am_depcomp\" conftest.dir\n  cd conftest.dir\n  # We will build objects and dependencies in a subdirectory because\n  # it helps to detect inapplicable dependency modes.  For instance\n  # both Tru64's cc and ICC support -MD to output dependencies as a\n  # side effect of compilation, but ICC will put the dependencies in\n  # the current directory while Tru64 will put them in the object\n  # directory.\n  mkdir sub\n\n  am_cv_CXX_dependencies_compiler_type=none\n  if test \"$am_compiler_list\" = \"\"; then\n     am_compiler_list=`sed -n 's/^#*\\([a-zA-Z0-9]*\\))$/\\1/p' < ./depcomp`\n  fi\n  am__universal=false\n  case \" $depcc \" in #(\n     *\\ -arch\\ *\\ -arch\\ *) am__universal=true ;;\n     esac\n\n  for depmode in $am_compiler_list; do\n    # Setup a source with many dependencies, because some compilers\n    # like to wrap large dependency lists on column 80 (with \\), and\n    # we should not choose a depcomp mode which is confused by this.\n    #\n    # We need to recreate these files for each test, as the compiler may\n    # overwrite some of them when testing with obscure command lines.\n    # This happens at least with the AIX C compiler.\n    : > sub/conftest.c\n    for i in 1 2 3 4 5 6; do\n      echo '#include \"conftst'$i'.h\"' >> sub/conftest.c\n      # Using \": > sub/conftst$i.h\" creates only sub/conftst1.h with\n      # Solaris 10 /bin/sh.\n      echo '/* dummy */' > sub/conftst$i.h\n    done\n    echo \"${am__include} ${am__quote}sub/conftest.Po${am__quote}\" > confmf\n\n    # We check with '-c' and '-o' for the sake of the \"dashmstdout\"\n    # mode.  It turns out that the SunPro C++ compiler does not properly\n    # handle '-M -o', and we need to detect this.  Also, some Intel\n    # versions had trouble with output in subdirs.\n    am__obj=sub/conftest.${OBJEXT-o}\n    am__minus_obj=\"-o $am__obj\"\n    case $depmode in\n    gcc)\n      # This depmode causes a compiler race in universal mode.\n      test \"$am__universal\" = false || continue\n      ;;\n    nosideeffect)\n      # After this tag, mechanisms are not by side-effect, so they'll\n      # only be used when explicitly requested.\n      if test \"x$enable_dependency_tracking\" = xyes; then\n\tcontinue\n      else\n\tbreak\n      fi\n      ;;\n    msvc7 | msvc7msys | msvisualcpp | msvcmsys)\n      # This compiler won't grok '-c -o', but also, the minuso test has\n      # not run yet.  These depmodes are late enough in the game, and\n      # so weak that their functioning should not be impacted.\n      am__obj=conftest.${OBJEXT-o}\n      am__minus_obj=\n      ;;\n    none) break ;;\n    esac\n    if depmode=$depmode \\\n       source=sub/conftest.c object=$am__obj \\\n       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \\\n       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \\\n         >/dev/null 2>conftest.err &&\n       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&\n       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&\n       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&\n       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then\n      # icc doesn't choke on unknown options, it will just issue warnings\n      # or remarks (even with -Werror).  So we grep stderr for any message\n      # that says an option was ignored or not supported.\n      # When given -MP, icc 7.0 and 7.1 complain thusly:\n      #   icc: Command line warning: ignoring option '-M'; no argument required\n      # The diagnosis changed in icc 8.0:\n      #   icc: Command line remark: option '-MP' not supported\n      if (grep 'ignoring option' conftest.err ||\n          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else\n        am_cv_CXX_dependencies_compiler_type=$depmode\n        break\n      fi\n    fi\n  done\n\n  cd ..\n  rm -rf conftest.dir\nelse\n  am_cv_CXX_dependencies_compiler_type=none\nfi\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type\" >&5\n$as_echo \"$am_cv_CXX_dependencies_compiler_type\" >&6; }\nCXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type\n\n if\n  test \"x$enable_dependency_tracking\" != xno \\\n  && test \"$am_cv_CXX_dependencies_compiler_type\" = gcc3; then\n  am__fastdepCXX_TRUE=\n  am__fastdepCXX_FALSE='#'\nelse\n  am__fastdepCXX_TRUE='#'\n  am__fastdepCXX_FALSE=\nfi\n\n\nac_ext=cpp\nac_cpp='$CXXCPP $CPPFLAGS'\nac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_cxx_compiler_gnu\n\n\nac_ext=cpp\nac_cpp='$CXXCPP $CPPFLAGS'\nac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_cxx_compiler_gnu\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor\" >&5\n$as_echo_n \"checking how to run the C++ preprocessor... \" >&6; }\nif test -z \"$CXXCPP\"; then\n  if ${ac_cv_prog_CXXCPP+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n      # Double quotes because CXXCPP needs to be expanded\n    for CXXCPP in \"$CXX -E\" \"/lib/cpp\"\n    do\n      ac_preproc_ok=false\nfor ac_cxx_preproc_warn_flag in '' yes\ndo\n  # Use a header file that comes with gcc, so configuring glibc\n  # with a fresh cross-compiler works.\n  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since\n  # <limits.h> exists even on freestanding compilers.\n  # On the NeXT, cc -E runs the code through the compiler's parser,\n  # not just through cpp. \"Syntax error\" is here to catch this case.\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#ifdef __STDC__\n# include <limits.h>\n#else\n# include <assert.h>\n#endif\n\t\t     Syntax error\n_ACEOF\nif ac_fn_cxx_try_cpp \"$LINENO\"; then :\n\nelse\n  # Broken: fails on valid input.\ncontinue\nfi\nrm -f conftest.err conftest.i conftest.$ac_ext\n\n  # OK, works on sane cases.  Now check whether nonexistent headers\n  # can be detected and how.\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <ac_nonexistent.h>\n_ACEOF\nif ac_fn_cxx_try_cpp \"$LINENO\"; then :\n  # Broken: success on invalid input.\ncontinue\nelse\n  # Passes both tests.\nac_preproc_ok=:\nbreak\nfi\nrm -f conftest.err conftest.i conftest.$ac_ext\n\ndone\n# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.\nrm -f conftest.i conftest.err conftest.$ac_ext\nif $ac_preproc_ok; then :\n  break\nfi\n\n    done\n    ac_cv_prog_CXXCPP=$CXXCPP\n\nfi\n  CXXCPP=$ac_cv_prog_CXXCPP\nelse\n  ac_cv_prog_CXXCPP=$CXXCPP\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $CXXCPP\" >&5\n$as_echo \"$CXXCPP\" >&6; }\nac_preproc_ok=false\nfor ac_cxx_preproc_warn_flag in '' yes\ndo\n  # Use a header file that comes with gcc, so configuring glibc\n  # with a fresh cross-compiler works.\n  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since\n  # <limits.h> exists even on freestanding compilers.\n  # On the NeXT, cc -E runs the code through the compiler's parser,\n  # not just through cpp. \"Syntax error\" is here to catch this case.\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#ifdef __STDC__\n# include <limits.h>\n#else\n# include <assert.h>\n#endif\n\t\t     Syntax error\n_ACEOF\nif ac_fn_cxx_try_cpp \"$LINENO\"; then :\n\nelse\n  # Broken: fails on valid input.\ncontinue\nfi\nrm -f conftest.err conftest.i conftest.$ac_ext\n\n  # OK, works on sane cases.  Now check whether nonexistent headers\n  # can be detected and how.\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <ac_nonexistent.h>\n_ACEOF\nif ac_fn_cxx_try_cpp \"$LINENO\"; then :\n  # Broken: success on invalid input.\ncontinue\nelse\n  # Passes both tests.\nac_preproc_ok=:\nbreak\nfi\nrm -f conftest.err conftest.i conftest.$ac_ext\n\ndone\n# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.\nrm -f conftest.i conftest.err conftest.$ac_ext\nif $ac_preproc_ok; then :\n\nelse\n  { { $as_echo \"$as_me:${as_lineno-$LINENO}: error: in \\`$ac_pwd':\" >&5\n$as_echo \"$as_me: error: in \\`$ac_pwd':\" >&2;}\nas_fn_error $? \"C++ preprocessor \\\"$CXXCPP\\\" fails sanity check\nSee \\`config.log' for more details\" \"$LINENO\" 5; }\nfi\n\nac_ext=cpp\nac_cpp='$CXXCPP $CPPFLAGS'\nac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_cxx_compiler_gnu\n\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e\" >&5\n$as_echo_n \"checking for grep that handles long lines and -e... \" >&6; }\nif ${ac_cv_path_GREP+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -z \"$GREP\"; then\n  ac_path_GREP_found=false\n  # Loop through the user's path and test for each of PROGNAME-LIST\n  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_prog in grep ggrep; do\n    for ac_exec_ext in '' $ac_executable_extensions; do\n      ac_path_GREP=\"$as_dir/$ac_prog$ac_exec_ext\"\n      as_fn_executable_p \"$ac_path_GREP\" || continue\n# Check for GNU ac_path_GREP and select it if it is found.\n  # Check for GNU $ac_path_GREP\ncase `\"$ac_path_GREP\" --version 2>&1` in\n*GNU*)\n  ac_cv_path_GREP=\"$ac_path_GREP\" ac_path_GREP_found=:;;\n*)\n  ac_count=0\n  $as_echo_n 0123456789 >\"conftest.in\"\n  while :\n  do\n    cat \"conftest.in\" \"conftest.in\" >\"conftest.tmp\"\n    mv \"conftest.tmp\" \"conftest.in\"\n    cp \"conftest.in\" \"conftest.nl\"\n    $as_echo 'GREP' >> \"conftest.nl\"\n    \"$ac_path_GREP\" -e 'GREP$' -e '-(cannot match)-' < \"conftest.nl\" >\"conftest.out\" 2>/dev/null || break\n    diff \"conftest.out\" \"conftest.nl\" >/dev/null 2>&1 || break\n    as_fn_arith $ac_count + 1 && ac_count=$as_val\n    if test $ac_count -gt ${ac_path_GREP_max-0}; then\n      # Best one so far, save it but keep looking for a better one\n      ac_cv_path_GREP=\"$ac_path_GREP\"\n      ac_path_GREP_max=$ac_count\n    fi\n    # 10*(2^10) chars as input seems more than enough\n    test $ac_count -gt 10 && break\n  done\n  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;\nesac\n\n      $ac_path_GREP_found && break 3\n    done\n  done\n  done\nIFS=$as_save_IFS\n  if test -z \"$ac_cv_path_GREP\"; then\n    as_fn_error $? \"no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin\" \"$LINENO\" 5\n  fi\nelse\n  ac_cv_path_GREP=$GREP\nfi\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP\" >&5\n$as_echo \"$ac_cv_path_GREP\" >&6; }\n GREP=\"$ac_cv_path_GREP\"\n\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for egrep\" >&5\n$as_echo_n \"checking for egrep... \" >&6; }\nif ${ac_cv_path_EGREP+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1\n   then ac_cv_path_EGREP=\"$GREP -E\"\n   else\n     if test -z \"$EGREP\"; then\n  ac_path_EGREP_found=false\n  # Loop through the user's path and test for each of PROGNAME-LIST\n  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_prog in egrep; do\n    for ac_exec_ext in '' $ac_executable_extensions; do\n      ac_path_EGREP=\"$as_dir/$ac_prog$ac_exec_ext\"\n      as_fn_executable_p \"$ac_path_EGREP\" || continue\n# Check for GNU ac_path_EGREP and select it if it is found.\n  # Check for GNU $ac_path_EGREP\ncase `\"$ac_path_EGREP\" --version 2>&1` in\n*GNU*)\n  ac_cv_path_EGREP=\"$ac_path_EGREP\" ac_path_EGREP_found=:;;\n*)\n  ac_count=0\n  $as_echo_n 0123456789 >\"conftest.in\"\n  while :\n  do\n    cat \"conftest.in\" \"conftest.in\" >\"conftest.tmp\"\n    mv \"conftest.tmp\" \"conftest.in\"\n    cp \"conftest.in\" \"conftest.nl\"\n    $as_echo 'EGREP' >> \"conftest.nl\"\n    \"$ac_path_EGREP\" 'EGREP$' < \"conftest.nl\" >\"conftest.out\" 2>/dev/null || break\n    diff \"conftest.out\" \"conftest.nl\" >/dev/null 2>&1 || break\n    as_fn_arith $ac_count + 1 && ac_count=$as_val\n    if test $ac_count -gt ${ac_path_EGREP_max-0}; then\n      # Best one so far, save it but keep looking for a better one\n      ac_cv_path_EGREP=\"$ac_path_EGREP\"\n      ac_path_EGREP_max=$ac_count\n    fi\n    # 10*(2^10) chars as input seems more than enough\n    test $ac_count -gt 10 && break\n  done\n  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;\nesac\n\n      $ac_path_EGREP_found && break 3\n    done\n  done\n  done\nIFS=$as_save_IFS\n  if test -z \"$ac_cv_path_EGREP\"; then\n    as_fn_error $? \"no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin\" \"$LINENO\" 5\n  fi\nelse\n  ac_cv_path_EGREP=$EGREP\nfi\n\n   fi\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP\" >&5\n$as_echo \"$ac_cv_path_EGREP\" >&6; }\n EGREP=\"$ac_cv_path_EGREP\"\n\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for ANSI C header files\" >&5\n$as_echo_n \"checking for ANSI C header files... \" >&6; }\nif ${ac_cv_header_stdc+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <stdlib.h>\n#include <stdarg.h>\n#include <string.h>\n#include <float.h>\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_cxx_try_compile \"$LINENO\"; then :\n  ac_cv_header_stdc=yes\nelse\n  ac_cv_header_stdc=no\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\n\nif test $ac_cv_header_stdc = yes; then\n  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <string.h>\n\n_ACEOF\nif (eval \"$ac_cpp conftest.$ac_ext\") 2>&5 |\n  $EGREP \"memchr\" >/dev/null 2>&1; then :\n\nelse\n  ac_cv_header_stdc=no\nfi\nrm -f conftest*\n\nfi\n\nif test $ac_cv_header_stdc = yes; then\n  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <stdlib.h>\n\n_ACEOF\nif (eval \"$ac_cpp conftest.$ac_ext\") 2>&5 |\n  $EGREP \"free\" >/dev/null 2>&1; then :\n\nelse\n  ac_cv_header_stdc=no\nfi\nrm -f conftest*\n\nfi\n\nif test $ac_cv_header_stdc = yes; then\n  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.\n  if test \"$cross_compiling\" = yes; then :\n  :\nelse\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <ctype.h>\n#include <stdlib.h>\n#if ((' ' & 0x0FF) == 0x020)\n# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')\n# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))\n#else\n# define ISLOWER(c) \\\n\t\t   (('a' <= (c) && (c) <= 'i') \\\n\t\t     || ('j' <= (c) && (c) <= 'r') \\\n\t\t     || ('s' <= (c) && (c) <= 'z'))\n# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))\n#endif\n\n#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))\nint\nmain ()\n{\n  int i;\n  for (i = 0; i < 256; i++)\n    if (XOR (islower (i), ISLOWER (i))\n\t|| toupper (i) != TOUPPER (i))\n      return 2;\n  return 0;\n}\n_ACEOF\nif ac_fn_cxx_try_run \"$LINENO\"; then :\n\nelse\n  ac_cv_header_stdc=no\nfi\nrm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \\\n  conftest.$ac_objext conftest.beam conftest.$ac_ext\nfi\n\nfi\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc\" >&5\n$as_echo \"$ac_cv_header_stdc\" >&6; }\nif test $ac_cv_header_stdc = yes; then\n\n$as_echo \"#define STDC_HEADERS 1\" >>confdefs.h\n\nfi\n\n# On IRIX 5.3, sys/types and inttypes.h are conflicting.\nfor ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \\\n\t\t  inttypes.h stdint.h unistd.h\ndo :\n  as_ac_Header=`$as_echo \"ac_cv_header_$ac_header\" | $as_tr_sh`\nac_fn_cxx_check_header_compile \"$LINENO\" \"$ac_header\" \"$as_ac_Header\" \"$ac_includes_default\n\"\nif eval test \\\"x\\$\"$as_ac_Header\"\\\" = x\"yes\"; then :\n  cat >>confdefs.h <<_ACEOF\n#define `$as_echo \"HAVE_$ac_header\" | $as_tr_cpp` 1\n_ACEOF\n\nfi\n\ndone\n\n\n\n  ac_fn_cxx_check_header_mongrel \"$LINENO\" \"minix/config.h\" \"ac_cv_header_minix_config_h\" \"$ac_includes_default\"\nif test \"x$ac_cv_header_minix_config_h\" = xyes; then :\n  MINIX=yes\nelse\n  MINIX=\nfi\n\n\n  if test \"$MINIX\" = yes; then\n\n$as_echo \"#define _POSIX_SOURCE 1\" >>confdefs.h\n\n\n$as_echo \"#define _POSIX_1_SOURCE 2\" >>confdefs.h\n\n\n$as_echo \"#define _MINIX 1\" >>confdefs.h\n\n  fi\n\n\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__\" >&5\n$as_echo_n \"checking whether it is safe to define __EXTENSIONS__... \" >&6; }\nif ${ac_cv_safe_to_define___extensions__+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\n#         define __EXTENSIONS__ 1\n          $ac_includes_default\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_cxx_try_compile \"$LINENO\"; then :\n  ac_cv_safe_to_define___extensions__=yes\nelse\n  ac_cv_safe_to_define___extensions__=no\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__\" >&5\n$as_echo \"$ac_cv_safe_to_define___extensions__\" >&6; }\n  test $ac_cv_safe_to_define___extensions__ = yes &&\n    $as_echo \"#define __EXTENSIONS__ 1\" >>confdefs.h\n\n  $as_echo \"#define _ALL_SOURCE 1\" >>confdefs.h\n\n  $as_echo \"#define _GNU_SOURCE 1\" >>confdefs.h\n\n  $as_echo \"#define _POSIX_PTHREAD_SEMANTICS 1\" >>confdefs.h\n\n  $as_echo \"#define _TANDEM_SOURCE 1\" >>confdefs.h\n\n\n\n\n\n\n\n\nif test -n \"$ac_tool_prefix\"; then\n  for ac_prog in ar lib \"link -lib\"\n  do\n    # Extract the first word of \"$ac_tool_prefix$ac_prog\", so it can be a program name with args.\nset dummy $ac_tool_prefix$ac_prog; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_AR+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$AR\"; then\n  ac_cv_prog_AR=\"$AR\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_AR=\"$ac_tool_prefix$ac_prog\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nAR=$ac_cv_prog_AR\nif test -n \"$AR\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $AR\" >&5\n$as_echo \"$AR\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\n    test -n \"$AR\" && break\n  done\nfi\nif test -z \"$AR\"; then\n  ac_ct_AR=$AR\n  for ac_prog in ar lib \"link -lib\"\ndo\n  # Extract the first word of \"$ac_prog\", so it can be a program name with args.\nset dummy $ac_prog; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_ac_ct_AR+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$ac_ct_AR\"; then\n  ac_cv_prog_ac_ct_AR=\"$ac_ct_AR\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_ac_ct_AR=\"$ac_prog\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nac_ct_AR=$ac_cv_prog_ac_ct_AR\nif test -n \"$ac_ct_AR\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR\" >&5\n$as_echo \"$ac_ct_AR\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\n  test -n \"$ac_ct_AR\" && break\ndone\n\n  if test \"x$ac_ct_AR\" = x; then\n    AR=\"false\"\n  else\n    case $cross_compiling:$ac_tool_warned in\nyes:)\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet\" >&5\n$as_echo \"$as_me: WARNING: using cross tools not prefixed with host triplet\" >&2;}\nac_tool_warned=yes ;;\nesac\n    AR=$ac_ct_AR\n  fi\nfi\n\n: ${AR=ar}\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking the archiver ($AR) interface\" >&5\n$as_echo_n \"checking the archiver ($AR) interface... \" >&6; }\nif ${am_cv_ar_interface+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  ac_ext=c\nac_cpp='$CPP $CPPFLAGS'\nac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_c_compiler_gnu\n\n   am_cv_ar_interface=ar\n   cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\nint some_variable = 0;\n_ACEOF\nif ac_fn_c_try_compile \"$LINENO\"; then :\n  am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&5'\n      { { eval echo \"\\\"\\$as_me\\\":${as_lineno-$LINENO}: \\\"$am_ar_try\\\"\"; } >&5\n  (eval $am_ar_try) 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; }\n      if test \"$ac_status\" -eq 0; then\n        am_cv_ar_interface=ar\n      else\n        am_ar_try='$AR -NOLOGO -OUT:conftest.lib conftest.$ac_objext >&5'\n        { { eval echo \"\\\"\\$as_me\\\":${as_lineno-$LINENO}: \\\"$am_ar_try\\\"\"; } >&5\n  (eval $am_ar_try) 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; }\n        if test \"$ac_status\" -eq 0; then\n          am_cv_ar_interface=lib\n        else\n          am_cv_ar_interface=unknown\n        fi\n      fi\n      rm -f conftest.lib libconftest.a\n\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\n   ac_ext=cpp\nac_cpp='$CXXCPP $CPPFLAGS'\nac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_cxx_compiler_gnu\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $am_cv_ar_interface\" >&5\n$as_echo \"$am_cv_ar_interface\" >&6; }\n\ncase $am_cv_ar_interface in\nar)\n  ;;\nlib)\n  # Microsoft lib, so override with the ar-lib wrapper script.\n  # FIXME: It is wrong to rewrite AR.\n  # But if we don't then we get into trouble of one sort or another.\n  # A longer-term fix would be to have automake use am__AR in this case,\n  # and then we could set am__AR=\"$am_aux_dir/ar-lib \\$(AR)\" or something\n  # similar.\n  AR=\"$am_aux_dir/ar-lib $AR\"\n  ;;\nunknown)\n  as_fn_error $? \"could not determine $AR interface\" \"$LINENO\" 5\n  ;;\nesac\n\n if test \"$GCC\" = yes; then\n  GCC_TRUE=\n  GCC_FALSE='#'\nelse\n  GCC_TRUE='#'\n  GCC_FALSE=\nfi\n   # let the Makefile know if we're gcc\nac_ext=m\nac_cpp='$OBJCPP $CPPFLAGS'\nac_compile='$OBJC -c $OBJCFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$OBJC -o conftest$ac_exeext $OBJCFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_objc_compiler_gnu\nif test -n \"$ac_tool_prefix\"; then\n  for ac_prog in gcc objcc objc cc CC\n  do\n    # Extract the first word of \"$ac_tool_prefix$ac_prog\", so it can be a program name with args.\nset dummy $ac_tool_prefix$ac_prog; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_OBJC+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$OBJC\"; then\n  ac_cv_prog_OBJC=\"$OBJC\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_OBJC=\"$ac_tool_prefix$ac_prog\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nOBJC=$ac_cv_prog_OBJC\nif test -n \"$OBJC\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $OBJC\" >&5\n$as_echo \"$OBJC\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\n    test -n \"$OBJC\" && break\n  done\nfi\nif test -z \"$OBJC\"; then\n  ac_ct_OBJC=$OBJC\n  for ac_prog in gcc objcc objc cc CC\ndo\n  # Extract the first word of \"$ac_prog\", so it can be a program name with args.\nset dummy $ac_prog; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_ac_ct_OBJC+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$ac_ct_OBJC\"; then\n  ac_cv_prog_ac_ct_OBJC=\"$ac_ct_OBJC\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_ac_ct_OBJC=\"$ac_prog\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nac_ct_OBJC=$ac_cv_prog_ac_ct_OBJC\nif test -n \"$ac_ct_OBJC\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJC\" >&5\n$as_echo \"$ac_ct_OBJC\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\n  test -n \"$ac_ct_OBJC\" && break\ndone\n\n  if test \"x$ac_ct_OBJC\" = x; then\n    OBJC=\"gcc\"\n  else\n    case $cross_compiling:$ac_tool_warned in\nyes:)\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet\" >&5\n$as_echo \"$as_me: WARNING: using cross tools not prefixed with host triplet\" >&2;}\nac_tool_warned=yes ;;\nesac\n    OBJC=$ac_ct_OBJC\n  fi\nfi\n\n# Provide some information about the compiler.\n$as_echo \"$as_me:${as_lineno-$LINENO}: checking for Objective C compiler version\" >&5\nset X $ac_compile\nac_compiler=$2\nfor ac_option in --version -v -V -qversion; do\n  { { ac_try=\"$ac_compiler $ac_option >&5\"\ncase \"(($ac_try\" in\n  *\\\"* | *\\`* | *\\\\*) ac_try_echo=\\$ac_try;;\n  *) ac_try_echo=$ac_try;;\nesac\neval ac_try_echo=\"\\\"\\$as_me:${as_lineno-$LINENO}: $ac_try_echo\\\"\"\n$as_echo \"$ac_try_echo\"; } >&5\n  (eval \"$ac_compiler $ac_option >&5\") 2>conftest.err\n  ac_status=$?\n  if test -s conftest.err; then\n    sed '10a\\\n... rest of stderr output deleted ...\n         10q' conftest.err >conftest.er1\n    cat conftest.er1 >&5\n  fi\n  rm -f conftest.er1 conftest.err\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; }\ndone\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU Objective C compiler\" >&5\n$as_echo_n \"checking whether we are using the GNU Objective C compiler... \" >&6; }\nif ${ac_cv_objc_compiler_gnu+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n#ifndef __GNUC__\n       choke me\n#endif\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_objc_try_compile \"$LINENO\"; then :\n  ac_compiler_gnu=yes\nelse\n  ac_compiler_gnu=no\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\nac_cv_objc_compiler_gnu=$ac_compiler_gnu\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_objc_compiler_gnu\" >&5\n$as_echo \"$ac_cv_objc_compiler_gnu\" >&6; }\nif test $ac_compiler_gnu = yes; then\n  GOBJC=yes\nelse\n  GOBJC=\nfi\nac_test_OBJCFLAGS=${OBJCFLAGS+set}\nac_save_OBJCFLAGS=$OBJCFLAGS\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether $OBJC accepts -g\" >&5\n$as_echo_n \"checking whether $OBJC accepts -g... \" >&6; }\nif ${ac_cv_prog_objc_g+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  ac_save_objc_werror_flag=$ac_objc_werror_flag\n   ac_objc_werror_flag=yes\n   ac_cv_prog_objc_g=no\n   OBJCFLAGS=\"-g\"\n   cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_objc_try_compile \"$LINENO\"; then :\n  ac_cv_prog_objc_g=yes\nelse\n  OBJCFLAGS=\"\"\n      cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_objc_try_compile \"$LINENO\"; then :\n\nelse\n  ac_objc_werror_flag=$ac_save_objc_werror_flag\n\t OBJCFLAGS=\"-g\"\n\t cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_objc_try_compile \"$LINENO\"; then :\n  ac_cv_prog_objc_g=yes\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\n   ac_objc_werror_flag=$ac_save_objc_werror_flag\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_objc_g\" >&5\n$as_echo \"$ac_cv_prog_objc_g\" >&6; }\nif test \"$ac_test_OBJCFLAGS\" = set; then\n  OBJCFLAGS=$ac_save_OBJCFLAGS\nelif test $ac_cv_prog_objc_g = yes; then\n  if test \"$GOBJC\" = yes; then\n    OBJCFLAGS=\"-g -O2\"\n  else\n    OBJCFLAGS=\"-g\"\n  fi\nelse\n  if test \"$GOBJC\" = yes; then\n    OBJCFLAGS=\"-O2\"\n  else\n    OBJCFLAGS=\n  fi\nfi\nac_ext=cpp\nac_cpp='$CXXCPP $CPPFLAGS'\nac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_cxx_compiler_gnu\n\ndepcc=\"$OBJC\" am_compiler_list='gcc3 gcc'\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc\" >&5\n$as_echo_n \"checking dependency style of $depcc... \" >&6; }\nif ${am_cv_OBJC_dependencies_compiler_type+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -z \"$AMDEP_TRUE\" && test -f \"$am_depcomp\"; then\n  # We make a subdir and do the tests there.  Otherwise we can end up\n  # making bogus files that we don't know about and never remove.  For\n  # instance it was reported that on HP-UX the gcc test will end up\n  # making a dummy file named 'D' -- because '-MD' means \"put the output\n  # in D\".\n  rm -rf conftest.dir\n  mkdir conftest.dir\n  # Copy depcomp to subdir because otherwise we won't find it if we're\n  # using a relative directory.\n  cp \"$am_depcomp\" conftest.dir\n  cd conftest.dir\n  # We will build objects and dependencies in a subdirectory because\n  # it helps to detect inapplicable dependency modes.  For instance\n  # both Tru64's cc and ICC support -MD to output dependencies as a\n  # side effect of compilation, but ICC will put the dependencies in\n  # the current directory while Tru64 will put them in the object\n  # directory.\n  mkdir sub\n\n  am_cv_OBJC_dependencies_compiler_type=none\n  if test \"$am_compiler_list\" = \"\"; then\n     am_compiler_list=`sed -n 's/^#*\\([a-zA-Z0-9]*\\))$/\\1/p' < ./depcomp`\n  fi\n  am__universal=false\n\n\n  for depmode in $am_compiler_list; do\n    # Setup a source with many dependencies, because some compilers\n    # like to wrap large dependency lists on column 80 (with \\), and\n    # we should not choose a depcomp mode which is confused by this.\n    #\n    # We need to recreate these files for each test, as the compiler may\n    # overwrite some of them when testing with obscure command lines.\n    # This happens at least with the AIX C compiler.\n    : > sub/conftest.c\n    for i in 1 2 3 4 5 6; do\n      echo '#include \"conftst'$i'.h\"' >> sub/conftest.c\n      # Using \": > sub/conftst$i.h\" creates only sub/conftst1.h with\n      # Solaris 10 /bin/sh.\n      echo '/* dummy */' > sub/conftst$i.h\n    done\n    echo \"${am__include} ${am__quote}sub/conftest.Po${am__quote}\" > confmf\n\n    # We check with '-c' and '-o' for the sake of the \"dashmstdout\"\n    # mode.  It turns out that the SunPro C++ compiler does not properly\n    # handle '-M -o', and we need to detect this.  Also, some Intel\n    # versions had trouble with output in subdirs.\n    am__obj=sub/conftest.${OBJEXT-o}\n    am__minus_obj=\"-o $am__obj\"\n    case $depmode in\n    gcc)\n      # This depmode causes a compiler race in universal mode.\n      test \"$am__universal\" = false || continue\n      ;;\n    nosideeffect)\n      # After this tag, mechanisms are not by side-effect, so they'll\n      # only be used when explicitly requested.\n      if test \"x$enable_dependency_tracking\" = xyes; then\n\tcontinue\n      else\n\tbreak\n      fi\n      ;;\n    msvc7 | msvc7msys | msvisualcpp | msvcmsys)\n      # This compiler won't grok '-c -o', but also, the minuso test has\n      # not run yet.  These depmodes are late enough in the game, and\n      # so weak that their functioning should not be impacted.\n      am__obj=conftest.${OBJEXT-o}\n      am__minus_obj=\n      ;;\n    none) break ;;\n    esac\n    if depmode=$depmode \\\n       source=sub/conftest.c object=$am__obj \\\n       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \\\n       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \\\n         >/dev/null 2>conftest.err &&\n       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&\n       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&\n       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&\n       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then\n      # icc doesn't choke on unknown options, it will just issue warnings\n      # or remarks (even with -Werror).  So we grep stderr for any message\n      # that says an option was ignored or not supported.\n      # When given -MP, icc 7.0 and 7.1 complain thusly:\n      #   icc: Command line warning: ignoring option '-M'; no argument required\n      # The diagnosis changed in icc 8.0:\n      #   icc: Command line remark: option '-MP' not supported\n      if (grep 'ignoring option' conftest.err ||\n          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else\n        am_cv_OBJC_dependencies_compiler_type=$depmode\n        break\n      fi\n    fi\n  done\n\n  cd ..\n  rm -rf conftest.dir\nelse\n  am_cv_OBJC_dependencies_compiler_type=none\nfi\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $am_cv_OBJC_dependencies_compiler_type\" >&5\n$as_echo \"$am_cv_OBJC_dependencies_compiler_type\" >&6; }\nOBJCDEPMODE=depmode=$am_cv_OBJC_dependencies_compiler_type\n\n if\n  test \"x$enable_dependency_tracking\" != xno \\\n  && test \"$am_cv_OBJC_dependencies_compiler_type\" = gcc3; then\n  am__fastdepOBJC_TRUE=\n  am__fastdepOBJC_FALSE='#'\nelse\n  am__fastdepOBJC_TRUE='#'\n  am__fastdepOBJC_FALSE=\nfi\n\n\n\n# test_util.cc takes forever to compile with GCC and optimization turned on.\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking C++ compiler flags...\" >&5\n$as_echo_n \"checking C++ compiler flags...... \" >&6; }\nif test \"x${ac_cv_env_CXXFLAGS_set}\" = \"x\"; then :\n\n  if test \"$GCC\" = \"yes\"; then :\n\n    PROTOBUF_OPT_FLAG=\"-O2\"\n    CXXFLAGS=\"${CXXFLAGS} -g\"\n\nfi\n\n  # Protocol Buffers contains several checks that are intended to be used only\n  # for debugging and which might hurt performance.  Most users are probably\n  # end users who don't want these checks, so add -DNDEBUG by default.\n  CXXFLAGS=\"$CXXFLAGS -DNDEBUG\"\n\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: use default: $PROTOBUF_OPT_FLAG $CXXFLAGS\" >&5\n$as_echo \"use default: $PROTOBUF_OPT_FLAG $CXXFLAGS\" >&6; }\n\nelse\n\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: use user-supplied: $CXXFLAGS\" >&5\n$as_echo \"use user-supplied: $CXXFLAGS\" >&6; }\n\nfi\n\n\n\n\n\n  ac_ext=cpp\nac_cpp='$CXXCPP $CPPFLAGS'\nac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_cxx_compiler_gnu\n\n  ac_fn_cxx_check_decl \"$LINENO\" \"__SUNPRO_CC\" \"ac_cv_have_decl___SUNPRO_CC\" \"$ac_includes_default\"\nif test \"x$ac_cv_have_decl___SUNPRO_CC\" = xyes; then :\n  SUNCC=\"yes\"\nelse\n  SUNCC=\"no\"\nfi\n\n  ac_ext=cpp\nac_cpp='$CXXCPP $CPPFLAGS'\nac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_cxx_compiler_gnu\n\n\n\n  # Check whether --enable-64bit-solaris was given.\nif test \"${enable_64bit_solaris+set}\" = set; then :\n  enableval=$enable_64bit_solaris; ac_enable_64bit=\"$enableval\"\nelse\n  ac_enable_64bit=\"yes\"\nfi\n\n\n  if test \"$SUNCC\" = \"yes\" -a \"x${ac_cv_env_CXXFLAGS_set}\" = \"x\"; then :\n\n            CXXFLAGS=\"-g0 -xO3 -xlibmil -xdepend -xbuiltin -mt -compat=5 -library=stlport4 -library=Crun -template=no%extdef ${CXXFLAGS}\"\n\nfi\n\n  case $host_os in\n    *solaris*)\n      for ac_prog in isainfo\ndo\n  # Extract the first word of \"$ac_prog\", so it can be a program name with args.\nset dummy $ac_prog; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_ISAINFO+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$ISAINFO\"; then\n  ac_cv_prog_ISAINFO=\"$ISAINFO\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_ISAINFO=\"$ac_prog\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nISAINFO=$ac_cv_prog_ISAINFO\nif test -n \"$ISAINFO\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ISAINFO\" >&5\n$as_echo \"$ISAINFO\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\n  test -n \"$ISAINFO\" && break\ndone\ntest -n \"$ISAINFO\" || ISAINFO=\"no\"\n\n      if test \"x$ISAINFO\" != \"xno\"; then :\n  isainfo_b=`${ISAINFO} -b`\nelse\n  isainfo_b=\"x\"\nfi\n\n      if test \"$isainfo_b\" != \"x\"; then :\n\n\n        isainfo_k=`${ISAINFO} -k`\n\n        if test \"x$ac_enable_64bit\" = \"xyes\"; then :\n\n\n          if test \"x$libdir\" = \"x\\${exec_prefix}/lib\"; then :\n\n                                 libdir=\"${libdir}/${isainfo_k}\"\n\nfi\n\n                                        CXXFLAGS=\"${CXXFLAGS} -m64\"\n          ac_cv_env_CXXFLAGS_set=set\n          ac_cv_env_CXXFLAGS_value='-m64'\n\n          CFLAGS=\"${CFLAGS} -m64\"\n          ac_cv_env_CFLAGS_set=set\n          ac_cv_env_CFLAGS_value='-m64'\n\n          if test \"$target_cpu\" = \"sparc\" -a \"x$SUNCC\" = \"xyes\" ; then :\n\n            CXXFLAGS=\"-xmemalign=8s ${CXXFLAGS}\"\n\nfi\n\nfi\n\nfi\n    ;;\n  esac\n\n\n\n# Have to do libtool after SUNCC, other wise it \"helpfully\" adds Crun Cstd\n# to the link\ncase `pwd` in\n  *\\ * | *\\\t*)\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \\`pwd\\`\" >&5\n$as_echo \"$as_me: WARNING: Libtool does not cope well with whitespace in \\`pwd\\`\" >&2;} ;;\nesac\n\n\n\nmacro_version='2.4.2'\nmacro_revision='1.3337'\n\n\n\n\n\n\n\n\n\n\n\n\n\nltmain=\"$ac_aux_dir/ltmain.sh\"\n\n# Backslashify metacharacters that are still active within\n# double-quoted strings.\nsed_quote_subst='s/\\([\"`$\\\\]\\)/\\\\\\1/g'\n\n# Same as above, but do not quote variable references.\ndouble_quote_subst='s/\\([\"`\\\\]\\)/\\\\\\1/g'\n\n# Sed substitution to delay expansion of an escaped shell variable in a\n# double_quote_subst'ed string.\ndelay_variable_subst='s/\\\\\\\\\\\\\\\\\\\\\\$/\\\\\\\\\\\\$/g'\n\n# Sed substitution to delay expansion of an escaped single quote.\ndelay_single_quote_subst='s/'\\''/'\\'\\\\\\\\\\\\\\'\\''/g'\n\n# Sed substitution to avoid accidental globbing in evaled expressions\nno_glob_subst='s/\\*/\\\\\\*/g'\n\nECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'\nECHO=$ECHO$ECHO$ECHO$ECHO$ECHO\nECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking how to print strings\" >&5\n$as_echo_n \"checking how to print strings... \" >&6; }\n# Test print first, because it will be a builtin if present.\nif test \"X`( print -r -- -n ) 2>/dev/null`\" = X-n && \\\n   test \"X`print -r -- $ECHO 2>/dev/null`\" = \"X$ECHO\"; then\n  ECHO='print -r --'\nelif test \"X`printf %s $ECHO 2>/dev/null`\" = \"X$ECHO\"; then\n  ECHO='printf %s\\n'\nelse\n  # Use this function as a fallback that always works.\n  func_fallback_echo ()\n  {\n    eval 'cat <<_LTECHO_EOF\n$1\n_LTECHO_EOF'\n  }\n  ECHO='func_fallback_echo'\nfi\n\n# func_echo_all arg...\n# Invoke $ECHO with all args, space-separated.\nfunc_echo_all ()\n{\n    $ECHO \"\"\n}\n\ncase \"$ECHO\" in\n  printf*) { $as_echo \"$as_me:${as_lineno-$LINENO}: result: printf\" >&5\n$as_echo \"printf\" >&6; } ;;\n  print*) { $as_echo \"$as_me:${as_lineno-$LINENO}: result: print -r\" >&5\n$as_echo \"print -r\" >&6; } ;;\n  *) { $as_echo \"$as_me:${as_lineno-$LINENO}: result: cat\" >&5\n$as_echo \"cat\" >&6; } ;;\nesac\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output\" >&5\n$as_echo_n \"checking for a sed that does not truncate output... \" >&6; }\nif ${ac_cv_path_SED+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n            ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/\n     for ac_i in 1 2 3 4 5 6 7; do\n       ac_script=\"$ac_script$as_nl$ac_script\"\n     done\n     echo \"$ac_script\" 2>/dev/null | sed 99q >conftest.sed\n     { ac_script=; unset ac_script;}\n     if test -z \"$SED\"; then\n  ac_path_SED_found=false\n  # Loop through the user's path and test for each of PROGNAME-LIST\n  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_prog in sed gsed; do\n    for ac_exec_ext in '' $ac_executable_extensions; do\n      ac_path_SED=\"$as_dir/$ac_prog$ac_exec_ext\"\n      as_fn_executable_p \"$ac_path_SED\" || continue\n# Check for GNU ac_path_SED and select it if it is found.\n  # Check for GNU $ac_path_SED\ncase `\"$ac_path_SED\" --version 2>&1` in\n*GNU*)\n  ac_cv_path_SED=\"$ac_path_SED\" ac_path_SED_found=:;;\n*)\n  ac_count=0\n  $as_echo_n 0123456789 >\"conftest.in\"\n  while :\n  do\n    cat \"conftest.in\" \"conftest.in\" >\"conftest.tmp\"\n    mv \"conftest.tmp\" \"conftest.in\"\n    cp \"conftest.in\" \"conftest.nl\"\n    $as_echo '' >> \"conftest.nl\"\n    \"$ac_path_SED\" -f conftest.sed < \"conftest.nl\" >\"conftest.out\" 2>/dev/null || break\n    diff \"conftest.out\" \"conftest.nl\" >/dev/null 2>&1 || break\n    as_fn_arith $ac_count + 1 && ac_count=$as_val\n    if test $ac_count -gt ${ac_path_SED_max-0}; then\n      # Best one so far, save it but keep looking for a better one\n      ac_cv_path_SED=\"$ac_path_SED\"\n      ac_path_SED_max=$ac_count\n    fi\n    # 10*(2^10) chars as input seems more than enough\n    test $ac_count -gt 10 && break\n  done\n  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;\nesac\n\n      $ac_path_SED_found && break 3\n    done\n  done\n  done\nIFS=$as_save_IFS\n  if test -z \"$ac_cv_path_SED\"; then\n    as_fn_error $? \"no acceptable sed could be found in \\$PATH\" \"$LINENO\" 5\n  fi\nelse\n  ac_cv_path_SED=$SED\nfi\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED\" >&5\n$as_echo \"$ac_cv_path_SED\" >&6; }\n SED=\"$ac_cv_path_SED\"\n  rm -f conftest.sed\n\ntest -z \"$SED\" && SED=sed\nXsed=\"$SED -e 1s/^X//\"\n\n\n\n\n\n\n\n\n\n\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for fgrep\" >&5\n$as_echo_n \"checking for fgrep... \" >&6; }\nif ${ac_cv_path_FGREP+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1\n   then ac_cv_path_FGREP=\"$GREP -F\"\n   else\n     if test -z \"$FGREP\"; then\n  ac_path_FGREP_found=false\n  # Loop through the user's path and test for each of PROGNAME-LIST\n  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_prog in fgrep; do\n    for ac_exec_ext in '' $ac_executable_extensions; do\n      ac_path_FGREP=\"$as_dir/$ac_prog$ac_exec_ext\"\n      as_fn_executable_p \"$ac_path_FGREP\" || continue\n# Check for GNU ac_path_FGREP and select it if it is found.\n  # Check for GNU $ac_path_FGREP\ncase `\"$ac_path_FGREP\" --version 2>&1` in\n*GNU*)\n  ac_cv_path_FGREP=\"$ac_path_FGREP\" ac_path_FGREP_found=:;;\n*)\n  ac_count=0\n  $as_echo_n 0123456789 >\"conftest.in\"\n  while :\n  do\n    cat \"conftest.in\" \"conftest.in\" >\"conftest.tmp\"\n    mv \"conftest.tmp\" \"conftest.in\"\n    cp \"conftest.in\" \"conftest.nl\"\n    $as_echo 'FGREP' >> \"conftest.nl\"\n    \"$ac_path_FGREP\" FGREP < \"conftest.nl\" >\"conftest.out\" 2>/dev/null || break\n    diff \"conftest.out\" \"conftest.nl\" >/dev/null 2>&1 || break\n    as_fn_arith $ac_count + 1 && ac_count=$as_val\n    if test $ac_count -gt ${ac_path_FGREP_max-0}; then\n      # Best one so far, save it but keep looking for a better one\n      ac_cv_path_FGREP=\"$ac_path_FGREP\"\n      ac_path_FGREP_max=$ac_count\n    fi\n    # 10*(2^10) chars as input seems more than enough\n    test $ac_count -gt 10 && break\n  done\n  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;\nesac\n\n      $ac_path_FGREP_found && break 3\n    done\n  done\n  done\nIFS=$as_save_IFS\n  if test -z \"$ac_cv_path_FGREP\"; then\n    as_fn_error $? \"no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin\" \"$LINENO\" 5\n  fi\nelse\n  ac_cv_path_FGREP=$FGREP\nfi\n\n   fi\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP\" >&5\n$as_echo \"$ac_cv_path_FGREP\" >&6; }\n FGREP=\"$ac_cv_path_FGREP\"\n\n\ntest -z \"$GREP\" && GREP=grep\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# Check whether --with-gnu-ld was given.\nif test \"${with_gnu_ld+set}\" = set; then :\n  withval=$with_gnu_ld; test \"$withval\" = no || with_gnu_ld=yes\nelse\n  with_gnu_ld=no\nfi\n\nac_prog=ld\nif test \"$GCC\" = yes; then\n  # Check if gcc -print-prog-name=ld gives a path.\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for ld used by $CC\" >&5\n$as_echo_n \"checking for ld used by $CC... \" >&6; }\n  case $host in\n  *-*-mingw*)\n    # gcc leaves a trailing carriage return which upsets mingw\n    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\\015'` ;;\n  *)\n    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;\n  esac\n  case $ac_prog in\n    # Accept absolute paths.\n    [\\\\/]* | ?:[\\\\/]*)\n      re_direlt='/[^/][^/]*/\\.\\./'\n      # Canonicalize the pathname of ld\n      ac_prog=`$ECHO \"$ac_prog\"| $SED 's%\\\\\\\\%/%g'`\n      while $ECHO \"$ac_prog\" | $GREP \"$re_direlt\" > /dev/null 2>&1; do\n\tac_prog=`$ECHO $ac_prog| $SED \"s%$re_direlt%/%\"`\n      done\n      test -z \"$LD\" && LD=\"$ac_prog\"\n      ;;\n  \"\")\n    # If it fails, then pretend we aren't using GCC.\n    ac_prog=ld\n    ;;\n  *)\n    # If it is relative, then search for the first ld in PATH.\n    with_gnu_ld=unknown\n    ;;\n  esac\nelif test \"$with_gnu_ld\" = yes; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for GNU ld\" >&5\n$as_echo_n \"checking for GNU ld... \" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for non-GNU ld\" >&5\n$as_echo_n \"checking for non-GNU ld... \" >&6; }\nfi\nif ${lt_cv_path_LD+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -z \"$LD\"; then\n  lt_save_ifs=\"$IFS\"; IFS=$PATH_SEPARATOR\n  for ac_dir in $PATH; do\n    IFS=\"$lt_save_ifs\"\n    test -z \"$ac_dir\" && ac_dir=.\n    if test -f \"$ac_dir/$ac_prog\" || test -f \"$ac_dir/$ac_prog$ac_exeext\"; then\n      lt_cv_path_LD=\"$ac_dir/$ac_prog\"\n      # Check to see if the program is GNU ld.  I'd rather use --version,\n      # but apparently some variants of GNU ld only accept -v.\n      # Break only if it was the GNU/non-GNU ld that we prefer.\n      case `\"$lt_cv_path_LD\" -v 2>&1 </dev/null` in\n      *GNU* | *'with BFD'*)\n\ttest \"$with_gnu_ld\" != no && break\n\t;;\n      *)\n\ttest \"$with_gnu_ld\" != yes && break\n\t;;\n      esac\n    fi\n  done\n  IFS=\"$lt_save_ifs\"\nelse\n  lt_cv_path_LD=\"$LD\" # Let the user override the test with a path.\nfi\nfi\n\nLD=\"$lt_cv_path_LD\"\nif test -n \"$LD\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $LD\" >&5\n$as_echo \"$LD\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\ntest -z \"$LD\" && as_fn_error $? \"no acceptable ld found in \\$PATH\" \"$LINENO\" 5\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld\" >&5\n$as_echo_n \"checking if the linker ($LD) is GNU ld... \" >&6; }\nif ${lt_cv_prog_gnu_ld+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  # I'd rather use --version here, but apparently some GNU lds only accept -v.\ncase `$LD -v 2>&1 </dev/null` in\n*GNU* | *'with BFD'*)\n  lt_cv_prog_gnu_ld=yes\n  ;;\n*)\n  lt_cv_prog_gnu_ld=no\n  ;;\nesac\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld\" >&5\n$as_echo \"$lt_cv_prog_gnu_ld\" >&6; }\nwith_gnu_ld=$lt_cv_prog_gnu_ld\n\n\n\n\n\n\n\n\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)\" >&5\n$as_echo_n \"checking for BSD- or MS-compatible name lister (nm)... \" >&6; }\nif ${lt_cv_path_NM+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$NM\"; then\n  # Let the user override the test.\n  lt_cv_path_NM=\"$NM\"\nelse\n  lt_nm_to_check=\"${ac_tool_prefix}nm\"\n  if test -n \"$ac_tool_prefix\" && test \"$build\" = \"$host\"; then\n    lt_nm_to_check=\"$lt_nm_to_check nm\"\n  fi\n  for lt_tmp_nm in $lt_nm_to_check; do\n    lt_save_ifs=\"$IFS\"; IFS=$PATH_SEPARATOR\n    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do\n      IFS=\"$lt_save_ifs\"\n      test -z \"$ac_dir\" && ac_dir=.\n      tmp_nm=\"$ac_dir/$lt_tmp_nm\"\n      if test -f \"$tmp_nm\" || test -f \"$tmp_nm$ac_exeext\" ; then\n\t# Check to see if the nm accepts a BSD-compat flag.\n\t# Adding the `sed 1q' prevents false positives on HP-UX, which says:\n\t#   nm: unknown option \"B\" ignored\n\t# Tru64's nm complains that /dev/null is an invalid object file\n\tcase `\"$tmp_nm\" -B /dev/null 2>&1 | sed '1q'` in\n\t*/dev/null* | *'Invalid file or object type'*)\n\t  lt_cv_path_NM=\"$tmp_nm -B\"\n\t  break\n\t  ;;\n\t*)\n\t  case `\"$tmp_nm\" -p /dev/null 2>&1 | sed '1q'` in\n\t  */dev/null*)\n\t    lt_cv_path_NM=\"$tmp_nm -p\"\n\t    break\n\t    ;;\n\t  *)\n\t    lt_cv_path_NM=${lt_cv_path_NM=\"$tmp_nm\"} # keep the first match, but\n\t    continue # so that we can try to find one that supports BSD flags\n\t    ;;\n\t  esac\n\t  ;;\n\tesac\n      fi\n    done\n    IFS=\"$lt_save_ifs\"\n  done\n  : ${lt_cv_path_NM=no}\nfi\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM\" >&5\n$as_echo \"$lt_cv_path_NM\" >&6; }\nif test \"$lt_cv_path_NM\" != \"no\"; then\n  NM=\"$lt_cv_path_NM\"\nelse\n  # Didn't find any BSD compatible name lister, look for dumpbin.\n  if test -n \"$DUMPBIN\"; then :\n    # Let the user override the test.\n  else\n    if test -n \"$ac_tool_prefix\"; then\n  for ac_prog in dumpbin \"link -dump\"\n  do\n    # Extract the first word of \"$ac_tool_prefix$ac_prog\", so it can be a program name with args.\nset dummy $ac_tool_prefix$ac_prog; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_DUMPBIN+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$DUMPBIN\"; then\n  ac_cv_prog_DUMPBIN=\"$DUMPBIN\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_DUMPBIN=\"$ac_tool_prefix$ac_prog\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nDUMPBIN=$ac_cv_prog_DUMPBIN\nif test -n \"$DUMPBIN\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $DUMPBIN\" >&5\n$as_echo \"$DUMPBIN\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\n    test -n \"$DUMPBIN\" && break\n  done\nfi\nif test -z \"$DUMPBIN\"; then\n  ac_ct_DUMPBIN=$DUMPBIN\n  for ac_prog in dumpbin \"link -dump\"\ndo\n  # Extract the first word of \"$ac_prog\", so it can be a program name with args.\nset dummy $ac_prog; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$ac_ct_DUMPBIN\"; then\n  ac_cv_prog_ac_ct_DUMPBIN=\"$ac_ct_DUMPBIN\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_ac_ct_DUMPBIN=\"$ac_prog\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN\nif test -n \"$ac_ct_DUMPBIN\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN\" >&5\n$as_echo \"$ac_ct_DUMPBIN\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\n  test -n \"$ac_ct_DUMPBIN\" && break\ndone\n\n  if test \"x$ac_ct_DUMPBIN\" = x; then\n    DUMPBIN=\":\"\n  else\n    case $cross_compiling:$ac_tool_warned in\nyes:)\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet\" >&5\n$as_echo \"$as_me: WARNING: using cross tools not prefixed with host triplet\" >&2;}\nac_tool_warned=yes ;;\nesac\n    DUMPBIN=$ac_ct_DUMPBIN\n  fi\nfi\n\n    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in\n    *COFF*)\n      DUMPBIN=\"$DUMPBIN -symbols\"\n      ;;\n    *)\n      DUMPBIN=:\n      ;;\n    esac\n  fi\n\n  if test \"$DUMPBIN\" != \":\"; then\n    NM=\"$DUMPBIN\"\n  fi\nfi\ntest -z \"$NM\" && NM=nm\n\n\n\n\n\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface\" >&5\n$as_echo_n \"checking the name lister ($NM) interface... \" >&6; }\nif ${lt_cv_nm_interface+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_nm_interface=\"BSD nm\"\n  echo \"int some_variable = 0;\" > conftest.$ac_ext\n  (eval echo \"\\\"\\$as_me:$LINENO: $ac_compile\\\"\" >&5)\n  (eval \"$ac_compile\" 2>conftest.err)\n  cat conftest.err >&5\n  (eval echo \"\\\"\\$as_me:$LINENO: $NM \\\\\\\"conftest.$ac_objext\\\\\\\"\\\"\" >&5)\n  (eval \"$NM \\\"conftest.$ac_objext\\\"\" 2>conftest.err > conftest.out)\n  cat conftest.err >&5\n  (eval echo \"\\\"\\$as_me:$LINENO: output\\\"\" >&5)\n  cat conftest.out >&5\n  if $GREP 'External.*some_variable' conftest.out > /dev/null; then\n    lt_cv_nm_interface=\"MS dumpbin\"\n  fi\n  rm -f conftest*\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface\" >&5\n$as_echo \"$lt_cv_nm_interface\" >&6; }\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether ln -s works\" >&5\n$as_echo_n \"checking whether ln -s works... \" >&6; }\nLN_S=$as_ln_s\nif test \"$LN_S\" = \"ln -s\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: yes\" >&5\n$as_echo \"yes\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no, using $LN_S\" >&5\n$as_echo \"no, using $LN_S\" >&6; }\nfi\n\n# find the maximum length of command line arguments\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments\" >&5\n$as_echo_n \"checking the maximum length of command line arguments... \" >&6; }\nif ${lt_cv_sys_max_cmd_len+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n    i=0\n  teststring=\"ABCD\"\n\n  case $build_os in\n  msdosdjgpp*)\n    # On DJGPP, this test can blow up pretty badly due to problems in libc\n    # (any single argument exceeding 2000 bytes causes a buffer overrun\n    # during glob expansion).  Even if it were fixed, the result of this\n    # check would be larger than it should be.\n    lt_cv_sys_max_cmd_len=12288;    # 12K is about right\n    ;;\n\n  gnu*)\n    # Under GNU Hurd, this test is not required because there is\n    # no limit to the length of command line arguments.\n    # Libtool will interpret -1 as no limit whatsoever\n    lt_cv_sys_max_cmd_len=-1;\n    ;;\n\n  cygwin* | mingw* | cegcc*)\n    # On Win9x/ME, this test blows up -- it succeeds, but takes\n    # about 5 minutes as the teststring grows exponentially.\n    # Worse, since 9x/ME are not pre-emptively multitasking,\n    # you end up with a \"frozen\" computer, even though with patience\n    # the test eventually succeeds (with a max line length of 256k).\n    # Instead, let's just punt: use the minimum linelength reported by\n    # all of the supported platforms: 8192 (on NT/2K/XP).\n    lt_cv_sys_max_cmd_len=8192;\n    ;;\n\n  mint*)\n    # On MiNT this can take a long time and run out of memory.\n    lt_cv_sys_max_cmd_len=8192;\n    ;;\n\n  amigaos*)\n    # On AmigaOS with pdksh, this test takes hours, literally.\n    # So we just punt and use a minimum line length of 8192.\n    lt_cv_sys_max_cmd_len=8192;\n    ;;\n\n  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)\n    # This has been around since 386BSD, at least.  Likely further.\n    if test -x /sbin/sysctl; then\n      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`\n    elif test -x /usr/sbin/sysctl; then\n      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`\n    else\n      lt_cv_sys_max_cmd_len=65536\t# usable default for all BSDs\n    fi\n    # And add a safety zone\n    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \\/ 4`\n    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \\* 3`\n    ;;\n\n  interix*)\n    # We know the value 262144 and hardcode it with a safety zone (like BSD)\n    lt_cv_sys_max_cmd_len=196608\n    ;;\n\n  os2*)\n    # The test takes a long time on OS/2.\n    lt_cv_sys_max_cmd_len=8192\n    ;;\n\n  osf*)\n    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure\n    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not\n    # nice to cause kernel panics so lets avoid the loop below.\n    # First set a reasonable default.\n    lt_cv_sys_max_cmd_len=16384\n    #\n    if test -x /sbin/sysconfig; then\n      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in\n        *1*) lt_cv_sys_max_cmd_len=-1 ;;\n      esac\n    fi\n    ;;\n  sco3.2v5*)\n    lt_cv_sys_max_cmd_len=102400\n    ;;\n  sysv5* | sco5v6* | sysv4.2uw2*)\n    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`\n    if test -n \"$kargmax\"; then\n      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[\t ]//'`\n    else\n      lt_cv_sys_max_cmd_len=32768\n    fi\n    ;;\n  *)\n    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`\n    if test -n \"$lt_cv_sys_max_cmd_len\" && \\\n\ttest undefined != \"$lt_cv_sys_max_cmd_len\"; then\n      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \\/ 4`\n      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \\* 3`\n    else\n      # Make teststring a little bigger before we do anything with it.\n      # a 1K string should be a reasonable start.\n      for i in 1 2 3 4 5 6 7 8 ; do\n        teststring=$teststring$teststring\n      done\n      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}\n      # If test is not a shell built-in, we'll probably end up computing a\n      # maximum length that is only half of the actual maximum length, but\n      # we can't tell.\n      while { test \"X\"`env echo \"$teststring$teststring\" 2>/dev/null` \\\n\t         = \"X$teststring$teststring\"; } >/dev/null 2>&1 &&\n\t      test $i != 17 # 1/2 MB should be enough\n      do\n        i=`expr $i + 1`\n        teststring=$teststring$teststring\n      done\n      # Only check the string length outside the loop.\n      lt_cv_sys_max_cmd_len=`expr \"X$teststring\" : \".*\" 2>&1`\n      teststring=\n      # Add a significant safety factor because C++ compilers can tack on\n      # massive amounts of additional arguments before passing them to the\n      # linker.  It appears as though 1/2 is a usable value.\n      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \\/ 2`\n    fi\n    ;;\n  esac\n\nfi\n\nif test -n $lt_cv_sys_max_cmd_len ; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len\" >&5\n$as_echo \"$lt_cv_sys_max_cmd_len\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: none\" >&5\n$as_echo \"none\" >&6; }\nfi\nmax_cmd_len=$lt_cv_sys_max_cmd_len\n\n\n\n\n\n\n: ${CP=\"cp -f\"}\n: ${MV=\"mv -f\"}\n: ${RM=\"rm -f\"}\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs\" >&5\n$as_echo_n \"checking whether the shell understands some XSI constructs... \" >&6; }\n# Try some XSI features\nxsi_shell=no\n( _lt_dummy=\"a/b/c\"\n  test \"${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}\"${_lt_dummy%\"$_lt_dummy\"}, \\\n      = c,a/b,b/c, \\\n    && eval 'test $(( 1 + 1 )) -eq 2 \\\n    && test \"${#_lt_dummy}\" -eq 5' ) >/dev/null 2>&1 \\\n  && xsi_shell=yes\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $xsi_shell\" >&5\n$as_echo \"$xsi_shell\" >&6; }\n\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether the shell understands \\\"+=\\\"\" >&5\n$as_echo_n \"checking whether the shell understands \\\"+=\\\"... \" >&6; }\nlt_shell_append=no\n( foo=bar; set foo baz; eval \"$1+=\\$2\" && test \"$foo\" = barbaz ) \\\n    >/dev/null 2>&1 \\\n  && lt_shell_append=yes\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_shell_append\" >&5\n$as_echo \"$lt_shell_append\" >&6; }\n\n\nif ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then\n  lt_unset=unset\nelse\n  lt_unset=false\nfi\n\n\n\n\n\n# test EBCDIC or ASCII\ncase `echo X|tr X '\\101'` in\n A) # ASCII based system\n    # \\n is not interpreted correctly by Solaris 8 /usr/ucb/tr\n  lt_SP2NL='tr \\040 \\012'\n  lt_NL2SP='tr \\015\\012 \\040\\040'\n  ;;\n *) # EBCDIC based system\n  lt_SP2NL='tr \\100 \\n'\n  lt_NL2SP='tr \\r\\n \\100\\100'\n  ;;\nesac\n\n\n\n\n\n\n\n\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format\" >&5\n$as_echo_n \"checking how to convert $build file names to $host format... \" >&6; }\nif ${lt_cv_to_host_file_cmd+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  case $host in\n  *-*-mingw* )\n    case $build in\n      *-*-mingw* ) # actually msys\n        lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32\n        ;;\n      *-*-cygwin* )\n        lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32\n        ;;\n      * ) # otherwise, assume *nix\n        lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32\n        ;;\n    esac\n    ;;\n  *-*-cygwin* )\n    case $build in\n      *-*-mingw* ) # actually msys\n        lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin\n        ;;\n      *-*-cygwin* )\n        lt_cv_to_host_file_cmd=func_convert_file_noop\n        ;;\n      * ) # otherwise, assume *nix\n        lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin\n        ;;\n    esac\n    ;;\n  * ) # unhandled hosts (and \"normal\" native builds)\n    lt_cv_to_host_file_cmd=func_convert_file_noop\n    ;;\nesac\n\nfi\n\nto_host_file_cmd=$lt_cv_to_host_file_cmd\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd\" >&5\n$as_echo \"$lt_cv_to_host_file_cmd\" >&6; }\n\n\n\n\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format\" >&5\n$as_echo_n \"checking how to convert $build file names to toolchain format... \" >&6; }\nif ${lt_cv_to_tool_file_cmd+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  #assume ordinary cross tools, or native build.\nlt_cv_to_tool_file_cmd=func_convert_file_noop\ncase $host in\n  *-*-mingw* )\n    case $build in\n      *-*-mingw* ) # actually msys\n        lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32\n        ;;\n    esac\n    ;;\nesac\n\nfi\n\nto_tool_file_cmd=$lt_cv_to_tool_file_cmd\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd\" >&5\n$as_echo \"$lt_cv_to_tool_file_cmd\" >&6; }\n\n\n\n\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files\" >&5\n$as_echo_n \"checking for $LD option to reload object files... \" >&6; }\nif ${lt_cv_ld_reload_flag+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_ld_reload_flag='-r'\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag\" >&5\n$as_echo \"$lt_cv_ld_reload_flag\" >&6; }\nreload_flag=$lt_cv_ld_reload_flag\ncase $reload_flag in\n\"\" | \" \"*) ;;\n*) reload_flag=\" $reload_flag\" ;;\nesac\nreload_cmds='$LD$reload_flag -o $output$reload_objs'\ncase $host_os in\n  cygwin* | mingw* | pw32* | cegcc*)\n    if test \"$GCC\" != yes; then\n      reload_cmds=false\n    fi\n    ;;\n  darwin*)\n    if test \"$GCC\" = yes; then\n      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'\n    else\n      reload_cmds='$LD$reload_flag -o $output$reload_objs'\n    fi\n    ;;\nesac\n\n\n\n\n\n\n\n\n\nif test -n \"$ac_tool_prefix\"; then\n  # Extract the first word of \"${ac_tool_prefix}objdump\", so it can be a program name with args.\nset dummy ${ac_tool_prefix}objdump; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_OBJDUMP+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$OBJDUMP\"; then\n  ac_cv_prog_OBJDUMP=\"$OBJDUMP\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_OBJDUMP=\"${ac_tool_prefix}objdump\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nOBJDUMP=$ac_cv_prog_OBJDUMP\nif test -n \"$OBJDUMP\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $OBJDUMP\" >&5\n$as_echo \"$OBJDUMP\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\nfi\nif test -z \"$ac_cv_prog_OBJDUMP\"; then\n  ac_ct_OBJDUMP=$OBJDUMP\n  # Extract the first word of \"objdump\", so it can be a program name with args.\nset dummy objdump; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$ac_ct_OBJDUMP\"; then\n  ac_cv_prog_ac_ct_OBJDUMP=\"$ac_ct_OBJDUMP\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_ac_ct_OBJDUMP=\"objdump\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP\nif test -n \"$ac_ct_OBJDUMP\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP\" >&5\n$as_echo \"$ac_ct_OBJDUMP\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n  if test \"x$ac_ct_OBJDUMP\" = x; then\n    OBJDUMP=\"false\"\n  else\n    case $cross_compiling:$ac_tool_warned in\nyes:)\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet\" >&5\n$as_echo \"$as_me: WARNING: using cross tools not prefixed with host triplet\" >&2;}\nac_tool_warned=yes ;;\nesac\n    OBJDUMP=$ac_ct_OBJDUMP\n  fi\nelse\n  OBJDUMP=\"$ac_cv_prog_OBJDUMP\"\nfi\n\ntest -z \"$OBJDUMP\" && OBJDUMP=objdump\n\n\n\n\n\n\n\n\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries\" >&5\n$as_echo_n \"checking how to recognize dependent libraries... \" >&6; }\nif ${lt_cv_deplibs_check_method+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_file_magic_cmd='$MAGIC_CMD'\nlt_cv_file_magic_test_file=\nlt_cv_deplibs_check_method='unknown'\n# Need to set the preceding variable on all platforms that support\n# interlibrary dependencies.\n# 'none' -- dependencies not supported.\n# `unknown' -- same as none, but documents that we really don't know.\n# 'pass_all' -- all dependencies passed with no checks.\n# 'test_compile' -- check by making test program.\n# 'file_magic [[regex]]' -- check by looking for files in library path\n# which responds to the $file_magic_cmd with a given extended regex.\n# If you have `file' or equivalent on your system and you're not sure\n# whether `pass_all' will *always* work, you probably want this one.\n\ncase $host_os in\naix[4-9]*)\n  lt_cv_deplibs_check_method=pass_all\n  ;;\n\nbeos*)\n  lt_cv_deplibs_check_method=pass_all\n  ;;\n\nbsdi[45]*)\n  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'\n  lt_cv_file_magic_cmd='/usr/bin/file -L'\n  lt_cv_file_magic_test_file=/shlib/libc.so\n  ;;\n\ncygwin*)\n  # func_win32_libid is a shell function defined in ltmain.sh\n  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'\n  lt_cv_file_magic_cmd='func_win32_libid'\n  ;;\n\nmingw* | pw32*)\n  # Base MSYS/MinGW do not provide the 'file' command needed by\n  # func_win32_libid shell function, so use a weaker test based on 'objdump',\n  # unless we find 'file', for example because we are cross-compiling.\n  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.\n  if ( test \"$lt_cv_nm_interface\" = \"BSD nm\" && file / ) >/dev/null 2>&1; then\n    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'\n    lt_cv_file_magic_cmd='func_win32_libid'\n  else\n    # Keep this pattern in sync with the one in func_win32_libid.\n    lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'\n    lt_cv_file_magic_cmd='$OBJDUMP -f'\n  fi\n  ;;\n\ncegcc*)\n  # use the weaker test based on 'objdump'. See mingw*.\n  lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'\n  lt_cv_file_magic_cmd='$OBJDUMP -f'\n  ;;\n\ndarwin* | rhapsody*)\n  lt_cv_deplibs_check_method=pass_all\n  ;;\n\nfreebsd* | dragonfly*)\n  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then\n    case $host_cpu in\n    i*86 )\n      # Not sure whether the presence of OpenBSD here was a mistake.\n      # Let's accept both of them until this is cleared up.\n      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'\n      lt_cv_file_magic_cmd=/usr/bin/file\n      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`\n      ;;\n    esac\n  else\n    lt_cv_deplibs_check_method=pass_all\n  fi\n  ;;\n\nhaiku*)\n  lt_cv_deplibs_check_method=pass_all\n  ;;\n\nhpux10.20* | hpux11*)\n  lt_cv_file_magic_cmd=/usr/bin/file\n  case $host_cpu in\n  ia64*)\n    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'\n    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so\n    ;;\n  hppa*64*)\n    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\\.[0-9]'\n    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl\n    ;;\n  *)\n    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\\.[0-9]) shared library'\n    lt_cv_file_magic_test_file=/usr/lib/libc.sl\n    ;;\n  esac\n  ;;\n\ninterix[3-9]*)\n  # PIC code is broken on Interix 3.x, that's why |\\.a not |_pic\\.a here\n  lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\\.so|\\.a)$'\n  ;;\n\nirix5* | irix6* | nonstopux*)\n  case $LD in\n  *-32|*\"-32 \") libmagic=32-bit;;\n  *-n32|*\"-n32 \") libmagic=N32;;\n  *-64|*\"-64 \") libmagic=64-bit;;\n  *) libmagic=never-match;;\n  esac\n  lt_cv_deplibs_check_method=pass_all\n  ;;\n\n# This must be glibc/ELF.\nlinux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)\n  lt_cv_deplibs_check_method=pass_all\n  ;;\n\nnetbsd* | netbsdelf*-gnu)\n  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then\n    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\\.so\\.[0-9]+\\.[0-9]+|_pic\\.a)$'\n  else\n    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\\.so|_pic\\.a)$'\n  fi\n  ;;\n\nnewos6*)\n  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'\n  lt_cv_file_magic_cmd=/usr/bin/file\n  lt_cv_file_magic_test_file=/usr/lib/libnls.so\n  ;;\n\n*nto* | *qnx*)\n  lt_cv_deplibs_check_method=pass_all\n  ;;\n\nopenbsd*)\n  if test -z \"`echo __ELF__ | $CC -E - | $GREP __ELF__`\" || test \"$host_os-$host_cpu\" = \"openbsd2.8-powerpc\"; then\n    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\\.so\\.[0-9]+\\.[0-9]+|\\.so|_pic\\.a)$'\n  else\n    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\\.so\\.[0-9]+\\.[0-9]+|_pic\\.a)$'\n  fi\n  ;;\n\nosf3* | osf4* | osf5*)\n  lt_cv_deplibs_check_method=pass_all\n  ;;\n\nrdos*)\n  lt_cv_deplibs_check_method=pass_all\n  ;;\n\nsolaris*)\n  lt_cv_deplibs_check_method=pass_all\n  ;;\n\nsysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)\n  lt_cv_deplibs_check_method=pass_all\n  ;;\n\nsysv4 | sysv4.3*)\n  case $host_vendor in\n  motorola)\n    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'\n    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`\n    ;;\n  ncr)\n    lt_cv_deplibs_check_method=pass_all\n    ;;\n  sequent)\n    lt_cv_file_magic_cmd='/bin/file'\n    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'\n    ;;\n  sni)\n    lt_cv_file_magic_cmd='/bin/file'\n    lt_cv_deplibs_check_method=\"file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib\"\n    lt_cv_file_magic_test_file=/lib/libc.so\n    ;;\n  siemens)\n    lt_cv_deplibs_check_method=pass_all\n    ;;\n  pc)\n    lt_cv_deplibs_check_method=pass_all\n    ;;\n  esac\n  ;;\n\ntpf*)\n  lt_cv_deplibs_check_method=pass_all\n  ;;\nesac\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method\" >&5\n$as_echo \"$lt_cv_deplibs_check_method\" >&6; }\n\nfile_magic_glob=\nwant_nocaseglob=no\nif test \"$build\" = \"$host\"; then\n  case $host_os in\n  mingw* | pw32*)\n    if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then\n      want_nocaseglob=yes\n    else\n      file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e \"s/\\(..\\)/s\\/[\\1]\\/[\\1]\\/g;/g\"`\n    fi\n    ;;\n  esac\nfi\n\nfile_magic_cmd=$lt_cv_file_magic_cmd\ndeplibs_check_method=$lt_cv_deplibs_check_method\ntest -z \"$deplibs_check_method\" && deplibs_check_method=unknown\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nif test -n \"$ac_tool_prefix\"; then\n  # Extract the first word of \"${ac_tool_prefix}dlltool\", so it can be a program name with args.\nset dummy ${ac_tool_prefix}dlltool; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_DLLTOOL+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$DLLTOOL\"; then\n  ac_cv_prog_DLLTOOL=\"$DLLTOOL\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_DLLTOOL=\"${ac_tool_prefix}dlltool\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nDLLTOOL=$ac_cv_prog_DLLTOOL\nif test -n \"$DLLTOOL\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $DLLTOOL\" >&5\n$as_echo \"$DLLTOOL\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\nfi\nif test -z \"$ac_cv_prog_DLLTOOL\"; then\n  ac_ct_DLLTOOL=$DLLTOOL\n  # Extract the first word of \"dlltool\", so it can be a program name with args.\nset dummy dlltool; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$ac_ct_DLLTOOL\"; then\n  ac_cv_prog_ac_ct_DLLTOOL=\"$ac_ct_DLLTOOL\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_ac_ct_DLLTOOL=\"dlltool\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL\nif test -n \"$ac_ct_DLLTOOL\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL\" >&5\n$as_echo \"$ac_ct_DLLTOOL\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n  if test \"x$ac_ct_DLLTOOL\" = x; then\n    DLLTOOL=\"false\"\n  else\n    case $cross_compiling:$ac_tool_warned in\nyes:)\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet\" >&5\n$as_echo \"$as_me: WARNING: using cross tools not prefixed with host triplet\" >&2;}\nac_tool_warned=yes ;;\nesac\n    DLLTOOL=$ac_ct_DLLTOOL\n  fi\nelse\n  DLLTOOL=\"$ac_cv_prog_DLLTOOL\"\nfi\n\ntest -z \"$DLLTOOL\" && DLLTOOL=dlltool\n\n\n\n\n\n\n\n\n\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries\" >&5\n$as_echo_n \"checking how to associate runtime and link libraries... \" >&6; }\nif ${lt_cv_sharedlib_from_linklib_cmd+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_sharedlib_from_linklib_cmd='unknown'\n\ncase $host_os in\ncygwin* | mingw* | pw32* | cegcc*)\n  # two different shell functions defined in ltmain.sh\n  # decide which to use based on capabilities of $DLLTOOL\n  case `$DLLTOOL --help 2>&1` in\n  *--identify-strict*)\n    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib\n    ;;\n  *)\n    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback\n    ;;\n  esac\n  ;;\n*)\n  # fallback: assume linklib IS sharedlib\n  lt_cv_sharedlib_from_linklib_cmd=\"$ECHO\"\n  ;;\nesac\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd\" >&5\n$as_echo \"$lt_cv_sharedlib_from_linklib_cmd\" >&6; }\nsharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd\ntest -z \"$sharedlib_from_linklib_cmd\" && sharedlib_from_linklib_cmd=$ECHO\n\n\n\n\n\n\n\nif test -n \"$ac_tool_prefix\"; then\n  for ac_prog in ar\n  do\n    # Extract the first word of \"$ac_tool_prefix$ac_prog\", so it can be a program name with args.\nset dummy $ac_tool_prefix$ac_prog; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_AR+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$AR\"; then\n  ac_cv_prog_AR=\"$AR\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_AR=\"$ac_tool_prefix$ac_prog\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nAR=$ac_cv_prog_AR\nif test -n \"$AR\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $AR\" >&5\n$as_echo \"$AR\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\n    test -n \"$AR\" && break\n  done\nfi\nif test -z \"$AR\"; then\n  ac_ct_AR=$AR\n  for ac_prog in ar\ndo\n  # Extract the first word of \"$ac_prog\", so it can be a program name with args.\nset dummy $ac_prog; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_ac_ct_AR+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$ac_ct_AR\"; then\n  ac_cv_prog_ac_ct_AR=\"$ac_ct_AR\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_ac_ct_AR=\"$ac_prog\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nac_ct_AR=$ac_cv_prog_ac_ct_AR\nif test -n \"$ac_ct_AR\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR\" >&5\n$as_echo \"$ac_ct_AR\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\n  test -n \"$ac_ct_AR\" && break\ndone\n\n  if test \"x$ac_ct_AR\" = x; then\n    AR=\"false\"\n  else\n    case $cross_compiling:$ac_tool_warned in\nyes:)\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet\" >&5\n$as_echo \"$as_me: WARNING: using cross tools not prefixed with host triplet\" >&2;}\nac_tool_warned=yes ;;\nesac\n    AR=$ac_ct_AR\n  fi\nfi\n\n: ${AR=ar}\n: ${AR_FLAGS=cru}\n\n\n\n\n\n\n\n\n\n\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support\" >&5\n$as_echo_n \"checking for archiver @FILE support... \" >&6; }\nif ${lt_cv_ar_at_file+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_ar_at_file=no\n   cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_cxx_try_compile \"$LINENO\"; then :\n  echo conftest.$ac_objext > conftest.lst\n      lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5'\n      { { eval echo \"\\\"\\$as_me\\\":${as_lineno-$LINENO}: \\\"$lt_ar_try\\\"\"; } >&5\n  (eval $lt_ar_try) 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; }\n      if test \"$ac_status\" -eq 0; then\n\t# Ensure the archiver fails upon bogus file names.\n\trm -f conftest.$ac_objext libconftest.a\n\t{ { eval echo \"\\\"\\$as_me\\\":${as_lineno-$LINENO}: \\\"$lt_ar_try\\\"\"; } >&5\n  (eval $lt_ar_try) 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; }\n\tif test \"$ac_status\" -ne 0; then\n          lt_cv_ar_at_file=@\n        fi\n      fi\n      rm -f conftest.* libconftest.a\n\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file\" >&5\n$as_echo \"$lt_cv_ar_at_file\" >&6; }\n\nif test \"x$lt_cv_ar_at_file\" = xno; then\n  archiver_list_spec=\nelse\n  archiver_list_spec=$lt_cv_ar_at_file\nfi\n\n\n\n\n\n\n\nif test -n \"$ac_tool_prefix\"; then\n  # Extract the first word of \"${ac_tool_prefix}strip\", so it can be a program name with args.\nset dummy ${ac_tool_prefix}strip; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_STRIP+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$STRIP\"; then\n  ac_cv_prog_STRIP=\"$STRIP\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_STRIP=\"${ac_tool_prefix}strip\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nSTRIP=$ac_cv_prog_STRIP\nif test -n \"$STRIP\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $STRIP\" >&5\n$as_echo \"$STRIP\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\nfi\nif test -z \"$ac_cv_prog_STRIP\"; then\n  ac_ct_STRIP=$STRIP\n  # Extract the first word of \"strip\", so it can be a program name with args.\nset dummy strip; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_ac_ct_STRIP+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$ac_ct_STRIP\"; then\n  ac_cv_prog_ac_ct_STRIP=\"$ac_ct_STRIP\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_ac_ct_STRIP=\"strip\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP\nif test -n \"$ac_ct_STRIP\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP\" >&5\n$as_echo \"$ac_ct_STRIP\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n  if test \"x$ac_ct_STRIP\" = x; then\n    STRIP=\":\"\n  else\n    case $cross_compiling:$ac_tool_warned in\nyes:)\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet\" >&5\n$as_echo \"$as_me: WARNING: using cross tools not prefixed with host triplet\" >&2;}\nac_tool_warned=yes ;;\nesac\n    STRIP=$ac_ct_STRIP\n  fi\nelse\n  STRIP=\"$ac_cv_prog_STRIP\"\nfi\n\ntest -z \"$STRIP\" && STRIP=:\n\n\n\n\n\n\nif test -n \"$ac_tool_prefix\"; then\n  # Extract the first word of \"${ac_tool_prefix}ranlib\", so it can be a program name with args.\nset dummy ${ac_tool_prefix}ranlib; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_RANLIB+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$RANLIB\"; then\n  ac_cv_prog_RANLIB=\"$RANLIB\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_RANLIB=\"${ac_tool_prefix}ranlib\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nRANLIB=$ac_cv_prog_RANLIB\nif test -n \"$RANLIB\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $RANLIB\" >&5\n$as_echo \"$RANLIB\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\nfi\nif test -z \"$ac_cv_prog_RANLIB\"; then\n  ac_ct_RANLIB=$RANLIB\n  # Extract the first word of \"ranlib\", so it can be a program name with args.\nset dummy ranlib; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_ac_ct_RANLIB+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$ac_ct_RANLIB\"; then\n  ac_cv_prog_ac_ct_RANLIB=\"$ac_ct_RANLIB\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_ac_ct_RANLIB=\"ranlib\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB\nif test -n \"$ac_ct_RANLIB\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB\" >&5\n$as_echo \"$ac_ct_RANLIB\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n  if test \"x$ac_ct_RANLIB\" = x; then\n    RANLIB=\":\"\n  else\n    case $cross_compiling:$ac_tool_warned in\nyes:)\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet\" >&5\n$as_echo \"$as_me: WARNING: using cross tools not prefixed with host triplet\" >&2;}\nac_tool_warned=yes ;;\nesac\n    RANLIB=$ac_ct_RANLIB\n  fi\nelse\n  RANLIB=\"$ac_cv_prog_RANLIB\"\nfi\n\ntest -z \"$RANLIB\" && RANLIB=:\n\n\n\n\n\n\n# Determine commands to create old-style static archives.\nold_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'\nold_postinstall_cmds='chmod 644 $oldlib'\nold_postuninstall_cmds=\n\nif test -n \"$RANLIB\"; then\n  case $host_os in\n  openbsd*)\n    old_postinstall_cmds=\"$old_postinstall_cmds~\\$RANLIB -t \\$tool_oldlib\"\n    ;;\n  *)\n    old_postinstall_cmds=\"$old_postinstall_cmds~\\$RANLIB \\$tool_oldlib\"\n    ;;\n  esac\n  old_archive_cmds=\"$old_archive_cmds~\\$RANLIB \\$tool_oldlib\"\nfi\n\ncase $host_os in\n  darwin*)\n    lock_old_archive_extraction=yes ;;\n  *)\n    lock_old_archive_extraction=no ;;\nesac\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# If no C compiler was specified, use CC.\nLTCC=${LTCC-\"$CC\"}\n\n# If no C compiler flags were specified, use CFLAGS.\nLTCFLAGS=${LTCFLAGS-\"$CFLAGS\"}\n\n# Allow CC to be a program name with arguments.\ncompiler=$CC\n\n\n# Check for command to grab the raw symbol name followed by C symbol from nm.\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object\" >&5\n$as_echo_n \"checking command to parse $NM output from $compiler object... \" >&6; }\nif ${lt_cv_sys_global_symbol_pipe+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n\n# These are sane defaults that work on at least a few old systems.\n# [They come from Ultrix.  What could be older than Ultrix?!! ;)]\n\n# Character class describing NM global symbol codes.\nsymcode='[BCDEGRST]'\n\n# Regexp to match symbols that can be accessed directly from C.\nsympat='\\([_A-Za-z][_A-Za-z0-9]*\\)'\n\n# Define system-specific variables.\ncase $host_os in\naix*)\n  symcode='[BCDT]'\n  ;;\ncygwin* | mingw* | pw32* | cegcc*)\n  symcode='[ABCDGISTW]'\n  ;;\nhpux*)\n  if test \"$host_cpu\" = ia64; then\n    symcode='[ABCDEGRST]'\n  fi\n  ;;\nirix* | nonstopux*)\n  symcode='[BCDEGRST]'\n  ;;\nosf*)\n  symcode='[BCDEGQRST]'\n  ;;\nsolaris*)\n  symcode='[BDRT]'\n  ;;\nsco3.2v5*)\n  symcode='[DT]'\n  ;;\nsysv4.2uw2*)\n  symcode='[DT]'\n  ;;\nsysv5* | sco5v6* | unixware* | OpenUNIX*)\n  symcode='[ABDT]'\n  ;;\nsysv4)\n  symcode='[DFNSTU]'\n  ;;\nesac\n\n# If we're using GNU nm, then use its standard symbol codes.\ncase `$NM -V 2>&1` in\n*GNU* | *'with BFD'*)\n  symcode='[ABCDGIRSTW]' ;;\nesac\n\n# Transform an extracted symbol line into a proper C declaration.\n# Some systems (esp. on ia64) link data and code symbols differently,\n# so use this general approach.\nlt_cv_sys_global_symbol_to_cdecl=\"sed -n -e 's/^T .* \\(.*\\)$/extern int \\1();/p' -e 's/^$symcode* .* \\(.*\\)$/extern char \\1;/p'\"\n\n# Transform an extracted symbol line into symbol name and symbol address\nlt_cv_sys_global_symbol_to_c_name_address=\"sed -n -e 's/^: \\([^ ]*\\)[ ]*$/  {\\\\\\\"\\1\\\\\\\", (void *) 0},/p' -e 's/^$symcode* \\([^ ]*\\) \\([^ ]*\\)$/  {\\\"\\2\\\", (void *) \\&\\2},/p'\"\nlt_cv_sys_global_symbol_to_c_name_address_lib_prefix=\"sed -n -e 's/^: \\([^ ]*\\)[ ]*$/  {\\\\\\\"\\1\\\\\\\", (void *) 0},/p' -e 's/^$symcode* \\([^ ]*\\) \\(lib[^ ]*\\)$/  {\\\"\\2\\\", (void *) \\&\\2},/p' -e 's/^$symcode* \\([^ ]*\\) \\([^ ]*\\)$/  {\\\"lib\\2\\\", (void *) \\&\\2},/p'\"\n\n# Handle CRLF in mingw tool chain\nopt_cr=\ncase $build_os in\nmingw*)\n  opt_cr=`$ECHO 'x\\{0,1\\}' | tr x '\\015'` # option cr in regexp\n  ;;\nesac\n\n# Try without a prefix underscore, then with it.\nfor ac_symprfx in \"\" \"_\"; do\n\n  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.\n  symxfrm=\"\\\\1 $ac_symprfx\\\\2 \\\\2\"\n\n  # Write the raw and C identifiers.\n  if test \"$lt_cv_nm_interface\" = \"MS dumpbin\"; then\n    # Fake it for dumpbin and say T for any non-static function\n    # and D for any global variable.\n    # Also find C++ and __fastcall symbols from MSVC++,\n    # which start with @ or ?.\n    lt_cv_sys_global_symbol_pipe=\"$AWK '\"\\\n\"     {last_section=section; section=\\$ 3};\"\\\n\"     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};\"\\\n\"     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};\"\\\n\"     \\$ 0!~/External *\\|/{next};\"\\\n\"     / 0+ UNDEF /{next}; / UNDEF \\([^|]\\)*()/{next};\"\\\n\"     {if(hide[section]) next};\"\\\n\"     {f=0}; \\$ 0~/\\(\\).*\\|/{f=1}; {printf f ? \\\"T \\\" : \\\"D \\\"};\"\\\n\"     {split(\\$ 0, a, /\\||\\r/); split(a[2], s)};\"\\\n\"     s[1]~/^[@?]/{print s[1], s[1]; next};\"\\\n\"     s[1]~prfx {split(s[1],t,\\\"@\\\"); print t[1], substr(t[1],length(prfx))}\"\\\n\"     ' prfx=^$ac_symprfx\"\n  else\n    lt_cv_sys_global_symbol_pipe=\"sed -n -e 's/^.*[\t ]\\($symcode$symcode*\\)[\t ][\t ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'\"\n  fi\n  lt_cv_sys_global_symbol_pipe=\"$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'\"\n\n  # Check to see that the pipe works correctly.\n  pipe_works=no\n\n  rm -f conftest*\n  cat > conftest.$ac_ext <<_LT_EOF\n#ifdef __cplusplus\nextern \"C\" {\n#endif\nchar nm_test_var;\nvoid nm_test_func(void);\nvoid nm_test_func(void){}\n#ifdef __cplusplus\n}\n#endif\nint main(){nm_test_var='a';nm_test_func();return(0);}\n_LT_EOF\n\n  if { { eval echo \"\\\"\\$as_me\\\":${as_lineno-$LINENO}: \\\"$ac_compile\\\"\"; } >&5\n  (eval $ac_compile) 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; }; then\n    # Now try to grab the symbols.\n    nlist=conftest.nm\n    if { { eval echo \"\\\"\\$as_me\\\":${as_lineno-$LINENO}: \\\"$NM conftest.$ac_objext \\| \"$lt_cv_sys_global_symbol_pipe\" \\> $nlist\\\"\"; } >&5\n  (eval $NM conftest.$ac_objext \\| \"$lt_cv_sys_global_symbol_pipe\" \\> $nlist) 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; } && test -s \"$nlist\"; then\n      # Try sorting and uniquifying the output.\n      if sort \"$nlist\" | uniq > \"$nlist\"T; then\n\tmv -f \"$nlist\"T \"$nlist\"\n      else\n\trm -f \"$nlist\"T\n      fi\n\n      # Make sure that we snagged all the symbols we need.\n      if $GREP ' nm_test_var$' \"$nlist\" >/dev/null; then\n\tif $GREP ' nm_test_func$' \"$nlist\" >/dev/null; then\n\t  cat <<_LT_EOF > conftest.$ac_ext\n/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */\n#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)\n/* DATA imports from DLLs on WIN32 con't be const, because runtime\n   relocations are performed -- see ld's documentation on pseudo-relocs.  */\n# define LT_DLSYM_CONST\n#elif defined(__osf__)\n/* This system does not cope well with relocations in const data.  */\n# define LT_DLSYM_CONST\n#else\n# define LT_DLSYM_CONST const\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n_LT_EOF\n\t  # Now generate the symbol file.\n\t  eval \"$lt_cv_sys_global_symbol_to_cdecl\"' < \"$nlist\" | $GREP -v main >> conftest.$ac_ext'\n\n\t  cat <<_LT_EOF >> conftest.$ac_ext\n\n/* The mapping between symbol names and symbols.  */\nLT_DLSYM_CONST struct {\n  const char *name;\n  void       *address;\n}\nlt__PROGRAM__LTX_preloaded_symbols[] =\n{\n  { \"@PROGRAM@\", (void *) 0 },\n_LT_EOF\n\t  $SED \"s/^$symcode$symcode* \\(.*\\) \\(.*\\)$/  {\\\"\\2\\\", (void *) \\&\\2},/\" < \"$nlist\" | $GREP -v main >> conftest.$ac_ext\n\t  cat <<\\_LT_EOF >> conftest.$ac_ext\n  {0, (void *) 0}\n};\n\n/* This works around a problem in FreeBSD linker */\n#ifdef FREEBSD_WORKAROUND\nstatic const void *lt_preloaded_setup() {\n  return lt__PROGRAM__LTX_preloaded_symbols;\n}\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n_LT_EOF\n\t  # Now try linking the two files.\n\t  mv conftest.$ac_objext conftstm.$ac_objext\n\t  lt_globsym_save_LIBS=$LIBS\n\t  lt_globsym_save_CFLAGS=$CFLAGS\n\t  LIBS=\"conftstm.$ac_objext\"\n\t  CFLAGS=\"$CFLAGS$lt_prog_compiler_no_builtin_flag\"\n\t  if { { eval echo \"\\\"\\$as_me\\\":${as_lineno-$LINENO}: \\\"$ac_link\\\"\"; } >&5\n  (eval $ac_link) 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; } && test -s conftest${ac_exeext}; then\n\t    pipe_works=yes\n\t  fi\n\t  LIBS=$lt_globsym_save_LIBS\n\t  CFLAGS=$lt_globsym_save_CFLAGS\n\telse\n\t  echo \"cannot find nm_test_func in $nlist\" >&5\n\tfi\n      else\n\techo \"cannot find nm_test_var in $nlist\" >&5\n      fi\n    else\n      echo \"cannot run $lt_cv_sys_global_symbol_pipe\" >&5\n    fi\n  else\n    echo \"$progname: failed program was:\" >&5\n    cat conftest.$ac_ext >&5\n  fi\n  rm -rf conftest* conftst*\n\n  # Do not use the global_symbol_pipe unless it works.\n  if test \"$pipe_works\" = yes; then\n    break\n  else\n    lt_cv_sys_global_symbol_pipe=\n  fi\ndone\n\nfi\n\nif test -z \"$lt_cv_sys_global_symbol_pipe\"; then\n  lt_cv_sys_global_symbol_to_cdecl=\nfi\nif test -z \"$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: failed\" >&5\n$as_echo \"failed\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: ok\" >&5\n$as_echo \"ok\" >&6; }\nfi\n\n# Response file support.\nif test \"$lt_cv_nm_interface\" = \"MS dumpbin\"; then\n  nm_file_list_spec='@'\nelif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then\n  nm_file_list_spec='@'\nfi\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for sysroot\" >&5\n$as_echo_n \"checking for sysroot... \" >&6; }\n\n# Check whether --with-sysroot was given.\nif test \"${with_sysroot+set}\" = set; then :\n  withval=$with_sysroot;\nelse\n  with_sysroot=no\nfi\n\n\nlt_sysroot=\ncase ${with_sysroot} in #(\n yes)\n   if test \"$GCC\" = yes; then\n     lt_sysroot=`$CC --print-sysroot 2>/dev/null`\n   fi\n   ;; #(\n /*)\n   lt_sysroot=`echo \"$with_sysroot\" | sed -e \"$sed_quote_subst\"`\n   ;; #(\n no|'')\n   ;; #(\n *)\n   { $as_echo \"$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}\" >&5\n$as_echo \"${with_sysroot}\" >&6; }\n   as_fn_error $? \"The sysroot must be an absolute path.\" \"$LINENO\" 5\n   ;;\nesac\n\n { $as_echo \"$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}\" >&5\n$as_echo \"${lt_sysroot:-no}\" >&6; }\n\n\n\n\n\n# Check whether --enable-libtool-lock was given.\nif test \"${enable_libtool_lock+set}\" = set; then :\n  enableval=$enable_libtool_lock;\nfi\n\ntest \"x$enable_libtool_lock\" != xno && enable_libtool_lock=yes\n\n# Some flags need to be propagated to the compiler or linker for good\n# libtool support.\ncase $host in\nia64-*-hpux*)\n  # Find out which ABI we are using.\n  echo 'int i;' > conftest.$ac_ext\n  if { { eval echo \"\\\"\\$as_me\\\":${as_lineno-$LINENO}: \\\"$ac_compile\\\"\"; } >&5\n  (eval $ac_compile) 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; }; then\n    case `/usr/bin/file conftest.$ac_objext` in\n      *ELF-32*)\n\tHPUX_IA64_MODE=\"32\"\n\t;;\n      *ELF-64*)\n\tHPUX_IA64_MODE=\"64\"\n\t;;\n    esac\n  fi\n  rm -rf conftest*\n  ;;\n*-*-irix6*)\n  # Find out which ABI we are using.\n  echo '#line '$LINENO' \"configure\"' > conftest.$ac_ext\n  if { { eval echo \"\\\"\\$as_me\\\":${as_lineno-$LINENO}: \\\"$ac_compile\\\"\"; } >&5\n  (eval $ac_compile) 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; }; then\n    if test \"$lt_cv_prog_gnu_ld\" = yes; then\n      case `/usr/bin/file conftest.$ac_objext` in\n\t*32-bit*)\n\t  LD=\"${LD-ld} -melf32bsmip\"\n\t  ;;\n\t*N32*)\n\t  LD=\"${LD-ld} -melf32bmipn32\"\n\t  ;;\n\t*64-bit*)\n\t  LD=\"${LD-ld} -melf64bmip\"\n\t;;\n      esac\n    else\n      case `/usr/bin/file conftest.$ac_objext` in\n\t*32-bit*)\n\t  LD=\"${LD-ld} -32\"\n\t  ;;\n\t*N32*)\n\t  LD=\"${LD-ld} -n32\"\n\t  ;;\n\t*64-bit*)\n\t  LD=\"${LD-ld} -64\"\n\t  ;;\n      esac\n    fi\n  fi\n  rm -rf conftest*\n  ;;\n\nx86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \\\ns390*-*linux*|s390*-*tpf*|sparc*-*linux*)\n  # Find out which ABI we are using.\n  echo 'int i;' > conftest.$ac_ext\n  if { { eval echo \"\\\"\\$as_me\\\":${as_lineno-$LINENO}: \\\"$ac_compile\\\"\"; } >&5\n  (eval $ac_compile) 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; }; then\n    case `/usr/bin/file conftest.o` in\n      *32-bit*)\n\tcase $host in\n\t  x86_64-*kfreebsd*-gnu)\n\t    LD=\"${LD-ld} -m elf_i386_fbsd\"\n\t    ;;\n\t  x86_64-*linux*)\n\t    case `/usr/bin/file conftest.o` in\n\t      *x86-64*)\n\t\tLD=\"${LD-ld} -m elf32_x86_64\"\n\t\t;;\n\t      *)\n\t\tLD=\"${LD-ld} -m elf_i386\"\n\t\t;;\n\t    esac\n\t    ;;\n\t  powerpc64le-*)\n\t    LD=\"${LD-ld} -m elf32lppclinux\"\n\t    ;;\n\t  powerpc64-*)\n\t    LD=\"${LD-ld} -m elf32ppclinux\"\n\t    ;;\n\t  s390x-*linux*)\n\t    LD=\"${LD-ld} -m elf_s390\"\n\t    ;;\n\t  sparc64-*linux*)\n\t    LD=\"${LD-ld} -m elf32_sparc\"\n\t    ;;\n\tesac\n\t;;\n      *64-bit*)\n\tcase $host in\n\t  x86_64-*kfreebsd*-gnu)\n\t    LD=\"${LD-ld} -m elf_x86_64_fbsd\"\n\t    ;;\n\t  x86_64-*linux*)\n\t    LD=\"${LD-ld} -m elf_x86_64\"\n\t    ;;\n\t  powerpcle-*)\n\t    LD=\"${LD-ld} -m elf64lppc\"\n\t    ;;\n\t  powerpc-*)\n\t    LD=\"${LD-ld} -m elf64ppc\"\n\t    ;;\n\t  s390*-*linux*|s390*-*tpf*)\n\t    LD=\"${LD-ld} -m elf64_s390\"\n\t    ;;\n\t  sparc*-*linux*)\n\t    LD=\"${LD-ld} -m elf64_sparc\"\n\t    ;;\n\tesac\n\t;;\n    esac\n  fi\n  rm -rf conftest*\n  ;;\n\n*-*-sco3.2v5*)\n  # On SCO OpenServer 5, we need -belf to get full-featured binaries.\n  SAVE_CFLAGS=\"$CFLAGS\"\n  CFLAGS=\"$CFLAGS -belf\"\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf\" >&5\n$as_echo_n \"checking whether the C compiler needs -belf... \" >&6; }\nif ${lt_cv_cc_needs_belf+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  ac_ext=c\nac_cpp='$CPP $CPPFLAGS'\nac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_c_compiler_gnu\n\n     cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_link \"$LINENO\"; then :\n  lt_cv_cc_needs_belf=yes\nelse\n  lt_cv_cc_needs_belf=no\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\n     ac_ext=c\nac_cpp='$CPP $CPPFLAGS'\nac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_c_compiler_gnu\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf\" >&5\n$as_echo \"$lt_cv_cc_needs_belf\" >&6; }\n  if test x\"$lt_cv_cc_needs_belf\" != x\"yes\"; then\n    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf\n    CFLAGS=\"$SAVE_CFLAGS\"\n  fi\n  ;;\n*-*solaris*)\n  # Find out which ABI we are using.\n  echo 'int i;' > conftest.$ac_ext\n  if { { eval echo \"\\\"\\$as_me\\\":${as_lineno-$LINENO}: \\\"$ac_compile\\\"\"; } >&5\n  (eval $ac_compile) 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; }; then\n    case `/usr/bin/file conftest.o` in\n    *64-bit*)\n      case $lt_cv_prog_gnu_ld in\n      yes*)\n        case $host in\n        i?86-*-solaris*)\n          LD=\"${LD-ld} -m elf_x86_64\"\n          ;;\n        sparc*-*-solaris*)\n          LD=\"${LD-ld} -m elf64_sparc\"\n          ;;\n        esac\n        # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.\n        if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then\n          LD=\"${LD-ld}_sol2\"\n        fi\n        ;;\n      *)\n\tif ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then\n\t  LD=\"${LD-ld} -64\"\n\tfi\n\t;;\n      esac\n      ;;\n    esac\n  fi\n  rm -rf conftest*\n  ;;\nesac\n\nneed_locks=\"$enable_libtool_lock\"\n\nif test -n \"$ac_tool_prefix\"; then\n  # Extract the first word of \"${ac_tool_prefix}mt\", so it can be a program name with args.\nset dummy ${ac_tool_prefix}mt; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_MANIFEST_TOOL+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$MANIFEST_TOOL\"; then\n  ac_cv_prog_MANIFEST_TOOL=\"$MANIFEST_TOOL\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_MANIFEST_TOOL=\"${ac_tool_prefix}mt\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nMANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL\nif test -n \"$MANIFEST_TOOL\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL\" >&5\n$as_echo \"$MANIFEST_TOOL\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\nfi\nif test -z \"$ac_cv_prog_MANIFEST_TOOL\"; then\n  ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL\n  # Extract the first word of \"mt\", so it can be a program name with args.\nset dummy mt; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$ac_ct_MANIFEST_TOOL\"; then\n  ac_cv_prog_ac_ct_MANIFEST_TOOL=\"$ac_ct_MANIFEST_TOOL\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_ac_ct_MANIFEST_TOOL=\"mt\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL\nif test -n \"$ac_ct_MANIFEST_TOOL\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL\" >&5\n$as_echo \"$ac_ct_MANIFEST_TOOL\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n  if test \"x$ac_ct_MANIFEST_TOOL\" = x; then\n    MANIFEST_TOOL=\":\"\n  else\n    case $cross_compiling:$ac_tool_warned in\nyes:)\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet\" >&5\n$as_echo \"$as_me: WARNING: using cross tools not prefixed with host triplet\" >&2;}\nac_tool_warned=yes ;;\nesac\n    MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL\n  fi\nelse\n  MANIFEST_TOOL=\"$ac_cv_prog_MANIFEST_TOOL\"\nfi\n\ntest -z \"$MANIFEST_TOOL\" && MANIFEST_TOOL=mt\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool\" >&5\n$as_echo_n \"checking if $MANIFEST_TOOL is a manifest tool... \" >&6; }\nif ${lt_cv_path_mainfest_tool+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_path_mainfest_tool=no\n  echo \"$as_me:$LINENO: $MANIFEST_TOOL '-?'\" >&5\n  $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out\n  cat conftest.err >&5\n  if $GREP 'Manifest Tool' conftest.out > /dev/null; then\n    lt_cv_path_mainfest_tool=yes\n  fi\n  rm -f conftest*\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool\" >&5\n$as_echo \"$lt_cv_path_mainfest_tool\" >&6; }\nif test \"x$lt_cv_path_mainfest_tool\" != xyes; then\n  MANIFEST_TOOL=:\nfi\n\n\n\n\n\n\n  case $host_os in\n    rhapsody* | darwin*)\n    if test -n \"$ac_tool_prefix\"; then\n  # Extract the first word of \"${ac_tool_prefix}dsymutil\", so it can be a program name with args.\nset dummy ${ac_tool_prefix}dsymutil; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_DSYMUTIL+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$DSYMUTIL\"; then\n  ac_cv_prog_DSYMUTIL=\"$DSYMUTIL\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_DSYMUTIL=\"${ac_tool_prefix}dsymutil\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nDSYMUTIL=$ac_cv_prog_DSYMUTIL\nif test -n \"$DSYMUTIL\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL\" >&5\n$as_echo \"$DSYMUTIL\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\nfi\nif test -z \"$ac_cv_prog_DSYMUTIL\"; then\n  ac_ct_DSYMUTIL=$DSYMUTIL\n  # Extract the first word of \"dsymutil\", so it can be a program name with args.\nset dummy dsymutil; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$ac_ct_DSYMUTIL\"; then\n  ac_cv_prog_ac_ct_DSYMUTIL=\"$ac_ct_DSYMUTIL\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_ac_ct_DSYMUTIL=\"dsymutil\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL\nif test -n \"$ac_ct_DSYMUTIL\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL\" >&5\n$as_echo \"$ac_ct_DSYMUTIL\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n  if test \"x$ac_ct_DSYMUTIL\" = x; then\n    DSYMUTIL=\":\"\n  else\n    case $cross_compiling:$ac_tool_warned in\nyes:)\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet\" >&5\n$as_echo \"$as_me: WARNING: using cross tools not prefixed with host triplet\" >&2;}\nac_tool_warned=yes ;;\nesac\n    DSYMUTIL=$ac_ct_DSYMUTIL\n  fi\nelse\n  DSYMUTIL=\"$ac_cv_prog_DSYMUTIL\"\nfi\n\n    if test -n \"$ac_tool_prefix\"; then\n  # Extract the first word of \"${ac_tool_prefix}nmedit\", so it can be a program name with args.\nset dummy ${ac_tool_prefix}nmedit; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_NMEDIT+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$NMEDIT\"; then\n  ac_cv_prog_NMEDIT=\"$NMEDIT\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_NMEDIT=\"${ac_tool_prefix}nmedit\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nNMEDIT=$ac_cv_prog_NMEDIT\nif test -n \"$NMEDIT\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $NMEDIT\" >&5\n$as_echo \"$NMEDIT\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\nfi\nif test -z \"$ac_cv_prog_NMEDIT\"; then\n  ac_ct_NMEDIT=$NMEDIT\n  # Extract the first word of \"nmedit\", so it can be a program name with args.\nset dummy nmedit; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_ac_ct_NMEDIT+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$ac_ct_NMEDIT\"; then\n  ac_cv_prog_ac_ct_NMEDIT=\"$ac_ct_NMEDIT\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_ac_ct_NMEDIT=\"nmedit\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT\nif test -n \"$ac_ct_NMEDIT\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT\" >&5\n$as_echo \"$ac_ct_NMEDIT\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n  if test \"x$ac_ct_NMEDIT\" = x; then\n    NMEDIT=\":\"\n  else\n    case $cross_compiling:$ac_tool_warned in\nyes:)\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet\" >&5\n$as_echo \"$as_me: WARNING: using cross tools not prefixed with host triplet\" >&2;}\nac_tool_warned=yes ;;\nesac\n    NMEDIT=$ac_ct_NMEDIT\n  fi\nelse\n  NMEDIT=\"$ac_cv_prog_NMEDIT\"\nfi\n\n    if test -n \"$ac_tool_prefix\"; then\n  # Extract the first word of \"${ac_tool_prefix}lipo\", so it can be a program name with args.\nset dummy ${ac_tool_prefix}lipo; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_LIPO+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$LIPO\"; then\n  ac_cv_prog_LIPO=\"$LIPO\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_LIPO=\"${ac_tool_prefix}lipo\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nLIPO=$ac_cv_prog_LIPO\nif test -n \"$LIPO\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $LIPO\" >&5\n$as_echo \"$LIPO\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\nfi\nif test -z \"$ac_cv_prog_LIPO\"; then\n  ac_ct_LIPO=$LIPO\n  # Extract the first word of \"lipo\", so it can be a program name with args.\nset dummy lipo; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_ac_ct_LIPO+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$ac_ct_LIPO\"; then\n  ac_cv_prog_ac_ct_LIPO=\"$ac_ct_LIPO\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_ac_ct_LIPO=\"lipo\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO\nif test -n \"$ac_ct_LIPO\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO\" >&5\n$as_echo \"$ac_ct_LIPO\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n  if test \"x$ac_ct_LIPO\" = x; then\n    LIPO=\":\"\n  else\n    case $cross_compiling:$ac_tool_warned in\nyes:)\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet\" >&5\n$as_echo \"$as_me: WARNING: using cross tools not prefixed with host triplet\" >&2;}\nac_tool_warned=yes ;;\nesac\n    LIPO=$ac_ct_LIPO\n  fi\nelse\n  LIPO=\"$ac_cv_prog_LIPO\"\nfi\n\n    if test -n \"$ac_tool_prefix\"; then\n  # Extract the first word of \"${ac_tool_prefix}otool\", so it can be a program name with args.\nset dummy ${ac_tool_prefix}otool; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_OTOOL+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$OTOOL\"; then\n  ac_cv_prog_OTOOL=\"$OTOOL\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_OTOOL=\"${ac_tool_prefix}otool\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nOTOOL=$ac_cv_prog_OTOOL\nif test -n \"$OTOOL\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $OTOOL\" >&5\n$as_echo \"$OTOOL\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\nfi\nif test -z \"$ac_cv_prog_OTOOL\"; then\n  ac_ct_OTOOL=$OTOOL\n  # Extract the first word of \"otool\", so it can be a program name with args.\nset dummy otool; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_ac_ct_OTOOL+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$ac_ct_OTOOL\"; then\n  ac_cv_prog_ac_ct_OTOOL=\"$ac_ct_OTOOL\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_ac_ct_OTOOL=\"otool\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL\nif test -n \"$ac_ct_OTOOL\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL\" >&5\n$as_echo \"$ac_ct_OTOOL\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n  if test \"x$ac_ct_OTOOL\" = x; then\n    OTOOL=\":\"\n  else\n    case $cross_compiling:$ac_tool_warned in\nyes:)\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet\" >&5\n$as_echo \"$as_me: WARNING: using cross tools not prefixed with host triplet\" >&2;}\nac_tool_warned=yes ;;\nesac\n    OTOOL=$ac_ct_OTOOL\n  fi\nelse\n  OTOOL=\"$ac_cv_prog_OTOOL\"\nfi\n\n    if test -n \"$ac_tool_prefix\"; then\n  # Extract the first word of \"${ac_tool_prefix}otool64\", so it can be a program name with args.\nset dummy ${ac_tool_prefix}otool64; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_OTOOL64+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$OTOOL64\"; then\n  ac_cv_prog_OTOOL64=\"$OTOOL64\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_OTOOL64=\"${ac_tool_prefix}otool64\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nOTOOL64=$ac_cv_prog_OTOOL64\nif test -n \"$OTOOL64\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $OTOOL64\" >&5\n$as_echo \"$OTOOL64\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\nfi\nif test -z \"$ac_cv_prog_OTOOL64\"; then\n  ac_ct_OTOOL64=$OTOOL64\n  # Extract the first word of \"otool64\", so it can be a program name with args.\nset dummy otool64; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_ac_ct_OTOOL64+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$ac_ct_OTOOL64\"; then\n  ac_cv_prog_ac_ct_OTOOL64=\"$ac_ct_OTOOL64\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_ac_ct_OTOOL64=\"otool64\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64\nif test -n \"$ac_ct_OTOOL64\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64\" >&5\n$as_echo \"$ac_ct_OTOOL64\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n  if test \"x$ac_ct_OTOOL64\" = x; then\n    OTOOL64=\":\"\n  else\n    case $cross_compiling:$ac_tool_warned in\nyes:)\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet\" >&5\n$as_echo \"$as_me: WARNING: using cross tools not prefixed with host triplet\" >&2;}\nac_tool_warned=yes ;;\nesac\n    OTOOL64=$ac_ct_OTOOL64\n  fi\nelse\n  OTOOL64=\"$ac_cv_prog_OTOOL64\"\nfi\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag\" >&5\n$as_echo_n \"checking for -single_module linker flag... \" >&6; }\nif ${lt_cv_apple_cc_single_mod+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_apple_cc_single_mod=no\n      if test -z \"${LT_MULTI_MODULE}\"; then\n\t# By default we will add the -single_module flag. You can override\n\t# by either setting the environment variable LT_MULTI_MODULE\n\t# non-empty at configure time, or by adding -multi_module to the\n\t# link flags.\n\trm -rf libconftest.dylib*\n\techo \"int foo(void){return 1;}\" > conftest.c\n\techo \"$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \\\n-dynamiclib -Wl,-single_module conftest.c\" >&5\n\t$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \\\n\t  -dynamiclib -Wl,-single_module conftest.c 2>conftest.err\n        _lt_result=$?\n\t# If there is a non-empty error log, and \"single_module\"\n\t# appears in it, assume the flag caused a linker warning\n        if test -s conftest.err && $GREP single_module conftest.err; then\n\t  cat conftest.err >&5\n\t# Otherwise, if the output was created with a 0 exit code from\n\t# the compiler, it worked.\n\telif test -f libconftest.dylib && test $_lt_result -eq 0; then\n\t  lt_cv_apple_cc_single_mod=yes\n\telse\n\t  cat conftest.err >&5\n\tfi\n\trm -rf libconftest.dylib*\n\trm -f conftest.*\n      fi\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod\" >&5\n$as_echo \"$lt_cv_apple_cc_single_mod\" >&6; }\n\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag\" >&5\n$as_echo_n \"checking for -exported_symbols_list linker flag... \" >&6; }\nif ${lt_cv_ld_exported_symbols_list+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_ld_exported_symbols_list=no\n      save_LDFLAGS=$LDFLAGS\n      echo \"_main\" > conftest.sym\n      LDFLAGS=\"$LDFLAGS -Wl,-exported_symbols_list,conftest.sym\"\n      cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_link \"$LINENO\"; then :\n  lt_cv_ld_exported_symbols_list=yes\nelse\n  lt_cv_ld_exported_symbols_list=no\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\n\tLDFLAGS=\"$save_LDFLAGS\"\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list\" >&5\n$as_echo \"$lt_cv_ld_exported_symbols_list\" >&6; }\n\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag\" >&5\n$as_echo_n \"checking for -force_load linker flag... \" >&6; }\nif ${lt_cv_ld_force_load+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_ld_force_load=no\n      cat > conftest.c << _LT_EOF\nint forced_loaded() { return 2;}\n_LT_EOF\n      echo \"$LTCC $LTCFLAGS -c -o conftest.o conftest.c\" >&5\n      $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5\n      echo \"$AR cru libconftest.a conftest.o\" >&5\n      $AR cru libconftest.a conftest.o 2>&5\n      echo \"$RANLIB libconftest.a\" >&5\n      $RANLIB libconftest.a 2>&5\n      cat > conftest.c << _LT_EOF\nint main() { return 0;}\n_LT_EOF\n      echo \"$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a\" >&5\n      $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err\n      _lt_result=$?\n      if test -s conftest.err && $GREP force_load conftest.err; then\n\tcat conftest.err >&5\n      elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then\n\tlt_cv_ld_force_load=yes\n      else\n\tcat conftest.err >&5\n      fi\n        rm -f conftest.err libconftest.a conftest conftest.c\n        rm -rf conftest.dSYM\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load\" >&5\n$as_echo \"$lt_cv_ld_force_load\" >&6; }\n    case $host_os in\n    rhapsody* | darwin1.[012])\n      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;\n    darwin1.*)\n      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;\n    darwin*) # darwin 5.x on\n      # if running on 10.5 or later, the deployment target defaults\n      # to the OS version, if on x86, and 10.4, the deployment\n      # target defaults to 10.4. Don't you love it?\n      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in\n\t10.0,*86*-darwin8*|10.0,*-darwin[91]*)\n\t  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;\n\t10.[012]*)\n\t  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;\n\t10.*)\n\t  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;\n      esac\n    ;;\n  esac\n    if test \"$lt_cv_apple_cc_single_mod\" = \"yes\"; then\n      _lt_dar_single_mod='$single_module'\n    fi\n    if test \"$lt_cv_ld_exported_symbols_list\" = \"yes\"; then\n      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'\n    else\n      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'\n    fi\n    if test \"$DSYMUTIL\" != \":\" && test \"$lt_cv_ld_force_load\" = \"no\"; then\n      _lt_dsymutil='~$DSYMUTIL $lib || :'\n    else\n      _lt_dsymutil=\n    fi\n    ;;\n  esac\n\nfor ac_header in dlfcn.h\ndo :\n  ac_fn_c_check_header_compile \"$LINENO\" \"dlfcn.h\" \"ac_cv_header_dlfcn_h\" \"$ac_includes_default\n\"\nif test \"x$ac_cv_header_dlfcn_h\" = xyes; then :\n  cat >>confdefs.h <<_ACEOF\n#define HAVE_DLFCN_H 1\n_ACEOF\n\nfi\n\ndone\n\n\n\nfunc_stripname_cnf ()\n{\n  case ${2} in\n  .*) func_stripname_result=`$ECHO \"${3}\" | $SED \"s%^${1}%%; s%\\\\\\\\${2}\\$%%\"`;;\n  *)  func_stripname_result=`$ECHO \"${3}\" | $SED \"s%^${1}%%; s%${2}\\$%%\"`;;\n  esac\n} # func_stripname_cnf\n\n\n\n\n\n# Set options\n\n\n\n        enable_dlopen=no\n\n\n  enable_win32_dll=no\n\n\n            # Check whether --enable-shared was given.\nif test \"${enable_shared+set}\" = set; then :\n  enableval=$enable_shared; p=${PACKAGE-default}\n    case $enableval in\n    yes) enable_shared=yes ;;\n    no) enable_shared=no ;;\n    *)\n      enable_shared=no\n      # Look at the argument we got.  We use all the common list separators.\n      lt_save_ifs=\"$IFS\"; IFS=\"${IFS}$PATH_SEPARATOR,\"\n      for pkg in $enableval; do\n\tIFS=\"$lt_save_ifs\"\n\tif test \"X$pkg\" = \"X$p\"; then\n\t  enable_shared=yes\n\tfi\n      done\n      IFS=\"$lt_save_ifs\"\n      ;;\n    esac\nelse\n  enable_shared=yes\nfi\n\n\n\n\n\n\n\n\n\n  # Check whether --enable-static was given.\nif test \"${enable_static+set}\" = set; then :\n  enableval=$enable_static; p=${PACKAGE-default}\n    case $enableval in\n    yes) enable_static=yes ;;\n    no) enable_static=no ;;\n    *)\n     enable_static=no\n      # Look at the argument we got.  We use all the common list separators.\n      lt_save_ifs=\"$IFS\"; IFS=\"${IFS}$PATH_SEPARATOR,\"\n      for pkg in $enableval; do\n\tIFS=\"$lt_save_ifs\"\n\tif test \"X$pkg\" = \"X$p\"; then\n\t  enable_static=yes\n\tfi\n      done\n      IFS=\"$lt_save_ifs\"\n      ;;\n    esac\nelse\n  enable_static=yes\nfi\n\n\n\n\n\n\n\n\n\n\n# Check whether --with-pic was given.\nif test \"${with_pic+set}\" = set; then :\n  withval=$with_pic; lt_p=${PACKAGE-default}\n    case $withval in\n    yes|no) pic_mode=$withval ;;\n    *)\n      pic_mode=default\n      # Look at the argument we got.  We use all the common list separators.\n      lt_save_ifs=\"$IFS\"; IFS=\"${IFS}$PATH_SEPARATOR,\"\n      for lt_pkg in $withval; do\n\tIFS=\"$lt_save_ifs\"\n\tif test \"X$lt_pkg\" = \"X$lt_p\"; then\n\t  pic_mode=yes\n\tfi\n      done\n      IFS=\"$lt_save_ifs\"\n      ;;\n    esac\nelse\n  pic_mode=default\nfi\n\n\ntest -z \"$pic_mode\" && pic_mode=default\n\n\n\n\n\n\n\n  # Check whether --enable-fast-install was given.\nif test \"${enable_fast_install+set}\" = set; then :\n  enableval=$enable_fast_install; p=${PACKAGE-default}\n    case $enableval in\n    yes) enable_fast_install=yes ;;\n    no) enable_fast_install=no ;;\n    *)\n      enable_fast_install=no\n      # Look at the argument we got.  We use all the common list separators.\n      lt_save_ifs=\"$IFS\"; IFS=\"${IFS}$PATH_SEPARATOR,\"\n      for pkg in $enableval; do\n\tIFS=\"$lt_save_ifs\"\n\tif test \"X$pkg\" = \"X$p\"; then\n\t  enable_fast_install=yes\n\tfi\n      done\n      IFS=\"$lt_save_ifs\"\n      ;;\n    esac\nelse\n  enable_fast_install=yes\nfi\n\n\n\n\n\n\n\n\n\n\n\n# This can be used to rebuild libtool when needed\nLIBTOOL_DEPS=\"$ltmain\"\n\n# Always use our own libtool.\nLIBTOOL='$(SHELL) $(top_builddir)/libtool'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\ntest -z \"$LN_S\" && LN_S=\"ln -s\"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nif test -n \"${ZSH_VERSION+set}\" ; then\n   setopt NO_GLOB_SUBST\nfi\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for objdir\" >&5\n$as_echo_n \"checking for objdir... \" >&6; }\nif ${lt_cv_objdir+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  rm -f .libs 2>/dev/null\nmkdir .libs 2>/dev/null\nif test -d .libs; then\n  lt_cv_objdir=.libs\nelse\n  # MS-DOS does not allow filenames that begin with a dot.\n  lt_cv_objdir=_libs\nfi\nrmdir .libs 2>/dev/null\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir\" >&5\n$as_echo \"$lt_cv_objdir\" >&6; }\nobjdir=$lt_cv_objdir\n\n\n\n\n\ncat >>confdefs.h <<_ACEOF\n#define LT_OBJDIR \"$lt_cv_objdir/\"\n_ACEOF\n\n\n\n\ncase $host_os in\naix3*)\n  # AIX sometimes has problems with the GCC collect2 program.  For some\n  # reason, if we set the COLLECT_NAMES environment variable, the problems\n  # vanish in a puff of smoke.\n  if test \"X${COLLECT_NAMES+set}\" != Xset; then\n    COLLECT_NAMES=\n    export COLLECT_NAMES\n  fi\n  ;;\nesac\n\n# Global variables:\nofile=libtool\ncan_build_shared=yes\n\n# All known linkers require a `.a' archive for static linking (except MSVC,\n# which needs '.lib').\nlibext=a\n\nwith_gnu_ld=\"$lt_cv_prog_gnu_ld\"\n\nold_CC=\"$CC\"\nold_CFLAGS=\"$CFLAGS\"\n\n# Set sane defaults for various variables\ntest -z \"$CC\" && CC=cc\ntest -z \"$LTCC\" && LTCC=$CC\ntest -z \"$LTCFLAGS\" && LTCFLAGS=$CFLAGS\ntest -z \"$LD\" && LD=ld\ntest -z \"$ac_objext\" && ac_objext=o\n\nfor cc_temp in $compiler\"\"; do\n  case $cc_temp in\n    compile | *[\\\\/]compile | ccache | *[\\\\/]ccache ) ;;\n    distcc | *[\\\\/]distcc | purify | *[\\\\/]purify ) ;;\n    \\-*) ;;\n    *) break;;\n  esac\ndone\ncc_basename=`$ECHO \"$cc_temp\" | $SED \"s%.*/%%; s%^$host_alias-%%\"`\n\n\n# Only perform the check for file, if the check method requires it\ntest -z \"$MAGIC_CMD\" && MAGIC_CMD=file\ncase $deplibs_check_method in\nfile_magic*)\n  if test \"$file_magic_cmd\" = '$MAGIC_CMD'; then\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file\" >&5\n$as_echo_n \"checking for ${ac_tool_prefix}file... \" >&6; }\nif ${lt_cv_path_MAGIC_CMD+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  case $MAGIC_CMD in\n[\\\\/*] |  ?:[\\\\/]*)\n  lt_cv_path_MAGIC_CMD=\"$MAGIC_CMD\" # Let the user override the test with a path.\n  ;;\n*)\n  lt_save_MAGIC_CMD=\"$MAGIC_CMD\"\n  lt_save_ifs=\"$IFS\"; IFS=$PATH_SEPARATOR\n  ac_dummy=\"/usr/bin$PATH_SEPARATOR$PATH\"\n  for ac_dir in $ac_dummy; do\n    IFS=\"$lt_save_ifs\"\n    test -z \"$ac_dir\" && ac_dir=.\n    if test -f $ac_dir/${ac_tool_prefix}file; then\n      lt_cv_path_MAGIC_CMD=\"$ac_dir/${ac_tool_prefix}file\"\n      if test -n \"$file_magic_test_file\"; then\n\tcase $deplibs_check_method in\n\t\"file_magic \"*)\n\t  file_magic_regex=`expr \"$deplibs_check_method\" : \"file_magic \\(.*\\)\"`\n\t  MAGIC_CMD=\"$lt_cv_path_MAGIC_CMD\"\n\t  if eval $file_magic_cmd \\$file_magic_test_file 2> /dev/null |\n\t    $EGREP \"$file_magic_regex\" > /dev/null; then\n\t    :\n\t  else\n\t    cat <<_LT_EOF 1>&2\n\n*** Warning: the command libtool uses to detect shared libraries,\n*** $file_magic_cmd, produces output that libtool cannot recognize.\n*** The result is that libtool may fail to recognize shared libraries\n*** as such.  This will affect the creation of libtool libraries that\n*** depend on shared libraries, but programs linked with such libtool\n*** libraries will work regardless of this problem.  Nevertheless, you\n*** may want to report the problem to your system manager and/or to\n*** bug-libtool@gnu.org\n\n_LT_EOF\n\t  fi ;;\n\tesac\n      fi\n      break\n    fi\n  done\n  IFS=\"$lt_save_ifs\"\n  MAGIC_CMD=\"$lt_save_MAGIC_CMD\"\n  ;;\nesac\nfi\n\nMAGIC_CMD=\"$lt_cv_path_MAGIC_CMD\"\nif test -n \"$MAGIC_CMD\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD\" >&5\n$as_echo \"$MAGIC_CMD\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\n\n\n\nif test -z \"$lt_cv_path_MAGIC_CMD\"; then\n  if test -n \"$ac_tool_prefix\"; then\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for file\" >&5\n$as_echo_n \"checking for file... \" >&6; }\nif ${lt_cv_path_MAGIC_CMD+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  case $MAGIC_CMD in\n[\\\\/*] |  ?:[\\\\/]*)\n  lt_cv_path_MAGIC_CMD=\"$MAGIC_CMD\" # Let the user override the test with a path.\n  ;;\n*)\n  lt_save_MAGIC_CMD=\"$MAGIC_CMD\"\n  lt_save_ifs=\"$IFS\"; IFS=$PATH_SEPARATOR\n  ac_dummy=\"/usr/bin$PATH_SEPARATOR$PATH\"\n  for ac_dir in $ac_dummy; do\n    IFS=\"$lt_save_ifs\"\n    test -z \"$ac_dir\" && ac_dir=.\n    if test -f $ac_dir/file; then\n      lt_cv_path_MAGIC_CMD=\"$ac_dir/file\"\n      if test -n \"$file_magic_test_file\"; then\n\tcase $deplibs_check_method in\n\t\"file_magic \"*)\n\t  file_magic_regex=`expr \"$deplibs_check_method\" : \"file_magic \\(.*\\)\"`\n\t  MAGIC_CMD=\"$lt_cv_path_MAGIC_CMD\"\n\t  if eval $file_magic_cmd \\$file_magic_test_file 2> /dev/null |\n\t    $EGREP \"$file_magic_regex\" > /dev/null; then\n\t    :\n\t  else\n\t    cat <<_LT_EOF 1>&2\n\n*** Warning: the command libtool uses to detect shared libraries,\n*** $file_magic_cmd, produces output that libtool cannot recognize.\n*** The result is that libtool may fail to recognize shared libraries\n*** as such.  This will affect the creation of libtool libraries that\n*** depend on shared libraries, but programs linked with such libtool\n*** libraries will work regardless of this problem.  Nevertheless, you\n*** may want to report the problem to your system manager and/or to\n*** bug-libtool@gnu.org\n\n_LT_EOF\n\t  fi ;;\n\tesac\n      fi\n      break\n    fi\n  done\n  IFS=\"$lt_save_ifs\"\n  MAGIC_CMD=\"$lt_save_MAGIC_CMD\"\n  ;;\nesac\nfi\n\nMAGIC_CMD=\"$lt_cv_path_MAGIC_CMD\"\nif test -n \"$MAGIC_CMD\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD\" >&5\n$as_echo \"$MAGIC_CMD\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\n  else\n    MAGIC_CMD=:\n  fi\nfi\n\n  fi\n  ;;\nesac\n\n# Use C for the default configuration in the libtool script\n\nlt_save_CC=\"$CC\"\nac_ext=c\nac_cpp='$CPP $CPPFLAGS'\nac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_c_compiler_gnu\n\n\n# Source file extension for C test sources.\nac_ext=c\n\n# Object file extension for compiled C test sources.\nobjext=o\nobjext=$objext\n\n# Code to be used in simple compile tests\nlt_simple_compile_test_code=\"int some_variable = 0;\"\n\n# Code to be used in simple link tests\nlt_simple_link_test_code='int main(){return(0);}'\n\n\n\n\n\n\n\n# If no C compiler was specified, use CC.\nLTCC=${LTCC-\"$CC\"}\n\n# If no C compiler flags were specified, use CFLAGS.\nLTCFLAGS=${LTCFLAGS-\"$CFLAGS\"}\n\n# Allow CC to be a program name with arguments.\ncompiler=$CC\n\n# Save the default compiler, since it gets overwritten when the other\n# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.\ncompiler_DEFAULT=$CC\n\n# save warnings/boilerplate of simple test code\nac_outfile=conftest.$ac_objext\necho \"$lt_simple_compile_test_code\" >conftest.$ac_ext\neval \"$ac_compile\" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err\n_lt_compiler_boilerplate=`cat conftest.err`\n$RM conftest*\n\nac_outfile=conftest.$ac_objext\necho \"$lt_simple_link_test_code\" >conftest.$ac_ext\neval \"$ac_link\" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err\n_lt_linker_boilerplate=`cat conftest.err`\n$RM -r conftest*\n\n\n## CAVEAT EMPTOR:\n## There is no encapsulation within the following macros, do not change\n## the running order or otherwise move them around unless you know exactly\n## what you are doing...\nif test -n \"$compiler\"; then\n\nlt_prog_compiler_no_builtin_flag=\n\nif test \"$GCC\" = yes; then\n  case $cc_basename in\n  nvcc*)\n    lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;;\n  *)\n    lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;;\n  esac\n\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions\" >&5\n$as_echo_n \"checking if $compiler supports -fno-rtti -fno-exceptions... \" >&6; }\nif ${lt_cv_prog_compiler_rtti_exceptions+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_prog_compiler_rtti_exceptions=no\n   ac_outfile=conftest.$ac_objext\n   echo \"$lt_simple_compile_test_code\" > conftest.$ac_ext\n   lt_compiler_flag=\"-fno-rtti -fno-exceptions\"\n   # Insert the option either (1) after the last *FLAGS variable, or\n   # (2) before a word containing \"conftest.\", or (3) at the end.\n   # Note that $ac_compile itself does not contain backslashes and begins\n   # with a dollar sign (not a hyphen), so the echo should work correctly.\n   # The option is referenced via a variable to avoid confusing sed.\n   lt_compile=`echo \"$ac_compile\" | $SED \\\n   -e 's:.*FLAGS}\\{0,1\\} :&$lt_compiler_flag :; t' \\\n   -e 's: [^ ]*conftest\\.: $lt_compiler_flag&:; t' \\\n   -e 's:$: $lt_compiler_flag:'`\n   (eval echo \"\\\"\\$as_me:$LINENO: $lt_compile\\\"\" >&5)\n   (eval \"$lt_compile\" 2>conftest.err)\n   ac_status=$?\n   cat conftest.err >&5\n   echo \"$as_me:$LINENO: \\$? = $ac_status\" >&5\n   if (exit $ac_status) && test -s \"$ac_outfile\"; then\n     # The compiler can only warn and ignore the option if not recognized\n     # So say no if there are warnings other than the usual output.\n     $ECHO \"$_lt_compiler_boilerplate\" | $SED '/^$/d' >conftest.exp\n     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2\n     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then\n       lt_cv_prog_compiler_rtti_exceptions=yes\n     fi\n   fi\n   $RM conftest*\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions\" >&5\n$as_echo \"$lt_cv_prog_compiler_rtti_exceptions\" >&6; }\n\nif test x\"$lt_cv_prog_compiler_rtti_exceptions\" = xyes; then\n    lt_prog_compiler_no_builtin_flag=\"$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions\"\nelse\n    :\nfi\n\nfi\n\n\n\n\n\n\n  lt_prog_compiler_wl=\nlt_prog_compiler_pic=\nlt_prog_compiler_static=\n\n\n  if test \"$GCC\" = yes; then\n    lt_prog_compiler_wl='-Wl,'\n    lt_prog_compiler_static='-static'\n\n    case $host_os in\n      aix*)\n      # All AIX code is PIC.\n      if test \"$host_cpu\" = ia64; then\n\t# AIX 5 now supports IA64 processor\n\tlt_prog_compiler_static='-Bstatic'\n      fi\n      ;;\n\n    amigaos*)\n      case $host_cpu in\n      powerpc)\n            # see comment about AmigaOS4 .so support\n            lt_prog_compiler_pic='-fPIC'\n        ;;\n      m68k)\n            # FIXME: we need at least 68020 code to build shared libraries, but\n            # adding the `-m68020' flag to GCC prevents building anything better,\n            # like `-m68040'.\n            lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'\n        ;;\n      esac\n      ;;\n\n    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)\n      # PIC is the default for these OSes.\n      ;;\n\n    mingw* | cygwin* | pw32* | os2* | cegcc*)\n      # This hack is so that the source file can tell whether it is being\n      # built for inclusion in a dll (and should export symbols for example).\n      # Although the cygwin gcc ignores -fPIC, still need this for old-style\n      # (--disable-auto-import) libraries\n      lt_prog_compiler_pic='-DDLL_EXPORT'\n      ;;\n\n    darwin* | rhapsody*)\n      # PIC is the default on this platform\n      # Common symbols not allowed in MH_DYLIB files\n      lt_prog_compiler_pic='-fno-common'\n      ;;\n\n    haiku*)\n      # PIC is the default for Haiku.\n      # The \"-static\" flag exists, but is broken.\n      lt_prog_compiler_static=\n      ;;\n\n    hpux*)\n      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit\n      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag\n      # sets the default TLS model and affects inlining.\n      case $host_cpu in\n      hppa*64*)\n\t# +Z the default\n\t;;\n      *)\n\tlt_prog_compiler_pic='-fPIC'\n\t;;\n      esac\n      ;;\n\n    interix[3-9]*)\n      # Interix 3.x gcc -fpic/-fPIC options generate broken code.\n      # Instead, we relocate shared libraries at runtime.\n      ;;\n\n    msdosdjgpp*)\n      # Just because we use GCC doesn't mean we suddenly get shared libraries\n      # on systems that don't support them.\n      lt_prog_compiler_can_build_shared=no\n      enable_shared=no\n      ;;\n\n    *nto* | *qnx*)\n      # QNX uses GNU C++, but need to define -shared option too, otherwise\n      # it will coredump.\n      lt_prog_compiler_pic='-fPIC -shared'\n      ;;\n\n    sysv4*MP*)\n      if test -d /usr/nec; then\n\tlt_prog_compiler_pic=-Kconform_pic\n      fi\n      ;;\n\n    *)\n      lt_prog_compiler_pic='-fPIC'\n      ;;\n    esac\n\n    case $cc_basename in\n    nvcc*) # Cuda Compiler Driver 2.2\n      lt_prog_compiler_wl='-Xlinker '\n      if test -n \"$lt_prog_compiler_pic\"; then\n        lt_prog_compiler_pic=\"-Xcompiler $lt_prog_compiler_pic\"\n      fi\n      ;;\n    esac\n  else\n    # PORTME Check for flag to pass linker flags through the system compiler.\n    case $host_os in\n    aix*)\n      lt_prog_compiler_wl='-Wl,'\n      if test \"$host_cpu\" = ia64; then\n\t# AIX 5 now supports IA64 processor\n\tlt_prog_compiler_static='-Bstatic'\n      else\n\tlt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'\n      fi\n      ;;\n\n    mingw* | cygwin* | pw32* | os2* | cegcc*)\n      # This hack is so that the source file can tell whether it is being\n      # built for inclusion in a dll (and should export symbols for example).\n      lt_prog_compiler_pic='-DDLL_EXPORT'\n      ;;\n\n    hpux9* | hpux10* | hpux11*)\n      lt_prog_compiler_wl='-Wl,'\n      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but\n      # not for PA HP-UX.\n      case $host_cpu in\n      hppa*64*|ia64*)\n\t# +Z the default\n\t;;\n      *)\n\tlt_prog_compiler_pic='+Z'\n\t;;\n      esac\n      # Is there a better lt_prog_compiler_static that works with the bundled CC?\n      lt_prog_compiler_static='${wl}-a ${wl}archive'\n      ;;\n\n    irix5* | irix6* | nonstopux*)\n      lt_prog_compiler_wl='-Wl,'\n      # PIC (with -KPIC) is the default.\n      lt_prog_compiler_static='-non_shared'\n      ;;\n\n    linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)\n      case $cc_basename in\n      # old Intel for x86_64 which still supported -KPIC.\n      ecc*)\n\tlt_prog_compiler_wl='-Wl,'\n\tlt_prog_compiler_pic='-KPIC'\n\tlt_prog_compiler_static='-static'\n        ;;\n      # icc used to be incompatible with GCC.\n      # ICC 10 doesn't accept -KPIC any more.\n      icc* | ifort*)\n\tlt_prog_compiler_wl='-Wl,'\n\tlt_prog_compiler_pic='-fPIC'\n\tlt_prog_compiler_static='-static'\n        ;;\n      # Lahey Fortran 8.1.\n      lf95*)\n\tlt_prog_compiler_wl='-Wl,'\n\tlt_prog_compiler_pic='--shared'\n\tlt_prog_compiler_static='--static'\n\t;;\n      nagfor*)\n\t# NAG Fortran compiler\n\tlt_prog_compiler_wl='-Wl,-Wl,,'\n\tlt_prog_compiler_pic='-PIC'\n\tlt_prog_compiler_static='-Bstatic'\n\t;;\n      pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)\n        # Portland Group compilers (*not* the Pentium gcc compiler,\n\t# which looks to be a dead project)\n\tlt_prog_compiler_wl='-Wl,'\n\tlt_prog_compiler_pic='-fpic'\n\tlt_prog_compiler_static='-Bstatic'\n        ;;\n      ccc*)\n        lt_prog_compiler_wl='-Wl,'\n        # All Alpha code is PIC.\n        lt_prog_compiler_static='-non_shared'\n        ;;\n      xl* | bgxl* | bgf* | mpixl*)\n\t# IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene\n\tlt_prog_compiler_wl='-Wl,'\n\tlt_prog_compiler_pic='-qpic'\n\tlt_prog_compiler_static='-qstaticlink'\n\t;;\n      *)\n\tcase `$CC -V 2>&1 | sed 5q` in\n\t*Sun\\ Ceres\\ Fortran* | *Sun*Fortran*\\ [1-7].* | *Sun*Fortran*\\ 8.[0-3]*)\n\t  # Sun Fortran 8.3 passes all unrecognized flags to the linker\n\t  lt_prog_compiler_pic='-KPIC'\n\t  lt_prog_compiler_static='-Bstatic'\n\t  lt_prog_compiler_wl=''\n\t  ;;\n\t*Sun\\ F* | *Sun*Fortran*)\n\t  lt_prog_compiler_pic='-KPIC'\n\t  lt_prog_compiler_static='-Bstatic'\n\t  lt_prog_compiler_wl='-Qoption ld '\n\t  ;;\n\t*Sun\\ C*)\n\t  # Sun C 5.9\n\t  lt_prog_compiler_pic='-KPIC'\n\t  lt_prog_compiler_static='-Bstatic'\n\t  lt_prog_compiler_wl='-Wl,'\n\t  ;;\n        *Intel*\\ [CF]*Compiler*)\n\t  lt_prog_compiler_wl='-Wl,'\n\t  lt_prog_compiler_pic='-fPIC'\n\t  lt_prog_compiler_static='-static'\n\t  ;;\n\t*Portland\\ Group*)\n\t  lt_prog_compiler_wl='-Wl,'\n\t  lt_prog_compiler_pic='-fpic'\n\t  lt_prog_compiler_static='-Bstatic'\n\t  ;;\n\tesac\n\t;;\n      esac\n      ;;\n\n    newsos6)\n      lt_prog_compiler_pic='-KPIC'\n      lt_prog_compiler_static='-Bstatic'\n      ;;\n\n    *nto* | *qnx*)\n      # QNX uses GNU C++, but need to define -shared option too, otherwise\n      # it will coredump.\n      lt_prog_compiler_pic='-fPIC -shared'\n      ;;\n\n    osf3* | osf4* | osf5*)\n      lt_prog_compiler_wl='-Wl,'\n      # All OSF/1 code is PIC.\n      lt_prog_compiler_static='-non_shared'\n      ;;\n\n    rdos*)\n      lt_prog_compiler_static='-non_shared'\n      ;;\n\n    solaris*)\n      lt_prog_compiler_pic='-KPIC'\n      lt_prog_compiler_static='-Bstatic'\n      case $cc_basename in\n      f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)\n\tlt_prog_compiler_wl='-Qoption ld ';;\n      *)\n\tlt_prog_compiler_wl='-Wl,';;\n      esac\n      ;;\n\n    sunos4*)\n      lt_prog_compiler_wl='-Qoption ld '\n      lt_prog_compiler_pic='-PIC'\n      lt_prog_compiler_static='-Bstatic'\n      ;;\n\n    sysv4 | sysv4.2uw2* | sysv4.3*)\n      lt_prog_compiler_wl='-Wl,'\n      lt_prog_compiler_pic='-KPIC'\n      lt_prog_compiler_static='-Bstatic'\n      ;;\n\n    sysv4*MP*)\n      if test -d /usr/nec ;then\n\tlt_prog_compiler_pic='-Kconform_pic'\n\tlt_prog_compiler_static='-Bstatic'\n      fi\n      ;;\n\n    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)\n      lt_prog_compiler_wl='-Wl,'\n      lt_prog_compiler_pic='-KPIC'\n      lt_prog_compiler_static='-Bstatic'\n      ;;\n\n    unicos*)\n      lt_prog_compiler_wl='-Wl,'\n      lt_prog_compiler_can_build_shared=no\n      ;;\n\n    uts4*)\n      lt_prog_compiler_pic='-pic'\n      lt_prog_compiler_static='-Bstatic'\n      ;;\n\n    *)\n      lt_prog_compiler_can_build_shared=no\n      ;;\n    esac\n  fi\n\ncase $host_os in\n  # For platforms which do not support PIC, -DPIC is meaningless:\n  *djgpp*)\n    lt_prog_compiler_pic=\n    ;;\n  *)\n    lt_prog_compiler_pic=\"$lt_prog_compiler_pic -DPIC\"\n    ;;\nesac\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC\" >&5\n$as_echo_n \"checking for $compiler option to produce PIC... \" >&6; }\nif ${lt_cv_prog_compiler_pic+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_prog_compiler_pic=$lt_prog_compiler_pic\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic\" >&5\n$as_echo \"$lt_cv_prog_compiler_pic\" >&6; }\nlt_prog_compiler_pic=$lt_cv_prog_compiler_pic\n\n#\n# Check to make sure the PIC flag actually works.\n#\nif test -n \"$lt_prog_compiler_pic\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works\" >&5\n$as_echo_n \"checking if $compiler PIC flag $lt_prog_compiler_pic works... \" >&6; }\nif ${lt_cv_prog_compiler_pic_works+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_prog_compiler_pic_works=no\n   ac_outfile=conftest.$ac_objext\n   echo \"$lt_simple_compile_test_code\" > conftest.$ac_ext\n   lt_compiler_flag=\"$lt_prog_compiler_pic -DPIC\"\n   # Insert the option either (1) after the last *FLAGS variable, or\n   # (2) before a word containing \"conftest.\", or (3) at the end.\n   # Note that $ac_compile itself does not contain backslashes and begins\n   # with a dollar sign (not a hyphen), so the echo should work correctly.\n   # The option is referenced via a variable to avoid confusing sed.\n   lt_compile=`echo \"$ac_compile\" | $SED \\\n   -e 's:.*FLAGS}\\{0,1\\} :&$lt_compiler_flag :; t' \\\n   -e 's: [^ ]*conftest\\.: $lt_compiler_flag&:; t' \\\n   -e 's:$: $lt_compiler_flag:'`\n   (eval echo \"\\\"\\$as_me:$LINENO: $lt_compile\\\"\" >&5)\n   (eval \"$lt_compile\" 2>conftest.err)\n   ac_status=$?\n   cat conftest.err >&5\n   echo \"$as_me:$LINENO: \\$? = $ac_status\" >&5\n   if (exit $ac_status) && test -s \"$ac_outfile\"; then\n     # The compiler can only warn and ignore the option if not recognized\n     # So say no if there are warnings other than the usual output.\n     $ECHO \"$_lt_compiler_boilerplate\" | $SED '/^$/d' >conftest.exp\n     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2\n     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then\n       lt_cv_prog_compiler_pic_works=yes\n     fi\n   fi\n   $RM conftest*\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works\" >&5\n$as_echo \"$lt_cv_prog_compiler_pic_works\" >&6; }\n\nif test x\"$lt_cv_prog_compiler_pic_works\" = xyes; then\n    case $lt_prog_compiler_pic in\n     \"\" | \" \"*) ;;\n     *) lt_prog_compiler_pic=\" $lt_prog_compiler_pic\" ;;\n     esac\nelse\n    lt_prog_compiler_pic=\n     lt_prog_compiler_can_build_shared=no\nfi\n\nfi\n\n\n\n\n\n\n\n\n\n\n\n#\n# Check to make sure the static flag actually works.\n#\nwl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\\\"$lt_prog_compiler_static\\\"\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works\" >&5\n$as_echo_n \"checking if $compiler static flag $lt_tmp_static_flag works... \" >&6; }\nif ${lt_cv_prog_compiler_static_works+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_prog_compiler_static_works=no\n   save_LDFLAGS=\"$LDFLAGS\"\n   LDFLAGS=\"$LDFLAGS $lt_tmp_static_flag\"\n   echo \"$lt_simple_link_test_code\" > conftest.$ac_ext\n   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then\n     # The linker can only warn and ignore the option if not recognized\n     # So say no if there are warnings\n     if test -s conftest.err; then\n       # Append any errors to the config.log.\n       cat conftest.err 1>&5\n       $ECHO \"$_lt_linker_boilerplate\" | $SED '/^$/d' > conftest.exp\n       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2\n       if diff conftest.exp conftest.er2 >/dev/null; then\n         lt_cv_prog_compiler_static_works=yes\n       fi\n     else\n       lt_cv_prog_compiler_static_works=yes\n     fi\n   fi\n   $RM -r conftest*\n   LDFLAGS=\"$save_LDFLAGS\"\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works\" >&5\n$as_echo \"$lt_cv_prog_compiler_static_works\" >&6; }\n\nif test x\"$lt_cv_prog_compiler_static_works\" = xyes; then\n    :\nelse\n    lt_prog_compiler_static=\nfi\n\n\n\n\n\n\n\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext\" >&5\n$as_echo_n \"checking if $compiler supports -c -o file.$ac_objext... \" >&6; }\nif ${lt_cv_prog_compiler_c_o+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_prog_compiler_c_o=no\n   $RM -r conftest 2>/dev/null\n   mkdir conftest\n   cd conftest\n   mkdir out\n   echo \"$lt_simple_compile_test_code\" > conftest.$ac_ext\n\n   lt_compiler_flag=\"-o out/conftest2.$ac_objext\"\n   # Insert the option either (1) after the last *FLAGS variable, or\n   # (2) before a word containing \"conftest.\", or (3) at the end.\n   # Note that $ac_compile itself does not contain backslashes and begins\n   # with a dollar sign (not a hyphen), so the echo should work correctly.\n   lt_compile=`echo \"$ac_compile\" | $SED \\\n   -e 's:.*FLAGS}\\{0,1\\} :&$lt_compiler_flag :; t' \\\n   -e 's: [^ ]*conftest\\.: $lt_compiler_flag&:; t' \\\n   -e 's:$: $lt_compiler_flag:'`\n   (eval echo \"\\\"\\$as_me:$LINENO: $lt_compile\\\"\" >&5)\n   (eval \"$lt_compile\" 2>out/conftest.err)\n   ac_status=$?\n   cat out/conftest.err >&5\n   echo \"$as_me:$LINENO: \\$? = $ac_status\" >&5\n   if (exit $ac_status) && test -s out/conftest2.$ac_objext\n   then\n     # The compiler can only warn and ignore the option if not recognized\n     # So say no if there are warnings\n     $ECHO \"$_lt_compiler_boilerplate\" | $SED '/^$/d' > out/conftest.exp\n     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2\n     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then\n       lt_cv_prog_compiler_c_o=yes\n     fi\n   fi\n   chmod u+w . 2>&5\n   $RM conftest*\n   # SGI C++ compiler will create directory out/ii_files/ for\n   # template instantiation\n   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files\n   $RM out/* && rmdir out\n   cd ..\n   $RM -r conftest\n   $RM conftest*\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o\" >&5\n$as_echo \"$lt_cv_prog_compiler_c_o\" >&6; }\n\n\n\n\n\n\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext\" >&5\n$as_echo_n \"checking if $compiler supports -c -o file.$ac_objext... \" >&6; }\nif ${lt_cv_prog_compiler_c_o+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_prog_compiler_c_o=no\n   $RM -r conftest 2>/dev/null\n   mkdir conftest\n   cd conftest\n   mkdir out\n   echo \"$lt_simple_compile_test_code\" > conftest.$ac_ext\n\n   lt_compiler_flag=\"-o out/conftest2.$ac_objext\"\n   # Insert the option either (1) after the last *FLAGS variable, or\n   # (2) before a word containing \"conftest.\", or (3) at the end.\n   # Note that $ac_compile itself does not contain backslashes and begins\n   # with a dollar sign (not a hyphen), so the echo should work correctly.\n   lt_compile=`echo \"$ac_compile\" | $SED \\\n   -e 's:.*FLAGS}\\{0,1\\} :&$lt_compiler_flag :; t' \\\n   -e 's: [^ ]*conftest\\.: $lt_compiler_flag&:; t' \\\n   -e 's:$: $lt_compiler_flag:'`\n   (eval echo \"\\\"\\$as_me:$LINENO: $lt_compile\\\"\" >&5)\n   (eval \"$lt_compile\" 2>out/conftest.err)\n   ac_status=$?\n   cat out/conftest.err >&5\n   echo \"$as_me:$LINENO: \\$? = $ac_status\" >&5\n   if (exit $ac_status) && test -s out/conftest2.$ac_objext\n   then\n     # The compiler can only warn and ignore the option if not recognized\n     # So say no if there are warnings\n     $ECHO \"$_lt_compiler_boilerplate\" | $SED '/^$/d' > out/conftest.exp\n     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2\n     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then\n       lt_cv_prog_compiler_c_o=yes\n     fi\n   fi\n   chmod u+w . 2>&5\n   $RM conftest*\n   # SGI C++ compiler will create directory out/ii_files/ for\n   # template instantiation\n   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files\n   $RM out/* && rmdir out\n   cd ..\n   $RM -r conftest\n   $RM conftest*\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o\" >&5\n$as_echo \"$lt_cv_prog_compiler_c_o\" >&6; }\n\n\n\n\nhard_links=\"nottested\"\nif test \"$lt_cv_prog_compiler_c_o\" = no && test \"$need_locks\" != no; then\n  # do not overwrite the value of need_locks provided by the user\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links\" >&5\n$as_echo_n \"checking if we can lock with hard links... \" >&6; }\n  hard_links=yes\n  $RM conftest*\n  ln conftest.a conftest.b 2>/dev/null && hard_links=no\n  touch conftest.a\n  ln conftest.a conftest.b 2>&5 || hard_links=no\n  ln conftest.a conftest.b 2>/dev/null && hard_links=no\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $hard_links\" >&5\n$as_echo \"$hard_links\" >&6; }\n  if test \"$hard_links\" = no; then\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: \\`$CC' does not support \\`-c -o', so \\`make -j' may be unsafe\" >&5\n$as_echo \"$as_me: WARNING: \\`$CC' does not support \\`-c -o', so \\`make -j' may be unsafe\" >&2;}\n    need_locks=warn\n  fi\nelse\n  need_locks=no\nfi\n\n\n\n\n\n\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries\" >&5\n$as_echo_n \"checking whether the $compiler linker ($LD) supports shared libraries... \" >&6; }\n\n  runpath_var=\n  allow_undefined_flag=\n  always_export_symbols=no\n  archive_cmds=\n  archive_expsym_cmds=\n  compiler_needs_object=no\n  enable_shared_with_static_runtimes=no\n  export_dynamic_flag_spec=\n  export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\\''s/.* //'\\'' | sort | uniq > $export_symbols'\n  hardcode_automatic=no\n  hardcode_direct=no\n  hardcode_direct_absolute=no\n  hardcode_libdir_flag_spec=\n  hardcode_libdir_separator=\n  hardcode_minus_L=no\n  hardcode_shlibpath_var=unsupported\n  inherit_rpath=no\n  link_all_deplibs=unknown\n  module_cmds=\n  module_expsym_cmds=\n  old_archive_from_new_cmds=\n  old_archive_from_expsyms_cmds=\n  thread_safe_flag_spec=\n  whole_archive_flag_spec=\n  # include_expsyms should be a list of space-separated symbols to be *always*\n  # included in the symbol list\n  include_expsyms=\n  # exclude_expsyms can be an extended regexp of symbols to exclude\n  # it will be wrapped by ` (' and `)$', so one must not match beginning or\n  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',\n  # as well as any symbol that contains `d'.\n  exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'\n  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out\n  # platforms (ab)use it in PIC code, but their linkers get confused if\n  # the symbol is explicitly referenced.  Since portable code cannot\n  # rely on this symbol name, it's probably fine to never include it in\n  # preloaded symbol tables.\n  # Exclude shared library initialization/finalization symbols.\n  extract_expsyms_cmds=\n\n  case $host_os in\n  cygwin* | mingw* | pw32* | cegcc*)\n    # FIXME: the MSVC++ port hasn't been tested in a loooong time\n    # When not using gcc, we currently assume that we are using\n    # Microsoft Visual C++.\n    if test \"$GCC\" != yes; then\n      with_gnu_ld=no\n    fi\n    ;;\n  interix*)\n    # we just hope/assume this is gcc and not c89 (= MSVC++)\n    with_gnu_ld=yes\n    ;;\n  openbsd*)\n    with_gnu_ld=no\n    ;;\n  linux* | k*bsd*-gnu | gnu*)\n    link_all_deplibs=no\n    ;;\n  esac\n\n  ld_shlibs=yes\n\n  # On some targets, GNU ld is compatible enough with the native linker\n  # that we're better off using the native interface for both.\n  lt_use_gnu_ld_interface=no\n  if test \"$with_gnu_ld\" = yes; then\n    case $host_os in\n      aix*)\n\t# The AIX port of GNU ld has always aspired to compatibility\n\t# with the native linker.  However, as the warning in the GNU ld\n\t# block says, versions before 2.19.5* couldn't really create working\n\t# shared libraries, regardless of the interface used.\n\tcase `$LD -v 2>&1` in\n\t  *\\ \\(GNU\\ Binutils\\)\\ 2.19.5*) ;;\n\t  *\\ \\(GNU\\ Binutils\\)\\ 2.[2-9]*) ;;\n\t  *\\ \\(GNU\\ Binutils\\)\\ [3-9]*) ;;\n\t  *)\n\t    lt_use_gnu_ld_interface=yes\n\t    ;;\n\tesac\n\t;;\n      *)\n\tlt_use_gnu_ld_interface=yes\n\t;;\n    esac\n  fi\n\n  if test \"$lt_use_gnu_ld_interface\" = yes; then\n    # If archive_cmds runs LD, not CC, wlarc should be empty\n    wlarc='${wl}'\n\n    # Set some defaults for GNU ld with shared library support. These\n    # are reset later if shared libraries are not supported. Putting them\n    # here allows them to be overridden if necessary.\n    runpath_var=LD_RUN_PATH\n    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'\n    export_dynamic_flag_spec='${wl}--export-dynamic'\n    # ancient GNU ld didn't support --whole-archive et. al.\n    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then\n      whole_archive_flag_spec=\"$wlarc\"'--whole-archive$convenience '\"$wlarc\"'--no-whole-archive'\n    else\n      whole_archive_flag_spec=\n    fi\n    supports_anon_versioning=no\n    case `$LD -v 2>&1` in\n      *GNU\\ gold*) supports_anon_versioning=yes ;;\n      *\\ [01].* | *\\ 2.[0-9].* | *\\ 2.10.*) ;; # catch versions < 2.11\n      *\\ 2.11.93.0.2\\ *) supports_anon_versioning=yes ;; # RH7.3 ...\n      *\\ 2.11.92.0.12\\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...\n      *\\ 2.11.*) ;; # other 2.11 versions\n      *) supports_anon_versioning=yes ;;\n    esac\n\n    # See if GNU ld supports shared libraries.\n    case $host_os in\n    aix[3-9]*)\n      # On AIX/PPC, the GNU linker is very broken\n      if test \"$host_cpu\" != ia64; then\n\tld_shlibs=no\n\tcat <<_LT_EOF 1>&2\n\n*** Warning: the GNU linker, at least up to release 2.19, is reported\n*** to be unable to reliably create shared libraries on AIX.\n*** Therefore, libtool is disabling shared libraries support.  If you\n*** really care for shared libraries, you may want to install binutils\n*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.\n*** You will then need to restart the configuration process.\n\n_LT_EOF\n      fi\n      ;;\n\n    amigaos*)\n      case $host_cpu in\n      powerpc)\n            # see comment about AmigaOS4 .so support\n            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n            archive_expsym_cmds=''\n        ;;\n      m68k)\n            archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO \"#define NAME $libname\" > $output_objdir/a2ixlibrary.data~$ECHO \"#define LIBRARY_ID 1\" >> $output_objdir/a2ixlibrary.data~$ECHO \"#define VERSION $major\" >> $output_objdir/a2ixlibrary.data~$ECHO \"#define REVISION $revision\" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'\n            hardcode_libdir_flag_spec='-L$libdir'\n            hardcode_minus_L=yes\n        ;;\n      esac\n      ;;\n\n    beos*)\n      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then\n\tallow_undefined_flag=unsupported\n\t# Joseph Beckenbach <jrb3@best.com> says some releases of gcc\n\t# support --undefined.  This deserves some investigation.  FIXME\n\tarchive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n      else\n\tld_shlibs=no\n      fi\n      ;;\n\n    cygwin* | mingw* | pw32* | cegcc*)\n      # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,\n      # as there is no search path for DLLs.\n      hardcode_libdir_flag_spec='-L$libdir'\n      export_dynamic_flag_spec='${wl}--export-all-symbols'\n      allow_undefined_flag=unsupported\n      always_export_symbols=no\n      enable_shared_with_static_runtimes=yes\n      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\\''/^[BCDGRS][ ]/s/.*[ ]\\([^ ]*\\)/\\1 DATA/;s/^.*[ ]__nm__\\([^ ]*\\)[ ][^ ]*/\\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\\'' | sort | uniq > $export_symbols'\n      exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'\n\n      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then\n        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'\n\t# If the export-symbols file already is a .def file (1st line\n\t# is EXPORTS), use it as is; otherwise, prepend...\n\tarchive_expsym_cmds='if test \"x`$SED 1q $export_symbols`\" = xEXPORTS; then\n\t  cp $export_symbols $output_objdir/$soname.def;\n\telse\n\t  echo EXPORTS > $output_objdir/$soname.def;\n\t  cat $export_symbols >> $output_objdir/$soname.def;\n\tfi~\n\t$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'\n      else\n\tld_shlibs=no\n      fi\n      ;;\n\n    haiku*)\n      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n      link_all_deplibs=yes\n      ;;\n\n    interix[3-9]*)\n      hardcode_direct=no\n      hardcode_shlibpath_var=no\n      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'\n      export_dynamic_flag_spec='${wl}-E'\n      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.\n      # Instead, shared libraries are loaded at an image base (0x10000000 by\n      # default) and relocated if they conflict, which is a slow very memory\n      # consuming and fragmenting process.  To avoid this, we pick a random,\n      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link\n      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.\n      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \\* 262144 + 1342177280` -o $lib'\n      archive_expsym_cmds='sed \"s,^,_,\" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \\* 262144 + 1342177280` -o $lib'\n      ;;\n\n    gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)\n      tmp_diet=no\n      if test \"$host_os\" = linux-dietlibc; then\n\tcase $cc_basename in\n\t  diet\\ *) tmp_diet=yes;;\t# linux-dietlibc with static linking (!diet-dyn)\n\tesac\n      fi\n      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \\\n\t && test \"$tmp_diet\" = no\n      then\n\ttmp_addflag=' $pic_flag'\n\ttmp_sharedflag='-shared'\n\tcase $cc_basename,$host_cpu in\n        pgcc*)\t\t\t\t# Portland Group C compiler\n\t  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\\\"\\\"; do test  -n \\\"$conv\\\" && new_convenience=\\\"$new_convenience,$conv\\\"; done; func_echo_all \\\"$new_convenience\\\"` ${wl}--no-whole-archive'\n\t  tmp_addflag=' $pic_flag'\n\t  ;;\n\tpgf77* | pgf90* | pgf95* | pgfortran*)\n\t\t\t\t\t# Portland Group f77 and f90 compilers\n\t  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\\\"\\\"; do test  -n \\\"$conv\\\" && new_convenience=\\\"$new_convenience,$conv\\\"; done; func_echo_all \\\"$new_convenience\\\"` ${wl}--no-whole-archive'\n\t  tmp_addflag=' $pic_flag -Mnomain' ;;\n\tecc*,ia64* | icc*,ia64*)\t# Intel C compiler on ia64\n\t  tmp_addflag=' -i_dynamic' ;;\n\tefc*,ia64* | ifort*,ia64*)\t# Intel Fortran compiler on ia64\n\t  tmp_addflag=' -i_dynamic -nofor_main' ;;\n\tifc* | ifort*)\t\t\t# Intel Fortran compiler\n\t  tmp_addflag=' -nofor_main' ;;\n\tlf95*)\t\t\t\t# Lahey Fortran 8.1\n\t  whole_archive_flag_spec=\n\t  tmp_sharedflag='--shared' ;;\n\txl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)\n\t  tmp_sharedflag='-qmkshrobj'\n\t  tmp_addflag= ;;\n\tnvcc*)\t# Cuda Compiler Driver 2.2\n\t  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\\\"\\\"; do test  -n \\\"$conv\\\" && new_convenience=\\\"$new_convenience,$conv\\\"; done; func_echo_all \\\"$new_convenience\\\"` ${wl}--no-whole-archive'\n\t  compiler_needs_object=yes\n\t  ;;\n\tesac\n\tcase `$CC -V 2>&1 | sed 5q` in\n\t*Sun\\ C*)\t\t\t# Sun C 5.9\n\t  whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\\\"\\\"; do test -z \\\"$conv\\\" || new_convenience=\\\"$new_convenience,$conv\\\"; done; func_echo_all \\\"$new_convenience\\\"` ${wl}--no-whole-archive'\n\t  compiler_needs_object=yes\n\t  tmp_sharedflag='-G' ;;\n\t*Sun\\ F*)\t\t\t# Sun Fortran 8.3\n\t  tmp_sharedflag='-G' ;;\n\tesac\n\tarchive_cmds='$CC '\"$tmp_sharedflag\"\"$tmp_addflag\"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n\n        if test \"x$supports_anon_versioning\" = xyes; then\n          archive_expsym_cmds='echo \"{ global:\" > $output_objdir/$libname.ver~\n\t    cat $export_symbols | sed -e \"s/\\(.*\\)/\\1;/\" >> $output_objdir/$libname.ver~\n\t    echo \"local: *; };\" >> $output_objdir/$libname.ver~\n\t    $CC '\"$tmp_sharedflag\"\"$tmp_addflag\"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'\n        fi\n\n\tcase $cc_basename in\n\txlf* | bgf* | bgxlf* | mpixlf*)\n\t  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself\n\t  whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'\n\t  hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'\n\t  archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'\n\t  if test \"x$supports_anon_versioning\" = xyes; then\n\t    archive_expsym_cmds='echo \"{ global:\" > $output_objdir/$libname.ver~\n\t      cat $export_symbols | sed -e \"s/\\(.*\\)/\\1;/\" >> $output_objdir/$libname.ver~\n\t      echo \"local: *; };\" >> $output_objdir/$libname.ver~\n\t      $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'\n\t  fi\n\t  ;;\n\tesac\n      else\n        ld_shlibs=no\n      fi\n      ;;\n\n    netbsd* | netbsdelf*-gnu)\n      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then\n\tarchive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'\n\twlarc=\n      else\n\tarchive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n\tarchive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'\n      fi\n      ;;\n\n    solaris*)\n      if $LD -v 2>&1 | $GREP 'BFD 2\\.8' > /dev/null; then\n\tld_shlibs=no\n\tcat <<_LT_EOF 1>&2\n\n*** Warning: The releases 2.8.* of the GNU linker cannot reliably\n*** create shared libraries on Solaris systems.  Therefore, libtool\n*** is disabling shared libraries support.  We urge you to upgrade GNU\n*** binutils to release 2.9.1 or newer.  Another option is to modify\n*** your PATH or compiler configuration so that the native linker is\n*** used, and then restart.\n\n_LT_EOF\n      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then\n\tarchive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n\tarchive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'\n      else\n\tld_shlibs=no\n      fi\n      ;;\n\n    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)\n      case `$LD -v 2>&1` in\n        *\\ [01].* | *\\ 2.[0-9].* | *\\ 2.1[0-5].*)\n\tld_shlibs=no\n\tcat <<_LT_EOF 1>&2\n\n*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not\n*** reliably create shared libraries on SCO systems.  Therefore, libtool\n*** is disabling shared libraries support.  We urge you to upgrade GNU\n*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify\n*** your PATH or compiler configuration so that the native linker is\n*** used, and then restart.\n\n_LT_EOF\n\t;;\n\t*)\n\t  # For security reasons, it is highly recommended that you always\n\t  # use absolute paths for naming shared libraries, and exclude the\n\t  # DT_RUNPATH tag from executables and libraries.  But doing so\n\t  # requires that you compile everything twice, which is a pain.\n\t  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then\n\t    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'\n\t    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n\t    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'\n\t  else\n\t    ld_shlibs=no\n\t  fi\n\t;;\n      esac\n      ;;\n\n    sunos4*)\n      archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'\n      wlarc=\n      hardcode_direct=yes\n      hardcode_shlibpath_var=no\n      ;;\n\n    *)\n      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then\n\tarchive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n\tarchive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'\n      else\n\tld_shlibs=no\n      fi\n      ;;\n    esac\n\n    if test \"$ld_shlibs\" = no; then\n      runpath_var=\n      hardcode_libdir_flag_spec=\n      export_dynamic_flag_spec=\n      whole_archive_flag_spec=\n    fi\n  else\n    # PORTME fill in a description of your system's linker (not GNU ld)\n    case $host_os in\n    aix3*)\n      allow_undefined_flag=unsupported\n      always_export_symbols=yes\n      archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'\n      # Note: this linker hardcodes the directories in LIBPATH if there\n      # are no directories specified by -L.\n      hardcode_minus_L=yes\n      if test \"$GCC\" = yes && test -z \"$lt_prog_compiler_static\"; then\n\t# Neither direct hardcoding nor static linking is supported with a\n\t# broken collect2.\n\thardcode_direct=unsupported\n      fi\n      ;;\n\n    aix[4-9]*)\n      if test \"$host_cpu\" = ia64; then\n\t# On IA64, the linker does run time linking by default, so we don't\n\t# have to do anything special.\n\taix_use_runtimelinking=no\n\texp_sym_flag='-Bexport'\n\tno_entry_flag=\"\"\n      else\n\t# If we're using GNU nm, then we don't want the \"-C\" option.\n\t# -C means demangle to AIX nm, but means don't demangle with GNU nm\n\t# Also, AIX nm treats weak defined symbols like other global\n\t# defined symbols, whereas GNU nm marks them as \"W\".\n\tif $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then\n\t  export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\\''{ if (((\\$ 2 == \"T\") || (\\$ 2 == \"D\") || (\\$ 2 == \"B\") || (\\$ 2 == \"W\")) && (substr(\\$ 3,1,1) != \".\")) { print \\$ 3 } }'\\'' | sort -u > $export_symbols'\n\telse\n\t  export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\\''{ if (((\\$ 2 == \"T\") || (\\$ 2 == \"D\") || (\\$ 2 == \"B\")) && (substr(\\$ 3,1,1) != \".\")) { print \\$ 3 } }'\\'' | sort -u > $export_symbols'\n\tfi\n\taix_use_runtimelinking=no\n\n\t# Test if we are trying to use run time linking or normal\n\t# AIX style linking. If -brtl is somewhere in LDFLAGS, we\n\t# need to do runtime linking.\n\tcase $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)\n\t  for ld_flag in $LDFLAGS; do\n\t  if (test $ld_flag = \"-brtl\" || test $ld_flag = \"-Wl,-brtl\"); then\n\t    aix_use_runtimelinking=yes\n\t    break\n\t  fi\n\t  done\n\t  ;;\n\tesac\n\n\texp_sym_flag='-bexport'\n\tno_entry_flag='-bnoentry'\n      fi\n\n      # When large executables or shared objects are built, AIX ld can\n      # have problems creating the table of contents.  If linking a library\n      # or program results in \"error TOC overflow\" add -mminimal-toc to\n      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not\n      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.\n\n      archive_cmds=''\n      hardcode_direct=yes\n      hardcode_direct_absolute=yes\n      hardcode_libdir_separator=':'\n      link_all_deplibs=yes\n      file_list_spec='${wl}-f,'\n\n      if test \"$GCC\" = yes; then\n\tcase $host_os in aix4.[012]|aix4.[012].*)\n\t# We only want to do this on AIX 4.2 and lower, the check\n\t# below for broken collect2 doesn't work under 4.3+\n\t  collect2name=`${CC} -print-prog-name=collect2`\n\t  if test -f \"$collect2name\" &&\n\t   strings \"$collect2name\" | $GREP resolve_lib_name >/dev/null\n\t  then\n\t  # We have reworked collect2\n\t  :\n\t  else\n\t  # We have old collect2\n\t  hardcode_direct=unsupported\n\t  # It fails to find uninstalled libraries when the uninstalled\n\t  # path is not listed in the libpath.  Setting hardcode_minus_L\n\t  # to unsupported forces relinking\n\t  hardcode_minus_L=yes\n\t  hardcode_libdir_flag_spec='-L$libdir'\n\t  hardcode_libdir_separator=\n\t  fi\n\t  ;;\n\tesac\n\tshared_flag='-shared'\n\tif test \"$aix_use_runtimelinking\" = yes; then\n\t  shared_flag=\"$shared_flag \"'${wl}-G'\n\tfi\n\tlink_all_deplibs=no\n      else\n\t# not using gcc\n\tif test \"$host_cpu\" = ia64; then\n\t# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release\n\t# chokes on -Wl,-G. The following line is correct:\n\t  shared_flag='-G'\n\telse\n\t  if test \"$aix_use_runtimelinking\" = yes; then\n\t    shared_flag='${wl}-G'\n\t  else\n\t    shared_flag='${wl}-bM:SRE'\n\t  fi\n\tfi\n      fi\n\n      export_dynamic_flag_spec='${wl}-bexpall'\n      # It seems that -bexpall does not export symbols beginning with\n      # underscore (_), so it is better to generate a list of symbols to export.\n      always_export_symbols=yes\n      if test \"$aix_use_runtimelinking\" = yes; then\n\t# Warning - without using the other runtime loading flags (-brtl),\n\t# -berok will link without error, but may produce a broken library.\n\tallow_undefined_flag='-berok'\n        # Determine the default libpath from the value encoded in an\n        # empty executable.\n        if test \"${lt_cv_aix_libpath+set}\" = set; then\n  aix_libpath=$lt_cv_aix_libpath\nelse\n  if ${lt_cv_aix_libpath_+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_link \"$LINENO\"; then :\n\n  lt_aix_libpath_sed='\n      /Import File Strings/,/^$/ {\n\t  /^0/ {\n\t      s/^0  *\\([^ ]*\\) *$/\\1/\n\t      p\n\t  }\n      }'\n  lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e \"$lt_aix_libpath_sed\"`\n  # Check for a 64-bit object if we didn't find anything.\n  if test -z \"$lt_cv_aix_libpath_\"; then\n    lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e \"$lt_aix_libpath_sed\"`\n  fi\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\n  if test -z \"$lt_cv_aix_libpath_\"; then\n    lt_cv_aix_libpath_=\"/usr/lib:/lib\"\n  fi\n\nfi\n\n  aix_libpath=$lt_cv_aix_libpath_\nfi\n\n        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'\"$aix_libpath\"\n        archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '\"\\${wl}$no_entry_flag\"' $compiler_flags `if test \"x${allow_undefined_flag}\" != \"x\"; then func_echo_all \"${wl}${allow_undefined_flag}\"; else :; fi` '\"\\${wl}$exp_sym_flag:\\$export_symbols $shared_flag\"\n      else\n\tif test \"$host_cpu\" = ia64; then\n\t  hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'\n\t  allow_undefined_flag=\"-z nodefs\"\n\t  archive_expsym_cmds=\"\\$CC $shared_flag\"' -o $output_objdir/$soname $libobjs $deplibs '\"\\${wl}$no_entry_flag\"' $compiler_flags ${wl}${allow_undefined_flag} '\"\\${wl}$exp_sym_flag:\\$export_symbols\"\n\telse\n\t # Determine the default libpath from the value encoded in an\n\t # empty executable.\n\t if test \"${lt_cv_aix_libpath+set}\" = set; then\n  aix_libpath=$lt_cv_aix_libpath\nelse\n  if ${lt_cv_aix_libpath_+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_link \"$LINENO\"; then :\n\n  lt_aix_libpath_sed='\n      /Import File Strings/,/^$/ {\n\t  /^0/ {\n\t      s/^0  *\\([^ ]*\\) *$/\\1/\n\t      p\n\t  }\n      }'\n  lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e \"$lt_aix_libpath_sed\"`\n  # Check for a 64-bit object if we didn't find anything.\n  if test -z \"$lt_cv_aix_libpath_\"; then\n    lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e \"$lt_aix_libpath_sed\"`\n  fi\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\n  if test -z \"$lt_cv_aix_libpath_\"; then\n    lt_cv_aix_libpath_=\"/usr/lib:/lib\"\n  fi\n\nfi\n\n  aix_libpath=$lt_cv_aix_libpath_\nfi\n\n\t hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'\"$aix_libpath\"\n\t  # Warning - without using the other run time loading flags,\n\t  # -berok will link without error, but may produce a broken library.\n\t  no_undefined_flag=' ${wl}-bernotok'\n\t  allow_undefined_flag=' ${wl}-berok'\n\t  if test \"$with_gnu_ld\" = yes; then\n\t    # We only use this code for GNU lds that support --whole-archive.\n\t    whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive'\n\t  else\n\t    # Exported symbols can be pulled into shared objects from archives\n\t    whole_archive_flag_spec='$convenience'\n\t  fi\n\t  archive_cmds_need_lc=yes\n\t  # This is similar to how AIX traditionally builds its shared libraries.\n\t  archive_expsym_cmds=\"\\$CC $shared_flag\"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'\n\tfi\n      fi\n      ;;\n\n    amigaos*)\n      case $host_cpu in\n      powerpc)\n            # see comment about AmigaOS4 .so support\n            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n            archive_expsym_cmds=''\n        ;;\n      m68k)\n            archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO \"#define NAME $libname\" > $output_objdir/a2ixlibrary.data~$ECHO \"#define LIBRARY_ID 1\" >> $output_objdir/a2ixlibrary.data~$ECHO \"#define VERSION $major\" >> $output_objdir/a2ixlibrary.data~$ECHO \"#define REVISION $revision\" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'\n            hardcode_libdir_flag_spec='-L$libdir'\n            hardcode_minus_L=yes\n        ;;\n      esac\n      ;;\n\n    bsdi[45]*)\n      export_dynamic_flag_spec=-rdynamic\n      ;;\n\n    cygwin* | mingw* | pw32* | cegcc*)\n      # When not using gcc, we currently assume that we are using\n      # Microsoft Visual C++.\n      # hardcode_libdir_flag_spec is actually meaningless, as there is\n      # no search path for DLLs.\n      case $cc_basename in\n      cl*)\n\t# Native MSVC\n\thardcode_libdir_flag_spec=' '\n\tallow_undefined_flag=unsupported\n\talways_export_symbols=yes\n\tfile_list_spec='@'\n\t# Tell ltmain to make .lib files, not .a files.\n\tlibext=lib\n\t# Tell ltmain to make .dll files, not .so files.\n\tshrext_cmds=\".dll\"\n\t# FIXME: Setting linknames here is a bad hack.\n\tarchive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='\n\tarchive_expsym_cmds='if test \"x`$SED 1q $export_symbols`\" = xEXPORTS; then\n\t    sed -n -e 's/\\\\\\\\\\\\\\(.*\\\\\\\\\\\\\\)/-link\\\\\\ -EXPORT:\\\\\\\\\\\\\\1/' -e '1\\\\\\!p' < $export_symbols > $output_objdir/$soname.exp;\n\t  else\n\t    sed -e 's/\\\\\\\\\\\\\\(.*\\\\\\\\\\\\\\)/-link\\\\\\ -EXPORT:\\\\\\\\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;\n\t  fi~\n\t  $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs \"@$tool_output_objdir$soname.exp\" -Wl,-DLL,-IMPLIB:\"$tool_output_objdir$libname.dll.lib\"~\n\t  linknames='\n\t# The linker will not automatically build a static lib if we build a DLL.\n\t# _LT_TAGVAR(old_archive_from_new_cmds, )='true'\n\tenable_shared_with_static_runtimes=yes\n\texclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'\n\texport_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\\''/^[BCDGRS][ ]/s/.*[ ]\\([^ ]*\\)/\\1,DATA/'\\'' | $SED -e '\\''/^[AITW][ ]/s/.*[ ]//'\\'' | sort | uniq > $export_symbols'\n\t# Don't use ranlib\n\told_postinstall_cmds='chmod 644 $oldlib'\n\tpostlink_cmds='lt_outputfile=\"@OUTPUT@\"~\n\t  lt_tool_outputfile=\"@TOOL_OUTPUT@\"~\n\t  case $lt_outputfile in\n\t    *.exe|*.EXE) ;;\n\t    *)\n\t      lt_outputfile=\"$lt_outputfile.exe\"\n\t      lt_tool_outputfile=\"$lt_tool_outputfile.exe\"\n\t      ;;\n\t  esac~\n\t  if test \"$MANIFEST_TOOL\" != \":\" && test -f \"$lt_outputfile.manifest\"; then\n\t    $MANIFEST_TOOL -manifest \"$lt_tool_outputfile.manifest\" -outputresource:\"$lt_tool_outputfile\" || exit 1;\n\t    $RM \"$lt_outputfile.manifest\";\n\t  fi'\n\t;;\n      *)\n\t# Assume MSVC wrapper\n\thardcode_libdir_flag_spec=' '\n\tallow_undefined_flag=unsupported\n\t# Tell ltmain to make .lib files, not .a files.\n\tlibext=lib\n\t# Tell ltmain to make .dll files, not .so files.\n\tshrext_cmds=\".dll\"\n\t# FIXME: Setting linknames here is a bad hack.\n\tarchive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all \"$deplibs\" | $SED '\\''s/ -lc$//'\\''` -link -dll~linknames='\n\t# The linker will automatically build a .lib file if we build a DLL.\n\told_archive_from_new_cmds='true'\n\t# FIXME: Should let the user specify the lib program.\n\told_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs'\n\tenable_shared_with_static_runtimes=yes\n\t;;\n      esac\n      ;;\n\n    darwin* | rhapsody*)\n\n\n  archive_cmds_need_lc=no\n  hardcode_direct=no\n  hardcode_automatic=yes\n  hardcode_shlibpath_var=unsupported\n  if test \"$lt_cv_ld_force_load\" = \"yes\"; then\n    whole_archive_flag_spec='`for conv in $convenience\\\"\\\"; do test  -n \\\"$conv\\\" && new_convenience=\\\"$new_convenience ${wl}-force_load,$conv\\\"; done; func_echo_all \\\"$new_convenience\\\"`'\n\n  else\n    whole_archive_flag_spec=''\n  fi\n  link_all_deplibs=yes\n  allow_undefined_flag=\"$_lt_dar_allow_undefined\"\n  case $cc_basename in\n     ifort*) _lt_dar_can_shared=yes ;;\n     *) _lt_dar_can_shared=$GCC ;;\n  esac\n  if test \"$_lt_dar_can_shared\" = \"yes\"; then\n    output_verbose_link_cmd=func_echo_all\n    archive_cmds=\"\\$CC -dynamiclib \\$allow_undefined_flag -o \\$lib \\$libobjs \\$deplibs \\$compiler_flags -install_name \\$rpath/\\$soname \\$verstring $_lt_dar_single_mod${_lt_dsymutil}\"\n    module_cmds=\"\\$CC \\$allow_undefined_flag -o \\$lib -bundle \\$libobjs \\$deplibs \\$compiler_flags${_lt_dsymutil}\"\n    archive_expsym_cmds=\"sed 's,^,_,' < \\$export_symbols > \\$output_objdir/\\${libname}-symbols.expsym~\\$CC -dynamiclib \\$allow_undefined_flag -o \\$lib \\$libobjs \\$deplibs \\$compiler_flags -install_name \\$rpath/\\$soname \\$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}\"\n    module_expsym_cmds=\"sed -e 's,^,_,' < \\$export_symbols > \\$output_objdir/\\${libname}-symbols.expsym~\\$CC \\$allow_undefined_flag -o \\$lib -bundle \\$libobjs \\$deplibs \\$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}\"\n\n  else\n  ld_shlibs=no\n  fi\n\n      ;;\n\n    dgux*)\n      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'\n      hardcode_libdir_flag_spec='-L$libdir'\n      hardcode_shlibpath_var=no\n      ;;\n\n    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor\n    # support.  Future versions do this automatically, but an explicit c++rt0.o\n    # does not break anything, and helps significantly (at the cost of a little\n    # extra space).\n    freebsd2.2*)\n      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'\n      hardcode_libdir_flag_spec='-R$libdir'\n      hardcode_direct=yes\n      hardcode_shlibpath_var=no\n      ;;\n\n    # Unfortunately, older versions of FreeBSD 2 do not have this feature.\n    freebsd2.*)\n      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'\n      hardcode_direct=yes\n      hardcode_minus_L=yes\n      hardcode_shlibpath_var=no\n      ;;\n\n    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.\n    freebsd* | dragonfly*)\n      archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'\n      hardcode_libdir_flag_spec='-R$libdir'\n      hardcode_direct=yes\n      hardcode_shlibpath_var=no\n      ;;\n\n    hpux9*)\n      if test \"$GCC\" = yes; then\n\tarchive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'\n      else\n\tarchive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'\n      fi\n      hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'\n      hardcode_libdir_separator=:\n      hardcode_direct=yes\n\n      # hardcode_minus_L: Not really in the search PATH,\n      # but as the default location of the library.\n      hardcode_minus_L=yes\n      export_dynamic_flag_spec='${wl}-E'\n      ;;\n\n    hpux10*)\n      if test \"$GCC\" = yes && test \"$with_gnu_ld\" = no; then\n\tarchive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'\n      else\n\tarchive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'\n      fi\n      if test \"$with_gnu_ld\" = no; then\n\thardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'\n\thardcode_libdir_separator=:\n\thardcode_direct=yes\n\thardcode_direct_absolute=yes\n\texport_dynamic_flag_spec='${wl}-E'\n\t# hardcode_minus_L: Not really in the search PATH,\n\t# but as the default location of the library.\n\thardcode_minus_L=yes\n      fi\n      ;;\n\n    hpux11*)\n      if test \"$GCC\" = yes && test \"$with_gnu_ld\" = no; then\n\tcase $host_cpu in\n\thppa*64*)\n\t  archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t  ;;\n\tia64*)\n\t  archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'\n\t  ;;\n\t*)\n\t  archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'\n\t  ;;\n\tesac\n      else\n\tcase $host_cpu in\n\thppa*64*)\n\t  archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t  ;;\n\tia64*)\n\t  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'\n\t  ;;\n\t*)\n\n\t  # Older versions of the 11.00 compiler do not understand -b yet\n\t  # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)\n\t  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking if $CC understands -b\" >&5\n$as_echo_n \"checking if $CC understands -b... \" >&6; }\nif ${lt_cv_prog_compiler__b+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_prog_compiler__b=no\n   save_LDFLAGS=\"$LDFLAGS\"\n   LDFLAGS=\"$LDFLAGS -b\"\n   echo \"$lt_simple_link_test_code\" > conftest.$ac_ext\n   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then\n     # The linker can only warn and ignore the option if not recognized\n     # So say no if there are warnings\n     if test -s conftest.err; then\n       # Append any errors to the config.log.\n       cat conftest.err 1>&5\n       $ECHO \"$_lt_linker_boilerplate\" | $SED '/^$/d' > conftest.exp\n       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2\n       if diff conftest.exp conftest.er2 >/dev/null; then\n         lt_cv_prog_compiler__b=yes\n       fi\n     else\n       lt_cv_prog_compiler__b=yes\n     fi\n   fi\n   $RM -r conftest*\n   LDFLAGS=\"$save_LDFLAGS\"\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b\" >&5\n$as_echo \"$lt_cv_prog_compiler__b\" >&6; }\n\nif test x\"$lt_cv_prog_compiler__b\" = xyes; then\n    archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'\nelse\n    archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'\nfi\n\n\t  ;;\n\tesac\n      fi\n      if test \"$with_gnu_ld\" = no; then\n\thardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'\n\thardcode_libdir_separator=:\n\n\tcase $host_cpu in\n\thppa*64*|ia64*)\n\t  hardcode_direct=no\n\t  hardcode_shlibpath_var=no\n\t  ;;\n\t*)\n\t  hardcode_direct=yes\n\t  hardcode_direct_absolute=yes\n\t  export_dynamic_flag_spec='${wl}-E'\n\n\t  # hardcode_minus_L: Not really in the search PATH,\n\t  # but as the default location of the library.\n\t  hardcode_minus_L=yes\n\t  ;;\n\tesac\n      fi\n      ;;\n\n    irix5* | irix6* | nonstopux*)\n      if test \"$GCC\" = yes; then\n\tarchive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n \"$verstring\" && func_echo_all \"${wl}-set_version ${wl}$verstring\"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'\n\t# Try to use the -exported_symbol ld option, if it does not\n\t# work, assume that -exports_file does not work either and\n\t# implicitly export all symbols.\n\t# This should be the same for all languages, so no per-tag cache variable.\n\t{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol\" >&5\n$as_echo_n \"checking whether the $host_os linker accepts -exported_symbol... \" >&6; }\nif ${lt_cv_irix_exported_symbol+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  save_LDFLAGS=\"$LDFLAGS\"\n\t   LDFLAGS=\"$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null\"\n\t   cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\nint foo (void) { return 0; }\n_ACEOF\nif ac_fn_c_try_link \"$LINENO\"; then :\n  lt_cv_irix_exported_symbol=yes\nelse\n  lt_cv_irix_exported_symbol=no\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\n           LDFLAGS=\"$save_LDFLAGS\"\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol\" >&5\n$as_echo \"$lt_cv_irix_exported_symbol\" >&6; }\n\tif test \"$lt_cv_irix_exported_symbol\" = yes; then\n          archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n \"$verstring\" && func_echo_all \"${wl}-set_version ${wl}$verstring\"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'\n\tfi\n      else\n\tarchive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n \"$verstring\" && func_echo_all \"-set_version $verstring\"` -update_registry ${output_objdir}/so_locations -o $lib'\n\tarchive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n \"$verstring\" && func_echo_all \"-set_version $verstring\"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'\n      fi\n      archive_cmds_need_lc='no'\n      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'\n      hardcode_libdir_separator=:\n      inherit_rpath=yes\n      link_all_deplibs=yes\n      ;;\n\n    netbsd* | netbsdelf*-gnu)\n      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then\n\tarchive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out\n      else\n\tarchive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF\n      fi\n      hardcode_libdir_flag_spec='-R$libdir'\n      hardcode_direct=yes\n      hardcode_shlibpath_var=no\n      ;;\n\n    newsos6)\n      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'\n      hardcode_direct=yes\n      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'\n      hardcode_libdir_separator=:\n      hardcode_shlibpath_var=no\n      ;;\n\n    *nto* | *qnx*)\n      ;;\n\n    openbsd*)\n      if test -f /usr/libexec/ld.so; then\n\thardcode_direct=yes\n\thardcode_shlibpath_var=no\n\thardcode_direct_absolute=yes\n\tif test -z \"`echo __ELF__ | $CC -E - | $GREP __ELF__`\" || test \"$host_os-$host_cpu\" = \"openbsd2.8-powerpc\"; then\n\t  archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'\n\t  archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'\n\t  hardcode_libdir_flag_spec='${wl}-rpath,$libdir'\n\t  export_dynamic_flag_spec='${wl}-E'\n\telse\n\t  case $host_os in\n\t   openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)\n\t     archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'\n\t     hardcode_libdir_flag_spec='-R$libdir'\n\t     ;;\n\t   *)\n\t     archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'\n\t     hardcode_libdir_flag_spec='${wl}-rpath,$libdir'\n\t     ;;\n\t  esac\n\tfi\n      else\n\tld_shlibs=no\n      fi\n      ;;\n\n    os2*)\n      hardcode_libdir_flag_spec='-L$libdir'\n      hardcode_minus_L=yes\n      allow_undefined_flag=unsupported\n      archive_cmds='$ECHO \"LIBRARY $libname INITINSTANCE\" > $output_objdir/$libname.def~$ECHO \"DESCRIPTION \\\"$libname\\\"\" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo \" SINGLE NONSHARED\" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'\n      old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'\n      ;;\n\n    osf3*)\n      if test \"$GCC\" = yes; then\n\tallow_undefined_flag=' ${wl}-expect_unresolved ${wl}\\*'\n\tarchive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n \"$verstring\" && func_echo_all \"${wl}-set_version ${wl}$verstring\"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'\n      else\n\tallow_undefined_flag=' -expect_unresolved \\*'\n\tarchive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n \"$verstring\" && func_echo_all \"-set_version $verstring\"` -update_registry ${output_objdir}/so_locations -o $lib'\n      fi\n      archive_cmds_need_lc='no'\n      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'\n      hardcode_libdir_separator=:\n      ;;\n\n    osf4* | osf5*)\t# as osf3* with the addition of -msym flag\n      if test \"$GCC\" = yes; then\n\tallow_undefined_flag=' ${wl}-expect_unresolved ${wl}\\*'\n\tarchive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n \"$verstring\" && func_echo_all \"${wl}-set_version ${wl}$verstring\"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'\n\thardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'\n      else\n\tallow_undefined_flag=' -expect_unresolved \\*'\n\tarchive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n \"$verstring\" && func_echo_all \"-set_version $verstring\"` -update_registry ${output_objdir}/so_locations -o $lib'\n\tarchive_expsym_cmds='for i in `cat $export_symbols`; do printf \"%s %s\\\\n\" -exported_symbol \"\\$i\" >> $lib.exp; done; printf \"%s\\\\n\" \"-hidden\">> $lib.exp~\n\t$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n \"$verstring\" && $ECHO \"-set_version $verstring\"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'\n\n\t# Both c and cxx compiler support -rpath directly\n\thardcode_libdir_flag_spec='-rpath $libdir'\n      fi\n      archive_cmds_need_lc='no'\n      hardcode_libdir_separator=:\n      ;;\n\n    solaris*)\n      no_undefined_flag=' -z defs'\n      if test \"$GCC\" = yes; then\n\twlarc='${wl}'\n\tarchive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'\n\tarchive_expsym_cmds='echo \"{ global:\" > $lib.exp~cat $export_symbols | $SED -e \"s/\\(.*\\)/\\1;/\" >> $lib.exp~echo \"local: *; };\" >> $lib.exp~\n\t  $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'\n      else\n\tcase `$CC -V 2>&1` in\n\t*\"Compilers 5.0\"*)\n\t  wlarc=''\n\t  archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'\n\t  archive_expsym_cmds='echo \"{ global:\" > $lib.exp~cat $export_symbols | $SED -e \"s/\\(.*\\)/\\1;/\" >> $lib.exp~echo \"local: *; };\" >> $lib.exp~\n\t  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'\n\t  ;;\n\t*)\n\t  wlarc='${wl}'\n\t  archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'\n\t  archive_expsym_cmds='echo \"{ global:\" > $lib.exp~cat $export_symbols | $SED -e \"s/\\(.*\\)/\\1;/\" >> $lib.exp~echo \"local: *; };\" >> $lib.exp~\n\t  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'\n\t  ;;\n\tesac\n      fi\n      hardcode_libdir_flag_spec='-R$libdir'\n      hardcode_shlibpath_var=no\n      case $host_os in\n      solaris2.[0-5] | solaris2.[0-5].*) ;;\n      *)\n\t# The compiler driver will combine and reorder linker options,\n\t# but understands `-z linker_flag'.  GCC discards it without `$wl',\n\t# but is careful enough not to reorder.\n\t# Supported since Solaris 2.6 (maybe 2.5.1?)\n\tif test \"$GCC\" = yes; then\n\t  whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'\n\telse\n\t  whole_archive_flag_spec='-z allextract$convenience -z defaultextract'\n\tfi\n\t;;\n      esac\n      link_all_deplibs=yes\n      ;;\n\n    sunos4*)\n      if test \"x$host_vendor\" = xsequent; then\n\t# Use $CC to link under sequent, because it throws in some extra .o\n\t# files that make .init and .fini sections work.\n\tarchive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'\n      else\n\tarchive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'\n      fi\n      hardcode_libdir_flag_spec='-L$libdir'\n      hardcode_direct=yes\n      hardcode_minus_L=yes\n      hardcode_shlibpath_var=no\n      ;;\n\n    sysv4)\n      case $host_vendor in\n\tsni)\n\t  archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'\n\t  hardcode_direct=yes # is this really true???\n\t;;\n\tsiemens)\n\t  ## LD is ld it makes a PLAMLIB\n\t  ## CC just makes a GrossModule.\n\t  archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'\n\t  reload_cmds='$CC -r -o $output$reload_objs'\n\t  hardcode_direct=no\n        ;;\n\tmotorola)\n\t  archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'\n\t  hardcode_direct=no #Motorola manual says yes, but my tests say they lie\n\t;;\n      esac\n      runpath_var='LD_RUN_PATH'\n      hardcode_shlibpath_var=no\n      ;;\n\n    sysv4.3*)\n      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'\n      hardcode_shlibpath_var=no\n      export_dynamic_flag_spec='-Bexport'\n      ;;\n\n    sysv4*MP*)\n      if test -d /usr/nec; then\n\tarchive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'\n\thardcode_shlibpath_var=no\n\trunpath_var=LD_RUN_PATH\n\thardcode_runpath_var=yes\n\tld_shlibs=yes\n      fi\n      ;;\n\n    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)\n      no_undefined_flag='${wl}-z,text'\n      archive_cmds_need_lc=no\n      hardcode_shlibpath_var=no\n      runpath_var='LD_RUN_PATH'\n\n      if test \"$GCC\" = yes; then\n\tarchive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\tarchive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n      else\n\tarchive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\tarchive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n      fi\n      ;;\n\n    sysv5* | sco3.2v5* | sco5v6*)\n      # Note: We can NOT use -z defs as we might desire, because we do not\n      # link with -lc, and that would cause any symbols used from libc to\n      # always be unresolved, which means just about no library would\n      # ever link correctly.  If we're not using GNU ld we use -z text\n      # though, which does catch some bad symbols but isn't as heavy-handed\n      # as -z defs.\n      no_undefined_flag='${wl}-z,text'\n      allow_undefined_flag='${wl}-z,nodefs'\n      archive_cmds_need_lc=no\n      hardcode_shlibpath_var=no\n      hardcode_libdir_flag_spec='${wl}-R,$libdir'\n      hardcode_libdir_separator=':'\n      link_all_deplibs=yes\n      export_dynamic_flag_spec='${wl}-Bexport'\n      runpath_var='LD_RUN_PATH'\n\n      if test \"$GCC\" = yes; then\n\tarchive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\tarchive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n      else\n\tarchive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\tarchive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n      fi\n      ;;\n\n    uts4*)\n      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'\n      hardcode_libdir_flag_spec='-L$libdir'\n      hardcode_shlibpath_var=no\n      ;;\n\n    *)\n      ld_shlibs=no\n      ;;\n    esac\n\n    if test x$host_vendor = xsni; then\n      case $host in\n      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)\n\texport_dynamic_flag_spec='${wl}-Blargedynsym'\n\t;;\n      esac\n    fi\n  fi\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ld_shlibs\" >&5\n$as_echo \"$ld_shlibs\" >&6; }\ntest \"$ld_shlibs\" = no && can_build_shared=no\n\nwith_gnu_ld=$with_gnu_ld\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n#\n# Do we need to explicitly link libc?\n#\ncase \"x$archive_cmds_need_lc\" in\nx|xyes)\n  # Assume -lc should be added\n  archive_cmds_need_lc=yes\n\n  if test \"$enable_shared\" = yes && test \"$GCC\" = yes; then\n    case $archive_cmds in\n    *'~'*)\n      # FIXME: we may have to deal with multi-command sequences.\n      ;;\n    '$CC '*)\n      # Test whether the compiler implicitly links with -lc since on some\n      # systems, -lgcc has to come before -lc. If gcc already passes -lc\n      # to ld, don't add -lc before -lgcc.\n      { $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in\" >&5\n$as_echo_n \"checking whether -lc should be explicitly linked in... \" >&6; }\nif ${lt_cv_archive_cmds_need_lc+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  $RM conftest*\n\techo \"$lt_simple_compile_test_code\" > conftest.$ac_ext\n\n\tif { { eval echo \"\\\"\\$as_me\\\":${as_lineno-$LINENO}: \\\"$ac_compile\\\"\"; } >&5\n  (eval $ac_compile) 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; } 2>conftest.err; then\n\t  soname=conftest\n\t  lib=conftest\n\t  libobjs=conftest.$ac_objext\n\t  deplibs=\n\t  wl=$lt_prog_compiler_wl\n\t  pic_flag=$lt_prog_compiler_pic\n\t  compiler_flags=-v\n\t  linker_flags=-v\n\t  verstring=\n\t  output_objdir=.\n\t  libname=conftest\n\t  lt_save_allow_undefined_flag=$allow_undefined_flag\n\t  allow_undefined_flag=\n\t  if { { eval echo \"\\\"\\$as_me\\\":${as_lineno-$LINENO}: \\\"$archive_cmds 2\\>\\&1 \\| $GREP \\\" -lc \\\" \\>/dev/null 2\\>\\&1\\\"\"; } >&5\n  (eval $archive_cmds 2\\>\\&1 \\| $GREP \\\" -lc \\\" \\>/dev/null 2\\>\\&1) 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; }\n\t  then\n\t    lt_cv_archive_cmds_need_lc=no\n\t  else\n\t    lt_cv_archive_cmds_need_lc=yes\n\t  fi\n\t  allow_undefined_flag=$lt_save_allow_undefined_flag\n\telse\n\t  cat conftest.err 1>&5\n\tfi\n\t$RM conftest*\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc\" >&5\n$as_echo \"$lt_cv_archive_cmds_need_lc\" >&6; }\n      archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc\n      ;;\n    esac\n  fi\n  ;;\nesac\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics\" >&5\n$as_echo_n \"checking dynamic linker characteristics... \" >&6; }\n\nif test \"$GCC\" = yes; then\n  case $host_os in\n    darwin*) lt_awk_arg=\"/^libraries:/,/LR/\" ;;\n    *) lt_awk_arg=\"/^libraries:/\" ;;\n  esac\n  case $host_os in\n    mingw* | cegcc*) lt_sed_strip_eq=\"s,=\\([A-Za-z]:\\),\\1,g\" ;;\n    *) lt_sed_strip_eq=\"s,=/,/,g\" ;;\n  esac\n  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e \"s/^libraries://\" -e $lt_sed_strip_eq`\n  case $lt_search_path_spec in\n  *\\;*)\n    # if the path contains \";\" then we assume it to be the separator\n    # otherwise default to the standard path separator (i.e. \":\") - it is\n    # assumed that no part of a normal pathname contains \";\" but that should\n    # okay in the real world where \";\" in dirpaths is itself problematic.\n    lt_search_path_spec=`$ECHO \"$lt_search_path_spec\" | $SED 's/;/ /g'`\n    ;;\n  *)\n    lt_search_path_spec=`$ECHO \"$lt_search_path_spec\" | $SED \"s/$PATH_SEPARATOR/ /g\"`\n    ;;\n  esac\n  # Ok, now we have the path, separated by spaces, we can step through it\n  # and add multilib dir if necessary.\n  lt_tmp_lt_search_path_spec=\n  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`\n  for lt_sys_path in $lt_search_path_spec; do\n    if test -d \"$lt_sys_path/$lt_multi_os_dir\"; then\n      lt_tmp_lt_search_path_spec=\"$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir\"\n    else\n      test -d \"$lt_sys_path\" && \\\n\tlt_tmp_lt_search_path_spec=\"$lt_tmp_lt_search_path_spec $lt_sys_path\"\n    fi\n  done\n  lt_search_path_spec=`$ECHO \"$lt_tmp_lt_search_path_spec\" | awk '\nBEGIN {RS=\" \"; FS=\"/|\\n\";} {\n  lt_foo=\"\";\n  lt_count=0;\n  for (lt_i = NF; lt_i > 0; lt_i--) {\n    if ($lt_i != \"\" && $lt_i != \".\") {\n      if ($lt_i == \"..\") {\n        lt_count++;\n      } else {\n        if (lt_count == 0) {\n          lt_foo=\"/\" $lt_i lt_foo;\n        } else {\n          lt_count--;\n        }\n      }\n    }\n  }\n  if (lt_foo != \"\") { lt_freq[lt_foo]++; }\n  if (lt_freq[lt_foo] == 1) { print lt_foo; }\n}'`\n  # AWK program above erroneously prepends '/' to C:/dos/paths\n  # for these hosts.\n  case $host_os in\n    mingw* | cegcc*) lt_search_path_spec=`$ECHO \"$lt_search_path_spec\" |\\\n      $SED 's,/\\([A-Za-z]:\\),\\1,g'` ;;\n  esac\n  sys_lib_search_path_spec=`$ECHO \"$lt_search_path_spec\" | $lt_NL2SP`\nelse\n  sys_lib_search_path_spec=\"/lib /usr/lib /usr/local/lib\"\nfi\nlibrary_names_spec=\nlibname_spec='lib$name'\nsoname_spec=\nshrext_cmds=\".so\"\npostinstall_cmds=\npostuninstall_cmds=\nfinish_cmds=\nfinish_eval=\nshlibpath_var=\nshlibpath_overrides_runpath=unknown\nversion_type=none\ndynamic_linker=\"$host_os ld.so\"\nsys_lib_dlsearch_path_spec=\"/lib /usr/lib\"\nneed_lib_prefix=unknown\nhardcode_into_libs=no\n\n# when you set need_version to no, make sure it does not cause -set_version\n# flags to be left without arguments\nneed_version=unknown\n\ncase $host_os in\naix3*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'\n  shlibpath_var=LIBPATH\n\n  # AIX 3 has no versioning support, so we append a major version to the name.\n  soname_spec='${libname}${release}${shared_ext}$major'\n  ;;\n\naix[4-9]*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_lib_prefix=no\n  need_version=no\n  hardcode_into_libs=yes\n  if test \"$host_cpu\" = ia64; then\n    # AIX 5 supports IA64\n    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'\n    shlibpath_var=LD_LIBRARY_PATH\n  else\n    # With GCC up to 2.95.x, collect2 would create an import file\n    # for dependence libraries.  The import file would start with\n    # the line `#! .'.  This would cause the generated library to\n    # depend on `.', always an invalid library.  This was fixed in\n    # development snapshots of GCC prior to 3.0.\n    case $host_os in\n      aix4 | aix4.[01] | aix4.[01].*)\n      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'\n\t   echo ' yes '\n\t   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then\n\t:\n      else\n\tcan_build_shared=no\n      fi\n      ;;\n    esac\n    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct\n    # soname into executable. Probably we can add versioning support to\n    # collect2, so additional links can be useful in future.\n    if test \"$aix_use_runtimelinking\" = yes; then\n      # If using run time linking (on AIX 4.2 or later) use lib<name>.so\n      # instead of lib<name>.a to let people know that these are not\n      # typical AIX shared libraries.\n      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n    else\n      # We preserve .a as extension for shared libraries through AIX4.2\n      # and later when we are not doing run time linking.\n      library_names_spec='${libname}${release}.a $libname.a'\n      soname_spec='${libname}${release}${shared_ext}$major'\n    fi\n    shlibpath_var=LIBPATH\n  fi\n  ;;\n\namigaos*)\n  case $host_cpu in\n  powerpc)\n    # Since July 2007 AmigaOS4 officially supports .so libraries.\n    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.\n    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n    ;;\n  m68k)\n    library_names_spec='$libname.ixlibrary $libname.a'\n    # Create ${libname}_ixlibrary.a entries in /sys/libs.\n    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all \"$lib\" | $SED '\\''s%^.*/\\([^/]*\\)\\.ixlibrary$%\\1%'\\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show \"cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a\"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'\n    ;;\n  esac\n  ;;\n\nbeos*)\n  library_names_spec='${libname}${shared_ext}'\n  dynamic_linker=\"$host_os ld.so\"\n  shlibpath_var=LIBRARY_PATH\n  ;;\n\nbsdi[45]*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  finish_cmds='PATH=\"\\$PATH:/sbin\" ldconfig $libdir'\n  shlibpath_var=LD_LIBRARY_PATH\n  sys_lib_search_path_spec=\"/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib\"\n  sys_lib_dlsearch_path_spec=\"/shlib /usr/lib /usr/local/lib\"\n  # the default ld.so.conf also contains /usr/contrib/lib and\n  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow\n  # libtool to hard-code these into programs\n  ;;\n\ncygwin* | mingw* | pw32* | cegcc*)\n  version_type=windows\n  shrext_cmds=\".dll\"\n  need_version=no\n  need_lib_prefix=no\n\n  case $GCC,$cc_basename in\n  yes,*)\n    # gcc\n    library_names_spec='$libname.dll.a'\n    # DLL is installed to $(libdir)/../bin by postinstall_cmds\n    postinstall_cmds='base_file=`basename \\${file}`~\n      dlpath=`$SHELL 2>&1 -c '\\''. $dir/'\\''\\${base_file}'\\''i; echo \\$dlname'\\''`~\n      dldir=$destdir/`dirname \\$dlpath`~\n      test -d \\$dldir || mkdir -p \\$dldir~\n      $install_prog $dir/$dlname \\$dldir/$dlname~\n      chmod a+x \\$dldir/$dlname~\n      if test -n '\\''$stripme'\\'' && test -n '\\''$striplib'\\''; then\n        eval '\\''$striplib \\$dldir/$dlname'\\'' || exit \\$?;\n      fi'\n    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\\''. $file; echo \\$dlname'\\''`~\n      dlpath=$dir/\\$dldll~\n       $RM \\$dlpath'\n    shlibpath_overrides_runpath=yes\n\n    case $host_os in\n    cygwin*)\n      # Cygwin DLLs use 'cyg' prefix rather than 'lib'\n      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'\n\n      sys_lib_search_path_spec=\"$sys_lib_search_path_spec /usr/lib/w32api\"\n      ;;\n    mingw* | cegcc*)\n      # MinGW DLLs use traditional 'lib' prefix\n      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'\n      ;;\n    pw32*)\n      # pw32 DLLs use 'pw' prefix rather than 'lib'\n      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'\n      ;;\n    esac\n    dynamic_linker='Win32 ld.exe'\n    ;;\n\n  *,cl*)\n    # Native MSVC\n    libname_spec='$name'\n    soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'\n    library_names_spec='${libname}.dll.lib'\n\n    case $build_os in\n    mingw*)\n      sys_lib_search_path_spec=\n      lt_save_ifs=$IFS\n      IFS=';'\n      for lt_path in $LIB\n      do\n        IFS=$lt_save_ifs\n        # Let DOS variable expansion print the short 8.3 style file name.\n        lt_path=`cd \"$lt_path\" 2>/dev/null && cmd //C \"for %i in (\".\") do @echo %~si\"`\n        sys_lib_search_path_spec=\"$sys_lib_search_path_spec $lt_path\"\n      done\n      IFS=$lt_save_ifs\n      # Convert to MSYS style.\n      sys_lib_search_path_spec=`$ECHO \"$sys_lib_search_path_spec\" | sed -e 's|\\\\\\\\|/|g' -e 's| \\\\([a-zA-Z]\\\\):| /\\\\1|g' -e 's|^ ||'`\n      ;;\n    cygwin*)\n      # Convert to unix form, then to dos form, then back to unix form\n      # but this time dos style (no spaces!) so that the unix form looks\n      # like /cygdrive/c/PROGRA~1:/cygdr...\n      sys_lib_search_path_spec=`cygpath --path --unix \"$LIB\"`\n      sys_lib_search_path_spec=`cygpath --path --dos \"$sys_lib_search_path_spec\" 2>/dev/null`\n      sys_lib_search_path_spec=`cygpath --path --unix \"$sys_lib_search_path_spec\" | $SED -e \"s/$PATH_SEPARATOR/ /g\"`\n      ;;\n    *)\n      sys_lib_search_path_spec=\"$LIB\"\n      if $ECHO \"$sys_lib_search_path_spec\" | $GREP ';[c-zC-Z]:/' >/dev/null; then\n        # It is most probably a Windows format PATH.\n        sys_lib_search_path_spec=`$ECHO \"$sys_lib_search_path_spec\" | $SED -e 's/;/ /g'`\n      else\n        sys_lib_search_path_spec=`$ECHO \"$sys_lib_search_path_spec\" | $SED -e \"s/$PATH_SEPARATOR/ /g\"`\n      fi\n      # FIXME: find the short name or the path components, as spaces are\n      # common. (e.g. \"Program Files\" -> \"PROGRA~1\")\n      ;;\n    esac\n\n    # DLL is installed to $(libdir)/../bin by postinstall_cmds\n    postinstall_cmds='base_file=`basename \\${file}`~\n      dlpath=`$SHELL 2>&1 -c '\\''. $dir/'\\''\\${base_file}'\\''i; echo \\$dlname'\\''`~\n      dldir=$destdir/`dirname \\$dlpath`~\n      test -d \\$dldir || mkdir -p \\$dldir~\n      $install_prog $dir/$dlname \\$dldir/$dlname'\n    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\\''. $file; echo \\$dlname'\\''`~\n      dlpath=$dir/\\$dldll~\n       $RM \\$dlpath'\n    shlibpath_overrides_runpath=yes\n    dynamic_linker='Win32 link.exe'\n    ;;\n\n  *)\n    # Assume MSVC wrapper\n    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'\n    dynamic_linker='Win32 ld.exe'\n    ;;\n  esac\n  # FIXME: first we should search . and the directory the executable is in\n  shlibpath_var=PATH\n  ;;\n\ndarwin* | rhapsody*)\n  dynamic_linker=\"$host_os dyld\"\n  version_type=darwin\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'\n  soname_spec='${libname}${release}${major}$shared_ext'\n  shlibpath_overrides_runpath=yes\n  shlibpath_var=DYLD_LIBRARY_PATH\n  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'\n\n  sys_lib_search_path_spec=\"$sys_lib_search_path_spec /usr/local/lib\"\n  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'\n  ;;\n\ndgux*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LD_LIBRARY_PATH\n  ;;\n\nfreebsd* | dragonfly*)\n  # DragonFly does not have aout.  When/if they implement a new\n  # versioning mechanism, adjust this.\n  if test -x /usr/bin/objformat; then\n    objformat=`/usr/bin/objformat`\n  else\n    case $host_os in\n    freebsd[23].*) objformat=aout ;;\n    *) objformat=elf ;;\n    esac\n  fi\n  version_type=freebsd-$objformat\n  case $version_type in\n    freebsd-elf*)\n      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'\n      need_version=no\n      need_lib_prefix=no\n      ;;\n    freebsd-*)\n      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'\n      need_version=yes\n      ;;\n  esac\n  shlibpath_var=LD_LIBRARY_PATH\n  case $host_os in\n  freebsd2.*)\n    shlibpath_overrides_runpath=yes\n    ;;\n  freebsd3.[01]* | freebsdelf3.[01]*)\n    shlibpath_overrides_runpath=yes\n    hardcode_into_libs=yes\n    ;;\n  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \\\n  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)\n    shlibpath_overrides_runpath=no\n    hardcode_into_libs=yes\n    ;;\n  *) # from 4.6 on, and DragonFly\n    shlibpath_overrides_runpath=yes\n    hardcode_into_libs=yes\n    ;;\n  esac\n  ;;\n\nhaiku*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_lib_prefix=no\n  need_version=no\n  dynamic_linker=\"$host_os runtime_loader\"\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LIBRARY_PATH\n  shlibpath_overrides_runpath=yes\n  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'\n  hardcode_into_libs=yes\n  ;;\n\nhpux9* | hpux10* | hpux11*)\n  # Give a soname corresponding to the major version so that dld.sl refuses to\n  # link against other versions.\n  version_type=sunos\n  need_lib_prefix=no\n  need_version=no\n  case $host_cpu in\n  ia64*)\n    shrext_cmds='.so'\n    hardcode_into_libs=yes\n    dynamic_linker=\"$host_os dld.so\"\n    shlibpath_var=LD_LIBRARY_PATH\n    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.\n    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n    soname_spec='${libname}${release}${shared_ext}$major'\n    if test \"X$HPUX_IA64_MODE\" = X32; then\n      sys_lib_search_path_spec=\"/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib\"\n    else\n      sys_lib_search_path_spec=\"/usr/lib/hpux64 /usr/local/lib/hpux64\"\n    fi\n    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec\n    ;;\n  hppa*64*)\n    shrext_cmds='.sl'\n    hardcode_into_libs=yes\n    dynamic_linker=\"$host_os dld.sl\"\n    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH\n    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.\n    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n    soname_spec='${libname}${release}${shared_ext}$major'\n    sys_lib_search_path_spec=\"/usr/lib/pa20_64 /usr/ccs/lib/pa20_64\"\n    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec\n    ;;\n  *)\n    shrext_cmds='.sl'\n    dynamic_linker=\"$host_os dld.sl\"\n    shlibpath_var=SHLIB_PATH\n    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH\n    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n    soname_spec='${libname}${release}${shared_ext}$major'\n    ;;\n  esac\n  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...\n  postinstall_cmds='chmod 555 $lib'\n  # or fails outright, so override atomically:\n  install_override_mode=555\n  ;;\n\ninterix[3-9]*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=no\n  hardcode_into_libs=yes\n  ;;\n\nirix5* | irix6* | nonstopux*)\n  case $host_os in\n    nonstopux*) version_type=nonstopux ;;\n    *)\n\tif test \"$lt_cv_prog_gnu_ld\" = yes; then\n\t\tversion_type=linux # correct to gnu/linux during the next big refactor\n\telse\n\t\tversion_type=irix\n\tfi ;;\n  esac\n  need_lib_prefix=no\n  need_version=no\n  soname_spec='${libname}${release}${shared_ext}$major'\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'\n  case $host_os in\n  irix5* | nonstopux*)\n    libsuff= shlibsuff=\n    ;;\n  *)\n    case $LD in # libtool.m4 will add one of these switches to LD\n    *-32|*\"-32 \"|*-melf32bsmip|*\"-melf32bsmip \")\n      libsuff= shlibsuff= libmagic=32-bit;;\n    *-n32|*\"-n32 \"|*-melf32bmipn32|*\"-melf32bmipn32 \")\n      libsuff=32 shlibsuff=N32 libmagic=N32;;\n    *-64|*\"-64 \"|*-melf64bmip|*\"-melf64bmip \")\n      libsuff=64 shlibsuff=64 libmagic=64-bit;;\n    *) libsuff= shlibsuff= libmagic=never-match;;\n    esac\n    ;;\n  esac\n  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH\n  shlibpath_overrides_runpath=no\n  sys_lib_search_path_spec=\"/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}\"\n  sys_lib_dlsearch_path_spec=\"/usr/lib${libsuff} /lib${libsuff}\"\n  hardcode_into_libs=yes\n  ;;\n\n# No shared lib support for Linux oldld, aout, or coff.\nlinux*oldld* | linux*aout* | linux*coff*)\n  dynamic_linker=no\n  ;;\n\n# This must be glibc/ELF.\nlinux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  finish_cmds='PATH=\"\\$PATH:/sbin\" ldconfig -n $libdir'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=no\n\n  # Some binutils ld are patched to set DT_RUNPATH\n  if ${lt_cv_shlibpath_overrides_runpath+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_shlibpath_overrides_runpath=no\n    save_LDFLAGS=$LDFLAGS\n    save_libdir=$libdir\n    eval \"libdir=/foo; wl=\\\"$lt_prog_compiler_wl\\\"; \\\n\t LDFLAGS=\\\"\\$LDFLAGS $hardcode_libdir_flag_spec\\\"\"\n    cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_link \"$LINENO\"; then :\n  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep \"RUNPATH.*$libdir\" >/dev/null; then :\n  lt_cv_shlibpath_overrides_runpath=yes\nfi\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\n    LDFLAGS=$save_LDFLAGS\n    libdir=$save_libdir\n\nfi\n\n  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath\n\n  # This implies no fast_install, which is unacceptable.\n  # Some rework will be needed to allow for fast_install\n  # before this can be enabled.\n  hardcode_into_libs=yes\n\n  # Append ld.so.conf contents to the search path\n  if test -f /etc/ld.so.conf; then\n    lt_ld_extra=`awk '/^include / { system(sprintf(\"cd /etc; cat %s 2>/dev/null\", \\$2)); skip = 1; } { if (!skip) print \\$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[\t ]*hwcap[\t ]/d;s/[:,\t]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/\"//g;/^$/d' | tr '\\n' ' '`\n    sys_lib_dlsearch_path_spec=\"/lib /usr/lib $lt_ld_extra\"\n  fi\n\n  # We used to test for /lib/ld.so.1 and disable shared libraries on\n  # powerpc, because MkLinux only supported shared libraries with the\n  # GNU dynamic linker.  Since this was broken with cross compilers,\n  # most powerpc-linux boxes support dynamic linking these days and\n  # people can always --disable-shared, the test was removed, and we\n  # assume the GNU/Linux dynamic linker is in use.\n  dynamic_linker='GNU/Linux ld.so'\n  ;;\n\nnetbsdelf*-gnu)\n  version_type=linux\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=no\n  hardcode_into_libs=yes\n  dynamic_linker='NetBSD ld.elf_so'\n  ;;\n\nnetbsd*)\n  version_type=sunos\n  need_lib_prefix=no\n  need_version=no\n  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then\n    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'\n    finish_cmds='PATH=\"\\$PATH:/sbin\" ldconfig -m $libdir'\n    dynamic_linker='NetBSD (a.out) ld.so'\n  else\n    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'\n    soname_spec='${libname}${release}${shared_ext}$major'\n    dynamic_linker='NetBSD ld.elf_so'\n  fi\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=yes\n  hardcode_into_libs=yes\n  ;;\n\nnewsos6)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=yes\n  ;;\n\n*nto* | *qnx*)\n  version_type=qnx\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=no\n  hardcode_into_libs=yes\n  dynamic_linker='ldqnx.so'\n  ;;\n\nopenbsd*)\n  version_type=sunos\n  sys_lib_dlsearch_path_spec=\"/usr/lib\"\n  need_lib_prefix=no\n  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.\n  case $host_os in\n    openbsd3.3 | openbsd3.3.*)\tneed_version=yes ;;\n    *)\t\t\t\tneed_version=no  ;;\n  esac\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'\n  finish_cmds='PATH=\"\\$PATH:/sbin\" ldconfig -m $libdir'\n  shlibpath_var=LD_LIBRARY_PATH\n  if test -z \"`echo __ELF__ | $CC -E - | $GREP __ELF__`\" || test \"$host_os-$host_cpu\" = \"openbsd2.8-powerpc\"; then\n    case $host_os in\n      openbsd2.[89] | openbsd2.[89].*)\n\tshlibpath_overrides_runpath=no\n\t;;\n      *)\n\tshlibpath_overrides_runpath=yes\n\t;;\n      esac\n  else\n    shlibpath_overrides_runpath=yes\n  fi\n  ;;\n\nos2*)\n  libname_spec='$name'\n  shrext_cmds=\".dll\"\n  need_lib_prefix=no\n  library_names_spec='$libname${shared_ext} $libname.a'\n  dynamic_linker='OS/2 ld.exe'\n  shlibpath_var=LIBPATH\n  ;;\n\nosf3* | osf4* | osf5*)\n  version_type=osf\n  need_lib_prefix=no\n  need_version=no\n  soname_spec='${libname}${release}${shared_ext}$major'\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  shlibpath_var=LD_LIBRARY_PATH\n  sys_lib_search_path_spec=\"/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib\"\n  sys_lib_dlsearch_path_spec=\"$sys_lib_search_path_spec\"\n  ;;\n\nrdos*)\n  dynamic_linker=no\n  ;;\n\nsolaris*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=yes\n  hardcode_into_libs=yes\n  # ldd complains unless libraries are executable\n  postinstall_cmds='chmod +x $lib'\n  ;;\n\nsunos4*)\n  version_type=sunos\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'\n  finish_cmds='PATH=\"\\$PATH:/usr/etc\" ldconfig $libdir'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=yes\n  if test \"$with_gnu_ld\" = yes; then\n    need_lib_prefix=no\n  fi\n  need_version=yes\n  ;;\n\nsysv4 | sysv4.3*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LD_LIBRARY_PATH\n  case $host_vendor in\n    sni)\n      shlibpath_overrides_runpath=no\n      need_lib_prefix=no\n      runpath_var=LD_RUN_PATH\n      ;;\n    siemens)\n      need_lib_prefix=no\n      ;;\n    motorola)\n      need_lib_prefix=no\n      need_version=no\n      shlibpath_overrides_runpath=no\n      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'\n      ;;\n  esac\n  ;;\n\nsysv4*MP*)\n  if test -d /usr/nec ;then\n    version_type=linux # correct to gnu/linux during the next big refactor\n    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'\n    soname_spec='$libname${shared_ext}.$major'\n    shlibpath_var=LD_LIBRARY_PATH\n  fi\n  ;;\n\nsysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)\n  version_type=freebsd-elf\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=yes\n  hardcode_into_libs=yes\n  if test \"$with_gnu_ld\" = yes; then\n    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'\n  else\n    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'\n    case $host_os in\n      sco3.2v5*)\n        sys_lib_search_path_spec=\"$sys_lib_search_path_spec /lib\"\n\t;;\n    esac\n  fi\n  sys_lib_dlsearch_path_spec='/usr/lib'\n  ;;\n\ntpf*)\n  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=no\n  hardcode_into_libs=yes\n  ;;\n\nuts4*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LD_LIBRARY_PATH\n  ;;\n\n*)\n  dynamic_linker=no\n  ;;\nesac\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $dynamic_linker\" >&5\n$as_echo \"$dynamic_linker\" >&6; }\ntest \"$dynamic_linker\" = no && can_build_shared=no\n\nvariables_saved_for_relink=\"PATH $shlibpath_var $runpath_var\"\nif test \"$GCC\" = yes; then\n  variables_saved_for_relink=\"$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH\"\nfi\n\nif test \"${lt_cv_sys_lib_search_path_spec+set}\" = set; then\n  sys_lib_search_path_spec=\"$lt_cv_sys_lib_search_path_spec\"\nfi\nif test \"${lt_cv_sys_lib_dlsearch_path_spec+set}\" = set; then\n  sys_lib_dlsearch_path_spec=\"$lt_cv_sys_lib_dlsearch_path_spec\"\nfi\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs\" >&5\n$as_echo_n \"checking how to hardcode library paths into programs... \" >&6; }\nhardcode_action=\nif test -n \"$hardcode_libdir_flag_spec\" ||\n   test -n \"$runpath_var\" ||\n   test \"X$hardcode_automatic\" = \"Xyes\" ; then\n\n  # We can hardcode non-existent directories.\n  if test \"$hardcode_direct\" != no &&\n     # If the only mechanism to avoid hardcoding is shlibpath_var, we\n     # have to relink, otherwise we might link with an installed library\n     # when we should be linking with a yet-to-be-installed one\n     ## test \"$_LT_TAGVAR(hardcode_shlibpath_var, )\" != no &&\n     test \"$hardcode_minus_L\" != no; then\n    # Linking always hardcodes the temporary library directory.\n    hardcode_action=relink\n  else\n    # We can link without hardcoding, and we can hardcode nonexisting dirs.\n    hardcode_action=immediate\n  fi\nelse\n  # We cannot hardcode anything, or else we can only hardcode existing\n  # directories.\n  hardcode_action=unsupported\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $hardcode_action\" >&5\n$as_echo \"$hardcode_action\" >&6; }\n\nif test \"$hardcode_action\" = relink ||\n   test \"$inherit_rpath\" = yes; then\n  # Fast installation is not supported\n  enable_fast_install=no\nelif test \"$shlibpath_overrides_runpath\" = yes ||\n     test \"$enable_shared\" = no; then\n  # Fast installation is not necessary\n  enable_fast_install=needless\nfi\n\n\n\n\n\n\n  if test \"x$enable_dlopen\" != xyes; then\n  enable_dlopen=unknown\n  enable_dlopen_self=unknown\n  enable_dlopen_self_static=unknown\nelse\n  lt_cv_dlopen=no\n  lt_cv_dlopen_libs=\n\n  case $host_os in\n  beos*)\n    lt_cv_dlopen=\"load_add_on\"\n    lt_cv_dlopen_libs=\n    lt_cv_dlopen_self=yes\n    ;;\n\n  mingw* | pw32* | cegcc*)\n    lt_cv_dlopen=\"LoadLibrary\"\n    lt_cv_dlopen_libs=\n    ;;\n\n  cygwin*)\n    lt_cv_dlopen=\"dlopen\"\n    lt_cv_dlopen_libs=\n    ;;\n\n  darwin*)\n  # if libdl is installed we need to link against it\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl\" >&5\n$as_echo_n \"checking for dlopen in -ldl... \" >&6; }\nif ${ac_cv_lib_dl_dlopen+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  ac_check_lib_save_LIBS=$LIBS\nLIBS=\"-ldl  $LIBS\"\ncat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\n/* Override any GCC internal prototype to avoid an error.\n   Use char because int might match the return type of a GCC\n   builtin and then its argument prototype would still apply.  */\n#ifdef __cplusplus\nextern \"C\"\n#endif\nchar dlopen ();\nint\nmain ()\n{\nreturn dlopen ();\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_link \"$LINENO\"; then :\n  ac_cv_lib_dl_dlopen=yes\nelse\n  ac_cv_lib_dl_dlopen=no\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\nLIBS=$ac_check_lib_save_LIBS\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen\" >&5\n$as_echo \"$ac_cv_lib_dl_dlopen\" >&6; }\nif test \"x$ac_cv_lib_dl_dlopen\" = xyes; then :\n  lt_cv_dlopen=\"dlopen\" lt_cv_dlopen_libs=\"-ldl\"\nelse\n\n    lt_cv_dlopen=\"dyld\"\n    lt_cv_dlopen_libs=\n    lt_cv_dlopen_self=yes\n\nfi\n\n    ;;\n\n  *)\n    ac_fn_c_check_func \"$LINENO\" \"shl_load\" \"ac_cv_func_shl_load\"\nif test \"x$ac_cv_func_shl_load\" = xyes; then :\n  lt_cv_dlopen=\"shl_load\"\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld\" >&5\n$as_echo_n \"checking for shl_load in -ldld... \" >&6; }\nif ${ac_cv_lib_dld_shl_load+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  ac_check_lib_save_LIBS=$LIBS\nLIBS=\"-ldld  $LIBS\"\ncat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\n/* Override any GCC internal prototype to avoid an error.\n   Use char because int might match the return type of a GCC\n   builtin and then its argument prototype would still apply.  */\n#ifdef __cplusplus\nextern \"C\"\n#endif\nchar shl_load ();\nint\nmain ()\n{\nreturn shl_load ();\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_link \"$LINENO\"; then :\n  ac_cv_lib_dld_shl_load=yes\nelse\n  ac_cv_lib_dld_shl_load=no\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\nLIBS=$ac_check_lib_save_LIBS\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load\" >&5\n$as_echo \"$ac_cv_lib_dld_shl_load\" >&6; }\nif test \"x$ac_cv_lib_dld_shl_load\" = xyes; then :\n  lt_cv_dlopen=\"shl_load\" lt_cv_dlopen_libs=\"-ldld\"\nelse\n  ac_fn_c_check_func \"$LINENO\" \"dlopen\" \"ac_cv_func_dlopen\"\nif test \"x$ac_cv_func_dlopen\" = xyes; then :\n  lt_cv_dlopen=\"dlopen\"\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl\" >&5\n$as_echo_n \"checking for dlopen in -ldl... \" >&6; }\nif ${ac_cv_lib_dl_dlopen+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  ac_check_lib_save_LIBS=$LIBS\nLIBS=\"-ldl  $LIBS\"\ncat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\n/* Override any GCC internal prototype to avoid an error.\n   Use char because int might match the return type of a GCC\n   builtin and then its argument prototype would still apply.  */\n#ifdef __cplusplus\nextern \"C\"\n#endif\nchar dlopen ();\nint\nmain ()\n{\nreturn dlopen ();\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_link \"$LINENO\"; then :\n  ac_cv_lib_dl_dlopen=yes\nelse\n  ac_cv_lib_dl_dlopen=no\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\nLIBS=$ac_check_lib_save_LIBS\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen\" >&5\n$as_echo \"$ac_cv_lib_dl_dlopen\" >&6; }\nif test \"x$ac_cv_lib_dl_dlopen\" = xyes; then :\n  lt_cv_dlopen=\"dlopen\" lt_cv_dlopen_libs=\"-ldl\"\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld\" >&5\n$as_echo_n \"checking for dlopen in -lsvld... \" >&6; }\nif ${ac_cv_lib_svld_dlopen+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  ac_check_lib_save_LIBS=$LIBS\nLIBS=\"-lsvld  $LIBS\"\ncat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\n/* Override any GCC internal prototype to avoid an error.\n   Use char because int might match the return type of a GCC\n   builtin and then its argument prototype would still apply.  */\n#ifdef __cplusplus\nextern \"C\"\n#endif\nchar dlopen ();\nint\nmain ()\n{\nreturn dlopen ();\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_link \"$LINENO\"; then :\n  ac_cv_lib_svld_dlopen=yes\nelse\n  ac_cv_lib_svld_dlopen=no\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\nLIBS=$ac_check_lib_save_LIBS\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen\" >&5\n$as_echo \"$ac_cv_lib_svld_dlopen\" >&6; }\nif test \"x$ac_cv_lib_svld_dlopen\" = xyes; then :\n  lt_cv_dlopen=\"dlopen\" lt_cv_dlopen_libs=\"-lsvld\"\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld\" >&5\n$as_echo_n \"checking for dld_link in -ldld... \" >&6; }\nif ${ac_cv_lib_dld_dld_link+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  ac_check_lib_save_LIBS=$LIBS\nLIBS=\"-ldld  $LIBS\"\ncat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\n/* Override any GCC internal prototype to avoid an error.\n   Use char because int might match the return type of a GCC\n   builtin and then its argument prototype would still apply.  */\n#ifdef __cplusplus\nextern \"C\"\n#endif\nchar dld_link ();\nint\nmain ()\n{\nreturn dld_link ();\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_link \"$LINENO\"; then :\n  ac_cv_lib_dld_dld_link=yes\nelse\n  ac_cv_lib_dld_dld_link=no\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\nLIBS=$ac_check_lib_save_LIBS\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link\" >&5\n$as_echo \"$ac_cv_lib_dld_dld_link\" >&6; }\nif test \"x$ac_cv_lib_dld_dld_link\" = xyes; then :\n  lt_cv_dlopen=\"dld_link\" lt_cv_dlopen_libs=\"-ldld\"\nfi\n\n\nfi\n\n\nfi\n\n\nfi\n\n\nfi\n\n\nfi\n\n    ;;\n  esac\n\n  if test \"x$lt_cv_dlopen\" != xno; then\n    enable_dlopen=yes\n  else\n    enable_dlopen=no\n  fi\n\n  case $lt_cv_dlopen in\n  dlopen)\n    save_CPPFLAGS=\"$CPPFLAGS\"\n    test \"x$ac_cv_header_dlfcn_h\" = xyes && CPPFLAGS=\"$CPPFLAGS -DHAVE_DLFCN_H\"\n\n    save_LDFLAGS=\"$LDFLAGS\"\n    wl=$lt_prog_compiler_wl eval LDFLAGS=\\\"\\$LDFLAGS $export_dynamic_flag_spec\\\"\n\n    save_LIBS=\"$LIBS\"\n    LIBS=\"$lt_cv_dlopen_libs $LIBS\"\n\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself\" >&5\n$as_echo_n \"checking whether a program can dlopen itself... \" >&6; }\nif ${lt_cv_dlopen_self+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  \t  if test \"$cross_compiling\" = yes; then :\n  lt_cv_dlopen_self=cross\nelse\n  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2\n  lt_status=$lt_dlunknown\n  cat > conftest.$ac_ext <<_LT_EOF\n#line $LINENO \"configure\"\n#include \"confdefs.h\"\n\n#if HAVE_DLFCN_H\n#include <dlfcn.h>\n#endif\n\n#include <stdio.h>\n\n#ifdef RTLD_GLOBAL\n#  define LT_DLGLOBAL\t\tRTLD_GLOBAL\n#else\n#  ifdef DL_GLOBAL\n#    define LT_DLGLOBAL\t\tDL_GLOBAL\n#  else\n#    define LT_DLGLOBAL\t\t0\n#  endif\n#endif\n\n/* We may have to define LT_DLLAZY_OR_NOW in the command line if we\n   find out it does not work in some platform. */\n#ifndef LT_DLLAZY_OR_NOW\n#  ifdef RTLD_LAZY\n#    define LT_DLLAZY_OR_NOW\t\tRTLD_LAZY\n#  else\n#    ifdef DL_LAZY\n#      define LT_DLLAZY_OR_NOW\t\tDL_LAZY\n#    else\n#      ifdef RTLD_NOW\n#        define LT_DLLAZY_OR_NOW\tRTLD_NOW\n#      else\n#        ifdef DL_NOW\n#          define LT_DLLAZY_OR_NOW\tDL_NOW\n#        else\n#          define LT_DLLAZY_OR_NOW\t0\n#        endif\n#      endif\n#    endif\n#  endif\n#endif\n\n/* When -fvisbility=hidden is used, assume the code has been annotated\n   correspondingly for the symbols needed.  */\n#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))\nint fnord () __attribute__((visibility(\"default\")));\n#endif\n\nint fnord () { return 42; }\nint main ()\n{\n  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);\n  int status = $lt_dlunknown;\n\n  if (self)\n    {\n      if (dlsym (self,\"fnord\"))       status = $lt_dlno_uscore;\n      else\n        {\n\t  if (dlsym( self,\"_fnord\"))  status = $lt_dlneed_uscore;\n          else puts (dlerror ());\n\t}\n      /* dlclose (self); */\n    }\n  else\n    puts (dlerror ());\n\n  return status;\n}\n_LT_EOF\n  if { { eval echo \"\\\"\\$as_me\\\":${as_lineno-$LINENO}: \\\"$ac_link\\\"\"; } >&5\n  (eval $ac_link) 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then\n    (./conftest; exit; ) >&5 2>/dev/null\n    lt_status=$?\n    case x$lt_status in\n      x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;\n      x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;\n      x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;\n    esac\n  else :\n    # compilation failed\n    lt_cv_dlopen_self=no\n  fi\nfi\nrm -fr conftest*\n\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self\" >&5\n$as_echo \"$lt_cv_dlopen_self\" >&6; }\n\n    if test \"x$lt_cv_dlopen_self\" = xyes; then\n      wl=$lt_prog_compiler_wl eval LDFLAGS=\\\"\\$LDFLAGS $lt_prog_compiler_static\\\"\n      { $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself\" >&5\n$as_echo_n \"checking whether a statically linked program can dlopen itself... \" >&6; }\nif ${lt_cv_dlopen_self_static+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  \t  if test \"$cross_compiling\" = yes; then :\n  lt_cv_dlopen_self_static=cross\nelse\n  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2\n  lt_status=$lt_dlunknown\n  cat > conftest.$ac_ext <<_LT_EOF\n#line $LINENO \"configure\"\n#include \"confdefs.h\"\n\n#if HAVE_DLFCN_H\n#include <dlfcn.h>\n#endif\n\n#include <stdio.h>\n\n#ifdef RTLD_GLOBAL\n#  define LT_DLGLOBAL\t\tRTLD_GLOBAL\n#else\n#  ifdef DL_GLOBAL\n#    define LT_DLGLOBAL\t\tDL_GLOBAL\n#  else\n#    define LT_DLGLOBAL\t\t0\n#  endif\n#endif\n\n/* We may have to define LT_DLLAZY_OR_NOW in the command line if we\n   find out it does not work in some platform. */\n#ifndef LT_DLLAZY_OR_NOW\n#  ifdef RTLD_LAZY\n#    define LT_DLLAZY_OR_NOW\t\tRTLD_LAZY\n#  else\n#    ifdef DL_LAZY\n#      define LT_DLLAZY_OR_NOW\t\tDL_LAZY\n#    else\n#      ifdef RTLD_NOW\n#        define LT_DLLAZY_OR_NOW\tRTLD_NOW\n#      else\n#        ifdef DL_NOW\n#          define LT_DLLAZY_OR_NOW\tDL_NOW\n#        else\n#          define LT_DLLAZY_OR_NOW\t0\n#        endif\n#      endif\n#    endif\n#  endif\n#endif\n\n/* When -fvisbility=hidden is used, assume the code has been annotated\n   correspondingly for the symbols needed.  */\n#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))\nint fnord () __attribute__((visibility(\"default\")));\n#endif\n\nint fnord () { return 42; }\nint main ()\n{\n  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);\n  int status = $lt_dlunknown;\n\n  if (self)\n    {\n      if (dlsym (self,\"fnord\"))       status = $lt_dlno_uscore;\n      else\n        {\n\t  if (dlsym( self,\"_fnord\"))  status = $lt_dlneed_uscore;\n          else puts (dlerror ());\n\t}\n      /* dlclose (self); */\n    }\n  else\n    puts (dlerror ());\n\n  return status;\n}\n_LT_EOF\n  if { { eval echo \"\\\"\\$as_me\\\":${as_lineno-$LINENO}: \\\"$ac_link\\\"\"; } >&5\n  (eval $ac_link) 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then\n    (./conftest; exit; ) >&5 2>/dev/null\n    lt_status=$?\n    case x$lt_status in\n      x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;\n      x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;\n      x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;\n    esac\n  else :\n    # compilation failed\n    lt_cv_dlopen_self_static=no\n  fi\nfi\nrm -fr conftest*\n\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static\" >&5\n$as_echo \"$lt_cv_dlopen_self_static\" >&6; }\n    fi\n\n    CPPFLAGS=\"$save_CPPFLAGS\"\n    LDFLAGS=\"$save_LDFLAGS\"\n    LIBS=\"$save_LIBS\"\n    ;;\n  esac\n\n  case $lt_cv_dlopen_self in\n  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;\n  *) enable_dlopen_self=unknown ;;\n  esac\n\n  case $lt_cv_dlopen_self_static in\n  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;\n  *) enable_dlopen_self_static=unknown ;;\n  esac\nfi\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nstriplib=\nold_striplib=\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible\" >&5\n$as_echo_n \"checking whether stripping libraries is possible... \" >&6; }\nif test -n \"$STRIP\" && $STRIP -V 2>&1 | $GREP \"GNU strip\" >/dev/null; then\n  test -z \"$old_striplib\" && old_striplib=\"$STRIP --strip-debug\"\n  test -z \"$striplib\" && striplib=\"$STRIP --strip-unneeded\"\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: yes\" >&5\n$as_echo \"yes\" >&6; }\nelse\n# FIXME - insert some real tests, host_os isn't really good enough\n  case $host_os in\n  darwin*)\n    if test -n \"$STRIP\" ; then\n      striplib=\"$STRIP -x\"\n      old_striplib=\"$STRIP -S\"\n      { $as_echo \"$as_me:${as_lineno-$LINENO}: result: yes\" >&5\n$as_echo \"yes\" >&6; }\n    else\n      { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\n    fi\n    ;;\n  *)\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\n    ;;\n  esac\nfi\n\n\n\n\n\n\n\n\n\n\n\n\n  # Report which library types will actually be built\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries\" >&5\n$as_echo_n \"checking if libtool supports shared libraries... \" >&6; }\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $can_build_shared\" >&5\n$as_echo \"$can_build_shared\" >&6; }\n\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries\" >&5\n$as_echo_n \"checking whether to build shared libraries... \" >&6; }\n  test \"$can_build_shared\" = \"no\" && enable_shared=no\n\n  # On AIX, shared libraries and static libraries use the same namespace, and\n  # are all built from PIC.\n  case $host_os in\n  aix3*)\n    test \"$enable_shared\" = yes && enable_static=no\n    if test -n \"$RANLIB\"; then\n      archive_cmds=\"$archive_cmds~\\$RANLIB \\$lib\"\n      postinstall_cmds='$RANLIB $lib'\n    fi\n    ;;\n\n  aix[4-9]*)\n    if test \"$host_cpu\" != ia64 && test \"$aix_use_runtimelinking\" = no ; then\n      test \"$enable_shared\" = yes && enable_static=no\n    fi\n    ;;\n  esac\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $enable_shared\" >&5\n$as_echo \"$enable_shared\" >&6; }\n\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether to build static libraries\" >&5\n$as_echo_n \"checking whether to build static libraries... \" >&6; }\n  # Make sure either enable_shared or enable_static is yes.\n  test \"$enable_shared\" = yes || enable_static=yes\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $enable_static\" >&5\n$as_echo \"$enable_static\" >&6; }\n\n\n\n\nfi\nac_ext=cpp\nac_cpp='$CXXCPP $CPPFLAGS'\nac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_cxx_compiler_gnu\n\nCC=\"$lt_save_CC\"\n\n      if test -n \"$CXX\" && ( test \"X$CXX\" != \"Xno\" &&\n    ( (test \"X$CXX\" = \"Xg++\" && `g++ -v >/dev/null 2>&1` ) ||\n    (test \"X$CXX\" != \"Xg++\"))) ; then\n  ac_ext=cpp\nac_cpp='$CXXCPP $CPPFLAGS'\nac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_cxx_compiler_gnu\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor\" >&5\n$as_echo_n \"checking how to run the C++ preprocessor... \" >&6; }\nif test -z \"$CXXCPP\"; then\n  if ${ac_cv_prog_CXXCPP+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n      # Double quotes because CXXCPP needs to be expanded\n    for CXXCPP in \"$CXX -E\" \"/lib/cpp\"\n    do\n      ac_preproc_ok=false\nfor ac_cxx_preproc_warn_flag in '' yes\ndo\n  # Use a header file that comes with gcc, so configuring glibc\n  # with a fresh cross-compiler works.\n  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since\n  # <limits.h> exists even on freestanding compilers.\n  # On the NeXT, cc -E runs the code through the compiler's parser,\n  # not just through cpp. \"Syntax error\" is here to catch this case.\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#ifdef __STDC__\n# include <limits.h>\n#else\n# include <assert.h>\n#endif\n\t\t     Syntax error\n_ACEOF\nif ac_fn_cxx_try_cpp \"$LINENO\"; then :\n\nelse\n  # Broken: fails on valid input.\ncontinue\nfi\nrm -f conftest.err conftest.i conftest.$ac_ext\n\n  # OK, works on sane cases.  Now check whether nonexistent headers\n  # can be detected and how.\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <ac_nonexistent.h>\n_ACEOF\nif ac_fn_cxx_try_cpp \"$LINENO\"; then :\n  # Broken: success on invalid input.\ncontinue\nelse\n  # Passes both tests.\nac_preproc_ok=:\nbreak\nfi\nrm -f conftest.err conftest.i conftest.$ac_ext\n\ndone\n# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.\nrm -f conftest.i conftest.err conftest.$ac_ext\nif $ac_preproc_ok; then :\n  break\nfi\n\n    done\n    ac_cv_prog_CXXCPP=$CXXCPP\n\nfi\n  CXXCPP=$ac_cv_prog_CXXCPP\nelse\n  ac_cv_prog_CXXCPP=$CXXCPP\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $CXXCPP\" >&5\n$as_echo \"$CXXCPP\" >&6; }\nac_preproc_ok=false\nfor ac_cxx_preproc_warn_flag in '' yes\ndo\n  # Use a header file that comes with gcc, so configuring glibc\n  # with a fresh cross-compiler works.\n  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since\n  # <limits.h> exists even on freestanding compilers.\n  # On the NeXT, cc -E runs the code through the compiler's parser,\n  # not just through cpp. \"Syntax error\" is here to catch this case.\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#ifdef __STDC__\n# include <limits.h>\n#else\n# include <assert.h>\n#endif\n\t\t     Syntax error\n_ACEOF\nif ac_fn_cxx_try_cpp \"$LINENO\"; then :\n\nelse\n  # Broken: fails on valid input.\ncontinue\nfi\nrm -f conftest.err conftest.i conftest.$ac_ext\n\n  # OK, works on sane cases.  Now check whether nonexistent headers\n  # can be detected and how.\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <ac_nonexistent.h>\n_ACEOF\nif ac_fn_cxx_try_cpp \"$LINENO\"; then :\n  # Broken: success on invalid input.\ncontinue\nelse\n  # Passes both tests.\nac_preproc_ok=:\nbreak\nfi\nrm -f conftest.err conftest.i conftest.$ac_ext\n\ndone\n# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.\nrm -f conftest.i conftest.err conftest.$ac_ext\nif $ac_preproc_ok; then :\n\nelse\n  { { $as_echo \"$as_me:${as_lineno-$LINENO}: error: in \\`$ac_pwd':\" >&5\n$as_echo \"$as_me: error: in \\`$ac_pwd':\" >&2;}\nas_fn_error $? \"C++ preprocessor \\\"$CXXCPP\\\" fails sanity check\nSee \\`config.log' for more details\" \"$LINENO\" 5; }\nfi\n\nac_ext=cpp\nac_cpp='$CXXCPP $CPPFLAGS'\nac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_cxx_compiler_gnu\n\nelse\n  _lt_caught_CXX_error=yes\nfi\n\nac_ext=cpp\nac_cpp='$CXXCPP $CPPFLAGS'\nac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_cxx_compiler_gnu\n\narchive_cmds_need_lc_CXX=no\nallow_undefined_flag_CXX=\nalways_export_symbols_CXX=no\narchive_expsym_cmds_CXX=\ncompiler_needs_object_CXX=no\nexport_dynamic_flag_spec_CXX=\nhardcode_direct_CXX=no\nhardcode_direct_absolute_CXX=no\nhardcode_libdir_flag_spec_CXX=\nhardcode_libdir_separator_CXX=\nhardcode_minus_L_CXX=no\nhardcode_shlibpath_var_CXX=unsupported\nhardcode_automatic_CXX=no\ninherit_rpath_CXX=no\nmodule_cmds_CXX=\nmodule_expsym_cmds_CXX=\nlink_all_deplibs_CXX=unknown\nold_archive_cmds_CXX=$old_archive_cmds\nreload_flag_CXX=$reload_flag\nreload_cmds_CXX=$reload_cmds\nno_undefined_flag_CXX=\nwhole_archive_flag_spec_CXX=\nenable_shared_with_static_runtimes_CXX=no\n\n# Source file extension for C++ test sources.\nac_ext=cpp\n\n# Object file extension for compiled C++ test sources.\nobjext=o\nobjext_CXX=$objext\n\n# No sense in running all these tests if we already determined that\n# the CXX compiler isn't working.  Some variables (like enable_shared)\n# are currently assumed to apply to all compilers on this platform,\n# and will be corrupted by setting them based on a non-working compiler.\nif test \"$_lt_caught_CXX_error\" != yes; then\n  # Code to be used in simple compile tests\n  lt_simple_compile_test_code=\"int some_variable = 0;\"\n\n  # Code to be used in simple link tests\n  lt_simple_link_test_code='int main(int, char *[]) { return(0); }'\n\n  # ltmain only uses $CC for tagged configurations so make sure $CC is set.\n\n\n\n\n\n\n# If no C compiler was specified, use CC.\nLTCC=${LTCC-\"$CC\"}\n\n# If no C compiler flags were specified, use CFLAGS.\nLTCFLAGS=${LTCFLAGS-\"$CFLAGS\"}\n\n# Allow CC to be a program name with arguments.\ncompiler=$CC\n\n\n  # save warnings/boilerplate of simple test code\n  ac_outfile=conftest.$ac_objext\necho \"$lt_simple_compile_test_code\" >conftest.$ac_ext\neval \"$ac_compile\" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err\n_lt_compiler_boilerplate=`cat conftest.err`\n$RM conftest*\n\n  ac_outfile=conftest.$ac_objext\necho \"$lt_simple_link_test_code\" >conftest.$ac_ext\neval \"$ac_link\" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err\n_lt_linker_boilerplate=`cat conftest.err`\n$RM -r conftest*\n\n\n  # Allow CC to be a program name with arguments.\n  lt_save_CC=$CC\n  lt_save_CFLAGS=$CFLAGS\n  lt_save_LD=$LD\n  lt_save_GCC=$GCC\n  GCC=$GXX\n  lt_save_with_gnu_ld=$with_gnu_ld\n  lt_save_path_LD=$lt_cv_path_LD\n  if test -n \"${lt_cv_prog_gnu_ldcxx+set}\"; then\n    lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx\n  else\n    $as_unset lt_cv_prog_gnu_ld\n  fi\n  if test -n \"${lt_cv_path_LDCXX+set}\"; then\n    lt_cv_path_LD=$lt_cv_path_LDCXX\n  else\n    $as_unset lt_cv_path_LD\n  fi\n  test -z \"${LDCXX+set}\" || LD=$LDCXX\n  CC=${CXX-\"c++\"}\n  CFLAGS=$CXXFLAGS\n  compiler=$CC\n  compiler_CXX=$CC\n  for cc_temp in $compiler\"\"; do\n  case $cc_temp in\n    compile | *[\\\\/]compile | ccache | *[\\\\/]ccache ) ;;\n    distcc | *[\\\\/]distcc | purify | *[\\\\/]purify ) ;;\n    \\-*) ;;\n    *) break;;\n  esac\ndone\ncc_basename=`$ECHO \"$cc_temp\" | $SED \"s%.*/%%; s%^$host_alias-%%\"`\n\n\n  if test -n \"$compiler\"; then\n    # We don't want -fno-exception when compiling C++ code, so set the\n    # no_builtin_flag separately\n    if test \"$GXX\" = yes; then\n      lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin'\n    else\n      lt_prog_compiler_no_builtin_flag_CXX=\n    fi\n\n    if test \"$GXX\" = yes; then\n      # Set up default GNU C++ configuration\n\n\n\n# Check whether --with-gnu-ld was given.\nif test \"${with_gnu_ld+set}\" = set; then :\n  withval=$with_gnu_ld; test \"$withval\" = no || with_gnu_ld=yes\nelse\n  with_gnu_ld=no\nfi\n\nac_prog=ld\nif test \"$GCC\" = yes; then\n  # Check if gcc -print-prog-name=ld gives a path.\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for ld used by $CC\" >&5\n$as_echo_n \"checking for ld used by $CC... \" >&6; }\n  case $host in\n  *-*-mingw*)\n    # gcc leaves a trailing carriage return which upsets mingw\n    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\\015'` ;;\n  *)\n    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;\n  esac\n  case $ac_prog in\n    # Accept absolute paths.\n    [\\\\/]* | ?:[\\\\/]*)\n      re_direlt='/[^/][^/]*/\\.\\./'\n      # Canonicalize the pathname of ld\n      ac_prog=`$ECHO \"$ac_prog\"| $SED 's%\\\\\\\\%/%g'`\n      while $ECHO \"$ac_prog\" | $GREP \"$re_direlt\" > /dev/null 2>&1; do\n\tac_prog=`$ECHO $ac_prog| $SED \"s%$re_direlt%/%\"`\n      done\n      test -z \"$LD\" && LD=\"$ac_prog\"\n      ;;\n  \"\")\n    # If it fails, then pretend we aren't using GCC.\n    ac_prog=ld\n    ;;\n  *)\n    # If it is relative, then search for the first ld in PATH.\n    with_gnu_ld=unknown\n    ;;\n  esac\nelif test \"$with_gnu_ld\" = yes; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for GNU ld\" >&5\n$as_echo_n \"checking for GNU ld... \" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for non-GNU ld\" >&5\n$as_echo_n \"checking for non-GNU ld... \" >&6; }\nfi\nif ${lt_cv_path_LD+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -z \"$LD\"; then\n  lt_save_ifs=\"$IFS\"; IFS=$PATH_SEPARATOR\n  for ac_dir in $PATH; do\n    IFS=\"$lt_save_ifs\"\n    test -z \"$ac_dir\" && ac_dir=.\n    if test -f \"$ac_dir/$ac_prog\" || test -f \"$ac_dir/$ac_prog$ac_exeext\"; then\n      lt_cv_path_LD=\"$ac_dir/$ac_prog\"\n      # Check to see if the program is GNU ld.  I'd rather use --version,\n      # but apparently some variants of GNU ld only accept -v.\n      # Break only if it was the GNU/non-GNU ld that we prefer.\n      case `\"$lt_cv_path_LD\" -v 2>&1 </dev/null` in\n      *GNU* | *'with BFD'*)\n\ttest \"$with_gnu_ld\" != no && break\n\t;;\n      *)\n\ttest \"$with_gnu_ld\" != yes && break\n\t;;\n      esac\n    fi\n  done\n  IFS=\"$lt_save_ifs\"\nelse\n  lt_cv_path_LD=\"$LD\" # Let the user override the test with a path.\nfi\nfi\n\nLD=\"$lt_cv_path_LD\"\nif test -n \"$LD\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $LD\" >&5\n$as_echo \"$LD\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\ntest -z \"$LD\" && as_fn_error $? \"no acceptable ld found in \\$PATH\" \"$LINENO\" 5\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld\" >&5\n$as_echo_n \"checking if the linker ($LD) is GNU ld... \" >&6; }\nif ${lt_cv_prog_gnu_ld+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  # I'd rather use --version here, but apparently some GNU lds only accept -v.\ncase `$LD -v 2>&1 </dev/null` in\n*GNU* | *'with BFD'*)\n  lt_cv_prog_gnu_ld=yes\n  ;;\n*)\n  lt_cv_prog_gnu_ld=no\n  ;;\nesac\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld\" >&5\n$as_echo \"$lt_cv_prog_gnu_ld\" >&6; }\nwith_gnu_ld=$lt_cv_prog_gnu_ld\n\n\n\n\n\n\n\n      # Check if GNU C++ uses GNU ld as the underlying linker, since the\n      # archiving commands below assume that GNU ld is being used.\n      if test \"$with_gnu_ld\" = yes; then\n        archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'\n        archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'\n\n        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'\n        export_dynamic_flag_spec_CXX='${wl}--export-dynamic'\n\n        # If archive_cmds runs LD, not CC, wlarc should be empty\n        # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to\n        #     investigate it a little bit more. (MM)\n        wlarc='${wl}'\n\n        # ancient GNU ld didn't support --whole-archive et. al.\n        if eval \"`$CC -print-prog-name=ld` --help 2>&1\" |\n\t  $GREP 'no-whole-archive' > /dev/null; then\n          whole_archive_flag_spec_CXX=\"$wlarc\"'--whole-archive$convenience '\"$wlarc\"'--no-whole-archive'\n        else\n          whole_archive_flag_spec_CXX=\n        fi\n      else\n        with_gnu_ld=no\n        wlarc=\n\n        # A generic and very simple default shared library creation\n        # command for GNU C++ for the case where it uses the native\n        # linker, instead of GNU ld.  If possible, this setting should\n        # overridden to take advantage of the native linker features on\n        # the platform it is being used on.\n        archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'\n      fi\n\n      # Commands to make compiler produce verbose output that lists\n      # what \"hidden\" libraries, object files and flags are used when\n      # linking a shared library.\n      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v \"^Configured with:\" | $GREP \"\\-L\"'\n\n    else\n      GXX=no\n      with_gnu_ld=no\n      wlarc=\n    fi\n\n    # PORTME: fill in a description of your system's C++ link characteristics\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries\" >&5\n$as_echo_n \"checking whether the $compiler linker ($LD) supports shared libraries... \" >&6; }\n    ld_shlibs_CXX=yes\n    case $host_os in\n      aix3*)\n        # FIXME: insert proper C++ library support\n        ld_shlibs_CXX=no\n        ;;\n      aix[4-9]*)\n        if test \"$host_cpu\" = ia64; then\n          # On IA64, the linker does run time linking by default, so we don't\n          # have to do anything special.\n          aix_use_runtimelinking=no\n          exp_sym_flag='-Bexport'\n          no_entry_flag=\"\"\n        else\n          aix_use_runtimelinking=no\n\n          # Test if we are trying to use run time linking or normal\n          # AIX style linking. If -brtl is somewhere in LDFLAGS, we\n          # need to do runtime linking.\n          case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)\n\t    for ld_flag in $LDFLAGS; do\n\t      case $ld_flag in\n\t      *-brtl*)\n\t        aix_use_runtimelinking=yes\n\t        break\n\t        ;;\n\t      esac\n\t    done\n\t    ;;\n          esac\n\n          exp_sym_flag='-bexport'\n          no_entry_flag='-bnoentry'\n        fi\n\n        # When large executables or shared objects are built, AIX ld can\n        # have problems creating the table of contents.  If linking a library\n        # or program results in \"error TOC overflow\" add -mminimal-toc to\n        # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not\n        # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.\n\n        archive_cmds_CXX=''\n        hardcode_direct_CXX=yes\n        hardcode_direct_absolute_CXX=yes\n        hardcode_libdir_separator_CXX=':'\n        link_all_deplibs_CXX=yes\n        file_list_spec_CXX='${wl}-f,'\n\n        if test \"$GXX\" = yes; then\n          case $host_os in aix4.[012]|aix4.[012].*)\n          # We only want to do this on AIX 4.2 and lower, the check\n          # below for broken collect2 doesn't work under 4.3+\n\t  collect2name=`${CC} -print-prog-name=collect2`\n\t  if test -f \"$collect2name\" &&\n\t     strings \"$collect2name\" | $GREP resolve_lib_name >/dev/null\n\t  then\n\t    # We have reworked collect2\n\t    :\n\t  else\n\t    # We have old collect2\n\t    hardcode_direct_CXX=unsupported\n\t    # It fails to find uninstalled libraries when the uninstalled\n\t    # path is not listed in the libpath.  Setting hardcode_minus_L\n\t    # to unsupported forces relinking\n\t    hardcode_minus_L_CXX=yes\n\t    hardcode_libdir_flag_spec_CXX='-L$libdir'\n\t    hardcode_libdir_separator_CXX=\n\t  fi\n          esac\n          shared_flag='-shared'\n\t  if test \"$aix_use_runtimelinking\" = yes; then\n\t    shared_flag=\"$shared_flag \"'${wl}-G'\n\t  fi\n        else\n          # not using gcc\n          if test \"$host_cpu\" = ia64; then\n\t  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release\n\t  # chokes on -Wl,-G. The following line is correct:\n\t  shared_flag='-G'\n          else\n\t    if test \"$aix_use_runtimelinking\" = yes; then\n\t      shared_flag='${wl}-G'\n\t    else\n\t      shared_flag='${wl}-bM:SRE'\n\t    fi\n          fi\n        fi\n\n        export_dynamic_flag_spec_CXX='${wl}-bexpall'\n        # It seems that -bexpall does not export symbols beginning with\n        # underscore (_), so it is better to generate a list of symbols to\n\t# export.\n        always_export_symbols_CXX=yes\n        if test \"$aix_use_runtimelinking\" = yes; then\n          # Warning - without using the other runtime loading flags (-brtl),\n          # -berok will link without error, but may produce a broken library.\n          allow_undefined_flag_CXX='-berok'\n          # Determine the default libpath from the value encoded in an empty\n          # executable.\n          if test \"${lt_cv_aix_libpath+set}\" = set; then\n  aix_libpath=$lt_cv_aix_libpath\nelse\n  if ${lt_cv_aix_libpath__CXX+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_cxx_try_link \"$LINENO\"; then :\n\n  lt_aix_libpath_sed='\n      /Import File Strings/,/^$/ {\n\t  /^0/ {\n\t      s/^0  *\\([^ ]*\\) *$/\\1/\n\t      p\n\t  }\n      }'\n  lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e \"$lt_aix_libpath_sed\"`\n  # Check for a 64-bit object if we didn't find anything.\n  if test -z \"$lt_cv_aix_libpath__CXX\"; then\n    lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e \"$lt_aix_libpath_sed\"`\n  fi\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\n  if test -z \"$lt_cv_aix_libpath__CXX\"; then\n    lt_cv_aix_libpath__CXX=\"/usr/lib:/lib\"\n  fi\n\nfi\n\n  aix_libpath=$lt_cv_aix_libpath__CXX\nfi\n\n          hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'\"$aix_libpath\"\n\n          archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '\"\\${wl}$no_entry_flag\"' $compiler_flags `if test \"x${allow_undefined_flag}\" != \"x\"; then func_echo_all \"${wl}${allow_undefined_flag}\"; else :; fi` '\"\\${wl}$exp_sym_flag:\\$export_symbols $shared_flag\"\n        else\n          if test \"$host_cpu\" = ia64; then\n\t    hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'\n\t    allow_undefined_flag_CXX=\"-z nodefs\"\n\t    archive_expsym_cmds_CXX=\"\\$CC $shared_flag\"' -o $output_objdir/$soname $libobjs $deplibs '\"\\${wl}$no_entry_flag\"' $compiler_flags ${wl}${allow_undefined_flag} '\"\\${wl}$exp_sym_flag:\\$export_symbols\"\n          else\n\t    # Determine the default libpath from the value encoded in an\n\t    # empty executable.\n\t    if test \"${lt_cv_aix_libpath+set}\" = set; then\n  aix_libpath=$lt_cv_aix_libpath\nelse\n  if ${lt_cv_aix_libpath__CXX+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_cxx_try_link \"$LINENO\"; then :\n\n  lt_aix_libpath_sed='\n      /Import File Strings/,/^$/ {\n\t  /^0/ {\n\t      s/^0  *\\([^ ]*\\) *$/\\1/\n\t      p\n\t  }\n      }'\n  lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e \"$lt_aix_libpath_sed\"`\n  # Check for a 64-bit object if we didn't find anything.\n  if test -z \"$lt_cv_aix_libpath__CXX\"; then\n    lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e \"$lt_aix_libpath_sed\"`\n  fi\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\n  if test -z \"$lt_cv_aix_libpath__CXX\"; then\n    lt_cv_aix_libpath__CXX=\"/usr/lib:/lib\"\n  fi\n\nfi\n\n  aix_libpath=$lt_cv_aix_libpath__CXX\nfi\n\n\t    hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'\"$aix_libpath\"\n\t    # Warning - without using the other run time loading flags,\n\t    # -berok will link without error, but may produce a broken library.\n\t    no_undefined_flag_CXX=' ${wl}-bernotok'\n\t    allow_undefined_flag_CXX=' ${wl}-berok'\n\t    if test \"$with_gnu_ld\" = yes; then\n\t      # We only use this code for GNU lds that support --whole-archive.\n\t      whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'\n\t    else\n\t      # Exported symbols can be pulled into shared objects from archives\n\t      whole_archive_flag_spec_CXX='$convenience'\n\t    fi\n\t    archive_cmds_need_lc_CXX=yes\n\t    # This is similar to how AIX traditionally builds its shared\n\t    # libraries.\n\t    archive_expsym_cmds_CXX=\"\\$CC $shared_flag\"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'\n          fi\n        fi\n        ;;\n\n      beos*)\n\tif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then\n\t  allow_undefined_flag_CXX=unsupported\n\t  # Joseph Beckenbach <jrb3@best.com> says some releases of gcc\n\t  # support --undefined.  This deserves some investigation.  FIXME\n\t  archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n\telse\n\t  ld_shlibs_CXX=no\n\tfi\n\t;;\n\n      chorus*)\n        case $cc_basename in\n          *)\n\t  # FIXME: insert proper C++ library support\n\t  ld_shlibs_CXX=no\n\t  ;;\n        esac\n        ;;\n\n      cygwin* | mingw* | pw32* | cegcc*)\n\tcase $GXX,$cc_basename in\n\t,cl* | no,cl*)\n\t  # Native MSVC\n\t  # hardcode_libdir_flag_spec is actually meaningless, as there is\n\t  # no search path for DLLs.\n\t  hardcode_libdir_flag_spec_CXX=' '\n\t  allow_undefined_flag_CXX=unsupported\n\t  always_export_symbols_CXX=yes\n\t  file_list_spec_CXX='@'\n\t  # Tell ltmain to make .lib files, not .a files.\n\t  libext=lib\n\t  # Tell ltmain to make .dll files, not .so files.\n\t  shrext_cmds=\".dll\"\n\t  # FIXME: Setting linknames here is a bad hack.\n\t  archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='\n\t  archive_expsym_cmds_CXX='if test \"x`$SED 1q $export_symbols`\" = xEXPORTS; then\n\t      $SED -n -e 's/\\\\\\\\\\\\\\(.*\\\\\\\\\\\\\\)/-link\\\\\\ -EXPORT:\\\\\\\\\\\\\\1/' -e '1\\\\\\!p' < $export_symbols > $output_objdir/$soname.exp;\n\t    else\n\t      $SED -e 's/\\\\\\\\\\\\\\(.*\\\\\\\\\\\\\\)/-link\\\\\\ -EXPORT:\\\\\\\\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;\n\t    fi~\n\t    $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs \"@$tool_output_objdir$soname.exp\" -Wl,-DLL,-IMPLIB:\"$tool_output_objdir$libname.dll.lib\"~\n\t    linknames='\n\t  # The linker will not automatically build a static lib if we build a DLL.\n\t  # _LT_TAGVAR(old_archive_from_new_cmds, CXX)='true'\n\t  enable_shared_with_static_runtimes_CXX=yes\n\t  # Don't use ranlib\n\t  old_postinstall_cmds_CXX='chmod 644 $oldlib'\n\t  postlink_cmds_CXX='lt_outputfile=\"@OUTPUT@\"~\n\t    lt_tool_outputfile=\"@TOOL_OUTPUT@\"~\n\t    case $lt_outputfile in\n\t      *.exe|*.EXE) ;;\n\t      *)\n\t\tlt_outputfile=\"$lt_outputfile.exe\"\n\t\tlt_tool_outputfile=\"$lt_tool_outputfile.exe\"\n\t\t;;\n\t    esac~\n\t    func_to_tool_file \"$lt_outputfile\"~\n\t    if test \"$MANIFEST_TOOL\" != \":\" && test -f \"$lt_outputfile.manifest\"; then\n\t      $MANIFEST_TOOL -manifest \"$lt_tool_outputfile.manifest\" -outputresource:\"$lt_tool_outputfile\" || exit 1;\n\t      $RM \"$lt_outputfile.manifest\";\n\t    fi'\n\t  ;;\n\t*)\n\t  # g++\n\t  # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,\n\t  # as there is no search path for DLLs.\n\t  hardcode_libdir_flag_spec_CXX='-L$libdir'\n\t  export_dynamic_flag_spec_CXX='${wl}--export-all-symbols'\n\t  allow_undefined_flag_CXX=unsupported\n\t  always_export_symbols_CXX=no\n\t  enable_shared_with_static_runtimes_CXX=yes\n\n\t  if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then\n\t    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'\n\t    # If the export-symbols file already is a .def file (1st line\n\t    # is EXPORTS), use it as is; otherwise, prepend...\n\t    archive_expsym_cmds_CXX='if test \"x`$SED 1q $export_symbols`\" = xEXPORTS; then\n\t      cp $export_symbols $output_objdir/$soname.def;\n\t    else\n\t      echo EXPORTS > $output_objdir/$soname.def;\n\t      cat $export_symbols >> $output_objdir/$soname.def;\n\t    fi~\n\t    $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'\n\t  else\n\t    ld_shlibs_CXX=no\n\t  fi\n\t  ;;\n\tesac\n\t;;\n      darwin* | rhapsody*)\n\n\n  archive_cmds_need_lc_CXX=no\n  hardcode_direct_CXX=no\n  hardcode_automatic_CXX=yes\n  hardcode_shlibpath_var_CXX=unsupported\n  if test \"$lt_cv_ld_force_load\" = \"yes\"; then\n    whole_archive_flag_spec_CXX='`for conv in $convenience\\\"\\\"; do test  -n \\\"$conv\\\" && new_convenience=\\\"$new_convenience ${wl}-force_load,$conv\\\"; done; func_echo_all \\\"$new_convenience\\\"`'\n\n  else\n    whole_archive_flag_spec_CXX=''\n  fi\n  link_all_deplibs_CXX=yes\n  allow_undefined_flag_CXX=\"$_lt_dar_allow_undefined\"\n  case $cc_basename in\n     ifort*) _lt_dar_can_shared=yes ;;\n     *) _lt_dar_can_shared=$GCC ;;\n  esac\n  if test \"$_lt_dar_can_shared\" = \"yes\"; then\n    output_verbose_link_cmd=func_echo_all\n    archive_cmds_CXX=\"\\$CC -dynamiclib \\$allow_undefined_flag -o \\$lib \\$libobjs \\$deplibs \\$compiler_flags -install_name \\$rpath/\\$soname \\$verstring $_lt_dar_single_mod${_lt_dsymutil}\"\n    module_cmds_CXX=\"\\$CC \\$allow_undefined_flag -o \\$lib -bundle \\$libobjs \\$deplibs \\$compiler_flags${_lt_dsymutil}\"\n    archive_expsym_cmds_CXX=\"sed 's,^,_,' < \\$export_symbols > \\$output_objdir/\\${libname}-symbols.expsym~\\$CC -dynamiclib \\$allow_undefined_flag -o \\$lib \\$libobjs \\$deplibs \\$compiler_flags -install_name \\$rpath/\\$soname \\$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}\"\n    module_expsym_cmds_CXX=\"sed -e 's,^,_,' < \\$export_symbols > \\$output_objdir/\\${libname}-symbols.expsym~\\$CC \\$allow_undefined_flag -o \\$lib -bundle \\$libobjs \\$deplibs \\$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}\"\n       if test \"$lt_cv_apple_cc_single_mod\" != \"yes\"; then\n      archive_cmds_CXX=\"\\$CC -r -keep_private_externs -nostdlib -o \\${lib}-master.o \\$libobjs~\\$CC -dynamiclib \\$allow_undefined_flag -o \\$lib \\${lib}-master.o \\$deplibs \\$compiler_flags -install_name \\$rpath/\\$soname \\$verstring${_lt_dsymutil}\"\n      archive_expsym_cmds_CXX=\"sed 's,^,_,' < \\$export_symbols > \\$output_objdir/\\${libname}-symbols.expsym~\\$CC -r -keep_private_externs -nostdlib -o \\${lib}-master.o \\$libobjs~\\$CC -dynamiclib \\$allow_undefined_flag -o \\$lib \\${lib}-master.o \\$deplibs \\$compiler_flags -install_name \\$rpath/\\$soname \\$verstring${_lt_dar_export_syms}${_lt_dsymutil}\"\n    fi\n\n  else\n  ld_shlibs_CXX=no\n  fi\n\n\t;;\n\n      dgux*)\n        case $cc_basename in\n          ec++*)\n\t    # FIXME: insert proper C++ library support\n\t    ld_shlibs_CXX=no\n\t    ;;\n          ghcx*)\n\t    # Green Hills C++ Compiler\n\t    # FIXME: insert proper C++ library support\n\t    ld_shlibs_CXX=no\n\t    ;;\n          *)\n\t    # FIXME: insert proper C++ library support\n\t    ld_shlibs_CXX=no\n\t    ;;\n        esac\n        ;;\n\n      freebsd2.*)\n        # C++ shared libraries reported to be fairly broken before\n\t# switch to ELF\n        ld_shlibs_CXX=no\n        ;;\n\n      freebsd-elf*)\n        archive_cmds_need_lc_CXX=no\n        ;;\n\n      freebsd* | dragonfly*)\n        # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF\n        # conventions\n        ld_shlibs_CXX=yes\n        ;;\n\n      haiku*)\n        archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n        link_all_deplibs_CXX=yes\n        ;;\n\n      hpux9*)\n        hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'\n        hardcode_libdir_separator_CXX=:\n        export_dynamic_flag_spec_CXX='${wl}-E'\n        hardcode_direct_CXX=yes\n        hardcode_minus_L_CXX=yes # Not in the search PATH,\n\t\t\t\t             # but as the default\n\t\t\t\t             # location of the library.\n\n        case $cc_basename in\n          CC*)\n            # FIXME: insert proper C++ library support\n            ld_shlibs_CXX=no\n            ;;\n          aCC*)\n            archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'\n            # Commands to make compiler produce verbose output that lists\n            # what \"hidden\" libraries, object files and flags are used when\n            # linking a shared library.\n            #\n            # There doesn't appear to be a way to prevent this compiler from\n            # explicitly linking system object files so we need to strip them\n            # from the output so that they don't get included in the library\n            # dependencies.\n            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP \"\\-L\"`; list=\"\"; for z in $templist; do case $z in conftest.$objext) list=\"$list $z\";; *.$objext);; *) list=\"$list $z\";;esac; done; func_echo_all \"$list\"'\n            ;;\n          *)\n            if test \"$GXX\" = yes; then\n              archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'\n            else\n              # FIXME: insert proper C++ library support\n              ld_shlibs_CXX=no\n            fi\n            ;;\n        esac\n        ;;\n\n      hpux10*|hpux11*)\n        if test $with_gnu_ld = no; then\n\t  hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'\n\t  hardcode_libdir_separator_CXX=:\n\n          case $host_cpu in\n            hppa*64*|ia64*)\n              ;;\n            *)\n\t      export_dynamic_flag_spec_CXX='${wl}-E'\n              ;;\n          esac\n        fi\n        case $host_cpu in\n          hppa*64*|ia64*)\n            hardcode_direct_CXX=no\n            hardcode_shlibpath_var_CXX=no\n            ;;\n          *)\n            hardcode_direct_CXX=yes\n            hardcode_direct_absolute_CXX=yes\n            hardcode_minus_L_CXX=yes # Not in the search PATH,\n\t\t\t\t\t         # but as the default\n\t\t\t\t\t         # location of the library.\n            ;;\n        esac\n\n        case $cc_basename in\n          CC*)\n\t    # FIXME: insert proper C++ library support\n\t    ld_shlibs_CXX=no\n\t    ;;\n          aCC*)\n\t    case $host_cpu in\n\t      hppa*64*)\n\t        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'\n\t        ;;\n\t      ia64*)\n\t        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'\n\t        ;;\n\t      *)\n\t        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'\n\t        ;;\n\t    esac\n\t    # Commands to make compiler produce verbose output that lists\n\t    # what \"hidden\" libraries, object files and flags are used when\n\t    # linking a shared library.\n\t    #\n\t    # There doesn't appear to be a way to prevent this compiler from\n\t    # explicitly linking system object files so we need to strip them\n\t    # from the output so that they don't get included in the library\n\t    # dependencies.\n\t    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP \"\\-L\"`; list=\"\"; for z in $templist; do case $z in conftest.$objext) list=\"$list $z\";; *.$objext);; *) list=\"$list $z\";;esac; done; func_echo_all \"$list\"'\n\t    ;;\n          *)\n\t    if test \"$GXX\" = yes; then\n\t      if test $with_gnu_ld = no; then\n\t        case $host_cpu in\n\t          hppa*64*)\n\t            archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'\n\t            ;;\n\t          ia64*)\n\t            archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'\n\t            ;;\n\t          *)\n\t            archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'\n\t            ;;\n\t        esac\n\t      fi\n\t    else\n\t      # FIXME: insert proper C++ library support\n\t      ld_shlibs_CXX=no\n\t    fi\n\t    ;;\n        esac\n        ;;\n\n      interix[3-9]*)\n\thardcode_direct_CXX=no\n\thardcode_shlibpath_var_CXX=no\n\thardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'\n\texport_dynamic_flag_spec_CXX='${wl}-E'\n\t# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.\n\t# Instead, shared libraries are loaded at an image base (0x10000000 by\n\t# default) and relocated if they conflict, which is a slow very memory\n\t# consuming and fragmenting process.  To avoid this, we pick a random,\n\t# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link\n\t# time.  Moving up from 0x10000000 also allows more sbrk(2) space.\n\tarchive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \\* 262144 + 1342177280` -o $lib'\n\tarchive_expsym_cmds_CXX='sed \"s,^,_,\" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \\* 262144 + 1342177280` -o $lib'\n\t;;\n      irix5* | irix6*)\n        case $cc_basename in\n          CC*)\n\t    # SGI C++\n\t    archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n \"$verstring\" && func_echo_all \"-set_version $verstring\"` -update_registry ${output_objdir}/so_locations -o $lib'\n\n\t    # Archives containing C++ object files must be created using\n\t    # \"CC -ar\", where \"CC\" is the IRIX C++ compiler.  This is\n\t    # necessary to make sure instantiated templates are included\n\t    # in the archive.\n\t    old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs'\n\t    ;;\n          *)\n\t    if test \"$GXX\" = yes; then\n\t      if test \"$with_gnu_ld\" = no; then\n\t        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n \"$verstring\" && func_echo_all \"${wl}-set_version ${wl}$verstring\"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'\n\t      else\n\t        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n \"$verstring\" && func_echo_all \"${wl}-set_version ${wl}$verstring\"` -o $lib'\n\t      fi\n\t    fi\n\t    link_all_deplibs_CXX=yes\n\t    ;;\n        esac\n        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'\n        hardcode_libdir_separator_CXX=:\n        inherit_rpath_CXX=yes\n        ;;\n\n      linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)\n        case $cc_basename in\n          KCC*)\n\t    # Kuck and Associates, Inc. (KAI) C++ Compiler\n\n\t    # KCC will only create a shared library if the output file\n\t    # ends with \".so\" (or \".sl\" for HP-UX), so rename the library\n\t    # to its proper name (with version) after linking.\n\t    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\\''s/\\([^()0-9A-Za-z{}]\\)/\\\\\\\\\\1/g'\\''`; templib=`echo $lib | $SED -e \"s/\\${tempext}\\..*/.so/\"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \\$templib; mv \\$templib $lib'\n\t    archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\\''s/\\([^()0-9A-Za-z{}]\\)/\\\\\\\\\\1/g'\\''`; templib=`echo $lib | $SED -e \"s/\\${tempext}\\..*/.so/\"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \\$templib ${wl}-retain-symbols-file,$export_symbols; mv \\$templib $lib'\n\t    # Commands to make compiler produce verbose output that lists\n\t    # what \"hidden\" libraries, object files and flags are used when\n\t    # linking a shared library.\n\t    #\n\t    # There doesn't appear to be a way to prevent this compiler from\n\t    # explicitly linking system object files so we need to strip them\n\t    # from the output so that they don't get included in the library\n\t    # dependencies.\n\t    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP \"ld\"`; rm -f libconftest$shared_ext; list=\"\"; for z in $templist; do case $z in conftest.$objext) list=\"$list $z\";; *.$objext);; *) list=\"$list $z\";;esac; done; func_echo_all \"$list\"'\n\n\t    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'\n\t    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'\n\n\t    # Archives containing C++ object files must be created using\n\t    # \"CC -Bstatic\", where \"CC\" is the KAI C++ compiler.\n\t    old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'\n\t    ;;\n\t  icpc* | ecpc* )\n\t    # Intel C++\n\t    with_gnu_ld=yes\n\t    # version 8.0 and above of icpc choke on multiply defined symbols\n\t    # if we add $predep_objects and $postdep_objects, however 7.1 and\n\t    # earlier do not add the objects themselves.\n\t    case `$CC -V 2>&1` in\n\t      *\"Version 7.\"*)\n\t        archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'\n\t\tarchive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'\n\t\t;;\n\t      *)  # Version 8.0 or newer\n\t        tmp_idyn=\n\t        case $host_cpu in\n\t\t  ia64*) tmp_idyn=' -i_dynamic';;\n\t\tesac\n\t        archive_cmds_CXX='$CC -shared'\"$tmp_idyn\"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n\t\tarchive_expsym_cmds_CXX='$CC -shared'\"$tmp_idyn\"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'\n\t\t;;\n\t    esac\n\t    archive_cmds_need_lc_CXX=no\n\t    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'\n\t    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'\n\t    whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'\n\t    ;;\n          pgCC* | pgcpp*)\n            # Portland Group C++ compiler\n\t    case `$CC -V` in\n\t    *pgCC\\ [1-5].* | *pgcpp\\ [1-5].*)\n\t      prelink_cmds_CXX='tpldir=Template.dir~\n\t\trm -rf $tpldir~\n\t\t$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~\n\t\tcompile_command=\"$compile_command `find $tpldir -name \\*.o | sort | $NL2SP`\"'\n\t      old_archive_cmds_CXX='tpldir=Template.dir~\n\t\trm -rf $tpldir~\n\t\t$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~\n\t\t$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \\*.o | sort | $NL2SP`~\n\t\t$RANLIB $oldlib'\n\t      archive_cmds_CXX='tpldir=Template.dir~\n\t\trm -rf $tpldir~\n\t\t$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~\n\t\t$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \\*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'\n\t      archive_expsym_cmds_CXX='tpldir=Template.dir~\n\t\trm -rf $tpldir~\n\t\t$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~\n\t\t$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \\*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'\n\t      ;;\n\t    *) # Version 6 and above use weak symbols\n\t      archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'\n\t      archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'\n\t      ;;\n\t    esac\n\n\t    hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'\n\t    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'\n\t    whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\\\"\\\"; do test  -n \\\"$conv\\\" && new_convenience=\\\"$new_convenience,$conv\\\"; done; func_echo_all \\\"$new_convenience\\\"` ${wl}--no-whole-archive'\n            ;;\n\t  cxx*)\n\t    # Compaq C++\n\t    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'\n\t    archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'\n\n\t    runpath_var=LD_RUN_PATH\n\t    hardcode_libdir_flag_spec_CXX='-rpath $libdir'\n\t    hardcode_libdir_separator_CXX=:\n\n\t    # Commands to make compiler produce verbose output that lists\n\t    # what \"hidden\" libraries, object files and flags are used when\n\t    # linking a shared library.\n\t    #\n\t    # There doesn't appear to be a way to prevent this compiler from\n\t    # explicitly linking system object files so we need to strip them\n\t    # from the output so that they don't get included in the library\n\t    # dependencies.\n\t    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP \"ld\"`; templist=`func_echo_all \"$templist\" | $SED \"s/\\(^.*ld.*\\)\\( .*ld .*$\\)/\\1/\"`; list=\"\"; for z in $templist; do case $z in conftest.$objext) list=\"$list $z\";; *.$objext);; *) list=\"$list $z\";;esac; done; func_echo_all \"X$list\" | $Xsed'\n\t    ;;\n\t  xl* | mpixl* | bgxl*)\n\t    # IBM XL 8.0 on PPC, with GNU ld\n\t    hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'\n\t    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'\n\t    archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n\t    if test \"x$supports_anon_versioning\" = xyes; then\n\t      archive_expsym_cmds_CXX='echo \"{ global:\" > $output_objdir/$libname.ver~\n\t\tcat $export_symbols | sed -e \"s/\\(.*\\)/\\1;/\" >> $output_objdir/$libname.ver~\n\t\techo \"local: *; };\" >> $output_objdir/$libname.ver~\n\t\t$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'\n\t    fi\n\t    ;;\n\t  *)\n\t    case `$CC -V 2>&1 | sed 5q` in\n\t    *Sun\\ C*)\n\t      # Sun C++ 5.9\n\t      no_undefined_flag_CXX=' -zdefs'\n\t      archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'\n\t      archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'\n\t      hardcode_libdir_flag_spec_CXX='-R$libdir'\n\t      whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\\\"\\\"; do test -z \\\"$conv\\\" || new_convenience=\\\"$new_convenience,$conv\\\"; done; func_echo_all \\\"$new_convenience\\\"` ${wl}--no-whole-archive'\n\t      compiler_needs_object_CXX=yes\n\n\t      # Not sure whether something based on\n\t      # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1\n\t      # would be better.\n\t      output_verbose_link_cmd='func_echo_all'\n\n\t      # Archives containing C++ object files must be created using\n\t      # \"CC -xar\", where \"CC\" is the Sun C++ compiler.  This is\n\t      # necessary to make sure instantiated templates are included\n\t      # in the archive.\n\t      old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'\n\t      ;;\n\t    esac\n\t    ;;\n\tesac\n\t;;\n\n      lynxos*)\n        # FIXME: insert proper C++ library support\n\tld_shlibs_CXX=no\n\t;;\n\n      m88k*)\n        # FIXME: insert proper C++ library support\n        ld_shlibs_CXX=no\n\t;;\n\n      mvs*)\n        case $cc_basename in\n          cxx*)\n\t    # FIXME: insert proper C++ library support\n\t    ld_shlibs_CXX=no\n\t    ;;\n\t  *)\n\t    # FIXME: insert proper C++ library support\n\t    ld_shlibs_CXX=no\n\t    ;;\n\tesac\n\t;;\n\n      netbsd*)\n        if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then\n\t  archive_cmds_CXX='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'\n\t  wlarc=\n\t  hardcode_libdir_flag_spec_CXX='-R$libdir'\n\t  hardcode_direct_CXX=yes\n\t  hardcode_shlibpath_var_CXX=no\n\tfi\n\t# Workaround some broken pre-1.5 toolchains\n\toutput_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e \"s:-lgcc -lc -lgcc::\"'\n\t;;\n\n      *nto* | *qnx*)\n        ld_shlibs_CXX=yes\n\t;;\n\n      openbsd2*)\n        # C++ shared libraries are fairly broken\n\tld_shlibs_CXX=no\n\t;;\n\n      openbsd*)\n\tif test -f /usr/libexec/ld.so; then\n\t  hardcode_direct_CXX=yes\n\t  hardcode_shlibpath_var_CXX=no\n\t  hardcode_direct_absolute_CXX=yes\n\t  archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'\n\t  hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'\n\t  if test -z \"`echo __ELF__ | $CC -E - | grep __ELF__`\" || test \"$host_os-$host_cpu\" = \"openbsd2.8-powerpc\"; then\n\t    archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'\n\t    export_dynamic_flag_spec_CXX='${wl}-E'\n\t    whole_archive_flag_spec_CXX=\"$wlarc\"'--whole-archive$convenience '\"$wlarc\"'--no-whole-archive'\n\t  fi\n\t  output_verbose_link_cmd=func_echo_all\n\telse\n\t  ld_shlibs_CXX=no\n\tfi\n\t;;\n\n      osf3* | osf4* | osf5*)\n        case $cc_basename in\n          KCC*)\n\t    # Kuck and Associates, Inc. (KAI) C++ Compiler\n\n\t    # KCC will only create a shared library if the output file\n\t    # ends with \".so\" (or \".sl\" for HP-UX), so rename the library\n\t    # to its proper name (with version) after linking.\n\t    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\\''s/\\([^()0-9A-Za-z{}]\\)/\\\\\\\\\\1/g'\\''`; templib=`echo \"$lib\" | $SED -e \"s/\\${tempext}\\..*/.so/\"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \\$templib; mv \\$templib $lib'\n\n\t    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'\n\t    hardcode_libdir_separator_CXX=:\n\n\t    # Archives containing C++ object files must be created using\n\t    # the KAI C++ compiler.\n\t    case $host in\n\t      osf3*) old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;;\n\t      *) old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;;\n\t    esac\n\t    ;;\n          RCC*)\n\t    # Rational C++ 2.4.1\n\t    # FIXME: insert proper C++ library support\n\t    ld_shlibs_CXX=no\n\t    ;;\n          cxx*)\n\t    case $host in\n\t      osf3*)\n\t        allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\\*'\n\t        archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n \"$verstring\" && func_echo_all \"${wl}-set_version $verstring\"` -update_registry ${output_objdir}/so_locations -o $lib'\n\t        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'\n\t\t;;\n\t      *)\n\t        allow_undefined_flag_CXX=' -expect_unresolved \\*'\n\t        archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n \"$verstring\" && func_echo_all \"-set_version $verstring\"` -update_registry ${output_objdir}/so_locations -o $lib'\n\t        archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf \"%s %s\\\\n\" -exported_symbol \"\\$i\" >> $lib.exp; done~\n\t          echo \"-hidden\">> $lib.exp~\n\t          $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n \"$verstring\" && $ECHO \"-set_version $verstring\"` -update_registry ${output_objdir}/so_locations -o $lib~\n\t          $RM $lib.exp'\n\t        hardcode_libdir_flag_spec_CXX='-rpath $libdir'\n\t\t;;\n\t    esac\n\n\t    hardcode_libdir_separator_CXX=:\n\n\t    # Commands to make compiler produce verbose output that lists\n\t    # what \"hidden\" libraries, object files and flags are used when\n\t    # linking a shared library.\n\t    #\n\t    # There doesn't appear to be a way to prevent this compiler from\n\t    # explicitly linking system object files so we need to strip them\n\t    # from the output so that they don't get included in the library\n\t    # dependencies.\n\t    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP \"ld\" | $GREP -v \"ld:\"`; templist=`func_echo_all \"$templist\" | $SED \"s/\\(^.*ld.*\\)\\( .*ld.*$\\)/\\1/\"`; list=\"\"; for z in $templist; do case $z in conftest.$objext) list=\"$list $z\";; *.$objext);; *) list=\"$list $z\";;esac; done; func_echo_all \"$list\"'\n\t    ;;\n\t  *)\n\t    if test \"$GXX\" = yes && test \"$with_gnu_ld\" = no; then\n\t      allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\\*'\n\t      case $host in\n\t        osf3*)\n\t          archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n \"$verstring\" && func_echo_all \"${wl}-set_version ${wl}$verstring\"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'\n\t\t  ;;\n\t        *)\n\t          archive_cmds_CXX='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n \"$verstring\" && func_echo_all \"${wl}-set_version ${wl}$verstring\"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'\n\t\t  ;;\n\t      esac\n\n\t      hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'\n\t      hardcode_libdir_separator_CXX=:\n\n\t      # Commands to make compiler produce verbose output that lists\n\t      # what \"hidden\" libraries, object files and flags are used when\n\t      # linking a shared library.\n\t      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v \"^Configured with:\" | $GREP \"\\-L\"'\n\n\t    else\n\t      # FIXME: insert proper C++ library support\n\t      ld_shlibs_CXX=no\n\t    fi\n\t    ;;\n        esac\n        ;;\n\n      psos*)\n        # FIXME: insert proper C++ library support\n        ld_shlibs_CXX=no\n        ;;\n\n      sunos4*)\n        case $cc_basename in\n          CC*)\n\t    # Sun C++ 4.x\n\t    # FIXME: insert proper C++ library support\n\t    ld_shlibs_CXX=no\n\t    ;;\n          lcc*)\n\t    # Lucid\n\t    # FIXME: insert proper C++ library support\n\t    ld_shlibs_CXX=no\n\t    ;;\n          *)\n\t    # FIXME: insert proper C++ library support\n\t    ld_shlibs_CXX=no\n\t    ;;\n        esac\n        ;;\n\n      solaris*)\n        case $cc_basename in\n          CC* | sunCC*)\n\t    # Sun C++ 4.2, 5.x and Centerline C++\n            archive_cmds_need_lc_CXX=yes\n\t    no_undefined_flag_CXX=' -zdefs'\n\t    archive_cmds_CXX='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'\n\t    archive_expsym_cmds_CXX='echo \"{ global:\" > $lib.exp~cat $export_symbols | $SED -e \"s/\\(.*\\)/\\1;/\" >> $lib.exp~echo \"local: *; };\" >> $lib.exp~\n\t      $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'\n\n\t    hardcode_libdir_flag_spec_CXX='-R$libdir'\n\t    hardcode_shlibpath_var_CXX=no\n\t    case $host_os in\n\t      solaris2.[0-5] | solaris2.[0-5].*) ;;\n\t      *)\n\t\t# The compiler driver will combine and reorder linker options,\n\t\t# but understands `-z linker_flag'.\n\t        # Supported since Solaris 2.6 (maybe 2.5.1?)\n\t\twhole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract'\n\t        ;;\n\t    esac\n\t    link_all_deplibs_CXX=yes\n\n\t    output_verbose_link_cmd='func_echo_all'\n\n\t    # Archives containing C++ object files must be created using\n\t    # \"CC -xar\", where \"CC\" is the Sun C++ compiler.  This is\n\t    # necessary to make sure instantiated templates are included\n\t    # in the archive.\n\t    old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'\n\t    ;;\n          gcx*)\n\t    # Green Hills C++ Compiler\n\t    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'\n\n\t    # The C++ compiler must be used to create the archive.\n\t    old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs'\n\t    ;;\n          *)\n\t    # GNU C++ compiler with Solaris linker\n\t    if test \"$GXX\" = yes && test \"$with_gnu_ld\" = no; then\n\t      no_undefined_flag_CXX=' ${wl}-z ${wl}defs'\n\t      if $CC --version | $GREP -v '^2\\.7' > /dev/null; then\n\t        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'\n\t        archive_expsym_cmds_CXX='echo \"{ global:\" > $lib.exp~cat $export_symbols | $SED -e \"s/\\(.*\\)/\\1;/\" >> $lib.exp~echo \"local: *; };\" >> $lib.exp~\n\t\t  $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'\n\n\t        # Commands to make compiler produce verbose output that lists\n\t        # what \"hidden\" libraries, object files and flags are used when\n\t        # linking a shared library.\n\t        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v \"^Configured with:\" | $GREP \"\\-L\"'\n\t      else\n\t        # g++ 2.7 appears to require `-G' NOT `-shared' on this\n\t        # platform.\n\t        archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'\n\t        archive_expsym_cmds_CXX='echo \"{ global:\" > $lib.exp~cat $export_symbols | $SED -e \"s/\\(.*\\)/\\1;/\" >> $lib.exp~echo \"local: *; };\" >> $lib.exp~\n\t\t  $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'\n\n\t        # Commands to make compiler produce verbose output that lists\n\t        # what \"hidden\" libraries, object files and flags are used when\n\t        # linking a shared library.\n\t        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v \"^Configured with:\" | $GREP \"\\-L\"'\n\t      fi\n\n\t      hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir'\n\t      case $host_os in\n\t\tsolaris2.[0-5] | solaris2.[0-5].*) ;;\n\t\t*)\n\t\t  whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'\n\t\t  ;;\n\t      esac\n\t    fi\n\t    ;;\n        esac\n        ;;\n\n    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)\n      no_undefined_flag_CXX='${wl}-z,text'\n      archive_cmds_need_lc_CXX=no\n      hardcode_shlibpath_var_CXX=no\n      runpath_var='LD_RUN_PATH'\n\n      case $cc_basename in\n        CC*)\n\t  archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t  archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t  ;;\n\t*)\n\t  archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t  archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t  ;;\n      esac\n      ;;\n\n      sysv5* | sco3.2v5* | sco5v6*)\n\t# Note: We can NOT use -z defs as we might desire, because we do not\n\t# link with -lc, and that would cause any symbols used from libc to\n\t# always be unresolved, which means just about no library would\n\t# ever link correctly.  If we're not using GNU ld we use -z text\n\t# though, which does catch some bad symbols but isn't as heavy-handed\n\t# as -z defs.\n\tno_undefined_flag_CXX='${wl}-z,text'\n\tallow_undefined_flag_CXX='${wl}-z,nodefs'\n\tarchive_cmds_need_lc_CXX=no\n\thardcode_shlibpath_var_CXX=no\n\thardcode_libdir_flag_spec_CXX='${wl}-R,$libdir'\n\thardcode_libdir_separator_CXX=':'\n\tlink_all_deplibs_CXX=yes\n\texport_dynamic_flag_spec_CXX='${wl}-Bexport'\n\trunpath_var='LD_RUN_PATH'\n\n\tcase $cc_basename in\n          CC*)\n\t    archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t    archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t    old_archive_cmds_CXX='$CC -Tprelink_objects $oldobjs~\n\t      '\"$old_archive_cmds_CXX\"\n\t    reload_cmds_CXX='$CC -Tprelink_objects $reload_objs~\n\t      '\"$reload_cmds_CXX\"\n\t    ;;\n\t  *)\n\t    archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t    archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t    ;;\n\tesac\n      ;;\n\n      tandem*)\n        case $cc_basename in\n          NCC*)\n\t    # NonStop-UX NCC 3.20\n\t    # FIXME: insert proper C++ library support\n\t    ld_shlibs_CXX=no\n\t    ;;\n          *)\n\t    # FIXME: insert proper C++ library support\n\t    ld_shlibs_CXX=no\n\t    ;;\n        esac\n        ;;\n\n      vxworks*)\n        # FIXME: insert proper C++ library support\n        ld_shlibs_CXX=no\n        ;;\n\n      *)\n        # FIXME: insert proper C++ library support\n        ld_shlibs_CXX=no\n        ;;\n    esac\n\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX\" >&5\n$as_echo \"$ld_shlibs_CXX\" >&6; }\n    test \"$ld_shlibs_CXX\" = no && can_build_shared=no\n\n    GCC_CXX=\"$GXX\"\n    LD_CXX=\"$LD\"\n\n    ## CAVEAT EMPTOR:\n    ## There is no encapsulation within the following macros, do not change\n    ## the running order or otherwise move them around unless you know exactly\n    ## what you are doing...\n    # Dependencies to place before and after the object being linked:\npredep_objects_CXX=\npostdep_objects_CXX=\npredeps_CXX=\npostdeps_CXX=\ncompiler_lib_search_path_CXX=\n\ncat > conftest.$ac_ext <<_LT_EOF\nclass Foo\n{\npublic:\n  Foo (void) { a = 0; }\nprivate:\n  int a;\n};\n_LT_EOF\n\n\n_lt_libdeps_save_CFLAGS=$CFLAGS\ncase \"$CC $CFLAGS \" in #(\n*\\ -flto*\\ *) CFLAGS=\"$CFLAGS -fno-lto\" ;;\n*\\ -fwhopr*\\ *) CFLAGS=\"$CFLAGS -fno-whopr\" ;;\n*\\ -fuse-linker-plugin*\\ *) CFLAGS=\"$CFLAGS -fno-use-linker-plugin\" ;;\nesac\n\nif { { eval echo \"\\\"\\$as_me\\\":${as_lineno-$LINENO}: \\\"$ac_compile\\\"\"; } >&5\n  (eval $ac_compile) 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; }; then\n  # Parse the compiler output and extract the necessary\n  # objects, libraries and library flags.\n\n  # Sentinel used to keep track of whether or not we are before\n  # the conftest object file.\n  pre_test_object_deps_done=no\n\n  for p in `eval \"$output_verbose_link_cmd\"`; do\n    case ${prev}${p} in\n\n    -L* | -R* | -l*)\n       # Some compilers place space between \"-{L,R}\" and the path.\n       # Remove the space.\n       if test $p = \"-L\" ||\n          test $p = \"-R\"; then\n\t prev=$p\n\t continue\n       fi\n\n       # Expand the sysroot to ease extracting the directories later.\n       if test -z \"$prev\"; then\n         case $p in\n         -L*) func_stripname_cnf '-L' '' \"$p\"; prev=-L; p=$func_stripname_result ;;\n         -R*) func_stripname_cnf '-R' '' \"$p\"; prev=-R; p=$func_stripname_result ;;\n         -l*) func_stripname_cnf '-l' '' \"$p\"; prev=-l; p=$func_stripname_result ;;\n         esac\n       fi\n       case $p in\n       =*) func_stripname_cnf '=' '' \"$p\"; p=$lt_sysroot$func_stripname_result ;;\n       esac\n       if test \"$pre_test_object_deps_done\" = no; then\n\t case ${prev} in\n\t -L | -R)\n\t   # Internal compiler library paths should come after those\n\t   # provided the user.  The postdeps already come after the\n\t   # user supplied libs so there is no need to process them.\n\t   if test -z \"$compiler_lib_search_path_CXX\"; then\n\t     compiler_lib_search_path_CXX=\"${prev}${p}\"\n\t   else\n\t     compiler_lib_search_path_CXX=\"${compiler_lib_search_path_CXX} ${prev}${p}\"\n\t   fi\n\t   ;;\n\t # The \"-l\" case would never come before the object being\n\t # linked, so don't bother handling this case.\n\t esac\n       else\n\t if test -z \"$postdeps_CXX\"; then\n\t   postdeps_CXX=\"${prev}${p}\"\n\t else\n\t   postdeps_CXX=\"${postdeps_CXX} ${prev}${p}\"\n\t fi\n       fi\n       prev=\n       ;;\n\n    *.lto.$objext) ;; # Ignore GCC LTO objects\n    *.$objext)\n       # This assumes that the test object file only shows up\n       # once in the compiler output.\n       if test \"$p\" = \"conftest.$objext\"; then\n\t pre_test_object_deps_done=yes\n\t continue\n       fi\n\n       if test \"$pre_test_object_deps_done\" = no; then\n\t if test -z \"$predep_objects_CXX\"; then\n\t   predep_objects_CXX=\"$p\"\n\t else\n\t   predep_objects_CXX=\"$predep_objects_CXX $p\"\n\t fi\n       else\n\t if test -z \"$postdep_objects_CXX\"; then\n\t   postdep_objects_CXX=\"$p\"\n\t else\n\t   postdep_objects_CXX=\"$postdep_objects_CXX $p\"\n\t fi\n       fi\n       ;;\n\n    *) ;; # Ignore the rest.\n\n    esac\n  done\n\n  # Clean up.\n  rm -f a.out a.exe\nelse\n  echo \"libtool.m4: error: problem compiling CXX test program\"\nfi\n\n$RM -f confest.$objext\nCFLAGS=$_lt_libdeps_save_CFLAGS\n\n# PORTME: override above test on systems where it is broken\ncase $host_os in\ninterix[3-9]*)\n  # Interix 3.5 installs completely hosed .la files for C++, so rather than\n  # hack all around it, let's just trust \"g++\" to DTRT.\n  predep_objects_CXX=\n  postdep_objects_CXX=\n  postdeps_CXX=\n  ;;\n\nlinux*)\n  case `$CC -V 2>&1 | sed 5q` in\n  *Sun\\ C*)\n    # Sun C++ 5.9\n\n    # The more standards-conforming stlport4 library is\n    # incompatible with the Cstd library. Avoid specifying\n    # it if it's in CXXFLAGS. Ignore libCrun as\n    # -library=stlport4 depends on it.\n    case \" $CXX $CXXFLAGS \" in\n    *\" -library=stlport4 \"*)\n      solaris_use_stlport4=yes\n      ;;\n    esac\n\n    if test \"$solaris_use_stlport4\" != yes; then\n      postdeps_CXX='-library=Cstd -library=Crun'\n    fi\n    ;;\n  esac\n  ;;\n\nsolaris*)\n  case $cc_basename in\n  CC* | sunCC*)\n    # The more standards-conforming stlport4 library is\n    # incompatible with the Cstd library. Avoid specifying\n    # it if it's in CXXFLAGS. Ignore libCrun as\n    # -library=stlport4 depends on it.\n    case \" $CXX $CXXFLAGS \" in\n    *\" -library=stlport4 \"*)\n      solaris_use_stlport4=yes\n      ;;\n    esac\n\n    # Adding this requires a known-good setup of shared libraries for\n    # Sun compiler versions before 5.6, else PIC objects from an old\n    # archive will be linked into the output, leading to subtle bugs.\n    if test \"$solaris_use_stlport4\" != yes; then\n      postdeps_CXX='-library=Cstd -library=Crun'\n    fi\n    ;;\n  esac\n  ;;\nesac\n\n\ncase \" $postdeps_CXX \" in\n*\" -lc \"*) archive_cmds_need_lc_CXX=no ;;\nesac\n compiler_lib_search_dirs_CXX=\nif test -n \"${compiler_lib_search_path_CXX}\"; then\n compiler_lib_search_dirs_CXX=`echo \" ${compiler_lib_search_path_CXX}\" | ${SED} -e 's! -L! !g' -e 's!^ !!'`\nfi\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    lt_prog_compiler_wl_CXX=\nlt_prog_compiler_pic_CXX=\nlt_prog_compiler_static_CXX=\n\n\n  # C++ specific cases for pic, static, wl, etc.\n  if test \"$GXX\" = yes; then\n    lt_prog_compiler_wl_CXX='-Wl,'\n    lt_prog_compiler_static_CXX='-static'\n\n    case $host_os in\n    aix*)\n      # All AIX code is PIC.\n      if test \"$host_cpu\" = ia64; then\n\t# AIX 5 now supports IA64 processor\n\tlt_prog_compiler_static_CXX='-Bstatic'\n      fi\n      ;;\n\n    amigaos*)\n      case $host_cpu in\n      powerpc)\n            # see comment about AmigaOS4 .so support\n            lt_prog_compiler_pic_CXX='-fPIC'\n        ;;\n      m68k)\n            # FIXME: we need at least 68020 code to build shared libraries, but\n            # adding the `-m68020' flag to GCC prevents building anything better,\n            # like `-m68040'.\n            lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4'\n        ;;\n      esac\n      ;;\n\n    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)\n      # PIC is the default for these OSes.\n      ;;\n    mingw* | cygwin* | os2* | pw32* | cegcc*)\n      # This hack is so that the source file can tell whether it is being\n      # built for inclusion in a dll (and should export symbols for example).\n      # Although the cygwin gcc ignores -fPIC, still need this for old-style\n      # (--disable-auto-import) libraries\n      lt_prog_compiler_pic_CXX='-DDLL_EXPORT'\n      ;;\n    darwin* | rhapsody*)\n      # PIC is the default on this platform\n      # Common symbols not allowed in MH_DYLIB files\n      lt_prog_compiler_pic_CXX='-fno-common'\n      ;;\n    *djgpp*)\n      # DJGPP does not support shared libraries at all\n      lt_prog_compiler_pic_CXX=\n      ;;\n    haiku*)\n      # PIC is the default for Haiku.\n      # The \"-static\" flag exists, but is broken.\n      lt_prog_compiler_static_CXX=\n      ;;\n    interix[3-9]*)\n      # Interix 3.x gcc -fpic/-fPIC options generate broken code.\n      # Instead, we relocate shared libraries at runtime.\n      ;;\n    sysv4*MP*)\n      if test -d /usr/nec; then\n\tlt_prog_compiler_pic_CXX=-Kconform_pic\n      fi\n      ;;\n    hpux*)\n      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit\n      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag\n      # sets the default TLS model and affects inlining.\n      case $host_cpu in\n      hppa*64*)\n\t;;\n      *)\n\tlt_prog_compiler_pic_CXX='-fPIC'\n\t;;\n      esac\n      ;;\n    *qnx* | *nto*)\n      # QNX uses GNU C++, but need to define -shared option too, otherwise\n      # it will coredump.\n      lt_prog_compiler_pic_CXX='-fPIC -shared'\n      ;;\n    *)\n      lt_prog_compiler_pic_CXX='-fPIC'\n      ;;\n    esac\n  else\n    case $host_os in\n      aix[4-9]*)\n\t# All AIX code is PIC.\n\tif test \"$host_cpu\" = ia64; then\n\t  # AIX 5 now supports IA64 processor\n\t  lt_prog_compiler_static_CXX='-Bstatic'\n\telse\n\t  lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp'\n\tfi\n\t;;\n      chorus*)\n\tcase $cc_basename in\n\tcxch68*)\n\t  # Green Hills C++ Compiler\n\t  # _LT_TAGVAR(lt_prog_compiler_static, CXX)=\"--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a\"\n\t  ;;\n\tesac\n\t;;\n      mingw* | cygwin* | os2* | pw32* | cegcc*)\n\t# This hack is so that the source file can tell whether it is being\n\t# built for inclusion in a dll (and should export symbols for example).\n\tlt_prog_compiler_pic_CXX='-DDLL_EXPORT'\n\t;;\n      dgux*)\n\tcase $cc_basename in\n\t  ec++*)\n\t    lt_prog_compiler_pic_CXX='-KPIC'\n\t    ;;\n\t  ghcx*)\n\t    # Green Hills C++ Compiler\n\t    lt_prog_compiler_pic_CXX='-pic'\n\t    ;;\n\t  *)\n\t    ;;\n\tesac\n\t;;\n      freebsd* | dragonfly*)\n\t# FreeBSD uses GNU C++\n\t;;\n      hpux9* | hpux10* | hpux11*)\n\tcase $cc_basename in\n\t  CC*)\n\t    lt_prog_compiler_wl_CXX='-Wl,'\n\t    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'\n\t    if test \"$host_cpu\" != ia64; then\n\t      lt_prog_compiler_pic_CXX='+Z'\n\t    fi\n\t    ;;\n\t  aCC*)\n\t    lt_prog_compiler_wl_CXX='-Wl,'\n\t    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'\n\t    case $host_cpu in\n\t    hppa*64*|ia64*)\n\t      # +Z the default\n\t      ;;\n\t    *)\n\t      lt_prog_compiler_pic_CXX='+Z'\n\t      ;;\n\t    esac\n\t    ;;\n\t  *)\n\t    ;;\n\tesac\n\t;;\n      interix*)\n\t# This is c89, which is MS Visual C++ (no shared libs)\n\t# Anyone wants to do a port?\n\t;;\n      irix5* | irix6* | nonstopux*)\n\tcase $cc_basename in\n\t  CC*)\n\t    lt_prog_compiler_wl_CXX='-Wl,'\n\t    lt_prog_compiler_static_CXX='-non_shared'\n\t    # CC pic flag -KPIC is the default.\n\t    ;;\n\t  *)\n\t    ;;\n\tesac\n\t;;\n      linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)\n\tcase $cc_basename in\n\t  KCC*)\n\t    # KAI C++ Compiler\n\t    lt_prog_compiler_wl_CXX='--backend -Wl,'\n\t    lt_prog_compiler_pic_CXX='-fPIC'\n\t    ;;\n\t  ecpc* )\n\t    # old Intel C++ for x86_64 which still supported -KPIC.\n\t    lt_prog_compiler_wl_CXX='-Wl,'\n\t    lt_prog_compiler_pic_CXX='-KPIC'\n\t    lt_prog_compiler_static_CXX='-static'\n\t    ;;\n\t  icpc* )\n\t    # Intel C++, used to be incompatible with GCC.\n\t    # ICC 10 doesn't accept -KPIC any more.\n\t    lt_prog_compiler_wl_CXX='-Wl,'\n\t    lt_prog_compiler_pic_CXX='-fPIC'\n\t    lt_prog_compiler_static_CXX='-static'\n\t    ;;\n\t  pgCC* | pgcpp*)\n\t    # Portland Group C++ compiler\n\t    lt_prog_compiler_wl_CXX='-Wl,'\n\t    lt_prog_compiler_pic_CXX='-fpic'\n\t    lt_prog_compiler_static_CXX='-Bstatic'\n\t    ;;\n\t  cxx*)\n\t    # Compaq C++\n\t    # Make sure the PIC flag is empty.  It appears that all Alpha\n\t    # Linux and Compaq Tru64 Unix objects are PIC.\n\t    lt_prog_compiler_pic_CXX=\n\t    lt_prog_compiler_static_CXX='-non_shared'\n\t    ;;\n\t  xlc* | xlC* | bgxl[cC]* | mpixl[cC]*)\n\t    # IBM XL 8.0, 9.0 on PPC and BlueGene\n\t    lt_prog_compiler_wl_CXX='-Wl,'\n\t    lt_prog_compiler_pic_CXX='-qpic'\n\t    lt_prog_compiler_static_CXX='-qstaticlink'\n\t    ;;\n\t  *)\n\t    case `$CC -V 2>&1 | sed 5q` in\n\t    *Sun\\ C*)\n\t      # Sun C++ 5.9\n\t      lt_prog_compiler_pic_CXX='-KPIC'\n\t      lt_prog_compiler_static_CXX='-Bstatic'\n\t      lt_prog_compiler_wl_CXX='-Qoption ld '\n\t      ;;\n\t    esac\n\t    ;;\n\tesac\n\t;;\n      lynxos*)\n\t;;\n      m88k*)\n\t;;\n      mvs*)\n\tcase $cc_basename in\n\t  cxx*)\n\t    lt_prog_compiler_pic_CXX='-W c,exportall'\n\t    ;;\n\t  *)\n\t    ;;\n\tesac\n\t;;\n      netbsd* | netbsdelf*-gnu)\n\t;;\n      *qnx* | *nto*)\n        # QNX uses GNU C++, but need to define -shared option too, otherwise\n        # it will coredump.\n        lt_prog_compiler_pic_CXX='-fPIC -shared'\n        ;;\n      osf3* | osf4* | osf5*)\n\tcase $cc_basename in\n\t  KCC*)\n\t    lt_prog_compiler_wl_CXX='--backend -Wl,'\n\t    ;;\n\t  RCC*)\n\t    # Rational C++ 2.4.1\n\t    lt_prog_compiler_pic_CXX='-pic'\n\t    ;;\n\t  cxx*)\n\t    # Digital/Compaq C++\n\t    lt_prog_compiler_wl_CXX='-Wl,'\n\t    # Make sure the PIC flag is empty.  It appears that all Alpha\n\t    # Linux and Compaq Tru64 Unix objects are PIC.\n\t    lt_prog_compiler_pic_CXX=\n\t    lt_prog_compiler_static_CXX='-non_shared'\n\t    ;;\n\t  *)\n\t    ;;\n\tesac\n\t;;\n      psos*)\n\t;;\n      solaris*)\n\tcase $cc_basename in\n\t  CC* | sunCC*)\n\t    # Sun C++ 4.2, 5.x and Centerline C++\n\t    lt_prog_compiler_pic_CXX='-KPIC'\n\t    lt_prog_compiler_static_CXX='-Bstatic'\n\t    lt_prog_compiler_wl_CXX='-Qoption ld '\n\t    ;;\n\t  gcx*)\n\t    # Green Hills C++ Compiler\n\t    lt_prog_compiler_pic_CXX='-PIC'\n\t    ;;\n\t  *)\n\t    ;;\n\tesac\n\t;;\n      sunos4*)\n\tcase $cc_basename in\n\t  CC*)\n\t    # Sun C++ 4.x\n\t    lt_prog_compiler_pic_CXX='-pic'\n\t    lt_prog_compiler_static_CXX='-Bstatic'\n\t    ;;\n\t  lcc*)\n\t    # Lucid\n\t    lt_prog_compiler_pic_CXX='-pic'\n\t    ;;\n\t  *)\n\t    ;;\n\tesac\n\t;;\n      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)\n\tcase $cc_basename in\n\t  CC*)\n\t    lt_prog_compiler_wl_CXX='-Wl,'\n\t    lt_prog_compiler_pic_CXX='-KPIC'\n\t    lt_prog_compiler_static_CXX='-Bstatic'\n\t    ;;\n\tesac\n\t;;\n      tandem*)\n\tcase $cc_basename in\n\t  NCC*)\n\t    # NonStop-UX NCC 3.20\n\t    lt_prog_compiler_pic_CXX='-KPIC'\n\t    ;;\n\t  *)\n\t    ;;\n\tesac\n\t;;\n      vxworks*)\n\t;;\n      *)\n\tlt_prog_compiler_can_build_shared_CXX=no\n\t;;\n    esac\n  fi\n\ncase $host_os in\n  # For platforms which do not support PIC, -DPIC is meaningless:\n  *djgpp*)\n    lt_prog_compiler_pic_CXX=\n    ;;\n  *)\n    lt_prog_compiler_pic_CXX=\"$lt_prog_compiler_pic_CXX -DPIC\"\n    ;;\nesac\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC\" >&5\n$as_echo_n \"checking for $compiler option to produce PIC... \" >&6; }\nif ${lt_cv_prog_compiler_pic_CXX+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_prog_compiler_pic_CXX=$lt_prog_compiler_pic_CXX\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_CXX\" >&5\n$as_echo \"$lt_cv_prog_compiler_pic_CXX\" >&6; }\nlt_prog_compiler_pic_CXX=$lt_cv_prog_compiler_pic_CXX\n\n#\n# Check to make sure the PIC flag actually works.\n#\nif test -n \"$lt_prog_compiler_pic_CXX\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works\" >&5\n$as_echo_n \"checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... \" >&6; }\nif ${lt_cv_prog_compiler_pic_works_CXX+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_prog_compiler_pic_works_CXX=no\n   ac_outfile=conftest.$ac_objext\n   echo \"$lt_simple_compile_test_code\" > conftest.$ac_ext\n   lt_compiler_flag=\"$lt_prog_compiler_pic_CXX -DPIC\"\n   # Insert the option either (1) after the last *FLAGS variable, or\n   # (2) before a word containing \"conftest.\", or (3) at the end.\n   # Note that $ac_compile itself does not contain backslashes and begins\n   # with a dollar sign (not a hyphen), so the echo should work correctly.\n   # The option is referenced via a variable to avoid confusing sed.\n   lt_compile=`echo \"$ac_compile\" | $SED \\\n   -e 's:.*FLAGS}\\{0,1\\} :&$lt_compiler_flag :; t' \\\n   -e 's: [^ ]*conftest\\.: $lt_compiler_flag&:; t' \\\n   -e 's:$: $lt_compiler_flag:'`\n   (eval echo \"\\\"\\$as_me:$LINENO: $lt_compile\\\"\" >&5)\n   (eval \"$lt_compile\" 2>conftest.err)\n   ac_status=$?\n   cat conftest.err >&5\n   echo \"$as_me:$LINENO: \\$? = $ac_status\" >&5\n   if (exit $ac_status) && test -s \"$ac_outfile\"; then\n     # The compiler can only warn and ignore the option if not recognized\n     # So say no if there are warnings other than the usual output.\n     $ECHO \"$_lt_compiler_boilerplate\" | $SED '/^$/d' >conftest.exp\n     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2\n     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then\n       lt_cv_prog_compiler_pic_works_CXX=yes\n     fi\n   fi\n   $RM conftest*\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX\" >&5\n$as_echo \"$lt_cv_prog_compiler_pic_works_CXX\" >&6; }\n\nif test x\"$lt_cv_prog_compiler_pic_works_CXX\" = xyes; then\n    case $lt_prog_compiler_pic_CXX in\n     \"\" | \" \"*) ;;\n     *) lt_prog_compiler_pic_CXX=\" $lt_prog_compiler_pic_CXX\" ;;\n     esac\nelse\n    lt_prog_compiler_pic_CXX=\n     lt_prog_compiler_can_build_shared_CXX=no\nfi\n\nfi\n\n\n\n\n\n#\n# Check to make sure the static flag actually works.\n#\nwl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\\\"$lt_prog_compiler_static_CXX\\\"\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works\" >&5\n$as_echo_n \"checking if $compiler static flag $lt_tmp_static_flag works... \" >&6; }\nif ${lt_cv_prog_compiler_static_works_CXX+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_prog_compiler_static_works_CXX=no\n   save_LDFLAGS=\"$LDFLAGS\"\n   LDFLAGS=\"$LDFLAGS $lt_tmp_static_flag\"\n   echo \"$lt_simple_link_test_code\" > conftest.$ac_ext\n   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then\n     # The linker can only warn and ignore the option if not recognized\n     # So say no if there are warnings\n     if test -s conftest.err; then\n       # Append any errors to the config.log.\n       cat conftest.err 1>&5\n       $ECHO \"$_lt_linker_boilerplate\" | $SED '/^$/d' > conftest.exp\n       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2\n       if diff conftest.exp conftest.er2 >/dev/null; then\n         lt_cv_prog_compiler_static_works_CXX=yes\n       fi\n     else\n       lt_cv_prog_compiler_static_works_CXX=yes\n     fi\n   fi\n   $RM -r conftest*\n   LDFLAGS=\"$save_LDFLAGS\"\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX\" >&5\n$as_echo \"$lt_cv_prog_compiler_static_works_CXX\" >&6; }\n\nif test x\"$lt_cv_prog_compiler_static_works_CXX\" = xyes; then\n    :\nelse\n    lt_prog_compiler_static_CXX=\nfi\n\n\n\n\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext\" >&5\n$as_echo_n \"checking if $compiler supports -c -o file.$ac_objext... \" >&6; }\nif ${lt_cv_prog_compiler_c_o_CXX+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_prog_compiler_c_o_CXX=no\n   $RM -r conftest 2>/dev/null\n   mkdir conftest\n   cd conftest\n   mkdir out\n   echo \"$lt_simple_compile_test_code\" > conftest.$ac_ext\n\n   lt_compiler_flag=\"-o out/conftest2.$ac_objext\"\n   # Insert the option either (1) after the last *FLAGS variable, or\n   # (2) before a word containing \"conftest.\", or (3) at the end.\n   # Note that $ac_compile itself does not contain backslashes and begins\n   # with a dollar sign (not a hyphen), so the echo should work correctly.\n   lt_compile=`echo \"$ac_compile\" | $SED \\\n   -e 's:.*FLAGS}\\{0,1\\} :&$lt_compiler_flag :; t' \\\n   -e 's: [^ ]*conftest\\.: $lt_compiler_flag&:; t' \\\n   -e 's:$: $lt_compiler_flag:'`\n   (eval echo \"\\\"\\$as_me:$LINENO: $lt_compile\\\"\" >&5)\n   (eval \"$lt_compile\" 2>out/conftest.err)\n   ac_status=$?\n   cat out/conftest.err >&5\n   echo \"$as_me:$LINENO: \\$? = $ac_status\" >&5\n   if (exit $ac_status) && test -s out/conftest2.$ac_objext\n   then\n     # The compiler can only warn and ignore the option if not recognized\n     # So say no if there are warnings\n     $ECHO \"$_lt_compiler_boilerplate\" | $SED '/^$/d' > out/conftest.exp\n     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2\n     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then\n       lt_cv_prog_compiler_c_o_CXX=yes\n     fi\n   fi\n   chmod u+w . 2>&5\n   $RM conftest*\n   # SGI C++ compiler will create directory out/ii_files/ for\n   # template instantiation\n   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files\n   $RM out/* && rmdir out\n   cd ..\n   $RM -r conftest\n   $RM conftest*\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX\" >&5\n$as_echo \"$lt_cv_prog_compiler_c_o_CXX\" >&6; }\n\n\n\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext\" >&5\n$as_echo_n \"checking if $compiler supports -c -o file.$ac_objext... \" >&6; }\nif ${lt_cv_prog_compiler_c_o_CXX+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_prog_compiler_c_o_CXX=no\n   $RM -r conftest 2>/dev/null\n   mkdir conftest\n   cd conftest\n   mkdir out\n   echo \"$lt_simple_compile_test_code\" > conftest.$ac_ext\n\n   lt_compiler_flag=\"-o out/conftest2.$ac_objext\"\n   # Insert the option either (1) after the last *FLAGS variable, or\n   # (2) before a word containing \"conftest.\", or (3) at the end.\n   # Note that $ac_compile itself does not contain backslashes and begins\n   # with a dollar sign (not a hyphen), so the echo should work correctly.\n   lt_compile=`echo \"$ac_compile\" | $SED \\\n   -e 's:.*FLAGS}\\{0,1\\} :&$lt_compiler_flag :; t' \\\n   -e 's: [^ ]*conftest\\.: $lt_compiler_flag&:; t' \\\n   -e 's:$: $lt_compiler_flag:'`\n   (eval echo \"\\\"\\$as_me:$LINENO: $lt_compile\\\"\" >&5)\n   (eval \"$lt_compile\" 2>out/conftest.err)\n   ac_status=$?\n   cat out/conftest.err >&5\n   echo \"$as_me:$LINENO: \\$? = $ac_status\" >&5\n   if (exit $ac_status) && test -s out/conftest2.$ac_objext\n   then\n     # The compiler can only warn and ignore the option if not recognized\n     # So say no if there are warnings\n     $ECHO \"$_lt_compiler_boilerplate\" | $SED '/^$/d' > out/conftest.exp\n     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2\n     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then\n       lt_cv_prog_compiler_c_o_CXX=yes\n     fi\n   fi\n   chmod u+w . 2>&5\n   $RM conftest*\n   # SGI C++ compiler will create directory out/ii_files/ for\n   # template instantiation\n   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files\n   $RM out/* && rmdir out\n   cd ..\n   $RM -r conftest\n   $RM conftest*\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX\" >&5\n$as_echo \"$lt_cv_prog_compiler_c_o_CXX\" >&6; }\n\n\n\n\nhard_links=\"nottested\"\nif test \"$lt_cv_prog_compiler_c_o_CXX\" = no && test \"$need_locks\" != no; then\n  # do not overwrite the value of need_locks provided by the user\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links\" >&5\n$as_echo_n \"checking if we can lock with hard links... \" >&6; }\n  hard_links=yes\n  $RM conftest*\n  ln conftest.a conftest.b 2>/dev/null && hard_links=no\n  touch conftest.a\n  ln conftest.a conftest.b 2>&5 || hard_links=no\n  ln conftest.a conftest.b 2>/dev/null && hard_links=no\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $hard_links\" >&5\n$as_echo \"$hard_links\" >&6; }\n  if test \"$hard_links\" = no; then\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: \\`$CC' does not support \\`-c -o', so \\`make -j' may be unsafe\" >&5\n$as_echo \"$as_me: WARNING: \\`$CC' does not support \\`-c -o', so \\`make -j' may be unsafe\" >&2;}\n    need_locks=warn\n  fi\nelse\n  need_locks=no\nfi\n\n\n\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries\" >&5\n$as_echo_n \"checking whether the $compiler linker ($LD) supports shared libraries... \" >&6; }\n\n  export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\\''s/.* //'\\'' | sort | uniq > $export_symbols'\n  exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'\n  case $host_os in\n  aix[4-9]*)\n    # If we're using GNU nm, then we don't want the \"-C\" option.\n    # -C means demangle to AIX nm, but means don't demangle with GNU nm\n    # Also, AIX nm treats weak defined symbols like other global defined\n    # symbols, whereas GNU nm marks them as \"W\".\n    if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then\n      export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\\''{ if (((\\$ 2 == \"T\") || (\\$ 2 == \"D\") || (\\$ 2 == \"B\") || (\\$ 2 == \"W\")) && (substr(\\$ 3,1,1) != \".\")) { print \\$ 3 } }'\\'' | sort -u > $export_symbols'\n    else\n      export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\\''{ if (((\\$ 2 == \"T\") || (\\$ 2 == \"D\") || (\\$ 2 == \"B\")) && (substr(\\$ 3,1,1) != \".\")) { print \\$ 3 } }'\\'' | sort -u > $export_symbols'\n    fi\n    ;;\n  pw32*)\n    export_symbols_cmds_CXX=\"$ltdll_cmds\"\n    ;;\n  cygwin* | mingw* | cegcc*)\n    case $cc_basename in\n    cl*)\n      exclude_expsyms_CXX='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'\n      ;;\n    *)\n      export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\\''/^[BCDGRS][ ]/s/.*[ ]\\([^ ]*\\)/\\1 DATA/;s/^.*[ ]__nm__\\([^ ]*\\)[ ][^ ]*/\\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\\'' | sort | uniq > $export_symbols'\n      exclude_expsyms_CXX='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'\n      ;;\n    esac\n    ;;\n  linux* | k*bsd*-gnu | gnu*)\n    link_all_deplibs_CXX=no\n    ;;\n  *)\n    export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\\''s/.* //'\\'' | sort | uniq > $export_symbols'\n    ;;\n  esac\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX\" >&5\n$as_echo \"$ld_shlibs_CXX\" >&6; }\ntest \"$ld_shlibs_CXX\" = no && can_build_shared=no\n\nwith_gnu_ld_CXX=$with_gnu_ld\n\n\n\n\n\n\n#\n# Do we need to explicitly link libc?\n#\ncase \"x$archive_cmds_need_lc_CXX\" in\nx|xyes)\n  # Assume -lc should be added\n  archive_cmds_need_lc_CXX=yes\n\n  if test \"$enable_shared\" = yes && test \"$GCC\" = yes; then\n    case $archive_cmds_CXX in\n    *'~'*)\n      # FIXME: we may have to deal with multi-command sequences.\n      ;;\n    '$CC '*)\n      # Test whether the compiler implicitly links with -lc since on some\n      # systems, -lgcc has to come before -lc. If gcc already passes -lc\n      # to ld, don't add -lc before -lgcc.\n      { $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in\" >&5\n$as_echo_n \"checking whether -lc should be explicitly linked in... \" >&6; }\nif ${lt_cv_archive_cmds_need_lc_CXX+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  $RM conftest*\n\techo \"$lt_simple_compile_test_code\" > conftest.$ac_ext\n\n\tif { { eval echo \"\\\"\\$as_me\\\":${as_lineno-$LINENO}: \\\"$ac_compile\\\"\"; } >&5\n  (eval $ac_compile) 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; } 2>conftest.err; then\n\t  soname=conftest\n\t  lib=conftest\n\t  libobjs=conftest.$ac_objext\n\t  deplibs=\n\t  wl=$lt_prog_compiler_wl_CXX\n\t  pic_flag=$lt_prog_compiler_pic_CXX\n\t  compiler_flags=-v\n\t  linker_flags=-v\n\t  verstring=\n\t  output_objdir=.\n\t  libname=conftest\n\t  lt_save_allow_undefined_flag=$allow_undefined_flag_CXX\n\t  allow_undefined_flag_CXX=\n\t  if { { eval echo \"\\\"\\$as_me\\\":${as_lineno-$LINENO}: \\\"$archive_cmds_CXX 2\\>\\&1 \\| $GREP \\\" -lc \\\" \\>/dev/null 2\\>\\&1\\\"\"; } >&5\n  (eval $archive_cmds_CXX 2\\>\\&1 \\| $GREP \\\" -lc \\\" \\>/dev/null 2\\>\\&1) 2>&5\n  ac_status=$?\n  $as_echo \"$as_me:${as_lineno-$LINENO}: \\$? = $ac_status\" >&5\n  test $ac_status = 0; }\n\t  then\n\t    lt_cv_archive_cmds_need_lc_CXX=no\n\t  else\n\t    lt_cv_archive_cmds_need_lc_CXX=yes\n\t  fi\n\t  allow_undefined_flag_CXX=$lt_save_allow_undefined_flag\n\telse\n\t  cat conftest.err 1>&5\n\tfi\n\t$RM conftest*\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc_CXX\" >&5\n$as_echo \"$lt_cv_archive_cmds_need_lc_CXX\" >&6; }\n      archive_cmds_need_lc_CXX=$lt_cv_archive_cmds_need_lc_CXX\n      ;;\n    esac\n  fi\n  ;;\nesac\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics\" >&5\n$as_echo_n \"checking dynamic linker characteristics... \" >&6; }\n\nlibrary_names_spec=\nlibname_spec='lib$name'\nsoname_spec=\nshrext_cmds=\".so\"\npostinstall_cmds=\npostuninstall_cmds=\nfinish_cmds=\nfinish_eval=\nshlibpath_var=\nshlibpath_overrides_runpath=unknown\nversion_type=none\ndynamic_linker=\"$host_os ld.so\"\nsys_lib_dlsearch_path_spec=\"/lib /usr/lib\"\nneed_lib_prefix=unknown\nhardcode_into_libs=no\n\n# when you set need_version to no, make sure it does not cause -set_version\n# flags to be left without arguments\nneed_version=unknown\n\ncase $host_os in\naix3*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'\n  shlibpath_var=LIBPATH\n\n  # AIX 3 has no versioning support, so we append a major version to the name.\n  soname_spec='${libname}${release}${shared_ext}$major'\n  ;;\n\naix[4-9]*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_lib_prefix=no\n  need_version=no\n  hardcode_into_libs=yes\n  if test \"$host_cpu\" = ia64; then\n    # AIX 5 supports IA64\n    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'\n    shlibpath_var=LD_LIBRARY_PATH\n  else\n    # With GCC up to 2.95.x, collect2 would create an import file\n    # for dependence libraries.  The import file would start with\n    # the line `#! .'.  This would cause the generated library to\n    # depend on `.', always an invalid library.  This was fixed in\n    # development snapshots of GCC prior to 3.0.\n    case $host_os in\n      aix4 | aix4.[01] | aix4.[01].*)\n      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'\n\t   echo ' yes '\n\t   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then\n\t:\n      else\n\tcan_build_shared=no\n      fi\n      ;;\n    esac\n    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct\n    # soname into executable. Probably we can add versioning support to\n    # collect2, so additional links can be useful in future.\n    if test \"$aix_use_runtimelinking\" = yes; then\n      # If using run time linking (on AIX 4.2 or later) use lib<name>.so\n      # instead of lib<name>.a to let people know that these are not\n      # typical AIX shared libraries.\n      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n    else\n      # We preserve .a as extension for shared libraries through AIX4.2\n      # and later when we are not doing run time linking.\n      library_names_spec='${libname}${release}.a $libname.a'\n      soname_spec='${libname}${release}${shared_ext}$major'\n    fi\n    shlibpath_var=LIBPATH\n  fi\n  ;;\n\namigaos*)\n  case $host_cpu in\n  powerpc)\n    # Since July 2007 AmigaOS4 officially supports .so libraries.\n    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.\n    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n    ;;\n  m68k)\n    library_names_spec='$libname.ixlibrary $libname.a'\n    # Create ${libname}_ixlibrary.a entries in /sys/libs.\n    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all \"$lib\" | $SED '\\''s%^.*/\\([^/]*\\)\\.ixlibrary$%\\1%'\\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show \"cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a\"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'\n    ;;\n  esac\n  ;;\n\nbeos*)\n  library_names_spec='${libname}${shared_ext}'\n  dynamic_linker=\"$host_os ld.so\"\n  shlibpath_var=LIBRARY_PATH\n  ;;\n\nbsdi[45]*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  finish_cmds='PATH=\"\\$PATH:/sbin\" ldconfig $libdir'\n  shlibpath_var=LD_LIBRARY_PATH\n  sys_lib_search_path_spec=\"/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib\"\n  sys_lib_dlsearch_path_spec=\"/shlib /usr/lib /usr/local/lib\"\n  # the default ld.so.conf also contains /usr/contrib/lib and\n  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow\n  # libtool to hard-code these into programs\n  ;;\n\ncygwin* | mingw* | pw32* | cegcc*)\n  version_type=windows\n  shrext_cmds=\".dll\"\n  need_version=no\n  need_lib_prefix=no\n\n  case $GCC,$cc_basename in\n  yes,*)\n    # gcc\n    library_names_spec='$libname.dll.a'\n    # DLL is installed to $(libdir)/../bin by postinstall_cmds\n    postinstall_cmds='base_file=`basename \\${file}`~\n      dlpath=`$SHELL 2>&1 -c '\\''. $dir/'\\''\\${base_file}'\\''i; echo \\$dlname'\\''`~\n      dldir=$destdir/`dirname \\$dlpath`~\n      test -d \\$dldir || mkdir -p \\$dldir~\n      $install_prog $dir/$dlname \\$dldir/$dlname~\n      chmod a+x \\$dldir/$dlname~\n      if test -n '\\''$stripme'\\'' && test -n '\\''$striplib'\\''; then\n        eval '\\''$striplib \\$dldir/$dlname'\\'' || exit \\$?;\n      fi'\n    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\\''. $file; echo \\$dlname'\\''`~\n      dlpath=$dir/\\$dldll~\n       $RM \\$dlpath'\n    shlibpath_overrides_runpath=yes\n\n    case $host_os in\n    cygwin*)\n      # Cygwin DLLs use 'cyg' prefix rather than 'lib'\n      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'\n\n      ;;\n    mingw* | cegcc*)\n      # MinGW DLLs use traditional 'lib' prefix\n      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'\n      ;;\n    pw32*)\n      # pw32 DLLs use 'pw' prefix rather than 'lib'\n      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'\n      ;;\n    esac\n    dynamic_linker='Win32 ld.exe'\n    ;;\n\n  *,cl*)\n    # Native MSVC\n    libname_spec='$name'\n    soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'\n    library_names_spec='${libname}.dll.lib'\n\n    case $build_os in\n    mingw*)\n      sys_lib_search_path_spec=\n      lt_save_ifs=$IFS\n      IFS=';'\n      for lt_path in $LIB\n      do\n        IFS=$lt_save_ifs\n        # Let DOS variable expansion print the short 8.3 style file name.\n        lt_path=`cd \"$lt_path\" 2>/dev/null && cmd //C \"for %i in (\".\") do @echo %~si\"`\n        sys_lib_search_path_spec=\"$sys_lib_search_path_spec $lt_path\"\n      done\n      IFS=$lt_save_ifs\n      # Convert to MSYS style.\n      sys_lib_search_path_spec=`$ECHO \"$sys_lib_search_path_spec\" | sed -e 's|\\\\\\\\|/|g' -e 's| \\\\([a-zA-Z]\\\\):| /\\\\1|g' -e 's|^ ||'`\n      ;;\n    cygwin*)\n      # Convert to unix form, then to dos form, then back to unix form\n      # but this time dos style (no spaces!) so that the unix form looks\n      # like /cygdrive/c/PROGRA~1:/cygdr...\n      sys_lib_search_path_spec=`cygpath --path --unix \"$LIB\"`\n      sys_lib_search_path_spec=`cygpath --path --dos \"$sys_lib_search_path_spec\" 2>/dev/null`\n      sys_lib_search_path_spec=`cygpath --path --unix \"$sys_lib_search_path_spec\" | $SED -e \"s/$PATH_SEPARATOR/ /g\"`\n      ;;\n    *)\n      sys_lib_search_path_spec=\"$LIB\"\n      if $ECHO \"$sys_lib_search_path_spec\" | $GREP ';[c-zC-Z]:/' >/dev/null; then\n        # It is most probably a Windows format PATH.\n        sys_lib_search_path_spec=`$ECHO \"$sys_lib_search_path_spec\" | $SED -e 's/;/ /g'`\n      else\n        sys_lib_search_path_spec=`$ECHO \"$sys_lib_search_path_spec\" | $SED -e \"s/$PATH_SEPARATOR/ /g\"`\n      fi\n      # FIXME: find the short name or the path components, as spaces are\n      # common. (e.g. \"Program Files\" -> \"PROGRA~1\")\n      ;;\n    esac\n\n    # DLL is installed to $(libdir)/../bin by postinstall_cmds\n    postinstall_cmds='base_file=`basename \\${file}`~\n      dlpath=`$SHELL 2>&1 -c '\\''. $dir/'\\''\\${base_file}'\\''i; echo \\$dlname'\\''`~\n      dldir=$destdir/`dirname \\$dlpath`~\n      test -d \\$dldir || mkdir -p \\$dldir~\n      $install_prog $dir/$dlname \\$dldir/$dlname'\n    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\\''. $file; echo \\$dlname'\\''`~\n      dlpath=$dir/\\$dldll~\n       $RM \\$dlpath'\n    shlibpath_overrides_runpath=yes\n    dynamic_linker='Win32 link.exe'\n    ;;\n\n  *)\n    # Assume MSVC wrapper\n    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'\n    dynamic_linker='Win32 ld.exe'\n    ;;\n  esac\n  # FIXME: first we should search . and the directory the executable is in\n  shlibpath_var=PATH\n  ;;\n\ndarwin* | rhapsody*)\n  dynamic_linker=\"$host_os dyld\"\n  version_type=darwin\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'\n  soname_spec='${libname}${release}${major}$shared_ext'\n  shlibpath_overrides_runpath=yes\n  shlibpath_var=DYLD_LIBRARY_PATH\n  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'\n\n  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'\n  ;;\n\ndgux*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LD_LIBRARY_PATH\n  ;;\n\nfreebsd* | dragonfly*)\n  # DragonFly does not have aout.  When/if they implement a new\n  # versioning mechanism, adjust this.\n  if test -x /usr/bin/objformat; then\n    objformat=`/usr/bin/objformat`\n  else\n    case $host_os in\n    freebsd[23].*) objformat=aout ;;\n    *) objformat=elf ;;\n    esac\n  fi\n  version_type=freebsd-$objformat\n  case $version_type in\n    freebsd-elf*)\n      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'\n      need_version=no\n      need_lib_prefix=no\n      ;;\n    freebsd-*)\n      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'\n      need_version=yes\n      ;;\n  esac\n  shlibpath_var=LD_LIBRARY_PATH\n  case $host_os in\n  freebsd2.*)\n    shlibpath_overrides_runpath=yes\n    ;;\n  freebsd3.[01]* | freebsdelf3.[01]*)\n    shlibpath_overrides_runpath=yes\n    hardcode_into_libs=yes\n    ;;\n  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \\\n  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)\n    shlibpath_overrides_runpath=no\n    hardcode_into_libs=yes\n    ;;\n  *) # from 4.6 on, and DragonFly\n    shlibpath_overrides_runpath=yes\n    hardcode_into_libs=yes\n    ;;\n  esac\n  ;;\n\nhaiku*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_lib_prefix=no\n  need_version=no\n  dynamic_linker=\"$host_os runtime_loader\"\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LIBRARY_PATH\n  shlibpath_overrides_runpath=yes\n  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'\n  hardcode_into_libs=yes\n  ;;\n\nhpux9* | hpux10* | hpux11*)\n  # Give a soname corresponding to the major version so that dld.sl refuses to\n  # link against other versions.\n  version_type=sunos\n  need_lib_prefix=no\n  need_version=no\n  case $host_cpu in\n  ia64*)\n    shrext_cmds='.so'\n    hardcode_into_libs=yes\n    dynamic_linker=\"$host_os dld.so\"\n    shlibpath_var=LD_LIBRARY_PATH\n    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.\n    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n    soname_spec='${libname}${release}${shared_ext}$major'\n    if test \"X$HPUX_IA64_MODE\" = X32; then\n      sys_lib_search_path_spec=\"/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib\"\n    else\n      sys_lib_search_path_spec=\"/usr/lib/hpux64 /usr/local/lib/hpux64\"\n    fi\n    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec\n    ;;\n  hppa*64*)\n    shrext_cmds='.sl'\n    hardcode_into_libs=yes\n    dynamic_linker=\"$host_os dld.sl\"\n    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH\n    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.\n    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n    soname_spec='${libname}${release}${shared_ext}$major'\n    sys_lib_search_path_spec=\"/usr/lib/pa20_64 /usr/ccs/lib/pa20_64\"\n    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec\n    ;;\n  *)\n    shrext_cmds='.sl'\n    dynamic_linker=\"$host_os dld.sl\"\n    shlibpath_var=SHLIB_PATH\n    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH\n    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n    soname_spec='${libname}${release}${shared_ext}$major'\n    ;;\n  esac\n  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...\n  postinstall_cmds='chmod 555 $lib'\n  # or fails outright, so override atomically:\n  install_override_mode=555\n  ;;\n\ninterix[3-9]*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=no\n  hardcode_into_libs=yes\n  ;;\n\nirix5* | irix6* | nonstopux*)\n  case $host_os in\n    nonstopux*) version_type=nonstopux ;;\n    *)\n\tif test \"$lt_cv_prog_gnu_ld\" = yes; then\n\t\tversion_type=linux # correct to gnu/linux during the next big refactor\n\telse\n\t\tversion_type=irix\n\tfi ;;\n  esac\n  need_lib_prefix=no\n  need_version=no\n  soname_spec='${libname}${release}${shared_ext}$major'\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'\n  case $host_os in\n  irix5* | nonstopux*)\n    libsuff= shlibsuff=\n    ;;\n  *)\n    case $LD in # libtool.m4 will add one of these switches to LD\n    *-32|*\"-32 \"|*-melf32bsmip|*\"-melf32bsmip \")\n      libsuff= shlibsuff= libmagic=32-bit;;\n    *-n32|*\"-n32 \"|*-melf32bmipn32|*\"-melf32bmipn32 \")\n      libsuff=32 shlibsuff=N32 libmagic=N32;;\n    *-64|*\"-64 \"|*-melf64bmip|*\"-melf64bmip \")\n      libsuff=64 shlibsuff=64 libmagic=64-bit;;\n    *) libsuff= shlibsuff= libmagic=never-match;;\n    esac\n    ;;\n  esac\n  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH\n  shlibpath_overrides_runpath=no\n  sys_lib_search_path_spec=\"/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}\"\n  sys_lib_dlsearch_path_spec=\"/usr/lib${libsuff} /lib${libsuff}\"\n  hardcode_into_libs=yes\n  ;;\n\n# No shared lib support for Linux oldld, aout, or coff.\nlinux*oldld* | linux*aout* | linux*coff*)\n  dynamic_linker=no\n  ;;\n\n# This must be glibc/ELF.\nlinux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  finish_cmds='PATH=\"\\$PATH:/sbin\" ldconfig -n $libdir'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=no\n\n  # Some binutils ld are patched to set DT_RUNPATH\n  if ${lt_cv_shlibpath_overrides_runpath+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  lt_cv_shlibpath_overrides_runpath=no\n    save_LDFLAGS=$LDFLAGS\n    save_libdir=$libdir\n    eval \"libdir=/foo; wl=\\\"$lt_prog_compiler_wl_CXX\\\"; \\\n\t LDFLAGS=\\\"\\$LDFLAGS $hardcode_libdir_flag_spec_CXX\\\"\"\n    cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_cxx_try_link \"$LINENO\"; then :\n  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep \"RUNPATH.*$libdir\" >/dev/null; then :\n  lt_cv_shlibpath_overrides_runpath=yes\nfi\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\n    LDFLAGS=$save_LDFLAGS\n    libdir=$save_libdir\n\nfi\n\n  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath\n\n  # This implies no fast_install, which is unacceptable.\n  # Some rework will be needed to allow for fast_install\n  # before this can be enabled.\n  hardcode_into_libs=yes\n\n  # Append ld.so.conf contents to the search path\n  if test -f /etc/ld.so.conf; then\n    lt_ld_extra=`awk '/^include / { system(sprintf(\"cd /etc; cat %s 2>/dev/null\", \\$2)); skip = 1; } { if (!skip) print \\$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[\t ]*hwcap[\t ]/d;s/[:,\t]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/\"//g;/^$/d' | tr '\\n' ' '`\n    sys_lib_dlsearch_path_spec=\"/lib /usr/lib $lt_ld_extra\"\n  fi\n\n  # We used to test for /lib/ld.so.1 and disable shared libraries on\n  # powerpc, because MkLinux only supported shared libraries with the\n  # GNU dynamic linker.  Since this was broken with cross compilers,\n  # most powerpc-linux boxes support dynamic linking these days and\n  # people can always --disable-shared, the test was removed, and we\n  # assume the GNU/Linux dynamic linker is in use.\n  dynamic_linker='GNU/Linux ld.so'\n  ;;\n\nnetbsdelf*-gnu)\n  version_type=linux\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=no\n  hardcode_into_libs=yes\n  dynamic_linker='NetBSD ld.elf_so'\n  ;;\n\nnetbsd*)\n  version_type=sunos\n  need_lib_prefix=no\n  need_version=no\n  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then\n    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'\n    finish_cmds='PATH=\"\\$PATH:/sbin\" ldconfig -m $libdir'\n    dynamic_linker='NetBSD (a.out) ld.so'\n  else\n    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'\n    soname_spec='${libname}${release}${shared_ext}$major'\n    dynamic_linker='NetBSD ld.elf_so'\n  fi\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=yes\n  hardcode_into_libs=yes\n  ;;\n\nnewsos6)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=yes\n  ;;\n\n*nto* | *qnx*)\n  version_type=qnx\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=no\n  hardcode_into_libs=yes\n  dynamic_linker='ldqnx.so'\n  ;;\n\nopenbsd*)\n  version_type=sunos\n  sys_lib_dlsearch_path_spec=\"/usr/lib\"\n  need_lib_prefix=no\n  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.\n  case $host_os in\n    openbsd3.3 | openbsd3.3.*)\tneed_version=yes ;;\n    *)\t\t\t\tneed_version=no  ;;\n  esac\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'\n  finish_cmds='PATH=\"\\$PATH:/sbin\" ldconfig -m $libdir'\n  shlibpath_var=LD_LIBRARY_PATH\n  if test -z \"`echo __ELF__ | $CC -E - | $GREP __ELF__`\" || test \"$host_os-$host_cpu\" = \"openbsd2.8-powerpc\"; then\n    case $host_os in\n      openbsd2.[89] | openbsd2.[89].*)\n\tshlibpath_overrides_runpath=no\n\t;;\n      *)\n\tshlibpath_overrides_runpath=yes\n\t;;\n      esac\n  else\n    shlibpath_overrides_runpath=yes\n  fi\n  ;;\n\nos2*)\n  libname_spec='$name'\n  shrext_cmds=\".dll\"\n  need_lib_prefix=no\n  library_names_spec='$libname${shared_ext} $libname.a'\n  dynamic_linker='OS/2 ld.exe'\n  shlibpath_var=LIBPATH\n  ;;\n\nosf3* | osf4* | osf5*)\n  version_type=osf\n  need_lib_prefix=no\n  need_version=no\n  soname_spec='${libname}${release}${shared_ext}$major'\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  shlibpath_var=LD_LIBRARY_PATH\n  sys_lib_search_path_spec=\"/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib\"\n  sys_lib_dlsearch_path_spec=\"$sys_lib_search_path_spec\"\n  ;;\n\nrdos*)\n  dynamic_linker=no\n  ;;\n\nsolaris*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=yes\n  hardcode_into_libs=yes\n  # ldd complains unless libraries are executable\n  postinstall_cmds='chmod +x $lib'\n  ;;\n\nsunos4*)\n  version_type=sunos\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'\n  finish_cmds='PATH=\"\\$PATH:/usr/etc\" ldconfig $libdir'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=yes\n  if test \"$with_gnu_ld\" = yes; then\n    need_lib_prefix=no\n  fi\n  need_version=yes\n  ;;\n\nsysv4 | sysv4.3*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LD_LIBRARY_PATH\n  case $host_vendor in\n    sni)\n      shlibpath_overrides_runpath=no\n      need_lib_prefix=no\n      runpath_var=LD_RUN_PATH\n      ;;\n    siemens)\n      need_lib_prefix=no\n      ;;\n    motorola)\n      need_lib_prefix=no\n      need_version=no\n      shlibpath_overrides_runpath=no\n      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'\n      ;;\n  esac\n  ;;\n\nsysv4*MP*)\n  if test -d /usr/nec ;then\n    version_type=linux # correct to gnu/linux during the next big refactor\n    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'\n    soname_spec='$libname${shared_ext}.$major'\n    shlibpath_var=LD_LIBRARY_PATH\n  fi\n  ;;\n\nsysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)\n  version_type=freebsd-elf\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=yes\n  hardcode_into_libs=yes\n  if test \"$with_gnu_ld\" = yes; then\n    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'\n  else\n    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'\n    case $host_os in\n      sco3.2v5*)\n        sys_lib_search_path_spec=\"$sys_lib_search_path_spec /lib\"\n\t;;\n    esac\n  fi\n  sys_lib_dlsearch_path_spec='/usr/lib'\n  ;;\n\ntpf*)\n  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=no\n  hardcode_into_libs=yes\n  ;;\n\nuts4*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LD_LIBRARY_PATH\n  ;;\n\n*)\n  dynamic_linker=no\n  ;;\nesac\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $dynamic_linker\" >&5\n$as_echo \"$dynamic_linker\" >&6; }\ntest \"$dynamic_linker\" = no && can_build_shared=no\n\nvariables_saved_for_relink=\"PATH $shlibpath_var $runpath_var\"\nif test \"$GCC\" = yes; then\n  variables_saved_for_relink=\"$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH\"\nfi\n\nif test \"${lt_cv_sys_lib_search_path_spec+set}\" = set; then\n  sys_lib_search_path_spec=\"$lt_cv_sys_lib_search_path_spec\"\nfi\nif test \"${lt_cv_sys_lib_dlsearch_path_spec+set}\" = set; then\n  sys_lib_dlsearch_path_spec=\"$lt_cv_sys_lib_dlsearch_path_spec\"\nfi\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs\" >&5\n$as_echo_n \"checking how to hardcode library paths into programs... \" >&6; }\nhardcode_action_CXX=\nif test -n \"$hardcode_libdir_flag_spec_CXX\" ||\n   test -n \"$runpath_var_CXX\" ||\n   test \"X$hardcode_automatic_CXX\" = \"Xyes\" ; then\n\n  # We can hardcode non-existent directories.\n  if test \"$hardcode_direct_CXX\" != no &&\n     # If the only mechanism to avoid hardcoding is shlibpath_var, we\n     # have to relink, otherwise we might link with an installed library\n     # when we should be linking with a yet-to-be-installed one\n     ## test \"$_LT_TAGVAR(hardcode_shlibpath_var, CXX)\" != no &&\n     test \"$hardcode_minus_L_CXX\" != no; then\n    # Linking always hardcodes the temporary library directory.\n    hardcode_action_CXX=relink\n  else\n    # We can link without hardcoding, and we can hardcode nonexisting dirs.\n    hardcode_action_CXX=immediate\n  fi\nelse\n  # We cannot hardcode anything, or else we can only hardcode existing\n  # directories.\n  hardcode_action_CXX=unsupported\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX\" >&5\n$as_echo \"$hardcode_action_CXX\" >&6; }\n\nif test \"$hardcode_action_CXX\" = relink ||\n   test \"$inherit_rpath_CXX\" = yes; then\n  # Fast installation is not supported\n  enable_fast_install=no\nelif test \"$shlibpath_overrides_runpath\" = yes ||\n     test \"$enable_shared\" = no; then\n  # Fast installation is not necessary\n  enable_fast_install=needless\nfi\n\n\n\n\n\n\n\n  fi # test -n \"$compiler\"\n\n  CC=$lt_save_CC\n  CFLAGS=$lt_save_CFLAGS\n  LDCXX=$LD\n  LD=$lt_save_LD\n  GCC=$lt_save_GCC\n  with_gnu_ld=$lt_save_with_gnu_ld\n  lt_cv_path_LDCXX=$lt_cv_path_LD\n  lt_cv_path_LD=$lt_save_path_LD\n  lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld\n  lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld\nfi # test \"$_lt_caught_CXX_error\" != yes\n\nac_ext=cpp\nac_cpp='$CXXCPP $CPPFLAGS'\nac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_cxx_compiler_gnu\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n        ac_config_commands=\"$ac_config_commands libtool\"\n\n\n\n\n# Only expand once:\n\n\n\n# Checks for header files.\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for ANSI C header files\" >&5\n$as_echo_n \"checking for ANSI C header files... \" >&6; }\nif ${ac_cv_header_stdc+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <stdlib.h>\n#include <stdarg.h>\n#include <string.h>\n#include <float.h>\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_cxx_try_compile \"$LINENO\"; then :\n  ac_cv_header_stdc=yes\nelse\n  ac_cv_header_stdc=no\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\n\nif test $ac_cv_header_stdc = yes; then\n  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <string.h>\n\n_ACEOF\nif (eval \"$ac_cpp conftest.$ac_ext\") 2>&5 |\n  $EGREP \"memchr\" >/dev/null 2>&1; then :\n\nelse\n  ac_cv_header_stdc=no\nfi\nrm -f conftest*\n\nfi\n\nif test $ac_cv_header_stdc = yes; then\n  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <stdlib.h>\n\n_ACEOF\nif (eval \"$ac_cpp conftest.$ac_ext\") 2>&5 |\n  $EGREP \"free\" >/dev/null 2>&1; then :\n\nelse\n  ac_cv_header_stdc=no\nfi\nrm -f conftest*\n\nfi\n\nif test $ac_cv_header_stdc = yes; then\n  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.\n  if test \"$cross_compiling\" = yes; then :\n  :\nelse\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <ctype.h>\n#include <stdlib.h>\n#if ((' ' & 0x0FF) == 0x020)\n# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')\n# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))\n#else\n# define ISLOWER(c) \\\n\t\t   (('a' <= (c) && (c) <= 'i') \\\n\t\t     || ('j' <= (c) && (c) <= 'r') \\\n\t\t     || ('s' <= (c) && (c) <= 'z'))\n# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))\n#endif\n\n#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))\nint\nmain ()\n{\n  int i;\n  for (i = 0; i < 256; i++)\n    if (XOR (islower (i), ISLOWER (i))\n\t|| toupper (i) != TOUPPER (i))\n      return 2;\n  return 0;\n}\n_ACEOF\nif ac_fn_cxx_try_run \"$LINENO\"; then :\n\nelse\n  ac_cv_header_stdc=no\nfi\nrm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \\\n  conftest.$ac_objext conftest.beam conftest.$ac_ext\nfi\n\nfi\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc\" >&5\n$as_echo \"$ac_cv_header_stdc\" >&6; }\nif test $ac_cv_header_stdc = yes; then\n\n$as_echo \"#define STDC_HEADERS 1\" >>confdefs.h\n\nfi\n\nfor ac_header in fcntl.h inttypes.h limits.h stdlib.h unistd.h\ndo :\n  as_ac_Header=`$as_echo \"ac_cv_header_$ac_header\" | $as_tr_sh`\nac_fn_cxx_check_header_mongrel \"$LINENO\" \"$ac_header\" \"$as_ac_Header\" \"$ac_includes_default\"\nif eval test \\\"x\\$\"$as_ac_Header\"\\\" = x\"yes\"; then :\n  cat >>confdefs.h <<_ACEOF\n#define `$as_echo \"HAVE_$ac_header\" | $as_tr_cpp` 1\n_ACEOF\n\nfi\n\ndone\n\n\n# Checks for library functions.\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for working memcmp\" >&5\n$as_echo_n \"checking for working memcmp... \" >&6; }\nif ${ac_cv_func_memcmp_working+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test \"$cross_compiling\" = yes; then :\n  ac_cv_func_memcmp_working=no\nelse\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n$ac_includes_default\nint\nmain ()\n{\n\n  /* Some versions of memcmp are not 8-bit clean.  */\n  char c0 = '\\100', c1 = '\\200', c2 = '\\201';\n  if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)\n    return 1;\n\n  /* The Next x86 OpenStep bug shows up only when comparing 16 bytes\n     or more and with at least one buffer not starting on a 4-byte boundary.\n     William Lewis provided this test program.   */\n  {\n    char foo[21];\n    char bar[21];\n    int i;\n    for (i = 0; i < 4; i++)\n      {\n\tchar *a = foo + i;\n\tchar *b = bar + i;\n\tstrcpy (a, \"--------01111111\");\n\tstrcpy (b, \"--------10000000\");\n\tif (memcmp (a, b, 16) >= 0)\n\t  return 1;\n      }\n    return 0;\n  }\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_cxx_try_run \"$LINENO\"; then :\n  ac_cv_func_memcmp_working=yes\nelse\n  ac_cv_func_memcmp_working=no\nfi\nrm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \\\n  conftest.$ac_objext conftest.beam conftest.$ac_ext\nfi\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_memcmp_working\" >&5\n$as_echo \"$ac_cv_func_memcmp_working\" >&6; }\ntest $ac_cv_func_memcmp_working = no && case \" $LIBOBJS \" in\n  *\" memcmp.$ac_objext \"* ) ;;\n  *) LIBOBJS=\"$LIBOBJS memcmp.$ac_objext\"\n ;;\nesac\n\n\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for working strtod\" >&5\n$as_echo_n \"checking for working strtod... \" >&6; }\nif ${ac_cv_func_strtod+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test \"$cross_compiling\" = yes; then :\n  ac_cv_func_strtod=no\nelse\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\n$ac_includes_default\n#ifndef strtod\ndouble strtod ();\n#endif\nint\nmain()\n{\n  {\n    /* Some versions of Linux strtod mis-parse strings with leading '+'.  */\n    char *string = \" +69\";\n    char *term;\n    double value;\n    value = strtod (string, &term);\n    if (value != 69 || term != (string + 4))\n      return 1;\n  }\n\n  {\n    /* Under Solaris 2.4, strtod returns the wrong value for the\n       terminating character under some conditions.  */\n    char *string = \"NaN\";\n    char *term;\n    strtod (string, &term);\n    if (term != string && *(term - 1) == 0)\n      return 1;\n  }\n  return 0;\n}\n\n_ACEOF\nif ac_fn_cxx_try_run \"$LINENO\"; then :\n  ac_cv_func_strtod=yes\nelse\n  ac_cv_func_strtod=no\nfi\nrm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \\\n  conftest.$ac_objext conftest.beam conftest.$ac_ext\nfi\n\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_strtod\" >&5\n$as_echo \"$ac_cv_func_strtod\" >&6; }\nif test $ac_cv_func_strtod = no; then\n  case \" $LIBOBJS \" in\n  *\" strtod.$ac_objext \"* ) ;;\n  *) LIBOBJS=\"$LIBOBJS strtod.$ac_objext\"\n ;;\nesac\n\nac_fn_cxx_check_func \"$LINENO\" \"pow\" \"ac_cv_func_pow\"\nif test \"x$ac_cv_func_pow\" = xyes; then :\n\nfi\n\nif test $ac_cv_func_pow = no; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for pow in -lm\" >&5\n$as_echo_n \"checking for pow in -lm... \" >&6; }\nif ${ac_cv_lib_m_pow+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  ac_check_lib_save_LIBS=$LIBS\nLIBS=\"-lm  $LIBS\"\ncat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\n/* Override any GCC internal prototype to avoid an error.\n   Use char because int might match the return type of a GCC\n   builtin and then its argument prototype would still apply.  */\n#ifdef __cplusplus\nextern \"C\"\n#endif\nchar pow ();\nint\nmain ()\n{\nreturn pow ();\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_cxx_try_link \"$LINENO\"; then :\n  ac_cv_lib_m_pow=yes\nelse\n  ac_cv_lib_m_pow=no\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\nLIBS=$ac_check_lib_save_LIBS\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_pow\" >&5\n$as_echo \"$ac_cv_lib_m_pow\" >&6; }\nif test \"x$ac_cv_lib_m_pow\" = xyes; then :\n  POW_LIB=-lm\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: cannot find library containing definition of pow\" >&5\n$as_echo \"$as_me: WARNING: cannot find library containing definition of pow\" >&2;}\nfi\n\nfi\n\nfi\n\nfor ac_func in ftruncate memset mkdir strchr strerror strtol\ndo :\n  as_ac_var=`$as_echo \"ac_cv_func_$ac_func\" | $as_tr_sh`\nac_fn_cxx_check_func \"$LINENO\" \"$ac_func\" \"$as_ac_var\"\nif eval test \\\"x\\$\"$as_ac_var\"\\\" = x\"yes\"; then :\n  cat >>confdefs.h <<_ACEOF\n#define `$as_echo \"HAVE_$ac_func\" | $as_tr_cpp` 1\n_ACEOF\n\nfi\ndone\n\n\n# Check for zlib.\nHAVE_ZLIB=0\nif test \"$with_zlib\" != no; then :\n\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: checking zlib version\" >&5\n$as_echo_n \"checking zlib version... \" >&6; }\n\n  # First check the zlib header version.\n  cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\n        #include <zlib.h>\n        #if !defined(ZLIB_VERNUM) || (ZLIB_VERNUM < 0x1204)\n        # error zlib version too old\n        #endif\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_cxx_try_compile \"$LINENO\"; then :\n\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: result: ok (1.2.0.4 or later)\" >&5\n$as_echo \"ok (1.2.0.4 or later)\" >&6; }\n\n    # Also need to add -lz to the linker flags and make sure this succeeds.\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion\" >&5\n$as_echo_n \"checking for library containing zlibVersion... \" >&6; }\nif ${ac_cv_search_zlibVersion+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  ac_func_search_save_LIBS=$LIBS\ncat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\n/* Override any GCC internal prototype to avoid an error.\n   Use char because int might match the return type of a GCC\n   builtin and then its argument prototype would still apply.  */\n#ifdef __cplusplus\nextern \"C\"\n#endif\nchar zlibVersion ();\nint\nmain ()\n{\nreturn zlibVersion ();\n  ;\n  return 0;\n}\n_ACEOF\nfor ac_lib in '' z; do\n  if test -z \"$ac_lib\"; then\n    ac_res=\"none required\"\n  else\n    ac_res=-l$ac_lib\n    LIBS=\"-l$ac_lib  $ac_func_search_save_LIBS\"\n  fi\n  if ac_fn_cxx_try_link \"$LINENO\"; then :\n  ac_cv_search_zlibVersion=$ac_res\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext\n  if ${ac_cv_search_zlibVersion+:} false; then :\n  break\nfi\ndone\nif ${ac_cv_search_zlibVersion+:} false; then :\n\nelse\n  ac_cv_search_zlibVersion=no\nfi\nrm conftest.$ac_ext\nLIBS=$ac_func_search_save_LIBS\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion\" >&5\n$as_echo \"$ac_cv_search_zlibVersion\" >&6; }\nac_res=$ac_cv_search_zlibVersion\nif test \"$ac_res\" != no; then :\n  test \"$ac_res\" = \"none required\" || LIBS=\"$ac_res $LIBS\"\n\n\n$as_echo \"#define HAVE_ZLIB 1\" >>confdefs.h\n\n      HAVE_ZLIB=1\n\nelse\n\n      if test \"$with_zlib\" != check; then :\n\n        { { $as_echo \"$as_me:${as_lineno-$LINENO}: error: in \\`$ac_pwd':\" >&5\n$as_echo \"$as_me: error: in \\`$ac_pwd':\" >&2;}\nas_fn_error $? \"--with-zlib was given, but no working zlib library was found\nSee \\`config.log' for more details\" \"$LINENO\" 5; }\n\nfi\n\nfi\n\n\nelse\n\n    if test \"$with_zlib\" = check; then :\n\n      { $as_echo \"$as_me:${as_lineno-$LINENO}: result: headers missing or too old (requires 1.2.0.4)\" >&5\n$as_echo \"headers missing or too old (requires 1.2.0.4)\" >&6; }\n\nelse\n\n      { { $as_echo \"$as_me:${as_lineno-$LINENO}: error: in \\`$ac_pwd':\" >&5\n$as_echo \"$as_me: error: in \\`$ac_pwd':\" >&2;}\nas_fn_error $? \"--with-zlib was given, but zlib headers were not present or were too old (requires 1.2.0.4)\nSee \\`config.log' for more details\" \"$LINENO\" 5; }\n\nfi\n\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\n\nfi\n if test $HAVE_ZLIB = 1; then\n  HAVE_ZLIB_TRUE=\n  HAVE_ZLIB_FALSE='#'\nelse\n  HAVE_ZLIB_TRUE='#'\n  HAVE_ZLIB_FALSE=\nfi\n\n\nif test \"$with_protoc\" != \"no\"; then :\n\n  PROTOC=$with_protoc\n  if test \"$with_protoc\" = \"yes\"; then :\n\n    # No argument given.  Use system protoc.\n    PROTOC=protoc\n\nfi\n  if echo \"$PROTOC\" | grep -q '^[^/].*/'; then :\n\n    # Does not start with a slash, but contains a slash.  So, it's a relative\n    # path (as opposed to an absolute path or an executable in $PATH).\n    # Since it will actually be executed from the src directory, prefix with\n    # the current directory.  We also insert $ac_top_build_prefix in case this\n    # is a nested package and --with-protoc was actually given on the outer\n    # package's configure script.\n    PROTOC=`pwd`/${ac_top_build_prefix}$PROTOC\n\nfi\n\n\nfi\n if test \"$with_protoc\" != \"no\"; then\n  USE_EXTERNAL_PROTOC_TRUE=\n  USE_EXTERNAL_PROTOC_FALSE='#'\nelse\n  USE_EXTERNAL_PROTOC_TRUE='#'\n  USE_EXTERNAL_PROTOC_FALSE=\nfi\n\n\n\n\n\nac_ext=c\nac_cpp='$CPP $CPPFLAGS'\nac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_c_compiler_gnu\n\nacx_pthread_ok=no\n\n# We used to check for pthread.h first, but this fails if pthread.h\n# requires special compiler flags (e.g. on True64 or Sequent).\n# It gets checked for in the link test anyway.\n\n# First of all, check if the user has set any of the PTHREAD_LIBS,\n# etcetera environment variables, and if threads linking works using\n# them:\nif test x\"$PTHREAD_LIBS$PTHREAD_CFLAGS\" != x; then\n        save_CFLAGS=\"$CFLAGS\"\n        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n        save_LIBS=\"$LIBS\"\n        LIBS=\"$PTHREAD_LIBS $LIBS\"\n        { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS\" >&5\n$as_echo_n \"checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS... \" >&6; }\n        cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\n/* Override any GCC internal prototype to avoid an error.\n   Use char because int might match the return type of a GCC\n   builtin and then its argument prototype would still apply.  */\n#ifdef __cplusplus\nextern \"C\"\n#endif\nchar pthread_join ();\nint\nmain ()\n{\nreturn pthread_join ();\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_link \"$LINENO\"; then :\n  acx_pthread_ok=yes\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\n        { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $acx_pthread_ok\" >&5\n$as_echo \"$acx_pthread_ok\" >&6; }\n        if test x\"$acx_pthread_ok\" = xno; then\n                PTHREAD_LIBS=\"\"\n                PTHREAD_CFLAGS=\"\"\n        fi\n        LIBS=\"$save_LIBS\"\n        CFLAGS=\"$save_CFLAGS\"\nfi\n\n# We must check for the threads library under a number of different\n# names; the ordering is very important because some systems\n# (e.g. DEC) have both -lpthread and -lpthreads, where one of the\n# libraries is broken (non-POSIX).\n\n# Create a list of thread flags to try.  Items starting with a \"-\" are\n# C compiler flags, and other items are library names, except for \"none\"\n# which indicates that we try without any flags at all, and \"pthread-config\"\n# which is a program returning the flags for the Pth emulation library.\n\nacx_pthread_flags=\"pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config\"\n\n# The ordering *is* (sometimes) important.  Some notes on the\n# individual items follow:\n\n# pthreads: AIX (must check this before -lpthread)\n# none: in case threads are in libc; should be tried before -Kthread and\n#       other compiler flags to prevent continual compiler warnings\n# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)\n# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)\n# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)\n# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)\n# -pthreads: Solaris/gcc\n# -mthreads: Mingw32/gcc, Lynx/gcc\n# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it\n#      doesn't hurt to check since this sometimes defines pthreads too;\n#      also defines -D_REENTRANT)\n#      ... -mt is also the pthreads flag for HP/aCC\n# pthread: Linux, etcetera\n# --thread-safe: KAI C++\n# pthread-config: use pthread-config program (for GNU Pth library)\n\ncase \"${host_cpu}-${host_os}\" in\n        *solaris*)\n\n        # On Solaris (at least, for some versions), libc contains stubbed\n        # (non-functional) versions of the pthreads routines, so link-based\n        # tests will erroneously succeed.  (We need to link with -pthreads/-mt/\n        # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather\n        # a function called by this macro, so we could check for that, but\n        # who knows whether they'll stub that too in a future libc.)  So,\n        # we'll just look for -pthreads and -lpthread first:\n\n        acx_pthread_flags=\"-pthreads pthread -mt -pthread $acx_pthread_flags\"\n        ;;\nesac\n\nif test x\"$acx_pthread_ok\" = xno; then\nfor flag in $acx_pthread_flags; do\n\n        case $flag in\n                none)\n                { $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether pthreads work without any flags\" >&5\n$as_echo_n \"checking whether pthreads work without any flags... \" >&6; }\n                ;;\n\n                -*)\n                { $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether pthreads work with $flag\" >&5\n$as_echo_n \"checking whether pthreads work with $flag... \" >&6; }\n                PTHREAD_CFLAGS=\"$flag\"\n                ;;\n\n\t\tpthread-config)\n\t\t# Extract the first word of \"pthread-config\", so it can be a program name with args.\nset dummy pthread-config; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_acx_pthread_config+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$acx_pthread_config\"; then\n  ac_cv_prog_acx_pthread_config=\"$acx_pthread_config\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_acx_pthread_config=\"yes\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\n  test -z \"$ac_cv_prog_acx_pthread_config\" && ac_cv_prog_acx_pthread_config=\"no\"\nfi\nfi\nacx_pthread_config=$ac_cv_prog_acx_pthread_config\nif test -n \"$acx_pthread_config\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $acx_pthread_config\" >&5\n$as_echo \"$acx_pthread_config\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\n\t\tif test x\"$acx_pthread_config\" = xno; then continue; fi\n\t\tPTHREAD_CFLAGS=\"`pthread-config --cflags`\"\n\t\tPTHREAD_LIBS=\"`pthread-config --ldflags` `pthread-config --libs`\"\n\t\t;;\n\n                *)\n                { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for the pthreads library -l$flag\" >&5\n$as_echo_n \"checking for the pthreads library -l$flag... \" >&6; }\n                PTHREAD_LIBS=\"-l$flag\"\n                ;;\n        esac\n\n        save_LIBS=\"$LIBS\"\n        save_CFLAGS=\"$CFLAGS\"\n        LIBS=\"$PTHREAD_LIBS $LIBS\"\n        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n\n        # Check for various functions.  We must include pthread.h,\n        # since some functions may be macros.  (On the Sequent, we\n        # need a special flag -Kthread to make this header compile.)\n        # We check for pthread_join because it is in -lpthread on IRIX\n        # while pthread_create is in libc.  We check for pthread_attr_init\n        # due to DEC craziness with -lpthreads.  We check for\n        # pthread_cleanup_push because it is one of the few pthread\n        # functions on Solaris that doesn't have a non-functional libc stub.\n        # We try pthread_create on general principles.\n        cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <pthread.h>\nint\nmain ()\n{\npthread_t th; pthread_join(th, 0);\n                     pthread_attr_init(0); pthread_cleanup_push(0, 0);\n                     pthread_create(0,0,0,0); pthread_cleanup_pop(0);\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_link \"$LINENO\"; then :\n  acx_pthread_ok=yes\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\n\n        LIBS=\"$save_LIBS\"\n        CFLAGS=\"$save_CFLAGS\"\n\n        { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $acx_pthread_ok\" >&5\n$as_echo \"$acx_pthread_ok\" >&6; }\n        if test \"x$acx_pthread_ok\" = xyes; then\n                break;\n        fi\n\n        PTHREAD_LIBS=\"\"\n        PTHREAD_CFLAGS=\"\"\ndone\nfi\n\n# Various other checks:\nif test \"x$acx_pthread_ok\" = xyes; then\n        save_LIBS=\"$LIBS\"\n        LIBS=\"$PTHREAD_LIBS $LIBS\"\n        save_CFLAGS=\"$CFLAGS\"\n        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n\n        # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.\n\t{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for joinable pthread attribute\" >&5\n$as_echo_n \"checking for joinable pthread attribute... \" >&6; }\n\tattr_name=unknown\n\tfor attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do\n\t    cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <pthread.h>\nint\nmain ()\n{\nint attr=$attr; return attr;\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_link \"$LINENO\"; then :\n  attr_name=$attr; break\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\n\tdone\n        { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $attr_name\" >&5\n$as_echo \"$attr_name\" >&6; }\n        if test \"$attr_name\" != PTHREAD_CREATE_JOINABLE; then\n\ncat >>confdefs.h <<_ACEOF\n#define PTHREAD_CREATE_JOINABLE $attr_name\n_ACEOF\n\n        fi\n\n        { $as_echo \"$as_me:${as_lineno-$LINENO}: checking if more special flags are required for pthreads\" >&5\n$as_echo_n \"checking if more special flags are required for pthreads... \" >&6; }\n        flag=no\n        case \"${host_cpu}-${host_os}\" in\n            *-aix* | *-freebsd* | *-darwin*) flag=\"-D_THREAD_SAFE\";;\n            *solaris* | *-osf* | *-hpux*) flag=\"-D_REENTRANT\";;\n        esac\n        { $as_echo \"$as_me:${as_lineno-$LINENO}: result: ${flag}\" >&5\n$as_echo \"${flag}\" >&6; }\n        if test \"x$flag\" != xno; then\n            PTHREAD_CFLAGS=\"$flag $PTHREAD_CFLAGS\"\n        fi\n\n        LIBS=\"$save_LIBS\"\n        CFLAGS=\"$save_CFLAGS\"\n        # More AIX lossage: must compile with xlc_r or cc_r\n\tif test x\"$GCC\" != xyes; then\n          for ac_prog in xlc_r cc_r\ndo\n  # Extract the first word of \"$ac_prog\", so it can be a program name with args.\nset dummy $ac_prog; ac_word=$2\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking for $ac_word\" >&5\n$as_echo_n \"checking for $ac_word... \" >&6; }\nif ${ac_cv_prog_PTHREAD_CC+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  if test -n \"$PTHREAD_CC\"; then\n  ac_cv_prog_PTHREAD_CC=\"$PTHREAD_CC\" # Let the user override the test.\nelse\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    for ac_exec_ext in '' $ac_executable_extensions; do\n  if as_fn_executable_p \"$as_dir/$ac_word$ac_exec_ext\"; then\n    ac_cv_prog_PTHREAD_CC=\"$ac_prog\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext\" >&5\n    break 2\n  fi\ndone\n  done\nIFS=$as_save_IFS\n\nfi\nfi\nPTHREAD_CC=$ac_cv_prog_PTHREAD_CC\nif test -n \"$PTHREAD_CC\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $PTHREAD_CC\" >&5\n$as_echo \"$PTHREAD_CC\" >&6; }\nelse\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\nfi\n\n\n  test -n \"$PTHREAD_CC\" && break\ndone\ntest -n \"$PTHREAD_CC\" || PTHREAD_CC=\"${CC}\"\n\n        else\n          PTHREAD_CC=$CC\n\tfi\n\n\t# The next part tries to detect GCC inconsistency with -shared on some\n\t# architectures and systems. The problem is that in certain\n\t# configurations, when -shared is specified, GCC \"forgets\" to\n\t# internally use various flags which are still necessary.\n\n\t#\n\t# Prepare the flags\n\t#\n\tsave_CFLAGS=\"$CFLAGS\"\n\tsave_LIBS=\"$LIBS\"\n\tsave_CC=\"$CC\"\n\n\t# Try with the flags determined by the earlier checks.\n\t#\n\t# -Wl,-z,defs forces link-time symbol resolution, so that the\n\t# linking checks with -shared actually have any value\n\t#\n\t# FIXME: -fPIC is required for -shared on many architectures,\n\t# so we specify it here, but the right way would probably be to\n\t# properly detect whether it is actually required.\n\tCFLAGS=\"-shared -fPIC -Wl,-z,defs $CFLAGS $PTHREAD_CFLAGS\"\n\tLIBS=\"$PTHREAD_LIBS $LIBS\"\n\tCC=\"$PTHREAD_CC\"\n\n\t# In order not to create several levels of indentation, we test\n\t# the value of \"$done\" until we find the cure or run out of ideas.\n\tdone=\"no\"\n\n\t# First, make sure the CFLAGS we added are actually accepted by our\n\t# compiler.  If not (and OS X's ld, for instance, does not accept -z),\n\t# then we can't do this test.\n\tif test x\"$done\" = xno; then\n\t   { $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether to check for GCC pthread/shared inconsistencies\" >&5\n$as_echo_n \"checking whether to check for GCC pthread/shared inconsistencies... \" >&6; }\n\t   cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\nint\nmain ()\n{\n\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_link \"$LINENO\"; then :\n\nelse\n  done=yes\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\n\n\t   if test \"x$done\" = xyes ; then\n\t      { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\n\t   else\n\t      { $as_echo \"$as_me:${as_lineno-$LINENO}: result: yes\" >&5\n$as_echo \"yes\" >&6; }\n\t   fi\n\tfi\n\n\tif test x\"$done\" = xno; then\n\t   { $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether -pthread is sufficient with -shared\" >&5\n$as_echo_n \"checking whether -pthread is sufficient with -shared... \" >&6; }\n\t   cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <pthread.h>\nint\nmain ()\n{\npthread_t th; pthread_join(th, 0);\n\t      pthread_attr_init(0); pthread_cleanup_push(0, 0);\n\t      pthread_create(0,0,0,0); pthread_cleanup_pop(0);\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_link \"$LINENO\"; then :\n  done=yes\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\n\n\t   if test \"x$done\" = xyes; then\n\t      { $as_echo \"$as_me:${as_lineno-$LINENO}: result: yes\" >&5\n$as_echo \"yes\" >&6; }\n\t   else\n\t      { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\n\t   fi\n\tfi\n\n\t#\n\t# Linux gcc on some architectures such as mips/mipsel forgets\n\t# about -lpthread\n\t#\n\tif test x\"$done\" = xno; then\n\t   { $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether -lpthread fixes that\" >&5\n$as_echo_n \"checking whether -lpthread fixes that... \" >&6; }\n\t   LIBS=\"-lpthread $PTHREAD_LIBS $save_LIBS\"\n\t   cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <pthread.h>\nint\nmain ()\n{\npthread_t th; pthread_join(th, 0);\n\t      pthread_attr_init(0); pthread_cleanup_push(0, 0);\n\t      pthread_create(0,0,0,0); pthread_cleanup_pop(0);\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_link \"$LINENO\"; then :\n  done=yes\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\n\n\t   if test \"x$done\" = xyes; then\n\t      { $as_echo \"$as_me:${as_lineno-$LINENO}: result: yes\" >&5\n$as_echo \"yes\" >&6; }\n\t      PTHREAD_LIBS=\"-lpthread $PTHREAD_LIBS\"\n\t   else\n\t      { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\n\t   fi\n\tfi\n\t#\n\t# FreeBSD 4.10 gcc forgets to use -lc_r instead of -lc\n\t#\n\tif test x\"$done\" = xno; then\n\t   { $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether -lc_r fixes that\" >&5\n$as_echo_n \"checking whether -lc_r fixes that... \" >&6; }\n\t   LIBS=\"-lc_r $PTHREAD_LIBS $save_LIBS\"\n\t   cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <pthread.h>\nint\nmain ()\n{\npthread_t th; pthread_join(th, 0);\n\t        pthread_attr_init(0); pthread_cleanup_push(0, 0);\n\t        pthread_create(0,0,0,0); pthread_cleanup_pop(0);\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_link \"$LINENO\"; then :\n  done=yes\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\n\n\t   if test \"x$done\" = xyes; then\n\t      { $as_echo \"$as_me:${as_lineno-$LINENO}: result: yes\" >&5\n$as_echo \"yes\" >&6; }\n\t      PTHREAD_LIBS=\"-lc_r $PTHREAD_LIBS\"\n\t   else\n\t      { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\n\t   fi\n\tfi\n\tif test x\"$done\" = xno; then\n\t   # OK, we have run out of ideas\n\t   { $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: Impossible to determine how to use pthreads with shared libraries\" >&5\n$as_echo \"$as_me: WARNING: Impossible to determine how to use pthreads with shared libraries\" >&2;}\n\n\t   # so it's not safe to assume that we may use pthreads\n\t   acx_pthread_ok=no\n\tfi\n\n\t{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether what we have so far is sufficient with -nostdlib\" >&5\n$as_echo_n \"checking whether what we have so far is sufficient with -nostdlib... \" >&6; }\n\tCFLAGS=\"-nostdlib $CFLAGS\"\n\t# we need c with nostdlib\n\tLIBS=\"$LIBS -lc\"\n\tcat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <pthread.h>\nint\nmain ()\n{\npthread_t th; pthread_join(th, 0);\n\t       pthread_attr_init(0); pthread_cleanup_push(0, 0);\n\t       pthread_create(0,0,0,0); pthread_cleanup_pop(0);\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_link \"$LINENO\"; then :\n  done=yes\nelse\n  done=no\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\n\n\tif test \"x$done\" = xyes; then\n\t   { $as_echo \"$as_me:${as_lineno-$LINENO}: result: yes\" >&5\n$as_echo \"yes\" >&6; }\n\telse\n\t   { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\n\tfi\n\n\tif test x\"$done\" = xno; then\n\t   { $as_echo \"$as_me:${as_lineno-$LINENO}: checking whether -lpthread saves the day\" >&5\n$as_echo_n \"checking whether -lpthread saves the day... \" >&6; }\n\t   LIBS=\"-lpthread $LIBS\"\n\t   cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <pthread.h>\nint\nmain ()\n{\npthread_t th; pthread_join(th, 0);\n\t       pthread_attr_init(0); pthread_cleanup_push(0, 0);\n\t       pthread_create(0,0,0,0); pthread_cleanup_pop(0);\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_c_try_link \"$LINENO\"; then :\n  done=yes\nelse\n  done=no\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext conftest.$ac_ext\n\n\t   if test \"x$done\" = xyes; then\n\t      { $as_echo \"$as_me:${as_lineno-$LINENO}: result: yes\" >&5\n$as_echo \"yes\" >&6; }\n\t      PTHREAD_LIBS=\"$PTHREAD_LIBS -lpthread\"\n\t   else\n\t      { $as_echo \"$as_me:${as_lineno-$LINENO}: result: no\" >&5\n$as_echo \"no\" >&6; }\n\t      { $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: Impossible to determine how to use pthreads with shared libraries and -nostdlib\" >&5\n$as_echo \"$as_me: WARNING: Impossible to determine how to use pthreads with shared libraries and -nostdlib\" >&2;}\n\t   fi\n\tfi\n\n\tCFLAGS=\"$save_CFLAGS\"\n\tLIBS=\"$save_LIBS\"\n\tCC=\"$save_CC\"\nelse\n        PTHREAD_CC=\"$CC\"\nfi\n\n\n\n\n\n# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:\nif test x\"$acx_pthread_ok\" = xyes; then\n\n$as_echo \"#define HAVE_PTHREAD 1\" >>confdefs.h\n\n        :\nelse\n        acx_pthread_ok=no\n\nfi\nac_ext=cpp\nac_cpp='$CXXCPP $CPPFLAGS'\nac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_cxx_compiler_gnu\n\n\n if test \"x$acx_pthread_ok\" = \"xyes\"; then\n  HAVE_PTHREAD_TRUE=\n  HAVE_PTHREAD_FALSE='#'\nelse\n  HAVE_PTHREAD_TRUE='#'\n  HAVE_PTHREAD_FALSE=\nfi\n\n\n# We still keep this for improving pbconfig.h for unsupported platforms.\n\n   { $as_echo \"$as_me:${as_lineno-$LINENO}: checking the location of hash_map\" >&5\n$as_echo_n \"checking the location of hash_map... \" >&6; }\n\n   ac_ext=cpp\nac_cpp='$CXXCPP $CPPFLAGS'\nac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'\nac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'\nac_compiler_gnu=$ac_cv_cxx_compiler_gnu\n\n   ac_cv_cxx_hash_map=\"\"\n   # First try unordered_map, but not on gcc's before 4.2 -- I've\n   # seen unexplainable unordered_map bugs with -O2 on older gcc's.\n   cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2))\n                   # error GCC too old for unordered_map\n                   #endif\n\nint\nmain ()\n{\n/* no program body necessary */\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_cxx_try_compile \"$LINENO\"; then :\n  stl_hash_old_gcc=no\nelse\n  stl_hash_old_gcc=yes\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\n   for location in unordered_map tr1/unordered_map; do\n     for namespace in std std::tr1; do\n       if test -z \"$ac_cv_cxx_hash_map\" -a \"$stl_hash_old_gcc\" != yes; then\n         # Some older gcc's have a buggy tr1, so test a bit of code.\n         cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <$location>\nint\nmain ()\n{\nconst ${namespace}::unordered_map<int, int> t;\n                         return t.find(5) == t.end();\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_cxx_try_compile \"$LINENO\"; then :\n  ac_cv_cxx_hash_map=\"<$location>\";\n                         ac_cv_cxx_hash_namespace=\"$namespace\";\n                         ac_cv_cxx_hash_map_class=\"unordered_map\";\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\n       fi\n     done\n   done\n   # Now try hash_map\n   for location in ext/hash_map hash_map; do\n     for namespace in __gnu_cxx \"\" std stdext; do\n       if test -z \"$ac_cv_cxx_hash_map\"; then\n         cat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n#include <$location>\nint\nmain ()\n{\n${namespace}::hash_map<int, int> t\n  ;\n  return 0;\n}\n_ACEOF\nif ac_fn_cxx_try_compile \"$LINENO\"; then :\n  ac_cv_cxx_hash_map=\"<$location>\";\n                         ac_cv_cxx_hash_namespace=\"$namespace\";\n                         ac_cv_cxx_hash_map_class=\"hash_map\";\nfi\nrm -f core conftest.err conftest.$ac_objext conftest.$ac_ext\n       fi\n     done\n   done\n   ac_cv_cxx_hash_set=`echo \"$ac_cv_cxx_hash_map\" | sed s/map/set/`;\n   ac_cv_cxx_hash_set_class=`echo \"$ac_cv_cxx_hash_map_class\" | sed s/map/set/`;\n   if test -n \"$ac_cv_cxx_hash_map\"; then\n\n$as_echo \"#define HAVE_HASH_MAP 1\" >>confdefs.h\n\n\n$as_echo \"#define HAVE_HASH_SET 1\" >>confdefs.h\n\n\ncat >>confdefs.h <<_ACEOF\n#define HASH_MAP_H $ac_cv_cxx_hash_map\n_ACEOF\n\n\ncat >>confdefs.h <<_ACEOF\n#define HASH_SET_H $ac_cv_cxx_hash_set\n_ACEOF\n\n\ncat >>confdefs.h <<_ACEOF\n#define HASH_NAMESPACE $ac_cv_cxx_hash_namespace\n_ACEOF\n\n\ncat >>confdefs.h <<_ACEOF\n#define HASH_MAP_CLASS $ac_cv_cxx_hash_map_class\n_ACEOF\n\n\ncat >>confdefs.h <<_ACEOF\n#define HASH_SET_CLASS $ac_cv_cxx_hash_set_class\n_ACEOF\n\n      { $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_hash_map\" >&5\n$as_echo \"$ac_cv_cxx_hash_map\" >&6; }\n   else\n      { $as_echo \"$as_me:${as_lineno-$LINENO}: result: \" >&5\n$as_echo \"\" >&6; }\n      { $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: could not find an STL hash_map\" >&5\n$as_echo \"$as_me: WARNING: could not find an STL hash_map\" >&2;}\n   fi\n\n\ncase \"$target_os\" in\n  mingw* | cygwin* | win*)\n    ;;\n  *)\n    # Need to link against rt on Solaris\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: checking for library containing sched_yield\" >&5\n$as_echo_n \"checking for library containing sched_yield... \" >&6; }\nif ${ac_cv_search_sched_yield+:} false; then :\n  $as_echo_n \"(cached) \" >&6\nelse\n  ac_func_search_save_LIBS=$LIBS\ncat confdefs.h - <<_ACEOF >conftest.$ac_ext\n/* end confdefs.h.  */\n\n/* Override any GCC internal prototype to avoid an error.\n   Use char because int might match the return type of a GCC\n   builtin and then its argument prototype would still apply.  */\n#ifdef __cplusplus\nextern \"C\"\n#endif\nchar sched_yield ();\nint\nmain ()\n{\nreturn sched_yield ();\n  ;\n  return 0;\n}\n_ACEOF\nfor ac_lib in '' rt; do\n  if test -z \"$ac_lib\"; then\n    ac_res=\"none required\"\n  else\n    ac_res=-l$ac_lib\n    LIBS=\"-l$ac_lib  $ac_func_search_save_LIBS\"\n  fi\n  if ac_fn_cxx_try_link \"$LINENO\"; then :\n  ac_cv_search_sched_yield=$ac_res\nfi\nrm -f core conftest.err conftest.$ac_objext \\\n    conftest$ac_exeext\n  if ${ac_cv_search_sched_yield+:} false; then :\n  break\nfi\ndone\nif ${ac_cv_search_sched_yield+:} false; then :\n\nelse\n  ac_cv_search_sched_yield=no\nfi\nrm conftest.$ac_ext\nLIBS=$ac_func_search_save_LIBS\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_sched_yield\" >&5\n$as_echo \"$ac_cv_search_sched_yield\" >&6; }\nac_res=$ac_cv_search_sched_yield\nif test \"$ac_res\" != no; then :\n  test \"$ac_res\" = \"none required\" || LIBS=\"$ac_res $LIBS\"\n\nelse\n  { { $as_echo \"$as_me:${as_lineno-$LINENO}: error: in \\`$ac_pwd':\" >&5\n$as_echo \"$as_me: error: in \\`$ac_pwd':\" >&2;}\nas_fn_error $? \"sched_yield was not found on your system\nSee \\`config.log' for more details\" \"$LINENO\" 5; }\nfi\n\n    ;;\nesac\n\n# Enable ObjC support for conformance directory on OS X.\nOBJC_CONFORMANCE_TEST=0\ncase \"$target_os\" in\n  darwin*)\n    OBJC_CONFORMANCE_TEST=1\n    ;;\nesac\n if test $OBJC_CONFORMANCE_TEST = 1; then\n  OBJC_CONFORMANCE_TEST_TRUE=\n  OBJC_CONFORMANCE_TEST_FALSE='#'\nelse\n  OBJC_CONFORMANCE_TEST_TRUE='#'\n  OBJC_CONFORMANCE_TEST_FALSE=\nfi\n\n\n# HACK:  Make gmock's configure script pick up our copy of CFLAGS and CXXFLAGS,\n#   since the flags added by ACX_CHECK_SUNCC must be used when compiling gmock\n#   too.\nexport CFLAGS\nexport CXXFLAGS\n\n\nsubdirs=\"$subdirs gmock\"\n\n\nac_config_files=\"$ac_config_files Makefile src/Makefile benchmarks/Makefile conformance/Makefile protobuf.pc protobuf-lite.pc\"\n\ncat >confcache <<\\_ACEOF\n# This file is a shell script that caches the results of configure\n# tests run on this system so they can be shared between configure\n# scripts and configure runs, see configure's option --config-cache.\n# It is not useful on other systems.  If it contains results you don't\n# want to keep, you may remove or edit it.\n#\n# config.status only pays attention to the cache file if you give it\n# the --recheck option to rerun configure.\n#\n# `ac_cv_env_foo' variables (set or unset) will be overridden when\n# loading this file, other *unset* `ac_cv_foo' will be assigned the\n# following values.\n\n_ACEOF\n\n# The following way of writing the cache mishandles newlines in values,\n# but we know of no workaround that is simple, portable, and efficient.\n# So, we kill variables containing newlines.\n# Ultrix sh set writes to stderr and can't be redirected directly,\n# and sets the high bit in the cache file unless we assign to the vars.\n(\n  for ac_var in `(set) 2>&1 | sed -n 's/^\\([a-zA-Z_][a-zA-Z0-9_]*\\)=.*/\\1/p'`; do\n    eval ac_val=\\$$ac_var\n    case $ac_val in #(\n    *${as_nl}*)\n      case $ac_var in #(\n      *_cv_*) { $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline\" >&5\n$as_echo \"$as_me: WARNING: cache variable $ac_var contains a newline\" >&2;} ;;\n      esac\n      case $ac_var in #(\n      _ | IFS | as_nl) ;; #(\n      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(\n      *) { eval $ac_var=; unset $ac_var;} ;;\n      esac ;;\n    esac\n  done\n\n  (set) 2>&1 |\n    case $as_nl`(ac_space=' '; set) 2>&1` in #(\n    *${as_nl}ac_space=\\ *)\n      # `set' does not quote correctly, so add quotes: double-quote\n      # substitution turns \\\\\\\\ into \\\\, and sed turns \\\\ into \\.\n      sed -n \\\n\t\"s/'/'\\\\\\\\''/g;\n\t  s/^\\\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\\\)=\\\\(.*\\\\)/\\\\1='\\\\2'/p\"\n      ;; #(\n    *)\n      # `set' quotes correctly as required by POSIX, so do not add quotes.\n      sed -n \"/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p\"\n      ;;\n    esac |\n    sort\n) |\n  sed '\n     /^ac_cv_env_/b end\n     t clear\n     :clear\n     s/^\\([^=]*\\)=\\(.*[{}].*\\)$/test \"${\\1+set}\" = set || &/\n     t end\n     s/^\\([^=]*\\)=\\(.*\\)$/\\1=${\\1=\\2}/\n     :end' >>confcache\nif diff \"$cache_file\" confcache >/dev/null 2>&1; then :; else\n  if test -w \"$cache_file\"; then\n    if test \"x$cache_file\" != \"x/dev/null\"; then\n      { $as_echo \"$as_me:${as_lineno-$LINENO}: updating cache $cache_file\" >&5\n$as_echo \"$as_me: updating cache $cache_file\" >&6;}\n      if test ! -f \"$cache_file\" || test -h \"$cache_file\"; then\n\tcat confcache >\"$cache_file\"\n      else\n        case $cache_file in #(\n        */* | ?:*)\n\t  mv -f confcache \"$cache_file\"$$ &&\n\t  mv -f \"$cache_file\"$$ \"$cache_file\" ;; #(\n        *)\n\t  mv -f confcache \"$cache_file\" ;;\n\tesac\n      fi\n    fi\n  else\n    { $as_echo \"$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file\" >&5\n$as_echo \"$as_me: not updating unwritable cache $cache_file\" >&6;}\n  fi\nfi\nrm -f confcache\n\ntest \"x$prefix\" = xNONE && prefix=$ac_default_prefix\n# Let make expand exec_prefix.\ntest \"x$exec_prefix\" = xNONE && exec_prefix='${prefix}'\n\nDEFS=-DHAVE_CONFIG_H\n\nac_libobjs=\nac_ltlibobjs=\nU=\nfor ac_i in : $LIBOBJS; do test \"x$ac_i\" = x: && continue\n  # 1. Remove the extension, and $U if already installed.\n  ac_script='s/\\$U\\././;s/\\.o$//;s/\\.obj$//'\n  ac_i=`$as_echo \"$ac_i\" | sed \"$ac_script\"`\n  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR\n  #    will be set to the directory where LIBOBJS objects are built.\n  as_fn_append ac_libobjs \" \\${LIBOBJDIR}$ac_i\\$U.$ac_objext\"\n  as_fn_append ac_ltlibobjs \" \\${LIBOBJDIR}$ac_i\"'$U.lo'\ndone\nLIBOBJS=$ac_libobjs\n\nLTLIBOBJS=$ac_ltlibobjs\n\n\nif test -z \"${MAINTAINER_MODE_TRUE}\" && test -z \"${MAINTAINER_MODE_FALSE}\"; then\n  as_fn_error $? \"conditional \\\"MAINTAINER_MODE\\\" was never defined.\nUsually this means the macro was only invoked conditionally.\" \"$LINENO\" 5\nfi\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure\" >&5\n$as_echo_n \"checking that generated files are newer than configure... \" >&6; }\n   if test -n \"$am_sleep_pid\"; then\n     # Hide warnings about reused PIDs.\n     wait $am_sleep_pid 2>/dev/null\n   fi\n   { $as_echo \"$as_me:${as_lineno-$LINENO}: result: done\" >&5\n$as_echo \"done\" >&6; }\n if test -n \"$EXEEXT\"; then\n  am__EXEEXT_TRUE=\n  am__EXEEXT_FALSE='#'\nelse\n  am__EXEEXT_TRUE='#'\n  am__EXEEXT_FALSE=\nfi\n\nif test -z \"${AMDEP_TRUE}\" && test -z \"${AMDEP_FALSE}\"; then\n  as_fn_error $? \"conditional \\\"AMDEP\\\" was never defined.\nUsually this means the macro was only invoked conditionally.\" \"$LINENO\" 5\nfi\nif test -z \"${am__fastdepCC_TRUE}\" && test -z \"${am__fastdepCC_FALSE}\"; then\n  as_fn_error $? \"conditional \\\"am__fastdepCC\\\" was never defined.\nUsually this means the macro was only invoked conditionally.\" \"$LINENO\" 5\nfi\nif test -z \"${am__fastdepCXX_TRUE}\" && test -z \"${am__fastdepCXX_FALSE}\"; then\n  as_fn_error $? \"conditional \\\"am__fastdepCXX\\\" was never defined.\nUsually this means the macro was only invoked conditionally.\" \"$LINENO\" 5\nfi\nif test -z \"${GCC_TRUE}\" && test -z \"${GCC_FALSE}\"; then\n  as_fn_error $? \"conditional \\\"GCC\\\" was never defined.\nUsually this means the macro was only invoked conditionally.\" \"$LINENO\" 5\nfi\nif test -z \"${am__fastdepOBJC_TRUE}\" && test -z \"${am__fastdepOBJC_FALSE}\"; then\n  as_fn_error $? \"conditional \\\"am__fastdepOBJC\\\" was never defined.\nUsually this means the macro was only invoked conditionally.\" \"$LINENO\" 5\nfi\nif test -z \"${HAVE_ZLIB_TRUE}\" && test -z \"${HAVE_ZLIB_FALSE}\"; then\n  as_fn_error $? \"conditional \\\"HAVE_ZLIB\\\" was never defined.\nUsually this means the macro was only invoked conditionally.\" \"$LINENO\" 5\nfi\nif test -z \"${USE_EXTERNAL_PROTOC_TRUE}\" && test -z \"${USE_EXTERNAL_PROTOC_FALSE}\"; then\n  as_fn_error $? \"conditional \\\"USE_EXTERNAL_PROTOC\\\" was never defined.\nUsually this means the macro was only invoked conditionally.\" \"$LINENO\" 5\nfi\nif test -z \"${HAVE_PTHREAD_TRUE}\" && test -z \"${HAVE_PTHREAD_FALSE}\"; then\n  as_fn_error $? \"conditional \\\"HAVE_PTHREAD\\\" was never defined.\nUsually this means the macro was only invoked conditionally.\" \"$LINENO\" 5\nfi\nif test -z \"${OBJC_CONFORMANCE_TEST_TRUE}\" && test -z \"${OBJC_CONFORMANCE_TEST_FALSE}\"; then\n  as_fn_error $? \"conditional \\\"OBJC_CONFORMANCE_TEST\\\" was never defined.\nUsually this means the macro was only invoked conditionally.\" \"$LINENO\" 5\nfi\n\n: \"${CONFIG_STATUS=./config.status}\"\nac_write_fail=0\nac_clean_files_save=$ac_clean_files\nac_clean_files=\"$ac_clean_files $CONFIG_STATUS\"\n{ $as_echo \"$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS\" >&5\n$as_echo \"$as_me: creating $CONFIG_STATUS\" >&6;}\nas_write_fail=0\ncat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1\n#! $SHELL\n# Generated by $as_me.\n# Run this file to recreate the current configuration.\n# Compiler output produced by configure, useful for debugging\n# configure, is in config.log if it exists.\n\ndebug=false\nac_cs_recheck=false\nac_cs_silent=false\n\nSHELL=\\${CONFIG_SHELL-$SHELL}\nexport SHELL\n_ASEOF\ncat >>$CONFIG_STATUS <<\\_ASEOF || as_write_fail=1\n## -------------------- ##\n## M4sh Initialization. ##\n## -------------------- ##\n\n# Be more Bourne compatible\nDUALCASE=1; export DUALCASE # for MKS sh\nif test -n \"${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :\n  emulate sh\n  NULLCMD=:\n  # Pre-4.2 versions of Zsh do word splitting on ${1+\"$@\"}, which\n  # is contrary to our usage.  Disable this feature.\n  alias -g '${1+\"$@\"}'='\"$@\"'\n  setopt NO_GLOB_SUBST\nelse\n  case `(set -o) 2>/dev/null` in #(\n  *posix*) :\n    set -o posix ;; #(\n  *) :\n     ;;\nesac\nfi\n\n\nas_nl='\n'\nexport as_nl\n# Printing a long string crashes Solaris 7 /usr/bin/printf.\nas_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'\nas_echo=$as_echo$as_echo$as_echo$as_echo$as_echo\nas_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo\n# Prefer a ksh shell builtin over an external printf program on Solaris,\n# but without wasting forks for bash or zsh.\nif test -z \"$BASH_VERSION$ZSH_VERSION\" \\\n    && (test \"X`print -r -- $as_echo`\" = \"X$as_echo\") 2>/dev/null; then\n  as_echo='print -r --'\n  as_echo_n='print -rn --'\nelif (test \"X`printf %s $as_echo`\" = \"X$as_echo\") 2>/dev/null; then\n  as_echo='printf %s\\n'\n  as_echo_n='printf %s'\nelse\n  if test \"X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`\" = \"X-n $as_echo\"; then\n    as_echo_body='eval /usr/ucb/echo -n \"$1$as_nl\"'\n    as_echo_n='/usr/ucb/echo -n'\n  else\n    as_echo_body='eval expr \"X$1\" : \"X\\\\(.*\\\\)\"'\n    as_echo_n_body='eval\n      arg=$1;\n      case $arg in #(\n      *\"$as_nl\"*)\n\texpr \"X$arg\" : \"X\\\\(.*\\\\)$as_nl\";\n\targ=`expr \"X$arg\" : \".*$as_nl\\\\(.*\\\\)\"`;;\n      esac;\n      expr \"X$arg\" : \"X\\\\(.*\\\\)\" | tr -d \"$as_nl\"\n    '\n    export as_echo_n_body\n    as_echo_n='sh -c $as_echo_n_body as_echo'\n  fi\n  export as_echo_body\n  as_echo='sh -c $as_echo_body as_echo'\nfi\n\n# The user is always right.\nif test \"${PATH_SEPARATOR+set}\" != set; then\n  PATH_SEPARATOR=:\n  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {\n    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||\n      PATH_SEPARATOR=';'\n  }\nfi\n\n\n# IFS\n# We need space, tab and new line, in precisely that order.  Quoting is\n# there to prevent editors from complaining about space-tab.\n# (If _AS_PATH_WALK were called with IFS unset, it would disable word\n# splitting by setting IFS to empty value.)\nIFS=\" \"\"\t$as_nl\"\n\n# Find who we are.  Look in the path if we contain no directory separator.\nas_myself=\ncase $0 in #((\n  *[\\\\/]* ) as_myself=$0 ;;\n  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n    test -r \"$as_dir/$0\" && as_myself=$as_dir/$0 && break\n  done\nIFS=$as_save_IFS\n\n     ;;\nesac\n# We did not find ourselves, most probably we were run as `sh COMMAND'\n# in which case we are not to be found in the path.\nif test \"x$as_myself\" = x; then\n  as_myself=$0\nfi\nif test ! -f \"$as_myself\"; then\n  $as_echo \"$as_myself: error: cannot find myself; rerun with an absolute file name\" >&2\n  exit 1\nfi\n\n# Unset variables that we do not need and which cause bugs (e.g. in\n# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the \"|| exit 1\"\n# suppresses any \"Segmentation fault\" message there.  '((' could\n# trigger a bug in pdksh 5.2.14.\nfor as_var in BASH_ENV ENV MAIL MAILPATH\ndo eval test x\\${$as_var+set} = xset \\\n  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :\ndone\nPS1='$ '\nPS2='> '\nPS4='+ '\n\n# NLS nuisances.\nLC_ALL=C\nexport LC_ALL\nLANGUAGE=C\nexport LANGUAGE\n\n# CDPATH.\n(unset CDPATH) >/dev/null 2>&1 && unset CDPATH\n\n\n# as_fn_error STATUS ERROR [LINENO LOG_FD]\n# ----------------------------------------\n# Output \"`basename $0`: error: ERROR\" to stderr. If LINENO and LOG_FD are\n# provided, also output the error to LOG_FD, referencing LINENO. Then exit the\n# script with STATUS, using 1 if that was 0.\nas_fn_error ()\n{\n  as_status=$1; test $as_status -eq 0 && as_status=1\n  if test \"$4\"; then\n    as_lineno=${as_lineno-\"$3\"} as_lineno_stack=as_lineno_stack=$as_lineno_stack\n    $as_echo \"$as_me:${as_lineno-$LINENO}: error: $2\" >&$4\n  fi\n  $as_echo \"$as_me: error: $2\" >&2\n  as_fn_exit $as_status\n} # as_fn_error\n\n\n# as_fn_set_status STATUS\n# -----------------------\n# Set $? to STATUS, without forking.\nas_fn_set_status ()\n{\n  return $1\n} # as_fn_set_status\n\n# as_fn_exit STATUS\n# -----------------\n# Exit the shell with STATUS, even in a \"trap 0\" or \"set -e\" context.\nas_fn_exit ()\n{\n  set +e\n  as_fn_set_status $1\n  exit $1\n} # as_fn_exit\n\n# as_fn_unset VAR\n# ---------------\n# Portably unset VAR.\nas_fn_unset ()\n{\n  { eval $1=; unset $1;}\n}\nas_unset=as_fn_unset\n# as_fn_append VAR VALUE\n# ----------------------\n# Append the text in VALUE to the end of the definition contained in VAR. Take\n# advantage of any shell optimizations that allow amortized linear growth over\n# repeated appends, instead of the typical quadratic growth present in naive\n# implementations.\nif (eval \"as_var=1; as_var+=2; test x\\$as_var = x12\") 2>/dev/null; then :\n  eval 'as_fn_append ()\n  {\n    eval $1+=\\$2\n  }'\nelse\n  as_fn_append ()\n  {\n    eval $1=\\$$1\\$2\n  }\nfi # as_fn_append\n\n# as_fn_arith ARG...\n# ------------------\n# Perform arithmetic evaluation on the ARGs, and store the result in the\n# global $as_val. Take advantage of shells that can avoid forks. The arguments\n# must be portable across $(()) and expr.\nif (eval \"test \\$(( 1 + 1 )) = 2\") 2>/dev/null; then :\n  eval 'as_fn_arith ()\n  {\n    as_val=$(( $* ))\n  }'\nelse\n  as_fn_arith ()\n  {\n    as_val=`expr \"$@\" || test $? -eq 1`\n  }\nfi # as_fn_arith\n\n\nif expr a : '\\(a\\)' >/dev/null 2>&1 &&\n   test \"X`expr 00001 : '.*\\(...\\)'`\" = X001; then\n  as_expr=expr\nelse\n  as_expr=false\nfi\n\nif (basename -- /) >/dev/null 2>&1 && test \"X`basename -- / 2>&1`\" = \"X/\"; then\n  as_basename=basename\nelse\n  as_basename=false\nfi\n\nif (as_dir=`dirname -- /` && test \"X$as_dir\" = X/) >/dev/null 2>&1; then\n  as_dirname=dirname\nelse\n  as_dirname=false\nfi\n\nas_me=`$as_basename -- \"$0\" ||\n$as_expr X/\"$0\" : '.*/\\([^/][^/]*\\)/*$' \\| \\\n\t X\"$0\" : 'X\\(//\\)$' \\| \\\n\t X\"$0\" : 'X\\(/\\)' \\| . 2>/dev/null ||\n$as_echo X/\"$0\" |\n    sed '/^.*\\/\\([^/][^/]*\\)\\/*$/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\/\\(\\/\\/\\)$/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\/\\(\\/\\).*/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  s/.*/./; q'`\n\n# Avoid depending upon Character Ranges.\nas_cr_letters='abcdefghijklmnopqrstuvwxyz'\nas_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'\nas_cr_Letters=$as_cr_letters$as_cr_LETTERS\nas_cr_digits='0123456789'\nas_cr_alnum=$as_cr_Letters$as_cr_digits\n\nECHO_C= ECHO_N= ECHO_T=\ncase `echo -n x` in #(((((\n-n*)\n  case `echo 'xy\\c'` in\n  *c*) ECHO_T='\t';;\t# ECHO_T is single tab character.\n  xy)  ECHO_C='\\c';;\n  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null\n       ECHO_T='\t';;\n  esac;;\n*)\n  ECHO_N='-n';;\nesac\n\nrm -f conf$$ conf$$.exe conf$$.file\nif test -d conf$$.dir; then\n  rm -f conf$$.dir/conf$$.file\nelse\n  rm -f conf$$.dir\n  mkdir conf$$.dir 2>/dev/null\nfi\nif (echo >conf$$.file) 2>/dev/null; then\n  if ln -s conf$$.file conf$$ 2>/dev/null; then\n    as_ln_s='ln -s'\n    # ... but there are two gotchas:\n    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.\n    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.\n    # In both cases, we have to default to `cp -pR'.\n    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||\n      as_ln_s='cp -pR'\n  elif ln conf$$.file conf$$ 2>/dev/null; then\n    as_ln_s=ln\n  else\n    as_ln_s='cp -pR'\n  fi\nelse\n  as_ln_s='cp -pR'\nfi\nrm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file\nrmdir conf$$.dir 2>/dev/null\n\n\n# as_fn_mkdir_p\n# -------------\n# Create \"$as_dir\" as a directory, including parents if necessary.\nas_fn_mkdir_p ()\n{\n\n  case $as_dir in #(\n  -*) as_dir=./$as_dir;;\n  esac\n  test -d \"$as_dir\" || eval $as_mkdir_p || {\n    as_dirs=\n    while :; do\n      case $as_dir in #(\n      *\\'*) as_qdir=`$as_echo \"$as_dir\" | sed \"s/'/'\\\\\\\\\\\\\\\\''/g\"`;; #'(\n      *) as_qdir=$as_dir;;\n      esac\n      as_dirs=\"'$as_qdir' $as_dirs\"\n      as_dir=`$as_dirname -- \"$as_dir\" ||\n$as_expr X\"$as_dir\" : 'X\\(.*[^/]\\)//*[^/][^/]*/*$' \\| \\\n\t X\"$as_dir\" : 'X\\(//\\)[^/]' \\| \\\n\t X\"$as_dir\" : 'X\\(//\\)$' \\| \\\n\t X\"$as_dir\" : 'X\\(/\\)' \\| . 2>/dev/null ||\n$as_echo X\"$as_dir\" |\n    sed '/^X\\(.*[^/]\\)\\/\\/*[^/][^/]*\\/*$/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\(\\/\\/\\)[^/].*/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\(\\/\\/\\)$/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\(\\/\\).*/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  s/.*/./; q'`\n      test -d \"$as_dir\" && break\n    done\n    test -z \"$as_dirs\" || eval \"mkdir $as_dirs\"\n  } || test -d \"$as_dir\" || as_fn_error $? \"cannot create directory $as_dir\"\n\n\n} # as_fn_mkdir_p\nif mkdir -p . 2>/dev/null; then\n  as_mkdir_p='mkdir -p \"$as_dir\"'\nelse\n  test -d ./-p && rmdir ./-p\n  as_mkdir_p=false\nfi\n\n\n# as_fn_executable_p FILE\n# -----------------------\n# Test if FILE is an executable regular file.\nas_fn_executable_p ()\n{\n  test -f \"$1\" && test -x \"$1\"\n} # as_fn_executable_p\nas_test_x='test -x'\nas_executable_p=as_fn_executable_p\n\n# Sed expression to map a string onto a valid CPP name.\nas_tr_cpp=\"eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'\"\n\n# Sed expression to map a string onto a valid variable name.\nas_tr_sh=\"eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'\"\n\n\nexec 6>&1\n## ----------------------------------- ##\n## Main body of $CONFIG_STATUS script. ##\n## ----------------------------------- ##\n_ASEOF\ntest $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1\n\ncat >>$CONFIG_STATUS <<\\_ACEOF || ac_write_fail=1\n# Save the log message, to keep $0 and so on meaningful, and to\n# report actual input values of CONFIG_FILES etc. instead of their\n# values after options handling.\nac_log=\"\nThis file was extended by Protocol Buffers $as_me 3.0.0, which was\ngenerated by GNU Autoconf 2.69.  Invocation command line was\n\n  CONFIG_FILES    = $CONFIG_FILES\n  CONFIG_HEADERS  = $CONFIG_HEADERS\n  CONFIG_LINKS    = $CONFIG_LINKS\n  CONFIG_COMMANDS = $CONFIG_COMMANDS\n  $ $0 $@\n\non `(hostname || uname -n) 2>/dev/null | sed 1q`\n\"\n\n_ACEOF\n\ncase $ac_config_files in *\"\n\"*) set x $ac_config_files; shift; ac_config_files=$*;;\nesac\n\ncase $ac_config_headers in *\"\n\"*) set x $ac_config_headers; shift; ac_config_headers=$*;;\nesac\n\n\ncat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1\n# Files that config.status was made for.\nconfig_files=\"$ac_config_files\"\nconfig_headers=\"$ac_config_headers\"\nconfig_commands=\"$ac_config_commands\"\n\n_ACEOF\n\ncat >>$CONFIG_STATUS <<\\_ACEOF || ac_write_fail=1\nac_cs_usage=\"\\\n\\`$as_me' instantiates files and other configuration actions\nfrom templates according to the current configuration.  Unless the files\nand actions are specified as TAGs, all are instantiated by default.\n\nUsage: $0 [OPTION]... [TAG]...\n\n  -h, --help       print this help, then exit\n  -V, --version    print version number and configuration settings, then exit\n      --config     print configuration, then exit\n  -q, --quiet, --silent\n                   do not print progress messages\n  -d, --debug      don't remove temporary files\n      --recheck    update $as_me by reconfiguring in the same conditions\n      --file=FILE[:TEMPLATE]\n                   instantiate the configuration file FILE\n      --header=FILE[:TEMPLATE]\n                   instantiate the configuration header FILE\n\nConfiguration files:\n$config_files\n\nConfiguration headers:\n$config_headers\n\nConfiguration commands:\n$config_commands\n\nReport bugs to <protobuf@googlegroups.com>.\"\n\n_ACEOF\ncat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1\nac_cs_config=\"`$as_echo \"$ac_configure_args\" | sed 's/^ //; s/[\\\\\"\"\\`\\$]/\\\\\\\\&/g'`\"\nac_cs_version=\"\\\\\nProtocol Buffers config.status 3.0.0\nconfigured by $0, generated by GNU Autoconf 2.69,\n  with options \\\\\"\\$ac_cs_config\\\\\"\n\nCopyright (C) 2012 Free Software Foundation, Inc.\nThis config.status script is free software; the Free Software Foundation\ngives unlimited permission to copy, distribute and modify it.\"\n\nac_pwd='$ac_pwd'\nsrcdir='$srcdir'\nINSTALL='$INSTALL'\nMKDIR_P='$MKDIR_P'\nAWK='$AWK'\ntest -n \"\\$AWK\" || AWK=awk\n_ACEOF\n\ncat >>$CONFIG_STATUS <<\\_ACEOF || ac_write_fail=1\n# The default lists apply if the user does not specify any file.\nac_need_defaults=:\nwhile test $# != 0\ndo\n  case $1 in\n  --*=?*)\n    ac_option=`expr \"X$1\" : 'X\\([^=]*\\)='`\n    ac_optarg=`expr \"X$1\" : 'X[^=]*=\\(.*\\)'`\n    ac_shift=:\n    ;;\n  --*=)\n    ac_option=`expr \"X$1\" : 'X\\([^=]*\\)='`\n    ac_optarg=\n    ac_shift=:\n    ;;\n  *)\n    ac_option=$1\n    ac_optarg=$2\n    ac_shift=shift\n    ;;\n  esac\n\n  case $ac_option in\n  # Handling of the options.\n  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)\n    ac_cs_recheck=: ;;\n  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )\n    $as_echo \"$ac_cs_version\"; exit ;;\n  --config | --confi | --conf | --con | --co | --c )\n    $as_echo \"$ac_cs_config\"; exit ;;\n  --debug | --debu | --deb | --de | --d | -d )\n    debug=: ;;\n  --file | --fil | --fi | --f )\n    $ac_shift\n    case $ac_optarg in\n    *\\'*) ac_optarg=`$as_echo \"$ac_optarg\" | sed \"s/'/'\\\\\\\\\\\\\\\\''/g\"` ;;\n    '') as_fn_error $? \"missing file argument\" ;;\n    esac\n    as_fn_append CONFIG_FILES \" '$ac_optarg'\"\n    ac_need_defaults=false;;\n  --header | --heade | --head | --hea )\n    $ac_shift\n    case $ac_optarg in\n    *\\'*) ac_optarg=`$as_echo \"$ac_optarg\" | sed \"s/'/'\\\\\\\\\\\\\\\\''/g\"` ;;\n    esac\n    as_fn_append CONFIG_HEADERS \" '$ac_optarg'\"\n    ac_need_defaults=false;;\n  --he | --h)\n    # Conflict between --help and --header\n    as_fn_error $? \"ambiguous option: \\`$1'\nTry \\`$0 --help' for more information.\";;\n  --help | --hel | -h )\n    $as_echo \"$ac_cs_usage\"; exit ;;\n  -q | -quiet | --quiet | --quie | --qui | --qu | --q \\\n  | -silent | --silent | --silen | --sile | --sil | --si | --s)\n    ac_cs_silent=: ;;\n\n  # This is an error.\n  -*) as_fn_error $? \"unrecognized option: \\`$1'\nTry \\`$0 --help' for more information.\" ;;\n\n  *) as_fn_append ac_config_targets \" $1\"\n     ac_need_defaults=false ;;\n\n  esac\n  shift\ndone\n\nac_configure_extra_args=\n\nif $ac_cs_silent; then\n  exec 6>/dev/null\n  ac_configure_extra_args=\"$ac_configure_extra_args --silent\"\nfi\n\n_ACEOF\ncat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1\nif \\$ac_cs_recheck; then\n  set X $SHELL '$0' $ac_configure_args \\$ac_configure_extra_args --no-create --no-recursion\n  shift\n  \\$as_echo \"running CONFIG_SHELL=$SHELL \\$*\" >&6\n  CONFIG_SHELL='$SHELL'\n  export CONFIG_SHELL\n  exec \"\\$@\"\nfi\n\n_ACEOF\ncat >>$CONFIG_STATUS <<\\_ACEOF || ac_write_fail=1\nexec 5>>config.log\n{\n  echo\n  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX\n## Running $as_me. ##\n_ASBOX\n  $as_echo \"$ac_log\"\n} >&5\n\n_ACEOF\ncat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1\n#\n# INIT-COMMANDS\n#\nAMDEP_TRUE=\"$AMDEP_TRUE\" ac_aux_dir=\"$ac_aux_dir\"\n\n\n# The HP-UX ksh and POSIX shell print the target directory to stdout\n# if CDPATH is set.\n(unset CDPATH) >/dev/null 2>&1 && unset CDPATH\n\nsed_quote_subst='$sed_quote_subst'\ndouble_quote_subst='$double_quote_subst'\ndelay_variable_subst='$delay_variable_subst'\nmacro_version='`$ECHO \"$macro_version\" | $SED \"$delay_single_quote_subst\"`'\nmacro_revision='`$ECHO \"$macro_revision\" | $SED \"$delay_single_quote_subst\"`'\nenable_shared='`$ECHO \"$enable_shared\" | $SED \"$delay_single_quote_subst\"`'\nenable_static='`$ECHO \"$enable_static\" | $SED \"$delay_single_quote_subst\"`'\npic_mode='`$ECHO \"$pic_mode\" | $SED \"$delay_single_quote_subst\"`'\nenable_fast_install='`$ECHO \"$enable_fast_install\" | $SED \"$delay_single_quote_subst\"`'\nSHELL='`$ECHO \"$SHELL\" | $SED \"$delay_single_quote_subst\"`'\nECHO='`$ECHO \"$ECHO\" | $SED \"$delay_single_quote_subst\"`'\nPATH_SEPARATOR='`$ECHO \"$PATH_SEPARATOR\" | $SED \"$delay_single_quote_subst\"`'\nhost_alias='`$ECHO \"$host_alias\" | $SED \"$delay_single_quote_subst\"`'\nhost='`$ECHO \"$host\" | $SED \"$delay_single_quote_subst\"`'\nhost_os='`$ECHO \"$host_os\" | $SED \"$delay_single_quote_subst\"`'\nbuild_alias='`$ECHO \"$build_alias\" | $SED \"$delay_single_quote_subst\"`'\nbuild='`$ECHO \"$build\" | $SED \"$delay_single_quote_subst\"`'\nbuild_os='`$ECHO \"$build_os\" | $SED \"$delay_single_quote_subst\"`'\nSED='`$ECHO \"$SED\" | $SED \"$delay_single_quote_subst\"`'\nXsed='`$ECHO \"$Xsed\" | $SED \"$delay_single_quote_subst\"`'\nGREP='`$ECHO \"$GREP\" | $SED \"$delay_single_quote_subst\"`'\nEGREP='`$ECHO \"$EGREP\" | $SED \"$delay_single_quote_subst\"`'\nFGREP='`$ECHO \"$FGREP\" | $SED \"$delay_single_quote_subst\"`'\nLD='`$ECHO \"$LD\" | $SED \"$delay_single_quote_subst\"`'\nNM='`$ECHO \"$NM\" | $SED \"$delay_single_quote_subst\"`'\nLN_S='`$ECHO \"$LN_S\" | $SED \"$delay_single_quote_subst\"`'\nmax_cmd_len='`$ECHO \"$max_cmd_len\" | $SED \"$delay_single_quote_subst\"`'\nac_objext='`$ECHO \"$ac_objext\" | $SED \"$delay_single_quote_subst\"`'\nexeext='`$ECHO \"$exeext\" | $SED \"$delay_single_quote_subst\"`'\nlt_unset='`$ECHO \"$lt_unset\" | $SED \"$delay_single_quote_subst\"`'\nlt_SP2NL='`$ECHO \"$lt_SP2NL\" | $SED \"$delay_single_quote_subst\"`'\nlt_NL2SP='`$ECHO \"$lt_NL2SP\" | $SED \"$delay_single_quote_subst\"`'\nlt_cv_to_host_file_cmd='`$ECHO \"$lt_cv_to_host_file_cmd\" | $SED \"$delay_single_quote_subst\"`'\nlt_cv_to_tool_file_cmd='`$ECHO \"$lt_cv_to_tool_file_cmd\" | $SED \"$delay_single_quote_subst\"`'\nreload_flag='`$ECHO \"$reload_flag\" | $SED \"$delay_single_quote_subst\"`'\nreload_cmds='`$ECHO \"$reload_cmds\" | $SED \"$delay_single_quote_subst\"`'\nOBJDUMP='`$ECHO \"$OBJDUMP\" | $SED \"$delay_single_quote_subst\"`'\ndeplibs_check_method='`$ECHO \"$deplibs_check_method\" | $SED \"$delay_single_quote_subst\"`'\nfile_magic_cmd='`$ECHO \"$file_magic_cmd\" | $SED \"$delay_single_quote_subst\"`'\nfile_magic_glob='`$ECHO \"$file_magic_glob\" | $SED \"$delay_single_quote_subst\"`'\nwant_nocaseglob='`$ECHO \"$want_nocaseglob\" | $SED \"$delay_single_quote_subst\"`'\nDLLTOOL='`$ECHO \"$DLLTOOL\" | $SED \"$delay_single_quote_subst\"`'\nsharedlib_from_linklib_cmd='`$ECHO \"$sharedlib_from_linklib_cmd\" | $SED \"$delay_single_quote_subst\"`'\nAR='`$ECHO \"$AR\" | $SED \"$delay_single_quote_subst\"`'\nAR_FLAGS='`$ECHO \"$AR_FLAGS\" | $SED \"$delay_single_quote_subst\"`'\narchiver_list_spec='`$ECHO \"$archiver_list_spec\" | $SED \"$delay_single_quote_subst\"`'\nSTRIP='`$ECHO \"$STRIP\" | $SED \"$delay_single_quote_subst\"`'\nRANLIB='`$ECHO \"$RANLIB\" | $SED \"$delay_single_quote_subst\"`'\nold_postinstall_cmds='`$ECHO \"$old_postinstall_cmds\" | $SED \"$delay_single_quote_subst\"`'\nold_postuninstall_cmds='`$ECHO \"$old_postuninstall_cmds\" | $SED \"$delay_single_quote_subst\"`'\nold_archive_cmds='`$ECHO \"$old_archive_cmds\" | $SED \"$delay_single_quote_subst\"`'\nlock_old_archive_extraction='`$ECHO \"$lock_old_archive_extraction\" | $SED \"$delay_single_quote_subst\"`'\nCC='`$ECHO \"$CC\" | $SED \"$delay_single_quote_subst\"`'\nCFLAGS='`$ECHO \"$CFLAGS\" | $SED \"$delay_single_quote_subst\"`'\ncompiler='`$ECHO \"$compiler\" | $SED \"$delay_single_quote_subst\"`'\nGCC='`$ECHO \"$GCC\" | $SED \"$delay_single_quote_subst\"`'\nlt_cv_sys_global_symbol_pipe='`$ECHO \"$lt_cv_sys_global_symbol_pipe\" | $SED \"$delay_single_quote_subst\"`'\nlt_cv_sys_global_symbol_to_cdecl='`$ECHO \"$lt_cv_sys_global_symbol_to_cdecl\" | $SED \"$delay_single_quote_subst\"`'\nlt_cv_sys_global_symbol_to_c_name_address='`$ECHO \"$lt_cv_sys_global_symbol_to_c_name_address\" | $SED \"$delay_single_quote_subst\"`'\nlt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO \"$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix\" | $SED \"$delay_single_quote_subst\"`'\nnm_file_list_spec='`$ECHO \"$nm_file_list_spec\" | $SED \"$delay_single_quote_subst\"`'\nlt_sysroot='`$ECHO \"$lt_sysroot\" | $SED \"$delay_single_quote_subst\"`'\nobjdir='`$ECHO \"$objdir\" | $SED \"$delay_single_quote_subst\"`'\nMAGIC_CMD='`$ECHO \"$MAGIC_CMD\" | $SED \"$delay_single_quote_subst\"`'\nlt_prog_compiler_no_builtin_flag='`$ECHO \"$lt_prog_compiler_no_builtin_flag\" | $SED \"$delay_single_quote_subst\"`'\nlt_prog_compiler_pic='`$ECHO \"$lt_prog_compiler_pic\" | $SED \"$delay_single_quote_subst\"`'\nlt_prog_compiler_wl='`$ECHO \"$lt_prog_compiler_wl\" | $SED \"$delay_single_quote_subst\"`'\nlt_prog_compiler_static='`$ECHO \"$lt_prog_compiler_static\" | $SED \"$delay_single_quote_subst\"`'\nlt_cv_prog_compiler_c_o='`$ECHO \"$lt_cv_prog_compiler_c_o\" | $SED \"$delay_single_quote_subst\"`'\nneed_locks='`$ECHO \"$need_locks\" | $SED \"$delay_single_quote_subst\"`'\nMANIFEST_TOOL='`$ECHO \"$MANIFEST_TOOL\" | $SED \"$delay_single_quote_subst\"`'\nDSYMUTIL='`$ECHO \"$DSYMUTIL\" | $SED \"$delay_single_quote_subst\"`'\nNMEDIT='`$ECHO \"$NMEDIT\" | $SED \"$delay_single_quote_subst\"`'\nLIPO='`$ECHO \"$LIPO\" | $SED \"$delay_single_quote_subst\"`'\nOTOOL='`$ECHO \"$OTOOL\" | $SED \"$delay_single_quote_subst\"`'\nOTOOL64='`$ECHO \"$OTOOL64\" | $SED \"$delay_single_quote_subst\"`'\nlibext='`$ECHO \"$libext\" | $SED \"$delay_single_quote_subst\"`'\nshrext_cmds='`$ECHO \"$shrext_cmds\" | $SED \"$delay_single_quote_subst\"`'\nextract_expsyms_cmds='`$ECHO \"$extract_expsyms_cmds\" | $SED \"$delay_single_quote_subst\"`'\narchive_cmds_need_lc='`$ECHO \"$archive_cmds_need_lc\" | $SED \"$delay_single_quote_subst\"`'\nenable_shared_with_static_runtimes='`$ECHO \"$enable_shared_with_static_runtimes\" | $SED \"$delay_single_quote_subst\"`'\nexport_dynamic_flag_spec='`$ECHO \"$export_dynamic_flag_spec\" | $SED \"$delay_single_quote_subst\"`'\nwhole_archive_flag_spec='`$ECHO \"$whole_archive_flag_spec\" | $SED \"$delay_single_quote_subst\"`'\ncompiler_needs_object='`$ECHO \"$compiler_needs_object\" | $SED \"$delay_single_quote_subst\"`'\nold_archive_from_new_cmds='`$ECHO \"$old_archive_from_new_cmds\" | $SED \"$delay_single_quote_subst\"`'\nold_archive_from_expsyms_cmds='`$ECHO \"$old_archive_from_expsyms_cmds\" | $SED \"$delay_single_quote_subst\"`'\narchive_cmds='`$ECHO \"$archive_cmds\" | $SED \"$delay_single_quote_subst\"`'\narchive_expsym_cmds='`$ECHO \"$archive_expsym_cmds\" | $SED \"$delay_single_quote_subst\"`'\nmodule_cmds='`$ECHO \"$module_cmds\" | $SED \"$delay_single_quote_subst\"`'\nmodule_expsym_cmds='`$ECHO \"$module_expsym_cmds\" | $SED \"$delay_single_quote_subst\"`'\nwith_gnu_ld='`$ECHO \"$with_gnu_ld\" | $SED \"$delay_single_quote_subst\"`'\nallow_undefined_flag='`$ECHO \"$allow_undefined_flag\" | $SED \"$delay_single_quote_subst\"`'\nno_undefined_flag='`$ECHO \"$no_undefined_flag\" | $SED \"$delay_single_quote_subst\"`'\nhardcode_libdir_flag_spec='`$ECHO \"$hardcode_libdir_flag_spec\" | $SED \"$delay_single_quote_subst\"`'\nhardcode_libdir_separator='`$ECHO \"$hardcode_libdir_separator\" | $SED \"$delay_single_quote_subst\"`'\nhardcode_direct='`$ECHO \"$hardcode_direct\" | $SED \"$delay_single_quote_subst\"`'\nhardcode_direct_absolute='`$ECHO \"$hardcode_direct_absolute\" | $SED \"$delay_single_quote_subst\"`'\nhardcode_minus_L='`$ECHO \"$hardcode_minus_L\" | $SED \"$delay_single_quote_subst\"`'\nhardcode_shlibpath_var='`$ECHO \"$hardcode_shlibpath_var\" | $SED \"$delay_single_quote_subst\"`'\nhardcode_automatic='`$ECHO \"$hardcode_automatic\" | $SED \"$delay_single_quote_subst\"`'\ninherit_rpath='`$ECHO \"$inherit_rpath\" | $SED \"$delay_single_quote_subst\"`'\nlink_all_deplibs='`$ECHO \"$link_all_deplibs\" | $SED \"$delay_single_quote_subst\"`'\nalways_export_symbols='`$ECHO \"$always_export_symbols\" | $SED \"$delay_single_quote_subst\"`'\nexport_symbols_cmds='`$ECHO \"$export_symbols_cmds\" | $SED \"$delay_single_quote_subst\"`'\nexclude_expsyms='`$ECHO \"$exclude_expsyms\" | $SED \"$delay_single_quote_subst\"`'\ninclude_expsyms='`$ECHO \"$include_expsyms\" | $SED \"$delay_single_quote_subst\"`'\nprelink_cmds='`$ECHO \"$prelink_cmds\" | $SED \"$delay_single_quote_subst\"`'\npostlink_cmds='`$ECHO \"$postlink_cmds\" | $SED \"$delay_single_quote_subst\"`'\nfile_list_spec='`$ECHO \"$file_list_spec\" | $SED \"$delay_single_quote_subst\"`'\nvariables_saved_for_relink='`$ECHO \"$variables_saved_for_relink\" | $SED \"$delay_single_quote_subst\"`'\nneed_lib_prefix='`$ECHO \"$need_lib_prefix\" | $SED \"$delay_single_quote_subst\"`'\nneed_version='`$ECHO \"$need_version\" | $SED \"$delay_single_quote_subst\"`'\nversion_type='`$ECHO \"$version_type\" | $SED \"$delay_single_quote_subst\"`'\nrunpath_var='`$ECHO \"$runpath_var\" | $SED \"$delay_single_quote_subst\"`'\nshlibpath_var='`$ECHO \"$shlibpath_var\" | $SED \"$delay_single_quote_subst\"`'\nshlibpath_overrides_runpath='`$ECHO \"$shlibpath_overrides_runpath\" | $SED \"$delay_single_quote_subst\"`'\nlibname_spec='`$ECHO \"$libname_spec\" | $SED \"$delay_single_quote_subst\"`'\nlibrary_names_spec='`$ECHO \"$library_names_spec\" | $SED \"$delay_single_quote_subst\"`'\nsoname_spec='`$ECHO \"$soname_spec\" | $SED \"$delay_single_quote_subst\"`'\ninstall_override_mode='`$ECHO \"$install_override_mode\" | $SED \"$delay_single_quote_subst\"`'\npostinstall_cmds='`$ECHO \"$postinstall_cmds\" | $SED \"$delay_single_quote_subst\"`'\npostuninstall_cmds='`$ECHO \"$postuninstall_cmds\" | $SED \"$delay_single_quote_subst\"`'\nfinish_cmds='`$ECHO \"$finish_cmds\" | $SED \"$delay_single_quote_subst\"`'\nfinish_eval='`$ECHO \"$finish_eval\" | $SED \"$delay_single_quote_subst\"`'\nhardcode_into_libs='`$ECHO \"$hardcode_into_libs\" | $SED \"$delay_single_quote_subst\"`'\nsys_lib_search_path_spec='`$ECHO \"$sys_lib_search_path_spec\" | $SED \"$delay_single_quote_subst\"`'\nsys_lib_dlsearch_path_spec='`$ECHO \"$sys_lib_dlsearch_path_spec\" | $SED \"$delay_single_quote_subst\"`'\nhardcode_action='`$ECHO \"$hardcode_action\" | $SED \"$delay_single_quote_subst\"`'\nenable_dlopen='`$ECHO \"$enable_dlopen\" | $SED \"$delay_single_quote_subst\"`'\nenable_dlopen_self='`$ECHO \"$enable_dlopen_self\" | $SED \"$delay_single_quote_subst\"`'\nenable_dlopen_self_static='`$ECHO \"$enable_dlopen_self_static\" | $SED \"$delay_single_quote_subst\"`'\nold_striplib='`$ECHO \"$old_striplib\" | $SED \"$delay_single_quote_subst\"`'\nstriplib='`$ECHO \"$striplib\" | $SED \"$delay_single_quote_subst\"`'\ncompiler_lib_search_dirs='`$ECHO \"$compiler_lib_search_dirs\" | $SED \"$delay_single_quote_subst\"`'\npredep_objects='`$ECHO \"$predep_objects\" | $SED \"$delay_single_quote_subst\"`'\npostdep_objects='`$ECHO \"$postdep_objects\" | $SED \"$delay_single_quote_subst\"`'\npredeps='`$ECHO \"$predeps\" | $SED \"$delay_single_quote_subst\"`'\npostdeps='`$ECHO \"$postdeps\" | $SED \"$delay_single_quote_subst\"`'\ncompiler_lib_search_path='`$ECHO \"$compiler_lib_search_path\" | $SED \"$delay_single_quote_subst\"`'\nLD_CXX='`$ECHO \"$LD_CXX\" | $SED \"$delay_single_quote_subst\"`'\nreload_flag_CXX='`$ECHO \"$reload_flag_CXX\" | $SED \"$delay_single_quote_subst\"`'\nreload_cmds_CXX='`$ECHO \"$reload_cmds_CXX\" | $SED \"$delay_single_quote_subst\"`'\nold_archive_cmds_CXX='`$ECHO \"$old_archive_cmds_CXX\" | $SED \"$delay_single_quote_subst\"`'\ncompiler_CXX='`$ECHO \"$compiler_CXX\" | $SED \"$delay_single_quote_subst\"`'\nGCC_CXX='`$ECHO \"$GCC_CXX\" | $SED \"$delay_single_quote_subst\"`'\nlt_prog_compiler_no_builtin_flag_CXX='`$ECHO \"$lt_prog_compiler_no_builtin_flag_CXX\" | $SED \"$delay_single_quote_subst\"`'\nlt_prog_compiler_pic_CXX='`$ECHO \"$lt_prog_compiler_pic_CXX\" | $SED \"$delay_single_quote_subst\"`'\nlt_prog_compiler_wl_CXX='`$ECHO \"$lt_prog_compiler_wl_CXX\" | $SED \"$delay_single_quote_subst\"`'\nlt_prog_compiler_static_CXX='`$ECHO \"$lt_prog_compiler_static_CXX\" | $SED \"$delay_single_quote_subst\"`'\nlt_cv_prog_compiler_c_o_CXX='`$ECHO \"$lt_cv_prog_compiler_c_o_CXX\" | $SED \"$delay_single_quote_subst\"`'\narchive_cmds_need_lc_CXX='`$ECHO \"$archive_cmds_need_lc_CXX\" | $SED \"$delay_single_quote_subst\"`'\nenable_shared_with_static_runtimes_CXX='`$ECHO \"$enable_shared_with_static_runtimes_CXX\" | $SED \"$delay_single_quote_subst\"`'\nexport_dynamic_flag_spec_CXX='`$ECHO \"$export_dynamic_flag_spec_CXX\" | $SED \"$delay_single_quote_subst\"`'\nwhole_archive_flag_spec_CXX='`$ECHO \"$whole_archive_flag_spec_CXX\" | $SED \"$delay_single_quote_subst\"`'\ncompiler_needs_object_CXX='`$ECHO \"$compiler_needs_object_CXX\" | $SED \"$delay_single_quote_subst\"`'\nold_archive_from_new_cmds_CXX='`$ECHO \"$old_archive_from_new_cmds_CXX\" | $SED \"$delay_single_quote_subst\"`'\nold_archive_from_expsyms_cmds_CXX='`$ECHO \"$old_archive_from_expsyms_cmds_CXX\" | $SED \"$delay_single_quote_subst\"`'\narchive_cmds_CXX='`$ECHO \"$archive_cmds_CXX\" | $SED \"$delay_single_quote_subst\"`'\narchive_expsym_cmds_CXX='`$ECHO \"$archive_expsym_cmds_CXX\" | $SED \"$delay_single_quote_subst\"`'\nmodule_cmds_CXX='`$ECHO \"$module_cmds_CXX\" | $SED \"$delay_single_quote_subst\"`'\nmodule_expsym_cmds_CXX='`$ECHO \"$module_expsym_cmds_CXX\" | $SED \"$delay_single_quote_subst\"`'\nwith_gnu_ld_CXX='`$ECHO \"$with_gnu_ld_CXX\" | $SED \"$delay_single_quote_subst\"`'\nallow_undefined_flag_CXX='`$ECHO \"$allow_undefined_flag_CXX\" | $SED \"$delay_single_quote_subst\"`'\nno_undefined_flag_CXX='`$ECHO \"$no_undefined_flag_CXX\" | $SED \"$delay_single_quote_subst\"`'\nhardcode_libdir_flag_spec_CXX='`$ECHO \"$hardcode_libdir_flag_spec_CXX\" | $SED \"$delay_single_quote_subst\"`'\nhardcode_libdir_separator_CXX='`$ECHO \"$hardcode_libdir_separator_CXX\" | $SED \"$delay_single_quote_subst\"`'\nhardcode_direct_CXX='`$ECHO \"$hardcode_direct_CXX\" | $SED \"$delay_single_quote_subst\"`'\nhardcode_direct_absolute_CXX='`$ECHO \"$hardcode_direct_absolute_CXX\" | $SED \"$delay_single_quote_subst\"`'\nhardcode_minus_L_CXX='`$ECHO \"$hardcode_minus_L_CXX\" | $SED \"$delay_single_quote_subst\"`'\nhardcode_shlibpath_var_CXX='`$ECHO \"$hardcode_shlibpath_var_CXX\" | $SED \"$delay_single_quote_subst\"`'\nhardcode_automatic_CXX='`$ECHO \"$hardcode_automatic_CXX\" | $SED \"$delay_single_quote_subst\"`'\ninherit_rpath_CXX='`$ECHO \"$inherit_rpath_CXX\" | $SED \"$delay_single_quote_subst\"`'\nlink_all_deplibs_CXX='`$ECHO \"$link_all_deplibs_CXX\" | $SED \"$delay_single_quote_subst\"`'\nalways_export_symbols_CXX='`$ECHO \"$always_export_symbols_CXX\" | $SED \"$delay_single_quote_subst\"`'\nexport_symbols_cmds_CXX='`$ECHO \"$export_symbols_cmds_CXX\" | $SED \"$delay_single_quote_subst\"`'\nexclude_expsyms_CXX='`$ECHO \"$exclude_expsyms_CXX\" | $SED \"$delay_single_quote_subst\"`'\ninclude_expsyms_CXX='`$ECHO \"$include_expsyms_CXX\" | $SED \"$delay_single_quote_subst\"`'\nprelink_cmds_CXX='`$ECHO \"$prelink_cmds_CXX\" | $SED \"$delay_single_quote_subst\"`'\npostlink_cmds_CXX='`$ECHO \"$postlink_cmds_CXX\" | $SED \"$delay_single_quote_subst\"`'\nfile_list_spec_CXX='`$ECHO \"$file_list_spec_CXX\" | $SED \"$delay_single_quote_subst\"`'\nhardcode_action_CXX='`$ECHO \"$hardcode_action_CXX\" | $SED \"$delay_single_quote_subst\"`'\ncompiler_lib_search_dirs_CXX='`$ECHO \"$compiler_lib_search_dirs_CXX\" | $SED \"$delay_single_quote_subst\"`'\npredep_objects_CXX='`$ECHO \"$predep_objects_CXX\" | $SED \"$delay_single_quote_subst\"`'\npostdep_objects_CXX='`$ECHO \"$postdep_objects_CXX\" | $SED \"$delay_single_quote_subst\"`'\npredeps_CXX='`$ECHO \"$predeps_CXX\" | $SED \"$delay_single_quote_subst\"`'\npostdeps_CXX='`$ECHO \"$postdeps_CXX\" | $SED \"$delay_single_quote_subst\"`'\ncompiler_lib_search_path_CXX='`$ECHO \"$compiler_lib_search_path_CXX\" | $SED \"$delay_single_quote_subst\"`'\n\nLTCC='$LTCC'\nLTCFLAGS='$LTCFLAGS'\ncompiler='$compiler_DEFAULT'\n\n# A function that is used when there is no print builtin or printf.\nfunc_fallback_echo ()\n{\n  eval 'cat <<_LTECHO_EOF\n\\$1\n_LTECHO_EOF'\n}\n\n# Quote evaled strings.\nfor var in SHELL \\\nECHO \\\nPATH_SEPARATOR \\\nSED \\\nGREP \\\nEGREP \\\nFGREP \\\nLD \\\nNM \\\nLN_S \\\nlt_SP2NL \\\nlt_NL2SP \\\nreload_flag \\\nOBJDUMP \\\ndeplibs_check_method \\\nfile_magic_cmd \\\nfile_magic_glob \\\nwant_nocaseglob \\\nDLLTOOL \\\nsharedlib_from_linklib_cmd \\\nAR \\\nAR_FLAGS \\\narchiver_list_spec \\\nSTRIP \\\nRANLIB \\\nCC \\\nCFLAGS \\\ncompiler \\\nlt_cv_sys_global_symbol_pipe \\\nlt_cv_sys_global_symbol_to_cdecl \\\nlt_cv_sys_global_symbol_to_c_name_address \\\nlt_cv_sys_global_symbol_to_c_name_address_lib_prefix \\\nnm_file_list_spec \\\nlt_prog_compiler_no_builtin_flag \\\nlt_prog_compiler_pic \\\nlt_prog_compiler_wl \\\nlt_prog_compiler_static \\\nlt_cv_prog_compiler_c_o \\\nneed_locks \\\nMANIFEST_TOOL \\\nDSYMUTIL \\\nNMEDIT \\\nLIPO \\\nOTOOL \\\nOTOOL64 \\\nshrext_cmds \\\nexport_dynamic_flag_spec \\\nwhole_archive_flag_spec \\\ncompiler_needs_object \\\nwith_gnu_ld \\\nallow_undefined_flag \\\nno_undefined_flag \\\nhardcode_libdir_flag_spec \\\nhardcode_libdir_separator \\\nexclude_expsyms \\\ninclude_expsyms \\\nfile_list_spec \\\nvariables_saved_for_relink \\\nlibname_spec \\\nlibrary_names_spec \\\nsoname_spec \\\ninstall_override_mode \\\nfinish_eval \\\nold_striplib \\\nstriplib \\\ncompiler_lib_search_dirs \\\npredep_objects \\\npostdep_objects \\\npredeps \\\npostdeps \\\ncompiler_lib_search_path \\\nLD_CXX \\\nreload_flag_CXX \\\ncompiler_CXX \\\nlt_prog_compiler_no_builtin_flag_CXX \\\nlt_prog_compiler_pic_CXX \\\nlt_prog_compiler_wl_CXX \\\nlt_prog_compiler_static_CXX \\\nlt_cv_prog_compiler_c_o_CXX \\\nexport_dynamic_flag_spec_CXX \\\nwhole_archive_flag_spec_CXX \\\ncompiler_needs_object_CXX \\\nwith_gnu_ld_CXX \\\nallow_undefined_flag_CXX \\\nno_undefined_flag_CXX \\\nhardcode_libdir_flag_spec_CXX \\\nhardcode_libdir_separator_CXX \\\nexclude_expsyms_CXX \\\ninclude_expsyms_CXX \\\nfile_list_spec_CXX \\\ncompiler_lib_search_dirs_CXX \\\npredep_objects_CXX \\\npostdep_objects_CXX \\\npredeps_CXX \\\npostdeps_CXX \\\ncompiler_lib_search_path_CXX; do\n    case \\`eval \\\\\\\\\\$ECHO \\\\\\\\\"\"\\\\\\\\\\$\\$var\"\\\\\\\\\"\\` in\n    *[\\\\\\\\\\\\\\`\\\\\"\\\\\\$]*)\n      eval \"lt_\\$var=\\\\\\\\\\\\\"\\\\\\`\\\\\\$ECHO \\\\\"\\\\\\$\\$var\\\\\" | \\\\\\$SED \\\\\"\\\\\\$sed_quote_subst\\\\\"\\\\\\`\\\\\\\\\\\\\"\"\n      ;;\n    *)\n      eval \"lt_\\$var=\\\\\\\\\\\\\"\\\\\\$\\$var\\\\\\\\\\\\\"\"\n      ;;\n    esac\ndone\n\n# Double-quote double-evaled strings.\nfor var in reload_cmds \\\nold_postinstall_cmds \\\nold_postuninstall_cmds \\\nold_archive_cmds \\\nextract_expsyms_cmds \\\nold_archive_from_new_cmds \\\nold_archive_from_expsyms_cmds \\\narchive_cmds \\\narchive_expsym_cmds \\\nmodule_cmds \\\nmodule_expsym_cmds \\\nexport_symbols_cmds \\\nprelink_cmds \\\npostlink_cmds \\\npostinstall_cmds \\\npostuninstall_cmds \\\nfinish_cmds \\\nsys_lib_search_path_spec \\\nsys_lib_dlsearch_path_spec \\\nreload_cmds_CXX \\\nold_archive_cmds_CXX \\\nold_archive_from_new_cmds_CXX \\\nold_archive_from_expsyms_cmds_CXX \\\narchive_cmds_CXX \\\narchive_expsym_cmds_CXX \\\nmodule_cmds_CXX \\\nmodule_expsym_cmds_CXX \\\nexport_symbols_cmds_CXX \\\nprelink_cmds_CXX \\\npostlink_cmds_CXX; do\n    case \\`eval \\\\\\\\\\$ECHO \\\\\\\\\"\"\\\\\\\\\\$\\$var\"\\\\\\\\\"\\` in\n    *[\\\\\\\\\\\\\\`\\\\\"\\\\\\$]*)\n      eval \"lt_\\$var=\\\\\\\\\\\\\"\\\\\\`\\\\\\$ECHO \\\\\"\\\\\\$\\$var\\\\\" | \\\\\\$SED -e \\\\\"\\\\\\$double_quote_subst\\\\\" -e \\\\\"\\\\\\$sed_quote_subst\\\\\" -e \\\\\"\\\\\\$delay_variable_subst\\\\\"\\\\\\`\\\\\\\\\\\\\"\"\n      ;;\n    *)\n      eval \"lt_\\$var=\\\\\\\\\\\\\"\\\\\\$\\$var\\\\\\\\\\\\\"\"\n      ;;\n    esac\ndone\n\nac_aux_dir='$ac_aux_dir'\nxsi_shell='$xsi_shell'\nlt_shell_append='$lt_shell_append'\n\n# See if we are running on zsh, and set the options which allow our\n# commands through without removal of \\ escapes INIT.\nif test -n \"\\${ZSH_VERSION+set}\" ; then\n   setopt NO_GLOB_SUBST\nfi\n\n\n    PACKAGE='$PACKAGE'\n    VERSION='$VERSION'\n    TIMESTAMP='$TIMESTAMP'\n    RM='$RM'\n    ofile='$ofile'\n\n\n\n\n\n\n_ACEOF\n\ncat >>$CONFIG_STATUS <<\\_ACEOF || ac_write_fail=1\n\n# Handling of arguments.\nfor ac_config_target in $ac_config_targets\ndo\n  case $ac_config_target in\n    \"config.h\") CONFIG_HEADERS=\"$CONFIG_HEADERS config.h\" ;;\n    \"depfiles\") CONFIG_COMMANDS=\"$CONFIG_COMMANDS depfiles\" ;;\n    \"libtool\") CONFIG_COMMANDS=\"$CONFIG_COMMANDS libtool\" ;;\n    \"Makefile\") CONFIG_FILES=\"$CONFIG_FILES Makefile\" ;;\n    \"src/Makefile\") CONFIG_FILES=\"$CONFIG_FILES src/Makefile\" ;;\n    \"benchmarks/Makefile\") CONFIG_FILES=\"$CONFIG_FILES benchmarks/Makefile\" ;;\n    \"conformance/Makefile\") CONFIG_FILES=\"$CONFIG_FILES conformance/Makefile\" ;;\n    \"protobuf.pc\") CONFIG_FILES=\"$CONFIG_FILES protobuf.pc\" ;;\n    \"protobuf-lite.pc\") CONFIG_FILES=\"$CONFIG_FILES protobuf-lite.pc\" ;;\n\n  *) as_fn_error $? \"invalid argument: \\`$ac_config_target'\" \"$LINENO\" 5;;\n  esac\ndone\n\n\n# If the user did not use the arguments to specify the items to instantiate,\n# then the envvar interface is used.  Set only those that are not.\n# We use the long form for the default assignment because of an extremely\n# bizarre bug on SunOS 4.1.3.\nif $ac_need_defaults; then\n  test \"${CONFIG_FILES+set}\" = set || CONFIG_FILES=$config_files\n  test \"${CONFIG_HEADERS+set}\" = set || CONFIG_HEADERS=$config_headers\n  test \"${CONFIG_COMMANDS+set}\" = set || CONFIG_COMMANDS=$config_commands\nfi\n\n# Have a temporary directory for convenience.  Make it in the build tree\n# simply because there is no reason against having it here, and in addition,\n# creating and moving files from /tmp can sometimes cause problems.\n# Hook for its removal unless debugging.\n# Note that there is a small window in which the directory will not be cleaned:\n# after its creation but before its name has been assigned to `$tmp'.\n$debug ||\n{\n  tmp= ac_tmp=\n  trap 'exit_status=$?\n  : \"${ac_tmp:=$tmp}\"\n  { test ! -d \"$ac_tmp\" || rm -fr \"$ac_tmp\"; } && exit $exit_status\n' 0\n  trap 'as_fn_exit 1' 1 2 13 15\n}\n# Create a (secure) tmp directory for tmp files.\n\n{\n  tmp=`(umask 077 && mktemp -d \"./confXXXXXX\") 2>/dev/null` &&\n  test -d \"$tmp\"\n}  ||\n{\n  tmp=./conf$$-$RANDOM\n  (umask 077 && mkdir \"$tmp\")\n} || as_fn_error $? \"cannot create a temporary directory in .\" \"$LINENO\" 5\nac_tmp=$tmp\n\n# Set up the scripts for CONFIG_FILES section.\n# No need to generate them if there are no CONFIG_FILES.\n# This happens for instance with `./config.status config.h'.\nif test -n \"$CONFIG_FILES\"; then\n\n\nac_cr=`echo X | tr X '\\015'`\n# On cygwin, bash can eat \\r inside `` if the user requested igncr.\n# But we know of no other shell where ac_cr would be empty at this\n# point, so we can use a bashism as a fallback.\nif test \"x$ac_cr\" = x; then\n  eval ac_cr=\\$\\'\\\\r\\'\nfi\nac_cs_awk_cr=`$AWK 'BEGIN { print \"a\\rb\" }' </dev/null 2>/dev/null`\nif test \"$ac_cs_awk_cr\" = \"a${ac_cr}b\"; then\n  ac_cs_awk_cr='\\\\r'\nelse\n  ac_cs_awk_cr=$ac_cr\nfi\n\necho 'BEGIN {' >\"$ac_tmp/subs1.awk\" &&\n_ACEOF\n\n\n{\n  echo \"cat >conf$$subs.awk <<_ACEOF\" &&\n  echo \"$ac_subst_vars\" | sed 's/.*/&!$&$ac_delim/' &&\n  echo \"_ACEOF\"\n} >conf$$subs.sh ||\n  as_fn_error $? \"could not make $CONFIG_STATUS\" \"$LINENO\" 5\nac_delim_num=`echo \"$ac_subst_vars\" | grep -c '^'`\nac_delim='%!_!# '\nfor ac_last_try in false false false false false :; do\n  . ./conf$$subs.sh ||\n    as_fn_error $? \"could not make $CONFIG_STATUS\" \"$LINENO\" 5\n\n  ac_delim_n=`sed -n \"s/.*$ac_delim\\$/X/p\" conf$$subs.awk | grep -c X`\n  if test $ac_delim_n = $ac_delim_num; then\n    break\n  elif $ac_last_try; then\n    as_fn_error $? \"could not make $CONFIG_STATUS\" \"$LINENO\" 5\n  else\n    ac_delim=\"$ac_delim!$ac_delim _$ac_delim!! \"\n  fi\ndone\nrm -f conf$$subs.sh\n\ncat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1\ncat >>\"\\$ac_tmp/subs1.awk\" <<\\\\_ACAWK &&\n_ACEOF\nsed -n '\nh\ns/^/S[\"/; s/!.*/\"]=/\np\ng\ns/^[^!]*!//\n:repl\nt repl\ns/'\"$ac_delim\"'$//\nt delim\n:nl\nh\ns/\\(.\\{148\\}\\)..*/\\1/\nt more1\ns/[\"\\\\]/\\\\&/g; s/^/\"/; s/$/\\\\n\"\\\\/\np\nn\nb repl\n:more1\ns/[\"\\\\]/\\\\&/g; s/^/\"/; s/$/\"\\\\/\np\ng\ns/.\\{148\\}//\nt nl\n:delim\nh\ns/\\(.\\{148\\}\\)..*/\\1/\nt more2\ns/[\"\\\\]/\\\\&/g; s/^/\"/; s/$/\"/\np\nb\n:more2\ns/[\"\\\\]/\\\\&/g; s/^/\"/; s/$/\"\\\\/\np\ng\ns/.\\{148\\}//\nt delim\n' <conf$$subs.awk | sed '\n/^[^\"\"]/{\n  N\n  s/\\n//\n}\n' >>$CONFIG_STATUS || ac_write_fail=1\nrm -f conf$$subs.awk\ncat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1\n_ACAWK\ncat >>\"\\$ac_tmp/subs1.awk\" <<_ACAWK &&\n  for (key in S) S_is_set[key] = 1\n  FS = \"\u0007\"\n\n}\n{\n  line = $ 0\n  nfields = split(line, field, \"@\")\n  substed = 0\n  len = length(field[1])\n  for (i = 2; i < nfields; i++) {\n    key = field[i]\n    keylen = length(key)\n    if (S_is_set[key]) {\n      value = S[key]\n      line = substr(line, 1, len) \"\" value \"\" substr(line, len + keylen + 3)\n      len += length(value) + length(field[++i])\n      substed = 1\n    } else\n      len += 1 + keylen\n  }\n\n  print line\n}\n\n_ACAWK\n_ACEOF\ncat >>$CONFIG_STATUS <<\\_ACEOF || ac_write_fail=1\nif sed \"s/$ac_cr//\" < /dev/null > /dev/null 2>&1; then\n  sed \"s/$ac_cr\\$//; s/$ac_cr/$ac_cs_awk_cr/g\"\nelse\n  cat\nfi < \"$ac_tmp/subs1.awk\" > \"$ac_tmp/subs.awk\" \\\n  || as_fn_error $? \"could not setup config files machinery\" \"$LINENO\" 5\n_ACEOF\n\n# VPATH may cause trouble with some makes, so we remove sole $(srcdir),\n# ${srcdir} and @srcdir@ entries from VPATH if srcdir is \".\", strip leading and\n# trailing colons and then remove the whole line if VPATH becomes empty\n# (actually we leave an empty line to preserve line numbers).\nif test \"x$srcdir\" = x.; then\n  ac_vpsub='/^[\t ]*VPATH[\t ]*=[\t ]*/{\nh\ns///\ns/^/:/\ns/[\t ]*$/:/\ns/:\\$(srcdir):/:/g\ns/:\\${srcdir}:/:/g\ns/:@srcdir@:/:/g\ns/^:*//\ns/:*$//\nx\ns/\\(=[\t ]*\\).*/\\1/\nG\ns/\\n//\ns/^[^=]*=[\t ]*$//\n}'\nfi\n\ncat >>$CONFIG_STATUS <<\\_ACEOF || ac_write_fail=1\nfi # test -n \"$CONFIG_FILES\"\n\n# Set up the scripts for CONFIG_HEADERS section.\n# No need to generate them if there are no CONFIG_HEADERS.\n# This happens for instance with `./config.status Makefile'.\nif test -n \"$CONFIG_HEADERS\"; then\ncat >\"$ac_tmp/defines.awk\" <<\\_ACAWK ||\nBEGIN {\n_ACEOF\n\n# Transform confdefs.h into an awk script `defines.awk', embedded as\n# here-document in config.status, that substitutes the proper values into\n# config.h.in to produce config.h.\n\n# Create a delimiter string that does not exist in confdefs.h, to ease\n# handling of long lines.\nac_delim='%!_!# '\nfor ac_last_try in false false :; do\n  ac_tt=`sed -n \"/$ac_delim/p\" confdefs.h`\n  if test -z \"$ac_tt\"; then\n    break\n  elif $ac_last_try; then\n    as_fn_error $? \"could not make $CONFIG_HEADERS\" \"$LINENO\" 5\n  else\n    ac_delim=\"$ac_delim!$ac_delim _$ac_delim!! \"\n  fi\ndone\n\n# For the awk script, D is an array of macro values keyed by name,\n# likewise P contains macro parameters if any.  Preserve backslash\n# newline sequences.\n\nac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*\nsed -n '\ns/.\\{148\\}/&'\"$ac_delim\"'/g\nt rset\n:rset\ns/^[\t ]*#[\t ]*define[\t ][\t ]*/ /\nt def\nd\n:def\ns/\\\\$//\nt bsnl\ns/[\"\\\\]/\\\\&/g\ns/^ \\('\"$ac_word_re\"'\\)\\(([^()]*)\\)[\t ]*\\(.*\\)/P[\"\\1\"]=\"\\2\"\\\nD[\"\\1\"]=\" \\3\"/p\ns/^ \\('\"$ac_word_re\"'\\)[\t ]*\\(.*\\)/D[\"\\1\"]=\" \\2\"/p\nd\n:bsnl\ns/[\"\\\\]/\\\\&/g\ns/^ \\('\"$ac_word_re\"'\\)\\(([^()]*)\\)[\t ]*\\(.*\\)/P[\"\\1\"]=\"\\2\"\\\nD[\"\\1\"]=\" \\3\\\\\\\\\\\\n\"\\\\/p\nt cont\ns/^ \\('\"$ac_word_re\"'\\)[\t ]*\\(.*\\)/D[\"\\1\"]=\" \\2\\\\\\\\\\\\n\"\\\\/p\nt cont\nd\n:cont\nn\ns/.\\{148\\}/&'\"$ac_delim\"'/g\nt clear\n:clear\ns/\\\\$//\nt bsnlc\ns/[\"\\\\]/\\\\&/g; s/^/\"/; s/$/\"/p\nd\n:bsnlc\ns/[\"\\\\]/\\\\&/g; s/^/\"/; s/$/\\\\\\\\\\\\n\"\\\\/p\nb cont\n' <confdefs.h | sed '\ns/'\"$ac_delim\"'/\"\\\\\\\n\"/g' >>$CONFIG_STATUS || ac_write_fail=1\n\ncat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1\n  for (key in D) D_is_set[key] = 1\n  FS = \"\u0007\"\n}\n/^[\\t ]*#[\\t ]*(define|undef)[\\t ]+$ac_word_re([\\t (]|\\$)/ {\n  line = \\$ 0\n  split(line, arg, \" \")\n  if (arg[1] == \"#\") {\n    defundef = arg[2]\n    mac1 = arg[3]\n  } else {\n    defundef = substr(arg[1], 2)\n    mac1 = arg[2]\n  }\n  split(mac1, mac2, \"(\") #)\n  macro = mac2[1]\n  prefix = substr(line, 1, index(line, defundef) - 1)\n  if (D_is_set[macro]) {\n    # Preserve the white space surrounding the \"#\".\n    print prefix \"define\", macro P[macro] D[macro]\n    next\n  } else {\n    # Replace #undef with comments.  This is necessary, for example,\n    # in the case of _POSIX_SOURCE, which is predefined and required\n    # on some systems where configure will not decide to define it.\n    if (defundef == \"undef\") {\n      print \"/*\", prefix defundef, macro, \"*/\"\n      next\n    }\n  }\n}\n{ print }\n_ACAWK\n_ACEOF\ncat >>$CONFIG_STATUS <<\\_ACEOF || ac_write_fail=1\n  as_fn_error $? \"could not setup config headers machinery\" \"$LINENO\" 5\nfi # test -n \"$CONFIG_HEADERS\"\n\n\neval set X \"  :F $CONFIG_FILES  :H $CONFIG_HEADERS    :C $CONFIG_COMMANDS\"\nshift\nfor ac_tag\ndo\n  case $ac_tag in\n  :[FHLC]) ac_mode=$ac_tag; continue;;\n  esac\n  case $ac_mode$ac_tag in\n  :[FHL]*:*);;\n  :L* | :C*:*) as_fn_error $? \"invalid tag \\`$ac_tag'\" \"$LINENO\" 5;;\n  :[FH]-) ac_tag=-:-;;\n  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;\n  esac\n  ac_save_IFS=$IFS\n  IFS=:\n  set x $ac_tag\n  IFS=$ac_save_IFS\n  shift\n  ac_file=$1\n  shift\n\n  case $ac_mode in\n  :L) ac_source=$1;;\n  :[FH])\n    ac_file_inputs=\n    for ac_f\n    do\n      case $ac_f in\n      -) ac_f=\"$ac_tmp/stdin\";;\n      *) # Look for the file first in the build tree, then in the source tree\n\t # (if the path is not absolute).  The absolute path cannot be DOS-style,\n\t # because $ac_f cannot contain `:'.\n\t test -f \"$ac_f\" ||\n\t   case $ac_f in\n\t   [\\\\/$]*) false;;\n\t   *) test -f \"$srcdir/$ac_f\" && ac_f=\"$srcdir/$ac_f\";;\n\t   esac ||\n\t   as_fn_error 1 \"cannot find input file: \\`$ac_f'\" \"$LINENO\" 5;;\n      esac\n      case $ac_f in *\\'*) ac_f=`$as_echo \"$ac_f\" | sed \"s/'/'\\\\\\\\\\\\\\\\''/g\"`;; esac\n      as_fn_append ac_file_inputs \" '$ac_f'\"\n    done\n\n    # Let's still pretend it is `configure' which instantiates (i.e., don't\n    # use $as_me), people would be surprised to read:\n    #    /* config.h.  Generated by config.status.  */\n    configure_input='Generated from '`\n\t  $as_echo \"$*\" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'\n\t`' by configure.'\n    if test x\"$ac_file\" != x-; then\n      configure_input=\"$ac_file.  $configure_input\"\n      { $as_echo \"$as_me:${as_lineno-$LINENO}: creating $ac_file\" >&5\n$as_echo \"$as_me: creating $ac_file\" >&6;}\n    fi\n    # Neutralize special characters interpreted by sed in replacement strings.\n    case $configure_input in #(\n    *\\&* | *\\|* | *\\\\* )\n       ac_sed_conf_input=`$as_echo \"$configure_input\" |\n       sed 's/[\\\\\\\\&|]/\\\\\\\\&/g'`;; #(\n    *) ac_sed_conf_input=$configure_input;;\n    esac\n\n    case $ac_tag in\n    *:-:* | *:-) cat >\"$ac_tmp/stdin\" \\\n      || as_fn_error $? \"could not create $ac_file\" \"$LINENO\" 5 ;;\n    esac\n    ;;\n  esac\n\n  ac_dir=`$as_dirname -- \"$ac_file\" ||\n$as_expr X\"$ac_file\" : 'X\\(.*[^/]\\)//*[^/][^/]*/*$' \\| \\\n\t X\"$ac_file\" : 'X\\(//\\)[^/]' \\| \\\n\t X\"$ac_file\" : 'X\\(//\\)$' \\| \\\n\t X\"$ac_file\" : 'X\\(/\\)' \\| . 2>/dev/null ||\n$as_echo X\"$ac_file\" |\n    sed '/^X\\(.*[^/]\\)\\/\\/*[^/][^/]*\\/*$/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\(\\/\\/\\)[^/].*/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\(\\/\\/\\)$/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\(\\/\\).*/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  s/.*/./; q'`\n  as_dir=\"$ac_dir\"; as_fn_mkdir_p\n  ac_builddir=.\n\ncase \"$ac_dir\" in\n.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;\n*)\n  ac_dir_suffix=/`$as_echo \"$ac_dir\" | sed 's|^\\.[\\\\/]||'`\n  # A \"..\" for each directory in $ac_dir_suffix.\n  ac_top_builddir_sub=`$as_echo \"$ac_dir_suffix\" | sed 's|/[^\\\\/]*|/..|g;s|/||'`\n  case $ac_top_builddir_sub in\n  \"\") ac_top_builddir_sub=. ac_top_build_prefix= ;;\n  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;\n  esac ;;\nesac\nac_abs_top_builddir=$ac_pwd\nac_abs_builddir=$ac_pwd$ac_dir_suffix\n# for backward compatibility:\nac_top_builddir=$ac_top_build_prefix\n\ncase $srcdir in\n  .)  # We are building in place.\n    ac_srcdir=.\n    ac_top_srcdir=$ac_top_builddir_sub\n    ac_abs_top_srcdir=$ac_pwd ;;\n  [\\\\/]* | ?:[\\\\/]* )  # Absolute name.\n    ac_srcdir=$srcdir$ac_dir_suffix;\n    ac_top_srcdir=$srcdir\n    ac_abs_top_srcdir=$srcdir ;;\n  *) # Relative name.\n    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix\n    ac_top_srcdir=$ac_top_build_prefix$srcdir\n    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;\nesac\nac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix\n\n\n  case $ac_mode in\n  :F)\n  #\n  # CONFIG_FILE\n  #\n\n  case $INSTALL in\n  [\\\\/$]* | ?:[\\\\/]* ) ac_INSTALL=$INSTALL ;;\n  *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;\n  esac\n  ac_MKDIR_P=$MKDIR_P\n  case $MKDIR_P in\n  [\\\\/$]* | ?:[\\\\/]* ) ;;\n  */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;\n  esac\n_ACEOF\n\ncat >>$CONFIG_STATUS <<\\_ACEOF || ac_write_fail=1\n# If the template does not know about datarootdir, expand it.\n# FIXME: This hack should be removed a few years after 2.60.\nac_datarootdir_hack=; ac_datarootdir_seen=\nac_sed_dataroot='\n/datarootdir/ {\n  p\n  q\n}\n/@datadir@/p\n/@docdir@/p\n/@infodir@/p\n/@localedir@/p\n/@mandir@/p'\ncase `eval \"sed -n \\\"\\$ac_sed_dataroot\\\" $ac_file_inputs\"` in\n*datarootdir*) ac_datarootdir_seen=yes;;\n*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting\" >&5\n$as_echo \"$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting\" >&2;}\n_ACEOF\ncat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1\n  ac_datarootdir_hack='\n  s&@datadir@&$datadir&g\n  s&@docdir@&$docdir&g\n  s&@infodir@&$infodir&g\n  s&@localedir@&$localedir&g\n  s&@mandir@&$mandir&g\n  s&\\\\\\${datarootdir}&$datarootdir&g' ;;\nesac\n_ACEOF\n\n# Neutralize VPATH when `$srcdir' = `.'.\n# Shell code in configure.ac might set extrasub.\n# FIXME: do we really want to maintain this feature?\ncat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1\nac_sed_extra=\"$ac_vpsub\n$extrasub\n_ACEOF\ncat >>$CONFIG_STATUS <<\\_ACEOF || ac_write_fail=1\n:t\n/@[a-zA-Z_][a-zA-Z_0-9]*@/!b\ns|@configure_input@|$ac_sed_conf_input|;t t\ns&@top_builddir@&$ac_top_builddir_sub&;t t\ns&@top_build_prefix@&$ac_top_build_prefix&;t t\ns&@srcdir@&$ac_srcdir&;t t\ns&@abs_srcdir@&$ac_abs_srcdir&;t t\ns&@top_srcdir@&$ac_top_srcdir&;t t\ns&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t\ns&@builddir@&$ac_builddir&;t t\ns&@abs_builddir@&$ac_abs_builddir&;t t\ns&@abs_top_builddir@&$ac_abs_top_builddir&;t t\ns&@INSTALL@&$ac_INSTALL&;t t\ns&@MKDIR_P@&$ac_MKDIR_P&;t t\n$ac_datarootdir_hack\n\"\neval sed \\\"\\$ac_sed_extra\\\" \"$ac_file_inputs\" | $AWK -f \"$ac_tmp/subs.awk\" \\\n  >$ac_tmp/out || as_fn_error $? \"could not create $ac_file\" \"$LINENO\" 5\n\ntest -z \"$ac_datarootdir_hack$ac_datarootdir_seen\" &&\n  { ac_out=`sed -n '/\\${datarootdir}/p' \"$ac_tmp/out\"`; test -n \"$ac_out\"; } &&\n  { ac_out=`sed -n '/^[\t ]*datarootdir[\t ]*:*=/p' \\\n      \"$ac_tmp/out\"`; test -z \"$ac_out\"; } &&\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \\`datarootdir'\nwhich seems to be undefined.  Please make sure it is defined\" >&5\n$as_echo \"$as_me: WARNING: $ac_file contains a reference to the variable \\`datarootdir'\nwhich seems to be undefined.  Please make sure it is defined\" >&2;}\n\n  rm -f \"$ac_tmp/stdin\"\n  case $ac_file in\n  -) cat \"$ac_tmp/out\" && rm -f \"$ac_tmp/out\";;\n  *) rm -f \"$ac_file\" && mv \"$ac_tmp/out\" \"$ac_file\";;\n  esac \\\n  || as_fn_error $? \"could not create $ac_file\" \"$LINENO\" 5\n ;;\n  :H)\n  #\n  # CONFIG_HEADER\n  #\n  if test x\"$ac_file\" != x-; then\n    {\n      $as_echo \"/* $configure_input  */\" \\\n      && eval '$AWK -f \"$ac_tmp/defines.awk\"' \"$ac_file_inputs\"\n    } >\"$ac_tmp/config.h\" \\\n      || as_fn_error $? \"could not create $ac_file\" \"$LINENO\" 5\n    if diff \"$ac_file\" \"$ac_tmp/config.h\" >/dev/null 2>&1; then\n      { $as_echo \"$as_me:${as_lineno-$LINENO}: $ac_file is unchanged\" >&5\n$as_echo \"$as_me: $ac_file is unchanged\" >&6;}\n    else\n      rm -f \"$ac_file\"\n      mv \"$ac_tmp/config.h\" \"$ac_file\" \\\n\t|| as_fn_error $? \"could not create $ac_file\" \"$LINENO\" 5\n    fi\n  else\n    $as_echo \"/* $configure_input  */\" \\\n      && eval '$AWK -f \"$ac_tmp/defines.awk\"' \"$ac_file_inputs\" \\\n      || as_fn_error $? \"could not create -\" \"$LINENO\" 5\n  fi\n# Compute \"$ac_file\"'s index in $config_headers.\n_am_arg=\"$ac_file\"\n_am_stamp_count=1\nfor _am_header in $config_headers :; do\n  case $_am_header in\n    $_am_arg | $_am_arg:* )\n      break ;;\n    * )\n      _am_stamp_count=`expr $_am_stamp_count + 1` ;;\n  esac\ndone\necho \"timestamp for $_am_arg\" >`$as_dirname -- \"$_am_arg\" ||\n$as_expr X\"$_am_arg\" : 'X\\(.*[^/]\\)//*[^/][^/]*/*$' \\| \\\n\t X\"$_am_arg\" : 'X\\(//\\)[^/]' \\| \\\n\t X\"$_am_arg\" : 'X\\(//\\)$' \\| \\\n\t X\"$_am_arg\" : 'X\\(/\\)' \\| . 2>/dev/null ||\n$as_echo X\"$_am_arg\" |\n    sed '/^X\\(.*[^/]\\)\\/\\/*[^/][^/]*\\/*$/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\(\\/\\/\\)[^/].*/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\(\\/\\/\\)$/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\(\\/\\).*/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  s/.*/./; q'`/stamp-h$_am_stamp_count\n ;;\n\n  :C)  { $as_echo \"$as_me:${as_lineno-$LINENO}: executing $ac_file commands\" >&5\n$as_echo \"$as_me: executing $ac_file commands\" >&6;}\n ;;\n  esac\n\n\n  case $ac_file$ac_mode in\n    \"depfiles\":C) test x\"$AMDEP_TRUE\" != x\"\" || {\n  # Older Autoconf quotes --file arguments for eval, but not when files\n  # are listed without --file.  Let's play safe and only enable the eval\n  # if we detect the quoting.\n  case $CONFIG_FILES in\n  *\\'*) eval set x \"$CONFIG_FILES\" ;;\n  *)   set x $CONFIG_FILES ;;\n  esac\n  shift\n  for mf\n  do\n    # Strip MF so we end up with the name of the file.\n    mf=`echo \"$mf\" | sed -e 's/:.*$//'`\n    # Check whether this is an Automake generated Makefile or not.\n    # We used to match only the files named 'Makefile.in', but\n    # some people rename them; so instead we look at the file content.\n    # Grep'ing the first line is not enough: some people post-process\n    # each Makefile.in and add a new line on top of each file to say so.\n    # Grep'ing the whole file is not good either: AIX grep has a line\n    # limit of 2048, but all sed's we know have understand at least 4000.\n    if sed -n 's,^#.*generated by automake.*,X,p' \"$mf\" | grep X >/dev/null 2>&1; then\n      dirpart=`$as_dirname -- \"$mf\" ||\n$as_expr X\"$mf\" : 'X\\(.*[^/]\\)//*[^/][^/]*/*$' \\| \\\n\t X\"$mf\" : 'X\\(//\\)[^/]' \\| \\\n\t X\"$mf\" : 'X\\(//\\)$' \\| \\\n\t X\"$mf\" : 'X\\(/\\)' \\| . 2>/dev/null ||\n$as_echo X\"$mf\" |\n    sed '/^X\\(.*[^/]\\)\\/\\/*[^/][^/]*\\/*$/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\(\\/\\/\\)[^/].*/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\(\\/\\/\\)$/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\(\\/\\).*/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  s/.*/./; q'`\n    else\n      continue\n    fi\n    # Extract the definition of DEPDIR, am__include, and am__quote\n    # from the Makefile without running 'make'.\n    DEPDIR=`sed -n 's/^DEPDIR = //p' < \"$mf\"`\n    test -z \"$DEPDIR\" && continue\n    am__include=`sed -n 's/^am__include = //p' < \"$mf\"`\n    test -z \"$am__include\" && continue\n    am__quote=`sed -n 's/^am__quote = //p' < \"$mf\"`\n    # Find all dependency output files, they are included files with\n    # $(DEPDIR) in their names.  We invoke sed twice because it is the\n    # simplest approach to changing $(DEPDIR) to its actual value in the\n    # expansion.\n    for file in `sed -n \"\n      s/^$am__include $am__quote\\(.*(DEPDIR).*\\)$am__quote\"'$/\\1/p' <\"$mf\" | \\\n\t sed -e 's/\\$(DEPDIR)/'\"$DEPDIR\"'/g'`; do\n      # Make sure the directory exists.\n      test -f \"$dirpart/$file\" && continue\n      fdir=`$as_dirname -- \"$file\" ||\n$as_expr X\"$file\" : 'X\\(.*[^/]\\)//*[^/][^/]*/*$' \\| \\\n\t X\"$file\" : 'X\\(//\\)[^/]' \\| \\\n\t X\"$file\" : 'X\\(//\\)$' \\| \\\n\t X\"$file\" : 'X\\(/\\)' \\| . 2>/dev/null ||\n$as_echo X\"$file\" |\n    sed '/^X\\(.*[^/]\\)\\/\\/*[^/][^/]*\\/*$/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\(\\/\\/\\)[^/].*/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\(\\/\\/\\)$/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  /^X\\(\\/\\).*/{\n\t    s//\\1/\n\t    q\n\t  }\n\t  s/.*/./; q'`\n      as_dir=$dirpart/$fdir; as_fn_mkdir_p\n      # echo \"creating $dirpart/$file\"\n      echo '# dummy' > \"$dirpart/$file\"\n    done\n  done\n}\n ;;\n    \"libtool\":C)\n\n    # See if we are running on zsh, and set the options which allow our\n    # commands through without removal of \\ escapes.\n    if test -n \"${ZSH_VERSION+set}\" ; then\n      setopt NO_GLOB_SUBST\n    fi\n\n    cfgfile=\"${ofile}T\"\n    trap \"$RM \\\"$cfgfile\\\"; exit 1\" 1 2 15\n    $RM \"$cfgfile\"\n\n    cat <<_LT_EOF >> \"$cfgfile\"\n#! $SHELL\n\n# `$ECHO \"$ofile\" | sed 's%^.*/%%'` - Provide generalized library-building support services.\n# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION\n# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:\n# NOTE: Changes made to this file will be lost: look at ltmain.sh.\n#\n#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,\n#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software\n#                 Foundation, Inc.\n#   Written by Gordon Matzigkeit, 1996\n#\n#   This file is part of GNU Libtool.\n#\n# GNU Libtool is free software; you can redistribute it and/or\n# modify it under the terms of the GNU General Public License as\n# published by the Free Software Foundation; either version 2 of\n# the License, or (at your option) any later version.\n#\n# As a special exception to the GNU General Public License,\n# if you distribute this file as part of a program or library that\n# is built using GNU Libtool, you may include this file under the\n# same distribution terms that you use for the rest of that program.\n#\n# GNU Libtool is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with GNU Libtool; see the file COPYING.  If not, a copy\n# can be downloaded from http://www.gnu.org/licenses/gpl.html, or\n# obtained by writing to the Free Software Foundation, Inc.,\n# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n\n\n# The names of the tagged configurations supported by this script.\navailable_tags=\"CXX \"\n\n# ### BEGIN LIBTOOL CONFIG\n\n# Which release of libtool.m4 was used?\nmacro_version=$macro_version\nmacro_revision=$macro_revision\n\n# Whether or not to build shared libraries.\nbuild_libtool_libs=$enable_shared\n\n# Whether or not to build static libraries.\nbuild_old_libs=$enable_static\n\n# What type of objects to build.\npic_mode=$pic_mode\n\n# Whether or not to optimize for fast installation.\nfast_install=$enable_fast_install\n\n# Shell to use when invoking shell scripts.\nSHELL=$lt_SHELL\n\n# An echo program that protects backslashes.\nECHO=$lt_ECHO\n\n# The PATH separator for the build system.\nPATH_SEPARATOR=$lt_PATH_SEPARATOR\n\n# The host system.\nhost_alias=$host_alias\nhost=$host\nhost_os=$host_os\n\n# The build system.\nbuild_alias=$build_alias\nbuild=$build\nbuild_os=$build_os\n\n# A sed program that does not truncate output.\nSED=$lt_SED\n\n# Sed that helps us avoid accidentally triggering echo(1) options like -n.\nXsed=\"\\$SED -e 1s/^X//\"\n\n# A grep program that handles long lines.\nGREP=$lt_GREP\n\n# An ERE matcher.\nEGREP=$lt_EGREP\n\n# A literal string matcher.\nFGREP=$lt_FGREP\n\n# A BSD- or MS-compatible name lister.\nNM=$lt_NM\n\n# Whether we need soft or hard links.\nLN_S=$lt_LN_S\n\n# What is the maximum length of a command?\nmax_cmd_len=$max_cmd_len\n\n# Object file suffix (normally \"o\").\nobjext=$ac_objext\n\n# Executable file suffix (normally \"\").\nexeext=$exeext\n\n# whether the shell understands \"unset\".\nlt_unset=$lt_unset\n\n# turn spaces into newlines.\nSP2NL=$lt_lt_SP2NL\n\n# turn newlines into spaces.\nNL2SP=$lt_lt_NL2SP\n\n# convert \\$build file names to \\$host format.\nto_host_file_cmd=$lt_cv_to_host_file_cmd\n\n# convert \\$build files to toolchain format.\nto_tool_file_cmd=$lt_cv_to_tool_file_cmd\n\n# An object symbol dumper.\nOBJDUMP=$lt_OBJDUMP\n\n# Method to check whether dependent libraries are shared objects.\ndeplibs_check_method=$lt_deplibs_check_method\n\n# Command to use when deplibs_check_method = \"file_magic\".\nfile_magic_cmd=$lt_file_magic_cmd\n\n# How to find potential files when deplibs_check_method = \"file_magic\".\nfile_magic_glob=$lt_file_magic_glob\n\n# Find potential files using nocaseglob when deplibs_check_method = \"file_magic\".\nwant_nocaseglob=$lt_want_nocaseglob\n\n# DLL creation program.\nDLLTOOL=$lt_DLLTOOL\n\n# Command to associate shared and link libraries.\nsharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd\n\n# The archiver.\nAR=$lt_AR\n\n# Flags to create an archive.\nAR_FLAGS=$lt_AR_FLAGS\n\n# How to feed a file listing to the archiver.\narchiver_list_spec=$lt_archiver_list_spec\n\n# A symbol stripping program.\nSTRIP=$lt_STRIP\n\n# Commands used to install an old-style archive.\nRANLIB=$lt_RANLIB\nold_postinstall_cmds=$lt_old_postinstall_cmds\nold_postuninstall_cmds=$lt_old_postuninstall_cmds\n\n# Whether to use a lock for old archive extraction.\nlock_old_archive_extraction=$lock_old_archive_extraction\n\n# A C compiler.\nLTCC=$lt_CC\n\n# LTCC compiler flags.\nLTCFLAGS=$lt_CFLAGS\n\n# Take the output of nm and produce a listing of raw symbols and C names.\nglobal_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe\n\n# Transform the output of nm in a proper C declaration.\nglobal_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl\n\n# Transform the output of nm in a C name address pair.\nglobal_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address\n\n# Transform the output of nm in a C name address pair when lib prefix is needed.\nglobal_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix\n\n# Specify filename containing input files for \\$NM.\nnm_file_list_spec=$lt_nm_file_list_spec\n\n# The root where to search for dependent libraries,and in which our libraries should be installed.\nlt_sysroot=$lt_sysroot\n\n# The name of the directory that contains temporary libtool files.\nobjdir=$objdir\n\n# Used to examine libraries when file_magic_cmd begins with \"file\".\nMAGIC_CMD=$MAGIC_CMD\n\n# Must we lock files when doing compilation?\nneed_locks=$lt_need_locks\n\n# Manifest tool.\nMANIFEST_TOOL=$lt_MANIFEST_TOOL\n\n# Tool to manipulate archived DWARF debug symbol files on Mac OS X.\nDSYMUTIL=$lt_DSYMUTIL\n\n# Tool to change global to local symbols on Mac OS X.\nNMEDIT=$lt_NMEDIT\n\n# Tool to manipulate fat objects and archives on Mac OS X.\nLIPO=$lt_LIPO\n\n# ldd/readelf like tool for Mach-O binaries on Mac OS X.\nOTOOL=$lt_OTOOL\n\n# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4.\nOTOOL64=$lt_OTOOL64\n\n# Old archive suffix (normally \"a\").\nlibext=$libext\n\n# Shared library suffix (normally \".so\").\nshrext_cmds=$lt_shrext_cmds\n\n# The commands to extract the exported symbol list from a shared archive.\nextract_expsyms_cmds=$lt_extract_expsyms_cmds\n\n# Variables whose values should be saved in libtool wrapper scripts and\n# restored at link time.\nvariables_saved_for_relink=$lt_variables_saved_for_relink\n\n# Do we need the \"lib\" prefix for modules?\nneed_lib_prefix=$need_lib_prefix\n\n# Do we need a version for libraries?\nneed_version=$need_version\n\n# Library versioning type.\nversion_type=$version_type\n\n# Shared library runtime path variable.\nrunpath_var=$runpath_var\n\n# Shared library path variable.\nshlibpath_var=$shlibpath_var\n\n# Is shlibpath searched before the hard-coded library search path?\nshlibpath_overrides_runpath=$shlibpath_overrides_runpath\n\n# Format of library name prefix.\nlibname_spec=$lt_libname_spec\n\n# List of archive names.  First name is the real one, the rest are links.\n# The last name is the one that the linker finds with -lNAME\nlibrary_names_spec=$lt_library_names_spec\n\n# The coded name of the library, if different from the real name.\nsoname_spec=$lt_soname_spec\n\n# Permission mode override for installation of shared libraries.\ninstall_override_mode=$lt_install_override_mode\n\n# Command to use after installation of a shared archive.\npostinstall_cmds=$lt_postinstall_cmds\n\n# Command to use after uninstallation of a shared archive.\npostuninstall_cmds=$lt_postuninstall_cmds\n\n# Commands used to finish a libtool library installation in a directory.\nfinish_cmds=$lt_finish_cmds\n\n# As \"finish_cmds\", except a single script fragment to be evaled but\n# not shown.\nfinish_eval=$lt_finish_eval\n\n# Whether we should hardcode library paths into libraries.\nhardcode_into_libs=$hardcode_into_libs\n\n# Compile-time system search path for libraries.\nsys_lib_search_path_spec=$lt_sys_lib_search_path_spec\n\n# Run-time system search path for libraries.\nsys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec\n\n# Whether dlopen is supported.\ndlopen_support=$enable_dlopen\n\n# Whether dlopen of programs is supported.\ndlopen_self=$enable_dlopen_self\n\n# Whether dlopen of statically linked programs is supported.\ndlopen_self_static=$enable_dlopen_self_static\n\n# Commands to strip libraries.\nold_striplib=$lt_old_striplib\nstriplib=$lt_striplib\n\n\n# The linker used to build libraries.\nLD=$lt_LD\n\n# How to create reloadable object files.\nreload_flag=$lt_reload_flag\nreload_cmds=$lt_reload_cmds\n\n# Commands used to build an old-style archive.\nold_archive_cmds=$lt_old_archive_cmds\n\n# A language specific compiler.\nCC=$lt_compiler\n\n# Is the compiler the GNU compiler?\nwith_gcc=$GCC\n\n# Compiler flag to turn off builtin functions.\nno_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag\n\n# Additional compiler flags for building library objects.\npic_flag=$lt_lt_prog_compiler_pic\n\n# How to pass a linker flag through the compiler.\nwl=$lt_lt_prog_compiler_wl\n\n# Compiler flag to prevent dynamic linking.\nlink_static_flag=$lt_lt_prog_compiler_static\n\n# Does compiler simultaneously support -c and -o options?\ncompiler_c_o=$lt_lt_cv_prog_compiler_c_o\n\n# Whether or not to add -lc for building shared libraries.\nbuild_libtool_need_lc=$archive_cmds_need_lc\n\n# Whether or not to disallow shared libs when runtime libs are static.\nallow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes\n\n# Compiler flag to allow reflexive dlopens.\nexport_dynamic_flag_spec=$lt_export_dynamic_flag_spec\n\n# Compiler flag to generate shared objects directly from archives.\nwhole_archive_flag_spec=$lt_whole_archive_flag_spec\n\n# Whether the compiler copes with passing no objects directly.\ncompiler_needs_object=$lt_compiler_needs_object\n\n# Create an old-style archive from a shared archive.\nold_archive_from_new_cmds=$lt_old_archive_from_new_cmds\n\n# Create a temporary old-style archive to link instead of a shared archive.\nold_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds\n\n# Commands used to build a shared archive.\narchive_cmds=$lt_archive_cmds\narchive_expsym_cmds=$lt_archive_expsym_cmds\n\n# Commands used to build a loadable module if different from building\n# a shared archive.\nmodule_cmds=$lt_module_cmds\nmodule_expsym_cmds=$lt_module_expsym_cmds\n\n# Whether we are building with GNU ld or not.\nwith_gnu_ld=$lt_with_gnu_ld\n\n# Flag that allows shared libraries with undefined symbols to be built.\nallow_undefined_flag=$lt_allow_undefined_flag\n\n# Flag that enforces no undefined symbols.\nno_undefined_flag=$lt_no_undefined_flag\n\n# Flag to hardcode \\$libdir into a binary during linking.\n# This must work even if \\$libdir does not exist\nhardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec\n\n# Whether we need a single \"-rpath\" flag with a separated argument.\nhardcode_libdir_separator=$lt_hardcode_libdir_separator\n\n# Set to \"yes\" if using DIR/libNAME\\${shared_ext} during linking hardcodes\n# DIR into the resulting binary.\nhardcode_direct=$hardcode_direct\n\n# Set to \"yes\" if using DIR/libNAME\\${shared_ext} during linking hardcodes\n# DIR into the resulting binary and the resulting library dependency is\n# \"absolute\",i.e impossible to change by setting \\${shlibpath_var} if the\n# library is relocated.\nhardcode_direct_absolute=$hardcode_direct_absolute\n\n# Set to \"yes\" if using the -LDIR flag during linking hardcodes DIR\n# into the resulting binary.\nhardcode_minus_L=$hardcode_minus_L\n\n# Set to \"yes\" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR\n# into the resulting binary.\nhardcode_shlibpath_var=$hardcode_shlibpath_var\n\n# Set to \"yes\" if building a shared library automatically hardcodes DIR\n# into the library and all subsequent libraries and executables linked\n# against it.\nhardcode_automatic=$hardcode_automatic\n\n# Set to yes if linker adds runtime paths of dependent libraries\n# to runtime path list.\ninherit_rpath=$inherit_rpath\n\n# Whether libtool must link a program against all its dependency libraries.\nlink_all_deplibs=$link_all_deplibs\n\n# Set to \"yes\" if exported symbols are required.\nalways_export_symbols=$always_export_symbols\n\n# The commands to list exported symbols.\nexport_symbols_cmds=$lt_export_symbols_cmds\n\n# Symbols that should not be listed in the preloaded symbols.\nexclude_expsyms=$lt_exclude_expsyms\n\n# Symbols that must always be exported.\ninclude_expsyms=$lt_include_expsyms\n\n# Commands necessary for linking programs (against libraries) with templates.\nprelink_cmds=$lt_prelink_cmds\n\n# Commands necessary for finishing linking programs.\npostlink_cmds=$lt_postlink_cmds\n\n# Specify filename containing input files.\nfile_list_spec=$lt_file_list_spec\n\n# How to hardcode a shared library path into an executable.\nhardcode_action=$hardcode_action\n\n# The directories searched by this compiler when creating a shared library.\ncompiler_lib_search_dirs=$lt_compiler_lib_search_dirs\n\n# Dependencies to place before and after the objects being linked to\n# create a shared library.\npredep_objects=$lt_predep_objects\npostdep_objects=$lt_postdep_objects\npredeps=$lt_predeps\npostdeps=$lt_postdeps\n\n# The library search path used internally by the compiler when linking\n# a shared library.\ncompiler_lib_search_path=$lt_compiler_lib_search_path\n\n# ### END LIBTOOL CONFIG\n\n_LT_EOF\n\n  case $host_os in\n  aix3*)\n    cat <<\\_LT_EOF >> \"$cfgfile\"\n# AIX sometimes has problems with the GCC collect2 program.  For some\n# reason, if we set the COLLECT_NAMES environment variable, the problems\n# vanish in a puff of smoke.\nif test \"X${COLLECT_NAMES+set}\" != Xset; then\n  COLLECT_NAMES=\n  export COLLECT_NAMES\nfi\n_LT_EOF\n    ;;\n  esac\n\n\nltmain=\"$ac_aux_dir/ltmain.sh\"\n\n\n  # We use sed instead of cat because bash on DJGPP gets confused if\n  # if finds mixed CR/LF and LF-only lines.  Since sed operates in\n  # text mode, it properly converts lines to CR/LF.  This bash problem\n  # is reportedly fixed, but why not run on old versions too?\n  sed '$q' \"$ltmain\" >> \"$cfgfile\" \\\n     || (rm -f \"$cfgfile\"; exit 1)\n\n  if test x\"$xsi_shell\" = xyes; then\n  sed -e '/^func_dirname ()$/,/^} # func_dirname /c\\\nfunc_dirname ()\\\n{\\\n\\    case ${1} in\\\n\\      */*) func_dirname_result=\"${1%/*}${2}\" ;;\\\n\\      *  ) func_dirname_result=\"${3}\" ;;\\\n\\    esac\\\n} # Extended-shell func_dirname implementation' \"$cfgfile\" > $cfgfile.tmp \\\n  && mv -f \"$cfgfile.tmp\" \"$cfgfile\" \\\n    || (rm -f \"$cfgfile\" && cp \"$cfgfile.tmp\" \"$cfgfile\" && rm -f \"$cfgfile.tmp\")\ntest 0 -eq $? || _lt_function_replace_fail=:\n\n\n  sed -e '/^func_basename ()$/,/^} # func_basename /c\\\nfunc_basename ()\\\n{\\\n\\    func_basename_result=\"${1##*/}\"\\\n} # Extended-shell func_basename implementation' \"$cfgfile\" > $cfgfile.tmp \\\n  && mv -f \"$cfgfile.tmp\" \"$cfgfile\" \\\n    || (rm -f \"$cfgfile\" && cp \"$cfgfile.tmp\" \"$cfgfile\" && rm -f \"$cfgfile.tmp\")\ntest 0 -eq $? || _lt_function_replace_fail=:\n\n\n  sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\\\nfunc_dirname_and_basename ()\\\n{\\\n\\    case ${1} in\\\n\\      */*) func_dirname_result=\"${1%/*}${2}\" ;;\\\n\\      *  ) func_dirname_result=\"${3}\" ;;\\\n\\    esac\\\n\\    func_basename_result=\"${1##*/}\"\\\n} # Extended-shell func_dirname_and_basename implementation' \"$cfgfile\" > $cfgfile.tmp \\\n  && mv -f \"$cfgfile.tmp\" \"$cfgfile\" \\\n    || (rm -f \"$cfgfile\" && cp \"$cfgfile.tmp\" \"$cfgfile\" && rm -f \"$cfgfile.tmp\")\ntest 0 -eq $? || _lt_function_replace_fail=:\n\n\n  sed -e '/^func_stripname ()$/,/^} # func_stripname /c\\\nfunc_stripname ()\\\n{\\\n\\    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\\\n\\    # positional parameters, so assign one to ordinary parameter first.\\\n\\    func_stripname_result=${3}\\\n\\    func_stripname_result=${func_stripname_result#\"${1}\"}\\\n\\    func_stripname_result=${func_stripname_result%\"${2}\"}\\\n} # Extended-shell func_stripname implementation' \"$cfgfile\" > $cfgfile.tmp \\\n  && mv -f \"$cfgfile.tmp\" \"$cfgfile\" \\\n    || (rm -f \"$cfgfile\" && cp \"$cfgfile.tmp\" \"$cfgfile\" && rm -f \"$cfgfile.tmp\")\ntest 0 -eq $? || _lt_function_replace_fail=:\n\n\n  sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\\\nfunc_split_long_opt ()\\\n{\\\n\\    func_split_long_opt_name=${1%%=*}\\\n\\    func_split_long_opt_arg=${1#*=}\\\n} # Extended-shell func_split_long_opt implementation' \"$cfgfile\" > $cfgfile.tmp \\\n  && mv -f \"$cfgfile.tmp\" \"$cfgfile\" \\\n    || (rm -f \"$cfgfile\" && cp \"$cfgfile.tmp\" \"$cfgfile\" && rm -f \"$cfgfile.tmp\")\ntest 0 -eq $? || _lt_function_replace_fail=:\n\n\n  sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\\\nfunc_split_short_opt ()\\\n{\\\n\\    func_split_short_opt_arg=${1#??}\\\n\\    func_split_short_opt_name=${1%\"$func_split_short_opt_arg\"}\\\n} # Extended-shell func_split_short_opt implementation' \"$cfgfile\" > $cfgfile.tmp \\\n  && mv -f \"$cfgfile.tmp\" \"$cfgfile\" \\\n    || (rm -f \"$cfgfile\" && cp \"$cfgfile.tmp\" \"$cfgfile\" && rm -f \"$cfgfile.tmp\")\ntest 0 -eq $? || _lt_function_replace_fail=:\n\n\n  sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\\\nfunc_lo2o ()\\\n{\\\n\\    case ${1} in\\\n\\      *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\\\n\\      *)    func_lo2o_result=${1} ;;\\\n\\    esac\\\n} # Extended-shell func_lo2o implementation' \"$cfgfile\" > $cfgfile.tmp \\\n  && mv -f \"$cfgfile.tmp\" \"$cfgfile\" \\\n    || (rm -f \"$cfgfile\" && cp \"$cfgfile.tmp\" \"$cfgfile\" && rm -f \"$cfgfile.tmp\")\ntest 0 -eq $? || _lt_function_replace_fail=:\n\n\n  sed -e '/^func_xform ()$/,/^} # func_xform /c\\\nfunc_xform ()\\\n{\\\n    func_xform_result=${1%.*}.lo\\\n} # Extended-shell func_xform implementation' \"$cfgfile\" > $cfgfile.tmp \\\n  && mv -f \"$cfgfile.tmp\" \"$cfgfile\" \\\n    || (rm -f \"$cfgfile\" && cp \"$cfgfile.tmp\" \"$cfgfile\" && rm -f \"$cfgfile.tmp\")\ntest 0 -eq $? || _lt_function_replace_fail=:\n\n\n  sed -e '/^func_arith ()$/,/^} # func_arith /c\\\nfunc_arith ()\\\n{\\\n    func_arith_result=$(( $* ))\\\n} # Extended-shell func_arith implementation' \"$cfgfile\" > $cfgfile.tmp \\\n  && mv -f \"$cfgfile.tmp\" \"$cfgfile\" \\\n    || (rm -f \"$cfgfile\" && cp \"$cfgfile.tmp\" \"$cfgfile\" && rm -f \"$cfgfile.tmp\")\ntest 0 -eq $? || _lt_function_replace_fail=:\n\n\n  sed -e '/^func_len ()$/,/^} # func_len /c\\\nfunc_len ()\\\n{\\\n    func_len_result=${#1}\\\n} # Extended-shell func_len implementation' \"$cfgfile\" > $cfgfile.tmp \\\n  && mv -f \"$cfgfile.tmp\" \"$cfgfile\" \\\n    || (rm -f \"$cfgfile\" && cp \"$cfgfile.tmp\" \"$cfgfile\" && rm -f \"$cfgfile.tmp\")\ntest 0 -eq $? || _lt_function_replace_fail=:\n\nfi\n\nif test x\"$lt_shell_append\" = xyes; then\n  sed -e '/^func_append ()$/,/^} # func_append /c\\\nfunc_append ()\\\n{\\\n    eval \"${1}+=\\\\${2}\"\\\n} # Extended-shell func_append implementation' \"$cfgfile\" > $cfgfile.tmp \\\n  && mv -f \"$cfgfile.tmp\" \"$cfgfile\" \\\n    || (rm -f \"$cfgfile\" && cp \"$cfgfile.tmp\" \"$cfgfile\" && rm -f \"$cfgfile.tmp\")\ntest 0 -eq $? || _lt_function_replace_fail=:\n\n\n  sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\\\nfunc_append_quoted ()\\\n{\\\n\\    func_quote_for_eval \"${2}\"\\\n\\    eval \"${1}+=\\\\\\\\ \\\\$func_quote_for_eval_result\"\\\n} # Extended-shell func_append_quoted implementation' \"$cfgfile\" > $cfgfile.tmp \\\n  && mv -f \"$cfgfile.tmp\" \"$cfgfile\" \\\n    || (rm -f \"$cfgfile\" && cp \"$cfgfile.tmp\" \"$cfgfile\" && rm -f \"$cfgfile.tmp\")\ntest 0 -eq $? || _lt_function_replace_fail=:\n\n\n  # Save a `func_append' function call where possible by direct use of '+='\n  sed -e 's%func_append \\([a-zA-Z_]\\{1,\\}\\) \"%\\1+=\"%g' $cfgfile > $cfgfile.tmp \\\n    && mv -f \"$cfgfile.tmp\" \"$cfgfile\" \\\n      || (rm -f \"$cfgfile\" && cp \"$cfgfile.tmp\" \"$cfgfile\" && rm -f \"$cfgfile.tmp\")\n  test 0 -eq $? || _lt_function_replace_fail=:\nelse\n  # Save a `func_append' function call even when '+=' is not available\n  sed -e 's%func_append \\([a-zA-Z_]\\{1,\\}\\) \"%\\1=\"$\\1%g' $cfgfile > $cfgfile.tmp \\\n    && mv -f \"$cfgfile.tmp\" \"$cfgfile\" \\\n      || (rm -f \"$cfgfile\" && cp \"$cfgfile.tmp\" \"$cfgfile\" && rm -f \"$cfgfile.tmp\")\n  test 0 -eq $? || _lt_function_replace_fail=:\nfi\n\nif test x\"$_lt_function_replace_fail\" = x\":\"; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile\" >&5\n$as_echo \"$as_me: WARNING: Unable to substitute extended shell functions in $ofile\" >&2;}\nfi\n\n\n   mv -f \"$cfgfile\" \"$ofile\" ||\n    (rm -f \"$ofile\" && cp \"$cfgfile\" \"$ofile\" && rm -f \"$cfgfile\")\n  chmod +x \"$ofile\"\n\n\n    cat <<_LT_EOF >> \"$ofile\"\n\n# ### BEGIN LIBTOOL TAG CONFIG: CXX\n\n# The linker used to build libraries.\nLD=$lt_LD_CXX\n\n# How to create reloadable object files.\nreload_flag=$lt_reload_flag_CXX\nreload_cmds=$lt_reload_cmds_CXX\n\n# Commands used to build an old-style archive.\nold_archive_cmds=$lt_old_archive_cmds_CXX\n\n# A language specific compiler.\nCC=$lt_compiler_CXX\n\n# Is the compiler the GNU compiler?\nwith_gcc=$GCC_CXX\n\n# Compiler flag to turn off builtin functions.\nno_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX\n\n# Additional compiler flags for building library objects.\npic_flag=$lt_lt_prog_compiler_pic_CXX\n\n# How to pass a linker flag through the compiler.\nwl=$lt_lt_prog_compiler_wl_CXX\n\n# Compiler flag to prevent dynamic linking.\nlink_static_flag=$lt_lt_prog_compiler_static_CXX\n\n# Does compiler simultaneously support -c and -o options?\ncompiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX\n\n# Whether or not to add -lc for building shared libraries.\nbuild_libtool_need_lc=$archive_cmds_need_lc_CXX\n\n# Whether or not to disallow shared libs when runtime libs are static.\nallow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX\n\n# Compiler flag to allow reflexive dlopens.\nexport_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX\n\n# Compiler flag to generate shared objects directly from archives.\nwhole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX\n\n# Whether the compiler copes with passing no objects directly.\ncompiler_needs_object=$lt_compiler_needs_object_CXX\n\n# Create an old-style archive from a shared archive.\nold_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX\n\n# Create a temporary old-style archive to link instead of a shared archive.\nold_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX\n\n# Commands used to build a shared archive.\narchive_cmds=$lt_archive_cmds_CXX\narchive_expsym_cmds=$lt_archive_expsym_cmds_CXX\n\n# Commands used to build a loadable module if different from building\n# a shared archive.\nmodule_cmds=$lt_module_cmds_CXX\nmodule_expsym_cmds=$lt_module_expsym_cmds_CXX\n\n# Whether we are building with GNU ld or not.\nwith_gnu_ld=$lt_with_gnu_ld_CXX\n\n# Flag that allows shared libraries with undefined symbols to be built.\nallow_undefined_flag=$lt_allow_undefined_flag_CXX\n\n# Flag that enforces no undefined symbols.\nno_undefined_flag=$lt_no_undefined_flag_CXX\n\n# Flag to hardcode \\$libdir into a binary during linking.\n# This must work even if \\$libdir does not exist\nhardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX\n\n# Whether we need a single \"-rpath\" flag with a separated argument.\nhardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX\n\n# Set to \"yes\" if using DIR/libNAME\\${shared_ext} during linking hardcodes\n# DIR into the resulting binary.\nhardcode_direct=$hardcode_direct_CXX\n\n# Set to \"yes\" if using DIR/libNAME\\${shared_ext} during linking hardcodes\n# DIR into the resulting binary and the resulting library dependency is\n# \"absolute\",i.e impossible to change by setting \\${shlibpath_var} if the\n# library is relocated.\nhardcode_direct_absolute=$hardcode_direct_absolute_CXX\n\n# Set to \"yes\" if using the -LDIR flag during linking hardcodes DIR\n# into the resulting binary.\nhardcode_minus_L=$hardcode_minus_L_CXX\n\n# Set to \"yes\" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR\n# into the resulting binary.\nhardcode_shlibpath_var=$hardcode_shlibpath_var_CXX\n\n# Set to \"yes\" if building a shared library automatically hardcodes DIR\n# into the library and all subsequent libraries and executables linked\n# against it.\nhardcode_automatic=$hardcode_automatic_CXX\n\n# Set to yes if linker adds runtime paths of dependent libraries\n# to runtime path list.\ninherit_rpath=$inherit_rpath_CXX\n\n# Whether libtool must link a program against all its dependency libraries.\nlink_all_deplibs=$link_all_deplibs_CXX\n\n# Set to \"yes\" if exported symbols are required.\nalways_export_symbols=$always_export_symbols_CXX\n\n# The commands to list exported symbols.\nexport_symbols_cmds=$lt_export_symbols_cmds_CXX\n\n# Symbols that should not be listed in the preloaded symbols.\nexclude_expsyms=$lt_exclude_expsyms_CXX\n\n# Symbols that must always be exported.\ninclude_expsyms=$lt_include_expsyms_CXX\n\n# Commands necessary for linking programs (against libraries) with templates.\nprelink_cmds=$lt_prelink_cmds_CXX\n\n# Commands necessary for finishing linking programs.\npostlink_cmds=$lt_postlink_cmds_CXX\n\n# Specify filename containing input files.\nfile_list_spec=$lt_file_list_spec_CXX\n\n# How to hardcode a shared library path into an executable.\nhardcode_action=$hardcode_action_CXX\n\n# The directories searched by this compiler when creating a shared library.\ncompiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX\n\n# Dependencies to place before and after the objects being linked to\n# create a shared library.\npredep_objects=$lt_predep_objects_CXX\npostdep_objects=$lt_postdep_objects_CXX\npredeps=$lt_predeps_CXX\npostdeps=$lt_postdeps_CXX\n\n# The library search path used internally by the compiler when linking\n# a shared library.\ncompiler_lib_search_path=$lt_compiler_lib_search_path_CXX\n\n# ### END LIBTOOL TAG CONFIG: CXX\n_LT_EOF\n\n ;;\n\n  esac\ndone # for ac_tag\n\n\nas_fn_exit 0\n_ACEOF\nac_clean_files=$ac_clean_files_save\n\ntest $ac_write_fail = 0 ||\n  as_fn_error $? \"write failure creating $CONFIG_STATUS\" \"$LINENO\" 5\n\n\n# configure is writing to config.log, and then calls config.status.\n# config.status does its own redirection, appending to config.log.\n# Unfortunately, on DOS this fails, as config.log is still kept open\n# by configure, so config.status won't be able to write to it; its\n# output is simply discarded.  So we exec the FD to /dev/null,\n# effectively closing config.log, so it can be properly (re)opened and\n# appended to by config.status.  When coming back to configure, we\n# need to make the FD available again.\nif test \"$no_create\" != yes; then\n  ac_cs_success=:\n  ac_config_status_args=\n  test \"$silent\" = yes &&\n    ac_config_status_args=\"$ac_config_status_args --quiet\"\n  exec 5>/dev/null\n  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false\n  exec 5>>config.log\n  # Use ||, not &&, to avoid exiting from the if with $? = 1, which\n  # would make configure fail if this is the last instruction.\n  $ac_cs_success || as_fn_exit 1\nfi\n\n#\n# CONFIG_SUBDIRS section.\n#\nif test \"$no_recursion\" != yes; then\n\n  # Remove --cache-file, --srcdir, and --disable-option-checking arguments\n  # so they do not pile up.\n  ac_sub_configure_args=\n  ac_prev=\n  eval \"set x $ac_configure_args\"\n  shift\n  for ac_arg\n  do\n    if test -n \"$ac_prev\"; then\n      ac_prev=\n      continue\n    fi\n    case $ac_arg in\n    -cache-file | --cache-file | --cache-fil | --cache-fi \\\n    | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)\n      ac_prev=cache_file ;;\n    -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \\\n    | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \\\n    | --c=*)\n      ;;\n    --config-cache | -C)\n      ;;\n    -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)\n      ac_prev=srcdir ;;\n    -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)\n      ;;\n    -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)\n      ac_prev=prefix ;;\n    -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)\n      ;;\n    --disable-option-checking)\n      ;;\n    *)\n      case $ac_arg in\n      *\\'*) ac_arg=`$as_echo \"$ac_arg\" | sed \"s/'/'\\\\\\\\\\\\\\\\''/g\"` ;;\n      esac\n      as_fn_append ac_sub_configure_args \" '$ac_arg'\" ;;\n    esac\n  done\n\n  # Always prepend --prefix to ensure using the same prefix\n  # in subdir configurations.\n  ac_arg=\"--prefix=$prefix\"\n  case $ac_arg in\n  *\\'*) ac_arg=`$as_echo \"$ac_arg\" | sed \"s/'/'\\\\\\\\\\\\\\\\''/g\"` ;;\n  esac\n  ac_sub_configure_args=\"'$ac_arg' $ac_sub_configure_args\"\n\n  # Pass --silent\n  if test \"$silent\" = yes; then\n    ac_sub_configure_args=\"--silent $ac_sub_configure_args\"\n  fi\n\n  # Always prepend --disable-option-checking to silence warnings, since\n  # different subdirs can have different --enable and --with options.\n  ac_sub_configure_args=\"--disable-option-checking $ac_sub_configure_args\"\n\n  ac_popdir=`pwd`\n  for ac_dir in : $subdirs; do test \"x$ac_dir\" = x: && continue\n\n    # Do not complain, so a configure script can configure whichever\n    # parts of a large source tree are present.\n    test -d \"$srcdir/$ac_dir\" || continue\n\n    ac_msg=\"=== configuring in $ac_dir (`pwd`/$ac_dir)\"\n    $as_echo \"$as_me:${as_lineno-$LINENO}: $ac_msg\" >&5\n    $as_echo \"$ac_msg\" >&6\n    as_dir=\"$ac_dir\"; as_fn_mkdir_p\n    ac_builddir=.\n\ncase \"$ac_dir\" in\n.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;\n*)\n  ac_dir_suffix=/`$as_echo \"$ac_dir\" | sed 's|^\\.[\\\\/]||'`\n  # A \"..\" for each directory in $ac_dir_suffix.\n  ac_top_builddir_sub=`$as_echo \"$ac_dir_suffix\" | sed 's|/[^\\\\/]*|/..|g;s|/||'`\n  case $ac_top_builddir_sub in\n  \"\") ac_top_builddir_sub=. ac_top_build_prefix= ;;\n  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;\n  esac ;;\nesac\nac_abs_top_builddir=$ac_pwd\nac_abs_builddir=$ac_pwd$ac_dir_suffix\n# for backward compatibility:\nac_top_builddir=$ac_top_build_prefix\n\ncase $srcdir in\n  .)  # We are building in place.\n    ac_srcdir=.\n    ac_top_srcdir=$ac_top_builddir_sub\n    ac_abs_top_srcdir=$ac_pwd ;;\n  [\\\\/]* | ?:[\\\\/]* )  # Absolute name.\n    ac_srcdir=$srcdir$ac_dir_suffix;\n    ac_top_srcdir=$srcdir\n    ac_abs_top_srcdir=$srcdir ;;\n  *) # Relative name.\n    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix\n    ac_top_srcdir=$ac_top_build_prefix$srcdir\n    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;\nesac\nac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix\n\n\n    cd \"$ac_dir\"\n\n    # Check for guested configure; otherwise get Cygnus style configure.\n    if test -f \"$ac_srcdir/configure.gnu\"; then\n      ac_sub_configure=$ac_srcdir/configure.gnu\n    elif test -f \"$ac_srcdir/configure\"; then\n      ac_sub_configure=$ac_srcdir/configure\n    elif test -f \"$ac_srcdir/configure.in\"; then\n      # This should be Cygnus configure.\n      ac_sub_configure=$ac_aux_dir/configure\n    else\n      { $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: no configuration information is in $ac_dir\" >&5\n$as_echo \"$as_me: WARNING: no configuration information is in $ac_dir\" >&2;}\n      ac_sub_configure=\n    fi\n\n    # The recursion is here.\n    if test -n \"$ac_sub_configure\"; then\n      # Make the cache file name correct relative to the subdirectory.\n      case $cache_file in\n      [\\\\/]* | ?:[\\\\/]* ) ac_sub_cache_file=$cache_file ;;\n      *) # Relative name.\n\tac_sub_cache_file=$ac_top_build_prefix$cache_file ;;\n      esac\n\n      { $as_echo \"$as_me:${as_lineno-$LINENO}: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir\" >&5\n$as_echo \"$as_me: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir\" >&6;}\n      # The eval makes quoting arguments work.\n      eval \"\\$SHELL \\\"\\$ac_sub_configure\\\" $ac_sub_configure_args \\\n\t   --cache-file=\\\"\\$ac_sub_cache_file\\\" --srcdir=\\\"\\$ac_srcdir\\\"\" ||\n\tas_fn_error $? \"$ac_sub_configure failed for $ac_dir\" \"$LINENO\" 5\n    fi\n\n    cd \"$ac_popdir\"\n  done\nfi\nif test -n \"$ac_unrecognized_opts\" && test \"$enable_option_checking\" != no; then\n  { $as_echo \"$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts\" >&5\n$as_echo \"$as_me: WARNING: unrecognized options: $ac_unrecognized_opts\" >&2;}\nfi\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/configure.ac",
    "content": "## Process this file with autoconf to produce configure.\n## In general, the safest way to proceed is to run ./autogen.sh\n\nAC_PREREQ(2.59)\n\n# Note:  If you change the version, you must also update it in:\n# * Protobuf.podspec\n# * csharp/Google.Protobuf.Tools.nuspec\n# * csharp/src/*/AssemblyInfo.cs\n# * csharp/src/Google.Protobuf/Google.Protobuf.nuspec\n# * java/*/pom.xml\n# * python/google/protobuf/__init__.py\n# * protoc-artifacts/pom.xml\n# * src/google/protobuf/stubs/common.h\n# * src/Makefile.am (Update -version-info for LDFLAGS if needed)\n#\n# In the SVN trunk, the version should always be the next anticipated release\n# version with the \"-pre\" suffix.  (We used to use \"-SNAPSHOT\" but this pushed\n# the size of one file name in the dist tarfile over the 99-char limit.)\nAC_INIT([Protocol Buffers],[3.0.0],[protobuf@googlegroups.com],[protobuf])\n\nAM_MAINTAINER_MODE([enable])\n\nAC_CONFIG_SRCDIR(src/google/protobuf/message.cc)\n# The config file is generated but not used by the source code, since we only\n# need very few of them, e.g. HAVE_PTHREAD and HAVE_ZLIB. Those macros are\n# passed down in CXXFLAGS manually in src/Makefile.am\nAC_CONFIG_HEADERS([config.h])\nAC_CONFIG_MACRO_DIR([m4])\n\nAC_ARG_VAR(DIST_LANG, [language to include in the distribution package (i.e., make dist)])\ncase \"$DIST_LANG\" in\n  \"\") DIST_LANG=all ;;\n  all | cpp | csharp | java | python | javanano | objectivec | ruby | js) ;;\n  *) AC_MSG_FAILURE([unknown language: $DIST_LANG]) ;;\nesac\nAC_SUBST(DIST_LANG)\n\n# autoconf's default CXXFLAGS are usually \"-g -O2\".  These aren't necessarily\n# the best choice for libprotobuf.\nAS_IF([test \"x${ac_cv_env_CFLAGS_set}\" = \"x\"],\n      [CFLAGS=\"\"])\nAS_IF([test \"x${ac_cv_env_CXXFLAGS_set}\" = \"x\"],\n      [CXXFLAGS=\"\"])\n\nAC_CANONICAL_TARGET\n\nAM_INIT_AUTOMAKE([1.9 tar-ustar subdir-objects])\n\nAC_ARG_WITH([zlib],\n  [AS_HELP_STRING([--with-zlib],\n    [include classes for streaming compressed data in and out @<:@default=check@:>@])],\n  [],[with_zlib=check])\n\nAC_ARG_WITH([protoc],\n  [AS_HELP_STRING([--with-protoc=COMMAND],\n    [use the given protoc command instead of building a new one when building tests (useful for cross-compiling)])],\n  [],[with_protoc=no])\n\n# Checks for programs.\nAC_PROG_CC\nAC_PROG_CXX\nAC_LANG([C++])\nACX_USE_SYSTEM_EXTENSIONS\nm4_ifdef([AM_PROG_AR], [AM_PROG_AR])\nAM_CONDITIONAL(GCC, test \"$GCC\" = yes)   # let the Makefile know if we're gcc\nAC_PROG_OBJC\n\n# test_util.cc takes forever to compile with GCC and optimization turned on.\nAC_MSG_CHECKING([C++ compiler flags...])\nAS_IF([test \"x${ac_cv_env_CXXFLAGS_set}\" = \"x\"],[\n  AS_IF([test \"$GCC\" = \"yes\"],[\n    PROTOBUF_OPT_FLAG=\"-O2\"\n    CXXFLAGS=\"${CXXFLAGS} -g\"\n  ])\n\n  # Protocol Buffers contains several checks that are intended to be used only\n  # for debugging and which might hurt performance.  Most users are probably\n  # end users who don't want these checks, so add -DNDEBUG by default.\n  CXXFLAGS=\"$CXXFLAGS -DNDEBUG\"\n\n  AC_MSG_RESULT([use default: $PROTOBUF_OPT_FLAG $CXXFLAGS])\n],[\n  AC_MSG_RESULT([use user-supplied: $CXXFLAGS])\n])\n\nAC_SUBST(PROTOBUF_OPT_FLAG)\n\nACX_CHECK_SUNCC\n\n# Have to do libtool after SUNCC, other wise it \"helpfully\" adds Crun Cstd\n# to the link\nAC_PROG_LIBTOOL\n\n# Checks for header files.\nAC_HEADER_STDC\nAC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdlib.h unistd.h])\n\n# Checks for library functions.\nAC_FUNC_MEMCMP\nAC_FUNC_STRTOD\nAC_CHECK_FUNCS([ftruncate memset mkdir strchr strerror strtol])\n\n# Check for zlib.\nHAVE_ZLIB=0\nAS_IF([test \"$with_zlib\" != no], [\n  AC_MSG_CHECKING([zlib version])\n\n  # First check the zlib header version.\n  AC_COMPILE_IFELSE(\n    [AC_LANG_PROGRAM([[\n        #include <zlib.h>\n        #if !defined(ZLIB_VERNUM) || (ZLIB_VERNUM < 0x1204)\n        # error zlib version too old\n        #endif\n        ]], [])], [\n    AC_MSG_RESULT([ok (1.2.0.4 or later)])\n\n    # Also need to add -lz to the linker flags and make sure this succeeds.\n    AC_SEARCH_LIBS([zlibVersion], [z], [\n      AC_DEFINE([HAVE_ZLIB], [1], [Enable classes using zlib compression.])\n      HAVE_ZLIB=1\n    ], [\n      AS_IF([test \"$with_zlib\" != check], [\n        AC_MSG_FAILURE([--with-zlib was given, but no working zlib library was found])\n      ])\n    ])\n  ], [\n    AS_IF([test \"$with_zlib\" = check], [\n      AC_MSG_RESULT([headers missing or too old (requires 1.2.0.4)])\n    ], [\n      AC_MSG_FAILURE([--with-zlib was given, but zlib headers were not present or were too old (requires 1.2.0.4)])\n    ])\n  ])\n])\nAM_CONDITIONAL([HAVE_ZLIB], [test $HAVE_ZLIB = 1])\n\nAS_IF([test \"$with_protoc\" != \"no\"], [\n  PROTOC=$with_protoc\n  AS_IF([test \"$with_protoc\" = \"yes\"], [\n    # No argument given.  Use system protoc.\n    PROTOC=protoc\n  ])\n  AS_IF([echo \"$PROTOC\" | grep -q '^@<:@^/@:>@.*/'], [\n    # Does not start with a slash, but contains a slash.  So, it's a relative\n    # path (as opposed to an absolute path or an executable in $PATH).\n    # Since it will actually be executed from the src directory, prefix with\n    # the current directory.  We also insert $ac_top_build_prefix in case this\n    # is a nested package and --with-protoc was actually given on the outer\n    # package's configure script.\n    PROTOC=`pwd`/${ac_top_build_prefix}$PROTOC\n  ])\n  AC_SUBST([PROTOC])\n])\nAM_CONDITIONAL([USE_EXTERNAL_PROTOC], [test \"$with_protoc\" != \"no\"])\n\nACX_PTHREAD\nAM_CONDITIONAL([HAVE_PTHREAD], [test \"x$acx_pthread_ok\" = \"xyes\"])\n\n# We still keep this for improving pbconfig.h for unsupported platforms.\nAC_CXX_STL_HASH\n\ncase \"$target_os\" in\n  mingw* | cygwin* | win*)\n    ;;\n  *)\n    # Need to link against rt on Solaris\n    AC_SEARCH_LIBS([sched_yield], [rt], [], [AC_MSG_FAILURE([sched_yield was not found on your system])])\n    ;;\nesac\n\n# Enable ObjC support for conformance directory on OS X.\nOBJC_CONFORMANCE_TEST=0\ncase \"$target_os\" in\n  darwin*)\n    OBJC_CONFORMANCE_TEST=1\n    ;;\nesac\nAM_CONDITIONAL([OBJC_CONFORMANCE_TEST], [test $OBJC_CONFORMANCE_TEST = 1])\n\n# HACK:  Make gmock's configure script pick up our copy of CFLAGS and CXXFLAGS,\n#   since the flags added by ACX_CHECK_SUNCC must be used when compiling gmock\n#   too.\nexport CFLAGS\nexport CXXFLAGS\nAC_CONFIG_SUBDIRS([gmock])\n\nAC_CONFIG_FILES([Makefile src/Makefile benchmarks/Makefile conformance/Makefile protobuf.pc protobuf-lite.pc])\nAC_OUTPUT\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/ConformanceJava.java",
    "content": "\nimport com.google.protobuf.conformance.Conformance;\nimport com.google.protobuf.util.JsonFormat;\nimport com.google.protobuf.util.JsonFormat.TypeRegistry;\nimport com.google.protobuf.InvalidProtocolBufferException;\n\nclass ConformanceJava {\n  private int testCount = 0;\n  private TypeRegistry typeRegistry;\n\n  private boolean readFromStdin(byte[] buf, int len) throws Exception {\n    int ofs = 0;\n    while (len > 0) {\n      int read = System.in.read(buf, ofs, len);\n      if (read == -1) {\n        return false;  // EOF\n      }\n      ofs += read;\n      len -= read;\n    }\n\n    return true;\n  }\n\n  private void writeToStdout(byte[] buf) throws Exception {\n    System.out.write(buf);\n  }\n\n  // Returns -1 on EOF (the actual values will always be positive).\n  private int readLittleEndianIntFromStdin() throws Exception {\n    byte[] buf = new byte[4];\n    if (!readFromStdin(buf, 4)) {\n      return -1;\n    }\n    return (buf[0] & 0xff)\n        | ((buf[1] & 0xff) << 8)\n        | ((buf[2] & 0xff) << 16)\n        | ((buf[3] & 0xff) << 24);\n  }\n\n  private void writeLittleEndianIntToStdout(int val) throws Exception {\n    byte[] buf = new byte[4];\n    buf[0] = (byte)val;\n    buf[1] = (byte)(val >> 8);\n    buf[2] = (byte)(val >> 16);\n    buf[3] = (byte)(val >> 24);\n    writeToStdout(buf);\n  }\n\n  private Conformance.ConformanceResponse doTest(Conformance.ConformanceRequest request) {\n    Conformance.TestAllTypes testMessage;\n\n    switch (request.getPayloadCase()) {\n      case PROTOBUF_PAYLOAD: {\n        try {\n          testMessage = Conformance.TestAllTypes.parseFrom(request.getProtobufPayload());\n        } catch (InvalidProtocolBufferException e) {\n          return Conformance.ConformanceResponse.newBuilder().setParseError(e.getMessage()).build();\n        }\n        break;\n      }\n      case JSON_PAYLOAD: {\n        try {\n          Conformance.TestAllTypes.Builder builder = Conformance.TestAllTypes.newBuilder();\n          JsonFormat.parser().usingTypeRegistry(typeRegistry)\n              .merge(request.getJsonPayload(), builder);\n          testMessage = builder.build();\n        } catch (InvalidProtocolBufferException e) {\n          return Conformance.ConformanceResponse.newBuilder().setParseError(e.getMessage()).build();\n        }\n        break;\n      }\n      case PAYLOAD_NOT_SET: {\n        throw new RuntimeException(\"Request didn't have payload.\");\n      }\n\n      default: {\n        throw new RuntimeException(\"Unexpected payload case.\");\n      }\n    }\n\n    switch (request.getRequestedOutputFormat()) {\n      case UNSPECIFIED:\n        throw new RuntimeException(\"Unspecified output format.\");\n\n      case PROTOBUF:\n        return Conformance.ConformanceResponse.newBuilder().setProtobufPayload(testMessage.toByteString()).build();\n\n      case JSON:\n        try {\n          return Conformance.ConformanceResponse.newBuilder().setJsonPayload(\n              JsonFormat.printer().usingTypeRegistry(typeRegistry).print(testMessage)).build();\n        } catch (InvalidProtocolBufferException | IllegalArgumentException e) {\n          return Conformance.ConformanceResponse.newBuilder().setSerializeError(\n              e.getMessage()).build();\n        }\n\n      default: {\n        throw new RuntimeException(\"Unexpected request output.\");\n      }\n    }\n  }\n\n  private boolean doTestIo() throws Exception {\n    int bytes = readLittleEndianIntFromStdin();\n\n    if (bytes == -1) {\n      return false;  // EOF\n    }\n\n    byte[] serializedInput = new byte[bytes];\n\n    if (!readFromStdin(serializedInput, bytes)) {\n      throw new RuntimeException(\"Unexpected EOF from test program.\");\n    }\n\n    Conformance.ConformanceRequest request =\n        Conformance.ConformanceRequest.parseFrom(serializedInput);\n    Conformance.ConformanceResponse response = doTest(request);\n    byte[] serializedOutput = response.toByteArray();\n\n    writeLittleEndianIntToStdout(serializedOutput.length);\n    writeToStdout(serializedOutput);\n\n    return true;\n  }\n\n  public void run() throws Exception {\n    typeRegistry = TypeRegistry.newBuilder().add(\n        Conformance.TestAllTypes.getDescriptor()).build();\n    while (doTestIo()) {\n      this.testCount++;\n    }\n\n    System.err.println(\"ConformanceJava: received EOF from test runner after \" +\n        this.testCount + \" tests\");\n  }\n\n  public static void main(String[] args) throws Exception {\n    new ConformanceJava().run();\n  }\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/ConformanceJavaLite.java",
    "content": "\nimport com.google.protobuf.conformance.Conformance;\nimport com.google.protobuf.InvalidProtocolBufferException;\n\nclass ConformanceJavaLite {\n  private int testCount = 0;\n\n  private boolean readFromStdin(byte[] buf, int len) throws Exception {\n    int ofs = 0;\n    while (len > 0) {\n      int read = System.in.read(buf, ofs, len);\n      if (read == -1) {\n        return false;  // EOF\n      }\n      ofs += read;\n      len -= read;\n    }\n\n    return true;\n  }\n\n  private void writeToStdout(byte[] buf) throws Exception {\n    System.out.write(buf);\n  }\n\n  // Returns -1 on EOF (the actual values will always be positive).\n  private int readLittleEndianIntFromStdin() throws Exception {\n    byte[] buf = new byte[4];\n    if (!readFromStdin(buf, 4)) {\n      return -1;\n    }\n    return (buf[0] & 0xff)\n        | ((buf[1] & 0xff) << 8)\n        | ((buf[2] & 0xff) << 16)\n        | ((buf[3] & 0xff) << 24);\n  }\n\n  private void writeLittleEndianIntToStdout(int val) throws Exception {\n    byte[] buf = new byte[4];\n    buf[0] = (byte)val;\n    buf[1] = (byte)(val >> 8);\n    buf[2] = (byte)(val >> 16);\n    buf[3] = (byte)(val >> 24);\n    writeToStdout(buf);\n  }\n\n  private Conformance.ConformanceResponse doTest(Conformance.ConformanceRequest request) {\n    Conformance.TestAllTypes testMessage;\n\n    switch (request.getPayloadCase()) {\n      case PROTOBUF_PAYLOAD: {\n        try {\n          testMessage = Conformance.TestAllTypes.parseFrom(request.getProtobufPayload());\n        } catch (InvalidProtocolBufferException e) {\n          return Conformance.ConformanceResponse.newBuilder().setParseError(e.getMessage()).build();\n        }\n        break;\n      }\n      case JSON_PAYLOAD: {\n        return Conformance.ConformanceResponse.newBuilder().setSkipped(\n            \"Lite runtime does not support JSON format.\").build();\n      }\n      case PAYLOAD_NOT_SET: {\n        throw new RuntimeException(\"Request didn't have payload.\");\n      }\n\n      default: {\n        throw new RuntimeException(\"Unexpected payload case.\");\n      }\n    }\n\n    switch (request.getRequestedOutputFormat()) {\n      case UNSPECIFIED:\n        throw new RuntimeException(\"Unspecified output format.\");\n\n      case PROTOBUF:\n        return Conformance.ConformanceResponse.newBuilder().setProtobufPayload(testMessage.toByteString()).build();\n\n      case JSON:\n        return Conformance.ConformanceResponse.newBuilder().setSkipped(\n            \"Lite runtime does not support JSON format.\").build();\n\n      default: {\n        throw new RuntimeException(\"Unexpected request output.\");\n      }\n    }\n  }\n\n  private boolean doTestIo() throws Exception {\n    int bytes = readLittleEndianIntFromStdin();\n\n    if (bytes == -1) {\n      return false;  // EOF\n    }\n\n    byte[] serializedInput = new byte[bytes];\n\n    if (!readFromStdin(serializedInput, bytes)) {\n      throw new RuntimeException(\"Unexpected EOF from test program.\");\n    }\n\n    Conformance.ConformanceRequest request =\n        Conformance.ConformanceRequest.parseFrom(serializedInput);\n    Conformance.ConformanceResponse response = doTest(request);\n    byte[] serializedOutput = response.toByteArray();\n\n    writeLittleEndianIntToStdout(serializedOutput.length);\n    writeToStdout(serializedOutput);\n\n    return true;\n  }\n\n  public void run() throws Exception {\n    while (doTestIo()) {\n      this.testCount++;\n    }\n\n    System.err.println(\"ConformanceJavaLite: received EOF from test runner after \" +\n        this.testCount + \" tests\");\n  }\n\n  public static void main(String[] args) throws Exception {\n    new ConformanceJavaLite().run();\n  }\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/Makefile.am",
    "content": "## Process this file with automake to produce Makefile.in\n\nconformance_protoc_inputs =                                    \\\n  conformance.proto\n\nwell_known_type_protoc_inputs =                                \\\n  $(top_srcdir)/src/google/protobuf/any.proto                  \\\n  $(top_srcdir)/src/google/protobuf/duration.proto             \\\n  $(top_srcdir)/src/google/protobuf/field_mask.proto           \\\n  $(top_srcdir)/src/google/protobuf/struct.proto               \\\n  $(top_srcdir)/src/google/protobuf/timestamp.proto            \\\n  $(top_srcdir)/src/google/protobuf/wrappers.proto\n\n\nprotoc_outputs =                                               \\\n  conformance.pb.cc                                            \\\n  conformance.pb.h\n\nother_language_protoc_outputs =                                \\\n  conformance_pb2.py                                           \\\n  Conformance.pbobjc.h                                         \\\n  Conformance.pbobjc.m                                         \\\n  conformance.rb                                               \\\n  com/google/protobuf/Any.java                                 \\\n  com/google/protobuf/AnyOrBuilder.java                        \\\n  com/google/protobuf/AnyProto.java                            \\\n  com/google/protobuf/BoolValue.java                           \\\n  com/google/protobuf/BoolValueOrBuilder.java                  \\\n  com/google/protobuf/BytesValue.java                          \\\n  com/google/protobuf/BytesValueOrBuilder.java                 \\\n  com/google/protobuf/conformance/Conformance.java             \\\n  com/google/protobuf/DoubleValue.java                         \\\n  com/google/protobuf/DoubleValueOrBuilder.java                \\\n  com/google/protobuf/Duration.java                            \\\n  com/google/protobuf/DurationOrBuilder.java                   \\\n  com/google/protobuf/DurationProto.java                       \\\n  com/google/protobuf/FieldMask.java                           \\\n  com/google/protobuf/FieldMaskOrBuilder.java                  \\\n  com/google/protobuf/FieldMaskProto.java                      \\\n  com/google/protobuf/FloatValue.java                          \\\n  com/google/protobuf/FloatValueOrBuilder.java                 \\\n  com/google/protobuf/Int32Value.java                          \\\n  com/google/protobuf/Int32ValueOrBuilder.java                 \\\n  com/google/protobuf/Int64Value.java                          \\\n  com/google/protobuf/Int64ValueOrBuilder.java                 \\\n  com/google/protobuf/ListValue.java                           \\\n  com/google/protobuf/ListValueOrBuilder.java                  \\\n  com/google/protobuf/NullValue.java                           \\\n  com/google/protobuf/StringValue.java                         \\\n  com/google/protobuf/StringValueOrBuilder.java                \\\n  com/google/protobuf/Struct.java                              \\\n  com/google/protobuf/StructOrBuilder.java                     \\\n  com/google/protobuf/StructProto.java                         \\\n  com/google/protobuf/Timestamp.java                           \\\n  com/google/protobuf/TimestampOrBuilder.java                  \\\n  com/google/protobuf/TimestampProto.java                      \\\n  com/google/protobuf/UInt32Value.java                         \\\n  com/google/protobuf/UInt32ValueOrBuilder.java                \\\n  com/google/protobuf/UInt64Value.java                         \\\n  com/google/protobuf/UInt64ValueOrBuilder.java                \\\n  com/google/protobuf/Value.java                               \\\n  com/google/protobuf/ValueOrBuilder.java                      \\\n  com/google/protobuf/WrappersProto.java                       \\\n  google/protobuf/any.pb.cc                                    \\\n  google/protobuf/any.pb.h                                     \\\n  google/protobuf/any.rb                                       \\\n  google/protobuf/any_pb2.py                                   \\\n  google/protobuf/duration.pb.cc                               \\\n  google/protobuf/duration.pb.h                                \\\n  google/protobuf/duration.rb                                  \\\n  google/protobuf/duration_pb2.py                              \\\n  google/protobuf/field_mask.pb.cc                             \\\n  google/protobuf/field_mask.pb.h                              \\\n  google/protobuf/field_mask.rb                                \\\n  google/protobuf/field_mask_pb2.py                            \\\n  google/protobuf/struct.pb.cc                                 \\\n  google/protobuf/struct.pb.h                                  \\\n  google/protobuf/struct.rb                                    \\\n  google/protobuf/struct_pb2.py                                \\\n  google/protobuf/timestamp.pb.cc                              \\\n  google/protobuf/timestamp.pb.h                               \\\n  google/protobuf/timestamp.rb                                 \\\n  google/protobuf/timestamp_pb2.py                             \\\n  google/protobuf/wrappers.pb.cc                               \\\n  google/protobuf/wrappers.pb.h                                \\\n  google/protobuf/wrappers.rb                                  \\\n  google/protobuf/wrappers_pb2.py\n  # lite/com/google/protobuf/Any.java                            \\\n  # lite/com/google/protobuf/AnyOrBuilder.java                   \\\n  # lite/com/google/protobuf/AnyProto.java                       \\\n  # lite/com/google/protobuf/BoolValue.java                      \\\n  # lite/com/google/protobuf/BoolValueOrBuilder.java             \\\n  # lite/com/google/protobuf/BytesValue.java                     \\\n  # lite/com/google/protobuf/BytesValueOrBuilder.java            \\\n  # lite/com/google/protobuf/conformance/Conformance.java        \\\n  # lite/com/google/protobuf/DoubleValue.java                    \\\n  # lite/com/google/protobuf/DoubleValueOrBuilder.java           \\\n  # lite/com/google/protobuf/Duration.java                       \\\n  # lite/com/google/protobuf/DurationOrBuilder.java              \\\n  # lite/com/google/protobuf/DurationProto.java                  \\\n  # lite/com/google/protobuf/FieldMask.java                      \\\n  # lite/com/google/protobuf/FieldMaskOrBuilder.java             \\\n  # lite/com/google/protobuf/FieldMaskProto.java                 \\\n  # lite/com/google/protobuf/FloatValue.java                     \\\n  # lite/com/google/protobuf/FloatValueOrBuilder.java            \\\n  # lite/com/google/protobuf/Int32Value.java                     \\\n  # lite/com/google/protobuf/Int32ValueOrBuilder.java            \\\n  # lite/com/google/protobuf/Int64Value.java                     \\\n  # lite/com/google/protobuf/Int64ValueOrBuilder.java            \\\n  # lite/com/google/protobuf/ListValue.java                      \\\n  # lite/com/google/protobuf/ListValueOrBuilder.java             \\\n  # lite/com/google/protobuf/NullValue.java                      \\\n  # lite/com/google/protobuf/StringValue.java                    \\\n  # lite/com/google/protobuf/StringValueOrBuilder.java           \\\n  # lite/com/google/protobuf/Struct.java                         \\\n  # lite/com/google/protobuf/StructOrBuilder.java                \\\n  # lite/com/google/protobuf/StructProto.java                    \\\n  # lite/com/google/protobuf/Timestamp.java                      \\\n  # lite/com/google/protobuf/TimestampOrBuilder.java             \\\n  # lite/com/google/protobuf/TimestampProto.java                 \\\n  # lite/com/google/protobuf/UInt32Value.java                    \\\n  # lite/com/google/protobuf/UInt32ValueOrBuilder.java           \\\n  # lite/com/google/protobuf/UInt64Value.java                    \\\n  # lite/com/google/protobuf/UInt64ValueOrBuilder.java           \\\n  # lite/com/google/protobuf/Value.java                          \\\n  # lite/com/google/protobuf/ValueOrBuilder.java                 \\\n  # lite/com/google/protobuf/WrappersProto.java\n\nbin_PROGRAMS = conformance-test-runner conformance-cpp\n\n# All source files excepet C++/Objective-C ones should be explicitly listed\n# here because the autoconf tools don't include files of other languages\n# automatically.\nEXTRA_DIST =                  \\\n  ConformanceJava.java        \\\n  ConformanceJavaLite.java    \\\n  README.md                   \\\n  conformance.proto           \\\n  conformance_python.py       \\\n  conformance_ruby.rb         \\\n  failure_list_cpp.txt        \\\n  failure_list_csharp.txt     \\\n  failure_list_java.txt       \\\n  failure_list_objc.txt       \\\n  failure_list_python.txt     \\\n  failure_list_python_cpp.txt \\\n  failure_list_python-post26.txt \\\n  failure_list_ruby.txt\n\nconformance_test_runner_LDADD = $(top_srcdir)/src/libprotobuf.la\nconformance_test_runner_SOURCES = conformance_test.h conformance_test.cc \\\n                                  conformance_test_runner.cc             \\\n                                  third_party/jsoncpp/json.h             \\\n                                  third_party/jsoncpp/jsoncpp.cpp\nnodist_conformance_test_runner_SOURCES = conformance.pb.cc\nconformance_test_runner_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir)\nconformance_test_runner_CXXFLAGS = -std=c++11\n# Explicit deps beacuse BUILT_SOURCES are only done before a \"make all/check\"\n# so a direct \"make test_cpp\" could fail if parallel enough.\nconformance_test_runner-conformance_test.$(OBJEXT): conformance.pb.h\nconformance_test_runner-conformance_test_runner.$(OBJEXT): conformance.pb.h\n\nconformance_cpp_LDADD = $(top_srcdir)/src/libprotobuf.la\nconformance_cpp_SOURCES = conformance_cpp.cc\nnodist_conformance_cpp_SOURCES = conformance.pb.cc\nconformance_cpp_CPPFLAGS = -I$(top_srcdir)/src\n# Explicit dep beacuse BUILT_SOURCES are only done before a \"make all/check\"\n# so a direct \"make test_cpp\" could fail if parallel enough.\nconformance_cpp-conformance_cpp.$(OBJEXT): conformance.pb.h\n\nif OBJC_CONFORMANCE_TEST\n\nbin_PROGRAMS += conformance-objc\n\nconformance_objc_SOURCES = conformance_objc.m ../objectivec/GPBProtocolBuffers.m\nnodist_conformance_objc_SOURCES = Conformance.pbobjc.m\n# On travis, the build fails without the isysroot because whatever system\n# headers are being found don't include generics support for\n# NSArray/NSDictionary, the only guess is their image at one time had an odd\n# setup for Xcode and old frameworks are being found.\nconformance_objc_CPPFLAGS = -I$(top_srcdir)/objectivec -isysroot `xcrun --sdk macosx --show-sdk-path`\nconformance_objc_LDFLAGS = -framework Foundation\n# Explicit dep beacuse BUILT_SOURCES are only done before a \"make all/check\"\n# so a direct \"make test_objc\" could fail if parallel enough.\nconformance_objc-conformance_objc.$(OBJEXT): Conformance.pbobjc.h\n\nendif\n\nif USE_EXTERNAL_PROTOC\n\n# Some implementations include pre-generated versions of well-known types.\nprotoc_middleman: $(conformance_protoc_inputs) $(well_known_type_protoc_inputs)\n\t$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --objc_out=. --python_out=. $(conformance_protoc_inputs)\n\t$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --python_out=. $(well_known_type_protoc_inputs)\n\t## $(PROTOC) -I$(srcdir) -I$(top_srcdir) --java_out=lite:lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs)\n\ttouch protoc_middleman\n\nelse\n\n# We have to cd to $(srcdir) before executing protoc because $(protoc_inputs) is\n# relative to srcdir, which may not be the same as the current directory when\n# building out-of-tree.\nprotoc_middleman: $(top_srcdir)/src/protoc$(EXEEXT) $(conformance_protoc_inputs) $(well_known_type_protoc_inputs)\n\toldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --objc_out=$$oldpwd --python_out=$$oldpwd $(conformance_protoc_inputs) )\n\toldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --python_out=$$oldpwd $(well_known_type_protoc_inputs) )\n\t## @mkdir -p lite\n\t## oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --java_out=lite:$$oldpwd/lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) )\n\ttouch protoc_middleman\n\nendif\n\n$(protoc_outputs): protoc_middleman\n\n$(other_language_protoc_outputs): protoc_middleman\n\nBUILT_SOURCES = $(protoc_outputs) $(other_language_protoc_outputs)\n\nCLEANFILES = $(protoc_outputs) protoc_middleman javac_middleman conformance-java javac_middleman_lite conformance-java-lite conformance-csharp $(other_language_protoc_outputs)\n\nMAINTAINERCLEANFILES =   \\\n  Makefile.in\n\njavac_middleman: ConformanceJava.java protoc_middleman $(other_language_protoc_outputs)\n\tjar=`ls ../java/util/target/*jar-with-dependencies.jar` && javac -classpath ../java/target/classes:$$jar ConformanceJava.java com/google/protobuf/conformance/Conformance.java\n\t@touch javac_middleman\n\nconformance-java: javac_middleman\n\t@echo \"Writing shortcut script conformance-java...\"\n\t@echo '#! /bin/sh' > conformance-java\n\t@jar=`ls ../java/util/target/*jar-with-dependencies.jar` && echo java -classpath .:../java/target/classes:$$jar ConformanceJava '$$@' >> conformance-java\n\t@chmod +x conformance-java\n\njavac_middleman_lite: ConformanceJavaLite.java protoc_middleman $(other_language_protoc_outputs)\n\tjavac -classpath ../java/lite/target/classes:lite ConformanceJavaLite.java lite/com/google/protobuf/conformance/Conformance.java\n\t@touch javac_middleman_lite\n\nconformance-java-lite: javac_middleman_lite\n\t@echo \"Writing shortcut script conformance-java-lite...\"\n\t@echo '#! /bin/sh' > conformance-java-lite\n\t@echo java -classpath .:../java/lite/target/classes:lite ConformanceJavaLite '$$@' >> conformance-java-lite\n\t@chmod +x conformance-java-lite\n\n# Currently the conformance code is alongside the rest of the C#\n# source, as it's easier to maintain there. We assume we've already\n# built that, so we just need a script to run it.\nconformance-csharp: $(other_language_protoc_outputs)\n\t@echo \"Writing shortcut script conformance-csharp...\"\n\t@echo '#! /bin/sh' > conformance-csharp\n\t@echo 'dotnet ../csharp/src/Google.Protobuf.Conformance/bin/Release/netcoreapp1.0/Google.Protobuf.Conformance.dll \"$$@\"' >> conformance-csharp\n\t@chmod +x conformance-csharp\n\n# Targets for actually running tests.\ntest_cpp: protoc_middleman conformance-test-runner conformance-cpp\n\t./conformance-test-runner --failure_list failure_list_cpp.txt ./conformance-cpp\n\ntest_java: protoc_middleman conformance-test-runner conformance-java\n\t./conformance-test-runner --failure_list failure_list_java.txt ./conformance-java\n\ntest_java_lite: protoc_middleman conformance-test-runner conformance-java-lite\n\t./conformance-test-runner ./conformance-java-lite\n\ntest_csharp: protoc_middleman conformance-test-runner conformance-csharp\n\t./conformance-test-runner --failure_list failure_list_csharp.txt ./conformance-csharp\n\ntest_ruby: protoc_middleman conformance-test-runner $(other_language_protoc_outputs)\n\tRUBYLIB=../ruby/lib:. ./conformance-test-runner --failure_list failure_list_ruby.txt ./conformance_ruby.rb\n\n# These depend on library paths being properly set up.  The easiest way to\n# run them is to just use \"tox\" from the python dir.\ntest_python: protoc_middleman conformance-test-runner\n\t./conformance-test-runner --failure_list failure_list_python.txt ./conformance_python.py\n\ntest_python_cpp: protoc_middleman conformance-test-runner\n\t./conformance-test-runner --failure_list failure_list_python_cpp.txt ./conformance_python.py\n\nif OBJC_CONFORMANCE_TEST\n\ntest_objc: protoc_middleman conformance-test-runner conformance-objc\n\t./conformance-test-runner --failure_list failure_list_objc.txt ./conformance-objc\n\nendif\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/Makefile.in",
    "content": "# Makefile.in generated by automake 1.14.1 from Makefile.am.\n# @configure_input@\n\n# Copyright (C) 1994-2013 Free Software Foundation, Inc.\n\n# This Makefile.in is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY, to the extent permitted by law; without\n# even the implied warranty of MERCHANTABILITY or FITNESS FOR A\n# PARTICULAR PURPOSE.\n\n@SET_MAKE@\n\nVPATH = @srcdir@\nam__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'\nam__make_running_with_option = \\\n  case $${target_option-} in \\\n      ?) ;; \\\n      *) echo \"am__make_running_with_option: internal error: invalid\" \\\n              \"target option '$${target_option-}' specified\" >&2; \\\n         exit 1;; \\\n  esac; \\\n  has_opt=no; \\\n  sane_makeflags=$$MAKEFLAGS; \\\n  if $(am__is_gnu_make); then \\\n    sane_makeflags=$$MFLAGS; \\\n  else \\\n    case $$MAKEFLAGS in \\\n      *\\\\[\\ \\\t]*) \\\n        bs=\\\\; \\\n        sane_makeflags=`printf '%s\\n' \"$$MAKEFLAGS\" \\\n          | sed \"s/$$bs$$bs[$$bs $$bs\t]*//g\"`;; \\\n    esac; \\\n  fi; \\\n  skip_next=no; \\\n  strip_trailopt () \\\n  { \\\n    flg=`printf '%s\\n' \"$$flg\" | sed \"s/$$1.*$$//\"`; \\\n  }; \\\n  for flg in $$sane_makeflags; do \\\n    test $$skip_next = yes && { skip_next=no; continue; }; \\\n    case $$flg in \\\n      *=*|--*) continue;; \\\n        -*I) strip_trailopt 'I'; skip_next=yes;; \\\n      -*I?*) strip_trailopt 'I';; \\\n        -*O) strip_trailopt 'O'; skip_next=yes;; \\\n      -*O?*) strip_trailopt 'O';; \\\n        -*l) strip_trailopt 'l'; skip_next=yes;; \\\n      -*l?*) strip_trailopt 'l';; \\\n      -[dEDm]) skip_next=yes;; \\\n      -[JT]) skip_next=yes;; \\\n    esac; \\\n    case $$flg in \\\n      *$$target_option*) has_opt=yes; break;; \\\n    esac; \\\n  done; \\\n  test $$has_opt = yes\nam__make_dryrun = (target_option=n; $(am__make_running_with_option))\nam__make_keepgoing = (target_option=k; $(am__make_running_with_option))\npkgdatadir = $(datadir)/@PACKAGE@\npkgincludedir = $(includedir)/@PACKAGE@\npkglibdir = $(libdir)/@PACKAGE@\npkglibexecdir = $(libexecdir)/@PACKAGE@\nam__cd = CDPATH=\"$${ZSH_VERSION+.}$(PATH_SEPARATOR)\" && cd\ninstall_sh_DATA = $(install_sh) -c -m 644\ninstall_sh_PROGRAM = $(install_sh) -c\ninstall_sh_SCRIPT = $(install_sh) -c\nINSTALL_HEADER = $(INSTALL_DATA)\ntransform = $(program_transform_name)\nNORMAL_INSTALL = :\nPRE_INSTALL = :\nPOST_INSTALL = :\nNORMAL_UNINSTALL = :\nPRE_UNINSTALL = :\nPOST_UNINSTALL = :\nbuild_triplet = @build@\nhost_triplet = @host@\ntarget_triplet = @target@\nbin_PROGRAMS = conformance-test-runner$(EXEEXT) \\\n\tconformance-cpp$(EXEEXT) $(am__EXEEXT_1)\n@OBJC_CONFORMANCE_TEST_TRUE@am__append_1 = conformance-objc\nsubdir = conformance\nDIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \\\n\t$(top_srcdir)/depcomp\nACLOCAL_M4 = $(top_srcdir)/aclocal.m4\nam__aclocal_m4_deps = $(top_srcdir)/m4/ac_system_extensions.m4 \\\n\t$(top_srcdir)/m4/acx_check_suncc.m4 \\\n\t$(top_srcdir)/m4/acx_pthread.m4 $(top_srcdir)/m4/libtool.m4 \\\n\t$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \\\n\t$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \\\n\t$(top_srcdir)/m4/stl_hash.m4 $(top_srcdir)/configure.ac\nam__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \\\n\t$(ACLOCAL_M4)\nmkinstalldirs = $(install_sh) -d\nCONFIG_HEADER = $(top_builddir)/config.h\nCONFIG_CLEAN_FILES =\nCONFIG_CLEAN_VPATH_FILES =\n@OBJC_CONFORMANCE_TEST_TRUE@am__EXEEXT_1 = conformance-objc$(EXEEXT)\nam__installdirs = \"$(DESTDIR)$(bindir)\"\nPROGRAMS = $(bin_PROGRAMS)\nam_conformance_cpp_OBJECTS =  \\\n\tconformance_cpp-conformance_cpp.$(OBJEXT)\nnodist_conformance_cpp_OBJECTS =  \\\n\tconformance_cpp-conformance.pb.$(OBJEXT)\nconformance_cpp_OBJECTS = $(am_conformance_cpp_OBJECTS) \\\n\t$(nodist_conformance_cpp_OBJECTS)\nconformance_cpp_DEPENDENCIES = $(top_srcdir)/src/libprotobuf.la\nAM_V_lt = $(am__v_lt_@AM_V@)\nam__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)\nam__v_lt_0 = --silent\nam__v_lt_1 = \nam__conformance_objc_SOURCES_DIST = conformance_objc.m \\\n\t../objectivec/GPBProtocolBuffers.m\nam__dirstamp = $(am__leading_dot)dirstamp\n@OBJC_CONFORMANCE_TEST_TRUE@am_conformance_objc_OBJECTS = conformance_objc-conformance_objc.$(OBJEXT) \\\n@OBJC_CONFORMANCE_TEST_TRUE@\t../objectivec/conformance_objc-GPBProtocolBuffers.$(OBJEXT)\n@OBJC_CONFORMANCE_TEST_TRUE@nodist_conformance_objc_OBJECTS = conformance_objc-Conformance.pbobjc.$(OBJEXT)\nconformance_objc_OBJECTS = $(am_conformance_objc_OBJECTS) \\\n\t$(nodist_conformance_objc_OBJECTS)\nconformance_objc_LDADD = $(LDADD)\nconformance_objc_LINK = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \\\n\t$(LIBTOOLFLAGS) --mode=link $(OBJCLD) $(AM_OBJCFLAGS) \\\n\t$(OBJCFLAGS) $(conformance_objc_LDFLAGS) $(LDFLAGS) -o $@\nam_conformance_test_runner_OBJECTS =  \\\n\tconformance_test_runner-conformance_test.$(OBJEXT) \\\n\tconformance_test_runner-conformance_test_runner.$(OBJEXT) \\\n\tthird_party/jsoncpp/conformance_test_runner-jsoncpp.$(OBJEXT)\nnodist_conformance_test_runner_OBJECTS =  \\\n\tconformance_test_runner-conformance.pb.$(OBJEXT)\nconformance_test_runner_OBJECTS =  \\\n\t$(am_conformance_test_runner_OBJECTS) \\\n\t$(nodist_conformance_test_runner_OBJECTS)\nconformance_test_runner_DEPENDENCIES =  \\\n\t$(top_srcdir)/src/libprotobuf.la\nconformance_test_runner_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \\\n\t$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \\\n\t$(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \\\n\t$(LDFLAGS) -o $@\nAM_V_P = $(am__v_P_@AM_V@)\nam__v_P_ = $(am__v_P_@AM_DEFAULT_V@)\nam__v_P_0 = false\nam__v_P_1 = :\nAM_V_GEN = $(am__v_GEN_@AM_V@)\nam__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)\nam__v_GEN_0 = @echo \"  GEN     \" $@;\nam__v_GEN_1 = \nAM_V_at = $(am__v_at_@AM_V@)\nam__v_at_ = $(am__v_at_@AM_DEFAULT_V@)\nam__v_at_0 = @\nam__v_at_1 = \nDEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)\ndepcomp = $(SHELL) $(top_srcdir)/depcomp\nam__depfiles_maybe = depfiles\nam__mv = mv -f\nCXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \\\n\t$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)\nLTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \\\n\t$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \\\n\t$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \\\n\t$(AM_CXXFLAGS) $(CXXFLAGS)\nAM_V_CXX = $(am__v_CXX_@AM_V@)\nam__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)\nam__v_CXX_0 = @echo \"  CXX     \" $@;\nam__v_CXX_1 = \nCXXLD = $(CXX)\nCXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \\\n\t$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \\\n\t$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@\nAM_V_CXXLD = $(am__v_CXXLD_@AM_V@)\nam__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)\nam__v_CXXLD_0 = @echo \"  CXXLD   \" $@;\nam__v_CXXLD_1 = \nOBJCCOMPILE = $(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \\\n\t$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)\nLTOBJCCOMPILE = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \\\n\t$(LIBTOOLFLAGS) --mode=compile $(OBJC) $(DEFS) \\\n\t$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \\\n\t$(AM_OBJCFLAGS) $(OBJCFLAGS)\nAM_V_OBJC = $(am__v_OBJC_@AM_V@)\nam__v_OBJC_ = $(am__v_OBJC_@AM_DEFAULT_V@)\nam__v_OBJC_0 = @echo \"  OBJC    \" $@;\nam__v_OBJC_1 = \nOBJCLD = $(OBJC)\nOBJCLINK = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \\\n\t--mode=link $(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) \\\n\t$(AM_LDFLAGS) $(LDFLAGS) -o $@\nAM_V_OBJCLD = $(am__v_OBJCLD_@AM_V@)\nam__v_OBJCLD_ = $(am__v_OBJCLD_@AM_DEFAULT_V@)\nam__v_OBJCLD_0 = @echo \"  OBJCLD  \" $@;\nam__v_OBJCLD_1 = \nCOMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \\\n\t$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)\nLTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \\\n\t$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \\\n\t$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \\\n\t$(AM_CFLAGS) $(CFLAGS)\nAM_V_CC = $(am__v_CC_@AM_V@)\nam__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)\nam__v_CC_0 = @echo \"  CC      \" $@;\nam__v_CC_1 = \nCCLD = $(CC)\nLINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \\\n\t$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \\\n\t$(AM_LDFLAGS) $(LDFLAGS) -o $@\nAM_V_CCLD = $(am__v_CCLD_@AM_V@)\nam__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)\nam__v_CCLD_0 = @echo \"  CCLD    \" $@;\nam__v_CCLD_1 = \nSOURCES = $(conformance_cpp_SOURCES) $(nodist_conformance_cpp_SOURCES) \\\n\t$(conformance_objc_SOURCES) $(nodist_conformance_objc_SOURCES) \\\n\t$(conformance_test_runner_SOURCES) \\\n\t$(nodist_conformance_test_runner_SOURCES)\nDIST_SOURCES = $(conformance_cpp_SOURCES) \\\n\t$(am__conformance_objc_SOURCES_DIST) \\\n\t$(conformance_test_runner_SOURCES)\nam__can_run_installinfo = \\\n  case $$AM_UPDATE_INFO_DIR in \\\n    n|no|NO) false;; \\\n    *) (install-info --version) >/dev/null 2>&1;; \\\n  esac\nam__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)\n# Read a list of newline-separated strings from the standard input,\n# and print each of them once, without duplicates.  Input order is\n# *not* preserved.\nam__uniquify_input = $(AWK) '\\\n  BEGIN { nonempty = 0; } \\\n  { items[$$0] = 1; nonempty = 1; } \\\n  END { if (nonempty) { for (i in items) print i; }; } \\\n'\n# Make sure the list of sources is unique.  This is necessary because,\n# e.g., the same source file might be shared among _SOURCES variables\n# for different programs/libraries.\nam__define_uniq_tagged_files = \\\n  list='$(am__tagged_files)'; \\\n  unique=`for i in $$list; do \\\n    if test -f \"$$i\"; then echo $$i; else echo $(srcdir)/$$i; fi; \\\n  done | $(am__uniquify_input)`\nETAGS = etags\nCTAGS = ctags\nDISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)\nACLOCAL = @ACLOCAL@\nAMTAR = @AMTAR@\nAM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@\nAR = @AR@\nAUTOCONF = @AUTOCONF@\nAUTOHEADER = @AUTOHEADER@\nAUTOMAKE = @AUTOMAKE@\nAWK = @AWK@\nCC = @CC@\nCCDEPMODE = @CCDEPMODE@\nCFLAGS = @CFLAGS@\nCPPFLAGS = @CPPFLAGS@\nCXX = @CXX@\nCXXCPP = @CXXCPP@\nCXXDEPMODE = @CXXDEPMODE@\nCXXFLAGS = @CXXFLAGS@\nCYGPATH_W = @CYGPATH_W@\nDEFS = @DEFS@\nDEPDIR = @DEPDIR@\nDIST_LANG = @DIST_LANG@\nDLLTOOL = @DLLTOOL@\nDSYMUTIL = @DSYMUTIL@\nDUMPBIN = @DUMPBIN@\nECHO_C = @ECHO_C@\nECHO_N = @ECHO_N@\nECHO_T = @ECHO_T@\nEGREP = @EGREP@\nEXEEXT = @EXEEXT@\nFGREP = @FGREP@\nGREP = @GREP@\nINSTALL = @INSTALL@\nINSTALL_DATA = @INSTALL_DATA@\nINSTALL_PROGRAM = @INSTALL_PROGRAM@\nINSTALL_SCRIPT = @INSTALL_SCRIPT@\nINSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@\nISAINFO = @ISAINFO@\nLD = @LD@\nLDFLAGS = @LDFLAGS@\nLIBOBJS = @LIBOBJS@\nLIBS = @LIBS@\nLIBTOOL = @LIBTOOL@\nLIPO = @LIPO@\nLN_S = @LN_S@\nLTLIBOBJS = @LTLIBOBJS@\nMAINT = @MAINT@\nMAKEINFO = @MAKEINFO@\nMANIFEST_TOOL = @MANIFEST_TOOL@\nMKDIR_P = @MKDIR_P@\nNM = @NM@\nNMEDIT = @NMEDIT@\nOBJC = @OBJC@\nOBJCDEPMODE = @OBJCDEPMODE@\nOBJCFLAGS = @OBJCFLAGS@\nOBJDUMP = @OBJDUMP@\nOBJEXT = @OBJEXT@\nOTOOL = @OTOOL@\nOTOOL64 = @OTOOL64@\nPACKAGE = @PACKAGE@\nPACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@\nPACKAGE_NAME = @PACKAGE_NAME@\nPACKAGE_STRING = @PACKAGE_STRING@\nPACKAGE_TARNAME = @PACKAGE_TARNAME@\nPACKAGE_URL = @PACKAGE_URL@\nPACKAGE_VERSION = @PACKAGE_VERSION@\nPATH_SEPARATOR = @PATH_SEPARATOR@\nPOW_LIB = @POW_LIB@\nPROTOBUF_OPT_FLAG = @PROTOBUF_OPT_FLAG@\nPROTOC = @PROTOC@\nPTHREAD_CC = @PTHREAD_CC@\nPTHREAD_CFLAGS = @PTHREAD_CFLAGS@\nPTHREAD_LIBS = @PTHREAD_LIBS@\nRANLIB = @RANLIB@\nSED = @SED@\nSET_MAKE = @SET_MAKE@\nSHELL = @SHELL@\nSTRIP = @STRIP@\nVERSION = @VERSION@\nabs_builddir = @abs_builddir@\nabs_srcdir = @abs_srcdir@\nabs_top_builddir = @abs_top_builddir@\nabs_top_srcdir = @abs_top_srcdir@\nac_ct_AR = @ac_ct_AR@\nac_ct_CC = @ac_ct_CC@\nac_ct_CXX = @ac_ct_CXX@\nac_ct_DUMPBIN = @ac_ct_DUMPBIN@\nac_ct_OBJC = @ac_ct_OBJC@\nacx_pthread_config = @acx_pthread_config@\nam__include = @am__include@\nam__leading_dot = @am__leading_dot@\nam__quote = @am__quote@\nam__tar = @am__tar@\nam__untar = @am__untar@\nbindir = @bindir@\nbuild = @build@\nbuild_alias = @build_alias@\nbuild_cpu = @build_cpu@\nbuild_os = @build_os@\nbuild_vendor = @build_vendor@\nbuilddir = @builddir@\ndatadir = @datadir@\ndatarootdir = @datarootdir@\ndocdir = @docdir@\ndvidir = @dvidir@\nexec_prefix = @exec_prefix@\nhost = @host@\nhost_alias = @host_alias@\nhost_cpu = @host_cpu@\nhost_os = @host_os@\nhost_vendor = @host_vendor@\nhtmldir = @htmldir@\nincludedir = @includedir@\ninfodir = @infodir@\ninstall_sh = @install_sh@\nlibdir = @libdir@\nlibexecdir = @libexecdir@\nlocaledir = @localedir@\nlocalstatedir = @localstatedir@\nmandir = @mandir@\nmkdir_p = @mkdir_p@\noldincludedir = @oldincludedir@\npdfdir = @pdfdir@\nprefix = @prefix@\nprogram_transform_name = @program_transform_name@\npsdir = @psdir@\nsbindir = @sbindir@\nsharedstatedir = @sharedstatedir@\nsrcdir = @srcdir@\nsubdirs = @subdirs@\nsysconfdir = @sysconfdir@\ntarget = @target@\ntarget_alias = @target_alias@\ntarget_cpu = @target_cpu@\ntarget_os = @target_os@\ntarget_vendor = @target_vendor@\ntop_build_prefix = @top_build_prefix@\ntop_builddir = @top_builddir@\ntop_srcdir = @top_srcdir@\nconformance_protoc_inputs = \\\n  conformance.proto\n\nwell_known_type_protoc_inputs = \\\n  $(top_srcdir)/src/google/protobuf/any.proto                  \\\n  $(top_srcdir)/src/google/protobuf/duration.proto             \\\n  $(top_srcdir)/src/google/protobuf/field_mask.proto           \\\n  $(top_srcdir)/src/google/protobuf/struct.proto               \\\n  $(top_srcdir)/src/google/protobuf/timestamp.proto            \\\n  $(top_srcdir)/src/google/protobuf/wrappers.proto\n\nprotoc_outputs = \\\n  conformance.pb.cc                                            \\\n  conformance.pb.h\n\nother_language_protoc_outputs = \\\n  conformance_pb2.py                                           \\\n  Conformance.pbobjc.h                                         \\\n  Conformance.pbobjc.m                                         \\\n  conformance.rb                                               \\\n  com/google/protobuf/Any.java                                 \\\n  com/google/protobuf/AnyOrBuilder.java                        \\\n  com/google/protobuf/AnyProto.java                            \\\n  com/google/protobuf/BoolValue.java                           \\\n  com/google/protobuf/BoolValueOrBuilder.java                  \\\n  com/google/protobuf/BytesValue.java                          \\\n  com/google/protobuf/BytesValueOrBuilder.java                 \\\n  com/google/protobuf/conformance/Conformance.java             \\\n  com/google/protobuf/DoubleValue.java                         \\\n  com/google/protobuf/DoubleValueOrBuilder.java                \\\n  com/google/protobuf/Duration.java                            \\\n  com/google/protobuf/DurationOrBuilder.java                   \\\n  com/google/protobuf/DurationProto.java                       \\\n  com/google/protobuf/FieldMask.java                           \\\n  com/google/protobuf/FieldMaskOrBuilder.java                  \\\n  com/google/protobuf/FieldMaskProto.java                      \\\n  com/google/protobuf/FloatValue.java                          \\\n  com/google/protobuf/FloatValueOrBuilder.java                 \\\n  com/google/protobuf/Int32Value.java                          \\\n  com/google/protobuf/Int32ValueOrBuilder.java                 \\\n  com/google/protobuf/Int64Value.java                          \\\n  com/google/protobuf/Int64ValueOrBuilder.java                 \\\n  com/google/protobuf/ListValue.java                           \\\n  com/google/protobuf/ListValueOrBuilder.java                  \\\n  com/google/protobuf/NullValue.java                           \\\n  com/google/protobuf/StringValue.java                         \\\n  com/google/protobuf/StringValueOrBuilder.java                \\\n  com/google/protobuf/Struct.java                              \\\n  com/google/protobuf/StructOrBuilder.java                     \\\n  com/google/protobuf/StructProto.java                         \\\n  com/google/protobuf/Timestamp.java                           \\\n  com/google/protobuf/TimestampOrBuilder.java                  \\\n  com/google/protobuf/TimestampProto.java                      \\\n  com/google/protobuf/UInt32Value.java                         \\\n  com/google/protobuf/UInt32ValueOrBuilder.java                \\\n  com/google/protobuf/UInt64Value.java                         \\\n  com/google/protobuf/UInt64ValueOrBuilder.java                \\\n  com/google/protobuf/Value.java                               \\\n  com/google/protobuf/ValueOrBuilder.java                      \\\n  com/google/protobuf/WrappersProto.java                       \\\n  google/protobuf/any.pb.cc                                    \\\n  google/protobuf/any.pb.h                                     \\\n  google/protobuf/any.rb                                       \\\n  google/protobuf/any_pb2.py                                   \\\n  google/protobuf/duration.pb.cc                               \\\n  google/protobuf/duration.pb.h                                \\\n  google/protobuf/duration.rb                                  \\\n  google/protobuf/duration_pb2.py                              \\\n  google/protobuf/field_mask.pb.cc                             \\\n  google/protobuf/field_mask.pb.h                              \\\n  google/protobuf/field_mask.rb                                \\\n  google/protobuf/field_mask_pb2.py                            \\\n  google/protobuf/struct.pb.cc                                 \\\n  google/protobuf/struct.pb.h                                  \\\n  google/protobuf/struct.rb                                    \\\n  google/protobuf/struct_pb2.py                                \\\n  google/protobuf/timestamp.pb.cc                              \\\n  google/protobuf/timestamp.pb.h                               \\\n  google/protobuf/timestamp.rb                                 \\\n  google/protobuf/timestamp_pb2.py                             \\\n  google/protobuf/wrappers.pb.cc                               \\\n  google/protobuf/wrappers.pb.h                                \\\n  google/protobuf/wrappers.rb                                  \\\n  google/protobuf/wrappers_pb2.py\n\n\n# All source files excepet C++/Objective-C ones should be explicitly listed\n# here because the autoconf tools don't include files of other languages\n# automatically.\nEXTRA_DIST = \\\n  ConformanceJava.java        \\\n  ConformanceJavaLite.java    \\\n  README.md                   \\\n  conformance.proto           \\\n  conformance_python.py       \\\n  conformance_ruby.rb         \\\n  failure_list_cpp.txt        \\\n  failure_list_csharp.txt     \\\n  failure_list_java.txt       \\\n  failure_list_objc.txt       \\\n  failure_list_python.txt     \\\n  failure_list_python_cpp.txt \\\n  failure_list_python-post26.txt \\\n  failure_list_ruby.txt\n\nconformance_test_runner_LDADD = $(top_srcdir)/src/libprotobuf.la\nconformance_test_runner_SOURCES = conformance_test.h conformance_test.cc \\\n                                  conformance_test_runner.cc             \\\n                                  third_party/jsoncpp/json.h             \\\n                                  third_party/jsoncpp/jsoncpp.cpp\n\nnodist_conformance_test_runner_SOURCES = conformance.pb.cc\nconformance_test_runner_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir)\nconformance_test_runner_CXXFLAGS = -std=c++11\nconformance_cpp_LDADD = $(top_srcdir)/src/libprotobuf.la\nconformance_cpp_SOURCES = conformance_cpp.cc\nnodist_conformance_cpp_SOURCES = conformance.pb.cc\nconformance_cpp_CPPFLAGS = -I$(top_srcdir)/src\n@OBJC_CONFORMANCE_TEST_TRUE@conformance_objc_SOURCES = conformance_objc.m ../objectivec/GPBProtocolBuffers.m\n@OBJC_CONFORMANCE_TEST_TRUE@nodist_conformance_objc_SOURCES = Conformance.pbobjc.m\n# On travis, the build fails without the isysroot because whatever system\n# headers are being found don't include generics support for\n# NSArray/NSDictionary, the only guess is their image at one time had an odd\n# setup for Xcode and old frameworks are being found.\n@OBJC_CONFORMANCE_TEST_TRUE@conformance_objc_CPPFLAGS = -I$(top_srcdir)/objectivec -isysroot `xcrun --sdk macosx --show-sdk-path`\n@OBJC_CONFORMANCE_TEST_TRUE@conformance_objc_LDFLAGS = -framework Foundation\nBUILT_SOURCES = $(protoc_outputs) $(other_language_protoc_outputs)\nCLEANFILES = $(protoc_outputs) protoc_middleman javac_middleman conformance-java javac_middleman_lite conformance-java-lite conformance-csharp $(other_language_protoc_outputs)\nMAINTAINERCLEANFILES = \\\n  Makefile.in\n\nall: $(BUILT_SOURCES)\n\t$(MAKE) $(AM_MAKEFLAGS) all-am\n\n.SUFFIXES:\n.SUFFIXES: .cc .cpp .lo .m .o .obj\n$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)\n\t@for dep in $?; do \\\n\t  case '$(am__configure_deps)' in \\\n\t    *$$dep*) \\\n\t      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \\\n\t        && { if test -f $@; then exit 0; else break; fi; }; \\\n\t      exit 1;; \\\n\t  esac; \\\n\tdone; \\\n\techo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign conformance/Makefile'; \\\n\t$(am__cd) $(top_srcdir) && \\\n\t  $(AUTOMAKE) --foreign conformance/Makefile\n.PRECIOUS: Makefile\nMakefile: $(srcdir)/Makefile.in $(top_builddir)/config.status\n\t@case '$?' in \\\n\t  *config.status*) \\\n\t    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \\\n\t  *) \\\n\t    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \\\n\t    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \\\n\tesac;\n\n$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)\n\tcd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh\n\n$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)\n\tcd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh\n$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)\n\tcd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh\n$(am__aclocal_m4_deps):\ninstall-binPROGRAMS: $(bin_PROGRAMS)\n\t@$(NORMAL_INSTALL)\n\t@list='$(bin_PROGRAMS)'; test -n \"$(bindir)\" || list=; \\\n\tif test -n \"$$list\"; then \\\n\t  echo \" $(MKDIR_P) '$(DESTDIR)$(bindir)'\"; \\\n\t  $(MKDIR_P) \"$(DESTDIR)$(bindir)\" || exit 1; \\\n\tfi; \\\n\tfor p in $$list; do echo \"$$p $$p\"; done | \\\n\tsed 's/$(EXEEXT)$$//' | \\\n\twhile read p p1; do if test -f $$p \\\n\t || test -f $$p1 \\\n\t  ; then echo \"$$p\"; echo \"$$p\"; else :; fi; \\\n\tdone | \\\n\tsed -e 'p;s,.*/,,;n;h' \\\n\t    -e 's|.*|.|' \\\n\t    -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \\\n\tsed 'N;N;N;s,\\n, ,g' | \\\n\t$(AWK) 'BEGIN { files[\".\"] = \"\"; dirs[\".\"] = 1 } \\\n\t  { d=$$3; if (dirs[d] != 1) { print \"d\", d; dirs[d] = 1 } \\\n\t    if ($$2 == $$4) files[d] = files[d] \" \" $$1; \\\n\t    else { print \"f\", $$3 \"/\" $$4, $$1; } } \\\n\t  END { for (d in files) print \"f\", d, files[d] }' | \\\n\twhile read type dir files; do \\\n\t    if test \"$$dir\" = .; then dir=; else dir=/$$dir; fi; \\\n\t    test -z \"$$files\" || { \\\n\t    echo \" $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'\"; \\\n\t    $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files \"$(DESTDIR)$(bindir)$$dir\" || exit $$?; \\\n\t    } \\\n\t; done\n\nuninstall-binPROGRAMS:\n\t@$(NORMAL_UNINSTALL)\n\t@list='$(bin_PROGRAMS)'; test -n \"$(bindir)\" || list=; \\\n\tfiles=`for p in $$list; do echo \"$$p\"; done | \\\n\t  sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \\\n\t      -e 's/$$/$(EXEEXT)/' \\\n\t`; \\\n\ttest -n \"$$list\" || exit 0; \\\n\techo \" ( cd '$(DESTDIR)$(bindir)' && rm -f\" $$files \")\"; \\\n\tcd \"$(DESTDIR)$(bindir)\" && rm -f $$files\n\nclean-binPROGRAMS:\n\t@list='$(bin_PROGRAMS)'; test -n \"$$list\" || exit 0; \\\n\techo \" rm -f\" $$list; \\\n\trm -f $$list || exit $$?; \\\n\ttest -n \"$(EXEEXT)\" || exit 0; \\\n\tlist=`for p in $$list; do echo \"$$p\"; done | sed 's/$(EXEEXT)$$//'`; \\\n\techo \" rm -f\" $$list; \\\n\trm -f $$list\n\nconformance-cpp$(EXEEXT): $(conformance_cpp_OBJECTS) $(conformance_cpp_DEPENDENCIES) $(EXTRA_conformance_cpp_DEPENDENCIES) \n\t@rm -f conformance-cpp$(EXEEXT)\n\t$(AM_V_CXXLD)$(CXXLINK) $(conformance_cpp_OBJECTS) $(conformance_cpp_LDADD) $(LIBS)\n../objectivec/$(am__dirstamp):\n\t@$(MKDIR_P) ../objectivec\n\t@: > ../objectivec/$(am__dirstamp)\n../objectivec/$(DEPDIR)/$(am__dirstamp):\n\t@$(MKDIR_P) ../objectivec/$(DEPDIR)\n\t@: > ../objectivec/$(DEPDIR)/$(am__dirstamp)\n../objectivec/conformance_objc-GPBProtocolBuffers.$(OBJEXT):  \\\n\t../objectivec/$(am__dirstamp) \\\n\t../objectivec/$(DEPDIR)/$(am__dirstamp)\n\nconformance-objc$(EXEEXT): $(conformance_objc_OBJECTS) $(conformance_objc_DEPENDENCIES) $(EXTRA_conformance_objc_DEPENDENCIES) \n\t@rm -f conformance-objc$(EXEEXT)\n\t$(AM_V_OBJCLD)$(conformance_objc_LINK) $(conformance_objc_OBJECTS) $(conformance_objc_LDADD) $(LIBS)\nthird_party/jsoncpp/$(am__dirstamp):\n\t@$(MKDIR_P) third_party/jsoncpp\n\t@: > third_party/jsoncpp/$(am__dirstamp)\nthird_party/jsoncpp/$(DEPDIR)/$(am__dirstamp):\n\t@$(MKDIR_P) third_party/jsoncpp/$(DEPDIR)\n\t@: > third_party/jsoncpp/$(DEPDIR)/$(am__dirstamp)\nthird_party/jsoncpp/conformance_test_runner-jsoncpp.$(OBJEXT):  \\\n\tthird_party/jsoncpp/$(am__dirstamp) \\\n\tthird_party/jsoncpp/$(DEPDIR)/$(am__dirstamp)\n\nconformance-test-runner$(EXEEXT): $(conformance_test_runner_OBJECTS) $(conformance_test_runner_DEPENDENCIES) $(EXTRA_conformance_test_runner_DEPENDENCIES) \n\t@rm -f conformance-test-runner$(EXEEXT)\n\t$(AM_V_CXXLD)$(conformance_test_runner_LINK) $(conformance_test_runner_OBJECTS) $(conformance_test_runner_LDADD) $(LIBS)\n\nmostlyclean-compile:\n\t-rm -f *.$(OBJEXT)\n\t-rm -f ../objectivec/*.$(OBJEXT)\n\t-rm -f third_party/jsoncpp/*.$(OBJEXT)\n\ndistclean-compile:\n\t-rm -f *.tab.c\n\n@AMDEP_TRUE@@am__include@ @am__quote@../objectivec/$(DEPDIR)/conformance_objc-GPBProtocolBuffers.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conformance_cpp-conformance.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conformance_cpp-conformance_cpp.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conformance_objc-Conformance.pbobjc.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conformance_objc-conformance_objc.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conformance_test_runner-conformance.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conformance_test_runner-conformance_test.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/conformance_test_runner-conformance_test_runner.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@third_party/jsoncpp/$(DEPDIR)/conformance_test_runner-jsoncpp.Po@am__quote@\n\n.cc.o:\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\\.o$$||'`;\\\n@am__fastdepCXX_TRUE@\t$(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\\\n@am__fastdepCXX_TRUE@\t$(am__mv) $$depbase.Tpo $$depbase.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<\n\n.cc.obj:\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\\.obj$$||'`;\\\n@am__fastdepCXX_TRUE@\t$(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\\\n@am__fastdepCXX_TRUE@\t$(am__mv) $$depbase.Tpo $$depbase.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`\n\n.cc.lo:\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\\.lo$$||'`;\\\n@am__fastdepCXX_TRUE@\t$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\\\n@am__fastdepCXX_TRUE@\t$(am__mv) $$depbase.Tpo $$depbase.Plo\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<\n\nconformance_cpp-conformance_cpp.o: conformance_cpp.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_cpp_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT conformance_cpp-conformance_cpp.o -MD -MP -MF $(DEPDIR)/conformance_cpp-conformance_cpp.Tpo -c -o conformance_cpp-conformance_cpp.o `test -f 'conformance_cpp.cc' || echo '$(srcdir)/'`conformance_cpp.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) $(DEPDIR)/conformance_cpp-conformance_cpp.Tpo $(DEPDIR)/conformance_cpp-conformance_cpp.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='conformance_cpp.cc' object='conformance_cpp-conformance_cpp.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_cpp_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o conformance_cpp-conformance_cpp.o `test -f 'conformance_cpp.cc' || echo '$(srcdir)/'`conformance_cpp.cc\n\nconformance_cpp-conformance_cpp.obj: conformance_cpp.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_cpp_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT conformance_cpp-conformance_cpp.obj -MD -MP -MF $(DEPDIR)/conformance_cpp-conformance_cpp.Tpo -c -o conformance_cpp-conformance_cpp.obj `if test -f 'conformance_cpp.cc'; then $(CYGPATH_W) 'conformance_cpp.cc'; else $(CYGPATH_W) '$(srcdir)/conformance_cpp.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) $(DEPDIR)/conformance_cpp-conformance_cpp.Tpo $(DEPDIR)/conformance_cpp-conformance_cpp.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='conformance_cpp.cc' object='conformance_cpp-conformance_cpp.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_cpp_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o conformance_cpp-conformance_cpp.obj `if test -f 'conformance_cpp.cc'; then $(CYGPATH_W) 'conformance_cpp.cc'; else $(CYGPATH_W) '$(srcdir)/conformance_cpp.cc'; fi`\n\nconformance_cpp-conformance.pb.o: conformance.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_cpp_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT conformance_cpp-conformance.pb.o -MD -MP -MF $(DEPDIR)/conformance_cpp-conformance.pb.Tpo -c -o conformance_cpp-conformance.pb.o `test -f 'conformance.pb.cc' || echo '$(srcdir)/'`conformance.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) $(DEPDIR)/conformance_cpp-conformance.pb.Tpo $(DEPDIR)/conformance_cpp-conformance.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='conformance.pb.cc' object='conformance_cpp-conformance.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_cpp_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o conformance_cpp-conformance.pb.o `test -f 'conformance.pb.cc' || echo '$(srcdir)/'`conformance.pb.cc\n\nconformance_cpp-conformance.pb.obj: conformance.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_cpp_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT conformance_cpp-conformance.pb.obj -MD -MP -MF $(DEPDIR)/conformance_cpp-conformance.pb.Tpo -c -o conformance_cpp-conformance.pb.obj `if test -f 'conformance.pb.cc'; then $(CYGPATH_W) 'conformance.pb.cc'; else $(CYGPATH_W) '$(srcdir)/conformance.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) $(DEPDIR)/conformance_cpp-conformance.pb.Tpo $(DEPDIR)/conformance_cpp-conformance.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='conformance.pb.cc' object='conformance_cpp-conformance.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_cpp_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o conformance_cpp-conformance.pb.obj `if test -f 'conformance.pb.cc'; then $(CYGPATH_W) 'conformance.pb.cc'; else $(CYGPATH_W) '$(srcdir)/conformance.pb.cc'; fi`\n\nconformance_test_runner-conformance_test.o: conformance_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -MT conformance_test_runner-conformance_test.o -MD -MP -MF $(DEPDIR)/conformance_test_runner-conformance_test.Tpo -c -o conformance_test_runner-conformance_test.o `test -f 'conformance_test.cc' || echo '$(srcdir)/'`conformance_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) $(DEPDIR)/conformance_test_runner-conformance_test.Tpo $(DEPDIR)/conformance_test_runner-conformance_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='conformance_test.cc' object='conformance_test_runner-conformance_test.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -c -o conformance_test_runner-conformance_test.o `test -f 'conformance_test.cc' || echo '$(srcdir)/'`conformance_test.cc\n\nconformance_test_runner-conformance_test.obj: conformance_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -MT conformance_test_runner-conformance_test.obj -MD -MP -MF $(DEPDIR)/conformance_test_runner-conformance_test.Tpo -c -o conformance_test_runner-conformance_test.obj `if test -f 'conformance_test.cc'; then $(CYGPATH_W) 'conformance_test.cc'; else $(CYGPATH_W) '$(srcdir)/conformance_test.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) $(DEPDIR)/conformance_test_runner-conformance_test.Tpo $(DEPDIR)/conformance_test_runner-conformance_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='conformance_test.cc' object='conformance_test_runner-conformance_test.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -c -o conformance_test_runner-conformance_test.obj `if test -f 'conformance_test.cc'; then $(CYGPATH_W) 'conformance_test.cc'; else $(CYGPATH_W) '$(srcdir)/conformance_test.cc'; fi`\n\nconformance_test_runner-conformance_test_runner.o: conformance_test_runner.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -MT conformance_test_runner-conformance_test_runner.o -MD -MP -MF $(DEPDIR)/conformance_test_runner-conformance_test_runner.Tpo -c -o conformance_test_runner-conformance_test_runner.o `test -f 'conformance_test_runner.cc' || echo '$(srcdir)/'`conformance_test_runner.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) $(DEPDIR)/conformance_test_runner-conformance_test_runner.Tpo $(DEPDIR)/conformance_test_runner-conformance_test_runner.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='conformance_test_runner.cc' object='conformance_test_runner-conformance_test_runner.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -c -o conformance_test_runner-conformance_test_runner.o `test -f 'conformance_test_runner.cc' || echo '$(srcdir)/'`conformance_test_runner.cc\n\nconformance_test_runner-conformance_test_runner.obj: conformance_test_runner.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -MT conformance_test_runner-conformance_test_runner.obj -MD -MP -MF $(DEPDIR)/conformance_test_runner-conformance_test_runner.Tpo -c -o conformance_test_runner-conformance_test_runner.obj `if test -f 'conformance_test_runner.cc'; then $(CYGPATH_W) 'conformance_test_runner.cc'; else $(CYGPATH_W) '$(srcdir)/conformance_test_runner.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) $(DEPDIR)/conformance_test_runner-conformance_test_runner.Tpo $(DEPDIR)/conformance_test_runner-conformance_test_runner.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='conformance_test_runner.cc' object='conformance_test_runner-conformance_test_runner.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -c -o conformance_test_runner-conformance_test_runner.obj `if test -f 'conformance_test_runner.cc'; then $(CYGPATH_W) 'conformance_test_runner.cc'; else $(CYGPATH_W) '$(srcdir)/conformance_test_runner.cc'; fi`\n\nthird_party/jsoncpp/conformance_test_runner-jsoncpp.o: third_party/jsoncpp/jsoncpp.cpp\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -MT third_party/jsoncpp/conformance_test_runner-jsoncpp.o -MD -MP -MF third_party/jsoncpp/$(DEPDIR)/conformance_test_runner-jsoncpp.Tpo -c -o third_party/jsoncpp/conformance_test_runner-jsoncpp.o `test -f 'third_party/jsoncpp/jsoncpp.cpp' || echo '$(srcdir)/'`third_party/jsoncpp/jsoncpp.cpp\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) third_party/jsoncpp/$(DEPDIR)/conformance_test_runner-jsoncpp.Tpo third_party/jsoncpp/$(DEPDIR)/conformance_test_runner-jsoncpp.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='third_party/jsoncpp/jsoncpp.cpp' object='third_party/jsoncpp/conformance_test_runner-jsoncpp.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -c -o third_party/jsoncpp/conformance_test_runner-jsoncpp.o `test -f 'third_party/jsoncpp/jsoncpp.cpp' || echo '$(srcdir)/'`third_party/jsoncpp/jsoncpp.cpp\n\nthird_party/jsoncpp/conformance_test_runner-jsoncpp.obj: third_party/jsoncpp/jsoncpp.cpp\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -MT third_party/jsoncpp/conformance_test_runner-jsoncpp.obj -MD -MP -MF third_party/jsoncpp/$(DEPDIR)/conformance_test_runner-jsoncpp.Tpo -c -o third_party/jsoncpp/conformance_test_runner-jsoncpp.obj `if test -f 'third_party/jsoncpp/jsoncpp.cpp'; then $(CYGPATH_W) 'third_party/jsoncpp/jsoncpp.cpp'; else $(CYGPATH_W) '$(srcdir)/third_party/jsoncpp/jsoncpp.cpp'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) third_party/jsoncpp/$(DEPDIR)/conformance_test_runner-jsoncpp.Tpo third_party/jsoncpp/$(DEPDIR)/conformance_test_runner-jsoncpp.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='third_party/jsoncpp/jsoncpp.cpp' object='third_party/jsoncpp/conformance_test_runner-jsoncpp.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -c -o third_party/jsoncpp/conformance_test_runner-jsoncpp.obj `if test -f 'third_party/jsoncpp/jsoncpp.cpp'; then $(CYGPATH_W) 'third_party/jsoncpp/jsoncpp.cpp'; else $(CYGPATH_W) '$(srcdir)/third_party/jsoncpp/jsoncpp.cpp'; fi`\n\nconformance_test_runner-conformance.pb.o: conformance.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -MT conformance_test_runner-conformance.pb.o -MD -MP -MF $(DEPDIR)/conformance_test_runner-conformance.pb.Tpo -c -o conformance_test_runner-conformance.pb.o `test -f 'conformance.pb.cc' || echo '$(srcdir)/'`conformance.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) $(DEPDIR)/conformance_test_runner-conformance.pb.Tpo $(DEPDIR)/conformance_test_runner-conformance.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='conformance.pb.cc' object='conformance_test_runner-conformance.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -c -o conformance_test_runner-conformance.pb.o `test -f 'conformance.pb.cc' || echo '$(srcdir)/'`conformance.pb.cc\n\nconformance_test_runner-conformance.pb.obj: conformance.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -MT conformance_test_runner-conformance.pb.obj -MD -MP -MF $(DEPDIR)/conformance_test_runner-conformance.pb.Tpo -c -o conformance_test_runner-conformance.pb.obj `if test -f 'conformance.pb.cc'; then $(CYGPATH_W) 'conformance.pb.cc'; else $(CYGPATH_W) '$(srcdir)/conformance.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) $(DEPDIR)/conformance_test_runner-conformance.pb.Tpo $(DEPDIR)/conformance_test_runner-conformance.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='conformance.pb.cc' object='conformance_test_runner-conformance.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_test_runner_CPPFLAGS) $(CPPFLAGS) $(conformance_test_runner_CXXFLAGS) $(CXXFLAGS) -c -o conformance_test_runner-conformance.pb.obj `if test -f 'conformance.pb.cc'; then $(CYGPATH_W) 'conformance.pb.cc'; else $(CYGPATH_W) '$(srcdir)/conformance.pb.cc'; fi`\n\n.cpp.o:\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\\.o$$||'`;\\\n@am__fastdepCXX_TRUE@\t$(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\\\n@am__fastdepCXX_TRUE@\t$(am__mv) $$depbase.Tpo $$depbase.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<\n\n.cpp.obj:\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\\.obj$$||'`;\\\n@am__fastdepCXX_TRUE@\t$(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\\\n@am__fastdepCXX_TRUE@\t$(am__mv) $$depbase.Tpo $$depbase.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`\n\n.cpp.lo:\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\\.lo$$||'`;\\\n@am__fastdepCXX_TRUE@\t$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\\\n@am__fastdepCXX_TRUE@\t$(am__mv) $$depbase.Tpo $$depbase.Plo\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<\n\n.m.o:\n@am__fastdepOBJC_TRUE@\t$(AM_V_OBJC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\\.o$$||'`;\\\n@am__fastdepOBJC_TRUE@\t$(OBJCCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\\\n@am__fastdepOBJC_TRUE@\t$(am__mv) $$depbase.Tpo $$depbase.Po\n@AMDEP_TRUE@@am__fastdepOBJC_FALSE@\t$(AM_V_OBJC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepOBJC_FALSE@\tDEPDIR=$(DEPDIR) $(OBJCDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepOBJC_FALSE@\t$(AM_V_OBJC@am__nodep@)$(OBJCCOMPILE) -c -o $@ $<\n\n.m.obj:\n@am__fastdepOBJC_TRUE@\t$(AM_V_OBJC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\\.obj$$||'`;\\\n@am__fastdepOBJC_TRUE@\t$(OBJCCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\\\n@am__fastdepOBJC_TRUE@\t$(am__mv) $$depbase.Tpo $$depbase.Po\n@AMDEP_TRUE@@am__fastdepOBJC_FALSE@\t$(AM_V_OBJC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepOBJC_FALSE@\tDEPDIR=$(DEPDIR) $(OBJCDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepOBJC_FALSE@\t$(AM_V_OBJC@am__nodep@)$(OBJCCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`\n\n.m.lo:\n@am__fastdepOBJC_TRUE@\t$(AM_V_OBJC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\\.lo$$||'`;\\\n@am__fastdepOBJC_TRUE@\t$(LTOBJCCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\\\n@am__fastdepOBJC_TRUE@\t$(am__mv) $$depbase.Tpo $$depbase.Plo\n@AMDEP_TRUE@@am__fastdepOBJC_FALSE@\t$(AM_V_OBJC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepOBJC_FALSE@\tDEPDIR=$(DEPDIR) $(OBJCDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepOBJC_FALSE@\t$(AM_V_OBJC@am__nodep@)$(LTOBJCCOMPILE) -c -o $@ $<\n\nconformance_objc-conformance_objc.o: conformance_objc.m\n@am__fastdepOBJC_TRUE@\t$(AM_V_OBJC)$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_objc_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS) -MT conformance_objc-conformance_objc.o -MD -MP -MF $(DEPDIR)/conformance_objc-conformance_objc.Tpo -c -o conformance_objc-conformance_objc.o `test -f 'conformance_objc.m' || echo '$(srcdir)/'`conformance_objc.m\n@am__fastdepOBJC_TRUE@\t$(AM_V_at)$(am__mv) $(DEPDIR)/conformance_objc-conformance_objc.Tpo $(DEPDIR)/conformance_objc-conformance_objc.Po\n@AMDEP_TRUE@@am__fastdepOBJC_FALSE@\t$(AM_V_OBJC)source='conformance_objc.m' object='conformance_objc-conformance_objc.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepOBJC_FALSE@\tDEPDIR=$(DEPDIR) $(OBJCDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepOBJC_FALSE@\t$(AM_V_OBJC@am__nodep@)$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_objc_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS) -c -o conformance_objc-conformance_objc.o `test -f 'conformance_objc.m' || echo '$(srcdir)/'`conformance_objc.m\n\nconformance_objc-conformance_objc.obj: conformance_objc.m\n@am__fastdepOBJC_TRUE@\t$(AM_V_OBJC)$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_objc_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS) -MT conformance_objc-conformance_objc.obj -MD -MP -MF $(DEPDIR)/conformance_objc-conformance_objc.Tpo -c -o conformance_objc-conformance_objc.obj `if test -f 'conformance_objc.m'; then $(CYGPATH_W) 'conformance_objc.m'; else $(CYGPATH_W) '$(srcdir)/conformance_objc.m'; fi`\n@am__fastdepOBJC_TRUE@\t$(AM_V_at)$(am__mv) $(DEPDIR)/conformance_objc-conformance_objc.Tpo $(DEPDIR)/conformance_objc-conformance_objc.Po\n@AMDEP_TRUE@@am__fastdepOBJC_FALSE@\t$(AM_V_OBJC)source='conformance_objc.m' object='conformance_objc-conformance_objc.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepOBJC_FALSE@\tDEPDIR=$(DEPDIR) $(OBJCDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepOBJC_FALSE@\t$(AM_V_OBJC@am__nodep@)$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_objc_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS) -c -o conformance_objc-conformance_objc.obj `if test -f 'conformance_objc.m'; then $(CYGPATH_W) 'conformance_objc.m'; else $(CYGPATH_W) '$(srcdir)/conformance_objc.m'; fi`\n\n../objectivec/conformance_objc-GPBProtocolBuffers.o: ../objectivec/GPBProtocolBuffers.m\n@am__fastdepOBJC_TRUE@\t$(AM_V_OBJC)$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_objc_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS) -MT ../objectivec/conformance_objc-GPBProtocolBuffers.o -MD -MP -MF ../objectivec/$(DEPDIR)/conformance_objc-GPBProtocolBuffers.Tpo -c -o ../objectivec/conformance_objc-GPBProtocolBuffers.o `test -f '../objectivec/GPBProtocolBuffers.m' || echo '$(srcdir)/'`../objectivec/GPBProtocolBuffers.m\n@am__fastdepOBJC_TRUE@\t$(AM_V_at)$(am__mv) ../objectivec/$(DEPDIR)/conformance_objc-GPBProtocolBuffers.Tpo ../objectivec/$(DEPDIR)/conformance_objc-GPBProtocolBuffers.Po\n@AMDEP_TRUE@@am__fastdepOBJC_FALSE@\t$(AM_V_OBJC)source='../objectivec/GPBProtocolBuffers.m' object='../objectivec/conformance_objc-GPBProtocolBuffers.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepOBJC_FALSE@\tDEPDIR=$(DEPDIR) $(OBJCDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepOBJC_FALSE@\t$(AM_V_OBJC@am__nodep@)$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_objc_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS) -c -o ../objectivec/conformance_objc-GPBProtocolBuffers.o `test -f '../objectivec/GPBProtocolBuffers.m' || echo '$(srcdir)/'`../objectivec/GPBProtocolBuffers.m\n\n../objectivec/conformance_objc-GPBProtocolBuffers.obj: ../objectivec/GPBProtocolBuffers.m\n@am__fastdepOBJC_TRUE@\t$(AM_V_OBJC)$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_objc_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS) -MT ../objectivec/conformance_objc-GPBProtocolBuffers.obj -MD -MP -MF ../objectivec/$(DEPDIR)/conformance_objc-GPBProtocolBuffers.Tpo -c -o ../objectivec/conformance_objc-GPBProtocolBuffers.obj `if test -f '../objectivec/GPBProtocolBuffers.m'; then $(CYGPATH_W) '../objectivec/GPBProtocolBuffers.m'; else $(CYGPATH_W) '$(srcdir)/../objectivec/GPBProtocolBuffers.m'; fi`\n@am__fastdepOBJC_TRUE@\t$(AM_V_at)$(am__mv) ../objectivec/$(DEPDIR)/conformance_objc-GPBProtocolBuffers.Tpo ../objectivec/$(DEPDIR)/conformance_objc-GPBProtocolBuffers.Po\n@AMDEP_TRUE@@am__fastdepOBJC_FALSE@\t$(AM_V_OBJC)source='../objectivec/GPBProtocolBuffers.m' object='../objectivec/conformance_objc-GPBProtocolBuffers.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepOBJC_FALSE@\tDEPDIR=$(DEPDIR) $(OBJCDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepOBJC_FALSE@\t$(AM_V_OBJC@am__nodep@)$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_objc_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS) -c -o ../objectivec/conformance_objc-GPBProtocolBuffers.obj `if test -f '../objectivec/GPBProtocolBuffers.m'; then $(CYGPATH_W) '../objectivec/GPBProtocolBuffers.m'; else $(CYGPATH_W) '$(srcdir)/../objectivec/GPBProtocolBuffers.m'; fi`\n\nconformance_objc-Conformance.pbobjc.o: Conformance.pbobjc.m\n@am__fastdepOBJC_TRUE@\t$(AM_V_OBJC)$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_objc_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS) -MT conformance_objc-Conformance.pbobjc.o -MD -MP -MF $(DEPDIR)/conformance_objc-Conformance.pbobjc.Tpo -c -o conformance_objc-Conformance.pbobjc.o `test -f 'Conformance.pbobjc.m' || echo '$(srcdir)/'`Conformance.pbobjc.m\n@am__fastdepOBJC_TRUE@\t$(AM_V_at)$(am__mv) $(DEPDIR)/conformance_objc-Conformance.pbobjc.Tpo $(DEPDIR)/conformance_objc-Conformance.pbobjc.Po\n@AMDEP_TRUE@@am__fastdepOBJC_FALSE@\t$(AM_V_OBJC)source='Conformance.pbobjc.m' object='conformance_objc-Conformance.pbobjc.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepOBJC_FALSE@\tDEPDIR=$(DEPDIR) $(OBJCDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepOBJC_FALSE@\t$(AM_V_OBJC@am__nodep@)$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_objc_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS) -c -o conformance_objc-Conformance.pbobjc.o `test -f 'Conformance.pbobjc.m' || echo '$(srcdir)/'`Conformance.pbobjc.m\n\nconformance_objc-Conformance.pbobjc.obj: Conformance.pbobjc.m\n@am__fastdepOBJC_TRUE@\t$(AM_V_OBJC)$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_objc_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS) -MT conformance_objc-Conformance.pbobjc.obj -MD -MP -MF $(DEPDIR)/conformance_objc-Conformance.pbobjc.Tpo -c -o conformance_objc-Conformance.pbobjc.obj `if test -f 'Conformance.pbobjc.m'; then $(CYGPATH_W) 'Conformance.pbobjc.m'; else $(CYGPATH_W) '$(srcdir)/Conformance.pbobjc.m'; fi`\n@am__fastdepOBJC_TRUE@\t$(AM_V_at)$(am__mv) $(DEPDIR)/conformance_objc-Conformance.pbobjc.Tpo $(DEPDIR)/conformance_objc-Conformance.pbobjc.Po\n@AMDEP_TRUE@@am__fastdepOBJC_FALSE@\t$(AM_V_OBJC)source='Conformance.pbobjc.m' object='conformance_objc-Conformance.pbobjc.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepOBJC_FALSE@\tDEPDIR=$(DEPDIR) $(OBJCDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepOBJC_FALSE@\t$(AM_V_OBJC@am__nodep@)$(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(conformance_objc_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS) -c -o conformance_objc-Conformance.pbobjc.obj `if test -f 'Conformance.pbobjc.m'; then $(CYGPATH_W) 'Conformance.pbobjc.m'; else $(CYGPATH_W) '$(srcdir)/Conformance.pbobjc.m'; fi`\n\nmostlyclean-libtool:\n\t-rm -f *.lo\n\nclean-libtool:\n\t-rm -rf .libs _libs\n\nID: $(am__tagged_files)\n\t$(am__define_uniq_tagged_files); mkid -fID $$unique\ntags: tags-am\nTAGS: tags\n\ntags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)\n\tset x; \\\n\there=`pwd`; \\\n\t$(am__define_uniq_tagged_files); \\\n\tshift; \\\n\tif test -z \"$(ETAGS_ARGS)$$*$$unique\"; then :; else \\\n\t  test -n \"$$unique\" || unique=$$empty_fix; \\\n\t  if test $$# -gt 0; then \\\n\t    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \\\n\t      \"$$@\" $$unique; \\\n\t  else \\\n\t    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \\\n\t      $$unique; \\\n\t  fi; \\\n\tfi\nctags: ctags-am\n\nCTAGS: ctags\nctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)\n\t$(am__define_uniq_tagged_files); \\\n\ttest -z \"$(CTAGS_ARGS)$$unique\" \\\n\t  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \\\n\t     $$unique\n\nGTAGS:\n\there=`$(am__cd) $(top_builddir) && pwd` \\\n\t  && $(am__cd) $(top_srcdir) \\\n\t  && gtags -i $(GTAGS_ARGS) \"$$here\"\ncscopelist: cscopelist-am\n\ncscopelist-am: $(am__tagged_files)\n\tlist='$(am__tagged_files)'; \\\n\tcase \"$(srcdir)\" in \\\n\t  [\\\\/]* | ?:[\\\\/]*) sdir=\"$(srcdir)\" ;; \\\n\t  *) sdir=$(subdir)/$(srcdir) ;; \\\n\tesac; \\\n\tfor i in $$list; do \\\n\t  if test -f \"$$i\"; then \\\n\t    echo \"$(subdir)/$$i\"; \\\n\t  else \\\n\t    echo \"$$sdir/$$i\"; \\\n\t  fi; \\\n\tdone >> $(top_builddir)/cscope.files\n\ndistclean-tags:\n\t-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags\n\ndistdir: $(DISTFILES)\n\t@srcdirstrip=`echo \"$(srcdir)\" | sed 's/[].[^$$\\\\*]/\\\\\\\\&/g'`; \\\n\ttopsrcdirstrip=`echo \"$(top_srcdir)\" | sed 's/[].[^$$\\\\*]/\\\\\\\\&/g'`; \\\n\tlist='$(DISTFILES)'; \\\n\t  dist_files=`for file in $$list; do echo $$file; done | \\\n\t  sed -e \"s|^$$srcdirstrip/||;t\" \\\n\t      -e \"s|^$$topsrcdirstrip/|$(top_builddir)/|;t\"`; \\\n\tcase $$dist_files in \\\n\t  */*) $(MKDIR_P) `echo \"$$dist_files\" | \\\n\t\t\t   sed '/\\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \\\n\t\t\t   sort -u` ;; \\\n\tesac; \\\n\tfor file in $$dist_files; do \\\n\t  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \\\n\t  if test -d $$d/$$file; then \\\n\t    dir=`echo \"/$$file\" | sed -e 's,/[^/]*$$,,'`; \\\n\t    if test -d \"$(distdir)/$$file\"; then \\\n\t      find \"$(distdir)/$$file\" -type d ! -perm -700 -exec chmod u+rwx {} \\;; \\\n\t    fi; \\\n\t    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \\\n\t      cp -fpR $(srcdir)/$$file \"$(distdir)$$dir\" || exit 1; \\\n\t      find \"$(distdir)/$$file\" -type d ! -perm -700 -exec chmod u+rwx {} \\;; \\\n\t    fi; \\\n\t    cp -fpR $$d/$$file \"$(distdir)$$dir\" || exit 1; \\\n\t  else \\\n\t    test -f \"$(distdir)/$$file\" \\\n\t    || cp -p $$d/$$file \"$(distdir)/$$file\" \\\n\t    || exit 1; \\\n\t  fi; \\\n\tdone\ncheck-am: all-am\ncheck: $(BUILT_SOURCES)\n\t$(MAKE) $(AM_MAKEFLAGS) check-am\nall-am: Makefile $(PROGRAMS)\ninstalldirs:\n\tfor dir in \"$(DESTDIR)$(bindir)\"; do \\\n\t  test -z \"$$dir\" || $(MKDIR_P) \"$$dir\"; \\\n\tdone\ninstall: $(BUILT_SOURCES)\n\t$(MAKE) $(AM_MAKEFLAGS) install-am\ninstall-exec: install-exec-am\ninstall-data: install-data-am\nuninstall: uninstall-am\n\ninstall-am: all-am\n\t@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am\n\ninstallcheck: installcheck-am\ninstall-strip:\n\tif test -z '$(STRIP)'; then \\\n\t  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM=\"$(INSTALL_STRIP_PROGRAM)\" \\\n\t    install_sh_PROGRAM=\"$(INSTALL_STRIP_PROGRAM)\" INSTALL_STRIP_FLAG=-s \\\n\t      install; \\\n\telse \\\n\t  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM=\"$(INSTALL_STRIP_PROGRAM)\" \\\n\t    install_sh_PROGRAM=\"$(INSTALL_STRIP_PROGRAM)\" INSTALL_STRIP_FLAG=-s \\\n\t    \"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'\" install; \\\n\tfi\nmostlyclean-generic:\n\nclean-generic:\n\t-test -z \"$(CLEANFILES)\" || rm -f $(CLEANFILES)\n\ndistclean-generic:\n\t-test -z \"$(CONFIG_CLEAN_FILES)\" || rm -f $(CONFIG_CLEAN_FILES)\n\t-test . = \"$(srcdir)\" || test -z \"$(CONFIG_CLEAN_VPATH_FILES)\" || rm -f $(CONFIG_CLEAN_VPATH_FILES)\n\t-rm -f ../objectivec/$(DEPDIR)/$(am__dirstamp)\n\t-rm -f ../objectivec/$(am__dirstamp)\n\t-rm -f third_party/jsoncpp/$(DEPDIR)/$(am__dirstamp)\n\t-rm -f third_party/jsoncpp/$(am__dirstamp)\n\nmaintainer-clean-generic:\n\t@echo \"This command is intended for maintainers to use\"\n\t@echo \"it deletes files that may require special tools to rebuild.\"\n\t-test -z \"$(BUILT_SOURCES)\" || rm -f $(BUILT_SOURCES)\n\t-test -z \"$(MAINTAINERCLEANFILES)\" || rm -f $(MAINTAINERCLEANFILES)\nclean: clean-am\n\nclean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am\n\ndistclean: distclean-am\n\t-rm -rf ../objectivec/$(DEPDIR) ./$(DEPDIR) third_party/jsoncpp/$(DEPDIR)\n\t-rm -f Makefile\ndistclean-am: clean-am distclean-compile distclean-generic \\\n\tdistclean-tags\n\ndvi: dvi-am\n\ndvi-am:\n\nhtml: html-am\n\nhtml-am:\n\ninfo: info-am\n\ninfo-am:\n\ninstall-data-am:\n\ninstall-dvi: install-dvi-am\n\ninstall-dvi-am:\n\ninstall-exec-am: install-binPROGRAMS\n\ninstall-html: install-html-am\n\ninstall-html-am:\n\ninstall-info: install-info-am\n\ninstall-info-am:\n\ninstall-man:\n\ninstall-pdf: install-pdf-am\n\ninstall-pdf-am:\n\ninstall-ps: install-ps-am\n\ninstall-ps-am:\n\ninstallcheck-am:\n\nmaintainer-clean: maintainer-clean-am\n\t-rm -rf ../objectivec/$(DEPDIR) ./$(DEPDIR) third_party/jsoncpp/$(DEPDIR)\n\t-rm -f Makefile\nmaintainer-clean-am: distclean-am maintainer-clean-generic\n\nmostlyclean: mostlyclean-am\n\nmostlyclean-am: mostlyclean-compile mostlyclean-generic \\\n\tmostlyclean-libtool\n\npdf: pdf-am\n\npdf-am:\n\nps: ps-am\n\nps-am:\n\nuninstall-am: uninstall-binPROGRAMS\n\n.MAKE: all check install install-am install-strip\n\n.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \\\n\tclean-binPROGRAMS clean-generic clean-libtool cscopelist-am \\\n\tctags ctags-am distclean distclean-compile distclean-generic \\\n\tdistclean-libtool distclean-tags distdir dvi dvi-am html \\\n\thtml-am info info-am install install-am install-binPROGRAMS \\\n\tinstall-data install-data-am install-dvi install-dvi-am \\\n\tinstall-exec install-exec-am install-html install-html-am \\\n\tinstall-info install-info-am install-man install-pdf \\\n\tinstall-pdf-am install-ps install-ps-am install-strip \\\n\tinstallcheck installcheck-am installdirs maintainer-clean \\\n\tmaintainer-clean-generic mostlyclean mostlyclean-compile \\\n\tmostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \\\n\ttags tags-am uninstall uninstall-am uninstall-binPROGRAMS\n\n  # lite/com/google/protobuf/Any.java                            \\\n  # lite/com/google/protobuf/AnyOrBuilder.java                   \\\n  # lite/com/google/protobuf/AnyProto.java                       \\\n  # lite/com/google/protobuf/BoolValue.java                      \\\n  # lite/com/google/protobuf/BoolValueOrBuilder.java             \\\n  # lite/com/google/protobuf/BytesValue.java                     \\\n  # lite/com/google/protobuf/BytesValueOrBuilder.java            \\\n  # lite/com/google/protobuf/conformance/Conformance.java        \\\n  # lite/com/google/protobuf/DoubleValue.java                    \\\n  # lite/com/google/protobuf/DoubleValueOrBuilder.java           \\\n  # lite/com/google/protobuf/Duration.java                       \\\n  # lite/com/google/protobuf/DurationOrBuilder.java              \\\n  # lite/com/google/protobuf/DurationProto.java                  \\\n  # lite/com/google/protobuf/FieldMask.java                      \\\n  # lite/com/google/protobuf/FieldMaskOrBuilder.java             \\\n  # lite/com/google/protobuf/FieldMaskProto.java                 \\\n  # lite/com/google/protobuf/FloatValue.java                     \\\n  # lite/com/google/protobuf/FloatValueOrBuilder.java            \\\n  # lite/com/google/protobuf/Int32Value.java                     \\\n  # lite/com/google/protobuf/Int32ValueOrBuilder.java            \\\n  # lite/com/google/protobuf/Int64Value.java                     \\\n  # lite/com/google/protobuf/Int64ValueOrBuilder.java            \\\n  # lite/com/google/protobuf/ListValue.java                      \\\n  # lite/com/google/protobuf/ListValueOrBuilder.java             \\\n  # lite/com/google/protobuf/NullValue.java                      \\\n  # lite/com/google/protobuf/StringValue.java                    \\\n  # lite/com/google/protobuf/StringValueOrBuilder.java           \\\n  # lite/com/google/protobuf/Struct.java                         \\\n  # lite/com/google/protobuf/StructOrBuilder.java                \\\n  # lite/com/google/protobuf/StructProto.java                    \\\n  # lite/com/google/protobuf/Timestamp.java                      \\\n  # lite/com/google/protobuf/TimestampOrBuilder.java             \\\n  # lite/com/google/protobuf/TimestampProto.java                 \\\n  # lite/com/google/protobuf/UInt32Value.java                    \\\n  # lite/com/google/protobuf/UInt32ValueOrBuilder.java           \\\n  # lite/com/google/protobuf/UInt64Value.java                    \\\n  # lite/com/google/protobuf/UInt64ValueOrBuilder.java           \\\n  # lite/com/google/protobuf/Value.java                          \\\n  # lite/com/google/protobuf/ValueOrBuilder.java                 \\\n  # lite/com/google/protobuf/WrappersProto.java\n# Explicit deps beacuse BUILT_SOURCES are only done before a \"make all/check\"\n# so a direct \"make test_cpp\" could fail if parallel enough.\nconformance_test_runner-conformance_test.$(OBJEXT): conformance.pb.h\nconformance_test_runner-conformance_test_runner.$(OBJEXT): conformance.pb.h\n# Explicit dep beacuse BUILT_SOURCES are only done before a \"make all/check\"\n# so a direct \"make test_cpp\" could fail if parallel enough.\nconformance_cpp-conformance_cpp.$(OBJEXT): conformance.pb.h\n# Explicit dep beacuse BUILT_SOURCES are only done before a \"make all/check\"\n# so a direct \"make test_objc\" could fail if parallel enough.\n@OBJC_CONFORMANCE_TEST_TRUE@conformance_objc-conformance_objc.$(OBJEXT): Conformance.pbobjc.h\n\n# Some implementations include pre-generated versions of well-known types.\n@USE_EXTERNAL_PROTOC_TRUE@protoc_middleman: $(conformance_protoc_inputs) $(well_known_type_protoc_inputs)\n@USE_EXTERNAL_PROTOC_TRUE@\t$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --objc_out=. --python_out=. $(conformance_protoc_inputs)\n@USE_EXTERNAL_PROTOC_TRUE@\t$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --python_out=. $(well_known_type_protoc_inputs)\n@USE_EXTERNAL_PROTOC_TRUE@\ttouch protoc_middleman\n\n# We have to cd to $(srcdir) before executing protoc because $(protoc_inputs) is\n# relative to srcdir, which may not be the same as the current directory when\n# building out-of-tree.\n@USE_EXTERNAL_PROTOC_FALSE@protoc_middleman: $(top_srcdir)/src/protoc$(EXEEXT) $(conformance_protoc_inputs) $(well_known_type_protoc_inputs)\n@USE_EXTERNAL_PROTOC_FALSE@\toldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --objc_out=$$oldpwd --python_out=$$oldpwd $(conformance_protoc_inputs) )\n@USE_EXTERNAL_PROTOC_FALSE@\toldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --python_out=$$oldpwd $(well_known_type_protoc_inputs) )\n@USE_EXTERNAL_PROTOC_FALSE@\ttouch protoc_middleman\n\n$(protoc_outputs): protoc_middleman\n\n$(other_language_protoc_outputs): protoc_middleman\n\njavac_middleman: ConformanceJava.java protoc_middleman $(other_language_protoc_outputs)\n\tjar=`ls ../java/util/target/*jar-with-dependencies.jar` && javac -classpath ../java/target/classes:$$jar ConformanceJava.java com/google/protobuf/conformance/Conformance.java\n\t@touch javac_middleman\n\nconformance-java: javac_middleman\n\t@echo \"Writing shortcut script conformance-java...\"\n\t@echo '#! /bin/sh' > conformance-java\n\t@jar=`ls ../java/util/target/*jar-with-dependencies.jar` && echo java -classpath .:../java/target/classes:$$jar ConformanceJava '$$@' >> conformance-java\n\t@chmod +x conformance-java\n\njavac_middleman_lite: ConformanceJavaLite.java protoc_middleman $(other_language_protoc_outputs)\n\tjavac -classpath ../java/lite/target/classes:lite ConformanceJavaLite.java lite/com/google/protobuf/conformance/Conformance.java\n\t@touch javac_middleman_lite\n\nconformance-java-lite: javac_middleman_lite\n\t@echo \"Writing shortcut script conformance-java-lite...\"\n\t@echo '#! /bin/sh' > conformance-java-lite\n\t@echo java -classpath .:../java/lite/target/classes:lite ConformanceJavaLite '$$@' >> conformance-java-lite\n\t@chmod +x conformance-java-lite\n\n# Currently the conformance code is alongside the rest of the C#\n# source, as it's easier to maintain there. We assume we've already\n# built that, so we just need a script to run it.\nconformance-csharp: $(other_language_protoc_outputs)\n\t@echo \"Writing shortcut script conformance-csharp...\"\n\t@echo '#! /bin/sh' > conformance-csharp\n\t@echo 'dotnet ../csharp/src/Google.Protobuf.Conformance/bin/Release/netcoreapp1.0/Google.Protobuf.Conformance.dll \"$$@\"' >> conformance-csharp\n\t@chmod +x conformance-csharp\n\n# Targets for actually running tests.\ntest_cpp: protoc_middleman conformance-test-runner conformance-cpp\n\t./conformance-test-runner --failure_list failure_list_cpp.txt ./conformance-cpp\n\ntest_java: protoc_middleman conformance-test-runner conformance-java\n\t./conformance-test-runner --failure_list failure_list_java.txt ./conformance-java\n\ntest_java_lite: protoc_middleman conformance-test-runner conformance-java-lite\n\t./conformance-test-runner ./conformance-java-lite\n\ntest_csharp: protoc_middleman conformance-test-runner conformance-csharp\n\t./conformance-test-runner --failure_list failure_list_csharp.txt ./conformance-csharp\n\ntest_ruby: protoc_middleman conformance-test-runner $(other_language_protoc_outputs)\n\tRUBYLIB=../ruby/lib:. ./conformance-test-runner --failure_list failure_list_ruby.txt ./conformance_ruby.rb\n\n# These depend on library paths being properly set up.  The easiest way to\n# run them is to just use \"tox\" from the python dir.\ntest_python: protoc_middleman conformance-test-runner\n\t./conformance-test-runner --failure_list failure_list_python.txt ./conformance_python.py\n\ntest_python_cpp: protoc_middleman conformance-test-runner\n\t./conformance-test-runner --failure_list failure_list_python_cpp.txt ./conformance_python.py\n\n@OBJC_CONFORMANCE_TEST_TRUE@test_objc: protoc_middleman conformance-test-runner conformance-objc\n@OBJC_CONFORMANCE_TEST_TRUE@\t./conformance-test-runner --failure_list failure_list_objc.txt ./conformance-objc\n\n# Tell versions [3.59,3.63) of GNU make to not export all variables.\n# Otherwise a system limit (for SysV at least) may be exceeded.\n.NOEXPORT:\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/README.md",
    "content": "Protocol Buffers - Google's data interchange format\n===================================================\n\n[![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https://travis-ci.org/google/protobuf)\n\nCopyright 2008 Google Inc.\n\nThis directory contains conformance tests for testing completeness and\ncorrectness of Protocol Buffers implementations.  These tests are designed\nto be easy to run against any Protocol Buffers implementation.\n\nThis directory contains the tester process `conformance-test`, which\ncontains all of the tests themselves.  Then separate programs written\nin whatever language you want to test communicate with the tester\nprogram over a pipe.\n\nBefore running any of these tests, make sure you run `make` in the base\ndirectory to build `protoc`, since all the tests depend on it.\n\n    $ make\n\nThen to run the tests against the C++ implementation, run:\n\n    $ cd conformance && make test_cpp\n\nMore tests and languages will be added soon!\n\nTesting other Protocol Buffer implementations\n---------------------------------------------\n\nTo run these tests against a new Protocol Buffers implementation, write a\nprogram in your language that uses the protobuf implementation you want\nto test.  This program should implement the testing protocol defined in\n[conformance.proto](https://github.com/google/protobuf/blob/master/conformance/conformance.proto).\nThis is designed to be as easy as possible: the C++ version is only\n150 lines and is a good example for what this program should look like\n(see [conformance_cpp.cc](https://github.com/google/protobuf/blob/master/conformance/conformance_cpp.cc)).\nThe program only needs to be able to read from stdin and write to stdout.\n\nPortability\n-----------\n\nNote that the test runner currently does not work on Windows.  Patches\nto fix this are welcome!  (But please get in touch first to settle on\na general implementation strategy).\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/conformance.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto3\";\npackage conformance;\noption java_package = \"com.google.protobuf.conformance\";\n\nimport \"google/protobuf/any.proto\";\nimport \"google/protobuf/duration.proto\";\nimport \"google/protobuf/field_mask.proto\";\nimport \"google/protobuf/struct.proto\";\nimport \"google/protobuf/timestamp.proto\";\nimport \"google/protobuf/wrappers.proto\";\n\n// This defines the conformance testing protocol.  This protocol exists between\n// the conformance test suite itself and the code being tested.  For each test,\n// the suite will send a ConformanceRequest message and expect a\n// ConformanceResponse message.\n//\n// You can either run the tests in two different ways:\n//\n//   1. in-process (using the interface in conformance_test.h).\n//\n//   2. as a sub-process communicating over a pipe.  Information about how to\n//      do this is in conformance_test_runner.cc.\n//\n// Pros/cons of the two approaches:\n//\n//   - running as a sub-process is much simpler for languages other than C/C++.\n//\n//   - running as a sub-process may be more tricky in unusual environments like\n//     iOS apps, where fork/stdin/stdout are not available.\n\nenum WireFormat {\n  UNSPECIFIED = 0;\n  PROTOBUF = 1;\n  JSON = 2;\n}\n\n// Represents a single test case's input.  The testee should:\n//\n//   1. parse this proto (which should always succeed)\n//   2. parse the protobuf or JSON payload in \"payload\" (which may fail)\n//   3. if the parse succeeded, serialize the message in the requested format.\nmessage ConformanceRequest {\n  // The payload (whether protobuf of JSON) is always for a TestAllTypes proto\n  // (see below).\n  oneof payload {\n    bytes protobuf_payload = 1;\n    string json_payload = 2;\n  }\n\n  // Which format should the testee serialize its message to?\n  WireFormat requested_output_format = 3;\n}\n\n// Represents a single test case's output.\nmessage ConformanceResponse {\n  oneof result {\n    // This string should be set to indicate parsing failed.  The string can\n    // provide more information about the parse error if it is available.\n    //\n    // Setting this string does not necessarily mean the testee failed the\n    // test.  Some of the test cases are intentionally invalid input.\n    string parse_error = 1;\n\n    // If the input was successfully parsed but errors occurred when\n    // serializing it to the requested output format, set the error message in\n    // this field.\n    string serialize_error = 6;\n\n    // This should be set if some other error occurred.  This will always\n    // indicate that the test failed.  The string can provide more information\n    // about the failure.\n    string runtime_error = 2;\n\n    // If the input was successfully parsed and the requested output was\n    // protobuf, serialize it to protobuf and set it in this field.\n    bytes protobuf_payload = 3;\n\n    // If the input was successfully parsed and the requested output was JSON,\n    // serialize to JSON and set it in this field.\n    string json_payload = 4;\n\n    // For when the testee skipped the test, likely because a certain feature\n    // wasn't supported, like JSON input/output.\n    string skipped = 5;\n  }\n}\n\n// This proto includes every type of field in both singular and repeated\n// forms.\nmessage TestAllTypes {\n  message NestedMessage {\n    int32 a = 1;\n    TestAllTypes corecursive = 2;\n  }\n\n  enum NestedEnum {\n    FOO = 0;\n    BAR = 1;\n    BAZ = 2;\n    NEG = -1;  // Intentionally negative.\n  }\n\n  // Singular\n  int32 optional_int32    =  1;\n  int64 optional_int64    =  2;\n  uint32 optional_uint32   =  3;\n  uint64 optional_uint64   =  4;\n  sint32 optional_sint32   =  5;\n  sint64 optional_sint64   =  6;\n  fixed32 optional_fixed32  =  7;\n  fixed64 optional_fixed64  =  8;\n  sfixed32 optional_sfixed32 =  9;\n  sfixed64 optional_sfixed64 = 10;\n  float optional_float    = 11;\n  double optional_double   = 12;\n  bool optional_bool     = 13;\n  string optional_string   = 14;\n  bytes optional_bytes    = 15;\n\n  NestedMessage                        optional_nested_message  = 18;\n  ForeignMessage                       optional_foreign_message = 19;\n\n  NestedEnum                           optional_nested_enum     = 21;\n  ForeignEnum                          optional_foreign_enum    = 22;\n\n  string optional_string_piece = 24 [ctype=STRING_PIECE];\n  string optional_cord = 25 [ctype=CORD];\n\n  TestAllTypes recursive_message = 27;\n\n  // Repeated\n  repeated    int32 repeated_int32    = 31;\n  repeated    int64 repeated_int64    = 32;\n  repeated   uint32 repeated_uint32   = 33;\n  repeated   uint64 repeated_uint64   = 34;\n  repeated   sint32 repeated_sint32   = 35;\n  repeated   sint64 repeated_sint64   = 36;\n  repeated  fixed32 repeated_fixed32  = 37;\n  repeated  fixed64 repeated_fixed64  = 38;\n  repeated sfixed32 repeated_sfixed32 = 39;\n  repeated sfixed64 repeated_sfixed64 = 40;\n  repeated    float repeated_float    = 41;\n  repeated   double repeated_double   = 42;\n  repeated     bool repeated_bool     = 43;\n  repeated   string repeated_string   = 44;\n  repeated    bytes repeated_bytes    = 45;\n\n  repeated NestedMessage                        repeated_nested_message  = 48;\n  repeated ForeignMessage                       repeated_foreign_message = 49;\n\n  repeated NestedEnum                           repeated_nested_enum     = 51;\n  repeated ForeignEnum                          repeated_foreign_enum    = 52;\n\n  repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];\n  repeated string repeated_cord = 55 [ctype=CORD];\n\n  // Map\n  map <   int32, int32>    map_int32_int32 = 56;\n  map <   int64, int64>    map_int64_int64 = 57;\n  map <  uint32, uint32>   map_uint32_uint32 = 58;\n  map <  uint64, uint64>   map_uint64_uint64 = 59;\n  map <  sint32, sint32>   map_sint32_sint32 = 60;\n  map <  sint64, sint64>   map_sint64_sint64 = 61;\n  map < fixed32, fixed32>  map_fixed32_fixed32 = 62;\n  map < fixed64, fixed64>  map_fixed64_fixed64 = 63;\n  map <sfixed32, sfixed32> map_sfixed32_sfixed32 = 64;\n  map <sfixed64, sfixed64> map_sfixed64_sfixed64 = 65;\n  map <   int32, float>    map_int32_float = 66;\n  map <   int32, double>   map_int32_double = 67;\n  map <    bool, bool>     map_bool_bool = 68;\n  map <  string, string>   map_string_string = 69;\n  map <  string, bytes>    map_string_bytes = 70;\n  map <  string, NestedMessage>  map_string_nested_message = 71;\n  map <  string, ForeignMessage> map_string_foreign_message = 72;\n  map <  string, NestedEnum>     map_string_nested_enum = 73;\n  map <  string, ForeignEnum>    map_string_foreign_enum = 74;\n\n  oneof oneof_field {\n    uint32 oneof_uint32 = 111;\n    NestedMessage oneof_nested_message = 112;\n    string oneof_string = 113;\n    bytes oneof_bytes = 114;\n  }\n\n  // Well-known types\n  google.protobuf.BoolValue optional_bool_wrapper = 201;\n  google.protobuf.Int32Value optional_int32_wrapper = 202;\n  google.protobuf.Int64Value optional_int64_wrapper = 203;\n  google.protobuf.UInt32Value optional_uint32_wrapper = 204;\n  google.protobuf.UInt64Value optional_uint64_wrapper = 205;\n  google.protobuf.FloatValue optional_float_wrapper = 206;\n  google.protobuf.DoubleValue optional_double_wrapper = 207;\n  google.protobuf.StringValue optional_string_wrapper = 208;\n  google.protobuf.BytesValue optional_bytes_wrapper = 209;\n\n  repeated google.protobuf.BoolValue repeated_bool_wrapper = 211;\n  repeated google.protobuf.Int32Value repeated_int32_wrapper = 212;\n  repeated google.protobuf.Int64Value repeated_int64_wrapper = 213;\n  repeated google.protobuf.UInt32Value repeated_uint32_wrapper = 214;\n  repeated google.protobuf.UInt64Value repeated_uint64_wrapper = 215;\n  repeated google.protobuf.FloatValue repeated_float_wrapper = 216;\n  repeated google.protobuf.DoubleValue repeated_double_wrapper = 217;\n  repeated google.protobuf.StringValue repeated_string_wrapper = 218;\n  repeated google.protobuf.BytesValue repeated_bytes_wrapper = 219;\n\n  google.protobuf.Duration optional_duration = 301;\n  google.protobuf.Timestamp optional_timestamp = 302;\n  google.protobuf.FieldMask optional_field_mask = 303;\n  google.protobuf.Struct optional_struct = 304;\n  google.protobuf.Any optional_any = 305;\n  google.protobuf.Value optional_value = 306;\n\n  repeated google.protobuf.Duration repeated_duration = 311;\n  repeated google.protobuf.Timestamp repeated_timestamp = 312;\n  repeated google.protobuf.FieldMask repeated_fieldmask = 313;\n  repeated google.protobuf.Struct repeated_struct = 324;\n  repeated google.protobuf.Any repeated_any = 315;\n  repeated google.protobuf.Value repeated_value = 316;\n\n  // Test field-name-to-JSON-name convention.\n  int32 fieldname1 = 401;\n  int32 field_name2 = 402;\n  int32 _field_name3 = 403;\n  int32 field__name4_ = 404;\n  int32 field0name5 = 405;\n  int32 field_0_name6 = 406;\n  int32 fieldName7 = 407;\n  int32 FieldName8 = 408;\n  int32 field_Name9 = 409;\n  int32 Field_Name10 = 410;\n  int32 FIELD_NAME11 = 411;\n  int32 FIELD_name12 = 412;\n}\n\nmessage ForeignMessage {\n  int32 c = 1;\n}\n\nenum ForeignEnum {\n  FOREIGN_FOO = 0;\n  FOREIGN_BAR = 1;\n  FOREIGN_BAZ = 2;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/conformance_cpp.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <errno.h>\n#include <stdarg.h>\n#include <unistd.h>\n\n#include \"conformance.pb.h\"\n#include <google/protobuf/util/json_util.h>\n#include <google/protobuf/util/type_resolver_util.h>\n\nusing conformance::ConformanceRequest;\nusing conformance::ConformanceResponse;\nusing conformance::TestAllTypes;\nusing google::protobuf::Descriptor;\nusing google::protobuf::DescriptorPool;\nusing google::protobuf::internal::scoped_ptr;\nusing google::protobuf::util::BinaryToJsonString;\nusing google::protobuf::util::JsonToBinaryString;\nusing google::protobuf::util::NewTypeResolverForDescriptorPool;\nusing google::protobuf::util::Status;\nusing google::protobuf::util::TypeResolver;\nusing std::string;\n\nstatic const char kTypeUrlPrefix[] = \"type.googleapis.com\";\n\nstatic string GetTypeUrl(const Descriptor* message) {\n  return string(kTypeUrlPrefix) + \"/\" + message->full_name();\n}\n\nint test_count = 0;\nbool verbose = false;\nTypeResolver* type_resolver;\nstring* type_url;\n\n\nbool CheckedRead(int fd, void *buf, size_t len) {\n  size_t ofs = 0;\n  while (len > 0) {\n    ssize_t bytes_read = read(fd, (char*)buf + ofs, len);\n\n    if (bytes_read == 0) return false;\n\n    if (bytes_read < 0) {\n      GOOGLE_LOG(FATAL) << \"Error reading from test runner: \" <<  strerror(errno);\n    }\n\n    len -= bytes_read;\n    ofs += bytes_read;\n  }\n\n  return true;\n}\n\nvoid CheckedWrite(int fd, const void *buf, size_t len) {\n  if (write(fd, buf, len) != len) {\n    GOOGLE_LOG(FATAL) << \"Error writing to test runner: \" << strerror(errno);\n  }\n}\n\nvoid DoTest(const ConformanceRequest& request, ConformanceResponse* response) {\n  TestAllTypes test_message;\n\n  switch (request.payload_case()) {\n    case ConformanceRequest::kProtobufPayload:\n      if (!test_message.ParseFromString(request.protobuf_payload())) {\n        // Getting parse details would involve something like:\n        //   http://stackoverflow.com/questions/22121922/how-can-i-get-more-details-about-errors-generated-during-protobuf-parsing-c\n        response->set_parse_error(\"Parse error (no more details available).\");\n        return;\n      }\n      break;\n\n    case ConformanceRequest::kJsonPayload: {\n      string proto_binary;\n      Status status = JsonToBinaryString(type_resolver, *type_url,\n                                         request.json_payload(), &proto_binary);\n      if (!status.ok()) {\n        response->set_parse_error(string(\"Parse error: \") +\n                                  status.error_message().as_string());\n        return;\n      }\n\n      if (!test_message.ParseFromString(proto_binary)) {\n        response->set_runtime_error(\n            \"Parsing JSON generates invalid proto output.\");\n        return;\n      }\n      break;\n    }\n\n    case ConformanceRequest::PAYLOAD_NOT_SET:\n      GOOGLE_LOG(FATAL) << \"Request didn't have payload.\";\n      break;\n  }\n\n  switch (request.requested_output_format()) {\n    case conformance::UNSPECIFIED:\n      GOOGLE_LOG(FATAL) << \"Unspecified output format\";\n      break;\n\n    case conformance::PROTOBUF:\n      GOOGLE_CHECK(\n          test_message.SerializeToString(response->mutable_protobuf_payload()));\n      break;\n\n    case conformance::JSON: {\n      string proto_binary;\n      GOOGLE_CHECK(test_message.SerializeToString(&proto_binary));\n      Status status = BinaryToJsonString(type_resolver, *type_url, proto_binary,\n                                         response->mutable_json_payload());\n      if (!status.ok()) {\n        response->set_serialize_error(\n            string(\"Failed to serialize JSON output: \") +\n            status.error_message().as_string());\n        return;\n      }\n      break;\n    }\n\n    default:\n      GOOGLE_LOG(FATAL) << \"Unknown output format: \"\n                        << request.requested_output_format();\n  }\n}\n\nbool DoTestIo() {\n  string serialized_input;\n  string serialized_output;\n  ConformanceRequest request;\n  ConformanceResponse response;\n  uint32_t bytes;\n\n  if (!CheckedRead(STDIN_FILENO, &bytes, sizeof(uint32_t))) {\n    // EOF.\n    return false;\n  }\n\n  serialized_input.resize(bytes);\n\n  if (!CheckedRead(STDIN_FILENO, (char*)serialized_input.c_str(), bytes)) {\n    GOOGLE_LOG(ERROR) << \"Unexpected EOF on stdin. \" << strerror(errno);\n  }\n\n  if (!request.ParseFromString(serialized_input)) {\n    GOOGLE_LOG(FATAL) << \"Parse of ConformanceRequest proto failed.\";\n    return false;\n  }\n\n  DoTest(request, &response);\n\n  response.SerializeToString(&serialized_output);\n\n  bytes = serialized_output.size();\n  CheckedWrite(STDOUT_FILENO, &bytes, sizeof(uint32_t));\n  CheckedWrite(STDOUT_FILENO, serialized_output.c_str(), bytes);\n\n  if (verbose) {\n    fprintf(stderr, \"conformance-cpp: request=%s, response=%s\\n\",\n            request.ShortDebugString().c_str(),\n            response.ShortDebugString().c_str());\n  }\n\n  test_count++;\n\n  return true;\n}\n\nint main() {\n  type_resolver = NewTypeResolverForDescriptorPool(\n      kTypeUrlPrefix, DescriptorPool::generated_pool());\n  type_url = new string(GetTypeUrl(TestAllTypes::descriptor()));\n  while (1) {\n    if (!DoTestIo()) {\n      fprintf(stderr, \"conformance-cpp: received EOF from test runner \"\n                      \"after %d tests, exiting\\n\", test_count);\n      return 0;\n    }\n  }\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/conformance_objc.m",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2015 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#import <Foundation/Foundation.h>\n\n#import \"Conformance.pbobjc.h\"\n\nstatic void Die(NSString *format, ...) __dead2;\n\nstatic BOOL verbose = NO;\nstatic int32_t testCount = 0;\n\nstatic void Die(NSString *format, ...) {\n  va_list args;\n  va_start(args, format);\n  NSString *msg = [[NSString alloc] initWithFormat:format arguments:args];\n  NSLog(@\"%@\", msg);\n  va_end(args);\n  [msg release];\n  exit(66);\n}\n\nstatic NSData *CheckedReadDataOfLength(NSFileHandle *handle, NSUInteger numBytes) {\n  NSData *data = [handle readDataOfLength:numBytes];\n  NSUInteger dataLen = data.length;\n  if (dataLen == 0) {\n    return nil;  // EOF.\n  }\n  if (dataLen != numBytes) {\n    Die(@\"Failed to read the request length (%d), only got: %@\",\n        numBytes, data);\n  }\n  return data;\n}\n\nstatic ConformanceResponse *DoTest(ConformanceRequest *request) {\n  ConformanceResponse *response = [ConformanceResponse message];\n  TestAllTypes *testMessage = nil;\n\n  switch (request.payloadOneOfCase) {\n    case ConformanceRequest_Payload_OneOfCase_GPBUnsetOneOfCase:\n      Die(@\"Request didn't have a payload: %@\", request);\n      break;\n\n    case ConformanceRequest_Payload_OneOfCase_ProtobufPayload: {\n      NSError *error = nil;\n      testMessage = [TestAllTypes parseFromData:request.protobufPayload\n                                          error:&error];\n      if (!testMessage) {\n        response.parseError =\n            [NSString stringWithFormat:@\"Parse error: %@\", error];\n      }\n      break;\n    }\n\n    case ConformanceRequest_Payload_OneOfCase_JsonPayload:\n      response.skipped = @\"ObjC doesn't support parsing JSON\";\n      break;\n  }\n\n  if (testMessage) {\n    switch (request.requestedOutputFormat) {\n      case WireFormat_GPBUnrecognizedEnumeratorValue:\n      case WireFormat_Unspecified:\n        Die(@\"Unrecognized/unspecified output format: %@\", request);\n        break;\n\n      case WireFormat_Protobuf:\n        response.protobufPayload = testMessage.data;\n        if (!response.protobufPayload) {\n          response.serializeError =\n            [NSString stringWithFormat:@\"Failed to make data from: %@\", testMessage];\n        }\n        break;\n\n      case WireFormat_Json:\n        response.skipped = @\"ObjC doesn't support generating JSON\";\n        break;\n    }\n  }\n\n  return response;\n}\n\nstatic uint32_t UInt32FromLittleEndianData(NSData *data) {\n  if (data.length != sizeof(uint32_t)) {\n    Die(@\"Data not the right size for uint32_t: %@\", data);\n  }\n  uint32_t value;\n  memcpy(&value, data.bytes, sizeof(uint32_t));\n  return CFSwapInt32LittleToHost(value);\n}\n\nstatic NSData *UInt32ToLittleEndianData(uint32_t num) {\n  uint32_t value = CFSwapInt32HostToLittle(num);\n  return [NSData dataWithBytes:&value length:sizeof(uint32_t)];\n}\n\nstatic BOOL DoTestIo(NSFileHandle *input, NSFileHandle *output) {\n  // See conformance_test_runner.cc for the wire format.\n  NSData *data = CheckedReadDataOfLength(input, sizeof(uint32_t));\n  if (!data) {\n    // EOF.\n    return NO;\n  }\n  uint32_t numBytes = UInt32FromLittleEndianData(data);\n  data = CheckedReadDataOfLength(input, numBytes);\n  if (!data) {\n    Die(@\"Failed to read request\");\n  }\n\n  NSError *error = nil;\n  ConformanceRequest *request = [ConformanceRequest parseFromData:data\n                                                            error:&error];\n  if (!request) {\n    Die(@\"Failed to parse the message data: %@\", error);\n  }\n\n  ConformanceResponse *response = DoTest(request);\n  if (!response) {\n    Die(@\"Failed to make a reply from %@\", request);\n  }\n\n  data = response.data;\n  [output writeData:UInt32ToLittleEndianData((int32_t)data.length)];\n  [output writeData:data];\n\n  if (verbose) {\n    NSLog(@\"Request: %@\", request);\n    NSLog(@\"Response: %@\", response);\n  }\n\n  ++testCount;\n  return YES;\n}\n\nint main(int argc, const char *argv[]) {\n  @autoreleasepool {\n    NSFileHandle *input = [[NSFileHandle fileHandleWithStandardInput] retain];\n    NSFileHandle *output = [[NSFileHandle fileHandleWithStandardOutput] retain];\n\n    BOOL notDone = YES;\n    while (notDone) {\n      @autoreleasepool {\n        notDone = DoTestIo(input, output);\n      }\n    }\n\n    NSLog(@\"Received EOF from test runner after %d tests, exiting.\", testCount);\n  }\n  return 0;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/conformance_python.py",
    "content": "#!/usr/bin/env python\n#\n# Protocol Buffers - Google's data interchange format\n# Copyright 2008 Google Inc.  All rights reserved.\n# https://developers.google.com/protocol-buffers/\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\"\"\"A conformance test implementation for the Python protobuf library.\n\nSee conformance.proto for more information.\n\"\"\"\n\nimport struct\nimport sys\nimport os\nfrom google.protobuf import message\nfrom google.protobuf import json_format\nimport conformance_pb2\n\nsys.stdout = os.fdopen(sys.stdout.fileno(), 'wb', 0)\nsys.stdin = os.fdopen(sys.stdin.fileno(), 'rb', 0)\n\ntest_count = 0\nverbose = False\n\nclass ProtocolError(Exception):\n  pass\n\ndef do_test(request):\n  test_message = conformance_pb2.TestAllTypes()\n  response = conformance_pb2.ConformanceResponse()\n  test_message = conformance_pb2.TestAllTypes()\n\n  try:\n    if request.WhichOneof('payload') == 'protobuf_payload':\n      try:\n        test_message.ParseFromString(request.protobuf_payload)\n      except message.DecodeError as e:\n        response.parse_error = str(e)\n        return response\n\n    elif request.WhichOneof('payload') == 'json_payload':\n      try:\n        json_format.Parse(request.json_payload, test_message)\n      except json_format.ParseError as e:\n        response.parse_error = str(e)\n        return response\n\n    else:\n      raise ProtocolError(\"Request didn't have payload.\")\n\n    if request.requested_output_format == conformance_pb2.UNSPECIFIED:\n      raise ProtocolError(\"Unspecified output format\")\n\n    elif request.requested_output_format == conformance_pb2.PROTOBUF:\n      response.protobuf_payload = test_message.SerializeToString()\n\n    elif request.requested_output_format == conformance_pb2.JSON:\n      response.json_payload = json_format.MessageToJson(test_message)\n\n  except Exception as e:\n    response.runtime_error = str(e)\n\n  return response\n\ndef do_test_io():\n  length_bytes = sys.stdin.read(4)\n  if len(length_bytes) == 0:\n    return False   # EOF\n  elif len(length_bytes) != 4:\n    raise IOError(\"I/O error\")\n\n  # \"I\" is \"unsigned int\", so this depends on running on a platform with\n  # 32-bit \"unsigned int\" type.  The Python struct module unfortunately\n  # has no format specifier for uint32_t.\n  length = struct.unpack(\"<I\", length_bytes)[0]\n  serialized_request = sys.stdin.read(length)\n  if len(serialized_request) != length:\n    raise IOError(\"I/O error\")\n\n  request = conformance_pb2.ConformanceRequest()\n  request.ParseFromString(serialized_request)\n\n  response = do_test(request)\n\n  serialized_response = response.SerializeToString()\n  sys.stdout.write(struct.pack(\"<I\", len(serialized_response)))\n  sys.stdout.write(serialized_response)\n  sys.stdout.flush()\n\n  if verbose:\n    sys.stderr.write(\"conformance_python: request=%s, response=%s\\n\" % (\n                       request.ShortDebugString().c_str(),\n                       response.ShortDebugString().c_str()))\n\n  global test_count\n  test_count += 1\n\n  return True\n\nwhile True:\n  if not do_test_io():\n    sys.stderr.write(\"conformance_python: received EOF from test runner \" +\n                     \"after %s tests, exiting\\n\" % (test_count))\n    sys.exit(0)\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/conformance_ruby.rb",
    "content": "#!/usr/bin/env ruby\n#\n# Protocol Buffers - Google's data interchange format\n# Copyright 2008 Google Inc.  All rights reserved.\n# https://developers.google.com/protocol-buffers/\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nrequire 'conformance_pb'\n\n$test_count = 0\n$verbose = false\n\ndef do_test(request)\n  test_message = Conformance::TestAllTypes.new\n  response = Conformance::ConformanceResponse.new\n\n  begin\n    case request.payload\n    when :protobuf_payload\n      begin\n        test_message =\n          Conformance::TestAllTypes.decode(request.protobuf_payload)\n      rescue Google::Protobuf::ParseError => err\n        response.parse_error = err.message.encode('utf-8')\n        return response\n      end\n\n    when :json_payload\n      begin\n        test_message = Conformance::TestAllTypes.decode_json(request.json_payload)\n      rescue Google::Protobuf::ParseError => err\n        response.parse_error = err.message.encode('utf-8')\n        return response\n      end\n\n    when nil\n      fail \"Request didn't have payload\"\n    end\n\n    case request.requested_output_format\n    when :UNSPECIFIED\n      fail 'Unspecified output format'\n\n    when :PROTOBUF\n      response.protobuf_payload = test_message.to_proto\n\n    when :JSON\n      response.json_payload = test_message.to_json\n\n    when nil\n      fail \"Request didn't have requested output format\"\n    end\n  rescue StandardError => err\n    response.runtime_error = err.message.encode('utf-8')\n  end\n\n  response\nend\n\n# Returns true if the test ran successfully, false on legitimate EOF.\n# If EOF is encountered in an unexpected place, raises IOError.\ndef do_test_io\n  length_bytes = STDIN.read(4)\n  return false if length_bytes.nil?\n\n  length = length_bytes.unpack('V').first\n  serialized_request = STDIN.read(length)\n  if serialized_request.nil? || serialized_request.length != length\n    fail IOError\n  end\n\n  request = Conformance::ConformanceRequest.decode(serialized_request)\n\n  response = do_test(request)\n\n  serialized_response = Conformance::ConformanceResponse.encode(response)\n  STDOUT.write([serialized_response.length].pack('V'))\n  STDOUT.write(serialized_response)\n  STDOUT.flush\n\n  if $verbose\n    STDERR.puts(\"conformance_ruby: request=#{request.to_json}, \" \\\n                                 \"response=#{response.to_json}\\n\")\n  end\n\n  $test_count += 1\n\n  true\nend\n\nloop do\n  unless do_test_io\n    STDERR.puts('conformance_ruby: received EOF from test runner ' \\\n                \"after #{$test_count} tests, exiting\")\n    break\n  end\nend\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/conformance_test.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <stdarg.h>\n#include <string>\n#include <fstream>\n\n#include \"conformance.pb.h\"\n#include \"conformance_test.h\"\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/stringprintf.h>\n#include <google/protobuf/text_format.h>\n#include <google/protobuf/util/json_util.h>\n#include <google/protobuf/util/field_comparator.h>\n#include <google/protobuf/util/message_differencer.h>\n#include <google/protobuf/util/type_resolver_util.h>\n#include <google/protobuf/wire_format_lite.h>\n\n#include \"third_party/jsoncpp/json.h\"\n\nusing conformance::ConformanceRequest;\nusing conformance::ConformanceResponse;\nusing conformance::TestAllTypes;\nusing conformance::WireFormat;\nusing google::protobuf::Descriptor;\nusing google::protobuf::FieldDescriptor;\nusing google::protobuf::internal::WireFormatLite;\nusing google::protobuf::TextFormat;\nusing google::protobuf::util::DefaultFieldComparator;\nusing google::protobuf::util::JsonToBinaryString;\nusing google::protobuf::util::MessageDifferencer;\nusing google::protobuf::util::NewTypeResolverForDescriptorPool;\nusing google::protobuf::util::Status;\nusing std::string;\n\nnamespace {\n\nstatic const char kTypeUrlPrefix[] = \"type.googleapis.com\";\n\nstatic string GetTypeUrl(const Descriptor* message) {\n  return string(kTypeUrlPrefix) + \"/\" + message->full_name();\n}\n\n/* Routines for building arbitrary protos *************************************/\n\n// We would use CodedOutputStream except that we want more freedom to build\n// arbitrary protos (even invalid ones).\n\nconst string empty;\n\nstring cat(const string& a, const string& b,\n           const string& c = empty,\n           const string& d = empty,\n           const string& e = empty,\n           const string& f = empty,\n           const string& g = empty,\n           const string& h = empty,\n           const string& i = empty,\n           const string& j = empty,\n           const string& k = empty,\n           const string& l = empty) {\n  string ret;\n  ret.reserve(a.size() + b.size() + c.size() + d.size() + e.size() + f.size() +\n              g.size() + h.size() + i.size() + j.size() + k.size() + l.size());\n  ret.append(a);\n  ret.append(b);\n  ret.append(c);\n  ret.append(d);\n  ret.append(e);\n  ret.append(f);\n  ret.append(g);\n  ret.append(h);\n  ret.append(i);\n  ret.append(j);\n  ret.append(k);\n  ret.append(l);\n  return ret;\n}\n\n// The maximum number of bytes that it takes to encode a 64-bit varint.\n#define VARINT_MAX_LEN 10\n\nsize_t vencode64(uint64_t val, char *buf) {\n  if (val == 0) { buf[0] = 0; return 1; }\n  size_t i = 0;\n  while (val) {\n    uint8_t byte = val & 0x7fU;\n    val >>= 7;\n    if (val) byte |= 0x80U;\n    buf[i++] = byte;\n  }\n  return i;\n}\n\nstring varint(uint64_t x) {\n  char buf[VARINT_MAX_LEN];\n  size_t len = vencode64(x, buf);\n  return string(buf, len);\n}\n\n// TODO: proper byte-swapping for big-endian machines.\nstring fixed32(void *data) { return string(static_cast<char*>(data), 4); }\nstring fixed64(void *data) { return string(static_cast<char*>(data), 8); }\n\nstring delim(const string& buf) { return cat(varint(buf.size()), buf); }\nstring uint32(uint32_t u32) { return fixed32(&u32); }\nstring uint64(uint64_t u64) { return fixed64(&u64); }\nstring flt(float f) { return fixed32(&f); }\nstring dbl(double d) { return fixed64(&d); }\nstring zz32(int32_t x) { return varint(WireFormatLite::ZigZagEncode32(x)); }\nstring zz64(int64_t x) { return varint(WireFormatLite::ZigZagEncode64(x)); }\n\nstring tag(uint32_t fieldnum, char wire_type) {\n  return varint((fieldnum << 3) | wire_type);\n}\n\nstring submsg(uint32_t fn, const string& buf) {\n  return cat( tag(fn, WireFormatLite::WIRETYPE_LENGTH_DELIMITED), delim(buf) );\n}\n\n#define UNKNOWN_FIELD 666\n\nuint32_t GetFieldNumberForType(FieldDescriptor::Type type, bool repeated) {\n  const Descriptor* d = TestAllTypes().GetDescriptor();\n  for (int i = 0; i < d->field_count(); i++) {\n    const FieldDescriptor* f = d->field(i);\n    if (f->type() == type && f->is_repeated() == repeated) {\n      return f->number();\n    }\n  }\n  GOOGLE_LOG(FATAL) << \"Couldn't find field with type \" << (int)type;\n  return 0;\n}\n\nstring UpperCase(string str) {\n  for (int i = 0; i < str.size(); i++) {\n    str[i] = toupper(str[i]);\n  }\n  return str;\n}\n\n}  // anonymous namespace\n\nnamespace google {\nnamespace protobuf {\n\nvoid ConformanceTestSuite::ReportSuccess(const string& test_name) {\n  if (expected_to_fail_.erase(test_name) != 0) {\n    StringAppendF(&output_,\n                  \"ERROR: test %s is in the failure list, but test succeeded.  \"\n                  \"Remove it from the failure list.\\n\",\n                  test_name.c_str());\n    unexpected_succeeding_tests_.insert(test_name);\n  }\n  successes_++;\n}\n\nvoid ConformanceTestSuite::ReportFailure(const string& test_name,\n                                         const ConformanceRequest& request,\n                                         const ConformanceResponse& response,\n                                         const char* fmt, ...) {\n  if (expected_to_fail_.erase(test_name) == 1) {\n    expected_failures_++;\n    if (!verbose_)\n      return;\n  } else {\n    StringAppendF(&output_, \"ERROR, test=%s: \", test_name.c_str());\n    unexpected_failing_tests_.insert(test_name);\n  }\n  va_list args;\n  va_start(args, fmt);\n  StringAppendV(&output_, fmt, args);\n  va_end(args);\n  StringAppendF(&output_, \" request=%s, response=%s\\n\",\n                request.ShortDebugString().c_str(),\n                response.ShortDebugString().c_str());\n}\n\nvoid ConformanceTestSuite::ReportSkip(const string& test_name,\n                                      const ConformanceRequest& request,\n                                      const ConformanceResponse& response) {\n  if (verbose_) {\n    StringAppendF(&output_, \"SKIPPED, test=%s request=%s, response=%s\\n\",\n                  test_name.c_str(), request.ShortDebugString().c_str(),\n                  response.ShortDebugString().c_str());\n  }\n  skipped_.insert(test_name);\n}\n\nvoid ConformanceTestSuite::RunTest(const string& test_name,\n                                   const ConformanceRequest& request,\n                                   ConformanceResponse* response) {\n  if (test_names_.insert(test_name).second == false) {\n    GOOGLE_LOG(FATAL) << \"Duplicated test name: \" << test_name;\n  }\n\n  string serialized_request;\n  string serialized_response;\n  request.SerializeToString(&serialized_request);\n\n  runner_->RunTest(test_name, serialized_request, &serialized_response);\n\n  if (!response->ParseFromString(serialized_response)) {\n    response->Clear();\n    response->set_runtime_error(\"response proto could not be parsed.\");\n  }\n\n  if (verbose_) {\n    StringAppendF(&output_, \"conformance test: name=%s, request=%s, response=%s\\n\",\n                  test_name.c_str(),\n                  request.ShortDebugString().c_str(),\n                  response->ShortDebugString().c_str());\n  }\n}\n\nvoid ConformanceTestSuite::RunValidInputTest(\n    const string& test_name, const string& input, WireFormat input_format,\n    const string& equivalent_text_format, WireFormat requested_output) {\n  TestAllTypes reference_message;\n  GOOGLE_CHECK(\n      TextFormat::ParseFromString(equivalent_text_format, &reference_message))\n          << \"Failed to parse data for test case: \" << test_name\n          << \", data: \" << equivalent_text_format;\n\n  ConformanceRequest request;\n  ConformanceResponse response;\n\n  switch (input_format) {\n    case conformance::PROTOBUF:\n      request.set_protobuf_payload(input);\n      break;\n\n    case conformance::JSON:\n      request.set_json_payload(input);\n      break;\n\n    default:\n      GOOGLE_LOG(FATAL) << \"Unspecified input format\";\n  }\n\n  request.set_requested_output_format(requested_output);\n\n  RunTest(test_name, request, &response);\n\n  TestAllTypes test_message;\n\n  switch (response.result_case()) {\n    case ConformanceResponse::kParseError:\n    case ConformanceResponse::kRuntimeError:\n    case ConformanceResponse::kSerializeError:\n      ReportFailure(test_name, request, response,\n                    \"Failed to parse JSON input or produce JSON output.\");\n      return;\n\n    case ConformanceResponse::kSkipped:\n      ReportSkip(test_name, request, response);\n      return;\n\n    case ConformanceResponse::kJsonPayload: {\n      if (requested_output != conformance::JSON) {\n        ReportFailure(\n            test_name, request, response,\n            \"Test was asked for protobuf output but provided JSON instead.\");\n        return;\n      }\n      string binary_protobuf;\n      Status status =\n          JsonToBinaryString(type_resolver_.get(), type_url_,\n                             response.json_payload(), &binary_protobuf);\n      if (!status.ok()) {\n        ReportFailure(test_name, request, response,\n                      \"JSON output we received from test was unparseable.\");\n        return;\n      }\n\n      if (!test_message.ParseFromString(binary_protobuf)) {\n        ReportFailure(test_name, request, response,\n                      \"INTERNAL ERROR: internal JSON->protobuf transcode \"\n                      \"yielded unparseable proto.\");\n        return;\n      }\n\n      break;\n    }\n\n    case ConformanceResponse::kProtobufPayload: {\n      if (requested_output != conformance::PROTOBUF) {\n        ReportFailure(\n            test_name, request, response,\n            \"Test was asked for JSON output but provided protobuf instead.\");\n        return;\n      }\n\n      if (!test_message.ParseFromString(response.protobuf_payload())) {\n        ReportFailure(test_name, request, response,\n                      \"Protobuf output we received from test was unparseable.\");\n        return;\n      }\n\n      break;\n    }\n\n    default:\n      GOOGLE_LOG(FATAL) << test_name << \": unknown payload type: \"\n                        << response.result_case();\n  }\n\n  MessageDifferencer differencer;\n  DefaultFieldComparator field_comparator;\n  field_comparator.set_treat_nan_as_equal(true);\n  differencer.set_field_comparator(&field_comparator);\n  string differences;\n  differencer.ReportDifferencesToString(&differences);\n\n  if (differencer.Compare(reference_message, test_message)) {\n    ReportSuccess(test_name);\n  } else {\n    ReportFailure(test_name, request, response,\n                  \"Output was not equivalent to reference message: %s.\",\n                  differences.c_str());\n  }\n}\n\n// Expect that this precise protobuf will cause a parse error.\nvoid ConformanceTestSuite::ExpectParseFailureForProto(\n    const string& proto, const string& test_name) {\n  ConformanceRequest request;\n  ConformanceResponse response;\n  request.set_protobuf_payload(proto);\n  string effective_test_name = \"ProtobufInput.\" + test_name;\n\n  // We don't expect output, but if the program erroneously accepts the protobuf\n  // we let it send its response as this.  We must not leave it unspecified.\n  request.set_requested_output_format(conformance::PROTOBUF);\n\n  RunTest(effective_test_name, request, &response);\n  if (response.result_case() == ConformanceResponse::kParseError) {\n    ReportSuccess(effective_test_name);\n  } else if (response.result_case() == ConformanceResponse::kSkipped) {\n    ReportSkip(effective_test_name, request, response);\n  } else {\n    ReportFailure(effective_test_name, request, response,\n                  \"Should have failed to parse, but didn't.\");\n  }\n}\n\n// Expect that this protobuf will cause a parse error, even if it is followed\n// by valid protobuf data.  We can try running this twice: once with this\n// data verbatim and once with this data followed by some valid data.\n//\n// TODO(haberman): implement the second of these.\nvoid ConformanceTestSuite::ExpectHardParseFailureForProto(\n    const string& proto, const string& test_name) {\n  return ExpectParseFailureForProto(proto, test_name);\n}\n\nvoid ConformanceTestSuite::RunValidJsonTest(\n    const string& test_name, const string& input_json,\n    const string& equivalent_text_format) {\n  RunValidInputTest(\"JsonInput.\" + test_name + \".ProtobufOutput\", input_json,\n                    conformance::JSON, equivalent_text_format,\n                    conformance::PROTOBUF);\n  RunValidInputTest(\"JsonInput.\" + test_name + \".JsonOutput\", input_json,\n                    conformance::JSON, equivalent_text_format,\n                    conformance::JSON);\n}\n\nvoid ConformanceTestSuite::RunValidJsonTestWithProtobufInput(\n    const string& test_name, const TestAllTypes& input,\n    const string& equivalent_text_format) {\n  RunValidInputTest(\"ProtobufInput.\" + test_name + \".JsonOutput\",\n                    input.SerializeAsString(), conformance::PROTOBUF,\n                    equivalent_text_format, conformance::JSON);\n}\n\n// According to proto3 JSON specification, JSON serializers follow more strict\n// rules than parsers (e.g., a serializer must serialize int32 values as JSON\n// numbers while the parser is allowed to accept them as JSON strings). This\n// method allows strict checking on a proto3 JSON serializer by inspecting\n// the JSON output directly.\nvoid ConformanceTestSuite::RunValidJsonTestWithValidator(\n    const string& test_name, const string& input_json,\n    const Validator& validator) {\n  ConformanceRequest request;\n  ConformanceResponse response;\n  request.set_json_payload(input_json);\n  request.set_requested_output_format(conformance::JSON);\n\n  string effective_test_name = \"JsonInput.\" + test_name + \".Validator\";\n\n  RunTest(effective_test_name, request, &response);\n\n  if (response.result_case() == ConformanceResponse::kSkipped) {\n    ReportSkip(effective_test_name, request, response);\n    return;\n  }\n\n  if (response.result_case() != ConformanceResponse::kJsonPayload) {\n    ReportFailure(effective_test_name, request, response,\n                  \"Expected JSON payload but got type %d.\",\n                  response.result_case());\n    return;\n  }\n  Json::Reader reader;\n  Json::Value value;\n  if (!reader.parse(response.json_payload(), value)) {\n    ReportFailure(effective_test_name, request, response,\n                  \"JSON payload cannot be parsed as valid JSON: %s\",\n                  reader.getFormattedErrorMessages().c_str());\n    return;\n  }\n  if (!validator(value)) {\n    ReportFailure(effective_test_name, request, response,\n                  \"JSON payload validation failed.\");\n    return;\n  }\n  ReportSuccess(effective_test_name);\n}\n\nvoid ConformanceTestSuite::ExpectParseFailureForJson(\n    const string& test_name, const string& input_json) {\n  ConformanceRequest request;\n  ConformanceResponse response;\n  request.set_json_payload(input_json);\n  string effective_test_name = \"JsonInput.\" + test_name;\n\n  // We don't expect output, but if the program erroneously accepts the protobuf\n  // we let it send its response as this.  We must not leave it unspecified.\n  request.set_requested_output_format(conformance::JSON);\n\n  RunTest(effective_test_name, request, &response);\n  if (response.result_case() == ConformanceResponse::kParseError) {\n    ReportSuccess(effective_test_name);\n  } else if (response.result_case() == ConformanceResponse::kSkipped) {\n    ReportSkip(effective_test_name, request, response);\n  } else {\n    ReportFailure(effective_test_name, request, response,\n                  \"Should have failed to parse, but didn't.\");\n  }\n}\n\nvoid ConformanceTestSuite::ExpectSerializeFailureForJson(\n    const string& test_name, const string& text_format) {\n  TestAllTypes payload_message;\n  GOOGLE_CHECK(\n      TextFormat::ParseFromString(text_format, &payload_message))\n          << \"Failed to parse: \" << text_format;\n\n  ConformanceRequest request;\n  ConformanceResponse response;\n  request.set_protobuf_payload(payload_message.SerializeAsString());\n  string effective_test_name = test_name + \".JsonOutput\";\n  request.set_requested_output_format(conformance::JSON);\n\n  RunTest(effective_test_name, request, &response);\n  if (response.result_case() == ConformanceResponse::kSerializeError) {\n    ReportSuccess(effective_test_name);\n  } else if (response.result_case() == ConformanceResponse::kSkipped) {\n    ReportSkip(effective_test_name, request, response);\n  } else {\n    ReportFailure(effective_test_name, request, response,\n                  \"Should have failed to serialize, but didn't.\");\n  }\n}\n\nvoid ConformanceTestSuite::TestPrematureEOFForType(FieldDescriptor::Type type) {\n  // Incomplete values for each wire type.\n  static const string incompletes[6] = {\n    string(\"\\x80\"),     // VARINT\n    string(\"abcdefg\"),  // 64BIT\n    string(\"\\x80\"),     // DELIMITED (partial length)\n    string(),           // START_GROUP (no value required)\n    string(),           // END_GROUP (no value required)\n    string(\"abc\")       // 32BIT\n  };\n\n  uint32_t fieldnum = GetFieldNumberForType(type, false);\n  uint32_t rep_fieldnum = GetFieldNumberForType(type, true);\n  WireFormatLite::WireType wire_type = WireFormatLite::WireTypeForFieldType(\n      static_cast<WireFormatLite::FieldType>(type));\n  const string& incomplete = incompletes[wire_type];\n  const string type_name =\n      UpperCase(string(\".\") + FieldDescriptor::TypeName(type));\n\n  ExpectParseFailureForProto(\n      tag(fieldnum, wire_type),\n      \"PrematureEofBeforeKnownNonRepeatedValue\" + type_name);\n\n  ExpectParseFailureForProto(\n      tag(rep_fieldnum, wire_type),\n      \"PrematureEofBeforeKnownRepeatedValue\" + type_name);\n\n  ExpectParseFailureForProto(\n      tag(UNKNOWN_FIELD, wire_type),\n      \"PrematureEofBeforeUnknownValue\" + type_name);\n\n  ExpectParseFailureForProto(\n      cat( tag(fieldnum, wire_type), incomplete ),\n      \"PrematureEofInsideKnownNonRepeatedValue\" + type_name);\n\n  ExpectParseFailureForProto(\n      cat( tag(rep_fieldnum, wire_type), incomplete ),\n      \"PrematureEofInsideKnownRepeatedValue\" + type_name);\n\n  ExpectParseFailureForProto(\n      cat( tag(UNKNOWN_FIELD, wire_type), incomplete ),\n      \"PrematureEofInsideUnknownValue\" + type_name);\n\n  if (wire_type == WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {\n    ExpectParseFailureForProto(\n        cat( tag(fieldnum, wire_type), varint(1) ),\n        \"PrematureEofInDelimitedDataForKnownNonRepeatedValue\" + type_name);\n\n    ExpectParseFailureForProto(\n        cat( tag(rep_fieldnum, wire_type), varint(1) ),\n        \"PrematureEofInDelimitedDataForKnownRepeatedValue\" + type_name);\n\n    // EOF in the middle of delimited data for unknown value.\n    ExpectParseFailureForProto(\n        cat( tag(UNKNOWN_FIELD, wire_type), varint(1) ),\n        \"PrematureEofInDelimitedDataForUnknownValue\" + type_name);\n\n    if (type == FieldDescriptor::TYPE_MESSAGE) {\n      // Submessage ends in the middle of a value.\n      string incomplete_submsg =\n          cat( tag(WireFormatLite::TYPE_INT32, WireFormatLite::WIRETYPE_VARINT),\n                incompletes[WireFormatLite::WIRETYPE_VARINT] );\n      ExpectHardParseFailureForProto(\n          cat( tag(fieldnum, WireFormatLite::WIRETYPE_LENGTH_DELIMITED),\n               varint(incomplete_submsg.size()),\n               incomplete_submsg ),\n          \"PrematureEofInSubmessageValue\" + type_name);\n    }\n  } else if (type != FieldDescriptor::TYPE_GROUP) {\n    // Non-delimited, non-group: eligible for packing.\n\n    // Packed region ends in the middle of a value.\n    ExpectHardParseFailureForProto(\n        cat( tag(rep_fieldnum, WireFormatLite::WIRETYPE_LENGTH_DELIMITED),\n             varint(incomplete.size()),\n             incomplete ),\n        \"PrematureEofInPackedFieldValue\" + type_name);\n\n    // EOF in the middle of packed region.\n    ExpectParseFailureForProto(\n        cat( tag(rep_fieldnum, WireFormatLite::WIRETYPE_LENGTH_DELIMITED),\n             varint(1) ),\n        \"PrematureEofInPackedField\" + type_name);\n  }\n}\n\nvoid ConformanceTestSuite::SetFailureList(const string& filename,\n                                          const vector<string>& failure_list) {\n  failure_list_filename_ = filename;\n  expected_to_fail_.clear();\n  std::copy(failure_list.begin(), failure_list.end(),\n            std::inserter(expected_to_fail_, expected_to_fail_.end()));\n}\n\nbool ConformanceTestSuite::CheckSetEmpty(const set<string>& set_to_check,\n                                         const std::string& write_to_file,\n                                         const std::string& msg) {\n  if (set_to_check.empty()) {\n    return true;\n  } else {\n    StringAppendF(&output_, \"\\n\");\n    StringAppendF(&output_, \"%s\\n\\n\", msg.c_str());\n    for (set<string>::const_iterator iter = set_to_check.begin();\n         iter != set_to_check.end(); ++iter) {\n      StringAppendF(&output_, \"  %s\\n\", iter->c_str());\n    }\n    StringAppendF(&output_, \"\\n\");\n\n    if (!write_to_file.empty()) {\n      std::ofstream os(write_to_file);\n      if (os) {\n        for (set<string>::const_iterator iter = set_to_check.begin();\n             iter != set_to_check.end(); ++iter) {\n          os << *iter << \"\\n\";\n        }\n      } else {\n        StringAppendF(&output_, \"Failed to open file: %s\\n\",\n                      write_to_file.c_str());\n      }\n    }\n\n    return false;\n  }\n}\n\nbool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,\n                                    std::string* output) {\n  runner_ = runner;\n  successes_ = 0;\n  expected_failures_ = 0;\n  skipped_.clear();\n  test_names_.clear();\n  unexpected_failing_tests_.clear();\n  unexpected_succeeding_tests_.clear();\n  type_resolver_.reset(NewTypeResolverForDescriptorPool(\n      kTypeUrlPrefix, DescriptorPool::generated_pool()));\n  type_url_ = GetTypeUrl(TestAllTypes::descriptor());\n\n  output_ = \"\\nCONFORMANCE TEST BEGIN ====================================\\n\\n\";\n\n  for (int i = 1; i <= FieldDescriptor::MAX_TYPE; i++) {\n    if (i == FieldDescriptor::TYPE_GROUP) continue;\n    TestPrematureEOFForType(static_cast<FieldDescriptor::Type>(i));\n  }\n\n  RunValidJsonTest(\"HelloWorld\", \"{\\\"optionalString\\\":\\\"Hello, World!\\\"}\",\n                   \"optional_string: 'Hello, World!'\");\n\n  // Test field name conventions.\n  RunValidJsonTest(\n      \"FieldNameInSnakeCase\",\n      R\"({\n        \"fieldname1\": 1,\n        \"fieldName2\": 2,\n        \"FieldName3\": 3\n      })\",\n      R\"(\n        fieldname1: 1\n        field_name2: 2\n        _field_name3: 3\n      )\");\n  RunValidJsonTest(\n      \"FieldNameWithNumbers\",\n      R\"({\n        \"field0name5\": 5,\n        \"field0Name6\": 6\n      })\",\n      R\"(\n        field0name5: 5\n        field_0_name6: 6\n      )\");\n  RunValidJsonTest(\n      \"FieldNameWithMixedCases\",\n      R\"({\n        \"fieldName7\": 7,\n        \"fieldName8\": 8,\n        \"fieldName9\": 9,\n        \"fieldName10\": 10,\n        \"fIELDNAME11\": 11,\n        \"fIELDName12\": 12\n      })\",\n      R\"(\n        fieldName7: 7\n        FieldName8: 8\n        field_Name9: 9\n        Field_Name10: 10\n        FIELD_NAME11: 11\n        FIELD_name12: 12\n      )\");\n  // Using the original proto field name in JSON is also allowed.\n  RunValidJsonTest(\n      \"OriginalProtoFieldName\",\n      R\"({\n        \"fieldname1\": 1,\n        \"field_name2\": 2,\n        \"_field_name3\": 3,\n        \"field0name5\": 5,\n        \"field_0_name6\": 6,\n        \"fieldName7\": 7,\n        \"FieldName8\": 8,\n        \"field_Name9\": 9,\n        \"Field_Name10\": 10,\n        \"FIELD_NAME11\": 11,\n        \"FIELD_name12\": 12\n      })\",\n      R\"(\n        fieldname1: 1\n        field_name2: 2\n        _field_name3: 3\n        field0name5: 5\n        field_0_name6: 6\n        fieldName7: 7\n        FieldName8: 8\n        field_Name9: 9\n        Field_Name10: 10\n        FIELD_NAME11: 11\n        FIELD_name12: 12\n      )\");\n  // Field names can be escaped.\n  RunValidJsonTest(\n      \"FieldNameEscaped\",\n      R\"({\"fieldn\\u0061me1\": 1})\",\n      \"fieldname1: 1\");\n  // Field names must be quoted (or it's not valid JSON).\n  ExpectParseFailureForJson(\n      \"FieldNameNotQuoted\",\n      \"{fieldname1: 1}\");\n  // Trailing comma is not allowed (not valid JSON).\n  ExpectParseFailureForJson(\n      \"TrailingCommaInAnObject\",\n      R\"({\"fieldname1\":1,})\");\n  // JSON doesn't support comments.\n  ExpectParseFailureForJson(\n      \"JsonWithComments\",\n      R\"({\n        // This is a comment.\n        \"fieldname1\": 1\n      })\");\n  // Duplicated field names are not allowed.\n  ExpectParseFailureForJson(\n      \"FieldNameDuplicate\",\n      R\"({\n        \"optionalNestedMessage\": {a: 1},\n        \"optionalNestedMessage\": {}\n      })\");\n  ExpectParseFailureForJson(\n      \"FieldNameDuplicateDifferentCasing1\",\n      R\"({\n        \"optional_nested_message\": {a: 1},\n        \"optionalNestedMessage\": {}\n      })\");\n  ExpectParseFailureForJson(\n      \"FieldNameDuplicateDifferentCasing2\",\n      R\"({\n        \"optionalNestedMessage\": {a: 1},\n        \"optional_nested_message\": {}\n      })\");\n  // Serializers should use lowerCamelCase by default.\n  RunValidJsonTestWithValidator(\n      \"FieldNameInLowerCamelCase\",\n      R\"({\n        \"fieldname1\": 1,\n        \"fieldName2\": 2,\n        \"FieldName3\": 3\n      })\",\n      [](const Json::Value& value) {\n        return value.isMember(\"fieldname1\") &&\n            value.isMember(\"fieldName2\") &&\n            value.isMember(\"FieldName3\");\n      });\n  RunValidJsonTestWithValidator(\n      \"FieldNameWithNumbers\",\n      R\"({\n        \"field0name5\": 5,\n        \"field0Name6\": 6\n      })\",\n      [](const Json::Value& value) {\n        return value.isMember(\"field0name5\") &&\n            value.isMember(\"field0Name6\");\n      });\n  RunValidJsonTestWithValidator(\n      \"FieldNameWithMixedCases\",\n      R\"({\n        \"fieldName7\": 7,\n        \"fieldName8\": 8,\n        \"fieldName9\": 9,\n        \"fieldName10\": 10,\n        \"fIELDNAME11\": 11,\n        \"fIELDName12\": 12\n      })\",\n      [](const Json::Value& value) {\n        return value.isMember(\"fieldName7\") &&\n            value.isMember(\"fieldName8\") &&\n            value.isMember(\"fieldName9\") &&\n            value.isMember(\"fieldName10\") &&\n            value.isMember(\"fIELDNAME11\") &&\n            value.isMember(\"fIELDName12\");\n      });\n\n  // Integer fields.\n  RunValidJsonTest(\n      \"Int32FieldMaxValue\",\n      R\"({\"optionalInt32\": 2147483647})\",\n      \"optional_int32: 2147483647\");\n  RunValidJsonTest(\n      \"Int32FieldMinValue\",\n      R\"({\"optionalInt32\": -2147483648})\",\n      \"optional_int32: -2147483648\");\n  RunValidJsonTest(\n      \"Uint32FieldMaxValue\",\n      R\"({\"optionalUint32\": 4294967295})\",\n      \"optional_uint32: 4294967295\");\n  RunValidJsonTest(\n      \"Int64FieldMaxValue\",\n      R\"({\"optionalInt64\": \"9223372036854775807\"})\",\n      \"optional_int64: 9223372036854775807\");\n  RunValidJsonTest(\n      \"Int64FieldMinValue\",\n      R\"({\"optionalInt64\": \"-9223372036854775808\"})\",\n      \"optional_int64: -9223372036854775808\");\n  RunValidJsonTest(\n      \"Uint64FieldMaxValue\",\n      R\"({\"optionalUint64\": \"18446744073709551615\"})\",\n      \"optional_uint64: 18446744073709551615\");\n  RunValidJsonTest(\n      \"Int64FieldMaxValueNotQuoted\",\n      R\"({\"optionalInt64\": 9223372036854775807})\",\n      \"optional_int64: 9223372036854775807\");\n  RunValidJsonTest(\n      \"Int64FieldMinValueNotQuoted\",\n      R\"({\"optionalInt64\": -9223372036854775808})\",\n      \"optional_int64: -9223372036854775808\");\n  RunValidJsonTest(\n      \"Uint64FieldMaxValueNotQuoted\",\n      R\"({\"optionalUint64\": 18446744073709551615})\",\n      \"optional_uint64: 18446744073709551615\");\n  // Values can be represented as JSON strings.\n  RunValidJsonTest(\n      \"Int32FieldStringValue\",\n      R\"({\"optionalInt32\": \"2147483647\"})\",\n      \"optional_int32: 2147483647\");\n  RunValidJsonTest(\n      \"Int32FieldStringValueEscaped\",\n      R\"({\"optionalInt32\": \"2\\u003147483647\"})\",\n      \"optional_int32: 2147483647\");\n\n  // Parsers reject out-of-bound integer values.\n  ExpectParseFailureForJson(\n      \"Int32FieldTooLarge\",\n      R\"({\"optionalInt32\": 2147483648})\");\n  ExpectParseFailureForJson(\n      \"Int32FieldTooSmall\",\n      R\"({\"optionalInt32\": -2147483649})\");\n  ExpectParseFailureForJson(\n      \"Uint32FieldTooLarge\",\n      R\"({\"optionalUint32\": 4294967296})\");\n  ExpectParseFailureForJson(\n      \"Int64FieldTooLarge\",\n      R\"({\"optionalInt64\": \"9223372036854775808\"})\");\n  ExpectParseFailureForJson(\n      \"Int64FieldTooSmall\",\n      R\"({\"optionalInt64\": \"-9223372036854775809\"})\");\n  ExpectParseFailureForJson(\n      \"Uint64FieldTooLarge\",\n      R\"({\"optionalUint64\": \"18446744073709551616\"})\");\n  // Parser reject non-integer numeric values as well.\n  ExpectParseFailureForJson(\n      \"Int32FieldNotInteger\",\n      R\"({\"optionalInt32\": 0.5})\");\n  ExpectParseFailureForJson(\n      \"Uint32FieldNotInteger\",\n      R\"({\"optionalUint32\": 0.5})\");\n  ExpectParseFailureForJson(\n      \"Int64FieldNotInteger\",\n      R\"({\"optionalInt64\": \"0.5\"})\");\n  ExpectParseFailureForJson(\n      \"Uint64FieldNotInteger\",\n      R\"({\"optionalUint64\": \"0.5\"})\");\n\n  // Integers but represented as float values are accepted.\n  RunValidJsonTest(\n      \"Int32FieldFloatTrailingZero\",\n      R\"({\"optionalInt32\": 100000.000})\",\n      \"optional_int32: 100000\");\n  RunValidJsonTest(\n      \"Int32FieldExponentialFormat\",\n      R\"({\"optionalInt32\": 1e5})\",\n      \"optional_int32: 100000\");\n  RunValidJsonTest(\n      \"Int32FieldMaxFloatValue\",\n      R\"({\"optionalInt32\": 2.147483647e9})\",\n      \"optional_int32: 2147483647\");\n  RunValidJsonTest(\n      \"Int32FieldMinFloatValue\",\n      R\"({\"optionalInt32\": -2.147483648e9})\",\n      \"optional_int32: -2147483648\");\n  RunValidJsonTest(\n      \"Uint32FieldMaxFloatValue\",\n      R\"({\"optionalUint32\": 4.294967295e9})\",\n      \"optional_uint32: 4294967295\");\n\n  // Parser reject non-numeric values.\n  ExpectParseFailureForJson(\n      \"Int32FieldNotNumber\",\n      R\"({\"optionalInt32\": \"3x3\"})\");\n  ExpectParseFailureForJson(\n      \"Uint32FieldNotNumber\",\n      R\"({\"optionalUint32\": \"3x3\"})\");\n  ExpectParseFailureForJson(\n      \"Int64FieldNotNumber\",\n      R\"({\"optionalInt64\": \"3x3\"})\");\n  ExpectParseFailureForJson(\n      \"Uint64FieldNotNumber\",\n      R\"({\"optionalUint64\": \"3x3\"})\");\n  // JSON does not allow \"+\" on numric values.\n  ExpectParseFailureForJson(\n      \"Int32FieldPlusSign\",\n      R\"({\"optionalInt32\": +1})\");\n  // JSON doesn't allow leading 0s.\n  ExpectParseFailureForJson(\n      \"Int32FieldLeadingZero\",\n      R\"({\"optionalInt32\": 01})\");\n  ExpectParseFailureForJson(\n      \"Int32FieldNegativeWithLeadingZero\",\n      R\"({\"optionalInt32\": -01})\");\n  // String values must follow the same syntax rule. Specifically leading\n  // or traling spaces are not allowed.\n  ExpectParseFailureForJson(\n      \"Int32FieldLeadingSpace\",\n      R\"({\"optionalInt32\": \" 1\"})\");\n  ExpectParseFailureForJson(\n      \"Int32FieldTrailingSpace\",\n      R\"({\"optionalInt32\": \"1 \"})\");\n\n  // 64-bit values are serialized as strings.\n  RunValidJsonTestWithValidator(\n      \"Int64FieldBeString\",\n      R\"({\"optionalInt64\": 1})\",\n      [](const Json::Value& value) {\n        return value[\"optionalInt64\"].type() == Json::stringValue &&\n            value[\"optionalInt64\"].asString() == \"1\";\n      });\n  RunValidJsonTestWithValidator(\n      \"Uint64FieldBeString\",\n      R\"({\"optionalUint64\": 1})\",\n      [](const Json::Value& value) {\n        return value[\"optionalUint64\"].type() == Json::stringValue &&\n            value[\"optionalUint64\"].asString() == \"1\";\n      });\n\n  // Bool fields.\n  RunValidJsonTest(\n      \"BoolFieldTrue\",\n      R\"({\"optionalBool\":true})\",\n      \"optional_bool: true\");\n  RunValidJsonTest(\n      \"BoolFieldFalse\",\n      R\"({\"optionalBool\":false})\",\n      \"optional_bool: false\");\n\n  // Other forms are not allowed.\n  ExpectParseFailureForJson(\n      \"BoolFieldIntegerZero\",\n      R\"({\"optionalBool\":0})\");\n  ExpectParseFailureForJson(\n      \"BoolFieldIntegerOne\",\n      R\"({\"optionalBool\":1})\");\n  ExpectParseFailureForJson(\n      \"BoolFieldCamelCaseTrue\",\n      R\"({\"optionalBool\":True})\");\n  ExpectParseFailureForJson(\n      \"BoolFieldCamelCaseFalse\",\n      R\"({\"optionalBool\":False})\");\n  ExpectParseFailureForJson(\n      \"BoolFieldAllCapitalTrue\",\n      R\"({\"optionalBool\":TRUE})\");\n  ExpectParseFailureForJson(\n      \"BoolFieldAllCapitalFalse\",\n      R\"({\"optionalBool\":FALSE})\");\n  ExpectParseFailureForJson(\n      \"BoolFieldDoubleQuotedTrue\",\n      R\"({\"optionalBool\":\"true\"})\");\n  ExpectParseFailureForJson(\n      \"BoolFieldDoubleQuotedFalse\",\n      R\"({\"optionalBool\":\"false\"})\");\n\n  // Float fields.\n  RunValidJsonTest(\n      \"FloatFieldMinPositiveValue\",\n      R\"({\"optionalFloat\": 1.175494e-38})\",\n      \"optional_float: 1.175494e-38\");\n  RunValidJsonTest(\n      \"FloatFieldMaxNegativeValue\",\n      R\"({\"optionalFloat\": -1.175494e-38})\",\n      \"optional_float: -1.175494e-38\");\n  RunValidJsonTest(\n      \"FloatFieldMaxPositiveValue\",\n      R\"({\"optionalFloat\": 3.402823e+38})\",\n      \"optional_float: 3.402823e+38\");\n  RunValidJsonTest(\n      \"FloatFieldMinNegativeValue\",\n      R\"({\"optionalFloat\": 3.402823e+38})\",\n      \"optional_float: 3.402823e+38\");\n  // Values can be quoted.\n  RunValidJsonTest(\n      \"FloatFieldQuotedValue\",\n      R\"({\"optionalFloat\": \"1\"})\",\n      \"optional_float: 1\");\n  // Special values.\n  RunValidJsonTest(\n      \"FloatFieldNan\",\n      R\"({\"optionalFloat\": \"NaN\"})\",\n      \"optional_float: nan\");\n  RunValidJsonTest(\n      \"FloatFieldInfinity\",\n      R\"({\"optionalFloat\": \"Infinity\"})\",\n      \"optional_float: inf\");\n  RunValidJsonTest(\n      \"FloatFieldNegativeInfinity\",\n      R\"({\"optionalFloat\": \"-Infinity\"})\",\n      \"optional_float: -inf\");\n  // Non-cannonical Nan will be correctly normalized.\n  {\n    TestAllTypes message;\n    // IEEE floating-point standard 32-bit quiet NaN:\n    //   0111 1111 1xxx xxxx xxxx xxxx xxxx xxxx\n    message.set_optional_float(\n        WireFormatLite::DecodeFloat(0x7FA12345));\n    RunValidJsonTestWithProtobufInput(\n        \"FloatFieldNormalizeQuietNan\", message,\n        \"optional_float: nan\");\n    // IEEE floating-point standard 64-bit signaling NaN:\n    //   1111 1111 1xxx xxxx xxxx xxxx xxxx xxxx\n    message.set_optional_float(\n        WireFormatLite::DecodeFloat(0xFFB54321));\n    RunValidJsonTestWithProtobufInput(\n        \"FloatFieldNormalizeSignalingNan\", message,\n        \"optional_float: nan\");\n  }\n\n  // Special values must be quoted.\n  ExpectParseFailureForJson(\n      \"FloatFieldNanNotQuoted\",\n      R\"({\"optionalFloat\": NaN})\");\n  ExpectParseFailureForJson(\n      \"FloatFieldInfinityNotQuoted\",\n      R\"({\"optionalFloat\": Infinity})\");\n  ExpectParseFailureForJson(\n      \"FloatFieldNegativeInfinityNotQuoted\",\n      R\"({\"optionalFloat\": -Infinity})\");\n  // Parsers should reject out-of-bound values.\n  ExpectParseFailureForJson(\n      \"FloatFieldTooSmall\",\n      R\"({\"optionalFloat\": -3.502823e+38})\");\n  ExpectParseFailureForJson(\n      \"FloatFieldTooLarge\",\n      R\"({\"optionalFloat\": 3.502823e+38})\");\n\n  // Double fields.\n  RunValidJsonTest(\n      \"DoubleFieldMinPositiveValue\",\n      R\"({\"optionalDouble\": 2.22507e-308})\",\n      \"optional_double: 2.22507e-308\");\n  RunValidJsonTest(\n      \"DoubleFieldMaxNegativeValue\",\n      R\"({\"optionalDouble\": -2.22507e-308})\",\n      \"optional_double: -2.22507e-308\");\n  RunValidJsonTest(\n      \"DoubleFieldMaxPositiveValue\",\n      R\"({\"optionalDouble\": 1.79769e+308})\",\n      \"optional_double: 1.79769e+308\");\n  RunValidJsonTest(\n      \"DoubleFieldMinNegativeValue\",\n      R\"({\"optionalDouble\": -1.79769e+308})\",\n      \"optional_double: -1.79769e+308\");\n  // Values can be quoted.\n  RunValidJsonTest(\n      \"DoubleFieldQuotedValue\",\n      R\"({\"optionalDouble\": \"1\"})\",\n      \"optional_double: 1\");\n  // Speical values.\n  RunValidJsonTest(\n      \"DoubleFieldNan\",\n      R\"({\"optionalDouble\": \"NaN\"})\",\n      \"optional_double: nan\");\n  RunValidJsonTest(\n      \"DoubleFieldInfinity\",\n      R\"({\"optionalDouble\": \"Infinity\"})\",\n      \"optional_double: inf\");\n  RunValidJsonTest(\n      \"DoubleFieldNegativeInfinity\",\n      R\"({\"optionalDouble\": \"-Infinity\"})\",\n      \"optional_double: -inf\");\n  // Non-cannonical Nan will be correctly normalized.\n  {\n    TestAllTypes message;\n    message.set_optional_double(\n        WireFormatLite::DecodeDouble(0x7FFA123456789ABCLL));\n    RunValidJsonTestWithProtobufInput(\n        \"DoubleFieldNormalizeQuietNan\", message,\n        \"optional_double: nan\");\n    message.set_optional_double(\n        WireFormatLite::DecodeDouble(0xFFFBCBA987654321LL));\n    RunValidJsonTestWithProtobufInput(\n        \"DoubleFieldNormalizeSignalingNan\", message,\n        \"optional_double: nan\");\n  }\n\n  // Special values must be quoted.\n  ExpectParseFailureForJson(\n      \"DoubleFieldNanNotQuoted\",\n      R\"({\"optionalDouble\": NaN})\");\n  ExpectParseFailureForJson(\n      \"DoubleFieldInfinityNotQuoted\",\n      R\"({\"optionalDouble\": Infinity})\");\n  ExpectParseFailureForJson(\n      \"DoubleFieldNegativeInfinityNotQuoted\",\n      R\"({\"optionalDouble\": -Infinity})\");\n\n  // Parsers should reject out-of-bound values.\n  ExpectParseFailureForJson(\n      \"DoubleFieldTooSmall\",\n      R\"({\"optionalDouble\": -1.89769e+308})\");\n  ExpectParseFailureForJson(\n      \"DoubleFieldTooLarge\",\n      R\"({\"optionalDouble\": +1.89769e+308})\");\n\n  // Enum fields.\n  RunValidJsonTest(\n      \"EnumField\",\n      R\"({\"optionalNestedEnum\": \"FOO\"})\",\n      \"optional_nested_enum: FOO\");\n  // Enum values must be represented as strings.\n  ExpectParseFailureForJson(\n      \"EnumFieldNotQuoted\",\n      R\"({\"optionalNestedEnum\": FOO})\");\n  // Numeric values are allowed.\n  RunValidJsonTest(\n      \"EnumFieldNumericValueZero\",\n      R\"({\"optionalNestedEnum\": 0})\",\n      \"optional_nested_enum: FOO\");\n  RunValidJsonTest(\n      \"EnumFieldNumericValueNonZero\",\n      R\"({\"optionalNestedEnum\": 1})\",\n      \"optional_nested_enum: BAR\");\n  // Unknown enum values are represented as numeric values.\n  RunValidJsonTestWithValidator(\n      \"EnumFieldUnknownValue\",\n      R\"({\"optionalNestedEnum\": 123})\",\n      [](const Json::Value& value) {\n        return value[\"optionalNestedEnum\"].type() == Json::intValue &&\n            value[\"optionalNestedEnum\"].asInt() == 123;\n      });\n\n  // String fields.\n  RunValidJsonTest(\n      \"StringField\",\n      R\"({\"optionalString\": \"Hello world!\"})\",\n      \"optional_string: \\\"Hello world!\\\"\");\n  RunValidJsonTest(\n      \"StringFieldUnicode\",\n      // Google in Chinese.\n      R\"({\"optionalString\": \"谷歌\"})\",\n      R\"(optional_string: \"谷歌\")\");\n  RunValidJsonTest(\n      \"StringFieldEscape\",\n      R\"({\"optionalString\": \"\\\"\\\\\\/\\b\\f\\n\\r\\t\"})\",\n      R\"(optional_string: \"\\\"\\\\/\\b\\f\\n\\r\\t\")\");\n  RunValidJsonTest(\n      \"StringFieldUnicodeEscape\",\n      R\"({\"optionalString\": \"\\u8C37\\u6B4C\"})\",\n      R\"(optional_string: \"谷歌\")\");\n  RunValidJsonTest(\n      \"StringFieldUnicodeEscapeWithLowercaseHexLetters\",\n      R\"({\"optionalString\": \"\\u8c37\\u6b4c\"})\",\n      R\"(optional_string: \"谷歌\")\");\n  RunValidJsonTest(\n      \"StringFieldSurrogatePair\",\n      // The character is an emoji: grinning face with smiling eyes. 😁\n      R\"({\"optionalString\": \"\\uD83D\\uDE01\"})\",\n      R\"(optional_string: \"\\xF0\\x9F\\x98\\x81\")\");\n\n  // Unicode escapes must start with \"\\u\" (lowercase u).\n  ExpectParseFailureForJson(\n      \"StringFieldUppercaseEscapeLetter\",\n      R\"({\"optionalString\": \"\\U8C37\\U6b4C\"})\");\n  ExpectParseFailureForJson(\n      \"StringFieldInvalidEscape\",\n      R\"({\"optionalString\": \"\\uXXXX\\u6B4C\"})\");\n  ExpectParseFailureForJson(\n      \"StringFieldUnterminatedEscape\",\n      R\"({\"optionalString\": \"\\u8C3\"})\");\n  ExpectParseFailureForJson(\n      \"StringFieldUnpairedHighSurrogate\",\n      R\"({\"optionalString\": \"\\uD800\"})\");\n  ExpectParseFailureForJson(\n      \"StringFieldUnpairedLowSurrogate\",\n      R\"({\"optionalString\": \"\\uDC00\"})\");\n  ExpectParseFailureForJson(\n      \"StringFieldSurrogateInWrongOrder\",\n      R\"({\"optionalString\": \"\\uDE01\\uD83D\"})\");\n  ExpectParseFailureForJson(\n      \"StringFieldNotAString\",\n      R\"({\"optionalString\": 12345})\");\n\n  // Bytes fields.\n  RunValidJsonTest(\n      \"BytesField\",\n      R\"({\"optionalBytes\": \"AQI=\"})\",\n      R\"(optional_bytes: \"\\x01\\x02\")\");\n  ExpectParseFailureForJson(\n      \"BytesFieldNoPadding\",\n      R\"({\"optionalBytes\": \"AQI\"})\");\n  ExpectParseFailureForJson(\n      \"BytesFieldInvalidBase64Characters\",\n      R\"({\"optionalBytes\": \"-_==\"})\");\n\n  // Message fields.\n  RunValidJsonTest(\n      \"MessageField\",\n      R\"({\"optionalNestedMessage\": {\"a\": 1234}})\",\n      \"optional_nested_message: {a: 1234}\");\n\n  // Oneof fields.\n  ExpectParseFailureForJson(\n      \"OneofFieldDuplicate\",\n      R\"({\"oneofUint32\": 1, \"oneofString\": \"test\"})\");\n\n  // Repeated fields.\n  RunValidJsonTest(\n      \"PrimitiveRepeatedField\",\n      R\"({\"repeatedInt32\": [1, 2, 3, 4]})\",\n      \"repeated_int32: [1, 2, 3, 4]\");\n  RunValidJsonTest(\n      \"EnumRepeatedField\",\n      R\"({\"repeatedNestedEnum\": [\"FOO\", \"BAR\", \"BAZ\"]})\",\n      \"repeated_nested_enum: [FOO, BAR, BAZ]\");\n  RunValidJsonTest(\n      \"StringRepeatedField\",\n      R\"({\"repeatedString\": [\"Hello\", \"world\"]})\",\n      R\"(repeated_string: [\"Hello\", \"world\"])\");\n  RunValidJsonTest(\n      \"BytesRepeatedField\",\n      R\"({\"repeatedBytes\": [\"AAEC\", \"AQI=\"]})\",\n      R\"(repeated_bytes: [\"\\x00\\x01\\x02\", \"\\x01\\x02\"])\");\n  RunValidJsonTest(\n      \"MessageRepeatedField\",\n      R\"({\"repeatedNestedMessage\": [{\"a\": 1234}, {\"a\": 5678}]})\",\n      \"repeated_nested_message: {a: 1234}\"\n      \"repeated_nested_message: {a: 5678}\");\n\n  // Repeated field elements are of incorrect type.\n  ExpectParseFailureForJson(\n      \"RepeatedFieldWrongElementTypeExpectingIntegersGotBool\",\n      R\"({\"repeatedInt32\": [1, false, 3, 4]})\");\n  ExpectParseFailureForJson(\n      \"RepeatedFieldWrongElementTypeExpectingIntegersGotString\",\n      R\"({\"repeatedInt32\": [1, 2, \"name\", 4]})\");\n  ExpectParseFailureForJson(\n      \"RepeatedFieldWrongElementTypeExpectingIntegersGotMessage\",\n      R\"({\"repeatedInt32\": [1, 2, 3, {\"a\": 4}]})\");\n  ExpectParseFailureForJson(\n      \"RepeatedFieldWrongElementTypeExpectingStringsGotInt\",\n      R\"({\"repeatedString\": [\"1\", 2, \"3\", \"4\"]})\");\n  ExpectParseFailureForJson(\n      \"RepeatedFieldWrongElementTypeExpectingStringsGotBool\",\n      R\"({\"repeatedString\": [\"1\", \"2\", false, \"4\"]})\");\n  ExpectParseFailureForJson(\n      \"RepeatedFieldWrongElementTypeExpectingStringsGotMessage\",\n      R\"({\"repeatedString\": [\"1\", 2, \"3\", {\"a\": 4}]})\");\n  ExpectParseFailureForJson(\n      \"RepeatedFieldWrongElementTypeExpectingMessagesGotInt\",\n      R\"({\"repeatedNestedMessage\": [{\"a\": 1}, 2]})\");\n  ExpectParseFailureForJson(\n      \"RepeatedFieldWrongElementTypeExpectingMessagesGotBool\",\n      R\"({\"repeatedNestedMessage\": [{\"a\": 1}, false]})\");\n  ExpectParseFailureForJson(\n      \"RepeatedFieldWrongElementTypeExpectingMessagesGotString\",\n      R\"({\"repeatedNestedMessage\": [{\"a\": 1}, \"2\"]})\");\n  // Trailing comma in the repeated field is not allowed.\n  ExpectParseFailureForJson(\n      \"RepeatedFieldTrailingComma\",\n      R\"({\"repeatedInt32\": [1, 2, 3, 4,]})\");\n\n  // Map fields.\n  RunValidJsonTest(\n      \"Int32MapField\",\n      R\"({\"mapInt32Int32\": {\"1\": 2, \"3\": 4}})\",\n      \"map_int32_int32: {key: 1 value: 2}\"\n      \"map_int32_int32: {key: 3 value: 4}\");\n  ExpectParseFailureForJson(\n      \"Int32MapFieldKeyNotQuoted\",\n      R\"({\"mapInt32Int32\": {1: 2, 3: 4}})\");\n  RunValidJsonTest(\n      \"Uint32MapField\",\n      R\"({\"mapUint32Uint32\": {\"1\": 2, \"3\": 4}})\",\n      \"map_uint32_uint32: {key: 1 value: 2}\"\n      \"map_uint32_uint32: {key: 3 value: 4}\");\n  ExpectParseFailureForJson(\n      \"Uint32MapFieldKeyNotQuoted\",\n      R\"({\"mapUint32Uint32\": {1: 2, 3: 4}})\");\n  RunValidJsonTest(\n      \"Int64MapField\",\n      R\"({\"mapInt64Int64\": {\"1\": 2, \"3\": 4}})\",\n      \"map_int64_int64: {key: 1 value: 2}\"\n      \"map_int64_int64: {key: 3 value: 4}\");\n  ExpectParseFailureForJson(\n      \"Int64MapFieldKeyNotQuoted\",\n      R\"({\"mapInt64Int64\": {1: 2, 3: 4}})\");\n  RunValidJsonTest(\n      \"Uint64MapField\",\n      R\"({\"mapUint64Uint64\": {\"1\": 2, \"3\": 4}})\",\n      \"map_uint64_uint64: {key: 1 value: 2}\"\n      \"map_uint64_uint64: {key: 3 value: 4}\");\n  ExpectParseFailureForJson(\n      \"Uint64MapFieldKeyNotQuoted\",\n      R\"({\"mapUint64Uint64\": {1: 2, 3: 4}})\");\n  RunValidJsonTest(\n      \"BoolMapField\",\n      R\"({\"mapBoolBool\": {\"true\": true, \"false\": false}})\",\n      \"map_bool_bool: {key: true value: true}\"\n      \"map_bool_bool: {key: false value: false}\");\n  ExpectParseFailureForJson(\n      \"BoolMapFieldKeyNotQuoted\",\n      R\"({\"mapBoolBool\": {true: true, false: false}})\");\n  RunValidJsonTest(\n      \"MessageMapField\",\n      R\"({\n        \"mapStringNestedMessage\": {\n          \"hello\": {\"a\": 1234},\n          \"world\": {\"a\": 5678}\n        }\n      })\",\n      R\"(\n        map_string_nested_message: {\n          key: \"hello\"\n          value: {a: 1234}\n        }\n        map_string_nested_message: {\n          key: \"world\"\n          value: {a: 5678}\n        }\n      )\");\n  // Since Map keys are represented as JSON strings, escaping should be allowed.\n  RunValidJsonTest(\n      \"Int32MapEscapedKey\",\n      R\"({\"mapInt32Int32\": {\"\\u0031\": 2}})\",\n      \"map_int32_int32: {key: 1 value: 2}\");\n  RunValidJsonTest(\n      \"Int64MapEscapedKey\",\n      R\"({\"mapInt64Int64\": {\"\\u0031\": 2}})\",\n      \"map_int64_int64: {key: 1 value: 2}\");\n  RunValidJsonTest(\n      \"BoolMapEscapedKey\",\n      R\"({\"mapBoolBool\": {\"tr\\u0075e\": true}})\",\n      \"map_bool_bool: {key: true value: true}\");\n\n  // \"null\" is accepted for all fields types.\n  RunValidJsonTest(\n      \"AllFieldAcceptNull\",\n      R\"({\n        \"optionalInt32\": null,\n        \"optionalInt64\": null,\n        \"optionalUint32\": null,\n        \"optionalUint64\": null,\n        \"optionalBool\": null,\n        \"optionalString\": null,\n        \"optionalBytes\": null,\n        \"optionalNestedEnum\": null,\n        \"optionalNestedMessage\": null,\n        \"repeatedInt32\": null,\n        \"repeatedInt64\": null,\n        \"repeatedUint32\": null,\n        \"repeatedUint64\": null,\n        \"repeatedBool\": null,\n        \"repeatedString\": null,\n        \"repeatedBytes\": null,\n        \"repeatedNestedEnum\": null,\n        \"repeatedNestedMessage\": null,\n        \"mapInt32Int32\": null,\n        \"mapBoolBool\": null,\n        \"mapStringNestedMessage\": null\n      })\",\n      \"\");\n\n  // Repeated field elements cannot be null.\n  ExpectParseFailureForJson(\n      \"RepeatedFieldPrimitiveElementIsNull\",\n      R\"({\"repeatedInt32\": [1, null, 2]})\");\n  ExpectParseFailureForJson(\n      \"RepeatedFieldMessageElementIsNull\",\n      R\"({\"repeatedNestedMessage\": [{\"a\":1}, null, {\"a\":2}]})\");\n  // Map field keys cannot be null.\n  ExpectParseFailureForJson(\n      \"MapFieldKeyIsNull\",\n      R\"({\"mapInt32Int32\": {null: 1}})\");\n  // Map field values cannot be null.\n  ExpectParseFailureForJson(\n      \"MapFieldValueIsNull\",\n      R\"({\"mapInt32Int32\": {\"0\": null}})\");\n\n  // Wrapper types.\n  RunValidJsonTest(\n      \"OptionalBoolWrapper\",\n      R\"({\"optionalBoolWrapper\": false})\",\n      \"optional_bool_wrapper: {value: false}\");\n  RunValidJsonTest(\n      \"OptionalInt32Wrapper\",\n      R\"({\"optionalInt32Wrapper\": 0})\",\n      \"optional_int32_wrapper: {value: 0}\");\n  RunValidJsonTest(\n      \"OptionalUint32Wrapper\",\n      R\"({\"optionalUint32Wrapper\": 0})\",\n      \"optional_uint32_wrapper: {value: 0}\");\n  RunValidJsonTest(\n      \"OptionalInt64Wrapper\",\n      R\"({\"optionalInt64Wrapper\": 0})\",\n      \"optional_int64_wrapper: {value: 0}\");\n  RunValidJsonTest(\n      \"OptionalUint64Wrapper\",\n      R\"({\"optionalUint64Wrapper\": 0})\",\n      \"optional_uint64_wrapper: {value: 0}\");\n  RunValidJsonTest(\n      \"OptionalFloatWrapper\",\n      R\"({\"optionalFloatWrapper\": 0})\",\n      \"optional_float_wrapper: {value: 0}\");\n  RunValidJsonTest(\n      \"OptionalDoubleWrapper\",\n      R\"({\"optionalDoubleWrapper\": 0})\",\n      \"optional_double_wrapper: {value: 0}\");\n  RunValidJsonTest(\n      \"OptionalStringWrapper\",\n      R\"({\"optionalStringWrapper\": \"\"})\",\n      R\"(optional_string_wrapper: {value: \"\"})\");\n  RunValidJsonTest(\n      \"OptionalBytesWrapper\",\n      R\"({\"optionalBytesWrapper\": \"\"})\",\n      R\"(optional_bytes_wrapper: {value: \"\"})\");\n  RunValidJsonTest(\n      \"OptionalWrapperTypesWithNonDefaultValue\",\n      R\"({\n        \"optionalBoolWrapper\": true,\n        \"optionalInt32Wrapper\": 1,\n        \"optionalUint32Wrapper\": 1,\n        \"optionalInt64Wrapper\": \"1\",\n        \"optionalUint64Wrapper\": \"1\",\n        \"optionalFloatWrapper\": 1,\n        \"optionalDoubleWrapper\": 1,\n        \"optionalStringWrapper\": \"1\",\n        \"optionalBytesWrapper\": \"AQI=\"\n      })\",\n      R\"(\n        optional_bool_wrapper: {value: true}\n        optional_int32_wrapper: {value: 1}\n        optional_uint32_wrapper: {value: 1}\n        optional_int64_wrapper: {value: 1}\n        optional_uint64_wrapper: {value: 1}\n        optional_float_wrapper: {value: 1}\n        optional_double_wrapper: {value: 1}\n        optional_string_wrapper: {value: \"1\"}\n        optional_bytes_wrapper: {value: \"\\x01\\x02\"}\n      )\");\n  RunValidJsonTest(\n      \"RepeatedBoolWrapper\",\n      R\"({\"repeatedBoolWrapper\": [true, false]})\",\n      \"repeated_bool_wrapper: {value: true}\"\n      \"repeated_bool_wrapper: {value: false}\");\n  RunValidJsonTest(\n      \"RepeatedInt32Wrapper\",\n      R\"({\"repeatedInt32Wrapper\": [0, 1]})\",\n      \"repeated_int32_wrapper: {value: 0}\"\n      \"repeated_int32_wrapper: {value: 1}\");\n  RunValidJsonTest(\n      \"RepeatedUint32Wrapper\",\n      R\"({\"repeatedUint32Wrapper\": [0, 1]})\",\n      \"repeated_uint32_wrapper: {value: 0}\"\n      \"repeated_uint32_wrapper: {value: 1}\");\n  RunValidJsonTest(\n      \"RepeatedInt64Wrapper\",\n      R\"({\"repeatedInt64Wrapper\": [0, 1]})\",\n      \"repeated_int64_wrapper: {value: 0}\"\n      \"repeated_int64_wrapper: {value: 1}\");\n  RunValidJsonTest(\n      \"RepeatedUint64Wrapper\",\n      R\"({\"repeatedUint64Wrapper\": [0, 1]})\",\n      \"repeated_uint64_wrapper: {value: 0}\"\n      \"repeated_uint64_wrapper: {value: 1}\");\n  RunValidJsonTest(\n      \"RepeatedFloatWrapper\",\n      R\"({\"repeatedFloatWrapper\": [0, 1]})\",\n      \"repeated_float_wrapper: {value: 0}\"\n      \"repeated_float_wrapper: {value: 1}\");\n  RunValidJsonTest(\n      \"RepeatedDoubleWrapper\",\n      R\"({\"repeatedDoubleWrapper\": [0, 1]})\",\n      \"repeated_double_wrapper: {value: 0}\"\n      \"repeated_double_wrapper: {value: 1}\");\n  RunValidJsonTest(\n      \"RepeatedStringWrapper\",\n      R\"({\"repeatedStringWrapper\": [\"\", \"AQI=\"]})\",\n      R\"(\n        repeated_string_wrapper: {value: \"\"}\n        repeated_string_wrapper: {value: \"AQI=\"}\n      )\");\n  RunValidJsonTest(\n      \"RepeatedBytesWrapper\",\n      R\"({\"repeatedBytesWrapper\": [\"\", \"AQI=\"]})\",\n      R\"(\n        repeated_bytes_wrapper: {value: \"\"}\n        repeated_bytes_wrapper: {value: \"\\x01\\x02\"}\n      )\");\n  RunValidJsonTest(\n      \"WrapperTypesWithNullValue\",\n      R\"({\n        \"optionalBoolWrapper\": null,\n        \"optionalInt32Wrapper\": null,\n        \"optionalUint32Wrapper\": null,\n        \"optionalInt64Wrapper\": null,\n        \"optionalUint64Wrapper\": null,\n        \"optionalFloatWrapper\": null,\n        \"optionalDoubleWrapper\": null,\n        \"optionalStringWrapper\": null,\n        \"optionalBytesWrapper\": null,\n        \"repeatedBoolWrapper\": null,\n        \"repeatedInt32Wrapper\": null,\n        \"repeatedUint32Wrapper\": null,\n        \"repeatedInt64Wrapper\": null,\n        \"repeatedUint64Wrapper\": null,\n        \"repeatedFloatWrapper\": null,\n        \"repeatedDoubleWrapper\": null,\n        \"repeatedStringWrapper\": null,\n        \"repeatedBytesWrapper\": null\n      })\",\n      \"\");\n\n  // Duration\n  RunValidJsonTest(\n      \"DurationMinValue\",\n      R\"({\"optionalDuration\": \"-315576000000.999999999s\"})\",\n      \"optional_duration: {seconds: -315576000000 nanos: -999999999}\");\n  RunValidJsonTest(\n      \"DurationMaxValue\",\n      R\"({\"optionalDuration\": \"315576000000.999999999s\"})\",\n      \"optional_duration: {seconds: 315576000000 nanos: 999999999}\");\n  RunValidJsonTest(\n      \"DurationRepeatedValue\",\n      R\"({\"repeatedDuration\": [\"1.5s\", \"-1.5s\"]})\",\n      \"repeated_duration: {seconds: 1 nanos: 500000000}\"\n      \"repeated_duration: {seconds: -1 nanos: -500000000}\");\n\n  ExpectParseFailureForJson(\n      \"DurationMissingS\",\n      R\"({\"optionalDuration\": \"1\"})\");\n  ExpectParseFailureForJson(\n      \"DurationJsonInputTooSmall\",\n      R\"({\"optionalDuration\": \"-315576000001.000000000s\"})\");\n  ExpectParseFailureForJson(\n      \"DurationJsonInputTooLarge\",\n      R\"({\"optionalDuration\": \"315576000001.000000000s\"})\");\n  ExpectSerializeFailureForJson(\n      \"DurationProtoInputTooSmall\",\n      \"optional_duration: {seconds: -315576000001 nanos: 0}\");\n  ExpectSerializeFailureForJson(\n      \"DurationProtoInputTooLarge\",\n      \"optional_duration: {seconds: 315576000001 nanos: 0}\");\n\n  RunValidJsonTestWithValidator(\n      \"DurationHasZeroFractionalDigit\",\n      R\"({\"optionalDuration\": \"1.000000000s\"})\",\n      [](const Json::Value& value) {\n        return value[\"optionalDuration\"].asString() == \"1s\";\n      });\n  RunValidJsonTestWithValidator(\n      \"DurationHas3FractionalDigits\",\n      R\"({\"optionalDuration\": \"1.010000000s\"})\",\n      [](const Json::Value& value) {\n        return value[\"optionalDuration\"].asString() == \"1.010s\";\n      });\n  RunValidJsonTestWithValidator(\n      \"DurationHas6FractionalDigits\",\n      R\"({\"optionalDuration\": \"1.000010000s\"})\",\n      [](const Json::Value& value) {\n        return value[\"optionalDuration\"].asString() == \"1.000010s\";\n      });\n  RunValidJsonTestWithValidator(\n      \"DurationHas9FractionalDigits\",\n      R\"({\"optionalDuration\": \"1.000000010s\"})\",\n      [](const Json::Value& value) {\n        return value[\"optionalDuration\"].asString() == \"1.000000010s\";\n      });\n\n  // Timestamp\n  RunValidJsonTest(\n      \"TimestampMinValue\",\n      R\"({\"optionalTimestamp\": \"0001-01-01T00:00:00Z\"})\",\n      \"optional_timestamp: {seconds: -62135596800}\");\n  RunValidJsonTest(\n      \"TimestampMaxValue\",\n      R\"({\"optionalTimestamp\": \"9999-12-31T23:59:59.999999999Z\"})\",\n      \"optional_timestamp: {seconds: 253402300799 nanos: 999999999}\");\n  RunValidJsonTest(\n      \"TimestampRepeatedValue\",\n      R\"({\n        \"repeatedTimestamp\": [\n          \"0001-01-01T00:00:00Z\",\n          \"9999-12-31T23:59:59.999999999Z\"\n        ]\n      })\",\n      \"repeated_timestamp: {seconds: -62135596800}\"\n      \"repeated_timestamp: {seconds: 253402300799 nanos: 999999999}\");\n  RunValidJsonTest(\n      \"TimestampWithPositiveOffset\",\n      R\"({\"optionalTimestamp\": \"1970-01-01T08:00:00+08:00\"})\",\n      \"optional_timestamp: {seconds: 0}\");\n  RunValidJsonTest(\n      \"TimestampWithNegativeOffset\",\n      R\"({\"optionalTimestamp\": \"1969-12-31T16:00:00-08:00\"})\",\n      \"optional_timestamp: {seconds: 0}\");\n\n  ExpectParseFailureForJson(\n      \"TimestampJsonInputTooSmall\",\n      R\"({\"optionalTimestamp\": \"0000-01-01T00:00:00Z\"})\");\n  ExpectParseFailureForJson(\n      \"TimestampJsonInputTooLarge\",\n      R\"({\"optionalTimestamp\": \"10000-01-01T00:00:00Z\"})\");\n  ExpectParseFailureForJson(\n      \"TimestampJsonInputMissingZ\",\n      R\"({\"optionalTimestamp\": \"0001-01-01T00:00:00\"})\");\n  ExpectParseFailureForJson(\n      \"TimestampJsonInputMissingT\",\n      R\"({\"optionalTimestamp\": \"0001-01-01 00:00:00Z\"})\");\n  ExpectParseFailureForJson(\n      \"TimestampJsonInputLowercaseZ\",\n      R\"({\"optionalTimestamp\": \"0001-01-01T00:00:00z\"})\");\n  ExpectParseFailureForJson(\n      \"TimestampJsonInputLowercaseT\",\n      R\"({\"optionalTimestamp\": \"0001-01-01t00:00:00Z\"})\");\n  ExpectSerializeFailureForJson(\n      \"TimestampProtoInputTooSmall\",\n      \"optional_timestamp: {seconds: -62135596801}\");\n  ExpectSerializeFailureForJson(\n      \"TimestampProtoInputTooLarge\",\n      \"optional_timestamp: {seconds: 253402300800}\");\n  RunValidJsonTestWithValidator(\n      \"TimestampZeroNormalized\",\n      R\"({\"optionalTimestamp\": \"1969-12-31T16:00:00-08:00\"})\",\n      [](const Json::Value& value) {\n        return value[\"optionalTimestamp\"].asString() ==\n            \"1970-01-01T00:00:00Z\";\n      });\n  RunValidJsonTestWithValidator(\n      \"TimestampHasZeroFractionalDigit\",\n      R\"({\"optionalTimestamp\": \"1970-01-01T00:00:00.000000000Z\"})\",\n      [](const Json::Value& value) {\n        return value[\"optionalTimestamp\"].asString() ==\n            \"1970-01-01T00:00:00Z\";\n      });\n  RunValidJsonTestWithValidator(\n      \"TimestampHas3FractionalDigits\",\n      R\"({\"optionalTimestamp\": \"1970-01-01T00:00:00.010000000Z\"})\",\n      [](const Json::Value& value) {\n        return value[\"optionalTimestamp\"].asString() ==\n            \"1970-01-01T00:00:00.010Z\";\n      });\n  RunValidJsonTestWithValidator(\n      \"TimestampHas6FractionalDigits\",\n      R\"({\"optionalTimestamp\": \"1970-01-01T00:00:00.000010000Z\"})\",\n      [](const Json::Value& value) {\n        return value[\"optionalTimestamp\"].asString() ==\n            \"1970-01-01T00:00:00.000010Z\";\n      });\n  RunValidJsonTestWithValidator(\n      \"TimestampHas9FractionalDigits\",\n      R\"({\"optionalTimestamp\": \"1970-01-01T00:00:00.000000010Z\"})\",\n      [](const Json::Value& value) {\n        return value[\"optionalTimestamp\"].asString() ==\n            \"1970-01-01T00:00:00.000000010Z\";\n      });\n\n  // FieldMask\n  RunValidJsonTest(\n      \"FieldMask\",\n      R\"({\"optionalFieldMask\": \"foo,barBaz\"})\",\n      R\"(optional_field_mask: {paths: \"foo\" paths: \"bar_baz\"})\");\n  ExpectParseFailureForJson(\n      \"FieldMaskInvalidCharacter\",\n      R\"({\"optionalFieldMask\": \"foo,bar_bar\"})\");\n  ExpectSerializeFailureForJson(\n      \"FieldMaskPathsDontRoundTrip\",\n      R\"(optional_field_mask: {paths: \"fooBar\"})\");\n  ExpectSerializeFailureForJson(\n      \"FieldMaskNumbersDontRoundTrip\",\n      R\"(optional_field_mask: {paths: \"foo_3_bar\"})\");\n  ExpectSerializeFailureForJson(\n      \"FieldMaskTooManyUnderscore\",\n      R\"(optional_field_mask: {paths: \"foo__bar\"})\");\n\n  // Struct\n  RunValidJsonTest(\n      \"Struct\",\n      R\"({\n        \"optionalStruct\": {\n          \"nullValue\": null,\n          \"intValue\": 1234,\n          \"boolValue\": true,\n          \"doubleValue\": 1234.5678,\n          \"stringValue\": \"Hello world!\",\n          \"listValue\": [1234, \"5678\"],\n          \"objectValue\": {\n            \"value\": 0\n          }\n        }\n      })\",\n      R\"(\n        optional_struct: {\n          fields: {\n            key: \"nullValue\"\n            value: {null_value: NULL_VALUE}\n          }\n          fields: {\n            key: \"intValue\"\n            value: {number_value: 1234}\n          }\n          fields: {\n            key: \"boolValue\"\n            value: {bool_value: true}\n          }\n          fields: {\n            key: \"doubleValue\"\n            value: {number_value: 1234.5678}\n          }\n          fields: {\n            key: \"stringValue\"\n            value: {string_value: \"Hello world!\"}\n          }\n          fields: {\n            key: \"listValue\"\n            value: {\n              list_value: {\n                values: {\n                  number_value: 1234\n                }\n                values: {\n                  string_value: \"5678\"\n                }\n              }\n            }\n          }\n          fields: {\n            key: \"objectValue\"\n            value: {\n              struct_value: {\n                fields: {\n                  key: \"value\"\n                  value: {\n                    number_value: 0\n                  }\n                }\n              }\n            }\n          }\n        }\n      )\");\n  // Value\n  RunValidJsonTest(\n      \"ValueAcceptInteger\",\n      R\"({\"optionalValue\": 1})\",\n      \"optional_value: { number_value: 1}\");\n  RunValidJsonTest(\n      \"ValueAcceptFloat\",\n      R\"({\"optionalValue\": 1.5})\",\n      \"optional_value: { number_value: 1.5}\");\n  RunValidJsonTest(\n      \"ValueAcceptBool\",\n      R\"({\"optionalValue\": false})\",\n      \"optional_value: { bool_value: false}\");\n  RunValidJsonTest(\n      \"ValueAcceptNull\",\n      R\"({\"optionalValue\": null})\",\n      \"optional_value: { null_value: NULL_VALUE}\");\n  RunValidJsonTest(\n      \"ValueAcceptString\",\n      R\"({\"optionalValue\": \"hello\"})\",\n      R\"(optional_value: { string_value: \"hello\"})\");\n  RunValidJsonTest(\n      \"ValueAcceptList\",\n      R\"({\"optionalValue\": [0, \"hello\"]})\",\n      R\"(\n        optional_value: {\n          list_value: {\n            values: {\n              number_value: 0\n            }\n            values: {\n              string_value: \"hello\"\n            }\n          }\n        }\n      )\");\n  RunValidJsonTest(\n      \"ValueAcceptObject\",\n      R\"({\"optionalValue\": {\"value\": 1}})\",\n      R\"(\n        optional_value: {\n          struct_value: {\n            fields: {\n              key: \"value\"\n              value: {\n                number_value: 1\n              }\n            }\n          }\n        }\n      )\");\n\n  // Any\n  RunValidJsonTest(\n      \"Any\",\n      R\"({\n        \"optionalAny\": {\n          \"@type\": \"type.googleapis.com/conformance.TestAllTypes\",\n          \"optionalInt32\": 12345\n        }\n      })\",\n      R\"(\n        optional_any: {\n          [type.googleapis.com/conformance.TestAllTypes] {\n            optional_int32: 12345\n          }\n        }\n      )\");\n  RunValidJsonTest(\n      \"AnyNested\",\n      R\"({\n        \"optionalAny\": {\n          \"@type\": \"type.googleapis.com/google.protobuf.Any\",\n          \"value\": {\n            \"@type\": \"type.googleapis.com/conformance.TestAllTypes\",\n            \"optionalInt32\": 12345\n          }\n        }\n      })\",\n      R\"(\n        optional_any: {\n          [type.googleapis.com/google.protobuf.Any] {\n            [type.googleapis.com/conformance.TestAllTypes] {\n              optional_int32: 12345\n            }\n          }\n        }\n      )\");\n  // The special \"@type\" tag is not required to appear first.\n  RunValidJsonTest(\n      \"AnyUnorderedTypeTag\",\n      R\"({\n        \"optionalAny\": {\n          \"optionalInt32\": 12345,\n          \"@type\": \"type.googleapis.com/conformance.TestAllTypes\"\n        }\n      })\",\n      R\"(\n        optional_any: {\n          [type.googleapis.com/conformance.TestAllTypes] {\n            optional_int32: 12345\n          }\n        }\n      )\");\n  // Well-known types in Any.\n  RunValidJsonTest(\n      \"AnyWithInt32ValueWrapper\",\n      R\"({\n        \"optionalAny\": {\n          \"@type\": \"type.googleapis.com/google.protobuf.Int32Value\",\n          \"value\": 12345\n        }\n      })\",\n      R\"(\n        optional_any: {\n          [type.googleapis.com/google.protobuf.Int32Value] {\n            value: 12345\n          }\n        }\n      )\");\n  RunValidJsonTest(\n      \"AnyWithDuration\",\n      R\"({\n        \"optionalAny\": {\n          \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n          \"value\": \"1.5s\"\n        }\n      })\",\n      R\"(\n        optional_any: {\n          [type.googleapis.com/google.protobuf.Duration] {\n            seconds: 1\n            nanos: 500000000\n          }\n        }\n      )\");\n  RunValidJsonTest(\n      \"AnyWithTimestamp\",\n      R\"({\n        \"optionalAny\": {\n          \"@type\": \"type.googleapis.com/google.protobuf.Timestamp\",\n          \"value\": \"1970-01-01T00:00:00Z\"\n        }\n      })\",\n      R\"(\n        optional_any: {\n          [type.googleapis.com/google.protobuf.Timestamp] {\n            seconds: 0\n            nanos: 0\n          }\n        }\n      )\");\n  RunValidJsonTest(\n      \"AnyWithFieldMask\",\n      R\"({\n        \"optionalAny\": {\n          \"@type\": \"type.googleapis.com/google.protobuf.FieldMask\",\n          \"value\": \"foo,barBaz\"\n        }\n      })\",\n      R\"(\n        optional_any: {\n          [type.googleapis.com/google.protobuf.FieldMask] {\n            paths: [\"foo\", \"bar_baz\"]\n          }\n        }\n      )\");\n  RunValidJsonTest(\n      \"AnyWithStruct\",\n      R\"({\n        \"optionalAny\": {\n          \"@type\": \"type.googleapis.com/google.protobuf.Struct\",\n          \"value\": {\n            \"foo\": 1\n          }\n        }\n      })\",\n      R\"(\n        optional_any: {\n          [type.googleapis.com/google.protobuf.Struct] {\n            fields: {\n              key: \"foo\"\n              value: {\n                number_value: 1\n              }\n            }\n          }\n        }\n      )\");\n  RunValidJsonTest(\n      \"AnyWithValueForJsonObject\",\n      R\"({\n        \"optionalAny\": {\n          \"@type\": \"type.googleapis.com/google.protobuf.Value\",\n          \"value\": {\n            \"foo\": 1\n          }\n        }\n      })\",\n      R\"(\n        optional_any: {\n          [type.googleapis.com/google.protobuf.Value] {\n            struct_value: {\n              fields: {\n                key: \"foo\"\n                value: {\n                  number_value: 1\n                }\n              }\n            }\n          }\n        }\n      )\");\n  RunValidJsonTest(\n      \"AnyWithValueForInteger\",\n      R\"({\n        \"optionalAny\": {\n          \"@type\": \"type.googleapis.com/google.protobuf.Value\",\n          \"value\": 1\n        }\n      })\",\n      R\"(\n        optional_any: {\n          [type.googleapis.com/google.protobuf.Value] {\n            number_value: 1\n          }\n        }\n      )\");\n\n  bool ok = true;\n  if (!CheckSetEmpty(expected_to_fail_, \"nonexistent_tests.txt\",\n                     \"These tests were listed in the failure list, but they \"\n                     \"don't exist.  Remove them from the failure list by \"\n                     \"running:\\n\"\n                     \"  ./update_failure_list.py \" + failure_list_filename_ +\n                     \" --remove nonexistent_tests.txt\")) {\n    ok = false;\n  }\n  if (!CheckSetEmpty(unexpected_failing_tests_, \"failing_tests.txt\",\n                     \"These tests failed.  If they can't be fixed right now, \"\n                     \"you can add them to the failure list so the overall \"\n                     \"suite can succeed.  Add them to the failure list by \"\n                     \"running:\\n\"\n                     \"  ./update_failure_list.py \" + failure_list_filename_ +\n                     \" --add failing_tests.txt\")) {\n    ok = false;\n  }\n  if (!CheckSetEmpty(unexpected_succeeding_tests_, \"succeeding_tests.txt\",\n                     \"These tests succeeded, even though they were listed in \"\n                     \"the failure list.  Remove them from the failure list \"\n                     \"by running:\\n\"\n                     \"  ./update_failure_list.py \" + failure_list_filename_ +\n                     \" --remove succeeding_tests.txt\")) {\n    ok = false;\n  }\n\n  if (verbose_) {\n    CheckSetEmpty(skipped_, \"\",\n                  \"These tests were skipped (probably because support for some \"\n                  \"features is not implemented)\");\n  }\n\n  StringAppendF(&output_,\n                \"CONFORMANCE SUITE %s: %d successes, %d skipped, \"\n                \"%d expected failures, %d unexpected failures.\\n\",\n                ok ? \"PASSED\" : \"FAILED\", successes_, skipped_.size(),\n                expected_failures_, unexpected_failing_tests_.size());\n  StringAppendF(&output_, \"\\n\");\n\n  output->assign(output_);\n\n  return ok;\n}\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/conformance_test.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n// This file defines a protocol for running the conformance test suite\n// in-process.  In other words, the suite itself will run in the same process as\n// the code under test.\n//\n// For pros and cons of this approach, please see conformance.proto.\n\n#ifndef CONFORMANCE_CONFORMANCE_TEST_H\n#define CONFORMANCE_CONFORMANCE_TEST_H\n\n#include <functional>\n#include <string>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/util/type_resolver.h>\n#include <google/protobuf/wire_format_lite.h>\n\n#include \"third_party/jsoncpp/json.h\"\n\nnamespace conformance {\nclass ConformanceRequest;\nclass ConformanceResponse;\nclass TestAllTypes;\n}  // namespace conformance\n\nnamespace google {\nnamespace protobuf {\n\nclass ConformanceTestRunner {\n public:\n  virtual ~ConformanceTestRunner() {}\n\n  // Call to run a single conformance test.\n  //\n  // \"input\" is a serialized conformance.ConformanceRequest.\n  // \"output\" should be set to a serialized conformance.ConformanceResponse.\n  //\n  // If there is any error in running the test itself, set \"runtime_error\" in\n  // the response.\n  virtual void RunTest(const std::string& test_name,\n                       const std::string& input,\n                       std::string* output) = 0;\n};\n\n// Class representing the test suite itself.  To run it, implement your own\n// class derived from ConformanceTestRunner and then write code like:\n//\n//    class MyConformanceTestRunner : public ConformanceTestRunner {\n//     public:\n//      virtual void RunTest(...) {\n//        // INSERT YOUR FRAMEWORK-SPECIFIC CODE HERE.\n//      }\n//    };\n//\n//    int main() {\n//      MyConformanceTestRunner runner;\n//      google::protobuf::ConformanceTestSuite suite;\n//\n//      std::string output;\n//      suite.RunSuite(&runner, &output);\n//    }\n//\nclass ConformanceTestSuite {\n public:\n  ConformanceTestSuite() : verbose_(false) {}\n\n  void SetVerbose(bool verbose) { verbose_ = verbose; }\n\n  // Sets the list of tests that are expected to fail when RunSuite() is called.\n  // RunSuite() will fail unless the set of failing tests is exactly the same\n  // as this list.\n  //\n  // The filename here is *only* used to create/format useful error messages for\n  // how to update the failure list.  We do NOT read this file at all.\n  void SetFailureList(const std::string& filename,\n                      const std::vector<std::string>& failure_list);\n\n  // Run all the conformance tests against the given test runner.\n  // Test output will be stored in \"output\".\n  //\n  // Returns true if the set of failing tests was exactly the same as the\n  // failure list.  If SetFailureList() was not called, returns true if all\n  // tests passed.\n  bool RunSuite(ConformanceTestRunner* runner, std::string* output);\n\n private:\n  void ReportSuccess(const std::string& test_name);\n  void ReportFailure(const string& test_name,\n                     const conformance::ConformanceRequest& request,\n                     const conformance::ConformanceResponse& response,\n                     const char* fmt, ...);\n  void ReportSkip(const string& test_name,\n                  const conformance::ConformanceRequest& request,\n                  const conformance::ConformanceResponse& response);\n  void RunTest(const std::string& test_name,\n               const conformance::ConformanceRequest& request,\n               conformance::ConformanceResponse* response);\n  void RunValidInputTest(const string& test_name, const string& input,\n                         conformance::WireFormat input_format,\n                         const string& equivalent_text_format,\n                         conformance::WireFormat requested_output);\n  void RunValidJsonTest(const string& test_name, const string& input_json,\n                        const string& equivalent_text_format);\n  void RunValidJsonTestWithProtobufInput(const string& test_name,\n                                         const conformance::TestAllTypes& input,\n                                         const string& equivalent_text_format);\n\n  typedef std::function<bool(const Json::Value&)> Validator;\n  void RunValidJsonTestWithValidator(const string& test_name,\n                                     const string& input_json,\n                                     const Validator& validator);\n  void ExpectParseFailureForJson(const string& test_name,\n                                 const string& input_json);\n  void ExpectSerializeFailureForJson(const string& test_name,\n                                     const string& text_format);\n  void ExpectParseFailureForProto(const std::string& proto,\n                                  const std::string& test_name);\n  void ExpectHardParseFailureForProto(const std::string& proto,\n                                      const std::string& test_name);\n  void TestPrematureEOFForType(google::protobuf::FieldDescriptor::Type type);\n  bool CheckSetEmpty(const set<string>& set_to_check,\n                     const std::string& write_to_file, const std::string& msg);\n  ConformanceTestRunner* runner_;\n  int successes_;\n  int expected_failures_;\n  bool verbose_;\n  std::string output_;\n  std::string failure_list_filename_;\n\n  // The set of test names that are expected to fail in this run, but haven't\n  // failed yet.\n  std::set<std::string> expected_to_fail_;\n\n  // The set of test names that have been run.  Used to ensure that there are no\n  // duplicate names in the suite.\n  std::set<std::string> test_names_;\n\n  // The set of tests that failed, but weren't expected to.\n  std::set<std::string> unexpected_failing_tests_;\n\n  // The set of tests that succeeded, but weren't expected to.\n  std::set<std::string> unexpected_succeeding_tests_;\n\n  // The set of tests that the testee opted out of;\n  std::set<std::string> skipped_;\n\n  google::protobuf::internal::scoped_ptr<google::protobuf::util::TypeResolver>\n      type_resolver_;\n  std::string type_url_;\n};\n\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // CONFORMANCE_CONFORMANCE_TEST_H\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/conformance_test_runner.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file contains a program for running the test suite in a separate\n// process.  The other alternative is to run the suite in-process.  See\n// conformance.proto for pros/cons of these two options.\n//\n// This program will fork the process under test and communicate with it over\n// its stdin/stdout:\n//\n//     +--------+   pipe   +----------+\n//     | tester | <------> | testee   |\n//     |        |          |          |\n//     |  C++   |          | any lang |\n//     +--------+          +----------+\n//\n// The tester contains all of the test cases and their expected output.\n// The testee is a simple program written in the target language that reads\n// each test case and attempts to produce acceptable output for it.\n//\n// Every test consists of a ConformanceRequest/ConformanceResponse\n// request/reply pair.  The protocol on the pipe is simply:\n//\n//   1. tester sends 4-byte length N (little endian)\n//   2. tester sends N bytes representing a ConformanceRequest proto\n//   3. testee sends 4-byte length M (little endian)\n//   4. testee sends M bytes representing a ConformanceResponse proto\n\n#include <algorithm>\n#include <errno.h>\n#include <fstream>\n#include <sys/types.h>\n#include <sys/wait.h>\n#include <unistd.h>\n#include <vector>\n\n#include <google/protobuf/stubs/stringprintf.h>\n\n#include \"conformance.pb.h\"\n#include \"conformance_test.h\"\n\nusing conformance::ConformanceRequest;\nusing conformance::ConformanceResponse;\nusing google::protobuf::internal::scoped_array;\nusing google::protobuf::StringAppendF;\nusing std::string;\nusing std::vector;\n\n#define STRINGIFY(x) #x\n#define TOSTRING(x) STRINGIFY(x)\n#define CHECK_SYSCALL(call) \\\n  if (call < 0) { \\\n    perror(#call \" \" __FILE__ \":\" TOSTRING(__LINE__)); \\\n    exit(1); \\\n  }\n\n// Test runner that spawns the process being tested and communicates with it\n// over a pipe.\nclass ForkPipeRunner : public google::protobuf::ConformanceTestRunner {\n public:\n  ForkPipeRunner(const std::string &executable)\n      : child_pid_(-1), executable_(executable) {}\n\n  virtual ~ForkPipeRunner() {}\n\n  void RunTest(const std::string& test_name,\n               const std::string& request,\n               std::string* response) {\n    if (child_pid_ < 0) {\n      SpawnTestProgram();\n    }\n\n    current_test_name_ = test_name;\n\n    uint32_t len = request.size();\n    CheckedWrite(write_fd_, &len, sizeof(uint32_t));\n    CheckedWrite(write_fd_, request.c_str(), request.size());\n\n    if (!TryRead(read_fd_, &len, sizeof(uint32_t))) {\n      // We failed to read from the child, assume a crash and try to reap.\n      GOOGLE_LOG(INFO) << \"Trying to reap child, pid=\" << child_pid_;\n\n      int status;\n      waitpid(child_pid_, &status, WEXITED);\n\n      string error_msg;\n      if (WIFEXITED(status)) {\n        StringAppendF(&error_msg,\n                      \"child exited, status=%d\", WEXITSTATUS(status));\n      } else if (WIFSIGNALED(status)) {\n        StringAppendF(&error_msg,\n                      \"child killed by signal %d\", WTERMSIG(status));\n      }\n      GOOGLE_LOG(INFO) << error_msg;\n      child_pid_ = -1;\n\n      conformance::ConformanceResponse response_obj;\n      response_obj.set_runtime_error(error_msg);\n      response_obj.SerializeToString(response);\n      return;\n    }\n\n    response->resize(len);\n    CheckedRead(read_fd_, (void*)response->c_str(), len);\n  }\n\n private:\n  // TODO(haberman): make this work on Windows, instead of using these\n  // UNIX-specific APIs.\n  //\n  // There is a platform-agnostic API in\n  //    src/google/protobuf/compiler/subprocess.h\n  //\n  // However that API only supports sending a single message to the subprocess.\n  // We really want to be able to send messages and receive responses one at a\n  // time:\n  //\n  // 1. Spawning a new process for each test would take way too long for thousands\n  //    of tests and subprocesses like java that can take 100ms or more to start\n  //    up.\n  //\n  // 2. Sending all the tests in one big message and receiving all results in one\n  //    big message would take away our visibility about which test(s) caused a\n  //    crash or other fatal error.  It would also give us only a single failure\n  //    instead of all of them.\n  void SpawnTestProgram() {\n    int toproc_pipe_fd[2];\n    int fromproc_pipe_fd[2];\n    if (pipe(toproc_pipe_fd) < 0 || pipe(fromproc_pipe_fd) < 0) {\n      perror(\"pipe\");\n      exit(1);\n    }\n\n    pid_t pid = fork();\n    if (pid < 0) {\n      perror(\"fork\");\n      exit(1);\n    }\n\n    if (pid) {\n      // Parent.\n      CHECK_SYSCALL(close(toproc_pipe_fd[0]));\n      CHECK_SYSCALL(close(fromproc_pipe_fd[1]));\n      write_fd_ = toproc_pipe_fd[1];\n      read_fd_ = fromproc_pipe_fd[0];\n      child_pid_ = pid;\n    } else {\n      // Child.\n      CHECK_SYSCALL(close(STDIN_FILENO));\n      CHECK_SYSCALL(close(STDOUT_FILENO));\n      CHECK_SYSCALL(dup2(toproc_pipe_fd[0], STDIN_FILENO));\n      CHECK_SYSCALL(dup2(fromproc_pipe_fd[1], STDOUT_FILENO));\n\n      CHECK_SYSCALL(close(toproc_pipe_fd[0]));\n      CHECK_SYSCALL(close(fromproc_pipe_fd[1]));\n      CHECK_SYSCALL(close(toproc_pipe_fd[1]));\n      CHECK_SYSCALL(close(fromproc_pipe_fd[0]));\n\n      scoped_array<char> executable(new char[executable_.size() + 1]);\n      memcpy(executable.get(), executable_.c_str(), executable_.size());\n      executable[executable_.size()] = '\\0';\n\n      char *const argv[] = {executable.get(), NULL};\n      CHECK_SYSCALL(execv(executable.get(), argv));  // Never returns.\n    }\n  }\n\n  void CheckedWrite(int fd, const void *buf, size_t len) {\n    if (write(fd, buf, len) != len) {\n      GOOGLE_LOG(FATAL) << current_test_name_\n                        << \": error writing to test program: \"\n                        << strerror(errno);\n    }\n  }\n\n  bool TryRead(int fd, void *buf, size_t len) {\n    size_t ofs = 0;\n    while (len > 0) {\n      ssize_t bytes_read = read(fd, (char*)buf + ofs, len);\n\n      if (bytes_read == 0) {\n        GOOGLE_LOG(ERROR) << current_test_name_\n                          << \": unexpected EOF from test program\";\n        return false;\n      } else if (bytes_read < 0) {\n        GOOGLE_LOG(ERROR) << current_test_name_\n                          << \": error reading from test program: \"\n                          << strerror(errno);\n        return false;\n      }\n\n      len -= bytes_read;\n      ofs += bytes_read;\n    }\n\n    return true;\n  }\n\n  void CheckedRead(int fd, void *buf, size_t len) {\n    if (!TryRead(fd, buf, len)) {\n      GOOGLE_LOG(FATAL) << current_test_name_\n                        << \": error reading from test program: \"\n                        << strerror(errno);\n    }\n  }\n\n  int write_fd_;\n  int read_fd_;\n  pid_t child_pid_;\n  std::string executable_;\n  std::string current_test_name_;\n};\n\nvoid UsageError() {\n  fprintf(stderr,\n          \"Usage: conformance-test-runner [options] <test-program>\\n\");\n  fprintf(stderr, \"\\n\");\n  fprintf(stderr, \"Options:\\n\");\n  fprintf(stderr,\n          \"  --failure_list <filename>   Use to specify list of tests\\n\");\n  fprintf(stderr,\n          \"                              that are expected to fail.  File\\n\");\n  fprintf(stderr,\n          \"                              should contain one test name per\\n\");\n  fprintf(stderr,\n          \"                              line.  Use '#' for comments.\\n\");\n  exit(1);\n}\n\nvoid ParseFailureList(const char *filename, vector<string>* failure_list) {\n  std::ifstream infile(filename);\n\n  if (!infile.is_open()) {\n    fprintf(stderr, \"Couldn't open failure list file: %s\\n\", filename);\n    exit(1);\n  }\n\n  for (string line; getline(infile, line);) {\n    // Remove whitespace.\n    line.erase(std::remove_if(line.begin(), line.end(), ::isspace),\n               line.end());\n\n    // Remove comments.\n    line = line.substr(0, line.find(\"#\"));\n\n    if (!line.empty()) {\n      failure_list->push_back(line);\n    }\n  }\n}\n\nint main(int argc, char *argv[]) {\n  char *program;\n  google::protobuf::ConformanceTestSuite suite;\n\n  string failure_list_filename;\n  vector<string> failure_list;\n\n  for (int arg = 1; arg < argc; ++arg) {\n    if (strcmp(argv[arg], \"--failure_list\") == 0) {\n      if (++arg == argc) UsageError();\n      failure_list_filename = argv[arg];\n      ParseFailureList(argv[arg], &failure_list);\n    } else if (strcmp(argv[arg], \"--verbose\") == 0) {\n      suite.SetVerbose(true);\n    } else if (argv[arg][0] == '-') {\n      fprintf(stderr, \"Unknown option: %s\\n\", argv[arg]);\n      UsageError();\n    } else {\n      if (arg != argc - 1) {\n        fprintf(stderr, \"Too many arguments.\\n\");\n        UsageError();\n      }\n      program = argv[arg];\n    }\n  }\n\n  suite.SetFailureList(failure_list_filename, failure_list);\n  ForkPipeRunner runner(program);\n\n  std::string output;\n  bool ok = suite.RunSuite(&runner, &output);\n\n  fwrite(output.c_str(), 1, output.size(), stderr);\n\n  return ok ? EXIT_SUCCESS : EXIT_FAILURE;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/failure_list_cpp.txt",
    "content": "# This is the list of conformance tests that are known to fail for the C++\r\n# implementation right now.  These should be fixed.\r\n#\r\n# By listing them here we can keep tabs on which ones are failing and be sure\r\n# that we don't introduce regressions in other tests.\r\n#\r\n# TODO(haberman): insert links to corresponding bugs tracking the issue.\r\n# Should we use GitHub issues or the Google-internal bug tracker?\r\n\r\nFieldMaskNumbersDontRoundTrip.JsonOutput\r\nFieldMaskPathsDontRoundTrip.JsonOutput\r\nFieldMaskTooManyUnderscore.JsonOutput\r\nJsonInput.AnyUnorderedTypeTag.JsonOutput\r\nJsonInput.AnyUnorderedTypeTag.ProtobufOutput\r\nJsonInput.BoolFieldDoubleQuotedFalse\r\nJsonInput.BoolFieldDoubleQuotedTrue\r\nJsonInput.BytesFieldNoPadding\r\nJsonInput.DoubleFieldTooSmall\r\nJsonInput.DurationHasZeroFractionalDigit.Validator\r\nJsonInput.EnumFieldUnknownValue.Validator\r\nJsonInput.FieldMaskInvalidCharacter\r\nJsonInput.FieldNameDuplicate\r\nJsonInput.FieldNameDuplicateDifferentCasing1\r\nJsonInput.FieldNameDuplicateDifferentCasing2\r\nJsonInput.FieldNameInLowerCamelCase.Validator\r\nJsonInput.FieldNameInSnakeCase.JsonOutput\r\nJsonInput.FieldNameInSnakeCase.ProtobufOutput\r\nJsonInput.FieldNameNotQuoted\r\nJsonInput.MapFieldValueIsNull\r\nJsonInput.RepeatedFieldMessageElementIsNull\r\nJsonInput.RepeatedFieldPrimitiveElementIsNull\r\nJsonInput.RepeatedFieldTrailingComma\r\nJsonInput.StringFieldUppercaseEscapeLetter\r\nJsonInput.TrailingCommaInAnObject\r\nJsonInput.WrapperTypesWithNullValue.JsonOutput\r\nJsonInput.WrapperTypesWithNullValue.ProtobufOutput\r\nProtobufInput.PrematureEofBeforeKnownRepeatedValue.MESSAGE\r\nProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE\r\nProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE\r\nProtobufInput.PrematureEofInPackedField.BOOL\r\nProtobufInput.PrematureEofInPackedField.ENUM\r\nProtobufInput.PrematureEofInPackedField.INT32\r\nProtobufInput.PrematureEofInPackedField.INT64\r\nProtobufInput.PrematureEofInPackedField.SINT32\r\nProtobufInput.PrematureEofInPackedField.SINT64\r\nProtobufInput.PrematureEofInPackedField.UINT32\r\nProtobufInput.PrematureEofInPackedField.UINT64\r\nProtobufInput.PrematureEofInsideKnownRepeatedValue.MESSAGE\r\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/failure_list_csharp.txt",
    "content": "JsonInput.FieldNameInLowerCamelCase.Validator\r\nJsonInput.FieldNameInSnakeCase.JsonOutput\r\nJsonInput.FieldNameInSnakeCase.ProtobufOutput\r\nJsonInput.FieldNameWithMixedCases.JsonOutput\r\nJsonInput.FieldNameWithMixedCases.ProtobufOutput\r\nJsonInput.FieldNameWithMixedCases.Validator\r\nJsonInput.Int64FieldMaxValueNotQuoted.JsonOutput\r\nJsonInput.Int64FieldMaxValueNotQuoted.ProtobufOutput\r\nJsonInput.OriginalProtoFieldName.JsonOutput\r\nJsonInput.Uint64FieldMaxValueNotQuoted.JsonOutput\r\nJsonInput.Uint64FieldMaxValueNotQuoted.ProtobufOutput\r\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/failure_list_java.txt",
    "content": "# This is the list of conformance tests that are known to fail for the Java\r\n# implementation right now.  These should be fixed.\r\n#\r\n# By listing them here we can keep tabs on which ones are failing and be sure\r\n# that we don't introduce regressions in other tests.\r\n\r\nFieldMaskNumbersDontRoundTrip.JsonOutput\r\nFieldMaskPathsDontRoundTrip.JsonOutput\r\nFieldMaskTooManyUnderscore.JsonOutput\r\nJsonInput.BoolFieldAllCapitalFalse\r\nJsonInput.BoolFieldAllCapitalTrue\r\nJsonInput.BoolFieldCamelCaseFalse\r\nJsonInput.BoolFieldCamelCaseTrue\r\nJsonInput.BoolFieldDoubleQuotedFalse\r\nJsonInput.BoolFieldDoubleQuotedTrue\r\nJsonInput.BoolMapFieldKeyNotQuoted\r\nJsonInput.DoubleFieldInfinityNotQuoted\r\nJsonInput.DoubleFieldNanNotQuoted\r\nJsonInput.DoubleFieldNegativeInfinityNotQuoted\r\nJsonInput.EnumFieldNotQuoted\r\nJsonInput.FieldMaskInvalidCharacter\r\nJsonInput.FieldNameDuplicate\r\nJsonInput.FieldNameInSnakeCase.JsonOutput\r\nJsonInput.FieldNameNotQuoted\r\nJsonInput.FloatFieldInfinityNotQuoted\r\nJsonInput.FloatFieldNanNotQuoted\r\nJsonInput.FloatFieldNegativeInfinityNotQuoted\r\nJsonInput.Int32FieldLeadingZero\r\nJsonInput.Int32FieldNegativeWithLeadingZero\r\nJsonInput.Int32FieldPlusSign\r\nJsonInput.Int32MapFieldKeyNotQuoted\r\nJsonInput.Int64MapFieldKeyNotQuoted\r\nJsonInput.JsonWithComments\r\nJsonInput.OriginalProtoFieldName.JsonOutput\r\nJsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool\r\nJsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt\r\nJsonInput.StringFieldNotAString\r\nJsonInput.StringFieldSurrogateInWrongOrder\r\nJsonInput.StringFieldUnpairedHighSurrogate\r\nJsonInput.StringFieldUnpairedLowSurrogate\r\nJsonInput.StringFieldUppercaseEscapeLetter\r\nJsonInput.Uint32MapFieldKeyNotQuoted\r\nJsonInput.Uint64MapFieldKeyNotQuoted\r\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/failure_list_objc.txt",
    "content": "# No tests currently failing.\r\n#\r\n# json input or output tests are skipped (in conformance_objc.m) as mobile\r\n# platforms don't support json wire format to avoid code bloat.\r\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/failure_list_python-post26.txt",
    "content": "JsonInput.StringFieldSurrogateInWrongOrder\r\nJsonInput.StringFieldUnpairedHighSurrogate\r\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/failure_list_python.txt",
    "content": "DurationProtoInputTooLarge.JsonOutput\r\nDurationProtoInputTooSmall.JsonOutput\r\nFieldMaskNumbersDontRoundTrip.JsonOutput\r\nFieldMaskPathsDontRoundTrip.JsonOutput\r\nFieldMaskTooManyUnderscore.JsonOutput\r\nJsonInput.AnyWithFieldMask.ProtobufOutput\r\nJsonInput.BytesFieldInvalidBase64Characters\r\nJsonInput.DoubleFieldInfinityNotQuoted\r\nJsonInput.DoubleFieldNanNotQuoted\r\nJsonInput.DoubleFieldNegativeInfinityNotQuoted\r\nJsonInput.DoubleFieldTooSmall\r\nJsonInput.DurationJsonInputTooLarge\r\nJsonInput.DurationJsonInputTooSmall\r\nJsonInput.DurationMissingS\r\nJsonInput.EnumFieldNumericValueNonZero.JsonOutput\r\nJsonInput.EnumFieldNumericValueNonZero.ProtobufOutput\r\nJsonInput.EnumFieldNumericValueZero.JsonOutput\r\nJsonInput.EnumFieldNumericValueZero.ProtobufOutput\r\nJsonInput.EnumFieldUnknownValue.Validator\r\nJsonInput.FieldMask.ProtobufOutput\r\nJsonInput.FieldMaskInvalidCharacter\r\nJsonInput.FieldNameInLowerCamelCase.Validator\r\nJsonInput.FieldNameInSnakeCase.JsonOutput\r\nJsonInput.FieldNameInSnakeCase.ProtobufOutput\r\nJsonInput.FloatFieldInfinityNotQuoted\r\nJsonInput.FloatFieldNanNotQuoted\r\nJsonInput.FloatFieldNegativeInfinityNotQuoted\r\nJsonInput.FloatFieldTooLarge\r\nJsonInput.FloatFieldTooSmall\r\nJsonInput.Int32FieldExponentialFormat.JsonOutput\r\nJsonInput.Int32FieldExponentialFormat.ProtobufOutput\r\nJsonInput.Int32FieldFloatTrailingZero.JsonOutput\r\nJsonInput.Int32FieldFloatTrailingZero.ProtobufOutput\r\nJsonInput.Int32FieldMaxFloatValue.JsonOutput\r\nJsonInput.Int32FieldMaxFloatValue.ProtobufOutput\r\nJsonInput.Int32FieldMinFloatValue.JsonOutput\r\nJsonInput.Int32FieldMinFloatValue.ProtobufOutput\r\nJsonInput.OriginalProtoFieldName.JsonOutput\r\nJsonInput.OriginalProtoFieldName.ProtobufOutput\r\nJsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool\r\nJsonInput.TimestampJsonInputLowercaseT\r\nJsonInput.Uint32FieldMaxFloatValue.JsonOutput\r\nJsonInput.Uint32FieldMaxFloatValue.ProtobufOutput\r\nJsonInput.ValueAcceptNull.JsonOutput\r\nJsonInput.ValueAcceptNull.ProtobufOutput\r\nTimestampProtoInputTooLarge.JsonOutput\r\nTimestampProtoInputTooSmall.JsonOutput\r\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/failure_list_python_cpp.txt",
    "content": "# This is the list of conformance tests that are known to fail for the\r\n# Python/C++ implementation right now.  These should be fixed.\r\n#\r\n# By listing them here we can keep tabs on which ones are failing and be sure\r\n# that we don't introduce regressions in other tests.\r\n#\r\n# TODO(haberman): insert links to corresponding bugs tracking the issue.\r\n# Should we use GitHub issues or the Google-internal bug tracker?\r\n\r\nDurationProtoInputTooLarge.JsonOutput\r\nDurationProtoInputTooSmall.JsonOutput\r\nFieldMaskNumbersDontRoundTrip.JsonOutput\r\nFieldMaskPathsDontRoundTrip.JsonOutput\r\nFieldMaskTooManyUnderscore.JsonOutput\r\nJsonInput.AnyWithFieldMask.ProtobufOutput\r\nJsonInput.BytesFieldInvalidBase64Characters\r\nJsonInput.DoubleFieldInfinityNotQuoted\r\nJsonInput.DoubleFieldNanNotQuoted\r\nJsonInput.DoubleFieldNegativeInfinityNotQuoted\r\nJsonInput.DoubleFieldTooSmall\r\nJsonInput.DurationJsonInputTooLarge\r\nJsonInput.DurationJsonInputTooSmall\r\nJsonInput.DurationMissingS\r\nJsonInput.EnumFieldNumericValueNonZero.JsonOutput\r\nJsonInput.EnumFieldNumericValueNonZero.ProtobufOutput\r\nJsonInput.EnumFieldNumericValueZero.JsonOutput\r\nJsonInput.EnumFieldNumericValueZero.ProtobufOutput\r\nJsonInput.EnumFieldUnknownValue.Validator\r\nJsonInput.FieldMask.ProtobufOutput\r\nJsonInput.FieldMaskInvalidCharacter\r\nJsonInput.FieldNameInLowerCamelCase.Validator\r\nJsonInput.FieldNameInSnakeCase.JsonOutput\r\nJsonInput.FieldNameInSnakeCase.ProtobufOutput\r\nJsonInput.FloatFieldInfinityNotQuoted\r\nJsonInput.FloatFieldNanNotQuoted\r\nJsonInput.FloatFieldNegativeInfinityNotQuoted\r\nJsonInput.FloatFieldTooLarge\r\nJsonInput.FloatFieldTooSmall\r\nJsonInput.Int32FieldExponentialFormat.JsonOutput\r\nJsonInput.Int32FieldExponentialFormat.ProtobufOutput\r\nJsonInput.Int32FieldFloatTrailingZero.JsonOutput\r\nJsonInput.Int32FieldFloatTrailingZero.ProtobufOutput\r\nJsonInput.Int32FieldMaxFloatValue.JsonOutput\r\nJsonInput.Int32FieldMaxFloatValue.ProtobufOutput\r\nJsonInput.Int32FieldMinFloatValue.JsonOutput\r\nJsonInput.Int32FieldMinFloatValue.ProtobufOutput\r\nJsonInput.OriginalProtoFieldName.JsonOutput\r\nJsonInput.OriginalProtoFieldName.ProtobufOutput\r\nJsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool\r\nJsonInput.TimestampJsonInputLowercaseT\r\nJsonInput.Uint32FieldMaxFloatValue.JsonOutput\r\nJsonInput.Uint32FieldMaxFloatValue.ProtobufOutput\r\nJsonInput.ValueAcceptNull.JsonOutput\r\nJsonInput.ValueAcceptNull.ProtobufOutput\r\nProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE\r\nProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE\r\nProtobufInput.PrematureEofInPackedField.BOOL\r\nProtobufInput.PrematureEofInPackedField.DOUBLE\r\nProtobufInput.PrematureEofInPackedField.ENUM\r\nProtobufInput.PrematureEofInPackedField.FIXED32\r\nProtobufInput.PrematureEofInPackedField.FIXED64\r\nProtobufInput.PrematureEofInPackedField.FLOAT\r\nProtobufInput.PrematureEofInPackedField.INT32\r\nProtobufInput.PrematureEofInPackedField.INT64\r\nProtobufInput.PrematureEofInPackedField.SFIXED32\r\nProtobufInput.PrematureEofInPackedField.SFIXED64\r\nProtobufInput.PrematureEofInPackedField.SINT32\r\nProtobufInput.PrematureEofInPackedField.SINT64\r\nProtobufInput.PrematureEofInPackedField.UINT32\r\nProtobufInput.PrematureEofInPackedField.UINT64\r\nTimestampProtoInputTooLarge.JsonOutput\r\nTimestampProtoInputTooSmall.JsonOutput\r\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/failure_list_ruby.txt",
    "content": "DurationProtoInputTooLarge.JsonOutput\r\nDurationProtoInputTooSmall.JsonOutput\r\nFieldMaskNumbersDontRoundTrip.JsonOutput\r\nFieldMaskPathsDontRoundTrip.JsonOutput\r\nFieldMaskTooManyUnderscore.JsonOutput\r\nJsonInput.Any.JsonOutput\r\nJsonInput.Any.ProtobufOutput\r\nJsonInput.AnyNested.JsonOutput\r\nJsonInput.AnyNested.ProtobufOutput\r\nJsonInput.AnyUnorderedTypeTag.JsonOutput\r\nJsonInput.AnyUnorderedTypeTag.ProtobufOutput\r\nJsonInput.AnyWithDuration.JsonOutput\r\nJsonInput.AnyWithDuration.ProtobufOutput\r\nJsonInput.AnyWithFieldMask.JsonOutput\r\nJsonInput.AnyWithFieldMask.ProtobufOutput\r\nJsonInput.AnyWithInt32ValueWrapper.JsonOutput\r\nJsonInput.AnyWithInt32ValueWrapper.ProtobufOutput\r\nJsonInput.AnyWithStruct.JsonOutput\r\nJsonInput.AnyWithStruct.ProtobufOutput\r\nJsonInput.AnyWithTimestamp.JsonOutput\r\nJsonInput.AnyWithTimestamp.ProtobufOutput\r\nJsonInput.AnyWithValueForInteger.JsonOutput\r\nJsonInput.AnyWithValueForInteger.ProtobufOutput\r\nJsonInput.AnyWithValueForJsonObject.JsonOutput\r\nJsonInput.AnyWithValueForJsonObject.ProtobufOutput\r\nJsonInput.BoolFieldIntegerOne\r\nJsonInput.BoolFieldIntegerZero\r\nJsonInput.DoubleFieldInfinity.JsonOutput\r\nJsonInput.DoubleFieldInfinity.ProtobufOutput\r\nJsonInput.DoubleFieldMaxNegativeValue.JsonOutput\r\nJsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput\r\nJsonInput.DoubleFieldMaxPositiveValue.JsonOutput\r\nJsonInput.DoubleFieldMaxPositiveValue.ProtobufOutput\r\nJsonInput.DoubleFieldMinNegativeValue.JsonOutput\r\nJsonInput.DoubleFieldMinNegativeValue.ProtobufOutput\r\nJsonInput.DoubleFieldMinPositiveValue.JsonOutput\r\nJsonInput.DoubleFieldMinPositiveValue.ProtobufOutput\r\nJsonInput.DoubleFieldNan.JsonOutput\r\nJsonInput.DoubleFieldNan.ProtobufOutput\r\nJsonInput.DoubleFieldNegativeInfinity.JsonOutput\r\nJsonInput.DoubleFieldNegativeInfinity.ProtobufOutput\r\nJsonInput.DoubleFieldQuotedValue.JsonOutput\r\nJsonInput.DoubleFieldQuotedValue.ProtobufOutput\r\nJsonInput.DurationHas3FractionalDigits.Validator\r\nJsonInput.DurationHas6FractionalDigits.Validator\r\nJsonInput.DurationHas9FractionalDigits.Validator\r\nJsonInput.DurationHasZeroFractionalDigit.Validator\r\nJsonInput.DurationMaxValue.JsonOutput\r\nJsonInput.DurationMaxValue.ProtobufOutput\r\nJsonInput.DurationMinValue.JsonOutput\r\nJsonInput.DurationMinValue.ProtobufOutput\r\nJsonInput.DurationRepeatedValue.JsonOutput\r\nJsonInput.DurationRepeatedValue.ProtobufOutput\r\nJsonInput.EnumFieldNumericValueNonZero.JsonOutput\r\nJsonInput.EnumFieldNumericValueNonZero.ProtobufOutput\r\nJsonInput.EnumFieldNumericValueZero.JsonOutput\r\nJsonInput.EnumFieldNumericValueZero.ProtobufOutput\r\nJsonInput.EnumFieldUnknownValue.Validator\r\nJsonInput.FieldMask.JsonOutput\r\nJsonInput.FieldMask.ProtobufOutput\r\nJsonInput.FieldNameInSnakeCase.JsonOutput\r\nJsonInput.FieldNameWithMixedCases.JsonOutput\r\nJsonInput.FieldNameWithMixedCases.ProtobufOutput\r\nJsonInput.FieldNameWithMixedCases.Validator\r\nJsonInput.FloatFieldInfinity.JsonOutput\r\nJsonInput.FloatFieldInfinity.ProtobufOutput\r\nJsonInput.FloatFieldNan.JsonOutput\r\nJsonInput.FloatFieldNan.ProtobufOutput\r\nJsonInput.FloatFieldNegativeInfinity.JsonOutput\r\nJsonInput.FloatFieldNegativeInfinity.ProtobufOutput\r\nJsonInput.FloatFieldQuotedValue.JsonOutput\r\nJsonInput.FloatFieldQuotedValue.ProtobufOutput\r\nJsonInput.FloatFieldTooLarge\r\nJsonInput.FloatFieldTooSmall\r\nJsonInput.Int32FieldExponentialFormat.JsonOutput\r\nJsonInput.Int32FieldExponentialFormat.ProtobufOutput\r\nJsonInput.Int32FieldFloatTrailingZero.JsonOutput\r\nJsonInput.Int32FieldFloatTrailingZero.ProtobufOutput\r\nJsonInput.Int32FieldMaxFloatValue.JsonOutput\r\nJsonInput.Int32FieldMaxFloatValue.ProtobufOutput\r\nJsonInput.Int32FieldMinFloatValue.JsonOutput\r\nJsonInput.Int32FieldMinFloatValue.ProtobufOutput\r\nJsonInput.Int32FieldStringValue.JsonOutput\r\nJsonInput.Int32FieldStringValue.ProtobufOutput\r\nJsonInput.Int32FieldStringValueEscaped.JsonOutput\r\nJsonInput.Int32FieldStringValueEscaped.ProtobufOutput\r\nJsonInput.Int32MapEscapedKey.JsonOutput\r\nJsonInput.Int32MapEscapedKey.ProtobufOutput\r\nJsonInput.Int32MapField.JsonOutput\r\nJsonInput.Int32MapField.ProtobufOutput\r\nJsonInput.Int64FieldBeString.Validator\r\nJsonInput.Int64FieldMaxValue.JsonOutput\r\nJsonInput.Int64FieldMaxValue.ProtobufOutput\r\nJsonInput.Int64FieldMinValue.JsonOutput\r\nJsonInput.Int64FieldMinValue.ProtobufOutput\r\nJsonInput.Int64MapEscapedKey.JsonOutput\r\nJsonInput.Int64MapEscapedKey.ProtobufOutput\r\nJsonInput.Int64MapField.JsonOutput\r\nJsonInput.Int64MapField.ProtobufOutput\r\nJsonInput.MessageField.JsonOutput\r\nJsonInput.MessageField.ProtobufOutput\r\nJsonInput.MessageMapField.JsonOutput\r\nJsonInput.MessageMapField.ProtobufOutput\r\nJsonInput.MessageRepeatedField.JsonOutput\r\nJsonInput.MessageRepeatedField.ProtobufOutput\r\nJsonInput.OptionalBoolWrapper.JsonOutput\r\nJsonInput.OptionalBoolWrapper.ProtobufOutput\r\nJsonInput.OptionalBytesWrapper.JsonOutput\r\nJsonInput.OptionalBytesWrapper.ProtobufOutput\r\nJsonInput.OptionalDoubleWrapper.JsonOutput\r\nJsonInput.OptionalDoubleWrapper.ProtobufOutput\r\nJsonInput.OptionalFloatWrapper.JsonOutput\r\nJsonInput.OptionalFloatWrapper.ProtobufOutput\r\nJsonInput.OptionalInt32Wrapper.JsonOutput\r\nJsonInput.OptionalInt32Wrapper.ProtobufOutput\r\nJsonInput.OptionalInt64Wrapper.JsonOutput\r\nJsonInput.OptionalInt64Wrapper.ProtobufOutput\r\nJsonInput.OptionalStringWrapper.JsonOutput\r\nJsonInput.OptionalStringWrapper.ProtobufOutput\r\nJsonInput.OptionalUint32Wrapper.JsonOutput\r\nJsonInput.OptionalUint32Wrapper.ProtobufOutput\r\nJsonInput.OptionalUint64Wrapper.JsonOutput\r\nJsonInput.OptionalUint64Wrapper.ProtobufOutput\r\nJsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput\r\nJsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput\r\nJsonInput.OriginalProtoFieldName.JsonOutput\r\nJsonInput.PrimitiveRepeatedField.JsonOutput\r\nJsonInput.PrimitiveRepeatedField.ProtobufOutput\r\nJsonInput.RepeatedBoolWrapper.JsonOutput\r\nJsonInput.RepeatedBoolWrapper.ProtobufOutput\r\nJsonInput.RepeatedBytesWrapper.JsonOutput\r\nJsonInput.RepeatedBytesWrapper.ProtobufOutput\r\nJsonInput.RepeatedDoubleWrapper.JsonOutput\r\nJsonInput.RepeatedDoubleWrapper.ProtobufOutput\r\nJsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt\r\nJsonInput.RepeatedFloatWrapper.JsonOutput\r\nJsonInput.RepeatedFloatWrapper.ProtobufOutput\r\nJsonInput.RepeatedInt32Wrapper.JsonOutput\r\nJsonInput.RepeatedInt32Wrapper.ProtobufOutput\r\nJsonInput.RepeatedInt64Wrapper.JsonOutput\r\nJsonInput.RepeatedInt64Wrapper.ProtobufOutput\r\nJsonInput.RepeatedStringWrapper.JsonOutput\r\nJsonInput.RepeatedStringWrapper.ProtobufOutput\r\nJsonInput.RepeatedUint32Wrapper.JsonOutput\r\nJsonInput.RepeatedUint32Wrapper.ProtobufOutput\r\nJsonInput.RepeatedUint64Wrapper.JsonOutput\r\nJsonInput.RepeatedUint64Wrapper.ProtobufOutput\r\nJsonInput.StringFieldNotAString\r\nJsonInput.StringFieldSurrogateInWrongOrder\r\nJsonInput.StringFieldSurrogatePair.JsonOutput\r\nJsonInput.StringFieldSurrogatePair.ProtobufOutput\r\nJsonInput.StringFieldUnpairedHighSurrogate\r\nJsonInput.StringFieldUnpairedLowSurrogate\r\nJsonInput.Struct.JsonOutput\r\nJsonInput.Struct.ProtobufOutput\r\nJsonInput.TimestampHas3FractionalDigits.Validator\r\nJsonInput.TimestampHas6FractionalDigits.Validator\r\nJsonInput.TimestampHas9FractionalDigits.Validator\r\nJsonInput.TimestampHasZeroFractionalDigit.Validator\r\nJsonInput.TimestampMaxValue.JsonOutput\r\nJsonInput.TimestampMaxValue.ProtobufOutput\r\nJsonInput.TimestampMinValue.JsonOutput\r\nJsonInput.TimestampMinValue.ProtobufOutput\r\nJsonInput.TimestampRepeatedValue.JsonOutput\r\nJsonInput.TimestampRepeatedValue.ProtobufOutput\r\nJsonInput.TimestampWithNegativeOffset.JsonOutput\r\nJsonInput.TimestampWithNegativeOffset.ProtobufOutput\r\nJsonInput.TimestampWithPositiveOffset.JsonOutput\r\nJsonInput.TimestampWithPositiveOffset.ProtobufOutput\r\nJsonInput.TimestampZeroNormalized.Validator\r\nJsonInput.Uint32FieldMaxFloatValue.JsonOutput\r\nJsonInput.Uint32FieldMaxFloatValue.ProtobufOutput\r\nJsonInput.Uint32MapField.JsonOutput\r\nJsonInput.Uint32MapField.ProtobufOutput\r\nJsonInput.Uint64FieldBeString.Validator\r\nJsonInput.Uint64FieldMaxValue.JsonOutput\r\nJsonInput.Uint64FieldMaxValue.ProtobufOutput\r\nJsonInput.Uint64MapField.JsonOutput\r\nJsonInput.Uint64MapField.ProtobufOutput\r\nJsonInput.ValueAcceptBool.JsonOutput\r\nJsonInput.ValueAcceptBool.ProtobufOutput\r\nJsonInput.ValueAcceptFloat.JsonOutput\r\nJsonInput.ValueAcceptFloat.ProtobufOutput\r\nJsonInput.ValueAcceptInteger.JsonOutput\r\nJsonInput.ValueAcceptInteger.ProtobufOutput\r\nJsonInput.ValueAcceptList.JsonOutput\r\nJsonInput.ValueAcceptList.ProtobufOutput\r\nJsonInput.ValueAcceptNull.JsonOutput\r\nJsonInput.ValueAcceptNull.ProtobufOutput\r\nJsonInput.ValueAcceptObject.JsonOutput\r\nJsonInput.ValueAcceptObject.ProtobufOutput\r\nJsonInput.ValueAcceptString.JsonOutput\r\nJsonInput.ValueAcceptString.ProtobufOutput\r\nProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput\r\nProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput\r\nProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput\r\nProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput\r\nTimestampProtoInputTooLarge.JsonOutput\r\nTimestampProtoInputTooSmall.JsonOutput\r\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/third_party/jsoncpp/json.h",
    "content": "/// Json-cpp amalgated header (http://jsoncpp.sourceforge.net/).\n/// It is intended to be used with #include \"json/json.h\"\n\n// //////////////////////////////////////////////////////////////////////\n// Beginning of content of file: LICENSE\n// //////////////////////////////////////////////////////////////////////\n\n/*\nThe JsonCpp library's source code, including accompanying documentation, \ntests and demonstration applications, are licensed under the following\nconditions...\n\nThe author (Baptiste Lepilleur) explicitly disclaims copyright in all \njurisdictions which recognize such a disclaimer. In such jurisdictions, \nthis software is released into the Public Domain.\n\nIn jurisdictions which do not recognize Public Domain property (e.g. Germany as of\n2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is\nreleased under the terms of the MIT License (see below).\n\nIn jurisdictions which recognize Public Domain property, the user of this \nsoftware may choose to accept it either as 1) Public Domain, 2) under the \nconditions of the MIT License (see below), or 3) under the terms of dual \nPublic Domain/MIT License conditions described here, as they choose.\n\nThe MIT License is about as close to Public Domain as a license can get, and is\ndescribed in clear, concise terms at:\n\n   http://en.wikipedia.org/wiki/MIT_License\n   \nThe full text of the MIT License follows:\n\n========================================================================\nCopyright (c) 2007-2010 Baptiste Lepilleur\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the \"Software\"), to deal in the Software without\nrestriction, including without limitation the rights to use, copy,\nmodify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\nBE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\nACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n========================================================================\n(END LICENSE TEXT)\n\nThe MIT license is compatible with both the GPL and commercial\nsoftware, affording one all of the rights of Public Domain with the\nminor nuisance of being required to keep the above copyright notice\nand license text in the source code. Note also that by accepting the\nPublic Domain \"license\" you can re-license your copy using whatever\nlicense you like.\n\n*/\n\n// //////////////////////////////////////////////////////////////////////\n// End of content of file: LICENSE\n// //////////////////////////////////////////////////////////////////////\n\n\n\n\n\n#ifndef JSON_AMALGATED_H_INCLUDED\n# define JSON_AMALGATED_H_INCLUDED\n/// If defined, indicates that the source file is amalgated\n/// to prevent private header inclusion.\n#define JSON_IS_AMALGAMATION\n\n// //////////////////////////////////////////////////////////////////////\n// Beginning of content of file: include/json/version.h\n// //////////////////////////////////////////////////////////////////////\n\n// DO NOT EDIT. This file (and \"version\") is generated by CMake.\n// Run CMake configure step to update it.\n#ifndef JSON_VERSION_H_INCLUDED\n# define JSON_VERSION_H_INCLUDED\n\n# define JSONCPP_VERSION_STRING \"1.6.5\"\n# define JSONCPP_VERSION_MAJOR 1\n# define JSONCPP_VERSION_MINOR 6\n# define JSONCPP_VERSION_PATCH 5\n# define JSONCPP_VERSION_QUALIFIER\n# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))\n\n#endif // JSON_VERSION_H_INCLUDED\n\n// //////////////////////////////////////////////////////////////////////\n// End of content of file: include/json/version.h\n// //////////////////////////////////////////////////////////////////////\n\n\n\n\n\n\n// //////////////////////////////////////////////////////////////////////\n// Beginning of content of file: include/json/config.h\n// //////////////////////////////////////////////////////////////////////\n\n// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_CONFIG_H_INCLUDED\n#define JSON_CONFIG_H_INCLUDED\n\n/// If defined, indicates that json library is embedded in CppTL library.\n//# define JSON_IN_CPPTL 1\n\n/// If defined, indicates that json may leverage CppTL library\n//#  define JSON_USE_CPPTL 1\n/// If defined, indicates that cpptl vector based map should be used instead of\n/// std::map\n/// as Value container.\n//#  define JSON_USE_CPPTL_SMALLMAP 1\n\n// If non-zero, the library uses exceptions to report bad input instead of C\n// assertion macros. The default is to use exceptions.\n#ifndef JSON_USE_EXCEPTION\n#define JSON_USE_EXCEPTION 1\n#endif\n\n/// If defined, indicates that the source file is amalgated\n/// to prevent private header inclusion.\n/// Remarks: it is automatically defined in the generated amalgated header.\n// #define JSON_IS_AMALGAMATION\n\n#ifdef JSON_IN_CPPTL\n#include <cpptl/config.h>\n#ifndef JSON_USE_CPPTL\n#define JSON_USE_CPPTL 1\n#endif\n#endif\n\n#ifdef JSON_IN_CPPTL\n#define JSON_API CPPTL_API\n#elif defined(JSON_DLL_BUILD)\n#if defined(_MSC_VER)\n#define JSON_API __declspec(dllexport)\n#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING\n#endif // if defined(_MSC_VER)\n#elif defined(JSON_DLL)\n#if defined(_MSC_VER)\n#define JSON_API __declspec(dllimport)\n#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING\n#endif // if defined(_MSC_VER)\n#endif // ifdef JSON_IN_CPPTL\n#if !defined(JSON_API)\n#define JSON_API\n#endif\n\n// If JSON_NO_INT64 is defined, then Json only support C++ \"int\" type for\n// integer\n// Storages, and 64 bits integer support is disabled.\n// #define JSON_NO_INT64 1\n\n#if defined(_MSC_VER) // MSVC\n#  if _MSC_VER <= 1200 // MSVC 6\n    // Microsoft Visual Studio 6 only support conversion from __int64 to double\n    // (no conversion from unsigned __int64).\n#    define JSON_USE_INT64_DOUBLE_CONVERSION 1\n    // Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'\n    // characters in the debug information)\n    // All projects I've ever seen with VS6 were using this globally (not bothering\n    // with pragma push/pop).\n#    pragma warning(disable : 4786)\n#  endif // MSVC 6\n\n#  if _MSC_VER >= 1500 // MSVC 2008\n    /// Indicates that the following function is deprecated.\n#    define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))\n#  endif\n\n#endif // defined(_MSC_VER)\n\n\n#ifndef JSON_HAS_RVALUE_REFERENCES\n\n#if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010\n#define JSON_HAS_RVALUE_REFERENCES 1\n#endif // MSVC >= 2010\n\n#ifdef __clang__\n#if __has_feature(cxx_rvalue_references)\n#define JSON_HAS_RVALUE_REFERENCES 1\n#endif  // has_feature\n\n#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)\n#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)\n#define JSON_HAS_RVALUE_REFERENCES 1\n#endif  // GXX_EXPERIMENTAL\n\n#endif // __clang__ || __GNUC__\n\n#endif // not defined JSON_HAS_RVALUE_REFERENCES\n\n#ifndef JSON_HAS_RVALUE_REFERENCES\n#define JSON_HAS_RVALUE_REFERENCES 0\n#endif\n\n#ifdef __clang__\n#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)\n#  if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))\n#    define JSONCPP_DEPRECATED(message)  __attribute__ ((deprecated(message)))\n#  elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))\n#    define JSONCPP_DEPRECATED(message)  __attribute__((__deprecated__))\n#  endif  // GNUC version\n#endif // __clang__ || __GNUC__\n\n#if !defined(JSONCPP_DEPRECATED)\n#define JSONCPP_DEPRECATED(message)\n#endif // if !defined(JSONCPP_DEPRECATED)\n\nnamespace Json {\ntypedef int Int;\ntypedef unsigned int UInt;\n#if defined(JSON_NO_INT64)\ntypedef int LargestInt;\ntypedef unsigned int LargestUInt;\n#undef JSON_HAS_INT64\n#else                 // if defined(JSON_NO_INT64)\n// For Microsoft Visual use specific types as long long is not supported\n#if defined(_MSC_VER) // Microsoft Visual Studio\ntypedef __int64 Int64;\ntypedef unsigned __int64 UInt64;\n#else                 // if defined(_MSC_VER) // Other platforms, use long long\ntypedef long long int Int64;\ntypedef unsigned long long int UInt64;\n#endif // if defined(_MSC_VER)\ntypedef Int64 LargestInt;\ntypedef UInt64 LargestUInt;\n#define JSON_HAS_INT64\n#endif // if defined(JSON_NO_INT64)\n} // end namespace Json\n\n#endif // JSON_CONFIG_H_INCLUDED\n\n// //////////////////////////////////////////////////////////////////////\n// End of content of file: include/json/config.h\n// //////////////////////////////////////////////////////////////////////\n\n\n\n\n\n\n// //////////////////////////////////////////////////////////////////////\n// Beginning of content of file: include/json/forwards.h\n// //////////////////////////////////////////////////////////////////////\n\n// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_FORWARDS_H_INCLUDED\n#define JSON_FORWARDS_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"config.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n\nnamespace Json {\n\n// writer.h\nclass FastWriter;\nclass StyledWriter;\n\n// reader.h\nclass Reader;\n\n// features.h\nclass Features;\n\n// value.h\ntypedef unsigned int ArrayIndex;\nclass StaticString;\nclass Path;\nclass PathArgument;\nclass Value;\nclass ValueIteratorBase;\nclass ValueIterator;\nclass ValueConstIterator;\n\n} // namespace Json\n\n#endif // JSON_FORWARDS_H_INCLUDED\n\n// //////////////////////////////////////////////////////////////////////\n// End of content of file: include/json/forwards.h\n// //////////////////////////////////////////////////////////////////////\n\n\n\n\n\n\n// //////////////////////////////////////////////////////////////////////\n// Beginning of content of file: include/json/features.h\n// //////////////////////////////////////////////////////////////////////\n\n// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_FEATURES_H_INCLUDED\n#define CPPTL_JSON_FEATURES_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"forwards.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n\nnamespace Json {\n\n/** \\brief Configuration passed to reader and writer.\n * This configuration object can be used to force the Reader or Writer\n * to behave in a standard conforming way.\n */\nclass JSON_API Features {\npublic:\n  /** \\brief A configuration that allows all features and assumes all strings\n   * are UTF-8.\n   * - C & C++ comments are allowed\n   * - Root object can be any JSON value\n   * - Assumes Value strings are encoded in UTF-8\n   */\n  static Features all();\n\n  /** \\brief A configuration that is strictly compatible with the JSON\n   * specification.\n   * - Comments are forbidden.\n   * - Root object must be either an array or an object value.\n   * - Assumes Value strings are encoded in UTF-8\n   */\n  static Features strictMode();\n\n  /** \\brief Initialize the configuration like JsonConfig::allFeatures;\n   */\n  Features();\n\n  /// \\c true if comments are allowed. Default: \\c true.\n  bool allowComments_;\n\n  /// \\c true if root must be either an array or an object value. Default: \\c\n  /// false.\n  bool strictRoot_;\n\n  /// \\c true if dropped null placeholders are allowed. Default: \\c false.\n  bool allowDroppedNullPlaceholders_;\n\n  /// \\c true if numeric object key are allowed. Default: \\c false.\n  bool allowNumericKeys_;\n};\n\n} // namespace Json\n\n#endif // CPPTL_JSON_FEATURES_H_INCLUDED\n\n// //////////////////////////////////////////////////////////////////////\n// End of content of file: include/json/features.h\n// //////////////////////////////////////////////////////////////////////\n\n\n\n\n\n\n// //////////////////////////////////////////////////////////////////////\n// Beginning of content of file: include/json/value.h\n// //////////////////////////////////////////////////////////////////////\n\n// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_H_INCLUDED\n#define CPPTL_JSON_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"forwards.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <string>\n#include <vector>\n#include <exception>\n\n#ifndef JSON_USE_CPPTL_SMALLMAP\n#include <map>\n#else\n#include <cpptl/smallmap.h>\n#endif\n#ifdef JSON_USE_CPPTL\n#include <cpptl/forwards.h>\n#endif\n\n// Disable warning C4251: <data member>: <type> needs to have dll-interface to\n// be used by...\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(push)\n#pragma warning(disable : 4251)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n/** \\brief JSON (JavaScript Object Notation).\n */\nnamespace Json {\n\n/** Base class for all exceptions we throw.\n *\n * We use nothing but these internally. Of course, STL can throw others.\n */\nclass JSON_API Exception : public std::exception {\npublic:\n  Exception(std::string const& msg);\n  ~Exception() throw() override;\n  char const* what() const throw() override;\nprotected:\n  std::string msg_;\n};\n\n/** Exceptions which the user cannot easily avoid.\n *\n * E.g. out-of-memory (when we use malloc), stack-overflow, malicious input\n * \n * \\remark derived from Json::Exception\n */\nclass JSON_API RuntimeError : public Exception {\npublic:\n  RuntimeError(std::string const& msg);\n};\n\n/** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.\n *\n * These are precondition-violations (user bugs) and internal errors (our bugs).\n * \n * \\remark derived from Json::Exception\n */\nclass JSON_API LogicError : public Exception {\npublic:\n  LogicError(std::string const& msg);\n};\n\n/// used internally\nvoid throwRuntimeError(std::string const& msg);\n/// used internally\nvoid throwLogicError(std::string const& msg);\n\n/** \\brief Type of the value held by a Value object.\n */\nenum ValueType {\n  nullValue = 0, ///< 'null' value\n  intValue,      ///< signed integer value\n  uintValue,     ///< unsigned integer value\n  realValue,     ///< double value\n  stringValue,   ///< UTF-8 string value\n  booleanValue,  ///< bool value\n  arrayValue,    ///< array value (ordered list)\n  objectValue    ///< object value (collection of name/value pairs).\n};\n\nenum CommentPlacement {\n  commentBefore = 0,      ///< a comment placed on the line before a value\n  commentAfterOnSameLine, ///< a comment just after a value on the same line\n  commentAfter, ///< a comment on the line after a value (only make sense for\n  /// root value)\n  numberOfCommentPlacement\n};\n\n//# ifdef JSON_USE_CPPTL\n//   typedef CppTL::AnyEnumerator<const char *> EnumMemberNames;\n//   typedef CppTL::AnyEnumerator<const Value &> EnumValues;\n//# endif\n\n/** \\brief Lightweight wrapper to tag static string.\n *\n * Value constructor and objectValue member assignement takes advantage of the\n * StaticString and avoid the cost of string duplication when storing the\n * string or the member name.\n *\n * Example of usage:\n * \\code\n * Json::Value aValue( StaticString(\"some text\") );\n * Json::Value object;\n * static const StaticString code(\"code\");\n * object[code] = 1234;\n * \\endcode\n */\nclass JSON_API StaticString {\npublic:\n  explicit StaticString(const char* czstring) : c_str_(czstring) {}\n\n  operator const char*() const { return c_str_; }\n\n  const char* c_str() const { return c_str_; }\n\nprivate:\n  const char* c_str_;\n};\n\n/** \\brief Represents a <a HREF=\"http://www.json.org\">JSON</a> value.\n *\n * This class is a discriminated union wrapper that can represents a:\n * - signed integer [range: Value::minInt - Value::maxInt]\n * - unsigned integer (range: 0 - Value::maxUInt)\n * - double\n * - UTF-8 string\n * - boolean\n * - 'null'\n * - an ordered list of Value\n * - collection of name/value pairs (javascript object)\n *\n * The type of the held value is represented by a #ValueType and\n * can be obtained using type().\n *\n * Values of an #objectValue or #arrayValue can be accessed using operator[]()\n * methods.\n * Non-const methods will automatically create the a #nullValue element\n * if it does not exist.\n * The sequence of an #arrayValue will be automatically resized and initialized\n * with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.\n *\n * The get() methods can be used to obtain default value in the case the\n * required element does not exist.\n *\n * It is possible to iterate over the list of a #objectValue values using\n * the getMemberNames() method.\n *\n * \\note #Value string-length fit in size_t, but keys must be < 2^30.\n * (The reason is an implementation detail.) A #CharReader will raise an\n * exception if a bound is exceeded to avoid security holes in your app,\n * but the Value API does *not* check bounds. That is the responsibility\n * of the caller.\n */\nclass JSON_API Value {\n  friend class ValueIteratorBase;\npublic:\n  typedef std::vector<std::string> Members;\n  typedef ValueIterator iterator;\n  typedef ValueConstIterator const_iterator;\n  typedef Json::UInt UInt;\n  typedef Json::Int Int;\n#if defined(JSON_HAS_INT64)\n  typedef Json::UInt64 UInt64;\n  typedef Json::Int64 Int64;\n#endif // defined(JSON_HAS_INT64)\n  typedef Json::LargestInt LargestInt;\n  typedef Json::LargestUInt LargestUInt;\n  typedef Json::ArrayIndex ArrayIndex;\n\n  static const Value& null;  ///< We regret this reference to a global instance; prefer the simpler Value().\n  static const Value& nullRef;  ///< just a kludge for binary-compatibility; same as null\n  /// Minimum signed integer value that can be stored in a Json::Value.\n  static const LargestInt minLargestInt;\n  /// Maximum signed integer value that can be stored in a Json::Value.\n  static const LargestInt maxLargestInt;\n  /// Maximum unsigned integer value that can be stored in a Json::Value.\n  static const LargestUInt maxLargestUInt;\n\n  /// Minimum signed int value that can be stored in a Json::Value.\n  static const Int minInt;\n  /// Maximum signed int value that can be stored in a Json::Value.\n  static const Int maxInt;\n  /// Maximum unsigned int value that can be stored in a Json::Value.\n  static const UInt maxUInt;\n\n#if defined(JSON_HAS_INT64)\n  /// Minimum signed 64 bits int value that can be stored in a Json::Value.\n  static const Int64 minInt64;\n  /// Maximum signed 64 bits int value that can be stored in a Json::Value.\n  static const Int64 maxInt64;\n  /// Maximum unsigned 64 bits int value that can be stored in a Json::Value.\n  static const UInt64 maxUInt64;\n#endif // defined(JSON_HAS_INT64)\n\nprivate:\n#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n  class CZString {\n  public:\n    enum DuplicationPolicy {\n      noDuplication = 0,\n      duplicate,\n      duplicateOnCopy\n    };\n    CZString(ArrayIndex index);\n    CZString(char const* str, unsigned length, DuplicationPolicy allocate);\n    CZString(CZString const& other);\n#if JSON_HAS_RVALUE_REFERENCES\n    CZString(CZString&& other);\n#endif\n    ~CZString();\n    CZString& operator=(CZString other);\n    bool operator<(CZString const& other) const;\n    bool operator==(CZString const& other) const;\n    ArrayIndex index() const;\n    //const char* c_str() const; ///< \\deprecated\n    char const* data() const;\n    unsigned length() const;\n    bool isStaticString() const;\n\n  private:\n    void swap(CZString& other);\n\n    struct StringStorage {\n      unsigned policy_: 2;\n      unsigned length_: 30; // 1GB max\n    };\n\n    char const* cstr_;  // actually, a prefixed string, unless policy is noDup\n    union {\n      ArrayIndex index_;\n      StringStorage storage_;\n    };\n  };\n\npublic:\n#ifndef JSON_USE_CPPTL_SMALLMAP\n  typedef std::map<CZString, Value> ObjectValues;\n#else\n  typedef CppTL::SmallMap<CZString, Value> ObjectValues;\n#endif // ifndef JSON_USE_CPPTL_SMALLMAP\n#endif // ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION\n\npublic:\n  /** \\brief Create a default Value of the given type.\n\n    This is a very useful constructor.\n    To create an empty array, pass arrayValue.\n    To create an empty object, pass objectValue.\n    Another Value can then be set to this one by assignment.\nThis is useful since clear() and resize() will not alter types.\n\n    Examples:\n\\code\nJson::Value null_value; // null\nJson::Value arr_value(Json::arrayValue); // []\nJson::Value obj_value(Json::objectValue); // {}\n\\endcode\n  */\n  Value(ValueType type = nullValue);\n  Value(Int value);\n  Value(UInt value);\n#if defined(JSON_HAS_INT64)\n  Value(Int64 value);\n  Value(UInt64 value);\n#endif // if defined(JSON_HAS_INT64)\n  Value(double value);\n  Value(const char* value); ///< Copy til first 0. (NULL causes to seg-fault.)\n  Value(const char* begin, const char* end); ///< Copy all, incl zeroes.\n  /** \\brief Constructs a value from a static string.\n\n   * Like other value string constructor but do not duplicate the string for\n   * internal storage. The given string must remain alive after the call to this\n   * constructor.\n   * \\note This works only for null-terminated strings. (We cannot change the\n   *   size of this class, so we have nowhere to store the length,\n   *   which might be computed later for various operations.)\n   *\n   * Example of usage:\n   * \\code\n   * static StaticString foo(\"some text\");\n   * Json::Value aValue(foo);\n   * \\endcode\n   */\n  Value(const StaticString& value);\n  Value(const std::string& value); ///< Copy data() til size(). Embedded zeroes too.\n#ifdef JSON_USE_CPPTL\n  Value(const CppTL::ConstString& value);\n#endif\n  Value(bool value);\n  /// Deep copy.\n  Value(const Value& other);\n#if JSON_HAS_RVALUE_REFERENCES\n  /// Move constructor\n  Value(Value&& other);\n#endif\n  ~Value();\n\n  /// Deep copy, then swap(other).\n  /// \\note Over-write existing comments. To preserve comments, use #swapPayload().\n  Value& operator=(Value other);\n  /// Swap everything.\n  void swap(Value& other);\n  /// Swap values but leave comments and source offsets in place.\n  void swapPayload(Value& other);\n\n  ValueType type() const;\n\n  /// Compare payload only, not comments etc.\n  bool operator<(const Value& other) const;\n  bool operator<=(const Value& other) const;\n  bool operator>=(const Value& other) const;\n  bool operator>(const Value& other) const;\n  bool operator==(const Value& other) const;\n  bool operator!=(const Value& other) const;\n  int compare(const Value& other) const;\n\n  const char* asCString() const; ///< Embedded zeroes could cause you trouble!\n  std::string asString() const; ///< Embedded zeroes are possible.\n  /** Get raw char* of string-value.\n   *  \\return false if !string. (Seg-fault if str or end are NULL.)\n   */\n  bool getString(\n      char const** begin, char const** end) const;\n#ifdef JSON_USE_CPPTL\n  CppTL::ConstString asConstString() const;\n#endif\n  Int asInt() const;\n  UInt asUInt() const;\n#if defined(JSON_HAS_INT64)\n  Int64 asInt64() const;\n  UInt64 asUInt64() const;\n#endif // if defined(JSON_HAS_INT64)\n  LargestInt asLargestInt() const;\n  LargestUInt asLargestUInt() const;\n  float asFloat() const;\n  double asDouble() const;\n  bool asBool() const;\n\n  bool isNull() const;\n  bool isBool() const;\n  bool isInt() const;\n  bool isInt64() const;\n  bool isUInt() const;\n  bool isUInt64() const;\n  bool isIntegral() const;\n  bool isDouble() const;\n  bool isNumeric() const;\n  bool isString() const;\n  bool isArray() const;\n  bool isObject() const;\n\n  bool isConvertibleTo(ValueType other) const;\n\n  /// Number of values in array or object\n  ArrayIndex size() const;\n\n  /// \\brief Return true if empty array, empty object, or null;\n  /// otherwise, false.\n  bool empty() const;\n\n  /// Return isNull()\n  bool operator!() const;\n\n  /// Remove all object members and array elements.\n  /// \\pre type() is arrayValue, objectValue, or nullValue\n  /// \\post type() is unchanged\n  void clear();\n\n  /// Resize the array to size elements.\n  /// New elements are initialized to null.\n  /// May only be called on nullValue or arrayValue.\n  /// \\pre type() is arrayValue or nullValue\n  /// \\post type() is arrayValue\n  void resize(ArrayIndex size);\n\n  /// Access an array element (zero based index ).\n  /// If the array contains less than index element, then null value are\n  /// inserted\n  /// in the array so that its size is index+1.\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  Value& operator[](ArrayIndex index);\n\n  /// Access an array element (zero based index ).\n  /// If the array contains less than index element, then null value are\n  /// inserted\n  /// in the array so that its size is index+1.\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  Value& operator[](int index);\n\n  /// Access an array element (zero based index )\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  const Value& operator[](ArrayIndex index) const;\n\n  /// Access an array element (zero based index )\n  /// (You may need to say 'value[0u]' to get your compiler to distinguish\n  ///  this from the operator[] which takes a string.)\n  const Value& operator[](int index) const;\n\n  /// If the array contains at least index+1 elements, returns the element\n  /// value,\n  /// otherwise returns defaultValue.\n  Value get(ArrayIndex index, const Value& defaultValue) const;\n  /// Return true if index < size().\n  bool isValidIndex(ArrayIndex index) const;\n  /// \\brief Append value to array at the end.\n  ///\n  /// Equivalent to jsonvalue[jsonvalue.size()] = value;\n  Value& append(const Value& value);\n\n  /// Access an object value by name, create a null member if it does not exist.\n  /// \\note Because of our implementation, keys are limited to 2^30 -1 chars.\n  ///  Exceeding that will cause an exception.\n  Value& operator[](const char* key);\n  /// Access an object value by name, returns null if there is no member with\n  /// that name.\n  const Value& operator[](const char* key) const;\n  /// Access an object value by name, create a null member if it does not exist.\n  /// \\param key may contain embedded nulls.\n  Value& operator[](const std::string& key);\n  /// Access an object value by name, returns null if there is no member with\n  /// that name.\n  /// \\param key may contain embedded nulls.\n  const Value& operator[](const std::string& key) const;\n  /** \\brief Access an object value by name, create a null member if it does not\n   exist.\n\n   * If the object has no entry for that name, then the member name used to store\n   * the new entry is not duplicated.\n   * Example of use:\n   * \\code\n   * Json::Value object;\n   * static const StaticString code(\"code\");\n   * object[code] = 1234;\n   * \\endcode\n   */\n  Value& operator[](const StaticString& key);\n#ifdef JSON_USE_CPPTL\n  /// Access an object value by name, create a null member if it does not exist.\n  Value& operator[](const CppTL::ConstString& key);\n  /// Access an object value by name, returns null if there is no member with\n  /// that name.\n  const Value& operator[](const CppTL::ConstString& key) const;\n#endif\n  /// Return the member named key if it exist, defaultValue otherwise.\n  /// \\note deep copy\n  Value get(const char* key, const Value& defaultValue) const;\n  /// Return the member named key if it exist, defaultValue otherwise.\n  /// \\note deep copy\n  /// \\note key may contain embedded nulls.\n  Value get(const char* begin, const char* end, const Value& defaultValue) const;\n  /// Return the member named key if it exist, defaultValue otherwise.\n  /// \\note deep copy\n  /// \\param key may contain embedded nulls.\n  Value get(const std::string& key, const Value& defaultValue) const;\n#ifdef JSON_USE_CPPTL\n  /// Return the member named key if it exist, defaultValue otherwise.\n  /// \\note deep copy\n  Value get(const CppTL::ConstString& key, const Value& defaultValue) const;\n#endif\n  /// Most general and efficient version of isMember()const, get()const,\n  /// and operator[]const\n  /// \\note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30\n  Value const* find(char const* begin, char const* end) const;\n  /// Most general and efficient version of object-mutators.\n  /// \\note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30\n  /// \\return non-zero, but JSON_ASSERT if this is neither object nor nullValue.\n  Value const* demand(char const* begin, char const* end);\n  /// \\brief Remove and return the named member.\n  ///\n  /// Do nothing if it did not exist.\n  /// \\return the removed Value, or null.\n  /// \\pre type() is objectValue or nullValue\n  /// \\post type() is unchanged\n  /// \\deprecated\n  Value removeMember(const char* key);\n  /// Same as removeMember(const char*)\n  /// \\param key may contain embedded nulls.\n  /// \\deprecated\n  Value removeMember(const std::string& key);\n  /// Same as removeMember(const char* begin, const char* end, Value* removed),\n  /// but 'key' is null-terminated.\n  bool removeMember(const char* key, Value* removed);\n  /** \\brief Remove the named map member.\n\n      Update 'removed' iff removed.\n      \\param key may contain embedded nulls.\n      \\return true iff removed (no exceptions)\n  */\n  bool removeMember(std::string const& key, Value* removed);\n  /// Same as removeMember(std::string const& key, Value* removed)\n  bool removeMember(const char* begin, const char* end, Value* removed);\n  /** \\brief Remove the indexed array element.\n\n      O(n) expensive operations.\n      Update 'removed' iff removed.\n      \\return true iff removed (no exceptions)\n  */\n  bool removeIndex(ArrayIndex i, Value* removed);\n\n  /// Return true if the object has a member named key.\n  /// \\note 'key' must be null-terminated.\n  bool isMember(const char* key) const;\n  /// Return true if the object has a member named key.\n  /// \\param key may contain embedded nulls.\n  bool isMember(const std::string& key) const;\n  /// Same as isMember(std::string const& key)const\n  bool isMember(const char* begin, const char* end) const;\n#ifdef JSON_USE_CPPTL\n  /// Return true if the object has a member named key.\n  bool isMember(const CppTL::ConstString& key) const;\n#endif\n\n  /// \\brief Return a list of the member names.\n  ///\n  /// If null, return an empty list.\n  /// \\pre type() is objectValue or nullValue\n  /// \\post if type() was nullValue, it remains nullValue\n  Members getMemberNames() const;\n\n  //# ifdef JSON_USE_CPPTL\n  //      EnumMemberNames enumMemberNames() const;\n  //      EnumValues enumValues() const;\n  //# endif\n\n  /// \\deprecated Always pass len.\n  JSONCPP_DEPRECATED(\"Use setComment(std::string const&) instead.\")\n  void setComment(const char* comment, CommentPlacement placement);\n  /// Comments must be //... or /* ... */\n  void setComment(const char* comment, size_t len, CommentPlacement placement);\n  /// Comments must be //... or /* ... */\n  void setComment(const std::string& comment, CommentPlacement placement);\n  bool hasComment(CommentPlacement placement) const;\n  /// Include delimiters and embedded newlines.\n  std::string getComment(CommentPlacement placement) const;\n\n  std::string toStyledString() const;\n\n  const_iterator begin() const;\n  const_iterator end() const;\n\n  iterator begin();\n  iterator end();\n\n  // Accessors for the [start, limit) range of bytes within the JSON text from\n  // which this value was parsed, if any.\n  void setOffsetStart(size_t start);\n  void setOffsetLimit(size_t limit);\n  size_t getOffsetStart() const;\n  size_t getOffsetLimit() const;\n\nprivate:\n  void initBasic(ValueType type, bool allocated = false);\n\n  Value& resolveReference(const char* key);\n  Value& resolveReference(const char* key, const char* end);\n\n  struct CommentInfo {\n    CommentInfo();\n    ~CommentInfo();\n\n    void setComment(const char* text, size_t len);\n\n    char* comment_;\n  };\n\n  // struct MemberNamesTransform\n  //{\n  //   typedef const char *result_type;\n  //   const char *operator()( const CZString &name ) const\n  //   {\n  //      return name.c_str();\n  //   }\n  //};\n\n  union ValueHolder {\n    LargestInt int_;\n    LargestUInt uint_;\n    double real_;\n    bool bool_;\n    char* string_;  // actually ptr to unsigned, followed by str, unless !allocated_\n    ObjectValues* map_;\n  } value_;\n  ValueType type_ : 8;\n  unsigned int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.\n                               // If not allocated_, string_ must be null-terminated.\n  CommentInfo* comments_;\n\n  // [start, limit) byte offsets in the source JSON text from which this Value\n  // was extracted.\n  size_t start_;\n  size_t limit_;\n};\n\n/** \\brief Experimental and untested: represents an element of the \"path\" to\n * access a node.\n */\nclass JSON_API PathArgument {\npublic:\n  friend class Path;\n\n  PathArgument();\n  PathArgument(ArrayIndex index);\n  PathArgument(const char* key);\n  PathArgument(const std::string& key);\n\nprivate:\n  enum Kind {\n    kindNone = 0,\n    kindIndex,\n    kindKey\n  };\n  std::string key_;\n  ArrayIndex index_;\n  Kind kind_;\n};\n\n/** \\brief Experimental and untested: represents a \"path\" to access a node.\n *\n * Syntax:\n * - \".\" => root node\n * - \".[n]\" => elements at index 'n' of root node (an array value)\n * - \".name\" => member named 'name' of root node (an object value)\n * - \".name1.name2.name3\"\n * - \".[0][1][2].name1[3]\"\n * - \".%\" => member name is provided as parameter\n * - \".[%]\" => index is provied as parameter\n */\nclass JSON_API Path {\npublic:\n  Path(const std::string& path,\n       const PathArgument& a1 = PathArgument(),\n       const PathArgument& a2 = PathArgument(),\n       const PathArgument& a3 = PathArgument(),\n       const PathArgument& a4 = PathArgument(),\n       const PathArgument& a5 = PathArgument());\n\n  const Value& resolve(const Value& root) const;\n  Value resolve(const Value& root, const Value& defaultValue) const;\n  /// Creates the \"path\" to access the specified node and returns a reference on\n  /// the node.\n  Value& make(Value& root) const;\n\nprivate:\n  typedef std::vector<const PathArgument*> InArgs;\n  typedef std::vector<PathArgument> Args;\n\n  void makePath(const std::string& path, const InArgs& in);\n  void addPathInArg(const std::string& path,\n                    const InArgs& in,\n                    InArgs::const_iterator& itInArg,\n                    PathArgument::Kind kind);\n  void invalidPath(const std::string& path, int location);\n\n  Args args_;\n};\n\n/** \\brief base class for Value iterators.\n *\n */\nclass JSON_API ValueIteratorBase {\npublic:\n  typedef std::bidirectional_iterator_tag iterator_category;\n  typedef unsigned int size_t;\n  typedef int difference_type;\n  typedef ValueIteratorBase SelfType;\n\n  bool operator==(const SelfType& other) const { return isEqual(other); }\n\n  bool operator!=(const SelfType& other) const { return !isEqual(other); }\n\n  difference_type operator-(const SelfType& other) const {\n    return other.computeDistance(*this);\n  }\n\n  /// Return either the index or the member name of the referenced value as a\n  /// Value.\n  Value key() const;\n\n  /// Return the index of the referenced Value, or -1 if it is not an arrayValue.\n  UInt index() const;\n\n  /// Return the member name of the referenced Value, or \"\" if it is not an\n  /// objectValue.\n  /// \\note Avoid `c_str()` on result, as embedded zeroes are possible.\n  std::string name() const;\n\n  /// Return the member name of the referenced Value. \"\" if it is not an\n  /// objectValue.\n  /// \\deprecated This cannot be used for UTF-8 strings, since there can be embedded nulls.\n  JSONCPP_DEPRECATED(\"Use `key = name();` instead.\")\n  char const* memberName() const;\n  /// Return the member name of the referenced Value, or NULL if it is not an\n  /// objectValue.\n  /// \\note Better version than memberName(). Allows embedded nulls.\n  char const* memberName(char const** end) const;\n\nprotected:\n  Value& deref() const;\n\n  void increment();\n\n  void decrement();\n\n  difference_type computeDistance(const SelfType& other) const;\n\n  bool isEqual(const SelfType& other) const;\n\n  void copy(const SelfType& other);\n\nprivate:\n  Value::ObjectValues::iterator current_;\n  // Indicates that iterator is for a null value.\n  bool isNull_;\n\npublic:\n  // For some reason, BORLAND needs these at the end, rather\n  // than earlier. No idea why.\n  ValueIteratorBase();\n  explicit ValueIteratorBase(const Value::ObjectValues::iterator& current);\n};\n\n/** \\brief const iterator for object and array value.\n *\n */\nclass JSON_API ValueConstIterator : public ValueIteratorBase {\n  friend class Value;\n\npublic:\n  typedef const Value value_type;\n  //typedef unsigned int size_t;\n  //typedef int difference_type;\n  typedef const Value& reference;\n  typedef const Value* pointer;\n  typedef ValueConstIterator SelfType;\n\n  ValueConstIterator();\n  ValueConstIterator(ValueIterator const& other);\n\nprivate:\n/*! \\internal Use by Value to create an iterator.\n */\n  explicit ValueConstIterator(const Value::ObjectValues::iterator& current);\npublic:\n  SelfType& operator=(const ValueIteratorBase& other);\n\n  SelfType operator++(int) {\n    SelfType temp(*this);\n    ++*this;\n    return temp;\n  }\n\n  SelfType operator--(int) {\n    SelfType temp(*this);\n    --*this;\n    return temp;\n  }\n\n  SelfType& operator--() {\n    decrement();\n    return *this;\n  }\n\n  SelfType& operator++() {\n    increment();\n    return *this;\n  }\n\n  reference operator*() const { return deref(); }\n\n  pointer operator->() const { return &deref(); }\n};\n\n/** \\brief Iterator for object and array value.\n */\nclass JSON_API ValueIterator : public ValueIteratorBase {\n  friend class Value;\n\npublic:\n  typedef Value value_type;\n  typedef unsigned int size_t;\n  typedef int difference_type;\n  typedef Value& reference;\n  typedef Value* pointer;\n  typedef ValueIterator SelfType;\n\n  ValueIterator();\n  explicit ValueIterator(const ValueConstIterator& other);\n  ValueIterator(const ValueIterator& other);\n\nprivate:\n/*! \\internal Use by Value to create an iterator.\n */\n  explicit ValueIterator(const Value::ObjectValues::iterator& current);\npublic:\n  SelfType& operator=(const SelfType& other);\n\n  SelfType operator++(int) {\n    SelfType temp(*this);\n    ++*this;\n    return temp;\n  }\n\n  SelfType operator--(int) {\n    SelfType temp(*this);\n    --*this;\n    return temp;\n  }\n\n  SelfType& operator--() {\n    decrement();\n    return *this;\n  }\n\n  SelfType& operator++() {\n    increment();\n    return *this;\n  }\n\n  reference operator*() const { return deref(); }\n\n  pointer operator->() const { return &deref(); }\n};\n\n} // namespace Json\n\n\nnamespace std {\n/// Specialize std::swap() for Json::Value.\ntemplate<>\ninline void swap(Json::Value& a, Json::Value& b) { a.swap(b); }\n}\n\n\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(pop)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n#endif // CPPTL_JSON_H_INCLUDED\n\n// //////////////////////////////////////////////////////////////////////\n// End of content of file: include/json/value.h\n// //////////////////////////////////////////////////////////////////////\n\n\n\n\n\n\n// //////////////////////////////////////////////////////////////////////\n// Beginning of content of file: include/json/reader.h\n// //////////////////////////////////////////////////////////////////////\n\n// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_READER_H_INCLUDED\n#define CPPTL_JSON_READER_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"features.h\"\n#include \"value.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <deque>\n#include <iosfwd>\n#include <stack>\n#include <string>\n#include <istream>\n\n// Disable warning C4251: <data member>: <type> needs to have dll-interface to\n// be used by...\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(push)\n#pragma warning(disable : 4251)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\nnamespace Json {\n\n/** \\brief Unserialize a <a HREF=\"http://www.json.org\">JSON</a> document into a\n *Value.\n *\n * \\deprecated Use CharReader and CharReaderBuilder.\n */\nclass JSON_API Reader {\npublic:\n  typedef char Char;\n  typedef const Char* Location;\n\n  /** \\brief An error tagged with where in the JSON text it was encountered.\n   *\n   * The offsets give the [start, limit) range of bytes within the text. Note\n   * that this is bytes, not codepoints.\n   *\n   */\n  struct StructuredError {\n    size_t offset_start;\n    size_t offset_limit;\n    std::string message;\n  };\n\n  /** \\brief Constructs a Reader allowing all features\n   * for parsing.\n   */\n  Reader();\n\n  /** \\brief Constructs a Reader allowing the specified feature set\n   * for parsing.\n   */\n  Reader(const Features& features);\n\n  /** \\brief Read a Value from a <a HREF=\"http://www.json.org\">JSON</a>\n   * document.\n   * \\param document UTF-8 encoded string containing the document to read.\n   * \\param root [out] Contains the root value of the document if it was\n   *             successfully parsed.\n   * \\param collectComments \\c true to collect comment and allow writing them\n   * back during\n   *                        serialization, \\c false to discard comments.\n   *                        This parameter is ignored if\n   * Features::allowComments_\n   *                        is \\c false.\n   * \\return \\c true if the document was successfully parsed, \\c false if an\n   * error occurred.\n   */\n  bool\n  parse(const std::string& document, Value& root, bool collectComments = true);\n\n  /** \\brief Read a Value from a <a HREF=\"http://www.json.org\">JSON</a>\n   document.\n   * \\param beginDoc Pointer on the beginning of the UTF-8 encoded string of the\n   document to read.\n   * \\param endDoc Pointer on the end of the UTF-8 encoded string of the\n   document to read.\n   *               Must be >= beginDoc.\n   * \\param root [out] Contains the root value of the document if it was\n   *             successfully parsed.\n   * \\param collectComments \\c true to collect comment and allow writing them\n   back during\n   *                        serialization, \\c false to discard comments.\n   *                        This parameter is ignored if\n   Features::allowComments_\n   *                        is \\c false.\n   * \\return \\c true if the document was successfully parsed, \\c false if an\n   error occurred.\n   */\n  bool parse(const char* beginDoc,\n             const char* endDoc,\n             Value& root,\n             bool collectComments = true);\n\n  /// \\brief Parse from input stream.\n  /// \\see Json::operator>>(std::istream&, Json::Value&).\n  bool parse(std::istream& is, Value& root, bool collectComments = true);\n\n  /** \\brief Returns a user friendly string that list errors in the parsed\n   * document.\n   * \\return Formatted error message with the list of errors with their location\n   * in\n   *         the parsed document. An empty string is returned if no error\n   * occurred\n   *         during parsing.\n   * \\deprecated Use getFormattedErrorMessages() instead (typo fix).\n   */\n  JSONCPP_DEPRECATED(\"Use getFormattedErrorMessages() instead.\")\n  std::string getFormatedErrorMessages() const;\n\n  /** \\brief Returns a user friendly string that list errors in the parsed\n   * document.\n   * \\return Formatted error message with the list of errors with their location\n   * in\n   *         the parsed document. An empty string is returned if no error\n   * occurred\n   *         during parsing.\n   */\n  std::string getFormattedErrorMessages() const;\n\n  /** \\brief Returns a vector of structured erros encounted while parsing.\n   * \\return A (possibly empty) vector of StructuredError objects. Currently\n   *         only one error can be returned, but the caller should tolerate\n   * multiple\n   *         errors.  This can occur if the parser recovers from a non-fatal\n   *         parse error and then encounters additional errors.\n   */\n  std::vector<StructuredError> getStructuredErrors() const;\n\n  /** \\brief Add a semantic error message.\n   * \\param value JSON Value location associated with the error\n   * \\param message The error message.\n   * \\return \\c true if the error was successfully added, \\c false if the\n   * Value offset exceeds the document size.\n   */\n  bool pushError(const Value& value, const std::string& message);\n\n  /** \\brief Add a semantic error message with extra context.\n   * \\param value JSON Value location associated with the error\n   * \\param message The error message.\n   * \\param extra Additional JSON Value location to contextualize the error\n   * \\return \\c true if the error was successfully added, \\c false if either\n   * Value offset exceeds the document size.\n   */\n  bool pushError(const Value& value, const std::string& message, const Value& extra);\n\n  /** \\brief Return whether there are any errors.\n   * \\return \\c true if there are no errors to report \\c false if\n   * errors have occurred.\n   */\n  bool good() const;\n\nprivate:\n  enum TokenType {\n    tokenEndOfStream = 0,\n    tokenObjectBegin,\n    tokenObjectEnd,\n    tokenArrayBegin,\n    tokenArrayEnd,\n    tokenString,\n    tokenNumber,\n    tokenTrue,\n    tokenFalse,\n    tokenNull,\n    tokenArraySeparator,\n    tokenMemberSeparator,\n    tokenComment,\n    tokenError\n  };\n\n  class Token {\n  public:\n    TokenType type_;\n    Location start_;\n    Location end_;\n  };\n\n  class ErrorInfo {\n  public:\n    Token token_;\n    std::string message_;\n    Location extra_;\n  };\n\n  typedef std::deque<ErrorInfo> Errors;\n\n  bool readToken(Token& token);\n  void skipSpaces();\n  bool match(Location pattern, int patternLength);\n  bool readComment();\n  bool readCStyleComment();\n  bool readCppStyleComment();\n  bool readString();\n  void readNumber();\n  bool readValue();\n  bool readObject(Token& token);\n  bool readArray(Token& token);\n  bool decodeNumber(Token& token);\n  bool decodeNumber(Token& token, Value& decoded);\n  bool decodeString(Token& token);\n  bool decodeString(Token& token, std::string& decoded);\n  bool decodeDouble(Token& token);\n  bool decodeDouble(Token& token, Value& decoded);\n  bool decodeUnicodeCodePoint(Token& token,\n                              Location& current,\n                              Location end,\n                              unsigned int& unicode);\n  bool decodeUnicodeEscapeSequence(Token& token,\n                                   Location& current,\n                                   Location end,\n                                   unsigned int& unicode);\n  bool addError(const std::string& message, Token& token, Location extra = 0);\n  bool recoverFromError(TokenType skipUntilToken);\n  bool addErrorAndRecover(const std::string& message,\n                          Token& token,\n                          TokenType skipUntilToken);\n  void skipUntilSpace();\n  Value& currentValue();\n  Char getNextChar();\n  void\n  getLocationLineAndColumn(Location location, int& line, int& column) const;\n  std::string getLocationLineAndColumn(Location location) const;\n  void addComment(Location begin, Location end, CommentPlacement placement);\n  void skipCommentTokens(Token& token);\n\n  typedef std::stack<Value*> Nodes;\n  Nodes nodes_;\n  Errors errors_;\n  std::string document_;\n  Location begin_;\n  Location end_;\n  Location current_;\n  Location lastValueEnd_;\n  Value* lastValue_;\n  std::string commentsBefore_;\n  Features features_;\n  bool collectComments_;\n};  // Reader\n\n/** Interface for reading JSON from a char array.\n */\nclass JSON_API CharReader {\npublic:\n  virtual ~CharReader() {}\n  /** \\brief Read a Value from a <a HREF=\"http://www.json.org\">JSON</a>\n   document.\n   * The document must be a UTF-8 encoded string containing the document to read.\n   *\n   * \\param beginDoc Pointer on the beginning of the UTF-8 encoded string of the\n   document to read.\n   * \\param endDoc Pointer on the end of the UTF-8 encoded string of the\n   document to read.\n   *        Must be >= beginDoc.\n   * \\param root [out] Contains the root value of the document if it was\n   *             successfully parsed.\n   * \\param errs [out] Formatted error messages (if not NULL)\n   *        a user friendly string that lists errors in the parsed\n   * document.\n   * \\return \\c true if the document was successfully parsed, \\c false if an\n   error occurred.\n   */\n  virtual bool parse(\n      char const* beginDoc, char const* endDoc,\n      Value* root, std::string* errs) = 0;\n\n  class JSON_API Factory {\n  public:\n    virtual ~Factory() {}\n    /** \\brief Allocate a CharReader via operator new().\n     * \\throw std::exception if something goes wrong (e.g. invalid settings)\n     */\n    virtual CharReader* newCharReader() const = 0;\n  };  // Factory\n};  // CharReader\n\n/** \\brief Build a CharReader implementation.\n\nUsage:\n\\code\n  using namespace Json;\n  CharReaderBuilder builder;\n  builder[\"collectComments\"] = false;\n  Value value;\n  std::string errs;\n  bool ok = parseFromStream(builder, std::cin, &value, &errs);\n\\endcode\n*/\nclass JSON_API CharReaderBuilder : public CharReader::Factory {\npublic:\n  // Note: We use a Json::Value so that we can add data-members to this class\n  // without a major version bump.\n  /** Configuration of this builder.\n    These are case-sensitive.\n    Available settings (case-sensitive):\n    - `\"collectComments\": false or true`\n      - true to collect comment and allow writing them\n        back during serialization, false to discard comments.\n        This parameter is ignored if allowComments is false.\n    - `\"allowComments\": false or true`\n      - true if comments are allowed.\n    - `\"strictRoot\": false or true`\n      - true if root must be either an array or an object value\n    - `\"allowDroppedNullPlaceholders\": false or true`\n      - true if dropped null placeholders are allowed. (See StreamWriterBuilder.)\n    - `\"allowNumericKeys\": false or true`\n      - true if numeric object keys are allowed.\n    - `\"allowSingleQuotes\": false or true`\n      - true if '' are allowed for strings (both keys and values)\n    - `\"stackLimit\": integer`\n      - Exceeding stackLimit (recursive depth of `readValue()`) will\n        cause an exception.\n      - This is a security issue (seg-faults caused by deeply nested JSON),\n        so the default is low.\n    - `\"failIfExtra\": false or true`\n      - If true, `parse()` returns false when extra non-whitespace trails\n        the JSON value in the input string.\n    - `\"rejectDupKeys\": false or true`\n      - If true, `parse()` returns false when a key is duplicated within an object.\n    - `\"allowSpecialFloats\": false or true`\n      - If true, special float values (NaNs and infinities) are allowed \n        and their values are lossfree restorable.\n\n    You can examine 'settings_` yourself\n    to see the defaults. You can also write and read them just like any\n    JSON Value.\n    \\sa setDefaults()\n    */\n  Json::Value settings_;\n\n  CharReaderBuilder();\n  ~CharReaderBuilder() override;\n\n  CharReader* newCharReader() const override;\n\n  /** \\return true if 'settings' are legal and consistent;\n   *   otherwise, indicate bad settings via 'invalid'.\n   */\n  bool validate(Json::Value* invalid) const;\n\n  /** A simple way to update a specific setting.\n   */\n  Value& operator[](std::string key);\n\n  /** Called by ctor, but you can use this to reset settings_.\n   * \\pre 'settings' != NULL (but Json::null is fine)\n   * \\remark Defaults:\n   * \\snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults\n   */\n  static void setDefaults(Json::Value* settings);\n  /** Same as old Features::strictMode().\n   * \\pre 'settings' != NULL (but Json::null is fine)\n   * \\remark Defaults:\n   * \\snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode\n   */\n  static void strictMode(Json::Value* settings);\n};\n\n/** Consume entire stream and use its begin/end.\n  * Someday we might have a real StreamReader, but for now this\n  * is convenient.\n  */\nbool JSON_API parseFromStream(\n    CharReader::Factory const&,\n    std::istream&,\n    Value* root, std::string* errs);\n\n/** \\brief Read from 'sin' into 'root'.\n\n Always keep comments from the input JSON.\n\n This can be used to read a file into a particular sub-object.\n For example:\n \\code\n Json::Value root;\n cin >> root[\"dir\"][\"file\"];\n cout << root;\n \\endcode\n Result:\n \\verbatim\n {\n \"dir\": {\n     \"file\": {\n     // The input stream JSON would be nested here.\n     }\n }\n }\n \\endverbatim\n \\throw std::exception on parse error.\n \\see Json::operator<<()\n*/\nJSON_API std::istream& operator>>(std::istream&, Value&);\n\n} // namespace Json\n\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(pop)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n#endif // CPPTL_JSON_READER_H_INCLUDED\n\n// //////////////////////////////////////////////////////////////////////\n// End of content of file: include/json/reader.h\n// //////////////////////////////////////////////////////////////////////\n\n\n\n\n\n\n// //////////////////////////////////////////////////////////////////////\n// Beginning of content of file: include/json/writer.h\n// //////////////////////////////////////////////////////////////////////\n\n// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef JSON_WRITER_H_INCLUDED\n#define JSON_WRITER_H_INCLUDED\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"value.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <vector>\n#include <string>\n#include <ostream>\n\n// Disable warning C4251: <data member>: <type> needs to have dll-interface to\n// be used by...\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(push)\n#pragma warning(disable : 4251)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\nnamespace Json {\n\nclass Value;\n\n/**\n\nUsage:\n\\code\n  using namespace Json;\n  void writeToStdout(StreamWriter::Factory const& factory, Value const& value) {\n    std::unique_ptr<StreamWriter> const writer(\n      factory.newStreamWriter());\n    writer->write(value, &std::cout);\n    std::cout << std::endl;  // add lf and flush\n  }\n\\endcode\n*/\nclass JSON_API StreamWriter {\nprotected:\n  std::ostream* sout_;  // not owned; will not delete\npublic:\n  StreamWriter();\n  virtual ~StreamWriter();\n  /** Write Value into document as configured in sub-class.\n      Do not take ownership of sout, but maintain a reference during function.\n      \\pre sout != NULL\n      \\return zero on success (For now, we always return zero, so check the stream instead.)\n      \\throw std::exception possibly, depending on configuration\n   */\n  virtual int write(Value const& root, std::ostream* sout) = 0;\n\n  /** \\brief A simple abstract factory.\n   */\n  class JSON_API Factory {\n  public:\n    virtual ~Factory();\n    /** \\brief Allocate a CharReader via operator new().\n     * \\throw std::exception if something goes wrong (e.g. invalid settings)\n     */\n    virtual StreamWriter* newStreamWriter() const = 0;\n  };  // Factory\n};  // StreamWriter\n\n/** \\brief Write into stringstream, then return string, for convenience.\n * A StreamWriter will be created from the factory, used, and then deleted.\n */\nstd::string JSON_API writeString(StreamWriter::Factory const& factory, Value const& root);\n\n\n/** \\brief Build a StreamWriter implementation.\n\nUsage:\n\\code\n  using namespace Json;\n  Value value = ...;\n  StreamWriterBuilder builder;\n  builder[\"commentStyle\"] = \"None\";\n  builder[\"indentation\"] = \"   \";  // or whatever you like\n  std::unique_ptr<Json::StreamWriter> writer(\n      builder.newStreamWriter());\n  writer->write(value, &std::cout);\n  std::cout << std::endl;  // add lf and flush\n\\endcode\n*/\nclass JSON_API StreamWriterBuilder : public StreamWriter::Factory {\npublic:\n  // Note: We use a Json::Value so that we can add data-members to this class\n  // without a major version bump.\n  /** Configuration of this builder.\n    Available settings (case-sensitive):\n    - \"commentStyle\": \"None\" or \"All\"\n    - \"indentation\":  \"<anything>\"\n    - \"enableYAMLCompatibility\": false or true\n      - slightly change the whitespace around colons\n    - \"dropNullPlaceholders\": false or true\n      - Drop the \"null\" string from the writer's output for nullValues.\n        Strictly speaking, this is not valid JSON. But when the output is being\n        fed to a browser's Javascript, it makes for smaller output and the\n        browser can handle the output just fine.\n    - \"useSpecialFloats\": false or true\n      - If true, outputs non-finite floating point values in the following way:\n        NaN values as \"NaN\", positive infinity as \"Infinity\", and negative infinity\n        as \"-Infinity\".\n\n    You can examine 'settings_` yourself\n    to see the defaults. You can also write and read them just like any\n    JSON Value.\n    \\sa setDefaults()\n    */\n  Json::Value settings_;\n\n  StreamWriterBuilder();\n  ~StreamWriterBuilder() override;\n\n  /**\n   * \\throw std::exception if something goes wrong (e.g. invalid settings)\n   */\n  StreamWriter* newStreamWriter() const override;\n\n  /** \\return true if 'settings' are legal and consistent;\n   *   otherwise, indicate bad settings via 'invalid'.\n   */\n  bool validate(Json::Value* invalid) const;\n  /** A simple way to update a specific setting.\n   */\n  Value& operator[](std::string key);\n\n  /** Called by ctor, but you can use this to reset settings_.\n   * \\pre 'settings' != NULL (but Json::null is fine)\n   * \\remark Defaults:\n   * \\snippet src/lib_json/json_writer.cpp StreamWriterBuilderDefaults\n   */\n  static void setDefaults(Json::Value* settings);\n};\n\n/** \\brief Abstract class for writers.\n * \\deprecated Use StreamWriter. (And really, this is an implementation detail.)\n */\nclass JSON_API Writer {\npublic:\n  virtual ~Writer();\n\n  virtual std::string write(const Value& root) = 0;\n};\n\n/** \\brief Outputs a Value in <a HREF=\"http://www.json.org\">JSON</a> format\n *without formatting (not human friendly).\n *\n * The JSON document is written in a single line. It is not intended for 'human'\n *consumption,\n * but may be usefull to support feature such as RPC where bandwith is limited.\n * \\sa Reader, Value\n * \\deprecated Use StreamWriterBuilder.\n */\nclass JSON_API FastWriter : public Writer {\n\npublic:\n  FastWriter();\n  ~FastWriter() override {}\n\n  void enableYAMLCompatibility();\n\n  /** \\brief Drop the \"null\" string from the writer's output for nullValues.\n   * Strictly speaking, this is not valid JSON. But when the output is being\n   * fed to a browser's Javascript, it makes for smaller output and the\n   * browser can handle the output just fine.\n   */\n  void dropNullPlaceholders();\n\n  void omitEndingLineFeed();\n\npublic: // overridden from Writer\n  std::string write(const Value& root) override;\n\nprivate:\n  void writeValue(const Value& value);\n\n  std::string document_;\n  bool yamlCompatiblityEnabled_;\n  bool dropNullPlaceholders_;\n  bool omitEndingLineFeed_;\n};\n\n/** \\brief Writes a Value in <a HREF=\"http://www.json.org\">JSON</a> format in a\n *human friendly way.\n *\n * The rules for line break and indent are as follow:\n * - Object value:\n *     - if empty then print {} without indent and line break\n *     - if not empty the print '{', line break & indent, print one value per\n *line\n *       and then unindent and line break and print '}'.\n * - Array value:\n *     - if empty then print [] without indent and line break\n *     - if the array contains no object value, empty array or some other value\n *types,\n *       and all the values fit on one lines, then print the array on a single\n *line.\n *     - otherwise, it the values do not fit on one line, or the array contains\n *       object or non empty array, then print one value per line.\n *\n * If the Value have comments then they are outputed according to their\n *#CommentPlacement.\n *\n * \\sa Reader, Value, Value::setComment()\n * \\deprecated Use StreamWriterBuilder.\n */\nclass JSON_API StyledWriter : public Writer {\npublic:\n  StyledWriter();\n  ~StyledWriter() override {}\n\npublic: // overridden from Writer\n  /** \\brief Serialize a Value in <a HREF=\"http://www.json.org\">JSON</a> format.\n   * \\param root Value to serialize.\n   * \\return String containing the JSON document that represents the root value.\n   */\n  std::string write(const Value& root) override;\n\nprivate:\n  void writeValue(const Value& value);\n  void writeArrayValue(const Value& value);\n  bool isMultineArray(const Value& value);\n  void pushValue(const std::string& value);\n  void writeIndent();\n  void writeWithIndent(const std::string& value);\n  void indent();\n  void unindent();\n  void writeCommentBeforeValue(const Value& root);\n  void writeCommentAfterValueOnSameLine(const Value& root);\n  bool hasCommentForValue(const Value& value);\n  static std::string normalizeEOL(const std::string& text);\n\n  typedef std::vector<std::string> ChildValues;\n\n  ChildValues childValues_;\n  std::string document_;\n  std::string indentString_;\n  int rightMargin_;\n  int indentSize_;\n  bool addChildValues_;\n};\n\n/** \\brief Writes a Value in <a HREF=\"http://www.json.org\">JSON</a> format in a\n human friendly way,\n     to a stream rather than to a string.\n *\n * The rules for line break and indent are as follow:\n * - Object value:\n *     - if empty then print {} without indent and line break\n *     - if not empty the print '{', line break & indent, print one value per\n line\n *       and then unindent and line break and print '}'.\n * - Array value:\n *     - if empty then print [] without indent and line break\n *     - if the array contains no object value, empty array or some other value\n types,\n *       and all the values fit on one lines, then print the array on a single\n line.\n *     - otherwise, it the values do not fit on one line, or the array contains\n *       object or non empty array, then print one value per line.\n *\n * If the Value have comments then they are outputed according to their\n #CommentPlacement.\n *\n * \\param indentation Each level will be indented by this amount extra.\n * \\sa Reader, Value, Value::setComment()\n * \\deprecated Use StreamWriterBuilder.\n */\nclass JSON_API StyledStreamWriter {\npublic:\n  StyledStreamWriter(std::string indentation = \"\\t\");\n  ~StyledStreamWriter() {}\n\npublic:\n  /** \\brief Serialize a Value in <a HREF=\"http://www.json.org\">JSON</a> format.\n   * \\param out Stream to write to. (Can be ostringstream, e.g.)\n   * \\param root Value to serialize.\n   * \\note There is no point in deriving from Writer, since write() should not\n   * return a value.\n   */\n  void write(std::ostream& out, const Value& root);\n\nprivate:\n  void writeValue(const Value& value);\n  void writeArrayValue(const Value& value);\n  bool isMultineArray(const Value& value);\n  void pushValue(const std::string& value);\n  void writeIndent();\n  void writeWithIndent(const std::string& value);\n  void indent();\n  void unindent();\n  void writeCommentBeforeValue(const Value& root);\n  void writeCommentAfterValueOnSameLine(const Value& root);\n  bool hasCommentForValue(const Value& value);\n  static std::string normalizeEOL(const std::string& text);\n\n  typedef std::vector<std::string> ChildValues;\n\n  ChildValues childValues_;\n  std::ostream* document_;\n  std::string indentString_;\n  int rightMargin_;\n  std::string indentation_;\n  bool addChildValues_ : 1;\n  bool indented_ : 1;\n};\n\n#if defined(JSON_HAS_INT64)\nstd::string JSON_API valueToString(Int value);\nstd::string JSON_API valueToString(UInt value);\n#endif // if defined(JSON_HAS_INT64)\nstd::string JSON_API valueToString(LargestInt value);\nstd::string JSON_API valueToString(LargestUInt value);\nstd::string JSON_API valueToString(double value);\nstd::string JSON_API valueToString(bool value);\nstd::string JSON_API valueToQuotedString(const char* value);\n\n/// \\brief Output using the StyledStreamWriter.\n/// \\see Json::operator>>()\nJSON_API std::ostream& operator<<(std::ostream&, const Value& root);\n\n} // namespace Json\n\n#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n#pragma warning(pop)\n#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)\n\n#endif // JSON_WRITER_H_INCLUDED\n\n// //////////////////////////////////////////////////////////////////////\n// End of content of file: include/json/writer.h\n// //////////////////////////////////////////////////////////////////////\n\n\n\n\n\n\n// //////////////////////////////////////////////////////////////////////\n// Beginning of content of file: include/json/assertions.h\n// //////////////////////////////////////////////////////////////////////\n\n// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef CPPTL_JSON_ASSERTIONS_H_INCLUDED\n#define CPPTL_JSON_ASSERTIONS_H_INCLUDED\n\n#include <stdlib.h>\n#include <sstream>\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include \"config.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n\n/** It should not be possible for a maliciously designed file to\n *  cause an abort() or seg-fault, so these macros are used only\n *  for pre-condition violations and internal logic errors.\n */\n#if JSON_USE_EXCEPTION\n\n// @todo <= add detail about condition in exception\n# define JSON_ASSERT(condition)                                                \\\n  {if (!(condition)) {Json::throwLogicError( \"assert json failed\" );}}\n\n# define JSON_FAIL_MESSAGE(message)                                            \\\n  {                                                                            \\\n    std::ostringstream oss; oss << message;                                    \\\n    Json::throwLogicError(oss.str());                                          \\\n    abort();                                                                   \\\n  }\n\n#else // JSON_USE_EXCEPTION\n\n# define JSON_ASSERT(condition) assert(condition)\n\n// The call to assert() will show the failure message in debug builds. In\n// release builds we abort, for a core-dump or debugger.\n# define JSON_FAIL_MESSAGE(message)                                            \\\n  {                                                                            \\\n    std::ostringstream oss; oss << message;                                    \\\n    assert(false && oss.str().c_str());                                        \\\n    abort();                                                                   \\\n  }\n\n\n#endif\n\n#define JSON_ASSERT_MESSAGE(condition, message)                                \\\n  if (!(condition)) {                                                          \\\n    JSON_FAIL_MESSAGE(message);                                                \\\n  }\n\n#endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED\n\n// //////////////////////////////////////////////////////////////////////\n// End of content of file: include/json/assertions.h\n// //////////////////////////////////////////////////////////////////////\n\n\n\n\n\n#endif //ifndef JSON_AMALGATED_H_INCLUDED\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/conformance/third_party/jsoncpp/jsoncpp.cpp",
    "content": "/// Json-cpp amalgated source (http://jsoncpp.sourceforge.net/).\n/// It is intended to be used with #include \"json/json.h\"\n\n// //////////////////////////////////////////////////////////////////////\n// Beginning of content of file: LICENSE\n// //////////////////////////////////////////////////////////////////////\n\n/*\nThe JsonCpp library's source code, including accompanying documentation, \ntests and demonstration applications, are licensed under the following\nconditions...\n\nThe author (Baptiste Lepilleur) explicitly disclaims copyright in all \njurisdictions which recognize such a disclaimer. In such jurisdictions, \nthis software is released into the Public Domain.\n\nIn jurisdictions which do not recognize Public Domain property (e.g. Germany as of\n2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is\nreleased under the terms of the MIT License (see below).\n\nIn jurisdictions which recognize Public Domain property, the user of this \nsoftware may choose to accept it either as 1) Public Domain, 2) under the \nconditions of the MIT License (see below), or 3) under the terms of dual \nPublic Domain/MIT License conditions described here, as they choose.\n\nThe MIT License is about as close to Public Domain as a license can get, and is\ndescribed in clear, concise terms at:\n\n   http://en.wikipedia.org/wiki/MIT_License\n   \nThe full text of the MIT License follows:\n\n========================================================================\nCopyright (c) 2007-2010 Baptiste Lepilleur\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the \"Software\"), to deal in the Software without\nrestriction, including without limitation the rights to use, copy,\nmodify, merge, publish, distribute, sublicense, and/or sell copies\nof the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\nBE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\nACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n========================================================================\n(END LICENSE TEXT)\n\nThe MIT license is compatible with both the GPL and commercial\nsoftware, affording one all of the rights of Public Domain with the\nminor nuisance of being required to keep the above copyright notice\nand license text in the source code. Note also that by accepting the\nPublic Domain \"license\" you can re-license your copy using whatever\nlicense you like.\n\n*/\n\n// //////////////////////////////////////////////////////////////////////\n// End of content of file: LICENSE\n// //////////////////////////////////////////////////////////////////////\n\n\n\n\n\n\n#include \"third_party/jsoncpp/json.h\"\n\n#ifndef JSON_IS_AMALGAMATION\n#error \"Compile with -I PATH_TO_JSON_DIRECTORY\"\n#endif\n\n\n// //////////////////////////////////////////////////////////////////////\n// Beginning of content of file: src/lib_json/json_tool.h\n// //////////////////////////////////////////////////////////////////////\n\n// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#ifndef LIB_JSONCPP_JSON_TOOL_H_INCLUDED\n#define LIB_JSONCPP_JSON_TOOL_H_INCLUDED\n\n/* This header provides common string manipulation support, such as UTF-8,\n * portable conversion from/to string...\n *\n * It is an internal header that must not be exposed.\n */\n\nnamespace Json {\n\n/// Converts a unicode code-point to UTF-8.\nstatic inline std::string codePointToUTF8(unsigned int cp) {\n  std::string result;\n\n  // based on description from http://en.wikipedia.org/wiki/UTF-8\n\n  if (cp <= 0x7f) {\n    result.resize(1);\n    result[0] = static_cast<char>(cp);\n  } else if (cp <= 0x7FF) {\n    result.resize(2);\n    result[1] = static_cast<char>(0x80 | (0x3f & cp));\n    result[0] = static_cast<char>(0xC0 | (0x1f & (cp >> 6)));\n  } else if (cp <= 0xFFFF) {\n    result.resize(3);\n    result[2] = static_cast<char>(0x80 | (0x3f & cp));\n    result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));\n    result[0] = static_cast<char>(0xE0 | (0xf & (cp >> 12)));\n  } else if (cp <= 0x10FFFF) {\n    result.resize(4);\n    result[3] = static_cast<char>(0x80 | (0x3f & cp));\n    result[2] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));\n    result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 12)));\n    result[0] = static_cast<char>(0xF0 | (0x7 & (cp >> 18)));\n  }\n\n  return result;\n}\n\n/// Returns true if ch is a control character (in range [1,31]).\nstatic inline bool isControlCharacter(char ch) { return ch > 0 && ch <= 0x1F; }\n\nenum {\n  /// Constant that specify the size of the buffer that must be passed to\n  /// uintToString.\n  uintToStringBufferSize = 3 * sizeof(LargestUInt) + 1\n};\n\n// Defines a char buffer for use with uintToString().\ntypedef char UIntToStringBuffer[uintToStringBufferSize];\n\n/** Converts an unsigned integer to string.\n * @param value Unsigned interger to convert to string\n * @param current Input/Output string buffer.\n *        Must have at least uintToStringBufferSize chars free.\n */\nstatic inline void uintToString(LargestUInt value, char*& current) {\n  *--current = 0;\n  do {\n    *--current = static_cast<signed char>(value % 10U + static_cast<unsigned>('0'));\n    value /= 10;\n  } while (value != 0);\n}\n\n/** Change ',' to '.' everywhere in buffer.\n *\n * We had a sophisticated way, but it did not work in WinCE.\n * @see https://github.com/open-source-parsers/jsoncpp/pull/9\n */\nstatic inline void fixNumericLocale(char* begin, char* end) {\n  while (begin < end) {\n    if (*begin == ',') {\n      *begin = '.';\n    }\n    ++begin;\n  }\n}\n\n} // namespace Json {\n\n#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED\n\n// //////////////////////////////////////////////////////////////////////\n// End of content of file: src/lib_json/json_tool.h\n// //////////////////////////////////////////////////////////////////////\n\n\n\n\n\n\n// //////////////////////////////////////////////////////////////////////\n// Beginning of content of file: src/lib_json/json_reader.cpp\n// //////////////////////////////////////////////////////////////////////\n\n// Copyright 2007-2011 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include <json/assertions.h>\n#include <json/reader.h>\n#include <json/value.h>\n#include \"json_tool.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <utility>\n#include <cstdio>\n#include <cassert>\n#include <cstring>\n#include <istream>\n#include <sstream>\n#include <memory>\n#include <set>\n#include <limits>\n\n#if defined(_MSC_VER)\n#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above \n#define snprintf sprintf_s\n#elif _MSC_VER >= 1900 // VC++ 14.0 and above\n#define snprintf std::snprintf\n#else\n#define snprintf _snprintf\n#endif\n#elif defined(__ANDROID__) || defined(__QNXNTO__)\n#define snprintf snprintf\n#elif __cplusplus >= 201103L\n#define snprintf std::snprintf\n#endif\n\n#if defined(__QNXNTO__)\n#define sscanf std::sscanf\n#endif\n\n#if defined(_MSC_VER) && _MSC_VER >= 1400 // VC++ 8.0\n// Disable warning about strdup being deprecated.\n#pragma warning(disable : 4996)\n#endif\n\nstatic int const stackLimit_g = 1000;\nstatic int       stackDepth_g = 0;  // see readValue()\n\nnamespace Json {\n\n#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)\ntypedef std::unique_ptr<CharReader> CharReaderPtr;\n#else\ntypedef std::auto_ptr<CharReader>   CharReaderPtr;\n#endif\n\n// Implementation of class Features\n// ////////////////////////////////\n\nFeatures::Features()\n    : allowComments_(true), strictRoot_(false),\n      allowDroppedNullPlaceholders_(false), allowNumericKeys_(false) {}\n\nFeatures Features::all() { return Features(); }\n\nFeatures Features::strictMode() {\n  Features features;\n  features.allowComments_ = false;\n  features.strictRoot_ = true;\n  features.allowDroppedNullPlaceholders_ = false;\n  features.allowNumericKeys_ = false;\n  return features;\n}\n\n// Implementation of class Reader\n// ////////////////////////////////\n\nstatic bool containsNewLine(Reader::Location begin, Reader::Location end) {\n  for (; begin < end; ++begin)\n    if (*begin == '\\n' || *begin == '\\r')\n      return true;\n  return false;\n}\n\n// Class Reader\n// //////////////////////////////////////////////////////////////////\n\nReader::Reader()\n    : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),\n      lastValue_(), commentsBefore_(), features_(Features::all()),\n      collectComments_() {}\n\nReader::Reader(const Features& features)\n    : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),\n      lastValue_(), commentsBefore_(), features_(features), collectComments_() {\n}\n\nbool\nReader::parse(const std::string& document, Value& root, bool collectComments) {\n  document_ = document;\n  const char* begin = document_.c_str();\n  const char* end = begin + document_.length();\n  return parse(begin, end, root, collectComments);\n}\n\nbool Reader::parse(std::istream& sin, Value& root, bool collectComments) {\n  // std::istream_iterator<char> begin(sin);\n  // std::istream_iterator<char> end;\n  // Those would allow streamed input from a file, if parse() were a\n  // template function.\n\n  // Since std::string is reference-counted, this at least does not\n  // create an extra copy.\n  std::string doc;\n  std::getline(sin, doc, (char)EOF);\n  return parse(doc, root, collectComments);\n}\n\nbool Reader::parse(const char* beginDoc,\n                   const char* endDoc,\n                   Value& root,\n                   bool collectComments) {\n  if (!features_.allowComments_) {\n    collectComments = false;\n  }\n\n  begin_ = beginDoc;\n  end_ = endDoc;\n  collectComments_ = collectComments;\n  current_ = begin_;\n  lastValueEnd_ = 0;\n  lastValue_ = 0;\n  commentsBefore_ = \"\";\n  errors_.clear();\n  while (!nodes_.empty())\n    nodes_.pop();\n  nodes_.push(&root);\n\n  stackDepth_g = 0;  // Yes, this is bad coding, but options are limited.\n  bool successful = readValue();\n  Token token;\n  skipCommentTokens(token);\n  if (collectComments_ && !commentsBefore_.empty())\n    root.setComment(commentsBefore_, commentAfter);\n  if (features_.strictRoot_) {\n    if (!root.isArray() && !root.isObject()) {\n      // Set error location to start of doc, ideally should be first token found\n      // in doc\n      token.type_ = tokenError;\n      token.start_ = beginDoc;\n      token.end_ = endDoc;\n      addError(\n          \"A valid JSON document must be either an array or an object value.\",\n          token);\n      return false;\n    }\n  }\n  return successful;\n}\n\nbool Reader::readValue() {\n  // This is a non-reentrant way to support a stackLimit. Terrible!\n  // But this deprecated class has a security problem: Bad input can\n  // cause a seg-fault. This seems like a fair, binary-compatible way\n  // to prevent the problem.\n  if (stackDepth_g >= stackLimit_g) throwRuntimeError(\"Exceeded stackLimit in readValue().\");\n  ++stackDepth_g;\n\n  Token token;\n  skipCommentTokens(token);\n  bool successful = true;\n\n  if (collectComments_ && !commentsBefore_.empty()) {\n    currentValue().setComment(commentsBefore_, commentBefore);\n    commentsBefore_ = \"\";\n  }\n\n  switch (token.type_) {\n  case tokenObjectBegin:\n    successful = readObject(token);\n    currentValue().setOffsetLimit(current_ - begin_);\n    break;\n  case tokenArrayBegin:\n    successful = readArray(token);\n    currentValue().setOffsetLimit(current_ - begin_);\n    break;\n  case tokenNumber:\n    successful = decodeNumber(token);\n    break;\n  case tokenString:\n    successful = decodeString(token);\n    break;\n  case tokenTrue:\n    {\n    Value v(true);\n    currentValue().swapPayload(v);\n    currentValue().setOffsetStart(token.start_ - begin_);\n    currentValue().setOffsetLimit(token.end_ - begin_);\n    }\n    break;\n  case tokenFalse:\n    {\n    Value v(false);\n    currentValue().swapPayload(v);\n    currentValue().setOffsetStart(token.start_ - begin_);\n    currentValue().setOffsetLimit(token.end_ - begin_);\n    }\n    break;\n  case tokenNull:\n    {\n    Value v;\n    currentValue().swapPayload(v);\n    currentValue().setOffsetStart(token.start_ - begin_);\n    currentValue().setOffsetLimit(token.end_ - begin_);\n    }\n    break;\n  case tokenArraySeparator:\n  case tokenObjectEnd:\n  case tokenArrayEnd:\n    if (features_.allowDroppedNullPlaceholders_) {\n      // \"Un-read\" the current token and mark the current value as a null\n      // token.\n      current_--;\n      Value v;\n      currentValue().swapPayload(v);\n      currentValue().setOffsetStart(current_ - begin_ - 1);\n      currentValue().setOffsetLimit(current_ - begin_);\n      break;\n    } // Else, fall through...\n  default:\n    currentValue().setOffsetStart(token.start_ - begin_);\n    currentValue().setOffsetLimit(token.end_ - begin_);\n    return addError(\"Syntax error: value, object or array expected.\", token);\n  }\n\n  if (collectComments_) {\n    lastValueEnd_ = current_;\n    lastValue_ = &currentValue();\n  }\n\n  --stackDepth_g;\n  return successful;\n}\n\nvoid Reader::skipCommentTokens(Token& token) {\n  if (features_.allowComments_) {\n    do {\n      readToken(token);\n    } while (token.type_ == tokenComment);\n  } else {\n    readToken(token);\n  }\n}\n\nbool Reader::readToken(Token& token) {\n  skipSpaces();\n  token.start_ = current_;\n  Char c = getNextChar();\n  bool ok = true;\n  switch (c) {\n  case '{':\n    token.type_ = tokenObjectBegin;\n    break;\n  case '}':\n    token.type_ = tokenObjectEnd;\n    break;\n  case '[':\n    token.type_ = tokenArrayBegin;\n    break;\n  case ']':\n    token.type_ = tokenArrayEnd;\n    break;\n  case '\"':\n    token.type_ = tokenString;\n    ok = readString();\n    break;\n  case '/':\n    token.type_ = tokenComment;\n    ok = readComment();\n    break;\n  case '0':\n  case '1':\n  case '2':\n  case '3':\n  case '4':\n  case '5':\n  case '6':\n  case '7':\n  case '8':\n  case '9':\n  case '-':\n    token.type_ = tokenNumber;\n    readNumber();\n    break;\n  case 't':\n    token.type_ = tokenTrue;\n    ok = match(\"rue\", 3);\n    break;\n  case 'f':\n    token.type_ = tokenFalse;\n    ok = match(\"alse\", 4);\n    break;\n  case 'n':\n    token.type_ = tokenNull;\n    ok = match(\"ull\", 3);\n    break;\n  case ',':\n    token.type_ = tokenArraySeparator;\n    break;\n  case ':':\n    token.type_ = tokenMemberSeparator;\n    break;\n  case 0:\n    token.type_ = tokenEndOfStream;\n    break;\n  default:\n    ok = false;\n    break;\n  }\n  if (!ok)\n    token.type_ = tokenError;\n  token.end_ = current_;\n  return true;\n}\n\nvoid Reader::skipSpaces() {\n  while (current_ != end_) {\n    Char c = *current_;\n    if (c == ' ' || c == '\\t' || c == '\\r' || c == '\\n')\n      ++current_;\n    else\n      break;\n  }\n}\n\nbool Reader::match(Location pattern, int patternLength) {\n  if (end_ - current_ < patternLength)\n    return false;\n  int index = patternLength;\n  while (index--)\n    if (current_[index] != pattern[index])\n      return false;\n  current_ += patternLength;\n  return true;\n}\n\nbool Reader::readComment() {\n  Location commentBegin = current_ - 1;\n  Char c = getNextChar();\n  bool successful = false;\n  if (c == '*')\n    successful = readCStyleComment();\n  else if (c == '/')\n    successful = readCppStyleComment();\n  if (!successful)\n    return false;\n\n  if (collectComments_) {\n    CommentPlacement placement = commentBefore;\n    if (lastValueEnd_ && !containsNewLine(lastValueEnd_, commentBegin)) {\n      if (c != '*' || !containsNewLine(commentBegin, current_))\n        placement = commentAfterOnSameLine;\n    }\n\n    addComment(commentBegin, current_, placement);\n  }\n  return true;\n}\n\nstatic std::string normalizeEOL(Reader::Location begin, Reader::Location end) {\n  std::string normalized;\n  normalized.reserve(end - begin);\n  Reader::Location current = begin;\n  while (current != end) {\n    char c = *current++;\n    if (c == '\\r') {\n      if (current != end && *current == '\\n')\n         // convert dos EOL\n         ++current;\n      // convert Mac EOL\n      normalized += '\\n';\n    } else {\n      normalized += c;\n    }\n  }\n  return normalized;\n}\n\nvoid\nReader::addComment(Location begin, Location end, CommentPlacement placement) {\n  assert(collectComments_);\n  const std::string& normalized = normalizeEOL(begin, end);\n  if (placement == commentAfterOnSameLine) {\n    assert(lastValue_ != 0);\n    lastValue_->setComment(normalized, placement);\n  } else {\n    commentsBefore_ += normalized;\n  }\n}\n\nbool Reader::readCStyleComment() {\n  while (current_ != end_) {\n    Char c = getNextChar();\n    if (c == '*' && *current_ == '/')\n      break;\n  }\n  return getNextChar() == '/';\n}\n\nbool Reader::readCppStyleComment() {\n  while (current_ != end_) {\n    Char c = getNextChar();\n    if (c == '\\n')\n      break;\n    if (c == '\\r') {\n      // Consume DOS EOL. It will be normalized in addComment.\n      if (current_ != end_ && *current_ == '\\n')\n        getNextChar();\n      // Break on Moc OS 9 EOL.\n      break;\n    }\n  }\n  return true;\n}\n\nvoid Reader::readNumber() {\n  const char *p = current_;\n  char c = '0'; // stopgap for already consumed character\n  // integral part\n  while (c >= '0' && c <= '9')\n    c = (current_ = p) < end_ ? *p++ : 0;\n  // fractional part\n  if (c == '.') {\n    c = (current_ = p) < end_ ? *p++ : 0;\n    while (c >= '0' && c <= '9')\n      c = (current_ = p) < end_ ? *p++ : 0;\n  }\n  // exponential part\n  if (c == 'e' || c == 'E') {\n    c = (current_ = p) < end_ ? *p++ : 0;\n    if (c == '+' || c == '-')\n      c = (current_ = p) < end_ ? *p++ : 0;\n    while (c >= '0' && c <= '9')\n      c = (current_ = p) < end_ ? *p++ : 0;\n  }\n}\n\nbool Reader::readString() {\n  Char c = 0;\n  while (current_ != end_) {\n    c = getNextChar();\n    if (c == '\\\\')\n      getNextChar();\n    else if (c == '\"')\n      break;\n  }\n  return c == '\"';\n}\n\nbool Reader::readObject(Token& tokenStart) {\n  Token tokenName;\n  std::string name;\n  Value init(objectValue);\n  currentValue().swapPayload(init);\n  currentValue().setOffsetStart(tokenStart.start_ - begin_);\n  while (readToken(tokenName)) {\n    bool initialTokenOk = true;\n    while (tokenName.type_ == tokenComment && initialTokenOk)\n      initialTokenOk = readToken(tokenName);\n    if (!initialTokenOk)\n      break;\n    if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object\n      return true;\n    name = \"\";\n    if (tokenName.type_ == tokenString) {\n      if (!decodeString(tokenName, name))\n        return recoverFromError(tokenObjectEnd);\n    } else if (tokenName.type_ == tokenNumber && features_.allowNumericKeys_) {\n      Value numberName;\n      if (!decodeNumber(tokenName, numberName))\n        return recoverFromError(tokenObjectEnd);\n      name = numberName.asString();\n    } else {\n      break;\n    }\n\n    Token colon;\n    if (!readToken(colon) || colon.type_ != tokenMemberSeparator) {\n      return addErrorAndRecover(\n          \"Missing ':' after object member name\", colon, tokenObjectEnd);\n    }\n    Value& value = currentValue()[name];\n    nodes_.push(&value);\n    bool ok = readValue();\n    nodes_.pop();\n    if (!ok) // error already set\n      return recoverFromError(tokenObjectEnd);\n\n    Token comma;\n    if (!readToken(comma) ||\n        (comma.type_ != tokenObjectEnd && comma.type_ != tokenArraySeparator &&\n         comma.type_ != tokenComment)) {\n      return addErrorAndRecover(\n          \"Missing ',' or '}' in object declaration\", comma, tokenObjectEnd);\n    }\n    bool finalizeTokenOk = true;\n    while (comma.type_ == tokenComment && finalizeTokenOk)\n      finalizeTokenOk = readToken(comma);\n    if (comma.type_ == tokenObjectEnd)\n      return true;\n  }\n  return addErrorAndRecover(\n      \"Missing '}' or object member name\", tokenName, tokenObjectEnd);\n}\n\nbool Reader::readArray(Token& tokenStart) {\n  Value init(arrayValue);\n  currentValue().swapPayload(init);\n  currentValue().setOffsetStart(tokenStart.start_ - begin_);\n  skipSpaces();\n  if (*current_ == ']') // empty array\n  {\n    Token endArray;\n    readToken(endArray);\n    return true;\n  }\n  int index = 0;\n  for (;;) {\n    Value& value = currentValue()[index++];\n    nodes_.push(&value);\n    bool ok = readValue();\n    nodes_.pop();\n    if (!ok) // error already set\n      return recoverFromError(tokenArrayEnd);\n\n    Token token;\n    // Accept Comment after last item in the array.\n    ok = readToken(token);\n    while (token.type_ == tokenComment && ok) {\n      ok = readToken(token);\n    }\n    bool badTokenType =\n        (token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd);\n    if (!ok || badTokenType) {\n      return addErrorAndRecover(\n          \"Missing ',' or ']' in array declaration\", token, tokenArrayEnd);\n    }\n    if (token.type_ == tokenArrayEnd)\n      break;\n  }\n  return true;\n}\n\nbool Reader::decodeNumber(Token& token) {\n  Value decoded;\n  if (!decodeNumber(token, decoded))\n    return false;\n  currentValue().swapPayload(decoded);\n  currentValue().setOffsetStart(token.start_ - begin_);\n  currentValue().setOffsetLimit(token.end_ - begin_);\n  return true;\n}\n\nbool Reader::decodeNumber(Token& token, Value& decoded) {\n  // Attempts to parse the number as an integer. If the number is\n  // larger than the maximum supported value of an integer then\n  // we decode the number as a double.\n  Location current = token.start_;\n  bool isNegative = *current == '-';\n  if (isNegative)\n    ++current;\n  // TODO: Help the compiler do the div and mod at compile time or get rid of them.\n  Value::LargestUInt maxIntegerValue =\n      isNegative ? Value::LargestUInt(Value::maxLargestInt) + 1\n                 : Value::maxLargestUInt;\n  Value::LargestUInt threshold = maxIntegerValue / 10;\n  Value::LargestUInt value = 0;\n  while (current < token.end_) {\n    Char c = *current++;\n    if (c < '0' || c > '9')\n      return decodeDouble(token, decoded);\n    Value::UInt digit(c - '0');\n    if (value >= threshold) {\n      // We've hit or exceeded the max value divided by 10 (rounded down). If\n      // a) we've only just touched the limit, b) this is the last digit, and\n      // c) it's small enough to fit in that rounding delta, we're okay.\n      // Otherwise treat this number as a double to avoid overflow.\n      if (value > threshold || current != token.end_ ||\n          digit > maxIntegerValue % 10) {\n        return decodeDouble(token, decoded);\n      }\n    }\n    value = value * 10 + digit;\n  }\n  if (isNegative && value == maxIntegerValue)\n    decoded = Value::minLargestInt;\n  else if (isNegative)\n    decoded = -Value::LargestInt(value);\n  else if (value <= Value::LargestUInt(Value::maxInt))\n    decoded = Value::LargestInt(value);\n  else\n    decoded = value;\n  return true;\n}\n\nbool Reader::decodeDouble(Token& token) {\n  Value decoded;\n  if (!decodeDouble(token, decoded))\n    return false;\n  currentValue().swapPayload(decoded);\n  currentValue().setOffsetStart(token.start_ - begin_);\n  currentValue().setOffsetLimit(token.end_ - begin_);\n  return true;\n}\n\nbool Reader::decodeDouble(Token& token, Value& decoded) {\n  double value = 0;\n  std::string buffer(token.start_, token.end_);\n  std::istringstream is(buffer);\n  if (!(is >> value))\n    return addError(\"'\" + std::string(token.start_, token.end_) +\n                        \"' is not a number.\",\n                    token);\n  decoded = value;\n  return true;\n}\n\nbool Reader::decodeString(Token& token) {\n  std::string decoded_string;\n  if (!decodeString(token, decoded_string))\n    return false;\n  Value decoded(decoded_string);\n  currentValue().swapPayload(decoded);\n  currentValue().setOffsetStart(token.start_ - begin_);\n  currentValue().setOffsetLimit(token.end_ - begin_);\n  return true;\n}\n\nbool Reader::decodeString(Token& token, std::string& decoded) {\n  decoded.reserve(token.end_ - token.start_ - 2);\n  Location current = token.start_ + 1; // skip '\"'\n  Location end = token.end_ - 1;       // do not include '\"'\n  while (current != end) {\n    Char c = *current++;\n    if (c == '\"')\n      break;\n    else if (c == '\\\\') {\n      if (current == end)\n        return addError(\"Empty escape sequence in string\", token, current);\n      Char escape = *current++;\n      switch (escape) {\n      case '\"':\n        decoded += '\"';\n        break;\n      case '/':\n        decoded += '/';\n        break;\n      case '\\\\':\n        decoded += '\\\\';\n        break;\n      case 'b':\n        decoded += '\\b';\n        break;\n      case 'f':\n        decoded += '\\f';\n        break;\n      case 'n':\n        decoded += '\\n';\n        break;\n      case 'r':\n        decoded += '\\r';\n        break;\n      case 't':\n        decoded += '\\t';\n        break;\n      case 'u': {\n        unsigned int unicode;\n        if (!decodeUnicodeCodePoint(token, current, end, unicode))\n          return false;\n        decoded += codePointToUTF8(unicode);\n      } break;\n      default:\n        return addError(\"Bad escape sequence in string\", token, current);\n      }\n    } else {\n      decoded += c;\n    }\n  }\n  return true;\n}\n\nbool Reader::decodeUnicodeCodePoint(Token& token,\n                                    Location& current,\n                                    Location end,\n                                    unsigned int& unicode) {\n\n  if (!decodeUnicodeEscapeSequence(token, current, end, unicode))\n    return false;\n  if (unicode >= 0xD800 && unicode <= 0xDBFF) {\n    // surrogate pairs\n    if (end - current < 6)\n      return addError(\n          \"additional six characters expected to parse unicode surrogate pair.\",\n          token,\n          current);\n    unsigned int surrogatePair;\n    if (*(current++) == '\\\\' && *(current++) == 'u') {\n      if (decodeUnicodeEscapeSequence(token, current, end, surrogatePair)) {\n        unicode = 0x10000 + ((unicode & 0x3FF) << 10) + (surrogatePair & 0x3FF);\n      } else\n        return false;\n    } else\n      return addError(\"expecting another \\\\u token to begin the second half of \"\n                      \"a unicode surrogate pair\",\n                      token,\n                      current);\n  }\n  return true;\n}\n\nbool Reader::decodeUnicodeEscapeSequence(Token& token,\n                                         Location& current,\n                                         Location end,\n                                         unsigned int& unicode) {\n  if (end - current < 4)\n    return addError(\n        \"Bad unicode escape sequence in string: four digits expected.\",\n        token,\n        current);\n  unicode = 0;\n  for (int index = 0; index < 4; ++index) {\n    Char c = *current++;\n    unicode *= 16;\n    if (c >= '0' && c <= '9')\n      unicode += c - '0';\n    else if (c >= 'a' && c <= 'f')\n      unicode += c - 'a' + 10;\n    else if (c >= 'A' && c <= 'F')\n      unicode += c - 'A' + 10;\n    else\n      return addError(\n          \"Bad unicode escape sequence in string: hexadecimal digit expected.\",\n          token,\n          current);\n  }\n  return true;\n}\n\nbool\nReader::addError(const std::string& message, Token& token, Location extra) {\n  ErrorInfo info;\n  info.token_ = token;\n  info.message_ = message;\n  info.extra_ = extra;\n  errors_.push_back(info);\n  return false;\n}\n\nbool Reader::recoverFromError(TokenType skipUntilToken) {\n  int errorCount = int(errors_.size());\n  Token skip;\n  for (;;) {\n    if (!readToken(skip))\n      errors_.resize(errorCount); // discard errors caused by recovery\n    if (skip.type_ == skipUntilToken || skip.type_ == tokenEndOfStream)\n      break;\n  }\n  errors_.resize(errorCount);\n  return false;\n}\n\nbool Reader::addErrorAndRecover(const std::string& message,\n                                Token& token,\n                                TokenType skipUntilToken) {\n  addError(message, token);\n  return recoverFromError(skipUntilToken);\n}\n\nValue& Reader::currentValue() { return *(nodes_.top()); }\n\nReader::Char Reader::getNextChar() {\n  if (current_ == end_)\n    return 0;\n  return *current_++;\n}\n\nvoid Reader::getLocationLineAndColumn(Location location,\n                                      int& line,\n                                      int& column) const {\n  Location current = begin_;\n  Location lastLineStart = current;\n  line = 0;\n  while (current < location && current != end_) {\n    Char c = *current++;\n    if (c == '\\r') {\n      if (*current == '\\n')\n        ++current;\n      lastLineStart = current;\n      ++line;\n    } else if (c == '\\n') {\n      lastLineStart = current;\n      ++line;\n    }\n  }\n  // column & line start at 1\n  column = int(location - lastLineStart) + 1;\n  ++line;\n}\n\nstd::string Reader::getLocationLineAndColumn(Location location) const {\n  int line, column;\n  getLocationLineAndColumn(location, line, column);\n  char buffer[18 + 16 + 16 + 1];\n  snprintf(buffer, sizeof(buffer), \"Line %d, Column %d\", line, column);\n  return buffer;\n}\n\n// Deprecated. Preserved for backward compatibility\nstd::string Reader::getFormatedErrorMessages() const {\n  return getFormattedErrorMessages();\n}\n\nstd::string Reader::getFormattedErrorMessages() const {\n  std::string formattedMessage;\n  for (Errors::const_iterator itError = errors_.begin();\n       itError != errors_.end();\n       ++itError) {\n    const ErrorInfo& error = *itError;\n    formattedMessage +=\n        \"* \" + getLocationLineAndColumn(error.token_.start_) + \"\\n\";\n    formattedMessage += \"  \" + error.message_ + \"\\n\";\n    if (error.extra_)\n      formattedMessage +=\n          \"See \" + getLocationLineAndColumn(error.extra_) + \" for detail.\\n\";\n  }\n  return formattedMessage;\n}\n\nstd::vector<Reader::StructuredError> Reader::getStructuredErrors() const {\n  std::vector<Reader::StructuredError> allErrors;\n  for (Errors::const_iterator itError = errors_.begin();\n       itError != errors_.end();\n       ++itError) {\n    const ErrorInfo& error = *itError;\n    Reader::StructuredError structured;\n    structured.offset_start = error.token_.start_ - begin_;\n    structured.offset_limit = error.token_.end_ - begin_;\n    structured.message = error.message_;\n    allErrors.push_back(structured);\n  }\n  return allErrors;\n}\n\nbool Reader::pushError(const Value& value, const std::string& message) {\n  size_t length = end_ - begin_;\n  if(value.getOffsetStart() > length\n    || value.getOffsetLimit() > length)\n    return false;\n  Token token;\n  token.type_ = tokenError;\n  token.start_ = begin_ + value.getOffsetStart();\n  token.end_ = end_ + value.getOffsetLimit();\n  ErrorInfo info;\n  info.token_ = token;\n  info.message_ = message;\n  info.extra_ = 0;\n  errors_.push_back(info);\n  return true;\n}\n\nbool Reader::pushError(const Value& value, const std::string& message, const Value& extra) {\n  size_t length = end_ - begin_;\n  if(value.getOffsetStart() > length\n    || value.getOffsetLimit() > length\n    || extra.getOffsetLimit() > length)\n    return false;\n  Token token;\n  token.type_ = tokenError;\n  token.start_ = begin_ + value.getOffsetStart();\n  token.end_ = begin_ + value.getOffsetLimit();\n  ErrorInfo info;\n  info.token_ = token;\n  info.message_ = message;\n  info.extra_ = begin_ + extra.getOffsetStart();\n  errors_.push_back(info);\n  return true;\n}\n\nbool Reader::good() const {\n  return !errors_.size();\n}\n\n// exact copy of Features\nclass OurFeatures {\npublic:\n  static OurFeatures all();\n  bool allowComments_;\n  bool strictRoot_;\n  bool allowDroppedNullPlaceholders_;\n  bool allowNumericKeys_;\n  bool allowSingleQuotes_;\n  bool failIfExtra_;\n  bool rejectDupKeys_;\n  bool allowSpecialFloats_;\n  int stackLimit_;\n};  // OurFeatures\n\n// exact copy of Implementation of class Features\n// ////////////////////////////////\n\nOurFeatures OurFeatures::all() { return OurFeatures(); }\n\n// Implementation of class Reader\n// ////////////////////////////////\n\n// exact copy of Reader, renamed to OurReader\nclass OurReader {\npublic:\n  typedef char Char;\n  typedef const Char* Location;\n  struct StructuredError {\n    size_t offset_start;\n    size_t offset_limit;\n    std::string message;\n  };\n\n  OurReader(OurFeatures const& features);\n  bool parse(const char* beginDoc,\n             const char* endDoc,\n             Value& root,\n             bool collectComments = true);\n  std::string getFormattedErrorMessages() const;\n  std::vector<StructuredError> getStructuredErrors() const;\n  bool pushError(const Value& value, const std::string& message);\n  bool pushError(const Value& value, const std::string& message, const Value& extra);\n  bool good() const;\n\nprivate:\n  OurReader(OurReader const&);  // no impl\n  void operator=(OurReader const&);  // no impl\n\n  enum TokenType {\n    tokenEndOfStream = 0,\n    tokenObjectBegin,\n    tokenObjectEnd,\n    tokenArrayBegin,\n    tokenArrayEnd,\n    tokenString,\n    tokenNumber,\n    tokenTrue,\n    tokenFalse,\n    tokenNull,\n    tokenNaN,\n    tokenPosInf,\n    tokenNegInf,\n    tokenArraySeparator,\n    tokenMemberSeparator,\n    tokenComment,\n    tokenError\n  };\n\n  class Token {\n  public:\n    TokenType type_;\n    Location start_;\n    Location end_;\n  };\n\n  class ErrorInfo {\n  public:\n    Token token_;\n    std::string message_;\n    Location extra_;\n  };\n\n  typedef std::deque<ErrorInfo> Errors;\n\n  bool readToken(Token& token);\n  void skipSpaces();\n  bool match(Location pattern, int patternLength);\n  bool readComment();\n  bool readCStyleComment();\n  bool readCppStyleComment();\n  bool readString();\n  bool readStringSingleQuote();\n  bool readNumber(bool checkInf);\n  bool readValue();\n  bool readObject(Token& token);\n  bool readArray(Token& token);\n  bool decodeNumber(Token& token);\n  bool decodeNumber(Token& token, Value& decoded);\n  bool decodeString(Token& token);\n  bool decodeString(Token& token, std::string& decoded);\n  bool decodeDouble(Token& token);\n  bool decodeDouble(Token& token, Value& decoded);\n  bool decodeUnicodeCodePoint(Token& token,\n                              Location& current,\n                              Location end,\n                              unsigned int& unicode);\n  bool decodeUnicodeEscapeSequence(Token& token,\n                                   Location& current,\n                                   Location end,\n                                   unsigned int& unicode);\n  bool addError(const std::string& message, Token& token, Location extra = 0);\n  bool recoverFromError(TokenType skipUntilToken);\n  bool addErrorAndRecover(const std::string& message,\n                          Token& token,\n                          TokenType skipUntilToken);\n  void skipUntilSpace();\n  Value& currentValue();\n  Char getNextChar();\n  void\n  getLocationLineAndColumn(Location location, int& line, int& column) const;\n  std::string getLocationLineAndColumn(Location location) const;\n  void addComment(Location begin, Location end, CommentPlacement placement);\n  void skipCommentTokens(Token& token);\n\n  typedef std::stack<Value*> Nodes;\n  Nodes nodes_;\n  Errors errors_;\n  std::string document_;\n  Location begin_;\n  Location end_;\n  Location current_;\n  Location lastValueEnd_;\n  Value* lastValue_;\n  std::string commentsBefore_;\n  int stackDepth_;\n\n  OurFeatures const features_;\n  bool collectComments_;\n};  // OurReader\n\n// complete copy of Read impl, for OurReader\n\nOurReader::OurReader(OurFeatures const& features)\n    : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),\n      lastValue_(), commentsBefore_(),\n      stackDepth_(0),\n      features_(features), collectComments_() {\n}\n\nbool OurReader::parse(const char* beginDoc,\n                   const char* endDoc,\n                   Value& root,\n                   bool collectComments) {\n  if (!features_.allowComments_) {\n    collectComments = false;\n  }\n\n  begin_ = beginDoc;\n  end_ = endDoc;\n  collectComments_ = collectComments;\n  current_ = begin_;\n  lastValueEnd_ = 0;\n  lastValue_ = 0;\n  commentsBefore_ = \"\";\n  errors_.clear();\n  while (!nodes_.empty())\n    nodes_.pop();\n  nodes_.push(&root);\n\n  stackDepth_ = 0;\n  bool successful = readValue();\n  Token token;\n  skipCommentTokens(token);\n  if (features_.failIfExtra_) {\n    if (token.type_ != tokenError && token.type_ != tokenEndOfStream) {\n      addError(\"Extra non-whitespace after JSON value.\", token);\n      return false;\n    }\n  }\n  if (collectComments_ && !commentsBefore_.empty())\n    root.setComment(commentsBefore_, commentAfter);\n  if (features_.strictRoot_) {\n    if (!root.isArray() && !root.isObject()) {\n      // Set error location to start of doc, ideally should be first token found\n      // in doc\n      token.type_ = tokenError;\n      token.start_ = beginDoc;\n      token.end_ = endDoc;\n      addError(\n          \"A valid JSON document must be either an array or an object value.\",\n          token);\n      return false;\n    }\n  }\n  return successful;\n}\n\nbool OurReader::readValue() {\n  if (stackDepth_ >= features_.stackLimit_) throwRuntimeError(\"Exceeded stackLimit in readValue().\");\n  ++stackDepth_;\n  Token token;\n  skipCommentTokens(token);\n  bool successful = true;\n\n  if (collectComments_ && !commentsBefore_.empty()) {\n    currentValue().setComment(commentsBefore_, commentBefore);\n    commentsBefore_ = \"\";\n  }\n\n  switch (token.type_) {\n  case tokenObjectBegin:\n    successful = readObject(token);\n    currentValue().setOffsetLimit(current_ - begin_);\n    break;\n  case tokenArrayBegin:\n    successful = readArray(token);\n    currentValue().setOffsetLimit(current_ - begin_);\n    break;\n  case tokenNumber:\n    successful = decodeNumber(token);\n    break;\n  case tokenString:\n    successful = decodeString(token);\n    break;\n  case tokenTrue:\n    {\n    Value v(true);\n    currentValue().swapPayload(v);\n    currentValue().setOffsetStart(token.start_ - begin_);\n    currentValue().setOffsetLimit(token.end_ - begin_);\n    }\n    break;\n  case tokenFalse:\n    {\n    Value v(false);\n    currentValue().swapPayload(v);\n    currentValue().setOffsetStart(token.start_ - begin_);\n    currentValue().setOffsetLimit(token.end_ - begin_);\n    }\n    break;\n  case tokenNull:\n    {\n    Value v;\n    currentValue().swapPayload(v);\n    currentValue().setOffsetStart(token.start_ - begin_);\n    currentValue().setOffsetLimit(token.end_ - begin_);\n    }\n    break;\n  case tokenNaN:\n    {\n    Value v(std::numeric_limits<double>::quiet_NaN());\n    currentValue().swapPayload(v);\n    currentValue().setOffsetStart(token.start_ - begin_);\n    currentValue().setOffsetLimit(token.end_ - begin_);\n    }\n    break;\n  case tokenPosInf:\n    {\n    Value v(std::numeric_limits<double>::infinity());\n    currentValue().swapPayload(v);\n    currentValue().setOffsetStart(token.start_ - begin_);\n    currentValue().setOffsetLimit(token.end_ - begin_);\n    }\n    break;\n  case tokenNegInf:\n    {\n    Value v(-std::numeric_limits<double>::infinity());\n    currentValue().swapPayload(v);\n    currentValue().setOffsetStart(token.start_ - begin_);\n    currentValue().setOffsetLimit(token.end_ - begin_);\n    }\n    break;\n  case tokenArraySeparator:\n  case tokenObjectEnd:\n  case tokenArrayEnd:\n    if (features_.allowDroppedNullPlaceholders_) {\n      // \"Un-read\" the current token and mark the current value as a null\n      // token.\n      current_--;\n      Value v;\n      currentValue().swapPayload(v);\n      currentValue().setOffsetStart(current_ - begin_ - 1);\n      currentValue().setOffsetLimit(current_ - begin_);\n      break;\n    } // else, fall through ...\n  default:\n    currentValue().setOffsetStart(token.start_ - begin_);\n    currentValue().setOffsetLimit(token.end_ - begin_);\n    return addError(\"Syntax error: value, object or array expected.\", token);\n  }\n\n  if (collectComments_) {\n    lastValueEnd_ = current_;\n    lastValue_ = &currentValue();\n  }\n\n  --stackDepth_;\n  return successful;\n}\n\nvoid OurReader::skipCommentTokens(Token& token) {\n  if (features_.allowComments_) {\n    do {\n      readToken(token);\n    } while (token.type_ == tokenComment);\n  } else {\n    readToken(token);\n  }\n}\n\nbool OurReader::readToken(Token& token) {\n  skipSpaces();\n  token.start_ = current_;\n  Char c = getNextChar();\n  bool ok = true;\n  switch (c) {\n  case '{':\n    token.type_ = tokenObjectBegin;\n    break;\n  case '}':\n    token.type_ = tokenObjectEnd;\n    break;\n  case '[':\n    token.type_ = tokenArrayBegin;\n    break;\n  case ']':\n    token.type_ = tokenArrayEnd;\n    break;\n  case '\"':\n    token.type_ = tokenString;\n    ok = readString();\n    break;\n  case '\\'':\n    if (features_.allowSingleQuotes_) {\n    token.type_ = tokenString;\n    ok = readStringSingleQuote();\n    break;\n    } // else continue\n  case '/':\n    token.type_ = tokenComment;\n    ok = readComment();\n    break;\n  case '0':\n  case '1':\n  case '2':\n  case '3':\n  case '4':\n  case '5':\n  case '6':\n  case '7':\n  case '8':\n  case '9':\n    token.type_ = tokenNumber;\n    readNumber(false);\n    break;\n  case '-':\n    if (readNumber(true)) {\n      token.type_ = tokenNumber;\n    } else {\n      token.type_ = tokenNegInf;\n      ok = features_.allowSpecialFloats_ && match(\"nfinity\", 7);\n    }\n    break;\n  case 't':\n    token.type_ = tokenTrue;\n    ok = match(\"rue\", 3);\n    break;\n  case 'f':\n    token.type_ = tokenFalse;\n    ok = match(\"alse\", 4);\n    break;\n  case 'n':\n    token.type_ = tokenNull;\n    ok = match(\"ull\", 3);\n    break;\n  case 'N':\n    if (features_.allowSpecialFloats_) {\n      token.type_ = tokenNaN;\n      ok = match(\"aN\", 2);\n    } else {\n      ok = false;\n    }\n    break;\n  case 'I':\n    if (features_.allowSpecialFloats_) {\n      token.type_ = tokenPosInf;\n      ok = match(\"nfinity\", 7);\n    } else {\n      ok = false;\n    }\n    break;\n  case ',':\n    token.type_ = tokenArraySeparator;\n    break;\n  case ':':\n    token.type_ = tokenMemberSeparator;\n    break;\n  case 0:\n    token.type_ = tokenEndOfStream;\n    break;\n  default:\n    ok = false;\n    break;\n  }\n  if (!ok)\n    token.type_ = tokenError;\n  token.end_ = current_;\n  return true;\n}\n\nvoid OurReader::skipSpaces() {\n  while (current_ != end_) {\n    Char c = *current_;\n    if (c == ' ' || c == '\\t' || c == '\\r' || c == '\\n')\n      ++current_;\n    else\n      break;\n  }\n}\n\nbool OurReader::match(Location pattern, int patternLength) {\n  if (end_ - current_ < patternLength)\n    return false;\n  int index = patternLength;\n  while (index--)\n    if (current_[index] != pattern[index])\n      return false;\n  current_ += patternLength;\n  return true;\n}\n\nbool OurReader::readComment() {\n  Location commentBegin = current_ - 1;\n  Char c = getNextChar();\n  bool successful = false;\n  if (c == '*')\n    successful = readCStyleComment();\n  else if (c == '/')\n    successful = readCppStyleComment();\n  if (!successful)\n    return false;\n\n  if (collectComments_) {\n    CommentPlacement placement = commentBefore;\n    if (lastValueEnd_ && !containsNewLine(lastValueEnd_, commentBegin)) {\n      if (c != '*' || !containsNewLine(commentBegin, current_))\n        placement = commentAfterOnSameLine;\n    }\n\n    addComment(commentBegin, current_, placement);\n  }\n  return true;\n}\n\nvoid\nOurReader::addComment(Location begin, Location end, CommentPlacement placement) {\n  assert(collectComments_);\n  const std::string& normalized = normalizeEOL(begin, end);\n  if (placement == commentAfterOnSameLine) {\n    assert(lastValue_ != 0);\n    lastValue_->setComment(normalized, placement);\n  } else {\n    commentsBefore_ += normalized;\n  }\n}\n\nbool OurReader::readCStyleComment() {\n  while (current_ != end_) {\n    Char c = getNextChar();\n    if (c == '*' && *current_ == '/')\n      break;\n  }\n  return getNextChar() == '/';\n}\n\nbool OurReader::readCppStyleComment() {\n  while (current_ != end_) {\n    Char c = getNextChar();\n    if (c == '\\n')\n      break;\n    if (c == '\\r') {\n      // Consume DOS EOL. It will be normalized in addComment.\n      if (current_ != end_ && *current_ == '\\n')\n        getNextChar();\n      // Break on Moc OS 9 EOL.\n      break;\n    }\n  }\n  return true;\n}\n\nbool OurReader::readNumber(bool checkInf) {\n  const char *p = current_;\n  if (checkInf && p != end_ && *p == 'I') {\n    current_ = ++p;\n    return false;\n  }\n  char c = '0'; // stopgap for already consumed character\n  // integral part\n  while (c >= '0' && c <= '9')\n    c = (current_ = p) < end_ ? *p++ : 0;\n  // fractional part\n  if (c == '.') {\n    c = (current_ = p) < end_ ? *p++ : 0;\n    while (c >= '0' && c <= '9')\n      c = (current_ = p) < end_ ? *p++ : 0;\n  }\n  // exponential part\n  if (c == 'e' || c == 'E') {\n    c = (current_ = p) < end_ ? *p++ : 0;\n    if (c == '+' || c == '-')\n      c = (current_ = p) < end_ ? *p++ : 0;\n    while (c >= '0' && c <= '9')\n      c = (current_ = p) < end_ ? *p++ : 0;\n  }\n  return true;\n}\nbool OurReader::readString() {\n  Char c = 0;\n  while (current_ != end_) {\n    c = getNextChar();\n    if (c == '\\\\')\n      getNextChar();\n    else if (c == '\"')\n      break;\n  }\n  return c == '\"';\n}\n\n\nbool OurReader::readStringSingleQuote() {\n  Char c = 0;\n  while (current_ != end_) {\n    c = getNextChar();\n    if (c == '\\\\')\n      getNextChar();\n    else if (c == '\\'')\n      break;\n  }\n  return c == '\\'';\n}\n\nbool OurReader::readObject(Token& tokenStart) {\n  Token tokenName;\n  std::string name;\n  Value init(objectValue);\n  currentValue().swapPayload(init);\n  currentValue().setOffsetStart(tokenStart.start_ - begin_);\n  while (readToken(tokenName)) {\n    bool initialTokenOk = true;\n    while (tokenName.type_ == tokenComment && initialTokenOk)\n      initialTokenOk = readToken(tokenName);\n    if (!initialTokenOk)\n      break;\n    if (tokenName.type_ == tokenObjectEnd && name.empty()) // empty object\n      return true;\n    name = \"\";\n    if (tokenName.type_ == tokenString) {\n      if (!decodeString(tokenName, name))\n        return recoverFromError(tokenObjectEnd);\n    } else if (tokenName.type_ == tokenNumber && features_.allowNumericKeys_) {\n      Value numberName;\n      if (!decodeNumber(tokenName, numberName))\n        return recoverFromError(tokenObjectEnd);\n      name = numberName.asString();\n    } else {\n      break;\n    }\n\n    Token colon;\n    if (!readToken(colon) || colon.type_ != tokenMemberSeparator) {\n      return addErrorAndRecover(\n          \"Missing ':' after object member name\", colon, tokenObjectEnd);\n    }\n    if (name.length() >= (1U<<30)) throwRuntimeError(\"keylength >= 2^30\");\n    if (features_.rejectDupKeys_ && currentValue().isMember(name)) {\n      std::string msg = \"Duplicate key: '\" + name + \"'\";\n      return addErrorAndRecover(\n          msg, tokenName, tokenObjectEnd);\n    }\n    Value& value = currentValue()[name];\n    nodes_.push(&value);\n    bool ok = readValue();\n    nodes_.pop();\n    if (!ok) // error already set\n      return recoverFromError(tokenObjectEnd);\n\n    Token comma;\n    if (!readToken(comma) ||\n        (comma.type_ != tokenObjectEnd && comma.type_ != tokenArraySeparator &&\n         comma.type_ != tokenComment)) {\n      return addErrorAndRecover(\n          \"Missing ',' or '}' in object declaration\", comma, tokenObjectEnd);\n    }\n    bool finalizeTokenOk = true;\n    while (comma.type_ == tokenComment && finalizeTokenOk)\n      finalizeTokenOk = readToken(comma);\n    if (comma.type_ == tokenObjectEnd)\n      return true;\n  }\n  return addErrorAndRecover(\n      \"Missing '}' or object member name\", tokenName, tokenObjectEnd);\n}\n\nbool OurReader::readArray(Token& tokenStart) {\n  Value init(arrayValue);\n  currentValue().swapPayload(init);\n  currentValue().setOffsetStart(tokenStart.start_ - begin_);\n  skipSpaces();\n  if (*current_ == ']') // empty array\n  {\n    Token endArray;\n    readToken(endArray);\n    return true;\n  }\n  int index = 0;\n  for (;;) {\n    Value& value = currentValue()[index++];\n    nodes_.push(&value);\n    bool ok = readValue();\n    nodes_.pop();\n    if (!ok) // error already set\n      return recoverFromError(tokenArrayEnd);\n\n    Token token;\n    // Accept Comment after last item in the array.\n    ok = readToken(token);\n    while (token.type_ == tokenComment && ok) {\n      ok = readToken(token);\n    }\n    bool badTokenType =\n        (token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd);\n    if (!ok || badTokenType) {\n      return addErrorAndRecover(\n          \"Missing ',' or ']' in array declaration\", token, tokenArrayEnd);\n    }\n    if (token.type_ == tokenArrayEnd)\n      break;\n  }\n  return true;\n}\n\nbool OurReader::decodeNumber(Token& token) {\n  Value decoded;\n  if (!decodeNumber(token, decoded))\n    return false;\n  currentValue().swapPayload(decoded);\n  currentValue().setOffsetStart(token.start_ - begin_);\n  currentValue().setOffsetLimit(token.end_ - begin_);\n  return true;\n}\n\nbool OurReader::decodeNumber(Token& token, Value& decoded) {\n  // Attempts to parse the number as an integer. If the number is\n  // larger than the maximum supported value of an integer then\n  // we decode the number as a double.\n  Location current = token.start_;\n  bool isNegative = *current == '-';\n  if (isNegative)\n    ++current;\n  // TODO: Help the compiler do the div and mod at compile time or get rid of them.\n  Value::LargestUInt maxIntegerValue =\n      isNegative ? Value::LargestUInt(-Value::minLargestInt)\n                 : Value::maxLargestUInt;\n  Value::LargestUInt threshold = maxIntegerValue / 10;\n  Value::LargestUInt value = 0;\n  while (current < token.end_) {\n    Char c = *current++;\n    if (c < '0' || c > '9')\n      return decodeDouble(token, decoded);\n    Value::UInt digit(c - '0');\n    if (value >= threshold) {\n      // We've hit or exceeded the max value divided by 10 (rounded down). If\n      // a) we've only just touched the limit, b) this is the last digit, and\n      // c) it's small enough to fit in that rounding delta, we're okay.\n      // Otherwise treat this number as a double to avoid overflow.\n      if (value > threshold || current != token.end_ ||\n          digit > maxIntegerValue % 10) {\n        return decodeDouble(token, decoded);\n      }\n    }\n    value = value * 10 + digit;\n  }\n  if (isNegative)\n    decoded = -Value::LargestInt(value);\n  else if (value <= Value::LargestUInt(Value::maxInt))\n    decoded = Value::LargestInt(value);\n  else\n    decoded = value;\n  return true;\n}\n\nbool OurReader::decodeDouble(Token& token) {\n  Value decoded;\n  if (!decodeDouble(token, decoded))\n    return false;\n  currentValue().swapPayload(decoded);\n  currentValue().setOffsetStart(token.start_ - begin_);\n  currentValue().setOffsetLimit(token.end_ - begin_);\n  return true;\n}\n\nbool OurReader::decodeDouble(Token& token, Value& decoded) {\n  double value = 0;\n  const int bufferSize = 32;\n  int count;\n  int length = int(token.end_ - token.start_);\n\n  // Sanity check to avoid buffer overflow exploits.\n  if (length < 0) {\n    return addError(\"Unable to parse token length\", token);\n  }\n\n  // Avoid using a string constant for the format control string given to\n  // sscanf, as this can cause hard to debug crashes on OS X. See here for more\n  // info:\n  //\n  //     http://developer.apple.com/library/mac/#DOCUMENTATION/DeveloperTools/gcc-4.0.1/gcc/Incompatibilities.html\n  char format[] = \"%lf\";\n\n  if (length <= bufferSize) {\n    Char buffer[bufferSize + 1];\n    memcpy(buffer, token.start_, length);\n    buffer[length] = 0;\n    count = sscanf(buffer, format, &value);\n  } else {\n    std::string buffer(token.start_, token.end_);\n    count = sscanf(buffer.c_str(), format, &value);\n  }\n\n  if (count != 1)\n    return addError(\"'\" + std::string(token.start_, token.end_) +\n                        \"' is not a number.\",\n                    token);\n  decoded = value;\n  return true;\n}\n\nbool OurReader::decodeString(Token& token) {\n  std::string decoded_string;\n  if (!decodeString(token, decoded_string))\n    return false;\n  Value decoded(decoded_string);\n  currentValue().swapPayload(decoded);\n  currentValue().setOffsetStart(token.start_ - begin_);\n  currentValue().setOffsetLimit(token.end_ - begin_);\n  return true;\n}\n\nbool OurReader::decodeString(Token& token, std::string& decoded) {\n  decoded.reserve(token.end_ - token.start_ - 2);\n  Location current = token.start_ + 1; // skip '\"'\n  Location end = token.end_ - 1;       // do not include '\"'\n  while (current != end) {\n    Char c = *current++;\n    if (c == '\"')\n      break;\n    else if (c == '\\\\') {\n      if (current == end)\n        return addError(\"Empty escape sequence in string\", token, current);\n      Char escape = *current++;\n      switch (escape) {\n      case '\"':\n        decoded += '\"';\n        break;\n      case '/':\n        decoded += '/';\n        break;\n      case '\\\\':\n        decoded += '\\\\';\n        break;\n      case 'b':\n        decoded += '\\b';\n        break;\n      case 'f':\n        decoded += '\\f';\n        break;\n      case 'n':\n        decoded += '\\n';\n        break;\n      case 'r':\n        decoded += '\\r';\n        break;\n      case 't':\n        decoded += '\\t';\n        break;\n      case 'u': {\n        unsigned int unicode;\n        if (!decodeUnicodeCodePoint(token, current, end, unicode))\n          return false;\n        decoded += codePointToUTF8(unicode);\n      } break;\n      default:\n        return addError(\"Bad escape sequence in string\", token, current);\n      }\n    } else {\n      decoded += c;\n    }\n  }\n  return true;\n}\n\nbool OurReader::decodeUnicodeCodePoint(Token& token,\n                                    Location& current,\n                                    Location end,\n                                    unsigned int& unicode) {\n\n  if (!decodeUnicodeEscapeSequence(token, current, end, unicode))\n    return false;\n  if (unicode >= 0xD800 && unicode <= 0xDBFF) {\n    // surrogate pairs\n    if (end - current < 6)\n      return addError(\n          \"additional six characters expected to parse unicode surrogate pair.\",\n          token,\n          current);\n    unsigned int surrogatePair;\n    if (*(current++) == '\\\\' && *(current++) == 'u') {\n      if (decodeUnicodeEscapeSequence(token, current, end, surrogatePair)) {\n        unicode = 0x10000 + ((unicode & 0x3FF) << 10) + (surrogatePair & 0x3FF);\n      } else\n        return false;\n    } else\n      return addError(\"expecting another \\\\u token to begin the second half of \"\n                      \"a unicode surrogate pair\",\n                      token,\n                      current);\n  }\n  return true;\n}\n\nbool OurReader::decodeUnicodeEscapeSequence(Token& token,\n                                         Location& current,\n                                         Location end,\n                                         unsigned int& unicode) {\n  if (end - current < 4)\n    return addError(\n        \"Bad unicode escape sequence in string: four digits expected.\",\n        token,\n        current);\n  unicode = 0;\n  for (int index = 0; index < 4; ++index) {\n    Char c = *current++;\n    unicode *= 16;\n    if (c >= '0' && c <= '9')\n      unicode += c - '0';\n    else if (c >= 'a' && c <= 'f')\n      unicode += c - 'a' + 10;\n    else if (c >= 'A' && c <= 'F')\n      unicode += c - 'A' + 10;\n    else\n      return addError(\n          \"Bad unicode escape sequence in string: hexadecimal digit expected.\",\n          token,\n          current);\n  }\n  return true;\n}\n\nbool\nOurReader::addError(const std::string& message, Token& token, Location extra) {\n  ErrorInfo info;\n  info.token_ = token;\n  info.message_ = message;\n  info.extra_ = extra;\n  errors_.push_back(info);\n  return false;\n}\n\nbool OurReader::recoverFromError(TokenType skipUntilToken) {\n  int errorCount = int(errors_.size());\n  Token skip;\n  for (;;) {\n    if (!readToken(skip))\n      errors_.resize(errorCount); // discard errors caused by recovery\n    if (skip.type_ == skipUntilToken || skip.type_ == tokenEndOfStream)\n      break;\n  }\n  errors_.resize(errorCount);\n  return false;\n}\n\nbool OurReader::addErrorAndRecover(const std::string& message,\n                                Token& token,\n                                TokenType skipUntilToken) {\n  addError(message, token);\n  return recoverFromError(skipUntilToken);\n}\n\nValue& OurReader::currentValue() { return *(nodes_.top()); }\n\nOurReader::Char OurReader::getNextChar() {\n  if (current_ == end_)\n    return 0;\n  return *current_++;\n}\n\nvoid OurReader::getLocationLineAndColumn(Location location,\n                                      int& line,\n                                      int& column) const {\n  Location current = begin_;\n  Location lastLineStart = current;\n  line = 0;\n  while (current < location && current != end_) {\n    Char c = *current++;\n    if (c == '\\r') {\n      if (*current == '\\n')\n        ++current;\n      lastLineStart = current;\n      ++line;\n    } else if (c == '\\n') {\n      lastLineStart = current;\n      ++line;\n    }\n  }\n  // column & line start at 1\n  column = int(location - lastLineStart) + 1;\n  ++line;\n}\n\nstd::string OurReader::getLocationLineAndColumn(Location location) const {\n  int line, column;\n  getLocationLineAndColumn(location, line, column);\n  char buffer[18 + 16 + 16 + 1];\n  snprintf(buffer, sizeof(buffer), \"Line %d, Column %d\", line, column);\n  return buffer;\n}\n\nstd::string OurReader::getFormattedErrorMessages() const {\n  std::string formattedMessage;\n  for (Errors::const_iterator itError = errors_.begin();\n       itError != errors_.end();\n       ++itError) {\n    const ErrorInfo& error = *itError;\n    formattedMessage +=\n        \"* \" + getLocationLineAndColumn(error.token_.start_) + \"\\n\";\n    formattedMessage += \"  \" + error.message_ + \"\\n\";\n    if (error.extra_)\n      formattedMessage +=\n          \"See \" + getLocationLineAndColumn(error.extra_) + \" for detail.\\n\";\n  }\n  return formattedMessage;\n}\n\nstd::vector<OurReader::StructuredError> OurReader::getStructuredErrors() const {\n  std::vector<OurReader::StructuredError> allErrors;\n  for (Errors::const_iterator itError = errors_.begin();\n       itError != errors_.end();\n       ++itError) {\n    const ErrorInfo& error = *itError;\n    OurReader::StructuredError structured;\n    structured.offset_start = error.token_.start_ - begin_;\n    structured.offset_limit = error.token_.end_ - begin_;\n    structured.message = error.message_;\n    allErrors.push_back(structured);\n  }\n  return allErrors;\n}\n\nbool OurReader::pushError(const Value& value, const std::string& message) {\n  size_t length = end_ - begin_;\n  if(value.getOffsetStart() > length\n    || value.getOffsetLimit() > length)\n    return false;\n  Token token;\n  token.type_ = tokenError;\n  token.start_ = begin_ + value.getOffsetStart();\n  token.end_ = end_ + value.getOffsetLimit();\n  ErrorInfo info;\n  info.token_ = token;\n  info.message_ = message;\n  info.extra_ = 0;\n  errors_.push_back(info);\n  return true;\n}\n\nbool OurReader::pushError(const Value& value, const std::string& message, const Value& extra) {\n  size_t length = end_ - begin_;\n  if(value.getOffsetStart() > length\n    || value.getOffsetLimit() > length\n    || extra.getOffsetLimit() > length)\n    return false;\n  Token token;\n  token.type_ = tokenError;\n  token.start_ = begin_ + value.getOffsetStart();\n  token.end_ = begin_ + value.getOffsetLimit();\n  ErrorInfo info;\n  info.token_ = token;\n  info.message_ = message;\n  info.extra_ = begin_ + extra.getOffsetStart();\n  errors_.push_back(info);\n  return true;\n}\n\nbool OurReader::good() const {\n  return !errors_.size();\n}\n\n\nclass OurCharReader : public CharReader {\n  bool const collectComments_;\n  OurReader reader_;\npublic:\n  OurCharReader(\n    bool collectComments,\n    OurFeatures const& features)\n  : collectComments_(collectComments)\n  , reader_(features)\n  {}\n  bool parse(\n      char const* beginDoc, char const* endDoc,\n      Value* root, std::string* errs) override {\n    bool ok = reader_.parse(beginDoc, endDoc, *root, collectComments_);\n    if (errs) {\n      *errs = reader_.getFormattedErrorMessages();\n    }\n    return ok;\n  }\n};\n\nCharReaderBuilder::CharReaderBuilder()\n{\n  setDefaults(&settings_);\n}\nCharReaderBuilder::~CharReaderBuilder()\n{}\nCharReader* CharReaderBuilder::newCharReader() const\n{\n  bool collectComments = settings_[\"collectComments\"].asBool();\n  OurFeatures features = OurFeatures::all();\n  features.allowComments_ = settings_[\"allowComments\"].asBool();\n  features.strictRoot_ = settings_[\"strictRoot\"].asBool();\n  features.allowDroppedNullPlaceholders_ = settings_[\"allowDroppedNullPlaceholders\"].asBool();\n  features.allowNumericKeys_ = settings_[\"allowNumericKeys\"].asBool();\n  features.allowSingleQuotes_ = settings_[\"allowSingleQuotes\"].asBool();\n  features.stackLimit_ = settings_[\"stackLimit\"].asInt();\n  features.failIfExtra_ = settings_[\"failIfExtra\"].asBool();\n  features.rejectDupKeys_ = settings_[\"rejectDupKeys\"].asBool();\n  features.allowSpecialFloats_ = settings_[\"allowSpecialFloats\"].asBool();\n  return new OurCharReader(collectComments, features);\n}\nstatic void getValidReaderKeys(std::set<std::string>* valid_keys)\n{\n  valid_keys->clear();\n  valid_keys->insert(\"collectComments\");\n  valid_keys->insert(\"allowComments\");\n  valid_keys->insert(\"strictRoot\");\n  valid_keys->insert(\"allowDroppedNullPlaceholders\");\n  valid_keys->insert(\"allowNumericKeys\");\n  valid_keys->insert(\"allowSingleQuotes\");\n  valid_keys->insert(\"stackLimit\");\n  valid_keys->insert(\"failIfExtra\");\n  valid_keys->insert(\"rejectDupKeys\");\n  valid_keys->insert(\"allowSpecialFloats\");\n}\nbool CharReaderBuilder::validate(Json::Value* invalid) const\n{\n  Json::Value my_invalid;\n  if (!invalid) invalid = &my_invalid;  // so we do not need to test for NULL\n  Json::Value& inv = *invalid;\n  std::set<std::string> valid_keys;\n  getValidReaderKeys(&valid_keys);\n  Value::Members keys = settings_.getMemberNames();\n  size_t n = keys.size();\n  for (size_t i = 0; i < n; ++i) {\n    std::string const& key = keys[i];\n    if (valid_keys.find(key) == valid_keys.end()) {\n      inv[key] = settings_[key];\n    }\n  }\n  return 0u == inv.size();\n}\nValue& CharReaderBuilder::operator[](std::string key)\n{\n  return settings_[key];\n}\n// static\nvoid CharReaderBuilder::strictMode(Json::Value* settings)\n{\n//! [CharReaderBuilderStrictMode]\n  (*settings)[\"allowComments\"] = false;\n  (*settings)[\"strictRoot\"] = true;\n  (*settings)[\"allowDroppedNullPlaceholders\"] = false;\n  (*settings)[\"allowNumericKeys\"] = false;\n  (*settings)[\"allowSingleQuotes\"] = false;\n  (*settings)[\"stackLimit\"] = 1000;\n  (*settings)[\"failIfExtra\"] = true;\n  (*settings)[\"rejectDupKeys\"] = true;\n  (*settings)[\"allowSpecialFloats\"] = false;\n//! [CharReaderBuilderStrictMode]\n}\n// static\nvoid CharReaderBuilder::setDefaults(Json::Value* settings)\n{\n//! [CharReaderBuilderDefaults]\n  (*settings)[\"collectComments\"] = true;\n  (*settings)[\"allowComments\"] = true;\n  (*settings)[\"strictRoot\"] = false;\n  (*settings)[\"allowDroppedNullPlaceholders\"] = false;\n  (*settings)[\"allowNumericKeys\"] = false;\n  (*settings)[\"allowSingleQuotes\"] = false;\n  (*settings)[\"stackLimit\"] = 1000;\n  (*settings)[\"failIfExtra\"] = false;\n  (*settings)[\"rejectDupKeys\"] = false;\n  (*settings)[\"allowSpecialFloats\"] = false;\n//! [CharReaderBuilderDefaults]\n}\n\n//////////////////////////////////\n// global functions\n\nbool parseFromStream(\n    CharReader::Factory const& fact, std::istream& sin,\n    Value* root, std::string* errs)\n{\n  std::ostringstream ssin;\n  ssin << sin.rdbuf();\n  std::string doc = ssin.str();\n  char const* begin = doc.data();\n  char const* end = begin + doc.size();\n  // Note that we do not actually need a null-terminator.\n  CharReaderPtr const reader(fact.newCharReader());\n  return reader->parse(begin, end, root, errs);\n}\n\nstd::istream& operator>>(std::istream& sin, Value& root) {\n  CharReaderBuilder b;\n  std::string errs;\n  bool ok = parseFromStream(b, sin, &root, &errs);\n  if (!ok) {\n    fprintf(stderr,\n            \"Error from reader: %s\",\n            errs.c_str());\n\n    throwRuntimeError(errs);\n  }\n  return sin;\n}\n\n} // namespace Json\n\n// //////////////////////////////////////////////////////////////////////\n// End of content of file: src/lib_json/json_reader.cpp\n// //////////////////////////////////////////////////////////////////////\n\n\n\n\n\n\n// //////////////////////////////////////////////////////////////////////\n// Beginning of content of file: src/lib_json/json_valueiterator.inl\n// //////////////////////////////////////////////////////////////////////\n\n// Copyright 2007-2010 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n// included by json_value.cpp\n\nnamespace Json {\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueIteratorBase\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueIteratorBase::ValueIteratorBase()\n    : current_(), isNull_(true) {\n}\n\nValueIteratorBase::ValueIteratorBase(\n    const Value::ObjectValues::iterator& current)\n    : current_(current), isNull_(false) {}\n\nValue& ValueIteratorBase::deref() const {\n  return current_->second;\n}\n\nvoid ValueIteratorBase::increment() {\n  ++current_;\n}\n\nvoid ValueIteratorBase::decrement() {\n  --current_;\n}\n\nValueIteratorBase::difference_type\nValueIteratorBase::computeDistance(const SelfType& other) const {\n#ifdef JSON_USE_CPPTL_SMALLMAP\n  return other.current_ - current_;\n#else\n  // Iterator for null value are initialized using the default\n  // constructor, which initialize current_ to the default\n  // std::map::iterator. As begin() and end() are two instance\n  // of the default std::map::iterator, they can not be compared.\n  // To allow this, we handle this comparison specifically.\n  if (isNull_ && other.isNull_) {\n    return 0;\n  }\n\n  // Usage of std::distance is not portable (does not compile with Sun Studio 12\n  // RogueWave STL,\n  // which is the one used by default).\n  // Using a portable hand-made version for non random iterator instead:\n  //   return difference_type( std::distance( current_, other.current_ ) );\n  difference_type myDistance = 0;\n  for (Value::ObjectValues::iterator it = current_; it != other.current_;\n       ++it) {\n    ++myDistance;\n  }\n  return myDistance;\n#endif\n}\n\nbool ValueIteratorBase::isEqual(const SelfType& other) const {\n  if (isNull_) {\n    return other.isNull_;\n  }\n  return current_ == other.current_;\n}\n\nvoid ValueIteratorBase::copy(const SelfType& other) {\n  current_ = other.current_;\n  isNull_ = other.isNull_;\n}\n\nValue ValueIteratorBase::key() const {\n  const Value::CZString czstring = (*current_).first;\n  if (czstring.data()) {\n    if (czstring.isStaticString())\n      return Value(StaticString(czstring.data()));\n    return Value(czstring.data(), czstring.data() + czstring.length());\n  }\n  return Value(czstring.index());\n}\n\nUInt ValueIteratorBase::index() const {\n  const Value::CZString czstring = (*current_).first;\n  if (!czstring.data())\n    return czstring.index();\n  return Value::UInt(-1);\n}\n\nstd::string ValueIteratorBase::name() const {\n  char const* keey;\n  char const* end;\n  keey = memberName(&end);\n  if (!keey) return std::string();\n  return std::string(keey, end);\n}\n\nchar const* ValueIteratorBase::memberName() const {\n  const char* cname = (*current_).first.data();\n  return cname ? cname : \"\";\n}\n\nchar const* ValueIteratorBase::memberName(char const** end) const {\n  const char* cname = (*current_).first.data();\n  if (!cname) {\n    *end = NULL;\n    return NULL;\n  }\n  *end = cname + (*current_).first.length();\n  return cname;\n}\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueConstIterator\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueConstIterator::ValueConstIterator() {}\n\nValueConstIterator::ValueConstIterator(\n    const Value::ObjectValues::iterator& current)\n    : ValueIteratorBase(current) {}\n\nValueConstIterator::ValueConstIterator(ValueIterator const& other)\n    : ValueIteratorBase(other) {}\n\nValueConstIterator& ValueConstIterator::\noperator=(const ValueIteratorBase& other) {\n  copy(other);\n  return *this;\n}\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class ValueIterator\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValueIterator::ValueIterator() {}\n\nValueIterator::ValueIterator(const Value::ObjectValues::iterator& current)\n    : ValueIteratorBase(current) {}\n\nValueIterator::ValueIterator(const ValueConstIterator& other)\n    : ValueIteratorBase(other) {\n  throwRuntimeError(\"ConstIterator to Iterator should never be allowed.\");\n}\n\nValueIterator::ValueIterator(const ValueIterator& other)\n    : ValueIteratorBase(other) {}\n\nValueIterator& ValueIterator::operator=(const SelfType& other) {\n  copy(other);\n  return *this;\n}\n\n} // namespace Json\n\n// //////////////////////////////////////////////////////////////////////\n// End of content of file: src/lib_json/json_valueiterator.inl\n// //////////////////////////////////////////////////////////////////////\n\n\n\n\n\n\n// //////////////////////////////////////////////////////////////////////\n// Beginning of content of file: src/lib_json/json_value.cpp\n// //////////////////////////////////////////////////////////////////////\n\n// Copyright 2011 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include <json/assertions.h>\n#include <json/value.h>\n#include <json/writer.h>\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <math.h>\n#include <sstream>\n#include <utility>\n#include <cstring>\n#include <cassert>\n#ifdef JSON_USE_CPPTL\n#include <cpptl/conststring.h>\n#endif\n#include <cstddef> // size_t\n#include <algorithm> // min()\n\n#define JSON_ASSERT_UNREACHABLE assert(false)\n\nnamespace Json {\n\n// This is a walkaround to avoid the static initialization of Value::null.\n// kNull must be word-aligned to avoid crashing on ARM.  We use an alignment of\n// 8 (instead of 4) as a bit of future-proofing.\n#if defined(__ARMEL__)\n#define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))\n#else\n#define ALIGNAS(byte_alignment)\n#endif\nstatic const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = { 0 };\nconst unsigned char& kNullRef = kNull[0];\nconst Value& Value::null = reinterpret_cast<const Value&>(kNullRef);\nconst Value& Value::nullRef = null;\n\nconst Int Value::minInt = Int(~(UInt(-1) / 2));\nconst Int Value::maxInt = Int(UInt(-1) / 2);\nconst UInt Value::maxUInt = UInt(-1);\n#if defined(JSON_HAS_INT64)\nconst Int64 Value::minInt64 = Int64(~(UInt64(-1) / 2));\nconst Int64 Value::maxInt64 = Int64(UInt64(-1) / 2);\nconst UInt64 Value::maxUInt64 = UInt64(-1);\n// The constant is hard-coded because some compiler have trouble\n// converting Value::maxUInt64 to a double correctly (AIX/xlC).\n// Assumes that UInt64 is a 64 bits integer.\nstatic const double maxUInt64AsDouble = 18446744073709551615.0;\n#endif // defined(JSON_HAS_INT64)\nconst LargestInt Value::minLargestInt = LargestInt(~(LargestUInt(-1) / 2));\nconst LargestInt Value::maxLargestInt = LargestInt(LargestUInt(-1) / 2);\nconst LargestUInt Value::maxLargestUInt = LargestUInt(-1);\n\n#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)\ntemplate <typename T, typename U>\nstatic inline bool InRange(double d, T min, U max) {\n  return d >= min && d <= max;\n}\n#else  // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)\nstatic inline double integerToDouble(Json::UInt64 value) {\n  return static_cast<double>(Int64(value / 2)) * 2.0 + Int64(value & 1);\n}\n\ntemplate <typename T> static inline double integerToDouble(T value) {\n  return static_cast<double>(value);\n}\n\ntemplate <typename T, typename U>\nstatic inline bool InRange(double d, T min, U max) {\n  return d >= integerToDouble(min) && d <= integerToDouble(max);\n}\n#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)\n\n/** Duplicates the specified string value.\n * @param value Pointer to the string to duplicate. Must be zero-terminated if\n *              length is \"unknown\".\n * @param length Length of the value. if equals to unknown, then it will be\n *               computed using strlen(value).\n * @return Pointer on the duplicate instance of string.\n */\nstatic inline char* duplicateStringValue(const char* value,\n                                         size_t length) {\n  // Avoid an integer overflow in the call to malloc below by limiting length\n  // to a sane value.\n  if (length >= (size_t)Value::maxInt)\n    length = Value::maxInt - 1;\n\n  char* newString = static_cast<char*>(malloc(length + 1));\n  if (newString == NULL) {\n    throwRuntimeError(\n        \"in Json::Value::duplicateStringValue(): \"\n        \"Failed to allocate string value buffer\");\n  }\n  memcpy(newString, value, length);\n  newString[length] = 0;\n  return newString;\n}\n\n/* Record the length as a prefix.\n */\nstatic inline char* duplicateAndPrefixStringValue(\n    const char* value,\n    unsigned int length)\n{\n  // Avoid an integer overflow in the call to malloc below by limiting length\n  // to a sane value.\n  JSON_ASSERT_MESSAGE(length <= (unsigned)Value::maxInt - sizeof(unsigned) - 1U,\n                      \"in Json::Value::duplicateAndPrefixStringValue(): \"\n                      \"length too big for prefixing\");\n  unsigned actualLength = length + static_cast<unsigned>(sizeof(unsigned)) + 1U;\n  char* newString = static_cast<char*>(malloc(actualLength));\n  if (newString == 0) {\n    throwRuntimeError(\n        \"in Json::Value::duplicateAndPrefixStringValue(): \"\n        \"Failed to allocate string value buffer\");\n  }\n  *reinterpret_cast<unsigned*>(newString) = length;\n  memcpy(newString + sizeof(unsigned), value, length);\n  newString[actualLength - 1U] = 0; // to avoid buffer over-run accidents by users later\n  return newString;\n}\ninline static void decodePrefixedString(\n    bool isPrefixed, char const* prefixed,\n    unsigned* length, char const** value)\n{\n  if (!isPrefixed) {\n    *length = static_cast<unsigned>(strlen(prefixed));\n    *value = prefixed;\n  } else {\n    *length = *reinterpret_cast<unsigned const*>(prefixed);\n    *value = prefixed + sizeof(unsigned);\n  }\n}\n/** Free the string duplicated by duplicateStringValue()/duplicateAndPrefixStringValue().\n */\nstatic inline void releaseStringValue(char* value) { free(value); }\n\n} // namespace Json\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// ValueInternals...\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n#if !defined(JSON_IS_AMALGAMATION)\n\n#include \"json_valueiterator.inl\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n\nnamespace Json {\n\nException::Exception(std::string const& msg)\n  : msg_(msg)\n{}\nException::~Exception() throw()\n{}\nchar const* Exception::what() const throw()\n{\n  return msg_.c_str();\n}\nRuntimeError::RuntimeError(std::string const& msg)\n  : Exception(msg)\n{}\nLogicError::LogicError(std::string const& msg)\n  : Exception(msg)\n{}\nvoid throwRuntimeError(std::string const& msg)\n{\n  throw RuntimeError(msg);\n}\nvoid throwLogicError(std::string const& msg)\n{\n  throw LogicError(msg);\n}\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class Value::CommentInfo\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\nValue::CommentInfo::CommentInfo() : comment_(0) {}\n\nValue::CommentInfo::~CommentInfo() {\n  if (comment_)\n    releaseStringValue(comment_);\n}\n\nvoid Value::CommentInfo::setComment(const char* text, size_t len) {\n  if (comment_) {\n    releaseStringValue(comment_);\n    comment_ = 0;\n  }\n  JSON_ASSERT(text != 0);\n  JSON_ASSERT_MESSAGE(\n      text[0] == '\\0' || text[0] == '/',\n      \"in Json::Value::setComment(): Comments must start with /\");\n  // It seems that /**/ style comments are acceptable as well.\n  comment_ = duplicateStringValue(text, len);\n}\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class Value::CZString\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\n// Notes: policy_ indicates if the string was allocated when\n// a string is stored.\n\nValue::CZString::CZString(ArrayIndex aindex) : cstr_(0), index_(aindex) {}\n\nValue::CZString::CZString(char const* str, unsigned ulength, DuplicationPolicy allocate)\n    : cstr_(str) {\n  // allocate != duplicate\n  storage_.policy_ = allocate & 0x3;\n  storage_.length_ = ulength & 0x3FFFFFFF;\n}\n\nValue::CZString::CZString(const CZString& other)\n    : cstr_(other.storage_.policy_ != noDuplication && other.cstr_ != 0\n                ? duplicateStringValue(other.cstr_, other.storage_.length_)\n                : other.cstr_) {\n  storage_.policy_ = (other.cstr_\n                 ? (static_cast<DuplicationPolicy>(other.storage_.policy_) == noDuplication\n                     ? noDuplication : duplicate)\n                 : static_cast<DuplicationPolicy>(other.storage_.policy_));\n  storage_.length_ = other.storage_.length_;\n}\n\n#if JSON_HAS_RVALUE_REFERENCES\nValue::CZString::CZString(CZString&& other)\n  : cstr_(other.cstr_), index_(other.index_) {\n  other.cstr_ = nullptr;\n}\n#endif\n\nValue::CZString::~CZString() {\n  if (cstr_ && storage_.policy_ == duplicate)\n    releaseStringValue(const_cast<char*>(cstr_));\n}\n\nvoid Value::CZString::swap(CZString& other) {\n  std::swap(cstr_, other.cstr_);\n  std::swap(index_, other.index_);\n}\n\nValue::CZString& Value::CZString::operator=(CZString other) {\n  swap(other);\n  return *this;\n}\n\nbool Value::CZString::operator<(const CZString& other) const {\n  if (!cstr_) return index_ < other.index_;\n  //return strcmp(cstr_, other.cstr_) < 0;\n  // Assume both are strings.\n  unsigned this_len = this->storage_.length_;\n  unsigned other_len = other.storage_.length_;\n  unsigned min_len = std::min(this_len, other_len);\n  int comp = memcmp(this->cstr_, other.cstr_, min_len);\n  if (comp < 0) return true;\n  if (comp > 0) return false;\n  return (this_len < other_len);\n}\n\nbool Value::CZString::operator==(const CZString& other) const {\n  if (!cstr_) return index_ == other.index_;\n  //return strcmp(cstr_, other.cstr_) == 0;\n  // Assume both are strings.\n  unsigned this_len = this->storage_.length_;\n  unsigned other_len = other.storage_.length_;\n  if (this_len != other_len) return false;\n  int comp = memcmp(this->cstr_, other.cstr_, this_len);\n  return comp == 0;\n}\n\nArrayIndex Value::CZString::index() const { return index_; }\n\n//const char* Value::CZString::c_str() const { return cstr_; }\nconst char* Value::CZString::data() const { return cstr_; }\nunsigned Value::CZString::length() const { return storage_.length_; }\nbool Value::CZString::isStaticString() const { return storage_.policy_ == noDuplication; }\n\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// class Value::Value\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n// //////////////////////////////////////////////////////////////////\n\n/*! \\internal Default constructor initialization must be equivalent to:\n * memset( this, 0, sizeof(Value) )\n * This optimization is used in ValueInternalMap fast allocator.\n */\nValue::Value(ValueType vtype) {\n  initBasic(vtype);\n  switch (vtype) {\n  case nullValue:\n    break;\n  case intValue:\n  case uintValue:\n    value_.int_ = 0;\n    break;\n  case realValue:\n    value_.real_ = 0.0;\n    break;\n  case stringValue:\n    value_.string_ = 0;\n    break;\n  case arrayValue:\n  case objectValue:\n    value_.map_ = new ObjectValues();\n    break;\n  case booleanValue:\n    value_.bool_ = false;\n    break;\n  default:\n    JSON_ASSERT_UNREACHABLE;\n  }\n}\n\nValue::Value(Int value) {\n  initBasic(intValue);\n  value_.int_ = value;\n}\n\nValue::Value(UInt value) {\n  initBasic(uintValue);\n  value_.uint_ = value;\n}\n#if defined(JSON_HAS_INT64)\nValue::Value(Int64 value) {\n  initBasic(intValue);\n  value_.int_ = value;\n}\nValue::Value(UInt64 value) {\n  initBasic(uintValue);\n  value_.uint_ = value;\n}\n#endif // defined(JSON_HAS_INT64)\n\nValue::Value(double value) {\n  initBasic(realValue);\n  value_.real_ = value;\n}\n\nValue::Value(const char* value) {\n  initBasic(stringValue, true);\n  value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(strlen(value)));\n}\n\nValue::Value(const char* beginValue, const char* endValue) {\n  initBasic(stringValue, true);\n  value_.string_ =\n      duplicateAndPrefixStringValue(beginValue, static_cast<unsigned>(endValue - beginValue));\n}\n\nValue::Value(const std::string& value) {\n  initBasic(stringValue, true);\n  value_.string_ =\n      duplicateAndPrefixStringValue(value.data(), static_cast<unsigned>(value.length()));\n}\n\nValue::Value(const StaticString& value) {\n  initBasic(stringValue);\n  value_.string_ = const_cast<char*>(value.c_str());\n}\n\n#ifdef JSON_USE_CPPTL\nValue::Value(const CppTL::ConstString& value) {\n  initBasic(stringValue, true);\n  value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(value.length()));\n}\n#endif\n\nValue::Value(bool value) {\n  initBasic(booleanValue);\n  value_.bool_ = value;\n}\n\nValue::Value(Value const& other)\n    : type_(other.type_), allocated_(false)\n      ,\n      comments_(0), start_(other.start_), limit_(other.limit_)\n{\n  switch (type_) {\n  case nullValue:\n  case intValue:\n  case uintValue:\n  case realValue:\n  case booleanValue:\n    value_ = other.value_;\n    break;\n  case stringValue:\n    if (other.value_.string_ && other.allocated_) {\n      unsigned len;\n      char const* str;\n      decodePrefixedString(other.allocated_, other.value_.string_,\n          &len, &str);\n      value_.string_ = duplicateAndPrefixStringValue(str, len);\n      allocated_ = true;\n    } else {\n      value_.string_ = other.value_.string_;\n      allocated_ = false;\n    }\n    break;\n  case arrayValue:\n  case objectValue:\n    value_.map_ = new ObjectValues(*other.value_.map_);\n    break;\n  default:\n    JSON_ASSERT_UNREACHABLE;\n  }\n  if (other.comments_) {\n    comments_ = new CommentInfo[numberOfCommentPlacement];\n    for (int comment = 0; comment < numberOfCommentPlacement; ++comment) {\n      const CommentInfo& otherComment = other.comments_[comment];\n      if (otherComment.comment_)\n        comments_[comment].setComment(\n            otherComment.comment_, strlen(otherComment.comment_));\n    }\n  }\n}\n\n#if JSON_HAS_RVALUE_REFERENCES\n// Move constructor\nValue::Value(Value&& other) {\n  initBasic(nullValue);\n  swap(other);\n}\n#endif\n\nValue::~Value() {\n  switch (type_) {\n  case nullValue:\n  case intValue:\n  case uintValue:\n  case realValue:\n  case booleanValue:\n    break;\n  case stringValue:\n    if (allocated_)\n      releaseStringValue(value_.string_);\n    break;\n  case arrayValue:\n  case objectValue:\n    delete value_.map_;\n    break;\n  default:\n    JSON_ASSERT_UNREACHABLE;\n  }\n\n  if (comments_)\n    delete[] comments_;\n}\n\nValue& Value::operator=(Value other) {\n  swap(other);\n  return *this;\n}\n\nvoid Value::swapPayload(Value& other) {\n  ValueType temp = type_;\n  type_ = other.type_;\n  other.type_ = temp;\n  std::swap(value_, other.value_);\n  int temp2 = allocated_;\n  allocated_ = other.allocated_;\n  other.allocated_ = temp2 & 0x1;\n}\n\nvoid Value::swap(Value& other) {\n  swapPayload(other);\n  std::swap(comments_, other.comments_);\n  std::swap(start_, other.start_);\n  std::swap(limit_, other.limit_);\n}\n\nValueType Value::type() const { return type_; }\n\nint Value::compare(const Value& other) const {\n  if (*this < other)\n    return -1;\n  if (*this > other)\n    return 1;\n  return 0;\n}\n\nbool Value::operator<(const Value& other) const {\n  int typeDelta = type_ - other.type_;\n  if (typeDelta)\n    return typeDelta < 0 ? true : false;\n  switch (type_) {\n  case nullValue:\n    return false;\n  case intValue:\n    return value_.int_ < other.value_.int_;\n  case uintValue:\n    return value_.uint_ < other.value_.uint_;\n  case realValue:\n    return value_.real_ < other.value_.real_;\n  case booleanValue:\n    return value_.bool_ < other.value_.bool_;\n  case stringValue:\n  {\n    if ((value_.string_ == 0) || (other.value_.string_ == 0)) {\n      if (other.value_.string_) return true;\n      else return false;\n    }\n    unsigned this_len;\n    unsigned other_len;\n    char const* this_str;\n    char const* other_str;\n    decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);\n    decodePrefixedString(other.allocated_, other.value_.string_, &other_len, &other_str);\n    unsigned min_len = std::min(this_len, other_len);\n    int comp = memcmp(this_str, other_str, min_len);\n    if (comp < 0) return true;\n    if (comp > 0) return false;\n    return (this_len < other_len);\n  }\n  case arrayValue:\n  case objectValue: {\n    int delta = int(value_.map_->size() - other.value_.map_->size());\n    if (delta)\n      return delta < 0;\n    return (*value_.map_) < (*other.value_.map_);\n  }\n  default:\n    JSON_ASSERT_UNREACHABLE;\n  }\n  return false; // unreachable\n}\n\nbool Value::operator<=(const Value& other) const { return !(other < *this); }\n\nbool Value::operator>=(const Value& other) const { return !(*this < other); }\n\nbool Value::operator>(const Value& other) const { return other < *this; }\n\nbool Value::operator==(const Value& other) const {\n  // if ( type_ != other.type_ )\n  // GCC 2.95.3 says:\n  // attempt to take address of bit-field structure member `Json::Value::type_'\n  // Beats me, but a temp solves the problem.\n  int temp = other.type_;\n  if (type_ != temp)\n    return false;\n  switch (type_) {\n  case nullValue:\n    return true;\n  case intValue:\n    return value_.int_ == other.value_.int_;\n  case uintValue:\n    return value_.uint_ == other.value_.uint_;\n  case realValue:\n    return value_.real_ == other.value_.real_;\n  case booleanValue:\n    return value_.bool_ == other.value_.bool_;\n  case stringValue:\n  {\n    if ((value_.string_ == 0) || (other.value_.string_ == 0)) {\n      return (value_.string_ == other.value_.string_);\n    }\n    unsigned this_len;\n    unsigned other_len;\n    char const* this_str;\n    char const* other_str;\n    decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);\n    decodePrefixedString(other.allocated_, other.value_.string_, &other_len, &other_str);\n    if (this_len != other_len) return false;\n    int comp = memcmp(this_str, other_str, this_len);\n    return comp == 0;\n  }\n  case arrayValue:\n  case objectValue:\n    return value_.map_->size() == other.value_.map_->size() &&\n           (*value_.map_) == (*other.value_.map_);\n  default:\n    JSON_ASSERT_UNREACHABLE;\n  }\n  return false; // unreachable\n}\n\nbool Value::operator!=(const Value& other) const { return !(*this == other); }\n\nconst char* Value::asCString() const {\n  JSON_ASSERT_MESSAGE(type_ == stringValue,\n                      \"in Json::Value::asCString(): requires stringValue\");\n  if (value_.string_ == 0) return 0;\n  unsigned this_len;\n  char const* this_str;\n  decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);\n  return this_str;\n}\n\nbool Value::getString(char const** str, char const** cend) const {\n  if (type_ != stringValue) return false;\n  if (value_.string_ == 0) return false;\n  unsigned length;\n  decodePrefixedString(this->allocated_, this->value_.string_, &length, str);\n  *cend = *str + length;\n  return true;\n}\n\nstd::string Value::asString() const {\n  switch (type_) {\n  case nullValue:\n    return \"\";\n  case stringValue:\n  {\n    if (value_.string_ == 0) return \"\";\n    unsigned this_len;\n    char const* this_str;\n    decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);\n    return std::string(this_str, this_len);\n  }\n  case booleanValue:\n    return value_.bool_ ? \"true\" : \"false\";\n  case intValue:\n    return valueToString(value_.int_);\n  case uintValue:\n    return valueToString(value_.uint_);\n  case realValue:\n    return valueToString(value_.real_);\n  default:\n    JSON_FAIL_MESSAGE(\"Type is not convertible to string\");\n  }\n}\n\n#ifdef JSON_USE_CPPTL\nCppTL::ConstString Value::asConstString() const {\n  unsigned len;\n  char const* str;\n  decodePrefixedString(allocated_, value_.string_,\n      &len, &str);\n  return CppTL::ConstString(str, len);\n}\n#endif\n\nValue::Int Value::asInt() const {\n  switch (type_) {\n  case intValue:\n    JSON_ASSERT_MESSAGE(isInt(), \"LargestInt out of Int range\");\n    return Int(value_.int_);\n  case uintValue:\n    JSON_ASSERT_MESSAGE(isInt(), \"LargestUInt out of Int range\");\n    return Int(value_.uint_);\n  case realValue:\n    JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt, maxInt),\n                        \"double out of Int range\");\n    return Int(value_.real_);\n  case nullValue:\n    return 0;\n  case booleanValue:\n    return value_.bool_ ? 1 : 0;\n  default:\n    break;\n  }\n  JSON_FAIL_MESSAGE(\"Value is not convertible to Int.\");\n}\n\nValue::UInt Value::asUInt() const {\n  switch (type_) {\n  case intValue:\n    JSON_ASSERT_MESSAGE(isUInt(), \"LargestInt out of UInt range\");\n    return UInt(value_.int_);\n  case uintValue:\n    JSON_ASSERT_MESSAGE(isUInt(), \"LargestUInt out of UInt range\");\n    return UInt(value_.uint_);\n  case realValue:\n    JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt),\n                        \"double out of UInt range\");\n    return UInt(value_.real_);\n  case nullValue:\n    return 0;\n  case booleanValue:\n    return value_.bool_ ? 1 : 0;\n  default:\n    break;\n  }\n  JSON_FAIL_MESSAGE(\"Value is not convertible to UInt.\");\n}\n\n#if defined(JSON_HAS_INT64)\n\nValue::Int64 Value::asInt64() const {\n  switch (type_) {\n  case intValue:\n    return Int64(value_.int_);\n  case uintValue:\n    JSON_ASSERT_MESSAGE(isInt64(), \"LargestUInt out of Int64 range\");\n    return Int64(value_.uint_);\n  case realValue:\n    JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt64, maxInt64),\n                        \"double out of Int64 range\");\n    return Int64(value_.real_);\n  case nullValue:\n    return 0;\n  case booleanValue:\n    return value_.bool_ ? 1 : 0;\n  default:\n    break;\n  }\n  JSON_FAIL_MESSAGE(\"Value is not convertible to Int64.\");\n}\n\nValue::UInt64 Value::asUInt64() const {\n  switch (type_) {\n  case intValue:\n    JSON_ASSERT_MESSAGE(isUInt64(), \"LargestInt out of UInt64 range\");\n    return UInt64(value_.int_);\n  case uintValue:\n    return UInt64(value_.uint_);\n  case realValue:\n    JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt64),\n                        \"double out of UInt64 range\");\n    return UInt64(value_.real_);\n  case nullValue:\n    return 0;\n  case booleanValue:\n    return value_.bool_ ? 1 : 0;\n  default:\n    break;\n  }\n  JSON_FAIL_MESSAGE(\"Value is not convertible to UInt64.\");\n}\n#endif // if defined(JSON_HAS_INT64)\n\nLargestInt Value::asLargestInt() const {\n#if defined(JSON_NO_INT64)\n  return asInt();\n#else\n  return asInt64();\n#endif\n}\n\nLargestUInt Value::asLargestUInt() const {\n#if defined(JSON_NO_INT64)\n  return asUInt();\n#else\n  return asUInt64();\n#endif\n}\n\ndouble Value::asDouble() const {\n  switch (type_) {\n  case intValue:\n    return static_cast<double>(value_.int_);\n  case uintValue:\n#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)\n    return static_cast<double>(value_.uint_);\n#else  // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)\n    return integerToDouble(value_.uint_);\n#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)\n  case realValue:\n    return value_.real_;\n  case nullValue:\n    return 0.0;\n  case booleanValue:\n    return value_.bool_ ? 1.0 : 0.0;\n  default:\n    break;\n  }\n  JSON_FAIL_MESSAGE(\"Value is not convertible to double.\");\n}\n\nfloat Value::asFloat() const {\n  switch (type_) {\n  case intValue:\n    return static_cast<float>(value_.int_);\n  case uintValue:\n#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)\n    return static_cast<float>(value_.uint_);\n#else  // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)\n    return integerToDouble(value_.uint_);\n#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)\n  case realValue:\n    return static_cast<float>(value_.real_);\n  case nullValue:\n    return 0.0;\n  case booleanValue:\n    return value_.bool_ ? 1.0f : 0.0f;\n  default:\n    break;\n  }\n  JSON_FAIL_MESSAGE(\"Value is not convertible to float.\");\n}\n\nbool Value::asBool() const {\n  switch (type_) {\n  case booleanValue:\n    return value_.bool_;\n  case nullValue:\n    return false;\n  case intValue:\n    return value_.int_ ? true : false;\n  case uintValue:\n    return value_.uint_ ? true : false;\n  case realValue:\n    // This is kind of strange. Not recommended.\n    return (value_.real_ != 0.0) ? true : false;\n  default:\n    break;\n  }\n  JSON_FAIL_MESSAGE(\"Value is not convertible to bool.\");\n}\n\nbool Value::isConvertibleTo(ValueType other) const {\n  switch (other) {\n  case nullValue:\n    return (isNumeric() && asDouble() == 0.0) ||\n           (type_ == booleanValue && value_.bool_ == false) ||\n           (type_ == stringValue && asString() == \"\") ||\n           (type_ == arrayValue && value_.map_->size() == 0) ||\n           (type_ == objectValue && value_.map_->size() == 0) ||\n           type_ == nullValue;\n  case intValue:\n    return isInt() ||\n           (type_ == realValue && InRange(value_.real_, minInt, maxInt)) ||\n           type_ == booleanValue || type_ == nullValue;\n  case uintValue:\n    return isUInt() ||\n           (type_ == realValue && InRange(value_.real_, 0, maxUInt)) ||\n           type_ == booleanValue || type_ == nullValue;\n  case realValue:\n    return isNumeric() || type_ == booleanValue || type_ == nullValue;\n  case booleanValue:\n    return isNumeric() || type_ == booleanValue || type_ == nullValue;\n  case stringValue:\n    return isNumeric() || type_ == booleanValue || type_ == stringValue ||\n           type_ == nullValue;\n  case arrayValue:\n    return type_ == arrayValue || type_ == nullValue;\n  case objectValue:\n    return type_ == objectValue || type_ == nullValue;\n  }\n  JSON_ASSERT_UNREACHABLE;\n  return false;\n}\n\n/// Number of values in array or object\nArrayIndex Value::size() const {\n  switch (type_) {\n  case nullValue:\n  case intValue:\n  case uintValue:\n  case realValue:\n  case booleanValue:\n  case stringValue:\n    return 0;\n  case arrayValue: // size of the array is highest index + 1\n    if (!value_.map_->empty()) {\n      ObjectValues::const_iterator itLast = value_.map_->end();\n      --itLast;\n      return (*itLast).first.index() + 1;\n    }\n    return 0;\n  case objectValue:\n    return ArrayIndex(value_.map_->size());\n  }\n  JSON_ASSERT_UNREACHABLE;\n  return 0; // unreachable;\n}\n\nbool Value::empty() const {\n  if (isNull() || isArray() || isObject())\n    return size() == 0u;\n  else\n    return false;\n}\n\nbool Value::operator!() const { return isNull(); }\n\nvoid Value::clear() {\n  JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == arrayValue ||\n                          type_ == objectValue,\n                      \"in Json::Value::clear(): requires complex value\");\n  start_ = 0;\n  limit_ = 0;\n  switch (type_) {\n  case arrayValue:\n  case objectValue:\n    value_.map_->clear();\n    break;\n  default:\n    break;\n  }\n}\n\nvoid Value::resize(ArrayIndex newSize) {\n  JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == arrayValue,\n                      \"in Json::Value::resize(): requires arrayValue\");\n  if (type_ == nullValue)\n    *this = Value(arrayValue);\n  ArrayIndex oldSize = size();\n  if (newSize == 0)\n    clear();\n  else if (newSize > oldSize)\n    (*this)[newSize - 1];\n  else {\n    for (ArrayIndex index = newSize; index < oldSize; ++index) {\n      value_.map_->erase(index);\n    }\n    assert(size() == newSize);\n  }\n}\n\nValue& Value::operator[](ArrayIndex index) {\n  JSON_ASSERT_MESSAGE(\n      type_ == nullValue || type_ == arrayValue,\n      \"in Json::Value::operator[](ArrayIndex): requires arrayValue\");\n  if (type_ == nullValue)\n    *this = Value(arrayValue);\n  CZString key(index);\n  ObjectValues::iterator it = value_.map_->lower_bound(key);\n  if (it != value_.map_->end() && (*it).first == key)\n    return (*it).second;\n\n  ObjectValues::value_type defaultValue(key, nullRef);\n  it = value_.map_->insert(it, defaultValue);\n  return (*it).second;\n}\n\nValue& Value::operator[](int index) {\n  JSON_ASSERT_MESSAGE(\n      index >= 0,\n      \"in Json::Value::operator[](int index): index cannot be negative\");\n  return (*this)[ArrayIndex(index)];\n}\n\nconst Value& Value::operator[](ArrayIndex index) const {\n  JSON_ASSERT_MESSAGE(\n      type_ == nullValue || type_ == arrayValue,\n      \"in Json::Value::operator[](ArrayIndex)const: requires arrayValue\");\n  if (type_ == nullValue)\n    return nullRef;\n  CZString key(index);\n  ObjectValues::const_iterator it = value_.map_->find(key);\n  if (it == value_.map_->end())\n    return nullRef;\n  return (*it).second;\n}\n\nconst Value& Value::operator[](int index) const {\n  JSON_ASSERT_MESSAGE(\n      index >= 0,\n      \"in Json::Value::operator[](int index) const: index cannot be negative\");\n  return (*this)[ArrayIndex(index)];\n}\n\nvoid Value::initBasic(ValueType vtype, bool allocated) {\n  type_ = vtype;\n  allocated_ = allocated;\n  comments_ = 0;\n  start_ = 0;\n  limit_ = 0;\n}\n\n// Access an object value by name, create a null member if it does not exist.\n// @pre Type of '*this' is object or null.\n// @param key is null-terminated.\nValue& Value::resolveReference(const char* key) {\n  JSON_ASSERT_MESSAGE(\n      type_ == nullValue || type_ == objectValue,\n      \"in Json::Value::resolveReference(): requires objectValue\");\n  if (type_ == nullValue)\n    *this = Value(objectValue);\n  CZString actualKey(\n      key, static_cast<unsigned>(strlen(key)), CZString::noDuplication); // NOTE!\n  ObjectValues::iterator it = value_.map_->lower_bound(actualKey);\n  if (it != value_.map_->end() && (*it).first == actualKey)\n    return (*it).second;\n\n  ObjectValues::value_type defaultValue(actualKey, nullRef);\n  it = value_.map_->insert(it, defaultValue);\n  Value& value = (*it).second;\n  return value;\n}\n\n// @param key is not null-terminated.\nValue& Value::resolveReference(char const* key, char const* cend)\n{\n  JSON_ASSERT_MESSAGE(\n      type_ == nullValue || type_ == objectValue,\n      \"in Json::Value::resolveReference(key, end): requires objectValue\");\n  if (type_ == nullValue)\n    *this = Value(objectValue);\n  CZString actualKey(\n      key, static_cast<unsigned>(cend-key), CZString::duplicateOnCopy);\n  ObjectValues::iterator it = value_.map_->lower_bound(actualKey);\n  if (it != value_.map_->end() && (*it).first == actualKey)\n    return (*it).second;\n\n  ObjectValues::value_type defaultValue(actualKey, nullRef);\n  it = value_.map_->insert(it, defaultValue);\n  Value& value = (*it).second;\n  return value;\n}\n\nValue Value::get(ArrayIndex index, const Value& defaultValue) const {\n  const Value* value = &((*this)[index]);\n  return value == &nullRef ? defaultValue : *value;\n}\n\nbool Value::isValidIndex(ArrayIndex index) const { return index < size(); }\n\nValue const* Value::find(char const* key, char const* cend) const\n{\n  JSON_ASSERT_MESSAGE(\n      type_ == nullValue || type_ == objectValue,\n      \"in Json::Value::find(key, end, found): requires objectValue or nullValue\");\n  if (type_ == nullValue) return NULL;\n  CZString actualKey(key, static_cast<unsigned>(cend-key), CZString::noDuplication);\n  ObjectValues::const_iterator it = value_.map_->find(actualKey);\n  if (it == value_.map_->end()) return NULL;\n  return &(*it).second;\n}\nconst Value& Value::operator[](const char* key) const\n{\n  Value const* found = find(key, key + strlen(key));\n  if (!found) return nullRef;\n  return *found;\n}\nValue const& Value::operator[](std::string const& key) const\n{\n  Value const* found = find(key.data(), key.data() + key.length());\n  if (!found) return nullRef;\n  return *found;\n}\n\nValue& Value::operator[](const char* key) {\n  return resolveReference(key, key + strlen(key));\n}\n\nValue& Value::operator[](const std::string& key) {\n  return resolveReference(key.data(), key.data() + key.length());\n}\n\nValue& Value::operator[](const StaticString& key) {\n  return resolveReference(key.c_str());\n}\n\n#ifdef JSON_USE_CPPTL\nValue& Value::operator[](const CppTL::ConstString& key) {\n  return resolveReference(key.c_str(), key.end_c_str());\n}\nValue const& Value::operator[](CppTL::ConstString const& key) const\n{\n  Value const* found = find(key.c_str(), key.end_c_str());\n  if (!found) return nullRef;\n  return *found;\n}\n#endif\n\nValue& Value::append(const Value& value) { return (*this)[size()] = value; }\n\nValue Value::get(char const* key, char const* cend, Value const& defaultValue) const\n{\n  Value const* found = find(key, cend);\n  return !found ? defaultValue : *found;\n}\nValue Value::get(char const* key, Value const& defaultValue) const\n{\n  return get(key, key + strlen(key), defaultValue);\n}\nValue Value::get(std::string const& key, Value const& defaultValue) const\n{\n  return get(key.data(), key.data() + key.length(), defaultValue);\n}\n\n\nbool Value::removeMember(const char* key, const char* cend, Value* removed)\n{\n  if (type_ != objectValue) {\n    return false;\n  }\n  CZString actualKey(key, static_cast<unsigned>(cend-key), CZString::noDuplication);\n  ObjectValues::iterator it = value_.map_->find(actualKey);\n  if (it == value_.map_->end())\n    return false;\n  *removed = it->second;\n  value_.map_->erase(it);\n  return true;\n}\nbool Value::removeMember(const char* key, Value* removed)\n{\n  return removeMember(key, key + strlen(key), removed);\n}\nbool Value::removeMember(std::string const& key, Value* removed)\n{\n  return removeMember(key.data(), key.data() + key.length(), removed);\n}\nValue Value::removeMember(const char* key)\n{\n  JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue,\n                      \"in Json::Value::removeMember(): requires objectValue\");\n  if (type_ == nullValue)\n    return nullRef;\n\n  Value removed;  // null\n  removeMember(key, key + strlen(key), &removed);\n  return removed; // still null if removeMember() did nothing\n}\nValue Value::removeMember(const std::string& key)\n{\n  return removeMember(key.c_str());\n}\n\nbool Value::removeIndex(ArrayIndex index, Value* removed) {\n  if (type_ != arrayValue) {\n    return false;\n  }\n  CZString key(index);\n  ObjectValues::iterator it = value_.map_->find(key);\n  if (it == value_.map_->end()) {\n    return false;\n  }\n  *removed = it->second;\n  ArrayIndex oldSize = size();\n  // shift left all items left, into the place of the \"removed\"\n  for (ArrayIndex i = index; i < (oldSize - 1); ++i){\n    CZString keey(i);\n    (*value_.map_)[keey] = (*this)[i + 1];\n  }\n  // erase the last one (\"leftover\")\n  CZString keyLast(oldSize - 1);\n  ObjectValues::iterator itLast = value_.map_->find(keyLast);\n  value_.map_->erase(itLast);\n  return true;\n}\n\n#ifdef JSON_USE_CPPTL\nValue Value::get(const CppTL::ConstString& key,\n                 const Value& defaultValue) const {\n  return get(key.c_str(), key.end_c_str(), defaultValue);\n}\n#endif\n\nbool Value::isMember(char const* key, char const* cend) const\n{\n  Value const* value = find(key, cend);\n  return NULL != value;\n}\nbool Value::isMember(char const* key) const\n{\n  return isMember(key, key + strlen(key));\n}\nbool Value::isMember(std::string const& key) const\n{\n  return isMember(key.data(), key.data() + key.length());\n}\n\n#ifdef JSON_USE_CPPTL\nbool Value::isMember(const CppTL::ConstString& key) const {\n  return isMember(key.c_str(), key.end_c_str());\n}\n#endif\n\nValue::Members Value::getMemberNames() const {\n  JSON_ASSERT_MESSAGE(\n      type_ == nullValue || type_ == objectValue,\n      \"in Json::Value::getMemberNames(), value must be objectValue\");\n  if (type_ == nullValue)\n    return Value::Members();\n  Members members;\n  members.reserve(value_.map_->size());\n  ObjectValues::const_iterator it = value_.map_->begin();\n  ObjectValues::const_iterator itEnd = value_.map_->end();\n  for (; it != itEnd; ++it) {\n    members.push_back(std::string((*it).first.data(),\n                                  (*it).first.length()));\n  }\n  return members;\n}\n//\n//# ifdef JSON_USE_CPPTL\n// EnumMemberNames\n// Value::enumMemberNames() const\n//{\n//   if ( type_ == objectValue )\n//   {\n//      return CppTL::Enum::any(  CppTL::Enum::transform(\n//         CppTL::Enum::keys( *(value_.map_), CppTL::Type<const CZString &>() ),\n//         MemberNamesTransform() ) );\n//   }\n//   return EnumMemberNames();\n//}\n//\n//\n// EnumValues\n// Value::enumValues() const\n//{\n//   if ( type_ == objectValue  ||  type_ == arrayValue )\n//      return CppTL::Enum::anyValues( *(value_.map_),\n//                                     CppTL::Type<const Value &>() );\n//   return EnumValues();\n//}\n//\n//# endif\n\nstatic bool IsIntegral(double d) {\n  double integral_part;\n  return modf(d, &integral_part) == 0.0;\n}\n\nbool Value::isNull() const { return type_ == nullValue; }\n\nbool Value::isBool() const { return type_ == booleanValue; }\n\nbool Value::isInt() const {\n  switch (type_) {\n  case intValue:\n    return value_.int_ >= minInt && value_.int_ <= maxInt;\n  case uintValue:\n    return value_.uint_ <= UInt(maxInt);\n  case realValue:\n    return value_.real_ >= minInt && value_.real_ <= maxInt &&\n           IsIntegral(value_.real_);\n  default:\n    break;\n  }\n  return false;\n}\n\nbool Value::isUInt() const {\n  switch (type_) {\n  case intValue:\n    return value_.int_ >= 0 && LargestUInt(value_.int_) <= LargestUInt(maxUInt);\n  case uintValue:\n    return value_.uint_ <= maxUInt;\n  case realValue:\n    return value_.real_ >= 0 && value_.real_ <= maxUInt &&\n           IsIntegral(value_.real_);\n  default:\n    break;\n  }\n  return false;\n}\n\nbool Value::isInt64() const {\n#if defined(JSON_HAS_INT64)\n  switch (type_) {\n  case intValue:\n    return true;\n  case uintValue:\n    return value_.uint_ <= UInt64(maxInt64);\n  case realValue:\n    // Note that maxInt64 (= 2^63 - 1) is not exactly representable as a\n    // double, so double(maxInt64) will be rounded up to 2^63. Therefore we\n    // require the value to be strictly less than the limit.\n    return value_.real_ >= double(minInt64) &&\n           value_.real_ < double(maxInt64) && IsIntegral(value_.real_);\n  default:\n    break;\n  }\n#endif // JSON_HAS_INT64\n  return false;\n}\n\nbool Value::isUInt64() const {\n#if defined(JSON_HAS_INT64)\n  switch (type_) {\n  case intValue:\n    return value_.int_ >= 0;\n  case uintValue:\n    return true;\n  case realValue:\n    // Note that maxUInt64 (= 2^64 - 1) is not exactly representable as a\n    // double, so double(maxUInt64) will be rounded up to 2^64. Therefore we\n    // require the value to be strictly less than the limit.\n    return value_.real_ >= 0 && value_.real_ < maxUInt64AsDouble &&\n           IsIntegral(value_.real_);\n  default:\n    break;\n  }\n#endif // JSON_HAS_INT64\n  return false;\n}\n\nbool Value::isIntegral() const {\n#if defined(JSON_HAS_INT64)\n  return isInt64() || isUInt64();\n#else\n  return isInt() || isUInt();\n#endif\n}\n\nbool Value::isDouble() const { return type_ == realValue || isIntegral(); }\n\nbool Value::isNumeric() const { return isIntegral() || isDouble(); }\n\nbool Value::isString() const { return type_ == stringValue; }\n\nbool Value::isArray() const { return type_ == arrayValue; }\n\nbool Value::isObject() const { return type_ == objectValue; }\n\nvoid Value::setComment(const char* comment, size_t len, CommentPlacement placement) {\n  if (!comments_)\n    comments_ = new CommentInfo[numberOfCommentPlacement];\n  if ((len > 0) && (comment[len-1] == '\\n')) {\n    // Always discard trailing newline, to aid indentation.\n    len -= 1;\n  }\n  comments_[placement].setComment(comment, len);\n}\n\nvoid Value::setComment(const char* comment, CommentPlacement placement) {\n  setComment(comment, strlen(comment), placement);\n}\n\nvoid Value::setComment(const std::string& comment, CommentPlacement placement) {\n  setComment(comment.c_str(), comment.length(), placement);\n}\n\nbool Value::hasComment(CommentPlacement placement) const {\n  return comments_ != 0 && comments_[placement].comment_ != 0;\n}\n\nstd::string Value::getComment(CommentPlacement placement) const {\n  if (hasComment(placement))\n    return comments_[placement].comment_;\n  return \"\";\n}\n\nvoid Value::setOffsetStart(size_t start) { start_ = start; }\n\nvoid Value::setOffsetLimit(size_t limit) { limit_ = limit; }\n\nsize_t Value::getOffsetStart() const { return start_; }\n\nsize_t Value::getOffsetLimit() const { return limit_; }\n\nstd::string Value::toStyledString() const {\n  StyledWriter writer;\n  return writer.write(*this);\n}\n\nValue::const_iterator Value::begin() const {\n  switch (type_) {\n  case arrayValue:\n  case objectValue:\n    if (value_.map_)\n      return const_iterator(value_.map_->begin());\n    break;\n  default:\n    break;\n  }\n  return const_iterator();\n}\n\nValue::const_iterator Value::end() const {\n  switch (type_) {\n  case arrayValue:\n  case objectValue:\n    if (value_.map_)\n      return const_iterator(value_.map_->end());\n    break;\n  default:\n    break;\n  }\n  return const_iterator();\n}\n\nValue::iterator Value::begin() {\n  switch (type_) {\n  case arrayValue:\n  case objectValue:\n    if (value_.map_)\n      return iterator(value_.map_->begin());\n    break;\n  default:\n    break;\n  }\n  return iterator();\n}\n\nValue::iterator Value::end() {\n  switch (type_) {\n  case arrayValue:\n  case objectValue:\n    if (value_.map_)\n      return iterator(value_.map_->end());\n    break;\n  default:\n    break;\n  }\n  return iterator();\n}\n\n// class PathArgument\n// //////////////////////////////////////////////////////////////////\n\nPathArgument::PathArgument() : key_(), index_(), kind_(kindNone) {}\n\nPathArgument::PathArgument(ArrayIndex index)\n    : key_(), index_(index), kind_(kindIndex) {}\n\nPathArgument::PathArgument(const char* key)\n    : key_(key), index_(), kind_(kindKey) {}\n\nPathArgument::PathArgument(const std::string& key)\n    : key_(key.c_str()), index_(), kind_(kindKey) {}\n\n// class Path\n// //////////////////////////////////////////////////////////////////\n\nPath::Path(const std::string& path,\n           const PathArgument& a1,\n           const PathArgument& a2,\n           const PathArgument& a3,\n           const PathArgument& a4,\n           const PathArgument& a5) {\n  InArgs in;\n  in.push_back(&a1);\n  in.push_back(&a2);\n  in.push_back(&a3);\n  in.push_back(&a4);\n  in.push_back(&a5);\n  makePath(path, in);\n}\n\nvoid Path::makePath(const std::string& path, const InArgs& in) {\n  const char* current = path.c_str();\n  const char* end = current + path.length();\n  InArgs::const_iterator itInArg = in.begin();\n  while (current != end) {\n    if (*current == '[') {\n      ++current;\n      if (*current == '%')\n        addPathInArg(path, in, itInArg, PathArgument::kindIndex);\n      else {\n        ArrayIndex index = 0;\n        for (; current != end && *current >= '0' && *current <= '9'; ++current)\n          index = index * 10 + ArrayIndex(*current - '0');\n        args_.push_back(index);\n      }\n      if (current == end || *current++ != ']')\n        invalidPath(path, int(current - path.c_str()));\n    } else if (*current == '%') {\n      addPathInArg(path, in, itInArg, PathArgument::kindKey);\n      ++current;\n    } else if (*current == '.') {\n      ++current;\n    } else {\n      const char* beginName = current;\n      while (current != end && !strchr(\"[.\", *current))\n        ++current;\n      args_.push_back(std::string(beginName, current));\n    }\n  }\n}\n\nvoid Path::addPathInArg(const std::string& /*path*/,\n                        const InArgs& in,\n                        InArgs::const_iterator& itInArg,\n                        PathArgument::Kind kind) {\n  if (itInArg == in.end()) {\n    // Error: missing argument %d\n  } else if ((*itInArg)->kind_ != kind) {\n    // Error: bad argument type\n  } else {\n    args_.push_back(**itInArg);\n  }\n}\n\nvoid Path::invalidPath(const std::string& /*path*/, int /*location*/) {\n  // Error: invalid path.\n}\n\nconst Value& Path::resolve(const Value& root) const {\n  const Value* node = &root;\n  for (Args::const_iterator it = args_.begin(); it != args_.end(); ++it) {\n    const PathArgument& arg = *it;\n    if (arg.kind_ == PathArgument::kindIndex) {\n      if (!node->isArray() || !node->isValidIndex(arg.index_)) {\n        // Error: unable to resolve path (array value expected at position...\n      }\n      node = &((*node)[arg.index_]);\n    } else if (arg.kind_ == PathArgument::kindKey) {\n      if (!node->isObject()) {\n        // Error: unable to resolve path (object value expected at position...)\n      }\n      node = &((*node)[arg.key_]);\n      if (node == &Value::nullRef) {\n        // Error: unable to resolve path (object has no member named '' at\n        // position...)\n      }\n    }\n  }\n  return *node;\n}\n\nValue Path::resolve(const Value& root, const Value& defaultValue) const {\n  const Value* node = &root;\n  for (Args::const_iterator it = args_.begin(); it != args_.end(); ++it) {\n    const PathArgument& arg = *it;\n    if (arg.kind_ == PathArgument::kindIndex) {\n      if (!node->isArray() || !node->isValidIndex(arg.index_))\n        return defaultValue;\n      node = &((*node)[arg.index_]);\n    } else if (arg.kind_ == PathArgument::kindKey) {\n      if (!node->isObject())\n        return defaultValue;\n      node = &((*node)[arg.key_]);\n      if (node == &Value::nullRef)\n        return defaultValue;\n    }\n  }\n  return *node;\n}\n\nValue& Path::make(Value& root) const {\n  Value* node = &root;\n  for (Args::const_iterator it = args_.begin(); it != args_.end(); ++it) {\n    const PathArgument& arg = *it;\n    if (arg.kind_ == PathArgument::kindIndex) {\n      if (!node->isArray()) {\n        // Error: node is not an array at position ...\n      }\n      node = &((*node)[arg.index_]);\n    } else if (arg.kind_ == PathArgument::kindKey) {\n      if (!node->isObject()) {\n        // Error: node is not an object at position...\n      }\n      node = &((*node)[arg.key_]);\n    }\n  }\n  return *node;\n}\n\n} // namespace Json\n\n// //////////////////////////////////////////////////////////////////////\n// End of content of file: src/lib_json/json_value.cpp\n// //////////////////////////////////////////////////////////////////////\n\n\n\n\n\n\n// //////////////////////////////////////////////////////////////////////\n// Beginning of content of file: src/lib_json/json_writer.cpp\n// //////////////////////////////////////////////////////////////////////\n\n// Copyright 2011 Baptiste Lepilleur\n// Distributed under MIT license, or public domain if desired and\n// recognized in your jurisdiction.\n// See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE\n\n#if !defined(JSON_IS_AMALGAMATION)\n#include <json/writer.h>\n#include \"json_tool.h\"\n#endif // if !defined(JSON_IS_AMALGAMATION)\n#include <iomanip>\n#include <memory>\n#include <sstream>\n#include <utility>\n#include <set>\n#include <cassert>\n#include <cstring>\n#include <cstdio>\n\n#if defined(_MSC_VER) && _MSC_VER >= 1200 && _MSC_VER < 1800 // Between VC++ 6.0 and VC++ 11.0\n#include <float.h>\n#define isfinite _finite\n#elif defined(__sun) && defined(__SVR4) //Solaris\n#if !defined(isfinite)\n#include <ieeefp.h>\n#define isfinite finite\n#endif\n#elif defined(_AIX)\n#if !defined(isfinite)\n#include <math.h>\n#define isfinite finite\n#endif\n#elif defined(__hpux)\n#if !defined(isfinite)\n#if defined(__ia64) && !defined(finite)\n#define isfinite(x) ((sizeof(x) == sizeof(float) ? \\\n                     _Isfinitef(x) : _IsFinite(x)))\n#else\n#include <math.h>\n#define isfinite finite\n#endif\n#endif\n#else\n#include <cmath>\n#if !(defined(__QNXNTO__)) // QNX already defines isfinite\n#define isfinite std::isfinite\n#endif\n#endif\n\n#if defined(_MSC_VER)\n#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above\n#define snprintf sprintf_s\n#elif _MSC_VER >= 1900 // VC++ 14.0 and above\n#define snprintf std::snprintf\n#else\n#define snprintf _snprintf\n#endif\n#elif defined(__ANDROID__) || defined(__QNXNTO__)\n#define snprintf snprintf\n#elif __cplusplus >= 201103L\n#define snprintf std::snprintf\n#endif\n\n#if defined(__BORLANDC__)  \n#include <float.h>\n#define isfinite _finite\n#define snprintf _snprintf\n#endif\n\n#if defined(_MSC_VER) && _MSC_VER >= 1400 // VC++ 8.0\n// Disable warning about strdup being deprecated.\n#pragma warning(disable : 4996)\n#endif\n\nnamespace Json {\n\n#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)\ntypedef std::unique_ptr<StreamWriter> StreamWriterPtr;\n#else\ntypedef std::auto_ptr<StreamWriter>   StreamWriterPtr;\n#endif\n\nstatic bool containsControlCharacter(const char* str) {\n  while (*str) {\n    if (isControlCharacter(*(str++)))\n      return true;\n  }\n  return false;\n}\n\nstatic bool containsControlCharacter0(const char* str, unsigned len) {\n  char const* end = str + len;\n  while (end != str) {\n    if (isControlCharacter(*str) || 0==*str)\n      return true;\n    ++str;\n  }\n  return false;\n}\n\nstd::string valueToString(LargestInt value) {\n  UIntToStringBuffer buffer;\n  char* current = buffer + sizeof(buffer);\n  if (value == Value::minLargestInt) {\n    uintToString(LargestUInt(Value::maxLargestInt) + 1, current);\n    *--current = '-';\n  } else if (value < 0) {\n    uintToString(LargestUInt(-value), current);\n    *--current = '-';\n  } else {\n    uintToString(LargestUInt(value), current);\n  }\n  assert(current >= buffer);\n  return current;\n}\n\nstd::string valueToString(LargestUInt value) {\n  UIntToStringBuffer buffer;\n  char* current = buffer + sizeof(buffer);\n  uintToString(value, current);\n  assert(current >= buffer);\n  return current;\n}\n\n#if defined(JSON_HAS_INT64)\n\nstd::string valueToString(Int value) {\n  return valueToString(LargestInt(value));\n}\n\nstd::string valueToString(UInt value) {\n  return valueToString(LargestUInt(value));\n}\n\n#endif // # if defined(JSON_HAS_INT64)\n\nstd::string valueToString(double value, bool useSpecialFloats, unsigned int precision) {\n  // Allocate a buffer that is more than large enough to store the 16 digits of\n  // precision requested below.\n  char buffer[32];\n  int len = -1;\n\n  char formatString[6];\n  sprintf(formatString, \"%%.%dg\", precision);\n\n  // Print into the buffer. We need not request the alternative representation\n  // that always has a decimal point because JSON doesn't distingish the\n  // concepts of reals and integers.\n  if (isfinite(value)) {\n    len = snprintf(buffer, sizeof(buffer), formatString, value);\n  } else {\n    // IEEE standard states that NaN values will not compare to themselves\n    if (value != value) {\n      len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? \"NaN\" : \"null\");\n    } else if (value < 0) {\n      len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? \"-Infinity\" : \"-1e+9999\");\n    } else {\n      len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? \"Infinity\" : \"1e+9999\");\n    }\n    // For those, we do not need to call fixNumLoc, but it is fast.\n  }\n  assert(len >= 0);\n  fixNumericLocale(buffer, buffer + len);\n  return buffer;\n}\n\nstd::string valueToString(double value) { return valueToString(value, false, 17); }\n\nstd::string valueToString(bool value) { return value ? \"true\" : \"false\"; }\n\nstd::string valueToQuotedString(const char* value) {\n  if (value == NULL)\n    return \"\";\n  // Not sure how to handle unicode...\n  if (strpbrk(value, \"\\\"\\\\\\b\\f\\n\\r\\t\") == NULL &&\n      !containsControlCharacter(value))\n    return std::string(\"\\\"\") + value + \"\\\"\";\n  // We have to walk value and escape any special characters.\n  // Appending to std::string is not efficient, but this should be rare.\n  // (Note: forward slashes are *not* rare, but I am not escaping them.)\n  std::string::size_type maxsize =\n      strlen(value) * 2 + 3; // allescaped+quotes+NULL\n  std::string result;\n  result.reserve(maxsize); // to avoid lots of mallocs\n  result += \"\\\"\";\n  for (const char* c = value; *c != 0; ++c) {\n    switch (*c) {\n    case '\\\"':\n      result += \"\\\\\\\"\";\n      break;\n    case '\\\\':\n      result += \"\\\\\\\\\";\n      break;\n    case '\\b':\n      result += \"\\\\b\";\n      break;\n    case '\\f':\n      result += \"\\\\f\";\n      break;\n    case '\\n':\n      result += \"\\\\n\";\n      break;\n    case '\\r':\n      result += \"\\\\r\";\n      break;\n    case '\\t':\n      result += \"\\\\t\";\n      break;\n    // case '/':\n    // Even though \\/ is considered a legal escape in JSON, a bare\n    // slash is also legal, so I see no reason to escape it.\n    // (I hope I am not misunderstanding something.\n    // blep notes: actually escaping \\/ may be useful in javascript to avoid </\n    // sequence.\n    // Should add a flag to allow this compatibility mode and prevent this\n    // sequence from occurring.\n    default:\n      if (isControlCharacter(*c)) {\n        std::ostringstream oss;\n        oss << \"\\\\u\" << std::hex << std::uppercase << std::setfill('0')\n            << std::setw(4) << static_cast<int>(*c);\n        result += oss.str();\n      } else {\n        result += *c;\n      }\n      break;\n    }\n  }\n  result += \"\\\"\";\n  return result;\n}\n\n// https://github.com/upcaste/upcaste/blob/master/src/upcore/src/cstring/strnpbrk.cpp\nstatic char const* strnpbrk(char const* s, char const* accept, size_t n) {\n  assert((s || !n) && accept);\n\n  char const* const end = s + n;\n  for (char const* cur = s; cur < end; ++cur) {\n    int const c = *cur;\n    for (char const* a = accept; *a; ++a) {\n      if (*a == c) {\n        return cur;\n      }\n    }\n  }\n  return NULL;\n}\nstatic std::string valueToQuotedStringN(const char* value, unsigned length) {\n  if (value == NULL)\n    return \"\";\n  // Not sure how to handle unicode...\n  if (strnpbrk(value, \"\\\"\\\\\\b\\f\\n\\r\\t\", length) == NULL &&\n      !containsControlCharacter0(value, length))\n    return std::string(\"\\\"\") + value + \"\\\"\";\n  // We have to walk value and escape any special characters.\n  // Appending to std::string is not efficient, but this should be rare.\n  // (Note: forward slashes are *not* rare, but I am not escaping them.)\n  std::string::size_type maxsize =\n      length * 2 + 3; // allescaped+quotes+NULL\n  std::string result;\n  result.reserve(maxsize); // to avoid lots of mallocs\n  result += \"\\\"\";\n  char const* end = value + length;\n  for (const char* c = value; c != end; ++c) {\n    switch (*c) {\n    case '\\\"':\n      result += \"\\\\\\\"\";\n      break;\n    case '\\\\':\n      result += \"\\\\\\\\\";\n      break;\n    case '\\b':\n      result += \"\\\\b\";\n      break;\n    case '\\f':\n      result += \"\\\\f\";\n      break;\n    case '\\n':\n      result += \"\\\\n\";\n      break;\n    case '\\r':\n      result += \"\\\\r\";\n      break;\n    case '\\t':\n      result += \"\\\\t\";\n      break;\n    // case '/':\n    // Even though \\/ is considered a legal escape in JSON, a bare\n    // slash is also legal, so I see no reason to escape it.\n    // (I hope I am not misunderstanding something.)\n    // blep notes: actually escaping \\/ may be useful in javascript to avoid </\n    // sequence.\n    // Should add a flag to allow this compatibility mode and prevent this\n    // sequence from occurring.\n    default:\n      if ((isControlCharacter(*c)) || (*c == 0)) {\n        std::ostringstream oss;\n        oss << \"\\\\u\" << std::hex << std::uppercase << std::setfill('0')\n            << std::setw(4) << static_cast<int>(*c);\n        result += oss.str();\n      } else {\n        result += *c;\n      }\n      break;\n    }\n  }\n  result += \"\\\"\";\n  return result;\n}\n\n// Class Writer\n// //////////////////////////////////////////////////////////////////\nWriter::~Writer() {}\n\n// Class FastWriter\n// //////////////////////////////////////////////////////////////////\n\nFastWriter::FastWriter()\n    : yamlCompatiblityEnabled_(false), dropNullPlaceholders_(false),\n      omitEndingLineFeed_(false) {}\n\nvoid FastWriter::enableYAMLCompatibility() { yamlCompatiblityEnabled_ = true; }\n\nvoid FastWriter::dropNullPlaceholders() { dropNullPlaceholders_ = true; }\n\nvoid FastWriter::omitEndingLineFeed() { omitEndingLineFeed_ = true; }\n\nstd::string FastWriter::write(const Value& root) {\n  document_ = \"\";\n  writeValue(root);\n  if (!omitEndingLineFeed_)\n    document_ += \"\\n\";\n  return document_;\n}\n\nvoid FastWriter::writeValue(const Value& value) {\n  switch (value.type()) {\n  case nullValue:\n    if (!dropNullPlaceholders_)\n      document_ += \"null\";\n    break;\n  case intValue:\n    document_ += valueToString(value.asLargestInt());\n    break;\n  case uintValue:\n    document_ += valueToString(value.asLargestUInt());\n    break;\n  case realValue:\n    document_ += valueToString(value.asDouble());\n    break;\n  case stringValue:\n  {\n    // Is NULL possible for value.string_?\n    char const* str;\n    char const* end;\n    bool ok = value.getString(&str, &end);\n    if (ok) document_ += valueToQuotedStringN(str, static_cast<unsigned>(end-str));\n    break;\n  }\n  case booleanValue:\n    document_ += valueToString(value.asBool());\n    break;\n  case arrayValue: {\n    document_ += '[';\n    int size = value.size();\n    for (int index = 0; index < size; ++index) {\n      if (index > 0)\n        document_ += ',';\n      writeValue(value[index]);\n    }\n    document_ += ']';\n  } break;\n  case objectValue: {\n    Value::Members members(value.getMemberNames());\n    document_ += '{';\n    for (Value::Members::iterator it = members.begin(); it != members.end();\n         ++it) {\n      const std::string& name = *it;\n      if (it != members.begin())\n        document_ += ',';\n      document_ += valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length()));\n      document_ += yamlCompatiblityEnabled_ ? \": \" : \":\";\n      writeValue(value[name]);\n    }\n    document_ += '}';\n  } break;\n  }\n}\n\n// Class StyledWriter\n// //////////////////////////////////////////////////////////////////\n\nStyledWriter::StyledWriter()\n    : rightMargin_(74), indentSize_(3), addChildValues_() {}\n\nstd::string StyledWriter::write(const Value& root) {\n  document_ = \"\";\n  addChildValues_ = false;\n  indentString_ = \"\";\n  writeCommentBeforeValue(root);\n  writeValue(root);\n  writeCommentAfterValueOnSameLine(root);\n  document_ += \"\\n\";\n  return document_;\n}\n\nvoid StyledWriter::writeValue(const Value& value) {\n  switch (value.type()) {\n  case nullValue:\n    pushValue(\"null\");\n    break;\n  case intValue:\n    pushValue(valueToString(value.asLargestInt()));\n    break;\n  case uintValue:\n    pushValue(valueToString(value.asLargestUInt()));\n    break;\n  case realValue:\n    pushValue(valueToString(value.asDouble()));\n    break;\n  case stringValue:\n  {\n    // Is NULL possible for value.string_?\n    char const* str;\n    char const* end;\n    bool ok = value.getString(&str, &end);\n    if (ok) pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end-str)));\n    else pushValue(\"\");\n    break;\n  }\n  case booleanValue:\n    pushValue(valueToString(value.asBool()));\n    break;\n  case arrayValue:\n    writeArrayValue(value);\n    break;\n  case objectValue: {\n    Value::Members members(value.getMemberNames());\n    if (members.empty())\n      pushValue(\"{}\");\n    else {\n      writeWithIndent(\"{\");\n      indent();\n      Value::Members::iterator it = members.begin();\n      for (;;) {\n        const std::string& name = *it;\n        const Value& childValue = value[name];\n        writeCommentBeforeValue(childValue);\n        writeWithIndent(valueToQuotedString(name.c_str()));\n        document_ += \" : \";\n        writeValue(childValue);\n        if (++it == members.end()) {\n          writeCommentAfterValueOnSameLine(childValue);\n          break;\n        }\n        document_ += ',';\n        writeCommentAfterValueOnSameLine(childValue);\n      }\n      unindent();\n      writeWithIndent(\"}\");\n    }\n  } break;\n  }\n}\n\nvoid StyledWriter::writeArrayValue(const Value& value) {\n  unsigned size = value.size();\n  if (size == 0)\n    pushValue(\"[]\");\n  else {\n    bool isArrayMultiLine = isMultineArray(value);\n    if (isArrayMultiLine) {\n      writeWithIndent(\"[\");\n      indent();\n      bool hasChildValue = !childValues_.empty();\n      unsigned index = 0;\n      for (;;) {\n        const Value& childValue = value[index];\n        writeCommentBeforeValue(childValue);\n        if (hasChildValue)\n          writeWithIndent(childValues_[index]);\n        else {\n          writeIndent();\n          writeValue(childValue);\n        }\n        if (++index == size) {\n          writeCommentAfterValueOnSameLine(childValue);\n          break;\n        }\n        document_ += ',';\n        writeCommentAfterValueOnSameLine(childValue);\n      }\n      unindent();\n      writeWithIndent(\"]\");\n    } else // output on a single line\n    {\n      assert(childValues_.size() == size);\n      document_ += \"[ \";\n      for (unsigned index = 0; index < size; ++index) {\n        if (index > 0)\n          document_ += \", \";\n        document_ += childValues_[index];\n      }\n      document_ += \" ]\";\n    }\n  }\n}\n\nbool StyledWriter::isMultineArray(const Value& value) {\n  int size = value.size();\n  bool isMultiLine = size * 3 >= rightMargin_;\n  childValues_.clear();\n  for (int index = 0; index < size && !isMultiLine; ++index) {\n    const Value& childValue = value[index];\n    isMultiLine = ((childValue.isArray() || childValue.isObject()) &&\n                        childValue.size() > 0);\n  }\n  if (!isMultiLine) // check if line length > max line length\n  {\n    childValues_.reserve(size);\n    addChildValues_ = true;\n    int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'\n    for (int index = 0; index < size; ++index) {\n      if (hasCommentForValue(value[index])) {\n        isMultiLine = true;\n      }\n      writeValue(value[index]);\n      lineLength += int(childValues_[index].length());\n    }\n    addChildValues_ = false;\n    isMultiLine = isMultiLine || lineLength >= rightMargin_;\n  }\n  return isMultiLine;\n}\n\nvoid StyledWriter::pushValue(const std::string& value) {\n  if (addChildValues_)\n    childValues_.push_back(value);\n  else\n    document_ += value;\n}\n\nvoid StyledWriter::writeIndent() {\n  if (!document_.empty()) {\n    char last = document_[document_.length() - 1];\n    if (last == ' ') // already indented\n      return;\n    if (last != '\\n') // Comments may add new-line\n      document_ += '\\n';\n  }\n  document_ += indentString_;\n}\n\nvoid StyledWriter::writeWithIndent(const std::string& value) {\n  writeIndent();\n  document_ += value;\n}\n\nvoid StyledWriter::indent() { indentString_ += std::string(indentSize_, ' '); }\n\nvoid StyledWriter::unindent() {\n  assert(int(indentString_.size()) >= indentSize_);\n  indentString_.resize(indentString_.size() - indentSize_);\n}\n\nvoid StyledWriter::writeCommentBeforeValue(const Value& root) {\n  if (!root.hasComment(commentBefore))\n    return;\n\n  document_ += \"\\n\";\n  writeIndent();\n  const std::string& comment = root.getComment(commentBefore);\n  std::string::const_iterator iter = comment.begin();\n  while (iter != comment.end()) {\n    document_ += *iter;\n    if (*iter == '\\n' &&\n       (iter != comment.end() && *(iter + 1) == '/'))\n      writeIndent();\n    ++iter;\n  }\n\n  // Comments are stripped of trailing newlines, so add one here\n  document_ += \"\\n\";\n}\n\nvoid StyledWriter::writeCommentAfterValueOnSameLine(const Value& root) {\n  if (root.hasComment(commentAfterOnSameLine))\n    document_ += \" \" + root.getComment(commentAfterOnSameLine);\n\n  if (root.hasComment(commentAfter)) {\n    document_ += \"\\n\";\n    document_ += root.getComment(commentAfter);\n    document_ += \"\\n\";\n  }\n}\n\nbool StyledWriter::hasCommentForValue(const Value& value) {\n  return value.hasComment(commentBefore) ||\n         value.hasComment(commentAfterOnSameLine) ||\n         value.hasComment(commentAfter);\n}\n\n// Class StyledStreamWriter\n// //////////////////////////////////////////////////////////////////\n\nStyledStreamWriter::StyledStreamWriter(std::string indentation)\n    : document_(NULL), rightMargin_(74), indentation_(indentation),\n      addChildValues_() {}\n\nvoid StyledStreamWriter::write(std::ostream& out, const Value& root) {\n  document_ = &out;\n  addChildValues_ = false;\n  indentString_ = \"\";\n  indented_ = true;\n  writeCommentBeforeValue(root);\n  if (!indented_) writeIndent();\n  indented_ = true;\n  writeValue(root);\n  writeCommentAfterValueOnSameLine(root);\n  *document_ << \"\\n\";\n  document_ = NULL; // Forget the stream, for safety.\n}\n\nvoid StyledStreamWriter::writeValue(const Value& value) {\n  switch (value.type()) {\n  case nullValue:\n    pushValue(\"null\");\n    break;\n  case intValue:\n    pushValue(valueToString(value.asLargestInt()));\n    break;\n  case uintValue:\n    pushValue(valueToString(value.asLargestUInt()));\n    break;\n  case realValue:\n    pushValue(valueToString(value.asDouble()));\n    break;\n  case stringValue:\n  {\n    // Is NULL possible for value.string_?\n    char const* str;\n    char const* end;\n    bool ok = value.getString(&str, &end);\n    if (ok) pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end-str)));\n    else pushValue(\"\");\n    break;\n  }\n  case booleanValue:\n    pushValue(valueToString(value.asBool()));\n    break;\n  case arrayValue:\n    writeArrayValue(value);\n    break;\n  case objectValue: {\n    Value::Members members(value.getMemberNames());\n    if (members.empty())\n      pushValue(\"{}\");\n    else {\n      writeWithIndent(\"{\");\n      indent();\n      Value::Members::iterator it = members.begin();\n      for (;;) {\n        const std::string& name = *it;\n        const Value& childValue = value[name];\n        writeCommentBeforeValue(childValue);\n        writeWithIndent(valueToQuotedString(name.c_str()));\n        *document_ << \" : \";\n        writeValue(childValue);\n        if (++it == members.end()) {\n          writeCommentAfterValueOnSameLine(childValue);\n          break;\n        }\n        *document_ << \",\";\n        writeCommentAfterValueOnSameLine(childValue);\n      }\n      unindent();\n      writeWithIndent(\"}\");\n    }\n  } break;\n  }\n}\n\nvoid StyledStreamWriter::writeArrayValue(const Value& value) {\n  unsigned size = value.size();\n  if (size == 0)\n    pushValue(\"[]\");\n  else {\n    bool isArrayMultiLine = isMultineArray(value);\n    if (isArrayMultiLine) {\n      writeWithIndent(\"[\");\n      indent();\n      bool hasChildValue = !childValues_.empty();\n      unsigned index = 0;\n      for (;;) {\n        const Value& childValue = value[index];\n        writeCommentBeforeValue(childValue);\n        if (hasChildValue)\n          writeWithIndent(childValues_[index]);\n        else {\n          if (!indented_) writeIndent();\n          indented_ = true;\n          writeValue(childValue);\n          indented_ = false;\n        }\n        if (++index == size) {\n          writeCommentAfterValueOnSameLine(childValue);\n          break;\n        }\n        *document_ << \",\";\n        writeCommentAfterValueOnSameLine(childValue);\n      }\n      unindent();\n      writeWithIndent(\"]\");\n    } else // output on a single line\n    {\n      assert(childValues_.size() == size);\n      *document_ << \"[ \";\n      for (unsigned index = 0; index < size; ++index) {\n        if (index > 0)\n          *document_ << \", \";\n        *document_ << childValues_[index];\n      }\n      *document_ << \" ]\";\n    }\n  }\n}\n\nbool StyledStreamWriter::isMultineArray(const Value& value) {\n  int size = value.size();\n  bool isMultiLine = size * 3 >= rightMargin_;\n  childValues_.clear();\n  for (int index = 0; index < size && !isMultiLine; ++index) {\n    const Value& childValue = value[index];\n    isMultiLine = ((childValue.isArray() || childValue.isObject()) &&\n                        childValue.size() > 0);\n  }\n  if (!isMultiLine) // check if line length > max line length\n  {\n    childValues_.reserve(size);\n    addChildValues_ = true;\n    int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'\n    for (int index = 0; index < size; ++index) {\n      if (hasCommentForValue(value[index])) {\n        isMultiLine = true;\n      }\n      writeValue(value[index]);\n      lineLength += int(childValues_[index].length());\n    }\n    addChildValues_ = false;\n    isMultiLine = isMultiLine || lineLength >= rightMargin_;\n  }\n  return isMultiLine;\n}\n\nvoid StyledStreamWriter::pushValue(const std::string& value) {\n  if (addChildValues_)\n    childValues_.push_back(value);\n  else\n    *document_ << value;\n}\n\nvoid StyledStreamWriter::writeIndent() {\n  // blep intended this to look at the so-far-written string\n  // to determine whether we are already indented, but\n  // with a stream we cannot do that. So we rely on some saved state.\n  // The caller checks indented_.\n  *document_ << '\\n' << indentString_;\n}\n\nvoid StyledStreamWriter::writeWithIndent(const std::string& value) {\n  if (!indented_) writeIndent();\n  *document_ << value;\n  indented_ = false;\n}\n\nvoid StyledStreamWriter::indent() { indentString_ += indentation_; }\n\nvoid StyledStreamWriter::unindent() {\n  assert(indentString_.size() >= indentation_.size());\n  indentString_.resize(indentString_.size() - indentation_.size());\n}\n\nvoid StyledStreamWriter::writeCommentBeforeValue(const Value& root) {\n  if (!root.hasComment(commentBefore))\n    return;\n\n  if (!indented_) writeIndent();\n  const std::string& comment = root.getComment(commentBefore);\n  std::string::const_iterator iter = comment.begin();\n  while (iter != comment.end()) {\n    *document_ << *iter;\n    if (*iter == '\\n' &&\n       (iter != comment.end() && *(iter + 1) == '/'))\n      // writeIndent();  // would include newline\n      *document_ << indentString_;\n    ++iter;\n  }\n  indented_ = false;\n}\n\nvoid StyledStreamWriter::writeCommentAfterValueOnSameLine(const Value& root) {\n  if (root.hasComment(commentAfterOnSameLine))\n    *document_ << ' ' << root.getComment(commentAfterOnSameLine);\n\n  if (root.hasComment(commentAfter)) {\n    writeIndent();\n    *document_ << root.getComment(commentAfter);\n  }\n  indented_ = false;\n}\n\nbool StyledStreamWriter::hasCommentForValue(const Value& value) {\n  return value.hasComment(commentBefore) ||\n         value.hasComment(commentAfterOnSameLine) ||\n         value.hasComment(commentAfter);\n}\n\n//////////////////////////\n// BuiltStyledStreamWriter\n\n/// Scoped enums are not available until C++11.\nstruct CommentStyle {\n  /// Decide whether to write comments.\n  enum Enum {\n    None,  ///< Drop all comments.\n    Most,  ///< Recover odd behavior of previous versions (not implemented yet).\n    All  ///< Keep all comments.\n  };\n};\n\nstruct BuiltStyledStreamWriter : public StreamWriter\n{\n  BuiltStyledStreamWriter(\n      std::string const& indentation,\n      CommentStyle::Enum cs,\n      std::string const& colonSymbol,\n      std::string const& nullSymbol,\n      std::string const& endingLineFeedSymbol,\n      bool useSpecialFloats,\n      unsigned int precision);\n  int write(Value const& root, std::ostream* sout) override;\nprivate:\n  void writeValue(Value const& value);\n  void writeArrayValue(Value const& value);\n  bool isMultineArray(Value const& value);\n  void pushValue(std::string const& value);\n  void writeIndent();\n  void writeWithIndent(std::string const& value);\n  void indent();\n  void unindent();\n  void writeCommentBeforeValue(Value const& root);\n  void writeCommentAfterValueOnSameLine(Value const& root);\n  static bool hasCommentForValue(const Value& value);\n\n  typedef std::vector<std::string> ChildValues;\n\n  ChildValues childValues_;\n  std::string indentString_;\n  int rightMargin_;\n  std::string indentation_;\n  CommentStyle::Enum cs_;\n  std::string colonSymbol_;\n  std::string nullSymbol_;\n  std::string endingLineFeedSymbol_;\n  bool addChildValues_ : 1;\n  bool indented_ : 1;\n  bool useSpecialFloats_ : 1;\n  unsigned int precision_;\n};\nBuiltStyledStreamWriter::BuiltStyledStreamWriter(\n      std::string const& indentation,\n      CommentStyle::Enum cs,\n      std::string const& colonSymbol,\n      std::string const& nullSymbol,\n      std::string const& endingLineFeedSymbol,\n      bool useSpecialFloats,\n      unsigned int precision)\n  : rightMargin_(74)\n  , indentation_(indentation)\n  , cs_(cs)\n  , colonSymbol_(colonSymbol)\n  , nullSymbol_(nullSymbol)\n  , endingLineFeedSymbol_(endingLineFeedSymbol)\n  , addChildValues_(false)\n  , indented_(false)\n  , useSpecialFloats_(useSpecialFloats)\n  , precision_(precision)\n{\n}\nint BuiltStyledStreamWriter::write(Value const& root, std::ostream* sout)\n{\n  sout_ = sout;\n  addChildValues_ = false;\n  indented_ = true;\n  indentString_ = \"\";\n  writeCommentBeforeValue(root);\n  if (!indented_) writeIndent();\n  indented_ = true;\n  writeValue(root);\n  writeCommentAfterValueOnSameLine(root);\n  *sout_ << endingLineFeedSymbol_;\n  sout_ = NULL;\n  return 0;\n}\nvoid BuiltStyledStreamWriter::writeValue(Value const& value) {\n  switch (value.type()) {\n  case nullValue:\n    pushValue(nullSymbol_);\n    break;\n  case intValue:\n    pushValue(valueToString(value.asLargestInt()));\n    break;\n  case uintValue:\n    pushValue(valueToString(value.asLargestUInt()));\n    break;\n  case realValue:\n    pushValue(valueToString(value.asDouble(), useSpecialFloats_, precision_));\n    break;\n  case stringValue:\n  {\n    // Is NULL is possible for value.string_?\n    char const* str;\n    char const* end;\n    bool ok = value.getString(&str, &end);\n    if (ok) pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end-str)));\n    else pushValue(\"\");\n    break;\n  }\n  case booleanValue:\n    pushValue(valueToString(value.asBool()));\n    break;\n  case arrayValue:\n    writeArrayValue(value);\n    break;\n  case objectValue: {\n    Value::Members members(value.getMemberNames());\n    if (members.empty())\n      pushValue(\"{}\");\n    else {\n      writeWithIndent(\"{\");\n      indent();\n      Value::Members::iterator it = members.begin();\n      for (;;) {\n        std::string const& name = *it;\n        Value const& childValue = value[name];\n        writeCommentBeforeValue(childValue);\n        writeWithIndent(valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length())));\n        *sout_ << colonSymbol_;\n        writeValue(childValue);\n        if (++it == members.end()) {\n          writeCommentAfterValueOnSameLine(childValue);\n          break;\n        }\n        *sout_ << \",\";\n        writeCommentAfterValueOnSameLine(childValue);\n      }\n      unindent();\n      writeWithIndent(\"}\");\n    }\n  } break;\n  }\n}\n\nvoid BuiltStyledStreamWriter::writeArrayValue(Value const& value) {\n  unsigned size = value.size();\n  if (size == 0)\n    pushValue(\"[]\");\n  else {\n    bool isMultiLine = (cs_ == CommentStyle::All) || isMultineArray(value);\n    if (isMultiLine) {\n      writeWithIndent(\"[\");\n      indent();\n      bool hasChildValue = !childValues_.empty();\n      unsigned index = 0;\n      for (;;) {\n        Value const& childValue = value[index];\n        writeCommentBeforeValue(childValue);\n        if (hasChildValue)\n          writeWithIndent(childValues_[index]);\n        else {\n          if (!indented_) writeIndent();\n          indented_ = true;\n          writeValue(childValue);\n          indented_ = false;\n        }\n        if (++index == size) {\n          writeCommentAfterValueOnSameLine(childValue);\n          break;\n        }\n        *sout_ << \",\";\n        writeCommentAfterValueOnSameLine(childValue);\n      }\n      unindent();\n      writeWithIndent(\"]\");\n    } else // output on a single line\n    {\n      assert(childValues_.size() == size);\n      *sout_ << \"[\";\n      if (!indentation_.empty()) *sout_ << \" \";\n      for (unsigned index = 0; index < size; ++index) {\n        if (index > 0)\n          *sout_ << \", \";\n        *sout_ << childValues_[index];\n      }\n      if (!indentation_.empty()) *sout_ << \" \";\n      *sout_ << \"]\";\n    }\n  }\n}\n\nbool BuiltStyledStreamWriter::isMultineArray(Value const& value) {\n  int size = value.size();\n  bool isMultiLine = size * 3 >= rightMargin_;\n  childValues_.clear();\n  for (int index = 0; index < size && !isMultiLine; ++index) {\n    Value const& childValue = value[index];\n    isMultiLine = ((childValue.isArray() || childValue.isObject()) &&\n                        childValue.size() > 0);\n  }\n  if (!isMultiLine) // check if line length > max line length\n  {\n    childValues_.reserve(size);\n    addChildValues_ = true;\n    int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'\n    for (int index = 0; index < size; ++index) {\n      if (hasCommentForValue(value[index])) {\n        isMultiLine = true;\n      }\n      writeValue(value[index]);\n      lineLength += int(childValues_[index].length());\n    }\n    addChildValues_ = false;\n    isMultiLine = isMultiLine || lineLength >= rightMargin_;\n  }\n  return isMultiLine;\n}\n\nvoid BuiltStyledStreamWriter::pushValue(std::string const& value) {\n  if (addChildValues_)\n    childValues_.push_back(value);\n  else\n    *sout_ << value;\n}\n\nvoid BuiltStyledStreamWriter::writeIndent() {\n  // blep intended this to look at the so-far-written string\n  // to determine whether we are already indented, but\n  // with a stream we cannot do that. So we rely on some saved state.\n  // The caller checks indented_.\n\n  if (!indentation_.empty()) {\n    // In this case, drop newlines too.\n    *sout_ << '\\n' << indentString_;\n  }\n}\n\nvoid BuiltStyledStreamWriter::writeWithIndent(std::string const& value) {\n  if (!indented_) writeIndent();\n  *sout_ << value;\n  indented_ = false;\n}\n\nvoid BuiltStyledStreamWriter::indent() { indentString_ += indentation_; }\n\nvoid BuiltStyledStreamWriter::unindent() {\n  assert(indentString_.size() >= indentation_.size());\n  indentString_.resize(indentString_.size() - indentation_.size());\n}\n\nvoid BuiltStyledStreamWriter::writeCommentBeforeValue(Value const& root) {\n  if (cs_ == CommentStyle::None) return;\n  if (!root.hasComment(commentBefore))\n    return;\n\n  if (!indented_) writeIndent();\n  const std::string& comment = root.getComment(commentBefore);\n  std::string::const_iterator iter = comment.begin();\n  while (iter != comment.end()) {\n    *sout_ << *iter;\n    if (*iter == '\\n' &&\n       (iter != comment.end() && *(iter + 1) == '/'))\n      // writeIndent();  // would write extra newline\n      *sout_ << indentString_;\n    ++iter;\n  }\n  indented_ = false;\n}\n\nvoid BuiltStyledStreamWriter::writeCommentAfterValueOnSameLine(Value const& root) {\n  if (cs_ == CommentStyle::None) return;\n  if (root.hasComment(commentAfterOnSameLine))\n    *sout_ << \" \" + root.getComment(commentAfterOnSameLine);\n\n  if (root.hasComment(commentAfter)) {\n    writeIndent();\n    *sout_ << root.getComment(commentAfter);\n  }\n}\n\n// static\nbool BuiltStyledStreamWriter::hasCommentForValue(const Value& value) {\n  return value.hasComment(commentBefore) ||\n         value.hasComment(commentAfterOnSameLine) ||\n         value.hasComment(commentAfter);\n}\n\n///////////////\n// StreamWriter\n\nStreamWriter::StreamWriter()\n    : sout_(NULL)\n{\n}\nStreamWriter::~StreamWriter()\n{\n}\nStreamWriter::Factory::~Factory()\n{}\nStreamWriterBuilder::StreamWriterBuilder()\n{\n  setDefaults(&settings_);\n}\nStreamWriterBuilder::~StreamWriterBuilder()\n{}\nStreamWriter* StreamWriterBuilder::newStreamWriter() const\n{\n  std::string indentation = settings_[\"indentation\"].asString();\n  std::string cs_str = settings_[\"commentStyle\"].asString();\n  bool eyc = settings_[\"enableYAMLCompatibility\"].asBool();\n  bool dnp = settings_[\"dropNullPlaceholders\"].asBool();\n  bool usf = settings_[\"useSpecialFloats\"].asBool(); \n  unsigned int pre = settings_[\"precision\"].asUInt();\n  CommentStyle::Enum cs = CommentStyle::All;\n  if (cs_str == \"All\") {\n    cs = CommentStyle::All;\n  } else if (cs_str == \"None\") {\n    cs = CommentStyle::None;\n  } else {\n    throwRuntimeError(\"commentStyle must be 'All' or 'None'\");\n  }\n  std::string colonSymbol = \" : \";\n  if (eyc) {\n    colonSymbol = \": \";\n  } else if (indentation.empty()) {\n    colonSymbol = \":\";\n  }\n  std::string nullSymbol = \"null\";\n  if (dnp) {\n    nullSymbol = \"\";\n  }\n  if (pre > 17) pre = 17;\n  std::string endingLineFeedSymbol = \"\";\n  return new BuiltStyledStreamWriter(\n      indentation, cs,\n      colonSymbol, nullSymbol, endingLineFeedSymbol, usf, pre);\n}\nstatic void getValidWriterKeys(std::set<std::string>* valid_keys)\n{\n  valid_keys->clear();\n  valid_keys->insert(\"indentation\");\n  valid_keys->insert(\"commentStyle\");\n  valid_keys->insert(\"enableYAMLCompatibility\");\n  valid_keys->insert(\"dropNullPlaceholders\");\n  valid_keys->insert(\"useSpecialFloats\");\n  valid_keys->insert(\"precision\");\n}\nbool StreamWriterBuilder::validate(Json::Value* invalid) const\n{\n  Json::Value my_invalid;\n  if (!invalid) invalid = &my_invalid;  // so we do not need to test for NULL\n  Json::Value& inv = *invalid;\n  std::set<std::string> valid_keys;\n  getValidWriterKeys(&valid_keys);\n  Value::Members keys = settings_.getMemberNames();\n  size_t n = keys.size();\n  for (size_t i = 0; i < n; ++i) {\n    std::string const& key = keys[i];\n    if (valid_keys.find(key) == valid_keys.end()) {\n      inv[key] = settings_[key];\n    }\n  }\n  return 0u == inv.size();\n}\nValue& StreamWriterBuilder::operator[](std::string key)\n{\n  return settings_[key];\n}\n// static\nvoid StreamWriterBuilder::setDefaults(Json::Value* settings)\n{\n  //! [StreamWriterBuilderDefaults]\n  (*settings)[\"commentStyle\"] = \"All\";\n  (*settings)[\"indentation\"] = \"\\t\";\n  (*settings)[\"enableYAMLCompatibility\"] = false;\n  (*settings)[\"dropNullPlaceholders\"] = false;\n  (*settings)[\"useSpecialFloats\"] = false;\n  (*settings)[\"precision\"] = 17;\n  //! [StreamWriterBuilderDefaults]\n}\n\nstd::string writeString(StreamWriter::Factory const& builder, Value const& root) {\n  std::ostringstream sout;\n  StreamWriterPtr const writer(builder.newStreamWriter());\n  writer->write(root, &sout);\n  return sout.str();\n}\n\nstd::ostream& operator<<(std::ostream& sout, Value const& root) {\n  StreamWriterBuilder builder;\n  StreamWriterPtr const writer(builder.newStreamWriter());\n  writer->write(root, &sout);\n  return sout;\n}\n\n} // namespace Json\n\n// //////////////////////////////////////////////////////////////////////\n// End of content of file: src/lib_json/json_writer.cpp\n// //////////////////////////////////////////////////////////////////////\n\n\n\n\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/depcomp",
    "content": "#! /bin/sh\n# depcomp - compile a program generating dependencies as side-effects\n\nscriptversion=2013-05-30.07; # UTC\n\n# Copyright (C) 1999-2013 Free Software Foundation, Inc.\n\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 2, or (at your option)\n# any later version.\n\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n\n# You should have received a copy of the GNU General Public License\n# along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\n# As a special exception to the GNU General Public License, if you\n# distribute this file as part of a program that contains a\n# configuration script generated by Autoconf, you may include it under\n# the same distribution terms that you use for the rest of that program.\n\n# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.\n\ncase $1 in\n  '')\n    echo \"$0: No command.  Try '$0 --help' for more information.\" 1>&2\n    exit 1;\n    ;;\n  -h | --h*)\n    cat <<\\EOF\nUsage: depcomp [--help] [--version] PROGRAM [ARGS]\n\nRun PROGRAMS ARGS to compile a file, generating dependencies\nas side-effects.\n\nEnvironment variables:\n  depmode     Dependency tracking mode.\n  source      Source file read by 'PROGRAMS ARGS'.\n  object      Object file output by 'PROGRAMS ARGS'.\n  DEPDIR      directory where to store dependencies.\n  depfile     Dependency file to output.\n  tmpdepfile  Temporary file to use when outputting dependencies.\n  libtool     Whether libtool is used (yes/no).\n\nReport bugs to <bug-automake@gnu.org>.\nEOF\n    exit $?\n    ;;\n  -v | --v*)\n    echo \"depcomp $scriptversion\"\n    exit $?\n    ;;\nesac\n\n# Get the directory component of the given path, and save it in the\n# global variables '$dir'.  Note that this directory component will\n# be either empty or ending with a '/' character.  This is deliberate.\nset_dir_from ()\n{\n  case $1 in\n    */*) dir=`echo \"$1\" | sed -e 's|/[^/]*$|/|'`;;\n      *) dir=;;\n  esac\n}\n\n# Get the suffix-stripped basename of the given path, and save it the\n# global variable '$base'.\nset_base_from ()\n{\n  base=`echo \"$1\" | sed -e 's|^.*/||' -e 's/\\.[^.]*$//'`\n}\n\n# If no dependency file was actually created by the compiler invocation,\n# we still have to create a dummy depfile, to avoid errors with the\n# Makefile \"include basename.Plo\" scheme.\nmake_dummy_depfile ()\n{\n  echo \"#dummy\" > \"$depfile\"\n}\n\n# Factor out some common post-processing of the generated depfile.\n# Requires the auxiliary global variable '$tmpdepfile' to be set.\naix_post_process_depfile ()\n{\n  # If the compiler actually managed to produce a dependency file,\n  # post-process it.\n  if test -f \"$tmpdepfile\"; then\n    # Each line is of the form 'foo.o: dependency.h'.\n    # Do two passes, one to just change these to\n    #   $object: dependency.h\n    # and one to simply output\n    #   dependency.h:\n    # which is needed to avoid the deleted-header problem.\n    { sed -e \"s,^.*\\.[$lower]*:,$object:,\" < \"$tmpdepfile\"\n      sed -e \"s,^.*\\.[$lower]*:[$tab ]*,,\" -e 's,$,:,' < \"$tmpdepfile\"\n    } > \"$depfile\"\n    rm -f \"$tmpdepfile\"\n  else\n    make_dummy_depfile\n  fi\n}\n\n# A tabulation character.\ntab='\t'\n# A newline character.\nnl='\n'\n# Character ranges might be problematic outside the C locale.\n# These definitions help.\nupper=ABCDEFGHIJKLMNOPQRSTUVWXYZ\nlower=abcdefghijklmnopqrstuvwxyz\ndigits=0123456789\nalpha=${upper}${lower}\n\nif test -z \"$depmode\" || test -z \"$source\" || test -z \"$object\"; then\n  echo \"depcomp: Variables source, object and depmode must be set\" 1>&2\n  exit 1\nfi\n\n# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.\ndepfile=${depfile-`echo \"$object\" |\n  sed 's|[^\\\\/]*$|'${DEPDIR-.deps}'/&|;s|\\.\\([^.]*\\)$|.P\\1|;s|Pobj$|Po|'`}\ntmpdepfile=${tmpdepfile-`echo \"$depfile\" | sed 's/\\.\\([^.]*\\)$/.T\\1/'`}\n\nrm -f \"$tmpdepfile\"\n\n# Avoid interferences from the environment.\ngccflag= dashmflag=\n\n# Some modes work just like other modes, but use different flags.  We\n# parameterize here, but still list the modes in the big case below,\n# to make depend.m4 easier to write.  Note that we *cannot* use a case\n# here, because this file can only contain one case statement.\nif test \"$depmode\" = hp; then\n  # HP compiler uses -M and no extra arg.\n  gccflag=-M\n  depmode=gcc\nfi\n\nif test \"$depmode\" = dashXmstdout; then\n  # This is just like dashmstdout with a different argument.\n  dashmflag=-xM\n  depmode=dashmstdout\nfi\n\ncygpath_u=\"cygpath -u -f -\"\nif test \"$depmode\" = msvcmsys; then\n  # This is just like msvisualcpp but w/o cygpath translation.\n  # Just convert the backslash-escaped backslashes to single forward\n  # slashes to satisfy depend.m4\n  cygpath_u='sed s,\\\\\\\\,/,g'\n  depmode=msvisualcpp\nfi\n\nif test \"$depmode\" = msvc7msys; then\n  # This is just like msvc7 but w/o cygpath translation.\n  # Just convert the backslash-escaped backslashes to single forward\n  # slashes to satisfy depend.m4\n  cygpath_u='sed s,\\\\\\\\,/,g'\n  depmode=msvc7\nfi\n\nif test \"$depmode\" = xlc; then\n  # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information.\n  gccflag=-qmakedep=gcc,-MF\n  depmode=gcc\nfi\n\ncase \"$depmode\" in\ngcc3)\n## gcc 3 implements dependency tracking that does exactly what\n## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like\n## it if -MD -MP comes after the -MF stuff.  Hmm.\n## Unfortunately, FreeBSD c89 acceptance of flags depends upon\n## the command line argument order; so add the flags where they\n## appear in depend2.am.  Note that the slowdown incurred here\n## affects only configure: in makefiles, %FASTDEP% shortcuts this.\n  for arg\n  do\n    case $arg in\n    -c) set fnord \"$@\" -MT \"$object\" -MD -MP -MF \"$tmpdepfile\" \"$arg\" ;;\n    *)  set fnord \"$@\" \"$arg\" ;;\n    esac\n    shift # fnord\n    shift # $arg\n  done\n  \"$@\"\n  stat=$?\n  if test $stat -ne 0; then\n    rm -f \"$tmpdepfile\"\n    exit $stat\n  fi\n  mv \"$tmpdepfile\" \"$depfile\"\n  ;;\n\ngcc)\n## Note that this doesn't just cater to obsosete pre-3.x GCC compilers.\n## but also to in-use compilers like IMB xlc/xlC and the HP C compiler.\n## (see the conditional assignment to $gccflag above).\n## There are various ways to get dependency output from gcc.  Here's\n## why we pick this rather obscure method:\n## - Don't want to use -MD because we'd like the dependencies to end\n##   up in a subdir.  Having to rename by hand is ugly.\n##   (We might end up doing this anyway to support other compilers.)\n## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like\n##   -MM, not -M (despite what the docs say).  Also, it might not be\n##   supported by the other compilers which use the 'gcc' depmode.\n## - Using -M directly means running the compiler twice (even worse\n##   than renaming).\n  if test -z \"$gccflag\"; then\n    gccflag=-MD,\n  fi\n  \"$@\" -Wp,\"$gccflag$tmpdepfile\"\n  stat=$?\n  if test $stat -ne 0; then\n    rm -f \"$tmpdepfile\"\n    exit $stat\n  fi\n  rm -f \"$depfile\"\n  echo \"$object : \\\\\" > \"$depfile\"\n  # The second -e expression handles DOS-style file names with drive\n  # letters.\n  sed -e 's/^[^:]*: / /' \\\n      -e 's/^['$alpha']:\\/[^:]*: / /' < \"$tmpdepfile\" >> \"$depfile\"\n## This next piece of magic avoids the \"deleted header file\" problem.\n## The problem is that when a header file which appears in a .P file\n## is deleted, the dependency causes make to die (because there is\n## typically no way to rebuild the header).  We avoid this by adding\n## dummy dependencies for each header file.  Too bad gcc doesn't do\n## this for us directly.\n## Some versions of gcc put a space before the ':'.  On the theory\n## that the space means something, we add a space to the output as\n## well.  hp depmode also adds that space, but also prefixes the VPATH\n## to the object.  Take care to not repeat it in the output.\n## Some versions of the HPUX 10.20 sed can't process this invocation\n## correctly.  Breaking it into two sed invocations is a workaround.\n  tr ' ' \"$nl\" < \"$tmpdepfile\" \\\n    | sed -e 's/^\\\\$//' -e '/^$/d' -e \"s|.*$object$||\" -e '/:$/d' \\\n    | sed -e 's/$/ :/' >> \"$depfile\"\n  rm -f \"$tmpdepfile\"\n  ;;\n\nhp)\n  # This case exists only to let depend.m4 do its work.  It works by\n  # looking at the text of this script.  This case will never be run,\n  # since it is checked for above.\n  exit 1\n  ;;\n\nsgi)\n  if test \"$libtool\" = yes; then\n    \"$@\" \"-Wp,-MDupdate,$tmpdepfile\"\n  else\n    \"$@\" -MDupdate \"$tmpdepfile\"\n  fi\n  stat=$?\n  if test $stat -ne 0; then\n    rm -f \"$tmpdepfile\"\n    exit $stat\n  fi\n  rm -f \"$depfile\"\n\n  if test -f \"$tmpdepfile\"; then  # yes, the sourcefile depend on other files\n    echo \"$object : \\\\\" > \"$depfile\"\n    # Clip off the initial element (the dependent).  Don't try to be\n    # clever and replace this with sed code, as IRIX sed won't handle\n    # lines with more than a fixed number of characters (4096 in\n    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;\n    # the IRIX cc adds comments like '#:fec' to the end of the\n    # dependency line.\n    tr ' ' \"$nl\" < \"$tmpdepfile\" \\\n      | sed -e 's/^.*\\.o://' -e 's/#.*$//' -e '/^$/ d' \\\n      | tr \"$nl\" ' ' >> \"$depfile\"\n    echo >> \"$depfile\"\n    # The second pass generates a dummy entry for each header file.\n    tr ' ' \"$nl\" < \"$tmpdepfile\" \\\n      | sed -e 's/^.*\\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \\\n      >> \"$depfile\"\n  else\n    make_dummy_depfile\n  fi\n  rm -f \"$tmpdepfile\"\n  ;;\n\nxlc)\n  # This case exists only to let depend.m4 do its work.  It works by\n  # looking at the text of this script.  This case will never be run,\n  # since it is checked for above.\n  exit 1\n  ;;\n\naix)\n  # The C for AIX Compiler uses -M and outputs the dependencies\n  # in a .u file.  In older versions, this file always lives in the\n  # current directory.  Also, the AIX compiler puts '$object:' at the\n  # start of each line; $object doesn't have directory information.\n  # Version 6 uses the directory in both cases.\n  set_dir_from \"$object\"\n  set_base_from \"$object\"\n  if test \"$libtool\" = yes; then\n    tmpdepfile1=$dir$base.u\n    tmpdepfile2=$base.u\n    tmpdepfile3=$dir.libs/$base.u\n    \"$@\" -Wc,-M\n  else\n    tmpdepfile1=$dir$base.u\n    tmpdepfile2=$dir$base.u\n    tmpdepfile3=$dir$base.u\n    \"$@\" -M\n  fi\n  stat=$?\n  if test $stat -ne 0; then\n    rm -f \"$tmpdepfile1\" \"$tmpdepfile2\" \"$tmpdepfile3\"\n    exit $stat\n  fi\n\n  for tmpdepfile in \"$tmpdepfile1\" \"$tmpdepfile2\" \"$tmpdepfile3\"\n  do\n    test -f \"$tmpdepfile\" && break\n  done\n  aix_post_process_depfile\n  ;;\n\ntcc)\n  # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26\n  # FIXME: That version still under development at the moment of writing.\n  #        Make that this statement remains true also for stable, released\n  #        versions.\n  # It will wrap lines (doesn't matter whether long or short) with a\n  # trailing '\\', as in:\n  #\n  #   foo.o : \\\n  #    foo.c \\\n  #    foo.h \\\n  #\n  # It will put a trailing '\\' even on the last line, and will use leading\n  # spaces rather than leading tabs (at least since its commit 0394caf7\n  # \"Emit spaces for -MD\").\n  \"$@\" -MD -MF \"$tmpdepfile\"\n  stat=$?\n  if test $stat -ne 0; then\n    rm -f \"$tmpdepfile\"\n    exit $stat\n  fi\n  rm -f \"$depfile\"\n  # Each non-empty line is of the form 'foo.o : \\' or ' dep.h \\'.\n  # We have to change lines of the first kind to '$object: \\'.\n  sed -e \"s|.*:|$object :|\" < \"$tmpdepfile\" > \"$depfile\"\n  # And for each line of the second kind, we have to emit a 'dep.h:'\n  # dummy dependency, to avoid the deleted-header problem.\n  sed -n -e 's|^  *\\(.*\\) *\\\\$|\\1:|p' < \"$tmpdepfile\" >> \"$depfile\"\n  rm -f \"$tmpdepfile\"\n  ;;\n\n## The order of this option in the case statement is important, since the\n## shell code in configure will try each of these formats in the order\n## listed in this file.  A plain '-MD' option would be understood by many\n## compilers, so we must ensure this comes after the gcc and icc options.\npgcc)\n  # Portland's C compiler understands '-MD'.\n  # Will always output deps to 'file.d' where file is the root name of the\n  # source file under compilation, even if file resides in a subdirectory.\n  # The object file name does not affect the name of the '.d' file.\n  # pgcc 10.2 will output\n  #    foo.o: sub/foo.c sub/foo.h\n  # and will wrap long lines using '\\' :\n  #    foo.o: sub/foo.c ... \\\n  #     sub/foo.h ... \\\n  #     ...\n  set_dir_from \"$object\"\n  # Use the source, not the object, to determine the base name, since\n  # that's sadly what pgcc will do too.\n  set_base_from \"$source\"\n  tmpdepfile=$base.d\n\n  # For projects that build the same source file twice into different object\n  # files, the pgcc approach of using the *source* file root name can cause\n  # problems in parallel builds.  Use a locking strategy to avoid stomping on\n  # the same $tmpdepfile.\n  lockdir=$base.d-lock\n  trap \"\n    echo '$0: caught signal, cleaning up...' >&2\n    rmdir '$lockdir'\n    exit 1\n  \" 1 2 13 15\n  numtries=100\n  i=$numtries\n  while test $i -gt 0; do\n    # mkdir is a portable test-and-set.\n    if mkdir \"$lockdir\" 2>/dev/null; then\n      # This process acquired the lock.\n      \"$@\" -MD\n      stat=$?\n      # Release the lock.\n      rmdir \"$lockdir\"\n      break\n    else\n      # If the lock is being held by a different process, wait\n      # until the winning process is done or we timeout.\n      while test -d \"$lockdir\" && test $i -gt 0; do\n        sleep 1\n        i=`expr $i - 1`\n      done\n    fi\n    i=`expr $i - 1`\n  done\n  trap - 1 2 13 15\n  if test $i -le 0; then\n    echo \"$0: failed to acquire lock after $numtries attempts\" >&2\n    echo \"$0: check lockdir '$lockdir'\" >&2\n    exit 1\n  fi\n\n  if test $stat -ne 0; then\n    rm -f \"$tmpdepfile\"\n    exit $stat\n  fi\n  rm -f \"$depfile\"\n  # Each line is of the form `foo.o: dependent.h',\n  # or `foo.o: dep1.h dep2.h \\', or ` dep3.h dep4.h \\'.\n  # Do two passes, one to just change these to\n  # `$object: dependent.h' and one to simply `dependent.h:'.\n  sed \"s,^[^:]*:,$object :,\" < \"$tmpdepfile\" > \"$depfile\"\n  # Some versions of the HPUX 10.20 sed can't process this invocation\n  # correctly.  Breaking it into two sed invocations is a workaround.\n  sed 's,^[^:]*: \\(.*\\)$,\\1,;s/^\\\\$//;/^$/d;/:$/d' < \"$tmpdepfile\" \\\n    | sed -e 's/$/ :/' >> \"$depfile\"\n  rm -f \"$tmpdepfile\"\n  ;;\n\nhp2)\n  # The \"hp\" stanza above does not work with aCC (C++) and HP's ia64\n  # compilers, which have integrated preprocessors.  The correct option\n  # to use with these is +Maked; it writes dependencies to a file named\n  # 'foo.d', which lands next to the object file, wherever that\n  # happens to be.\n  # Much of this is similar to the tru64 case; see comments there.\n  set_dir_from  \"$object\"\n  set_base_from \"$object\"\n  if test \"$libtool\" = yes; then\n    tmpdepfile1=$dir$base.d\n    tmpdepfile2=$dir.libs/$base.d\n    \"$@\" -Wc,+Maked\n  else\n    tmpdepfile1=$dir$base.d\n    tmpdepfile2=$dir$base.d\n    \"$@\" +Maked\n  fi\n  stat=$?\n  if test $stat -ne 0; then\n     rm -f \"$tmpdepfile1\" \"$tmpdepfile2\"\n     exit $stat\n  fi\n\n  for tmpdepfile in \"$tmpdepfile1\" \"$tmpdepfile2\"\n  do\n    test -f \"$tmpdepfile\" && break\n  done\n  if test -f \"$tmpdepfile\"; then\n    sed -e \"s,^.*\\.[$lower]*:,$object:,\" \"$tmpdepfile\" > \"$depfile\"\n    # Add 'dependent.h:' lines.\n    sed -ne '2,${\n               s/^ *//\n               s/ \\\\*$//\n               s/$/:/\n               p\n             }' \"$tmpdepfile\" >> \"$depfile\"\n  else\n    make_dummy_depfile\n  fi\n  rm -f \"$tmpdepfile\" \"$tmpdepfile2\"\n  ;;\n\ntru64)\n  # The Tru64 compiler uses -MD to generate dependencies as a side\n  # effect.  'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.\n  # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put\n  # dependencies in 'foo.d' instead, so we check for that too.\n  # Subdirectories are respected.\n  set_dir_from  \"$object\"\n  set_base_from \"$object\"\n\n  if test \"$libtool\" = yes; then\n    # Libtool generates 2 separate objects for the 2 libraries.  These\n    # two compilations output dependencies in $dir.libs/$base.o.d and\n    # in $dir$base.o.d.  We have to check for both files, because\n    # one of the two compilations can be disabled.  We should prefer\n    # $dir$base.o.d over $dir.libs/$base.o.d because the latter is\n    # automatically cleaned when .libs/ is deleted, while ignoring\n    # the former would cause a distcleancheck panic.\n    tmpdepfile1=$dir$base.o.d          # libtool 1.5\n    tmpdepfile2=$dir.libs/$base.o.d    # Likewise.\n    tmpdepfile3=$dir.libs/$base.d      # Compaq CCC V6.2-504\n    \"$@\" -Wc,-MD\n  else\n    tmpdepfile1=$dir$base.d\n    tmpdepfile2=$dir$base.d\n    tmpdepfile3=$dir$base.d\n    \"$@\" -MD\n  fi\n\n  stat=$?\n  if test $stat -ne 0; then\n    rm -f \"$tmpdepfile1\" \"$tmpdepfile2\" \"$tmpdepfile3\"\n    exit $stat\n  fi\n\n  for tmpdepfile in \"$tmpdepfile1\" \"$tmpdepfile2\" \"$tmpdepfile3\"\n  do\n    test -f \"$tmpdepfile\" && break\n  done\n  # Same post-processing that is required for AIX mode.\n  aix_post_process_depfile\n  ;;\n\nmsvc7)\n  if test \"$libtool\" = yes; then\n    showIncludes=-Wc,-showIncludes\n  else\n    showIncludes=-showIncludes\n  fi\n  \"$@\" $showIncludes > \"$tmpdepfile\"\n  stat=$?\n  grep -v '^Note: including file: ' \"$tmpdepfile\"\n  if test $stat -ne 0; then\n    rm -f \"$tmpdepfile\"\n    exit $stat\n  fi\n  rm -f \"$depfile\"\n  echo \"$object : \\\\\" > \"$depfile\"\n  # The first sed program below extracts the file names and escapes\n  # backslashes for cygpath.  The second sed program outputs the file\n  # name when reading, but also accumulates all include files in the\n  # hold buffer in order to output them again at the end.  This only\n  # works with sed implementations that can handle large buffers.\n  sed < \"$tmpdepfile\" -n '\n/^Note: including file:  *\\(.*\\)/ {\n  s//\\1/\n  s/\\\\/\\\\\\\\/g\n  p\n}' | $cygpath_u | sort -u | sed -n '\ns/ /\\\\ /g\ns/\\(.*\\)/'\"$tab\"'\\1 \\\\/p\ns/.\\(.*\\) \\\\/\\1:/\nH\n$ {\n  s/.*/'\"$tab\"'/\n  G\n  p\n}' >> \"$depfile\"\n  echo >> \"$depfile\" # make sure the fragment doesn't end with a backslash\n  rm -f \"$tmpdepfile\"\n  ;;\n\nmsvc7msys)\n  # This case exists only to let depend.m4 do its work.  It works by\n  # looking at the text of this script.  This case will never be run,\n  # since it is checked for above.\n  exit 1\n  ;;\n\n#nosideeffect)\n  # This comment above is used by automake to tell side-effect\n  # dependency tracking mechanisms from slower ones.\n\ndashmstdout)\n  # Important note: in order to support this mode, a compiler *must*\n  # always write the preprocessed file to stdout, regardless of -o.\n  \"$@\" || exit $?\n\n  # Remove the call to Libtool.\n  if test \"$libtool\" = yes; then\n    while test \"X$1\" != 'X--mode=compile'; do\n      shift\n    done\n    shift\n  fi\n\n  # Remove '-o $object'.\n  IFS=\" \"\n  for arg\n  do\n    case $arg in\n    -o)\n      shift\n      ;;\n    $object)\n      shift\n      ;;\n    *)\n      set fnord \"$@\" \"$arg\"\n      shift # fnord\n      shift # $arg\n      ;;\n    esac\n  done\n\n  test -z \"$dashmflag\" && dashmflag=-M\n  # Require at least two characters before searching for ':'\n  # in the target name.  This is to cope with DOS-style filenames:\n  # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.\n  \"$@\" $dashmflag |\n    sed \"s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |\" > \"$tmpdepfile\"\n  rm -f \"$depfile\"\n  cat < \"$tmpdepfile\" > \"$depfile\"\n  # Some versions of the HPUX 10.20 sed can't process this sed invocation\n  # correctly.  Breaking it into two sed invocations is a workaround.\n  tr ' ' \"$nl\" < \"$tmpdepfile\" \\\n    | sed -e 's/^\\\\$//' -e '/^$/d' -e '/:$/d' \\\n    | sed -e 's/$/ :/' >> \"$depfile\"\n  rm -f \"$tmpdepfile\"\n  ;;\n\ndashXmstdout)\n  # This case only exists to satisfy depend.m4.  It is never actually\n  # run, as this mode is specially recognized in the preamble.\n  exit 1\n  ;;\n\nmakedepend)\n  \"$@\" || exit $?\n  # Remove any Libtool call\n  if test \"$libtool\" = yes; then\n    while test \"X$1\" != 'X--mode=compile'; do\n      shift\n    done\n    shift\n  fi\n  # X makedepend\n  shift\n  cleared=no eat=no\n  for arg\n  do\n    case $cleared in\n    no)\n      set \"\"; shift\n      cleared=yes ;;\n    esac\n    if test $eat = yes; then\n      eat=no\n      continue\n    fi\n    case \"$arg\" in\n    -D*|-I*)\n      set fnord \"$@\" \"$arg\"; shift ;;\n    # Strip any option that makedepend may not understand.  Remove\n    # the object too, otherwise makedepend will parse it as a source file.\n    -arch)\n      eat=yes ;;\n    -*|$object)\n      ;;\n    *)\n      set fnord \"$@\" \"$arg\"; shift ;;\n    esac\n  done\n  obj_suffix=`echo \"$object\" | sed 's/^.*\\././'`\n  touch \"$tmpdepfile\"\n  ${MAKEDEPEND-makedepend} -o\"$obj_suffix\" -f\"$tmpdepfile\" \"$@\"\n  rm -f \"$depfile\"\n  # makedepend may prepend the VPATH from the source file name to the object.\n  # No need to regex-escape $object, excess matching of '.' is harmless.\n  sed \"s|^.*\\($object *:\\)|\\1|\" \"$tmpdepfile\" > \"$depfile\"\n  # Some versions of the HPUX 10.20 sed can't process the last invocation\n  # correctly.  Breaking it into two sed invocations is a workaround.\n  sed '1,2d' \"$tmpdepfile\" \\\n    | tr ' ' \"$nl\" \\\n    | sed -e 's/^\\\\$//' -e '/^$/d' -e '/:$/d' \\\n    | sed -e 's/$/ :/' >> \"$depfile\"\n  rm -f \"$tmpdepfile\" \"$tmpdepfile\".bak\n  ;;\n\ncpp)\n  # Important note: in order to support this mode, a compiler *must*\n  # always write the preprocessed file to stdout.\n  \"$@\" || exit $?\n\n  # Remove the call to Libtool.\n  if test \"$libtool\" = yes; then\n    while test \"X$1\" != 'X--mode=compile'; do\n      shift\n    done\n    shift\n  fi\n\n  # Remove '-o $object'.\n  IFS=\" \"\n  for arg\n  do\n    case $arg in\n    -o)\n      shift\n      ;;\n    $object)\n      shift\n      ;;\n    *)\n      set fnord \"$@\" \"$arg\"\n      shift # fnord\n      shift # $arg\n      ;;\n    esac\n  done\n\n  \"$@\" -E \\\n    | sed -n -e '/^# [0-9][0-9]* \"\\([^\"]*\\)\".*/ s:: \\1 \\\\:p' \\\n             -e '/^#line [0-9][0-9]* \"\\([^\"]*\\)\".*/ s:: \\1 \\\\:p' \\\n    | sed '$ s: \\\\$::' > \"$tmpdepfile\"\n  rm -f \"$depfile\"\n  echo \"$object : \\\\\" > \"$depfile\"\n  cat < \"$tmpdepfile\" >> \"$depfile\"\n  sed < \"$tmpdepfile\" '/^$/d;s/^ //;s/ \\\\$//;s/$/ :/' >> \"$depfile\"\n  rm -f \"$tmpdepfile\"\n  ;;\n\nmsvisualcpp)\n  # Important note: in order to support this mode, a compiler *must*\n  # always write the preprocessed file to stdout.\n  \"$@\" || exit $?\n\n  # Remove the call to Libtool.\n  if test \"$libtool\" = yes; then\n    while test \"X$1\" != 'X--mode=compile'; do\n      shift\n    done\n    shift\n  fi\n\n  IFS=\" \"\n  for arg\n  do\n    case \"$arg\" in\n    -o)\n      shift\n      ;;\n    $object)\n      shift\n      ;;\n    \"-Gm\"|\"/Gm\"|\"-Gi\"|\"/Gi\"|\"-ZI\"|\"/ZI\")\n        set fnord \"$@\"\n        shift\n        shift\n        ;;\n    *)\n        set fnord \"$@\" \"$arg\"\n        shift\n        shift\n        ;;\n    esac\n  done\n  \"$@\" -E 2>/dev/null |\n  sed -n '/^#line [0-9][0-9]* \"\\([^\"]*\\)\"/ s::\\1:p' | $cygpath_u | sort -u > \"$tmpdepfile\"\n  rm -f \"$depfile\"\n  echo \"$object : \\\\\" > \"$depfile\"\n  sed < \"$tmpdepfile\" -n -e 's% %\\\\ %g' -e '/^\\(.*\\)$/ s::'\"$tab\"'\\1 \\\\:p' >> \"$depfile\"\n  echo \"$tab\" >> \"$depfile\"\n  sed < \"$tmpdepfile\" -n -e 's% %\\\\ %g' -e '/^\\(.*\\)$/ s::\\1\\::p' >> \"$depfile\"\n  rm -f \"$tmpdepfile\"\n  ;;\n\nmsvcmsys)\n  # This case exists only to let depend.m4 do its work.  It works by\n  # looking at the text of this script.  This case will never be run,\n  # since it is checked for above.\n  exit 1\n  ;;\n\nnone)\n  exec \"$@\"\n  ;;\n\n*)\n  echo \"Unknown depmode $depmode\" 1>&2\n  exit 1\n  ;;\nesac\n\nexit 0\n\n# Local Variables:\n# mode: shell-script\n# sh-indentation: 2\n# eval: (add-hook 'write-file-hooks 'time-stamp)\n# time-stamp-start: \"scriptversion=\"\n# time-stamp-format: \"%:y-%02m-%02d.%02H\"\n# time-stamp-time-zone: \"UTC\"\n# time-stamp-end: \"; # UTC\"\n# End:\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/editors/README.txt",
    "content": "This directory contains syntax highlighting and configuration files for editors\r\nto properly display Protocol Buffer files.\r\n\r\nSee each file's header comment for directions on how to use it with the\r\nappropriate editor.\r\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/editors/proto.vim",
    "content": "\" Protocol Buffers - Google's data interchange format\n\" Copyright 2008 Google Inc.  All rights reserved.\n\" https://developers.google.com/protocol-buffers/\n\"\n\" Redistribution and use in source and binary forms, with or without\n\" modification, are permitted provided that the following conditions are\n\" met:\n\"\n\"     * Redistributions of source code must retain the above copyright\n\" notice, this list of conditions and the following disclaimer.\n\"     * Redistributions in binary form must reproduce the above\n\" copyright notice, this list of conditions and the following disclaimer\n\" in the documentation and/or other materials provided with the\n\" distribution.\n\"     * Neither the name of Google Inc. nor the names of its\n\" contributors may be used to endorse or promote products derived from\n\" this software without specific prior written permission.\n\"\n\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\" \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\" This is the Vim syntax file for Google Protocol Buffers.\n\"\n\" Usage:\n\"\n\" 1. cp proto.vim ~/.vim/syntax/\n\" 2. Add the following to ~/.vimrc:\n\"\n\" augroup filetype\n\"   au! BufRead,BufNewFile *.proto setfiletype proto\n\" augroup end\n\"\n\" Or just create a new file called ~/.vim/ftdetect/proto.vim with the\n\" previous lines on it.\n\nif version < 600\n  syntax clear\nelseif exists(\"b:current_syntax\")\n  finish\nendif\n\nsyn case match\n\nsyn keyword pbTodo       contained TODO FIXME XXX\nsyn cluster pbCommentGrp contains=pbTodo\n\nsyn keyword pbSyntax     syntax import option\nsyn keyword pbStructure  package message group oneof\nsyn keyword pbRepeat     optional required repeated\nsyn keyword pbDefault    default\nsyn keyword pbExtend     extend extensions to max reserved\nsyn keyword pbRPC        service rpc returns\n\nsyn keyword pbType      int32 int64 uint32 uint64 sint32 sint64\nsyn keyword pbType      fixed32 fixed64 sfixed32 sfixed64\nsyn keyword pbType      float double bool string bytes\nsyn keyword pbTypedef   enum\nsyn keyword pbBool      true false\n\nsyn match   pbInt     /-\\?\\<\\d\\+\\>/\nsyn match   pbInt     /\\<0[xX]\\x+\\>/\nsyn match   pbFloat   /\\<-\\?\\d*\\(\\.\\d*\\)\\?/\nsyn region  pbComment start=\"\\/\\*\" end=\"\\*\\/\" contains=@pbCommentGrp\nsyn region  pbComment start=\"//\" skip=\"\\\\$\" end=\"$\" keepend contains=@pbCommentGrp\nsyn region  pbString  start=/\"/ skip=/\\\\./ end=/\"/\nsyn region  pbString  start=/'/ skip=/\\\\./ end=/'/\n\nif version >= 508 || !exists(\"did_proto_syn_inits\")\n  if version < 508\n    let did_proto_syn_inits = 1\n    command -nargs=+ HiLink hi link <args>\n  else\n    command -nargs=+ HiLink hi def link <args>\n  endif\n\n  HiLink pbTodo         Todo\n\n  HiLink pbSyntax       Include\n  HiLink pbStructure    Structure\n  HiLink pbRepeat       Repeat\n  HiLink pbDefault      Keyword\n  HiLink pbExtend       Keyword\n  HiLink pbRPC          Keyword\n  HiLink pbType         Type\n  HiLink pbTypedef      Typedef\n  HiLink pbBool         Boolean\n\n  HiLink pbInt          Number\n  HiLink pbFloat        Float\n  HiLink pbComment      Comment\n  HiLink pbString       String\n\n  delcommand HiLink\nendif\n\nlet b:current_syntax = \"proto\"\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/editors/protobuf-mode.el",
    "content": ";;; protobuf-mode.el --- major mode for editing protocol buffers.\n\n;; Author: Alexandre Vassalotti <alexandre@peadrop.com>\n;; Created: 23-Apr-2009\n;; Version: 0.3\n;; Keywords: google protobuf languages\n\n;; Redistribution and use in source and binary forms, with or without\n;; modification, are permitted provided that the following conditions are\n;; met:\n;;\n;;     * Redistributions of source code must retain the above copyright\n;; notice, this list of conditions and the following disclaimer.\n;;     * Redistributions in binary form must reproduce the above\n;; copyright notice, this list of conditions and the following disclaimer\n;; in the documentation and/or other materials provided with the\n;; distribution.\n;;     * Neither the name of Google Inc. nor the names of its\n;; contributors may be used to endorse or promote products derived from\n;; this software without specific prior written permission.\n;;\n;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n;; \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n;;; Commentary:\n\n;; Installation:\n;;   - Put `protobuf-mode.el' in your Emacs load-path.\n;;   - Add this line to your .emacs file:\n;;       (require 'protobuf-mode)\n;;\n;; You can customize this mode just like any mode derived from CC Mode.  If\n;; you want to add customizations specific to protobuf-mode, you can use the\n;; `protobuf-mode-hook'. For example, the following would make protocol-mode\n;; use 2-space indentation:\n;;\n;;   (defconst my-protobuf-style\n;;     '((c-basic-offset . 2)\n;;       (indent-tabs-mode . nil)))\n;;\n;;   (add-hook 'protobuf-mode-hook\n;;     (lambda () (c-add-style \"my-style\" my-protobuf-style t)))\n;;\n;; Refer to the documentation of CC Mode for more information about\n;; customization details and how to use this mode.\n;;\n;; TODO:\n;;   - Make highlighting for enum values work properly.\n;;   - Fix the parser to recognize extensions as identifiers and not\n;;     as casts.\n;;   - Improve the parsing of option assignment lists. For example:\n;;       optional int32 foo = 1 [(my_field_option) = 4.5];\n;;   - Add support for fully-qualified identifiers (e.g., with a leading \".\").\n\n;;; Code:\n\n(require 'cc-mode)\n\n(eval-when-compile\n  (require 'cc-langs)\n  (require 'cc-fonts))\n\n;; This mode does not inherit properties from other modes. So, we do not use \n;; the usual `c-add-language' function.\n(eval-and-compile\n  (put 'protobuf-mode 'c-mode-prefix \"protobuf-\"))\n\n;; The following code uses of the `c-lang-defconst' macro define syntactic\n;; features of protocol buffer language.  Refer to the documentation in the\n;; cc-langs.el file for information about the meaning of the -kwds variables.\n\n(c-lang-defconst c-primitive-type-kwds\n  protobuf '(\"double\" \"float\" \"int32\" \"int64\" \"uint32\" \"uint64\" \"sint32\"\n             \"sint64\" \"fixed32\" \"fixed64\" \"sfixed32\" \"sfixed64\" \"bool\"\n             \"string\" \"bytes\" \"group\"))\n\n(c-lang-defconst c-modifier-kwds\n  protobuf '(\"required\" \"optional\" \"repeated\"))\n\n(c-lang-defconst c-class-decl-kwds\n  protobuf '(\"message\" \"enum\" \"service\"))\n\n(c-lang-defconst c-constant-kwds\n  protobuf '(\"true\" \"false\"))\n\n(c-lang-defconst c-other-decl-kwds\n  protobuf '(\"package\" \"import\"))\n\n(c-lang-defconst c-other-kwds\n  protobuf '(\"default\" \"max\"))\n\n(c-lang-defconst c-identifier-ops\n  ;; Handle extended identifiers like google.protobuf.MessageOptions\n  protobuf '((left-assoc \".\")))\n\n;; The following keywords do not fit well in keyword classes defined by\n;; cc-mode.  So, we approximate as best we can.\n\n(c-lang-defconst c-type-list-kwds\n  protobuf '(\"extensions\" \"to\" \"reserved\"))\n\n(c-lang-defconst c-typeless-decl-kwds\n  protobuf '(\"extend\" \"rpc\" \"option\" \"returns\"))\n\n\n;; Here we remove default syntax for loops, if-statements and other C\n;; syntactic features that are not supported by the protocol buffer language.\n\n(c-lang-defconst c-brace-list-decl-kwds\n  ;; Remove syntax for C-style enumerations.\n  protobuf nil)\n\n(c-lang-defconst c-block-stmt-1-kwds\n  ;; Remove syntax for \"do\" and \"else\" keywords.\n  protobuf nil)\n\n(c-lang-defconst c-block-stmt-2-kwds\n  ;; Remove syntax for \"for\", \"if\", \"switch\" and \"while\" keywords.\n  protobuf nil)\n\n(c-lang-defconst c-simple-stmt-kwds\n  ;; Remove syntax for \"break\", \"continue\", \"goto\" and \"return\" keywords.\n  protobuf nil)\n\n(c-lang-defconst c-paren-stmt-kwds\n  ;; Remove special case for the \"(;;)\" in for-loops.\n  protobuf nil)\n\n(c-lang-defconst c-label-kwds\n  ;; Remove case label syntax for the \"case\" and \"default\" keywords.\n  protobuf nil)\n\n(c-lang-defconst c-before-label-kwds\n  ;; Remove special case for the label in a goto statement.\n  protobuf nil)\n\n(c-lang-defconst c-cpp-matchers\n  ;; Disable all the C preprocessor syntax.\n  protobuf nil)\n\n(c-lang-defconst c-decl-prefix-re\n  ;; Same as for C, except it does not match \"(\". This is needed for disabling\n  ;; the syntax for casts.\n  protobuf \"\\\\([\\{\\};,]+\\\\)\")\n\n\n;; Add support for variable levels of syntax highlighting.\n\n(defconst protobuf-font-lock-keywords-1 (c-lang-const c-matchers-1 protobuf)\n  \"Minimal highlighting for protobuf-mode.\")\n\n(defconst protobuf-font-lock-keywords-2 (c-lang-const c-matchers-2 protobuf)\n  \"Fast normal highlighting for protobuf-mode.\")\n\n(defconst protobuf-font-lock-keywords-3 (c-lang-const c-matchers-3 protobuf)\n  \"Accurate normal highlighting for protobuf-mode.\")\n\n(defvar protobuf-font-lock-keywords protobuf-font-lock-keywords-3\n  \"Default expressions to highlight in protobuf-mode.\")\n\n;; Our syntax table is auto-generated from the keyword classes we defined\n;; previously with the `c-lang-const' macro.\n(defvar protobuf-mode-syntax-table nil\n  \"Syntax table used in protobuf-mode buffers.\")\n(or protobuf-mode-syntax-table\n    (setq protobuf-mode-syntax-table\n          (funcall (c-lang-const c-make-mode-syntax-table protobuf))))\n\n(defvar protobuf-mode-abbrev-table nil\n  \"Abbreviation table used in protobuf-mode buffers.\")\n\n(defvar protobuf-mode-map nil\n  \"Keymap used in protobuf-mode buffers.\")\n(or protobuf-mode-map\n    (setq protobuf-mode-map (c-make-inherited-keymap)))\n\n(easy-menu-define protobuf-menu protobuf-mode-map\n  \"Protocol Buffers Mode Commands\"\n  (cons \"Protocol Buffers\" (c-lang-const c-mode-menu protobuf)))\n\n;;;###autoload (add-to-list 'auto-mode-alist '(\"\\\\.proto\\\\'\" . protobuf-mode))\n\n;;;###autoload\n(defun protobuf-mode ()\n  \"Major mode for editing Protocol Buffers description language.\n\nThe hook `c-mode-common-hook' is run with no argument at mode\ninitialization, then `protobuf-mode-hook'.\n\nKey bindings:\n\\\\{protobuf-mode-map}\"\n  (interactive)\n  (kill-all-local-variables)\n  (set-syntax-table protobuf-mode-syntax-table)\n  (setq major-mode 'protobuf-mode\n        mode-name \"Protocol-Buffers\"\n        local-abbrev-table protobuf-mode-abbrev-table\n        abbrev-mode t)\n  (use-local-map protobuf-mode-map)\n  (c-initialize-cc-mode t)\n  (if (fboundp 'c-make-emacs-variables-local)\n      (c-make-emacs-variables-local))\n  (c-init-language-vars protobuf-mode)\n  (c-common-init 'protobuf-mode)\n  (easy-menu-add protobuf-menu)\n  (c-run-mode-hooks 'c-mode-common-hook 'protobuf-mode-hook)\n  (c-update-modeline))\n\n(provide 'protobuf-mode)\n\n;;; protobuf-mode.el ends here\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/generate_descriptor_proto.sh",
    "content": "#!/bin/sh\n\n# Run this script to regenerate descriptor.pb.{h,cc} after the protocol\n# compiler changes.  Since these files are compiled into the protocol compiler\n# itself, they cannot be generated automatically by a make rule.  \"make check\"\n# will fail if these files do not match what the protocol compiler would\n# generate.\n#\n# HINT:  Flags passed to generate_descriptor_proto.sh will be passed directly\n#   to make when building protoc.  This is particularly useful for passing\n#   -j4 to run 4 jobs simultaneously.\n\nif test ! -e src/google/protobuf/stubs/common.h; then\n  cat >&2 << __EOF__\nCould not find source code.  Make sure you are running this script from the\nroot of the distribution tree.\n__EOF__\n  exit 1\nfi\n\nif test ! -e src/Makefile; then\n  cat >&2 << __EOF__\nCould not find src/Makefile.  You must run ./configure (and perhaps\n./autogen.sh) first.\n__EOF__\n  exit 1\nfi\n\ncd src\n\ndeclare -a RUNTIME_PROTO_FILES=(\\\n  google/protobuf/any.proto \\\n  google/protobuf/api.proto \\\n  google/protobuf/descriptor.proto \\\n  google/protobuf/duration.proto \\\n  google/protobuf/empty.proto \\\n  google/protobuf/field_mask.proto \\\n  google/protobuf/source_context.proto \\\n  google/protobuf/struct.proto \\\n  google/protobuf/timestamp.proto \\\n  google/protobuf/type.proto \\\n  google/protobuf/wrappers.proto)\n\nCORE_PROTO_IS_CORRECT=0\nPROCESS_ROUND=1\nTMP=$(mktemp -d)\necho \"Updating descriptor protos...\"\nwhile [ $CORE_PROTO_IS_CORRECT -ne 1 ]\ndo\n  echo \"Round $PROCESS_ROUND\"\n  CORE_PROTO_IS_CORRECT=1\n\n  make $@ protoc\n  if test $? -ne 0; then\n    echo \"Failed to build protoc.\"\n    exit 1\n  fi\n\n  ./protoc --cpp_out=dllexport_decl=LIBPROTOBUF_EXPORT:$TMP ${RUNTIME_PROTO_FILES[@]} && \\\n  ./protoc --cpp_out=dllexport_decl=LIBPROTOC_EXPORT:$TMP google/protobuf/compiler/plugin.proto\n\n  for PROTO_FILE in ${RUNTIME_PROTO_FILES[@]}; do\n    BASE_NAME=${PROTO_FILE%.*}\n    diff ${BASE_NAME}.pb.h $TMP/${BASE_NAME}.pb.h > /dev/null\n    if test $? -ne 0; then\n      CORE_PROTO_IS_CORRECT=0\n    fi\n    diff ${BASE_NAME}.pb.cc $TMP/${BASE_NAME}.pb.cc > /dev/null\n    if test $? -ne 0; then\n      CORE_PROTO_IS_CORRECT=0\n    fi\n  done\n\n  diff google/protobuf/compiler/plugin.pb.h $TMP/google/protobuf/compiler/plugin.pb.h > /dev/null\n  if test $? -ne 0; then\n    CORE_PROTO_IS_CORRECT=0\n  fi\n  diff google/protobuf/compiler/plugin.pb.cc $TMP/google/protobuf/compiler/plugin.pb.cc > /dev/null\n  if test $? -ne 0; then\n    CORE_PROTO_IS_CORRECT=0\n  fi\n\n  # Only override the output if the files are different to avoid re-compilation\n  # of the protoc.\n  if [ $CORE_PROTO_IS_CORRECT -ne 1 ]; then\n    for PROTO_FILE in ${RUNTIME_PROTO_FILES[@]}; do\n      BASE_NAME=${PROTO_FILE%.*}\n      mv $TMP/${BASE_NAME}.pb.h ${BASE_NAME}.pb.h\n      mv $TMP/${BASE_NAME}.pb.cc ${BASE_NAME}.pb.cc\n    done\n    mv $TMP/google/protobuf/compiler/plugin.pb.* google/protobuf/compiler/\n  fi\n\n  PROCESS_ROUND=$((PROCESS_ROUND + 1))\ndone\ncd ..\n\nif test -x objectivec/generate_well_known_types.sh; then\n  echo \"Generating messages for objc.\"\n  objectivec/generate_well_known_types.sh $@\nfi\n\nif test -x csharp/generate_protos.sh; then\n  echo \"Generating messages for C#.\"\n  csharp/generate_protos.sh $@\nfi\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/gmock.BUILD",
    "content": "cc_library(\n    name = \"gtest\",\n    srcs = [\n        \"gmock-1.7.0/gtest/src/gtest-all.cc\",\n        \"gmock-1.7.0/src/gmock-all.cc\",\n    ],\n    hdrs = glob([\n        \"gmock-1.7.0/**/*.h\",\n        \"gmock-1.7.0/gtest/src/*.cc\",\n        \"gmock-1.7.0/src/*.cc\",\n    ]),\n    includes = [\n        \"gmock-1.7.0\",\n        \"gmock-1.7.0/gtest\",\n        \"gmock-1.7.0/gtest/include\",\n        \"gmock-1.7.0/include\",\n    ],\n    linkopts = [\"-pthread\"],\n    visibility = [\"//visibility:public\"],\n)\n\ncc_library(\n    name = \"gtest_main\",\n    srcs = [\"gmock-1.7.0/src/gmock_main.cc\"],\n    linkopts = [\"-pthread\"],\n    visibility = [\"//visibility:public\"],\n    deps = [\":gtest\"],\n)\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/install-sh",
    "content": "#!/bin/sh\n# install - install a program, script, or datafile\n\nscriptversion=2011-11-20.07; # UTC\n\n# This originates from X11R5 (mit/util/scripts/install.sh), which was\n# later released in X11R6 (xc/config/util/install.sh) with the\n# following copyright and license.\n#\n# Copyright (C) 1994 X Consortium\n#\n# Permission is hereby granted, free of charge, to any person obtaining a copy\n# of this software and associated documentation files (the \"Software\"), to\n# deal in the Software without restriction, including without limitation the\n# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n# sell copies of the Software, and to permit persons to whom the Software is\n# furnished to do so, subject to the following conditions:\n#\n# The above copyright notice and this permission notice shall be included in\n# all copies or substantial portions of the Software.\n#\n# THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\n# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\n# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-\n# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n#\n# Except as contained in this notice, the name of the X Consortium shall not\n# be used in advertising or otherwise to promote the sale, use or other deal-\n# ings in this Software without prior written authorization from the X Consor-\n# tium.\n#\n#\n# FSF changes to this file are in the public domain.\n#\n# Calling this script install-sh is preferred over install.sh, to prevent\n# 'make' implicit rules from creating a file called install from it\n# when there is no Makefile.\n#\n# This script is compatible with the BSD install script, but was written\n# from scratch.\n\nnl='\n'\nIFS=\" \"\"\t$nl\"\n\n# set DOITPROG to echo to test this script\n\n# Don't use :- since 4.3BSD and earlier shells don't like it.\ndoit=${DOITPROG-}\nif test -z \"$doit\"; then\n  doit_exec=exec\nelse\n  doit_exec=$doit\nfi\n\n# Put in absolute file names if you don't have them in your path;\n# or use environment vars.\n\nchgrpprog=${CHGRPPROG-chgrp}\nchmodprog=${CHMODPROG-chmod}\nchownprog=${CHOWNPROG-chown}\ncmpprog=${CMPPROG-cmp}\ncpprog=${CPPROG-cp}\nmkdirprog=${MKDIRPROG-mkdir}\nmvprog=${MVPROG-mv}\nrmprog=${RMPROG-rm}\nstripprog=${STRIPPROG-strip}\n\nposix_glob='?'\ninitialize_posix_glob='\n  test \"$posix_glob\" != \"?\" || {\n    if (set -f) 2>/dev/null; then\n      posix_glob=\n    else\n      posix_glob=:\n    fi\n  }\n'\n\nposix_mkdir=\n\n# Desired mode of installed file.\nmode=0755\n\nchgrpcmd=\nchmodcmd=$chmodprog\nchowncmd=\nmvcmd=$mvprog\nrmcmd=\"$rmprog -f\"\nstripcmd=\n\nsrc=\ndst=\ndir_arg=\ndst_arg=\n\ncopy_on_change=false\nno_target_directory=\n\nusage=\"\\\nUsage: $0 [OPTION]... [-T] SRCFILE DSTFILE\n   or: $0 [OPTION]... SRCFILES... DIRECTORY\n   or: $0 [OPTION]... -t DIRECTORY SRCFILES...\n   or: $0 [OPTION]... -d DIRECTORIES...\n\nIn the 1st form, copy SRCFILE to DSTFILE.\nIn the 2nd and 3rd, copy all SRCFILES to DIRECTORY.\nIn the 4th, create DIRECTORIES.\n\nOptions:\n     --help     display this help and exit.\n     --version  display version info and exit.\n\n  -c            (ignored)\n  -C            install only if different (preserve the last data modification time)\n  -d            create directories instead of installing files.\n  -g GROUP      $chgrpprog installed files to GROUP.\n  -m MODE       $chmodprog installed files to MODE.\n  -o USER       $chownprog installed files to USER.\n  -s            $stripprog installed files.\n  -t DIRECTORY  install into DIRECTORY.\n  -T            report an error if DSTFILE is a directory.\n\nEnvironment variables override the default commands:\n  CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG\n  RMPROG STRIPPROG\n\"\n\nwhile test $# -ne 0; do\n  case $1 in\n    -c) ;;\n\n    -C) copy_on_change=true;;\n\n    -d) dir_arg=true;;\n\n    -g) chgrpcmd=\"$chgrpprog $2\"\n\tshift;;\n\n    --help) echo \"$usage\"; exit $?;;\n\n    -m) mode=$2\n\tcase $mode in\n\t  *' '* | *'\t'* | *'\n'*\t  | *'*'* | *'?'* | *'['*)\n\t    echo \"$0: invalid mode: $mode\" >&2\n\t    exit 1;;\n\tesac\n\tshift;;\n\n    -o) chowncmd=\"$chownprog $2\"\n\tshift;;\n\n    -s) stripcmd=$stripprog;;\n\n    -t) dst_arg=$2\n\t# Protect names problematic for 'test' and other utilities.\n\tcase $dst_arg in\n\t  -* | [=\\(\\)!]) dst_arg=./$dst_arg;;\n\tesac\n\tshift;;\n\n    -T) no_target_directory=true;;\n\n    --version) echo \"$0 $scriptversion\"; exit $?;;\n\n    --)\tshift\n\tbreak;;\n\n    -*)\techo \"$0: invalid option: $1\" >&2\n\texit 1;;\n\n    *)  break;;\n  esac\n  shift\ndone\n\nif test $# -ne 0 && test -z \"$dir_arg$dst_arg\"; then\n  # When -d is used, all remaining arguments are directories to create.\n  # When -t is used, the destination is already specified.\n  # Otherwise, the last argument is the destination.  Remove it from $@.\n  for arg\n  do\n    if test -n \"$dst_arg\"; then\n      # $@ is not empty: it contains at least $arg.\n      set fnord \"$@\" \"$dst_arg\"\n      shift # fnord\n    fi\n    shift # arg\n    dst_arg=$arg\n    # Protect names problematic for 'test' and other utilities.\n    case $dst_arg in\n      -* | [=\\(\\)!]) dst_arg=./$dst_arg;;\n    esac\n  done\nfi\n\nif test $# -eq 0; then\n  if test -z \"$dir_arg\"; then\n    echo \"$0: no input file specified.\" >&2\n    exit 1\n  fi\n  # It's OK to call 'install-sh -d' without argument.\n  # This can happen when creating conditional directories.\n  exit 0\nfi\n\nif test -z \"$dir_arg\"; then\n  do_exit='(exit $ret); exit $ret'\n  trap \"ret=129; $do_exit\" 1\n  trap \"ret=130; $do_exit\" 2\n  trap \"ret=141; $do_exit\" 13\n  trap \"ret=143; $do_exit\" 15\n\n  # Set umask so as not to create temps with too-generous modes.\n  # However, 'strip' requires both read and write access to temps.\n  case $mode in\n    # Optimize common cases.\n    *644) cp_umask=133;;\n    *755) cp_umask=22;;\n\n    *[0-7])\n      if test -z \"$stripcmd\"; then\n\tu_plus_rw=\n      else\n\tu_plus_rw='% 200'\n      fi\n      cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;\n    *)\n      if test -z \"$stripcmd\"; then\n\tu_plus_rw=\n      else\n\tu_plus_rw=,u+rw\n      fi\n      cp_umask=$mode$u_plus_rw;;\n  esac\nfi\n\nfor src\ndo\n  # Protect names problematic for 'test' and other utilities.\n  case $src in\n    -* | [=\\(\\)!]) src=./$src;;\n  esac\n\n  if test -n \"$dir_arg\"; then\n    dst=$src\n    dstdir=$dst\n    test -d \"$dstdir\"\n    dstdir_status=$?\n  else\n\n    # Waiting for this to be detected by the \"$cpprog $src $dsttmp\" command\n    # might cause directories to be created, which would be especially bad\n    # if $src (and thus $dsttmp) contains '*'.\n    if test ! -f \"$src\" && test ! -d \"$src\"; then\n      echo \"$0: $src does not exist.\" >&2\n      exit 1\n    fi\n\n    if test -z \"$dst_arg\"; then\n      echo \"$0: no destination specified.\" >&2\n      exit 1\n    fi\n    dst=$dst_arg\n\n    # If destination is a directory, append the input filename; won't work\n    # if double slashes aren't ignored.\n    if test -d \"$dst\"; then\n      if test -n \"$no_target_directory\"; then\n\techo \"$0: $dst_arg: Is a directory\" >&2\n\texit 1\n      fi\n      dstdir=$dst\n      dst=$dstdir/`basename \"$src\"`\n      dstdir_status=0\n    else\n      # Prefer dirname, but fall back on a substitute if dirname fails.\n      dstdir=`\n\t(dirname \"$dst\") 2>/dev/null ||\n\texpr X\"$dst\" : 'X\\(.*[^/]\\)//*[^/][^/]*/*$' \\| \\\n\t     X\"$dst\" : 'X\\(//\\)[^/]' \\| \\\n\t     X\"$dst\" : 'X\\(//\\)$' \\| \\\n\t     X\"$dst\" : 'X\\(/\\)' \\| . 2>/dev/null ||\n\techo X\"$dst\" |\n\t    sed '/^X\\(.*[^/]\\)\\/\\/*[^/][^/]*\\/*$/{\n\t\t   s//\\1/\n\t\t   q\n\t\t }\n\t\t /^X\\(\\/\\/\\)[^/].*/{\n\t\t   s//\\1/\n\t\t   q\n\t\t }\n\t\t /^X\\(\\/\\/\\)$/{\n\t\t   s//\\1/\n\t\t   q\n\t\t }\n\t\t /^X\\(\\/\\).*/{\n\t\t   s//\\1/\n\t\t   q\n\t\t }\n\t\t s/.*/./; q'\n      `\n\n      test -d \"$dstdir\"\n      dstdir_status=$?\n    fi\n  fi\n\n  obsolete_mkdir_used=false\n\n  if test $dstdir_status != 0; then\n    case $posix_mkdir in\n      '')\n\t# Create intermediate dirs using mode 755 as modified by the umask.\n\t# This is like FreeBSD 'install' as of 1997-10-28.\n\tumask=`umask`\n\tcase $stripcmd.$umask in\n\t  # Optimize common cases.\n\t  *[2367][2367]) mkdir_umask=$umask;;\n\t  .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;\n\n\t  *[0-7])\n\t    mkdir_umask=`expr $umask + 22 \\\n\t      - $umask % 100 % 40 + $umask % 20 \\\n\t      - $umask % 10 % 4 + $umask % 2\n\t    `;;\n\t  *) mkdir_umask=$umask,go-w;;\n\tesac\n\n\t# With -d, create the new directory with the user-specified mode.\n\t# Otherwise, rely on $mkdir_umask.\n\tif test -n \"$dir_arg\"; then\n\t  mkdir_mode=-m$mode\n\telse\n\t  mkdir_mode=\n\tfi\n\n\tposix_mkdir=false\n\tcase $umask in\n\t  *[123567][0-7][0-7])\n\t    # POSIX mkdir -p sets u+wx bits regardless of umask, which\n\t    # is incompatible with FreeBSD 'install' when (umask & 300) != 0.\n\t    ;;\n\t  *)\n\t    tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$\n\t    trap 'ret=$?; rmdir \"$tmpdir/d\" \"$tmpdir\" 2>/dev/null; exit $ret' 0\n\n\t    if (umask $mkdir_umask &&\n\t\texec $mkdirprog $mkdir_mode -p -- \"$tmpdir/d\") >/dev/null 2>&1\n\t    then\n\t      if test -z \"$dir_arg\" || {\n\t\t   # Check for POSIX incompatibilities with -m.\n\t\t   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or\n\t\t   # other-writable bit of parent directory when it shouldn't.\n\t\t   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.\n\t\t   ls_ld_tmpdir=`ls -ld \"$tmpdir\"`\n\t\t   case $ls_ld_tmpdir in\n\t\t     d????-?r-*) different_mode=700;;\n\t\t     d????-?--*) different_mode=755;;\n\t\t     *) false;;\n\t\t   esac &&\n\t\t   $mkdirprog -m$different_mode -p -- \"$tmpdir\" && {\n\t\t     ls_ld_tmpdir_1=`ls -ld \"$tmpdir\"`\n\t\t     test \"$ls_ld_tmpdir\" = \"$ls_ld_tmpdir_1\"\n\t\t   }\n\t\t }\n\t      then posix_mkdir=:\n\t      fi\n\t      rmdir \"$tmpdir/d\" \"$tmpdir\"\n\t    else\n\t      # Remove any dirs left behind by ancient mkdir implementations.\n\t      rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null\n\t    fi\n\t    trap '' 0;;\n\tesac;;\n    esac\n\n    if\n      $posix_mkdir && (\n\tumask $mkdir_umask &&\n\t$doit_exec $mkdirprog $mkdir_mode -p -- \"$dstdir\"\n      )\n    then :\n    else\n\n      # The umask is ridiculous, or mkdir does not conform to POSIX,\n      # or it failed possibly due to a race condition.  Create the\n      # directory the slow way, step by step, checking for races as we go.\n\n      case $dstdir in\n\t/*) prefix='/';;\n\t[-=\\(\\)!]*) prefix='./';;\n\t*)  prefix='';;\n      esac\n\n      eval \"$initialize_posix_glob\"\n\n      oIFS=$IFS\n      IFS=/\n      $posix_glob set -f\n      set fnord $dstdir\n      shift\n      $posix_glob set +f\n      IFS=$oIFS\n\n      prefixes=\n\n      for d\n      do\n\ttest X\"$d\" = X && continue\n\n\tprefix=$prefix$d\n\tif test -d \"$prefix\"; then\n\t  prefixes=\n\telse\n\t  if $posix_mkdir; then\n\t    (umask=$mkdir_umask &&\n\t     $doit_exec $mkdirprog $mkdir_mode -p -- \"$dstdir\") && break\n\t    # Don't fail if two instances are running concurrently.\n\t    test -d \"$prefix\" || exit 1\n\t  else\n\t    case $prefix in\n\t      *\\'*) qprefix=`echo \"$prefix\" | sed \"s/'/'\\\\\\\\\\\\\\\\''/g\"`;;\n\t      *) qprefix=$prefix;;\n\t    esac\n\t    prefixes=\"$prefixes '$qprefix'\"\n\t  fi\n\tfi\n\tprefix=$prefix/\n      done\n\n      if test -n \"$prefixes\"; then\n\t# Don't fail if two instances are running concurrently.\n\t(umask $mkdir_umask &&\n\t eval \"\\$doit_exec \\$mkdirprog $prefixes\") ||\n\t  test -d \"$dstdir\" || exit 1\n\tobsolete_mkdir_used=true\n      fi\n    fi\n  fi\n\n  if test -n \"$dir_arg\"; then\n    { test -z \"$chowncmd\" || $doit $chowncmd \"$dst\"; } &&\n    { test -z \"$chgrpcmd\" || $doit $chgrpcmd \"$dst\"; } &&\n    { test \"$obsolete_mkdir_used$chowncmd$chgrpcmd\" = false ||\n      test -z \"$chmodcmd\" || $doit $chmodcmd $mode \"$dst\"; } || exit 1\n  else\n\n    # Make a couple of temp file names in the proper directory.\n    dsttmp=$dstdir/_inst.$$_\n    rmtmp=$dstdir/_rm.$$_\n\n    # Trap to clean up those temp files at exit.\n    trap 'ret=$?; rm -f \"$dsttmp\" \"$rmtmp\" && exit $ret' 0\n\n    # Copy the file name to the temp name.\n    (umask $cp_umask && $doit_exec $cpprog \"$src\" \"$dsttmp\") &&\n\n    # and set any options; do chmod last to preserve setuid bits.\n    #\n    # If any of these fail, we abort the whole thing.  If we want to\n    # ignore errors from any of these, just make sure not to ignore\n    # errors from the above \"$doit $cpprog $src $dsttmp\" command.\n    #\n    { test -z \"$chowncmd\" || $doit $chowncmd \"$dsttmp\"; } &&\n    { test -z \"$chgrpcmd\" || $doit $chgrpcmd \"$dsttmp\"; } &&\n    { test -z \"$stripcmd\" || $doit $stripcmd \"$dsttmp\"; } &&\n    { test -z \"$chmodcmd\" || $doit $chmodcmd $mode \"$dsttmp\"; } &&\n\n    # If -C, don't bother to copy if it wouldn't change the file.\n    if $copy_on_change &&\n       old=`LC_ALL=C ls -dlL \"$dst\"\t2>/dev/null` &&\n       new=`LC_ALL=C ls -dlL \"$dsttmp\"\t2>/dev/null` &&\n\n       eval \"$initialize_posix_glob\" &&\n       $posix_glob set -f &&\n       set X $old && old=:$2:$4:$5:$6 &&\n       set X $new && new=:$2:$4:$5:$6 &&\n       $posix_glob set +f &&\n\n       test \"$old\" = \"$new\" &&\n       $cmpprog \"$dst\" \"$dsttmp\" >/dev/null 2>&1\n    then\n      rm -f \"$dsttmp\"\n    else\n      # Rename the file to the real destination.\n      $doit $mvcmd -f \"$dsttmp\" \"$dst\" 2>/dev/null ||\n\n      # The rename failed, perhaps because mv can't rename something else\n      # to itself, or perhaps because mv is so ancient that it does not\n      # support -f.\n      {\n\t# Now remove or move aside any old file at destination location.\n\t# We try this two ways since rm can't unlink itself on some\n\t# systems and the destination file might be busy for other\n\t# reasons.  In this case, the final cleanup might fail but the new\n\t# file should still install successfully.\n\t{\n\t  test ! -f \"$dst\" ||\n\t  $doit $rmcmd -f \"$dst\" 2>/dev/null ||\n\t  { $doit $mvcmd -f \"$dst\" \"$rmtmp\" 2>/dev/null &&\n\t    { $doit $rmcmd -f \"$rmtmp\" 2>/dev/null; :; }\n\t  } ||\n\t  { echo \"$0: cannot unlink or rename $dst\" >&2\n\t    (exit 1); exit 1\n\t  }\n\t} &&\n\n\t# Now rename the file to the real destination.\n\t$doit $mvcmd \"$dsttmp\" \"$dst\"\n      }\n    fi || exit 1\n\n    trap '' 0\n  fi\ndone\n\n# Local variables:\n# eval: (add-hook 'write-file-hooks 'time-stamp)\n# time-stamp-start: \"scriptversion=\"\n# time-stamp-format: \"%:y-%02m-%02d.%02H\"\n# time-stamp-time-zone: \"UTC\"\n# time-stamp-end: \"; # UTC\"\n# End:\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/ltmain.sh",
    "content": "\n# libtool (GNU libtool) 2.4.2\n# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996\n\n# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,\n# 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.\n# This is free software; see the source for copying conditions.  There is NO\n# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n# GNU Libtool is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 2 of the License, or\n# (at your option) any later version.\n#\n# As a special exception to the GNU General Public License,\n# if you distribute this file as part of a program or library that\n# is built using GNU Libtool, you may include this file under the\n# same distribution terms that you use for the rest of that program.\n#\n# GNU Libtool is distributed in the hope that it will be useful, but\n# WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n# General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with GNU Libtool; see the file COPYING.  If not, a copy\n# can be downloaded from http://www.gnu.org/licenses/gpl.html,\n# or obtained by writing to the Free Software Foundation, Inc.,\n# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n\n# Usage: $progname [OPTION]... [MODE-ARG]...\n#\n# Provide generalized library-building support services.\n#\n#       --config             show all configuration variables\n#       --debug              enable verbose shell tracing\n#   -n, --dry-run            display commands without modifying any files\n#       --features           display basic configuration information and exit\n#       --mode=MODE          use operation mode MODE\n#       --preserve-dup-deps  don't remove duplicate dependency libraries\n#       --quiet, --silent    don't print informational messages\n#       --no-quiet, --no-silent\n#                            print informational messages (default)\n#       --no-warn            don't display warning messages\n#       --tag=TAG            use configuration variables from tag TAG\n#   -v, --verbose            print more informational messages than default\n#       --no-verbose         don't print the extra informational messages\n#       --version            print version information\n#   -h, --help, --help-all   print short, long, or detailed help message\n#\n# MODE must be one of the following:\n#\n#         clean              remove files from the build directory\n#         compile            compile a source file into a libtool object\n#         execute            automatically set library path, then run a program\n#         finish             complete the installation of libtool libraries\n#         install            install libraries or executables\n#         link               create a library or an executable\n#         uninstall          remove libraries from an installed directory\n#\n# MODE-ARGS vary depending on the MODE.  When passed as first option,\n# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.\n# Try `$progname --help --mode=MODE' for a more detailed description of MODE.\n#\n# When reporting a bug, please describe a test case to reproduce it and\n# include the following information:\n#\n#         host-triplet:\t$host\n#         shell:\t\t$SHELL\n#         compiler:\t\t$LTCC\n#         compiler flags:\t\t$LTCFLAGS\n#         linker:\t\t$LD (gnu? $with_gnu_ld)\n#         $progname:\t(GNU libtool) 2.4.2 Debian-2.4.2-1.7ubuntu1\n#         automake:\t$automake_version\n#         autoconf:\t$autoconf_version\n#\n# Report bugs to <bug-libtool@gnu.org>.\n# GNU libtool home page: <http://www.gnu.org/software/libtool/>.\n# General help using GNU software: <http://www.gnu.org/gethelp/>.\n\nPROGRAM=libtool\nPACKAGE=libtool\nVERSION=\"2.4.2 Debian-2.4.2-1.7ubuntu1\"\nTIMESTAMP=\"\"\npackage_revision=1.3337\n\n# Be Bourne compatible\nif test -n \"${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then\n  emulate sh\n  NULLCMD=:\n  # Zsh 3.x and 4.x performs word splitting on ${1+\"$@\"}, which\n  # is contrary to our usage.  Disable this feature.\n  alias -g '${1+\"$@\"}'='\"$@\"'\n  setopt NO_GLOB_SUBST\nelse\n  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac\nfi\nBIN_SH=xpg4; export BIN_SH # for Tru64\nDUALCASE=1; export DUALCASE # for MKS sh\n\n# A function that is used when there is no print builtin or printf.\nfunc_fallback_echo ()\n{\n  eval 'cat <<_LTECHO_EOF\n$1\n_LTECHO_EOF'\n}\n\n# NLS nuisances: We save the old values to restore during execute mode.\nlt_user_locale=\nlt_safe_locale=\nfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES\ndo\n  eval \"if test \\\"\\${$lt_var+set}\\\" = set; then\n          save_$lt_var=\\$$lt_var\n          $lt_var=C\n\t  export $lt_var\n\t  lt_user_locale=\\\"$lt_var=\\\\\\$save_\\$lt_var; \\$lt_user_locale\\\"\n\t  lt_safe_locale=\\\"$lt_var=C; \\$lt_safe_locale\\\"\n\tfi\"\ndone\nLC_ALL=C\nLANGUAGE=C\nexport LANGUAGE LC_ALL\n\n$lt_unset CDPATH\n\n\n# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh\n# is ksh but when the shell is invoked as \"sh\" and the current value of\n# the _XPG environment variable is not equal to 1 (one), the special\n# positional parameter $0, within a function call, is the name of the\n# function.\nprogpath=\"$0\"\n\n\n\n: ${CP=\"cp -f\"}\ntest \"${ECHO+set}\" = set || ECHO=${as_echo-'printf %s\\n'}\n: ${MAKE=\"make\"}\n: ${MKDIR=\"mkdir\"}\n: ${MV=\"mv -f\"}\n: ${RM=\"rm -f\"}\n: ${SHELL=\"${CONFIG_SHELL-/bin/sh}\"}\n: ${Xsed=\"$SED -e 1s/^X//\"}\n\n# Global variables:\nEXIT_SUCCESS=0\nEXIT_FAILURE=1\nEXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.\nEXIT_SKIP=77\t  # $? = 77 is used to indicate a skipped test to automake.\n\nexit_status=$EXIT_SUCCESS\n\n# Make sure IFS has a sensible default\nlt_nl='\n'\nIFS=\" \t$lt_nl\"\n\ndirname=\"s,/[^/]*$,,\"\nbasename=\"s,^.*/,,\"\n\n# func_dirname file append nondir_replacement\n# Compute the dirname of FILE.  If nonempty, add APPEND to the result,\n# otherwise set result to NONDIR_REPLACEMENT.\nfunc_dirname ()\n{\n    func_dirname_result=`$ECHO \"${1}\" | $SED \"$dirname\"`\n    if test \"X$func_dirname_result\" = \"X${1}\"; then\n      func_dirname_result=\"${3}\"\n    else\n      func_dirname_result=\"$func_dirname_result${2}\"\n    fi\n} # func_dirname may be replaced by extended shell implementation\n\n\n# func_basename file\nfunc_basename ()\n{\n    func_basename_result=`$ECHO \"${1}\" | $SED \"$basename\"`\n} # func_basename may be replaced by extended shell implementation\n\n\n# func_dirname_and_basename file append nondir_replacement\n# perform func_basename and func_dirname in a single function\n# call:\n#   dirname:  Compute the dirname of FILE.  If nonempty,\n#             add APPEND to the result, otherwise set result\n#             to NONDIR_REPLACEMENT.\n#             value returned in \"$func_dirname_result\"\n#   basename: Compute filename of FILE.\n#             value retuned in \"$func_basename_result\"\n# Implementation must be kept synchronized with func_dirname\n# and func_basename. For efficiency, we do not delegate to\n# those functions but instead duplicate the functionality here.\nfunc_dirname_and_basename ()\n{\n    # Extract subdirectory from the argument.\n    func_dirname_result=`$ECHO \"${1}\" | $SED -e \"$dirname\"`\n    if test \"X$func_dirname_result\" = \"X${1}\"; then\n      func_dirname_result=\"${3}\"\n    else\n      func_dirname_result=\"$func_dirname_result${2}\"\n    fi\n    func_basename_result=`$ECHO \"${1}\" | $SED -e \"$basename\"`\n} # func_dirname_and_basename may be replaced by extended shell implementation\n\n\n# func_stripname prefix suffix name\n# strip PREFIX and SUFFIX off of NAME.\n# PREFIX and SUFFIX must not contain globbing or regex special\n# characters, hashes, percent signs, but SUFFIX may contain a leading\n# dot (in which case that matches only a dot).\n# func_strip_suffix prefix name\nfunc_stripname ()\n{\n    case ${2} in\n      .*) func_stripname_result=`$ECHO \"${3}\" | $SED \"s%^${1}%%; s%\\\\\\\\${2}\\$%%\"`;;\n      *)  func_stripname_result=`$ECHO \"${3}\" | $SED \"s%^${1}%%; s%${2}\\$%%\"`;;\n    esac\n} # func_stripname may be replaced by extended shell implementation\n\n\n# These SED scripts presuppose an absolute path with a trailing slash.\npathcar='s,^/\\([^/]*\\).*$,\\1,'\npathcdr='s,^/[^/]*,,'\nremovedotparts=':dotsl\n\t\ts@/\\./@/@g\n\t\tt dotsl\n\t\ts,/\\.$,/,'\ncollapseslashes='s@/\\{1,\\}@/@g'\nfinalslash='s,/*$,/,'\n\n# func_normal_abspath PATH\n# Remove doubled-up and trailing slashes, \".\" path components,\n# and cancel out any \"..\" path components in PATH after making\n# it an absolute path.\n#             value returned in \"$func_normal_abspath_result\"\nfunc_normal_abspath ()\n{\n  # Start from root dir and reassemble the path.\n  func_normal_abspath_result=\n  func_normal_abspath_tpath=$1\n  func_normal_abspath_altnamespace=\n  case $func_normal_abspath_tpath in\n    \"\")\n      # Empty path, that just means $cwd.\n      func_stripname '' '/' \"`pwd`\"\n      func_normal_abspath_result=$func_stripname_result\n      return\n    ;;\n    # The next three entries are used to spot a run of precisely\n    # two leading slashes without using negated character classes;\n    # we take advantage of case's first-match behaviour.\n    ///*)\n      # Unusual form of absolute path, do nothing.\n    ;;\n    //*)\n      # Not necessarily an ordinary path; POSIX reserves leading '//'\n      # and for example Cygwin uses it to access remote file shares\n      # over CIFS/SMB, so we conserve a leading double slash if found.\n      func_normal_abspath_altnamespace=/\n    ;;\n    /*)\n      # Absolute path, do nothing.\n    ;;\n    *)\n      # Relative path, prepend $cwd.\n      func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath\n    ;;\n  esac\n  # Cancel out all the simple stuff to save iterations.  We also want\n  # the path to end with a slash for ease of parsing, so make sure\n  # there is one (and only one) here.\n  func_normal_abspath_tpath=`$ECHO \"$func_normal_abspath_tpath\" | $SED \\\n        -e \"$removedotparts\" -e \"$collapseslashes\" -e \"$finalslash\"`\n  while :; do\n    # Processed it all yet?\n    if test \"$func_normal_abspath_tpath\" = / ; then\n      # If we ascended to the root using \"..\" the result may be empty now.\n      if test -z \"$func_normal_abspath_result\" ; then\n        func_normal_abspath_result=/\n      fi\n      break\n    fi\n    func_normal_abspath_tcomponent=`$ECHO \"$func_normal_abspath_tpath\" | $SED \\\n        -e \"$pathcar\"`\n    func_normal_abspath_tpath=`$ECHO \"$func_normal_abspath_tpath\" | $SED \\\n        -e \"$pathcdr\"`\n    # Figure out what to do with it\n    case $func_normal_abspath_tcomponent in\n      \"\")\n        # Trailing empty path component, ignore it.\n      ;;\n      ..)\n        # Parent dir; strip last assembled component from result.\n        func_dirname \"$func_normal_abspath_result\"\n        func_normal_abspath_result=$func_dirname_result\n      ;;\n      *)\n        # Actual path component, append it.\n        func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent\n      ;;\n    esac\n  done\n  # Restore leading double-slash if one was found on entry.\n  func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result\n}\n\n# func_relative_path SRCDIR DSTDIR\n# generates a relative path from SRCDIR to DSTDIR, with a trailing\n# slash if non-empty, suitable for immediately appending a filename\n# without needing to append a separator.\n#             value returned in \"$func_relative_path_result\"\nfunc_relative_path ()\n{\n  func_relative_path_result=\n  func_normal_abspath \"$1\"\n  func_relative_path_tlibdir=$func_normal_abspath_result\n  func_normal_abspath \"$2\"\n  func_relative_path_tbindir=$func_normal_abspath_result\n\n  # Ascend the tree starting from libdir\n  while :; do\n    # check if we have found a prefix of bindir\n    case $func_relative_path_tbindir in\n      $func_relative_path_tlibdir)\n        # found an exact match\n        func_relative_path_tcancelled=\n        break\n        ;;\n      $func_relative_path_tlibdir*)\n        # found a matching prefix\n        func_stripname \"$func_relative_path_tlibdir\" '' \"$func_relative_path_tbindir\"\n        func_relative_path_tcancelled=$func_stripname_result\n        if test -z \"$func_relative_path_result\"; then\n          func_relative_path_result=.\n        fi\n        break\n        ;;\n      *)\n        func_dirname $func_relative_path_tlibdir\n        func_relative_path_tlibdir=${func_dirname_result}\n        if test \"x$func_relative_path_tlibdir\" = x ; then\n          # Have to descend all the way to the root!\n          func_relative_path_result=../$func_relative_path_result\n          func_relative_path_tcancelled=$func_relative_path_tbindir\n          break\n        fi\n        func_relative_path_result=../$func_relative_path_result\n        ;;\n    esac\n  done\n\n  # Now calculate path; take care to avoid doubling-up slashes.\n  func_stripname '' '/' \"$func_relative_path_result\"\n  func_relative_path_result=$func_stripname_result\n  func_stripname '/' '/' \"$func_relative_path_tcancelled\"\n  if test \"x$func_stripname_result\" != x ; then\n    func_relative_path_result=${func_relative_path_result}/${func_stripname_result}\n  fi\n\n  # Normalisation. If bindir is libdir, return empty string,\n  # else relative path ending with a slash; either way, target\n  # file name can be directly appended.\n  if test ! -z \"$func_relative_path_result\"; then\n    func_stripname './' '' \"$func_relative_path_result/\"\n    func_relative_path_result=$func_stripname_result\n  fi\n}\n\n# The name of this program:\nfunc_dirname_and_basename \"$progpath\"\nprogname=$func_basename_result\n\n# Make sure we have an absolute path for reexecution:\ncase $progpath in\n  [\\\\/]*|[A-Za-z]:\\\\*) ;;\n  *[\\\\/]*)\n     progdir=$func_dirname_result\n     progdir=`cd \"$progdir\" && pwd`\n     progpath=\"$progdir/$progname\"\n     ;;\n  *)\n     save_IFS=\"$IFS\"\n     IFS=${PATH_SEPARATOR-:}\n     for progdir in $PATH; do\n       IFS=\"$save_IFS\"\n       test -x \"$progdir/$progname\" && break\n     done\n     IFS=\"$save_IFS\"\n     test -n \"$progdir\" || progdir=`pwd`\n     progpath=\"$progdir/$progname\"\n     ;;\nesac\n\n# Sed substitution that helps us do robust quoting.  It backslashifies\n# metacharacters that are still active within double-quoted strings.\nXsed=\"${SED}\"' -e 1s/^X//'\nsed_quote_subst='s/\\([`\"$\\\\]\\)/\\\\\\1/g'\n\n# Same as above, but do not quote variable references.\ndouble_quote_subst='s/\\([\"`\\\\]\\)/\\\\\\1/g'\n\n# Sed substitution that turns a string into a regex matching for the\n# string literally.\nsed_make_literal_regex='s,[].[^$\\\\*\\/],\\\\&,g'\n\n# Sed substitution that converts a w32 file name or path\n# which contains forward slashes, into one that contains\n# (escaped) backslashes.  A very naive implementation.\nlt_sed_naive_backslashify='s|\\\\\\\\*|\\\\|g;s|/|\\\\|g;s|\\\\|\\\\\\\\|g'\n\n# Re-`\\' parameter expansions in output of double_quote_subst that were\n# `\\'-ed in input to the same.  If an odd number of `\\' preceded a '$'\n# in input to double_quote_subst, that '$' was protected from expansion.\n# Since each input `\\' is now two `\\'s, look for any number of runs of\n# four `\\'s followed by two `\\'s and then a '$'.  `\\' that '$'.\nbs='\\\\'\nbs2='\\\\\\\\'\nbs4='\\\\\\\\\\\\\\\\'\ndollar='\\$'\nsed_double_backslash=\"\\\n  s/$bs4/&\\\\\n/g\n  s/^$bs2$dollar/$bs&/\n  s/\\\\([^$bs]\\\\)$bs2$dollar/\\\\1$bs2$bs$dollar/g\n  s/\\n//g\"\n\n# Standard options:\nopt_dry_run=false\nopt_help=false\nopt_quiet=false\nopt_verbose=false\nopt_warning=:\n\n# func_echo arg...\n# Echo program name prefixed message, along with the current mode\n# name if it has been set yet.\nfunc_echo ()\n{\n    $ECHO \"$progname: ${opt_mode+$opt_mode: }$*\"\n}\n\n# func_verbose arg...\n# Echo program name prefixed message in verbose mode only.\nfunc_verbose ()\n{\n    $opt_verbose && func_echo ${1+\"$@\"}\n\n    # A bug in bash halts the script if the last line of a function\n    # fails when set -e is in force, so we need another command to\n    # work around that:\n    :\n}\n\n# func_echo_all arg...\n# Invoke $ECHO with all args, space-separated.\nfunc_echo_all ()\n{\n    $ECHO \"$*\"\n}\n\n# func_error arg...\n# Echo program name prefixed message to standard error.\nfunc_error ()\n{\n    $ECHO \"$progname: ${opt_mode+$opt_mode: }\"${1+\"$@\"} 1>&2\n}\n\n# func_warning arg...\n# Echo program name prefixed warning message to standard error.\nfunc_warning ()\n{\n    $opt_warning && $ECHO \"$progname: ${opt_mode+$opt_mode: }warning: \"${1+\"$@\"} 1>&2\n\n    # bash bug again:\n    :\n}\n\n# func_fatal_error arg...\n# Echo program name prefixed message to standard error, and exit.\nfunc_fatal_error ()\n{\n    func_error ${1+\"$@\"}\n    exit $EXIT_FAILURE\n}\n\n# func_fatal_help arg...\n# Echo program name prefixed message to standard error, followed by\n# a help hint, and exit.\nfunc_fatal_help ()\n{\n    func_error ${1+\"$@\"}\n    func_fatal_error \"$help\"\n}\nhelp=\"Try \\`$progname --help' for more information.\"  ## default\n\n\n# func_grep expression filename\n# Check whether EXPRESSION matches any line of FILENAME, without output.\nfunc_grep ()\n{\n    $GREP \"$1\" \"$2\" >/dev/null 2>&1\n}\n\n\n# func_mkdir_p directory-path\n# Make sure the entire path to DIRECTORY-PATH is available.\nfunc_mkdir_p ()\n{\n    my_directory_path=\"$1\"\n    my_dir_list=\n\n    if test -n \"$my_directory_path\" && test \"$opt_dry_run\" != \":\"; then\n\n      # Protect directory names starting with `-'\n      case $my_directory_path in\n        -*) my_directory_path=\"./$my_directory_path\" ;;\n      esac\n\n      # While some portion of DIR does not yet exist...\n      while test ! -d \"$my_directory_path\"; do\n        # ...make a list in topmost first order.  Use a colon delimited\n\t# list incase some portion of path contains whitespace.\n        my_dir_list=\"$my_directory_path:$my_dir_list\"\n\n        # If the last portion added has no slash in it, the list is done\n        case $my_directory_path in */*) ;; *) break ;; esac\n\n        # ...otherwise throw away the child directory and loop\n        my_directory_path=`$ECHO \"$my_directory_path\" | $SED -e \"$dirname\"`\n      done\n      my_dir_list=`$ECHO \"$my_dir_list\" | $SED 's,:*$,,'`\n\n      save_mkdir_p_IFS=\"$IFS\"; IFS=':'\n      for my_dir in $my_dir_list; do\n\tIFS=\"$save_mkdir_p_IFS\"\n        # mkdir can fail with a `File exist' error if two processes\n        # try to create one of the directories concurrently.  Don't\n        # stop in that case!\n        $MKDIR \"$my_dir\" 2>/dev/null || :\n      done\n      IFS=\"$save_mkdir_p_IFS\"\n\n      # Bail out if we (or some other process) failed to create a directory.\n      test -d \"$my_directory_path\" || \\\n        func_fatal_error \"Failed to create \\`$1'\"\n    fi\n}\n\n\n# func_mktempdir [string]\n# Make a temporary directory that won't clash with other running\n# libtool processes, and avoids race conditions if possible.  If\n# given, STRING is the basename for that directory.\nfunc_mktempdir ()\n{\n    my_template=\"${TMPDIR-/tmp}/${1-$progname}\"\n\n    if test \"$opt_dry_run\" = \":\"; then\n      # Return a directory name, but don't create it in dry-run mode\n      my_tmpdir=\"${my_template}-$$\"\n    else\n\n      # If mktemp works, use that first and foremost\n      my_tmpdir=`mktemp -d \"${my_template}-XXXXXXXX\" 2>/dev/null`\n\n      if test ! -d \"$my_tmpdir\"; then\n        # Failing that, at least try and use $RANDOM to avoid a race\n        my_tmpdir=\"${my_template}-${RANDOM-0}$$\"\n\n        save_mktempdir_umask=`umask`\n        umask 0077\n        $MKDIR \"$my_tmpdir\"\n        umask $save_mktempdir_umask\n      fi\n\n      # If we're not in dry-run mode, bomb out on failure\n      test -d \"$my_tmpdir\" || \\\n        func_fatal_error \"cannot create temporary directory \\`$my_tmpdir'\"\n    fi\n\n    $ECHO \"$my_tmpdir\"\n}\n\n\n# func_quote_for_eval arg\n# Aesthetically quote ARG to be evaled later.\n# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT\n# is double-quoted, suitable for a subsequent eval, whereas\n# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters\n# which are still active within double quotes backslashified.\nfunc_quote_for_eval ()\n{\n    case $1 in\n      *[\\\\\\`\\\"\\$]*)\n\tfunc_quote_for_eval_unquoted_result=`$ECHO \"$1\" | $SED \"$sed_quote_subst\"` ;;\n      *)\n        func_quote_for_eval_unquoted_result=\"$1\" ;;\n    esac\n\n    case $func_quote_for_eval_unquoted_result in\n      # Double-quote args containing shell metacharacters to delay\n      # word splitting, command substitution and and variable\n      # expansion for a subsequent eval.\n      # Many Bourne shells cannot handle close brackets correctly\n      # in scan sets, so we specify it separately.\n      *[\\[\\~\\#\\^\\&\\*\\(\\)\\{\\}\\|\\;\\<\\>\\?\\'\\ \\\t]*|*]*|\"\")\n        func_quote_for_eval_result=\"\\\"$func_quote_for_eval_unquoted_result\\\"\"\n        ;;\n      *)\n        func_quote_for_eval_result=\"$func_quote_for_eval_unquoted_result\"\n    esac\n}\n\n\n# func_quote_for_expand arg\n# Aesthetically quote ARG to be evaled later; same as above,\n# but do not quote variable references.\nfunc_quote_for_expand ()\n{\n    case $1 in\n      *[\\\\\\`\\\"]*)\n\tmy_arg=`$ECHO \"$1\" | $SED \\\n\t    -e \"$double_quote_subst\" -e \"$sed_double_backslash\"` ;;\n      *)\n        my_arg=\"$1\" ;;\n    esac\n\n    case $my_arg in\n      # Double-quote args containing shell metacharacters to delay\n      # word splitting and command substitution for a subsequent eval.\n      # Many Bourne shells cannot handle close brackets correctly\n      # in scan sets, so we specify it separately.\n      *[\\[\\~\\#\\^\\&\\*\\(\\)\\{\\}\\|\\;\\<\\>\\?\\'\\ \\\t]*|*]*|\"\")\n        my_arg=\"\\\"$my_arg\\\"\"\n        ;;\n    esac\n\n    func_quote_for_expand_result=\"$my_arg\"\n}\n\n\n# func_show_eval cmd [fail_exp]\n# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is\n# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP\n# is given, then evaluate it.\nfunc_show_eval ()\n{\n    my_cmd=\"$1\"\n    my_fail_exp=\"${2-:}\"\n\n    ${opt_silent-false} || {\n      func_quote_for_expand \"$my_cmd\"\n      eval \"func_echo $func_quote_for_expand_result\"\n    }\n\n    if ${opt_dry_run-false}; then :; else\n      eval \"$my_cmd\"\n      my_status=$?\n      if test \"$my_status\" -eq 0; then :; else\n\teval \"(exit $my_status); $my_fail_exp\"\n      fi\n    fi\n}\n\n\n# func_show_eval_locale cmd [fail_exp]\n# Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is\n# not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP\n# is given, then evaluate it.  Use the saved locale for evaluation.\nfunc_show_eval_locale ()\n{\n    my_cmd=\"$1\"\n    my_fail_exp=\"${2-:}\"\n\n    ${opt_silent-false} || {\n      func_quote_for_expand \"$my_cmd\"\n      eval \"func_echo $func_quote_for_expand_result\"\n    }\n\n    if ${opt_dry_run-false}; then :; else\n      eval \"$lt_user_locale\n\t    $my_cmd\"\n      my_status=$?\n      eval \"$lt_safe_locale\"\n      if test \"$my_status\" -eq 0; then :; else\n\teval \"(exit $my_status); $my_fail_exp\"\n      fi\n    fi\n}\n\n# func_tr_sh\n# Turn $1 into a string suitable for a shell variable name.\n# Result is stored in $func_tr_sh_result.  All characters\n# not in the set a-zA-Z0-9_ are replaced with '_'. Further,\n# if $1 begins with a digit, a '_' is prepended as well.\nfunc_tr_sh ()\n{\n  case $1 in\n  [0-9]* | *[!a-zA-Z0-9_]*)\n    func_tr_sh_result=`$ECHO \"$1\" | $SED 's/^\\([0-9]\\)/_\\1/; s/[^a-zA-Z0-9_]/_/g'`\n    ;;\n  * )\n    func_tr_sh_result=$1\n    ;;\n  esac\n}\n\n\n# func_version\n# Echo version message to standard output and exit.\nfunc_version ()\n{\n    $opt_debug\n\n    $SED -n '/(C)/!b go\n\t:more\n\t/\\./!{\n\t  N\n\t  s/\\n# / /\n\t  b more\n\t}\n\t:go\n\t/^# '$PROGRAM' (GNU /,/# warranty; / {\n        s/^# //\n\ts/^# *$//\n        s/\\((C)\\)[ 0-9,-]*\\( [1-9][0-9]*\\)/\\1\\2/\n        p\n     }' < \"$progpath\"\n     exit $?\n}\n\n# func_usage\n# Echo short help message to standard output and exit.\nfunc_usage ()\n{\n    $opt_debug\n\n    $SED -n '/^# Usage:/,/^#  *.*--help/ {\n        s/^# //\n\ts/^# *$//\n\ts/\\$progname/'$progname'/\n\tp\n    }' < \"$progpath\"\n    echo\n    $ECHO \"run \\`$progname --help | more' for full usage\"\n    exit $?\n}\n\n# func_help [NOEXIT]\n# Echo long help message to standard output and exit,\n# unless 'noexit' is passed as argument.\nfunc_help ()\n{\n    $opt_debug\n\n    $SED -n '/^# Usage:/,/# Report bugs to/ {\n\t:print\n        s/^# //\n\ts/^# *$//\n\ts*\\$progname*'$progname'*\n\ts*\\$host*'\"$host\"'*\n\ts*\\$SHELL*'\"$SHELL\"'*\n\ts*\\$LTCC*'\"$LTCC\"'*\n\ts*\\$LTCFLAGS*'\"$LTCFLAGS\"'*\n\ts*\\$LD*'\"$LD\"'*\n\ts/\\$with_gnu_ld/'\"$with_gnu_ld\"'/\n\ts/\\$automake_version/'\"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`\"'/\n\ts/\\$autoconf_version/'\"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`\"'/\n\tp\n\td\n     }\n     /^# .* home page:/b print\n     /^# General help using/b print\n     ' < \"$progpath\"\n    ret=$?\n    if test -z \"$1\"; then\n      exit $ret\n    fi\n}\n\n# func_missing_arg argname\n# Echo program name prefixed message to standard error and set global\n# exit_cmd.\nfunc_missing_arg ()\n{\n    $opt_debug\n\n    func_error \"missing argument for $1.\"\n    exit_cmd=exit\n}\n\n\n# func_split_short_opt shortopt\n# Set func_split_short_opt_name and func_split_short_opt_arg shell\n# variables after splitting SHORTOPT after the 2nd character.\nfunc_split_short_opt ()\n{\n    my_sed_short_opt='1s/^\\(..\\).*$/\\1/;q'\n    my_sed_short_rest='1s/^..\\(.*\\)$/\\1/;q'\n\n    func_split_short_opt_name=`$ECHO \"$1\" | $SED \"$my_sed_short_opt\"`\n    func_split_short_opt_arg=`$ECHO \"$1\" | $SED \"$my_sed_short_rest\"`\n} # func_split_short_opt may be replaced by extended shell implementation\n\n\n# func_split_long_opt longopt\n# Set func_split_long_opt_name and func_split_long_opt_arg shell\n# variables after splitting LONGOPT at the `=' sign.\nfunc_split_long_opt ()\n{\n    my_sed_long_opt='1s/^\\(--[^=]*\\)=.*/\\1/;q'\n    my_sed_long_arg='1s/^--[^=]*=//'\n\n    func_split_long_opt_name=`$ECHO \"$1\" | $SED \"$my_sed_long_opt\"`\n    func_split_long_opt_arg=`$ECHO \"$1\" | $SED \"$my_sed_long_arg\"`\n} # func_split_long_opt may be replaced by extended shell implementation\n\nexit_cmd=:\n\n\n\n\n\nmagic=\"%%%MAGIC variable%%%\"\nmagic_exe=\"%%%MAGIC EXE variable%%%\"\n\n# Global variables.\nnonopt=\npreserve_args=\nlo2o=\"s/\\\\.lo\\$/.${objext}/\"\no2lo=\"s/\\\\.${objext}\\$/.lo/\"\nextracted_archives=\nextracted_serial=0\n\n# If this variable is set in any of the actions, the command in it\n# will be execed at the end.  This prevents here-documents from being\n# left over by shells.\nexec_cmd=\n\n# func_append var value\n# Append VALUE to the end of shell variable VAR.\nfunc_append ()\n{\n    eval \"${1}=\\$${1}\\${2}\"\n} # func_append may be replaced by extended shell implementation\n\n# func_append_quoted var value\n# Quote VALUE and append to the end of shell variable VAR, separated\n# by a space.\nfunc_append_quoted ()\n{\n    func_quote_for_eval \"${2}\"\n    eval \"${1}=\\$${1}\\\\ \\$func_quote_for_eval_result\"\n} # func_append_quoted may be replaced by extended shell implementation\n\n\n# func_arith arithmetic-term...\nfunc_arith ()\n{\n    func_arith_result=`expr \"${@}\"`\n} # func_arith may be replaced by extended shell implementation\n\n\n# func_len string\n# STRING may not start with a hyphen.\nfunc_len ()\n{\n    func_len_result=`expr \"${1}\" : \".*\" 2>/dev/null || echo $max_cmd_len`\n} # func_len may be replaced by extended shell implementation\n\n\n# func_lo2o object\nfunc_lo2o ()\n{\n    func_lo2o_result=`$ECHO \"${1}\" | $SED \"$lo2o\"`\n} # func_lo2o may be replaced by extended shell implementation\n\n\n# func_xform libobj-or-source\nfunc_xform ()\n{\n    func_xform_result=`$ECHO \"${1}\" | $SED 's/\\.[^.]*$/.lo/'`\n} # func_xform may be replaced by extended shell implementation\n\n\n# func_fatal_configuration arg...\n# Echo program name prefixed message to standard error, followed by\n# a configuration failure hint, and exit.\nfunc_fatal_configuration ()\n{\n    func_error ${1+\"$@\"}\n    func_error \"See the $PACKAGE documentation for more information.\"\n    func_fatal_error \"Fatal configuration error.\"\n}\n\n\n# func_config\n# Display the configuration for all the tags in this script.\nfunc_config ()\n{\n    re_begincf='^# ### BEGIN LIBTOOL'\n    re_endcf='^# ### END LIBTOOL'\n\n    # Default configuration.\n    $SED \"1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\\$d\" < \"$progpath\"\n\n    # Now print the configurations for the tags.\n    for tagname in $taglist; do\n      $SED -n \"/$re_begincf TAG CONFIG: $tagname\\$/,/$re_endcf TAG CONFIG: $tagname\\$/p\" < \"$progpath\"\n    done\n\n    exit $?\n}\n\n# func_features\n# Display the features supported by this script.\nfunc_features ()\n{\n    echo \"host: $host\"\n    if test \"$build_libtool_libs\" = yes; then\n      echo \"enable shared libraries\"\n    else\n      echo \"disable shared libraries\"\n    fi\n    if test \"$build_old_libs\" = yes; then\n      echo \"enable static libraries\"\n    else\n      echo \"disable static libraries\"\n    fi\n\n    exit $?\n}\n\n# func_enable_tag tagname\n# Verify that TAGNAME is valid, and either flag an error and exit, or\n# enable the TAGNAME tag.  We also add TAGNAME to the global $taglist\n# variable here.\nfunc_enable_tag ()\n{\n  # Global variable:\n  tagname=\"$1\"\n\n  re_begincf=\"^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\\$\"\n  re_endcf=\"^# ### END LIBTOOL TAG CONFIG: $tagname\\$\"\n  sed_extractcf=\"/$re_begincf/,/$re_endcf/p\"\n\n  # Validate tagname.\n  case $tagname in\n    *[!-_A-Za-z0-9,/]*)\n      func_fatal_error \"invalid tag name: $tagname\"\n      ;;\n  esac\n\n  # Don't test for the \"default\" C tag, as we know it's\n  # there but not specially marked.\n  case $tagname in\n    CC) ;;\n    *)\n      if $GREP \"$re_begincf\" \"$progpath\" >/dev/null 2>&1; then\n\ttaglist=\"$taglist $tagname\"\n\n\t# Evaluate the configuration.  Be careful to quote the path\n\t# and the sed script, to avoid splitting on whitespace, but\n\t# also don't use non-portable quotes within backquotes within\n\t# quotes we have to do it in 2 steps:\n\textractedcf=`$SED -n -e \"$sed_extractcf\" < \"$progpath\"`\n\teval \"$extractedcf\"\n      else\n\tfunc_error \"ignoring unknown tag $tagname\"\n      fi\n      ;;\n  esac\n}\n\n# func_check_version_match\n# Ensure that we are using m4 macros, and libtool script from the same\n# release of libtool.\nfunc_check_version_match ()\n{\n  if test \"$package_revision\" != \"$macro_revision\"; then\n    if test \"$VERSION\" != \"$macro_version\"; then\n      if test -z \"$macro_version\"; then\n        cat >&2 <<_LT_EOF\n$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the\n$progname: definition of this LT_INIT comes from an older release.\n$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION\n$progname: and run autoconf again.\n_LT_EOF\n      else\n        cat >&2 <<_LT_EOF\n$progname: Version mismatch error.  This is $PACKAGE $VERSION, but the\n$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.\n$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION\n$progname: and run autoconf again.\n_LT_EOF\n      fi\n    else\n      cat >&2 <<_LT_EOF\n$progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,\n$progname: but the definition of this LT_INIT comes from revision $macro_revision.\n$progname: You should recreate aclocal.m4 with macros from revision $package_revision\n$progname: of $PACKAGE $VERSION and run autoconf again.\n_LT_EOF\n    fi\n\n    exit $EXIT_MISMATCH\n  fi\n}\n\n\n# Shorthand for --mode=foo, only valid as the first argument\ncase $1 in\nclean|clea|cle|cl)\n  shift; set dummy --mode clean ${1+\"$@\"}; shift\n  ;;\ncompile|compil|compi|comp|com|co|c)\n  shift; set dummy --mode compile ${1+\"$@\"}; shift\n  ;;\nexecute|execut|execu|exec|exe|ex|e)\n  shift; set dummy --mode execute ${1+\"$@\"}; shift\n  ;;\nfinish|finis|fini|fin|fi|f)\n  shift; set dummy --mode finish ${1+\"$@\"}; shift\n  ;;\ninstall|instal|insta|inst|ins|in|i)\n  shift; set dummy --mode install ${1+\"$@\"}; shift\n  ;;\nlink|lin|li|l)\n  shift; set dummy --mode link ${1+\"$@\"}; shift\n  ;;\nuninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)\n  shift; set dummy --mode uninstall ${1+\"$@\"}; shift\n  ;;\nesac\n\n\n\n# Option defaults:\nopt_debug=:\nopt_dry_run=false\nopt_config=false\nopt_preserve_dup_deps=false\nopt_features=false\nopt_finish=false\nopt_help=false\nopt_help_all=false\nopt_silent=:\nopt_warning=:\nopt_verbose=:\nopt_silent=false\nopt_verbose=false\n\n\n# Parse options once, thoroughly.  This comes as soon as possible in the\n# script to make things like `--version' happen as quickly as we can.\n{\n  # this just eases exit handling\n  while test $# -gt 0; do\n    opt=\"$1\"\n    shift\n    case $opt in\n      --debug|-x)\topt_debug='set -x'\n\t\t\tfunc_echo \"enabling shell trace mode\"\n\t\t\t$opt_debug\n\t\t\t;;\n      --dry-run|--dryrun|-n)\n\t\t\topt_dry_run=:\n\t\t\t;;\n      --config)\n\t\t\topt_config=:\nfunc_config\n\t\t\t;;\n      --dlopen|-dlopen)\n\t\t\toptarg=\"$1\"\n\t\t\topt_dlopen=\"${opt_dlopen+$opt_dlopen\n}$optarg\"\n\t\t\tshift\n\t\t\t;;\n      --preserve-dup-deps)\n\t\t\topt_preserve_dup_deps=:\n\t\t\t;;\n      --features)\n\t\t\topt_features=:\nfunc_features\n\t\t\t;;\n      --finish)\n\t\t\topt_finish=:\nset dummy --mode finish ${1+\"$@\"}; shift\n\t\t\t;;\n      --help)\n\t\t\topt_help=:\n\t\t\t;;\n      --help-all)\n\t\t\topt_help_all=:\nopt_help=': help-all'\n\t\t\t;;\n      --mode)\n\t\t\ttest $# = 0 && func_missing_arg $opt && break\n\t\t\toptarg=\"$1\"\n\t\t\topt_mode=\"$optarg\"\ncase $optarg in\n  # Valid mode arguments:\n  clean|compile|execute|finish|install|link|relink|uninstall) ;;\n\n  # Catch anything else as an error\n  *) func_error \"invalid argument for $opt\"\n     exit_cmd=exit\n     break\n     ;;\nesac\n\t\t\tshift\n\t\t\t;;\n      --no-silent|--no-quiet)\n\t\t\topt_silent=false\nfunc_append preserve_args \" $opt\"\n\t\t\t;;\n      --no-warning|--no-warn)\n\t\t\topt_warning=false\nfunc_append preserve_args \" $opt\"\n\t\t\t;;\n      --no-verbose)\n\t\t\topt_verbose=false\nfunc_append preserve_args \" $opt\"\n\t\t\t;;\n      --silent|--quiet)\n\t\t\topt_silent=:\nfunc_append preserve_args \" $opt\"\n        opt_verbose=false\n\t\t\t;;\n      --verbose|-v)\n\t\t\topt_verbose=:\nfunc_append preserve_args \" $opt\"\nopt_silent=false\n\t\t\t;;\n      --tag)\n\t\t\ttest $# = 0 && func_missing_arg $opt && break\n\t\t\toptarg=\"$1\"\n\t\t\topt_tag=\"$optarg\"\nfunc_append preserve_args \" $opt $optarg\"\nfunc_enable_tag \"$optarg\"\n\t\t\tshift\n\t\t\t;;\n\n      -\\?|-h)\t\tfunc_usage\t\t\t\t;;\n      --help)\t\tfunc_help\t\t\t\t;;\n      --version)\tfunc_version\t\t\t\t;;\n\n      # Separate optargs to long options:\n      --*=*)\n\t\t\tfunc_split_long_opt \"$opt\"\n\t\t\tset dummy \"$func_split_long_opt_name\" \"$func_split_long_opt_arg\" ${1+\"$@\"}\n\t\t\tshift\n\t\t\t;;\n\n      # Separate non-argument short options:\n      -\\?*|-h*|-n*|-v*)\n\t\t\tfunc_split_short_opt \"$opt\"\n\t\t\tset dummy \"$func_split_short_opt_name\" \"-$func_split_short_opt_arg\" ${1+\"$@\"}\n\t\t\tshift\n\t\t\t;;\n\n      --)\t\tbreak\t\t\t\t\t;;\n      -*)\t\tfunc_fatal_help \"unrecognized option \\`$opt'\" ;;\n      *)\t\tset dummy \"$opt\" ${1+\"$@\"};\tshift; break  ;;\n    esac\n  done\n\n  # Validate options:\n\n  # save first non-option argument\n  if test \"$#\" -gt 0; then\n    nonopt=\"$opt\"\n    shift\n  fi\n\n  # preserve --debug\n  test \"$opt_debug\" = : || func_append preserve_args \" --debug\"\n\n  case $host in\n    *cygwin* | *mingw* | *pw32* | *cegcc*)\n      # don't eliminate duplications in $postdeps and $predeps\n      opt_duplicate_compiler_generated_deps=:\n      ;;\n    *)\n      opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps\n      ;;\n  esac\n\n  $opt_help || {\n    # Sanity checks first:\n    func_check_version_match\n\n    if test \"$build_libtool_libs\" != yes && test \"$build_old_libs\" != yes; then\n      func_fatal_configuration \"not configured to build any kind of library\"\n    fi\n\n    # Darwin sucks\n    eval std_shrext=\\\"$shrext_cmds\\\"\n\n    # Only execute mode is allowed to have -dlopen flags.\n    if test -n \"$opt_dlopen\" && test \"$opt_mode\" != execute; then\n      func_error \"unrecognized option \\`-dlopen'\"\n      $ECHO \"$help\" 1>&2\n      exit $EXIT_FAILURE\n    fi\n\n    # Change the help message to a mode-specific one.\n    generic_help=\"$help\"\n    help=\"Try \\`$progname --help --mode=$opt_mode' for more information.\"\n  }\n\n\n  # Bail if the options were screwed\n  $exit_cmd $EXIT_FAILURE\n}\n\n\n\n\n## ----------- ##\n##    Main.    ##\n## ----------- ##\n\n# func_lalib_p file\n# True iff FILE is a libtool `.la' library or `.lo' object file.\n# This function is only a basic sanity check; it will hardly flush out\n# determined imposters.\nfunc_lalib_p ()\n{\n    test -f \"$1\" &&\n      $SED -e 4q \"$1\" 2>/dev/null \\\n        | $GREP \"^# Generated by .*$PACKAGE\" > /dev/null 2>&1\n}\n\n# func_lalib_unsafe_p file\n# True iff FILE is a libtool `.la' library or `.lo' object file.\n# This function implements the same check as func_lalib_p without\n# resorting to external programs.  To this end, it redirects stdin and\n# closes it afterwards, without saving the original file descriptor.\n# As a safety measure, use it only where a negative result would be\n# fatal anyway.  Works if `file' does not exist.\nfunc_lalib_unsafe_p ()\n{\n    lalib_p=no\n    if test -f \"$1\" && test -r \"$1\" && exec 5<&0 <\"$1\"; then\n\tfor lalib_p_l in 1 2 3 4\n\tdo\n\t    read lalib_p_line\n\t    case \"$lalib_p_line\" in\n\t\t\\#\\ Generated\\ by\\ *$PACKAGE* ) lalib_p=yes; break;;\n\t    esac\n\tdone\n\texec 0<&5 5<&-\n    fi\n    test \"$lalib_p\" = yes\n}\n\n# func_ltwrapper_script_p file\n# True iff FILE is a libtool wrapper script\n# This function is only a basic sanity check; it will hardly flush out\n# determined imposters.\nfunc_ltwrapper_script_p ()\n{\n    func_lalib_p \"$1\"\n}\n\n# func_ltwrapper_executable_p file\n# True iff FILE is a libtool wrapper executable\n# This function is only a basic sanity check; it will hardly flush out\n# determined imposters.\nfunc_ltwrapper_executable_p ()\n{\n    func_ltwrapper_exec_suffix=\n    case $1 in\n    *.exe) ;;\n    *) func_ltwrapper_exec_suffix=.exe ;;\n    esac\n    $GREP \"$magic_exe\" \"$1$func_ltwrapper_exec_suffix\" >/dev/null 2>&1\n}\n\n# func_ltwrapper_scriptname file\n# Assumes file is an ltwrapper_executable\n# uses $file to determine the appropriate filename for a\n# temporary ltwrapper_script.\nfunc_ltwrapper_scriptname ()\n{\n    func_dirname_and_basename \"$1\" \"\" \".\"\n    func_stripname '' '.exe' \"$func_basename_result\"\n    func_ltwrapper_scriptname_result=\"$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper\"\n}\n\n# func_ltwrapper_p file\n# True iff FILE is a libtool wrapper script or wrapper executable\n# This function is only a basic sanity check; it will hardly flush out\n# determined imposters.\nfunc_ltwrapper_p ()\n{\n    func_ltwrapper_script_p \"$1\" || func_ltwrapper_executable_p \"$1\"\n}\n\n\n# func_execute_cmds commands fail_cmd\n# Execute tilde-delimited COMMANDS.\n# If FAIL_CMD is given, eval that upon failure.\n# FAIL_CMD may read-access the current command in variable CMD!\nfunc_execute_cmds ()\n{\n    $opt_debug\n    save_ifs=$IFS; IFS='~'\n    for cmd in $1; do\n      IFS=$save_ifs\n      eval cmd=\\\"$cmd\\\"\n      func_show_eval \"$cmd\" \"${2-:}\"\n    done\n    IFS=$save_ifs\n}\n\n\n# func_source file\n# Source FILE, adding directory component if necessary.\n# Note that it is not necessary on cygwin/mingw to append a dot to\n# FILE even if both FILE and FILE.exe exist: automatic-append-.exe\n# behavior happens only for exec(3), not for open(2)!  Also, sourcing\n# `FILE.' does not work on cygwin managed mounts.\nfunc_source ()\n{\n    $opt_debug\n    case $1 in\n    */* | *\\\\*)\t. \"$1\" ;;\n    *)\t\t. \"./$1\" ;;\n    esac\n}\n\n\n# func_resolve_sysroot PATH\n# Replace a leading = in PATH with a sysroot.  Store the result into\n# func_resolve_sysroot_result\nfunc_resolve_sysroot ()\n{\n  func_resolve_sysroot_result=$1\n  case $func_resolve_sysroot_result in\n  =*)\n    func_stripname '=' '' \"$func_resolve_sysroot_result\"\n    func_resolve_sysroot_result=$lt_sysroot$func_stripname_result\n    ;;\n  esac\n}\n\n# func_replace_sysroot PATH\n# If PATH begins with the sysroot, replace it with = and\n# store the result into func_replace_sysroot_result.\nfunc_replace_sysroot ()\n{\n  case \"$lt_sysroot:$1\" in\n  ?*:\"$lt_sysroot\"*)\n    func_stripname \"$lt_sysroot\" '' \"$1\"\n    func_replace_sysroot_result=\"=$func_stripname_result\"\n    ;;\n  *)\n    # Including no sysroot.\n    func_replace_sysroot_result=$1\n    ;;\n  esac\n}\n\n# func_infer_tag arg\n# Infer tagged configuration to use if any are available and\n# if one wasn't chosen via the \"--tag\" command line option.\n# Only attempt this if the compiler in the base compile\n# command doesn't match the default compiler.\n# arg is usually of the form 'gcc ...'\nfunc_infer_tag ()\n{\n    $opt_debug\n    if test -n \"$available_tags\" && test -z \"$tagname\"; then\n      CC_quoted=\n      for arg in $CC; do\n\tfunc_append_quoted CC_quoted \"$arg\"\n      done\n      CC_expanded=`func_echo_all $CC`\n      CC_quoted_expanded=`func_echo_all $CC_quoted`\n      case $@ in\n      # Blanks in the command may have been stripped by the calling shell,\n      # but not from the CC environment variable when configure was run.\n      \" $CC \"* | \"$CC \"* | \" $CC_expanded \"* | \"$CC_expanded \"* | \\\n      \" $CC_quoted\"* | \"$CC_quoted \"* | \" $CC_quoted_expanded \"* | \"$CC_quoted_expanded \"*) ;;\n      # Blanks at the start of $base_compile will cause this to fail\n      # if we don't check for them as well.\n      *)\n\tfor z in $available_tags; do\n\t  if $GREP \"^# ### BEGIN LIBTOOL TAG CONFIG: $z$\" < \"$progpath\" > /dev/null; then\n\t    # Evaluate the configuration.\n\t    eval \"`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`\"\n\t    CC_quoted=\n\t    for arg in $CC; do\n\t      # Double-quote args containing other shell metacharacters.\n\t      func_append_quoted CC_quoted \"$arg\"\n\t    done\n\t    CC_expanded=`func_echo_all $CC`\n\t    CC_quoted_expanded=`func_echo_all $CC_quoted`\n\t    case \"$@ \" in\n\t    \" $CC \"* | \"$CC \"* | \" $CC_expanded \"* | \"$CC_expanded \"* | \\\n\t    \" $CC_quoted\"* | \"$CC_quoted \"* | \" $CC_quoted_expanded \"* | \"$CC_quoted_expanded \"*)\n\t      # The compiler in the base compile command matches\n\t      # the one in the tagged configuration.\n\t      # Assume this is the tagged configuration we want.\n\t      tagname=$z\n\t      break\n\t      ;;\n\t    esac\n\t  fi\n\tdone\n\t# If $tagname still isn't set, then no tagged configuration\n\t# was found and let the user know that the \"--tag\" command\n\t# line option must be used.\n\tif test -z \"$tagname\"; then\n\t  func_echo \"unable to infer tagged configuration\"\n\t  func_fatal_error \"specify a tag with \\`--tag'\"\n#\telse\n#\t  func_verbose \"using $tagname tagged configuration\"\n\tfi\n\t;;\n      esac\n    fi\n}\n\n\n\n# func_write_libtool_object output_name pic_name nonpic_name\n# Create a libtool object file (analogous to a \".la\" file),\n# but don't create it if we're doing a dry run.\nfunc_write_libtool_object ()\n{\n    write_libobj=${1}\n    if test \"$build_libtool_libs\" = yes; then\n      write_lobj=\\'${2}\\'\n    else\n      write_lobj=none\n    fi\n\n    if test \"$build_old_libs\" = yes; then\n      write_oldobj=\\'${3}\\'\n    else\n      write_oldobj=none\n    fi\n\n    $opt_dry_run || {\n      cat >${write_libobj}T <<EOF\n# $write_libobj - a libtool object file\n# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION\n#\n# Please DO NOT delete this file!\n# It is necessary for linking the library.\n\n# Name of the PIC object.\npic_object=$write_lobj\n\n# Name of the non-PIC object\nnon_pic_object=$write_oldobj\n\nEOF\n      $MV \"${write_libobj}T\" \"${write_libobj}\"\n    }\n}\n\n\n##################################################\n# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #\n##################################################\n\n# func_convert_core_file_wine_to_w32 ARG\n# Helper function used by file name conversion functions when $build is *nix,\n# and $host is mingw, cygwin, or some other w32 environment. Relies on a\n# correctly configured wine environment available, with the winepath program\n# in $build's $PATH.\n#\n# ARG is the $build file name to be converted to w32 format.\n# Result is available in $func_convert_core_file_wine_to_w32_result, and will\n# be empty on error (or when ARG is empty)\nfunc_convert_core_file_wine_to_w32 ()\n{\n  $opt_debug\n  func_convert_core_file_wine_to_w32_result=\"$1\"\n  if test -n \"$1\"; then\n    # Unfortunately, winepath does not exit with a non-zero error code, so we\n    # are forced to check the contents of stdout. On the other hand, if the\n    # command is not found, the shell will set an exit code of 127 and print\n    # *an error message* to stdout. So we must check for both error code of\n    # zero AND non-empty stdout, which explains the odd construction:\n    func_convert_core_file_wine_to_w32_tmp=`winepath -w \"$1\" 2>/dev/null`\n    if test \"$?\" -eq 0 && test -n \"${func_convert_core_file_wine_to_w32_tmp}\"; then\n      func_convert_core_file_wine_to_w32_result=`$ECHO \"$func_convert_core_file_wine_to_w32_tmp\" |\n        $SED -e \"$lt_sed_naive_backslashify\"`\n    else\n      func_convert_core_file_wine_to_w32_result=\n    fi\n  fi\n}\n# end: func_convert_core_file_wine_to_w32\n\n\n# func_convert_core_path_wine_to_w32 ARG\n# Helper function used by path conversion functions when $build is *nix, and\n# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly\n# configured wine environment available, with the winepath program in $build's\n# $PATH. Assumes ARG has no leading or trailing path separator characters.\n#\n# ARG is path to be converted from $build format to win32.\n# Result is available in $func_convert_core_path_wine_to_w32_result.\n# Unconvertible file (directory) names in ARG are skipped; if no directory names\n# are convertible, then the result may be empty.\nfunc_convert_core_path_wine_to_w32 ()\n{\n  $opt_debug\n  # unfortunately, winepath doesn't convert paths, only file names\n  func_convert_core_path_wine_to_w32_result=\"\"\n  if test -n \"$1\"; then\n    oldIFS=$IFS\n    IFS=:\n    for func_convert_core_path_wine_to_w32_f in $1; do\n      IFS=$oldIFS\n      func_convert_core_file_wine_to_w32 \"$func_convert_core_path_wine_to_w32_f\"\n      if test -n \"$func_convert_core_file_wine_to_w32_result\" ; then\n        if test -z \"$func_convert_core_path_wine_to_w32_result\"; then\n          func_convert_core_path_wine_to_w32_result=\"$func_convert_core_file_wine_to_w32_result\"\n        else\n          func_append func_convert_core_path_wine_to_w32_result \";$func_convert_core_file_wine_to_w32_result\"\n        fi\n      fi\n    done\n    IFS=$oldIFS\n  fi\n}\n# end: func_convert_core_path_wine_to_w32\n\n\n# func_cygpath ARGS...\n# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when\n# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)\n# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or\n# (2), returns the Cygwin file name or path in func_cygpath_result (input\n# file name or path is assumed to be in w32 format, as previously converted\n# from $build's *nix or MSYS format). In case (3), returns the w32 file name\n# or path in func_cygpath_result (input file name or path is assumed to be in\n# Cygwin format). Returns an empty string on error.\n#\n# ARGS are passed to cygpath, with the last one being the file name or path to\n# be converted.\n#\n# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH\n# environment variable; do not put it in $PATH.\nfunc_cygpath ()\n{\n  $opt_debug\n  if test -n \"$LT_CYGPATH\" && test -f \"$LT_CYGPATH\"; then\n    func_cygpath_result=`$LT_CYGPATH \"$@\" 2>/dev/null`\n    if test \"$?\" -ne 0; then\n      # on failure, ensure result is empty\n      func_cygpath_result=\n    fi\n  else\n    func_cygpath_result=\n    func_error \"LT_CYGPATH is empty or specifies non-existent file: \\`$LT_CYGPATH'\"\n  fi\n}\n#end: func_cygpath\n\n\n# func_convert_core_msys_to_w32 ARG\n# Convert file name or path ARG from MSYS format to w32 format.  Return\n# result in func_convert_core_msys_to_w32_result.\nfunc_convert_core_msys_to_w32 ()\n{\n  $opt_debug\n  # awkward: cmd appends spaces to result\n  func_convert_core_msys_to_w32_result=`( cmd //c echo \"$1\" ) 2>/dev/null |\n    $SED -e 's/[ ]*$//' -e \"$lt_sed_naive_backslashify\"`\n}\n#end: func_convert_core_msys_to_w32\n\n\n# func_convert_file_check ARG1 ARG2\n# Verify that ARG1 (a file name in $build format) was converted to $host\n# format in ARG2. Otherwise, emit an error message, but continue (resetting\n# func_to_host_file_result to ARG1).\nfunc_convert_file_check ()\n{\n  $opt_debug\n  if test -z \"$2\" && test -n \"$1\" ; then\n    func_error \"Could not determine host file name corresponding to\"\n    func_error \"  \\`$1'\"\n    func_error \"Continuing, but uninstalled executables may not work.\"\n    # Fallback:\n    func_to_host_file_result=\"$1\"\n  fi\n}\n# end func_convert_file_check\n\n\n# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH\n# Verify that FROM_PATH (a path in $build format) was converted to $host\n# format in TO_PATH. Otherwise, emit an error message, but continue, resetting\n# func_to_host_file_result to a simplistic fallback value (see below).\nfunc_convert_path_check ()\n{\n  $opt_debug\n  if test -z \"$4\" && test -n \"$3\"; then\n    func_error \"Could not determine the host path corresponding to\"\n    func_error \"  \\`$3'\"\n    func_error \"Continuing, but uninstalled executables may not work.\"\n    # Fallback.  This is a deliberately simplistic \"conversion\" and\n    # should not be \"improved\".  See libtool.info.\n    if test \"x$1\" != \"x$2\"; then\n      lt_replace_pathsep_chars=\"s|$1|$2|g\"\n      func_to_host_path_result=`echo \"$3\" |\n        $SED -e \"$lt_replace_pathsep_chars\"`\n    else\n      func_to_host_path_result=\"$3\"\n    fi\n  fi\n}\n# end func_convert_path_check\n\n\n# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG\n# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT\n# and appending REPL if ORIG matches BACKPAT.\nfunc_convert_path_front_back_pathsep ()\n{\n  $opt_debug\n  case $4 in\n  $1 ) func_to_host_path_result=\"$3$func_to_host_path_result\"\n    ;;\n  esac\n  case $4 in\n  $2 ) func_append func_to_host_path_result \"$3\"\n    ;;\n  esac\n}\n# end func_convert_path_front_back_pathsep\n\n\n##################################################\n# $build to $host FILE NAME CONVERSION FUNCTIONS #\n##################################################\n# invoked via `$to_host_file_cmd ARG'\n#\n# In each case, ARG is the path to be converted from $build to $host format.\n# Result will be available in $func_to_host_file_result.\n\n\n# func_to_host_file ARG\n# Converts the file name ARG from $build format to $host format. Return result\n# in func_to_host_file_result.\nfunc_to_host_file ()\n{\n  $opt_debug\n  $to_host_file_cmd \"$1\"\n}\n# end func_to_host_file\n\n\n# func_to_tool_file ARG LAZY\n# converts the file name ARG from $build format to toolchain format. Return\n# result in func_to_tool_file_result.  If the conversion in use is listed\n# in (the comma separated) LAZY, no conversion takes place.\nfunc_to_tool_file ()\n{\n  $opt_debug\n  case ,$2, in\n    *,\"$to_tool_file_cmd\",*)\n      func_to_tool_file_result=$1\n      ;;\n    *)\n      $to_tool_file_cmd \"$1\"\n      func_to_tool_file_result=$func_to_host_file_result\n      ;;\n  esac\n}\n# end func_to_tool_file\n\n\n# func_convert_file_noop ARG\n# Copy ARG to func_to_host_file_result.\nfunc_convert_file_noop ()\n{\n  func_to_host_file_result=\"$1\"\n}\n# end func_convert_file_noop\n\n\n# func_convert_file_msys_to_w32 ARG\n# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic\n# conversion to w32 is not available inside the cwrapper.  Returns result in\n# func_to_host_file_result.\nfunc_convert_file_msys_to_w32 ()\n{\n  $opt_debug\n  func_to_host_file_result=\"$1\"\n  if test -n \"$1\"; then\n    func_convert_core_msys_to_w32 \"$1\"\n    func_to_host_file_result=\"$func_convert_core_msys_to_w32_result\"\n  fi\n  func_convert_file_check \"$1\" \"$func_to_host_file_result\"\n}\n# end func_convert_file_msys_to_w32\n\n\n# func_convert_file_cygwin_to_w32 ARG\n# Convert file name ARG from Cygwin to w32 format.  Returns result in\n# func_to_host_file_result.\nfunc_convert_file_cygwin_to_w32 ()\n{\n  $opt_debug\n  func_to_host_file_result=\"$1\"\n  if test -n \"$1\"; then\n    # because $build is cygwin, we call \"the\" cygpath in $PATH; no need to use\n    # LT_CYGPATH in this case.\n    func_to_host_file_result=`cygpath -m \"$1\"`\n  fi\n  func_convert_file_check \"$1\" \"$func_to_host_file_result\"\n}\n# end func_convert_file_cygwin_to_w32\n\n\n# func_convert_file_nix_to_w32 ARG\n# Convert file name ARG from *nix to w32 format.  Requires a wine environment\n# and a working winepath. Returns result in func_to_host_file_result.\nfunc_convert_file_nix_to_w32 ()\n{\n  $opt_debug\n  func_to_host_file_result=\"$1\"\n  if test -n \"$1\"; then\n    func_convert_core_file_wine_to_w32 \"$1\"\n    func_to_host_file_result=\"$func_convert_core_file_wine_to_w32_result\"\n  fi\n  func_convert_file_check \"$1\" \"$func_to_host_file_result\"\n}\n# end func_convert_file_nix_to_w32\n\n\n# func_convert_file_msys_to_cygwin ARG\n# Convert file name ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.\n# Returns result in func_to_host_file_result.\nfunc_convert_file_msys_to_cygwin ()\n{\n  $opt_debug\n  func_to_host_file_result=\"$1\"\n  if test -n \"$1\"; then\n    func_convert_core_msys_to_w32 \"$1\"\n    func_cygpath -u \"$func_convert_core_msys_to_w32_result\"\n    func_to_host_file_result=\"$func_cygpath_result\"\n  fi\n  func_convert_file_check \"$1\" \"$func_to_host_file_result\"\n}\n# end func_convert_file_msys_to_cygwin\n\n\n# func_convert_file_nix_to_cygwin ARG\n# Convert file name ARG from *nix to Cygwin format.  Requires Cygwin installed\n# in a wine environment, working winepath, and LT_CYGPATH set.  Returns result\n# in func_to_host_file_result.\nfunc_convert_file_nix_to_cygwin ()\n{\n  $opt_debug\n  func_to_host_file_result=\"$1\"\n  if test -n \"$1\"; then\n    # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.\n    func_convert_core_file_wine_to_w32 \"$1\"\n    func_cygpath -u \"$func_convert_core_file_wine_to_w32_result\"\n    func_to_host_file_result=\"$func_cygpath_result\"\n  fi\n  func_convert_file_check \"$1\" \"$func_to_host_file_result\"\n}\n# end func_convert_file_nix_to_cygwin\n\n\n#############################################\n# $build to $host PATH CONVERSION FUNCTIONS #\n#############################################\n# invoked via `$to_host_path_cmd ARG'\n#\n# In each case, ARG is the path to be converted from $build to $host format.\n# The result will be available in $func_to_host_path_result.\n#\n# Path separators are also converted from $build format to $host format.  If\n# ARG begins or ends with a path separator character, it is preserved (but\n# converted to $host format) on output.\n#\n# All path conversion functions are named using the following convention:\n#   file name conversion function    : func_convert_file_X_to_Y ()\n#   path conversion function         : func_convert_path_X_to_Y ()\n# where, for any given $build/$host combination the 'X_to_Y' value is the\n# same.  If conversion functions are added for new $build/$host combinations,\n# the two new functions must follow this pattern, or func_init_to_host_path_cmd\n# will break.\n\n\n# func_init_to_host_path_cmd\n# Ensures that function \"pointer\" variable $to_host_path_cmd is set to the\n# appropriate value, based on the value of $to_host_file_cmd.\nto_host_path_cmd=\nfunc_init_to_host_path_cmd ()\n{\n  $opt_debug\n  if test -z \"$to_host_path_cmd\"; then\n    func_stripname 'func_convert_file_' '' \"$to_host_file_cmd\"\n    to_host_path_cmd=\"func_convert_path_${func_stripname_result}\"\n  fi\n}\n\n\n# func_to_host_path ARG\n# Converts the path ARG from $build format to $host format. Return result\n# in func_to_host_path_result.\nfunc_to_host_path ()\n{\n  $opt_debug\n  func_init_to_host_path_cmd\n  $to_host_path_cmd \"$1\"\n}\n# end func_to_host_path\n\n\n# func_convert_path_noop ARG\n# Copy ARG to func_to_host_path_result.\nfunc_convert_path_noop ()\n{\n  func_to_host_path_result=\"$1\"\n}\n# end func_convert_path_noop\n\n\n# func_convert_path_msys_to_w32 ARG\n# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic\n# conversion to w32 is not available inside the cwrapper.  Returns result in\n# func_to_host_path_result.\nfunc_convert_path_msys_to_w32 ()\n{\n  $opt_debug\n  func_to_host_path_result=\"$1\"\n  if test -n \"$1\"; then\n    # Remove leading and trailing path separator characters from ARG.  MSYS\n    # behavior is inconsistent here; cygpath turns them into '.;' and ';.';\n    # and winepath ignores them completely.\n    func_stripname : : \"$1\"\n    func_to_host_path_tmp1=$func_stripname_result\n    func_convert_core_msys_to_w32 \"$func_to_host_path_tmp1\"\n    func_to_host_path_result=\"$func_convert_core_msys_to_w32_result\"\n    func_convert_path_check : \";\" \\\n      \"$func_to_host_path_tmp1\" \"$func_to_host_path_result\"\n    func_convert_path_front_back_pathsep \":*\" \"*:\" \";\" \"$1\"\n  fi\n}\n# end func_convert_path_msys_to_w32\n\n\n# func_convert_path_cygwin_to_w32 ARG\n# Convert path ARG from Cygwin to w32 format.  Returns result in\n# func_to_host_file_result.\nfunc_convert_path_cygwin_to_w32 ()\n{\n  $opt_debug\n  func_to_host_path_result=\"$1\"\n  if test -n \"$1\"; then\n    # See func_convert_path_msys_to_w32:\n    func_stripname : : \"$1\"\n    func_to_host_path_tmp1=$func_stripname_result\n    func_to_host_path_result=`cygpath -m -p \"$func_to_host_path_tmp1\"`\n    func_convert_path_check : \";\" \\\n      \"$func_to_host_path_tmp1\" \"$func_to_host_path_result\"\n    func_convert_path_front_back_pathsep \":*\" \"*:\" \";\" \"$1\"\n  fi\n}\n# end func_convert_path_cygwin_to_w32\n\n\n# func_convert_path_nix_to_w32 ARG\n# Convert path ARG from *nix to w32 format.  Requires a wine environment and\n# a working winepath.  Returns result in func_to_host_file_result.\nfunc_convert_path_nix_to_w32 ()\n{\n  $opt_debug\n  func_to_host_path_result=\"$1\"\n  if test -n \"$1\"; then\n    # See func_convert_path_msys_to_w32:\n    func_stripname : : \"$1\"\n    func_to_host_path_tmp1=$func_stripname_result\n    func_convert_core_path_wine_to_w32 \"$func_to_host_path_tmp1\"\n    func_to_host_path_result=\"$func_convert_core_path_wine_to_w32_result\"\n    func_convert_path_check : \";\" \\\n      \"$func_to_host_path_tmp1\" \"$func_to_host_path_result\"\n    func_convert_path_front_back_pathsep \":*\" \"*:\" \";\" \"$1\"\n  fi\n}\n# end func_convert_path_nix_to_w32\n\n\n# func_convert_path_msys_to_cygwin ARG\n# Convert path ARG from MSYS to Cygwin format.  Requires LT_CYGPATH set.\n# Returns result in func_to_host_file_result.\nfunc_convert_path_msys_to_cygwin ()\n{\n  $opt_debug\n  func_to_host_path_result=\"$1\"\n  if test -n \"$1\"; then\n    # See func_convert_path_msys_to_w32:\n    func_stripname : : \"$1\"\n    func_to_host_path_tmp1=$func_stripname_result\n    func_convert_core_msys_to_w32 \"$func_to_host_path_tmp1\"\n    func_cygpath -u -p \"$func_convert_core_msys_to_w32_result\"\n    func_to_host_path_result=\"$func_cygpath_result\"\n    func_convert_path_check : : \\\n      \"$func_to_host_path_tmp1\" \"$func_to_host_path_result\"\n    func_convert_path_front_back_pathsep \":*\" \"*:\" : \"$1\"\n  fi\n}\n# end func_convert_path_msys_to_cygwin\n\n\n# func_convert_path_nix_to_cygwin ARG\n# Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a\n# a wine environment, working winepath, and LT_CYGPATH set.  Returns result in\n# func_to_host_file_result.\nfunc_convert_path_nix_to_cygwin ()\n{\n  $opt_debug\n  func_to_host_path_result=\"$1\"\n  if test -n \"$1\"; then\n    # Remove leading and trailing path separator characters from\n    # ARG. msys behavior is inconsistent here, cygpath turns them\n    # into '.;' and ';.', and winepath ignores them completely.\n    func_stripname : : \"$1\"\n    func_to_host_path_tmp1=$func_stripname_result\n    func_convert_core_path_wine_to_w32 \"$func_to_host_path_tmp1\"\n    func_cygpath -u -p \"$func_convert_core_path_wine_to_w32_result\"\n    func_to_host_path_result=\"$func_cygpath_result\"\n    func_convert_path_check : : \\\n      \"$func_to_host_path_tmp1\" \"$func_to_host_path_result\"\n    func_convert_path_front_back_pathsep \":*\" \"*:\" : \"$1\"\n  fi\n}\n# end func_convert_path_nix_to_cygwin\n\n\n# func_mode_compile arg...\nfunc_mode_compile ()\n{\n    $opt_debug\n    # Get the compilation command and the source file.\n    base_compile=\n    srcfile=\"$nonopt\"  #  always keep a non-empty value in \"srcfile\"\n    suppress_opt=yes\n    suppress_output=\n    arg_mode=normal\n    libobj=\n    later=\n    pie_flag=\n\n    for arg\n    do\n      case $arg_mode in\n      arg  )\n\t# do not \"continue\".  Instead, add this to base_compile\n\tlastarg=\"$arg\"\n\targ_mode=normal\n\t;;\n\n      target )\n\tlibobj=\"$arg\"\n\targ_mode=normal\n\tcontinue\n\t;;\n\n      normal )\n\t# Accept any command-line options.\n\tcase $arg in\n\t-o)\n\t  test -n \"$libobj\" && \\\n\t    func_fatal_error \"you cannot specify \\`-o' more than once\"\n\t  arg_mode=target\n\t  continue\n\t  ;;\n\n\t-pie | -fpie | -fPIE)\n          func_append pie_flag \" $arg\"\n\t  continue\n\t  ;;\n\n\t-shared | -static | -prefer-pic | -prefer-non-pic)\n\t  func_append later \" $arg\"\n\t  continue\n\t  ;;\n\n\t-no-suppress)\n\t  suppress_opt=no\n\t  continue\n\t  ;;\n\n\t-Xcompiler)\n\t  arg_mode=arg  #  the next one goes into the \"base_compile\" arg list\n\t  continue      #  The current \"srcfile\" will either be retained or\n\t  ;;            #  replaced later.  I would guess that would be a bug.\n\n\t-Wc,*)\n\t  func_stripname '-Wc,' '' \"$arg\"\n\t  args=$func_stripname_result\n\t  lastarg=\n\t  save_ifs=\"$IFS\"; IFS=','\n\t  for arg in $args; do\n\t    IFS=\"$save_ifs\"\n\t    func_append_quoted lastarg \"$arg\"\n\t  done\n\t  IFS=\"$save_ifs\"\n\t  func_stripname ' ' '' \"$lastarg\"\n\t  lastarg=$func_stripname_result\n\n\t  # Add the arguments to base_compile.\n\t  func_append base_compile \" $lastarg\"\n\t  continue\n\t  ;;\n\n\t*)\n\t  # Accept the current argument as the source file.\n\t  # The previous \"srcfile\" becomes the current argument.\n\t  #\n\t  lastarg=\"$srcfile\"\n\t  srcfile=\"$arg\"\n\t  ;;\n\tesac  #  case $arg\n\t;;\n      esac    #  case $arg_mode\n\n      # Aesthetically quote the previous argument.\n      func_append_quoted base_compile \"$lastarg\"\n    done # for arg\n\n    case $arg_mode in\n    arg)\n      func_fatal_error \"you must specify an argument for -Xcompile\"\n      ;;\n    target)\n      func_fatal_error \"you must specify a target with \\`-o'\"\n      ;;\n    *)\n      # Get the name of the library object.\n      test -z \"$libobj\" && {\n\tfunc_basename \"$srcfile\"\n\tlibobj=\"$func_basename_result\"\n      }\n      ;;\n    esac\n\n    # Recognize several different file suffixes.\n    # If the user specifies -o file.o, it is replaced with file.lo\n    case $libobj in\n    *.[cCFSifmso] | \\\n    *.ada | *.adb | *.ads | *.asm | \\\n    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \\\n    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)\n      func_xform \"$libobj\"\n      libobj=$func_xform_result\n      ;;\n    esac\n\n    case $libobj in\n    *.lo) func_lo2o \"$libobj\"; obj=$func_lo2o_result ;;\n    *)\n      func_fatal_error \"cannot determine name of library object from \\`$libobj'\"\n      ;;\n    esac\n\n    func_infer_tag $base_compile\n\n    for arg in $later; do\n      case $arg in\n      -shared)\n\ttest \"$build_libtool_libs\" != yes && \\\n\t  func_fatal_configuration \"can not build a shared library\"\n\tbuild_old_libs=no\n\tcontinue\n\t;;\n\n      -static)\n\tbuild_libtool_libs=no\n\tbuild_old_libs=yes\n\tcontinue\n\t;;\n\n      -prefer-pic)\n\tpic_mode=yes\n\tcontinue\n\t;;\n\n      -prefer-non-pic)\n\tpic_mode=no\n\tcontinue\n\t;;\n      esac\n    done\n\n    func_quote_for_eval \"$libobj\"\n    test \"X$libobj\" != \"X$func_quote_for_eval_result\" \\\n      && $ECHO \"X$libobj\" | $GREP '[]~#^*{};<>?\"'\"'\"'\t &()|`$[]' \\\n      && func_warning \"libobj name \\`$libobj' may not contain shell special characters.\"\n    func_dirname_and_basename \"$obj\" \"/\" \"\"\n    objname=\"$func_basename_result\"\n    xdir=\"$func_dirname_result\"\n    lobj=${xdir}$objdir/$objname\n\n    test -z \"$base_compile\" && \\\n      func_fatal_help \"you must specify a compilation command\"\n\n    # Delete any leftover library objects.\n    if test \"$build_old_libs\" = yes; then\n      removelist=\"$obj $lobj $libobj ${libobj}T\"\n    else\n      removelist=\"$lobj $libobj ${libobj}T\"\n    fi\n\n    # On Cygwin there's no \"real\" PIC flag so we must build both object types\n    case $host_os in\n    cygwin* | mingw* | pw32* | os2* | cegcc*)\n      pic_mode=default\n      ;;\n    esac\n    if test \"$pic_mode\" = no && test \"$deplibs_check_method\" != pass_all; then\n      # non-PIC code in shared libraries is not supported\n      pic_mode=default\n    fi\n\n    # Calculate the filename of the output object if compiler does\n    # not support -o with -c\n    if test \"$compiler_c_o\" = no; then\n      output_obj=`$ECHO \"$srcfile\" | $SED 's%^.*/%%; s%\\.[^.]*$%%'`.${objext}\n      lockfile=\"$output_obj.lock\"\n    else\n      output_obj=\n      need_locks=no\n      lockfile=\n    fi\n\n    # Lock this critical section if it is needed\n    # We use this script file to make the link, it avoids creating a new file\n    if test \"$need_locks\" = yes; then\n      until $opt_dry_run || ln \"$progpath\" \"$lockfile\" 2>/dev/null; do\n\tfunc_echo \"Waiting for $lockfile to be removed\"\n\tsleep 2\n      done\n    elif test \"$need_locks\" = warn; then\n      if test -f \"$lockfile\"; then\n\t$ECHO \"\\\n*** ERROR, $lockfile exists and contains:\n`cat $lockfile 2>/dev/null`\n\nThis indicates that another process is trying to use the same\ntemporary object file, and libtool could not work around it because\nyour compiler does not support \\`-c' and \\`-o' together.  If you\nrepeat this compilation, it may succeed, by chance, but you had better\navoid parallel builds (make -j) in this platform, or get a better\ncompiler.\"\n\n\t$opt_dry_run || $RM $removelist\n\texit $EXIT_FAILURE\n      fi\n      func_append removelist \" $output_obj\"\n      $ECHO \"$srcfile\" > \"$lockfile\"\n    fi\n\n    $opt_dry_run || $RM $removelist\n    func_append removelist \" $lockfile\"\n    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15\n\n    func_to_tool_file \"$srcfile\" func_convert_file_msys_to_w32\n    srcfile=$func_to_tool_file_result\n    func_quote_for_eval \"$srcfile\"\n    qsrcfile=$func_quote_for_eval_result\n\n    # Only build a PIC object if we are building libtool libraries.\n    if test \"$build_libtool_libs\" = yes; then\n      # Without this assignment, base_compile gets emptied.\n      fbsd_hideous_sh_bug=$base_compile\n\n      if test \"$pic_mode\" != no; then\n\tcommand=\"$base_compile $qsrcfile $pic_flag\"\n      else\n\t# Don't build PIC code\n\tcommand=\"$base_compile $qsrcfile\"\n      fi\n\n      func_mkdir_p \"$xdir$objdir\"\n\n      if test -z \"$output_obj\"; then\n\t# Place PIC objects in $objdir\n\tfunc_append command \" -o $lobj\"\n      fi\n\n      func_show_eval_locale \"$command\"\t\\\n          'test -n \"$output_obj\" && $RM $removelist; exit $EXIT_FAILURE'\n\n      if test \"$need_locks\" = warn &&\n\t test \"X`cat $lockfile 2>/dev/null`\" != \"X$srcfile\"; then\n\t$ECHO \"\\\n*** ERROR, $lockfile contains:\n`cat $lockfile 2>/dev/null`\n\nbut it should contain:\n$srcfile\n\nThis indicates that another process is trying to use the same\ntemporary object file, and libtool could not work around it because\nyour compiler does not support \\`-c' and \\`-o' together.  If you\nrepeat this compilation, it may succeed, by chance, but you had better\navoid parallel builds (make -j) in this platform, or get a better\ncompiler.\"\n\n\t$opt_dry_run || $RM $removelist\n\texit $EXIT_FAILURE\n      fi\n\n      # Just move the object if needed, then go on to compile the next one\n      if test -n \"$output_obj\" && test \"X$output_obj\" != \"X$lobj\"; then\n\tfunc_show_eval '$MV \"$output_obj\" \"$lobj\"' \\\n\t  'error=$?; $opt_dry_run || $RM $removelist; exit $error'\n      fi\n\n      # Allow error messages only from the first compilation.\n      if test \"$suppress_opt\" = yes; then\n\tsuppress_output=' >/dev/null 2>&1'\n      fi\n    fi\n\n    # Only build a position-dependent object if we build old libraries.\n    if test \"$build_old_libs\" = yes; then\n      if test \"$pic_mode\" != yes; then\n\t# Don't build PIC code\n\tcommand=\"$base_compile $qsrcfile$pie_flag\"\n      else\n\tcommand=\"$base_compile $qsrcfile $pic_flag\"\n      fi\n      if test \"$compiler_c_o\" = yes; then\n\tfunc_append command \" -o $obj\"\n      fi\n\n      # Suppress compiler output if we already did a PIC compilation.\n      func_append command \"$suppress_output\"\n      func_show_eval_locale \"$command\" \\\n        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'\n\n      if test \"$need_locks\" = warn &&\n\t test \"X`cat $lockfile 2>/dev/null`\" != \"X$srcfile\"; then\n\t$ECHO \"\\\n*** ERROR, $lockfile contains:\n`cat $lockfile 2>/dev/null`\n\nbut it should contain:\n$srcfile\n\nThis indicates that another process is trying to use the same\ntemporary object file, and libtool could not work around it because\nyour compiler does not support \\`-c' and \\`-o' together.  If you\nrepeat this compilation, it may succeed, by chance, but you had better\navoid parallel builds (make -j) in this platform, or get a better\ncompiler.\"\n\n\t$opt_dry_run || $RM $removelist\n\texit $EXIT_FAILURE\n      fi\n\n      # Just move the object if needed\n      if test -n \"$output_obj\" && test \"X$output_obj\" != \"X$obj\"; then\n\tfunc_show_eval '$MV \"$output_obj\" \"$obj\"' \\\n\t  'error=$?; $opt_dry_run || $RM $removelist; exit $error'\n      fi\n    fi\n\n    $opt_dry_run || {\n      func_write_libtool_object \"$libobj\" \"$objdir/$objname\" \"$objname\"\n\n      # Unlock the critical section if it was locked\n      if test \"$need_locks\" != no; then\n\tremovelist=$lockfile\n        $RM \"$lockfile\"\n      fi\n    }\n\n    exit $EXIT_SUCCESS\n}\n\n$opt_help || {\n  test \"$opt_mode\" = compile && func_mode_compile ${1+\"$@\"}\n}\n\nfunc_mode_help ()\n{\n    # We need to display help for each of the modes.\n    case $opt_mode in\n      \"\")\n        # Generic help is extracted from the usage comments\n        # at the start of this file.\n        func_help\n        ;;\n\n      clean)\n        $ECHO \\\n\"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...\n\nRemove files from the build directory.\n\nRM is the name of the program to use to delete files associated with each FILE\n(typically \\`/bin/rm').  RM-OPTIONS are options (such as \\`-f') to be passed\nto RM.\n\nIf FILE is a libtool library, object or program, all the files associated\nwith it are deleted. Otherwise, only FILE itself is deleted using RM.\"\n        ;;\n\n      compile)\n      $ECHO \\\n\"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE\n\nCompile a source file into a libtool library object.\n\nThis mode accepts the following additional options:\n\n  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE\n  -no-suppress      do not suppress compiler output for multiple passes\n  -prefer-pic       try to build PIC objects only\n  -prefer-non-pic   try to build non-PIC objects only\n  -shared           do not build a \\`.o' file suitable for static linking\n  -static           only build a \\`.o' file suitable for static linking\n  -Wc,FLAG          pass FLAG directly to the compiler\n\nCOMPILE-COMMAND is a command to be used in creating a \\`standard' object file\nfrom the given SOURCEFILE.\n\nThe output file name is determined by removing the directory component from\nSOURCEFILE, then substituting the C source code suffix \\`.c' with the\nlibrary object suffix, \\`.lo'.\"\n        ;;\n\n      execute)\n        $ECHO \\\n\"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...\n\nAutomatically set library path, then run a program.\n\nThis mode accepts the following additional options:\n\n  -dlopen FILE      add the directory containing FILE to the library path\n\nThis mode sets the library path environment variable according to \\`-dlopen'\nflags.\n\nIf any of the ARGS are libtool executable wrappers, then they are translated\ninto their corresponding uninstalled binary, and any of their required library\ndirectories are added to the library path.\n\nThen, COMMAND is executed, with ARGS as arguments.\"\n        ;;\n\n      finish)\n        $ECHO \\\n\"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...\n\nComplete the installation of libtool libraries.\n\nEach LIBDIR is a directory that contains libtool libraries.\n\nThe commands that this mode executes may require superuser privileges.  Use\nthe \\`--dry-run' option if you just want to see what would be executed.\"\n        ;;\n\n      install)\n        $ECHO \\\n\"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...\n\nInstall executables or libraries.\n\nINSTALL-COMMAND is the installation command.  The first component should be\neither the \\`install' or \\`cp' program.\n\nThe following components of INSTALL-COMMAND are treated specially:\n\n  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation\n\nThe rest of the components are interpreted as arguments to that command (only\nBSD-compatible install options are recognized).\"\n        ;;\n\n      link)\n        $ECHO \\\n\"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...\n\nLink object files or libraries together to form another library, or to\ncreate an executable program.\n\nLINK-COMMAND is a command using the C compiler that you would use to create\na program from several object files.\n\nThe following components of LINK-COMMAND are treated specially:\n\n  -all-static       do not do any dynamic linking at all\n  -avoid-version    do not add a version suffix if possible\n  -bindir BINDIR    specify path to binaries directory (for systems where\n                    libraries must be found in the PATH setting at runtime)\n  -dlopen FILE      \\`-dlpreopen' FILE if it cannot be dlopened at runtime\n  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols\n  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)\n  -export-symbols SYMFILE\n                    try to export only the symbols listed in SYMFILE\n  -export-symbols-regex REGEX\n                    try to export only the symbols matching REGEX\n  -LLIBDIR          search LIBDIR for required installed libraries\n  -lNAME            OUTPUT-FILE requires the installed library libNAME\n  -module           build a library that can dlopened\n  -no-fast-install  disable the fast-install mode\n  -no-install       link a not-installable executable\n  -no-undefined     declare that a library does not refer to external symbols\n  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects\n  -objectlist FILE  Use a list of object files found in FILE to specify objects\n  -precious-files-regex REGEX\n                    don't remove output files matching REGEX\n  -release RELEASE  specify package release information\n  -rpath LIBDIR     the created library will eventually be installed in LIBDIR\n  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries\n  -shared           only do dynamic linking of libtool libraries\n  -shrext SUFFIX    override the standard shared library file extension\n  -static           do not do any dynamic linking of uninstalled libtool libraries\n  -static-libtool-libs\n                    do not do any dynamic linking of libtool libraries\n  -version-info CURRENT[:REVISION[:AGE]]\n                    specify library version info [each variable defaults to 0]\n  -weak LIBNAME     declare that the target provides the LIBNAME interface\n  -Wc,FLAG\n  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler\n  -Wl,FLAG\n  -Xlinker FLAG     pass linker-specific FLAG directly to the linker\n  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)\n\nAll other options (arguments beginning with \\`-') are ignored.\n\nEvery other argument is treated as a filename.  Files ending in \\`.la' are\ntreated as uninstalled libtool libraries, other files are standard or library\nobject files.\n\nIf the OUTPUT-FILE ends in \\`.la', then a libtool library is created,\nonly library objects (\\`.lo' files) may be specified, and \\`-rpath' is\nrequired, except when creating a convenience library.\n\nIf OUTPUT-FILE ends in \\`.a' or \\`.lib', then a standard library is created\nusing \\`ar' and \\`ranlib', or on Windows using \\`lib'.\n\nIf OUTPUT-FILE ends in \\`.lo' or \\`.${objext}', then a reloadable object file\nis created, otherwise an executable program is created.\"\n        ;;\n\n      uninstall)\n        $ECHO \\\n\"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...\n\nRemove libraries from an installation directory.\n\nRM is the name of the program to use to delete files associated with each FILE\n(typically \\`/bin/rm').  RM-OPTIONS are options (such as \\`-f') to be passed\nto RM.\n\nIf FILE is a libtool library, all the files associated with it are deleted.\nOtherwise, only FILE itself is deleted using RM.\"\n        ;;\n\n      *)\n        func_fatal_help \"invalid operation mode \\`$opt_mode'\"\n        ;;\n    esac\n\n    echo\n    $ECHO \"Try \\`$progname --help' for more information about other modes.\"\n}\n\n# Now that we've collected a possible --mode arg, show help if necessary\nif $opt_help; then\n  if test \"$opt_help\" = :; then\n    func_mode_help\n  else\n    {\n      func_help noexit\n      for opt_mode in compile link execute install finish uninstall clean; do\n\tfunc_mode_help\n      done\n    } | sed -n '1p; 2,$s/^Usage:/  or: /p'\n    {\n      func_help noexit\n      for opt_mode in compile link execute install finish uninstall clean; do\n\techo\n\tfunc_mode_help\n      done\n    } |\n    sed '1d\n      /^When reporting/,/^Report/{\n\tH\n\td\n      }\n      $x\n      /information about other modes/d\n      /more detailed .*MODE/d\n      s/^Usage:.*--mode=\\([^ ]*\\) .*/Description of \\1 mode:/'\n  fi\n  exit $?\nfi\n\n\n# func_mode_execute arg...\nfunc_mode_execute ()\n{\n    $opt_debug\n    # The first argument is the command name.\n    cmd=\"$nonopt\"\n    test -z \"$cmd\" && \\\n      func_fatal_help \"you must specify a COMMAND\"\n\n    # Handle -dlopen flags immediately.\n    for file in $opt_dlopen; do\n      test -f \"$file\" \\\n\t|| func_fatal_help \"\\`$file' is not a file\"\n\n      dir=\n      case $file in\n      *.la)\n\tfunc_resolve_sysroot \"$file\"\n\tfile=$func_resolve_sysroot_result\n\n\t# Check to see that this really is a libtool archive.\n\tfunc_lalib_unsafe_p \"$file\" \\\n\t  || func_fatal_help \"\\`$lib' is not a valid libtool archive\"\n\n\t# Read the libtool library.\n\tdlname=\n\tlibrary_names=\n\tfunc_source \"$file\"\n\n\t# Skip this library if it cannot be dlopened.\n\tif test -z \"$dlname\"; then\n\t  # Warn if it was a shared library.\n\t  test -n \"$library_names\" && \\\n\t    func_warning \"\\`$file' was not linked with \\`-export-dynamic'\"\n\t  continue\n\tfi\n\n\tfunc_dirname \"$file\" \"\" \".\"\n\tdir=\"$func_dirname_result\"\n\n\tif test -f \"$dir/$objdir/$dlname\"; then\n\t  func_append dir \"/$objdir\"\n\telse\n\t  if test ! -f \"$dir/$dlname\"; then\n\t    func_fatal_error \"cannot find \\`$dlname' in \\`$dir' or \\`$dir/$objdir'\"\n\t  fi\n\tfi\n\t;;\n\n      *.lo)\n\t# Just add the directory containing the .lo file.\n\tfunc_dirname \"$file\" \"\" \".\"\n\tdir=\"$func_dirname_result\"\n\t;;\n\n      *)\n\tfunc_warning \"\\`-dlopen' is ignored for non-libtool libraries and objects\"\n\tcontinue\n\t;;\n      esac\n\n      # Get the absolute pathname.\n      absdir=`cd \"$dir\" && pwd`\n      test -n \"$absdir\" && dir=\"$absdir\"\n\n      # Now add the directory to shlibpath_var.\n      if eval \"test -z \\\"\\$$shlibpath_var\\\"\"; then\n\teval \"$shlibpath_var=\\\"\\$dir\\\"\"\n      else\n\teval \"$shlibpath_var=\\\"\\$dir:\\$$shlibpath_var\\\"\"\n      fi\n    done\n\n    # This variable tells wrapper scripts just to set shlibpath_var\n    # rather than running their programs.\n    libtool_execute_magic=\"$magic\"\n\n    # Check if any of the arguments is a wrapper script.\n    args=\n    for file\n    do\n      case $file in\n      -* | *.la | *.lo ) ;;\n      *)\n\t# Do a test to see if this is really a libtool program.\n\tif func_ltwrapper_script_p \"$file\"; then\n\t  func_source \"$file\"\n\t  # Transform arg to wrapped name.\n\t  file=\"$progdir/$program\"\n\telif func_ltwrapper_executable_p \"$file\"; then\n\t  func_ltwrapper_scriptname \"$file\"\n\t  func_source \"$func_ltwrapper_scriptname_result\"\n\t  # Transform arg to wrapped name.\n\t  file=\"$progdir/$program\"\n\tfi\n\t;;\n      esac\n      # Quote arguments (to preserve shell metacharacters).\n      func_append_quoted args \"$file\"\n    done\n\n    if test \"X$opt_dry_run\" = Xfalse; then\n      if test -n \"$shlibpath_var\"; then\n\t# Export the shlibpath_var.\n\teval \"export $shlibpath_var\"\n      fi\n\n      # Restore saved environment variables\n      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES\n      do\n\teval \"if test \\\"\\${save_$lt_var+set}\\\" = set; then\n                $lt_var=\\$save_$lt_var; export $lt_var\n\t      else\n\t\t$lt_unset $lt_var\n\t      fi\"\n      done\n\n      # Now prepare to actually exec the command.\n      exec_cmd=\"\\$cmd$args\"\n    else\n      # Display what would be done.\n      if test -n \"$shlibpath_var\"; then\n\teval \"\\$ECHO \\\"\\$shlibpath_var=\\$$shlibpath_var\\\"\"\n\techo \"export $shlibpath_var\"\n      fi\n      $ECHO \"$cmd$args\"\n      exit $EXIT_SUCCESS\n    fi\n}\n\ntest \"$opt_mode\" = execute && func_mode_execute ${1+\"$@\"}\n\n\n# func_mode_finish arg...\nfunc_mode_finish ()\n{\n    $opt_debug\n    libs=\n    libdirs=\n    admincmds=\n\n    for opt in \"$nonopt\" ${1+\"$@\"}\n    do\n      if test -d \"$opt\"; then\n\tfunc_append libdirs \" $opt\"\n\n      elif test -f \"$opt\"; then\n\tif func_lalib_unsafe_p \"$opt\"; then\n\t  func_append libs \" $opt\"\n\telse\n\t  func_warning \"\\`$opt' is not a valid libtool archive\"\n\tfi\n\n      else\n\tfunc_fatal_error \"invalid argument \\`$opt'\"\n      fi\n    done\n\n    if test -n \"$libs\"; then\n      if test -n \"$lt_sysroot\"; then\n        sysroot_regex=`$ECHO \"$lt_sysroot\" | $SED \"$sed_make_literal_regex\"`\n        sysroot_cmd=\"s/\\([ ']\\)$sysroot_regex/\\1/g;\"\n      else\n        sysroot_cmd=\n      fi\n\n      # Remove sysroot references\n      if $opt_dry_run; then\n        for lib in $libs; do\n          echo \"removing references to $lt_sysroot and \\`=' prefixes from $lib\"\n        done\n      else\n        tmpdir=`func_mktempdir`\n        for lib in $libs; do\n\t  sed -e \"${sysroot_cmd} s/\\([ ']-[LR]\\)=/\\1/g; s/\\([ ']\\)=/\\1/g\" $lib \\\n\t    > $tmpdir/tmp-la\n\t  mv -f $tmpdir/tmp-la $lib\n\tdone\n        ${RM}r \"$tmpdir\"\n      fi\n    fi\n\n    if test -n \"$finish_cmds$finish_eval\" && test -n \"$libdirs\"; then\n      for libdir in $libdirs; do\n\tif test -n \"$finish_cmds\"; then\n\t  # Do each command in the finish commands.\n\t  func_execute_cmds \"$finish_cmds\" 'admincmds=\"$admincmds\n'\"$cmd\"'\"'\n\tfi\n\tif test -n \"$finish_eval\"; then\n\t  # Do the single finish_eval.\n\t  eval cmds=\\\"$finish_eval\\\"\n\t  $opt_dry_run || eval \"$cmds\" || func_append admincmds \"\n       $cmds\"\n\tfi\n      done\n    fi\n\n    # Exit here if they wanted silent mode.\n    $opt_silent && exit $EXIT_SUCCESS\n\n    if test -n \"$finish_cmds$finish_eval\" && test -n \"$libdirs\"; then\n      echo \"----------------------------------------------------------------------\"\n      echo \"Libraries have been installed in:\"\n      for libdir in $libdirs; do\n\t$ECHO \"   $libdir\"\n      done\n      echo\n      echo \"If you ever happen to want to link against installed libraries\"\n      echo \"in a given directory, LIBDIR, you must either use libtool, and\"\n      echo \"specify the full pathname of the library, or use the \\`-LLIBDIR'\"\n      echo \"flag during linking and do at least one of the following:\"\n      if test -n \"$shlibpath_var\"; then\n\techo \"   - add LIBDIR to the \\`$shlibpath_var' environment variable\"\n\techo \"     during execution\"\n      fi\n      if test -n \"$runpath_var\"; then\n\techo \"   - add LIBDIR to the \\`$runpath_var' environment variable\"\n\techo \"     during linking\"\n      fi\n      if test -n \"$hardcode_libdir_flag_spec\"; then\n\tlibdir=LIBDIR\n\teval flag=\\\"$hardcode_libdir_flag_spec\\\"\n\n\t$ECHO \"   - use the \\`$flag' linker flag\"\n      fi\n      if test -n \"$admincmds\"; then\n\t$ECHO \"   - have your system administrator run these commands:$admincmds\"\n      fi\n      if test -f /etc/ld.so.conf; then\n\techo \"   - have your system administrator add LIBDIR to \\`/etc/ld.so.conf'\"\n      fi\n      echo\n\n      echo \"See any operating system documentation about shared libraries for\"\n      case $host in\n\tsolaris2.[6789]|solaris2.1[0-9])\n\t  echo \"more information, such as the ld(1), crle(1) and ld.so(8) manual\"\n\t  echo \"pages.\"\n\t  ;;\n\t*)\n\t  echo \"more information, such as the ld(1) and ld.so(8) manual pages.\"\n\t  ;;\n      esac\n      echo \"----------------------------------------------------------------------\"\n    fi\n    exit $EXIT_SUCCESS\n}\n\ntest \"$opt_mode\" = finish && func_mode_finish ${1+\"$@\"}\n\n\n# func_mode_install arg...\nfunc_mode_install ()\n{\n    $opt_debug\n    # There may be an optional sh(1) argument at the beginning of\n    # install_prog (especially on Windows NT).\n    if test \"$nonopt\" = \"$SHELL\" || test \"$nonopt\" = /bin/sh ||\n       # Allow the use of GNU shtool's install command.\n       case $nonopt in *shtool*) :;; *) false;; esac; then\n      # Aesthetically quote it.\n      func_quote_for_eval \"$nonopt\"\n      install_prog=\"$func_quote_for_eval_result \"\n      arg=$1\n      shift\n    else\n      install_prog=\n      arg=$nonopt\n    fi\n\n    # The real first argument should be the name of the installation program.\n    # Aesthetically quote it.\n    func_quote_for_eval \"$arg\"\n    func_append install_prog \"$func_quote_for_eval_result\"\n    install_shared_prog=$install_prog\n    case \" $install_prog \" in\n      *[\\\\\\ /]cp\\ *) install_cp=: ;;\n      *) install_cp=false ;;\n    esac\n\n    # We need to accept at least all the BSD install flags.\n    dest=\n    files=\n    opts=\n    prev=\n    install_type=\n    isdir=no\n    stripme=\n    no_mode=:\n    for arg\n    do\n      arg2=\n      if test -n \"$dest\"; then\n\tfunc_append files \" $dest\"\n\tdest=$arg\n\tcontinue\n      fi\n\n      case $arg in\n      -d) isdir=yes ;;\n      -f)\n\tif $install_cp; then :; else\n\t  prev=$arg\n\tfi\n\t;;\n      -g | -m | -o)\n\tprev=$arg\n\t;;\n      -s)\n\tstripme=\" -s\"\n\tcontinue\n\t;;\n      -*)\n\t;;\n      *)\n\t# If the previous option needed an argument, then skip it.\n\tif test -n \"$prev\"; then\n\t  if test \"x$prev\" = x-m && test -n \"$install_override_mode\"; then\n\t    arg2=$install_override_mode\n\t    no_mode=false\n\t  fi\n\t  prev=\n\telse\n\t  dest=$arg\n\t  continue\n\tfi\n\t;;\n      esac\n\n      # Aesthetically quote the argument.\n      func_quote_for_eval \"$arg\"\n      func_append install_prog \" $func_quote_for_eval_result\"\n      if test -n \"$arg2\"; then\n\tfunc_quote_for_eval \"$arg2\"\n      fi\n      func_append install_shared_prog \" $func_quote_for_eval_result\"\n    done\n\n    test -z \"$install_prog\" && \\\n      func_fatal_help \"you must specify an install program\"\n\n    test -n \"$prev\" && \\\n      func_fatal_help \"the \\`$prev' option requires an argument\"\n\n    if test -n \"$install_override_mode\" && $no_mode; then\n      if $install_cp; then :; else\n\tfunc_quote_for_eval \"$install_override_mode\"\n\tfunc_append install_shared_prog \" -m $func_quote_for_eval_result\"\n      fi\n    fi\n\n    if test -z \"$files\"; then\n      if test -z \"$dest\"; then\n\tfunc_fatal_help \"no file or destination specified\"\n      else\n\tfunc_fatal_help \"you must specify a destination\"\n      fi\n    fi\n\n    # Strip any trailing slash from the destination.\n    func_stripname '' '/' \"$dest\"\n    dest=$func_stripname_result\n\n    # Check to see that the destination is a directory.\n    test -d \"$dest\" && isdir=yes\n    if test \"$isdir\" = yes; then\n      destdir=\"$dest\"\n      destname=\n    else\n      func_dirname_and_basename \"$dest\" \"\" \".\"\n      destdir=\"$func_dirname_result\"\n      destname=\"$func_basename_result\"\n\n      # Not a directory, so check to see that there is only one file specified.\n      set dummy $files; shift\n      test \"$#\" -gt 1 && \\\n\tfunc_fatal_help \"\\`$dest' is not a directory\"\n    fi\n    case $destdir in\n    [\\\\/]* | [A-Za-z]:[\\\\/]*) ;;\n    *)\n      for file in $files; do\n\tcase $file in\n\t*.lo) ;;\n\t*)\n\t  func_fatal_help \"\\`$destdir' must be an absolute directory name\"\n\t  ;;\n\tesac\n      done\n      ;;\n    esac\n\n    # This variable tells wrapper scripts just to set variables rather\n    # than running their programs.\n    libtool_install_magic=\"$magic\"\n\n    staticlibs=\n    future_libdirs=\n    current_libdirs=\n    for file in $files; do\n\n      # Do each installation.\n      case $file in\n      *.$libext)\n\t# Do the static libraries later.\n\tfunc_append staticlibs \" $file\"\n\t;;\n\n      *.la)\n\tfunc_resolve_sysroot \"$file\"\n\tfile=$func_resolve_sysroot_result\n\n\t# Check to see that this really is a libtool archive.\n\tfunc_lalib_unsafe_p \"$file\" \\\n\t  || func_fatal_help \"\\`$file' is not a valid libtool archive\"\n\n\tlibrary_names=\n\told_library=\n\trelink_command=\n\tfunc_source \"$file\"\n\n\t# Add the libdir to current_libdirs if it is the destination.\n\tif test \"X$destdir\" = \"X$libdir\"; then\n\t  case \"$current_libdirs \" in\n\t  *\" $libdir \"*) ;;\n\t  *) func_append current_libdirs \" $libdir\" ;;\n\t  esac\n\telse\n\t  # Note the libdir as a future libdir.\n\t  case \"$future_libdirs \" in\n\t  *\" $libdir \"*) ;;\n\t  *) func_append future_libdirs \" $libdir\" ;;\n\t  esac\n\tfi\n\n\tfunc_dirname \"$file\" \"/\" \"\"\n\tdir=\"$func_dirname_result\"\n\tfunc_append dir \"$objdir\"\n\n\tif test -n \"$relink_command\"; then\n\t  # Determine the prefix the user has applied to our future dir.\n\t  inst_prefix_dir=`$ECHO \"$destdir\" | $SED -e \"s%$libdir\\$%%\"`\n\n\t  # Don't allow the user to place us outside of our expected\n\t  # location b/c this prevents finding dependent libraries that\n\t  # are installed to the same prefix.\n\t  # At present, this check doesn't affect windows .dll's that\n\t  # are installed into $libdir/../bin (currently, that works fine)\n\t  # but it's something to keep an eye on.\n\t  test \"$inst_prefix_dir\" = \"$destdir\" && \\\n\t    func_fatal_error \"error: cannot install \\`$file' to a directory not ending in $libdir\"\n\n\t  if test -n \"$inst_prefix_dir\"; then\n\t    # Stick the inst_prefix_dir data into the link command.\n\t    relink_command=`$ECHO \"$relink_command\" | $SED \"s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%\"`\n\t  else\n\t    relink_command=`$ECHO \"$relink_command\" | $SED \"s%@inst_prefix_dir@%%\"`\n\t  fi\n\n\t  func_warning \"relinking \\`$file'\"\n\t  func_show_eval \"$relink_command\" \\\n\t    'func_fatal_error \"error: relink \\`$file'\\'' with the above command before installing it\"'\n\tfi\n\n\t# See the names of the shared library.\n\tset dummy $library_names; shift\n\tif test -n \"$1\"; then\n\t  realname=\"$1\"\n\t  shift\n\n\t  srcname=\"$realname\"\n\t  test -n \"$relink_command\" && srcname=\"$realname\"T\n\n\t  # Install the shared library and build the symlinks.\n\t  func_show_eval \"$install_shared_prog $dir/$srcname $destdir/$realname\" \\\n\t      'exit $?'\n\t  tstripme=\"$stripme\"\n\t  case $host_os in\n\t  cygwin* | mingw* | pw32* | cegcc*)\n\t    case $realname in\n\t    *.dll.a)\n\t      tstripme=\"\"\n\t      ;;\n\t    esac\n\t    ;;\n\t  esac\n\t  if test -n \"$tstripme\" && test -n \"$striplib\"; then\n\t    func_show_eval \"$striplib $destdir/$realname\" 'exit $?'\n\t  fi\n\n\t  if test \"$#\" -gt 0; then\n\t    # Delete the old symlinks, and create new ones.\n\t    # Try `ln -sf' first, because the `ln' binary might depend on\n\t    # the symlink we replace!  Solaris /bin/ln does not understand -f,\n\t    # so we also need to try rm && ln -s.\n\t    for linkname\n\t    do\n\t      test \"$linkname\" != \"$realname\" \\\n\t\t&& func_show_eval \"(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })\"\n\t    done\n\t  fi\n\n\t  # Do each command in the postinstall commands.\n\t  lib=\"$destdir/$realname\"\n\t  func_execute_cmds \"$postinstall_cmds\" 'exit $?'\n\tfi\n\n\t# Install the pseudo-library for information purposes.\n\tfunc_basename \"$file\"\n\tname=\"$func_basename_result\"\n\tinstname=\"$dir/$name\"i\n\tfunc_show_eval \"$install_prog $instname $destdir/$name\" 'exit $?'\n\n\t# Maybe install the static library, too.\n\ttest -n \"$old_library\" && func_append staticlibs \" $dir/$old_library\"\n\t;;\n\n      *.lo)\n\t# Install (i.e. copy) a libtool object.\n\n\t# Figure out destination file name, if it wasn't already specified.\n\tif test -n \"$destname\"; then\n\t  destfile=\"$destdir/$destname\"\n\telse\n\t  func_basename \"$file\"\n\t  destfile=\"$func_basename_result\"\n\t  destfile=\"$destdir/$destfile\"\n\tfi\n\n\t# Deduce the name of the destination old-style object file.\n\tcase $destfile in\n\t*.lo)\n\t  func_lo2o \"$destfile\"\n\t  staticdest=$func_lo2o_result\n\t  ;;\n\t*.$objext)\n\t  staticdest=\"$destfile\"\n\t  destfile=\n\t  ;;\n\t*)\n\t  func_fatal_help \"cannot copy a libtool object to \\`$destfile'\"\n\t  ;;\n\tesac\n\n\t# Install the libtool object if requested.\n\ttest -n \"$destfile\" && \\\n\t  func_show_eval \"$install_prog $file $destfile\" 'exit $?'\n\n\t# Install the old object if enabled.\n\tif test \"$build_old_libs\" = yes; then\n\t  # Deduce the name of the old-style object file.\n\t  func_lo2o \"$file\"\n\t  staticobj=$func_lo2o_result\n\t  func_show_eval \"$install_prog \\$staticobj \\$staticdest\" 'exit $?'\n\tfi\n\texit $EXIT_SUCCESS\n\t;;\n\n      *)\n\t# Figure out destination file name, if it wasn't already specified.\n\tif test -n \"$destname\"; then\n\t  destfile=\"$destdir/$destname\"\n\telse\n\t  func_basename \"$file\"\n\t  destfile=\"$func_basename_result\"\n\t  destfile=\"$destdir/$destfile\"\n\tfi\n\n\t# If the file is missing, and there is a .exe on the end, strip it\n\t# because it is most likely a libtool script we actually want to\n\t# install\n\tstripped_ext=\"\"\n\tcase $file in\n\t  *.exe)\n\t    if test ! -f \"$file\"; then\n\t      func_stripname '' '.exe' \"$file\"\n\t      file=$func_stripname_result\n\t      stripped_ext=\".exe\"\n\t    fi\n\t    ;;\n\tesac\n\n\t# Do a test to see if this is really a libtool program.\n\tcase $host in\n\t*cygwin* | *mingw*)\n\t    if func_ltwrapper_executable_p \"$file\"; then\n\t      func_ltwrapper_scriptname \"$file\"\n\t      wrapper=$func_ltwrapper_scriptname_result\n\t    else\n\t      func_stripname '' '.exe' \"$file\"\n\t      wrapper=$func_stripname_result\n\t    fi\n\t    ;;\n\t*)\n\t    wrapper=$file\n\t    ;;\n\tesac\n\tif func_ltwrapper_script_p \"$wrapper\"; then\n\t  notinst_deplibs=\n\t  relink_command=\n\n\t  func_source \"$wrapper\"\n\n\t  # Check the variables that should have been set.\n\t  test -z \"$generated_by_libtool_version\" && \\\n\t    func_fatal_error \"invalid libtool wrapper script \\`$wrapper'\"\n\n\t  finalize=yes\n\t  for lib in $notinst_deplibs; do\n\t    # Check to see that each library is installed.\n\t    libdir=\n\t    if test -f \"$lib\"; then\n\t      func_source \"$lib\"\n\t    fi\n\t    libfile=\"$libdir/\"`$ECHO \"$lib\" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test\n\t    if test -n \"$libdir\" && test ! -f \"$libfile\"; then\n\t      func_warning \"\\`$lib' has not been installed in \\`$libdir'\"\n\t      finalize=no\n\t    fi\n\t  done\n\n\t  relink_command=\n\t  func_source \"$wrapper\"\n\n\t  outputname=\n\t  if test \"$fast_install\" = no && test -n \"$relink_command\"; then\n\t    $opt_dry_run || {\n\t      if test \"$finalize\" = yes; then\n\t        tmpdir=`func_mktempdir`\n\t\tfunc_basename \"$file$stripped_ext\"\n\t\tfile=\"$func_basename_result\"\n\t        outputname=\"$tmpdir/$file\"\n\t        # Replace the output file specification.\n\t        relink_command=`$ECHO \"$relink_command\" | $SED 's%@OUTPUT@%'\"$outputname\"'%g'`\n\n\t        $opt_silent || {\n\t          func_quote_for_expand \"$relink_command\"\n\t\t  eval \"func_echo $func_quote_for_expand_result\"\n\t        }\n\t        if eval \"$relink_command\"; then :\n\t          else\n\t\t  func_error \"error: relink \\`$file' with the above command before installing it\"\n\t\t  $opt_dry_run || ${RM}r \"$tmpdir\"\n\t\t  continue\n\t        fi\n\t        file=\"$outputname\"\n\t      else\n\t        func_warning \"cannot relink \\`$file'\"\n\t      fi\n\t    }\n\t  else\n\t    # Install the binary that we compiled earlier.\n\t    file=`$ECHO \"$file$stripped_ext\" | $SED \"s%\\([^/]*\\)$%$objdir/\\1%\"`\n\t  fi\n\tfi\n\n\t# remove .exe since cygwin /usr/bin/install will append another\n\t# one anyway\n\tcase $install_prog,$host in\n\t*/usr/bin/install*,*cygwin*)\n\t  case $file:$destfile in\n\t  *.exe:*.exe)\n\t    # this is ok\n\t    ;;\n\t  *.exe:*)\n\t    destfile=$destfile.exe\n\t    ;;\n\t  *:*.exe)\n\t    func_stripname '' '.exe' \"$destfile\"\n\t    destfile=$func_stripname_result\n\t    ;;\n\t  esac\n\t  ;;\n\tesac\n\tfunc_show_eval \"$install_prog\\$stripme \\$file \\$destfile\" 'exit $?'\n\t$opt_dry_run || if test -n \"$outputname\"; then\n\t  ${RM}r \"$tmpdir\"\n\tfi\n\t;;\n      esac\n    done\n\n    for file in $staticlibs; do\n      func_basename \"$file\"\n      name=\"$func_basename_result\"\n\n      # Set up the ranlib parameters.\n      oldlib=\"$destdir/$name\"\n      func_to_tool_file \"$oldlib\" func_convert_file_msys_to_w32\n      tool_oldlib=$func_to_tool_file_result\n\n      func_show_eval \"$install_prog \\$file \\$oldlib\" 'exit $?'\n\n      if test -n \"$stripme\" && test -n \"$old_striplib\"; then\n\tfunc_show_eval \"$old_striplib $tool_oldlib\" 'exit $?'\n      fi\n\n      # Do each command in the postinstall commands.\n      func_execute_cmds \"$old_postinstall_cmds\" 'exit $?'\n    done\n\n    test -n \"$future_libdirs\" && \\\n      func_warning \"remember to run \\`$progname --finish$future_libdirs'\"\n\n    if test -n \"$current_libdirs\"; then\n      # Maybe just do a dry run.\n      $opt_dry_run && current_libdirs=\" -n$current_libdirs\"\n      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'\n    else\n      exit $EXIT_SUCCESS\n    fi\n}\n\ntest \"$opt_mode\" = install && func_mode_install ${1+\"$@\"}\n\n\n# func_generate_dlsyms outputname originator pic_p\n# Extract symbols from dlprefiles and create ${outputname}S.o with\n# a dlpreopen symbol table.\nfunc_generate_dlsyms ()\n{\n    $opt_debug\n    my_outputname=\"$1\"\n    my_originator=\"$2\"\n    my_pic_p=\"${3-no}\"\n    my_prefix=`$ECHO \"$my_originator\" | sed 's%[^a-zA-Z0-9]%_%g'`\n    my_dlsyms=\n\n    if test -n \"$dlfiles$dlprefiles\" || test \"$dlself\" != no; then\n      if test -n \"$NM\" && test -n \"$global_symbol_pipe\"; then\n\tmy_dlsyms=\"${my_outputname}S.c\"\n      else\n\tfunc_error \"not configured to extract global symbols from dlpreopened files\"\n      fi\n    fi\n\n    if test -n \"$my_dlsyms\"; then\n      case $my_dlsyms in\n      \"\") ;;\n      *.c)\n\t# Discover the nlist of each of the dlfiles.\n\tnlist=\"$output_objdir/${my_outputname}.nm\"\n\n\tfunc_show_eval \"$RM $nlist ${nlist}S ${nlist}T\"\n\n\t# Parse the name list into a source file.\n\tfunc_verbose \"creating $output_objdir/$my_dlsyms\"\n\n\t$opt_dry_run || $ECHO > \"$output_objdir/$my_dlsyms\" \"\\\n/* $my_dlsyms - symbol resolution table for \\`$my_outputname' dlsym emulation. */\n/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */\n\n#ifdef __cplusplus\nextern \\\"C\\\" {\n#endif\n\n#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))\n#pragma GCC diagnostic ignored \\\"-Wstrict-prototypes\\\"\n#endif\n\n/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */\n#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)\n/* DATA imports from DLLs on WIN32 con't be const, because runtime\n   relocations are performed -- see ld's documentation on pseudo-relocs.  */\n# define LT_DLSYM_CONST\n#elif defined(__osf__)\n/* This system does not cope well with relocations in const data.  */\n# define LT_DLSYM_CONST\n#else\n# define LT_DLSYM_CONST const\n#endif\n\n/* External symbol declarations for the compiler. */\\\n\"\n\n\tif test \"$dlself\" = yes; then\n\t  func_verbose \"generating symbol list for \\`$output'\"\n\n\t  $opt_dry_run || echo ': @PROGRAM@ ' > \"$nlist\"\n\n\t  # Add our own program objects to the symbol list.\n\t  progfiles=`$ECHO \"$objs$old_deplibs\" | $SP2NL | $SED \"$lo2o\" | $NL2SP`\n\t  for progfile in $progfiles; do\n\t    func_to_tool_file \"$progfile\" func_convert_file_msys_to_w32\n\t    func_verbose \"extracting global C symbols from \\`$func_to_tool_file_result'\"\n\t    $opt_dry_run || eval \"$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'\"\n\t  done\n\n\t  if test -n \"$exclude_expsyms\"; then\n\t    $opt_dry_run || {\n\t      eval '$EGREP -v \" ($exclude_expsyms)$\" \"$nlist\" > \"$nlist\"T'\n\t      eval '$MV \"$nlist\"T \"$nlist\"'\n\t    }\n\t  fi\n\n\t  if test -n \"$export_symbols_regex\"; then\n\t    $opt_dry_run || {\n\t      eval '$EGREP -e \"$export_symbols_regex\" \"$nlist\" > \"$nlist\"T'\n\t      eval '$MV \"$nlist\"T \"$nlist\"'\n\t    }\n\t  fi\n\n\t  # Prepare the list of exported symbols\n\t  if test -z \"$export_symbols\"; then\n\t    export_symbols=\"$output_objdir/$outputname.exp\"\n\t    $opt_dry_run || {\n\t      $RM $export_symbols\n\t      eval \"${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \\(.*\\)$/\\1/p' \"'< \"$nlist\" > \"$export_symbols\"'\n\t      case $host in\n\t      *cygwin* | *mingw* | *cegcc* )\n                eval \"echo EXPORTS \"'> \"$output_objdir/$outputname.def\"'\n                eval 'cat \"$export_symbols\" >> \"$output_objdir/$outputname.def\"'\n\t        ;;\n\t      esac\n\t    }\n\t  else\n\t    $opt_dry_run || {\n\t      eval \"${SED} -e 's/\\([].[*^$]\\)/\\\\\\\\\\1/g' -e 's/^/ /' -e 's/$/$/'\"' < \"$export_symbols\" > \"$output_objdir/$outputname.exp\"'\n\t      eval '$GREP -f \"$output_objdir/$outputname.exp\" < \"$nlist\" > \"$nlist\"T'\n\t      eval '$MV \"$nlist\"T \"$nlist\"'\n\t      case $host in\n\t        *cygwin* | *mingw* | *cegcc* )\n\t          eval \"echo EXPORTS \"'> \"$output_objdir/$outputname.def\"'\n\t          eval 'cat \"$nlist\" >> \"$output_objdir/$outputname.def\"'\n\t          ;;\n\t      esac\n\t    }\n\t  fi\n\tfi\n\n\tfor dlprefile in $dlprefiles; do\n\t  func_verbose \"extracting global C symbols from \\`$dlprefile'\"\n\t  func_basename \"$dlprefile\"\n\t  name=\"$func_basename_result\"\n          case $host in\n\t    *cygwin* | *mingw* | *cegcc* )\n\t      # if an import library, we need to obtain dlname\n\t      if func_win32_import_lib_p \"$dlprefile\"; then\n\t        func_tr_sh \"$dlprefile\"\n\t        eval \"curr_lafile=\\$libfile_$func_tr_sh_result\"\n\t        dlprefile_dlbasename=\"\"\n\t        if test -n \"$curr_lafile\" && func_lalib_p \"$curr_lafile\"; then\n\t          # Use subshell, to avoid clobbering current variable values\n\t          dlprefile_dlname=`source \"$curr_lafile\" && echo \"$dlname\"`\n\t          if test -n \"$dlprefile_dlname\" ; then\n\t            func_basename \"$dlprefile_dlname\"\n\t            dlprefile_dlbasename=\"$func_basename_result\"\n\t          else\n\t            # no lafile. user explicitly requested -dlpreopen <import library>.\n\t            $sharedlib_from_linklib_cmd \"$dlprefile\"\n\t            dlprefile_dlbasename=$sharedlib_from_linklib_result\n\t          fi\n\t        fi\n\t        $opt_dry_run || {\n\t          if test -n \"$dlprefile_dlbasename\" ; then\n\t            eval '$ECHO \": $dlprefile_dlbasename\" >> \"$nlist\"'\n\t          else\n\t            func_warning \"Could not compute DLL name from $name\"\n\t            eval '$ECHO \": $name \" >> \"$nlist\"'\n\t          fi\n\t          func_to_tool_file \"$dlprefile\" func_convert_file_msys_to_w32\n\t          eval \"$NM \\\"$func_to_tool_file_result\\\" 2>/dev/null | $global_symbol_pipe |\n\t            $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'\"\n\t        }\n\t      else # not an import lib\n\t        $opt_dry_run || {\n\t          eval '$ECHO \": $name \" >> \"$nlist\"'\n\t          func_to_tool_file \"$dlprefile\" func_convert_file_msys_to_w32\n\t          eval \"$NM \\\"$func_to_tool_file_result\\\" 2>/dev/null | $global_symbol_pipe >> '$nlist'\"\n\t        }\n\t      fi\n\t    ;;\n\t    *)\n\t      $opt_dry_run || {\n\t        eval '$ECHO \": $name \" >> \"$nlist\"'\n\t        func_to_tool_file \"$dlprefile\" func_convert_file_msys_to_w32\n\t        eval \"$NM \\\"$func_to_tool_file_result\\\" 2>/dev/null | $global_symbol_pipe >> '$nlist'\"\n\t      }\n\t    ;;\n          esac\n\tdone\n\n\t$opt_dry_run || {\n\t  # Make sure we have at least an empty file.\n\t  test -f \"$nlist\" || : > \"$nlist\"\n\n\t  if test -n \"$exclude_expsyms\"; then\n\t    $EGREP -v \" ($exclude_expsyms)$\" \"$nlist\" > \"$nlist\"T\n\t    $MV \"$nlist\"T \"$nlist\"\n\t  fi\n\n\t  # Try sorting and uniquifying the output.\n\t  if $GREP -v \"^: \" < \"$nlist\" |\n\t      if sort -k 3 </dev/null >/dev/null 2>&1; then\n\t\tsort -k 3\n\t      else\n\t\tsort +2\n\t      fi |\n\t      uniq > \"$nlist\"S; then\n\t    :\n\t  else\n\t    $GREP -v \"^: \" < \"$nlist\" > \"$nlist\"S\n\t  fi\n\n\t  if test -f \"$nlist\"S; then\n\t    eval \"$global_symbol_to_cdecl\"' < \"$nlist\"S >> \"$output_objdir/$my_dlsyms\"'\n\t  else\n\t    echo '/* NONE */' >> \"$output_objdir/$my_dlsyms\"\n\t  fi\n\n\t  echo >> \"$output_objdir/$my_dlsyms\" \"\\\n\n/* The mapping between symbol names and symbols.  */\ntypedef struct {\n  const char *name;\n  void *address;\n} lt_dlsymlist;\nextern LT_DLSYM_CONST lt_dlsymlist\nlt_${my_prefix}_LTX_preloaded_symbols[];\nLT_DLSYM_CONST lt_dlsymlist\nlt_${my_prefix}_LTX_preloaded_symbols[] =\n{\\\n  { \\\"$my_originator\\\", (void *) 0 },\"\n\n\t  case $need_lib_prefix in\n\t  no)\n\t    eval \"$global_symbol_to_c_name_address\" < \"$nlist\" >> \"$output_objdir/$my_dlsyms\"\n\t    ;;\n\t  *)\n\t    eval \"$global_symbol_to_c_name_address_lib_prefix\" < \"$nlist\" >> \"$output_objdir/$my_dlsyms\"\n\t    ;;\n\t  esac\n\t  echo >> \"$output_objdir/$my_dlsyms\" \"\\\n  {0, (void *) 0}\n};\n\n/* This works around a problem in FreeBSD linker */\n#ifdef FREEBSD_WORKAROUND\nstatic const void *lt_preloaded_setup() {\n  return lt_${my_prefix}_LTX_preloaded_symbols;\n}\n#endif\n\n#ifdef __cplusplus\n}\n#endif\\\n\"\n\t} # !$opt_dry_run\n\n\tpic_flag_for_symtable=\n\tcase \"$compile_command \" in\n\t*\" -static \"*) ;;\n\t*)\n\t  case $host in\n\t  # compiling the symbol table file with pic_flag works around\n\t  # a FreeBSD bug that causes programs to crash when -lm is\n\t  # linked before any other PIC object.  But we must not use\n\t  # pic_flag when linking with -static.  The problem exists in\n\t  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.\n\t  *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)\n\t    pic_flag_for_symtable=\" $pic_flag -DFREEBSD_WORKAROUND\" ;;\n\t  *-*-hpux*)\n\t    pic_flag_for_symtable=\" $pic_flag\"  ;;\n\t  *)\n\t    if test \"X$my_pic_p\" != Xno; then\n\t      pic_flag_for_symtable=\" $pic_flag\"\n\t    fi\n\t    ;;\n\t  esac\n\t  ;;\n\tesac\n\tsymtab_cflags=\n\tfor arg in $LTCFLAGS; do\n\t  case $arg in\n\t  -pie | -fpie | -fPIE) ;;\n\t  *) func_append symtab_cflags \" $arg\" ;;\n\t  esac\n\tdone\n\n\t# Now compile the dynamic symbol file.\n\tfunc_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable \"$my_dlsyms\")' 'exit $?'\n\n\t# Clean up the generated files.\n\tfunc_show_eval '$RM \"$output_objdir/$my_dlsyms\" \"$nlist\" \"${nlist}S\" \"${nlist}T\"'\n\n\t# Transform the symbol file into the correct name.\n\tsymfileobj=\"$output_objdir/${my_outputname}S.$objext\"\n\tcase $host in\n\t*cygwin* | *mingw* | *cegcc* )\n\t  if test -f \"$output_objdir/$my_outputname.def\"; then\n\t    compile_command=`$ECHO \"$compile_command\" | $SED \"s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%\"`\n\t    finalize_command=`$ECHO \"$finalize_command\" | $SED \"s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%\"`\n\t  else\n\t    compile_command=`$ECHO \"$compile_command\" | $SED \"s%@SYMFILE@%$symfileobj%\"`\n\t    finalize_command=`$ECHO \"$finalize_command\" | $SED \"s%@SYMFILE@%$symfileobj%\"`\n\t  fi\n\t  ;;\n\t*)\n\t  compile_command=`$ECHO \"$compile_command\" | $SED \"s%@SYMFILE@%$symfileobj%\"`\n\t  finalize_command=`$ECHO \"$finalize_command\" | $SED \"s%@SYMFILE@%$symfileobj%\"`\n\t  ;;\n\tesac\n\t;;\n      *)\n\tfunc_fatal_error \"unknown suffix for \\`$my_dlsyms'\"\n\t;;\n      esac\n    else\n      # We keep going just in case the user didn't refer to\n      # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe\n      # really was required.\n\n      # Nullify the symbol file.\n      compile_command=`$ECHO \"$compile_command\" | $SED \"s% @SYMFILE@%%\"`\n      finalize_command=`$ECHO \"$finalize_command\" | $SED \"s% @SYMFILE@%%\"`\n    fi\n}\n\n# func_win32_libid arg\n# return the library type of file 'arg'\n#\n# Need a lot of goo to handle *both* DLLs and import libs\n# Has to be a shell function in order to 'eat' the argument\n# that is supplied when $file_magic_command is called.\n# Despite the name, also deal with 64 bit binaries.\nfunc_win32_libid ()\n{\n  $opt_debug\n  win32_libid_type=\"unknown\"\n  win32_fileres=`file -L $1 2>/dev/null`\n  case $win32_fileres in\n  *ar\\ archive\\ import\\ library*) # definitely import\n    win32_libid_type=\"x86 archive import\"\n    ;;\n  *ar\\ archive*) # could be an import, or static\n    # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.\n    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |\n       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then\n      func_to_tool_file \"$1\" func_convert_file_msys_to_w32\n      win32_nmres=`eval $NM -f posix -A \\\"$func_to_tool_file_result\\\" |\n\t$SED -n -e '\n\t    1,100{\n\t\t/ I /{\n\t\t    s,.*,import,\n\t\t    p\n\t\t    q\n\t\t}\n\t    }'`\n      case $win32_nmres in\n      import*)  win32_libid_type=\"x86 archive import\";;\n      *)        win32_libid_type=\"x86 archive static\";;\n      esac\n    fi\n    ;;\n  *DLL*)\n    win32_libid_type=\"x86 DLL\"\n    ;;\n  *executable*) # but shell scripts are \"executable\" too...\n    case $win32_fileres in\n    *MS\\ Windows\\ PE\\ Intel*)\n      win32_libid_type=\"x86 DLL\"\n      ;;\n    esac\n    ;;\n  esac\n  $ECHO \"$win32_libid_type\"\n}\n\n# func_cygming_dll_for_implib ARG\n#\n# Platform-specific function to extract the\n# name of the DLL associated with the specified\n# import library ARG.\n# Invoked by eval'ing the libtool variable\n#    $sharedlib_from_linklib_cmd\n# Result is available in the variable\n#    $sharedlib_from_linklib_result\nfunc_cygming_dll_for_implib ()\n{\n  $opt_debug\n  sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify \"$1\"`\n}\n\n# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs\n#\n# The is the core of a fallback implementation of a\n# platform-specific function to extract the name of the\n# DLL associated with the specified import library LIBNAME.\n#\n# SECTION_NAME is either .idata$6 or .idata$7, depending\n# on the platform and compiler that created the implib.\n#\n# Echos the name of the DLL associated with the\n# specified import library.\nfunc_cygming_dll_for_implib_fallback_core ()\n{\n  $opt_debug\n  match_literal=`$ECHO \"$1\" | $SED \"$sed_make_literal_regex\"`\n  $OBJDUMP -s --section \"$1\" \"$2\" 2>/dev/null |\n    $SED '/^Contents of section '\"$match_literal\"':/{\n      # Place marker at beginning of archive member dllname section\n      s/.*/====MARK====/\n      p\n      d\n    }\n    # These lines can sometimes be longer than 43 characters, but\n    # are always uninteresting\n    /:[\t ]*file format pe[i]\\{,1\\}-/d\n    /^In archive [^:]*:/d\n    # Ensure marker is printed\n    /^====MARK====/p\n    # Remove all lines with less than 43 characters\n    /^.\\{43\\}/!d\n    # From remaining lines, remove first 43 characters\n    s/^.\\{43\\}//' |\n    $SED -n '\n      # Join marker and all lines until next marker into a single line\n      /^====MARK====/ b para\n      H\n      $ b para\n      b\n      :para\n      x\n      s/\\n//g\n      # Remove the marker\n      s/^====MARK====//\n      # Remove trailing dots and whitespace\n      s/[\\. \\t]*$//\n      # Print\n      /./p' |\n    # we now have a list, one entry per line, of the stringified\n    # contents of the appropriate section of all members of the\n    # archive which possess that section. Heuristic: eliminate\n    # all those which have a first or second character that is\n    # a '.' (that is, objdump's representation of an unprintable\n    # character.) This should work for all archives with less than\n    # 0x302f exports -- but will fail for DLLs whose name actually\n    # begins with a literal '.' or a single character followed by\n    # a '.'.\n    #\n    # Of those that remain, print the first one.\n    $SED -e '/^\\./d;/^.\\./d;q'\n}\n\n# func_cygming_gnu_implib_p ARG\n# This predicate returns with zero status (TRUE) if\n# ARG is a GNU/binutils-style import library. Returns\n# with nonzero status (FALSE) otherwise.\nfunc_cygming_gnu_implib_p ()\n{\n  $opt_debug\n  func_to_tool_file \"$1\" func_convert_file_msys_to_w32\n  func_cygming_gnu_implib_tmp=`$NM \"$func_to_tool_file_result\" | eval \"$global_symbol_pipe\" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`\n  test -n \"$func_cygming_gnu_implib_tmp\"\n}\n\n# func_cygming_ms_implib_p ARG\n# This predicate returns with zero status (TRUE) if\n# ARG is an MS-style import library. Returns\n# with nonzero status (FALSE) otherwise.\nfunc_cygming_ms_implib_p ()\n{\n  $opt_debug\n  func_to_tool_file \"$1\" func_convert_file_msys_to_w32\n  func_cygming_ms_implib_tmp=`$NM \"$func_to_tool_file_result\" | eval \"$global_symbol_pipe\" | $GREP '_NULL_IMPORT_DESCRIPTOR'`\n  test -n \"$func_cygming_ms_implib_tmp\"\n}\n\n# func_cygming_dll_for_implib_fallback ARG\n# Platform-specific function to extract the\n# name of the DLL associated with the specified\n# import library ARG.\n#\n# This fallback implementation is for use when $DLLTOOL\n# does not support the --identify-strict option.\n# Invoked by eval'ing the libtool variable\n#    $sharedlib_from_linklib_cmd\n# Result is available in the variable\n#    $sharedlib_from_linklib_result\nfunc_cygming_dll_for_implib_fallback ()\n{\n  $opt_debug\n  if func_cygming_gnu_implib_p \"$1\" ; then\n    # binutils import library\n    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' \"$1\"`\n  elif func_cygming_ms_implib_p \"$1\" ; then\n    # ms-generated import library\n    sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' \"$1\"`\n  else\n    # unknown\n    sharedlib_from_linklib_result=\"\"\n  fi\n}\n\n\n# func_extract_an_archive dir oldlib\nfunc_extract_an_archive ()\n{\n    $opt_debug\n    f_ex_an_ar_dir=\"$1\"; shift\n    f_ex_an_ar_oldlib=\"$1\"\n    if test \"$lock_old_archive_extraction\" = yes; then\n      lockfile=$f_ex_an_ar_oldlib.lock\n      until $opt_dry_run || ln \"$progpath\" \"$lockfile\" 2>/dev/null; do\n\tfunc_echo \"Waiting for $lockfile to be removed\"\n\tsleep 2\n      done\n    fi\n    func_show_eval \"(cd \\$f_ex_an_ar_dir && $AR x \\\"\\$f_ex_an_ar_oldlib\\\")\" \\\n\t\t   'stat=$?; rm -f \"$lockfile\"; exit $stat'\n    if test \"$lock_old_archive_extraction\" = yes; then\n      $opt_dry_run || rm -f \"$lockfile\"\n    fi\n    if ($AR t \"$f_ex_an_ar_oldlib\" | sort | sort -uc >/dev/null 2>&1); then\n     :\n    else\n      func_fatal_error \"object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib\"\n    fi\n}\n\n\n# func_extract_archives gentop oldlib ...\nfunc_extract_archives ()\n{\n    $opt_debug\n    my_gentop=\"$1\"; shift\n    my_oldlibs=${1+\"$@\"}\n    my_oldobjs=\"\"\n    my_xlib=\"\"\n    my_xabs=\"\"\n    my_xdir=\"\"\n\n    for my_xlib in $my_oldlibs; do\n      # Extract the objects.\n      case $my_xlib in\n\t[\\\\/]* | [A-Za-z]:[\\\\/]*) my_xabs=\"$my_xlib\" ;;\n\t*) my_xabs=`pwd`\"/$my_xlib\" ;;\n      esac\n      func_basename \"$my_xlib\"\n      my_xlib=\"$func_basename_result\"\n      my_xlib_u=$my_xlib\n      while :; do\n        case \" $extracted_archives \" in\n\t*\" $my_xlib_u \"*)\n\t  func_arith $extracted_serial + 1\n\t  extracted_serial=$func_arith_result\n\t  my_xlib_u=lt$extracted_serial-$my_xlib ;;\n\t*) break ;;\n\tesac\n      done\n      extracted_archives=\"$extracted_archives $my_xlib_u\"\n      my_xdir=\"$my_gentop/$my_xlib_u\"\n\n      func_mkdir_p \"$my_xdir\"\n\n      case $host in\n      *-darwin*)\n\tfunc_verbose \"Extracting $my_xabs\"\n\t# Do not bother doing anything if just a dry run\n\t$opt_dry_run || {\n\t  darwin_orig_dir=`pwd`\n\t  cd $my_xdir || exit $?\n\t  darwin_archive=$my_xabs\n\t  darwin_curdir=`pwd`\n\t  darwin_base_archive=`basename \"$darwin_archive\"`\n\t  darwin_arches=`$LIPO -info \"$darwin_archive\" 2>/dev/null | $GREP Architectures 2>/dev/null || true`\n\t  if test -n \"$darwin_arches\"; then\n\t    darwin_arches=`$ECHO \"$darwin_arches\" | $SED -e 's/.*are://'`\n\t    darwin_arch=\n\t    func_verbose \"$darwin_base_archive has multiple architectures $darwin_arches\"\n\t    for darwin_arch in  $darwin_arches ; do\n\t      func_mkdir_p \"unfat-$$/${darwin_base_archive}-${darwin_arch}\"\n\t      $LIPO -thin $darwin_arch -output \"unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}\" \"${darwin_archive}\"\n\t      cd \"unfat-$$/${darwin_base_archive}-${darwin_arch}\"\n\t      func_extract_an_archive \"`pwd`\" \"${darwin_base_archive}\"\n\t      cd \"$darwin_curdir\"\n\t      $RM \"unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}\"\n\t    done # $darwin_arches\n            ## Okay now we've a bunch of thin objects, gotta fatten them up :)\n\t    darwin_filelist=`find unfat-$$ -type f -name \\*.o -print -o -name \\*.lo -print | $SED -e \"$basename\" | sort -u`\n\t    darwin_file=\n\t    darwin_files=\n\t    for darwin_file in $darwin_filelist; do\n\t      darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`\n\t      $LIPO -create -output \"$darwin_file\" $darwin_files\n\t    done # $darwin_filelist\n\t    $RM -rf unfat-$$\n\t    cd \"$darwin_orig_dir\"\n\t  else\n\t    cd $darwin_orig_dir\n\t    func_extract_an_archive \"$my_xdir\" \"$my_xabs\"\n\t  fi # $darwin_arches\n\t} # !$opt_dry_run\n\t;;\n      *)\n        func_extract_an_archive \"$my_xdir\" \"$my_xabs\"\n\t;;\n      esac\n      my_oldobjs=\"$my_oldobjs \"`find $my_xdir -name \\*.$objext -print -o -name \\*.lo -print | sort | $NL2SP`\n    done\n\n    func_extract_archives_result=\"$my_oldobjs\"\n}\n\n\n# func_emit_wrapper [arg=no]\n#\n# Emit a libtool wrapper script on stdout.\n# Don't directly open a file because we may want to\n# incorporate the script contents within a cygwin/mingw\n# wrapper executable.  Must ONLY be called from within\n# func_mode_link because it depends on a number of variables\n# set therein.\n#\n# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\n# variable will take.  If 'yes', then the emitted script\n# will assume that the directory in which it is stored is\n# the $objdir directory.  This is a cygwin/mingw-specific\n# behavior.\nfunc_emit_wrapper ()\n{\n\tfunc_emit_wrapper_arg1=${1-no}\n\n\t$ECHO \"\\\n#! $SHELL\n\n# $output - temporary wrapper script for $objdir/$outputname\n# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION\n#\n# The $output program cannot be directly executed until all the libtool\n# libraries that it depends on are installed.\n#\n# This wrapper script should never be moved out of the build directory.\n# If it is, it will not operate correctly.\n\n# Sed substitution that helps us do robust quoting.  It backslashifies\n# metacharacters that are still active within double-quoted strings.\nsed_quote_subst='$sed_quote_subst'\n\n# Be Bourne compatible\nif test -n \\\"\\${ZSH_VERSION+set}\\\" && (emulate sh) >/dev/null 2>&1; then\n  emulate sh\n  NULLCMD=:\n  # Zsh 3.x and 4.x performs word splitting on \\${1+\\\"\\$@\\\"}, which\n  # is contrary to our usage.  Disable this feature.\n  alias -g '\\${1+\\\"\\$@\\\"}'='\\\"\\$@\\\"'\n  setopt NO_GLOB_SUBST\nelse\n  case \\`(set -o) 2>/dev/null\\` in *posix*) set -o posix;; esac\nfi\nBIN_SH=xpg4; export BIN_SH # for Tru64\nDUALCASE=1; export DUALCASE # for MKS sh\n\n# The HP-UX ksh and POSIX shell print the target directory to stdout\n# if CDPATH is set.\n(unset CDPATH) >/dev/null 2>&1 && unset CDPATH\n\nrelink_command=\\\"$relink_command\\\"\n\n# This environment variable determines our operation mode.\nif test \\\"\\$libtool_install_magic\\\" = \\\"$magic\\\"; then\n  # install mode needs the following variables:\n  generated_by_libtool_version='$macro_version'\n  notinst_deplibs='$notinst_deplibs'\nelse\n  # When we are sourced in execute mode, \\$file and \\$ECHO are already set.\n  if test \\\"\\$libtool_execute_magic\\\" != \\\"$magic\\\"; then\n    file=\\\"\\$0\\\"\"\n\n    qECHO=`$ECHO \"$ECHO\" | $SED \"$sed_quote_subst\"`\n    $ECHO \"\\\n\n# A function that is used when there is no print builtin or printf.\nfunc_fallback_echo ()\n{\n  eval 'cat <<_LTECHO_EOF\n\\$1\n_LTECHO_EOF'\n}\n    ECHO=\\\"$qECHO\\\"\n  fi\n\n# Very basic option parsing. These options are (a) specific to\n# the libtool wrapper, (b) are identical between the wrapper\n# /script/ and the wrapper /executable/ which is used only on\n# windows platforms, and (c) all begin with the string \"--lt-\"\n# (application programs are unlikely to have options which match\n# this pattern).\n#\n# There are only two supported options: --lt-debug and\n# --lt-dump-script. There is, deliberately, no --lt-help.\n#\n# The first argument to this parsing function should be the\n# script's $0 value, followed by \"$@\".\nlt_option_debug=\nfunc_parse_lt_options ()\n{\n  lt_script_arg0=\\$0\n  shift\n  for lt_opt\n  do\n    case \\\"\\$lt_opt\\\" in\n    --lt-debug) lt_option_debug=1 ;;\n    --lt-dump-script)\n        lt_dump_D=\\`\\$ECHO \\\"X\\$lt_script_arg0\\\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\\`\n        test \\\"X\\$lt_dump_D\\\" = \\\"X\\$lt_script_arg0\\\" && lt_dump_D=.\n        lt_dump_F=\\`\\$ECHO \\\"X\\$lt_script_arg0\\\" | $SED -e 's/^X//' -e 's%^.*/%%'\\`\n        cat \\\"\\$lt_dump_D/\\$lt_dump_F\\\"\n        exit 0\n      ;;\n    --lt-*)\n        \\$ECHO \\\"Unrecognized --lt- option: '\\$lt_opt'\\\" 1>&2\n        exit 1\n      ;;\n    esac\n  done\n\n  # Print the debug banner immediately:\n  if test -n \\\"\\$lt_option_debug\\\"; then\n    echo \\\"${outputname}:${output}:\\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\\\" 1>&2\n  fi\n}\n\n# Used when --lt-debug. Prints its arguments to stdout\n# (redirection is the responsibility of the caller)\nfunc_lt_dump_args ()\n{\n  lt_dump_args_N=1;\n  for lt_arg\n  do\n    \\$ECHO \\\"${outputname}:${output}:\\${LINENO}: newargv[\\$lt_dump_args_N]: \\$lt_arg\\\"\n    lt_dump_args_N=\\`expr \\$lt_dump_args_N + 1\\`\n  done\n}\n\n# Core function for launching the target application\nfunc_exec_program_core ()\n{\n\"\n  case $host in\n  # Backslashes separate directories on plain windows\n  *-*-mingw | *-*-os2* | *-cegcc*)\n    $ECHO \"\\\n      if test -n \\\"\\$lt_option_debug\\\"; then\n        \\$ECHO \\\"${outputname}:${output}:\\${LINENO}: newargv[0]: \\$progdir\\\\\\\\\\$program\\\" 1>&2\n        func_lt_dump_args \\${1+\\\"\\$@\\\"} 1>&2\n      fi\n      exec \\\"\\$progdir\\\\\\\\\\$program\\\" \\${1+\\\"\\$@\\\"}\n\"\n    ;;\n\n  *)\n    $ECHO \"\\\n      if test -n \\\"\\$lt_option_debug\\\"; then\n        \\$ECHO \\\"${outputname}:${output}:\\${LINENO}: newargv[0]: \\$progdir/\\$program\\\" 1>&2\n        func_lt_dump_args \\${1+\\\"\\$@\\\"} 1>&2\n      fi\n      exec \\\"\\$progdir/\\$program\\\" \\${1+\\\"\\$@\\\"}\n\"\n    ;;\n  esac\n  $ECHO \"\\\n      \\$ECHO \\\"\\$0: cannot exec \\$program \\$*\\\" 1>&2\n      exit 1\n}\n\n# A function to encapsulate launching the target application\n# Strips options in the --lt-* namespace from \\$@ and\n# launches target application with the remaining arguments.\nfunc_exec_program ()\n{\n  case \\\" \\$* \\\" in\n  *\\\\ --lt-*)\n    for lt_wr_arg\n    do\n      case \\$lt_wr_arg in\n      --lt-*) ;;\n      *) set x \\\"\\$@\\\" \\\"\\$lt_wr_arg\\\"; shift;;\n      esac\n      shift\n    done ;;\n  esac\n  func_exec_program_core \\${1+\\\"\\$@\\\"}\n}\n\n  # Parse options\n  func_parse_lt_options \\\"\\$0\\\" \\${1+\\\"\\$@\\\"}\n\n  # Find the directory that this script lives in.\n  thisdir=\\`\\$ECHO \\\"\\$file\\\" | $SED 's%/[^/]*$%%'\\`\n  test \\\"x\\$thisdir\\\" = \\\"x\\$file\\\" && thisdir=.\n\n  # Follow symbolic links until we get to the real thisdir.\n  file=\\`ls -ld \\\"\\$file\\\" | $SED -n 's/.*-> //p'\\`\n  while test -n \\\"\\$file\\\"; do\n    destdir=\\`\\$ECHO \\\"\\$file\\\" | $SED 's%/[^/]*\\$%%'\\`\n\n    # If there was a directory component, then change thisdir.\n    if test \\\"x\\$destdir\\\" != \\\"x\\$file\\\"; then\n      case \\\"\\$destdir\\\" in\n      [\\\\\\\\/]* | [A-Za-z]:[\\\\\\\\/]*) thisdir=\\\"\\$destdir\\\" ;;\n      *) thisdir=\\\"\\$thisdir/\\$destdir\\\" ;;\n      esac\n    fi\n\n    file=\\`\\$ECHO \\\"\\$file\\\" | $SED 's%^.*/%%'\\`\n    file=\\`ls -ld \\\"\\$thisdir/\\$file\\\" | $SED -n 's/.*-> //p'\\`\n  done\n\n  # Usually 'no', except on cygwin/mingw when embedded into\n  # the cwrapper.\n  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1\n  if test \\\"\\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\\\" = \\\"yes\\\"; then\n    # special case for '.'\n    if test \\\"\\$thisdir\\\" = \\\".\\\"; then\n      thisdir=\\`pwd\\`\n    fi\n    # remove .libs from thisdir\n    case \\\"\\$thisdir\\\" in\n    *[\\\\\\\\/]$objdir ) thisdir=\\`\\$ECHO \\\"\\$thisdir\\\" | $SED 's%[\\\\\\\\/][^\\\\\\\\/]*$%%'\\` ;;\n    $objdir )   thisdir=. ;;\n    esac\n  fi\n\n  # Try to get the absolute directory name.\n  absdir=\\`cd \\\"\\$thisdir\\\" && pwd\\`\n  test -n \\\"\\$absdir\\\" && thisdir=\\\"\\$absdir\\\"\n\"\n\n\tif test \"$fast_install\" = yes; then\n\t  $ECHO \"\\\n  program=lt-'$outputname'$exeext\n  progdir=\\\"\\$thisdir/$objdir\\\"\n\n  if test ! -f \\\"\\$progdir/\\$program\\\" ||\n     { file=\\`ls -1dt \\\"\\$progdir/\\$program\\\" \\\"\\$progdir/../\\$program\\\" 2>/dev/null | ${SED} 1q\\`; \\\\\n       test \\\"X\\$file\\\" != \\\"X\\$progdir/\\$program\\\"; }; then\n\n    file=\\\"\\$\\$-\\$program\\\"\n\n    if test ! -d \\\"\\$progdir\\\"; then\n      $MKDIR \\\"\\$progdir\\\"\n    else\n      $RM \\\"\\$progdir/\\$file\\\"\n    fi\"\n\n\t  $ECHO \"\\\n\n    # relink executable if necessary\n    if test -n \\\"\\$relink_command\\\"; then\n      if relink_command_output=\\`eval \\$relink_command 2>&1\\`; then :\n      else\n\t$ECHO \\\"\\$relink_command_output\\\" >&2\n\t$RM \\\"\\$progdir/\\$file\\\"\n\texit 1\n      fi\n    fi\n\n    $MV \\\"\\$progdir/\\$file\\\" \\\"\\$progdir/\\$program\\\" 2>/dev/null ||\n    { $RM \\\"\\$progdir/\\$program\\\";\n      $MV \\\"\\$progdir/\\$file\\\" \\\"\\$progdir/\\$program\\\"; }\n    $RM \\\"\\$progdir/\\$file\\\"\n  fi\"\n\telse\n\t  $ECHO \"\\\n  program='$outputname'\n  progdir=\\\"\\$thisdir/$objdir\\\"\n\"\n\tfi\n\n\t$ECHO \"\\\n\n  if test -f \\\"\\$progdir/\\$program\\\"; then\"\n\n\t# fixup the dll searchpath if we need to.\n\t#\n\t# Fix the DLL searchpath if we need to.  Do this before prepending\n\t# to shlibpath, because on Windows, both are PATH and uninstalled\n\t# libraries must come first.\n\tif test -n \"$dllsearchpath\"; then\n\t  $ECHO \"\\\n    # Add the dll search path components to the executable PATH\n    PATH=$dllsearchpath:\\$PATH\n\"\n\tfi\n\n\t# Export our shlibpath_var if we have one.\n\tif test \"$shlibpath_overrides_runpath\" = yes && test -n \"$shlibpath_var\" && test -n \"$temp_rpath\"; then\n\t  $ECHO \"\\\n    # Add our own library path to $shlibpath_var\n    $shlibpath_var=\\\"$temp_rpath\\$$shlibpath_var\\\"\n\n    # Some systems cannot cope with colon-terminated $shlibpath_var\n    # The second colon is a workaround for a bug in BeOS R4 sed\n    $shlibpath_var=\\`\\$ECHO \\\"\\$$shlibpath_var\\\" | $SED 's/::*\\$//'\\`\n\n    export $shlibpath_var\n\"\n\tfi\n\n\t$ECHO \"\\\n    if test \\\"\\$libtool_execute_magic\\\" != \\\"$magic\\\"; then\n      # Run the actual program with our arguments.\n      func_exec_program \\${1+\\\"\\$@\\\"}\n    fi\n  else\n    # The program doesn't exist.\n    \\$ECHO \\\"\\$0: error: \\\\\\`\\$progdir/\\$program' does not exist\\\" 1>&2\n    \\$ECHO \\\"This script is just a wrapper for \\$program.\\\" 1>&2\n    \\$ECHO \\\"See the $PACKAGE documentation for more information.\\\" 1>&2\n    exit 1\n  fi\nfi\\\n\"\n}\n\n\n# func_emit_cwrapperexe_src\n# emit the source code for a wrapper executable on stdout\n# Must ONLY be called from within func_mode_link because\n# it depends on a number of variable set therein.\nfunc_emit_cwrapperexe_src ()\n{\n\tcat <<EOF\n\n/* $cwrappersource - temporary wrapper executable for $objdir/$outputname\n   Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION\n\n   The $output program cannot be directly executed until all the libtool\n   libraries that it depends on are installed.\n\n   This wrapper executable should never be moved out of the build directory.\n   If it is, it will not operate correctly.\n*/\nEOF\n\t    cat <<\"EOF\"\n#ifdef _MSC_VER\n# define _CRT_SECURE_NO_DEPRECATE 1\n#endif\n#include <stdio.h>\n#include <stdlib.h>\n#ifdef _MSC_VER\n# include <direct.h>\n# include <process.h>\n# include <io.h>\n#else\n# include <unistd.h>\n# include <stdint.h>\n# ifdef __CYGWIN__\n#  include <io.h>\n# endif\n#endif\n#include <malloc.h>\n#include <stdarg.h>\n#include <assert.h>\n#include <string.h>\n#include <ctype.h>\n#include <errno.h>\n#include <fcntl.h>\n#include <sys/stat.h>\n\n/* declarations of non-ANSI functions */\n#if defined(__MINGW32__)\n# ifdef __STRICT_ANSI__\nint _putenv (const char *);\n# endif\n#elif defined(__CYGWIN__)\n# ifdef __STRICT_ANSI__\nchar *realpath (const char *, char *);\nint putenv (char *);\nint setenv (const char *, const char *, int);\n# endif\n/* #elif defined (other platforms) ... */\n#endif\n\n/* portability defines, excluding path handling macros */\n#if defined(_MSC_VER)\n# define setmode _setmode\n# define stat    _stat\n# define chmod   _chmod\n# define getcwd  _getcwd\n# define putenv  _putenv\n# define S_IXUSR _S_IEXEC\n# ifndef _INTPTR_T_DEFINED\n#  define _INTPTR_T_DEFINED\n#  define intptr_t int\n# endif\n#elif defined(__MINGW32__)\n# define setmode _setmode\n# define stat    _stat\n# define chmod   _chmod\n# define getcwd  _getcwd\n# define putenv  _putenv\n#elif defined(__CYGWIN__)\n# define HAVE_SETENV\n# define FOPEN_WB \"wb\"\n/* #elif defined (other platforms) ... */\n#endif\n\n#if defined(PATH_MAX)\n# define LT_PATHMAX PATH_MAX\n#elif defined(MAXPATHLEN)\n# define LT_PATHMAX MAXPATHLEN\n#else\n# define LT_PATHMAX 1024\n#endif\n\n#ifndef S_IXOTH\n# define S_IXOTH 0\n#endif\n#ifndef S_IXGRP\n# define S_IXGRP 0\n#endif\n\n/* path handling portability macros */\n#ifndef DIR_SEPARATOR\n# define DIR_SEPARATOR '/'\n# define PATH_SEPARATOR ':'\n#endif\n\n#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \\\n  defined (__OS2__)\n# define HAVE_DOS_BASED_FILE_SYSTEM\n# define FOPEN_WB \"wb\"\n# ifndef DIR_SEPARATOR_2\n#  define DIR_SEPARATOR_2 '\\\\'\n# endif\n# ifndef PATH_SEPARATOR_2\n#  define PATH_SEPARATOR_2 ';'\n# endif\n#endif\n\n#ifndef DIR_SEPARATOR_2\n# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)\n#else /* DIR_SEPARATOR_2 */\n# define IS_DIR_SEPARATOR(ch) \\\n\t(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))\n#endif /* DIR_SEPARATOR_2 */\n\n#ifndef PATH_SEPARATOR_2\n# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)\n#else /* PATH_SEPARATOR_2 */\n# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)\n#endif /* PATH_SEPARATOR_2 */\n\n#ifndef FOPEN_WB\n# define FOPEN_WB \"w\"\n#endif\n#ifndef _O_BINARY\n# define _O_BINARY 0\n#endif\n\n#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))\n#define XFREE(stale) do { \\\n  if (stale) { free ((void *) stale); stale = 0; } \\\n} while (0)\n\n#if defined(LT_DEBUGWRAPPER)\nstatic int lt_debug = 1;\n#else\nstatic int lt_debug = 0;\n#endif\n\nconst char *program_name = \"libtool-wrapper\"; /* in case xstrdup fails */\n\nvoid *xmalloc (size_t num);\nchar *xstrdup (const char *string);\nconst char *base_name (const char *name);\nchar *find_executable (const char *wrapper);\nchar *chase_symlinks (const char *pathspec);\nint make_executable (const char *path);\nint check_executable (const char *path);\nchar *strendzap (char *str, const char *pat);\nvoid lt_debugprintf (const char *file, int line, const char *fmt, ...);\nvoid lt_fatal (const char *file, int line, const char *message, ...);\nstatic const char *nonnull (const char *s);\nstatic const char *nonempty (const char *s);\nvoid lt_setenv (const char *name, const char *value);\nchar *lt_extend_str (const char *orig_value, const char *add, int to_end);\nvoid lt_update_exe_path (const char *name, const char *value);\nvoid lt_update_lib_path (const char *name, const char *value);\nchar **prepare_spawn (char **argv);\nvoid lt_dump_script (FILE *f);\nEOF\n\n\t    cat <<EOF\nvolatile const char * MAGIC_EXE = \"$magic_exe\";\nconst char * LIB_PATH_VARNAME = \"$shlibpath_var\";\nEOF\n\n\t    if test \"$shlibpath_overrides_runpath\" = yes && test -n \"$shlibpath_var\" && test -n \"$temp_rpath\"; then\n              func_to_host_path \"$temp_rpath\"\n\t      cat <<EOF\nconst char * LIB_PATH_VALUE   = \"$func_to_host_path_result\";\nEOF\n\t    else\n\t      cat <<\"EOF\"\nconst char * LIB_PATH_VALUE   = \"\";\nEOF\n\t    fi\n\n\t    if test -n \"$dllsearchpath\"; then\n              func_to_host_path \"$dllsearchpath:\"\n\t      cat <<EOF\nconst char * EXE_PATH_VARNAME = \"PATH\";\nconst char * EXE_PATH_VALUE   = \"$func_to_host_path_result\";\nEOF\n\t    else\n\t      cat <<\"EOF\"\nconst char * EXE_PATH_VARNAME = \"\";\nconst char * EXE_PATH_VALUE   = \"\";\nEOF\n\t    fi\n\n\t    if test \"$fast_install\" = yes; then\n\t      cat <<EOF\nconst char * TARGET_PROGRAM_NAME = \"lt-$outputname\"; /* hopefully, no .exe */\nEOF\n\t    else\n\t      cat <<EOF\nconst char * TARGET_PROGRAM_NAME = \"$outputname\"; /* hopefully, no .exe */\nEOF\n\t    fi\n\n\n\t    cat <<\"EOF\"\n\n#define LTWRAPPER_OPTION_PREFIX         \"--lt-\"\n\nstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;\nstatic const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX \"dump-script\";\nstatic const char *debug_opt            = LTWRAPPER_OPTION_PREFIX \"debug\";\n\nint\nmain (int argc, char *argv[])\n{\n  char **newargz;\n  int  newargc;\n  char *tmp_pathspec;\n  char *actual_cwrapper_path;\n  char *actual_cwrapper_name;\n  char *target_name;\n  char *lt_argv_zero;\n  intptr_t rval = 127;\n\n  int i;\n\n  program_name = (char *) xstrdup (base_name (argv[0]));\n  newargz = XMALLOC (char *, argc + 1);\n\n  /* very simple arg parsing; don't want to rely on getopt\n   * also, copy all non cwrapper options to newargz, except\n   * argz[0], which is handled differently\n   */\n  newargc=0;\n  for (i = 1; i < argc; i++)\n    {\n      if (strcmp (argv[i], dumpscript_opt) == 0)\n\t{\nEOF\n\t    case \"$host\" in\n\t      *mingw* | *cygwin* )\n\t\t# make stdout use \"unix\" line endings\n\t\techo \"          setmode(1,_O_BINARY);\"\n\t\t;;\n\t      esac\n\n\t    cat <<\"EOF\"\n\t  lt_dump_script (stdout);\n\t  return 0;\n\t}\n      if (strcmp (argv[i], debug_opt) == 0)\n\t{\n          lt_debug = 1;\n          continue;\n\t}\n      if (strcmp (argv[i], ltwrapper_option_prefix) == 0)\n        {\n          /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX\n             namespace, but it is not one of the ones we know about and\n             have already dealt with, above (inluding dump-script), then\n             report an error. Otherwise, targets might begin to believe\n             they are allowed to use options in the LTWRAPPER_OPTION_PREFIX\n             namespace. The first time any user complains about this, we'll\n             need to make LTWRAPPER_OPTION_PREFIX a configure-time option\n             or a configure.ac-settable value.\n           */\n          lt_fatal (__FILE__, __LINE__,\n\t\t    \"unrecognized %s option: '%s'\",\n                    ltwrapper_option_prefix, argv[i]);\n        }\n      /* otherwise ... */\n      newargz[++newargc] = xstrdup (argv[i]);\n    }\n  newargz[++newargc] = NULL;\n\nEOF\n\t    cat <<EOF\n  /* The GNU banner must be the first non-error debug message */\n  lt_debugprintf (__FILE__, __LINE__, \"libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\\n\");\nEOF\n\t    cat <<\"EOF\"\n  lt_debugprintf (__FILE__, __LINE__, \"(main) argv[0]: %s\\n\", argv[0]);\n  lt_debugprintf (__FILE__, __LINE__, \"(main) program_name: %s\\n\", program_name);\n\n  tmp_pathspec = find_executable (argv[0]);\n  if (tmp_pathspec == NULL)\n    lt_fatal (__FILE__, __LINE__, \"couldn't find %s\", argv[0]);\n  lt_debugprintf (__FILE__, __LINE__,\n                  \"(main) found exe (before symlink chase) at: %s\\n\",\n\t\t  tmp_pathspec);\n\n  actual_cwrapper_path = chase_symlinks (tmp_pathspec);\n  lt_debugprintf (__FILE__, __LINE__,\n                  \"(main) found exe (after symlink chase) at: %s\\n\",\n\t\t  actual_cwrapper_path);\n  XFREE (tmp_pathspec);\n\n  actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));\n  strendzap (actual_cwrapper_path, actual_cwrapper_name);\n\n  /* wrapper name transforms */\n  strendzap (actual_cwrapper_name, \".exe\");\n  tmp_pathspec = lt_extend_str (actual_cwrapper_name, \".exe\", 1);\n  XFREE (actual_cwrapper_name);\n  actual_cwrapper_name = tmp_pathspec;\n  tmp_pathspec = 0;\n\n  /* target_name transforms -- use actual target program name; might have lt- prefix */\n  target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));\n  strendzap (target_name, \".exe\");\n  tmp_pathspec = lt_extend_str (target_name, \".exe\", 1);\n  XFREE (target_name);\n  target_name = tmp_pathspec;\n  tmp_pathspec = 0;\n\n  lt_debugprintf (__FILE__, __LINE__,\n\t\t  \"(main) libtool target name: %s\\n\",\n\t\t  target_name);\nEOF\n\n\t    cat <<EOF\n  newargz[0] =\n    XMALLOC (char, (strlen (actual_cwrapper_path) +\n\t\t    strlen (\"$objdir\") + 1 + strlen (actual_cwrapper_name) + 1));\n  strcpy (newargz[0], actual_cwrapper_path);\n  strcat (newargz[0], \"$objdir\");\n  strcat (newargz[0], \"/\");\nEOF\n\n\t    cat <<\"EOF\"\n  /* stop here, and copy so we don't have to do this twice */\n  tmp_pathspec = xstrdup (newargz[0]);\n\n  /* do NOT want the lt- prefix here, so use actual_cwrapper_name */\n  strcat (newargz[0], actual_cwrapper_name);\n\n  /* DO want the lt- prefix here if it exists, so use target_name */\n  lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);\n  XFREE (tmp_pathspec);\n  tmp_pathspec = NULL;\nEOF\n\n\t    case $host_os in\n\t      mingw*)\n\t    cat <<\"EOF\"\n  {\n    char* p;\n    while ((p = strchr (newargz[0], '\\\\')) != NULL)\n      {\n\t*p = '/';\n      }\n    while ((p = strchr (lt_argv_zero, '\\\\')) != NULL)\n      {\n\t*p = '/';\n      }\n  }\nEOF\n\t    ;;\n\t    esac\n\n\t    cat <<\"EOF\"\n  XFREE (target_name);\n  XFREE (actual_cwrapper_path);\n  XFREE (actual_cwrapper_name);\n\n  lt_setenv (\"BIN_SH\", \"xpg4\"); /* for Tru64 */\n  lt_setenv (\"DUALCASE\", \"1\");  /* for MSK sh */\n  /* Update the DLL searchpath.  EXE_PATH_VALUE ($dllsearchpath) must\n     be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)\n     because on Windows, both *_VARNAMEs are PATH but uninstalled\n     libraries must come first. */\n  lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);\n  lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);\n\n  lt_debugprintf (__FILE__, __LINE__, \"(main) lt_argv_zero: %s\\n\",\n\t\t  nonnull (lt_argv_zero));\n  for (i = 0; i < newargc; i++)\n    {\n      lt_debugprintf (__FILE__, __LINE__, \"(main) newargz[%d]: %s\\n\",\n\t\t      i, nonnull (newargz[i]));\n    }\n\nEOF\n\n\t    case $host_os in\n\t      mingw*)\n\t\tcat <<\"EOF\"\n  /* execv doesn't actually work on mingw as expected on unix */\n  newargz = prepare_spawn (newargz);\n  rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);\n  if (rval == -1)\n    {\n      /* failed to start process */\n      lt_debugprintf (__FILE__, __LINE__,\n\t\t      \"(main) failed to launch target \\\"%s\\\": %s\\n\",\n\t\t      lt_argv_zero, nonnull (strerror (errno)));\n      return 127;\n    }\n  return rval;\nEOF\n\t\t;;\n\t      *)\n\t\tcat <<\"EOF\"\n  execv (lt_argv_zero, newargz);\n  return rval; /* =127, but avoids unused variable warning */\nEOF\n\t\t;;\n\t    esac\n\n\t    cat <<\"EOF\"\n}\n\nvoid *\nxmalloc (size_t num)\n{\n  void *p = (void *) malloc (num);\n  if (!p)\n    lt_fatal (__FILE__, __LINE__, \"memory exhausted\");\n\n  return p;\n}\n\nchar *\nxstrdup (const char *string)\n{\n  return string ? strcpy ((char *) xmalloc (strlen (string) + 1),\n\t\t\t  string) : NULL;\n}\n\nconst char *\nbase_name (const char *name)\n{\n  const char *base;\n\n#if defined (HAVE_DOS_BASED_FILE_SYSTEM)\n  /* Skip over the disk name in MSDOS pathnames. */\n  if (isalpha ((unsigned char) name[0]) && name[1] == ':')\n    name += 2;\n#endif\n\n  for (base = name; *name; name++)\n    if (IS_DIR_SEPARATOR (*name))\n      base = name + 1;\n  return base;\n}\n\nint\ncheck_executable (const char *path)\n{\n  struct stat st;\n\n  lt_debugprintf (__FILE__, __LINE__, \"(check_executable): %s\\n\",\n                  nonempty (path));\n  if ((!path) || (!*path))\n    return 0;\n\n  if ((stat (path, &st) >= 0)\n      && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))\n    return 1;\n  else\n    return 0;\n}\n\nint\nmake_executable (const char *path)\n{\n  int rval = 0;\n  struct stat st;\n\n  lt_debugprintf (__FILE__, __LINE__, \"(make_executable): %s\\n\",\n                  nonempty (path));\n  if ((!path) || (!*path))\n    return 0;\n\n  if (stat (path, &st) >= 0)\n    {\n      rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);\n    }\n  return rval;\n}\n\n/* Searches for the full path of the wrapper.  Returns\n   newly allocated full path name if found, NULL otherwise\n   Does not chase symlinks, even on platforms that support them.\n*/\nchar *\nfind_executable (const char *wrapper)\n{\n  int has_slash = 0;\n  const char *p;\n  const char *p_next;\n  /* static buffer for getcwd */\n  char tmp[LT_PATHMAX + 1];\n  int tmp_len;\n  char *concat_name;\n\n  lt_debugprintf (__FILE__, __LINE__, \"(find_executable): %s\\n\",\n                  nonempty (wrapper));\n\n  if ((wrapper == NULL) || (*wrapper == '\\0'))\n    return NULL;\n\n  /* Absolute path? */\n#if defined (HAVE_DOS_BASED_FILE_SYSTEM)\n  if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')\n    {\n      concat_name = xstrdup (wrapper);\n      if (check_executable (concat_name))\n\treturn concat_name;\n      XFREE (concat_name);\n    }\n  else\n    {\n#endif\n      if (IS_DIR_SEPARATOR (wrapper[0]))\n\t{\n\t  concat_name = xstrdup (wrapper);\n\t  if (check_executable (concat_name))\n\t    return concat_name;\n\t  XFREE (concat_name);\n\t}\n#if defined (HAVE_DOS_BASED_FILE_SYSTEM)\n    }\n#endif\n\n  for (p = wrapper; *p; p++)\n    if (*p == '/')\n      {\n\thas_slash = 1;\n\tbreak;\n      }\n  if (!has_slash)\n    {\n      /* no slashes; search PATH */\n      const char *path = getenv (\"PATH\");\n      if (path != NULL)\n\t{\n\t  for (p = path; *p; p = p_next)\n\t    {\n\t      const char *q;\n\t      size_t p_len;\n\t      for (q = p; *q; q++)\n\t\tif (IS_PATH_SEPARATOR (*q))\n\t\t  break;\n\t      p_len = q - p;\n\t      p_next = (*q == '\\0' ? q : q + 1);\n\t      if (p_len == 0)\n\t\t{\n\t\t  /* empty path: current directory */\n\t\t  if (getcwd (tmp, LT_PATHMAX) == NULL)\n\t\t    lt_fatal (__FILE__, __LINE__, \"getcwd failed: %s\",\n                              nonnull (strerror (errno)));\n\t\t  tmp_len = strlen (tmp);\n\t\t  concat_name =\n\t\t    XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);\n\t\t  memcpy (concat_name, tmp, tmp_len);\n\t\t  concat_name[tmp_len] = '/';\n\t\t  strcpy (concat_name + tmp_len + 1, wrapper);\n\t\t}\n\t      else\n\t\t{\n\t\t  concat_name =\n\t\t    XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);\n\t\t  memcpy (concat_name, p, p_len);\n\t\t  concat_name[p_len] = '/';\n\t\t  strcpy (concat_name + p_len + 1, wrapper);\n\t\t}\n\t      if (check_executable (concat_name))\n\t\treturn concat_name;\n\t      XFREE (concat_name);\n\t    }\n\t}\n      /* not found in PATH; assume curdir */\n    }\n  /* Relative path | not found in path: prepend cwd */\n  if (getcwd (tmp, LT_PATHMAX) == NULL)\n    lt_fatal (__FILE__, __LINE__, \"getcwd failed: %s\",\n              nonnull (strerror (errno)));\n  tmp_len = strlen (tmp);\n  concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);\n  memcpy (concat_name, tmp, tmp_len);\n  concat_name[tmp_len] = '/';\n  strcpy (concat_name + tmp_len + 1, wrapper);\n\n  if (check_executable (concat_name))\n    return concat_name;\n  XFREE (concat_name);\n  return NULL;\n}\n\nchar *\nchase_symlinks (const char *pathspec)\n{\n#ifndef S_ISLNK\n  return xstrdup (pathspec);\n#else\n  char buf[LT_PATHMAX];\n  struct stat s;\n  char *tmp_pathspec = xstrdup (pathspec);\n  char *p;\n  int has_symlinks = 0;\n  while (strlen (tmp_pathspec) && !has_symlinks)\n    {\n      lt_debugprintf (__FILE__, __LINE__,\n\t\t      \"checking path component for symlinks: %s\\n\",\n\t\t      tmp_pathspec);\n      if (lstat (tmp_pathspec, &s) == 0)\n\t{\n\t  if (S_ISLNK (s.st_mode) != 0)\n\t    {\n\t      has_symlinks = 1;\n\t      break;\n\t    }\n\n\t  /* search backwards for last DIR_SEPARATOR */\n\t  p = tmp_pathspec + strlen (tmp_pathspec) - 1;\n\t  while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))\n\t    p--;\n\t  if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))\n\t    {\n\t      /* no more DIR_SEPARATORS left */\n\t      break;\n\t    }\n\t  *p = '\\0';\n\t}\n      else\n\t{\n\t  lt_fatal (__FILE__, __LINE__,\n\t\t    \"error accessing file \\\"%s\\\": %s\",\n\t\t    tmp_pathspec, nonnull (strerror (errno)));\n\t}\n    }\n  XFREE (tmp_pathspec);\n\n  if (!has_symlinks)\n    {\n      return xstrdup (pathspec);\n    }\n\n  tmp_pathspec = realpath (pathspec, buf);\n  if (tmp_pathspec == 0)\n    {\n      lt_fatal (__FILE__, __LINE__,\n\t\t\"could not follow symlinks for %s\", pathspec);\n    }\n  return xstrdup (tmp_pathspec);\n#endif\n}\n\nchar *\nstrendzap (char *str, const char *pat)\n{\n  size_t len, patlen;\n\n  assert (str != NULL);\n  assert (pat != NULL);\n\n  len = strlen (str);\n  patlen = strlen (pat);\n\n  if (patlen <= len)\n    {\n      str += len - patlen;\n      if (strcmp (str, pat) == 0)\n\t*str = '\\0';\n    }\n  return str;\n}\n\nvoid\nlt_debugprintf (const char *file, int line, const char *fmt, ...)\n{\n  va_list args;\n  if (lt_debug)\n    {\n      (void) fprintf (stderr, \"%s:%s:%d: \", program_name, file, line);\n      va_start (args, fmt);\n      (void) vfprintf (stderr, fmt, args);\n      va_end (args);\n    }\n}\n\nstatic void\nlt_error_core (int exit_status, const char *file,\n\t       int line, const char *mode,\n\t       const char *message, va_list ap)\n{\n  fprintf (stderr, \"%s:%s:%d: %s: \", program_name, file, line, mode);\n  vfprintf (stderr, message, ap);\n  fprintf (stderr, \".\\n\");\n\n  if (exit_status >= 0)\n    exit (exit_status);\n}\n\nvoid\nlt_fatal (const char *file, int line, const char *message, ...)\n{\n  va_list ap;\n  va_start (ap, message);\n  lt_error_core (EXIT_FAILURE, file, line, \"FATAL\", message, ap);\n  va_end (ap);\n}\n\nstatic const char *\nnonnull (const char *s)\n{\n  return s ? s : \"(null)\";\n}\n\nstatic const char *\nnonempty (const char *s)\n{\n  return (s && !*s) ? \"(empty)\" : nonnull (s);\n}\n\nvoid\nlt_setenv (const char *name, const char *value)\n{\n  lt_debugprintf (__FILE__, __LINE__,\n\t\t  \"(lt_setenv) setting '%s' to '%s'\\n\",\n                  nonnull (name), nonnull (value));\n  {\n#ifdef HAVE_SETENV\n    /* always make a copy, for consistency with !HAVE_SETENV */\n    char *str = xstrdup (value);\n    setenv (name, str, 1);\n#else\n    int len = strlen (name) + 1 + strlen (value) + 1;\n    char *str = XMALLOC (char, len);\n    sprintf (str, \"%s=%s\", name, value);\n    if (putenv (str) != EXIT_SUCCESS)\n      {\n        XFREE (str);\n      }\n#endif\n  }\n}\n\nchar *\nlt_extend_str (const char *orig_value, const char *add, int to_end)\n{\n  char *new_value;\n  if (orig_value && *orig_value)\n    {\n      int orig_value_len = strlen (orig_value);\n      int add_len = strlen (add);\n      new_value = XMALLOC (char, add_len + orig_value_len + 1);\n      if (to_end)\n        {\n          strcpy (new_value, orig_value);\n          strcpy (new_value + orig_value_len, add);\n        }\n      else\n        {\n          strcpy (new_value, add);\n          strcpy (new_value + add_len, orig_value);\n        }\n    }\n  else\n    {\n      new_value = xstrdup (add);\n    }\n  return new_value;\n}\n\nvoid\nlt_update_exe_path (const char *name, const char *value)\n{\n  lt_debugprintf (__FILE__, __LINE__,\n\t\t  \"(lt_update_exe_path) modifying '%s' by prepending '%s'\\n\",\n                  nonnull (name), nonnull (value));\n\n  if (name && *name && value && *value)\n    {\n      char *new_value = lt_extend_str (getenv (name), value, 0);\n      /* some systems can't cope with a ':'-terminated path #' */\n      int len = strlen (new_value);\n      while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))\n        {\n          new_value[len-1] = '\\0';\n        }\n      lt_setenv (name, new_value);\n      XFREE (new_value);\n    }\n}\n\nvoid\nlt_update_lib_path (const char *name, const char *value)\n{\n  lt_debugprintf (__FILE__, __LINE__,\n\t\t  \"(lt_update_lib_path) modifying '%s' by prepending '%s'\\n\",\n                  nonnull (name), nonnull (value));\n\n  if (name && *name && value && *value)\n    {\n      char *new_value = lt_extend_str (getenv (name), value, 0);\n      lt_setenv (name, new_value);\n      XFREE (new_value);\n    }\n}\n\nEOF\n\t    case $host_os in\n\t      mingw*)\n\t\tcat <<\"EOF\"\n\n/* Prepares an argument vector before calling spawn().\n   Note that spawn() does not by itself call the command interpreter\n     (getenv (\"COMSPEC\") != NULL ? getenv (\"COMSPEC\") :\n      ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);\n         GetVersionEx(&v);\n         v.dwPlatformId == VER_PLATFORM_WIN32_NT;\n      }) ? \"cmd.exe\" : \"command.com\").\n   Instead it simply concatenates the arguments, separated by ' ', and calls\n   CreateProcess().  We must quote the arguments since Win32 CreateProcess()\n   interprets characters like ' ', '\\t', '\\\\', '\"' (but not '<' and '>') in a\n   special way:\n   - Space and tab are interpreted as delimiters. They are not treated as\n     delimiters if they are surrounded by double quotes: \"...\".\n   - Unescaped double quotes are removed from the input. Their only effect is\n     that within double quotes, space and tab are treated like normal\n     characters.\n   - Backslashes not followed by double quotes are not special.\n   - But 2*n+1 backslashes followed by a double quote become\n     n backslashes followed by a double quote (n >= 0):\n       \\\" -> \"\n       \\\\\\\" -> \\\"\n       \\\\\\\\\\\" -> \\\\\"\n */\n#define SHELL_SPECIAL_CHARS \"\\\"\\\\ \\001\\002\\003\\004\\005\\006\\007\\010\\011\\012\\013\\014\\015\\016\\017\\020\\021\\022\\023\\024\\025\\026\\027\\030\\031\\032\\033\\034\\035\\036\\037\"\n#define SHELL_SPACE_CHARS \" \\001\\002\\003\\004\\005\\006\\007\\010\\011\\012\\013\\014\\015\\016\\017\\020\\021\\022\\023\\024\\025\\026\\027\\030\\031\\032\\033\\034\\035\\036\\037\"\nchar **\nprepare_spawn (char **argv)\n{\n  size_t argc;\n  char **new_argv;\n  size_t i;\n\n  /* Count number of arguments.  */\n  for (argc = 0; argv[argc] != NULL; argc++)\n    ;\n\n  /* Allocate new argument vector.  */\n  new_argv = XMALLOC (char *, argc + 1);\n\n  /* Put quoted arguments into the new argument vector.  */\n  for (i = 0; i < argc; i++)\n    {\n      const char *string = argv[i];\n\n      if (string[0] == '\\0')\n\tnew_argv[i] = xstrdup (\"\\\"\\\"\");\n      else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)\n\t{\n\t  int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);\n\t  size_t length;\n\t  unsigned int backslashes;\n\t  const char *s;\n\t  char *quoted_string;\n\t  char *p;\n\n\t  length = 0;\n\t  backslashes = 0;\n\t  if (quote_around)\n\t    length++;\n\t  for (s = string; *s != '\\0'; s++)\n\t    {\n\t      char c = *s;\n\t      if (c == '\"')\n\t\tlength += backslashes + 1;\n\t      length++;\n\t      if (c == '\\\\')\n\t\tbackslashes++;\n\t      else\n\t\tbackslashes = 0;\n\t    }\n\t  if (quote_around)\n\t    length += backslashes + 1;\n\n\t  quoted_string = XMALLOC (char, length + 1);\n\n\t  p = quoted_string;\n\t  backslashes = 0;\n\t  if (quote_around)\n\t    *p++ = '\"';\n\t  for (s = string; *s != '\\0'; s++)\n\t    {\n\t      char c = *s;\n\t      if (c == '\"')\n\t\t{\n\t\t  unsigned int j;\n\t\t  for (j = backslashes + 1; j > 0; j--)\n\t\t    *p++ = '\\\\';\n\t\t}\n\t      *p++ = c;\n\t      if (c == '\\\\')\n\t\tbackslashes++;\n\t      else\n\t\tbackslashes = 0;\n\t    }\n\t  if (quote_around)\n\t    {\n\t      unsigned int j;\n\t      for (j = backslashes; j > 0; j--)\n\t\t*p++ = '\\\\';\n\t      *p++ = '\"';\n\t    }\n\t  *p = '\\0';\n\n\t  new_argv[i] = quoted_string;\n\t}\n      else\n\tnew_argv[i] = (char *) string;\n    }\n  new_argv[argc] = NULL;\n\n  return new_argv;\n}\nEOF\n\t\t;;\n\t    esac\n\n            cat <<\"EOF\"\nvoid lt_dump_script (FILE* f)\n{\nEOF\n\t    func_emit_wrapper yes |\n\t      $SED -n -e '\ns/^\\(.\\{79\\}\\)\\(..*\\)/\\1\\\n\\2/\nh\ns/\\([\\\\\"]\\)/\\\\\\1/g\ns/$/\\\\n/\ns/\\([^\\n]*\\).*/  fputs (\"\\1\", f);/p\ng\nD'\n            cat <<\"EOF\"\n}\nEOF\n}\n# end: func_emit_cwrapperexe_src\n\n# func_win32_import_lib_p ARG\n# True if ARG is an import lib, as indicated by $file_magic_cmd\nfunc_win32_import_lib_p ()\n{\n    $opt_debug\n    case `eval $file_magic_cmd \\\"\\$1\\\" 2>/dev/null | $SED -e 10q` in\n    *import*) : ;;\n    *) false ;;\n    esac\n}\n\n# func_mode_link arg...\nfunc_mode_link ()\n{\n    $opt_debug\n    case $host in\n    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)\n      # It is impossible to link a dll without this setting, and\n      # we shouldn't force the makefile maintainer to figure out\n      # which system we are compiling for in order to pass an extra\n      # flag for every libtool invocation.\n      # allow_undefined=no\n\n      # FIXME: Unfortunately, there are problems with the above when trying\n      # to make a dll which has undefined symbols, in which case not\n      # even a static library is built.  For now, we need to specify\n      # -no-undefined on the libtool link line when we can be certain\n      # that all symbols are satisfied, otherwise we get a static library.\n      allow_undefined=yes\n      ;;\n    *)\n      allow_undefined=yes\n      ;;\n    esac\n    libtool_args=$nonopt\n    base_compile=\"$nonopt $@\"\n    compile_command=$nonopt\n    finalize_command=$nonopt\n\n    compile_rpath=\n    finalize_rpath=\n    compile_shlibpath=\n    finalize_shlibpath=\n    convenience=\n    old_convenience=\n    deplibs=\n    old_deplibs=\n    compiler_flags=\n    linker_flags=\n    dllsearchpath=\n    lib_search_path=`pwd`\n    inst_prefix_dir=\n    new_inherited_linker_flags=\n\n    avoid_version=no\n    bindir=\n    dlfiles=\n    dlprefiles=\n    dlself=no\n    export_dynamic=no\n    export_symbols=\n    export_symbols_regex=\n    generated=\n    libobjs=\n    ltlibs=\n    module=no\n    no_install=no\n    objs=\n    non_pic_objects=\n    precious_files_regex=\n    prefer_static_libs=no\n    preload=no\n    prev=\n    prevarg=\n    release=\n    rpath=\n    xrpath=\n    perm_rpath=\n    temp_rpath=\n    thread_safe=no\n    vinfo=\n    vinfo_number=no\n    weak_libs=\n    single_module=\"${wl}-single_module\"\n    func_infer_tag $base_compile\n\n    # We need to know -static, to get the right output filenames.\n    for arg\n    do\n      case $arg in\n      -shared)\n\ttest \"$build_libtool_libs\" != yes && \\\n\t  func_fatal_configuration \"can not build a shared library\"\n\tbuild_old_libs=no\n\tbreak\n\t;;\n      -all-static | -static | -static-libtool-libs)\n\tcase $arg in\n\t-all-static)\n\t  if test \"$build_libtool_libs\" = yes && test -z \"$link_static_flag\"; then\n\t    func_warning \"complete static linking is impossible in this configuration\"\n\t  fi\n\t  if test -n \"$link_static_flag\"; then\n\t    dlopen_self=$dlopen_self_static\n\t  fi\n\t  prefer_static_libs=yes\n\t  ;;\n\t-static)\n\t  if test -z \"$pic_flag\" && test -n \"$link_static_flag\"; then\n\t    dlopen_self=$dlopen_self_static\n\t  fi\n\t  prefer_static_libs=built\n\t  ;;\n\t-static-libtool-libs)\n\t  if test -z \"$pic_flag\" && test -n \"$link_static_flag\"; then\n\t    dlopen_self=$dlopen_self_static\n\t  fi\n\t  prefer_static_libs=yes\n\t  ;;\n\tesac\n\tbuild_libtool_libs=no\n\tbuild_old_libs=yes\n\tbreak\n\t;;\n      esac\n    done\n\n    # See if our shared archives depend on static archives.\n    test -n \"$old_archive_from_new_cmds\" && build_old_libs=yes\n\n    # Go through the arguments, transforming them on the way.\n    while test \"$#\" -gt 0; do\n      arg=\"$1\"\n      shift\n      func_quote_for_eval \"$arg\"\n      qarg=$func_quote_for_eval_unquoted_result\n      func_append libtool_args \" $func_quote_for_eval_result\"\n\n      # If the previous option needs an argument, assign it.\n      if test -n \"$prev\"; then\n\tcase $prev in\n\toutput)\n\t  func_append compile_command \" @OUTPUT@\"\n\t  func_append finalize_command \" @OUTPUT@\"\n\t  ;;\n\tesac\n\n\tcase $prev in\n\tbindir)\n\t  bindir=\"$arg\"\n\t  prev=\n\t  continue\n\t  ;;\n\tdlfiles|dlprefiles)\n\t  if test \"$preload\" = no; then\n\t    # Add the symbol object into the linking commands.\n\t    func_append compile_command \" @SYMFILE@\"\n\t    func_append finalize_command \" @SYMFILE@\"\n\t    preload=yes\n\t  fi\n\t  case $arg in\n\t  *.la | *.lo) ;;  # We handle these cases below.\n\t  force)\n\t    if test \"$dlself\" = no; then\n\t      dlself=needless\n\t      export_dynamic=yes\n\t    fi\n\t    prev=\n\t    continue\n\t    ;;\n\t  self)\n\t    if test \"$prev\" = dlprefiles; then\n\t      dlself=yes\n\t    elif test \"$prev\" = dlfiles && test \"$dlopen_self\" != yes; then\n\t      dlself=yes\n\t    else\n\t      dlself=needless\n\t      export_dynamic=yes\n\t    fi\n\t    prev=\n\t    continue\n\t    ;;\n\t  *)\n\t    if test \"$prev\" = dlfiles; then\n\t      func_append dlfiles \" $arg\"\n\t    else\n\t      func_append dlprefiles \" $arg\"\n\t    fi\n\t    prev=\n\t    continue\n\t    ;;\n\t  esac\n\t  ;;\n\texpsyms)\n\t  export_symbols=\"$arg\"\n\t  test -f \"$arg\" \\\n\t    || func_fatal_error \"symbol file \\`$arg' does not exist\"\n\t  prev=\n\t  continue\n\t  ;;\n\texpsyms_regex)\n\t  export_symbols_regex=\"$arg\"\n\t  prev=\n\t  continue\n\t  ;;\n\tframework)\n\t  case $host in\n\t    *-*-darwin*)\n\t      case \"$deplibs \" in\n\t\t*\" $qarg.ltframework \"*) ;;\n\t\t*) func_append deplibs \" $qarg.ltframework\" # this is fixed later\n\t\t   ;;\n\t      esac\n\t      ;;\n\t  esac\n\t  prev=\n\t  continue\n\t  ;;\n\tinst_prefix)\n\t  inst_prefix_dir=\"$arg\"\n\t  prev=\n\t  continue\n\t  ;;\n\tobjectlist)\n\t  if test -f \"$arg\"; then\n\t    save_arg=$arg\n\t    moreargs=\n\t    for fil in `cat \"$save_arg\"`\n\t    do\n#\t      func_append moreargs \" $fil\"\n\t      arg=$fil\n\t      # A libtool-controlled object.\n\n\t      # Check to see that this really is a libtool object.\n\t      if func_lalib_unsafe_p \"$arg\"; then\n\t\tpic_object=\n\t\tnon_pic_object=\n\n\t\t# Read the .lo file\n\t\tfunc_source \"$arg\"\n\n\t\tif test -z \"$pic_object\" ||\n\t\t   test -z \"$non_pic_object\" ||\n\t\t   test \"$pic_object\" = none &&\n\t\t   test \"$non_pic_object\" = none; then\n\t\t  func_fatal_error \"cannot find name of object for \\`$arg'\"\n\t\tfi\n\n\t\t# Extract subdirectory from the argument.\n\t\tfunc_dirname \"$arg\" \"/\" \"\"\n\t\txdir=\"$func_dirname_result\"\n\n\t\tif test \"$pic_object\" != none; then\n\t\t  # Prepend the subdirectory the object is found in.\n\t\t  pic_object=\"$xdir$pic_object\"\n\n\t\t  if test \"$prev\" = dlfiles; then\n\t\t    if test \"$build_libtool_libs\" = yes && test \"$dlopen_support\" = yes; then\n\t\t      func_append dlfiles \" $pic_object\"\n\t\t      prev=\n\t\t      continue\n\t\t    else\n\t\t      # If libtool objects are unsupported, then we need to preload.\n\t\t      prev=dlprefiles\n\t\t    fi\n\t\t  fi\n\n\t\t  # CHECK ME:  I think I busted this.  -Ossama\n\t\t  if test \"$prev\" = dlprefiles; then\n\t\t    # Preload the old-style object.\n\t\t    func_append dlprefiles \" $pic_object\"\n\t\t    prev=\n\t\t  fi\n\n\t\t  # A PIC object.\n\t\t  func_append libobjs \" $pic_object\"\n\t\t  arg=\"$pic_object\"\n\t\tfi\n\n\t\t# Non-PIC object.\n\t\tif test \"$non_pic_object\" != none; then\n\t\t  # Prepend the subdirectory the object is found in.\n\t\t  non_pic_object=\"$xdir$non_pic_object\"\n\n\t\t  # A standard non-PIC object\n\t\t  func_append non_pic_objects \" $non_pic_object\"\n\t\t  if test -z \"$pic_object\" || test \"$pic_object\" = none ; then\n\t\t    arg=\"$non_pic_object\"\n\t\t  fi\n\t\telse\n\t\t  # If the PIC object exists, use it instead.\n\t\t  # $xdir was prepended to $pic_object above.\n\t\t  non_pic_object=\"$pic_object\"\n\t\t  func_append non_pic_objects \" $non_pic_object\"\n\t\tfi\n\t      else\n\t\t# Only an error if not doing a dry-run.\n\t\tif $opt_dry_run; then\n\t\t  # Extract subdirectory from the argument.\n\t\t  func_dirname \"$arg\" \"/\" \"\"\n\t\t  xdir=\"$func_dirname_result\"\n\n\t\t  func_lo2o \"$arg\"\n\t\t  pic_object=$xdir$objdir/$func_lo2o_result\n\t\t  non_pic_object=$xdir$func_lo2o_result\n\t\t  func_append libobjs \" $pic_object\"\n\t\t  func_append non_pic_objects \" $non_pic_object\"\n\t        else\n\t\t  func_fatal_error \"\\`$arg' is not a valid libtool object\"\n\t\tfi\n\t      fi\n\t    done\n\t  else\n\t    func_fatal_error \"link input file \\`$arg' does not exist\"\n\t  fi\n\t  arg=$save_arg\n\t  prev=\n\t  continue\n\t  ;;\n\tprecious_regex)\n\t  precious_files_regex=\"$arg\"\n\t  prev=\n\t  continue\n\t  ;;\n\trelease)\n\t  release=\"-$arg\"\n\t  prev=\n\t  continue\n\t  ;;\n\trpath | xrpath)\n\t  # We need an absolute path.\n\t  case $arg in\n\t  [\\\\/]* | [A-Za-z]:[\\\\/]*) ;;\n\t  *)\n\t    func_fatal_error \"only absolute run-paths are allowed\"\n\t    ;;\n\t  esac\n\t  if test \"$prev\" = rpath; then\n\t    case \"$rpath \" in\n\t    *\" $arg \"*) ;;\n\t    *) func_append rpath \" $arg\" ;;\n\t    esac\n\t  else\n\t    case \"$xrpath \" in\n\t    *\" $arg \"*) ;;\n\t    *) func_append xrpath \" $arg\" ;;\n\t    esac\n\t  fi\n\t  prev=\n\t  continue\n\t  ;;\n\tshrext)\n\t  shrext_cmds=\"$arg\"\n\t  prev=\n\t  continue\n\t  ;;\n\tweak)\n\t  func_append weak_libs \" $arg\"\n\t  prev=\n\t  continue\n\t  ;;\n\txcclinker)\n\t  func_append linker_flags \" $qarg\"\n\t  func_append compiler_flags \" $qarg\"\n\t  prev=\n\t  func_append compile_command \" $qarg\"\n\t  func_append finalize_command \" $qarg\"\n\t  continue\n\t  ;;\n\txcompiler)\n\t  func_append compiler_flags \" $qarg\"\n\t  prev=\n\t  func_append compile_command \" $qarg\"\n\t  func_append finalize_command \" $qarg\"\n\t  continue\n\t  ;;\n\txlinker)\n\t  func_append linker_flags \" $qarg\"\n\t  func_append compiler_flags \" $wl$qarg\"\n\t  prev=\n\t  func_append compile_command \" $wl$qarg\"\n\t  func_append finalize_command \" $wl$qarg\"\n\t  continue\n\t  ;;\n\t*)\n\t  eval \"$prev=\\\"\\$arg\\\"\"\n\t  prev=\n\t  continue\n\t  ;;\n\tesac\n      fi # test -n \"$prev\"\n\n      prevarg=\"$arg\"\n\n      case $arg in\n      -all-static)\n\tif test -n \"$link_static_flag\"; then\n\t  # See comment for -static flag below, for more details.\n\t  func_append compile_command \" $link_static_flag\"\n\t  func_append finalize_command \" $link_static_flag\"\n\tfi\n\tcontinue\n\t;;\n\n      -allow-undefined)\n\t# FIXME: remove this flag sometime in the future.\n\tfunc_fatal_error \"\\`-allow-undefined' must not be used because it is the default\"\n\t;;\n\n      -avoid-version)\n\tavoid_version=yes\n\tcontinue\n\t;;\n\n      -bindir)\n\tprev=bindir\n\tcontinue\n\t;;\n\n      -dlopen)\n\tprev=dlfiles\n\tcontinue\n\t;;\n\n      -dlpreopen)\n\tprev=dlprefiles\n\tcontinue\n\t;;\n\n      -export-dynamic)\n\texport_dynamic=yes\n\tcontinue\n\t;;\n\n      -export-symbols | -export-symbols-regex)\n\tif test -n \"$export_symbols\" || test -n \"$export_symbols_regex\"; then\n\t  func_fatal_error \"more than one -exported-symbols argument is not allowed\"\n\tfi\n\tif test \"X$arg\" = \"X-export-symbols\"; then\n\t  prev=expsyms\n\telse\n\t  prev=expsyms_regex\n\tfi\n\tcontinue\n\t;;\n\n      -framework)\n\tprev=framework\n\tcontinue\n\t;;\n\n      -inst-prefix-dir)\n\tprev=inst_prefix\n\tcontinue\n\t;;\n\n      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*\n      # so, if we see these flags be careful not to treat them like -L\n      -L[A-Z][A-Z]*:*)\n\tcase $with_gcc/$host in\n\tno/*-*-irix* | /*-*-irix*)\n\t  func_append compile_command \" $arg\"\n\t  func_append finalize_command \" $arg\"\n\t  ;;\n\tesac\n\tcontinue\n\t;;\n\n      -L*)\n\tfunc_stripname \"-L\" '' \"$arg\"\n\tif test -z \"$func_stripname_result\"; then\n\t  if test \"$#\" -gt 0; then\n\t    func_fatal_error \"require no space between \\`-L' and \\`$1'\"\n\t  else\n\t    func_fatal_error \"need path for \\`-L' option\"\n\t  fi\n\tfi\n\tfunc_resolve_sysroot \"$func_stripname_result\"\n\tdir=$func_resolve_sysroot_result\n\t# We need an absolute path.\n\tcase $dir in\n\t[\\\\/]* | [A-Za-z]:[\\\\/]*) ;;\n\t*)\n\t  absdir=`cd \"$dir\" && pwd`\n\t  test -z \"$absdir\" && \\\n\t    func_fatal_error \"cannot determine absolute directory name of \\`$dir'\"\n\t  dir=\"$absdir\"\n\t  ;;\n\tesac\n\tcase \"$deplibs \" in\n\t*\" -L$dir \"* | *\" $arg \"*)\n\t  # Will only happen for absolute or sysroot arguments\n\t  ;;\n\t*)\n\t  # Preserve sysroot, but never include relative directories\n\t  case $dir in\n\t    [\\\\/]* | [A-Za-z]:[\\\\/]* | =*) func_append deplibs \" $arg\" ;;\n\t    *) func_append deplibs \" -L$dir\" ;;\n\t  esac\n\t  func_append lib_search_path \" $dir\"\n\t  ;;\n\tesac\n\tcase $host in\n\t*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)\n\t  testbindir=`$ECHO \"$dir\" | $SED 's*/lib$*/bin*'`\n\t  case :$dllsearchpath: in\n\t  *\":$dir:\"*) ;;\n\t  ::) dllsearchpath=$dir;;\n\t  *) func_append dllsearchpath \":$dir\";;\n\t  esac\n\t  case :$dllsearchpath: in\n\t  *\":$testbindir:\"*) ;;\n\t  ::) dllsearchpath=$testbindir;;\n\t  *) func_append dllsearchpath \":$testbindir\";;\n\t  esac\n\t  ;;\n\tesac\n\tcontinue\n\t;;\n\n      -l*)\n\tif test \"X$arg\" = \"X-lc\" || test \"X$arg\" = \"X-lm\"; then\n\t  case $host in\n\t  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)\n\t    # These systems don't actually have a C or math library (as such)\n\t    continue\n\t    ;;\n\t  *-*-os2*)\n\t    # These systems don't actually have a C library (as such)\n\t    test \"X$arg\" = \"X-lc\" && continue\n\t    ;;\n\t  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)\n\t    # Do not include libc due to us having libc/libc_r.\n\t    test \"X$arg\" = \"X-lc\" && continue\n\t    ;;\n\t  *-*-rhapsody* | *-*-darwin1.[012])\n\t    # Rhapsody C and math libraries are in the System framework\n\t    func_append deplibs \" System.ltframework\"\n\t    continue\n\t    ;;\n\t  *-*-sco3.2v5* | *-*-sco5v6*)\n\t    # Causes problems with __ctype\n\t    test \"X$arg\" = \"X-lc\" && continue\n\t    ;;\n\t  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)\n\t    # Compiler inserts libc in the correct place for threads to work\n\t    test \"X$arg\" = \"X-lc\" && continue\n\t    ;;\n\t  esac\n\telif test \"X$arg\" = \"X-lc_r\"; then\n\t case $host in\n\t *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)\n\t   # Do not include libc_r directly, use -pthread flag.\n\t   continue\n\t   ;;\n\t esac\n\tfi\n\tfunc_append deplibs \" $arg\"\n\tcontinue\n\t;;\n\n      -module)\n\tmodule=yes\n\tcontinue\n\t;;\n\n      # Tru64 UNIX uses -model [arg] to determine the layout of C++\n      # classes, name mangling, and exception handling.\n      # Darwin uses the -arch flag to determine output architecture.\n      -model|-arch|-isysroot|--sysroot)\n\tfunc_append compiler_flags \" $arg\"\n\tfunc_append compile_command \" $arg\"\n\tfunc_append finalize_command \" $arg\"\n\tprev=xcompiler\n\tcontinue\n\t;;\n\n      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \\\n      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)\n\tfunc_append compiler_flags \" $arg\"\n\tfunc_append compile_command \" $arg\"\n\tfunc_append finalize_command \" $arg\"\n\tcase \"$new_inherited_linker_flags \" in\n\t    *\" $arg \"*) ;;\n\t    * ) func_append new_inherited_linker_flags \" $arg\" ;;\n\tesac\n\tcontinue\n\t;;\n\n      -multi_module)\n\tsingle_module=\"${wl}-multi_module\"\n\tcontinue\n\t;;\n\n      -no-fast-install)\n\tfast_install=no\n\tcontinue\n\t;;\n\n      -no-install)\n\tcase $host in\n\t*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)\n\t  # The PATH hackery in wrapper scripts is required on Windows\n\t  # and Darwin in order for the loader to find any dlls it needs.\n\t  func_warning \"\\`-no-install' is ignored for $host\"\n\t  func_warning \"assuming \\`-no-fast-install' instead\"\n\t  fast_install=no\n\t  ;;\n\t*) no_install=yes ;;\n\tesac\n\tcontinue\n\t;;\n\n      -no-undefined)\n\tallow_undefined=no\n\tcontinue\n\t;;\n\n      -objectlist)\n\tprev=objectlist\n\tcontinue\n\t;;\n\n      -o) prev=output ;;\n\n      -precious-files-regex)\n\tprev=precious_regex\n\tcontinue\n\t;;\n\n      -release)\n\tprev=release\n\tcontinue\n\t;;\n\n      -rpath)\n\tprev=rpath\n\tcontinue\n\t;;\n\n      -R)\n\tprev=xrpath\n\tcontinue\n\t;;\n\n      -R*)\n\tfunc_stripname '-R' '' \"$arg\"\n\tdir=$func_stripname_result\n\t# We need an absolute path.\n\tcase $dir in\n\t[\\\\/]* | [A-Za-z]:[\\\\/]*) ;;\n\t=*)\n\t  func_stripname '=' '' \"$dir\"\n\t  dir=$lt_sysroot$func_stripname_result\n\t  ;;\n\t*)\n\t  func_fatal_error \"only absolute run-paths are allowed\"\n\t  ;;\n\tesac\n\tcase \"$xrpath \" in\n\t*\" $dir \"*) ;;\n\t*) func_append xrpath \" $dir\" ;;\n\tesac\n\tcontinue\n\t;;\n\n      -shared)\n\t# The effects of -shared are defined in a previous loop.\n\tcontinue\n\t;;\n\n      -shrext)\n\tprev=shrext\n\tcontinue\n\t;;\n\n      -static | -static-libtool-libs)\n\t# The effects of -static are defined in a previous loop.\n\t# We used to do the same as -all-static on platforms that\n\t# didn't have a PIC flag, but the assumption that the effects\n\t# would be equivalent was wrong.  It would break on at least\n\t# Digital Unix and AIX.\n\tcontinue\n\t;;\n\n      -thread-safe)\n\tthread_safe=yes\n\tcontinue\n\t;;\n\n      -version-info)\n\tprev=vinfo\n\tcontinue\n\t;;\n\n      -version-number)\n\tprev=vinfo\n\tvinfo_number=yes\n\tcontinue\n\t;;\n\n      -weak)\n        prev=weak\n\tcontinue\n\t;;\n\n      -Wc,*)\n\tfunc_stripname '-Wc,' '' \"$arg\"\n\targs=$func_stripname_result\n\targ=\n\tsave_ifs=\"$IFS\"; IFS=','\n\tfor flag in $args; do\n\t  IFS=\"$save_ifs\"\n          func_quote_for_eval \"$flag\"\n\t  func_append arg \" $func_quote_for_eval_result\"\n\t  func_append compiler_flags \" $func_quote_for_eval_result\"\n\tdone\n\tIFS=\"$save_ifs\"\n\tfunc_stripname ' ' '' \"$arg\"\n\targ=$func_stripname_result\n\t;;\n\n      -Wl,*)\n\tfunc_stripname '-Wl,' '' \"$arg\"\n\targs=$func_stripname_result\n\targ=\n\tsave_ifs=\"$IFS\"; IFS=','\n\tfor flag in $args; do\n\t  IFS=\"$save_ifs\"\n          func_quote_for_eval \"$flag\"\n\t  func_append arg \" $wl$func_quote_for_eval_result\"\n\t  func_append compiler_flags \" $wl$func_quote_for_eval_result\"\n\t  func_append linker_flags \" $func_quote_for_eval_result\"\n\tdone\n\tIFS=\"$save_ifs\"\n\tfunc_stripname ' ' '' \"$arg\"\n\targ=$func_stripname_result\n\t;;\n\n      -Xcompiler)\n\tprev=xcompiler\n\tcontinue\n\t;;\n\n      -Xlinker)\n\tprev=xlinker\n\tcontinue\n\t;;\n\n      -XCClinker)\n\tprev=xcclinker\n\tcontinue\n\t;;\n\n      # -msg_* for osf cc\n      -msg_*)\n\tfunc_quote_for_eval \"$arg\"\n\targ=\"$func_quote_for_eval_result\"\n\t;;\n\n      # Flags to be passed through unchanged, with rationale:\n      # -64, -mips[0-9]      enable 64-bit mode for the SGI compiler\n      # -r[0-9][0-9]*        specify processor for the SGI compiler\n      # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler\n      # +DA*, +DD*           enable 64-bit mode for the HP compiler\n      # -q*                  compiler args for the IBM compiler\n      # -m*, -t[45]*, -txscale* architecture-specific flags for GCC\n      # -F/path              path to uninstalled frameworks, gcc on darwin\n      # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC\n      # @file                GCC response files\n      # -tp=*                Portland pgcc target processor selection\n      # --sysroot=*          for sysroot support\n      # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization\n      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \\\n      -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \\\n      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)\n        func_quote_for_eval \"$arg\"\n\targ=\"$func_quote_for_eval_result\"\n        func_append compile_command \" $arg\"\n        func_append finalize_command \" $arg\"\n        func_append compiler_flags \" $arg\"\n        continue\n        ;;\n\n      # Some other compiler flag.\n      -* | +*)\n        func_quote_for_eval \"$arg\"\n\targ=\"$func_quote_for_eval_result\"\n\t;;\n\n      *.$objext)\n\t# A standard object.\n\tfunc_append objs \" $arg\"\n\t;;\n\n      *.lo)\n\t# A libtool-controlled object.\n\n\t# Check to see that this really is a libtool object.\n\tif func_lalib_unsafe_p \"$arg\"; then\n\t  pic_object=\n\t  non_pic_object=\n\n\t  # Read the .lo file\n\t  func_source \"$arg\"\n\n\t  if test -z \"$pic_object\" ||\n\t     test -z \"$non_pic_object\" ||\n\t     test \"$pic_object\" = none &&\n\t     test \"$non_pic_object\" = none; then\n\t    func_fatal_error \"cannot find name of object for \\`$arg'\"\n\t  fi\n\n\t  # Extract subdirectory from the argument.\n\t  func_dirname \"$arg\" \"/\" \"\"\n\t  xdir=\"$func_dirname_result\"\n\n\t  if test \"$pic_object\" != none; then\n\t    # Prepend the subdirectory the object is found in.\n\t    pic_object=\"$xdir$pic_object\"\n\n\t    if test \"$prev\" = dlfiles; then\n\t      if test \"$build_libtool_libs\" = yes && test \"$dlopen_support\" = yes; then\n\t\tfunc_append dlfiles \" $pic_object\"\n\t\tprev=\n\t\tcontinue\n\t      else\n\t\t# If libtool objects are unsupported, then we need to preload.\n\t\tprev=dlprefiles\n\t      fi\n\t    fi\n\n\t    # CHECK ME:  I think I busted this.  -Ossama\n\t    if test \"$prev\" = dlprefiles; then\n\t      # Preload the old-style object.\n\t      func_append dlprefiles \" $pic_object\"\n\t      prev=\n\t    fi\n\n\t    # A PIC object.\n\t    func_append libobjs \" $pic_object\"\n\t    arg=\"$pic_object\"\n\t  fi\n\n\t  # Non-PIC object.\n\t  if test \"$non_pic_object\" != none; then\n\t    # Prepend the subdirectory the object is found in.\n\t    non_pic_object=\"$xdir$non_pic_object\"\n\n\t    # A standard non-PIC object\n\t    func_append non_pic_objects \" $non_pic_object\"\n\t    if test -z \"$pic_object\" || test \"$pic_object\" = none ; then\n\t      arg=\"$non_pic_object\"\n\t    fi\n\t  else\n\t    # If the PIC object exists, use it instead.\n\t    # $xdir was prepended to $pic_object above.\n\t    non_pic_object=\"$pic_object\"\n\t    func_append non_pic_objects \" $non_pic_object\"\n\t  fi\n\telse\n\t  # Only an error if not doing a dry-run.\n\t  if $opt_dry_run; then\n\t    # Extract subdirectory from the argument.\n\t    func_dirname \"$arg\" \"/\" \"\"\n\t    xdir=\"$func_dirname_result\"\n\n\t    func_lo2o \"$arg\"\n\t    pic_object=$xdir$objdir/$func_lo2o_result\n\t    non_pic_object=$xdir$func_lo2o_result\n\t    func_append libobjs \" $pic_object\"\n\t    func_append non_pic_objects \" $non_pic_object\"\n\t  else\n\t    func_fatal_error \"\\`$arg' is not a valid libtool object\"\n\t  fi\n\tfi\n\t;;\n\n      *.$libext)\n\t# An archive.\n\tfunc_append deplibs \" $arg\"\n\tfunc_append old_deplibs \" $arg\"\n\tcontinue\n\t;;\n\n      *.la)\n\t# A libtool-controlled library.\n\n\tfunc_resolve_sysroot \"$arg\"\n\tif test \"$prev\" = dlfiles; then\n\t  # This library was specified with -dlopen.\n\t  func_append dlfiles \" $func_resolve_sysroot_result\"\n\t  prev=\n\telif test \"$prev\" = dlprefiles; then\n\t  # The library was specified with -dlpreopen.\n\t  func_append dlprefiles \" $func_resolve_sysroot_result\"\n\t  prev=\n\telse\n\t  func_append deplibs \" $func_resolve_sysroot_result\"\n\tfi\n\tcontinue\n\t;;\n\n      # Some other compiler argument.\n      *)\n\t# Unknown arguments in both finalize_command and compile_command need\n\t# to be aesthetically quoted because they are evaled later.\n\tfunc_quote_for_eval \"$arg\"\n\targ=\"$func_quote_for_eval_result\"\n\t;;\n      esac # arg\n\n      # Now actually substitute the argument into the commands.\n      if test -n \"$arg\"; then\n\tfunc_append compile_command \" $arg\"\n\tfunc_append finalize_command \" $arg\"\n      fi\n    done # argument parsing loop\n\n    test -n \"$prev\" && \\\n      func_fatal_help \"the \\`$prevarg' option requires an argument\"\n\n    if test \"$export_dynamic\" = yes && test -n \"$export_dynamic_flag_spec\"; then\n      eval arg=\\\"$export_dynamic_flag_spec\\\"\n      func_append compile_command \" $arg\"\n      func_append finalize_command \" $arg\"\n    fi\n\n    oldlibs=\n    # calculate the name of the file, without its directory\n    func_basename \"$output\"\n    outputname=\"$func_basename_result\"\n    libobjs_save=\"$libobjs\"\n\n    if test -n \"$shlibpath_var\"; then\n      # get the directories listed in $shlibpath_var\n      eval shlib_search_path=\\`\\$ECHO \\\"\\${$shlibpath_var}\\\" \\| \\$SED \\'s/:/ /g\\'\\`\n    else\n      shlib_search_path=\n    fi\n    eval sys_lib_search_path=\\\"$sys_lib_search_path_spec\\\"\n    eval sys_lib_dlsearch_path=\\\"$sys_lib_dlsearch_path_spec\\\"\n\n    func_dirname \"$output\" \"/\" \"\"\n    output_objdir=\"$func_dirname_result$objdir\"\n    func_to_tool_file \"$output_objdir/\"\n    tool_output_objdir=$func_to_tool_file_result\n    # Create the object directory.\n    func_mkdir_p \"$output_objdir\"\n\n    # Determine the type of output\n    case $output in\n    \"\")\n      func_fatal_help \"you must specify an output file\"\n      ;;\n    *.$libext) linkmode=oldlib ;;\n    *.lo | *.$objext) linkmode=obj ;;\n    *.la) linkmode=lib ;;\n    *) linkmode=prog ;; # Anything else should be a program.\n    esac\n\n    specialdeplibs=\n\n    libs=\n    # Find all interdependent deplibs by searching for libraries\n    # that are linked more than once (e.g. -la -lb -la)\n    for deplib in $deplibs; do\n      if $opt_preserve_dup_deps ; then\n\tcase \"$libs \" in\n\t*\" $deplib \"*) func_append specialdeplibs \" $deplib\" ;;\n\tesac\n      fi\n      func_append libs \" $deplib\"\n    done\n\n    if test \"$linkmode\" = lib; then\n      libs=\"$predeps $libs $compiler_lib_search_path $postdeps\"\n\n      # Compute libraries that are listed more than once in $predeps\n      # $postdeps and mark them as special (i.e., whose duplicates are\n      # not to be eliminated).\n      pre_post_deps=\n      if $opt_duplicate_compiler_generated_deps; then\n\tfor pre_post_dep in $predeps $postdeps; do\n\t  case \"$pre_post_deps \" in\n\t  *\" $pre_post_dep \"*) func_append specialdeplibs \" $pre_post_deps\" ;;\n\t  esac\n\t  func_append pre_post_deps \" $pre_post_dep\"\n\tdone\n      fi\n      pre_post_deps=\n    fi\n\n    deplibs=\n    newdependency_libs=\n    newlib_search_path=\n    need_relink=no # whether we're linking any uninstalled libtool libraries\n    notinst_deplibs= # not-installed libtool libraries\n    notinst_path= # paths that contain not-installed libtool libraries\n\n    case $linkmode in\n    lib)\n\tpasses=\"conv dlpreopen link\"\n\tfor file in $dlfiles $dlprefiles; do\n\t  case $file in\n\t  *.la) ;;\n\t  *)\n\t    func_fatal_help \"libraries can \\`-dlopen' only libtool libraries: $file\"\n\t    ;;\n\t  esac\n\tdone\n\t;;\n    prog)\n\tcompile_deplibs=\n\tfinalize_deplibs=\n\talldeplibs=no\n\tnewdlfiles=\n\tnewdlprefiles=\n\tpasses=\"conv scan dlopen dlpreopen link\"\n\t;;\n    *)  passes=\"conv\"\n\t;;\n    esac\n\n    for pass in $passes; do\n      # The preopen pass in lib mode reverses $deplibs; put it back here\n      # so that -L comes before libs that need it for instance...\n      if test \"$linkmode,$pass\" = \"lib,link\"; then\n\t## FIXME: Find the place where the list is rebuilt in the wrong\n\t##        order, and fix it there properly\n        tmp_deplibs=\n\tfor deplib in $deplibs; do\n\t  tmp_deplibs=\"$deplib $tmp_deplibs\"\n\tdone\n\tdeplibs=\"$tmp_deplibs\"\n      fi\n\n      if test \"$linkmode,$pass\" = \"lib,link\" ||\n\t test \"$linkmode,$pass\" = \"prog,scan\"; then\n\tlibs=\"$deplibs\"\n\tdeplibs=\n      fi\n      if test \"$linkmode\" = prog; then\n\tcase $pass in\n\tdlopen) libs=\"$dlfiles\" ;;\n\tdlpreopen) libs=\"$dlprefiles\" ;;\n\tlink)\n\t  libs=\"$deplibs %DEPLIBS%\"\n\t  test \"X$link_all_deplibs\" != Xno && libs=\"$libs $dependency_libs\"\n\t  ;;\n\tesac\n      fi\n      if test \"$linkmode,$pass\" = \"lib,dlpreopen\"; then\n\t# Collect and forward deplibs of preopened libtool libs\n\tfor lib in $dlprefiles; do\n\t  # Ignore non-libtool-libs\n\t  dependency_libs=\n\t  func_resolve_sysroot \"$lib\"\n\t  case $lib in\n\t  *.la)\tfunc_source \"$func_resolve_sysroot_result\" ;;\n\t  esac\n\n\t  # Collect preopened libtool deplibs, except any this library\n\t  # has declared as weak libs\n\t  for deplib in $dependency_libs; do\n\t    func_basename \"$deplib\"\n            deplib_base=$func_basename_result\n\t    case \" $weak_libs \" in\n\t    *\" $deplib_base \"*) ;;\n\t    *) func_append deplibs \" $deplib\" ;;\n\t    esac\n\t  done\n\tdone\n\tlibs=\"$dlprefiles\"\n      fi\n      if test \"$pass\" = dlopen; then\n\t# Collect dlpreopened libraries\n\tsave_deplibs=\"$deplibs\"\n\tdeplibs=\n      fi\n\n      for deplib in $libs; do\n\tlib=\n\tfound=no\n\tcase $deplib in\n\t-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \\\n        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)\n\t  if test \"$linkmode,$pass\" = \"prog,link\"; then\n\t    compile_deplibs=\"$deplib $compile_deplibs\"\n\t    finalize_deplibs=\"$deplib $finalize_deplibs\"\n\t  else\n\t    func_append compiler_flags \" $deplib\"\n\t    if test \"$linkmode\" = lib ; then\n\t\tcase \"$new_inherited_linker_flags \" in\n\t\t    *\" $deplib \"*) ;;\n\t\t    * ) func_append new_inherited_linker_flags \" $deplib\" ;;\n\t\tesac\n\t    fi\n\t  fi\n\t  continue\n\t  ;;\n\t-l*)\n\t  if test \"$linkmode\" != lib && test \"$linkmode\" != prog; then\n\t    func_warning \"\\`-l' is ignored for archives/objects\"\n\t    continue\n\t  fi\n\t  func_stripname '-l' '' \"$deplib\"\n\t  name=$func_stripname_result\n\t  if test \"$linkmode\" = lib; then\n\t    searchdirs=\"$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path\"\n\t  else\n\t    searchdirs=\"$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path\"\n\t  fi\n\t  for searchdir in $searchdirs; do\n\t    for search_ext in .la $std_shrext .so .a; do\n\t      # Search the libtool library\n\t      lib=\"$searchdir/lib${name}${search_ext}\"\n\t      if test -f \"$lib\"; then\n\t\tif test \"$search_ext\" = \".la\"; then\n\t\t  found=yes\n\t\telse\n\t\t  found=no\n\t\tfi\n\t\tbreak 2\n\t      fi\n\t    done\n\t  done\n\t  if test \"$found\" != yes; then\n\t    # deplib doesn't seem to be a libtool library\n\t    if test \"$linkmode,$pass\" = \"prog,link\"; then\n\t      compile_deplibs=\"$deplib $compile_deplibs\"\n\t      finalize_deplibs=\"$deplib $finalize_deplibs\"\n\t    else\n\t      deplibs=\"$deplib $deplibs\"\n\t      test \"$linkmode\" = lib && newdependency_libs=\"$deplib $newdependency_libs\"\n\t    fi\n\t    continue\n\t  else # deplib is a libtool library\n\t    # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,\n\t    # We need to do some special things here, and not later.\n\t    if test \"X$allow_libtool_libs_with_static_runtimes\" = \"Xyes\" ; then\n\t      case \" $predeps $postdeps \" in\n\t      *\" $deplib \"*)\n\t\tif func_lalib_p \"$lib\"; then\n\t\t  library_names=\n\t\t  old_library=\n\t\t  func_source \"$lib\"\n\t\t  for l in $old_library $library_names; do\n\t\t    ll=\"$l\"\n\t\t  done\n\t\t  if test \"X$ll\" = \"X$old_library\" ; then # only static version available\n\t\t    found=no\n\t\t    func_dirname \"$lib\" \"\" \".\"\n\t\t    ladir=\"$func_dirname_result\"\n\t\t    lib=$ladir/$old_library\n\t\t    if test \"$linkmode,$pass\" = \"prog,link\"; then\n\t\t      compile_deplibs=\"$deplib $compile_deplibs\"\n\t\t      finalize_deplibs=\"$deplib $finalize_deplibs\"\n\t\t    else\n\t\t      deplibs=\"$deplib $deplibs\"\n\t\t      test \"$linkmode\" = lib && newdependency_libs=\"$deplib $newdependency_libs\"\n\t\t    fi\n\t\t    continue\n\t\t  fi\n\t\tfi\n\t\t;;\n\t      *) ;;\n\t      esac\n\t    fi\n\t  fi\n\t  ;; # -l\n\t*.ltframework)\n\t  if test \"$linkmode,$pass\" = \"prog,link\"; then\n\t    compile_deplibs=\"$deplib $compile_deplibs\"\n\t    finalize_deplibs=\"$deplib $finalize_deplibs\"\n\t  else\n\t    deplibs=\"$deplib $deplibs\"\n\t    if test \"$linkmode\" = lib ; then\n\t\tcase \"$new_inherited_linker_flags \" in\n\t\t    *\" $deplib \"*) ;;\n\t\t    * ) func_append new_inherited_linker_flags \" $deplib\" ;;\n\t\tesac\n\t    fi\n\t  fi\n\t  continue\n\t  ;;\n\t-L*)\n\t  case $linkmode in\n\t  lib)\n\t    deplibs=\"$deplib $deplibs\"\n\t    test \"$pass\" = conv && continue\n\t    newdependency_libs=\"$deplib $newdependency_libs\"\n\t    func_stripname '-L' '' \"$deplib\"\n\t    func_resolve_sysroot \"$func_stripname_result\"\n\t    func_append newlib_search_path \" $func_resolve_sysroot_result\"\n\t    ;;\n\t  prog)\n\t    if test \"$pass\" = conv; then\n\t      deplibs=\"$deplib $deplibs\"\n\t      continue\n\t    fi\n\t    if test \"$pass\" = scan; then\n\t      deplibs=\"$deplib $deplibs\"\n\t    else\n\t      compile_deplibs=\"$deplib $compile_deplibs\"\n\t      finalize_deplibs=\"$deplib $finalize_deplibs\"\n\t    fi\n\t    func_stripname '-L' '' \"$deplib\"\n\t    func_resolve_sysroot \"$func_stripname_result\"\n\t    func_append newlib_search_path \" $func_resolve_sysroot_result\"\n\t    ;;\n\t  *)\n\t    func_warning \"\\`-L' is ignored for archives/objects\"\n\t    ;;\n\t  esac # linkmode\n\t  continue\n\t  ;; # -L\n\t-R*)\n\t  if test \"$pass\" = link; then\n\t    func_stripname '-R' '' \"$deplib\"\n\t    func_resolve_sysroot \"$func_stripname_result\"\n\t    dir=$func_resolve_sysroot_result\n\t    # Make sure the xrpath contains only unique directories.\n\t    case \"$xrpath \" in\n\t    *\" $dir \"*) ;;\n\t    *) func_append xrpath \" $dir\" ;;\n\t    esac\n\t  fi\n\t  deplibs=\"$deplib $deplibs\"\n\t  continue\n\t  ;;\n\t*.la)\n\t  func_resolve_sysroot \"$deplib\"\n\t  lib=$func_resolve_sysroot_result\n\t  ;;\n\t*.$libext)\n\t  if test \"$pass\" = conv; then\n\t    deplibs=\"$deplib $deplibs\"\n\t    continue\n\t  fi\n\t  case $linkmode in\n\t  lib)\n\t    # Linking convenience modules into shared libraries is allowed,\n\t    # but linking other static libraries is non-portable.\n\t    case \" $dlpreconveniencelibs \" in\n\t    *\" $deplib \"*) ;;\n\t    *)\n\t      valid_a_lib=no\n\t      case $deplibs_check_method in\n\t\tmatch_pattern*)\n\t\t  set dummy $deplibs_check_method; shift\n\t\t  match_pattern_regex=`expr \"$deplibs_check_method\" : \"$1 \\(.*\\)\"`\n\t\t  if eval \"\\$ECHO \\\"$deplib\\\"\" 2>/dev/null | $SED 10q \\\n\t\t    | $EGREP \"$match_pattern_regex\" > /dev/null; then\n\t\t    valid_a_lib=yes\n\t\t  fi\n\t\t;;\n\t\tpass_all)\n\t\t  valid_a_lib=yes\n\t\t;;\n\t      esac\n\t      if test \"$valid_a_lib\" != yes; then\n\t\techo\n\t\t$ECHO \"*** Warning: Trying to link with static lib archive $deplib.\"\n\t\techo \"*** I have the capability to make that library automatically link in when\"\n\t\techo \"*** you link to this library.  But I can only do this if you have a\"\n\t\techo \"*** shared version of the library, which you do not appear to have\"\n\t\techo \"*** because the file extensions .$libext of this argument makes me believe\"\n\t\techo \"*** that it is just a static archive that I should not use here.\"\n\t      else\n\t\techo\n\t\t$ECHO \"*** Warning: Linking the shared library $output against the\"\n\t\t$ECHO \"*** static library $deplib is not portable!\"\n\t\tdeplibs=\"$deplib $deplibs\"\n\t      fi\n\t      ;;\n\t    esac\n\t    continue\n\t    ;;\n\t  prog)\n\t    if test \"$pass\" != link; then\n\t      deplibs=\"$deplib $deplibs\"\n\t    else\n\t      compile_deplibs=\"$deplib $compile_deplibs\"\n\t      finalize_deplibs=\"$deplib $finalize_deplibs\"\n\t    fi\n\t    continue\n\t    ;;\n\t  esac # linkmode\n\t  ;; # *.$libext\n\t*.lo | *.$objext)\n\t  if test \"$pass\" = conv; then\n\t    deplibs=\"$deplib $deplibs\"\n\t  elif test \"$linkmode\" = prog; then\n\t    if test \"$pass\" = dlpreopen || test \"$dlopen_support\" != yes || test \"$build_libtool_libs\" = no; then\n\t      # If there is no dlopen support or we're linking statically,\n\t      # we need to preload.\n\t      func_append newdlprefiles \" $deplib\"\n\t      compile_deplibs=\"$deplib $compile_deplibs\"\n\t      finalize_deplibs=\"$deplib $finalize_deplibs\"\n\t    else\n\t      func_append newdlfiles \" $deplib\"\n\t    fi\n\t  fi\n\t  continue\n\t  ;;\n\t%DEPLIBS%)\n\t  alldeplibs=yes\n\t  continue\n\t  ;;\n\tesac # case $deplib\n\n\tif test \"$found\" = yes || test -f \"$lib\"; then :\n\telse\n\t  func_fatal_error \"cannot find the library \\`$lib' or unhandled argument \\`$deplib'\"\n\tfi\n\n\t# Check to see that this really is a libtool archive.\n\tfunc_lalib_unsafe_p \"$lib\" \\\n\t  || func_fatal_error \"\\`$lib' is not a valid libtool archive\"\n\n\tfunc_dirname \"$lib\" \"\" \".\"\n\tladir=\"$func_dirname_result\"\n\n\tdlname=\n\tdlopen=\n\tdlpreopen=\n\tlibdir=\n\tlibrary_names=\n\told_library=\n\tinherited_linker_flags=\n\t# If the library was installed with an old release of libtool,\n\t# it will not redefine variables installed, or shouldnotlink\n\tinstalled=yes\n\tshouldnotlink=no\n\tavoidtemprpath=\n\n\n\t# Read the .la file\n\tfunc_source \"$lib\"\n\n\t# Convert \"-framework foo\" to \"foo.ltframework\"\n\tif test -n \"$inherited_linker_flags\"; then\n\t  tmp_inherited_linker_flags=`$ECHO \"$inherited_linker_flags\" | $SED 's/-framework \\([^ $]*\\)/\\1.ltframework/g'`\n\t  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do\n\t    case \" $new_inherited_linker_flags \" in\n\t      *\" $tmp_inherited_linker_flag \"*) ;;\n\t      *) func_append new_inherited_linker_flags \" $tmp_inherited_linker_flag\";;\n\t    esac\n\t  done\n\tfi\n\tdependency_libs=`$ECHO \" $dependency_libs\" | $SED 's% \\([^ $]*\\).ltframework% -framework \\1%g'`\n\tif test \"$linkmode,$pass\" = \"lib,link\" ||\n\t   test \"$linkmode,$pass\" = \"prog,scan\" ||\n\t   { test \"$linkmode\" != prog && test \"$linkmode\" != lib; }; then\n\t  test -n \"$dlopen\" && func_append dlfiles \" $dlopen\"\n\t  test -n \"$dlpreopen\" && func_append dlprefiles \" $dlpreopen\"\n\tfi\n\n\tif test \"$pass\" = conv; then\n\t  # Only check for convenience libraries\n\t  deplibs=\"$lib $deplibs\"\n\t  if test -z \"$libdir\"; then\n\t    if test -z \"$old_library\"; then\n\t      func_fatal_error \"cannot find name of link library for \\`$lib'\"\n\t    fi\n\t    # It is a libtool convenience library, so add in its objects.\n\t    func_append convenience \" $ladir/$objdir/$old_library\"\n\t    func_append old_convenience \" $ladir/$objdir/$old_library\"\n\t    tmp_libs=\n\t    for deplib in $dependency_libs; do\n\t      deplibs=\"$deplib $deplibs\"\n\t      if $opt_preserve_dup_deps ; then\n\t\tcase \"$tmp_libs \" in\n\t\t*\" $deplib \"*) func_append specialdeplibs \" $deplib\" ;;\n\t\tesac\n\t      fi\n\t      func_append tmp_libs \" $deplib\"\n\t    done\n\t  elif test \"$linkmode\" != prog && test \"$linkmode\" != lib; then\n\t    func_fatal_error \"\\`$lib' is not a convenience library\"\n\t  fi\n\t  continue\n\tfi # $pass = conv\n\n\n\t# Get the name of the library we link against.\n\tlinklib=\n\tif test -n \"$old_library\" &&\n\t   { test \"$prefer_static_libs\" = yes ||\n\t     test \"$prefer_static_libs,$installed\" = \"built,no\"; }; then\n\t  linklib=$old_library\n\telse\n\t  for l in $old_library $library_names; do\n\t    linklib=\"$l\"\n\t  done\n\tfi\n\tif test -z \"$linklib\"; then\n\t  func_fatal_error \"cannot find name of link library for \\`$lib'\"\n\tfi\n\n\t# This library was specified with -dlopen.\n\tif test \"$pass\" = dlopen; then\n\t  if test -z \"$libdir\"; then\n\t    func_fatal_error \"cannot -dlopen a convenience library: \\`$lib'\"\n\t  fi\n\t  if test -z \"$dlname\" ||\n\t     test \"$dlopen_support\" != yes ||\n\t     test \"$build_libtool_libs\" = no; then\n\t    # If there is no dlname, no dlopen support or we're linking\n\t    # statically, we need to preload.  We also need to preload any\n\t    # dependent libraries so libltdl's deplib preloader doesn't\n\t    # bomb out in the load deplibs phase.\n\t    func_append dlprefiles \" $lib $dependency_libs\"\n\t  else\n\t    func_append newdlfiles \" $lib\"\n\t  fi\n\t  continue\n\tfi # $pass = dlopen\n\n\t# We need an absolute path.\n\tcase $ladir in\n\t[\\\\/]* | [A-Za-z]:[\\\\/]*) abs_ladir=\"$ladir\" ;;\n\t*)\n\t  abs_ladir=`cd \"$ladir\" && pwd`\n\t  if test -z \"$abs_ladir\"; then\n\t    func_warning \"cannot determine absolute directory name of \\`$ladir'\"\n\t    func_warning \"passing it literally to the linker, although it might fail\"\n\t    abs_ladir=\"$ladir\"\n\t  fi\n\t  ;;\n\tesac\n\tfunc_basename \"$lib\"\n\tlaname=\"$func_basename_result\"\n\n\t# Find the relevant object directory and library name.\n\tif test \"X$installed\" = Xyes; then\n\t  if test ! -f \"$lt_sysroot$libdir/$linklib\" && test -f \"$abs_ladir/$linklib\"; then\n\t    func_warning \"library \\`$lib' was moved.\"\n\t    dir=\"$ladir\"\n\t    absdir=\"$abs_ladir\"\n\t    libdir=\"$abs_ladir\"\n\t  else\n\t    dir=\"$lt_sysroot$libdir\"\n\t    absdir=\"$lt_sysroot$libdir\"\n\t  fi\n\t  test \"X$hardcode_automatic\" = Xyes && avoidtemprpath=yes\n\telse\n\t  if test ! -f \"$ladir/$objdir/$linklib\" && test -f \"$abs_ladir/$linklib\"; then\n\t    dir=\"$ladir\"\n\t    absdir=\"$abs_ladir\"\n\t    # Remove this search path later\n\t    func_append notinst_path \" $abs_ladir\"\n\t  else\n\t    dir=\"$ladir/$objdir\"\n\t    absdir=\"$abs_ladir/$objdir\"\n\t    # Remove this search path later\n\t    func_append notinst_path \" $abs_ladir\"\n\t  fi\n\tfi # $installed = yes\n\tfunc_stripname 'lib' '.la' \"$laname\"\n\tname=$func_stripname_result\n\n\t# This library was specified with -dlpreopen.\n\tif test \"$pass\" = dlpreopen; then\n\t  if test -z \"$libdir\" && test \"$linkmode\" = prog; then\n\t    func_fatal_error \"only libraries may -dlpreopen a convenience library: \\`$lib'\"\n\t  fi\n\t  case \"$host\" in\n\t    # special handling for platforms with PE-DLLs.\n\t    *cygwin* | *mingw* | *cegcc* )\n\t      # Linker will automatically link against shared library if both\n\t      # static and shared are present.  Therefore, ensure we extract\n\t      # symbols from the import library if a shared library is present\n\t      # (otherwise, the dlopen module name will be incorrect).  We do\n\t      # this by putting the import library name into $newdlprefiles.\n\t      # We recover the dlopen module name by 'saving' the la file\n\t      # name in a special purpose variable, and (later) extracting the\n\t      # dlname from the la file.\n\t      if test -n \"$dlname\"; then\n\t        func_tr_sh \"$dir/$linklib\"\n\t        eval \"libfile_$func_tr_sh_result=\\$abs_ladir/\\$laname\"\n\t        func_append newdlprefiles \" $dir/$linklib\"\n\t      else\n\t        func_append newdlprefiles \" $dir/$old_library\"\n\t        # Keep a list of preopened convenience libraries to check\n\t        # that they are being used correctly in the link pass.\n\t        test -z \"$libdir\" && \\\n\t          func_append dlpreconveniencelibs \" $dir/$old_library\"\n\t      fi\n\t    ;;\n\t    * )\n\t      # Prefer using a static library (so that no silly _DYNAMIC symbols\n\t      # are required to link).\n\t      if test -n \"$old_library\"; then\n\t        func_append newdlprefiles \" $dir/$old_library\"\n\t        # Keep a list of preopened convenience libraries to check\n\t        # that they are being used correctly in the link pass.\n\t        test -z \"$libdir\" && \\\n\t          func_append dlpreconveniencelibs \" $dir/$old_library\"\n\t      # Otherwise, use the dlname, so that lt_dlopen finds it.\n\t      elif test -n \"$dlname\"; then\n\t        func_append newdlprefiles \" $dir/$dlname\"\n\t      else\n\t        func_append newdlprefiles \" $dir/$linklib\"\n\t      fi\n\t    ;;\n\t  esac\n\tfi # $pass = dlpreopen\n\n\tif test -z \"$libdir\"; then\n\t  # Link the convenience library\n\t  if test \"$linkmode\" = lib; then\n\t    deplibs=\"$dir/$old_library $deplibs\"\n\t  elif test \"$linkmode,$pass\" = \"prog,link\"; then\n\t    compile_deplibs=\"$dir/$old_library $compile_deplibs\"\n\t    finalize_deplibs=\"$dir/$old_library $finalize_deplibs\"\n\t  else\n\t    deplibs=\"$lib $deplibs\" # used for prog,scan pass\n\t  fi\n\t  continue\n\tfi\n\n\n\tif test \"$linkmode\" = prog && test \"$pass\" != link; then\n\t  func_append newlib_search_path \" $ladir\"\n\t  deplibs=\"$lib $deplibs\"\n\n\t  linkalldeplibs=no\n\t  if test \"$link_all_deplibs\" != no || test -z \"$library_names\" ||\n\t     test \"$build_libtool_libs\" = no; then\n\t    linkalldeplibs=yes\n\t  fi\n\n\t  tmp_libs=\n\t  for deplib in $dependency_libs; do\n\t    case $deplib in\n\t    -L*) func_stripname '-L' '' \"$deplib\"\n\t         func_resolve_sysroot \"$func_stripname_result\"\n\t         func_append newlib_search_path \" $func_resolve_sysroot_result\"\n\t\t ;;\n\t    esac\n\t    # Need to link against all dependency_libs?\n\t    if test \"$linkalldeplibs\" = yes; then\n\t      deplibs=\"$deplib $deplibs\"\n\t    else\n\t      # Need to hardcode shared library paths\n\t      # or/and link against static libraries\n\t      newdependency_libs=\"$deplib $newdependency_libs\"\n\t    fi\n\t    if $opt_preserve_dup_deps ; then\n\t      case \"$tmp_libs \" in\n\t      *\" $deplib \"*) func_append specialdeplibs \" $deplib\" ;;\n\t      esac\n\t    fi\n\t    func_append tmp_libs \" $deplib\"\n\t  done # for deplib\n\t  continue\n\tfi # $linkmode = prog...\n\n\tif test \"$linkmode,$pass\" = \"prog,link\"; then\n\t  if test -n \"$library_names\" &&\n\t     { { test \"$prefer_static_libs\" = no ||\n\t         test \"$prefer_static_libs,$installed\" = \"built,yes\"; } ||\n\t       test -z \"$old_library\"; }; then\n\t    # We need to hardcode the library path\n\t    if test -n \"$shlibpath_var\" && test -z \"$avoidtemprpath\" ; then\n\t      # Make sure the rpath contains only unique directories.\n\t      case \"$temp_rpath:\" in\n\t      *\"$absdir:\"*) ;;\n\t      *) func_append temp_rpath \"$absdir:\" ;;\n\t      esac\n\t    fi\n\n\t    # Hardcode the library path.\n\t    # Skip directories that are in the system default run-time\n\t    # search path.\n\t    case \" $sys_lib_dlsearch_path \" in\n\t    *\" $absdir \"*) ;;\n\t    *)\n\t      case \"$compile_rpath \" in\n\t      *\" $absdir \"*) ;;\n\t      *) func_append compile_rpath \" $absdir\" ;;\n\t      esac\n\t      ;;\n\t    esac\n\t    case \" $sys_lib_dlsearch_path \" in\n\t    *\" $libdir \"*) ;;\n\t    *)\n\t      case \"$finalize_rpath \" in\n\t      *\" $libdir \"*) ;;\n\t      *) func_append finalize_rpath \" $libdir\" ;;\n\t      esac\n\t      ;;\n\t    esac\n\t  fi # $linkmode,$pass = prog,link...\n\n\t  if test \"$alldeplibs\" = yes &&\n\t     { test \"$deplibs_check_method\" = pass_all ||\n\t       { test \"$build_libtool_libs\" = yes &&\n\t\t test -n \"$library_names\"; }; }; then\n\t    # We only need to search for static libraries\n\t    continue\n\t  fi\n\tfi\n\n\tlink_static=no # Whether the deplib will be linked statically\n\tuse_static_libs=$prefer_static_libs\n\tif test \"$use_static_libs\" = built && test \"$installed\" = yes; then\n\t  use_static_libs=no\n\tfi\n\tif test -n \"$library_names\" &&\n\t   { test \"$use_static_libs\" = no || test -z \"$old_library\"; }; then\n\t  case $host in\n\t  *cygwin* | *mingw* | *cegcc*)\n\t      # No point in relinking DLLs because paths are not encoded\n\t      func_append notinst_deplibs \" $lib\"\n\t      need_relink=no\n\t    ;;\n\t  *)\n\t    if test \"$installed\" = no; then\n\t      func_append notinst_deplibs \" $lib\"\n\t      need_relink=yes\n\t    fi\n\t    ;;\n\t  esac\n\t  # This is a shared library\n\n\t  # Warn about portability, can't link against -module's on some\n\t  # systems (darwin).  Don't bleat about dlopened modules though!\n\t  dlopenmodule=\"\"\n\t  for dlpremoduletest in $dlprefiles; do\n\t    if test \"X$dlpremoduletest\" = \"X$lib\"; then\n\t      dlopenmodule=\"$dlpremoduletest\"\n\t      break\n\t    fi\n\t  done\n\t  if test -z \"$dlopenmodule\" && test \"$shouldnotlink\" = yes && test \"$pass\" = link; then\n\t    echo\n\t    if test \"$linkmode\" = prog; then\n\t      $ECHO \"*** Warning: Linking the executable $output against the loadable module\"\n\t    else\n\t      $ECHO \"*** Warning: Linking the shared library $output against the loadable module\"\n\t    fi\n\t    $ECHO \"*** $linklib is not portable!\"\n\t  fi\n\t  if test \"$linkmode\" = lib &&\n\t     test \"$hardcode_into_libs\" = yes; then\n\t    # Hardcode the library path.\n\t    # Skip directories that are in the system default run-time\n\t    # search path.\n\t    case \" $sys_lib_dlsearch_path \" in\n\t    *\" $absdir \"*) ;;\n\t    *)\n\t      case \"$compile_rpath \" in\n\t      *\" $absdir \"*) ;;\n\t      *) func_append compile_rpath \" $absdir\" ;;\n\t      esac\n\t      ;;\n\t    esac\n\t    case \" $sys_lib_dlsearch_path \" in\n\t    *\" $libdir \"*) ;;\n\t    *)\n\t      case \"$finalize_rpath \" in\n\t      *\" $libdir \"*) ;;\n\t      *) func_append finalize_rpath \" $libdir\" ;;\n\t      esac\n\t      ;;\n\t    esac\n\t  fi\n\n\t  if test -n \"$old_archive_from_expsyms_cmds\"; then\n\t    # figure out the soname\n\t    set dummy $library_names\n\t    shift\n\t    realname=\"$1\"\n\t    shift\n\t    libname=`eval \"\\\\$ECHO \\\"$libname_spec\\\"\"`\n\t    # use dlname if we got it. it's perfectly good, no?\n\t    if test -n \"$dlname\"; then\n\t      soname=\"$dlname\"\n\t    elif test -n \"$soname_spec\"; then\n\t      # bleh windows\n\t      case $host in\n\t      *cygwin* | mingw* | *cegcc*)\n\t        func_arith $current - $age\n\t\tmajor=$func_arith_result\n\t\tversuffix=\"-$major\"\n\t\t;;\n\t      esac\n\t      eval soname=\\\"$soname_spec\\\"\n\t    else\n\t      soname=\"$realname\"\n\t    fi\n\n\t    # Make a new name for the extract_expsyms_cmds to use\n\t    soroot=\"$soname\"\n\t    func_basename \"$soroot\"\n\t    soname=\"$func_basename_result\"\n\t    func_stripname 'lib' '.dll' \"$soname\"\n\t    newlib=libimp-$func_stripname_result.a\n\n\t    # If the library has no export list, then create one now\n\t    if test -f \"$output_objdir/$soname-def\"; then :\n\t    else\n\t      func_verbose \"extracting exported symbol list from \\`$soname'\"\n\t      func_execute_cmds \"$extract_expsyms_cmds\" 'exit $?'\n\t    fi\n\n\t    # Create $newlib\n\t    if test -f \"$output_objdir/$newlib\"; then :; else\n\t      func_verbose \"generating import library for \\`$soname'\"\n\t      func_execute_cmds \"$old_archive_from_expsyms_cmds\" 'exit $?'\n\t    fi\n\t    # make sure the library variables are pointing to the new library\n\t    dir=$output_objdir\n\t    linklib=$newlib\n\t  fi # test -n \"$old_archive_from_expsyms_cmds\"\n\n\t  if test \"$linkmode\" = prog || test \"$opt_mode\" != relink; then\n\t    add_shlibpath=\n\t    add_dir=\n\t    add=\n\t    lib_linked=yes\n\t    case $hardcode_action in\n\t    immediate | unsupported)\n\t      if test \"$hardcode_direct\" = no; then\n\t\tadd=\"$dir/$linklib\"\n\t\tcase $host in\n\t\t  *-*-sco3.2v5.0.[024]*) add_dir=\"-L$dir\" ;;\n\t\t  *-*-sysv4*uw2*) add_dir=\"-L$dir\" ;;\n\t\t  *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \\\n\t\t    *-*-unixware7*) add_dir=\"-L$dir\" ;;\n\t\t  *-*-darwin* )\n\t\t    # if the lib is a (non-dlopened) module then we can not\n\t\t    # link against it, someone is ignoring the earlier warnings\n\t\t    if /usr/bin/file -L $add 2> /dev/null |\n\t\t\t $GREP \": [^:]* bundle\" >/dev/null ; then\n\t\t      if test \"X$dlopenmodule\" != \"X$lib\"; then\n\t\t\t$ECHO \"*** Warning: lib $linklib is a module, not a shared library\"\n\t\t\tif test -z \"$old_library\" ; then\n\t\t\t  echo\n\t\t\t  echo \"*** And there doesn't seem to be a static archive available\"\n\t\t\t  echo \"*** The link will probably fail, sorry\"\n\t\t\telse\n\t\t\t  add=\"$dir/$old_library\"\n\t\t\tfi\n\t\t      elif test -n \"$old_library\"; then\n\t\t\tadd=\"$dir/$old_library\"\n\t\t      fi\n\t\t    fi\n\t\tesac\n\t      elif test \"$hardcode_minus_L\" = no; then\n\t\tcase $host in\n\t\t*-*-sunos*) add_shlibpath=\"$dir\" ;;\n\t\tesac\n\t\tadd_dir=\"-L$dir\"\n\t\tadd=\"-l$name\"\n\t      elif test \"$hardcode_shlibpath_var\" = no; then\n\t\tadd_shlibpath=\"$dir\"\n\t\tadd=\"-l$name\"\n\t      else\n\t\tlib_linked=no\n\t      fi\n\t      ;;\n\t    relink)\n\t      if test \"$hardcode_direct\" = yes &&\n\t         test \"$hardcode_direct_absolute\" = no; then\n\t\tadd=\"$dir/$linklib\"\n\t      elif test \"$hardcode_minus_L\" = yes; then\n\t\tadd_dir=\"-L$absdir\"\n\t\t# Try looking first in the location we're being installed to.\n\t\tif test -n \"$inst_prefix_dir\"; then\n\t\t  case $libdir in\n\t\t    [\\\\/]*)\n\t\t      func_append add_dir \" -L$inst_prefix_dir$libdir\"\n\t\t      ;;\n\t\t  esac\n\t\tfi\n\t\tadd=\"-l$name\"\n\t      elif test \"$hardcode_shlibpath_var\" = yes; then\n\t\tadd_shlibpath=\"$dir\"\n\t\tadd=\"-l$name\"\n\t      else\n\t\tlib_linked=no\n\t      fi\n\t      ;;\n\t    *) lib_linked=no ;;\n\t    esac\n\n\t    if test \"$lib_linked\" != yes; then\n\t      func_fatal_configuration \"unsupported hardcode properties\"\n\t    fi\n\n\t    if test -n \"$add_shlibpath\"; then\n\t      case :$compile_shlibpath: in\n\t      *\":$add_shlibpath:\"*) ;;\n\t      *) func_append compile_shlibpath \"$add_shlibpath:\" ;;\n\t      esac\n\t    fi\n\t    if test \"$linkmode\" = prog; then\n\t      test -n \"$add_dir\" && compile_deplibs=\"$add_dir $compile_deplibs\"\n\t      test -n \"$add\" && compile_deplibs=\"$add $compile_deplibs\"\n\t    else\n\t      test -n \"$add_dir\" && deplibs=\"$add_dir $deplibs\"\n\t      test -n \"$add\" && deplibs=\"$add $deplibs\"\n\t      if test \"$hardcode_direct\" != yes &&\n\t\t test \"$hardcode_minus_L\" != yes &&\n\t\t test \"$hardcode_shlibpath_var\" = yes; then\n\t\tcase :$finalize_shlibpath: in\n\t\t*\":$libdir:\"*) ;;\n\t\t*) func_append finalize_shlibpath \"$libdir:\" ;;\n\t\tesac\n\t      fi\n\t    fi\n\t  fi\n\n\t  if test \"$linkmode\" = prog || test \"$opt_mode\" = relink; then\n\t    add_shlibpath=\n\t    add_dir=\n\t    add=\n\t    # Finalize command for both is simple: just hardcode it.\n\t    if test \"$hardcode_direct\" = yes &&\n\t       test \"$hardcode_direct_absolute\" = no; then\n\t      add=\"$libdir/$linklib\"\n\t    elif test \"$hardcode_minus_L\" = yes; then\n\t      add_dir=\"-L$libdir\"\n\t      add=\"-l$name\"\n\t    elif test \"$hardcode_shlibpath_var\" = yes; then\n\t      case :$finalize_shlibpath: in\n\t      *\":$libdir:\"*) ;;\n\t      *) func_append finalize_shlibpath \"$libdir:\" ;;\n\t      esac\n\t      add=\"-l$name\"\n\t    elif test \"$hardcode_automatic\" = yes; then\n\t      if test -n \"$inst_prefix_dir\" &&\n\t\t test -f \"$inst_prefix_dir$libdir/$linklib\" ; then\n\t\tadd=\"$inst_prefix_dir$libdir/$linklib\"\n\t      else\n\t\tadd=\"$libdir/$linklib\"\n\t      fi\n\t    else\n\t      # We cannot seem to hardcode it, guess we'll fake it.\n\t      add_dir=\"-L$libdir\"\n\t      # Try looking first in the location we're being installed to.\n\t      if test -n \"$inst_prefix_dir\"; then\n\t\tcase $libdir in\n\t\t  [\\\\/]*)\n\t\t    func_append add_dir \" -L$inst_prefix_dir$libdir\"\n\t\t    ;;\n\t\tesac\n\t      fi\n\t      add=\"-l$name\"\n\t    fi\n\n\t    if test \"$linkmode\" = prog; then\n\t      test -n \"$add_dir\" && finalize_deplibs=\"$add_dir $finalize_deplibs\"\n\t      test -n \"$add\" && finalize_deplibs=\"$add $finalize_deplibs\"\n\t    else\n\t      test -n \"$add_dir\" && deplibs=\"$add_dir $deplibs\"\n\t      test -n \"$add\" && deplibs=\"$add $deplibs\"\n\t    fi\n\t  fi\n\telif test \"$linkmode\" = prog; then\n\t  # Here we assume that one of hardcode_direct or hardcode_minus_L\n\t  # is not unsupported.  This is valid on all known static and\n\t  # shared platforms.\n\t  if test \"$hardcode_direct\" != unsupported; then\n\t    test -n \"$old_library\" && linklib=\"$old_library\"\n\t    compile_deplibs=\"$dir/$linklib $compile_deplibs\"\n\t    finalize_deplibs=\"$dir/$linklib $finalize_deplibs\"\n\t  else\n\t    compile_deplibs=\"-l$name -L$dir $compile_deplibs\"\n\t    finalize_deplibs=\"-l$name -L$dir $finalize_deplibs\"\n\t  fi\n\telif test \"$build_libtool_libs\" = yes; then\n\t  # Not a shared library\n\t  if test \"$deplibs_check_method\" != pass_all; then\n\t    # We're trying link a shared library against a static one\n\t    # but the system doesn't support it.\n\n\t    # Just print a warning and add the library to dependency_libs so\n\t    # that the program can be linked against the static library.\n\t    echo\n\t    $ECHO \"*** Warning: This system can not link to static lib archive $lib.\"\n\t    echo \"*** I have the capability to make that library automatically link in when\"\n\t    echo \"*** you link to this library.  But I can only do this if you have a\"\n\t    echo \"*** shared version of the library, which you do not appear to have.\"\n\t    if test \"$module\" = yes; then\n\t      echo \"*** But as you try to build a module library, libtool will still create \"\n\t      echo \"*** a static module, that should work as long as the dlopening application\"\n\t      echo \"*** is linked with the -dlopen flag to resolve symbols at runtime.\"\n\t      if test -z \"$global_symbol_pipe\"; then\n\t\techo\n\t\techo \"*** However, this would only work if libtool was able to extract symbol\"\n\t\techo \"*** lists from a program, using \\`nm' or equivalent, but libtool could\"\n\t\techo \"*** not find such a program.  So, this module is probably useless.\"\n\t\techo \"*** \\`nm' from GNU binutils and a full rebuild may help.\"\n\t      fi\n\t      if test \"$build_old_libs\" = no; then\n\t\tbuild_libtool_libs=module\n\t\tbuild_old_libs=yes\n\t      else\n\t\tbuild_libtool_libs=no\n\t      fi\n\t    fi\n\t  else\n\t    deplibs=\"$dir/$old_library $deplibs\"\n\t    link_static=yes\n\t  fi\n\tfi # link shared/static library?\n\n\tif test \"$linkmode\" = lib; then\n\t  if test -n \"$dependency_libs\" &&\n\t     { test \"$hardcode_into_libs\" != yes ||\n\t       test \"$build_old_libs\" = yes ||\n\t       test \"$link_static\" = yes; }; then\n\t    # Extract -R from dependency_libs\n\t    temp_deplibs=\n\t    for libdir in $dependency_libs; do\n\t      case $libdir in\n\t      -R*) func_stripname '-R' '' \"$libdir\"\n\t           temp_xrpath=$func_stripname_result\n\t\t   case \" $xrpath \" in\n\t\t   *\" $temp_xrpath \"*) ;;\n\t\t   *) func_append xrpath \" $temp_xrpath\";;\n\t\t   esac;;\n\t      *) func_append temp_deplibs \" $libdir\";;\n\t      esac\n\t    done\n\t    dependency_libs=\"$temp_deplibs\"\n\t  fi\n\n\t  func_append newlib_search_path \" $absdir\"\n\t  # Link against this library\n\t  test \"$link_static\" = no && newdependency_libs=\"$abs_ladir/$laname $newdependency_libs\"\n\t  # ... and its dependency_libs\n\t  tmp_libs=\n\t  for deplib in $dependency_libs; do\n\t    newdependency_libs=\"$deplib $newdependency_libs\"\n\t    case $deplib in\n              -L*) func_stripname '-L' '' \"$deplib\"\n                   func_resolve_sysroot \"$func_stripname_result\";;\n              *) func_resolve_sysroot \"$deplib\" ;;\n            esac\n\t    if $opt_preserve_dup_deps ; then\n\t      case \"$tmp_libs \" in\n\t      *\" $func_resolve_sysroot_result \"*)\n                func_append specialdeplibs \" $func_resolve_sysroot_result\" ;;\n\t      esac\n\t    fi\n\t    func_append tmp_libs \" $func_resolve_sysroot_result\"\n\t  done\n\n\t  if test \"$link_all_deplibs\" != no; then\n\t    # Add the search paths of all dependency libraries\n\t    for deplib in $dependency_libs; do\n\t      path=\n\t      case $deplib in\n\t      -L*) path=\"$deplib\" ;;\n\t      *.la)\n\t        func_resolve_sysroot \"$deplib\"\n\t        deplib=$func_resolve_sysroot_result\n\t        func_dirname \"$deplib\" \"\" \".\"\n\t\tdir=$func_dirname_result\n\t\t# We need an absolute path.\n\t\tcase $dir in\n\t\t[\\\\/]* | [A-Za-z]:[\\\\/]*) absdir=\"$dir\" ;;\n\t\t*)\n\t\t  absdir=`cd \"$dir\" && pwd`\n\t\t  if test -z \"$absdir\"; then\n\t\t    func_warning \"cannot determine absolute directory name of \\`$dir'\"\n\t\t    absdir=\"$dir\"\n\t\t  fi\n\t\t  ;;\n\t\tesac\n\t\tif $GREP \"^installed=no\" $deplib > /dev/null; then\n\t\tcase $host in\n\t\t*-*-darwin*)\n\t\t  depdepl=\n\t\t  eval deplibrary_names=`${SED} -n -e 's/^library_names=\\(.*\\)$/\\1/p' $deplib`\n\t\t  if test -n \"$deplibrary_names\" ; then\n\t\t    for tmp in $deplibrary_names ; do\n\t\t      depdepl=$tmp\n\t\t    done\n\t\t    if test -f \"$absdir/$objdir/$depdepl\" ; then\n\t\t      depdepl=\"$absdir/$objdir/$depdepl\"\n\t\t      darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`\n                      if test -z \"$darwin_install_name\"; then\n                          darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`\n                      fi\n\t\t      func_append compiler_flags \" ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}\"\n\t\t      func_append linker_flags \" -dylib_file ${darwin_install_name}:${depdepl}\"\n\t\t      path=\n\t\t    fi\n\t\t  fi\n\t\t  ;;\n\t\t*)\n\t\t  path=\"-L$absdir/$objdir\"\n\t\t  ;;\n\t\tesac\n\t\telse\n\t\t  eval libdir=`${SED} -n -e 's/^libdir=\\(.*\\)$/\\1/p' $deplib`\n\t\t  test -z \"$libdir\" && \\\n\t\t    func_fatal_error \"\\`$deplib' is not a valid libtool archive\"\n\t\t  test \"$absdir\" != \"$libdir\" && \\\n\t\t    func_warning \"\\`$deplib' seems to be moved\"\n\n\t\t  path=\"-L$absdir\"\n\t\tfi\n\t\t;;\n\t      esac\n\t      case \" $deplibs \" in\n\t      *\" $path \"*) ;;\n\t      *) deplibs=\"$path $deplibs\" ;;\n\t      esac\n\t    done\n\t  fi # link_all_deplibs != no\n\tfi # linkmode = lib\n      done # for deplib in $libs\n      if test \"$pass\" = link; then\n\tif test \"$linkmode\" = \"prog\"; then\n\t  compile_deplibs=\"$new_inherited_linker_flags $compile_deplibs\"\n\t  finalize_deplibs=\"$new_inherited_linker_flags $finalize_deplibs\"\n\telse\n\t  compiler_flags=\"$compiler_flags \"`$ECHO \" $new_inherited_linker_flags\" | $SED 's% \\([^ $]*\\).ltframework% -framework \\1%g'`\n\tfi\n      fi\n      dependency_libs=\"$newdependency_libs\"\n      if test \"$pass\" = dlpreopen; then\n\t# Link the dlpreopened libraries before other libraries\n\tfor deplib in $save_deplibs; do\n\t  deplibs=\"$deplib $deplibs\"\n\tdone\n      fi\n      if test \"$pass\" != dlopen; then\n\tif test \"$pass\" != conv; then\n\t  # Make sure lib_search_path contains only unique directories.\n\t  lib_search_path=\n\t  for dir in $newlib_search_path; do\n\t    case \"$lib_search_path \" in\n\t    *\" $dir \"*) ;;\n\t    *) func_append lib_search_path \" $dir\" ;;\n\t    esac\n\t  done\n\t  newlib_search_path=\n\tfi\n\n\tif test \"$linkmode,$pass\" != \"prog,link\"; then\n\t  vars=\"deplibs\"\n\telse\n\t  vars=\"compile_deplibs finalize_deplibs\"\n\tfi\n\tfor var in $vars dependency_libs; do\n\t  # Add libraries to $var in reverse order\n\t  eval tmp_libs=\\\"\\$$var\\\"\n\t  new_libs=\n\t  for deplib in $tmp_libs; do\n\t    # FIXME: Pedantically, this is the right thing to do, so\n\t    #        that some nasty dependency loop isn't accidentally\n\t    #        broken:\n\t    #new_libs=\"$deplib $new_libs\"\n\t    # Pragmatically, this seems to cause very few problems in\n\t    # practice:\n\t    case $deplib in\n\t    -L*) new_libs=\"$deplib $new_libs\" ;;\n\t    -R*) ;;\n\t    *)\n\t      # And here is the reason: when a library appears more\n\t      # than once as an explicit dependence of a library, or\n\t      # is implicitly linked in more than once by the\n\t      # compiler, it is considered special, and multiple\n\t      # occurrences thereof are not removed.  Compare this\n\t      # with having the same library being listed as a\n\t      # dependency of multiple other libraries: in this case,\n\t      # we know (pedantically, we assume) the library does not\n\t      # need to be listed more than once, so we keep only the\n\t      # last copy.  This is not always right, but it is rare\n\t      # enough that we require users that really mean to play\n\t      # such unportable linking tricks to link the library\n\t      # using -Wl,-lname, so that libtool does not consider it\n\t      # for duplicate removal.\n\t      case \" $specialdeplibs \" in\n\t      *\" $deplib \"*) new_libs=\"$deplib $new_libs\" ;;\n\t      *)\n\t\tcase \" $new_libs \" in\n\t\t*\" $deplib \"*) ;;\n\t\t*) new_libs=\"$deplib $new_libs\" ;;\n\t\tesac\n\t\t;;\n\t      esac\n\t      ;;\n\t    esac\n\t  done\n\t  tmp_libs=\n\t  for deplib in $new_libs; do\n\t    case $deplib in\n\t    -L*)\n\t      case \" $tmp_libs \" in\n\t      *\" $deplib \"*) ;;\n\t      *) func_append tmp_libs \" $deplib\" ;;\n\t      esac\n\t      ;;\n\t    *) func_append tmp_libs \" $deplib\" ;;\n\t    esac\n\t  done\n\t  eval $var=\\\"$tmp_libs\\\"\n\tdone # for var\n      fi\n      # Last step: remove runtime libs from dependency_libs\n      # (they stay in deplibs)\n      tmp_libs=\n      for i in $dependency_libs ; do\n\tcase \" $predeps $postdeps $compiler_lib_search_path \" in\n\t*\" $i \"*)\n\t  i=\"\"\n\t  ;;\n\tesac\n\tif test -n \"$i\" ; then\n\t  func_append tmp_libs \" $i\"\n\tfi\n      done\n      dependency_libs=$tmp_libs\n    done # for pass\n    if test \"$linkmode\" = prog; then\n      dlfiles=\"$newdlfiles\"\n    fi\n    if test \"$linkmode\" = prog || test \"$linkmode\" = lib; then\n      dlprefiles=\"$newdlprefiles\"\n    fi\n\n    case $linkmode in\n    oldlib)\n      if test -n \"$dlfiles$dlprefiles\" || test \"$dlself\" != no; then\n\tfunc_warning \"\\`-dlopen' is ignored for archives\"\n      fi\n\n      case \" $deplibs\" in\n      *\\ -l* | *\\ -L*)\n\tfunc_warning \"\\`-l' and \\`-L' are ignored for archives\" ;;\n      esac\n\n      test -n \"$rpath\" && \\\n\tfunc_warning \"\\`-rpath' is ignored for archives\"\n\n      test -n \"$xrpath\" && \\\n\tfunc_warning \"\\`-R' is ignored for archives\"\n\n      test -n \"$vinfo\" && \\\n\tfunc_warning \"\\`-version-info/-version-number' is ignored for archives\"\n\n      test -n \"$release\" && \\\n\tfunc_warning \"\\`-release' is ignored for archives\"\n\n      test -n \"$export_symbols$export_symbols_regex\" && \\\n\tfunc_warning \"\\`-export-symbols' is ignored for archives\"\n\n      # Now set the variables for building old libraries.\n      build_libtool_libs=no\n      oldlibs=\"$output\"\n      func_append objs \"$old_deplibs\"\n      ;;\n\n    lib)\n      # Make sure we only generate libraries of the form `libNAME.la'.\n      case $outputname in\n      lib*)\n\tfunc_stripname 'lib' '.la' \"$outputname\"\n\tname=$func_stripname_result\n\teval shared_ext=\\\"$shrext_cmds\\\"\n\teval libname=\\\"$libname_spec\\\"\n\t;;\n      *)\n\ttest \"$module\" = no && \\\n\t  func_fatal_help \"libtool library \\`$output' must begin with \\`lib'\"\n\n\tif test \"$need_lib_prefix\" != no; then\n\t  # Add the \"lib\" prefix for modules if required\n\t  func_stripname '' '.la' \"$outputname\"\n\t  name=$func_stripname_result\n\t  eval shared_ext=\\\"$shrext_cmds\\\"\n\t  eval libname=\\\"$libname_spec\\\"\n\telse\n\t  func_stripname '' '.la' \"$outputname\"\n\t  libname=$func_stripname_result\n\tfi\n\t;;\n      esac\n\n      if test -n \"$objs\"; then\n\tif test \"$deplibs_check_method\" != pass_all; then\n\t  func_fatal_error \"cannot build libtool library \\`$output' from non-libtool objects on this host:$objs\"\n\telse\n\t  echo\n\t  $ECHO \"*** Warning: Linking the shared library $output against the non-libtool\"\n\t  $ECHO \"*** objects $objs is not portable!\"\n\t  func_append libobjs \" $objs\"\n\tfi\n      fi\n\n      test \"$dlself\" != no && \\\n\tfunc_warning \"\\`-dlopen self' is ignored for libtool libraries\"\n\n      set dummy $rpath\n      shift\n      test \"$#\" -gt 1 && \\\n\tfunc_warning \"ignoring multiple \\`-rpath's for a libtool library\"\n\n      install_libdir=\"$1\"\n\n      oldlibs=\n      if test -z \"$rpath\"; then\n\tif test \"$build_libtool_libs\" = yes; then\n\t  # Building a libtool convenience library.\n\t  # Some compilers have problems with a `.al' extension so\n\t  # convenience libraries should have the same extension an\n\t  # archive normally would.\n\t  oldlibs=\"$output_objdir/$libname.$libext $oldlibs\"\n\t  build_libtool_libs=convenience\n\t  build_old_libs=yes\n\tfi\n\n\ttest -n \"$vinfo\" && \\\n\t  func_warning \"\\`-version-info/-version-number' is ignored for convenience libraries\"\n\n\ttest -n \"$release\" && \\\n\t  func_warning \"\\`-release' is ignored for convenience libraries\"\n      else\n\n\t# Parse the version information argument.\n\tsave_ifs=\"$IFS\"; IFS=':'\n\tset dummy $vinfo 0 0 0\n\tshift\n\tIFS=\"$save_ifs\"\n\n\ttest -n \"$7\" && \\\n\t  func_fatal_help \"too many parameters to \\`-version-info'\"\n\n\t# convert absolute version numbers to libtool ages\n\t# this retains compatibility with .la files and attempts\n\t# to make the code below a bit more comprehensible\n\n\tcase $vinfo_number in\n\tyes)\n\t  number_major=\"$1\"\n\t  number_minor=\"$2\"\n\t  number_revision=\"$3\"\n\t  #\n\t  # There are really only two kinds -- those that\n\t  # use the current revision as the major version\n\t  # and those that subtract age and use age as\n\t  # a minor version.  But, then there is irix\n\t  # which has an extra 1 added just for fun\n\t  #\n\t  case $version_type in\n\t  # correct linux to gnu/linux during the next big refactor\n\t  darwin|linux|osf|windows|none)\n\t    func_arith $number_major + $number_minor\n\t    current=$func_arith_result\n\t    age=\"$number_minor\"\n\t    revision=\"$number_revision\"\n\t    ;;\n\t  freebsd-aout|freebsd-elf|qnx|sunos)\n\t    current=\"$number_major\"\n\t    revision=\"$number_minor\"\n\t    age=\"0\"\n\t    ;;\n\t  irix|nonstopux)\n\t    func_arith $number_major + $number_minor\n\t    current=$func_arith_result\n\t    age=\"$number_minor\"\n\t    revision=\"$number_minor\"\n\t    lt_irix_increment=no\n\t    ;;\n\t  *)\n\t    func_fatal_configuration \"$modename: unknown library version type \\`$version_type'\"\n\t    ;;\n\t  esac\n\t  ;;\n\tno)\n\t  current=\"$1\"\n\t  revision=\"$2\"\n\t  age=\"$3\"\n\t  ;;\n\tesac\n\n\t# Check that each of the things are valid numbers.\n\tcase $current in\n\t0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;\n\t*)\n\t  func_error \"CURRENT \\`$current' must be a nonnegative integer\"\n\t  func_fatal_error \"\\`$vinfo' is not valid version information\"\n\t  ;;\n\tesac\n\n\tcase $revision in\n\t0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;\n\t*)\n\t  func_error \"REVISION \\`$revision' must be a nonnegative integer\"\n\t  func_fatal_error \"\\`$vinfo' is not valid version information\"\n\t  ;;\n\tesac\n\n\tcase $age in\n\t0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;\n\t*)\n\t  func_error \"AGE \\`$age' must be a nonnegative integer\"\n\t  func_fatal_error \"\\`$vinfo' is not valid version information\"\n\t  ;;\n\tesac\n\n\tif test \"$age\" -gt \"$current\"; then\n\t  func_error \"AGE \\`$age' is greater than the current interface number \\`$current'\"\n\t  func_fatal_error \"\\`$vinfo' is not valid version information\"\n\tfi\n\n\t# Calculate the version variables.\n\tmajor=\n\tversuffix=\n\tverstring=\n\tcase $version_type in\n\tnone) ;;\n\n\tdarwin)\n\t  # Like Linux, but with the current version available in\n\t  # verstring for coding it into the library header\n\t  func_arith $current - $age\n\t  major=.$func_arith_result\n\t  versuffix=\"$major.$age.$revision\"\n\t  # Darwin ld doesn't like 0 for these options...\n\t  func_arith $current + 1\n\t  minor_current=$func_arith_result\n\t  xlcverstring=\"${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision\"\n\t  verstring=\"-compatibility_version $minor_current -current_version $minor_current.$revision\"\n\t  ;;\n\n\tfreebsd-aout)\n\t  major=\".$current\"\n\t  versuffix=\".$current.$revision\";\n\t  ;;\n\n\tfreebsd-elf)\n\t  major=\".$current\"\n\t  versuffix=\".$current\"\n\t  ;;\n\n\tirix | nonstopux)\n\t  if test \"X$lt_irix_increment\" = \"Xno\"; then\n\t    func_arith $current - $age\n\t  else\n\t    func_arith $current - $age + 1\n\t  fi\n\t  major=$func_arith_result\n\n\t  case $version_type in\n\t    nonstopux) verstring_prefix=nonstopux ;;\n\t    *)         verstring_prefix=sgi ;;\n\t  esac\n\t  verstring=\"$verstring_prefix$major.$revision\"\n\n\t  # Add in all the interfaces that we are compatible with.\n\t  loop=$revision\n\t  while test \"$loop\" -ne 0; do\n\t    func_arith $revision - $loop\n\t    iface=$func_arith_result\n\t    func_arith $loop - 1\n\t    loop=$func_arith_result\n\t    verstring=\"$verstring_prefix$major.$iface:$verstring\"\n\t  done\n\n\t  # Before this point, $major must not contain `.'.\n\t  major=.$major\n\t  versuffix=\"$major.$revision\"\n\t  ;;\n\n\tlinux) # correct to gnu/linux during the next big refactor\n\t  func_arith $current - $age\n\t  major=.$func_arith_result\n\t  versuffix=\"$major.$age.$revision\"\n\t  ;;\n\n\tosf)\n\t  func_arith $current - $age\n\t  major=.$func_arith_result\n\t  versuffix=\".$current.$age.$revision\"\n\t  verstring=\"$current.$age.$revision\"\n\n\t  # Add in all the interfaces that we are compatible with.\n\t  loop=$age\n\t  while test \"$loop\" -ne 0; do\n\t    func_arith $current - $loop\n\t    iface=$func_arith_result\n\t    func_arith $loop - 1\n\t    loop=$func_arith_result\n\t    verstring=\"$verstring:${iface}.0\"\n\t  done\n\n\t  # Make executables depend on our current version.\n\t  func_append verstring \":${current}.0\"\n\t  ;;\n\n\tqnx)\n\t  major=\".$current\"\n\t  versuffix=\".$current\"\n\t  ;;\n\n\tsunos)\n\t  major=\".$current\"\n\t  versuffix=\".$current.$revision\"\n\t  ;;\n\n\twindows)\n\t  # Use '-' rather than '.', since we only want one\n\t  # extension on DOS 8.3 filesystems.\n\t  func_arith $current - $age\n\t  major=$func_arith_result\n\t  versuffix=\"-$major\"\n\t  ;;\n\n\t*)\n\t  func_fatal_configuration \"unknown library version type \\`$version_type'\"\n\t  ;;\n\tesac\n\n\t# Clear the version info if we defaulted, and they specified a release.\n\tif test -z \"$vinfo\" && test -n \"$release\"; then\n\t  major=\n\t  case $version_type in\n\t  darwin)\n\t    # we can't check for \"0.0\" in archive_cmds due to quoting\n\t    # problems, so we reset it completely\n\t    verstring=\n\t    ;;\n\t  *)\n\t    verstring=\"0.0\"\n\t    ;;\n\t  esac\n\t  if test \"$need_version\" = no; then\n\t    versuffix=\n\t  else\n\t    versuffix=\".0.0\"\n\t  fi\n\tfi\n\n\t# Remove version info from name if versioning should be avoided\n\tif test \"$avoid_version\" = yes && test \"$need_version\" = no; then\n\t  major=\n\t  versuffix=\n\t  verstring=\"\"\n\tfi\n\n\t# Check to see if the archive will have undefined symbols.\n\tif test \"$allow_undefined\" = yes; then\n\t  if test \"$allow_undefined_flag\" = unsupported; then\n\t    func_warning \"undefined symbols not allowed in $host shared libraries\"\n\t    build_libtool_libs=no\n\t    build_old_libs=yes\n\t  fi\n\telse\n\t  # Don't allow undefined symbols.\n\t  allow_undefined_flag=\"$no_undefined_flag\"\n\tfi\n\n      fi\n\n      func_generate_dlsyms \"$libname\" \"$libname\" \"yes\"\n      func_append libobjs \" $symfileobj\"\n      test \"X$libobjs\" = \"X \" && libobjs=\n\n      if test \"$opt_mode\" != relink; then\n\t# Remove our outputs, but don't remove object files since they\n\t# may have been created when compiling PIC objects.\n\tremovelist=\n\ttempremovelist=`$ECHO \"$output_objdir/*\"`\n\tfor p in $tempremovelist; do\n\t  case $p in\n\t    *.$objext | *.gcno)\n\t       ;;\n\t    $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)\n\t       if test \"X$precious_files_regex\" != \"X\"; then\n\t\t if $ECHO \"$p\" | $EGREP -e \"$precious_files_regex\" >/dev/null 2>&1\n\t\t then\n\t\t   continue\n\t\t fi\n\t       fi\n\t       func_append removelist \" $p\"\n\t       ;;\n\t    *) ;;\n\t  esac\n\tdone\n\ttest -n \"$removelist\" && \\\n\t  func_show_eval \"${RM}r \\$removelist\"\n      fi\n\n      # Now set the variables for building old libraries.\n      if test \"$build_old_libs\" = yes && test \"$build_libtool_libs\" != convenience ; then\n\tfunc_append oldlibs \" $output_objdir/$libname.$libext\"\n\n\t# Transform .lo files to .o files.\n\toldobjs=\"$objs \"`$ECHO \"$libobjs\" | $SP2NL | $SED \"/\\.${libext}$/d; $lo2o\" | $NL2SP`\n      fi\n\n      # Eliminate all temporary directories.\n      #for path in $notinst_path; do\n      #\tlib_search_path=`$ECHO \"$lib_search_path \" | $SED \"s% $path % %g\"`\n      #\tdeplibs=`$ECHO \"$deplibs \" | $SED \"s% -L$path % %g\"`\n      #\tdependency_libs=`$ECHO \"$dependency_libs \" | $SED \"s% -L$path % %g\"`\n      #done\n\n      if test -n \"$xrpath\"; then\n\t# If the user specified any rpath flags, then add them.\n\ttemp_xrpath=\n\tfor libdir in $xrpath; do\n\t  func_replace_sysroot \"$libdir\"\n\t  func_append temp_xrpath \" -R$func_replace_sysroot_result\"\n\t  case \"$finalize_rpath \" in\n\t  *\" $libdir \"*) ;;\n\t  *) func_append finalize_rpath \" $libdir\" ;;\n\t  esac\n\tdone\n\tif test \"$hardcode_into_libs\" != yes || test \"$build_old_libs\" = yes; then\n\t  dependency_libs=\"$temp_xrpath $dependency_libs\"\n\tfi\n      fi\n\n      # Make sure dlfiles contains only unique files that won't be dlpreopened\n      old_dlfiles=\"$dlfiles\"\n      dlfiles=\n      for lib in $old_dlfiles; do\n\tcase \" $dlprefiles $dlfiles \" in\n\t*\" $lib \"*) ;;\n\t*) func_append dlfiles \" $lib\" ;;\n\tesac\n      done\n\n      # Make sure dlprefiles contains only unique files\n      old_dlprefiles=\"$dlprefiles\"\n      dlprefiles=\n      for lib in $old_dlprefiles; do\n\tcase \"$dlprefiles \" in\n\t*\" $lib \"*) ;;\n\t*) func_append dlprefiles \" $lib\" ;;\n\tesac\n      done\n\n      if test \"$build_libtool_libs\" = yes; then\n\tif test -n \"$rpath\"; then\n\t  case $host in\n\t  *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)\n\t    # these systems don't actually have a c library (as such)!\n\t    ;;\n\t  *-*-rhapsody* | *-*-darwin1.[012])\n\t    # Rhapsody C library is in the System framework\n\t    func_append deplibs \" System.ltframework\"\n\t    ;;\n\t  *-*-netbsd*)\n\t    # Don't link with libc until the a.out ld.so is fixed.\n\t    ;;\n\t  *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)\n\t    # Do not include libc due to us having libc/libc_r.\n\t    ;;\n\t  *-*-sco3.2v5* | *-*-sco5v6*)\n\t    # Causes problems with __ctype\n\t    ;;\n\t  *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)\n\t    # Compiler inserts libc in the correct place for threads to work\n\t    ;;\n\t  *)\n\t    # Add libc to deplibs on all other systems if necessary.\n\t    if test \"$build_libtool_need_lc\" = \"yes\"; then\n\t      func_append deplibs \" -lc\"\n\t    fi\n\t    ;;\n\t  esac\n\tfi\n\n\t# Transform deplibs into only deplibs that can be linked in shared.\n\tname_save=$name\n\tlibname_save=$libname\n\trelease_save=$release\n\tversuffix_save=$versuffix\n\tmajor_save=$major\n\t# I'm not sure if I'm treating the release correctly.  I think\n\t# release should show up in the -l (ie -lgmp5) so we don't want to\n\t# add it in twice.  Is that correct?\n\trelease=\"\"\n\tversuffix=\"\"\n\tmajor=\"\"\n\tnewdeplibs=\n\tdroppeddeps=no\n\tcase $deplibs_check_method in\n\tpass_all)\n\t  # Don't check for shared/static.  Everything works.\n\t  # This might be a little naive.  We might want to check\n\t  # whether the library exists or not.  But this is on\n\t  # osf3 & osf4 and I'm not really sure... Just\n\t  # implementing what was already the behavior.\n\t  newdeplibs=$deplibs\n\t  ;;\n\ttest_compile)\n\t  # This code stresses the \"libraries are programs\" paradigm to its\n\t  # limits. Maybe even breaks it.  We compile a program, linking it\n\t  # against the deplibs as a proxy for the library.  Then we can check\n\t  # whether they linked in statically or dynamically with ldd.\n\t  $opt_dry_run || $RM conftest.c\n\t  cat > conftest.c <<EOF\n\t  int main() { return 0; }\nEOF\n\t  $opt_dry_run || $RM conftest\n\t  if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then\n\t    ldd_output=`ldd conftest`\n\t    for i in $deplibs; do\n\t      case $i in\n\t      -l*)\n\t\tfunc_stripname -l '' \"$i\"\n\t\tname=$func_stripname_result\n\t\tif test \"X$allow_libtool_libs_with_static_runtimes\" = \"Xyes\" ; then\n\t\t  case \" $predeps $postdeps \" in\n\t\t  *\" $i \"*)\n\t\t    func_append newdeplibs \" $i\"\n\t\t    i=\"\"\n\t\t    ;;\n\t\t  esac\n\t\tfi\n\t\tif test -n \"$i\" ; then\n\t\t  libname=`eval \"\\\\$ECHO \\\"$libname_spec\\\"\"`\n\t\t  deplib_matches=`eval \"\\\\$ECHO \\\"$library_names_spec\\\"\"`\n\t\t  set dummy $deplib_matches; shift\n\t\t  deplib_match=$1\n\t\t  if test `expr \"$ldd_output\" : \".*$deplib_match\"` -ne 0 ; then\n\t\t    func_append newdeplibs \" $i\"\n\t\t  else\n\t\t    droppeddeps=yes\n\t\t    echo\n\t\t    $ECHO \"*** Warning: dynamic linker does not accept needed library $i.\"\n\t\t    echo \"*** I have the capability to make that library automatically link in when\"\n\t\t    echo \"*** you link to this library.  But I can only do this if you have a\"\n\t\t    echo \"*** shared version of the library, which I believe you do not have\"\n\t\t    echo \"*** because a test_compile did reveal that the linker did not use it for\"\n\t\t    echo \"*** its dynamic dependency list that programs get resolved with at runtime.\"\n\t\t  fi\n\t\tfi\n\t\t;;\n\t      *)\n\t\tfunc_append newdeplibs \" $i\"\n\t\t;;\n\t      esac\n\t    done\n\t  else\n\t    # Error occurred in the first compile.  Let's try to salvage\n\t    # the situation: Compile a separate program for each library.\n\t    for i in $deplibs; do\n\t      case $i in\n\t      -l*)\n\t\tfunc_stripname -l '' \"$i\"\n\t\tname=$func_stripname_result\n\t\t$opt_dry_run || $RM conftest\n\t\tif $LTCC $LTCFLAGS -o conftest conftest.c $i; then\n\t\t  ldd_output=`ldd conftest`\n\t\t  if test \"X$allow_libtool_libs_with_static_runtimes\" = \"Xyes\" ; then\n\t\t    case \" $predeps $postdeps \" in\n\t\t    *\" $i \"*)\n\t\t      func_append newdeplibs \" $i\"\n\t\t      i=\"\"\n\t\t      ;;\n\t\t    esac\n\t\t  fi\n\t\t  if test -n \"$i\" ; then\n\t\t    libname=`eval \"\\\\$ECHO \\\"$libname_spec\\\"\"`\n\t\t    deplib_matches=`eval \"\\\\$ECHO \\\"$library_names_spec\\\"\"`\n\t\t    set dummy $deplib_matches; shift\n\t\t    deplib_match=$1\n\t\t    if test `expr \"$ldd_output\" : \".*$deplib_match\"` -ne 0 ; then\n\t\t      func_append newdeplibs \" $i\"\n\t\t    else\n\t\t      droppeddeps=yes\n\t\t      echo\n\t\t      $ECHO \"*** Warning: dynamic linker does not accept needed library $i.\"\n\t\t      echo \"*** I have the capability to make that library automatically link in when\"\n\t\t      echo \"*** you link to this library.  But I can only do this if you have a\"\n\t\t      echo \"*** shared version of the library, which you do not appear to have\"\n\t\t      echo \"*** because a test_compile did reveal that the linker did not use this one\"\n\t\t      echo \"*** as a dynamic dependency that programs can get resolved with at runtime.\"\n\t\t    fi\n\t\t  fi\n\t\telse\n\t\t  droppeddeps=yes\n\t\t  echo\n\t\t  $ECHO \"*** Warning!  Library $i is needed by this library but I was not able to\"\n\t\t  echo \"*** make it link in!  You will probably need to install it or some\"\n\t\t  echo \"*** library that it depends on before this library will be fully\"\n\t\t  echo \"*** functional.  Installing it before continuing would be even better.\"\n\t\tfi\n\t\t;;\n\t      *)\n\t\tfunc_append newdeplibs \" $i\"\n\t\t;;\n\t      esac\n\t    done\n\t  fi\n\t  ;;\n\tfile_magic*)\n\t  set dummy $deplibs_check_method; shift\n\t  file_magic_regex=`expr \"$deplibs_check_method\" : \"$1 \\(.*\\)\"`\n\t  for a_deplib in $deplibs; do\n\t    case $a_deplib in\n\t    -l*)\n\t      func_stripname -l '' \"$a_deplib\"\n\t      name=$func_stripname_result\n\t      if test \"X$allow_libtool_libs_with_static_runtimes\" = \"Xyes\" ; then\n\t\tcase \" $predeps $postdeps \" in\n\t\t*\" $a_deplib \"*)\n\t\t  func_append newdeplibs \" $a_deplib\"\n\t\t  a_deplib=\"\"\n\t\t  ;;\n\t\tesac\n\t      fi\n\t      if test -n \"$a_deplib\" ; then\n\t\tlibname=`eval \"\\\\$ECHO \\\"$libname_spec\\\"\"`\n\t\tif test -n \"$file_magic_glob\"; then\n\t\t  libnameglob=`func_echo_all \"$libname\" | $SED -e $file_magic_glob`\n\t\telse\n\t\t  libnameglob=$libname\n\t\tfi\n\t\ttest \"$want_nocaseglob\" = yes && nocaseglob=`shopt -p nocaseglob`\n\t\tfor i in $lib_search_path $sys_lib_search_path $shlib_search_path; do\n\t\t  if test \"$want_nocaseglob\" = yes; then\n\t\t    shopt -s nocaseglob\n\t\t    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`\n\t\t    $nocaseglob\n\t\t  else\n\t\t    potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`\n\t\t  fi\n\t\t  for potent_lib in $potential_libs; do\n\t\t      # Follow soft links.\n\t\t      if ls -lLd \"$potent_lib\" 2>/dev/null |\n\t\t\t $GREP \" -> \" >/dev/null; then\n\t\t\tcontinue\n\t\t      fi\n\t\t      # The statement above tries to avoid entering an\n\t\t      # endless loop below, in case of cyclic links.\n\t\t      # We might still enter an endless loop, since a link\n\t\t      # loop can be closed while we follow links,\n\t\t      # but so what?\n\t\t      potlib=\"$potent_lib\"\n\t\t      while test -h \"$potlib\" 2>/dev/null; do\n\t\t\tpotliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`\n\t\t\tcase $potliblink in\n\t\t\t[\\\\/]* | [A-Za-z]:[\\\\/]*) potlib=\"$potliblink\";;\n\t\t\t*) potlib=`$ECHO \"$potlib\" | $SED 's,[^/]*$,,'`\"$potliblink\";;\n\t\t\tesac\n\t\t      done\n\t\t      if eval $file_magic_cmd \\\"\\$potlib\\\" 2>/dev/null |\n\t\t\t $SED -e 10q |\n\t\t\t $EGREP \"$file_magic_regex\" > /dev/null; then\n\t\t\tfunc_append newdeplibs \" $a_deplib\"\n\t\t\ta_deplib=\"\"\n\t\t\tbreak 2\n\t\t      fi\n\t\t  done\n\t\tdone\n\t      fi\n\t      if test -n \"$a_deplib\" ; then\n\t\tdroppeddeps=yes\n\t\techo\n\t\t$ECHO \"*** Warning: linker path does not have real file for library $a_deplib.\"\n\t\techo \"*** I have the capability to make that library automatically link in when\"\n\t\techo \"*** you link to this library.  But I can only do this if you have a\"\n\t\techo \"*** shared version of the library, which you do not appear to have\"\n\t\techo \"*** because I did check the linker path looking for a file starting\"\n\t\tif test -z \"$potlib\" ; then\n\t\t  $ECHO \"*** with $libname but no candidates were found. (...for file magic test)\"\n\t\telse\n\t\t  $ECHO \"*** with $libname and none of the candidates passed a file format test\"\n\t\t  $ECHO \"*** using a file magic. Last file checked: $potlib\"\n\t\tfi\n\t      fi\n\t      ;;\n\t    *)\n\t      # Add a -L argument.\n\t      func_append newdeplibs \" $a_deplib\"\n\t      ;;\n\t    esac\n\t  done # Gone through all deplibs.\n\t  ;;\n\tmatch_pattern*)\n\t  set dummy $deplibs_check_method; shift\n\t  match_pattern_regex=`expr \"$deplibs_check_method\" : \"$1 \\(.*\\)\"`\n\t  for a_deplib in $deplibs; do\n\t    case $a_deplib in\n\t    -l*)\n\t      func_stripname -l '' \"$a_deplib\"\n\t      name=$func_stripname_result\n\t      if test \"X$allow_libtool_libs_with_static_runtimes\" = \"Xyes\" ; then\n\t\tcase \" $predeps $postdeps \" in\n\t\t*\" $a_deplib \"*)\n\t\t  func_append newdeplibs \" $a_deplib\"\n\t\t  a_deplib=\"\"\n\t\t  ;;\n\t\tesac\n\t      fi\n\t      if test -n \"$a_deplib\" ; then\n\t\tlibname=`eval \"\\\\$ECHO \\\"$libname_spec\\\"\"`\n\t\tfor i in $lib_search_path $sys_lib_search_path $shlib_search_path; do\n\t\t  potential_libs=`ls $i/$libname[.-]* 2>/dev/null`\n\t\t  for potent_lib in $potential_libs; do\n\t\t    potlib=\"$potent_lib\" # see symlink-check above in file_magic test\n\t\t    if eval \"\\$ECHO \\\"$potent_lib\\\"\" 2>/dev/null | $SED 10q | \\\n\t\t       $EGREP \"$match_pattern_regex\" > /dev/null; then\n\t\t      func_append newdeplibs \" $a_deplib\"\n\t\t      a_deplib=\"\"\n\t\t      break 2\n\t\t    fi\n\t\t  done\n\t\tdone\n\t      fi\n\t      if test -n \"$a_deplib\" ; then\n\t\tdroppeddeps=yes\n\t\techo\n\t\t$ECHO \"*** Warning: linker path does not have real file for library $a_deplib.\"\n\t\techo \"*** I have the capability to make that library automatically link in when\"\n\t\techo \"*** you link to this library.  But I can only do this if you have a\"\n\t\techo \"*** shared version of the library, which you do not appear to have\"\n\t\techo \"*** because I did check the linker path looking for a file starting\"\n\t\tif test -z \"$potlib\" ; then\n\t\t  $ECHO \"*** with $libname but no candidates were found. (...for regex pattern test)\"\n\t\telse\n\t\t  $ECHO \"*** with $libname and none of the candidates passed a file format test\"\n\t\t  $ECHO \"*** using a regex pattern. Last file checked: $potlib\"\n\t\tfi\n\t      fi\n\t      ;;\n\t    *)\n\t      # Add a -L argument.\n\t      func_append newdeplibs \" $a_deplib\"\n\t      ;;\n\t    esac\n\t  done # Gone through all deplibs.\n\t  ;;\n\tnone | unknown | *)\n\t  newdeplibs=\"\"\n\t  tmp_deplibs=`$ECHO \" $deplibs\" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`\n\t  if test \"X$allow_libtool_libs_with_static_runtimes\" = \"Xyes\" ; then\n\t    for i in $predeps $postdeps ; do\n\t      # can't use Xsed below, because $i might contain '/'\n\t      tmp_deplibs=`$ECHO \" $tmp_deplibs\" | $SED \"s,$i,,\"`\n\t    done\n\t  fi\n\t  case $tmp_deplibs in\n\t  *[!\\\t\\ ]*)\n\t    echo\n\t    if test \"X$deplibs_check_method\" = \"Xnone\"; then\n\t      echo \"*** Warning: inter-library dependencies are not supported in this platform.\"\n\t    else\n\t      echo \"*** Warning: inter-library dependencies are not known to be supported.\"\n\t    fi\n\t    echo \"*** All declared inter-library dependencies are being dropped.\"\n\t    droppeddeps=yes\n\t    ;;\n\t  esac\n\t  ;;\n\tesac\n\tversuffix=$versuffix_save\n\tmajor=$major_save\n\trelease=$release_save\n\tlibname=$libname_save\n\tname=$name_save\n\n\tcase $host in\n\t*-*-rhapsody* | *-*-darwin1.[012])\n\t  # On Rhapsody replace the C library with the System framework\n\t  newdeplibs=`$ECHO \" $newdeplibs\" | $SED 's/ -lc / System.ltframework /'`\n\t  ;;\n\tesac\n\n\tif test \"$droppeddeps\" = yes; then\n\t  if test \"$module\" = yes; then\n\t    echo\n\t    echo \"*** Warning: libtool could not satisfy all declared inter-library\"\n\t    $ECHO \"*** dependencies of module $libname.  Therefore, libtool will create\"\n\t    echo \"*** a static module, that should work as long as the dlopening\"\n\t    echo \"*** application is linked with the -dlopen flag.\"\n\t    if test -z \"$global_symbol_pipe\"; then\n\t      echo\n\t      echo \"*** However, this would only work if libtool was able to extract symbol\"\n\t      echo \"*** lists from a program, using \\`nm' or equivalent, but libtool could\"\n\t      echo \"*** not find such a program.  So, this module is probably useless.\"\n\t      echo \"*** \\`nm' from GNU binutils and a full rebuild may help.\"\n\t    fi\n\t    if test \"$build_old_libs\" = no; then\n\t      oldlibs=\"$output_objdir/$libname.$libext\"\n\t      build_libtool_libs=module\n\t      build_old_libs=yes\n\t    else\n\t      build_libtool_libs=no\n\t    fi\n\t  else\n\t    echo \"*** The inter-library dependencies that have been dropped here will be\"\n\t    echo \"*** automatically added whenever a program is linked with this library\"\n\t    echo \"*** or is declared to -dlopen it.\"\n\n\t    if test \"$allow_undefined\" = no; then\n\t      echo\n\t      echo \"*** Since this library must not contain undefined symbols,\"\n\t      echo \"*** because either the platform does not support them or\"\n\t      echo \"*** it was explicitly requested with -no-undefined,\"\n\t      echo \"*** libtool will only create a static version of it.\"\n\t      if test \"$build_old_libs\" = no; then\n\t\toldlibs=\"$output_objdir/$libname.$libext\"\n\t\tbuild_libtool_libs=module\n\t\tbuild_old_libs=yes\n\t      else\n\t\tbuild_libtool_libs=no\n\t      fi\n\t    fi\n\t  fi\n\tfi\n\t# Done checking deplibs!\n\tdeplibs=$newdeplibs\n      fi\n      # Time to change all our \"foo.ltframework\" stuff back to \"-framework foo\"\n      case $host in\n\t*-*-darwin*)\n\t  newdeplibs=`$ECHO \" $newdeplibs\" | $SED 's% \\([^ $]*\\).ltframework% -framework \\1%g'`\n\t  new_inherited_linker_flags=`$ECHO \" $new_inherited_linker_flags\" | $SED 's% \\([^ $]*\\).ltframework% -framework \\1%g'`\n\t  deplibs=`$ECHO \" $deplibs\" | $SED 's% \\([^ $]*\\).ltframework% -framework \\1%g'`\n\t  ;;\n      esac\n\n      # move library search paths that coincide with paths to not yet\n      # installed libraries to the beginning of the library search list\n      new_libs=\n      for path in $notinst_path; do\n\tcase \" $new_libs \" in\n\t*\" -L$path/$objdir \"*) ;;\n\t*)\n\t  case \" $deplibs \" in\n\t  *\" -L$path/$objdir \"*)\n\t    func_append new_libs \" -L$path/$objdir\" ;;\n\t  esac\n\t  ;;\n\tesac\n      done\n      for deplib in $deplibs; do\n\tcase $deplib in\n\t-L*)\n\t  case \" $new_libs \" in\n\t  *\" $deplib \"*) ;;\n\t  *) func_append new_libs \" $deplib\" ;;\n\t  esac\n\t  ;;\n\t*) func_append new_libs \" $deplib\" ;;\n\tesac\n      done\n      deplibs=\"$new_libs\"\n\n      # All the library-specific variables (install_libdir is set above).\n      library_names=\n      old_library=\n      dlname=\n\n      # Test again, we may have decided not to build it any more\n      if test \"$build_libtool_libs\" = yes; then\n\t# Remove ${wl} instances when linking with ld.\n\t# FIXME: should test the right _cmds variable.\n\tcase $archive_cmds in\n\t  *\\$LD\\ *) wl= ;;\n        esac\n\tif test \"$hardcode_into_libs\" = yes; then\n\t  # Hardcode the library paths\n\t  hardcode_libdirs=\n\t  dep_rpath=\n\t  rpath=\"$finalize_rpath\"\n\t  test \"$opt_mode\" != relink && rpath=\"$compile_rpath$rpath\"\n\t  for libdir in $rpath; do\n\t    if test -n \"$hardcode_libdir_flag_spec\"; then\n\t      if test -n \"$hardcode_libdir_separator\"; then\n\t\tfunc_replace_sysroot \"$libdir\"\n\t\tlibdir=$func_replace_sysroot_result\n\t\tif test -z \"$hardcode_libdirs\"; then\n\t\t  hardcode_libdirs=\"$libdir\"\n\t\telse\n\t\t  # Just accumulate the unique libdirs.\n\t\t  case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in\n\t\t  *\"$hardcode_libdir_separator$libdir$hardcode_libdir_separator\"*)\n\t\t    ;;\n\t\t  *)\n\t\t    func_append hardcode_libdirs \"$hardcode_libdir_separator$libdir\"\n\t\t    ;;\n\t\t  esac\n\t\tfi\n\t      else\n\t\teval flag=\\\"$hardcode_libdir_flag_spec\\\"\n\t\tfunc_append dep_rpath \" $flag\"\n\t      fi\n\t    elif test -n \"$runpath_var\"; then\n\t      case \"$perm_rpath \" in\n\t      *\" $libdir \"*) ;;\n\t      *) func_append perm_rpath \" $libdir\" ;;\n\t      esac\n\t    fi\n\t  done\n\t  # Substitute the hardcoded libdirs into the rpath.\n\t  if test -n \"$hardcode_libdir_separator\" &&\n\t     test -n \"$hardcode_libdirs\"; then\n\t    libdir=\"$hardcode_libdirs\"\n\t    eval \"dep_rpath=\\\"$hardcode_libdir_flag_spec\\\"\"\n\t  fi\n\t  if test -n \"$runpath_var\" && test -n \"$perm_rpath\"; then\n\t    # We should set the runpath_var.\n\t    rpath=\n\t    for dir in $perm_rpath; do\n\t      func_append rpath \"$dir:\"\n\t    done\n\t    eval \"$runpath_var='$rpath\\$$runpath_var'; export $runpath_var\"\n\t  fi\n\t  test -n \"$dep_rpath\" && deplibs=\"$dep_rpath $deplibs\"\n\tfi\n\n\tshlibpath=\"$finalize_shlibpath\"\n\ttest \"$opt_mode\" != relink && shlibpath=\"$compile_shlibpath$shlibpath\"\n\tif test -n \"$shlibpath\"; then\n\t  eval \"$shlibpath_var='$shlibpath\\$$shlibpath_var'; export $shlibpath_var\"\n\tfi\n\n\t# Get the real and link names of the library.\n\teval shared_ext=\\\"$shrext_cmds\\\"\n\teval library_names=\\\"$library_names_spec\\\"\n\tset dummy $library_names\n\tshift\n\trealname=\"$1\"\n\tshift\n\n\tif test -n \"$soname_spec\"; then\n\t  eval soname=\\\"$soname_spec\\\"\n\telse\n\t  soname=\"$realname\"\n\tfi\n\tif test -z \"$dlname\"; then\n\t  dlname=$soname\n\tfi\n\n\tlib=\"$output_objdir/$realname\"\n\tlinknames=\n\tfor link\n\tdo\n\t  func_append linknames \" $link\"\n\tdone\n\n\t# Use standard objects if they are pic\n\ttest -z \"$pic_flag\" && libobjs=`$ECHO \"$libobjs\" | $SP2NL | $SED \"$lo2o\" | $NL2SP`\n\ttest \"X$libobjs\" = \"X \" && libobjs=\n\n\tdelfiles=\n\tif test -n \"$export_symbols\" && test -n \"$include_expsyms\"; then\n\t  $opt_dry_run || cp \"$export_symbols\" \"$output_objdir/$libname.uexp\"\n\t  export_symbols=\"$output_objdir/$libname.uexp\"\n\t  func_append delfiles \" $export_symbols\"\n\tfi\n\n\torig_export_symbols=\n\tcase $host_os in\n\tcygwin* | mingw* | cegcc*)\n\t  if test -n \"$export_symbols\" && test -z \"$export_symbols_regex\"; then\n\t    # exporting using user supplied symfile\n\t    if test \"x`$SED 1q $export_symbols`\" != xEXPORTS; then\n\t      # and it's NOT already a .def file. Must figure out\n\t      # which of the given symbols are data symbols and tag\n\t      # them as such. So, trigger use of export_symbols_cmds.\n\t      # export_symbols gets reassigned inside the \"prepare\n\t      # the list of exported symbols\" if statement, so the\n\t      # include_expsyms logic still works.\n\t      orig_export_symbols=\"$export_symbols\"\n\t      export_symbols=\n\t      always_export_symbols=yes\n\t    fi\n\t  fi\n\t  ;;\n\tesac\n\n\t# Prepare the list of exported symbols\n\tif test -z \"$export_symbols\"; then\n\t  if test \"$always_export_symbols\" = yes || test -n \"$export_symbols_regex\"; then\n\t    func_verbose \"generating symbol list for \\`$libname.la'\"\n\t    export_symbols=\"$output_objdir/$libname.exp\"\n\t    $opt_dry_run || $RM $export_symbols\n\t    cmds=$export_symbols_cmds\n\t    save_ifs=\"$IFS\"; IFS='~'\n\t    for cmd1 in $cmds; do\n\t      IFS=\"$save_ifs\"\n\t      # Take the normal branch if the nm_file_list_spec branch\n\t      # doesn't work or if tool conversion is not needed.\n\t      case $nm_file_list_spec~$to_tool_file_cmd in\n\t\t*~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)\n\t\t  try_normal_branch=yes\n\t\t  eval cmd=\\\"$cmd1\\\"\n\t\t  func_len \" $cmd\"\n\t\t  len=$func_len_result\n\t\t  ;;\n\t\t*)\n\t\t  try_normal_branch=no\n\t\t  ;;\n\t      esac\n\t      if test \"$try_normal_branch\" = yes \\\n\t\t && { test \"$len\" -lt \"$max_cmd_len\" \\\n\t\t      || test \"$max_cmd_len\" -le -1; }\n\t      then\n\t\tfunc_show_eval \"$cmd\" 'exit $?'\n\t\tskipped_export=false\n\t      elif test -n \"$nm_file_list_spec\"; then\n\t\tfunc_basename \"$output\"\n\t\toutput_la=$func_basename_result\n\t\tsave_libobjs=$libobjs\n\t\tsave_output=$output\n\t\toutput=${output_objdir}/${output_la}.nm\n\t\tfunc_to_tool_file \"$output\"\n\t\tlibobjs=$nm_file_list_spec$func_to_tool_file_result\n\t\tfunc_append delfiles \" $output\"\n\t\tfunc_verbose \"creating $NM input file list: $output\"\n\t\tfor obj in $save_libobjs; do\n\t\t  func_to_tool_file \"$obj\"\n\t\t  $ECHO \"$func_to_tool_file_result\"\n\t\tdone > \"$output\"\n\t\teval cmd=\\\"$cmd1\\\"\n\t\tfunc_show_eval \"$cmd\" 'exit $?'\n\t\toutput=$save_output\n\t\tlibobjs=$save_libobjs\n\t\tskipped_export=false\n\t      else\n\t\t# The command line is too long to execute in one step.\n\t\tfunc_verbose \"using reloadable object file for export list...\"\n\t\tskipped_export=:\n\t\t# Break out early, otherwise skipped_export may be\n\t\t# set to false by a later but shorter cmd.\n\t\tbreak\n\t      fi\n\t    done\n\t    IFS=\"$save_ifs\"\n\t    if test -n \"$export_symbols_regex\" && test \"X$skipped_export\" != \"X:\"; then\n\t      func_show_eval '$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"'\n\t      func_show_eval '$MV \"${export_symbols}T\" \"$export_symbols\"'\n\t    fi\n\t  fi\n\tfi\n\n\tif test -n \"$export_symbols\" && test -n \"$include_expsyms\"; then\n\t  tmp_export_symbols=\"$export_symbols\"\n\t  test -n \"$orig_export_symbols\" && tmp_export_symbols=\"$orig_export_symbols\"\n\t  $opt_dry_run || eval '$ECHO \"$include_expsyms\" | $SP2NL >> \"$tmp_export_symbols\"'\n\tfi\n\n\tif test \"X$skipped_export\" != \"X:\" && test -n \"$orig_export_symbols\"; then\n\t  # The given exports_symbols file has to be filtered, so filter it.\n\t  func_verbose \"filter symbol list for \\`$libname.la' to tag DATA exports\"\n\t  # FIXME: $output_objdir/$libname.filter potentially contains lots of\n\t  # 's' commands which not all seds can handle. GNU sed should be fine\n\t  # though. Also, the filter scales superlinearly with the number of\n\t  # global variables. join(1) would be nice here, but unfortunately\n\t  # isn't a blessed tool.\n\t  $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\\(.*\\)\\([ \\,].*\\),s|^\\1$|\\1\\2|,' < $export_symbols > $output_objdir/$libname.filter\n\t  func_append delfiles \" $export_symbols $output_objdir/$libname.filter\"\n\t  export_symbols=$output_objdir/$libname.def\n\t  $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols\n\tfi\n\n\ttmp_deplibs=\n\tfor test_deplib in $deplibs; do\n\t  case \" $convenience \" in\n\t  *\" $test_deplib \"*) ;;\n\t  *)\n\t    func_append tmp_deplibs \" $test_deplib\"\n\t    ;;\n\t  esac\n\tdone\n\tdeplibs=\"$tmp_deplibs\"\n\n\tif test -n \"$convenience\"; then\n\t  if test -n \"$whole_archive_flag_spec\" &&\n\t    test \"$compiler_needs_object\" = yes &&\n\t    test -z \"$libobjs\"; then\n\t    # extract the archives, so we have objects to list.\n\t    # TODO: could optimize this to just extract one archive.\n\t    whole_archive_flag_spec=\n\t  fi\n\t  if test -n \"$whole_archive_flag_spec\"; then\n\t    save_libobjs=$libobjs\n\t    eval libobjs=\\\"\\$libobjs $whole_archive_flag_spec\\\"\n\t    test \"X$libobjs\" = \"X \" && libobjs=\n\t  else\n\t    gentop=\"$output_objdir/${outputname}x\"\n\t    func_append generated \" $gentop\"\n\n\t    func_extract_archives $gentop $convenience\n\t    func_append libobjs \" $func_extract_archives_result\"\n\t    test \"X$libobjs\" = \"X \" && libobjs=\n\t  fi\n\tfi\n\n\tif test \"$thread_safe\" = yes && test -n \"$thread_safe_flag_spec\"; then\n\t  eval flag=\\\"$thread_safe_flag_spec\\\"\n\t  func_append linker_flags \" $flag\"\n\tfi\n\n\t# Make a backup of the uninstalled library when relinking\n\tif test \"$opt_mode\" = relink; then\n\t  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?\n\tfi\n\n\t# Do each of the archive commands.\n\tif test \"$module\" = yes && test -n \"$module_cmds\" ; then\n\t  if test -n \"$export_symbols\" && test -n \"$module_expsym_cmds\"; then\n\t    eval test_cmds=\\\"$module_expsym_cmds\\\"\n\t    cmds=$module_expsym_cmds\n\t  else\n\t    eval test_cmds=\\\"$module_cmds\\\"\n\t    cmds=$module_cmds\n\t  fi\n\telse\n\t  if test -n \"$export_symbols\" && test -n \"$archive_expsym_cmds\"; then\n\t    eval test_cmds=\\\"$archive_expsym_cmds\\\"\n\t    cmds=$archive_expsym_cmds\n\t  else\n\t    eval test_cmds=\\\"$archive_cmds\\\"\n\t    cmds=$archive_cmds\n\t  fi\n\tfi\n\n\tif test \"X$skipped_export\" != \"X:\" &&\n\t   func_len \" $test_cmds\" &&\n\t   len=$func_len_result &&\n\t   test \"$len\" -lt \"$max_cmd_len\" || test \"$max_cmd_len\" -le -1; then\n\t  :\n\telse\n\t  # The command line is too long to link in one step, link piecewise\n\t  # or, if using GNU ld and skipped_export is not :, use a linker\n\t  # script.\n\n\t  # Save the value of $output and $libobjs because we want to\n\t  # use them later.  If we have whole_archive_flag_spec, we\n\t  # want to use save_libobjs as it was before\n\t  # whole_archive_flag_spec was expanded, because we can't\n\t  # assume the linker understands whole_archive_flag_spec.\n\t  # This may have to be revisited, in case too many\n\t  # convenience libraries get linked in and end up exceeding\n\t  # the spec.\n\t  if test -z \"$convenience\" || test -z \"$whole_archive_flag_spec\"; then\n\t    save_libobjs=$libobjs\n\t  fi\n\t  save_output=$output\n\t  func_basename \"$output\"\n\t  output_la=$func_basename_result\n\n\t  # Clear the reloadable object creation command queue and\n\t  # initialize k to one.\n\t  test_cmds=\n\t  concat_cmds=\n\t  objlist=\n\t  last_robj=\n\t  k=1\n\n\t  if test -n \"$save_libobjs\" && test \"X$skipped_export\" != \"X:\" && test \"$with_gnu_ld\" = yes; then\n\t    output=${output_objdir}/${output_la}.lnkscript\n\t    func_verbose \"creating GNU ld script: $output\"\n\t    echo 'INPUT (' > $output\n\t    for obj in $save_libobjs\n\t    do\n\t      func_to_tool_file \"$obj\"\n\t      $ECHO \"$func_to_tool_file_result\" >> $output\n\t    done\n\t    echo ')' >> $output\n\t    func_append delfiles \" $output\"\n\t    func_to_tool_file \"$output\"\n\t    output=$func_to_tool_file_result\n\t  elif test -n \"$save_libobjs\" && test \"X$skipped_export\" != \"X:\" && test \"X$file_list_spec\" != X; then\n\t    output=${output_objdir}/${output_la}.lnk\n\t    func_verbose \"creating linker input file list: $output\"\n\t    : > $output\n\t    set x $save_libobjs\n\t    shift\n\t    firstobj=\n\t    if test \"$compiler_needs_object\" = yes; then\n\t      firstobj=\"$1 \"\n\t      shift\n\t    fi\n\t    for obj\n\t    do\n\t      func_to_tool_file \"$obj\"\n\t      $ECHO \"$func_to_tool_file_result\" >> $output\n\t    done\n\t    func_append delfiles \" $output\"\n\t    func_to_tool_file \"$output\"\n\t    output=$firstobj\\\"$file_list_spec$func_to_tool_file_result\\\"\n\t  else\n\t    if test -n \"$save_libobjs\"; then\n\t      func_verbose \"creating reloadable object files...\"\n\t      output=$output_objdir/$output_la-${k}.$objext\n\t      eval test_cmds=\\\"$reload_cmds\\\"\n\t      func_len \" $test_cmds\"\n\t      len0=$func_len_result\n\t      len=$len0\n\n\t      # Loop over the list of objects to be linked.\n\t      for obj in $save_libobjs\n\t      do\n\t\tfunc_len \" $obj\"\n\t\tfunc_arith $len + $func_len_result\n\t\tlen=$func_arith_result\n\t\tif test \"X$objlist\" = X ||\n\t\t   test \"$len\" -lt \"$max_cmd_len\"; then\n\t\t  func_append objlist \" $obj\"\n\t\telse\n\t\t  # The command $test_cmds is almost too long, add a\n\t\t  # command to the queue.\n\t\t  if test \"$k\" -eq 1 ; then\n\t\t    # The first file doesn't have a previous command to add.\n\t\t    reload_objs=$objlist\n\t\t    eval concat_cmds=\\\"$reload_cmds\\\"\n\t\t  else\n\t\t    # All subsequent reloadable object files will link in\n\t\t    # the last one created.\n\t\t    reload_objs=\"$objlist $last_robj\"\n\t\t    eval concat_cmds=\\\"\\$concat_cmds~$reload_cmds~\\$RM $last_robj\\\"\n\t\t  fi\n\t\t  last_robj=$output_objdir/$output_la-${k}.$objext\n\t\t  func_arith $k + 1\n\t\t  k=$func_arith_result\n\t\t  output=$output_objdir/$output_la-${k}.$objext\n\t\t  objlist=\" $obj\"\n\t\t  func_len \" $last_robj\"\n\t\t  func_arith $len0 + $func_len_result\n\t\t  len=$func_arith_result\n\t\tfi\n\t      done\n\t      # Handle the remaining objects by creating one last\n\t      # reloadable object file.  All subsequent reloadable object\n\t      # files will link in the last one created.\n\t      test -z \"$concat_cmds\" || concat_cmds=$concat_cmds~\n\t      reload_objs=\"$objlist $last_robj\"\n\t      eval concat_cmds=\\\"\\${concat_cmds}$reload_cmds\\\"\n\t      if test -n \"$last_robj\"; then\n\t        eval concat_cmds=\\\"\\${concat_cmds}~\\$RM $last_robj\\\"\n\t      fi\n\t      func_append delfiles \" $output\"\n\n\t    else\n\t      output=\n\t    fi\n\n\t    if ${skipped_export-false}; then\n\t      func_verbose \"generating symbol list for \\`$libname.la'\"\n\t      export_symbols=\"$output_objdir/$libname.exp\"\n\t      $opt_dry_run || $RM $export_symbols\n\t      libobjs=$output\n\t      # Append the command to create the export file.\n\t      test -z \"$concat_cmds\" || concat_cmds=$concat_cmds~\n\t      eval concat_cmds=\\\"\\$concat_cmds$export_symbols_cmds\\\"\n\t      if test -n \"$last_robj\"; then\n\t\teval concat_cmds=\\\"\\$concat_cmds~\\$RM $last_robj\\\"\n\t      fi\n\t    fi\n\n\t    test -n \"$save_libobjs\" &&\n\t      func_verbose \"creating a temporary reloadable object file: $output\"\n\n\t    # Loop through the commands generated above and execute them.\n\t    save_ifs=\"$IFS\"; IFS='~'\n\t    for cmd in $concat_cmds; do\n\t      IFS=\"$save_ifs\"\n\t      $opt_silent || {\n\t\t  func_quote_for_expand \"$cmd\"\n\t\t  eval \"func_echo $func_quote_for_expand_result\"\n\t      }\n\t      $opt_dry_run || eval \"$cmd\" || {\n\t\tlt_exit=$?\n\n\t\t# Restore the uninstalled library and exit\n\t\tif test \"$opt_mode\" = relink; then\n\t\t  ( cd \"$output_objdir\" && \\\n\t\t    $RM \"${realname}T\" && \\\n\t\t    $MV \"${realname}U\" \"$realname\" )\n\t\tfi\n\n\t\texit $lt_exit\n\t      }\n\t    done\n\t    IFS=\"$save_ifs\"\n\n\t    if test -n \"$export_symbols_regex\" && ${skipped_export-false}; then\n\t      func_show_eval '$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"'\n\t      func_show_eval '$MV \"${export_symbols}T\" \"$export_symbols\"'\n\t    fi\n\t  fi\n\n          if ${skipped_export-false}; then\n\t    if test -n \"$export_symbols\" && test -n \"$include_expsyms\"; then\n\t      tmp_export_symbols=\"$export_symbols\"\n\t      test -n \"$orig_export_symbols\" && tmp_export_symbols=\"$orig_export_symbols\"\n\t      $opt_dry_run || eval '$ECHO \"$include_expsyms\" | $SP2NL >> \"$tmp_export_symbols\"'\n\t    fi\n\n\t    if test -n \"$orig_export_symbols\"; then\n\t      # The given exports_symbols file has to be filtered, so filter it.\n\t      func_verbose \"filter symbol list for \\`$libname.la' to tag DATA exports\"\n\t      # FIXME: $output_objdir/$libname.filter potentially contains lots of\n\t      # 's' commands which not all seds can handle. GNU sed should be fine\n\t      # though. Also, the filter scales superlinearly with the number of\n\t      # global variables. join(1) would be nice here, but unfortunately\n\t      # isn't a blessed tool.\n\t      $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\\(.*\\)\\([ \\,].*\\),s|^\\1$|\\1\\2|,' < $export_symbols > $output_objdir/$libname.filter\n\t      func_append delfiles \" $export_symbols $output_objdir/$libname.filter\"\n\t      export_symbols=$output_objdir/$libname.def\n\t      $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols\n\t    fi\n\t  fi\n\n\t  libobjs=$output\n\t  # Restore the value of output.\n\t  output=$save_output\n\n\t  if test -n \"$convenience\" && test -n \"$whole_archive_flag_spec\"; then\n\t    eval libobjs=\\\"\\$libobjs $whole_archive_flag_spec\\\"\n\t    test \"X$libobjs\" = \"X \" && libobjs=\n\t  fi\n\t  # Expand the library linking commands again to reset the\n\t  # value of $libobjs for piecewise linking.\n\n\t  # Do each of the archive commands.\n\t  if test \"$module\" = yes && test -n \"$module_cmds\" ; then\n\t    if test -n \"$export_symbols\" && test -n \"$module_expsym_cmds\"; then\n\t      cmds=$module_expsym_cmds\n\t    else\n\t      cmds=$module_cmds\n\t    fi\n\t  else\n\t    if test -n \"$export_symbols\" && test -n \"$archive_expsym_cmds\"; then\n\t      cmds=$archive_expsym_cmds\n\t    else\n\t      cmds=$archive_cmds\n\t    fi\n\t  fi\n\tfi\n\n\tif test -n \"$delfiles\"; then\n\t  # Append the command to remove temporary files to $cmds.\n\t  eval cmds=\\\"\\$cmds~\\$RM $delfiles\\\"\n\tfi\n\n\t# Add any objects from preloaded convenience libraries\n\tif test -n \"$dlprefiles\"; then\n\t  gentop=\"$output_objdir/${outputname}x\"\n\t  func_append generated \" $gentop\"\n\n\t  func_extract_archives $gentop $dlprefiles\n\t  func_append libobjs \" $func_extract_archives_result\"\n\t  test \"X$libobjs\" = \"X \" && libobjs=\n\tfi\n\n\tsave_ifs=\"$IFS\"; IFS='~'\n\tfor cmd in $cmds; do\n\t  IFS=\"$save_ifs\"\n\t  eval cmd=\\\"$cmd\\\"\n\t  $opt_silent || {\n\t    func_quote_for_expand \"$cmd\"\n\t    eval \"func_echo $func_quote_for_expand_result\"\n\t  }\n\t  $opt_dry_run || eval \"$cmd\" || {\n\t    lt_exit=$?\n\n\t    # Restore the uninstalled library and exit\n\t    if test \"$opt_mode\" = relink; then\n\t      ( cd \"$output_objdir\" && \\\n\t        $RM \"${realname}T\" && \\\n\t\t$MV \"${realname}U\" \"$realname\" )\n\t    fi\n\n\t    exit $lt_exit\n\t  }\n\tdone\n\tIFS=\"$save_ifs\"\n\n\t# Restore the uninstalled library and exit\n\tif test \"$opt_mode\" = relink; then\n\t  $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?\n\n\t  if test -n \"$convenience\"; then\n\t    if test -z \"$whole_archive_flag_spec\"; then\n\t      func_show_eval '${RM}r \"$gentop\"'\n\t    fi\n\t  fi\n\n\t  exit $EXIT_SUCCESS\n\tfi\n\n\t# Create links to the real library.\n\tfor linkname in $linknames; do\n\t  if test \"$realname\" != \"$linkname\"; then\n\t    func_show_eval '(cd \"$output_objdir\" && $RM \"$linkname\" && $LN_S \"$realname\" \"$linkname\")' 'exit $?'\n\t  fi\n\tdone\n\n\t# If -module or -export-dynamic was specified, set the dlname.\n\tif test \"$module\" = yes || test \"$export_dynamic\" = yes; then\n\t  # On all known operating systems, these are identical.\n\t  dlname=\"$soname\"\n\tfi\n      fi\n      ;;\n\n    obj)\n      if test -n \"$dlfiles$dlprefiles\" || test \"$dlself\" != no; then\n\tfunc_warning \"\\`-dlopen' is ignored for objects\"\n      fi\n\n      case \" $deplibs\" in\n      *\\ -l* | *\\ -L*)\n\tfunc_warning \"\\`-l' and \\`-L' are ignored for objects\" ;;\n      esac\n\n      test -n \"$rpath\" && \\\n\tfunc_warning \"\\`-rpath' is ignored for objects\"\n\n      test -n \"$xrpath\" && \\\n\tfunc_warning \"\\`-R' is ignored for objects\"\n\n      test -n \"$vinfo\" && \\\n\tfunc_warning \"\\`-version-info' is ignored for objects\"\n\n      test -n \"$release\" && \\\n\tfunc_warning \"\\`-release' is ignored for objects\"\n\n      case $output in\n      *.lo)\n\ttest -n \"$objs$old_deplibs\" && \\\n\t  func_fatal_error \"cannot build library object \\`$output' from non-libtool objects\"\n\n\tlibobj=$output\n\tfunc_lo2o \"$libobj\"\n\tobj=$func_lo2o_result\n\t;;\n      *)\n\tlibobj=\n\tobj=\"$output\"\n\t;;\n      esac\n\n      # Delete the old objects.\n      $opt_dry_run || $RM $obj $libobj\n\n      # Objects from convenience libraries.  This assumes\n      # single-version convenience libraries.  Whenever we create\n      # different ones for PIC/non-PIC, this we'll have to duplicate\n      # the extraction.\n      reload_conv_objs=\n      gentop=\n      # reload_cmds runs $LD directly, so let us get rid of\n      # -Wl from whole_archive_flag_spec and hope we can get by with\n      # turning comma into space..\n      wl=\n\n      if test -n \"$convenience\"; then\n\tif test -n \"$whole_archive_flag_spec\"; then\n\t  eval tmp_whole_archive_flags=\\\"$whole_archive_flag_spec\\\"\n\t  reload_conv_objs=$reload_objs\\ `$ECHO \"$tmp_whole_archive_flags\" | $SED 's|,| |g'`\n\telse\n\t  gentop=\"$output_objdir/${obj}x\"\n\t  func_append generated \" $gentop\"\n\n\t  func_extract_archives $gentop $convenience\n\t  reload_conv_objs=\"$reload_objs $func_extract_archives_result\"\n\tfi\n      fi\n\n      # If we're not building shared, we need to use non_pic_objs\n      test \"$build_libtool_libs\" != yes && libobjs=\"$non_pic_objects\"\n\n      # Create the old-style object.\n      reload_objs=\"$objs$old_deplibs \"`$ECHO \"$libobjs\" | $SP2NL | $SED \"/\\.${libext}$/d; /\\.lib$/d; $lo2o\" | $NL2SP`\" $reload_conv_objs\" ### testsuite: skip nested quoting test\n\n      output=\"$obj\"\n      func_execute_cmds \"$reload_cmds\" 'exit $?'\n\n      # Exit if we aren't doing a library object file.\n      if test -z \"$libobj\"; then\n\tif test -n \"$gentop\"; then\n\t  func_show_eval '${RM}r \"$gentop\"'\n\tfi\n\n\texit $EXIT_SUCCESS\n      fi\n\n      if test \"$build_libtool_libs\" != yes; then\n\tif test -n \"$gentop\"; then\n\t  func_show_eval '${RM}r \"$gentop\"'\n\tfi\n\n\t# Create an invalid libtool object if no PIC, so that we don't\n\t# accidentally link it into a program.\n\t# $show \"echo timestamp > $libobj\"\n\t# $opt_dry_run || eval \"echo timestamp > $libobj\" || exit $?\n\texit $EXIT_SUCCESS\n      fi\n\n      if test -n \"$pic_flag\" || test \"$pic_mode\" != default; then\n\t# Only do commands if we really have different PIC objects.\n\treload_objs=\"$libobjs $reload_conv_objs\"\n\toutput=\"$libobj\"\n\tfunc_execute_cmds \"$reload_cmds\" 'exit $?'\n      fi\n\n      if test -n \"$gentop\"; then\n\tfunc_show_eval '${RM}r \"$gentop\"'\n      fi\n\n      exit $EXIT_SUCCESS\n      ;;\n\n    prog)\n      case $host in\n\t*cygwin*) func_stripname '' '.exe' \"$output\"\n\t          output=$func_stripname_result.exe;;\n      esac\n      test -n \"$vinfo\" && \\\n\tfunc_warning \"\\`-version-info' is ignored for programs\"\n\n      test -n \"$release\" && \\\n\tfunc_warning \"\\`-release' is ignored for programs\"\n\n      test \"$preload\" = yes \\\n        && test \"$dlopen_support\" = unknown \\\n\t&& test \"$dlopen_self\" = unknown \\\n\t&& test \"$dlopen_self_static\" = unknown && \\\n\t  func_warning \"\\`LT_INIT([dlopen])' not used. Assuming no dlopen support.\"\n\n      case $host in\n      *-*-rhapsody* | *-*-darwin1.[012])\n\t# On Rhapsody replace the C library is the System framework\n\tcompile_deplibs=`$ECHO \" $compile_deplibs\" | $SED 's/ -lc / System.ltframework /'`\n\tfinalize_deplibs=`$ECHO \" $finalize_deplibs\" | $SED 's/ -lc / System.ltframework /'`\n\t;;\n      esac\n\n      case $host in\n      *-*-darwin*)\n\t# Don't allow lazy linking, it breaks C++ global constructors\n\t# But is supposedly fixed on 10.4 or later (yay!).\n\tif test \"$tagname\" = CXX ; then\n\t  case ${MACOSX_DEPLOYMENT_TARGET-10.0} in\n\t    10.[0123])\n\t      func_append compile_command \" ${wl}-bind_at_load\"\n\t      func_append finalize_command \" ${wl}-bind_at_load\"\n\t    ;;\n\t  esac\n\tfi\n\t# Time to change all our \"foo.ltframework\" stuff back to \"-framework foo\"\n\tcompile_deplibs=`$ECHO \" $compile_deplibs\" | $SED 's% \\([^ $]*\\).ltframework% -framework \\1%g'`\n\tfinalize_deplibs=`$ECHO \" $finalize_deplibs\" | $SED 's% \\([^ $]*\\).ltframework% -framework \\1%g'`\n\t;;\n      esac\n\n\n      # move library search paths that coincide with paths to not yet\n      # installed libraries to the beginning of the library search list\n      new_libs=\n      for path in $notinst_path; do\n\tcase \" $new_libs \" in\n\t*\" -L$path/$objdir \"*) ;;\n\t*)\n\t  case \" $compile_deplibs \" in\n\t  *\" -L$path/$objdir \"*)\n\t    func_append new_libs \" -L$path/$objdir\" ;;\n\t  esac\n\t  ;;\n\tesac\n      done\n      for deplib in $compile_deplibs; do\n\tcase $deplib in\n\t-L*)\n\t  case \" $new_libs \" in\n\t  *\" $deplib \"*) ;;\n\t  *) func_append new_libs \" $deplib\" ;;\n\t  esac\n\t  ;;\n\t*) func_append new_libs \" $deplib\" ;;\n\tesac\n      done\n      compile_deplibs=\"$new_libs\"\n\n\n      func_append compile_command \" $compile_deplibs\"\n      func_append finalize_command \" $finalize_deplibs\"\n\n      if test -n \"$rpath$xrpath\"; then\n\t# If the user specified any rpath flags, then add them.\n\tfor libdir in $rpath $xrpath; do\n\t  # This is the magic to use -rpath.\n\t  case \"$finalize_rpath \" in\n\t  *\" $libdir \"*) ;;\n\t  *) func_append finalize_rpath \" $libdir\" ;;\n\t  esac\n\tdone\n      fi\n\n      # Now hardcode the library paths\n      rpath=\n      hardcode_libdirs=\n      for libdir in $compile_rpath $finalize_rpath; do\n\tif test -n \"$hardcode_libdir_flag_spec\"; then\n\t  if test -n \"$hardcode_libdir_separator\"; then\n\t    if test -z \"$hardcode_libdirs\"; then\n\t      hardcode_libdirs=\"$libdir\"\n\t    else\n\t      # Just accumulate the unique libdirs.\n\t      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in\n\t      *\"$hardcode_libdir_separator$libdir$hardcode_libdir_separator\"*)\n\t\t;;\n\t      *)\n\t\tfunc_append hardcode_libdirs \"$hardcode_libdir_separator$libdir\"\n\t\t;;\n\t      esac\n\t    fi\n\t  else\n\t    eval flag=\\\"$hardcode_libdir_flag_spec\\\"\n\t    func_append rpath \" $flag\"\n\t  fi\n\telif test -n \"$runpath_var\"; then\n\t  case \"$perm_rpath \" in\n\t  *\" $libdir \"*) ;;\n\t  *) func_append perm_rpath \" $libdir\" ;;\n\t  esac\n\tfi\n\tcase $host in\n\t*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)\n\t  testbindir=`${ECHO} \"$libdir\" | ${SED} -e 's*/lib$*/bin*'`\n\t  case :$dllsearchpath: in\n\t  *\":$libdir:\"*) ;;\n\t  ::) dllsearchpath=$libdir;;\n\t  *) func_append dllsearchpath \":$libdir\";;\n\t  esac\n\t  case :$dllsearchpath: in\n\t  *\":$testbindir:\"*) ;;\n\t  ::) dllsearchpath=$testbindir;;\n\t  *) func_append dllsearchpath \":$testbindir\";;\n\t  esac\n\t  ;;\n\tesac\n      done\n      # Substitute the hardcoded libdirs into the rpath.\n      if test -n \"$hardcode_libdir_separator\" &&\n\t test -n \"$hardcode_libdirs\"; then\n\tlibdir=\"$hardcode_libdirs\"\n\teval rpath=\\\" $hardcode_libdir_flag_spec\\\"\n      fi\n      compile_rpath=\"$rpath\"\n\n      rpath=\n      hardcode_libdirs=\n      for libdir in $finalize_rpath; do\n\tif test -n \"$hardcode_libdir_flag_spec\"; then\n\t  if test -n \"$hardcode_libdir_separator\"; then\n\t    if test -z \"$hardcode_libdirs\"; then\n\t      hardcode_libdirs=\"$libdir\"\n\t    else\n\t      # Just accumulate the unique libdirs.\n\t      case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in\n\t      *\"$hardcode_libdir_separator$libdir$hardcode_libdir_separator\"*)\n\t\t;;\n\t      *)\n\t\tfunc_append hardcode_libdirs \"$hardcode_libdir_separator$libdir\"\n\t\t;;\n\t      esac\n\t    fi\n\t  else\n\t    eval flag=\\\"$hardcode_libdir_flag_spec\\\"\n\t    func_append rpath \" $flag\"\n\t  fi\n\telif test -n \"$runpath_var\"; then\n\t  case \"$finalize_perm_rpath \" in\n\t  *\" $libdir \"*) ;;\n\t  *) func_append finalize_perm_rpath \" $libdir\" ;;\n\t  esac\n\tfi\n      done\n      # Substitute the hardcoded libdirs into the rpath.\n      if test -n \"$hardcode_libdir_separator\" &&\n\t test -n \"$hardcode_libdirs\"; then\n\tlibdir=\"$hardcode_libdirs\"\n\teval rpath=\\\" $hardcode_libdir_flag_spec\\\"\n      fi\n      finalize_rpath=\"$rpath\"\n\n      if test -n \"$libobjs\" && test \"$build_old_libs\" = yes; then\n\t# Transform all the library objects into standard objects.\n\tcompile_command=`$ECHO \"$compile_command\" | $SP2NL | $SED \"$lo2o\" | $NL2SP`\n\tfinalize_command=`$ECHO \"$finalize_command\" | $SP2NL | $SED \"$lo2o\" | $NL2SP`\n      fi\n\n      func_generate_dlsyms \"$outputname\" \"@PROGRAM@\" \"no\"\n\n      # template prelinking step\n      if test -n \"$prelink_cmds\"; then\n\tfunc_execute_cmds \"$prelink_cmds\" 'exit $?'\n      fi\n\n      wrappers_required=yes\n      case $host in\n      *cegcc* | *mingw32ce*)\n        # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.\n        wrappers_required=no\n        ;;\n      *cygwin* | *mingw* )\n        if test \"$build_libtool_libs\" != yes; then\n          wrappers_required=no\n        fi\n        ;;\n      *)\n        if test \"$need_relink\" = no || test \"$build_libtool_libs\" != yes; then\n          wrappers_required=no\n        fi\n        ;;\n      esac\n      if test \"$wrappers_required\" = no; then\n\t# Replace the output file specification.\n\tcompile_command=`$ECHO \"$compile_command\" | $SED 's%@OUTPUT@%'\"$output\"'%g'`\n\tlink_command=\"$compile_command$compile_rpath\"\n\n\t# We have no uninstalled library dependencies, so finalize right now.\n\texit_status=0\n\tfunc_show_eval \"$link_command\" 'exit_status=$?'\n\n\tif test -n \"$postlink_cmds\"; then\n\t  func_to_tool_file \"$output\"\n\t  postlink_cmds=`func_echo_all \"$postlink_cmds\" | $SED -e 's%@OUTPUT@%'\"$output\"'%g' -e 's%@TOOL_OUTPUT@%'\"$func_to_tool_file_result\"'%g'`\n\t  func_execute_cmds \"$postlink_cmds\" 'exit $?'\n\tfi\n\n\t# Delete the generated files.\n\tif test -f \"$output_objdir/${outputname}S.${objext}\"; then\n\t  func_show_eval '$RM \"$output_objdir/${outputname}S.${objext}\"'\n\tfi\n\n\texit $exit_status\n      fi\n\n      if test -n \"$compile_shlibpath$finalize_shlibpath\"; then\n\tcompile_command=\"$shlibpath_var=\\\"$compile_shlibpath$finalize_shlibpath\\$$shlibpath_var\\\" $compile_command\"\n      fi\n      if test -n \"$finalize_shlibpath\"; then\n\tfinalize_command=\"$shlibpath_var=\\\"$finalize_shlibpath\\$$shlibpath_var\\\" $finalize_command\"\n      fi\n\n      compile_var=\n      finalize_var=\n      if test -n \"$runpath_var\"; then\n\tif test -n \"$perm_rpath\"; then\n\t  # We should set the runpath_var.\n\t  rpath=\n\t  for dir in $perm_rpath; do\n\t    func_append rpath \"$dir:\"\n\t  done\n\t  compile_var=\"$runpath_var=\\\"$rpath\\$$runpath_var\\\" \"\n\tfi\n\tif test -n \"$finalize_perm_rpath\"; then\n\t  # We should set the runpath_var.\n\t  rpath=\n\t  for dir in $finalize_perm_rpath; do\n\t    func_append rpath \"$dir:\"\n\t  done\n\t  finalize_var=\"$runpath_var=\\\"$rpath\\$$runpath_var\\\" \"\n\tfi\n      fi\n\n      if test \"$no_install\" = yes; then\n\t# We don't need to create a wrapper script.\n\tlink_command=\"$compile_var$compile_command$compile_rpath\"\n\t# Replace the output file specification.\n\tlink_command=`$ECHO \"$link_command\" | $SED 's%@OUTPUT@%'\"$output\"'%g'`\n\t# Delete the old output file.\n\t$opt_dry_run || $RM $output\n\t# Link the executable and exit\n\tfunc_show_eval \"$link_command\" 'exit $?'\n\n\tif test -n \"$postlink_cmds\"; then\n\t  func_to_tool_file \"$output\"\n\t  postlink_cmds=`func_echo_all \"$postlink_cmds\" | $SED -e 's%@OUTPUT@%'\"$output\"'%g' -e 's%@TOOL_OUTPUT@%'\"$func_to_tool_file_result\"'%g'`\n\t  func_execute_cmds \"$postlink_cmds\" 'exit $?'\n\tfi\n\n\texit $EXIT_SUCCESS\n      fi\n\n      if test \"$hardcode_action\" = relink; then\n\t# Fast installation is not supported\n\tlink_command=\"$compile_var$compile_command$compile_rpath\"\n\trelink_command=\"$finalize_var$finalize_command$finalize_rpath\"\n\n\tfunc_warning \"this platform does not like uninstalled shared libraries\"\n\tfunc_warning \"\\`$output' will be relinked during installation\"\n      else\n\tif test \"$fast_install\" != no; then\n\t  link_command=\"$finalize_var$compile_command$finalize_rpath\"\n\t  if test \"$fast_install\" = yes; then\n\t    relink_command=`$ECHO \"$compile_var$compile_command$compile_rpath\" | $SED 's%@OUTPUT@%\\$progdir/\\$file%g'`\n\t  else\n\t    # fast_install is set to needless\n\t    relink_command=\n\t  fi\n\telse\n\t  link_command=\"$compile_var$compile_command$compile_rpath\"\n\t  relink_command=\"$finalize_var$finalize_command$finalize_rpath\"\n\tfi\n      fi\n\n      # Replace the output file specification.\n      link_command=`$ECHO \"$link_command\" | $SED 's%@OUTPUT@%'\"$output_objdir/$outputname\"'%g'`\n\n      # Delete the old output files.\n      $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname\n\n      func_show_eval \"$link_command\" 'exit $?'\n\n      if test -n \"$postlink_cmds\"; then\n\tfunc_to_tool_file \"$output_objdir/$outputname\"\n\tpostlink_cmds=`func_echo_all \"$postlink_cmds\" | $SED -e 's%@OUTPUT@%'\"$output_objdir/$outputname\"'%g' -e 's%@TOOL_OUTPUT@%'\"$func_to_tool_file_result\"'%g'`\n\tfunc_execute_cmds \"$postlink_cmds\" 'exit $?'\n      fi\n\n      # Now create the wrapper script.\n      func_verbose \"creating $output\"\n\n      # Quote the relink command for shipping.\n      if test -n \"$relink_command\"; then\n\t# Preserve any variables that may affect compiler behavior\n\tfor var in $variables_saved_for_relink; do\n\t  if eval test -z \\\"\\${$var+set}\\\"; then\n\t    relink_command=\"{ test -z \\\"\\${$var+set}\\\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command\"\n\t  elif eval var_value=\\$$var; test -z \"$var_value\"; then\n\t    relink_command=\"$var=; export $var; $relink_command\"\n\t  else\n\t    func_quote_for_eval \"$var_value\"\n\t    relink_command=\"$var=$func_quote_for_eval_result; export $var; $relink_command\"\n\t  fi\n\tdone\n\trelink_command=\"(cd `pwd`; $relink_command)\"\n\trelink_command=`$ECHO \"$relink_command\" | $SED \"$sed_quote_subst\"`\n      fi\n\n      # Only actually do things if not in dry run mode.\n      $opt_dry_run || {\n\t# win32 will think the script is a binary if it has\n\t# a .exe suffix, so we strip it off here.\n\tcase $output in\n\t  *.exe) func_stripname '' '.exe' \"$output\"\n\t         output=$func_stripname_result ;;\n\tesac\n\t# test for cygwin because mv fails w/o .exe extensions\n\tcase $host in\n\t  *cygwin*)\n\t    exeext=.exe\n\t    func_stripname '' '.exe' \"$outputname\"\n\t    outputname=$func_stripname_result ;;\n\t  *) exeext= ;;\n\tesac\n\tcase $host in\n\t  *cygwin* | *mingw* )\n\t    func_dirname_and_basename \"$output\" \"\" \".\"\n\t    output_name=$func_basename_result\n\t    output_path=$func_dirname_result\n\t    cwrappersource=\"$output_path/$objdir/lt-$output_name.c\"\n\t    cwrapper=\"$output_path/$output_name.exe\"\n\t    $RM $cwrappersource $cwrapper\n\t    trap \"$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE\" 1 2 15\n\n\t    func_emit_cwrapperexe_src > $cwrappersource\n\n\t    # The wrapper executable is built using the $host compiler,\n\t    # because it contains $host paths and files. If cross-\n\t    # compiling, it, like the target executable, must be\n\t    # executed on the $host or under an emulation environment.\n\t    $opt_dry_run || {\n\t      $LTCC $LTCFLAGS -o $cwrapper $cwrappersource\n\t      $STRIP $cwrapper\n\t    }\n\n\t    # Now, create the wrapper script for func_source use:\n\t    func_ltwrapper_scriptname $cwrapper\n\t    $RM $func_ltwrapper_scriptname_result\n\t    trap \"$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE\" 1 2 15\n\t    $opt_dry_run || {\n\t      # note: this script will not be executed, so do not chmod.\n\t      if test \"x$build\" = \"x$host\" ; then\n\t\t$cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result\n\t      else\n\t\tfunc_emit_wrapper no > $func_ltwrapper_scriptname_result\n\t      fi\n\t    }\n\t  ;;\n\t  * )\n\t    $RM $output\n\t    trap \"$RM $output; exit $EXIT_FAILURE\" 1 2 15\n\n\t    func_emit_wrapper no > $output\n\t    chmod +x $output\n\t  ;;\n\tesac\n      }\n      exit $EXIT_SUCCESS\n      ;;\n    esac\n\n    # See if we need to build an old-fashioned archive.\n    for oldlib in $oldlibs; do\n\n      if test \"$build_libtool_libs\" = convenience; then\n\toldobjs=\"$libobjs_save $symfileobj\"\n\taddlibs=\"$convenience\"\n\tbuild_libtool_libs=no\n      else\n\tif test \"$build_libtool_libs\" = module; then\n\t  oldobjs=\"$libobjs_save\"\n\t  build_libtool_libs=no\n\telse\n\t  oldobjs=\"$old_deplibs $non_pic_objects\"\n\t  if test \"$preload\" = yes && test -f \"$symfileobj\"; then\n\t    func_append oldobjs \" $symfileobj\"\n\t  fi\n\tfi\n\taddlibs=\"$old_convenience\"\n      fi\n\n      if test -n \"$addlibs\"; then\n\tgentop=\"$output_objdir/${outputname}x\"\n\tfunc_append generated \" $gentop\"\n\n\tfunc_extract_archives $gentop $addlibs\n\tfunc_append oldobjs \" $func_extract_archives_result\"\n      fi\n\n      # Do each command in the archive commands.\n      if test -n \"$old_archive_from_new_cmds\" && test \"$build_libtool_libs\" = yes; then\n\tcmds=$old_archive_from_new_cmds\n      else\n\n\t# Add any objects from preloaded convenience libraries\n\tif test -n \"$dlprefiles\"; then\n\t  gentop=\"$output_objdir/${outputname}x\"\n\t  func_append generated \" $gentop\"\n\n\t  func_extract_archives $gentop $dlprefiles\n\t  func_append oldobjs \" $func_extract_archives_result\"\n\tfi\n\n\t# POSIX demands no paths to be encoded in archives.  We have\n\t# to avoid creating archives with duplicate basenames if we\n\t# might have to extract them afterwards, e.g., when creating a\n\t# static archive out of a convenience library, or when linking\n\t# the entirety of a libtool archive into another (currently\n\t# not supported by libtool).\n\tif (for obj in $oldobjs\n\t    do\n\t      func_basename \"$obj\"\n\t      $ECHO \"$func_basename_result\"\n\t    done | sort | sort -uc >/dev/null 2>&1); then\n\t  :\n\telse\n\t  echo \"copying selected object files to avoid basename conflicts...\"\n\t  gentop=\"$output_objdir/${outputname}x\"\n\t  func_append generated \" $gentop\"\n\t  func_mkdir_p \"$gentop\"\n\t  save_oldobjs=$oldobjs\n\t  oldobjs=\n\t  counter=1\n\t  for obj in $save_oldobjs\n\t  do\n\t    func_basename \"$obj\"\n\t    objbase=\"$func_basename_result\"\n\t    case \" $oldobjs \" in\n\t    \" \") oldobjs=$obj ;;\n\t    *[\\ /]\"$objbase \"*)\n\t      while :; do\n\t\t# Make sure we don't pick an alternate name that also\n\t\t# overlaps.\n\t\tnewobj=lt$counter-$objbase\n\t\tfunc_arith $counter + 1\n\t\tcounter=$func_arith_result\n\t\tcase \" $oldobjs \" in\n\t\t*[\\ /]\"$newobj \"*) ;;\n\t\t*) if test ! -f \"$gentop/$newobj\"; then break; fi ;;\n\t\tesac\n\t      done\n\t      func_show_eval \"ln $obj $gentop/$newobj || cp $obj $gentop/$newobj\"\n\t      func_append oldobjs \" $gentop/$newobj\"\n\t      ;;\n\t    *) func_append oldobjs \" $obj\" ;;\n\t    esac\n\t  done\n\tfi\n\tfunc_to_tool_file \"$oldlib\" func_convert_file_msys_to_w32\n\ttool_oldlib=$func_to_tool_file_result\n\teval cmds=\\\"$old_archive_cmds\\\"\n\n\tfunc_len \" $cmds\"\n\tlen=$func_len_result\n\tif test \"$len\" -lt \"$max_cmd_len\" || test \"$max_cmd_len\" -le -1; then\n\t  cmds=$old_archive_cmds\n\telif test -n \"$archiver_list_spec\"; then\n\t  func_verbose \"using command file archive linking...\"\n\t  for obj in $oldobjs\n\t  do\n\t    func_to_tool_file \"$obj\"\n\t    $ECHO \"$func_to_tool_file_result\"\n\t  done > $output_objdir/$libname.libcmd\n\t  func_to_tool_file \"$output_objdir/$libname.libcmd\"\n\t  oldobjs=\" $archiver_list_spec$func_to_tool_file_result\"\n\t  cmds=$old_archive_cmds\n\telse\n\t  # the command line is too long to link in one step, link in parts\n\t  func_verbose \"using piecewise archive linking...\"\n\t  save_RANLIB=$RANLIB\n\t  RANLIB=:\n\t  objlist=\n\t  concat_cmds=\n\t  save_oldobjs=$oldobjs\n\t  oldobjs=\n\t  # Is there a better way of finding the last object in the list?\n\t  for obj in $save_oldobjs\n\t  do\n\t    last_oldobj=$obj\n\t  done\n\t  eval test_cmds=\\\"$old_archive_cmds\\\"\n\t  func_len \" $test_cmds\"\n\t  len0=$func_len_result\n\t  len=$len0\n\t  for obj in $save_oldobjs\n\t  do\n\t    func_len \" $obj\"\n\t    func_arith $len + $func_len_result\n\t    len=$func_arith_result\n\t    func_append objlist \" $obj\"\n\t    if test \"$len\" -lt \"$max_cmd_len\"; then\n\t      :\n\t    else\n\t      # the above command should be used before it gets too long\n\t      oldobjs=$objlist\n\t      if test \"$obj\" = \"$last_oldobj\" ; then\n\t\tRANLIB=$save_RANLIB\n\t      fi\n\t      test -z \"$concat_cmds\" || concat_cmds=$concat_cmds~\n\t      eval concat_cmds=\\\"\\${concat_cmds}$old_archive_cmds\\\"\n\t      objlist=\n\t      len=$len0\n\t    fi\n\t  done\n\t  RANLIB=$save_RANLIB\n\t  oldobjs=$objlist\n\t  if test \"X$oldobjs\" = \"X\" ; then\n\t    eval cmds=\\\"\\$concat_cmds\\\"\n\t  else\n\t    eval cmds=\\\"\\$concat_cmds~\\$old_archive_cmds\\\"\n\t  fi\n\tfi\n      fi\n      func_execute_cmds \"$cmds\" 'exit $?'\n    done\n\n    test -n \"$generated\" && \\\n      func_show_eval \"${RM}r$generated\"\n\n    # Now create the libtool archive.\n    case $output in\n    *.la)\n      old_library=\n      test \"$build_old_libs\" = yes && old_library=\"$libname.$libext\"\n      func_verbose \"creating $output\"\n\n      # Preserve any variables that may affect compiler behavior\n      for var in $variables_saved_for_relink; do\n\tif eval test -z \\\"\\${$var+set}\\\"; then\n\t  relink_command=\"{ test -z \\\"\\${$var+set}\\\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command\"\n\telif eval var_value=\\$$var; test -z \"$var_value\"; then\n\t  relink_command=\"$var=; export $var; $relink_command\"\n\telse\n\t  func_quote_for_eval \"$var_value\"\n\t  relink_command=\"$var=$func_quote_for_eval_result; export $var; $relink_command\"\n\tfi\n      done\n      # Quote the link command for shipping.\n      relink_command=\"(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)\"\n      relink_command=`$ECHO \"$relink_command\" | $SED \"$sed_quote_subst\"`\n      if test \"$hardcode_automatic\" = yes ; then\n\trelink_command=\n      fi\n\n      # Only create the output if not a dry run.\n      $opt_dry_run || {\n\tfor installed in no yes; do\n\t  if test \"$installed\" = yes; then\n\t    if test -z \"$install_libdir\"; then\n\t      break\n\t    fi\n\t    output=\"$output_objdir/$outputname\"i\n\t    # Replace all uninstalled libtool libraries with the installed ones\n\t    newdependency_libs=\n\t    for deplib in $dependency_libs; do\n\t      case $deplib in\n\t      *.la)\n\t\tfunc_basename \"$deplib\"\n\t\tname=\"$func_basename_result\"\n\t\tfunc_resolve_sysroot \"$deplib\"\n\t\teval libdir=`${SED} -n -e 's/^libdir=\\(.*\\)$/\\1/p' $func_resolve_sysroot_result`\n\t\ttest -z \"$libdir\" && \\\n\t\t  func_fatal_error \"\\`$deplib' is not a valid libtool archive\"\n\t\tfunc_append newdependency_libs \" ${lt_sysroot:+=}$libdir/$name\"\n\t\t;;\n\t      -L*)\n\t\tfunc_stripname -L '' \"$deplib\"\n\t\tfunc_replace_sysroot \"$func_stripname_result\"\n\t\tfunc_append newdependency_libs \" -L$func_replace_sysroot_result\"\n\t\t;;\n\t      -R*)\n\t\tfunc_stripname -R '' \"$deplib\"\n\t\tfunc_replace_sysroot \"$func_stripname_result\"\n\t\tfunc_append newdependency_libs \" -R$func_replace_sysroot_result\"\n\t\t;;\n\t      *) func_append newdependency_libs \" $deplib\" ;;\n\t      esac\n\t    done\n\t    dependency_libs=\"$newdependency_libs\"\n\t    newdlfiles=\n\n\t    for lib in $dlfiles; do\n\t      case $lib in\n\t      *.la)\n\t        func_basename \"$lib\"\n\t\tname=\"$func_basename_result\"\n\t\teval libdir=`${SED} -n -e 's/^libdir=\\(.*\\)$/\\1/p' $lib`\n\t\ttest -z \"$libdir\" && \\\n\t\t  func_fatal_error \"\\`$lib' is not a valid libtool archive\"\n\t\tfunc_append newdlfiles \" ${lt_sysroot:+=}$libdir/$name\"\n\t\t;;\n\t      *) func_append newdlfiles \" $lib\" ;;\n\t      esac\n\t    done\n\t    dlfiles=\"$newdlfiles\"\n\t    newdlprefiles=\n\t    for lib in $dlprefiles; do\n\t      case $lib in\n\t      *.la)\n\t\t# Only pass preopened files to the pseudo-archive (for\n\t\t# eventual linking with the app. that links it) if we\n\t\t# didn't already link the preopened objects directly into\n\t\t# the library:\n\t\tfunc_basename \"$lib\"\n\t\tname=\"$func_basename_result\"\n\t\teval libdir=`${SED} -n -e 's/^libdir=\\(.*\\)$/\\1/p' $lib`\n\t\ttest -z \"$libdir\" && \\\n\t\t  func_fatal_error \"\\`$lib' is not a valid libtool archive\"\n\t\tfunc_append newdlprefiles \" ${lt_sysroot:+=}$libdir/$name\"\n\t\t;;\n\t      esac\n\t    done\n\t    dlprefiles=\"$newdlprefiles\"\n\t  else\n\t    newdlfiles=\n\t    for lib in $dlfiles; do\n\t      case $lib in\n\t\t[\\\\/]* | [A-Za-z]:[\\\\/]*) abs=\"$lib\" ;;\n\t\t*) abs=`pwd`\"/$lib\" ;;\n\t      esac\n\t      func_append newdlfiles \" $abs\"\n\t    done\n\t    dlfiles=\"$newdlfiles\"\n\t    newdlprefiles=\n\t    for lib in $dlprefiles; do\n\t      case $lib in\n\t\t[\\\\/]* | [A-Za-z]:[\\\\/]*) abs=\"$lib\" ;;\n\t\t*) abs=`pwd`\"/$lib\" ;;\n\t      esac\n\t      func_append newdlprefiles \" $abs\"\n\t    done\n\t    dlprefiles=\"$newdlprefiles\"\n\t  fi\n\t  $RM $output\n\t  # place dlname in correct position for cygwin\n\t  # In fact, it would be nice if we could use this code for all target\n\t  # systems that can't hard-code library paths into their executables\n\t  # and that have no shared library path variable independent of PATH,\n\t  # but it turns out we can't easily determine that from inspecting\n\t  # libtool variables, so we have to hard-code the OSs to which it\n\t  # applies here; at the moment, that means platforms that use the PE\n\t  # object format with DLL files.  See the long comment at the top of\n\t  # tests/bindir.at for full details.\n\t  tdlname=$dlname\n\t  case $host,$output,$installed,$module,$dlname in\n\t    *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)\n\t      # If a -bindir argument was supplied, place the dll there.\n\t      if test \"x$bindir\" != x ;\n\t      then\n\t\tfunc_relative_path \"$install_libdir\" \"$bindir\"\n\t\ttdlname=$func_relative_path_result$dlname\n\t      else\n\t\t# Otherwise fall back on heuristic.\n\t\ttdlname=../bin/$dlname\n\t      fi\n\t      ;;\n\t  esac\n\t  $ECHO > $output \"\\\n# $outputname - a libtool library file\n# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION\n#\n# Please DO NOT delete this file!\n# It is necessary for linking the library.\n\n# The name that we can dlopen(3).\ndlname='$tdlname'\n\n# Names of this library.\nlibrary_names='$library_names'\n\n# The name of the static archive.\nold_library='$old_library'\n\n# Linker flags that can not go in dependency_libs.\ninherited_linker_flags='$new_inherited_linker_flags'\n\n# Libraries that this one depends upon.\ndependency_libs='$dependency_libs'\n\n# Names of additional weak libraries provided by this library\nweak_library_names='$weak_libs'\n\n# Version information for $libname.\ncurrent=$current\nage=$age\nrevision=$revision\n\n# Is this an already installed library?\ninstalled=$installed\n\n# Should we warn about portability when linking against -modules?\nshouldnotlink=$module\n\n# Files to dlopen/dlpreopen\ndlopen='$dlfiles'\ndlpreopen='$dlprefiles'\n\n# Directory that this library needs to be installed in:\nlibdir='$install_libdir'\"\n\t  if test \"$installed\" = no && test \"$need_relink\" = yes; then\n\t    $ECHO >> $output \"\\\nrelink_command=\\\"$relink_command\\\"\"\n\t  fi\n\tdone\n      }\n\n      # Do a symbolic link so that the libtool archive can be found in\n      # LD_LIBRARY_PATH before the program is installed.\n      func_show_eval '( cd \"$output_objdir\" && $RM \"$outputname\" && $LN_S \"../$outputname\" \"$outputname\" )' 'exit $?'\n      ;;\n    esac\n    exit $EXIT_SUCCESS\n}\n\n{ test \"$opt_mode\" = link || test \"$opt_mode\" = relink; } &&\n    func_mode_link ${1+\"$@\"}\n\n\n# func_mode_uninstall arg...\nfunc_mode_uninstall ()\n{\n    $opt_debug\n    RM=\"$nonopt\"\n    files=\n    rmforce=\n    exit_status=0\n\n    # This variable tells wrapper scripts just to set variables rather\n    # than running their programs.\n    libtool_install_magic=\"$magic\"\n\n    for arg\n    do\n      case $arg in\n      -f) func_append RM \" $arg\"; rmforce=yes ;;\n      -*) func_append RM \" $arg\" ;;\n      *) func_append files \" $arg\" ;;\n      esac\n    done\n\n    test -z \"$RM\" && \\\n      func_fatal_help \"you must specify an RM program\"\n\n    rmdirs=\n\n    for file in $files; do\n      func_dirname \"$file\" \"\" \".\"\n      dir=\"$func_dirname_result\"\n      if test \"X$dir\" = X.; then\n\todir=\"$objdir\"\n      else\n\todir=\"$dir/$objdir\"\n      fi\n      func_basename \"$file\"\n      name=\"$func_basename_result\"\n      test \"$opt_mode\" = uninstall && odir=\"$dir\"\n\n      # Remember odir for removal later, being careful to avoid duplicates\n      if test \"$opt_mode\" = clean; then\n\tcase \" $rmdirs \" in\n\t  *\" $odir \"*) ;;\n\t  *) func_append rmdirs \" $odir\" ;;\n\tesac\n      fi\n\n      # Don't error if the file doesn't exist and rm -f was used.\n      if { test -L \"$file\"; } >/dev/null 2>&1 ||\n\t { test -h \"$file\"; } >/dev/null 2>&1 ||\n\t test -f \"$file\"; then\n\t:\n      elif test -d \"$file\"; then\n\texit_status=1\n\tcontinue\n      elif test \"$rmforce\" = yes; then\n\tcontinue\n      fi\n\n      rmfiles=\"$file\"\n\n      case $name in\n      *.la)\n\t# Possibly a libtool archive, so verify it.\n\tif func_lalib_p \"$file\"; then\n\t  func_source $dir/$name\n\n\t  # Delete the libtool libraries and symlinks.\n\t  for n in $library_names; do\n\t    func_append rmfiles \" $odir/$n\"\n\t  done\n\t  test -n \"$old_library\" && func_append rmfiles \" $odir/$old_library\"\n\n\t  case \"$opt_mode\" in\n\t  clean)\n\t    case \" $library_names \" in\n\t    *\" $dlname \"*) ;;\n\t    *) test -n \"$dlname\" && func_append rmfiles \" $odir/$dlname\" ;;\n\t    esac\n\t    test -n \"$libdir\" && func_append rmfiles \" $odir/$name $odir/${name}i\"\n\t    ;;\n\t  uninstall)\n\t    if test -n \"$library_names\"; then\n\t      # Do each command in the postuninstall commands.\n\t      func_execute_cmds \"$postuninstall_cmds\" 'test \"$rmforce\" = yes || exit_status=1'\n\t    fi\n\n\t    if test -n \"$old_library\"; then\n\t      # Do each command in the old_postuninstall commands.\n\t      func_execute_cmds \"$old_postuninstall_cmds\" 'test \"$rmforce\" = yes || exit_status=1'\n\t    fi\n\t    # FIXME: should reinstall the best remaining shared library.\n\t    ;;\n\t  esac\n\tfi\n\t;;\n\n      *.lo)\n\t# Possibly a libtool object, so verify it.\n\tif func_lalib_p \"$file\"; then\n\n\t  # Read the .lo file\n\t  func_source $dir/$name\n\n\t  # Add PIC object to the list of files to remove.\n\t  if test -n \"$pic_object\" &&\n\t     test \"$pic_object\" != none; then\n\t    func_append rmfiles \" $dir/$pic_object\"\n\t  fi\n\n\t  # Add non-PIC object to the list of files to remove.\n\t  if test -n \"$non_pic_object\" &&\n\t     test \"$non_pic_object\" != none; then\n\t    func_append rmfiles \" $dir/$non_pic_object\"\n\t  fi\n\tfi\n\t;;\n\n      *)\n\tif test \"$opt_mode\" = clean ; then\n\t  noexename=$name\n\t  case $file in\n\t  *.exe)\n\t    func_stripname '' '.exe' \"$file\"\n\t    file=$func_stripname_result\n\t    func_stripname '' '.exe' \"$name\"\n\t    noexename=$func_stripname_result\n\t    # $file with .exe has already been added to rmfiles,\n\t    # add $file without .exe\n\t    func_append rmfiles \" $file\"\n\t    ;;\n\t  esac\n\t  # Do a test to see if this is a libtool program.\n\t  if func_ltwrapper_p \"$file\"; then\n\t    if func_ltwrapper_executable_p \"$file\"; then\n\t      func_ltwrapper_scriptname \"$file\"\n\t      relink_command=\n\t      func_source $func_ltwrapper_scriptname_result\n\t      func_append rmfiles \" $func_ltwrapper_scriptname_result\"\n\t    else\n\t      relink_command=\n\t      func_source $dir/$noexename\n\t    fi\n\n\t    # note $name still contains .exe if it was in $file originally\n\t    # as does the version of $file that was added into $rmfiles\n\t    func_append rmfiles \" $odir/$name $odir/${name}S.${objext}\"\n\t    if test \"$fast_install\" = yes && test -n \"$relink_command\"; then\n\t      func_append rmfiles \" $odir/lt-$name\"\n\t    fi\n\t    if test \"X$noexename\" != \"X$name\" ; then\n\t      func_append rmfiles \" $odir/lt-${noexename}.c\"\n\t    fi\n\t  fi\n\tfi\n\t;;\n      esac\n      func_show_eval \"$RM $rmfiles\" 'exit_status=1'\n    done\n\n    # Try to remove the ${objdir}s in the directories where we deleted files\n    for dir in $rmdirs; do\n      if test -d \"$dir\"; then\n\tfunc_show_eval \"rmdir $dir >/dev/null 2>&1\"\n      fi\n    done\n\n    exit $exit_status\n}\n\n{ test \"$opt_mode\" = uninstall || test \"$opt_mode\" = clean; } &&\n    func_mode_uninstall ${1+\"$@\"}\n\ntest -z \"$opt_mode\" && {\n  help=\"$generic_help\"\n  func_fatal_help \"you must specify a MODE\"\n}\n\ntest -z \"$exec_cmd\" && \\\n  func_fatal_help \"invalid operation mode \\`$opt_mode'\"\n\nif test -n \"$exec_cmd\"; then\n  eval exec \"$exec_cmd\"\n  exit $EXIT_FAILURE\nfi\n\nexit $exit_status\n\n\n# The TAGs below are defined such that we never get into a situation\n# in which we disable both kinds of libraries.  Given conflicting\n# choices, we go for a static library, that is the most portable,\n# since we can't tell whether shared libraries were disabled because\n# the user asked for that or because the platform doesn't support\n# them.  This is particularly important on AIX, because we don't\n# support having both static and shared libraries enabled at the same\n# time on that platform, so we default to a shared-only configuration.\n# If a disable-shared tag is given, we'll fallback to a static-only\n# configuration.  But we'll never go from static-only to shared-only.\n\n# ### BEGIN LIBTOOL TAG CONFIG: disable-shared\nbuild_libtool_libs=no\nbuild_old_libs=yes\n# ### END LIBTOOL TAG CONFIG: disable-shared\n\n# ### BEGIN LIBTOOL TAG CONFIG: disable-static\nbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`\n# ### END LIBTOOL TAG CONFIG: disable-static\n\n# Local Variables:\n# mode:shell-script\n# sh-indentation:2\n# End:\n# vi:sw=2\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/m4/ac_system_extensions.m4",
    "content": "dnl Provide AC_USE_SYSTEM_EXTENSIONS for old autoconf machines.\nAC_DEFUN([ACX_USE_SYSTEM_EXTENSIONS],[\n  ifdef([AC_USE_SYSTEM_EXTENSIONS],[\n    AC_USE_SYSTEM_EXTENSIONS\n  ],[\n    AC_BEFORE([$0], [AC_COMPILE_IFELSE])\n    AC_BEFORE([$0], [AC_RUN_IFELSE])\n\n    AC_REQUIRE([AC_GNU_SOURCE])\n    AC_REQUIRE([AC_AIX])\n    AC_REQUIRE([AC_MINIX])\n\n    AH_VERBATIM([__EXTENSIONS__],\n[/* Enable extensions on Solaris.  */\n#ifndef __EXTENSIONS__\n# undef __EXTENSIONS__\n#endif\n#ifndef _POSIX_PTHREAD_SEMANTICS\n# undef _POSIX_PTHREAD_SEMANTICS\n#endif\n#ifndef _TANDEM_SOURCE\n# undef _TANDEM_SOURCE\n#endif])\n    AC_CACHE_CHECK([whether it is safe to define __EXTENSIONS__],\n      [ac_cv_safe_to_define___extensions__],\n      [AC_COMPILE_IFELSE(\n         [AC_LANG_PROGRAM([\n#           define __EXTENSIONS__ 1\n            AC_INCLUDES_DEFAULT])],\n         [ac_cv_safe_to_define___extensions__=yes],\n         [ac_cv_safe_to_define___extensions__=no])])\n    test $ac_cv_safe_to_define___extensions__ = yes &&\n      AC_DEFINE([__EXTENSIONS__])\n    AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])\n    AC_DEFINE([_TANDEM_SOURCE])\n  ])\n])\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/m4/acx_check_suncc.m4",
    "content": "dnl Check for the presence of the Sun Studio compiler.\ndnl If Sun Studio compiler is found, set appropriate flags.\ndnl Additionally, Sun Studio doesn't default to 64-bit by itself,\ndnl nor does it automatically look in standard Solaris places for\ndnl 64-bit libs, so we must add those options and paths to the search\ndnl paths.\n\ndnl TODO(kenton):  This is pretty hacky.  It sets CXXFLAGS, which the autoconf\ndnl docs say should never be overridden except by the user.  It also isn't\ndnl cross-compile safe.  We should fix these problems, but since I don't have\ndnl Sun CC at my disposal for testing, someone else will have to do it.\n\nAC_DEFUN([ACX_CHECK_SUNCC],[\n\n  AC_LANG_PUSH([C++])\n  AC_CHECK_DECL([__SUNPRO_CC], [SUNCC=\"yes\"], [SUNCC=\"no\"])\n  AC_LANG_POP()\n\n\n  AC_ARG_ENABLE([64bit-solaris],\n    [AS_HELP_STRING([--disable-64bit-solaris],\n      [Build 64 bit binary on Solaris @<:@default=on@:>@])],\n             [ac_enable_64bit=\"$enableval\"],\n             [ac_enable_64bit=\"yes\"])\n\n  AS_IF([test \"$SUNCC\" = \"yes\" -a \"x${ac_cv_env_CXXFLAGS_set}\" = \"x\"],[\n    dnl Sun Studio has a crashing bug with -xO4 in some cases. Keep this\n    dnl at -xO3 until a proper test to detect those crashes can be done.\n    CXXFLAGS=\"-g0 -xO3 -xlibmil -xdepend -xbuiltin -mt -compat=5 -library=stlport4 -library=Crun -template=no%extdef ${CXXFLAGS}\"\n  ])\n\n  case $host_os in\n    *solaris*)\n      AC_CHECK_PROGS(ISAINFO, [isainfo], [no])\n      AS_IF([test \"x$ISAINFO\" != \"xno\"],\n            [isainfo_b=`${ISAINFO} -b`],\n            [isainfo_b=\"x\"])\n\n      AS_IF([test \"$isainfo_b\" != \"x\"],[\n\n        isainfo_k=`${ISAINFO} -k`\n\n        AS_IF([test \"x$ac_enable_64bit\" = \"xyes\"],[\n\n          AS_IF([test \"x$libdir\" = \"x\\${exec_prefix}/lib\"],[\n           dnl The user hasn't overridden the default libdir, so we'll\n           dnl the dir suffix to match solaris 32/64-bit policy\n           libdir=\"${libdir}/${isainfo_k}\"\n          ])\n\n          dnl This should just be set in CPPFLAGS and in LDFLAGS, but libtool\n          dnl does the wrong thing if you don't put it into CXXFLAGS. sigh.\n          dnl (It also needs it in CFLAGS, or it does a different wrong thing!)\n          CXXFLAGS=\"${CXXFLAGS} -m64\"\n          ac_cv_env_CXXFLAGS_set=set\n          ac_cv_env_CXXFLAGS_value='-m64'\n\n          CFLAGS=\"${CFLAGS} -m64\"\n          ac_cv_env_CFLAGS_set=set\n          ac_cv_env_CFLAGS_value='-m64'\n\n          AS_IF([test \"$target_cpu\" = \"sparc\" -a \"x$SUNCC\" = \"xyes\" ],[\n            CXXFLAGS=\"-xmemalign=8s ${CXXFLAGS}\"\n          ])\n        ])\n      ])\n    ;;\n  esac\n\n])\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/m4/acx_pthread.m4",
    "content": "# This was retrieved from\n#    http://svn.0pointer.de/viewvc/trunk/common/acx_pthread.m4?revision=1277&root=avahi\n# See also (perhaps for new versions?)\n#    http://svn.0pointer.de/viewvc/trunk/common/acx_pthread.m4?root=avahi\n#\n# We've rewritten the inconsistency check code (from avahi), to work\n# more broadly.  In particular, it no longer assumes ld accepts -zdefs.\n# This caused a restructing of the code, but the functionality has only\n# changed a little.\n\ndnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])\ndnl\ndnl @summary figure out how to build C programs using POSIX threads\ndnl\ndnl This macro figures out how to build C programs using POSIX threads.\ndnl It sets the PTHREAD_LIBS output variable to the threads library and\ndnl linker flags, and the PTHREAD_CFLAGS output variable to any special\ndnl C compiler flags that are needed. (The user can also force certain\ndnl compiler flags/libs to be tested by setting these environment\ndnl variables.)\ndnl\ndnl Also sets PTHREAD_CC to any special C compiler that is needed for\ndnl multi-threaded programs (defaults to the value of CC otherwise).\ndnl (This is necessary on AIX to use the special cc_r compiler alias.)\ndnl\ndnl NOTE: You are assumed to not only compile your program with these\ndnl flags, but also link it with them as well. e.g. you should link\ndnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS\ndnl $LIBS\ndnl\ndnl If you are only building threads programs, you may wish to use\ndnl these variables in your default LIBS, CFLAGS, and CC:\ndnl\ndnl        LIBS=\"$PTHREAD_LIBS $LIBS\"\ndnl        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\ndnl        CC=\"$PTHREAD_CC\"\ndnl\ndnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute\ndnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to\ndnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).\ndnl\ndnl ACTION-IF-FOUND is a list of shell commands to run if a threads\ndnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to\ndnl run it if it is not found. If ACTION-IF-FOUND is not specified, the\ndnl default action will define HAVE_PTHREAD.\ndnl\ndnl Please let the authors know if this macro fails on any platform, or\ndnl if you have any other suggestions or comments. This macro was based\ndnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with\ndnl help from M. Frigo), as well as ac_pthread and hb_pthread macros\ndnl posted by Alejandro Forero Cuervo to the autoconf macro repository.\ndnl We are also grateful for the helpful feedback of numerous users.\ndnl\ndnl @category InstalledPackages\ndnl @author Steven G. Johnson <stevenj@alum.mit.edu>\ndnl @version 2006-05-29\ndnl @license GPLWithACException\ndnl \ndnl Checks for GCC shared/pthread inconsistency based on work by\ndnl Marcin Owsiany <marcin@owsiany.pl>\n\n\nAC_DEFUN([ACX_PTHREAD], [\nAC_REQUIRE([AC_CANONICAL_HOST])\nAC_LANG_SAVE\nAC_LANG_C\nacx_pthread_ok=no\n\n# We used to check for pthread.h first, but this fails if pthread.h\n# requires special compiler flags (e.g. on True64 or Sequent).\n# It gets checked for in the link test anyway.\n\n# First of all, check if the user has set any of the PTHREAD_LIBS,\n# etcetera environment variables, and if threads linking works using\n# them:\nif test x\"$PTHREAD_LIBS$PTHREAD_CFLAGS\" != x; then\n        save_CFLAGS=\"$CFLAGS\"\n        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n        save_LIBS=\"$LIBS\"\n        LIBS=\"$PTHREAD_LIBS $LIBS\"\n        AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])\n        AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)\n        AC_MSG_RESULT($acx_pthread_ok)\n        if test x\"$acx_pthread_ok\" = xno; then\n                PTHREAD_LIBS=\"\"\n                PTHREAD_CFLAGS=\"\"\n        fi\n        LIBS=\"$save_LIBS\"\n        CFLAGS=\"$save_CFLAGS\"\nfi\n\n# We must check for the threads library under a number of different\n# names; the ordering is very important because some systems\n# (e.g. DEC) have both -lpthread and -lpthreads, where one of the\n# libraries is broken (non-POSIX).\n\n# Create a list of thread flags to try.  Items starting with a \"-\" are\n# C compiler flags, and other items are library names, except for \"none\"\n# which indicates that we try without any flags at all, and \"pthread-config\"\n# which is a program returning the flags for the Pth emulation library.\n\nacx_pthread_flags=\"pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config\"\n\n# The ordering *is* (sometimes) important.  Some notes on the\n# individual items follow:\n\n# pthreads: AIX (must check this before -lpthread)\n# none: in case threads are in libc; should be tried before -Kthread and\n#       other compiler flags to prevent continual compiler warnings\n# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)\n# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)\n# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)\n# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)\n# -pthreads: Solaris/gcc\n# -mthreads: Mingw32/gcc, Lynx/gcc\n# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it\n#      doesn't hurt to check since this sometimes defines pthreads too;\n#      also defines -D_REENTRANT)\n#      ... -mt is also the pthreads flag for HP/aCC\n# pthread: Linux, etcetera\n# --thread-safe: KAI C++\n# pthread-config: use pthread-config program (for GNU Pth library)\n\ncase \"${host_cpu}-${host_os}\" in\n        *solaris*)\n\n        # On Solaris (at least, for some versions), libc contains stubbed\n        # (non-functional) versions of the pthreads routines, so link-based\n        # tests will erroneously succeed.  (We need to link with -pthreads/-mt/\n        # -lpthread.)  (The stubs are missing pthread_cleanup_push, or rather\n        # a function called by this macro, so we could check for that, but\n        # who knows whether they'll stub that too in a future libc.)  So,\n        # we'll just look for -pthreads and -lpthread first:\n\n        acx_pthread_flags=\"-pthreads pthread -mt -pthread $acx_pthread_flags\"\n        ;;\nesac\n\nif test x\"$acx_pthread_ok\" = xno; then\nfor flag in $acx_pthread_flags; do\n\n        case $flag in\n                none)\n                AC_MSG_CHECKING([whether pthreads work without any flags])\n                ;;\n\n                -*)\n                AC_MSG_CHECKING([whether pthreads work with $flag])\n                PTHREAD_CFLAGS=\"$flag\"\n                ;;\n\n\t\tpthread-config)\n\t\tAC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)\n\t\tif test x\"$acx_pthread_config\" = xno; then continue; fi\n\t\tPTHREAD_CFLAGS=\"`pthread-config --cflags`\"\n\t\tPTHREAD_LIBS=\"`pthread-config --ldflags` `pthread-config --libs`\"\n\t\t;;\n\n                *)\n                AC_MSG_CHECKING([for the pthreads library -l$flag])\n                PTHREAD_LIBS=\"-l$flag\"\n                ;;\n        esac\n\n        save_LIBS=\"$LIBS\"\n        save_CFLAGS=\"$CFLAGS\"\n        LIBS=\"$PTHREAD_LIBS $LIBS\"\n        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n\n        # Check for various functions.  We must include pthread.h,\n        # since some functions may be macros.  (On the Sequent, we\n        # need a special flag -Kthread to make this header compile.)\n        # We check for pthread_join because it is in -lpthread on IRIX\n        # while pthread_create is in libc.  We check for pthread_attr_init\n        # due to DEC craziness with -lpthreads.  We check for\n        # pthread_cleanup_push because it is one of the few pthread\n        # functions on Solaris that doesn't have a non-functional libc stub.\n        # We try pthread_create on general principles.\n        AC_TRY_LINK([#include <pthread.h>],\n                    [pthread_t th; pthread_join(th, 0);\n                     pthread_attr_init(0); pthread_cleanup_push(0, 0);\n                     pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],\n                    [acx_pthread_ok=yes])\n\n        LIBS=\"$save_LIBS\"\n        CFLAGS=\"$save_CFLAGS\"\n\n        AC_MSG_RESULT($acx_pthread_ok)\n        if test \"x$acx_pthread_ok\" = xyes; then\n                break;\n        fi\n\n        PTHREAD_LIBS=\"\"\n        PTHREAD_CFLAGS=\"\"\ndone\nfi\n\n# Various other checks:\nif test \"x$acx_pthread_ok\" = xyes; then\n        save_LIBS=\"$LIBS\"\n        LIBS=\"$PTHREAD_LIBS $LIBS\"\n        save_CFLAGS=\"$CFLAGS\"\n        CFLAGS=\"$CFLAGS $PTHREAD_CFLAGS\"\n\n        # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.\n\tAC_MSG_CHECKING([for joinable pthread attribute])\n\tattr_name=unknown\n\tfor attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do\n\t    AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],\n                        [attr_name=$attr; break])\n\tdone\n        AC_MSG_RESULT($attr_name)\n        if test \"$attr_name\" != PTHREAD_CREATE_JOINABLE; then\n            AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,\n                               [Define to necessary symbol if this constant\n                                uses a non-standard name on your system.])\n        fi\n\n        AC_MSG_CHECKING([if more special flags are required for pthreads])\n        flag=no\n        case \"${host_cpu}-${host_os}\" in\n            *-aix* | *-freebsd* | *-darwin*) flag=\"-D_THREAD_SAFE\";;\n            *solaris* | *-osf* | *-hpux*) flag=\"-D_REENTRANT\";;\n        esac\n        AC_MSG_RESULT(${flag})\n        if test \"x$flag\" != xno; then\n            PTHREAD_CFLAGS=\"$flag $PTHREAD_CFLAGS\"\n        fi\n\n        LIBS=\"$save_LIBS\"\n        CFLAGS=\"$save_CFLAGS\"\n        # More AIX lossage: must compile with xlc_r or cc_r\n\tif test x\"$GCC\" != xyes; then\n          AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})\n        else\n          PTHREAD_CC=$CC\n\tfi\n\n\t# The next part tries to detect GCC inconsistency with -shared on some\n\t# architectures and systems. The problem is that in certain\n\t# configurations, when -shared is specified, GCC \"forgets\" to\n\t# internally use various flags which are still necessary.\n\t\n\t#\n\t# Prepare the flags\n\t#\n\tsave_CFLAGS=\"$CFLAGS\"\n\tsave_LIBS=\"$LIBS\"\n\tsave_CC=\"$CC\"\n\t\n\t# Try with the flags determined by the earlier checks.\n\t#\n\t# -Wl,-z,defs forces link-time symbol resolution, so that the\n\t# linking checks with -shared actually have any value\n\t#\n\t# FIXME: -fPIC is required for -shared on many architectures,\n\t# so we specify it here, but the right way would probably be to\n\t# properly detect whether it is actually required.\n\tCFLAGS=\"-shared -fPIC -Wl,-z,defs $CFLAGS $PTHREAD_CFLAGS\"\n\tLIBS=\"$PTHREAD_LIBS $LIBS\"\n\tCC=\"$PTHREAD_CC\"\n\t\n\t# In order not to create several levels of indentation, we test\n\t# the value of \"$done\" until we find the cure or run out of ideas.\n\tdone=\"no\"\n\t\n\t# First, make sure the CFLAGS we added are actually accepted by our\n\t# compiler.  If not (and OS X's ld, for instance, does not accept -z),\n\t# then we can't do this test.\n\tif test x\"$done\" = xno; then\n\t   AC_MSG_CHECKING([whether to check for GCC pthread/shared inconsistencies])\n\t   AC_TRY_LINK(,, , [done=yes])\n\t\n\t   if test \"x$done\" = xyes ; then\n\t      AC_MSG_RESULT([no])\n\t   else\n\t      AC_MSG_RESULT([yes])\n\t   fi\n\tfi\n\t\n\tif test x\"$done\" = xno; then\n\t   AC_MSG_CHECKING([whether -pthread is sufficient with -shared])\n\t   AC_TRY_LINK([#include <pthread.h>],\n\t      [pthread_t th; pthread_join(th, 0);\n\t      pthread_attr_init(0); pthread_cleanup_push(0, 0);\n\t      pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],\n\t      [done=yes])\n\t   \n\t   if test \"x$done\" = xyes; then\n\t      AC_MSG_RESULT([yes])\n\t   else\n\t      AC_MSG_RESULT([no])\n\t   fi\n\tfi\n\t\n\t#\n\t# Linux gcc on some architectures such as mips/mipsel forgets\n\t# about -lpthread\n\t#\n\tif test x\"$done\" = xno; then\n\t   AC_MSG_CHECKING([whether -lpthread fixes that])\n\t   LIBS=\"-lpthread $PTHREAD_LIBS $save_LIBS\"\n\t   AC_TRY_LINK([#include <pthread.h>],\n\t      [pthread_t th; pthread_join(th, 0);\n\t      pthread_attr_init(0); pthread_cleanup_push(0, 0);\n\t      pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],\n\t      [done=yes])\n\t\n\t   if test \"x$done\" = xyes; then\n\t      AC_MSG_RESULT([yes])\n\t      PTHREAD_LIBS=\"-lpthread $PTHREAD_LIBS\"\n\t   else\n\t      AC_MSG_RESULT([no])\n\t   fi\n\tfi\n\t#\n\t# FreeBSD 4.10 gcc forgets to use -lc_r instead of -lc\n\t#\n\tif test x\"$done\" = xno; then\n\t   AC_MSG_CHECKING([whether -lc_r fixes that])\n\t   LIBS=\"-lc_r $PTHREAD_LIBS $save_LIBS\"\n\t   AC_TRY_LINK([#include <pthread.h>],\n\t       [pthread_t th; pthread_join(th, 0);\n\t        pthread_attr_init(0); pthread_cleanup_push(0, 0);\n\t        pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],\n\t       [done=yes])\n\t\n\t   if test \"x$done\" = xyes; then\n\t      AC_MSG_RESULT([yes])\n\t      PTHREAD_LIBS=\"-lc_r $PTHREAD_LIBS\"\n\t   else\n\t      AC_MSG_RESULT([no])\n\t   fi\n\tfi\n\tif test x\"$done\" = xno; then\n\t   # OK, we have run out of ideas\n\t   AC_MSG_WARN([Impossible to determine how to use pthreads with shared libraries])\n\t\n\t   # so it's not safe to assume that we may use pthreads\n\t   acx_pthread_ok=no\n\tfi\n\t\n\tAC_MSG_CHECKING([whether what we have so far is sufficient with -nostdlib])\n\tCFLAGS=\"-nostdlib $CFLAGS\"\n\t# we need c with nostdlib\n\tLIBS=\"$LIBS -lc\"\n\tAC_TRY_LINK([#include <pthread.h>],\n\t      [pthread_t th; pthread_join(th, 0);\n\t       pthread_attr_init(0); pthread_cleanup_push(0, 0);\n\t       pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],\n\t      [done=yes],[done=no])\n\n\tif test \"x$done\" = xyes; then\n\t   AC_MSG_RESULT([yes])\n\telse\n\t   AC_MSG_RESULT([no])\n\tfi\n\t\n\tif test x\"$done\" = xno; then\n\t   AC_MSG_CHECKING([whether -lpthread saves the day])\n\t   LIBS=\"-lpthread $LIBS\"\n\t   AC_TRY_LINK([#include <pthread.h>],\n\t      [pthread_t th; pthread_join(th, 0);\n\t       pthread_attr_init(0); pthread_cleanup_push(0, 0);\n\t       pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],\n\t      [done=yes],[done=no])\n\n\t   if test \"x$done\" = xyes; then\n\t      AC_MSG_RESULT([yes])\n\t      PTHREAD_LIBS=\"$PTHREAD_LIBS -lpthread\"\n\t   else\n\t      AC_MSG_RESULT([no])\n\t      AC_MSG_WARN([Impossible to determine how to use pthreads with shared libraries and -nostdlib])\n\t   fi\n\tfi\n\n\tCFLAGS=\"$save_CFLAGS\"\n\tLIBS=\"$save_LIBS\"\n\tCC=\"$save_CC\"\nelse\n        PTHREAD_CC=\"$CC\"\nfi\n\nAC_SUBST(PTHREAD_LIBS)\nAC_SUBST(PTHREAD_CFLAGS)\nAC_SUBST(PTHREAD_CC)\n\n# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:\nif test x\"$acx_pthread_ok\" = xyes; then\n        ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])\n        :\nelse\n        acx_pthread_ok=no\n        $2\nfi\nAC_LANG_RESTORE\n])dnl ACX_PTHREAD\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/m4/libtool.m4",
    "content": "# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-\n#\n#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,\n#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software\n#                 Foundation, Inc.\n#   Written by Gordon Matzigkeit, 1996\n#\n# This file is free software; the Free Software Foundation gives\n# unlimited permission to copy and/or distribute it, with or without\n# modifications, as long as this notice is preserved.\n\nm4_define([_LT_COPYING], [dnl\n#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,\n#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software\n#                 Foundation, Inc.\n#   Written by Gordon Matzigkeit, 1996\n#\n#   This file is part of GNU Libtool.\n#\n# GNU Libtool is free software; you can redistribute it and/or\n# modify it under the terms of the GNU General Public License as\n# published by the Free Software Foundation; either version 2 of\n# the License, or (at your option) any later version.\n#\n# As a special exception to the GNU General Public License,\n# if you distribute this file as part of a program or library that\n# is built using GNU Libtool, you may include this file under the\n# same distribution terms that you use for the rest of that program.\n#\n# GNU Libtool is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with GNU Libtool; see the file COPYING.  If not, a copy\n# can be downloaded from http://www.gnu.org/licenses/gpl.html, or\n# obtained by writing to the Free Software Foundation, Inc.,\n# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n])\n\n# serial 57 LT_INIT\n\n\n# LT_PREREQ(VERSION)\n# ------------------\n# Complain and exit if this libtool version is less that VERSION.\nm4_defun([LT_PREREQ],\n[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,\n       [m4_default([$3],\n\t\t   [m4_fatal([Libtool version $1 or higher is required],\n\t\t             63)])],\n       [$2])])\n\n\n# _LT_CHECK_BUILDDIR\n# ------------------\n# Complain if the absolute build directory name contains unusual characters\nm4_defun([_LT_CHECK_BUILDDIR],\n[case `pwd` in\n  *\\ * | *\\\t*)\n    AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;\nesac\n])\n\n\n# LT_INIT([OPTIONS])\n# ------------------\nAC_DEFUN([LT_INIT],\n[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT\nAC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl\nAC_BEFORE([$0], [LT_LANG])dnl\nAC_BEFORE([$0], [LT_OUTPUT])dnl\nAC_BEFORE([$0], [LTDL_INIT])dnl\nm4_require([_LT_CHECK_BUILDDIR])dnl\n\ndnl Autoconf doesn't catch unexpanded LT_ macros by default:\nm4_pattern_forbid([^_?LT_[A-Z_]+$])dnl\nm4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl\ndnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4\ndnl unless we require an AC_DEFUNed macro:\nAC_REQUIRE([LTOPTIONS_VERSION])dnl\nAC_REQUIRE([LTSUGAR_VERSION])dnl\nAC_REQUIRE([LTVERSION_VERSION])dnl\nAC_REQUIRE([LTOBSOLETE_VERSION])dnl\nm4_require([_LT_PROG_LTMAIN])dnl\n\n_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}])\n\ndnl Parse OPTIONS\n_LT_SET_OPTIONS([$0], [$1])\n\n# This can be used to rebuild libtool when needed\nLIBTOOL_DEPS=\"$ltmain\"\n\n# Always use our own libtool.\nLIBTOOL='$(SHELL) $(top_builddir)/libtool'\nAC_SUBST(LIBTOOL)dnl\n\n_LT_SETUP\n\n# Only expand once:\nm4_define([LT_INIT])\n])# LT_INIT\n\n# Old names:\nAU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])\nAU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])\ndnl aclocal-1.4 backwards compatibility:\ndnl AC_DEFUN([AC_PROG_LIBTOOL], [])\ndnl AC_DEFUN([AM_PROG_LIBTOOL], [])\n\n\n# _LT_CC_BASENAME(CC)\n# -------------------\n# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.\nm4_defun([_LT_CC_BASENAME],\n[for cc_temp in $1\"\"; do\n  case $cc_temp in\n    compile | *[[\\\\/]]compile | ccache | *[[\\\\/]]ccache ) ;;\n    distcc | *[[\\\\/]]distcc | purify | *[[\\\\/]]purify ) ;;\n    \\-*) ;;\n    *) break;;\n  esac\ndone\ncc_basename=`$ECHO \"$cc_temp\" | $SED \"s%.*/%%; s%^$host_alias-%%\"`\n])\n\n\n# _LT_FILEUTILS_DEFAULTS\n# ----------------------\n# It is okay to use these file commands and assume they have been set\n# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.\nm4_defun([_LT_FILEUTILS_DEFAULTS],\n[: ${CP=\"cp -f\"}\n: ${MV=\"mv -f\"}\n: ${RM=\"rm -f\"}\n])# _LT_FILEUTILS_DEFAULTS\n\n\n# _LT_SETUP\n# ---------\nm4_defun([_LT_SETUP],\n[AC_REQUIRE([AC_CANONICAL_HOST])dnl\nAC_REQUIRE([AC_CANONICAL_BUILD])dnl\nAC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl\nAC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl\n\n_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl\ndnl\n_LT_DECL([], [host_alias], [0], [The host system])dnl\n_LT_DECL([], [host], [0])dnl\n_LT_DECL([], [host_os], [0])dnl\ndnl\n_LT_DECL([], [build_alias], [0], [The build system])dnl\n_LT_DECL([], [build], [0])dnl\n_LT_DECL([], [build_os], [0])dnl\ndnl\nAC_REQUIRE([AC_PROG_CC])dnl\nAC_REQUIRE([LT_PATH_LD])dnl\nAC_REQUIRE([LT_PATH_NM])dnl\ndnl\nAC_REQUIRE([AC_PROG_LN_S])dnl\ntest -z \"$LN_S\" && LN_S=\"ln -s\"\n_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl\ndnl\nAC_REQUIRE([LT_CMD_MAX_LEN])dnl\n_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally \"o\")])dnl\n_LT_DECL([], [exeext], [0], [Executable file suffix (normally \"\")])dnl\ndnl\nm4_require([_LT_FILEUTILS_DEFAULTS])dnl\nm4_require([_LT_CHECK_SHELL_FEATURES])dnl\nm4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl\nm4_require([_LT_CMD_RELOAD])dnl\nm4_require([_LT_CHECK_MAGIC_METHOD])dnl\nm4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl\nm4_require([_LT_CMD_OLD_ARCHIVE])dnl\nm4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl\nm4_require([_LT_WITH_SYSROOT])dnl\n\n_LT_CONFIG_LIBTOOL_INIT([\n# See if we are running on zsh, and set the options which allow our\n# commands through without removal of \\ escapes INIT.\nif test -n \"\\${ZSH_VERSION+set}\" ; then\n   setopt NO_GLOB_SUBST\nfi\n])\nif test -n \"${ZSH_VERSION+set}\" ; then\n   setopt NO_GLOB_SUBST\nfi\n\n_LT_CHECK_OBJDIR\n\nm4_require([_LT_TAG_COMPILER])dnl\n\ncase $host_os in\naix3*)\n  # AIX sometimes has problems with the GCC collect2 program.  For some\n  # reason, if we set the COLLECT_NAMES environment variable, the problems\n  # vanish in a puff of smoke.\n  if test \"X${COLLECT_NAMES+set}\" != Xset; then\n    COLLECT_NAMES=\n    export COLLECT_NAMES\n  fi\n  ;;\nesac\n\n# Global variables:\nofile=libtool\ncan_build_shared=yes\n\n# All known linkers require a `.a' archive for static linking (except MSVC,\n# which needs '.lib').\nlibext=a\n\nwith_gnu_ld=\"$lt_cv_prog_gnu_ld\"\n\nold_CC=\"$CC\"\nold_CFLAGS=\"$CFLAGS\"\n\n# Set sane defaults for various variables\ntest -z \"$CC\" && CC=cc\ntest -z \"$LTCC\" && LTCC=$CC\ntest -z \"$LTCFLAGS\" && LTCFLAGS=$CFLAGS\ntest -z \"$LD\" && LD=ld\ntest -z \"$ac_objext\" && ac_objext=o\n\n_LT_CC_BASENAME([$compiler])\n\n# Only perform the check for file, if the check method requires it\ntest -z \"$MAGIC_CMD\" && MAGIC_CMD=file\ncase $deplibs_check_method in\nfile_magic*)\n  if test \"$file_magic_cmd\" = '$MAGIC_CMD'; then\n    _LT_PATH_MAGIC\n  fi\n  ;;\nesac\n\n# Use C for the default configuration in the libtool script\nLT_SUPPORTED_TAG([CC])\n_LT_LANG_C_CONFIG\n_LT_LANG_DEFAULT_CONFIG\n_LT_CONFIG_COMMANDS\n])# _LT_SETUP\n\n\n# _LT_PREPARE_SED_QUOTE_VARS\n# --------------------------\n# Define a few sed substitution that help us do robust quoting.\nm4_defun([_LT_PREPARE_SED_QUOTE_VARS],\n[# Backslashify metacharacters that are still active within\n# double-quoted strings.\nsed_quote_subst='s/\\([[\"`$\\\\]]\\)/\\\\\\1/g'\n\n# Same as above, but do not quote variable references.\ndouble_quote_subst='s/\\([[\"`\\\\]]\\)/\\\\\\1/g'\n\n# Sed substitution to delay expansion of an escaped shell variable in a\n# double_quote_subst'ed string.\ndelay_variable_subst='s/\\\\\\\\\\\\\\\\\\\\\\$/\\\\\\\\\\\\$/g'\n\n# Sed substitution to delay expansion of an escaped single quote.\ndelay_single_quote_subst='s/'\\''/'\\'\\\\\\\\\\\\\\'\\''/g'\n\n# Sed substitution to avoid accidental globbing in evaled expressions\nno_glob_subst='s/\\*/\\\\\\*/g'\n])\n\n# _LT_PROG_LTMAIN\n# ---------------\n# Note that this code is called both from `configure', and `config.status'\n# now that we use AC_CONFIG_COMMANDS to generate libtool.  Notably,\n# `config.status' has no value for ac_aux_dir unless we are using Automake,\n# so we pass a copy along to make sure it has a sensible value anyway.\nm4_defun([_LT_PROG_LTMAIN],\n[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl\n_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])\nltmain=\"$ac_aux_dir/ltmain.sh\"\n])# _LT_PROG_LTMAIN\n\n\n## ------------------------------------- ##\n## Accumulate code for creating libtool. ##\n## ------------------------------------- ##\n\n# So that we can recreate a full libtool script including additional\n# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS\n# in macros and then make a single call at the end using the `libtool'\n# label.\n\n\n# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])\n# ----------------------------------------\n# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.\nm4_define([_LT_CONFIG_LIBTOOL_INIT],\n[m4_ifval([$1],\n          [m4_append([_LT_OUTPUT_LIBTOOL_INIT],\n                     [$1\n])])])\n\n# Initialize.\nm4_define([_LT_OUTPUT_LIBTOOL_INIT])\n\n\n# _LT_CONFIG_LIBTOOL([COMMANDS])\n# ------------------------------\n# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.\nm4_define([_LT_CONFIG_LIBTOOL],\n[m4_ifval([$1],\n          [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],\n                     [$1\n])])])\n\n# Initialize.\nm4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])\n\n\n# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])\n# -----------------------------------------------------\nm4_defun([_LT_CONFIG_SAVE_COMMANDS],\n[_LT_CONFIG_LIBTOOL([$1])\n_LT_CONFIG_LIBTOOL_INIT([$2])\n])\n\n\n# _LT_FORMAT_COMMENT([COMMENT])\n# -----------------------------\n# Add leading comment marks to the start of each line, and a trailing\n# full-stop to the whole comment if one is not present already.\nm4_define([_LT_FORMAT_COMMENT],\n[m4_ifval([$1], [\nm4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],\n              [['`$\\]], [\\\\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])\n)])\n\n\n\n## ------------------------ ##\n## FIXME: Eliminate VARNAME ##\n## ------------------------ ##\n\n\n# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])\n# -------------------------------------------------------------------\n# CONFIGNAME is the name given to the value in the libtool script.\n# VARNAME is the (base) name used in the configure script.\n# VALUE may be 0, 1 or 2 for a computed quote escaped value based on\n# VARNAME.  Any other value will be used directly.\nm4_define([_LT_DECL],\n[lt_if_append_uniq([lt_decl_varnames], [$2], [, ],\n    [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],\n\t[m4_ifval([$1], [$1], [$2])])\n    lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])\n    m4_ifval([$4],\n\t[lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])\n    lt_dict_add_subkey([lt_decl_dict], [$2],\n\t[tagged?], [m4_ifval([$5], [yes], [no])])])\n])\n\n\n# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])\n# --------------------------------------------------------\nm4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])\n\n\n# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])\n# ------------------------------------------------\nm4_define([lt_decl_tag_varnames],\n[_lt_decl_filter([tagged?], [yes], $@)])\n\n\n# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])\n# ---------------------------------------------------------\nm4_define([_lt_decl_filter],\n[m4_case([$#],\n  [0], [m4_fatal([$0: too few arguments: $#])],\n  [1], [m4_fatal([$0: too few arguments: $#: $1])],\n  [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],\n  [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],\n  [lt_dict_filter([lt_decl_dict], $@)])[]dnl\n])\n\n\n# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])\n# --------------------------------------------------\nm4_define([lt_decl_quote_varnames],\n[_lt_decl_filter([value], [1], $@)])\n\n\n# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])\n# ---------------------------------------------------\nm4_define([lt_decl_dquote_varnames],\n[_lt_decl_filter([value], [2], $@)])\n\n\n# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])\n# ---------------------------------------------------\nm4_define([lt_decl_varnames_tagged],\n[m4_assert([$# <= 2])dnl\n_$0(m4_quote(m4_default([$1], [[, ]])),\n    m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]),\n    m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))])\nm4_define([_lt_decl_varnames_tagged],\n[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])])\n\n\n# lt_decl_all_varnames([SEPARATOR], [VARNAME1...])\n# ------------------------------------------------\nm4_define([lt_decl_all_varnames],\n[_$0(m4_quote(m4_default([$1], [[, ]])),\n     m4_if([$2], [],\n\t   m4_quote(lt_decl_varnames),\n\tm4_quote(m4_shift($@))))[]dnl\n])\nm4_define([_lt_decl_all_varnames],\n[lt_join($@, lt_decl_varnames_tagged([$1],\n\t\t\tlt_decl_tag_varnames([[, ]], m4_shift($@))))dnl\n])\n\n\n# _LT_CONFIG_STATUS_DECLARE([VARNAME])\n# ------------------------------------\n# Quote a variable value, and forward it to `config.status' so that its\n# declaration there will have the same value as in `configure'.  VARNAME\n# must have a single quote delimited value for this to work.\nm4_define([_LT_CONFIG_STATUS_DECLARE],\n[$1='`$ECHO \"$][$1\" | $SED \"$delay_single_quote_subst\"`'])\n\n\n# _LT_CONFIG_STATUS_DECLARATIONS\n# ------------------------------\n# We delimit libtool config variables with single quotes, so when\n# we write them to config.status, we have to be sure to quote all\n# embedded single quotes properly.  In configure, this macro expands\n# each variable declared with _LT_DECL (and _LT_TAGDECL) into:\n#\n#    <var>='`$ECHO \"$<var>\" | $SED \"$delay_single_quote_subst\"`'\nm4_defun([_LT_CONFIG_STATUS_DECLARATIONS],\n[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),\n    [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])\n\n\n# _LT_LIBTOOL_TAGS\n# ----------------\n# Output comment and list of tags supported by the script\nm4_defun([_LT_LIBTOOL_TAGS],\n[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl\navailable_tags=\"_LT_TAGS\"dnl\n])\n\n\n# _LT_LIBTOOL_DECLARE(VARNAME, [TAG])\n# -----------------------------------\n# Extract the dictionary values for VARNAME (optionally with TAG) and\n# expand to a commented shell variable setting:\n#\n#    # Some comment about what VAR is for.\n#    visible_name=$lt_internal_name\nm4_define([_LT_LIBTOOL_DECLARE],\n[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],\n\t\t\t\t\t   [description])))[]dnl\nm4_pushdef([_libtool_name],\n    m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl\nm4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),\n    [0], [_libtool_name=[$]$1],\n    [1], [_libtool_name=$lt_[]$1],\n    [2], [_libtool_name=$lt_[]$1],\n    [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl\nm4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl\n])\n\n\n# _LT_LIBTOOL_CONFIG_VARS\n# -----------------------\n# Produce commented declarations of non-tagged libtool config variables\n# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'\n# script.  Tagged libtool config variables (even for the LIBTOOL CONFIG\n# section) are produced by _LT_LIBTOOL_TAG_VARS.\nm4_defun([_LT_LIBTOOL_CONFIG_VARS],\n[m4_foreach([_lt_var],\n    m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),\n    [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])\n\n\n# _LT_LIBTOOL_TAG_VARS(TAG)\n# -------------------------\nm4_define([_LT_LIBTOOL_TAG_VARS],\n[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),\n    [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])\n\n\n# _LT_TAGVAR(VARNAME, [TAGNAME])\n# ------------------------------\nm4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])\n\n\n# _LT_CONFIG_COMMANDS\n# -------------------\n# Send accumulated output to $CONFIG_STATUS.  Thanks to the lists of\n# variables for single and double quote escaping we saved from calls\n# to _LT_DECL, we can put quote escaped variables declarations\n# into `config.status', and then the shell code to quote escape them in\n# for loops in `config.status'.  Finally, any additional code accumulated\n# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.\nm4_defun([_LT_CONFIG_COMMANDS],\n[AC_PROVIDE_IFELSE([LT_OUTPUT],\n\tdnl If the libtool generation code has been placed in $CONFIG_LT,\n\tdnl instead of duplicating it all over again into config.status,\n\tdnl then we will have config.status run $CONFIG_LT later, so it\n\tdnl needs to know what name is stored there:\n        [AC_CONFIG_COMMANDS([libtool],\n            [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],\n    dnl If the libtool generation code is destined for config.status,\n    dnl expand the accumulated commands and init code now:\n    [AC_CONFIG_COMMANDS([libtool],\n        [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])\n])#_LT_CONFIG_COMMANDS\n\n\n# Initialize.\nm4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],\n[\n\n# The HP-UX ksh and POSIX shell print the target directory to stdout\n# if CDPATH is set.\n(unset CDPATH) >/dev/null 2>&1 && unset CDPATH\n\nsed_quote_subst='$sed_quote_subst'\ndouble_quote_subst='$double_quote_subst'\ndelay_variable_subst='$delay_variable_subst'\n_LT_CONFIG_STATUS_DECLARATIONS\nLTCC='$LTCC'\nLTCFLAGS='$LTCFLAGS'\ncompiler='$compiler_DEFAULT'\n\n# A function that is used when there is no print builtin or printf.\nfunc_fallback_echo ()\n{\n  eval 'cat <<_LTECHO_EOF\n\\$[]1\n_LTECHO_EOF'\n}\n\n# Quote evaled strings.\nfor var in lt_decl_all_varnames([[ \\\n]], lt_decl_quote_varnames); do\n    case \\`eval \\\\\\\\\\$ECHO \\\\\\\\\"\"\\\\\\\\\\$\\$var\"\\\\\\\\\"\\` in\n    *[[\\\\\\\\\\\\\\`\\\\\"\\\\\\$]]*)\n      eval \"lt_\\$var=\\\\\\\\\\\\\"\\\\\\`\\\\\\$ECHO \\\\\"\\\\\\$\\$var\\\\\" | \\\\\\$SED \\\\\"\\\\\\$sed_quote_subst\\\\\"\\\\\\`\\\\\\\\\\\\\"\"\n      ;;\n    *)\n      eval \"lt_\\$var=\\\\\\\\\\\\\"\\\\\\$\\$var\\\\\\\\\\\\\"\"\n      ;;\n    esac\ndone\n\n# Double-quote double-evaled strings.\nfor var in lt_decl_all_varnames([[ \\\n]], lt_decl_dquote_varnames); do\n    case \\`eval \\\\\\\\\\$ECHO \\\\\\\\\"\"\\\\\\\\\\$\\$var\"\\\\\\\\\"\\` in\n    *[[\\\\\\\\\\\\\\`\\\\\"\\\\\\$]]*)\n      eval \"lt_\\$var=\\\\\\\\\\\\\"\\\\\\`\\\\\\$ECHO \\\\\"\\\\\\$\\$var\\\\\" | \\\\\\$SED -e \\\\\"\\\\\\$double_quote_subst\\\\\" -e \\\\\"\\\\\\$sed_quote_subst\\\\\" -e \\\\\"\\\\\\$delay_variable_subst\\\\\"\\\\\\`\\\\\\\\\\\\\"\"\n      ;;\n    *)\n      eval \"lt_\\$var=\\\\\\\\\\\\\"\\\\\\$\\$var\\\\\\\\\\\\\"\"\n      ;;\n    esac\ndone\n\n_LT_OUTPUT_LIBTOOL_INIT\n])\n\n# _LT_GENERATED_FILE_INIT(FILE, [COMMENT])\n# ------------------------------------\n# Generate a child script FILE with all initialization necessary to\n# reuse the environment learned by the parent script, and make the\n# file executable.  If COMMENT is supplied, it is inserted after the\n# `#!' sequence but before initialization text begins.  After this\n# macro, additional text can be appended to FILE to form the body of\n# the child script.  The macro ends with non-zero status if the\n# file could not be fully written (such as if the disk is full).\nm4_ifdef([AS_INIT_GENERATED],\n[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])],\n[m4_defun([_LT_GENERATED_FILE_INIT],\n[m4_require([AS_PREPARE])]dnl\n[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl\n[lt_write_fail=0\ncat >$1 <<_ASEOF || lt_write_fail=1\n#! $SHELL\n# Generated by $as_me.\n$2\nSHELL=\\${CONFIG_SHELL-$SHELL}\nexport SHELL\n_ASEOF\ncat >>$1 <<\\_ASEOF || lt_write_fail=1\nAS_SHELL_SANITIZE\n_AS_PREPARE\nexec AS_MESSAGE_FD>&1\n_ASEOF\ntest $lt_write_fail = 0 && chmod +x $1[]dnl\nm4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT\n\n# LT_OUTPUT\n# ---------\n# This macro allows early generation of the libtool script (before\n# AC_OUTPUT is called), incase it is used in configure for compilation\n# tests.\nAC_DEFUN([LT_OUTPUT],\n[: ${CONFIG_LT=./config.lt}\nAC_MSG_NOTICE([creating $CONFIG_LT])\n_LT_GENERATED_FILE_INIT([\"$CONFIG_LT\"],\n[# Run this file to recreate a libtool stub with the current configuration.])\n\ncat >>\"$CONFIG_LT\" <<\\_LTEOF\nlt_cl_silent=false\nexec AS_MESSAGE_LOG_FD>>config.log\n{\n  echo\n  AS_BOX([Running $as_me.])\n} >&AS_MESSAGE_LOG_FD\n\nlt_cl_help=\"\\\n\\`$as_me' creates a local libtool stub from the current configuration,\nfor use in further configure time tests before the real libtool is\ngenerated.\n\nUsage: $[0] [[OPTIONS]]\n\n  -h, --help      print this help, then exit\n  -V, --version   print version number, then exit\n  -q, --quiet     do not print progress messages\n  -d, --debug     don't remove temporary files\n\nReport bugs to <bug-libtool@gnu.org>.\"\n\nlt_cl_version=\"\\\nm4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl\nm4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])\nconfigured by $[0], generated by m4_PACKAGE_STRING.\n\nCopyright (C) 2011 Free Software Foundation, Inc.\nThis config.lt script is free software; the Free Software Foundation\ngives unlimited permision to copy, distribute and modify it.\"\n\nwhile test $[#] != 0\ndo\n  case $[1] in\n    --version | --v* | -V )\n      echo \"$lt_cl_version\"; exit 0 ;;\n    --help | --h* | -h )\n      echo \"$lt_cl_help\"; exit 0 ;;\n    --debug | --d* | -d )\n      debug=: ;;\n    --quiet | --q* | --silent | --s* | -q )\n      lt_cl_silent=: ;;\n\n    -*) AC_MSG_ERROR([unrecognized option: $[1]\nTry \\`$[0] --help' for more information.]) ;;\n\n    *) AC_MSG_ERROR([unrecognized argument: $[1]\nTry \\`$[0] --help' for more information.]) ;;\n  esac\n  shift\ndone\n\nif $lt_cl_silent; then\n  exec AS_MESSAGE_FD>/dev/null\nfi\n_LTEOF\n\ncat >>\"$CONFIG_LT\" <<_LTEOF\n_LT_OUTPUT_LIBTOOL_COMMANDS_INIT\n_LTEOF\n\ncat >>\"$CONFIG_LT\" <<\\_LTEOF\nAC_MSG_NOTICE([creating $ofile])\n_LT_OUTPUT_LIBTOOL_COMMANDS\nAS_EXIT(0)\n_LTEOF\nchmod +x \"$CONFIG_LT\"\n\n# configure is writing to config.log, but config.lt does its own redirection,\n# appending to config.log, which fails on DOS, as config.log is still kept\n# open by configure.  Here we exec the FD to /dev/null, effectively closing\n# config.log, so it can be properly (re)opened and appended to by config.lt.\nlt_cl_success=:\ntest \"$silent\" = yes &&\n  lt_config_lt_args=\"$lt_config_lt_args --quiet\"\nexec AS_MESSAGE_LOG_FD>/dev/null\n$SHELL \"$CONFIG_LT\" $lt_config_lt_args || lt_cl_success=false\nexec AS_MESSAGE_LOG_FD>>config.log\n$lt_cl_success || AS_EXIT(1)\n])# LT_OUTPUT\n\n\n# _LT_CONFIG(TAG)\n# ---------------\n# If TAG is the built-in tag, create an initial libtool script with a\n# default configuration from the untagged config vars.  Otherwise add code\n# to config.status for appending the configuration named by TAG from the\n# matching tagged config vars.\nm4_defun([_LT_CONFIG],\n[m4_require([_LT_FILEUTILS_DEFAULTS])dnl\n_LT_CONFIG_SAVE_COMMANDS([\n  m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl\n  m4_if(_LT_TAG, [C], [\n    # See if we are running on zsh, and set the options which allow our\n    # commands through without removal of \\ escapes.\n    if test -n \"${ZSH_VERSION+set}\" ; then\n      setopt NO_GLOB_SUBST\n    fi\n\n    cfgfile=\"${ofile}T\"\n    trap \"$RM \\\"$cfgfile\\\"; exit 1\" 1 2 15\n    $RM \"$cfgfile\"\n\n    cat <<_LT_EOF >> \"$cfgfile\"\n#! $SHELL\n\n# `$ECHO \"$ofile\" | sed 's%^.*/%%'` - Provide generalized library-building support services.\n# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION\n# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:\n# NOTE: Changes made to this file will be lost: look at ltmain.sh.\n#\n_LT_COPYING\n_LT_LIBTOOL_TAGS\n\n# ### BEGIN LIBTOOL CONFIG\n_LT_LIBTOOL_CONFIG_VARS\n_LT_LIBTOOL_TAG_VARS\n# ### END LIBTOOL CONFIG\n\n_LT_EOF\n\n  case $host_os in\n  aix3*)\n    cat <<\\_LT_EOF >> \"$cfgfile\"\n# AIX sometimes has problems with the GCC collect2 program.  For some\n# reason, if we set the COLLECT_NAMES environment variable, the problems\n# vanish in a puff of smoke.\nif test \"X${COLLECT_NAMES+set}\" != Xset; then\n  COLLECT_NAMES=\n  export COLLECT_NAMES\nfi\n_LT_EOF\n    ;;\n  esac\n\n  _LT_PROG_LTMAIN\n\n  # We use sed instead of cat because bash on DJGPP gets confused if\n  # if finds mixed CR/LF and LF-only lines.  Since sed operates in\n  # text mode, it properly converts lines to CR/LF.  This bash problem\n  # is reportedly fixed, but why not run on old versions too?\n  sed '$q' \"$ltmain\" >> \"$cfgfile\" \\\n     || (rm -f \"$cfgfile\"; exit 1)\n\n  _LT_PROG_REPLACE_SHELLFNS\n\n   mv -f \"$cfgfile\" \"$ofile\" ||\n    (rm -f \"$ofile\" && cp \"$cfgfile\" \"$ofile\" && rm -f \"$cfgfile\")\n  chmod +x \"$ofile\"\n],\n[cat <<_LT_EOF >> \"$ofile\"\n\ndnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded\ndnl in a comment (ie after a #).\n# ### BEGIN LIBTOOL TAG CONFIG: $1\n_LT_LIBTOOL_TAG_VARS(_LT_TAG)\n# ### END LIBTOOL TAG CONFIG: $1\n_LT_EOF\n])dnl /m4_if\n],\n[m4_if([$1], [], [\n    PACKAGE='$PACKAGE'\n    VERSION='$VERSION'\n    TIMESTAMP='$TIMESTAMP'\n    RM='$RM'\n    ofile='$ofile'], [])\n])dnl /_LT_CONFIG_SAVE_COMMANDS\n])# _LT_CONFIG\n\n\n# LT_SUPPORTED_TAG(TAG)\n# ---------------------\n# Trace this macro to discover what tags are supported by the libtool\n# --tag option, using:\n#    autoconf --trace 'LT_SUPPORTED_TAG:$1'\nAC_DEFUN([LT_SUPPORTED_TAG], [])\n\n\n# C support is built-in for now\nm4_define([_LT_LANG_C_enabled], [])\nm4_define([_LT_TAGS], [])\n\n\n# LT_LANG(LANG)\n# -------------\n# Enable libtool support for the given language if not already enabled.\nAC_DEFUN([LT_LANG],\n[AC_BEFORE([$0], [LT_OUTPUT])dnl\nm4_case([$1],\n  [C],\t\t\t[_LT_LANG(C)],\n  [C++],\t\t[_LT_LANG(CXX)],\n  [Go],\t\t\t[_LT_LANG(GO)],\n  [Java],\t\t[_LT_LANG(GCJ)],\n  [Fortran 77],\t\t[_LT_LANG(F77)],\n  [Fortran],\t\t[_LT_LANG(FC)],\n  [Windows Resource],\t[_LT_LANG(RC)],\n  [m4_ifdef([_LT_LANG_]$1[_CONFIG],\n    [_LT_LANG($1)],\n    [m4_fatal([$0: unsupported language: \"$1\"])])])dnl\n])# LT_LANG\n\n\n# _LT_LANG(LANGNAME)\n# ------------------\nm4_defun([_LT_LANG],\n[m4_ifdef([_LT_LANG_]$1[_enabled], [],\n  [LT_SUPPORTED_TAG([$1])dnl\n  m4_append([_LT_TAGS], [$1 ])dnl\n  m4_define([_LT_LANG_]$1[_enabled], [])dnl\n  _LT_LANG_$1_CONFIG($1)])dnl\n])# _LT_LANG\n\n\nm4_ifndef([AC_PROG_GO], [\n############################################################\n# NOTE: This macro has been submitted for inclusion into   #\n#  GNU Autoconf as AC_PROG_GO.  When it is available in    #\n#  a released version of Autoconf we should remove this    #\n#  macro and use it instead.                               #\n############################################################\nm4_defun([AC_PROG_GO],\n[AC_LANG_PUSH(Go)dnl\nAC_ARG_VAR([GOC],     [Go compiler command])dnl\nAC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl\n_AC_ARG_VAR_LDFLAGS()dnl\nAC_CHECK_TOOL(GOC, gccgo)\nif test -z \"$GOC\"; then\n  if test -n \"$ac_tool_prefix\"; then\n    AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo])\n  fi\nfi\nif test -z \"$GOC\"; then\n  AC_CHECK_PROG(GOC, gccgo, gccgo, false)\nfi\n])#m4_defun\n])#m4_ifndef\n\n\n# _LT_LANG_DEFAULT_CONFIG\n# -----------------------\nm4_defun([_LT_LANG_DEFAULT_CONFIG],\n[AC_PROVIDE_IFELSE([AC_PROG_CXX],\n  [LT_LANG(CXX)],\n  [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])\n\nAC_PROVIDE_IFELSE([AC_PROG_F77],\n  [LT_LANG(F77)],\n  [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])\n\nAC_PROVIDE_IFELSE([AC_PROG_FC],\n  [LT_LANG(FC)],\n  [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])\n\ndnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal\ndnl pulling things in needlessly.\nAC_PROVIDE_IFELSE([AC_PROG_GCJ],\n  [LT_LANG(GCJ)],\n  [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],\n    [LT_LANG(GCJ)],\n    [AC_PROVIDE_IFELSE([LT_PROG_GCJ],\n      [LT_LANG(GCJ)],\n      [m4_ifdef([AC_PROG_GCJ],\n\t[m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])\n       m4_ifdef([A][M_PROG_GCJ],\n\t[m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])\n       m4_ifdef([LT_PROG_GCJ],\n\t[m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])\n\nAC_PROVIDE_IFELSE([AC_PROG_GO],\n  [LT_LANG(GO)],\n  [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])])\n\nAC_PROVIDE_IFELSE([LT_PROG_RC],\n  [LT_LANG(RC)],\n  [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])\n])# _LT_LANG_DEFAULT_CONFIG\n\n# Obsolete macros:\nAU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])\nAU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])\nAU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])\nAU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])\nAU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)])\ndnl aclocal-1.4 backwards compatibility:\ndnl AC_DEFUN([AC_LIBTOOL_CXX], [])\ndnl AC_DEFUN([AC_LIBTOOL_F77], [])\ndnl AC_DEFUN([AC_LIBTOOL_FC], [])\ndnl AC_DEFUN([AC_LIBTOOL_GCJ], [])\ndnl AC_DEFUN([AC_LIBTOOL_RC], [])\n\n\n# _LT_TAG_COMPILER\n# ----------------\nm4_defun([_LT_TAG_COMPILER],\n[AC_REQUIRE([AC_PROG_CC])dnl\n\n_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl\n_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl\n_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl\n_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl\n\n# If no C compiler was specified, use CC.\nLTCC=${LTCC-\"$CC\"}\n\n# If no C compiler flags were specified, use CFLAGS.\nLTCFLAGS=${LTCFLAGS-\"$CFLAGS\"}\n\n# Allow CC to be a program name with arguments.\ncompiler=$CC\n])# _LT_TAG_COMPILER\n\n\n# _LT_COMPILER_BOILERPLATE\n# ------------------------\n# Check for compiler boilerplate output or warnings with\n# the simple compiler test code.\nm4_defun([_LT_COMPILER_BOILERPLATE],\n[m4_require([_LT_DECL_SED])dnl\nac_outfile=conftest.$ac_objext\necho \"$lt_simple_compile_test_code\" >conftest.$ac_ext\neval \"$ac_compile\" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err\n_lt_compiler_boilerplate=`cat conftest.err`\n$RM conftest*\n])# _LT_COMPILER_BOILERPLATE\n\n\n# _LT_LINKER_BOILERPLATE\n# ----------------------\n# Check for linker boilerplate output or warnings with\n# the simple link test code.\nm4_defun([_LT_LINKER_BOILERPLATE],\n[m4_require([_LT_DECL_SED])dnl\nac_outfile=conftest.$ac_objext\necho \"$lt_simple_link_test_code\" >conftest.$ac_ext\neval \"$ac_link\" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err\n_lt_linker_boilerplate=`cat conftest.err`\n$RM -r conftest*\n])# _LT_LINKER_BOILERPLATE\n\n# _LT_REQUIRED_DARWIN_CHECKS\n# -------------------------\nm4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[\n  case $host_os in\n    rhapsody* | darwin*)\n    AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])\n    AC_CHECK_TOOL([NMEDIT], [nmedit], [:])\n    AC_CHECK_TOOL([LIPO], [lipo], [:])\n    AC_CHECK_TOOL([OTOOL], [otool], [:])\n    AC_CHECK_TOOL([OTOOL64], [otool64], [:])\n    _LT_DECL([], [DSYMUTIL], [1],\n      [Tool to manipulate archived DWARF debug symbol files on Mac OS X])\n    _LT_DECL([], [NMEDIT], [1],\n      [Tool to change global to local symbols on Mac OS X])\n    _LT_DECL([], [LIPO], [1],\n      [Tool to manipulate fat objects and archives on Mac OS X])\n    _LT_DECL([], [OTOOL], [1],\n      [ldd/readelf like tool for Mach-O binaries on Mac OS X])\n    _LT_DECL([], [OTOOL64], [1],\n      [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])\n\n    AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],\n      [lt_cv_apple_cc_single_mod=no\n      if test -z \"${LT_MULTI_MODULE}\"; then\n\t# By default we will add the -single_module flag. You can override\n\t# by either setting the environment variable LT_MULTI_MODULE\n\t# non-empty at configure time, or by adding -multi_module to the\n\t# link flags.\n\trm -rf libconftest.dylib*\n\techo \"int foo(void){return 1;}\" > conftest.c\n\techo \"$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \\\n-dynamiclib -Wl,-single_module conftest.c\" >&AS_MESSAGE_LOG_FD\n\t$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \\\n\t  -dynamiclib -Wl,-single_module conftest.c 2>conftest.err\n        _lt_result=$?\n\t# If there is a non-empty error log, and \"single_module\"\n\t# appears in it, assume the flag caused a linker warning\n        if test -s conftest.err && $GREP single_module conftest.err; then\n\t  cat conftest.err >&AS_MESSAGE_LOG_FD\n\t# Otherwise, if the output was created with a 0 exit code from\n\t# the compiler, it worked.\n\telif test -f libconftest.dylib && test $_lt_result -eq 0; then\n\t  lt_cv_apple_cc_single_mod=yes\n\telse\n\t  cat conftest.err >&AS_MESSAGE_LOG_FD\n\tfi\n\trm -rf libconftest.dylib*\n\trm -f conftest.*\n      fi])\n\n    AC_CACHE_CHECK([for -exported_symbols_list linker flag],\n      [lt_cv_ld_exported_symbols_list],\n      [lt_cv_ld_exported_symbols_list=no\n      save_LDFLAGS=$LDFLAGS\n      echo \"_main\" > conftest.sym\n      LDFLAGS=\"$LDFLAGS -Wl,-exported_symbols_list,conftest.sym\"\n      AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],\n\t[lt_cv_ld_exported_symbols_list=yes],\n\t[lt_cv_ld_exported_symbols_list=no])\n\tLDFLAGS=\"$save_LDFLAGS\"\n    ])\n\n    AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load],\n      [lt_cv_ld_force_load=no\n      cat > conftest.c << _LT_EOF\nint forced_loaded() { return 2;}\n_LT_EOF\n      echo \"$LTCC $LTCFLAGS -c -o conftest.o conftest.c\" >&AS_MESSAGE_LOG_FD\n      $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD\n      echo \"$AR cru libconftest.a conftest.o\" >&AS_MESSAGE_LOG_FD\n      $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD\n      echo \"$RANLIB libconftest.a\" >&AS_MESSAGE_LOG_FD\n      $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD\n      cat > conftest.c << _LT_EOF\nint main() { return 0;}\n_LT_EOF\n      echo \"$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a\" >&AS_MESSAGE_LOG_FD\n      $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err\n      _lt_result=$?\n      if test -s conftest.err && $GREP force_load conftest.err; then\n\tcat conftest.err >&AS_MESSAGE_LOG_FD\n      elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then\n\tlt_cv_ld_force_load=yes\n      else\n\tcat conftest.err >&AS_MESSAGE_LOG_FD\n      fi\n        rm -f conftest.err libconftest.a conftest conftest.c\n        rm -rf conftest.dSYM\n    ])\n    case $host_os in\n    rhapsody* | darwin1.[[012]])\n      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;\n    darwin1.*)\n      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;\n    darwin*) # darwin 5.x on\n      # if running on 10.5 or later, the deployment target defaults\n      # to the OS version, if on x86, and 10.4, the deployment\n      # target defaults to 10.4. Don't you love it?\n      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in\n\t10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)\n\t  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;\n\t10.[[012]]*)\n\t  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;\n\t10.*)\n\t  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;\n      esac\n    ;;\n  esac\n    if test \"$lt_cv_apple_cc_single_mod\" = \"yes\"; then\n      _lt_dar_single_mod='$single_module'\n    fi\n    if test \"$lt_cv_ld_exported_symbols_list\" = \"yes\"; then\n      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'\n    else\n      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'\n    fi\n    if test \"$DSYMUTIL\" != \":\" && test \"$lt_cv_ld_force_load\" = \"no\"; then\n      _lt_dsymutil='~$DSYMUTIL $lib || :'\n    else\n      _lt_dsymutil=\n    fi\n    ;;\n  esac\n])\n\n\n# _LT_DARWIN_LINKER_FEATURES([TAG])\n# ---------------------------------\n# Checks for linker and compiler features on darwin\nm4_defun([_LT_DARWIN_LINKER_FEATURES],\n[\n  m4_require([_LT_REQUIRED_DARWIN_CHECKS])\n  _LT_TAGVAR(archive_cmds_need_lc, $1)=no\n  _LT_TAGVAR(hardcode_direct, $1)=no\n  _LT_TAGVAR(hardcode_automatic, $1)=yes\n  _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported\n  if test \"$lt_cv_ld_force_load\" = \"yes\"; then\n    _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\\\"\\\"; do test  -n \\\"$conv\\\" && new_convenience=\\\"$new_convenience ${wl}-force_load,$conv\\\"; done; func_echo_all \\\"$new_convenience\\\"`'\n    m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes],\n                  [FC],  [_LT_TAGVAR(compiler_needs_object, $1)=yes])\n  else\n    _LT_TAGVAR(whole_archive_flag_spec, $1)=''\n  fi\n  _LT_TAGVAR(link_all_deplibs, $1)=yes\n  _LT_TAGVAR(allow_undefined_flag, $1)=\"$_lt_dar_allow_undefined\"\n  case $cc_basename in\n     ifort*) _lt_dar_can_shared=yes ;;\n     *) _lt_dar_can_shared=$GCC ;;\n  esac\n  if test \"$_lt_dar_can_shared\" = \"yes\"; then\n    output_verbose_link_cmd=func_echo_all\n    _LT_TAGVAR(archive_cmds, $1)=\"\\$CC -dynamiclib \\$allow_undefined_flag -o \\$lib \\$libobjs \\$deplibs \\$compiler_flags -install_name \\$rpath/\\$soname \\$verstring $_lt_dar_single_mod${_lt_dsymutil}\"\n    _LT_TAGVAR(module_cmds, $1)=\"\\$CC \\$allow_undefined_flag -o \\$lib -bundle \\$libobjs \\$deplibs \\$compiler_flags${_lt_dsymutil}\"\n    _LT_TAGVAR(archive_expsym_cmds, $1)=\"sed 's,^,_,' < \\$export_symbols > \\$output_objdir/\\${libname}-symbols.expsym~\\$CC -dynamiclib \\$allow_undefined_flag -o \\$lib \\$libobjs \\$deplibs \\$compiler_flags -install_name \\$rpath/\\$soname \\$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}\"\n    _LT_TAGVAR(module_expsym_cmds, $1)=\"sed -e 's,^,_,' < \\$export_symbols > \\$output_objdir/\\${libname}-symbols.expsym~\\$CC \\$allow_undefined_flag -o \\$lib -bundle \\$libobjs \\$deplibs \\$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}\"\n    m4_if([$1], [CXX],\n[   if test \"$lt_cv_apple_cc_single_mod\" != \"yes\"; then\n      _LT_TAGVAR(archive_cmds, $1)=\"\\$CC -r -keep_private_externs -nostdlib -o \\${lib}-master.o \\$libobjs~\\$CC -dynamiclib \\$allow_undefined_flag -o \\$lib \\${lib}-master.o \\$deplibs \\$compiler_flags -install_name \\$rpath/\\$soname \\$verstring${_lt_dsymutil}\"\n      _LT_TAGVAR(archive_expsym_cmds, $1)=\"sed 's,^,_,' < \\$export_symbols > \\$output_objdir/\\${libname}-symbols.expsym~\\$CC -r -keep_private_externs -nostdlib -o \\${lib}-master.o \\$libobjs~\\$CC -dynamiclib \\$allow_undefined_flag -o \\$lib \\${lib}-master.o \\$deplibs \\$compiler_flags -install_name \\$rpath/\\$soname \\$verstring${_lt_dar_export_syms}${_lt_dsymutil}\"\n    fi\n],[])\n  else\n  _LT_TAGVAR(ld_shlibs, $1)=no\n  fi\n])\n\n# _LT_SYS_MODULE_PATH_AIX([TAGNAME])\n# ----------------------------------\n# Links a minimal program and checks the executable\n# for the system default hardcoded library path. In most cases,\n# this is /usr/lib:/lib, but when the MPI compilers are used\n# the location of the communication and MPI libs are included too.\n# If we don't find anything, use the default library path according\n# to the aix ld manual.\n# Store the results from the different compilers for each TAGNAME.\n# Allow to override them for all tags through lt_cv_aix_libpath.\nm4_defun([_LT_SYS_MODULE_PATH_AIX],\n[m4_require([_LT_DECL_SED])dnl\nif test \"${lt_cv_aix_libpath+set}\" = set; then\n  aix_libpath=$lt_cv_aix_libpath\nelse\n  AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])],\n  [AC_LINK_IFELSE([AC_LANG_PROGRAM],[\n  lt_aix_libpath_sed='[\n      /Import File Strings/,/^$/ {\n\t  /^0/ {\n\t      s/^0  *\\([^ ]*\\) *$/\\1/\n\t      p\n\t  }\n      }]'\n  _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e \"$lt_aix_libpath_sed\"`\n  # Check for a 64-bit object if we didn't find anything.\n  if test -z \"$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])\"; then\n    _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e \"$lt_aix_libpath_sed\"`\n  fi],[])\n  if test -z \"$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])\"; then\n    _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=\"/usr/lib:/lib\"\n  fi\n  ])\n  aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])\nfi\n])# _LT_SYS_MODULE_PATH_AIX\n\n\n# _LT_SHELL_INIT(ARG)\n# -------------------\nm4_define([_LT_SHELL_INIT],\n[m4_divert_text([M4SH-INIT], [$1\n])])# _LT_SHELL_INIT\n\n\n\n# _LT_PROG_ECHO_BACKSLASH\n# -----------------------\n# Find how we can fake an echo command that does not interpret backslash.\n# In particular, with Autoconf 2.60 or later we add some code to the start\n# of the generated configure script which will find a shell with a builtin\n# printf (which we can use as an echo command).\nm4_defun([_LT_PROG_ECHO_BACKSLASH],\n[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'\nECHO=$ECHO$ECHO$ECHO$ECHO$ECHO\nECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO\n\nAC_MSG_CHECKING([how to print strings])\n# Test print first, because it will be a builtin if present.\nif test \"X`( print -r -- -n ) 2>/dev/null`\" = X-n && \\\n   test \"X`print -r -- $ECHO 2>/dev/null`\" = \"X$ECHO\"; then\n  ECHO='print -r --'\nelif test \"X`printf %s $ECHO 2>/dev/null`\" = \"X$ECHO\"; then\n  ECHO='printf %s\\n'\nelse\n  # Use this function as a fallback that always works.\n  func_fallback_echo ()\n  {\n    eval 'cat <<_LTECHO_EOF\n$[]1\n_LTECHO_EOF'\n  }\n  ECHO='func_fallback_echo'\nfi\n\n# func_echo_all arg...\n# Invoke $ECHO with all args, space-separated.\nfunc_echo_all ()\n{\n    $ECHO \"$*\" \n}\n\ncase \"$ECHO\" in\n  printf*) AC_MSG_RESULT([printf]) ;;\n  print*) AC_MSG_RESULT([print -r]) ;;\n  *) AC_MSG_RESULT([cat]) ;;\nesac\n\nm4_ifdef([_AS_DETECT_SUGGESTED],\n[_AS_DETECT_SUGGESTED([\n  test -n \"${ZSH_VERSION+set}${BASH_VERSION+set}\" || (\n    ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'\n    ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO\n    ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO\n    PATH=/empty FPATH=/empty; export PATH FPATH\n    test \"X`printf %s $ECHO`\" = \"X$ECHO\" \\\n      || test \"X`print -r -- $ECHO`\" = \"X$ECHO\" )])])\n\n_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])\n_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes])\n])# _LT_PROG_ECHO_BACKSLASH\n\n\n# _LT_WITH_SYSROOT\n# ----------------\nAC_DEFUN([_LT_WITH_SYSROOT],\n[AC_MSG_CHECKING([for sysroot])\nAC_ARG_WITH([sysroot],\n[  --with-sysroot[=DIR] Search for dependent libraries within DIR\n                        (or the compiler's sysroot if not specified).],\n[], [with_sysroot=no])\n\ndnl lt_sysroot will always be passed unquoted.  We quote it here\ndnl in case the user passed a directory name.\nlt_sysroot=\ncase ${with_sysroot} in #(\n yes)\n   if test \"$GCC\" = yes; then\n     lt_sysroot=`$CC --print-sysroot 2>/dev/null`\n   fi\n   ;; #(\n /*)\n   lt_sysroot=`echo \"$with_sysroot\" | sed -e \"$sed_quote_subst\"`\n   ;; #(\n no|'')\n   ;; #(\n *)\n   AC_MSG_RESULT([${with_sysroot}])\n   AC_MSG_ERROR([The sysroot must be an absolute path.])\n   ;;\nesac\n\n AC_MSG_RESULT([${lt_sysroot:-no}])\n_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl\n[dependent libraries, and in which our libraries should be installed.])])\n\n# _LT_ENABLE_LOCK\n# ---------------\nm4_defun([_LT_ENABLE_LOCK],\n[AC_ARG_ENABLE([libtool-lock],\n  [AS_HELP_STRING([--disable-libtool-lock],\n    [avoid locking (might break parallel builds)])])\ntest \"x$enable_libtool_lock\" != xno && enable_libtool_lock=yes\n\n# Some flags need to be propagated to the compiler or linker for good\n# libtool support.\ncase $host in\nia64-*-hpux*)\n  # Find out which ABI we are using.\n  echo 'int i;' > conftest.$ac_ext\n  if AC_TRY_EVAL(ac_compile); then\n    case `/usr/bin/file conftest.$ac_objext` in\n      *ELF-32*)\n\tHPUX_IA64_MODE=\"32\"\n\t;;\n      *ELF-64*)\n\tHPUX_IA64_MODE=\"64\"\n\t;;\n    esac\n  fi\n  rm -rf conftest*\n  ;;\n*-*-irix6*)\n  # Find out which ABI we are using.\n  echo '[#]line '$LINENO' \"configure\"' > conftest.$ac_ext\n  if AC_TRY_EVAL(ac_compile); then\n    if test \"$lt_cv_prog_gnu_ld\" = yes; then\n      case `/usr/bin/file conftest.$ac_objext` in\n\t*32-bit*)\n\t  LD=\"${LD-ld} -melf32bsmip\"\n\t  ;;\n\t*N32*)\n\t  LD=\"${LD-ld} -melf32bmipn32\"\n\t  ;;\n\t*64-bit*)\n\t  LD=\"${LD-ld} -melf64bmip\"\n\t;;\n      esac\n    else\n      case `/usr/bin/file conftest.$ac_objext` in\n\t*32-bit*)\n\t  LD=\"${LD-ld} -32\"\n\t  ;;\n\t*N32*)\n\t  LD=\"${LD-ld} -n32\"\n\t  ;;\n\t*64-bit*)\n\t  LD=\"${LD-ld} -64\"\n\t  ;;\n      esac\n    fi\n  fi\n  rm -rf conftest*\n  ;;\n\nx86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \\\ns390*-*linux*|s390*-*tpf*|sparc*-*linux*)\n  # Find out which ABI we are using.\n  echo 'int i;' > conftest.$ac_ext\n  if AC_TRY_EVAL(ac_compile); then\n    case `/usr/bin/file conftest.o` in\n      *32-bit*)\n\tcase $host in\n\t  x86_64-*kfreebsd*-gnu)\n\t    LD=\"${LD-ld} -m elf_i386_fbsd\"\n\t    ;;\n\t  x86_64-*linux*)\n\t    case `/usr/bin/file conftest.o` in\n\t      *x86-64*)\n\t\tLD=\"${LD-ld} -m elf32_x86_64\"\n\t\t;;\n\t      *)\n\t\tLD=\"${LD-ld} -m elf_i386\"\n\t\t;;\n\t    esac\n\t    ;;\n\t  powerpc64le-*)\n\t    LD=\"${LD-ld} -m elf32lppclinux\"\n\t    ;;\n\t  powerpc64-*)\n\t    LD=\"${LD-ld} -m elf32ppclinux\"\n\t    ;;\n\t  s390x-*linux*)\n\t    LD=\"${LD-ld} -m elf_s390\"\n\t    ;;\n\t  sparc64-*linux*)\n\t    LD=\"${LD-ld} -m elf32_sparc\"\n\t    ;;\n\tesac\n\t;;\n      *64-bit*)\n\tcase $host in\n\t  x86_64-*kfreebsd*-gnu)\n\t    LD=\"${LD-ld} -m elf_x86_64_fbsd\"\n\t    ;;\n\t  x86_64-*linux*)\n\t    LD=\"${LD-ld} -m elf_x86_64\"\n\t    ;;\n\t  powerpcle-*)\n\t    LD=\"${LD-ld} -m elf64lppc\"\n\t    ;;\n\t  powerpc-*)\n\t    LD=\"${LD-ld} -m elf64ppc\"\n\t    ;;\n\t  s390*-*linux*|s390*-*tpf*)\n\t    LD=\"${LD-ld} -m elf64_s390\"\n\t    ;;\n\t  sparc*-*linux*)\n\t    LD=\"${LD-ld} -m elf64_sparc\"\n\t    ;;\n\tesac\n\t;;\n    esac\n  fi\n  rm -rf conftest*\n  ;;\n\n*-*-sco3.2v5*)\n  # On SCO OpenServer 5, we need -belf to get full-featured binaries.\n  SAVE_CFLAGS=\"$CFLAGS\"\n  CFLAGS=\"$CFLAGS -belf\"\n  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,\n    [AC_LANG_PUSH(C)\n     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])\n     AC_LANG_POP])\n  if test x\"$lt_cv_cc_needs_belf\" != x\"yes\"; then\n    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf\n    CFLAGS=\"$SAVE_CFLAGS\"\n  fi\n  ;;\n*-*solaris*)\n  # Find out which ABI we are using.\n  echo 'int i;' > conftest.$ac_ext\n  if AC_TRY_EVAL(ac_compile); then\n    case `/usr/bin/file conftest.o` in\n    *64-bit*)\n      case $lt_cv_prog_gnu_ld in\n      yes*)\n        case $host in\n        i?86-*-solaris*)\n          LD=\"${LD-ld} -m elf_x86_64\"\n          ;;\n        sparc*-*-solaris*)\n          LD=\"${LD-ld} -m elf64_sparc\"\n          ;;\n        esac\n        # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.\n        if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then\n          LD=\"${LD-ld}_sol2\"\n        fi\n        ;;\n      *)\n\tif ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then\n\t  LD=\"${LD-ld} -64\"\n\tfi\n\t;;\n      esac\n      ;;\n    esac\n  fi\n  rm -rf conftest*\n  ;;\nesac\n\nneed_locks=\"$enable_libtool_lock\"\n])# _LT_ENABLE_LOCK\n\n\n# _LT_PROG_AR\n# -----------\nm4_defun([_LT_PROG_AR],\n[AC_CHECK_TOOLS(AR, [ar], false)\n: ${AR=ar}\n: ${AR_FLAGS=cru}\n_LT_DECL([], [AR], [1], [The archiver])\n_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive])\n\nAC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file],\n  [lt_cv_ar_at_file=no\n   AC_COMPILE_IFELSE([AC_LANG_PROGRAM],\n     [echo conftest.$ac_objext > conftest.lst\n      lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD'\n      AC_TRY_EVAL([lt_ar_try])\n      if test \"$ac_status\" -eq 0; then\n\t# Ensure the archiver fails upon bogus file names.\n\trm -f conftest.$ac_objext libconftest.a\n\tAC_TRY_EVAL([lt_ar_try])\n\tif test \"$ac_status\" -ne 0; then\n          lt_cv_ar_at_file=@\n        fi\n      fi\n      rm -f conftest.* libconftest.a\n     ])\n  ])\n\nif test \"x$lt_cv_ar_at_file\" = xno; then\n  archiver_list_spec=\nelse\n  archiver_list_spec=$lt_cv_ar_at_file\nfi\n_LT_DECL([], [archiver_list_spec], [1],\n  [How to feed a file listing to the archiver])\n])# _LT_PROG_AR\n\n\n# _LT_CMD_OLD_ARCHIVE\n# -------------------\nm4_defun([_LT_CMD_OLD_ARCHIVE],\n[_LT_PROG_AR\n\nAC_CHECK_TOOL(STRIP, strip, :)\ntest -z \"$STRIP\" && STRIP=:\n_LT_DECL([], [STRIP], [1], [A symbol stripping program])\n\nAC_CHECK_TOOL(RANLIB, ranlib, :)\ntest -z \"$RANLIB\" && RANLIB=:\n_LT_DECL([], [RANLIB], [1],\n    [Commands used to install an old-style archive])\n\n# Determine commands to create old-style static archives.\nold_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'\nold_postinstall_cmds='chmod 644 $oldlib'\nold_postuninstall_cmds=\n\nif test -n \"$RANLIB\"; then\n  case $host_os in\n  openbsd*)\n    old_postinstall_cmds=\"$old_postinstall_cmds~\\$RANLIB -t \\$tool_oldlib\"\n    ;;\n  *)\n    old_postinstall_cmds=\"$old_postinstall_cmds~\\$RANLIB \\$tool_oldlib\"\n    ;;\n  esac\n  old_archive_cmds=\"$old_archive_cmds~\\$RANLIB \\$tool_oldlib\"\nfi\n\ncase $host_os in\n  darwin*)\n    lock_old_archive_extraction=yes ;;\n  *)\n    lock_old_archive_extraction=no ;;\nesac\n_LT_DECL([], [old_postinstall_cmds], [2])\n_LT_DECL([], [old_postuninstall_cmds], [2])\n_LT_TAGDECL([], [old_archive_cmds], [2],\n    [Commands used to build an old-style archive])\n_LT_DECL([], [lock_old_archive_extraction], [0],\n    [Whether to use a lock for old archive extraction])\n])# _LT_CMD_OLD_ARCHIVE\n\n\n# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,\n#\t\t[OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])\n# ----------------------------------------------------------------\n# Check whether the given compiler option works\nAC_DEFUN([_LT_COMPILER_OPTION],\n[m4_require([_LT_FILEUTILS_DEFAULTS])dnl\nm4_require([_LT_DECL_SED])dnl\nAC_CACHE_CHECK([$1], [$2],\n  [$2=no\n   m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])\n   echo \"$lt_simple_compile_test_code\" > conftest.$ac_ext\n   lt_compiler_flag=\"$3\"\n   # Insert the option either (1) after the last *FLAGS variable, or\n   # (2) before a word containing \"conftest.\", or (3) at the end.\n   # Note that $ac_compile itself does not contain backslashes and begins\n   # with a dollar sign (not a hyphen), so the echo should work correctly.\n   # The option is referenced via a variable to avoid confusing sed.\n   lt_compile=`echo \"$ac_compile\" | $SED \\\n   -e 's:.*FLAGS}\\{0,1\\} :&$lt_compiler_flag :; t' \\\n   -e 's: [[^ ]]*conftest\\.: $lt_compiler_flag&:; t' \\\n   -e 's:$: $lt_compiler_flag:'`\n   (eval echo \"\\\"\\$as_me:$LINENO: $lt_compile\\\"\" >&AS_MESSAGE_LOG_FD)\n   (eval \"$lt_compile\" 2>conftest.err)\n   ac_status=$?\n   cat conftest.err >&AS_MESSAGE_LOG_FD\n   echo \"$as_me:$LINENO: \\$? = $ac_status\" >&AS_MESSAGE_LOG_FD\n   if (exit $ac_status) && test -s \"$ac_outfile\"; then\n     # The compiler can only warn and ignore the option if not recognized\n     # So say no if there are warnings other than the usual output.\n     $ECHO \"$_lt_compiler_boilerplate\" | $SED '/^$/d' >conftest.exp\n     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2\n     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then\n       $2=yes\n     fi\n   fi\n   $RM conftest*\n])\n\nif test x\"[$]$2\" = xyes; then\n    m4_if([$5], , :, [$5])\nelse\n    m4_if([$6], , :, [$6])\nfi\n])# _LT_COMPILER_OPTION\n\n# Old name:\nAU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])\ndnl aclocal-1.4 backwards compatibility:\ndnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])\n\n\n# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,\n#                  [ACTION-SUCCESS], [ACTION-FAILURE])\n# ----------------------------------------------------\n# Check whether the given linker option works\nAC_DEFUN([_LT_LINKER_OPTION],\n[m4_require([_LT_FILEUTILS_DEFAULTS])dnl\nm4_require([_LT_DECL_SED])dnl\nAC_CACHE_CHECK([$1], [$2],\n  [$2=no\n   save_LDFLAGS=\"$LDFLAGS\"\n   LDFLAGS=\"$LDFLAGS $3\"\n   echo \"$lt_simple_link_test_code\" > conftest.$ac_ext\n   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then\n     # The linker can only warn and ignore the option if not recognized\n     # So say no if there are warnings\n     if test -s conftest.err; then\n       # Append any errors to the config.log.\n       cat conftest.err 1>&AS_MESSAGE_LOG_FD\n       $ECHO \"$_lt_linker_boilerplate\" | $SED '/^$/d' > conftest.exp\n       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2\n       if diff conftest.exp conftest.er2 >/dev/null; then\n         $2=yes\n       fi\n     else\n       $2=yes\n     fi\n   fi\n   $RM -r conftest*\n   LDFLAGS=\"$save_LDFLAGS\"\n])\n\nif test x\"[$]$2\" = xyes; then\n    m4_if([$4], , :, [$4])\nelse\n    m4_if([$5], , :, [$5])\nfi\n])# _LT_LINKER_OPTION\n\n# Old name:\nAU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])\ndnl aclocal-1.4 backwards compatibility:\ndnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])\n\n\n# LT_CMD_MAX_LEN\n#---------------\nAC_DEFUN([LT_CMD_MAX_LEN],\n[AC_REQUIRE([AC_CANONICAL_HOST])dnl\n# find the maximum length of command line arguments\nAC_MSG_CHECKING([the maximum length of command line arguments])\nAC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl\n  i=0\n  teststring=\"ABCD\"\n\n  case $build_os in\n  msdosdjgpp*)\n    # On DJGPP, this test can blow up pretty badly due to problems in libc\n    # (any single argument exceeding 2000 bytes causes a buffer overrun\n    # during glob expansion).  Even if it were fixed, the result of this\n    # check would be larger than it should be.\n    lt_cv_sys_max_cmd_len=12288;    # 12K is about right\n    ;;\n\n  gnu*)\n    # Under GNU Hurd, this test is not required because there is\n    # no limit to the length of command line arguments.\n    # Libtool will interpret -1 as no limit whatsoever\n    lt_cv_sys_max_cmd_len=-1;\n    ;;\n\n  cygwin* | mingw* | cegcc*)\n    # On Win9x/ME, this test blows up -- it succeeds, but takes\n    # about 5 minutes as the teststring grows exponentially.\n    # Worse, since 9x/ME are not pre-emptively multitasking,\n    # you end up with a \"frozen\" computer, even though with patience\n    # the test eventually succeeds (with a max line length of 256k).\n    # Instead, let's just punt: use the minimum linelength reported by\n    # all of the supported platforms: 8192 (on NT/2K/XP).\n    lt_cv_sys_max_cmd_len=8192;\n    ;;\n\n  mint*)\n    # On MiNT this can take a long time and run out of memory.\n    lt_cv_sys_max_cmd_len=8192;\n    ;;\n\n  amigaos*)\n    # On AmigaOS with pdksh, this test takes hours, literally.\n    # So we just punt and use a minimum line length of 8192.\n    lt_cv_sys_max_cmd_len=8192;\n    ;;\n\n  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)\n    # This has been around since 386BSD, at least.  Likely further.\n    if test -x /sbin/sysctl; then\n      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`\n    elif test -x /usr/sbin/sysctl; then\n      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`\n    else\n      lt_cv_sys_max_cmd_len=65536\t# usable default for all BSDs\n    fi\n    # And add a safety zone\n    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \\/ 4`\n    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \\* 3`\n    ;;\n\n  interix*)\n    # We know the value 262144 and hardcode it with a safety zone (like BSD)\n    lt_cv_sys_max_cmd_len=196608\n    ;;\n\n  os2*)\n    # The test takes a long time on OS/2.\n    lt_cv_sys_max_cmd_len=8192\n    ;;\n\n  osf*)\n    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure\n    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not\n    # nice to cause kernel panics so lets avoid the loop below.\n    # First set a reasonable default.\n    lt_cv_sys_max_cmd_len=16384\n    #\n    if test -x /sbin/sysconfig; then\n      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in\n        *1*) lt_cv_sys_max_cmd_len=-1 ;;\n      esac\n    fi\n    ;;\n  sco3.2v5*)\n    lt_cv_sys_max_cmd_len=102400\n    ;;\n  sysv5* | sco5v6* | sysv4.2uw2*)\n    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`\n    if test -n \"$kargmax\"; then\n      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[\t ]]//'`\n    else\n      lt_cv_sys_max_cmd_len=32768\n    fi\n    ;;\n  *)\n    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`\n    if test -n \"$lt_cv_sys_max_cmd_len\" && \\\n\ttest undefined != \"$lt_cv_sys_max_cmd_len\"; then\n      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \\/ 4`\n      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \\* 3`\n    else\n      # Make teststring a little bigger before we do anything with it.\n      # a 1K string should be a reasonable start.\n      for i in 1 2 3 4 5 6 7 8 ; do\n        teststring=$teststring$teststring\n      done\n      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}\n      # If test is not a shell built-in, we'll probably end up computing a\n      # maximum length that is only half of the actual maximum length, but\n      # we can't tell.\n      while { test \"X\"`env echo \"$teststring$teststring\" 2>/dev/null` \\\n\t         = \"X$teststring$teststring\"; } >/dev/null 2>&1 &&\n\t      test $i != 17 # 1/2 MB should be enough\n      do\n        i=`expr $i + 1`\n        teststring=$teststring$teststring\n      done\n      # Only check the string length outside the loop.\n      lt_cv_sys_max_cmd_len=`expr \"X$teststring\" : \".*\" 2>&1`\n      teststring=\n      # Add a significant safety factor because C++ compilers can tack on\n      # massive amounts of additional arguments before passing them to the\n      # linker.  It appears as though 1/2 is a usable value.\n      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \\/ 2`\n    fi\n    ;;\n  esac\n])\nif test -n $lt_cv_sys_max_cmd_len ; then\n  AC_MSG_RESULT($lt_cv_sys_max_cmd_len)\nelse\n  AC_MSG_RESULT(none)\nfi\nmax_cmd_len=$lt_cv_sys_max_cmd_len\n_LT_DECL([], [max_cmd_len], [0],\n    [What is the maximum length of a command?])\n])# LT_CMD_MAX_LEN\n\n# Old name:\nAU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])\ndnl aclocal-1.4 backwards compatibility:\ndnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])\n\n\n# _LT_HEADER_DLFCN\n# ----------------\nm4_defun([_LT_HEADER_DLFCN],\n[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl\n])# _LT_HEADER_DLFCN\n\n\n# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,\n#                      ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)\n# ----------------------------------------------------------------\nm4_defun([_LT_TRY_DLOPEN_SELF],\n[m4_require([_LT_HEADER_DLFCN])dnl\nif test \"$cross_compiling\" = yes; then :\n  [$4]\nelse\n  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2\n  lt_status=$lt_dlunknown\n  cat > conftest.$ac_ext <<_LT_EOF\n[#line $LINENO \"configure\"\n#include \"confdefs.h\"\n\n#if HAVE_DLFCN_H\n#include <dlfcn.h>\n#endif\n\n#include <stdio.h>\n\n#ifdef RTLD_GLOBAL\n#  define LT_DLGLOBAL\t\tRTLD_GLOBAL\n#else\n#  ifdef DL_GLOBAL\n#    define LT_DLGLOBAL\t\tDL_GLOBAL\n#  else\n#    define LT_DLGLOBAL\t\t0\n#  endif\n#endif\n\n/* We may have to define LT_DLLAZY_OR_NOW in the command line if we\n   find out it does not work in some platform. */\n#ifndef LT_DLLAZY_OR_NOW\n#  ifdef RTLD_LAZY\n#    define LT_DLLAZY_OR_NOW\t\tRTLD_LAZY\n#  else\n#    ifdef DL_LAZY\n#      define LT_DLLAZY_OR_NOW\t\tDL_LAZY\n#    else\n#      ifdef RTLD_NOW\n#        define LT_DLLAZY_OR_NOW\tRTLD_NOW\n#      else\n#        ifdef DL_NOW\n#          define LT_DLLAZY_OR_NOW\tDL_NOW\n#        else\n#          define LT_DLLAZY_OR_NOW\t0\n#        endif\n#      endif\n#    endif\n#  endif\n#endif\n\n/* When -fvisbility=hidden is used, assume the code has been annotated\n   correspondingly for the symbols needed.  */\n#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))\nint fnord () __attribute__((visibility(\"default\")));\n#endif\n\nint fnord () { return 42; }\nint main ()\n{\n  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);\n  int status = $lt_dlunknown;\n\n  if (self)\n    {\n      if (dlsym (self,\"fnord\"))       status = $lt_dlno_uscore;\n      else\n        {\n\t  if (dlsym( self,\"_fnord\"))  status = $lt_dlneed_uscore;\n          else puts (dlerror ());\n\t}\n      /* dlclose (self); */\n    }\n  else\n    puts (dlerror ());\n\n  return status;\n}]\n_LT_EOF\n  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then\n    (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null\n    lt_status=$?\n    case x$lt_status in\n      x$lt_dlno_uscore) $1 ;;\n      x$lt_dlneed_uscore) $2 ;;\n      x$lt_dlunknown|x*) $3 ;;\n    esac\n  else :\n    # compilation failed\n    $3\n  fi\nfi\nrm -fr conftest*\n])# _LT_TRY_DLOPEN_SELF\n\n\n# LT_SYS_DLOPEN_SELF\n# ------------------\nAC_DEFUN([LT_SYS_DLOPEN_SELF],\n[m4_require([_LT_HEADER_DLFCN])dnl\nif test \"x$enable_dlopen\" != xyes; then\n  enable_dlopen=unknown\n  enable_dlopen_self=unknown\n  enable_dlopen_self_static=unknown\nelse\n  lt_cv_dlopen=no\n  lt_cv_dlopen_libs=\n\n  case $host_os in\n  beos*)\n    lt_cv_dlopen=\"load_add_on\"\n    lt_cv_dlopen_libs=\n    lt_cv_dlopen_self=yes\n    ;;\n\n  mingw* | pw32* | cegcc*)\n    lt_cv_dlopen=\"LoadLibrary\"\n    lt_cv_dlopen_libs=\n    ;;\n\n  cygwin*)\n    lt_cv_dlopen=\"dlopen\"\n    lt_cv_dlopen_libs=\n    ;;\n\n  darwin*)\n  # if libdl is installed we need to link against it\n    AC_CHECK_LIB([dl], [dlopen],\n\t\t[lt_cv_dlopen=\"dlopen\" lt_cv_dlopen_libs=\"-ldl\"],[\n    lt_cv_dlopen=\"dyld\"\n    lt_cv_dlopen_libs=\n    lt_cv_dlopen_self=yes\n    ])\n    ;;\n\n  *)\n    AC_CHECK_FUNC([shl_load],\n\t  [lt_cv_dlopen=\"shl_load\"],\n      [AC_CHECK_LIB([dld], [shl_load],\n\t    [lt_cv_dlopen=\"shl_load\" lt_cv_dlopen_libs=\"-ldld\"],\n\t[AC_CHECK_FUNC([dlopen],\n\t      [lt_cv_dlopen=\"dlopen\"],\n\t  [AC_CHECK_LIB([dl], [dlopen],\n\t\t[lt_cv_dlopen=\"dlopen\" lt_cv_dlopen_libs=\"-ldl\"],\n\t    [AC_CHECK_LIB([svld], [dlopen],\n\t\t  [lt_cv_dlopen=\"dlopen\" lt_cv_dlopen_libs=\"-lsvld\"],\n\t      [AC_CHECK_LIB([dld], [dld_link],\n\t\t    [lt_cv_dlopen=\"dld_link\" lt_cv_dlopen_libs=\"-ldld\"])\n\t      ])\n\t    ])\n\t  ])\n\t])\n      ])\n    ;;\n  esac\n\n  if test \"x$lt_cv_dlopen\" != xno; then\n    enable_dlopen=yes\n  else\n    enable_dlopen=no\n  fi\n\n  case $lt_cv_dlopen in\n  dlopen)\n    save_CPPFLAGS=\"$CPPFLAGS\"\n    test \"x$ac_cv_header_dlfcn_h\" = xyes && CPPFLAGS=\"$CPPFLAGS -DHAVE_DLFCN_H\"\n\n    save_LDFLAGS=\"$LDFLAGS\"\n    wl=$lt_prog_compiler_wl eval LDFLAGS=\\\"\\$LDFLAGS $export_dynamic_flag_spec\\\"\n\n    save_LIBS=\"$LIBS\"\n    LIBS=\"$lt_cv_dlopen_libs $LIBS\"\n\n    AC_CACHE_CHECK([whether a program can dlopen itself],\n\t  lt_cv_dlopen_self, [dnl\n\t  _LT_TRY_DLOPEN_SELF(\n\t    lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,\n\t    lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)\n    ])\n\n    if test \"x$lt_cv_dlopen_self\" = xyes; then\n      wl=$lt_prog_compiler_wl eval LDFLAGS=\\\"\\$LDFLAGS $lt_prog_compiler_static\\\"\n      AC_CACHE_CHECK([whether a statically linked program can dlopen itself],\n\t  lt_cv_dlopen_self_static, [dnl\n\t  _LT_TRY_DLOPEN_SELF(\n\t    lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,\n\t    lt_cv_dlopen_self_static=no,  lt_cv_dlopen_self_static=cross)\n      ])\n    fi\n\n    CPPFLAGS=\"$save_CPPFLAGS\"\n    LDFLAGS=\"$save_LDFLAGS\"\n    LIBS=\"$save_LIBS\"\n    ;;\n  esac\n\n  case $lt_cv_dlopen_self in\n  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;\n  *) enable_dlopen_self=unknown ;;\n  esac\n\n  case $lt_cv_dlopen_self_static in\n  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;\n  *) enable_dlopen_self_static=unknown ;;\n  esac\nfi\n_LT_DECL([dlopen_support], [enable_dlopen], [0],\n\t [Whether dlopen is supported])\n_LT_DECL([dlopen_self], [enable_dlopen_self], [0],\n\t [Whether dlopen of programs is supported])\n_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],\n\t [Whether dlopen of statically linked programs is supported])\n])# LT_SYS_DLOPEN_SELF\n\n# Old name:\nAU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])\ndnl aclocal-1.4 backwards compatibility:\ndnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])\n\n\n# _LT_COMPILER_C_O([TAGNAME])\n# ---------------------------\n# Check to see if options -c and -o are simultaneously supported by compiler.\n# This macro does not hard code the compiler like AC_PROG_CC_C_O.\nm4_defun([_LT_COMPILER_C_O],\n[m4_require([_LT_DECL_SED])dnl\nm4_require([_LT_FILEUTILS_DEFAULTS])dnl\nm4_require([_LT_TAG_COMPILER])dnl\nAC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],\n  [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],\n  [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no\n   $RM -r conftest 2>/dev/null\n   mkdir conftest\n   cd conftest\n   mkdir out\n   echo \"$lt_simple_compile_test_code\" > conftest.$ac_ext\n\n   lt_compiler_flag=\"-o out/conftest2.$ac_objext\"\n   # Insert the option either (1) after the last *FLAGS variable, or\n   # (2) before a word containing \"conftest.\", or (3) at the end.\n   # Note that $ac_compile itself does not contain backslashes and begins\n   # with a dollar sign (not a hyphen), so the echo should work correctly.\n   lt_compile=`echo \"$ac_compile\" | $SED \\\n   -e 's:.*FLAGS}\\{0,1\\} :&$lt_compiler_flag :; t' \\\n   -e 's: [[^ ]]*conftest\\.: $lt_compiler_flag&:; t' \\\n   -e 's:$: $lt_compiler_flag:'`\n   (eval echo \"\\\"\\$as_me:$LINENO: $lt_compile\\\"\" >&AS_MESSAGE_LOG_FD)\n   (eval \"$lt_compile\" 2>out/conftest.err)\n   ac_status=$?\n   cat out/conftest.err >&AS_MESSAGE_LOG_FD\n   echo \"$as_me:$LINENO: \\$? = $ac_status\" >&AS_MESSAGE_LOG_FD\n   if (exit $ac_status) && test -s out/conftest2.$ac_objext\n   then\n     # The compiler can only warn and ignore the option if not recognized\n     # So say no if there are warnings\n     $ECHO \"$_lt_compiler_boilerplate\" | $SED '/^$/d' > out/conftest.exp\n     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2\n     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then\n       _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes\n     fi\n   fi\n   chmod u+w . 2>&AS_MESSAGE_LOG_FD\n   $RM conftest*\n   # SGI C++ compiler will create directory out/ii_files/ for\n   # template instantiation\n   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files\n   $RM out/* && rmdir out\n   cd ..\n   $RM -r conftest\n   $RM conftest*\n])\n_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],\n\t[Does compiler simultaneously support -c and -o options?])\n])# _LT_COMPILER_C_O\n\n\n# _LT_COMPILER_FILE_LOCKS([TAGNAME])\n# ----------------------------------\n# Check to see if we can do hard links to lock some files if needed\nm4_defun([_LT_COMPILER_FILE_LOCKS],\n[m4_require([_LT_ENABLE_LOCK])dnl\nm4_require([_LT_FILEUTILS_DEFAULTS])dnl\n_LT_COMPILER_C_O([$1])\n\nhard_links=\"nottested\"\nif test \"$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)\" = no && test \"$need_locks\" != no; then\n  # do not overwrite the value of need_locks provided by the user\n  AC_MSG_CHECKING([if we can lock with hard links])\n  hard_links=yes\n  $RM conftest*\n  ln conftest.a conftest.b 2>/dev/null && hard_links=no\n  touch conftest.a\n  ln conftest.a conftest.b 2>&5 || hard_links=no\n  ln conftest.a conftest.b 2>/dev/null && hard_links=no\n  AC_MSG_RESULT([$hard_links])\n  if test \"$hard_links\" = no; then\n    AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])\n    need_locks=warn\n  fi\nelse\n  need_locks=no\nfi\n_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])\n])# _LT_COMPILER_FILE_LOCKS\n\n\n# _LT_CHECK_OBJDIR\n# ----------------\nm4_defun([_LT_CHECK_OBJDIR],\n[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],\n[rm -f .libs 2>/dev/null\nmkdir .libs 2>/dev/null\nif test -d .libs; then\n  lt_cv_objdir=.libs\nelse\n  # MS-DOS does not allow filenames that begin with a dot.\n  lt_cv_objdir=_libs\nfi\nrmdir .libs 2>/dev/null])\nobjdir=$lt_cv_objdir\n_LT_DECL([], [objdir], [0],\n         [The name of the directory that contains temporary libtool files])dnl\nm4_pattern_allow([LT_OBJDIR])dnl\nAC_DEFINE_UNQUOTED(LT_OBJDIR, \"$lt_cv_objdir/\",\n  [Define to the sub-directory in which libtool stores uninstalled libraries.])\n])# _LT_CHECK_OBJDIR\n\n\n# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])\n# --------------------------------------\n# Check hardcoding attributes.\nm4_defun([_LT_LINKER_HARDCODE_LIBPATH],\n[AC_MSG_CHECKING([how to hardcode library paths into programs])\n_LT_TAGVAR(hardcode_action, $1)=\nif test -n \"$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\" ||\n   test -n \"$_LT_TAGVAR(runpath_var, $1)\" ||\n   test \"X$_LT_TAGVAR(hardcode_automatic, $1)\" = \"Xyes\" ; then\n\n  # We can hardcode non-existent directories.\n  if test \"$_LT_TAGVAR(hardcode_direct, $1)\" != no &&\n     # If the only mechanism to avoid hardcoding is shlibpath_var, we\n     # have to relink, otherwise we might link with an installed library\n     # when we should be linking with a yet-to-be-installed one\n     ## test \"$_LT_TAGVAR(hardcode_shlibpath_var, $1)\" != no &&\n     test \"$_LT_TAGVAR(hardcode_minus_L, $1)\" != no; then\n    # Linking always hardcodes the temporary library directory.\n    _LT_TAGVAR(hardcode_action, $1)=relink\n  else\n    # We can link without hardcoding, and we can hardcode nonexisting dirs.\n    _LT_TAGVAR(hardcode_action, $1)=immediate\n  fi\nelse\n  # We cannot hardcode anything, or else we can only hardcode existing\n  # directories.\n  _LT_TAGVAR(hardcode_action, $1)=unsupported\nfi\nAC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])\n\nif test \"$_LT_TAGVAR(hardcode_action, $1)\" = relink ||\n   test \"$_LT_TAGVAR(inherit_rpath, $1)\" = yes; then\n  # Fast installation is not supported\n  enable_fast_install=no\nelif test \"$shlibpath_overrides_runpath\" = yes ||\n     test \"$enable_shared\" = no; then\n  # Fast installation is not necessary\n  enable_fast_install=needless\nfi\n_LT_TAGDECL([], [hardcode_action], [0],\n    [How to hardcode a shared library path into an executable])\n])# _LT_LINKER_HARDCODE_LIBPATH\n\n\n# _LT_CMD_STRIPLIB\n# ----------------\nm4_defun([_LT_CMD_STRIPLIB],\n[m4_require([_LT_DECL_EGREP])\nstriplib=\nold_striplib=\nAC_MSG_CHECKING([whether stripping libraries is possible])\nif test -n \"$STRIP\" && $STRIP -V 2>&1 | $GREP \"GNU strip\" >/dev/null; then\n  test -z \"$old_striplib\" && old_striplib=\"$STRIP --strip-debug\"\n  test -z \"$striplib\" && striplib=\"$STRIP --strip-unneeded\"\n  AC_MSG_RESULT([yes])\nelse\n# FIXME - insert some real tests, host_os isn't really good enough\n  case $host_os in\n  darwin*)\n    if test -n \"$STRIP\" ; then\n      striplib=\"$STRIP -x\"\n      old_striplib=\"$STRIP -S\"\n      AC_MSG_RESULT([yes])\n    else\n      AC_MSG_RESULT([no])\n    fi\n    ;;\n  *)\n    AC_MSG_RESULT([no])\n    ;;\n  esac\nfi\n_LT_DECL([], [old_striplib], [1], [Commands to strip libraries])\n_LT_DECL([], [striplib], [1])\n])# _LT_CMD_STRIPLIB\n\n\n# _LT_SYS_DYNAMIC_LINKER([TAG])\n# -----------------------------\n# PORTME Fill in your ld.so characteristics\nm4_defun([_LT_SYS_DYNAMIC_LINKER],\n[AC_REQUIRE([AC_CANONICAL_HOST])dnl\nm4_require([_LT_DECL_EGREP])dnl\nm4_require([_LT_FILEUTILS_DEFAULTS])dnl\nm4_require([_LT_DECL_OBJDUMP])dnl\nm4_require([_LT_DECL_SED])dnl\nm4_require([_LT_CHECK_SHELL_FEATURES])dnl\nAC_MSG_CHECKING([dynamic linker characteristics])\nm4_if([$1],\n\t[], [\nif test \"$GCC\" = yes; then\n  case $host_os in\n    darwin*) lt_awk_arg=\"/^libraries:/,/LR/\" ;;\n    *) lt_awk_arg=\"/^libraries:/\" ;;\n  esac\n  case $host_os in\n    mingw* | cegcc*) lt_sed_strip_eq=\"s,=\\([[A-Za-z]]:\\),\\1,g\" ;;\n    *) lt_sed_strip_eq=\"s,=/,/,g\" ;;\n  esac\n  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e \"s/^libraries://\" -e $lt_sed_strip_eq`\n  case $lt_search_path_spec in\n  *\\;*)\n    # if the path contains \";\" then we assume it to be the separator\n    # otherwise default to the standard path separator (i.e. \":\") - it is\n    # assumed that no part of a normal pathname contains \";\" but that should\n    # okay in the real world where \";\" in dirpaths is itself problematic.\n    lt_search_path_spec=`$ECHO \"$lt_search_path_spec\" | $SED 's/;/ /g'`\n    ;;\n  *)\n    lt_search_path_spec=`$ECHO \"$lt_search_path_spec\" | $SED \"s/$PATH_SEPARATOR/ /g\"`\n    ;;\n  esac\n  # Ok, now we have the path, separated by spaces, we can step through it\n  # and add multilib dir if necessary.\n  lt_tmp_lt_search_path_spec=\n  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`\n  for lt_sys_path in $lt_search_path_spec; do\n    if test -d \"$lt_sys_path/$lt_multi_os_dir\"; then\n      lt_tmp_lt_search_path_spec=\"$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir\"\n    else\n      test -d \"$lt_sys_path\" && \\\n\tlt_tmp_lt_search_path_spec=\"$lt_tmp_lt_search_path_spec $lt_sys_path\"\n    fi\n  done\n  lt_search_path_spec=`$ECHO \"$lt_tmp_lt_search_path_spec\" | awk '\nBEGIN {RS=\" \"; FS=\"/|\\n\";} {\n  lt_foo=\"\";\n  lt_count=0;\n  for (lt_i = NF; lt_i > 0; lt_i--) {\n    if ($lt_i != \"\" && $lt_i != \".\") {\n      if ($lt_i == \"..\") {\n        lt_count++;\n      } else {\n        if (lt_count == 0) {\n          lt_foo=\"/\" $lt_i lt_foo;\n        } else {\n          lt_count--;\n        }\n      }\n    }\n  }\n  if (lt_foo != \"\") { lt_freq[[lt_foo]]++; }\n  if (lt_freq[[lt_foo]] == 1) { print lt_foo; }\n}'`\n  # AWK program above erroneously prepends '/' to C:/dos/paths\n  # for these hosts.\n  case $host_os in\n    mingw* | cegcc*) lt_search_path_spec=`$ECHO \"$lt_search_path_spec\" |\\\n      $SED 's,/\\([[A-Za-z]]:\\),\\1,g'` ;;\n  esac\n  sys_lib_search_path_spec=`$ECHO \"$lt_search_path_spec\" | $lt_NL2SP`\nelse\n  sys_lib_search_path_spec=\"/lib /usr/lib /usr/local/lib\"\nfi])\nlibrary_names_spec=\nlibname_spec='lib$name'\nsoname_spec=\nshrext_cmds=\".so\"\npostinstall_cmds=\npostuninstall_cmds=\nfinish_cmds=\nfinish_eval=\nshlibpath_var=\nshlibpath_overrides_runpath=unknown\nversion_type=none\ndynamic_linker=\"$host_os ld.so\"\nsys_lib_dlsearch_path_spec=\"/lib /usr/lib\"\nneed_lib_prefix=unknown\nhardcode_into_libs=no\n\n# when you set need_version to no, make sure it does not cause -set_version\n# flags to be left without arguments\nneed_version=unknown\n\ncase $host_os in\naix3*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'\n  shlibpath_var=LIBPATH\n\n  # AIX 3 has no versioning support, so we append a major version to the name.\n  soname_spec='${libname}${release}${shared_ext}$major'\n  ;;\n\naix[[4-9]]*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_lib_prefix=no\n  need_version=no\n  hardcode_into_libs=yes\n  if test \"$host_cpu\" = ia64; then\n    # AIX 5 supports IA64\n    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'\n    shlibpath_var=LD_LIBRARY_PATH\n  else\n    # With GCC up to 2.95.x, collect2 would create an import file\n    # for dependence libraries.  The import file would start with\n    # the line `#! .'.  This would cause the generated library to\n    # depend on `.', always an invalid library.  This was fixed in\n    # development snapshots of GCC prior to 3.0.\n    case $host_os in\n      aix4 | aix4.[[01]] | aix4.[[01]].*)\n      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'\n\t   echo ' yes '\n\t   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then\n\t:\n      else\n\tcan_build_shared=no\n      fi\n      ;;\n    esac\n    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct\n    # soname into executable. Probably we can add versioning support to\n    # collect2, so additional links can be useful in future.\n    if test \"$aix_use_runtimelinking\" = yes; then\n      # If using run time linking (on AIX 4.2 or later) use lib<name>.so\n      # instead of lib<name>.a to let people know that these are not\n      # typical AIX shared libraries.\n      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n    else\n      # We preserve .a as extension for shared libraries through AIX4.2\n      # and later when we are not doing run time linking.\n      library_names_spec='${libname}${release}.a $libname.a'\n      soname_spec='${libname}${release}${shared_ext}$major'\n    fi\n    shlibpath_var=LIBPATH\n  fi\n  ;;\n\namigaos*)\n  case $host_cpu in\n  powerpc)\n    # Since July 2007 AmigaOS4 officially supports .so libraries.\n    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.\n    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n    ;;\n  m68k)\n    library_names_spec='$libname.ixlibrary $libname.a'\n    # Create ${libname}_ixlibrary.a entries in /sys/libs.\n    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all \"$lib\" | $SED '\\''s%^.*/\\([[^/]]*\\)\\.ixlibrary$%\\1%'\\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show \"cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a\"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'\n    ;;\n  esac\n  ;;\n\nbeos*)\n  library_names_spec='${libname}${shared_ext}'\n  dynamic_linker=\"$host_os ld.so\"\n  shlibpath_var=LIBRARY_PATH\n  ;;\n\nbsdi[[45]]*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  finish_cmds='PATH=\"\\$PATH:/sbin\" ldconfig $libdir'\n  shlibpath_var=LD_LIBRARY_PATH\n  sys_lib_search_path_spec=\"/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib\"\n  sys_lib_dlsearch_path_spec=\"/shlib /usr/lib /usr/local/lib\"\n  # the default ld.so.conf also contains /usr/contrib/lib and\n  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow\n  # libtool to hard-code these into programs\n  ;;\n\ncygwin* | mingw* | pw32* | cegcc*)\n  version_type=windows\n  shrext_cmds=\".dll\"\n  need_version=no\n  need_lib_prefix=no\n\n  case $GCC,$cc_basename in\n  yes,*)\n    # gcc\n    library_names_spec='$libname.dll.a'\n    # DLL is installed to $(libdir)/../bin by postinstall_cmds\n    postinstall_cmds='base_file=`basename \\${file}`~\n      dlpath=`$SHELL 2>&1 -c '\\''. $dir/'\\''\\${base_file}'\\''i; echo \\$dlname'\\''`~\n      dldir=$destdir/`dirname \\$dlpath`~\n      test -d \\$dldir || mkdir -p \\$dldir~\n      $install_prog $dir/$dlname \\$dldir/$dlname~\n      chmod a+x \\$dldir/$dlname~\n      if test -n '\\''$stripme'\\'' && test -n '\\''$striplib'\\''; then\n        eval '\\''$striplib \\$dldir/$dlname'\\'' || exit \\$?;\n      fi'\n    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\\''. $file; echo \\$dlname'\\''`~\n      dlpath=$dir/\\$dldll~\n       $RM \\$dlpath'\n    shlibpath_overrides_runpath=yes\n\n    case $host_os in\n    cygwin*)\n      # Cygwin DLLs use 'cyg' prefix rather than 'lib'\n      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'\nm4_if([$1], [],[\n      sys_lib_search_path_spec=\"$sys_lib_search_path_spec /usr/lib/w32api\"])\n      ;;\n    mingw* | cegcc*)\n      # MinGW DLLs use traditional 'lib' prefix\n      soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'\n      ;;\n    pw32*)\n      # pw32 DLLs use 'pw' prefix rather than 'lib'\n      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'\n      ;;\n    esac\n    dynamic_linker='Win32 ld.exe'\n    ;;\n\n  *,cl*)\n    # Native MSVC\n    libname_spec='$name'\n    soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'\n    library_names_spec='${libname}.dll.lib'\n\n    case $build_os in\n    mingw*)\n      sys_lib_search_path_spec=\n      lt_save_ifs=$IFS\n      IFS=';'\n      for lt_path in $LIB\n      do\n        IFS=$lt_save_ifs\n        # Let DOS variable expansion print the short 8.3 style file name.\n        lt_path=`cd \"$lt_path\" 2>/dev/null && cmd //C \"for %i in (\".\") do @echo %~si\"`\n        sys_lib_search_path_spec=\"$sys_lib_search_path_spec $lt_path\"\n      done\n      IFS=$lt_save_ifs\n      # Convert to MSYS style.\n      sys_lib_search_path_spec=`$ECHO \"$sys_lib_search_path_spec\" | sed -e 's|\\\\\\\\|/|g' -e 's| \\\\([[a-zA-Z]]\\\\):| /\\\\1|g' -e 's|^ ||'`\n      ;;\n    cygwin*)\n      # Convert to unix form, then to dos form, then back to unix form\n      # but this time dos style (no spaces!) so that the unix form looks\n      # like /cygdrive/c/PROGRA~1:/cygdr...\n      sys_lib_search_path_spec=`cygpath --path --unix \"$LIB\"`\n      sys_lib_search_path_spec=`cygpath --path --dos \"$sys_lib_search_path_spec\" 2>/dev/null`\n      sys_lib_search_path_spec=`cygpath --path --unix \"$sys_lib_search_path_spec\" | $SED -e \"s/$PATH_SEPARATOR/ /g\"`\n      ;;\n    *)\n      sys_lib_search_path_spec=\"$LIB\"\n      if $ECHO \"$sys_lib_search_path_spec\" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then\n        # It is most probably a Windows format PATH.\n        sys_lib_search_path_spec=`$ECHO \"$sys_lib_search_path_spec\" | $SED -e 's/;/ /g'`\n      else\n        sys_lib_search_path_spec=`$ECHO \"$sys_lib_search_path_spec\" | $SED -e \"s/$PATH_SEPARATOR/ /g\"`\n      fi\n      # FIXME: find the short name or the path components, as spaces are\n      # common. (e.g. \"Program Files\" -> \"PROGRA~1\")\n      ;;\n    esac\n\n    # DLL is installed to $(libdir)/../bin by postinstall_cmds\n    postinstall_cmds='base_file=`basename \\${file}`~\n      dlpath=`$SHELL 2>&1 -c '\\''. $dir/'\\''\\${base_file}'\\''i; echo \\$dlname'\\''`~\n      dldir=$destdir/`dirname \\$dlpath`~\n      test -d \\$dldir || mkdir -p \\$dldir~\n      $install_prog $dir/$dlname \\$dldir/$dlname'\n    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\\''. $file; echo \\$dlname'\\''`~\n      dlpath=$dir/\\$dldll~\n       $RM \\$dlpath'\n    shlibpath_overrides_runpath=yes\n    dynamic_linker='Win32 link.exe'\n    ;;\n\n  *)\n    # Assume MSVC wrapper\n    library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'\n    dynamic_linker='Win32 ld.exe'\n    ;;\n  esac\n  # FIXME: first we should search . and the directory the executable is in\n  shlibpath_var=PATH\n  ;;\n\ndarwin* | rhapsody*)\n  dynamic_linker=\"$host_os dyld\"\n  version_type=darwin\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'\n  soname_spec='${libname}${release}${major}$shared_ext'\n  shlibpath_overrides_runpath=yes\n  shlibpath_var=DYLD_LIBRARY_PATH\n  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'\nm4_if([$1], [],[\n  sys_lib_search_path_spec=\"$sys_lib_search_path_spec /usr/local/lib\"])\n  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'\n  ;;\n\ndgux*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LD_LIBRARY_PATH\n  ;;\n\nfreebsd* | dragonfly*)\n  # DragonFly does not have aout.  When/if they implement a new\n  # versioning mechanism, adjust this.\n  if test -x /usr/bin/objformat; then\n    objformat=`/usr/bin/objformat`\n  else\n    case $host_os in\n    freebsd[[23]].*) objformat=aout ;;\n    *) objformat=elf ;;\n    esac\n  fi\n  version_type=freebsd-$objformat\n  case $version_type in\n    freebsd-elf*)\n      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'\n      need_version=no\n      need_lib_prefix=no\n      ;;\n    freebsd-*)\n      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'\n      need_version=yes\n      ;;\n  esac\n  shlibpath_var=LD_LIBRARY_PATH\n  case $host_os in\n  freebsd2.*)\n    shlibpath_overrides_runpath=yes\n    ;;\n  freebsd3.[[01]]* | freebsdelf3.[[01]]*)\n    shlibpath_overrides_runpath=yes\n    hardcode_into_libs=yes\n    ;;\n  freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \\\n  freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)\n    shlibpath_overrides_runpath=no\n    hardcode_into_libs=yes\n    ;;\n  *) # from 4.6 on, and DragonFly\n    shlibpath_overrides_runpath=yes\n    hardcode_into_libs=yes\n    ;;\n  esac\n  ;;\n\nhaiku*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_lib_prefix=no\n  need_version=no\n  dynamic_linker=\"$host_os runtime_loader\"\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LIBRARY_PATH\n  shlibpath_overrides_runpath=yes\n  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'\n  hardcode_into_libs=yes\n  ;;\n\nhpux9* | hpux10* | hpux11*)\n  # Give a soname corresponding to the major version so that dld.sl refuses to\n  # link against other versions.\n  version_type=sunos\n  need_lib_prefix=no\n  need_version=no\n  case $host_cpu in\n  ia64*)\n    shrext_cmds='.so'\n    hardcode_into_libs=yes\n    dynamic_linker=\"$host_os dld.so\"\n    shlibpath_var=LD_LIBRARY_PATH\n    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.\n    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n    soname_spec='${libname}${release}${shared_ext}$major'\n    if test \"X$HPUX_IA64_MODE\" = X32; then\n      sys_lib_search_path_spec=\"/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib\"\n    else\n      sys_lib_search_path_spec=\"/usr/lib/hpux64 /usr/local/lib/hpux64\"\n    fi\n    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec\n    ;;\n  hppa*64*)\n    shrext_cmds='.sl'\n    hardcode_into_libs=yes\n    dynamic_linker=\"$host_os dld.sl\"\n    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH\n    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.\n    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n    soname_spec='${libname}${release}${shared_ext}$major'\n    sys_lib_search_path_spec=\"/usr/lib/pa20_64 /usr/ccs/lib/pa20_64\"\n    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec\n    ;;\n  *)\n    shrext_cmds='.sl'\n    dynamic_linker=\"$host_os dld.sl\"\n    shlibpath_var=SHLIB_PATH\n    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH\n    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n    soname_spec='${libname}${release}${shared_ext}$major'\n    ;;\n  esac\n  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...\n  postinstall_cmds='chmod 555 $lib'\n  # or fails outright, so override atomically:\n  install_override_mode=555\n  ;;\n\ninterix[[3-9]]*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=no\n  hardcode_into_libs=yes\n  ;;\n\nirix5* | irix6* | nonstopux*)\n  case $host_os in\n    nonstopux*) version_type=nonstopux ;;\n    *)\n\tif test \"$lt_cv_prog_gnu_ld\" = yes; then\n\t\tversion_type=linux # correct to gnu/linux during the next big refactor\n\telse\n\t\tversion_type=irix\n\tfi ;;\n  esac\n  need_lib_prefix=no\n  need_version=no\n  soname_spec='${libname}${release}${shared_ext}$major'\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'\n  case $host_os in\n  irix5* | nonstopux*)\n    libsuff= shlibsuff=\n    ;;\n  *)\n    case $LD in # libtool.m4 will add one of these switches to LD\n    *-32|*\"-32 \"|*-melf32bsmip|*\"-melf32bsmip \")\n      libsuff= shlibsuff= libmagic=32-bit;;\n    *-n32|*\"-n32 \"|*-melf32bmipn32|*\"-melf32bmipn32 \")\n      libsuff=32 shlibsuff=N32 libmagic=N32;;\n    *-64|*\"-64 \"|*-melf64bmip|*\"-melf64bmip \")\n      libsuff=64 shlibsuff=64 libmagic=64-bit;;\n    *) libsuff= shlibsuff= libmagic=never-match;;\n    esac\n    ;;\n  esac\n  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH\n  shlibpath_overrides_runpath=no\n  sys_lib_search_path_spec=\"/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}\"\n  sys_lib_dlsearch_path_spec=\"/usr/lib${libsuff} /lib${libsuff}\"\n  hardcode_into_libs=yes\n  ;;\n\n# No shared lib support for Linux oldld, aout, or coff.\nlinux*oldld* | linux*aout* | linux*coff*)\n  dynamic_linker=no\n  ;;\n\n# This must be glibc/ELF.\nlinux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  finish_cmds='PATH=\"\\$PATH:/sbin\" ldconfig -n $libdir'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=no\n\n  # Some binutils ld are patched to set DT_RUNPATH\n  AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath],\n    [lt_cv_shlibpath_overrides_runpath=no\n    save_LDFLAGS=$LDFLAGS\n    save_libdir=$libdir\n    eval \"libdir=/foo; wl=\\\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\\\"; \\\n\t LDFLAGS=\\\"\\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\\\"\"\n    AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],\n      [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep \"RUNPATH.*$libdir\" >/dev/null],\n\t [lt_cv_shlibpath_overrides_runpath=yes])])\n    LDFLAGS=$save_LDFLAGS\n    libdir=$save_libdir\n    ])\n  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath\n\n  # This implies no fast_install, which is unacceptable.\n  # Some rework will be needed to allow for fast_install\n  # before this can be enabled.\n  hardcode_into_libs=yes\n\n  # Append ld.so.conf contents to the search path\n  if test -f /etc/ld.so.conf; then\n    lt_ld_extra=`awk '/^include / { system(sprintf(\"cd /etc; cat %s 2>/dev/null\", \\[$]2)); skip = 1; } { if (!skip) print \\[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[\t ]*hwcap[\t ]/d;s/[:,\t]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/\"//g;/^$/d' | tr '\\n' ' '`\n    sys_lib_dlsearch_path_spec=\"/lib /usr/lib $lt_ld_extra\"\n  fi\n\n  # We used to test for /lib/ld.so.1 and disable shared libraries on\n  # powerpc, because MkLinux only supported shared libraries with the\n  # GNU dynamic linker.  Since this was broken with cross compilers,\n  # most powerpc-linux boxes support dynamic linking these days and\n  # people can always --disable-shared, the test was removed, and we\n  # assume the GNU/Linux dynamic linker is in use.\n  dynamic_linker='GNU/Linux ld.so'\n  ;;\n\nnetbsdelf*-gnu)\n  version_type=linux\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=no\n  hardcode_into_libs=yes\n  dynamic_linker='NetBSD ld.elf_so'\n  ;;\n\nnetbsd*)\n  version_type=sunos\n  need_lib_prefix=no\n  need_version=no\n  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then\n    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'\n    finish_cmds='PATH=\"\\$PATH:/sbin\" ldconfig -m $libdir'\n    dynamic_linker='NetBSD (a.out) ld.so'\n  else\n    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'\n    soname_spec='${libname}${release}${shared_ext}$major'\n    dynamic_linker='NetBSD ld.elf_so'\n  fi\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=yes\n  hardcode_into_libs=yes\n  ;;\n\nnewsos6)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=yes\n  ;;\n\n*nto* | *qnx*)\n  version_type=qnx\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=no\n  hardcode_into_libs=yes\n  dynamic_linker='ldqnx.so'\n  ;;\n\nopenbsd*)\n  version_type=sunos\n  sys_lib_dlsearch_path_spec=\"/usr/lib\"\n  need_lib_prefix=no\n  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.\n  case $host_os in\n    openbsd3.3 | openbsd3.3.*)\tneed_version=yes ;;\n    *)\t\t\t\tneed_version=no  ;;\n  esac\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'\n  finish_cmds='PATH=\"\\$PATH:/sbin\" ldconfig -m $libdir'\n  shlibpath_var=LD_LIBRARY_PATH\n  if test -z \"`echo __ELF__ | $CC -E - | $GREP __ELF__`\" || test \"$host_os-$host_cpu\" = \"openbsd2.8-powerpc\"; then\n    case $host_os in\n      openbsd2.[[89]] | openbsd2.[[89]].*)\n\tshlibpath_overrides_runpath=no\n\t;;\n      *)\n\tshlibpath_overrides_runpath=yes\n\t;;\n      esac\n  else\n    shlibpath_overrides_runpath=yes\n  fi\n  ;;\n\nos2*)\n  libname_spec='$name'\n  shrext_cmds=\".dll\"\n  need_lib_prefix=no\n  library_names_spec='$libname${shared_ext} $libname.a'\n  dynamic_linker='OS/2 ld.exe'\n  shlibpath_var=LIBPATH\n  ;;\n\nosf3* | osf4* | osf5*)\n  version_type=osf\n  need_lib_prefix=no\n  need_version=no\n  soname_spec='${libname}${release}${shared_ext}$major'\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  shlibpath_var=LD_LIBRARY_PATH\n  sys_lib_search_path_spec=\"/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib\"\n  sys_lib_dlsearch_path_spec=\"$sys_lib_search_path_spec\"\n  ;;\n\nrdos*)\n  dynamic_linker=no\n  ;;\n\nsolaris*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=yes\n  hardcode_into_libs=yes\n  # ldd complains unless libraries are executable\n  postinstall_cmds='chmod +x $lib'\n  ;;\n\nsunos4*)\n  version_type=sunos\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'\n  finish_cmds='PATH=\"\\$PATH:/usr/etc\" ldconfig $libdir'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=yes\n  if test \"$with_gnu_ld\" = yes; then\n    need_lib_prefix=no\n  fi\n  need_version=yes\n  ;;\n\nsysv4 | sysv4.3*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LD_LIBRARY_PATH\n  case $host_vendor in\n    sni)\n      shlibpath_overrides_runpath=no\n      need_lib_prefix=no\n      runpath_var=LD_RUN_PATH\n      ;;\n    siemens)\n      need_lib_prefix=no\n      ;;\n    motorola)\n      need_lib_prefix=no\n      need_version=no\n      shlibpath_overrides_runpath=no\n      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'\n      ;;\n  esac\n  ;;\n\nsysv4*MP*)\n  if test -d /usr/nec ;then\n    version_type=linux # correct to gnu/linux during the next big refactor\n    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'\n    soname_spec='$libname${shared_ext}.$major'\n    shlibpath_var=LD_LIBRARY_PATH\n  fi\n  ;;\n\nsysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)\n  version_type=freebsd-elf\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=yes\n  hardcode_into_libs=yes\n  if test \"$with_gnu_ld\" = yes; then\n    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'\n  else\n    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'\n    case $host_os in\n      sco3.2v5*)\n        sys_lib_search_path_spec=\"$sys_lib_search_path_spec /lib\"\n\t;;\n    esac\n  fi\n  sys_lib_dlsearch_path_spec='/usr/lib'\n  ;;\n\ntpf*)\n  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.\n  version_type=linux # correct to gnu/linux during the next big refactor\n  need_lib_prefix=no\n  need_version=no\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  shlibpath_var=LD_LIBRARY_PATH\n  shlibpath_overrides_runpath=no\n  hardcode_into_libs=yes\n  ;;\n\nuts4*)\n  version_type=linux # correct to gnu/linux during the next big refactor\n  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'\n  soname_spec='${libname}${release}${shared_ext}$major'\n  shlibpath_var=LD_LIBRARY_PATH\n  ;;\n\n*)\n  dynamic_linker=no\n  ;;\nesac\nAC_MSG_RESULT([$dynamic_linker])\ntest \"$dynamic_linker\" = no && can_build_shared=no\n\nvariables_saved_for_relink=\"PATH $shlibpath_var $runpath_var\"\nif test \"$GCC\" = yes; then\n  variables_saved_for_relink=\"$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH\"\nfi\n\nif test \"${lt_cv_sys_lib_search_path_spec+set}\" = set; then\n  sys_lib_search_path_spec=\"$lt_cv_sys_lib_search_path_spec\"\nfi\nif test \"${lt_cv_sys_lib_dlsearch_path_spec+set}\" = set; then\n  sys_lib_dlsearch_path_spec=\"$lt_cv_sys_lib_dlsearch_path_spec\"\nfi\n\n_LT_DECL([], [variables_saved_for_relink], [1],\n    [Variables whose values should be saved in libtool wrapper scripts and\n    restored at link time])\n_LT_DECL([], [need_lib_prefix], [0],\n    [Do we need the \"lib\" prefix for modules?])\n_LT_DECL([], [need_version], [0], [Do we need a version for libraries?])\n_LT_DECL([], [version_type], [0], [Library versioning type])\n_LT_DECL([], [runpath_var], [0],  [Shared library runtime path variable])\n_LT_DECL([], [shlibpath_var], [0],[Shared library path variable])\n_LT_DECL([], [shlibpath_overrides_runpath], [0],\n    [Is shlibpath searched before the hard-coded library search path?])\n_LT_DECL([], [libname_spec], [1], [Format of library name prefix])\n_LT_DECL([], [library_names_spec], [1],\n    [[List of archive names.  First name is the real one, the rest are links.\n    The last name is the one that the linker finds with -lNAME]])\n_LT_DECL([], [soname_spec], [1],\n    [[The coded name of the library, if different from the real name]])\n_LT_DECL([], [install_override_mode], [1],\n    [Permission mode override for installation of shared libraries])\n_LT_DECL([], [postinstall_cmds], [2],\n    [Command to use after installation of a shared archive])\n_LT_DECL([], [postuninstall_cmds], [2],\n    [Command to use after uninstallation of a shared archive])\n_LT_DECL([], [finish_cmds], [2],\n    [Commands used to finish a libtool library installation in a directory])\n_LT_DECL([], [finish_eval], [1],\n    [[As \"finish_cmds\", except a single script fragment to be evaled but\n    not shown]])\n_LT_DECL([], [hardcode_into_libs], [0],\n    [Whether we should hardcode library paths into libraries])\n_LT_DECL([], [sys_lib_search_path_spec], [2],\n    [Compile-time system search path for libraries])\n_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],\n    [Run-time system search path for libraries])\n])# _LT_SYS_DYNAMIC_LINKER\n\n\n# _LT_PATH_TOOL_PREFIX(TOOL)\n# --------------------------\n# find a file program which can recognize shared library\nAC_DEFUN([_LT_PATH_TOOL_PREFIX],\n[m4_require([_LT_DECL_EGREP])dnl\nAC_MSG_CHECKING([for $1])\nAC_CACHE_VAL(lt_cv_path_MAGIC_CMD,\n[case $MAGIC_CMD in\n[[\\\\/*] |  ?:[\\\\/]*])\n  lt_cv_path_MAGIC_CMD=\"$MAGIC_CMD\" # Let the user override the test with a path.\n  ;;\n*)\n  lt_save_MAGIC_CMD=\"$MAGIC_CMD\"\n  lt_save_ifs=\"$IFS\"; IFS=$PATH_SEPARATOR\ndnl $ac_dummy forces splitting on constant user-supplied paths.\ndnl POSIX.2 word splitting is done only on the output of word expansions,\ndnl not every word.  This closes a longstanding sh security hole.\n  ac_dummy=\"m4_if([$2], , $PATH, [$2])\"\n  for ac_dir in $ac_dummy; do\n    IFS=\"$lt_save_ifs\"\n    test -z \"$ac_dir\" && ac_dir=.\n    if test -f $ac_dir/$1; then\n      lt_cv_path_MAGIC_CMD=\"$ac_dir/$1\"\n      if test -n \"$file_magic_test_file\"; then\n\tcase $deplibs_check_method in\n\t\"file_magic \"*)\n\t  file_magic_regex=`expr \"$deplibs_check_method\" : \"file_magic \\(.*\\)\"`\n\t  MAGIC_CMD=\"$lt_cv_path_MAGIC_CMD\"\n\t  if eval $file_magic_cmd \\$file_magic_test_file 2> /dev/null |\n\t    $EGREP \"$file_magic_regex\" > /dev/null; then\n\t    :\n\t  else\n\t    cat <<_LT_EOF 1>&2\n\n*** Warning: the command libtool uses to detect shared libraries,\n*** $file_magic_cmd, produces output that libtool cannot recognize.\n*** The result is that libtool may fail to recognize shared libraries\n*** as such.  This will affect the creation of libtool libraries that\n*** depend on shared libraries, but programs linked with such libtool\n*** libraries will work regardless of this problem.  Nevertheless, you\n*** may want to report the problem to your system manager and/or to\n*** bug-libtool@gnu.org\n\n_LT_EOF\n\t  fi ;;\n\tesac\n      fi\n      break\n    fi\n  done\n  IFS=\"$lt_save_ifs\"\n  MAGIC_CMD=\"$lt_save_MAGIC_CMD\"\n  ;;\nesac])\nMAGIC_CMD=\"$lt_cv_path_MAGIC_CMD\"\nif test -n \"$MAGIC_CMD\"; then\n  AC_MSG_RESULT($MAGIC_CMD)\nelse\n  AC_MSG_RESULT(no)\nfi\n_LT_DECL([], [MAGIC_CMD], [0],\n\t [Used to examine libraries when file_magic_cmd begins with \"file\"])dnl\n])# _LT_PATH_TOOL_PREFIX\n\n# Old name:\nAU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])\ndnl aclocal-1.4 backwards compatibility:\ndnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])\n\n\n# _LT_PATH_MAGIC\n# --------------\n# find a file program which can recognize a shared library\nm4_defun([_LT_PATH_MAGIC],\n[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)\nif test -z \"$lt_cv_path_MAGIC_CMD\"; then\n  if test -n \"$ac_tool_prefix\"; then\n    _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)\n  else\n    MAGIC_CMD=:\n  fi\nfi\n])# _LT_PATH_MAGIC\n\n\n# LT_PATH_LD\n# ----------\n# find the pathname to the GNU or non-GNU linker\nAC_DEFUN([LT_PATH_LD],\n[AC_REQUIRE([AC_PROG_CC])dnl\nAC_REQUIRE([AC_CANONICAL_HOST])dnl\nAC_REQUIRE([AC_CANONICAL_BUILD])dnl\nm4_require([_LT_DECL_SED])dnl\nm4_require([_LT_DECL_EGREP])dnl\nm4_require([_LT_PROG_ECHO_BACKSLASH])dnl\n\nAC_ARG_WITH([gnu-ld],\n    [AS_HELP_STRING([--with-gnu-ld],\n\t[assume the C compiler uses GNU ld @<:@default=no@:>@])],\n    [test \"$withval\" = no || with_gnu_ld=yes],\n    [with_gnu_ld=no])dnl\n\nac_prog=ld\nif test \"$GCC\" = yes; then\n  # Check if gcc -print-prog-name=ld gives a path.\n  AC_MSG_CHECKING([for ld used by $CC])\n  case $host in\n  *-*-mingw*)\n    # gcc leaves a trailing carriage return which upsets mingw\n    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\\015'` ;;\n  *)\n    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;\n  esac\n  case $ac_prog in\n    # Accept absolute paths.\n    [[\\\\/]]* | ?:[[\\\\/]]*)\n      re_direlt='/[[^/]][[^/]]*/\\.\\./'\n      # Canonicalize the pathname of ld\n      ac_prog=`$ECHO \"$ac_prog\"| $SED 's%\\\\\\\\%/%g'`\n      while $ECHO \"$ac_prog\" | $GREP \"$re_direlt\" > /dev/null 2>&1; do\n\tac_prog=`$ECHO $ac_prog| $SED \"s%$re_direlt%/%\"`\n      done\n      test -z \"$LD\" && LD=\"$ac_prog\"\n      ;;\n  \"\")\n    # If it fails, then pretend we aren't using GCC.\n    ac_prog=ld\n    ;;\n  *)\n    # If it is relative, then search for the first ld in PATH.\n    with_gnu_ld=unknown\n    ;;\n  esac\nelif test \"$with_gnu_ld\" = yes; then\n  AC_MSG_CHECKING([for GNU ld])\nelse\n  AC_MSG_CHECKING([for non-GNU ld])\nfi\nAC_CACHE_VAL(lt_cv_path_LD,\n[if test -z \"$LD\"; then\n  lt_save_ifs=\"$IFS\"; IFS=$PATH_SEPARATOR\n  for ac_dir in $PATH; do\n    IFS=\"$lt_save_ifs\"\n    test -z \"$ac_dir\" && ac_dir=.\n    if test -f \"$ac_dir/$ac_prog\" || test -f \"$ac_dir/$ac_prog$ac_exeext\"; then\n      lt_cv_path_LD=\"$ac_dir/$ac_prog\"\n      # Check to see if the program is GNU ld.  I'd rather use --version,\n      # but apparently some variants of GNU ld only accept -v.\n      # Break only if it was the GNU/non-GNU ld that we prefer.\n      case `\"$lt_cv_path_LD\" -v 2>&1 </dev/null` in\n      *GNU* | *'with BFD'*)\n\ttest \"$with_gnu_ld\" != no && break\n\t;;\n      *)\n\ttest \"$with_gnu_ld\" != yes && break\n\t;;\n      esac\n    fi\n  done\n  IFS=\"$lt_save_ifs\"\nelse\n  lt_cv_path_LD=\"$LD\" # Let the user override the test with a path.\nfi])\nLD=\"$lt_cv_path_LD\"\nif test -n \"$LD\"; then\n  AC_MSG_RESULT($LD)\nelse\n  AC_MSG_RESULT(no)\nfi\ntest -z \"$LD\" && AC_MSG_ERROR([no acceptable ld found in \\$PATH])\n_LT_PATH_LD_GNU\nAC_SUBST([LD])\n\n_LT_TAGDECL([], [LD], [1], [The linker used to build libraries])\n])# LT_PATH_LD\n\n# Old names:\nAU_ALIAS([AM_PROG_LD], [LT_PATH_LD])\nAU_ALIAS([AC_PROG_LD], [LT_PATH_LD])\ndnl aclocal-1.4 backwards compatibility:\ndnl AC_DEFUN([AM_PROG_LD], [])\ndnl AC_DEFUN([AC_PROG_LD], [])\n\n\n# _LT_PATH_LD_GNU\n#- --------------\nm4_defun([_LT_PATH_LD_GNU],\n[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,\n[# I'd rather use --version here, but apparently some GNU lds only accept -v.\ncase `$LD -v 2>&1 </dev/null` in\n*GNU* | *'with BFD'*)\n  lt_cv_prog_gnu_ld=yes\n  ;;\n*)\n  lt_cv_prog_gnu_ld=no\n  ;;\nesac])\nwith_gnu_ld=$lt_cv_prog_gnu_ld\n])# _LT_PATH_LD_GNU\n\n\n# _LT_CMD_RELOAD\n# --------------\n# find reload flag for linker\n#   -- PORTME Some linkers may need a different reload flag.\nm4_defun([_LT_CMD_RELOAD],\n[AC_CACHE_CHECK([for $LD option to reload object files],\n  lt_cv_ld_reload_flag,\n  [lt_cv_ld_reload_flag='-r'])\nreload_flag=$lt_cv_ld_reload_flag\ncase $reload_flag in\n\"\" | \" \"*) ;;\n*) reload_flag=\" $reload_flag\" ;;\nesac\nreload_cmds='$LD$reload_flag -o $output$reload_objs'\ncase $host_os in\n  cygwin* | mingw* | pw32* | cegcc*)\n    if test \"$GCC\" != yes; then\n      reload_cmds=false\n    fi\n    ;;\n  darwin*)\n    if test \"$GCC\" = yes; then\n      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'\n    else\n      reload_cmds='$LD$reload_flag -o $output$reload_objs'\n    fi\n    ;;\nesac\n_LT_TAGDECL([], [reload_flag], [1], [How to create reloadable object files])dnl\n_LT_TAGDECL([], [reload_cmds], [2])dnl\n])# _LT_CMD_RELOAD\n\n\n# _LT_CHECK_MAGIC_METHOD\n# ----------------------\n# how to check for library dependencies\n#  -- PORTME fill in with the dynamic library characteristics\nm4_defun([_LT_CHECK_MAGIC_METHOD],\n[m4_require([_LT_DECL_EGREP])\nm4_require([_LT_DECL_OBJDUMP])\nAC_CACHE_CHECK([how to recognize dependent libraries],\nlt_cv_deplibs_check_method,\n[lt_cv_file_magic_cmd='$MAGIC_CMD'\nlt_cv_file_magic_test_file=\nlt_cv_deplibs_check_method='unknown'\n# Need to set the preceding variable on all platforms that support\n# interlibrary dependencies.\n# 'none' -- dependencies not supported.\n# `unknown' -- same as none, but documents that we really don't know.\n# 'pass_all' -- all dependencies passed with no checks.\n# 'test_compile' -- check by making test program.\n# 'file_magic [[regex]]' -- check by looking for files in library path\n# which responds to the $file_magic_cmd with a given extended regex.\n# If you have `file' or equivalent on your system and you're not sure\n# whether `pass_all' will *always* work, you probably want this one.\n\ncase $host_os in\naix[[4-9]]*)\n  lt_cv_deplibs_check_method=pass_all\n  ;;\n\nbeos*)\n  lt_cv_deplibs_check_method=pass_all\n  ;;\n\nbsdi[[45]]*)\n  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'\n  lt_cv_file_magic_cmd='/usr/bin/file -L'\n  lt_cv_file_magic_test_file=/shlib/libc.so\n  ;;\n\ncygwin*)\n  # func_win32_libid is a shell function defined in ltmain.sh\n  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'\n  lt_cv_file_magic_cmd='func_win32_libid'\n  ;;\n\nmingw* | pw32*)\n  # Base MSYS/MinGW do not provide the 'file' command needed by\n  # func_win32_libid shell function, so use a weaker test based on 'objdump',\n  # unless we find 'file', for example because we are cross-compiling.\n  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.\n  if ( test \"$lt_cv_nm_interface\" = \"BSD nm\" && file / ) >/dev/null 2>&1; then\n    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'\n    lt_cv_file_magic_cmd='func_win32_libid'\n  else\n    # Keep this pattern in sync with the one in func_win32_libid.\n    lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'\n    lt_cv_file_magic_cmd='$OBJDUMP -f'\n  fi\n  ;;\n\ncegcc*)\n  # use the weaker test based on 'objdump'. See mingw*.\n  lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'\n  lt_cv_file_magic_cmd='$OBJDUMP -f'\n  ;;\n\ndarwin* | rhapsody*)\n  lt_cv_deplibs_check_method=pass_all\n  ;;\n\nfreebsd* | dragonfly*)\n  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then\n    case $host_cpu in\n    i*86 )\n      # Not sure whether the presence of OpenBSD here was a mistake.\n      # Let's accept both of them until this is cleared up.\n      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'\n      lt_cv_file_magic_cmd=/usr/bin/file\n      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`\n      ;;\n    esac\n  else\n    lt_cv_deplibs_check_method=pass_all\n  fi\n  ;;\n\nhaiku*)\n  lt_cv_deplibs_check_method=pass_all\n  ;;\n\nhpux10.20* | hpux11*)\n  lt_cv_file_magic_cmd=/usr/bin/file\n  case $host_cpu in\n  ia64*)\n    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'\n    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so\n    ;;\n  hppa*64*)\n    [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\\.[0-9]']\n    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl\n    ;;\n  *)\n    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\\.[[0-9]]) shared library'\n    lt_cv_file_magic_test_file=/usr/lib/libc.sl\n    ;;\n  esac\n  ;;\n\ninterix[[3-9]]*)\n  # PIC code is broken on Interix 3.x, that's why |\\.a not |_pic\\.a here\n  lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\\.so|\\.a)$'\n  ;;\n\nirix5* | irix6* | nonstopux*)\n  case $LD in\n  *-32|*\"-32 \") libmagic=32-bit;;\n  *-n32|*\"-n32 \") libmagic=N32;;\n  *-64|*\"-64 \") libmagic=64-bit;;\n  *) libmagic=never-match;;\n  esac\n  lt_cv_deplibs_check_method=pass_all\n  ;;\n\n# This must be glibc/ELF.\nlinux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)\n  lt_cv_deplibs_check_method=pass_all\n  ;;\n\nnetbsd* | netbsdelf*-gnu)\n  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then\n    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\\.so\\.[[0-9]]+\\.[[0-9]]+|_pic\\.a)$'\n  else\n    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\\.so|_pic\\.a)$'\n  fi\n  ;;\n\nnewos6*)\n  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'\n  lt_cv_file_magic_cmd=/usr/bin/file\n  lt_cv_file_magic_test_file=/usr/lib/libnls.so\n  ;;\n\n*nto* | *qnx*)\n  lt_cv_deplibs_check_method=pass_all\n  ;;\n\nopenbsd*)\n  if test -z \"`echo __ELF__ | $CC -E - | $GREP __ELF__`\" || test \"$host_os-$host_cpu\" = \"openbsd2.8-powerpc\"; then\n    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\\.so\\.[[0-9]]+\\.[[0-9]]+|\\.so|_pic\\.a)$'\n  else\n    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\\.so\\.[[0-9]]+\\.[[0-9]]+|_pic\\.a)$'\n  fi\n  ;;\n\nosf3* | osf4* | osf5*)\n  lt_cv_deplibs_check_method=pass_all\n  ;;\n\nrdos*)\n  lt_cv_deplibs_check_method=pass_all\n  ;;\n\nsolaris*)\n  lt_cv_deplibs_check_method=pass_all\n  ;;\n\nsysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)\n  lt_cv_deplibs_check_method=pass_all\n  ;;\n\nsysv4 | sysv4.3*)\n  case $host_vendor in\n  motorola)\n    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'\n    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`\n    ;;\n  ncr)\n    lt_cv_deplibs_check_method=pass_all\n    ;;\n  sequent)\n    lt_cv_file_magic_cmd='/bin/file'\n    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'\n    ;;\n  sni)\n    lt_cv_file_magic_cmd='/bin/file'\n    lt_cv_deplibs_check_method=\"file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib\"\n    lt_cv_file_magic_test_file=/lib/libc.so\n    ;;\n  siemens)\n    lt_cv_deplibs_check_method=pass_all\n    ;;\n  pc)\n    lt_cv_deplibs_check_method=pass_all\n    ;;\n  esac\n  ;;\n\ntpf*)\n  lt_cv_deplibs_check_method=pass_all\n  ;;\nesac\n])\n\nfile_magic_glob=\nwant_nocaseglob=no\nif test \"$build\" = \"$host\"; then\n  case $host_os in\n  mingw* | pw32*)\n    if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then\n      want_nocaseglob=yes\n    else\n      file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e \"s/\\(..\\)/s\\/[[\\1]]\\/[[\\1]]\\/g;/g\"`\n    fi\n    ;;\n  esac\nfi\n\nfile_magic_cmd=$lt_cv_file_magic_cmd\ndeplibs_check_method=$lt_cv_deplibs_check_method\ntest -z \"$deplibs_check_method\" && deplibs_check_method=unknown\n\n_LT_DECL([], [deplibs_check_method], [1],\n    [Method to check whether dependent libraries are shared objects])\n_LT_DECL([], [file_magic_cmd], [1],\n    [Command to use when deplibs_check_method = \"file_magic\"])\n_LT_DECL([], [file_magic_glob], [1],\n    [How to find potential files when deplibs_check_method = \"file_magic\"])\n_LT_DECL([], [want_nocaseglob], [1],\n    [Find potential files using nocaseglob when deplibs_check_method = \"file_magic\"])\n])# _LT_CHECK_MAGIC_METHOD\n\n\n# LT_PATH_NM\n# ----------\n# find the pathname to a BSD- or MS-compatible name lister\nAC_DEFUN([LT_PATH_NM],\n[AC_REQUIRE([AC_PROG_CC])dnl\nAC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,\n[if test -n \"$NM\"; then\n  # Let the user override the test.\n  lt_cv_path_NM=\"$NM\"\nelse\n  lt_nm_to_check=\"${ac_tool_prefix}nm\"\n  if test -n \"$ac_tool_prefix\" && test \"$build\" = \"$host\"; then\n    lt_nm_to_check=\"$lt_nm_to_check nm\"\n  fi\n  for lt_tmp_nm in $lt_nm_to_check; do\n    lt_save_ifs=\"$IFS\"; IFS=$PATH_SEPARATOR\n    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do\n      IFS=\"$lt_save_ifs\"\n      test -z \"$ac_dir\" && ac_dir=.\n      tmp_nm=\"$ac_dir/$lt_tmp_nm\"\n      if test -f \"$tmp_nm\" || test -f \"$tmp_nm$ac_exeext\" ; then\n\t# Check to see if the nm accepts a BSD-compat flag.\n\t# Adding the `sed 1q' prevents false positives on HP-UX, which says:\n\t#   nm: unknown option \"B\" ignored\n\t# Tru64's nm complains that /dev/null is an invalid object file\n\tcase `\"$tmp_nm\" -B /dev/null 2>&1 | sed '1q'` in\n\t*/dev/null* | *'Invalid file or object type'*)\n\t  lt_cv_path_NM=\"$tmp_nm -B\"\n\t  break\n\t  ;;\n\t*)\n\t  case `\"$tmp_nm\" -p /dev/null 2>&1 | sed '1q'` in\n\t  */dev/null*)\n\t    lt_cv_path_NM=\"$tmp_nm -p\"\n\t    break\n\t    ;;\n\t  *)\n\t    lt_cv_path_NM=${lt_cv_path_NM=\"$tmp_nm\"} # keep the first match, but\n\t    continue # so that we can try to find one that supports BSD flags\n\t    ;;\n\t  esac\n\t  ;;\n\tesac\n      fi\n    done\n    IFS=\"$lt_save_ifs\"\n  done\n  : ${lt_cv_path_NM=no}\nfi])\nif test \"$lt_cv_path_NM\" != \"no\"; then\n  NM=\"$lt_cv_path_NM\"\nelse\n  # Didn't find any BSD compatible name lister, look for dumpbin.\n  if test -n \"$DUMPBIN\"; then :\n    # Let the user override the test.\n  else\n    AC_CHECK_TOOLS(DUMPBIN, [dumpbin \"link -dump\"], :)\n    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in\n    *COFF*)\n      DUMPBIN=\"$DUMPBIN -symbols\"\n      ;;\n    *)\n      DUMPBIN=:\n      ;;\n    esac\n  fi\n  AC_SUBST([DUMPBIN])\n  if test \"$DUMPBIN\" != \":\"; then\n    NM=\"$DUMPBIN\"\n  fi\nfi\ntest -z \"$NM\" && NM=nm\nAC_SUBST([NM])\n_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl\n\nAC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],\n  [lt_cv_nm_interface=\"BSD nm\"\n  echo \"int some_variable = 0;\" > conftest.$ac_ext\n  (eval echo \"\\\"\\$as_me:$LINENO: $ac_compile\\\"\" >&AS_MESSAGE_LOG_FD)\n  (eval \"$ac_compile\" 2>conftest.err)\n  cat conftest.err >&AS_MESSAGE_LOG_FD\n  (eval echo \"\\\"\\$as_me:$LINENO: $NM \\\\\\\"conftest.$ac_objext\\\\\\\"\\\"\" >&AS_MESSAGE_LOG_FD)\n  (eval \"$NM \\\"conftest.$ac_objext\\\"\" 2>conftest.err > conftest.out)\n  cat conftest.err >&AS_MESSAGE_LOG_FD\n  (eval echo \"\\\"\\$as_me:$LINENO: output\\\"\" >&AS_MESSAGE_LOG_FD)\n  cat conftest.out >&AS_MESSAGE_LOG_FD\n  if $GREP 'External.*some_variable' conftest.out > /dev/null; then\n    lt_cv_nm_interface=\"MS dumpbin\"\n  fi\n  rm -f conftest*])\n])# LT_PATH_NM\n\n# Old names:\nAU_ALIAS([AM_PROG_NM], [LT_PATH_NM])\nAU_ALIAS([AC_PROG_NM], [LT_PATH_NM])\ndnl aclocal-1.4 backwards compatibility:\ndnl AC_DEFUN([AM_PROG_NM], [])\ndnl AC_DEFUN([AC_PROG_NM], [])\n\n# _LT_CHECK_SHAREDLIB_FROM_LINKLIB\n# --------------------------------\n# how to determine the name of the shared library\n# associated with a specific link library.\n#  -- PORTME fill in with the dynamic library characteristics\nm4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB],\n[m4_require([_LT_DECL_EGREP])\nm4_require([_LT_DECL_OBJDUMP])\nm4_require([_LT_DECL_DLLTOOL])\nAC_CACHE_CHECK([how to associate runtime and link libraries],\nlt_cv_sharedlib_from_linklib_cmd,\n[lt_cv_sharedlib_from_linklib_cmd='unknown'\n\ncase $host_os in\ncygwin* | mingw* | pw32* | cegcc*)\n  # two different shell functions defined in ltmain.sh\n  # decide which to use based on capabilities of $DLLTOOL\n  case `$DLLTOOL --help 2>&1` in\n  *--identify-strict*)\n    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib\n    ;;\n  *)\n    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback\n    ;;\n  esac\n  ;;\n*)\n  # fallback: assume linklib IS sharedlib\n  lt_cv_sharedlib_from_linklib_cmd=\"$ECHO\"\n  ;;\nesac\n])\nsharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd\ntest -z \"$sharedlib_from_linklib_cmd\" && sharedlib_from_linklib_cmd=$ECHO\n\n_LT_DECL([], [sharedlib_from_linklib_cmd], [1],\n    [Command to associate shared and link libraries])\n])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB\n\n\n# _LT_PATH_MANIFEST_TOOL\n# ----------------------\n# locate the manifest tool\nm4_defun([_LT_PATH_MANIFEST_TOOL],\n[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :)\ntest -z \"$MANIFEST_TOOL\" && MANIFEST_TOOL=mt\nAC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool],\n  [lt_cv_path_mainfest_tool=no\n  echo \"$as_me:$LINENO: $MANIFEST_TOOL '-?'\" >&AS_MESSAGE_LOG_FD\n  $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out\n  cat conftest.err >&AS_MESSAGE_LOG_FD\n  if $GREP 'Manifest Tool' conftest.out > /dev/null; then\n    lt_cv_path_mainfest_tool=yes\n  fi\n  rm -f conftest*])\nif test \"x$lt_cv_path_mainfest_tool\" != xyes; then\n  MANIFEST_TOOL=:\nfi\n_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl\n])# _LT_PATH_MANIFEST_TOOL\n\n\n# LT_LIB_M\n# --------\n# check for math library\nAC_DEFUN([LT_LIB_M],\n[AC_REQUIRE([AC_CANONICAL_HOST])dnl\nLIBM=\ncase $host in\n*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*)\n  # These system don't have libm, or don't need it\n  ;;\n*-ncr-sysv4.3*)\n  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM=\"-lmw\")\n  AC_CHECK_LIB(m, cos, LIBM=\"$LIBM -lm\")\n  ;;\n*)\n  AC_CHECK_LIB(m, cos, LIBM=\"-lm\")\n  ;;\nesac\nAC_SUBST([LIBM])\n])# LT_LIB_M\n\n# Old name:\nAU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])\ndnl aclocal-1.4 backwards compatibility:\ndnl AC_DEFUN([AC_CHECK_LIBM], [])\n\n\n# _LT_COMPILER_NO_RTTI([TAGNAME])\n# -------------------------------\nm4_defun([_LT_COMPILER_NO_RTTI],\n[m4_require([_LT_TAG_COMPILER])dnl\n\n_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=\n\nif test \"$GCC\" = yes; then\n  case $cc_basename in\n  nvcc*)\n    _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;;\n  *)\n    _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;;\n  esac\n\n  _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],\n    lt_cv_prog_compiler_rtti_exceptions,\n    [-fno-rtti -fno-exceptions], [],\n    [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=\"$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions\"])\nfi\n_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],\n\t[Compiler flag to turn off builtin functions])\n])# _LT_COMPILER_NO_RTTI\n\n\n# _LT_CMD_GLOBAL_SYMBOLS\n# ----------------------\nm4_defun([_LT_CMD_GLOBAL_SYMBOLS],\n[AC_REQUIRE([AC_CANONICAL_HOST])dnl\nAC_REQUIRE([AC_PROG_CC])dnl\nAC_REQUIRE([AC_PROG_AWK])dnl\nAC_REQUIRE([LT_PATH_NM])dnl\nAC_REQUIRE([LT_PATH_LD])dnl\nm4_require([_LT_DECL_SED])dnl\nm4_require([_LT_DECL_EGREP])dnl\nm4_require([_LT_TAG_COMPILER])dnl\n\n# Check for command to grab the raw symbol name followed by C symbol from nm.\nAC_MSG_CHECKING([command to parse $NM output from $compiler object])\nAC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],\n[\n# These are sane defaults that work on at least a few old systems.\n# [They come from Ultrix.  What could be older than Ultrix?!! ;)]\n\n# Character class describing NM global symbol codes.\nsymcode='[[BCDEGRST]]'\n\n# Regexp to match symbols that can be accessed directly from C.\nsympat='\\([[_A-Za-z]][[_A-Za-z0-9]]*\\)'\n\n# Define system-specific variables.\ncase $host_os in\naix*)\n  symcode='[[BCDT]]'\n  ;;\ncygwin* | mingw* | pw32* | cegcc*)\n  symcode='[[ABCDGISTW]]'\n  ;;\nhpux*)\n  if test \"$host_cpu\" = ia64; then\n    symcode='[[ABCDEGRST]]'\n  fi\n  ;;\nirix* | nonstopux*)\n  symcode='[[BCDEGRST]]'\n  ;;\nosf*)\n  symcode='[[BCDEGQRST]]'\n  ;;\nsolaris*)\n  symcode='[[BDRT]]'\n  ;;\nsco3.2v5*)\n  symcode='[[DT]]'\n  ;;\nsysv4.2uw2*)\n  symcode='[[DT]]'\n  ;;\nsysv5* | sco5v6* | unixware* | OpenUNIX*)\n  symcode='[[ABDT]]'\n  ;;\nsysv4)\n  symcode='[[DFNSTU]]'\n  ;;\nesac\n\n# If we're using GNU nm, then use its standard symbol codes.\ncase `$NM -V 2>&1` in\n*GNU* | *'with BFD'*)\n  symcode='[[ABCDGIRSTW]]' ;;\nesac\n\n# Transform an extracted symbol line into a proper C declaration.\n# Some systems (esp. on ia64) link data and code symbols differently,\n# so use this general approach.\nlt_cv_sys_global_symbol_to_cdecl=\"sed -n -e 's/^T .* \\(.*\\)$/extern int \\1();/p' -e 's/^$symcode* .* \\(.*\\)$/extern char \\1;/p'\"\n\n# Transform an extracted symbol line into symbol name and symbol address\nlt_cv_sys_global_symbol_to_c_name_address=\"sed -n -e 's/^: \\([[^ ]]*\\)[[ ]]*$/  {\\\\\\\"\\1\\\\\\\", (void *) 0},/p' -e 's/^$symcode* \\([[^ ]]*\\) \\([[^ ]]*\\)$/  {\\\"\\2\\\", (void *) \\&\\2},/p'\"\nlt_cv_sys_global_symbol_to_c_name_address_lib_prefix=\"sed -n -e 's/^: \\([[^ ]]*\\)[[ ]]*$/  {\\\\\\\"\\1\\\\\\\", (void *) 0},/p' -e 's/^$symcode* \\([[^ ]]*\\) \\(lib[[^ ]]*\\)$/  {\\\"\\2\\\", (void *) \\&\\2},/p' -e 's/^$symcode* \\([[^ ]]*\\) \\([[^ ]]*\\)$/  {\\\"lib\\2\\\", (void *) \\&\\2},/p'\"\n\n# Handle CRLF in mingw tool chain\nopt_cr=\ncase $build_os in\nmingw*)\n  opt_cr=`$ECHO 'x\\{0,1\\}' | tr x '\\015'` # option cr in regexp\n  ;;\nesac\n\n# Try without a prefix underscore, then with it.\nfor ac_symprfx in \"\" \"_\"; do\n\n  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.\n  symxfrm=\"\\\\1 $ac_symprfx\\\\2 \\\\2\"\n\n  # Write the raw and C identifiers.\n  if test \"$lt_cv_nm_interface\" = \"MS dumpbin\"; then\n    # Fake it for dumpbin and say T for any non-static function\n    # and D for any global variable.\n    # Also find C++ and __fastcall symbols from MSVC++,\n    # which start with @ or ?.\n    lt_cv_sys_global_symbol_pipe=\"$AWK ['\"\\\n\"     {last_section=section; section=\\$ 3};\"\\\n\"     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};\"\\\n\"     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};\"\\\n\"     \\$ 0!~/External *\\|/{next};\"\\\n\"     / 0+ UNDEF /{next}; / UNDEF \\([^|]\\)*()/{next};\"\\\n\"     {if(hide[section]) next};\"\\\n\"     {f=0}; \\$ 0~/\\(\\).*\\|/{f=1}; {printf f ? \\\"T \\\" : \\\"D \\\"};\"\\\n\"     {split(\\$ 0, a, /\\||\\r/); split(a[2], s)};\"\\\n\"     s[1]~/^[@?]/{print s[1], s[1]; next};\"\\\n\"     s[1]~prfx {split(s[1],t,\\\"@\\\"); print t[1], substr(t[1],length(prfx))}\"\\\n\"     ' prfx=^$ac_symprfx]\"\n  else\n    lt_cv_sys_global_symbol_pipe=\"sed -n -e 's/^.*[[\t ]]\\($symcode$symcode*\\)[[\t ]][[\t ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'\"\n  fi\n  lt_cv_sys_global_symbol_pipe=\"$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'\"\n\n  # Check to see that the pipe works correctly.\n  pipe_works=no\n\n  rm -f conftest*\n  cat > conftest.$ac_ext <<_LT_EOF\n#ifdef __cplusplus\nextern \"C\" {\n#endif\nchar nm_test_var;\nvoid nm_test_func(void);\nvoid nm_test_func(void){}\n#ifdef __cplusplus\n}\n#endif\nint main(){nm_test_var='a';nm_test_func();return(0);}\n_LT_EOF\n\n  if AC_TRY_EVAL(ac_compile); then\n    # Now try to grab the symbols.\n    nlist=conftest.nm\n    if AC_TRY_EVAL(NM conftest.$ac_objext \\| \"$lt_cv_sys_global_symbol_pipe\" \\> $nlist) && test -s \"$nlist\"; then\n      # Try sorting and uniquifying the output.\n      if sort \"$nlist\" | uniq > \"$nlist\"T; then\n\tmv -f \"$nlist\"T \"$nlist\"\n      else\n\trm -f \"$nlist\"T\n      fi\n\n      # Make sure that we snagged all the symbols we need.\n      if $GREP ' nm_test_var$' \"$nlist\" >/dev/null; then\n\tif $GREP ' nm_test_func$' \"$nlist\" >/dev/null; then\n\t  cat <<_LT_EOF > conftest.$ac_ext\n/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */\n#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)\n/* DATA imports from DLLs on WIN32 con't be const, because runtime\n   relocations are performed -- see ld's documentation on pseudo-relocs.  */\n# define LT@&t@_DLSYM_CONST\n#elif defined(__osf__)\n/* This system does not cope well with relocations in const data.  */\n# define LT@&t@_DLSYM_CONST\n#else\n# define LT@&t@_DLSYM_CONST const\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n_LT_EOF\n\t  # Now generate the symbol file.\n\t  eval \"$lt_cv_sys_global_symbol_to_cdecl\"' < \"$nlist\" | $GREP -v main >> conftest.$ac_ext'\n\n\t  cat <<_LT_EOF >> conftest.$ac_ext\n\n/* The mapping between symbol names and symbols.  */\nLT@&t@_DLSYM_CONST struct {\n  const char *name;\n  void       *address;\n}\nlt__PROGRAM__LTX_preloaded_symbols[[]] =\n{\n  { \"@PROGRAM@\", (void *) 0 },\n_LT_EOF\n\t  $SED \"s/^$symcode$symcode* \\(.*\\) \\(.*\\)$/  {\\\"\\2\\\", (void *) \\&\\2},/\" < \"$nlist\" | $GREP -v main >> conftest.$ac_ext\n\t  cat <<\\_LT_EOF >> conftest.$ac_ext\n  {0, (void *) 0}\n};\n\n/* This works around a problem in FreeBSD linker */\n#ifdef FREEBSD_WORKAROUND\nstatic const void *lt_preloaded_setup() {\n  return lt__PROGRAM__LTX_preloaded_symbols;\n}\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n_LT_EOF\n\t  # Now try linking the two files.\n\t  mv conftest.$ac_objext conftstm.$ac_objext\n\t  lt_globsym_save_LIBS=$LIBS\n\t  lt_globsym_save_CFLAGS=$CFLAGS\n\t  LIBS=\"conftstm.$ac_objext\"\n\t  CFLAGS=\"$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)\"\n\t  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then\n\t    pipe_works=yes\n\t  fi\n\t  LIBS=$lt_globsym_save_LIBS\n\t  CFLAGS=$lt_globsym_save_CFLAGS\n\telse\n\t  echo \"cannot find nm_test_func in $nlist\" >&AS_MESSAGE_LOG_FD\n\tfi\n      else\n\techo \"cannot find nm_test_var in $nlist\" >&AS_MESSAGE_LOG_FD\n      fi\n    else\n      echo \"cannot run $lt_cv_sys_global_symbol_pipe\" >&AS_MESSAGE_LOG_FD\n    fi\n  else\n    echo \"$progname: failed program was:\" >&AS_MESSAGE_LOG_FD\n    cat conftest.$ac_ext >&5\n  fi\n  rm -rf conftest* conftst*\n\n  # Do not use the global_symbol_pipe unless it works.\n  if test \"$pipe_works\" = yes; then\n    break\n  else\n    lt_cv_sys_global_symbol_pipe=\n  fi\ndone\n])\nif test -z \"$lt_cv_sys_global_symbol_pipe\"; then\n  lt_cv_sys_global_symbol_to_cdecl=\nfi\nif test -z \"$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl\"; then\n  AC_MSG_RESULT(failed)\nelse\n  AC_MSG_RESULT(ok)\nfi\n\n# Response file support.\nif test \"$lt_cv_nm_interface\" = \"MS dumpbin\"; then\n  nm_file_list_spec='@'\nelif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then\n  nm_file_list_spec='@'\nfi\n\n_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],\n    [Take the output of nm and produce a listing of raw symbols and C names])\n_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],\n    [Transform the output of nm in a proper C declaration])\n_LT_DECL([global_symbol_to_c_name_address],\n    [lt_cv_sys_global_symbol_to_c_name_address], [1],\n    [Transform the output of nm in a C name address pair])\n_LT_DECL([global_symbol_to_c_name_address_lib_prefix],\n    [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],\n    [Transform the output of nm in a C name address pair when lib prefix is needed])\n_LT_DECL([], [nm_file_list_spec], [1],\n    [Specify filename containing input files for $NM])\n]) # _LT_CMD_GLOBAL_SYMBOLS\n\n\n# _LT_COMPILER_PIC([TAGNAME])\n# ---------------------------\nm4_defun([_LT_COMPILER_PIC],\n[m4_require([_LT_TAG_COMPILER])dnl\n_LT_TAGVAR(lt_prog_compiler_wl, $1)=\n_LT_TAGVAR(lt_prog_compiler_pic, $1)=\n_LT_TAGVAR(lt_prog_compiler_static, $1)=\n\nm4_if([$1], [CXX], [\n  # C++ specific cases for pic, static, wl, etc.\n  if test \"$GXX\" = yes; then\n    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'\n\n    case $host_os in\n    aix*)\n      # All AIX code is PIC.\n      if test \"$host_cpu\" = ia64; then\n\t# AIX 5 now supports IA64 processor\n\t_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'\n      fi\n      ;;\n\n    amigaos*)\n      case $host_cpu in\n      powerpc)\n            # see comment about AmigaOS4 .so support\n            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'\n        ;;\n      m68k)\n            # FIXME: we need at least 68020 code to build shared libraries, but\n            # adding the `-m68020' flag to GCC prevents building anything better,\n            # like `-m68040'.\n            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'\n        ;;\n      esac\n      ;;\n\n    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)\n      # PIC is the default for these OSes.\n      ;;\n    mingw* | cygwin* | os2* | pw32* | cegcc*)\n      # This hack is so that the source file can tell whether it is being\n      # built for inclusion in a dll (and should export symbols for example).\n      # Although the cygwin gcc ignores -fPIC, still need this for old-style\n      # (--disable-auto-import) libraries\n      m4_if([$1], [GCJ], [],\n\t[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])\n      ;;\n    darwin* | rhapsody*)\n      # PIC is the default on this platform\n      # Common symbols not allowed in MH_DYLIB files\n      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'\n      ;;\n    *djgpp*)\n      # DJGPP does not support shared libraries at all\n      _LT_TAGVAR(lt_prog_compiler_pic, $1)=\n      ;;\n    haiku*)\n      # PIC is the default for Haiku.\n      # The \"-static\" flag exists, but is broken.\n      _LT_TAGVAR(lt_prog_compiler_static, $1)=\n      ;;\n    interix[[3-9]]*)\n      # Interix 3.x gcc -fpic/-fPIC options generate broken code.\n      # Instead, we relocate shared libraries at runtime.\n      ;;\n    sysv4*MP*)\n      if test -d /usr/nec; then\n\t_LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic\n      fi\n      ;;\n    hpux*)\n      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit\n      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag\n      # sets the default TLS model and affects inlining.\n      case $host_cpu in\n      hppa*64*)\n\t;;\n      *)\n\t_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'\n\t;;\n      esac\n      ;;\n    *qnx* | *nto*)\n      # QNX uses GNU C++, but need to define -shared option too, otherwise\n      # it will coredump.\n      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'\n      ;;\n    *)\n      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'\n      ;;\n    esac\n  else\n    case $host_os in\n      aix[[4-9]]*)\n\t# All AIX code is PIC.\n\tif test \"$host_cpu\" = ia64; then\n\t  # AIX 5 now supports IA64 processor\n\t  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'\n\telse\n\t  _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'\n\tfi\n\t;;\n      chorus*)\n\tcase $cc_basename in\n\tcxch68*)\n\t  # Green Hills C++ Compiler\n\t  # _LT_TAGVAR(lt_prog_compiler_static, $1)=\"--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a\"\n\t  ;;\n\tesac\n\t;;\n      mingw* | cygwin* | os2* | pw32* | cegcc*)\n\t# This hack is so that the source file can tell whether it is being\n\t# built for inclusion in a dll (and should export symbols for example).\n\tm4_if([$1], [GCJ], [],\n\t  [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])\n\t;;\n      dgux*)\n\tcase $cc_basename in\n\t  ec++*)\n\t    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'\n\t    ;;\n\t  ghcx*)\n\t    # Green Hills C++ Compiler\n\t    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'\n\t    ;;\n\t  *)\n\t    ;;\n\tesac\n\t;;\n      freebsd* | dragonfly*)\n\t# FreeBSD uses GNU C++\n\t;;\n      hpux9* | hpux10* | hpux11*)\n\tcase $cc_basename in\n\t  CC*)\n\t    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n\t    _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'\n\t    if test \"$host_cpu\" != ia64; then\n\t      _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'\n\t    fi\n\t    ;;\n\t  aCC*)\n\t    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n\t    _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'\n\t    case $host_cpu in\n\t    hppa*64*|ia64*)\n\t      # +Z the default\n\t      ;;\n\t    *)\n\t      _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'\n\t      ;;\n\t    esac\n\t    ;;\n\t  *)\n\t    ;;\n\tesac\n\t;;\n      interix*)\n\t# This is c89, which is MS Visual C++ (no shared libs)\n\t# Anyone wants to do a port?\n\t;;\n      irix5* | irix6* | nonstopux*)\n\tcase $cc_basename in\n\t  CC*)\n\t    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n\t    _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'\n\t    # CC pic flag -KPIC is the default.\n\t    ;;\n\t  *)\n\t    ;;\n\tesac\n\t;;\n      linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)\n\tcase $cc_basename in\n\t  KCC*)\n\t    # KAI C++ Compiler\n\t    _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'\n\t    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'\n\t    ;;\n\t  ecpc* )\n\t    # old Intel C++ for x86_64 which still supported -KPIC.\n\t    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n\t    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'\n\t    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'\n\t    ;;\n\t  icpc* )\n\t    # Intel C++, used to be incompatible with GCC.\n\t    # ICC 10 doesn't accept -KPIC any more.\n\t    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n\t    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'\n\t    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'\n\t    ;;\n\t  pgCC* | pgcpp*)\n\t    # Portland Group C++ compiler\n\t    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n\t    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'\n\t    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'\n\t    ;;\n\t  cxx*)\n\t    # Compaq C++\n\t    # Make sure the PIC flag is empty.  It appears that all Alpha\n\t    # Linux and Compaq Tru64 Unix objects are PIC.\n\t    _LT_TAGVAR(lt_prog_compiler_pic, $1)=\n\t    _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'\n\t    ;;\n\t  xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*)\n\t    # IBM XL 8.0, 9.0 on PPC and BlueGene\n\t    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n\t    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'\n\t    _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'\n\t    ;;\n\t  *)\n\t    case `$CC -V 2>&1 | sed 5q` in\n\t    *Sun\\ C*)\n\t      # Sun C++ 5.9\n\t      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'\n\t      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'\n\t      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '\n\t      ;;\n\t    esac\n\t    ;;\n\tesac\n\t;;\n      lynxos*)\n\t;;\n      m88k*)\n\t;;\n      mvs*)\n\tcase $cc_basename in\n\t  cxx*)\n\t    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'\n\t    ;;\n\t  *)\n\t    ;;\n\tesac\n\t;;\n      netbsd* | netbsdelf*-gnu)\n\t;;\n      *qnx* | *nto*)\n        # QNX uses GNU C++, but need to define -shared option too, otherwise\n        # it will coredump.\n        _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'\n        ;;\n      osf3* | osf4* | osf5*)\n\tcase $cc_basename in\n\t  KCC*)\n\t    _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'\n\t    ;;\n\t  RCC*)\n\t    # Rational C++ 2.4.1\n\t    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'\n\t    ;;\n\t  cxx*)\n\t    # Digital/Compaq C++\n\t    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n\t    # Make sure the PIC flag is empty.  It appears that all Alpha\n\t    # Linux and Compaq Tru64 Unix objects are PIC.\n\t    _LT_TAGVAR(lt_prog_compiler_pic, $1)=\n\t    _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'\n\t    ;;\n\t  *)\n\t    ;;\n\tesac\n\t;;\n      psos*)\n\t;;\n      solaris*)\n\tcase $cc_basename in\n\t  CC* | sunCC*)\n\t    # Sun C++ 4.2, 5.x and Centerline C++\n\t    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'\n\t    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'\n\t    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '\n\t    ;;\n\t  gcx*)\n\t    # Green Hills C++ Compiler\n\t    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'\n\t    ;;\n\t  *)\n\t    ;;\n\tesac\n\t;;\n      sunos4*)\n\tcase $cc_basename in\n\t  CC*)\n\t    # Sun C++ 4.x\n\t    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'\n\t    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'\n\t    ;;\n\t  lcc*)\n\t    # Lucid\n\t    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'\n\t    ;;\n\t  *)\n\t    ;;\n\tesac\n\t;;\n      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)\n\tcase $cc_basename in\n\t  CC*)\n\t    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n\t    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'\n\t    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'\n\t    ;;\n\tesac\n\t;;\n      tandem*)\n\tcase $cc_basename in\n\t  NCC*)\n\t    # NonStop-UX NCC 3.20\n\t    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'\n\t    ;;\n\t  *)\n\t    ;;\n\tesac\n\t;;\n      vxworks*)\n\t;;\n      *)\n\t_LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no\n\t;;\n    esac\n  fi\n],\n[\n  if test \"$GCC\" = yes; then\n    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'\n\n    case $host_os in\n      aix*)\n      # All AIX code is PIC.\n      if test \"$host_cpu\" = ia64; then\n\t# AIX 5 now supports IA64 processor\n\t_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'\n      fi\n      ;;\n\n    amigaos*)\n      case $host_cpu in\n      powerpc)\n            # see comment about AmigaOS4 .so support\n            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'\n        ;;\n      m68k)\n            # FIXME: we need at least 68020 code to build shared libraries, but\n            # adding the `-m68020' flag to GCC prevents building anything better,\n            # like `-m68040'.\n            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'\n        ;;\n      esac\n      ;;\n\n    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)\n      # PIC is the default for these OSes.\n      ;;\n\n    mingw* | cygwin* | pw32* | os2* | cegcc*)\n      # This hack is so that the source file can tell whether it is being\n      # built for inclusion in a dll (and should export symbols for example).\n      # Although the cygwin gcc ignores -fPIC, still need this for old-style\n      # (--disable-auto-import) libraries\n      m4_if([$1], [GCJ], [],\n\t[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])\n      ;;\n\n    darwin* | rhapsody*)\n      # PIC is the default on this platform\n      # Common symbols not allowed in MH_DYLIB files\n      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'\n      ;;\n\n    haiku*)\n      # PIC is the default for Haiku.\n      # The \"-static\" flag exists, but is broken.\n      _LT_TAGVAR(lt_prog_compiler_static, $1)=\n      ;;\n\n    hpux*)\n      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit\n      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag\n      # sets the default TLS model and affects inlining.\n      case $host_cpu in\n      hppa*64*)\n\t# +Z the default\n\t;;\n      *)\n\t_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'\n\t;;\n      esac\n      ;;\n\n    interix[[3-9]]*)\n      # Interix 3.x gcc -fpic/-fPIC options generate broken code.\n      # Instead, we relocate shared libraries at runtime.\n      ;;\n\n    msdosdjgpp*)\n      # Just because we use GCC doesn't mean we suddenly get shared libraries\n      # on systems that don't support them.\n      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no\n      enable_shared=no\n      ;;\n\n    *nto* | *qnx*)\n      # QNX uses GNU C++, but need to define -shared option too, otherwise\n      # it will coredump.\n      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'\n      ;;\n\n    sysv4*MP*)\n      if test -d /usr/nec; then\n\t_LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic\n      fi\n      ;;\n\n    *)\n      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'\n      ;;\n    esac\n\n    case $cc_basename in\n    nvcc*) # Cuda Compiler Driver 2.2\n      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker '\n      if test -n \"$_LT_TAGVAR(lt_prog_compiler_pic, $1)\"; then\n        _LT_TAGVAR(lt_prog_compiler_pic, $1)=\"-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)\"\n      fi\n      ;;\n    esac\n  else\n    # PORTME Check for flag to pass linker flags through the system compiler.\n    case $host_os in\n    aix*)\n      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n      if test \"$host_cpu\" = ia64; then\n\t# AIX 5 now supports IA64 processor\n\t_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'\n      else\n\t_LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'\n      fi\n      ;;\n\n    mingw* | cygwin* | pw32* | os2* | cegcc*)\n      # This hack is so that the source file can tell whether it is being\n      # built for inclusion in a dll (and should export symbols for example).\n      m4_if([$1], [GCJ], [],\n\t[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])\n      ;;\n\n    hpux9* | hpux10* | hpux11*)\n      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but\n      # not for PA HP-UX.\n      case $host_cpu in\n      hppa*64*|ia64*)\n\t# +Z the default\n\t;;\n      *)\n\t_LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'\n\t;;\n      esac\n      # Is there a better lt_prog_compiler_static that works with the bundled CC?\n      _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'\n      ;;\n\n    irix5* | irix6* | nonstopux*)\n      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n      # PIC (with -KPIC) is the default.\n      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'\n      ;;\n\n    linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)\n      case $cc_basename in\n      # old Intel for x86_64 which still supported -KPIC.\n      ecc*)\n\t_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n\t_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'\n\t_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'\n        ;;\n      # icc used to be incompatible with GCC.\n      # ICC 10 doesn't accept -KPIC any more.\n      icc* | ifort*)\n\t_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n\t_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'\n\t_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'\n        ;;\n      # Lahey Fortran 8.1.\n      lf95*)\n\t_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n\t_LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared'\n\t_LT_TAGVAR(lt_prog_compiler_static, $1)='--static'\n\t;;\n      nagfor*)\n\t# NAG Fortran compiler\n\t_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,'\n\t_LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'\n\t_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'\n\t;;\n      pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)\n        # Portland Group compilers (*not* the Pentium gcc compiler,\n\t# which looks to be a dead project)\n\t_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n\t_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'\n\t_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'\n        ;;\n      ccc*)\n        _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n        # All Alpha code is PIC.\n        _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'\n        ;;\n      xl* | bgxl* | bgf* | mpixl*)\n\t# IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene\n\t_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n\t_LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'\n\t_LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'\n\t;;\n      *)\n\tcase `$CC -V 2>&1 | sed 5q` in\n\t*Sun\\ Ceres\\ Fortran* | *Sun*Fortran*\\ [[1-7]].* | *Sun*Fortran*\\ 8.[[0-3]]*)\n\t  # Sun Fortran 8.3 passes all unrecognized flags to the linker\n\t  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'\n\t  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'\n\t  _LT_TAGVAR(lt_prog_compiler_wl, $1)=''\n\t  ;;\n\t*Sun\\ F* | *Sun*Fortran*)\n\t  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'\n\t  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'\n\t  _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '\n\t  ;;\n\t*Sun\\ C*)\n\t  # Sun C 5.9\n\t  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'\n\t  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'\n\t  _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n\t  ;;\n        *Intel*\\ [[CF]]*Compiler*)\n\t  _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n\t  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'\n\t  _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'\n\t  ;;\n\t*Portland\\ Group*)\n\t  _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n\t  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'\n\t  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'\n\t  ;;\n\tesac\n\t;;\n      esac\n      ;;\n\n    newsos6)\n      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'\n      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'\n      ;;\n\n    *nto* | *qnx*)\n      # QNX uses GNU C++, but need to define -shared option too, otherwise\n      # it will coredump.\n      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'\n      ;;\n\n    osf3* | osf4* | osf5*)\n      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n      # All OSF/1 code is PIC.\n      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'\n      ;;\n\n    rdos*)\n      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'\n      ;;\n\n    solaris*)\n      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'\n      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'\n      case $cc_basename in\n      f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)\n\t_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;\n      *)\n\t_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;\n      esac\n      ;;\n\n    sunos4*)\n      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '\n      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'\n      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'\n      ;;\n\n    sysv4 | sysv4.2uw2* | sysv4.3*)\n      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'\n      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'\n      ;;\n\n    sysv4*MP*)\n      if test -d /usr/nec ;then\n\t_LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'\n\t_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'\n      fi\n      ;;\n\n    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)\n      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'\n      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'\n      ;;\n\n    unicos*)\n      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'\n      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no\n      ;;\n\n    uts4*)\n      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'\n      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'\n      ;;\n\n    *)\n      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no\n      ;;\n    esac\n  fi\n])\ncase $host_os in\n  # For platforms which do not support PIC, -DPIC is meaningless:\n  *djgpp*)\n    _LT_TAGVAR(lt_prog_compiler_pic, $1)=\n    ;;\n  *)\n    _LT_TAGVAR(lt_prog_compiler_pic, $1)=\"$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])\"\n    ;;\nesac\n\nAC_CACHE_CHECK([for $compiler option to produce PIC],\n  [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)],\n  [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)])\n_LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)\n\n#\n# Check to make sure the PIC flag actually works.\n#\nif test -n \"$_LT_TAGVAR(lt_prog_compiler_pic, $1)\"; then\n  _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works],\n    [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)],\n    [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [],\n    [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in\n     \"\" | \" \"*) ;;\n     *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=\" $_LT_TAGVAR(lt_prog_compiler_pic, $1)\" ;;\n     esac],\n    [_LT_TAGVAR(lt_prog_compiler_pic, $1)=\n     _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])\nfi\n_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],\n\t[Additional compiler flags for building library objects])\n\n_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],\n\t[How to pass a linker flag through the compiler])\n#\n# Check to make sure the static flag actually works.\n#\nwl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\\\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\\\"\n_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],\n  _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1),\n  $lt_tmp_static_flag,\n  [],\n  [_LT_TAGVAR(lt_prog_compiler_static, $1)=])\n_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],\n\t[Compiler flag to prevent dynamic linking])\n])# _LT_COMPILER_PIC\n\n\n# _LT_LINKER_SHLIBS([TAGNAME])\n# ----------------------------\n# See if the linker supports building shared libraries.\nm4_defun([_LT_LINKER_SHLIBS],\n[AC_REQUIRE([LT_PATH_LD])dnl\nAC_REQUIRE([LT_PATH_NM])dnl\nm4_require([_LT_PATH_MANIFEST_TOOL])dnl\nm4_require([_LT_FILEUTILS_DEFAULTS])dnl\nm4_require([_LT_DECL_EGREP])dnl\nm4_require([_LT_DECL_SED])dnl\nm4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl\nm4_require([_LT_TAG_COMPILER])dnl\nAC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])\nm4_if([$1], [CXX], [\n  _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\\''s/.* //'\\'' | sort | uniq > $export_symbols'\n  _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']\n  case $host_os in\n  aix[[4-9]]*)\n    # If we're using GNU nm, then we don't want the \"-C\" option.\n    # -C means demangle to AIX nm, but means don't demangle with GNU nm\n    # Also, AIX nm treats weak defined symbols like other global defined\n    # symbols, whereas GNU nm marks them as \"W\".\n    if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then\n      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\\''{ if (((\\$ 2 == \"T\") || (\\$ 2 == \"D\") || (\\$ 2 == \"B\") || (\\$ 2 == \"W\")) && ([substr](\\$ 3,1,1) != \".\")) { print \\$ 3 } }'\\'' | sort -u > $export_symbols'\n    else\n      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\\''{ if (((\\$ 2 == \"T\") || (\\$ 2 == \"D\") || (\\$ 2 == \"B\")) && ([substr](\\$ 3,1,1) != \".\")) { print \\$ 3 } }'\\'' | sort -u > $export_symbols'\n    fi\n    ;;\n  pw32*)\n    _LT_TAGVAR(export_symbols_cmds, $1)=\"$ltdll_cmds\"\n    ;;\n  cygwin* | mingw* | cegcc*)\n    case $cc_basename in\n    cl*)\n      _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'\n      ;;\n    *)\n      _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\\([[^ ]]*\\)/\\1 DATA/;s/^.*[[ ]]__nm__\\([[^ ]]*\\)[[ ]][[^ ]]*/\\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\\'' | sort | uniq > $export_symbols'\n      _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']\n      ;;\n    esac\n    ;;\n  linux* | k*bsd*-gnu | gnu*)\n    _LT_TAGVAR(link_all_deplibs, $1)=no\n    ;;\n  *)\n    _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\\''s/.* //'\\'' | sort | uniq > $export_symbols'\n    ;;\n  esac\n], [\n  runpath_var=\n  _LT_TAGVAR(allow_undefined_flag, $1)=\n  _LT_TAGVAR(always_export_symbols, $1)=no\n  _LT_TAGVAR(archive_cmds, $1)=\n  _LT_TAGVAR(archive_expsym_cmds, $1)=\n  _LT_TAGVAR(compiler_needs_object, $1)=no\n  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no\n  _LT_TAGVAR(export_dynamic_flag_spec, $1)=\n  _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\\''s/.* //'\\'' | sort | uniq > $export_symbols'\n  _LT_TAGVAR(hardcode_automatic, $1)=no\n  _LT_TAGVAR(hardcode_direct, $1)=no\n  _LT_TAGVAR(hardcode_direct_absolute, $1)=no\n  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=\n  _LT_TAGVAR(hardcode_libdir_separator, $1)=\n  _LT_TAGVAR(hardcode_minus_L, $1)=no\n  _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported\n  _LT_TAGVAR(inherit_rpath, $1)=no\n  _LT_TAGVAR(link_all_deplibs, $1)=unknown\n  _LT_TAGVAR(module_cmds, $1)=\n  _LT_TAGVAR(module_expsym_cmds, $1)=\n  _LT_TAGVAR(old_archive_from_new_cmds, $1)=\n  _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)=\n  _LT_TAGVAR(thread_safe_flag_spec, $1)=\n  _LT_TAGVAR(whole_archive_flag_spec, $1)=\n  # include_expsyms should be a list of space-separated symbols to be *always*\n  # included in the symbol list\n  _LT_TAGVAR(include_expsyms, $1)=\n  # exclude_expsyms can be an extended regexp of symbols to exclude\n  # it will be wrapped by ` (' and `)$', so one must not match beginning or\n  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',\n  # as well as any symbol that contains `d'.\n  _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']\n  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out\n  # platforms (ab)use it in PIC code, but their linkers get confused if\n  # the symbol is explicitly referenced.  Since portable code cannot\n  # rely on this symbol name, it's probably fine to never include it in\n  # preloaded symbol tables.\n  # Exclude shared library initialization/finalization symbols.\ndnl Note also adjust exclude_expsyms for C++ above.\n  extract_expsyms_cmds=\n\n  case $host_os in\n  cygwin* | mingw* | pw32* | cegcc*)\n    # FIXME: the MSVC++ port hasn't been tested in a loooong time\n    # When not using gcc, we currently assume that we are using\n    # Microsoft Visual C++.\n    if test \"$GCC\" != yes; then\n      with_gnu_ld=no\n    fi\n    ;;\n  interix*)\n    # we just hope/assume this is gcc and not c89 (= MSVC++)\n    with_gnu_ld=yes\n    ;;\n  openbsd*)\n    with_gnu_ld=no\n    ;;\n  linux* | k*bsd*-gnu | gnu*)\n    _LT_TAGVAR(link_all_deplibs, $1)=no\n    ;;\n  esac\n\n  _LT_TAGVAR(ld_shlibs, $1)=yes\n\n  # On some targets, GNU ld is compatible enough with the native linker\n  # that we're better off using the native interface for both.\n  lt_use_gnu_ld_interface=no\n  if test \"$with_gnu_ld\" = yes; then\n    case $host_os in\n      aix*)\n\t# The AIX port of GNU ld has always aspired to compatibility\n\t# with the native linker.  However, as the warning in the GNU ld\n\t# block says, versions before 2.19.5* couldn't really create working\n\t# shared libraries, regardless of the interface used.\n\tcase `$LD -v 2>&1` in\n\t  *\\ \\(GNU\\ Binutils\\)\\ 2.19.5*) ;;\n\t  *\\ \\(GNU\\ Binutils\\)\\ 2.[[2-9]]*) ;;\n\t  *\\ \\(GNU\\ Binutils\\)\\ [[3-9]]*) ;;\n\t  *)\n\t    lt_use_gnu_ld_interface=yes\n\t    ;;\n\tesac\n\t;;\n      *)\n\tlt_use_gnu_ld_interface=yes\n\t;;\n    esac\n  fi\n\n  if test \"$lt_use_gnu_ld_interface\" = yes; then\n    # If archive_cmds runs LD, not CC, wlarc should be empty\n    wlarc='${wl}'\n\n    # Set some defaults for GNU ld with shared library support. These\n    # are reset later if shared libraries are not supported. Putting them\n    # here allows them to be overridden if necessary.\n    runpath_var=LD_RUN_PATH\n    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'\n    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'\n    # ancient GNU ld didn't support --whole-archive et. al.\n    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then\n      _LT_TAGVAR(whole_archive_flag_spec, $1)=\"$wlarc\"'--whole-archive$convenience '\"$wlarc\"'--no-whole-archive'\n    else\n      _LT_TAGVAR(whole_archive_flag_spec, $1)=\n    fi\n    supports_anon_versioning=no\n    case `$LD -v 2>&1` in\n      *GNU\\ gold*) supports_anon_versioning=yes ;;\n      *\\ [[01]].* | *\\ 2.[[0-9]].* | *\\ 2.10.*) ;; # catch versions < 2.11\n      *\\ 2.11.93.0.2\\ *) supports_anon_versioning=yes ;; # RH7.3 ...\n      *\\ 2.11.92.0.12\\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...\n      *\\ 2.11.*) ;; # other 2.11 versions\n      *) supports_anon_versioning=yes ;;\n    esac\n\n    # See if GNU ld supports shared libraries.\n    case $host_os in\n    aix[[3-9]]*)\n      # On AIX/PPC, the GNU linker is very broken\n      if test \"$host_cpu\" != ia64; then\n\t_LT_TAGVAR(ld_shlibs, $1)=no\n\tcat <<_LT_EOF 1>&2\n\n*** Warning: the GNU linker, at least up to release 2.19, is reported\n*** to be unable to reliably create shared libraries on AIX.\n*** Therefore, libtool is disabling shared libraries support.  If you\n*** really care for shared libraries, you may want to install binutils\n*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.\n*** You will then need to restart the configuration process.\n\n_LT_EOF\n      fi\n      ;;\n\n    amigaos*)\n      case $host_cpu in\n      powerpc)\n            # see comment about AmigaOS4 .so support\n            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n            _LT_TAGVAR(archive_expsym_cmds, $1)=''\n        ;;\n      m68k)\n            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO \"#define NAME $libname\" > $output_objdir/a2ixlibrary.data~$ECHO \"#define LIBRARY_ID 1\" >> $output_objdir/a2ixlibrary.data~$ECHO \"#define VERSION $major\" >> $output_objdir/a2ixlibrary.data~$ECHO \"#define REVISION $revision\" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'\n            _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'\n            _LT_TAGVAR(hardcode_minus_L, $1)=yes\n        ;;\n      esac\n      ;;\n\n    beos*)\n      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then\n\t_LT_TAGVAR(allow_undefined_flag, $1)=unsupported\n\t# Joseph Beckenbach <jrb3@best.com> says some releases of gcc\n\t# support --undefined.  This deserves some investigation.  FIXME\n\t_LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n      else\n\t_LT_TAGVAR(ld_shlibs, $1)=no\n      fi\n      ;;\n\n    cygwin* | mingw* | pw32* | cegcc*)\n      # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,\n      # as there is no search path for DLLs.\n      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'\n      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'\n      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported\n      _LT_TAGVAR(always_export_symbols, $1)=no\n      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes\n      _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\\([[^ ]]*\\)/\\1 DATA/;s/^.*[[ ]]__nm__\\([[^ ]]*\\)[[ ]][[^ ]]*/\\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\\'' | sort | uniq > $export_symbols'\n      _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']\n\n      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then\n        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'\n\t# If the export-symbols file already is a .def file (1st line\n\t# is EXPORTS), use it as is; otherwise, prepend...\n\t_LT_TAGVAR(archive_expsym_cmds, $1)='if test \"x`$SED 1q $export_symbols`\" = xEXPORTS; then\n\t  cp $export_symbols $output_objdir/$soname.def;\n\telse\n\t  echo EXPORTS > $output_objdir/$soname.def;\n\t  cat $export_symbols >> $output_objdir/$soname.def;\n\tfi~\n\t$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'\n      else\n\t_LT_TAGVAR(ld_shlibs, $1)=no\n      fi\n      ;;\n\n    haiku*)\n      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n      _LT_TAGVAR(link_all_deplibs, $1)=yes\n      ;;\n\n    interix[[3-9]]*)\n      _LT_TAGVAR(hardcode_direct, $1)=no\n      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'\n      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'\n      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.\n      # Instead, shared libraries are loaded at an image base (0x10000000 by\n      # default) and relocated if they conflict, which is a slow very memory\n      # consuming and fragmenting process.  To avoid this, we pick a random,\n      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link\n      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.\n      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \\* 262144 + 1342177280` -o $lib'\n      _LT_TAGVAR(archive_expsym_cmds, $1)='sed \"s,^,_,\" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \\* 262144 + 1342177280` -o $lib'\n      ;;\n\n    gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)\n      tmp_diet=no\n      if test \"$host_os\" = linux-dietlibc; then\n\tcase $cc_basename in\n\t  diet\\ *) tmp_diet=yes;;\t# linux-dietlibc with static linking (!diet-dyn)\n\tesac\n      fi\n      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \\\n\t && test \"$tmp_diet\" = no\n      then\n\ttmp_addflag=' $pic_flag'\n\ttmp_sharedflag='-shared'\n\tcase $cc_basename,$host_cpu in\n        pgcc*)\t\t\t\t# Portland Group C compiler\n\t  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\\\"\\\"; do test  -n \\\"$conv\\\" && new_convenience=\\\"$new_convenience,$conv\\\"; done; func_echo_all \\\"$new_convenience\\\"` ${wl}--no-whole-archive'\n\t  tmp_addflag=' $pic_flag'\n\t  ;;\n\tpgf77* | pgf90* | pgf95* | pgfortran*)\n\t\t\t\t\t# Portland Group f77 and f90 compilers\n\t  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\\\"\\\"; do test  -n \\\"$conv\\\" && new_convenience=\\\"$new_convenience,$conv\\\"; done; func_echo_all \\\"$new_convenience\\\"` ${wl}--no-whole-archive'\n\t  tmp_addflag=' $pic_flag -Mnomain' ;;\n\tecc*,ia64* | icc*,ia64*)\t# Intel C compiler on ia64\n\t  tmp_addflag=' -i_dynamic' ;;\n\tefc*,ia64* | ifort*,ia64*)\t# Intel Fortran compiler on ia64\n\t  tmp_addflag=' -i_dynamic -nofor_main' ;;\n\tifc* | ifort*)\t\t\t# Intel Fortran compiler\n\t  tmp_addflag=' -nofor_main' ;;\n\tlf95*)\t\t\t\t# Lahey Fortran 8.1\n\t  _LT_TAGVAR(whole_archive_flag_spec, $1)=\n\t  tmp_sharedflag='--shared' ;;\n\txl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)\n\t  tmp_sharedflag='-qmkshrobj'\n\t  tmp_addflag= ;;\n\tnvcc*)\t# Cuda Compiler Driver 2.2\n\t  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\\\"\\\"; do test  -n \\\"$conv\\\" && new_convenience=\\\"$new_convenience,$conv\\\"; done; func_echo_all \\\"$new_convenience\\\"` ${wl}--no-whole-archive'\n\t  _LT_TAGVAR(compiler_needs_object, $1)=yes\n\t  ;;\n\tesac\n\tcase `$CC -V 2>&1 | sed 5q` in\n\t*Sun\\ C*)\t\t\t# Sun C 5.9\n\t  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\\\"\\\"; do test -z \\\"$conv\\\" || new_convenience=\\\"$new_convenience,$conv\\\"; done; func_echo_all \\\"$new_convenience\\\"` ${wl}--no-whole-archive'\n\t  _LT_TAGVAR(compiler_needs_object, $1)=yes\n\t  tmp_sharedflag='-G' ;;\n\t*Sun\\ F*)\t\t\t# Sun Fortran 8.3\n\t  tmp_sharedflag='-G' ;;\n\tesac\n\t_LT_TAGVAR(archive_cmds, $1)='$CC '\"$tmp_sharedflag\"\"$tmp_addflag\"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n\n        if test \"x$supports_anon_versioning\" = xyes; then\n          _LT_TAGVAR(archive_expsym_cmds, $1)='echo \"{ global:\" > $output_objdir/$libname.ver~\n\t    cat $export_symbols | sed -e \"s/\\(.*\\)/\\1;/\" >> $output_objdir/$libname.ver~\n\t    echo \"local: *; };\" >> $output_objdir/$libname.ver~\n\t    $CC '\"$tmp_sharedflag\"\"$tmp_addflag\"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'\n        fi\n\n\tcase $cc_basename in\n\txlf* | bgf* | bgxlf* | mpixlf*)\n\t  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself\n\t  _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'\n\t  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'\n\t  _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'\n\t  if test \"x$supports_anon_versioning\" = xyes; then\n\t    _LT_TAGVAR(archive_expsym_cmds, $1)='echo \"{ global:\" > $output_objdir/$libname.ver~\n\t      cat $export_symbols | sed -e \"s/\\(.*\\)/\\1;/\" >> $output_objdir/$libname.ver~\n\t      echo \"local: *; };\" >> $output_objdir/$libname.ver~\n\t      $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'\n\t  fi\n\t  ;;\n\tesac\n      else\n        _LT_TAGVAR(ld_shlibs, $1)=no\n      fi\n      ;;\n\n    netbsd* | netbsdelf*-gnu)\n      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then\n\t_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'\n\twlarc=\n      else\n\t_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n\t_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'\n      fi\n      ;;\n\n    solaris*)\n      if $LD -v 2>&1 | $GREP 'BFD 2\\.8' > /dev/null; then\n\t_LT_TAGVAR(ld_shlibs, $1)=no\n\tcat <<_LT_EOF 1>&2\n\n*** Warning: The releases 2.8.* of the GNU linker cannot reliably\n*** create shared libraries on Solaris systems.  Therefore, libtool\n*** is disabling shared libraries support.  We urge you to upgrade GNU\n*** binutils to release 2.9.1 or newer.  Another option is to modify\n*** your PATH or compiler configuration so that the native linker is\n*** used, and then restart.\n\n_LT_EOF\n      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then\n\t_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n\t_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'\n      else\n\t_LT_TAGVAR(ld_shlibs, $1)=no\n      fi\n      ;;\n\n    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)\n      case `$LD -v 2>&1` in\n        *\\ [[01]].* | *\\ 2.[[0-9]].* | *\\ 2.1[[0-5]].*)\n\t_LT_TAGVAR(ld_shlibs, $1)=no\n\tcat <<_LT_EOF 1>&2\n\n*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not\n*** reliably create shared libraries on SCO systems.  Therefore, libtool\n*** is disabling shared libraries support.  We urge you to upgrade GNU\n*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify\n*** your PATH or compiler configuration so that the native linker is\n*** used, and then restart.\n\n_LT_EOF\n\t;;\n\t*)\n\t  # For security reasons, it is highly recommended that you always\n\t  # use absolute paths for naming shared libraries, and exclude the\n\t  # DT_RUNPATH tag from executables and libraries.  But doing so\n\t  # requires that you compile everything twice, which is a pain.\n\t  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then\n\t    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'\n\t    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n\t    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'\n\t  else\n\t    _LT_TAGVAR(ld_shlibs, $1)=no\n\t  fi\n\t;;\n      esac\n      ;;\n\n    sunos4*)\n      _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'\n      wlarc=\n      _LT_TAGVAR(hardcode_direct, $1)=yes\n      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n      ;;\n\n    *)\n      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then\n\t_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n\t_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'\n      else\n\t_LT_TAGVAR(ld_shlibs, $1)=no\n      fi\n      ;;\n    esac\n\n    if test \"$_LT_TAGVAR(ld_shlibs, $1)\" = no; then\n      runpath_var=\n      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=\n      _LT_TAGVAR(export_dynamic_flag_spec, $1)=\n      _LT_TAGVAR(whole_archive_flag_spec, $1)=\n    fi\n  else\n    # PORTME fill in a description of your system's linker (not GNU ld)\n    case $host_os in\n    aix3*)\n      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported\n      _LT_TAGVAR(always_export_symbols, $1)=yes\n      _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'\n      # Note: this linker hardcodes the directories in LIBPATH if there\n      # are no directories specified by -L.\n      _LT_TAGVAR(hardcode_minus_L, $1)=yes\n      if test \"$GCC\" = yes && test -z \"$lt_prog_compiler_static\"; then\n\t# Neither direct hardcoding nor static linking is supported with a\n\t# broken collect2.\n\t_LT_TAGVAR(hardcode_direct, $1)=unsupported\n      fi\n      ;;\n\n    aix[[4-9]]*)\n      if test \"$host_cpu\" = ia64; then\n\t# On IA64, the linker does run time linking by default, so we don't\n\t# have to do anything special.\n\taix_use_runtimelinking=no\n\texp_sym_flag='-Bexport'\n\tno_entry_flag=\"\"\n      else\n\t# If we're using GNU nm, then we don't want the \"-C\" option.\n\t# -C means demangle to AIX nm, but means don't demangle with GNU nm\n\t# Also, AIX nm treats weak defined symbols like other global\n\t# defined symbols, whereas GNU nm marks them as \"W\".\n\tif $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then\n\t  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\\''{ if (((\\$ 2 == \"T\") || (\\$ 2 == \"D\") || (\\$ 2 == \"B\") || (\\$ 2 == \"W\")) && ([substr](\\$ 3,1,1) != \".\")) { print \\$ 3 } }'\\'' | sort -u > $export_symbols'\n\telse\n\t  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\\''{ if (((\\$ 2 == \"T\") || (\\$ 2 == \"D\") || (\\$ 2 == \"B\")) && ([substr](\\$ 3,1,1) != \".\")) { print \\$ 3 } }'\\'' | sort -u > $export_symbols'\n\tfi\n\taix_use_runtimelinking=no\n\n\t# Test if we are trying to use run time linking or normal\n\t# AIX style linking. If -brtl is somewhere in LDFLAGS, we\n\t# need to do runtime linking.\n\tcase $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)\n\t  for ld_flag in $LDFLAGS; do\n\t  if (test $ld_flag = \"-brtl\" || test $ld_flag = \"-Wl,-brtl\"); then\n\t    aix_use_runtimelinking=yes\n\t    break\n\t  fi\n\t  done\n\t  ;;\n\tesac\n\n\texp_sym_flag='-bexport'\n\tno_entry_flag='-bnoentry'\n      fi\n\n      # When large executables or shared objects are built, AIX ld can\n      # have problems creating the table of contents.  If linking a library\n      # or program results in \"error TOC overflow\" add -mminimal-toc to\n      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not\n      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.\n\n      _LT_TAGVAR(archive_cmds, $1)=''\n      _LT_TAGVAR(hardcode_direct, $1)=yes\n      _LT_TAGVAR(hardcode_direct_absolute, $1)=yes\n      _LT_TAGVAR(hardcode_libdir_separator, $1)=':'\n      _LT_TAGVAR(link_all_deplibs, $1)=yes\n      _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'\n\n      if test \"$GCC\" = yes; then\n\tcase $host_os in aix4.[[012]]|aix4.[[012]].*)\n\t# We only want to do this on AIX 4.2 and lower, the check\n\t# below for broken collect2 doesn't work under 4.3+\n\t  collect2name=`${CC} -print-prog-name=collect2`\n\t  if test -f \"$collect2name\" &&\n\t   strings \"$collect2name\" | $GREP resolve_lib_name >/dev/null\n\t  then\n\t  # We have reworked collect2\n\t  :\n\t  else\n\t  # We have old collect2\n\t  _LT_TAGVAR(hardcode_direct, $1)=unsupported\n\t  # It fails to find uninstalled libraries when the uninstalled\n\t  # path is not listed in the libpath.  Setting hardcode_minus_L\n\t  # to unsupported forces relinking\n\t  _LT_TAGVAR(hardcode_minus_L, $1)=yes\n\t  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'\n\t  _LT_TAGVAR(hardcode_libdir_separator, $1)=\n\t  fi\n\t  ;;\n\tesac\n\tshared_flag='-shared'\n\tif test \"$aix_use_runtimelinking\" = yes; then\n\t  shared_flag=\"$shared_flag \"'${wl}-G'\n\tfi\n\t_LT_TAGVAR(link_all_deplibs, $1)=no\n      else\n\t# not using gcc\n\tif test \"$host_cpu\" = ia64; then\n\t# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release\n\t# chokes on -Wl,-G. The following line is correct:\n\t  shared_flag='-G'\n\telse\n\t  if test \"$aix_use_runtimelinking\" = yes; then\n\t    shared_flag='${wl}-G'\n\t  else\n\t    shared_flag='${wl}-bM:SRE'\n\t  fi\n\tfi\n      fi\n\n      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'\n      # It seems that -bexpall does not export symbols beginning with\n      # underscore (_), so it is better to generate a list of symbols to export.\n      _LT_TAGVAR(always_export_symbols, $1)=yes\n      if test \"$aix_use_runtimelinking\" = yes; then\n\t# Warning - without using the other runtime loading flags (-brtl),\n\t# -berok will link without error, but may produce a broken library.\n\t_LT_TAGVAR(allow_undefined_flag, $1)='-berok'\n        # Determine the default libpath from the value encoded in an\n        # empty executable.\n        _LT_SYS_MODULE_PATH_AIX([$1])\n        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'\"$aix_libpath\"\n        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '\"\\${wl}$no_entry_flag\"' $compiler_flags `if test \"x${allow_undefined_flag}\" != \"x\"; then func_echo_all \"${wl}${allow_undefined_flag}\"; else :; fi` '\"\\${wl}$exp_sym_flag:\\$export_symbols $shared_flag\"\n      else\n\tif test \"$host_cpu\" = ia64; then\n\t  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'\n\t  _LT_TAGVAR(allow_undefined_flag, $1)=\"-z nodefs\"\n\t  _LT_TAGVAR(archive_expsym_cmds, $1)=\"\\$CC $shared_flag\"' -o $output_objdir/$soname $libobjs $deplibs '\"\\${wl}$no_entry_flag\"' $compiler_flags ${wl}${allow_undefined_flag} '\"\\${wl}$exp_sym_flag:\\$export_symbols\"\n\telse\n\t # Determine the default libpath from the value encoded in an\n\t # empty executable.\n\t _LT_SYS_MODULE_PATH_AIX([$1])\n\t _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'\"$aix_libpath\"\n\t  # Warning - without using the other run time loading flags,\n\t  # -berok will link without error, but may produce a broken library.\n\t  _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'\n\t  _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'\n\t  if test \"$with_gnu_ld\" = yes; then\n\t    # We only use this code for GNU lds that support --whole-archive.\n\t    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'\n\t  else\n\t    # Exported symbols can be pulled into shared objects from archives\n\t    _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'\n\t  fi\n\t  _LT_TAGVAR(archive_cmds_need_lc, $1)=yes\n\t  # This is similar to how AIX traditionally builds its shared libraries.\n\t  _LT_TAGVAR(archive_expsym_cmds, $1)=\"\\$CC $shared_flag\"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'\n\tfi\n      fi\n      ;;\n\n    amigaos*)\n      case $host_cpu in\n      powerpc)\n            # see comment about AmigaOS4 .so support\n            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n            _LT_TAGVAR(archive_expsym_cmds, $1)=''\n        ;;\n      m68k)\n            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO \"#define NAME $libname\" > $output_objdir/a2ixlibrary.data~$ECHO \"#define LIBRARY_ID 1\" >> $output_objdir/a2ixlibrary.data~$ECHO \"#define VERSION $major\" >> $output_objdir/a2ixlibrary.data~$ECHO \"#define REVISION $revision\" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'\n            _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'\n            _LT_TAGVAR(hardcode_minus_L, $1)=yes\n        ;;\n      esac\n      ;;\n\n    bsdi[[45]]*)\n      _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic\n      ;;\n\n    cygwin* | mingw* | pw32* | cegcc*)\n      # When not using gcc, we currently assume that we are using\n      # Microsoft Visual C++.\n      # hardcode_libdir_flag_spec is actually meaningless, as there is\n      # no search path for DLLs.\n      case $cc_basename in\n      cl*)\n\t# Native MSVC\n\t_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '\n\t_LT_TAGVAR(allow_undefined_flag, $1)=unsupported\n\t_LT_TAGVAR(always_export_symbols, $1)=yes\n\t_LT_TAGVAR(file_list_spec, $1)='@'\n\t# Tell ltmain to make .lib files, not .a files.\n\tlibext=lib\n\t# Tell ltmain to make .dll files, not .so files.\n\tshrext_cmds=\".dll\"\n\t# FIXME: Setting linknames here is a bad hack.\n\t_LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='\n\t_LT_TAGVAR(archive_expsym_cmds, $1)='if test \"x`$SED 1q $export_symbols`\" = xEXPORTS; then\n\t    sed -n -e 's/\\\\\\\\\\\\\\(.*\\\\\\\\\\\\\\)/-link\\\\\\ -EXPORT:\\\\\\\\\\\\\\1/' -e '1\\\\\\!p' < $export_symbols > $output_objdir/$soname.exp;\n\t  else\n\t    sed -e 's/\\\\\\\\\\\\\\(.*\\\\\\\\\\\\\\)/-link\\\\\\ -EXPORT:\\\\\\\\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;\n\t  fi~\n\t  $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs \"@$tool_output_objdir$soname.exp\" -Wl,-DLL,-IMPLIB:\"$tool_output_objdir$libname.dll.lib\"~\n\t  linknames='\n\t# The linker will not automatically build a static lib if we build a DLL.\n\t# _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'\n\t_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes\n\t_LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'\n\t_LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\\([[^ ]]*\\)/\\1,DATA/'\\'' | $SED -e '\\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\\'' | sort | uniq > $export_symbols'\n\t# Don't use ranlib\n\t_LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'\n\t_LT_TAGVAR(postlink_cmds, $1)='lt_outputfile=\"@OUTPUT@\"~\n\t  lt_tool_outputfile=\"@TOOL_OUTPUT@\"~\n\t  case $lt_outputfile in\n\t    *.exe|*.EXE) ;;\n\t    *)\n\t      lt_outputfile=\"$lt_outputfile.exe\"\n\t      lt_tool_outputfile=\"$lt_tool_outputfile.exe\"\n\t      ;;\n\t  esac~\n\t  if test \"$MANIFEST_TOOL\" != \":\" && test -f \"$lt_outputfile.manifest\"; then\n\t    $MANIFEST_TOOL -manifest \"$lt_tool_outputfile.manifest\" -outputresource:\"$lt_tool_outputfile\" || exit 1;\n\t    $RM \"$lt_outputfile.manifest\";\n\t  fi'\n\t;;\n      *)\n\t# Assume MSVC wrapper\n\t_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '\n\t_LT_TAGVAR(allow_undefined_flag, $1)=unsupported\n\t# Tell ltmain to make .lib files, not .a files.\n\tlibext=lib\n\t# Tell ltmain to make .dll files, not .so files.\n\tshrext_cmds=\".dll\"\n\t# FIXME: Setting linknames here is a bad hack.\n\t_LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all \"$deplibs\" | $SED '\\''s/ -lc$//'\\''` -link -dll~linknames='\n\t# The linker will automatically build a .lib file if we build a DLL.\n\t_LT_TAGVAR(old_archive_from_new_cmds, $1)='true'\n\t# FIXME: Should let the user specify the lib program.\n\t_LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'\n\t_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes\n\t;;\n      esac\n      ;;\n\n    darwin* | rhapsody*)\n      _LT_DARWIN_LINKER_FEATURES($1)\n      ;;\n\n    dgux*)\n      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'\n      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'\n      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n      ;;\n\n    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor\n    # support.  Future versions do this automatically, but an explicit c++rt0.o\n    # does not break anything, and helps significantly (at the cost of a little\n    # extra space).\n    freebsd2.2*)\n      _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'\n      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'\n      _LT_TAGVAR(hardcode_direct, $1)=yes\n      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n      ;;\n\n    # Unfortunately, older versions of FreeBSD 2 do not have this feature.\n    freebsd2.*)\n      _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'\n      _LT_TAGVAR(hardcode_direct, $1)=yes\n      _LT_TAGVAR(hardcode_minus_L, $1)=yes\n      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n      ;;\n\n    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.\n    freebsd* | dragonfly*)\n      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'\n      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'\n      _LT_TAGVAR(hardcode_direct, $1)=yes\n      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n      ;;\n\n    hpux9*)\n      if test \"$GCC\" = yes; then\n\t_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'\n      else\n\t_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'\n      fi\n      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'\n      _LT_TAGVAR(hardcode_libdir_separator, $1)=:\n      _LT_TAGVAR(hardcode_direct, $1)=yes\n\n      # hardcode_minus_L: Not really in the search PATH,\n      # but as the default location of the library.\n      _LT_TAGVAR(hardcode_minus_L, $1)=yes\n      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'\n      ;;\n\n    hpux10*)\n      if test \"$GCC\" = yes && test \"$with_gnu_ld\" = no; then\n\t_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'\n      else\n\t_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'\n      fi\n      if test \"$with_gnu_ld\" = no; then\n\t_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'\n\t_LT_TAGVAR(hardcode_libdir_separator, $1)=:\n\t_LT_TAGVAR(hardcode_direct, $1)=yes\n\t_LT_TAGVAR(hardcode_direct_absolute, $1)=yes\n\t_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'\n\t# hardcode_minus_L: Not really in the search PATH,\n\t# but as the default location of the library.\n\t_LT_TAGVAR(hardcode_minus_L, $1)=yes\n      fi\n      ;;\n\n    hpux11*)\n      if test \"$GCC\" = yes && test \"$with_gnu_ld\" = no; then\n\tcase $host_cpu in\n\thppa*64*)\n\t  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t  ;;\n\tia64*)\n\t  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'\n\t  ;;\n\t*)\n\t  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'\n\t  ;;\n\tesac\n      else\n\tcase $host_cpu in\n\thppa*64*)\n\t  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t  ;;\n\tia64*)\n\t  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'\n\t  ;;\n\t*)\n\tm4_if($1, [], [\n\t  # Older versions of the 11.00 compiler do not understand -b yet\n\t  # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)\n\t  _LT_LINKER_OPTION([if $CC understands -b],\n\t    _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b],\n\t    [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],\n\t    [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])],\n\t  [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])\n\t  ;;\n\tesac\n      fi\n      if test \"$with_gnu_ld\" = no; then\n\t_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'\n\t_LT_TAGVAR(hardcode_libdir_separator, $1)=:\n\n\tcase $host_cpu in\n\thppa*64*|ia64*)\n\t  _LT_TAGVAR(hardcode_direct, $1)=no\n\t  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n\t  ;;\n\t*)\n\t  _LT_TAGVAR(hardcode_direct, $1)=yes\n\t  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes\n\t  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'\n\n\t  # hardcode_minus_L: Not really in the search PATH,\n\t  # but as the default location of the library.\n\t  _LT_TAGVAR(hardcode_minus_L, $1)=yes\n\t  ;;\n\tesac\n      fi\n      ;;\n\n    irix5* | irix6* | nonstopux*)\n      if test \"$GCC\" = yes; then\n\t_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n \"$verstring\" && func_echo_all \"${wl}-set_version ${wl}$verstring\"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'\n\t# Try to use the -exported_symbol ld option, if it does not\n\t# work, assume that -exports_file does not work either and\n\t# implicitly export all symbols.\n\t# This should be the same for all languages, so no per-tag cache variable.\n\tAC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol],\n\t  [lt_cv_irix_exported_symbol],\n\t  [save_LDFLAGS=\"$LDFLAGS\"\n\t   LDFLAGS=\"$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null\"\n\t   AC_LINK_IFELSE(\n\t     [AC_LANG_SOURCE(\n\t        [AC_LANG_CASE([C], [[int foo (void) { return 0; }]],\n\t\t\t      [C++], [[int foo (void) { return 0; }]],\n\t\t\t      [Fortran 77], [[\n      subroutine foo\n      end]],\n\t\t\t      [Fortran], [[\n      subroutine foo\n      end]])])],\n\t      [lt_cv_irix_exported_symbol=yes],\n\t      [lt_cv_irix_exported_symbol=no])\n           LDFLAGS=\"$save_LDFLAGS\"])\n\tif test \"$lt_cv_irix_exported_symbol\" = yes; then\n          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n \"$verstring\" && func_echo_all \"${wl}-set_version ${wl}$verstring\"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'\n\tfi\n      else\n\t_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n \"$verstring\" && func_echo_all \"-set_version $verstring\"` -update_registry ${output_objdir}/so_locations -o $lib'\n\t_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n \"$verstring\" && func_echo_all \"-set_version $verstring\"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'\n      fi\n      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'\n      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'\n      _LT_TAGVAR(hardcode_libdir_separator, $1)=:\n      _LT_TAGVAR(inherit_rpath, $1)=yes\n      _LT_TAGVAR(link_all_deplibs, $1)=yes\n      ;;\n\n    netbsd* | netbsdelf*-gnu)\n      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then\n\t_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out\n      else\n\t_LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF\n      fi\n      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'\n      _LT_TAGVAR(hardcode_direct, $1)=yes\n      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n      ;;\n\n    newsos6)\n      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'\n      _LT_TAGVAR(hardcode_direct, $1)=yes\n      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'\n      _LT_TAGVAR(hardcode_libdir_separator, $1)=:\n      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n      ;;\n\n    *nto* | *qnx*)\n      ;;\n\n    openbsd*)\n      if test -f /usr/libexec/ld.so; then\n\t_LT_TAGVAR(hardcode_direct, $1)=yes\n\t_LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n\t_LT_TAGVAR(hardcode_direct_absolute, $1)=yes\n\tif test -z \"`echo __ELF__ | $CC -E - | $GREP __ELF__`\" || test \"$host_os-$host_cpu\" = \"openbsd2.8-powerpc\"; then\n\t  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'\n\t  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'\n\t  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'\n\t  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'\n\telse\n\t  case $host_os in\n\t   openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)\n\t     _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'\n\t     _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'\n\t     ;;\n\t   *)\n\t     _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'\n\t     _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'\n\t     ;;\n\t  esac\n\tfi\n      else\n\t_LT_TAGVAR(ld_shlibs, $1)=no\n      fi\n      ;;\n\n    os2*)\n      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'\n      _LT_TAGVAR(hardcode_minus_L, $1)=yes\n      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported\n      _LT_TAGVAR(archive_cmds, $1)='$ECHO \"LIBRARY $libname INITINSTANCE\" > $output_objdir/$libname.def~$ECHO \"DESCRIPTION \\\"$libname\\\"\" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo \" SINGLE NONSHARED\" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'\n      _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'\n      ;;\n\n    osf3*)\n      if test \"$GCC\" = yes; then\n\t_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\\*'\n\t_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n \"$verstring\" && func_echo_all \"${wl}-set_version ${wl}$verstring\"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'\n      else\n\t_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \\*'\n\t_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n \"$verstring\" && func_echo_all \"-set_version $verstring\"` -update_registry ${output_objdir}/so_locations -o $lib'\n      fi\n      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'\n      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'\n      _LT_TAGVAR(hardcode_libdir_separator, $1)=:\n      ;;\n\n    osf4* | osf5*)\t# as osf3* with the addition of -msym flag\n      if test \"$GCC\" = yes; then\n\t_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\\*'\n\t_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n \"$verstring\" && func_echo_all \"${wl}-set_version ${wl}$verstring\"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'\n\t_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'\n      else\n\t_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \\*'\n\t_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n \"$verstring\" && func_echo_all \"-set_version $verstring\"` -update_registry ${output_objdir}/so_locations -o $lib'\n\t_LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf \"%s %s\\\\n\" -exported_symbol \"\\$i\" >> $lib.exp; done; printf \"%s\\\\n\" \"-hidden\">> $lib.exp~\n\t$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n \"$verstring\" && $ECHO \"-set_version $verstring\"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'\n\n\t# Both c and cxx compiler support -rpath directly\n\t_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'\n      fi\n      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'\n      _LT_TAGVAR(hardcode_libdir_separator, $1)=:\n      ;;\n\n    solaris*)\n      _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'\n      if test \"$GCC\" = yes; then\n\twlarc='${wl}'\n\t_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t_LT_TAGVAR(archive_expsym_cmds, $1)='echo \"{ global:\" > $lib.exp~cat $export_symbols | $SED -e \"s/\\(.*\\)/\\1;/\" >> $lib.exp~echo \"local: *; };\" >> $lib.exp~\n\t  $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'\n      else\n\tcase `$CC -V 2>&1` in\n\t*\"Compilers 5.0\"*)\n\t  wlarc=''\n\t  _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'\n\t  _LT_TAGVAR(archive_expsym_cmds, $1)='echo \"{ global:\" > $lib.exp~cat $export_symbols | $SED -e \"s/\\(.*\\)/\\1;/\" >> $lib.exp~echo \"local: *; };\" >> $lib.exp~\n\t  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'\n\t  ;;\n\t*)\n\t  wlarc='${wl}'\n\t  _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'\n\t  _LT_TAGVAR(archive_expsym_cmds, $1)='echo \"{ global:\" > $lib.exp~cat $export_symbols | $SED -e \"s/\\(.*\\)/\\1;/\" >> $lib.exp~echo \"local: *; };\" >> $lib.exp~\n\t  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'\n\t  ;;\n\tesac\n      fi\n      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'\n      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n      case $host_os in\n      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;\n      *)\n\t# The compiler driver will combine and reorder linker options,\n\t# but understands `-z linker_flag'.  GCC discards it without `$wl',\n\t# but is careful enough not to reorder.\n\t# Supported since Solaris 2.6 (maybe 2.5.1?)\n\tif test \"$GCC\" = yes; then\n\t  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'\n\telse\n\t  _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'\n\tfi\n\t;;\n      esac\n      _LT_TAGVAR(link_all_deplibs, $1)=yes\n      ;;\n\n    sunos4*)\n      if test \"x$host_vendor\" = xsequent; then\n\t# Use $CC to link under sequent, because it throws in some extra .o\n\t# files that make .init and .fini sections work.\n\t_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'\n      else\n\t_LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'\n      fi\n      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'\n      _LT_TAGVAR(hardcode_direct, $1)=yes\n      _LT_TAGVAR(hardcode_minus_L, $1)=yes\n      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n      ;;\n\n    sysv4)\n      case $host_vendor in\n\tsni)\n\t  _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'\n\t  _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true???\n\t;;\n\tsiemens)\n\t  ## LD is ld it makes a PLAMLIB\n\t  ## CC just makes a GrossModule.\n\t  _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'\n\t  _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'\n\t  _LT_TAGVAR(hardcode_direct, $1)=no\n        ;;\n\tmotorola)\n\t  _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'\n\t  _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie\n\t;;\n      esac\n      runpath_var='LD_RUN_PATH'\n      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n      ;;\n\n    sysv4.3*)\n      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'\n      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n      _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'\n      ;;\n\n    sysv4*MP*)\n      if test -d /usr/nec; then\n\t_LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'\n\t_LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n\trunpath_var=LD_RUN_PATH\n\thardcode_runpath_var=yes\n\t_LT_TAGVAR(ld_shlibs, $1)=yes\n      fi\n      ;;\n\n    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)\n      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'\n      _LT_TAGVAR(archive_cmds_need_lc, $1)=no\n      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n      runpath_var='LD_RUN_PATH'\n\n      if test \"$GCC\" = yes; then\n\t_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n      else\n\t_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n      fi\n      ;;\n\n    sysv5* | sco3.2v5* | sco5v6*)\n      # Note: We can NOT use -z defs as we might desire, because we do not\n      # link with -lc, and that would cause any symbols used from libc to\n      # always be unresolved, which means just about no library would\n      # ever link correctly.  If we're not using GNU ld we use -z text\n      # though, which does catch some bad symbols but isn't as heavy-handed\n      # as -z defs.\n      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'\n      _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'\n      _LT_TAGVAR(archive_cmds_need_lc, $1)=no\n      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'\n      _LT_TAGVAR(hardcode_libdir_separator, $1)=':'\n      _LT_TAGVAR(link_all_deplibs, $1)=yes\n      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'\n      runpath_var='LD_RUN_PATH'\n\n      if test \"$GCC\" = yes; then\n\t_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n      else\n\t_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n      fi\n      ;;\n\n    uts4*)\n      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'\n      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'\n      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n      ;;\n\n    *)\n      _LT_TAGVAR(ld_shlibs, $1)=no\n      ;;\n    esac\n\n    if test x$host_vendor = xsni; then\n      case $host in\n      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)\n\t_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'\n\t;;\n      esac\n    fi\n  fi\n])\nAC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])\ntest \"$_LT_TAGVAR(ld_shlibs, $1)\" = no && can_build_shared=no\n\n_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld\n\n_LT_DECL([], [libext], [0], [Old archive suffix (normally \"a\")])dnl\n_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally \".so\")])dnl\n_LT_DECL([], [extract_expsyms_cmds], [2],\n    [The commands to extract the exported symbol list from a shared archive])\n\n#\n# Do we need to explicitly link libc?\n#\ncase \"x$_LT_TAGVAR(archive_cmds_need_lc, $1)\" in\nx|xyes)\n  # Assume -lc should be added\n  _LT_TAGVAR(archive_cmds_need_lc, $1)=yes\n\n  if test \"$enable_shared\" = yes && test \"$GCC\" = yes; then\n    case $_LT_TAGVAR(archive_cmds, $1) in\n    *'~'*)\n      # FIXME: we may have to deal with multi-command sequences.\n      ;;\n    '$CC '*)\n      # Test whether the compiler implicitly links with -lc since on some\n      # systems, -lgcc has to come before -lc. If gcc already passes -lc\n      # to ld, don't add -lc before -lgcc.\n      AC_CACHE_CHECK([whether -lc should be explicitly linked in],\n\t[lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1),\n\t[$RM conftest*\n\techo \"$lt_simple_compile_test_code\" > conftest.$ac_ext\n\n\tif AC_TRY_EVAL(ac_compile) 2>conftest.err; then\n\t  soname=conftest\n\t  lib=conftest\n\t  libobjs=conftest.$ac_objext\n\t  deplibs=\n\t  wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1)\n\t  pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)\n\t  compiler_flags=-v\n\t  linker_flags=-v\n\t  verstring=\n\t  output_objdir=.\n\t  libname=conftest\n\t  lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)\n\t  _LT_TAGVAR(allow_undefined_flag, $1)=\n\t  if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\\>\\&1 \\| $GREP \\\" -lc \\\" \\>/dev/null 2\\>\\&1)\n\t  then\n\t    lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no\n\t  else\n\t    lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes\n\t  fi\n\t  _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag\n\telse\n\t  cat conftest.err 1>&5\n\tfi\n\t$RM conftest*\n\t])\n      _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)\n      ;;\n    esac\n  fi\n  ;;\nesac\n\n_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0],\n    [Whether or not to add -lc for building shared libraries])\n_LT_TAGDECL([allow_libtool_libs_with_static_runtimes],\n    [enable_shared_with_static_runtimes], [0],\n    [Whether or not to disallow shared libs when runtime libs are static])\n_LT_TAGDECL([], [export_dynamic_flag_spec], [1],\n    [Compiler flag to allow reflexive dlopens])\n_LT_TAGDECL([], [whole_archive_flag_spec], [1],\n    [Compiler flag to generate shared objects directly from archives])\n_LT_TAGDECL([], [compiler_needs_object], [1],\n    [Whether the compiler copes with passing no objects directly])\n_LT_TAGDECL([], [old_archive_from_new_cmds], [2],\n    [Create an old-style archive from a shared archive])\n_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2],\n    [Create a temporary old-style archive to link instead of a shared archive])\n_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive])\n_LT_TAGDECL([], [archive_expsym_cmds], [2])\n_LT_TAGDECL([], [module_cmds], [2],\n    [Commands used to build a loadable module if different from building\n    a shared archive.])\n_LT_TAGDECL([], [module_expsym_cmds], [2])\n_LT_TAGDECL([], [with_gnu_ld], [1],\n    [Whether we are building with GNU ld or not])\n_LT_TAGDECL([], [allow_undefined_flag], [1],\n    [Flag that allows shared libraries with undefined symbols to be built])\n_LT_TAGDECL([], [no_undefined_flag], [1],\n    [Flag that enforces no undefined symbols])\n_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],\n    [Flag to hardcode $libdir into a binary during linking.\n    This must work even if $libdir does not exist])\n_LT_TAGDECL([], [hardcode_libdir_separator], [1],\n    [Whether we need a single \"-rpath\" flag with a separated argument])\n_LT_TAGDECL([], [hardcode_direct], [0],\n    [Set to \"yes\" if using DIR/libNAME${shared_ext} during linking hardcodes\n    DIR into the resulting binary])\n_LT_TAGDECL([], [hardcode_direct_absolute], [0],\n    [Set to \"yes\" if using DIR/libNAME${shared_ext} during linking hardcodes\n    DIR into the resulting binary and the resulting library dependency is\n    \"absolute\", i.e impossible to change by setting ${shlibpath_var} if the\n    library is relocated])\n_LT_TAGDECL([], [hardcode_minus_L], [0],\n    [Set to \"yes\" if using the -LDIR flag during linking hardcodes DIR\n    into the resulting binary])\n_LT_TAGDECL([], [hardcode_shlibpath_var], [0],\n    [Set to \"yes\" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR\n    into the resulting binary])\n_LT_TAGDECL([], [hardcode_automatic], [0],\n    [Set to \"yes\" if building a shared library automatically hardcodes DIR\n    into the library and all subsequent libraries and executables linked\n    against it])\n_LT_TAGDECL([], [inherit_rpath], [0],\n    [Set to yes if linker adds runtime paths of dependent libraries\n    to runtime path list])\n_LT_TAGDECL([], [link_all_deplibs], [0],\n    [Whether libtool must link a program against all its dependency libraries])\n_LT_TAGDECL([], [always_export_symbols], [0],\n    [Set to \"yes\" if exported symbols are required])\n_LT_TAGDECL([], [export_symbols_cmds], [2],\n    [The commands to list exported symbols])\n_LT_TAGDECL([], [exclude_expsyms], [1],\n    [Symbols that should not be listed in the preloaded symbols])\n_LT_TAGDECL([], [include_expsyms], [1],\n    [Symbols that must always be exported])\n_LT_TAGDECL([], [prelink_cmds], [2],\n    [Commands necessary for linking programs (against libraries) with templates])\n_LT_TAGDECL([], [postlink_cmds], [2],\n    [Commands necessary for finishing linking programs])\n_LT_TAGDECL([], [file_list_spec], [1],\n    [Specify filename containing input files])\ndnl FIXME: Not yet implemented\ndnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],\ndnl    [Compiler flag to generate thread safe objects])\n])# _LT_LINKER_SHLIBS\n\n\n# _LT_LANG_C_CONFIG([TAG])\n# ------------------------\n# Ensure that the configuration variables for a C compiler are suitably\n# defined.  These variables are subsequently used by _LT_CONFIG to write\n# the compiler configuration to `libtool'.\nm4_defun([_LT_LANG_C_CONFIG],\n[m4_require([_LT_DECL_EGREP])dnl\nlt_save_CC=\"$CC\"\nAC_LANG_PUSH(C)\n\n# Source file extension for C test sources.\nac_ext=c\n\n# Object file extension for compiled C test sources.\nobjext=o\n_LT_TAGVAR(objext, $1)=$objext\n\n# Code to be used in simple compile tests\nlt_simple_compile_test_code=\"int some_variable = 0;\"\n\n# Code to be used in simple link tests\nlt_simple_link_test_code='int main(){return(0);}'\n\n_LT_TAG_COMPILER\n# Save the default compiler, since it gets overwritten when the other\n# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.\ncompiler_DEFAULT=$CC\n\n# save warnings/boilerplate of simple test code\n_LT_COMPILER_BOILERPLATE\n_LT_LINKER_BOILERPLATE\n\n## CAVEAT EMPTOR:\n## There is no encapsulation within the following macros, do not change\n## the running order or otherwise move them around unless you know exactly\n## what you are doing...\nif test -n \"$compiler\"; then\n  _LT_COMPILER_NO_RTTI($1)\n  _LT_COMPILER_PIC($1)\n  _LT_COMPILER_C_O($1)\n  _LT_COMPILER_FILE_LOCKS($1)\n  _LT_LINKER_SHLIBS($1)\n  _LT_SYS_DYNAMIC_LINKER($1)\n  _LT_LINKER_HARDCODE_LIBPATH($1)\n  LT_SYS_DLOPEN_SELF\n  _LT_CMD_STRIPLIB\n\n  # Report which library types will actually be built\n  AC_MSG_CHECKING([if libtool supports shared libraries])\n  AC_MSG_RESULT([$can_build_shared])\n\n  AC_MSG_CHECKING([whether to build shared libraries])\n  test \"$can_build_shared\" = \"no\" && enable_shared=no\n\n  # On AIX, shared libraries and static libraries use the same namespace, and\n  # are all built from PIC.\n  case $host_os in\n  aix3*)\n    test \"$enable_shared\" = yes && enable_static=no\n    if test -n \"$RANLIB\"; then\n      archive_cmds=\"$archive_cmds~\\$RANLIB \\$lib\"\n      postinstall_cmds='$RANLIB $lib'\n    fi\n    ;;\n\n  aix[[4-9]]*)\n    if test \"$host_cpu\" != ia64 && test \"$aix_use_runtimelinking\" = no ; then\n      test \"$enable_shared\" = yes && enable_static=no\n    fi\n    ;;\n  esac\n  AC_MSG_RESULT([$enable_shared])\n\n  AC_MSG_CHECKING([whether to build static libraries])\n  # Make sure either enable_shared or enable_static is yes.\n  test \"$enable_shared\" = yes || enable_static=yes\n  AC_MSG_RESULT([$enable_static])\n\n  _LT_CONFIG($1)\nfi\nAC_LANG_POP\nCC=\"$lt_save_CC\"\n])# _LT_LANG_C_CONFIG\n\n\n# _LT_LANG_CXX_CONFIG([TAG])\n# --------------------------\n# Ensure that the configuration variables for a C++ compiler are suitably\n# defined.  These variables are subsequently used by _LT_CONFIG to write\n# the compiler configuration to `libtool'.\nm4_defun([_LT_LANG_CXX_CONFIG],\n[m4_require([_LT_FILEUTILS_DEFAULTS])dnl\nm4_require([_LT_DECL_EGREP])dnl\nm4_require([_LT_PATH_MANIFEST_TOOL])dnl\nif test -n \"$CXX\" && ( test \"X$CXX\" != \"Xno\" &&\n    ( (test \"X$CXX\" = \"Xg++\" && `g++ -v >/dev/null 2>&1` ) ||\n    (test \"X$CXX\" != \"Xg++\"))) ; then\n  AC_PROG_CXXCPP\nelse\n  _lt_caught_CXX_error=yes\nfi\n\nAC_LANG_PUSH(C++)\n_LT_TAGVAR(archive_cmds_need_lc, $1)=no\n_LT_TAGVAR(allow_undefined_flag, $1)=\n_LT_TAGVAR(always_export_symbols, $1)=no\n_LT_TAGVAR(archive_expsym_cmds, $1)=\n_LT_TAGVAR(compiler_needs_object, $1)=no\n_LT_TAGVAR(export_dynamic_flag_spec, $1)=\n_LT_TAGVAR(hardcode_direct, $1)=no\n_LT_TAGVAR(hardcode_direct_absolute, $1)=no\n_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=\n_LT_TAGVAR(hardcode_libdir_separator, $1)=\n_LT_TAGVAR(hardcode_minus_L, $1)=no\n_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported\n_LT_TAGVAR(hardcode_automatic, $1)=no\n_LT_TAGVAR(inherit_rpath, $1)=no\n_LT_TAGVAR(module_cmds, $1)=\n_LT_TAGVAR(module_expsym_cmds, $1)=\n_LT_TAGVAR(link_all_deplibs, $1)=unknown\n_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds\n_LT_TAGVAR(reload_flag, $1)=$reload_flag\n_LT_TAGVAR(reload_cmds, $1)=$reload_cmds\n_LT_TAGVAR(no_undefined_flag, $1)=\n_LT_TAGVAR(whole_archive_flag_spec, $1)=\n_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no\n\n# Source file extension for C++ test sources.\nac_ext=cpp\n\n# Object file extension for compiled C++ test sources.\nobjext=o\n_LT_TAGVAR(objext, $1)=$objext\n\n# No sense in running all these tests if we already determined that\n# the CXX compiler isn't working.  Some variables (like enable_shared)\n# are currently assumed to apply to all compilers on this platform,\n# and will be corrupted by setting them based on a non-working compiler.\nif test \"$_lt_caught_CXX_error\" != yes; then\n  # Code to be used in simple compile tests\n  lt_simple_compile_test_code=\"int some_variable = 0;\"\n\n  # Code to be used in simple link tests\n  lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'\n\n  # ltmain only uses $CC for tagged configurations so make sure $CC is set.\n  _LT_TAG_COMPILER\n\n  # save warnings/boilerplate of simple test code\n  _LT_COMPILER_BOILERPLATE\n  _LT_LINKER_BOILERPLATE\n\n  # Allow CC to be a program name with arguments.\n  lt_save_CC=$CC\n  lt_save_CFLAGS=$CFLAGS\n  lt_save_LD=$LD\n  lt_save_GCC=$GCC\n  GCC=$GXX\n  lt_save_with_gnu_ld=$with_gnu_ld\n  lt_save_path_LD=$lt_cv_path_LD\n  if test -n \"${lt_cv_prog_gnu_ldcxx+set}\"; then\n    lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx\n  else\n    $as_unset lt_cv_prog_gnu_ld\n  fi\n  if test -n \"${lt_cv_path_LDCXX+set}\"; then\n    lt_cv_path_LD=$lt_cv_path_LDCXX\n  else\n    $as_unset lt_cv_path_LD\n  fi\n  test -z \"${LDCXX+set}\" || LD=$LDCXX\n  CC=${CXX-\"c++\"}\n  CFLAGS=$CXXFLAGS\n  compiler=$CC\n  _LT_TAGVAR(compiler, $1)=$CC\n  _LT_CC_BASENAME([$compiler])\n\n  if test -n \"$compiler\"; then\n    # We don't want -fno-exception when compiling C++ code, so set the\n    # no_builtin_flag separately\n    if test \"$GXX\" = yes; then\n      _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'\n    else\n      _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=\n    fi\n\n    if test \"$GXX\" = yes; then\n      # Set up default GNU C++ configuration\n\n      LT_PATH_LD\n\n      # Check if GNU C++ uses GNU ld as the underlying linker, since the\n      # archiving commands below assume that GNU ld is being used.\n      if test \"$with_gnu_ld\" = yes; then\n        _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'\n        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'\n\n        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'\n        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'\n\n        # If archive_cmds runs LD, not CC, wlarc should be empty\n        # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to\n        #     investigate it a little bit more. (MM)\n        wlarc='${wl}'\n\n        # ancient GNU ld didn't support --whole-archive et. al.\n        if eval \"`$CC -print-prog-name=ld` --help 2>&1\" |\n\t  $GREP 'no-whole-archive' > /dev/null; then\n          _LT_TAGVAR(whole_archive_flag_spec, $1)=\"$wlarc\"'--whole-archive$convenience '\"$wlarc\"'--no-whole-archive'\n        else\n          _LT_TAGVAR(whole_archive_flag_spec, $1)=\n        fi\n      else\n        with_gnu_ld=no\n        wlarc=\n\n        # A generic and very simple default shared library creation\n        # command for GNU C++ for the case where it uses the native\n        # linker, instead of GNU ld.  If possible, this setting should\n        # overridden to take advantage of the native linker features on\n        # the platform it is being used on.\n        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'\n      fi\n\n      # Commands to make compiler produce verbose output that lists\n      # what \"hidden\" libraries, object files and flags are used when\n      # linking a shared library.\n      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v \"^Configured with:\" | $GREP \"\\-L\"'\n\n    else\n      GXX=no\n      with_gnu_ld=no\n      wlarc=\n    fi\n\n    # PORTME: fill in a description of your system's C++ link characteristics\n    AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])\n    _LT_TAGVAR(ld_shlibs, $1)=yes\n    case $host_os in\n      aix3*)\n        # FIXME: insert proper C++ library support\n        _LT_TAGVAR(ld_shlibs, $1)=no\n        ;;\n      aix[[4-9]]*)\n        if test \"$host_cpu\" = ia64; then\n          # On IA64, the linker does run time linking by default, so we don't\n          # have to do anything special.\n          aix_use_runtimelinking=no\n          exp_sym_flag='-Bexport'\n          no_entry_flag=\"\"\n        else\n          aix_use_runtimelinking=no\n\n          # Test if we are trying to use run time linking or normal\n          # AIX style linking. If -brtl is somewhere in LDFLAGS, we\n          # need to do runtime linking.\n          case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)\n\t    for ld_flag in $LDFLAGS; do\n\t      case $ld_flag in\n\t      *-brtl*)\n\t        aix_use_runtimelinking=yes\n\t        break\n\t        ;;\n\t      esac\n\t    done\n\t    ;;\n          esac\n\n          exp_sym_flag='-bexport'\n          no_entry_flag='-bnoentry'\n        fi\n\n        # When large executables or shared objects are built, AIX ld can\n        # have problems creating the table of contents.  If linking a library\n        # or program results in \"error TOC overflow\" add -mminimal-toc to\n        # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not\n        # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.\n\n        _LT_TAGVAR(archive_cmds, $1)=''\n        _LT_TAGVAR(hardcode_direct, $1)=yes\n        _LT_TAGVAR(hardcode_direct_absolute, $1)=yes\n        _LT_TAGVAR(hardcode_libdir_separator, $1)=':'\n        _LT_TAGVAR(link_all_deplibs, $1)=yes\n        _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'\n\n        if test \"$GXX\" = yes; then\n          case $host_os in aix4.[[012]]|aix4.[[012]].*)\n          # We only want to do this on AIX 4.2 and lower, the check\n          # below for broken collect2 doesn't work under 4.3+\n\t  collect2name=`${CC} -print-prog-name=collect2`\n\t  if test -f \"$collect2name\" &&\n\t     strings \"$collect2name\" | $GREP resolve_lib_name >/dev/null\n\t  then\n\t    # We have reworked collect2\n\t    :\n\t  else\n\t    # We have old collect2\n\t    _LT_TAGVAR(hardcode_direct, $1)=unsupported\n\t    # It fails to find uninstalled libraries when the uninstalled\n\t    # path is not listed in the libpath.  Setting hardcode_minus_L\n\t    # to unsupported forces relinking\n\t    _LT_TAGVAR(hardcode_minus_L, $1)=yes\n\t    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'\n\t    _LT_TAGVAR(hardcode_libdir_separator, $1)=\n\t  fi\n          esac\n          shared_flag='-shared'\n\t  if test \"$aix_use_runtimelinking\" = yes; then\n\t    shared_flag=\"$shared_flag \"'${wl}-G'\n\t  fi\n        else\n          # not using gcc\n          if test \"$host_cpu\" = ia64; then\n\t  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release\n\t  # chokes on -Wl,-G. The following line is correct:\n\t  shared_flag='-G'\n          else\n\t    if test \"$aix_use_runtimelinking\" = yes; then\n\t      shared_flag='${wl}-G'\n\t    else\n\t      shared_flag='${wl}-bM:SRE'\n\t    fi\n          fi\n        fi\n\n        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'\n        # It seems that -bexpall does not export symbols beginning with\n        # underscore (_), so it is better to generate a list of symbols to\n\t# export.\n        _LT_TAGVAR(always_export_symbols, $1)=yes\n        if test \"$aix_use_runtimelinking\" = yes; then\n          # Warning - without using the other runtime loading flags (-brtl),\n          # -berok will link without error, but may produce a broken library.\n          _LT_TAGVAR(allow_undefined_flag, $1)='-berok'\n          # Determine the default libpath from the value encoded in an empty\n          # executable.\n          _LT_SYS_MODULE_PATH_AIX([$1])\n          _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'\"$aix_libpath\"\n\n          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '\"\\${wl}$no_entry_flag\"' $compiler_flags `if test \"x${allow_undefined_flag}\" != \"x\"; then func_echo_all \"${wl}${allow_undefined_flag}\"; else :; fi` '\"\\${wl}$exp_sym_flag:\\$export_symbols $shared_flag\"\n        else\n          if test \"$host_cpu\" = ia64; then\n\t    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'\n\t    _LT_TAGVAR(allow_undefined_flag, $1)=\"-z nodefs\"\n\t    _LT_TAGVAR(archive_expsym_cmds, $1)=\"\\$CC $shared_flag\"' -o $output_objdir/$soname $libobjs $deplibs '\"\\${wl}$no_entry_flag\"' $compiler_flags ${wl}${allow_undefined_flag} '\"\\${wl}$exp_sym_flag:\\$export_symbols\"\n          else\n\t    # Determine the default libpath from the value encoded in an\n\t    # empty executable.\n\t    _LT_SYS_MODULE_PATH_AIX([$1])\n\t    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'\"$aix_libpath\"\n\t    # Warning - without using the other run time loading flags,\n\t    # -berok will link without error, but may produce a broken library.\n\t    _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'\n\t    _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'\n\t    if test \"$with_gnu_ld\" = yes; then\n\t      # We only use this code for GNU lds that support --whole-archive.\n\t      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'\n\t    else\n\t      # Exported symbols can be pulled into shared objects from archives\n\t      _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'\n\t    fi\n\t    _LT_TAGVAR(archive_cmds_need_lc, $1)=yes\n\t    # This is similar to how AIX traditionally builds its shared\n\t    # libraries.\n\t    _LT_TAGVAR(archive_expsym_cmds, $1)=\"\\$CC $shared_flag\"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'\n          fi\n        fi\n        ;;\n\n      beos*)\n\tif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then\n\t  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported\n\t  # Joseph Beckenbach <jrb3@best.com> says some releases of gcc\n\t  # support --undefined.  This deserves some investigation.  FIXME\n\t  _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n\telse\n\t  _LT_TAGVAR(ld_shlibs, $1)=no\n\tfi\n\t;;\n\n      chorus*)\n        case $cc_basename in\n          *)\n\t  # FIXME: insert proper C++ library support\n\t  _LT_TAGVAR(ld_shlibs, $1)=no\n\t  ;;\n        esac\n        ;;\n\n      cygwin* | mingw* | pw32* | cegcc*)\n\tcase $GXX,$cc_basename in\n\t,cl* | no,cl*)\n\t  # Native MSVC\n\t  # hardcode_libdir_flag_spec is actually meaningless, as there is\n\t  # no search path for DLLs.\n\t  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '\n\t  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported\n\t  _LT_TAGVAR(always_export_symbols, $1)=yes\n\t  _LT_TAGVAR(file_list_spec, $1)='@'\n\t  # Tell ltmain to make .lib files, not .a files.\n\t  libext=lib\n\t  # Tell ltmain to make .dll files, not .so files.\n\t  shrext_cmds=\".dll\"\n\t  # FIXME: Setting linknames here is a bad hack.\n\t  _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='\n\t  _LT_TAGVAR(archive_expsym_cmds, $1)='if test \"x`$SED 1q $export_symbols`\" = xEXPORTS; then\n\t      $SED -n -e 's/\\\\\\\\\\\\\\(.*\\\\\\\\\\\\\\)/-link\\\\\\ -EXPORT:\\\\\\\\\\\\\\1/' -e '1\\\\\\!p' < $export_symbols > $output_objdir/$soname.exp;\n\t    else\n\t      $SED -e 's/\\\\\\\\\\\\\\(.*\\\\\\\\\\\\\\)/-link\\\\\\ -EXPORT:\\\\\\\\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;\n\t    fi~\n\t    $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs \"@$tool_output_objdir$soname.exp\" -Wl,-DLL,-IMPLIB:\"$tool_output_objdir$libname.dll.lib\"~\n\t    linknames='\n\t  # The linker will not automatically build a static lib if we build a DLL.\n\t  # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'\n\t  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes\n\t  # Don't use ranlib\n\t  _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'\n\t  _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile=\"@OUTPUT@\"~\n\t    lt_tool_outputfile=\"@TOOL_OUTPUT@\"~\n\t    case $lt_outputfile in\n\t      *.exe|*.EXE) ;;\n\t      *)\n\t\tlt_outputfile=\"$lt_outputfile.exe\"\n\t\tlt_tool_outputfile=\"$lt_tool_outputfile.exe\"\n\t\t;;\n\t    esac~\n\t    func_to_tool_file \"$lt_outputfile\"~\n\t    if test \"$MANIFEST_TOOL\" != \":\" && test -f \"$lt_outputfile.manifest\"; then\n\t      $MANIFEST_TOOL -manifest \"$lt_tool_outputfile.manifest\" -outputresource:\"$lt_tool_outputfile\" || exit 1;\n\t      $RM \"$lt_outputfile.manifest\";\n\t    fi'\n\t  ;;\n\t*)\n\t  # g++\n\t  # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,\n\t  # as there is no search path for DLLs.\n\t  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'\n\t  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'\n\t  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported\n\t  _LT_TAGVAR(always_export_symbols, $1)=no\n\t  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes\n\n\t  if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then\n\t    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'\n\t    # If the export-symbols file already is a .def file (1st line\n\t    # is EXPORTS), use it as is; otherwise, prepend...\n\t    _LT_TAGVAR(archive_expsym_cmds, $1)='if test \"x`$SED 1q $export_symbols`\" = xEXPORTS; then\n\t      cp $export_symbols $output_objdir/$soname.def;\n\t    else\n\t      echo EXPORTS > $output_objdir/$soname.def;\n\t      cat $export_symbols >> $output_objdir/$soname.def;\n\t    fi~\n\t    $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'\n\t  else\n\t    _LT_TAGVAR(ld_shlibs, $1)=no\n\t  fi\n\t  ;;\n\tesac\n\t;;\n      darwin* | rhapsody*)\n        _LT_DARWIN_LINKER_FEATURES($1)\n\t;;\n\n      dgux*)\n        case $cc_basename in\n          ec++*)\n\t    # FIXME: insert proper C++ library support\n\t    _LT_TAGVAR(ld_shlibs, $1)=no\n\t    ;;\n          ghcx*)\n\t    # Green Hills C++ Compiler\n\t    # FIXME: insert proper C++ library support\n\t    _LT_TAGVAR(ld_shlibs, $1)=no\n\t    ;;\n          *)\n\t    # FIXME: insert proper C++ library support\n\t    _LT_TAGVAR(ld_shlibs, $1)=no\n\t    ;;\n        esac\n        ;;\n\n      freebsd2.*)\n        # C++ shared libraries reported to be fairly broken before\n\t# switch to ELF\n        _LT_TAGVAR(ld_shlibs, $1)=no\n        ;;\n\n      freebsd-elf*)\n        _LT_TAGVAR(archive_cmds_need_lc, $1)=no\n        ;;\n\n      freebsd* | dragonfly*)\n        # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF\n        # conventions\n        _LT_TAGVAR(ld_shlibs, $1)=yes\n        ;;\n\n      haiku*)\n        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n        _LT_TAGVAR(link_all_deplibs, $1)=yes\n        ;;\n\n      hpux9*)\n        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'\n        _LT_TAGVAR(hardcode_libdir_separator, $1)=:\n        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'\n        _LT_TAGVAR(hardcode_direct, $1)=yes\n        _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,\n\t\t\t\t             # but as the default\n\t\t\t\t             # location of the library.\n\n        case $cc_basename in\n          CC*)\n            # FIXME: insert proper C++ library support\n            _LT_TAGVAR(ld_shlibs, $1)=no\n            ;;\n          aCC*)\n            _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'\n            # Commands to make compiler produce verbose output that lists\n            # what \"hidden\" libraries, object files and flags are used when\n            # linking a shared library.\n            #\n            # There doesn't appear to be a way to prevent this compiler from\n            # explicitly linking system object files so we need to strip them\n            # from the output so that they don't get included in the library\n            # dependencies.\n            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP \"\\-L\"`; list=\"\"; for z in $templist; do case $z in conftest.$objext) list=\"$list $z\";; *.$objext);; *) list=\"$list $z\";;esac; done; func_echo_all \"$list\"'\n            ;;\n          *)\n            if test \"$GXX\" = yes; then\n              _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'\n            else\n              # FIXME: insert proper C++ library support\n              _LT_TAGVAR(ld_shlibs, $1)=no\n            fi\n            ;;\n        esac\n        ;;\n\n      hpux10*|hpux11*)\n        if test $with_gnu_ld = no; then\n\t  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'\n\t  _LT_TAGVAR(hardcode_libdir_separator, $1)=:\n\n          case $host_cpu in\n            hppa*64*|ia64*)\n              ;;\n            *)\n\t      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'\n              ;;\n          esac\n        fi\n        case $host_cpu in\n          hppa*64*|ia64*)\n            _LT_TAGVAR(hardcode_direct, $1)=no\n            _LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n            ;;\n          *)\n            _LT_TAGVAR(hardcode_direct, $1)=yes\n            _LT_TAGVAR(hardcode_direct_absolute, $1)=yes\n            _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,\n\t\t\t\t\t         # but as the default\n\t\t\t\t\t         # location of the library.\n            ;;\n        esac\n\n        case $cc_basename in\n          CC*)\n\t    # FIXME: insert proper C++ library support\n\t    _LT_TAGVAR(ld_shlibs, $1)=no\n\t    ;;\n          aCC*)\n\t    case $host_cpu in\n\t      hppa*64*)\n\t        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'\n\t        ;;\n\t      ia64*)\n\t        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'\n\t        ;;\n\t      *)\n\t        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'\n\t        ;;\n\t    esac\n\t    # Commands to make compiler produce verbose output that lists\n\t    # what \"hidden\" libraries, object files and flags are used when\n\t    # linking a shared library.\n\t    #\n\t    # There doesn't appear to be a way to prevent this compiler from\n\t    # explicitly linking system object files so we need to strip them\n\t    # from the output so that they don't get included in the library\n\t    # dependencies.\n\t    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP \"\\-L\"`; list=\"\"; for z in $templist; do case $z in conftest.$objext) list=\"$list $z\";; *.$objext);; *) list=\"$list $z\";;esac; done; func_echo_all \"$list\"'\n\t    ;;\n          *)\n\t    if test \"$GXX\" = yes; then\n\t      if test $with_gnu_ld = no; then\n\t        case $host_cpu in\n\t          hppa*64*)\n\t            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'\n\t            ;;\n\t          ia64*)\n\t            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'\n\t            ;;\n\t          *)\n\t            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'\n\t            ;;\n\t        esac\n\t      fi\n\t    else\n\t      # FIXME: insert proper C++ library support\n\t      _LT_TAGVAR(ld_shlibs, $1)=no\n\t    fi\n\t    ;;\n        esac\n        ;;\n\n      interix[[3-9]]*)\n\t_LT_TAGVAR(hardcode_direct, $1)=no\n\t_LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n\t_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'\n\t_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'\n\t# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.\n\t# Instead, shared libraries are loaded at an image base (0x10000000 by\n\t# default) and relocated if they conflict, which is a slow very memory\n\t# consuming and fragmenting process.  To avoid this, we pick a random,\n\t# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link\n\t# time.  Moving up from 0x10000000 also allows more sbrk(2) space.\n\t_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \\* 262144 + 1342177280` -o $lib'\n\t_LT_TAGVAR(archive_expsym_cmds, $1)='sed \"s,^,_,\" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \\* 262144 + 1342177280` -o $lib'\n\t;;\n      irix5* | irix6*)\n        case $cc_basename in\n          CC*)\n\t    # SGI C++\n\t    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n \"$verstring\" && func_echo_all \"-set_version $verstring\"` -update_registry ${output_objdir}/so_locations -o $lib'\n\n\t    # Archives containing C++ object files must be created using\n\t    # \"CC -ar\", where \"CC\" is the IRIX C++ compiler.  This is\n\t    # necessary to make sure instantiated templates are included\n\t    # in the archive.\n\t    _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'\n\t    ;;\n          *)\n\t    if test \"$GXX\" = yes; then\n\t      if test \"$with_gnu_ld\" = no; then\n\t        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n \"$verstring\" && func_echo_all \"${wl}-set_version ${wl}$verstring\"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'\n\t      else\n\t        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n \"$verstring\" && func_echo_all \"${wl}-set_version ${wl}$verstring\"` -o $lib'\n\t      fi\n\t    fi\n\t    _LT_TAGVAR(link_all_deplibs, $1)=yes\n\t    ;;\n        esac\n        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'\n        _LT_TAGVAR(hardcode_libdir_separator, $1)=:\n        _LT_TAGVAR(inherit_rpath, $1)=yes\n        ;;\n\n      linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)\n        case $cc_basename in\n          KCC*)\n\t    # Kuck and Associates, Inc. (KAI) C++ Compiler\n\n\t    # KCC will only create a shared library if the output file\n\t    # ends with \".so\" (or \".sl\" for HP-UX), so rename the library\n\t    # to its proper name (with version) after linking.\n\t    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\\''s/\\([[^()0-9A-Za-z{}]]\\)/\\\\\\\\\\1/g'\\''`; templib=`echo $lib | $SED -e \"s/\\${tempext}\\..*/.so/\"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \\$templib; mv \\$templib $lib'\n\t    _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\\''s/\\([[^()0-9A-Za-z{}]]\\)/\\\\\\\\\\1/g'\\''`; templib=`echo $lib | $SED -e \"s/\\${tempext}\\..*/.so/\"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \\$templib ${wl}-retain-symbols-file,$export_symbols; mv \\$templib $lib'\n\t    # Commands to make compiler produce verbose output that lists\n\t    # what \"hidden\" libraries, object files and flags are used when\n\t    # linking a shared library.\n\t    #\n\t    # There doesn't appear to be a way to prevent this compiler from\n\t    # explicitly linking system object files so we need to strip them\n\t    # from the output so that they don't get included in the library\n\t    # dependencies.\n\t    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP \"ld\"`; rm -f libconftest$shared_ext; list=\"\"; for z in $templist; do case $z in conftest.$objext) list=\"$list $z\";; *.$objext);; *) list=\"$list $z\";;esac; done; func_echo_all \"$list\"'\n\n\t    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'\n\t    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'\n\n\t    # Archives containing C++ object files must be created using\n\t    # \"CC -Bstatic\", where \"CC\" is the KAI C++ compiler.\n\t    _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'\n\t    ;;\n\t  icpc* | ecpc* )\n\t    # Intel C++\n\t    with_gnu_ld=yes\n\t    # version 8.0 and above of icpc choke on multiply defined symbols\n\t    # if we add $predep_objects and $postdep_objects, however 7.1 and\n\t    # earlier do not add the objects themselves.\n\t    case `$CC -V 2>&1` in\n\t      *\"Version 7.\"*)\n\t        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'\n\t\t_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'\n\t\t;;\n\t      *)  # Version 8.0 or newer\n\t        tmp_idyn=\n\t        case $host_cpu in\n\t\t  ia64*) tmp_idyn=' -i_dynamic';;\n\t\tesac\n\t        _LT_TAGVAR(archive_cmds, $1)='$CC -shared'\"$tmp_idyn\"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n\t\t_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'\"$tmp_idyn\"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'\n\t\t;;\n\t    esac\n\t    _LT_TAGVAR(archive_cmds_need_lc, $1)=no\n\t    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'\n\t    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'\n\t    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'\n\t    ;;\n          pgCC* | pgcpp*)\n            # Portland Group C++ compiler\n\t    case `$CC -V` in\n\t    *pgCC\\ [[1-5]].* | *pgcpp\\ [[1-5]].*)\n\t      _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~\n\t\trm -rf $tpldir~\n\t\t$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~\n\t\tcompile_command=\"$compile_command `find $tpldir -name \\*.o | sort | $NL2SP`\"'\n\t      _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~\n\t\trm -rf $tpldir~\n\t\t$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~\n\t\t$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \\*.o | sort | $NL2SP`~\n\t\t$RANLIB $oldlib'\n\t      _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~\n\t\trm -rf $tpldir~\n\t\t$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~\n\t\t$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \\*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'\n\t      _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~\n\t\trm -rf $tpldir~\n\t\t$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~\n\t\t$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \\*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'\n\t      ;;\n\t    *) # Version 6 and above use weak symbols\n\t      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'\n\t      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'\n\t      ;;\n\t    esac\n\n\t    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'\n\t    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'\n\t    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\\\"\\\"; do test  -n \\\"$conv\\\" && new_convenience=\\\"$new_convenience,$conv\\\"; done; func_echo_all \\\"$new_convenience\\\"` ${wl}--no-whole-archive'\n            ;;\n\t  cxx*)\n\t    # Compaq C++\n\t    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'\n\t    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'\n\n\t    runpath_var=LD_RUN_PATH\n\t    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'\n\t    _LT_TAGVAR(hardcode_libdir_separator, $1)=:\n\n\t    # Commands to make compiler produce verbose output that lists\n\t    # what \"hidden\" libraries, object files and flags are used when\n\t    # linking a shared library.\n\t    #\n\t    # There doesn't appear to be a way to prevent this compiler from\n\t    # explicitly linking system object files so we need to strip them\n\t    # from the output so that they don't get included in the library\n\t    # dependencies.\n\t    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP \"ld\"`; templist=`func_echo_all \"$templist\" | $SED \"s/\\(^.*ld.*\\)\\( .*ld .*$\\)/\\1/\"`; list=\"\"; for z in $templist; do case $z in conftest.$objext) list=\"$list $z\";; *.$objext);; *) list=\"$list $z\";;esac; done; func_echo_all \"X$list\" | $Xsed'\n\t    ;;\n\t  xl* | mpixl* | bgxl*)\n\t    # IBM XL 8.0 on PPC, with GNU ld\n\t    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'\n\t    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'\n\t    _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'\n\t    if test \"x$supports_anon_versioning\" = xyes; then\n\t      _LT_TAGVAR(archive_expsym_cmds, $1)='echo \"{ global:\" > $output_objdir/$libname.ver~\n\t\tcat $export_symbols | sed -e \"s/\\(.*\\)/\\1;/\" >> $output_objdir/$libname.ver~\n\t\techo \"local: *; };\" >> $output_objdir/$libname.ver~\n\t\t$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'\n\t    fi\n\t    ;;\n\t  *)\n\t    case `$CC -V 2>&1 | sed 5q` in\n\t    *Sun\\ C*)\n\t      # Sun C++ 5.9\n\t      _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'\n\t      _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'\n\t      _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'\n\t      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'\n\t      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\\\"\\\"; do test -z \\\"$conv\\\" || new_convenience=\\\"$new_convenience,$conv\\\"; done; func_echo_all \\\"$new_convenience\\\"` ${wl}--no-whole-archive'\n\t      _LT_TAGVAR(compiler_needs_object, $1)=yes\n\n\t      # Not sure whether something based on\n\t      # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1\n\t      # would be better.\n\t      output_verbose_link_cmd='func_echo_all'\n\n\t      # Archives containing C++ object files must be created using\n\t      # \"CC -xar\", where \"CC\" is the Sun C++ compiler.  This is\n\t      # necessary to make sure instantiated templates are included\n\t      # in the archive.\n\t      _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'\n\t      ;;\n\t    esac\n\t    ;;\n\tesac\n\t;;\n\n      lynxos*)\n        # FIXME: insert proper C++ library support\n\t_LT_TAGVAR(ld_shlibs, $1)=no\n\t;;\n\n      m88k*)\n        # FIXME: insert proper C++ library support\n        _LT_TAGVAR(ld_shlibs, $1)=no\n\t;;\n\n      mvs*)\n        case $cc_basename in\n          cxx*)\n\t    # FIXME: insert proper C++ library support\n\t    _LT_TAGVAR(ld_shlibs, $1)=no\n\t    ;;\n\t  *)\n\t    # FIXME: insert proper C++ library support\n\t    _LT_TAGVAR(ld_shlibs, $1)=no\n\t    ;;\n\tesac\n\t;;\n\n      netbsd*)\n        if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then\n\t  _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'\n\t  wlarc=\n\t  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'\n\t  _LT_TAGVAR(hardcode_direct, $1)=yes\n\t  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n\tfi\n\t# Workaround some broken pre-1.5 toolchains\n\toutput_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e \"s:-lgcc -lc -lgcc::\"'\n\t;;\n\n      *nto* | *qnx*)\n        _LT_TAGVAR(ld_shlibs, $1)=yes\n\t;;\n\n      openbsd2*)\n        # C++ shared libraries are fairly broken\n\t_LT_TAGVAR(ld_shlibs, $1)=no\n\t;;\n\n      openbsd*)\n\tif test -f /usr/libexec/ld.so; then\n\t  _LT_TAGVAR(hardcode_direct, $1)=yes\n\t  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n\t  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes\n\t  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'\n\t  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'\n\t  if test -z \"`echo __ELF__ | $CC -E - | grep __ELF__`\" || test \"$host_os-$host_cpu\" = \"openbsd2.8-powerpc\"; then\n\t    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'\n\t    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'\n\t    _LT_TAGVAR(whole_archive_flag_spec, $1)=\"$wlarc\"'--whole-archive$convenience '\"$wlarc\"'--no-whole-archive'\n\t  fi\n\t  output_verbose_link_cmd=func_echo_all\n\telse\n\t  _LT_TAGVAR(ld_shlibs, $1)=no\n\tfi\n\t;;\n\n      osf3* | osf4* | osf5*)\n        case $cc_basename in\n          KCC*)\n\t    # Kuck and Associates, Inc. (KAI) C++ Compiler\n\n\t    # KCC will only create a shared library if the output file\n\t    # ends with \".so\" (or \".sl\" for HP-UX), so rename the library\n\t    # to its proper name (with version) after linking.\n\t    _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\\''s/\\([[^()0-9A-Za-z{}]]\\)/\\\\\\\\\\1/g'\\''`; templib=`echo \"$lib\" | $SED -e \"s/\\${tempext}\\..*/.so/\"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \\$templib; mv \\$templib $lib'\n\n\t    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'\n\t    _LT_TAGVAR(hardcode_libdir_separator, $1)=:\n\n\t    # Archives containing C++ object files must be created using\n\t    # the KAI C++ compiler.\n\t    case $host in\n\t      osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;\n\t      *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;\n\t    esac\n\t    ;;\n          RCC*)\n\t    # Rational C++ 2.4.1\n\t    # FIXME: insert proper C++ library support\n\t    _LT_TAGVAR(ld_shlibs, $1)=no\n\t    ;;\n          cxx*)\n\t    case $host in\n\t      osf3*)\n\t        _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\\*'\n\t        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n \"$verstring\" && func_echo_all \"${wl}-set_version $verstring\"` -update_registry ${output_objdir}/so_locations -o $lib'\n\t        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'\n\t\t;;\n\t      *)\n\t        _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \\*'\n\t        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n \"$verstring\" && func_echo_all \"-set_version $verstring\"` -update_registry ${output_objdir}/so_locations -o $lib'\n\t        _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf \"%s %s\\\\n\" -exported_symbol \"\\$i\" >> $lib.exp; done~\n\t          echo \"-hidden\">> $lib.exp~\n\t          $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n \"$verstring\" && $ECHO \"-set_version $verstring\"` -update_registry ${output_objdir}/so_locations -o $lib~\n\t          $RM $lib.exp'\n\t        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'\n\t\t;;\n\t    esac\n\n\t    _LT_TAGVAR(hardcode_libdir_separator, $1)=:\n\n\t    # Commands to make compiler produce verbose output that lists\n\t    # what \"hidden\" libraries, object files and flags are used when\n\t    # linking a shared library.\n\t    #\n\t    # There doesn't appear to be a way to prevent this compiler from\n\t    # explicitly linking system object files so we need to strip them\n\t    # from the output so that they don't get included in the library\n\t    # dependencies.\n\t    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP \"ld\" | $GREP -v \"ld:\"`; templist=`func_echo_all \"$templist\" | $SED \"s/\\(^.*ld.*\\)\\( .*ld.*$\\)/\\1/\"`; list=\"\"; for z in $templist; do case $z in conftest.$objext) list=\"$list $z\";; *.$objext);; *) list=\"$list $z\";;esac; done; func_echo_all \"$list\"'\n\t    ;;\n\t  *)\n\t    if test \"$GXX\" = yes && test \"$with_gnu_ld\" = no; then\n\t      _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\\*'\n\t      case $host in\n\t        osf3*)\n\t          _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n \"$verstring\" && func_echo_all \"${wl}-set_version ${wl}$verstring\"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'\n\t\t  ;;\n\t        *)\n\t          _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n \"$verstring\" && func_echo_all \"${wl}-set_version ${wl}$verstring\"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'\n\t\t  ;;\n\t      esac\n\n\t      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'\n\t      _LT_TAGVAR(hardcode_libdir_separator, $1)=:\n\n\t      # Commands to make compiler produce verbose output that lists\n\t      # what \"hidden\" libraries, object files and flags are used when\n\t      # linking a shared library.\n\t      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v \"^Configured with:\" | $GREP \"\\-L\"'\n\n\t    else\n\t      # FIXME: insert proper C++ library support\n\t      _LT_TAGVAR(ld_shlibs, $1)=no\n\t    fi\n\t    ;;\n        esac\n        ;;\n\n      psos*)\n        # FIXME: insert proper C++ library support\n        _LT_TAGVAR(ld_shlibs, $1)=no\n        ;;\n\n      sunos4*)\n        case $cc_basename in\n          CC*)\n\t    # Sun C++ 4.x\n\t    # FIXME: insert proper C++ library support\n\t    _LT_TAGVAR(ld_shlibs, $1)=no\n\t    ;;\n          lcc*)\n\t    # Lucid\n\t    # FIXME: insert proper C++ library support\n\t    _LT_TAGVAR(ld_shlibs, $1)=no\n\t    ;;\n          *)\n\t    # FIXME: insert proper C++ library support\n\t    _LT_TAGVAR(ld_shlibs, $1)=no\n\t    ;;\n        esac\n        ;;\n\n      solaris*)\n        case $cc_basename in\n          CC* | sunCC*)\n\t    # Sun C++ 4.2, 5.x and Centerline C++\n            _LT_TAGVAR(archive_cmds_need_lc,$1)=yes\n\t    _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'\n\t    _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'\n\t    _LT_TAGVAR(archive_expsym_cmds, $1)='echo \"{ global:\" > $lib.exp~cat $export_symbols | $SED -e \"s/\\(.*\\)/\\1;/\" >> $lib.exp~echo \"local: *; };\" >> $lib.exp~\n\t      $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'\n\n\t    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'\n\t    _LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n\t    case $host_os in\n\t      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;\n\t      *)\n\t\t# The compiler driver will combine and reorder linker options,\n\t\t# but understands `-z linker_flag'.\n\t        # Supported since Solaris 2.6 (maybe 2.5.1?)\n\t\t_LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'\n\t        ;;\n\t    esac\n\t    _LT_TAGVAR(link_all_deplibs, $1)=yes\n\n\t    output_verbose_link_cmd='func_echo_all'\n\n\t    # Archives containing C++ object files must be created using\n\t    # \"CC -xar\", where \"CC\" is the Sun C++ compiler.  This is\n\t    # necessary to make sure instantiated templates are included\n\t    # in the archive.\n\t    _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'\n\t    ;;\n          gcx*)\n\t    # Green Hills C++ Compiler\n\t    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'\n\n\t    # The C++ compiler must be used to create the archive.\n\t    _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'\n\t    ;;\n          *)\n\t    # GNU C++ compiler with Solaris linker\n\t    if test \"$GXX\" = yes && test \"$with_gnu_ld\" = no; then\n\t      _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'\n\t      if $CC --version | $GREP -v '^2\\.7' > /dev/null; then\n\t        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'\n\t        _LT_TAGVAR(archive_expsym_cmds, $1)='echo \"{ global:\" > $lib.exp~cat $export_symbols | $SED -e \"s/\\(.*\\)/\\1;/\" >> $lib.exp~echo \"local: *; };\" >> $lib.exp~\n\t\t  $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'\n\n\t        # Commands to make compiler produce verbose output that lists\n\t        # what \"hidden\" libraries, object files and flags are used when\n\t        # linking a shared library.\n\t        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v \"^Configured with:\" | $GREP \"\\-L\"'\n\t      else\n\t        # g++ 2.7 appears to require `-G' NOT `-shared' on this\n\t        # platform.\n\t        _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'\n\t        _LT_TAGVAR(archive_expsym_cmds, $1)='echo \"{ global:\" > $lib.exp~cat $export_symbols | $SED -e \"s/\\(.*\\)/\\1;/\" >> $lib.exp~echo \"local: *; };\" >> $lib.exp~\n\t\t  $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'\n\n\t        # Commands to make compiler produce verbose output that lists\n\t        # what \"hidden\" libraries, object files and flags are used when\n\t        # linking a shared library.\n\t        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v \"^Configured with:\" | $GREP \"\\-L\"'\n\t      fi\n\n\t      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'\n\t      case $host_os in\n\t\tsolaris2.[[0-5]] | solaris2.[[0-5]].*) ;;\n\t\t*)\n\t\t  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'\n\t\t  ;;\n\t      esac\n\t    fi\n\t    ;;\n        esac\n        ;;\n\n    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)\n      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'\n      _LT_TAGVAR(archive_cmds_need_lc, $1)=no\n      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n      runpath_var='LD_RUN_PATH'\n\n      case $cc_basename in\n        CC*)\n\t  _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t  ;;\n\t*)\n\t  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t  ;;\n      esac\n      ;;\n\n      sysv5* | sco3.2v5* | sco5v6*)\n\t# Note: We can NOT use -z defs as we might desire, because we do not\n\t# link with -lc, and that would cause any symbols used from libc to\n\t# always be unresolved, which means just about no library would\n\t# ever link correctly.  If we're not using GNU ld we use -z text\n\t# though, which does catch some bad symbols but isn't as heavy-handed\n\t# as -z defs.\n\t_LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'\n\t_LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'\n\t_LT_TAGVAR(archive_cmds_need_lc, $1)=no\n\t_LT_TAGVAR(hardcode_shlibpath_var, $1)=no\n\t_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'\n\t_LT_TAGVAR(hardcode_libdir_separator, $1)=':'\n\t_LT_TAGVAR(link_all_deplibs, $1)=yes\n\t_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'\n\trunpath_var='LD_RUN_PATH'\n\n\tcase $cc_basename in\n          CC*)\n\t    _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t    _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~\n\t      '\"$_LT_TAGVAR(old_archive_cmds, $1)\"\n\t    _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~\n\t      '\"$_LT_TAGVAR(reload_cmds, $1)\"\n\t    ;;\n\t  *)\n\t    _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'\n\t    ;;\n\tesac\n      ;;\n\n      tandem*)\n        case $cc_basename in\n          NCC*)\n\t    # NonStop-UX NCC 3.20\n\t    # FIXME: insert proper C++ library support\n\t    _LT_TAGVAR(ld_shlibs, $1)=no\n\t    ;;\n          *)\n\t    # FIXME: insert proper C++ library support\n\t    _LT_TAGVAR(ld_shlibs, $1)=no\n\t    ;;\n        esac\n        ;;\n\n      vxworks*)\n        # FIXME: insert proper C++ library support\n        _LT_TAGVAR(ld_shlibs, $1)=no\n        ;;\n\n      *)\n        # FIXME: insert proper C++ library support\n        _LT_TAGVAR(ld_shlibs, $1)=no\n        ;;\n    esac\n\n    AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])\n    test \"$_LT_TAGVAR(ld_shlibs, $1)\" = no && can_build_shared=no\n\n    _LT_TAGVAR(GCC, $1)=\"$GXX\"\n    _LT_TAGVAR(LD, $1)=\"$LD\"\n\n    ## CAVEAT EMPTOR:\n    ## There is no encapsulation within the following macros, do not change\n    ## the running order or otherwise move them around unless you know exactly\n    ## what you are doing...\n    _LT_SYS_HIDDEN_LIBDEPS($1)\n    _LT_COMPILER_PIC($1)\n    _LT_COMPILER_C_O($1)\n    _LT_COMPILER_FILE_LOCKS($1)\n    _LT_LINKER_SHLIBS($1)\n    _LT_SYS_DYNAMIC_LINKER($1)\n    _LT_LINKER_HARDCODE_LIBPATH($1)\n\n    _LT_CONFIG($1)\n  fi # test -n \"$compiler\"\n\n  CC=$lt_save_CC\n  CFLAGS=$lt_save_CFLAGS\n  LDCXX=$LD\n  LD=$lt_save_LD\n  GCC=$lt_save_GCC\n  with_gnu_ld=$lt_save_with_gnu_ld\n  lt_cv_path_LDCXX=$lt_cv_path_LD\n  lt_cv_path_LD=$lt_save_path_LD\n  lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld\n  lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld\nfi # test \"$_lt_caught_CXX_error\" != yes\n\nAC_LANG_POP\n])# _LT_LANG_CXX_CONFIG\n\n\n# _LT_FUNC_STRIPNAME_CNF\n# ----------------------\n# func_stripname_cnf prefix suffix name\n# strip PREFIX and SUFFIX off of NAME.\n# PREFIX and SUFFIX must not contain globbing or regex special\n# characters, hashes, percent signs, but SUFFIX may contain a leading\n# dot (in which case that matches only a dot).\n#\n# This function is identical to the (non-XSI) version of func_stripname,\n# except this one can be used by m4 code that may be executed by configure,\n# rather than the libtool script.\nm4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl\nAC_REQUIRE([_LT_DECL_SED])\nAC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])\nfunc_stripname_cnf ()\n{\n  case ${2} in\n  .*) func_stripname_result=`$ECHO \"${3}\" | $SED \"s%^${1}%%; s%\\\\\\\\${2}\\$%%\"`;;\n  *)  func_stripname_result=`$ECHO \"${3}\" | $SED \"s%^${1}%%; s%${2}\\$%%\"`;;\n  esac\n} # func_stripname_cnf\n])# _LT_FUNC_STRIPNAME_CNF\n\n# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])\n# ---------------------------------\n# Figure out \"hidden\" library dependencies from verbose\n# compiler output when linking a shared library.\n# Parse the compiler output and extract the necessary\n# objects, libraries and library flags.\nm4_defun([_LT_SYS_HIDDEN_LIBDEPS],\n[m4_require([_LT_FILEUTILS_DEFAULTS])dnl\nAC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl\n# Dependencies to place before and after the object being linked:\n_LT_TAGVAR(predep_objects, $1)=\n_LT_TAGVAR(postdep_objects, $1)=\n_LT_TAGVAR(predeps, $1)=\n_LT_TAGVAR(postdeps, $1)=\n_LT_TAGVAR(compiler_lib_search_path, $1)=\n\ndnl we can't use the lt_simple_compile_test_code here,\ndnl because it contains code intended for an executable,\ndnl not a library.  It's possible we should let each\ndnl tag define a new lt_????_link_test_code variable,\ndnl but it's only used here...\nm4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF\nint a;\nvoid foo (void) { a = 0; }\n_LT_EOF\n], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF\nclass Foo\n{\npublic:\n  Foo (void) { a = 0; }\nprivate:\n  int a;\n};\n_LT_EOF\n], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF\n      subroutine foo\n      implicit none\n      integer*4 a\n      a=0\n      return\n      end\n_LT_EOF\n], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF\n      subroutine foo\n      implicit none\n      integer a\n      a=0\n      return\n      end\n_LT_EOF\n], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF\npublic class foo {\n  private int a;\n  public void bar (void) {\n    a = 0;\n  }\n};\n_LT_EOF\n], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF\npackage foo\nfunc foo() {\n}\n_LT_EOF\n])\n\n_lt_libdeps_save_CFLAGS=$CFLAGS\ncase \"$CC $CFLAGS \" in #(\n*\\ -flto*\\ *) CFLAGS=\"$CFLAGS -fno-lto\" ;;\n*\\ -fwhopr*\\ *) CFLAGS=\"$CFLAGS -fno-whopr\" ;;\n*\\ -fuse-linker-plugin*\\ *) CFLAGS=\"$CFLAGS -fno-use-linker-plugin\" ;;\nesac\n\ndnl Parse the compiler output and extract the necessary\ndnl objects, libraries and library flags.\nif AC_TRY_EVAL(ac_compile); then\n  # Parse the compiler output and extract the necessary\n  # objects, libraries and library flags.\n\n  # Sentinel used to keep track of whether or not we are before\n  # the conftest object file.\n  pre_test_object_deps_done=no\n\n  for p in `eval \"$output_verbose_link_cmd\"`; do\n    case ${prev}${p} in\n\n    -L* | -R* | -l*)\n       # Some compilers place space between \"-{L,R}\" and the path.\n       # Remove the space.\n       if test $p = \"-L\" ||\n          test $p = \"-R\"; then\n\t prev=$p\n\t continue\n       fi\n\n       # Expand the sysroot to ease extracting the directories later.\n       if test -z \"$prev\"; then\n         case $p in\n         -L*) func_stripname_cnf '-L' '' \"$p\"; prev=-L; p=$func_stripname_result ;;\n         -R*) func_stripname_cnf '-R' '' \"$p\"; prev=-R; p=$func_stripname_result ;;\n         -l*) func_stripname_cnf '-l' '' \"$p\"; prev=-l; p=$func_stripname_result ;;\n         esac\n       fi\n       case $p in\n       =*) func_stripname_cnf '=' '' \"$p\"; p=$lt_sysroot$func_stripname_result ;;\n       esac\n       if test \"$pre_test_object_deps_done\" = no; then\n\t case ${prev} in\n\t -L | -R)\n\t   # Internal compiler library paths should come after those\n\t   # provided the user.  The postdeps already come after the\n\t   # user supplied libs so there is no need to process them.\n\t   if test -z \"$_LT_TAGVAR(compiler_lib_search_path, $1)\"; then\n\t     _LT_TAGVAR(compiler_lib_search_path, $1)=\"${prev}${p}\"\n\t   else\n\t     _LT_TAGVAR(compiler_lib_search_path, $1)=\"${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}\"\n\t   fi\n\t   ;;\n\t # The \"-l\" case would never come before the object being\n\t # linked, so don't bother handling this case.\n\t esac\n       else\n\t if test -z \"$_LT_TAGVAR(postdeps, $1)\"; then\n\t   _LT_TAGVAR(postdeps, $1)=\"${prev}${p}\"\n\t else\n\t   _LT_TAGVAR(postdeps, $1)=\"${_LT_TAGVAR(postdeps, $1)} ${prev}${p}\"\n\t fi\n       fi\n       prev=\n       ;;\n\n    *.lto.$objext) ;; # Ignore GCC LTO objects\n    *.$objext)\n       # This assumes that the test object file only shows up\n       # once in the compiler output.\n       if test \"$p\" = \"conftest.$objext\"; then\n\t pre_test_object_deps_done=yes\n\t continue\n       fi\n\n       if test \"$pre_test_object_deps_done\" = no; then\n\t if test -z \"$_LT_TAGVAR(predep_objects, $1)\"; then\n\t   _LT_TAGVAR(predep_objects, $1)=\"$p\"\n\t else\n\t   _LT_TAGVAR(predep_objects, $1)=\"$_LT_TAGVAR(predep_objects, $1) $p\"\n\t fi\n       else\n\t if test -z \"$_LT_TAGVAR(postdep_objects, $1)\"; then\n\t   _LT_TAGVAR(postdep_objects, $1)=\"$p\"\n\t else\n\t   _LT_TAGVAR(postdep_objects, $1)=\"$_LT_TAGVAR(postdep_objects, $1) $p\"\n\t fi\n       fi\n       ;;\n\n    *) ;; # Ignore the rest.\n\n    esac\n  done\n\n  # Clean up.\n  rm -f a.out a.exe\nelse\n  echo \"libtool.m4: error: problem compiling $1 test program\"\nfi\n\n$RM -f confest.$objext\nCFLAGS=$_lt_libdeps_save_CFLAGS\n\n# PORTME: override above test on systems where it is broken\nm4_if([$1], [CXX],\n[case $host_os in\ninterix[[3-9]]*)\n  # Interix 3.5 installs completely hosed .la files for C++, so rather than\n  # hack all around it, let's just trust \"g++\" to DTRT.\n  _LT_TAGVAR(predep_objects,$1)=\n  _LT_TAGVAR(postdep_objects,$1)=\n  _LT_TAGVAR(postdeps,$1)=\n  ;;\n\nlinux*)\n  case `$CC -V 2>&1 | sed 5q` in\n  *Sun\\ C*)\n    # Sun C++ 5.9\n\n    # The more standards-conforming stlport4 library is\n    # incompatible with the Cstd library. Avoid specifying\n    # it if it's in CXXFLAGS. Ignore libCrun as\n    # -library=stlport4 depends on it.\n    case \" $CXX $CXXFLAGS \" in\n    *\" -library=stlport4 \"*)\n      solaris_use_stlport4=yes\n      ;;\n    esac\n\n    if test \"$solaris_use_stlport4\" != yes; then\n      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'\n    fi\n    ;;\n  esac\n  ;;\n\nsolaris*)\n  case $cc_basename in\n  CC* | sunCC*)\n    # The more standards-conforming stlport4 library is\n    # incompatible with the Cstd library. Avoid specifying\n    # it if it's in CXXFLAGS. Ignore libCrun as\n    # -library=stlport4 depends on it.\n    case \" $CXX $CXXFLAGS \" in\n    *\" -library=stlport4 \"*)\n      solaris_use_stlport4=yes\n      ;;\n    esac\n\n    # Adding this requires a known-good setup of shared libraries for\n    # Sun compiler versions before 5.6, else PIC objects from an old\n    # archive will be linked into the output, leading to subtle bugs.\n    if test \"$solaris_use_stlport4\" != yes; then\n      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'\n    fi\n    ;;\n  esac\n  ;;\nesac\n])\n\ncase \" $_LT_TAGVAR(postdeps, $1) \" in\n*\" -lc \"*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;\nesac\n _LT_TAGVAR(compiler_lib_search_dirs, $1)=\nif test -n \"${_LT_TAGVAR(compiler_lib_search_path, $1)}\"; then\n _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo \" ${_LT_TAGVAR(compiler_lib_search_path, $1)}\" | ${SED} -e 's! -L! !g' -e 's!^ !!'`\nfi\n_LT_TAGDECL([], [compiler_lib_search_dirs], [1],\n    [The directories searched by this compiler when creating a shared library])\n_LT_TAGDECL([], [predep_objects], [1],\n    [Dependencies to place before and after the objects being linked to\n    create a shared library])\n_LT_TAGDECL([], [postdep_objects], [1])\n_LT_TAGDECL([], [predeps], [1])\n_LT_TAGDECL([], [postdeps], [1])\n_LT_TAGDECL([], [compiler_lib_search_path], [1],\n    [The library search path used internally by the compiler when linking\n    a shared library])\n])# _LT_SYS_HIDDEN_LIBDEPS\n\n\n# _LT_LANG_F77_CONFIG([TAG])\n# --------------------------\n# Ensure that the configuration variables for a Fortran 77 compiler are\n# suitably defined.  These variables are subsequently used by _LT_CONFIG\n# to write the compiler configuration to `libtool'.\nm4_defun([_LT_LANG_F77_CONFIG],\n[AC_LANG_PUSH(Fortran 77)\nif test -z \"$F77\" || test \"X$F77\" = \"Xno\"; then\n  _lt_disable_F77=yes\nfi\n\n_LT_TAGVAR(archive_cmds_need_lc, $1)=no\n_LT_TAGVAR(allow_undefined_flag, $1)=\n_LT_TAGVAR(always_export_symbols, $1)=no\n_LT_TAGVAR(archive_expsym_cmds, $1)=\n_LT_TAGVAR(export_dynamic_flag_spec, $1)=\n_LT_TAGVAR(hardcode_direct, $1)=no\n_LT_TAGVAR(hardcode_direct_absolute, $1)=no\n_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=\n_LT_TAGVAR(hardcode_libdir_separator, $1)=\n_LT_TAGVAR(hardcode_minus_L, $1)=no\n_LT_TAGVAR(hardcode_automatic, $1)=no\n_LT_TAGVAR(inherit_rpath, $1)=no\n_LT_TAGVAR(module_cmds, $1)=\n_LT_TAGVAR(module_expsym_cmds, $1)=\n_LT_TAGVAR(link_all_deplibs, $1)=unknown\n_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds\n_LT_TAGVAR(reload_flag, $1)=$reload_flag\n_LT_TAGVAR(reload_cmds, $1)=$reload_cmds\n_LT_TAGVAR(no_undefined_flag, $1)=\n_LT_TAGVAR(whole_archive_flag_spec, $1)=\n_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no\n\n# Source file extension for f77 test sources.\nac_ext=f\n\n# Object file extension for compiled f77 test sources.\nobjext=o\n_LT_TAGVAR(objext, $1)=$objext\n\n# No sense in running all these tests if we already determined that\n# the F77 compiler isn't working.  Some variables (like enable_shared)\n# are currently assumed to apply to all compilers on this platform,\n# and will be corrupted by setting them based on a non-working compiler.\nif test \"$_lt_disable_F77\" != yes; then\n  # Code to be used in simple compile tests\n  lt_simple_compile_test_code=\"\\\n      subroutine t\n      return\n      end\n\"\n\n  # Code to be used in simple link tests\n  lt_simple_link_test_code=\"\\\n      program t\n      end\n\"\n\n  # ltmain only uses $CC for tagged configurations so make sure $CC is set.\n  _LT_TAG_COMPILER\n\n  # save warnings/boilerplate of simple test code\n  _LT_COMPILER_BOILERPLATE\n  _LT_LINKER_BOILERPLATE\n\n  # Allow CC to be a program name with arguments.\n  lt_save_CC=\"$CC\"\n  lt_save_GCC=$GCC\n  lt_save_CFLAGS=$CFLAGS\n  CC=${F77-\"f77\"}\n  CFLAGS=$FFLAGS\n  compiler=$CC\n  _LT_TAGVAR(compiler, $1)=$CC\n  _LT_CC_BASENAME([$compiler])\n  GCC=$G77\n  if test -n \"$compiler\"; then\n    AC_MSG_CHECKING([if libtool supports shared libraries])\n    AC_MSG_RESULT([$can_build_shared])\n\n    AC_MSG_CHECKING([whether to build shared libraries])\n    test \"$can_build_shared\" = \"no\" && enable_shared=no\n\n    # On AIX, shared libraries and static libraries use the same namespace, and\n    # are all built from PIC.\n    case $host_os in\n      aix3*)\n        test \"$enable_shared\" = yes && enable_static=no\n        if test -n \"$RANLIB\"; then\n          archive_cmds=\"$archive_cmds~\\$RANLIB \\$lib\"\n          postinstall_cmds='$RANLIB $lib'\n        fi\n        ;;\n      aix[[4-9]]*)\n\tif test \"$host_cpu\" != ia64 && test \"$aix_use_runtimelinking\" = no ; then\n\t  test \"$enable_shared\" = yes && enable_static=no\n\tfi\n        ;;\n    esac\n    AC_MSG_RESULT([$enable_shared])\n\n    AC_MSG_CHECKING([whether to build static libraries])\n    # Make sure either enable_shared or enable_static is yes.\n    test \"$enable_shared\" = yes || enable_static=yes\n    AC_MSG_RESULT([$enable_static])\n\n    _LT_TAGVAR(GCC, $1)=\"$G77\"\n    _LT_TAGVAR(LD, $1)=\"$LD\"\n\n    ## CAVEAT EMPTOR:\n    ## There is no encapsulation within the following macros, do not change\n    ## the running order or otherwise move them around unless you know exactly\n    ## what you are doing...\n    _LT_COMPILER_PIC($1)\n    _LT_COMPILER_C_O($1)\n    _LT_COMPILER_FILE_LOCKS($1)\n    _LT_LINKER_SHLIBS($1)\n    _LT_SYS_DYNAMIC_LINKER($1)\n    _LT_LINKER_HARDCODE_LIBPATH($1)\n\n    _LT_CONFIG($1)\n  fi # test -n \"$compiler\"\n\n  GCC=$lt_save_GCC\n  CC=\"$lt_save_CC\"\n  CFLAGS=\"$lt_save_CFLAGS\"\nfi # test \"$_lt_disable_F77\" != yes\n\nAC_LANG_POP\n])# _LT_LANG_F77_CONFIG\n\n\n# _LT_LANG_FC_CONFIG([TAG])\n# -------------------------\n# Ensure that the configuration variables for a Fortran compiler are\n# suitably defined.  These variables are subsequently used by _LT_CONFIG\n# to write the compiler configuration to `libtool'.\nm4_defun([_LT_LANG_FC_CONFIG],\n[AC_LANG_PUSH(Fortran)\n\nif test -z \"$FC\" || test \"X$FC\" = \"Xno\"; then\n  _lt_disable_FC=yes\nfi\n\n_LT_TAGVAR(archive_cmds_need_lc, $1)=no\n_LT_TAGVAR(allow_undefined_flag, $1)=\n_LT_TAGVAR(always_export_symbols, $1)=no\n_LT_TAGVAR(archive_expsym_cmds, $1)=\n_LT_TAGVAR(export_dynamic_flag_spec, $1)=\n_LT_TAGVAR(hardcode_direct, $1)=no\n_LT_TAGVAR(hardcode_direct_absolute, $1)=no\n_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=\n_LT_TAGVAR(hardcode_libdir_separator, $1)=\n_LT_TAGVAR(hardcode_minus_L, $1)=no\n_LT_TAGVAR(hardcode_automatic, $1)=no\n_LT_TAGVAR(inherit_rpath, $1)=no\n_LT_TAGVAR(module_cmds, $1)=\n_LT_TAGVAR(module_expsym_cmds, $1)=\n_LT_TAGVAR(link_all_deplibs, $1)=unknown\n_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds\n_LT_TAGVAR(reload_flag, $1)=$reload_flag\n_LT_TAGVAR(reload_cmds, $1)=$reload_cmds\n_LT_TAGVAR(no_undefined_flag, $1)=\n_LT_TAGVAR(whole_archive_flag_spec, $1)=\n_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no\n\n# Source file extension for fc test sources.\nac_ext=${ac_fc_srcext-f}\n\n# Object file extension for compiled fc test sources.\nobjext=o\n_LT_TAGVAR(objext, $1)=$objext\n\n# No sense in running all these tests if we already determined that\n# the FC compiler isn't working.  Some variables (like enable_shared)\n# are currently assumed to apply to all compilers on this platform,\n# and will be corrupted by setting them based on a non-working compiler.\nif test \"$_lt_disable_FC\" != yes; then\n  # Code to be used in simple compile tests\n  lt_simple_compile_test_code=\"\\\n      subroutine t\n      return\n      end\n\"\n\n  # Code to be used in simple link tests\n  lt_simple_link_test_code=\"\\\n      program t\n      end\n\"\n\n  # ltmain only uses $CC for tagged configurations so make sure $CC is set.\n  _LT_TAG_COMPILER\n\n  # save warnings/boilerplate of simple test code\n  _LT_COMPILER_BOILERPLATE\n  _LT_LINKER_BOILERPLATE\n\n  # Allow CC to be a program name with arguments.\n  lt_save_CC=\"$CC\"\n  lt_save_GCC=$GCC\n  lt_save_CFLAGS=$CFLAGS\n  CC=${FC-\"f95\"}\n  CFLAGS=$FCFLAGS\n  compiler=$CC\n  GCC=$ac_cv_fc_compiler_gnu\n\n  _LT_TAGVAR(compiler, $1)=$CC\n  _LT_CC_BASENAME([$compiler])\n\n  if test -n \"$compiler\"; then\n    AC_MSG_CHECKING([if libtool supports shared libraries])\n    AC_MSG_RESULT([$can_build_shared])\n\n    AC_MSG_CHECKING([whether to build shared libraries])\n    test \"$can_build_shared\" = \"no\" && enable_shared=no\n\n    # On AIX, shared libraries and static libraries use the same namespace, and\n    # are all built from PIC.\n    case $host_os in\n      aix3*)\n        test \"$enable_shared\" = yes && enable_static=no\n        if test -n \"$RANLIB\"; then\n          archive_cmds=\"$archive_cmds~\\$RANLIB \\$lib\"\n          postinstall_cmds='$RANLIB $lib'\n        fi\n        ;;\n      aix[[4-9]]*)\n\tif test \"$host_cpu\" != ia64 && test \"$aix_use_runtimelinking\" = no ; then\n\t  test \"$enable_shared\" = yes && enable_static=no\n\tfi\n        ;;\n    esac\n    AC_MSG_RESULT([$enable_shared])\n\n    AC_MSG_CHECKING([whether to build static libraries])\n    # Make sure either enable_shared or enable_static is yes.\n    test \"$enable_shared\" = yes || enable_static=yes\n    AC_MSG_RESULT([$enable_static])\n\n    _LT_TAGVAR(GCC, $1)=\"$ac_cv_fc_compiler_gnu\"\n    _LT_TAGVAR(LD, $1)=\"$LD\"\n\n    ## CAVEAT EMPTOR:\n    ## There is no encapsulation within the following macros, do not change\n    ## the running order or otherwise move them around unless you know exactly\n    ## what you are doing...\n    _LT_SYS_HIDDEN_LIBDEPS($1)\n    _LT_COMPILER_PIC($1)\n    _LT_COMPILER_C_O($1)\n    _LT_COMPILER_FILE_LOCKS($1)\n    _LT_LINKER_SHLIBS($1)\n    _LT_SYS_DYNAMIC_LINKER($1)\n    _LT_LINKER_HARDCODE_LIBPATH($1)\n\n    _LT_CONFIG($1)\n  fi # test -n \"$compiler\"\n\n  GCC=$lt_save_GCC\n  CC=$lt_save_CC\n  CFLAGS=$lt_save_CFLAGS\nfi # test \"$_lt_disable_FC\" != yes\n\nAC_LANG_POP\n])# _LT_LANG_FC_CONFIG\n\n\n# _LT_LANG_GCJ_CONFIG([TAG])\n# --------------------------\n# Ensure that the configuration variables for the GNU Java Compiler compiler\n# are suitably defined.  These variables are subsequently used by _LT_CONFIG\n# to write the compiler configuration to `libtool'.\nm4_defun([_LT_LANG_GCJ_CONFIG],\n[AC_REQUIRE([LT_PROG_GCJ])dnl\nAC_LANG_SAVE\n\n# Source file extension for Java test sources.\nac_ext=java\n\n# Object file extension for compiled Java test sources.\nobjext=o\n_LT_TAGVAR(objext, $1)=$objext\n\n# Code to be used in simple compile tests\nlt_simple_compile_test_code=\"class foo {}\"\n\n# Code to be used in simple link tests\nlt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'\n\n# ltmain only uses $CC for tagged configurations so make sure $CC is set.\n_LT_TAG_COMPILER\n\n# save warnings/boilerplate of simple test code\n_LT_COMPILER_BOILERPLATE\n_LT_LINKER_BOILERPLATE\n\n# Allow CC to be a program name with arguments.\nlt_save_CC=$CC\nlt_save_CFLAGS=$CFLAGS\nlt_save_GCC=$GCC\nGCC=yes\nCC=${GCJ-\"gcj\"}\nCFLAGS=$GCJFLAGS\ncompiler=$CC\n_LT_TAGVAR(compiler, $1)=$CC\n_LT_TAGVAR(LD, $1)=\"$LD\"\n_LT_CC_BASENAME([$compiler])\n\n# GCJ did not exist at the time GCC didn't implicitly link libc in.\n_LT_TAGVAR(archive_cmds_need_lc, $1)=no\n\n_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds\n_LT_TAGVAR(reload_flag, $1)=$reload_flag\n_LT_TAGVAR(reload_cmds, $1)=$reload_cmds\n\n## CAVEAT EMPTOR:\n## There is no encapsulation within the following macros, do not change\n## the running order or otherwise move them around unless you know exactly\n## what you are doing...\nif test -n \"$compiler\"; then\n  _LT_COMPILER_NO_RTTI($1)\n  _LT_COMPILER_PIC($1)\n  _LT_COMPILER_C_O($1)\n  _LT_COMPILER_FILE_LOCKS($1)\n  _LT_LINKER_SHLIBS($1)\n  _LT_LINKER_HARDCODE_LIBPATH($1)\n\n  _LT_CONFIG($1)\nfi\n\nAC_LANG_RESTORE\n\nGCC=$lt_save_GCC\nCC=$lt_save_CC\nCFLAGS=$lt_save_CFLAGS\n])# _LT_LANG_GCJ_CONFIG\n\n\n# _LT_LANG_GO_CONFIG([TAG])\n# --------------------------\n# Ensure that the configuration variables for the GNU Go compiler\n# are suitably defined.  These variables are subsequently used by _LT_CONFIG\n# to write the compiler configuration to `libtool'.\nm4_defun([_LT_LANG_GO_CONFIG],\n[AC_REQUIRE([LT_PROG_GO])dnl\nAC_LANG_SAVE\n\n# Source file extension for Go test sources.\nac_ext=go\n\n# Object file extension for compiled Go test sources.\nobjext=o\n_LT_TAGVAR(objext, $1)=$objext\n\n# Code to be used in simple compile tests\nlt_simple_compile_test_code=\"package main; func main() { }\"\n\n# Code to be used in simple link tests\nlt_simple_link_test_code='package main; func main() { }'\n\n# ltmain only uses $CC for tagged configurations so make sure $CC is set.\n_LT_TAG_COMPILER\n\n# save warnings/boilerplate of simple test code\n_LT_COMPILER_BOILERPLATE\n_LT_LINKER_BOILERPLATE\n\n# Allow CC to be a program name with arguments.\nlt_save_CC=$CC\nlt_save_CFLAGS=$CFLAGS\nlt_save_GCC=$GCC\nGCC=yes\nCC=${GOC-\"gccgo\"}\nCFLAGS=$GOFLAGS\ncompiler=$CC\n_LT_TAGVAR(compiler, $1)=$CC\n_LT_TAGVAR(LD, $1)=\"$LD\"\n_LT_CC_BASENAME([$compiler])\n\n# Go did not exist at the time GCC didn't implicitly link libc in.\n_LT_TAGVAR(archive_cmds_need_lc, $1)=no\n\n_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds\n_LT_TAGVAR(reload_flag, $1)=$reload_flag\n_LT_TAGVAR(reload_cmds, $1)=$reload_cmds\n\n## CAVEAT EMPTOR:\n## There is no encapsulation within the following macros, do not change\n## the running order or otherwise move them around unless you know exactly\n## what you are doing...\nif test -n \"$compiler\"; then\n  _LT_COMPILER_NO_RTTI($1)\n  _LT_COMPILER_PIC($1)\n  _LT_COMPILER_C_O($1)\n  _LT_COMPILER_FILE_LOCKS($1)\n  _LT_LINKER_SHLIBS($1)\n  _LT_LINKER_HARDCODE_LIBPATH($1)\n\n  _LT_CONFIG($1)\nfi\n\nAC_LANG_RESTORE\n\nGCC=$lt_save_GCC\nCC=$lt_save_CC\nCFLAGS=$lt_save_CFLAGS\n])# _LT_LANG_GO_CONFIG\n\n\n# _LT_LANG_RC_CONFIG([TAG])\n# -------------------------\n# Ensure that the configuration variables for the Windows resource compiler\n# are suitably defined.  These variables are subsequently used by _LT_CONFIG\n# to write the compiler configuration to `libtool'.\nm4_defun([_LT_LANG_RC_CONFIG],\n[AC_REQUIRE([LT_PROG_RC])dnl\nAC_LANG_SAVE\n\n# Source file extension for RC test sources.\nac_ext=rc\n\n# Object file extension for compiled RC test sources.\nobjext=o\n_LT_TAGVAR(objext, $1)=$objext\n\n# Code to be used in simple compile tests\nlt_simple_compile_test_code='sample MENU { MENUITEM \"&Soup\", 100, CHECKED }'\n\n# Code to be used in simple link tests\nlt_simple_link_test_code=\"$lt_simple_compile_test_code\"\n\n# ltmain only uses $CC for tagged configurations so make sure $CC is set.\n_LT_TAG_COMPILER\n\n# save warnings/boilerplate of simple test code\n_LT_COMPILER_BOILERPLATE\n_LT_LINKER_BOILERPLATE\n\n# Allow CC to be a program name with arguments.\nlt_save_CC=\"$CC\"\nlt_save_CFLAGS=$CFLAGS\nlt_save_GCC=$GCC\nGCC=\nCC=${RC-\"windres\"}\nCFLAGS=\ncompiler=$CC\n_LT_TAGVAR(compiler, $1)=$CC\n_LT_CC_BASENAME([$compiler])\n_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes\n\nif test -n \"$compiler\"; then\n  :\n  _LT_CONFIG($1)\nfi\n\nGCC=$lt_save_GCC\nAC_LANG_RESTORE\nCC=$lt_save_CC\nCFLAGS=$lt_save_CFLAGS\n])# _LT_LANG_RC_CONFIG\n\n\n# LT_PROG_GCJ\n# -----------\nAC_DEFUN([LT_PROG_GCJ],\n[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],\n  [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],\n    [AC_CHECK_TOOL(GCJ, gcj,)\n      test \"x${GCJFLAGS+set}\" = xset || GCJFLAGS=\"-g -O2\"\n      AC_SUBST(GCJFLAGS)])])[]dnl\n])\n\n# Old name:\nAU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])\ndnl aclocal-1.4 backwards compatibility:\ndnl AC_DEFUN([LT_AC_PROG_GCJ], [])\n\n\n# LT_PROG_GO\n# ----------\nAC_DEFUN([LT_PROG_GO],\n[AC_CHECK_TOOL(GOC, gccgo,)\n])\n\n\n# LT_PROG_RC\n# ----------\nAC_DEFUN([LT_PROG_RC],\n[AC_CHECK_TOOL(RC, windres,)\n])\n\n# Old name:\nAU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])\ndnl aclocal-1.4 backwards compatibility:\ndnl AC_DEFUN([LT_AC_PROG_RC], [])\n\n\n# _LT_DECL_EGREP\n# --------------\n# If we don't have a new enough Autoconf to choose the best grep\n# available, choose the one first in the user's PATH.\nm4_defun([_LT_DECL_EGREP],\n[AC_REQUIRE([AC_PROG_EGREP])dnl\nAC_REQUIRE([AC_PROG_FGREP])dnl\ntest -z \"$GREP\" && GREP=grep\n_LT_DECL([], [GREP], [1], [A grep program that handles long lines])\n_LT_DECL([], [EGREP], [1], [An ERE matcher])\n_LT_DECL([], [FGREP], [1], [A literal string matcher])\ndnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too\nAC_SUBST([GREP])\n])\n\n\n# _LT_DECL_OBJDUMP\n# --------------\n# If we don't have a new enough Autoconf to choose the best objdump\n# available, choose the one first in the user's PATH.\nm4_defun([_LT_DECL_OBJDUMP],\n[AC_CHECK_TOOL(OBJDUMP, objdump, false)\ntest -z \"$OBJDUMP\" && OBJDUMP=objdump\n_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper])\nAC_SUBST([OBJDUMP])\n])\n\n# _LT_DECL_DLLTOOL\n# ----------------\n# Ensure DLLTOOL variable is set.\nm4_defun([_LT_DECL_DLLTOOL],\n[AC_CHECK_TOOL(DLLTOOL, dlltool, false)\ntest -z \"$DLLTOOL\" && DLLTOOL=dlltool\n_LT_DECL([], [DLLTOOL], [1], [DLL creation program])\nAC_SUBST([DLLTOOL])\n])\n\n# _LT_DECL_SED\n# ------------\n# Check for a fully-functional sed program, that truncates\n# as few characters as possible.  Prefer GNU sed if found.\nm4_defun([_LT_DECL_SED],\n[AC_PROG_SED\ntest -z \"$SED\" && SED=sed\nXsed=\"$SED -e 1s/^X//\"\n_LT_DECL([], [SED], [1], [A sed program that does not truncate output])\n_LT_DECL([], [Xsed], [\"\\$SED -e 1s/^X//\"],\n    [Sed that helps us avoid accidentally triggering echo(1) options like -n])\n])# _LT_DECL_SED\n\nm4_ifndef([AC_PROG_SED], [\n############################################################\n# NOTE: This macro has been submitted for inclusion into   #\n#  GNU Autoconf as AC_PROG_SED.  When it is available in   #\n#  a released version of Autoconf we should remove this    #\n#  macro and use it instead.                               #\n############################################################\n\nm4_defun([AC_PROG_SED],\n[AC_MSG_CHECKING([for a sed that does not truncate output])\nAC_CACHE_VAL(lt_cv_path_SED,\n[# Loop through the user's path and test for sed and gsed.\n# Then use that list of sed's as ones to test for truncation.\nas_save_IFS=$IFS; IFS=$PATH_SEPARATOR\nfor as_dir in $PATH\ndo\n  IFS=$as_save_IFS\n  test -z \"$as_dir\" && as_dir=.\n  for lt_ac_prog in sed gsed; do\n    for ac_exec_ext in '' $ac_executable_extensions; do\n      if $as_executable_p \"$as_dir/$lt_ac_prog$ac_exec_ext\"; then\n        lt_ac_sed_list=\"$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext\"\n      fi\n    done\n  done\ndone\nIFS=$as_save_IFS\nlt_ac_max=0\nlt_ac_count=0\n# Add /usr/xpg4/bin/sed as it is typically found on Solaris\n# along with /bin/sed that truncates output.\nfor lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do\n  test ! -f $lt_ac_sed && continue\n  cat /dev/null > conftest.in\n  lt_ac_count=0\n  echo $ECHO_N \"0123456789$ECHO_C\" >conftest.in\n  # Check for GNU sed and select it if it is found.\n  if \"$lt_ac_sed\" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then\n    lt_cv_path_SED=$lt_ac_sed\n    break\n  fi\n  while true; do\n    cat conftest.in conftest.in >conftest.tmp\n    mv conftest.tmp conftest.in\n    cp conftest.in conftest.nl\n    echo >>conftest.nl\n    $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break\n    cmp -s conftest.out conftest.nl || break\n    # 10000 chars as input seems more than enough\n    test $lt_ac_count -gt 10 && break\n    lt_ac_count=`expr $lt_ac_count + 1`\n    if test $lt_ac_count -gt $lt_ac_max; then\n      lt_ac_max=$lt_ac_count\n      lt_cv_path_SED=$lt_ac_sed\n    fi\n  done\ndone\n])\nSED=$lt_cv_path_SED\nAC_SUBST([SED])\nAC_MSG_RESULT([$SED])\n])#AC_PROG_SED\n])#m4_ifndef\n\n# Old name:\nAU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])\ndnl aclocal-1.4 backwards compatibility:\ndnl AC_DEFUN([LT_AC_PROG_SED], [])\n\n\n# _LT_CHECK_SHELL_FEATURES\n# ------------------------\n# Find out whether the shell is Bourne or XSI compatible,\n# or has some other useful features.\nm4_defun([_LT_CHECK_SHELL_FEATURES],\n[AC_MSG_CHECKING([whether the shell understands some XSI constructs])\n# Try some XSI features\nxsi_shell=no\n( _lt_dummy=\"a/b/c\"\n  test \"${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}\"${_lt_dummy%\"$_lt_dummy\"}, \\\n      = c,a/b,b/c, \\\n    && eval 'test $(( 1 + 1 )) -eq 2 \\\n    && test \"${#_lt_dummy}\" -eq 5' ) >/dev/null 2>&1 \\\n  && xsi_shell=yes\nAC_MSG_RESULT([$xsi_shell])\n_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])\n\nAC_MSG_CHECKING([whether the shell understands \"+=\"])\nlt_shell_append=no\n( foo=bar; set foo baz; eval \"$[1]+=\\$[2]\" && test \"$foo\" = barbaz ) \\\n    >/dev/null 2>&1 \\\n  && lt_shell_append=yes\nAC_MSG_RESULT([$lt_shell_append])\n_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])\n\nif ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then\n  lt_unset=unset\nelse\n  lt_unset=false\nfi\n_LT_DECL([], [lt_unset], [0], [whether the shell understands \"unset\"])dnl\n\n# test EBCDIC or ASCII\ncase `echo X|tr X '\\101'` in\n A) # ASCII based system\n    # \\n is not interpreted correctly by Solaris 8 /usr/ucb/tr\n  lt_SP2NL='tr \\040 \\012'\n  lt_NL2SP='tr \\015\\012 \\040\\040'\n  ;;\n *) # EBCDIC based system\n  lt_SP2NL='tr \\100 \\n'\n  lt_NL2SP='tr \\r\\n \\100\\100'\n  ;;\nesac\n_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl\n_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl\n])# _LT_CHECK_SHELL_FEATURES\n\n\n# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY)\n# ------------------------------------------------------\n# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and\n# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY.\nm4_defun([_LT_PROG_FUNCTION_REPLACE],\n[dnl {\nsed -e '/^$1 ()$/,/^} # $1 /c\\\n$1 ()\\\n{\\\nm4_bpatsubsts([$2], [$], [\\\\], [^\\([\t ]\\)], [\\\\\\1])\n} # Extended-shell $1 implementation' \"$cfgfile\" > $cfgfile.tmp \\\n  && mv -f \"$cfgfile.tmp\" \"$cfgfile\" \\\n    || (rm -f \"$cfgfile\" && cp \"$cfgfile.tmp\" \"$cfgfile\" && rm -f \"$cfgfile.tmp\")\ntest 0 -eq $? || _lt_function_replace_fail=:\n])\n\n\n# _LT_PROG_REPLACE_SHELLFNS\n# -------------------------\n# Replace existing portable implementations of several shell functions with\n# equivalent extended shell implementations where those features are available..\nm4_defun([_LT_PROG_REPLACE_SHELLFNS],\n[if test x\"$xsi_shell\" = xyes; then\n  _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl\n    case ${1} in\n      */*) func_dirname_result=\"${1%/*}${2}\" ;;\n      *  ) func_dirname_result=\"${3}\" ;;\n    esac])\n\n  _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl\n    func_basename_result=\"${1##*/}\"])\n\n  _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl\n    case ${1} in\n      */*) func_dirname_result=\"${1%/*}${2}\" ;;\n      *  ) func_dirname_result=\"${3}\" ;;\n    esac\n    func_basename_result=\"${1##*/}\"])\n\n  _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl\n    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\n    # positional parameters, so assign one to ordinary parameter first.\n    func_stripname_result=${3}\n    func_stripname_result=${func_stripname_result#\"${1}\"}\n    func_stripname_result=${func_stripname_result%\"${2}\"}])\n\n  _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl\n    func_split_long_opt_name=${1%%=*}\n    func_split_long_opt_arg=${1#*=}])\n\n  _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl\n    func_split_short_opt_arg=${1#??}\n    func_split_short_opt_name=${1%\"$func_split_short_opt_arg\"}])\n\n  _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl\n    case ${1} in\n      *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\n      *)    func_lo2o_result=${1} ;;\n    esac])\n\n  _LT_PROG_FUNCTION_REPLACE([func_xform], [    func_xform_result=${1%.*}.lo])\n\n  _LT_PROG_FUNCTION_REPLACE([func_arith], [    func_arith_result=$(( $[*] ))])\n\n  _LT_PROG_FUNCTION_REPLACE([func_len], [    func_len_result=${#1}])\nfi\n\nif test x\"$lt_shell_append\" = xyes; then\n  _LT_PROG_FUNCTION_REPLACE([func_append], [    eval \"${1}+=\\\\${2}\"])\n\n  _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl\n    func_quote_for_eval \"${2}\"\ndnl m4 expansion turns \\\\\\\\ into \\\\, and then the shell eval turns that into \\\n    eval \"${1}+=\\\\\\\\ \\\\$func_quote_for_eval_result\"])\n\n  # Save a `func_append' function call where possible by direct use of '+='\n  sed -e 's%func_append \\([[a-zA-Z_]]\\{1,\\}\\) \"%\\1+=\"%g' $cfgfile > $cfgfile.tmp \\\n    && mv -f \"$cfgfile.tmp\" \"$cfgfile\" \\\n      || (rm -f \"$cfgfile\" && cp \"$cfgfile.tmp\" \"$cfgfile\" && rm -f \"$cfgfile.tmp\")\n  test 0 -eq $? || _lt_function_replace_fail=:\nelse\n  # Save a `func_append' function call even when '+=' is not available\n  sed -e 's%func_append \\([[a-zA-Z_]]\\{1,\\}\\) \"%\\1=\"$\\1%g' $cfgfile > $cfgfile.tmp \\\n    && mv -f \"$cfgfile.tmp\" \"$cfgfile\" \\\n      || (rm -f \"$cfgfile\" && cp \"$cfgfile.tmp\" \"$cfgfile\" && rm -f \"$cfgfile.tmp\")\n  test 0 -eq $? || _lt_function_replace_fail=:\nfi\n\nif test x\"$_lt_function_replace_fail\" = x\":\"; then\n  AC_MSG_WARN([Unable to substitute extended shell functions in $ofile])\nfi\n])\n\n# _LT_PATH_CONVERSION_FUNCTIONS\n# -----------------------------\n# Determine which file name conversion functions should be used by\n# func_to_host_file (and, implicitly, by func_to_host_path).  These are needed\n# for certain cross-compile configurations and native mingw.\nm4_defun([_LT_PATH_CONVERSION_FUNCTIONS],\n[AC_REQUIRE([AC_CANONICAL_HOST])dnl\nAC_REQUIRE([AC_CANONICAL_BUILD])dnl\nAC_MSG_CHECKING([how to convert $build file names to $host format])\nAC_CACHE_VAL(lt_cv_to_host_file_cmd,\n[case $host in\n  *-*-mingw* )\n    case $build in\n      *-*-mingw* ) # actually msys\n        lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32\n        ;;\n      *-*-cygwin* )\n        lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32\n        ;;\n      * ) # otherwise, assume *nix\n        lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32\n        ;;\n    esac\n    ;;\n  *-*-cygwin* )\n    case $build in\n      *-*-mingw* ) # actually msys\n        lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin\n        ;;\n      *-*-cygwin* )\n        lt_cv_to_host_file_cmd=func_convert_file_noop\n        ;;\n      * ) # otherwise, assume *nix\n        lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin\n        ;;\n    esac\n    ;;\n  * ) # unhandled hosts (and \"normal\" native builds)\n    lt_cv_to_host_file_cmd=func_convert_file_noop\n    ;;\nesac\n])\nto_host_file_cmd=$lt_cv_to_host_file_cmd\nAC_MSG_RESULT([$lt_cv_to_host_file_cmd])\n_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd],\n         [0], [convert $build file names to $host format])dnl\n\nAC_MSG_CHECKING([how to convert $build file names to toolchain format])\nAC_CACHE_VAL(lt_cv_to_tool_file_cmd,\n[#assume ordinary cross tools, or native build.\nlt_cv_to_tool_file_cmd=func_convert_file_noop\ncase $host in\n  *-*-mingw* )\n    case $build in\n      *-*-mingw* ) # actually msys\n        lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32\n        ;;\n    esac\n    ;;\nesac\n])\nto_tool_file_cmd=$lt_cv_to_tool_file_cmd\nAC_MSG_RESULT([$lt_cv_to_tool_file_cmd])\n_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd],\n         [0], [convert $build files to toolchain format])dnl\n])# _LT_PATH_CONVERSION_FUNCTIONS\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/m4/ltoptions.m4",
    "content": "# Helper functions for option handling.                    -*- Autoconf -*-\n#\n#   Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,\n#   Inc.\n#   Written by Gary V. Vaughan, 2004\n#\n# This file is free software; the Free Software Foundation gives\n# unlimited permission to copy and/or distribute it, with or without\n# modifications, as long as this notice is preserved.\n\n# serial 7 ltoptions.m4\n\n# This is to help aclocal find these macros, as it can't see m4_define.\nAC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])\n\n\n# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)\n# ------------------------------------------\nm4_define([_LT_MANGLE_OPTION],\n[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])\n\n\n# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)\n# ---------------------------------------\n# Set option OPTION-NAME for macro MACRO-NAME, and if there is a\n# matching handler defined, dispatch to it.  Other OPTION-NAMEs are\n# saved as a flag.\nm4_define([_LT_SET_OPTION],\n[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl\nm4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),\n        _LT_MANGLE_DEFUN([$1], [$2]),\n    [m4_warning([Unknown $1 option `$2'])])[]dnl\n])\n\n\n# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])\n# ------------------------------------------------------------\n# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.\nm4_define([_LT_IF_OPTION],\n[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])\n\n\n# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)\n# -------------------------------------------------------\n# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME\n# are set.\nm4_define([_LT_UNLESS_OPTIONS],\n[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),\n\t    [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),\n\t\t      [m4_define([$0_found])])])[]dnl\nm4_ifdef([$0_found], [m4_undefine([$0_found])], [$3\n])[]dnl\n])\n\n\n# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)\n# ----------------------------------------\n# OPTION-LIST is a space-separated list of Libtool options associated\n# with MACRO-NAME.  If any OPTION has a matching handler declared with\n# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about\n# the unknown option and exit.\nm4_defun([_LT_SET_OPTIONS],\n[# Set options\nm4_foreach([_LT_Option], m4_split(m4_normalize([$2])),\n    [_LT_SET_OPTION([$1], _LT_Option)])\n\nm4_if([$1],[LT_INIT],[\n  dnl\n  dnl Simply set some default values (i.e off) if boolean options were not\n  dnl specified:\n  _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no\n  ])\n  _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no\n  ])\n  dnl\n  dnl If no reference was made to various pairs of opposing options, then\n  dnl we run the default mode handler for the pair.  For example, if neither\n  dnl `shared' nor `disable-shared' was passed, we enable building of shared\n  dnl archives by default:\n  _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])\n  _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])\n  _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])\n  _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],\n  \t\t   [_LT_ENABLE_FAST_INSTALL])\n  ])\n])# _LT_SET_OPTIONS\n\n\n## --------------------------------- ##\n## Macros to handle LT_INIT options. ##\n## --------------------------------- ##\n\n# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)\n# -----------------------------------------\nm4_define([_LT_MANGLE_DEFUN],\n[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])\n\n\n# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)\n# -----------------------------------------------\nm4_define([LT_OPTION_DEFINE],\n[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl\n])# LT_OPTION_DEFINE\n\n\n# dlopen\n# ------\nLT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes\n])\n\nAU_DEFUN([AC_LIBTOOL_DLOPEN],\n[_LT_SET_OPTION([LT_INIT], [dlopen])\nAC_DIAGNOSE([obsolete],\n[$0: Remove this warning and the call to _LT_SET_OPTION when you\nput the `dlopen' option into LT_INIT's first parameter.])\n])\n\ndnl aclocal-1.4 backwards compatibility:\ndnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])\n\n\n# win32-dll\n# ---------\n# Declare package support for building win32 dll's.\nLT_OPTION_DEFINE([LT_INIT], [win32-dll],\n[enable_win32_dll=yes\n\ncase $host in\n*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)\n  AC_CHECK_TOOL(AS, as, false)\n  AC_CHECK_TOOL(DLLTOOL, dlltool, false)\n  AC_CHECK_TOOL(OBJDUMP, objdump, false)\n  ;;\nesac\n\ntest -z \"$AS\" && AS=as\n_LT_DECL([], [AS],      [1], [Assembler program])dnl\n\ntest -z \"$DLLTOOL\" && DLLTOOL=dlltool\n_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl\n\ntest -z \"$OBJDUMP\" && OBJDUMP=objdump\n_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl\n])# win32-dll\n\nAU_DEFUN([AC_LIBTOOL_WIN32_DLL],\n[AC_REQUIRE([AC_CANONICAL_HOST])dnl\n_LT_SET_OPTION([LT_INIT], [win32-dll])\nAC_DIAGNOSE([obsolete],\n[$0: Remove this warning and the call to _LT_SET_OPTION when you\nput the `win32-dll' option into LT_INIT's first parameter.])\n])\n\ndnl aclocal-1.4 backwards compatibility:\ndnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])\n\n\n# _LT_ENABLE_SHARED([DEFAULT])\n# ----------------------------\n# implement the --enable-shared flag, and supports the `shared' and\n# `disable-shared' LT_INIT options.\n# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.\nm4_define([_LT_ENABLE_SHARED],\n[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl\nAC_ARG_ENABLE([shared],\n    [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],\n\t[build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],\n    [p=${PACKAGE-default}\n    case $enableval in\n    yes) enable_shared=yes ;;\n    no) enable_shared=no ;;\n    *)\n      enable_shared=no\n      # Look at the argument we got.  We use all the common list separators.\n      lt_save_ifs=\"$IFS\"; IFS=\"${IFS}$PATH_SEPARATOR,\"\n      for pkg in $enableval; do\n\tIFS=\"$lt_save_ifs\"\n\tif test \"X$pkg\" = \"X$p\"; then\n\t  enable_shared=yes\n\tfi\n      done\n      IFS=\"$lt_save_ifs\"\n      ;;\n    esac],\n    [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)\n\n    _LT_DECL([build_libtool_libs], [enable_shared], [0],\n\t[Whether or not to build shared libraries])\n])# _LT_ENABLE_SHARED\n\nLT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])\nLT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])\n\n# Old names:\nAC_DEFUN([AC_ENABLE_SHARED],\n[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])\n])\n\nAC_DEFUN([AC_DISABLE_SHARED],\n[_LT_SET_OPTION([LT_INIT], [disable-shared])\n])\n\nAU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])\nAU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])\n\ndnl aclocal-1.4 backwards compatibility:\ndnl AC_DEFUN([AM_ENABLE_SHARED], [])\ndnl AC_DEFUN([AM_DISABLE_SHARED], [])\n\n\n\n# _LT_ENABLE_STATIC([DEFAULT])\n# ----------------------------\n# implement the --enable-static flag, and support the `static' and\n# `disable-static' LT_INIT options.\n# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.\nm4_define([_LT_ENABLE_STATIC],\n[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl\nAC_ARG_ENABLE([static],\n    [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],\n\t[build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],\n    [p=${PACKAGE-default}\n    case $enableval in\n    yes) enable_static=yes ;;\n    no) enable_static=no ;;\n    *)\n     enable_static=no\n      # Look at the argument we got.  We use all the common list separators.\n      lt_save_ifs=\"$IFS\"; IFS=\"${IFS}$PATH_SEPARATOR,\"\n      for pkg in $enableval; do\n\tIFS=\"$lt_save_ifs\"\n\tif test \"X$pkg\" = \"X$p\"; then\n\t  enable_static=yes\n\tfi\n      done\n      IFS=\"$lt_save_ifs\"\n      ;;\n    esac],\n    [enable_static=]_LT_ENABLE_STATIC_DEFAULT)\n\n    _LT_DECL([build_old_libs], [enable_static], [0],\n\t[Whether or not to build static libraries])\n])# _LT_ENABLE_STATIC\n\nLT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])\nLT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])\n\n# Old names:\nAC_DEFUN([AC_ENABLE_STATIC],\n[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])\n])\n\nAC_DEFUN([AC_DISABLE_STATIC],\n[_LT_SET_OPTION([LT_INIT], [disable-static])\n])\n\nAU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])\nAU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])\n\ndnl aclocal-1.4 backwards compatibility:\ndnl AC_DEFUN([AM_ENABLE_STATIC], [])\ndnl AC_DEFUN([AM_DISABLE_STATIC], [])\n\n\n\n# _LT_ENABLE_FAST_INSTALL([DEFAULT])\n# ----------------------------------\n# implement the --enable-fast-install flag, and support the `fast-install'\n# and `disable-fast-install' LT_INIT options.\n# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.\nm4_define([_LT_ENABLE_FAST_INSTALL],\n[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl\nAC_ARG_ENABLE([fast-install],\n    [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],\n    [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],\n    [p=${PACKAGE-default}\n    case $enableval in\n    yes) enable_fast_install=yes ;;\n    no) enable_fast_install=no ;;\n    *)\n      enable_fast_install=no\n      # Look at the argument we got.  We use all the common list separators.\n      lt_save_ifs=\"$IFS\"; IFS=\"${IFS}$PATH_SEPARATOR,\"\n      for pkg in $enableval; do\n\tIFS=\"$lt_save_ifs\"\n\tif test \"X$pkg\" = \"X$p\"; then\n\t  enable_fast_install=yes\n\tfi\n      done\n      IFS=\"$lt_save_ifs\"\n      ;;\n    esac],\n    [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)\n\n_LT_DECL([fast_install], [enable_fast_install], [0],\n\t [Whether or not to optimize for fast installation])dnl\n])# _LT_ENABLE_FAST_INSTALL\n\nLT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])\nLT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])\n\n# Old names:\nAU_DEFUN([AC_ENABLE_FAST_INSTALL],\n[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])\nAC_DIAGNOSE([obsolete],\n[$0: Remove this warning and the call to _LT_SET_OPTION when you put\nthe `fast-install' option into LT_INIT's first parameter.])\n])\n\nAU_DEFUN([AC_DISABLE_FAST_INSTALL],\n[_LT_SET_OPTION([LT_INIT], [disable-fast-install])\nAC_DIAGNOSE([obsolete],\n[$0: Remove this warning and the call to _LT_SET_OPTION when you put\nthe `disable-fast-install' option into LT_INIT's first parameter.])\n])\n\ndnl aclocal-1.4 backwards compatibility:\ndnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])\ndnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])\n\n\n# _LT_WITH_PIC([MODE])\n# --------------------\n# implement the --with-pic flag, and support the `pic-only' and `no-pic'\n# LT_INIT options.\n# MODE is either `yes' or `no'.  If omitted, it defaults to `both'.\nm4_define([_LT_WITH_PIC],\n[AC_ARG_WITH([pic],\n    [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],\n\t[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],\n    [lt_p=${PACKAGE-default}\n    case $withval in\n    yes|no) pic_mode=$withval ;;\n    *)\n      pic_mode=default\n      # Look at the argument we got.  We use all the common list separators.\n      lt_save_ifs=\"$IFS\"; IFS=\"${IFS}$PATH_SEPARATOR,\"\n      for lt_pkg in $withval; do\n\tIFS=\"$lt_save_ifs\"\n\tif test \"X$lt_pkg\" = \"X$lt_p\"; then\n\t  pic_mode=yes\n\tfi\n      done\n      IFS=\"$lt_save_ifs\"\n      ;;\n    esac],\n    [pic_mode=default])\n\ntest -z \"$pic_mode\" && pic_mode=m4_default([$1], [default])\n\n_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl\n])# _LT_WITH_PIC\n\nLT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])\nLT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])\n\n# Old name:\nAU_DEFUN([AC_LIBTOOL_PICMODE],\n[_LT_SET_OPTION([LT_INIT], [pic-only])\nAC_DIAGNOSE([obsolete],\n[$0: Remove this warning and the call to _LT_SET_OPTION when you\nput the `pic-only' option into LT_INIT's first parameter.])\n])\n\ndnl aclocal-1.4 backwards compatibility:\ndnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])\n\n## ----------------- ##\n## LTDL_INIT Options ##\n## ----------------- ##\n\nm4_define([_LTDL_MODE], [])\nLT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],\n\t\t [m4_define([_LTDL_MODE], [nonrecursive])])\nLT_OPTION_DEFINE([LTDL_INIT], [recursive],\n\t\t [m4_define([_LTDL_MODE], [recursive])])\nLT_OPTION_DEFINE([LTDL_INIT], [subproject],\n\t\t [m4_define([_LTDL_MODE], [subproject])])\n\nm4_define([_LTDL_TYPE], [])\nLT_OPTION_DEFINE([LTDL_INIT], [installable],\n\t\t [m4_define([_LTDL_TYPE], [installable])])\nLT_OPTION_DEFINE([LTDL_INIT], [convenience],\n\t\t [m4_define([_LTDL_TYPE], [convenience])])\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/m4/ltsugar.m4",
    "content": "# ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-\n#\n# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.\n# Written by Gary V. Vaughan, 2004\n#\n# This file is free software; the Free Software Foundation gives\n# unlimited permission to copy and/or distribute it, with or without\n# modifications, as long as this notice is preserved.\n\n# serial 6 ltsugar.m4\n\n# This is to help aclocal find these macros, as it can't see m4_define.\nAC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])\n\n\n# lt_join(SEP, ARG1, [ARG2...])\n# -----------------------------\n# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their\n# associated separator.\n# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier\n# versions in m4sugar had bugs.\nm4_define([lt_join],\n[m4_if([$#], [1], [],\n       [$#], [2], [[$2]],\n       [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])\nm4_define([_lt_join],\n[m4_if([$#$2], [2], [],\n       [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])\n\n\n# lt_car(LIST)\n# lt_cdr(LIST)\n# ------------\n# Manipulate m4 lists.\n# These macros are necessary as long as will still need to support\n# Autoconf-2.59 which quotes differently.\nm4_define([lt_car], [[$1]])\nm4_define([lt_cdr],\n[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],\n       [$#], 1, [],\n       [m4_dquote(m4_shift($@))])])\nm4_define([lt_unquote], $1)\n\n\n# lt_append(MACRO-NAME, STRING, [SEPARATOR])\n# ------------------------------------------\n# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.\n# Note that neither SEPARATOR nor STRING are expanded; they are appended\n# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).\n# No SEPARATOR is output if MACRO-NAME was previously undefined (different\n# than defined and empty).\n#\n# This macro is needed until we can rely on Autoconf 2.62, since earlier\n# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.\nm4_define([lt_append],\n[m4_define([$1],\n\t   m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])\n\n\n\n# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])\n# ----------------------------------------------------------\n# Produce a SEP delimited list of all paired combinations of elements of\n# PREFIX-LIST with SUFFIX1 through SUFFIXn.  Each element of the list\n# has the form PREFIXmINFIXSUFFIXn.\n# Needed until we can rely on m4_combine added in Autoconf 2.62.\nm4_define([lt_combine],\n[m4_if(m4_eval([$# > 3]), [1],\n       [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl\n[[m4_foreach([_Lt_prefix], [$2],\n\t     [m4_foreach([_Lt_suffix],\n\t\t]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,\n\t[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])\n\n\n# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])\n# -----------------------------------------------------------------------\n# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited\n# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.\nm4_define([lt_if_append_uniq],\n[m4_ifdef([$1],\n\t  [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],\n\t\t [lt_append([$1], [$2], [$3])$4],\n\t\t [$5])],\n\t  [lt_append([$1], [$2], [$3])$4])])\n\n\n# lt_dict_add(DICT, KEY, VALUE)\n# -----------------------------\nm4_define([lt_dict_add],\n[m4_define([$1($2)], [$3])])\n\n\n# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)\n# --------------------------------------------\nm4_define([lt_dict_add_subkey],\n[m4_define([$1($2:$3)], [$4])])\n\n\n# lt_dict_fetch(DICT, KEY, [SUBKEY])\n# ----------------------------------\nm4_define([lt_dict_fetch],\n[m4_ifval([$3],\n\tm4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),\n    m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])\n\n\n# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])\n# -----------------------------------------------------------------\nm4_define([lt_if_dict_fetch],\n[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],\n\t[$5],\n    [$6])])\n\n\n# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])\n# --------------------------------------------------------------\nm4_define([lt_dict_filter],\n[m4_if([$5], [], [],\n  [lt_join(m4_quote(m4_default([$4], [[, ]])),\n           lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),\n\t\t      [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl\n])\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/m4/ltversion.m4",
    "content": "# ltversion.m4 -- version numbers\t\t\t-*- Autoconf -*-\n#\n#   Copyright (C) 2004 Free Software Foundation, Inc.\n#   Written by Scott James Remnant, 2004\n#\n# This file is free software; the Free Software Foundation gives\n# unlimited permission to copy and/or distribute it, with or without\n# modifications, as long as this notice is preserved.\n\n# @configure_input@\n\n# serial 3337 ltversion.m4\n# This file is part of GNU Libtool\n\nm4_define([LT_PACKAGE_VERSION], [2.4.2])\nm4_define([LT_PACKAGE_REVISION], [1.3337])\n\nAC_DEFUN([LTVERSION_VERSION],\n[macro_version='2.4.2'\nmacro_revision='1.3337'\n_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])\n_LT_DECL(, macro_revision, 0)\n])\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/m4/lt~obsolete.m4",
    "content": "# lt~obsolete.m4 -- aclocal satisfying obsolete definitions.    -*-Autoconf-*-\n#\n#   Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.\n#   Written by Scott James Remnant, 2004.\n#\n# This file is free software; the Free Software Foundation gives\n# unlimited permission to copy and/or distribute it, with or without\n# modifications, as long as this notice is preserved.\n\n# serial 5 lt~obsolete.m4\n\n# These exist entirely to fool aclocal when bootstrapping libtool.\n#\n# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)\n# which have later been changed to m4_define as they aren't part of the\n# exported API, or moved to Autoconf or Automake where they belong.\n#\n# The trouble is, aclocal is a bit thick.  It'll see the old AC_DEFUN\n# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us\n# using a macro with the same name in our local m4/libtool.m4 it'll\n# pull the old libtool.m4 in (it doesn't see our shiny new m4_define\n# and doesn't know about Autoconf macros at all.)\n#\n# So we provide this file, which has a silly filename so it's always\n# included after everything else.  This provides aclocal with the\n# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything\n# because those macros already exist, or will be overwritten later.\n# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. \n#\n# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.\n# Yes, that means every name once taken will need to remain here until\n# we give up compatibility with versions before 1.7, at which point\n# we need to keep only those names which we still refer to.\n\n# This is to help aclocal find these macros, as it can't see m4_define.\nAC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])\n\nm4_ifndef([AC_LIBTOOL_LINKER_OPTION],\t[AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])\nm4_ifndef([AC_PROG_EGREP],\t\t[AC_DEFUN([AC_PROG_EGREP])])\nm4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH],\t[AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])\nm4_ifndef([_LT_AC_SHELL_INIT],\t\t[AC_DEFUN([_LT_AC_SHELL_INIT])])\nm4_ifndef([_LT_AC_SYS_LIBPATH_AIX],\t[AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])\nm4_ifndef([_LT_PROG_LTMAIN],\t\t[AC_DEFUN([_LT_PROG_LTMAIN])])\nm4_ifndef([_LT_AC_TAGVAR],\t\t[AC_DEFUN([_LT_AC_TAGVAR])])\nm4_ifndef([AC_LTDL_ENABLE_INSTALL],\t[AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])\nm4_ifndef([AC_LTDL_PREOPEN],\t\t[AC_DEFUN([AC_LTDL_PREOPEN])])\nm4_ifndef([_LT_AC_SYS_COMPILER],\t[AC_DEFUN([_LT_AC_SYS_COMPILER])])\nm4_ifndef([_LT_AC_LOCK],\t\t[AC_DEFUN([_LT_AC_LOCK])])\nm4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE],\t[AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])\nm4_ifndef([_LT_AC_TRY_DLOPEN_SELF],\t[AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])\nm4_ifndef([AC_LIBTOOL_PROG_CC_C_O],\t[AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])\nm4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])\nm4_ifndef([AC_LIBTOOL_OBJDIR],\t\t[AC_DEFUN([AC_LIBTOOL_OBJDIR])])\nm4_ifndef([AC_LTDL_OBJDIR],\t\t[AC_DEFUN([AC_LTDL_OBJDIR])])\nm4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])\nm4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP],\t[AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])\nm4_ifndef([AC_PATH_MAGIC],\t\t[AC_DEFUN([AC_PATH_MAGIC])])\nm4_ifndef([AC_PROG_LD_GNU],\t\t[AC_DEFUN([AC_PROG_LD_GNU])])\nm4_ifndef([AC_PROG_LD_RELOAD_FLAG],\t[AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])\nm4_ifndef([AC_DEPLIBS_CHECK_METHOD],\t[AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])\nm4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])\nm4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])\nm4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])\nm4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS],\t[AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])\nm4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP],\t[AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])\nm4_ifndef([LT_AC_PROG_EGREP],\t\t[AC_DEFUN([LT_AC_PROG_EGREP])])\nm4_ifndef([LT_AC_PROG_SED],\t\t[AC_DEFUN([LT_AC_PROG_SED])])\nm4_ifndef([_LT_CC_BASENAME],\t\t[AC_DEFUN([_LT_CC_BASENAME])])\nm4_ifndef([_LT_COMPILER_BOILERPLATE],\t[AC_DEFUN([_LT_COMPILER_BOILERPLATE])])\nm4_ifndef([_LT_LINKER_BOILERPLATE],\t[AC_DEFUN([_LT_LINKER_BOILERPLATE])])\nm4_ifndef([_AC_PROG_LIBTOOL],\t\t[AC_DEFUN([_AC_PROG_LIBTOOL])])\nm4_ifndef([AC_LIBTOOL_SETUP],\t\t[AC_DEFUN([AC_LIBTOOL_SETUP])])\nm4_ifndef([_LT_AC_CHECK_DLFCN],\t\t[AC_DEFUN([_LT_AC_CHECK_DLFCN])])\nm4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER],\t[AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])\nm4_ifndef([_LT_AC_TAGCONFIG],\t\t[AC_DEFUN([_LT_AC_TAGCONFIG])])\nm4_ifndef([AC_DISABLE_FAST_INSTALL],\t[AC_DEFUN([AC_DISABLE_FAST_INSTALL])])\nm4_ifndef([_LT_AC_LANG_CXX],\t\t[AC_DEFUN([_LT_AC_LANG_CXX])])\nm4_ifndef([_LT_AC_LANG_F77],\t\t[AC_DEFUN([_LT_AC_LANG_F77])])\nm4_ifndef([_LT_AC_LANG_GCJ],\t\t[AC_DEFUN([_LT_AC_LANG_GCJ])])\nm4_ifndef([AC_LIBTOOL_LANG_C_CONFIG],\t[AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])\nm4_ifndef([_LT_AC_LANG_C_CONFIG],\t[AC_DEFUN([_LT_AC_LANG_C_CONFIG])])\nm4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG],\t[AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])\nm4_ifndef([_LT_AC_LANG_CXX_CONFIG],\t[AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])\nm4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG],\t[AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])\nm4_ifndef([_LT_AC_LANG_F77_CONFIG],\t[AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])\nm4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG],\t[AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])\nm4_ifndef([_LT_AC_LANG_GCJ_CONFIG],\t[AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])\nm4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG],\t[AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])\nm4_ifndef([_LT_AC_LANG_RC_CONFIG],\t[AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])\nm4_ifndef([AC_LIBTOOL_CONFIG],\t\t[AC_DEFUN([AC_LIBTOOL_CONFIG])])\nm4_ifndef([_LT_AC_FILE_LTDLL_C],\t[AC_DEFUN([_LT_AC_FILE_LTDLL_C])])\nm4_ifndef([_LT_REQUIRED_DARWIN_CHECKS],\t[AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])\nm4_ifndef([_LT_AC_PROG_CXXCPP],\t\t[AC_DEFUN([_LT_AC_PROG_CXXCPP])])\nm4_ifndef([_LT_PREPARE_SED_QUOTE_VARS],\t[AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])\nm4_ifndef([_LT_PROG_ECHO_BACKSLASH],\t[AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])\nm4_ifndef([_LT_PROG_F77],\t\t[AC_DEFUN([_LT_PROG_F77])])\nm4_ifndef([_LT_PROG_FC],\t\t[AC_DEFUN([_LT_PROG_FC])])\nm4_ifndef([_LT_PROG_CXX],\t\t[AC_DEFUN([_LT_PROG_CXX])])\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/m4/stl_hash.m4",
    "content": "# We check two things: where the include file is for\n# unordered_map/hash_map (we prefer the first form), and what\n# namespace unordered/hash_map lives in within that include file.  We\n# include AC_TRY_COMPILE for all the combinations we've seen in the\n# wild.  We define HASH_MAP_H to the location of the header file, and\n# HASH_NAMESPACE to the namespace the class (unordered_map or\n# hash_map) is in.\n\n# This also checks if unordered map exists.\nAC_DEFUN([AC_CXX_STL_HASH],\n  [\n   AC_MSG_CHECKING(the location of hash_map)\n   AC_LANG_SAVE\n   AC_LANG_CPLUSPLUS\n   ac_cv_cxx_hash_map=\"\"\n   # First try unordered_map, but not on gcc's before 4.2 -- I've\n   # seen unexplainable unordered_map bugs with -O2 on older gcc's.\n   AC_TRY_COMPILE([#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2))\n                   # error GCC too old for unordered_map\n                   #endif\n                   ],\n                   [/* no program body necessary */],\n                   [stl_hash_old_gcc=no],\n                   [stl_hash_old_gcc=yes])\n   for location in unordered_map tr1/unordered_map; do\n     for namespace in std std::tr1; do\n       if test -z \"$ac_cv_cxx_hash_map\" -a \"$stl_hash_old_gcc\" != yes; then\n         # Some older gcc's have a buggy tr1, so test a bit of code.\n         AC_TRY_COMPILE([#include <$location>],\n                        [const ${namespace}::unordered_map<int, int> t;\n                         return t.find(5) == t.end();],\n                        [ac_cv_cxx_hash_map=\"<$location>\";\n                         ac_cv_cxx_hash_namespace=\"$namespace\";\n                         ac_cv_cxx_hash_map_class=\"unordered_map\";])\n       fi\n     done\n   done\n   # Now try hash_map\n   for location in ext/hash_map hash_map; do\n     for namespace in __gnu_cxx \"\" std stdext; do\n       if test -z \"$ac_cv_cxx_hash_map\"; then\n         AC_TRY_COMPILE([#include <$location>],\n                        [${namespace}::hash_map<int, int> t],\n                        [ac_cv_cxx_hash_map=\"<$location>\";\n                         ac_cv_cxx_hash_namespace=\"$namespace\";\n                         ac_cv_cxx_hash_map_class=\"hash_map\";])\n       fi\n     done\n   done\n   ac_cv_cxx_hash_set=`echo \"$ac_cv_cxx_hash_map\" | sed s/map/set/`;\n   ac_cv_cxx_hash_set_class=`echo \"$ac_cv_cxx_hash_map_class\" | sed s/map/set/`;\n   if test -n \"$ac_cv_cxx_hash_map\"; then\n      AC_DEFINE(HAVE_HASH_MAP, 1, [define if the compiler has hash_map])\n      AC_DEFINE(HAVE_HASH_SET, 1, [define if the compiler has hash_set])\n      AC_DEFINE_UNQUOTED(HASH_MAP_H,$ac_cv_cxx_hash_map,\n                         [the location of <unordered_map> or <hash_map>])\n      AC_DEFINE_UNQUOTED(HASH_SET_H,$ac_cv_cxx_hash_set,\n                         [the location of <unordered_set> or <hash_set>])\n      AC_DEFINE_UNQUOTED(HASH_NAMESPACE,$ac_cv_cxx_hash_namespace,\n                         [the namespace of hash_map/hash_set])\n      AC_DEFINE_UNQUOTED(HASH_MAP_CLASS,$ac_cv_cxx_hash_map_class,\n                         [the name of <hash_map>])\n      AC_DEFINE_UNQUOTED(HASH_SET_CLASS,$ac_cv_cxx_hash_set_class,\n                         [the name of <hash_set>])\n      AC_MSG_RESULT([$ac_cv_cxx_hash_map])\n   else\n      AC_MSG_RESULT()\n      AC_MSG_WARN([could not find an STL hash_map])\n   fi\n])\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/missing",
    "content": "#! /bin/sh\n# Common wrapper for a few potentially missing GNU programs.\n\nscriptversion=2013-10-28.13; # UTC\n\n# Copyright (C) 1996-2013 Free Software Foundation, Inc.\n# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.\n\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 2, or (at your option)\n# any later version.\n\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n\n# You should have received a copy of the GNU General Public License\n# along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\n# As a special exception to the GNU General Public License, if you\n# distribute this file as part of a program that contains a\n# configuration script generated by Autoconf, you may include it under\n# the same distribution terms that you use for the rest of that program.\n\nif test $# -eq 0; then\n  echo 1>&2 \"Try '$0 --help' for more information\"\n  exit 1\nfi\n\ncase $1 in\n\n  --is-lightweight)\n    # Used by our autoconf macros to check whether the available missing\n    # script is modern enough.\n    exit 0\n    ;;\n\n  --run)\n    # Back-compat with the calling convention used by older automake.\n    shift\n    ;;\n\n  -h|--h|--he|--hel|--help)\n    echo \"\\\n$0 [OPTION]... PROGRAM [ARGUMENT]...\n\nRun 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due\nto PROGRAM being missing or too old.\n\nOptions:\n  -h, --help      display this help and exit\n  -v, --version   output version information and exit\n\nSupported PROGRAM values:\n  aclocal   autoconf  autoheader   autom4te  automake  makeinfo\n  bison     yacc      flex         lex       help2man\n\nVersion suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and\n'g' are ignored when checking the name.\n\nSend bug reports to <bug-automake@gnu.org>.\"\n    exit $?\n    ;;\n\n  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)\n    echo \"missing $scriptversion (GNU Automake)\"\n    exit $?\n    ;;\n\n  -*)\n    echo 1>&2 \"$0: unknown '$1' option\"\n    echo 1>&2 \"Try '$0 --help' for more information\"\n    exit 1\n    ;;\n\nesac\n\n# Run the given program, remember its exit status.\n\"$@\"; st=$?\n\n# If it succeeded, we are done.\ntest $st -eq 0 && exit 0\n\n# Also exit now if we it failed (or wasn't found), and '--version' was\n# passed; such an option is passed most likely to detect whether the\n# program is present and works.\ncase $2 in --version|--help) exit $st;; esac\n\n# Exit code 63 means version mismatch.  This often happens when the user\n# tries to use an ancient version of a tool on a file that requires a\n# minimum version.\nif test $st -eq 63; then\n  msg=\"probably too old\"\nelif test $st -eq 127; then\n  # Program was missing.\n  msg=\"missing on your system\"\nelse\n  # Program was found and executed, but failed.  Give up.\n  exit $st\nfi\n\nperl_URL=http://www.perl.org/\nflex_URL=http://flex.sourceforge.net/\ngnu_software_URL=http://www.gnu.org/software\n\nprogram_details ()\n{\n  case $1 in\n    aclocal|automake)\n      echo \"The '$1' program is part of the GNU Automake package:\"\n      echo \"<$gnu_software_URL/automake>\"\n      echo \"It also requires GNU Autoconf, GNU m4 and Perl in order to run:\"\n      echo \"<$gnu_software_URL/autoconf>\"\n      echo \"<$gnu_software_URL/m4/>\"\n      echo \"<$perl_URL>\"\n      ;;\n    autoconf|autom4te|autoheader)\n      echo \"The '$1' program is part of the GNU Autoconf package:\"\n      echo \"<$gnu_software_URL/autoconf/>\"\n      echo \"It also requires GNU m4 and Perl in order to run:\"\n      echo \"<$gnu_software_URL/m4/>\"\n      echo \"<$perl_URL>\"\n      ;;\n  esac\n}\n\ngive_advice ()\n{\n  # Normalize program name to check for.\n  normalized_program=`echo \"$1\" | sed '\n    s/^gnu-//; t\n    s/^gnu//; t\n    s/^g//; t'`\n\n  printf '%s\\n' \"'$1' is $msg.\"\n\n  configure_deps=\"'configure.ac' or m4 files included by 'configure.ac'\"\n  case $normalized_program in\n    autoconf*)\n      echo \"You should only need it if you modified 'configure.ac',\"\n      echo \"or m4 files included by it.\"\n      program_details 'autoconf'\n      ;;\n    autoheader*)\n      echo \"You should only need it if you modified 'acconfig.h' or\"\n      echo \"$configure_deps.\"\n      program_details 'autoheader'\n      ;;\n    automake*)\n      echo \"You should only need it if you modified 'Makefile.am' or\"\n      echo \"$configure_deps.\"\n      program_details 'automake'\n      ;;\n    aclocal*)\n      echo \"You should only need it if you modified 'acinclude.m4' or\"\n      echo \"$configure_deps.\"\n      program_details 'aclocal'\n      ;;\n   autom4te*)\n      echo \"You might have modified some maintainer files that require\"\n      echo \"the 'autom4te' program to be rebuilt.\"\n      program_details 'autom4te'\n      ;;\n    bison*|yacc*)\n      echo \"You should only need it if you modified a '.y' file.\"\n      echo \"You may want to install the GNU Bison package:\"\n      echo \"<$gnu_software_URL/bison/>\"\n      ;;\n    lex*|flex*)\n      echo \"You should only need it if you modified a '.l' file.\"\n      echo \"You may want to install the Fast Lexical Analyzer package:\"\n      echo \"<$flex_URL>\"\n      ;;\n    help2man*)\n      echo \"You should only need it if you modified a dependency\" \\\n           \"of a man page.\"\n      echo \"You may want to install the GNU Help2man package:\"\n      echo \"<$gnu_software_URL/help2man/>\"\n    ;;\n    makeinfo*)\n      echo \"You should only need it if you modified a '.texi' file, or\"\n      echo \"any other file indirectly affecting the aspect of the manual.\"\n      echo \"You might want to install the Texinfo package:\"\n      echo \"<$gnu_software_URL/texinfo/>\"\n      echo \"The spurious makeinfo call might also be the consequence of\"\n      echo \"using a buggy 'make' (AIX, DU, IRIX), in which case you might\"\n      echo \"want to install GNU make:\"\n      echo \"<$gnu_software_URL/make/>\"\n      ;;\n    *)\n      echo \"You might have modified some files without having the proper\"\n      echo \"tools for further handling them.  Check the 'README' file, it\"\n      echo \"often tells you about the needed prerequisites for installing\"\n      echo \"this package.  You may also peek at any GNU archive site, in\"\n      echo \"case some other package contains this missing '$1' program.\"\n      ;;\n  esac\n}\n\ngive_advice \"$1\" | sed -e '1s/^/WARNING: /' \\\n                       -e '2,$s/^/         /' >&2\n\n# Propagate the correct exit status (expected to be 127 for a program\n# not found, 63 for a program that failed due to version mismatch).\nexit $st\n\n# Local variables:\n# eval: (add-hook 'write-file-hooks 'time-stamp)\n# time-stamp-start: \"scriptversion=\"\n# time-stamp-format: \"%:y-%02m-%02d.%02H\"\n# time-stamp-time-zone: \"UTC\"\n# time-stamp-end: \"; # UTC\"\n# End:\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/protobuf-lite.pc.in",
    "content": "prefix=@prefix@\nexec_prefix=@exec_prefix@\nlibdir=@libdir@\nincludedir=@includedir@\n\nName: Protocol Buffers\nDescription: Google's Data Interchange Format\nVersion: @VERSION@\nLibs: -L${libdir} -lprotobuf-lite @PTHREAD_CFLAGS@ @PTHREAD_LIBS@\nCflags: -I${includedir} @PTHREAD_CFLAGS@\nConflicts: protobuf\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/protobuf.bzl",
    "content": "# -*- mode: python; -*- PYTHON-PREPROCESSING-REQUIRED\n\ndef _GetPath(ctx, path):\n  if ctx.label.workspace_root:\n    return ctx.label.workspace_root + '/' + path\n  else:\n    return path\n\ndef _GenDir(ctx):\n  if not ctx.attr.includes:\n    return ctx.label.workspace_root\n  if not ctx.attr.includes[0]:\n    return _GetPath(ctx, ctx.label.package)\n  if not ctx.label.package:\n    return _GetPath(ctx, ctx.attr.includes[0])\n  return _GetPath(ctx, ctx.label.package + '/' + ctx.attr.includes[0])\n\ndef _CcOuts(srcs, use_grpc_plugin=False):\n  ret = [s[:-len(\".proto\")] + \".pb.h\" for s in srcs] + \\\n        [s[:-len(\".proto\")] + \".pb.cc\" for s in srcs]\n  if use_grpc_plugin:\n    ret += [s[:-len(\".proto\")] + \".grpc.pb.h\" for s in srcs] + \\\n           [s[:-len(\".proto\")] + \".grpc.pb.cc\" for s in srcs]\n  return ret\n\ndef _PyOuts(srcs):\n  return [s[:-len(\".proto\")] + \"_pb2.py\" for s in srcs]\n\ndef _RelativeOutputPath(path, include, dest=\"\"):\n  if include == None:\n    return path\n\n  if not path.startswith(include):\n    fail(\"Include path %s isn't part of the path %s.\" % (include, path))\n\n  if include and include[-1] != '/':\n    include = include + '/'\n  if dest and dest[-1] != '/':\n    dest = dest + '/'\n\n  path = path[len(include):]\n  return dest + path\n\ndef _proto_gen_impl(ctx):\n  \"\"\"General implementation for generating protos\"\"\"\n  srcs = ctx.files.srcs\n  deps = []\n  deps += ctx.files.srcs\n  gen_dir = _GenDir(ctx)\n  if gen_dir:\n    import_flags = [\"-I\" + gen_dir, \"-I\" + ctx.var[\"GENDIR\"] + \"/\" + gen_dir]\n  else:\n    import_flags = [\"-I.\"]\n\n  for dep in ctx.attr.deps:\n    import_flags += dep.proto.import_flags\n    deps += dep.proto.deps\n\n  args = []\n  if ctx.attr.gen_cc:\n    args += [\"--cpp_out=\" + ctx.var[\"GENDIR\"] + \"/\" + gen_dir]\n  if ctx.attr.gen_py:\n    args += [\"--python_out=\" + ctx.var[\"GENDIR\"] + \"/\" + gen_dir]\n\n  if ctx.executable.grpc_cpp_plugin:\n    args += [\"--plugin=protoc-gen-grpc=\" + ctx.executable.grpc_cpp_plugin.path]\n    args += [\"--grpc_out=\" + ctx.var[\"GENDIR\"] + \"/\" + gen_dir]\n\n  if args:\n    ctx.action(\n        inputs=srcs + deps,\n        outputs=ctx.outputs.outs,\n        arguments=args + import_flags + [s.path for s in srcs],\n        executable=ctx.executable.protoc,\n    )\n\n  return struct(\n      proto=struct(\n          srcs=srcs,\n          import_flags=import_flags,\n          deps=deps,\n      ),\n  )\n\n_proto_gen = rule(\n    attrs = {\n        \"srcs\": attr.label_list(allow_files = True),\n        \"deps\": attr.label_list(providers = [\"proto\"]),\n        \"includes\": attr.string_list(),\n        \"protoc\": attr.label(\n            cfg = HOST_CFG,\n            executable = True,\n            single_file = True,\n            mandatory = True,\n        ),\n        \"grpc_cpp_plugin\": attr.label(\n            cfg = HOST_CFG,\n            executable = True,\n            single_file = True,\n        ),\n        \"gen_cc\": attr.bool(),\n        \"gen_py\": attr.bool(),\n        \"outs\": attr.output_list(),\n    },\n    output_to_genfiles = True,\n    implementation = _proto_gen_impl,\n)\n\ndef cc_proto_library(\n        name,\n        srcs=[],\n        deps=[],\n        cc_libs=[],\n        include=None,\n        protoc=\"//:protoc\",\n        internal_bootstrap_hack=False,\n        use_grpc_plugin=False,\n        default_runtime=\"//:protobuf\",\n        **kargs):\n  \"\"\"Bazel rule to create a C++ protobuf library from proto source files\n\n  NOTE: the rule is only an internal workaround to generate protos. The\n  interface may change and the rule may be removed when bazel has introduced\n  the native rule.\n\n  Args:\n    name: the name of the cc_proto_library.\n    srcs: the .proto files of the cc_proto_library.\n    deps: a list of dependency labels; must be cc_proto_library.\n    cc_libs: a list of other cc_library targets depended by the generated\n        cc_library.\n    include: a string indicating the include path of the .proto files.\n    protoc: the label of the protocol compiler to generate the sources.\n    internal_bootstrap_hack: a flag indicate the cc_proto_library is used only\n        for bootstraping. When it is set to True, no files will be generated.\n        The rule will simply be a provider for .proto files, so that other\n        cc_proto_library can depend on it.\n    use_grpc_plugin: a flag to indicate whether to call the grpc C++ plugin\n        when processing the proto files.\n    default_runtime: the implicitly default runtime which will be depended on by\n        the generated cc_library target.\n    **kargs: other keyword arguments that are passed to cc_library.\n\n  \"\"\"\n\n  includes = []\n  if include != None:\n    includes = [include]\n\n  if internal_bootstrap_hack:\n    # For pre-checked-in generated files, we add the internal_bootstrap_hack\n    # which will skip the codegen action.\n    _proto_gen(\n        name=name + \"_genproto\",\n        srcs=srcs,\n        deps=[s + \"_genproto\" for s in deps],\n        includes=includes,\n        protoc=protoc,\n        visibility=[\"//visibility:public\"],\n    )\n    # An empty cc_library to make rule dependency consistent.\n    native.cc_library(\n        name=name,\n        **kargs)\n    return\n\n  grpc_cpp_plugin = None\n  if use_grpc_plugin:\n    grpc_cpp_plugin = \"//external:grpc_cpp_plugin\"\n\n  outs = _CcOuts(srcs, use_grpc_plugin)\n\n  _proto_gen(\n      name=name + \"_genproto\",\n      srcs=srcs,\n      deps=[s + \"_genproto\" for s in deps],\n      includes=includes,\n      protoc=protoc,\n      grpc_cpp_plugin=grpc_cpp_plugin,\n      gen_cc=1,\n      outs=outs,\n      visibility=[\"//visibility:public\"],\n  )\n\n  if default_runtime and not default_runtime in cc_libs:\n    cc_libs += [default_runtime]\n  if use_grpc_plugin:\n    cc_libs += [\"//external:grpc_lib\"]\n\n  native.cc_library(\n      name=name,\n      srcs=outs,\n      deps=cc_libs + deps,\n      includes=includes,\n      **kargs)\n\n\ndef internal_gen_well_known_protos_java(srcs):\n  \"\"\"Bazel rule to generate the gen_well_known_protos_java genrule\n\n  Args:\n    srcs: the well known protos\n  \"\"\"\n  root = Label(\"%s//protobuf_java\" % (REPOSITORY_NAME)).workspace_root\n  if root == \"\":\n    include = \" -Isrc \"\n  else:\n    include = \" -I%s/src \" % root\n  native.genrule(\n    name = \"gen_well_known_protos_java\",\n    srcs = srcs,\n    outs = [\n        \"wellknown.srcjar\",\n    ],\n    cmd = \"$(location :protoc) --java_out=$(@D)/wellknown.jar\" +\n          \" %s $(SRCS) \" % include +\n          \" && mv $(@D)/wellknown.jar $(@D)/wellknown.srcjar\",\n    tools = [\":protoc\"],\n  )\n\n\ndef internal_copied_filegroup(name, srcs, strip_prefix, dest, **kwargs):\n  \"\"\"Macro to copy files to a different directory and then create a filegroup.\n\n  This is used by the //:protobuf_python py_proto_library target to work around\n  an issue caused by Python source files that are part of the same Python\n  package being in separate directories.\n\n  Args:\n    srcs: The source files to copy and add to the filegroup.\n    strip_prefix: Path to the root of the files to copy.\n    dest: The directory to copy the source files into.\n    **kwargs: extra arguments that will be passesd to the filegroup.\n  \"\"\"\n  outs = [_RelativeOutputPath(s, strip_prefix, dest) for s in srcs]\n\n  native.genrule(\n      name = name + \"_genrule\",\n      srcs = srcs,\n      outs = outs,\n      cmd = \" && \".join(\n          [\"cp $(location %s) $(location %s)\" %\n           (s, _RelativeOutputPath(s, strip_prefix, dest)) for s in srcs]),\n  )\n\n  native.filegroup(\n      name = name,\n      srcs = outs,\n      **kwargs)\n\n\ndef py_proto_library(\n        name,\n        srcs=[],\n        deps=[],\n        py_libs=[],\n        py_extra_srcs=[],\n        include=None,\n        default_runtime=\"//:protobuf_python\",\n        protoc=\"//:protoc\",\n        **kargs):\n  \"\"\"Bazel rule to create a Python protobuf library from proto source files\n\n  NOTE: the rule is only an internal workaround to generate protos. The\n  interface may change and the rule may be removed when bazel has introduced\n  the native rule.\n\n  Args:\n    name: the name of the py_proto_library.\n    srcs: the .proto files of the py_proto_library.\n    deps: a list of dependency labels; must be py_proto_library.\n    py_libs: a list of other py_library targets depended by the generated\n        py_library.\n    py_extra_srcs: extra source files that will be added to the output\n        py_library. This attribute is used for internal bootstrapping.\n    include: a string indicating the include path of the .proto files.\n    default_runtime: the implicitly default runtime which will be depended on by\n        the generated py_library target.\n    protoc: the label of the protocol compiler to generate the sources.\n    **kargs: other keyword arguments that are passed to cc_library.\n\n  \"\"\"\n  outs = _PyOuts(srcs)\n\n  includes = []\n  if include != None:\n    includes = [include]\n\n  _proto_gen(\n      name=name + \"_genproto\",\n      srcs=srcs,\n      deps=[s + \"_genproto\" for s in deps],\n      includes=includes,\n      protoc=protoc,\n      gen_py=1,\n      outs=outs,\n      visibility=[\"//visibility:public\"],\n  )\n\n  if default_runtime and not default_runtime in py_libs + deps:\n    py_libs += [default_runtime]\n\n  native.py_library(\n      name=name,\n      srcs=outs+py_extra_srcs,\n      deps=py_libs+deps,\n      imports=includes,\n      **kargs)\n\ndef internal_protobuf_py_tests(\n    name,\n    modules=[],\n    **kargs):\n  \"\"\"Bazel rules to create batch tests for protobuf internal.\n\n  Args:\n    name: the name of the rule.\n    modules: a list of modules for tests. The macro will create a py_test for\n        each of the parameter with the source \"google/protobuf/%s.py\"\n    kargs: extra parameters that will be passed into the py_test.\n\n  \"\"\"\n  for m in modules:\n    s = \"python/google/protobuf/internal/%s.py\" % m\n    native.py_test(\n        name=\"py_%s\" % m,\n        srcs=[s],\n        main=s,\n        **kargs)\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/protobuf.pc.in",
    "content": "prefix=@prefix@\nexec_prefix=@exec_prefix@\nlibdir=@libdir@\nincludedir=@includedir@\n\nName: Protocol Buffers\nDescription: Google's Data Interchange Format\nVersion: @VERSION@\nLibs: -L${libdir} -lprotobuf @PTHREAD_CFLAGS@ @PTHREAD_LIBS@\nLibs.private: @LIBS@\nCflags: -I${includedir} @PTHREAD_CFLAGS@\nConflicts: protobuf-lite\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/six.BUILD",
    "content": "genrule(\n  name = \"copy_six\",\n  srcs = [\"six-1.10.0/six.py\"],\n  outs = [\"six.py\"],\n  cmd = \"cp $< $(@)\",\n)\n\npy_library(\n  name = \"six\",\n  srcs = [\"six.py\"],\n  srcs_version = \"PY2AND3\",\n  visibility = [\"//visibility:public\"],\n)\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/Makefile.am",
    "content": "## Process this file with automake to produce Makefile.in\n\nif HAVE_ZLIB\nGZCHECKPROGRAMS = zcgzip zcgunzip\nGZHEADERS = google/protobuf/io/gzip_stream.h\nGZTESTS = google/protobuf/io/gzip_stream_unittest.sh\nZLIB_DEF = -DHAVE_ZLIB=1\nelse\nGZCHECKPROGRAMS =\nGZHEADERS =\nGZTESTS =\nZLIB_DEF =\nendif\n\nif HAVE_PTHREAD\nPTHREAD_DEF = -DHAVE_PTHREAD=1\nelse\nPTHREAD_DEF =\nendif\n\nif GCC\n# Turn on all warnings except for sign comparison (we ignore sign comparison\n# in Google so our code base have tons of such warnings).\nNO_OPT_CXXFLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_DEF) $(ZLIB_DEF) -Wall -Wno-sign-compare\nelse\nNO_OPT_CXXFLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_DEF) $(ZLIB_DEF)\nendif\n\nAM_CXXFLAGS = $(NO_OPT_CXXFLAGS) $(PROTOBUF_OPT_FLAG)\n\nAM_LDFLAGS = $(PTHREAD_CFLAGS)\n\n# If I say \"dist_include_DATA\", automake complains that $(includedir) is not\n# a \"legitimate\" directory for DATA.  Screw you, automake.\nprotodir = $(includedir)\nnobase_dist_proto_DATA = google/protobuf/descriptor.proto     \\\n                         google/protobuf/any.proto            \\\n                         google/protobuf/api.proto            \\\n                         google/protobuf/duration.proto       \\\n                         google/protobuf/empty.proto          \\\n                         google/protobuf/field_mask.proto     \\\n                         google/protobuf/source_context.proto \\\n                         google/protobuf/struct.proto         \\\n                         google/protobuf/timestamp.proto      \\\n                         google/protobuf/type.proto           \\\n                         google/protobuf/wrappers.proto       \\\n                         google/protobuf/compiler/plugin.proto\n\n# Not sure why these don't get cleaned automatically.\nclean-local:\n\trm -f *.loT\n\nCLEANFILES = $(protoc_outputs) unittest_proto_middleman \\\n             testzip.jar testzip.list testzip.proto testzip.zip \\\n             no_warning_test.cc\n\nMAINTAINERCLEANFILES =   \\\n  Makefile.in\n\nnobase_include_HEADERS =                                        \\\n  google/protobuf/stubs/atomic_sequence_num.h                   \\\n  google/protobuf/stubs/atomicops.h                             \\\n  google/protobuf/stubs/atomicops_internals_power.h             \\\n  google/protobuf/stubs/atomicops_internals_ppc_gcc.h           \\\n  google/protobuf/stubs/atomicops_internals_arm64_gcc.h         \\\n  google/protobuf/stubs/atomicops_internals_arm_gcc.h           \\\n  google/protobuf/stubs/atomicops_internals_arm_qnx.h           \\\n  google/protobuf/stubs/atomicops_internals_atomicword_compat.h \\\n  google/protobuf/stubs/atomicops_internals_generic_gcc.h       \\\n  google/protobuf/stubs/atomicops_internals_macosx.h            \\\n  google/protobuf/stubs/atomicops_internals_mips_gcc.h          \\\n  google/protobuf/stubs/atomicops_internals_pnacl.h             \\\n  google/protobuf/stubs/atomicops_internals_solaris.h           \\\n  google/protobuf/stubs/atomicops_internals_tsan.h              \\\n  google/protobuf/stubs/atomicops_internals_x86_gcc.h           \\\n  google/protobuf/stubs/atomicops_internals_x86_msvc.h          \\\n  google/protobuf/stubs/callback.h                              \\\n  google/protobuf/stubs/bytestream.h                            \\\n  google/protobuf/stubs/casts.h                                 \\\n  google/protobuf/stubs/common.h                                \\\n  google/protobuf/stubs/fastmem.h                               \\\n  google/protobuf/stubs/hash.h                                  \\\n  google/protobuf/stubs/logging.h                               \\\n  google/protobuf/stubs/macros.h                                \\\n  google/protobuf/stubs/mutex.h                                 \\\n  google/protobuf/stubs/once.h                                  \\\n  google/protobuf/stubs/platform_macros.h                       \\\n  google/protobuf/stubs/port.h                                  \\\n  google/protobuf/stubs/scoped_ptr.h                            \\\n  google/protobuf/stubs/shared_ptr.h                            \\\n  google/protobuf/stubs/singleton.h                             \\\n  google/protobuf/stubs/status.h                                \\\n  google/protobuf/stubs/stl_util.h                              \\\n  google/protobuf/stubs/stringpiece.h                           \\\n  google/protobuf/stubs/template_util.h                         \\\n  google/protobuf/stubs/type_traits.h                           \\\n  google/protobuf/any.pb.h                                      \\\n  google/protobuf/api.pb.h                                      \\\n  google/protobuf/any.h                                         \\\n  google/protobuf/arena.h                                       \\\n  google/protobuf/arenastring.h                                 \\\n  google/protobuf/descriptor_database.h                         \\\n  google/protobuf/descriptor.h                                  \\\n  google/protobuf/descriptor.pb.h                               \\\n  google/protobuf/duration.pb.h                                 \\\n  google/protobuf/dynamic_message.h                             \\\n  google/protobuf/empty.pb.h                                    \\\n  google/protobuf/extension_set.h                               \\\n  google/protobuf/field_mask.pb.h                               \\\n  google/protobuf/generated_enum_reflection.h                   \\\n  google/protobuf/generated_enum_util.h                         \\\n  google/protobuf/generated_message_reflection.h                \\\n  google/protobuf/generated_message_util.h                      \\\n  google/protobuf/map_entry.h                                   \\\n  google/protobuf/map_entry_lite.h                              \\\n  google/protobuf/map_field.h                                   \\\n  google/protobuf/map_field_inl.h                               \\\n  google/protobuf/map_field_lite.h                              \\\n  google/protobuf/map.h                                         \\\n  google/protobuf/map_type_handler.h                            \\\n  google/protobuf/message.h                                     \\\n  google/protobuf/message_lite.h                                \\\n  google/protobuf/metadata.h                                    \\\n  google/protobuf/reflection.h                                  \\\n  google/protobuf/reflection_ops.h                              \\\n  google/protobuf/repeated_field.h                              \\\n  google/protobuf/service.h                                     \\\n  google/protobuf/source_context.pb.h                           \\\n  google/protobuf/struct.pb.h                                   \\\n  google/protobuf/text_format.h                                 \\\n  google/protobuf/timestamp.pb.h                                \\\n  google/protobuf/type.pb.h                                     \\\n  google/protobuf/unknown_field_set.h                           \\\n  google/protobuf/wire_format.h                                 \\\n  google/protobuf/wire_format_lite.h                            \\\n  google/protobuf/wire_format_lite_inl.h                        \\\n  google/protobuf/wrappers.pb.h                                 \\\n  google/protobuf/io/coded_stream.h                             \\\n  $(GZHEADERS)                                                  \\\n  google/protobuf/io/printer.h                                  \\\n  google/protobuf/io/strtod.h                                   \\\n  google/protobuf/io/tokenizer.h                                \\\n  google/protobuf/io/zero_copy_stream.h                         \\\n  google/protobuf/io/zero_copy_stream_impl.h                    \\\n  google/protobuf/io/zero_copy_stream_impl_lite.h               \\\n  google/protobuf/compiler/code_generator.h                     \\\n  google/protobuf/compiler/command_line_interface.h             \\\n  google/protobuf/compiler/importer.h                           \\\n  google/protobuf/compiler/parser.h                             \\\n  google/protobuf/compiler/plugin.h                             \\\n  google/protobuf/compiler/plugin.pb.h                          \\\n  google/protobuf/compiler/cpp/cpp_generator.h                  \\\n  google/protobuf/compiler/csharp/csharp_generator.h            \\\n  google/protobuf/compiler/csharp/csharp_names.h                \\\n  google/protobuf/compiler/java/java_generator.h                \\\n  google/protobuf/compiler/java/java_names.h                    \\\n  google/protobuf/compiler/javanano/javanano_generator.h        \\\n  google/protobuf/compiler/js/js_generator.h                    \\\n  google/protobuf/compiler/objectivec/objectivec_generator.h    \\\n  google/protobuf/compiler/objectivec/objectivec_helpers.h      \\\n  google/protobuf/compiler/python/python_generator.h            \\\n  google/protobuf/compiler/ruby/ruby_generator.h                \\\n  google/protobuf/util/type_resolver.h                          \\\n  google/protobuf/util/field_comparator.h                       \\\n  google/protobuf/util/field_mask_util.h                        \\\n  google/protobuf/util/json_util.h                              \\\n  google/protobuf/util/time_util.h                              \\\n  google/protobuf/util/type_resolver_util.h                     \\\n  google/protobuf/util/message_differencer.h\n\nlib_LTLIBRARIES = libprotobuf-lite.la libprotobuf.la libprotoc.la\n\nlibprotobuf_lite_la_LIBADD = $(PTHREAD_LIBS)\nlibprotobuf_lite_la_LDFLAGS = -version-info 10:0:0 -export-dynamic -no-undefined\nlibprotobuf_lite_la_SOURCES =                                  \\\n  google/protobuf/stubs/atomicops_internals_x86_gcc.cc         \\\n  google/protobuf/stubs/atomicops_internals_x86_msvc.cc        \\\n  google/protobuf/stubs/bytestream.cc                          \\\n  google/protobuf/stubs/bytestream.h                           \\\n  google/protobuf/stubs/common.cc                              \\\n  google/protobuf/stubs/hash.h                                 \\\n  google/protobuf/stubs/int128.cc                              \\\n  google/protobuf/stubs/int128.h                               \\\n  google/protobuf/stubs/map_util.h                             \\\n  google/protobuf/stubs/mathutil.h                             \\\n  google/protobuf/stubs/once.cc                                \\\n  google/protobuf/stubs/shared_ptr.h                           \\\n  google/protobuf/stubs/status.cc                              \\\n  google/protobuf/stubs/status.h                               \\\n  google/protobuf/stubs/status_macros.h                        \\\n  google/protobuf/stubs/statusor.cc                            \\\n  google/protobuf/stubs/statusor.h                             \\\n  google/protobuf/stubs/stringpiece.cc                         \\\n  google/protobuf/stubs/stringpiece.h                          \\\n  google/protobuf/stubs/stringprintf.cc                        \\\n  google/protobuf/stubs/stringprintf.h                         \\\n  google/protobuf/stubs/structurally_valid.cc                  \\\n  google/protobuf/stubs/strutil.cc                             \\\n  google/protobuf/stubs/strutil.h                              \\\n  google/protobuf/stubs/time.cc                                \\\n  google/protobuf/stubs/time.h                                 \\\n  google/protobuf/arena.cc                                     \\\n  google/protobuf/arenastring.cc                               \\\n  google/protobuf/extension_set.cc                             \\\n  google/protobuf/generated_message_util.cc                    \\\n  google/protobuf/message_lite.cc                              \\\n  google/protobuf/repeated_field.cc                            \\\n  google/protobuf/wire_format_lite.cc                          \\\n  google/protobuf/io/coded_stream.cc                           \\\n  google/protobuf/io/coded_stream_inl.h                        \\\n  google/protobuf/io/zero_copy_stream.cc                       \\\n  google/protobuf/io/zero_copy_stream_impl_lite.cc\n\nlibprotobuf_la_LIBADD = $(PTHREAD_LIBS)\nlibprotobuf_la_LDFLAGS = -version-info 10:0:0 -export-dynamic -no-undefined\nlibprotobuf_la_SOURCES =                                       \\\n  $(libprotobuf_lite_la_SOURCES)                               \\\n  google/protobuf/any.pb.cc                                    \\\n  google/protobuf/api.pb.cc                                    \\\n  google/protobuf/stubs/mathlimits.cc                          \\\n  google/protobuf/stubs/mathlimits.h                           \\\n  google/protobuf/any.cc                                       \\\n  google/protobuf/descriptor.cc                                \\\n  google/protobuf/descriptor_database.cc                       \\\n  google/protobuf/descriptor.pb.cc                             \\\n  google/protobuf/duration.pb.cc                               \\\n  google/protobuf/dynamic_message.cc                           \\\n  google/protobuf/empty.pb.cc                                  \\\n  google/protobuf/extension_set_heavy.cc                       \\\n  google/protobuf/field_mask.pb.cc                             \\\n  google/protobuf/generated_message_reflection.cc              \\\n  google/protobuf/map_field.cc                                 \\\n  google/protobuf/message.cc                                   \\\n  google/protobuf/reflection_internal.h                        \\\n  google/protobuf/reflection_ops.cc                            \\\n  google/protobuf/service.cc                                   \\\n  google/protobuf/source_context.pb.cc                         \\\n  google/protobuf/struct.pb.cc                                 \\\n  google/protobuf/stubs/substitute.cc                          \\\n  google/protobuf/stubs/substitute.h                           \\\n  google/protobuf/text_format.cc                               \\\n  google/protobuf/timestamp.pb.cc                              \\\n  google/protobuf/type.pb.cc                                   \\\n  google/protobuf/unknown_field_set.cc                         \\\n  google/protobuf/wire_format.cc                               \\\n  google/protobuf/wrappers.pb.cc                               \\\n  google/protobuf/io/gzip_stream.cc                            \\\n  google/protobuf/io/printer.cc                                \\\n  google/protobuf/io/strtod.cc                                 \\\n  google/protobuf/io/tokenizer.cc                              \\\n  google/protobuf/io/zero_copy_stream_impl.cc                  \\\n  google/protobuf/compiler/importer.cc                         \\\n  google/protobuf/compiler/parser.cc                           \\\n  google/protobuf/util/field_comparator.cc                     \\\n  google/protobuf/util/field_mask_util.cc                      \\\n  google/protobuf/util/internal/constants.h                    \\\n  google/protobuf/util/internal/datapiece.cc                   \\\n  google/protobuf/util/internal/datapiece.h                    \\\n  google/protobuf/util/internal/default_value_objectwriter.cc  \\\n  google/protobuf/util/internal/default_value_objectwriter.h   \\\n  google/protobuf/util/internal/error_listener.cc              \\\n  google/protobuf/util/internal/error_listener.h               \\\n  google/protobuf/util/internal/expecting_objectwriter.h       \\\n  google/protobuf/util/internal/field_mask_utility.cc          \\\n  google/protobuf/util/internal/field_mask_utility.h           \\\n  google/protobuf/util/internal/json_escaping.cc               \\\n  google/protobuf/util/internal/json_escaping.h                \\\n  google/protobuf/util/internal/json_objectwriter.cc           \\\n  google/protobuf/util/internal/json_objectwriter.h            \\\n  google/protobuf/util/internal/json_stream_parser.cc          \\\n  google/protobuf/util/internal/json_stream_parser.h           \\\n  google/protobuf/util/internal/location_tracker.h             \\\n  google/protobuf/util/internal/mock_error_listener.h          \\\n  google/protobuf/util/internal/object_location_tracker.h      \\\n  google/protobuf/util/internal/object_source.h                \\\n  google/protobuf/util/internal/object_writer.cc               \\\n  google/protobuf/util/internal/object_writer.h                \\\n  google/protobuf/util/internal/protostream_objectsource.cc    \\\n  google/protobuf/util/internal/protostream_objectsource.h     \\\n  google/protobuf/util/internal/protostream_objectwriter.cc    \\\n  google/protobuf/util/internal/protostream_objectwriter.h     \\\n  google/protobuf/util/internal/proto_writer.cc                \\\n  google/protobuf/util/internal/proto_writer.h                 \\\n  google/protobuf/util/internal/structured_objectwriter.h      \\\n  google/protobuf/util/internal/type_info.cc                   \\\n  google/protobuf/util/internal/type_info.h                    \\\n  google/protobuf/util/internal/type_info_test_helper.cc       \\\n  google/protobuf/util/internal/type_info_test_helper.h        \\\n  google/protobuf/util/internal/utility.cc                     \\\n  google/protobuf/util/internal/utility.h                      \\\n  google/protobuf/util/json_util.cc                            \\\n  google/protobuf/util/message_differencer.cc                  \\\n  google/protobuf/util/time_util.cc                            \\\n  google/protobuf/util/type_resolver_util.cc\n\nnodist_libprotobuf_la_SOURCES = $(nodist_libprotobuf_lite_la_SOURCES)\n\nlibprotoc_la_LIBADD = $(PTHREAD_LIBS) libprotobuf.la\nlibprotoc_la_LDFLAGS = -version-info 10:0:0 -export-dynamic -no-undefined\nlibprotoc_la_SOURCES =                                         \\\n  google/protobuf/compiler/code_generator.cc                   \\\n  google/protobuf/compiler/command_line_interface.cc           \\\n  google/protobuf/compiler/plugin.cc                           \\\n  google/protobuf/compiler/plugin.pb.cc                        \\\n  google/protobuf/compiler/subprocess.cc                       \\\n  google/protobuf/compiler/subprocess.h                        \\\n  google/protobuf/compiler/zip_writer.cc                       \\\n  google/protobuf/compiler/zip_writer.h                        \\\n  google/protobuf/compiler/cpp/cpp_enum.cc                     \\\n  google/protobuf/compiler/cpp/cpp_enum.h                      \\\n  google/protobuf/compiler/cpp/cpp_enum_field.cc               \\\n  google/protobuf/compiler/cpp/cpp_enum_field.h                \\\n  google/protobuf/compiler/cpp/cpp_extension.cc                \\\n  google/protobuf/compiler/cpp/cpp_extension.h                 \\\n  google/protobuf/compiler/cpp/cpp_field.cc                    \\\n  google/protobuf/compiler/cpp/cpp_field.h                     \\\n  google/protobuf/compiler/cpp/cpp_file.cc                     \\\n  google/protobuf/compiler/cpp/cpp_file.h                      \\\n  google/protobuf/compiler/cpp/cpp_generator.cc                \\\n  google/protobuf/compiler/cpp/cpp_helpers.cc                  \\\n  google/protobuf/compiler/cpp/cpp_helpers.h                   \\\n  google/protobuf/compiler/cpp/cpp_map_field.cc                \\\n  google/protobuf/compiler/cpp/cpp_map_field.h                 \\\n  google/protobuf/compiler/cpp/cpp_message.cc                  \\\n  google/protobuf/compiler/cpp/cpp_message.h                   \\\n  google/protobuf/compiler/cpp/cpp_message_field.cc            \\\n  google/protobuf/compiler/cpp/cpp_message_field.h             \\\n  google/protobuf/compiler/cpp/cpp_options.h                   \\\n  google/protobuf/compiler/cpp/cpp_primitive_field.cc          \\\n  google/protobuf/compiler/cpp/cpp_primitive_field.h           \\\n  google/protobuf/compiler/cpp/cpp_service.cc                  \\\n  google/protobuf/compiler/cpp/cpp_service.h                   \\\n  google/protobuf/compiler/cpp/cpp_string_field.cc             \\\n  google/protobuf/compiler/cpp/cpp_string_field.h              \\\n  google/protobuf/compiler/java/java_context.cc                \\\n  google/protobuf/compiler/java/java_context.h                 \\\n  google/protobuf/compiler/java/java_enum.cc                   \\\n  google/protobuf/compiler/java/java_enum_lite.cc              \\\n  google/protobuf/compiler/java/java_enum_field.cc             \\\n  google/protobuf/compiler/java/java_enum_field.h              \\\n  google/protobuf/compiler/java/java_enum_field_lite.cc        \\\n  google/protobuf/compiler/java/java_enum_field_lite.h         \\\n  google/protobuf/compiler/java/java_enum.h                    \\\n  google/protobuf/compiler/java/java_enum_lite.h               \\\n  google/protobuf/compiler/java/java_extension.cc              \\\n  google/protobuf/compiler/java/java_extension.h               \\\n  google/protobuf/compiler/java/java_extension_lite.cc         \\\n  google/protobuf/compiler/java/java_extension_lite.h          \\\n  google/protobuf/compiler/java/java_field.cc                  \\\n  google/protobuf/compiler/java/java_field.h                   \\\n  google/protobuf/compiler/java/java_file.cc                   \\\n  google/protobuf/compiler/java/java_file.h                    \\\n  google/protobuf/compiler/java/java_generator.cc              \\\n  google/protobuf/compiler/java/java_generator_factory.cc      \\\n  google/protobuf/compiler/java/java_generator_factory.h       \\\n  google/protobuf/compiler/java/java_helpers.cc                \\\n  google/protobuf/compiler/java/java_helpers.h                 \\\n  google/protobuf/compiler/java/java_lazy_message_field.cc     \\\n  google/protobuf/compiler/java/java_lazy_message_field.h      \\\n  google/protobuf/compiler/java/java_lazy_message_field_lite.cc\\\n  google/protobuf/compiler/java/java_lazy_message_field_lite.h \\\n  google/protobuf/compiler/java/java_map_field.cc              \\\n  google/protobuf/compiler/java/java_map_field.h               \\\n  google/protobuf/compiler/java/java_map_field_lite.cc         \\\n  google/protobuf/compiler/java/java_map_field_lite.h          \\\n  google/protobuf/compiler/java/java_message.cc                \\\n  google/protobuf/compiler/java/java_message_lite.cc           \\\n  google/protobuf/compiler/java/java_message_builder.cc        \\\n  google/protobuf/compiler/java/java_message_builder_lite.cc   \\\n  google/protobuf/compiler/java/java_message_field.cc          \\\n  google/protobuf/compiler/java/java_message_field.h           \\\n  google/protobuf/compiler/java/java_message_field_lite.cc     \\\n  google/protobuf/compiler/java/java_message_field_lite.h      \\\n  google/protobuf/compiler/java/java_message.h                 \\\n  google/protobuf/compiler/java/java_message_lite.h            \\\n  google/protobuf/compiler/java/java_message_builder.h         \\\n  google/protobuf/compiler/java/java_message_builder_lite.h    \\\n  google/protobuf/compiler/java/java_name_resolver.cc          \\\n  google/protobuf/compiler/java/java_name_resolver.h           \\\n  google/protobuf/compiler/java/java_options.h                 \\\n  google/protobuf/compiler/java/java_primitive_field.cc        \\\n  google/protobuf/compiler/java/java_primitive_field.h         \\\n  google/protobuf/compiler/java/java_primitive_field_lite.cc   \\\n  google/protobuf/compiler/java/java_primitive_field_lite.h    \\\n  google/protobuf/compiler/java/java_shared_code_generator.cc  \\\n  google/protobuf/compiler/java/java_shared_code_generator.h   \\\n  google/protobuf/compiler/java/java_service.cc                \\\n  google/protobuf/compiler/java/java_service.h                 \\\n  google/protobuf/compiler/java/java_string_field.cc           \\\n  google/protobuf/compiler/java/java_string_field.h            \\\n  google/protobuf/compiler/java/java_string_field_lite.cc      \\\n  google/protobuf/compiler/java/java_string_field_lite.h       \\\n  google/protobuf/compiler/java/java_doc_comment.cc            \\\n  google/protobuf/compiler/java/java_doc_comment.h             \\\n  google/protobuf/compiler/js/js_generator.cc                  \\\n  google/protobuf/compiler/javanano/javanano_enum.cc           \\\n  google/protobuf/compiler/javanano/javanano_enum.h            \\\n  google/protobuf/compiler/javanano/javanano_enum_field.cc     \\\n  google/protobuf/compiler/javanano/javanano_enum_field.h      \\\n  google/protobuf/compiler/javanano/javanano_extension.cc      \\\n  google/protobuf/compiler/javanano/javanano_extension.h       \\\n  google/protobuf/compiler/javanano/javanano_field.cc          \\\n  google/protobuf/compiler/javanano/javanano_field.h           \\\n  google/protobuf/compiler/javanano/javanano_file.cc           \\\n  google/protobuf/compiler/javanano/javanano_file.h            \\\n  google/protobuf/compiler/javanano/javanano_generator.cc      \\\n  google/protobuf/compiler/javanano/javanano_generator.h       \\\n  google/protobuf/compiler/javanano/javanano_helpers.cc        \\\n  google/protobuf/compiler/javanano/javanano_helpers.h         \\\n  google/protobuf/compiler/javanano/javanano_map_field.cc      \\\n  google/protobuf/compiler/javanano/javanano_map_field.h       \\\n  google/protobuf/compiler/javanano/javanano_message.cc        \\\n  google/protobuf/compiler/javanano/javanano_message.h         \\\n  google/protobuf/compiler/javanano/javanano_message_field.cc  \\\n  google/protobuf/compiler/javanano/javanano_message_field.h   \\\n  google/protobuf/compiler/javanano/javanano_params.h          \\\n  google/protobuf/compiler/javanano/javanano_primitive_field.cc \\\n  google/protobuf/compiler/javanano/javanano_primitive_field.h \\\n  google/protobuf/compiler/objectivec/objectivec_enum.cc       \\\n  google/protobuf/compiler/objectivec/objectivec_enum.h        \\\n  google/protobuf/compiler/objectivec/objectivec_enum_field.cc \\\n  google/protobuf/compiler/objectivec/objectivec_enum_field.h  \\\n  google/protobuf/compiler/objectivec/objectivec_extension.cc  \\\n  google/protobuf/compiler/objectivec/objectivec_extension.h   \\\n  google/protobuf/compiler/objectivec/objectivec_field.cc      \\\n  google/protobuf/compiler/objectivec/objectivec_field.h       \\\n  google/protobuf/compiler/objectivec/objectivec_file.cc       \\\n  google/protobuf/compiler/objectivec/objectivec_file.h        \\\n  google/protobuf/compiler/objectivec/objectivec_generator.cc  \\\n  google/protobuf/compiler/objectivec/objectivec_helpers.cc    \\\n  google/protobuf/compiler/objectivec/objectivec_helpers.h     \\\n  google/protobuf/compiler/objectivec/objectivec_map_field.cc  \\\n  google/protobuf/compiler/objectivec/objectivec_map_field.h   \\\n  google/protobuf/compiler/objectivec/objectivec_message.cc    \\\n  google/protobuf/compiler/objectivec/objectivec_message.h     \\\n  google/protobuf/compiler/objectivec/objectivec_message_field.cc \\\n  google/protobuf/compiler/objectivec/objectivec_message_field.h \\\n  google/protobuf/compiler/objectivec/objectivec_oneof.cc      \\\n  google/protobuf/compiler/objectivec/objectivec_oneof.h       \\\n  google/protobuf/compiler/objectivec/objectivec_primitive_field.cc \\\n  google/protobuf/compiler/objectivec/objectivec_primitive_field.h \\\n  google/protobuf/compiler/python/python_generator.cc          \\\n  google/protobuf/compiler/ruby/ruby_generator.cc              \\\n  google/protobuf/compiler/csharp/csharp_doc_comment.cc        \\\n  google/protobuf/compiler/csharp/csharp_doc_comment.h         \\\n  google/protobuf/compiler/csharp/csharp_enum.cc               \\\n  google/protobuf/compiler/csharp/csharp_enum.h                \\\n  google/protobuf/compiler/csharp/csharp_enum_field.cc         \\\n  google/protobuf/compiler/csharp/csharp_enum_field.h          \\\n  google/protobuf/compiler/csharp/csharp_field_base.cc         \\\n  google/protobuf/compiler/csharp/csharp_field_base.h          \\\n  google/protobuf/compiler/csharp/csharp_generator.cc          \\\n  google/protobuf/compiler/csharp/csharp_helpers.cc            \\\n  google/protobuf/compiler/csharp/csharp_helpers.h             \\\n  google/protobuf/compiler/csharp/csharp_map_field.cc          \\\n  google/protobuf/compiler/csharp/csharp_map_field.h           \\\n  google/protobuf/compiler/csharp/csharp_message.cc            \\\n  google/protobuf/compiler/csharp/csharp_message.h             \\\n  google/protobuf/compiler/csharp/csharp_message_field.cc      \\\n  google/protobuf/compiler/csharp/csharp_message_field.h       \\\n  google/protobuf/compiler/csharp/csharp_options.h             \\\n  google/protobuf/compiler/csharp/csharp_primitive_field.cc    \\\n  google/protobuf/compiler/csharp/csharp_primitive_field.h     \\\n  google/protobuf/compiler/csharp/csharp_reflection_class.cc     \\\n  google/protobuf/compiler/csharp/csharp_reflection_class.h      \\\n  google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc \\\n  google/protobuf/compiler/csharp/csharp_repeated_enum_field.h \\\n  google/protobuf/compiler/csharp/csharp_repeated_message_field.cc \\\n  google/protobuf/compiler/csharp/csharp_repeated_message_field.h \\\n  google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc \\\n  google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h \\\n  google/protobuf/compiler/csharp/csharp_source_generator_base.cc \\\n  google/protobuf/compiler/csharp/csharp_source_generator_base.h \\\n  google/protobuf/compiler/csharp/csharp_wrapper_field.cc      \\\n  google/protobuf/compiler/csharp/csharp_wrapper_field.h\n\nbin_PROGRAMS = protoc\nprotoc_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la\nprotoc_SOURCES = google/protobuf/compiler/main.cc\n\n# Tests ==============================================================\n\nprotoc_inputs =                                                   \\\n  google/protobuf/any_test.proto                                  \\\n  google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto     \\\n  google/protobuf/map_lite_unittest.proto                         \\\n  google/protobuf/map_proto2_unittest.proto                       \\\n  google/protobuf/map_unittest.proto                              \\\n  google/protobuf/unittest_arena.proto                            \\\n  google/protobuf/unittest_custom_options.proto                   \\\n  google/protobuf/unittest_drop_unknown_fields.proto              \\\n  google/protobuf/unittest_embed_optimize_for.proto               \\\n  google/protobuf/unittest_empty.proto                            \\\n  google/protobuf/unittest_enormous_descriptor.proto              \\\n  google/protobuf/unittest_import_lite.proto                      \\\n  google/protobuf/unittest_import.proto                           \\\n  google/protobuf/unittest_import_public_lite.proto               \\\n  google/protobuf/unittest_import_public.proto                    \\\n  google/protobuf/unittest_lite_imports_nonlite.proto             \\\n  google/protobuf/unittest_lite.proto                             \\\n  google/protobuf/unittest_mset.proto                             \\\n  google/protobuf/unittest_mset_wire_format.proto                 \\\n  google/protobuf/unittest_no_arena_lite.proto                    \\\n  google/protobuf/unittest_no_arena_import.proto                  \\\n  google/protobuf/unittest_no_arena.proto                         \\\n  google/protobuf/unittest_no_field_presence.proto                \\\n  google/protobuf/unittest_no_generic_services.proto              \\\n  google/protobuf/unittest_optimize_for.proto                     \\\n  google/protobuf/unittest_preserve_unknown_enum2.proto           \\\n  google/protobuf/unittest_preserve_unknown_enum.proto            \\\n  google/protobuf/unittest.proto                                  \\\n  google/protobuf/unittest_proto3_arena.proto                     \\\n  google/protobuf/unittest_proto3_arena_lite.proto                     \\\n  google/protobuf/unittest_proto3_lite.proto                     \\\n  google/protobuf/unittest_well_known_types.proto                 \\\n  google/protobuf/util/internal/testdata/anys.proto               \\\n  google/protobuf/util/internal/testdata/books.proto              \\\n  google/protobuf/util/internal/testdata/default_value.proto      \\\n  google/protobuf/util/internal/testdata/default_value_test.proto \\\n  google/protobuf/util/internal/testdata/field_mask.proto         \\\n  google/protobuf/util/internal/testdata/maps.proto               \\\n  google/protobuf/util/internal/testdata/oneofs.proto             \\\n  google/protobuf/util/internal/testdata/struct.proto             \\\n  google/protobuf/util/internal/testdata/timestamp_duration.proto \\\n  google/protobuf/util/json_format_proto3.proto                   \\\n  google/protobuf/util/message_differencer_unittest.proto         \\\n  google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto\n\nEXTRA_DIST =                                                   \\\n  $(protoc_inputs)                                             \\\n  solaris/libstdc++.la                                         \\\n  google/protobuf/io/gzip_stream.h                             \\\n  google/protobuf/io/gzip_stream_unittest.sh                   \\\n  google/protobuf/testdata/golden_message                      \\\n  google/protobuf/testdata/golden_message_maps                 \\\n  google/protobuf/testdata/golden_message_oneof_implemented    \\\n  google/protobuf/testdata/golden_message_proto3               \\\n  google/protobuf/testdata/golden_packed_fields_message        \\\n  google/protobuf/testdata/bad_utf8_string                     \\\n  google/protobuf/testdata/map_test_data.txt                   \\\n  google/protobuf/testdata/text_format_unittest_data.txt       \\\n  google/protobuf/testdata/text_format_unittest_data_oneof_implemented.txt  \\\n  google/protobuf/testdata/text_format_unittest_data_pointy.txt             \\\n  google/protobuf/testdata/text_format_unittest_data_pointy_oneof.txt       \\\n  google/protobuf/testdata/text_format_unittest_extensions_data.txt         \\\n  google/protobuf/testdata/text_format_unittest_extensions_data_pointy.txt  \\\n  google/protobuf/package_info.h                               \\\n  google/protobuf/io/package_info.h                            \\\n  google/protobuf/compiler/ruby/ruby_generated_code.proto      \\\n  google/protobuf/compiler/ruby/ruby_generated_code_pb.rb      \\\n  google/protobuf/compiler/package_info.h                      \\\n  google/protobuf/compiler/zip_output_unittest.sh              \\\n  README.md\n\nprotoc_lite_outputs =                                          \\\n  google/protobuf/map_lite_unittest.pb.cc                      \\\n  google/protobuf/map_lite_unittest.pb.h                       \\\n  google/protobuf/unittest_lite.pb.cc                          \\\n  google/protobuf/unittest_lite.pb.h                           \\\n  google/protobuf/unittest_no_arena_lite.pb.cc                 \\\n  google/protobuf/unittest_no_arena_lite.pb.h                  \\\n  google/protobuf/unittest_import_lite.pb.cc                   \\\n  google/protobuf/unittest_import_lite.pb.h                    \\\n  google/protobuf/unittest_import_public_lite.pb.cc            \\\n  google/protobuf/unittest_import_public_lite.pb.h\n\nprotoc_outputs =                                                  \\\n  $(protoc_lite_outputs)                                          \\\n  google/protobuf/any_test.pb.cc                                  \\\n  google/protobuf/any_test.pb.h                                   \\\n  google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc     \\\n  google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.h      \\\n  google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc    \\\n  google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.h     \\\n  google/protobuf/map_proto2_unittest.pb.cc                       \\\n  google/protobuf/map_proto2_unittest.pb.h                        \\\n  google/protobuf/map_unittest.pb.cc                              \\\n  google/protobuf/map_unittest.pb.h                               \\\n  google/protobuf/unittest_arena.pb.cc                            \\\n  google/protobuf/unittest_arena.pb.h                             \\\n  google/protobuf/unittest_custom_options.pb.cc                   \\\n  google/protobuf/unittest_custom_options.pb.h                    \\\n  google/protobuf/unittest_drop_unknown_fields.pb.cc              \\\n  google/protobuf/unittest_drop_unknown_fields.pb.h               \\\n  google/protobuf/unittest_embed_optimize_for.pb.cc               \\\n  google/protobuf/unittest_embed_optimize_for.pb.h                \\\n  google/protobuf/unittest_empty.pb.cc                            \\\n  google/protobuf/unittest_empty.pb.h                             \\\n  google/protobuf/unittest_enormous_descriptor.pb.cc              \\\n  google/protobuf/unittest_enormous_descriptor.pb.h               \\\n  google/protobuf/unittest_import.pb.cc                           \\\n  google/protobuf/unittest_import.pb.h                            \\\n  google/protobuf/unittest_import_public.pb.cc                    \\\n  google/protobuf/unittest_import_public.pb.h                     \\\n  google/protobuf/unittest_lite_imports_nonlite.pb.cc             \\\n  google/protobuf/unittest_lite_imports_nonlite.pb.h              \\\n  google/protobuf/unittest_mset.pb.cc                             \\\n  google/protobuf/unittest_mset.pb.h                              \\\n  google/protobuf/unittest_mset_wire_format.pb.cc                 \\\n  google/protobuf/unittest_mset_wire_format.pb.h                  \\\n  google/protobuf/unittest_no_arena_import.pb.cc                  \\\n  google/protobuf/unittest_no_arena_import.pb.h                   \\\n  google/protobuf/unittest_no_arena.pb.cc                         \\\n  google/protobuf/unittest_no_arena.pb.h                          \\\n  google/protobuf/unittest_no_field_presence.pb.cc                \\\n  google/protobuf/unittest_no_field_presence.pb.h                 \\\n  google/protobuf/unittest_no_generic_services.pb.cc              \\\n  google/protobuf/unittest_no_generic_services.pb.h               \\\n  google/protobuf/unittest_optimize_for.pb.cc                     \\\n  google/protobuf/unittest_optimize_for.pb.h                      \\\n  google/protobuf/unittest.pb.cc                                  \\\n  google/protobuf/unittest.pb.h                                   \\\n  google/protobuf/unittest_preserve_unknown_enum2.pb.cc           \\\n  google/protobuf/unittest_preserve_unknown_enum2.pb.h            \\\n  google/protobuf/unittest_preserve_unknown_enum.pb.cc            \\\n  google/protobuf/unittest_preserve_unknown_enum.pb.h             \\\n  google/protobuf/unittest_proto3_arena.pb.cc                     \\\n  google/protobuf/unittest_proto3_arena.pb.h                      \\\n  google/protobuf/unittest_proto3_arena_lite.pb.cc                     \\\n  google/protobuf/unittest_proto3_arena_lite.pb.h                      \\\n  google/protobuf/unittest_proto3_lite.pb.cc                     \\\n  google/protobuf/unittest_proto3_lite.pb.h                      \\\n  google/protobuf/unittest_well_known_types.pb.cc                 \\\n  google/protobuf/unittest_well_known_types.pb.h                  \\\n  google/protobuf/util/internal/testdata/anys.pb.cc               \\\n  google/protobuf/util/internal/testdata/anys.pb.h                \\\n  google/protobuf/util/internal/testdata/books.pb.cc              \\\n  google/protobuf/util/internal/testdata/books.pb.h               \\\n  google/protobuf/util/internal/testdata/default_value.pb.cc      \\\n  google/protobuf/util/internal/testdata/default_value.pb.h       \\\n  google/protobuf/util/internal/testdata/default_value_test.pb.cc \\\n  google/protobuf/util/internal/testdata/default_value_test.pb.h  \\\n  google/protobuf/util/internal/testdata/field_mask.pb.cc         \\\n  google/protobuf/util/internal/testdata/field_mask.pb.h          \\\n  google/protobuf/util/internal/testdata/maps.pb.cc               \\\n  google/protobuf/util/internal/testdata/maps.pb.h                \\\n  google/protobuf/util/internal/testdata/oneofs.pb.cc             \\\n  google/protobuf/util/internal/testdata/oneofs.pb.h              \\\n  google/protobuf/util/internal/testdata/struct.pb.cc             \\\n  google/protobuf/util/internal/testdata/struct.pb.h              \\\n  google/protobuf/util/internal/testdata/timestamp_duration.pb.cc \\\n  google/protobuf/util/internal/testdata/timestamp_duration.pb.h  \\\n  google/protobuf/util/json_format_proto3.pb.cc                   \\\n  google/protobuf/util/json_format_proto3.pb.h                    \\\n  google/protobuf/util/message_differencer_unittest.pb.cc         \\\n  google/protobuf/util/message_differencer_unittest.pb.h\n\nBUILT_SOURCES = $(protoc_outputs)\n\nif USE_EXTERNAL_PROTOC\n\nunittest_proto_middleman: $(protoc_inputs)\n\t$(PROTOC) -I$(srcdir) --cpp_out=. $^\n\ttouch unittest_proto_middleman\n\nelse\n\n# We have to cd to $(srcdir) before executing protoc because $(protoc_inputs) is\n# relative to srcdir, which may not be the same as the current directory when\n# building out-of-tree.\nunittest_proto_middleman: protoc$(EXEEXT) $(protoc_inputs)\n\toldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/protoc$(EXEEXT) -I. --cpp_out=$$oldpwd $(protoc_inputs) )\n\ttouch unittest_proto_middleman\n\nendif\n\n$(protoc_outputs): unittest_proto_middleman\n\nCOMMON_TEST_SOURCES =                                          \\\n  google/protobuf/arena_test_util.cc                           \\\n  google/protobuf/arena_test_util.h                            \\\n  google/protobuf/map_test_util.cc                             \\\n  google/protobuf/map_test_util.h                              \\\n  google/protobuf/map_test_util_impl.h                         \\\n  google/protobuf/test_util.cc                                 \\\n  google/protobuf/test_util.h                                  \\\n  google/protobuf/testing/googletest.cc                        \\\n  google/protobuf/testing/googletest.h                         \\\n  google/protobuf/testing/file.cc                              \\\n  google/protobuf/testing/file.h\n\ncheck_PROGRAMS = protoc protobuf-test protobuf-lazy-descriptor-test \\\n                 protobuf-lite-test test_plugin protobuf-lite-arena-test \\\n                 no-warning-test $(GZCHECKPROGRAMS)\nprotobuf_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la \\\n                      ../gmock/gtest/lib/libgtest.la              \\\n                      ../gmock/lib/libgmock.la                    \\\n                      ../gmock/lib/libgmock_main.la\nprotobuf_test_CPPFLAGS = -I$(srcdir)/../gmock/gtest/include \\\n                         -I$(srcdir)/../gmock/include\n# Disable optimization for tests unless the user explicitly asked for it,\n# since test_util.cc takes forever to compile with optimization (with GCC).\n# See configure.ac for more info.\nprotobuf_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)\nprotobuf_test_SOURCES =                                        \\\n  google/protobuf/stubs/bytestream_unittest.cc                 \\\n  google/protobuf/stubs/common_unittest.cc                     \\\n  google/protobuf/stubs/int128_unittest.cc                     \\\n  google/protobuf/stubs/once_unittest.cc                       \\\n  google/protobuf/stubs/statusor_test.cc                       \\\n  google/protobuf/stubs/status_test.cc                         \\\n  google/protobuf/stubs/stringpiece_unittest.cc                \\\n  google/protobuf/stubs/stringprintf_unittest.cc               \\\n  google/protobuf/stubs/structurally_valid_unittest.cc         \\\n  google/protobuf/stubs/strutil_unittest.cc                    \\\n  google/protobuf/stubs/template_util_unittest.cc              \\\n  google/protobuf/stubs/time_test.cc                           \\\n  google/protobuf/stubs/type_traits_unittest.cc                \\\n  google/protobuf/any_test.cc                                  \\\n  google/protobuf/arenastring_unittest.cc                      \\\n  google/protobuf/arena_unittest.cc                            \\\n  google/protobuf/descriptor_database_unittest.cc              \\\n  google/protobuf/descriptor_unittest.cc                       \\\n  google/protobuf/drop_unknown_fields_test.cc                  \\\n  google/protobuf/dynamic_message_unittest.cc                  \\\n  google/protobuf/extension_set_unittest.cc                    \\\n  google/protobuf/generated_message_reflection_unittest.cc     \\\n  google/protobuf/map_field_test.cc                            \\\n  google/protobuf/map_test.cc                                  \\\n  google/protobuf/message_unittest.cc                          \\\n  google/protobuf/no_field_presence_test.cc                    \\\n  google/protobuf/preserve_unknown_enum_test.cc                \\\n  google/protobuf/proto3_arena_unittest.cc                     \\\n  google/protobuf/proto3_arena_lite_unittest.cc                     \\\n  google/protobuf/proto3_lite_unittest.cc                     \\\n  google/protobuf/reflection_ops_unittest.cc                   \\\n  google/protobuf/repeated_field_reflection_unittest.cc        \\\n  google/protobuf/repeated_field_unittest.cc                   \\\n  google/protobuf/text_format_unittest.cc                      \\\n  google/protobuf/unknown_field_set_unittest.cc                \\\n  google/protobuf/well_known_types_unittest.cc                 \\\n  google/protobuf/wire_format_unittest.cc                      \\\n  google/protobuf/io/coded_stream_unittest.cc                  \\\n  google/protobuf/io/printer_unittest.cc                       \\\n  google/protobuf/io/tokenizer_unittest.cc                     \\\n  google/protobuf/io/zero_copy_stream_unittest.cc              \\\n  google/protobuf/compiler/command_line_interface_unittest.cc  \\\n  google/protobuf/compiler/importer_unittest.cc                \\\n  google/protobuf/compiler/mock_code_generator.cc              \\\n  google/protobuf/compiler/mock_code_generator.h               \\\n  google/protobuf/compiler/parser_unittest.cc                  \\\n  google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc       \\\n  google/protobuf/compiler/cpp/cpp_unittest.h                  \\\n  google/protobuf/compiler/cpp/cpp_unittest.cc                 \\\n  google/protobuf/compiler/cpp/cpp_plugin_unittest.cc          \\\n  google/protobuf/compiler/cpp/metadata_test.cc                \\\n  google/protobuf/compiler/java/java_plugin_unittest.cc        \\\n  google/protobuf/compiler/java/java_doc_comment_unittest.cc   \\\n  google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc \\\n  google/protobuf/compiler/python/python_plugin_unittest.cc    \\\n  google/protobuf/compiler/ruby/ruby_generator_unittest.cc     \\\n  google/protobuf/compiler/csharp/csharp_generator_unittest.cc \\\n  google/protobuf/util/field_comparator_test.cc                \\\n  google/protobuf/util/field_mask_util_test.cc                 \\\n  google/protobuf/util/internal/default_value_objectwriter_test.cc \\\n  google/protobuf/util/internal/json_objectwriter_test.cc      \\\n  google/protobuf/util/internal/json_stream_parser_test.cc     \\\n  google/protobuf/util/internal/protostream_objectsource_test.cc \\\n  google/protobuf/util/internal/protostream_objectwriter_test.cc \\\n  google/protobuf/util/internal/type_info_test_helper.cc       \\\n  google/protobuf/util/json_util_test.cc                       \\\n  google/protobuf/util/message_differencer_unittest.cc         \\\n  google/protobuf/util/time_util_test.cc                       \\\n  google/protobuf/util/type_resolver_util_test.cc              \\\n  $(COMMON_TEST_SOURCES)\n\n\nnodist_protobuf_test_SOURCES = $(protoc_outputs)\n\n# Run cpp_unittest again with PROTOBUF_TEST_NO_DESCRIPTORS defined.\nprotobuf_lazy_descriptor_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la \\\n                      libprotoc.la                                   \\\n                      ../gmock/gtest/lib/libgtest.la                 \\\n                      ../gmock/lib/libgmock.la                       \\\n                      ../gmock/lib/libgmock_main.la\nprotobuf_lazy_descriptor_test_CPPFLAGS = -I$(srcdir)/../gmock/include       \\\n                                         -I$(srcdir)/../gmock/gtest/include \\\n                                         -DPROTOBUF_TEST_NO_DESCRIPTORS\nprotobuf_lazy_descriptor_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)\nprotobuf_lazy_descriptor_test_SOURCES =                        \\\n  google/protobuf/compiler/cpp/cpp_unittest.cc                 \\\n  $(COMMON_TEST_SOURCES)\nnodist_protobuf_lazy_descriptor_test_SOURCES = $(protoc_outputs)\n\nCOMMON_LITE_TEST_SOURCES =                                             \\\n  google/protobuf/arena_test_util.cc                                   \\\n  google/protobuf/arena_test_util.h                                    \\\n  google/protobuf/map_lite_test_util.cc                                \\\n  google/protobuf/map_lite_test_util.h                                 \\\n  google/protobuf/test_util_lite.cc                                    \\\n  google/protobuf/test_util_lite.h\n\n# Build lite_unittest separately, since it doesn't use gtest. It can't\n# depend on gtest because our internal version of gtest depend on proto\n# full runtime and we want to make sure this test builds without full\n# runtime.\nprotobuf_lite_test_LDADD = $(PTHREAD_LIBS) libprotobuf-lite.la\nprotobuf_lite_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)\nprotobuf_lite_test_SOURCES =                                           \\\n  google/protobuf/lite_unittest.cc                                     \\\n  $(COMMON_LITE_TEST_SOURCES)\nnodist_protobuf_lite_test_SOURCES = $(protoc_lite_outputs)\n\n# lite_arena_unittest depends on gtest because teboring@ found that without\n# gtest when building the test internally our memory sanitizer doesn't detect\n# memory leaks (don't know why).\nprotobuf_lite_arena_test_LDADD = $(PTHREAD_LIBS) libprotobuf-lite.la \\\n                      ../gmock/gtest/lib/libgtest.la                 \\\n                      ../gmock/lib/libgmock.la                       \\\n                      ../gmock/lib/libgmock_main.la\nprotobuf_lite_arena_test_CPPFLAGS = -I$(srcdir)/../gmock/include       \\\n                                    -I$(srcdir)/../gmock/gtest/include\nprotobuf_lite_arena_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)\nprotobuf_lite_arena_test_SOURCES =       \\\n  google/protobuf/lite_arena_unittest.cc \\\n  $(COMMON_LITE_TEST_SOURCES)\nnodist_protobuf_lite_arena_test_SOURCES = $(protoc_lite_outputs)\n\n# Test plugin binary.\ntest_plugin_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la \\\n                    ../gmock/gtest/lib/libgtest.la\ntest_plugin_CPPFLAGS = -I$(srcdir)/../gmock/gtest/include\ntest_plugin_SOURCES =                                          \\\n  google/protobuf/compiler/mock_code_generator.cc              \\\n  google/protobuf/testing/file.cc                              \\\n  google/protobuf/testing/file.h                               \\\n  google/protobuf/compiler/test_plugin.cc\n\nif HAVE_ZLIB\nzcgzip_LDADD = $(PTHREAD_LIBS) libprotobuf.la\nzcgzip_SOURCES = google/protobuf/testing/zcgzip.cc\n\nzcgunzip_LDADD = $(PTHREAD_LIBS) libprotobuf.la\nzcgunzip_SOURCES = google/protobuf/testing/zcgunzip.cc\nendif\n\n# This test target is to ensure all our public header files and generated\n# code is free from warnings. We have to be more pedantic about these\n# files because they are compiled by users with different compiler flags.\nno_warning_test.cc:\n\techo \"// Generated from Makefile.am\" > no_warning_test.cc\n\tfor FILE in $(nobase_include_HEADERS); do \\\n\t  if ! echo $${FILE} | grep \"atomicops\"; then \\\n\t    echo \"#include <$${FILE}>\" >> no_warning_test.cc; \\\n\t  fi \\\n\tdone\n\techo \"#include <gtest/gtest.h>\" >> no_warning_test.cc\n\techo \"TEST(NoWarningTest, Empty) {}\" >> no_warning_test.cc\n\nno_warning_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la      \\\n                        ../gmock/gtest/lib/libgtest.la      \\\n                        ../gmock/gtest/lib/libgtest_main.la\nno_warning_test_CPPFLAGS = -I$(srcdir)/../gmock/gtest/include\nno_warning_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_DEF) $(ZLIB_DEF) \\\n                           -Wall -Werror\nnodist_no_warning_test_SOURCES = no_warning_test.cc $(protoc_outputs)\n\nTESTS = protobuf-test protobuf-lazy-descriptor-test protobuf-lite-test \\\n        google/protobuf/compiler/zip_output_unittest.sh $(GZTESTS)     \\\n        protobuf-lite-arena-test no-warning-test\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/Makefile.in",
    "content": "# Makefile.in generated by automake 1.14.1 from Makefile.am.\n# @configure_input@\n\n# Copyright (C) 1994-2013 Free Software Foundation, Inc.\n\n# This Makefile.in is free software; the Free Software Foundation\n# gives unlimited permission to copy and/or distribute it,\n# with or without modifications, as long as this notice is preserved.\n\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY, to the extent permitted by law; without\n# even the implied warranty of MERCHANTABILITY or FITNESS FOR A\n# PARTICULAR PURPOSE.\n\n@SET_MAKE@\n\n\n\n\nVPATH = @srcdir@\nam__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'\nam__make_running_with_option = \\\n  case $${target_option-} in \\\n      ?) ;; \\\n      *) echo \"am__make_running_with_option: internal error: invalid\" \\\n              \"target option '$${target_option-}' specified\" >&2; \\\n         exit 1;; \\\n  esac; \\\n  has_opt=no; \\\n  sane_makeflags=$$MAKEFLAGS; \\\n  if $(am__is_gnu_make); then \\\n    sane_makeflags=$$MFLAGS; \\\n  else \\\n    case $$MAKEFLAGS in \\\n      *\\\\[\\ \\\t]*) \\\n        bs=\\\\; \\\n        sane_makeflags=`printf '%s\\n' \"$$MAKEFLAGS\" \\\n          | sed \"s/$$bs$$bs[$$bs $$bs\t]*//g\"`;; \\\n    esac; \\\n  fi; \\\n  skip_next=no; \\\n  strip_trailopt () \\\n  { \\\n    flg=`printf '%s\\n' \"$$flg\" | sed \"s/$$1.*$$//\"`; \\\n  }; \\\n  for flg in $$sane_makeflags; do \\\n    test $$skip_next = yes && { skip_next=no; continue; }; \\\n    case $$flg in \\\n      *=*|--*) continue;; \\\n        -*I) strip_trailopt 'I'; skip_next=yes;; \\\n      -*I?*) strip_trailopt 'I';; \\\n        -*O) strip_trailopt 'O'; skip_next=yes;; \\\n      -*O?*) strip_trailopt 'O';; \\\n        -*l) strip_trailopt 'l'; skip_next=yes;; \\\n      -*l?*) strip_trailopt 'l';; \\\n      -[dEDm]) skip_next=yes;; \\\n      -[JT]) skip_next=yes;; \\\n    esac; \\\n    case $$flg in \\\n      *$$target_option*) has_opt=yes; break;; \\\n    esac; \\\n  done; \\\n  test $$has_opt = yes\nam__make_dryrun = (target_option=n; $(am__make_running_with_option))\nam__make_keepgoing = (target_option=k; $(am__make_running_with_option))\npkgdatadir = $(datadir)/@PACKAGE@\npkgincludedir = $(includedir)/@PACKAGE@\npkglibdir = $(libdir)/@PACKAGE@\npkglibexecdir = $(libexecdir)/@PACKAGE@\nam__cd = CDPATH=\"$${ZSH_VERSION+.}$(PATH_SEPARATOR)\" && cd\ninstall_sh_DATA = $(install_sh) -c -m 644\ninstall_sh_PROGRAM = $(install_sh) -c\ninstall_sh_SCRIPT = $(install_sh) -c\nINSTALL_HEADER = $(INSTALL_DATA)\ntransform = $(program_transform_name)\nNORMAL_INSTALL = :\nPRE_INSTALL = :\nPOST_INSTALL = :\nNORMAL_UNINSTALL = :\nPRE_UNINSTALL = :\nPOST_UNINSTALL = :\nbuild_triplet = @build@\nhost_triplet = @host@\ntarget_triplet = @target@\nbin_PROGRAMS = protoc$(EXEEXT)\ncheck_PROGRAMS = protoc$(EXEEXT) protobuf-test$(EXEEXT) \\\n\tprotobuf-lazy-descriptor-test$(EXEEXT) \\\n\tprotobuf-lite-test$(EXEEXT) test_plugin$(EXEEXT) \\\n\tprotobuf-lite-arena-test$(EXEEXT) no-warning-test$(EXEEXT) \\\n\t$(am__EXEEXT_1)\nTESTS = protobuf-test$(EXEEXT) protobuf-lazy-descriptor-test$(EXEEXT) \\\n\tprotobuf-lite-test$(EXEEXT) \\\n\tgoogle/protobuf/compiler/zip_output_unittest.sh \\\n\t$(am__EXEEXT_2) protobuf-lite-arena-test$(EXEEXT) \\\n\tno-warning-test$(EXEEXT)\nsubdir = src\nDIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \\\n\t$(top_srcdir)/depcomp $(nobase_dist_proto_DATA) \\\n\t$(am__nobase_include_HEADERS_DIST) $(top_srcdir)/test-driver\nACLOCAL_M4 = $(top_srcdir)/aclocal.m4\nam__aclocal_m4_deps = $(top_srcdir)/m4/ac_system_extensions.m4 \\\n\t$(top_srcdir)/m4/acx_check_suncc.m4 \\\n\t$(top_srcdir)/m4/acx_pthread.m4 $(top_srcdir)/m4/libtool.m4 \\\n\t$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \\\n\t$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \\\n\t$(top_srcdir)/m4/stl_hash.m4 $(top_srcdir)/configure.ac\nam__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \\\n\t$(ACLOCAL_M4)\nmkinstalldirs = $(install_sh) -d\nCONFIG_HEADER = $(top_builddir)/config.h\nCONFIG_CLEAN_FILES =\nCONFIG_CLEAN_VPATH_FILES =\nam__vpath_adj_setup = srcdirstrip=`echo \"$(srcdir)\" | sed 's|.|.|g'`;\nam__vpath_adj = case $$p in \\\n    $(srcdir)/*) f=`echo \"$$p\" | sed \"s|^$$srcdirstrip/||\"`;; \\\n    *) f=$$p;; \\\n  esac;\nam__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;\nam__install_max = 40\nam__nobase_strip_setup = \\\n  srcdirstrip=`echo \"$(srcdir)\" | sed 's/[].[^$$\\\\*|]/\\\\\\\\&/g'`\nam__nobase_strip = \\\n  for p in $$list; do echo \"$$p\"; done | sed -e \"s|$$srcdirstrip/||\"\nam__nobase_list = $(am__nobase_strip_setup); \\\n  for p in $$list; do echo \"$$p $$p\"; done | \\\n  sed \"s| $$srcdirstrip/| |;\"' / .*\\//!s/ .*/ ./; s,\\( .*\\)/[^/]*$$,\\1,' | \\\n  $(AWK) 'BEGIN { files[\".\"] = \"\" } { files[$$2] = files[$$2] \" \" $$1; \\\n    if (++n[$$2] == $(am__install_max)) \\\n      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = \"\" } } \\\n    END { for (dir in files) print dir, files[dir] }'\nam__base_list = \\\n  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\\n/ /g' | \\\n  sed '$$!N;$$!N;$$!N;$$!N;s/\\n/ /g'\nam__uninstall_files_from_dir = { \\\n  test -z \"$$files\" \\\n    || { test ! -d \"$$dir\" && test ! -f \"$$dir\" && test ! -r \"$$dir\"; } \\\n    || { echo \" ( cd '$$dir' && rm -f\" $$files \")\"; \\\n         $(am__cd) \"$$dir\" && rm -f $$files; }; \\\n  }\nam__installdirs = \"$(DESTDIR)$(libdir)\" \"$(DESTDIR)$(bindir)\" \\\n\t\"$(DESTDIR)$(protodir)\" \"$(DESTDIR)$(includedir)\"\nLTLIBRARIES = $(lib_LTLIBRARIES)\nam__DEPENDENCIES_1 =\nlibprotobuf_lite_la_DEPENDENCIES = $(am__DEPENDENCIES_1)\nam__dirstamp = $(am__leading_dot)dirstamp\nam_libprotobuf_lite_la_OBJECTS =  \\\n\tgoogle/protobuf/stubs/atomicops_internals_x86_gcc.lo \\\n\tgoogle/protobuf/stubs/atomicops_internals_x86_msvc.lo \\\n\tgoogle/protobuf/stubs/bytestream.lo \\\n\tgoogle/protobuf/stubs/common.lo \\\n\tgoogle/protobuf/stubs/int128.lo google/protobuf/stubs/once.lo \\\n\tgoogle/protobuf/stubs/status.lo \\\n\tgoogle/protobuf/stubs/statusor.lo \\\n\tgoogle/protobuf/stubs/stringpiece.lo \\\n\tgoogle/protobuf/stubs/stringprintf.lo \\\n\tgoogle/protobuf/stubs/structurally_valid.lo \\\n\tgoogle/protobuf/stubs/strutil.lo google/protobuf/stubs/time.lo \\\n\tgoogle/protobuf/arena.lo google/protobuf/arenastring.lo \\\n\tgoogle/protobuf/extension_set.lo \\\n\tgoogle/protobuf/generated_message_util.lo \\\n\tgoogle/protobuf/message_lite.lo \\\n\tgoogle/protobuf/repeated_field.lo \\\n\tgoogle/protobuf/wire_format_lite.lo \\\n\tgoogle/protobuf/io/coded_stream.lo \\\n\tgoogle/protobuf/io/zero_copy_stream.lo \\\n\tgoogle/protobuf/io/zero_copy_stream_impl_lite.lo\nlibprotobuf_lite_la_OBJECTS = $(am_libprotobuf_lite_la_OBJECTS)\nAM_V_lt = $(am__v_lt_@AM_V@)\nam__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)\nam__v_lt_0 = --silent\nam__v_lt_1 = \nlibprotobuf_lite_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \\\n\t$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \\\n\t$(AM_CXXFLAGS) $(CXXFLAGS) $(libprotobuf_lite_la_LDFLAGS) \\\n\t$(LDFLAGS) -o $@\nlibprotobuf_la_DEPENDENCIES = $(am__DEPENDENCIES_1)\nam__objects_1 = google/protobuf/stubs/atomicops_internals_x86_gcc.lo \\\n\tgoogle/protobuf/stubs/atomicops_internals_x86_msvc.lo \\\n\tgoogle/protobuf/stubs/bytestream.lo \\\n\tgoogle/protobuf/stubs/common.lo \\\n\tgoogle/protobuf/stubs/int128.lo google/protobuf/stubs/once.lo \\\n\tgoogle/protobuf/stubs/status.lo \\\n\tgoogle/protobuf/stubs/statusor.lo \\\n\tgoogle/protobuf/stubs/stringpiece.lo \\\n\tgoogle/protobuf/stubs/stringprintf.lo \\\n\tgoogle/protobuf/stubs/structurally_valid.lo \\\n\tgoogle/protobuf/stubs/strutil.lo google/protobuf/stubs/time.lo \\\n\tgoogle/protobuf/arena.lo google/protobuf/arenastring.lo \\\n\tgoogle/protobuf/extension_set.lo \\\n\tgoogle/protobuf/generated_message_util.lo \\\n\tgoogle/protobuf/message_lite.lo \\\n\tgoogle/protobuf/repeated_field.lo \\\n\tgoogle/protobuf/wire_format_lite.lo \\\n\tgoogle/protobuf/io/coded_stream.lo \\\n\tgoogle/protobuf/io/zero_copy_stream.lo \\\n\tgoogle/protobuf/io/zero_copy_stream_impl_lite.lo\nam_libprotobuf_la_OBJECTS = $(am__objects_1) google/protobuf/any.pb.lo \\\n\tgoogle/protobuf/api.pb.lo google/protobuf/stubs/mathlimits.lo \\\n\tgoogle/protobuf/any.lo google/protobuf/descriptor.lo \\\n\tgoogle/protobuf/descriptor_database.lo \\\n\tgoogle/protobuf/descriptor.pb.lo \\\n\tgoogle/protobuf/duration.pb.lo \\\n\tgoogle/protobuf/dynamic_message.lo google/protobuf/empty.pb.lo \\\n\tgoogle/protobuf/extension_set_heavy.lo \\\n\tgoogle/protobuf/field_mask.pb.lo \\\n\tgoogle/protobuf/generated_message_reflection.lo \\\n\tgoogle/protobuf/map_field.lo google/protobuf/message.lo \\\n\tgoogle/protobuf/reflection_ops.lo google/protobuf/service.lo \\\n\tgoogle/protobuf/source_context.pb.lo \\\n\tgoogle/protobuf/struct.pb.lo \\\n\tgoogle/protobuf/stubs/substitute.lo \\\n\tgoogle/protobuf/text_format.lo google/protobuf/timestamp.pb.lo \\\n\tgoogle/protobuf/type.pb.lo \\\n\tgoogle/protobuf/unknown_field_set.lo \\\n\tgoogle/protobuf/wire_format.lo google/protobuf/wrappers.pb.lo \\\n\tgoogle/protobuf/io/gzip_stream.lo \\\n\tgoogle/protobuf/io/printer.lo google/protobuf/io/strtod.lo \\\n\tgoogle/protobuf/io/tokenizer.lo \\\n\tgoogle/protobuf/io/zero_copy_stream_impl.lo \\\n\tgoogle/protobuf/compiler/importer.lo \\\n\tgoogle/protobuf/compiler/parser.lo \\\n\tgoogle/protobuf/util/field_comparator.lo \\\n\tgoogle/protobuf/util/field_mask_util.lo \\\n\tgoogle/protobuf/util/internal/datapiece.lo \\\n\tgoogle/protobuf/util/internal/default_value_objectwriter.lo \\\n\tgoogle/protobuf/util/internal/error_listener.lo \\\n\tgoogle/protobuf/util/internal/field_mask_utility.lo \\\n\tgoogle/protobuf/util/internal/json_escaping.lo \\\n\tgoogle/protobuf/util/internal/json_objectwriter.lo \\\n\tgoogle/protobuf/util/internal/json_stream_parser.lo \\\n\tgoogle/protobuf/util/internal/object_writer.lo \\\n\tgoogle/protobuf/util/internal/protostream_objectsource.lo \\\n\tgoogle/protobuf/util/internal/protostream_objectwriter.lo \\\n\tgoogle/protobuf/util/internal/proto_writer.lo \\\n\tgoogle/protobuf/util/internal/type_info.lo \\\n\tgoogle/protobuf/util/internal/type_info_test_helper.lo \\\n\tgoogle/protobuf/util/internal/utility.lo \\\n\tgoogle/protobuf/util/json_util.lo \\\n\tgoogle/protobuf/util/message_differencer.lo \\\n\tgoogle/protobuf/util/time_util.lo \\\n\tgoogle/protobuf/util/type_resolver_util.lo\nnodist_libprotobuf_la_OBJECTS =\nlibprotobuf_la_OBJECTS = $(am_libprotobuf_la_OBJECTS) \\\n\t$(nodist_libprotobuf_la_OBJECTS)\nlibprotobuf_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \\\n\t$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \\\n\t$(AM_CXXFLAGS) $(CXXFLAGS) $(libprotobuf_la_LDFLAGS) \\\n\t$(LDFLAGS) -o $@\nlibprotoc_la_DEPENDENCIES = $(am__DEPENDENCIES_1) libprotobuf.la\nam_libprotoc_la_OBJECTS = google/protobuf/compiler/code_generator.lo \\\n\tgoogle/protobuf/compiler/command_line_interface.lo \\\n\tgoogle/protobuf/compiler/plugin.lo \\\n\tgoogle/protobuf/compiler/plugin.pb.lo \\\n\tgoogle/protobuf/compiler/subprocess.lo \\\n\tgoogle/protobuf/compiler/zip_writer.lo \\\n\tgoogle/protobuf/compiler/cpp/cpp_enum.lo \\\n\tgoogle/protobuf/compiler/cpp/cpp_enum_field.lo \\\n\tgoogle/protobuf/compiler/cpp/cpp_extension.lo \\\n\tgoogle/protobuf/compiler/cpp/cpp_field.lo \\\n\tgoogle/protobuf/compiler/cpp/cpp_file.lo \\\n\tgoogle/protobuf/compiler/cpp/cpp_generator.lo \\\n\tgoogle/protobuf/compiler/cpp/cpp_helpers.lo \\\n\tgoogle/protobuf/compiler/cpp/cpp_map_field.lo \\\n\tgoogle/protobuf/compiler/cpp/cpp_message.lo \\\n\tgoogle/protobuf/compiler/cpp/cpp_message_field.lo \\\n\tgoogle/protobuf/compiler/cpp/cpp_primitive_field.lo \\\n\tgoogle/protobuf/compiler/cpp/cpp_service.lo \\\n\tgoogle/protobuf/compiler/cpp/cpp_string_field.lo \\\n\tgoogle/protobuf/compiler/java/java_context.lo \\\n\tgoogle/protobuf/compiler/java/java_enum.lo \\\n\tgoogle/protobuf/compiler/java/java_enum_lite.lo \\\n\tgoogle/protobuf/compiler/java/java_enum_field.lo \\\n\tgoogle/protobuf/compiler/java/java_enum_field_lite.lo \\\n\tgoogle/protobuf/compiler/java/java_extension.lo \\\n\tgoogle/protobuf/compiler/java/java_extension_lite.lo \\\n\tgoogle/protobuf/compiler/java/java_field.lo \\\n\tgoogle/protobuf/compiler/java/java_file.lo \\\n\tgoogle/protobuf/compiler/java/java_generator.lo \\\n\tgoogle/protobuf/compiler/java/java_generator_factory.lo \\\n\tgoogle/protobuf/compiler/java/java_helpers.lo \\\n\tgoogle/protobuf/compiler/java/java_lazy_message_field.lo \\\n\tgoogle/protobuf/compiler/java/java_lazy_message_field_lite.lo \\\n\tgoogle/protobuf/compiler/java/java_map_field.lo \\\n\tgoogle/protobuf/compiler/java/java_map_field_lite.lo \\\n\tgoogle/protobuf/compiler/java/java_message.lo \\\n\tgoogle/protobuf/compiler/java/java_message_lite.lo \\\n\tgoogle/protobuf/compiler/java/java_message_builder.lo \\\n\tgoogle/protobuf/compiler/java/java_message_builder_lite.lo \\\n\tgoogle/protobuf/compiler/java/java_message_field.lo \\\n\tgoogle/protobuf/compiler/java/java_message_field_lite.lo \\\n\tgoogle/protobuf/compiler/java/java_name_resolver.lo \\\n\tgoogle/protobuf/compiler/java/java_primitive_field.lo \\\n\tgoogle/protobuf/compiler/java/java_primitive_field_lite.lo \\\n\tgoogle/protobuf/compiler/java/java_shared_code_generator.lo \\\n\tgoogle/protobuf/compiler/java/java_service.lo \\\n\tgoogle/protobuf/compiler/java/java_string_field.lo \\\n\tgoogle/protobuf/compiler/java/java_string_field_lite.lo \\\n\tgoogle/protobuf/compiler/java/java_doc_comment.lo \\\n\tgoogle/protobuf/compiler/js/js_generator.lo \\\n\tgoogle/protobuf/compiler/javanano/javanano_enum.lo \\\n\tgoogle/protobuf/compiler/javanano/javanano_enum_field.lo \\\n\tgoogle/protobuf/compiler/javanano/javanano_extension.lo \\\n\tgoogle/protobuf/compiler/javanano/javanano_field.lo \\\n\tgoogle/protobuf/compiler/javanano/javanano_file.lo \\\n\tgoogle/protobuf/compiler/javanano/javanano_generator.lo \\\n\tgoogle/protobuf/compiler/javanano/javanano_helpers.lo \\\n\tgoogle/protobuf/compiler/javanano/javanano_map_field.lo \\\n\tgoogle/protobuf/compiler/javanano/javanano_message.lo \\\n\tgoogle/protobuf/compiler/javanano/javanano_message_field.lo \\\n\tgoogle/protobuf/compiler/javanano/javanano_primitive_field.lo \\\n\tgoogle/protobuf/compiler/objectivec/objectivec_enum.lo \\\n\tgoogle/protobuf/compiler/objectivec/objectivec_enum_field.lo \\\n\tgoogle/protobuf/compiler/objectivec/objectivec_extension.lo \\\n\tgoogle/protobuf/compiler/objectivec/objectivec_field.lo \\\n\tgoogle/protobuf/compiler/objectivec/objectivec_file.lo \\\n\tgoogle/protobuf/compiler/objectivec/objectivec_generator.lo \\\n\tgoogle/protobuf/compiler/objectivec/objectivec_helpers.lo \\\n\tgoogle/protobuf/compiler/objectivec/objectivec_map_field.lo \\\n\tgoogle/protobuf/compiler/objectivec/objectivec_message.lo \\\n\tgoogle/protobuf/compiler/objectivec/objectivec_message_field.lo \\\n\tgoogle/protobuf/compiler/objectivec/objectivec_oneof.lo \\\n\tgoogle/protobuf/compiler/objectivec/objectivec_primitive_field.lo \\\n\tgoogle/protobuf/compiler/python/python_generator.lo \\\n\tgoogle/protobuf/compiler/ruby/ruby_generator.lo \\\n\tgoogle/protobuf/compiler/csharp/csharp_doc_comment.lo \\\n\tgoogle/protobuf/compiler/csharp/csharp_enum.lo \\\n\tgoogle/protobuf/compiler/csharp/csharp_enum_field.lo \\\n\tgoogle/protobuf/compiler/csharp/csharp_field_base.lo \\\n\tgoogle/protobuf/compiler/csharp/csharp_generator.lo \\\n\tgoogle/protobuf/compiler/csharp/csharp_helpers.lo \\\n\tgoogle/protobuf/compiler/csharp/csharp_map_field.lo \\\n\tgoogle/protobuf/compiler/csharp/csharp_message.lo \\\n\tgoogle/protobuf/compiler/csharp/csharp_message_field.lo \\\n\tgoogle/protobuf/compiler/csharp/csharp_primitive_field.lo \\\n\tgoogle/protobuf/compiler/csharp/csharp_reflection_class.lo \\\n\tgoogle/protobuf/compiler/csharp/csharp_repeated_enum_field.lo \\\n\tgoogle/protobuf/compiler/csharp/csharp_repeated_message_field.lo \\\n\tgoogle/protobuf/compiler/csharp/csharp_repeated_primitive_field.lo \\\n\tgoogle/protobuf/compiler/csharp/csharp_source_generator_base.lo \\\n\tgoogle/protobuf/compiler/csharp/csharp_wrapper_field.lo\nlibprotoc_la_OBJECTS = $(am_libprotoc_la_OBJECTS)\nlibprotoc_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \\\n\t$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \\\n\t$(CXXFLAGS) $(libprotoc_la_LDFLAGS) $(LDFLAGS) -o $@\n@HAVE_ZLIB_TRUE@am__EXEEXT_1 = zcgzip$(EXEEXT) zcgunzip$(EXEEXT)\nPROGRAMS = $(bin_PROGRAMS)\nam__objects_2 = google/protobuf/no_warning_test-map_lite_unittest.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_lite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_no_arena_lite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_import_lite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_import_public_lite.pb.$(OBJEXT)\nam__objects_3 = $(am__objects_2) \\\n\tgoogle/protobuf/no_warning_test-any_test.pb.$(OBJEXT) \\\n\tgoogle/protobuf/compiler/cpp/no_warning_test-cpp_test_bad_identifiers.pb.$(OBJEXT) \\\n\tgoogle/protobuf/compiler/cpp/no_warning_test-cpp_test_large_enum_value.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-map_proto2_unittest.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-map_unittest.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_arena.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_custom_options.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_drop_unknown_fields.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_embed_optimize_for.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_empty.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_enormous_descriptor.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_import.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_import_public.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_lite_imports_nonlite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_mset.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_mset_wire_format.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_no_arena_import.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_no_arena.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_no_field_presence.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_no_generic_services.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_optimize_for.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_preserve_unknown_enum2.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_preserve_unknown_enum.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_proto3_arena.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_proto3_arena_lite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_proto3_lite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/no_warning_test-unittest_well_known_types.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/no_warning_test-anys.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/no_warning_test-books.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/no_warning_test-default_value.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/no_warning_test-default_value_test.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/no_warning_test-field_mask.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/no_warning_test-maps.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/no_warning_test-oneofs.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/no_warning_test-struct.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/no_warning_test-timestamp_duration.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/no_warning_test-json_format_proto3.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/no_warning_test-message_differencer_unittest.pb.$(OBJEXT)\nnodist_no_warning_test_OBJECTS =  \\\n\tno_warning_test-no_warning_test.$(OBJEXT) $(am__objects_3)\nno_warning_test_OBJECTS = $(nodist_no_warning_test_OBJECTS)\nno_warning_test_DEPENDENCIES = $(am__DEPENDENCIES_1) libprotobuf.la \\\n\t../gmock/gtest/lib/libgtest.la \\\n\t../gmock/gtest/lib/libgtest_main.la\nno_warning_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \\\n\t$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \\\n\t$(no_warning_test_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \\\n\t$(LDFLAGS) -o $@\nam__objects_4 = google/protobuf/protobuf_lazy_descriptor_test-arena_test_util.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-map_test_util.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-test_util.$(OBJEXT) \\\n\tgoogle/protobuf/testing/protobuf_lazy_descriptor_test-googletest.$(OBJEXT) \\\n\tgoogle/protobuf/testing/protobuf_lazy_descriptor_test-file.$(OBJEXT)\nam_protobuf_lazy_descriptor_test_OBJECTS = google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_unittest.$(OBJEXT) \\\n\t$(am__objects_4)\nam__objects_5 = google/protobuf/protobuf_lazy_descriptor_test-map_lite_unittest.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_lite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_lite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_import_lite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_import_public_lite.pb.$(OBJEXT)\nam__objects_6 = $(am__objects_5) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-any_test.pb.$(OBJEXT) \\\n\tgoogle/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_bad_identifiers.pb.$(OBJEXT) \\\n\tgoogle/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_large_enum_value.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-map_proto2_unittest.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-map_unittest.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_arena.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_custom_options.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_drop_unknown_fields.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_embed_optimize_for.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_empty.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_enormous_descriptor.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_import.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_import_public.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_lite_imports_nonlite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_mset.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_mset_wire_format.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_import.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_no_field_presence.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_no_generic_services.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_optimize_for.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum2.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena_lite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_lite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lazy_descriptor_test-unittest_well_known_types.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-anys.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-books.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value_test.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-field_mask.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-maps.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-oneofs.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-struct.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-timestamp_duration.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/protobuf_lazy_descriptor_test-json_format_proto3.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/protobuf_lazy_descriptor_test-message_differencer_unittest.pb.$(OBJEXT)\nnodist_protobuf_lazy_descriptor_test_OBJECTS = $(am__objects_6)\nprotobuf_lazy_descriptor_test_OBJECTS =  \\\n\t$(am_protobuf_lazy_descriptor_test_OBJECTS) \\\n\t$(nodist_protobuf_lazy_descriptor_test_OBJECTS)\nprotobuf_lazy_descriptor_test_DEPENDENCIES = $(am__DEPENDENCIES_1) \\\n\tlibprotobuf.la libprotoc.la ../gmock/gtest/lib/libgtest.la \\\n\t../gmock/lib/libgmock.la ../gmock/lib/libgmock_main.la\nprotobuf_lazy_descriptor_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \\\n\t$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \\\n\t$(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) \\\n\t$(AM_LDFLAGS) $(LDFLAGS) -o $@\nam__objects_7 = google/protobuf/protobuf_lite_arena_test-arena_test_util.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lite_arena_test-map_lite_test_util.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lite_arena_test-test_util_lite.$(OBJEXT)\nam_protobuf_lite_arena_test_OBJECTS = google/protobuf/protobuf_lite_arena_test-lite_arena_unittest.$(OBJEXT) \\\n\t$(am__objects_7)\nam__objects_8 = google/protobuf/protobuf_lite_arena_test-map_lite_unittest.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lite_arena_test-unittest_lite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lite_arena_test-unittest_no_arena_lite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lite_arena_test-unittest_import_lite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lite_arena_test-unittest_import_public_lite.pb.$(OBJEXT)\nnodist_protobuf_lite_arena_test_OBJECTS = $(am__objects_8)\nprotobuf_lite_arena_test_OBJECTS =  \\\n\t$(am_protobuf_lite_arena_test_OBJECTS) \\\n\t$(nodist_protobuf_lite_arena_test_OBJECTS)\nprotobuf_lite_arena_test_DEPENDENCIES = $(am__DEPENDENCIES_1) \\\n\tlibprotobuf-lite.la ../gmock/gtest/lib/libgtest.la \\\n\t../gmock/lib/libgmock.la ../gmock/lib/libgmock_main.la\nprotobuf_lite_arena_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \\\n\t$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \\\n\t$(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \\\n\t$(LDFLAGS) -o $@\nam__objects_9 =  \\\n\tgoogle/protobuf/protobuf_lite_test-arena_test_util.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lite_test-map_lite_test_util.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lite_test-test_util_lite.$(OBJEXT)\nam_protobuf_lite_test_OBJECTS =  \\\n\tgoogle/protobuf/protobuf_lite_test-lite_unittest.$(OBJEXT) \\\n\t$(am__objects_9)\nam__objects_10 = google/protobuf/protobuf_lite_test-map_lite_unittest.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lite_test-unittest_lite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lite_test-unittest_no_arena_lite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lite_test-unittest_import_lite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_lite_test-unittest_import_public_lite.pb.$(OBJEXT)\nnodist_protobuf_lite_test_OBJECTS = $(am__objects_10)\nprotobuf_lite_test_OBJECTS = $(am_protobuf_lite_test_OBJECTS) \\\n\t$(nodist_protobuf_lite_test_OBJECTS)\nprotobuf_lite_test_DEPENDENCIES = $(am__DEPENDENCIES_1) \\\n\tlibprotobuf-lite.la\nprotobuf_lite_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \\\n\t$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \\\n\t$(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \\\n\t$(LDFLAGS) -o $@\nam__objects_11 =  \\\n\tgoogle/protobuf/protobuf_test-arena_test_util.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-map_test_util.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-test_util.$(OBJEXT) \\\n\tgoogle/protobuf/testing/protobuf_test-googletest.$(OBJEXT) \\\n\tgoogle/protobuf/testing/protobuf_test-file.$(OBJEXT)\nam_protobuf_test_OBJECTS = google/protobuf/stubs/protobuf_test-bytestream_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/stubs/protobuf_test-common_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/stubs/protobuf_test-int128_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/stubs/protobuf_test-once_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/stubs/protobuf_test-statusor_test.$(OBJEXT) \\\n\tgoogle/protobuf/stubs/protobuf_test-status_test.$(OBJEXT) \\\n\tgoogle/protobuf/stubs/protobuf_test-stringpiece_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/stubs/protobuf_test-stringprintf_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/stubs/protobuf_test-structurally_valid_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/stubs/protobuf_test-strutil_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/stubs/protobuf_test-template_util_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/stubs/protobuf_test-time_test.$(OBJEXT) \\\n\tgoogle/protobuf/stubs/protobuf_test-type_traits_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-any_test.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-arenastring_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-arena_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-descriptor_database_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-descriptor_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-drop_unknown_fields_test.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-dynamic_message_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-extension_set_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-generated_message_reflection_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-map_field_test.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-map_test.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-message_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-no_field_presence_test.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-preserve_unknown_enum_test.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-proto3_arena_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-proto3_arena_lite_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-proto3_lite_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-reflection_ops_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-repeated_field_reflection_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-repeated_field_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-text_format_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unknown_field_set_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-well_known_types_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-wire_format_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/io/protobuf_test-coded_stream_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/io/protobuf_test-printer_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/io/protobuf_test-tokenizer_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/io/protobuf_test-zero_copy_stream_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/compiler/protobuf_test-command_line_interface_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/compiler/protobuf_test-importer_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/compiler/protobuf_test-mock_code_generator.$(OBJEXT) \\\n\tgoogle/protobuf/compiler/protobuf_test-parser_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/compiler/cpp/protobuf_test-cpp_bootstrap_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/compiler/cpp/protobuf_test-cpp_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/compiler/cpp/protobuf_test-cpp_plugin_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/compiler/cpp/protobuf_test-metadata_test.$(OBJEXT) \\\n\tgoogle/protobuf/compiler/java/protobuf_test-java_plugin_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/compiler/java/protobuf_test-java_doc_comment_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/compiler/objectivec/protobuf_test-objectivec_helpers_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/compiler/python/protobuf_test-python_plugin_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/compiler/ruby/protobuf_test-ruby_generator_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/compiler/csharp/protobuf_test-csharp_generator_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/util/protobuf_test-field_comparator_test.$(OBJEXT) \\\n\tgoogle/protobuf/util/protobuf_test-field_mask_util_test.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/protobuf_test-default_value_objectwriter_test.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/protobuf_test-json_objectwriter_test.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/protobuf_test-json_stream_parser_test.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/protobuf_test-protostream_objectsource_test.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/protobuf_test-protostream_objectwriter_test.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/protobuf_test-type_info_test_helper.$(OBJEXT) \\\n\tgoogle/protobuf/util/protobuf_test-json_util_test.$(OBJEXT) \\\n\tgoogle/protobuf/util/protobuf_test-message_differencer_unittest.$(OBJEXT) \\\n\tgoogle/protobuf/util/protobuf_test-time_util_test.$(OBJEXT) \\\n\tgoogle/protobuf/util/protobuf_test-type_resolver_util_test.$(OBJEXT) \\\n\t$(am__objects_11)\nam__objects_12 =  \\\n\tgoogle/protobuf/protobuf_test-map_lite_unittest.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_lite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_no_arena_lite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_import_lite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_import_public_lite.pb.$(OBJEXT)\nam__objects_13 = $(am__objects_12) \\\n\tgoogle/protobuf/protobuf_test-any_test.pb.$(OBJEXT) \\\n\tgoogle/protobuf/compiler/cpp/protobuf_test-cpp_test_bad_identifiers.pb.$(OBJEXT) \\\n\tgoogle/protobuf/compiler/cpp/protobuf_test-cpp_test_large_enum_value.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-map_proto2_unittest.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-map_unittest.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_arena.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_custom_options.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_drop_unknown_fields.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_embed_optimize_for.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_empty.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_enormous_descriptor.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_import.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_import_public.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_lite_imports_nonlite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_mset.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_mset_wire_format.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_no_arena_import.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_no_arena.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_no_field_presence.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_no_generic_services.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_optimize_for.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_preserve_unknown_enum2.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_preserve_unknown_enum.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_proto3_arena.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_proto3_arena_lite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_proto3_lite.pb.$(OBJEXT) \\\n\tgoogle/protobuf/protobuf_test-unittest_well_known_types.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/protobuf_test-anys.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/protobuf_test-books.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/protobuf_test-default_value.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/protobuf_test-default_value_test.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/protobuf_test-field_mask.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/protobuf_test-maps.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/protobuf_test-oneofs.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/protobuf_test-struct.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/internal/testdata/protobuf_test-timestamp_duration.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/protobuf_test-json_format_proto3.pb.$(OBJEXT) \\\n\tgoogle/protobuf/util/protobuf_test-message_differencer_unittest.pb.$(OBJEXT)\nnodist_protobuf_test_OBJECTS = $(am__objects_13)\nprotobuf_test_OBJECTS = $(am_protobuf_test_OBJECTS) \\\n\t$(nodist_protobuf_test_OBJECTS)\nprotobuf_test_DEPENDENCIES = $(am__DEPENDENCIES_1) libprotobuf.la \\\n\tlibprotoc.la ../gmock/gtest/lib/libgtest.la \\\n\t../gmock/lib/libgmock.la ../gmock/lib/libgmock_main.la\nprotobuf_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \\\n\t$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \\\n\t$(protobuf_test_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \\\n\t-o $@\nam_protoc_OBJECTS = google/protobuf/compiler/main.$(OBJEXT)\nprotoc_OBJECTS = $(am_protoc_OBJECTS)\nprotoc_DEPENDENCIES = $(am__DEPENDENCIES_1) libprotobuf.la \\\n\tlibprotoc.la\nam_test_plugin_OBJECTS = google/protobuf/compiler/test_plugin-mock_code_generator.$(OBJEXT) \\\n\tgoogle/protobuf/testing/test_plugin-file.$(OBJEXT) \\\n\tgoogle/protobuf/compiler/test_plugin-test_plugin.$(OBJEXT)\ntest_plugin_OBJECTS = $(am_test_plugin_OBJECTS)\ntest_plugin_DEPENDENCIES = $(am__DEPENDENCIES_1) libprotobuf.la \\\n\tlibprotoc.la ../gmock/gtest/lib/libgtest.la\nam__zcgunzip_SOURCES_DIST = google/protobuf/testing/zcgunzip.cc\n@HAVE_ZLIB_TRUE@am_zcgunzip_OBJECTS =  \\\n@HAVE_ZLIB_TRUE@\tgoogle/protobuf/testing/zcgunzip.$(OBJEXT)\nzcgunzip_OBJECTS = $(am_zcgunzip_OBJECTS)\n@HAVE_ZLIB_TRUE@zcgunzip_DEPENDENCIES = $(am__DEPENDENCIES_1) \\\n@HAVE_ZLIB_TRUE@\tlibprotobuf.la\nam__zcgzip_SOURCES_DIST = google/protobuf/testing/zcgzip.cc\n@HAVE_ZLIB_TRUE@am_zcgzip_OBJECTS =  \\\n@HAVE_ZLIB_TRUE@\tgoogle/protobuf/testing/zcgzip.$(OBJEXT)\nzcgzip_OBJECTS = $(am_zcgzip_OBJECTS)\n@HAVE_ZLIB_TRUE@zcgzip_DEPENDENCIES = $(am__DEPENDENCIES_1) \\\n@HAVE_ZLIB_TRUE@\tlibprotobuf.la\nAM_V_P = $(am__v_P_@AM_V@)\nam__v_P_ = $(am__v_P_@AM_DEFAULT_V@)\nam__v_P_0 = false\nam__v_P_1 = :\nAM_V_GEN = $(am__v_GEN_@AM_V@)\nam__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)\nam__v_GEN_0 = @echo \"  GEN     \" $@;\nam__v_GEN_1 = \nAM_V_at = $(am__v_at_@AM_V@)\nam__v_at_ = $(am__v_at_@AM_DEFAULT_V@)\nam__v_at_0 = @\nam__v_at_1 = \nDEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)\ndepcomp = $(SHELL) $(top_srcdir)/depcomp\nam__depfiles_maybe = depfiles\nam__mv = mv -f\nCXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \\\n\t$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)\nLTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \\\n\t$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \\\n\t$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \\\n\t$(AM_CXXFLAGS) $(CXXFLAGS)\nAM_V_CXX = $(am__v_CXX_@AM_V@)\nam__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)\nam__v_CXX_0 = @echo \"  CXX     \" $@;\nam__v_CXX_1 = \nCXXLD = $(CXX)\nCXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \\\n\t$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \\\n\t$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@\nAM_V_CXXLD = $(am__v_CXXLD_@AM_V@)\nam__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)\nam__v_CXXLD_0 = @echo \"  CXXLD   \" $@;\nam__v_CXXLD_1 = \nCOMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \\\n\t$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)\nLTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \\\n\t$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \\\n\t$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \\\n\t$(AM_CFLAGS) $(CFLAGS)\nAM_V_CC = $(am__v_CC_@AM_V@)\nam__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)\nam__v_CC_0 = @echo \"  CC      \" $@;\nam__v_CC_1 = \nCCLD = $(CC)\nLINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \\\n\t$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \\\n\t$(AM_LDFLAGS) $(LDFLAGS) -o $@\nAM_V_CCLD = $(am__v_CCLD_@AM_V@)\nam__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)\nam__v_CCLD_0 = @echo \"  CCLD    \" $@;\nam__v_CCLD_1 = \nSOURCES = $(libprotobuf_lite_la_SOURCES) $(libprotobuf_la_SOURCES) \\\n\t$(nodist_libprotobuf_la_SOURCES) $(libprotoc_la_SOURCES) \\\n\t$(nodist_no_warning_test_SOURCES) \\\n\t$(protobuf_lazy_descriptor_test_SOURCES) \\\n\t$(nodist_protobuf_lazy_descriptor_test_SOURCES) \\\n\t$(protobuf_lite_arena_test_SOURCES) \\\n\t$(nodist_protobuf_lite_arena_test_SOURCES) \\\n\t$(protobuf_lite_test_SOURCES) \\\n\t$(nodist_protobuf_lite_test_SOURCES) $(protobuf_test_SOURCES) \\\n\t$(nodist_protobuf_test_SOURCES) $(protoc_SOURCES) \\\n\t$(test_plugin_SOURCES) $(zcgunzip_SOURCES) $(zcgzip_SOURCES)\nDIST_SOURCES = $(libprotobuf_lite_la_SOURCES) \\\n\t$(libprotobuf_la_SOURCES) $(libprotoc_la_SOURCES) \\\n\t$(protobuf_lazy_descriptor_test_SOURCES) \\\n\t$(protobuf_lite_arena_test_SOURCES) \\\n\t$(protobuf_lite_test_SOURCES) $(protobuf_test_SOURCES) \\\n\t$(protoc_SOURCES) $(test_plugin_SOURCES) \\\n\t$(am__zcgunzip_SOURCES_DIST) $(am__zcgzip_SOURCES_DIST)\nam__can_run_installinfo = \\\n  case $$AM_UPDATE_INFO_DIR in \\\n    n|no|NO) false;; \\\n    *) (install-info --version) >/dev/null 2>&1;; \\\n  esac\nDATA = $(nobase_dist_proto_DATA)\nam__nobase_include_HEADERS_DIST =  \\\n\tgoogle/protobuf/stubs/atomic_sequence_num.h \\\n\tgoogle/protobuf/stubs/atomicops.h \\\n\tgoogle/protobuf/stubs/atomicops_internals_power.h \\\n\tgoogle/protobuf/stubs/atomicops_internals_ppc_gcc.h \\\n\tgoogle/protobuf/stubs/atomicops_internals_arm64_gcc.h \\\n\tgoogle/protobuf/stubs/atomicops_internals_arm_gcc.h \\\n\tgoogle/protobuf/stubs/atomicops_internals_arm_qnx.h \\\n\tgoogle/protobuf/stubs/atomicops_internals_atomicword_compat.h \\\n\tgoogle/protobuf/stubs/atomicops_internals_generic_gcc.h \\\n\tgoogle/protobuf/stubs/atomicops_internals_macosx.h \\\n\tgoogle/protobuf/stubs/atomicops_internals_mips_gcc.h \\\n\tgoogle/protobuf/stubs/atomicops_internals_pnacl.h \\\n\tgoogle/protobuf/stubs/atomicops_internals_solaris.h \\\n\tgoogle/protobuf/stubs/atomicops_internals_tsan.h \\\n\tgoogle/protobuf/stubs/atomicops_internals_x86_gcc.h \\\n\tgoogle/protobuf/stubs/atomicops_internals_x86_msvc.h \\\n\tgoogle/protobuf/stubs/callback.h \\\n\tgoogle/protobuf/stubs/bytestream.h \\\n\tgoogle/protobuf/stubs/casts.h google/protobuf/stubs/common.h \\\n\tgoogle/protobuf/stubs/fastmem.h google/protobuf/stubs/hash.h \\\n\tgoogle/protobuf/stubs/logging.h google/protobuf/stubs/macros.h \\\n\tgoogle/protobuf/stubs/mutex.h google/protobuf/stubs/once.h \\\n\tgoogle/protobuf/stubs/platform_macros.h \\\n\tgoogle/protobuf/stubs/port.h \\\n\tgoogle/protobuf/stubs/scoped_ptr.h \\\n\tgoogle/protobuf/stubs/shared_ptr.h \\\n\tgoogle/protobuf/stubs/singleton.h \\\n\tgoogle/protobuf/stubs/status.h \\\n\tgoogle/protobuf/stubs/stl_util.h \\\n\tgoogle/protobuf/stubs/stringpiece.h \\\n\tgoogle/protobuf/stubs/template_util.h \\\n\tgoogle/protobuf/stubs/type_traits.h google/protobuf/any.pb.h \\\n\tgoogle/protobuf/api.pb.h google/protobuf/any.h \\\n\tgoogle/protobuf/arena.h google/protobuf/arenastring.h \\\n\tgoogle/protobuf/descriptor_database.h \\\n\tgoogle/protobuf/descriptor.h google/protobuf/descriptor.pb.h \\\n\tgoogle/protobuf/duration.pb.h \\\n\tgoogle/protobuf/dynamic_message.h google/protobuf/empty.pb.h \\\n\tgoogle/protobuf/extension_set.h \\\n\tgoogle/protobuf/field_mask.pb.h \\\n\tgoogle/protobuf/generated_enum_reflection.h \\\n\tgoogle/protobuf/generated_enum_util.h \\\n\tgoogle/protobuf/generated_message_reflection.h \\\n\tgoogle/protobuf/generated_message_util.h \\\n\tgoogle/protobuf/map_entry.h google/protobuf/map_entry_lite.h \\\n\tgoogle/protobuf/map_field.h google/protobuf/map_field_inl.h \\\n\tgoogle/protobuf/map_field_lite.h google/protobuf/map.h \\\n\tgoogle/protobuf/map_type_handler.h google/protobuf/message.h \\\n\tgoogle/protobuf/message_lite.h google/protobuf/metadata.h \\\n\tgoogle/protobuf/reflection.h google/protobuf/reflection_ops.h \\\n\tgoogle/protobuf/repeated_field.h google/protobuf/service.h \\\n\tgoogle/protobuf/source_context.pb.h \\\n\tgoogle/protobuf/struct.pb.h google/protobuf/text_format.h \\\n\tgoogle/protobuf/timestamp.pb.h google/protobuf/type.pb.h \\\n\tgoogle/protobuf/unknown_field_set.h \\\n\tgoogle/protobuf/wire_format.h \\\n\tgoogle/protobuf/wire_format_lite.h \\\n\tgoogle/protobuf/wire_format_lite_inl.h \\\n\tgoogle/protobuf/wrappers.pb.h \\\n\tgoogle/protobuf/io/coded_stream.h \\\n\tgoogle/protobuf/io/gzip_stream.h google/protobuf/io/printer.h \\\n\tgoogle/protobuf/io/strtod.h google/protobuf/io/tokenizer.h \\\n\tgoogle/protobuf/io/zero_copy_stream.h \\\n\tgoogle/protobuf/io/zero_copy_stream_impl.h \\\n\tgoogle/protobuf/io/zero_copy_stream_impl_lite.h \\\n\tgoogle/protobuf/compiler/code_generator.h \\\n\tgoogle/protobuf/compiler/command_line_interface.h \\\n\tgoogle/protobuf/compiler/importer.h \\\n\tgoogle/protobuf/compiler/parser.h \\\n\tgoogle/protobuf/compiler/plugin.h \\\n\tgoogle/protobuf/compiler/plugin.pb.h \\\n\tgoogle/protobuf/compiler/cpp/cpp_generator.h \\\n\tgoogle/protobuf/compiler/csharp/csharp_generator.h \\\n\tgoogle/protobuf/compiler/csharp/csharp_names.h \\\n\tgoogle/protobuf/compiler/java/java_generator.h \\\n\tgoogle/protobuf/compiler/java/java_names.h \\\n\tgoogle/protobuf/compiler/javanano/javanano_generator.h \\\n\tgoogle/protobuf/compiler/js/js_generator.h \\\n\tgoogle/protobuf/compiler/objectivec/objectivec_generator.h \\\n\tgoogle/protobuf/compiler/objectivec/objectivec_helpers.h \\\n\tgoogle/protobuf/compiler/python/python_generator.h \\\n\tgoogle/protobuf/compiler/ruby/ruby_generator.h \\\n\tgoogle/protobuf/util/type_resolver.h \\\n\tgoogle/protobuf/util/field_comparator.h \\\n\tgoogle/protobuf/util/field_mask_util.h \\\n\tgoogle/protobuf/util/json_util.h \\\n\tgoogle/protobuf/util/time_util.h \\\n\tgoogle/protobuf/util/type_resolver_util.h \\\n\tgoogle/protobuf/util/message_differencer.h\nHEADERS = $(nobase_include_HEADERS)\nam__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)\n# Read a list of newline-separated strings from the standard input,\n# and print each of them once, without duplicates.  Input order is\n# *not* preserved.\nam__uniquify_input = $(AWK) '\\\n  BEGIN { nonempty = 0; } \\\n  { items[$$0] = 1; nonempty = 1; } \\\n  END { if (nonempty) { for (i in items) print i; }; } \\\n'\n# Make sure the list of sources is unique.  This is necessary because,\n# e.g., the same source file might be shared among _SOURCES variables\n# for different programs/libraries.\nam__define_uniq_tagged_files = \\\n  list='$(am__tagged_files)'; \\\n  unique=`for i in $$list; do \\\n    if test -f \"$$i\"; then echo $$i; else echo $(srcdir)/$$i; fi; \\\n  done | $(am__uniquify_input)`\nETAGS = etags\nCTAGS = ctags\nam__tty_colors_dummy = \\\n  mgn= red= grn= lgn= blu= brg= std=; \\\n  am__color_tests=no\nam__tty_colors = { \\\n  $(am__tty_colors_dummy); \\\n  if test \"X$(AM_COLOR_TESTS)\" = Xno; then \\\n    am__color_tests=no; \\\n  elif test \"X$(AM_COLOR_TESTS)\" = Xalways; then \\\n    am__color_tests=yes; \\\n  elif test \"X$$TERM\" != Xdumb && { test -t 1; } 2>/dev/null; then \\\n    am__color_tests=yes; \\\n  fi; \\\n  if test $$am__color_tests = yes; then \\\n    red='\u001b[0;31m'; \\\n    grn='\u001b[0;32m'; \\\n    lgn='\u001b[1;32m'; \\\n    blu='\u001b[1;34m'; \\\n    mgn='\u001b[0;35m'; \\\n    brg='\u001b[1m'; \\\n    std='\u001b[m'; \\\n  fi; \\\n}\nam__recheck_rx = ^[ \t]*:recheck:[ \t]*\nam__global_test_result_rx = ^[ \t]*:global-test-result:[ \t]*\nam__copy_in_global_log_rx = ^[ \t]*:copy-in-global-log:[ \t]*\n# A command that, given a newline-separated list of test names on the\n# standard input, print the name of the tests that are to be re-run\n# upon \"make recheck\".\nam__list_recheck_tests = $(AWK) '{ \\\n  recheck = 1; \\\n  while ((rc = (getline line < ($$0 \".trs\"))) != 0) \\\n    { \\\n      if (rc < 0) \\\n        { \\\n          if ((getline line2 < ($$0 \".log\")) < 0) \\\n\t    recheck = 0; \\\n          break; \\\n        } \\\n      else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \\\n        { \\\n          recheck = 0; \\\n          break; \\\n        } \\\n      else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \\\n        { \\\n          break; \\\n        } \\\n    }; \\\n  if (recheck) \\\n    print $$0; \\\n  close ($$0 \".trs\"); \\\n  close ($$0 \".log\"); \\\n}'\n# A command that, given a newline-separated list of test names on the\n# standard input, create the global log from their .trs and .log files.\nam__create_global_log = $(AWK) ' \\\nfunction fatal(msg) \\\n{ \\\n  print \"fatal: making $@: \" msg | \"cat >&2\"; \\\n  exit 1; \\\n} \\\nfunction rst_section(header) \\\n{ \\\n  print header; \\\n  len = length(header); \\\n  for (i = 1; i <= len; i = i + 1) \\\n    printf \"=\"; \\\n  printf \"\\n\\n\"; \\\n} \\\n{ \\\n  copy_in_global_log = 1; \\\n  global_test_result = \"RUN\"; \\\n  while ((rc = (getline line < ($$0 \".trs\"))) != 0) \\\n    { \\\n      if (rc < 0) \\\n         fatal(\"failed to read from \" $$0 \".trs\"); \\\n      if (line ~ /$(am__global_test_result_rx)/) \\\n        { \\\n          sub(\"$(am__global_test_result_rx)\", \"\", line); \\\n          sub(\"[ \t]*$$\", \"\", line); \\\n          global_test_result = line; \\\n        } \\\n      else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \\\n        copy_in_global_log = 0; \\\n    }; \\\n  if (copy_in_global_log) \\\n    { \\\n      rst_section(global_test_result \": \" $$0); \\\n      while ((rc = (getline line < ($$0 \".log\"))) != 0) \\\n      { \\\n        if (rc < 0) \\\n          fatal(\"failed to read from \" $$0 \".log\"); \\\n        print line; \\\n      }; \\\n      printf \"\\n\"; \\\n    }; \\\n  close ($$0 \".trs\"); \\\n  close ($$0 \".log\"); \\\n}'\n# Restructured Text title.\nam__rst_title = { sed 's/.*/   &   /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }\n# Solaris 10 'make', and several other traditional 'make' implementations,\n# pass \"-e\" to $(SHELL), and POSIX 2008 even requires this.  Work around it\n# by disabling -e (using the XSI extension \"set +e\") if it's set.\nam__sh_e_setup = case $$- in *e*) set +e;; esac\n# Default flags passed to test drivers.\nam__common_driver_flags = \\\n  --color-tests \"$$am__color_tests\" \\\n  --enable-hard-errors \"$$am__enable_hard_errors\" \\\n  --expect-failure \"$$am__expect_failure\"\n# To be inserted before the command running the test.  Creates the\n# directory for the log if needed.  Stores in $dir the directory\n# containing $f, in $tst the test, in $log the log.  Executes the\n# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and\n# passes TESTS_ENVIRONMENT.  Set up options for the wrapper that\n# will run the test scripts (or their associated LOG_COMPILER, if\n# thy have one).\nam__check_pre = \\\n$(am__sh_e_setup);\t\t\t\t\t\\\n$(am__vpath_adj_setup) $(am__vpath_adj)\t\t\t\\\n$(am__tty_colors);\t\t\t\t\t\\\nsrcdir=$(srcdir); export srcdir;\t\t\t\\\ncase \"$@\" in\t\t\t\t\t\t\\\n  */*) am__odir=`echo \"./$@\" | sed 's|/[^/]*$$||'`;;\t\\\n    *) am__odir=.;; \t\t\t\t\t\\\nesac;\t\t\t\t\t\t\t\\\ntest \"x$$am__odir\" = x\".\" || test -d \"$$am__odir\" \t\\\n  || $(MKDIR_P) \"$$am__odir\" || exit $$?;\t\t\\\nif test -f \"./$$f\"; then dir=./;\t\t\t\\\nelif test -f \"$$f\"; then dir=;\t\t\t\t\\\nelse dir=\"$(srcdir)/\"; fi;\t\t\t\t\\\ntst=$$dir$$f; log='$@'; \t\t\t\t\\\nif test -n '$(DISABLE_HARD_ERRORS)'; then\t\t\\\n  am__enable_hard_errors=no; \t\t\t\t\\\nelse\t\t\t\t\t\t\t\\\n  am__enable_hard_errors=yes; \t\t\t\t\\\nfi; \t\t\t\t\t\t\t\\\ncase \" $(XFAIL_TESTS) \" in\t\t\t\t\\\n  *[\\ \\\t]$$f[\\ \\\t]* | *[\\ \\\t]$$dir$$f[\\ \\\t]*) \\\n    am__expect_failure=yes;;\t\t\t\t\\\n  *)\t\t\t\t\t\t\t\\\n    am__expect_failure=no;;\t\t\t\t\\\nesac; \t\t\t\t\t\t\t\\\n$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)\n# A shell command to get the names of the tests scripts with any registered\n# extension removed (i.e., equivalently, the names of the test logs, with\n# the '.log' extension removed).  The result is saved in the shell variable\n# '$bases'.  This honors runtime overriding of TESTS and TEST_LOGS.  Sadly,\n# we cannot use something simpler, involving e.g., \"$(TEST_LOGS:.log=)\",\n# since that might cause problem with VPATH rewrites for suffix-less tests.\n# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'.\nam__set_TESTS_bases = \\\n  bases='$(TEST_LOGS)'; \\\n  bases=`for i in $$bases; do echo $$i; done | sed 's/\\.log$$//'`; \\\n  bases=`echo $$bases`\nRECHECK_LOGS = $(TEST_LOGS)\nAM_RECURSIVE_TARGETS = check recheck\n@HAVE_ZLIB_TRUE@am__EXEEXT_2 =  \\\n@HAVE_ZLIB_TRUE@\tgoogle/protobuf/io/gzip_stream_unittest.sh\nTEST_SUITE_LOG = test-suite.log\nTEST_EXTENSIONS = @EXEEXT@ .test\nLOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver\nLOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS)\nam__set_b = \\\n  case '$@' in \\\n    */*) \\\n      case '$*' in \\\n        */*) b='$*';; \\\n          *) b=`echo '$@' | sed 's/\\.log$$//'`; \\\n       esac;; \\\n    *) \\\n      b='$*';; \\\n  esac\nam__test_logs1 = $(TESTS:=.log)\nam__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log)\nTEST_LOGS = $(am__test_logs2:.test.log=.log)\nTEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver\nTEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \\\n\t$(TEST_LOG_FLAGS)\nDISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)\nACLOCAL = @ACLOCAL@\nAMTAR = @AMTAR@\nAM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@\nAR = @AR@\nAUTOCONF = @AUTOCONF@\nAUTOHEADER = @AUTOHEADER@\nAUTOMAKE = @AUTOMAKE@\nAWK = @AWK@\nCC = @CC@\nCCDEPMODE = @CCDEPMODE@\nCFLAGS = @CFLAGS@\nCPPFLAGS = @CPPFLAGS@\nCXX = @CXX@\nCXXCPP = @CXXCPP@\nCXXDEPMODE = @CXXDEPMODE@\nCXXFLAGS = @CXXFLAGS@\nCYGPATH_W = @CYGPATH_W@\nDEFS = @DEFS@\nDEPDIR = @DEPDIR@\nDIST_LANG = @DIST_LANG@\nDLLTOOL = @DLLTOOL@\nDSYMUTIL = @DSYMUTIL@\nDUMPBIN = @DUMPBIN@\nECHO_C = @ECHO_C@\nECHO_N = @ECHO_N@\nECHO_T = @ECHO_T@\nEGREP = @EGREP@\nEXEEXT = @EXEEXT@\nFGREP = @FGREP@\nGREP = @GREP@\nINSTALL = @INSTALL@\nINSTALL_DATA = @INSTALL_DATA@\nINSTALL_PROGRAM = @INSTALL_PROGRAM@\nINSTALL_SCRIPT = @INSTALL_SCRIPT@\nINSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@\nISAINFO = @ISAINFO@\nLD = @LD@\nLDFLAGS = @LDFLAGS@\nLIBOBJS = @LIBOBJS@\nLIBS = @LIBS@\nLIBTOOL = @LIBTOOL@\nLIPO = @LIPO@\nLN_S = @LN_S@\nLTLIBOBJS = @LTLIBOBJS@\nMAINT = @MAINT@\nMAKEINFO = @MAKEINFO@\nMANIFEST_TOOL = @MANIFEST_TOOL@\nMKDIR_P = @MKDIR_P@\nNM = @NM@\nNMEDIT = @NMEDIT@\nOBJC = @OBJC@\nOBJCDEPMODE = @OBJCDEPMODE@\nOBJCFLAGS = @OBJCFLAGS@\nOBJDUMP = @OBJDUMP@\nOBJEXT = @OBJEXT@\nOTOOL = @OTOOL@\nOTOOL64 = @OTOOL64@\nPACKAGE = @PACKAGE@\nPACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@\nPACKAGE_NAME = @PACKAGE_NAME@\nPACKAGE_STRING = @PACKAGE_STRING@\nPACKAGE_TARNAME = @PACKAGE_TARNAME@\nPACKAGE_URL = @PACKAGE_URL@\nPACKAGE_VERSION = @PACKAGE_VERSION@\nPATH_SEPARATOR = @PATH_SEPARATOR@\nPOW_LIB = @POW_LIB@\nPROTOBUF_OPT_FLAG = @PROTOBUF_OPT_FLAG@\nPROTOC = @PROTOC@\nPTHREAD_CC = @PTHREAD_CC@\nPTHREAD_CFLAGS = @PTHREAD_CFLAGS@\nPTHREAD_LIBS = @PTHREAD_LIBS@\nRANLIB = @RANLIB@\nSED = @SED@\nSET_MAKE = @SET_MAKE@\nSHELL = @SHELL@\nSTRIP = @STRIP@\nVERSION = @VERSION@\nabs_builddir = @abs_builddir@\nabs_srcdir = @abs_srcdir@\nabs_top_builddir = @abs_top_builddir@\nabs_top_srcdir = @abs_top_srcdir@\nac_ct_AR = @ac_ct_AR@\nac_ct_CC = @ac_ct_CC@\nac_ct_CXX = @ac_ct_CXX@\nac_ct_DUMPBIN = @ac_ct_DUMPBIN@\nac_ct_OBJC = @ac_ct_OBJC@\nacx_pthread_config = @acx_pthread_config@\nam__include = @am__include@\nam__leading_dot = @am__leading_dot@\nam__quote = @am__quote@\nam__tar = @am__tar@\nam__untar = @am__untar@\nbindir = @bindir@\nbuild = @build@\nbuild_alias = @build_alias@\nbuild_cpu = @build_cpu@\nbuild_os = @build_os@\nbuild_vendor = @build_vendor@\nbuilddir = @builddir@\ndatadir = @datadir@\ndatarootdir = @datarootdir@\ndocdir = @docdir@\ndvidir = @dvidir@\nexec_prefix = @exec_prefix@\nhost = @host@\nhost_alias = @host_alias@\nhost_cpu = @host_cpu@\nhost_os = @host_os@\nhost_vendor = @host_vendor@\nhtmldir = @htmldir@\nincludedir = @includedir@\ninfodir = @infodir@\ninstall_sh = @install_sh@\nlibdir = @libdir@\nlibexecdir = @libexecdir@\nlocaledir = @localedir@\nlocalstatedir = @localstatedir@\nmandir = @mandir@\nmkdir_p = @mkdir_p@\noldincludedir = @oldincludedir@\npdfdir = @pdfdir@\nprefix = @prefix@\nprogram_transform_name = @program_transform_name@\npsdir = @psdir@\nsbindir = @sbindir@\nsharedstatedir = @sharedstatedir@\nsrcdir = @srcdir@\nsubdirs = @subdirs@\nsysconfdir = @sysconfdir@\ntarget = @target@\ntarget_alias = @target_alias@\ntarget_cpu = @target_cpu@\ntarget_os = @target_os@\ntarget_vendor = @target_vendor@\ntop_build_prefix = @top_build_prefix@\ntop_builddir = @top_builddir@\ntop_srcdir = @top_srcdir@\n@HAVE_ZLIB_FALSE@GZCHECKPROGRAMS = \n@HAVE_ZLIB_TRUE@GZCHECKPROGRAMS = zcgzip zcgunzip\n@HAVE_ZLIB_FALSE@GZHEADERS = \n@HAVE_ZLIB_TRUE@GZHEADERS = google/protobuf/io/gzip_stream.h\n@HAVE_ZLIB_FALSE@GZTESTS = \n@HAVE_ZLIB_TRUE@GZTESTS = google/protobuf/io/gzip_stream_unittest.sh\n@HAVE_ZLIB_FALSE@ZLIB_DEF = \n@HAVE_ZLIB_TRUE@ZLIB_DEF = -DHAVE_ZLIB=1\n@HAVE_PTHREAD_FALSE@PTHREAD_DEF = \n@HAVE_PTHREAD_TRUE@PTHREAD_DEF = -DHAVE_PTHREAD=1\n@GCC_FALSE@NO_OPT_CXXFLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_DEF) $(ZLIB_DEF)\n\n# Turn on all warnings except for sign comparison (we ignore sign comparison\n# in Google so our code base have tons of such warnings).\n@GCC_TRUE@NO_OPT_CXXFLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_DEF) $(ZLIB_DEF) -Wall -Wno-sign-compare\nAM_CXXFLAGS = $(NO_OPT_CXXFLAGS) $(PROTOBUF_OPT_FLAG)\nAM_LDFLAGS = $(PTHREAD_CFLAGS)\n\n# If I say \"dist_include_DATA\", automake complains that $(includedir) is not\n# a \"legitimate\" directory for DATA.  Screw you, automake.\nprotodir = $(includedir)\nnobase_dist_proto_DATA = google/protobuf/descriptor.proto     \\\n                         google/protobuf/any.proto            \\\n                         google/protobuf/api.proto            \\\n                         google/protobuf/duration.proto       \\\n                         google/protobuf/empty.proto          \\\n                         google/protobuf/field_mask.proto     \\\n                         google/protobuf/source_context.proto \\\n                         google/protobuf/struct.proto         \\\n                         google/protobuf/timestamp.proto      \\\n                         google/protobuf/type.proto           \\\n                         google/protobuf/wrappers.proto       \\\n                         google/protobuf/compiler/plugin.proto\n\nCLEANFILES = $(protoc_outputs) unittest_proto_middleman \\\n             testzip.jar testzip.list testzip.proto testzip.zip \\\n             no_warning_test.cc\n\nMAINTAINERCLEANFILES = \\\n  Makefile.in\n\nnobase_include_HEADERS = \\\n  google/protobuf/stubs/atomic_sequence_num.h                   \\\n  google/protobuf/stubs/atomicops.h                             \\\n  google/protobuf/stubs/atomicops_internals_power.h             \\\n  google/protobuf/stubs/atomicops_internals_ppc_gcc.h           \\\n  google/protobuf/stubs/atomicops_internals_arm64_gcc.h         \\\n  google/protobuf/stubs/atomicops_internals_arm_gcc.h           \\\n  google/protobuf/stubs/atomicops_internals_arm_qnx.h           \\\n  google/protobuf/stubs/atomicops_internals_atomicword_compat.h \\\n  google/protobuf/stubs/atomicops_internals_generic_gcc.h       \\\n  google/protobuf/stubs/atomicops_internals_macosx.h            \\\n  google/protobuf/stubs/atomicops_internals_mips_gcc.h          \\\n  google/protobuf/stubs/atomicops_internals_pnacl.h             \\\n  google/protobuf/stubs/atomicops_internals_solaris.h           \\\n  google/protobuf/stubs/atomicops_internals_tsan.h              \\\n  google/protobuf/stubs/atomicops_internals_x86_gcc.h           \\\n  google/protobuf/stubs/atomicops_internals_x86_msvc.h          \\\n  google/protobuf/stubs/callback.h                              \\\n  google/protobuf/stubs/bytestream.h                            \\\n  google/protobuf/stubs/casts.h                                 \\\n  google/protobuf/stubs/common.h                                \\\n  google/protobuf/stubs/fastmem.h                               \\\n  google/protobuf/stubs/hash.h                                  \\\n  google/protobuf/stubs/logging.h                               \\\n  google/protobuf/stubs/macros.h                                \\\n  google/protobuf/stubs/mutex.h                                 \\\n  google/protobuf/stubs/once.h                                  \\\n  google/protobuf/stubs/platform_macros.h                       \\\n  google/protobuf/stubs/port.h                                  \\\n  google/protobuf/stubs/scoped_ptr.h                            \\\n  google/protobuf/stubs/shared_ptr.h                            \\\n  google/protobuf/stubs/singleton.h                             \\\n  google/protobuf/stubs/status.h                                \\\n  google/protobuf/stubs/stl_util.h                              \\\n  google/protobuf/stubs/stringpiece.h                           \\\n  google/protobuf/stubs/template_util.h                         \\\n  google/protobuf/stubs/type_traits.h                           \\\n  google/protobuf/any.pb.h                                      \\\n  google/protobuf/api.pb.h                                      \\\n  google/protobuf/any.h                                         \\\n  google/protobuf/arena.h                                       \\\n  google/protobuf/arenastring.h                                 \\\n  google/protobuf/descriptor_database.h                         \\\n  google/protobuf/descriptor.h                                  \\\n  google/protobuf/descriptor.pb.h                               \\\n  google/protobuf/duration.pb.h                                 \\\n  google/protobuf/dynamic_message.h                             \\\n  google/protobuf/empty.pb.h                                    \\\n  google/protobuf/extension_set.h                               \\\n  google/protobuf/field_mask.pb.h                               \\\n  google/protobuf/generated_enum_reflection.h                   \\\n  google/protobuf/generated_enum_util.h                         \\\n  google/protobuf/generated_message_reflection.h                \\\n  google/protobuf/generated_message_util.h                      \\\n  google/protobuf/map_entry.h                                   \\\n  google/protobuf/map_entry_lite.h                              \\\n  google/protobuf/map_field.h                                   \\\n  google/protobuf/map_field_inl.h                               \\\n  google/protobuf/map_field_lite.h                              \\\n  google/protobuf/map.h                                         \\\n  google/protobuf/map_type_handler.h                            \\\n  google/protobuf/message.h                                     \\\n  google/protobuf/message_lite.h                                \\\n  google/protobuf/metadata.h                                    \\\n  google/protobuf/reflection.h                                  \\\n  google/protobuf/reflection_ops.h                              \\\n  google/protobuf/repeated_field.h                              \\\n  google/protobuf/service.h                                     \\\n  google/protobuf/source_context.pb.h                           \\\n  google/protobuf/struct.pb.h                                   \\\n  google/protobuf/text_format.h                                 \\\n  google/protobuf/timestamp.pb.h                                \\\n  google/protobuf/type.pb.h                                     \\\n  google/protobuf/unknown_field_set.h                           \\\n  google/protobuf/wire_format.h                                 \\\n  google/protobuf/wire_format_lite.h                            \\\n  google/protobuf/wire_format_lite_inl.h                        \\\n  google/protobuf/wrappers.pb.h                                 \\\n  google/protobuf/io/coded_stream.h                             \\\n  $(GZHEADERS)                                                  \\\n  google/protobuf/io/printer.h                                  \\\n  google/protobuf/io/strtod.h                                   \\\n  google/protobuf/io/tokenizer.h                                \\\n  google/protobuf/io/zero_copy_stream.h                         \\\n  google/protobuf/io/zero_copy_stream_impl.h                    \\\n  google/protobuf/io/zero_copy_stream_impl_lite.h               \\\n  google/protobuf/compiler/code_generator.h                     \\\n  google/protobuf/compiler/command_line_interface.h             \\\n  google/protobuf/compiler/importer.h                           \\\n  google/protobuf/compiler/parser.h                             \\\n  google/protobuf/compiler/plugin.h                             \\\n  google/protobuf/compiler/plugin.pb.h                          \\\n  google/protobuf/compiler/cpp/cpp_generator.h                  \\\n  google/protobuf/compiler/csharp/csharp_generator.h            \\\n  google/protobuf/compiler/csharp/csharp_names.h                \\\n  google/protobuf/compiler/java/java_generator.h                \\\n  google/protobuf/compiler/java/java_names.h                    \\\n  google/protobuf/compiler/javanano/javanano_generator.h        \\\n  google/protobuf/compiler/js/js_generator.h                    \\\n  google/protobuf/compiler/objectivec/objectivec_generator.h    \\\n  google/protobuf/compiler/objectivec/objectivec_helpers.h      \\\n  google/protobuf/compiler/python/python_generator.h            \\\n  google/protobuf/compiler/ruby/ruby_generator.h                \\\n  google/protobuf/util/type_resolver.h                          \\\n  google/protobuf/util/field_comparator.h                       \\\n  google/protobuf/util/field_mask_util.h                        \\\n  google/protobuf/util/json_util.h                              \\\n  google/protobuf/util/time_util.h                              \\\n  google/protobuf/util/type_resolver_util.h                     \\\n  google/protobuf/util/message_differencer.h\n\nlib_LTLIBRARIES = libprotobuf-lite.la libprotobuf.la libprotoc.la\nlibprotobuf_lite_la_LIBADD = $(PTHREAD_LIBS)\nlibprotobuf_lite_la_LDFLAGS = -version-info 10:0:0 -export-dynamic -no-undefined\nlibprotobuf_lite_la_SOURCES = \\\n  google/protobuf/stubs/atomicops_internals_x86_gcc.cc         \\\n  google/protobuf/stubs/atomicops_internals_x86_msvc.cc        \\\n  google/protobuf/stubs/bytestream.cc                          \\\n  google/protobuf/stubs/bytestream.h                           \\\n  google/protobuf/stubs/common.cc                              \\\n  google/protobuf/stubs/hash.h                                 \\\n  google/protobuf/stubs/int128.cc                              \\\n  google/protobuf/stubs/int128.h                               \\\n  google/protobuf/stubs/map_util.h                             \\\n  google/protobuf/stubs/mathutil.h                             \\\n  google/protobuf/stubs/once.cc                                \\\n  google/protobuf/stubs/shared_ptr.h                           \\\n  google/protobuf/stubs/status.cc                              \\\n  google/protobuf/stubs/status.h                               \\\n  google/protobuf/stubs/status_macros.h                        \\\n  google/protobuf/stubs/statusor.cc                            \\\n  google/protobuf/stubs/statusor.h                             \\\n  google/protobuf/stubs/stringpiece.cc                         \\\n  google/protobuf/stubs/stringpiece.h                          \\\n  google/protobuf/stubs/stringprintf.cc                        \\\n  google/protobuf/stubs/stringprintf.h                         \\\n  google/protobuf/stubs/structurally_valid.cc                  \\\n  google/protobuf/stubs/strutil.cc                             \\\n  google/protobuf/stubs/strutil.h                              \\\n  google/protobuf/stubs/time.cc                                \\\n  google/protobuf/stubs/time.h                                 \\\n  google/protobuf/arena.cc                                     \\\n  google/protobuf/arenastring.cc                               \\\n  google/protobuf/extension_set.cc                             \\\n  google/protobuf/generated_message_util.cc                    \\\n  google/protobuf/message_lite.cc                              \\\n  google/protobuf/repeated_field.cc                            \\\n  google/protobuf/wire_format_lite.cc                          \\\n  google/protobuf/io/coded_stream.cc                           \\\n  google/protobuf/io/coded_stream_inl.h                        \\\n  google/protobuf/io/zero_copy_stream.cc                       \\\n  google/protobuf/io/zero_copy_stream_impl_lite.cc\n\nlibprotobuf_la_LIBADD = $(PTHREAD_LIBS)\nlibprotobuf_la_LDFLAGS = -version-info 10:0:0 -export-dynamic -no-undefined\nlibprotobuf_la_SOURCES = \\\n  $(libprotobuf_lite_la_SOURCES)                               \\\n  google/protobuf/any.pb.cc                                    \\\n  google/protobuf/api.pb.cc                                    \\\n  google/protobuf/stubs/mathlimits.cc                          \\\n  google/protobuf/stubs/mathlimits.h                           \\\n  google/protobuf/any.cc                                       \\\n  google/protobuf/descriptor.cc                                \\\n  google/protobuf/descriptor_database.cc                       \\\n  google/protobuf/descriptor.pb.cc                             \\\n  google/protobuf/duration.pb.cc                               \\\n  google/protobuf/dynamic_message.cc                           \\\n  google/protobuf/empty.pb.cc                                  \\\n  google/protobuf/extension_set_heavy.cc                       \\\n  google/protobuf/field_mask.pb.cc                             \\\n  google/protobuf/generated_message_reflection.cc              \\\n  google/protobuf/map_field.cc                                 \\\n  google/protobuf/message.cc                                   \\\n  google/protobuf/reflection_internal.h                        \\\n  google/protobuf/reflection_ops.cc                            \\\n  google/protobuf/service.cc                                   \\\n  google/protobuf/source_context.pb.cc                         \\\n  google/protobuf/struct.pb.cc                                 \\\n  google/protobuf/stubs/substitute.cc                          \\\n  google/protobuf/stubs/substitute.h                           \\\n  google/protobuf/text_format.cc                               \\\n  google/protobuf/timestamp.pb.cc                              \\\n  google/protobuf/type.pb.cc                                   \\\n  google/protobuf/unknown_field_set.cc                         \\\n  google/protobuf/wire_format.cc                               \\\n  google/protobuf/wrappers.pb.cc                               \\\n  google/protobuf/io/gzip_stream.cc                            \\\n  google/protobuf/io/printer.cc                                \\\n  google/protobuf/io/strtod.cc                                 \\\n  google/protobuf/io/tokenizer.cc                              \\\n  google/protobuf/io/zero_copy_stream_impl.cc                  \\\n  google/protobuf/compiler/importer.cc                         \\\n  google/protobuf/compiler/parser.cc                           \\\n  google/protobuf/util/field_comparator.cc                     \\\n  google/protobuf/util/field_mask_util.cc                      \\\n  google/protobuf/util/internal/constants.h                    \\\n  google/protobuf/util/internal/datapiece.cc                   \\\n  google/protobuf/util/internal/datapiece.h                    \\\n  google/protobuf/util/internal/default_value_objectwriter.cc  \\\n  google/protobuf/util/internal/default_value_objectwriter.h   \\\n  google/protobuf/util/internal/error_listener.cc              \\\n  google/protobuf/util/internal/error_listener.h               \\\n  google/protobuf/util/internal/expecting_objectwriter.h       \\\n  google/protobuf/util/internal/field_mask_utility.cc          \\\n  google/protobuf/util/internal/field_mask_utility.h           \\\n  google/protobuf/util/internal/json_escaping.cc               \\\n  google/protobuf/util/internal/json_escaping.h                \\\n  google/protobuf/util/internal/json_objectwriter.cc           \\\n  google/protobuf/util/internal/json_objectwriter.h            \\\n  google/protobuf/util/internal/json_stream_parser.cc          \\\n  google/protobuf/util/internal/json_stream_parser.h           \\\n  google/protobuf/util/internal/location_tracker.h             \\\n  google/protobuf/util/internal/mock_error_listener.h          \\\n  google/protobuf/util/internal/object_location_tracker.h      \\\n  google/protobuf/util/internal/object_source.h                \\\n  google/protobuf/util/internal/object_writer.cc               \\\n  google/protobuf/util/internal/object_writer.h                \\\n  google/protobuf/util/internal/protostream_objectsource.cc    \\\n  google/protobuf/util/internal/protostream_objectsource.h     \\\n  google/protobuf/util/internal/protostream_objectwriter.cc    \\\n  google/protobuf/util/internal/protostream_objectwriter.h     \\\n  google/protobuf/util/internal/proto_writer.cc                \\\n  google/protobuf/util/internal/proto_writer.h                 \\\n  google/protobuf/util/internal/structured_objectwriter.h      \\\n  google/protobuf/util/internal/type_info.cc                   \\\n  google/protobuf/util/internal/type_info.h                    \\\n  google/protobuf/util/internal/type_info_test_helper.cc       \\\n  google/protobuf/util/internal/type_info_test_helper.h        \\\n  google/protobuf/util/internal/utility.cc                     \\\n  google/protobuf/util/internal/utility.h                      \\\n  google/protobuf/util/json_util.cc                            \\\n  google/protobuf/util/message_differencer.cc                  \\\n  google/protobuf/util/time_util.cc                            \\\n  google/protobuf/util/type_resolver_util.cc\n\nnodist_libprotobuf_la_SOURCES = $(nodist_libprotobuf_lite_la_SOURCES)\nlibprotoc_la_LIBADD = $(PTHREAD_LIBS) libprotobuf.la\nlibprotoc_la_LDFLAGS = -version-info 10:0:0 -export-dynamic -no-undefined\nlibprotoc_la_SOURCES = \\\n  google/protobuf/compiler/code_generator.cc                   \\\n  google/protobuf/compiler/command_line_interface.cc           \\\n  google/protobuf/compiler/plugin.cc                           \\\n  google/protobuf/compiler/plugin.pb.cc                        \\\n  google/protobuf/compiler/subprocess.cc                       \\\n  google/protobuf/compiler/subprocess.h                        \\\n  google/protobuf/compiler/zip_writer.cc                       \\\n  google/protobuf/compiler/zip_writer.h                        \\\n  google/protobuf/compiler/cpp/cpp_enum.cc                     \\\n  google/protobuf/compiler/cpp/cpp_enum.h                      \\\n  google/protobuf/compiler/cpp/cpp_enum_field.cc               \\\n  google/protobuf/compiler/cpp/cpp_enum_field.h                \\\n  google/protobuf/compiler/cpp/cpp_extension.cc                \\\n  google/protobuf/compiler/cpp/cpp_extension.h                 \\\n  google/protobuf/compiler/cpp/cpp_field.cc                    \\\n  google/protobuf/compiler/cpp/cpp_field.h                     \\\n  google/protobuf/compiler/cpp/cpp_file.cc                     \\\n  google/protobuf/compiler/cpp/cpp_file.h                      \\\n  google/protobuf/compiler/cpp/cpp_generator.cc                \\\n  google/protobuf/compiler/cpp/cpp_helpers.cc                  \\\n  google/protobuf/compiler/cpp/cpp_helpers.h                   \\\n  google/protobuf/compiler/cpp/cpp_map_field.cc                \\\n  google/protobuf/compiler/cpp/cpp_map_field.h                 \\\n  google/protobuf/compiler/cpp/cpp_message.cc                  \\\n  google/protobuf/compiler/cpp/cpp_message.h                   \\\n  google/protobuf/compiler/cpp/cpp_message_field.cc            \\\n  google/protobuf/compiler/cpp/cpp_message_field.h             \\\n  google/protobuf/compiler/cpp/cpp_options.h                   \\\n  google/protobuf/compiler/cpp/cpp_primitive_field.cc          \\\n  google/protobuf/compiler/cpp/cpp_primitive_field.h           \\\n  google/protobuf/compiler/cpp/cpp_service.cc                  \\\n  google/protobuf/compiler/cpp/cpp_service.h                   \\\n  google/protobuf/compiler/cpp/cpp_string_field.cc             \\\n  google/protobuf/compiler/cpp/cpp_string_field.h              \\\n  google/protobuf/compiler/java/java_context.cc                \\\n  google/protobuf/compiler/java/java_context.h                 \\\n  google/protobuf/compiler/java/java_enum.cc                   \\\n  google/protobuf/compiler/java/java_enum_lite.cc              \\\n  google/protobuf/compiler/java/java_enum_field.cc             \\\n  google/protobuf/compiler/java/java_enum_field.h              \\\n  google/protobuf/compiler/java/java_enum_field_lite.cc        \\\n  google/protobuf/compiler/java/java_enum_field_lite.h         \\\n  google/protobuf/compiler/java/java_enum.h                    \\\n  google/protobuf/compiler/java/java_enum_lite.h               \\\n  google/protobuf/compiler/java/java_extension.cc              \\\n  google/protobuf/compiler/java/java_extension.h               \\\n  google/protobuf/compiler/java/java_extension_lite.cc         \\\n  google/protobuf/compiler/java/java_extension_lite.h          \\\n  google/protobuf/compiler/java/java_field.cc                  \\\n  google/protobuf/compiler/java/java_field.h                   \\\n  google/protobuf/compiler/java/java_file.cc                   \\\n  google/protobuf/compiler/java/java_file.h                    \\\n  google/protobuf/compiler/java/java_generator.cc              \\\n  google/protobuf/compiler/java/java_generator_factory.cc      \\\n  google/protobuf/compiler/java/java_generator_factory.h       \\\n  google/protobuf/compiler/java/java_helpers.cc                \\\n  google/protobuf/compiler/java/java_helpers.h                 \\\n  google/protobuf/compiler/java/java_lazy_message_field.cc     \\\n  google/protobuf/compiler/java/java_lazy_message_field.h      \\\n  google/protobuf/compiler/java/java_lazy_message_field_lite.cc\\\n  google/protobuf/compiler/java/java_lazy_message_field_lite.h \\\n  google/protobuf/compiler/java/java_map_field.cc              \\\n  google/protobuf/compiler/java/java_map_field.h               \\\n  google/protobuf/compiler/java/java_map_field_lite.cc         \\\n  google/protobuf/compiler/java/java_map_field_lite.h          \\\n  google/protobuf/compiler/java/java_message.cc                \\\n  google/protobuf/compiler/java/java_message_lite.cc           \\\n  google/protobuf/compiler/java/java_message_builder.cc        \\\n  google/protobuf/compiler/java/java_message_builder_lite.cc   \\\n  google/protobuf/compiler/java/java_message_field.cc          \\\n  google/protobuf/compiler/java/java_message_field.h           \\\n  google/protobuf/compiler/java/java_message_field_lite.cc     \\\n  google/protobuf/compiler/java/java_message_field_lite.h      \\\n  google/protobuf/compiler/java/java_message.h                 \\\n  google/protobuf/compiler/java/java_message_lite.h            \\\n  google/protobuf/compiler/java/java_message_builder.h         \\\n  google/protobuf/compiler/java/java_message_builder_lite.h    \\\n  google/protobuf/compiler/java/java_name_resolver.cc          \\\n  google/protobuf/compiler/java/java_name_resolver.h           \\\n  google/protobuf/compiler/java/java_options.h                 \\\n  google/protobuf/compiler/java/java_primitive_field.cc        \\\n  google/protobuf/compiler/java/java_primitive_field.h         \\\n  google/protobuf/compiler/java/java_primitive_field_lite.cc   \\\n  google/protobuf/compiler/java/java_primitive_field_lite.h    \\\n  google/protobuf/compiler/java/java_shared_code_generator.cc  \\\n  google/protobuf/compiler/java/java_shared_code_generator.h   \\\n  google/protobuf/compiler/java/java_service.cc                \\\n  google/protobuf/compiler/java/java_service.h                 \\\n  google/protobuf/compiler/java/java_string_field.cc           \\\n  google/protobuf/compiler/java/java_string_field.h            \\\n  google/protobuf/compiler/java/java_string_field_lite.cc      \\\n  google/protobuf/compiler/java/java_string_field_lite.h       \\\n  google/protobuf/compiler/java/java_doc_comment.cc            \\\n  google/protobuf/compiler/java/java_doc_comment.h             \\\n  google/protobuf/compiler/js/js_generator.cc                  \\\n  google/protobuf/compiler/javanano/javanano_enum.cc           \\\n  google/protobuf/compiler/javanano/javanano_enum.h            \\\n  google/protobuf/compiler/javanano/javanano_enum_field.cc     \\\n  google/protobuf/compiler/javanano/javanano_enum_field.h      \\\n  google/protobuf/compiler/javanano/javanano_extension.cc      \\\n  google/protobuf/compiler/javanano/javanano_extension.h       \\\n  google/protobuf/compiler/javanano/javanano_field.cc          \\\n  google/protobuf/compiler/javanano/javanano_field.h           \\\n  google/protobuf/compiler/javanano/javanano_file.cc           \\\n  google/protobuf/compiler/javanano/javanano_file.h            \\\n  google/protobuf/compiler/javanano/javanano_generator.cc      \\\n  google/protobuf/compiler/javanano/javanano_generator.h       \\\n  google/protobuf/compiler/javanano/javanano_helpers.cc        \\\n  google/protobuf/compiler/javanano/javanano_helpers.h         \\\n  google/protobuf/compiler/javanano/javanano_map_field.cc      \\\n  google/protobuf/compiler/javanano/javanano_map_field.h       \\\n  google/protobuf/compiler/javanano/javanano_message.cc        \\\n  google/protobuf/compiler/javanano/javanano_message.h         \\\n  google/protobuf/compiler/javanano/javanano_message_field.cc  \\\n  google/protobuf/compiler/javanano/javanano_message_field.h   \\\n  google/protobuf/compiler/javanano/javanano_params.h          \\\n  google/protobuf/compiler/javanano/javanano_primitive_field.cc \\\n  google/protobuf/compiler/javanano/javanano_primitive_field.h \\\n  google/protobuf/compiler/objectivec/objectivec_enum.cc       \\\n  google/protobuf/compiler/objectivec/objectivec_enum.h        \\\n  google/protobuf/compiler/objectivec/objectivec_enum_field.cc \\\n  google/protobuf/compiler/objectivec/objectivec_enum_field.h  \\\n  google/protobuf/compiler/objectivec/objectivec_extension.cc  \\\n  google/protobuf/compiler/objectivec/objectivec_extension.h   \\\n  google/protobuf/compiler/objectivec/objectivec_field.cc      \\\n  google/protobuf/compiler/objectivec/objectivec_field.h       \\\n  google/protobuf/compiler/objectivec/objectivec_file.cc       \\\n  google/protobuf/compiler/objectivec/objectivec_file.h        \\\n  google/protobuf/compiler/objectivec/objectivec_generator.cc  \\\n  google/protobuf/compiler/objectivec/objectivec_helpers.cc    \\\n  google/protobuf/compiler/objectivec/objectivec_helpers.h     \\\n  google/protobuf/compiler/objectivec/objectivec_map_field.cc  \\\n  google/protobuf/compiler/objectivec/objectivec_map_field.h   \\\n  google/protobuf/compiler/objectivec/objectivec_message.cc    \\\n  google/protobuf/compiler/objectivec/objectivec_message.h     \\\n  google/protobuf/compiler/objectivec/objectivec_message_field.cc \\\n  google/protobuf/compiler/objectivec/objectivec_message_field.h \\\n  google/protobuf/compiler/objectivec/objectivec_oneof.cc      \\\n  google/protobuf/compiler/objectivec/objectivec_oneof.h       \\\n  google/protobuf/compiler/objectivec/objectivec_primitive_field.cc \\\n  google/protobuf/compiler/objectivec/objectivec_primitive_field.h \\\n  google/protobuf/compiler/python/python_generator.cc          \\\n  google/protobuf/compiler/ruby/ruby_generator.cc              \\\n  google/protobuf/compiler/csharp/csharp_doc_comment.cc        \\\n  google/protobuf/compiler/csharp/csharp_doc_comment.h         \\\n  google/protobuf/compiler/csharp/csharp_enum.cc               \\\n  google/protobuf/compiler/csharp/csharp_enum.h                \\\n  google/protobuf/compiler/csharp/csharp_enum_field.cc         \\\n  google/protobuf/compiler/csharp/csharp_enum_field.h          \\\n  google/protobuf/compiler/csharp/csharp_field_base.cc         \\\n  google/protobuf/compiler/csharp/csharp_field_base.h          \\\n  google/protobuf/compiler/csharp/csharp_generator.cc          \\\n  google/protobuf/compiler/csharp/csharp_helpers.cc            \\\n  google/protobuf/compiler/csharp/csharp_helpers.h             \\\n  google/protobuf/compiler/csharp/csharp_map_field.cc          \\\n  google/protobuf/compiler/csharp/csharp_map_field.h           \\\n  google/protobuf/compiler/csharp/csharp_message.cc            \\\n  google/protobuf/compiler/csharp/csharp_message.h             \\\n  google/protobuf/compiler/csharp/csharp_message_field.cc      \\\n  google/protobuf/compiler/csharp/csharp_message_field.h       \\\n  google/protobuf/compiler/csharp/csharp_options.h             \\\n  google/protobuf/compiler/csharp/csharp_primitive_field.cc    \\\n  google/protobuf/compiler/csharp/csharp_primitive_field.h     \\\n  google/protobuf/compiler/csharp/csharp_reflection_class.cc     \\\n  google/protobuf/compiler/csharp/csharp_reflection_class.h      \\\n  google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc \\\n  google/protobuf/compiler/csharp/csharp_repeated_enum_field.h \\\n  google/protobuf/compiler/csharp/csharp_repeated_message_field.cc \\\n  google/protobuf/compiler/csharp/csharp_repeated_message_field.h \\\n  google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc \\\n  google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h \\\n  google/protobuf/compiler/csharp/csharp_source_generator_base.cc \\\n  google/protobuf/compiler/csharp/csharp_source_generator_base.h \\\n  google/protobuf/compiler/csharp/csharp_wrapper_field.cc      \\\n  google/protobuf/compiler/csharp/csharp_wrapper_field.h\n\nprotoc_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la\nprotoc_SOURCES = google/protobuf/compiler/main.cc\n\n# Tests ==============================================================\nprotoc_inputs = \\\n  google/protobuf/any_test.proto                                  \\\n  google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto     \\\n  google/protobuf/map_lite_unittest.proto                         \\\n  google/protobuf/map_proto2_unittest.proto                       \\\n  google/protobuf/map_unittest.proto                              \\\n  google/protobuf/unittest_arena.proto                            \\\n  google/protobuf/unittest_custom_options.proto                   \\\n  google/protobuf/unittest_drop_unknown_fields.proto              \\\n  google/protobuf/unittest_embed_optimize_for.proto               \\\n  google/protobuf/unittest_empty.proto                            \\\n  google/protobuf/unittest_enormous_descriptor.proto              \\\n  google/protobuf/unittest_import_lite.proto                      \\\n  google/protobuf/unittest_import.proto                           \\\n  google/protobuf/unittest_import_public_lite.proto               \\\n  google/protobuf/unittest_import_public.proto                    \\\n  google/protobuf/unittest_lite_imports_nonlite.proto             \\\n  google/protobuf/unittest_lite.proto                             \\\n  google/protobuf/unittest_mset.proto                             \\\n  google/protobuf/unittest_mset_wire_format.proto                 \\\n  google/protobuf/unittest_no_arena_lite.proto                    \\\n  google/protobuf/unittest_no_arena_import.proto                  \\\n  google/protobuf/unittest_no_arena.proto                         \\\n  google/protobuf/unittest_no_field_presence.proto                \\\n  google/protobuf/unittest_no_generic_services.proto              \\\n  google/protobuf/unittest_optimize_for.proto                     \\\n  google/protobuf/unittest_preserve_unknown_enum2.proto           \\\n  google/protobuf/unittest_preserve_unknown_enum.proto            \\\n  google/protobuf/unittest.proto                                  \\\n  google/protobuf/unittest_proto3_arena.proto                     \\\n  google/protobuf/unittest_proto3_arena_lite.proto                     \\\n  google/protobuf/unittest_proto3_lite.proto                     \\\n  google/protobuf/unittest_well_known_types.proto                 \\\n  google/protobuf/util/internal/testdata/anys.proto               \\\n  google/protobuf/util/internal/testdata/books.proto              \\\n  google/protobuf/util/internal/testdata/default_value.proto      \\\n  google/protobuf/util/internal/testdata/default_value_test.proto \\\n  google/protobuf/util/internal/testdata/field_mask.proto         \\\n  google/protobuf/util/internal/testdata/maps.proto               \\\n  google/protobuf/util/internal/testdata/oneofs.proto             \\\n  google/protobuf/util/internal/testdata/struct.proto             \\\n  google/protobuf/util/internal/testdata/timestamp_duration.proto \\\n  google/protobuf/util/json_format_proto3.proto                   \\\n  google/protobuf/util/message_differencer_unittest.proto         \\\n  google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto\n\nEXTRA_DIST = \\\n  $(protoc_inputs)                                             \\\n  solaris/libstdc++.la                                         \\\n  google/protobuf/io/gzip_stream.h                             \\\n  google/protobuf/io/gzip_stream_unittest.sh                   \\\n  google/protobuf/testdata/golden_message                      \\\n  google/protobuf/testdata/golden_message_maps                 \\\n  google/protobuf/testdata/golden_message_oneof_implemented    \\\n  google/protobuf/testdata/golden_message_proto3               \\\n  google/protobuf/testdata/golden_packed_fields_message        \\\n  google/protobuf/testdata/bad_utf8_string                     \\\n  google/protobuf/testdata/map_test_data.txt                   \\\n  google/protobuf/testdata/text_format_unittest_data.txt       \\\n  google/protobuf/testdata/text_format_unittest_data_oneof_implemented.txt  \\\n  google/protobuf/testdata/text_format_unittest_data_pointy.txt             \\\n  google/protobuf/testdata/text_format_unittest_data_pointy_oneof.txt       \\\n  google/protobuf/testdata/text_format_unittest_extensions_data.txt         \\\n  google/protobuf/testdata/text_format_unittest_extensions_data_pointy.txt  \\\n  google/protobuf/package_info.h                               \\\n  google/protobuf/io/package_info.h                            \\\n  google/protobuf/compiler/ruby/ruby_generated_code.proto      \\\n  google/protobuf/compiler/ruby/ruby_generated_code_pb.rb      \\\n  google/protobuf/compiler/package_info.h                      \\\n  google/protobuf/compiler/zip_output_unittest.sh              \\\n  README.md\n\nprotoc_lite_outputs = \\\n  google/protobuf/map_lite_unittest.pb.cc                      \\\n  google/protobuf/map_lite_unittest.pb.h                       \\\n  google/protobuf/unittest_lite.pb.cc                          \\\n  google/protobuf/unittest_lite.pb.h                           \\\n  google/protobuf/unittest_no_arena_lite.pb.cc                 \\\n  google/protobuf/unittest_no_arena_lite.pb.h                  \\\n  google/protobuf/unittest_import_lite.pb.cc                   \\\n  google/protobuf/unittest_import_lite.pb.h                    \\\n  google/protobuf/unittest_import_public_lite.pb.cc            \\\n  google/protobuf/unittest_import_public_lite.pb.h\n\nprotoc_outputs = \\\n  $(protoc_lite_outputs)                                          \\\n  google/protobuf/any_test.pb.cc                                  \\\n  google/protobuf/any_test.pb.h                                   \\\n  google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc     \\\n  google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.h      \\\n  google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc    \\\n  google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.h     \\\n  google/protobuf/map_proto2_unittest.pb.cc                       \\\n  google/protobuf/map_proto2_unittest.pb.h                        \\\n  google/protobuf/map_unittest.pb.cc                              \\\n  google/protobuf/map_unittest.pb.h                               \\\n  google/protobuf/unittest_arena.pb.cc                            \\\n  google/protobuf/unittest_arena.pb.h                             \\\n  google/protobuf/unittest_custom_options.pb.cc                   \\\n  google/protobuf/unittest_custom_options.pb.h                    \\\n  google/protobuf/unittest_drop_unknown_fields.pb.cc              \\\n  google/protobuf/unittest_drop_unknown_fields.pb.h               \\\n  google/protobuf/unittest_embed_optimize_for.pb.cc               \\\n  google/protobuf/unittest_embed_optimize_for.pb.h                \\\n  google/protobuf/unittest_empty.pb.cc                            \\\n  google/protobuf/unittest_empty.pb.h                             \\\n  google/protobuf/unittest_enormous_descriptor.pb.cc              \\\n  google/protobuf/unittest_enormous_descriptor.pb.h               \\\n  google/protobuf/unittest_import.pb.cc                           \\\n  google/protobuf/unittest_import.pb.h                            \\\n  google/protobuf/unittest_import_public.pb.cc                    \\\n  google/protobuf/unittest_import_public.pb.h                     \\\n  google/protobuf/unittest_lite_imports_nonlite.pb.cc             \\\n  google/protobuf/unittest_lite_imports_nonlite.pb.h              \\\n  google/protobuf/unittest_mset.pb.cc                             \\\n  google/protobuf/unittest_mset.pb.h                              \\\n  google/protobuf/unittest_mset_wire_format.pb.cc                 \\\n  google/protobuf/unittest_mset_wire_format.pb.h                  \\\n  google/protobuf/unittest_no_arena_import.pb.cc                  \\\n  google/protobuf/unittest_no_arena_import.pb.h                   \\\n  google/protobuf/unittest_no_arena.pb.cc                         \\\n  google/protobuf/unittest_no_arena.pb.h                          \\\n  google/protobuf/unittest_no_field_presence.pb.cc                \\\n  google/protobuf/unittest_no_field_presence.pb.h                 \\\n  google/protobuf/unittest_no_generic_services.pb.cc              \\\n  google/protobuf/unittest_no_generic_services.pb.h               \\\n  google/protobuf/unittest_optimize_for.pb.cc                     \\\n  google/protobuf/unittest_optimize_for.pb.h                      \\\n  google/protobuf/unittest.pb.cc                                  \\\n  google/protobuf/unittest.pb.h                                   \\\n  google/protobuf/unittest_preserve_unknown_enum2.pb.cc           \\\n  google/protobuf/unittest_preserve_unknown_enum2.pb.h            \\\n  google/protobuf/unittest_preserve_unknown_enum.pb.cc            \\\n  google/protobuf/unittest_preserve_unknown_enum.pb.h             \\\n  google/protobuf/unittest_proto3_arena.pb.cc                     \\\n  google/protobuf/unittest_proto3_arena.pb.h                      \\\n  google/protobuf/unittest_proto3_arena_lite.pb.cc                     \\\n  google/protobuf/unittest_proto3_arena_lite.pb.h                      \\\n  google/protobuf/unittest_proto3_lite.pb.cc                     \\\n  google/protobuf/unittest_proto3_lite.pb.h                      \\\n  google/protobuf/unittest_well_known_types.pb.cc                 \\\n  google/protobuf/unittest_well_known_types.pb.h                  \\\n  google/protobuf/util/internal/testdata/anys.pb.cc               \\\n  google/protobuf/util/internal/testdata/anys.pb.h                \\\n  google/protobuf/util/internal/testdata/books.pb.cc              \\\n  google/protobuf/util/internal/testdata/books.pb.h               \\\n  google/protobuf/util/internal/testdata/default_value.pb.cc      \\\n  google/protobuf/util/internal/testdata/default_value.pb.h       \\\n  google/protobuf/util/internal/testdata/default_value_test.pb.cc \\\n  google/protobuf/util/internal/testdata/default_value_test.pb.h  \\\n  google/protobuf/util/internal/testdata/field_mask.pb.cc         \\\n  google/protobuf/util/internal/testdata/field_mask.pb.h          \\\n  google/protobuf/util/internal/testdata/maps.pb.cc               \\\n  google/protobuf/util/internal/testdata/maps.pb.h                \\\n  google/protobuf/util/internal/testdata/oneofs.pb.cc             \\\n  google/protobuf/util/internal/testdata/oneofs.pb.h              \\\n  google/protobuf/util/internal/testdata/struct.pb.cc             \\\n  google/protobuf/util/internal/testdata/struct.pb.h              \\\n  google/protobuf/util/internal/testdata/timestamp_duration.pb.cc \\\n  google/protobuf/util/internal/testdata/timestamp_duration.pb.h  \\\n  google/protobuf/util/json_format_proto3.pb.cc                   \\\n  google/protobuf/util/json_format_proto3.pb.h                    \\\n  google/protobuf/util/message_differencer_unittest.pb.cc         \\\n  google/protobuf/util/message_differencer_unittest.pb.h\n\nBUILT_SOURCES = $(protoc_outputs)\nCOMMON_TEST_SOURCES = \\\n  google/protobuf/arena_test_util.cc                           \\\n  google/protobuf/arena_test_util.h                            \\\n  google/protobuf/map_test_util.cc                             \\\n  google/protobuf/map_test_util.h                              \\\n  google/protobuf/map_test_util_impl.h                         \\\n  google/protobuf/test_util.cc                                 \\\n  google/protobuf/test_util.h                                  \\\n  google/protobuf/testing/googletest.cc                        \\\n  google/protobuf/testing/googletest.h                         \\\n  google/protobuf/testing/file.cc                              \\\n  google/protobuf/testing/file.h\n\nprotobuf_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la \\\n                      ../gmock/gtest/lib/libgtest.la              \\\n                      ../gmock/lib/libgmock.la                    \\\n                      ../gmock/lib/libgmock_main.la\n\nprotobuf_test_CPPFLAGS = -I$(srcdir)/../gmock/gtest/include \\\n                         -I$(srcdir)/../gmock/include\n\n# Disable optimization for tests unless the user explicitly asked for it,\n# since test_util.cc takes forever to compile with optimization (with GCC).\n# See configure.ac for more info.\nprotobuf_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)\nprotobuf_test_SOURCES = \\\n  google/protobuf/stubs/bytestream_unittest.cc                 \\\n  google/protobuf/stubs/common_unittest.cc                     \\\n  google/protobuf/stubs/int128_unittest.cc                     \\\n  google/protobuf/stubs/once_unittest.cc                       \\\n  google/protobuf/stubs/statusor_test.cc                       \\\n  google/protobuf/stubs/status_test.cc                         \\\n  google/protobuf/stubs/stringpiece_unittest.cc                \\\n  google/protobuf/stubs/stringprintf_unittest.cc               \\\n  google/protobuf/stubs/structurally_valid_unittest.cc         \\\n  google/protobuf/stubs/strutil_unittest.cc                    \\\n  google/protobuf/stubs/template_util_unittest.cc              \\\n  google/protobuf/stubs/time_test.cc                           \\\n  google/protobuf/stubs/type_traits_unittest.cc                \\\n  google/protobuf/any_test.cc                                  \\\n  google/protobuf/arenastring_unittest.cc                      \\\n  google/protobuf/arena_unittest.cc                            \\\n  google/protobuf/descriptor_database_unittest.cc              \\\n  google/protobuf/descriptor_unittest.cc                       \\\n  google/protobuf/drop_unknown_fields_test.cc                  \\\n  google/protobuf/dynamic_message_unittest.cc                  \\\n  google/protobuf/extension_set_unittest.cc                    \\\n  google/protobuf/generated_message_reflection_unittest.cc     \\\n  google/protobuf/map_field_test.cc                            \\\n  google/protobuf/map_test.cc                                  \\\n  google/protobuf/message_unittest.cc                          \\\n  google/protobuf/no_field_presence_test.cc                    \\\n  google/protobuf/preserve_unknown_enum_test.cc                \\\n  google/protobuf/proto3_arena_unittest.cc                     \\\n  google/protobuf/proto3_arena_lite_unittest.cc                     \\\n  google/protobuf/proto3_lite_unittest.cc                     \\\n  google/protobuf/reflection_ops_unittest.cc                   \\\n  google/protobuf/repeated_field_reflection_unittest.cc        \\\n  google/protobuf/repeated_field_unittest.cc                   \\\n  google/protobuf/text_format_unittest.cc                      \\\n  google/protobuf/unknown_field_set_unittest.cc                \\\n  google/protobuf/well_known_types_unittest.cc                 \\\n  google/protobuf/wire_format_unittest.cc                      \\\n  google/protobuf/io/coded_stream_unittest.cc                  \\\n  google/protobuf/io/printer_unittest.cc                       \\\n  google/protobuf/io/tokenizer_unittest.cc                     \\\n  google/protobuf/io/zero_copy_stream_unittest.cc              \\\n  google/protobuf/compiler/command_line_interface_unittest.cc  \\\n  google/protobuf/compiler/importer_unittest.cc                \\\n  google/protobuf/compiler/mock_code_generator.cc              \\\n  google/protobuf/compiler/mock_code_generator.h               \\\n  google/protobuf/compiler/parser_unittest.cc                  \\\n  google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc       \\\n  google/protobuf/compiler/cpp/cpp_unittest.h                  \\\n  google/protobuf/compiler/cpp/cpp_unittest.cc                 \\\n  google/protobuf/compiler/cpp/cpp_plugin_unittest.cc          \\\n  google/protobuf/compiler/cpp/metadata_test.cc                \\\n  google/protobuf/compiler/java/java_plugin_unittest.cc        \\\n  google/protobuf/compiler/java/java_doc_comment_unittest.cc   \\\n  google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc \\\n  google/protobuf/compiler/python/python_plugin_unittest.cc    \\\n  google/protobuf/compiler/ruby/ruby_generator_unittest.cc     \\\n  google/protobuf/compiler/csharp/csharp_generator_unittest.cc \\\n  google/protobuf/util/field_comparator_test.cc                \\\n  google/protobuf/util/field_mask_util_test.cc                 \\\n  google/protobuf/util/internal/default_value_objectwriter_test.cc \\\n  google/protobuf/util/internal/json_objectwriter_test.cc      \\\n  google/protobuf/util/internal/json_stream_parser_test.cc     \\\n  google/protobuf/util/internal/protostream_objectsource_test.cc \\\n  google/protobuf/util/internal/protostream_objectwriter_test.cc \\\n  google/protobuf/util/internal/type_info_test_helper.cc       \\\n  google/protobuf/util/json_util_test.cc                       \\\n  google/protobuf/util/message_differencer_unittest.cc         \\\n  google/protobuf/util/time_util_test.cc                       \\\n  google/protobuf/util/type_resolver_util_test.cc              \\\n  $(COMMON_TEST_SOURCES)\n\nnodist_protobuf_test_SOURCES = $(protoc_outputs)\n\n# Run cpp_unittest again with PROTOBUF_TEST_NO_DESCRIPTORS defined.\nprotobuf_lazy_descriptor_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la \\\n                      libprotoc.la                                   \\\n                      ../gmock/gtest/lib/libgtest.la                 \\\n                      ../gmock/lib/libgmock.la                       \\\n                      ../gmock/lib/libgmock_main.la\n\nprotobuf_lazy_descriptor_test_CPPFLAGS = -I$(srcdir)/../gmock/include       \\\n                                         -I$(srcdir)/../gmock/gtest/include \\\n                                         -DPROTOBUF_TEST_NO_DESCRIPTORS\n\nprotobuf_lazy_descriptor_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)\nprotobuf_lazy_descriptor_test_SOURCES = \\\n  google/protobuf/compiler/cpp/cpp_unittest.cc                 \\\n  $(COMMON_TEST_SOURCES)\n\nnodist_protobuf_lazy_descriptor_test_SOURCES = $(protoc_outputs)\nCOMMON_LITE_TEST_SOURCES = \\\n  google/protobuf/arena_test_util.cc                                   \\\n  google/protobuf/arena_test_util.h                                    \\\n  google/protobuf/map_lite_test_util.cc                                \\\n  google/protobuf/map_lite_test_util.h                                 \\\n  google/protobuf/test_util_lite.cc                                    \\\n  google/protobuf/test_util_lite.h\n\n\n# Build lite_unittest separately, since it doesn't use gtest. It can't\n# depend on gtest because our internal version of gtest depend on proto\n# full runtime and we want to make sure this test builds without full\n# runtime.\nprotobuf_lite_test_LDADD = $(PTHREAD_LIBS) libprotobuf-lite.la\nprotobuf_lite_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)\nprotobuf_lite_test_SOURCES = \\\n  google/protobuf/lite_unittest.cc                                     \\\n  $(COMMON_LITE_TEST_SOURCES)\n\nnodist_protobuf_lite_test_SOURCES = $(protoc_lite_outputs)\n\n# lite_arena_unittest depends on gtest because teboring@ found that without\n# gtest when building the test internally our memory sanitizer doesn't detect\n# memory leaks (don't know why).\nprotobuf_lite_arena_test_LDADD = $(PTHREAD_LIBS) libprotobuf-lite.la \\\n                      ../gmock/gtest/lib/libgtest.la                 \\\n                      ../gmock/lib/libgmock.la                       \\\n                      ../gmock/lib/libgmock_main.la\n\nprotobuf_lite_arena_test_CPPFLAGS = -I$(srcdir)/../gmock/include       \\\n                                    -I$(srcdir)/../gmock/gtest/include\n\nprotobuf_lite_arena_test_CXXFLAGS = $(NO_OPT_CXXFLAGS)\nprotobuf_lite_arena_test_SOURCES = \\\n  google/protobuf/lite_arena_unittest.cc \\\n  $(COMMON_LITE_TEST_SOURCES)\n\nnodist_protobuf_lite_arena_test_SOURCES = $(protoc_lite_outputs)\n\n# Test plugin binary.\ntest_plugin_LDADD = $(PTHREAD_LIBS) libprotobuf.la libprotoc.la \\\n                    ../gmock/gtest/lib/libgtest.la\n\ntest_plugin_CPPFLAGS = -I$(srcdir)/../gmock/gtest/include\ntest_plugin_SOURCES = \\\n  google/protobuf/compiler/mock_code_generator.cc              \\\n  google/protobuf/testing/file.cc                              \\\n  google/protobuf/testing/file.h                               \\\n  google/protobuf/compiler/test_plugin.cc\n\n@HAVE_ZLIB_TRUE@zcgzip_LDADD = $(PTHREAD_LIBS) libprotobuf.la\n@HAVE_ZLIB_TRUE@zcgzip_SOURCES = google/protobuf/testing/zcgzip.cc\n@HAVE_ZLIB_TRUE@zcgunzip_LDADD = $(PTHREAD_LIBS) libprotobuf.la\n@HAVE_ZLIB_TRUE@zcgunzip_SOURCES = google/protobuf/testing/zcgunzip.cc\nno_warning_test_LDADD = $(PTHREAD_LIBS) libprotobuf.la      \\\n                        ../gmock/gtest/lib/libgtest.la      \\\n                        ../gmock/gtest/lib/libgtest_main.la\n\nno_warning_test_CPPFLAGS = -I$(srcdir)/../gmock/gtest/include\nno_warning_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_DEF) $(ZLIB_DEF) \\\n                           -Wall -Werror\n\nnodist_no_warning_test_SOURCES = no_warning_test.cc $(protoc_outputs)\nall: $(BUILT_SOURCES)\n\t$(MAKE) $(AM_MAKEFLAGS) all-am\n\n.SUFFIXES:\n.SUFFIXES: .cc .lo .log .o .obj .test .test$(EXEEXT) .trs\n$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)\n\t@for dep in $?; do \\\n\t  case '$(am__configure_deps)' in \\\n\t    *$$dep*) \\\n\t      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \\\n\t        && { if test -f $@; then exit 0; else break; fi; }; \\\n\t      exit 1;; \\\n\t  esac; \\\n\tdone; \\\n\techo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \\\n\t$(am__cd) $(top_srcdir) && \\\n\t  $(AUTOMAKE) --foreign src/Makefile\n.PRECIOUS: Makefile\nMakefile: $(srcdir)/Makefile.in $(top_builddir)/config.status\n\t@case '$?' in \\\n\t  *config.status*) \\\n\t    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \\\n\t  *) \\\n\t    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \\\n\t    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \\\n\tesac;\n\n$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)\n\tcd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh\n\n$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)\n\tcd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh\n$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)\n\tcd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh\n$(am__aclocal_m4_deps):\n\ninstall-libLTLIBRARIES: $(lib_LTLIBRARIES)\n\t@$(NORMAL_INSTALL)\n\t@list='$(lib_LTLIBRARIES)'; test -n \"$(libdir)\" || list=; \\\n\tlist2=; for p in $$list; do \\\n\t  if test -f $$p; then \\\n\t    list2=\"$$list2 $$p\"; \\\n\t  else :; fi; \\\n\tdone; \\\n\ttest -z \"$$list2\" || { \\\n\t  echo \" $(MKDIR_P) '$(DESTDIR)$(libdir)'\"; \\\n\t  $(MKDIR_P) \"$(DESTDIR)$(libdir)\" || exit 1; \\\n\t  echo \" $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'\"; \\\n\t  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 \"$(DESTDIR)$(libdir)\"; \\\n\t}\n\nuninstall-libLTLIBRARIES:\n\t@$(NORMAL_UNINSTALL)\n\t@list='$(lib_LTLIBRARIES)'; test -n \"$(libdir)\" || list=; \\\n\tfor p in $$list; do \\\n\t  $(am__strip_dir) \\\n\t  echo \" $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'\"; \\\n\t  $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f \"$(DESTDIR)$(libdir)/$$f\"; \\\n\tdone\n\nclean-libLTLIBRARIES:\n\t-test -z \"$(lib_LTLIBRARIES)\" || rm -f $(lib_LTLIBRARIES)\n\t@list='$(lib_LTLIBRARIES)'; \\\n\tlocs=`for p in $$list; do echo $$p; done | \\\n\t      sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \\\n\t      sort -u`; \\\n\ttest -z \"$$locs\" || { \\\n\t  echo rm -f $${locs}; \\\n\t  rm -f $${locs}; \\\n\t}\ngoogle/protobuf/stubs/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/stubs\n\t@: > google/protobuf/stubs/$(am__dirstamp)\ngoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/stubs/$(DEPDIR)\n\t@: > google/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/atomicops_internals_x86_gcc.lo:  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/atomicops_internals_x86_msvc.lo:  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/bytestream.lo:  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/common.lo:  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/int128.lo:  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/once.lo: google/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/status.lo:  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/statusor.lo:  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/stringpiece.lo:  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/stringprintf.lo:  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/structurally_valid.lo:  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/strutil.lo:  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/time.lo: google/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf\n\t@: > google/protobuf/$(am__dirstamp)\ngoogle/protobuf/$(DEPDIR)/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/$(DEPDIR)\n\t@: > google/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/arena.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/arenastring.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/extension_set.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/generated_message_util.lo:  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/message_lite.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/repeated_field.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/wire_format_lite.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/io/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/io\n\t@: > google/protobuf/io/$(am__dirstamp)\ngoogle/protobuf/io/$(DEPDIR)/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/io/$(DEPDIR)\n\t@: > google/protobuf/io/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/io/coded_stream.lo:  \\\n\tgoogle/protobuf/io/$(am__dirstamp) \\\n\tgoogle/protobuf/io/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/io/zero_copy_stream.lo:  \\\n\tgoogle/protobuf/io/$(am__dirstamp) \\\n\tgoogle/protobuf/io/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/io/zero_copy_stream_impl_lite.lo:  \\\n\tgoogle/protobuf/io/$(am__dirstamp) \\\n\tgoogle/protobuf/io/$(DEPDIR)/$(am__dirstamp)\n\nlibprotobuf-lite.la: $(libprotobuf_lite_la_OBJECTS) $(libprotobuf_lite_la_DEPENDENCIES) $(EXTRA_libprotobuf_lite_la_DEPENDENCIES) \n\t$(AM_V_CXXLD)$(libprotobuf_lite_la_LINK) -rpath $(libdir) $(libprotobuf_lite_la_OBJECTS) $(libprotobuf_lite_la_LIBADD) $(LIBS)\ngoogle/protobuf/any.pb.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/api.pb.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/mathlimits.lo:  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/any.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/descriptor.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/descriptor_database.lo:  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/descriptor.pb.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/duration.pb.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/dynamic_message.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/empty.pb.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/extension_set_heavy.lo:  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/field_mask.pb.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/generated_message_reflection.lo:  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/map_field.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/message.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/reflection_ops.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/service.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/source_context.pb.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/struct.pb.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/substitute.lo:  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/text_format.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/timestamp.pb.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/type.pb.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/unknown_field_set.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/wire_format.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/wrappers.pb.lo: google/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/io/gzip_stream.lo: google/protobuf/io/$(am__dirstamp) \\\n\tgoogle/protobuf/io/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/io/printer.lo: google/protobuf/io/$(am__dirstamp) \\\n\tgoogle/protobuf/io/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/io/strtod.lo: google/protobuf/io/$(am__dirstamp) \\\n\tgoogle/protobuf/io/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/io/tokenizer.lo: google/protobuf/io/$(am__dirstamp) \\\n\tgoogle/protobuf/io/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/io/zero_copy_stream_impl.lo:  \\\n\tgoogle/protobuf/io/$(am__dirstamp) \\\n\tgoogle/protobuf/io/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/compiler\n\t@: > google/protobuf/compiler/$(am__dirstamp)\ngoogle/protobuf/compiler/$(DEPDIR)/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/compiler/$(DEPDIR)\n\t@: > google/protobuf/compiler/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/importer.lo:  \\\n\tgoogle/protobuf/compiler/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/parser.lo:  \\\n\tgoogle/protobuf/compiler/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/util\n\t@: > google/protobuf/util/$(am__dirstamp)\ngoogle/protobuf/util/$(DEPDIR)/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/util/$(DEPDIR)\n\t@: > google/protobuf/util/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/field_comparator.lo:  \\\n\tgoogle/protobuf/util/$(am__dirstamp) \\\n\tgoogle/protobuf/util/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/field_mask_util.lo:  \\\n\tgoogle/protobuf/util/$(am__dirstamp) \\\n\tgoogle/protobuf/util/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/util/internal\n\t@: > google/protobuf/util/internal/$(am__dirstamp)\ngoogle/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/util/internal/$(DEPDIR)\n\t@: > google/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/datapiece.lo:  \\\n\tgoogle/protobuf/util/internal/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/default_value_objectwriter.lo:  \\\n\tgoogle/protobuf/util/internal/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/error_listener.lo:  \\\n\tgoogle/protobuf/util/internal/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/field_mask_utility.lo:  \\\n\tgoogle/protobuf/util/internal/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/json_escaping.lo:  \\\n\tgoogle/protobuf/util/internal/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/json_objectwriter.lo:  \\\n\tgoogle/protobuf/util/internal/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/json_stream_parser.lo:  \\\n\tgoogle/protobuf/util/internal/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/object_writer.lo:  \\\n\tgoogle/protobuf/util/internal/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/protostream_objectsource.lo:  \\\n\tgoogle/protobuf/util/internal/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/protostream_objectwriter.lo:  \\\n\tgoogle/protobuf/util/internal/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/proto_writer.lo:  \\\n\tgoogle/protobuf/util/internal/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/type_info.lo:  \\\n\tgoogle/protobuf/util/internal/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/type_info_test_helper.lo:  \\\n\tgoogle/protobuf/util/internal/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/utility.lo:  \\\n\tgoogle/protobuf/util/internal/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/json_util.lo:  \\\n\tgoogle/protobuf/util/$(am__dirstamp) \\\n\tgoogle/protobuf/util/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/message_differencer.lo:  \\\n\tgoogle/protobuf/util/$(am__dirstamp) \\\n\tgoogle/protobuf/util/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/time_util.lo:  \\\n\tgoogle/protobuf/util/$(am__dirstamp) \\\n\tgoogle/protobuf/util/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/type_resolver_util.lo:  \\\n\tgoogle/protobuf/util/$(am__dirstamp) \\\n\tgoogle/protobuf/util/$(DEPDIR)/$(am__dirstamp)\n\nlibprotobuf.la: $(libprotobuf_la_OBJECTS) $(libprotobuf_la_DEPENDENCIES) $(EXTRA_libprotobuf_la_DEPENDENCIES) \n\t$(AM_V_CXXLD)$(libprotobuf_la_LINK) -rpath $(libdir) $(libprotobuf_la_OBJECTS) $(libprotobuf_la_LIBADD) $(LIBS)\ngoogle/protobuf/compiler/code_generator.lo:  \\\n\tgoogle/protobuf/compiler/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/command_line_interface.lo:  \\\n\tgoogle/protobuf/compiler/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/plugin.lo:  \\\n\tgoogle/protobuf/compiler/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/plugin.pb.lo:  \\\n\tgoogle/protobuf/compiler/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/subprocess.lo:  \\\n\tgoogle/protobuf/compiler/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/zip_writer.lo:  \\\n\tgoogle/protobuf/compiler/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/compiler/cpp\n\t@: > google/protobuf/compiler/cpp/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/compiler/cpp/$(DEPDIR)\n\t@: > google/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/cpp_enum.lo:  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/cpp_enum_field.lo:  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/cpp_extension.lo:  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/cpp_field.lo:  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/cpp_file.lo:  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/cpp_generator.lo:  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/cpp_helpers.lo:  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/cpp_map_field.lo:  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/cpp_message.lo:  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/cpp_message_field.lo:  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/cpp_primitive_field.lo:  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/cpp_service.lo:  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/cpp_string_field.lo:  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/compiler/java\n\t@: > google/protobuf/compiler/java/$(am__dirstamp)\ngoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/compiler/java/$(DEPDIR)\n\t@: > google/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_context.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_enum.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_enum_lite.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_enum_field.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_enum_field_lite.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_extension.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_extension_lite.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_field.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_file.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_generator.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_generator_factory.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_helpers.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_lazy_message_field.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_lazy_message_field_lite.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_map_field.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_map_field_lite.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_message.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_message_lite.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_message_builder.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_message_builder_lite.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_message_field.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_message_field_lite.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_name_resolver.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_primitive_field.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_primitive_field_lite.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_shared_code_generator.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_service.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_string_field.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_string_field_lite.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/java_doc_comment.lo:  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/js/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/compiler/js\n\t@: > google/protobuf/compiler/js/$(am__dirstamp)\ngoogle/protobuf/compiler/js/$(DEPDIR)/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/compiler/js/$(DEPDIR)\n\t@: > google/protobuf/compiler/js/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/js/js_generator.lo:  \\\n\tgoogle/protobuf/compiler/js/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/js/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/javanano/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/compiler/javanano\n\t@: > google/protobuf/compiler/javanano/$(am__dirstamp)\ngoogle/protobuf/compiler/javanano/$(DEPDIR)/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/compiler/javanano/$(DEPDIR)\n\t@: > google/protobuf/compiler/javanano/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/javanano/javanano_enum.lo:  \\\n\tgoogle/protobuf/compiler/javanano/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/javanano/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/javanano/javanano_enum_field.lo:  \\\n\tgoogle/protobuf/compiler/javanano/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/javanano/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/javanano/javanano_extension.lo:  \\\n\tgoogle/protobuf/compiler/javanano/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/javanano/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/javanano/javanano_field.lo:  \\\n\tgoogle/protobuf/compiler/javanano/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/javanano/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/javanano/javanano_file.lo:  \\\n\tgoogle/protobuf/compiler/javanano/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/javanano/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/javanano/javanano_generator.lo:  \\\n\tgoogle/protobuf/compiler/javanano/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/javanano/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/javanano/javanano_helpers.lo:  \\\n\tgoogle/protobuf/compiler/javanano/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/javanano/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/javanano/javanano_map_field.lo:  \\\n\tgoogle/protobuf/compiler/javanano/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/javanano/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/javanano/javanano_message.lo:  \\\n\tgoogle/protobuf/compiler/javanano/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/javanano/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/javanano/javanano_message_field.lo:  \\\n\tgoogle/protobuf/compiler/javanano/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/javanano/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/javanano/javanano_primitive_field.lo:  \\\n\tgoogle/protobuf/compiler/javanano/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/javanano/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/objectivec/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/compiler/objectivec\n\t@: > google/protobuf/compiler/objectivec/$(am__dirstamp)\ngoogle/protobuf/compiler/objectivec/$(DEPDIR)/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/compiler/objectivec/$(DEPDIR)\n\t@: > google/protobuf/compiler/objectivec/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/objectivec/objectivec_enum.lo:  \\\n\tgoogle/protobuf/compiler/objectivec/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/objectivec/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/objectivec/objectivec_enum_field.lo:  \\\n\tgoogle/protobuf/compiler/objectivec/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/objectivec/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/objectivec/objectivec_extension.lo:  \\\n\tgoogle/protobuf/compiler/objectivec/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/objectivec/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/objectivec/objectivec_field.lo:  \\\n\tgoogle/protobuf/compiler/objectivec/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/objectivec/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/objectivec/objectivec_file.lo:  \\\n\tgoogle/protobuf/compiler/objectivec/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/objectivec/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/objectivec/objectivec_generator.lo:  \\\n\tgoogle/protobuf/compiler/objectivec/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/objectivec/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/objectivec/objectivec_helpers.lo:  \\\n\tgoogle/protobuf/compiler/objectivec/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/objectivec/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/objectivec/objectivec_map_field.lo:  \\\n\tgoogle/protobuf/compiler/objectivec/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/objectivec/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/objectivec/objectivec_message.lo:  \\\n\tgoogle/protobuf/compiler/objectivec/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/objectivec/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/objectivec/objectivec_message_field.lo:  \\\n\tgoogle/protobuf/compiler/objectivec/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/objectivec/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/objectivec/objectivec_oneof.lo:  \\\n\tgoogle/protobuf/compiler/objectivec/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/objectivec/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/objectivec/objectivec_primitive_field.lo:  \\\n\tgoogle/protobuf/compiler/objectivec/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/objectivec/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/python/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/compiler/python\n\t@: > google/protobuf/compiler/python/$(am__dirstamp)\ngoogle/protobuf/compiler/python/$(DEPDIR)/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/compiler/python/$(DEPDIR)\n\t@: > google/protobuf/compiler/python/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/python/python_generator.lo:  \\\n\tgoogle/protobuf/compiler/python/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/python/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/ruby/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/compiler/ruby\n\t@: > google/protobuf/compiler/ruby/$(am__dirstamp)\ngoogle/protobuf/compiler/ruby/$(DEPDIR)/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/compiler/ruby/$(DEPDIR)\n\t@: > google/protobuf/compiler/ruby/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/ruby/ruby_generator.lo:  \\\n\tgoogle/protobuf/compiler/ruby/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/ruby/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/csharp/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/compiler/csharp\n\t@: > google/protobuf/compiler/csharp/$(am__dirstamp)\ngoogle/protobuf/compiler/csharp/$(DEPDIR)/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/compiler/csharp/$(DEPDIR)\n\t@: > google/protobuf/compiler/csharp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/csharp/csharp_doc_comment.lo:  \\\n\tgoogle/protobuf/compiler/csharp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/csharp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/csharp/csharp_enum.lo:  \\\n\tgoogle/protobuf/compiler/csharp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/csharp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/csharp/csharp_enum_field.lo:  \\\n\tgoogle/protobuf/compiler/csharp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/csharp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/csharp/csharp_field_base.lo:  \\\n\tgoogle/protobuf/compiler/csharp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/csharp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/csharp/csharp_generator.lo:  \\\n\tgoogle/protobuf/compiler/csharp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/csharp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/csharp/csharp_helpers.lo:  \\\n\tgoogle/protobuf/compiler/csharp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/csharp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/csharp/csharp_map_field.lo:  \\\n\tgoogle/protobuf/compiler/csharp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/csharp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/csharp/csharp_message.lo:  \\\n\tgoogle/protobuf/compiler/csharp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/csharp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/csharp/csharp_message_field.lo:  \\\n\tgoogle/protobuf/compiler/csharp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/csharp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/csharp/csharp_primitive_field.lo:  \\\n\tgoogle/protobuf/compiler/csharp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/csharp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/csharp/csharp_reflection_class.lo:  \\\n\tgoogle/protobuf/compiler/csharp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/csharp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/csharp/csharp_repeated_enum_field.lo:  \\\n\tgoogle/protobuf/compiler/csharp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/csharp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/csharp/csharp_repeated_message_field.lo:  \\\n\tgoogle/protobuf/compiler/csharp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/csharp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/csharp/csharp_repeated_primitive_field.lo:  \\\n\tgoogle/protobuf/compiler/csharp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/csharp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/csharp/csharp_source_generator_base.lo:  \\\n\tgoogle/protobuf/compiler/csharp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/csharp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/csharp/csharp_wrapper_field.lo:  \\\n\tgoogle/protobuf/compiler/csharp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/csharp/$(DEPDIR)/$(am__dirstamp)\n\nlibprotoc.la: $(libprotoc_la_OBJECTS) $(libprotoc_la_DEPENDENCIES) $(EXTRA_libprotoc_la_DEPENDENCIES) \n\t$(AM_V_CXXLD)$(libprotoc_la_LINK) -rpath $(libdir) $(libprotoc_la_OBJECTS) $(libprotoc_la_LIBADD) $(LIBS)\ninstall-binPROGRAMS: $(bin_PROGRAMS)\n\t@$(NORMAL_INSTALL)\n\t@list='$(bin_PROGRAMS)'; test -n \"$(bindir)\" || list=; \\\n\tif test -n \"$$list\"; then \\\n\t  echo \" $(MKDIR_P) '$(DESTDIR)$(bindir)'\"; \\\n\t  $(MKDIR_P) \"$(DESTDIR)$(bindir)\" || exit 1; \\\n\tfi; \\\n\tfor p in $$list; do echo \"$$p $$p\"; done | \\\n\tsed 's/$(EXEEXT)$$//' | \\\n\twhile read p p1; do if test -f $$p \\\n\t || test -f $$p1 \\\n\t  ; then echo \"$$p\"; echo \"$$p\"; else :; fi; \\\n\tdone | \\\n\tsed -e 'p;s,.*/,,;n;h' \\\n\t    -e 's|.*|.|' \\\n\t    -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \\\n\tsed 'N;N;N;s,\\n, ,g' | \\\n\t$(AWK) 'BEGIN { files[\".\"] = \"\"; dirs[\".\"] = 1 } \\\n\t  { d=$$3; if (dirs[d] != 1) { print \"d\", d; dirs[d] = 1 } \\\n\t    if ($$2 == $$4) files[d] = files[d] \" \" $$1; \\\n\t    else { print \"f\", $$3 \"/\" $$4, $$1; } } \\\n\t  END { for (d in files) print \"f\", d, files[d] }' | \\\n\twhile read type dir files; do \\\n\t    if test \"$$dir\" = .; then dir=; else dir=/$$dir; fi; \\\n\t    test -z \"$$files\" || { \\\n\t    echo \" $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'\"; \\\n\t    $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files \"$(DESTDIR)$(bindir)$$dir\" || exit $$?; \\\n\t    } \\\n\t; done\n\nuninstall-binPROGRAMS:\n\t@$(NORMAL_UNINSTALL)\n\t@list='$(bin_PROGRAMS)'; test -n \"$(bindir)\" || list=; \\\n\tfiles=`for p in $$list; do echo \"$$p\"; done | \\\n\t  sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \\\n\t      -e 's/$$/$(EXEEXT)/' \\\n\t`; \\\n\ttest -n \"$$list\" || exit 0; \\\n\techo \" ( cd '$(DESTDIR)$(bindir)' && rm -f\" $$files \")\"; \\\n\tcd \"$(DESTDIR)$(bindir)\" && rm -f $$files\n\nclean-binPROGRAMS:\n\t@list='$(bin_PROGRAMS)'; test -n \"$$list\" || exit 0; \\\n\techo \" rm -f\" $$list; \\\n\trm -f $$list || exit $$?; \\\n\ttest -n \"$(EXEEXT)\" || exit 0; \\\n\tlist=`for p in $$list; do echo \"$$p\"; done | sed 's/$(EXEEXT)$$//'`; \\\n\techo \" rm -f\" $$list; \\\n\trm -f $$list\n\nclean-checkPROGRAMS:\n\t@list='$(check_PROGRAMS)'; test -n \"$$list\" || exit 0; \\\n\techo \" rm -f\" $$list; \\\n\trm -f $$list || exit $$?; \\\n\ttest -n \"$(EXEEXT)\" || exit 0; \\\n\tlist=`for p in $$list; do echo \"$$p\"; done | sed 's/$(EXEEXT)$$//'`; \\\n\techo \" rm -f\" $$list; \\\n\trm -f $$list\ngoogle/protobuf/no_warning_test-map_lite_unittest.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_no_arena_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_import_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_import_public_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-any_test.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/no_warning_test-cpp_test_bad_identifiers.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/no_warning_test-cpp_test_large_enum_value.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-map_proto2_unittest.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-map_unittest.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_arena.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_custom_options.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_drop_unknown_fields.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_embed_optimize_for.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_empty.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_enormous_descriptor.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_import.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_import_public.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_lite_imports_nonlite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_mset.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_mset_wire_format.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_no_arena_import.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_no_arena.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_no_field_presence.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_no_generic_services.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_optimize_for.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_preserve_unknown_enum2.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_preserve_unknown_enum.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_proto3_arena.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_proto3_arena_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_proto3_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/no_warning_test-unittest_well_known_types.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/util/internal/testdata\n\t@: > google/protobuf/util/internal/testdata/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/util/internal/testdata/$(DEPDIR)\n\t@: > google/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/no_warning_test-anys.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/no_warning_test-books.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/no_warning_test-default_value.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/no_warning_test-default_value_test.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/no_warning_test-field_mask.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/no_warning_test-maps.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/no_warning_test-oneofs.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/no_warning_test-struct.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/no_warning_test-timestamp_duration.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/no_warning_test-json_format_proto3.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/$(am__dirstamp) \\\n\tgoogle/protobuf/util/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/no_warning_test-message_differencer_unittest.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/$(am__dirstamp) \\\n\tgoogle/protobuf/util/$(DEPDIR)/$(am__dirstamp)\n\nno-warning-test$(EXEEXT): $(no_warning_test_OBJECTS) $(no_warning_test_DEPENDENCIES) $(EXTRA_no_warning_test_DEPENDENCIES) \n\t@rm -f no-warning-test$(EXEEXT)\n\t$(AM_V_CXXLD)$(no_warning_test_LINK) $(no_warning_test_OBJECTS) $(no_warning_test_LDADD) $(LIBS)\ngoogle/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-arena_test_util.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-map_test_util.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-test_util.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/testing/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/testing\n\t@: > google/protobuf/testing/$(am__dirstamp)\ngoogle/protobuf/testing/$(DEPDIR)/$(am__dirstamp):\n\t@$(MKDIR_P) google/protobuf/testing/$(DEPDIR)\n\t@: > google/protobuf/testing/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/testing/protobuf_lazy_descriptor_test-googletest.$(OBJEXT):  \\\n\tgoogle/protobuf/testing/$(am__dirstamp) \\\n\tgoogle/protobuf/testing/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/testing/protobuf_lazy_descriptor_test-file.$(OBJEXT):  \\\n\tgoogle/protobuf/testing/$(am__dirstamp) \\\n\tgoogle/protobuf/testing/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-map_lite_unittest.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_import_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_import_public_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-any_test.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_bad_identifiers.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_large_enum_value.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-map_proto2_unittest.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-map_unittest.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_arena.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_custom_options.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_drop_unknown_fields.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_embed_optimize_for.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_empty.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_enormous_descriptor.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_import.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_import_public.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_lite_imports_nonlite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_mset.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_mset_wire_format.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_import.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_no_field_presence.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_no_generic_services.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_optimize_for.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum2.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_well_known_types.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-anys.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-books.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value_test.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-field_mask.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-maps.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-oneofs.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-struct.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-timestamp_duration.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/protobuf_lazy_descriptor_test-json_format_proto3.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/$(am__dirstamp) \\\n\tgoogle/protobuf/util/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/protobuf_lazy_descriptor_test-message_differencer_unittest.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/$(am__dirstamp) \\\n\tgoogle/protobuf/util/$(DEPDIR)/$(am__dirstamp)\n\nprotobuf-lazy-descriptor-test$(EXEEXT): $(protobuf_lazy_descriptor_test_OBJECTS) $(protobuf_lazy_descriptor_test_DEPENDENCIES) $(EXTRA_protobuf_lazy_descriptor_test_DEPENDENCIES) \n\t@rm -f protobuf-lazy-descriptor-test$(EXEEXT)\n\t$(AM_V_CXXLD)$(protobuf_lazy_descriptor_test_LINK) $(protobuf_lazy_descriptor_test_OBJECTS) $(protobuf_lazy_descriptor_test_LDADD) $(LIBS)\ngoogle/protobuf/protobuf_lite_arena_test-lite_arena_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lite_arena_test-arena_test_util.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lite_arena_test-map_lite_test_util.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lite_arena_test-test_util_lite.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lite_arena_test-map_lite_unittest.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lite_arena_test-unittest_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lite_arena_test-unittest_no_arena_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lite_arena_test-unittest_import_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lite_arena_test-unittest_import_public_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\n\nprotobuf-lite-arena-test$(EXEEXT): $(protobuf_lite_arena_test_OBJECTS) $(protobuf_lite_arena_test_DEPENDENCIES) $(EXTRA_protobuf_lite_arena_test_DEPENDENCIES) \n\t@rm -f protobuf-lite-arena-test$(EXEEXT)\n\t$(AM_V_CXXLD)$(protobuf_lite_arena_test_LINK) $(protobuf_lite_arena_test_OBJECTS) $(protobuf_lite_arena_test_LDADD) $(LIBS)\ngoogle/protobuf/protobuf_lite_test-lite_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lite_test-arena_test_util.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lite_test-map_lite_test_util.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lite_test-test_util_lite.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lite_test-map_lite_unittest.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lite_test-unittest_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lite_test-unittest_no_arena_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lite_test-unittest_import_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_lite_test-unittest_import_public_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\n\nprotobuf-lite-test$(EXEEXT): $(protobuf_lite_test_OBJECTS) $(protobuf_lite_test_DEPENDENCIES) $(EXTRA_protobuf_lite_test_DEPENDENCIES) \n\t@rm -f protobuf-lite-test$(EXEEXT)\n\t$(AM_V_CXXLD)$(protobuf_lite_test_LINK) $(protobuf_lite_test_OBJECTS) $(protobuf_lite_test_LDADD) $(LIBS)\ngoogle/protobuf/stubs/protobuf_test-bytestream_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/protobuf_test-common_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/protobuf_test-int128_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/protobuf_test-once_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/protobuf_test-statusor_test.$(OBJEXT):  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/protobuf_test-status_test.$(OBJEXT):  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/protobuf_test-stringpiece_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/protobuf_test-stringprintf_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/protobuf_test-structurally_valid_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/protobuf_test-strutil_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/protobuf_test-template_util_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/protobuf_test-time_test.$(OBJEXT):  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/stubs/protobuf_test-type_traits_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/stubs/$(am__dirstamp) \\\n\tgoogle/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-any_test.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-arenastring_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-arena_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-descriptor_database_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-descriptor_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-drop_unknown_fields_test.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-dynamic_message_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-extension_set_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-generated_message_reflection_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-map_field_test.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-map_test.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-message_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-no_field_presence_test.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-preserve_unknown_enum_test.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-proto3_arena_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-proto3_arena_lite_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-proto3_lite_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-reflection_ops_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-repeated_field_reflection_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-repeated_field_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-text_format_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unknown_field_set_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-well_known_types_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-wire_format_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/io/protobuf_test-coded_stream_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/io/$(am__dirstamp) \\\n\tgoogle/protobuf/io/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/io/protobuf_test-printer_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/io/$(am__dirstamp) \\\n\tgoogle/protobuf/io/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/io/protobuf_test-tokenizer_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/io/$(am__dirstamp) \\\n\tgoogle/protobuf/io/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/io/protobuf_test-zero_copy_stream_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/io/$(am__dirstamp) \\\n\tgoogle/protobuf/io/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/protobuf_test-command_line_interface_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/protobuf_test-importer_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/protobuf_test-mock_code_generator.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/protobuf_test-parser_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/protobuf_test-cpp_bootstrap_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/protobuf_test-cpp_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/protobuf_test-cpp_plugin_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/protobuf_test-metadata_test.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/protobuf_test-java_plugin_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/java/protobuf_test-java_doc_comment_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/java/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/objectivec/protobuf_test-objectivec_helpers_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/objectivec/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/objectivec/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/python/protobuf_test-python_plugin_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/python/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/python/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/ruby/protobuf_test-ruby_generator_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/ruby/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/ruby/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/csharp/protobuf_test-csharp_generator_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/csharp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/csharp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/protobuf_test-field_comparator_test.$(OBJEXT):  \\\n\tgoogle/protobuf/util/$(am__dirstamp) \\\n\tgoogle/protobuf/util/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/protobuf_test-field_mask_util_test.$(OBJEXT):  \\\n\tgoogle/protobuf/util/$(am__dirstamp) \\\n\tgoogle/protobuf/util/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/protobuf_test-default_value_objectwriter_test.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/protobuf_test-json_objectwriter_test.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/protobuf_test-json_stream_parser_test.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/protobuf_test-protostream_objectsource_test.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/protobuf_test-protostream_objectwriter_test.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/protobuf_test-type_info_test_helper.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/protobuf_test-json_util_test.$(OBJEXT):  \\\n\tgoogle/protobuf/util/$(am__dirstamp) \\\n\tgoogle/protobuf/util/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/protobuf_test-message_differencer_unittest.$(OBJEXT):  \\\n\tgoogle/protobuf/util/$(am__dirstamp) \\\n\tgoogle/protobuf/util/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/protobuf_test-time_util_test.$(OBJEXT):  \\\n\tgoogle/protobuf/util/$(am__dirstamp) \\\n\tgoogle/protobuf/util/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/protobuf_test-type_resolver_util_test.$(OBJEXT):  \\\n\tgoogle/protobuf/util/$(am__dirstamp) \\\n\tgoogle/protobuf/util/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-arena_test_util.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-map_test_util.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-test_util.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/testing/protobuf_test-googletest.$(OBJEXT):  \\\n\tgoogle/protobuf/testing/$(am__dirstamp) \\\n\tgoogle/protobuf/testing/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/testing/protobuf_test-file.$(OBJEXT):  \\\n\tgoogle/protobuf/testing/$(am__dirstamp) \\\n\tgoogle/protobuf/testing/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-map_lite_unittest.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_no_arena_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_import_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_import_public_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-any_test.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/protobuf_test-cpp_test_bad_identifiers.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/cpp/protobuf_test-cpp_test_large_enum_value.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/cpp/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-map_proto2_unittest.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-map_unittest.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_arena.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_custom_options.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_drop_unknown_fields.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_embed_optimize_for.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_empty.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_enormous_descriptor.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_import.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_import_public.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_lite_imports_nonlite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_mset.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_mset_wire_format.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_no_arena_import.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_no_arena.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_no_field_presence.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_no_generic_services.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_optimize_for.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_preserve_unknown_enum2.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_preserve_unknown_enum.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_proto3_arena.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_proto3_arena_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_proto3_lite.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/protobuf_test-unittest_well_known_types.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/$(am__dirstamp) \\\n\tgoogle/protobuf/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/protobuf_test-anys.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/protobuf_test-books.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/protobuf_test-default_value.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/protobuf_test-default_value_test.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/protobuf_test-field_mask.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/protobuf_test-maps.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/protobuf_test-oneofs.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/protobuf_test-struct.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/internal/testdata/protobuf_test-timestamp_duration.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/internal/testdata/$(am__dirstamp) \\\n\tgoogle/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/protobuf_test-json_format_proto3.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/$(am__dirstamp) \\\n\tgoogle/protobuf/util/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/util/protobuf_test-message_differencer_unittest.pb.$(OBJEXT):  \\\n\tgoogle/protobuf/util/$(am__dirstamp) \\\n\tgoogle/protobuf/util/$(DEPDIR)/$(am__dirstamp)\n\nprotobuf-test$(EXEEXT): $(protobuf_test_OBJECTS) $(protobuf_test_DEPENDENCIES) $(EXTRA_protobuf_test_DEPENDENCIES) \n\t@rm -f protobuf-test$(EXEEXT)\n\t$(AM_V_CXXLD)$(protobuf_test_LINK) $(protobuf_test_OBJECTS) $(protobuf_test_LDADD) $(LIBS)\ngoogle/protobuf/compiler/main.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/$(DEPDIR)/$(am__dirstamp)\n\nprotoc$(EXEEXT): $(protoc_OBJECTS) $(protoc_DEPENDENCIES) $(EXTRA_protoc_DEPENDENCIES) \n\t@rm -f protoc$(EXEEXT)\n\t$(AM_V_CXXLD)$(CXXLINK) $(protoc_OBJECTS) $(protoc_LDADD) $(LIBS)\ngoogle/protobuf/compiler/test_plugin-mock_code_generator.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/testing/test_plugin-file.$(OBJEXT):  \\\n\tgoogle/protobuf/testing/$(am__dirstamp) \\\n\tgoogle/protobuf/testing/$(DEPDIR)/$(am__dirstamp)\ngoogle/protobuf/compiler/test_plugin-test_plugin.$(OBJEXT):  \\\n\tgoogle/protobuf/compiler/$(am__dirstamp) \\\n\tgoogle/protobuf/compiler/$(DEPDIR)/$(am__dirstamp)\n\ntest_plugin$(EXEEXT): $(test_plugin_OBJECTS) $(test_plugin_DEPENDENCIES) $(EXTRA_test_plugin_DEPENDENCIES) \n\t@rm -f test_plugin$(EXEEXT)\n\t$(AM_V_CXXLD)$(CXXLINK) $(test_plugin_OBJECTS) $(test_plugin_LDADD) $(LIBS)\ngoogle/protobuf/testing/zcgunzip.$(OBJEXT):  \\\n\tgoogle/protobuf/testing/$(am__dirstamp) \\\n\tgoogle/protobuf/testing/$(DEPDIR)/$(am__dirstamp)\n\nzcgunzip$(EXEEXT): $(zcgunzip_OBJECTS) $(zcgunzip_DEPENDENCIES) $(EXTRA_zcgunzip_DEPENDENCIES) \n\t@rm -f zcgunzip$(EXEEXT)\n\t$(AM_V_CXXLD)$(CXXLINK) $(zcgunzip_OBJECTS) $(zcgunzip_LDADD) $(LIBS)\ngoogle/protobuf/testing/zcgzip.$(OBJEXT):  \\\n\tgoogle/protobuf/testing/$(am__dirstamp) \\\n\tgoogle/protobuf/testing/$(DEPDIR)/$(am__dirstamp)\n\nzcgzip$(EXEEXT): $(zcgzip_OBJECTS) $(zcgzip_DEPENDENCIES) $(EXTRA_zcgzip_DEPENDENCIES) \n\t@rm -f zcgzip$(EXEEXT)\n\t$(AM_V_CXXLD)$(CXXLINK) $(zcgzip_OBJECTS) $(zcgzip_LDADD) $(LIBS)\n\nmostlyclean-compile:\n\t-rm -f *.$(OBJEXT)\n\t-rm -f google/protobuf/*.$(OBJEXT)\n\t-rm -f google/protobuf/*.lo\n\t-rm -f google/protobuf/compiler/*.$(OBJEXT)\n\t-rm -f google/protobuf/compiler/*.lo\n\t-rm -f google/protobuf/compiler/cpp/*.$(OBJEXT)\n\t-rm -f google/protobuf/compiler/cpp/*.lo\n\t-rm -f google/protobuf/compiler/csharp/*.$(OBJEXT)\n\t-rm -f google/protobuf/compiler/csharp/*.lo\n\t-rm -f google/protobuf/compiler/java/*.$(OBJEXT)\n\t-rm -f google/protobuf/compiler/java/*.lo\n\t-rm -f google/protobuf/compiler/javanano/*.$(OBJEXT)\n\t-rm -f google/protobuf/compiler/javanano/*.lo\n\t-rm -f google/protobuf/compiler/js/*.$(OBJEXT)\n\t-rm -f google/protobuf/compiler/js/*.lo\n\t-rm -f google/protobuf/compiler/objectivec/*.$(OBJEXT)\n\t-rm -f google/protobuf/compiler/objectivec/*.lo\n\t-rm -f google/protobuf/compiler/python/*.$(OBJEXT)\n\t-rm -f google/protobuf/compiler/python/*.lo\n\t-rm -f google/protobuf/compiler/ruby/*.$(OBJEXT)\n\t-rm -f google/protobuf/compiler/ruby/*.lo\n\t-rm -f google/protobuf/io/*.$(OBJEXT)\n\t-rm -f google/protobuf/io/*.lo\n\t-rm -f google/protobuf/stubs/*.$(OBJEXT)\n\t-rm -f google/protobuf/stubs/*.lo\n\t-rm -f google/protobuf/testing/*.$(OBJEXT)\n\t-rm -f google/protobuf/util/*.$(OBJEXT)\n\t-rm -f google/protobuf/util/*.lo\n\t-rm -f google/protobuf/util/internal/*.$(OBJEXT)\n\t-rm -f google/protobuf/util/internal/*.lo\n\t-rm -f google/protobuf/util/internal/testdata/*.$(OBJEXT)\n\ndistclean-compile:\n\t-rm -f *.tab.c\n\n@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/no_warning_test-no_warning_test.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/any.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/any.pb.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/api.pb.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/arena.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/arenastring.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/descriptor.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/descriptor.pb.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/descriptor_database.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/duration.pb.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/dynamic_message.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/empty.pb.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/extension_set.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/extension_set_heavy.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/field_mask.pb.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/generated_message_reflection.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/generated_message_util.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/map_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/message.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/message_lite.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-any_test.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-map_lite_unittest.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-map_proto2_unittest.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-map_unittest.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_arena.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_custom_options.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_drop_unknown_fields.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_embed_optimize_for.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_empty.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_enormous_descriptor.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_import.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_import_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_import_public.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_import_public_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_lite_imports_nonlite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_mset.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_mset_wire_format.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_arena.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_arena_import.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_arena_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_field_presence.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_generic_services.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_optimize_for.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_preserve_unknown_enum.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_preserve_unknown_enum2.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_proto3_arena.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_proto3_arena_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_proto3_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/no_warning_test-unittest_well_known_types.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-any_test.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-arena_test_util.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_lite_unittest.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_proto2_unittest.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_test_util.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_unittest.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-test_util.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_arena.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_custom_options.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_drop_unknown_fields.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_embed_optimize_for.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_empty.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_enormous_descriptor.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import_public.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import_public_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_lite_imports_nonlite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_mset.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_mset_wire_format.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_arena.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_arena_import.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_arena_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_field_presence.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_generic_services.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_optimize_for.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum2.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_proto3_arena.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_proto3_arena_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_proto3_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_well_known_types.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-arena_test_util.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-lite_arena_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-map_lite_test_util.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-map_lite_unittest.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-test_util_lite.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_import_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_import_public_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_no_arena_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lite_test-arena_test_util.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lite_test-lite_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lite_test-map_lite_test_util.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lite_test-map_lite_unittest.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lite_test-test_util_lite.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_import_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_import_public_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_no_arena_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-any_test.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-any_test.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-arena_test_util.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-arena_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-arenastring_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-descriptor_database_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-descriptor_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-drop_unknown_fields_test.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-dynamic_message_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-extension_set_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-generated_message_reflection_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-map_field_test.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-map_lite_unittest.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-map_proto2_unittest.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-map_test.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-map_test_util.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-map_unittest.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-message_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-no_field_presence_test.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-preserve_unknown_enum_test.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-proto3_arena_lite_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-proto3_arena_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-proto3_lite_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-reflection_ops_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-repeated_field_reflection_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-repeated_field_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-test_util.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-text_format_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_arena.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_custom_options.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_drop_unknown_fields.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_embed_optimize_for.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_empty.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_enormous_descriptor.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_import.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_import_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_import_public.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_import_public_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_lite_imports_nonlite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_mset.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_mset_wire_format.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_arena.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_arena_import.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_arena_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_field_presence.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_generic_services.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_optimize_for.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_preserve_unknown_enum.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_preserve_unknown_enum2.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_proto3_arena.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_proto3_arena_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_proto3_lite.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unittest_well_known_types.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-unknown_field_set_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-well_known_types_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/protobuf_test-wire_format_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/reflection_ops.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/repeated_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/service.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/source_context.pb.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/struct.pb.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/text_format.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/timestamp.pb.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/type.pb.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/unknown_field_set.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/wire_format.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/wire_format_lite.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/$(DEPDIR)/wrappers.pb.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/$(DEPDIR)/code_generator.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/$(DEPDIR)/command_line_interface.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/$(DEPDIR)/importer.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/$(DEPDIR)/main.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/$(DEPDIR)/parser.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/$(DEPDIR)/plugin.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/$(DEPDIR)/plugin.pb.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/$(DEPDIR)/protobuf_test-command_line_interface_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/$(DEPDIR)/protobuf_test-importer_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/$(DEPDIR)/protobuf_test-mock_code_generator.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/$(DEPDIR)/protobuf_test-parser_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/$(DEPDIR)/subprocess.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/$(DEPDIR)/test_plugin-mock_code_generator.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/$(DEPDIR)/test_plugin-test_plugin.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/$(DEPDIR)/zip_writer.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/cpp_enum.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/cpp_enum_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/cpp_extension.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/cpp_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/cpp_file.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/cpp_generator.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/cpp_helpers.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/cpp_map_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/cpp_message.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/cpp_message_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/cpp_primitive_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/cpp_service.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/cpp_string_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/no_warning_test-cpp_test_bad_identifiers.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/no_warning_test-cpp_test_large_enum_value.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_lazy_descriptor_test-cpp_test_bad_identifiers.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_lazy_descriptor_test-cpp_test_large_enum_value.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_lazy_descriptor_test-cpp_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_bootstrap_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_plugin_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_test_bad_identifiers.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_test_large_enum_value.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-metadata_test.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/csharp/$(DEPDIR)/csharp_doc_comment.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/csharp/$(DEPDIR)/csharp_enum.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/csharp/$(DEPDIR)/csharp_enum_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/csharp/$(DEPDIR)/csharp_field_base.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/csharp/$(DEPDIR)/csharp_generator.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/csharp/$(DEPDIR)/csharp_helpers.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/csharp/$(DEPDIR)/csharp_map_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/csharp/$(DEPDIR)/csharp_message.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/csharp/$(DEPDIR)/csharp_message_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/csharp/$(DEPDIR)/csharp_primitive_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/csharp/$(DEPDIR)/csharp_reflection_class.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/csharp/$(DEPDIR)/csharp_repeated_enum_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/csharp/$(DEPDIR)/csharp_repeated_message_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/csharp/$(DEPDIR)/csharp_repeated_primitive_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/csharp/$(DEPDIR)/csharp_source_generator_base.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/csharp/$(DEPDIR)/csharp_wrapper_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/csharp/$(DEPDIR)/protobuf_test-csharp_generator_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_context.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_doc_comment.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_enum.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_enum_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_enum_field_lite.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_enum_lite.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_extension.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_extension_lite.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_file.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_generator.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_generator_factory.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_helpers.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_lazy_message_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_lazy_message_field_lite.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_map_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_map_field_lite.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_message.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_message_builder.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_message_builder_lite.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_message_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_message_field_lite.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_message_lite.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_name_resolver.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_primitive_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_primitive_field_lite.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_service.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_shared_code_generator.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_string_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/java_string_field_lite.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/protobuf_test-java_doc_comment_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/java/$(DEPDIR)/protobuf_test-java_plugin_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/javanano/$(DEPDIR)/javanano_enum.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/javanano/$(DEPDIR)/javanano_enum_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/javanano/$(DEPDIR)/javanano_extension.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/javanano/$(DEPDIR)/javanano_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/javanano/$(DEPDIR)/javanano_file.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/javanano/$(DEPDIR)/javanano_generator.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/javanano/$(DEPDIR)/javanano_helpers.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/javanano/$(DEPDIR)/javanano_map_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/javanano/$(DEPDIR)/javanano_message.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/javanano/$(DEPDIR)/javanano_message_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/javanano/$(DEPDIR)/javanano_primitive_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/js/$(DEPDIR)/js_generator.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/objectivec/$(DEPDIR)/objectivec_enum.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/objectivec/$(DEPDIR)/objectivec_enum_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/objectivec/$(DEPDIR)/objectivec_extension.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/objectivec/$(DEPDIR)/objectivec_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/objectivec/$(DEPDIR)/objectivec_file.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/objectivec/$(DEPDIR)/objectivec_generator.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/objectivec/$(DEPDIR)/objectivec_helpers.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/objectivec/$(DEPDIR)/objectivec_map_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/objectivec/$(DEPDIR)/objectivec_message.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/objectivec/$(DEPDIR)/objectivec_message_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/objectivec/$(DEPDIR)/objectivec_oneof.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/objectivec/$(DEPDIR)/objectivec_primitive_field.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/objectivec/$(DEPDIR)/protobuf_test-objectivec_helpers_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/python/$(DEPDIR)/protobuf_test-python_plugin_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/python/$(DEPDIR)/python_generator.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/ruby/$(DEPDIR)/protobuf_test-ruby_generator_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/compiler/ruby/$(DEPDIR)/ruby_generator.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/io/$(DEPDIR)/coded_stream.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/io/$(DEPDIR)/gzip_stream.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/io/$(DEPDIR)/printer.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/io/$(DEPDIR)/protobuf_test-coded_stream_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/io/$(DEPDIR)/protobuf_test-printer_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/io/$(DEPDIR)/protobuf_test-tokenizer_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/io/$(DEPDIR)/protobuf_test-zero_copy_stream_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/io/$(DEPDIR)/strtod.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/io/$(DEPDIR)/tokenizer.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/io/$(DEPDIR)/zero_copy_stream.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/io/$(DEPDIR)/zero_copy_stream_impl.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/io/$(DEPDIR)/zero_copy_stream_impl_lite.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/atomicops_internals_x86_gcc.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/atomicops_internals_x86_msvc.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/bytestream.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/common.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/int128.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/mathlimits.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/once.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/protobuf_test-bytestream_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/protobuf_test-common_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/protobuf_test-int128_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/protobuf_test-once_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/protobuf_test-status_test.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/protobuf_test-statusor_test.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/protobuf_test-stringpiece_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/protobuf_test-stringprintf_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/protobuf_test-structurally_valid_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/protobuf_test-strutil_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/protobuf_test-template_util_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/protobuf_test-time_test.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/protobuf_test-type_traits_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/status.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/statusor.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/stringpiece.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/stringprintf.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/structurally_valid.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/strutil.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/substitute.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/stubs/$(DEPDIR)/time.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/testing/$(DEPDIR)/protobuf_lazy_descriptor_test-file.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/testing/$(DEPDIR)/protobuf_lazy_descriptor_test-googletest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/testing/$(DEPDIR)/protobuf_test-file.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/testing/$(DEPDIR)/protobuf_test-googletest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/testing/$(DEPDIR)/test_plugin-file.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/testing/$(DEPDIR)/zcgunzip.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/testing/$(DEPDIR)/zcgzip.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/$(DEPDIR)/field_comparator.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/$(DEPDIR)/field_mask_util.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/$(DEPDIR)/json_util.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/$(DEPDIR)/message_differencer.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/$(DEPDIR)/no_warning_test-json_format_proto3.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/$(DEPDIR)/no_warning_test-message_differencer_unittest.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/$(DEPDIR)/protobuf_lazy_descriptor_test-json_format_proto3.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/$(DEPDIR)/protobuf_lazy_descriptor_test-message_differencer_unittest.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/$(DEPDIR)/protobuf_test-field_comparator_test.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/$(DEPDIR)/protobuf_test-field_mask_util_test.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/$(DEPDIR)/protobuf_test-json_format_proto3.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/$(DEPDIR)/protobuf_test-json_util_test.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/$(DEPDIR)/protobuf_test-message_differencer_unittest.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/$(DEPDIR)/protobuf_test-message_differencer_unittest.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/$(DEPDIR)/protobuf_test-time_util_test.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/$(DEPDIR)/protobuf_test-type_resolver_util_test.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/$(DEPDIR)/time_util.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/$(DEPDIR)/type_resolver_util.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/$(DEPDIR)/datapiece.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/$(DEPDIR)/default_value_objectwriter.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/$(DEPDIR)/error_listener.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/$(DEPDIR)/field_mask_utility.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/$(DEPDIR)/json_escaping.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/$(DEPDIR)/json_objectwriter.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/$(DEPDIR)/json_stream_parser.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/$(DEPDIR)/object_writer.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/$(DEPDIR)/proto_writer.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/$(DEPDIR)/protobuf_test-default_value_objectwriter_test.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/$(DEPDIR)/protobuf_test-json_objectwriter_test.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/$(DEPDIR)/protobuf_test-json_stream_parser_test.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/$(DEPDIR)/protobuf_test-protostream_objectsource_test.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/$(DEPDIR)/protobuf_test-protostream_objectwriter_test.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/$(DEPDIR)/protobuf_test-type_info_test_helper.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/$(DEPDIR)/protostream_objectsource.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/$(DEPDIR)/protostream_objectwriter.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/$(DEPDIR)/type_info.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/$(DEPDIR)/type_info_test_helper.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/$(DEPDIR)/utility.Plo@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-anys.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-books.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-default_value.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-default_value_test.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-field_mask.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-maps.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-oneofs.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-struct.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-timestamp_duration.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-anys.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-books.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-default_value.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-default_value_test.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-field_mask.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-maps.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-oneofs.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-struct.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-timestamp_duration.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-anys.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-books.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-default_value.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-default_value_test.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-field_mask.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-maps.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-oneofs.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-struct.pb.Po@am__quote@\n@AMDEP_TRUE@@am__include@ @am__quote@google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-timestamp_duration.pb.Po@am__quote@\n\n.cc.o:\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\\.o$$||'`;\\\n@am__fastdepCXX_TRUE@\t$(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\\\n@am__fastdepCXX_TRUE@\t$(am__mv) $$depbase.Tpo $$depbase.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<\n\n.cc.obj:\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\\.obj$$||'`;\\\n@am__fastdepCXX_TRUE@\t$(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\\\n@am__fastdepCXX_TRUE@\t$(am__mv) $$depbase.Tpo $$depbase.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`\n\n.cc.lo:\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\\.lo$$||'`;\\\n@am__fastdepCXX_TRUE@\t$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\\\n@am__fastdepCXX_TRUE@\t$(am__mv) $$depbase.Tpo $$depbase.Plo\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<\n\nno_warning_test-no_warning_test.o: no_warning_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT no_warning_test-no_warning_test.o -MD -MP -MF $(DEPDIR)/no_warning_test-no_warning_test.Tpo -c -o no_warning_test-no_warning_test.o `test -f 'no_warning_test.cc' || echo '$(srcdir)/'`no_warning_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) $(DEPDIR)/no_warning_test-no_warning_test.Tpo $(DEPDIR)/no_warning_test-no_warning_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='no_warning_test.cc' object='no_warning_test-no_warning_test.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o no_warning_test-no_warning_test.o `test -f 'no_warning_test.cc' || echo '$(srcdir)/'`no_warning_test.cc\n\nno_warning_test-no_warning_test.obj: no_warning_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT no_warning_test-no_warning_test.obj -MD -MP -MF $(DEPDIR)/no_warning_test-no_warning_test.Tpo -c -o no_warning_test-no_warning_test.obj `if test -f 'no_warning_test.cc'; then $(CYGPATH_W) 'no_warning_test.cc'; else $(CYGPATH_W) '$(srcdir)/no_warning_test.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) $(DEPDIR)/no_warning_test-no_warning_test.Tpo $(DEPDIR)/no_warning_test-no_warning_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='no_warning_test.cc' object='no_warning_test-no_warning_test.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o no_warning_test-no_warning_test.obj `if test -f 'no_warning_test.cc'; then $(CYGPATH_W) 'no_warning_test.cc'; else $(CYGPATH_W) '$(srcdir)/no_warning_test.cc'; fi`\n\ngoogle/protobuf/no_warning_test-map_lite_unittest.pb.o: google/protobuf/map_lite_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-map_lite_unittest.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-map_lite_unittest.pb.Tpo -c -o google/protobuf/no_warning_test-map_lite_unittest.pb.o `test -f 'google/protobuf/map_lite_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/map_lite_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-map_lite_unittest.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-map_lite_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_lite_unittest.pb.cc' object='google/protobuf/no_warning_test-map_lite_unittest.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-map_lite_unittest.pb.o `test -f 'google/protobuf/map_lite_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/map_lite_unittest.pb.cc\n\ngoogle/protobuf/no_warning_test-map_lite_unittest.pb.obj: google/protobuf/map_lite_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-map_lite_unittest.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-map_lite_unittest.pb.Tpo -c -o google/protobuf/no_warning_test-map_lite_unittest.pb.obj `if test -f 'google/protobuf/map_lite_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/map_lite_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_lite_unittest.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-map_lite_unittest.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-map_lite_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_lite_unittest.pb.cc' object='google/protobuf/no_warning_test-map_lite_unittest.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-map_lite_unittest.pb.obj `if test -f 'google/protobuf/map_lite_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/map_lite_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_lite_unittest.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_lite.pb.o: google/protobuf/unittest_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_lite.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_lite.pb.o `test -f 'google/protobuf/unittest_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_lite.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_lite.pb.cc' object='google/protobuf/no_warning_test-unittest_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_lite.pb.o `test -f 'google/protobuf/unittest_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_lite.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_lite.pb.obj: google/protobuf/unittest_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_lite.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_lite.pb.obj `if test -f 'google/protobuf/unittest_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_lite.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_lite.pb.cc' object='google/protobuf/no_warning_test-unittest_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_lite.pb.obj `if test -f 'google/protobuf/unittest_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_lite.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_no_arena_lite.pb.o: google/protobuf/unittest_no_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_no_arena_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_arena_lite.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_no_arena_lite.pb.o `test -f 'google/protobuf/unittest_no_arena_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_arena_lite.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_arena_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_arena_lite.pb.cc' object='google/protobuf/no_warning_test-unittest_no_arena_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_no_arena_lite.pb.o `test -f 'google/protobuf/unittest_no_arena_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_arena_lite.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_no_arena_lite.pb.obj: google/protobuf/unittest_no_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_no_arena_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_arena_lite.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_no_arena_lite.pb.obj `if test -f 'google/protobuf/unittest_no_arena_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_arena_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_arena_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_arena_lite.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_arena_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_arena_lite.pb.cc' object='google/protobuf/no_warning_test-unittest_no_arena_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_no_arena_lite.pb.obj `if test -f 'google/protobuf/unittest_no_arena_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_arena_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_arena_lite.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_import_lite.pb.o: google/protobuf/unittest_import_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_import_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_import_lite.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_import_lite.pb.o `test -f 'google/protobuf/unittest_import_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_import_lite.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_import_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_lite.pb.cc' object='google/protobuf/no_warning_test-unittest_import_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_import_lite.pb.o `test -f 'google/protobuf/unittest_import_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_lite.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_import_lite.pb.obj: google/protobuf/unittest_import_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_import_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_import_lite.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_import_lite.pb.obj `if test -f 'google/protobuf/unittest_import_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_import_lite.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_import_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_lite.pb.cc' object='google/protobuf/no_warning_test-unittest_import_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_import_lite.pb.obj `if test -f 'google/protobuf/unittest_import_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_lite.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_import_public_lite.pb.o: google/protobuf/unittest_import_public_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_import_public_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_import_public_lite.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_import_public_lite.pb.o `test -f 'google/protobuf/unittest_import_public_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_public_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_import_public_lite.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_import_public_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_public_lite.pb.cc' object='google/protobuf/no_warning_test-unittest_import_public_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_import_public_lite.pb.o `test -f 'google/protobuf/unittest_import_public_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_public_lite.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_import_public_lite.pb.obj: google/protobuf/unittest_import_public_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_import_public_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_import_public_lite.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_import_public_lite.pb.obj `if test -f 'google/protobuf/unittest_import_public_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_public_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_public_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_import_public_lite.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_import_public_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_public_lite.pb.cc' object='google/protobuf/no_warning_test-unittest_import_public_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_import_public_lite.pb.obj `if test -f 'google/protobuf/unittest_import_public_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_public_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_public_lite.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-any_test.pb.o: google/protobuf/any_test.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-any_test.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-any_test.pb.Tpo -c -o google/protobuf/no_warning_test-any_test.pb.o `test -f 'google/protobuf/any_test.pb.cc' || echo '$(srcdir)/'`google/protobuf/any_test.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-any_test.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-any_test.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/any_test.pb.cc' object='google/protobuf/no_warning_test-any_test.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-any_test.pb.o `test -f 'google/protobuf/any_test.pb.cc' || echo '$(srcdir)/'`google/protobuf/any_test.pb.cc\n\ngoogle/protobuf/no_warning_test-any_test.pb.obj: google/protobuf/any_test.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-any_test.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-any_test.pb.Tpo -c -o google/protobuf/no_warning_test-any_test.pb.obj `if test -f 'google/protobuf/any_test.pb.cc'; then $(CYGPATH_W) 'google/protobuf/any_test.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/any_test.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-any_test.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-any_test.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/any_test.pb.cc' object='google/protobuf/no_warning_test-any_test.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-any_test.pb.obj `if test -f 'google/protobuf/any_test.pb.cc'; then $(CYGPATH_W) 'google/protobuf/any_test.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/any_test.pb.cc'; fi`\n\ngoogle/protobuf/compiler/cpp/no_warning_test-cpp_test_bad_identifiers.pb.o: google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/cpp/no_warning_test-cpp_test_bad_identifiers.pb.o -MD -MP -MF google/protobuf/compiler/cpp/$(DEPDIR)/no_warning_test-cpp_test_bad_identifiers.pb.Tpo -c -o google/protobuf/compiler/cpp/no_warning_test-cpp_test_bad_identifiers.pb.o `test -f 'google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc' || echo '$(srcdir)/'`google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/cpp/$(DEPDIR)/no_warning_test-cpp_test_bad_identifiers.pb.Tpo google/protobuf/compiler/cpp/$(DEPDIR)/no_warning_test-cpp_test_bad_identifiers.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc' object='google/protobuf/compiler/cpp/no_warning_test-cpp_test_bad_identifiers.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/cpp/no_warning_test-cpp_test_bad_identifiers.pb.o `test -f 'google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc' || echo '$(srcdir)/'`google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc\n\ngoogle/protobuf/compiler/cpp/no_warning_test-cpp_test_bad_identifiers.pb.obj: google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/cpp/no_warning_test-cpp_test_bad_identifiers.pb.obj -MD -MP -MF google/protobuf/compiler/cpp/$(DEPDIR)/no_warning_test-cpp_test_bad_identifiers.pb.Tpo -c -o google/protobuf/compiler/cpp/no_warning_test-cpp_test_bad_identifiers.pb.obj `if test -f 'google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/cpp/$(DEPDIR)/no_warning_test-cpp_test_bad_identifiers.pb.Tpo google/protobuf/compiler/cpp/$(DEPDIR)/no_warning_test-cpp_test_bad_identifiers.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc' object='google/protobuf/compiler/cpp/no_warning_test-cpp_test_bad_identifiers.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/cpp/no_warning_test-cpp_test_bad_identifiers.pb.obj `if test -f 'google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc'; fi`\n\ngoogle/protobuf/compiler/cpp/no_warning_test-cpp_test_large_enum_value.pb.o: google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/cpp/no_warning_test-cpp_test_large_enum_value.pb.o -MD -MP -MF google/protobuf/compiler/cpp/$(DEPDIR)/no_warning_test-cpp_test_large_enum_value.pb.Tpo -c -o google/protobuf/compiler/cpp/no_warning_test-cpp_test_large_enum_value.pb.o `test -f 'google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc' || echo '$(srcdir)/'`google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/cpp/$(DEPDIR)/no_warning_test-cpp_test_large_enum_value.pb.Tpo google/protobuf/compiler/cpp/$(DEPDIR)/no_warning_test-cpp_test_large_enum_value.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc' object='google/protobuf/compiler/cpp/no_warning_test-cpp_test_large_enum_value.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/cpp/no_warning_test-cpp_test_large_enum_value.pb.o `test -f 'google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc' || echo '$(srcdir)/'`google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc\n\ngoogle/protobuf/compiler/cpp/no_warning_test-cpp_test_large_enum_value.pb.obj: google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/cpp/no_warning_test-cpp_test_large_enum_value.pb.obj -MD -MP -MF google/protobuf/compiler/cpp/$(DEPDIR)/no_warning_test-cpp_test_large_enum_value.pb.Tpo -c -o google/protobuf/compiler/cpp/no_warning_test-cpp_test_large_enum_value.pb.obj `if test -f 'google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/cpp/$(DEPDIR)/no_warning_test-cpp_test_large_enum_value.pb.Tpo google/protobuf/compiler/cpp/$(DEPDIR)/no_warning_test-cpp_test_large_enum_value.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc' object='google/protobuf/compiler/cpp/no_warning_test-cpp_test_large_enum_value.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/cpp/no_warning_test-cpp_test_large_enum_value.pb.obj `if test -f 'google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-map_proto2_unittest.pb.o: google/protobuf/map_proto2_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-map_proto2_unittest.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-map_proto2_unittest.pb.Tpo -c -o google/protobuf/no_warning_test-map_proto2_unittest.pb.o `test -f 'google/protobuf/map_proto2_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/map_proto2_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-map_proto2_unittest.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-map_proto2_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_proto2_unittest.pb.cc' object='google/protobuf/no_warning_test-map_proto2_unittest.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-map_proto2_unittest.pb.o `test -f 'google/protobuf/map_proto2_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/map_proto2_unittest.pb.cc\n\ngoogle/protobuf/no_warning_test-map_proto2_unittest.pb.obj: google/protobuf/map_proto2_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-map_proto2_unittest.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-map_proto2_unittest.pb.Tpo -c -o google/protobuf/no_warning_test-map_proto2_unittest.pb.obj `if test -f 'google/protobuf/map_proto2_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/map_proto2_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_proto2_unittest.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-map_proto2_unittest.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-map_proto2_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_proto2_unittest.pb.cc' object='google/protobuf/no_warning_test-map_proto2_unittest.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-map_proto2_unittest.pb.obj `if test -f 'google/protobuf/map_proto2_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/map_proto2_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_proto2_unittest.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-map_unittest.pb.o: google/protobuf/map_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-map_unittest.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-map_unittest.pb.Tpo -c -o google/protobuf/no_warning_test-map_unittest.pb.o `test -f 'google/protobuf/map_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/map_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-map_unittest.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-map_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_unittest.pb.cc' object='google/protobuf/no_warning_test-map_unittest.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-map_unittest.pb.o `test -f 'google/protobuf/map_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/map_unittest.pb.cc\n\ngoogle/protobuf/no_warning_test-map_unittest.pb.obj: google/protobuf/map_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-map_unittest.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-map_unittest.pb.Tpo -c -o google/protobuf/no_warning_test-map_unittest.pb.obj `if test -f 'google/protobuf/map_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/map_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_unittest.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-map_unittest.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-map_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_unittest.pb.cc' object='google/protobuf/no_warning_test-map_unittest.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-map_unittest.pb.obj `if test -f 'google/protobuf/map_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/map_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_unittest.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_arena.pb.o: google/protobuf/unittest_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_arena.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_arena.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_arena.pb.o `test -f 'google/protobuf/unittest_arena.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_arena.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_arena.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_arena.pb.cc' object='google/protobuf/no_warning_test-unittest_arena.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_arena.pb.o `test -f 'google/protobuf/unittest_arena.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_arena.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_arena.pb.obj: google/protobuf/unittest_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_arena.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_arena.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_arena.pb.obj `if test -f 'google/protobuf/unittest_arena.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_arena.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_arena.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_arena.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_arena.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_arena.pb.cc' object='google/protobuf/no_warning_test-unittest_arena.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_arena.pb.obj `if test -f 'google/protobuf/unittest_arena.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_arena.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_arena.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_custom_options.pb.o: google/protobuf/unittest_custom_options.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_custom_options.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_custom_options.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_custom_options.pb.o `test -f 'google/protobuf/unittest_custom_options.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_custom_options.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_custom_options.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_custom_options.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_custom_options.pb.cc' object='google/protobuf/no_warning_test-unittest_custom_options.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_custom_options.pb.o `test -f 'google/protobuf/unittest_custom_options.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_custom_options.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_custom_options.pb.obj: google/protobuf/unittest_custom_options.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_custom_options.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_custom_options.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_custom_options.pb.obj `if test -f 'google/protobuf/unittest_custom_options.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_custom_options.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_custom_options.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_custom_options.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_custom_options.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_custom_options.pb.cc' object='google/protobuf/no_warning_test-unittest_custom_options.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_custom_options.pb.obj `if test -f 'google/protobuf/unittest_custom_options.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_custom_options.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_custom_options.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_drop_unknown_fields.pb.o: google/protobuf/unittest_drop_unknown_fields.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_drop_unknown_fields.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_drop_unknown_fields.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_drop_unknown_fields.pb.o `test -f 'google/protobuf/unittest_drop_unknown_fields.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_drop_unknown_fields.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_drop_unknown_fields.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_drop_unknown_fields.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_drop_unknown_fields.pb.cc' object='google/protobuf/no_warning_test-unittest_drop_unknown_fields.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_drop_unknown_fields.pb.o `test -f 'google/protobuf/unittest_drop_unknown_fields.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_drop_unknown_fields.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_drop_unknown_fields.pb.obj: google/protobuf/unittest_drop_unknown_fields.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_drop_unknown_fields.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_drop_unknown_fields.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_drop_unknown_fields.pb.obj `if test -f 'google/protobuf/unittest_drop_unknown_fields.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_drop_unknown_fields.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_drop_unknown_fields.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_drop_unknown_fields.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_drop_unknown_fields.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_drop_unknown_fields.pb.cc' object='google/protobuf/no_warning_test-unittest_drop_unknown_fields.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_drop_unknown_fields.pb.obj `if test -f 'google/protobuf/unittest_drop_unknown_fields.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_drop_unknown_fields.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_drop_unknown_fields.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_embed_optimize_for.pb.o: google/protobuf/unittest_embed_optimize_for.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_embed_optimize_for.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_embed_optimize_for.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_embed_optimize_for.pb.o `test -f 'google/protobuf/unittest_embed_optimize_for.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_embed_optimize_for.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_embed_optimize_for.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_embed_optimize_for.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_embed_optimize_for.pb.cc' object='google/protobuf/no_warning_test-unittest_embed_optimize_for.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_embed_optimize_for.pb.o `test -f 'google/protobuf/unittest_embed_optimize_for.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_embed_optimize_for.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_embed_optimize_for.pb.obj: google/protobuf/unittest_embed_optimize_for.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_embed_optimize_for.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_embed_optimize_for.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_embed_optimize_for.pb.obj `if test -f 'google/protobuf/unittest_embed_optimize_for.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_embed_optimize_for.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_embed_optimize_for.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_embed_optimize_for.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_embed_optimize_for.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_embed_optimize_for.pb.cc' object='google/protobuf/no_warning_test-unittest_embed_optimize_for.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_embed_optimize_for.pb.obj `if test -f 'google/protobuf/unittest_embed_optimize_for.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_embed_optimize_for.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_embed_optimize_for.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_empty.pb.o: google/protobuf/unittest_empty.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_empty.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_empty.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_empty.pb.o `test -f 'google/protobuf/unittest_empty.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_empty.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_empty.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_empty.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_empty.pb.cc' object='google/protobuf/no_warning_test-unittest_empty.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_empty.pb.o `test -f 'google/protobuf/unittest_empty.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_empty.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_empty.pb.obj: google/protobuf/unittest_empty.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_empty.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_empty.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_empty.pb.obj `if test -f 'google/protobuf/unittest_empty.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_empty.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_empty.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_empty.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_empty.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_empty.pb.cc' object='google/protobuf/no_warning_test-unittest_empty.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_empty.pb.obj `if test -f 'google/protobuf/unittest_empty.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_empty.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_empty.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_enormous_descriptor.pb.o: google/protobuf/unittest_enormous_descriptor.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_enormous_descriptor.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_enormous_descriptor.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_enormous_descriptor.pb.o `test -f 'google/protobuf/unittest_enormous_descriptor.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_enormous_descriptor.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_enormous_descriptor.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_enormous_descriptor.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_enormous_descriptor.pb.cc' object='google/protobuf/no_warning_test-unittest_enormous_descriptor.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_enormous_descriptor.pb.o `test -f 'google/protobuf/unittest_enormous_descriptor.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_enormous_descriptor.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_enormous_descriptor.pb.obj: google/protobuf/unittest_enormous_descriptor.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_enormous_descriptor.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_enormous_descriptor.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_enormous_descriptor.pb.obj `if test -f 'google/protobuf/unittest_enormous_descriptor.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_enormous_descriptor.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_enormous_descriptor.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_enormous_descriptor.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_enormous_descriptor.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_enormous_descriptor.pb.cc' object='google/protobuf/no_warning_test-unittest_enormous_descriptor.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_enormous_descriptor.pb.obj `if test -f 'google/protobuf/unittest_enormous_descriptor.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_enormous_descriptor.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_enormous_descriptor.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_import.pb.o: google/protobuf/unittest_import.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_import.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_import.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_import.pb.o `test -f 'google/protobuf/unittest_import.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_import.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_import.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import.pb.cc' object='google/protobuf/no_warning_test-unittest_import.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_import.pb.o `test -f 'google/protobuf/unittest_import.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_import.pb.obj: google/protobuf/unittest_import.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_import.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_import.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_import.pb.obj `if test -f 'google/protobuf/unittest_import.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_import.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_import.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import.pb.cc' object='google/protobuf/no_warning_test-unittest_import.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_import.pb.obj `if test -f 'google/protobuf/unittest_import.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_import_public.pb.o: google/protobuf/unittest_import_public.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_import_public.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_import_public.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_import_public.pb.o `test -f 'google/protobuf/unittest_import_public.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_public.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_import_public.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_import_public.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_public.pb.cc' object='google/protobuf/no_warning_test-unittest_import_public.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_import_public.pb.o `test -f 'google/protobuf/unittest_import_public.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_public.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_import_public.pb.obj: google/protobuf/unittest_import_public.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_import_public.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_import_public.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_import_public.pb.obj `if test -f 'google/protobuf/unittest_import_public.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_public.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_public.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_import_public.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_import_public.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_public.pb.cc' object='google/protobuf/no_warning_test-unittest_import_public.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_import_public.pb.obj `if test -f 'google/protobuf/unittest_import_public.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_public.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_public.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_lite_imports_nonlite.pb.o: google/protobuf/unittest_lite_imports_nonlite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_lite_imports_nonlite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_lite_imports_nonlite.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_lite_imports_nonlite.pb.o `test -f 'google/protobuf/unittest_lite_imports_nonlite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_lite_imports_nonlite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_lite_imports_nonlite.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_lite_imports_nonlite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_lite_imports_nonlite.pb.cc' object='google/protobuf/no_warning_test-unittest_lite_imports_nonlite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_lite_imports_nonlite.pb.o `test -f 'google/protobuf/unittest_lite_imports_nonlite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_lite_imports_nonlite.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_lite_imports_nonlite.pb.obj: google/protobuf/unittest_lite_imports_nonlite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_lite_imports_nonlite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_lite_imports_nonlite.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_lite_imports_nonlite.pb.obj `if test -f 'google/protobuf/unittest_lite_imports_nonlite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_lite_imports_nonlite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_lite_imports_nonlite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_lite_imports_nonlite.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_lite_imports_nonlite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_lite_imports_nonlite.pb.cc' object='google/protobuf/no_warning_test-unittest_lite_imports_nonlite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_lite_imports_nonlite.pb.obj `if test -f 'google/protobuf/unittest_lite_imports_nonlite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_lite_imports_nonlite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_lite_imports_nonlite.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_mset.pb.o: google/protobuf/unittest_mset.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_mset.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_mset.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_mset.pb.o `test -f 'google/protobuf/unittest_mset.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_mset.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_mset.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_mset.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_mset.pb.cc' object='google/protobuf/no_warning_test-unittest_mset.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_mset.pb.o `test -f 'google/protobuf/unittest_mset.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_mset.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_mset.pb.obj: google/protobuf/unittest_mset.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_mset.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_mset.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_mset.pb.obj `if test -f 'google/protobuf/unittest_mset.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_mset.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_mset.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_mset.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_mset.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_mset.pb.cc' object='google/protobuf/no_warning_test-unittest_mset.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_mset.pb.obj `if test -f 'google/protobuf/unittest_mset.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_mset.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_mset.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_mset_wire_format.pb.o: google/protobuf/unittest_mset_wire_format.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_mset_wire_format.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_mset_wire_format.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_mset_wire_format.pb.o `test -f 'google/protobuf/unittest_mset_wire_format.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_mset_wire_format.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_mset_wire_format.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_mset_wire_format.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_mset_wire_format.pb.cc' object='google/protobuf/no_warning_test-unittest_mset_wire_format.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_mset_wire_format.pb.o `test -f 'google/protobuf/unittest_mset_wire_format.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_mset_wire_format.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_mset_wire_format.pb.obj: google/protobuf/unittest_mset_wire_format.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_mset_wire_format.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_mset_wire_format.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_mset_wire_format.pb.obj `if test -f 'google/protobuf/unittest_mset_wire_format.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_mset_wire_format.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_mset_wire_format.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_mset_wire_format.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_mset_wire_format.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_mset_wire_format.pb.cc' object='google/protobuf/no_warning_test-unittest_mset_wire_format.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_mset_wire_format.pb.obj `if test -f 'google/protobuf/unittest_mset_wire_format.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_mset_wire_format.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_mset_wire_format.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_no_arena_import.pb.o: google/protobuf/unittest_no_arena_import.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_no_arena_import.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_arena_import.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_no_arena_import.pb.o `test -f 'google/protobuf/unittest_no_arena_import.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_arena_import.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_arena_import.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_arena_import.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_arena_import.pb.cc' object='google/protobuf/no_warning_test-unittest_no_arena_import.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_no_arena_import.pb.o `test -f 'google/protobuf/unittest_no_arena_import.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_arena_import.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_no_arena_import.pb.obj: google/protobuf/unittest_no_arena_import.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_no_arena_import.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_arena_import.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_no_arena_import.pb.obj `if test -f 'google/protobuf/unittest_no_arena_import.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_arena_import.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_arena_import.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_arena_import.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_arena_import.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_arena_import.pb.cc' object='google/protobuf/no_warning_test-unittest_no_arena_import.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_no_arena_import.pb.obj `if test -f 'google/protobuf/unittest_no_arena_import.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_arena_import.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_arena_import.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_no_arena.pb.o: google/protobuf/unittest_no_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_no_arena.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_arena.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_no_arena.pb.o `test -f 'google/protobuf/unittest_no_arena.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_arena.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_arena.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_arena.pb.cc' object='google/protobuf/no_warning_test-unittest_no_arena.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_no_arena.pb.o `test -f 'google/protobuf/unittest_no_arena.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_arena.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_no_arena.pb.obj: google/protobuf/unittest_no_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_no_arena.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_arena.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_no_arena.pb.obj `if test -f 'google/protobuf/unittest_no_arena.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_arena.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_arena.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_arena.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_arena.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_arena.pb.cc' object='google/protobuf/no_warning_test-unittest_no_arena.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_no_arena.pb.obj `if test -f 'google/protobuf/unittest_no_arena.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_arena.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_arena.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_no_field_presence.pb.o: google/protobuf/unittest_no_field_presence.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_no_field_presence.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_field_presence.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_no_field_presence.pb.o `test -f 'google/protobuf/unittest_no_field_presence.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_field_presence.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_field_presence.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_field_presence.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_field_presence.pb.cc' object='google/protobuf/no_warning_test-unittest_no_field_presence.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_no_field_presence.pb.o `test -f 'google/protobuf/unittest_no_field_presence.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_field_presence.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_no_field_presence.pb.obj: google/protobuf/unittest_no_field_presence.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_no_field_presence.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_field_presence.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_no_field_presence.pb.obj `if test -f 'google/protobuf/unittest_no_field_presence.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_field_presence.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_field_presence.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_field_presence.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_field_presence.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_field_presence.pb.cc' object='google/protobuf/no_warning_test-unittest_no_field_presence.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_no_field_presence.pb.obj `if test -f 'google/protobuf/unittest_no_field_presence.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_field_presence.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_field_presence.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_no_generic_services.pb.o: google/protobuf/unittest_no_generic_services.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_no_generic_services.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_generic_services.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_no_generic_services.pb.o `test -f 'google/protobuf/unittest_no_generic_services.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_generic_services.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_generic_services.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_generic_services.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_generic_services.pb.cc' object='google/protobuf/no_warning_test-unittest_no_generic_services.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_no_generic_services.pb.o `test -f 'google/protobuf/unittest_no_generic_services.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_generic_services.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_no_generic_services.pb.obj: google/protobuf/unittest_no_generic_services.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_no_generic_services.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_generic_services.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_no_generic_services.pb.obj `if test -f 'google/protobuf/unittest_no_generic_services.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_generic_services.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_generic_services.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_generic_services.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_no_generic_services.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_generic_services.pb.cc' object='google/protobuf/no_warning_test-unittest_no_generic_services.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_no_generic_services.pb.obj `if test -f 'google/protobuf/unittest_no_generic_services.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_generic_services.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_generic_services.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_optimize_for.pb.o: google/protobuf/unittest_optimize_for.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_optimize_for.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_optimize_for.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_optimize_for.pb.o `test -f 'google/protobuf/unittest_optimize_for.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_optimize_for.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_optimize_for.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_optimize_for.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_optimize_for.pb.cc' object='google/protobuf/no_warning_test-unittest_optimize_for.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_optimize_for.pb.o `test -f 'google/protobuf/unittest_optimize_for.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_optimize_for.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_optimize_for.pb.obj: google/protobuf/unittest_optimize_for.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_optimize_for.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_optimize_for.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_optimize_for.pb.obj `if test -f 'google/protobuf/unittest_optimize_for.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_optimize_for.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_optimize_for.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_optimize_for.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_optimize_for.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_optimize_for.pb.cc' object='google/protobuf/no_warning_test-unittest_optimize_for.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_optimize_for.pb.obj `if test -f 'google/protobuf/unittest_optimize_for.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_optimize_for.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_optimize_for.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest.pb.o: google/protobuf/unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest.pb.Tpo -c -o google/protobuf/no_warning_test-unittest.pb.o `test -f 'google/protobuf/unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest.pb.cc' object='google/protobuf/no_warning_test-unittest.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest.pb.o `test -f 'google/protobuf/unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest.pb.obj: google/protobuf/unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest.pb.Tpo -c -o google/protobuf/no_warning_test-unittest.pb.obj `if test -f 'google/protobuf/unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest.pb.cc' object='google/protobuf/no_warning_test-unittest.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest.pb.obj `if test -f 'google/protobuf/unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_preserve_unknown_enum2.pb.o: google/protobuf/unittest_preserve_unknown_enum2.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_preserve_unknown_enum2.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_preserve_unknown_enum2.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_preserve_unknown_enum2.pb.o `test -f 'google/protobuf/unittest_preserve_unknown_enum2.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_preserve_unknown_enum2.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_preserve_unknown_enum2.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_preserve_unknown_enum2.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_preserve_unknown_enum2.pb.cc' object='google/protobuf/no_warning_test-unittest_preserve_unknown_enum2.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_preserve_unknown_enum2.pb.o `test -f 'google/protobuf/unittest_preserve_unknown_enum2.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_preserve_unknown_enum2.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_preserve_unknown_enum2.pb.obj: google/protobuf/unittest_preserve_unknown_enum2.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_preserve_unknown_enum2.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_preserve_unknown_enum2.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_preserve_unknown_enum2.pb.obj `if test -f 'google/protobuf/unittest_preserve_unknown_enum2.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_preserve_unknown_enum2.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_preserve_unknown_enum2.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_preserve_unknown_enum2.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_preserve_unknown_enum2.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_preserve_unknown_enum2.pb.cc' object='google/protobuf/no_warning_test-unittest_preserve_unknown_enum2.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_preserve_unknown_enum2.pb.obj `if test -f 'google/protobuf/unittest_preserve_unknown_enum2.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_preserve_unknown_enum2.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_preserve_unknown_enum2.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_preserve_unknown_enum.pb.o: google/protobuf/unittest_preserve_unknown_enum.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_preserve_unknown_enum.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_preserve_unknown_enum.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_preserve_unknown_enum.pb.o `test -f 'google/protobuf/unittest_preserve_unknown_enum.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_preserve_unknown_enum.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_preserve_unknown_enum.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_preserve_unknown_enum.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_preserve_unknown_enum.pb.cc' object='google/protobuf/no_warning_test-unittest_preserve_unknown_enum.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_preserve_unknown_enum.pb.o `test -f 'google/protobuf/unittest_preserve_unknown_enum.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_preserve_unknown_enum.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_preserve_unknown_enum.pb.obj: google/protobuf/unittest_preserve_unknown_enum.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_preserve_unknown_enum.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_preserve_unknown_enum.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_preserve_unknown_enum.pb.obj `if test -f 'google/protobuf/unittest_preserve_unknown_enum.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_preserve_unknown_enum.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_preserve_unknown_enum.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_preserve_unknown_enum.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_preserve_unknown_enum.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_preserve_unknown_enum.pb.cc' object='google/protobuf/no_warning_test-unittest_preserve_unknown_enum.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_preserve_unknown_enum.pb.obj `if test -f 'google/protobuf/unittest_preserve_unknown_enum.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_preserve_unknown_enum.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_preserve_unknown_enum.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_proto3_arena.pb.o: google/protobuf/unittest_proto3_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_proto3_arena.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_proto3_arena.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_proto3_arena.pb.o `test -f 'google/protobuf/unittest_proto3_arena.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_proto3_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_proto3_arena.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_proto3_arena.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_proto3_arena.pb.cc' object='google/protobuf/no_warning_test-unittest_proto3_arena.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_proto3_arena.pb.o `test -f 'google/protobuf/unittest_proto3_arena.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_proto3_arena.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_proto3_arena.pb.obj: google/protobuf/unittest_proto3_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_proto3_arena.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_proto3_arena.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_proto3_arena.pb.obj `if test -f 'google/protobuf/unittest_proto3_arena.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_proto3_arena.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_proto3_arena.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_proto3_arena.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_proto3_arena.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_proto3_arena.pb.cc' object='google/protobuf/no_warning_test-unittest_proto3_arena.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_proto3_arena.pb.obj `if test -f 'google/protobuf/unittest_proto3_arena.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_proto3_arena.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_proto3_arena.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_proto3_arena_lite.pb.o: google/protobuf/unittest_proto3_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_proto3_arena_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_proto3_arena_lite.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_proto3_arena_lite.pb.o `test -f 'google/protobuf/unittest_proto3_arena_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_proto3_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_proto3_arena_lite.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_proto3_arena_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_proto3_arena_lite.pb.cc' object='google/protobuf/no_warning_test-unittest_proto3_arena_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_proto3_arena_lite.pb.o `test -f 'google/protobuf/unittest_proto3_arena_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_proto3_arena_lite.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_proto3_arena_lite.pb.obj: google/protobuf/unittest_proto3_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_proto3_arena_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_proto3_arena_lite.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_proto3_arena_lite.pb.obj `if test -f 'google/protobuf/unittest_proto3_arena_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_proto3_arena_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_proto3_arena_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_proto3_arena_lite.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_proto3_arena_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_proto3_arena_lite.pb.cc' object='google/protobuf/no_warning_test-unittest_proto3_arena_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_proto3_arena_lite.pb.obj `if test -f 'google/protobuf/unittest_proto3_arena_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_proto3_arena_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_proto3_arena_lite.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_proto3_lite.pb.o: google/protobuf/unittest_proto3_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_proto3_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_proto3_lite.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_proto3_lite.pb.o `test -f 'google/protobuf/unittest_proto3_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_proto3_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_proto3_lite.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_proto3_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_proto3_lite.pb.cc' object='google/protobuf/no_warning_test-unittest_proto3_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_proto3_lite.pb.o `test -f 'google/protobuf/unittest_proto3_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_proto3_lite.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_proto3_lite.pb.obj: google/protobuf/unittest_proto3_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_proto3_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_proto3_lite.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_proto3_lite.pb.obj `if test -f 'google/protobuf/unittest_proto3_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_proto3_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_proto3_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_proto3_lite.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_proto3_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_proto3_lite.pb.cc' object='google/protobuf/no_warning_test-unittest_proto3_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_proto3_lite.pb.obj `if test -f 'google/protobuf/unittest_proto3_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_proto3_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_proto3_lite.pb.cc'; fi`\n\ngoogle/protobuf/no_warning_test-unittest_well_known_types.pb.o: google/protobuf/unittest_well_known_types.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_well_known_types.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_well_known_types.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_well_known_types.pb.o `test -f 'google/protobuf/unittest_well_known_types.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_well_known_types.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_well_known_types.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_well_known_types.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_well_known_types.pb.cc' object='google/protobuf/no_warning_test-unittest_well_known_types.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_well_known_types.pb.o `test -f 'google/protobuf/unittest_well_known_types.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_well_known_types.pb.cc\n\ngoogle/protobuf/no_warning_test-unittest_well_known_types.pb.obj: google/protobuf/unittest_well_known_types.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/no_warning_test-unittest_well_known_types.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/no_warning_test-unittest_well_known_types.pb.Tpo -c -o google/protobuf/no_warning_test-unittest_well_known_types.pb.obj `if test -f 'google/protobuf/unittest_well_known_types.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_well_known_types.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_well_known_types.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/no_warning_test-unittest_well_known_types.pb.Tpo google/protobuf/$(DEPDIR)/no_warning_test-unittest_well_known_types.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_well_known_types.pb.cc' object='google/protobuf/no_warning_test-unittest_well_known_types.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/no_warning_test-unittest_well_known_types.pb.obj `if test -f 'google/protobuf/unittest_well_known_types.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_well_known_types.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_well_known_types.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/no_warning_test-anys.pb.o: google/protobuf/util/internal/testdata/anys.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/no_warning_test-anys.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-anys.pb.Tpo -c -o google/protobuf/util/internal/testdata/no_warning_test-anys.pb.o `test -f 'google/protobuf/util/internal/testdata/anys.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/anys.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-anys.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-anys.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/anys.pb.cc' object='google/protobuf/util/internal/testdata/no_warning_test-anys.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/no_warning_test-anys.pb.o `test -f 'google/protobuf/util/internal/testdata/anys.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/anys.pb.cc\n\ngoogle/protobuf/util/internal/testdata/no_warning_test-anys.pb.obj: google/protobuf/util/internal/testdata/anys.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/no_warning_test-anys.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-anys.pb.Tpo -c -o google/protobuf/util/internal/testdata/no_warning_test-anys.pb.obj `if test -f 'google/protobuf/util/internal/testdata/anys.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/anys.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/anys.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-anys.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-anys.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/anys.pb.cc' object='google/protobuf/util/internal/testdata/no_warning_test-anys.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/no_warning_test-anys.pb.obj `if test -f 'google/protobuf/util/internal/testdata/anys.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/anys.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/anys.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/no_warning_test-books.pb.o: google/protobuf/util/internal/testdata/books.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/no_warning_test-books.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-books.pb.Tpo -c -o google/protobuf/util/internal/testdata/no_warning_test-books.pb.o `test -f 'google/protobuf/util/internal/testdata/books.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/books.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-books.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-books.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/books.pb.cc' object='google/protobuf/util/internal/testdata/no_warning_test-books.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/no_warning_test-books.pb.o `test -f 'google/protobuf/util/internal/testdata/books.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/books.pb.cc\n\ngoogle/protobuf/util/internal/testdata/no_warning_test-books.pb.obj: google/protobuf/util/internal/testdata/books.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/no_warning_test-books.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-books.pb.Tpo -c -o google/protobuf/util/internal/testdata/no_warning_test-books.pb.obj `if test -f 'google/protobuf/util/internal/testdata/books.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/books.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/books.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-books.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-books.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/books.pb.cc' object='google/protobuf/util/internal/testdata/no_warning_test-books.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/no_warning_test-books.pb.obj `if test -f 'google/protobuf/util/internal/testdata/books.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/books.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/books.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/no_warning_test-default_value.pb.o: google/protobuf/util/internal/testdata/default_value.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/no_warning_test-default_value.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-default_value.pb.Tpo -c -o google/protobuf/util/internal/testdata/no_warning_test-default_value.pb.o `test -f 'google/protobuf/util/internal/testdata/default_value.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/default_value.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-default_value.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-default_value.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/default_value.pb.cc' object='google/protobuf/util/internal/testdata/no_warning_test-default_value.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/no_warning_test-default_value.pb.o `test -f 'google/protobuf/util/internal/testdata/default_value.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/default_value.pb.cc\n\ngoogle/protobuf/util/internal/testdata/no_warning_test-default_value.pb.obj: google/protobuf/util/internal/testdata/default_value.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/no_warning_test-default_value.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-default_value.pb.Tpo -c -o google/protobuf/util/internal/testdata/no_warning_test-default_value.pb.obj `if test -f 'google/protobuf/util/internal/testdata/default_value.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/default_value.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/default_value.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-default_value.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-default_value.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/default_value.pb.cc' object='google/protobuf/util/internal/testdata/no_warning_test-default_value.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/no_warning_test-default_value.pb.obj `if test -f 'google/protobuf/util/internal/testdata/default_value.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/default_value.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/default_value.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/no_warning_test-default_value_test.pb.o: google/protobuf/util/internal/testdata/default_value_test.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/no_warning_test-default_value_test.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-default_value_test.pb.Tpo -c -o google/protobuf/util/internal/testdata/no_warning_test-default_value_test.pb.o `test -f 'google/protobuf/util/internal/testdata/default_value_test.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/default_value_test.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-default_value_test.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-default_value_test.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/default_value_test.pb.cc' object='google/protobuf/util/internal/testdata/no_warning_test-default_value_test.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/no_warning_test-default_value_test.pb.o `test -f 'google/protobuf/util/internal/testdata/default_value_test.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/default_value_test.pb.cc\n\ngoogle/protobuf/util/internal/testdata/no_warning_test-default_value_test.pb.obj: google/protobuf/util/internal/testdata/default_value_test.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/no_warning_test-default_value_test.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-default_value_test.pb.Tpo -c -o google/protobuf/util/internal/testdata/no_warning_test-default_value_test.pb.obj `if test -f 'google/protobuf/util/internal/testdata/default_value_test.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/default_value_test.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/default_value_test.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-default_value_test.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-default_value_test.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/default_value_test.pb.cc' object='google/protobuf/util/internal/testdata/no_warning_test-default_value_test.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/no_warning_test-default_value_test.pb.obj `if test -f 'google/protobuf/util/internal/testdata/default_value_test.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/default_value_test.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/default_value_test.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/no_warning_test-field_mask.pb.o: google/protobuf/util/internal/testdata/field_mask.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/no_warning_test-field_mask.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-field_mask.pb.Tpo -c -o google/protobuf/util/internal/testdata/no_warning_test-field_mask.pb.o `test -f 'google/protobuf/util/internal/testdata/field_mask.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/field_mask.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-field_mask.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-field_mask.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/field_mask.pb.cc' object='google/protobuf/util/internal/testdata/no_warning_test-field_mask.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/no_warning_test-field_mask.pb.o `test -f 'google/protobuf/util/internal/testdata/field_mask.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/field_mask.pb.cc\n\ngoogle/protobuf/util/internal/testdata/no_warning_test-field_mask.pb.obj: google/protobuf/util/internal/testdata/field_mask.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/no_warning_test-field_mask.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-field_mask.pb.Tpo -c -o google/protobuf/util/internal/testdata/no_warning_test-field_mask.pb.obj `if test -f 'google/protobuf/util/internal/testdata/field_mask.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/field_mask.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/field_mask.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-field_mask.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-field_mask.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/field_mask.pb.cc' object='google/protobuf/util/internal/testdata/no_warning_test-field_mask.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/no_warning_test-field_mask.pb.obj `if test -f 'google/protobuf/util/internal/testdata/field_mask.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/field_mask.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/field_mask.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/no_warning_test-maps.pb.o: google/protobuf/util/internal/testdata/maps.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/no_warning_test-maps.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-maps.pb.Tpo -c -o google/protobuf/util/internal/testdata/no_warning_test-maps.pb.o `test -f 'google/protobuf/util/internal/testdata/maps.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/maps.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-maps.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-maps.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/maps.pb.cc' object='google/protobuf/util/internal/testdata/no_warning_test-maps.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/no_warning_test-maps.pb.o `test -f 'google/protobuf/util/internal/testdata/maps.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/maps.pb.cc\n\ngoogle/protobuf/util/internal/testdata/no_warning_test-maps.pb.obj: google/protobuf/util/internal/testdata/maps.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/no_warning_test-maps.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-maps.pb.Tpo -c -o google/protobuf/util/internal/testdata/no_warning_test-maps.pb.obj `if test -f 'google/protobuf/util/internal/testdata/maps.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/maps.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/maps.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-maps.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-maps.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/maps.pb.cc' object='google/protobuf/util/internal/testdata/no_warning_test-maps.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/no_warning_test-maps.pb.obj `if test -f 'google/protobuf/util/internal/testdata/maps.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/maps.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/maps.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/no_warning_test-oneofs.pb.o: google/protobuf/util/internal/testdata/oneofs.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/no_warning_test-oneofs.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-oneofs.pb.Tpo -c -o google/protobuf/util/internal/testdata/no_warning_test-oneofs.pb.o `test -f 'google/protobuf/util/internal/testdata/oneofs.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/oneofs.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-oneofs.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-oneofs.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/oneofs.pb.cc' object='google/protobuf/util/internal/testdata/no_warning_test-oneofs.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/no_warning_test-oneofs.pb.o `test -f 'google/protobuf/util/internal/testdata/oneofs.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/oneofs.pb.cc\n\ngoogle/protobuf/util/internal/testdata/no_warning_test-oneofs.pb.obj: google/protobuf/util/internal/testdata/oneofs.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/no_warning_test-oneofs.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-oneofs.pb.Tpo -c -o google/protobuf/util/internal/testdata/no_warning_test-oneofs.pb.obj `if test -f 'google/protobuf/util/internal/testdata/oneofs.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/oneofs.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/oneofs.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-oneofs.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-oneofs.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/oneofs.pb.cc' object='google/protobuf/util/internal/testdata/no_warning_test-oneofs.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/no_warning_test-oneofs.pb.obj `if test -f 'google/protobuf/util/internal/testdata/oneofs.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/oneofs.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/oneofs.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/no_warning_test-struct.pb.o: google/protobuf/util/internal/testdata/struct.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/no_warning_test-struct.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-struct.pb.Tpo -c -o google/protobuf/util/internal/testdata/no_warning_test-struct.pb.o `test -f 'google/protobuf/util/internal/testdata/struct.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/struct.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-struct.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-struct.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/struct.pb.cc' object='google/protobuf/util/internal/testdata/no_warning_test-struct.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/no_warning_test-struct.pb.o `test -f 'google/protobuf/util/internal/testdata/struct.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/struct.pb.cc\n\ngoogle/protobuf/util/internal/testdata/no_warning_test-struct.pb.obj: google/protobuf/util/internal/testdata/struct.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/no_warning_test-struct.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-struct.pb.Tpo -c -o google/protobuf/util/internal/testdata/no_warning_test-struct.pb.obj `if test -f 'google/protobuf/util/internal/testdata/struct.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/struct.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/struct.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-struct.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-struct.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/struct.pb.cc' object='google/protobuf/util/internal/testdata/no_warning_test-struct.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/no_warning_test-struct.pb.obj `if test -f 'google/protobuf/util/internal/testdata/struct.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/struct.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/struct.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/no_warning_test-timestamp_duration.pb.o: google/protobuf/util/internal/testdata/timestamp_duration.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/no_warning_test-timestamp_duration.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-timestamp_duration.pb.Tpo -c -o google/protobuf/util/internal/testdata/no_warning_test-timestamp_duration.pb.o `test -f 'google/protobuf/util/internal/testdata/timestamp_duration.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/timestamp_duration.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-timestamp_duration.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-timestamp_duration.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/timestamp_duration.pb.cc' object='google/protobuf/util/internal/testdata/no_warning_test-timestamp_duration.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/no_warning_test-timestamp_duration.pb.o `test -f 'google/protobuf/util/internal/testdata/timestamp_duration.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/timestamp_duration.pb.cc\n\ngoogle/protobuf/util/internal/testdata/no_warning_test-timestamp_duration.pb.obj: google/protobuf/util/internal/testdata/timestamp_duration.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/no_warning_test-timestamp_duration.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-timestamp_duration.pb.Tpo -c -o google/protobuf/util/internal/testdata/no_warning_test-timestamp_duration.pb.obj `if test -f 'google/protobuf/util/internal/testdata/timestamp_duration.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/timestamp_duration.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/timestamp_duration.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-timestamp_duration.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/no_warning_test-timestamp_duration.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/timestamp_duration.pb.cc' object='google/protobuf/util/internal/testdata/no_warning_test-timestamp_duration.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/no_warning_test-timestamp_duration.pb.obj `if test -f 'google/protobuf/util/internal/testdata/timestamp_duration.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/timestamp_duration.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/timestamp_duration.pb.cc'; fi`\n\ngoogle/protobuf/util/no_warning_test-json_format_proto3.pb.o: google/protobuf/util/json_format_proto3.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/no_warning_test-json_format_proto3.pb.o -MD -MP -MF google/protobuf/util/$(DEPDIR)/no_warning_test-json_format_proto3.pb.Tpo -c -o google/protobuf/util/no_warning_test-json_format_proto3.pb.o `test -f 'google/protobuf/util/json_format_proto3.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/json_format_proto3.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/no_warning_test-json_format_proto3.pb.Tpo google/protobuf/util/$(DEPDIR)/no_warning_test-json_format_proto3.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/json_format_proto3.pb.cc' object='google/protobuf/util/no_warning_test-json_format_proto3.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/no_warning_test-json_format_proto3.pb.o `test -f 'google/protobuf/util/json_format_proto3.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/json_format_proto3.pb.cc\n\ngoogle/protobuf/util/no_warning_test-json_format_proto3.pb.obj: google/protobuf/util/json_format_proto3.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/no_warning_test-json_format_proto3.pb.obj -MD -MP -MF google/protobuf/util/$(DEPDIR)/no_warning_test-json_format_proto3.pb.Tpo -c -o google/protobuf/util/no_warning_test-json_format_proto3.pb.obj `if test -f 'google/protobuf/util/json_format_proto3.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/json_format_proto3.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/json_format_proto3.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/no_warning_test-json_format_proto3.pb.Tpo google/protobuf/util/$(DEPDIR)/no_warning_test-json_format_proto3.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/json_format_proto3.pb.cc' object='google/protobuf/util/no_warning_test-json_format_proto3.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/no_warning_test-json_format_proto3.pb.obj `if test -f 'google/protobuf/util/json_format_proto3.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/json_format_proto3.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/json_format_proto3.pb.cc'; fi`\n\ngoogle/protobuf/util/no_warning_test-message_differencer_unittest.pb.o: google/protobuf/util/message_differencer_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/no_warning_test-message_differencer_unittest.pb.o -MD -MP -MF google/protobuf/util/$(DEPDIR)/no_warning_test-message_differencer_unittest.pb.Tpo -c -o google/protobuf/util/no_warning_test-message_differencer_unittest.pb.o `test -f 'google/protobuf/util/message_differencer_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/message_differencer_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/no_warning_test-message_differencer_unittest.pb.Tpo google/protobuf/util/$(DEPDIR)/no_warning_test-message_differencer_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/message_differencer_unittest.pb.cc' object='google/protobuf/util/no_warning_test-message_differencer_unittest.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/no_warning_test-message_differencer_unittest.pb.o `test -f 'google/protobuf/util/message_differencer_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/message_differencer_unittest.pb.cc\n\ngoogle/protobuf/util/no_warning_test-message_differencer_unittest.pb.obj: google/protobuf/util/message_differencer_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/no_warning_test-message_differencer_unittest.pb.obj -MD -MP -MF google/protobuf/util/$(DEPDIR)/no_warning_test-message_differencer_unittest.pb.Tpo -c -o google/protobuf/util/no_warning_test-message_differencer_unittest.pb.obj `if test -f 'google/protobuf/util/message_differencer_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/message_differencer_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/message_differencer_unittest.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/no_warning_test-message_differencer_unittest.pb.Tpo google/protobuf/util/$(DEPDIR)/no_warning_test-message_differencer_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/message_differencer_unittest.pb.cc' object='google/protobuf/util/no_warning_test-message_differencer_unittest.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(no_warning_test_CPPFLAGS) $(CPPFLAGS) $(no_warning_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/no_warning_test-message_differencer_unittest.pb.obj `if test -f 'google/protobuf/util/message_differencer_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/message_differencer_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/message_differencer_unittest.pb.cc'; fi`\n\ngoogle/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_unittest.o: google/protobuf/compiler/cpp/cpp_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_unittest.o -MD -MP -MF google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_lazy_descriptor_test-cpp_unittest.Tpo -c -o google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_unittest.o `test -f 'google/protobuf/compiler/cpp/cpp_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/cpp/cpp_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_lazy_descriptor_test-cpp_unittest.Tpo google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_lazy_descriptor_test-cpp_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/cpp/cpp_unittest.cc' object='google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_unittest.o `test -f 'google/protobuf/compiler/cpp/cpp_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/cpp/cpp_unittest.cc\n\ngoogle/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_unittest.obj: google/protobuf/compiler/cpp/cpp_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_unittest.obj -MD -MP -MF google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_lazy_descriptor_test-cpp_unittest.Tpo -c -o google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_unittest.obj `if test -f 'google/protobuf/compiler/cpp/cpp_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/cpp/cpp_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/cpp/cpp_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_lazy_descriptor_test-cpp_unittest.Tpo google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_lazy_descriptor_test-cpp_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/cpp/cpp_unittest.cc' object='google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_unittest.obj `if test -f 'google/protobuf/compiler/cpp/cpp_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/cpp/cpp_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/cpp/cpp_unittest.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-arena_test_util.o: google/protobuf/arena_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-arena_test_util.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-arena_test_util.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-arena_test_util.o `test -f 'google/protobuf/arena_test_util.cc' || echo '$(srcdir)/'`google/protobuf/arena_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-arena_test_util.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-arena_test_util.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/arena_test_util.cc' object='google/protobuf/protobuf_lazy_descriptor_test-arena_test_util.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-arena_test_util.o `test -f 'google/protobuf/arena_test_util.cc' || echo '$(srcdir)/'`google/protobuf/arena_test_util.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-arena_test_util.obj: google/protobuf/arena_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-arena_test_util.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-arena_test_util.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-arena_test_util.obj `if test -f 'google/protobuf/arena_test_util.cc'; then $(CYGPATH_W) 'google/protobuf/arena_test_util.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/arena_test_util.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-arena_test_util.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-arena_test_util.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/arena_test_util.cc' object='google/protobuf/protobuf_lazy_descriptor_test-arena_test_util.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-arena_test_util.obj `if test -f 'google/protobuf/arena_test_util.cc'; then $(CYGPATH_W) 'google/protobuf/arena_test_util.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/arena_test_util.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-map_test_util.o: google/protobuf/map_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-map_test_util.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_test_util.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-map_test_util.o `test -f 'google/protobuf/map_test_util.cc' || echo '$(srcdir)/'`google/protobuf/map_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_test_util.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_test_util.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_test_util.cc' object='google/protobuf/protobuf_lazy_descriptor_test-map_test_util.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-map_test_util.o `test -f 'google/protobuf/map_test_util.cc' || echo '$(srcdir)/'`google/protobuf/map_test_util.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-map_test_util.obj: google/protobuf/map_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-map_test_util.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_test_util.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-map_test_util.obj `if test -f 'google/protobuf/map_test_util.cc'; then $(CYGPATH_W) 'google/protobuf/map_test_util.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_test_util.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_test_util.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_test_util.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_test_util.cc' object='google/protobuf/protobuf_lazy_descriptor_test-map_test_util.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-map_test_util.obj `if test -f 'google/protobuf/map_test_util.cc'; then $(CYGPATH_W) 'google/protobuf/map_test_util.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_test_util.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-test_util.o: google/protobuf/test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-test_util.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-test_util.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-test_util.o `test -f 'google/protobuf/test_util.cc' || echo '$(srcdir)/'`google/protobuf/test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-test_util.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-test_util.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/test_util.cc' object='google/protobuf/protobuf_lazy_descriptor_test-test_util.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-test_util.o `test -f 'google/protobuf/test_util.cc' || echo '$(srcdir)/'`google/protobuf/test_util.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-test_util.obj: google/protobuf/test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-test_util.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-test_util.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-test_util.obj `if test -f 'google/protobuf/test_util.cc'; then $(CYGPATH_W) 'google/protobuf/test_util.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/test_util.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-test_util.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-test_util.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/test_util.cc' object='google/protobuf/protobuf_lazy_descriptor_test-test_util.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-test_util.obj `if test -f 'google/protobuf/test_util.cc'; then $(CYGPATH_W) 'google/protobuf/test_util.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/test_util.cc'; fi`\n\ngoogle/protobuf/testing/protobuf_lazy_descriptor_test-googletest.o: google/protobuf/testing/googletest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/testing/protobuf_lazy_descriptor_test-googletest.o -MD -MP -MF google/protobuf/testing/$(DEPDIR)/protobuf_lazy_descriptor_test-googletest.Tpo -c -o google/protobuf/testing/protobuf_lazy_descriptor_test-googletest.o `test -f 'google/protobuf/testing/googletest.cc' || echo '$(srcdir)/'`google/protobuf/testing/googletest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/testing/$(DEPDIR)/protobuf_lazy_descriptor_test-googletest.Tpo google/protobuf/testing/$(DEPDIR)/protobuf_lazy_descriptor_test-googletest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/testing/googletest.cc' object='google/protobuf/testing/protobuf_lazy_descriptor_test-googletest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/testing/protobuf_lazy_descriptor_test-googletest.o `test -f 'google/protobuf/testing/googletest.cc' || echo '$(srcdir)/'`google/protobuf/testing/googletest.cc\n\ngoogle/protobuf/testing/protobuf_lazy_descriptor_test-googletest.obj: google/protobuf/testing/googletest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/testing/protobuf_lazy_descriptor_test-googletest.obj -MD -MP -MF google/protobuf/testing/$(DEPDIR)/protobuf_lazy_descriptor_test-googletest.Tpo -c -o google/protobuf/testing/protobuf_lazy_descriptor_test-googletest.obj `if test -f 'google/protobuf/testing/googletest.cc'; then $(CYGPATH_W) 'google/protobuf/testing/googletest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/testing/googletest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/testing/$(DEPDIR)/protobuf_lazy_descriptor_test-googletest.Tpo google/protobuf/testing/$(DEPDIR)/protobuf_lazy_descriptor_test-googletest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/testing/googletest.cc' object='google/protobuf/testing/protobuf_lazy_descriptor_test-googletest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/testing/protobuf_lazy_descriptor_test-googletest.obj `if test -f 'google/protobuf/testing/googletest.cc'; then $(CYGPATH_W) 'google/protobuf/testing/googletest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/testing/googletest.cc'; fi`\n\ngoogle/protobuf/testing/protobuf_lazy_descriptor_test-file.o: google/protobuf/testing/file.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/testing/protobuf_lazy_descriptor_test-file.o -MD -MP -MF google/protobuf/testing/$(DEPDIR)/protobuf_lazy_descriptor_test-file.Tpo -c -o google/protobuf/testing/protobuf_lazy_descriptor_test-file.o `test -f 'google/protobuf/testing/file.cc' || echo '$(srcdir)/'`google/protobuf/testing/file.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/testing/$(DEPDIR)/protobuf_lazy_descriptor_test-file.Tpo google/protobuf/testing/$(DEPDIR)/protobuf_lazy_descriptor_test-file.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/testing/file.cc' object='google/protobuf/testing/protobuf_lazy_descriptor_test-file.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/testing/protobuf_lazy_descriptor_test-file.o `test -f 'google/protobuf/testing/file.cc' || echo '$(srcdir)/'`google/protobuf/testing/file.cc\n\ngoogle/protobuf/testing/protobuf_lazy_descriptor_test-file.obj: google/protobuf/testing/file.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/testing/protobuf_lazy_descriptor_test-file.obj -MD -MP -MF google/protobuf/testing/$(DEPDIR)/protobuf_lazy_descriptor_test-file.Tpo -c -o google/protobuf/testing/protobuf_lazy_descriptor_test-file.obj `if test -f 'google/protobuf/testing/file.cc'; then $(CYGPATH_W) 'google/protobuf/testing/file.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/testing/file.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/testing/$(DEPDIR)/protobuf_lazy_descriptor_test-file.Tpo google/protobuf/testing/$(DEPDIR)/protobuf_lazy_descriptor_test-file.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/testing/file.cc' object='google/protobuf/testing/protobuf_lazy_descriptor_test-file.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/testing/protobuf_lazy_descriptor_test-file.obj `if test -f 'google/protobuf/testing/file.cc'; then $(CYGPATH_W) 'google/protobuf/testing/file.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/testing/file.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-map_lite_unittest.pb.o: google/protobuf/map_lite_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-map_lite_unittest.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_lite_unittest.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-map_lite_unittest.pb.o `test -f 'google/protobuf/map_lite_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/map_lite_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_lite_unittest.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_lite_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_lite_unittest.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-map_lite_unittest.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-map_lite_unittest.pb.o `test -f 'google/protobuf/map_lite_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/map_lite_unittest.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-map_lite_unittest.pb.obj: google/protobuf/map_lite_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-map_lite_unittest.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_lite_unittest.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-map_lite_unittest.pb.obj `if test -f 'google/protobuf/map_lite_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/map_lite_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_lite_unittest.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_lite_unittest.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_lite_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_lite_unittest.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-map_lite_unittest.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-map_lite_unittest.pb.obj `if test -f 'google/protobuf/map_lite_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/map_lite_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_lite_unittest.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_lite.pb.o: google/protobuf/unittest_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_lite.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_lite.pb.o `test -f 'google/protobuf/unittest_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_lite.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_lite.pb.o `test -f 'google/protobuf/unittest_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_lite.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_lite.pb.obj: google/protobuf/unittest_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_lite.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_lite.pb.obj `if test -f 'google/protobuf/unittest_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_lite.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_lite.pb.obj `if test -f 'google/protobuf/unittest_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_lite.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_lite.pb.o: google/protobuf/unittest_no_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_arena_lite.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_lite.pb.o `test -f 'google/protobuf/unittest_no_arena_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_arena_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_arena_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_arena_lite.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_lite.pb.o `test -f 'google/protobuf/unittest_no_arena_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_arena_lite.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_lite.pb.obj: google/protobuf/unittest_no_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_arena_lite.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_lite.pb.obj `if test -f 'google/protobuf/unittest_no_arena_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_arena_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_arena_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_arena_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_arena_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_arena_lite.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_lite.pb.obj `if test -f 'google/protobuf/unittest_no_arena_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_arena_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_arena_lite.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_import_lite.pb.o: google/protobuf/unittest_import_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_import_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import_lite.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_import_lite.pb.o `test -f 'google/protobuf/unittest_import_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_lite.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_import_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_import_lite.pb.o `test -f 'google/protobuf/unittest_import_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_lite.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_import_lite.pb.obj: google/protobuf/unittest_import_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_import_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import_lite.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_import_lite.pb.obj `if test -f 'google/protobuf/unittest_import_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_lite.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_import_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_import_lite.pb.obj `if test -f 'google/protobuf/unittest_import_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_lite.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_import_public_lite.pb.o: google/protobuf/unittest_import_public_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_import_public_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import_public_lite.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_import_public_lite.pb.o `test -f 'google/protobuf/unittest_import_public_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_public_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import_public_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import_public_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_public_lite.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_import_public_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_import_public_lite.pb.o `test -f 'google/protobuf/unittest_import_public_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_public_lite.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_import_public_lite.pb.obj: google/protobuf/unittest_import_public_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_import_public_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import_public_lite.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_import_public_lite.pb.obj `if test -f 'google/protobuf/unittest_import_public_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_public_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_public_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import_public_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import_public_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_public_lite.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_import_public_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_import_public_lite.pb.obj `if test -f 'google/protobuf/unittest_import_public_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_public_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_public_lite.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-any_test.pb.o: google/protobuf/any_test.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-any_test.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-any_test.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-any_test.pb.o `test -f 'google/protobuf/any_test.pb.cc' || echo '$(srcdir)/'`google/protobuf/any_test.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-any_test.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-any_test.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/any_test.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-any_test.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-any_test.pb.o `test -f 'google/protobuf/any_test.pb.cc' || echo '$(srcdir)/'`google/protobuf/any_test.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-any_test.pb.obj: google/protobuf/any_test.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-any_test.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-any_test.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-any_test.pb.obj `if test -f 'google/protobuf/any_test.pb.cc'; then $(CYGPATH_W) 'google/protobuf/any_test.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/any_test.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-any_test.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-any_test.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/any_test.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-any_test.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-any_test.pb.obj `if test -f 'google/protobuf/any_test.pb.cc'; then $(CYGPATH_W) 'google/protobuf/any_test.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/any_test.pb.cc'; fi`\n\ngoogle/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_bad_identifiers.pb.o: google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_bad_identifiers.pb.o -MD -MP -MF google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_lazy_descriptor_test-cpp_test_bad_identifiers.pb.Tpo -c -o google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_bad_identifiers.pb.o `test -f 'google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc' || echo '$(srcdir)/'`google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_lazy_descriptor_test-cpp_test_bad_identifiers.pb.Tpo google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_lazy_descriptor_test-cpp_test_bad_identifiers.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc' object='google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_bad_identifiers.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_bad_identifiers.pb.o `test -f 'google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc' || echo '$(srcdir)/'`google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc\n\ngoogle/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_bad_identifiers.pb.obj: google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_bad_identifiers.pb.obj -MD -MP -MF google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_lazy_descriptor_test-cpp_test_bad_identifiers.pb.Tpo -c -o google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_bad_identifiers.pb.obj `if test -f 'google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_lazy_descriptor_test-cpp_test_bad_identifiers.pb.Tpo google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_lazy_descriptor_test-cpp_test_bad_identifiers.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc' object='google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_bad_identifiers.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_bad_identifiers.pb.obj `if test -f 'google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc'; fi`\n\ngoogle/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_large_enum_value.pb.o: google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_large_enum_value.pb.o -MD -MP -MF google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_lazy_descriptor_test-cpp_test_large_enum_value.pb.Tpo -c -o google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_large_enum_value.pb.o `test -f 'google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc' || echo '$(srcdir)/'`google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_lazy_descriptor_test-cpp_test_large_enum_value.pb.Tpo google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_lazy_descriptor_test-cpp_test_large_enum_value.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc' object='google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_large_enum_value.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_large_enum_value.pb.o `test -f 'google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc' || echo '$(srcdir)/'`google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc\n\ngoogle/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_large_enum_value.pb.obj: google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_large_enum_value.pb.obj -MD -MP -MF google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_lazy_descriptor_test-cpp_test_large_enum_value.pb.Tpo -c -o google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_large_enum_value.pb.obj `if test -f 'google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_lazy_descriptor_test-cpp_test_large_enum_value.pb.Tpo google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_lazy_descriptor_test-cpp_test_large_enum_value.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc' object='google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_large_enum_value.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/cpp/protobuf_lazy_descriptor_test-cpp_test_large_enum_value.pb.obj `if test -f 'google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-map_proto2_unittest.pb.o: google/protobuf/map_proto2_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-map_proto2_unittest.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_proto2_unittest.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-map_proto2_unittest.pb.o `test -f 'google/protobuf/map_proto2_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/map_proto2_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_proto2_unittest.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_proto2_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_proto2_unittest.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-map_proto2_unittest.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-map_proto2_unittest.pb.o `test -f 'google/protobuf/map_proto2_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/map_proto2_unittest.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-map_proto2_unittest.pb.obj: google/protobuf/map_proto2_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-map_proto2_unittest.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_proto2_unittest.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-map_proto2_unittest.pb.obj `if test -f 'google/protobuf/map_proto2_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/map_proto2_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_proto2_unittest.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_proto2_unittest.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_proto2_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_proto2_unittest.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-map_proto2_unittest.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-map_proto2_unittest.pb.obj `if test -f 'google/protobuf/map_proto2_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/map_proto2_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_proto2_unittest.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-map_unittest.pb.o: google/protobuf/map_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-map_unittest.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_unittest.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-map_unittest.pb.o `test -f 'google/protobuf/map_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/map_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_unittest.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_unittest.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-map_unittest.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-map_unittest.pb.o `test -f 'google/protobuf/map_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/map_unittest.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-map_unittest.pb.obj: google/protobuf/map_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-map_unittest.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_unittest.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-map_unittest.pb.obj `if test -f 'google/protobuf/map_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/map_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_unittest.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_unittest.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-map_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_unittest.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-map_unittest.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-map_unittest.pb.obj `if test -f 'google/protobuf/map_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/map_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_unittest.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_arena.pb.o: google/protobuf/unittest_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_arena.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_arena.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_arena.pb.o `test -f 'google/protobuf/unittest_arena.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_arena.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_arena.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_arena.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_arena.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_arena.pb.o `test -f 'google/protobuf/unittest_arena.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_arena.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_arena.pb.obj: google/protobuf/unittest_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_arena.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_arena.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_arena.pb.obj `if test -f 'google/protobuf/unittest_arena.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_arena.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_arena.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_arena.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_arena.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_arena.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_arena.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_arena.pb.obj `if test -f 'google/protobuf/unittest_arena.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_arena.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_arena.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_custom_options.pb.o: google/protobuf/unittest_custom_options.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_custom_options.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_custom_options.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_custom_options.pb.o `test -f 'google/protobuf/unittest_custom_options.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_custom_options.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_custom_options.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_custom_options.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_custom_options.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_custom_options.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_custom_options.pb.o `test -f 'google/protobuf/unittest_custom_options.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_custom_options.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_custom_options.pb.obj: google/protobuf/unittest_custom_options.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_custom_options.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_custom_options.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_custom_options.pb.obj `if test -f 'google/protobuf/unittest_custom_options.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_custom_options.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_custom_options.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_custom_options.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_custom_options.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_custom_options.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_custom_options.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_custom_options.pb.obj `if test -f 'google/protobuf/unittest_custom_options.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_custom_options.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_custom_options.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_drop_unknown_fields.pb.o: google/protobuf/unittest_drop_unknown_fields.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_drop_unknown_fields.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_drop_unknown_fields.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_drop_unknown_fields.pb.o `test -f 'google/protobuf/unittest_drop_unknown_fields.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_drop_unknown_fields.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_drop_unknown_fields.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_drop_unknown_fields.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_drop_unknown_fields.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_drop_unknown_fields.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_drop_unknown_fields.pb.o `test -f 'google/protobuf/unittest_drop_unknown_fields.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_drop_unknown_fields.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_drop_unknown_fields.pb.obj: google/protobuf/unittest_drop_unknown_fields.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_drop_unknown_fields.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_drop_unknown_fields.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_drop_unknown_fields.pb.obj `if test -f 'google/protobuf/unittest_drop_unknown_fields.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_drop_unknown_fields.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_drop_unknown_fields.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_drop_unknown_fields.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_drop_unknown_fields.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_drop_unknown_fields.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_drop_unknown_fields.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_drop_unknown_fields.pb.obj `if test -f 'google/protobuf/unittest_drop_unknown_fields.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_drop_unknown_fields.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_drop_unknown_fields.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_embed_optimize_for.pb.o: google/protobuf/unittest_embed_optimize_for.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_embed_optimize_for.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_embed_optimize_for.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_embed_optimize_for.pb.o `test -f 'google/protobuf/unittest_embed_optimize_for.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_embed_optimize_for.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_embed_optimize_for.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_embed_optimize_for.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_embed_optimize_for.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_embed_optimize_for.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_embed_optimize_for.pb.o `test -f 'google/protobuf/unittest_embed_optimize_for.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_embed_optimize_for.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_embed_optimize_for.pb.obj: google/protobuf/unittest_embed_optimize_for.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_embed_optimize_for.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_embed_optimize_for.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_embed_optimize_for.pb.obj `if test -f 'google/protobuf/unittest_embed_optimize_for.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_embed_optimize_for.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_embed_optimize_for.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_embed_optimize_for.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_embed_optimize_for.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_embed_optimize_for.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_embed_optimize_for.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_embed_optimize_for.pb.obj `if test -f 'google/protobuf/unittest_embed_optimize_for.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_embed_optimize_for.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_embed_optimize_for.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_empty.pb.o: google/protobuf/unittest_empty.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_empty.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_empty.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_empty.pb.o `test -f 'google/protobuf/unittest_empty.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_empty.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_empty.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_empty.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_empty.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_empty.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_empty.pb.o `test -f 'google/protobuf/unittest_empty.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_empty.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_empty.pb.obj: google/protobuf/unittest_empty.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_empty.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_empty.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_empty.pb.obj `if test -f 'google/protobuf/unittest_empty.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_empty.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_empty.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_empty.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_empty.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_empty.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_empty.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_empty.pb.obj `if test -f 'google/protobuf/unittest_empty.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_empty.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_empty.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_enormous_descriptor.pb.o: google/protobuf/unittest_enormous_descriptor.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_enormous_descriptor.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_enormous_descriptor.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_enormous_descriptor.pb.o `test -f 'google/protobuf/unittest_enormous_descriptor.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_enormous_descriptor.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_enormous_descriptor.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_enormous_descriptor.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_enormous_descriptor.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_enormous_descriptor.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_enormous_descriptor.pb.o `test -f 'google/protobuf/unittest_enormous_descriptor.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_enormous_descriptor.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_enormous_descriptor.pb.obj: google/protobuf/unittest_enormous_descriptor.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_enormous_descriptor.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_enormous_descriptor.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_enormous_descriptor.pb.obj `if test -f 'google/protobuf/unittest_enormous_descriptor.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_enormous_descriptor.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_enormous_descriptor.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_enormous_descriptor.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_enormous_descriptor.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_enormous_descriptor.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_enormous_descriptor.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_enormous_descriptor.pb.obj `if test -f 'google/protobuf/unittest_enormous_descriptor.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_enormous_descriptor.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_enormous_descriptor.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_import.pb.o: google/protobuf/unittest_import.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_import.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_import.pb.o `test -f 'google/protobuf/unittest_import.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_import.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_import.pb.o `test -f 'google/protobuf/unittest_import.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_import.pb.obj: google/protobuf/unittest_import.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_import.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_import.pb.obj `if test -f 'google/protobuf/unittest_import.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_import.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_import.pb.obj `if test -f 'google/protobuf/unittest_import.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_import_public.pb.o: google/protobuf/unittest_import_public.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_import_public.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import_public.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_import_public.pb.o `test -f 'google/protobuf/unittest_import_public.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_public.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import_public.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import_public.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_public.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_import_public.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_import_public.pb.o `test -f 'google/protobuf/unittest_import_public.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_public.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_import_public.pb.obj: google/protobuf/unittest_import_public.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_import_public.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import_public.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_import_public.pb.obj `if test -f 'google/protobuf/unittest_import_public.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_public.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_public.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import_public.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_import_public.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_public.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_import_public.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_import_public.pb.obj `if test -f 'google/protobuf/unittest_import_public.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_public.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_public.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_lite_imports_nonlite.pb.o: google/protobuf/unittest_lite_imports_nonlite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_lite_imports_nonlite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_lite_imports_nonlite.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_lite_imports_nonlite.pb.o `test -f 'google/protobuf/unittest_lite_imports_nonlite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_lite_imports_nonlite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_lite_imports_nonlite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_lite_imports_nonlite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_lite_imports_nonlite.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_lite_imports_nonlite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_lite_imports_nonlite.pb.o `test -f 'google/protobuf/unittest_lite_imports_nonlite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_lite_imports_nonlite.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_lite_imports_nonlite.pb.obj: google/protobuf/unittest_lite_imports_nonlite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_lite_imports_nonlite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_lite_imports_nonlite.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_lite_imports_nonlite.pb.obj `if test -f 'google/protobuf/unittest_lite_imports_nonlite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_lite_imports_nonlite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_lite_imports_nonlite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_lite_imports_nonlite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_lite_imports_nonlite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_lite_imports_nonlite.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_lite_imports_nonlite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_lite_imports_nonlite.pb.obj `if test -f 'google/protobuf/unittest_lite_imports_nonlite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_lite_imports_nonlite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_lite_imports_nonlite.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_mset.pb.o: google/protobuf/unittest_mset.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_mset.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_mset.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_mset.pb.o `test -f 'google/protobuf/unittest_mset.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_mset.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_mset.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_mset.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_mset.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_mset.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_mset.pb.o `test -f 'google/protobuf/unittest_mset.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_mset.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_mset.pb.obj: google/protobuf/unittest_mset.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_mset.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_mset.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_mset.pb.obj `if test -f 'google/protobuf/unittest_mset.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_mset.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_mset.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_mset.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_mset.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_mset.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_mset.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_mset.pb.obj `if test -f 'google/protobuf/unittest_mset.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_mset.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_mset.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_mset_wire_format.pb.o: google/protobuf/unittest_mset_wire_format.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_mset_wire_format.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_mset_wire_format.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_mset_wire_format.pb.o `test -f 'google/protobuf/unittest_mset_wire_format.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_mset_wire_format.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_mset_wire_format.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_mset_wire_format.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_mset_wire_format.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_mset_wire_format.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_mset_wire_format.pb.o `test -f 'google/protobuf/unittest_mset_wire_format.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_mset_wire_format.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_mset_wire_format.pb.obj: google/protobuf/unittest_mset_wire_format.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_mset_wire_format.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_mset_wire_format.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_mset_wire_format.pb.obj `if test -f 'google/protobuf/unittest_mset_wire_format.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_mset_wire_format.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_mset_wire_format.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_mset_wire_format.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_mset_wire_format.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_mset_wire_format.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_mset_wire_format.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_mset_wire_format.pb.obj `if test -f 'google/protobuf/unittest_mset_wire_format.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_mset_wire_format.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_mset_wire_format.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_import.pb.o: google/protobuf/unittest_no_arena_import.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_import.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_arena_import.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_import.pb.o `test -f 'google/protobuf/unittest_no_arena_import.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_arena_import.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_arena_import.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_arena_import.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_arena_import.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_import.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_import.pb.o `test -f 'google/protobuf/unittest_no_arena_import.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_arena_import.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_import.pb.obj: google/protobuf/unittest_no_arena_import.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_import.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_arena_import.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_import.pb.obj `if test -f 'google/protobuf/unittest_no_arena_import.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_arena_import.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_arena_import.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_arena_import.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_arena_import.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_arena_import.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_import.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena_import.pb.obj `if test -f 'google/protobuf/unittest_no_arena_import.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_arena_import.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_arena_import.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena.pb.o: google/protobuf/unittest_no_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_arena.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena.pb.o `test -f 'google/protobuf/unittest_no_arena.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_arena.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_arena.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_arena.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena.pb.o `test -f 'google/protobuf/unittest_no_arena.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_arena.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena.pb.obj: google/protobuf/unittest_no_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_arena.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena.pb.obj `if test -f 'google/protobuf/unittest_no_arena.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_arena.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_arena.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_arena.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_arena.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_arena.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_no_arena.pb.obj `if test -f 'google/protobuf/unittest_no_arena.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_arena.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_arena.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_no_field_presence.pb.o: google/protobuf/unittest_no_field_presence.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_no_field_presence.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_field_presence.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_no_field_presence.pb.o `test -f 'google/protobuf/unittest_no_field_presence.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_field_presence.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_field_presence.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_field_presence.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_field_presence.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_no_field_presence.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_no_field_presence.pb.o `test -f 'google/protobuf/unittest_no_field_presence.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_field_presence.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_no_field_presence.pb.obj: google/protobuf/unittest_no_field_presence.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_no_field_presence.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_field_presence.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_no_field_presence.pb.obj `if test -f 'google/protobuf/unittest_no_field_presence.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_field_presence.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_field_presence.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_field_presence.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_field_presence.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_field_presence.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_no_field_presence.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_no_field_presence.pb.obj `if test -f 'google/protobuf/unittest_no_field_presence.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_field_presence.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_field_presence.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_no_generic_services.pb.o: google/protobuf/unittest_no_generic_services.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_no_generic_services.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_generic_services.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_no_generic_services.pb.o `test -f 'google/protobuf/unittest_no_generic_services.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_generic_services.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_generic_services.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_generic_services.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_generic_services.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_no_generic_services.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_no_generic_services.pb.o `test -f 'google/protobuf/unittest_no_generic_services.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_generic_services.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_no_generic_services.pb.obj: google/protobuf/unittest_no_generic_services.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_no_generic_services.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_generic_services.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_no_generic_services.pb.obj `if test -f 'google/protobuf/unittest_no_generic_services.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_generic_services.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_generic_services.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_generic_services.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_no_generic_services.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_generic_services.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_no_generic_services.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_no_generic_services.pb.obj `if test -f 'google/protobuf/unittest_no_generic_services.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_generic_services.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_generic_services.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_optimize_for.pb.o: google/protobuf/unittest_optimize_for.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_optimize_for.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_optimize_for.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_optimize_for.pb.o `test -f 'google/protobuf/unittest_optimize_for.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_optimize_for.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_optimize_for.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_optimize_for.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_optimize_for.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_optimize_for.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_optimize_for.pb.o `test -f 'google/protobuf/unittest_optimize_for.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_optimize_for.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_optimize_for.pb.obj: google/protobuf/unittest_optimize_for.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_optimize_for.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_optimize_for.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_optimize_for.pb.obj `if test -f 'google/protobuf/unittest_optimize_for.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_optimize_for.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_optimize_for.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_optimize_for.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_optimize_for.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_optimize_for.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_optimize_for.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_optimize_for.pb.obj `if test -f 'google/protobuf/unittest_optimize_for.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_optimize_for.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_optimize_for.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest.pb.o: google/protobuf/unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest.pb.o `test -f 'google/protobuf/unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest.pb.o `test -f 'google/protobuf/unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest.pb.obj: google/protobuf/unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest.pb.obj `if test -f 'google/protobuf/unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest.pb.obj `if test -f 'google/protobuf/unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum2.pb.o: google/protobuf/unittest_preserve_unknown_enum2.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum2.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum2.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum2.pb.o `test -f 'google/protobuf/unittest_preserve_unknown_enum2.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_preserve_unknown_enum2.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum2.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum2.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_preserve_unknown_enum2.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum2.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum2.pb.o `test -f 'google/protobuf/unittest_preserve_unknown_enum2.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_preserve_unknown_enum2.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum2.pb.obj: google/protobuf/unittest_preserve_unknown_enum2.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum2.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum2.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum2.pb.obj `if test -f 'google/protobuf/unittest_preserve_unknown_enum2.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_preserve_unknown_enum2.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_preserve_unknown_enum2.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum2.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum2.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_preserve_unknown_enum2.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum2.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum2.pb.obj `if test -f 'google/protobuf/unittest_preserve_unknown_enum2.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_preserve_unknown_enum2.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_preserve_unknown_enum2.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum.pb.o: google/protobuf/unittest_preserve_unknown_enum.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum.pb.o `test -f 'google/protobuf/unittest_preserve_unknown_enum.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_preserve_unknown_enum.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_preserve_unknown_enum.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum.pb.o `test -f 'google/protobuf/unittest_preserve_unknown_enum.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_preserve_unknown_enum.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum.pb.obj: google/protobuf/unittest_preserve_unknown_enum.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum.pb.obj `if test -f 'google/protobuf/unittest_preserve_unknown_enum.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_preserve_unknown_enum.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_preserve_unknown_enum.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_preserve_unknown_enum.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_preserve_unknown_enum.pb.obj `if test -f 'google/protobuf/unittest_preserve_unknown_enum.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_preserve_unknown_enum.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_preserve_unknown_enum.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena.pb.o: google/protobuf/unittest_proto3_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_proto3_arena.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena.pb.o `test -f 'google/protobuf/unittest_proto3_arena.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_proto3_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_proto3_arena.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_proto3_arena.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_proto3_arena.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena.pb.o `test -f 'google/protobuf/unittest_proto3_arena.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_proto3_arena.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena.pb.obj: google/protobuf/unittest_proto3_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_proto3_arena.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena.pb.obj `if test -f 'google/protobuf/unittest_proto3_arena.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_proto3_arena.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_proto3_arena.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_proto3_arena.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_proto3_arena.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_proto3_arena.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena.pb.obj `if test -f 'google/protobuf/unittest_proto3_arena.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_proto3_arena.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_proto3_arena.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena_lite.pb.o: google/protobuf/unittest_proto3_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_proto3_arena_lite.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena_lite.pb.o `test -f 'google/protobuf/unittest_proto3_arena_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_proto3_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_proto3_arena_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_proto3_arena_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_proto3_arena_lite.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena_lite.pb.o `test -f 'google/protobuf/unittest_proto3_arena_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_proto3_arena_lite.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena_lite.pb.obj: google/protobuf/unittest_proto3_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_proto3_arena_lite.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena_lite.pb.obj `if test -f 'google/protobuf/unittest_proto3_arena_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_proto3_arena_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_proto3_arena_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_proto3_arena_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_proto3_arena_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_proto3_arena_lite.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_arena_lite.pb.obj `if test -f 'google/protobuf/unittest_proto3_arena_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_proto3_arena_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_proto3_arena_lite.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_lite.pb.o: google/protobuf/unittest_proto3_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_proto3_lite.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_lite.pb.o `test -f 'google/protobuf/unittest_proto3_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_proto3_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_proto3_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_proto3_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_proto3_lite.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_lite.pb.o `test -f 'google/protobuf/unittest_proto3_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_proto3_lite.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_lite.pb.obj: google/protobuf/unittest_proto3_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_proto3_lite.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_lite.pb.obj `if test -f 'google/protobuf/unittest_proto3_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_proto3_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_proto3_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_proto3_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_proto3_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_proto3_lite.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_proto3_lite.pb.obj `if test -f 'google/protobuf/unittest_proto3_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_proto3_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_proto3_lite.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_well_known_types.pb.o: google/protobuf/unittest_well_known_types.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_well_known_types.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_well_known_types.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_well_known_types.pb.o `test -f 'google/protobuf/unittest_well_known_types.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_well_known_types.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_well_known_types.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_well_known_types.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_well_known_types.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_well_known_types.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_well_known_types.pb.o `test -f 'google/protobuf/unittest_well_known_types.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_well_known_types.pb.cc\n\ngoogle/protobuf/protobuf_lazy_descriptor_test-unittest_well_known_types.pb.obj: google/protobuf/unittest_well_known_types.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lazy_descriptor_test-unittest_well_known_types.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_well_known_types.pb.Tpo -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_well_known_types.pb.obj `if test -f 'google/protobuf/unittest_well_known_types.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_well_known_types.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_well_known_types.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_well_known_types.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lazy_descriptor_test-unittest_well_known_types.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_well_known_types.pb.cc' object='google/protobuf/protobuf_lazy_descriptor_test-unittest_well_known_types.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lazy_descriptor_test-unittest_well_known_types.pb.obj `if test -f 'google/protobuf/unittest_well_known_types.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_well_known_types.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_well_known_types.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-anys.pb.o: google/protobuf/util/internal/testdata/anys.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-anys.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-anys.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-anys.pb.o `test -f 'google/protobuf/util/internal/testdata/anys.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/anys.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-anys.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-anys.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/anys.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-anys.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-anys.pb.o `test -f 'google/protobuf/util/internal/testdata/anys.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/anys.pb.cc\n\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-anys.pb.obj: google/protobuf/util/internal/testdata/anys.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-anys.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-anys.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-anys.pb.obj `if test -f 'google/protobuf/util/internal/testdata/anys.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/anys.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/anys.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-anys.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-anys.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/anys.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-anys.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-anys.pb.obj `if test -f 'google/protobuf/util/internal/testdata/anys.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/anys.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/anys.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-books.pb.o: google/protobuf/util/internal/testdata/books.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-books.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-books.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-books.pb.o `test -f 'google/protobuf/util/internal/testdata/books.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/books.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-books.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-books.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/books.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-books.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-books.pb.o `test -f 'google/protobuf/util/internal/testdata/books.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/books.pb.cc\n\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-books.pb.obj: google/protobuf/util/internal/testdata/books.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-books.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-books.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-books.pb.obj `if test -f 'google/protobuf/util/internal/testdata/books.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/books.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/books.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-books.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-books.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/books.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-books.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-books.pb.obj `if test -f 'google/protobuf/util/internal/testdata/books.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/books.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/books.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value.pb.o: google/protobuf/util/internal/testdata/default_value.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-default_value.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value.pb.o `test -f 'google/protobuf/util/internal/testdata/default_value.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/default_value.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-default_value.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-default_value.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/default_value.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value.pb.o `test -f 'google/protobuf/util/internal/testdata/default_value.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/default_value.pb.cc\n\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value.pb.obj: google/protobuf/util/internal/testdata/default_value.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-default_value.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value.pb.obj `if test -f 'google/protobuf/util/internal/testdata/default_value.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/default_value.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/default_value.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-default_value.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-default_value.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/default_value.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value.pb.obj `if test -f 'google/protobuf/util/internal/testdata/default_value.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/default_value.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/default_value.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value_test.pb.o: google/protobuf/util/internal/testdata/default_value_test.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value_test.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-default_value_test.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value_test.pb.o `test -f 'google/protobuf/util/internal/testdata/default_value_test.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/default_value_test.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-default_value_test.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-default_value_test.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/default_value_test.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value_test.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value_test.pb.o `test -f 'google/protobuf/util/internal/testdata/default_value_test.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/default_value_test.pb.cc\n\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value_test.pb.obj: google/protobuf/util/internal/testdata/default_value_test.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value_test.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-default_value_test.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value_test.pb.obj `if test -f 'google/protobuf/util/internal/testdata/default_value_test.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/default_value_test.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/default_value_test.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-default_value_test.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-default_value_test.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/default_value_test.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value_test.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-default_value_test.pb.obj `if test -f 'google/protobuf/util/internal/testdata/default_value_test.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/default_value_test.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/default_value_test.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-field_mask.pb.o: google/protobuf/util/internal/testdata/field_mask.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-field_mask.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-field_mask.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-field_mask.pb.o `test -f 'google/protobuf/util/internal/testdata/field_mask.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/field_mask.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-field_mask.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-field_mask.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/field_mask.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-field_mask.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-field_mask.pb.o `test -f 'google/protobuf/util/internal/testdata/field_mask.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/field_mask.pb.cc\n\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-field_mask.pb.obj: google/protobuf/util/internal/testdata/field_mask.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-field_mask.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-field_mask.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-field_mask.pb.obj `if test -f 'google/protobuf/util/internal/testdata/field_mask.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/field_mask.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/field_mask.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-field_mask.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-field_mask.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/field_mask.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-field_mask.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-field_mask.pb.obj `if test -f 'google/protobuf/util/internal/testdata/field_mask.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/field_mask.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/field_mask.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-maps.pb.o: google/protobuf/util/internal/testdata/maps.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-maps.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-maps.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-maps.pb.o `test -f 'google/protobuf/util/internal/testdata/maps.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/maps.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-maps.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-maps.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/maps.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-maps.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-maps.pb.o `test -f 'google/protobuf/util/internal/testdata/maps.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/maps.pb.cc\n\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-maps.pb.obj: google/protobuf/util/internal/testdata/maps.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-maps.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-maps.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-maps.pb.obj `if test -f 'google/protobuf/util/internal/testdata/maps.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/maps.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/maps.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-maps.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-maps.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/maps.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-maps.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-maps.pb.obj `if test -f 'google/protobuf/util/internal/testdata/maps.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/maps.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/maps.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-oneofs.pb.o: google/protobuf/util/internal/testdata/oneofs.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-oneofs.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-oneofs.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-oneofs.pb.o `test -f 'google/protobuf/util/internal/testdata/oneofs.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/oneofs.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-oneofs.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-oneofs.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/oneofs.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-oneofs.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-oneofs.pb.o `test -f 'google/protobuf/util/internal/testdata/oneofs.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/oneofs.pb.cc\n\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-oneofs.pb.obj: google/protobuf/util/internal/testdata/oneofs.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-oneofs.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-oneofs.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-oneofs.pb.obj `if test -f 'google/protobuf/util/internal/testdata/oneofs.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/oneofs.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/oneofs.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-oneofs.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-oneofs.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/oneofs.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-oneofs.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-oneofs.pb.obj `if test -f 'google/protobuf/util/internal/testdata/oneofs.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/oneofs.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/oneofs.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-struct.pb.o: google/protobuf/util/internal/testdata/struct.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-struct.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-struct.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-struct.pb.o `test -f 'google/protobuf/util/internal/testdata/struct.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/struct.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-struct.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-struct.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/struct.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-struct.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-struct.pb.o `test -f 'google/protobuf/util/internal/testdata/struct.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/struct.pb.cc\n\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-struct.pb.obj: google/protobuf/util/internal/testdata/struct.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-struct.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-struct.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-struct.pb.obj `if test -f 'google/protobuf/util/internal/testdata/struct.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/struct.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/struct.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-struct.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-struct.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/struct.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-struct.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-struct.pb.obj `if test -f 'google/protobuf/util/internal/testdata/struct.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/struct.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/struct.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-timestamp_duration.pb.o: google/protobuf/util/internal/testdata/timestamp_duration.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-timestamp_duration.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-timestamp_duration.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-timestamp_duration.pb.o `test -f 'google/protobuf/util/internal/testdata/timestamp_duration.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/timestamp_duration.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-timestamp_duration.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-timestamp_duration.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/timestamp_duration.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-timestamp_duration.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-timestamp_duration.pb.o `test -f 'google/protobuf/util/internal/testdata/timestamp_duration.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/timestamp_duration.pb.cc\n\ngoogle/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-timestamp_duration.pb.obj: google/protobuf/util/internal/testdata/timestamp_duration.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-timestamp_duration.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-timestamp_duration.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-timestamp_duration.pb.obj `if test -f 'google/protobuf/util/internal/testdata/timestamp_duration.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/timestamp_duration.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/timestamp_duration.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-timestamp_duration.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_lazy_descriptor_test-timestamp_duration.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/timestamp_duration.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-timestamp_duration.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_lazy_descriptor_test-timestamp_duration.pb.obj `if test -f 'google/protobuf/util/internal/testdata/timestamp_duration.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/timestamp_duration.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/timestamp_duration.pb.cc'; fi`\n\ngoogle/protobuf/util/protobuf_lazy_descriptor_test-json_format_proto3.pb.o: google/protobuf/util/json_format_proto3.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/protobuf_lazy_descriptor_test-json_format_proto3.pb.o -MD -MP -MF google/protobuf/util/$(DEPDIR)/protobuf_lazy_descriptor_test-json_format_proto3.pb.Tpo -c -o google/protobuf/util/protobuf_lazy_descriptor_test-json_format_proto3.pb.o `test -f 'google/protobuf/util/json_format_proto3.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/json_format_proto3.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/protobuf_lazy_descriptor_test-json_format_proto3.pb.Tpo google/protobuf/util/$(DEPDIR)/protobuf_lazy_descriptor_test-json_format_proto3.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/json_format_proto3.pb.cc' object='google/protobuf/util/protobuf_lazy_descriptor_test-json_format_proto3.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/protobuf_lazy_descriptor_test-json_format_proto3.pb.o `test -f 'google/protobuf/util/json_format_proto3.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/json_format_proto3.pb.cc\n\ngoogle/protobuf/util/protobuf_lazy_descriptor_test-json_format_proto3.pb.obj: google/protobuf/util/json_format_proto3.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/protobuf_lazy_descriptor_test-json_format_proto3.pb.obj -MD -MP -MF google/protobuf/util/$(DEPDIR)/protobuf_lazy_descriptor_test-json_format_proto3.pb.Tpo -c -o google/protobuf/util/protobuf_lazy_descriptor_test-json_format_proto3.pb.obj `if test -f 'google/protobuf/util/json_format_proto3.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/json_format_proto3.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/json_format_proto3.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/protobuf_lazy_descriptor_test-json_format_proto3.pb.Tpo google/protobuf/util/$(DEPDIR)/protobuf_lazy_descriptor_test-json_format_proto3.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/json_format_proto3.pb.cc' object='google/protobuf/util/protobuf_lazy_descriptor_test-json_format_proto3.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/protobuf_lazy_descriptor_test-json_format_proto3.pb.obj `if test -f 'google/protobuf/util/json_format_proto3.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/json_format_proto3.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/json_format_proto3.pb.cc'; fi`\n\ngoogle/protobuf/util/protobuf_lazy_descriptor_test-message_differencer_unittest.pb.o: google/protobuf/util/message_differencer_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/protobuf_lazy_descriptor_test-message_differencer_unittest.pb.o -MD -MP -MF google/protobuf/util/$(DEPDIR)/protobuf_lazy_descriptor_test-message_differencer_unittest.pb.Tpo -c -o google/protobuf/util/protobuf_lazy_descriptor_test-message_differencer_unittest.pb.o `test -f 'google/protobuf/util/message_differencer_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/message_differencer_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/protobuf_lazy_descriptor_test-message_differencer_unittest.pb.Tpo google/protobuf/util/$(DEPDIR)/protobuf_lazy_descriptor_test-message_differencer_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/message_differencer_unittest.pb.cc' object='google/protobuf/util/protobuf_lazy_descriptor_test-message_differencer_unittest.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/protobuf_lazy_descriptor_test-message_differencer_unittest.pb.o `test -f 'google/protobuf/util/message_differencer_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/message_differencer_unittest.pb.cc\n\ngoogle/protobuf/util/protobuf_lazy_descriptor_test-message_differencer_unittest.pb.obj: google/protobuf/util/message_differencer_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/protobuf_lazy_descriptor_test-message_differencer_unittest.pb.obj -MD -MP -MF google/protobuf/util/$(DEPDIR)/protobuf_lazy_descriptor_test-message_differencer_unittest.pb.Tpo -c -o google/protobuf/util/protobuf_lazy_descriptor_test-message_differencer_unittest.pb.obj `if test -f 'google/protobuf/util/message_differencer_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/message_differencer_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/message_differencer_unittest.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/protobuf_lazy_descriptor_test-message_differencer_unittest.pb.Tpo google/protobuf/util/$(DEPDIR)/protobuf_lazy_descriptor_test-message_differencer_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/message_differencer_unittest.pb.cc' object='google/protobuf/util/protobuf_lazy_descriptor_test-message_differencer_unittest.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lazy_descriptor_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lazy_descriptor_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/protobuf_lazy_descriptor_test-message_differencer_unittest.pb.obj `if test -f 'google/protobuf/util/message_differencer_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/message_differencer_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/message_differencer_unittest.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lite_arena_test-lite_arena_unittest.o: google/protobuf/lite_arena_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_arena_test-lite_arena_unittest.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-lite_arena_unittest.Tpo -c -o google/protobuf/protobuf_lite_arena_test-lite_arena_unittest.o `test -f 'google/protobuf/lite_arena_unittest.cc' || echo '$(srcdir)/'`google/protobuf/lite_arena_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-lite_arena_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-lite_arena_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/lite_arena_unittest.cc' object='google/protobuf/protobuf_lite_arena_test-lite_arena_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_arena_test-lite_arena_unittest.o `test -f 'google/protobuf/lite_arena_unittest.cc' || echo '$(srcdir)/'`google/protobuf/lite_arena_unittest.cc\n\ngoogle/protobuf/protobuf_lite_arena_test-lite_arena_unittest.obj: google/protobuf/lite_arena_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_arena_test-lite_arena_unittest.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-lite_arena_unittest.Tpo -c -o google/protobuf/protobuf_lite_arena_test-lite_arena_unittest.obj `if test -f 'google/protobuf/lite_arena_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/lite_arena_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/lite_arena_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-lite_arena_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-lite_arena_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/lite_arena_unittest.cc' object='google/protobuf/protobuf_lite_arena_test-lite_arena_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_arena_test-lite_arena_unittest.obj `if test -f 'google/protobuf/lite_arena_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/lite_arena_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/lite_arena_unittest.cc'; fi`\n\ngoogle/protobuf/protobuf_lite_arena_test-arena_test_util.o: google/protobuf/arena_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_arena_test-arena_test_util.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-arena_test_util.Tpo -c -o google/protobuf/protobuf_lite_arena_test-arena_test_util.o `test -f 'google/protobuf/arena_test_util.cc' || echo '$(srcdir)/'`google/protobuf/arena_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-arena_test_util.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-arena_test_util.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/arena_test_util.cc' object='google/protobuf/protobuf_lite_arena_test-arena_test_util.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_arena_test-arena_test_util.o `test -f 'google/protobuf/arena_test_util.cc' || echo '$(srcdir)/'`google/protobuf/arena_test_util.cc\n\ngoogle/protobuf/protobuf_lite_arena_test-arena_test_util.obj: google/protobuf/arena_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_arena_test-arena_test_util.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-arena_test_util.Tpo -c -o google/protobuf/protobuf_lite_arena_test-arena_test_util.obj `if test -f 'google/protobuf/arena_test_util.cc'; then $(CYGPATH_W) 'google/protobuf/arena_test_util.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/arena_test_util.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-arena_test_util.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-arena_test_util.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/arena_test_util.cc' object='google/protobuf/protobuf_lite_arena_test-arena_test_util.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_arena_test-arena_test_util.obj `if test -f 'google/protobuf/arena_test_util.cc'; then $(CYGPATH_W) 'google/protobuf/arena_test_util.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/arena_test_util.cc'; fi`\n\ngoogle/protobuf/protobuf_lite_arena_test-map_lite_test_util.o: google/protobuf/map_lite_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_arena_test-map_lite_test_util.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-map_lite_test_util.Tpo -c -o google/protobuf/protobuf_lite_arena_test-map_lite_test_util.o `test -f 'google/protobuf/map_lite_test_util.cc' || echo '$(srcdir)/'`google/protobuf/map_lite_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-map_lite_test_util.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-map_lite_test_util.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_lite_test_util.cc' object='google/protobuf/protobuf_lite_arena_test-map_lite_test_util.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_arena_test-map_lite_test_util.o `test -f 'google/protobuf/map_lite_test_util.cc' || echo '$(srcdir)/'`google/protobuf/map_lite_test_util.cc\n\ngoogle/protobuf/protobuf_lite_arena_test-map_lite_test_util.obj: google/protobuf/map_lite_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_arena_test-map_lite_test_util.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-map_lite_test_util.Tpo -c -o google/protobuf/protobuf_lite_arena_test-map_lite_test_util.obj `if test -f 'google/protobuf/map_lite_test_util.cc'; then $(CYGPATH_W) 'google/protobuf/map_lite_test_util.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_lite_test_util.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-map_lite_test_util.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-map_lite_test_util.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_lite_test_util.cc' object='google/protobuf/protobuf_lite_arena_test-map_lite_test_util.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_arena_test-map_lite_test_util.obj `if test -f 'google/protobuf/map_lite_test_util.cc'; then $(CYGPATH_W) 'google/protobuf/map_lite_test_util.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_lite_test_util.cc'; fi`\n\ngoogle/protobuf/protobuf_lite_arena_test-test_util_lite.o: google/protobuf/test_util_lite.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_arena_test-test_util_lite.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-test_util_lite.Tpo -c -o google/protobuf/protobuf_lite_arena_test-test_util_lite.o `test -f 'google/protobuf/test_util_lite.cc' || echo '$(srcdir)/'`google/protobuf/test_util_lite.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-test_util_lite.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-test_util_lite.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/test_util_lite.cc' object='google/protobuf/protobuf_lite_arena_test-test_util_lite.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_arena_test-test_util_lite.o `test -f 'google/protobuf/test_util_lite.cc' || echo '$(srcdir)/'`google/protobuf/test_util_lite.cc\n\ngoogle/protobuf/protobuf_lite_arena_test-test_util_lite.obj: google/protobuf/test_util_lite.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_arena_test-test_util_lite.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-test_util_lite.Tpo -c -o google/protobuf/protobuf_lite_arena_test-test_util_lite.obj `if test -f 'google/protobuf/test_util_lite.cc'; then $(CYGPATH_W) 'google/protobuf/test_util_lite.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/test_util_lite.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-test_util_lite.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-test_util_lite.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/test_util_lite.cc' object='google/protobuf/protobuf_lite_arena_test-test_util_lite.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_arena_test-test_util_lite.obj `if test -f 'google/protobuf/test_util_lite.cc'; then $(CYGPATH_W) 'google/protobuf/test_util_lite.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/test_util_lite.cc'; fi`\n\ngoogle/protobuf/protobuf_lite_arena_test-map_lite_unittest.pb.o: google/protobuf/map_lite_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_arena_test-map_lite_unittest.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-map_lite_unittest.pb.Tpo -c -o google/protobuf/protobuf_lite_arena_test-map_lite_unittest.pb.o `test -f 'google/protobuf/map_lite_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/map_lite_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-map_lite_unittest.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-map_lite_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_lite_unittest.pb.cc' object='google/protobuf/protobuf_lite_arena_test-map_lite_unittest.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_arena_test-map_lite_unittest.pb.o `test -f 'google/protobuf/map_lite_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/map_lite_unittest.pb.cc\n\ngoogle/protobuf/protobuf_lite_arena_test-map_lite_unittest.pb.obj: google/protobuf/map_lite_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_arena_test-map_lite_unittest.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-map_lite_unittest.pb.Tpo -c -o google/protobuf/protobuf_lite_arena_test-map_lite_unittest.pb.obj `if test -f 'google/protobuf/map_lite_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/map_lite_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_lite_unittest.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-map_lite_unittest.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-map_lite_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_lite_unittest.pb.cc' object='google/protobuf/protobuf_lite_arena_test-map_lite_unittest.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_arena_test-map_lite_unittest.pb.obj `if test -f 'google/protobuf/map_lite_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/map_lite_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_lite_unittest.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lite_arena_test-unittest_lite.pb.o: google/protobuf/unittest_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_arena_test-unittest_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_lite.pb.Tpo -c -o google/protobuf/protobuf_lite_arena_test-unittest_lite.pb.o `test -f 'google/protobuf/unittest_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_lite.pb.cc' object='google/protobuf/protobuf_lite_arena_test-unittest_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_arena_test-unittest_lite.pb.o `test -f 'google/protobuf/unittest_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_lite.pb.cc\n\ngoogle/protobuf/protobuf_lite_arena_test-unittest_lite.pb.obj: google/protobuf/unittest_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_arena_test-unittest_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_lite.pb.Tpo -c -o google/protobuf/protobuf_lite_arena_test-unittest_lite.pb.obj `if test -f 'google/protobuf/unittest_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_lite.pb.cc' object='google/protobuf/protobuf_lite_arena_test-unittest_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_arena_test-unittest_lite.pb.obj `if test -f 'google/protobuf/unittest_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_lite.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lite_arena_test-unittest_no_arena_lite.pb.o: google/protobuf/unittest_no_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_arena_test-unittest_no_arena_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_no_arena_lite.pb.Tpo -c -o google/protobuf/protobuf_lite_arena_test-unittest_no_arena_lite.pb.o `test -f 'google/protobuf/unittest_no_arena_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_no_arena_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_no_arena_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_arena_lite.pb.cc' object='google/protobuf/protobuf_lite_arena_test-unittest_no_arena_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_arena_test-unittest_no_arena_lite.pb.o `test -f 'google/protobuf/unittest_no_arena_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_arena_lite.pb.cc\n\ngoogle/protobuf/protobuf_lite_arena_test-unittest_no_arena_lite.pb.obj: google/protobuf/unittest_no_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_arena_test-unittest_no_arena_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_no_arena_lite.pb.Tpo -c -o google/protobuf/protobuf_lite_arena_test-unittest_no_arena_lite.pb.obj `if test -f 'google/protobuf/unittest_no_arena_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_arena_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_arena_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_no_arena_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_no_arena_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_arena_lite.pb.cc' object='google/protobuf/protobuf_lite_arena_test-unittest_no_arena_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_arena_test-unittest_no_arena_lite.pb.obj `if test -f 'google/protobuf/unittest_no_arena_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_arena_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_arena_lite.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lite_arena_test-unittest_import_lite.pb.o: google/protobuf/unittest_import_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_arena_test-unittest_import_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_import_lite.pb.Tpo -c -o google/protobuf/protobuf_lite_arena_test-unittest_import_lite.pb.o `test -f 'google/protobuf/unittest_import_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_import_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_import_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_lite.pb.cc' object='google/protobuf/protobuf_lite_arena_test-unittest_import_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_arena_test-unittest_import_lite.pb.o `test -f 'google/protobuf/unittest_import_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_lite.pb.cc\n\ngoogle/protobuf/protobuf_lite_arena_test-unittest_import_lite.pb.obj: google/protobuf/unittest_import_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_arena_test-unittest_import_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_import_lite.pb.Tpo -c -o google/protobuf/protobuf_lite_arena_test-unittest_import_lite.pb.obj `if test -f 'google/protobuf/unittest_import_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_import_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_import_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_lite.pb.cc' object='google/protobuf/protobuf_lite_arena_test-unittest_import_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_arena_test-unittest_import_lite.pb.obj `if test -f 'google/protobuf/unittest_import_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_lite.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lite_arena_test-unittest_import_public_lite.pb.o: google/protobuf/unittest_import_public_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_arena_test-unittest_import_public_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_import_public_lite.pb.Tpo -c -o google/protobuf/protobuf_lite_arena_test-unittest_import_public_lite.pb.o `test -f 'google/protobuf/unittest_import_public_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_public_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_import_public_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_import_public_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_public_lite.pb.cc' object='google/protobuf/protobuf_lite_arena_test-unittest_import_public_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_arena_test-unittest_import_public_lite.pb.o `test -f 'google/protobuf/unittest_import_public_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_public_lite.pb.cc\n\ngoogle/protobuf/protobuf_lite_arena_test-unittest_import_public_lite.pb.obj: google/protobuf/unittest_import_public_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_arena_test-unittest_import_public_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_import_public_lite.pb.Tpo -c -o google/protobuf/protobuf_lite_arena_test-unittest_import_public_lite.pb.obj `if test -f 'google/protobuf/unittest_import_public_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_public_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_public_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_import_public_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_arena_test-unittest_import_public_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_public_lite.pb.cc' object='google/protobuf/protobuf_lite_arena_test-unittest_import_public_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_lite_arena_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_arena_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_arena_test-unittest_import_public_lite.pb.obj `if test -f 'google/protobuf/unittest_import_public_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_public_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_public_lite.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lite_test-lite_unittest.o: google/protobuf/lite_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_test-lite_unittest.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_test-lite_unittest.Tpo -c -o google/protobuf/protobuf_lite_test-lite_unittest.o `test -f 'google/protobuf/lite_unittest.cc' || echo '$(srcdir)/'`google/protobuf/lite_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_test-lite_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_test-lite_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/lite_unittest.cc' object='google/protobuf/protobuf_lite_test-lite_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_test-lite_unittest.o `test -f 'google/protobuf/lite_unittest.cc' || echo '$(srcdir)/'`google/protobuf/lite_unittest.cc\n\ngoogle/protobuf/protobuf_lite_test-lite_unittest.obj: google/protobuf/lite_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_test-lite_unittest.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_test-lite_unittest.Tpo -c -o google/protobuf/protobuf_lite_test-lite_unittest.obj `if test -f 'google/protobuf/lite_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/lite_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/lite_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_test-lite_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_test-lite_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/lite_unittest.cc' object='google/protobuf/protobuf_lite_test-lite_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_test-lite_unittest.obj `if test -f 'google/protobuf/lite_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/lite_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/lite_unittest.cc'; fi`\n\ngoogle/protobuf/protobuf_lite_test-arena_test_util.o: google/protobuf/arena_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_test-arena_test_util.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_test-arena_test_util.Tpo -c -o google/protobuf/protobuf_lite_test-arena_test_util.o `test -f 'google/protobuf/arena_test_util.cc' || echo '$(srcdir)/'`google/protobuf/arena_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_test-arena_test_util.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_test-arena_test_util.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/arena_test_util.cc' object='google/protobuf/protobuf_lite_test-arena_test_util.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_test-arena_test_util.o `test -f 'google/protobuf/arena_test_util.cc' || echo '$(srcdir)/'`google/protobuf/arena_test_util.cc\n\ngoogle/protobuf/protobuf_lite_test-arena_test_util.obj: google/protobuf/arena_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_test-arena_test_util.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_test-arena_test_util.Tpo -c -o google/protobuf/protobuf_lite_test-arena_test_util.obj `if test -f 'google/protobuf/arena_test_util.cc'; then $(CYGPATH_W) 'google/protobuf/arena_test_util.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/arena_test_util.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_test-arena_test_util.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_test-arena_test_util.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/arena_test_util.cc' object='google/protobuf/protobuf_lite_test-arena_test_util.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_test-arena_test_util.obj `if test -f 'google/protobuf/arena_test_util.cc'; then $(CYGPATH_W) 'google/protobuf/arena_test_util.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/arena_test_util.cc'; fi`\n\ngoogle/protobuf/protobuf_lite_test-map_lite_test_util.o: google/protobuf/map_lite_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_test-map_lite_test_util.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_test-map_lite_test_util.Tpo -c -o google/protobuf/protobuf_lite_test-map_lite_test_util.o `test -f 'google/protobuf/map_lite_test_util.cc' || echo '$(srcdir)/'`google/protobuf/map_lite_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_test-map_lite_test_util.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_test-map_lite_test_util.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_lite_test_util.cc' object='google/protobuf/protobuf_lite_test-map_lite_test_util.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_test-map_lite_test_util.o `test -f 'google/protobuf/map_lite_test_util.cc' || echo '$(srcdir)/'`google/protobuf/map_lite_test_util.cc\n\ngoogle/protobuf/protobuf_lite_test-map_lite_test_util.obj: google/protobuf/map_lite_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_test-map_lite_test_util.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_test-map_lite_test_util.Tpo -c -o google/protobuf/protobuf_lite_test-map_lite_test_util.obj `if test -f 'google/protobuf/map_lite_test_util.cc'; then $(CYGPATH_W) 'google/protobuf/map_lite_test_util.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_lite_test_util.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_test-map_lite_test_util.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_test-map_lite_test_util.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_lite_test_util.cc' object='google/protobuf/protobuf_lite_test-map_lite_test_util.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_test-map_lite_test_util.obj `if test -f 'google/protobuf/map_lite_test_util.cc'; then $(CYGPATH_W) 'google/protobuf/map_lite_test_util.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_lite_test_util.cc'; fi`\n\ngoogle/protobuf/protobuf_lite_test-test_util_lite.o: google/protobuf/test_util_lite.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_test-test_util_lite.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_test-test_util_lite.Tpo -c -o google/protobuf/protobuf_lite_test-test_util_lite.o `test -f 'google/protobuf/test_util_lite.cc' || echo '$(srcdir)/'`google/protobuf/test_util_lite.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_test-test_util_lite.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_test-test_util_lite.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/test_util_lite.cc' object='google/protobuf/protobuf_lite_test-test_util_lite.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_test-test_util_lite.o `test -f 'google/protobuf/test_util_lite.cc' || echo '$(srcdir)/'`google/protobuf/test_util_lite.cc\n\ngoogle/protobuf/protobuf_lite_test-test_util_lite.obj: google/protobuf/test_util_lite.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_test-test_util_lite.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_test-test_util_lite.Tpo -c -o google/protobuf/protobuf_lite_test-test_util_lite.obj `if test -f 'google/protobuf/test_util_lite.cc'; then $(CYGPATH_W) 'google/protobuf/test_util_lite.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/test_util_lite.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_test-test_util_lite.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_test-test_util_lite.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/test_util_lite.cc' object='google/protobuf/protobuf_lite_test-test_util_lite.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_test-test_util_lite.obj `if test -f 'google/protobuf/test_util_lite.cc'; then $(CYGPATH_W) 'google/protobuf/test_util_lite.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/test_util_lite.cc'; fi`\n\ngoogle/protobuf/protobuf_lite_test-map_lite_unittest.pb.o: google/protobuf/map_lite_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_test-map_lite_unittest.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_test-map_lite_unittest.pb.Tpo -c -o google/protobuf/protobuf_lite_test-map_lite_unittest.pb.o `test -f 'google/protobuf/map_lite_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/map_lite_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_test-map_lite_unittest.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_test-map_lite_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_lite_unittest.pb.cc' object='google/protobuf/protobuf_lite_test-map_lite_unittest.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_test-map_lite_unittest.pb.o `test -f 'google/protobuf/map_lite_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/map_lite_unittest.pb.cc\n\ngoogle/protobuf/protobuf_lite_test-map_lite_unittest.pb.obj: google/protobuf/map_lite_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_test-map_lite_unittest.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_test-map_lite_unittest.pb.Tpo -c -o google/protobuf/protobuf_lite_test-map_lite_unittest.pb.obj `if test -f 'google/protobuf/map_lite_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/map_lite_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_lite_unittest.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_test-map_lite_unittest.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_test-map_lite_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_lite_unittest.pb.cc' object='google/protobuf/protobuf_lite_test-map_lite_unittest.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_test-map_lite_unittest.pb.obj `if test -f 'google/protobuf/map_lite_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/map_lite_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_lite_unittest.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lite_test-unittest_lite.pb.o: google/protobuf/unittest_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_test-unittest_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_lite.pb.Tpo -c -o google/protobuf/protobuf_lite_test-unittest_lite.pb.o `test -f 'google/protobuf/unittest_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_lite.pb.cc' object='google/protobuf/protobuf_lite_test-unittest_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_test-unittest_lite.pb.o `test -f 'google/protobuf/unittest_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_lite.pb.cc\n\ngoogle/protobuf/protobuf_lite_test-unittest_lite.pb.obj: google/protobuf/unittest_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_test-unittest_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_lite.pb.Tpo -c -o google/protobuf/protobuf_lite_test-unittest_lite.pb.obj `if test -f 'google/protobuf/unittest_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_lite.pb.cc' object='google/protobuf/protobuf_lite_test-unittest_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_test-unittest_lite.pb.obj `if test -f 'google/protobuf/unittest_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_lite.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lite_test-unittest_no_arena_lite.pb.o: google/protobuf/unittest_no_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_test-unittest_no_arena_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_no_arena_lite.pb.Tpo -c -o google/protobuf/protobuf_lite_test-unittest_no_arena_lite.pb.o `test -f 'google/protobuf/unittest_no_arena_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_no_arena_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_no_arena_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_arena_lite.pb.cc' object='google/protobuf/protobuf_lite_test-unittest_no_arena_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_test-unittest_no_arena_lite.pb.o `test -f 'google/protobuf/unittest_no_arena_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_arena_lite.pb.cc\n\ngoogle/protobuf/protobuf_lite_test-unittest_no_arena_lite.pb.obj: google/protobuf/unittest_no_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_test-unittest_no_arena_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_no_arena_lite.pb.Tpo -c -o google/protobuf/protobuf_lite_test-unittest_no_arena_lite.pb.obj `if test -f 'google/protobuf/unittest_no_arena_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_arena_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_arena_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_no_arena_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_no_arena_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_arena_lite.pb.cc' object='google/protobuf/protobuf_lite_test-unittest_no_arena_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_test-unittest_no_arena_lite.pb.obj `if test -f 'google/protobuf/unittest_no_arena_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_arena_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_arena_lite.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lite_test-unittest_import_lite.pb.o: google/protobuf/unittest_import_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_test-unittest_import_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_import_lite.pb.Tpo -c -o google/protobuf/protobuf_lite_test-unittest_import_lite.pb.o `test -f 'google/protobuf/unittest_import_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_import_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_import_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_lite.pb.cc' object='google/protobuf/protobuf_lite_test-unittest_import_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_test-unittest_import_lite.pb.o `test -f 'google/protobuf/unittest_import_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_lite.pb.cc\n\ngoogle/protobuf/protobuf_lite_test-unittest_import_lite.pb.obj: google/protobuf/unittest_import_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_test-unittest_import_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_import_lite.pb.Tpo -c -o google/protobuf/protobuf_lite_test-unittest_import_lite.pb.obj `if test -f 'google/protobuf/unittest_import_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_import_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_import_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_lite.pb.cc' object='google/protobuf/protobuf_lite_test-unittest_import_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_test-unittest_import_lite.pb.obj `if test -f 'google/protobuf/unittest_import_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_lite.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_lite_test-unittest_import_public_lite.pb.o: google/protobuf/unittest_import_public_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_test-unittest_import_public_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_import_public_lite.pb.Tpo -c -o google/protobuf/protobuf_lite_test-unittest_import_public_lite.pb.o `test -f 'google/protobuf/unittest_import_public_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_public_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_import_public_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_import_public_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_public_lite.pb.cc' object='google/protobuf/protobuf_lite_test-unittest_import_public_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_test-unittest_import_public_lite.pb.o `test -f 'google/protobuf/unittest_import_public_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_public_lite.pb.cc\n\ngoogle/protobuf/protobuf_lite_test-unittest_import_public_lite.pb.obj: google/protobuf/unittest_import_public_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_lite_test-unittest_import_public_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_import_public_lite.pb.Tpo -c -o google/protobuf/protobuf_lite_test-unittest_import_public_lite.pb.obj `if test -f 'google/protobuf/unittest_import_public_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_public_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_public_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_import_public_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_lite_test-unittest_import_public_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_public_lite.pb.cc' object='google/protobuf/protobuf_lite_test-unittest_import_public_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(protobuf_lite_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_lite_test-unittest_import_public_lite.pb.obj `if test -f 'google/protobuf/unittest_import_public_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_public_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_public_lite.pb.cc'; fi`\n\ngoogle/protobuf/stubs/protobuf_test-bytestream_unittest.o: google/protobuf/stubs/bytestream_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-bytestream_unittest.o -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-bytestream_unittest.Tpo -c -o google/protobuf/stubs/protobuf_test-bytestream_unittest.o `test -f 'google/protobuf/stubs/bytestream_unittest.cc' || echo '$(srcdir)/'`google/protobuf/stubs/bytestream_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-bytestream_unittest.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-bytestream_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/bytestream_unittest.cc' object='google/protobuf/stubs/protobuf_test-bytestream_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-bytestream_unittest.o `test -f 'google/protobuf/stubs/bytestream_unittest.cc' || echo '$(srcdir)/'`google/protobuf/stubs/bytestream_unittest.cc\n\ngoogle/protobuf/stubs/protobuf_test-bytestream_unittest.obj: google/protobuf/stubs/bytestream_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-bytestream_unittest.obj -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-bytestream_unittest.Tpo -c -o google/protobuf/stubs/protobuf_test-bytestream_unittest.obj `if test -f 'google/protobuf/stubs/bytestream_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/bytestream_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/bytestream_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-bytestream_unittest.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-bytestream_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/bytestream_unittest.cc' object='google/protobuf/stubs/protobuf_test-bytestream_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-bytestream_unittest.obj `if test -f 'google/protobuf/stubs/bytestream_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/bytestream_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/bytestream_unittest.cc'; fi`\n\ngoogle/protobuf/stubs/protobuf_test-common_unittest.o: google/protobuf/stubs/common_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-common_unittest.o -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-common_unittest.Tpo -c -o google/protobuf/stubs/protobuf_test-common_unittest.o `test -f 'google/protobuf/stubs/common_unittest.cc' || echo '$(srcdir)/'`google/protobuf/stubs/common_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-common_unittest.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-common_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/common_unittest.cc' object='google/protobuf/stubs/protobuf_test-common_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-common_unittest.o `test -f 'google/protobuf/stubs/common_unittest.cc' || echo '$(srcdir)/'`google/protobuf/stubs/common_unittest.cc\n\ngoogle/protobuf/stubs/protobuf_test-common_unittest.obj: google/protobuf/stubs/common_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-common_unittest.obj -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-common_unittest.Tpo -c -o google/protobuf/stubs/protobuf_test-common_unittest.obj `if test -f 'google/protobuf/stubs/common_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/common_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/common_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-common_unittest.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-common_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/common_unittest.cc' object='google/protobuf/stubs/protobuf_test-common_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-common_unittest.obj `if test -f 'google/protobuf/stubs/common_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/common_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/common_unittest.cc'; fi`\n\ngoogle/protobuf/stubs/protobuf_test-int128_unittest.o: google/protobuf/stubs/int128_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-int128_unittest.o -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-int128_unittest.Tpo -c -o google/protobuf/stubs/protobuf_test-int128_unittest.o `test -f 'google/protobuf/stubs/int128_unittest.cc' || echo '$(srcdir)/'`google/protobuf/stubs/int128_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-int128_unittest.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-int128_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/int128_unittest.cc' object='google/protobuf/stubs/protobuf_test-int128_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-int128_unittest.o `test -f 'google/protobuf/stubs/int128_unittest.cc' || echo '$(srcdir)/'`google/protobuf/stubs/int128_unittest.cc\n\ngoogle/protobuf/stubs/protobuf_test-int128_unittest.obj: google/protobuf/stubs/int128_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-int128_unittest.obj -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-int128_unittest.Tpo -c -o google/protobuf/stubs/protobuf_test-int128_unittest.obj `if test -f 'google/protobuf/stubs/int128_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/int128_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/int128_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-int128_unittest.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-int128_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/int128_unittest.cc' object='google/protobuf/stubs/protobuf_test-int128_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-int128_unittest.obj `if test -f 'google/protobuf/stubs/int128_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/int128_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/int128_unittest.cc'; fi`\n\ngoogle/protobuf/stubs/protobuf_test-once_unittest.o: google/protobuf/stubs/once_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-once_unittest.o -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-once_unittest.Tpo -c -o google/protobuf/stubs/protobuf_test-once_unittest.o `test -f 'google/protobuf/stubs/once_unittest.cc' || echo '$(srcdir)/'`google/protobuf/stubs/once_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-once_unittest.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-once_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/once_unittest.cc' object='google/protobuf/stubs/protobuf_test-once_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-once_unittest.o `test -f 'google/protobuf/stubs/once_unittest.cc' || echo '$(srcdir)/'`google/protobuf/stubs/once_unittest.cc\n\ngoogle/protobuf/stubs/protobuf_test-once_unittest.obj: google/protobuf/stubs/once_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-once_unittest.obj -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-once_unittest.Tpo -c -o google/protobuf/stubs/protobuf_test-once_unittest.obj `if test -f 'google/protobuf/stubs/once_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/once_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/once_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-once_unittest.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-once_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/once_unittest.cc' object='google/protobuf/stubs/protobuf_test-once_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-once_unittest.obj `if test -f 'google/protobuf/stubs/once_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/once_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/once_unittest.cc'; fi`\n\ngoogle/protobuf/stubs/protobuf_test-statusor_test.o: google/protobuf/stubs/statusor_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-statusor_test.o -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-statusor_test.Tpo -c -o google/protobuf/stubs/protobuf_test-statusor_test.o `test -f 'google/protobuf/stubs/statusor_test.cc' || echo '$(srcdir)/'`google/protobuf/stubs/statusor_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-statusor_test.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-statusor_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/statusor_test.cc' object='google/protobuf/stubs/protobuf_test-statusor_test.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-statusor_test.o `test -f 'google/protobuf/stubs/statusor_test.cc' || echo '$(srcdir)/'`google/protobuf/stubs/statusor_test.cc\n\ngoogle/protobuf/stubs/protobuf_test-statusor_test.obj: google/protobuf/stubs/statusor_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-statusor_test.obj -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-statusor_test.Tpo -c -o google/protobuf/stubs/protobuf_test-statusor_test.obj `if test -f 'google/protobuf/stubs/statusor_test.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/statusor_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/statusor_test.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-statusor_test.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-statusor_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/statusor_test.cc' object='google/protobuf/stubs/protobuf_test-statusor_test.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-statusor_test.obj `if test -f 'google/protobuf/stubs/statusor_test.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/statusor_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/statusor_test.cc'; fi`\n\ngoogle/protobuf/stubs/protobuf_test-status_test.o: google/protobuf/stubs/status_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-status_test.o -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-status_test.Tpo -c -o google/protobuf/stubs/protobuf_test-status_test.o `test -f 'google/protobuf/stubs/status_test.cc' || echo '$(srcdir)/'`google/protobuf/stubs/status_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-status_test.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-status_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/status_test.cc' object='google/protobuf/stubs/protobuf_test-status_test.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-status_test.o `test -f 'google/protobuf/stubs/status_test.cc' || echo '$(srcdir)/'`google/protobuf/stubs/status_test.cc\n\ngoogle/protobuf/stubs/protobuf_test-status_test.obj: google/protobuf/stubs/status_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-status_test.obj -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-status_test.Tpo -c -o google/protobuf/stubs/protobuf_test-status_test.obj `if test -f 'google/protobuf/stubs/status_test.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/status_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/status_test.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-status_test.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-status_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/status_test.cc' object='google/protobuf/stubs/protobuf_test-status_test.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-status_test.obj `if test -f 'google/protobuf/stubs/status_test.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/status_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/status_test.cc'; fi`\n\ngoogle/protobuf/stubs/protobuf_test-stringpiece_unittest.o: google/protobuf/stubs/stringpiece_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-stringpiece_unittest.o -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-stringpiece_unittest.Tpo -c -o google/protobuf/stubs/protobuf_test-stringpiece_unittest.o `test -f 'google/protobuf/stubs/stringpiece_unittest.cc' || echo '$(srcdir)/'`google/protobuf/stubs/stringpiece_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-stringpiece_unittest.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-stringpiece_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/stringpiece_unittest.cc' object='google/protobuf/stubs/protobuf_test-stringpiece_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-stringpiece_unittest.o `test -f 'google/protobuf/stubs/stringpiece_unittest.cc' || echo '$(srcdir)/'`google/protobuf/stubs/stringpiece_unittest.cc\n\ngoogle/protobuf/stubs/protobuf_test-stringpiece_unittest.obj: google/protobuf/stubs/stringpiece_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-stringpiece_unittest.obj -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-stringpiece_unittest.Tpo -c -o google/protobuf/stubs/protobuf_test-stringpiece_unittest.obj `if test -f 'google/protobuf/stubs/stringpiece_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/stringpiece_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/stringpiece_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-stringpiece_unittest.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-stringpiece_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/stringpiece_unittest.cc' object='google/protobuf/stubs/protobuf_test-stringpiece_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-stringpiece_unittest.obj `if test -f 'google/protobuf/stubs/stringpiece_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/stringpiece_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/stringpiece_unittest.cc'; fi`\n\ngoogle/protobuf/stubs/protobuf_test-stringprintf_unittest.o: google/protobuf/stubs/stringprintf_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-stringprintf_unittest.o -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-stringprintf_unittest.Tpo -c -o google/protobuf/stubs/protobuf_test-stringprintf_unittest.o `test -f 'google/protobuf/stubs/stringprintf_unittest.cc' || echo '$(srcdir)/'`google/protobuf/stubs/stringprintf_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-stringprintf_unittest.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-stringprintf_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/stringprintf_unittest.cc' object='google/protobuf/stubs/protobuf_test-stringprintf_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-stringprintf_unittest.o `test -f 'google/protobuf/stubs/stringprintf_unittest.cc' || echo '$(srcdir)/'`google/protobuf/stubs/stringprintf_unittest.cc\n\ngoogle/protobuf/stubs/protobuf_test-stringprintf_unittest.obj: google/protobuf/stubs/stringprintf_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-stringprintf_unittest.obj -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-stringprintf_unittest.Tpo -c -o google/protobuf/stubs/protobuf_test-stringprintf_unittest.obj `if test -f 'google/protobuf/stubs/stringprintf_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/stringprintf_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/stringprintf_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-stringprintf_unittest.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-stringprintf_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/stringprintf_unittest.cc' object='google/protobuf/stubs/protobuf_test-stringprintf_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-stringprintf_unittest.obj `if test -f 'google/protobuf/stubs/stringprintf_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/stringprintf_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/stringprintf_unittest.cc'; fi`\n\ngoogle/protobuf/stubs/protobuf_test-structurally_valid_unittest.o: google/protobuf/stubs/structurally_valid_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-structurally_valid_unittest.o -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-structurally_valid_unittest.Tpo -c -o google/protobuf/stubs/protobuf_test-structurally_valid_unittest.o `test -f 'google/protobuf/stubs/structurally_valid_unittest.cc' || echo '$(srcdir)/'`google/protobuf/stubs/structurally_valid_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-structurally_valid_unittest.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-structurally_valid_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/structurally_valid_unittest.cc' object='google/protobuf/stubs/protobuf_test-structurally_valid_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-structurally_valid_unittest.o `test -f 'google/protobuf/stubs/structurally_valid_unittest.cc' || echo '$(srcdir)/'`google/protobuf/stubs/structurally_valid_unittest.cc\n\ngoogle/protobuf/stubs/protobuf_test-structurally_valid_unittest.obj: google/protobuf/stubs/structurally_valid_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-structurally_valid_unittest.obj -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-structurally_valid_unittest.Tpo -c -o google/protobuf/stubs/protobuf_test-structurally_valid_unittest.obj `if test -f 'google/protobuf/stubs/structurally_valid_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/structurally_valid_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/structurally_valid_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-structurally_valid_unittest.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-structurally_valid_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/structurally_valid_unittest.cc' object='google/protobuf/stubs/protobuf_test-structurally_valid_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-structurally_valid_unittest.obj `if test -f 'google/protobuf/stubs/structurally_valid_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/structurally_valid_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/structurally_valid_unittest.cc'; fi`\n\ngoogle/protobuf/stubs/protobuf_test-strutil_unittest.o: google/protobuf/stubs/strutil_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-strutil_unittest.o -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-strutil_unittest.Tpo -c -o google/protobuf/stubs/protobuf_test-strutil_unittest.o `test -f 'google/protobuf/stubs/strutil_unittest.cc' || echo '$(srcdir)/'`google/protobuf/stubs/strutil_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-strutil_unittest.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-strutil_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/strutil_unittest.cc' object='google/protobuf/stubs/protobuf_test-strutil_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-strutil_unittest.o `test -f 'google/protobuf/stubs/strutil_unittest.cc' || echo '$(srcdir)/'`google/protobuf/stubs/strutil_unittest.cc\n\ngoogle/protobuf/stubs/protobuf_test-strutil_unittest.obj: google/protobuf/stubs/strutil_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-strutil_unittest.obj -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-strutil_unittest.Tpo -c -o google/protobuf/stubs/protobuf_test-strutil_unittest.obj `if test -f 'google/protobuf/stubs/strutil_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/strutil_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/strutil_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-strutil_unittest.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-strutil_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/strutil_unittest.cc' object='google/protobuf/stubs/protobuf_test-strutil_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-strutil_unittest.obj `if test -f 'google/protobuf/stubs/strutil_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/strutil_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/strutil_unittest.cc'; fi`\n\ngoogle/protobuf/stubs/protobuf_test-template_util_unittest.o: google/protobuf/stubs/template_util_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-template_util_unittest.o -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-template_util_unittest.Tpo -c -o google/protobuf/stubs/protobuf_test-template_util_unittest.o `test -f 'google/protobuf/stubs/template_util_unittest.cc' || echo '$(srcdir)/'`google/protobuf/stubs/template_util_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-template_util_unittest.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-template_util_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/template_util_unittest.cc' object='google/protobuf/stubs/protobuf_test-template_util_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-template_util_unittest.o `test -f 'google/protobuf/stubs/template_util_unittest.cc' || echo '$(srcdir)/'`google/protobuf/stubs/template_util_unittest.cc\n\ngoogle/protobuf/stubs/protobuf_test-template_util_unittest.obj: google/protobuf/stubs/template_util_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-template_util_unittest.obj -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-template_util_unittest.Tpo -c -o google/protobuf/stubs/protobuf_test-template_util_unittest.obj `if test -f 'google/protobuf/stubs/template_util_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/template_util_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/template_util_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-template_util_unittest.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-template_util_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/template_util_unittest.cc' object='google/protobuf/stubs/protobuf_test-template_util_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-template_util_unittest.obj `if test -f 'google/protobuf/stubs/template_util_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/template_util_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/template_util_unittest.cc'; fi`\n\ngoogle/protobuf/stubs/protobuf_test-time_test.o: google/protobuf/stubs/time_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-time_test.o -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-time_test.Tpo -c -o google/protobuf/stubs/protobuf_test-time_test.o `test -f 'google/protobuf/stubs/time_test.cc' || echo '$(srcdir)/'`google/protobuf/stubs/time_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-time_test.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-time_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/time_test.cc' object='google/protobuf/stubs/protobuf_test-time_test.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-time_test.o `test -f 'google/protobuf/stubs/time_test.cc' || echo '$(srcdir)/'`google/protobuf/stubs/time_test.cc\n\ngoogle/protobuf/stubs/protobuf_test-time_test.obj: google/protobuf/stubs/time_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-time_test.obj -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-time_test.Tpo -c -o google/protobuf/stubs/protobuf_test-time_test.obj `if test -f 'google/protobuf/stubs/time_test.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/time_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/time_test.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-time_test.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-time_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/time_test.cc' object='google/protobuf/stubs/protobuf_test-time_test.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-time_test.obj `if test -f 'google/protobuf/stubs/time_test.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/time_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/time_test.cc'; fi`\n\ngoogle/protobuf/stubs/protobuf_test-type_traits_unittest.o: google/protobuf/stubs/type_traits_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-type_traits_unittest.o -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-type_traits_unittest.Tpo -c -o google/protobuf/stubs/protobuf_test-type_traits_unittest.o `test -f 'google/protobuf/stubs/type_traits_unittest.cc' || echo '$(srcdir)/'`google/protobuf/stubs/type_traits_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-type_traits_unittest.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-type_traits_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/type_traits_unittest.cc' object='google/protobuf/stubs/protobuf_test-type_traits_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-type_traits_unittest.o `test -f 'google/protobuf/stubs/type_traits_unittest.cc' || echo '$(srcdir)/'`google/protobuf/stubs/type_traits_unittest.cc\n\ngoogle/protobuf/stubs/protobuf_test-type_traits_unittest.obj: google/protobuf/stubs/type_traits_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/stubs/protobuf_test-type_traits_unittest.obj -MD -MP -MF google/protobuf/stubs/$(DEPDIR)/protobuf_test-type_traits_unittest.Tpo -c -o google/protobuf/stubs/protobuf_test-type_traits_unittest.obj `if test -f 'google/protobuf/stubs/type_traits_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/type_traits_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/type_traits_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/stubs/$(DEPDIR)/protobuf_test-type_traits_unittest.Tpo google/protobuf/stubs/$(DEPDIR)/protobuf_test-type_traits_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/stubs/type_traits_unittest.cc' object='google/protobuf/stubs/protobuf_test-type_traits_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/stubs/protobuf_test-type_traits_unittest.obj `if test -f 'google/protobuf/stubs/type_traits_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/stubs/type_traits_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/stubs/type_traits_unittest.cc'; fi`\n\ngoogle/protobuf/protobuf_test-any_test.o: google/protobuf/any_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-any_test.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-any_test.Tpo -c -o google/protobuf/protobuf_test-any_test.o `test -f 'google/protobuf/any_test.cc' || echo '$(srcdir)/'`google/protobuf/any_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-any_test.Tpo google/protobuf/$(DEPDIR)/protobuf_test-any_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/any_test.cc' object='google/protobuf/protobuf_test-any_test.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-any_test.o `test -f 'google/protobuf/any_test.cc' || echo '$(srcdir)/'`google/protobuf/any_test.cc\n\ngoogle/protobuf/protobuf_test-any_test.obj: google/protobuf/any_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-any_test.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-any_test.Tpo -c -o google/protobuf/protobuf_test-any_test.obj `if test -f 'google/protobuf/any_test.cc'; then $(CYGPATH_W) 'google/protobuf/any_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/any_test.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-any_test.Tpo google/protobuf/$(DEPDIR)/protobuf_test-any_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/any_test.cc' object='google/protobuf/protobuf_test-any_test.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-any_test.obj `if test -f 'google/protobuf/any_test.cc'; then $(CYGPATH_W) 'google/protobuf/any_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/any_test.cc'; fi`\n\ngoogle/protobuf/protobuf_test-arenastring_unittest.o: google/protobuf/arenastring_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-arenastring_unittest.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-arenastring_unittest.Tpo -c -o google/protobuf/protobuf_test-arenastring_unittest.o `test -f 'google/protobuf/arenastring_unittest.cc' || echo '$(srcdir)/'`google/protobuf/arenastring_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-arenastring_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-arenastring_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/arenastring_unittest.cc' object='google/protobuf/protobuf_test-arenastring_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-arenastring_unittest.o `test -f 'google/protobuf/arenastring_unittest.cc' || echo '$(srcdir)/'`google/protobuf/arenastring_unittest.cc\n\ngoogle/protobuf/protobuf_test-arenastring_unittest.obj: google/protobuf/arenastring_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-arenastring_unittest.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-arenastring_unittest.Tpo -c -o google/protobuf/protobuf_test-arenastring_unittest.obj `if test -f 'google/protobuf/arenastring_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/arenastring_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/arenastring_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-arenastring_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-arenastring_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/arenastring_unittest.cc' object='google/protobuf/protobuf_test-arenastring_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-arenastring_unittest.obj `if test -f 'google/protobuf/arenastring_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/arenastring_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/arenastring_unittest.cc'; fi`\n\ngoogle/protobuf/protobuf_test-arena_unittest.o: google/protobuf/arena_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-arena_unittest.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-arena_unittest.Tpo -c -o google/protobuf/protobuf_test-arena_unittest.o `test -f 'google/protobuf/arena_unittest.cc' || echo '$(srcdir)/'`google/protobuf/arena_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-arena_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-arena_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/arena_unittest.cc' object='google/protobuf/protobuf_test-arena_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-arena_unittest.o `test -f 'google/protobuf/arena_unittest.cc' || echo '$(srcdir)/'`google/protobuf/arena_unittest.cc\n\ngoogle/protobuf/protobuf_test-arena_unittest.obj: google/protobuf/arena_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-arena_unittest.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-arena_unittest.Tpo -c -o google/protobuf/protobuf_test-arena_unittest.obj `if test -f 'google/protobuf/arena_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/arena_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/arena_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-arena_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-arena_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/arena_unittest.cc' object='google/protobuf/protobuf_test-arena_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-arena_unittest.obj `if test -f 'google/protobuf/arena_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/arena_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/arena_unittest.cc'; fi`\n\ngoogle/protobuf/protobuf_test-descriptor_database_unittest.o: google/protobuf/descriptor_database_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-descriptor_database_unittest.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-descriptor_database_unittest.Tpo -c -o google/protobuf/protobuf_test-descriptor_database_unittest.o `test -f 'google/protobuf/descriptor_database_unittest.cc' || echo '$(srcdir)/'`google/protobuf/descriptor_database_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-descriptor_database_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-descriptor_database_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/descriptor_database_unittest.cc' object='google/protobuf/protobuf_test-descriptor_database_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-descriptor_database_unittest.o `test -f 'google/protobuf/descriptor_database_unittest.cc' || echo '$(srcdir)/'`google/protobuf/descriptor_database_unittest.cc\n\ngoogle/protobuf/protobuf_test-descriptor_database_unittest.obj: google/protobuf/descriptor_database_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-descriptor_database_unittest.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-descriptor_database_unittest.Tpo -c -o google/protobuf/protobuf_test-descriptor_database_unittest.obj `if test -f 'google/protobuf/descriptor_database_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/descriptor_database_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/descriptor_database_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-descriptor_database_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-descriptor_database_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/descriptor_database_unittest.cc' object='google/protobuf/protobuf_test-descriptor_database_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-descriptor_database_unittest.obj `if test -f 'google/protobuf/descriptor_database_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/descriptor_database_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/descriptor_database_unittest.cc'; fi`\n\ngoogle/protobuf/protobuf_test-descriptor_unittest.o: google/protobuf/descriptor_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-descriptor_unittest.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-descriptor_unittest.Tpo -c -o google/protobuf/protobuf_test-descriptor_unittest.o `test -f 'google/protobuf/descriptor_unittest.cc' || echo '$(srcdir)/'`google/protobuf/descriptor_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-descriptor_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-descriptor_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/descriptor_unittest.cc' object='google/protobuf/protobuf_test-descriptor_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-descriptor_unittest.o `test -f 'google/protobuf/descriptor_unittest.cc' || echo '$(srcdir)/'`google/protobuf/descriptor_unittest.cc\n\ngoogle/protobuf/protobuf_test-descriptor_unittest.obj: google/protobuf/descriptor_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-descriptor_unittest.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-descriptor_unittest.Tpo -c -o google/protobuf/protobuf_test-descriptor_unittest.obj `if test -f 'google/protobuf/descriptor_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/descriptor_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/descriptor_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-descriptor_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-descriptor_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/descriptor_unittest.cc' object='google/protobuf/protobuf_test-descriptor_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-descriptor_unittest.obj `if test -f 'google/protobuf/descriptor_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/descriptor_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/descriptor_unittest.cc'; fi`\n\ngoogle/protobuf/protobuf_test-drop_unknown_fields_test.o: google/protobuf/drop_unknown_fields_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-drop_unknown_fields_test.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-drop_unknown_fields_test.Tpo -c -o google/protobuf/protobuf_test-drop_unknown_fields_test.o `test -f 'google/protobuf/drop_unknown_fields_test.cc' || echo '$(srcdir)/'`google/protobuf/drop_unknown_fields_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-drop_unknown_fields_test.Tpo google/protobuf/$(DEPDIR)/protobuf_test-drop_unknown_fields_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/drop_unknown_fields_test.cc' object='google/protobuf/protobuf_test-drop_unknown_fields_test.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-drop_unknown_fields_test.o `test -f 'google/protobuf/drop_unknown_fields_test.cc' || echo '$(srcdir)/'`google/protobuf/drop_unknown_fields_test.cc\n\ngoogle/protobuf/protobuf_test-drop_unknown_fields_test.obj: google/protobuf/drop_unknown_fields_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-drop_unknown_fields_test.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-drop_unknown_fields_test.Tpo -c -o google/protobuf/protobuf_test-drop_unknown_fields_test.obj `if test -f 'google/protobuf/drop_unknown_fields_test.cc'; then $(CYGPATH_W) 'google/protobuf/drop_unknown_fields_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/drop_unknown_fields_test.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-drop_unknown_fields_test.Tpo google/protobuf/$(DEPDIR)/protobuf_test-drop_unknown_fields_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/drop_unknown_fields_test.cc' object='google/protobuf/protobuf_test-drop_unknown_fields_test.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-drop_unknown_fields_test.obj `if test -f 'google/protobuf/drop_unknown_fields_test.cc'; then $(CYGPATH_W) 'google/protobuf/drop_unknown_fields_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/drop_unknown_fields_test.cc'; fi`\n\ngoogle/protobuf/protobuf_test-dynamic_message_unittest.o: google/protobuf/dynamic_message_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-dynamic_message_unittest.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-dynamic_message_unittest.Tpo -c -o google/protobuf/protobuf_test-dynamic_message_unittest.o `test -f 'google/protobuf/dynamic_message_unittest.cc' || echo '$(srcdir)/'`google/protobuf/dynamic_message_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-dynamic_message_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-dynamic_message_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/dynamic_message_unittest.cc' object='google/protobuf/protobuf_test-dynamic_message_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-dynamic_message_unittest.o `test -f 'google/protobuf/dynamic_message_unittest.cc' || echo '$(srcdir)/'`google/protobuf/dynamic_message_unittest.cc\n\ngoogle/protobuf/protobuf_test-dynamic_message_unittest.obj: google/protobuf/dynamic_message_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-dynamic_message_unittest.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-dynamic_message_unittest.Tpo -c -o google/protobuf/protobuf_test-dynamic_message_unittest.obj `if test -f 'google/protobuf/dynamic_message_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/dynamic_message_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/dynamic_message_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-dynamic_message_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-dynamic_message_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/dynamic_message_unittest.cc' object='google/protobuf/protobuf_test-dynamic_message_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-dynamic_message_unittest.obj `if test -f 'google/protobuf/dynamic_message_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/dynamic_message_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/dynamic_message_unittest.cc'; fi`\n\ngoogle/protobuf/protobuf_test-extension_set_unittest.o: google/protobuf/extension_set_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-extension_set_unittest.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-extension_set_unittest.Tpo -c -o google/protobuf/protobuf_test-extension_set_unittest.o `test -f 'google/protobuf/extension_set_unittest.cc' || echo '$(srcdir)/'`google/protobuf/extension_set_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-extension_set_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-extension_set_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/extension_set_unittest.cc' object='google/protobuf/protobuf_test-extension_set_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-extension_set_unittest.o `test -f 'google/protobuf/extension_set_unittest.cc' || echo '$(srcdir)/'`google/protobuf/extension_set_unittest.cc\n\ngoogle/protobuf/protobuf_test-extension_set_unittest.obj: google/protobuf/extension_set_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-extension_set_unittest.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-extension_set_unittest.Tpo -c -o google/protobuf/protobuf_test-extension_set_unittest.obj `if test -f 'google/protobuf/extension_set_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/extension_set_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/extension_set_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-extension_set_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-extension_set_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/extension_set_unittest.cc' object='google/protobuf/protobuf_test-extension_set_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-extension_set_unittest.obj `if test -f 'google/protobuf/extension_set_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/extension_set_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/extension_set_unittest.cc'; fi`\n\ngoogle/protobuf/protobuf_test-generated_message_reflection_unittest.o: google/protobuf/generated_message_reflection_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-generated_message_reflection_unittest.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-generated_message_reflection_unittest.Tpo -c -o google/protobuf/protobuf_test-generated_message_reflection_unittest.o `test -f 'google/protobuf/generated_message_reflection_unittest.cc' || echo '$(srcdir)/'`google/protobuf/generated_message_reflection_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-generated_message_reflection_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-generated_message_reflection_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/generated_message_reflection_unittest.cc' object='google/protobuf/protobuf_test-generated_message_reflection_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-generated_message_reflection_unittest.o `test -f 'google/protobuf/generated_message_reflection_unittest.cc' || echo '$(srcdir)/'`google/protobuf/generated_message_reflection_unittest.cc\n\ngoogle/protobuf/protobuf_test-generated_message_reflection_unittest.obj: google/protobuf/generated_message_reflection_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-generated_message_reflection_unittest.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-generated_message_reflection_unittest.Tpo -c -o google/protobuf/protobuf_test-generated_message_reflection_unittest.obj `if test -f 'google/protobuf/generated_message_reflection_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/generated_message_reflection_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/generated_message_reflection_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-generated_message_reflection_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-generated_message_reflection_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/generated_message_reflection_unittest.cc' object='google/protobuf/protobuf_test-generated_message_reflection_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-generated_message_reflection_unittest.obj `if test -f 'google/protobuf/generated_message_reflection_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/generated_message_reflection_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/generated_message_reflection_unittest.cc'; fi`\n\ngoogle/protobuf/protobuf_test-map_field_test.o: google/protobuf/map_field_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-map_field_test.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-map_field_test.Tpo -c -o google/protobuf/protobuf_test-map_field_test.o `test -f 'google/protobuf/map_field_test.cc' || echo '$(srcdir)/'`google/protobuf/map_field_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-map_field_test.Tpo google/protobuf/$(DEPDIR)/protobuf_test-map_field_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_field_test.cc' object='google/protobuf/protobuf_test-map_field_test.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-map_field_test.o `test -f 'google/protobuf/map_field_test.cc' || echo '$(srcdir)/'`google/protobuf/map_field_test.cc\n\ngoogle/protobuf/protobuf_test-map_field_test.obj: google/protobuf/map_field_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-map_field_test.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-map_field_test.Tpo -c -o google/protobuf/protobuf_test-map_field_test.obj `if test -f 'google/protobuf/map_field_test.cc'; then $(CYGPATH_W) 'google/protobuf/map_field_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_field_test.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-map_field_test.Tpo google/protobuf/$(DEPDIR)/protobuf_test-map_field_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_field_test.cc' object='google/protobuf/protobuf_test-map_field_test.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-map_field_test.obj `if test -f 'google/protobuf/map_field_test.cc'; then $(CYGPATH_W) 'google/protobuf/map_field_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_field_test.cc'; fi`\n\ngoogle/protobuf/protobuf_test-map_test.o: google/protobuf/map_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-map_test.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-map_test.Tpo -c -o google/protobuf/protobuf_test-map_test.o `test -f 'google/protobuf/map_test.cc' || echo '$(srcdir)/'`google/protobuf/map_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-map_test.Tpo google/protobuf/$(DEPDIR)/protobuf_test-map_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_test.cc' object='google/protobuf/protobuf_test-map_test.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-map_test.o `test -f 'google/protobuf/map_test.cc' || echo '$(srcdir)/'`google/protobuf/map_test.cc\n\ngoogle/protobuf/protobuf_test-map_test.obj: google/protobuf/map_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-map_test.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-map_test.Tpo -c -o google/protobuf/protobuf_test-map_test.obj `if test -f 'google/protobuf/map_test.cc'; then $(CYGPATH_W) 'google/protobuf/map_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_test.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-map_test.Tpo google/protobuf/$(DEPDIR)/protobuf_test-map_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_test.cc' object='google/protobuf/protobuf_test-map_test.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-map_test.obj `if test -f 'google/protobuf/map_test.cc'; then $(CYGPATH_W) 'google/protobuf/map_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_test.cc'; fi`\n\ngoogle/protobuf/protobuf_test-message_unittest.o: google/protobuf/message_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-message_unittest.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-message_unittest.Tpo -c -o google/protobuf/protobuf_test-message_unittest.o `test -f 'google/protobuf/message_unittest.cc' || echo '$(srcdir)/'`google/protobuf/message_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-message_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-message_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/message_unittest.cc' object='google/protobuf/protobuf_test-message_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-message_unittest.o `test -f 'google/protobuf/message_unittest.cc' || echo '$(srcdir)/'`google/protobuf/message_unittest.cc\n\ngoogle/protobuf/protobuf_test-message_unittest.obj: google/protobuf/message_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-message_unittest.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-message_unittest.Tpo -c -o google/protobuf/protobuf_test-message_unittest.obj `if test -f 'google/protobuf/message_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/message_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/message_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-message_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-message_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/message_unittest.cc' object='google/protobuf/protobuf_test-message_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-message_unittest.obj `if test -f 'google/protobuf/message_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/message_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/message_unittest.cc'; fi`\n\ngoogle/protobuf/protobuf_test-no_field_presence_test.o: google/protobuf/no_field_presence_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-no_field_presence_test.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-no_field_presence_test.Tpo -c -o google/protobuf/protobuf_test-no_field_presence_test.o `test -f 'google/protobuf/no_field_presence_test.cc' || echo '$(srcdir)/'`google/protobuf/no_field_presence_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-no_field_presence_test.Tpo google/protobuf/$(DEPDIR)/protobuf_test-no_field_presence_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/no_field_presence_test.cc' object='google/protobuf/protobuf_test-no_field_presence_test.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-no_field_presence_test.o `test -f 'google/protobuf/no_field_presence_test.cc' || echo '$(srcdir)/'`google/protobuf/no_field_presence_test.cc\n\ngoogle/protobuf/protobuf_test-no_field_presence_test.obj: google/protobuf/no_field_presence_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-no_field_presence_test.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-no_field_presence_test.Tpo -c -o google/protobuf/protobuf_test-no_field_presence_test.obj `if test -f 'google/protobuf/no_field_presence_test.cc'; then $(CYGPATH_W) 'google/protobuf/no_field_presence_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/no_field_presence_test.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-no_field_presence_test.Tpo google/protobuf/$(DEPDIR)/protobuf_test-no_field_presence_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/no_field_presence_test.cc' object='google/protobuf/protobuf_test-no_field_presence_test.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-no_field_presence_test.obj `if test -f 'google/protobuf/no_field_presence_test.cc'; then $(CYGPATH_W) 'google/protobuf/no_field_presence_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/no_field_presence_test.cc'; fi`\n\ngoogle/protobuf/protobuf_test-preserve_unknown_enum_test.o: google/protobuf/preserve_unknown_enum_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-preserve_unknown_enum_test.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-preserve_unknown_enum_test.Tpo -c -o google/protobuf/protobuf_test-preserve_unknown_enum_test.o `test -f 'google/protobuf/preserve_unknown_enum_test.cc' || echo '$(srcdir)/'`google/protobuf/preserve_unknown_enum_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-preserve_unknown_enum_test.Tpo google/protobuf/$(DEPDIR)/protobuf_test-preserve_unknown_enum_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/preserve_unknown_enum_test.cc' object='google/protobuf/protobuf_test-preserve_unknown_enum_test.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-preserve_unknown_enum_test.o `test -f 'google/protobuf/preserve_unknown_enum_test.cc' || echo '$(srcdir)/'`google/protobuf/preserve_unknown_enum_test.cc\n\ngoogle/protobuf/protobuf_test-preserve_unknown_enum_test.obj: google/protobuf/preserve_unknown_enum_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-preserve_unknown_enum_test.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-preserve_unknown_enum_test.Tpo -c -o google/protobuf/protobuf_test-preserve_unknown_enum_test.obj `if test -f 'google/protobuf/preserve_unknown_enum_test.cc'; then $(CYGPATH_W) 'google/protobuf/preserve_unknown_enum_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/preserve_unknown_enum_test.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-preserve_unknown_enum_test.Tpo google/protobuf/$(DEPDIR)/protobuf_test-preserve_unknown_enum_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/preserve_unknown_enum_test.cc' object='google/protobuf/protobuf_test-preserve_unknown_enum_test.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-preserve_unknown_enum_test.obj `if test -f 'google/protobuf/preserve_unknown_enum_test.cc'; then $(CYGPATH_W) 'google/protobuf/preserve_unknown_enum_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/preserve_unknown_enum_test.cc'; fi`\n\ngoogle/protobuf/protobuf_test-proto3_arena_unittest.o: google/protobuf/proto3_arena_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-proto3_arena_unittest.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-proto3_arena_unittest.Tpo -c -o google/protobuf/protobuf_test-proto3_arena_unittest.o `test -f 'google/protobuf/proto3_arena_unittest.cc' || echo '$(srcdir)/'`google/protobuf/proto3_arena_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-proto3_arena_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-proto3_arena_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/proto3_arena_unittest.cc' object='google/protobuf/protobuf_test-proto3_arena_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-proto3_arena_unittest.o `test -f 'google/protobuf/proto3_arena_unittest.cc' || echo '$(srcdir)/'`google/protobuf/proto3_arena_unittest.cc\n\ngoogle/protobuf/protobuf_test-proto3_arena_unittest.obj: google/protobuf/proto3_arena_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-proto3_arena_unittest.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-proto3_arena_unittest.Tpo -c -o google/protobuf/protobuf_test-proto3_arena_unittest.obj `if test -f 'google/protobuf/proto3_arena_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/proto3_arena_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/proto3_arena_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-proto3_arena_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-proto3_arena_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/proto3_arena_unittest.cc' object='google/protobuf/protobuf_test-proto3_arena_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-proto3_arena_unittest.obj `if test -f 'google/protobuf/proto3_arena_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/proto3_arena_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/proto3_arena_unittest.cc'; fi`\n\ngoogle/protobuf/protobuf_test-proto3_arena_lite_unittest.o: google/protobuf/proto3_arena_lite_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-proto3_arena_lite_unittest.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-proto3_arena_lite_unittest.Tpo -c -o google/protobuf/protobuf_test-proto3_arena_lite_unittest.o `test -f 'google/protobuf/proto3_arena_lite_unittest.cc' || echo '$(srcdir)/'`google/protobuf/proto3_arena_lite_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-proto3_arena_lite_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-proto3_arena_lite_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/proto3_arena_lite_unittest.cc' object='google/protobuf/protobuf_test-proto3_arena_lite_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-proto3_arena_lite_unittest.o `test -f 'google/protobuf/proto3_arena_lite_unittest.cc' || echo '$(srcdir)/'`google/protobuf/proto3_arena_lite_unittest.cc\n\ngoogle/protobuf/protobuf_test-proto3_arena_lite_unittest.obj: google/protobuf/proto3_arena_lite_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-proto3_arena_lite_unittest.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-proto3_arena_lite_unittest.Tpo -c -o google/protobuf/protobuf_test-proto3_arena_lite_unittest.obj `if test -f 'google/protobuf/proto3_arena_lite_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/proto3_arena_lite_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/proto3_arena_lite_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-proto3_arena_lite_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-proto3_arena_lite_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/proto3_arena_lite_unittest.cc' object='google/protobuf/protobuf_test-proto3_arena_lite_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-proto3_arena_lite_unittest.obj `if test -f 'google/protobuf/proto3_arena_lite_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/proto3_arena_lite_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/proto3_arena_lite_unittest.cc'; fi`\n\ngoogle/protobuf/protobuf_test-proto3_lite_unittest.o: google/protobuf/proto3_lite_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-proto3_lite_unittest.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-proto3_lite_unittest.Tpo -c -o google/protobuf/protobuf_test-proto3_lite_unittest.o `test -f 'google/protobuf/proto3_lite_unittest.cc' || echo '$(srcdir)/'`google/protobuf/proto3_lite_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-proto3_lite_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-proto3_lite_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/proto3_lite_unittest.cc' object='google/protobuf/protobuf_test-proto3_lite_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-proto3_lite_unittest.o `test -f 'google/protobuf/proto3_lite_unittest.cc' || echo '$(srcdir)/'`google/protobuf/proto3_lite_unittest.cc\n\ngoogle/protobuf/protobuf_test-proto3_lite_unittest.obj: google/protobuf/proto3_lite_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-proto3_lite_unittest.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-proto3_lite_unittest.Tpo -c -o google/protobuf/protobuf_test-proto3_lite_unittest.obj `if test -f 'google/protobuf/proto3_lite_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/proto3_lite_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/proto3_lite_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-proto3_lite_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-proto3_lite_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/proto3_lite_unittest.cc' object='google/protobuf/protobuf_test-proto3_lite_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-proto3_lite_unittest.obj `if test -f 'google/protobuf/proto3_lite_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/proto3_lite_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/proto3_lite_unittest.cc'; fi`\n\ngoogle/protobuf/protobuf_test-reflection_ops_unittest.o: google/protobuf/reflection_ops_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-reflection_ops_unittest.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-reflection_ops_unittest.Tpo -c -o google/protobuf/protobuf_test-reflection_ops_unittest.o `test -f 'google/protobuf/reflection_ops_unittest.cc' || echo '$(srcdir)/'`google/protobuf/reflection_ops_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-reflection_ops_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-reflection_ops_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/reflection_ops_unittest.cc' object='google/protobuf/protobuf_test-reflection_ops_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-reflection_ops_unittest.o `test -f 'google/protobuf/reflection_ops_unittest.cc' || echo '$(srcdir)/'`google/protobuf/reflection_ops_unittest.cc\n\ngoogle/protobuf/protobuf_test-reflection_ops_unittest.obj: google/protobuf/reflection_ops_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-reflection_ops_unittest.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-reflection_ops_unittest.Tpo -c -o google/protobuf/protobuf_test-reflection_ops_unittest.obj `if test -f 'google/protobuf/reflection_ops_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/reflection_ops_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/reflection_ops_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-reflection_ops_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-reflection_ops_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/reflection_ops_unittest.cc' object='google/protobuf/protobuf_test-reflection_ops_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-reflection_ops_unittest.obj `if test -f 'google/protobuf/reflection_ops_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/reflection_ops_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/reflection_ops_unittest.cc'; fi`\n\ngoogle/protobuf/protobuf_test-repeated_field_reflection_unittest.o: google/protobuf/repeated_field_reflection_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-repeated_field_reflection_unittest.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-repeated_field_reflection_unittest.Tpo -c -o google/protobuf/protobuf_test-repeated_field_reflection_unittest.o `test -f 'google/protobuf/repeated_field_reflection_unittest.cc' || echo '$(srcdir)/'`google/protobuf/repeated_field_reflection_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-repeated_field_reflection_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-repeated_field_reflection_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/repeated_field_reflection_unittest.cc' object='google/protobuf/protobuf_test-repeated_field_reflection_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-repeated_field_reflection_unittest.o `test -f 'google/protobuf/repeated_field_reflection_unittest.cc' || echo '$(srcdir)/'`google/protobuf/repeated_field_reflection_unittest.cc\n\ngoogle/protobuf/protobuf_test-repeated_field_reflection_unittest.obj: google/protobuf/repeated_field_reflection_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-repeated_field_reflection_unittest.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-repeated_field_reflection_unittest.Tpo -c -o google/protobuf/protobuf_test-repeated_field_reflection_unittest.obj `if test -f 'google/protobuf/repeated_field_reflection_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/repeated_field_reflection_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/repeated_field_reflection_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-repeated_field_reflection_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-repeated_field_reflection_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/repeated_field_reflection_unittest.cc' object='google/protobuf/protobuf_test-repeated_field_reflection_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-repeated_field_reflection_unittest.obj `if test -f 'google/protobuf/repeated_field_reflection_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/repeated_field_reflection_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/repeated_field_reflection_unittest.cc'; fi`\n\ngoogle/protobuf/protobuf_test-repeated_field_unittest.o: google/protobuf/repeated_field_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-repeated_field_unittest.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-repeated_field_unittest.Tpo -c -o google/protobuf/protobuf_test-repeated_field_unittest.o `test -f 'google/protobuf/repeated_field_unittest.cc' || echo '$(srcdir)/'`google/protobuf/repeated_field_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-repeated_field_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-repeated_field_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/repeated_field_unittest.cc' object='google/protobuf/protobuf_test-repeated_field_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-repeated_field_unittest.o `test -f 'google/protobuf/repeated_field_unittest.cc' || echo '$(srcdir)/'`google/protobuf/repeated_field_unittest.cc\n\ngoogle/protobuf/protobuf_test-repeated_field_unittest.obj: google/protobuf/repeated_field_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-repeated_field_unittest.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-repeated_field_unittest.Tpo -c -o google/protobuf/protobuf_test-repeated_field_unittest.obj `if test -f 'google/protobuf/repeated_field_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/repeated_field_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/repeated_field_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-repeated_field_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-repeated_field_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/repeated_field_unittest.cc' object='google/protobuf/protobuf_test-repeated_field_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-repeated_field_unittest.obj `if test -f 'google/protobuf/repeated_field_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/repeated_field_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/repeated_field_unittest.cc'; fi`\n\ngoogle/protobuf/protobuf_test-text_format_unittest.o: google/protobuf/text_format_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-text_format_unittest.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-text_format_unittest.Tpo -c -o google/protobuf/protobuf_test-text_format_unittest.o `test -f 'google/protobuf/text_format_unittest.cc' || echo '$(srcdir)/'`google/protobuf/text_format_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-text_format_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-text_format_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/text_format_unittest.cc' object='google/protobuf/protobuf_test-text_format_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-text_format_unittest.o `test -f 'google/protobuf/text_format_unittest.cc' || echo '$(srcdir)/'`google/protobuf/text_format_unittest.cc\n\ngoogle/protobuf/protobuf_test-text_format_unittest.obj: google/protobuf/text_format_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-text_format_unittest.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-text_format_unittest.Tpo -c -o google/protobuf/protobuf_test-text_format_unittest.obj `if test -f 'google/protobuf/text_format_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/text_format_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/text_format_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-text_format_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-text_format_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/text_format_unittest.cc' object='google/protobuf/protobuf_test-text_format_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-text_format_unittest.obj `if test -f 'google/protobuf/text_format_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/text_format_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/text_format_unittest.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unknown_field_set_unittest.o: google/protobuf/unknown_field_set_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unknown_field_set_unittest.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unknown_field_set_unittest.Tpo -c -o google/protobuf/protobuf_test-unknown_field_set_unittest.o `test -f 'google/protobuf/unknown_field_set_unittest.cc' || echo '$(srcdir)/'`google/protobuf/unknown_field_set_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unknown_field_set_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unknown_field_set_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unknown_field_set_unittest.cc' object='google/protobuf/protobuf_test-unknown_field_set_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unknown_field_set_unittest.o `test -f 'google/protobuf/unknown_field_set_unittest.cc' || echo '$(srcdir)/'`google/protobuf/unknown_field_set_unittest.cc\n\ngoogle/protobuf/protobuf_test-unknown_field_set_unittest.obj: google/protobuf/unknown_field_set_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unknown_field_set_unittest.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unknown_field_set_unittest.Tpo -c -o google/protobuf/protobuf_test-unknown_field_set_unittest.obj `if test -f 'google/protobuf/unknown_field_set_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/unknown_field_set_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unknown_field_set_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unknown_field_set_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unknown_field_set_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unknown_field_set_unittest.cc' object='google/protobuf/protobuf_test-unknown_field_set_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unknown_field_set_unittest.obj `if test -f 'google/protobuf/unknown_field_set_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/unknown_field_set_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unknown_field_set_unittest.cc'; fi`\n\ngoogle/protobuf/protobuf_test-well_known_types_unittest.o: google/protobuf/well_known_types_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-well_known_types_unittest.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-well_known_types_unittest.Tpo -c -o google/protobuf/protobuf_test-well_known_types_unittest.o `test -f 'google/protobuf/well_known_types_unittest.cc' || echo '$(srcdir)/'`google/protobuf/well_known_types_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-well_known_types_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-well_known_types_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/well_known_types_unittest.cc' object='google/protobuf/protobuf_test-well_known_types_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-well_known_types_unittest.o `test -f 'google/protobuf/well_known_types_unittest.cc' || echo '$(srcdir)/'`google/protobuf/well_known_types_unittest.cc\n\ngoogle/protobuf/protobuf_test-well_known_types_unittest.obj: google/protobuf/well_known_types_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-well_known_types_unittest.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-well_known_types_unittest.Tpo -c -o google/protobuf/protobuf_test-well_known_types_unittest.obj `if test -f 'google/protobuf/well_known_types_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/well_known_types_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/well_known_types_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-well_known_types_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-well_known_types_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/well_known_types_unittest.cc' object='google/protobuf/protobuf_test-well_known_types_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-well_known_types_unittest.obj `if test -f 'google/protobuf/well_known_types_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/well_known_types_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/well_known_types_unittest.cc'; fi`\n\ngoogle/protobuf/protobuf_test-wire_format_unittest.o: google/protobuf/wire_format_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-wire_format_unittest.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-wire_format_unittest.Tpo -c -o google/protobuf/protobuf_test-wire_format_unittest.o `test -f 'google/protobuf/wire_format_unittest.cc' || echo '$(srcdir)/'`google/protobuf/wire_format_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-wire_format_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-wire_format_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/wire_format_unittest.cc' object='google/protobuf/protobuf_test-wire_format_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-wire_format_unittest.o `test -f 'google/protobuf/wire_format_unittest.cc' || echo '$(srcdir)/'`google/protobuf/wire_format_unittest.cc\n\ngoogle/protobuf/protobuf_test-wire_format_unittest.obj: google/protobuf/wire_format_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-wire_format_unittest.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-wire_format_unittest.Tpo -c -o google/protobuf/protobuf_test-wire_format_unittest.obj `if test -f 'google/protobuf/wire_format_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/wire_format_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/wire_format_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-wire_format_unittest.Tpo google/protobuf/$(DEPDIR)/protobuf_test-wire_format_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/wire_format_unittest.cc' object='google/protobuf/protobuf_test-wire_format_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-wire_format_unittest.obj `if test -f 'google/protobuf/wire_format_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/wire_format_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/wire_format_unittest.cc'; fi`\n\ngoogle/protobuf/io/protobuf_test-coded_stream_unittest.o: google/protobuf/io/coded_stream_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/io/protobuf_test-coded_stream_unittest.o -MD -MP -MF google/protobuf/io/$(DEPDIR)/protobuf_test-coded_stream_unittest.Tpo -c -o google/protobuf/io/protobuf_test-coded_stream_unittest.o `test -f 'google/protobuf/io/coded_stream_unittest.cc' || echo '$(srcdir)/'`google/protobuf/io/coded_stream_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/io/$(DEPDIR)/protobuf_test-coded_stream_unittest.Tpo google/protobuf/io/$(DEPDIR)/protobuf_test-coded_stream_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/io/coded_stream_unittest.cc' object='google/protobuf/io/protobuf_test-coded_stream_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/io/protobuf_test-coded_stream_unittest.o `test -f 'google/protobuf/io/coded_stream_unittest.cc' || echo '$(srcdir)/'`google/protobuf/io/coded_stream_unittest.cc\n\ngoogle/protobuf/io/protobuf_test-coded_stream_unittest.obj: google/protobuf/io/coded_stream_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/io/protobuf_test-coded_stream_unittest.obj -MD -MP -MF google/protobuf/io/$(DEPDIR)/protobuf_test-coded_stream_unittest.Tpo -c -o google/protobuf/io/protobuf_test-coded_stream_unittest.obj `if test -f 'google/protobuf/io/coded_stream_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/io/coded_stream_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/io/coded_stream_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/io/$(DEPDIR)/protobuf_test-coded_stream_unittest.Tpo google/protobuf/io/$(DEPDIR)/protobuf_test-coded_stream_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/io/coded_stream_unittest.cc' object='google/protobuf/io/protobuf_test-coded_stream_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/io/protobuf_test-coded_stream_unittest.obj `if test -f 'google/protobuf/io/coded_stream_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/io/coded_stream_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/io/coded_stream_unittest.cc'; fi`\n\ngoogle/protobuf/io/protobuf_test-printer_unittest.o: google/protobuf/io/printer_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/io/protobuf_test-printer_unittest.o -MD -MP -MF google/protobuf/io/$(DEPDIR)/protobuf_test-printer_unittest.Tpo -c -o google/protobuf/io/protobuf_test-printer_unittest.o `test -f 'google/protobuf/io/printer_unittest.cc' || echo '$(srcdir)/'`google/protobuf/io/printer_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/io/$(DEPDIR)/protobuf_test-printer_unittest.Tpo google/protobuf/io/$(DEPDIR)/protobuf_test-printer_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/io/printer_unittest.cc' object='google/protobuf/io/protobuf_test-printer_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/io/protobuf_test-printer_unittest.o `test -f 'google/protobuf/io/printer_unittest.cc' || echo '$(srcdir)/'`google/protobuf/io/printer_unittest.cc\n\ngoogle/protobuf/io/protobuf_test-printer_unittest.obj: google/protobuf/io/printer_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/io/protobuf_test-printer_unittest.obj -MD -MP -MF google/protobuf/io/$(DEPDIR)/protobuf_test-printer_unittest.Tpo -c -o google/protobuf/io/protobuf_test-printer_unittest.obj `if test -f 'google/protobuf/io/printer_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/io/printer_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/io/printer_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/io/$(DEPDIR)/protobuf_test-printer_unittest.Tpo google/protobuf/io/$(DEPDIR)/protobuf_test-printer_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/io/printer_unittest.cc' object='google/protobuf/io/protobuf_test-printer_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/io/protobuf_test-printer_unittest.obj `if test -f 'google/protobuf/io/printer_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/io/printer_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/io/printer_unittest.cc'; fi`\n\ngoogle/protobuf/io/protobuf_test-tokenizer_unittest.o: google/protobuf/io/tokenizer_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/io/protobuf_test-tokenizer_unittest.o -MD -MP -MF google/protobuf/io/$(DEPDIR)/protobuf_test-tokenizer_unittest.Tpo -c -o google/protobuf/io/protobuf_test-tokenizer_unittest.o `test -f 'google/protobuf/io/tokenizer_unittest.cc' || echo '$(srcdir)/'`google/protobuf/io/tokenizer_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/io/$(DEPDIR)/protobuf_test-tokenizer_unittest.Tpo google/protobuf/io/$(DEPDIR)/protobuf_test-tokenizer_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/io/tokenizer_unittest.cc' object='google/protobuf/io/protobuf_test-tokenizer_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/io/protobuf_test-tokenizer_unittest.o `test -f 'google/protobuf/io/tokenizer_unittest.cc' || echo '$(srcdir)/'`google/protobuf/io/tokenizer_unittest.cc\n\ngoogle/protobuf/io/protobuf_test-tokenizer_unittest.obj: google/protobuf/io/tokenizer_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/io/protobuf_test-tokenizer_unittest.obj -MD -MP -MF google/protobuf/io/$(DEPDIR)/protobuf_test-tokenizer_unittest.Tpo -c -o google/protobuf/io/protobuf_test-tokenizer_unittest.obj `if test -f 'google/protobuf/io/tokenizer_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/io/tokenizer_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/io/tokenizer_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/io/$(DEPDIR)/protobuf_test-tokenizer_unittest.Tpo google/protobuf/io/$(DEPDIR)/protobuf_test-tokenizer_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/io/tokenizer_unittest.cc' object='google/protobuf/io/protobuf_test-tokenizer_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/io/protobuf_test-tokenizer_unittest.obj `if test -f 'google/protobuf/io/tokenizer_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/io/tokenizer_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/io/tokenizer_unittest.cc'; fi`\n\ngoogle/protobuf/io/protobuf_test-zero_copy_stream_unittest.o: google/protobuf/io/zero_copy_stream_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/io/protobuf_test-zero_copy_stream_unittest.o -MD -MP -MF google/protobuf/io/$(DEPDIR)/protobuf_test-zero_copy_stream_unittest.Tpo -c -o google/protobuf/io/protobuf_test-zero_copy_stream_unittest.o `test -f 'google/protobuf/io/zero_copy_stream_unittest.cc' || echo '$(srcdir)/'`google/protobuf/io/zero_copy_stream_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/io/$(DEPDIR)/protobuf_test-zero_copy_stream_unittest.Tpo google/protobuf/io/$(DEPDIR)/protobuf_test-zero_copy_stream_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/io/zero_copy_stream_unittest.cc' object='google/protobuf/io/protobuf_test-zero_copy_stream_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/io/protobuf_test-zero_copy_stream_unittest.o `test -f 'google/protobuf/io/zero_copy_stream_unittest.cc' || echo '$(srcdir)/'`google/protobuf/io/zero_copy_stream_unittest.cc\n\ngoogle/protobuf/io/protobuf_test-zero_copy_stream_unittest.obj: google/protobuf/io/zero_copy_stream_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/io/protobuf_test-zero_copy_stream_unittest.obj -MD -MP -MF google/protobuf/io/$(DEPDIR)/protobuf_test-zero_copy_stream_unittest.Tpo -c -o google/protobuf/io/protobuf_test-zero_copy_stream_unittest.obj `if test -f 'google/protobuf/io/zero_copy_stream_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/io/zero_copy_stream_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/io/zero_copy_stream_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/io/$(DEPDIR)/protobuf_test-zero_copy_stream_unittest.Tpo google/protobuf/io/$(DEPDIR)/protobuf_test-zero_copy_stream_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/io/zero_copy_stream_unittest.cc' object='google/protobuf/io/protobuf_test-zero_copy_stream_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/io/protobuf_test-zero_copy_stream_unittest.obj `if test -f 'google/protobuf/io/zero_copy_stream_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/io/zero_copy_stream_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/io/zero_copy_stream_unittest.cc'; fi`\n\ngoogle/protobuf/compiler/protobuf_test-command_line_interface_unittest.o: google/protobuf/compiler/command_line_interface_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/protobuf_test-command_line_interface_unittest.o -MD -MP -MF google/protobuf/compiler/$(DEPDIR)/protobuf_test-command_line_interface_unittest.Tpo -c -o google/protobuf/compiler/protobuf_test-command_line_interface_unittest.o `test -f 'google/protobuf/compiler/command_line_interface_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/command_line_interface_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/$(DEPDIR)/protobuf_test-command_line_interface_unittest.Tpo google/protobuf/compiler/$(DEPDIR)/protobuf_test-command_line_interface_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/command_line_interface_unittest.cc' object='google/protobuf/compiler/protobuf_test-command_line_interface_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/protobuf_test-command_line_interface_unittest.o `test -f 'google/protobuf/compiler/command_line_interface_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/command_line_interface_unittest.cc\n\ngoogle/protobuf/compiler/protobuf_test-command_line_interface_unittest.obj: google/protobuf/compiler/command_line_interface_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/protobuf_test-command_line_interface_unittest.obj -MD -MP -MF google/protobuf/compiler/$(DEPDIR)/protobuf_test-command_line_interface_unittest.Tpo -c -o google/protobuf/compiler/protobuf_test-command_line_interface_unittest.obj `if test -f 'google/protobuf/compiler/command_line_interface_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/command_line_interface_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/command_line_interface_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/$(DEPDIR)/protobuf_test-command_line_interface_unittest.Tpo google/protobuf/compiler/$(DEPDIR)/protobuf_test-command_line_interface_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/command_line_interface_unittest.cc' object='google/protobuf/compiler/protobuf_test-command_line_interface_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/protobuf_test-command_line_interface_unittest.obj `if test -f 'google/protobuf/compiler/command_line_interface_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/command_line_interface_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/command_line_interface_unittest.cc'; fi`\n\ngoogle/protobuf/compiler/protobuf_test-importer_unittest.o: google/protobuf/compiler/importer_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/protobuf_test-importer_unittest.o -MD -MP -MF google/protobuf/compiler/$(DEPDIR)/protobuf_test-importer_unittest.Tpo -c -o google/protobuf/compiler/protobuf_test-importer_unittest.o `test -f 'google/protobuf/compiler/importer_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/importer_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/$(DEPDIR)/protobuf_test-importer_unittest.Tpo google/protobuf/compiler/$(DEPDIR)/protobuf_test-importer_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/importer_unittest.cc' object='google/protobuf/compiler/protobuf_test-importer_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/protobuf_test-importer_unittest.o `test -f 'google/protobuf/compiler/importer_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/importer_unittest.cc\n\ngoogle/protobuf/compiler/protobuf_test-importer_unittest.obj: google/protobuf/compiler/importer_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/protobuf_test-importer_unittest.obj -MD -MP -MF google/protobuf/compiler/$(DEPDIR)/protobuf_test-importer_unittest.Tpo -c -o google/protobuf/compiler/protobuf_test-importer_unittest.obj `if test -f 'google/protobuf/compiler/importer_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/importer_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/importer_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/$(DEPDIR)/protobuf_test-importer_unittest.Tpo google/protobuf/compiler/$(DEPDIR)/protobuf_test-importer_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/importer_unittest.cc' object='google/protobuf/compiler/protobuf_test-importer_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/protobuf_test-importer_unittest.obj `if test -f 'google/protobuf/compiler/importer_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/importer_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/importer_unittest.cc'; fi`\n\ngoogle/protobuf/compiler/protobuf_test-mock_code_generator.o: google/protobuf/compiler/mock_code_generator.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/protobuf_test-mock_code_generator.o -MD -MP -MF google/protobuf/compiler/$(DEPDIR)/protobuf_test-mock_code_generator.Tpo -c -o google/protobuf/compiler/protobuf_test-mock_code_generator.o `test -f 'google/protobuf/compiler/mock_code_generator.cc' || echo '$(srcdir)/'`google/protobuf/compiler/mock_code_generator.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/$(DEPDIR)/protobuf_test-mock_code_generator.Tpo google/protobuf/compiler/$(DEPDIR)/protobuf_test-mock_code_generator.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/mock_code_generator.cc' object='google/protobuf/compiler/protobuf_test-mock_code_generator.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/protobuf_test-mock_code_generator.o `test -f 'google/protobuf/compiler/mock_code_generator.cc' || echo '$(srcdir)/'`google/protobuf/compiler/mock_code_generator.cc\n\ngoogle/protobuf/compiler/protobuf_test-mock_code_generator.obj: google/protobuf/compiler/mock_code_generator.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/protobuf_test-mock_code_generator.obj -MD -MP -MF google/protobuf/compiler/$(DEPDIR)/protobuf_test-mock_code_generator.Tpo -c -o google/protobuf/compiler/protobuf_test-mock_code_generator.obj `if test -f 'google/protobuf/compiler/mock_code_generator.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/mock_code_generator.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/mock_code_generator.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/$(DEPDIR)/protobuf_test-mock_code_generator.Tpo google/protobuf/compiler/$(DEPDIR)/protobuf_test-mock_code_generator.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/mock_code_generator.cc' object='google/protobuf/compiler/protobuf_test-mock_code_generator.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/protobuf_test-mock_code_generator.obj `if test -f 'google/protobuf/compiler/mock_code_generator.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/mock_code_generator.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/mock_code_generator.cc'; fi`\n\ngoogle/protobuf/compiler/protobuf_test-parser_unittest.o: google/protobuf/compiler/parser_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/protobuf_test-parser_unittest.o -MD -MP -MF google/protobuf/compiler/$(DEPDIR)/protobuf_test-parser_unittest.Tpo -c -o google/protobuf/compiler/protobuf_test-parser_unittest.o `test -f 'google/protobuf/compiler/parser_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/parser_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/$(DEPDIR)/protobuf_test-parser_unittest.Tpo google/protobuf/compiler/$(DEPDIR)/protobuf_test-parser_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/parser_unittest.cc' object='google/protobuf/compiler/protobuf_test-parser_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/protobuf_test-parser_unittest.o `test -f 'google/protobuf/compiler/parser_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/parser_unittest.cc\n\ngoogle/protobuf/compiler/protobuf_test-parser_unittest.obj: google/protobuf/compiler/parser_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/protobuf_test-parser_unittest.obj -MD -MP -MF google/protobuf/compiler/$(DEPDIR)/protobuf_test-parser_unittest.Tpo -c -o google/protobuf/compiler/protobuf_test-parser_unittest.obj `if test -f 'google/protobuf/compiler/parser_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/parser_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/parser_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/$(DEPDIR)/protobuf_test-parser_unittest.Tpo google/protobuf/compiler/$(DEPDIR)/protobuf_test-parser_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/parser_unittest.cc' object='google/protobuf/compiler/protobuf_test-parser_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/protobuf_test-parser_unittest.obj `if test -f 'google/protobuf/compiler/parser_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/parser_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/parser_unittest.cc'; fi`\n\ngoogle/protobuf/compiler/cpp/protobuf_test-cpp_bootstrap_unittest.o: google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/cpp/protobuf_test-cpp_bootstrap_unittest.o -MD -MP -MF google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_bootstrap_unittest.Tpo -c -o google/protobuf/compiler/cpp/protobuf_test-cpp_bootstrap_unittest.o `test -f 'google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_bootstrap_unittest.Tpo google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_bootstrap_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc' object='google/protobuf/compiler/cpp/protobuf_test-cpp_bootstrap_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/cpp/protobuf_test-cpp_bootstrap_unittest.o `test -f 'google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc\n\ngoogle/protobuf/compiler/cpp/protobuf_test-cpp_bootstrap_unittest.obj: google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/cpp/protobuf_test-cpp_bootstrap_unittest.obj -MD -MP -MF google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_bootstrap_unittest.Tpo -c -o google/protobuf/compiler/cpp/protobuf_test-cpp_bootstrap_unittest.obj `if test -f 'google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_bootstrap_unittest.Tpo google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_bootstrap_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc' object='google/protobuf/compiler/cpp/protobuf_test-cpp_bootstrap_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/cpp/protobuf_test-cpp_bootstrap_unittest.obj `if test -f 'google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc'; fi`\n\ngoogle/protobuf/compiler/cpp/protobuf_test-cpp_unittest.o: google/protobuf/compiler/cpp/cpp_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/cpp/protobuf_test-cpp_unittest.o -MD -MP -MF google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_unittest.Tpo -c -o google/protobuf/compiler/cpp/protobuf_test-cpp_unittest.o `test -f 'google/protobuf/compiler/cpp/cpp_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/cpp/cpp_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_unittest.Tpo google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/cpp/cpp_unittest.cc' object='google/protobuf/compiler/cpp/protobuf_test-cpp_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/cpp/protobuf_test-cpp_unittest.o `test -f 'google/protobuf/compiler/cpp/cpp_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/cpp/cpp_unittest.cc\n\ngoogle/protobuf/compiler/cpp/protobuf_test-cpp_unittest.obj: google/protobuf/compiler/cpp/cpp_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/cpp/protobuf_test-cpp_unittest.obj -MD -MP -MF google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_unittest.Tpo -c -o google/protobuf/compiler/cpp/protobuf_test-cpp_unittest.obj `if test -f 'google/protobuf/compiler/cpp/cpp_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/cpp/cpp_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/cpp/cpp_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_unittest.Tpo google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/cpp/cpp_unittest.cc' object='google/protobuf/compiler/cpp/protobuf_test-cpp_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/cpp/protobuf_test-cpp_unittest.obj `if test -f 'google/protobuf/compiler/cpp/cpp_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/cpp/cpp_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/cpp/cpp_unittest.cc'; fi`\n\ngoogle/protobuf/compiler/cpp/protobuf_test-cpp_plugin_unittest.o: google/protobuf/compiler/cpp/cpp_plugin_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/cpp/protobuf_test-cpp_plugin_unittest.o -MD -MP -MF google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_plugin_unittest.Tpo -c -o google/protobuf/compiler/cpp/protobuf_test-cpp_plugin_unittest.o `test -f 'google/protobuf/compiler/cpp/cpp_plugin_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/cpp/cpp_plugin_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_plugin_unittest.Tpo google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_plugin_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/cpp/cpp_plugin_unittest.cc' object='google/protobuf/compiler/cpp/protobuf_test-cpp_plugin_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/cpp/protobuf_test-cpp_plugin_unittest.o `test -f 'google/protobuf/compiler/cpp/cpp_plugin_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/cpp/cpp_plugin_unittest.cc\n\ngoogle/protobuf/compiler/cpp/protobuf_test-cpp_plugin_unittest.obj: google/protobuf/compiler/cpp/cpp_plugin_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/cpp/protobuf_test-cpp_plugin_unittest.obj -MD -MP -MF google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_plugin_unittest.Tpo -c -o google/protobuf/compiler/cpp/protobuf_test-cpp_plugin_unittest.obj `if test -f 'google/protobuf/compiler/cpp/cpp_plugin_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/cpp/cpp_plugin_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_plugin_unittest.Tpo google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_plugin_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/cpp/cpp_plugin_unittest.cc' object='google/protobuf/compiler/cpp/protobuf_test-cpp_plugin_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/cpp/protobuf_test-cpp_plugin_unittest.obj `if test -f 'google/protobuf/compiler/cpp/cpp_plugin_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/cpp/cpp_plugin_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc'; fi`\n\ngoogle/protobuf/compiler/cpp/protobuf_test-metadata_test.o: google/protobuf/compiler/cpp/metadata_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/cpp/protobuf_test-metadata_test.o -MD -MP -MF google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-metadata_test.Tpo -c -o google/protobuf/compiler/cpp/protobuf_test-metadata_test.o `test -f 'google/protobuf/compiler/cpp/metadata_test.cc' || echo '$(srcdir)/'`google/protobuf/compiler/cpp/metadata_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-metadata_test.Tpo google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-metadata_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/cpp/metadata_test.cc' object='google/protobuf/compiler/cpp/protobuf_test-metadata_test.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/cpp/protobuf_test-metadata_test.o `test -f 'google/protobuf/compiler/cpp/metadata_test.cc' || echo '$(srcdir)/'`google/protobuf/compiler/cpp/metadata_test.cc\n\ngoogle/protobuf/compiler/cpp/protobuf_test-metadata_test.obj: google/protobuf/compiler/cpp/metadata_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/cpp/protobuf_test-metadata_test.obj -MD -MP -MF google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-metadata_test.Tpo -c -o google/protobuf/compiler/cpp/protobuf_test-metadata_test.obj `if test -f 'google/protobuf/compiler/cpp/metadata_test.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/cpp/metadata_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/cpp/metadata_test.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-metadata_test.Tpo google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-metadata_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/cpp/metadata_test.cc' object='google/protobuf/compiler/cpp/protobuf_test-metadata_test.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/cpp/protobuf_test-metadata_test.obj `if test -f 'google/protobuf/compiler/cpp/metadata_test.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/cpp/metadata_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/cpp/metadata_test.cc'; fi`\n\ngoogle/protobuf/compiler/java/protobuf_test-java_plugin_unittest.o: google/protobuf/compiler/java/java_plugin_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/java/protobuf_test-java_plugin_unittest.o -MD -MP -MF google/protobuf/compiler/java/$(DEPDIR)/protobuf_test-java_plugin_unittest.Tpo -c -o google/protobuf/compiler/java/protobuf_test-java_plugin_unittest.o `test -f 'google/protobuf/compiler/java/java_plugin_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/java/java_plugin_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/java/$(DEPDIR)/protobuf_test-java_plugin_unittest.Tpo google/protobuf/compiler/java/$(DEPDIR)/protobuf_test-java_plugin_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/java/java_plugin_unittest.cc' object='google/protobuf/compiler/java/protobuf_test-java_plugin_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/java/protobuf_test-java_plugin_unittest.o `test -f 'google/protobuf/compiler/java/java_plugin_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/java/java_plugin_unittest.cc\n\ngoogle/protobuf/compiler/java/protobuf_test-java_plugin_unittest.obj: google/protobuf/compiler/java/java_plugin_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/java/protobuf_test-java_plugin_unittest.obj -MD -MP -MF google/protobuf/compiler/java/$(DEPDIR)/protobuf_test-java_plugin_unittest.Tpo -c -o google/protobuf/compiler/java/protobuf_test-java_plugin_unittest.obj `if test -f 'google/protobuf/compiler/java/java_plugin_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/java/java_plugin_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/java/java_plugin_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/java/$(DEPDIR)/protobuf_test-java_plugin_unittest.Tpo google/protobuf/compiler/java/$(DEPDIR)/protobuf_test-java_plugin_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/java/java_plugin_unittest.cc' object='google/protobuf/compiler/java/protobuf_test-java_plugin_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/java/protobuf_test-java_plugin_unittest.obj `if test -f 'google/protobuf/compiler/java/java_plugin_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/java/java_plugin_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/java/java_plugin_unittest.cc'; fi`\n\ngoogle/protobuf/compiler/java/protobuf_test-java_doc_comment_unittest.o: google/protobuf/compiler/java/java_doc_comment_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/java/protobuf_test-java_doc_comment_unittest.o -MD -MP -MF google/protobuf/compiler/java/$(DEPDIR)/protobuf_test-java_doc_comment_unittest.Tpo -c -o google/protobuf/compiler/java/protobuf_test-java_doc_comment_unittest.o `test -f 'google/protobuf/compiler/java/java_doc_comment_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/java/java_doc_comment_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/java/$(DEPDIR)/protobuf_test-java_doc_comment_unittest.Tpo google/protobuf/compiler/java/$(DEPDIR)/protobuf_test-java_doc_comment_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/java/java_doc_comment_unittest.cc' object='google/protobuf/compiler/java/protobuf_test-java_doc_comment_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/java/protobuf_test-java_doc_comment_unittest.o `test -f 'google/protobuf/compiler/java/java_doc_comment_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/java/java_doc_comment_unittest.cc\n\ngoogle/protobuf/compiler/java/protobuf_test-java_doc_comment_unittest.obj: google/protobuf/compiler/java/java_doc_comment_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/java/protobuf_test-java_doc_comment_unittest.obj -MD -MP -MF google/protobuf/compiler/java/$(DEPDIR)/protobuf_test-java_doc_comment_unittest.Tpo -c -o google/protobuf/compiler/java/protobuf_test-java_doc_comment_unittest.obj `if test -f 'google/protobuf/compiler/java/java_doc_comment_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/java/java_doc_comment_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/java/java_doc_comment_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/java/$(DEPDIR)/protobuf_test-java_doc_comment_unittest.Tpo google/protobuf/compiler/java/$(DEPDIR)/protobuf_test-java_doc_comment_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/java/java_doc_comment_unittest.cc' object='google/protobuf/compiler/java/protobuf_test-java_doc_comment_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/java/protobuf_test-java_doc_comment_unittest.obj `if test -f 'google/protobuf/compiler/java/java_doc_comment_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/java/java_doc_comment_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/java/java_doc_comment_unittest.cc'; fi`\n\ngoogle/protobuf/compiler/objectivec/protobuf_test-objectivec_helpers_unittest.o: google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/objectivec/protobuf_test-objectivec_helpers_unittest.o -MD -MP -MF google/protobuf/compiler/objectivec/$(DEPDIR)/protobuf_test-objectivec_helpers_unittest.Tpo -c -o google/protobuf/compiler/objectivec/protobuf_test-objectivec_helpers_unittest.o `test -f 'google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/objectivec/$(DEPDIR)/protobuf_test-objectivec_helpers_unittest.Tpo google/protobuf/compiler/objectivec/$(DEPDIR)/protobuf_test-objectivec_helpers_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc' object='google/protobuf/compiler/objectivec/protobuf_test-objectivec_helpers_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/objectivec/protobuf_test-objectivec_helpers_unittest.o `test -f 'google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc\n\ngoogle/protobuf/compiler/objectivec/protobuf_test-objectivec_helpers_unittest.obj: google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/objectivec/protobuf_test-objectivec_helpers_unittest.obj -MD -MP -MF google/protobuf/compiler/objectivec/$(DEPDIR)/protobuf_test-objectivec_helpers_unittest.Tpo -c -o google/protobuf/compiler/objectivec/protobuf_test-objectivec_helpers_unittest.obj `if test -f 'google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/objectivec/$(DEPDIR)/protobuf_test-objectivec_helpers_unittest.Tpo google/protobuf/compiler/objectivec/$(DEPDIR)/protobuf_test-objectivec_helpers_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc' object='google/protobuf/compiler/objectivec/protobuf_test-objectivec_helpers_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/objectivec/protobuf_test-objectivec_helpers_unittest.obj `if test -f 'google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc'; fi`\n\ngoogle/protobuf/compiler/python/protobuf_test-python_plugin_unittest.o: google/protobuf/compiler/python/python_plugin_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/python/protobuf_test-python_plugin_unittest.o -MD -MP -MF google/protobuf/compiler/python/$(DEPDIR)/protobuf_test-python_plugin_unittest.Tpo -c -o google/protobuf/compiler/python/protobuf_test-python_plugin_unittest.o `test -f 'google/protobuf/compiler/python/python_plugin_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/python/python_plugin_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/python/$(DEPDIR)/protobuf_test-python_plugin_unittest.Tpo google/protobuf/compiler/python/$(DEPDIR)/protobuf_test-python_plugin_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/python/python_plugin_unittest.cc' object='google/protobuf/compiler/python/protobuf_test-python_plugin_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/python/protobuf_test-python_plugin_unittest.o `test -f 'google/protobuf/compiler/python/python_plugin_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/python/python_plugin_unittest.cc\n\ngoogle/protobuf/compiler/python/protobuf_test-python_plugin_unittest.obj: google/protobuf/compiler/python/python_plugin_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/python/protobuf_test-python_plugin_unittest.obj -MD -MP -MF google/protobuf/compiler/python/$(DEPDIR)/protobuf_test-python_plugin_unittest.Tpo -c -o google/protobuf/compiler/python/protobuf_test-python_plugin_unittest.obj `if test -f 'google/protobuf/compiler/python/python_plugin_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/python/python_plugin_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/python/python_plugin_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/python/$(DEPDIR)/protobuf_test-python_plugin_unittest.Tpo google/protobuf/compiler/python/$(DEPDIR)/protobuf_test-python_plugin_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/python/python_plugin_unittest.cc' object='google/protobuf/compiler/python/protobuf_test-python_plugin_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/python/protobuf_test-python_plugin_unittest.obj `if test -f 'google/protobuf/compiler/python/python_plugin_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/python/python_plugin_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/python/python_plugin_unittest.cc'; fi`\n\ngoogle/protobuf/compiler/ruby/protobuf_test-ruby_generator_unittest.o: google/protobuf/compiler/ruby/ruby_generator_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/ruby/protobuf_test-ruby_generator_unittest.o -MD -MP -MF google/protobuf/compiler/ruby/$(DEPDIR)/protobuf_test-ruby_generator_unittest.Tpo -c -o google/protobuf/compiler/ruby/protobuf_test-ruby_generator_unittest.o `test -f 'google/protobuf/compiler/ruby/ruby_generator_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/ruby/ruby_generator_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/ruby/$(DEPDIR)/protobuf_test-ruby_generator_unittest.Tpo google/protobuf/compiler/ruby/$(DEPDIR)/protobuf_test-ruby_generator_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/ruby/ruby_generator_unittest.cc' object='google/protobuf/compiler/ruby/protobuf_test-ruby_generator_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/ruby/protobuf_test-ruby_generator_unittest.o `test -f 'google/protobuf/compiler/ruby/ruby_generator_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/ruby/ruby_generator_unittest.cc\n\ngoogle/protobuf/compiler/ruby/protobuf_test-ruby_generator_unittest.obj: google/protobuf/compiler/ruby/ruby_generator_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/ruby/protobuf_test-ruby_generator_unittest.obj -MD -MP -MF google/protobuf/compiler/ruby/$(DEPDIR)/protobuf_test-ruby_generator_unittest.Tpo -c -o google/protobuf/compiler/ruby/protobuf_test-ruby_generator_unittest.obj `if test -f 'google/protobuf/compiler/ruby/ruby_generator_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/ruby/ruby_generator_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/ruby/ruby_generator_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/ruby/$(DEPDIR)/protobuf_test-ruby_generator_unittest.Tpo google/protobuf/compiler/ruby/$(DEPDIR)/protobuf_test-ruby_generator_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/ruby/ruby_generator_unittest.cc' object='google/protobuf/compiler/ruby/protobuf_test-ruby_generator_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/ruby/protobuf_test-ruby_generator_unittest.obj `if test -f 'google/protobuf/compiler/ruby/ruby_generator_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/ruby/ruby_generator_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/ruby/ruby_generator_unittest.cc'; fi`\n\ngoogle/protobuf/compiler/csharp/protobuf_test-csharp_generator_unittest.o: google/protobuf/compiler/csharp/csharp_generator_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/csharp/protobuf_test-csharp_generator_unittest.o -MD -MP -MF google/protobuf/compiler/csharp/$(DEPDIR)/protobuf_test-csharp_generator_unittest.Tpo -c -o google/protobuf/compiler/csharp/protobuf_test-csharp_generator_unittest.o `test -f 'google/protobuf/compiler/csharp/csharp_generator_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/csharp/csharp_generator_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/csharp/$(DEPDIR)/protobuf_test-csharp_generator_unittest.Tpo google/protobuf/compiler/csharp/$(DEPDIR)/protobuf_test-csharp_generator_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/csharp/csharp_generator_unittest.cc' object='google/protobuf/compiler/csharp/protobuf_test-csharp_generator_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/csharp/protobuf_test-csharp_generator_unittest.o `test -f 'google/protobuf/compiler/csharp/csharp_generator_unittest.cc' || echo '$(srcdir)/'`google/protobuf/compiler/csharp/csharp_generator_unittest.cc\n\ngoogle/protobuf/compiler/csharp/protobuf_test-csharp_generator_unittest.obj: google/protobuf/compiler/csharp/csharp_generator_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/csharp/protobuf_test-csharp_generator_unittest.obj -MD -MP -MF google/protobuf/compiler/csharp/$(DEPDIR)/protobuf_test-csharp_generator_unittest.Tpo -c -o google/protobuf/compiler/csharp/protobuf_test-csharp_generator_unittest.obj `if test -f 'google/protobuf/compiler/csharp/csharp_generator_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/csharp/csharp_generator_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/csharp/csharp_generator_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/csharp/$(DEPDIR)/protobuf_test-csharp_generator_unittest.Tpo google/protobuf/compiler/csharp/$(DEPDIR)/protobuf_test-csharp_generator_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/csharp/csharp_generator_unittest.cc' object='google/protobuf/compiler/csharp/protobuf_test-csharp_generator_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/csharp/protobuf_test-csharp_generator_unittest.obj `if test -f 'google/protobuf/compiler/csharp/csharp_generator_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/csharp/csharp_generator_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/csharp/csharp_generator_unittest.cc'; fi`\n\ngoogle/protobuf/util/protobuf_test-field_comparator_test.o: google/protobuf/util/field_comparator_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/protobuf_test-field_comparator_test.o -MD -MP -MF google/protobuf/util/$(DEPDIR)/protobuf_test-field_comparator_test.Tpo -c -o google/protobuf/util/protobuf_test-field_comparator_test.o `test -f 'google/protobuf/util/field_comparator_test.cc' || echo '$(srcdir)/'`google/protobuf/util/field_comparator_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/protobuf_test-field_comparator_test.Tpo google/protobuf/util/$(DEPDIR)/protobuf_test-field_comparator_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/field_comparator_test.cc' object='google/protobuf/util/protobuf_test-field_comparator_test.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/protobuf_test-field_comparator_test.o `test -f 'google/protobuf/util/field_comparator_test.cc' || echo '$(srcdir)/'`google/protobuf/util/field_comparator_test.cc\n\ngoogle/protobuf/util/protobuf_test-field_comparator_test.obj: google/protobuf/util/field_comparator_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/protobuf_test-field_comparator_test.obj -MD -MP -MF google/protobuf/util/$(DEPDIR)/protobuf_test-field_comparator_test.Tpo -c -o google/protobuf/util/protobuf_test-field_comparator_test.obj `if test -f 'google/protobuf/util/field_comparator_test.cc'; then $(CYGPATH_W) 'google/protobuf/util/field_comparator_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/field_comparator_test.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/protobuf_test-field_comparator_test.Tpo google/protobuf/util/$(DEPDIR)/protobuf_test-field_comparator_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/field_comparator_test.cc' object='google/protobuf/util/protobuf_test-field_comparator_test.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/protobuf_test-field_comparator_test.obj `if test -f 'google/protobuf/util/field_comparator_test.cc'; then $(CYGPATH_W) 'google/protobuf/util/field_comparator_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/field_comparator_test.cc'; fi`\n\ngoogle/protobuf/util/protobuf_test-field_mask_util_test.o: google/protobuf/util/field_mask_util_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/protobuf_test-field_mask_util_test.o -MD -MP -MF google/protobuf/util/$(DEPDIR)/protobuf_test-field_mask_util_test.Tpo -c -o google/protobuf/util/protobuf_test-field_mask_util_test.o `test -f 'google/protobuf/util/field_mask_util_test.cc' || echo '$(srcdir)/'`google/protobuf/util/field_mask_util_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/protobuf_test-field_mask_util_test.Tpo google/protobuf/util/$(DEPDIR)/protobuf_test-field_mask_util_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/field_mask_util_test.cc' object='google/protobuf/util/protobuf_test-field_mask_util_test.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/protobuf_test-field_mask_util_test.o `test -f 'google/protobuf/util/field_mask_util_test.cc' || echo '$(srcdir)/'`google/protobuf/util/field_mask_util_test.cc\n\ngoogle/protobuf/util/protobuf_test-field_mask_util_test.obj: google/protobuf/util/field_mask_util_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/protobuf_test-field_mask_util_test.obj -MD -MP -MF google/protobuf/util/$(DEPDIR)/protobuf_test-field_mask_util_test.Tpo -c -o google/protobuf/util/protobuf_test-field_mask_util_test.obj `if test -f 'google/protobuf/util/field_mask_util_test.cc'; then $(CYGPATH_W) 'google/protobuf/util/field_mask_util_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/field_mask_util_test.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/protobuf_test-field_mask_util_test.Tpo google/protobuf/util/$(DEPDIR)/protobuf_test-field_mask_util_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/field_mask_util_test.cc' object='google/protobuf/util/protobuf_test-field_mask_util_test.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/protobuf_test-field_mask_util_test.obj `if test -f 'google/protobuf/util/field_mask_util_test.cc'; then $(CYGPATH_W) 'google/protobuf/util/field_mask_util_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/field_mask_util_test.cc'; fi`\n\ngoogle/protobuf/util/internal/protobuf_test-default_value_objectwriter_test.o: google/protobuf/util/internal/default_value_objectwriter_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/protobuf_test-default_value_objectwriter_test.o -MD -MP -MF google/protobuf/util/internal/$(DEPDIR)/protobuf_test-default_value_objectwriter_test.Tpo -c -o google/protobuf/util/internal/protobuf_test-default_value_objectwriter_test.o `test -f 'google/protobuf/util/internal/default_value_objectwriter_test.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/default_value_objectwriter_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/$(DEPDIR)/protobuf_test-default_value_objectwriter_test.Tpo google/protobuf/util/internal/$(DEPDIR)/protobuf_test-default_value_objectwriter_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/default_value_objectwriter_test.cc' object='google/protobuf/util/internal/protobuf_test-default_value_objectwriter_test.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/protobuf_test-default_value_objectwriter_test.o `test -f 'google/protobuf/util/internal/default_value_objectwriter_test.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/default_value_objectwriter_test.cc\n\ngoogle/protobuf/util/internal/protobuf_test-default_value_objectwriter_test.obj: google/protobuf/util/internal/default_value_objectwriter_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/protobuf_test-default_value_objectwriter_test.obj -MD -MP -MF google/protobuf/util/internal/$(DEPDIR)/protobuf_test-default_value_objectwriter_test.Tpo -c -o google/protobuf/util/internal/protobuf_test-default_value_objectwriter_test.obj `if test -f 'google/protobuf/util/internal/default_value_objectwriter_test.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/default_value_objectwriter_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/default_value_objectwriter_test.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/$(DEPDIR)/protobuf_test-default_value_objectwriter_test.Tpo google/protobuf/util/internal/$(DEPDIR)/protobuf_test-default_value_objectwriter_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/default_value_objectwriter_test.cc' object='google/protobuf/util/internal/protobuf_test-default_value_objectwriter_test.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/protobuf_test-default_value_objectwriter_test.obj `if test -f 'google/protobuf/util/internal/default_value_objectwriter_test.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/default_value_objectwriter_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/default_value_objectwriter_test.cc'; fi`\n\ngoogle/protobuf/util/internal/protobuf_test-json_objectwriter_test.o: google/protobuf/util/internal/json_objectwriter_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/protobuf_test-json_objectwriter_test.o -MD -MP -MF google/protobuf/util/internal/$(DEPDIR)/protobuf_test-json_objectwriter_test.Tpo -c -o google/protobuf/util/internal/protobuf_test-json_objectwriter_test.o `test -f 'google/protobuf/util/internal/json_objectwriter_test.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/json_objectwriter_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/$(DEPDIR)/protobuf_test-json_objectwriter_test.Tpo google/protobuf/util/internal/$(DEPDIR)/protobuf_test-json_objectwriter_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/json_objectwriter_test.cc' object='google/protobuf/util/internal/protobuf_test-json_objectwriter_test.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/protobuf_test-json_objectwriter_test.o `test -f 'google/protobuf/util/internal/json_objectwriter_test.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/json_objectwriter_test.cc\n\ngoogle/protobuf/util/internal/protobuf_test-json_objectwriter_test.obj: google/protobuf/util/internal/json_objectwriter_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/protobuf_test-json_objectwriter_test.obj -MD -MP -MF google/protobuf/util/internal/$(DEPDIR)/protobuf_test-json_objectwriter_test.Tpo -c -o google/protobuf/util/internal/protobuf_test-json_objectwriter_test.obj `if test -f 'google/protobuf/util/internal/json_objectwriter_test.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/json_objectwriter_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/json_objectwriter_test.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/$(DEPDIR)/protobuf_test-json_objectwriter_test.Tpo google/protobuf/util/internal/$(DEPDIR)/protobuf_test-json_objectwriter_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/json_objectwriter_test.cc' object='google/protobuf/util/internal/protobuf_test-json_objectwriter_test.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/protobuf_test-json_objectwriter_test.obj `if test -f 'google/protobuf/util/internal/json_objectwriter_test.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/json_objectwriter_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/json_objectwriter_test.cc'; fi`\n\ngoogle/protobuf/util/internal/protobuf_test-json_stream_parser_test.o: google/protobuf/util/internal/json_stream_parser_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/protobuf_test-json_stream_parser_test.o -MD -MP -MF google/protobuf/util/internal/$(DEPDIR)/protobuf_test-json_stream_parser_test.Tpo -c -o google/protobuf/util/internal/protobuf_test-json_stream_parser_test.o `test -f 'google/protobuf/util/internal/json_stream_parser_test.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/json_stream_parser_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/$(DEPDIR)/protobuf_test-json_stream_parser_test.Tpo google/protobuf/util/internal/$(DEPDIR)/protobuf_test-json_stream_parser_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/json_stream_parser_test.cc' object='google/protobuf/util/internal/protobuf_test-json_stream_parser_test.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/protobuf_test-json_stream_parser_test.o `test -f 'google/protobuf/util/internal/json_stream_parser_test.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/json_stream_parser_test.cc\n\ngoogle/protobuf/util/internal/protobuf_test-json_stream_parser_test.obj: google/protobuf/util/internal/json_stream_parser_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/protobuf_test-json_stream_parser_test.obj -MD -MP -MF google/protobuf/util/internal/$(DEPDIR)/protobuf_test-json_stream_parser_test.Tpo -c -o google/protobuf/util/internal/protobuf_test-json_stream_parser_test.obj `if test -f 'google/protobuf/util/internal/json_stream_parser_test.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/json_stream_parser_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/json_stream_parser_test.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/$(DEPDIR)/protobuf_test-json_stream_parser_test.Tpo google/protobuf/util/internal/$(DEPDIR)/protobuf_test-json_stream_parser_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/json_stream_parser_test.cc' object='google/protobuf/util/internal/protobuf_test-json_stream_parser_test.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/protobuf_test-json_stream_parser_test.obj `if test -f 'google/protobuf/util/internal/json_stream_parser_test.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/json_stream_parser_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/json_stream_parser_test.cc'; fi`\n\ngoogle/protobuf/util/internal/protobuf_test-protostream_objectsource_test.o: google/protobuf/util/internal/protostream_objectsource_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/protobuf_test-protostream_objectsource_test.o -MD -MP -MF google/protobuf/util/internal/$(DEPDIR)/protobuf_test-protostream_objectsource_test.Tpo -c -o google/protobuf/util/internal/protobuf_test-protostream_objectsource_test.o `test -f 'google/protobuf/util/internal/protostream_objectsource_test.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/protostream_objectsource_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/$(DEPDIR)/protobuf_test-protostream_objectsource_test.Tpo google/protobuf/util/internal/$(DEPDIR)/protobuf_test-protostream_objectsource_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/protostream_objectsource_test.cc' object='google/protobuf/util/internal/protobuf_test-protostream_objectsource_test.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/protobuf_test-protostream_objectsource_test.o `test -f 'google/protobuf/util/internal/protostream_objectsource_test.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/protostream_objectsource_test.cc\n\ngoogle/protobuf/util/internal/protobuf_test-protostream_objectsource_test.obj: google/protobuf/util/internal/protostream_objectsource_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/protobuf_test-protostream_objectsource_test.obj -MD -MP -MF google/protobuf/util/internal/$(DEPDIR)/protobuf_test-protostream_objectsource_test.Tpo -c -o google/protobuf/util/internal/protobuf_test-protostream_objectsource_test.obj `if test -f 'google/protobuf/util/internal/protostream_objectsource_test.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/protostream_objectsource_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/protostream_objectsource_test.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/$(DEPDIR)/protobuf_test-protostream_objectsource_test.Tpo google/protobuf/util/internal/$(DEPDIR)/protobuf_test-protostream_objectsource_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/protostream_objectsource_test.cc' object='google/protobuf/util/internal/protobuf_test-protostream_objectsource_test.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/protobuf_test-protostream_objectsource_test.obj `if test -f 'google/protobuf/util/internal/protostream_objectsource_test.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/protostream_objectsource_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/protostream_objectsource_test.cc'; fi`\n\ngoogle/protobuf/util/internal/protobuf_test-protostream_objectwriter_test.o: google/protobuf/util/internal/protostream_objectwriter_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/protobuf_test-protostream_objectwriter_test.o -MD -MP -MF google/protobuf/util/internal/$(DEPDIR)/protobuf_test-protostream_objectwriter_test.Tpo -c -o google/protobuf/util/internal/protobuf_test-protostream_objectwriter_test.o `test -f 'google/protobuf/util/internal/protostream_objectwriter_test.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/protostream_objectwriter_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/$(DEPDIR)/protobuf_test-protostream_objectwriter_test.Tpo google/protobuf/util/internal/$(DEPDIR)/protobuf_test-protostream_objectwriter_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/protostream_objectwriter_test.cc' object='google/protobuf/util/internal/protobuf_test-protostream_objectwriter_test.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/protobuf_test-protostream_objectwriter_test.o `test -f 'google/protobuf/util/internal/protostream_objectwriter_test.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/protostream_objectwriter_test.cc\n\ngoogle/protobuf/util/internal/protobuf_test-protostream_objectwriter_test.obj: google/protobuf/util/internal/protostream_objectwriter_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/protobuf_test-protostream_objectwriter_test.obj -MD -MP -MF google/protobuf/util/internal/$(DEPDIR)/protobuf_test-protostream_objectwriter_test.Tpo -c -o google/protobuf/util/internal/protobuf_test-protostream_objectwriter_test.obj `if test -f 'google/protobuf/util/internal/protostream_objectwriter_test.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/protostream_objectwriter_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/protostream_objectwriter_test.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/$(DEPDIR)/protobuf_test-protostream_objectwriter_test.Tpo google/protobuf/util/internal/$(DEPDIR)/protobuf_test-protostream_objectwriter_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/protostream_objectwriter_test.cc' object='google/protobuf/util/internal/protobuf_test-protostream_objectwriter_test.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/protobuf_test-protostream_objectwriter_test.obj `if test -f 'google/protobuf/util/internal/protostream_objectwriter_test.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/protostream_objectwriter_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/protostream_objectwriter_test.cc'; fi`\n\ngoogle/protobuf/util/internal/protobuf_test-type_info_test_helper.o: google/protobuf/util/internal/type_info_test_helper.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/protobuf_test-type_info_test_helper.o -MD -MP -MF google/protobuf/util/internal/$(DEPDIR)/protobuf_test-type_info_test_helper.Tpo -c -o google/protobuf/util/internal/protobuf_test-type_info_test_helper.o `test -f 'google/protobuf/util/internal/type_info_test_helper.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/type_info_test_helper.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/$(DEPDIR)/protobuf_test-type_info_test_helper.Tpo google/protobuf/util/internal/$(DEPDIR)/protobuf_test-type_info_test_helper.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/type_info_test_helper.cc' object='google/protobuf/util/internal/protobuf_test-type_info_test_helper.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/protobuf_test-type_info_test_helper.o `test -f 'google/protobuf/util/internal/type_info_test_helper.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/type_info_test_helper.cc\n\ngoogle/protobuf/util/internal/protobuf_test-type_info_test_helper.obj: google/protobuf/util/internal/type_info_test_helper.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/protobuf_test-type_info_test_helper.obj -MD -MP -MF google/protobuf/util/internal/$(DEPDIR)/protobuf_test-type_info_test_helper.Tpo -c -o google/protobuf/util/internal/protobuf_test-type_info_test_helper.obj `if test -f 'google/protobuf/util/internal/type_info_test_helper.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/type_info_test_helper.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/type_info_test_helper.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/$(DEPDIR)/protobuf_test-type_info_test_helper.Tpo google/protobuf/util/internal/$(DEPDIR)/protobuf_test-type_info_test_helper.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/type_info_test_helper.cc' object='google/protobuf/util/internal/protobuf_test-type_info_test_helper.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/protobuf_test-type_info_test_helper.obj `if test -f 'google/protobuf/util/internal/type_info_test_helper.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/type_info_test_helper.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/type_info_test_helper.cc'; fi`\n\ngoogle/protobuf/util/protobuf_test-json_util_test.o: google/protobuf/util/json_util_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/protobuf_test-json_util_test.o -MD -MP -MF google/protobuf/util/$(DEPDIR)/protobuf_test-json_util_test.Tpo -c -o google/protobuf/util/protobuf_test-json_util_test.o `test -f 'google/protobuf/util/json_util_test.cc' || echo '$(srcdir)/'`google/protobuf/util/json_util_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/protobuf_test-json_util_test.Tpo google/protobuf/util/$(DEPDIR)/protobuf_test-json_util_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/json_util_test.cc' object='google/protobuf/util/protobuf_test-json_util_test.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/protobuf_test-json_util_test.o `test -f 'google/protobuf/util/json_util_test.cc' || echo '$(srcdir)/'`google/protobuf/util/json_util_test.cc\n\ngoogle/protobuf/util/protobuf_test-json_util_test.obj: google/protobuf/util/json_util_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/protobuf_test-json_util_test.obj -MD -MP -MF google/protobuf/util/$(DEPDIR)/protobuf_test-json_util_test.Tpo -c -o google/protobuf/util/protobuf_test-json_util_test.obj `if test -f 'google/protobuf/util/json_util_test.cc'; then $(CYGPATH_W) 'google/protobuf/util/json_util_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/json_util_test.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/protobuf_test-json_util_test.Tpo google/protobuf/util/$(DEPDIR)/protobuf_test-json_util_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/json_util_test.cc' object='google/protobuf/util/protobuf_test-json_util_test.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/protobuf_test-json_util_test.obj `if test -f 'google/protobuf/util/json_util_test.cc'; then $(CYGPATH_W) 'google/protobuf/util/json_util_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/json_util_test.cc'; fi`\n\ngoogle/protobuf/util/protobuf_test-message_differencer_unittest.o: google/protobuf/util/message_differencer_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/protobuf_test-message_differencer_unittest.o -MD -MP -MF google/protobuf/util/$(DEPDIR)/protobuf_test-message_differencer_unittest.Tpo -c -o google/protobuf/util/protobuf_test-message_differencer_unittest.o `test -f 'google/protobuf/util/message_differencer_unittest.cc' || echo '$(srcdir)/'`google/protobuf/util/message_differencer_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/protobuf_test-message_differencer_unittest.Tpo google/protobuf/util/$(DEPDIR)/protobuf_test-message_differencer_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/message_differencer_unittest.cc' object='google/protobuf/util/protobuf_test-message_differencer_unittest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/protobuf_test-message_differencer_unittest.o `test -f 'google/protobuf/util/message_differencer_unittest.cc' || echo '$(srcdir)/'`google/protobuf/util/message_differencer_unittest.cc\n\ngoogle/protobuf/util/protobuf_test-message_differencer_unittest.obj: google/protobuf/util/message_differencer_unittest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/protobuf_test-message_differencer_unittest.obj -MD -MP -MF google/protobuf/util/$(DEPDIR)/protobuf_test-message_differencer_unittest.Tpo -c -o google/protobuf/util/protobuf_test-message_differencer_unittest.obj `if test -f 'google/protobuf/util/message_differencer_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/util/message_differencer_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/message_differencer_unittest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/protobuf_test-message_differencer_unittest.Tpo google/protobuf/util/$(DEPDIR)/protobuf_test-message_differencer_unittest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/message_differencer_unittest.cc' object='google/protobuf/util/protobuf_test-message_differencer_unittest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/protobuf_test-message_differencer_unittest.obj `if test -f 'google/protobuf/util/message_differencer_unittest.cc'; then $(CYGPATH_W) 'google/protobuf/util/message_differencer_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/message_differencer_unittest.cc'; fi`\n\ngoogle/protobuf/util/protobuf_test-time_util_test.o: google/protobuf/util/time_util_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/protobuf_test-time_util_test.o -MD -MP -MF google/protobuf/util/$(DEPDIR)/protobuf_test-time_util_test.Tpo -c -o google/protobuf/util/protobuf_test-time_util_test.o `test -f 'google/protobuf/util/time_util_test.cc' || echo '$(srcdir)/'`google/protobuf/util/time_util_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/protobuf_test-time_util_test.Tpo google/protobuf/util/$(DEPDIR)/protobuf_test-time_util_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/time_util_test.cc' object='google/protobuf/util/protobuf_test-time_util_test.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/protobuf_test-time_util_test.o `test -f 'google/protobuf/util/time_util_test.cc' || echo '$(srcdir)/'`google/protobuf/util/time_util_test.cc\n\ngoogle/protobuf/util/protobuf_test-time_util_test.obj: google/protobuf/util/time_util_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/protobuf_test-time_util_test.obj -MD -MP -MF google/protobuf/util/$(DEPDIR)/protobuf_test-time_util_test.Tpo -c -o google/protobuf/util/protobuf_test-time_util_test.obj `if test -f 'google/protobuf/util/time_util_test.cc'; then $(CYGPATH_W) 'google/protobuf/util/time_util_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/time_util_test.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/protobuf_test-time_util_test.Tpo google/protobuf/util/$(DEPDIR)/protobuf_test-time_util_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/time_util_test.cc' object='google/protobuf/util/protobuf_test-time_util_test.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/protobuf_test-time_util_test.obj `if test -f 'google/protobuf/util/time_util_test.cc'; then $(CYGPATH_W) 'google/protobuf/util/time_util_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/time_util_test.cc'; fi`\n\ngoogle/protobuf/util/protobuf_test-type_resolver_util_test.o: google/protobuf/util/type_resolver_util_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/protobuf_test-type_resolver_util_test.o -MD -MP -MF google/protobuf/util/$(DEPDIR)/protobuf_test-type_resolver_util_test.Tpo -c -o google/protobuf/util/protobuf_test-type_resolver_util_test.o `test -f 'google/protobuf/util/type_resolver_util_test.cc' || echo '$(srcdir)/'`google/protobuf/util/type_resolver_util_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/protobuf_test-type_resolver_util_test.Tpo google/protobuf/util/$(DEPDIR)/protobuf_test-type_resolver_util_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/type_resolver_util_test.cc' object='google/protobuf/util/protobuf_test-type_resolver_util_test.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/protobuf_test-type_resolver_util_test.o `test -f 'google/protobuf/util/type_resolver_util_test.cc' || echo '$(srcdir)/'`google/protobuf/util/type_resolver_util_test.cc\n\ngoogle/protobuf/util/protobuf_test-type_resolver_util_test.obj: google/protobuf/util/type_resolver_util_test.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/protobuf_test-type_resolver_util_test.obj -MD -MP -MF google/protobuf/util/$(DEPDIR)/protobuf_test-type_resolver_util_test.Tpo -c -o google/protobuf/util/protobuf_test-type_resolver_util_test.obj `if test -f 'google/protobuf/util/type_resolver_util_test.cc'; then $(CYGPATH_W) 'google/protobuf/util/type_resolver_util_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/type_resolver_util_test.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/protobuf_test-type_resolver_util_test.Tpo google/protobuf/util/$(DEPDIR)/protobuf_test-type_resolver_util_test.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/type_resolver_util_test.cc' object='google/protobuf/util/protobuf_test-type_resolver_util_test.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/protobuf_test-type_resolver_util_test.obj `if test -f 'google/protobuf/util/type_resolver_util_test.cc'; then $(CYGPATH_W) 'google/protobuf/util/type_resolver_util_test.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/type_resolver_util_test.cc'; fi`\n\ngoogle/protobuf/protobuf_test-arena_test_util.o: google/protobuf/arena_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-arena_test_util.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-arena_test_util.Tpo -c -o google/protobuf/protobuf_test-arena_test_util.o `test -f 'google/protobuf/arena_test_util.cc' || echo '$(srcdir)/'`google/protobuf/arena_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-arena_test_util.Tpo google/protobuf/$(DEPDIR)/protobuf_test-arena_test_util.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/arena_test_util.cc' object='google/protobuf/protobuf_test-arena_test_util.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-arena_test_util.o `test -f 'google/protobuf/arena_test_util.cc' || echo '$(srcdir)/'`google/protobuf/arena_test_util.cc\n\ngoogle/protobuf/protobuf_test-arena_test_util.obj: google/protobuf/arena_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-arena_test_util.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-arena_test_util.Tpo -c -o google/protobuf/protobuf_test-arena_test_util.obj `if test -f 'google/protobuf/arena_test_util.cc'; then $(CYGPATH_W) 'google/protobuf/arena_test_util.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/arena_test_util.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-arena_test_util.Tpo google/protobuf/$(DEPDIR)/protobuf_test-arena_test_util.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/arena_test_util.cc' object='google/protobuf/protobuf_test-arena_test_util.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-arena_test_util.obj `if test -f 'google/protobuf/arena_test_util.cc'; then $(CYGPATH_W) 'google/protobuf/arena_test_util.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/arena_test_util.cc'; fi`\n\ngoogle/protobuf/protobuf_test-map_test_util.o: google/protobuf/map_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-map_test_util.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-map_test_util.Tpo -c -o google/protobuf/protobuf_test-map_test_util.o `test -f 'google/protobuf/map_test_util.cc' || echo '$(srcdir)/'`google/protobuf/map_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-map_test_util.Tpo google/protobuf/$(DEPDIR)/protobuf_test-map_test_util.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_test_util.cc' object='google/protobuf/protobuf_test-map_test_util.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-map_test_util.o `test -f 'google/protobuf/map_test_util.cc' || echo '$(srcdir)/'`google/protobuf/map_test_util.cc\n\ngoogle/protobuf/protobuf_test-map_test_util.obj: google/protobuf/map_test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-map_test_util.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-map_test_util.Tpo -c -o google/protobuf/protobuf_test-map_test_util.obj `if test -f 'google/protobuf/map_test_util.cc'; then $(CYGPATH_W) 'google/protobuf/map_test_util.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_test_util.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-map_test_util.Tpo google/protobuf/$(DEPDIR)/protobuf_test-map_test_util.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_test_util.cc' object='google/protobuf/protobuf_test-map_test_util.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-map_test_util.obj `if test -f 'google/protobuf/map_test_util.cc'; then $(CYGPATH_W) 'google/protobuf/map_test_util.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_test_util.cc'; fi`\n\ngoogle/protobuf/protobuf_test-test_util.o: google/protobuf/test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-test_util.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-test_util.Tpo -c -o google/protobuf/protobuf_test-test_util.o `test -f 'google/protobuf/test_util.cc' || echo '$(srcdir)/'`google/protobuf/test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-test_util.Tpo google/protobuf/$(DEPDIR)/protobuf_test-test_util.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/test_util.cc' object='google/protobuf/protobuf_test-test_util.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-test_util.o `test -f 'google/protobuf/test_util.cc' || echo '$(srcdir)/'`google/protobuf/test_util.cc\n\ngoogle/protobuf/protobuf_test-test_util.obj: google/protobuf/test_util.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-test_util.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-test_util.Tpo -c -o google/protobuf/protobuf_test-test_util.obj `if test -f 'google/protobuf/test_util.cc'; then $(CYGPATH_W) 'google/protobuf/test_util.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/test_util.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-test_util.Tpo google/protobuf/$(DEPDIR)/protobuf_test-test_util.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/test_util.cc' object='google/protobuf/protobuf_test-test_util.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-test_util.obj `if test -f 'google/protobuf/test_util.cc'; then $(CYGPATH_W) 'google/protobuf/test_util.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/test_util.cc'; fi`\n\ngoogle/protobuf/testing/protobuf_test-googletest.o: google/protobuf/testing/googletest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/testing/protobuf_test-googletest.o -MD -MP -MF google/protobuf/testing/$(DEPDIR)/protobuf_test-googletest.Tpo -c -o google/protobuf/testing/protobuf_test-googletest.o `test -f 'google/protobuf/testing/googletest.cc' || echo '$(srcdir)/'`google/protobuf/testing/googletest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/testing/$(DEPDIR)/protobuf_test-googletest.Tpo google/protobuf/testing/$(DEPDIR)/protobuf_test-googletest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/testing/googletest.cc' object='google/protobuf/testing/protobuf_test-googletest.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/testing/protobuf_test-googletest.o `test -f 'google/protobuf/testing/googletest.cc' || echo '$(srcdir)/'`google/protobuf/testing/googletest.cc\n\ngoogle/protobuf/testing/protobuf_test-googletest.obj: google/protobuf/testing/googletest.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/testing/protobuf_test-googletest.obj -MD -MP -MF google/protobuf/testing/$(DEPDIR)/protobuf_test-googletest.Tpo -c -o google/protobuf/testing/protobuf_test-googletest.obj `if test -f 'google/protobuf/testing/googletest.cc'; then $(CYGPATH_W) 'google/protobuf/testing/googletest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/testing/googletest.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/testing/$(DEPDIR)/protobuf_test-googletest.Tpo google/protobuf/testing/$(DEPDIR)/protobuf_test-googletest.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/testing/googletest.cc' object='google/protobuf/testing/protobuf_test-googletest.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/testing/protobuf_test-googletest.obj `if test -f 'google/protobuf/testing/googletest.cc'; then $(CYGPATH_W) 'google/protobuf/testing/googletest.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/testing/googletest.cc'; fi`\n\ngoogle/protobuf/testing/protobuf_test-file.o: google/protobuf/testing/file.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/testing/protobuf_test-file.o -MD -MP -MF google/protobuf/testing/$(DEPDIR)/protobuf_test-file.Tpo -c -o google/protobuf/testing/protobuf_test-file.o `test -f 'google/protobuf/testing/file.cc' || echo '$(srcdir)/'`google/protobuf/testing/file.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/testing/$(DEPDIR)/protobuf_test-file.Tpo google/protobuf/testing/$(DEPDIR)/protobuf_test-file.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/testing/file.cc' object='google/protobuf/testing/protobuf_test-file.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/testing/protobuf_test-file.o `test -f 'google/protobuf/testing/file.cc' || echo '$(srcdir)/'`google/protobuf/testing/file.cc\n\ngoogle/protobuf/testing/protobuf_test-file.obj: google/protobuf/testing/file.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/testing/protobuf_test-file.obj -MD -MP -MF google/protobuf/testing/$(DEPDIR)/protobuf_test-file.Tpo -c -o google/protobuf/testing/protobuf_test-file.obj `if test -f 'google/protobuf/testing/file.cc'; then $(CYGPATH_W) 'google/protobuf/testing/file.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/testing/file.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/testing/$(DEPDIR)/protobuf_test-file.Tpo google/protobuf/testing/$(DEPDIR)/protobuf_test-file.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/testing/file.cc' object='google/protobuf/testing/protobuf_test-file.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/testing/protobuf_test-file.obj `if test -f 'google/protobuf/testing/file.cc'; then $(CYGPATH_W) 'google/protobuf/testing/file.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/testing/file.cc'; fi`\n\ngoogle/protobuf/protobuf_test-map_lite_unittest.pb.o: google/protobuf/map_lite_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-map_lite_unittest.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-map_lite_unittest.pb.Tpo -c -o google/protobuf/protobuf_test-map_lite_unittest.pb.o `test -f 'google/protobuf/map_lite_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/map_lite_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-map_lite_unittest.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-map_lite_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_lite_unittest.pb.cc' object='google/protobuf/protobuf_test-map_lite_unittest.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-map_lite_unittest.pb.o `test -f 'google/protobuf/map_lite_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/map_lite_unittest.pb.cc\n\ngoogle/protobuf/protobuf_test-map_lite_unittest.pb.obj: google/protobuf/map_lite_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-map_lite_unittest.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-map_lite_unittest.pb.Tpo -c -o google/protobuf/protobuf_test-map_lite_unittest.pb.obj `if test -f 'google/protobuf/map_lite_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/map_lite_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_lite_unittest.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-map_lite_unittest.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-map_lite_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_lite_unittest.pb.cc' object='google/protobuf/protobuf_test-map_lite_unittest.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-map_lite_unittest.pb.obj `if test -f 'google/protobuf/map_lite_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/map_lite_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_lite_unittest.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_lite.pb.o: google/protobuf/unittest_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_lite.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_lite.pb.o `test -f 'google/protobuf/unittest_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_lite.pb.cc' object='google/protobuf/protobuf_test-unittest_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_lite.pb.o `test -f 'google/protobuf/unittest_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_lite.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_lite.pb.obj: google/protobuf/unittest_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_lite.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_lite.pb.obj `if test -f 'google/protobuf/unittest_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_lite.pb.cc' object='google/protobuf/protobuf_test-unittest_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_lite.pb.obj `if test -f 'google/protobuf/unittest_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_lite.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_no_arena_lite.pb.o: google/protobuf/unittest_no_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_no_arena_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_arena_lite.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_no_arena_lite.pb.o `test -f 'google/protobuf/unittest_no_arena_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_arena_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_arena_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_arena_lite.pb.cc' object='google/protobuf/protobuf_test-unittest_no_arena_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_no_arena_lite.pb.o `test -f 'google/protobuf/unittest_no_arena_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_arena_lite.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_no_arena_lite.pb.obj: google/protobuf/unittest_no_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_no_arena_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_arena_lite.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_no_arena_lite.pb.obj `if test -f 'google/protobuf/unittest_no_arena_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_arena_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_arena_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_arena_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_arena_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_arena_lite.pb.cc' object='google/protobuf/protobuf_test-unittest_no_arena_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_no_arena_lite.pb.obj `if test -f 'google/protobuf/unittest_no_arena_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_arena_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_arena_lite.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_import_lite.pb.o: google/protobuf/unittest_import_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_import_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_import_lite.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_import_lite.pb.o `test -f 'google/protobuf/unittest_import_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_import_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_import_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_lite.pb.cc' object='google/protobuf/protobuf_test-unittest_import_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_import_lite.pb.o `test -f 'google/protobuf/unittest_import_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_lite.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_import_lite.pb.obj: google/protobuf/unittest_import_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_import_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_import_lite.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_import_lite.pb.obj `if test -f 'google/protobuf/unittest_import_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_import_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_import_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_lite.pb.cc' object='google/protobuf/protobuf_test-unittest_import_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_import_lite.pb.obj `if test -f 'google/protobuf/unittest_import_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_lite.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_import_public_lite.pb.o: google/protobuf/unittest_import_public_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_import_public_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_import_public_lite.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_import_public_lite.pb.o `test -f 'google/protobuf/unittest_import_public_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_public_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_import_public_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_import_public_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_public_lite.pb.cc' object='google/protobuf/protobuf_test-unittest_import_public_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_import_public_lite.pb.o `test -f 'google/protobuf/unittest_import_public_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_public_lite.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_import_public_lite.pb.obj: google/protobuf/unittest_import_public_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_import_public_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_import_public_lite.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_import_public_lite.pb.obj `if test -f 'google/protobuf/unittest_import_public_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_public_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_public_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_import_public_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_import_public_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_public_lite.pb.cc' object='google/protobuf/protobuf_test-unittest_import_public_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_import_public_lite.pb.obj `if test -f 'google/protobuf/unittest_import_public_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_public_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_public_lite.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-any_test.pb.o: google/protobuf/any_test.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-any_test.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-any_test.pb.Tpo -c -o google/protobuf/protobuf_test-any_test.pb.o `test -f 'google/protobuf/any_test.pb.cc' || echo '$(srcdir)/'`google/protobuf/any_test.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-any_test.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-any_test.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/any_test.pb.cc' object='google/protobuf/protobuf_test-any_test.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-any_test.pb.o `test -f 'google/protobuf/any_test.pb.cc' || echo '$(srcdir)/'`google/protobuf/any_test.pb.cc\n\ngoogle/protobuf/protobuf_test-any_test.pb.obj: google/protobuf/any_test.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-any_test.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-any_test.pb.Tpo -c -o google/protobuf/protobuf_test-any_test.pb.obj `if test -f 'google/protobuf/any_test.pb.cc'; then $(CYGPATH_W) 'google/protobuf/any_test.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/any_test.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-any_test.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-any_test.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/any_test.pb.cc' object='google/protobuf/protobuf_test-any_test.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-any_test.pb.obj `if test -f 'google/protobuf/any_test.pb.cc'; then $(CYGPATH_W) 'google/protobuf/any_test.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/any_test.pb.cc'; fi`\n\ngoogle/protobuf/compiler/cpp/protobuf_test-cpp_test_bad_identifiers.pb.o: google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/cpp/protobuf_test-cpp_test_bad_identifiers.pb.o -MD -MP -MF google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_test_bad_identifiers.pb.Tpo -c -o google/protobuf/compiler/cpp/protobuf_test-cpp_test_bad_identifiers.pb.o `test -f 'google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc' || echo '$(srcdir)/'`google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_test_bad_identifiers.pb.Tpo google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_test_bad_identifiers.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc' object='google/protobuf/compiler/cpp/protobuf_test-cpp_test_bad_identifiers.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/cpp/protobuf_test-cpp_test_bad_identifiers.pb.o `test -f 'google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc' || echo '$(srcdir)/'`google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc\n\ngoogle/protobuf/compiler/cpp/protobuf_test-cpp_test_bad_identifiers.pb.obj: google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/cpp/protobuf_test-cpp_test_bad_identifiers.pb.obj -MD -MP -MF google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_test_bad_identifiers.pb.Tpo -c -o google/protobuf/compiler/cpp/protobuf_test-cpp_test_bad_identifiers.pb.obj `if test -f 'google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_test_bad_identifiers.pb.Tpo google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_test_bad_identifiers.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc' object='google/protobuf/compiler/cpp/protobuf_test-cpp_test_bad_identifiers.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/cpp/protobuf_test-cpp_test_bad_identifiers.pb.obj `if test -f 'google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.cc'; fi`\n\ngoogle/protobuf/compiler/cpp/protobuf_test-cpp_test_large_enum_value.pb.o: google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/cpp/protobuf_test-cpp_test_large_enum_value.pb.o -MD -MP -MF google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_test_large_enum_value.pb.Tpo -c -o google/protobuf/compiler/cpp/protobuf_test-cpp_test_large_enum_value.pb.o `test -f 'google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc' || echo '$(srcdir)/'`google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_test_large_enum_value.pb.Tpo google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_test_large_enum_value.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc' object='google/protobuf/compiler/cpp/protobuf_test-cpp_test_large_enum_value.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/cpp/protobuf_test-cpp_test_large_enum_value.pb.o `test -f 'google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc' || echo '$(srcdir)/'`google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc\n\ngoogle/protobuf/compiler/cpp/protobuf_test-cpp_test_large_enum_value.pb.obj: google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/cpp/protobuf_test-cpp_test_large_enum_value.pb.obj -MD -MP -MF google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_test_large_enum_value.pb.Tpo -c -o google/protobuf/compiler/cpp/protobuf_test-cpp_test_large_enum_value.pb.obj `if test -f 'google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_test_large_enum_value.pb.Tpo google/protobuf/compiler/cpp/$(DEPDIR)/protobuf_test-cpp_test_large_enum_value.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc' object='google/protobuf/compiler/cpp/protobuf_test-cpp_test_large_enum_value.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/cpp/protobuf_test-cpp_test_large_enum_value.pb.obj `if test -f 'google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/cpp/cpp_test_large_enum_value.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-map_proto2_unittest.pb.o: google/protobuf/map_proto2_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-map_proto2_unittest.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-map_proto2_unittest.pb.Tpo -c -o google/protobuf/protobuf_test-map_proto2_unittest.pb.o `test -f 'google/protobuf/map_proto2_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/map_proto2_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-map_proto2_unittest.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-map_proto2_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_proto2_unittest.pb.cc' object='google/protobuf/protobuf_test-map_proto2_unittest.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-map_proto2_unittest.pb.o `test -f 'google/protobuf/map_proto2_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/map_proto2_unittest.pb.cc\n\ngoogle/protobuf/protobuf_test-map_proto2_unittest.pb.obj: google/protobuf/map_proto2_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-map_proto2_unittest.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-map_proto2_unittest.pb.Tpo -c -o google/protobuf/protobuf_test-map_proto2_unittest.pb.obj `if test -f 'google/protobuf/map_proto2_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/map_proto2_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_proto2_unittest.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-map_proto2_unittest.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-map_proto2_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_proto2_unittest.pb.cc' object='google/protobuf/protobuf_test-map_proto2_unittest.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-map_proto2_unittest.pb.obj `if test -f 'google/protobuf/map_proto2_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/map_proto2_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_proto2_unittest.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-map_unittest.pb.o: google/protobuf/map_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-map_unittest.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-map_unittest.pb.Tpo -c -o google/protobuf/protobuf_test-map_unittest.pb.o `test -f 'google/protobuf/map_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/map_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-map_unittest.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-map_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_unittest.pb.cc' object='google/protobuf/protobuf_test-map_unittest.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-map_unittest.pb.o `test -f 'google/protobuf/map_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/map_unittest.pb.cc\n\ngoogle/protobuf/protobuf_test-map_unittest.pb.obj: google/protobuf/map_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-map_unittest.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-map_unittest.pb.Tpo -c -o google/protobuf/protobuf_test-map_unittest.pb.obj `if test -f 'google/protobuf/map_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/map_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_unittest.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-map_unittest.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-map_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/map_unittest.pb.cc' object='google/protobuf/protobuf_test-map_unittest.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-map_unittest.pb.obj `if test -f 'google/protobuf/map_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/map_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/map_unittest.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_arena.pb.o: google/protobuf/unittest_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_arena.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_arena.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_arena.pb.o `test -f 'google/protobuf/unittest_arena.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_arena.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_arena.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_arena.pb.cc' object='google/protobuf/protobuf_test-unittest_arena.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_arena.pb.o `test -f 'google/protobuf/unittest_arena.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_arena.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_arena.pb.obj: google/protobuf/unittest_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_arena.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_arena.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_arena.pb.obj `if test -f 'google/protobuf/unittest_arena.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_arena.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_arena.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_arena.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_arena.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_arena.pb.cc' object='google/protobuf/protobuf_test-unittest_arena.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_arena.pb.obj `if test -f 'google/protobuf/unittest_arena.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_arena.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_arena.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_custom_options.pb.o: google/protobuf/unittest_custom_options.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_custom_options.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_custom_options.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_custom_options.pb.o `test -f 'google/protobuf/unittest_custom_options.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_custom_options.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_custom_options.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_custom_options.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_custom_options.pb.cc' object='google/protobuf/protobuf_test-unittest_custom_options.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_custom_options.pb.o `test -f 'google/protobuf/unittest_custom_options.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_custom_options.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_custom_options.pb.obj: google/protobuf/unittest_custom_options.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_custom_options.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_custom_options.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_custom_options.pb.obj `if test -f 'google/protobuf/unittest_custom_options.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_custom_options.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_custom_options.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_custom_options.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_custom_options.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_custom_options.pb.cc' object='google/protobuf/protobuf_test-unittest_custom_options.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_custom_options.pb.obj `if test -f 'google/protobuf/unittest_custom_options.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_custom_options.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_custom_options.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_drop_unknown_fields.pb.o: google/protobuf/unittest_drop_unknown_fields.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_drop_unknown_fields.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_drop_unknown_fields.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_drop_unknown_fields.pb.o `test -f 'google/protobuf/unittest_drop_unknown_fields.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_drop_unknown_fields.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_drop_unknown_fields.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_drop_unknown_fields.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_drop_unknown_fields.pb.cc' object='google/protobuf/protobuf_test-unittest_drop_unknown_fields.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_drop_unknown_fields.pb.o `test -f 'google/protobuf/unittest_drop_unknown_fields.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_drop_unknown_fields.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_drop_unknown_fields.pb.obj: google/protobuf/unittest_drop_unknown_fields.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_drop_unknown_fields.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_drop_unknown_fields.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_drop_unknown_fields.pb.obj `if test -f 'google/protobuf/unittest_drop_unknown_fields.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_drop_unknown_fields.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_drop_unknown_fields.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_drop_unknown_fields.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_drop_unknown_fields.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_drop_unknown_fields.pb.cc' object='google/protobuf/protobuf_test-unittest_drop_unknown_fields.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_drop_unknown_fields.pb.obj `if test -f 'google/protobuf/unittest_drop_unknown_fields.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_drop_unknown_fields.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_drop_unknown_fields.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_embed_optimize_for.pb.o: google/protobuf/unittest_embed_optimize_for.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_embed_optimize_for.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_embed_optimize_for.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_embed_optimize_for.pb.o `test -f 'google/protobuf/unittest_embed_optimize_for.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_embed_optimize_for.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_embed_optimize_for.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_embed_optimize_for.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_embed_optimize_for.pb.cc' object='google/protobuf/protobuf_test-unittest_embed_optimize_for.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_embed_optimize_for.pb.o `test -f 'google/protobuf/unittest_embed_optimize_for.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_embed_optimize_for.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_embed_optimize_for.pb.obj: google/protobuf/unittest_embed_optimize_for.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_embed_optimize_for.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_embed_optimize_for.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_embed_optimize_for.pb.obj `if test -f 'google/protobuf/unittest_embed_optimize_for.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_embed_optimize_for.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_embed_optimize_for.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_embed_optimize_for.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_embed_optimize_for.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_embed_optimize_for.pb.cc' object='google/protobuf/protobuf_test-unittest_embed_optimize_for.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_embed_optimize_for.pb.obj `if test -f 'google/protobuf/unittest_embed_optimize_for.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_embed_optimize_for.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_embed_optimize_for.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_empty.pb.o: google/protobuf/unittest_empty.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_empty.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_empty.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_empty.pb.o `test -f 'google/protobuf/unittest_empty.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_empty.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_empty.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_empty.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_empty.pb.cc' object='google/protobuf/protobuf_test-unittest_empty.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_empty.pb.o `test -f 'google/protobuf/unittest_empty.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_empty.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_empty.pb.obj: google/protobuf/unittest_empty.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_empty.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_empty.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_empty.pb.obj `if test -f 'google/protobuf/unittest_empty.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_empty.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_empty.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_empty.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_empty.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_empty.pb.cc' object='google/protobuf/protobuf_test-unittest_empty.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_empty.pb.obj `if test -f 'google/protobuf/unittest_empty.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_empty.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_empty.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_enormous_descriptor.pb.o: google/protobuf/unittest_enormous_descriptor.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_enormous_descriptor.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_enormous_descriptor.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_enormous_descriptor.pb.o `test -f 'google/protobuf/unittest_enormous_descriptor.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_enormous_descriptor.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_enormous_descriptor.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_enormous_descriptor.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_enormous_descriptor.pb.cc' object='google/protobuf/protobuf_test-unittest_enormous_descriptor.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_enormous_descriptor.pb.o `test -f 'google/protobuf/unittest_enormous_descriptor.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_enormous_descriptor.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_enormous_descriptor.pb.obj: google/protobuf/unittest_enormous_descriptor.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_enormous_descriptor.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_enormous_descriptor.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_enormous_descriptor.pb.obj `if test -f 'google/protobuf/unittest_enormous_descriptor.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_enormous_descriptor.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_enormous_descriptor.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_enormous_descriptor.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_enormous_descriptor.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_enormous_descriptor.pb.cc' object='google/protobuf/protobuf_test-unittest_enormous_descriptor.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_enormous_descriptor.pb.obj `if test -f 'google/protobuf/unittest_enormous_descriptor.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_enormous_descriptor.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_enormous_descriptor.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_import.pb.o: google/protobuf/unittest_import.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_import.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_import.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_import.pb.o `test -f 'google/protobuf/unittest_import.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_import.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_import.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import.pb.cc' object='google/protobuf/protobuf_test-unittest_import.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_import.pb.o `test -f 'google/protobuf/unittest_import.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_import.pb.obj: google/protobuf/unittest_import.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_import.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_import.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_import.pb.obj `if test -f 'google/protobuf/unittest_import.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_import.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_import.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import.pb.cc' object='google/protobuf/protobuf_test-unittest_import.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_import.pb.obj `if test -f 'google/protobuf/unittest_import.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_import_public.pb.o: google/protobuf/unittest_import_public.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_import_public.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_import_public.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_import_public.pb.o `test -f 'google/protobuf/unittest_import_public.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_public.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_import_public.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_import_public.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_public.pb.cc' object='google/protobuf/protobuf_test-unittest_import_public.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_import_public.pb.o `test -f 'google/protobuf/unittest_import_public.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_import_public.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_import_public.pb.obj: google/protobuf/unittest_import_public.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_import_public.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_import_public.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_import_public.pb.obj `if test -f 'google/protobuf/unittest_import_public.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_public.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_public.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_import_public.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_import_public.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_import_public.pb.cc' object='google/protobuf/protobuf_test-unittest_import_public.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_import_public.pb.obj `if test -f 'google/protobuf/unittest_import_public.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_import_public.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_import_public.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_lite_imports_nonlite.pb.o: google/protobuf/unittest_lite_imports_nonlite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_lite_imports_nonlite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_lite_imports_nonlite.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_lite_imports_nonlite.pb.o `test -f 'google/protobuf/unittest_lite_imports_nonlite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_lite_imports_nonlite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_lite_imports_nonlite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_lite_imports_nonlite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_lite_imports_nonlite.pb.cc' object='google/protobuf/protobuf_test-unittest_lite_imports_nonlite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_lite_imports_nonlite.pb.o `test -f 'google/protobuf/unittest_lite_imports_nonlite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_lite_imports_nonlite.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_lite_imports_nonlite.pb.obj: google/protobuf/unittest_lite_imports_nonlite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_lite_imports_nonlite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_lite_imports_nonlite.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_lite_imports_nonlite.pb.obj `if test -f 'google/protobuf/unittest_lite_imports_nonlite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_lite_imports_nonlite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_lite_imports_nonlite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_lite_imports_nonlite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_lite_imports_nonlite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_lite_imports_nonlite.pb.cc' object='google/protobuf/protobuf_test-unittest_lite_imports_nonlite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_lite_imports_nonlite.pb.obj `if test -f 'google/protobuf/unittest_lite_imports_nonlite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_lite_imports_nonlite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_lite_imports_nonlite.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_mset.pb.o: google/protobuf/unittest_mset.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_mset.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_mset.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_mset.pb.o `test -f 'google/protobuf/unittest_mset.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_mset.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_mset.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_mset.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_mset.pb.cc' object='google/protobuf/protobuf_test-unittest_mset.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_mset.pb.o `test -f 'google/protobuf/unittest_mset.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_mset.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_mset.pb.obj: google/protobuf/unittest_mset.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_mset.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_mset.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_mset.pb.obj `if test -f 'google/protobuf/unittest_mset.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_mset.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_mset.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_mset.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_mset.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_mset.pb.cc' object='google/protobuf/protobuf_test-unittest_mset.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_mset.pb.obj `if test -f 'google/protobuf/unittest_mset.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_mset.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_mset.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_mset_wire_format.pb.o: google/protobuf/unittest_mset_wire_format.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_mset_wire_format.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_mset_wire_format.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_mset_wire_format.pb.o `test -f 'google/protobuf/unittest_mset_wire_format.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_mset_wire_format.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_mset_wire_format.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_mset_wire_format.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_mset_wire_format.pb.cc' object='google/protobuf/protobuf_test-unittest_mset_wire_format.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_mset_wire_format.pb.o `test -f 'google/protobuf/unittest_mset_wire_format.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_mset_wire_format.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_mset_wire_format.pb.obj: google/protobuf/unittest_mset_wire_format.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_mset_wire_format.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_mset_wire_format.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_mset_wire_format.pb.obj `if test -f 'google/protobuf/unittest_mset_wire_format.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_mset_wire_format.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_mset_wire_format.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_mset_wire_format.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_mset_wire_format.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_mset_wire_format.pb.cc' object='google/protobuf/protobuf_test-unittest_mset_wire_format.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_mset_wire_format.pb.obj `if test -f 'google/protobuf/unittest_mset_wire_format.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_mset_wire_format.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_mset_wire_format.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_no_arena_import.pb.o: google/protobuf/unittest_no_arena_import.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_no_arena_import.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_arena_import.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_no_arena_import.pb.o `test -f 'google/protobuf/unittest_no_arena_import.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_arena_import.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_arena_import.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_arena_import.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_arena_import.pb.cc' object='google/protobuf/protobuf_test-unittest_no_arena_import.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_no_arena_import.pb.o `test -f 'google/protobuf/unittest_no_arena_import.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_arena_import.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_no_arena_import.pb.obj: google/protobuf/unittest_no_arena_import.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_no_arena_import.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_arena_import.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_no_arena_import.pb.obj `if test -f 'google/protobuf/unittest_no_arena_import.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_arena_import.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_arena_import.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_arena_import.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_arena_import.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_arena_import.pb.cc' object='google/protobuf/protobuf_test-unittest_no_arena_import.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_no_arena_import.pb.obj `if test -f 'google/protobuf/unittest_no_arena_import.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_arena_import.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_arena_import.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_no_arena.pb.o: google/protobuf/unittest_no_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_no_arena.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_arena.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_no_arena.pb.o `test -f 'google/protobuf/unittest_no_arena.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_arena.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_arena.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_arena.pb.cc' object='google/protobuf/protobuf_test-unittest_no_arena.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_no_arena.pb.o `test -f 'google/protobuf/unittest_no_arena.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_arena.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_no_arena.pb.obj: google/protobuf/unittest_no_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_no_arena.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_arena.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_no_arena.pb.obj `if test -f 'google/protobuf/unittest_no_arena.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_arena.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_arena.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_arena.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_arena.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_arena.pb.cc' object='google/protobuf/protobuf_test-unittest_no_arena.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_no_arena.pb.obj `if test -f 'google/protobuf/unittest_no_arena.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_arena.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_arena.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_no_field_presence.pb.o: google/protobuf/unittest_no_field_presence.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_no_field_presence.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_field_presence.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_no_field_presence.pb.o `test -f 'google/protobuf/unittest_no_field_presence.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_field_presence.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_field_presence.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_field_presence.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_field_presence.pb.cc' object='google/protobuf/protobuf_test-unittest_no_field_presence.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_no_field_presence.pb.o `test -f 'google/protobuf/unittest_no_field_presence.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_field_presence.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_no_field_presence.pb.obj: google/protobuf/unittest_no_field_presence.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_no_field_presence.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_field_presence.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_no_field_presence.pb.obj `if test -f 'google/protobuf/unittest_no_field_presence.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_field_presence.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_field_presence.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_field_presence.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_field_presence.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_field_presence.pb.cc' object='google/protobuf/protobuf_test-unittest_no_field_presence.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_no_field_presence.pb.obj `if test -f 'google/protobuf/unittest_no_field_presence.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_field_presence.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_field_presence.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_no_generic_services.pb.o: google/protobuf/unittest_no_generic_services.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_no_generic_services.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_generic_services.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_no_generic_services.pb.o `test -f 'google/protobuf/unittest_no_generic_services.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_generic_services.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_generic_services.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_generic_services.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_generic_services.pb.cc' object='google/protobuf/protobuf_test-unittest_no_generic_services.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_no_generic_services.pb.o `test -f 'google/protobuf/unittest_no_generic_services.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_no_generic_services.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_no_generic_services.pb.obj: google/protobuf/unittest_no_generic_services.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_no_generic_services.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_generic_services.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_no_generic_services.pb.obj `if test -f 'google/protobuf/unittest_no_generic_services.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_generic_services.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_generic_services.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_generic_services.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_no_generic_services.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_no_generic_services.pb.cc' object='google/protobuf/protobuf_test-unittest_no_generic_services.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_no_generic_services.pb.obj `if test -f 'google/protobuf/unittest_no_generic_services.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_no_generic_services.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_no_generic_services.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_optimize_for.pb.o: google/protobuf/unittest_optimize_for.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_optimize_for.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_optimize_for.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_optimize_for.pb.o `test -f 'google/protobuf/unittest_optimize_for.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_optimize_for.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_optimize_for.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_optimize_for.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_optimize_for.pb.cc' object='google/protobuf/protobuf_test-unittest_optimize_for.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_optimize_for.pb.o `test -f 'google/protobuf/unittest_optimize_for.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_optimize_for.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_optimize_for.pb.obj: google/protobuf/unittest_optimize_for.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_optimize_for.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_optimize_for.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_optimize_for.pb.obj `if test -f 'google/protobuf/unittest_optimize_for.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_optimize_for.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_optimize_for.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_optimize_for.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_optimize_for.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_optimize_for.pb.cc' object='google/protobuf/protobuf_test-unittest_optimize_for.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_optimize_for.pb.obj `if test -f 'google/protobuf/unittest_optimize_for.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_optimize_for.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_optimize_for.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest.pb.o: google/protobuf/unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest.pb.Tpo -c -o google/protobuf/protobuf_test-unittest.pb.o `test -f 'google/protobuf/unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest.pb.cc' object='google/protobuf/protobuf_test-unittest.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest.pb.o `test -f 'google/protobuf/unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest.pb.obj: google/protobuf/unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest.pb.Tpo -c -o google/protobuf/protobuf_test-unittest.pb.obj `if test -f 'google/protobuf/unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest.pb.cc' object='google/protobuf/protobuf_test-unittest.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest.pb.obj `if test -f 'google/protobuf/unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_preserve_unknown_enum2.pb.o: google/protobuf/unittest_preserve_unknown_enum2.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_preserve_unknown_enum2.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_preserve_unknown_enum2.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_preserve_unknown_enum2.pb.o `test -f 'google/protobuf/unittest_preserve_unknown_enum2.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_preserve_unknown_enum2.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_preserve_unknown_enum2.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_preserve_unknown_enum2.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_preserve_unknown_enum2.pb.cc' object='google/protobuf/protobuf_test-unittest_preserve_unknown_enum2.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_preserve_unknown_enum2.pb.o `test -f 'google/protobuf/unittest_preserve_unknown_enum2.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_preserve_unknown_enum2.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_preserve_unknown_enum2.pb.obj: google/protobuf/unittest_preserve_unknown_enum2.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_preserve_unknown_enum2.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_preserve_unknown_enum2.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_preserve_unknown_enum2.pb.obj `if test -f 'google/protobuf/unittest_preserve_unknown_enum2.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_preserve_unknown_enum2.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_preserve_unknown_enum2.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_preserve_unknown_enum2.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_preserve_unknown_enum2.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_preserve_unknown_enum2.pb.cc' object='google/protobuf/protobuf_test-unittest_preserve_unknown_enum2.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_preserve_unknown_enum2.pb.obj `if test -f 'google/protobuf/unittest_preserve_unknown_enum2.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_preserve_unknown_enum2.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_preserve_unknown_enum2.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_preserve_unknown_enum.pb.o: google/protobuf/unittest_preserve_unknown_enum.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_preserve_unknown_enum.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_preserve_unknown_enum.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_preserve_unknown_enum.pb.o `test -f 'google/protobuf/unittest_preserve_unknown_enum.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_preserve_unknown_enum.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_preserve_unknown_enum.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_preserve_unknown_enum.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_preserve_unknown_enum.pb.cc' object='google/protobuf/protobuf_test-unittest_preserve_unknown_enum.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_preserve_unknown_enum.pb.o `test -f 'google/protobuf/unittest_preserve_unknown_enum.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_preserve_unknown_enum.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_preserve_unknown_enum.pb.obj: google/protobuf/unittest_preserve_unknown_enum.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_preserve_unknown_enum.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_preserve_unknown_enum.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_preserve_unknown_enum.pb.obj `if test -f 'google/protobuf/unittest_preserve_unknown_enum.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_preserve_unknown_enum.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_preserve_unknown_enum.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_preserve_unknown_enum.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_preserve_unknown_enum.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_preserve_unknown_enum.pb.cc' object='google/protobuf/protobuf_test-unittest_preserve_unknown_enum.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_preserve_unknown_enum.pb.obj `if test -f 'google/protobuf/unittest_preserve_unknown_enum.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_preserve_unknown_enum.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_preserve_unknown_enum.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_proto3_arena.pb.o: google/protobuf/unittest_proto3_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_proto3_arena.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_proto3_arena.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_proto3_arena.pb.o `test -f 'google/protobuf/unittest_proto3_arena.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_proto3_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_proto3_arena.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_proto3_arena.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_proto3_arena.pb.cc' object='google/protobuf/protobuf_test-unittest_proto3_arena.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_proto3_arena.pb.o `test -f 'google/protobuf/unittest_proto3_arena.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_proto3_arena.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_proto3_arena.pb.obj: google/protobuf/unittest_proto3_arena.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_proto3_arena.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_proto3_arena.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_proto3_arena.pb.obj `if test -f 'google/protobuf/unittest_proto3_arena.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_proto3_arena.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_proto3_arena.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_proto3_arena.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_proto3_arena.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_proto3_arena.pb.cc' object='google/protobuf/protobuf_test-unittest_proto3_arena.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_proto3_arena.pb.obj `if test -f 'google/protobuf/unittest_proto3_arena.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_proto3_arena.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_proto3_arena.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_proto3_arena_lite.pb.o: google/protobuf/unittest_proto3_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_proto3_arena_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_proto3_arena_lite.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_proto3_arena_lite.pb.o `test -f 'google/protobuf/unittest_proto3_arena_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_proto3_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_proto3_arena_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_proto3_arena_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_proto3_arena_lite.pb.cc' object='google/protobuf/protobuf_test-unittest_proto3_arena_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_proto3_arena_lite.pb.o `test -f 'google/protobuf/unittest_proto3_arena_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_proto3_arena_lite.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_proto3_arena_lite.pb.obj: google/protobuf/unittest_proto3_arena_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_proto3_arena_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_proto3_arena_lite.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_proto3_arena_lite.pb.obj `if test -f 'google/protobuf/unittest_proto3_arena_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_proto3_arena_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_proto3_arena_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_proto3_arena_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_proto3_arena_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_proto3_arena_lite.pb.cc' object='google/protobuf/protobuf_test-unittest_proto3_arena_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_proto3_arena_lite.pb.obj `if test -f 'google/protobuf/unittest_proto3_arena_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_proto3_arena_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_proto3_arena_lite.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_proto3_lite.pb.o: google/protobuf/unittest_proto3_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_proto3_lite.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_proto3_lite.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_proto3_lite.pb.o `test -f 'google/protobuf/unittest_proto3_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_proto3_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_proto3_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_proto3_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_proto3_lite.pb.cc' object='google/protobuf/protobuf_test-unittest_proto3_lite.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_proto3_lite.pb.o `test -f 'google/protobuf/unittest_proto3_lite.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_proto3_lite.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_proto3_lite.pb.obj: google/protobuf/unittest_proto3_lite.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_proto3_lite.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_proto3_lite.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_proto3_lite.pb.obj `if test -f 'google/protobuf/unittest_proto3_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_proto3_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_proto3_lite.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_proto3_lite.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_proto3_lite.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_proto3_lite.pb.cc' object='google/protobuf/protobuf_test-unittest_proto3_lite.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_proto3_lite.pb.obj `if test -f 'google/protobuf/unittest_proto3_lite.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_proto3_lite.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_proto3_lite.pb.cc'; fi`\n\ngoogle/protobuf/protobuf_test-unittest_well_known_types.pb.o: google/protobuf/unittest_well_known_types.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_well_known_types.pb.o -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_well_known_types.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_well_known_types.pb.o `test -f 'google/protobuf/unittest_well_known_types.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_well_known_types.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_well_known_types.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_well_known_types.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_well_known_types.pb.cc' object='google/protobuf/protobuf_test-unittest_well_known_types.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_well_known_types.pb.o `test -f 'google/protobuf/unittest_well_known_types.pb.cc' || echo '$(srcdir)/'`google/protobuf/unittest_well_known_types.pb.cc\n\ngoogle/protobuf/protobuf_test-unittest_well_known_types.pb.obj: google/protobuf/unittest_well_known_types.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/protobuf_test-unittest_well_known_types.pb.obj -MD -MP -MF google/protobuf/$(DEPDIR)/protobuf_test-unittest_well_known_types.pb.Tpo -c -o google/protobuf/protobuf_test-unittest_well_known_types.pb.obj `if test -f 'google/protobuf/unittest_well_known_types.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_well_known_types.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_well_known_types.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/$(DEPDIR)/protobuf_test-unittest_well_known_types.pb.Tpo google/protobuf/$(DEPDIR)/protobuf_test-unittest_well_known_types.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/unittest_well_known_types.pb.cc' object='google/protobuf/protobuf_test-unittest_well_known_types.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/protobuf_test-unittest_well_known_types.pb.obj `if test -f 'google/protobuf/unittest_well_known_types.pb.cc'; then $(CYGPATH_W) 'google/protobuf/unittest_well_known_types.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/unittest_well_known_types.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/protobuf_test-anys.pb.o: google/protobuf/util/internal/testdata/anys.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_test-anys.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-anys.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_test-anys.pb.o `test -f 'google/protobuf/util/internal/testdata/anys.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/anys.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-anys.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-anys.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/anys.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_test-anys.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_test-anys.pb.o `test -f 'google/protobuf/util/internal/testdata/anys.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/anys.pb.cc\n\ngoogle/protobuf/util/internal/testdata/protobuf_test-anys.pb.obj: google/protobuf/util/internal/testdata/anys.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_test-anys.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-anys.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_test-anys.pb.obj `if test -f 'google/protobuf/util/internal/testdata/anys.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/anys.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/anys.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-anys.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-anys.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/anys.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_test-anys.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_test-anys.pb.obj `if test -f 'google/protobuf/util/internal/testdata/anys.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/anys.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/anys.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/protobuf_test-books.pb.o: google/protobuf/util/internal/testdata/books.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_test-books.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-books.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_test-books.pb.o `test -f 'google/protobuf/util/internal/testdata/books.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/books.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-books.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-books.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/books.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_test-books.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_test-books.pb.o `test -f 'google/protobuf/util/internal/testdata/books.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/books.pb.cc\n\ngoogle/protobuf/util/internal/testdata/protobuf_test-books.pb.obj: google/protobuf/util/internal/testdata/books.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_test-books.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-books.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_test-books.pb.obj `if test -f 'google/protobuf/util/internal/testdata/books.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/books.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/books.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-books.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-books.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/books.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_test-books.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_test-books.pb.obj `if test -f 'google/protobuf/util/internal/testdata/books.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/books.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/books.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/protobuf_test-default_value.pb.o: google/protobuf/util/internal/testdata/default_value.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_test-default_value.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-default_value.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_test-default_value.pb.o `test -f 'google/protobuf/util/internal/testdata/default_value.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/default_value.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-default_value.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-default_value.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/default_value.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_test-default_value.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_test-default_value.pb.o `test -f 'google/protobuf/util/internal/testdata/default_value.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/default_value.pb.cc\n\ngoogle/protobuf/util/internal/testdata/protobuf_test-default_value.pb.obj: google/protobuf/util/internal/testdata/default_value.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_test-default_value.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-default_value.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_test-default_value.pb.obj `if test -f 'google/protobuf/util/internal/testdata/default_value.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/default_value.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/default_value.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-default_value.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-default_value.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/default_value.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_test-default_value.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_test-default_value.pb.obj `if test -f 'google/protobuf/util/internal/testdata/default_value.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/default_value.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/default_value.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/protobuf_test-default_value_test.pb.o: google/protobuf/util/internal/testdata/default_value_test.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_test-default_value_test.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-default_value_test.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_test-default_value_test.pb.o `test -f 'google/protobuf/util/internal/testdata/default_value_test.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/default_value_test.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-default_value_test.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-default_value_test.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/default_value_test.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_test-default_value_test.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_test-default_value_test.pb.o `test -f 'google/protobuf/util/internal/testdata/default_value_test.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/default_value_test.pb.cc\n\ngoogle/protobuf/util/internal/testdata/protobuf_test-default_value_test.pb.obj: google/protobuf/util/internal/testdata/default_value_test.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_test-default_value_test.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-default_value_test.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_test-default_value_test.pb.obj `if test -f 'google/protobuf/util/internal/testdata/default_value_test.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/default_value_test.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/default_value_test.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-default_value_test.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-default_value_test.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/default_value_test.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_test-default_value_test.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_test-default_value_test.pb.obj `if test -f 'google/protobuf/util/internal/testdata/default_value_test.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/default_value_test.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/default_value_test.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/protobuf_test-field_mask.pb.o: google/protobuf/util/internal/testdata/field_mask.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_test-field_mask.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-field_mask.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_test-field_mask.pb.o `test -f 'google/protobuf/util/internal/testdata/field_mask.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/field_mask.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-field_mask.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-field_mask.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/field_mask.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_test-field_mask.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_test-field_mask.pb.o `test -f 'google/protobuf/util/internal/testdata/field_mask.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/field_mask.pb.cc\n\ngoogle/protobuf/util/internal/testdata/protobuf_test-field_mask.pb.obj: google/protobuf/util/internal/testdata/field_mask.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_test-field_mask.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-field_mask.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_test-field_mask.pb.obj `if test -f 'google/protobuf/util/internal/testdata/field_mask.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/field_mask.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/field_mask.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-field_mask.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-field_mask.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/field_mask.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_test-field_mask.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_test-field_mask.pb.obj `if test -f 'google/protobuf/util/internal/testdata/field_mask.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/field_mask.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/field_mask.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/protobuf_test-maps.pb.o: google/protobuf/util/internal/testdata/maps.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_test-maps.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-maps.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_test-maps.pb.o `test -f 'google/protobuf/util/internal/testdata/maps.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/maps.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-maps.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-maps.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/maps.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_test-maps.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_test-maps.pb.o `test -f 'google/protobuf/util/internal/testdata/maps.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/maps.pb.cc\n\ngoogle/protobuf/util/internal/testdata/protobuf_test-maps.pb.obj: google/protobuf/util/internal/testdata/maps.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_test-maps.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-maps.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_test-maps.pb.obj `if test -f 'google/protobuf/util/internal/testdata/maps.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/maps.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/maps.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-maps.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-maps.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/maps.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_test-maps.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_test-maps.pb.obj `if test -f 'google/protobuf/util/internal/testdata/maps.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/maps.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/maps.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/protobuf_test-oneofs.pb.o: google/protobuf/util/internal/testdata/oneofs.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_test-oneofs.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-oneofs.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_test-oneofs.pb.o `test -f 'google/protobuf/util/internal/testdata/oneofs.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/oneofs.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-oneofs.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-oneofs.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/oneofs.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_test-oneofs.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_test-oneofs.pb.o `test -f 'google/protobuf/util/internal/testdata/oneofs.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/oneofs.pb.cc\n\ngoogle/protobuf/util/internal/testdata/protobuf_test-oneofs.pb.obj: google/protobuf/util/internal/testdata/oneofs.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_test-oneofs.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-oneofs.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_test-oneofs.pb.obj `if test -f 'google/protobuf/util/internal/testdata/oneofs.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/oneofs.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/oneofs.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-oneofs.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-oneofs.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/oneofs.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_test-oneofs.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_test-oneofs.pb.obj `if test -f 'google/protobuf/util/internal/testdata/oneofs.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/oneofs.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/oneofs.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/protobuf_test-struct.pb.o: google/protobuf/util/internal/testdata/struct.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_test-struct.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-struct.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_test-struct.pb.o `test -f 'google/protobuf/util/internal/testdata/struct.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/struct.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-struct.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-struct.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/struct.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_test-struct.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_test-struct.pb.o `test -f 'google/protobuf/util/internal/testdata/struct.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/struct.pb.cc\n\ngoogle/protobuf/util/internal/testdata/protobuf_test-struct.pb.obj: google/protobuf/util/internal/testdata/struct.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_test-struct.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-struct.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_test-struct.pb.obj `if test -f 'google/protobuf/util/internal/testdata/struct.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/struct.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/struct.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-struct.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-struct.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/struct.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_test-struct.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_test-struct.pb.obj `if test -f 'google/protobuf/util/internal/testdata/struct.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/struct.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/struct.pb.cc'; fi`\n\ngoogle/protobuf/util/internal/testdata/protobuf_test-timestamp_duration.pb.o: google/protobuf/util/internal/testdata/timestamp_duration.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_test-timestamp_duration.pb.o -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-timestamp_duration.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_test-timestamp_duration.pb.o `test -f 'google/protobuf/util/internal/testdata/timestamp_duration.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/timestamp_duration.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-timestamp_duration.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-timestamp_duration.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/timestamp_duration.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_test-timestamp_duration.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_test-timestamp_duration.pb.o `test -f 'google/protobuf/util/internal/testdata/timestamp_duration.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/internal/testdata/timestamp_duration.pb.cc\n\ngoogle/protobuf/util/internal/testdata/protobuf_test-timestamp_duration.pb.obj: google/protobuf/util/internal/testdata/timestamp_duration.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/internal/testdata/protobuf_test-timestamp_duration.pb.obj -MD -MP -MF google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-timestamp_duration.pb.Tpo -c -o google/protobuf/util/internal/testdata/protobuf_test-timestamp_duration.pb.obj `if test -f 'google/protobuf/util/internal/testdata/timestamp_duration.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/timestamp_duration.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/timestamp_duration.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-timestamp_duration.pb.Tpo google/protobuf/util/internal/testdata/$(DEPDIR)/protobuf_test-timestamp_duration.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/internal/testdata/timestamp_duration.pb.cc' object='google/protobuf/util/internal/testdata/protobuf_test-timestamp_duration.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/internal/testdata/protobuf_test-timestamp_duration.pb.obj `if test -f 'google/protobuf/util/internal/testdata/timestamp_duration.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/internal/testdata/timestamp_duration.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/internal/testdata/timestamp_duration.pb.cc'; fi`\n\ngoogle/protobuf/util/protobuf_test-json_format_proto3.pb.o: google/protobuf/util/json_format_proto3.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/protobuf_test-json_format_proto3.pb.o -MD -MP -MF google/protobuf/util/$(DEPDIR)/protobuf_test-json_format_proto3.pb.Tpo -c -o google/protobuf/util/protobuf_test-json_format_proto3.pb.o `test -f 'google/protobuf/util/json_format_proto3.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/json_format_proto3.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/protobuf_test-json_format_proto3.pb.Tpo google/protobuf/util/$(DEPDIR)/protobuf_test-json_format_proto3.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/json_format_proto3.pb.cc' object='google/protobuf/util/protobuf_test-json_format_proto3.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/protobuf_test-json_format_proto3.pb.o `test -f 'google/protobuf/util/json_format_proto3.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/json_format_proto3.pb.cc\n\ngoogle/protobuf/util/protobuf_test-json_format_proto3.pb.obj: google/protobuf/util/json_format_proto3.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/protobuf_test-json_format_proto3.pb.obj -MD -MP -MF google/protobuf/util/$(DEPDIR)/protobuf_test-json_format_proto3.pb.Tpo -c -o google/protobuf/util/protobuf_test-json_format_proto3.pb.obj `if test -f 'google/protobuf/util/json_format_proto3.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/json_format_proto3.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/json_format_proto3.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/protobuf_test-json_format_proto3.pb.Tpo google/protobuf/util/$(DEPDIR)/protobuf_test-json_format_proto3.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/json_format_proto3.pb.cc' object='google/protobuf/util/protobuf_test-json_format_proto3.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/protobuf_test-json_format_proto3.pb.obj `if test -f 'google/protobuf/util/json_format_proto3.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/json_format_proto3.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/json_format_proto3.pb.cc'; fi`\n\ngoogle/protobuf/util/protobuf_test-message_differencer_unittest.pb.o: google/protobuf/util/message_differencer_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/protobuf_test-message_differencer_unittest.pb.o -MD -MP -MF google/protobuf/util/$(DEPDIR)/protobuf_test-message_differencer_unittest.pb.Tpo -c -o google/protobuf/util/protobuf_test-message_differencer_unittest.pb.o `test -f 'google/protobuf/util/message_differencer_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/message_differencer_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/protobuf_test-message_differencer_unittest.pb.Tpo google/protobuf/util/$(DEPDIR)/protobuf_test-message_differencer_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/message_differencer_unittest.pb.cc' object='google/protobuf/util/protobuf_test-message_differencer_unittest.pb.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/protobuf_test-message_differencer_unittest.pb.o `test -f 'google/protobuf/util/message_differencer_unittest.pb.cc' || echo '$(srcdir)/'`google/protobuf/util/message_differencer_unittest.pb.cc\n\ngoogle/protobuf/util/protobuf_test-message_differencer_unittest.pb.obj: google/protobuf/util/message_differencer_unittest.pb.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/util/protobuf_test-message_differencer_unittest.pb.obj -MD -MP -MF google/protobuf/util/$(DEPDIR)/protobuf_test-message_differencer_unittest.pb.Tpo -c -o google/protobuf/util/protobuf_test-message_differencer_unittest.pb.obj `if test -f 'google/protobuf/util/message_differencer_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/message_differencer_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/message_differencer_unittest.pb.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/util/$(DEPDIR)/protobuf_test-message_differencer_unittest.pb.Tpo google/protobuf/util/$(DEPDIR)/protobuf_test-message_differencer_unittest.pb.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/util/message_differencer_unittest.pb.cc' object='google/protobuf/util/protobuf_test-message_differencer_unittest.pb.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(protobuf_test_CPPFLAGS) $(CPPFLAGS) $(protobuf_test_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/util/protobuf_test-message_differencer_unittest.pb.obj `if test -f 'google/protobuf/util/message_differencer_unittest.pb.cc'; then $(CYGPATH_W) 'google/protobuf/util/message_differencer_unittest.pb.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/util/message_differencer_unittest.pb.cc'; fi`\n\ngoogle/protobuf/compiler/test_plugin-mock_code_generator.o: google/protobuf/compiler/mock_code_generator.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_plugin_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/test_plugin-mock_code_generator.o -MD -MP -MF google/protobuf/compiler/$(DEPDIR)/test_plugin-mock_code_generator.Tpo -c -o google/protobuf/compiler/test_plugin-mock_code_generator.o `test -f 'google/protobuf/compiler/mock_code_generator.cc' || echo '$(srcdir)/'`google/protobuf/compiler/mock_code_generator.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/$(DEPDIR)/test_plugin-mock_code_generator.Tpo google/protobuf/compiler/$(DEPDIR)/test_plugin-mock_code_generator.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/mock_code_generator.cc' object='google/protobuf/compiler/test_plugin-mock_code_generator.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_plugin_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/test_plugin-mock_code_generator.o `test -f 'google/protobuf/compiler/mock_code_generator.cc' || echo '$(srcdir)/'`google/protobuf/compiler/mock_code_generator.cc\n\ngoogle/protobuf/compiler/test_plugin-mock_code_generator.obj: google/protobuf/compiler/mock_code_generator.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_plugin_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/test_plugin-mock_code_generator.obj -MD -MP -MF google/protobuf/compiler/$(DEPDIR)/test_plugin-mock_code_generator.Tpo -c -o google/protobuf/compiler/test_plugin-mock_code_generator.obj `if test -f 'google/protobuf/compiler/mock_code_generator.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/mock_code_generator.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/mock_code_generator.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/$(DEPDIR)/test_plugin-mock_code_generator.Tpo google/protobuf/compiler/$(DEPDIR)/test_plugin-mock_code_generator.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/mock_code_generator.cc' object='google/protobuf/compiler/test_plugin-mock_code_generator.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_plugin_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/test_plugin-mock_code_generator.obj `if test -f 'google/protobuf/compiler/mock_code_generator.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/mock_code_generator.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/mock_code_generator.cc'; fi`\n\ngoogle/protobuf/testing/test_plugin-file.o: google/protobuf/testing/file.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_plugin_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/testing/test_plugin-file.o -MD -MP -MF google/protobuf/testing/$(DEPDIR)/test_plugin-file.Tpo -c -o google/protobuf/testing/test_plugin-file.o `test -f 'google/protobuf/testing/file.cc' || echo '$(srcdir)/'`google/protobuf/testing/file.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/testing/$(DEPDIR)/test_plugin-file.Tpo google/protobuf/testing/$(DEPDIR)/test_plugin-file.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/testing/file.cc' object='google/protobuf/testing/test_plugin-file.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_plugin_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/testing/test_plugin-file.o `test -f 'google/protobuf/testing/file.cc' || echo '$(srcdir)/'`google/protobuf/testing/file.cc\n\ngoogle/protobuf/testing/test_plugin-file.obj: google/protobuf/testing/file.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_plugin_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/testing/test_plugin-file.obj -MD -MP -MF google/protobuf/testing/$(DEPDIR)/test_plugin-file.Tpo -c -o google/protobuf/testing/test_plugin-file.obj `if test -f 'google/protobuf/testing/file.cc'; then $(CYGPATH_W) 'google/protobuf/testing/file.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/testing/file.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/testing/$(DEPDIR)/test_plugin-file.Tpo google/protobuf/testing/$(DEPDIR)/test_plugin-file.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/testing/file.cc' object='google/protobuf/testing/test_plugin-file.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_plugin_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/testing/test_plugin-file.obj `if test -f 'google/protobuf/testing/file.cc'; then $(CYGPATH_W) 'google/protobuf/testing/file.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/testing/file.cc'; fi`\n\ngoogle/protobuf/compiler/test_plugin-test_plugin.o: google/protobuf/compiler/test_plugin.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_plugin_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/test_plugin-test_plugin.o -MD -MP -MF google/protobuf/compiler/$(DEPDIR)/test_plugin-test_plugin.Tpo -c -o google/protobuf/compiler/test_plugin-test_plugin.o `test -f 'google/protobuf/compiler/test_plugin.cc' || echo '$(srcdir)/'`google/protobuf/compiler/test_plugin.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/$(DEPDIR)/test_plugin-test_plugin.Tpo google/protobuf/compiler/$(DEPDIR)/test_plugin-test_plugin.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/test_plugin.cc' object='google/protobuf/compiler/test_plugin-test_plugin.o' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_plugin_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/test_plugin-test_plugin.o `test -f 'google/protobuf/compiler/test_plugin.cc' || echo '$(srcdir)/'`google/protobuf/compiler/test_plugin.cc\n\ngoogle/protobuf/compiler/test_plugin-test_plugin.obj: google/protobuf/compiler/test_plugin.cc\n@am__fastdepCXX_TRUE@\t$(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_plugin_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT google/protobuf/compiler/test_plugin-test_plugin.obj -MD -MP -MF google/protobuf/compiler/$(DEPDIR)/test_plugin-test_plugin.Tpo -c -o google/protobuf/compiler/test_plugin-test_plugin.obj `if test -f 'google/protobuf/compiler/test_plugin.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/test_plugin.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/test_plugin.cc'; fi`\n@am__fastdepCXX_TRUE@\t$(AM_V_at)$(am__mv) google/protobuf/compiler/$(DEPDIR)/test_plugin-test_plugin.Tpo google/protobuf/compiler/$(DEPDIR)/test_plugin-test_plugin.Po\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\t$(AM_V_CXX)source='google/protobuf/compiler/test_plugin.cc' object='google/protobuf/compiler/test_plugin-test_plugin.obj' libtool=no @AMDEPBACKSLASH@\n@AMDEP_TRUE@@am__fastdepCXX_FALSE@\tDEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@\n@am__fastdepCXX_FALSE@\t$(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_plugin_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o google/protobuf/compiler/test_plugin-test_plugin.obj `if test -f 'google/protobuf/compiler/test_plugin.cc'; then $(CYGPATH_W) 'google/protobuf/compiler/test_plugin.cc'; else $(CYGPATH_W) '$(srcdir)/google/protobuf/compiler/test_plugin.cc'; fi`\n\nmostlyclean-libtool:\n\t-rm -f *.lo\n\nclean-libtool:\n\t-rm -rf .libs _libs\n\t-rm -rf google/protobuf/.libs google/protobuf/_libs\n\t-rm -rf google/protobuf/compiler/.libs google/protobuf/compiler/_libs\n\t-rm -rf google/protobuf/compiler/cpp/.libs google/protobuf/compiler/cpp/_libs\n\t-rm -rf google/protobuf/compiler/csharp/.libs google/protobuf/compiler/csharp/_libs\n\t-rm -rf google/protobuf/compiler/java/.libs google/protobuf/compiler/java/_libs\n\t-rm -rf google/protobuf/compiler/javanano/.libs google/protobuf/compiler/javanano/_libs\n\t-rm -rf google/protobuf/compiler/js/.libs google/protobuf/compiler/js/_libs\n\t-rm -rf google/protobuf/compiler/objectivec/.libs google/protobuf/compiler/objectivec/_libs\n\t-rm -rf google/protobuf/compiler/python/.libs google/protobuf/compiler/python/_libs\n\t-rm -rf google/protobuf/compiler/ruby/.libs google/protobuf/compiler/ruby/_libs\n\t-rm -rf google/protobuf/io/.libs google/protobuf/io/_libs\n\t-rm -rf google/protobuf/stubs/.libs google/protobuf/stubs/_libs\n\t-rm -rf google/protobuf/util/.libs google/protobuf/util/_libs\n\t-rm -rf google/protobuf/util/internal/.libs google/protobuf/util/internal/_libs\ninstall-nobase_dist_protoDATA: $(nobase_dist_proto_DATA)\n\t@$(NORMAL_INSTALL)\n\t@list='$(nobase_dist_proto_DATA)'; test -n \"$(protodir)\" || list=; \\\n\tif test -n \"$$list\"; then \\\n\t  echo \" $(MKDIR_P) '$(DESTDIR)$(protodir)'\"; \\\n\t  $(MKDIR_P) \"$(DESTDIR)$(protodir)\" || exit 1; \\\n\tfi; \\\n\t$(am__nobase_list) | while read dir files; do \\\n\t  xfiles=; for file in $$files; do \\\n\t    if test -f \"$$file\"; then xfiles=\"$$xfiles $$file\"; \\\n\t    else xfiles=\"$$xfiles $(srcdir)/$$file\"; fi; done; \\\n\t  test -z \"$$xfiles\" || { \\\n\t    test \"x$$dir\" = x. || { \\\n\t      echo \" $(MKDIR_P) '$(DESTDIR)$(protodir)/$$dir'\"; \\\n\t      $(MKDIR_P) \"$(DESTDIR)$(protodir)/$$dir\"; }; \\\n\t    echo \" $(INSTALL_DATA) $$xfiles '$(DESTDIR)$(protodir)/$$dir'\"; \\\n\t    $(INSTALL_DATA) $$xfiles \"$(DESTDIR)$(protodir)/$$dir\" || exit $$?; }; \\\n\tdone\n\nuninstall-nobase_dist_protoDATA:\n\t@$(NORMAL_UNINSTALL)\n\t@list='$(nobase_dist_proto_DATA)'; test -n \"$(protodir)\" || list=; \\\n\t$(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \\\n\tdir='$(DESTDIR)$(protodir)'; $(am__uninstall_files_from_dir)\ninstall-nobase_includeHEADERS: $(nobase_include_HEADERS)\n\t@$(NORMAL_INSTALL)\n\t@list='$(nobase_include_HEADERS)'; test -n \"$(includedir)\" || list=; \\\n\tif test -n \"$$list\"; then \\\n\t  echo \" $(MKDIR_P) '$(DESTDIR)$(includedir)'\"; \\\n\t  $(MKDIR_P) \"$(DESTDIR)$(includedir)\" || exit 1; \\\n\tfi; \\\n\t$(am__nobase_list) | while read dir files; do \\\n\t  xfiles=; for file in $$files; do \\\n\t    if test -f \"$$file\"; then xfiles=\"$$xfiles $$file\"; \\\n\t    else xfiles=\"$$xfiles $(srcdir)/$$file\"; fi; done; \\\n\t  test -z \"$$xfiles\" || { \\\n\t    test \"x$$dir\" = x. || { \\\n\t      echo \" $(MKDIR_P) '$(DESTDIR)$(includedir)/$$dir'\"; \\\n\t      $(MKDIR_P) \"$(DESTDIR)$(includedir)/$$dir\"; }; \\\n\t    echo \" $(INSTALL_HEADER) $$xfiles '$(DESTDIR)$(includedir)/$$dir'\"; \\\n\t    $(INSTALL_HEADER) $$xfiles \"$(DESTDIR)$(includedir)/$$dir\" || exit $$?; }; \\\n\tdone\n\nuninstall-nobase_includeHEADERS:\n\t@$(NORMAL_UNINSTALL)\n\t@list='$(nobase_include_HEADERS)'; test -n \"$(includedir)\" || list=; \\\n\t$(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \\\n\tdir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir)\n\nID: $(am__tagged_files)\n\t$(am__define_uniq_tagged_files); mkid -fID $$unique\ntags: tags-am\nTAGS: tags\n\ntags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)\n\tset x; \\\n\there=`pwd`; \\\n\t$(am__define_uniq_tagged_files); \\\n\tshift; \\\n\tif test -z \"$(ETAGS_ARGS)$$*$$unique\"; then :; else \\\n\t  test -n \"$$unique\" || unique=$$empty_fix; \\\n\t  if test $$# -gt 0; then \\\n\t    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \\\n\t      \"$$@\" $$unique; \\\n\t  else \\\n\t    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \\\n\t      $$unique; \\\n\t  fi; \\\n\tfi\nctags: ctags-am\n\nCTAGS: ctags\nctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)\n\t$(am__define_uniq_tagged_files); \\\n\ttest -z \"$(CTAGS_ARGS)$$unique\" \\\n\t  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \\\n\t     $$unique\n\nGTAGS:\n\there=`$(am__cd) $(top_builddir) && pwd` \\\n\t  && $(am__cd) $(top_srcdir) \\\n\t  && gtags -i $(GTAGS_ARGS) \"$$here\"\ncscopelist: cscopelist-am\n\ncscopelist-am: $(am__tagged_files)\n\tlist='$(am__tagged_files)'; \\\n\tcase \"$(srcdir)\" in \\\n\t  [\\\\/]* | ?:[\\\\/]*) sdir=\"$(srcdir)\" ;; \\\n\t  *) sdir=$(subdir)/$(srcdir) ;; \\\n\tesac; \\\n\tfor i in $$list; do \\\n\t  if test -f \"$$i\"; then \\\n\t    echo \"$(subdir)/$$i\"; \\\n\t  else \\\n\t    echo \"$$sdir/$$i\"; \\\n\t  fi; \\\n\tdone >> $(top_builddir)/cscope.files\n\ndistclean-tags:\n\t-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags\n\n# Recover from deleted '.trs' file; this should ensure that\n# \"rm -f foo.log; make foo.trs\" re-run 'foo.test', and re-create\n# both 'foo.log' and 'foo.trs'.  Break the recipe in two subshells\n# to avoid problems with \"make -n\".\n.log.trs:\n\trm -f $< $@\n\t$(MAKE) $(AM_MAKEFLAGS) $<\n\n# Leading 'am--fnord' is there to ensure the list of targets does not\n# expand to empty, as could happen e.g. with make check TESTS=''.\nam--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck)\nam--force-recheck:\n\t@:\n\n$(TEST_SUITE_LOG): $(TEST_LOGS)\n\t@$(am__set_TESTS_bases); \\\n\tam__f_ok () { test -f \"$$1\" && test -r \"$$1\"; }; \\\n\tredo_bases=`for i in $$bases; do \\\n\t              am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \\\n\t            done`; \\\n\tif test -n \"$$redo_bases\"; then \\\n\t  redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \\\n\t  redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \\\n\t  if $(am__make_dryrun); then :; else \\\n\t    rm -f $$redo_logs && rm -f $$redo_results || exit 1; \\\n\t  fi; \\\n\tfi; \\\n\tif test -n \"$$am__remaking_logs\"; then \\\n\t  echo \"fatal: making $(TEST_SUITE_LOG): possible infinite\" \\\n\t       \"recursion detected\" >&2; \\\n\telse \\\n\t  am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \\\n\tfi; \\\n\tif $(am__make_dryrun); then :; else \\\n\t  st=0;  \\\n\t  errmsg=\"fatal: making $(TEST_SUITE_LOG): failed to create\"; \\\n\t  for i in $$redo_bases; do \\\n\t    test -f $$i.trs && test -r $$i.trs \\\n\t      || { echo \"$$errmsg $$i.trs\" >&2; st=1; }; \\\n\t    test -f $$i.log && test -r $$i.log \\\n\t      || { echo \"$$errmsg $$i.log\" >&2; st=1; }; \\\n\t  done; \\\n\t  test $$st -eq 0 || exit 1; \\\n\tfi\n\t@$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \\\n\tws='[ \t]'; \\\n\tresults=`for b in $$bases; do echo $$b.trs; done`; \\\n\ttest -n \"$$results\" || results=/dev/null; \\\n\tall=`  grep \"^$$ws*:test-result:\"           $$results | wc -l`; \\\n\tpass=` grep \"^$$ws*:test-result:$$ws*PASS\"  $$results | wc -l`; \\\n\tfail=` grep \"^$$ws*:test-result:$$ws*FAIL\"  $$results | wc -l`; \\\n\tskip=` grep \"^$$ws*:test-result:$$ws*SKIP\"  $$results | wc -l`; \\\n\txfail=`grep \"^$$ws*:test-result:$$ws*XFAIL\" $$results | wc -l`; \\\n\txpass=`grep \"^$$ws*:test-result:$$ws*XPASS\" $$results | wc -l`; \\\n\terror=`grep \"^$$ws*:test-result:$$ws*ERROR\" $$results | wc -l`; \\\n\tif test `expr $$fail + $$xpass + $$error` -eq 0; then \\\n\t  success=true; \\\n\telse \\\n\t  success=false; \\\n\tfi; \\\n\tbr='==================='; br=$$br$$br$$br$$br; \\\n\tresult_count () \\\n\t{ \\\n\t    if test x\"$$1\" = x\"--maybe-color\"; then \\\n\t      maybe_colorize=yes; \\\n\t    elif test x\"$$1\" = x\"--no-color\"; then \\\n\t      maybe_colorize=no; \\\n\t    else \\\n\t      echo \"$@: invalid 'result_count' usage\" >&2; exit 4; \\\n\t    fi; \\\n\t    shift; \\\n\t    desc=$$1 count=$$2; \\\n\t    if test $$maybe_colorize = yes && test $$count -gt 0; then \\\n\t      color_start=$$3 color_end=$$std; \\\n\t    else \\\n\t      color_start= color_end=; \\\n\t    fi; \\\n\t    echo \"$${color_start}# $$desc $$count$${color_end}\"; \\\n\t}; \\\n\tcreate_testsuite_report () \\\n\t{ \\\n\t  result_count $$1 \"TOTAL:\" $$all   \"$$brg\"; \\\n\t  result_count $$1 \"PASS: \" $$pass  \"$$grn\"; \\\n\t  result_count $$1 \"SKIP: \" $$skip  \"$$blu\"; \\\n\t  result_count $$1 \"XFAIL:\" $$xfail \"$$lgn\"; \\\n\t  result_count $$1 \"FAIL: \" $$fail  \"$$red\"; \\\n\t  result_count $$1 \"XPASS:\" $$xpass \"$$red\"; \\\n\t  result_count $$1 \"ERROR:\" $$error \"$$mgn\"; \\\n\t}; \\\n\t{\t\t\t\t\t\t\t\t\\\n\t  echo \"$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)\" |\t\\\n\t    $(am__rst_title);\t\t\t\t\t\t\\\n\t  create_testsuite_report --no-color;\t\t\t\t\\\n\t  echo;\t\t\t\t\t\t\t\t\\\n\t  echo \".. contents:: :depth: 2\";\t\t\t\t\\\n\t  echo;\t\t\t\t\t\t\t\t\\\n\t  for b in $$bases; do echo $$b; done\t\t\t\t\\\n\t    | $(am__create_global_log);\t\t\t\t\t\\\n\t} >$(TEST_SUITE_LOG).tmp || exit 1;\t\t\t\t\\\n\tmv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG);\t\t\t\\\n\tif $$success; then\t\t\t\t\t\t\\\n\t  col=\"$$grn\";\t\t\t\t\t\t\t\\\n\t else\t\t\t\t\t\t\t\t\\\n\t  col=\"$$red\";\t\t\t\t\t\t\t\\\n\t  test x\"$$VERBOSE\" = x || cat $(TEST_SUITE_LOG);\t\t\\\n\tfi;\t\t\t\t\t\t\t\t\\\n\techo \"$${col}$$br$${std}\"; \t\t\t\t\t\\\n\techo \"$${col}Testsuite summary for $(PACKAGE_STRING)$${std}\";\t\\\n\techo \"$${col}$$br$${std}\"; \t\t\t\t\t\\\n\tcreate_testsuite_report --maybe-color;\t\t\t\t\\\n\techo \"$$col$$br$$std\";\t\t\t\t\t\t\\\n\tif $$success; then :; else\t\t\t\t\t\\\n\t  echo \"$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}\";\t\t\\\n\t  if test -n \"$(PACKAGE_BUGREPORT)\"; then\t\t\t\\\n\t    echo \"$${col}Please report to $(PACKAGE_BUGREPORT)$${std}\";\t\\\n\t  fi;\t\t\t\t\t\t\t\t\\\n\t  echo \"$$col$$br$$std\";\t\t\t\t\t\\\n\tfi;\t\t\t\t\t\t\t\t\\\n\t$$success || exit 1\n\ncheck-TESTS:\n\t@list='$(RECHECK_LOGS)';           test -z \"$$list\" || rm -f $$list\n\t@list='$(RECHECK_LOGS:.log=.trs)'; test -z \"$$list\" || rm -f $$list\n\t@test -z \"$(TEST_SUITE_LOG)\" || rm -f $(TEST_SUITE_LOG)\n\t@set +e; $(am__set_TESTS_bases); \\\n\tlog_list=`for i in $$bases; do echo $$i.log; done`; \\\n\ttrs_list=`for i in $$bases; do echo $$i.trs; done`; \\\n\tlog_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \\\n\t$(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS=\"$$log_list\"; \\\n\texit $$?;\nrecheck: all $(check_PROGRAMS)\n\t@test -z \"$(TEST_SUITE_LOG)\" || rm -f $(TEST_SUITE_LOG)\n\t@set +e; $(am__set_TESTS_bases); \\\n\tbases=`for i in $$bases; do echo $$i; done \\\n\t         | $(am__list_recheck_tests)` || exit 1; \\\n\tlog_list=`for i in $$bases; do echo $$i.log; done`; \\\n\tlog_list=`echo $$log_list`; \\\n\t$(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \\\n\t        am__force_recheck=am--force-recheck \\\n\t        TEST_LOGS=\"$$log_list\"; \\\n\texit $$?\nprotobuf-test.log: protobuf-test$(EXEEXT)\n\t@p='protobuf-test$(EXEEXT)'; \\\n\tb='protobuf-test'; \\\n\t$(am__check_pre) $(LOG_DRIVER) --test-name \"$$f\" \\\n\t--log-file $$b.log --trs-file $$b.trs \\\n\t$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \\\n\t\"$$tst\" $(AM_TESTS_FD_REDIRECT)\nprotobuf-lazy-descriptor-test.log: protobuf-lazy-descriptor-test$(EXEEXT)\n\t@p='protobuf-lazy-descriptor-test$(EXEEXT)'; \\\n\tb='protobuf-lazy-descriptor-test'; \\\n\t$(am__check_pre) $(LOG_DRIVER) --test-name \"$$f\" \\\n\t--log-file $$b.log --trs-file $$b.trs \\\n\t$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \\\n\t\"$$tst\" $(AM_TESTS_FD_REDIRECT)\nprotobuf-lite-test.log: protobuf-lite-test$(EXEEXT)\n\t@p='protobuf-lite-test$(EXEEXT)'; \\\n\tb='protobuf-lite-test'; \\\n\t$(am__check_pre) $(LOG_DRIVER) --test-name \"$$f\" \\\n\t--log-file $$b.log --trs-file $$b.trs \\\n\t$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \\\n\t\"$$tst\" $(AM_TESTS_FD_REDIRECT)\ngoogle/protobuf/compiler/zip_output_unittest.sh.log: google/protobuf/compiler/zip_output_unittest.sh\n\t@p='google/protobuf/compiler/zip_output_unittest.sh'; \\\n\tb='google/protobuf/compiler/zip_output_unittest.sh'; \\\n\t$(am__check_pre) $(LOG_DRIVER) --test-name \"$$f\" \\\n\t--log-file $$b.log --trs-file $$b.trs \\\n\t$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \\\n\t\"$$tst\" $(AM_TESTS_FD_REDIRECT)\ngoogle/protobuf/io/gzip_stream_unittest.sh.log: google/protobuf/io/gzip_stream_unittest.sh\n\t@p='google/protobuf/io/gzip_stream_unittest.sh'; \\\n\tb='google/protobuf/io/gzip_stream_unittest.sh'; \\\n\t$(am__check_pre) $(LOG_DRIVER) --test-name \"$$f\" \\\n\t--log-file $$b.log --trs-file $$b.trs \\\n\t$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \\\n\t\"$$tst\" $(AM_TESTS_FD_REDIRECT)\nprotobuf-lite-arena-test.log: protobuf-lite-arena-test$(EXEEXT)\n\t@p='protobuf-lite-arena-test$(EXEEXT)'; \\\n\tb='protobuf-lite-arena-test'; \\\n\t$(am__check_pre) $(LOG_DRIVER) --test-name \"$$f\" \\\n\t--log-file $$b.log --trs-file $$b.trs \\\n\t$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \\\n\t\"$$tst\" $(AM_TESTS_FD_REDIRECT)\nno-warning-test.log: no-warning-test$(EXEEXT)\n\t@p='no-warning-test$(EXEEXT)'; \\\n\tb='no-warning-test'; \\\n\t$(am__check_pre) $(LOG_DRIVER) --test-name \"$$f\" \\\n\t--log-file $$b.log --trs-file $$b.trs \\\n\t$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \\\n\t\"$$tst\" $(AM_TESTS_FD_REDIRECT)\n.test.log:\n\t@p='$<'; \\\n\t$(am__set_b); \\\n\t$(am__check_pre) $(TEST_LOG_DRIVER) --test-name \"$$f\" \\\n\t--log-file $$b.log --trs-file $$b.trs \\\n\t$(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \\\n\t\"$$tst\" $(AM_TESTS_FD_REDIRECT)\n@am__EXEEXT_TRUE@.test$(EXEEXT).log:\n@am__EXEEXT_TRUE@\t@p='$<'; \\\n@am__EXEEXT_TRUE@\t$(am__set_b); \\\n@am__EXEEXT_TRUE@\t$(am__check_pre) $(TEST_LOG_DRIVER) --test-name \"$$f\" \\\n@am__EXEEXT_TRUE@\t--log-file $$b.log --trs-file $$b.trs \\\n@am__EXEEXT_TRUE@\t$(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \\\n@am__EXEEXT_TRUE@\t\"$$tst\" $(AM_TESTS_FD_REDIRECT)\n\ndistdir: $(DISTFILES)\n\t@srcdirstrip=`echo \"$(srcdir)\" | sed 's/[].[^$$\\\\*]/\\\\\\\\&/g'`; \\\n\ttopsrcdirstrip=`echo \"$(top_srcdir)\" | sed 's/[].[^$$\\\\*]/\\\\\\\\&/g'`; \\\n\tlist='$(DISTFILES)'; \\\n\t  dist_files=`for file in $$list; do echo $$file; done | \\\n\t  sed -e \"s|^$$srcdirstrip/||;t\" \\\n\t      -e \"s|^$$topsrcdirstrip/|$(top_builddir)/|;t\"`; \\\n\tcase $$dist_files in \\\n\t  */*) $(MKDIR_P) `echo \"$$dist_files\" | \\\n\t\t\t   sed '/\\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \\\n\t\t\t   sort -u` ;; \\\n\tesac; \\\n\tfor file in $$dist_files; do \\\n\t  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \\\n\t  if test -d $$d/$$file; then \\\n\t    dir=`echo \"/$$file\" | sed -e 's,/[^/]*$$,,'`; \\\n\t    if test -d \"$(distdir)/$$file\"; then \\\n\t      find \"$(distdir)/$$file\" -type d ! -perm -700 -exec chmod u+rwx {} \\;; \\\n\t    fi; \\\n\t    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \\\n\t      cp -fpR $(srcdir)/$$file \"$(distdir)$$dir\" || exit 1; \\\n\t      find \"$(distdir)/$$file\" -type d ! -perm -700 -exec chmod u+rwx {} \\;; \\\n\t    fi; \\\n\t    cp -fpR $$d/$$file \"$(distdir)$$dir\" || exit 1; \\\n\t  else \\\n\t    test -f \"$(distdir)/$$file\" \\\n\t    || cp -p $$d/$$file \"$(distdir)/$$file\" \\\n\t    || exit 1; \\\n\t  fi; \\\n\tdone\ncheck-am: all-am\n\t$(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)\n\t$(MAKE) $(AM_MAKEFLAGS) check-TESTS\ncheck: $(BUILT_SOURCES)\n\t$(MAKE) $(AM_MAKEFLAGS) check-am\nall-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(DATA) $(HEADERS)\ninstall-binPROGRAMS: install-libLTLIBRARIES\n\ninstalldirs:\n\tfor dir in \"$(DESTDIR)$(libdir)\" \"$(DESTDIR)$(bindir)\" \"$(DESTDIR)$(protodir)\" \"$(DESTDIR)$(includedir)\"; do \\\n\t  test -z \"$$dir\" || $(MKDIR_P) \"$$dir\"; \\\n\tdone\ninstall: $(BUILT_SOURCES)\n\t$(MAKE) $(AM_MAKEFLAGS) install-am\ninstall-exec: install-exec-am\ninstall-data: install-data-am\nuninstall: uninstall-am\n\ninstall-am: all-am\n\t@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am\n\ninstallcheck: installcheck-am\ninstall-strip:\n\tif test -z '$(STRIP)'; then \\\n\t  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM=\"$(INSTALL_STRIP_PROGRAM)\" \\\n\t    install_sh_PROGRAM=\"$(INSTALL_STRIP_PROGRAM)\" INSTALL_STRIP_FLAG=-s \\\n\t      install; \\\n\telse \\\n\t  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM=\"$(INSTALL_STRIP_PROGRAM)\" \\\n\t    install_sh_PROGRAM=\"$(INSTALL_STRIP_PROGRAM)\" INSTALL_STRIP_FLAG=-s \\\n\t    \"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'\" install; \\\n\tfi\nmostlyclean-generic:\n\t-test -z \"$(TEST_LOGS)\" || rm -f $(TEST_LOGS)\n\t-test -z \"$(TEST_LOGS:.log=.trs)\" || rm -f $(TEST_LOGS:.log=.trs)\n\t-test -z \"$(TEST_SUITE_LOG)\" || rm -f $(TEST_SUITE_LOG)\n\nclean-generic:\n\t-test -z \"$(CLEANFILES)\" || rm -f $(CLEANFILES)\n\ndistclean-generic:\n\t-test -z \"$(CONFIG_CLEAN_FILES)\" || rm -f $(CONFIG_CLEAN_FILES)\n\t-test . = \"$(srcdir)\" || test -z \"$(CONFIG_CLEAN_VPATH_FILES)\" || rm -f $(CONFIG_CLEAN_VPATH_FILES)\n\t-rm -f google/protobuf/$(DEPDIR)/$(am__dirstamp)\n\t-rm -f google/protobuf/$(am__dirstamp)\n\t-rm -f google/protobuf/compiler/$(DEPDIR)/$(am__dirstamp)\n\t-rm -f google/protobuf/compiler/$(am__dirstamp)\n\t-rm -f google/protobuf/compiler/cpp/$(DEPDIR)/$(am__dirstamp)\n\t-rm -f google/protobuf/compiler/cpp/$(am__dirstamp)\n\t-rm -f google/protobuf/compiler/csharp/$(DEPDIR)/$(am__dirstamp)\n\t-rm -f google/protobuf/compiler/csharp/$(am__dirstamp)\n\t-rm -f google/protobuf/compiler/java/$(DEPDIR)/$(am__dirstamp)\n\t-rm -f google/protobuf/compiler/java/$(am__dirstamp)\n\t-rm -f google/protobuf/compiler/javanano/$(DEPDIR)/$(am__dirstamp)\n\t-rm -f google/protobuf/compiler/javanano/$(am__dirstamp)\n\t-rm -f google/protobuf/compiler/js/$(DEPDIR)/$(am__dirstamp)\n\t-rm -f google/protobuf/compiler/js/$(am__dirstamp)\n\t-rm -f google/protobuf/compiler/objectivec/$(DEPDIR)/$(am__dirstamp)\n\t-rm -f google/protobuf/compiler/objectivec/$(am__dirstamp)\n\t-rm -f google/protobuf/compiler/python/$(DEPDIR)/$(am__dirstamp)\n\t-rm -f google/protobuf/compiler/python/$(am__dirstamp)\n\t-rm -f google/protobuf/compiler/ruby/$(DEPDIR)/$(am__dirstamp)\n\t-rm -f google/protobuf/compiler/ruby/$(am__dirstamp)\n\t-rm -f google/protobuf/io/$(DEPDIR)/$(am__dirstamp)\n\t-rm -f google/protobuf/io/$(am__dirstamp)\n\t-rm -f google/protobuf/stubs/$(DEPDIR)/$(am__dirstamp)\n\t-rm -f google/protobuf/stubs/$(am__dirstamp)\n\t-rm -f google/protobuf/testing/$(DEPDIR)/$(am__dirstamp)\n\t-rm -f google/protobuf/testing/$(am__dirstamp)\n\t-rm -f google/protobuf/util/$(DEPDIR)/$(am__dirstamp)\n\t-rm -f google/protobuf/util/$(am__dirstamp)\n\t-rm -f google/protobuf/util/internal/$(DEPDIR)/$(am__dirstamp)\n\t-rm -f google/protobuf/util/internal/$(am__dirstamp)\n\t-rm -f google/protobuf/util/internal/testdata/$(DEPDIR)/$(am__dirstamp)\n\t-rm -f google/protobuf/util/internal/testdata/$(am__dirstamp)\n\nmaintainer-clean-generic:\n\t@echo \"This command is intended for maintainers to use\"\n\t@echo \"it deletes files that may require special tools to rebuild.\"\n\t-test -z \"$(BUILT_SOURCES)\" || rm -f $(BUILT_SOURCES)\n\t-test -z \"$(MAINTAINERCLEANFILES)\" || rm -f $(MAINTAINERCLEANFILES)\nclean: clean-am\n\nclean-am: clean-binPROGRAMS clean-checkPROGRAMS clean-generic \\\n\tclean-libLTLIBRARIES clean-libtool clean-local mostlyclean-am\n\ndistclean: distclean-am\n\t-rm -rf ./$(DEPDIR) google/protobuf/$(DEPDIR) google/protobuf/compiler/$(DEPDIR) google/protobuf/compiler/cpp/$(DEPDIR) google/protobuf/compiler/csharp/$(DEPDIR) google/protobuf/compiler/java/$(DEPDIR) google/protobuf/compiler/javanano/$(DEPDIR) google/protobuf/compiler/js/$(DEPDIR) google/protobuf/compiler/objectivec/$(DEPDIR) google/protobuf/compiler/python/$(DEPDIR) google/protobuf/compiler/ruby/$(DEPDIR) google/protobuf/io/$(DEPDIR) google/protobuf/stubs/$(DEPDIR) google/protobuf/testing/$(DEPDIR) google/protobuf/util/$(DEPDIR) google/protobuf/util/internal/$(DEPDIR) google/protobuf/util/internal/testdata/$(DEPDIR)\n\t-rm -f Makefile\ndistclean-am: clean-am distclean-compile distclean-generic \\\n\tdistclean-tags\n\ndvi: dvi-am\n\ndvi-am:\n\nhtml: html-am\n\nhtml-am:\n\ninfo: info-am\n\ninfo-am:\n\ninstall-data-am: install-nobase_dist_protoDATA \\\n\tinstall-nobase_includeHEADERS\n\ninstall-dvi: install-dvi-am\n\ninstall-dvi-am:\n\ninstall-exec-am: install-binPROGRAMS install-libLTLIBRARIES\n\ninstall-html: install-html-am\n\ninstall-html-am:\n\ninstall-info: install-info-am\n\ninstall-info-am:\n\ninstall-man:\n\ninstall-pdf: install-pdf-am\n\ninstall-pdf-am:\n\ninstall-ps: install-ps-am\n\ninstall-ps-am:\n\ninstallcheck-am:\n\nmaintainer-clean: maintainer-clean-am\n\t-rm -rf ./$(DEPDIR) google/protobuf/$(DEPDIR) google/protobuf/compiler/$(DEPDIR) google/protobuf/compiler/cpp/$(DEPDIR) google/protobuf/compiler/csharp/$(DEPDIR) google/protobuf/compiler/java/$(DEPDIR) google/protobuf/compiler/javanano/$(DEPDIR) google/protobuf/compiler/js/$(DEPDIR) google/protobuf/compiler/objectivec/$(DEPDIR) google/protobuf/compiler/python/$(DEPDIR) google/protobuf/compiler/ruby/$(DEPDIR) google/protobuf/io/$(DEPDIR) google/protobuf/stubs/$(DEPDIR) google/protobuf/testing/$(DEPDIR) google/protobuf/util/$(DEPDIR) google/protobuf/util/internal/$(DEPDIR) google/protobuf/util/internal/testdata/$(DEPDIR)\n\t-rm -f Makefile\nmaintainer-clean-am: distclean-am maintainer-clean-generic\n\nmostlyclean: mostlyclean-am\n\nmostlyclean-am: mostlyclean-compile mostlyclean-generic \\\n\tmostlyclean-libtool\n\npdf: pdf-am\n\npdf-am:\n\nps: ps-am\n\nps-am:\n\nuninstall-am: uninstall-binPROGRAMS uninstall-libLTLIBRARIES \\\n\tuninstall-nobase_dist_protoDATA \\\n\tuninstall-nobase_includeHEADERS\n\n.MAKE: all check check-am install install-am install-strip\n\n.PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \\\n\tclean-binPROGRAMS clean-checkPROGRAMS clean-generic \\\n\tclean-libLTLIBRARIES clean-libtool clean-local cscopelist-am \\\n\tctags ctags-am distclean distclean-compile distclean-generic \\\n\tdistclean-libtool distclean-tags distdir dvi dvi-am html \\\n\thtml-am info info-am install install-am install-binPROGRAMS \\\n\tinstall-data install-data-am install-dvi install-dvi-am \\\n\tinstall-exec install-exec-am install-html install-html-am \\\n\tinstall-info install-info-am install-libLTLIBRARIES \\\n\tinstall-man install-nobase_dist_protoDATA \\\n\tinstall-nobase_includeHEADERS install-pdf install-pdf-am \\\n\tinstall-ps install-ps-am install-strip installcheck \\\n\tinstallcheck-am installdirs maintainer-clean \\\n\tmaintainer-clean-generic mostlyclean mostlyclean-compile \\\n\tmostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \\\n\trecheck tags tags-am uninstall uninstall-am \\\n\tuninstall-binPROGRAMS uninstall-libLTLIBRARIES \\\n\tuninstall-nobase_dist_protoDATA \\\n\tuninstall-nobase_includeHEADERS\n\n\n# Not sure why these don't get cleaned automatically.\nclean-local:\n\trm -f *.loT\n\n@USE_EXTERNAL_PROTOC_TRUE@unittest_proto_middleman: $(protoc_inputs)\n@USE_EXTERNAL_PROTOC_TRUE@\t$(PROTOC) -I$(srcdir) --cpp_out=. $^\n@USE_EXTERNAL_PROTOC_TRUE@\ttouch unittest_proto_middleman\n\n# We have to cd to $(srcdir) before executing protoc because $(protoc_inputs) is\n# relative to srcdir, which may not be the same as the current directory when\n# building out-of-tree.\n@USE_EXTERNAL_PROTOC_FALSE@unittest_proto_middleman: protoc$(EXEEXT) $(protoc_inputs)\n@USE_EXTERNAL_PROTOC_FALSE@\toldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/protoc$(EXEEXT) -I. --cpp_out=$$oldpwd $(protoc_inputs) )\n@USE_EXTERNAL_PROTOC_FALSE@\ttouch unittest_proto_middleman\n\n$(protoc_outputs): unittest_proto_middleman\n\n# This test target is to ensure all our public header files and generated\n# code is free from warnings. We have to be more pedantic about these\n# files because they are compiled by users with different compiler flags.\nno_warning_test.cc:\n\techo \"// Generated from Makefile.am\" > no_warning_test.cc\n\tfor FILE in $(nobase_include_HEADERS); do \\\n\t  if ! echo $${FILE} | grep \"atomicops\"; then \\\n\t    echo \"#include <$${FILE}>\" >> no_warning_test.cc; \\\n\t  fi \\\n\tdone\n\techo \"#include <gtest/gtest.h>\" >> no_warning_test.cc\n\techo \"TEST(NoWarningTest, Empty) {}\" >> no_warning_test.cc\n\n# Tell versions [3.59,3.63) of GNU make to not export all variables.\n# Otherwise a system limit (for SysV at least) may be exceeded.\n.NOEXPORT:\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/README.md",
    "content": "Protocol Buffers - Google's data interchange format\n===================================================\n\n[![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https://travis-ci.org/google/protobuf) [![Build status](https://ci.appveyor.com/api/projects/status/73ctee6ua4w2ruin?svg=true)](https://ci.appveyor.com/project/protobuf/protobuf)\n\nCopyright 2008 Google Inc.\n\nhttps://developers.google.com/protocol-buffers/\n\nC++ Installation - Unix\n-----------------------\n\nTo build protobuf from source, the following tools are needed:\n\n  * autoconf\n  * automake\n  * libtool\n  * curl (used to download gmock)\n  * make\n  * g++\n  * unzip\n\nOn Ubuntu, you can install them with:\n\n    $ sudo apt-get install autoconf automake libtool curl make g++ unzip\n\nOn other platforms, please use the corresponding package managing tool to\ninstall them before proceeding.\n\nIf you get the source from github, you need to generate the configure script\nfirst:\n\n    $ ./autogen.sh\n\nThis will download gmock source (which is used for C++ Protocol Buffer\nunit-tests) to the current directory and run automake, autoconf, etc.\nto generate the configure script and various template makefiles.\n\nYou can skip this step if you are using a release package (which already\ncontains gmock and the configure script).\n\nTo build and install the C++ Protocol Buffer runtime and the Protocol\nBuffer compiler (protoc) execute the following:\n\n    $ ./configure\n    $ make\n    $ make check\n    $ sudo make install\n    $ sudo ldconfig # refresh shared library cache.\n\nIf \"make check\" fails, you can still install, but it is likely that\nsome features of this library will not work correctly on your system.\nProceed at your own risk.\n\nFor advanced usage information on configure and make, please refer to the\nautoconf documentation:\n\n  http://www.gnu.org/software/autoconf/manual/autoconf.html#Running-configure-Scripts\n\n**Hint on install location**\n\n  By default, the package will be installed to /usr/local.  However,\n  on many platforms, /usr/local/lib is not part of LD_LIBRARY_PATH.\n  You can add it, but it may be easier to just install to /usr\n  instead.  To do this, invoke configure as follows:\n\n    ./configure --prefix=/usr\n\n  If you already built the package with a different prefix, make sure\n  to run \"make clean\" before building again.\n\n**Compiling dependent packages**\n\n  To compile a package that uses Protocol Buffers, you need to pass\n  various flags to your compiler and linker.  As of version 2.2.0,\n  Protocol Buffers integrates with pkg-config to manage this.  If you\n  have pkg-config installed, then you can invoke it to get a list of\n  flags like so:\n\n    pkg-config --cflags protobuf         # print compiler flags\n    pkg-config --libs protobuf           # print linker flags\n    pkg-config --cflags --libs protobuf  # print both\n\n  For example:\n\n    c++ my_program.cc my_proto.pb.cc `pkg-config --cflags --libs protobuf`\n\n  Note that packages written prior to the 2.2.0 release of Protocol\n  Buffers may not yet integrate with pkg-config to get flags, and may\n  not pass the correct set of flags to correctly link against\n  libprotobuf.  If the package in question uses autoconf, you can\n  often fix the problem by invoking its configure script like:\n\n    configure CXXFLAGS=\"$(pkg-config --cflags protobuf)\" \\\n              LIBS=\"$(pkg-config --libs protobuf)\"\n\n  This will force it to use the correct flags.\n\n  If you are writing an autoconf-based package that uses Protocol\n  Buffers, you should probably use the PKG_CHECK_MODULES macro in your\n  configure script like:\n\n    PKG_CHECK_MODULES([protobuf], [protobuf])\n\n  See the pkg-config man page for more info.\n\n  If you only want protobuf-lite, substitute \"protobuf-lite\" in place\n  of \"protobuf\" in these examples.\n\n**Note for Mac users**\n\n  For a Mac system, Unix tools are not available by default. You will first need\n  to install Xcode from the Mac AppStore and then run the following command from\n  a terminal:\n\n    $ sudo xcode-select --install\n\n  To install Unix tools, you can install \"port\" following the instructions at\n  https://www.macports.org . This will reside in /opt/local/bin/port for most\n  Mac installations.\n\n    $ sudo /opt/local/bin/port install autoconf automake libtool\n\n  Then follow the Unix instructions above.\n\n**Note for cross-compiling**\n\n  The makefiles normally invoke the protoc executable that they just\n  built in order to build tests.  When cross-compiling, the protoc\n  executable may not be executable on the host machine.  In this case,\n  you must build a copy of protoc for the host machine first, then use\n  the --with-protoc option to tell configure to use it instead.  For\n  example:\n\n    ./configure --with-protoc=protoc\n\n  This will use the installed protoc (found in your $PATH) instead of\n  trying to execute the one built during the build process.  You can\n  also use an executable that hasn't been installed.  For example, if\n  you built the protobuf package for your host machine in ../host,\n  you might do:\n\n    ./configure --with-protoc=../host/src/protoc\n\n  Either way, you must make sure that the protoc executable you use\n  has the same version as the protobuf source code you are trying to\n  use it with.\n\n**Note for Solaris users**\n\n  Solaris 10 x86 has a bug that will make linking fail, complaining\n  about libstdc++.la being invalid.  We have included a work-around\n  in this package.  To use the work-around, run configure as follows:\n\n    ./configure LDFLAGS=-L$PWD/src/solaris\n\n  See src/solaris/libstdc++.la for more info on this bug.\n\n**Note for HP C++ Tru64 users**\n\n  To compile invoke configure as follows:\n\n    ./configure CXXFLAGS=\"-O -std ansi -ieee -D__USE_STD_IOSTREAM\"\n\n  Also, you will need to use gmake instead of make.\n\n**Note for AIX users**\n\n  Compile using the IBM xlC C++ compiler as follows:\n\n    ./configure CXX=xlC\n\n  Also, you will need to use GNU `make` (`gmake`) instead of AIX `make`.\n\nC++ Installation - Windows\n--------------------------\n\nIf you only need the protoc binary, you can download it from the release\npage:\n\n  https://github.com/google/protobuf/releases\n\nIn the downloads section, download the zip file protoc-$VERSION-win32.zip.\nIt contains the protoc binary as well as public proto files of protobuf\nlibrary.\n\nTo build from source using Microsoft Visual C++, see [cmake/README.md](../cmake/README.md).\n\nTo build from source using Cygwin or MinGW, follow the Unix installation\ninstructions, above.\n\nBinary Compatibility Warning\n----------------------------\n\nDue to the nature of C++, it is unlikely that any two versions of the\nProtocol Buffers C++ runtime libraries will have compatible ABIs.\nThat is, if you linked an executable against an older version of\nlibprotobuf, it is unlikely to work with a newer version without\nre-compiling.  This problem, when it occurs, will normally be detected\nimmediately on startup of your app.  Still, you may want to consider\nusing static linkage.  You can configure this package to install\nstatic libraries only using:\n\n    ./configure --disable-shared\n\nUsage\n-----\n\nThe complete documentation for Protocol Buffers is available via the\nweb at:\n\n    https://developers.google.com/protocol-buffers/\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/any.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/any.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\nnamespace {\nstring GetTypeUrl(const Descriptor* message,\n                  const string& type_url_prefix) {\n  if (!type_url_prefix.empty() &&\n      type_url_prefix[type_url_prefix.size() - 1] == '/') {\n    return type_url_prefix + message->full_name();\n  } else {\n    return type_url_prefix + \"/\" + message->full_name();\n  }\n}\n}  // namespace\n\nconst char kAnyFullTypeName[] = \"google.protobuf.Any\";\nconst char kTypeGoogleApisComPrefix[] = \"type.googleapis.com/\";\nconst char kTypeGoogleProdComPrefix[] = \"type.googleprod.com/\";\n\nAnyMetadata::AnyMetadata(UrlType* type_url, ValueType* value)\n    : type_url_(type_url), value_(value) {\n}\n\nvoid AnyMetadata::PackFrom(const Message& message) {\n  PackFrom(message, kTypeGoogleApisComPrefix);\n}\n\nvoid AnyMetadata::PackFrom(const Message& message,\n                           const string& type_url_prefix) {\n  type_url_->SetNoArena(&::google::protobuf::internal::GetEmptyString(),\n                        GetTypeUrl(message.GetDescriptor(), type_url_prefix));\n  message.SerializeToString(value_->MutableNoArena(\n      &::google::protobuf::internal::GetEmptyStringAlreadyInited()));\n}\n\nbool AnyMetadata::UnpackTo(Message* message) const {\n  if (!InternalIs(message->GetDescriptor())) {\n    return false;\n  }\n  return message->ParseFromString(\n      value_->GetNoArena(&::google::protobuf::internal::GetEmptyString()));\n}\n\nbool AnyMetadata::InternalIs(const Descriptor* descriptor) const {\n  const string type_url = type_url_->GetNoArena(\n             &::google::protobuf::internal::GetEmptyString());\n  string full_name;\n  if (!ParseAnyTypeUrl(type_url, &full_name)) {\n    return false;\n  }\n  return full_name == descriptor->full_name();\n}\n\nbool ParseAnyTypeUrl(const string& type_url, string* full_type_name) {\n  size_t pos = type_url.find_last_of(\"/\");\n  if (pos == string::npos || pos + 1 == type_url.size()) {\n    return false;\n  }\n  *full_type_name = type_url.substr(pos + 1);\n  return true;\n}\n\n\nbool GetAnyFieldDescriptors(const Message& message,\n                            const FieldDescriptor** type_url_field,\n                            const FieldDescriptor** value_field) {\n    const Descriptor* descriptor = message.GetDescriptor();\n    if (descriptor->full_name() != kAnyFullTypeName) {\n      return false;\n    }\n    *type_url_field = descriptor->FindFieldByNumber(1);\n    *value_field = descriptor->FindFieldByNumber(2);\n    return (*type_url_field != NULL &&\n            (*type_url_field)->type() == FieldDescriptor::TYPE_STRING &&\n            *value_field != NULL &&\n            (*value_field)->type() == FieldDescriptor::TYPE_BYTES);\n}\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/any.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_ANY_H__\n#define GOOGLE_PROTOBUF_ANY_H__\n\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/arenastring.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\n// Helper class used to implement google::protobuf::Any.\nclass LIBPROTOBUF_EXPORT AnyMetadata {\n  typedef ArenaStringPtr UrlType;\n  typedef ArenaStringPtr ValueType;\n public:\n  // AnyMetadata does not take ownership of \"type_url\" and \"value\".\n  AnyMetadata(UrlType* type_url, ValueType* value);\n\n  // Packs a message using the default type URL prefix: \"type.googleapis.com\".\n  // The resulted type URL will be \"type.googleapis.com/<message_full_name>\".\n  void PackFrom(const Message& message);\n  // Packs a message using the given type URL prefix. The type URL will be\n  // constructed by concatenating the message type's full name to the prefix\n  // with an optional \"/\" separator if the prefix doesn't already end up \"/\".\n  // For example, both PackFrom(message, \"type.googleapis.com\") and\n  // PackFrom(message, \"type.googleapis.com/\") yield the same result type\n  // URL: \"type.googleapis.com/<message_full_name>\".\n  void PackFrom(const Message& message, const string& type_url_prefix);\n\n  // Unpacks the payload into the given message. Returns false if the message's\n  // type doesn't match the type specified in the type URL (i.e., the full\n  // name after the last \"/\" of the type URL doesn't match the message's actaul\n  // full name) or parsing the payload has failed.\n  bool UnpackTo(Message* message) const;\n\n  // Checks whether the type specified in the type URL matches the given type.\n  // A type is consdiered matching if its full name matches the full name after\n  // the last \"/\" in the type URL.\n  template<typename T>\n  bool Is() const {\n    return InternalIs(T::default_instance().GetDescriptor());\n  }\n\n private:\n  bool InternalIs(const Descriptor* message) const;\n\n  UrlType* type_url_;\n  ValueType* value_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(AnyMetadata);\n};\n\nextern const char kAnyFullTypeName[];          // \"google.protobuf.Any\".\nextern const char kTypeGoogleApisComPrefix[];  // \"type.googleapis.com/\".\nextern const char kTypeGoogleProdComPrefix[];  // \"type.googleprod.com/\".\n\n// Get the proto type name from Any::type_url value. For example, passing\n// \"type.googleapis.com/rpc.QueryOrigin\" will return \"rpc.QueryOrigin\" in\n// *full_type_name. Returns false if type_url does not start with\n// \"type.googleapis.com\" or \"type.googleprod.com\".\nbool ParseAnyTypeUrl(const string& type_url, string* full_type_name);\n\n// See if message is of type google.protobuf.Any, if so, return the descriptors\n// for \"type_url\" and \"value\" fields.\nbool GetAnyFieldDescriptors(const Message& message,\n                            const FieldDescriptor** type_url_field,\n                            const FieldDescriptor** value_field);\n\n}  // namespace internal\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_ANY_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/any.pb.cc",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/any.proto\n\n#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION\n#include <google/protobuf/any.pb.h>\n\n#include <algorithm>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/port.h>\n#include <google/protobuf/stubs/once.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/generated_message_reflection.h>\n#include <google/protobuf/reflection_ops.h>\n#include <google/protobuf/wire_format.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\n\nnamespace {\n\nconst ::google::protobuf::Descriptor* Any_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  Any_reflection_ = NULL;\n\n}  // namespace\n\n\nvoid protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto() {\n  protobuf_AddDesc_google_2fprotobuf_2fany_2eproto();\n  const ::google::protobuf::FileDescriptor* file =\n    ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(\n      \"google/protobuf/any.proto\");\n  GOOGLE_CHECK(file != NULL);\n  Any_descriptor_ = file->message_type(0);\n  static const int Any_offsets_[2] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, type_url_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, value_),\n  };\n  Any_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      Any_descriptor_,\n      Any::default_instance_,\n      Any_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(Any),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Any, _is_default_instance_));\n}\n\nnamespace {\n\nGOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);\ninline void protobuf_AssignDescriptorsOnce() {\n  ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,\n                 &protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto);\n}\n\nvoid protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_RegisterTypes(const ::std::string&) {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      Any_descriptor_, &Any::default_instance());\n}\n\n}  // namespace\n\nvoid protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto() {\n  delete Any::default_instance_;\n  delete Any_reflection_;\n}\n\nvoid protobuf_AddDesc_google_2fprotobuf_2fany_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AddDesc_google_2fprotobuf_2fany_2eproto() {\n  static bool already_here = false;\n  if (already_here) return;\n  already_here = true;\n  GOOGLE_PROTOBUF_VERIFY_VERSION;\n\n  ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(\n    \"\\n\\031google/protobuf/any.proto\\022\\017google.prot\"\n    \"obuf\\\"&\\n\\003Any\\022\\020\\n\\010type_url\\030\\001 \\001(\\t\\022\\r\\n\\005value\\030\\002\"\n    \" \\001(\\014Br\\n\\023com.google.protobufB\\010AnyProtoP\\001Z\"\n    \"%github.com/golang/protobuf/ptypes/any\\240\\001\"\n    \"\\001\\242\\002\\003GPB\\252\\002\\036Google.Protobuf.WellKnownTypes\"\n    \"b\\006proto3\", 208);\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(\n    \"google/protobuf/any.proto\", &protobuf_RegisterTypes);\n  Any::default_instance_ = new Any();\n  Any::default_instance_->InitAsDefaultInstance();\n  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto);\n}\n\n// Force AddDescriptors() to be called at static initialization time.\nstruct StaticDescriptorInitializer_google_2fprotobuf_2fany_2eproto {\n  StaticDescriptorInitializer_google_2fprotobuf_2fany_2eproto() {\n    protobuf_AddDesc_google_2fprotobuf_2fany_2eproto();\n  }\n} static_descriptor_initializer_google_2fprotobuf_2fany_2eproto_;\n\n// ===================================================================\n\nvoid Any::PackFrom(const ::google::protobuf::Message& message) {\n  _any_metadata_.PackFrom(message);\n}\n\nvoid Any::PackFrom(const ::google::protobuf::Message& message,\n                           const ::std::string& type_url_prefix) {\n  _any_metadata_.PackFrom(message, type_url_prefix);\n}\n\nbool Any::UnpackTo(::google::protobuf::Message* message) const {\n  return _any_metadata_.UnpackTo(message);\n}\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int Any::kTypeUrlFieldNumber;\nconst int Any::kValueFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nAny::Any()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL), _any_metadata_(&type_url_, &value_) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.Any)\n}\n\nvoid Any::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n}\n\nAny::Any(const Any& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL),\n    _any_metadata_(&type_url_, &value_) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.Any)\n}\n\nvoid Any::SharedCtor() {\n    _is_default_instance_ = false;\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n\nAny::~Any() {\n  // @@protoc_insertion_point(destructor:google.protobuf.Any)\n  SharedDtor();\n}\n\nvoid Any::SharedDtor() {\n  type_url_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n  }\n}\n\nvoid Any::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* Any::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return Any_descriptor_;\n}\n\nconst Any& Any::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fany_2eproto();\n  return *default_instance_;\n}\n\nAny* Any::default_instance_ = NULL;\n\nAny* Any::New(::google::protobuf::Arena* arena) const {\n  Any* n = new Any;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid Any::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.Any)\n  type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n\nbool Any::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.Any)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional string type_url = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_type_url()));\n          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n            this->type_url().data(), this->type_url().length(),\n            ::google::protobuf::internal::WireFormatLite::PARSE,\n            \"google.protobuf.Any.type_url\"));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_value;\n        break;\n      }\n\n      // optional bytes value = 2;\n      case 2: {\n        if (tag == 18) {\n         parse_value:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(\n                input, this->mutable_value()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.Any)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.Any)\n  return false;\n#undef DO_\n}\n\nvoid Any::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.Any)\n  // optional string type_url = 1;\n  if (this->type_url().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->type_url().data(), this->type_url().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Any.type_url\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      1, this->type_url(), output);\n  }\n\n  // optional bytes value = 2;\n  if (this->value().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(\n      2, this->value(), output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.Any)\n}\n\n::google::protobuf::uint8* Any::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Any)\n  // optional string type_url = 1;\n  if (this->type_url().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->type_url().data(), this->type_url().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Any.type_url\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        1, this->type_url(), target);\n  }\n\n  // optional bytes value = 2;\n  if (this->value().size() > 0) {\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteBytesToArray(\n        2, this->value(), target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Any)\n  return target;\n}\n\nint Any::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Any)\n  int total_size = 0;\n\n  // optional string type_url = 1;\n  if (this->type_url().size() > 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::StringSize(\n        this->type_url());\n  }\n\n  // optional bytes value = 2;\n  if (this->value().size() > 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::BytesSize(\n        this->value());\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid Any::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Any)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const Any* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const Any>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.Any)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Any)\n    MergeFrom(*source);\n  }\n}\n\nvoid Any::MergeFrom(const Any& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Any)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from.type_url().size() > 0) {\n\n    type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_url_);\n  }\n  if (from.value().size() > 0) {\n\n    value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.value_);\n  }\n}\n\nvoid Any::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.Any)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid Any::CopyFrom(const Any& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Any)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool Any::IsInitialized() const {\n\n  return true;\n}\n\nvoid Any::Swap(Any* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid Any::InternalSwap(Any* other) {\n  type_url_.Swap(&other->type_url_);\n  value_.Swap(&other->value_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata Any::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = Any_descriptor_;\n  metadata.reflection = Any_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// Any\n\n// optional string type_url = 1;\nvoid Any::clear_type_url() {\n  type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n const ::std::string& Any::type_url() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Any.type_url)\n  return type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Any::set_type_url(const ::std::string& value) {\n  \n  type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Any.type_url)\n}\n void Any::set_type_url(const char* value) {\n  \n  type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Any.type_url)\n}\n void Any::set_type_url(const char* value, size_t size) {\n  \n  type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Any.type_url)\n}\n ::std::string* Any::mutable_type_url() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Any.type_url)\n  return type_url_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* Any::release_type_url() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Any.type_url)\n  \n  return type_url_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Any::set_allocated_type_url(::std::string* type_url) {\n  if (type_url != NULL) {\n    \n  } else {\n    \n  }\n  type_url_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type_url);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.type_url)\n}\n\n// optional bytes value = 2;\nvoid Any::clear_value() {\n  value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n const ::std::string& Any::value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Any.value)\n  return value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Any::set_value(const ::std::string& value) {\n  \n  value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Any.value)\n}\n void Any::set_value(const char* value) {\n  \n  value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Any.value)\n}\n void Any::set_value(const void* value, size_t size) {\n  \n  value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Any.value)\n}\n ::std::string* Any::mutable_value() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Any.value)\n  return value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* Any::release_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Any.value)\n  \n  return value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Any::set_allocated_value(::std::string* value) {\n  if (value != NULL) {\n    \n  } else {\n    \n  }\n  value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace protobuf\n}  // namespace google\n\n// @@protoc_insertion_point(global_scope)\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/any.pb.h",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/any.proto\n\n#ifndef PROTOBUF_google_2fprotobuf_2fany_2eproto__INCLUDED\n#define PROTOBUF_google_2fprotobuf_2fany_2eproto__INCLUDED\n\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n\n#if GOOGLE_PROTOBUF_VERSION < 3000000\n#error This file was generated by a newer version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please update\n#error your headers.\n#endif\n#if 3000000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION\n#error This file was generated by an older version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please\n#error regenerate this file with a newer version of protoc.\n#endif\n\n#include <google/protobuf/arena.h>\n#include <google/protobuf/arenastring.h>\n#include <google/protobuf/generated_message_util.h>\n#include <google/protobuf/metadata.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/extension_set.h>\n#include <google/protobuf/unknown_field_set.h>\n#include <google/protobuf/any.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\n\n// Internal implementation detail -- do not call these.\nvoid LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fany_2eproto();\nvoid protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto();\nvoid protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto();\n\nclass Any;\n\n// ===================================================================\n\nclass LIBPROTOBUF_EXPORT Any : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Any) */ {\n public:\n  Any();\n  virtual ~Any();\n\n  Any(const Any& from);\n\n  inline Any& operator=(const Any& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const Any& default_instance();\n\n  // implements Any -----------------------------------------------\n\n  void PackFrom(const ::google::protobuf::Message& message);\n  void PackFrom(const ::google::protobuf::Message& message,\n                const ::std::string& type_url_prefix);\n  bool UnpackTo(::google::protobuf::Message* message) const;\n  template<typename T> bool Is() const {\n    return _any_metadata_.Is<T>();\n  }\n\n  void Swap(Any* other);\n\n  // implements Message ----------------------------------------------\n\n  inline Any* New() const { return New(NULL); }\n\n  Any* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const Any& from);\n  void MergeFrom(const Any& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(Any* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional string type_url = 1;\n  void clear_type_url();\n  static const int kTypeUrlFieldNumber = 1;\n  const ::std::string& type_url() const;\n  void set_type_url(const ::std::string& value);\n  void set_type_url(const char* value);\n  void set_type_url(const char* value, size_t size);\n  ::std::string* mutable_type_url();\n  ::std::string* release_type_url();\n  void set_allocated_type_url(::std::string* type_url);\n\n  // optional bytes value = 2;\n  void clear_value();\n  static const int kValueFieldNumber = 2;\n  const ::std::string& value() const;\n  void set_value(const ::std::string& value);\n  void set_value(const char* value);\n  void set_value(const void* value, size_t size);\n  ::std::string* mutable_value();\n  ::std::string* release_value();\n  void set_allocated_value(::std::string* value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.Any)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  bool _is_default_instance_;\n  ::google::protobuf::internal::ArenaStringPtr type_url_;\n  ::google::protobuf::internal::ArenaStringPtr value_;\n  mutable int _cached_size_;\n  ::google::protobuf::internal::AnyMetadata _any_metadata_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fany_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fany_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fany_2eproto();\n\n  void InitAsDefaultInstance();\n  static Any* default_instance_;\n};\n// ===================================================================\n\n\n// ===================================================================\n\n#if !PROTOBUF_INLINE_NOT_IN_HEADERS\n// Any\n\n// optional string type_url = 1;\ninline void Any::clear_type_url() {\n  type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline const ::std::string& Any::type_url() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Any.type_url)\n  return type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Any::set_type_url(const ::std::string& value) {\n  \n  type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Any.type_url)\n}\ninline void Any::set_type_url(const char* value) {\n  \n  type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Any.type_url)\n}\ninline void Any::set_type_url(const char* value, size_t size) {\n  \n  type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Any.type_url)\n}\ninline ::std::string* Any::mutable_type_url() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Any.type_url)\n  return type_url_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* Any::release_type_url() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Any.type_url)\n  \n  return type_url_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Any::set_allocated_type_url(::std::string* type_url) {\n  if (type_url != NULL) {\n    \n  } else {\n    \n  }\n  type_url_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type_url);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.type_url)\n}\n\n// optional bytes value = 2;\ninline void Any::clear_value() {\n  value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline const ::std::string& Any::value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Any.value)\n  return value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Any::set_value(const ::std::string& value) {\n  \n  value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Any.value)\n}\ninline void Any::set_value(const char* value) {\n  \n  value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Any.value)\n}\ninline void Any::set_value(const void* value, size_t size) {\n  \n  value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Any.value)\n}\ninline ::std::string* Any::mutable_value() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Any.value)\n  return value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* Any::release_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Any.value)\n  \n  return value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Any::set_allocated_value(::std::string* value) {\n  if (value != NULL) {\n    \n  } else {\n    \n  }\n  value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Any.value)\n}\n\n#endif  // !PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace protobuf\n}  // namespace google\n\n// @@protoc_insertion_point(global_scope)\n\n#endif  // PROTOBUF_google_2fprotobuf_2fany_2eproto__INCLUDED\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/any.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto3\";\n\npackage google.protobuf;\n\noption csharp_namespace = \"Google.Protobuf.WellKnownTypes\";\noption go_package = \"github.com/golang/protobuf/ptypes/any\";\noption java_package = \"com.google.protobuf\";\noption java_outer_classname = \"AnyProto\";\noption java_multiple_files = true;\noption java_generate_equals_and_hash = true;\noption objc_class_prefix = \"GPB\";\n\n// `Any` contains an arbitrary serialized protocol buffer message along with a\n// URL that describes the type of the serialized message.\n//\n// Protobuf library provides support to pack/unpack Any values in the form\n// of utility functions or additional generated methods of the Any type.\n//\n// Example 1: Pack and unpack a message in C++.\n//\n//     Foo foo = ...;\n//     Any any;\n//     any.PackFrom(foo);\n//     ...\n//     if (any.UnpackTo(&foo)) {\n//       ...\n//     }\n//\n// Example 2: Pack and unpack a message in Java.\n//\n//     Foo foo = ...;\n//     Any any = Any.pack(foo);\n//     ...\n//     if (any.is(Foo.class)) {\n//       foo = any.unpack(Foo.class);\n//     }\n//\n//  Example 3: Pack and unpack a message in Python.\n//\n//     foo = Foo(...)\n//     any = Any()\n//     any.Pack(foo)\n//     ...\n//     if any.Is(Foo.DESCRIPTOR):\n//       any.Unpack(foo)\n//       ...\n//\n// The pack methods provided by protobuf library will by default use\n// 'type.googleapis.com/full.type.name' as the type URL and the unpack\n// methods only use the fully qualified type name after the last '/'\n// in the type URL, for example \"foo.bar.com/x/y.z\" will yield type\n// name \"y.z\".\n//\n//\n// JSON\n// ====\n// The JSON representation of an `Any` value uses the regular\n// representation of the deserialized, embedded message, with an\n// additional field `@type` which contains the type URL. Example:\n//\n//     package google.profile;\n//     message Person {\n//       string first_name = 1;\n//       string last_name = 2;\n//     }\n//\n//     {\n//       \"@type\": \"type.googleapis.com/google.profile.Person\",\n//       \"firstName\": <string>,\n//       \"lastName\": <string>\n//     }\n//\n// If the embedded message type is well-known and has a custom JSON\n// representation, that representation will be embedded adding a field\n// `value` which holds the custom JSON in addition to the `@type`\n// field. Example (for message [google.protobuf.Duration][]):\n//\n//     {\n//       \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n//       \"value\": \"1.212s\"\n//     }\n//\nmessage Any {\n  // A URL/resource name whose content describes the type of the\n  // serialized protocol buffer message.\n  //\n  // For URLs which use the scheme `http`, `https`, or no scheme, the\n  // following restrictions and interpretations apply:\n  //\n  // * If no scheme is provided, `https` is assumed.\n  // * The last segment of the URL's path must represent the fully\n  //   qualified name of the type (as in `path/google.protobuf.Duration`).\n  //   The name should be in a canonical form (e.g., leading \".\" is\n  //   not accepted).\n  // * An HTTP GET on the URL must yield a [google.protobuf.Type][]\n  //   value in binary format, or produce an error.\n  // * Applications are allowed to cache lookup results based on the\n  //   URL, or have them precompiled into a binary to avoid any\n  //   lookup. Therefore, binary compatibility needs to be preserved\n  //   on changes to types. (Use versioned type names to manage\n  //   breaking changes.)\n  //\n  // Schemes other than `http`, `https` (or the empty scheme) might be\n  // used with implementation specific semantics.\n  //\n  string type_url = 1;\n\n  // Must be a valid serialized protocol buffer of the above specified type.\n  bytes value = 2;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/any_test.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/any_test.pb.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace {\n\nTEST(AnyTest, TestPackAndUnpack) {\n  protobuf_unittest::TestAny submessage;\n  submessage.set_int32_value(12345);\n  protobuf_unittest::TestAny message;\n  message.mutable_any_value()->PackFrom(submessage);\n\n  string data = message.SerializeAsString();\n\n  ASSERT_TRUE(message.ParseFromString(data));\n  EXPECT_TRUE(message.has_any_value());\n  ASSERT_TRUE(message.any_value().UnpackTo(&submessage));\n  EXPECT_EQ(12345, submessage.int32_value());\n}\n\nTEST(AnyTest, TestPackAndUnpackAny) {\n  // We can pack a Any message inside another Any message.\n  protobuf_unittest::TestAny submessage;\n  submessage.set_int32_value(12345);\n  google::protobuf::Any any;\n  any.PackFrom(submessage);\n  protobuf_unittest::TestAny message;\n  message.mutable_any_value()->PackFrom(any);\n\n  string data = message.SerializeAsString();\n\n  ASSERT_TRUE(message.ParseFromString(data));\n  EXPECT_TRUE(message.has_any_value());\n  ASSERT_TRUE(message.any_value().UnpackTo(&any));\n  ASSERT_TRUE(any.UnpackTo(&submessage));\n  EXPECT_EQ(12345, submessage.int32_value());\n}\n\nTEST(AnyTest, TestIs) {\n  protobuf_unittest::TestAny submessage;\n  submessage.set_int32_value(12345);\n  google::protobuf::Any any;\n  any.PackFrom(submessage);\n  ASSERT_TRUE(any.ParseFromString(any.SerializeAsString()));\n  EXPECT_TRUE(any.Is<protobuf_unittest::TestAny>());\n  EXPECT_FALSE(any.Is<google::protobuf::Any>());\n\n  protobuf_unittest::TestAny message;\n  message.mutable_any_value()->PackFrom(any);\n  ASSERT_TRUE(message.ParseFromString(message.SerializeAsString()));\n  EXPECT_FALSE(message.any_value().Is<protobuf_unittest::TestAny>());\n  EXPECT_TRUE(message.any_value().Is<google::protobuf::Any>());\n}\n\n}  // namespace\n}  // namespace protobuf\n\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/any_test.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto3\";\n\npackage protobuf_unittest;\n\nimport \"google/protobuf/any.proto\";\n\nmessage TestAny {\n  int32 int32_value = 1;\n  google.protobuf.Any any_value = 2;\n  repeated google.protobuf.Any repeated_any_value = 3;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/api.pb.cc",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/api.proto\n\n#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION\n#include <google/protobuf/api.pb.h>\n\n#include <algorithm>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/port.h>\n#include <google/protobuf/stubs/once.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/generated_message_reflection.h>\n#include <google/protobuf/reflection_ops.h>\n#include <google/protobuf/wire_format.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\n\nnamespace {\n\nconst ::google::protobuf::Descriptor* Api_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  Api_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* Method_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  Method_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* Mixin_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  Mixin_reflection_ = NULL;\n\n}  // namespace\n\n\nvoid protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto() {\n  protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto();\n  const ::google::protobuf::FileDescriptor* file =\n    ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(\n      \"google/protobuf/api.proto\");\n  GOOGLE_CHECK(file != NULL);\n  Api_descriptor_ = file->message_type(0);\n  static const int Api_offsets_[7] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, name_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, methods_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, options_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, version_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, source_context_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, mixins_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, syntax_),\n  };\n  Api_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      Api_descriptor_,\n      Api::default_instance_,\n      Api_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(Api),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Api, _is_default_instance_));\n  Method_descriptor_ = file->message_type(1);\n  static const int Method_offsets_[7] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, name_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, request_type_url_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, request_streaming_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, response_type_url_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, response_streaming_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, options_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, syntax_),\n  };\n  Method_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      Method_descriptor_,\n      Method::default_instance_,\n      Method_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(Method),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Method, _is_default_instance_));\n  Mixin_descriptor_ = file->message_type(2);\n  static const int Mixin_offsets_[2] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, name_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, root_),\n  };\n  Mixin_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      Mixin_descriptor_,\n      Mixin::default_instance_,\n      Mixin_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(Mixin),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Mixin, _is_default_instance_));\n}\n\nnamespace {\n\nGOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);\ninline void protobuf_AssignDescriptorsOnce() {\n  ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,\n                 &protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto);\n}\n\nvoid protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_RegisterTypes(const ::std::string&) {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      Api_descriptor_, &Api::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      Method_descriptor_, &Method::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      Mixin_descriptor_, &Mixin::default_instance());\n}\n\n}  // namespace\n\nvoid protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto() {\n  delete Api::default_instance_;\n  delete Api_reflection_;\n  delete Method::default_instance_;\n  delete Method_reflection_;\n  delete Mixin::default_instance_;\n  delete Mixin_reflection_;\n}\n\nvoid protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto() {\n  static bool already_here = false;\n  if (already_here) return;\n  already_here = true;\n  GOOGLE_PROTOBUF_VERIFY_VERSION;\n\n  ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();\n  ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();\n  ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(\n    \"\\n\\031google/protobuf/api.proto\\022\\017google.prot\"\n    \"obuf\\032$google/protobuf/source_context.pro\"\n    \"to\\032\\032google/protobuf/type.proto\\\"\\201\\002\\n\\003Api\\022\\014\"\n    \"\\n\\004name\\030\\001 \\001(\\t\\022(\\n\\007methods\\030\\002 \\003(\\0132\\027.google.p\"\n    \"rotobuf.Method\\022(\\n\\007options\\030\\003 \\003(\\0132\\027.google\"\n    \".protobuf.Option\\022\\017\\n\\007version\\030\\004 \\001(\\t\\0226\\n\\016sou\"\n    \"rce_context\\030\\005 \\001(\\0132\\036.google.protobuf.Sour\"\n    \"ceContext\\022&\\n\\006mixins\\030\\006 \\003(\\0132\\026.google.proto\"\n    \"buf.Mixin\\022\\'\\n\\006syntax\\030\\007 \\001(\\0162\\027.google.proto\"\n    \"buf.Syntax\\\"\\325\\001\\n\\006Method\\022\\014\\n\\004name\\030\\001 \\001(\\t\\022\\030\\n\\020r\"\n    \"equest_type_url\\030\\002 \\001(\\t\\022\\031\\n\\021request_streami\"\n    \"ng\\030\\003 \\001(\\010\\022\\031\\n\\021response_type_url\\030\\004 \\001(\\t\\022\\032\\n\\022r\"\n    \"esponse_streaming\\030\\005 \\001(\\010\\022(\\n\\007options\\030\\006 \\003(\\013\"\n    \"2\\027.google.protobuf.Option\\022\\'\\n\\006syntax\\030\\007 \\001(\"\n    \"\\0162\\027.google.protobuf.Syntax\\\"#\\n\\005Mixin\\022\\014\\n\\004n\"\n    \"ame\\030\\001 \\001(\\t\\022\\014\\n\\004root\\030\\002 \\001(\\tBK\\n\\023com.google.pr\"\n    \"otobufB\\010ApiProtoP\\001\\240\\001\\001\\242\\002\\003GPB\\252\\002\\036Google.Pro\"\n    \"tobuf.WellKnownTypesb\\006proto3\", 708);\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(\n    \"google/protobuf/api.proto\", &protobuf_RegisterTypes);\n  Api::default_instance_ = new Api();\n  Method::default_instance_ = new Method();\n  Mixin::default_instance_ = new Mixin();\n  Api::default_instance_->InitAsDefaultInstance();\n  Method::default_instance_->InitAsDefaultInstance();\n  Mixin::default_instance_->InitAsDefaultInstance();\n  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto);\n}\n\n// Force AddDescriptors() to be called at static initialization time.\nstruct StaticDescriptorInitializer_google_2fprotobuf_2fapi_2eproto {\n  StaticDescriptorInitializer_google_2fprotobuf_2fapi_2eproto() {\n    protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto();\n  }\n} static_descriptor_initializer_google_2fprotobuf_2fapi_2eproto_;\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int Api::kNameFieldNumber;\nconst int Api::kMethodsFieldNumber;\nconst int Api::kOptionsFieldNumber;\nconst int Api::kVersionFieldNumber;\nconst int Api::kSourceContextFieldNumber;\nconst int Api::kMixinsFieldNumber;\nconst int Api::kSyntaxFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nApi::Api()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.Api)\n}\n\nvoid Api::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n  source_context_ = const_cast< ::google::protobuf::SourceContext*>(&::google::protobuf::SourceContext::default_instance());\n}\n\nApi::Api(const Api& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.Api)\n}\n\nvoid Api::SharedCtor() {\n    _is_default_instance_ = false;\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  version_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  source_context_ = NULL;\n  syntax_ = 0;\n}\n\nApi::~Api() {\n  // @@protoc_insertion_point(destructor:google.protobuf.Api)\n  SharedDtor();\n}\n\nvoid Api::SharedDtor() {\n  name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  version_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n    delete source_context_;\n  }\n}\n\nvoid Api::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* Api::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return Api_descriptor_;\n}\n\nconst Api& Api::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto();\n  return *default_instance_;\n}\n\nApi* Api::default_instance_ = NULL;\n\nApi* Api::New(::google::protobuf::Arena* arena) const {\n  Api* n = new Api;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid Api::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.Api)\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  version_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_;\n  source_context_ = NULL;\n  syntax_ = 0;\n  methods_.Clear();\n  options_.Clear();\n  mixins_.Clear();\n}\n\nbool Api::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.Api)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional string name = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_name()));\n          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n            this->name().data(), this->name().length(),\n            ::google::protobuf::internal::WireFormatLite::PARSE,\n            \"google.protobuf.Api.name\"));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_methods;\n        break;\n      }\n\n      // repeated .google.protobuf.Method methods = 2;\n      case 2: {\n        if (tag == 18) {\n         parse_methods:\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_methods:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_methods()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_loop_methods;\n        if (input->ExpectTag(26)) goto parse_loop_options;\n        input->UnsafeDecrementRecursionDepth();\n        break;\n      }\n\n      // repeated .google.protobuf.Option options = 3;\n      case 3: {\n        if (tag == 26) {\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_options:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_options()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(26)) goto parse_loop_options;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectTag(34)) goto parse_version;\n        break;\n      }\n\n      // optional string version = 4;\n      case 4: {\n        if (tag == 34) {\n         parse_version:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_version()));\n          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n            this->version().data(), this->version().length(),\n            ::google::protobuf::internal::WireFormatLite::PARSE,\n            \"google.protobuf.Api.version\"));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(42)) goto parse_source_context;\n        break;\n      }\n\n      // optional .google.protobuf.SourceContext source_context = 5;\n      case 5: {\n        if (tag == 42) {\n         parse_source_context:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\n               input, mutable_source_context()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(50)) goto parse_mixins;\n        break;\n      }\n\n      // repeated .google.protobuf.Mixin mixins = 6;\n      case 6: {\n        if (tag == 50) {\n         parse_mixins:\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_mixins:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_mixins()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(50)) goto parse_loop_mixins;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectTag(56)) goto parse_syntax;\n        break;\n      }\n\n      // optional .google.protobuf.Syntax syntax = 7;\n      case 7: {\n        if (tag == 56) {\n         parse_syntax:\n          int value;\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n                 input, &value)));\n          set_syntax(static_cast< ::google::protobuf::Syntax >(value));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.Api)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.Api)\n  return false;\n#undef DO_\n}\n\nvoid Api::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.Api)\n  // optional string name = 1;\n  if (this->name().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Api.name\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      1, this->name(), output);\n  }\n\n  // repeated .google.protobuf.Method methods = 2;\n  for (unsigned int i = 0, n = this->methods_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      2, this->methods(i), output);\n  }\n\n  // repeated .google.protobuf.Option options = 3;\n  for (unsigned int i = 0, n = this->options_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      3, this->options(i), output);\n  }\n\n  // optional string version = 4;\n  if (this->version().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->version().data(), this->version().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Api.version\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      4, this->version(), output);\n  }\n\n  // optional .google.protobuf.SourceContext source_context = 5;\n  if (this->has_source_context()) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      5, *this->source_context_, output);\n  }\n\n  // repeated .google.protobuf.Mixin mixins = 6;\n  for (unsigned int i = 0, n = this->mixins_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      6, this->mixins(i), output);\n  }\n\n  // optional .google.protobuf.Syntax syntax = 7;\n  if (this->syntax() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteEnum(\n      7, this->syntax(), output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.Api)\n}\n\n::google::protobuf::uint8* Api::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Api)\n  // optional string name = 1;\n  if (this->name().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Api.name\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        1, this->name(), target);\n  }\n\n  // repeated .google.protobuf.Method methods = 2;\n  for (unsigned int i = 0, n = this->methods_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        2, this->methods(i), false, target);\n  }\n\n  // repeated .google.protobuf.Option options = 3;\n  for (unsigned int i = 0, n = this->options_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        3, this->options(i), false, target);\n  }\n\n  // optional string version = 4;\n  if (this->version().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->version().data(), this->version().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Api.version\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        4, this->version(), target);\n  }\n\n  // optional .google.protobuf.SourceContext source_context = 5;\n  if (this->has_source_context()) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        5, *this->source_context_, false, target);\n  }\n\n  // repeated .google.protobuf.Mixin mixins = 6;\n  for (unsigned int i = 0, n = this->mixins_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        6, this->mixins(i), false, target);\n  }\n\n  // optional .google.protobuf.Syntax syntax = 7;\n  if (this->syntax() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(\n      7, this->syntax(), target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Api)\n  return target;\n}\n\nint Api::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Api)\n  int total_size = 0;\n\n  // optional string name = 1;\n  if (this->name().size() > 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::StringSize(\n        this->name());\n  }\n\n  // optional string version = 4;\n  if (this->version().size() > 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::StringSize(\n        this->version());\n  }\n\n  // optional .google.protobuf.SourceContext source_context = 5;\n  if (this->has_source_context()) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        *this->source_context_);\n  }\n\n  // optional .google.protobuf.Syntax syntax = 7;\n  if (this->syntax() != 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax());\n  }\n\n  // repeated .google.protobuf.Method methods = 2;\n  total_size += 1 * this->methods_size();\n  for (int i = 0; i < this->methods_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->methods(i));\n  }\n\n  // repeated .google.protobuf.Option options = 3;\n  total_size += 1 * this->options_size();\n  for (int i = 0; i < this->options_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->options(i));\n  }\n\n  // repeated .google.protobuf.Mixin mixins = 6;\n  total_size += 1 * this->mixins_size();\n  for (int i = 0; i < this->mixins_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->mixins(i));\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid Api::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Api)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const Api* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const Api>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.Api)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Api)\n    MergeFrom(*source);\n  }\n}\n\nvoid Api::MergeFrom(const Api& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Api)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  methods_.MergeFrom(from.methods_);\n  options_.MergeFrom(from.options_);\n  mixins_.MergeFrom(from.mixins_);\n  if (from.name().size() > 0) {\n\n    name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);\n  }\n  if (from.version().size() > 0) {\n\n    version_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.version_);\n  }\n  if (from.has_source_context()) {\n    mutable_source_context()->::google::protobuf::SourceContext::MergeFrom(from.source_context());\n  }\n  if (from.syntax() != 0) {\n    set_syntax(from.syntax());\n  }\n}\n\nvoid Api::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.Api)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid Api::CopyFrom(const Api& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Api)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool Api::IsInitialized() const {\n\n  return true;\n}\n\nvoid Api::Swap(Api* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid Api::InternalSwap(Api* other) {\n  name_.Swap(&other->name_);\n  methods_.UnsafeArenaSwap(&other->methods_);\n  options_.UnsafeArenaSwap(&other->options_);\n  version_.Swap(&other->version_);\n  std::swap(source_context_, other->source_context_);\n  mixins_.UnsafeArenaSwap(&other->mixins_);\n  std::swap(syntax_, other->syntax_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata Api::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = Api_descriptor_;\n  metadata.reflection = Api_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// Api\n\n// optional string name = 1;\nvoid Api::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n const ::std::string& Api::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Api.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Api::set_name(const ::std::string& value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Api.name)\n}\n void Api::set_name(const char* value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Api.name)\n}\n void Api::set_name(const char* value, size_t size) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Api.name)\n}\n ::std::string* Api::mutable_name() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Api.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* Api::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Api.name)\n  \n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Api::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    \n  } else {\n    \n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.name)\n}\n\n// repeated .google.protobuf.Method methods = 2;\nint Api::methods_size() const {\n  return methods_.size();\n}\nvoid Api::clear_methods() {\n  methods_.Clear();\n}\nconst ::google::protobuf::Method& Api::methods(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Api.methods)\n  return methods_.Get(index);\n}\n::google::protobuf::Method* Api::mutable_methods(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Api.methods)\n  return methods_.Mutable(index);\n}\n::google::protobuf::Method* Api::add_methods() {\n  // @@protoc_insertion_point(field_add:google.protobuf.Api.methods)\n  return methods_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::Method >*\nApi::mutable_methods() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.Api.methods)\n  return &methods_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::Method >&\nApi::methods() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.Api.methods)\n  return methods_;\n}\n\n// repeated .google.protobuf.Option options = 3;\nint Api::options_size() const {\n  return options_.size();\n}\nvoid Api::clear_options() {\n  options_.Clear();\n}\nconst ::google::protobuf::Option& Api::options(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Api.options)\n  return options_.Get(index);\n}\n::google::protobuf::Option* Api::mutable_options(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Api.options)\n  return options_.Mutable(index);\n}\n::google::protobuf::Option* Api::add_options() {\n  // @@protoc_insertion_point(field_add:google.protobuf.Api.options)\n  return options_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*\nApi::mutable_options() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.Api.options)\n  return &options_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&\nApi::options() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.Api.options)\n  return options_;\n}\n\n// optional string version = 4;\nvoid Api::clear_version() {\n  version_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n const ::std::string& Api::version() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Api.version)\n  return version_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Api::set_version(const ::std::string& value) {\n  \n  version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Api.version)\n}\n void Api::set_version(const char* value) {\n  \n  version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Api.version)\n}\n void Api::set_version(const char* value, size_t size) {\n  \n  version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Api.version)\n}\n ::std::string* Api::mutable_version() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Api.version)\n  return version_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* Api::release_version() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Api.version)\n  \n  return version_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Api::set_allocated_version(::std::string* version) {\n  if (version != NULL) {\n    \n  } else {\n    \n  }\n  version_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), version);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.version)\n}\n\n// optional .google.protobuf.SourceContext source_context = 5;\nbool Api::has_source_context() const {\n  return !_is_default_instance_ && source_context_ != NULL;\n}\nvoid Api::clear_source_context() {\n  if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_;\n  source_context_ = NULL;\n}\nconst ::google::protobuf::SourceContext& Api::source_context() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Api.source_context)\n  return source_context_ != NULL ? *source_context_ : *default_instance_->source_context_;\n}\n::google::protobuf::SourceContext* Api::mutable_source_context() {\n  \n  if (source_context_ == NULL) {\n    source_context_ = new ::google::protobuf::SourceContext;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Api.source_context)\n  return source_context_;\n}\n::google::protobuf::SourceContext* Api::release_source_context() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Api.source_context)\n  \n  ::google::protobuf::SourceContext* temp = source_context_;\n  source_context_ = NULL;\n  return temp;\n}\nvoid Api::set_allocated_source_context(::google::protobuf::SourceContext* source_context) {\n  delete source_context_;\n  source_context_ = source_context;\n  if (source_context) {\n    \n  } else {\n    \n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.source_context)\n}\n\n// repeated .google.protobuf.Mixin mixins = 6;\nint Api::mixins_size() const {\n  return mixins_.size();\n}\nvoid Api::clear_mixins() {\n  mixins_.Clear();\n}\nconst ::google::protobuf::Mixin& Api::mixins(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Api.mixins)\n  return mixins_.Get(index);\n}\n::google::protobuf::Mixin* Api::mutable_mixins(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Api.mixins)\n  return mixins_.Mutable(index);\n}\n::google::protobuf::Mixin* Api::add_mixins() {\n  // @@protoc_insertion_point(field_add:google.protobuf.Api.mixins)\n  return mixins_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >*\nApi::mutable_mixins() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.Api.mixins)\n  return &mixins_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >&\nApi::mixins() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.Api.mixins)\n  return mixins_;\n}\n\n// optional .google.protobuf.Syntax syntax = 7;\nvoid Api::clear_syntax() {\n  syntax_ = 0;\n}\n ::google::protobuf::Syntax Api::syntax() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Api.syntax)\n  return static_cast< ::google::protobuf::Syntax >(syntax_);\n}\n void Api::set_syntax(::google::protobuf::Syntax value) {\n  \n  syntax_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Api.syntax)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int Method::kNameFieldNumber;\nconst int Method::kRequestTypeUrlFieldNumber;\nconst int Method::kRequestStreamingFieldNumber;\nconst int Method::kResponseTypeUrlFieldNumber;\nconst int Method::kResponseStreamingFieldNumber;\nconst int Method::kOptionsFieldNumber;\nconst int Method::kSyntaxFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nMethod::Method()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.Method)\n}\n\nvoid Method::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n}\n\nMethod::Method(const Method& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.Method)\n}\n\nvoid Method::SharedCtor() {\n    _is_default_instance_ = false;\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  request_type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  request_streaming_ = false;\n  response_type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  response_streaming_ = false;\n  syntax_ = 0;\n}\n\nMethod::~Method() {\n  // @@protoc_insertion_point(destructor:google.protobuf.Method)\n  SharedDtor();\n}\n\nvoid Method::SharedDtor() {\n  name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  request_type_url_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  response_type_url_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n  }\n}\n\nvoid Method::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* Method::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return Method_descriptor_;\n}\n\nconst Method& Method::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto();\n  return *default_instance_;\n}\n\nMethod* Method::default_instance_ = NULL;\n\nMethod* Method::New(::google::protobuf::Arena* arena) const {\n  Method* n = new Method;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid Method::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.Method)\n#if defined(__clang__)\n#define ZR_HELPER_(f) \\\n  _Pragma(\"clang diagnostic push\") \\\n  _Pragma(\"clang diagnostic ignored \\\"-Winvalid-offsetof\\\"\") \\\n  __builtin_offsetof(Method, f) \\\n  _Pragma(\"clang diagnostic pop\")\n#else\n#define ZR_HELPER_(f) reinterpret_cast<char*>(\\\n  &reinterpret_cast<Method*>(16)->f)\n#endif\n\n#define ZR_(first, last) do {\\\n  ::memset(&first, 0,\\\n           ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\\\n} while (0)\n\n  ZR_(request_streaming_, syntax_);\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  request_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  response_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n\n#undef ZR_HELPER_\n#undef ZR_\n\n  options_.Clear();\n}\n\nbool Method::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.Method)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional string name = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_name()));\n          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n            this->name().data(), this->name().length(),\n            ::google::protobuf::internal::WireFormatLite::PARSE,\n            \"google.protobuf.Method.name\"));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_request_type_url;\n        break;\n      }\n\n      // optional string request_type_url = 2;\n      case 2: {\n        if (tag == 18) {\n         parse_request_type_url:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_request_type_url()));\n          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n            this->request_type_url().data(), this->request_type_url().length(),\n            ::google::protobuf::internal::WireFormatLite::PARSE,\n            \"google.protobuf.Method.request_type_url\"));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(24)) goto parse_request_streaming;\n        break;\n      }\n\n      // optional bool request_streaming = 3;\n      case 3: {\n        if (tag == 24) {\n         parse_request_streaming:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &request_streaming_)));\n\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(34)) goto parse_response_type_url;\n        break;\n      }\n\n      // optional string response_type_url = 4;\n      case 4: {\n        if (tag == 34) {\n         parse_response_type_url:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_response_type_url()));\n          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n            this->response_type_url().data(), this->response_type_url().length(),\n            ::google::protobuf::internal::WireFormatLite::PARSE,\n            \"google.protobuf.Method.response_type_url\"));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(40)) goto parse_response_streaming;\n        break;\n      }\n\n      // optional bool response_streaming = 5;\n      case 5: {\n        if (tag == 40) {\n         parse_response_streaming:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &response_streaming_)));\n\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(50)) goto parse_options;\n        break;\n      }\n\n      // repeated .google.protobuf.Option options = 6;\n      case 6: {\n        if (tag == 50) {\n         parse_options:\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_options:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_options()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(50)) goto parse_loop_options;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectTag(56)) goto parse_syntax;\n        break;\n      }\n\n      // optional .google.protobuf.Syntax syntax = 7;\n      case 7: {\n        if (tag == 56) {\n         parse_syntax:\n          int value;\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n                 input, &value)));\n          set_syntax(static_cast< ::google::protobuf::Syntax >(value));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.Method)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.Method)\n  return false;\n#undef DO_\n}\n\nvoid Method::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.Method)\n  // optional string name = 1;\n  if (this->name().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Method.name\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      1, this->name(), output);\n  }\n\n  // optional string request_type_url = 2;\n  if (this->request_type_url().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->request_type_url().data(), this->request_type_url().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Method.request_type_url\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      2, this->request_type_url(), output);\n  }\n\n  // optional bool request_streaming = 3;\n  if (this->request_streaming() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(3, this->request_streaming(), output);\n  }\n\n  // optional string response_type_url = 4;\n  if (this->response_type_url().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->response_type_url().data(), this->response_type_url().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Method.response_type_url\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      4, this->response_type_url(), output);\n  }\n\n  // optional bool response_streaming = 5;\n  if (this->response_streaming() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(5, this->response_streaming(), output);\n  }\n\n  // repeated .google.protobuf.Option options = 6;\n  for (unsigned int i = 0, n = this->options_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      6, this->options(i), output);\n  }\n\n  // optional .google.protobuf.Syntax syntax = 7;\n  if (this->syntax() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteEnum(\n      7, this->syntax(), output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.Method)\n}\n\n::google::protobuf::uint8* Method::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Method)\n  // optional string name = 1;\n  if (this->name().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Method.name\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        1, this->name(), target);\n  }\n\n  // optional string request_type_url = 2;\n  if (this->request_type_url().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->request_type_url().data(), this->request_type_url().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Method.request_type_url\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        2, this->request_type_url(), target);\n  }\n\n  // optional bool request_streaming = 3;\n  if (this->request_streaming() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(3, this->request_streaming(), target);\n  }\n\n  // optional string response_type_url = 4;\n  if (this->response_type_url().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->response_type_url().data(), this->response_type_url().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Method.response_type_url\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        4, this->response_type_url(), target);\n  }\n\n  // optional bool response_streaming = 5;\n  if (this->response_streaming() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(5, this->response_streaming(), target);\n  }\n\n  // repeated .google.protobuf.Option options = 6;\n  for (unsigned int i = 0, n = this->options_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        6, this->options(i), false, target);\n  }\n\n  // optional .google.protobuf.Syntax syntax = 7;\n  if (this->syntax() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(\n      7, this->syntax(), target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Method)\n  return target;\n}\n\nint Method::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Method)\n  int total_size = 0;\n\n  // optional string name = 1;\n  if (this->name().size() > 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::StringSize(\n        this->name());\n  }\n\n  // optional string request_type_url = 2;\n  if (this->request_type_url().size() > 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::StringSize(\n        this->request_type_url());\n  }\n\n  // optional bool request_streaming = 3;\n  if (this->request_streaming() != 0) {\n    total_size += 1 + 1;\n  }\n\n  // optional string response_type_url = 4;\n  if (this->response_type_url().size() > 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::StringSize(\n        this->response_type_url());\n  }\n\n  // optional bool response_streaming = 5;\n  if (this->response_streaming() != 0) {\n    total_size += 1 + 1;\n  }\n\n  // optional .google.protobuf.Syntax syntax = 7;\n  if (this->syntax() != 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax());\n  }\n\n  // repeated .google.protobuf.Option options = 6;\n  total_size += 1 * this->options_size();\n  for (int i = 0; i < this->options_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->options(i));\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid Method::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Method)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const Method* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const Method>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.Method)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Method)\n    MergeFrom(*source);\n  }\n}\n\nvoid Method::MergeFrom(const Method& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Method)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  options_.MergeFrom(from.options_);\n  if (from.name().size() > 0) {\n\n    name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);\n  }\n  if (from.request_type_url().size() > 0) {\n\n    request_type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.request_type_url_);\n  }\n  if (from.request_streaming() != 0) {\n    set_request_streaming(from.request_streaming());\n  }\n  if (from.response_type_url().size() > 0) {\n\n    response_type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.response_type_url_);\n  }\n  if (from.response_streaming() != 0) {\n    set_response_streaming(from.response_streaming());\n  }\n  if (from.syntax() != 0) {\n    set_syntax(from.syntax());\n  }\n}\n\nvoid Method::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.Method)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid Method::CopyFrom(const Method& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Method)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool Method::IsInitialized() const {\n\n  return true;\n}\n\nvoid Method::Swap(Method* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid Method::InternalSwap(Method* other) {\n  name_.Swap(&other->name_);\n  request_type_url_.Swap(&other->request_type_url_);\n  std::swap(request_streaming_, other->request_streaming_);\n  response_type_url_.Swap(&other->response_type_url_);\n  std::swap(response_streaming_, other->response_streaming_);\n  options_.UnsafeArenaSwap(&other->options_);\n  std::swap(syntax_, other->syntax_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata Method::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = Method_descriptor_;\n  metadata.reflection = Method_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// Method\n\n// optional string name = 1;\nvoid Method::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n const ::std::string& Method::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Method.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Method::set_name(const ::std::string& value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Method.name)\n}\n void Method::set_name(const char* value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Method.name)\n}\n void Method::set_name(const char* value, size_t size) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.name)\n}\n ::std::string* Method::mutable_name() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Method.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* Method::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Method.name)\n  \n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Method::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    \n  } else {\n    \n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.name)\n}\n\n// optional string request_type_url = 2;\nvoid Method::clear_request_type_url() {\n  request_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n const ::std::string& Method::request_type_url() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Method.request_type_url)\n  return request_type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Method::set_request_type_url(const ::std::string& value) {\n  \n  request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url)\n}\n void Method::set_request_type_url(const char* value) {\n  \n  request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Method.request_type_url)\n}\n void Method::set_request_type_url(const char* value, size_t size) {\n  \n  request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.request_type_url)\n}\n ::std::string* Method::mutable_request_type_url() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Method.request_type_url)\n  return request_type_url_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* Method::release_request_type_url() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Method.request_type_url)\n  \n  return request_type_url_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Method::set_allocated_request_type_url(::std::string* request_type_url) {\n  if (request_type_url != NULL) {\n    \n  } else {\n    \n  }\n  request_type_url_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), request_type_url);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.request_type_url)\n}\n\n// optional bool request_streaming = 3;\nvoid Method::clear_request_streaming() {\n  request_streaming_ = false;\n}\n bool Method::request_streaming() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Method.request_streaming)\n  return request_streaming_;\n}\n void Method::set_request_streaming(bool value) {\n  \n  request_streaming_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Method.request_streaming)\n}\n\n// optional string response_type_url = 4;\nvoid Method::clear_response_type_url() {\n  response_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n const ::std::string& Method::response_type_url() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Method.response_type_url)\n  return response_type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Method::set_response_type_url(const ::std::string& value) {\n  \n  response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url)\n}\n void Method::set_response_type_url(const char* value) {\n  \n  response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Method.response_type_url)\n}\n void Method::set_response_type_url(const char* value, size_t size) {\n  \n  response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.response_type_url)\n}\n ::std::string* Method::mutable_response_type_url() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Method.response_type_url)\n  return response_type_url_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* Method::release_response_type_url() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Method.response_type_url)\n  \n  return response_type_url_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Method::set_allocated_response_type_url(::std::string* response_type_url) {\n  if (response_type_url != NULL) {\n    \n  } else {\n    \n  }\n  response_type_url_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), response_type_url);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.response_type_url)\n}\n\n// optional bool response_streaming = 5;\nvoid Method::clear_response_streaming() {\n  response_streaming_ = false;\n}\n bool Method::response_streaming() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Method.response_streaming)\n  return response_streaming_;\n}\n void Method::set_response_streaming(bool value) {\n  \n  response_streaming_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Method.response_streaming)\n}\n\n// repeated .google.protobuf.Option options = 6;\nint Method::options_size() const {\n  return options_.size();\n}\nvoid Method::clear_options() {\n  options_.Clear();\n}\nconst ::google::protobuf::Option& Method::options(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Method.options)\n  return options_.Get(index);\n}\n::google::protobuf::Option* Method::mutable_options(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Method.options)\n  return options_.Mutable(index);\n}\n::google::protobuf::Option* Method::add_options() {\n  // @@protoc_insertion_point(field_add:google.protobuf.Method.options)\n  return options_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*\nMethod::mutable_options() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.Method.options)\n  return &options_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&\nMethod::options() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.Method.options)\n  return options_;\n}\n\n// optional .google.protobuf.Syntax syntax = 7;\nvoid Method::clear_syntax() {\n  syntax_ = 0;\n}\n ::google::protobuf::Syntax Method::syntax() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Method.syntax)\n  return static_cast< ::google::protobuf::Syntax >(syntax_);\n}\n void Method::set_syntax(::google::protobuf::Syntax value) {\n  \n  syntax_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Method.syntax)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int Mixin::kNameFieldNumber;\nconst int Mixin::kRootFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nMixin::Mixin()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.Mixin)\n}\n\nvoid Mixin::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n}\n\nMixin::Mixin(const Mixin& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.Mixin)\n}\n\nvoid Mixin::SharedCtor() {\n    _is_default_instance_ = false;\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  root_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n\nMixin::~Mixin() {\n  // @@protoc_insertion_point(destructor:google.protobuf.Mixin)\n  SharedDtor();\n}\n\nvoid Mixin::SharedDtor() {\n  name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  root_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n  }\n}\n\nvoid Mixin::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* Mixin::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return Mixin_descriptor_;\n}\n\nconst Mixin& Mixin::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto();\n  return *default_instance_;\n}\n\nMixin* Mixin::default_instance_ = NULL;\n\nMixin* Mixin::New(::google::protobuf::Arena* arena) const {\n  Mixin* n = new Mixin;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid Mixin::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.Mixin)\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  root_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n\nbool Mixin::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.Mixin)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional string name = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_name()));\n          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n            this->name().data(), this->name().length(),\n            ::google::protobuf::internal::WireFormatLite::PARSE,\n            \"google.protobuf.Mixin.name\"));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_root;\n        break;\n      }\n\n      // optional string root = 2;\n      case 2: {\n        if (tag == 18) {\n         parse_root:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_root()));\n          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n            this->root().data(), this->root().length(),\n            ::google::protobuf::internal::WireFormatLite::PARSE,\n            \"google.protobuf.Mixin.root\"));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.Mixin)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.Mixin)\n  return false;\n#undef DO_\n}\n\nvoid Mixin::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.Mixin)\n  // optional string name = 1;\n  if (this->name().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Mixin.name\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      1, this->name(), output);\n  }\n\n  // optional string root = 2;\n  if (this->root().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->root().data(), this->root().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Mixin.root\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      2, this->root(), output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.Mixin)\n}\n\n::google::protobuf::uint8* Mixin::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Mixin)\n  // optional string name = 1;\n  if (this->name().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Mixin.name\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        1, this->name(), target);\n  }\n\n  // optional string root = 2;\n  if (this->root().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->root().data(), this->root().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Mixin.root\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        2, this->root(), target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Mixin)\n  return target;\n}\n\nint Mixin::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Mixin)\n  int total_size = 0;\n\n  // optional string name = 1;\n  if (this->name().size() > 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::StringSize(\n        this->name());\n  }\n\n  // optional string root = 2;\n  if (this->root().size() > 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::StringSize(\n        this->root());\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid Mixin::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Mixin)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const Mixin* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const Mixin>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.Mixin)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Mixin)\n    MergeFrom(*source);\n  }\n}\n\nvoid Mixin::MergeFrom(const Mixin& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Mixin)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from.name().size() > 0) {\n\n    name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);\n  }\n  if (from.root().size() > 0) {\n\n    root_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.root_);\n  }\n}\n\nvoid Mixin::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.Mixin)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid Mixin::CopyFrom(const Mixin& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Mixin)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool Mixin::IsInitialized() const {\n\n  return true;\n}\n\nvoid Mixin::Swap(Mixin* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid Mixin::InternalSwap(Mixin* other) {\n  name_.Swap(&other->name_);\n  root_.Swap(&other->root_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata Mixin::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = Mixin_descriptor_;\n  metadata.reflection = Mixin_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// Mixin\n\n// optional string name = 1;\nvoid Mixin::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n const ::std::string& Mixin::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Mixin.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Mixin::set_name(const ::std::string& value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Mixin.name)\n}\n void Mixin::set_name(const char* value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Mixin.name)\n}\n void Mixin::set_name(const char* value, size_t size) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Mixin.name)\n}\n ::std::string* Mixin::mutable_name() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Mixin.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* Mixin::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Mixin.name)\n  \n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Mixin::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    \n  } else {\n    \n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.name)\n}\n\n// optional string root = 2;\nvoid Mixin::clear_root() {\n  root_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n const ::std::string& Mixin::root() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Mixin.root)\n  return root_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Mixin::set_root(const ::std::string& value) {\n  \n  root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Mixin.root)\n}\n void Mixin::set_root(const char* value) {\n  \n  root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Mixin.root)\n}\n void Mixin::set_root(const char* value, size_t size) {\n  \n  root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Mixin.root)\n}\n ::std::string* Mixin::mutable_root() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Mixin.root)\n  return root_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* Mixin::release_root() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Mixin.root)\n  \n  return root_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Mixin::set_allocated_root(::std::string* root) {\n  if (root != NULL) {\n    \n  } else {\n    \n  }\n  root_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), root);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace protobuf\n}  // namespace google\n\n// @@protoc_insertion_point(global_scope)\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/api.pb.h",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/api.proto\n\n#ifndef PROTOBUF_google_2fprotobuf_2fapi_2eproto__INCLUDED\n#define PROTOBUF_google_2fprotobuf_2fapi_2eproto__INCLUDED\n\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n\n#if GOOGLE_PROTOBUF_VERSION < 3000000\n#error This file was generated by a newer version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please update\n#error your headers.\n#endif\n#if 3000000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION\n#error This file was generated by an older version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please\n#error regenerate this file with a newer version of protoc.\n#endif\n\n#include <google/protobuf/arena.h>\n#include <google/protobuf/arenastring.h>\n#include <google/protobuf/generated_message_util.h>\n#include <google/protobuf/metadata.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/extension_set.h>\n#include <google/protobuf/unknown_field_set.h>\n#include <google/protobuf/source_context.pb.h>\n#include <google/protobuf/type.pb.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\n\n// Internal implementation detail -- do not call these.\nvoid LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto();\nvoid protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto();\nvoid protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto();\n\nclass Api;\nclass Method;\nclass Mixin;\n\n// ===================================================================\n\nclass LIBPROTOBUF_EXPORT Api : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Api) */ {\n public:\n  Api();\n  virtual ~Api();\n\n  Api(const Api& from);\n\n  inline Api& operator=(const Api& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const Api& default_instance();\n\n  void Swap(Api* other);\n\n  // implements Message ----------------------------------------------\n\n  inline Api* New() const { return New(NULL); }\n\n  Api* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const Api& from);\n  void MergeFrom(const Api& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(Api* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional string name = 1;\n  void clear_name();\n  static const int kNameFieldNumber = 1;\n  const ::std::string& name() const;\n  void set_name(const ::std::string& value);\n  void set_name(const char* value);\n  void set_name(const char* value, size_t size);\n  ::std::string* mutable_name();\n  ::std::string* release_name();\n  void set_allocated_name(::std::string* name);\n\n  // repeated .google.protobuf.Method methods = 2;\n  int methods_size() const;\n  void clear_methods();\n  static const int kMethodsFieldNumber = 2;\n  const ::google::protobuf::Method& methods(int index) const;\n  ::google::protobuf::Method* mutable_methods(int index);\n  ::google::protobuf::Method* add_methods();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Method >*\n      mutable_methods();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Method >&\n      methods() const;\n\n  // repeated .google.protobuf.Option options = 3;\n  int options_size() const;\n  void clear_options();\n  static const int kOptionsFieldNumber = 3;\n  const ::google::protobuf::Option& options(int index) const;\n  ::google::protobuf::Option* mutable_options(int index);\n  ::google::protobuf::Option* add_options();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*\n      mutable_options();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&\n      options() const;\n\n  // optional string version = 4;\n  void clear_version();\n  static const int kVersionFieldNumber = 4;\n  const ::std::string& version() const;\n  void set_version(const ::std::string& value);\n  void set_version(const char* value);\n  void set_version(const char* value, size_t size);\n  ::std::string* mutable_version();\n  ::std::string* release_version();\n  void set_allocated_version(::std::string* version);\n\n  // optional .google.protobuf.SourceContext source_context = 5;\n  bool has_source_context() const;\n  void clear_source_context();\n  static const int kSourceContextFieldNumber = 5;\n  const ::google::protobuf::SourceContext& source_context() const;\n  ::google::protobuf::SourceContext* mutable_source_context();\n  ::google::protobuf::SourceContext* release_source_context();\n  void set_allocated_source_context(::google::protobuf::SourceContext* source_context);\n\n  // repeated .google.protobuf.Mixin mixins = 6;\n  int mixins_size() const;\n  void clear_mixins();\n  static const int kMixinsFieldNumber = 6;\n  const ::google::protobuf::Mixin& mixins(int index) const;\n  ::google::protobuf::Mixin* mutable_mixins(int index);\n  ::google::protobuf::Mixin* add_mixins();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >*\n      mutable_mixins();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >&\n      mixins() const;\n\n  // optional .google.protobuf.Syntax syntax = 7;\n  void clear_syntax();\n  static const int kSyntaxFieldNumber = 7;\n  ::google::protobuf::Syntax syntax() const;\n  void set_syntax(::google::protobuf::Syntax value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.Api)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  bool _is_default_instance_;\n  ::google::protobuf::internal::ArenaStringPtr name_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Method > methods_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_;\n  ::google::protobuf::internal::ArenaStringPtr version_;\n  ::google::protobuf::SourceContext* source_context_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin > mixins_;\n  int syntax_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto();\n\n  void InitAsDefaultInstance();\n  static Api* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT Method : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Method) */ {\n public:\n  Method();\n  virtual ~Method();\n\n  Method(const Method& from);\n\n  inline Method& operator=(const Method& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const Method& default_instance();\n\n  void Swap(Method* other);\n\n  // implements Message ----------------------------------------------\n\n  inline Method* New() const { return New(NULL); }\n\n  Method* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const Method& from);\n  void MergeFrom(const Method& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(Method* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional string name = 1;\n  void clear_name();\n  static const int kNameFieldNumber = 1;\n  const ::std::string& name() const;\n  void set_name(const ::std::string& value);\n  void set_name(const char* value);\n  void set_name(const char* value, size_t size);\n  ::std::string* mutable_name();\n  ::std::string* release_name();\n  void set_allocated_name(::std::string* name);\n\n  // optional string request_type_url = 2;\n  void clear_request_type_url();\n  static const int kRequestTypeUrlFieldNumber = 2;\n  const ::std::string& request_type_url() const;\n  void set_request_type_url(const ::std::string& value);\n  void set_request_type_url(const char* value);\n  void set_request_type_url(const char* value, size_t size);\n  ::std::string* mutable_request_type_url();\n  ::std::string* release_request_type_url();\n  void set_allocated_request_type_url(::std::string* request_type_url);\n\n  // optional bool request_streaming = 3;\n  void clear_request_streaming();\n  static const int kRequestStreamingFieldNumber = 3;\n  bool request_streaming() const;\n  void set_request_streaming(bool value);\n\n  // optional string response_type_url = 4;\n  void clear_response_type_url();\n  static const int kResponseTypeUrlFieldNumber = 4;\n  const ::std::string& response_type_url() const;\n  void set_response_type_url(const ::std::string& value);\n  void set_response_type_url(const char* value);\n  void set_response_type_url(const char* value, size_t size);\n  ::std::string* mutable_response_type_url();\n  ::std::string* release_response_type_url();\n  void set_allocated_response_type_url(::std::string* response_type_url);\n\n  // optional bool response_streaming = 5;\n  void clear_response_streaming();\n  static const int kResponseStreamingFieldNumber = 5;\n  bool response_streaming() const;\n  void set_response_streaming(bool value);\n\n  // repeated .google.protobuf.Option options = 6;\n  int options_size() const;\n  void clear_options();\n  static const int kOptionsFieldNumber = 6;\n  const ::google::protobuf::Option& options(int index) const;\n  ::google::protobuf::Option* mutable_options(int index);\n  ::google::protobuf::Option* add_options();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*\n      mutable_options();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&\n      options() const;\n\n  // optional .google.protobuf.Syntax syntax = 7;\n  void clear_syntax();\n  static const int kSyntaxFieldNumber = 7;\n  ::google::protobuf::Syntax syntax() const;\n  void set_syntax(::google::protobuf::Syntax value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.Method)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  bool _is_default_instance_;\n  ::google::protobuf::internal::ArenaStringPtr name_;\n  ::google::protobuf::internal::ArenaStringPtr request_type_url_;\n  ::google::protobuf::internal::ArenaStringPtr response_type_url_;\n  bool request_streaming_;\n  bool response_streaming_;\n  int syntax_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto();\n\n  void InitAsDefaultInstance();\n  static Method* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT Mixin : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Mixin) */ {\n public:\n  Mixin();\n  virtual ~Mixin();\n\n  Mixin(const Mixin& from);\n\n  inline Mixin& operator=(const Mixin& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const Mixin& default_instance();\n\n  void Swap(Mixin* other);\n\n  // implements Message ----------------------------------------------\n\n  inline Mixin* New() const { return New(NULL); }\n\n  Mixin* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const Mixin& from);\n  void MergeFrom(const Mixin& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(Mixin* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional string name = 1;\n  void clear_name();\n  static const int kNameFieldNumber = 1;\n  const ::std::string& name() const;\n  void set_name(const ::std::string& value);\n  void set_name(const char* value);\n  void set_name(const char* value, size_t size);\n  ::std::string* mutable_name();\n  ::std::string* release_name();\n  void set_allocated_name(::std::string* name);\n\n  // optional string root = 2;\n  void clear_root();\n  static const int kRootFieldNumber = 2;\n  const ::std::string& root() const;\n  void set_root(const ::std::string& value);\n  void set_root(const char* value);\n  void set_root(const char* value, size_t size);\n  ::std::string* mutable_root();\n  ::std::string* release_root();\n  void set_allocated_root(::std::string* root);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.Mixin)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  bool _is_default_instance_;\n  ::google::protobuf::internal::ArenaStringPtr name_;\n  ::google::protobuf::internal::ArenaStringPtr root_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fapi_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fapi_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fapi_2eproto();\n\n  void InitAsDefaultInstance();\n  static Mixin* default_instance_;\n};\n// ===================================================================\n\n\n// ===================================================================\n\n#if !PROTOBUF_INLINE_NOT_IN_HEADERS\n// Api\n\n// optional string name = 1;\ninline void Api::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline const ::std::string& Api::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Api.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Api::set_name(const ::std::string& value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Api.name)\n}\ninline void Api::set_name(const char* value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Api.name)\n}\ninline void Api::set_name(const char* value, size_t size) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Api.name)\n}\ninline ::std::string* Api::mutable_name() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Api.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* Api::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Api.name)\n  \n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Api::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    \n  } else {\n    \n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.name)\n}\n\n// repeated .google.protobuf.Method methods = 2;\ninline int Api::methods_size() const {\n  return methods_.size();\n}\ninline void Api::clear_methods() {\n  methods_.Clear();\n}\ninline const ::google::protobuf::Method& Api::methods(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Api.methods)\n  return methods_.Get(index);\n}\ninline ::google::protobuf::Method* Api::mutable_methods(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Api.methods)\n  return methods_.Mutable(index);\n}\ninline ::google::protobuf::Method* Api::add_methods() {\n  // @@protoc_insertion_point(field_add:google.protobuf.Api.methods)\n  return methods_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Method >*\nApi::mutable_methods() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.Api.methods)\n  return &methods_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Method >&\nApi::methods() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.Api.methods)\n  return methods_;\n}\n\n// repeated .google.protobuf.Option options = 3;\ninline int Api::options_size() const {\n  return options_.size();\n}\ninline void Api::clear_options() {\n  options_.Clear();\n}\ninline const ::google::protobuf::Option& Api::options(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Api.options)\n  return options_.Get(index);\n}\ninline ::google::protobuf::Option* Api::mutable_options(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Api.options)\n  return options_.Mutable(index);\n}\ninline ::google::protobuf::Option* Api::add_options() {\n  // @@protoc_insertion_point(field_add:google.protobuf.Api.options)\n  return options_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*\nApi::mutable_options() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.Api.options)\n  return &options_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&\nApi::options() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.Api.options)\n  return options_;\n}\n\n// optional string version = 4;\ninline void Api::clear_version() {\n  version_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline const ::std::string& Api::version() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Api.version)\n  return version_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Api::set_version(const ::std::string& value) {\n  \n  version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Api.version)\n}\ninline void Api::set_version(const char* value) {\n  \n  version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Api.version)\n}\ninline void Api::set_version(const char* value, size_t size) {\n  \n  version_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Api.version)\n}\ninline ::std::string* Api::mutable_version() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Api.version)\n  return version_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* Api::release_version() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Api.version)\n  \n  return version_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Api::set_allocated_version(::std::string* version) {\n  if (version != NULL) {\n    \n  } else {\n    \n  }\n  version_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), version);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.version)\n}\n\n// optional .google.protobuf.SourceContext source_context = 5;\ninline bool Api::has_source_context() const {\n  return !_is_default_instance_ && source_context_ != NULL;\n}\ninline void Api::clear_source_context() {\n  if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_;\n  source_context_ = NULL;\n}\ninline const ::google::protobuf::SourceContext& Api::source_context() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Api.source_context)\n  return source_context_ != NULL ? *source_context_ : *default_instance_->source_context_;\n}\ninline ::google::protobuf::SourceContext* Api::mutable_source_context() {\n  \n  if (source_context_ == NULL) {\n    source_context_ = new ::google::protobuf::SourceContext;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Api.source_context)\n  return source_context_;\n}\ninline ::google::protobuf::SourceContext* Api::release_source_context() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Api.source_context)\n  \n  ::google::protobuf::SourceContext* temp = source_context_;\n  source_context_ = NULL;\n  return temp;\n}\ninline void Api::set_allocated_source_context(::google::protobuf::SourceContext* source_context) {\n  delete source_context_;\n  source_context_ = source_context;\n  if (source_context) {\n    \n  } else {\n    \n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Api.source_context)\n}\n\n// repeated .google.protobuf.Mixin mixins = 6;\ninline int Api::mixins_size() const {\n  return mixins_.size();\n}\ninline void Api::clear_mixins() {\n  mixins_.Clear();\n}\ninline const ::google::protobuf::Mixin& Api::mixins(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Api.mixins)\n  return mixins_.Get(index);\n}\ninline ::google::protobuf::Mixin* Api::mutable_mixins(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Api.mixins)\n  return mixins_.Mutable(index);\n}\ninline ::google::protobuf::Mixin* Api::add_mixins() {\n  // @@protoc_insertion_point(field_add:google.protobuf.Api.mixins)\n  return mixins_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >*\nApi::mutable_mixins() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.Api.mixins)\n  return &mixins_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Mixin >&\nApi::mixins() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.Api.mixins)\n  return mixins_;\n}\n\n// optional .google.protobuf.Syntax syntax = 7;\ninline void Api::clear_syntax() {\n  syntax_ = 0;\n}\ninline ::google::protobuf::Syntax Api::syntax() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Api.syntax)\n  return static_cast< ::google::protobuf::Syntax >(syntax_);\n}\ninline void Api::set_syntax(::google::protobuf::Syntax value) {\n  \n  syntax_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Api.syntax)\n}\n\n// -------------------------------------------------------------------\n\n// Method\n\n// optional string name = 1;\ninline void Method::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline const ::std::string& Method::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Method.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Method::set_name(const ::std::string& value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Method.name)\n}\ninline void Method::set_name(const char* value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Method.name)\n}\ninline void Method::set_name(const char* value, size_t size) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.name)\n}\ninline ::std::string* Method::mutable_name() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Method.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* Method::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Method.name)\n  \n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Method::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    \n  } else {\n    \n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.name)\n}\n\n// optional string request_type_url = 2;\ninline void Method::clear_request_type_url() {\n  request_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline const ::std::string& Method::request_type_url() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Method.request_type_url)\n  return request_type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Method::set_request_type_url(const ::std::string& value) {\n  \n  request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Method.request_type_url)\n}\ninline void Method::set_request_type_url(const char* value) {\n  \n  request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Method.request_type_url)\n}\ninline void Method::set_request_type_url(const char* value, size_t size) {\n  \n  request_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.request_type_url)\n}\ninline ::std::string* Method::mutable_request_type_url() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Method.request_type_url)\n  return request_type_url_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* Method::release_request_type_url() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Method.request_type_url)\n  \n  return request_type_url_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Method::set_allocated_request_type_url(::std::string* request_type_url) {\n  if (request_type_url != NULL) {\n    \n  } else {\n    \n  }\n  request_type_url_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), request_type_url);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.request_type_url)\n}\n\n// optional bool request_streaming = 3;\ninline void Method::clear_request_streaming() {\n  request_streaming_ = false;\n}\ninline bool Method::request_streaming() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Method.request_streaming)\n  return request_streaming_;\n}\ninline void Method::set_request_streaming(bool value) {\n  \n  request_streaming_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Method.request_streaming)\n}\n\n// optional string response_type_url = 4;\ninline void Method::clear_response_type_url() {\n  response_type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline const ::std::string& Method::response_type_url() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Method.response_type_url)\n  return response_type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Method::set_response_type_url(const ::std::string& value) {\n  \n  response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Method.response_type_url)\n}\ninline void Method::set_response_type_url(const char* value) {\n  \n  response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Method.response_type_url)\n}\ninline void Method::set_response_type_url(const char* value, size_t size) {\n  \n  response_type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Method.response_type_url)\n}\ninline ::std::string* Method::mutable_response_type_url() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Method.response_type_url)\n  return response_type_url_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* Method::release_response_type_url() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Method.response_type_url)\n  \n  return response_type_url_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Method::set_allocated_response_type_url(::std::string* response_type_url) {\n  if (response_type_url != NULL) {\n    \n  } else {\n    \n  }\n  response_type_url_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), response_type_url);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Method.response_type_url)\n}\n\n// optional bool response_streaming = 5;\ninline void Method::clear_response_streaming() {\n  response_streaming_ = false;\n}\ninline bool Method::response_streaming() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Method.response_streaming)\n  return response_streaming_;\n}\ninline void Method::set_response_streaming(bool value) {\n  \n  response_streaming_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Method.response_streaming)\n}\n\n// repeated .google.protobuf.Option options = 6;\ninline int Method::options_size() const {\n  return options_.size();\n}\ninline void Method::clear_options() {\n  options_.Clear();\n}\ninline const ::google::protobuf::Option& Method::options(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Method.options)\n  return options_.Get(index);\n}\ninline ::google::protobuf::Option* Method::mutable_options(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Method.options)\n  return options_.Mutable(index);\n}\ninline ::google::protobuf::Option* Method::add_options() {\n  // @@protoc_insertion_point(field_add:google.protobuf.Method.options)\n  return options_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*\nMethod::mutable_options() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.Method.options)\n  return &options_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&\nMethod::options() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.Method.options)\n  return options_;\n}\n\n// optional .google.protobuf.Syntax syntax = 7;\ninline void Method::clear_syntax() {\n  syntax_ = 0;\n}\ninline ::google::protobuf::Syntax Method::syntax() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Method.syntax)\n  return static_cast< ::google::protobuf::Syntax >(syntax_);\n}\ninline void Method::set_syntax(::google::protobuf::Syntax value) {\n  \n  syntax_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Method.syntax)\n}\n\n// -------------------------------------------------------------------\n\n// Mixin\n\n// optional string name = 1;\ninline void Mixin::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline const ::std::string& Mixin::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Mixin.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Mixin::set_name(const ::std::string& value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Mixin.name)\n}\ninline void Mixin::set_name(const char* value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Mixin.name)\n}\ninline void Mixin::set_name(const char* value, size_t size) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Mixin.name)\n}\ninline ::std::string* Mixin::mutable_name() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Mixin.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* Mixin::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Mixin.name)\n  \n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Mixin::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    \n  } else {\n    \n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.name)\n}\n\n// optional string root = 2;\ninline void Mixin::clear_root() {\n  root_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline const ::std::string& Mixin::root() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Mixin.root)\n  return root_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Mixin::set_root(const ::std::string& value) {\n  \n  root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Mixin.root)\n}\ninline void Mixin::set_root(const char* value) {\n  \n  root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Mixin.root)\n}\ninline void Mixin::set_root(const char* value, size_t size) {\n  \n  root_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Mixin.root)\n}\ninline ::std::string* Mixin::mutable_root() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Mixin.root)\n  return root_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* Mixin::release_root() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Mixin.root)\n  \n  return root_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Mixin::set_allocated_root(::std::string* root) {\n  if (root != NULL) {\n    \n  } else {\n    \n  }\n  root_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), root);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Mixin.root)\n}\n\n#endif  // !PROTOBUF_INLINE_NOT_IN_HEADERS\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace protobuf\n}  // namespace google\n\n// @@protoc_insertion_point(global_scope)\n\n#endif  // PROTOBUF_google_2fprotobuf_2fapi_2eproto__INCLUDED\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/api.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto3\";\n\npackage google.protobuf;\n\nimport \"google/protobuf/source_context.proto\";\nimport \"google/protobuf/type.proto\";\n\noption csharp_namespace = \"Google.Protobuf.WellKnownTypes\";\noption java_package = \"com.google.protobuf\";\noption java_outer_classname = \"ApiProto\";\noption java_multiple_files = true;\noption java_generate_equals_and_hash = true;\noption objc_class_prefix = \"GPB\";\n\n// Api is a light-weight descriptor for a protocol buffer service.\nmessage Api {\n\n  // The fully qualified name of this api, including package name\n  // followed by the api's simple name.\n  string name = 1;\n\n  // The methods of this api, in unspecified order.\n  repeated Method methods = 2;\n\n  // Any metadata attached to the API.\n  repeated Option options = 3;\n\n  // A version string for this api. If specified, must have the form\n  // `major-version.minor-version`, as in `1.10`. If the minor version\n  // is omitted, it defaults to zero. If the entire version field is\n  // empty, the major version is derived from the package name, as\n  // outlined below. If the field is not empty, the version in the\n  // package name will be verified to be consistent with what is\n  // provided here.\n  //\n  // The versioning schema uses [semantic\n  // versioning](http://semver.org) where the major version number\n  // indicates a breaking change and the minor version an additive,\n  // non-breaking change. Both version numbers are signals to users\n  // what to expect from different versions, and should be carefully\n  // chosen based on the product plan.\n  //\n  // The major version is also reflected in the package name of the\n  // API, which must end in `v<major-version>`, as in\n  // `google.feature.v1`. For major versions 0 and 1, the suffix can\n  // be omitted. Zero major versions must only be used for\n  // experimental, none-GA apis.\n  //\n  //\n  string version = 4;\n\n  // Source context for the protocol buffer service represented by this\n  // message.\n  SourceContext source_context = 5;\n\n  // Included APIs. See [Mixin][].\n  repeated Mixin mixins = 6;\n\n  // The source syntax of the service.\n  Syntax syntax = 7;\n}\n\n// Method represents a method of an api.\nmessage Method {\n\n  // The simple name of this method.\n  string name = 1;\n\n  // A URL of the input message type.\n  string request_type_url = 2;\n\n  // If true, the request is streamed.\n  bool request_streaming = 3;\n\n  // The URL of the output message type.\n  string response_type_url = 4;\n\n  // If true, the response is streamed.\n  bool response_streaming = 5;\n\n  // Any metadata attached to the method.\n  repeated Option options = 6;\n\n  // The source syntax of this method.\n  Syntax syntax = 7;\n}\n\n// Declares an API to be included in this API. The including API must\n// redeclare all the methods from the included API, but documentation\n// and options are inherited as follows:\n//\n// - If after comment and whitespace stripping, the documentation\n//   string of the redeclared method is empty, it will be inherited\n//   from the original method.\n//\n// - Each annotation belonging to the service config (http,\n//   visibility) which is not set in the redeclared method will be\n//   inherited.\n//\n// - If an http annotation is inherited, the path pattern will be\n//   modified as follows. Any version prefix will be replaced by the\n//   version of the including API plus the [root][] path if specified.\n//\n// Example of a simple mixin:\n//\n//     package google.acl.v1;\n//     service AccessControl {\n//       // Get the underlying ACL object.\n//       rpc GetAcl(GetAclRequest) returns (Acl) {\n//         option (google.api.http).get = \"/v1/{resource=**}:getAcl\";\n//       }\n//     }\n//\n//     package google.storage.v2;\n//     service Storage {\n//       rpc GetAcl(GetAclRequest) returns (Acl);\n//\n//       // Get a data record.\n//       rpc GetData(GetDataRequest) returns (Data) {\n//         option (google.api.http).get = \"/v2/{resource=**}\";\n//       }\n//     }\n//\n// Example of a mixin configuration:\n//\n//     apis:\n//     - name: google.storage.v2.Storage\n//       mixins:\n//       - name: google.acl.v1.AccessControl\n//\n// The mixin construct implies that all methods in `AccessControl` are\n// also declared with same name and request/response types in\n// `Storage`. A documentation generator or annotation processor will\n// see the effective `Storage.GetAcl` method after inherting\n// documentation and annotations as follows:\n//\n//     service Storage {\n//       // Get the underlying ACL object.\n//       rpc GetAcl(GetAclRequest) returns (Acl) {\n//         option (google.api.http).get = \"/v2/{resource=**}:getAcl\";\n//       }\n//       ...\n//     }\n//\n// Note how the version in the path pattern changed from `v1` to `v2`.\n//\n// If the `root` field in the mixin is specified, it should be a\n// relative path under which inherited HTTP paths are placed. Example:\n//\n//     apis:\n//     - name: google.storage.v2.Storage\n//       mixins:\n//       - name: google.acl.v1.AccessControl\n//         root: acls\n//\n// This implies the following inherited HTTP annotation:\n//\n//     service Storage {\n//       // Get the underlying ACL object.\n//       rpc GetAcl(GetAclRequest) returns (Acl) {\n//         option (google.api.http).get = \"/v2/acls/{resource=**}:getAcl\";\n//       }\n//       ...\n//     }\nmessage Mixin {\n  // The fully qualified name of the API which is included.\n  string name = 1;\n\n  // If non-empty specifies a path under which inherited HTTP paths\n  // are rooted.\n  string root = 2;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/arena.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/arena.h>\n\n\n#ifdef ADDRESS_SANITIZER\n#include <sanitizer/asan_interface.h>\n#endif\n\nnamespace google {\nnamespace protobuf {\n\n\ngoogle::protobuf::internal::SequenceNumber Arena::lifecycle_id_generator_;\n#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)\nArena::ThreadCache& Arena::thread_cache() {\n  static internal::ThreadLocalStorage<ThreadCache>* thread_cache_ =\n      new internal::ThreadLocalStorage<ThreadCache>();\n  return *thread_cache_->Get();\n}\n#elif defined(PROTOBUF_USE_DLLS)\nArena::ThreadCache& Arena::thread_cache() {\n  static GOOGLE_THREAD_LOCAL ThreadCache thread_cache_ = { -1, NULL };\n  return thread_cache_;\n}\n#else\nGOOGLE_THREAD_LOCAL Arena::ThreadCache Arena::thread_cache_ = { -1, NULL };\n#endif\n\nvoid Arena::Init() {\n  lifecycle_id_ = lifecycle_id_generator_.GetNext();\n  blocks_ = 0;\n  hint_ = 0;\n  owns_first_block_ = true;\n  cleanup_list_ = 0;\n\n  if (options_.initial_block != NULL && options_.initial_block_size > 0) {\n    GOOGLE_CHECK_GE(options_.initial_block_size, sizeof(Block))\n        << \": Initial block size too small for header.\";\n\n    // Add first unowned block to list.\n    Block* first_block = reinterpret_cast<Block*>(options_.initial_block);\n    first_block->size = options_.initial_block_size;\n    first_block->pos = kHeaderSize;\n    first_block->next = NULL;\n    // Thread which calls Init() owns the first block. This allows the\n    // single-threaded case to allocate on the first block without taking any\n    // locks.\n    first_block->owner = &thread_cache();\n    SetThreadCacheBlock(first_block);\n    AddBlockInternal(first_block);\n    owns_first_block_ = false;\n  }\n\n  // Call the initialization hook\n  if (options_.on_arena_init != NULL) {\n    hooks_cookie_ = options_.on_arena_init(this);\n  } else {\n    hooks_cookie_ = NULL;\n  }\n}\n\nArena::~Arena() {\n  uint64 space_allocated = ResetInternal();\n\n  // Call the destruction hook\n  if (options_.on_arena_destruction != NULL) {\n    options_.on_arena_destruction(this, hooks_cookie_, space_allocated);\n  }\n}\n\nuint64 Arena::Reset() {\n  // Invalidate any ThreadCaches pointing to any blocks we just destroyed.\n  lifecycle_id_ = lifecycle_id_generator_.GetNext();\n  return ResetInternal();\n}\n\nuint64 Arena::ResetInternal() {\n  CleanupList();\n  uint64 space_allocated = FreeBlocks();\n\n  // Call the reset hook\n  if (options_.on_arena_reset != NULL) {\n    options_.on_arena_reset(this, hooks_cookie_, space_allocated);\n  }\n\n  return space_allocated;\n}\n\nArena::Block* Arena::NewBlock(void* me, Block* my_last_block, size_t n,\n                              size_t start_block_size, size_t max_block_size) {\n  size_t size;\n  if (my_last_block != NULL) {\n    // Double the current block size, up to a limit.\n    size = 2 * (my_last_block->size);\n    if (size > max_block_size) size = max_block_size;\n  } else {\n    size = start_block_size;\n  }\n  if (n > size - kHeaderSize) {\n    // TODO(sanjay): Check if n + kHeaderSize would overflow\n    size = kHeaderSize + n;\n  }\n\n  Block* b = reinterpret_cast<Block*>(options_.block_alloc(size));\n  b->pos = kHeaderSize + n;\n  b->size = size;\n  b->owner = me;\n#ifdef ADDRESS_SANITIZER\n  // Poison the rest of the block for ASAN. It was unpoisoned by the underlying\n  // malloc but it's not yet usable until we return it as part of an allocation.\n  ASAN_POISON_MEMORY_REGION(\n      reinterpret_cast<char*>(b) + b->pos, b->size - b->pos);\n#endif\n  return b;\n}\n\nvoid Arena::AddBlock(Block* b) {\n  MutexLock l(&blocks_lock_);\n  AddBlockInternal(b);\n}\n\nvoid Arena::AddBlockInternal(Block* b) {\n  b->next = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_));\n  google::protobuf::internal::Release_Store(&blocks_, reinterpret_cast<google::protobuf::internal::AtomicWord>(b));\n  if (b->avail() != 0) {\n    // Direct future allocations to this block.\n    google::protobuf::internal::Release_Store(&hint_, reinterpret_cast<google::protobuf::internal::AtomicWord>(b));\n  }\n}\n\nvoid Arena::AddListNode(void* elem, void (*cleanup)(void*)) {\n  Node* node = reinterpret_cast<Node*>(AllocateAligned(sizeof(Node)));\n  node->elem = elem;\n  node->cleanup = cleanup;\n  node->next = reinterpret_cast<Node*>(\n      google::protobuf::internal::NoBarrier_AtomicExchange(&cleanup_list_,\n            reinterpret_cast<google::protobuf::internal::AtomicWord>(node)));\n}\n\nvoid* Arena::AllocateAligned(const std::type_info* allocated, size_t n) {\n  // Align n to next multiple of 8 (from Hacker's Delight, Chapter 3.)\n  n = (n + 7) & -8;\n\n  // Monitor allocation if needed.\n  if (GOOGLE_PREDICT_FALSE(hooks_cookie_ != NULL) &&\n      options_.on_arena_allocation != NULL) {\n    options_.on_arena_allocation(allocated, n, hooks_cookie_);\n  }\n\n  // If this thread already owns a block in this arena then try to use that.\n  // This fast path optimizes the case where multiple threads allocate from the\n  // same arena.\n  if (thread_cache().last_lifecycle_id_seen == lifecycle_id_ &&\n      thread_cache().last_block_used_ != NULL) {\n    if (thread_cache().last_block_used_->avail() < n) {\n      return SlowAlloc(n);\n    }\n    return AllocFromBlock(thread_cache().last_block_used_, n);\n  }\n\n  // Check whether we own the last accessed block on this arena.\n  // This fast path optimizes the case where a single thread uses multiple\n  // arenas.\n  void* me = &thread_cache();\n  Block* b = reinterpret_cast<Block*>(google::protobuf::internal::Acquire_Load(&hint_));\n  if (!b || b->owner != me || b->avail() < n) {\n    return SlowAlloc(n);\n  }\n  return AllocFromBlock(b, n);\n}\n\nvoid* Arena::AllocFromBlock(Block* b, size_t n) {\n  size_t p = b->pos;\n  b->pos = p + n;\n#ifdef ADDRESS_SANITIZER\n  ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast<char*>(b) + p, n);\n#endif\n  return reinterpret_cast<char*>(b) + p;\n}\n\nvoid* Arena::SlowAlloc(size_t n) {\n  void* me = &thread_cache();\n  Block* b = FindBlock(me);  // Find block owned by me.\n  // See if allocation fits in my latest block.\n  if (b != NULL && b->avail() >= n) {\n    SetThreadCacheBlock(b);\n    google::protobuf::internal::NoBarrier_Store(&hint_, reinterpret_cast<google::protobuf::internal::AtomicWord>(b));\n    return AllocFromBlock(b, n);\n  }\n  b = NewBlock(me, b, n, options_.start_block_size, options_.max_block_size);\n  AddBlock(b);\n  SetThreadCacheBlock(b);\n  return reinterpret_cast<char*>(b) + kHeaderSize;\n}\n\nuint64 Arena::SpaceAllocated() const {\n  uint64 space_allocated = 0;\n  Block* b = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_));\n  while (b != NULL) {\n    space_allocated += (b->size);\n    b = b->next;\n  }\n  return space_allocated;\n}\n\nuint64 Arena::SpaceUsed() const {\n  uint64 space_used = 0;\n  Block* b = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_));\n  while (b != NULL) {\n    space_used += (b->pos - kHeaderSize);\n    b = b->next;\n  }\n  return space_used;\n}\n\npair<uint64, uint64> Arena::SpaceAllocatedAndUsed() const {\n  uint64 allocated = 0;\n  uint64 used = 0;\n\n  Block* b = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_));\n  while (b != NULL) {\n    allocated += b->size;\n    used += (b->pos - kHeaderSize);\n    b = b->next;\n  }\n  return std::make_pair(allocated, used);\n}\n\nuint64 Arena::FreeBlocks() {\n  uint64 space_allocated = 0;\n  Block* b = reinterpret_cast<Block*>(google::protobuf::internal::NoBarrier_Load(&blocks_));\n  Block* first_block = NULL;\n  while (b != NULL) {\n    space_allocated += (b->size);\n    Block* next = b->next;\n    if (next != NULL) {\n      options_.block_dealloc(b, b->size);\n    } else {\n      if (owns_first_block_) {\n        options_.block_dealloc(b, b->size);\n      } else {\n        // User passed in the first block, skip free'ing the memory.\n        first_block = b;\n      }\n    }\n    b = next;\n  }\n  blocks_ = 0;\n  hint_ = 0;\n  if (!owns_first_block_) {\n    // Make the first block that was passed in through ArenaOptions\n    // available for reuse.\n    first_block->pos = kHeaderSize;\n    // Thread which calls Reset() owns the first block. This allows the\n    // single-threaded case to allocate on the first block without taking any\n    // locks.\n    first_block->owner = &thread_cache();\n    SetThreadCacheBlock(first_block);\n    AddBlockInternal(first_block);\n  }\n  return space_allocated;\n}\n\nvoid Arena::CleanupList() {\n  Node* head =\n      reinterpret_cast<Node*>(google::protobuf::internal::NoBarrier_Load(&cleanup_list_));\n  while (head != NULL) {\n    head->cleanup(head->elem);\n    head = head->next;\n  }\n  cleanup_list_ = 0;\n}\n\nArena::Block* Arena::FindBlock(void* me) {\n  // TODO(sanjay): We might want to keep a separate list with one\n  // entry per thread.\n  Block* b = reinterpret_cast<Block*>(google::protobuf::internal::Acquire_Load(&blocks_));\n  while (b != NULL && b->owner != me) {\n    b = b->next;\n  }\n  return b;\n}\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/arena.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_ARENA_H__\n#define GOOGLE_PROTOBUF_ARENA_H__\n\n#include <limits>\n#ifdef max\n#undef max  // Visual Studio defines this macro\n#endif\n#if __cplusplus >= 201103L\n#include <google/protobuf/stubs/type_traits.h>\n#endif\n#if defined(_MSC_VER) && !_HAS_EXCEPTIONS\n// Work around bugs in MSVC <typeinfo> header when _HAS_EXCEPTIONS=0.\n#include <exception>\n#include <typeinfo>\nnamespace std {\nusing type_info = ::type_info;\n}\n#else\n#include <typeinfo>\n#endif\n\n#include <google/protobuf/stubs/atomic_sequence_num.h>\n#include <google/protobuf/stubs/atomicops.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/mutex.h>\n#include <google/protobuf/stubs/type_traits.h>\n\n\nnamespace google {\nnamespace protobuf {\n\nclass Arena;       // defined below\nclass Message;     // message.h\n\nnamespace internal {\nclass ArenaString; // arenastring.h\nclass LazyField;   // lazy_field.h\n\ntemplate<typename Type>\nclass GenericTypeHandler; // repeated_field.h\n\n// Templated cleanup methods.\ntemplate<typename T> void arena_destruct_object(void* object) {\n  reinterpret_cast<T*>(object)->~T();\n}\ntemplate<typename T> void arena_delete_object(void* object) {\n  delete reinterpret_cast<T*>(object);\n}\ninline void arena_free(void* object, size_t /* size */) {\n  free(object);\n}\n\n}  // namespace internal\n\n// ArenaOptions provides optional additional parameters to arena construction\n// that control its block-allocation behavior.\nstruct ArenaOptions {\n  // This defines the size of the first block requested from the system malloc.\n  // Subsequent block sizes will increase in a geometric series up to a maximum.\n  size_t start_block_size;\n\n  // This defines the maximum block size requested from system malloc (unless an\n  // individual arena allocation request occurs with a size larger than this\n  // maximum). Requested block sizes increase up to this value, then remain\n  // here.\n  size_t max_block_size;\n\n  // An initial block of memory for the arena to use, or NULL for none. If\n  // provided, the block must live at least as long as the arena itself. The\n  // creator of the Arena retains ownership of the block after the Arena is\n  // destroyed.\n  char* initial_block;\n\n  // The size of the initial block, if provided.\n  size_t initial_block_size;\n\n  // A function pointer to an alloc method that returns memory blocks of size\n  // requested. By default, it contains a ptr to the malloc function.\n  //\n  // NOTE: block_alloc and dealloc functions are expected to behave like\n  // malloc and free, including Asan poisoning.\n  void* (*block_alloc)(size_t);\n  // A function pointer to a dealloc method that takes ownership of the blocks\n  // from the arena. By default, it contains a ptr to a wrapper function that\n  // calls free.\n  void (*block_dealloc)(void*, size_t);\n\n  // Hooks for adding external functionality such as user-specific metrics\n  // collection, specific debugging abilities, etc.\n  // Init hook may return a pointer to a cookie to be stored in the arena.\n  // reset and destruction hooks will then be called with the same cookie\n  // pointer. This allows us to save an external object per arena instance and\n  // use it on the other hooks (Note: It is just as legal for init to return\n  // NULL and not use the cookie feature).\n  // on_arena_reset and on_arena_destruction also receive the space used in\n  // the arena just before the reset.\n  void* (*on_arena_init)(Arena* arena);\n  void (*on_arena_reset)(Arena* arena, void* cookie, uint64 space_used);\n  void (*on_arena_destruction)(Arena* arena, void* cookie, uint64 space_used);\n\n  // type_info is promised to be static - its lifetime extends to\n  // match program's lifetime (It is given by typeid operator).\n  // Note: typeid(void) will be passed as allocated_type every time we\n  // intentionally want to avoid monitoring an allocation. (i.e. internal\n  // allocations for managing the arena)\n  void (*on_arena_allocation)(const std::type_info* allocated_type,\n      uint64 alloc_size, void* cookie);\n\n  ArenaOptions()\n      : start_block_size(kDefaultStartBlockSize),\n        max_block_size(kDefaultMaxBlockSize),\n        initial_block(NULL),\n        initial_block_size(0),\n        block_alloc(&malloc),\n        block_dealloc(&internal::arena_free),\n        on_arena_init(NULL),\n        on_arena_reset(NULL),\n        on_arena_destruction(NULL),\n        on_arena_allocation(NULL) {}\n\n private:\n  // Constants define default starting block size and max block size for\n  // arena allocator behavior -- see descriptions above.\n  static const size_t kDefaultStartBlockSize = 256;\n  static const size_t kDefaultMaxBlockSize   = 8192;\n};\n\n// Support for non-RTTI environments. (The metrics hooks API uses type\n// information.)\n#ifndef GOOGLE_PROTOBUF_NO_RTTI\n#define RTTI_TYPE_ID(type) (&typeid(type))\n#else\n#define RTTI_TYPE_ID(type) (NULL)\n#endif\n\n// Arena allocator. Arena allocation replaces ordinary (heap-based) allocation\n// with new/delete, and improves performance by aggregating allocations into\n// larger blocks and freeing allocations all at once. Protocol messages are\n// allocated on an arena by using Arena::CreateMessage<T>(Arena*), below, and\n// are automatically freed when the arena is destroyed.\n//\n// This is a thread-safe implementation: multiple threads may allocate from the\n// arena concurrently. Destruction is not thread-safe and the destructing\n// thread must synchronize with users of the arena first.\n//\n// An arena provides two allocation interfaces: CreateMessage<T>, which works\n// for arena-enabled proto2 message types as well as other types that satisfy\n// the appropriate protocol (described below), and Create<T>, which works for\n// any arbitrary type T. CreateMessage<T> is better when the type T supports it,\n// because this interface (i) passes the arena pointer to the created object so\n// that its sub-objects and internal allocations can use the arena too, and (ii)\n// elides the object's destructor call when possible. Create<T> does not place\n// any special requirements on the type T, and will invoke the object's\n// destructor when the arena is destroyed.\n//\n// The arena message allocation protocol, required by CreateMessage<T>, is as\n// follows:\n//\n// - The type T must have (at least) two constructors: a constructor with no\n//   arguments, called when a T is allocated on the heap; and a constructor with\n//   a google::protobuf::Arena* argument, called when a T is allocated on an arena. If the\n//   second constructor is called with a NULL arena pointer, it must be\n//   equivalent to invoking the first (no-argument) constructor.\n//\n// - The type T must have a particular type trait: a nested type\n//   |InternalArenaConstructable_|. This is usually a typedef to |void|. If no\n//   such type trait exists, then the instantiation CreateMessage<T> will fail\n//   to compile.\n//\n// - The type T *may* have the type trait |DestructorSkippable_|. If this type\n//   trait is present in the type, then its destructor will not be called if and\n//   only if it was passed a non-NULL arena pointer. If this type trait is not\n//   present on the type, then its destructor is always called when the\n//   containing arena is destroyed.\n//\n// - One- and two-user-argument forms of CreateMessage<T>() also exist that\n//   forward these constructor arguments to T's constructor: for example,\n//   CreateMessage<T>(Arena*, arg1, arg2) forwards to a constructor T(Arena*,\n//   arg1, arg2).\n//\n// This protocol is implemented by all arena-enabled proto2 message classes as\n// well as RepeatedPtrField.\n\n#if __cplusplus >= 201103L\nclass LIBPROTOBUF_EXPORT Arena final {\n#else\nclass LIBPROTOBUF_EXPORT Arena {\n#endif\n public:\n  // Arena constructor taking custom options. See ArenaOptions below for\n  // descriptions of the options available.\n  explicit Arena(const ArenaOptions& options) : options_(options) {\n    Init();\n  }\n\n  // Default constructor with sensible default options, tuned for average\n  // use-cases.\n  Arena() {\n    Init();\n  }\n\n  // Destructor deletes all owned heap allocated objects, and destructs objects\n  // that have non-trivial destructors, except for proto2 message objects whose\n  // destructors can be skipped. Also, frees all blocks except the initial block\n  // if it was passed in.\n  ~Arena();\n\n  // API to create proto2 message objects on the arena. If the arena passed in\n  // is NULL, then a heap allocated object is returned. Type T must be a message\n  // defined in a .proto file with cc_enable_arenas set to true, otherwise a\n  // compilation error will occur.\n  //\n  // RepeatedField and RepeatedPtrField may also be instantiated directly on an\n  // arena with this method.\n  //\n  // This function also accepts any type T that satisfies the arena message\n  // allocation protocol, documented above.\n  template <typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  static T* CreateMessage(::google::protobuf::Arena* arena) {\n    if (arena == NULL) {\n      return new T;\n    } else {\n      return arena->CreateMessageInternal<T>(static_cast<T*>(0));\n    }\n  }\n\n  // One-argument form of CreateMessage. This is useful for constructing objects\n  // that implement the arena message construction protocol described above but\n  // take additional constructor arguments.\n  template <typename T, typename Arg> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  static T* CreateMessage(::google::protobuf::Arena* arena, const Arg& arg) {\n    if (arena == NULL) {\n      return new T(NULL, arg);\n    } else {\n      return arena->CreateMessageInternal<T>(static_cast<T*>(0),\n                                             arg);\n    }\n  }\n\n  // Two-argument form of CreateMessage. This is useful for constructing objects\n  // that implement the arena message construction protocol described above but\n  // take additional constructor arguments.\n  template <typename T, typename Arg1, typename Arg2> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  static T* CreateMessage(::google::protobuf::Arena* arena,\n                          const Arg1& arg1,\n                          const Arg2& arg2) {\n    if (arena == NULL) {\n      return new T(NULL, arg1, arg2);\n    } else {\n      return arena->CreateMessageInternal<T>(static_cast<T*>(0),\n                                             arg1, arg2);\n    }\n  }\n\n  // API to create any objects on the arena. Note that only the object will\n  // be created on the arena; the underlying ptrs (in case of a proto2 message)\n  // will be still heap allocated. Proto messages should usually be allocated\n  // with CreateMessage<T>() instead.\n  //\n  // Note that even if T satisfies the arena message construction protocol\n  // (InternalArenaConstructable_ trait and optional DestructorSkippable_\n  // trait), as described above, this function does not follow the protocol;\n  // instead, it treats T as a black-box type, just as if it did not have these\n  // traits. Specifically, T's constructor arguments will always be only those\n  // passed to Create<T>() -- no additional arena pointer is implicitly added.\n  // Furthermore, the destructor will always be called at arena destruction time\n  // (unless the destructor is trivial). Hence, from T's point of view, it is as\n  // if the object were allocated on the heap (except that the underlying memory\n  // is obtained from the arena).\n  template <typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  static T* Create(::google::protobuf::Arena* arena) {\n    if (arena == NULL) {\n      return new T();\n    } else {\n      return arena->CreateInternal<T>(google::protobuf::internal::has_trivial_destructor<T>::value);\n    }\n  }\n\n  // Version of the above with one constructor argument for the created object.\n  template <typename T, typename Arg> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  static T* Create(::google::protobuf::Arena* arena, const Arg& arg) {\n    if (arena == NULL) {\n      return new T(arg);\n    } else {\n      return arena->CreateInternal<T>(google::protobuf::internal::has_trivial_destructor<T>::value,\n                                      arg);\n    }\n  }\n\n  // Version of the above with two constructor arguments for the created object.\n  template <typename T, typename Arg1, typename Arg2> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  static T* Create(::google::protobuf::Arena* arena, const Arg1& arg1, const Arg2& arg2) {\n    if (arena == NULL) {\n      return new T(arg1, arg2);\n    } else {\n      return arena->CreateInternal<T>(google::protobuf::internal::has_trivial_destructor<T>::value,\n                                      arg1, arg2);\n    }\n  }\n\n  // Version of the above with three constructor arguments for the created\n  // object.\n  template <typename T, typename Arg1, typename Arg2, typename Arg3>\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE static T* Create(::google::protobuf::Arena* arena,\n                                           const Arg1& arg1, const Arg2& arg2,\n                                           const Arg3& arg3) {\n    if (arena == NULL) {\n      return new T(arg1, arg2, arg3);\n    } else {\n      return arena->CreateInternal<T>(google::protobuf::internal::has_trivial_destructor<T>::value,\n                                      arg1, arg2, arg3);\n    }\n  }\n\n  // Version of the above with four constructor arguments for the created\n  // object.\n  template <typename T, typename Arg1, typename Arg2, typename Arg3,\n            typename Arg4>\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE static T* Create(::google::protobuf::Arena* arena,\n                                           const Arg1& arg1, const Arg2& arg2,\n                                           const Arg3& arg3, const Arg4& arg4) {\n    if (arena == NULL) {\n      return new T(arg1, arg2, arg3, arg4);\n    } else {\n      return arena->CreateInternal<T>(google::protobuf::internal::has_trivial_destructor<T>::value,\n                                      arg1, arg2, arg3, arg4);\n    }\n  }\n\n  // Version of the above with five constructor arguments for the created\n  // object.\n  template <typename T, typename Arg1, typename Arg2, typename Arg3,\n            typename Arg4, typename Arg5>\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE static T* Create(::google::protobuf::Arena* arena,\n                                           const Arg1& arg1, const Arg2& arg2,\n                                           const Arg3& arg3, const Arg4& arg4,\n                                           const Arg5& arg5) {\n    if (arena == NULL) {\n      return new T(arg1, arg2, arg3, arg4, arg5);\n    } else {\n      return arena->CreateInternal<T>(google::protobuf::internal::has_trivial_destructor<T>::value,\n                                      arg1, arg2, arg3, arg4, arg5);\n    }\n  }\n\n  // Version of the above with six constructor arguments for the created\n  // object.\n  template <typename T, typename Arg1, typename Arg2, typename Arg3,\n            typename Arg4, typename Arg5, typename Arg6>\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE static T* Create(::google::protobuf::Arena* arena,\n                                           const Arg1& arg1, const Arg2& arg2,\n                                           const Arg3& arg3, const Arg4& arg4,\n                                           const Arg5& arg5, const Arg6& arg6) {\n    if (arena == NULL) {\n      return new T(arg1, arg2, arg3, arg4, arg5, arg6);\n    } else {\n      return arena->CreateInternal<T>(google::protobuf::internal::has_trivial_destructor<T>::value,\n                                      arg1, arg2, arg3, arg4, arg5, arg6);\n    }\n  }\n\n  // Version of the above with seven constructor arguments for the created\n  // object.\n  template <typename T, typename Arg1, typename Arg2, typename Arg3,\n            typename Arg4, typename Arg5, typename Arg6, typename Arg7>\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE static T* Create(::google::protobuf::Arena* arena,\n                                           const Arg1& arg1, const Arg2& arg2,\n                                           const Arg3& arg3, const Arg4& arg4,\n                                           const Arg5& arg5, const Arg6& arg6,\n                                           const Arg7& arg7) {\n    if (arena == NULL) {\n      return new T(arg1, arg2, arg3, arg4, arg5, arg6, arg7);\n    } else {\n      return arena->CreateInternal<T>(google::protobuf::internal::has_trivial_destructor<T>::value,\n                                      arg1, arg2, arg3, arg4, arg5, arg6, arg7);\n    }\n  }\n\n  // Version of the above with eight constructor arguments for the created\n  // object.\n  template <typename T, typename Arg1, typename Arg2, typename Arg3,\n            typename Arg4, typename Arg5, typename Arg6, typename Arg7,\n            typename Arg8>\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE static T* Create(::google::protobuf::Arena* arena,\n                                           const Arg1& arg1, const Arg2& arg2,\n                                           const Arg3& arg3, const Arg4& arg4,\n                                           const Arg5& arg5, const Arg6& arg6,\n                                           const Arg7& arg7, const Arg8& arg8) {\n    if (arena == NULL) {\n      return new T(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);\n    } else {\n      return arena->CreateInternal<T>(\n          google::protobuf::internal::has_trivial_destructor<T>::value,\n          arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);\n    }\n  }\n\n  // Create an array of object type T on the arena *without* invoking the\n  // constructor of T. If `arena` is null, then the return value should be freed\n  // with `delete[] x;` (or `::operator delete[](x);`).\n  // To ensure safe uses, this function checks at compile time\n  // (when compiled as C++11) that T is trivially default-constructible and\n  // trivially destructible.\n  template <typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  static T* CreateArray(::google::protobuf::Arena* arena, size_t num_elements) {\n    GOOGLE_CHECK_LE(num_elements,\n             std::numeric_limits<size_t>::max() / sizeof(T))\n        << \"Requested size is too large to fit into size_t.\";\n    if (arena == NULL) {\n      return static_cast<T*>(::operator new[](num_elements * sizeof(T)));\n    } else {\n      return arena->CreateInternalRawArray<T>(num_elements);\n    }\n  }\n\n  // Returns the total space used by the arena, which is the sums of the sizes\n  // of the underlying blocks. The total space used may not include the new\n  // blocks that are allocated by this arena from other threads concurrently\n  // with the call to this method.\n  GOOGLE_ATTRIBUTE_NOINLINE uint64 SpaceAllocated() const;\n  // As above, but does not include any free space in underlying blocks.\n  GOOGLE_ATTRIBUTE_NOINLINE uint64 SpaceUsed() const;\n\n  // Combines SpaceAllocated and SpaceUsed. Returns a pair of\n  // <space_allocated, space_used>.\n  GOOGLE_ATTRIBUTE_NOINLINE pair<uint64, uint64> SpaceAllocatedAndUsed() const;\n\n  // Frees all storage allocated by this arena after calling destructors\n  // registered with OwnDestructor() and freeing objects registered with Own().\n  // Any objects allocated on this arena are unusable after this call. It also\n  // returns the total space used by the arena which is the sums of the sizes\n  // of the allocated blocks. This method is not thread-safe.\n  GOOGLE_ATTRIBUTE_NOINLINE uint64 Reset();\n\n  // Adds |object| to a list of heap-allocated objects to be freed with |delete|\n  // when the arena is destroyed or reset.\n  template <typename T> GOOGLE_ATTRIBUTE_NOINLINE\n  void Own(T* object) {\n    OwnInternal(object, google::protobuf::internal::is_convertible<T*, ::google::protobuf::Message*>());\n  }\n\n  // Adds |object| to a list of objects whose destructors will be manually\n  // called when the arena is destroyed or reset. This differs from Own() in\n  // that it does not free the underlying memory with |delete|; hence, it is\n  // normally only used for objects that are placement-newed into\n  // arena-allocated memory.\n  template <typename T> GOOGLE_ATTRIBUTE_NOINLINE\n  void OwnDestructor(T* object) {\n    if (object != NULL) {\n      AddListNode(object, &internal::arena_destruct_object<T>);\n    }\n  }\n\n  // Adds a custom member function on an object to the list of destructors that\n  // will be manually called when the arena is destroyed or reset. This differs\n  // from OwnDestructor() in that any member function may be specified, not only\n  // the class destructor.\n  GOOGLE_ATTRIBUTE_NOINLINE void OwnCustomDestructor(void* object,\n                                              void (*destruct)(void*)) {\n    AddListNode(object, destruct);\n  }\n\n  // Retrieves the arena associated with |value| if |value| is an arena-capable\n  // message, or NULL otherwise. This differs from value->GetArena() in that the\n  // latter is a virtual call, while this method is a templated call that\n  // resolves at compile-time.\n  template<typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  static ::google::protobuf::Arena* GetArena(const T* value) {\n    return GetArenaInternal(value, static_cast<T*>(0));\n  }\n\n private:\n  struct InternalIsArenaConstructableHelper {\n    template<typename U>\n    static char ArenaConstructable(\n        const typename U::InternalArenaConstructable_*);\n    template<typename U>\n    static double ArenaConstructable(...);\n  };\n\n public:\n  // Helper typetrait that indicates support for arenas in a type T at compile\n  // time. This is public only to allow construction of higher-level templated\n  // utilities. is_arena_constructable<T>::value is true if the message type T\n  // has arena support enabled, and false otherwise.\n  //\n  // This is inside Arena because only Arena has the friend relationships\n  // necessary to see the underlying generated code traits.\n  template <typename T>\n  struct is_arena_constructable\n      : public google::protobuf::internal::integral_constant<\n            bool, sizeof(InternalIsArenaConstructableHelper::ArenaConstructable<\n                         const T>(static_cast<const T*>(0))) == sizeof(char)> {\n  };\n\n private:\n  // Blocks are variable length malloc-ed objects.  The following structure\n  // describes the common header for all blocks.\n  struct Block {\n    void* owner;   // &ThreadCache of thread that owns this block, or\n                   // &this->owner if not yet owned by a thread.\n    Block* next;   // Next block in arena (may have different owner)\n    // ((char*) &block) + pos is next available byte. It is always\n    // aligned at a multiple of 8 bytes.\n    size_t pos;\n    size_t size;  // total size of the block.\n    GOOGLE_ATTRIBUTE_ALWAYS_INLINE size_t avail() const { return size - pos; }\n    // data follows\n  };\n\n  template<typename Type> friend class ::google::protobuf::internal::GenericTypeHandler;\n  friend class MockArena;              // For unit-testing.\n  friend class internal::ArenaString;  // For AllocateAligned.\n  friend class internal::LazyField;    // For CreateMaybeMessage.\n\n  struct ThreadCache {\n    // The ThreadCache is considered valid as long as this matches the\n    // lifecycle_id of the arena being used.\n    int64 last_lifecycle_id_seen;\n    Block* last_block_used_;\n  };\n\n  static const size_t kHeaderSize = sizeof(Block);\n  static google::protobuf::internal::SequenceNumber lifecycle_id_generator_;\n#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)\n  // Android ndk does not support GOOGLE_THREAD_LOCAL keyword so we use a custom thread\n  // local storage class we implemented.\n  // iOS also does not support the GOOGLE_THREAD_LOCAL keyword.\n  static ThreadCache& thread_cache();\n#elif defined(PROTOBUF_USE_DLLS)\n  // Thread local variables cannot be exposed through DLL interface but we can\n  // wrap them in static functions.\n  static ThreadCache& thread_cache();\n#else\n  static GOOGLE_THREAD_LOCAL ThreadCache thread_cache_;\n  static ThreadCache& thread_cache() { return thread_cache_; }\n#endif\n\n  // SFINAE for skipping addition to delete list for a message type when created\n  // with CreateMessage. This is mainly to skip proto2/proto1 message objects\n  // with cc_enable_arenas=true from being part of the delete list. Also, note,\n  // compiler will optimize out the branch in CreateInternal<T>.\n  template<typename T>\n  static inline bool SkipDeleteList(typename T::DestructorSkippable_*) {\n    return true;\n  }\n\n  // For message objects that don't have the DestructorSkippable_ trait, we\n  // always add to the delete list.\n  template<typename T>\n  static inline bool SkipDeleteList(...) {\n    return google::protobuf::internal::has_trivial_destructor<T>::value;\n  }\n\n private:\n  struct InternalIsDestructorSkippableHelper {\n    template<typename U>\n    static char DestructorSkippable(\n        const typename U::DestructorSkippable_*);\n    template<typename U>\n    static double DestructorSkippable(...);\n  };\n\n public:\n  // Helper typetrait that indicates whether the desctructor of type T should be\n  // called when arena is destroyed at compile time. This is only to allow\n  // construction of higher-level templated utilities.\n  // is_destructor_skippable<T>::value is true if the destructor of the message\n  // type T should not be called when arena is destroyed or false otherwise.\n  // This is inside Arena because only Arena has the friend relationships\n  // necessary to see the underlying generated code traits.\n  template<typename T>\n  struct is_destructor_skippable\n      : public google::protobuf::internal::integral_constant<\n            bool,\n            sizeof(InternalIsDestructorSkippableHelper::DestructorSkippable<\n                   const T>(static_cast<const T*>(0))) == sizeof(char) ||\n                google::protobuf::internal::has_trivial_destructor<T>::value> {};\n\n  // CreateMessage<T> requires that T supports arenas, but this private method\n  // works whether or not T supports arenas. These are not exposed to user code\n  // as it can cause confusing API usages, and end up having double free in\n  // user code. These are used only internally from LazyField and Repeated\n  // fields, since they are designed to work in all mode combinations.\n  template<typename Msg> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  static Msg* CreateMaybeMessage(\n      Arena* arena, typename Msg::InternalArenaConstructable_*) {\n    return CreateMessage<Msg>(arena);\n  }\n\n  template<typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  static T* CreateMaybeMessage(Arena* arena, ...) {\n    return Create<T>(arena);\n  }\n\n  // Just allocate the required size for the given type assuming the\n  // type has a trivial constructor.\n  template<typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  T* CreateInternalRawArray(size_t num_elements) {\n    GOOGLE_CHECK_LE(num_elements,\n             std::numeric_limits<size_t>::max() / sizeof(T))\n        << \"Requested size is too large to fit into size_t.\";\n    return static_cast<T*>(\n        AllocateAligned(RTTI_TYPE_ID(T), sizeof(T) * num_elements));\n  }\n\n  template <typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  T* CreateInternal(bool skip_explicit_ownership) {\n    T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T))) T();\n    if (!skip_explicit_ownership) {\n      AddListNode(t, &internal::arena_destruct_object<T>);\n    }\n    return t;\n  }\n\n  template <typename T, typename Arg> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  T* CreateInternal(bool skip_explicit_ownership, const Arg& arg) {\n    T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T))) T(arg);\n    if (!skip_explicit_ownership) {\n      AddListNode(t, &internal::arena_destruct_object<T>);\n    }\n    return t;\n  }\n\n  template <typename T, typename Arg1, typename Arg2> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  T* CreateInternal(\n      bool skip_explicit_ownership, const Arg1& arg1, const Arg2& arg2) {\n    T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T))) T(arg1, arg2);\n    if (!skip_explicit_ownership) {\n      AddListNode(t, &internal::arena_destruct_object<T>);\n    }\n    return t;\n  }\n\n  template <typename T, typename Arg1, typename Arg2, typename Arg3>\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE T* CreateInternal(bool skip_explicit_ownership,\n                                            const Arg1& arg1,\n                                            const Arg2& arg2,\n                                            const Arg3& arg3) {\n    T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T)))\n        T(arg1, arg2, arg3);\n    if (!skip_explicit_ownership) {\n      AddListNode(t, &internal::arena_destruct_object<T>);\n    }\n    return t;\n  }\n\n  template <typename T, typename Arg1, typename Arg2, typename Arg3,\n            typename Arg4>\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE T* CreateInternal(bool skip_explicit_ownership,\n                                            const Arg1& arg1,\n                                            const Arg2& arg2,\n                                            const Arg3& arg3,\n                                            const Arg4& arg4) {\n    T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T)))\n        T(arg1, arg2, arg3, arg4);\n    if (!skip_explicit_ownership) {\n      AddListNode(t, &internal::arena_destruct_object<T>);\n    }\n    return t;\n  }\n\n  template <typename T, typename Arg1, typename Arg2, typename Arg3,\n            typename Arg4, typename Arg5>\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE T* CreateInternal(bool skip_explicit_ownership,\n                                            const Arg1& arg1,\n                                            const Arg2& arg2,\n                                            const Arg3& arg3,\n                                            const Arg4& arg4,\n                                            const Arg5& arg5) {\n    T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T)))\n        T(arg1, arg2, arg3, arg4, arg5);\n    if (!skip_explicit_ownership) {\n      AddListNode(t, &internal::arena_destruct_object<T>);\n    }\n    return t;\n  }\n\n  template <typename T, typename Arg1, typename Arg2, typename Arg3,\n            typename Arg4, typename Arg5, typename Arg6>\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE T* CreateInternal(bool skip_explicit_ownership,\n                                            const Arg1& arg1,\n                                            const Arg2& arg2,\n                                            const Arg3& arg3,\n                                            const Arg4& arg4,\n                                            const Arg5& arg5,\n                                            const Arg6& arg6) {\n    T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T)))\n        T(arg1, arg2, arg3, arg4, arg5, arg6);\n    if (!skip_explicit_ownership) {\n      AddListNode(t, &internal::arena_destruct_object<T>);\n    }\n    return t;\n  }\n\n  template <typename T, typename Arg1, typename Arg2, typename Arg3,\n            typename Arg4, typename Arg5, typename Arg6, typename Arg7>\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE T* CreateInternal(bool skip_explicit_ownership,\n                                            const Arg1& arg1,\n                                            const Arg2& arg2,\n                                            const Arg3& arg3,\n                                            const Arg4& arg4,\n                                            const Arg5& arg5,\n                                            const Arg6& arg6,\n                                            const Arg7& arg7) {\n    T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T)))\n        T(arg1, arg2, arg3, arg4, arg5, arg6, arg7);\n    if (!skip_explicit_ownership) {\n      AddListNode(t, &internal::arena_destruct_object<T>);\n    }\n    return t;\n  }\n\n  template <typename T, typename Arg1, typename Arg2, typename Arg3,\n            typename Arg4, typename Arg5, typename Arg6, typename Arg7,\n            typename Arg8>\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE T* CreateInternal(bool skip_explicit_ownership,\n                                            const Arg1& arg1,\n                                            const Arg2& arg2,\n                                            const Arg3& arg3,\n                                            const Arg4& arg4,\n                                            const Arg5& arg5,\n                                            const Arg6& arg6,\n                                            const Arg7& arg7,\n                                            const Arg8& arg8) {\n    T* t = new (AllocateAligned(RTTI_TYPE_ID(T), sizeof(T)))\n        T(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);\n    if (!skip_explicit_ownership) {\n      AddListNode(t, &internal::arena_destruct_object<T>);\n    }\n    return t;\n  }\n\n  template <typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  T* CreateMessageInternal(typename T::InternalArenaConstructable_*) {\n    return CreateInternal<T, Arena*>(SkipDeleteList<T>(static_cast<T*>(0)),\n                                     this);\n  }\n\n  template <typename T, typename Arg> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  T* CreateMessageInternal(typename T::InternalArenaConstructable_*,\n                           const Arg& arg) {\n    return CreateInternal<T, Arena*>(SkipDeleteList<T>(static_cast<T*>(0)),\n                                     this, arg);\n  }\n\n  template <typename T, typename Arg1, typename Arg2> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  T* CreateMessageInternal(typename T::InternalArenaConstructable_*,\n                           const Arg1& arg1, const Arg2& arg2) {\n    return CreateInternal<T, Arena*>(SkipDeleteList<T>(static_cast<T*>(0)),\n                                     this, arg1, arg2);\n  }\n\n  // CreateInArenaStorage is used to implement map field. Without it,\n  // google::protobuf::Map need to call generated message's protected arena constructor,\n  // which needs to declare google::protobuf::Map as friend of generated message.\n  template <typename T>\n  static void CreateInArenaStorage(T* ptr, Arena* arena) {\n    CreateInArenaStorageInternal(ptr, arena,\n                                 typename is_arena_constructable<T>::type());\n    RegisterDestructorInternal(ptr, arena,\n                               typename is_destructor_skippable<T>::type());\n  }\n\n  template <typename T>\n  static void CreateInArenaStorageInternal(\n      T* ptr, Arena* arena, google::protobuf::internal::true_type) {\n    new (ptr) T(arena);\n  }\n  template <typename T>\n  static void CreateInArenaStorageInternal(\n      T* ptr, Arena* arena, google::protobuf::internal::false_type) {\n    new (ptr) T();\n  }\n\n  template <typename T>\n  static void RegisterDestructorInternal(\n      T* ptr, Arena* arena, google::protobuf::internal::true_type) {}\n  template <typename T>\n  static void RegisterDestructorInternal(\n      T* ptr, Arena* arena, google::protobuf::internal::false_type) {\n    arena->OwnDestructor(ptr);\n  }\n\n  // These implement Own(), which registers an object for deletion (destructor\n  // call and operator delete()). The second parameter has type 'true_type' if T\n  // is a subtype of ::google::protobuf::Message and 'false_type' otherwise. Collapsing\n  // all template instantiations to one for generic Message reduces code size,\n  // using the virtual destructor instead.\n  template<typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  void OwnInternal(T* object, google::protobuf::internal::true_type) {\n    if (object != NULL) {\n      AddListNode(object, &internal::arena_delete_object< ::google::protobuf::Message >);\n    }\n  }\n  template<typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  void OwnInternal(T* object, google::protobuf::internal::false_type) {\n    if (object != NULL) {\n      AddListNode(object, &internal::arena_delete_object<T>);\n    }\n  }\n\n  // Implementation for GetArena(). Only message objects with\n  // InternalArenaConstructable_ tags can be associated with an arena, and such\n  // objects must implement a GetArenaNoVirtual() method.\n  template<typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  static ::google::protobuf::Arena* GetArenaInternal(\n      const T* value, typename T::InternalArenaConstructable_*) {\n    return value->GetArenaNoVirtual();\n  }\n\n  template<typename T> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  static ::google::protobuf::Arena* GetArenaInternal(const T* value, ...) {\n    return NULL;\n  }\n\n  // Allocate and also optionally call on_arena_allocation callback with the\n  // allocated type info when the hooks are in place in ArenaOptions and\n  // the cookie is not null.\n  void* AllocateAligned(const std::type_info* allocated, size_t n);\n\n  // Allocate an internal allocation, avoiding optional typed monitoring.\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE void* AllocateAligned(size_t n) {\n    return AllocateAligned(NULL, n);\n  }\n\n  void Init();\n\n  // Free all blocks and return the total space used which is the sums of sizes\n  // of the all the allocated blocks.\n  uint64 FreeBlocks();\n\n  // Add object pointer and cleanup function pointer to the list.\n  // TODO(rohananil, cfallin): We could pass in a sub-arena into this method\n  // to avoid polluting blocks of this arena with list nodes. This would help in\n  // mixed mode (where many protobufs have cc_enable_arenas=false), and is an\n  // alternative to a chunked linked-list, but with extra overhead of *next.\n  void AddListNode(void* elem, void (*cleanup)(void*));\n  // Delete or Destruct all objects owned by the arena.\n  void CleanupList();\n  uint64 ResetInternal();\n\n  inline void SetThreadCacheBlock(Block* block) {\n    thread_cache().last_block_used_ = block;\n    thread_cache().last_lifecycle_id_seen = lifecycle_id_;\n  }\n\n  int64 lifecycle_id_;  // Unique for each arena. Changes on Reset().\n\n  google::protobuf::internal::AtomicWord blocks_;  // Head of linked list of all allocated blocks\n  google::protobuf::internal::AtomicWord hint_;    // Fast thread-local block access\n\n  // Node contains the ptr of the object to be cleaned up and the associated\n  // cleanup function ptr.\n  struct Node {\n    void* elem;              // Pointer to the object to be cleaned up.\n    void (*cleanup)(void*);  // Function pointer to the destructor or deleter.\n    Node* next;              // Next node in the list.\n  };\n\n  google::protobuf::internal::AtomicWord cleanup_list_;  // Head of a linked list of nodes containing object\n                             // ptrs and cleanup methods.\n\n  bool owns_first_block_;    // Indicates that arena owns the first block\n  Mutex blocks_lock_;\n\n  void AddBlock(Block* b);\n  // Access must be synchronized, either by blocks_lock_ or by being called from\n  // Init()/Reset().\n  void AddBlockInternal(Block* b);\n  void* SlowAlloc(size_t n);\n  Block* FindBlock(void* me);\n  Block* NewBlock(void* me, Block* my_last_block, size_t n,\n                  size_t start_block_size, size_t max_block_size);\n  static void* AllocFromBlock(Block* b, size_t n);\n  template <typename Key, typename T>\n  friend class Map;\n\n  // The arena may save a cookie it receives from the external on_init hook\n  // and then use it when calling the on_reset and on_destruction hooks.\n  void* hooks_cookie_;\n\n  ArenaOptions options_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Arena);\n};\n\n// Defined above for supporting environments without RTTI.\n#undef RTTI_TYPE_ID\n\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_ARENA_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/arena_test_util.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/arena_test_util.h>\n\n\n#define EXPECT_EQ GOOGLE_CHECK_EQ\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\nNoHeapChecker::~NoHeapChecker() {\n  capture_alloc.Unhook();\n  EXPECT_EQ(0, capture_alloc.alloc_count());\n  EXPECT_EQ(0, capture_alloc.free_count());\n}\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/arena_test_util.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_ARENA_TEST_UTIL_H__\n#define GOOGLE_PROTOBUF_ARENA_TEST_UTIL_H__\n\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\nclass NoHeapChecker {\n public:\n  NoHeapChecker() {\n    capture_alloc.Hook();\n  }\n  ~NoHeapChecker();\n private:\n  class NewDeleteCapture {\n   public:\n    // TOOD(xiaofeng): Implement this for opensource protobuf.\n    void Hook() {}\n    void Unhook() {}\n    int alloc_count() { return 0; }\n    int free_count() { return 0; }\n  } capture_alloc;\n};\n\n}  // namespace internal\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_ARENA_TEST_UTIL_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/arena_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/arena.h>\n\n#include <algorithm>\n#include <cstring>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <string>\n#include <typeinfo>\n#include <vector>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/arena_test_util.h>\n#include <google/protobuf/test_util.h>\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/unittest_arena.pb.h>\n#include <google/protobuf/unittest_no_arena.pb.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl_lite.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/extension_set.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/message_lite.h>\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/wire_format_lite.h>\n#include <google/protobuf/unknown_field_set.h>\n#include <gtest/gtest.h>\n\n\nnamespace google {\nusing proto2_arena_unittest::ArenaMessage;\nusing protobuf_unittest::TestAllTypes;\nusing protobuf_unittest::TestAllExtensions;\nusing protobuf_unittest::TestOneof2;\nusing protobuf_unittest::TestEmptyMessage;\n\nnamespace protobuf {\nnamespace {\n\nclass Notifier {\n public:\n  Notifier() : count_(0) {}\n  void Notify() {\n    count_++;\n  }\n  int GetCount() {\n    return count_;\n  }\n\n private:\n  int count_;\n};\n\nclass SimpleDataType {\n public:\n  SimpleDataType() : notifier_(NULL) {}\n  void SetNotifier(Notifier* notifier) {\n    notifier_ = notifier;\n  }\n  virtual ~SimpleDataType() {\n    if (notifier_ != NULL) {\n      notifier_->Notify();\n    }\n  };\n private:\n  Notifier* notifier_;\n};\n\n// A simple class that does not allow copying and so cannot be used as a\n// parameter type without \"const &\".\nclass PleaseDontCopyMe {\n public:\n  explicit PleaseDontCopyMe(int value) : value_(value) {}\n\n  int value() const { return value_; }\n\n private:\n  int value_;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PleaseDontCopyMe);\n};\n\n// A class that takes four different types as constructor arguments.\nclass MustBeConstructedWithOneThroughFour {\n public:\n  MustBeConstructedWithOneThroughFour(\n      int one, const char* two, const string& three,\n      const PleaseDontCopyMe* four)\n      : one_(one), two_(two), three_(three), four_(four) {}\n\n  int one_;\n  const char* const two_;\n  string three_;\n  const PleaseDontCopyMe* four_;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MustBeConstructedWithOneThroughFour);\n};\n\n// A class that takes eight different types as constructor arguments.\nclass MustBeConstructedWithOneThroughEight {\n public:\n  MustBeConstructedWithOneThroughEight(\n      int one, const char* two, const string& three,\n      const PleaseDontCopyMe* four, int five, const char* six,\n      const string& seven, const string& eight)\n      : one_(one), two_(two), three_(three), four_(four), five_(five),\n        six_(six), seven_(seven), eight_(eight) {}\n\n  int one_;\n  const char* const two_;\n  string three_;\n  const PleaseDontCopyMe* four_;\n  int five_;\n  const char* const six_;\n  string seven_;\n  string eight_;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MustBeConstructedWithOneThroughEight);\n};\n\n}  // namespace\n\nTEST(ArenaTest, ArenaConstructable) {\n  EXPECT_TRUE(Arena::is_arena_constructable<TestAllTypes>::type::value);\n  EXPECT_TRUE(Arena::is_arena_constructable<const TestAllTypes>::type::value);\n  EXPECT_FALSE(Arena::is_arena_constructable<Arena>::type::value);\n}\n\nTEST(ArenaTest, BasicCreate) {\n  Arena arena;\n  EXPECT_TRUE(Arena::Create<int32>(&arena) != NULL);\n  EXPECT_TRUE(Arena::Create<int64>(&arena) != NULL);\n  EXPECT_TRUE(Arena::Create<float>(&arena) != NULL);\n  EXPECT_TRUE(Arena::Create<double>(&arena) != NULL);\n  EXPECT_TRUE(Arena::Create<string>(&arena) != NULL);\n  arena.Own(new int32);\n  arena.Own(new int64);\n  arena.Own(new float);\n  arena.Own(new double);\n  arena.Own(new string);\n  arena.Own<int>(NULL);\n  Notifier notifier;\n  SimpleDataType* data = Arena::Create<SimpleDataType>(&arena);\n  data->SetNotifier(&notifier);\n  data = new SimpleDataType;\n  data->SetNotifier(&notifier);\n  arena.Own(data);\n  arena.Reset();\n  EXPECT_EQ(2, notifier.GetCount());\n}\n\nTEST(ArenaTest, CreateWithFourConstructorArguments) {\n  Arena arena;\n  const string three(\"3\");\n  const PleaseDontCopyMe four(4);\n  const MustBeConstructedWithOneThroughFour* new_object =\n      Arena::Create<MustBeConstructedWithOneThroughFour>(\n          &arena, 1, \"2\", three, &four);\n  EXPECT_TRUE(new_object != NULL);\n  ASSERT_EQ(1, new_object->one_);\n  ASSERT_STREQ(\"2\", new_object->two_);\n  ASSERT_EQ(\"3\", new_object->three_);\n  ASSERT_EQ(4, new_object->four_->value());\n}\n\nTEST(ArenaTest, CreateWithEightConstructorArguments) {\n  Arena arena;\n  const string three(\"3\");\n  const PleaseDontCopyMe four(4);\n  const string seven(\"7\");\n  const string eight(\"8\");\n  const MustBeConstructedWithOneThroughEight* new_object =\n      Arena::Create<MustBeConstructedWithOneThroughEight>(\n          &arena, 1, \"2\", three, &four, 5, \"6\", seven, eight);\n  EXPECT_TRUE(new_object != NULL);\n  ASSERT_EQ(1, new_object->one_);\n  ASSERT_STREQ(\"2\", new_object->two_);\n  ASSERT_EQ(\"3\", new_object->three_);\n  ASSERT_EQ(4, new_object->four_->value());\n  ASSERT_EQ(5, new_object->five_);\n  ASSERT_STREQ(\"6\", new_object->six_);\n  ASSERT_EQ(\"7\", new_object->seven_);\n  ASSERT_EQ(\"8\", new_object->eight_);\n}\n\nTEST(ArenaTest, InitialBlockTooSmall) {\n  // Construct a small (64 byte) initial block of memory to be used by the\n  // arena allocator; then, allocate an object which will not fit in the\n  // initial block.\n  std::vector<char> arena_block(64);\n  ArenaOptions options;\n  options.initial_block = &arena_block[0];\n  options.initial_block_size = arena_block.size();\n  Arena arena(options);\n\n  char* p = ::google::protobuf::Arena::CreateArray<char>(&arena, 96);\n  uintptr_t allocation = reinterpret_cast<uintptr_t>(p);\n\n  // Ensure that the arena allocator did not return memory pointing into the\n  // initial block of memory.\n  uintptr_t arena_start = reinterpret_cast<uintptr_t>(&arena_block[0]);\n  uintptr_t arena_end = arena_start + arena_block.size();\n  EXPECT_FALSE(allocation >= arena_start && allocation < arena_end);\n\n  // Write to the memory we allocated; this should (but is not guaranteed to)\n  // trigger a check for heap corruption if the object was allocated from the\n  // initially-provided block.\n  memset(p, '\\0', 96);\n}\n\nTEST(ArenaTest, Parsing) {\n  TestAllTypes original;\n  TestUtil::SetAllFields(&original);\n\n  // Test memory leak.\n  Arena arena;\n  TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena);\n  arena_message->ParseFromString(original.SerializeAsString());\n  TestUtil::ExpectAllFieldsSet(*arena_message);\n\n  // Test that string fields have null terminator bytes (earlier bug).\n  EXPECT_EQ(strlen(original.optional_string().c_str()),\n            strlen(arena_message->optional_string().c_str()));\n}\n\nTEST(ArenaTest, UnknownFields) {\n  TestAllTypes original;\n  TestUtil::SetAllFields(&original);\n\n  // Test basic parsing into (populating) and reading out of unknown fields on\n  // an arena.\n  Arena arena;\n  TestEmptyMessage* arena_message =\n      Arena::CreateMessage<TestEmptyMessage>(&arena);\n  arena_message->ParseFromString(original.SerializeAsString());\n\n  TestAllTypes copied;\n  copied.ParseFromString(arena_message->SerializeAsString());\n  TestUtil::ExpectAllFieldsSet(copied);\n\n  // Exercise UFS manual manipulation (setters).\n  arena_message = Arena::CreateMessage<TestEmptyMessage>(&arena);\n  arena_message->mutable_unknown_fields()->AddVarint(\n      TestAllTypes::kOptionalInt32FieldNumber, 42);\n  copied.Clear();\n  copied.ParseFromString(arena_message->SerializeAsString());\n  EXPECT_TRUE(copied.has_optional_int32());\n  EXPECT_EQ(42, copied.optional_int32());\n\n  // Exercise UFS swap path.\n  TestEmptyMessage* arena_message_2 =\n      Arena::CreateMessage<TestEmptyMessage>(&arena);\n  arena_message_2->Swap(arena_message);\n  copied.Clear();\n  copied.ParseFromString(arena_message_2->SerializeAsString());\n  EXPECT_TRUE(copied.has_optional_int32());\n  EXPECT_EQ(42, copied.optional_int32());\n\n  // Test field manipulation.\n  TestEmptyMessage* arena_message_3 =\n      Arena::CreateMessage<TestEmptyMessage>(&arena);\n  arena_message_3->mutable_unknown_fields()->AddVarint(1000, 42);\n  arena_message_3->mutable_unknown_fields()->AddFixed32(1001, 42);\n  arena_message_3->mutable_unknown_fields()->AddFixed64(1002, 42);\n  arena_message_3->mutable_unknown_fields()->AddLengthDelimited(1003);\n  arena_message_3->mutable_unknown_fields()->DeleteSubrange(0, 2);\n  arena_message_3->mutable_unknown_fields()->DeleteByNumber(1002);\n  arena_message_3->mutable_unknown_fields()->DeleteByNumber(1003);\n  EXPECT_TRUE(arena_message_3->unknown_fields().empty());\n}\n\nTEST(ArenaTest, Swap) {\n  Arena arena1;\n  Arena arena2;\n  TestAllTypes* arena1_message;\n  TestAllTypes* arena2_message;\n\n  // Case 1: Swap(), no UFS on either message, both messages on different\n  // arenas. Arena pointers should remain the same after swap.\n  arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1);\n  arena2_message = Arena::CreateMessage<TestAllTypes>(&arena2);\n  arena1_message->Swap(arena2_message);\n  EXPECT_EQ(&arena1, arena1_message->GetArena());\n  EXPECT_EQ(&arena2, arena2_message->GetArena());\n\n  // Case 2: Swap(), UFS on one message, both messages on different arenas.\n  arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1);\n  arena2_message = Arena::CreateMessage<TestAllTypes>(&arena2);\n  arena1_message->mutable_unknown_fields()->AddVarint(1, 42);\n  arena1_message->Swap(arena2_message);\n  EXPECT_EQ(&arena1, arena1_message->GetArena());\n  EXPECT_EQ(&arena2, arena2_message->GetArena());\n  EXPECT_EQ(0, arena1_message->unknown_fields().field_count());\n  EXPECT_EQ(1, arena2_message->unknown_fields().field_count());\n  EXPECT_EQ(42, arena2_message->unknown_fields().field(0).varint());\n\n  // Case 3: Swap(), UFS on both messages, both messages on different arenas.\n  arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1);\n  arena2_message = Arena::CreateMessage<TestAllTypes>(&arena2);\n  arena1_message->mutable_unknown_fields()->AddVarint(1, 42);\n  arena2_message->mutable_unknown_fields()->AddVarint(2, 84);\n  arena1_message->Swap(arena2_message);\n  EXPECT_EQ(&arena1, arena1_message->GetArena());\n  EXPECT_EQ(&arena2, arena2_message->GetArena());\n  EXPECT_EQ(1, arena1_message->unknown_fields().field_count());\n  EXPECT_EQ(1, arena2_message->unknown_fields().field_count());\n  EXPECT_EQ(84, arena1_message->unknown_fields().field(0).varint());\n  EXPECT_EQ(42, arena2_message->unknown_fields().field(0).varint());\n}\n\nTEST(ArenaTest, ReflectionSwapFields) {\n  Arena arena1;\n  Arena arena2;\n  TestAllTypes* arena1_message;\n  TestAllTypes* arena2_message;\n\n  // Case 1: messages on different arenas, only one message is set.\n  arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1);\n  arena2_message = Arena::CreateMessage<TestAllTypes>(&arena2);\n  TestUtil::SetAllFields(arena1_message);\n  const Reflection* reflection = arena1_message->GetReflection();\n  std::vector<const FieldDescriptor*> fields;\n  reflection->ListFields(*arena1_message, &fields);\n  reflection->SwapFields(arena1_message, arena2_message, fields);\n  EXPECT_EQ(&arena1, arena1_message->GetArena());\n  EXPECT_EQ(&arena2, arena2_message->GetArena());\n  string output;\n  arena1_message->SerializeToString(&output);\n  EXPECT_EQ(0, output.size());\n  TestUtil::ExpectAllFieldsSet(*arena2_message);\n  reflection->SwapFields(arena1_message, arena2_message, fields);\n  arena2_message->SerializeToString(&output);\n  EXPECT_EQ(0, output.size());\n  TestUtil::ExpectAllFieldsSet(*arena1_message);\n\n  // Case 2: messages on different arenas, both messages are set.\n  arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1);\n  arena2_message = Arena::CreateMessage<TestAllTypes>(&arena2);\n  TestUtil::SetAllFields(arena1_message);\n  TestUtil::SetAllFields(arena2_message);\n  reflection->SwapFields(arena1_message, arena2_message, fields);\n  EXPECT_EQ(&arena1, arena1_message->GetArena());\n  EXPECT_EQ(&arena2, arena2_message->GetArena());\n  TestUtil::ExpectAllFieldsSet(*arena1_message);\n  TestUtil::ExpectAllFieldsSet(*arena2_message);\n\n  // Case 3: messages on different arenas with different lifetimes.\n  arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1);\n  {\n    Arena arena3;\n    TestAllTypes* arena3_message = Arena::CreateMessage<TestAllTypes>(&arena3);\n    TestUtil::SetAllFields(arena3_message);\n    reflection->SwapFields(arena1_message, arena3_message, fields);\n  }\n  TestUtil::ExpectAllFieldsSet(*arena1_message);\n\n  // Case 4: one message on arena, the other on heap.\n  arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1);\n  TestAllTypes message;\n  TestUtil::SetAllFields(arena1_message);\n  reflection->SwapFields(arena1_message, &message, fields);\n  EXPECT_EQ(&arena1, arena1_message->GetArena());\n  EXPECT_EQ(NULL, message.GetArena());\n  arena1_message->SerializeToString(&output);\n  EXPECT_EQ(0, output.size());\n  TestUtil::ExpectAllFieldsSet(message);\n}\n\nTEST(ArenaTest, SetAllocatedMessage) {\n  Arena arena;\n  TestAllTypes *arena_message = Arena::CreateMessage<TestAllTypes>(&arena);\n  TestAllTypes::NestedMessage* nested = new TestAllTypes::NestedMessage;\n  nested->set_bb(118);\n  arena_message->set_allocated_optional_nested_message(nested);\n  EXPECT_EQ(118, arena_message->optional_nested_message().bb());\n\n  protobuf_unittest_no_arena::TestNoArenaMessage no_arena_message;\n  EXPECT_FALSE(no_arena_message.has_arena_message());\n  no_arena_message.set_allocated_arena_message(NULL);\n  EXPECT_FALSE(no_arena_message.has_arena_message());\n  no_arena_message.set_allocated_arena_message(new ArenaMessage);\n  EXPECT_TRUE(no_arena_message.has_arena_message());\n}\n\nTEST(ArenaTest, ReleaseMessage) {\n  Arena arena;\n  TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena);\n  arena_message->mutable_optional_nested_message()->set_bb(118);\n  google::protobuf::scoped_ptr<TestAllTypes::NestedMessage> nested(\n      arena_message->release_optional_nested_message());\n  EXPECT_EQ(118, nested->bb());\n\n  TestAllTypes::NestedMessage* released_null =\n      arena_message->release_optional_nested_message();\n  EXPECT_EQ(NULL, released_null);\n}\n\nTEST(ArenaTest, SetAllocatedString) {\n  Arena arena;\n  TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena);\n  string* allocated_str = new string(\"hello\");\n  arena_message->set_allocated_optional_string(allocated_str);\n  EXPECT_EQ(\"hello\", arena_message->optional_string());\n}\n\nTEST(ArenaTest, ReleaseString) {\n  Arena arena;\n  TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena);\n  arena_message->set_optional_string(\"hello\");\n  google::protobuf::scoped_ptr<string> released_str(\n      arena_message->release_optional_string());\n  EXPECT_EQ(\"hello\", *released_str);\n\n  // Test default value.\n}\n\n\nTEST(ArenaTest, SwapBetweenArenasWithAllFieldsSet) {\n  Arena arena1;\n  TestAllTypes* arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1);\n  {\n    Arena arena2;\n    TestAllTypes* arena2_message = Arena::CreateMessage<TestAllTypes>(&arena2);\n    TestUtil::SetAllFields(arena2_message);\n    arena2_message->Swap(arena1_message);\n    string output;\n    arena2_message->SerializeToString(&output);\n    EXPECT_EQ(0, output.size());\n  }\n  TestUtil::ExpectAllFieldsSet(*arena1_message);\n}\n\nTEST(ArenaTest, SwapBetweenArenaAndNonArenaWithAllFieldsSet) {\n  TestAllTypes non_arena_message;\n  TestUtil::SetAllFields(&non_arena_message);\n  {\n    Arena arena2;\n    TestAllTypes* arena2_message = Arena::CreateMessage<TestAllTypes>(&arena2);\n    TestUtil::SetAllFields(arena2_message);\n    arena2_message->Swap(&non_arena_message);\n    TestUtil::ExpectAllFieldsSet(*arena2_message);\n    TestUtil::ExpectAllFieldsSet(non_arena_message);\n  }\n}\n\nTEST(ArenaTest, UnsafeArenaSwap) {\n  Arena shared_arena;\n  TestAllTypes* message1 = Arena::CreateMessage<TestAllTypes>(&shared_arena);\n  TestAllTypes* message2 = Arena::CreateMessage<TestAllTypes>(&shared_arena);\n  TestUtil::SetAllFields(message1);\n  message1->UnsafeArenaSwap(message2);\n  TestUtil::ExpectAllFieldsSet(*message2);\n}\n\nTEST(ArenaTest, SwapBetweenArenasUsingReflection) {\n  Arena arena1;\n  TestAllTypes* arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1);\n  {\n    Arena arena2;\n    TestAllTypes* arena2_message = Arena::CreateMessage<TestAllTypes>(&arena2);\n    TestUtil::SetAllFields(arena2_message);\n    const Reflection* r = arena2_message->GetReflection();\n    r->Swap(arena1_message, arena2_message);\n    string output;\n    arena2_message->SerializeToString(&output);\n    EXPECT_EQ(0, output.size());\n  }\n  TestUtil::ExpectAllFieldsSet(*arena1_message);\n}\n\nTEST(ArenaTest, SwapBetweenArenaAndNonArenaUsingReflection) {\n  TestAllTypes non_arena_message;\n  TestUtil::SetAllFields(&non_arena_message);\n  {\n    Arena arena2;\n    TestAllTypes* arena2_message = Arena::CreateMessage<TestAllTypes>(&arena2);\n    TestUtil::SetAllFields(arena2_message);\n    const Reflection* r = arena2_message->GetReflection();\n    r->Swap(&non_arena_message, arena2_message);\n    TestUtil::ExpectAllFieldsSet(*arena2_message);\n    TestUtil::ExpectAllFieldsSet(non_arena_message);\n  }\n}\n\nTEST(ArenaTest, ReleaseFromArenaMessageMakesCopy) {\n  TestAllTypes::NestedMessage* nested_msg = NULL;\n  string* nested_string = NULL;\n  {\n    Arena arena;\n    TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena);\n    arena_message->mutable_optional_nested_message()->set_bb(42);\n    *arena_message->mutable_optional_string() = \"Hello\";\n    nested_msg = arena_message->release_optional_nested_message();\n    nested_string = arena_message->release_optional_string();\n  }\n  EXPECT_EQ(42, nested_msg->bb());\n  EXPECT_EQ(\"Hello\", *nested_string);\n  delete nested_msg;\n  delete nested_string;\n}\n\n#ifndef GOOGLE_PROTOBUF_NO_RTTI\nTEST(ArenaTest, ReleaseFromArenaMessageUsingReflectionMakesCopy) {\n  TestAllTypes::NestedMessage* nested_msg = NULL;\n  // Note: no string: reflection API only supports releasing submessages.\n  {\n    Arena arena;\n    TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena);\n    arena_message->mutable_optional_nested_message()->set_bb(42);\n    const Reflection* r = arena_message->GetReflection();\n    const FieldDescriptor* f = arena_message->GetDescriptor()->FindFieldByName(\n        \"optional_nested_message\");\n    nested_msg = static_cast<TestAllTypes::NestedMessage*>(\n        r->ReleaseMessage(arena_message, f));\n  }\n  EXPECT_EQ(42, nested_msg->bb());\n  delete nested_msg;\n}\n#endif  // !GOOGLE_PROTOBUF_NO_RTTI\n\nTEST(ArenaTest, UnsafeArenaReleaseDoesNotMakeCopy) {\n  Arena arena;\n  TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena);\n  TestAllTypes::NestedMessage* nested_msg = NULL;\n  TestAllTypes::NestedMessage* orig_nested_msg = NULL;\n  string* nested_string = NULL;\n  string* orig_nested_string = NULL;\n  arena_message->mutable_optional_nested_message()->set_bb(42);\n  *arena_message->mutable_optional_string() = \"Hello\";\n  orig_nested_msg = arena_message->mutable_optional_nested_message();\n  orig_nested_string = arena_message->mutable_optional_string();\n  nested_msg = arena_message->unsafe_arena_release_optional_nested_message();\n  nested_string = arena_message->unsafe_arena_release_optional_string();\n\n  EXPECT_EQ(orig_nested_msg, nested_msg);\n  EXPECT_EQ(orig_nested_string, nested_string);\n  // Released pointers still on arena; no 'delete' calls needed here.\n}\n\nTEST(ArenaTest, SetAllocatedAcrossArenas) {\n  Arena arena1;\n  TestAllTypes* arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1);\n  TestAllTypes::NestedMessage* heap_submessage =\n      new TestAllTypes::NestedMessage();\n  heap_submessage->set_bb(42);\n  arena1_message->set_allocated_optional_nested_message(heap_submessage);\n  // Should keep same object and add to arena's Own()-list.\n  EXPECT_EQ(heap_submessage,\n            arena1_message->mutable_optional_nested_message());\n  {\n    Arena arena2;\n    TestAllTypes::NestedMessage* arena2_submessage =\n        Arena::CreateMessage<TestAllTypes::NestedMessage>(&arena2);\n    arena2_submessage->set_bb(42);\n    arena1_message->set_allocated_optional_nested_message(arena2_submessage);\n    EXPECT_NE(arena2_submessage,\n              arena1_message->mutable_optional_nested_message());\n  }\n\n  TestAllTypes::NestedMessage* arena1_submessage =\n      Arena::CreateMessage<TestAllTypes::NestedMessage>(&arena1);\n  arena1_submessage->set_bb(42);\n  TestAllTypes* heap_message = new TestAllTypes;\n  heap_message->set_allocated_optional_nested_message(arena1_submessage);\n  EXPECT_NE(arena1_submessage,\n            heap_message->mutable_optional_nested_message());\n  delete heap_message;\n}\n\nTEST(ArenaTest, SetAllocatedAcrossArenasWithReflection) {\n  // Same as above, with reflection.\n  Arena arena1;\n  TestAllTypes* arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1);\n  const Reflection* r = arena1_message->GetReflection();\n  const Descriptor* d = arena1_message->GetDescriptor();\n  const FieldDescriptor* msg_field = d->FindFieldByName(\n      \"optional_nested_message\");\n  TestAllTypes::NestedMessage* heap_submessage =\n      new TestAllTypes::NestedMessage();\n  heap_submessage->set_bb(42);\n  r->SetAllocatedMessage(arena1_message, heap_submessage, msg_field);\n  // Should keep same object and add to arena's Own()-list.\n  EXPECT_EQ(heap_submessage,\n            arena1_message->mutable_optional_nested_message());\n  {\n    Arena arena2;\n    TestAllTypes::NestedMessage* arena2_submessage =\n        Arena::CreateMessage<TestAllTypes::NestedMessage>(&arena2);\n    arena2_submessage->set_bb(42);\n    r->SetAllocatedMessage(arena1_message, arena2_submessage, msg_field);\n    EXPECT_NE(arena2_submessage,\n              arena1_message->mutable_optional_nested_message());\n  }\n\n  TestAllTypes::NestedMessage* arena1_submessage =\n      Arena::CreateMessage<TestAllTypes::NestedMessage>(&arena1);\n  arena1_submessage->set_bb(42);\n  TestAllTypes* heap_message = new TestAllTypes;\n  r->SetAllocatedMessage(heap_message, arena1_submessage, msg_field);\n  EXPECT_NE(arena1_submessage,\n            heap_message->mutable_optional_nested_message());\n  delete heap_message;\n}\n\nTEST(ArenaTest, AddAllocatedWithReflection) {\n  Arena arena1;\n  ArenaMessage* arena1_message = Arena::CreateMessage<ArenaMessage>(&arena1);\n  const Reflection* r = arena1_message->GetReflection();\n  const Descriptor* d = arena1_message->GetDescriptor();\n  const FieldDescriptor* fd =\n      d->FindFieldByName(\"repeated_import_no_arena_message\");\n  // Message with cc_enable_arenas = false;\n  r->AddMessage(arena1_message, fd);\n  r->AddMessage(arena1_message, fd);\n  r->AddMessage(arena1_message, fd);\n  EXPECT_EQ(3, r->FieldSize(*arena1_message, fd));\n  // Message with cc_enable_arenas = true;\n  fd = d->FindFieldByName(\"repeated_nested_message\");\n  r->AddMessage(arena1_message, fd);\n  r->AddMessage(arena1_message, fd);\n  r->AddMessage(arena1_message, fd);\n  EXPECT_EQ(3, r->FieldSize(*arena1_message, fd));\n}\n\nTEST(ArenaTest, RepeatedPtrFieldAddClearedTest) {\n  {\n    RepeatedPtrField<TestAllTypes> repeated_field;\n    EXPECT_TRUE(repeated_field.empty());\n    EXPECT_EQ(0, repeated_field.size());\n    // Ownership is passed to repeated_field.\n    TestAllTypes* cleared = new TestAllTypes();\n    repeated_field.AddCleared(cleared);\n    EXPECT_TRUE(repeated_field.empty());\n    EXPECT_EQ(0, repeated_field.size());\n  }\n  {\n    RepeatedPtrField<TestAllTypes> repeated_field;\n    EXPECT_TRUE(repeated_field.empty());\n    EXPECT_EQ(0, repeated_field.size());\n    // Ownership is passed to repeated_field.\n    TestAllTypes* cleared = new TestAllTypes();\n    repeated_field.AddAllocated(cleared);\n    EXPECT_FALSE(repeated_field.empty());\n    EXPECT_EQ(1, repeated_field.size());\n  }\n}\n\nTEST(ArenaTest, AddAllocatedToRepeatedField) {\n  // Heap->arena case.\n  Arena arena1;\n  TestAllTypes* arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1);\n  for (int i = 0; i < 10; i++) {\n    TestAllTypes::NestedMessage* heap_submessage =\n        new TestAllTypes::NestedMessage();\n    heap_submessage->set_bb(42);\n    arena1_message->mutable_repeated_nested_message()->\n        AddAllocated(heap_submessage);\n    // Should not copy object -- will use arena_->Own().\n    EXPECT_EQ(heap_submessage,\n              &arena1_message->repeated_nested_message(i));\n    EXPECT_EQ(42, arena1_message->repeated_nested_message(i).bb());\n  }\n\n  // Arena1->Arena2 case.\n  arena1_message->Clear();\n  for (int i = 0; i < 10; i++) {\n    Arena arena2;\n    TestAllTypes::NestedMessage* arena2_submessage =\n        Arena::CreateMessage<TestAllTypes::NestedMessage>(&arena2);\n    arena2_submessage->set_bb(42);\n    arena1_message->mutable_repeated_nested_message()->\n        AddAllocated(arena2_submessage);\n    // Should copy object.\n    EXPECT_NE(arena2_submessage,\n              &arena1_message->repeated_nested_message(i));\n    EXPECT_EQ(42, arena1_message->repeated_nested_message(i).bb());\n  }\n\n  // Arena->heap case.\n  TestAllTypes* heap_message = new TestAllTypes();\n  for (int i = 0; i < 10; i++) {\n    Arena arena2;\n    TestAllTypes::NestedMessage* arena2_submessage =\n        Arena::CreateMessage<TestAllTypes::NestedMessage>(&arena2);\n    arena2_submessage->set_bb(42);\n    heap_message->mutable_repeated_nested_message()->\n        AddAllocated(arena2_submessage);\n    // Should copy object.\n    EXPECT_NE(arena2_submessage,\n              &heap_message->repeated_nested_message(i));\n    EXPECT_EQ(42, heap_message->repeated_nested_message(i).bb());\n  }\n  delete heap_message;\n\n  // Heap-arena case for strings (which are not arena-allocated).\n  arena1_message->Clear();\n  for (int i = 0; i < 10; i++) {\n    string* s = new string(\"Test\");\n    arena1_message->mutable_repeated_string()->\n        AddAllocated(s);\n    // Should not copy.\n    EXPECT_EQ(s, &arena1_message->repeated_string(i));\n    EXPECT_EQ(\"Test\", arena1_message->repeated_string(i));\n  }\n}\n\nTEST(ArenaTest, AddAllocatedToRepeatedFieldViaReflection) {\n  // Heap->arena case.\n  Arena arena1;\n  TestAllTypes* arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1);\n  const Reflection* r = arena1_message->GetReflection();\n  const Descriptor* d = arena1_message->GetDescriptor();\n  const FieldDescriptor* fd =\n      d->FindFieldByName(\"repeated_nested_message\");\n  for (int i = 0; i < 10; i++) {\n    TestAllTypes::NestedMessage* heap_submessage =\n        new TestAllTypes::NestedMessage;\n    heap_submessage->set_bb(42);\n    r->AddAllocatedMessage(arena1_message, fd, heap_submessage);\n    // Should not copy object -- will use arena_->Own().\n    EXPECT_EQ(heap_submessage,\n              &arena1_message->repeated_nested_message(i));\n    EXPECT_EQ(42, arena1_message->repeated_nested_message(i).bb());\n  }\n\n  // Arena1->Arena2 case.\n  arena1_message->Clear();\n  for (int i = 0; i < 10; i++) {\n    Arena arena2;\n    TestAllTypes::NestedMessage* arena2_submessage =\n        Arena::CreateMessage<TestAllTypes::NestedMessage>(&arena2);\n    arena2_submessage->set_bb(42);\n    r->AddAllocatedMessage(arena1_message, fd, arena2_submessage);\n    // Should copy object.\n    EXPECT_NE(arena2_submessage,\n              &arena1_message->repeated_nested_message(i));\n    EXPECT_EQ(42, arena1_message->repeated_nested_message(i).bb());\n  }\n\n  // Arena->heap case.\n  TestAllTypes* heap_message = new TestAllTypes;\n  for (int i = 0; i < 10; i++) {\n    Arena arena2;\n    TestAllTypes::NestedMessage* arena2_submessage =\n        Arena::CreateMessage<TestAllTypes::NestedMessage>(&arena2);\n    arena2_submessage->set_bb(42);\n    r->AddAllocatedMessage(heap_message, fd, arena2_submessage);\n    // Should copy object.\n    EXPECT_NE(arena2_submessage,\n              &heap_message->repeated_nested_message(i));\n    EXPECT_EQ(42, heap_message->repeated_nested_message(i).bb());\n  }\n  delete heap_message;\n}\n\nTEST(ArenaTest, ReleaseLastRepeatedField) {\n  // Release from arena-allocated repeated field and ensure that returned object\n  // is heap-allocated.\n  Arena arena;\n  TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena);\n  for (int i = 0; i < 10; i++) {\n    TestAllTypes::NestedMessage* nested =\n        Arena::CreateMessage<TestAllTypes::NestedMessage>(&arena);\n    nested->set_bb(42);\n    arena_message->mutable_repeated_nested_message()->AddAllocated(nested);\n  }\n\n  for (int i = 0; i < 10; i++) {\n    const TestAllTypes::NestedMessage *orig_submessage =\n        &arena_message->repeated_nested_message(10 - 1 - i);  // last element\n    TestAllTypes::NestedMessage *released =\n        arena_message->mutable_repeated_nested_message()->ReleaseLast();\n    EXPECT_NE(released, orig_submessage);\n    EXPECT_EQ(42, released->bb());\n    delete released;\n  }\n\n  // Test UnsafeArenaReleaseLast().\n  for (int i = 0; i < 10; i++) {\n    TestAllTypes::NestedMessage* nested =\n        Arena::CreateMessage<TestAllTypes::NestedMessage>(&arena);\n    nested->set_bb(42);\n    arena_message->mutable_repeated_nested_message()->AddAllocated(nested);\n  }\n\n  for (int i = 0; i < 10; i++) {\n    const TestAllTypes::NestedMessage *orig_submessage =\n        &arena_message->repeated_nested_message(10 - 1 - i);  // last element\n    TestAllTypes::NestedMessage *released =\n        arena_message->mutable_repeated_nested_message()->\n        UnsafeArenaReleaseLast();\n    EXPECT_EQ(released, orig_submessage);\n    EXPECT_EQ(42, released->bb());\n    // no delete -- |released| is on the arena.\n  }\n\n  // Test string case as well. ReleaseLast() in this case must copy the string,\n  // even though it was originally heap-allocated and its pointer was simply\n  // appended to the repeated field's internal vector, because the string was\n  // placed on the arena's destructor list and cannot be removed from that list\n  // (so the arena permanently owns the original instance).\n  arena_message->Clear();\n  for (int i = 0; i < 10; i++) {\n    string* s = new string(\"Test\");\n    arena_message->mutable_repeated_string()->AddAllocated(s);\n  }\n  for (int i = 0; i < 10; i++) {\n    const string* orig_element = &arena_message->repeated_string(10 - 1 - i);\n    string* released = arena_message->mutable_repeated_string()->ReleaseLast();\n    EXPECT_NE(released, orig_element);\n    EXPECT_EQ(\"Test\", *released);\n    delete released;\n  }\n}\n\nTEST(ArenaTest, UnsafeArenaReleaseAdd) {\n  // Use unsafe_arena_release() and unsafe_arena_set_allocated() to transfer an\n  // arena-allocated string from one message to another.\n  Arena arena;\n  TestAllTypes* message1 = Arena::CreateMessage<TestAllTypes>(&arena);\n  TestAllTypes* message2 = Arena::CreateMessage<TestAllTypes>(&arena);\n  string* arena_string = Arena::Create<string>(&arena);\n  *arena_string = \"Test content\";\n\n  message1->unsafe_arena_set_allocated_optional_string(arena_string);\n  EXPECT_EQ(arena_string, message1->mutable_optional_string());\n  message2->unsafe_arena_set_allocated_optional_string(\n      message1->unsafe_arena_release_optional_string());\n  EXPECT_EQ(arena_string, message2->mutable_optional_string());\n}\n\nTEST(ArenaTest, UnsafeArenaAddAllocated) {\n  Arena arena;\n  TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena);\n  for (int i = 0; i < 10; i++) {\n    string* arena_string = Arena::Create<string>(&arena);\n    message->mutable_repeated_string()->UnsafeArenaAddAllocated(arena_string);\n    EXPECT_EQ(arena_string, message->mutable_repeated_string(i));\n  }\n}\n\nTEST(ArenaTest, UnsafeArenaRelease) {\n  Arena arena;\n  TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena);\n\n  string* s = new string(\"test string\");\n  message->unsafe_arena_set_allocated_optional_string(s);\n  EXPECT_TRUE(message->has_optional_string());\n  EXPECT_EQ(\"test string\", message->optional_string());\n  s = message->unsafe_arena_release_optional_string();\n  EXPECT_FALSE(message->has_optional_string());\n  delete s;\n\n  s = new string(\"test string\");\n  message->unsafe_arena_set_allocated_oneof_string(s);\n  EXPECT_TRUE(message->has_oneof_string());\n  EXPECT_EQ(\"test string\", message->oneof_string());\n  s = message->unsafe_arena_release_oneof_string();\n  EXPECT_FALSE(message->has_oneof_string());\n  delete s;\n}\n\nTEST(ArenaTest, ArenaOneofReflection) {\n  Arena arena;\n  TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena);\n  const Descriptor* desc = message->GetDescriptor();\n  const Reflection* refl = message->GetReflection();\n\n  const FieldDescriptor* string_field = desc->FindFieldByName(\n      \"oneof_string\");\n  const FieldDescriptor* msg_field = desc->FindFieldByName(\n      \"oneof_nested_message\");\n  const OneofDescriptor* oneof = desc->FindOneofByName(\n      \"oneof_field\");\n\n  refl->SetString(message, string_field, \"Test value\");\n  EXPECT_TRUE(refl->HasOneof(*message, oneof));\n  refl->ClearOneof(message, oneof);\n  EXPECT_FALSE(refl->HasOneof(*message, oneof));\n\n  Message* submsg = refl->MutableMessage(message, msg_field);\n  EXPECT_TRUE(refl->HasOneof(*message, oneof));\n  refl->ClearOneof(message, oneof);\n  EXPECT_FALSE(refl->HasOneof(*message, oneof));\n  refl->MutableMessage(message, msg_field);\n  EXPECT_TRUE(refl->HasOneof(*message, oneof));\n  submsg = refl->ReleaseMessage(message, msg_field);\n  EXPECT_FALSE(refl->HasOneof(*message, oneof));\n  EXPECT_TRUE(submsg->GetArena() == NULL);\n  delete submsg;\n}\n\nnamespace {\nvoid TestSwapRepeatedField(Arena* arena1, Arena* arena2) {\n  // Test \"safe\" (copying) semantics for direct Swap() on RepeatedPtrField\n  // between arenas.\n  RepeatedPtrField<TestAllTypes> field1(arena1);\n  RepeatedPtrField<TestAllTypes> field2(arena2);\n  for (int i = 0; i < 10; i++) {\n    TestAllTypes* t = Arena::CreateMessage<TestAllTypes>(arena1);\n    t->set_optional_string(\"field1\");\n    t->set_optional_int32(i);\n    if (arena1 != NULL) {\n      field1.UnsafeArenaAddAllocated(t);\n    } else {\n      field1.AddAllocated(t);\n    }\n  }\n  for (int i = 0; i < 5; i++) {\n    TestAllTypes* t = Arena::CreateMessage<TestAllTypes>(arena2);\n    t->set_optional_string(\"field2\");\n    t->set_optional_int32(i);\n    if (arena2 != NULL) {\n      field2.UnsafeArenaAddAllocated(t);\n    } else {\n      field2.AddAllocated(t);\n    }\n  }\n  field1.Swap(&field2);\n  EXPECT_EQ(5, field1.size());\n  EXPECT_EQ(10, field2.size());\n  EXPECT_TRUE(string(\"field1\") == field2.Get(0).optional_string());\n  EXPECT_TRUE(string(\"field2\") == field1.Get(0).optional_string());\n  // Ensure that fields retained their original order:\n  for (int i = 0; i < field1.size(); i++) {\n    EXPECT_EQ(i, field1.Get(i).optional_int32());\n  }\n  for (int i = 0; i < field2.size(); i++) {\n    EXPECT_EQ(i, field2.Get(i).optional_int32());\n  }\n}\n}  // namespace\n\nTEST(ArenaTest, SwapRepeatedField) {\n  Arena arena;\n  TestSwapRepeatedField(&arena, &arena);\n}\n\nTEST(ArenaTest, SwapRepeatedFieldWithDifferentArenas) {\n  Arena arena1;\n  Arena arena2;\n  TestSwapRepeatedField(&arena1, &arena2);\n}\n\nTEST(ArenaTest, SwapRepeatedFieldWithNoArenaOnRightHandSide) {\n  Arena arena;\n  TestSwapRepeatedField(&arena, NULL);\n}\n\nTEST(ArenaTest, SwapRepeatedFieldWithNoArenaOnLeftHandSide) {\n  Arena arena;\n  TestSwapRepeatedField(NULL, &arena);\n}\n\nTEST(ArenaTest, ExtensionsOnArena) {\n  Arena arena;\n  // Ensure no leaks.\n  TestAllExtensions* message_ext =\n      Arena::CreateMessage<TestAllExtensions>(&arena);\n  message_ext->SetExtension(\n      protobuf_unittest::optional_int32_extension, 42);\n  message_ext->SetExtension(\n      protobuf_unittest::optional_string_extension, string(\"test\"));\n  message_ext->MutableExtension(\n      protobuf_unittest::optional_nested_message_extension)->set_bb(42);\n}\n\nTEST(ArenaTest, RepeatedFieldOnArena) {\n  // Preallocate an initial arena block to avoid mallocs during hooked region.\n  std::vector<char> arena_block(1024 * 1024);\n  ArenaOptions options;\n  options.initial_block = &arena_block[0];\n  options.initial_block_size = arena_block.size();\n  Arena arena(options);\n\n  {\n    internal::NoHeapChecker no_heap;\n\n    // Fill some repeated fields on the arena to test for leaks. Also verify no\n    // memory allocations.\n    RepeatedField<int32> repeated_int32(&arena);\n    RepeatedPtrField<TestAllTypes> repeated_message(&arena);\n    for (int i = 0; i < 100; i++) {\n      repeated_int32.Add(42);\n      repeated_message.Add()->set_optional_int32(42);\n      EXPECT_EQ(&arena, repeated_message.Get(0).GetArena());\n      const TestAllTypes* msg_in_repeated_field = &repeated_message.Get(0);\n      TestAllTypes* msg = repeated_message.UnsafeArenaReleaseLast();\n      EXPECT_EQ(msg_in_repeated_field, msg);\n    }\n\n    // UnsafeArenaExtractSubrange (i) should not leak and (ii) should return\n    // on-arena pointers.\n    for (int i = 0; i < 10; i++) {\n      repeated_message.Add()->set_optional_int32(42);\n    }\n    TestAllTypes* extracted_messages[5];\n    repeated_message.UnsafeArenaExtractSubrange(0, 5, extracted_messages);\n    EXPECT_EQ(&arena, repeated_message.Get(0).GetArena());\n    EXPECT_EQ(5, repeated_message.size());\n  }\n\n  // Now, outside the scope of the NoHeapChecker, test ExtractSubrange's copying\n  // semantics.\n  {\n    RepeatedPtrField<TestAllTypes> repeated_message(&arena);\n    for (int i = 0; i < 100; i++) {\n      repeated_message.Add()->set_optional_int32(42);\n    }\n\n    TestAllTypes* extracted_messages[5];\n    // ExtractSubrange should copy to the heap.\n    repeated_message.ExtractSubrange(0, 5, extracted_messages);\n    EXPECT_EQ(NULL, extracted_messages[0]->GetArena());\n    // We need to free the heap-allocated messages to prevent a leak.\n    for (int i = 0; i < 5; i++) {\n      delete extracted_messages[i];\n      extracted_messages[i] = NULL;\n    }\n  }\n\n  // Now check that we can create RepeatedFields/RepeatedPtrFields themselves on\n  // the arena. They have the necessary type traits so that they can behave like\n  // messages in this way. This is useful for higher-level generic templated\n  // code that may allocate messages or repeated fields of messages on an arena.\n  {\n    RepeatedPtrField<TestAllTypes>* repeated_ptr_on_arena =\n        Arena::CreateMessage< RepeatedPtrField<TestAllTypes> >(&arena);\n    for (int i = 0; i < 10; i++) {\n      // Add some elements and let the leak-checker ensure that everything is\n      // freed.\n      repeated_ptr_on_arena->Add();\n    }\n\n    RepeatedField<int>* repeated_int_on_arena =\n        Arena::CreateMessage< RepeatedField<int> >(&arena);\n    for (int i = 0; i < 100; i++) {\n      repeated_int_on_arena->Add(i);\n    }\n\n  }\n\n  arena.Reset();\n}\n\n\n#ifndef GOOGLE_PROTOBUF_NO_RTTI\nTEST(ArenaTest, MutableMessageReflection) {\n  Arena arena;\n  TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena);\n  const Reflection* r = message->GetReflection();\n  const Descriptor* d = message->GetDescriptor();\n  const FieldDescriptor* field = d->FindFieldByName(\"optional_nested_message\");\n  TestAllTypes::NestedMessage* submessage =\n      static_cast<TestAllTypes::NestedMessage*>(\n          r->MutableMessage(message, field));\n  TestAllTypes::NestedMessage* submessage_expected =\n      message->mutable_optional_nested_message();\n\n  EXPECT_EQ(submessage_expected, submessage);\n  EXPECT_EQ(&arena, submessage->GetArena());\n\n  const FieldDescriptor* oneof_field = d->FindFieldByName(\"oneof_nested_message\");\n  submessage = static_cast<TestAllTypes::NestedMessage*>(\n      r->MutableMessage(message, oneof_field));\n  submessage_expected = message->mutable_oneof_nested_message();\n\n  EXPECT_EQ(submessage_expected, submessage);\n  EXPECT_EQ(&arena, submessage->GetArena());\n}\n#endif  // !GOOGLE_PROTOBUF_NO_RTTI\n\n\nnamespace {\n\nvoid FillArenaAwareFields(TestAllTypes* message) {\n  string test_string = \"hello world\";\n  message->set_optional_int32(42);\n  message->set_optional_string(test_string);\n  message->set_optional_bytes(test_string);\n  message->mutable_optional_nested_message()->set_bb(42);\n\n  message->set_oneof_uint32(42);\n  message->mutable_oneof_nested_message()->set_bb(42);\n  message->set_oneof_string(test_string);\n  message->set_oneof_bytes(test_string);\n\n  message->add_repeated_int32(42);\n  // No repeated string: not yet arena-aware.\n  message->add_repeated_nested_message()->set_bb(42);\n  message->mutable_optional_lazy_message()->set_bb(42);\n}\n\n}\n\n// Test: no allocations occur on heap while touching all supported field types.\nTEST(ArenaTest, NoHeapAllocationsTest) {\n  // Allocate a large initial block to avoid mallocs during hooked test.\n  std::vector<char> arena_block(128 * 1024);\n  ArenaOptions options;\n  options.initial_block = &arena_block[0];\n  options.initial_block_size = arena_block.size();\n  Arena arena(options);\n\n  {\n\n    TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena);\n    FillArenaAwareFields(message);\n  }\n\n  arena.Reset();\n}\n\n#ifndef GOOGLE_PROTOBUF_NO_RTTI\n// Test construction on an arena via generic MessageLite interface. We should be\n// able to successfully deserialize on the arena without incurring heap\n// allocations, i.e., everything should still be arena-allocation-aware.\nTEST(ArenaTest, MessageLiteOnArena) {\n  std::vector<char> arena_block(128 * 1024);\n  ArenaOptions options;\n  options.initial_block = &arena_block[0];\n  options.initial_block_size = arena_block.size();\n  Arena arena(options);\n  const google::protobuf::MessageLite* prototype = &TestAllTypes::default_instance();\n\n  TestAllTypes initial_message;\n  FillArenaAwareFields(&initial_message);\n  string serialized;\n  initial_message.SerializeToString(&serialized);\n\n  {\n\n    google::protobuf::MessageLite* generic_message = prototype->New(&arena);\n    EXPECT_TRUE(generic_message != NULL);\n    EXPECT_EQ(&arena, generic_message->GetArena());\n    EXPECT_TRUE(generic_message->ParseFromString(serialized));\n    TestAllTypes* deserialized = static_cast<TestAllTypes*>(generic_message);\n    EXPECT_EQ(42, deserialized->optional_int32());\n  }\n\n  arena.Reset();\n}\n#endif  // !GOOGLE_PROTOBUF_NO_RTTI\n\n\n// RepeatedField should support non-POD types, and invoke constructors and\n// destructors appropriately, because it's used this way by lots of other code\n// (even if this was not its original intent).\nTEST(ArenaTest, RepeatedFieldWithNonPODType) {\n  {\n    RepeatedField<string> field_on_heap;\n    for (int i = 0; i < 100; i++) {\n      *field_on_heap.Add() = \"test string long enough to exceed inline buffer\";\n    }\n  }\n  {\n    Arena arena;\n    RepeatedField<string> field_on_arena(&arena);\n    for (int i = 0; i < 100; i++) {\n      *field_on_arena.Add() = \"test string long enough to exceed inline buffer\";\n    }\n  }\n}\n\n// Align n to next multiple of 8\nnamespace {\nuint64 Align8(uint64 n) { return (n + 7) & -8; }\n}  // namespace\n\nTEST(ArenaTest, SpaceAllocated_and_Used) {\n  ArenaOptions options;\n  options.start_block_size = 256;\n  options.max_block_size = 8192;\n  Arena arena_1(options);\n  EXPECT_EQ(0, arena_1.SpaceAllocated());\n  EXPECT_EQ(0, arena_1.SpaceUsed());\n  EXPECT_EQ(0, arena_1.Reset());\n  ::google::protobuf::Arena::CreateArray<char>(&arena_1, 320);\n  // Arena will allocate slightly more than 320 for the block headers.\n  EXPECT_LE(320, arena_1.SpaceAllocated());\n  EXPECT_EQ(Align8(320), arena_1.SpaceUsed());\n  EXPECT_LE(320, arena_1.Reset());\n\n  // Test with initial block.\n  std::vector<char> arena_block(1024);\n  options.initial_block = &arena_block[0];\n  options.initial_block_size = arena_block.size();\n  Arena arena_2(options);\n  EXPECT_EQ(1024, arena_2.SpaceAllocated());\n  EXPECT_EQ(0, arena_2.SpaceUsed());\n  EXPECT_EQ(1024, arena_2.Reset());\n  ::google::protobuf::Arena::CreateArray<char>(&arena_2, 55);\n  EXPECT_EQ(1024, arena_2.SpaceAllocated());\n  EXPECT_EQ(Align8(55), arena_2.SpaceUsed());\n  EXPECT_EQ(1024, arena_2.Reset());\n\n  // Reset options to test doubling policy explicitly.\n  options.initial_block = NULL;\n  options.initial_block_size = 0;\n  Arena arena_3(options);\n  EXPECT_EQ(0, arena_3.SpaceUsed());\n  ::google::protobuf::Arena::CreateArray<char>(&arena_3, 190);\n  EXPECT_EQ(256, arena_3.SpaceAllocated());\n  EXPECT_EQ(Align8(190), arena_3.SpaceUsed());\n  ::google::protobuf::Arena::CreateArray<char>(&arena_3, 70);\n  EXPECT_EQ(256 + 512, arena_3.SpaceAllocated());\n  EXPECT_EQ(Align8(190) + Align8(70), arena_3.SpaceUsed());\n  EXPECT_EQ(256 + 512, arena_3.Reset());\n}\n\nTEST(ArenaTest, Alignment) {\n  ::google::protobuf::Arena arena;\n  for (int i = 0; i < 200; i++) {\n    void* p = ::google::protobuf::Arena::CreateArray<char>(&arena, i);\n    GOOGLE_CHECK_EQ(reinterpret_cast<uintptr_t>(p) % 8, 0) << i << \": \" << p;\n  }\n}\n\nTEST(ArenaTest, GetArenaShouldReturnTheArenaForArenaAllocatedMessages) {\n  ::google::protobuf::Arena arena;\n  ArenaMessage* message = Arena::CreateMessage<ArenaMessage>(&arena);\n  const ArenaMessage* const_pointer_to_message = message;\n  EXPECT_EQ(&arena, Arena::GetArena(message));\n  EXPECT_EQ(&arena, Arena::GetArena(const_pointer_to_message));\n}\n\nTEST(ArenaTest, GetArenaShouldReturnNullForNonArenaAllocatedMessages) {\n  ArenaMessage message;\n  const ArenaMessage* const_pointer_to_message = &message;\n  EXPECT_EQ(NULL, Arena::GetArena(&message));\n  EXPECT_EQ(NULL, Arena::GetArena(const_pointer_to_message));\n}\n\nTEST(ArenaTest, UnsafeSetAllocatedOnArena) {\n  ::google::protobuf::Arena arena;\n  TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena);\n  EXPECT_FALSE(message->has_optional_string());\n\n  string owned_string = \"test with long enough content to heap-allocate\";\n  message->unsafe_arena_set_allocated_optional_string(&owned_string);\n  EXPECT_TRUE(message->has_optional_string());\n\n  message->unsafe_arena_set_allocated_optional_string(NULL);\n  EXPECT_FALSE(message->has_optional_string());\n}\n\n// A helper utility class to only contain static hook functions, some\n// counters to be used to verify the counters have been called and a cookie\n// value to be verified.\nclass ArenaHooksTestUtil {\n public:\n  static void* on_init(::google::protobuf::Arena* arena) {\n    ++num_init;\n    int* cookie = new int(kCookieValue);\n    return static_cast<void*>(cookie);\n  }\n\n  static void on_allocation(const std::type_info* /*unused*/, uint64 alloc_size,\n                            void* cookie) {\n    ++num_allocations;\n    int cookie_value = *static_cast<int*>(cookie);\n    EXPECT_EQ(kCookieValue, cookie_value);\n  }\n\n  static void on_reset(::google::protobuf::Arena* arena, void* cookie,\n                       uint64 space_used) {\n    ++num_reset;\n    int cookie_value = *static_cast<int*>(cookie);\n    EXPECT_EQ(kCookieValue, cookie_value);\n  }\n\n  static void on_destruction(::google::protobuf::Arena* arena, void* cookie,\n                             uint64 space_used) {\n    ++num_destruct;\n    int cookie_value = *static_cast<int*>(cookie);\n    EXPECT_EQ(kCookieValue, cookie_value);\n    delete static_cast<int*>(cookie);\n  }\n\n  static const int kCookieValue = 999;\n  static uint32 num_init;\n  static uint32 num_allocations;\n  static uint32 num_reset;\n  static uint32 num_destruct;\n};\nuint32 ArenaHooksTestUtil::num_init = 0;\nuint32 ArenaHooksTestUtil::num_allocations = 0;\nuint32 ArenaHooksTestUtil::num_reset = 0;\nuint32 ArenaHooksTestUtil::num_destruct = 0;\nconst int ArenaHooksTestUtil::kCookieValue;\n\n// Test the hooks are correctly called and that the cookie is passed.\nTEST(ArenaTest, ArenaHooksSanity) {\n  ::google::protobuf::ArenaOptions options;\n  options.on_arena_init = ArenaHooksTestUtil::on_init;\n  options.on_arena_allocation = ArenaHooksTestUtil::on_allocation;\n  options.on_arena_reset = ArenaHooksTestUtil::on_reset;\n  options.on_arena_destruction = ArenaHooksTestUtil::on_destruction;\n\n  // Scope for defining the arena\n  {\n    ::google::protobuf::Arena arena(options);\n    EXPECT_EQ(1, ArenaHooksTestUtil::num_init);\n    EXPECT_EQ(0, ArenaHooksTestUtil::num_allocations);\n    ::google::protobuf::Arena::Create<uint64>(&arena);\n    if (google::protobuf::internal::has_trivial_destructor<uint64>::value) {\n      EXPECT_EQ(1, ArenaHooksTestUtil::num_allocations);\n    } else {\n      EXPECT_EQ(2, ArenaHooksTestUtil::num_allocations);\n    }\n    arena.Reset();\n    arena.Reset();\n    EXPECT_EQ(2, ArenaHooksTestUtil::num_reset);\n  }\n  EXPECT_EQ(3, ArenaHooksTestUtil::num_reset);\n  EXPECT_EQ(1, ArenaHooksTestUtil::num_destruct);\n}\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/arenastring.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// The ArenaString implementation is not included in the open-source release. Do\n// not include this file in the distribution.\n\n#include <google/protobuf/arenastring.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\n\nvoid ArenaStringPtr::AssignWithDefault(const ::std::string* default_value,\n                                       ArenaStringPtr value) {\n  const ::std::string* me = *UnsafeRawStringPointer();\n  const ::std::string* other = *value.UnsafeRawStringPointer();\n  // If the pointers are the same then do nothing.\n  if (me != other) {\n    SetNoArena(default_value, value.GetNoArena(default_value));\n  }\n}\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/arenastring.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_ARENASTRING_H__\n#define GOOGLE_PROTOBUF_ARENASTRING_H__\n\n#include <string>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/fastmem.h>\n#include <google/protobuf/arena.h>\n#include <google/protobuf/generated_message_util.h>\n\n\n\n// This is the implementation of arena string fields written for the open-source\n// release. The ArenaStringPtr struct below is an internal implementation class\n// and *should not be used* by user code. It is used to collect string\n// operations together into one place and abstract away the underlying\n// string-field pointer representation, so that (for example) an alternate\n// implementation that knew more about ::std::string's internals could integrate more\n// closely with the arena allocator.\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\nstruct LIBPROTOBUF_EXPORT ArenaStringPtr {\n  inline void Set(const ::std::string* default_value,\n                  const ::std::string& value, ::google::protobuf::Arena* arena) {\n    if (ptr_ == default_value) {\n      CreateInstance(arena, &value);\n    } else {\n      *ptr_ = value;\n    }\n  }\n\n  // Basic accessors.\n  inline const ::std::string& Get(const ::std::string* /* default_value */) const {\n    return *ptr_;\n  }\n\n  inline ::std::string* Mutable(const ::std::string* default_value,\n                           ::google::protobuf::Arena* arena) {\n    if (ptr_ == default_value) {\n      CreateInstance(arena, default_value);\n    }\n    return ptr_;\n  }\n\n  // Release returns a ::std::string* instance that is heap-allocated and is not\n  // Own()'d by any arena. If the field was not set, it returns NULL. The caller\n  // retains ownership. Clears this field back to NULL state. Used to implement\n  // release_<field>() methods on generated classes.\n  inline ::std::string* Release(const ::std::string* default_value,\n                           ::google::protobuf::Arena* arena) {\n    if (ptr_ == default_value) {\n      return NULL;\n    }\n    ::std::string* released = NULL;\n    if (arena != NULL) {\n      // ptr_ is owned by the arena -- we need to return a copy.\n      released = new ::std::string(*ptr_);\n    } else {\n      released = ptr_;\n    }\n    ptr_ = const_cast< ::std::string* >(default_value);\n    return released;\n  }\n\n  // UnsafeArenaRelease returns a ::std::string*, but it may be arena-owned (i.e.\n  // have its destructor already registered) if arena != NULL. If the field was\n  // not set, this returns NULL. This method clears this field back to NULL\n  // state. Used to implement unsafe_arena_release_<field>() methods on\n  // generated classes.\n  inline ::std::string* UnsafeArenaRelease(const ::std::string* default_value,\n                                      ::google::protobuf::Arena* /* arena */) {\n    if (ptr_ == default_value) {\n      return NULL;\n    }\n    ::std::string* released = ptr_;\n    ptr_ = const_cast< ::std::string* >(default_value);\n    return released;\n  }\n\n  // Takes a string that is heap-allocated, and takes ownership. The string's\n  // destructor is registered with the arena. Used to implement\n  // set_allocated_<field> in generated classes.\n  inline void SetAllocated(const ::std::string* default_value,\n                           ::std::string* value, ::google::protobuf::Arena* arena) {\n    if (arena == NULL && ptr_ != default_value) {\n      Destroy(default_value, arena);\n    }\n    if (value != NULL) {\n      ptr_ = value;\n      if (arena != NULL) {\n        arena->Own(value);\n      }\n    } else {\n      ptr_ = const_cast< ::std::string* >(default_value);\n    }\n  }\n\n  // Takes a string that has lifetime equal to the arena's lifetime. The arena\n  // must be non-null. It is safe only to pass this method a value returned by\n  // UnsafeArenaRelease() on another field of a message in the same arena. Used\n  // to implement unsafe_arena_set_allocated_<field> in generated classes.\n  inline void UnsafeArenaSetAllocated(const ::std::string* default_value,\n                                      ::std::string* value,\n                                      ::google::protobuf::Arena* /* arena */) {\n    if (value != NULL) {\n      ptr_ = value;\n    } else {\n      ptr_ = const_cast< ::std::string* >(default_value);\n    }\n  }\n\n  // Swaps internal pointers. Arena-safety semantics: this is guarded by the\n  // logic in Swap()/UnsafeArenaSwap() at the message level, so this method is\n  // 'unsafe' if called directly.\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE void Swap(ArenaStringPtr* other) {\n    std::swap(ptr_, other->ptr_);\n  }\n\n  // Frees storage (if not on an arena) and sets field to default value.\n  inline void Destroy(const ::std::string* default_value,\n                      ::google::protobuf::Arena* arena) {\n    if (arena == NULL && ptr_ != default_value) {\n      delete ptr_;\n    }\n    ptr_ = const_cast< ::std::string* >(default_value);\n  }\n\n  // Clears content, but keeps allocated string if arena != NULL, to avoid the\n  // overhead of heap operations. After this returns, the content (as seen by\n  // the user) will always be the empty string. Assumes that |default_value|\n  // is an empty string.\n  inline void ClearToEmpty(const ::std::string* default_value,\n                           ::google::protobuf::Arena* /* arena */) {\n    if (ptr_ == default_value) {\n      // Already set to default (which is empty) -- do nothing.\n    } else {\n      ptr_->clear();\n    }\n  }\n\n  // Clears content, but keeps allocated string if arena != NULL, to avoid the\n  // overhead of heap operations. After this returns, the content (as seen by\n  // the user) will always be equal to |default_value|.\n  inline void ClearToDefault(const ::std::string* default_value,\n                             ::google::protobuf::Arena* /* arena */) {\n    if (ptr_ == default_value) {\n      // Already set to default -- do nothing.\n    } else {\n      // Have another allocated string -- rather than throwing this away and\n      // resetting ptr_ to the canonical default string instance, we just reuse\n      // this instance.\n      *ptr_ = *default_value;\n    }\n  }\n\n  // Called from generated code / reflection runtime only. Resets value to point\n  // to a default string pointer, with the semantics that this ArenaStringPtr\n  // does not own the pointed-to memory. Disregards initial value of ptr_ (so\n  // this is the *ONLY* safe method to call after construction or when\n  // reinitializing after becoming the active field in a oneof union).\n  inline void UnsafeSetDefault(const ::std::string* default_value) {\n    // Casting away 'const' is safe here: accessors ensure that ptr_ is only\n    // returned as a const if it is equal to default_value.\n    ptr_ = const_cast< ::std::string* >(default_value);\n  }\n\n  // The 'NoArena' variants of methods below assume arena == NULL and are\n  // optimized to provide very little overhead relative to a raw string pointer\n  // (while still being in-memory compatible with other code that assumes\n  // ArenaStringPtr). Note the invariant that a class instance that has only\n  // ever been mutated by NoArena methods must *only* be in the String state\n  // (i.e., tag bits are not used), *NEVER* ArenaString. This allows all\n  // tagged-pointer manipulations to be avoided.\n  inline void SetNoArena(const ::std::string* default_value,\n                         const ::std::string& value) {\n    if (ptr_ == default_value) {\n      CreateInstanceNoArena(&value);\n    } else {\n      *ptr_ = value;\n    }\n  }\n\n  void AssignWithDefault(const ::std::string* default_value, ArenaStringPtr value);\n\n  inline const ::std::string& GetNoArena(const ::std::string* /* default_value */) const {\n    return *ptr_;\n  }\n\n  inline ::std::string* MutableNoArena(const ::std::string* default_value) {\n    if (ptr_ == default_value) {\n      CreateInstanceNoArena(default_value);\n    }\n    return ptr_;\n  }\n\n  inline ::std::string* ReleaseNoArena(const ::std::string* default_value) {\n    if (ptr_ == default_value) {\n      return NULL;\n    } else {\n      ::std::string* released = ptr_;\n      ptr_ = const_cast< ::std::string* >(default_value);\n      return released;\n    }\n  }\n\n  inline void SetAllocatedNoArena(const ::std::string* default_value,\n                                  ::std::string* value) {\n    if (ptr_ != default_value) {\n      delete ptr_;\n    }\n    if (value != NULL) {\n      ptr_ = value;\n    } else {\n      ptr_ = const_cast< ::std::string* >(default_value);\n    }\n  }\n\n  inline void DestroyNoArena(const ::std::string* default_value) {\n    if (ptr_ != default_value) {\n      delete ptr_;\n    }\n    ptr_ = NULL;\n  }\n\n  inline void ClearToEmptyNoArena(const ::std::string* default_value) {\n    if (ptr_ == default_value) {\n      // Nothing: already equal to default (which is the empty string).\n    } else {\n      ptr_->clear();\n    }\n  }\n\n  inline void ClearToDefaultNoArena(const ::std::string* default_value) {\n    if (ptr_ == default_value) {\n      // Nothing: already set to default.\n    } else {\n      // Reuse existing allocated instance.\n      *ptr_ = *default_value;\n    }\n  }\n\n  // Internal accessor used only at parse time to provide direct access to the\n  // raw pointer from the shared parse routine (in the non-arenas case). The\n  // parse routine does the string allocation in order to save code size in the\n  // generated parsing code.\n  inline ::std::string** UnsafeRawStringPointer() {\n    return &ptr_;\n  }\n\n private:\n  ::std::string* ptr_;\n\n  GOOGLE_ATTRIBUTE_NOINLINE void CreateInstance(::google::protobuf::Arena* arena,\n                                         const ::std::string* initial_value) {\n    // Assumes ptr_ is not NULL.\n    if (initial_value != NULL) {\n      ptr_ = new ::std::string(*initial_value);\n    } else {\n      ptr_ = new ::std::string();\n    }\n    if (arena != NULL) {\n      arena->Own(ptr_);\n    }\n  }\n  GOOGLE_ATTRIBUTE_NOINLINE void CreateInstanceNoArena(const ::std::string* initial_value) {\n    if (initial_value != NULL) {\n      ptr_ = new ::std::string(*initial_value);\n    } else {\n      ptr_ = new ::std::string();\n    }\n  }\n};\n\n}  // namespace internal\n}  // namespace protobuf\n\n\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_ARENASTRING_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/arenastring_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Based on mvels@'s frankenstring.\n\n#include <google/protobuf/arenastring.h>\n\n#include <string>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <cstdlib>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nusing google::protobuf::internal::ArenaString;\nusing google::protobuf::internal::ArenaStringPtr;\n\nnamespace protobuf {\n\n\nstatic string WrapString(const char* value) {\n  return value;\n}\n\n// Test ArenaStringPtr with arena == NULL.\nTEST(ArenaStringPtrTest, ArenaStringPtrOnHeap) {\n  ArenaStringPtr field;\n  ::std::string default_value = \"default\";\n  field.UnsafeSetDefault(&default_value);\n  EXPECT_EQ(string(\"default\"), field.Get(&default_value));\n  field.Set(&default_value, WrapString(\"Test short\"), NULL);\n  EXPECT_EQ(string(\"Test short\"), field.Get(&default_value));\n  field.Set(&default_value, WrapString(\"Test long long long long value\"), NULL);\n  EXPECT_EQ(string(\"Test long long long long value\"), field.Get(&default_value));\n  field.Set(&default_value, string(\"\"), NULL);\n  field.Destroy(&default_value, NULL);\n\n  ArenaStringPtr field2;\n  field2.UnsafeSetDefault(&default_value);\n  ::std::string* mut = field2.Mutable(&default_value, NULL);\n  EXPECT_EQ(mut, field2.Mutable(&default_value, NULL));\n  EXPECT_EQ(mut, &field2.Get(&default_value));\n  EXPECT_NE(&default_value, mut);\n  EXPECT_EQ(string(\"default\"), *mut);\n  *mut = \"Test long long long long value\";  // ensure string allocates storage\n  EXPECT_EQ(string(\"Test long long long long value\"), field2.Get(&default_value));\n  field2.Destroy(&default_value, NULL);\n}\n\nTEST(ArenaStringPtrTest, ArenaStringPtrOnArena) {\n  google::protobuf::Arena arena;\n  ArenaStringPtr field;\n  ::std::string default_value = \"default\";\n  field.UnsafeSetDefault(&default_value);\n  EXPECT_EQ(string(\"default\"), field.Get(&default_value));\n  field.Set(&default_value, WrapString(\"Test short\"), &arena);\n  EXPECT_EQ(string(\"Test short\"), field.Get(&default_value));\n  field.Set(&default_value, WrapString(\"Test long long long long value\"), &arena);\n  EXPECT_EQ(string(\"Test long long long long value\"),\n            field.Get(&default_value));\n  field.Set(&default_value, string(\"\"), &arena);\n  field.Destroy(&default_value, &arena);\n\n  ArenaStringPtr field2;\n  field2.UnsafeSetDefault(&default_value);\n  ::std::string* mut = field2.Mutable(&default_value, &arena);\n  EXPECT_EQ(mut, field2.Mutable(&default_value, &arena));\n  EXPECT_EQ(mut, &field2.Get(&default_value));\n  EXPECT_NE(&default_value, mut);\n  EXPECT_EQ(string(\"default\"), *mut);\n  *mut = \"Test long long long long value\";  // ensure string allocates storage\n  EXPECT_EQ(string(\"Test long long long long value\"),\n            field2.Get(&default_value));\n  field2.Destroy(&default_value, &arena);\n}\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/code_generator.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/code_generator.h>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\n\nCodeGenerator::~CodeGenerator() {}\nGeneratorContext::~GeneratorContext() {}\n\nio::ZeroCopyOutputStream*\nGeneratorContext::OpenForAppend(const string& filename) {\n  return NULL;\n}\n\nio::ZeroCopyOutputStream* GeneratorContext::OpenForInsert(\n    const string& filename, const string& insertion_point) {\n  GOOGLE_LOG(FATAL) << \"This GeneratorContext does not support insertion.\";\n  return NULL;  // make compiler happy\n}\n\nvoid GeneratorContext::ListParsedFiles(\n    vector<const FileDescriptor*>* output) {\n  GOOGLE_LOG(FATAL) << \"This GeneratorContext does not support ListParsedFiles\";\n}\n\n// Parses a set of comma-delimited name/value pairs.\nvoid ParseGeneratorParameter(const string& text,\n                             vector<pair<string, string> >* output) {\n  vector<string> parts = Split(text, \",\", true);\n\n  for (int i = 0; i < parts.size(); i++) {\n    string::size_type equals_pos = parts[i].find_first_of('=');\n    pair<string, string> value;\n    if (equals_pos == string::npos) {\n      value.first = parts[i];\n      value.second = \"\";\n    } else {\n      value.first = parts[i].substr(0, equals_pos);\n      value.second = parts[i].substr(equals_pos + 1);\n    }\n    output->push_back(value);\n  }\n}\n\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/code_generator.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Defines the abstract interface implemented by each of the language-specific\n// code generators.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CODE_GENERATOR_H__\n#define GOOGLE_PROTOBUF_COMPILER_CODE_GENERATOR_H__\n\n#include <google/protobuf/stubs/common.h>\n#include <string>\n#include <vector>\n#include <utility>\n\nnamespace google {\nnamespace protobuf {\n\nnamespace io { class ZeroCopyOutputStream; }\nclass FileDescriptor;\n\nnamespace compiler {\n\n// Defined in this file.\nclass CodeGenerator;\nclass GeneratorContext;\n\n// The abstract interface to a class which generates code implementing a\n// particular proto file in a particular language.  A number of these may\n// be registered with CommandLineInterface to support various languages.\nclass LIBPROTOC_EXPORT CodeGenerator {\n public:\n  inline CodeGenerator() {}\n  virtual ~CodeGenerator();\n\n  // Generates code for the given proto file, generating one or more files in\n  // the given output directory.\n  //\n  // A parameter to be passed to the generator can be specified on the\n  // command line.  This is intended to be used by Java and similar languages\n  // to specify which specific class from the proto file is to be generated,\n  // though it could have other uses as well.  It is empty if no parameter was\n  // given.\n  //\n  // Returns true if successful.  Otherwise, sets *error to a description of\n  // the problem (e.g. \"invalid parameter\") and returns false.\n  virtual bool Generate(const FileDescriptor* file,\n                        const string& parameter,\n                        GeneratorContext* generator_context,\n                        string* error) const = 0;\n\n  // Generates code for all given proto files, generating one or more files in\n  // the given output directory.\n  //\n  // This method should be called instead of |Generate()| when\n  // |HasGenerateAll()| returns |true|. It is used to emulate legacy semantics\n  // when more than one `.proto` file is specified on one compiler invocation.\n  //\n  // WARNING: Please do not use unless legacy semantics force the code generator\n  // to produce a single output file for all input files, or otherwise require\n  // an examination of all input files first. The canonical code generator\n  // design produces one output file per input .proto file, and we do not wish\n  // to encourage alternate designs.\n  //\n  // A parameter is given as passed on the command line, as in |Generate()|\n  // above.\n  //\n  // Returns true if successful.  Otherwise, sets *error to a description of\n  // the problem (e.g. \"invalid parameter\") and returns false.\n  virtual bool GenerateAll(const vector<const FileDescriptor*>& files,\n                           const string& parameter,\n                           GeneratorContext* generator_context,\n                           string* error) const {\n    *error = \"Unimplemented GenerateAll() method.\";\n    return false;\n  }\n\n  // Returns true if the code generator expects to receive all FileDescriptors\n  // at once (via |GenerateAll()|), rather than one at a time (via\n  // |Generate()|). This is required to implement legacy semantics.\n  virtual bool HasGenerateAll() const { return false; }\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CodeGenerator);\n};\n\n// CodeGenerators generate one or more files in a given directory.  This\n// abstract interface represents the directory to which the CodeGenerator is\n// to write and other information about the context in which the Generator\n// runs.\nclass LIBPROTOC_EXPORT GeneratorContext {\n public:\n  inline GeneratorContext() {}\n  virtual ~GeneratorContext();\n\n  // Opens the given file, truncating it if it exists, and returns a\n  // ZeroCopyOutputStream that writes to the file.  The caller takes ownership\n  // of the returned object.  This method never fails (a dummy stream will be\n  // returned instead).\n  //\n  // The filename given should be relative to the root of the source tree.\n  // E.g. the C++ generator, when generating code for \"foo/bar.proto\", will\n  // generate the files \"foo/bar.pb.h\" and \"foo/bar.pb.cc\"; note that\n  // \"foo/\" is included in these filenames.  The filename is not allowed to\n  // contain \".\" or \"..\" components.\n  virtual io::ZeroCopyOutputStream* Open(const string& filename) = 0;\n\n  // Similar to Open() but the output will be appended to the file if exists\n  virtual io::ZeroCopyOutputStream* OpenForAppend(const string& filename);\n\n  // Creates a ZeroCopyOutputStream which will insert code into the given file\n  // at the given insertion point.  See plugin.proto (plugin.pb.h) for more\n  // information on insertion points.  The default implementation\n  // assert-fails -- it exists only for backwards-compatibility.\n  //\n  // WARNING:  This feature is currently EXPERIMENTAL and is subject to change.\n  virtual io::ZeroCopyOutputStream* OpenForInsert(\n      const string& filename, const string& insertion_point);\n\n  // Returns a vector of FileDescriptors for all the files being compiled\n  // in this run.  Useful for languages, such as Go, that treat files\n  // differently when compiled as a set rather than individually.\n  virtual void ListParsedFiles(vector<const FileDescriptor*>* output);\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratorContext);\n};\n\n// The type GeneratorContext was once called OutputDirectory. This typedef\n// provides backward compatibility.\ntypedef GeneratorContext OutputDirectory;\n\n// Several code generators treat the parameter argument as holding a\n// list of options separated by commas.  This helper function parses\n// a set of comma-delimited name/value pairs: e.g.,\n//   \"foo=bar,baz,qux=corge\"\n// parses to the pairs:\n//   (\"foo\", \"bar\"), (\"baz\", \"\"), (\"qux\", \"corge\")\nextern void ParseGeneratorParameter(const string&,\n            vector<pair<string, string> >*);\n\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_CODE_GENERATOR_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/command_line_interface.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/command_line_interface.h>\n#include <google/protobuf/stubs/platform_macros.h>\n\n#include <stdio.h>\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n#ifdef _MSC_VER\n#include <io.h>\n#include <direct.h>\n#else\n#include <unistd.h>\n#endif\n#include <errno.h>\n#include <fstream>\n#include <iostream>\n#include <ctype.h>\n\n#include <limits.h> //For PATH_MAX\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#ifdef __APPLE__\n#include <mach-o/dyld.h>\n#endif\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/stringprintf.h>\n#include <google/protobuf/compiler/importer.h>\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/plugin.pb.h>\n#include <google/protobuf/compiler/subprocess.h>\n#include <google/protobuf/compiler/zip_writer.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/text_format.h>\n#include <google/protobuf/dynamic_message.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n#include <google/protobuf/stubs/map_util.h>\n#include <google/protobuf/stubs/stl_util.h>\n\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\n\n#if defined(_WIN32)\n#define mkdir(name, mode) mkdir(name)\n#ifndef W_OK\n#define W_OK 02  // not defined by MSVC for whatever reason\n#endif\n#ifndef F_OK\n#define F_OK 00  // not defined by MSVC for whatever reason\n#endif\n#ifndef STDIN_FILENO\n#define STDIN_FILENO 0\n#endif\n#ifndef STDOUT_FILENO\n#define STDOUT_FILENO 1\n#endif\n#endif\n\n#ifndef O_BINARY\n#ifdef _O_BINARY\n#define O_BINARY _O_BINARY\n#else\n#define O_BINARY 0     // If this isn't defined, the platform doesn't need it.\n#endif\n#endif\n\nnamespace {\n#if defined(_WIN32) && !defined(__CYGWIN__)\nstatic const char* kPathSeparator = \";\";\n#else\nstatic const char* kPathSeparator = \":\";\n#endif\n\n// Returns true if the text looks like a Windows-style absolute path, starting\n// with a drive letter.  Example:  \"C:\\foo\".  TODO(kenton):  Share this with\n// copy in importer.cc?\nstatic bool IsWindowsAbsolutePath(const string& text) {\n#if defined(_WIN32) || defined(__CYGWIN__)\n  return text.size() >= 3 && text[1] == ':' &&\n         isalpha(text[0]) &&\n         (text[2] == '/' || text[2] == '\\\\') &&\n         text.find_last_of(':') == 1;\n#else\n  return false;\n#endif\n}\n\nvoid SetFdToTextMode(int fd) {\n#ifdef _WIN32\n  if (_setmode(fd, _O_TEXT) == -1) {\n    // This should never happen, I think.\n    GOOGLE_LOG(WARNING) << \"_setmode(\" << fd << \", _O_TEXT): \" << strerror(errno);\n  }\n#endif\n  // (Text and binary are the same on non-Windows platforms.)\n}\n\nvoid SetFdToBinaryMode(int fd) {\n#ifdef _WIN32\n  if (_setmode(fd, _O_BINARY) == -1) {\n    // This should never happen, I think.\n    GOOGLE_LOG(WARNING) << \"_setmode(\" << fd << \", _O_BINARY): \" << strerror(errno);\n  }\n#endif\n  // (Text and binary are the same on non-Windows platforms.)\n}\n\nvoid AddTrailingSlash(string* path) {\n  if (!path->empty() && path->at(path->size() - 1) != '/') {\n    path->push_back('/');\n  }\n}\n\nbool VerifyDirectoryExists(const string& path) {\n  if (path.empty()) return true;\n\n  if (access(path.c_str(), F_OK) == -1) {\n    std::cerr << path << \": \" << strerror(errno) << std::endl;\n    return false;\n  } else {\n    return true;\n  }\n}\n\n// Try to create the parent directory of the given file, creating the parent's\n// parent if necessary, and so on.  The full file name is actually\n// (prefix + filename), but we assume |prefix| already exists and only create\n// directories listed in |filename|.\nbool TryCreateParentDirectory(const string& prefix, const string& filename) {\n  // Recursively create parent directories to the output file.\n  vector<string> parts = Split(filename, \"/\", true);\n  string path_so_far = prefix;\n  for (int i = 0; i < parts.size() - 1; i++) {\n    path_so_far += parts[i];\n    if (mkdir(path_so_far.c_str(), 0777) != 0) {\n      if (errno != EEXIST) {\n        std::cerr << filename << \": while trying to create directory \"\n                  << path_so_far << \": \" << strerror(errno) << std::endl;\n        return false;\n      }\n    }\n    path_so_far += '/';\n  }\n\n  return true;\n}\n\n// Get the absolute path of this protoc binary.\nbool GetProtocAbsolutePath(string* path) {\n#ifdef _WIN32\n  char buffer[MAX_PATH];\n  int len = GetModuleFileNameA(NULL, buffer, MAX_PATH);\n#elif __APPLE__\n  char buffer[PATH_MAX];\n  int len = 0;\n\n  char dirtybuffer[PATH_MAX];\n  uint32_t size = sizeof(dirtybuffer);\n  if (_NSGetExecutablePath(dirtybuffer, &size) == 0) {\n    realpath(dirtybuffer, buffer);\n    len = strlen(buffer);\n  }\n#else\n  char buffer[PATH_MAX];\n  int len = readlink(\"/proc/self/exe\", buffer, PATH_MAX);\n#endif\n  if (len > 0) {\n    path->assign(buffer, len);\n    return true;\n  } else {\n    return false;\n  }\n}\n\n// Whether a path is where google/protobuf/descriptor.proto and other well-known\n// type protos are installed.\nbool IsInstalledProtoPath(const string& path) {\n  // Checking the descriptor.proto file should be good enough.\n  string file_path = path + \"/google/protobuf/descriptor.proto\";\n  return access(file_path.c_str(), F_OK) != -1;\n}\n\n// Add the paths where google/protobuf/descritor.proto and other well-known\n// type protos are installed.\nvoid AddDefaultProtoPaths(vector<pair<string, string> >* paths) {\n  // TODO(xiaofeng): The code currently only checks relative paths of where\n  // the protoc binary is installed. We probably should make it handle more\n  // cases than that.\n  string path;\n  if (!GetProtocAbsolutePath(&path)) {\n    return;\n  }\n  // Strip the binary name.\n  size_t pos = path.find_last_of(\"/\\\\\");\n  if (pos == string::npos || pos == 0) {\n    return;\n  }\n  path = path.substr(0, pos);\n  // Check the binary's directory.\n  if (IsInstalledProtoPath(path)) {\n    paths->push_back(pair<string, string>(\"\", path));\n    return;\n  }\n  // Check if there is an include subdirectory.\n  if (IsInstalledProtoPath(path + \"/include\")) {\n    paths->push_back(pair<string, string>(\"\", path + \"/include\"));\n    return;\n  }\n  // Check if the upper level directory has an \"include\" subdirectory.\n  pos = path.find_last_of(\"/\\\\\");\n  if (pos == string::npos || pos == 0) {\n    return;\n  }\n  path = path.substr(0, pos);\n  if (IsInstalledProtoPath(path + \"/include\")) {\n    paths->push_back(pair<string, string>(\"\", path + \"/include\"));\n    return;\n  }\n}\n}  // namespace\n\n// A MultiFileErrorCollector that prints errors to stderr.\nclass CommandLineInterface::ErrorPrinter : public MultiFileErrorCollector,\n                                           public io::ErrorCollector {\n public:\n  ErrorPrinter(ErrorFormat format, DiskSourceTree *tree = NULL)\n    : format_(format), tree_(tree) {}\n  ~ErrorPrinter() {}\n\n  // implements MultiFileErrorCollector ------------------------------\n  void AddError(const string& filename, int line, int column,\n                const string& message) {\n    AddErrorOrWarning(filename, line, column, message, \"error\", std::cerr);\n  }\n\n  void AddWarning(const string& filename, int line, int column,\n                  const string& message) {\n    AddErrorOrWarning(filename, line, column, message, \"warning\", std::clog);\n  }\n\n  // implements io::ErrorCollector -----------------------------------\n  void AddError(int line, int column, const string& message) {\n    AddError(\"input\", line, column, message);\n  }\n\n  void AddWarning(int line, int column, const string& message) {\n    AddErrorOrWarning(\"input\", line, column, message, \"warning\", std::clog);\n  }\n\n private:\n  void AddErrorOrWarning(\n      const string& filename, int line, int column,\n      const string& message, const string& type, ostream& out) {\n    // Print full path when running under MSVS\n    string dfile;\n    if (format_ == CommandLineInterface::ERROR_FORMAT_MSVS &&\n        tree_ != NULL &&\n        tree_->VirtualFileToDiskFile(filename, &dfile)) {\n      out << dfile;\n    } else {\n      out << filename;\n    }\n\n    // Users typically expect 1-based line/column numbers, so we add 1\n    // to each here.\n    if (line != -1) {\n      // Allow for both GCC- and Visual-Studio-compatible output.\n      switch (format_) {\n        case CommandLineInterface::ERROR_FORMAT_GCC:\n          out << \":\" << (line + 1) << \":\" << (column + 1);\n          break;\n        case CommandLineInterface::ERROR_FORMAT_MSVS:\n          out << \"(\" << (line + 1) << \") : \"\n              << type << \" in column=\" << (column + 1);\n          break;\n      }\n    }\n\n    if (type == \"warning\") {\n      out << \": warning: \" << message << std::endl;\n    } else {\n      out << \": \" << message << std::endl;\n    }\n  }\n\n  const ErrorFormat format_;\n  DiskSourceTree *tree_;\n};\n\n// -------------------------------------------------------------------\n\n// A GeneratorContext implementation that buffers files in memory, then dumps\n// them all to disk on demand.\nclass CommandLineInterface::GeneratorContextImpl : public GeneratorContext {\n public:\n  GeneratorContextImpl(const vector<const FileDescriptor*>& parsed_files);\n  ~GeneratorContextImpl();\n\n  // Write all files in the directory to disk at the given output location,\n  // which must end in a '/'.\n  bool WriteAllToDisk(const string& prefix);\n\n  // Write the contents of this directory to a ZIP-format archive with the\n  // given name.\n  bool WriteAllToZip(const string& filename);\n\n  // Add a boilerplate META-INF/MANIFEST.MF file as required by the Java JAR\n  // format, unless one has already been written.\n  void AddJarManifest();\n\n  // Get name of all output files.\n  void GetOutputFilenames(vector<string>* output_filenames);\n\n  // implements GeneratorContext --------------------------------------\n  io::ZeroCopyOutputStream* Open(const string& filename);\n  io::ZeroCopyOutputStream* OpenForAppend(const string& filename);\n  io::ZeroCopyOutputStream* OpenForInsert(\n      const string& filename, const string& insertion_point);\n  void ListParsedFiles(vector<const FileDescriptor*>* output) {\n    *output = parsed_files_;\n  }\n\n private:\n  friend class MemoryOutputStream;\n\n  // map instead of hash_map so that files are written in order (good when\n  // writing zips).\n  map<string, string*> files_;\n  const vector<const FileDescriptor*>& parsed_files_;\n  bool had_error_;\n};\n\nclass CommandLineInterface::MemoryOutputStream\n    : public io::ZeroCopyOutputStream {\n public:\n  MemoryOutputStream(GeneratorContextImpl* directory, const string& filename,\n                     bool append_mode);\n  MemoryOutputStream(GeneratorContextImpl* directory, const string& filename,\n                     const string& insertion_point);\n  virtual ~MemoryOutputStream();\n\n  // implements ZeroCopyOutputStream ---------------------------------\n  virtual bool Next(void** data, int* size) { return inner_->Next(data, size); }\n  virtual void BackUp(int count)            {        inner_->BackUp(count);    }\n  virtual int64 ByteCount() const           { return inner_->ByteCount();      }\n\n private:\n  // Where to insert the string when it's done.\n  GeneratorContextImpl* directory_;\n  string filename_;\n  string insertion_point_;\n\n  // The string we're building.\n  string data_;\n\n  // Whether we should append the output stream to the existing file.\n  bool append_mode_;\n\n  // StringOutputStream writing to data_.\n  google::protobuf::scoped_ptr<io::StringOutputStream> inner_;\n};\n\n// -------------------------------------------------------------------\n\nCommandLineInterface::GeneratorContextImpl::GeneratorContextImpl(\n    const vector<const FileDescriptor*>& parsed_files)\n    : parsed_files_(parsed_files),\n      had_error_(false) {\n}\n\nCommandLineInterface::GeneratorContextImpl::~GeneratorContextImpl() {\n  STLDeleteValues(&files_);\n}\n\nbool CommandLineInterface::GeneratorContextImpl::WriteAllToDisk(\n    const string& prefix) {\n  if (had_error_) {\n    return false;\n  }\n\n  if (!VerifyDirectoryExists(prefix)) {\n    return false;\n  }\n\n  for (map<string, string*>::const_iterator iter = files_.begin();\n       iter != files_.end(); ++iter) {\n    const string& relative_filename = iter->first;\n    const char* data = iter->second->data();\n    int size = iter->second->size();\n\n    if (!TryCreateParentDirectory(prefix, relative_filename)) {\n      return false;\n    }\n    string filename = prefix + relative_filename;\n\n    // Create the output file.\n    int file_descriptor;\n    do {\n      file_descriptor =\n        open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);\n    } while (file_descriptor < 0 && errno == EINTR);\n\n    if (file_descriptor < 0) {\n      int error = errno;\n      std::cerr << filename << \": \" << strerror(error);\n      return false;\n    }\n\n    // Write the file.\n    while (size > 0) {\n      int write_result;\n      do {\n        write_result = write(file_descriptor, data, size);\n      } while (write_result < 0 && errno == EINTR);\n\n      if (write_result <= 0) {\n        // Write error.\n\n        // FIXME(kenton):  According to the man page, if write() returns zero,\n        //   there was no error; write() simply did not write anything.  It's\n        //   unclear under what circumstances this might happen, but presumably\n        //   errno won't be set in this case.  I am confused as to how such an\n        //   event should be handled.  For now I'm treating it as an error,\n        //   since retrying seems like it could lead to an infinite loop.  I\n        //   suspect this never actually happens anyway.\n\n        if (write_result < 0) {\n          int error = errno;\n          std::cerr << filename << \": write: \" << strerror(error);\n        } else {\n          std::cerr << filename << \": write() returned zero?\" << std::endl;\n        }\n        return false;\n      }\n\n      data += write_result;\n      size -= write_result;\n    }\n\n    if (close(file_descriptor) != 0) {\n      int error = errno;\n      std::cerr << filename << \": close: \" << strerror(error);\n      return false;\n    }\n  }\n\n  return true;\n}\n\nbool CommandLineInterface::GeneratorContextImpl::WriteAllToZip(\n    const string& filename) {\n  if (had_error_) {\n    return false;\n  }\n\n  // Create the output file.\n  int file_descriptor;\n  do {\n    file_descriptor =\n      open(filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);\n  } while (file_descriptor < 0 && errno == EINTR);\n\n  if (file_descriptor < 0) {\n    int error = errno;\n    std::cerr << filename << \": \" << strerror(error);\n    return false;\n  }\n\n  // Create the ZipWriter\n  io::FileOutputStream stream(file_descriptor);\n  ZipWriter zip_writer(&stream);\n\n  for (map<string, string*>::const_iterator iter = files_.begin();\n       iter != files_.end(); ++iter) {\n    zip_writer.Write(iter->first, *iter->second);\n  }\n\n  zip_writer.WriteDirectory();\n\n  if (stream.GetErrno() != 0) {\n    std::cerr << filename << \": \" << strerror(stream.GetErrno()) << std::endl;\n  }\n\n  if (!stream.Close()) {\n    std::cerr << filename << \": \" << strerror(stream.GetErrno()) << std::endl;\n  }\n\n  return true;\n}\n\nvoid CommandLineInterface::GeneratorContextImpl::AddJarManifest() {\n  string** map_slot = &files_[\"META-INF/MANIFEST.MF\"];\n  if (*map_slot == NULL) {\n    *map_slot = new string(\n        \"Manifest-Version: 1.0\\n\"\n        \"Created-By: 1.6.0 (protoc)\\n\"\n        \"\\n\");\n  }\n}\n\nvoid CommandLineInterface::GeneratorContextImpl::GetOutputFilenames(\n    vector<string>* output_filenames) {\n  for (map<string, string*>::iterator iter = files_.begin();\n       iter != files_.end(); ++iter) {\n    output_filenames->push_back(iter->first);\n  }\n}\n\nio::ZeroCopyOutputStream* CommandLineInterface::GeneratorContextImpl::Open(\n    const string& filename) {\n  return new MemoryOutputStream(this, filename, false);\n}\n\nio::ZeroCopyOutputStream*\nCommandLineInterface::GeneratorContextImpl::OpenForAppend(\n    const string& filename) {\n  return new MemoryOutputStream(this, filename, true);\n}\n\nio::ZeroCopyOutputStream*\nCommandLineInterface::GeneratorContextImpl::OpenForInsert(\n    const string& filename, const string& insertion_point) {\n  return new MemoryOutputStream(this, filename, insertion_point);\n}\n\n// -------------------------------------------------------------------\n\nCommandLineInterface::MemoryOutputStream::MemoryOutputStream(\n    GeneratorContextImpl* directory, const string& filename, bool append_mode)\n    : directory_(directory),\n      filename_(filename),\n      append_mode_(append_mode),\n      inner_(new io::StringOutputStream(&data_)) {\n}\n\nCommandLineInterface::MemoryOutputStream::MemoryOutputStream(\n    GeneratorContextImpl* directory, const string& filename,\n    const string& insertion_point)\n    : directory_(directory),\n      filename_(filename),\n      insertion_point_(insertion_point),\n      inner_(new io::StringOutputStream(&data_)) {\n}\n\nCommandLineInterface::MemoryOutputStream::~MemoryOutputStream() {\n  // Make sure all data has been written.\n  inner_.reset();\n\n  // Insert into the directory.\n  string** map_slot = &directory_->files_[filename_];\n\n  if (insertion_point_.empty()) {\n    // This was just a regular Open().\n    if (*map_slot != NULL) {\n      if (append_mode_) {\n        (*map_slot)->append(data_);\n      } else {\n        std::cerr << filename_ << \": Tried to write the same file twice.\"\n                  << std::endl;\n        directory_->had_error_ = true;\n      }\n      return;\n    }\n\n    *map_slot = new string;\n    (*map_slot)->swap(data_);\n  } else {\n    // This was an OpenForInsert().\n\n    // If the data doesn't end with a clean line break, add one.\n    if (!data_.empty() && data_[data_.size() - 1] != '\\n') {\n      data_.push_back('\\n');\n    }\n\n    // Find the file we are going to insert into.\n    if (*map_slot == NULL) {\n      std::cerr << filename_\n                << \": Tried to insert into file that doesn't exist.\"\n                << std::endl;\n      directory_->had_error_ = true;\n      return;\n    }\n    string* target = *map_slot;\n\n    // Find the insertion point.\n    string magic_string = strings::Substitute(\n        \"@@protoc_insertion_point($0)\", insertion_point_);\n    string::size_type pos = target->find(magic_string);\n\n    if (pos == string::npos) {\n      std::cerr << filename_ << \": insertion point \\\"\" << insertion_point_\n                << \"\\\" not found.\" << std::endl;\n      directory_->had_error_ = true;\n      return;\n    }\n\n    if ((pos > 3) && (target->substr(pos - 3, 2) == \"/*\")) {\n      // Support for inline \"/* @@protoc_insertion_point() */\"\n      pos = pos - 3;\n    } else {\n      // Seek backwards to the beginning of the line, which is where we will\n      // insert the data.  Note that this has the effect of pushing the\n      // insertion point down, so the data is inserted before it.  This is\n      // intentional because it means that multiple insertions at the same point\n      // will end up in the expected order in the final output.\n      pos = target->find_last_of('\\n', pos);\n      if (pos == string::npos) {\n        // Insertion point is on the first line.\n        pos = 0;\n      } else {\n        // Advance to character after '\\n'.\n        ++pos;\n      }\n    }\n\n    // Extract indent.\n    string indent_(*target, pos, target->find_first_not_of(\" \\t\", pos) - pos);\n\n    if (indent_.empty()) {\n      // No indent.  This makes things easier.\n      target->insert(pos, data_);\n    } else {\n      // Calculate how much space we need.\n      int indent_size = 0;\n      for (int i = 0; i < data_.size(); i++) {\n        if (data_[i] == '\\n') indent_size += indent_.size();\n      }\n\n      // Make a hole for it.\n      target->insert(pos, data_.size() + indent_size, '\\0');\n\n      // Now copy in the data.\n      string::size_type data_pos = 0;\n      char* target_ptr = string_as_array(target) + pos;\n      while (data_pos < data_.size()) {\n        // Copy indent.\n        memcpy(target_ptr, indent_.data(), indent_.size());\n        target_ptr += indent_.size();\n\n        // Copy line from data_.\n        // We already guaranteed that data_ ends with a newline (above), so this\n        // search can't fail.\n        string::size_type line_length =\n            data_.find_first_of('\\n', data_pos) + 1 - data_pos;\n        memcpy(target_ptr, data_.data() + data_pos, line_length);\n        target_ptr += line_length;\n        data_pos += line_length;\n      }\n\n      GOOGLE_CHECK_EQ(target_ptr,\n          string_as_array(target) + pos + data_.size() + indent_size);\n    }\n  }\n}\n\n// ===================================================================\n\nCommandLineInterface::CommandLineInterface()\n  : mode_(MODE_COMPILE),\n    print_mode_(PRINT_NONE),\n    error_format_(ERROR_FORMAT_GCC),\n    imports_in_descriptor_set_(false),\n    source_info_in_descriptor_set_(false),\n    disallow_services_(false),\n    inputs_are_proto_path_relative_(false) {}\nCommandLineInterface::~CommandLineInterface() {}\n\nvoid CommandLineInterface::RegisterGenerator(const string& flag_name,\n                                             CodeGenerator* generator,\n                                             const string& help_text) {\n  GeneratorInfo info;\n  info.flag_name = flag_name;\n  info.generator = generator;\n  info.help_text = help_text;\n  generators_by_flag_name_[flag_name] = info;\n}\n\nvoid CommandLineInterface::RegisterGenerator(const string& flag_name,\n                                             const string& option_flag_name,\n                                             CodeGenerator* generator,\n                                             const string& help_text) {\n  GeneratorInfo info;\n  info.flag_name = flag_name;\n  info.option_flag_name = option_flag_name;\n  info.generator = generator;\n  info.help_text = help_text;\n  generators_by_flag_name_[flag_name] = info;\n  generators_by_option_name_[option_flag_name] = info;\n}\n\nvoid CommandLineInterface::AllowPlugins(const string& exe_name_prefix) {\n  plugin_prefix_ = exe_name_prefix;\n}\n\nint CommandLineInterface::Run(int argc, const char* const argv[]) {\n  Clear();\n  switch (ParseArguments(argc, argv)) {\n    case PARSE_ARGUMENT_DONE_AND_EXIT:\n      return 0;\n    case PARSE_ARGUMENT_FAIL:\n      return 1;\n    case PARSE_ARGUMENT_DONE_AND_CONTINUE:\n      break;\n  }\n\n  AddDefaultProtoPaths(&proto_path_);\n\n  // Set up the source tree.\n  DiskSourceTree source_tree;\n  for (int i = 0; i < proto_path_.size(); i++) {\n    source_tree.MapPath(proto_path_[i].first, proto_path_[i].second);\n  }\n\n  // Map input files to virtual paths if necessary.\n  if (!inputs_are_proto_path_relative_) {\n    if (!MakeInputsBeProtoPathRelative(&source_tree)) {\n      return 1;\n    }\n  }\n\n  // Allocate the Importer.\n  ErrorPrinter error_collector(error_format_, &source_tree);\n  Importer importer(&source_tree, &error_collector);\n\n  vector<const FileDescriptor*> parsed_files;\n\n  // Parse each file.\n  for (int i = 0; i < input_files_.size(); i++) {\n    // Import the file.\n    importer.AddUnusedImportTrackFile(input_files_[i]);\n    const FileDescriptor* parsed_file = importer.Import(input_files_[i]);\n    importer.ClearUnusedImportTrackFiles();\n    if (parsed_file == NULL) return 1;\n    parsed_files.push_back(parsed_file);\n\n    // Enforce --disallow_services.\n    if (disallow_services_ && parsed_file->service_count() > 0) {\n      cerr << parsed_file->name() << \": This file contains services, but \"\n              \"--disallow_services was used.\" << endl;\n      return 1;\n    }\n  }\n\n  // We construct a separate GeneratorContext for each output location.  Note\n  // that two code generators may output to the same location, in which case\n  // they should share a single GeneratorContext so that OpenForInsert() works.\n  GeneratorContextMap output_directories;\n\n  // Generate output.\n  if (mode_ == MODE_COMPILE) {\n    for (int i = 0; i < output_directives_.size(); i++) {\n      string output_location = output_directives_[i].output_location;\n      if (!HasSuffixString(output_location, \".zip\") &&\n          !HasSuffixString(output_location, \".jar\")) {\n        AddTrailingSlash(&output_location);\n      }\n      GeneratorContextImpl** map_slot = &output_directories[output_location];\n\n      if (*map_slot == NULL) {\n        // First time we've seen this output location.\n        *map_slot = new GeneratorContextImpl(parsed_files);\n      }\n\n      if (!GenerateOutput(parsed_files, output_directives_[i], *map_slot)) {\n        STLDeleteValues(&output_directories);\n        return 1;\n      }\n    }\n  }\n\n  // Write all output to disk.\n  for (GeneratorContextMap::iterator iter = output_directories.begin();\n       iter != output_directories.end(); ++iter) {\n    const string& location = iter->first;\n    GeneratorContextImpl* directory = iter->second;\n    if (HasSuffixString(location, \"/\")) {\n      if (!directory->WriteAllToDisk(location)) {\n        STLDeleteValues(&output_directories);\n        return 1;\n      }\n    } else {\n      if (HasSuffixString(location, \".jar\")) {\n        directory->AddJarManifest();\n      }\n\n      if (!directory->WriteAllToZip(location)) {\n        STLDeleteValues(&output_directories);\n        return 1;\n      }\n    }\n  }\n\n  if (!dependency_out_name_.empty()) {\n    if (!GenerateDependencyManifestFile(parsed_files, output_directories,\n                                        &source_tree)) {\n      return 1;\n    }\n  }\n\n  STLDeleteValues(&output_directories);\n\n  if (!descriptor_set_name_.empty()) {\n    if (!WriteDescriptorSet(parsed_files)) {\n      return 1;\n    }\n  }\n\n  if (mode_ == MODE_ENCODE || mode_ == MODE_DECODE) {\n    if (codec_type_.empty()) {\n      // HACK:  Define an EmptyMessage type to use for decoding.\n      DescriptorPool pool;\n      FileDescriptorProto file;\n      file.set_name(\"empty_message.proto\");\n      file.add_message_type()->set_name(\"EmptyMessage\");\n      GOOGLE_CHECK(pool.BuildFile(file) != NULL);\n      codec_type_ = \"EmptyMessage\";\n      if (!EncodeOrDecode(&pool)) {\n        return 1;\n      }\n    } else {\n      if (!EncodeOrDecode(importer.pool())) {\n        return 1;\n      }\n    }\n  }\n\n  if (mode_ == MODE_PRINT) {\n    switch (print_mode_) {\n      case PRINT_FREE_FIELDS:\n        for (int i = 0; i < parsed_files.size(); ++i) {\n          const FileDescriptor* fd = parsed_files[i];\n          for (int j = 0; j < fd->message_type_count(); ++j) {\n            PrintFreeFieldNumbers(fd->message_type(j));\n          }\n        }\n        break;\n      case PRINT_NONE:\n        GOOGLE_LOG(ERROR) << \"If the code reaches here, it usually means a bug of \"\n                     \"flag parsing in the CommonadLineInterface.\";\n        return 1;\n\n      // Do not add a default case.\n    }\n  }\n\n  return 0;\n}\n\nvoid CommandLineInterface::Clear() {\n  // Clear all members that are set by Run().  Note that we must not clear\n  // members which are set by other methods before Run() is called.\n  executable_name_.clear();\n  proto_path_.clear();\n  input_files_.clear();\n  output_directives_.clear();\n  codec_type_.clear();\n  descriptor_set_name_.clear();\n  dependency_out_name_.clear();\n\n  mode_ = MODE_COMPILE;\n  print_mode_ = PRINT_NONE;\n  imports_in_descriptor_set_ = false;\n  source_info_in_descriptor_set_ = false;\n  disallow_services_ = false;\n}\n\nbool CommandLineInterface::MakeInputsBeProtoPathRelative(\n    DiskSourceTree* source_tree) {\n  for (int i = 0; i < input_files_.size(); i++) {\n    string virtual_file, shadowing_disk_file;\n    switch (source_tree->DiskFileToVirtualFile(\n        input_files_[i], &virtual_file, &shadowing_disk_file)) {\n      case DiskSourceTree::SUCCESS:\n        input_files_[i] = virtual_file;\n        break;\n      case DiskSourceTree::SHADOWED:\n        std::cerr << input_files_[i]\n                  << \": Input is shadowed in the --proto_path by \\\"\"\n                  << shadowing_disk_file\n                  << \"\\\".  Either use the latter file as your input or reorder \"\n                     \"the --proto_path so that the former file's location \"\n                     \"comes first.\" << std::endl;\n        return false;\n      case DiskSourceTree::CANNOT_OPEN:\n        std::cerr << input_files_[i] << \": \" << strerror(errno) << std::endl;\n        return false;\n      case DiskSourceTree::NO_MAPPING:\n        // First check if the file exists at all.\n        if (access(input_files_[i].c_str(), F_OK) < 0) {\n          // File does not even exist.\n          std::cerr << input_files_[i] << \": \" << strerror(ENOENT) << std::endl;\n        } else {\n          std::cerr\n              << input_files_[i]\n              << \": File does not reside within any path \"\n                 \"specified using --proto_path (or -I).  You must specify a \"\n                 \"--proto_path which encompasses this file.  Note that the \"\n                 \"proto_path must be an exact prefix of the .proto file \"\n                 \"names -- protoc is too dumb to figure out when two paths \"\n                 \"(e.g. absolute and relative) are equivalent (it's harder \"\n                 \"than you think).\" << std::endl;\n        }\n        return false;\n    }\n  }\n\n  return true;\n}\n\n\nCommandLineInterface::ParseArgumentStatus\nCommandLineInterface::ParseArguments(int argc, const char* const argv[]) {\n  executable_name_ = argv[0];\n\n  vector<string> arguments;\n  for (int i = 1; i < argc; ++i) {\n    arguments.push_back(argv[i]);\n  }\n\n  // Iterate through all arguments and parse them.\n  for (int i = 0; i < arguments.size(); ++i) {\n    string name, value;\n\n    if (ParseArgument(arguments[i].c_str(), &name, &value)) {\n      // Returned true => Use the next argument as the flag value.\n      if (i + 1 == arguments.size() || arguments[i + 1][0] == '-') {\n        std::cerr << \"Missing value for flag: \" << name << std::endl;\n        if (name == \"--decode\") {\n          std::cerr << \"To decode an unknown message, use --decode_raw.\"\n                    << std::endl;\n        }\n        return PARSE_ARGUMENT_FAIL;\n      } else {\n        ++i;\n        value = arguments[i];\n      }\n    }\n\n    ParseArgumentStatus status = InterpretArgument(name, value);\n    if (status != PARSE_ARGUMENT_DONE_AND_CONTINUE)\n      return status;\n  }\n\n  // If no --proto_path was given, use the current working directory.\n  if (proto_path_.empty()) {\n    // Don't use make_pair as the old/default standard library on Solaris\n    // doesn't support it without explicit template parameters, which are\n    // incompatible with C++0x's make_pair.\n    proto_path_.push_back(pair<string, string>(\"\", \".\"));\n  }\n\n  // Check some errror cases.\n  bool decoding_raw = (mode_ == MODE_DECODE) && codec_type_.empty();\n  if (decoding_raw && !input_files_.empty()) {\n    std::cerr << \"When using --decode_raw, no input files should be given.\"\n              << std::endl;\n    return PARSE_ARGUMENT_FAIL;\n  } else if (!decoding_raw && input_files_.empty()) {\n    std::cerr << \"Missing input file.\" << std::endl;\n    return PARSE_ARGUMENT_FAIL;\n  }\n  if (mode_ == MODE_COMPILE && output_directives_.empty() &&\n      descriptor_set_name_.empty()) {\n    std::cerr << \"Missing output directives.\" << std::endl;\n    return PARSE_ARGUMENT_FAIL;\n  }\n  if (mode_ != MODE_COMPILE && !dependency_out_name_.empty()) {\n    std::cerr << \"Can only use --dependency_out=FILE when generating code.\"\n              << std::endl;\n    return PARSE_ARGUMENT_FAIL;\n  }\n  if (!dependency_out_name_.empty() && input_files_.size() > 1) {\n    std::cerr\n        << \"Can only process one input file when using --dependency_out=FILE.\"\n        << std::endl;\n    return PARSE_ARGUMENT_FAIL;\n  }\n  if (imports_in_descriptor_set_ && descriptor_set_name_.empty()) {\n    std::cerr << \"--include_imports only makes sense when combined with \"\n                 \"--descriptor_set_out.\" << std::endl;\n  }\n  if (source_info_in_descriptor_set_ && descriptor_set_name_.empty()) {\n    std::cerr << \"--include_source_info only makes sense when combined with \"\n                 \"--descriptor_set_out.\" << std::endl;\n  }\n\n  return PARSE_ARGUMENT_DONE_AND_CONTINUE;\n}\n\nbool CommandLineInterface::ParseArgument(const char* arg,\n                                         string* name, string* value) {\n  bool parsed_value = false;\n\n  if (arg[0] != '-') {\n    // Not a flag.\n    name->clear();\n    parsed_value = true;\n    *value = arg;\n  } else if (arg[1] == '-') {\n    // Two dashes:  Multi-character name, with '=' separating name and\n    //   value.\n    const char* equals_pos = strchr(arg, '=');\n    if (equals_pos != NULL) {\n      *name = string(arg, equals_pos - arg);\n      *value = equals_pos + 1;\n      parsed_value = true;\n    } else {\n      *name = arg;\n    }\n  } else {\n    // One dash:  One-character name, all subsequent characters are the\n    //   value.\n    if (arg[1] == '\\0') {\n      // arg is just \"-\".  We treat this as an input file, except that at\n      // present this will just lead to a \"file not found\" error.\n      name->clear();\n      *value = arg;\n      parsed_value = true;\n    } else {\n      *name = string(arg, 2);\n      *value = arg + 2;\n      parsed_value = !value->empty();\n    }\n  }\n\n  // Need to return true iff the next arg should be used as the value for this\n  // one, false otherwise.\n\n  if (parsed_value) {\n    // We already parsed a value for this flag.\n    return false;\n  }\n\n  if (*name == \"-h\" || *name == \"--help\" ||\n      *name == \"--disallow_services\" ||\n      *name == \"--include_imports\" ||\n      *name == \"--include_source_info\" ||\n      *name == \"--version\" ||\n      *name == \"--decode_raw\" ||\n      *name == \"--print_free_field_numbers\") {\n    // HACK:  These are the only flags that don't take a value.\n    //   They probably should not be hard-coded like this but for now it's\n    //   not worth doing better.\n    return false;\n  }\n\n  // Next argument is the flag value.\n  return true;\n}\n\nCommandLineInterface::ParseArgumentStatus\nCommandLineInterface::InterpretArgument(const string& name,\n                                        const string& value) {\n  if (name.empty()) {\n    // Not a flag.  Just a filename.\n    if (value.empty()) {\n      std::cerr\n          << \"You seem to have passed an empty string as one of the \"\n             \"arguments to \" << executable_name_\n          << \".  This is actually \"\n             \"sort of hard to do.  Congrats.  Unfortunately it is not valid \"\n             \"input so the program is going to die now.\" << std::endl;\n      return PARSE_ARGUMENT_FAIL;\n    }\n\n    input_files_.push_back(value);\n\n  } else if (name == \"-I\" || name == \"--proto_path\") {\n    // Java's -classpath (and some other languages) delimits path components\n    // with colons.  Let's accept that syntax too just to make things more\n    // intuitive.\n    vector<string> parts = Split(\n        value, kPathSeparator, true);\n\n    for (int i = 0; i < parts.size(); i++) {\n      string virtual_path;\n      string disk_path;\n\n      string::size_type equals_pos = parts[i].find_first_of('=');\n      if (equals_pos == string::npos) {\n        virtual_path = \"\";\n        disk_path = parts[i];\n      } else {\n        virtual_path = parts[i].substr(0, equals_pos);\n        disk_path = parts[i].substr(equals_pos + 1);\n      }\n\n      if (disk_path.empty()) {\n        std::cerr\n            << \"--proto_path passed empty directory name.  (Use \\\".\\\" for \"\n               \"current directory.)\" << std::endl;\n        return PARSE_ARGUMENT_FAIL;\n      }\n\n      // Make sure disk path exists, warn otherwise.\n      if (access(disk_path.c_str(), F_OK) < 0) {\n        // Try the original path; it may have just happed to have a '=' in it.\n        if (access(parts[i].c_str(), F_OK) < 0) {\n          cerr << disk_path << \": warning: directory does not exist.\" << endl;\n        } else {\n          virtual_path = \"\";\n          disk_path = parts[i];\n        }\n      }\n\n      // Don't use make_pair as the old/default standard library on Solaris\n      // doesn't support it without explicit template parameters, which are\n      // incompatible with C++0x's make_pair.\n      proto_path_.push_back(pair<string, string>(virtual_path, disk_path));\n    }\n\n  } else if (name == \"-o\" || name == \"--descriptor_set_out\") {\n    if (!descriptor_set_name_.empty()) {\n      std::cerr << name << \" may only be passed once.\" << std::endl;\n      return PARSE_ARGUMENT_FAIL;\n    }\n    if (value.empty()) {\n      std::cerr << name << \" requires a non-empty value.\" << std::endl;\n      return PARSE_ARGUMENT_FAIL;\n    }\n    if (mode_ != MODE_COMPILE) {\n      std::cerr\n          << \"Cannot use --encode or --decode and generate descriptors at the \"\n             \"same time.\" << std::endl;\n      return PARSE_ARGUMENT_FAIL;\n    }\n    descriptor_set_name_ = value;\n\n  } else if (name == \"--dependency_out\") {\n    if (!dependency_out_name_.empty()) {\n      std::cerr << name << \" may only be passed once.\" << std::endl;\n      return PARSE_ARGUMENT_FAIL;\n    }\n    if (value.empty()) {\n      std::cerr << name << \" requires a non-empty value.\" << std::endl;\n      return PARSE_ARGUMENT_FAIL;\n    }\n    dependency_out_name_ = value;\n\n  } else if (name == \"--include_imports\") {\n    if (imports_in_descriptor_set_) {\n      std::cerr << name << \" may only be passed once.\" << std::endl;\n      return PARSE_ARGUMENT_FAIL;\n    }\n    imports_in_descriptor_set_ = true;\n\n  } else if (name == \"--include_source_info\") {\n    if (source_info_in_descriptor_set_) {\n      std::cerr << name << \" may only be passed once.\" << std::endl;\n      return PARSE_ARGUMENT_FAIL;\n    }\n    source_info_in_descriptor_set_ = true;\n\n  } else if (name == \"-h\" || name == \"--help\") {\n    PrintHelpText();\n    return PARSE_ARGUMENT_DONE_AND_EXIT;  // Exit without running compiler.\n\n  } else if (name == \"--version\") {\n    if (!version_info_.empty()) {\n      std::cout << version_info_ << std::endl;\n    }\n    cout << \"libprotoc \"\n         << protobuf::internal::VersionString(GOOGLE_PROTOBUF_VERSION)\n         << endl;\n    return PARSE_ARGUMENT_DONE_AND_EXIT;  // Exit without running compiler.\n\n  } else if (name == \"--disallow_services\") {\n    disallow_services_ = true;\n\n  } else if (name == \"--encode\" || name == \"--decode\" ||\n             name == \"--decode_raw\") {\n    if (mode_ != MODE_COMPILE) {\n      std::cerr << \"Only one of --encode and --decode can be specified.\"\n                << std::endl;\n      return PARSE_ARGUMENT_FAIL;\n    }\n    if (!output_directives_.empty() || !descriptor_set_name_.empty()) {\n      std::cerr << \"Cannot use \" << name\n                << \" and generate code or descriptors at the same time.\"\n                << std::endl;\n      return PARSE_ARGUMENT_FAIL;\n    }\n\n    mode_ = (name == \"--encode\") ? MODE_ENCODE : MODE_DECODE;\n\n    if (value.empty() && name != \"--decode_raw\") {\n      std::cerr << \"Type name for \" << name << \" cannot be blank.\" << std::endl;\n      if (name == \"--decode\") {\n        std::cerr << \"To decode an unknown message, use --decode_raw.\"\n                  << std::endl;\n      }\n      return PARSE_ARGUMENT_FAIL;\n    } else if (!value.empty() && name == \"--decode_raw\") {\n      std::cerr << \"--decode_raw does not take a parameter.\" << std::endl;\n      return PARSE_ARGUMENT_FAIL;\n    }\n\n    codec_type_ = value;\n\n  } else if (name == \"--error_format\") {\n    if (value == \"gcc\") {\n      error_format_ = ERROR_FORMAT_GCC;\n    } else if (value == \"msvs\") {\n      error_format_ = ERROR_FORMAT_MSVS;\n    } else {\n      std::cerr << \"Unknown error format: \" << value << std::endl;\n      return PARSE_ARGUMENT_FAIL;\n    }\n\n  } else if (name == \"--plugin\") {\n    if (plugin_prefix_.empty()) {\n      std::cerr << \"This compiler does not support plugins.\" << std::endl;\n      return PARSE_ARGUMENT_FAIL;\n    }\n\n    string plugin_name;\n    string path;\n\n    string::size_type equals_pos = value.find_first_of('=');\n    if (equals_pos == string::npos) {\n      // Use the basename of the file.\n      string::size_type slash_pos = value.find_last_of('/');\n      if (slash_pos == string::npos) {\n        plugin_name = value;\n      } else {\n        plugin_name = value.substr(slash_pos + 1);\n      }\n      path = value;\n    } else {\n      plugin_name = value.substr(0, equals_pos);\n      path = value.substr(equals_pos + 1);\n    }\n\n    plugins_[plugin_name] = path;\n\n  } else if (name == \"--print_free_field_numbers\") {\n    if (mode_ != MODE_COMPILE) {\n      std::cerr << \"Cannot use \" << name\n                << \" and use --encode, --decode or print \"\n                << \"other info at the same time.\" << std::endl;\n      return PARSE_ARGUMENT_FAIL;\n    }\n    if (!output_directives_.empty() || !descriptor_set_name_.empty()) {\n      std::cerr << \"Cannot use \" << name\n                << \" and generate code or descriptors at the same time.\"\n                << std::endl;\n      return PARSE_ARGUMENT_FAIL;\n    }\n    mode_ = MODE_PRINT;\n    print_mode_ = PRINT_FREE_FIELDS;\n  } else {\n    // Some other flag.  Look it up in the generators list.\n    const GeneratorInfo* generator_info =\n        FindOrNull(generators_by_flag_name_, name);\n    if (generator_info == NULL &&\n        (plugin_prefix_.empty() || !HasSuffixString(name, \"_out\"))) {\n      // Check if it's a generator option flag.\n      generator_info = FindOrNull(generators_by_option_name_, name);\n      if (generator_info == NULL) {\n        std::cerr << \"Unknown flag: \" << name << std::endl;\n        return PARSE_ARGUMENT_FAIL;\n      } else {\n        string* parameters = &generator_parameters_[generator_info->flag_name];\n        if (!parameters->empty()) {\n          parameters->append(\",\");\n        }\n        parameters->append(value);\n      }\n    } else {\n      // It's an output flag.  Add it to the output directives.\n      if (mode_ != MODE_COMPILE) {\n        std::cerr << \"Cannot use --encode, --decode or print .proto info and \"\n                     \"generate code at the same time.\" << std::endl;\n        return PARSE_ARGUMENT_FAIL;\n      }\n\n      OutputDirective directive;\n      directive.name = name;\n      if (generator_info == NULL) {\n        directive.generator = NULL;\n      } else {\n        directive.generator = generator_info->generator;\n      }\n\n      // Split value at ':' to separate the generator parameter from the\n      // filename.  However, avoid doing this if the colon is part of a valid\n      // Windows-style absolute path.\n      string::size_type colon_pos = value.find_first_of(':');\n      if (colon_pos == string::npos || IsWindowsAbsolutePath(value)) {\n        directive.output_location = value;\n      } else {\n        directive.parameter = value.substr(0, colon_pos);\n        directive.output_location = value.substr(colon_pos + 1);\n      }\n\n      output_directives_.push_back(directive);\n    }\n  }\n\n  return PARSE_ARGUMENT_DONE_AND_CONTINUE;\n}\n\nvoid CommandLineInterface::PrintHelpText() {\n  // Sorry for indentation here; line wrapping would be uglier.\n  std::cerr <<\n\"Usage: \" << executable_name_ << \" [OPTION] PROTO_FILES\\n\"\n\"Parse PROTO_FILES and generate output based on the options given:\\n\"\n\"  -IPATH, --proto_path=PATH   Specify the directory in which to search for\\n\"\n\"                              imports.  May be specified multiple times;\\n\"\n\"                              directories will be searched in order.  If not\\n\"\n\"                              given, the current working directory is used.\\n\"\n\"  --version                   Show version info and exit.\\n\"\n\"  -h, --help                  Show this text and exit.\\n\"\n\"  --encode=MESSAGE_TYPE       Read a text-format message of the given type\\n\"\n\"                              from standard input and write it in binary\\n\"\n\"                              to standard output.  The message type must\\n\"\n\"                              be defined in PROTO_FILES or their imports.\\n\"\n\"  --decode=MESSAGE_TYPE       Read a binary message of the given type from\\n\"\n\"                              standard input and write it in text format\\n\"\n\"                              to standard output.  The message type must\\n\"\n\"                              be defined in PROTO_FILES or their imports.\\n\"\n\"  --decode_raw                Read an arbitrary protocol message from\\n\"\n\"                              standard input and write the raw tag/value\\n\"\n\"                              pairs in text format to standard output.  No\\n\"\n\"                              PROTO_FILES should be given when using this\\n\"\n\"                              flag.\\n\"\n\"  -oFILE,                     Writes a FileDescriptorSet (a protocol buffer,\\n\"\n\"    --descriptor_set_out=FILE defined in descriptor.proto) containing all of\\n\"\n\"                              the input files to FILE.\\n\"\n\"  --include_imports           When using --descriptor_set_out, also include\\n\"\n\"                              all dependencies of the input files in the\\n\"\n\"                              set, so that the set is self-contained.\\n\"\n\"  --include_source_info       When using --descriptor_set_out, do not strip\\n\"\n\"                              SourceCodeInfo from the FileDescriptorProto.\\n\"\n\"                              This results in vastly larger descriptors that\\n\"\n\"                              include information about the original\\n\"\n\"                              location of each decl in the source file as\\n\"\n\"                              well as surrounding comments.\\n\"\n\"  --dependency_out=FILE       Write a dependency output file in the format\\n\"\n\"                              expected by make. This writes the transitive\\n\"\n\"                              set of input file paths to FILE\\n\"\n\"  --error_format=FORMAT       Set the format in which to print errors.\\n\"\n\"                              FORMAT may be 'gcc' (the default) or 'msvs'\\n\"\n\"                              (Microsoft Visual Studio format).\\n\"\n\"  --print_free_field_numbers  Print the free field numbers of the messages\\n\"\n\"                              defined in the given proto files. Groups share\\n\"\n\"                              the same field number space with the parent \\n\"\n\"                              message. Extension ranges are counted as \\n\"\n\"                              occupied fields numbers.\\n\"\n      << std::endl;\n  if (!plugin_prefix_.empty()) {\n    std::cerr <<\n\"  --plugin=EXECUTABLE         Specifies a plugin executable to use.\\n\"\n\"                              Normally, protoc searches the PATH for\\n\"\n\"                              plugins, but you may specify additional\\n\"\n\"                              executables not in the path using this flag.\\n\"\n\"                              Additionally, EXECUTABLE may be of the form\\n\"\n\"                              NAME=PATH, in which case the given plugin name\\n\"\n\"                              is mapped to the given executable even if\\n\"\n\"                              the executable's own name differs.\" << std::endl;\n  }\n\n  for (GeneratorMap::iterator iter = generators_by_flag_name_.begin();\n       iter != generators_by_flag_name_.end(); ++iter) {\n    // FIXME(kenton):  If the text is long enough it will wrap, which is ugly,\n    //   but fixing this nicely (e.g. splitting on spaces) is probably more\n    //   trouble than it's worth.\n    std::cerr << \"  \" << iter->first << \"=OUT_DIR \"\n              << string(19 - iter->first.size(), ' ')  // Spaces for alignment.\n              << iter->second.help_text << std::endl;\n  }\n}\n\nbool CommandLineInterface::GenerateOutput(\n    const vector<const FileDescriptor*>& parsed_files,\n    const OutputDirective& output_directive,\n    GeneratorContext* generator_context) {\n  // Call the generator.\n  string error;\n  if (output_directive.generator == NULL) {\n    // This is a plugin.\n    GOOGLE_CHECK(HasPrefixString(output_directive.name, \"--\") &&\n          HasSuffixString(output_directive.name, \"_out\"))\n        << \"Bad name for plugin generator: \" << output_directive.name;\n\n    // Strip the \"--\" and \"_out\" and add the plugin prefix.\n    string plugin_name = plugin_prefix_ + \"gen-\" +\n        output_directive.name.substr(2, output_directive.name.size() - 6);\n\n    if (!GeneratePluginOutput(parsed_files, plugin_name,\n                              output_directive.parameter,\n                              generator_context, &error)) {\n      std::cerr << output_directive.name << \": \" << error << std::endl;\n      return false;\n    }\n  } else {\n    // Regular generator.\n    string parameters = output_directive.parameter;\n    if (!generator_parameters_[output_directive.name].empty()) {\n      if (!parameters.empty()) {\n        parameters.append(\",\");\n      }\n      parameters.append(generator_parameters_[output_directive.name]);\n    }\n    if (output_directive.generator->HasGenerateAll()) {\n      if (!output_directive.generator->GenerateAll(\n          parsed_files, parameters, generator_context, &error)) {\n          // Generator returned an error.\n          std::cerr << output_directive.name << \": \"\n                    << \": \" << error << std::endl;\n          return false;\n      }\n    } else {\n      for (int i = 0; i < parsed_files.size(); i++) {\n        if (!output_directive.generator->Generate(parsed_files[i], parameters,\n                                                  generator_context, &error)) {\n          // Generator returned an error.\n          std::cerr << output_directive.name << \": \" << parsed_files[i]->name()\n                    << \": \" << error << std::endl;\n          return false;\n        }\n      }\n    }\n  }\n\n  return true;\n}\n\nbool CommandLineInterface::GenerateDependencyManifestFile(\n    const vector<const FileDescriptor*>& parsed_files,\n    const GeneratorContextMap& output_directories,\n    DiskSourceTree* source_tree) {\n  FileDescriptorSet file_set;\n\n  set<const FileDescriptor*> already_seen;\n  for (int i = 0; i < parsed_files.size(); i++) {\n    GetTransitiveDependencies(parsed_files[i],\n                              false,\n                              false,\n                              &already_seen,\n                              file_set.mutable_file());\n  }\n\n  vector<string> output_filenames;\n  for (GeneratorContextMap::const_iterator iter = output_directories.begin();\n       iter != output_directories.end(); ++iter) {\n    const string& location = iter->first;\n    GeneratorContextImpl* directory = iter->second;\n    vector<string> relative_output_filenames;\n    directory->GetOutputFilenames(&relative_output_filenames);\n    for (int i = 0; i < relative_output_filenames.size(); i++) {\n      string output_filename = location + relative_output_filenames[i];\n      if (output_filename.compare(0, 2, \"./\") == 0) {\n        output_filename = output_filename.substr(2);\n      }\n      output_filenames.push_back(output_filename);\n    }\n  }\n\n  int fd;\n  do {\n    fd = open(dependency_out_name_.c_str(),\n              O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);\n  } while (fd < 0 && errno == EINTR);\n\n  if (fd < 0) {\n    perror(dependency_out_name_.c_str());\n    return false;\n  }\n\n  io::FileOutputStream out(fd);\n  io::Printer printer(&out, '$');\n\n  for (int i = 0; i < output_filenames.size(); i++) {\n    printer.Print(output_filenames[i].c_str());\n    if (i == output_filenames.size() - 1) {\n      printer.Print(\":\");\n    } else {\n      printer.Print(\" \\\\\\n\");\n    }\n  }\n\n  for (int i = 0; i < file_set.file_size(); i++) {\n    const FileDescriptorProto& file = file_set.file(i);\n    const string& virtual_file = file.name();\n    string disk_file;\n    if (source_tree &&\n        source_tree->VirtualFileToDiskFile(virtual_file, &disk_file)) {\n      printer.Print(\" $disk_file$\", \"disk_file\", disk_file);\n      if (i < file_set.file_size() - 1) printer.Print(\"\\\\\\n\");\n    } else {\n      std::cerr << \"Unable to identify path for file \" << virtual_file\n                << std::endl;\n      return false;\n    }\n  }\n\n  return true;\n}\n\nbool CommandLineInterface::GeneratePluginOutput(\n    const vector<const FileDescriptor*>& parsed_files,\n    const string& plugin_name,\n    const string& parameter,\n    GeneratorContext* generator_context,\n    string* error) {\n  CodeGeneratorRequest request;\n  CodeGeneratorResponse response;\n\n  // Build the request.\n  if (!parameter.empty()) {\n    request.set_parameter(parameter);\n  }\n\n  set<const FileDescriptor*> already_seen;\n  for (int i = 0; i < parsed_files.size(); i++) {\n    request.add_file_to_generate(parsed_files[i]->name());\n    GetTransitiveDependencies(parsed_files[i],\n                              true,  // Include json_name for plugins.\n                              true,  // Include source code info.\n                              &already_seen, request.mutable_proto_file());\n  }\n\n  // Invoke the plugin.\n  Subprocess subprocess;\n\n  if (plugins_.count(plugin_name) > 0) {\n    subprocess.Start(plugins_[plugin_name], Subprocess::EXACT_NAME);\n  } else {\n    subprocess.Start(plugin_name, Subprocess::SEARCH_PATH);\n  }\n\n  string communicate_error;\n  if (!subprocess.Communicate(request, &response, &communicate_error)) {\n    *error = strings::Substitute(\"$0: $1\", plugin_name, communicate_error);\n    return false;\n  }\n\n  // Write the files.  We do this even if there was a generator error in order\n  // to match the behavior of a compiled-in generator.\n  google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> current_output;\n  for (int i = 0; i < response.file_size(); i++) {\n    const CodeGeneratorResponse::File& output_file = response.file(i);\n\n    if (!output_file.insertion_point().empty()) {\n      // Open a file for insert.\n      // We reset current_output to NULL first so that the old file is closed\n      // before the new one is opened.\n      current_output.reset();\n      current_output.reset(generator_context->OpenForInsert(\n          output_file.name(), output_file.insertion_point()));\n    } else if (!output_file.name().empty()) {\n      // Starting a new file.  Open it.\n      // We reset current_output to NULL first so that the old file is closed\n      // before the new one is opened.\n      current_output.reset();\n      current_output.reset(generator_context->Open(output_file.name()));\n    } else if (current_output == NULL) {\n      *error = strings::Substitute(\n        \"$0: First file chunk returned by plugin did not specify a file name.\",\n        plugin_name);\n      return false;\n    }\n\n    // Use CodedOutputStream for convenience; otherwise we'd need to provide\n    // our own buffer-copying loop.\n    io::CodedOutputStream writer(current_output.get());\n    writer.WriteString(output_file.content());\n  }\n\n  // Check for errors.\n  if (!response.error().empty()) {\n    // Generator returned an error.\n    *error = response.error();\n    return false;\n  }\n\n  return true;\n}\n\nbool CommandLineInterface::EncodeOrDecode(const DescriptorPool* pool) {\n  // Look up the type.\n  const Descriptor* type = pool->FindMessageTypeByName(codec_type_);\n  if (type == NULL) {\n    std::cerr << \"Type not defined: \" << codec_type_ << std::endl;\n    return false;\n  }\n\n  DynamicMessageFactory dynamic_factory(pool);\n  google::protobuf::scoped_ptr<Message> message(dynamic_factory.GetPrototype(type)->New());\n\n  if (mode_ == MODE_ENCODE) {\n    SetFdToTextMode(STDIN_FILENO);\n    SetFdToBinaryMode(STDOUT_FILENO);\n  } else {\n    SetFdToBinaryMode(STDIN_FILENO);\n    SetFdToTextMode(STDOUT_FILENO);\n  }\n\n  io::FileInputStream in(STDIN_FILENO);\n  io::FileOutputStream out(STDOUT_FILENO);\n\n  if (mode_ == MODE_ENCODE) {\n    // Input is text.\n    ErrorPrinter error_collector(error_format_);\n    TextFormat::Parser parser;\n    parser.RecordErrorsTo(&error_collector);\n    parser.AllowPartialMessage(true);\n\n    if (!parser.Parse(&in, message.get())) {\n      std::cerr << \"Failed to parse input.\" << std::endl;\n      return false;\n    }\n  } else {\n    // Input is binary.\n    if (!message->ParsePartialFromZeroCopyStream(&in)) {\n      std::cerr << \"Failed to parse input.\" << std::endl;\n      return false;\n    }\n  }\n\n  if (!message->IsInitialized()) {\n    std::cerr << \"warning:  Input message is missing required fields:  \"\n              << message->InitializationErrorString() << std::endl;\n  }\n\n  if (mode_ == MODE_ENCODE) {\n    // Output is binary.\n    if (!message->SerializePartialToZeroCopyStream(&out)) {\n      std::cerr << \"output: I/O error.\" << std::endl;\n      return false;\n    }\n  } else {\n    // Output is text.\n    if (!TextFormat::Print(*message, &out)) {\n      std::cerr << \"output: I/O error.\" << std::endl;\n      return false;\n    }\n  }\n\n  return true;\n}\n\nbool CommandLineInterface::WriteDescriptorSet(\n    const vector<const FileDescriptor*> parsed_files) {\n  FileDescriptorSet file_set;\n\n  if (imports_in_descriptor_set_) {\n    set<const FileDescriptor*> already_seen;\n    for (int i = 0; i < parsed_files.size(); i++) {\n      GetTransitiveDependencies(parsed_files[i],\n                                true,  // Include json_name\n                                source_info_in_descriptor_set_,\n                                &already_seen, file_set.mutable_file());\n    }\n  } else {\n    set<const FileDescriptor*> already_seen;\n    for (int i = 0; i < parsed_files.size(); i++) {\n      if (!already_seen.insert(parsed_files[i]).second) {\n        continue;\n      }\n      FileDescriptorProto* file_proto = file_set.add_file();\n      parsed_files[i]->CopyTo(file_proto);\n      parsed_files[i]->CopyJsonNameTo(file_proto);\n      if (source_info_in_descriptor_set_) {\n        parsed_files[i]->CopySourceCodeInfoTo(file_proto);\n      }\n    }\n  }\n\n  int fd;\n  do {\n    fd = open(descriptor_set_name_.c_str(),\n              O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);\n  } while (fd < 0 && errno == EINTR);\n\n  if (fd < 0) {\n    perror(descriptor_set_name_.c_str());\n    return false;\n  }\n\n  io::FileOutputStream out(fd);\n  if (!file_set.SerializeToZeroCopyStream(&out)) {\n    std::cerr << descriptor_set_name_ << \": \" << strerror(out.GetErrno())\n              << std::endl;\n    out.Close();\n    return false;\n  }\n  if (!out.Close()) {\n    std::cerr << descriptor_set_name_ << \": \" << strerror(out.GetErrno())\n              << std::endl;\n    return false;\n  }\n\n  return true;\n}\n\nvoid CommandLineInterface::GetTransitiveDependencies(\n    const FileDescriptor* file,\n    bool include_json_name,\n    bool include_source_code_info,\n    set<const FileDescriptor*>* already_seen,\n    RepeatedPtrField<FileDescriptorProto>* output) {\n  if (!already_seen->insert(file).second) {\n    // Already saw this file.  Skip.\n    return;\n  }\n\n  // Add all dependencies.\n  for (int i = 0; i < file->dependency_count(); i++) {\n    GetTransitiveDependencies(file->dependency(i),\n                              include_json_name,\n                              include_source_code_info,\n                              already_seen, output);\n  }\n\n  // Add this file.\n  FileDescriptorProto* new_descriptor = output->Add();\n  file->CopyTo(new_descriptor);\n  if (include_json_name) {\n    file->CopyJsonNameTo(new_descriptor);\n  }\n  if (include_source_code_info) {\n    file->CopySourceCodeInfoTo(new_descriptor);\n  }\n}\n\nnamespace {\n\n// Utility function for PrintFreeFieldNumbers.\n// Stores occupied ranges into the ranges parameter, and next level of sub\n// message types into the nested_messages parameter.  The FieldRange is left\n// inclusive, right exclusive. i.e. [a, b).\n//\n// Nested Messages:\n// Note that it only stores the nested message type, iff the nested type is\n// either a direct child of the given descriptor, or the nested type is a\n// decendent of the given descriptor and all the nodes between the\n// nested type and the given descriptor are group types. e.g.\n//\n// message Foo {\n//   message Bar {\n//     message NestedBar {}\n//   }\n//   group Baz = 1 {\n//     group NestedBazGroup = 2 {\n//       message Quz {\n//         message NestedQuz {}\n//       }\n//     }\n//     message NestedBaz {}\n//   }\n// }\n//\n// In this case, Bar, Quz and NestedBaz will be added into the nested types.\n// Since free field numbers of group types will not be printed, this makes sure\n// the nested message types in groups will not be dropped. The nested_messages\n// parameter will contain the direct children (when groups are ignored in the\n// tree) of the given descriptor for the caller to traverse. The declaration\n// order of the nested messages is also preserved.\ntypedef pair<int, int> FieldRange;\nvoid GatherOccupiedFieldRanges(const Descriptor* descriptor,\n                               set<FieldRange>* ranges,\n                               vector<const Descriptor*>* nested_messages) {\n  set<const Descriptor*> groups;\n  for (int i = 0; i < descriptor->field_count(); ++i) {\n    const FieldDescriptor* fd = descriptor->field(i);\n    ranges->insert(FieldRange(fd->number(), fd->number() + 1));\n    if (fd->type() == FieldDescriptor::TYPE_GROUP) {\n      groups.insert(fd->message_type());\n    }\n  }\n  for (int i = 0; i < descriptor->extension_range_count(); ++i) {\n    ranges->insert(FieldRange(descriptor->extension_range(i)->start,\n                              descriptor->extension_range(i)->end));\n  }\n  for (int i = 0; i < descriptor->reserved_range_count(); ++i) {\n    ranges->insert(FieldRange(descriptor->reserved_range(i)->start,\n                              descriptor->reserved_range(i)->end));\n  }\n  // Handle the nested messages/groups in declaration order to make it\n  // post-order strict.\n  for (int i = 0; i < descriptor->nested_type_count(); ++i) {\n    const Descriptor* nested_desc = descriptor->nested_type(i);\n    if (groups.find(nested_desc) != groups.end()) {\n      GatherOccupiedFieldRanges(nested_desc, ranges, nested_messages);\n    } else {\n      nested_messages->push_back(nested_desc);\n    }\n  }\n}\n\n// Utility function for PrintFreeFieldNumbers.\n// Actually prints the formatted free field numbers for given message name and\n// occupied ranges.\nvoid FormatFreeFieldNumbers(const string& name,\n                            const set<FieldRange>& ranges) {\n  string output;\n  StringAppendF(&output, \"%-35s free:\", name.c_str());\n  int next_free_number = 1;\n  for (set<FieldRange>::const_iterator i = ranges.begin();\n       i != ranges.end(); ++i) {\n    // This happens when groups re-use parent field numbers, in which\n    // case we skip the FieldRange entirely.\n    if (next_free_number >= i->second) continue;\n\n    if (next_free_number < i->first) {\n      if (next_free_number + 1 == i->first) {\n        // Singleton\n        StringAppendF(&output, \" %d\", next_free_number);\n      } else {\n        // Range\n        StringAppendF(&output, \" %d-%d\", next_free_number, i->first - 1);\n      }\n    }\n    next_free_number = i->second;\n  }\n  if (next_free_number <= FieldDescriptor::kMaxNumber) {\n    StringAppendF(&output, \" %d-INF\", next_free_number);\n  }\n  std::cout << output << std::endl;\n}\n\n}  // namespace\n\nvoid CommandLineInterface::PrintFreeFieldNumbers(\n    const Descriptor* descriptor) {\n  set<FieldRange> ranges;\n  vector<const Descriptor*> nested_messages;\n  GatherOccupiedFieldRanges(descriptor, &ranges, &nested_messages);\n\n  for (int i = 0; i < nested_messages.size(); ++i) {\n    PrintFreeFieldNumbers(nested_messages[i]);\n  }\n  FormatFreeFieldNumbers(descriptor->full_name(), ranges);\n}\n\n\n\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/command_line_interface.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Implements the Protocol Compiler front-end such that it may be reused by\n// custom compilers written to support other languages.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_COMMAND_LINE_INTERFACE_H__\n#define GOOGLE_PROTOBUF_COMPILER_COMMAND_LINE_INTERFACE_H__\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/hash.h>\n#include <string>\n#include <vector>\n#include <map>\n#include <set>\n#include <utility>\n\nnamespace google {\nnamespace protobuf {\n\nclass Descriptor;            // descriptor.h\nclass DescriptorPool;        // descriptor.h\nclass FileDescriptor;        // descriptor.h\nclass FileDescriptorProto;   // descriptor.pb.h\ntemplate<typename T> class RepeatedPtrField;  // repeated_field.h\n\nnamespace compiler {\n\nclass CodeGenerator;        // code_generator.h\nclass GeneratorContext;      // code_generator.h\nclass DiskSourceTree;       // importer.h\n\n// This class implements the command-line interface to the protocol compiler.\n// It is designed to make it very easy to create a custom protocol compiler\n// supporting the languages of your choice.  For example, if you wanted to\n// create a custom protocol compiler binary which includes both the regular\n// C++ support plus support for your own custom output \"Foo\", you would\n// write a class \"FooGenerator\" which implements the CodeGenerator interface,\n// then write a main() procedure like this:\n//\n//   int main(int argc, char* argv[]) {\n//     google::protobuf::compiler::CommandLineInterface cli;\n//\n//     // Support generation of C++ source and headers.\n//     google::protobuf::compiler::cpp::CppGenerator cpp_generator;\n//     cli.RegisterGenerator(\"--cpp_out\", &cpp_generator,\n//       \"Generate C++ source and header.\");\n//\n//     // Support generation of Foo code.\n//     FooGenerator foo_generator;\n//     cli.RegisterGenerator(\"--foo_out\", &foo_generator,\n//       \"Generate Foo file.\");\n//\n//     return cli.Run(argc, argv);\n//   }\n//\n// The compiler is invoked with syntax like:\n//   protoc --cpp_out=outdir --foo_out=outdir --proto_path=src src/foo.proto\n//\n// For a full description of the command-line syntax, invoke it with --help.\nclass LIBPROTOC_EXPORT CommandLineInterface {\n public:\n  CommandLineInterface();\n  ~CommandLineInterface();\n\n  // Register a code generator for a language.\n  //\n  // Parameters:\n  // * flag_name: The command-line flag used to specify an output file of\n  //   this type.  The name must start with a '-'.  If the name is longer\n  //   than one letter, it must start with two '-'s.\n  // * generator: The CodeGenerator which will be called to generate files\n  //   of this type.\n  // * help_text: Text describing this flag in the --help output.\n  //\n  // Some generators accept extra parameters.  You can specify this parameter\n  // on the command-line by placing it before the output directory, separated\n  // by a colon:\n  //   protoc --foo_out=enable_bar:outdir\n  // The text before the colon is passed to CodeGenerator::Generate() as the\n  // \"parameter\".\n  void RegisterGenerator(const string& flag_name,\n                         CodeGenerator* generator,\n                         const string& help_text);\n\n  // Register a code generator for a language.\n  // Besides flag_name you can specify another option_flag_name that could be\n  // used to pass extra parameters to the registered code generator.\n  // Suppose you have registered a generator by calling:\n  //   command_line_interface.RegisterGenerator(\"--foo_out\", \"--foo_opt\", ...)\n  // Then you could invoke the compiler with a command like:\n  //   protoc --foo_out=enable_bar:outdir --foo_opt=enable_baz\n  // This will pass \"enable_bar,enable_baz\" as the parameter to the generator.\n  void RegisterGenerator(const string& flag_name,\n                         const string& option_flag_name,\n                         CodeGenerator* generator,\n                         const string& help_text);\n\n  // Enables \"plugins\".  In this mode, if a command-line flag ends with \"_out\"\n  // but does not match any registered generator, the compiler will attempt to\n  // find a \"plugin\" to implement the generator.  Plugins are just executables.\n  // They should live somewhere in the PATH.\n  //\n  // The compiler determines the executable name to search for by concatenating\n  // exe_name_prefix with the unrecognized flag name, removing \"_out\".  So, for\n  // example, if exe_name_prefix is \"protoc-\" and you pass the flag --foo_out,\n  // the compiler will try to run the program \"protoc-foo\".\n  //\n  // The plugin program should implement the following usage:\n  //   plugin [--out=OUTDIR] [--parameter=PARAMETER] PROTO_FILES < DESCRIPTORS\n  // --out indicates the output directory (as passed to the --foo_out\n  // parameter); if omitted, the current directory should be used.  --parameter\n  // gives the generator parameter, if any was provided.  The PROTO_FILES list\n  // the .proto files which were given on the compiler command-line; these are\n  // the files for which the plugin is expected to generate output code.\n  // Finally, DESCRIPTORS is an encoded FileDescriptorSet (as defined in\n  // descriptor.proto).  This is piped to the plugin's stdin.  The set will\n  // include descriptors for all the files listed in PROTO_FILES as well as\n  // all files that they import.  The plugin MUST NOT attempt to read the\n  // PROTO_FILES directly -- it must use the FileDescriptorSet.\n  //\n  // The plugin should generate whatever files are necessary, as code generators\n  // normally do.  It should write the names of all files it generates to\n  // stdout.  The names should be relative to the output directory, NOT absolute\n  // names or relative to the current directory.  If any errors occur, error\n  // messages should be written to stderr.  If an error is fatal, the plugin\n  // should exit with a non-zero exit code.\n  void AllowPlugins(const string& exe_name_prefix);\n\n  // Run the Protocol Compiler with the given command-line parameters.\n  // Returns the error code which should be returned by main().\n  //\n  // It may not be safe to call Run() in a multi-threaded environment because\n  // it calls strerror().  I'm not sure why you'd want to do this anyway.\n  int Run(int argc, const char* const argv[]);\n\n  // Call SetInputsAreCwdRelative(true) if the input files given on the command\n  // line should be interpreted relative to the proto import path specified\n  // using --proto_path or -I flags.  Otherwise, input file names will be\n  // interpreted relative to the current working directory (or as absolute\n  // paths if they start with '/'), though they must still reside inside\n  // a directory given by --proto_path or the compiler will fail.  The latter\n  // mode is generally more intuitive and easier to use, especially e.g. when\n  // defining implicit rules in Makefiles.\n  void SetInputsAreProtoPathRelative(bool enable) {\n    inputs_are_proto_path_relative_ = enable;\n  }\n\n  // Provides some text which will be printed when the --version flag is\n  // used.  The version of libprotoc will also be printed on the next line\n  // after this text.\n  void SetVersionInfo(const string& text) {\n    version_info_ = text;\n  }\n\n\n private:\n  // -----------------------------------------------------------------\n\n  class ErrorPrinter;\n  class GeneratorContextImpl;\n  class MemoryOutputStream;\n  typedef hash_map<string, GeneratorContextImpl*> GeneratorContextMap;\n\n  // Clear state from previous Run().\n  void Clear();\n\n  // Remaps each file in input_files_ so that it is relative to one of the\n  // directories in proto_path_.  Returns false if an error occurred.  This\n  // is only used if inputs_are_proto_path_relative_ is false.\n  bool MakeInputsBeProtoPathRelative(\n    DiskSourceTree* source_tree);\n\n  // Return status for ParseArguments() and InterpretArgument().\n  enum ParseArgumentStatus {\n    PARSE_ARGUMENT_DONE_AND_CONTINUE,\n    PARSE_ARGUMENT_DONE_AND_EXIT,\n    PARSE_ARGUMENT_FAIL\n  };\n\n  // Parse all command-line arguments.\n  ParseArgumentStatus ParseArguments(int argc, const char* const argv[]);\n\n\n  // Parses a command-line argument into a name/value pair.  Returns\n  // true if the next argument in the argv should be used as the value,\n  // false otherwise.\n  //\n  // Examples:\n  //   \"-Isrc/protos\" ->\n  //     name = \"-I\", value = \"src/protos\"\n  //   \"--cpp_out=src/foo.pb2.cc\" ->\n  //     name = \"--cpp_out\", value = \"src/foo.pb2.cc\"\n  //   \"foo.proto\" ->\n  //     name = \"\", value = \"foo.proto\"\n  bool ParseArgument(const char* arg, string* name, string* value);\n\n  // Interprets arguments parsed with ParseArgument.\n  ParseArgumentStatus InterpretArgument(const string& name,\n                                        const string& value);\n\n  // Print the --help text to stderr.\n  void PrintHelpText();\n\n  // Generate the given output file from the given input.\n  struct OutputDirective;  // see below\n  bool GenerateOutput(const vector<const FileDescriptor*>& parsed_files,\n                      const OutputDirective& output_directive,\n                      GeneratorContext* generator_context);\n  bool GeneratePluginOutput(const vector<const FileDescriptor*>& parsed_files,\n                            const string& plugin_name,\n                            const string& parameter,\n                            GeneratorContext* generator_context,\n                            string* error);\n\n  // Implements --encode and --decode.\n  bool EncodeOrDecode(const DescriptorPool* pool);\n\n  // Implements the --descriptor_set_out option.\n  bool WriteDescriptorSet(const vector<const FileDescriptor*> parsed_files);\n\n  // Implements the --dependency_out option\n  bool GenerateDependencyManifestFile(\n      const vector<const FileDescriptor*>& parsed_files,\n      const GeneratorContextMap& output_directories,\n      DiskSourceTree* source_tree);\n\n  // Get all transitive dependencies of the given file (including the file\n  // itself), adding them to the given list of FileDescriptorProtos.  The\n  // protos will be ordered such that every file is listed before any file that\n  // depends on it, so that you can call DescriptorPool::BuildFile() on them\n  // in order.  Any files in *already_seen will not be added, and each file\n  // added will be inserted into *already_seen.  If include_source_code_info is\n  // true then include the source code information in the FileDescriptorProtos.\n  // If include_json_name is true, populate the json_name field of\n  // FieldDescriptorProto for all fields.\n  static void GetTransitiveDependencies(\n      const FileDescriptor* file,\n      bool include_json_name,\n      bool include_source_code_info,\n      set<const FileDescriptor*>* already_seen,\n      RepeatedPtrField<FileDescriptorProto>* output);\n\n  // Implements the --print_free_field_numbers. This function prints free field\n  // numbers into stdout for the message and it's nested message types in\n  // post-order, i.e. nested types first. Printed range are left-right\n  // inclusive, i.e. [a, b].\n  //\n  // Groups:\n  // For historical reasons, groups are considered to share the same\n  // field number space with the parent message, thus it will not print free\n  // field numbers for groups. The field numbers used in the groups are\n  // excluded in the free field numbers of the parent message.\n  //\n  // Extension Ranges:\n  // Extension ranges are considered ocuppied field numbers and they will not be\n  // listed as free numbers in the output.\n  void PrintFreeFieldNumbers(const Descriptor* descriptor);\n\n  // -----------------------------------------------------------------\n\n  // The name of the executable as invoked (i.e. argv[0]).\n  string executable_name_;\n\n  // Version info set with SetVersionInfo().\n  string version_info_;\n\n  // Registered generators.\n  struct GeneratorInfo {\n    string flag_name;\n    string option_flag_name;\n    CodeGenerator* generator;\n    string help_text;\n  };\n  typedef map<string, GeneratorInfo> GeneratorMap;\n  GeneratorMap generators_by_flag_name_;\n  GeneratorMap generators_by_option_name_;\n  // A map from generator names to the parameters specified using the option\n  // flag. For example, if the user invokes the compiler with:\n  //   protoc --foo_out=outputdir --foo_opt=enable_bar ...\n  // Then there will be an entry (\"--foo_out\", \"enable_bar\") in this map.\n  map<string, string> generator_parameters_;\n\n  // See AllowPlugins().  If this is empty, plugins aren't allowed.\n  string plugin_prefix_;\n\n  // Maps specific plugin names to files.  When executing a plugin, this map\n  // is searched first to find the plugin executable.  If not found here, the\n  // PATH (or other OS-specific search strategy) is searched.\n  map<string, string> plugins_;\n\n  // Stuff parsed from command line.\n  enum Mode {\n    MODE_COMPILE,  // Normal mode:  parse .proto files and compile them.\n    MODE_ENCODE,   // --encode:  read text from stdin, write binary to stdout.\n    MODE_DECODE,   // --decode:  read binary from stdin, write text to stdout.\n    MODE_PRINT,    // Print mode: print info of the given .proto files and exit.\n  };\n\n  Mode mode_;\n\n  enum PrintMode {\n    PRINT_NONE,               // Not in MODE_PRINT\n    PRINT_FREE_FIELDS,        // --print_free_fields\n  };\n\n  PrintMode print_mode_;\n\n  enum ErrorFormat {\n    ERROR_FORMAT_GCC,   // GCC error output format (default).\n    ERROR_FORMAT_MSVS   // Visual Studio output (--error_format=msvs).\n  };\n\n  ErrorFormat error_format_;\n\n  vector<pair<string, string> > proto_path_;  // Search path for proto files.\n  vector<string> input_files_;                // Names of the input proto files.\n\n  // output_directives_ lists all the files we are supposed to output and what\n  // generator to use for each.\n  struct OutputDirective {\n    string name;                // E.g. \"--foo_out\"\n    CodeGenerator* generator;   // NULL for plugins\n    string parameter;\n    string output_location;\n  };\n  vector<OutputDirective> output_directives_;\n\n  // When using --encode or --decode, this names the type we are encoding or\n  // decoding.  (Empty string indicates --decode_raw.)\n  string codec_type_;\n\n  // If --descriptor_set_out was given, this is the filename to which the\n  // FileDescriptorSet should be written.  Otherwise, empty.\n  string descriptor_set_name_;\n\n  // If --dependency_out was given, this is the path to the file where the\n  // dependency file will be written. Otherwise, empty.\n  string dependency_out_name_;\n\n  // True if --include_imports was given, meaning that we should\n  // write all transitive dependencies to the DescriptorSet.  Otherwise, only\n  // the .proto files listed on the command-line are added.\n  bool imports_in_descriptor_set_;\n\n  // True if --include_source_info was given, meaning that we should not strip\n  // SourceCodeInfo from the DescriptorSet.\n  bool source_info_in_descriptor_set_;\n\n  // Was the --disallow_services flag used?\n  bool disallow_services_;\n\n  // See SetInputsAreProtoPathRelative().\n  bool inputs_are_proto_path_relative_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CommandLineInterface);\n};\n\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_COMMAND_LINE_INTERFACE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/command_line_interface_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n#ifdef _MSC_VER\n#include <io.h>\n#else\n#include <unistd.h>\n#endif\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <vector>\n\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/compiler/command_line_interface.h>\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/compiler/mock_code_generator.h>\n#include <google/protobuf/compiler/subprocess.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\n\n// Disable the whole test when we use tcmalloc for \"draconian\" heap checks, in\n// which case tcmalloc will print warnings that fail the plugin tests.\n#if !GOOGLE_PROTOBUF_HEAP_CHECK_DRACONIAN\n\n#if defined(_WIN32)\n#ifndef STDIN_FILENO\n#define STDIN_FILENO 0\n#endif\n#ifndef STDOUT_FILENO\n#define STDOUT_FILENO 1\n#endif\n#ifndef F_OK\n#define F_OK 00  // not defined by MSVC for whatever reason\n#endif\n#endif\n\nnamespace {\n\nbool FileExists(const string& path) {\n  return File::Exists(path);\n}\n\nclass CommandLineInterfaceTest : public testing::Test {\n protected:\n  virtual void SetUp();\n  virtual void TearDown();\n\n  // Runs the CommandLineInterface with the given command line.  The\n  // command is automatically split on spaces, and the string \"$tmpdir\"\n  // is replaced with TestTempDir().\n  void Run(const string& command);\n\n  // -----------------------------------------------------------------\n  // Methods to set up the test (called before Run()).\n\n  class NullCodeGenerator;\n\n  // Normally plugins are allowed for all tests.  Call this to explicitly\n  // disable them.\n  void DisallowPlugins() { disallow_plugins_ = true; }\n\n  // Create a temp file within temp_directory_ with the given name.\n  // The containing directory is also created if necessary.\n  void CreateTempFile(const string& name, const string& contents);\n\n  // Create a subdirectory within temp_directory_.\n  void CreateTempDir(const string& name);\n\n#ifdef PROTOBUF_OPENSOURCE\n  // Change working directory to temp directory.\n  void SwitchToTempDirectory() {\n    File::ChangeWorkingDirectory(temp_directory_);\n  }\n#else  // !PROTOBUF_OPENSOURCE\n  // TODO(teboring): Figure out how to change and get working directory in\n  // google3.\n#endif  // !PROTOBUF_OPENSOURCE\n\n  void SetInputsAreProtoPathRelative(bool enable) {\n    cli_.SetInputsAreProtoPathRelative(enable);\n  }\n\n  // -----------------------------------------------------------------\n  // Methods to check the test results (called after Run()).\n\n  // Checks that no text was written to stderr during Run(), and Run()\n  // returned 0.\n  void ExpectNoErrors();\n\n  // Checks that Run() returned non-zero and the stderr output is exactly\n  // the text given.  expected_test may contain references to \"$tmpdir\",\n  // which will be replaced by the temporary directory path.\n  void ExpectErrorText(const string& expected_text);\n\n  // Checks that Run() returned non-zero and the stderr contains the given\n  // substring.\n  void ExpectErrorSubstring(const string& expected_substring);\n\n  // Like ExpectErrorSubstring, but checks that Run() returned zero.\n  void ExpectErrorSubstringWithZeroReturnCode(\n      const string& expected_substring);\n\n  // Checks that the captured stdout is the same as the expected_text.\n  void ExpectCapturedStdout(const string& expected_text);\n\n  // Returns true if ExpectErrorSubstring(expected_substring) would pass, but\n  // does not fail otherwise.\n  bool HasAlternateErrorSubstring(const string& expected_substring);\n\n  // Checks that MockCodeGenerator::Generate() was called in the given\n  // context (or the generator in test_plugin.cc, which produces the same\n  // output).  That is, this tests if the generator with the given name\n  // was called with the given parameter and proto file and produced the\n  // given output file.  This is checked by reading the output file and\n  // checking that it contains the content that MockCodeGenerator would\n  // generate given these inputs.  message_name is the name of the first\n  // message that appeared in the proto file; this is just to make extra\n  // sure that the correct file was parsed.\n  void ExpectGenerated(const string& generator_name,\n                       const string& parameter,\n                       const string& proto_name,\n                       const string& message_name);\n  void ExpectGenerated(const string& generator_name,\n                       const string& parameter,\n                       const string& proto_name,\n                       const string& message_name,\n                       const string& output_directory);\n  void ExpectGeneratedWithMultipleInputs(const string& generator_name,\n                                         const string& all_proto_names,\n                                         const string& proto_name,\n                                         const string& message_name);\n  void ExpectGeneratedWithInsertions(const string& generator_name,\n                                     const string& parameter,\n                                     const string& insertions,\n                                     const string& proto_name,\n                                     const string& message_name);\n\n  void ExpectNullCodeGeneratorCalled(const string& parameter);\n\n  void ReadDescriptorSet(const string& filename,\n                         FileDescriptorSet* descriptor_set);\n\n  void ExpectFileContent(const string& filename,\n                         const string& content);\n\n private:\n  // The object we are testing.\n  CommandLineInterface cli_;\n\n  // Was DisallowPlugins() called?\n  bool disallow_plugins_;\n\n  // We create a directory within TestTempDir() in order to add extra\n  // protection against accidentally deleting user files (since we recursively\n  // delete this directory during the test).  This is the full path of that\n  // directory.\n  string temp_directory_;\n\n  // The result of Run().\n  int return_code_;\n\n  // The captured stderr output.\n  string error_text_;\n\n  // The captured stdout.\n  string captured_stdout_;\n\n  // Pointers which need to be deleted later.\n  vector<CodeGenerator*> mock_generators_to_delete_;\n\n  NullCodeGenerator* null_generator_;\n};\n\nclass CommandLineInterfaceTest::NullCodeGenerator : public CodeGenerator {\n public:\n  NullCodeGenerator() : called_(false) {}\n  ~NullCodeGenerator() {}\n\n  mutable bool called_;\n  mutable string parameter_;\n\n  // implements CodeGenerator ----------------------------------------\n  bool Generate(const FileDescriptor* file,\n                const string& parameter,\n                GeneratorContext* context,\n                string* error) const {\n    called_ = true;\n    parameter_ = parameter;\n    return true;\n  }\n};\n\n// ===================================================================\n\nvoid CommandLineInterfaceTest::SetUp() {\n  // Most of these tests were written before this option was added, so we\n  // run with the option on (which used to be the only way) except in certain\n  // tests where we turn it off.\n  cli_.SetInputsAreProtoPathRelative(true);\n\n  temp_directory_ = TestTempDir() + \"/proto2_cli_test_temp\";\n\n  // If the temp directory already exists, it must be left over from a\n  // previous run.  Delete it.\n  if (FileExists(temp_directory_)) {\n    File::DeleteRecursively(temp_directory_, NULL, NULL);\n  }\n\n  // Create the temp directory.\n  GOOGLE_CHECK_OK(File::CreateDir(temp_directory_, 0777));\n\n  // Register generators.\n  CodeGenerator* generator = new MockCodeGenerator(\"test_generator\");\n  mock_generators_to_delete_.push_back(generator);\n  cli_.RegisterGenerator(\"--test_out\", \"--test_opt\", generator, \"Test output.\");\n  cli_.RegisterGenerator(\"-t\", generator, \"Test output.\");\n\n  generator = new MockCodeGenerator(\"alt_generator\");\n  mock_generators_to_delete_.push_back(generator);\n  cli_.RegisterGenerator(\"--alt_out\", generator, \"Alt output.\");\n\n  generator = null_generator_ = new NullCodeGenerator();\n  mock_generators_to_delete_.push_back(generator);\n  cli_.RegisterGenerator(\"--null_out\", generator, \"Null output.\");\n\n  disallow_plugins_ = false;\n}\n\nvoid CommandLineInterfaceTest::TearDown() {\n  // Delete the temp directory.\n  if (FileExists(temp_directory_)) {\n    File::DeleteRecursively(temp_directory_, NULL, NULL);\n  }\n\n  // Delete all the MockCodeGenerators.\n  for (int i = 0; i < mock_generators_to_delete_.size(); i++) {\n    delete mock_generators_to_delete_[i];\n  }\n  mock_generators_to_delete_.clear();\n}\n\nvoid CommandLineInterfaceTest::Run(const string& command) {\n  vector<string> args = Split(command, \" \", true);\n\n  if (!disallow_plugins_) {\n    cli_.AllowPlugins(\"prefix-\");\n#ifndef GOOGLE_THIRD_PARTY_PROTOBUF\n    string plugin_path;\n#ifdef GOOGLE_PROTOBUF_TEST_PLUGIN_PATH\n    plugin_path = GOOGLE_PROTOBUF_TEST_PLUGIN_PATH;\n#else\n    const char* possible_paths[] = {\n      // When building with shared libraries, libtool hides the real executable\n      // in .libs and puts a fake wrapper in the current directory.\n      // Unfortunately, due to an apparent bug on Cygwin/MinGW, if one program\n      // wrapped in this way (e.g. protobuf-tests.exe) tries to execute another\n      // program wrapped in this way (e.g. test_plugin.exe), the latter fails\n      // with error code 127 and no explanation message.  Presumably the problem\n      // is that the wrapper for protobuf-tests.exe set some environment\n      // variables that confuse the wrapper for test_plugin.exe.  Luckily, it\n      // turns out that if we simply invoke the wrapped test_plugin.exe\n      // directly, it works -- I guess the environment variables set by the\n      // protobuf-tests.exe wrapper happen to be correct for it too.  So we do\n      // that.\n      \".libs/test_plugin.exe\",  // Win32 w/autotool (Cygwin / MinGW)\n      \"test_plugin.exe\",        // Other Win32 (MSVC)\n      \"test_plugin\",            // Unix\n    };\n    for (int i = 0; i < GOOGLE_ARRAYSIZE(possible_paths); i++) {\n      if (access(possible_paths[i], F_OK) == 0) {\n        plugin_path = possible_paths[i];\n        break;\n      }\n    }\n#endif\n\n    if (plugin_path.empty()) {\n#else\n    string plugin_path = \"third_party/protobuf/test_plugin\";\n\n    if (access(plugin_path.c_str(), F_OK) != 0) {\n#endif  // GOOGLE_THIRD_PARTY_PROTOBUF\n      GOOGLE_LOG(ERROR)\n          << \"Plugin executable not found.  Plugin tests are likely to fail.\";\n    } else {\n      args.push_back(\"--plugin=prefix-gen-plug=\" + plugin_path);\n    }\n  }\n\n  google::protobuf::scoped_array<const char * > argv(new const char* [args.size()]);\n\n  for (int i = 0; i < args.size(); i++) {\n    args[i] = StringReplace(args[i], \"$tmpdir\", temp_directory_, true);\n    argv[i] = args[i].c_str();\n  }\n\n  // TODO(jieluo): Cygwin doesn't work well if we try to capture stderr and\n  // stdout at the same time. Need to figure out why and add this capture back\n  // for Cygwin.\n#if !defined(__CYGWIN__)\n  CaptureTestStdout();\n#endif\n  CaptureTestStderr();\n\n  return_code_ = cli_.Run(args.size(), argv.get());\n\n  error_text_ = GetCapturedTestStderr();\n#if !defined(__CYGWIN__)\n  captured_stdout_ = GetCapturedTestStdout();\n#endif\n}\n\n// -------------------------------------------------------------------\n\nvoid CommandLineInterfaceTest::CreateTempFile(\n    const string& name,\n    const string& contents) {\n  // Create parent directory, if necessary.\n  string::size_type slash_pos = name.find_last_of('/');\n  if (slash_pos != string::npos) {\n    string dir = name.substr(0, slash_pos);\n    if (!FileExists(temp_directory_ + \"/\" + dir)) {\n      GOOGLE_CHECK_OK(File::RecursivelyCreateDir(temp_directory_ + \"/\" + dir,\n                                          0777));\n    }\n  }\n\n  // Write file.\n  string full_name = temp_directory_ + \"/\" + name;\n  GOOGLE_CHECK_OK(File::SetContents(\n      full_name, StringReplace(contents, \"$tmpdir\", temp_directory_, true),\n      true));\n}\n\nvoid CommandLineInterfaceTest::CreateTempDir(const string& name) {\n  GOOGLE_CHECK_OK(File::RecursivelyCreateDir(temp_directory_ + \"/\" + name,\n                                      0777));\n}\n\n// -------------------------------------------------------------------\n\nvoid CommandLineInterfaceTest::ExpectNoErrors() {\n  EXPECT_EQ(0, return_code_);\n  EXPECT_EQ(\"\", error_text_);\n}\n\nvoid CommandLineInterfaceTest::ExpectErrorText(const string& expected_text) {\n  EXPECT_NE(0, return_code_);\n  EXPECT_EQ(StringReplace(expected_text, \"$tmpdir\", temp_directory_, true),\n            error_text_);\n}\n\nvoid CommandLineInterfaceTest::ExpectErrorSubstring(\n    const string& expected_substring) {\n  EXPECT_NE(0, return_code_);\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, expected_substring, error_text_);\n}\n\nvoid CommandLineInterfaceTest::ExpectErrorSubstringWithZeroReturnCode(\n    const string& expected_substring) {\n  EXPECT_EQ(0, return_code_);\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, expected_substring, error_text_);\n}\n\nbool CommandLineInterfaceTest::HasAlternateErrorSubstring(\n    const string& expected_substring) {\n  EXPECT_NE(0, return_code_);\n  return error_text_.find(expected_substring) != string::npos;\n}\n\nvoid CommandLineInterfaceTest::ExpectGenerated(\n    const string& generator_name,\n    const string& parameter,\n    const string& proto_name,\n    const string& message_name) {\n  MockCodeGenerator::ExpectGenerated(\n      generator_name, parameter, \"\", proto_name, message_name, proto_name,\n      temp_directory_);\n}\n\nvoid CommandLineInterfaceTest::ExpectGenerated(\n    const string& generator_name,\n    const string& parameter,\n    const string& proto_name,\n    const string& message_name,\n    const string& output_directory) {\n  MockCodeGenerator::ExpectGenerated(\n      generator_name, parameter, \"\", proto_name, message_name, proto_name,\n      temp_directory_ + \"/\" + output_directory);\n}\n\nvoid CommandLineInterfaceTest::ExpectGeneratedWithMultipleInputs(\n    const string& generator_name,\n    const string& all_proto_names,\n    const string& proto_name,\n    const string& message_name) {\n  MockCodeGenerator::ExpectGenerated(\n      generator_name, \"\", \"\", proto_name, message_name,\n      all_proto_names,\n      temp_directory_);\n}\n\nvoid CommandLineInterfaceTest::ExpectGeneratedWithInsertions(\n    const string& generator_name,\n    const string& parameter,\n    const string& insertions,\n    const string& proto_name,\n    const string& message_name) {\n  MockCodeGenerator::ExpectGenerated(\n      generator_name, parameter, insertions, proto_name, message_name,\n      proto_name, temp_directory_);\n}\n\nvoid CommandLineInterfaceTest::ExpectNullCodeGeneratorCalled(\n    const string& parameter) {\n  EXPECT_TRUE(null_generator_->called_);\n  EXPECT_EQ(parameter, null_generator_->parameter_);\n}\n\nvoid CommandLineInterfaceTest::ReadDescriptorSet(\n    const string& filename, FileDescriptorSet* descriptor_set) {\n  string path = temp_directory_ + \"/\" + filename;\n  string file_contents;\n  GOOGLE_CHECK_OK(File::GetContents(path, &file_contents, true));\n\n  if (!descriptor_set->ParseFromString(file_contents)) {\n    FAIL() << \"Could not parse file contents: \" << path;\n  }\n}\n\nvoid CommandLineInterfaceTest::ExpectCapturedStdout(\n    const string& expected_text) {\n  EXPECT_EQ(expected_text, captured_stdout_);\n}\n\n\nvoid CommandLineInterfaceTest::ExpectFileContent(\n    const string& filename, const string& content) {\n  string path = temp_directory_ + \"/\" + filename;\n  string file_contents;\n  GOOGLE_CHECK_OK(File::GetContents(path, &file_contents, true));\n\n  EXPECT_EQ(StringReplace(content, \"$tmpdir\", temp_directory_, true),\n            file_contents);\n}\n\n// ===================================================================\n\nTEST_F(CommandLineInterfaceTest, BasicOutput) {\n  // Test that the common case works.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  Run(\"protocol_compiler --test_out=$tmpdir \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectNoErrors();\n  ExpectGenerated(\"test_generator\", \"\", \"foo.proto\", \"Foo\");\n}\n\nTEST_F(CommandLineInterfaceTest, BasicPlugin) {\n  // Test that basic plugins work.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  Run(\"protocol_compiler --plug_out=$tmpdir \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectNoErrors();\n  ExpectGenerated(\"test_plugin\", \"\", \"foo.proto\", \"Foo\");\n}\n\nTEST_F(CommandLineInterfaceTest, GeneratorAndPlugin) {\n  // Invoke a generator and a plugin at the same time.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  Run(\"protocol_compiler --test_out=$tmpdir --plug_out=$tmpdir \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectNoErrors();\n  ExpectGenerated(\"test_generator\", \"\", \"foo.proto\", \"Foo\");\n  ExpectGenerated(\"test_plugin\", \"\", \"foo.proto\", \"Foo\");\n}\n\nTEST_F(CommandLineInterfaceTest, MultipleInputs) {\n  // Test parsing multiple input files.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n  CreateTempFile(\"bar.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Bar {}\\n\");\n\n  Run(\"protocol_compiler --test_out=$tmpdir --plug_out=$tmpdir \"\n      \"--proto_path=$tmpdir foo.proto bar.proto\");\n\n  ExpectNoErrors();\n  ExpectGeneratedWithMultipleInputs(\"test_generator\", \"foo.proto,bar.proto\",\n                                    \"foo.proto\", \"Foo\");\n  ExpectGeneratedWithMultipleInputs(\"test_generator\", \"foo.proto,bar.proto\",\n                                    \"bar.proto\", \"Bar\");\n  ExpectGeneratedWithMultipleInputs(\"test_plugin\", \"foo.proto,bar.proto\",\n                                    \"foo.proto\", \"Foo\");\n  ExpectGeneratedWithMultipleInputs(\"test_plugin\", \"foo.proto,bar.proto\",\n                                    \"bar.proto\", \"Bar\");\n}\n\nTEST_F(CommandLineInterfaceTest, MultipleInputsWithImport) {\n  // Test parsing multiple input files with an import of a separate file.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n  CreateTempFile(\"bar.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"import \\\"baz.proto\\\";\\n\"\n    \"message Bar {\\n\"\n    \"  optional Baz a = 1;\\n\"\n    \"}\\n\");\n  CreateTempFile(\"baz.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Baz {}\\n\");\n\n  Run(\"protocol_compiler --test_out=$tmpdir --plug_out=$tmpdir \"\n      \"--proto_path=$tmpdir foo.proto bar.proto\");\n\n  ExpectNoErrors();\n  ExpectGeneratedWithMultipleInputs(\"test_generator\", \"foo.proto,bar.proto\",\n                                    \"foo.proto\", \"Foo\");\n  ExpectGeneratedWithMultipleInputs(\"test_generator\", \"foo.proto,bar.proto\",\n                                    \"bar.proto\", \"Bar\");\n  ExpectGeneratedWithMultipleInputs(\"test_plugin\", \"foo.proto,bar.proto\",\n                                    \"foo.proto\", \"Foo\");\n  ExpectGeneratedWithMultipleInputs(\"test_plugin\", \"foo.proto,bar.proto\",\n                                    \"bar.proto\", \"Bar\");\n}\n\nTEST_F(CommandLineInterfaceTest, CreateDirectory) {\n  // Test that when we output to a sub-directory, it is created.\n\n  CreateTempFile(\"bar/baz/foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n  CreateTempDir(\"out\");\n  CreateTempDir(\"plugout\");\n\n  Run(\"protocol_compiler --test_out=$tmpdir/out --plug_out=$tmpdir/plugout \"\n      \"--proto_path=$tmpdir bar/baz/foo.proto\");\n\n  ExpectNoErrors();\n  ExpectGenerated(\"test_generator\", \"\", \"bar/baz/foo.proto\", \"Foo\", \"out\");\n  ExpectGenerated(\"test_plugin\", \"\", \"bar/baz/foo.proto\", \"Foo\", \"plugout\");\n}\n\nTEST_F(CommandLineInterfaceTest, GeneratorParameters) {\n  // Test that generator parameters are correctly parsed from the command line.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  Run(\"protocol_compiler --test_out=TestParameter:$tmpdir \"\n      \"--plug_out=TestPluginParameter:$tmpdir \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectNoErrors();\n  ExpectGenerated(\"test_generator\", \"TestParameter\", \"foo.proto\", \"Foo\");\n  ExpectGenerated(\"test_plugin\", \"TestPluginParameter\", \"foo.proto\", \"Foo\");\n}\n\nTEST_F(CommandLineInterfaceTest, ExtraGeneratorParameters) {\n  // Test that generator parameters specified with the option flag are\n  // correctly passed to the code generator.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n  // Create the \"a\" and \"b\" sub-directories.\n  CreateTempDir(\"a\");\n  CreateTempDir(\"b\");\n\n  Run(\"protocol_compiler \"\n      \"--test_opt=foo1 \"\n      \"--test_out=bar:$tmpdir/a \"\n      \"--test_opt=foo2 \"\n      \"--test_out=baz:$tmpdir/b \"\n      \"--test_opt=foo3 \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectNoErrors();\n  ExpectGenerated(\n      \"test_generator\", \"bar,foo1,foo2,foo3\", \"foo.proto\", \"Foo\", \"a\");\n  ExpectGenerated(\n      \"test_generator\", \"baz,foo1,foo2,foo3\", \"foo.proto\", \"Foo\", \"b\");\n}\n\nTEST_F(CommandLineInterfaceTest, Insert) {\n  // Test running a generator that inserts code into another's output.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  Run(\"protocol_compiler \"\n      \"--test_out=TestParameter:$tmpdir \"\n      \"--plug_out=TestPluginParameter:$tmpdir \"\n      \"--test_out=insert=test_generator,test_plugin:$tmpdir \"\n      \"--plug_out=insert=test_generator,test_plugin:$tmpdir \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectNoErrors();\n  ExpectGeneratedWithInsertions(\n      \"test_generator\", \"TestParameter\", \"test_generator,test_plugin\",\n      \"foo.proto\", \"Foo\");\n  ExpectGeneratedWithInsertions(\n      \"test_plugin\", \"TestPluginParameter\", \"test_generator,test_plugin\",\n      \"foo.proto\", \"Foo\");\n}\n\n#if defined(_WIN32)\n\nTEST_F(CommandLineInterfaceTest, WindowsOutputPath) {\n  // Test that the output path can be a Windows-style path.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\");\n\n  Run(\"protocol_compiler --null_out=C:\\\\ \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectNoErrors();\n  ExpectNullCodeGeneratorCalled(\"\");\n}\n\nTEST_F(CommandLineInterfaceTest, WindowsOutputPathAndParameter) {\n  // Test that we can have a windows-style output path and a parameter.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\");\n\n  Run(\"protocol_compiler --null_out=bar:C:\\\\ \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectNoErrors();\n  ExpectNullCodeGeneratorCalled(\"bar\");\n}\n\nTEST_F(CommandLineInterfaceTest, TrailingBackslash) {\n  // Test that the directories can end in backslashes.  Some users claim this\n  // doesn't work on their system.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  Run(\"protocol_compiler --test_out=$tmpdir\\\\ \"\n      \"--proto_path=$tmpdir\\\\ foo.proto\");\n\n  ExpectNoErrors();\n  ExpectGenerated(\"test_generator\", \"\", \"foo.proto\", \"Foo\");\n}\n\n#endif  // defined(_WIN32) || defined(__CYGWIN__)\n\nTEST_F(CommandLineInterfaceTest, PathLookup) {\n  // Test that specifying multiple directories in the proto search path works.\n\n  CreateTempFile(\"b/bar.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Bar {}\\n\");\n  CreateTempFile(\"a/foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"import \\\"bar.proto\\\";\\n\"\n    \"message Foo {\\n\"\n    \"  optional Bar a = 1;\\n\"\n    \"}\\n\");\n  CreateTempFile(\"b/foo.proto\", \"this should not be parsed\\n\");\n\n  Run(\"protocol_compiler --test_out=$tmpdir \"\n      \"--proto_path=$tmpdir/a --proto_path=$tmpdir/b foo.proto\");\n\n  ExpectNoErrors();\n  ExpectGenerated(\"test_generator\", \"\", \"foo.proto\", \"Foo\");\n}\n\nTEST_F(CommandLineInterfaceTest, ColonDelimitedPath) {\n  // Same as PathLookup, but we provide the proto_path in a single flag.\n\n  CreateTempFile(\"b/bar.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Bar {}\\n\");\n  CreateTempFile(\"a/foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"import \\\"bar.proto\\\";\\n\"\n    \"message Foo {\\n\"\n    \"  optional Bar a = 1;\\n\"\n    \"}\\n\");\n  CreateTempFile(\"b/foo.proto\", \"this should not be parsed\\n\");\n\n#undef PATH_SEPARATOR\n#if defined(_WIN32)\n#define PATH_SEPARATOR \";\"\n#else\n#define PATH_SEPARATOR \":\"\n#endif\n\n  Run(\"protocol_compiler --test_out=$tmpdir \"\n      \"--proto_path=$tmpdir/a\" PATH_SEPARATOR \"$tmpdir/b foo.proto\");\n\n#undef PATH_SEPARATOR\n\n  ExpectNoErrors();\n  ExpectGenerated(\"test_generator\", \"\", \"foo.proto\", \"Foo\");\n}\n\nTEST_F(CommandLineInterfaceTest, NonRootMapping) {\n  // Test setting up a search path mapping a directory to a non-root location.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  Run(\"protocol_compiler --test_out=$tmpdir \"\n      \"--proto_path=bar=$tmpdir bar/foo.proto\");\n\n  ExpectNoErrors();\n  ExpectGenerated(\"test_generator\", \"\", \"bar/foo.proto\", \"Foo\");\n}\n\nTEST_F(CommandLineInterfaceTest, PathWithEqualsSign) {\n  // Test setting up a search path which happens to have '=' in it.\n\n  CreateTempDir(\"with=sign\");\n  CreateTempFile(\"with=sign/foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  Run(\"protocol_compiler --test_out=$tmpdir \"\n      \"--proto_path=$tmpdir/with=sign foo.proto\");\n\n  ExpectNoErrors();\n  ExpectGenerated(\"test_generator\", \"\", \"foo.proto\", \"Foo\");\n}\n\nTEST_F(CommandLineInterfaceTest, MultipleGenerators) {\n  // Test that we can have multiple generators and use both in one invocation,\n  // each with a different output directory.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n  // Create the \"a\" and \"b\" sub-directories.\n  CreateTempDir(\"a\");\n  CreateTempDir(\"b\");\n\n  Run(\"protocol_compiler \"\n      \"--test_out=$tmpdir/a \"\n      \"--alt_out=$tmpdir/b \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectNoErrors();\n  ExpectGenerated(\"test_generator\", \"\", \"foo.proto\", \"Foo\", \"a\");\n  ExpectGenerated(\"alt_generator\", \"\", \"foo.proto\", \"Foo\", \"b\");\n}\n\nTEST_F(CommandLineInterfaceTest, DisallowServicesNoServices) {\n  // Test that --disallow_services doesn't cause a problem when there are no\n  // services.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  Run(\"protocol_compiler --disallow_services --test_out=$tmpdir \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectNoErrors();\n  ExpectGenerated(\"test_generator\", \"\", \"foo.proto\", \"Foo\");\n}\n\nTEST_F(CommandLineInterfaceTest, DisallowServicesHasService) {\n  // Test that --disallow_services produces an error when there are services.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\"\n    \"service Bar {}\\n\");\n\n  Run(\"protocol_compiler --disallow_services --test_out=$tmpdir \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectErrorSubstring(\"foo.proto: This file contains services\");\n}\n\nTEST_F(CommandLineInterfaceTest, AllowServicesHasService) {\n  // Test that services work fine as long as --disallow_services is not used.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\"\n    \"service Bar {}\\n\");\n\n  Run(\"protocol_compiler --test_out=$tmpdir \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectNoErrors();\n  ExpectGenerated(\"test_generator\", \"\", \"foo.proto\", \"Foo\");\n}\n\nTEST_F(CommandLineInterfaceTest, CwdRelativeInputs) {\n  // Test that we can accept working-directory-relative input files.\n\n  SetInputsAreProtoPathRelative(false);\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  Run(\"protocol_compiler --test_out=$tmpdir \"\n      \"--proto_path=$tmpdir $tmpdir/foo.proto\");\n\n  ExpectNoErrors();\n  ExpectGenerated(\"test_generator\", \"\", \"foo.proto\", \"Foo\");\n}\n\nTEST_F(CommandLineInterfaceTest, WriteDescriptorSet) {\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n  CreateTempFile(\"bar.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"import \\\"foo.proto\\\";\\n\"\n    \"message Bar {\\n\"\n    \"  optional Foo foo = 1;\\n\"\n    \"}\\n\");\n\n  Run(\"protocol_compiler --descriptor_set_out=$tmpdir/descriptor_set \"\n      \"--proto_path=$tmpdir bar.proto\");\n\n  ExpectNoErrors();\n\n  FileDescriptorSet descriptor_set;\n  ReadDescriptorSet(\"descriptor_set\", &descriptor_set);\n  if (HasFatalFailure()) return;\n  EXPECT_EQ(1, descriptor_set.file_size());\n  EXPECT_EQ(\"bar.proto\", descriptor_set.file(0).name());\n  // Descriptor set should not have source code info.\n  EXPECT_FALSE(descriptor_set.file(0).has_source_code_info());\n  // Descriptor set should have json_name.\n  EXPECT_EQ(\"Bar\", descriptor_set.file(0).message_type(0).name());\n  EXPECT_EQ(\"foo\", descriptor_set.file(0).message_type(0).field(0).name());\n  EXPECT_TRUE(descriptor_set.file(0).message_type(0).field(0).has_json_name());\n}\n\nTEST_F(CommandLineInterfaceTest, WriteDescriptorSetWithDuplicates) {\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n  CreateTempFile(\"bar.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"import \\\"foo.proto\\\";\\n\"\n    \"message Bar {\\n\"\n    \"  optional Foo foo = 1;\\n\"\n    \"}\\n\");\n  CreateTempFile(\"baz.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"import \\\"foo.proto\\\";\\n\"\n    \"message Baz {\\n\"\n    \"  optional Foo foo = 1;\\n\"\n    \"}\\n\");\n\n  Run(\"protocol_compiler --descriptor_set_out=$tmpdir/descriptor_set \"\n      \"--proto_path=$tmpdir bar.proto foo.proto bar.proto baz.proto\");\n\n  ExpectNoErrors();\n\n  FileDescriptorSet descriptor_set;\n  ReadDescriptorSet(\"descriptor_set\", &descriptor_set);\n  if (HasFatalFailure()) return;\n  EXPECT_EQ(3, descriptor_set.file_size());\n  EXPECT_EQ(\"bar.proto\", descriptor_set.file(0).name());\n  EXPECT_EQ(\"foo.proto\", descriptor_set.file(1).name());\n  EXPECT_EQ(\"baz.proto\", descriptor_set.file(2).name());\n  // Descriptor set should not have source code info.\n  EXPECT_FALSE(descriptor_set.file(0).has_source_code_info());\n  // Descriptor set should have json_name.\n  EXPECT_EQ(\"Bar\", descriptor_set.file(0).message_type(0).name());\n  EXPECT_EQ(\"foo\", descriptor_set.file(0).message_type(0).field(0).name());\n  EXPECT_TRUE(descriptor_set.file(0).message_type(0).field(0).has_json_name());\n}\n\nTEST_F(CommandLineInterfaceTest, WriteDescriptorSetWithSourceInfo) {\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n  CreateTempFile(\"bar.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"import \\\"foo.proto\\\";\\n\"\n    \"message Bar {\\n\"\n    \"  optional Foo foo = 1;\\n\"\n    \"}\\n\");\n\n  Run(\"protocol_compiler --descriptor_set_out=$tmpdir/descriptor_set \"\n      \"--include_source_info --proto_path=$tmpdir bar.proto\");\n\n  ExpectNoErrors();\n\n  FileDescriptorSet descriptor_set;\n  ReadDescriptorSet(\"descriptor_set\", &descriptor_set);\n  if (HasFatalFailure()) return;\n  EXPECT_EQ(1, descriptor_set.file_size());\n  EXPECT_EQ(\"bar.proto\", descriptor_set.file(0).name());\n  // Source code info included.\n  EXPECT_TRUE(descriptor_set.file(0).has_source_code_info());\n}\n\nTEST_F(CommandLineInterfaceTest, WriteTransitiveDescriptorSet) {\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n  CreateTempFile(\"bar.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"import \\\"foo.proto\\\";\\n\"\n    \"message Bar {\\n\"\n    \"  optional Foo foo = 1;\\n\"\n    \"}\\n\");\n\n  Run(\"protocol_compiler --descriptor_set_out=$tmpdir/descriptor_set \"\n      \"--include_imports --proto_path=$tmpdir bar.proto\");\n\n  ExpectNoErrors();\n\n  FileDescriptorSet descriptor_set;\n  ReadDescriptorSet(\"descriptor_set\", &descriptor_set);\n  if (HasFatalFailure()) return;\n  EXPECT_EQ(2, descriptor_set.file_size());\n  if (descriptor_set.file(0).name() == \"bar.proto\") {\n    std::swap(descriptor_set.mutable_file()->mutable_data()[0],\n              descriptor_set.mutable_file()->mutable_data()[1]);\n  }\n  EXPECT_EQ(\"foo.proto\", descriptor_set.file(0).name());\n  EXPECT_EQ(\"bar.proto\", descriptor_set.file(1).name());\n  // Descriptor set should not have source code info.\n  EXPECT_FALSE(descriptor_set.file(0).has_source_code_info());\n  EXPECT_FALSE(descriptor_set.file(1).has_source_code_info());\n}\n\nTEST_F(CommandLineInterfaceTest, WriteTransitiveDescriptorSetWithSourceInfo) {\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n  CreateTempFile(\"bar.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"import \\\"foo.proto\\\";\\n\"\n    \"message Bar {\\n\"\n    \"  optional Foo foo = 1;\\n\"\n    \"}\\n\");\n\n  Run(\"protocol_compiler --descriptor_set_out=$tmpdir/descriptor_set \"\n      \"--include_imports --include_source_info --proto_path=$tmpdir bar.proto\");\n\n  ExpectNoErrors();\n\n  FileDescriptorSet descriptor_set;\n  ReadDescriptorSet(\"descriptor_set\", &descriptor_set);\n  if (HasFatalFailure()) return;\n  EXPECT_EQ(2, descriptor_set.file_size());\n  if (descriptor_set.file(0).name() == \"bar.proto\") {\n    std::swap(descriptor_set.mutable_file()->mutable_data()[0],\n              descriptor_set.mutable_file()->mutable_data()[1]);\n  }\n  EXPECT_EQ(\"foo.proto\", descriptor_set.file(0).name());\n  EXPECT_EQ(\"bar.proto\", descriptor_set.file(1).name());\n  // Source code info included.\n  EXPECT_TRUE(descriptor_set.file(0).has_source_code_info());\n  EXPECT_TRUE(descriptor_set.file(1).has_source_code_info());\n}\n\n#ifdef _WIN32\n// TODO(teboring): Figure out how to write test on windows.\n#else\nTEST_F(CommandLineInterfaceTest, WriteDependencyManifestFileGivenTwoInputs) {\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n  CreateTempFile(\"bar.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"import \\\"foo.proto\\\";\\n\"\n    \"message Bar {\\n\"\n    \"  optional Foo foo = 1;\\n\"\n    \"}\\n\");\n\n  Run(\"protocol_compiler --dependency_out=$tmpdir/manifest \"\n      \"--test_out=$tmpdir --proto_path=$tmpdir bar.proto foo.proto\");\n\n  ExpectErrorText(\n      \"Can only process one input file when using --dependency_out=FILE.\\n\");\n}\n\n#ifdef PROTOBUF_OPENSOURCE\nTEST_F(CommandLineInterfaceTest, WriteDependencyManifestFile) {\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n  CreateTempFile(\"bar.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"import \\\"foo.proto\\\";\\n\"\n    \"message Bar {\\n\"\n    \"  optional Foo foo = 1;\\n\"\n    \"}\\n\");\n\n  string current_working_directory = getcwd(NULL, 0);\n  SwitchToTempDirectory();\n\n  Run(\"protocol_compiler --dependency_out=manifest --test_out=. \"\n      \"bar.proto\");\n\n  ExpectNoErrors();\n\n  ExpectFileContent(\"manifest\",\n                    \"bar.proto.MockCodeGenerator.test_generator: \"\n                    \"foo.proto\\\\\\n bar.proto\");\n\n  File::ChangeWorkingDirectory(current_working_directory);\n}\n#else  // !PROTOBUF_OPENSOURCE\n// TODO(teboring): Figure out how to change and get working directory in\n// google3.\n#endif  // !PROTOBUF_OPENSOURCE\n\nTEST_F(CommandLineInterfaceTest, WriteDependencyManifestFileForAbsolutePath) {\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n  CreateTempFile(\"bar.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"import \\\"foo.proto\\\";\\n\"\n    \"message Bar {\\n\"\n    \"  optional Foo foo = 1;\\n\"\n    \"}\\n\");\n\n  Run(\"protocol_compiler --dependency_out=$tmpdir/manifest \"\n      \"--test_out=$tmpdir --proto_path=$tmpdir bar.proto\");\n\n  ExpectNoErrors();\n\n  ExpectFileContent(\"manifest\",\n                    \"$tmpdir/bar.proto.MockCodeGenerator.test_generator: \"\n                    \"$tmpdir/foo.proto\\\\\\n $tmpdir/bar.proto\");\n}\n#endif  // !_WIN32\n\n\n// -------------------------------------------------------------------\n\nTEST_F(CommandLineInterfaceTest, ParseErrors) {\n  // Test that parse errors are reported.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"badsyntax\\n\");\n\n  Run(\"protocol_compiler --test_out=$tmpdir \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectErrorText(\n    \"foo.proto:2:1: Expected top-level statement (e.g. \\\"message\\\").\\n\");\n}\n\nTEST_F(CommandLineInterfaceTest, ParseErrorsMultipleFiles) {\n  // Test that parse errors are reported from multiple files.\n\n  // We set up files such that foo.proto actually depends on bar.proto in\n  // two ways:  Directly and through baz.proto.  bar.proto's errors should\n  // only be reported once.\n  CreateTempFile(\"bar.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"badsyntax\\n\");\n  CreateTempFile(\"baz.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"import \\\"bar.proto\\\";\\n\");\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"import \\\"bar.proto\\\";\\n\"\n    \"import \\\"baz.proto\\\";\\n\");\n\n  Run(\"protocol_compiler --test_out=$tmpdir \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectErrorText(\n    \"bar.proto:2:1: Expected top-level statement (e.g. \\\"message\\\").\\n\"\n    \"baz.proto: Import \\\"bar.proto\\\" was not found or had errors.\\n\"\n    \"foo.proto: Import \\\"bar.proto\\\" was not found or had errors.\\n\"\n    \"foo.proto: Import \\\"baz.proto\\\" was not found or had errors.\\n\");\n}\n\nTEST_F(CommandLineInterfaceTest, InputNotFoundError) {\n  // Test what happens if the input file is not found.\n\n  Run(\"protocol_compiler --test_out=$tmpdir \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectErrorText(\n    \"foo.proto: File not found.\\n\");\n}\n\nTEST_F(CommandLineInterfaceTest, CwdRelativeInputNotFoundError) {\n  // Test what happens when a working-directory-relative input file is not\n  // found.\n\n  SetInputsAreProtoPathRelative(false);\n\n  Run(\"protocol_compiler --test_out=$tmpdir \"\n      \"--proto_path=$tmpdir $tmpdir/foo.proto\");\n\n  ExpectErrorText(\n    \"$tmpdir/foo.proto: No such file or directory\\n\");\n}\n\nTEST_F(CommandLineInterfaceTest, CwdRelativeInputNotMappedError) {\n  // Test what happens when a working-directory-relative input file is not\n  // mapped to a virtual path.\n\n  SetInputsAreProtoPathRelative(false);\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  // Create a directory called \"bar\" so that we can point --proto_path at it.\n  CreateTempFile(\"bar/dummy\", \"\");\n\n  Run(\"protocol_compiler --test_out=$tmpdir \"\n      \"--proto_path=$tmpdir/bar $tmpdir/foo.proto\");\n\n  ExpectErrorText(\n    \"$tmpdir/foo.proto: File does not reside within any path \"\n      \"specified using --proto_path (or -I).  You must specify a \"\n      \"--proto_path which encompasses this file.  Note that the \"\n      \"proto_path must be an exact prefix of the .proto file \"\n      \"names -- protoc is too dumb to figure out when two paths \"\n      \"(e.g. absolute and relative) are equivalent (it's harder \"\n      \"than you think).\\n\");\n}\n\nTEST_F(CommandLineInterfaceTest, CwdRelativeInputNotFoundAndNotMappedError) {\n  // Check what happens if the input file is not found *and* is not mapped\n  // in the proto_path.\n\n  SetInputsAreProtoPathRelative(false);\n\n  // Create a directory called \"bar\" so that we can point --proto_path at it.\n  CreateTempFile(\"bar/dummy\", \"\");\n\n  Run(\"protocol_compiler --test_out=$tmpdir \"\n      \"--proto_path=$tmpdir/bar $tmpdir/foo.proto\");\n\n  ExpectErrorText(\n    \"$tmpdir/foo.proto: No such file or directory\\n\");\n}\n\nTEST_F(CommandLineInterfaceTest, CwdRelativeInputShadowedError) {\n  // Test what happens when a working-directory-relative input file is shadowed\n  // by another file in the virtual path.\n\n  SetInputsAreProtoPathRelative(false);\n\n  CreateTempFile(\"foo/foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n  CreateTempFile(\"bar/foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Bar {}\\n\");\n\n  Run(\"protocol_compiler --test_out=$tmpdir \"\n      \"--proto_path=$tmpdir/foo --proto_path=$tmpdir/bar \"\n      \"$tmpdir/bar/foo.proto\");\n\n  ExpectErrorText(\n    \"$tmpdir/bar/foo.proto: Input is shadowed in the --proto_path \"\n    \"by \\\"$tmpdir/foo/foo.proto\\\".  Either use the latter \"\n    \"file as your input or reorder the --proto_path so that the \"\n    \"former file's location comes first.\\n\");\n}\n\nTEST_F(CommandLineInterfaceTest, ProtoPathNotFoundError) {\n  // Test what happens if the input file is not found.\n\n  Run(\"protocol_compiler --test_out=$tmpdir \"\n      \"--proto_path=$tmpdir/foo foo.proto\");\n\n  ExpectErrorText(\n    \"$tmpdir/foo: warning: directory does not exist.\\n\"\n    \"foo.proto: File not found.\\n\");\n}\n\nTEST_F(CommandLineInterfaceTest, MissingInputError) {\n  // Test that we get an error if no inputs are given.\n\n  Run(\"protocol_compiler --test_out=$tmpdir \"\n      \"--proto_path=$tmpdir\");\n\n  ExpectErrorText(\"Missing input file.\\n\");\n}\n\nTEST_F(CommandLineInterfaceTest, MissingOutputError) {\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  Run(\"protocol_compiler --proto_path=$tmpdir foo.proto\");\n\n  ExpectErrorText(\"Missing output directives.\\n\");\n}\n\nTEST_F(CommandLineInterfaceTest, OutputWriteError) {\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  string output_file =\n      MockCodeGenerator::GetOutputFileName(\"test_generator\", \"foo.proto\");\n\n  // Create a directory blocking our output location.\n  CreateTempDir(output_file);\n\n  Run(\"protocol_compiler --test_out=$tmpdir \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  // MockCodeGenerator no longer detects an error because we actually write to\n  // an in-memory location first, then dump to disk at the end.  This is no\n  // big deal.\n  //   ExpectErrorSubstring(\"MockCodeGenerator detected write error.\");\n\n#if defined(_WIN32) && !defined(__CYGWIN__)\n  // Windows with MSVCRT.dll produces EPERM instead of EISDIR.\n  if (HasAlternateErrorSubstring(output_file + \": Permission denied\")) {\n    return;\n  }\n#endif\n\n  ExpectErrorSubstring(output_file + \": Is a directory\");\n}\n\nTEST_F(CommandLineInterfaceTest, PluginOutputWriteError) {\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  string output_file =\n      MockCodeGenerator::GetOutputFileName(\"test_plugin\", \"foo.proto\");\n\n  // Create a directory blocking our output location.\n  CreateTempDir(output_file);\n\n  Run(\"protocol_compiler --plug_out=$tmpdir \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n#if defined(_WIN32) && !defined(__CYGWIN__)\n  // Windows with MSVCRT.dll produces EPERM instead of EISDIR.\n  if (HasAlternateErrorSubstring(output_file + \": Permission denied\")) {\n    return;\n  }\n#endif\n\n  ExpectErrorSubstring(output_file + \": Is a directory\");\n}\n\nTEST_F(CommandLineInterfaceTest, OutputDirectoryNotFoundError) {\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  Run(\"protocol_compiler --test_out=$tmpdir/nosuchdir \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectErrorSubstring(\"nosuchdir/: No such file or directory\");\n}\n\nTEST_F(CommandLineInterfaceTest, PluginOutputDirectoryNotFoundError) {\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  Run(\"protocol_compiler --plug_out=$tmpdir/nosuchdir \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectErrorSubstring(\"nosuchdir/: No such file or directory\");\n}\n\nTEST_F(CommandLineInterfaceTest, OutputDirectoryIsFileError) {\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  Run(\"protocol_compiler --test_out=$tmpdir/foo.proto \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n#if defined(_WIN32) && !defined(__CYGWIN__)\n  // Windows with MSVCRT.dll produces EINVAL instead of ENOTDIR.\n  if (HasAlternateErrorSubstring(\"foo.proto/: Invalid argument\")) {\n    return;\n  }\n#endif\n\n  ExpectErrorSubstring(\"foo.proto/: Not a directory\");\n}\n\nTEST_F(CommandLineInterfaceTest, GeneratorError) {\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message MockCodeGenerator_Error {}\\n\");\n\n  Run(\"protocol_compiler --test_out=$tmpdir \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectErrorSubstring(\n      \"--test_out: foo.proto: Saw message type MockCodeGenerator_Error.\");\n}\n\nTEST_F(CommandLineInterfaceTest, GeneratorPluginError) {\n  // Test a generator plugin that returns an error.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message MockCodeGenerator_Error {}\\n\");\n\n  Run(\"protocol_compiler --plug_out=TestParameter:$tmpdir \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectErrorSubstring(\n      \"--plug_out: foo.proto: Saw message type MockCodeGenerator_Error.\");\n}\n\nTEST_F(CommandLineInterfaceTest, GeneratorPluginFail) {\n  // Test a generator plugin that exits with an error code.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message MockCodeGenerator_Exit {}\\n\");\n\n  Run(\"protocol_compiler --plug_out=TestParameter:$tmpdir \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectErrorSubstring(\"Saw message type MockCodeGenerator_Exit.\");\n  ExpectErrorSubstring(\n      \"--plug_out: prefix-gen-plug: Plugin failed with status code 123.\");\n}\n\nTEST_F(CommandLineInterfaceTest, GeneratorPluginCrash) {\n  // Test a generator plugin that crashes.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message MockCodeGenerator_Abort {}\\n\");\n\n  Run(\"protocol_compiler --plug_out=TestParameter:$tmpdir \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectErrorSubstring(\"Saw message type MockCodeGenerator_Abort.\");\n\n#ifdef _WIN32\n  // Windows doesn't have signals.  It looks like abort()ing causes the process\n  // to exit with status code 3, but let's not depend on the exact number here.\n  ExpectErrorSubstring(\n      \"--plug_out: prefix-gen-plug: Plugin failed with status code\");\n#else\n  // Don't depend on the exact signal number.\n  ExpectErrorSubstring(\n      \"--plug_out: prefix-gen-plug: Plugin killed by signal\");\n#endif\n}\n\nTEST_F(CommandLineInterfaceTest, PluginReceivesSourceCodeInfo) {\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message MockCodeGenerator_HasSourceCodeInfo {}\\n\");\n\n  Run(\"protocol_compiler --plug_out=$tmpdir --proto_path=$tmpdir foo.proto\");\n\n  ExpectErrorSubstring(\n      \"Saw message type MockCodeGenerator_HasSourceCodeInfo: 1.\");\n}\n\nTEST_F(CommandLineInterfaceTest, PluginReceivesJsonName) {\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message MockCodeGenerator_HasJsonName {\\n\"\n    \"  optional int32 value = 1;\\n\"\n    \"}\\n\");\n\n  Run(\"protocol_compiler --plug_out=$tmpdir --proto_path=$tmpdir foo.proto\");\n\n  ExpectErrorSubstring(\"Saw json_name: 1\");\n}\n\nTEST_F(CommandLineInterfaceTest, GeneratorPluginNotFound) {\n  // Test what happens if the plugin isn't found.\n\n  CreateTempFile(\"error.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  Run(\"protocol_compiler --badplug_out=TestParameter:$tmpdir \"\n      \"--plugin=prefix-gen-badplug=no_such_file \"\n      \"--proto_path=$tmpdir error.proto\");\n\n#ifdef _WIN32\n  ExpectErrorSubstring(\"--badplug_out: prefix-gen-badplug: \" +\n      Subprocess::Win32ErrorMessage(ERROR_FILE_NOT_FOUND));\n#else\n  // Error written to stdout by child process after exec() fails.\n  ExpectErrorSubstring(\n      \"no_such_file: program not found or is not executable\");\n\n  // Error written by parent process when child fails.\n  ExpectErrorSubstring(\n      \"--badplug_out: prefix-gen-badplug: Plugin failed with status code 1.\");\n#endif\n}\n\nTEST_F(CommandLineInterfaceTest, GeneratorPluginNotAllowed) {\n  // Test what happens if plugins aren't allowed.\n\n  CreateTempFile(\"error.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  DisallowPlugins();\n  Run(\"protocol_compiler --plug_out=TestParameter:$tmpdir \"\n      \"--proto_path=$tmpdir error.proto\");\n\n  ExpectErrorSubstring(\"Unknown flag: --plug_out\");\n}\n\nTEST_F(CommandLineInterfaceTest, HelpText) {\n  Run(\"test_exec_name --help\");\n\n  ExpectErrorSubstringWithZeroReturnCode(\"Usage: test_exec_name \");\n  ExpectErrorSubstringWithZeroReturnCode(\"--test_out=OUT_DIR\");\n  ExpectErrorSubstringWithZeroReturnCode(\"Test output.\");\n  ExpectErrorSubstringWithZeroReturnCode(\"--alt_out=OUT_DIR\");\n  ExpectErrorSubstringWithZeroReturnCode(\"Alt output.\");\n}\n\nTEST_F(CommandLineInterfaceTest, GccFormatErrors) {\n  // Test --error_format=gcc (which is the default, but we want to verify\n  // that it can be set explicitly).\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"badsyntax\\n\");\n\n  Run(\"protocol_compiler --test_out=$tmpdir \"\n      \"--proto_path=$tmpdir --error_format=gcc foo.proto\");\n\n  ExpectErrorText(\n    \"foo.proto:2:1: Expected top-level statement (e.g. \\\"message\\\").\\n\");\n}\n\nTEST_F(CommandLineInterfaceTest, MsvsFormatErrors) {\n  // Test --error_format=msvs\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"badsyntax\\n\");\n\n  Run(\"protocol_compiler --test_out=$tmpdir \"\n      \"--proto_path=$tmpdir --error_format=msvs foo.proto\");\n\n  ExpectErrorText(\n    \"$tmpdir/foo.proto(2) : error in column=1: Expected top-level statement \"\n      \"(e.g. \\\"message\\\").\\n\");\n}\n\nTEST_F(CommandLineInterfaceTest, InvalidErrorFormat) {\n  // Test --error_format=msvs\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"badsyntax\\n\");\n\n  Run(\"protocol_compiler --test_out=$tmpdir \"\n      \"--proto_path=$tmpdir --error_format=invalid foo.proto\");\n\n  ExpectErrorText(\n    \"Unknown error format: invalid\\n\");\n}\n\n// -------------------------------------------------------------------\n// Flag parsing tests\n\nTEST_F(CommandLineInterfaceTest, ParseSingleCharacterFlag) {\n  // Test that a single-character flag works.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  Run(\"protocol_compiler -t$tmpdir \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectNoErrors();\n  ExpectGenerated(\"test_generator\", \"\", \"foo.proto\", \"Foo\");\n}\n\nTEST_F(CommandLineInterfaceTest, ParseSpaceDelimitedValue) {\n  // Test that separating the flag value with a space works.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  Run(\"protocol_compiler --test_out $tmpdir \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectNoErrors();\n  ExpectGenerated(\"test_generator\", \"\", \"foo.proto\", \"Foo\");\n}\n\nTEST_F(CommandLineInterfaceTest, ParseSingleCharacterSpaceDelimitedValue) {\n  // Test that separating the flag value with a space works for\n  // single-character flags.\n\n  CreateTempFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  Run(\"protocol_compiler -t $tmpdir \"\n      \"--proto_path=$tmpdir foo.proto\");\n\n  ExpectNoErrors();\n  ExpectGenerated(\"test_generator\", \"\", \"foo.proto\", \"Foo\");\n}\n\nTEST_F(CommandLineInterfaceTest, MissingValueError) {\n  // Test that we get an error if a flag is missing its value.\n\n  Run(\"protocol_compiler --test_out --proto_path=$tmpdir foo.proto\");\n\n  ExpectErrorText(\"Missing value for flag: --test_out\\n\");\n}\n\nTEST_F(CommandLineInterfaceTest, MissingValueAtEndError) {\n  // Test that we get an error if the last argument is a flag requiring a\n  // value.\n\n  Run(\"protocol_compiler --test_out\");\n\n  ExpectErrorText(\"Missing value for flag: --test_out\\n\");\n}\n\nTEST_F(CommandLineInterfaceTest, PrintFreeFieldNumbers) {\n  CreateTempFile(\n      \"foo.proto\",\n      \"syntax = \\\"proto2\\\";\\n\"\n      \"package foo;\\n\"\n      \"message Foo {\\n\"\n      \"  optional int32 a = 2;\\n\"\n      \"  optional string b = 4;\\n\"\n      \"  optional string c = 5;\\n\"\n      \"  optional int64 d = 8;\\n\"\n      \"  optional double e = 10;\\n\"\n      \"}\\n\");\n  CreateTempFile(\n      \"bar.proto\",\n      \"syntax = \\\"proto2\\\";\\n\"\n      \"message Bar {\\n\"\n      \"  optional int32 a = 2;\\n\"\n      \"  extensions 4 to 5;\\n\"\n      \"  optional int64 d = 8;\\n\"\n      \"  extensions 10;\\n\"\n      \"}\\n\");\n  CreateTempFile(\n      \"baz.proto\",\n      \"syntax = \\\"proto2\\\";\\n\"\n      \"message Baz {\\n\"\n      \"  optional int32 a = 2;\\n\"\n      \"  optional int64 d = 8;\\n\"\n      \"  extensions 15 to max;\\n\"  // unordered.\n      \"  extensions 13;\\n\"\n      \"  extensions 10 to 12;\\n\"\n      \"  extensions 5;\\n\"\n      \"  extensions 4;\\n\"\n      \"}\\n\");\n  CreateTempFile(\n      \"quz.proto\",\n      \"syntax = \\\"proto2\\\";\\n\"\n      \"message Quz {\\n\"\n      \"  message Foo {}\\n\"  // nested message\n      \"  optional int32 a = 2;\\n\"\n      \"  optional group C = 4 {\\n\"\n      \"    optional int32 d = 5;\\n\"\n      \"  }\\n\"\n      \"  extensions 8 to 10;\\n\"\n      \"  optional group E = 11 {\\n\"\n      \"    optional int32 f = 9;\\n\"    // explicitly reuse extension range 8-10\n      \"    optional group G = 15 {\\n\"  // nested group\n      \"      message Foo {}\\n\"         // nested message inside nested group\n      \"    }\\n\"\n      \"  }\\n\"\n      \"}\\n\");\n\n  Run(\"protocol_compiler --print_free_field_numbers --proto_path=$tmpdir \"\n      \"foo.proto bar.proto baz.proto quz.proto\");\n\n  ExpectNoErrors();\n\n  // TODO(jieluo): Cygwin doesn't work well if we try to capture stderr and\n  // stdout at the same time. Need to figure out why and add this test back\n  // for Cygwin.\n#if !defined(__CYGWIN__)\n  ExpectCapturedStdout(\n      \"foo.Foo                             free: 1 3 6-7 9 11-INF\\n\"\n      \"Bar                                 free: 1 3 6-7 9 11-INF\\n\"\n      \"Baz                                 free: 1 3 6-7 9 14\\n\"\n      \"Quz.Foo                             free: 1-INF\\n\"\n      \"Quz.E.G.Foo                         free: 1-INF\\n\"\n      \"Quz                                 free: 1 3 6-7 12-14 16-INF\\n\");\n#endif\n}\n\n// ===================================================================\n\n// Test for --encode and --decode.  Note that it would be easier to do this\n// test as a shell script, but we'd like to be able to run the test on\n// platforms that don't have a Bourne-compatible shell available (especially\n// Windows/MSVC).\nclass EncodeDecodeTest : public testing::Test {\n protected:\n  virtual void SetUp() {\n    duped_stdin_ = dup(STDIN_FILENO);\n  }\n\n  virtual void TearDown() {\n    dup2(duped_stdin_, STDIN_FILENO);\n    close(duped_stdin_);\n  }\n\n  void RedirectStdinFromText(const string& input) {\n    string filename = TestTempDir() + \"/test_stdin\";\n    GOOGLE_CHECK_OK(File::SetContents(filename, input, true));\n    GOOGLE_CHECK(RedirectStdinFromFile(filename));\n  }\n\n  bool RedirectStdinFromFile(const string& filename) {\n    int fd = open(filename.c_str(), O_RDONLY);\n    if (fd < 0) return false;\n    dup2(fd, STDIN_FILENO);\n    close(fd);\n    return true;\n  }\n\n  // Remove '\\r' characters from text.\n  string StripCR(const string& text) {\n    string result;\n\n    for (int i = 0; i < text.size(); i++) {\n      if (text[i] != '\\r') {\n        result.push_back(text[i]);\n      }\n    }\n\n    return result;\n  }\n\n  enum Type { TEXT, BINARY };\n  enum ReturnCode { SUCCESS, ERROR };\n\n  bool Run(const string& command) {\n    vector<string> args;\n    args.push_back(\"protoc\");\n    SplitStringUsing(command, \" \", &args);\n    args.push_back(\"--proto_path=\" + TestSourceDir());\n\n    google::protobuf::scoped_array<const char * > argv(new const char* [args.size()]);\n    for (int i = 0; i < args.size(); i++) {\n      argv[i] = args[i].c_str();\n    }\n\n    CommandLineInterface cli;\n    cli.SetInputsAreProtoPathRelative(true);\n\n    CaptureTestStdout();\n    CaptureTestStderr();\n\n    int result = cli.Run(args.size(), argv.get());\n\n    captured_stdout_ = GetCapturedTestStdout();\n    captured_stderr_ = GetCapturedTestStderr();\n\n    return result == 0;\n  }\n\n  void ExpectStdoutMatchesBinaryFile(const string& filename) {\n    string expected_output;\n    GOOGLE_CHECK_OK(File::GetContents(filename, &expected_output, true));\n\n    // Don't use EXPECT_EQ because we don't want to print raw binary data to\n    // stdout on failure.\n    EXPECT_TRUE(captured_stdout_ == expected_output);\n  }\n\n  void ExpectStdoutMatchesTextFile(const string& filename) {\n    string expected_output;\n    GOOGLE_CHECK_OK(File::GetContents(filename, &expected_output, true));\n\n    ExpectStdoutMatchesText(expected_output);\n  }\n\n  void ExpectStdoutMatchesText(const string& expected_text) {\n    EXPECT_EQ(StripCR(expected_text), StripCR(captured_stdout_));\n  }\n\n  void ExpectStderrMatchesText(const string& expected_text) {\n    EXPECT_EQ(StripCR(expected_text), StripCR(captured_stderr_));\n  }\n\n private:\n  int duped_stdin_;\n  string captured_stdout_;\n  string captured_stderr_;\n};\n\nTEST_F(EncodeDecodeTest, Encode) {\n  RedirectStdinFromFile(TestSourceDir() + \"/google/protobuf/\"\n    \"testdata/text_format_unittest_data_oneof_implemented.txt\");\n  EXPECT_TRUE(Run(\"google/protobuf/unittest.proto \"\n                  \"--encode=protobuf_unittest.TestAllTypes\"));\n  ExpectStdoutMatchesBinaryFile(TestSourceDir() +\n    \"/google/protobuf/testdata/golden_message_oneof_implemented\");\n  ExpectStderrMatchesText(\"\");\n}\n\nTEST_F(EncodeDecodeTest, Decode) {\n  RedirectStdinFromFile(TestSourceDir() +\n    \"/google/protobuf/testdata/golden_message_oneof_implemented\");\n  EXPECT_TRUE(Run(\"google/protobuf/unittest.proto \"\n                  \"--decode=protobuf_unittest.TestAllTypes\"));\n  ExpectStdoutMatchesTextFile(TestSourceDir() +\n    \"/google/protobuf/\"\n    \"testdata/text_format_unittest_data_oneof_implemented.txt\");\n  ExpectStderrMatchesText(\"\");\n}\n\nTEST_F(EncodeDecodeTest, Partial) {\n  RedirectStdinFromText(\"\");\n  EXPECT_TRUE(Run(\"google/protobuf/unittest.proto \"\n                  \"--encode=protobuf_unittest.TestRequired\"));\n  ExpectStdoutMatchesText(\"\");\n  ExpectStderrMatchesText(\n    \"warning:  Input message is missing required fields:  a, b, c\\n\");\n}\n\nTEST_F(EncodeDecodeTest, DecodeRaw) {\n  protobuf_unittest::TestAllTypes message;\n  message.set_optional_int32(123);\n  message.set_optional_string(\"foo\");\n  string data;\n  message.SerializeToString(&data);\n\n  RedirectStdinFromText(data);\n  EXPECT_TRUE(Run(\"--decode_raw\"));\n  ExpectStdoutMatchesText(\"1: 123\\n\"\n                          \"14: \\\"foo\\\"\\n\");\n  ExpectStderrMatchesText(\"\");\n}\n\nTEST_F(EncodeDecodeTest, UnknownType) {\n  EXPECT_FALSE(Run(\"google/protobuf/unittest.proto \"\n                   \"--encode=NoSuchType\"));\n  ExpectStdoutMatchesText(\"\");\n  ExpectStderrMatchesText(\"Type not defined: NoSuchType\\n\");\n}\n\nTEST_F(EncodeDecodeTest, ProtoParseError) {\n  EXPECT_FALSE(Run(\"google/protobuf/no_such_file.proto \"\n                   \"--encode=NoSuchType\"));\n  ExpectStdoutMatchesText(\"\");\n  ExpectStderrMatchesText(\n    \"google/protobuf/no_such_file.proto: File not found.\\n\");\n}\n\n}  // anonymous namespace\n\n#endif  // !GOOGLE_PROTOBUF_HEAP_CHECK_DRACONIAN\n\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This test insures that google/protobuf/descriptor.pb.{h,cc} match exactly\n// what would be generated by the protocol compiler.  These files are not\n// generated automatically at build time because they are compiled into the\n// protocol compiler itself.  So, if they were auto-generated, you'd have a\n// chicken-and-egg problem.\n//\n// If this test fails, run the script\n// \"generate_descriptor_proto.sh\" and add\n// descriptor.pb.{h,cc} to your changelist.\n\n#include <map>\n\n#include <google/protobuf/compiler/cpp/cpp_generator.h>\n#include <google/protobuf/compiler/importer.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/stubs/map_util.h>\n#include <google/protobuf/stubs/stl_util.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\nnamespace {\n\nclass MockErrorCollector : public MultiFileErrorCollector {\n public:\n  MockErrorCollector() {}\n  ~MockErrorCollector() {}\n\n  string text_;\n\n  // implements ErrorCollector ---------------------------------------\n  void AddError(const string& filename, int line, int column,\n                const string& message) {\n    strings::SubstituteAndAppend(&text_, \"$0:$1:$2: $3\\n\",\n                                 filename, line, column, message);\n  }\n};\n\nclass MockGeneratorContext : public GeneratorContext {\n public:\n  MockGeneratorContext() {}\n  ~MockGeneratorContext() {\n    STLDeleteValues(&files_);\n  }\n\n  void ExpectFileMatches(const string& virtual_filename,\n                         const string& physical_filename) {\n    string* expected_contents = FindPtrOrNull(files_, virtual_filename);\n    ASSERT_TRUE(expected_contents != NULL)\n      << \"Generator failed to generate file: \" << virtual_filename;\n\n    string actual_contents;\n    GOOGLE_CHECK_OK(\n        File::GetContents(TestSourceDir() + \"/\" + physical_filename,\n                          &actual_contents, true));\n    EXPECT_TRUE(actual_contents == *expected_contents)\n      << physical_filename << \" needs to be regenerated.  Please run \"\n         \"google/protobuf/compiler/release_compiler.sh and \"\n         \"generate_descriptor_proto.sh. Then add this file \"\n         \"to your CL.\";\n  }\n\n  // implements GeneratorContext --------------------------------------\n\n  virtual io::ZeroCopyOutputStream* Open(const string& filename) {\n    string** map_slot = &files_[filename];\n    delete *map_slot;\n    *map_slot = new string;\n\n    return new io::StringOutputStream(*map_slot);\n  }\n\n private:\n  map<string, string*> files_;\n};\n\nTEST(BootstrapTest, GeneratedDescriptorMatches) {\n  MockErrorCollector error_collector;\n  DiskSourceTree source_tree;\n  source_tree.MapPath(\"\", TestSourceDir());\n  Importer importer(&source_tree, &error_collector);\n  const FileDescriptor* proto_file =\n    importer.Import(\"google/protobuf/descriptor.proto\");\n  const FileDescriptor* plugin_proto_file =\n    importer.Import(\"google/protobuf/compiler/plugin.proto\");\n  EXPECT_EQ(\"\", error_collector.text_);\n  ASSERT_TRUE(proto_file != NULL);\n  ASSERT_TRUE(plugin_proto_file != NULL);\n\n  CppGenerator generator;\n  MockGeneratorContext context;\n  string error;\n  string parameter = \"dllexport_decl=LIBPROTOBUF_EXPORT\";\n  ASSERT_TRUE(generator.Generate(proto_file, parameter,\n                                 &context, &error));\n  parameter = \"dllexport_decl=LIBPROTOC_EXPORT\";\n  ASSERT_TRUE(generator.Generate(plugin_proto_file, parameter,\n                                 &context, &error));\n\n  context.ExpectFileMatches(\"google/protobuf/descriptor.pb.h\",\n                            \"google/protobuf/descriptor.pb.h\");\n  context.ExpectFileMatches(\"google/protobuf/descriptor.pb.cc\",\n                            \"google/protobuf/descriptor.pb.cc\");\n  context.ExpectFileMatches(\"google/protobuf/compiler/plugin.pb.h\",\n                            \"google/protobuf/compiler/plugin.pb.h\");\n  context.ExpectFileMatches(\"google/protobuf/compiler/plugin.pb.cc\",\n                            \"google/protobuf/compiler/plugin.pb.cc\");\n}\n\n}  // namespace\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_enum.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <map>\n\n#include <google/protobuf/compiler/cpp/cpp_enum.h>\n#include <google/protobuf/compiler/cpp/cpp_helpers.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\nnamespace {\n// The GOOGLE_ARRAYSIZE constant is the max enum value plus 1. If the max enum value\n// is ::google::protobuf::kint32max, GOOGLE_ARRAYSIZE will overflow. In such cases we should omit the\n// generation of the GOOGLE_ARRAYSIZE constant.\nbool ShouldGenerateArraySize(const EnumDescriptor* descriptor) {\n  int32 max_value = descriptor->value(0)->number();\n  for (int i = 0; i < descriptor->value_count(); i++) {\n    if (descriptor->value(i)->number() > max_value) {\n      max_value = descriptor->value(i)->number();\n    }\n  }\n  return max_value != ::google::protobuf::kint32max;\n}\n}  // namespace\n\nEnumGenerator::EnumGenerator(const EnumDescriptor* descriptor,\n                             const Options& options)\n  : descriptor_(descriptor),\n    classname_(ClassName(descriptor, false)),\n    options_(options),\n    generate_array_size_(ShouldGenerateArraySize(descriptor)) {\n}\n\nEnumGenerator::~EnumGenerator() {}\n\nvoid EnumGenerator::FillForwardDeclaration(\n    map<string, const EnumDescriptor*>* enum_names) {\n  if (!options_.proto_h) {\n    return;\n  }\n  (*enum_names)[classname_] = descriptor_;\n}\n\nvoid EnumGenerator::GenerateDefinition(io::Printer* printer) {\n  map<string, string> vars;\n  vars[\"classname\"] = classname_;\n  vars[\"short_name\"] = descriptor_->name();\n  vars[\"enumbase\"] = classname_ + (options_.proto_h ? \" : int\" : \"\");\n\n  printer->Print(vars, \"enum $enumbase$ {\\n\");\n  printer->Annotate(\"enumbase\", descriptor_);\n  printer->Indent();\n\n  const EnumValueDescriptor* min_value = descriptor_->value(0);\n  const EnumValueDescriptor* max_value = descriptor_->value(0);\n\n  for (int i = 0; i < descriptor_->value_count(); i++) {\n    vars[\"name\"] = EnumValueName(descriptor_->value(i));\n    // In C++, an value of -2147483648 gets interpreted as the negative of\n    // 2147483648, and since 2147483648 can't fit in an integer, this produces a\n    // compiler warning.  This works around that issue.\n    vars[\"number\"] = Int32ToString(descriptor_->value(i)->number());\n    vars[\"prefix\"] = (descriptor_->containing_type() == NULL) ?\n      \"\" : classname_ + \"_\";\n    vars[\"deprecation\"] = descriptor_->value(i)->options().deprecated() ?\n        \" PROTOBUF_DEPRECATED\" : \"\";\n\n    if (i > 0) printer->Print(\",\\n\");\n    printer->Print(vars, \"$prefix$$name$$deprecation$ = $number$\");\n\n    if (descriptor_->value(i)->number() < min_value->number()) {\n      min_value = descriptor_->value(i);\n    }\n    if (descriptor_->value(i)->number() > max_value->number()) {\n      max_value = descriptor_->value(i);\n    }\n  }\n\n  if (HasPreservingUnknownEnumSemantics(descriptor_->file())) {\n    // For new enum semantics: generate min and max sentinel values equal to\n    // INT32_MIN and INT32_MAX\n    if (descriptor_->value_count() > 0) printer->Print(\",\\n\");\n    printer->Print(vars,\n        \"$classname$_$prefix$INT_MIN_SENTINEL_DO_NOT_USE_ = ::google::protobuf::kint32min,\\n\"\n        \"$classname$_$prefix$INT_MAX_SENTINEL_DO_NOT_USE_ = ::google::protobuf::kint32max\");\n  }\n\n  printer->Outdent();\n  printer->Print(\"\\n};\\n\");\n\n  vars[\"min_name\"] = EnumValueName(min_value);\n  vars[\"max_name\"] = EnumValueName(max_value);\n\n  if (options_.dllexport_decl.empty()) {\n    vars[\"dllexport\"] = \"\";\n  } else {\n    vars[\"dllexport\"] = options_.dllexport_decl + \" \";\n  }\n\n  printer->Print(vars,\n    \"$dllexport$bool $classname$_IsValid(int value);\\n\"\n    \"const $classname$ $prefix$$short_name$_MIN = $prefix$$min_name$;\\n\"\n    \"const $classname$ $prefix$$short_name$_MAX = $prefix$$max_name$;\\n\");\n\n  if (generate_array_size_) {\n    printer->Print(vars,\n      \"const int $prefix$$short_name$_ARRAYSIZE = \"\n      \"$prefix$$short_name$_MAX + 1;\\n\\n\");\n  }\n\n  if (HasDescriptorMethods(descriptor_->file(), options_)) {\n    printer->Print(vars,\n      \"$dllexport$const ::google::protobuf::EnumDescriptor* $classname$_descriptor();\\n\");\n    // The _Name and _Parse methods\n    printer->Print(\n        vars,\n        \"inline const ::std::string& $classname$_Name($classname$ value) {\\n\"\n        \"  return ::google::protobuf::internal::NameOfEnum(\\n\"\n        \"    $classname$_descriptor(), value);\\n\"\n        \"}\\n\");\n    printer->Print(vars,\n      \"inline bool $classname$_Parse(\\n\"\n      \"    const ::std::string& name, $classname$* value) {\\n\"\n      \"  return ::google::protobuf::internal::ParseNamedEnum<$classname$>(\\n\"\n      \"    $classname$_descriptor(), name, value);\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid EnumGenerator::\nGenerateGetEnumDescriptorSpecializations(io::Printer* printer) {\n  printer->Print(\n      \"template <> struct is_proto_enum< $classname$> : ::google::protobuf::internal::true_type \"\n      \"{};\\n\",\n      \"classname\", ClassName(descriptor_, true));\n  if (HasDescriptorMethods(descriptor_->file(), options_)) {\n    printer->Print(\n      \"template <>\\n\"\n      \"inline const EnumDescriptor* GetEnumDescriptor< $classname$>() {\\n\"\n      \"  return $classname$_descriptor();\\n\"\n      \"}\\n\",\n      \"classname\", ClassName(descriptor_, true));\n  }\n}\n\nvoid EnumGenerator::GenerateSymbolImports(io::Printer* printer) {\n  map<string, string> vars;\n  vars[\"nested_name\"] = descriptor_->name();\n  vars[\"classname\"] = classname_;\n  vars[\"constexpr\"] = options_.proto_h ? \"constexpr \" : \"\";\n  printer->Print(vars, \"typedef $classname$ $nested_name$;\\n\");\n\n  for (int j = 0; j < descriptor_->value_count(); j++) {\n    vars[\"tag\"] = EnumValueName(descriptor_->value(j));\n    vars[\"deprecated_attr\"] = descriptor_->value(j)->options().deprecated() ?\n      \"GOOGLE_PROTOBUF_DEPRECATED_ATTR \" : \"\";\n    printer->Print(vars,\n      \"$deprecated_attr$static $constexpr$const $nested_name$ $tag$ =\\n\"\n      \"  $classname$_$tag$;\\n\");\n  }\n\n  printer->Print(vars,\n    \"static inline bool $nested_name$_IsValid(int value) {\\n\"\n    \"  return $classname$_IsValid(value);\\n\"\n    \"}\\n\"\n    \"static const $nested_name$ $nested_name$_MIN =\\n\"\n    \"  $classname$_$nested_name$_MIN;\\n\"\n    \"static const $nested_name$ $nested_name$_MAX =\\n\"\n    \"  $classname$_$nested_name$_MAX;\\n\");\n  if (generate_array_size_) {\n    printer->Print(vars,\n      \"static const int $nested_name$_ARRAYSIZE =\\n\"\n      \"  $classname$_$nested_name$_ARRAYSIZE;\\n\");\n  }\n\n  if (HasDescriptorMethods(descriptor_->file(), options_)) {\n    printer->Print(vars,\n      \"static inline const ::google::protobuf::EnumDescriptor*\\n\"\n      \"$nested_name$_descriptor() {\\n\"\n      \"  return $classname$_descriptor();\\n\"\n      \"}\\n\");\n    printer->Print(vars,\n                   \"static inline const ::std::string& \"\n                   \"$nested_name$_Name($nested_name$ value) {\"\n                   \"\\n\"\n                   \"  return $classname$_Name(value);\\n\"\n                   \"}\\n\");\n    printer->Print(vars,\n      \"static inline bool $nested_name$_Parse(const ::std::string& name,\\n\"\n      \"    $nested_name$* value) {\\n\"\n      \"  return $classname$_Parse(name, value);\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid EnumGenerator::GenerateDescriptorInitializer(\n    io::Printer* printer, int index) {\n  map<string, string> vars;\n  vars[\"classname\"] = classname_;\n  vars[\"index\"] = SimpleItoa(index);\n\n  if (descriptor_->containing_type() == NULL) {\n    printer->Print(vars,\n      \"$classname$_descriptor_ = file->enum_type($index$);\\n\");\n  } else {\n    vars[\"parent\"] = ClassName(descriptor_->containing_type(), false);\n    printer->Print(vars,\n      \"$classname$_descriptor_ = $parent$_descriptor_->enum_type($index$);\\n\");\n  }\n}\n\nvoid EnumGenerator::GenerateMethods(io::Printer* printer) {\n  map<string, string> vars;\n  vars[\"classname\"] = classname_;\n  vars[\"constexpr\"] = options_.proto_h ? \"constexpr \" : \"\";\n\n  if (HasDescriptorMethods(descriptor_->file(), options_)) {\n    printer->Print(vars,\n      \"const ::google::protobuf::EnumDescriptor* $classname$_descriptor() {\\n\"\n      \"  protobuf_AssignDescriptorsOnce();\\n\"\n      \"  return $classname$_descriptor_;\\n\"\n      \"}\\n\");\n  }\n\n  printer->Print(vars,\n    \"bool $classname$_IsValid(int value) {\\n\"\n    \"  switch(value) {\\n\");\n\n  // Multiple values may have the same number.  Make sure we only cover\n  // each number once by first constructing a set containing all valid\n  // numbers, then printing a case statement for each element.\n\n  set<int> numbers;\n  for (int j = 0; j < descriptor_->value_count(); j++) {\n    const EnumValueDescriptor* value = descriptor_->value(j);\n    numbers.insert(value->number());\n  }\n\n  for (set<int>::iterator iter = numbers.begin();\n       iter != numbers.end(); ++iter) {\n    printer->Print(\n      \"    case $number$:\\n\",\n      \"number\", Int32ToString(*iter));\n  }\n\n  printer->Print(vars,\n    \"      return true;\\n\"\n    \"    default:\\n\"\n    \"      return false;\\n\"\n    \"  }\\n\"\n    \"}\\n\"\n    \"\\n\");\n\n  if (descriptor_->containing_type() != NULL) {\n    // We need to \"define\" the static constants which were declared in the\n    // header, to give the linker a place to put them.  Or at least the C++\n    // standard says we have to.  MSVC actually insists that we do _not_ define\n    // them again in the .cc file, prior to VC++ 2015.\n    printer->Print(\"#if !defined(_MSC_VER) || _MSC_VER >= 1900\\n\");\n\n    vars[\"parent\"] = ClassName(descriptor_->containing_type(), false);\n    vars[\"nested_name\"] = descriptor_->name();\n    for (int i = 0; i < descriptor_->value_count(); i++) {\n      vars[\"value\"] = EnumValueName(descriptor_->value(i));\n      printer->Print(vars,\n        \"$constexpr$const $classname$ $parent$::$value$;\\n\");\n    }\n    printer->Print(vars,\n      \"const $classname$ $parent$::$nested_name$_MIN;\\n\"\n      \"const $classname$ $parent$::$nested_name$_MAX;\\n\");\n    if (generate_array_size_) {\n      printer->Print(vars,\n        \"const int $parent$::$nested_name$_ARRAYSIZE;\\n\");\n    }\n\n    printer->Print(\"#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\\n\");\n  }\n}\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_enum.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_H__\n#define GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_H__\n\n#include <map>\n#include <set>\n#include <string>\n#include <google/protobuf/compiler/cpp/cpp_options.h>\n#include <google/protobuf/descriptor.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace io {\n    class Printer;             // printer.h\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\nclass EnumGenerator {\n public:\n  // See generator.cc for the meaning of dllexport_decl.\n  EnumGenerator(const EnumDescriptor* descriptor, const Options& options);\n  ~EnumGenerator();\n\n  // Header stuff.\n\n  // Fills the name to use when declaring the enum. This is for use when\n  // generating other .proto.h files. This code should be placed within the\n  // enum's package namespace, but NOT within any class, even for nested\n  // enums. A given key in enum_names will map from an enum class name to the\n  // EnumDescriptor that was responsible for its inclusion in the map. This can\n  // be used to associate the descriptor with the code generated for it.\n  void FillForwardDeclaration(map<string, const EnumDescriptor*>* enum_names);\n\n  // Generate header code defining the enum.  This code should be placed\n  // within the enum's package namespace, but NOT within any class, even for\n  // nested enums.\n  void GenerateDefinition(io::Printer* printer);\n\n  // Generate specialization of GetEnumDescriptor<MyEnum>().\n  // Precondition: in ::google::protobuf namespace.\n  void GenerateGetEnumDescriptorSpecializations(io::Printer* printer);\n\n  // For enums nested within a message, generate code to import all the enum's\n  // symbols (e.g. the enum type name, all its values, etc.) into the class's\n  // namespace.  This should be placed inside the class definition in the\n  // header.\n  void GenerateSymbolImports(io::Printer* printer);\n\n  // Source file stuff.\n\n  // Generate code that initializes the global variable storing the enum's\n  // descriptor.\n  void GenerateDescriptorInitializer(io::Printer* printer, int index);\n\n  // Generate non-inline methods related to the enum, such as IsValidValue().\n  // Goes in the .cc file.\n  void GenerateMethods(io::Printer* printer);\n\n private:\n  const EnumDescriptor* descriptor_;\n  const string classname_;\n  const Options& options_;\n  // whether to generate the *_ARRAYSIZE constant.\n  const bool generate_array_size_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator);\n};\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_enum_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/cpp/cpp_enum_field.h>\n#include <google/protobuf/compiler/cpp/cpp_helpers.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\nnamespace {\n\nvoid SetEnumVariables(const FieldDescriptor* descriptor,\n                      map<string, string>* variables,\n                      const Options& options) {\n  SetCommonFieldVariables(descriptor, variables, options);\n  const EnumValueDescriptor* default_value = descriptor->default_value_enum();\n  (*variables)[\"type\"] = ClassName(descriptor->enum_type(), true);\n  (*variables)[\"default\"] = Int32ToString(default_value->number());\n  (*variables)[\"full_name\"] = descriptor->full_name();\n}\n\n}  // namespace\n\n// ===================================================================\n\nEnumFieldGenerator::EnumFieldGenerator(const FieldDescriptor* descriptor,\n                                       const Options& options)\n    : FieldGenerator(options), descriptor_(descriptor) {\n  SetEnumVariables(descriptor, &variables_, options);\n}\n\nEnumFieldGenerator::~EnumFieldGenerator() {}\n\nvoid EnumFieldGenerator::\nGeneratePrivateMembers(io::Printer* printer) const {\n  printer->Print(variables_, \"int $name$_;\\n\");\n}\n\nvoid EnumFieldGenerator::\nGenerateAccessorDeclarations(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$deprecated_attr$$type$ $name$() const;\\n\"\n    \"$deprecated_attr$void set_$name$($type$ value);\\n\");\n}\n\nvoid EnumFieldGenerator::\nGenerateInlineAccessorDefinitions(io::Printer* printer,\n                                  bool is_inline) const {\n  map<string, string> variables(variables_);\n  variables[\"inline\"] = is_inline ? \"inline\" : \"\";\n  printer->Print(variables,\n    \"$inline$ $type$ $classname$::$name$() const {\\n\"\n    \"  // @@protoc_insertion_point(field_get:$full_name$)\\n\"\n    \"  return static_cast< $type$ >($name$_);\\n\"\n    \"}\\n\"\n    \"$inline$ void $classname$::set_$name$($type$ value) {\\n\");\n  if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) {\n    printer->Print(variables,\n    \"  assert($type$_IsValid(value));\\n\");\n  }\n  printer->Print(variables,\n    \"  $set_hasbit$\\n\"\n    \"  $name$_ = value;\\n\"\n    \"  // @@protoc_insertion_point(field_set:$full_name$)\\n\"\n    \"}\\n\");\n}\n\nvoid EnumFieldGenerator::\nGenerateClearingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_ = $default$;\\n\");\n}\n\nvoid EnumFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"set_$name$(from.$name$());\\n\");\n}\n\nvoid EnumFieldGenerator::\nGenerateSwappingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"std::swap($name$_, other->$name$_);\\n\");\n}\n\nvoid EnumFieldGenerator::\nGenerateConstructorCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_ = $default$;\\n\");\n}\n\nvoid EnumFieldGenerator::\nGenerateMergeFromCodedStream(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"int value;\\n\"\n    \"DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\\n\"\n    \"         int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\\n\"\n    \"       input, &value)));\\n\");\n  if (HasPreservingUnknownEnumSemantics(descriptor_->file())) {\n    printer->Print(variables_,\n      \"set_$name$(static_cast< $type$ >(value));\\n\");\n  } else {\n    printer->Print(variables_,\n      \"if ($type$_IsValid(value)) {\\n\"\n      \"  set_$name$(static_cast< $type$ >(value));\\n\");\n    if (UseUnknownFieldSet(descriptor_->file(), options_)) {\n      printer->Print(variables_,\n        \"} else {\\n\"\n        \"  mutable_unknown_fields()->AddVarint($number$, value);\\n\");\n    } else {\n      printer->Print(\n        \"} else {\\n\"\n        \"  unknown_fields_stream.WriteVarint32($tag$);\\n\"\n        \"  unknown_fields_stream.WriteVarint32(value);\\n\",\n        \"tag\", SimpleItoa(internal::WireFormat::MakeTag(descriptor_)));\n    }\n    printer->Print(variables_,\n      \"}\\n\");\n  }\n}\n\nvoid EnumFieldGenerator::\nGenerateSerializeWithCachedSizes(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"::google::protobuf::internal::WireFormatLite::WriteEnum(\\n\"\n    \"  $number$, this->$name$(), output);\\n\");\n}\n\nvoid EnumFieldGenerator::\nGenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(\\n\"\n    \"  $number$, this->$name$(), target);\\n\");\n}\n\nvoid EnumFieldGenerator::\nGenerateByteSize(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"total_size += $tag_size$ +\\n\"\n    \"  ::google::protobuf::internal::WireFormatLite::EnumSize(this->$name$());\\n\");\n}\n\n// ===================================================================\n\nEnumOneofFieldGenerator::\nEnumOneofFieldGenerator(const FieldDescriptor* descriptor,\n                        const Options& options)\n  : EnumFieldGenerator(descriptor, options) {\n  SetCommonOneofFieldVariables(descriptor, &variables_);\n}\n\nEnumOneofFieldGenerator::~EnumOneofFieldGenerator() {}\n\nvoid EnumOneofFieldGenerator::\nGenerateInlineAccessorDefinitions(io::Printer* printer,\n                                  bool is_inline) const {\n  map<string, string> variables(variables_);\n  variables[\"inline\"] = is_inline ? \"inline\" : \"\";\n  printer->Print(variables,\n    \"$inline$ $type$ $classname$::$name$() const {\\n\"\n    \"  // @@protoc_insertion_point(field_get:$full_name$)\\n\"\n    \"  if (has_$name$()) {\\n\"\n    \"    return static_cast< $type$ >($oneof_prefix$$name$_);\\n\"\n    \"  }\\n\"\n    \"  return static_cast< $type$ >($default$);\\n\"\n    \"}\\n\"\n    \"$inline$ void $classname$::set_$name$($type$ value) {\\n\");\n  if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) {\n    printer->Print(variables,\n    \"  assert($type$_IsValid(value));\\n\");\n  }\n  printer->Print(variables,\n    \"  if (!has_$name$()) {\\n\"\n    \"    clear_$oneof_name$();\\n\"\n    \"    set_has_$name$();\\n\"\n    \"  }\\n\"\n    \"  $oneof_prefix$$name$_ = value;\\n\"\n    \"  // @@protoc_insertion_point(field_set:$full_name$)\\n\"\n    \"}\\n\");\n}\n\nvoid EnumOneofFieldGenerator::\nGenerateClearingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$oneof_prefix$$name$_ = $default$;\\n\");\n}\n\nvoid EnumOneofFieldGenerator::\nGenerateSwappingCode(io::Printer* printer) const {\n  // Don't print any swapping code. Swapping the union will swap this field.\n}\n\nvoid EnumOneofFieldGenerator::\nGenerateConstructorCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"  $classname$_default_oneof_instance_->$name$_ = $default$;\\n\");\n}\n\n// ===================================================================\n\nRepeatedEnumFieldGenerator::RepeatedEnumFieldGenerator(\n    const FieldDescriptor* descriptor, const Options& options)\n    : FieldGenerator(options), descriptor_(descriptor) {\n  SetEnumVariables(descriptor, &variables_, options);\n}\n\nRepeatedEnumFieldGenerator::~RepeatedEnumFieldGenerator() {}\n\nvoid RepeatedEnumFieldGenerator::\nGeneratePrivateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"::google::protobuf::RepeatedField<int> $name$_;\\n\");\n  if (descriptor_->is_packed() &&\n      HasGeneratedMethods(descriptor_->file(), options_)) {\n    printer->Print(variables_,\n      \"mutable int _$name$_cached_byte_size_;\\n\");\n  }\n}\n\nvoid RepeatedEnumFieldGenerator::\nGenerateAccessorDeclarations(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$deprecated_attr$$type$ $name$(int index) const;\\n\"\n    \"$deprecated_attr$void set_$name$(int index, $type$ value);\\n\"\n    \"$deprecated_attr$void add_$name$($type$ value);\\n\");\n  printer->Print(variables_,\n    \"$deprecated_attr$const ::google::protobuf::RepeatedField<int>& $name$() const;\\n\"\n    \"$deprecated_attr$::google::protobuf::RepeatedField<int>* mutable_$name$();\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::\nGenerateInlineAccessorDefinitions(io::Printer* printer,\n                                  bool is_inline) const {\n  map<string, string> variables(variables_);\n  variables[\"inline\"] = is_inline ? \"inline\" : \"\";\n  printer->Print(variables,\n    \"$inline$ $type$ $classname$::$name$(int index) const {\\n\"\n    \"  // @@protoc_insertion_point(field_get:$full_name$)\\n\"\n    \"  return static_cast< $type$ >($name$_.Get(index));\\n\"\n    \"}\\n\"\n    \"$inline$ void $classname$::set_$name$(int index, $type$ value) {\\n\");\n  if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) {\n    printer->Print(variables,\n    \"  assert($type$_IsValid(value));\\n\");\n  }\n  printer->Print(variables,\n    \"  $name$_.Set(index, value);\\n\"\n    \"  // @@protoc_insertion_point(field_set:$full_name$)\\n\"\n    \"}\\n\"\n    \"$inline$ void $classname$::add_$name$($type$ value) {\\n\");\n  if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) {\n    printer->Print(variables,\n    \"  assert($type$_IsValid(value));\\n\");\n  }\n  printer->Print(variables,\n    \"  $name$_.Add(value);\\n\"\n    \"  // @@protoc_insertion_point(field_add:$full_name$)\\n\"\n    \"}\\n\");\n  printer->Print(variables,\n    \"$inline$ const ::google::protobuf::RepeatedField<int>&\\n\"\n    \"$classname$::$name$() const {\\n\"\n    \"  // @@protoc_insertion_point(field_list:$full_name$)\\n\"\n    \"  return $name$_;\\n\"\n    \"}\\n\"\n    \"$inline$ ::google::protobuf::RepeatedField<int>*\\n\"\n    \"$classname$::mutable_$name$() {\\n\"\n    \"  // @@protoc_insertion_point(field_mutable_list:$full_name$)\\n\"\n    \"  return &$name$_;\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::\nGenerateClearingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_.Clear();\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_.MergeFrom(from.$name$_);\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::\nGenerateSwappingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_.UnsafeArenaSwap(&other->$name$_);\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::\nGenerateConstructorCode(io::Printer* printer) const {\n  // Not needed for repeated fields.\n}\n\nvoid RepeatedEnumFieldGenerator::\nGenerateMergeFromCodedStream(io::Printer* printer) const {\n  // Don't use ReadRepeatedPrimitive here so that the enum can be validated.\n  printer->Print(variables_,\n    \"int value;\\n\"\n    \"DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\\n\"\n    \"         int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\\n\"\n    \"       input, &value)));\\n\");\n  if (HasPreservingUnknownEnumSemantics(descriptor_->file())) {\n    printer->Print(variables_,\n      \"add_$name$(static_cast< $type$ >(value));\\n\");\n  } else {\n    printer->Print(variables_,\n      \"if ($type$_IsValid(value)) {\\n\"\n      \"  add_$name$(static_cast< $type$ >(value));\\n\");\n    if (UseUnknownFieldSet(descriptor_->file(), options_)) {\n      printer->Print(variables_,\n        \"} else {\\n\"\n        \"  mutable_unknown_fields()->AddVarint($number$, value);\\n\");\n    } else {\n      printer->Print(\n        \"} else {\\n\"\n        \"  unknown_fields_stream.WriteVarint32(tag);\\n\"\n        \"  unknown_fields_stream.WriteVarint32(value);\\n\");\n    }\n    printer->Print(\"}\\n\");\n  }\n}\n\nvoid RepeatedEnumFieldGenerator::\nGenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const {\n  if (!descriptor_->is_packed()) {\n      // This path is rarely executed, so we use a non-inlined implementation.\n    if (HasPreservingUnknownEnumSemantics(descriptor_->file())) {\n      printer->Print(variables_,\n        \"DO_((::google::protobuf::internal::\"\n                    \"WireFormatLite::ReadPackedEnumPreserveUnknowns(\\n\"\n        \"       input,\\n\"\n        \"       $number$,\\n\"\n        \"       NULL,\\n\"\n        \"       NULL,\\n\"\n        \"       this->mutable_$name$())));\\n\");\n    } else if (UseUnknownFieldSet(descriptor_->file(), options_)) {\n      printer->Print(variables_,\n        \"DO_((::google::protobuf::internal::WireFormat::ReadPackedEnumPreserveUnknowns(\\n\"\n        \"       input,\\n\"\n        \"       $number$,\\n\"\n        \"       $type$_IsValid,\\n\"\n        \"       mutable_unknown_fields(),\\n\"\n        \"       this->mutable_$name$())));\\n\");\n    } else {\n      printer->Print(variables_,\n        \"DO_((::google::protobuf::internal::\"\n                     \"WireFormatLite::ReadPackedEnumPreserveUnknowns(\\n\"\n        \"       input,\\n\"\n        \"       $number$,\\n\"\n        \"       $type$_IsValid,\\n\"\n        \"       &unknown_fields_stream,\\n\"\n        \"       this->mutable_$name$())));\\n\");\n    }\n  } else {\n    printer->Print(variables_,\n      \"::google::protobuf::uint32 length;\\n\"\n      \"DO_(input->ReadVarint32(&length));\\n\"\n      \"::google::protobuf::io::CodedInputStream::Limit limit = \"\n          \"input->PushLimit(length);\\n\"\n      \"while (input->BytesUntilLimit() > 0) {\\n\"\n      \"  int value;\\n\"\n      \"  DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\\n\"\n      \"         int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\\n\"\n      \"       input, &value)));\\n\");\n    if (HasPreservingUnknownEnumSemantics(descriptor_->file())) {\n      printer->Print(variables_,\n      \"  add_$name$(static_cast< $type$ >(value));\\n\");\n    } else {\n      printer->Print(variables_,\n      \"  if ($type$_IsValid(value)) {\\n\"\n      \"    add_$name$(static_cast< $type$ >(value));\\n\"\n      \"  } else {\\n\");\n      if (UseUnknownFieldSet(descriptor_->file(), options_)) {\n        printer->Print(variables_,\n        \"    mutable_unknown_fields()->AddVarint($number$, value);\\n\");\n      } else {\n        printer->Print(variables_,\n        \"    unknown_fields_stream.WriteVarint32(tag);\\n\"\n        \"    unknown_fields_stream.WriteVarint32(value);\\n\");\n      }\n      printer->Print(\n      \"  }\\n\");\n    }\n    printer->Print(variables_,\n      \"}\\n\"\n      \"input->PopLimit(limit);\\n\");\n  }\n}\n\nvoid RepeatedEnumFieldGenerator::\nGenerateSerializeWithCachedSizes(io::Printer* printer) const {\n  if (descriptor_->is_packed()) {\n    // Write the tag and the size.\n    printer->Print(variables_,\n      \"if (this->$name$_size() > 0) {\\n\"\n      \"  ::google::protobuf::internal::WireFormatLite::WriteTag(\\n\"\n      \"    $number$,\\n\"\n      \"    ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\\n\"\n      \"    output);\\n\"\n      \"  output->WriteVarint32(_$name$_cached_byte_size_);\\n\"\n      \"}\\n\");\n  }\n  printer->Print(variables_,\n      \"for (int i = 0; i < this->$name$_size(); i++) {\\n\");\n  if (descriptor_->is_packed()) {\n    printer->Print(variables_,\n      \"  ::google::protobuf::internal::WireFormatLite::WriteEnumNoTag(\\n\"\n      \"    this->$name$(i), output);\\n\");\n  } else {\n    printer->Print(variables_,\n      \"  ::google::protobuf::internal::WireFormatLite::WriteEnum(\\n\"\n      \"    $number$, this->$name$(i), output);\\n\");\n  }\n  printer->Print(\"}\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::\nGenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {\n  if (descriptor_->is_packed()) {\n    // Write the tag and the size.\n    printer->Print(variables_,\n      \"if (this->$name$_size() > 0) {\\n\"\n      \"  target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray(\\n\"\n      \"    $number$,\\n\"\n      \"    ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\\n\"\n      \"    target);\\n\"\n      \"  target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(\"\n      \"    _$name$_cached_byte_size_, target);\\n\"\n      \"}\\n\");\n  }\n  printer->Print(variables_,\n      \"for (int i = 0; i < this->$name$_size(); i++) {\\n\");\n  if (descriptor_->is_packed()) {\n    printer->Print(variables_,\n      \"  target = ::google::protobuf::internal::WireFormatLite::WriteEnumNoTagToArray(\\n\"\n      \"    this->$name$(i), target);\\n\");\n  } else {\n    printer->Print(variables_,\n      \"  target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(\\n\"\n      \"    $number$, this->$name$(i), target);\\n\");\n  }\n  printer->Print(\"}\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::\nGenerateByteSize(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"{\\n\"\n    \"  int data_size = 0;\\n\");\n  printer->Indent();\n  printer->Print(variables_,\n      \"for (int i = 0; i < this->$name$_size(); i++) {\\n\"\n      \"  data_size += ::google::protobuf::internal::WireFormatLite::EnumSize(\\n\"\n      \"    this->$name$(i));\\n\"\n      \"}\\n\");\n\n  if (descriptor_->is_packed()) {\n    printer->Print(variables_,\n      \"if (data_size > 0) {\\n\"\n      \"  total_size += $tag_size$ +\\n\"\n      \"    ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);\\n\"\n      \"}\\n\"\n      \"GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\\n\"\n      \"_$name$_cached_byte_size_ = data_size;\\n\"\n      \"GOOGLE_SAFE_CONCURRENT_WRITES_END();\\n\"\n      \"total_size += data_size;\\n\");\n  } else {\n    printer->Print(variables_,\n      \"total_size += $tag_size$ * this->$name$_size() + data_size;\\n\");\n  }\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_enum_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_FIELD_H__\n\n#include <map>\n#include <string>\n#include <google/protobuf/compiler/cpp/cpp_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\nclass EnumFieldGenerator : public FieldGenerator {\n public:\n  EnumFieldGenerator(const FieldDescriptor* descriptor, const Options& options);\n  ~EnumFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  void GeneratePrivateMembers(io::Printer* printer) const;\n  void GenerateAccessorDeclarations(io::Printer* printer) const;\n  void GenerateInlineAccessorDefinitions(io::Printer* printer,\n                                         bool is_inline) const;\n  void GenerateClearingCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateSwappingCode(io::Printer* printer) const;\n  void GenerateConstructorCode(io::Printer* printer) const;\n  void GenerateMergeFromCodedStream(io::Printer* printer) const;\n  void GenerateSerializeWithCachedSizes(io::Printer* printer) const;\n  void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;\n  void GenerateByteSize(io::Printer* printer) const;\n\n protected:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator);\n};\n\nclass EnumOneofFieldGenerator : public EnumFieldGenerator {\n public:\n  EnumOneofFieldGenerator(const FieldDescriptor* descriptor,\n                          const Options& options);\n  ~EnumOneofFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  void GenerateInlineAccessorDefinitions(io::Printer* printer,\n                                         bool is_inline) const;\n  void GenerateClearingCode(io::Printer* printer) const;\n  void GenerateSwappingCode(io::Printer* printer) const;\n  void GenerateConstructorCode(io::Printer* printer) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumOneofFieldGenerator);\n};\n\nclass RepeatedEnumFieldGenerator : public FieldGenerator {\n public:\n  RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor,\n                             const Options& options);\n  ~RepeatedEnumFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  void GeneratePrivateMembers(io::Printer* printer) const;\n  void GenerateAccessorDeclarations(io::Printer* printer) const;\n  void GenerateInlineAccessorDefinitions(io::Printer* printer,\n                                         bool is_inline) const;\n  void GenerateClearingCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateSwappingCode(io::Printer* printer) const;\n  void GenerateConstructorCode(io::Printer* printer) const;\n  void GenerateMergeFromCodedStream(io::Printer* printer) const;\n  void GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const;\n  void GenerateSerializeWithCachedSizes(io::Printer* printer) const;\n  void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;\n  void GenerateByteSize(io::Printer* printer) const;\n\n private:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedEnumFieldGenerator);\n};\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_CPP_ENUM_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_extension.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/cpp/cpp_extension.h>\n#include <map>\n#include <google/protobuf/compiler/cpp/cpp_helpers.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/descriptor.pb.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\nnamespace {\n\n// Returns the fully-qualified class name of the message that this field\n// extends. This function is used in the Google-internal code to handle some\n// legacy cases.\nstring ExtendeeClassName(const FieldDescriptor* descriptor) {\n  const Descriptor* extendee = descriptor->containing_type();\n  return ClassName(extendee, true);\n}\n\n}  // anonymous namespace\n\nExtensionGenerator::ExtensionGenerator(const FieldDescriptor* descriptor,\n                                       const Options& options)\n  : descriptor_(descriptor),\n    options_(options) {\n  // Construct type_traits_.\n  if (descriptor_->is_repeated()) {\n    type_traits_ = \"Repeated\";\n  }\n\n  switch (descriptor_->cpp_type()) {\n    case FieldDescriptor::CPPTYPE_ENUM:\n      type_traits_.append(\"EnumTypeTraits< \");\n      type_traits_.append(ClassName(descriptor_->enum_type(), true));\n      type_traits_.append(\", \");\n      type_traits_.append(ClassName(descriptor_->enum_type(), true));\n      type_traits_.append(\"_IsValid>\");\n      break;\n    case FieldDescriptor::CPPTYPE_STRING:\n      type_traits_.append(\"StringTypeTraits\");\n      break;\n    case FieldDescriptor::CPPTYPE_MESSAGE:\n      type_traits_.append(\"MessageTypeTraits< \");\n      type_traits_.append(ClassName(descriptor_->message_type(), true));\n      type_traits_.append(\" >\");\n      break;\n    default:\n      type_traits_.append(\"PrimitiveTypeTraits< \");\n      type_traits_.append(PrimitiveTypeName(descriptor_->cpp_type()));\n      type_traits_.append(\" >\");\n      break;\n  }\n}\n\nExtensionGenerator::~ExtensionGenerator() {}\n\nvoid ExtensionGenerator::GenerateDeclaration(io::Printer* printer) {\n  map<string, string> vars;\n  vars[\"extendee\"     ] = ExtendeeClassName(descriptor_);\n  vars[\"number\"       ] = SimpleItoa(descriptor_->number());\n  vars[\"type_traits\"  ] = type_traits_;\n  vars[\"name\"         ] = descriptor_->name();\n  vars[\"field_type\"   ] = SimpleItoa(static_cast<int>(descriptor_->type()));\n  vars[\"packed\"       ] = descriptor_->options().packed() ? \"true\" : \"false\";\n  vars[\"constant_name\"] = FieldConstantName(descriptor_);\n\n  // If this is a class member, it needs to be declared \"static\".  Otherwise,\n  // it needs to be \"extern\".  In the latter case, it also needs the DLL\n  // export/import specifier.\n  if (descriptor_->extension_scope() == NULL) {\n    vars[\"qualifier\"] = \"extern\";\n    if (!options_.dllexport_decl.empty()) {\n      vars[\"qualifier\"] = options_.dllexport_decl + \" \" + vars[\"qualifier\"];\n    }\n  } else {\n    vars[\"qualifier\"] = \"static\";\n  }\n\n  printer->Print(vars,\n    \"static const int $constant_name$ = $number$;\\n\"\n    \"$qualifier$ ::google::protobuf::internal::ExtensionIdentifier< $extendee$,\\n\"\n    \"    ::google::protobuf::internal::$type_traits$, $field_type$, $packed$ >\\n\"\n    \"  $name$;\\n\"\n    );\n\n}\n\nvoid ExtensionGenerator::GenerateDefinition(io::Printer* printer) {\n  // If this is a class member, it needs to be declared in its class scope.\n  string scope = (descriptor_->extension_scope() == NULL) ? \"\" :\n    ClassName(descriptor_->extension_scope(), false) + \"::\";\n  string name = scope + descriptor_->name();\n\n  map<string, string> vars;\n  vars[\"extendee\"     ] = ExtendeeClassName(descriptor_);\n  vars[\"type_traits\"  ] = type_traits_;\n  vars[\"name\"         ] = name;\n  vars[\"constant_name\"] = FieldConstantName(descriptor_);\n  vars[\"default\"      ] = DefaultValue(descriptor_);\n  vars[\"field_type\"   ] = SimpleItoa(static_cast<int>(descriptor_->type()));\n  vars[\"packed\"       ] = descriptor_->options().packed() ? \"true\" : \"false\";\n  vars[\"scope\"        ] = scope;\n\n  if (descriptor_->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {\n    // We need to declare a global string which will contain the default value.\n    // We cannot declare it at class scope because that would require exposing\n    // it in the header which would be annoying for other reasons.  So we\n    // replace :: with _ in the name and declare it as a global.\n    string global_name = StringReplace(name, \"::\", \"_\", true);\n    vars[\"global_name\"] = global_name;\n    printer->Print(vars,\n      \"const ::std::string $global_name$_default($default$);\\n\");\n\n    // Update the default to refer to the string global.\n    vars[\"default\"] = global_name + \"_default\";\n  }\n\n  // Likewise, class members need to declare the field constant variable.\n  if (descriptor_->extension_scope() != NULL) {\n    printer->Print(vars,\n      \"#if !defined(_MSC_VER) || _MSC_VER >= 1900\\n\"\n      \"const int $scope$$constant_name$;\\n\"\n      \"#endif\\n\");\n  }\n\n  printer->Print(vars,\n    \"::google::protobuf::internal::ExtensionIdentifier< $extendee$,\\n\"\n    \"    ::google::protobuf::internal::$type_traits$, $field_type$, $packed$ >\\n\"\n    \"  $name$($constant_name$, $default$);\\n\");\n}\n\nvoid ExtensionGenerator::GenerateRegistration(io::Printer* printer) {\n  map<string, string> vars;\n  vars[\"extendee\"   ] = ExtendeeClassName(descriptor_);\n  vars[\"number\"     ] = SimpleItoa(descriptor_->number());\n  vars[\"field_type\" ] = SimpleItoa(static_cast<int>(descriptor_->type()));\n  vars[\"is_repeated\"] = descriptor_->is_repeated() ? \"true\" : \"false\";\n  vars[\"is_packed\"  ] = (descriptor_->is_repeated() &&\n                         descriptor_->options().packed())\n                        ? \"true\" : \"false\";\n\n  switch (descriptor_->cpp_type()) {\n    case FieldDescriptor::CPPTYPE_ENUM:\n      printer->Print(vars,\n        \"::google::protobuf::internal::ExtensionSet::RegisterEnumExtension(\\n\"\n        \"  &$extendee$::default_instance(),\\n\"\n        \"  $number$, $field_type$, $is_repeated$, $is_packed$,\\n\");\n      printer->Print(\n        \"  &$type$_IsValid);\\n\",\n        \"type\", ClassName(descriptor_->enum_type(), true));\n      break;\n    case FieldDescriptor::CPPTYPE_MESSAGE:\n      printer->Print(vars,\n        \"::google::protobuf::internal::ExtensionSet::RegisterMessageExtension(\\n\"\n        \"  &$extendee$::default_instance(),\\n\"\n        \"  $number$, $field_type$, $is_repeated$, $is_packed$,\\n\");\n      printer->Print(\n        \"  &$type$::default_instance());\\n\",\n        \"type\", ClassName(descriptor_->message_type(), true));\n      break;\n    default:\n      printer->Print(vars,\n        \"::google::protobuf::internal::ExtensionSet::RegisterExtension(\\n\"\n        \"  &$extendee$::default_instance(),\\n\"\n        \"  $number$, $field_type$, $is_repeated$, $is_packed$);\\n\");\n      break;\n  }\n}\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_extension.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_EXTENSION_H__\n#define GOOGLE_PROTOBUF_COMPILER_CPP_EXTENSION_H__\n\n#include <string>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/compiler/cpp/cpp_options.h>\n\nnamespace google {\nnamespace protobuf {\n  class FieldDescriptor;       // descriptor.h\n  namespace io {\n    class Printer;             // printer.h\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\n// Generates code for an extension, which may be within the scope of some\n// message or may be at file scope.  This is much simpler than FieldGenerator\n// since extensions are just simple identifiers with interesting types.\nclass ExtensionGenerator {\n public:\n  // See generator.cc for the meaning of dllexport_decl.\n  explicit ExtensionGenerator(const FieldDescriptor* descriptor,\n                              const Options& options);\n  ~ExtensionGenerator();\n\n  // Header stuff.\n  void GenerateDeclaration(io::Printer* printer);\n\n  // Source file stuff.\n  void GenerateDefinition(io::Printer* printer);\n\n  // Generate code to register the extension.\n  void GenerateRegistration(io::Printer* printer);\n\n private:\n  const FieldDescriptor* descriptor_;\n  string type_traits_;\n  Options options_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator);\n};\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/cpp/cpp_field.h>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#include <google/protobuf/compiler/cpp/cpp_helpers.h>\n#include <google/protobuf/compiler/cpp/cpp_primitive_field.h>\n#include <google/protobuf/compiler/cpp/cpp_string_field.h>\n#include <google/protobuf/compiler/cpp/cpp_enum_field.h>\n#include <google/protobuf/compiler/cpp/cpp_map_field.h>\n#include <google/protobuf/compiler/cpp/cpp_message_field.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\nusing internal::WireFormat;\n\nvoid SetCommonFieldVariables(const FieldDescriptor* descriptor,\n                             map<string, string>* variables,\n                             const Options& options) {\n  (*variables)[\"name\"] = FieldName(descriptor);\n  (*variables)[\"index\"] = SimpleItoa(descriptor->index());\n  (*variables)[\"number\"] = SimpleItoa(descriptor->number());\n  (*variables)[\"classname\"] = ClassName(FieldScope(descriptor), false);\n  (*variables)[\"declared_type\"] = DeclaredTypeMethodName(descriptor->type());\n\n  // non_null_ptr_to_name is usable only if has_$name$ is true.  It yields a\n  // pointer that will not be NULL.  Subclasses of FieldGenerator may set\n  // (*variables)[\"non_null_ptr_to_name\"] differently.\n  (*variables)[\"non_null_ptr_to_name\"] =\n      StrCat(\"&this->\", FieldName(descriptor), \"()\");\n\n  (*variables)[\"tag_size\"] = SimpleItoa(\n    WireFormat::TagSize(descriptor->number(), descriptor->type()));\n  (*variables)[\"deprecation\"] = descriptor->options().deprecated()\n      ? \" PROTOBUF_DEPRECATED\" : \"\";\n  (*variables)[\"deprecated_attr\"] = descriptor->options().deprecated()\n      ? \"GOOGLE_PROTOBUF_DEPRECATED_ATTR \" : \"\";\n\n  (*variables)[\"cppget\"] = \"Get\";\n\n  if (HasFieldPresence(descriptor->file())) {\n    (*variables)[\"set_hasbit\"] =\n        \"set_has_\" + FieldName(descriptor) + \"();\";\n    (*variables)[\"clear_hasbit\"] =\n        \"clear_has_\" + FieldName(descriptor) + \"();\";\n  } else {\n    (*variables)[\"set_hasbit\"] = \"\";\n    (*variables)[\"clear_hasbit\"] = \"\";\n  }\n\n  // By default, empty string, so that generic code used for both oneofs and\n  // singular fields can be written.\n  (*variables)[\"oneof_prefix\"] = \"\";\n}\n\nvoid SetCommonOneofFieldVariables(const FieldDescriptor* descriptor,\n                                  map<string, string>* variables) {\n  const string prefix = descriptor->containing_oneof()->name() + \"_.\";\n  (*variables)[\"oneof_prefix\"] = prefix;\n  (*variables)[\"oneof_name\"] = descriptor->containing_oneof()->name();\n  (*variables)[\"non_null_ptr_to_name\"] =\n      StrCat(prefix, (*variables)[\"name\"], \"_\");\n}\n\nFieldGenerator::~FieldGenerator() {}\n\nvoid FieldGenerator::\nGenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const {\n  // Reaching here indicates a bug. Cases are:\n  //   - This FieldGenerator should support packing, but this method should be\n  //     overridden.\n  //   - This FieldGenerator doesn't support packing, and this method should\n  //     never have been called.\n  GOOGLE_LOG(FATAL) << \"GenerateMergeFromCodedStreamWithPacking() \"\n             << \"called on field generator that does not support packing.\";\n\n}\n\nFieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor,\n                                     const Options& options)\n    : descriptor_(descriptor),\n      options_(options),\n      field_generators_(\n          new google::protobuf::scoped_ptr<FieldGenerator>[descriptor->field_count()]) {\n  // Construct all the FieldGenerators.\n  for (int i = 0; i < descriptor->field_count(); i++) {\n    field_generators_[i].reset(MakeGenerator(descriptor->field(i), options));\n  }\n}\n\nFieldGenerator* FieldGeneratorMap::MakeGenerator(const FieldDescriptor* field,\n                                                 const Options& options) {\n  if (field->is_repeated()) {\n    switch (field->cpp_type()) {\n      case FieldDescriptor::CPPTYPE_MESSAGE:\n        if (field->is_map()) {\n          return new MapFieldGenerator(field, options);\n        } else {\n          return new RepeatedMessageFieldGenerator(field, options);\n        }\n      case FieldDescriptor::CPPTYPE_STRING:\n        switch (field->options().ctype()) {\n          default:  // RepeatedStringFieldGenerator handles unknown ctypes.\n          case FieldOptions::STRING:\n            return new RepeatedStringFieldGenerator(field, options);\n        }\n      case FieldDescriptor::CPPTYPE_ENUM:\n        return new RepeatedEnumFieldGenerator(field, options);\n      default:\n        return new RepeatedPrimitiveFieldGenerator(field, options);\n    }\n  } else if (field->containing_oneof()) {\n    switch (field->cpp_type()) {\n      case FieldDescriptor::CPPTYPE_MESSAGE:\n        return new MessageOneofFieldGenerator(field, options);\n      case FieldDescriptor::CPPTYPE_STRING:\n        switch (field->options().ctype()) {\n          default:  // StringOneofFieldGenerator handles unknown ctypes.\n          case FieldOptions::STRING:\n            return new StringOneofFieldGenerator(field, options);\n        }\n      case FieldDescriptor::CPPTYPE_ENUM:\n        return new EnumOneofFieldGenerator(field, options);\n      default:\n        return new PrimitiveOneofFieldGenerator(field, options);\n    }\n  } else {\n    switch (field->cpp_type()) {\n      case FieldDescriptor::CPPTYPE_MESSAGE:\n        return new MessageFieldGenerator(field, options);\n      case FieldDescriptor::CPPTYPE_STRING:\n        switch (field->options().ctype()) {\n          default:  // StringFieldGenerator handles unknown ctypes.\n          case FieldOptions::STRING:\n            return new StringFieldGenerator(field, options);\n        }\n      case FieldDescriptor::CPPTYPE_ENUM:\n        return new EnumFieldGenerator(field, options);\n      default:\n        return new PrimitiveFieldGenerator(field, options);\n    }\n  }\n}\n\nFieldGeneratorMap::~FieldGeneratorMap() {}\n\nconst FieldGenerator& FieldGeneratorMap::get(\n    const FieldDescriptor* field) const {\n  GOOGLE_CHECK_EQ(field->containing_type(), descriptor_);\n  return *field_generators_[field->index()];\n}\n\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_H__\n\n#include <map>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <string>\n\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/compiler/cpp/cpp_options.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace io {\n    class Printer;             // printer.h\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\n// Helper function: set variables in the map that are the same for all\n// field code generators.\n// ['name', 'index', 'number', 'classname', 'declared_type', 'tag_size',\n// 'deprecation'].\nvoid SetCommonFieldVariables(const FieldDescriptor* descriptor,\n                             map<string, string>* variables,\n                             const Options& options);\n\nvoid SetCommonOneofFieldVariables(const FieldDescriptor* descriptor,\n                                  map<string, string>* variables);\n\nclass FieldGenerator {\n public:\n  explicit FieldGenerator(const Options& options) : options_(options) {}\n  virtual ~FieldGenerator();\n\n  // Generate lines of code declaring members fields of the message class\n  // needed to represent this field.  These are placed inside the message\n  // class.\n  virtual void GeneratePrivateMembers(io::Printer* printer) const = 0;\n\n  // Generate static default variable for this field. These are placed inside\n  // the message class. Most field types don't need this, so the default\n  // implementation is empty.\n  virtual void GenerateStaticMembers(io::Printer* /*printer*/) const {}\n\n  // Generate prototypes for accessors that will manipulate imported\n  // messages inline.  These are for .proto.h headers.\n  //\n  // In .proto.h mode, the headers of imports are not #included. However,\n  // functions that manipulate the imported message types need access to\n  // the class definition of the imported message, meaning that the headers\n  // must be #included. To get around this, functions that manipulate\n  // imported message objects are defined as dependent functions in a base\n  // template class. By making them dependent template functions, the\n  // function templates will not be instantiated until they are called, so\n  // we can defer to those translation units to #include the necessary\n  // generated headers.\n  //\n  // See:\n  // http://en.cppreference.com/w/cpp/language/class_template#Implicit_instantiation\n  //\n  // Most field types don't need this, so the default implementation is empty.\n  virtual void GenerateDependentAccessorDeclarations(\n      io::Printer* printer) const {}\n\n  // Generate prototypes for all of the accessor functions related to this\n  // field.  These are placed inside the class definition.\n  virtual void GenerateAccessorDeclarations(io::Printer* printer) const = 0;\n\n  // Generate inline definitions of depenent accessor functions for this field.\n  // These are placed inside the header after all class definitions.\n  virtual void GenerateDependentInlineAccessorDefinitions(\n    io::Printer* printer) const {}\n\n  // Generate inline definitions of accessor functions for this field.\n  // These are placed inside the header after all class definitions.\n  // In non-.proto.h mode, this generates dependent accessor functions as well.\n  virtual void GenerateInlineAccessorDefinitions(\n    io::Printer* printer, bool is_inline) const = 0;\n\n  // Generate definitions of accessors that aren't inlined.  These are\n  // placed somewhere in the .cc file.\n  // Most field types don't need this, so the default implementation is empty.\n  virtual void GenerateNonInlineAccessorDefinitions(\n    io::Printer* /*printer*/) const {}\n\n  // Generate lines of code (statements, not declarations) which clear the\n  // field.  This is used to define the clear_$name$() method as well as\n  // the Clear() method for the whole message.\n  virtual void GenerateClearingCode(io::Printer* printer) const = 0;\n\n  // Generate lines of code (statements, not declarations) which merges the\n  // contents of the field from the current message to the target message,\n  // which is stored in the generated code variable \"from\".\n  // This is used to fill in the MergeFrom method for the whole message.\n  // Details of this usage can be found in message.cc under the\n  // GenerateMergeFrom method.\n  virtual void GenerateMergingCode(io::Printer* printer) const = 0;\n\n  // Generate lines of code (statements, not declarations) which swaps\n  // this field and the corresponding field of another message, which\n  // is stored in the generated code variable \"other\". This is used to\n  // define the Swap method. Details of usage can be found in\n  // message.cc under the GenerateSwap method.\n  virtual void GenerateSwappingCode(io::Printer* printer) const = 0;\n\n  // Generate initialization code for private members declared by\n  // GeneratePrivateMembers(). These go into the message class's SharedCtor()\n  // method, invoked by each of the generated constructors.\n  virtual void GenerateConstructorCode(io::Printer* printer) const = 0;\n\n  // Generate any code that needs to go in the class's SharedDtor() method,\n  // invoked by the destructor.\n  // Most field types don't need this, so the default implementation is empty.\n  virtual void GenerateDestructorCode(io::Printer* /*printer*/) const {}\n\n  // Generate a manual destructor invocation for use when the message is on an\n  // arena. The code that this method generates will be executed inside a\n  // shared-for-the-whole-message-class method registered with OwnDestructor().\n  // The method should return |true| if it generated any code that requires a\n  // call; this allows the message generator to eliminate the OwnDestructor()\n  // registration if no fields require it.\n  virtual bool GenerateArenaDestructorCode(io::Printer* printer) const {\n    return false;\n  }\n\n  // Generate code that allocates the fields's default instance.\n  virtual void GenerateDefaultInstanceAllocator(io::Printer* /*printer*/)\n      const {}\n\n  // Generate code that should be run when ShutdownProtobufLibrary() is called,\n  // to delete all dynamically-allocated objects.\n  virtual void GenerateShutdownCode(io::Printer* /*printer*/) const {}\n\n  // Generate lines to decode this field, which will be placed inside the\n  // message's MergeFromCodedStream() method.\n  virtual void GenerateMergeFromCodedStream(io::Printer* printer) const = 0;\n\n  // Generate lines to decode this field from a packed value, which will be\n  // placed inside the message's MergeFromCodedStream() method.\n  virtual void GenerateMergeFromCodedStreamWithPacking(io::Printer* printer)\n      const;\n\n  // Generate lines to serialize this field, which are placed within the\n  // message's SerializeWithCachedSizes() method.\n  virtual void GenerateSerializeWithCachedSizes(io::Printer* printer) const = 0;\n\n  // Generate lines to serialize this field directly to the array \"target\",\n  // which are placed within the message's SerializeWithCachedSizesToArray()\n  // method. This must also advance \"target\" past the written bytes.\n  virtual void GenerateSerializeWithCachedSizesToArray(\n      io::Printer* printer) const = 0;\n\n  // Generate lines to compute the serialized size of this field, which\n  // are placed in the message's ByteSize() method.\n  virtual void GenerateByteSize(io::Printer* printer) const = 0;\n\n protected:\n  const Options& options_;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGenerator);\n};\n\n// Convenience class which constructs FieldGenerators for a Descriptor.\nclass FieldGeneratorMap {\n public:\n  FieldGeneratorMap(const Descriptor* descriptor, const Options& options);\n  ~FieldGeneratorMap();\n\n  const FieldGenerator& get(const FieldDescriptor* field) const;\n\n private:\n  const Descriptor* descriptor_;\n  const Options& options_;\n  google::protobuf::scoped_array<google::protobuf::scoped_ptr<FieldGenerator> > field_generators_;\n\n  static FieldGenerator* MakeGenerator(const FieldDescriptor* field,\n                                       const Options& options);\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap);\n};\n\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_CPP_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_file.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/cpp/cpp_file.h>\n#include <map>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <set>\n\n#include <google/protobuf/compiler/cpp/cpp_enum.h>\n#include <google/protobuf/compiler/cpp/cpp_service.h>\n#include <google/protobuf/compiler/cpp/cpp_extension.h>\n#include <google/protobuf/compiler/cpp/cpp_helpers.h>\n#include <google/protobuf/compiler/cpp/cpp_message.h>\n#include <google/protobuf/compiler/cpp/cpp_field.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\n// ===================================================================\n\nFileGenerator::FileGenerator(const FileDescriptor* file, const Options& options)\n    : file_(file),\n      options_(options),\n      message_generators_(\n          new google::protobuf::scoped_ptr<MessageGenerator>[file->message_type_count()]),\n      enum_generators_(\n          new google::protobuf::scoped_ptr<EnumGenerator>[file->enum_type_count()]),\n      service_generators_(\n          new google::protobuf::scoped_ptr<ServiceGenerator>[file->service_count()]),\n      extension_generators_(\n          new google::protobuf::scoped_ptr<ExtensionGenerator>[file->extension_count()]) {\n\n  for (int i = 0; i < file->message_type_count(); i++) {\n    message_generators_[i].reset(\n      new MessageGenerator(file->message_type(i), options));\n  }\n\n  for (int i = 0; i < file->enum_type_count(); i++) {\n    enum_generators_[i].reset(\n      new EnumGenerator(file->enum_type(i), options));\n  }\n\n  for (int i = 0; i < file->service_count(); i++) {\n    service_generators_[i].reset(\n      new ServiceGenerator(file->service(i), options));\n  }\n\n  for (int i = 0; i < file->extension_count(); i++) {\n    extension_generators_[i].reset(\n      new ExtensionGenerator(file->extension(i), options));\n  }\n\n  SplitStringUsing(file_->package(), \".\", &package_parts_);\n}\n\nFileGenerator::~FileGenerator() {}\n\nvoid FileGenerator::GenerateProtoHeader(io::Printer* printer,\n                                        const string& info_path) {\n  if (!options_.proto_h) {\n    return;\n  }\n\n  string filename_identifier = FilenameIdentifier(file_->name());\n  GenerateTopHeaderGuard(printer, filename_identifier);\n\n\n  GenerateLibraryIncludes(printer);\n\n  for (int i = 0; i < file_->public_dependency_count(); i++) {\n    const FileDescriptor* dep = file_->public_dependency(i);\n    const char* extension = \".proto.h\";\n    string dependency = StripProto(dep->name()) + extension;\n    printer->Print(\n      \"#include \\\"$dependency$\\\"  // IWYU pragma: export\\n\",\n      \"dependency\", dependency);\n  }\n\n  GenerateMetadataPragma(printer, info_path);\n\n  printer->Print(\n    \"// @@protoc_insertion_point(includes)\\n\");\n\n\n  GenerateForwardDeclarations(printer);\n\n  // Open namespace.\n  GenerateNamespaceOpeners(printer);\n\n  GenerateGlobalStateFunctionDeclarations(printer);\n\n  printer->Print(\"\\n\");\n\n  GenerateEnumDefinitions(printer);\n\n  printer->Print(kThickSeparator);\n  printer->Print(\"\\n\");\n\n  GenerateMessageDefinitions(printer);\n\n  printer->Print(\"\\n\");\n  printer->Print(kThickSeparator);\n  printer->Print(\"\\n\");\n\n  GenerateServiceDefinitions(printer);\n\n  GenerateExtensionIdentifiers(printer);\n\n  printer->Print(\"\\n\");\n  printer->Print(kThickSeparator);\n  printer->Print(\"\\n\");\n\n  GenerateInlineFunctionDefinitions(printer);\n\n  printer->Print(\n    \"\\n\"\n    \"// @@protoc_insertion_point(namespace_scope)\\n\"\n    \"\\n\");\n\n  // Close up namespace.\n  GenerateNamespaceClosers(printer);\n\n  // We need to specialize some templates in the ::google::protobuf namespace:\n  GenerateProto2NamespaceEnumSpecializations(printer);\n\n  printer->Print(\n    \"\\n\"\n    \"// @@protoc_insertion_point(global_scope)\\n\"\n    \"\\n\");\n\n  GenerateBottomHeaderGuard(printer, filename_identifier);\n}\n\nvoid FileGenerator::GeneratePBHeader(io::Printer* printer,\n                                     const string& info_path) {\n  string filename_identifier =\n      FilenameIdentifier(file_->name() + (options_.proto_h ? \".pb.h\" : \"\"));\n  GenerateTopHeaderGuard(printer, filename_identifier);\n\n  if (options_.proto_h) {\n    printer->Print(\"#include \\\"$basename$.proto.h\\\"  // IWYU pragma: export\\n\",\n                   \"basename\", StripProto(file_->name()));\n  } else {\n    GenerateLibraryIncludes(printer);\n  }\n  GenerateDependencyIncludes(printer);\n  GenerateMetadataPragma(printer, info_path);\n\n  printer->Print(\n    \"// @@protoc_insertion_point(includes)\\n\");\n\n\n\n  // Open namespace.\n  GenerateNamespaceOpeners(printer);\n\n  if (!options_.proto_h) {\n    GenerateGlobalStateFunctionDeclarations(printer);\n    GenerateMessageForwardDeclarations(printer);\n\n    printer->Print(\"\\n\");\n\n    GenerateEnumDefinitions(printer);\n\n    printer->Print(kThickSeparator);\n    printer->Print(\"\\n\");\n\n    GenerateMessageDefinitions(printer);\n\n    printer->Print(\"\\n\");\n    printer->Print(kThickSeparator);\n    printer->Print(\"\\n\");\n\n    GenerateServiceDefinitions(printer);\n\n    GenerateExtensionIdentifiers(printer);\n\n    printer->Print(\"\\n\");\n    printer->Print(kThickSeparator);\n    printer->Print(\"\\n\");\n\n    GenerateInlineFunctionDefinitions(printer);\n  }\n\n  printer->Print(\n    \"\\n\"\n    \"// @@protoc_insertion_point(namespace_scope)\\n\");\n\n  // Close up namespace.\n  GenerateNamespaceClosers(printer);\n\n  if (!options_.proto_h) {\n    // We need to specialize some templates in the ::google::protobuf namespace:\n    GenerateProto2NamespaceEnumSpecializations(printer);\n  }\n\n  printer->Print(\n    \"\\n\"\n    \"// @@protoc_insertion_point(global_scope)\\n\"\n    \"\\n\");\n\n  GenerateBottomHeaderGuard(printer, filename_identifier);\n}\n\nvoid FileGenerator::GenerateSource(io::Printer* printer) {\n  const bool use_system_include = IsWellKnownMessage(file_);\n  string header =\n      StripProto(file_->name()) + (options_.proto_h ? \".proto.h\" : \".pb.h\");\n  printer->Print(\n    \"// Generated by the protocol buffer compiler.  DO NOT EDIT!\\n\"\n    \"// source: $filename$\\n\"\n    \"\\n\"\n    // The generated code calls accessors that might be deprecated. We don't\n    // want the compiler to warn in generated code.\n    \"#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION\\n\"\n    \"#include $left$$header$$right$\\n\"\n    \"\\n\"\n    \"#include <algorithm>\\n\"    // for swap()\n    \"\\n\"\n    \"#include <google/protobuf/stubs/common.h>\\n\"\n    \"#include <google/protobuf/stubs/port.h>\\n\"\n    \"#include <google/protobuf/stubs/once.h>\\n\"\n    \"#include <google/protobuf/io/coded_stream.h>\\n\"\n    \"#include <google/protobuf/wire_format_lite_inl.h>\\n\",\n    \"filename\", file_->name(),\n    \"header\", header,\n    \"left\", use_system_include ? \"<\" : \"\\\"\",\n    \"right\", use_system_include ? \">\" : \"\\\"\");\n\n  // Unknown fields implementation in lite mode uses StringOutputStream\n  if (!UseUnknownFieldSet(file_, options_) && file_->message_type_count() > 0) {\n    printer->Print(\n      \"#include <google/protobuf/io/zero_copy_stream_impl_lite.h>\\n\");\n  }\n\n  if (HasDescriptorMethods(file_, options_)) {\n    printer->Print(\n      \"#include <google/protobuf/descriptor.h>\\n\"\n      \"#include <google/protobuf/generated_message_reflection.h>\\n\"\n      \"#include <google/protobuf/reflection_ops.h>\\n\"\n      \"#include <google/protobuf/wire_format.h>\\n\");\n  }\n\n  if (options_.proto_h) {\n    // Use the smaller .proto.h files.\n    for (int i = 0; i < file_->dependency_count(); i++) {\n      const FileDescriptor* dep = file_->dependency(i);\n      const char* extension = \".proto.h\";\n      string dependency = StripProto(dep->name()) + extension;\n      printer->Print(\n          \"#include \\\"$dependency$\\\"\\n\",\n          \"dependency\", dependency);\n    }\n  }\n\n  printer->Print(\n    \"// @@protoc_insertion_point(includes)\\n\");\n\n  GenerateNamespaceOpeners(printer);\n\n  if (HasDescriptorMethods(file_, options_)) {\n    printer->Print(\n      \"\\n\"\n      \"namespace {\\n\"\n      \"\\n\");\n    for (int i = 0; i < file_->message_type_count(); i++) {\n      message_generators_[i]->GenerateDescriptorDeclarations(printer);\n    }\n    for (int i = 0; i < file_->enum_type_count(); i++) {\n      printer->Print(\n        \"const ::google::protobuf::EnumDescriptor* $name$_descriptor_ = NULL;\\n\",\n        \"name\", ClassName(file_->enum_type(i), false));\n    }\n\n    if (HasGenericServices(file_, options_)) {\n      for (int i = 0; i < file_->service_count(); i++) {\n        printer->Print(\n          \"const ::google::protobuf::ServiceDescriptor* $name$_descriptor_ = NULL;\\n\",\n          \"name\", file_->service(i)->name());\n      }\n    }\n\n    printer->Print(\n      \"\\n\"\n      \"}  // namespace\\n\"\n      \"\\n\");\n  }\n\n  // Define our externally-visible BuildDescriptors() function.  (For the lite\n  // library, all this does is initialize default instances.)\n  GenerateBuildDescriptors(printer);\n\n  // Generate enums.\n  for (int i = 0; i < file_->enum_type_count(); i++) {\n    enum_generators_[i]->GenerateMethods(printer);\n  }\n\n  // Generate classes.\n  for (int i = 0; i < file_->message_type_count(); i++) {\n    printer->Print(\"\\n\");\n    printer->Print(kThickSeparator);\n    printer->Print(\"\\n\");\n    message_generators_[i]->GenerateClassMethods(printer);\n\n    printer->Print(\"#if PROTOBUF_INLINE_NOT_IN_HEADERS\\n\");\n    // Generate class inline methods.\n    message_generators_[i]->GenerateInlineMethods(printer,\n                                                  /* is_inline = */ false);\n    printer->Print(\"#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\\n\");\n  }\n\n  if (HasGenericServices(file_, options_)) {\n    // Generate services.\n    for (int i = 0; i < file_->service_count(); i++) {\n      if (i == 0) printer->Print(\"\\n\");\n      printer->Print(kThickSeparator);\n      printer->Print(\"\\n\");\n      service_generators_[i]->GenerateImplementation(printer);\n    }\n  }\n\n  // Define extensions.\n  for (int i = 0; i < file_->extension_count(); i++) {\n    extension_generators_[i]->GenerateDefinition(printer);\n  }\n\n  printer->Print(\n    \"\\n\"\n    \"// @@protoc_insertion_point(namespace_scope)\\n\");\n\n  GenerateNamespaceClosers(printer);\n\n  printer->Print(\n    \"\\n\"\n    \"// @@protoc_insertion_point(global_scope)\\n\");\n}\n\nclass FileGenerator::ForwardDeclarations {\n public:\n  ~ForwardDeclarations() {\n    for (map<string, ForwardDeclarations *>::iterator it = namespaces_.begin(),\n                                                      end = namespaces_.end();\n         it != end; ++it) {\n      delete it->second;\n    }\n    namespaces_.clear();\n  }\n\n  ForwardDeclarations* AddOrGetNamespace(const string& ns_name) {\n    ForwardDeclarations*& ns = namespaces_[ns_name];\n    if (ns == NULL) {\n      ns = new ForwardDeclarations;\n    }\n    return ns;\n  }\n\n  map<string, const Descriptor*>& classes() { return classes_; }\n  map<string, const EnumDescriptor*>& enums() { return enums_; }\n\n  void Print(io::Printer* printer) const {\n    for (map<string, const EnumDescriptor *>::const_iterator\n             it = enums_.begin(),\n             end = enums_.end();\n         it != end; ++it) {\n      printer->Print(\"enum $enumname$ : int;\\n\", \"enumname\", it->first);\n      printer->Annotate(\"enumname\", it->second);\n      printer->Print(\"bool $enumname$_IsValid(int value);\\n\", \"enumname\",\n                     it->first);\n    }\n    for (map<string, const Descriptor *>::const_iterator it = classes_.begin(),\n                                                         end = classes_.end();\n         it != end; ++it) {\n      printer->Print(\"class $classname$;\\n\", \"classname\", it->first);\n      printer->Annotate(\"classname\", it->second);\n    }\n    for (map<string, ForwardDeclarations *>::const_iterator\n             it = namespaces_.begin(),\n             end = namespaces_.end();\n         it != end; ++it) {\n      printer->Print(\"namespace $nsname$ {\\n\",\n                     \"nsname\", it->first);\n      it->second->Print(printer);\n      printer->Print(\"}  // namespace $nsname$\\n\",\n                     \"nsname\", it->first);\n    }\n  }\n\n\n private:\n  map<string, ForwardDeclarations*> namespaces_;\n  map<string, const Descriptor*> classes_;\n  map<string, const EnumDescriptor*> enums_;\n};\n\nvoid FileGenerator::GenerateBuildDescriptors(io::Printer* printer) {\n  // AddDescriptors() is a file-level procedure which adds the encoded\n  // FileDescriptorProto for this .proto file to the global DescriptorPool for\n  // generated files (DescriptorPool::generated_pool()). It either runs at\n  // static initialization time (by default) or when default_instance() is\n  // called for the first time (in LITE_RUNTIME mode with\n  // GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER flag enabled). This procedure also\n  // constructs default instances and registers extensions.\n  //\n  // Its sibling, AssignDescriptors(), actually pulls the compiled\n  // FileDescriptor from the DescriptorPool and uses it to populate all of\n  // the global variables which store pointers to the descriptor objects.\n  // It also constructs the reflection objects.  It is called the first time\n  // anyone calls descriptor() or GetReflection() on one of the types defined\n  // in the file.\n\n  // In optimize_for = LITE_RUNTIME mode, we don't generate AssignDescriptors()\n  // and we only use AddDescriptors() to allocate default instances.\n  if (HasDescriptorMethods(file_, options_)) {\n    printer->Print(\n        \"\\n\"\n        \"void $assigndescriptorsname$() GOOGLE_ATTRIBUTE_COLD;\\n\"\n        \"void $assigndescriptorsname$() {\\n\",\n        \"assigndescriptorsname\", GlobalAssignDescriptorsName(file_->name()));\n    printer->Indent();\n\n    // Make sure the file has found its way into the pool.  If a descriptor\n    // is requested *during* static init then AddDescriptors() may not have\n    // been called yet, so we call it manually.  Note that it's fine if\n    // AddDescriptors() is called multiple times.\n    printer->Print(\n      \"$adddescriptorsname$();\\n\",\n      \"adddescriptorsname\", GlobalAddDescriptorsName(file_->name()));\n\n    // Get the file's descriptor from the pool.\n    printer->Print(\n      \"const ::google::protobuf::FileDescriptor* file =\\n\"\n      \"  ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(\\n\"\n      \"    \\\"$filename$\\\");\\n\"\n      // Note that this GOOGLE_CHECK is necessary to prevent a warning about \"file\"\n      // being unused when compiling an empty .proto file.\n      \"GOOGLE_CHECK(file != NULL);\\n\",\n      \"filename\", file_->name());\n\n    // Go through all the stuff defined in this file and generated code to\n    // assign the global descriptor pointers based on the file descriptor.\n    for (int i = 0; i < file_->message_type_count(); i++) {\n      message_generators_[i]->GenerateDescriptorInitializer(printer, i);\n    }\n    for (int i = 0; i < file_->enum_type_count(); i++) {\n      enum_generators_[i]->GenerateDescriptorInitializer(printer, i);\n    }\n    if (HasGenericServices(file_, options_)) {\n      for (int i = 0; i < file_->service_count(); i++) {\n        service_generators_[i]->GenerateDescriptorInitializer(printer, i);\n      }\n    }\n\n    printer->Outdent();\n    printer->Print(\n      \"}\\n\"\n      \"\\n\");\n\n    // ---------------------------------------------------------------\n\n    // protobuf_AssignDescriptorsOnce():  The first time it is called, calls\n    // AssignDescriptors().  All later times, waits for the first call to\n    // complete and then returns.\n    printer->Print(\n      \"namespace {\\n\"\n      \"\\n\"\n      \"GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);\\n\"\n      \"inline void protobuf_AssignDescriptorsOnce() {\\n\"\n      \"  ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,\\n\"\n      \"                 &$assigndescriptorsname$);\\n\"\n      \"}\\n\"\n      \"\\n\",\n      \"assigndescriptorsname\", GlobalAssignDescriptorsName(file_->name()));\n\n    // protobuf_RegisterTypes():  Calls\n    // MessageFactory::InternalRegisterGeneratedType() for each message type.\n    printer->Print(\n        \"void protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;\\n\"\n        \"void protobuf_RegisterTypes(const ::std::string&) {\\n\"\n        \"  protobuf_AssignDescriptorsOnce();\\n\");\n    printer->Indent();\n\n    for (int i = 0; i < file_->message_type_count(); i++) {\n      message_generators_[i]->GenerateTypeRegistrations(printer);\n    }\n\n    printer->Outdent();\n    printer->Print(\n      \"}\\n\"\n      \"\\n\"\n      \"}  // namespace\\n\");\n  }\n\n  // -----------------------------------------------------------------\n\n  // ShutdownFile():  Deletes descriptors, default instances, etc. on shutdown.\n  printer->Print(\n    \"\\n\"\n    \"void $shutdownfilename$() {\\n\",\n    \"shutdownfilename\", GlobalShutdownFileName(file_->name()));\n  printer->Indent();\n\n  for (int i = 0; i < file_->message_type_count(); i++) {\n    message_generators_[i]->GenerateShutdownCode(printer);\n  }\n\n  printer->Outdent();\n  printer->Print(\n    \"}\\n\\n\");\n\n  // -----------------------------------------------------------------\n\n  // Now generate the AddDescriptors() function.\n  PrintHandlingOptionalStaticInitializers(\n      file_, options_, printer,\n      // With static initializers.\n      // Note that we don't need any special synchronization in the following\n      // code\n      // because it is called at static init time before any threads exist.\n      \"void $adddescriptorsname$() GOOGLE_ATTRIBUTE_COLD;\\n\"\n      \"void $adddescriptorsname$() {\\n\"\n      \"  static bool already_here = false;\\n\"\n      \"  if (already_here) return;\\n\"\n      \"  already_here = true;\\n\"\n      \"  GOOGLE_PROTOBUF_VERIFY_VERSION;\\n\"\n      \"\\n\",\n      // Without.\n      \"void $adddescriptorsname$_impl() {\\n\"\n      \"  GOOGLE_PROTOBUF_VERIFY_VERSION;\\n\"\n      \"\\n\",\n      // Vars.\n      \"adddescriptorsname\", GlobalAddDescriptorsName(file_->name()));\n\n  printer->Indent();\n\n  // Call the AddDescriptors() methods for all of our dependencies, to make\n  // sure they get added first.\n  for (int i = 0; i < file_->dependency_count(); i++) {\n    const FileDescriptor* dependency = file_->dependency(i);\n    // Print the namespace prefix for the dependency.\n    string add_desc_name = QualifiedFileLevelSymbol(\n        dependency->package(), GlobalAddDescriptorsName(dependency->name()));\n    // Call its AddDescriptors function.\n    printer->Print(\n      \"$name$();\\n\",\n      \"name\", add_desc_name);\n  }\n\n  if (HasDescriptorMethods(file_, options_)) {\n    // Embed the descriptor.  We simply serialize the entire FileDescriptorProto\n    // and embed it as a string literal, which is parsed and built into real\n    // descriptors at initialization time.\n    FileDescriptorProto file_proto;\n    file_->CopyTo(&file_proto);\n    string file_data;\n    file_proto.SerializeToString(&file_data);\n\n#ifdef _MSC_VER\n    bool breakdown_large_file = true;\n#else\n    bool breakdown_large_file = false;\n#endif\n    // Workaround for MSVC: \"Error C1091: compiler limit: string exceeds 65535\n    // bytes in length\". Declare a static array of characters rather than use a\n    // string literal.\n    if (breakdown_large_file && file_data.size() > 65535) {\n      // This has to be explicitly marked as a signed char because the generated\n      // code puts negative values in the array, and sometimes plain char is\n      // unsigned. That implicit narrowing conversion is not allowed in C++11.\n      // <http://stackoverflow.com/questions/4434140/narrowing-conversions-in-c0x-is-it-just-me-or-does-this-sound-like-a-breakin>\n      // has details on why.\n      printer->Print(\n          \"static const signed char descriptor[] = {\\n\");\n      printer->Indent();\n\n      // Only write 25 bytes per line.\n      static const int kBytesPerLine = 25;\n      for (int i = 0; i < file_data.size();) {\n          for (int j = 0; j < kBytesPerLine && i < file_data.size(); ++i, ++j) {\n            printer->Print(\n                \"$char$, \",\n                \"char\", SimpleItoa(file_data[i]));\n          }\n          printer->Print(\n              \"\\n\");\n      }\n\n      printer->Outdent();\n      printer->Print(\n          \"};\\n\");\n\n      printer->Print(\n          \"::google::protobuf::DescriptorPool::InternalAddGeneratedFile(descriptor, $size$);\\n\",\n          \"size\", SimpleItoa(file_data.size()));\n\n    } else {\n      printer->Print(\n        \"::google::protobuf::DescriptorPool::InternalAddGeneratedFile(\");\n\n      // Only write 40 bytes per line.\n      static const int kBytesPerLine = 40;\n      for (int i = 0; i < file_data.size(); i += kBytesPerLine) {\n        printer->Print(\"\\n  \\\"$data$\\\"\",\n                       \"data\",\n                       EscapeTrigraphs(\n                           CEscape(file_data.substr(i, kBytesPerLine))));\n    }\n    printer->Print(\n        \", $size$);\\n\",\n        \"size\", SimpleItoa(file_data.size()));\n    }\n\n    // Call MessageFactory::InternalRegisterGeneratedFile().\n    printer->Print(\n      \"::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(\\n\"\n      \"  \\\"$filename$\\\", &protobuf_RegisterTypes);\\n\",\n      \"filename\", file_->name());\n  }\n\n  // Allocate and initialize default instances.  This can't be done lazily\n  // since default instances are returned by simple accessors and are used with\n  // extensions.  Speaking of which, we also register extensions at this time.\n  for (int i = 0; i < file_->message_type_count(); i++) {\n    message_generators_[i]->GenerateDefaultInstanceAllocator(printer);\n  }\n  for (int i = 0; i < file_->extension_count(); i++) {\n    extension_generators_[i]->GenerateRegistration(printer);\n  }\n  for (int i = 0; i < file_->message_type_count(); i++) {\n    message_generators_[i]->GenerateDefaultInstanceInitializer(printer);\n  }\n\n  printer->Print(\n    \"::google::protobuf::internal::OnShutdown(&$shutdownfilename$);\\n\",\n    \"shutdownfilename\", GlobalShutdownFileName(file_->name()));\n\n  printer->Outdent();\n  printer->Print(\n    \"}\\n\"\n    \"\\n\");\n\n  PrintHandlingOptionalStaticInitializers(\n      file_, options_, printer,\n      // With static initializers.\n      \"// Force AddDescriptors() to be called at static initialization time.\\n\"\n      \"struct StaticDescriptorInitializer_$filename$ {\\n\"\n      \"  StaticDescriptorInitializer_$filename$() {\\n\"\n      \"    $adddescriptorsname$();\\n\"\n      \"  }\\n\"\n      \"} static_descriptor_initializer_$filename$_;\\n\",\n      // Without.\n      \"GOOGLE_PROTOBUF_DECLARE_ONCE($adddescriptorsname$_once_);\\n\"\n      \"void $adddescriptorsname$() {\\n\"\n      \"  ::google::protobuf::GoogleOnceInit(&$adddescriptorsname$_once_,\\n\"\n      \"                 &$adddescriptorsname$_impl);\\n\"\n      \"}\\n\",\n      // Vars.\n      \"adddescriptorsname\", GlobalAddDescriptorsName(file_->name()), \"filename\",\n      FilenameIdentifier(file_->name()));\n}\n\nvoid FileGenerator::GenerateNamespaceOpeners(io::Printer* printer) {\n  if (package_parts_.size() > 0) printer->Print(\"\\n\");\n\n  for (int i = 0; i < package_parts_.size(); i++) {\n    printer->Print(\"namespace $part$ {\\n\",\n                   \"part\", package_parts_[i]);\n  }\n}\n\nvoid FileGenerator::GenerateNamespaceClosers(io::Printer* printer) {\n  if (package_parts_.size() > 0) printer->Print(\"\\n\");\n\n  for (int i = package_parts_.size() - 1; i >= 0; i--) {\n    printer->Print(\"}  // namespace $part$\\n\",\n                   \"part\", package_parts_[i]);\n  }\n}\n\nvoid FileGenerator::GenerateForwardDeclarations(io::Printer* printer) {\n  ForwardDeclarations decls;\n  for (int i = 0; i < file_->dependency_count(); i++) {\n    FileGenerator dependency(file_->dependency(i), options_);\n    dependency.FillForwardDeclarations(&decls);\n  }\n  FillForwardDeclarations(&decls);\n  decls.Print(printer);\n}\n\nvoid FileGenerator::FillForwardDeclarations(ForwardDeclarations* decls) {\n  for (int i = 0; i < file_->public_dependency_count(); i++) {\n    FileGenerator dependency(file_->public_dependency(i), options_);\n    dependency.FillForwardDeclarations(decls);\n  }\n  for (int i = 0; i < package_parts_.size(); i++) {\n    decls = decls->AddOrGetNamespace(package_parts_[i]);\n  }\n  // Generate enum definitions.\n  for (int i = 0; i < file_->message_type_count(); i++) {\n    message_generators_[i]->FillEnumForwardDeclarations(&decls->enums());\n  }\n  for (int i = 0; i < file_->enum_type_count(); i++) {\n    enum_generators_[i]->FillForwardDeclaration(&decls->enums());\n  }\n  // Generate forward declarations of classes.\n  for (int i = 0; i < file_->message_type_count(); i++) {\n    message_generators_[i]->FillMessageForwardDeclarations(\n        &decls->classes());\n  }\n}\n\nvoid FileGenerator::GenerateTopHeaderGuard(io::Printer* printer,\n                                           const string& filename_identifier) {\n  // Generate top of header.\n  printer->Print(\n      \"// Generated by the protocol buffer compiler.  DO NOT EDIT!\\n\"\n      \"// source: $filename$\\n\"\n      \"\\n\"\n      \"#ifndef PROTOBUF_$filename_identifier$__INCLUDED\\n\"\n      \"#define PROTOBUF_$filename_identifier$__INCLUDED\\n\"\n      \"\\n\"\n      \"#include <string>\\n\",\n      \"filename\", file_->name(), \"filename_identifier\", filename_identifier);\n  printer->Print(\"\\n\");\n}\n\nvoid FileGenerator::GenerateBottomHeaderGuard(\n    io::Printer* printer, const string& filename_identifier) {\n  printer->Print(\n    \"#endif  // PROTOBUF_$filename_identifier$__INCLUDED\\n\",\n    \"filename_identifier\", filename_identifier);\n}\n\nvoid FileGenerator::GenerateLibraryIncludes(io::Printer* printer) {\n\n  printer->Print(\n    \"#include <google/protobuf/stubs/common.h>\\n\"\n    \"\\n\");\n\n  // Verify the protobuf library header version is compatible with the protoc\n  // version before going any further.\n  printer->Print(\n    \"#if GOOGLE_PROTOBUF_VERSION < $min_header_version$\\n\"\n    \"#error This file was generated by a newer version of protoc which is\\n\"\n    \"#error incompatible with your Protocol Buffer headers.  Please update\\n\"\n    \"#error your headers.\\n\"\n    \"#endif\\n\"\n    \"#if $protoc_version$ < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION\\n\"\n    \"#error This file was generated by an older version of protoc which is\\n\"\n    \"#error incompatible with your Protocol Buffer headers.  Please\\n\"\n    \"#error regenerate this file with a newer version of protoc.\\n\"\n    \"#endif\\n\"\n    \"\\n\",\n    \"min_header_version\",\n      SimpleItoa(protobuf::internal::kMinHeaderVersionForProtoc),\n    \"protoc_version\", SimpleItoa(GOOGLE_PROTOBUF_VERSION));\n\n  // OK, it's now safe to #include other files.\n  printer->Print(\n    \"#include <google/protobuf/arena.h>\\n\"\n    \"#include <google/protobuf/arenastring.h>\\n\"\n    \"#include <google/protobuf/generated_message_util.h>\\n\");\n  if (UseUnknownFieldSet(file_, options_)) {\n    printer->Print(\n      \"#include <google/protobuf/metadata.h>\\n\");\n  }\n  if (file_->message_type_count() > 0) {\n    if (HasDescriptorMethods(file_, options_)) {\n      printer->Print(\n        \"#include <google/protobuf/message.h>\\n\");\n    } else {\n      printer->Print(\n        \"#include <google/protobuf/message_lite.h>\\n\");\n    }\n  }\n  printer->Print(\n    \"#include <google/protobuf/repeated_field.h>\\n\"\n    \"#include <google/protobuf/extension_set.h>\\n\");\n  if (HasMapFields(file_)) {\n    printer->Print(\n        \"#include <google/protobuf/map.h>\\n\");\n    if (HasDescriptorMethods(file_, options_)) {\n      printer->Print(\n          \"#include <google/protobuf/map_field_inl.h>\\n\");\n    } else {\n      printer->Print(\n          \"#include <google/protobuf/map_field_lite.h>\\n\");\n    }\n  }\n\n  if (HasEnumDefinitions(file_)) {\n    if (HasDescriptorMethods(file_, options_)) {\n      printer->Print(\n          \"#include <google/protobuf/generated_enum_reflection.h>\\n\");\n    } else {\n      printer->Print(\n          \"#include <google/protobuf/generated_enum_util.h>\\n\");\n    }\n  }\n\n  if (HasGenericServices(file_, options_)) {\n    printer->Print(\n      \"#include <google/protobuf/service.h>\\n\");\n  }\n\n  if (UseUnknownFieldSet(file_, options_) && file_->message_type_count() > 0) {\n    printer->Print(\n      \"#include <google/protobuf/unknown_field_set.h>\\n\");\n  }\n\n\n  if (IsAnyMessage(file_)) {\n    printer->Print(\n      \"#include <google/protobuf/any.h>\\n\");\n  }\n}\n\nvoid FileGenerator::GenerateMetadataPragma(io::Printer* printer,\n                                           const string& info_path) {\n  if (!info_path.empty() && !options_.annotation_pragma_name.empty() &&\n      !options_.annotation_guard_name.empty()) {\n    printer->Print(\n        \"#ifdef $guard$\\n\"\n        \"#pragma $pragma$ \\\"$info_path$\\\"\\n\"\n        \"#endif  // $guard$\\n\",\n        \"guard\", options_.annotation_guard_name, \"pragma\",\n        options_.annotation_pragma_name, \"info_path\", info_path);\n  }\n}\n\nvoid FileGenerator::GenerateDependencyIncludes(io::Printer* printer) {\n  set<string> public_import_names;\n  for (int i = 0; i < file_->public_dependency_count(); i++) {\n    public_import_names.insert(file_->public_dependency(i)->name());\n  }\n\n  for (int i = 0; i < file_->dependency_count(); i++) {\n    const bool use_system_include = IsWellKnownMessage(file_->dependency(i));\n    const string& name = file_->dependency(i)->name();\n    bool public_import = (public_import_names.count(name) != 0);\n\n\n    printer->Print(\n      \"#include $left$$dependency$.pb.h$right$$iwyu$\\n\",\n      \"dependency\", StripProto(name),\n      \"iwyu\", (public_import) ? \"  // IWYU pragma: export\" : \"\",\n      \"left\", use_system_include ? \"<\" : \"\\\"\",\n      \"right\", use_system_include ? \">\" : \"\\\"\");\n  }\n}\n\nvoid FileGenerator::GenerateGlobalStateFunctionDeclarations(\n    io::Printer* printer) {\n  // Forward-declare the AddDescriptors, AssignDescriptors, and ShutdownFile\n  // functions, so that we can declare them to be friends of each class.\n  printer->Print(\n    \"\\n\"\n    \"// Internal implementation detail -- do not call these.\\n\"\n    \"void $dllexport_decl$$adddescriptorsname$();\\n\",\n    \"adddescriptorsname\", GlobalAddDescriptorsName(file_->name()),\n    \"dllexport_decl\",\n    options_.dllexport_decl.empty() ? \"\" : options_.dllexport_decl + \" \");\n\n  printer->Print(\n    // Note that we don't put dllexport_decl on these because they are only\n    // called by the .pb.cc file in which they are defined.\n    \"void $assigndescriptorsname$();\\n\"\n    \"void $shutdownfilename$();\\n\"\n    \"\\n\",\n    \"assigndescriptorsname\", GlobalAssignDescriptorsName(file_->name()),\n    \"shutdownfilename\", GlobalShutdownFileName(file_->name()));\n}\n\nvoid FileGenerator::GenerateMessageForwardDeclarations(io::Printer* printer) {\n  map<string, const Descriptor*> classes;\n  for (int i = 0; i < file_->message_type_count(); i++) {\n    message_generators_[i]->FillMessageForwardDeclarations(&classes);\n  }\n  for (map<string, const Descriptor *>::const_iterator it = classes.begin(),\n                                                       end = classes.end();\n       it != end; ++it) {\n    printer->Print(\"class $classname$;\\n\", \"classname\", it->first);\n    printer->Annotate(\"classname\", it->second);\n  }\n}\n\nvoid FileGenerator::GenerateMessageDefinitions(io::Printer* printer) {\n  // Generate class definitions.\n  for (int i = 0; i < file_->message_type_count(); i++) {\n    if (i > 0) {\n      printer->Print(\"\\n\");\n      printer->Print(kThinSeparator);\n      printer->Print(\"\\n\");\n    }\n    message_generators_[i]->GenerateClassDefinition(printer);\n  }\n}\n\nvoid FileGenerator::GenerateEnumDefinitions(io::Printer* printer) {\n  // Generate enum definitions.\n  for (int i = 0; i < file_->message_type_count(); i++) {\n    message_generators_[i]->GenerateEnumDefinitions(printer);\n  }\n  for (int i = 0; i < file_->enum_type_count(); i++) {\n    enum_generators_[i]->GenerateDefinition(printer);\n  }\n}\n\nvoid FileGenerator::GenerateServiceDefinitions(io::Printer* printer) {\n  if (HasGenericServices(file_, options_)) {\n    // Generate service definitions.\n    for (int i = 0; i < file_->service_count(); i++) {\n      if (i > 0) {\n        printer->Print(\"\\n\");\n        printer->Print(kThinSeparator);\n        printer->Print(\"\\n\");\n      }\n      service_generators_[i]->GenerateDeclarations(printer);\n    }\n\n    printer->Print(\"\\n\");\n    printer->Print(kThickSeparator);\n    printer->Print(\"\\n\");\n  }\n}\n\nvoid FileGenerator::GenerateExtensionIdentifiers(io::Printer* printer) {\n  // Declare extension identifiers.\n  for (int i = 0; i < file_->extension_count(); i++) {\n    extension_generators_[i]->GenerateDeclaration(printer);\n  }\n}\n\nvoid FileGenerator::GenerateInlineFunctionDefinitions(io::Printer* printer) {\n  // An aside about inline functions in .proto.h mode:\n  //\n  // The PROTOBUF_INLINE_NOT_IN_HEADERS symbol controls conditionally\n  // moving much of the inline functions to the .pb.cc file, which can be a\n  // significant performance benefit for compilation time, at the expense\n  // of non-inline function calls.\n  //\n  // However, in .proto.h mode, the definition of the internal dependent\n  // base class must remain in the header, and can never be out-lined. The\n  // dependent base class also needs access to has-bit manipuation\n  // functions, so the has-bit functions must be unconditionally inlined in\n  // proto_h mode.\n  //\n  // This gives us three flavors of functions:\n  //\n  //  1. Functions on the message not used by the internal dependent base\n  //     class: in .proto.h mode, only some functions are defined on the\n  //     message class; others are defined on the dependent base class.\n  //     These are guarded and can be out-lined. These are generated by\n  //     GenerateInlineMethods, and include has_* bit functions in\n  //     non-proto_h mode.\n  //\n  //  2. Functions on the internal dependent base class: these functions\n  //     are dependent on a template parameter, so they always need to\n  //     remain in the header.\n  //\n  //  3. Functions on the message that are used by the dependent base: the\n  //     dependent base class down casts itself to the message\n  //     implementation class to access these functions (the has_* bit\n  //     manipulation functions). Unlike #1, these functions must\n  //     unconditionally remain in the header. These are emitted by\n  //     GenerateDependentInlineMethods, even though they are not actually\n  //     dependent.\n\n  printer->Print(\"#if !PROTOBUF_INLINE_NOT_IN_HEADERS\\n\");\n  // Generate class inline methods.\n  for (int i = 0; i < file_->message_type_count(); i++) {\n    if (i > 0) {\n      printer->Print(kThinSeparator);\n      printer->Print(\"\\n\");\n    }\n    message_generators_[i]->GenerateInlineMethods(printer,\n                                                  /* is_inline = */ true);\n  }\n  printer->Print(\"#endif  // !PROTOBUF_INLINE_NOT_IN_HEADERS\\n\");\n\n  for (int i = 0; i < file_->message_type_count(); i++) {\n    if (i > 0) {\n      printer->Print(kThinSeparator);\n      printer->Print(\"\\n\");\n    }\n    // Methods of the dependent base class must always be inline in the header.\n    message_generators_[i]->GenerateDependentInlineMethods(printer);\n  }\n}\n\nvoid FileGenerator::GenerateProto2NamespaceEnumSpecializations(\n    io::Printer* printer) {\n  // Emit GetEnumDescriptor specializations into google::protobuf namespace:\n  if (HasEnumDefinitions(file_)) {\n    // The SWIG conditional is to avoid a null-pointer dereference\n    // (bug 1984964) in swig-1.3.21 resulting from the following syntax:\n    //   namespace X { void Y<Z::W>(); }\n    // which appears in GetEnumDescriptor() specializations.\n    printer->Print(\n        \"\\n\"\n        \"#ifndef SWIG\\n\"\n        \"namespace google {\\nnamespace protobuf {\\n\"\n        \"\\n\");\n    for (int i = 0; i < file_->message_type_count(); i++) {\n      message_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer);\n    }\n    for (int i = 0; i < file_->enum_type_count(); i++) {\n      enum_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer);\n    }\n    printer->Print(\n        \"\\n\"\n        \"}  // namespace protobuf\\n}  // namespace google\\n\"\n        \"#endif  // SWIG\\n\");\n  }\n}\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_file.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__\n#define GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <string>\n#include <vector>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/compiler/cpp/cpp_field.h>\n#include <google/protobuf/compiler/cpp/cpp_options.h>\n\nnamespace google {\nnamespace protobuf {\n  class FileDescriptor;        // descriptor.h\n  namespace io {\n    class Printer;             // printer.h\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\nclass EnumGenerator;           // enum.h\nclass MessageGenerator;        // message.h\nclass ServiceGenerator;        // service.h\nclass ExtensionGenerator;      // extension.h\n\nclass FileGenerator {\n public:\n  // See generator.cc for the meaning of dllexport_decl.\n  FileGenerator(const FileDescriptor* file, const Options& options);\n  ~FileGenerator();\n\n  // info_path, if non-empty, should be the path (relative to printer's output)\n  // to the metadata file describing this proto header.\n  void GenerateProtoHeader(io::Printer* printer,\n                           const string& info_path);\n  // info_path, if non-empty, should be the path (relative to printer's output)\n  // to the metadata file describing this PB header.\n  void GeneratePBHeader(io::Printer* printer,\n                        const string& info_path);\n  void GenerateSource(io::Printer* printer);\n\n private:\n  // Internal type used by GenerateForwardDeclarations (defined in file.cc).\n  class ForwardDeclarations;\n\n  // Generate the BuildDescriptors() procedure, which builds all descriptors\n  // for types defined in the file.\n  void GenerateBuildDescriptors(io::Printer* printer);\n\n  void GenerateNamespaceOpeners(io::Printer* printer);\n  void GenerateNamespaceClosers(io::Printer* printer);\n\n  // For other imports, generates their forward-declarations.\n  void GenerateForwardDeclarations(io::Printer* printer);\n\n  // Internal helper used by GenerateForwardDeclarations: fills 'decls'\n  // with all necessary forward-declarations for this file and its\n  // transient depednencies.\n  void FillForwardDeclarations(ForwardDeclarations* decls);\n\n  // Generates top or bottom of a header file.\n  void GenerateTopHeaderGuard(io::Printer* printer,\n                              const string& filename_identifier);\n  void GenerateBottomHeaderGuard(io::Printer* printer,\n                                 const string& filename_identifier);\n\n  // Generates #include directives.\n  void GenerateLibraryIncludes(io::Printer* printer);\n  void GenerateDependencyIncludes(io::Printer* printer);\n\n  // Generate a pragma to pull in metadata using the given info_path (if\n  // non-empty). info_path should be relative to printer's output.\n  void GenerateMetadataPragma(io::Printer* printer, const string& info_path);\n\n  // Generates a couple of different pieces before definitions:\n  void GenerateGlobalStateFunctionDeclarations(io::Printer* printer);\n\n  // Generates types for classes.\n  void GenerateMessageDefinitions(io::Printer* printer);\n\n  // Generates forward-declarations for just this file's classes. This is\n  // used for .pb.h headers, but not in proto_h mode.\n  void GenerateMessageForwardDeclarations(io::Printer* printer);\n\n  // Fills in types for forward declarations. This is used internally, and\n  // also by other FileGenerators to determine imports' declarations.\n  void FillMessageForwardDeclarations(ForwardDeclarations* decls);\n  void FillMessageDefinitions(ForwardDeclarations* decls);\n\n  // Generates enum definitions.\n  void GenerateEnumForwardDeclarations(io::Printer* printer);\n  void FillEnumForwardDeclarations(ForwardDeclarations* decls);\n  void GenerateEnumDefinitions(io::Printer* printer);\n\n  // Generates generic service definitions.\n  void GenerateServiceDefinitions(io::Printer* printer);\n\n  // Generates extension identifiers.\n  void GenerateExtensionIdentifiers(io::Printer* printer);\n\n  // Generates inline function defintions.\n  void GenerateInlineFunctionDefinitions(io::Printer* printer);\n\n  void GenerateProto2NamespaceEnumSpecializations(io::Printer* printer);\n\n  const FileDescriptor* file_;\n  const Options options_;\n\n  google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator> > message_generators_;\n  google::protobuf::scoped_array<google::protobuf::scoped_ptr<EnumGenerator> > enum_generators_;\n  google::protobuf::scoped_array<google::protobuf::scoped_ptr<ServiceGenerator> > service_generators_;\n  google::protobuf::scoped_array<google::protobuf::scoped_ptr<ExtensionGenerator> > extension_generators_;\n\n  // E.g. if the package is foo.bar, package_parts_ is {\"foo\", \"bar\"}.\n  vector<string> package_parts_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator);\n};\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_CPP_FILE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_generator.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/cpp/cpp_generator.h>\n\n#include <vector>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <utility>\n\n#include <google/protobuf/compiler/cpp/cpp_file.h>\n#include <google/protobuf/compiler/cpp/cpp_helpers.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/descriptor.pb.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\nCppGenerator::CppGenerator() {}\nCppGenerator::~CppGenerator() {}\n\nbool CppGenerator::Generate(const FileDescriptor* file,\n                            const string& parameter,\n                            GeneratorContext* generator_context,\n                            string* error) const {\n  vector<pair<string, string> > options;\n  ParseGeneratorParameter(parameter, &options);\n\n  // -----------------------------------------------------------------\n  // parse generator options\n\n  // TODO(kenton):  If we ever have more options, we may want to create a\n  //   class that encapsulates them which we can pass down to all the\n  //   generator classes.  Currently we pass dllexport_decl down to all of\n  //   them via the constructors, but we don't want to have to add another\n  //   constructor parameter for every option.\n\n  // If the dllexport_decl option is passed to the compiler, we need to write\n  // it in front of every symbol that should be exported if this .proto is\n  // compiled into a Windows DLL.  E.g., if the user invokes the protocol\n  // compiler as:\n  //   protoc --cpp_out=dllexport_decl=FOO_EXPORT:outdir foo.proto\n  // then we'll define classes like this:\n  //   class FOO_EXPORT Foo {\n  //     ...\n  //   }\n  // FOO_EXPORT is a macro which should expand to __declspec(dllexport) or\n  // __declspec(dllimport) depending on what is being compiled.\n  //\n  Options file_options;\n\n  for (int i = 0; i < options.size(); i++) {\n    if (options[i].first == \"dllexport_decl\") {\n      file_options.dllexport_decl = options[i].second;\n    } else if (options[i].first == \"safe_boundary_check\") {\n      file_options.safe_boundary_check = true;\n    } else if (options[i].first == \"annotate_headers\") {\n      file_options.annotate_headers = true;\n    } else if (options[i].first == \"annotation_pragma_name\") {\n      file_options.annotation_pragma_name = options[i].second;\n    } else if (options[i].first == \"annotation_guard_name\") {\n      file_options.annotation_guard_name = options[i].second;\n    } else if (options[i].first == \"lite\") {\n      file_options.enforce_lite = true;\n    } else {\n      *error = \"Unknown generator option: \" + options[i].first;\n      return false;\n    }\n  }\n\n  // -----------------------------------------------------------------\n\n\n  string basename = StripProto(file->name());\n\n  FileGenerator file_generator(file, file_options);\n\n  // Generate header(s).\n  if (file_options.proto_h) {\n    google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(\n        generator_context->Open(basename + \".proto.h\"));\n    GeneratedCodeInfo annotations;\n    io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(\n        &annotations);\n    string info_path = basename + \".proto.h.meta\";\n    io::Printer printer(output.get(), '$', file_options.annotate_headers\n                                               ? &annotation_collector\n                                               : NULL);\n    file_generator.GenerateProtoHeader(\n        &printer, file_options.annotate_headers ? info_path : \"\");\n    if (file_options.annotate_headers) {\n      google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> info_output(\n          generator_context->Open(info_path));\n      annotations.SerializeToZeroCopyStream(info_output.get());\n    }\n  }\n\n  basename.append(\".pb\");\n  {\n    google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(\n        generator_context->Open(basename + \".h\"));\n    GeneratedCodeInfo annotations;\n    io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(\n        &annotations);\n    string info_path = basename + \".h.meta\";\n    io::Printer printer(output.get(), '$', file_options.annotate_headers\n                                               ? &annotation_collector\n                                               : NULL);\n    file_generator.GeneratePBHeader(\n        &printer, file_options.annotate_headers ? info_path : \"\");\n    if (file_options.annotate_headers) {\n      google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> info_output(\n          generator_context->Open(info_path));\n      annotations.SerializeToZeroCopyStream(info_output.get());\n    }\n  }\n\n  // Generate cc file.\n  {\n    google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(\n        generator_context->Open(basename + \".cc\"));\n    io::Printer printer(output.get(), '$');\n    file_generator.GenerateSource(&printer);\n  }\n\n  return true;\n}\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_generator.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Generates C++ code for a given .proto file.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__\n#define GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__\n\n#include <string>\n#include <google/protobuf/compiler/code_generator.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\n// CodeGenerator implementation which generates a C++ source file and\n// header.  If you create your own protocol compiler binary and you want\n// it to support C++ output, you can do so by registering an instance of this\n// CodeGenerator with the CommandLineInterface in your main() function.\nclass LIBPROTOC_EXPORT CppGenerator : public CodeGenerator {\n public:\n  CppGenerator();\n  ~CppGenerator();\n\n  // implements CodeGenerator ----------------------------------------\n  bool Generate(const FileDescriptor* file,\n                const string& parameter,\n                GeneratorContext* generator_context,\n                string* error) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CppGenerator);\n};\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_CPP_GENERATOR_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_helpers.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <limits>\n#include <map>\n#include <vector>\n#include <google/protobuf/stubs/hash.h>\n\n#include <google/protobuf/compiler/cpp/cpp_helpers.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\nnamespace {\n\nstatic const char kAnyMessageName[] = \"Any\";\nstatic const char kAnyProtoFile[] = \"google/protobuf/any.proto\";\nstatic const char kGoogleProtobufPrefix[] = \"google/protobuf/\";\n\nstring DotsToUnderscores(const string& name) {\n  return StringReplace(name, \".\", \"_\", true);\n}\n\nstring DotsToColons(const string& name) {\n  return StringReplace(name, \".\", \"::\", true);\n}\n\nconst char* const kKeywordList[] = {\n  \"alignas\", \"alignof\", \"and\", \"and_eq\", \"asm\", \"auto\", \"bitand\", \"bitor\",\n  \"bool\", \"break\", \"case\", \"catch\", \"char\", \"class\", \"compl\", \"const\",\n  \"constexpr\", \"const_cast\", \"continue\", \"decltype\", \"default\", \"delete\", \"do\",\n  \"double\", \"dynamic_cast\", \"else\", \"enum\", \"explicit\", \"export\", \"extern\",\n  \"false\", \"float\", \"for\", \"friend\", \"goto\", \"if\", \"inline\", \"int\", \"long\",\n  \"mutable\", \"namespace\", \"new\", \"noexcept\", \"not\", \"not_eq\", \"NULL\",\n  \"operator\", \"or\", \"or_eq\", \"private\", \"protected\", \"public\", \"register\",\n  \"reinterpret_cast\", \"return\", \"short\", \"signed\", \"sizeof\", \"static\",\n  \"static_assert\", \"static_cast\", \"struct\", \"switch\", \"template\", \"this\",\n  \"thread_local\", \"throw\", \"true\", \"try\", \"typedef\", \"typeid\", \"typename\",\n  \"union\", \"unsigned\", \"using\", \"virtual\", \"void\", \"volatile\", \"wchar_t\",\n  \"while\", \"xor\", \"xor_eq\"\n};\n\nhash_set<string> MakeKeywordsMap() {\n  hash_set<string> result;\n  for (int i = 0; i < GOOGLE_ARRAYSIZE(kKeywordList); i++) {\n    result.insert(kKeywordList[i]);\n  }\n  return result;\n}\n\nhash_set<string> kKeywords = MakeKeywordsMap();\n\n// Returns whether the provided descriptor has an extension. This includes its\n// nested types.\nbool HasExtension(const Descriptor* descriptor) {\n  if (descriptor->extension_count() > 0) {\n    return true;\n  }\n  for (int i = 0; i < descriptor->nested_type_count(); ++i) {\n    if (HasExtension(descriptor->nested_type(i))) {\n      return true;\n    }\n  }\n  return false;\n}\n\n}  // namespace\n\nstring UnderscoresToCamelCase(const string& input, bool cap_next_letter) {\n  string result;\n  // Note:  I distrust ctype.h due to locales.\n  for (int i = 0; i < input.size(); i++) {\n    if ('a' <= input[i] && input[i] <= 'z') {\n      if (cap_next_letter) {\n        result += input[i] + ('A' - 'a');\n      } else {\n        result += input[i];\n      }\n      cap_next_letter = false;\n    } else if ('A' <= input[i] && input[i] <= 'Z') {\n      // Capital letters are left as-is.\n      result += input[i];\n      cap_next_letter = false;\n    } else if ('0' <= input[i] && input[i] <= '9') {\n      result += input[i];\n      cap_next_letter = true;\n    } else {\n      cap_next_letter = true;\n    }\n  }\n  return result;\n}\n\nconst char kThickSeparator[] =\n  \"// ===================================================================\\n\";\nconst char kThinSeparator[] =\n  \"// -------------------------------------------------------------------\\n\";\n\nstring ClassName(const Descriptor* descriptor, bool qualified) {\n\n  // Find \"outer\", the descriptor of the top-level message in which\n  // \"descriptor\" is embedded.\n  const Descriptor* outer = descriptor;\n  while (outer->containing_type() != NULL) outer = outer->containing_type();\n\n  const string& outer_name = outer->full_name();\n  string inner_name = descriptor->full_name().substr(outer_name.size());\n\n  if (qualified) {\n    return \"::\" + DotsToColons(outer_name) + DotsToUnderscores(inner_name);\n  } else {\n    return outer->name() + DotsToUnderscores(inner_name);\n  }\n}\n\nstring ClassName(const EnumDescriptor* enum_descriptor, bool qualified) {\n  if (enum_descriptor->containing_type() == NULL) {\n    if (qualified) {\n      return \"::\" + DotsToColons(enum_descriptor->full_name());\n    } else {\n      return enum_descriptor->name();\n    }\n  } else {\n    string result = ClassName(enum_descriptor->containing_type(), qualified);\n    result += '_';\n    result += enum_descriptor->name();\n    return result;\n  }\n}\n\n\nstring DependentBaseClassTemplateName(const Descriptor* descriptor) {\n  return ClassName(descriptor, false) + \"_InternalBase\";\n}\n\nstring SuperClassName(const Descriptor* descriptor, const Options& options) {\n  return HasDescriptorMethods(descriptor->file(), options)\n             ? \"::google::protobuf::Message\"\n             : \"::google::protobuf::MessageLite\";\n}\n\nstring DependentBaseDownCast() {\n  return \"reinterpret_cast<T*>(this)->\";\n}\n\nstring DependentBaseConstDownCast() {\n  return \"reinterpret_cast<const T*>(this)->\";\n}\n\nstring FieldName(const FieldDescriptor* field) {\n  string result = field->name();\n  LowerString(&result);\n  if (kKeywords.count(result) > 0) {\n    result.append(\"_\");\n  }\n  return result;\n}\n\nstring EnumValueName(const EnumValueDescriptor* enum_value) {\n  string result = enum_value->name();\n  if (kKeywords.count(result) > 0) {\n    result.append(\"_\");\n  }\n  return result;\n}\n\nstring FieldConstantName(const FieldDescriptor *field) {\n  string field_name = UnderscoresToCamelCase(field->name(), true);\n  string result = \"k\" + field_name + \"FieldNumber\";\n\n  if (!field->is_extension() &&\n      field->containing_type()->FindFieldByCamelcaseName(\n        field->camelcase_name()) != field) {\n    // This field's camelcase name is not unique.  As a hack, add the field\n    // number to the constant name.  This makes the constant rather useless,\n    // but what can we do?\n    result += \"_\" + SimpleItoa(field->number());\n  }\n\n  return result;\n}\n\nbool IsFieldDependent(const FieldDescriptor* field) {\n  if (field->containing_oneof() != NULL &&\n      field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {\n    return true;\n  }\n  if (field->is_map()) {\n    const Descriptor* map_descriptor = field->message_type();\n    for (int i = 0; i < map_descriptor->field_count(); i++) {\n      if (IsFieldDependent(map_descriptor->field(i))) {\n        return true;\n      }\n    }\n    return false;\n  }\n  if (field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) {\n    return false;\n  }\n  if (field->containing_oneof() != NULL) {\n    // Oneof fields will always be dependent.\n    //\n    // This is a unique case for field codegen. Field generators are\n    // responsible for generating all the field-specific accessor\n    // functions, except for the clear_*() function; instead, field\n    // generators produce inline clearing code.\n    //\n    // For non-oneof fields, the Message class uses the inline clearing\n    // code to define the field's clear_*() function, as well as in the\n    // destructor. For oneof fields, the Message class generates a much\n    // more complicated clear_*() function, which clears only the oneof\n    // member that is set, in addition to clearing methods for each of the\n    // oneof members individually.\n    //\n    // Since oneofs do not have their own generator class, the Message code\n    // generation logic would be significantly complicated in order to\n    // split dependent and non-dependent manipulation logic based on\n    // whether the oneof truly needs to be dependent; so, for oneof fields,\n    // we just assume it (and its constituents) should be manipulated by a\n    // dependent base class function.\n    //\n    // This is less precise than how dependent message-typed fields are\n    // handled, but the cost is limited to only the generated code for the\n    // oneof field, which seems like an acceptable tradeoff.\n    return true;\n  }\n  if (field->file() == field->message_type()->file()) {\n    return false;\n  }\n  return true;\n}\n\nstring DependentTypeName(const FieldDescriptor* field) {\n  return \"InternalBase_\" + field->name() + \"_T\";\n}\n\nstring FieldMessageTypeName(const FieldDescriptor* field) {\n  // Note:  The Google-internal version of Protocol Buffers uses this function\n  //   as a hook point for hacks to support legacy code.\n  return ClassName(field->message_type(), true);\n}\n\nstring StripProto(const string& filename) {\n  if (HasSuffixString(filename, \".protodevel\")) {\n    return StripSuffixString(filename, \".protodevel\");\n  } else {\n    return StripSuffixString(filename, \".proto\");\n  }\n}\n\nconst char* PrimitiveTypeName(FieldDescriptor::CppType type) {\n  switch (type) {\n    case FieldDescriptor::CPPTYPE_INT32  : return \"::google::protobuf::int32\";\n    case FieldDescriptor::CPPTYPE_INT64  : return \"::google::protobuf::int64\";\n    case FieldDescriptor::CPPTYPE_UINT32 : return \"::google::protobuf::uint32\";\n    case FieldDescriptor::CPPTYPE_UINT64 : return \"::google::protobuf::uint64\";\n    case FieldDescriptor::CPPTYPE_DOUBLE : return \"double\";\n    case FieldDescriptor::CPPTYPE_FLOAT  : return \"float\";\n    case FieldDescriptor::CPPTYPE_BOOL   : return \"bool\";\n    case FieldDescriptor::CPPTYPE_ENUM   : return \"int\";\n    case FieldDescriptor::CPPTYPE_STRING : return \"::std::string\";\n    case FieldDescriptor::CPPTYPE_MESSAGE: return NULL;\n\n    // No default because we want the compiler to complain if any new\n    // CppTypes are added.\n  }\n\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return NULL;\n}\n\nconst char* DeclaredTypeMethodName(FieldDescriptor::Type type) {\n  switch (type) {\n    case FieldDescriptor::TYPE_INT32   : return \"Int32\";\n    case FieldDescriptor::TYPE_INT64   : return \"Int64\";\n    case FieldDescriptor::TYPE_UINT32  : return \"UInt32\";\n    case FieldDescriptor::TYPE_UINT64  : return \"UInt64\";\n    case FieldDescriptor::TYPE_SINT32  : return \"SInt32\";\n    case FieldDescriptor::TYPE_SINT64  : return \"SInt64\";\n    case FieldDescriptor::TYPE_FIXED32 : return \"Fixed32\";\n    case FieldDescriptor::TYPE_FIXED64 : return \"Fixed64\";\n    case FieldDescriptor::TYPE_SFIXED32: return \"SFixed32\";\n    case FieldDescriptor::TYPE_SFIXED64: return \"SFixed64\";\n    case FieldDescriptor::TYPE_FLOAT   : return \"Float\";\n    case FieldDescriptor::TYPE_DOUBLE  : return \"Double\";\n\n    case FieldDescriptor::TYPE_BOOL    : return \"Bool\";\n    case FieldDescriptor::TYPE_ENUM    : return \"Enum\";\n\n    case FieldDescriptor::TYPE_STRING  : return \"String\";\n    case FieldDescriptor::TYPE_BYTES   : return \"Bytes\";\n    case FieldDescriptor::TYPE_GROUP   : return \"Group\";\n    case FieldDescriptor::TYPE_MESSAGE : return \"Message\";\n\n    // No default because we want the compiler to complain if any new\n    // types are added.\n  }\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return \"\";\n}\n\nstring Int32ToString(int number) {\n  // gcc rejects the decimal form of kint32min.\n  if (number == kint32min) {\n    GOOGLE_COMPILE_ASSERT(kint32min == (~0x7fffffff), kint32min_value_error);\n    return \"(~0x7fffffff)\";\n  } else {\n    return SimpleItoa(number);\n  }\n}\n\nstring Int64ToString(int64 number) {\n  // gcc rejects the decimal form of kint64min\n  if (number == kint64min) {\n    // Make sure we are in a 2's complement system.\n    GOOGLE_COMPILE_ASSERT(kint64min == GOOGLE_LONGLONG(~0x7fffffffffffffff),\n                   kint64min_value_error);\n    return \"GOOGLE_LONGLONG(~0x7fffffffffffffff)\";\n  }\n  return \"GOOGLE_LONGLONG(\" + SimpleItoa(number) + \")\";\n}\n\nstring DefaultValue(const FieldDescriptor* field) {\n  switch (field->cpp_type()) {\n    case FieldDescriptor::CPPTYPE_INT32:\n      return Int32ToString(field->default_value_int32());\n    case FieldDescriptor::CPPTYPE_UINT32:\n      return SimpleItoa(field->default_value_uint32()) + \"u\";\n    case FieldDescriptor::CPPTYPE_INT64:\n      return Int64ToString(field->default_value_int64());\n    case FieldDescriptor::CPPTYPE_UINT64:\n      return \"GOOGLE_ULONGLONG(\" + SimpleItoa(field->default_value_uint64())+ \")\";\n    case FieldDescriptor::CPPTYPE_DOUBLE: {\n      double value = field->default_value_double();\n      if (value == numeric_limits<double>::infinity()) {\n        return \"::google::protobuf::internal::Infinity()\";\n      } else if (value == -numeric_limits<double>::infinity()) {\n        return \"-::google::protobuf::internal::Infinity()\";\n      } else if (value != value) {\n        return \"::google::protobuf::internal::NaN()\";\n      } else {\n        return SimpleDtoa(value);\n      }\n    }\n    case FieldDescriptor::CPPTYPE_FLOAT:\n      {\n        float value = field->default_value_float();\n        if (value == numeric_limits<float>::infinity()) {\n          return \"static_cast<float>(::google::protobuf::internal::Infinity())\";\n        } else if (value == -numeric_limits<float>::infinity()) {\n          return \"static_cast<float>(-::google::protobuf::internal::Infinity())\";\n        } else if (value != value) {\n          return \"static_cast<float>(::google::protobuf::internal::NaN())\";\n        } else {\n          string float_value = SimpleFtoa(value);\n          // If floating point value contains a period (.) or an exponent\n          // (either E or e), then append suffix 'f' to make it a float\n          // literal.\n          if (float_value.find_first_of(\".eE\") != string::npos) {\n            float_value.push_back('f');\n          }\n          return float_value;\n        }\n      }\n    case FieldDescriptor::CPPTYPE_BOOL:\n      return field->default_value_bool() ? \"true\" : \"false\";\n    case FieldDescriptor::CPPTYPE_ENUM:\n      // Lazy:  Generate a static_cast because we don't have a helper function\n      //   that constructs the full name of an enum value.\n      return strings::Substitute(\n          \"static_cast< $0 >($1)\",\n          ClassName(field->enum_type(), true),\n          Int32ToString(field->default_value_enum()->number()));\n    case FieldDescriptor::CPPTYPE_STRING:\n      return \"\\\"\" + EscapeTrigraphs(\n        CEscape(field->default_value_string())) +\n        \"\\\"\";\n    case FieldDescriptor::CPPTYPE_MESSAGE:\n      return FieldMessageTypeName(field) + \"::default_instance()\";\n  }\n  // Can't actually get here; make compiler happy.  (We could add a default\n  // case above but then we wouldn't get the nice compiler warning when a\n  // new type is added.)\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return \"\";\n}\n\n// Convert a file name into a valid identifier.\nstring FilenameIdentifier(const string& filename) {\n  string result;\n  for (int i = 0; i < filename.size(); i++) {\n    if (ascii_isalnum(filename[i])) {\n      result.push_back(filename[i]);\n    } else {\n      // Not alphanumeric.  To avoid any possibility of name conflicts we\n      // use the hex code for the character.\n      StrAppend(&result, \"_\", strings::Hex(static_cast<uint8>(filename[i])));\n    }\n  }\n  return result;\n}\n\n// Return the name of the AddDescriptors() function for a given file.\nstring GlobalAddDescriptorsName(const string& filename) {\n  return \"protobuf_AddDesc_\" + FilenameIdentifier(filename);\n}\n\n// Return the name of the AssignDescriptors() function for a given file.\nstring GlobalAssignDescriptorsName(const string& filename) {\n  return \"protobuf_AssignDesc_\" + FilenameIdentifier(filename);\n}\n\n// Return the name of the ShutdownFile() function for a given file.\nstring GlobalShutdownFileName(const string& filename) {\n  return \"protobuf_ShutdownFile_\" + FilenameIdentifier(filename);\n}\n\n// Return the qualified C++ name for a file level symbol.\nstring QualifiedFileLevelSymbol(const string& package, const string& name) {\n  if (package.empty()) {\n    return StrCat(\"::\", name);\n  }\n  return StrCat(\"::\", DotsToColons(package), \"::\", name);\n}\n\n// Escape C++ trigraphs by escaping question marks to \\?\nstring EscapeTrigraphs(const string& to_escape) {\n  return StringReplace(to_escape, \"?\", \"\\\\?\", true);\n}\n\n// Escaped function name to eliminate naming conflict.\nstring SafeFunctionName(const Descriptor* descriptor,\n                        const FieldDescriptor* field,\n                        const string& prefix) {\n  // Do not use FieldName() since it will escape keywords.\n  string name = field->name();\n  LowerString(&name);\n  string function_name = prefix + name;\n  if (descriptor->FindFieldByName(function_name)) {\n    // Single underscore will also make it conflicting with the private data\n    // member. We use double underscore to escape function names.\n    function_name.append(\"__\");\n  } else if (kKeywords.count(name) > 0) {\n    // If the field name is a keyword, we append the underscore back to keep it\n    // consistent with other function names.\n    function_name.append(\"_\");\n  }\n  return function_name;\n}\n\nbool StaticInitializersForced(const FileDescriptor* file,\n                              const Options& options) {\n  if (HasDescriptorMethods(file, options) || file->extension_count() > 0) {\n    return true;\n  }\n  for (int i = 0; i < file->message_type_count(); ++i) {\n    if (HasExtension(file->message_type(i))) {\n      return true;\n    }\n  }\n  return false;\n}\n\nvoid PrintHandlingOptionalStaticInitializers(\n    const FileDescriptor* file, const Options& options, io::Printer* printer,\n    const char* with_static_init, const char* without_static_init,\n    const char* var1, const string& val1, const char* var2,\n    const string& val2) {\n  map<string, string> vars;\n  if (var1) {\n    vars[var1] = val1;\n  }\n  if (var2) {\n    vars[var2] = val2;\n  }\n  PrintHandlingOptionalStaticInitializers(\n      vars, file, options, printer, with_static_init, without_static_init);\n}\n\nvoid PrintHandlingOptionalStaticInitializers(const map<string, string>& vars,\n                                             const FileDescriptor* file,\n                                             const Options& options,\n                                             io::Printer* printer,\n                                             const char* with_static_init,\n                                             const char* without_static_init) {\n  if (StaticInitializersForced(file, options)) {\n    printer->Print(vars, with_static_init);\n  } else {\n    printer->Print(vars, (string(\n      \"#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\\n\") +\n      without_static_init +\n      \"#else\\n\" +\n      with_static_init +\n      \"#endif\\n\").c_str());\n  }\n}\n\n\nstatic bool HasMapFields(const Descriptor* descriptor) {\n  for (int i = 0; i < descriptor->field_count(); ++i) {\n    if (descriptor->field(i)->is_map()) {\n      return true;\n    }\n  }\n  for (int i = 0; i < descriptor->nested_type_count(); ++i) {\n    if (HasMapFields(descriptor->nested_type(i))) return true;\n  }\n  return false;\n}\n\nbool HasMapFields(const FileDescriptor* file) {\n  for (int i = 0; i < file->message_type_count(); ++i) {\n    if (HasMapFields(file->message_type(i))) return true;\n  }\n  return false;\n}\n\nstatic bool HasEnumDefinitions(const Descriptor* message_type) {\n  if (message_type->enum_type_count() > 0) return true;\n  for (int i = 0; i < message_type->nested_type_count(); ++i) {\n    if (HasEnumDefinitions(message_type->nested_type(i))) return true;\n  }\n  return false;\n}\n\nbool HasEnumDefinitions(const FileDescriptor* file) {\n  if (file->enum_type_count() > 0) return true;\n  for (int i = 0; i < file->message_type_count(); ++i) {\n    if (HasEnumDefinitions(file->message_type(i))) return true;\n  }\n  return false;\n}\n\nbool IsStringOrMessage(const FieldDescriptor* field) {\n  switch (field->cpp_type()) {\n    case FieldDescriptor::CPPTYPE_INT32:\n    case FieldDescriptor::CPPTYPE_INT64:\n    case FieldDescriptor::CPPTYPE_UINT32:\n    case FieldDescriptor::CPPTYPE_UINT64:\n    case FieldDescriptor::CPPTYPE_DOUBLE:\n    case FieldDescriptor::CPPTYPE_FLOAT:\n    case FieldDescriptor::CPPTYPE_BOOL:\n    case FieldDescriptor::CPPTYPE_ENUM:\n      return false;\n    case FieldDescriptor::CPPTYPE_STRING:\n    case FieldDescriptor::CPPTYPE_MESSAGE:\n      return true;\n  }\n\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return false;\n}\n\nFieldOptions::CType EffectiveStringCType(const FieldDescriptor* field) {\n  GOOGLE_DCHECK(field->cpp_type() == FieldDescriptor::CPPTYPE_STRING);\n  // Open-source protobuf release only supports STRING ctype.\n  return FieldOptions::STRING;\n\n}\n\nbool IsAnyMessage(const FileDescriptor* descriptor) {\n  return descriptor->name() == kAnyProtoFile;\n}\n\nbool IsAnyMessage(const Descriptor* descriptor) {\n  return descriptor->name() == kAnyMessageName &&\n         descriptor->file()->name() == kAnyProtoFile;\n}\n\nbool IsWellKnownMessage(const FileDescriptor* descriptor) {\n  return !descriptor->name().compare(0, 16, kGoogleProtobufPrefix);\n}\n\nenum Utf8CheckMode {\n  STRICT = 0,  // Parsing will fail if non UTF-8 data is in string fields.\n  VERIFY = 1,  // Only log an error but parsing will succeed.\n  NONE = 2,  // No UTF-8 check.\n};\n\n// Which level of UTF-8 enforcemant is placed on this file.\nstatic Utf8CheckMode GetUtf8CheckMode(const FieldDescriptor* field,\n                                      const Options& options) {\n  if (field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) {\n    return STRICT;\n  } else if (GetOptimizeFor(field->file(), options) !=\n             FileOptions::LITE_RUNTIME) {\n    return VERIFY;\n  } else {\n    return NONE;\n  }\n}\n\nstatic void GenerateUtf8CheckCode(const FieldDescriptor* field,\n                                  const Options& options, bool for_parse,\n                                  const map<string, string>& variables,\n                                  const char* parameters,\n                                  const char* strict_function,\n                                  const char* verify_function,\n                                  io::Printer* printer) {\n  switch (GetUtf8CheckMode(field, options)) {\n    case STRICT: {\n      if (for_parse) {\n        printer->Print(\"DO_(\");\n      }\n      printer->Print(\n          \"::google::protobuf::internal::WireFormatLite::$function$(\\n\",\n          \"function\", strict_function);\n      printer->Indent();\n      printer->Print(variables, parameters);\n      if (for_parse) {\n        printer->Print(\"::google::protobuf::internal::WireFormatLite::PARSE,\\n\");\n      } else {\n        printer->Print(\"::google::protobuf::internal::WireFormatLite::SERIALIZE,\\n\");\n      }\n      printer->Print(\"\\\"$full_name$\\\")\", \"full_name\", field->full_name());\n      if (for_parse) {\n        printer->Print(\")\");\n      }\n      printer->Print(\";\\n\");\n      printer->Outdent();\n      break;\n    }\n    case VERIFY: {\n      printer->Print(\n          \"::google::protobuf::internal::WireFormat::$function$(\\n\",\n          \"function\", verify_function);\n      printer->Indent();\n      printer->Print(variables, parameters);\n      if (for_parse) {\n        printer->Print(\"::google::protobuf::internal::WireFormat::PARSE,\\n\");\n      } else {\n        printer->Print(\"::google::protobuf::internal::WireFormat::SERIALIZE,\\n\");\n      }\n      printer->Print(\"\\\"$full_name$\\\");\\n\", \"full_name\", field->full_name());\n      printer->Outdent();\n      break;\n    }\n    case NONE:\n      break;\n  }\n}\n\nvoid GenerateUtf8CheckCodeForString(const FieldDescriptor* field,\n                                    const Options& options, bool for_parse,\n                                    const map<string, string>& variables,\n                                    const char* parameters,\n                                    io::Printer* printer) {\n  GenerateUtf8CheckCode(field, options, for_parse, variables, parameters,\n                        \"VerifyUtf8String\", \"VerifyUTF8StringNamedField\",\n                        printer);\n}\n\nvoid GenerateUtf8CheckCodeForCord(const FieldDescriptor* field,\n                                  const Options& options, bool for_parse,\n                                  const map<string, string>& variables,\n                                  const char* parameters,\n                                  io::Printer* printer) {\n  GenerateUtf8CheckCode(field, options, for_parse, variables, parameters,\n                        \"VerifyUtf8Cord\", \"VerifyUTF8CordNamedField\", printer);\n}\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_helpers.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__\n#define GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__\n\n#include <map>\n#include <string>\n#include <google/protobuf/compiler/cpp/cpp_options.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/descriptor.h>\n\nnamespace google {\nnamespace protobuf {\n\nnamespace io {\nclass Printer;\n}\n\nnamespace compiler {\nnamespace cpp {\n\n// Commonly-used separator comments.  Thick is a line of '=', thin is a line\n// of '-'.\nextern const char kThickSeparator[];\nextern const char kThinSeparator[];\n\n// Returns the non-nested type name for the given type.  If \"qualified\" is\n// true, prefix the type with the full namespace.  For example, if you had:\n//   package foo.bar;\n//   message Baz { message Qux {} }\n// Then the qualified ClassName for Qux would be:\n//   ::foo::bar::Baz_Qux\n// While the non-qualified version would be:\n//   Baz_Qux\nstring ClassName(const Descriptor* descriptor, bool qualified);\nstring ClassName(const EnumDescriptor* enum_descriptor, bool qualified);\n\n// Name of the CRTP class template (for use with proto_h).\n// This is a class name, like \"ProtoName_InternalBase\".\nstring DependentBaseClassTemplateName(const Descriptor* descriptor);\n\n// Name of the base class: either the dependent base class (for use with\n// proto_h) or google::protobuf::Message.\nstring SuperClassName(const Descriptor* descriptor, const Options& options);\n\n// Returns a string that down-casts from the dependent base class to the\n// derived class.\nstring DependentBaseDownCast();\nstring DependentBaseConstDownCast();\n\n// Get the (unqualified) name that should be used for this field in C++ code.\n// The name is coerced to lower-case to emulate proto1 behavior.  People\n// should be using lowercase-with-underscores style for proto field names\n// anyway, so normally this just returns field->name().\nstring FieldName(const FieldDescriptor* field);\n\n// Get the sanitized name that should be used for the given enum in C++ code.\nstring EnumValueName(const EnumValueDescriptor* enum_value);\n\n// Get the unqualified name that should be used for a field's field\n// number constant.\nstring FieldConstantName(const FieldDescriptor *field);\n\n// Returns the scope where the field was defined (for extensions, this is\n// different from the message type to which the field applies).\ninline const Descriptor* FieldScope(const FieldDescriptor* field) {\n  return field->is_extension() ?\n    field->extension_scope() : field->containing_type();\n}\n\n// Returns true if the given 'field_descriptor' has a message type that is\n// a dependency of the file where the field is defined (i.e., the field\n// type is defined in a different file than the message holding the field).\n//\n// This only applies to Message-typed fields. Enum-typed fields may refer\n// to an enum in a dependency; however, enums are specified and\n// forward-declared with an enum-base, so the definition is not required to\n// manipulate the field value.\nbool IsFieldDependent(const FieldDescriptor* field_descriptor);\n\n// Returns the name that should be used for forcing dependent lookup from a\n// dependent base class.\nstring DependentTypeName(const FieldDescriptor* field);\n\n// Returns the fully-qualified type name field->message_type().  Usually this\n// is just ClassName(field->message_type(), true);\nstring FieldMessageTypeName(const FieldDescriptor* field);\n\n// Strips \".proto\" or \".protodevel\" from the end of a filename.\nLIBPROTOC_EXPORT string StripProto(const string& filename);\n\n// Get the C++ type name for a primitive type (e.g. \"double\", \"::google::protobuf::int32\", etc.).\n// Note:  non-built-in type names will be qualified, meaning they will start\n// with a ::.  If you are using the type as a template parameter, you will\n// need to insure there is a space between the < and the ::, because the\n// ridiculous C++ standard defines \"<:\" to be a synonym for \"[\".\nconst char* PrimitiveTypeName(FieldDescriptor::CppType type);\n\n// Get the declared type name in CamelCase format, as is used e.g. for the\n// methods of WireFormat.  For example, TYPE_INT32 becomes \"Int32\".\nconst char* DeclaredTypeMethodName(FieldDescriptor::Type type);\n\n// Return the code that evaluates to the number when compiled.\nstring Int32ToString(int number);\n\n// Return the code that evaluates to the number when compiled.\nstring Int64ToString(int64 number);\n\n// Get code that evaluates to the field's default value.\nstring DefaultValue(const FieldDescriptor* field);\n\n// Convert a file name into a valid identifier.\nstring FilenameIdentifier(const string& filename);\n\n// Return the name of the AddDescriptors() function for a given file.\nstring GlobalAddDescriptorsName(const string& filename);\n\n// Return the name of the AssignDescriptors() function for a given file.\nstring GlobalAssignDescriptorsName(const string& filename);\n\n// Return the qualified C++ name for a file level symbol.\nstring QualifiedFileLevelSymbol(const string& package, const string& name);\n\n// Return the name of the ShutdownFile() function for a given file.\nstring GlobalShutdownFileName(const string& filename);\n\n// Escape C++ trigraphs by escaping question marks to \\?\nstring EscapeTrigraphs(const string& to_escape);\n\n// Escaped function name to eliminate naming conflict.\nstring SafeFunctionName(const Descriptor* descriptor,\n                        const FieldDescriptor* field,\n                        const string& prefix);\n\n// Returns true if unknown fields are preseved after parsing.\ninline bool PreserveUnknownFields(const Descriptor* message) {\n  return message->file()->syntax() != FileDescriptor::SYNTAX_PROTO3;\n}\n\n// Returns the optimize mode for <file>, respecting <options.enforce_lite>.\n::google::protobuf::FileOptions_OptimizeMode GetOptimizeFor(\n    const FileDescriptor* file, const Options& options);\n\n// If PreserveUnknownFields() is true, determines whether unknown\n// fields will be stored in an UnknownFieldSet or a string.\n// If PreserveUnknownFields() is false, this method will not be\n// used.\ninline bool UseUnknownFieldSet(const FileDescriptor* file,\n                               const Options& options) {\n  return GetOptimizeFor(file, options) != FileOptions::LITE_RUNTIME;\n}\n\n\n// Does the file have any map fields, necessitating the file to include\n// map_field_inl.h and map.h.\nbool HasMapFields(const FileDescriptor* file);\n\n// Does this file have any enum type definitions?\nbool HasEnumDefinitions(const FileDescriptor* file);\n\n// Does this file have generated parsing, serialization, and other\n// standard methods for which reflection-based fallback implementations exist?\ninline bool HasGeneratedMethods(const FileDescriptor* file,\n                                const Options& options) {\n  return GetOptimizeFor(file, options) != FileOptions::CODE_SIZE;\n}\n\n// Do message classes in this file have descriptor and reflection methods?\ninline bool HasDescriptorMethods(const FileDescriptor* file,\n                                 const Options& options) {\n  return GetOptimizeFor(file, options) != FileOptions::LITE_RUNTIME;\n}\n\n// Should we generate generic services for this file?\ninline bool HasGenericServices(const FileDescriptor* file,\n                               const Options& options) {\n  return file->service_count() > 0 &&\n         GetOptimizeFor(file, options) != FileOptions::LITE_RUNTIME &&\n         file->options().cc_generic_services();\n}\n\n// Should we generate a separate, super-optimized code path for serializing to\n// flat arrays?  We don't do this in Lite mode because we'd rather reduce code\n// size.\ninline bool HasFastArraySerialization(const FileDescriptor* file,\n                                      const Options& options) {\n  return GetOptimizeFor(file, options) == FileOptions::SPEED;\n}\n\n// Returns whether we have to generate code with static initializers.\nbool StaticInitializersForced(const FileDescriptor* file,\n                              const Options& options);\n\n// Prints 'with_static_init' if static initializers have to be used for the\n// provided file. Otherwise emits both 'with_static_init' and\n// 'without_static_init' using #ifdef.\nvoid PrintHandlingOptionalStaticInitializers(\n    const FileDescriptor* file, const Options& options, io::Printer* printer,\n    const char* with_static_init, const char* without_static_init,\n    const char* var1 = NULL, const string& val1 = \"\", const char* var2 = NULL,\n    const string& val2 = \"\");\n\nvoid PrintHandlingOptionalStaticInitializers(const map<string, string>& vars,\n                                             const FileDescriptor* file,\n                                             const Options& options,\n                                             io::Printer* printer,\n                                             const char* with_static_init,\n                                             const char* without_static_init);\n\n\ninline bool IsMapEntryMessage(const Descriptor* descriptor) {\n  return descriptor->options().map_entry();\n}\n\n// Returns true if the field's CPPTYPE is string or message.\nbool IsStringOrMessage(const FieldDescriptor* field);\n\n// For a string field, returns the effective ctype.  If the actual ctype is\n// not supported, returns the default of STRING.\nFieldOptions::CType EffectiveStringCType(const FieldDescriptor* field);\n\nstring UnderscoresToCamelCase(const string& input, bool cap_next_letter);\n\ninline bool HasFieldPresence(const FileDescriptor* file) {\n  return file->syntax() != FileDescriptor::SYNTAX_PROTO3;\n}\n\n// Returns true if 'enum' semantics are such that unknown values are preserved\n// in the enum field itself, rather than going to the UnknownFieldSet.\ninline bool HasPreservingUnknownEnumSemantics(const FileDescriptor* file) {\n  return file->syntax() == FileDescriptor::SYNTAX_PROTO3;\n}\n\ninline bool SupportsArenas(const FileDescriptor* file) {\n  return file->options().cc_enable_arenas();\n}\n\ninline bool SupportsArenas(const Descriptor* desc) {\n  return SupportsArenas(desc->file());\n}\n\ninline bool SupportsArenas(const FieldDescriptor* field) {\n  return SupportsArenas(field->file());\n}\n\nbool IsAnyMessage(const FileDescriptor* descriptor);\nbool IsAnyMessage(const Descriptor* descriptor);\n\nbool IsWellKnownMessage(const FileDescriptor* descriptor);\n\nvoid GenerateUtf8CheckCodeForString(const FieldDescriptor* field,\n                                    const Options& options, bool for_parse,\n                                    const map<string, string>& variables,\n                                    const char* parameters,\n                                    io::Printer* printer);\n\nvoid GenerateUtf8CheckCodeForCord(const FieldDescriptor* field,\n                                  const Options& options, bool for_parse,\n                                  const map<string, string>& variables,\n                                  const char* parameters, io::Printer* printer);\n\ninline ::google::protobuf::FileOptions_OptimizeMode GetOptimizeFor(\n    const FileDescriptor* file, const Options& options) {\n  return options.enforce_lite\n      ? FileOptions::LITE_RUNTIME\n      : file->options().optimize_for();\n}\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_CPP_HELPERS_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_map_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/compiler/cpp/cpp_map_field.h>\n#include <google/protobuf/compiler/cpp/cpp_helpers.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\nbool IsProto3Field(const FieldDescriptor* field_descriptor) {\n  const FileDescriptor* file_descriptor = field_descriptor->file();\n  return file_descriptor->syntax() == FileDescriptor::SYNTAX_PROTO3;\n}\n\nvoid SetMessageVariables(const FieldDescriptor* descriptor,\n                         map<string, string>* variables,\n                         const Options& options) {\n  SetCommonFieldVariables(descriptor, variables, options);\n  (*variables)[\"type\"] = FieldMessageTypeName(descriptor);\n  (*variables)[\"stream_writer\"] =\n      (*variables)[\"declared_type\"] +\n      (HasFastArraySerialization(descriptor->message_type()->file(), options)\n           ? \"MaybeToArray\"\n           : \"\");\n  (*variables)[\"full_name\"] = descriptor->full_name();\n\n  const FieldDescriptor* key =\n      descriptor->message_type()->FindFieldByName(\"key\");\n  const FieldDescriptor* val =\n      descriptor->message_type()->FindFieldByName(\"value\");\n  (*variables)[\"key_cpp\"] = PrimitiveTypeName(key->cpp_type());\n  switch (val->cpp_type()) {\n    case FieldDescriptor::CPPTYPE_MESSAGE:\n      (*variables)[\"val_cpp\"] = FieldMessageTypeName(val);\n      (*variables)[\"wrapper\"] = \"EntryWrapper\";\n      break;\n    case FieldDescriptor::CPPTYPE_ENUM:\n      (*variables)[\"val_cpp\"] = ClassName(val->enum_type(), true);\n      (*variables)[\"wrapper\"] = \"EnumEntryWrapper\";\n      break;\n    default:\n      (*variables)[\"val_cpp\"] = PrimitiveTypeName(val->cpp_type());\n      (*variables)[\"wrapper\"] = \"EntryWrapper\";\n  }\n  (*variables)[\"key_wire_type\"] =\n      \"::google::protobuf::internal::WireFormatLite::TYPE_\" +\n      ToUpper(DeclaredTypeMethodName(key->type()));\n  (*variables)[\"val_wire_type\"] =\n      \"::google::protobuf::internal::WireFormatLite::TYPE_\" +\n      ToUpper(DeclaredTypeMethodName(val->type()));\n  (*variables)[\"map_classname\"] = ClassName(descriptor->message_type(), false);\n  (*variables)[\"number\"] = SimpleItoa(descriptor->number());\n  (*variables)[\"tag\"] = SimpleItoa(internal::WireFormat::MakeTag(descriptor));\n\n  if (HasDescriptorMethods(descriptor->file(), options)) {\n    (*variables)[\"lite\"] = \"\";\n  } else {\n    (*variables)[\"lite\"] = \"Lite\";\n  }\n\n  if (!IsProto3Field(descriptor) &&\n      val->type() == FieldDescriptor::TYPE_ENUM) {\n    const EnumValueDescriptor* default_value = val->default_value_enum();\n    (*variables)[\"default_enum_value\"] = Int32ToString(default_value->number());\n  } else {\n    (*variables)[\"default_enum_value\"] = \"0\";\n  }\n}\n\nMapFieldGenerator::MapFieldGenerator(const FieldDescriptor* descriptor,\n                                     const Options& options)\n    : FieldGenerator(options),\n      descriptor_(descriptor),\n      dependent_field_(options.proto_h && IsFieldDependent(descriptor)) {\n  SetMessageVariables(descriptor, &variables_, options);\n}\n\nMapFieldGenerator::~MapFieldGenerator() {}\n\nvoid MapFieldGenerator::\nGeneratePrivateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n      \"typedef ::google::protobuf::internal::MapEntryLite<\\n\"\n      \"    $key_cpp$, $val_cpp$,\\n\"\n      \"    $key_wire_type$,\\n\"\n      \"    $val_wire_type$,\\n\"\n      \"    $default_enum_value$ >\\n\"\n      \"    $map_classname$;\\n\"\n      \"::google::protobuf::internal::MapField$lite$<\\n\"\n      \"    $key_cpp$, $val_cpp$,\\n\"\n      \"    $key_wire_type$,\\n\"\n      \"    $val_wire_type$,\\n\"\n      \"    $default_enum_value$ > $name$_;\\n\");\n}\n\nvoid MapFieldGenerator::\nGenerateAccessorDeclarations(io::Printer* printer) const {\n  printer->Print(variables_,\n      \"$deprecated_attr$const ::google::protobuf::Map< $key_cpp$, $val_cpp$ >&\\n\"\n      \"    $name$() const;\\n\"\n      \"$deprecated_attr$::google::protobuf::Map< $key_cpp$, $val_cpp$ >*\\n\"\n      \"    mutable_$name$();\\n\");\n}\n\nvoid MapFieldGenerator::\nGenerateInlineAccessorDefinitions(io::Printer* printer,\n                                  bool is_inline) const {\n  map<string, string> variables(variables_);\n  variables[\"inline\"] = is_inline ? \"inline\" : \"\";\n  printer->Print(variables,\n      \"$inline$ const ::google::protobuf::Map< $key_cpp$, $val_cpp$ >&\\n\"\n      \"$classname$::$name$() const {\\n\"\n      \"  // @@protoc_insertion_point(field_map:$full_name$)\\n\"\n      \"  return $name$_.GetMap();\\n\"\n      \"}\\n\"\n      \"$inline$ ::google::protobuf::Map< $key_cpp$, $val_cpp$ >*\\n\"\n      \"$classname$::mutable_$name$() {\\n\"\n      \"  // @@protoc_insertion_point(field_mutable_map:$full_name$)\\n\"\n      \"  return $name$_.MutableMap();\\n\"\n      \"}\\n\");\n}\n\nvoid MapFieldGenerator::\nGenerateClearingCode(io::Printer* printer) const {\n  map<string, string> variables(variables_);\n  variables[\"this_message\"] = dependent_field_ ? DependentBaseDownCast() : \"\";\n  printer->Print(variables, \"$this_message$$name$_.Clear();\\n\");\n}\n\nvoid MapFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_.MergeFrom(from.$name$_);\\n\");\n}\n\nvoid MapFieldGenerator::\nGenerateSwappingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_.Swap(&other->$name$_);\\n\");\n}\n\nvoid MapFieldGenerator::\nGenerateConstructorCode(io::Printer* printer) const {\n  if (HasDescriptorMethods(descriptor_->file(), options_)) {\n    printer->Print(variables_,\n        \"$name$_.SetAssignDescriptorCallback(\\n\"\n        \"    protobuf_AssignDescriptorsOnce);\\n\"\n        \"$name$_.SetEntryDescriptor(\\n\"\n        \"    &$type$_descriptor_);\\n\");\n  }\n}\n\nvoid MapFieldGenerator::\nGenerateMergeFromCodedStream(io::Printer* printer) const {\n    const FieldDescriptor* key_field =\n        descriptor_->message_type()->FindFieldByName(\"key\");\n  const FieldDescriptor* value_field =\n      descriptor_->message_type()->FindFieldByName(\"value\");\n  bool using_entry = false;\n  string key;\n  string value;\n  if (IsProto3Field(descriptor_) ||\n      value_field->type() != FieldDescriptor::TYPE_ENUM) {\n    printer->Print(variables_,\n        \"$map_classname$::Parser< ::google::protobuf::internal::MapField$lite$<\\n\"\n                   \"    $key_cpp$, $val_cpp$,\\n\"\n                   \"    $key_wire_type$,\\n\"\n                   \"    $val_wire_type$,\\n\"\n                   \"    $default_enum_value$ >,\\n\"\n                   \"  ::google::protobuf::Map< $key_cpp$, $val_cpp$ > >\"\n        \" parser(&$name$_);\\n\"\n        \"DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\\n\"\n        \"    input, &parser));\\n\");\n    key = \"parser.key()\";\n    value = \"parser.value()\";\n  } else {\n    using_entry = true;\n    key = \"entry->key()\";\n    value = \"entry->value()\";\n    printer->Print(variables_,\n        \"::google::protobuf::scoped_ptr<$map_classname$> entry($name$_.NewEntry());\\n\");\n    printer->Print(variables_,\n        \"{\\n\"\n        \"  ::std::string data;\\n\"\n        \"  DO_(::google::protobuf::internal::WireFormatLite::ReadString(input, &data));\\n\"\n        \"  DO_(entry->ParseFromString(data));\\n\"\n        \"  if ($val_cpp$_IsValid(*entry->mutable_value())) {\\n\"\n        \"    (*mutable_$name$())[entry->key()] =\\n\"\n        \"        static_cast< $val_cpp$ >(*entry->mutable_value());\\n\"\n        \"  } else {\\n\");\n    if (HasDescriptorMethods(descriptor_->file(), options_)) {\n      printer->Print(variables_,\n          \"    mutable_unknown_fields()\"\n          \"->AddLengthDelimited($number$, data);\\n\");\n    } else {\n      printer->Print(variables_,\n          \"    unknown_fields_stream.WriteVarint32($tag$);\\n\"\n          \"    unknown_fields_stream.WriteVarint32(data.size());\\n\"\n          \"    unknown_fields_stream.WriteString(data);\\n\");\n    }\n\n    printer->Print(variables_,\n        \"  }\\n\"\n        \"}\\n\");\n  }\n\n  if (key_field->type() == FieldDescriptor::TYPE_STRING) {\n    GenerateUtf8CheckCodeForString(\n    key_field, options_, true, variables_,\n        StrCat(key, \".data(), \", key, \".length(),\\n\").data(), printer);\n  }\n  if (value_field->type() == FieldDescriptor::TYPE_STRING) {\n    GenerateUtf8CheckCodeForString(value_field, options_, true, variables_,\n        StrCat(value, \".data(), \", value, \".length(),\\n\").data(), printer);\n  }\n\n  // If entry is allocated by arena, its desctructor should be avoided.\n  if (using_entry && SupportsArenas(descriptor_)) {\n    printer->Print(variables_,\n        \"if (entry->GetArena() != NULL) entry.release();\\n\");\n  }\n}\n\nstatic void GenerateSerializationLoop(io::Printer* printer,\n                                      const map<string, string>& variables,\n                                      bool supports_arenas,\n                                      const string& utf8_check,\n                                      const string& loop_header,\n                                      const string& ptr,\n                                      bool loop_via_iterators) {\n  printer->Print(variables,\n      StrCat(\"::google::protobuf::scoped_ptr<$map_classname$> entry;\\n\",\n             loop_header, \" {\\n\").c_str());\n  printer->Indent();\n\n  printer->Print(variables, StrCat(\n      \"entry.reset($name$_.New$wrapper$(\\n\"\n      \"    \", ptr, \"->first, \", ptr, \"->second));\\n\"\n      \"$write_entry$;\\n\").c_str());\n\n  // If entry is allocated by arena, its desctructor should be avoided.\n  if (supports_arenas) {\n    printer->Print(\n        \"if (entry->GetArena() != NULL) {\\n\"\n        \"  entry.release();\\n\"\n        \"}\\n\");\n  }\n\n  if (!utf8_check.empty()) {\n    // If loop_via_iterators is true then ptr is actually an iterator, and we\n    // create a pointer by prefixing it with \"&*\".\n    printer->Print(\n        StrCat(utf8_check, \"(\", (loop_via_iterators ? \"&*\" : \"\"), ptr, \");\\n\")\n            .c_str());\n  }\n\n  printer->Outdent();\n  printer->Print(\n      \"}\\n\");\n}\n\nvoid MapFieldGenerator::\nGenerateSerializeWithCachedSizes(io::Printer* printer) const {\n  map<string, string> variables(variables_);\n  variables[\"write_entry\"] = \"::google::protobuf::internal::WireFormatLite::Write\" +\n                             variables[\"stream_writer\"] + \"(\\n            \" +\n                             variables[\"number\"] + \", *entry, output)\";\n  variables[\"deterministic\"] = \"output->IsSerializationDeterminstic()\";\n  GenerateSerializeWithCachedSizes(printer, variables);\n}\n\nvoid MapFieldGenerator::\nGenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {\n  map<string, string> variables(variables_);\n  variables[\"write_entry\"] =\n      \"target = ::google::protobuf::internal::WireFormatLite::\\n\"\n      \"                   InternalWrite\" + variables[\"declared_type\"] +\n      \"NoVirtualToArray(\\n                       \" + variables[\"number\"] +\n      \", *entry, deterministic, target);\\n\";\n  variables[\"deterministic\"] = \"deterministic\";\n  GenerateSerializeWithCachedSizes(printer, variables);\n}\n\nvoid MapFieldGenerator::GenerateSerializeWithCachedSizes(\n    io::Printer* printer, const map<string, string>& variables) const {\n  printer->Print(variables,\n      \"if (!this->$name$().empty()) {\\n\");\n  printer->Indent();\n  const FieldDescriptor* key_field =\n      descriptor_->message_type()->FindFieldByName(\"key\");\n  const FieldDescriptor* value_field =\n      descriptor_->message_type()->FindFieldByName(\"value\");\n  const bool string_key = key_field->type() == FieldDescriptor::TYPE_STRING;\n  const bool string_value = value_field->type() == FieldDescriptor::TYPE_STRING;\n\n  printer->Print(variables,\n      \"typedef ::google::protobuf::Map< $key_cpp$, $val_cpp$ >::const_pointer\\n\"\n      \"    ConstPtr;\\n\");\n  if (string_key) {\n    printer->Print(variables,\n        \"typedef ConstPtr SortItem;\\n\"\n        \"typedef ::google::protobuf::internal::\"\n        \"CompareByDerefFirst<SortItem> Less;\\n\");\n  } else {\n    printer->Print(variables,\n        \"typedef ::google::protobuf::internal::SortItem< $key_cpp$, ConstPtr > \"\n        \"SortItem;\\n\"\n        \"typedef ::google::protobuf::internal::CompareByFirstField<SortItem> Less;\\n\");\n  }\n  string utf8_check;\n  if (string_key || string_value) {\n    printer->Print(\n        \"struct Utf8Check {\\n\"\n        \"  static void Check(ConstPtr p) {\\n\");\n    printer->Indent();\n    printer->Indent();\n    if (string_key) {\n      GenerateUtf8CheckCodeForString(key_field, options_, false, variables,\n                                     \"p->first.data(), p->first.length(),\\n\",\n                                     printer);\n    }\n    if (string_value) {\n      GenerateUtf8CheckCodeForString(value_field, options_, false, variables,\n                                     \"p->second.data(), p->second.length(),\\n\",\n                                     printer);\n    }\n    printer->Outdent();\n    printer->Outdent();\n    printer->Print(\n        \"  }\\n\"\n        \"};\\n\");\n    utf8_check = \"Utf8Check::Check\";\n  }\n\n  printer->Print(variables,\n      \"\\n\"\n      \"if ($deterministic$ &&\\n\"\n      \"    this->$name$().size() > 1) {\\n\"\n      \"  ::google::protobuf::scoped_array<SortItem> items(\\n\"\n      \"      new SortItem[this->$name$().size()]);\\n\"\n      \"  typedef ::google::protobuf::Map< $key_cpp$, $val_cpp$ >::size_type size_type;\\n\"\n      \"  size_type n = 0;\\n\"\n      \"  for (::google::protobuf::Map< $key_cpp$, $val_cpp$ >::const_iterator\\n\"\n      \"      it = this->$name$().begin();\\n\"\n      \"      it != this->$name$().end(); ++it, ++n) {\\n\"\n      \"    items[n] = SortItem(&*it);\\n\"\n      \"  }\\n\"\n      \"  ::std::sort(&items[0], &items[n], Less());\\n\");\n  printer->Indent();\n  GenerateSerializationLoop(printer, variables, SupportsArenas(descriptor_),\n                            utf8_check, \"for (size_type i = 0; i < n; i++)\",\n                            string_key ? \"items[i]\" : \"items[i].second\", false);\n  printer->Outdent();\n  printer->Print(\n      \"} else {\\n\");\n  printer->Indent();\n  GenerateSerializationLoop(\n      printer, variables, SupportsArenas(descriptor_), utf8_check,\n      \"for (::google::protobuf::Map< $key_cpp$, $val_cpp$ >::const_iterator\\n\"\n      \"    it = this->$name$().begin();\\n\"\n      \"    it != this->$name$().end(); ++it)\",\n      \"it\", true);\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid MapFieldGenerator::\nGenerateByteSize(io::Printer* printer) const {\n  printer->Print(variables_,\n      \"total_size += $tag_size$ * this->$name$_size();\\n\"\n      \"{\\n\"\n      \"  ::google::protobuf::scoped_ptr<$map_classname$> entry;\\n\"\n      \"  for (::google::protobuf::Map< $key_cpp$, $val_cpp$ >::const_iterator\\n\"\n      \"      it = this->$name$().begin();\\n\"\n      \"      it != this->$name$().end(); ++it) {\\n\");\n\n  // If entry is allocated by arena, its desctructor should be avoided.\n  if (SupportsArenas(descriptor_)) {\n    printer->Print(variables_,\n        \"    if (entry.get() != NULL && entry->GetArena() != NULL) {\\n\"\n        \"      entry.release();\\n\"\n        \"    }\\n\");\n  }\n\n  printer->Print(variables_,\n      \"    entry.reset($name$_.New$wrapper$(it->first, it->second));\\n\"\n      \"    total_size += ::google::protobuf::internal::WireFormatLite::\\n\"\n      \"        $declared_type$SizeNoVirtual(*entry);\\n\"\n      \"  }\\n\");\n\n  // If entry is allocated by arena, its desctructor should be avoided.\n  if (SupportsArenas(descriptor_)) {\n    printer->Print(variables_,\n        \"  if (entry.get() != NULL && entry->GetArena() != NULL) {\\n\"\n        \"    entry.release();\\n\"\n        \"  }\\n\");\n  }\n\n  printer->Print(\"}\\n\");\n}\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_map_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_MAP_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_CPP_MAP_FIELD_H__\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/compiler/cpp/cpp_message_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\nclass MapFieldGenerator : public FieldGenerator {\n public:\n  MapFieldGenerator(const FieldDescriptor* descriptor, const Options& options);\n  ~MapFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  void GeneratePrivateMembers(io::Printer* printer) const;\n  void GenerateAccessorDeclarations(io::Printer* printer) const;\n  void GenerateInlineAccessorDefinitions(io::Printer* printer,\n                                         bool is_inline) const;\n  void GenerateClearingCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateSwappingCode(io::Printer* printer) const;\n  void GenerateConstructorCode(io::Printer* printer) const;\n  void GenerateMergeFromCodedStream(io::Printer* printer) const;\n  void GenerateSerializeWithCachedSizes(io::Printer* printer) const;\n  void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;\n  void GenerateByteSize(io::Printer* printer) const;\n\n private:\n  // A helper for GenerateSerializeWithCachedSizes{,ToArray}.\n  void GenerateSerializeWithCachedSizes(\n      io::Printer* printer, const map<string, string>& variables) const;\n\n  const FieldDescriptor* descriptor_;\n  const bool dependent_field_;\n  map<string, string> variables_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldGenerator);\n};\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_CPP_MAP_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_message.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <algorithm>\n#include <google/protobuf/stubs/hash.h>\n#include <map>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <utility>\n#include <vector>\n#include <google/protobuf/compiler/cpp/cpp_message.h>\n#include <google/protobuf/compiler/cpp/cpp_field.h>\n#include <google/protobuf/compiler/cpp/cpp_enum.h>\n#include <google/protobuf/compiler/cpp/cpp_extension.h>\n#include <google/protobuf/compiler/cpp/cpp_helpers.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/descriptor.pb.h>\n\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\nusing internal::WireFormat;\nusing internal::WireFormatLite;\n\nnamespace {\n\ntemplate <class T>\nvoid PrintFieldComment(io::Printer* printer, const T* field) {\n  // Print the field's (or oneof's) proto-syntax definition as a comment.\n  // We don't want to print group bodies so we cut off after the first\n  // line.\n  DebugStringOptions options;\n  options.elide_group_body = true;\n  options.elide_oneof_body = true;\n  string def = field->DebugStringWithOptions(options);\n  printer->Print(\"// $def$\\n\",\n    \"def\", def.substr(0, def.find_first_of('\\n')));\n}\n\nstruct FieldOrderingByNumber {\n  inline bool operator()(const FieldDescriptor* a,\n                         const FieldDescriptor* b) const {\n    return a->number() < b->number();\n  }\n};\n\n// Sort the fields of the given Descriptor by number into a new[]'d array\n// and return it.\nconst FieldDescriptor** SortFieldsByNumber(const Descriptor* descriptor) {\n  const FieldDescriptor** fields =\n    new const FieldDescriptor*[descriptor->field_count()];\n  for (int i = 0; i < descriptor->field_count(); i++) {\n    fields[i] = descriptor->field(i);\n  }\n  std::sort(fields, fields + descriptor->field_count(),\n            FieldOrderingByNumber());\n  return fields;\n}\n\n// Functor for sorting extension ranges by their \"start\" field number.\nstruct ExtensionRangeSorter {\n  bool operator()(const Descriptor::ExtensionRange* left,\n                  const Descriptor::ExtensionRange* right) const {\n    return left->start < right->start;\n  }\n};\n\n// Returns true if the \"required\" restriction check should be ignored for the\n// given field.\ninline static bool ShouldIgnoreRequiredFieldCheck(const FieldDescriptor* field,\n                                                  const Options& options) {\n  return false;\n}\n\n// Returns true if the message type has any required fields.  If it doesn't,\n// we can optimize out calls to its IsInitialized() method.\n//\n// already_seen is used to avoid checking the same type multiple times\n// (and also to protect against recursion).\nstatic bool HasRequiredFields(const Descriptor* type, const Options& options,\n                              hash_set<const Descriptor*>* already_seen) {\n  if (already_seen->count(type) > 0) {\n    // Since the first occurrence of a required field causes the whole\n    // function to return true, we can assume that if the type is already\n    // in the cache it didn't have any required fields.\n    return false;\n  }\n  already_seen->insert(type);\n\n  // If the type has extensions, an extension with message type could contain\n  // required fields, so we have to be conservative and assume such an\n  // extension exists.\n  if (type->extension_range_count() > 0) return true;\n\n  for (int i = 0; i < type->field_count(); i++) {\n    const FieldDescriptor* field = type->field(i);\n    if (field->is_required()) {\n      return true;\n    }\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&\n        !ShouldIgnoreRequiredFieldCheck(field, options)) {\n      if (HasRequiredFields(field->message_type(), options, already_seen)) {\n        return true;\n      }\n    }\n  }\n\n  return false;\n}\n\nstatic bool HasRequiredFields(const Descriptor* type, const Options& options) {\n  hash_set<const Descriptor*> already_seen;\n  return HasRequiredFields(type, options, &already_seen);\n}\n\n// This returns an estimate of the compiler's alignment for the field.  This\n// can't guarantee to be correct because the generated code could be compiled on\n// different systems with different alignment rules.  The estimates below assume\n// 64-bit pointers.\nint EstimateAlignmentSize(const FieldDescriptor* field) {\n  if (field == NULL) return 0;\n  if (field->is_repeated()) return 8;\n  switch (field->cpp_type()) {\n    case FieldDescriptor::CPPTYPE_BOOL:\n      return 1;\n\n    case FieldDescriptor::CPPTYPE_INT32:\n    case FieldDescriptor::CPPTYPE_UINT32:\n    case FieldDescriptor::CPPTYPE_ENUM:\n    case FieldDescriptor::CPPTYPE_FLOAT:\n      return 4;\n\n    case FieldDescriptor::CPPTYPE_INT64:\n    case FieldDescriptor::CPPTYPE_UINT64:\n    case FieldDescriptor::CPPTYPE_DOUBLE:\n    case FieldDescriptor::CPPTYPE_STRING:\n    case FieldDescriptor::CPPTYPE_MESSAGE:\n      return 8;\n  }\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return -1;  // Make compiler happy.\n}\n\n// FieldGroup is just a helper for OptimizePadding below.  It holds a vector of\n// fields that are grouped together because they have compatible alignment, and\n// a preferred location in the final field ordering.\nclass FieldGroup {\n public:\n  FieldGroup()\n      : preferred_location_(0) {}\n\n  // A group with a single field.\n  FieldGroup(float preferred_location, const FieldDescriptor* field)\n      : preferred_location_(preferred_location),\n        fields_(1, field) {}\n\n  // Append the fields in 'other' to this group.\n  void Append(const FieldGroup& other) {\n    if (other.fields_.empty()) {\n      return;\n    }\n    // Preferred location is the average among all the fields, so we weight by\n    // the number of fields on each FieldGroup object.\n    preferred_location_ =\n        (preferred_location_ * fields_.size() +\n         (other.preferred_location_ * other.fields_.size())) /\n        (fields_.size() + other.fields_.size());\n    fields_.insert(fields_.end(), other.fields_.begin(), other.fields_.end());\n  }\n\n  void SetPreferredLocation(float location) { preferred_location_ = location; }\n  const vector<const FieldDescriptor*>& fields() const { return fields_; }\n\n  // FieldGroup objects sort by their preferred location.\n  bool operator<(const FieldGroup& other) const {\n    return preferred_location_ < other.preferred_location_;\n  }\n\n private:\n  // \"preferred_location_\" is an estimate of where this group should go in the\n  // final list of fields.  We compute this by taking the average index of each\n  // field in this group in the original ordering of fields.  This is very\n  // approximate, but should put this group close to where its member fields\n  // originally went.\n  float preferred_location_;\n  vector<const FieldDescriptor*> fields_;\n  // We rely on the default copy constructor and operator= so this type can be\n  // used in a vector.\n};\n\n// Reorder 'fields' so that if the fields are output into a c++ class in the new\n// order, the alignment padding is minimized.  We try to do this while keeping\n// each field as close as possible to its original position so that we don't\n// reduce cache locality much for function that access each field in order.\nvoid OptimizePadding(vector<const FieldDescriptor*>* fields) {\n  // First divide fields into those that align to 1 byte, 4 bytes or 8 bytes.\n  vector<FieldGroup> aligned_to_1, aligned_to_4, aligned_to_8;\n  for (int i = 0; i < fields->size(); ++i) {\n    switch (EstimateAlignmentSize((*fields)[i])) {\n      case 1: aligned_to_1.push_back(FieldGroup(i, (*fields)[i])); break;\n      case 4: aligned_to_4.push_back(FieldGroup(i, (*fields)[i])); break;\n      case 8: aligned_to_8.push_back(FieldGroup(i, (*fields)[i])); break;\n      default:\n        GOOGLE_LOG(FATAL) << \"Unknown alignment size.\";\n    }\n  }\n\n  // Now group fields aligned to 1 byte into sets of 4, and treat those like a\n  // single field aligned to 4 bytes.\n  for (int i = 0; i < aligned_to_1.size(); i += 4) {\n    FieldGroup field_group;\n    for (int j = i; j < aligned_to_1.size() && j < i + 4; ++j) {\n      field_group.Append(aligned_to_1[j]);\n    }\n    aligned_to_4.push_back(field_group);\n  }\n  // Sort by preferred location to keep fields as close to their original\n  // location as possible.  Using stable_sort ensures that the output is\n  // consistent across runs.\n  std::stable_sort(aligned_to_4.begin(), aligned_to_4.end());\n\n  // Now group fields aligned to 4 bytes (or the 4-field groups created above)\n  // into pairs, and treat those like a single field aligned to 8 bytes.\n  for (int i = 0; i < aligned_to_4.size(); i += 2) {\n    FieldGroup field_group;\n    for (int j = i; j < aligned_to_4.size() && j < i + 2; ++j) {\n      field_group.Append(aligned_to_4[j]);\n    }\n    if (i == aligned_to_4.size() - 1) {\n      // Move incomplete 4-byte block to the end.\n      field_group.SetPreferredLocation(fields->size() + 1);\n    }\n    aligned_to_8.push_back(field_group);\n  }\n  // Sort by preferred location.\n  std::stable_sort(aligned_to_8.begin(), aligned_to_8.end());\n\n  // Now pull out all the FieldDescriptors in order.\n  fields->clear();\n  for (int i = 0; i < aligned_to_8.size(); ++i) {\n    fields->insert(fields->end(),\n                   aligned_to_8[i].fields().begin(),\n                   aligned_to_8[i].fields().end());\n  }\n}\n\nstring MessageTypeProtoName(const FieldDescriptor* field) {\n  return field->message_type()->full_name();\n}\n\n// Emits an if-statement with a condition that evaluates to true if |field| is\n// considered non-default (will be sent over the wire), for message types\n// without true field presence. Should only be called if\n// !HasFieldPresence(message_descriptor).\nbool EmitFieldNonDefaultCondition(io::Printer* printer,\n                                  const string& prefix,\n                                  const FieldDescriptor* field) {\n  // Merge and serialize semantics: primitive fields are merged/serialized only\n  // if non-zero (numeric) or non-empty (string).\n  if (!field->is_repeated() && !field->containing_oneof()) {\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {\n      printer->Print(\n          \"if ($prefix$$name$().size() > 0) {\\n\",\n          \"prefix\", prefix,\n          \"name\", FieldName(field));\n    } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n      // Message fields still have has_$name$() methods.\n      printer->Print(\n          \"if ($prefix$has_$name$()) {\\n\",\n          \"prefix\", prefix,\n          \"name\", FieldName(field));\n    } else {\n      printer->Print(\n          \"if ($prefix$$name$() != 0) {\\n\",\n          \"prefix\", prefix,\n          \"name\", FieldName(field));\n    }\n    printer->Indent();\n    return true;\n  } else if (field->containing_oneof()) {\n    printer->Print(\n        \"if (has_$name$()) {\\n\",\n        \"name\", FieldName(field));\n    printer->Indent();\n    return true;\n  }\n  return false;\n}\n\n// Does the given field have a has_$name$() method?\nbool HasHasMethod(const FieldDescriptor* field) {\n  if (HasFieldPresence(field->file())) {\n    // In proto1/proto2, every field has a has_$name$() method.\n    return true;\n  }\n  // For message types without true field presence, only fields with a message\n  // type have a has_$name$() method.\n  return field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE;\n}\n\n// Collects map entry message type information.\nvoid CollectMapInfo(const Descriptor* descriptor,\n                    map<string, string>* variables) {\n  GOOGLE_CHECK(IsMapEntryMessage(descriptor));\n  const FieldDescriptor* key = descriptor->FindFieldByName(\"key\");\n  const FieldDescriptor* val = descriptor->FindFieldByName(\"value\");\n  (*variables)[\"key\"] = PrimitiveTypeName(key->cpp_type());\n  switch (val->cpp_type()) {\n    case FieldDescriptor::CPPTYPE_MESSAGE:\n      (*variables)[\"val\"] = FieldMessageTypeName(val);\n      break;\n    case FieldDescriptor::CPPTYPE_ENUM:\n      (*variables)[\"val\"] = ClassName(val->enum_type(), true);\n      break;\n    default:\n      (*variables)[\"val\"] = PrimitiveTypeName(val->cpp_type());\n  }\n  (*variables)[\"key_wire_type\"] =\n      \"::google::protobuf::internal::WireFormatLite::TYPE_\" +\n      ToUpper(DeclaredTypeMethodName(key->type()));\n  (*variables)[\"val_wire_type\"] =\n      \"::google::protobuf::internal::WireFormatLite::TYPE_\" +\n      ToUpper(DeclaredTypeMethodName(val->type()));\n}\n\n// Does the given field have a private (internal helper only) has_$name$()\n// method?\nbool HasPrivateHasMethod(const FieldDescriptor* field) {\n  // Only for oneofs in message types with no field presence. has_$name$(),\n  // based on the oneof case, is still useful internally for generated code.\n  return (!HasFieldPresence(field->file()) &&\n          field->containing_oneof() != NULL);\n}\n\n}  // anonymous namespace\n\n// ===================================================================\n\nMessageGenerator::MessageGenerator(const Descriptor* descriptor,\n                                   const Options& options)\n    : descriptor_(descriptor),\n      classname_(ClassName(descriptor, false)),\n      options_(options),\n      field_generators_(descriptor, options),\n      nested_generators_(new google::protobuf::scoped_ptr<\n          MessageGenerator>[descriptor->nested_type_count()]),\n      enum_generators_(\n          new google::protobuf::scoped_ptr<EnumGenerator>[descriptor->enum_type_count()]),\n      extension_generators_(new google::protobuf::scoped_ptr<\n          ExtensionGenerator>[descriptor->extension_count()]),\n      use_dependent_base_(false) {\n\n  for (int i = 0; i < descriptor->nested_type_count(); i++) {\n    nested_generators_[i].reset(\n      new MessageGenerator(descriptor->nested_type(i), options));\n  }\n\n  for (int i = 0; i < descriptor->enum_type_count(); i++) {\n    enum_generators_[i].reset(\n      new EnumGenerator(descriptor->enum_type(i), options));\n  }\n\n  for (int i = 0; i < descriptor->extension_count(); i++) {\n    extension_generators_[i].reset(\n      new ExtensionGenerator(descriptor->extension(i), options));\n  }\n\n  num_required_fields_ = 0;\n  for (int i = 0; i < descriptor->field_count(); i++) {\n    if (descriptor->field(i)->is_required()) {\n      ++num_required_fields_;\n    }\n    if (options.proto_h && IsFieldDependent(descriptor->field(i))) {\n      use_dependent_base_ = true;\n    }\n  }\n  if (options.proto_h && descriptor->oneof_decl_count() > 0) {\n    // Always make oneofs dependent.\n    use_dependent_base_ = true;\n  }\n}\n\nMessageGenerator::~MessageGenerator() {}\n\nvoid MessageGenerator::\nFillMessageForwardDeclarations(map<string, const Descriptor*>* class_names) {\n  (*class_names)[classname_] = descriptor_;\n\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    // map entry message doesn't need forward declaration. Since map entry\n    // message cannot be a top level class, we just need to avoid calling\n    // GenerateForwardDeclaration here.\n    if (IsMapEntryMessage(descriptor_->nested_type(i))) continue;\n    nested_generators_[i]->FillMessageForwardDeclarations(class_names);\n  }\n}\n\nvoid MessageGenerator::\nFillEnumForwardDeclarations(map<string, const EnumDescriptor*>* enum_names) {\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    nested_generators_[i]->FillEnumForwardDeclarations(enum_names);\n  }\n  for (int i = 0; i < descriptor_->enum_type_count(); i++) {\n    enum_generators_[i]->FillForwardDeclaration(enum_names);\n  }\n}\n\nvoid MessageGenerator::\nGenerateEnumDefinitions(io::Printer* printer) {\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    nested_generators_[i]->GenerateEnumDefinitions(printer);\n  }\n\n  for (int i = 0; i < descriptor_->enum_type_count(); i++) {\n    enum_generators_[i]->GenerateDefinition(printer);\n  }\n}\n\nvoid MessageGenerator::\nGenerateGetEnumDescriptorSpecializations(io::Printer* printer) {\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    nested_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer);\n  }\n  for (int i = 0; i < descriptor_->enum_type_count(); i++) {\n    enum_generators_[i]->GenerateGetEnumDescriptorSpecializations(printer);\n  }\n}\n\nvoid MessageGenerator::\nGenerateDependentFieldAccessorDeclarations(io::Printer* printer) {\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n\n    PrintFieldComment(printer, field);\n\n    map<string, string> vars;\n    SetCommonFieldVariables(field, &vars, options_);\n\n    if (use_dependent_base_ && IsFieldDependent(field)) {\n      // If the message is dependent, the inline clear_*() method will need\n      // to delete the message type, so it must be in the dependent base\n      // class. (See also GenerateFieldAccessorDeclarations.)\n      printer->Print(vars, \"$deprecated_attr$void clear_$name$();\\n\");\n    }\n    // Generate type-specific accessor declarations.\n    field_generators_.get(field).GenerateDependentAccessorDeclarations(printer);\n    printer->Print(\"\\n\");\n  }\n}\n\nvoid MessageGenerator::\nGenerateFieldAccessorDeclarations(io::Printer* printer) {\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n\n    PrintFieldComment(printer, field);\n\n    map<string, string> vars;\n    SetCommonFieldVariables(field, &vars, options_);\n    vars[\"constant_name\"] = FieldConstantName(field);\n\n    bool dependent_field = use_dependent_base_ && IsFieldDependent(field);\n    if (dependent_field &&\n        field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&\n        !field->is_map()) {\n      // If this field is dependent, the dependent base class determines\n      // the message type from the derived class (which is a template\n      // parameter). This typedef is for that:\n      printer->Print(\n          \"private:\\n\"\n          \"typedef $field_type$ $dependent_type$;\\n\"\n          \"public:\\n\",\n          \"field_type\", FieldMessageTypeName(field),\n          \"dependent_type\", DependentTypeName(field));\n    }\n\n    if (field->is_repeated()) {\n      printer->Print(vars, \"$deprecated_attr$int $name$_size() const;\\n\");\n    } else if (HasHasMethod(field)) {\n      printer->Print(vars, \"$deprecated_attr$bool has_$name$() const;\\n\");\n    } else if (HasPrivateHasMethod(field)) {\n      printer->Print(vars,\n          \"private:\\n\"\n          \"bool has_$name$() const;\\n\"\n          \"public:\\n\");\n    }\n\n    if (!dependent_field) {\n      // If this field is dependent, then its clear_() method is in the\n      // depenent base class. (See also GenerateDependentAccessorDeclarations.)\n      printer->Print(vars, \"$deprecated_attr$void clear_$name$();\\n\");\n    }\n    printer->Print(vars,\n                   \"$deprecated_attr$static const int $constant_name$ = \"\n                   \"$number$;\\n\");\n\n    // Generate type-specific accessor declarations.\n    field_generators_.get(field).GenerateAccessorDeclarations(printer);\n\n    printer->Print(\"\\n\");\n  }\n\n  if (descriptor_->extension_range_count() > 0) {\n    // Generate accessors for extensions.  We just call a macro located in\n    // extension_set.h since the accessors about 80 lines of static code.\n    printer->Print(\n      \"GOOGLE_PROTOBUF_EXTENSION_ACCESSORS($classname$)\\n\",\n      \"classname\", classname_);\n  }\n\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    printer->Print(\n        \"$camel_oneof_name$Case $oneof_name$_case() const;\\n\",\n        \"camel_oneof_name\",\n        UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), true),\n        \"oneof_name\", descriptor_->oneof_decl(i)->name());\n  }\n}\n\nvoid MessageGenerator::\nGenerateDependentFieldAccessorDefinitions(io::Printer* printer) {\n  if (!use_dependent_base_) return;\n\n  printer->Print(\"// $classname$\\n\\n\", \"classname\",\n                 DependentBaseClassTemplateName(descriptor_));\n\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n\n    PrintFieldComment(printer, field);\n\n    // These functions are not really dependent: they are part of the\n    // (non-dependent) derived class. However, they need to live outside\n    // any #ifdef guards, so we treat them as if they were dependent.\n    //\n    // See the comment in FileGenerator::GenerateInlineFunctionDefinitions\n    // for a more complete explanation.\n    if (use_dependent_base_ && IsFieldDependent(field)) {\n      map<string, string> vars;\n      SetCommonFieldVariables(field, &vars, options_);\n      vars[\"inline\"] = \"inline \";\n      if (field->containing_oneof()) {\n        vars[\"field_name\"] = UnderscoresToCamelCase(field->name(), true);\n        vars[\"oneof_name\"] = field->containing_oneof()->name();\n        vars[\"oneof_index\"] = SimpleItoa(field->containing_oneof()->index());\n        GenerateOneofMemberHasBits(field, vars, printer);\n      } else if (!field->is_repeated()) {\n        // There will be no header guard, so this always has to be inline.\n        GenerateSingularFieldHasBits(field, vars, printer);\n      }\n      // vars needed for clear_(), which is in the dependent base:\n      // (See also GenerateDependentFieldAccessorDeclarations.)\n      vars[\"tmpl\"] = \"template<class T>\\n\";\n      vars[\"dependent_classname\"] =\n          DependentBaseClassTemplateName(descriptor_) + \"<T>\";\n      vars[\"this_message\"] = DependentBaseDownCast();\n      vars[\"this_const_message\"] = DependentBaseConstDownCast();\n      GenerateFieldClear(field, vars, printer);\n    }\n\n    // Generate type-specific accessors.\n    field_generators_.get(field)\n        .GenerateDependentInlineAccessorDefinitions(printer);\n\n    printer->Print(\"\\n\");\n  }\n\n  // Generate has_$name$() and clear_has_$name$() functions for oneofs\n  // Similar to other has-bits, these must always be in the header if we\n  // are using a dependent base class.\n  GenerateOneofHasBits(printer, true /* is_inline */);\n}\n\nvoid MessageGenerator::\nGenerateSingularFieldHasBits(const FieldDescriptor* field,\n                             map<string, string> vars,\n                             io::Printer* printer) {\n  if (HasFieldPresence(descriptor_->file())) {\n    // N.B.: without field presence, we do not use has-bits or generate\n    // has_$name$() methods.\n    vars[\"has_array_index\"] = SimpleItoa(field->index() / 32);\n    vars[\"has_mask\"] = StrCat(strings::Hex(1u << (field->index() % 32),\n                                           strings::ZERO_PAD_8));\n    printer->Print(vars,\n      \"$inline$\"\n      \"bool $classname$::has_$name$() const {\\n\"\n      \"  return (_has_bits_[$has_array_index$] & 0x$has_mask$u) != 0;\\n\"\n      \"}\\n\"\n      \"$inline$\"\n      \"void $classname$::set_has_$name$() {\\n\"\n      \"  _has_bits_[$has_array_index$] |= 0x$has_mask$u;\\n\"\n      \"}\\n\"\n      \"$inline$\"\n      \"void $classname$::clear_has_$name$() {\\n\"\n      \"  _has_bits_[$has_array_index$] &= ~0x$has_mask$u;\\n\"\n      \"}\\n\");\n  } else {\n    // Message fields have a has_$name$() method.\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n      bool is_lazy = false;\n      if (is_lazy) {\n        printer->Print(vars,\n          \"$inline$\"\n          \"bool $classname$::has_$name$() const {\\n\"\n          \"  return !$name$_.IsCleared();\\n\"\n          \"}\\n\");\n      } else {\n        printer->Print(vars,\n          \"$inline$\"\n          \"bool $classname$::has_$name$() const {\\n\"\n          \"  return !_is_default_instance_ && $name$_ != NULL;\\n\"\n          \"}\\n\");\n      }\n    }\n  }\n}\n\nvoid MessageGenerator::\nGenerateOneofHasBits(io::Printer* printer, bool is_inline) {\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    map<string, string> vars;\n    vars[\"oneof_name\"] = descriptor_->oneof_decl(i)->name();\n    vars[\"oneof_index\"] = SimpleItoa(descriptor_->oneof_decl(i)->index());\n    vars[\"cap_oneof_name\"] =\n        ToUpper(descriptor_->oneof_decl(i)->name());\n    vars[\"classname\"] = classname_;\n    vars[\"inline\"] = (is_inline ? \"inline \" : \"\");\n    printer->Print(\n        vars,\n        \"$inline$\"\n        \"bool $classname$::has_$oneof_name$() const {\\n\"\n        \"  return $oneof_name$_case() != $cap_oneof_name$_NOT_SET;\\n\"\n        \"}\\n\"\n        \"$inline$\"\n        \"void $classname$::clear_has_$oneof_name$() {\\n\"\n        \"  _oneof_case_[$oneof_index$] = $cap_oneof_name$_NOT_SET;\\n\"\n        \"}\\n\");\n  }\n}\n\nvoid MessageGenerator::\nGenerateOneofMemberHasBits(const FieldDescriptor* field,\n                           const map<string, string>& vars,\n                           io::Printer* printer) {\n  // Singular field in a oneof\n  // N.B.: Without field presence, we do not use has-bits or generate\n  // has_$name$() methods, but oneofs still have set_has_$name$().\n  // Oneofs also have has_$name$() but only as a private helper\n  // method, so that generated code is slightly cleaner (vs.  comparing\n  // _oneof_case_[index] against a constant everywhere).\n  printer->Print(vars,\n    \"$inline$\"\n    \"bool $classname$::has_$name$() const {\\n\"\n    \"  return $oneof_name$_case() == k$field_name$;\\n\"\n    \"}\\n\");\n  printer->Print(vars,\n    \"$inline$\"\n    \"void $classname$::set_has_$name$() {\\n\"\n    \"  _oneof_case_[$oneof_index$] = k$field_name$;\\n\"\n    \"}\\n\");\n}\n\nvoid MessageGenerator::\nGenerateFieldClear(const FieldDescriptor* field,\n                   const map<string, string>& vars,\n                   io::Printer* printer) {\n  // Generate clear_$name$() (See GenerateFieldAccessorDeclarations and\n  // GenerateDependentFieldAccessorDeclarations, $dependent_classname$ is\n  // set by the Generate*Definitions functions.)\n  printer->Print(vars,\n    \"$tmpl$\"\n    \"$inline$\"\n    \"void $dependent_classname$::clear_$name$() {\\n\");\n\n  printer->Indent();\n\n  if (field->containing_oneof()) {\n    // Clear this field only if it is the active field in this oneof,\n    // otherwise ignore\n    printer->Print(vars,\n      \"if ($this_message$has_$name$()) {\\n\");\n    printer->Indent();\n    field_generators_.get(field)\n        .GenerateClearingCode(printer);\n    printer->Print(vars,\n      \"$this_message$clear_has_$oneof_name$();\\n\");\n    printer->Outdent();\n    printer->Print(\"}\\n\");\n  } else {\n    field_generators_.get(field)\n        .GenerateClearingCode(printer);\n    if (HasFieldPresence(descriptor_->file())) {\n      if (!field->is_repeated()) {\n        printer->Print(vars,\n                       \"$this_message$clear_has_$name$();\\n\");\n      }\n    }\n  }\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid MessageGenerator::\nGenerateFieldAccessorDefinitions(io::Printer* printer, bool is_inline) {\n  printer->Print(\"// $classname$\\n\\n\", \"classname\", classname_);\n\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n\n    PrintFieldComment(printer, field);\n\n    map<string, string> vars;\n    SetCommonFieldVariables(field, &vars, options_);\n    vars[\"inline\"] = is_inline ? \"inline \" : \"\";\n    if (use_dependent_base_ && IsFieldDependent(field)) {\n      vars[\"tmpl\"] = \"template<class T>\\n\";\n      vars[\"dependent_classname\"] =\n          DependentBaseClassTemplateName(descriptor_) + \"<T>\";\n      vars[\"this_message\"] = \"reinterpret_cast<T*>(this)->\";\n      vars[\"this_const_message\"] = \"reinterpret_cast<const T*>(this)->\";\n    } else {\n      vars[\"tmpl\"] = \"\";\n      vars[\"dependent_classname\"] = vars[\"classname\"];\n      vars[\"this_message\"] = \"\";\n      vars[\"this_const_message\"] = \"\";\n    }\n\n    // Generate has_$name$() or $name$_size().\n    if (field->is_repeated()) {\n      printer->Print(vars,\n        \"$inline$\"\n        \"int $classname$::$name$_size() const {\\n\"\n        \"  return $name$_.size();\\n\"\n        \"}\\n\");\n    } else if (field->containing_oneof()) {\n      vars[\"field_name\"] = UnderscoresToCamelCase(field->name(), true);\n      vars[\"oneof_name\"] = field->containing_oneof()->name();\n      vars[\"oneof_index\"] = SimpleItoa(field->containing_oneof()->index());\n      if (!use_dependent_base_ || !IsFieldDependent(field)) {\n        GenerateOneofMemberHasBits(field, vars, printer);\n      }\n    } else {\n      // Singular field.\n      if (!use_dependent_base_ || !IsFieldDependent(field)) {\n        GenerateSingularFieldHasBits(field, vars, printer);\n      }\n    }\n\n    if (!use_dependent_base_ || !IsFieldDependent(field)) {\n      GenerateFieldClear(field, vars, printer);\n    }\n\n    // Generate type-specific accessors.\n    field_generators_.get(field).GenerateInlineAccessorDefinitions(printer,\n                                                                   is_inline);\n\n    printer->Print(\"\\n\");\n  }\n\n  if (!use_dependent_base_) {\n    // Generate has_$name$() and clear_has_$name$() functions for oneofs\n    // If we aren't using a dependent base, they can be with the other functions\n    // that are #ifdef-guarded.\n    GenerateOneofHasBits(printer, is_inline);\n  }\n}\n\n// Helper for the code that emits the Clear() method.\nstatic bool CanClearByZeroing(const FieldDescriptor* field) {\n  if (field->is_repeated() || field->is_extension()) return false;\n  switch (field->cpp_type()) {\n    case internal::WireFormatLite::CPPTYPE_ENUM:\n      return field->default_value_enum()->number() == 0;\n    case internal::WireFormatLite::CPPTYPE_INT32:\n      return field->default_value_int32() == 0;\n    case internal::WireFormatLite::CPPTYPE_INT64:\n      return field->default_value_int64() == 0;\n    case internal::WireFormatLite::CPPTYPE_UINT32:\n      return field->default_value_uint32() == 0;\n    case internal::WireFormatLite::CPPTYPE_UINT64:\n      return field->default_value_uint64() == 0;\n    case internal::WireFormatLite::CPPTYPE_FLOAT:\n      return field->default_value_float() == 0;\n    case internal::WireFormatLite::CPPTYPE_DOUBLE:\n      return field->default_value_double() == 0;\n    case internal::WireFormatLite::CPPTYPE_BOOL:\n      return field->default_value_bool() == false;\n    default:\n      return false;\n  }\n}\n\nvoid MessageGenerator::\nGenerateDependentBaseClassDefinition(io::Printer* printer) {\n  if (!use_dependent_base_) {\n    return;\n  }\n\n  map<string, string> vars;\n  vars[\"classname\"] = DependentBaseClassTemplateName(descriptor_);\n  vars[\"full_name\"] = descriptor_->full_name();\n  vars[\"superclass\"] = SuperClassName(descriptor_, options_);\n\n  printer->Print(vars,\n    \"template <class T>\\n\"\n    \"class $classname$ : public $superclass$ \"\n    \"/* @@protoc_insertion_point(dep_base_class_definition:$full_name$) */ {\\n\"\n    \" public:\\n\");\n  printer->Indent();\n\n  printer->Print(vars,\n    \"$classname$() {}\\n\"\n    \"virtual ~$classname$() {}\\n\"\n    \"\\n\");\n\n  // Generate dependent accessor methods for all fields.\n  GenerateDependentFieldAccessorDeclarations(printer);\n\n  printer->Outdent();\n  printer->Print(\"};\\n\");\n}\n\nvoid MessageGenerator::\nGenerateClassDefinition(io::Printer* printer) {\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    // map entry message doesn't need class definition. Since map entry message\n    // cannot be a top level class, we just need to avoid calling\n    // GenerateClassDefinition here.\n    if (IsMapEntryMessage(descriptor_->nested_type(i))) continue;\n    nested_generators_[i]->GenerateClassDefinition(printer);\n    printer->Print(\"\\n\");\n    printer->Print(kThinSeparator);\n    printer->Print(\"\\n\");\n  }\n\n  if (use_dependent_base_) {\n    GenerateDependentBaseClassDefinition(printer);\n      printer->Print(\"\\n\");\n  }\n\n  map<string, string> vars;\n  vars[\"classname\"] = classname_;\n  vars[\"full_name\"] = descriptor_->full_name();\n  vars[\"field_count\"] = SimpleItoa(descriptor_->field_count());\n  vars[\"oneof_decl_count\"] = SimpleItoa(descriptor_->oneof_decl_count());\n  if (options_.dllexport_decl.empty()) {\n    vars[\"dllexport\"] = \"\";\n  } else {\n    vars[\"dllexport\"] = options_.dllexport_decl + \" \";\n  }\n  if (use_dependent_base_) {\n    vars[\"superclass\"] =\n        DependentBaseClassTemplateName(descriptor_) + \"<\" + classname_ + \">\";\n  } else {\n    vars[\"superclass\"] = SuperClassName(descriptor_, options_);\n  }\n  printer->Print(vars,\n    \"class $dllexport$$classname$ : public $superclass$ \"\n    \"/* @@protoc_insertion_point(class_definition:$full_name$) */ \"\n    \"{\\n\");\n  printer->Annotate(\"classname\", descriptor_);\n  if (use_dependent_base_) {\n    printer->Print(vars, \"  friend class $superclass$;\\n\");\n  }\n  printer->Print(\" public:\\n\");\n  printer->Indent();\n\n  printer->Print(vars,\n    \"$classname$();\\n\"\n    \"virtual ~$classname$();\\n\"\n    \"\\n\"\n    \"$classname$(const $classname$& from);\\n\"\n    \"\\n\"\n    \"inline $classname$& operator=(const $classname$& from) {\\n\"\n    \"  CopyFrom(from);\\n\"\n    \"  return *this;\\n\"\n    \"}\\n\"\n    \"\\n\");\n\n  if (PreserveUnknownFields(descriptor_)) {\n    if (UseUnknownFieldSet(descriptor_->file(), options_)) {\n      printer->Print(\n        \"inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\\n\"\n        \"  return _internal_metadata_.unknown_fields();\\n\"\n        \"}\\n\"\n        \"\\n\"\n        \"inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\\n\"\n        \"  return _internal_metadata_.mutable_unknown_fields();\\n\"\n        \"}\\n\"\n        \"\\n\");\n    } else {\n      if (SupportsArenas(descriptor_)) {\n        printer->Print(\n          \"inline const ::std::string& unknown_fields() const {\\n\"\n          \"  return _unknown_fields_.Get(\\n\"\n          \"      &::google::protobuf::internal::GetEmptyStringAlreadyInited());\\n\"\n          \"}\\n\"\n          \"\\n\"\n          \"inline ::std::string* mutable_unknown_fields() {\\n\"\n          \"  return _unknown_fields_.Mutable(\\n\"\n          \"      &::google::protobuf::internal::GetEmptyStringAlreadyInited(),\\n\"\n          \"      GetArenaNoVirtual());\\n\"\n          \"}\\n\"\n          \"\\n\");\n      } else {\n        printer->Print(\n          \"inline const ::std::string& unknown_fields() const {\\n\"\n          \"  return _unknown_fields_.GetNoArena(\\n\"\n          \"      &::google::protobuf::internal::GetEmptyStringAlreadyInited());\\n\"\n          \"}\\n\"\n          \"\\n\"\n          \"inline ::std::string* mutable_unknown_fields() {\\n\"\n          \"  return _unknown_fields_.MutableNoArena(\\n\"\n          \"      &::google::protobuf::internal::GetEmptyStringAlreadyInited());\\n\"\n          \"}\\n\"\n          \"\\n\");\n      }\n    }\n  }\n\n  // N.B.: We exclude GetArena() when arena support is disabled, falling back on\n  // MessageLite's implementation which returns NULL rather than generating our\n  // own method which returns NULL, in order to reduce code size.\n  if (SupportsArenas(descriptor_)) {\n    // virtual method version of GetArenaNoVirtual(), required for generic dispatch given a\n    // MessageLite* (e.g., in RepeatedField::AddAllocated()).\n    printer->Print(\n        \"inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }\\n\"\n        \"inline void* GetMaybeArenaPointer() const {\\n\"\n        \"  return MaybeArenaPtr();\\n\"\n        \"}\\n\");\n  }\n\n  // Only generate this member if it's not disabled.\n  if (HasDescriptorMethods(descriptor_->file(), options_) &&\n      !descriptor_->options().no_standard_descriptor_accessor()) {\n    printer->Print(vars,\n      \"static const ::google::protobuf::Descriptor* descriptor();\\n\");\n  }\n\n  printer->Print(vars,\n    \"static const $classname$& default_instance();\\n\"\n    \"\\n\");\n\n  // Generate enum values for every field in oneofs. One list is generated for\n  // each oneof with an additional *_NOT_SET value.\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    printer->Print(\n        \"enum $camel_oneof_name$Case {\\n\",\n        \"camel_oneof_name\",\n        UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), true));\n    printer->Indent();\n    for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {\n      printer->Print(\n          \"k$field_name$ = $field_number$,\\n\",\n          \"field_name\",\n          UnderscoresToCamelCase(\n              descriptor_->oneof_decl(i)->field(j)->name(), true),\n          \"field_number\",\n          SimpleItoa(descriptor_->oneof_decl(i)->field(j)->number()));\n    }\n    printer->Print(\n        \"$cap_oneof_name$_NOT_SET = 0,\\n\",\n        \"cap_oneof_name\",\n        ToUpper(descriptor_->oneof_decl(i)->name()));\n    printer->Outdent();\n    printer->Print(\n        \"};\\n\"\n        \"\\n\");\n  }\n\n  if (!StaticInitializersForced(descriptor_->file(), options_)) {\n    printer->Print(vars,\n      \"#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER\\n\"\n      \"// Returns the internal default instance pointer. This function can\\n\"\n      \"// return NULL thus should not be used by the user. This is intended\\n\"\n      \"// for Protobuf internal code. Please use default_instance() declared\\n\"\n      \"// above instead.\\n\"\n      \"static inline const $classname$* internal_default_instance() {\\n\"\n      \"  return default_instance_;\\n\"\n      \"}\\n\"\n      \"#endif\\n\"\n      \"\\n\");\n  }\n\n\n  if (SupportsArenas(descriptor_)) {\n    printer->Print(vars,\n      \"void UnsafeArenaSwap($classname$* other);\\n\");\n  }\n\n  if (IsAnyMessage(descriptor_)) {\n    printer->Print(vars,\n      \"// implements Any -----------------------------------------------\\n\"\n      \"\\n\"\n      \"void PackFrom(const ::google::protobuf::Message& message);\\n\"\n      \"void PackFrom(const ::google::protobuf::Message& message,\\n\"\n      \"              const ::std::string& type_url_prefix);\\n\"\n      \"bool UnpackTo(::google::protobuf::Message* message) const;\\n\"\n      \"template<typename T> bool Is() const {\\n\"\n      \"  return _any_metadata_.Is<T>();\\n\"\n      \"}\\n\"\n      \"\\n\");\n  }\n\n  printer->Print(vars,\n    \"void Swap($classname$* other);\\n\"\n    \"\\n\"\n    \"// implements Message ----------------------------------------------\\n\"\n    \"\\n\"\n    \"inline $classname$* New() const { return New(NULL); }\\n\"\n    \"\\n\"\n    \"$classname$* New(::google::protobuf::Arena* arena) const;\\n\");\n\n  if (HasGeneratedMethods(descriptor_->file(), options_)) {\n    if (HasDescriptorMethods(descriptor_->file(), options_)) {\n      printer->Print(vars,\n        \"void CopyFrom(const ::google::protobuf::Message& from);\\n\"\n        \"void MergeFrom(const ::google::protobuf::Message& from);\\n\");\n    } else {\n      printer->Print(vars,\n        \"void CheckTypeAndMergeFrom(const ::google::protobuf::MessageLite& from);\\n\");\n    }\n\n    printer->Print(vars,\n      \"void CopyFrom(const $classname$& from);\\n\"\n      \"void MergeFrom(const $classname$& from);\\n\"\n      \"void Clear();\\n\"\n      \"bool IsInitialized() const;\\n\"\n      \"\\n\"\n      \"int ByteSize() const;\\n\"\n      \"bool MergePartialFromCodedStream(\\n\"\n      \"    ::google::protobuf::io::CodedInputStream* input);\\n\"\n      \"void SerializeWithCachedSizes(\\n\"\n      \"    ::google::protobuf::io::CodedOutputStream* output) const;\\n\");\n    // DiscardUnknownFields() is implemented in message.cc using reflections. We\n    // need to implement this function in generated code for messages.\n    if (!UseUnknownFieldSet(descriptor_->file(), options_)) {\n      printer->Print(\n        \"void DiscardUnknownFields();\\n\");\n    }\n    if (HasFastArraySerialization(descriptor_->file(), options_)) {\n      printer->Print(\n        \"::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\\n\"\n        \"    bool deterministic, ::google::protobuf::uint8* output) const;\\n\"\n        \"::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\\n\"\n        \"  return InternalSerializeWithCachedSizesToArray(false, output);\\n\"\n        \"}\\n\");\n    }\n  }\n\n  // Check all FieldDescriptors including those in oneofs to estimate\n  // whether ::std::string is likely to be used, and depending on that\n  // estimate, set uses_string_ to true or false.  That contols\n  // whether to force initialization of empty_string_ in SharedCtor().\n  // It's often advantageous to do so to keep \"is empty_string_\n  // inited?\" code from appearing all over the place.\n  vector<const FieldDescriptor*> descriptors;\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    descriptors.push_back(descriptor_->field(i));\n  }\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {\n      descriptors.push_back(descriptor_->oneof_decl(i)->field(j));\n    }\n  }\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    const Descriptor* nested_type = descriptor_->nested_type(i);\n    if (IsMapEntryMessage(nested_type)) {\n      descriptors.push_back(nested_type->FindFieldByName(\"key\"));\n      descriptors.push_back(nested_type->FindFieldByName(\"value\"));\n    }\n  }\n  uses_string_ = false;\n  if (PreserveUnknownFields(descriptor_) &&\n      !UseUnknownFieldSet(descriptor_->file(), options_)) {\n    uses_string_ = true;\n  }\n  for (int i = 0; i < descriptors.size(); i++) {\n    const FieldDescriptor* field = descriptors[i];\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {\n      switch (field->options().ctype()) {\n        default: uses_string_ = true; break;\n      }\n    }\n  }\n\n  printer->Print(\n    \"int GetCachedSize() const { return _cached_size_; }\\n\"\n    \"private:\\n\"\n    \"void SharedCtor();\\n\"\n    \"void SharedDtor();\\n\"\n    \"void SetCachedSize(int size) const;\\n\"\n    \"void InternalSwap($classname$* other);\\n\",\n    \"classname\", classname_);\n  if (SupportsArenas(descriptor_)) {\n    printer->Print(\n      \"protected:\\n\"\n      \"explicit $classname$(::google::protobuf::Arena* arena);\\n\"\n      \"private:\\n\"\n      \"static void ArenaDtor(void* object);\\n\"\n      \"inline void RegisterArenaDtor(::google::protobuf::Arena* arena);\\n\",\n      \"classname\", classname_);\n  }\n\n  if (UseUnknownFieldSet(descriptor_->file(), options_)) {\n    printer->Print(\n      \"private:\\n\"\n      \"inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\\n\"\n      \"  return _internal_metadata_.arena();\\n\"\n      \"}\\n\"\n      \"inline void* MaybeArenaPtr() const {\\n\"\n      \"  return _internal_metadata_.raw_arena_ptr();\\n\"\n      \"}\\n\"\n      \"public:\\n\"\n      \"\\n\");\n  } else {\n    printer->Print(\n      \"private:\\n\"\n      \"inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\\n\"\n      \"  return _arena_ptr_;\\n\"\n      \"}\\n\"\n      \"inline ::google::protobuf::Arena* MaybeArenaPtr() const {\\n\"\n      \"  return _arena_ptr_;\\n\"\n      \"}\\n\"\n      \"public:\\n\"\n      \"\\n\");\n  }\n\n  if (HasDescriptorMethods(descriptor_->file(), options_)) {\n    printer->Print(\n      \"::google::protobuf::Metadata GetMetadata() const;\\n\"\n      \"\\n\");\n  } else {\n    printer->Print(\n      \"::std::string GetTypeName() const;\\n\"\n      \"\\n\");\n  }\n\n  printer->Print(\n    \"// nested types ----------------------------------------------------\\n\"\n    \"\\n\");\n\n  // Import all nested message classes into this class's scope with typedefs.\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    const Descriptor* nested_type = descriptor_->nested_type(i);\n    if (!IsMapEntryMessage(nested_type)) {\n      printer->Print(\"typedef $nested_full_name$ $nested_name$;\\n\",\n                     \"nested_name\", nested_type->name(),\n                     \"nested_full_name\", ClassName(nested_type, false));\n    }\n  }\n\n  if (descriptor_->nested_type_count() > 0) {\n    printer->Print(\"\\n\");\n  }\n\n  // Import all nested enums and their values into this class's scope with\n  // typedefs and constants.\n  for (int i = 0; i < descriptor_->enum_type_count(); i++) {\n    enum_generators_[i]->GenerateSymbolImports(printer);\n    printer->Print(\"\\n\");\n  }\n\n  printer->Print(\n    \"// accessors -------------------------------------------------------\\n\"\n    \"\\n\");\n\n  // Generate accessor methods for all fields.\n  GenerateFieldAccessorDeclarations(printer);\n\n  // Declare extension identifiers.\n  for (int i = 0; i < descriptor_->extension_count(); i++) {\n    extension_generators_[i]->GenerateDeclaration(printer);\n  }\n\n\n  printer->Print(\n    \"// @@protoc_insertion_point(class_scope:$full_name$)\\n\",\n    \"full_name\", descriptor_->full_name());\n\n  // Generate private members.\n  printer->Outdent();\n  printer->Print(\" private:\\n\");\n  printer->Indent();\n\n\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    if (!descriptor_->field(i)->is_repeated()) {\n      // set_has_***() generated in all proto1/2 code and in oneofs (only) for\n      // messages without true field presence.\n      if (HasFieldPresence(descriptor_->file()) ||\n          descriptor_->field(i)->containing_oneof()) {\n        printer->Print(\n          \"inline void set_has_$name$();\\n\",\n          \"name\", FieldName(descriptor_->field(i)));\n      }\n      // clear_has_***() generated only for non-oneof fields\n      // in proto1/2.\n      if (!descriptor_->field(i)->containing_oneof() &&\n          HasFieldPresence(descriptor_->file())) {\n        printer->Print(\n          \"inline void clear_has_$name$();\\n\",\n          \"name\", FieldName(descriptor_->field(i)));\n      }\n    }\n  }\n  printer->Print(\"\\n\");\n\n  // Generate oneof function declarations\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    printer->Print(\n        \"inline bool has_$oneof_name$() const;\\n\"\n        \"void clear_$oneof_name$();\\n\"\n        \"inline void clear_has_$oneof_name$();\\n\\n\",\n        \"oneof_name\", descriptor_->oneof_decl(i)->name());\n  }\n\n  if (HasGeneratedMethods(descriptor_->file(), options_) &&\n      !descriptor_->options().message_set_wire_format() &&\n      num_required_fields_ > 1) {\n    printer->Print(\n        \"// helper for ByteSize()\\n\"\n        \"int RequiredFieldsByteSizeFallback() const;\\n\\n\");\n  }\n\n  // Prepare decls for _cached_size_ and _has_bits_.  Their position in the\n  // output will be determined later.\n\n  bool need_to_emit_cached_size = true;\n  // TODO(kenton):  Make _cached_size_ an atomic<int> when C++ supports it.\n  const string cached_size_decl = \"mutable int _cached_size_;\\n\";\n\n  // TODO(jieluo) - Optimize _has_bits_ for repeated and oneof fields.\n  size_t sizeof_has_bits = (descriptor_->field_count() + 31) / 32 * 4;\n  if (descriptor_->field_count() == 0) {\n    // Zero-size arrays aren't technically allowed, and MSVC in particular\n    // doesn't like them.  We still need to declare these arrays to make\n    // other code compile.  Since this is an uncommon case, we'll just declare\n    // them with size 1 and waste some space.  Oh well.\n    sizeof_has_bits = 4;\n  }\n  const string has_bits_decl = sizeof_has_bits == 0 ? \"\" :\n      \"::google::protobuf::uint32 _has_bits_[\" + SimpleItoa(sizeof_has_bits / 4) + \"];\\n\";\n\n\n  // To minimize padding, data members are divided into three sections:\n  // (1) members assumed to align to 8 bytes\n  // (2) members corresponding to message fields, re-ordered to optimize\n  //     alignment.\n  // (3) members assumed to align to 4 bytes.\n\n  // Members assumed to align to 8 bytes:\n\n  if (descriptor_->extension_range_count() > 0) {\n    printer->Print(\n      \"::google::protobuf::internal::ExtensionSet _extensions_;\\n\"\n      \"\\n\");\n  }\n\n  if (UseUnknownFieldSet(descriptor_->file(), options_)) {\n    printer->Print(\n      \"::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\\n\");\n  } else {\n    printer->Print(\n      \"::google::protobuf::internal::ArenaStringPtr _unknown_fields_;\\n\"\n      \"::google::protobuf::Arena* _arena_ptr_;\\n\"\n      \"\\n\");\n  }\n\n  if (SupportsArenas(descriptor_)) {\n    printer->Print(\n      \"friend class ::google::protobuf::Arena;\\n\"\n      \"typedef void InternalArenaConstructable_;\\n\"\n      \"typedef void DestructorSkippable_;\\n\");\n  }\n\n  if (HasFieldPresence(descriptor_->file())) {\n    // _has_bits_ is frequently accessed, so to reduce code size and improve\n    // speed, it should be close to the start of the object.  But, try not to\n    // waste space:_has_bits_ by itself always makes sense if its size is a\n    // multiple of 8, but, otherwise, maybe _has_bits_ and cached_size_ together\n    // will work well.\n    printer->Print(has_bits_decl.c_str());\n    if ((sizeof_has_bits % 8) != 0) {\n      printer->Print(cached_size_decl.c_str());\n      need_to_emit_cached_size = false;\n    }\n  } else {\n    // Without field presence, we need another way to disambiguate the default\n    // instance, because the default instance's submessage fields (if any) store\n    // pointers to the default instances of the submessages even when they\n    // aren't present. Alternatives to this approach might be to (i) use a\n    // tagged pointer on all message fields, setting a tag bit for \"not really\n    // present, just default instance\"; or (ii) comparing |this| against the\n    // return value from GeneratedMessageFactory::GetPrototype() in all\n    // has_$field$() calls. However, both of these options are much more\n    // expensive (in code size and CPU overhead) than just checking a field in\n    // the message. Long-term, the best solution would be to rearchitect the\n    // default instance design not to store pointers to submessage default\n    // instances, and have reflection get those some other way; but that change\n    // would have too much impact on proto2.\n    printer->Print(\n      \"bool _is_default_instance_;\\n\");\n  }\n\n  // Field members:\n\n  // List fields which doesn't belong to any oneof\n  vector<const FieldDescriptor*> fields;\n  hash_map<string, int> fieldname_to_chunk;\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    if (!descriptor_->field(i)->containing_oneof()) {\n      const FieldDescriptor* field = descriptor_->field(i);\n      fields.push_back(field);\n      fieldname_to_chunk[FieldName(field)] = i / 8;\n    }\n  }\n  OptimizePadding(&fields);\n  // Emit some private and static members\n  runs_of_fields_ = vector< vector<string> >(1);\n  for (int i = 0; i < fields.size(); ++i) {\n    const FieldDescriptor* field = fields[i];\n    const FieldGenerator& generator = field_generators_.get(field);\n    generator.GenerateStaticMembers(printer);\n    generator.GeneratePrivateMembers(printer);\n    if (CanClearByZeroing(field)) {\n      const string& fieldname = FieldName(field);\n      if (!runs_of_fields_.back().empty() &&\n          (fieldname_to_chunk[runs_of_fields_.back().back()] !=\n           fieldname_to_chunk[fieldname])) {\n        runs_of_fields_.push_back(vector<string>());\n      }\n      runs_of_fields_.back().push_back(fieldname);\n    } else if (!runs_of_fields_.back().empty()) {\n      runs_of_fields_.push_back(vector<string>());\n    }\n  }\n\n  // For each oneof generate a union\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    printer->Print(\n        \"union $camel_oneof_name$Union {\\n\"\n        // explicit empty constructor is needed when union contains\n        // ArenaStringPtr members for string fields.\n        \"  $camel_oneof_name$Union() {}\\n\",\n        \"camel_oneof_name\",\n        UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), true));\n    printer->Indent();\n    for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {\n      field_generators_.get(descriptor_->oneof_decl(i)->\n                            field(j)).GeneratePrivateMembers(printer);\n    }\n    printer->Outdent();\n    printer->Print(\n        \"} $oneof_name$_;\\n\",\n        \"oneof_name\", descriptor_->oneof_decl(i)->name());\n    for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {\n      field_generators_.get(descriptor_->oneof_decl(i)->\n                            field(j)).GenerateStaticMembers(printer);\n    }\n  }\n\n  // Members assumed to align to 4 bytes:\n\n  if (need_to_emit_cached_size) {\n    printer->Print(cached_size_decl.c_str());\n    need_to_emit_cached_size = false;\n  }\n\n  // Generate _oneof_case_.\n  if (descriptor_->oneof_decl_count() > 0) {\n    printer->Print(vars,\n      \"::google::protobuf::uint32 _oneof_case_[$oneof_decl_count$];\\n\"\n      \"\\n\");\n  }\n\n  // Generate _any_metadata_ for the Any type.\n  if (IsAnyMessage(descriptor_)) {\n    printer->Print(vars,\n      \"::google::protobuf::internal::AnyMetadata _any_metadata_;\\n\");\n  }\n\n  // Declare AddDescriptors(), BuildDescriptors(), and ShutdownFile() as\n  // friends so that they can access private static variables like\n  // default_instance_ and reflection_.\n  PrintHandlingOptionalStaticInitializers(\n      descriptor_->file(), options_, printer,\n      // With static initializers.\n      \"friend void $dllexport_decl$ $adddescriptorsname$();\\n\",\n      // Without.\n      \"friend void $dllexport_decl$ $adddescriptorsname$_impl();\\n\",\n      // Vars.\n      \"dllexport_decl\", options_.dllexport_decl, \"adddescriptorsname\",\n      GlobalAddDescriptorsName(descriptor_->file()->name()));\n\n  printer->Print(\n    \"friend void $assigndescriptorsname$();\\n\"\n    \"friend void $shutdownfilename$();\\n\"\n    \"\\n\",\n    \"assigndescriptorsname\",\n      GlobalAssignDescriptorsName(descriptor_->file()->name()),\n    \"shutdownfilename\", GlobalShutdownFileName(descriptor_->file()->name()));\n\n  printer->Print(\n    \"void InitAsDefaultInstance();\\n\"\n    \"static $classname$* default_instance_;\\n\",\n    \"classname\", classname_);\n\n  printer->Outdent();\n  printer->Print(vars, \"};\");\n  GOOGLE_DCHECK(!need_to_emit_cached_size);\n}\n\nvoid MessageGenerator::\nGenerateDependentInlineMethods(io::Printer* printer) {\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    // map entry message doesn't need inline methods. Since map entry message\n    // cannot be a top level class, we just need to avoid calling\n    // GenerateInlineMethods here.\n    if (IsMapEntryMessage(descriptor_->nested_type(i))) continue;\n    nested_generators_[i]->GenerateDependentInlineMethods(printer);\n    printer->Print(kThinSeparator);\n    printer->Print(\"\\n\");\n  }\n\n  GenerateDependentFieldAccessorDefinitions(printer);\n}\n\nvoid MessageGenerator::\nGenerateInlineMethods(io::Printer* printer, bool is_inline) {\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    // map entry message doesn't need inline methods. Since map entry message\n    // cannot be a top level class, we just need to avoid calling\n    // GenerateInlineMethods here.\n    if (IsMapEntryMessage(descriptor_->nested_type(i))) continue;\n    nested_generators_[i]->GenerateInlineMethods(printer, is_inline);\n    printer->Print(kThinSeparator);\n    printer->Print(\"\\n\");\n  }\n\n  GenerateFieldAccessorDefinitions(printer, is_inline);\n\n  // Generate oneof_case() functions.\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    map<string, string> vars;\n    vars[\"class_name\"] = classname_;\n    vars[\"camel_oneof_name\"] = UnderscoresToCamelCase(\n        descriptor_->oneof_decl(i)->name(), true);\n    vars[\"oneof_name\"] = descriptor_->oneof_decl(i)->name();\n    vars[\"oneof_index\"] = SimpleItoa(descriptor_->oneof_decl(i)->index());\n    vars[\"inline\"] = is_inline ? \"inline \" : \"\";\n    printer->Print(\n        vars,\n        \"$inline$\"\n        \"$class_name$::$camel_oneof_name$Case $class_name$::\"\n        \"$oneof_name$_case() const {\\n\"\n        \"  return $class_name$::$camel_oneof_name$Case(\"\n        \"_oneof_case_[$oneof_index$]);\\n\"\n        \"}\\n\");\n  }\n}\n\nvoid MessageGenerator::\nGenerateDescriptorDeclarations(io::Printer* printer) {\n  if (!IsMapEntryMessage(descriptor_)) {\n    printer->Print(\n      \"const ::google::protobuf::Descriptor* $name$_descriptor_ = NULL;\\n\"\n      \"const ::google::protobuf::internal::GeneratedMessageReflection*\\n\"\n      \"  $name$_reflection_ = NULL;\\n\",\n      \"name\", classname_);\n  } else {\n    printer->Print(\n      \"const ::google::protobuf::Descriptor* $name$_descriptor_ = NULL;\\n\",\n      \"name\", classname_);\n  }\n\n  // Generate oneof default instance for reflection usage.\n  if (descriptor_->oneof_decl_count() > 0) {\n    printer->Print(\"struct $name$OneofInstance {\\n\",\n                   \"name\", classname_);\n    for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n      for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {\n        const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);\n        printer->Print(\"  \");\n        if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE ||\n            (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING &&\n             EffectiveStringCType(field) != FieldOptions::STRING)) {\n          printer->Print(\"const \");\n        }\n        field_generators_.get(field).GeneratePrivateMembers(printer);\n      }\n    }\n\n    printer->Print(\"}* $name$_default_oneof_instance_ = NULL;\\n\",\n                   \"name\", classname_);\n  }\n\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    nested_generators_[i]->GenerateDescriptorDeclarations(printer);\n  }\n\n  for (int i = 0; i < descriptor_->enum_type_count(); i++) {\n    printer->Print(\n      \"const ::google::protobuf::EnumDescriptor* $name$_descriptor_ = NULL;\\n\",\n      \"name\", ClassName(descriptor_->enum_type(i), false));\n  }\n}\n\nvoid MessageGenerator::\nGenerateDescriptorInitializer(io::Printer* printer, int index) {\n  // TODO(kenton):  Passing the index to this method is redundant; just use\n  //   descriptor_->index() instead.\n  map<string, string> vars;\n  vars[\"classname\"] = classname_;\n  vars[\"index\"] = SimpleItoa(index);\n\n  // Obtain the descriptor from the parent's descriptor.\n  if (descriptor_->containing_type() == NULL) {\n    printer->Print(vars,\n      \"$classname$_descriptor_ = file->message_type($index$);\\n\");\n  } else {\n    vars[\"parent\"] = ClassName(descriptor_->containing_type(), false);\n    printer->Print(vars,\n      \"$classname$_descriptor_ = \"\n        \"$parent$_descriptor_->nested_type($index$);\\n\");\n  }\n\n  if (IsMapEntryMessage(descriptor_)) return;\n\n  // Generate the offsets.\n  GenerateOffsets(printer);\n\n  const bool pass_pool_and_factory = false;\n  vars[\"fn\"] = pass_pool_and_factory ?\n      \"new ::google::protobuf::internal::GeneratedMessageReflection\" :\n      \"::google::protobuf::internal::GeneratedMessageReflection\"\n      \"::NewGeneratedMessageReflection\";\n  // Construct the reflection object.\n  printer->Print(vars,\n    \"$classname$_reflection_ =\\n\"\n    \"  $fn$(\\n\"\n    \"    $classname$_descriptor_,\\n\"\n    \"    $classname$::default_instance_,\\n\"\n    \"    $classname$_offsets_,\\n\");\n  if (!HasFieldPresence(descriptor_->file())) {\n    // If we don't have field presence, then _has_bits_ does not exist.\n    printer->Print(vars,\n    \"    -1,\\n\");\n  } else {\n    printer->Print(vars,\n    \"    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, _has_bits_[0]),\\n\");\n  }\n\n  // Unknown field offset: either points to the unknown field set if embedded\n  // directly, or indicates that the unknown field set is stored as part of the\n  // internal metadata if not.\n  if (UseUnknownFieldSet(descriptor_->file(), options_)) {\n    printer->Print(vars,\n    \"    -1,\\n\");\n  } else {\n    printer->Print(vars,\n    \"    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(\"\n      \"$classname$, _unknown_fields_),\\n\");\n  }\n\n  if (descriptor_->extension_range_count() > 0) {\n    printer->Print(vars,\n      \"    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(\"\n        \"$classname$, _extensions_),\\n\");\n  } else {\n    // No extensions.\n    printer->Print(vars,\n      \"    -1,\\n\");\n  }\n\n  if (descriptor_->oneof_decl_count() > 0) {\n    printer->Print(vars,\n    \"    $classname$_default_oneof_instance_,\\n\"\n    \"    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(\"\n      \"$classname$, _oneof_case_[0]),\\n\");\n  }\n\n  if (pass_pool_and_factory) {\n    printer->Print(\n        \"    ::google::protobuf::DescriptorPool::generated_pool(),\\n\");\n      printer->Print(vars,\n                     \"    ::google::protobuf::MessageFactory::generated_factory(),\\n\");\n  }\n\n  printer->Print(vars,\n    \"    sizeof($classname$),\\n\");\n\n  // Arena offset: either an offset to the metadata struct that contains the\n  // arena pointer and unknown field set (in a space-efficient way) if we use\n  // that implementation strategy, or an offset directly to the arena pointer if\n  // not (because e.g. we don't have an unknown field set).\n  if (UseUnknownFieldSet(descriptor_->file(), options_)) {\n    printer->Print(vars,\n    \"    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(\"\n    \"$classname$, _internal_metadata_),\\n\");\n  } else {\n    printer->Print(vars,\n    \"    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(\"\n    \"$classname$, _arena_),\\n\");\n  }\n\n  // is_default_instance_ offset.\n  if (HasFieldPresence(descriptor_->file())) {\n    printer->Print(vars,\n    \"    -1);\\n\");\n  } else {\n    printer->Print(vars,\n    \"    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(\"\n    \"$classname$, _is_default_instance_));\\n\");\n  }\n\n  // Handle nested types.\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    nested_generators_[i]->GenerateDescriptorInitializer(printer, i);\n  }\n\n  for (int i = 0; i < descriptor_->enum_type_count(); i++) {\n    enum_generators_[i]->GenerateDescriptorInitializer(printer, i);\n  }\n}\n\nvoid MessageGenerator::\nGenerateTypeRegistrations(io::Printer* printer) {\n  // Register this message type with the message factory.\n  if (!IsMapEntryMessage(descriptor_)) {\n    printer->Print(\n      \"::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\\n\"\n      \"    $classname$_descriptor_, &$classname$::default_instance());\\n\",\n      \"classname\", classname_);\n  }\n  else {\n    map<string, string> vars;\n    CollectMapInfo(descriptor_, &vars);\n    vars[\"classname\"] = classname_;\n\n    const FieldDescriptor* val = descriptor_->FindFieldByName(\"value\");\n    if (descriptor_->file()->syntax() == FileDescriptor::SYNTAX_PROTO2 &&\n        val->type() == FieldDescriptor::TYPE_ENUM) {\n      const EnumValueDescriptor* default_value = val->default_value_enum();\n      vars[\"default_enum_value\"] = Int32ToString(default_value->number());\n    } else {\n      vars[\"default_enum_value\"] = \"0\";\n    }\n\n    printer->Print(vars,\n      \"::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\\n\"\n      \"      $classname$_descriptor_,\\n\"\n      \"      ::google::protobuf::internal::MapEntry<\\n\"\n      \"          $key$,\\n\"\n      \"          $val$,\\n\"\n      \"          $key_wire_type$,\\n\"\n      \"          $val_wire_type$,\\n\"\n      \"          $default_enum_value$>::CreateDefaultInstance(\\n\"\n      \"              $classname$_descriptor_));\\n\");\n  }\n\n  // Handle nested types.\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    nested_generators_[i]->GenerateTypeRegistrations(printer);\n  }\n}\n\nvoid MessageGenerator::\nGenerateDefaultInstanceAllocator(io::Printer* printer) {\n  // Construct the default instances of all fields, as they will be used\n  // when creating the default instance of the entire message.\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    field_generators_.get(descriptor_->field(i))\n                     .GenerateDefaultInstanceAllocator(printer);\n  }\n\n  if (IsMapEntryMessage(descriptor_)) return;\n\n  // Construct the default instance.  We can't call InitAsDefaultInstance() yet\n  // because we need to make sure all default instances that this one might\n  // depend on are constructed first.\n  printer->Print(\n    \"$classname$::default_instance_ = new $classname$();\\n\",\n    \"classname\", classname_);\n\n  if ((descriptor_->oneof_decl_count() > 0) &&\n      HasDescriptorMethods(descriptor_->file(), options_)) {\n    printer->Print(\n    \"$classname$_default_oneof_instance_ = new $classname$OneofInstance();\\n\",\n    \"classname\", classname_);\n  }\n\n  // Handle nested types.\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    nested_generators_[i]->GenerateDefaultInstanceAllocator(printer);\n  }\n\n}\n\nvoid MessageGenerator::\nGenerateDefaultInstanceInitializer(io::Printer* printer) {\n  printer->Print(\n    \"$classname$::default_instance_->InitAsDefaultInstance();\\n\",\n    \"classname\", classname_);\n\n  // Register extensions.\n  for (int i = 0; i < descriptor_->extension_count(); i++) {\n    extension_generators_[i]->GenerateRegistration(printer);\n  }\n\n  // Handle nested types.\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    // map entry message doesn't need to initialize default instance manually.\n    // Since map entry message cannot be a top level class, we just need to\n    // avoid calling DefaultInstanceInitializer here.\n    if (IsMapEntryMessage(descriptor_->nested_type(i))) continue;\n    nested_generators_[i]->GenerateDefaultInstanceInitializer(printer);\n  }\n}\n\nvoid MessageGenerator::\nGenerateShutdownCode(io::Printer* printer) {\n  printer->Print(\n    \"delete $classname$::default_instance_;\\n\",\n    \"classname\", classname_);\n\n  if (HasDescriptorMethods(descriptor_->file(), options_)) {\n    if (descriptor_->oneof_decl_count() > 0) {\n      printer->Print(\n        \"delete $classname$_default_oneof_instance_;\\n\",\n        \"classname\", classname_);\n    }\n    printer->Print(\n      \"delete $classname$_reflection_;\\n\",\n      \"classname\", classname_);\n  }\n\n  // Handle default instances of fields.\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    field_generators_.get(descriptor_->field(i))\n                     .GenerateShutdownCode(printer);\n  }\n\n  // Handle nested types.\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    if (IsMapEntryMessage(descriptor_->nested_type(i))) continue;\n    nested_generators_[i]->GenerateShutdownCode(printer);\n  }\n}\n\nvoid MessageGenerator::\nGenerateClassMethods(io::Printer* printer) {\n  // mutable_unknown_fields wrapper function for LazyStringOutputStream\n  // callback.\n  if (PreserveUnknownFields(descriptor_) &&\n      !UseUnknownFieldSet(descriptor_->file(), options_)) {\n    printer->Print(\n        \"static ::std::string* MutableUnknownFieldsFor$classname$(\\n\"\n        \"    $classname$* ptr) {\\n\"\n        \"  return ptr->mutable_unknown_fields();\\n\"\n        \"}\\n\"\n        \"\\n\",\n        \"classname\", classname_);\n  }\n  if (IsAnyMessage(descriptor_)) {\n    printer->Print(\n      \"void $classname$::PackFrom(const ::google::protobuf::Message& message) {\\n\"\n      \"  _any_metadata_.PackFrom(message);\\n\"\n      \"}\\n\"\n      \"\\n\"\n      \"void $classname$::PackFrom(const ::google::protobuf::Message& message,\\n\"\n      \"                           const ::std::string& type_url_prefix) {\\n\"\n      \"  _any_metadata_.PackFrom(message, type_url_prefix);\\n\"\n      \"}\\n\"\n      \"\\n\"\n      \"bool $classname$::UnpackTo(::google::protobuf::Message* message) const {\\n\"\n      \"  return _any_metadata_.UnpackTo(message);\\n\"\n      \"}\\n\"\n      \"\\n\",\n      \"classname\", classname_);\n  }\n\n  for (int i = 0; i < descriptor_->enum_type_count(); i++) {\n    enum_generators_[i]->GenerateMethods(printer);\n  }\n\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    // map entry message doesn't need class methods. Since map entry message\n    // cannot be a top level class, we just need to avoid calling\n    // GenerateClassMethods here.\n    if (IsMapEntryMessage(descriptor_->nested_type(i))) continue;\n    nested_generators_[i]->GenerateClassMethods(printer);\n    printer->Print(\"\\n\");\n    printer->Print(kThinSeparator);\n    printer->Print(\"\\n\");\n  }\n\n  // Generate non-inline field definitions.\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    field_generators_.get(descriptor_->field(i))\n                     .GenerateNonInlineAccessorDefinitions(printer);\n  }\n\n  // Generate field number constants.\n  printer->Print(\"#if !defined(_MSC_VER) || _MSC_VER >= 1900\\n\");\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor *field = descriptor_->field(i);\n    printer->Print(\n      \"const int $classname$::$constant_name$;\\n\",\n      \"classname\", ClassName(FieldScope(field), false),\n      \"constant_name\", FieldConstantName(field));\n  }\n  printer->Print(\n    \"#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\\n\"\n    \"\\n\");\n\n  // Define extension identifiers.\n  for (int i = 0; i < descriptor_->extension_count(); i++) {\n    extension_generators_[i]->GenerateDefinition(printer);\n  }\n\n  GenerateStructors(printer);\n  printer->Print(\"\\n\");\n\n  if (descriptor_->oneof_decl_count() > 0) {\n    GenerateOneofClear(printer);\n    printer->Print(\"\\n\");\n  }\n\n  if (HasGeneratedMethods(descriptor_->file(), options_)) {\n    GenerateClear(printer);\n    printer->Print(\"\\n\");\n\n    GenerateMergeFromCodedStream(printer);\n    printer->Print(\"\\n\");\n\n    GenerateSerializeWithCachedSizes(printer);\n    printer->Print(\"\\n\");\n\n    if (HasFastArraySerialization(descriptor_->file(), options_)) {\n      GenerateSerializeWithCachedSizesToArray(printer);\n      printer->Print(\"\\n\");\n    }\n\n    GenerateByteSize(printer);\n    printer->Print(\"\\n\");\n\n    GenerateMergeFrom(printer);\n    printer->Print(\"\\n\");\n\n    GenerateCopyFrom(printer);\n    printer->Print(\"\\n\");\n\n    GenerateIsInitialized(printer);\n    printer->Print(\"\\n\");\n  }\n\n  GenerateSwap(printer);\n  printer->Print(\"\\n\");\n\n  if (HasDescriptorMethods(descriptor_->file(), options_)) {\n    printer->Print(\n      \"::google::protobuf::Metadata $classname$::GetMetadata() const {\\n\"\n      \"  protobuf_AssignDescriptorsOnce();\\n\"\n      \"  ::google::protobuf::Metadata metadata;\\n\"\n      \"  metadata.descriptor = $classname$_descriptor_;\\n\"\n      \"  metadata.reflection = $classname$_reflection_;\\n\"\n      \"  return metadata;\\n\"\n      \"}\\n\"\n      \"\\n\",\n      \"classname\", classname_);\n  } else {\n    printer->Print(\n      \"::std::string $classname$::GetTypeName() const {\\n\"\n      \"  return \\\"$type_name$\\\";\\n\"\n      \"}\\n\"\n      \"\\n\",\n      \"classname\", classname_,\n      \"type_name\", descriptor_->full_name());\n  }\n\n}\n\nvoid MessageGenerator::\nGenerateOffsets(io::Printer* printer) {\n  printer->Print(\"static const int $classname$_offsets_[$field_count$] = {\\n\",\n                 \"classname\", classname_, \"field_count\",\n                 SimpleItoa(std::max(1, descriptor_->field_count() +\n                                            descriptor_->oneof_decl_count())));\n  printer->Indent();\n\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n    if (field->containing_oneof()) {\n      printer->Print(\n          \"PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(\"\n          \"$classname$_default_oneof_instance_, $name$_),\\n\",\n          \"classname\", classname_,\n          \"name\", FieldName(field));\n    } else {\n      printer->Print(\n          \"GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, \"\n                                                 \"$name$_),\\n\",\n          \"classname\", classname_,\n          \"name\", FieldName(field));\n    }\n  }\n\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    const OneofDescriptor* oneof = descriptor_->oneof_decl(i);\n    printer->Print(\n      \"GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET($classname$, $name$_),\\n\",\n      \"classname\", classname_,\n      \"name\", oneof->name());\n  }\n\n  printer->Outdent();\n  printer->Print(\"};\\n\");\n}\n\nvoid MessageGenerator::\nGenerateSharedConstructorCode(io::Printer* printer) {\n  printer->Print(\n    \"void $classname$::SharedCtor() {\\n\",\n    \"classname\", classname_);\n  printer->Indent();\n\n  if (!HasFieldPresence(descriptor_->file())) {\n    printer->Print(\n      \"  _is_default_instance_ = false;\\n\");\n  }\n\n  printer->Print(StrCat(\n      uses_string_ ? \"::google::protobuf::internal::GetEmptyString();\\n\" : \"\",\n      \"_cached_size_ = 0;\\n\").c_str());\n\n  if (PreserveUnknownFields(descriptor_) &&\n      !UseUnknownFieldSet(descriptor_->file(), options_)) {\n    printer->Print(\n        \"_unknown_fields_.UnsafeSetDefault(\\n\"\n        \"    &::google::protobuf::internal::GetEmptyStringAlreadyInited());\\n\");\n  }\n\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    if (!descriptor_->field(i)->containing_oneof()) {\n      field_generators_.get(descriptor_->field(i))\n          .GenerateConstructorCode(printer);\n    }\n  }\n\n  if (HasFieldPresence(descriptor_->file())) {\n    printer->Print(\n      \"::memset(_has_bits_, 0, sizeof(_has_bits_));\\n\");\n  }\n\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    printer->Print(\n        \"clear_has_$oneof_name$();\\n\",\n        \"oneof_name\", descriptor_->oneof_decl(i)->name());\n  }\n\n  printer->Outdent();\n  printer->Print(\"}\\n\\n\");\n}\n\nvoid MessageGenerator::\nGenerateSharedDestructorCode(io::Printer* printer) {\n  printer->Print(\n    \"void $classname$::SharedDtor() {\\n\",\n    \"classname\", classname_);\n  printer->Indent();\n  if (SupportsArenas(descriptor_)) {\n    // Do nothing when the message is allocated in an arena.\n    printer->Print(\n      \"if (GetArenaNoVirtual() != NULL) {\\n\"\n      \"  return;\\n\"\n      \"}\\n\"\n      \"\\n\");\n  }\n\n  // Write the desctructor for _unknown_fields_ in lite runtime.\n  if (PreserveUnknownFields(descriptor_) &&\n      !UseUnknownFieldSet(descriptor_->file(), options_)) {\n    if (SupportsArenas(descriptor_)) {\n      printer->Print(\n          \"_unknown_fields_.Destroy(\\n\"\n          \"    &::google::protobuf::internal::GetEmptyStringAlreadyInited(),\\n\"\n          \"    GetArenaNoVirtual());\\n\");\n    } else {\n      printer->Print(\n          \"_unknown_fields_.DestroyNoArena(\\n\"\n          \"    &::google::protobuf::internal::GetEmptyStringAlreadyInited());\\n\");\n    }\n  }\n\n  // Write the destructors for each field except oneof members.\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    if (!descriptor_->field(i)->containing_oneof()) {\n      field_generators_.get(descriptor_->field(i))\n                       .GenerateDestructorCode(printer);\n    }\n  }\n\n  // Generate code to destruct oneofs. Clearing should do the work.\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    printer->Print(\n        \"if (has_$oneof_name$()) {\\n\"\n        \"  clear_$oneof_name$();\\n\"\n        \"}\\n\",\n        \"oneof_name\", descriptor_->oneof_decl(i)->name());\n  }\n\n  PrintHandlingOptionalStaticInitializers(\n      descriptor_->file(), options_, printer,\n      // With static initializers.\n      \"if (this != default_instance_) {\\n\",\n      // Without.\n      \"if (this != &default_instance()) {\\n\");\n\n  // We need to delete all embedded messages.\n  // TODO(kenton):  If we make unset messages point at default instances\n  //   instead of NULL, then it would make sense to move this code into\n  //   MessageFieldGenerator::GenerateDestructorCode().\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n\n    if (!field->is_repeated() &&\n        field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n      // Skip oneof members\n      if (!field->containing_oneof()) {\n        printer->Print(\n            \"  delete $name$_;\\n\",\n            \"name\", FieldName(field));\n      }\n    }\n  }\n\n  printer->Outdent();\n  printer->Print(\n    \"  }\\n\"\n    \"}\\n\"\n    \"\\n\");\n}\n\nvoid MessageGenerator::\nGenerateArenaDestructorCode(io::Printer* printer) {\n  // Generate the ArenaDtor() method. Track whether any fields actually produced\n  // code that needs to be called.\n  printer->Print(\n      \"void $classname$::ArenaDtor(void* object) {\\n\",\n      \"classname\", classname_);\n  printer->Indent();\n\n  // This code is placed inside a static method, rather than an ordinary one,\n  // since that simplifies Arena's destructor list (ordinary function pointers\n  // rather than member function pointers). _this is the object being\n  // destructed.\n  printer->Print(\n      \"$classname$* _this = reinterpret_cast< $classname$* >(object);\\n\"\n      // avoid an \"unused variable\" warning in case no fields have dtor code.\n      \"(void)_this;\\n\",\n      \"classname\", classname_);\n\n  bool need_registration = false;\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    if (field_generators_.get(descriptor_->field(i))\n                         .GenerateArenaDestructorCode(printer)) {\n      need_registration = true;\n    }\n  }\n  printer->Outdent();\n  printer->Print(\n      \"}\\n\");\n\n  if (need_registration) {\n    printer->Print(\n        \"inline void $classname$::RegisterArenaDtor(::google::protobuf::Arena* arena) {\\n\"\n        \"  if (arena != NULL) {\\n\"\n        \"    arena->OwnCustomDestructor(this, &$classname$::ArenaDtor);\\n\"\n        \"  }\\n\"\n        \"}\\n\",\n        \"classname\", classname_);\n  } else {\n    printer->Print(\n        \"void $classname$::RegisterArenaDtor(::google::protobuf::Arena* arena) {\\n\"\n        \"}\\n\",\n        \"classname\", classname_);\n  }\n}\n\nvoid MessageGenerator::\nGenerateStructors(io::Printer* printer) {\n  string superclass;\n  if (use_dependent_base_) {\n    superclass =\n        DependentBaseClassTemplateName(descriptor_) + \"<\" + classname_ + \">\";\n  } else {\n    superclass = SuperClassName(descriptor_, options_);\n  }\n  string initializer_with_arena = superclass + \"()\";\n\n  if (descriptor_->extension_range_count() > 0) {\n    initializer_with_arena += \",\\n  _extensions_(arena)\";\n  }\n\n  if (UseUnknownFieldSet(descriptor_->file(), options_)) {\n    initializer_with_arena += \",\\n  _internal_metadata_(arena)\";\n  } else {\n    initializer_with_arena += \",\\n  _arena_ptr_(arena)\";\n  }\n\n  // Initialize member variables with arena constructor.\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    bool has_arena_constructor = descriptor_->field(i)->is_repeated();\n    if (has_arena_constructor) {\n      initializer_with_arena += string(\",\\n  \") +\n          FieldName(descriptor_->field(i)) + string(\"_(arena)\");\n    }\n  }\n\n  if (IsAnyMessage(descriptor_)) {\n    initializer_with_arena += \",\\n  _any_metadata_(&type_url, &value_)\";\n  }\n\n  string initializer_null;\n  initializer_null = (UseUnknownFieldSet(descriptor_->file(), options_) ?\n    \", _internal_metadata_(NULL)\" : \", _arena_ptr_(NULL)\");\n  if (IsAnyMessage(descriptor_)) {\n    initializer_null += \", _any_metadata_(&type_url_, &value_)\";\n  }\n\n  printer->Print(\n      \"$classname$::$classname$()\\n\"\n      \"  : $superclass$()$initializer$ {\\n\"\n      \"  SharedCtor();\\n\"\n      \"  // @@protoc_insertion_point(constructor:$full_name$)\\n\"\n      \"}\\n\",\n      \"classname\", classname_,\n      \"superclass\", superclass,\n      \"full_name\", descriptor_->full_name(),\n      \"initializer\", initializer_null);\n\n  if (SupportsArenas(descriptor_)) {\n    printer->Print(\n        \"\\n\"\n        \"$classname$::$classname$(::google::protobuf::Arena* arena)\\n\"\n        \"  : $initializer$ {\\n\"\n        \"  SharedCtor();\\n\"\n        \"  RegisterArenaDtor(arena);\\n\"\n        \"  // @@protoc_insertion_point(arena_constructor:$full_name$)\\n\"\n        \"}\\n\",\n        \"initializer\", initializer_with_arena,\n        \"classname\", classname_,\n        \"superclass\", superclass,\n        \"full_name\", descriptor_->full_name());\n  }\n\n  printer->Print(\n    \"\\n\"\n    \"void $classname$::InitAsDefaultInstance() {\\n\",\n    \"classname\", classname_);\n\n  if (!HasFieldPresence(descriptor_->file())) {\n    printer->Print(\n      \"  _is_default_instance_ = true;\\n\");\n  }\n\n  // The default instance needs all of its embedded message pointers\n  // cross-linked to other default instances.  We can't do this initialization\n  // in the constructor because some other default instances may not have been\n  // constructed yet at that time.\n  // TODO(kenton):  Maybe all message fields (even for non-default messages)\n  //   should be initialized to point at default instances rather than NULL?\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n\n    if (!field->is_repeated() &&\n        field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&\n        (field->containing_oneof() == NULL ||\n         HasDescriptorMethods(descriptor_->file(), options_))) {\n      string name;\n      if (field->containing_oneof()) {\n        name = classname_ + \"_default_oneof_instance_->\";\n      }\n      name += FieldName(field);\n      PrintHandlingOptionalStaticInitializers(\n          descriptor_->file(), options_, printer,\n          // With static initializers.\n          \"  $name$_ = const_cast< $type$*>(&$type$::default_instance());\\n\",\n          // Without.\n          \"  $name$_ = const_cast< $type$*>(\\n\"\n          \"      $type$::internal_default_instance());\\n\",\n          // Vars.\n          \"name\", name, \"type\", FieldMessageTypeName(field));\n    } else if (field->containing_oneof() &&\n               HasDescriptorMethods(descriptor_->file(), options_)) {\n      field_generators_.get(descriptor_->field(i))\n          .GenerateConstructorCode(printer);\n    }\n  }\n  printer->Print(\n    \"}\\n\"\n    \"\\n\");\n\n  // Generate the copy constructor.\n  printer->Print(\n    \"$classname$::$classname$(const $classname$& from)\\n\"\n    \"  : $superclass$()\",\n    \"classname\", classname_,\n    \"superclass\", superclass,\n    \"full_name\", descriptor_->full_name());\n  if (UseUnknownFieldSet(descriptor_->file(), options_)) {\n    printer->Print(\n        \",\\n    _internal_metadata_(NULL)\");\n  } else if (!UseUnknownFieldSet(descriptor_->file(), options_)) {\n    printer->Print(\",\\n    _arena_ptr_(NULL)\");\n  }\n  if (IsAnyMessage(descriptor_)) {\n    printer->Print(\",\\n    _any_metadata_(&type_url_, &value_)\");\n  }\n  printer->Print(\" {\\n\");\n  printer->Print(\n    \"  SharedCtor();\\n\"\n    \"  MergeFrom(from);\\n\"\n    \"  // @@protoc_insertion_point(copy_constructor:$full_name$)\\n\"\n    \"}\\n\"\n    \"\\n\",\n    \"classname\", classname_,\n    \"superclass\", superclass,\n    \"full_name\", descriptor_->full_name());\n\n  // Generate the shared constructor code.\n  GenerateSharedConstructorCode(printer);\n\n  // Generate the destructor.\n  printer->Print(\n    \"$classname$::~$classname$() {\\n\"\n    \"  // @@protoc_insertion_point(destructor:$full_name$)\\n\"\n    \"  SharedDtor();\\n\"\n    \"}\\n\"\n    \"\\n\",\n    \"classname\", classname_,\n    \"full_name\", descriptor_->full_name());\n\n  // Generate the shared destructor code.\n  GenerateSharedDestructorCode(printer);\n\n  // Generate the arena-specific destructor code.\n  if (SupportsArenas(descriptor_)) {\n    GenerateArenaDestructorCode(printer);\n  }\n\n  // Generate SetCachedSize.\n  printer->Print(\n    \"void $classname$::SetCachedSize(int size) const {\\n\"\n    \"  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\\n\"\n    \"  _cached_size_ = size;\\n\"\n    \"  GOOGLE_SAFE_CONCURRENT_WRITES_END();\\n\"\n    \"}\\n\",\n    \"classname\", classname_);\n\n  // Only generate this member if it's not disabled.\n  if (HasDescriptorMethods(descriptor_->file(), options_) &&\n      !descriptor_->options().no_standard_descriptor_accessor()) {\n    printer->Print(\n      \"const ::google::protobuf::Descriptor* $classname$::descriptor() {\\n\"\n      \"  protobuf_AssignDescriptorsOnce();\\n\"\n      \"  return $classname$_descriptor_;\\n\"\n      \"}\\n\"\n      \"\\n\",\n      \"classname\", classname_,\n      \"adddescriptorsname\",\n      GlobalAddDescriptorsName(descriptor_->file()->name()));\n  }\n\n  printer->Print(\n    \"const $classname$& $classname$::default_instance() {\\n\",\n    \"classname\", classname_);\n\n  PrintHandlingOptionalStaticInitializers(\n      descriptor_->file(), options_, printer,\n      // With static initializers.\n      \"  if (default_instance_ == NULL) $adddescriptorsname$();\\n\",\n      // Without.\n      \"  $adddescriptorsname$();\\n\",\n      // Vars.\n      \"adddescriptorsname\",\n      GlobalAddDescriptorsName(descriptor_->file()->name()));\n\n  printer->Print(\n    \"  return *default_instance_;\\n\"\n    \"}\\n\"\n    \"\\n\"\n    \"$classname$* $classname$::default_instance_ = NULL;\\n\"\n    \"\\n\",\n    \"classname\", classname_);\n\n  if (SupportsArenas(descriptor_)) {\n    printer->Print(\n      \"$classname$* $classname$::New(::google::protobuf::Arena* arena) const {\\n\"\n      \"  return ::google::protobuf::Arena::CreateMessage<$classname$>(arena);\\n\"\n      \"}\\n\",\n      \"classname\", classname_);\n  } else {\n    printer->Print(\n      \"$classname$* $classname$::New(::google::protobuf::Arena* arena) const {\\n\"\n      \"  $classname$* n = new $classname$;\\n\"\n      \"  if (arena != NULL) {\\n\"\n      \"    arena->Own(n);\\n\"\n      \"  }\\n\"\n      \"  return n;\\n\"\n      \"}\\n\",\n      \"classname\", classname_);\n  }\n\n}\n\n// Return the number of bits set in n, a non-negative integer.\nstatic int popcnt(uint32 n) {\n  int result = 0;\n  while (n != 0) {\n    result += (n & 1);\n    n = n / 2;\n  }\n  return result;\n}\n\nvoid MessageGenerator::\nGenerateClear(io::Printer* printer) {\n  printer->Print(\n      \"void $classname$::Clear() {\\n\"\n      \"// @@protoc_insertion_point(message_clear_start:$full_name$)\\n\",\n      \"classname\", classname_, \"full_name\", descriptor_->full_name());\n  printer->Indent();\n\n  // Step 1: Extensions\n  if (descriptor_->extension_range_count() > 0) {\n    printer->Print(\"_extensions_.Clear();\\n\");\n  }\n\n  // Step 2: Everything but extensions, repeateds, unions.\n  // These are handled in chunks of 8.  The first chunk is\n  // the non-extensions-non-repeateds-non-unions in\n  //  descriptor_->field(0), descriptor_->field(1), ... descriptor_->field(7),\n  // and the second chunk is the same for\n  //  descriptor_->field(8), descriptor_->field(9), ... descriptor_->field(15),\n  // etc.\n  set<int> step2_indices;\n  hash_map<string, int> fieldname_to_chunk;\n  hash_map<int, string> memsets_for_chunk;\n  hash_map<int, int> memset_field_count_for_chunk;\n  hash_set<string> handled;  // fields that appear anywhere in memsets_for_chunk\n  hash_map<int, uint32> fields_mask_for_chunk;\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n    if (!field->is_repeated() && !field->containing_oneof()) {\n      step2_indices.insert(i);\n      int chunk = i / 8;\n      fieldname_to_chunk[FieldName(field)] = chunk;\n      fields_mask_for_chunk[chunk] |= static_cast<uint32>(1) << (i % 32);\n    }\n  }\n\n  // Step 2a: Greedily seek runs of fields that can be cleared by memset-to-0.\n  // The generated code uses two macros to help it clear runs of fields:\n  // ZR_HELPER_(f1) - ZR_HELPER_(f0) computes the difference, in bytes, of the\n  // positions of two fields in the Message.\n  // ZR_ zeroes a non-empty range of fields via memset.\n  const char* macros =\n      \"#if defined(__clang__)\\n\"\n      \"#define ZR_HELPER_(f) \\\\\\n\"\n      \"  _Pragma(\\\"clang diagnostic push\\\") \\\\\\n\"\n      \"  _Pragma(\\\"clang diagnostic ignored \\\\\\\"-Winvalid-offsetof\\\\\\\"\\\") \\\\\\n\"\n      \"  __builtin_offsetof($classname$, f) \\\\\\n\"\n      \"  _Pragma(\\\"clang diagnostic pop\\\")\\n\"\n      \"#else\\n\"\n      \"#define ZR_HELPER_(f) reinterpret_cast<char*>(\\\\\\n\"\n      \"  &reinterpret_cast<$classname$*>(16)->f)\\n\"\n      \"#endif\\n\\n\"\n      \"#define ZR_(first, last) do {\\\\\\n\"\n      \"  ::memset(&first, 0,\\\\\\n\"\n      \"           ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\\\\\\n\"\n      \"} while (0)\\n\\n\";\n  for (int i = 0; i < runs_of_fields_.size(); i++) {\n    const vector<string>& run = runs_of_fields_[i];\n    if (run.size() < 2) continue;\n    const string& first_field_name = run[0];\n    const string& last_field_name = run.back();\n    int chunk = fieldname_to_chunk[run[0]];\n    memsets_for_chunk[chunk].append(\n      \"ZR_(\" + first_field_name + \"_, \" + last_field_name + \"_);\\n\");\n    for (int j = 0; j < run.size(); j++) {\n      GOOGLE_DCHECK_EQ(chunk, fieldname_to_chunk[run[j]]);\n      handled.insert(run[j]);\n    }\n    memset_field_count_for_chunk[chunk] += run.size();\n  }\n  const bool macros_are_needed = handled.size() > 0;\n  if (macros_are_needed) {\n    printer->Outdent();\n    printer->Print(macros,\n                   \"classname\", classname_);\n    printer->Indent();\n  }\n  // Step 2b: Finish step 2, ignoring fields handled in step 2a.\n  int last_index = -1;\n  bool chunk_block_in_progress = false;\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    if (step2_indices.count(i) == 0) continue;\n    const FieldDescriptor* field = descriptor_->field(i);\n    const string fieldname = FieldName(field);\n    if (i / 8 != last_index / 8 || last_index < 0) {\n      // End previous chunk, if there was one.\n      if (chunk_block_in_progress) {\n        printer->Outdent();\n        printer->Print(\"}\\n\");\n        chunk_block_in_progress = false;\n      }\n      // Start chunk.\n      const string& memsets = memsets_for_chunk[i / 8];\n      uint32 mask = fields_mask_for_chunk[i / 8];\n      int count = popcnt(mask);\n      GOOGLE_DCHECK_GE(count, 1);\n      if (count == 1 ||\n          (count <= 4 && count == memset_field_count_for_chunk[i / 8])) {\n        // No \"if\" here because the chunk is trivial.\n      } else {\n        if (HasFieldPresence(descriptor_->file())) {\n          printer->Print(\n            \"if (_has_bits_[$index$ / 32] & $mask$u) {\\n\",\n            \"index\", SimpleItoa(i / 8 * 8),\n            \"mask\", SimpleItoa(mask));\n          printer->Indent();\n          chunk_block_in_progress = true;\n        }\n      }\n      printer->Print(memsets.c_str());\n    }\n    last_index = i;\n    if (handled.count(fieldname) > 0) continue;\n\n    // It's faster to just overwrite primitive types, but we should\n    // only clear strings and messages if they were set.\n    // TODO(kenton):  Let the CppFieldGenerator decide this somehow.\n    bool should_check_bit =\n      field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE ||\n      field->cpp_type() == FieldDescriptor::CPPTYPE_STRING;\n\n    bool have_enclosing_if = false;\n    if (should_check_bit &&\n        // If no field presence, then always clear strings/messages as well.\n        HasFieldPresence(descriptor_->file())) {\n      printer->Print(\"if (has_$name$()) {\\n\", \"name\", fieldname);\n      printer->Indent();\n      have_enclosing_if = true;\n    }\n\n    if (use_dependent_base_ && IsFieldDependent(field)) {\n      printer->Print(\"clear_$name$();\\n\", \"name\", fieldname);\n    } else {\n      field_generators_.get(field).GenerateClearingCode(printer);\n    }\n\n    if (have_enclosing_if) {\n      printer->Outdent();\n      printer->Print(\"}\\n\");\n    }\n  }\n\n  if (chunk_block_in_progress) {\n    printer->Outdent();\n    printer->Print(\"}\\n\");\n  }\n  if (macros_are_needed) {\n    printer->Outdent();\n    printer->Print(\"\\n#undef ZR_HELPER_\\n#undef ZR_\\n\\n\");\n    printer->Indent();\n  }\n\n  // Step 3: Repeated fields don't use _has_bits_; emit code to clear them here.\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n\n    if (field->is_repeated()) {\n      if (use_dependent_base_ && IsFieldDependent(field)) {\n        printer->Print(\"clear_$name$();\\n\", \"name\", FieldName(field));\n      } else {\n        field_generators_.get(field).GenerateClearingCode(printer);\n      }\n    }\n  }\n\n  // Step 4: Unions.\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    printer->Print(\n        \"clear_$oneof_name$();\\n\",\n        \"oneof_name\", descriptor_->oneof_decl(i)->name());\n  }\n\n  if (HasFieldPresence(descriptor_->file())) {\n    // Step 5: Everything else.\n    printer->Print(\n      \"::memset(_has_bits_, 0, sizeof(_has_bits_));\\n\");\n  }\n\n  if (PreserveUnknownFields(descriptor_)) {\n    if (UseUnknownFieldSet(descriptor_->file(), options_)) {\n      printer->Print(\n        \"if (_internal_metadata_.have_unknown_fields()) {\\n\"\n        \"  mutable_unknown_fields()->Clear();\\n\"\n        \"}\\n\");\n    } else {\n      if (SupportsArenas(descriptor_)) {\n        printer->Print(\n          \"_unknown_fields_.ClearToEmpty(\\n\"\n          \"    &::google::protobuf::internal::GetEmptyStringAlreadyInited(),\\n\"\n          \"    GetArenaNoVirtual());\\n\");\n      } else {\n        printer->Print(\n          \"_unknown_fields_.ClearToEmptyNoArena(\\n\"\n          \"    &::google::protobuf::internal::GetEmptyStringAlreadyInited());\\n\");\n      }\n    }\n  }\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid MessageGenerator::\nGenerateOneofClear(io::Printer* printer) {\n  // Generated function clears the active field and union case (e.g. foo_case_).\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    map<string, string> oneof_vars;\n    oneof_vars[\"classname\"] = classname_;\n    oneof_vars[\"oneofname\"] = descriptor_->oneof_decl(i)->name();\n    oneof_vars[\"full_name\"] = descriptor_->full_name();\n    string message_class;\n\n    printer->Print(oneof_vars,\n                   \"void $classname$::clear_$oneofname$() {\\n\"\n                   \"// @@protoc_insertion_point(one_of_clear_start:\"\n                   \"$full_name$)\\n\");\n    printer->Indent();\n    printer->Print(oneof_vars,\n        \"switch($oneofname$_case()) {\\n\");\n    printer->Indent();\n    for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {\n      const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);\n      printer->Print(\n          \"case k$field_name$: {\\n\",\n          \"field_name\", UnderscoresToCamelCase(field->name(), true));\n      printer->Indent();\n      // We clear only allocated objects in oneofs\n      if (!IsStringOrMessage(field)) {\n        printer->Print(\n            \"// No need to clear\\n\");\n      } else {\n        field_generators_.get(field).GenerateClearingCode(printer);\n      }\n      printer->Print(\n          \"break;\\n\");\n      printer->Outdent();\n      printer->Print(\n          \"}\\n\");\n    }\n    printer->Print(\n        \"case $cap_oneof_name$_NOT_SET: {\\n\"\n        \"  break;\\n\"\n        \"}\\n\",\n        \"cap_oneof_name\",\n        ToUpper(descriptor_->oneof_decl(i)->name()));\n    printer->Outdent();\n    printer->Print(\n        \"}\\n\"\n        \"_oneof_case_[$oneof_index$] = $cap_oneof_name$_NOT_SET;\\n\",\n        \"oneof_index\", SimpleItoa(i),\n        \"cap_oneof_name\",\n        ToUpper(descriptor_->oneof_decl(i)->name()));\n    printer->Outdent();\n    printer->Print(\n        \"}\\n\"\n        \"\\n\");\n  }\n}\n\nvoid MessageGenerator::\nGenerateSwap(io::Printer* printer) {\n  if (SupportsArenas(descriptor_)) {\n    // Generate the Swap member function. This is a lightweight wrapper around\n    // UnsafeArenaSwap() / MergeFrom() with temporaries, depending on the memory\n    // ownership situation: swapping across arenas or between an arena and a\n    // heap requires copying.\n    printer->Print(\n        \"void $classname$::Swap($classname$* other) {\\n\"\n        \"  if (other == this) return;\\n\"\n        \"  if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {\\n\"\n        \"    InternalSwap(other);\\n\"\n        \"  } else {\\n\"\n        \"    $classname$ temp;\\n\"\n        \"    temp.MergeFrom(*this);\\n\"\n        \"    CopyFrom(*other);\\n\"\n        \"    other->CopyFrom(temp);\\n\"\n        \"  }\\n\"\n        \"}\\n\"\n        \"void $classname$::UnsafeArenaSwap($classname$* other) {\\n\"\n        \"  if (other == this) return;\\n\"\n        \"  GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());\\n\"\n        \"  InternalSwap(other);\\n\"\n        \"}\\n\",\n        \"classname\", classname_);\n  } else {\n    printer->Print(\n        \"void $classname$::Swap($classname$* other) {\\n\"\n        \"  if (other == this) return;\\n\"\n        \"  InternalSwap(other);\\n\"\n        \"}\\n\",\n        \"classname\", classname_);\n  }\n\n  // Generate the UnsafeArenaSwap member function.\n  printer->Print(\"void $classname$::InternalSwap($classname$* other) {\\n\",\n                 \"classname\", classname_);\n  printer->Indent();\n\n  if (HasGeneratedMethods(descriptor_->file(), options_)) {\n    for (int i = 0; i < descriptor_->field_count(); i++) {\n      const FieldDescriptor* field = descriptor_->field(i);\n      field_generators_.get(field).GenerateSwappingCode(printer);\n    }\n\n    for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n      printer->Print(\n        \"std::swap($oneof_name$_, other->$oneof_name$_);\\n\"\n        \"std::swap(_oneof_case_[$i$], other->_oneof_case_[$i$]);\\n\",\n        \"oneof_name\", descriptor_->oneof_decl(i)->name(),\n        \"i\", SimpleItoa(i));\n    }\n\n    if (HasFieldPresence(descriptor_->file())) {\n      for (int i = 0; i < (descriptor_->field_count() + 31) / 32; ++i) {\n        printer->Print(\"std::swap(_has_bits_[$i$], other->_has_bits_[$i$]);\\n\",\n                       \"i\", SimpleItoa(i));\n      }\n    }\n\n    // Ignore PreserveUnknownFields here - always swap internal_metadata as it\n    // may contain more than just unknown fields.\n    if (UseUnknownFieldSet(descriptor_->file(), options_)) {\n      printer->Print(\n          \"_internal_metadata_.Swap(&other->_internal_metadata_);\\n\");\n    } else {\n      printer->Print(\"_unknown_fields_.Swap(&other->_unknown_fields_);\\n\");\n    }\n\n    printer->Print(\"std::swap(_cached_size_, other->_cached_size_);\\n\");\n    if (descriptor_->extension_range_count() > 0) {\n      printer->Print(\"_extensions_.Swap(&other->_extensions_);\\n\");\n    }\n  } else {\n    printer->Print(\"GetReflection()->Swap(this, other);\");\n  }\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid MessageGenerator::\nGenerateMergeFrom(io::Printer* printer) {\n  if (HasDescriptorMethods(descriptor_->file(), options_)) {\n    // Generate the generalized MergeFrom (aka that which takes in the Message\n    // base class as a parameter).\n    printer->Print(\n        \"void $classname$::MergeFrom(const ::google::protobuf::Message& from) {\\n\"\n        \"// @@protoc_insertion_point(generalized_merge_from_start:\"\n        \"$full_name$)\\n\"\n        \"  if (GOOGLE_PREDICT_FALSE(&from == this)) {\\n\"\n        \"    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\\n\"\n        \"  }\\n\",\n        \"classname\", classname_, \"full_name\", descriptor_->full_name());\n    printer->Indent();\n\n    // Cast the message to the proper type. If we find that the message is\n    // *not* of the proper type, we can still call Merge via the reflection\n    // system, as the GOOGLE_CHECK above ensured that we have the same descriptor\n    // for each message.\n    printer->Print(\n      \"const $classname$* source = \\n\"\n      \"    ::google::protobuf::internal::DynamicCastToGenerated<const $classname$>(\\n\"\n      \"        &from);\\n\"\n      \"if (source == NULL) {\\n\"\n      \"// @@protoc_insertion_point(generalized_merge_from_cast_fail:\"\n      \"$full_name$)\\n\"\n      \"  ::google::protobuf::internal::ReflectionOps::Merge(from, this);\\n\"\n      \"} else {\\n\"\n      \"// @@protoc_insertion_point(generalized_merge_from_cast_success:\"\n      \"$full_name$)\\n\"\n      \"  MergeFrom(*source);\\n\"\n      \"}\\n\",\n      \"classname\", classname_, \"full_name\", descriptor_->full_name());\n\n    printer->Outdent();\n    printer->Print(\"}\\n\\n\");\n  } else {\n    // Generate CheckTypeAndMergeFrom().\n    printer->Print(\n      \"void $classname$::CheckTypeAndMergeFrom(\\n\"\n      \"    const ::google::protobuf::MessageLite& from) {\\n\"\n      \"  MergeFrom(*::google::protobuf::down_cast<const $classname$*>(&from));\\n\"\n      \"}\\n\"\n      \"\\n\",\n      \"classname\", classname_);\n  }\n\n  // Generate the class-specific MergeFrom, which avoids the GOOGLE_CHECK and cast.\n  printer->Print(\n      \"void $classname$::MergeFrom(const $classname$& from) {\\n\"\n      \"// @@protoc_insertion_point(class_specific_merge_from_start:\"\n      \"$full_name$)\\n\"\n      \"  if (GOOGLE_PREDICT_FALSE(&from == this)) {\\n\"\n      \"    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\\n\"\n      \"  }\\n\",\n      \"classname\", classname_, \"full_name\", descriptor_->full_name());\n  printer->Indent();\n\n  // Merge Repeated fields. These fields do not require a\n  // check as we can simply iterate over them.\n  for (int i = 0; i < descriptor_->field_count(); ++i) {\n    const FieldDescriptor* field = descriptor_->field(i);\n\n    if (field->is_repeated()) {\n      field_generators_.get(field).GenerateMergingCode(printer);\n    }\n  }\n\n  // Merge oneof fields. Oneof field requires oneof case check.\n  for (int i = 0; i < descriptor_->oneof_decl_count(); ++i) {\n    printer->Print(\n        \"switch (from.$oneofname$_case()) {\\n\",\n        \"oneofname\", descriptor_->oneof_decl(i)->name());\n    printer->Indent();\n    for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {\n      const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);\n      printer->Print(\n          \"case k$field_name$: {\\n\",\n          \"field_name\", UnderscoresToCamelCase(field->name(), true));\n      printer->Indent();\n      field_generators_.get(field).GenerateMergingCode(printer);\n      printer->Print(\n          \"break;\\n\");\n      printer->Outdent();\n      printer->Print(\n          \"}\\n\");\n    }\n    printer->Print(\n        \"case $cap_oneof_name$_NOT_SET: {\\n\"\n        \"  break;\\n\"\n        \"}\\n\",\n        \"cap_oneof_name\",\n        ToUpper(descriptor_->oneof_decl(i)->name()));\n    printer->Outdent();\n    printer->Print(\n        \"}\\n\");\n  }\n\n  // Merge Optional and Required fields (after a _has_bit check).\n  int last_index = -1;\n\n  for (int i = 0; i < descriptor_->field_count(); ++i) {\n    const FieldDescriptor* field = descriptor_->field(i);\n\n    if (!field->is_repeated() && !field->containing_oneof()) {\n      if (HasFieldPresence(descriptor_->file())) {\n        // See above in GenerateClear for an explanation of this.\n        if (i / 8 != last_index / 8 || last_index < 0) {\n          if (last_index >= 0) {\n            printer->Outdent();\n            printer->Print(\"}\\n\");\n          }\n          printer->Print(\n            \"if (from._has_bits_[$index$ / 32] & \"\n            \"(0xffu << ($index$ % 32))) {\\n\",\n            \"index\", SimpleItoa(field->index()));\n          printer->Indent();\n        }\n      }\n\n      last_index = i;\n\n      bool have_enclosing_if = false;\n      if (HasFieldPresence(descriptor_->file())) {\n        printer->Print(\n          \"if (from.has_$name$()) {\\n\",\n          \"name\", FieldName(field));\n        printer->Indent();\n        have_enclosing_if = true;\n      } else {\n        // Merge semantics without true field presence: primitive fields are\n        // merged only if non-zero (numeric) or non-empty (string).\n        have_enclosing_if = EmitFieldNonDefaultCondition(\n            printer, \"from.\", field);\n      }\n\n      field_generators_.get(field).GenerateMergingCode(printer);\n\n      if (have_enclosing_if) {\n        printer->Outdent();\n        printer->Print(\"}\\n\");\n      }\n    }\n  }\n\n  if (HasFieldPresence(descriptor_->file()) &&\n      last_index >= 0) {\n    printer->Outdent();\n    printer->Print(\"}\\n\");\n  }\n\n  if (descriptor_->extension_range_count() > 0) {\n    printer->Print(\"_extensions_.MergeFrom(from._extensions_);\\n\");\n  }\n\n  if (PreserveUnknownFields(descriptor_)) {\n    if (UseUnknownFieldSet(descriptor_->file(), options_)) {\n      printer->Print(\n        \"if (from._internal_metadata_.have_unknown_fields()) {\\n\"\n        \"  mutable_unknown_fields()->MergeFrom(from.unknown_fields());\\n\"\n        \"}\\n\");\n    } else {\n      printer->Print(\n        \"if (!from.unknown_fields().empty()) {\\n\"\n        \"  mutable_unknown_fields()->append(from.unknown_fields());\\n\"\n        \"}\\n\");\n    }\n  }\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid MessageGenerator::\nGenerateCopyFrom(io::Printer* printer) {\n  if (HasDescriptorMethods(descriptor_->file(), options_)) {\n    // Generate the generalized CopyFrom (aka that which takes in the Message\n    // base class as a parameter).\n    printer->Print(\n        \"void $classname$::CopyFrom(const ::google::protobuf::Message& from) {\\n\"\n        \"// @@protoc_insertion_point(generalized_copy_from_start:\"\n        \"$full_name$)\\n\",\n        \"classname\", classname_, \"full_name\", descriptor_->full_name());\n    printer->Indent();\n\n    printer->Print(\n      \"if (&from == this) return;\\n\"\n      \"Clear();\\n\"\n      \"MergeFrom(from);\\n\");\n\n    printer->Outdent();\n    printer->Print(\"}\\n\\n\");\n  }\n\n  // Generate the class-specific CopyFrom.\n  printer->Print(\n      \"void $classname$::CopyFrom(const $classname$& from) {\\n\"\n      \"// @@protoc_insertion_point(class_specific_copy_from_start:\"\n      \"$full_name$)\\n\",\n      \"classname\", classname_, \"full_name\", descriptor_->full_name());\n  printer->Indent();\n\n  printer->Print(\n    \"if (&from == this) return;\\n\"\n    \"Clear();\\n\"\n    \"MergeFrom(from);\\n\");\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid MessageGenerator::\nGenerateMergeFromCodedStream(io::Printer* printer) {\n  if (descriptor_->options().message_set_wire_format()) {\n    // Special-case MessageSet.\n    printer->Print(\n      \"bool $classname$::MergePartialFromCodedStream(\\n\"\n      \"    ::google::protobuf::io::CodedInputStream* input) {\\n\",\n      \"classname\", classname_);\n\n    PrintHandlingOptionalStaticInitializers(\n        descriptor_->file(), options_, printer,\n        // With static initializers.\n        \"  return _extensions_.ParseMessageSet(input, default_instance_,\\n\"\n        \"                                      mutable_unknown_fields());\\n\",\n        // Without.\n        \"  return _extensions_.ParseMessageSet(input, &default_instance(),\\n\"\n        \"                                      mutable_unknown_fields());\\n\",\n        // Vars.\n        \"classname\", classname_);\n\n    printer->Print(\n      \"}\\n\");\n    return;\n  }\n\n  printer->Print(\n    \"bool $classname$::MergePartialFromCodedStream(\\n\"\n    \"    ::google::protobuf::io::CodedInputStream* input) {\\n\"\n    \"#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\\n\"\n    \"  ::google::protobuf::uint32 tag;\\n\",\n    \"classname\", classname_);\n\n  if (PreserveUnknownFields(descriptor_) &&\n      !UseUnknownFieldSet(descriptor_->file(), options_)) {\n    // Use LazyStringOutputString to avoid initializing unknown fields string\n    // unless it is actually needed. For the same reason, disable eager refresh\n    // on the CodedOutputStream.\n    printer->Print(\n      \"  ::google::protobuf::io::LazyStringOutputStream unknown_fields_string(\\n\"\n      \"      ::google::protobuf::internal::NewPermanentCallback(\\n\"\n      \"          &MutableUnknownFieldsFor$classname$, this));\\n\"\n      \"  ::google::protobuf::io::CodedOutputStream unknown_fields_stream(\\n\"\n      \"      &unknown_fields_string, false);\\n\",\n      \"classname\", classname_);\n  }\n\n  printer->Print(\n    \"  // @@protoc_insertion_point(parse_start:$full_name$)\\n\",\n    \"full_name\", descriptor_->full_name());\n\n  printer->Indent();\n  printer->Print(\"for (;;) {\\n\");\n  printer->Indent();\n\n  google::protobuf::scoped_array<const FieldDescriptor * > ordered_fields(\n      SortFieldsByNumber(descriptor_));\n  uint32 maxtag = descriptor_->field_count() == 0 ? 0 :\n      WireFormat::MakeTag(ordered_fields[descriptor_->field_count() - 1]);\n  const int kCutoff0 = 127;               // fits in 1-byte varint\n  const int kCutoff1 = (127 << 7) + 127;  // fits in 2-byte varint\n  printer->Print(\"::std::pair< ::google::protobuf::uint32, bool> p = \"\n                 \"input->ReadTagWithCutoff($max$);\\n\"\n                 \"tag = p.first;\\n\"\n                 \"if (!p.second) goto handle_unusual;\\n\",\n                 \"max\", SimpleItoa(maxtag <= kCutoff0 ? kCutoff0 :\n                                   (maxtag <= kCutoff1 ? kCutoff1 :\n                                    maxtag)));\n  if (descriptor_->field_count() > 0) {\n    // We don't even want to print the switch() if we have no fields because\n    // MSVC dislikes switch() statements that contain only a default value.\n\n    // Note:  If we just switched on the tag rather than the field number, we\n    // could avoid the need for the if() to check the wire type at the beginning\n    // of each case.  However, this is actually a bit slower in practice as it\n    // creates a jump table that is 8x larger and sparser, and meanwhile the\n    // if()s are highly predictable.\n    printer->Print(\"switch (::google::protobuf::internal::WireFormatLite::\"\n                   \"GetTagFieldNumber(tag)) {\\n\");\n\n    printer->Indent();\n\n    // Find repeated messages and groups now, to simplify what follows.\n    hash_set<int> fields_with_parse_loop;\n    for (int i = 0; i < descriptor_->field_count(); i++) {\n      const FieldDescriptor* field = ordered_fields[i];\n      if (field->is_repeated() &&\n          (field->type() == FieldDescriptor::TYPE_MESSAGE ||\n           field->type() == FieldDescriptor::TYPE_GROUP)) {\n        fields_with_parse_loop.insert(i);\n      }\n    }\n\n    // need_label is true if we generated \"goto parse_$name$\" while handling the\n    // previous field.\n    bool need_label = false;\n    for (int i = 0; i < descriptor_->field_count(); i++) {\n      const FieldDescriptor* field = ordered_fields[i];\n      const bool loops = fields_with_parse_loop.count(i) > 0;\n      const bool next_field_loops = fields_with_parse_loop.count(i + 1) > 0;\n\n      PrintFieldComment(printer, field);\n\n      printer->Print(\n        \"case $number$: {\\n\",\n        \"number\", SimpleItoa(field->number()));\n      printer->Indent();\n      const FieldGenerator& field_generator = field_generators_.get(field);\n\n      // Emit code to parse the common, expected case.\n      printer->Print(\"if (tag == $commontag$) {\\n\",\n                     \"commontag\", SimpleItoa(WireFormat::MakeTag(field)));\n\n      if (need_label ||\n          (field->is_repeated() && !field->is_packed() && !loops)) {\n        printer->Print(\n            \" parse_$name$:\\n\",\n            \"name\", field->name());\n      }\n      if (loops) {\n        printer->Print(\n          \"  DO_(input->IncrementRecursionDepth());\\n\"\n          \" parse_loop_$name$:\\n\",\n          \"name\", field->name());\n      }\n\n      printer->Indent();\n      if (field->is_packed()) {\n        field_generator.GenerateMergeFromCodedStreamWithPacking(printer);\n      } else {\n        field_generator.GenerateMergeFromCodedStream(printer);\n      }\n      printer->Outdent();\n\n      // Emit code to parse unexpectedly packed or unpacked values.\n      if (field->is_packed()) {\n        internal::WireFormatLite::WireType wiretype =\n            WireFormat::WireTypeForFieldType(field->type());\n        printer->Print(\"} else if (tag == $uncommontag$) {\\n\",\n                       \"uncommontag\", SimpleItoa(\n                           internal::WireFormatLite::MakeTag(\n                               field->number(), wiretype)));\n        printer->Indent();\n        field_generator.GenerateMergeFromCodedStream(printer);\n        printer->Outdent();\n      } else if (field->is_packable() && !field->is_packed()) {\n        internal::WireFormatLite::WireType wiretype =\n            internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED;\n        printer->Print(\"} else if (tag == $uncommontag$) {\\n\",\n                       \"uncommontag\", SimpleItoa(\n                           internal::WireFormatLite::MakeTag(\n                               field->number(), wiretype)));\n        printer->Indent();\n        field_generator.GenerateMergeFromCodedStreamWithPacking(printer);\n        printer->Outdent();\n      }\n\n      printer->Print(\n        \"} else {\\n\"\n        \"  goto handle_unusual;\\n\"\n        \"}\\n\");\n\n      // switch() is slow since it can't be predicted well.  Insert some if()s\n      // here that attempt to predict the next tag.\n      // For non-packed repeated fields, expect the same tag again.\n      if (loops) {\n        printer->Print(\n          \"if (input->ExpectTag($tag$)) goto parse_loop_$name$;\\n\",\n          \"tag\", SimpleItoa(WireFormat::MakeTag(field)),\n          \"name\", field->name());\n      } else if (field->is_repeated() && !field->is_packed()) {\n        printer->Print(\n          \"if (input->ExpectTag($tag$)) goto parse_$name$;\\n\",\n          \"tag\", SimpleItoa(WireFormat::MakeTag(field)),\n          \"name\", field->name());\n      }\n\n      // Have we emitted \"if (input->ExpectTag($next_tag$)) ...\" yet?\n      bool emitted_goto_next_tag = false;\n\n      // For repeated messages/groups, we need to decrement recursion depth,\n      // unless the next tag is also for a repeated message/group.\n      if (loops) {\n        if (next_field_loops) {\n          const FieldDescriptor* next_field = ordered_fields[i + 1];\n          printer->Print(\n            \"if (input->ExpectTag($next_tag$)) goto parse_loop_$next_name$;\\n\",\n            \"next_tag\", SimpleItoa(WireFormat::MakeTag(next_field)),\n            \"next_name\", next_field->name());\n          emitted_goto_next_tag = true;\n        }\n        printer->Print(\n          \"input->UnsafeDecrementRecursionDepth();\\n\");\n      }\n\n      // If there are more fields, expect the next one.\n      need_label = false;\n      if (!emitted_goto_next_tag) {\n        if (i + 1 == descriptor_->field_count()) {\n          // Expect EOF.\n          // TODO(kenton):  Expect group end-tag?\n          printer->Print(\n            \"if (input->ExpectAtEnd()) goto success;\\n\");\n        } else {\n          const FieldDescriptor* next_field = ordered_fields[i + 1];\n          printer->Print(\n            \"if (input->ExpectTag($next_tag$)) goto parse_$next_name$;\\n\",\n            \"next_tag\", SimpleItoa(WireFormat::MakeTag(next_field)),\n            \"next_name\", next_field->name());\n          need_label = true;\n        }\n      }\n\n      printer->Print(\n        \"break;\\n\");\n\n      printer->Outdent();\n      printer->Print(\"}\\n\\n\");\n    }\n\n    printer->Print(\"default: {\\n\");\n    printer->Indent();\n  }\n\n  printer->Outdent();\n  printer->Print(\"handle_unusual:\\n\");\n  printer->Indent();\n  // If tag is 0 or an end-group tag then this must be the end of the message.\n  printer->Print(\n    \"if (tag == 0 ||\\n\"\n    \"    ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\\n\"\n    \"    ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\\n\"\n    \"  goto success;\\n\"\n    \"}\\n\");\n\n  // Handle extension ranges.\n  if (descriptor_->extension_range_count() > 0) {\n    printer->Print(\n      \"if (\");\n    for (int i = 0; i < descriptor_->extension_range_count(); i++) {\n      const Descriptor::ExtensionRange* range =\n        descriptor_->extension_range(i);\n      if (i > 0) printer->Print(\" ||\\n    \");\n\n      uint32 start_tag = WireFormatLite::MakeTag(\n        range->start, static_cast<WireFormatLite::WireType>(0));\n      uint32 end_tag = WireFormatLite::MakeTag(\n        range->end, static_cast<WireFormatLite::WireType>(0));\n\n      if (range->end > FieldDescriptor::kMaxNumber) {\n        printer->Print(\n          \"($start$u <= tag)\",\n          \"start\", SimpleItoa(start_tag));\n      } else {\n        printer->Print(\n          \"($start$u <= tag && tag < $end$u)\",\n          \"start\", SimpleItoa(start_tag),\n          \"end\", SimpleItoa(end_tag));\n      }\n    }\n    printer->Print(\") {\\n\");\n    if (PreserveUnknownFields(descriptor_)) {\n      if (UseUnknownFieldSet(descriptor_->file(), options_)) {\n        PrintHandlingOptionalStaticInitializers(\n            descriptor_->file(), options_, printer,\n            // With static initializers.\n            \"  DO_(_extensions_.ParseField(tag, input, default_instance_,\\n\"\n            \"                              mutable_unknown_fields()));\\n\",\n            // Without.\n            \"  DO_(_extensions_.ParseField(tag, input, &default_instance(),\\n\"\n            \"                              mutable_unknown_fields()));\\n\");\n      } else {\n        PrintHandlingOptionalStaticInitializers(\n            descriptor_->file(), options_, printer,\n            // With static initializers.\n            \"  DO_(_extensions_.ParseField(tag, input, default_instance_,\\n\"\n            \"                              &unknown_fields_stream));\\n\",\n            // Without.\n            \"  DO_(_extensions_.ParseField(tag, input, &default_instance(),\\n\"\n            \"                              &unknown_fields_stream));\\n\");\n      }\n    } else {\n      PrintHandlingOptionalStaticInitializers(\n          descriptor_->file(), options_, printer,\n          // With static initializers.\n          \"  DO_(_extensions_.ParseField(tag, input, default_instance_);\\n\",\n          // Without.\n          \"  DO_(_extensions_.ParseField(tag, input, &default_instance());\\n\");\n    }\n    printer->Print(\n      \"  continue;\\n\"\n      \"}\\n\");\n  }\n\n  // We really don't recognize this tag.  Skip it.\n  if (PreserveUnknownFields(descriptor_)) {\n    if (UseUnknownFieldSet(descriptor_->file(), options_)) {\n      printer->Print(\n        \"DO_(::google::protobuf::internal::WireFormat::SkipField(\\n\"\n        \"      input, tag, mutable_unknown_fields()));\\n\");\n    } else {\n      printer->Print(\n        \"DO_(::google::protobuf::internal::WireFormatLite::SkipField(\\n\"\n        \"    input, tag, &unknown_fields_stream));\\n\");\n    }\n  } else {\n    printer->Print(\n      \"DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\\n\");\n  }\n\n  if (descriptor_->field_count() > 0) {\n    printer->Print(\"break;\\n\");\n    printer->Outdent();\n    printer->Print(\"}\\n\");    // default:\n    printer->Outdent();\n    printer->Print(\"}\\n\");    // switch\n  }\n\n  printer->Outdent();\n  printer->Outdent();\n  printer->Print(\n    \"  }\\n\"                   // for (;;)\n    \"success:\\n\"\n    \"  // @@protoc_insertion_point(parse_success:$full_name$)\\n\"\n    \"  return true;\\n\"\n    \"failure:\\n\"\n    \"  // @@protoc_insertion_point(parse_failure:$full_name$)\\n\"\n    \"  return false;\\n\"\n    \"#undef DO_\\n\"\n    \"}\\n\", \"full_name\", descriptor_->full_name());\n}\n\nvoid MessageGenerator::GenerateSerializeOneField(\n    io::Printer* printer, const FieldDescriptor* field, bool to_array) {\n  PrintFieldComment(printer, field);\n\n  bool have_enclosing_if = false;\n  if (!field->is_repeated() && HasFieldPresence(descriptor_->file())) {\n    printer->Print(\n      \"if (has_$name$()) {\\n\",\n      \"name\", FieldName(field));\n    printer->Indent();\n    have_enclosing_if = true;\n  } else if (!HasFieldPresence(descriptor_->file())) {\n    have_enclosing_if = EmitFieldNonDefaultCondition(printer, \"this->\", field);\n  }\n\n  if (to_array) {\n    field_generators_.get(field).GenerateSerializeWithCachedSizesToArray(\n        printer);\n  } else {\n    field_generators_.get(field).GenerateSerializeWithCachedSizes(printer);\n  }\n\n  if (have_enclosing_if) {\n    printer->Outdent();\n    printer->Print(\"}\\n\");\n  }\n  printer->Print(\"\\n\");\n}\n\nvoid MessageGenerator::GenerateSerializeOneExtensionRange(\n    io::Printer* printer, const Descriptor::ExtensionRange* range,\n    bool to_array) {\n  map<string, string> vars;\n  vars[\"start\"] = SimpleItoa(range->start);\n  vars[\"end\"] = SimpleItoa(range->end);\n  printer->Print(vars,\n    \"// Extension range [$start$, $end$)\\n\");\n  if (to_array) {\n    printer->Print(vars,\n      \"target = _extensions_.InternalSerializeWithCachedSizesToArray(\\n\"\n      \"    $start$, $end$, false, target);\\n\\n\");\n  } else {\n    printer->Print(vars,\n      \"_extensions_.SerializeWithCachedSizes(\\n\"\n      \"    $start$, $end$, output);\\n\\n\");\n  }\n}\n\nvoid MessageGenerator::\nGenerateSerializeWithCachedSizes(io::Printer* printer) {\n  if (descriptor_->options().message_set_wire_format()) {\n    // Special-case MessageSet.\n    printer->Print(\n      \"void $classname$::SerializeWithCachedSizes(\\n\"\n      \"    ::google::protobuf::io::CodedOutputStream* output) const {\\n\"\n      \"  _extensions_.SerializeMessageSetWithCachedSizes(output);\\n\",\n      \"classname\", classname_);\n    GOOGLE_CHECK(UseUnknownFieldSet(descriptor_->file(), options_));\n    printer->Print(\n      \"  ::google::protobuf::internal::WireFormat::SerializeUnknownMessageSetItems(\\n\"\n      \"      unknown_fields(), output);\\n\");\n    printer->Print(\n      \"}\\n\");\n    return;\n  }\n\n  printer->Print(\n    \"void $classname$::SerializeWithCachedSizes(\\n\"\n    \"    ::google::protobuf::io::CodedOutputStream* output) const {\\n\",\n    \"classname\", classname_);\n  printer->Indent();\n\n  printer->Print(\n    \"// @@protoc_insertion_point(serialize_start:$full_name$)\\n\",\n    \"full_name\", descriptor_->full_name());\n\n  GenerateSerializeWithCachedSizesBody(printer, false);\n\n  printer->Print(\n    \"// @@protoc_insertion_point(serialize_end:$full_name$)\\n\",\n    \"full_name\", descriptor_->full_name());\n\n  printer->Outdent();\n  printer->Print(\n    \"}\\n\");\n}\n\nvoid MessageGenerator::\nGenerateSerializeWithCachedSizesToArray(io::Printer* printer) {\n  if (descriptor_->options().message_set_wire_format()) {\n    // Special-case MessageSet.\n    printer->Print(\n      \"::google::protobuf::uint8* $classname$::InternalSerializeWithCachedSizesToArray(\\n\"\n      \"    bool deterministic, ::google::protobuf::uint8* target) const {\\n\"\n      \"  target = _extensions_.\"\n      \"InternalSerializeMessageSetWithCachedSizesToArray(\\n\"\n      \"               deterministic, target);\\n\",\n      \"classname\", classname_);\n    GOOGLE_CHECK(UseUnknownFieldSet(descriptor_->file(), options_));\n    printer->Print(\n      \"  target = ::google::protobuf::internal::WireFormat::\\n\"\n      \"             SerializeUnknownMessageSetItemsToArray(\\n\"\n      \"               unknown_fields(), target);\\n\");\n    printer->Print(\n      \"  return target;\\n\"\n      \"}\\n\");\n    return;\n  }\n\n  printer->Print(\n    \"::google::protobuf::uint8* $classname$::InternalSerializeWithCachedSizesToArray(\\n\"\n    \"    bool deterministic, ::google::protobuf::uint8* target) const {\\n\",\n    \"classname\", classname_);\n  printer->Indent();\n\n  printer->Print(\n    \"// @@protoc_insertion_point(serialize_to_array_start:$full_name$)\\n\",\n    \"full_name\", descriptor_->full_name());\n\n  GenerateSerializeWithCachedSizesBody(printer, true);\n\n  printer->Print(\n    \"// @@protoc_insertion_point(serialize_to_array_end:$full_name$)\\n\",\n    \"full_name\", descriptor_->full_name());\n\n  printer->Outdent();\n  printer->Print(\n    \"  return target;\\n\"\n    \"}\\n\");\n}\n\nvoid MessageGenerator::\nGenerateSerializeWithCachedSizesBody(io::Printer* printer, bool to_array) {\n  google::protobuf::scoped_array<const FieldDescriptor * > ordered_fields(\n      SortFieldsByNumber(descriptor_));\n\n  vector<const Descriptor::ExtensionRange*> sorted_extensions;\n  for (int i = 0; i < descriptor_->extension_range_count(); ++i) {\n    sorted_extensions.push_back(descriptor_->extension_range(i));\n  }\n  std::sort(sorted_extensions.begin(), sorted_extensions.end(),\n            ExtensionRangeSorter());\n\n  // Merge the fields and the extension ranges, both sorted by field number.\n  int i, j;\n  for (i = 0, j = 0;\n       i < descriptor_->field_count() || j < sorted_extensions.size();\n       ) {\n    if (i == descriptor_->field_count()) {\n      GenerateSerializeOneExtensionRange(printer,\n                                         sorted_extensions[j++],\n                                         to_array);\n    } else if (j == sorted_extensions.size()) {\n      GenerateSerializeOneField(printer, ordered_fields[i++], to_array);\n    } else if (ordered_fields[i]->number() < sorted_extensions[j]->start) {\n      GenerateSerializeOneField(printer, ordered_fields[i++], to_array);\n    } else {\n      GenerateSerializeOneExtensionRange(printer,\n                                         sorted_extensions[j++],\n                                         to_array);\n    }\n  }\n\n  if (PreserveUnknownFields(descriptor_)) {\n    if (UseUnknownFieldSet(descriptor_->file(), options_)) {\n      printer->Print(\"if (_internal_metadata_.have_unknown_fields()) {\\n\");\n      printer->Indent();\n      if (to_array) {\n        printer->Print(\n          \"target = \"\n              \"::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\\n\"\n          \"    unknown_fields(), target);\\n\");\n      } else {\n        printer->Print(\n          \"::google::protobuf::internal::WireFormat::SerializeUnknownFields(\\n\"\n          \"    unknown_fields(), output);\\n\");\n      }\n      printer->Outdent();\n\n      printer->Print(\n        \"}\\n\");\n    } else {\n      printer->Print(\n        \"output->WriteRaw(unknown_fields().data(),\\n\"\n        \"                 static_cast<int>(unknown_fields().size()));\\n\");\n    }\n  }\n}\n\nstatic vector<uint32> RequiredFieldsBitMask(const Descriptor* desc) {\n  vector<uint32> result;\n  uint32 mask = 0;\n  for (int i = 0; i < desc->field_count(); i++) {\n    if (i > 0 && i % 32 == 0) {\n      result.push_back(mask);\n      mask = 0;\n    }\n    if (desc->field(i)->is_required()) {\n      mask |= (1 << (i & 31));\n    }\n  }\n  if (mask != 0) {\n    result.push_back(mask);\n  }\n  return result;\n}\n\n// Create an expression that evaluates to\n//  \"for all i, (_has_bits_[i] & masks[i]) == masks[i]\"\n// masks is allowed to be shorter than _has_bits_, but at least one element of\n// masks must be non-zero.\nstatic string ConditionalToCheckBitmasks(const vector<uint32>& masks) {\n  vector<string> parts;\n  for (int i = 0; i < masks.size(); i++) {\n    if (masks[i] == 0) continue;\n    string m = StrCat(\"0x\", strings::Hex(masks[i], strings::ZERO_PAD_8));\n    // Each xor evaluates to 0 if the expected bits are present.\n    parts.push_back(StrCat(\"((_has_bits_[\", i, \"] & \", m, \") ^ \", m, \")\"));\n  }\n  GOOGLE_CHECK(!parts.empty());\n  // If we have multiple parts, each expected to be 0, then bitwise-or them.\n  string result = parts.size() == 1 ? parts[0] :\n      StrCat(\"(\", Join(parts, \"\\n       | \"), \")\");\n  return result + \" == 0\";\n}\n\nvoid MessageGenerator::\nGenerateByteSize(io::Printer* printer) {\n  if (descriptor_->options().message_set_wire_format()) {\n    // Special-case MessageSet.\n    printer->Print(\n        \"int $classname$::ByteSize() const {\\n\"\n        \"// @@protoc_insertion_point(message_set_byte_size_start:$full_name$)\\n\"\n        \"  int total_size = _extensions_.MessageSetByteSize();\\n\",\n        \"classname\", classname_, \"full_name\", descriptor_->full_name());\n    GOOGLE_CHECK(UseUnknownFieldSet(descriptor_->file(), options_));\n    printer->Print(\n      \"if (_internal_metadata_.have_unknown_fields()) {\\n\"\n      \"  total_size += ::google::protobuf::internal::WireFormat::\\n\"\n      \"      ComputeUnknownMessageSetItemsSize(unknown_fields());\\n\"\n      \"}\\n\");\n    printer->Print(\n      \"  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\\n\"\n      \"  _cached_size_ = total_size;\\n\"\n      \"  GOOGLE_SAFE_CONCURRENT_WRITES_END();\\n\"\n      \"  return total_size;\\n\"\n      \"}\\n\");\n    return;\n  }\n\n  if (num_required_fields_ > 1 && HasFieldPresence(descriptor_->file())) {\n    // Emit a function (rarely used, we hope) that handles the required fields\n    // by checking for each one individually.\n    printer->Print(\n        \"int $classname$::RequiredFieldsByteSizeFallback() const {\\n\"\n        \"// @@protoc_insertion_point(required_fields_byte_size_fallback_start:\"\n        \"$full_name$)\\n\",\n        \"classname\", classname_, \"full_name\", descriptor_->full_name());\n    printer->Indent();\n    printer->Print(\"int total_size = 0;\\n\");\n    for (int i = 0; i < descriptor_->field_count(); i++) {\n      const FieldDescriptor* field = descriptor_->field(i);\n      if (field->is_required()) {\n        printer->Print(\"\\n\"\n                       \"if (has_$name$()) {\\n\",\n                       \"name\", FieldName(field));\n        printer->Indent();\n        PrintFieldComment(printer, field);\n        field_generators_.get(field).GenerateByteSize(printer);\n        printer->Outdent();\n        printer->Print(\"}\\n\");\n      }\n    }\n    printer->Print(\"\\n\"\n                   \"return total_size;\\n\");\n    printer->Outdent();\n    printer->Print(\"}\\n\");\n  }\n\n  printer->Print(\n      \"int $classname$::ByteSize() const {\\n\"\n      \"// @@protoc_insertion_point(message_byte_size_start:$full_name$)\\n\",\n      \"classname\", classname_, \"full_name\", descriptor_->full_name());\n  printer->Indent();\n  printer->Print(\n    \"int total_size = 0;\\n\"\n    \"\\n\");\n\n  // Handle required fields (if any).  We expect all of them to be\n  // present, so emit one conditional that checks for that.  If they are all\n  // present then the fast path executes; otherwise the slow path executes.\n  if (num_required_fields_ > 1 && HasFieldPresence(descriptor_->file())) {\n    // The fast path works if all required fields are present.\n    vector<uint32> masks_for_has_bits = RequiredFieldsBitMask(descriptor_);\n    printer->Print((string(\"if (\") +\n                    ConditionalToCheckBitmasks(masks_for_has_bits) +\n                    \") {  // All required fields are present.\\n\").c_str());\n    printer->Indent();\n    for (int i = 0; i < descriptor_->field_count(); i++) {\n      const FieldDescriptor* field = descriptor_->field(i);\n      if (!field->is_required()) continue;\n      PrintFieldComment(printer, field);\n      field_generators_.get(field).GenerateByteSize(printer);\n      printer->Print(\"\\n\");\n    }\n    printer->Outdent();\n    printer->Print(\"} else {\\n\"  // the slow path\n                   \"  total_size += RequiredFieldsByteSizeFallback();\\n\"\n                   \"}\\n\");\n  } else {\n    // num_required_fields_ <= 1: no need to be tricky\n    for (int i = 0; i < descriptor_->field_count(); i++) {\n      const FieldDescriptor* field = descriptor_->field(i);\n      if (!field->is_required()) continue;\n      PrintFieldComment(printer, field);\n      printer->Print(\"if (has_$name$()) {\\n\",\n                     \"name\", FieldName(field));\n      printer->Indent();\n      field_generators_.get(field).GenerateByteSize(printer);\n      printer->Outdent();\n      printer->Print(\"}\\n\");\n    }\n  }\n\n  // Handle optional fields (worry below about repeateds, oneofs, etc.).\n  // These are handled in chunks of 8.  The first chunk is\n  // the non-requireds-non-repeateds-non-unions-non-extensions in\n  //  descriptor_->field(0), descriptor_->field(1), ... descriptor_->field(7),\n  // and the second chunk is the same for\n  //  descriptor_->field(8), descriptor_->field(9), ... descriptor_->field(15),\n  // etc.\n  hash_map<int, uint32> fields_mask_for_chunk;\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n    if (!field->is_required() && !field->is_repeated() &&\n        !field->containing_oneof()) {\n      fields_mask_for_chunk[i / 8] |= static_cast<uint32>(1) << (i % 32);\n    }\n  }\n\n  int last_index = -1;\n  bool chunk_block_in_progress = false;\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n    if (!field->is_required() && !field->is_repeated() &&\n        !field->containing_oneof()) {\n      // See above in GenerateClear for an explanation of this.\n      // TODO(kenton):  Share code?  Unclear how to do so without\n      //   over-engineering.\n      if (i / 8 != last_index / 8 || last_index < 0) {\n        // End previous chunk, if there was one.\n        if (chunk_block_in_progress) {\n          printer->Outdent();\n          printer->Print(\"}\\n\");\n          chunk_block_in_progress = false;\n        }\n        // Start chunk.\n        uint32 mask = fields_mask_for_chunk[i / 8];\n        int count = popcnt(mask);\n        GOOGLE_DCHECK_GE(count, 1);\n        if (count == 1) {\n          // No \"if\" here because the chunk is trivial.\n        } else {\n          if (HasFieldPresence(descriptor_->file())) {\n            printer->Print(\n              \"if (_has_bits_[$index$ / 32] & $mask$u) {\\n\",\n              \"index\", SimpleItoa(i),\n              \"mask\", SimpleItoa(mask));\n            printer->Indent();\n            chunk_block_in_progress = true;\n          }\n        }\n      }\n      last_index = i;\n\n      PrintFieldComment(printer, field);\n\n      bool have_enclosing_if = false;\n      if (HasFieldPresence(descriptor_->file())) {\n        printer->Print(\n          \"if (has_$name$()) {\\n\",\n          \"name\", FieldName(field));\n        printer->Indent();\n        have_enclosing_if = true;\n      } else {\n        // Without field presence: field is serialized only if it has a\n        // non-default value.\n        have_enclosing_if = EmitFieldNonDefaultCondition(\n            printer, \"this->\", field);\n      }\n\n      field_generators_.get(field).GenerateByteSize(printer);\n\n      if (have_enclosing_if) {\n        printer->Outdent();\n        printer->Print(\n          \"}\\n\"\n          \"\\n\");\n      }\n    }\n  }\n\n  if (chunk_block_in_progress) {\n    printer->Outdent();\n    printer->Print(\"}\\n\");\n  }\n\n  // Repeated fields don't use _has_bits_ so we count them in a separate\n  // pass.\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n\n    if (field->is_repeated()) {\n      PrintFieldComment(printer, field);\n      field_generators_.get(field).GenerateByteSize(printer);\n      printer->Print(\"\\n\");\n    }\n  }\n\n  // Fields inside a oneof don't use _has_bits_ so we count them in a separate\n  // pass.\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    printer->Print(\n        \"switch ($oneofname$_case()) {\\n\",\n        \"oneofname\", descriptor_->oneof_decl(i)->name());\n    printer->Indent();\n    for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {\n      const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);\n      PrintFieldComment(printer, field);\n      printer->Print(\n          \"case k$field_name$: {\\n\",\n          \"field_name\", UnderscoresToCamelCase(field->name(), true));\n      printer->Indent();\n      field_generators_.get(field).GenerateByteSize(printer);\n      printer->Print(\n          \"break;\\n\");\n      printer->Outdent();\n      printer->Print(\n          \"}\\n\");\n    }\n    printer->Print(\n        \"case $cap_oneof_name$_NOT_SET: {\\n\"\n        \"  break;\\n\"\n        \"}\\n\",\n        \"cap_oneof_name\",\n        ToUpper(descriptor_->oneof_decl(i)->name()));\n    printer->Outdent();\n    printer->Print(\n        \"}\\n\");\n  }\n\n  if (descriptor_->extension_range_count() > 0) {\n    printer->Print(\n      \"total_size += _extensions_.ByteSize();\\n\"\n      \"\\n\");\n  }\n\n  if (PreserveUnknownFields(descriptor_)) {\n    if (UseUnknownFieldSet(descriptor_->file(), options_)) {\n      printer->Print(\n        \"if (_internal_metadata_.have_unknown_fields()) {\\n\"\n        \"  total_size +=\\n\"\n        \"    ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\\n\"\n        \"      unknown_fields());\\n\"\n        \"}\\n\");\n    } else {\n      printer->Print(\n        \"total_size += unknown_fields().size();\\n\"\n        \"\\n\");\n    }\n  }\n\n  // We update _cached_size_ even though this is a const method.  In theory,\n  // this is not thread-compatible, because concurrent writes have undefined\n  // results.  In practice, since any concurrent writes will be writing the\n  // exact same value, it works on all common processors.  In a future version\n  // of C++, _cached_size_ should be made into an atomic<int>.\n  printer->Print(\n    \"GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\\n\"\n    \"_cached_size_ = total_size;\\n\"\n    \"GOOGLE_SAFE_CONCURRENT_WRITES_END();\\n\"\n    \"return total_size;\\n\");\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid MessageGenerator::\nGenerateIsInitialized(io::Printer* printer) {\n  printer->Print(\n    \"bool $classname$::IsInitialized() const {\\n\",\n    \"classname\", classname_);\n  printer->Indent();\n\n  if (HasFieldPresence(descriptor_->file())) {\n    // Check that all required fields in this message are set.  We can do this\n    // most efficiently by checking 32 \"has bits\" at a time.\n    int has_bits_array_size = (descriptor_->field_count() + 31) / 32;\n    for (int i = 0; i < has_bits_array_size; i++) {\n      uint32 mask = 0;\n      for (int bit = 0; bit < 32; bit++) {\n        int index = i * 32 + bit;\n        if (index >= descriptor_->field_count()) break;\n        const FieldDescriptor* field = descriptor_->field(index);\n\n        if (field->is_required()) {\n          mask |= 1 << bit;\n        }\n      }\n\n      if (mask != 0) {\n        printer->Print(\n          \"if ((_has_bits_[$i$] & 0x$mask$) != 0x$mask$) return false;\\n\",\n          \"i\", SimpleItoa(i),\n          \"mask\", StrCat(strings::Hex(mask, strings::ZERO_PAD_8)));\n      }\n    }\n  }\n\n  // Now check that all embedded messages are initialized.\n  printer->Print(\"\\n\");\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&\n        !ShouldIgnoreRequiredFieldCheck(field, options_) &&\n        HasRequiredFields(field->message_type(), options_)) {\n      if (field->is_repeated()) {\n        printer->Print(\n          \"if (!::google::protobuf::internal::AllAreInitialized(this->$name$()))\"\n          \" return false;\\n\",\n          \"name\", FieldName(field));\n      } else {\n        if (field->options().weak() || !field->containing_oneof()) {\n          // For weak fields, use the data member (::google::protobuf::Message*) instead\n          // of the getter to avoid a link dependency on the weak message type\n          // which is only forward declared.\n          printer->Print(\n              \"if (has_$name$()) {\\n\"\n              \"  if (!this->$name$_->IsInitialized()) return false;\\n\"\n              \"}\\n\",\n            \"name\", FieldName(field));\n        } else {\n          printer->Print(\n            \"if (has_$name$()) {\\n\"\n            \"  if (!this->$name$().IsInitialized()) return false;\\n\"\n            \"}\\n\",\n            \"name\", FieldName(field));\n        }\n      }\n    }\n  }\n\n  if (descriptor_->extension_range_count() > 0) {\n    printer->Print(\n      \"\\n\"\n      \"if (!_extensions_.IsInitialized()) return false;\");\n  }\n\n  printer->Outdent();\n  printer->Print(\n    \"  return true;\\n\"\n    \"}\\n\");\n}\n\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_message.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__\n#define GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <set>\n#include <string>\n#include <google/protobuf/compiler/cpp/cpp_field.h>\n#include <google/protobuf/compiler/cpp/cpp_options.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace io {\n    class Printer;             // printer.h\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\nclass EnumGenerator;           // enum.h\nclass ExtensionGenerator;      // extension.h\n\nclass MessageGenerator {\n public:\n  // See generator.cc for the meaning of dllexport_decl.\n  MessageGenerator(const Descriptor* descriptor, const Options& options);\n  ~MessageGenerator();\n\n  // Header stuff.\n\n  // Return names for forward declarations of this class and all its nested\n  // types. A given key in {class,enum}_names will map from a class name to the\n  // descriptor that was responsible for its inclusion in the map. This can be\n  // used to associate the descriptor with the code generated for it.\n  void FillMessageForwardDeclarations(\n      map<string, const Descriptor*>* class_names);\n  void FillEnumForwardDeclarations(\n      map<string, const EnumDescriptor*>* enum_names);\n\n  // Generate definitions of all nested enums (must come before class\n  // definitions because those classes use the enums definitions).\n  void GenerateEnumDefinitions(io::Printer* printer);\n\n  // Generate specializations of GetEnumDescriptor<MyEnum>().\n  // Precondition: in ::google::protobuf namespace.\n  void GenerateGetEnumDescriptorSpecializations(io::Printer* printer);\n\n  // Generate definitions for this class and all its nested types.\n  void GenerateClassDefinition(io::Printer* printer);\n\n  // Generate definitions of inline methods (placed at the end of the header\n  // file).\n  void GenerateInlineMethods(io::Printer* printer, bool is_inline);\n\n  // Dependent methods are always inline.\n  void GenerateDependentInlineMethods(io::Printer* printer);\n\n  // Source file stuff.\n\n  // Generate code which declares all the global descriptor pointers which\n  // will be initialized by the methods below.\n  void GenerateDescriptorDeclarations(io::Printer* printer);\n\n  // Generate code that initializes the global variable storing the message's\n  // descriptor.\n  void GenerateDescriptorInitializer(io::Printer* printer, int index);\n\n  // Generate code that calls MessageFactory::InternalRegisterGeneratedMessage()\n  // for all types.\n  void GenerateTypeRegistrations(io::Printer* printer);\n\n  // Generates code that allocates the message's default instance.\n  void GenerateDefaultInstanceAllocator(io::Printer* printer);\n\n  // Generates code that initializes the message's default instance.  This\n  // is separate from allocating because all default instances must be\n  // allocated before any can be initialized.\n  void GenerateDefaultInstanceInitializer(io::Printer* printer);\n\n  // Generates code that should be run when ShutdownProtobufLibrary() is called,\n  // to delete all dynamically-allocated objects.\n  void GenerateShutdownCode(io::Printer* printer);\n\n  // Generate all non-inline methods for this class.\n  void GenerateClassMethods(io::Printer* printer);\n\n private:\n  // Generate declarations and definitions of accessors for fields.\n  void GenerateDependentBaseClassDefinition(io::Printer* printer);\n  void GenerateDependentFieldAccessorDeclarations(io::Printer* printer);\n  void GenerateFieldAccessorDeclarations(io::Printer* printer);\n  void GenerateDependentFieldAccessorDefinitions(io::Printer* printer);\n  void GenerateFieldAccessorDefinitions(io::Printer* printer, bool is_inline);\n\n  // Generate the field offsets array.\n  void GenerateOffsets(io::Printer* printer);\n\n  // Generate constructors and destructor.\n  void GenerateStructors(io::Printer* printer);\n\n  // The compiler typically generates multiple copies of each constructor and\n  // destructor: http://gcc.gnu.org/bugs.html#nonbugs_cxx\n  // Placing common code in a separate method reduces the generated code size.\n  //\n  // Generate the shared constructor code.\n  void GenerateSharedConstructorCode(io::Printer* printer);\n  // Generate the shared destructor code.\n  void GenerateSharedDestructorCode(io::Printer* printer);\n  // Generate the arena-specific destructor code.\n  void GenerateArenaDestructorCode(io::Printer* printer);\n\n  // Generate standard Message methods.\n  void GenerateClear(io::Printer* printer);\n  void GenerateOneofClear(io::Printer* printer);\n  void GenerateMergeFromCodedStream(io::Printer* printer);\n  void GenerateSerializeWithCachedSizes(io::Printer* printer);\n  void GenerateSerializeWithCachedSizesToArray(io::Printer* printer);\n  void GenerateSerializeWithCachedSizesBody(io::Printer* printer,\n                                            bool to_array);\n  void GenerateByteSize(io::Printer* printer);\n  void GenerateMergeFrom(io::Printer* printer);\n  void GenerateCopyFrom(io::Printer* printer);\n  void GenerateSwap(io::Printer* printer);\n  void GenerateIsInitialized(io::Printer* printer);\n\n  // Helpers for GenerateSerializeWithCachedSizes().\n  void GenerateSerializeOneField(io::Printer* printer,\n                                 const FieldDescriptor* field,\n                                 bool unbounded);\n  void GenerateSerializeOneExtensionRange(\n      io::Printer* printer, const Descriptor::ExtensionRange* range,\n      bool unbounded);\n\n\n  // Generates has_foo() functions and variables for singular field has-bits.\n  void GenerateSingularFieldHasBits(const FieldDescriptor* field,\n                                    map<string, string> vars,\n                                    io::Printer* printer);\n  // Generates has_foo() functions and variables for oneof field has-bits.\n  void GenerateOneofHasBits(io::Printer* printer, bool is_inline);\n  // Generates has_foo_bar() functions for oneof members.\n  void GenerateOneofMemberHasBits(const FieldDescriptor* field,\n                                  const map<string, string>& vars,\n                                  io::Printer* printer);\n  // Generates the clear_foo() method for a field.\n  void GenerateFieldClear(const FieldDescriptor* field,\n                          const map<string, string>& vars,\n                          io::Printer* printer);\n\n  const Descriptor* descriptor_;\n  string classname_;\n  Options options_;\n  FieldGeneratorMap field_generators_;\n  vector< vector<string> > runs_of_fields_;  // that might be trivially cleared\n  google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator> > nested_generators_;\n  google::protobuf::scoped_array<google::protobuf::scoped_ptr<EnumGenerator> > enum_generators_;\n  google::protobuf::scoped_array<google::protobuf::scoped_ptr<ExtensionGenerator> > extension_generators_;\n  int num_required_fields_;\n  bool uses_string_;\n  bool use_dependent_base_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);\n};\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_message_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/cpp/cpp_message_field.h>\n#include <google/protobuf/compiler/cpp/cpp_helpers.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\nnamespace {\n\nvoid SetMessageVariables(const FieldDescriptor* descriptor,\n                         map<string, string>* variables,\n                         const Options& options) {\n  SetCommonFieldVariables(descriptor, variables, options);\n  (*variables)[\"type\"] = FieldMessageTypeName(descriptor);\n  if (descriptor->options().weak() || !descriptor->containing_oneof()) {\n    (*variables)[\"non_null_ptr_to_name\"] =\n        StrCat(\"this->\", (*variables)[\"name\"], \"_\");\n  }\n  (*variables)[\"stream_writer\"] =\n      (*variables)[\"declared_type\"] +\n      (HasFastArraySerialization(descriptor->message_type()->file(), options)\n           ? \"MaybeToArray\"\n           : \"\");\n  // NOTE: Escaped here to unblock proto1->proto2 migration.\n  // TODO(liujisi): Extend this to apply for other conflicting methods.\n  (*variables)[\"release_name\"] =\n      SafeFunctionName(descriptor->containing_type(),\n                       descriptor, \"release_\");\n  (*variables)[\"full_name\"] = descriptor->full_name();\n  if (options.proto_h && IsFieldDependent(descriptor)) {\n    (*variables)[\"dependent_type\"] = \"T::\" + DependentTypeName(descriptor);\n    (*variables)[\"dependent_typename\"] =\n        \"typename T::\" + DependentTypeName(descriptor);\n  } else {\n    (*variables)[\"dependent_type\"] = FieldMessageTypeName(descriptor);\n    (*variables)[\"dependent_typename\"] = FieldMessageTypeName(descriptor);\n  }\n}\n\n}  // namespace\n\n// ===================================================================\n\nMessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor,\n                                             const Options& options)\n    : FieldGenerator(options),\n      descriptor_(descriptor),\n      dependent_field_(options.proto_h && IsFieldDependent(descriptor)) {\n  SetMessageVariables(descriptor, &variables_, options);\n}\n\nMessageFieldGenerator::~MessageFieldGenerator() {}\n\nvoid MessageFieldGenerator::\nGeneratePrivateMembers(io::Printer* printer) const {\n  printer->Print(variables_, \"$type$* $name$_;\\n\");\n}\n\nvoid MessageFieldGenerator::\nGenerateGetterDeclaration(io::Printer* printer) const {\n  printer->Print(variables_,\n      \"$deprecated_attr$const $type$& $name$() const;\\n\");\n}\n\nvoid MessageFieldGenerator::\nGenerateDependentAccessorDeclarations(io::Printer* printer) const {\n  if (!dependent_field_) {\n    return;\n  }\n  // Arena manipulation code is out-of-line in the derived message class.\n  printer->Print(variables_,\n    \"$deprecated_attr$$type$* mutable_$name$();\\n\"\n    \"$deprecated_attr$$type$* $release_name$();\\n\"\n    \"$deprecated_attr$void set_allocated_$name$($type$* $name$);\\n\");\n}\n\nvoid MessageFieldGenerator::\nGenerateAccessorDeclarations(io::Printer* printer) const {\n  if (SupportsArenas(descriptor_)) {\n    printer->Print(variables_,\n       \"private:\\n\"\n       \"void _slow_mutable_$name$();\\n\");\n    if (SupportsArenas(descriptor_->message_type())) {\n      printer->Print(variables_,\n       \"void _slow_set_allocated_$name$(\\n\"\n       \"    ::google::protobuf::Arena* message_arena, $type$** $name$);\\n\");\n    }\n    printer->Print(variables_,\n       \"$type$* _slow_$release_name$();\\n\"\n       \"public:\\n\");\n  }\n  GenerateGetterDeclaration(printer);\n  if (!dependent_field_) {\n    printer->Print(variables_,\n      \"$deprecated_attr$$type$* mutable_$name$();\\n\"\n      \"$deprecated_attr$$type$* $release_name$();\\n\"\n      \"$deprecated_attr$void set_allocated_$name$($type$* $name$);\\n\");\n  }\n  if (SupportsArenas(descriptor_)) {\n    printer->Print(variables_,\n      \"$deprecated_attr$$type$* unsafe_arena_release_$name$();\\n\"\n      \"$deprecated_attr$void unsafe_arena_set_allocated_$name$(\\n\"\n      \"    $type$* $name$);\\n\");\n  }\n}\n\nvoid MessageFieldGenerator::GenerateNonInlineAccessorDefinitions(\n    io::Printer* printer) const {\n  if (SupportsArenas(descriptor_)) {\n    printer->Print(variables_,\n      \"void $classname$::_slow_mutable_$name$() {\\n\");\n      if (SupportsArenas(descriptor_->message_type())) {\n        printer->Print(variables_,\n          \"  $name$_ = ::google::protobuf::Arena::CreateMessage< $type$ >(\\n\"\n          \"      GetArenaNoVirtual());\\n\");\n      } else {\n        printer->Print(variables_,\n          \"  $name$_ = ::google::protobuf::Arena::Create< $type$ >(\\n\"\n          \"      GetArenaNoVirtual());\\n\");\n      }\n    printer->Print(variables_,\n      \"}\\n\"\n      \"$type$* $classname$::_slow_$release_name$() {\\n\"\n      \"  if ($name$_ == NULL) {\\n\"\n      \"    return NULL;\\n\"\n      \"  } else {\\n\"\n      \"    $type$* temp = new $type$;\\n\"\n      \"    temp->MergeFrom(*$name$_);\\n\"\n      \"    $name$_ = NULL;\\n\"\n      \"    return temp;\\n\"\n      \"  }\\n\"\n      \"}\\n\"\n      \"$type$* $classname$::unsafe_arena_release_$name$() {\\n\"\n      \"  // @@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\\n\"\n      \"  $clear_hasbit$\\n\"\n      \"  $type$* temp = $name$_;\\n\"\n      \"  $name$_ = NULL;\\n\"\n      \"  return temp;\\n\"\n      \"}\\n\");\n    if (SupportsArenas(descriptor_->message_type())) {\n      // NOTE: the same logic is mirrored in weak_message_field.cc. Any\n      // arena-related semantics changes should be made in both places.\n      printer->Print(variables_,\n          \"void $classname$::_slow_set_allocated_$name$(\\n\"\n          \"    ::google::protobuf::Arena* message_arena, $type$** $name$) {\\n\"\n          \"    if (message_arena != NULL && \\n\"\n          \"        ::google::protobuf::Arena::GetArena(*$name$) == NULL) {\\n\"\n          \"      message_arena->Own(*$name$);\\n\"\n          \"    } else if (message_arena !=\\n\"\n          \"               ::google::protobuf::Arena::GetArena(*$name$)) {\\n\"\n          \"      $type$* new_$name$ = \\n\"\n          \"            ::google::protobuf::Arena::CreateMessage< $type$ >(\\n\"\n          \"            message_arena);\\n\"\n          \"      new_$name$->CopyFrom(**$name$);\\n\"\n          \"      *$name$ = new_$name$;\\n\"\n          \"    }\\n\"\n          \"}\\n\");\n    }\n    printer->Print(variables_,\n      \"void $classname$::unsafe_arena_set_allocated_$name$(\\n\"\n      \"    $type$* $name$) {\\n\"\n      // If we're not on an arena, free whatever we were holding before.\n      // (If we are on arena, we can just forget the earlier pointer.)\n      \"  if (GetArenaNoVirtual() == NULL) {\\n\"\n      \"    delete $name$_;\\n\"\n      \"  }\\n\"\n      \"  $name$_ = $name$;\\n\"\n      \"  if ($name$) {\\n\"\n      \"    $set_hasbit$\\n\"\n      \"  } else {\\n\"\n      \"    $clear_hasbit$\\n\"\n      \"  }\\n\"\n      \"  // @@protoc_insertion_point(field_unsafe_arena_set_allocated\"\n      \":$full_name$)\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid MessageFieldGenerator::\nGenerateDependentInlineAccessorDefinitions(io::Printer* printer) const {\n  if (!dependent_field_) {\n    return;\n  }\n\n  map<string, string> variables(variables_);\n  // For the CRTP base class, all mutation methods are dependent, and so\n  // they must be in the header.\n  variables[\"dependent_classname\"] =\n      DependentBaseClassTemplateName(descriptor_->containing_type()) + \"<T>\";\n  variables[\"this_message\"] = DependentBaseDownCast();\n  if (!variables[\"set_hasbit\"].empty()) {\n    variables[\"set_hasbit\"] =\n        variables[\"this_message\"] + variables[\"set_hasbit\"];\n  }\n  if (!variables[\"clear_hasbit\"].empty()) {\n    variables[\"clear_hasbit\"] =\n        variables[\"this_message\"] + variables[\"clear_hasbit\"];\n  }\n\n  if (SupportsArenas(descriptor_)) {\n    printer->Print(variables,\n      \"template <class T>\\n\"\n      \"inline $type$* $dependent_classname$::mutable_$name$() {\\n\"\n      \"  $set_hasbit$\\n\"\n      \"  $dependent_typename$*& $name$_ = $this_message$$name$_;\\n\"\n      \"  if ($name$_ == NULL) {\\n\"\n      \"    $this_message$_slow_mutable_$name$();\\n\"\n      \"  }\\n\"\n      \"  // @@protoc_insertion_point(field_mutable:$full_name$)\\n\"\n      \"  return $name$_;\\n\"\n      \"}\\n\"\n      \"template <class T>\\n\"\n      \"inline $type$* $dependent_classname$::$release_name$() {\\n\"\n      \"  // @@protoc_insertion_point(field_release:$full_name$)\\n\"\n      \"  $dependent_typename$*& $name$_ = $this_message$$name$_;\\n\"\n      \"  $clear_hasbit$\\n\"\n      \"  if ($this_message$GetArenaNoVirtual() != NULL) {\\n\"\n      \"    return $this_message$_slow_$release_name$();\\n\"\n      \"  } else {\\n\"\n      \"    $dependent_typename$* temp = $name$_;\\n\"\n      \"    $name$_ = NULL;\\n\"\n      \"    return temp;\\n\"\n      \"  }\\n\"\n      \"}\\n\"\n      \"template <class T>\\n\"\n      \"inline void $dependent_classname$::\"\n      \"set_allocated_$name$($type$* $name$) {\\n\"\n      \"  ::google::protobuf::Arena* message_arena = $this_message$GetArenaNoVirtual();\\n\"\n      \"  $dependent_typename$*& $name$_ = $this_message$$name$_;\\n\"\n      \"  if (message_arena == NULL) {\\n\"\n      \"    delete $name$_;\\n\"\n      \"  }\\n\"\n      \"  if ($name$ != NULL) {\\n\");\n    if (SupportsArenas(descriptor_->message_type())) {\n      // If we're on an arena and the incoming message is not, simply Own() it\n      // rather than copy to the arena -- either way we need a heap dealloc,\n      // so we might as well defer it. Otherwise, if incoming message is on a\n      // different ownership domain (specific arena, or the heap) than we are,\n      // copy to our arena (or heap, as the case may be).\n      printer->Print(variables,\n        \"    $this_message$_slow_set_allocated_$name$(message_arena, \"\n        \"&$name$);\\n\");\n    } else {\n      printer->Print(variables,\n        \"    if (message_arena != NULL) {\\n\"\n        \"      message_arena->Own($name$);\\n\"\n        \"    }\\n\");\n    }\n    printer->Print(variables,\n      \"  }\\n\"\n      \"  $name$_ = $name$;\\n\"\n      \"  if ($name$) {\\n\"\n      \"    $set_hasbit$\\n\"\n      \"  } else {\\n\"\n      \"    $clear_hasbit$\\n\"\n      \"  }\\n\"\n      // TODO(dlj): move insertion points to message class.\n      \"  // @@protoc_insertion_point(field_set_allocated:$full_name$)\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables,\n      \"template <class T>\\n\"\n      \"inline $type$* $dependent_classname$::mutable_$name$() {\\n\"\n      \"  $set_hasbit$\\n\"\n      \"  $dependent_typename$*& $name$_ = $this_message$$name$_;\\n\"\n      \"  if ($name$_ == NULL) {\\n\"\n      \"    $name$_ = new $dependent_typename$;\\n\"\n      \"  }\\n\"\n      \"  // @@protoc_insertion_point(field_mutable:$full_name$)\\n\"\n      \"  return $name$_;\\n\"\n      \"}\\n\"\n      \"template <class T>\\n\"\n      \"inline $type$* $dependent_classname$::$release_name$() {\\n\"\n      \"  // @@protoc_insertion_point(field_release:$full_name$)\\n\"\n      \"  $clear_hasbit$\\n\"\n      \"  $dependent_typename$*& $name$_ = $this_message$$name$_;\\n\"\n      \"  $dependent_typename$* temp = $name$_;\\n\"\n      \"  $name$_ = NULL;\\n\"\n      \"  return temp;\\n\"\n      \"}\\n\"\n      \"template <class T>\\n\"\n      \"inline void $dependent_classname$::\"\n      \"set_allocated_$name$($type$* $name$) {\\n\"\n      \"  $dependent_typename$*& $name$_ = $this_message$$name$_;\\n\"\n      \"  delete $name$_;\\n\");\n\n    if (SupportsArenas(descriptor_->message_type())) {\n      printer->Print(variables,\n      \"  if ($name$ != NULL && static_cast< $dependent_typename$* >($name$)\"\n      \"->GetArena() != NULL) {\\n\"\n      \"    $dependent_typename$* new_$name$ = new $dependent_typename$;\\n\"\n      \"    new_$name$->CopyFrom(*$name$);\\n\"\n      \"    $name$ = new_$name$;\\n\"\n      \"  }\\n\");\n    }\n\n    printer->Print(variables,\n      \"  $name$_ = $name$;\\n\"\n      \"  if ($name$) {\\n\"\n      \"    $set_hasbit$\\n\"\n      \"  } else {\\n\"\n      \"    $clear_hasbit$\\n\"\n      \"  }\\n\"\n      \"  // @@protoc_insertion_point(field_set_allocated:$full_name$)\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid MessageFieldGenerator::\nGenerateInlineAccessorDefinitions(io::Printer* printer,\n                                  bool is_inline) const {\n  map<string, string> variables(variables_);\n  variables[\"inline\"] = is_inline ? \"inline \" : \"\";\n  printer->Print(variables,\n    \"$inline$const $type$& $classname$::$name$() const {\\n\"\n    \"  // @@protoc_insertion_point(field_get:$full_name$)\\n\");\n\n  PrintHandlingOptionalStaticInitializers(\n      variables, descriptor_->file(), options_, printer,\n      // With static initializers.\n      \"  return $name$_ != NULL ? *$name$_ : *default_instance_->$name$_;\\n\",\n      // Without.\n      \"  return $name$_ != NULL ? *$name$_ : *default_instance().$name$_;\\n\");\n  printer->Print(variables, \"}\\n\");\n\n  if (dependent_field_) {\n    return;\n  }\n\n  if (SupportsArenas(descriptor_)) {\n    printer->Print(variables,\n      \"$inline$\"\n      \"$type$* $classname$::mutable_$name$() {\\n\"\n      \"  $set_hasbit$\\n\"\n      \"  if ($name$_ == NULL) {\\n\"\n      \"    _slow_mutable_$name$();\\n\"\n      \"  }\\n\"\n      \"  // @@protoc_insertion_point(field_mutable:$full_name$)\\n\"\n      \"  return $name$_;\\n\"\n      \"}\\n\"\n      \"$inline$\"\n      \"$type$* $classname$::$release_name$() {\\n\"\n      \"  // @@protoc_insertion_point(field_release:$full_name$)\\n\"\n      \"  $clear_hasbit$\\n\"\n      \"  if (GetArenaNoVirtual() != NULL) {\\n\"\n      \"    return _slow_$release_name$();\\n\"\n      \"  } else {\\n\"\n      \"    $type$* temp = $name$_;\\n\"\n      \"    $name$_ = NULL;\\n\"\n      \"    return temp;\\n\"\n      \"  }\\n\"\n      \"}\\n\"\n      \"$inline$ \"\n      \"void $classname$::set_allocated_$name$($type$* $name$) {\\n\"\n      \"  ::google::protobuf::Arena* message_arena = GetArenaNoVirtual();\\n\"\n      \"  if (message_arena == NULL) {\\n\"\n      \"    delete $name$_;\\n\"\n      \"  }\\n\"\n      \"  if ($name$ != NULL) {\\n\");\n    if (SupportsArenas(descriptor_->message_type())) {\n      // If we're on an arena and the incoming message is not, simply Own() it\n      // rather than copy to the arena -- either way we need a heap dealloc,\n      // so we might as well defer it. Otherwise, if incoming message is on a\n      // different ownership domain (specific arena, or the heap) than we are,\n      // copy to our arena (or heap, as the case may be).\n      printer->Print(variables,\n        \"    _slow_set_allocated_$name$(message_arena, &$name$);\\n\");\n    } else {\n      printer->Print(variables,\n        \"    if (message_arena != NULL) {\\n\"\n        \"      message_arena->Own($name$);\\n\"\n        \"    }\\n\");\n    }\n    printer->Print(variables,\n      \"  }\\n\"\n      \"  $name$_ = $name$;\\n\"\n      \"  if ($name$) {\\n\"\n      \"    $set_hasbit$\\n\"\n      \"  } else {\\n\"\n      \"    $clear_hasbit$\\n\"\n      \"  }\\n\"\n      \"  // @@protoc_insertion_point(field_set_allocated:$full_name$)\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables,\n      \"$inline$\"\n      \"$type$* $classname$::mutable_$name$() {\\n\"\n      \"  $set_hasbit$\\n\"\n      \"  if ($name$_ == NULL) {\\n\"\n      \"    $name$_ = new $type$;\\n\"\n      \"  }\\n\"\n      \"  // @@protoc_insertion_point(field_mutable:$full_name$)\\n\"\n      \"  return $name$_;\\n\"\n      \"}\\n\"\n      \"$inline$\"\n      \"$type$* $classname$::$release_name$() {\\n\"\n      \"  // @@protoc_insertion_point(field_release:$full_name$)\\n\"\n      \"  $clear_hasbit$\\n\"\n      \"  $type$* temp = $name$_;\\n\"\n      \"  $name$_ = NULL;\\n\"\n      \"  return temp;\\n\"\n      \"}\\n\"\n      \"$inline$\"\n      \"void $classname$::set_allocated_$name$($type$* $name$) {\\n\"\n      \"  delete $name$_;\\n\");\n\n    if (SupportsArenas(descriptor_->message_type())) {\n      printer->Print(variables,\n      \"  if ($name$ != NULL && $name$->GetArena() != NULL) {\\n\"\n      \"    $type$* new_$name$ = new $type$;\\n\"\n      \"    new_$name$->CopyFrom(*$name$);\\n\"\n      \"    $name$ = new_$name$;\\n\"\n      \"  }\\n\");\n    }\n\n    printer->Print(variables,\n      \"  $name$_ = $name$;\\n\"\n      \"  if ($name$) {\\n\"\n      \"    $set_hasbit$\\n\"\n      \"  } else {\\n\"\n      \"    $clear_hasbit$\\n\"\n      \"  }\\n\"\n      \"  // @@protoc_insertion_point(field_set_allocated:$full_name$)\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid MessageFieldGenerator::\nGenerateClearingCode(io::Printer* printer) const {\n  map<string, string> variables(variables_);\n  variables[\"this_message\"] = dependent_field_ ? DependentBaseDownCast() : \"\";\n  if (!HasFieldPresence(descriptor_->file())) {\n    // If we don't have has-bits, message presence is indicated only by ptr !=\n    // NULL. Thus on clear, we need to delete the object.\n    printer->Print(variables,\n      \"if ($this_message$GetArenaNoVirtual() == NULL && \"\n      \"$this_message$$name$_ != NULL) delete $this_message$$name$_;\\n\"\n      \"$this_message$$name$_ = NULL;\\n\");\n  } else {\n    printer->Print(variables,\n      \"if ($this_message$$name$_ != NULL) $this_message$$name$_->\"\n      \"$dependent_type$::Clear();\\n\");\n  }\n}\n\nvoid MessageFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"mutable_$name$()->$type$::MergeFrom(from.$name$());\\n\");\n}\n\nvoid MessageFieldGenerator::\nGenerateSwappingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"std::swap($name$_, other->$name$_);\\n\");\n}\n\nvoid MessageFieldGenerator::\nGenerateConstructorCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_ = NULL;\\n\");\n}\n\nvoid MessageFieldGenerator::\nGenerateMergeFromCodedStream(io::Printer* printer) const {\n  if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) {\n    printer->Print(variables_,\n      \"DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\\n\"\n      \"     input, mutable_$name$()));\\n\");\n  } else {\n    printer->Print(variables_,\n      \"DO_(::google::protobuf::internal::WireFormatLite::ReadGroupNoVirtual(\\n\"\n      \"      $number$, input, mutable_$name$()));\\n\");\n  }\n}\n\nvoid MessageFieldGenerator::\nGenerateSerializeWithCachedSizes(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"::google::protobuf::internal::WireFormatLite::Write$stream_writer$(\\n\"\n    \"  $number$, *$non_null_ptr_to_name$, output);\\n\");\n}\n\nvoid MessageFieldGenerator::\nGenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"target = ::google::protobuf::internal::WireFormatLite::\\n\"\n    \"  InternalWrite$declared_type$NoVirtualToArray(\\n\"\n    \"    $number$, *$non_null_ptr_to_name$, false, target);\\n\");\n}\n\nvoid MessageFieldGenerator::\nGenerateByteSize(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"total_size += $tag_size$ +\\n\"\n    \"  ::google::protobuf::internal::WireFormatLite::$declared_type$SizeNoVirtual(\\n\"\n    \"    *$non_null_ptr_to_name$);\\n\");\n}\n\n// ===================================================================\n\nMessageOneofFieldGenerator::\nMessageOneofFieldGenerator(const FieldDescriptor* descriptor,\n                           const Options& options)\n  : MessageFieldGenerator(descriptor, options),\n    dependent_base_(options.proto_h) {\n  SetCommonOneofFieldVariables(descriptor, &variables_);\n}\n\nMessageOneofFieldGenerator::~MessageOneofFieldGenerator() {}\n\n\nvoid MessageOneofFieldGenerator::\nGenerateDependentAccessorDeclarations(io::Printer* printer) const {\n  // Oneof field getters must be dependent as they call default_instance().\n  // Otherwise, the logic is the same as MessageFields.\n  if (!dependent_field_) {\n    return;\n  }\n  printer->Print(variables_,\n      \"$deprecated_attr$const $type$& $name$() const;\\n\");\n  MessageFieldGenerator::GenerateDependentAccessorDeclarations(printer);\n}\n\nvoid MessageOneofFieldGenerator::\nGenerateGetterDeclaration(io::Printer* printer) const {\n  // Oneof field getters must be dependent as they call default_instance().\n  // Unlike MessageField, this means there is no (non-dependent) getter to\n  // generate.\n  if (dependent_field_) {\n    return;\n  }\n  printer->Print(variables_,\n      \"$deprecated_attr$const $type$& $name$() const;\\n\");\n}\n\nvoid MessageOneofFieldGenerator::\nGenerateDependentInlineAccessorDefinitions(io::Printer* printer) const {\n  // For the CRTP base class, all mutation methods are dependent, and so\n  // they must be in the header.\n  if (!dependent_base_) {\n    return;\n  }\n  map<string, string> variables(variables_);\n  variables[\"inline\"] = \"inline \";\n  variables[\"dependent_classname\"] =\n      DependentBaseClassTemplateName(descriptor_->containing_type()) + \"<T>\";\n  variables[\"this_message\"] = \"reinterpret_cast<T*>(this)->\";\n  // Const message access is needed for the dependent getter.\n  variables[\"this_const_message\"] = \"reinterpret_cast<const T*>(this)->\";\n  variables[\"tmpl\"] = \"template <class T>\\n\";\n  variables[\"field_member\"] = variables[\"this_message\"] +\n                              variables[\"oneof_prefix\"] + variables[\"name\"] +\n                              \"_\";\n  InternalGenerateInlineAccessorDefinitions(variables, printer);\n}\n\nvoid MessageOneofFieldGenerator::\nGenerateInlineAccessorDefinitions(io::Printer* printer,\n                                  bool is_inline) const {\n  if (dependent_base_) {\n    return;\n  }\n  map<string, string> variables(variables_);\n  variables[\"inline\"] = is_inline ? \"inline \" : \"\";\n  variables[\"dependent_classname\"] = variables[\"classname\"];\n  variables[\"this_message\"] = \"\";\n  variables[\"this_const_message\"] = \"\";\n  variables[\"tmpl\"] = \"\";\n  variables[\"field_member\"] =\n      variables[\"oneof_prefix\"] + variables[\"name\"] + \"_\";\n  variables[\"dependent_type\"] = variables[\"type\"];\n  InternalGenerateInlineAccessorDefinitions(variables, printer);\n}\n\nvoid MessageOneofFieldGenerator::\nGenerateNonInlineAccessorDefinitions(io::Printer* printer) const {\n  map<string, string> variables(variables_);\n  variables[\"field_member\"] =\n      variables[\"oneof_prefix\"] + variables[\"name\"] + \"_\";\n\n  //printer->Print(variables,\n}\n\nvoid MessageOneofFieldGenerator::\nInternalGenerateInlineAccessorDefinitions(const map<string, string>& variables,\n                                          io::Printer* printer) const {\n  printer->Print(variables,\n    \"$tmpl$\"\n    \"$inline$ \"\n    \"const $type$& $dependent_classname$::$name$() const {\\n\"\n    \"  // @@protoc_insertion_point(field_get:$full_name$)\\n\"\n    \"  return $this_const_message$has_$name$()\\n\"\n    \"      ? *$this_const_message$$oneof_prefix$$name$_\\n\"\n    \"      : $dependent_type$::default_instance();\\n\"\n    \"}\\n\");\n\n  if (SupportsArenas(descriptor_)) {\n    printer->Print(variables,\n      \"$tmpl$\"\n      \"$inline$\"\n      \"$type$* $dependent_classname$::mutable_$name$() {\\n\"\n      \"  if (!$this_message$has_$name$()) {\\n\"\n      \"    $this_message$clear_$oneof_name$();\\n\"\n      \"    $this_message$set_has_$name$();\\n\");\n    if (SupportsArenas(descriptor_->message_type())) {\n      printer->Print(variables,\n         \"    $field_member$ = \\n\"\n         \"      ::google::protobuf::Arena::CreateMessage< $dependent_typename$ >(\\n\"\n         \"      $this_message$GetArenaNoVirtual());\\n\");\n    } else {\n      printer->Print(variables,\n         \"    $this_message$$oneof_prefix$$name$_ = \\n\"\n         \"      ::google::protobuf::Arena::Create< $dependent_typename$ >(\\n\"\n         \"      $this_message$GetArenaNoVirtual());\\n\");\n    }\n    printer->Print(variables,\n      \"  }\\n\"\n      \"  // @@protoc_insertion_point(field_mutable:$full_name$)\\n\"\n      \"  return $field_member$;\\n\"\n      \"}\\n\"\n      \"$tmpl$\"\n      \"$inline$\"\n      \"$type$* $dependent_classname$::$release_name$() {\\n\"\n      \"  // @@protoc_insertion_point(field_release:$full_name$)\\n\"\n      \"  if ($this_message$has_$name$()) {\\n\"\n      \"    $this_message$clear_has_$oneof_name$();\\n\"\n      \"    if ($this_message$GetArenaNoVirtual() != NULL) {\\n\"\n      // N.B.: safe to use the underlying field pointer here because we are sure\n      // that it is non-NULL (because has_$name$() returned true).\n      \"      $dependent_typename$* temp = new $dependent_typename$;\\n\"\n      \"      temp->MergeFrom(*$field_member$);\\n\"\n      \"      $field_member$ = NULL;\\n\"\n      \"      return temp;\\n\"\n      \"    } else {\\n\"\n      \"      $dependent_typename$* temp = $field_member$;\\n\"\n      \"      $field_member$ = NULL;\\n\"\n      \"      return temp;\\n\"\n      \"    }\\n\"\n      \"  } else {\\n\"\n      \"    return NULL;\\n\"\n      \"  }\\n\"\n      \"}\\n\"\n      \"$tmpl$\"\n      \"$inline$\"\n      \"void $dependent_classname$::\"\n      \"set_allocated_$name$($type$* $name$) {\\n\"\n      \"  $this_message$clear_$oneof_name$();\\n\"\n      \"  if ($name$) {\\n\");\n\n    if (SupportsArenas(descriptor_->message_type())) {\n      printer->Print(variables,\n        // If incoming message is on the heap and we are on an arena, just Own()\n        // it (see above). If it's on a different arena than we are or one of us\n        // is on the heap, we make a copy to our arena/heap.\n        \"    if ($this_message$GetArenaNoVirtual() != NULL &&\\n\"\n        \"        ::google::protobuf::Arena::GetArena($name$) == NULL) {\\n\"\n        \"      $this_message$GetArenaNoVirtual()->Own($name$);\\n\"\n        \"    } else if ($this_message$GetArenaNoVirtual() !=\\n\"\n        \"               ::google::protobuf::Arena::GetArena($name$)) {\\n\"\n        \"      $dependent_typename$* new_$name$ = \\n\"\n        \"          ::google::protobuf::Arena::CreateMessage< $dependent_typename$ >(\\n\"\n        \"          $this_message$GetArenaNoVirtual());\\n\"\n        \"      new_$name$->CopyFrom(*$name$);\\n\"\n        \"      $name$ = new_$name$;\\n\"\n        \"    }\\n\");\n    } else {\n      printer->Print(variables,\n        \"    if ($this_message$GetArenaNoVirtual() != NULL) {\\n\"\n        \"      $this_message$GetArenaNoVirtual()->Own($name$);\\n\"\n        \"    }\\n\");\n    }\n\n    printer->Print(variables,\n      \"    $this_message$set_has_$name$();\\n\"\n      \"    $field_member$ = $name$;\\n\"\n      \"  }\\n\"\n      \"  // @@protoc_insertion_point(field_set_allocated:$full_name$)\\n\"\n      \"}\\n\"\n      \"$inline$ $type$* $classname$::unsafe_arena_release_$name$() {\\n\"\n      \"  // @@protoc_insertion_point(field_unsafe_arena_release\"\n      \":$full_name$)\\n\"\n      \"  if (has_$name$()) {\\n\"\n      \"    clear_has_$oneof_name$();\\n\"\n      \"    $type$* temp = $oneof_prefix$$name$_;\\n\"\n      \"    $oneof_prefix$$name$_ = NULL;\\n\"\n      \"    return temp;\\n\"\n      \"  } else {\\n\"\n      \"    return NULL;\\n\"\n      \"  }\\n\"\n      \"}\\n\"\n      \"$inline$ void $classname$::unsafe_arena_set_allocated_$name$\"\n      \"($type$* $name$) {\\n\"\n      // We rely on the oneof clear method to free the earlier contents of this\n      // oneof. We can directly use the pointer we're given to set the new\n      // value.\n      \"  clear_$oneof_name$();\\n\"\n      \"  if ($name$) {\\n\"\n      \"    set_has_$name$();\\n\"\n      \"    $oneof_prefix$$name$_ = $name$;\\n\"\n      \"  }\\n\"\n      \"  // @@protoc_insertion_point(field_unsafe_arena_set_allocated:\"\n      \"$full_name$)\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables,\n      \"$tmpl$\"\n      \"$inline$\"\n      \"$type$* $dependent_classname$::mutable_$name$() {\\n\"\n      \"  if (!$this_message$has_$name$()) {\\n\"\n      \"    $this_message$clear_$oneof_name$();\\n\"\n      \"    $this_message$set_has_$name$();\\n\"\n      \"    $field_member$ = new $dependent_typename$;\\n\"\n      \"  }\\n\"\n      \"  // @@protoc_insertion_point(field_mutable:$full_name$)\\n\"\n      \"  return $field_member$;\\n\"\n      \"}\\n\"\n      \"$tmpl$\"\n      \"$inline$\"\n      \"$type$* $dependent_classname$::$release_name$() {\\n\"\n      \"  // @@protoc_insertion_point(field_release:$full_name$)\\n\"\n      \"  if ($this_message$has_$name$()) {\\n\"\n      \"    $this_message$clear_has_$oneof_name$();\\n\"\n      \"    $dependent_typename$* temp = $field_member$;\\n\"\n      \"    $field_member$ = NULL;\\n\"\n      \"    return temp;\\n\"\n      \"  } else {\\n\"\n      \"    return NULL;\\n\"\n      \"  }\\n\"\n      \"}\\n\"\n      \"$tmpl$\"\n      \"$inline$\"\n      \"void $dependent_classname$::\"\n      \"set_allocated_$name$($type$* $name$) {\\n\"\n      \"  $this_message$clear_$oneof_name$();\\n\"\n      \"  if ($name$) {\\n\");\n    if (SupportsArenas(descriptor_->message_type())) {\n      printer->Print(variables,\n        \"    if (static_cast< $dependent_typename$*>($name$)->\"\n        \"GetArena() != NULL) {\\n\"\n        \"      $dependent_typename$* new_$name$ = new $dependent_typename$;\\n\"\n        \"      new_$name$->CopyFrom(*$name$);\\n\"\n        \"      $name$ = new_$name$;\\n\"\n        \"    }\\n\");\n    }\n    printer->Print(variables,\n      \"    $this_message$set_has_$name$();\\n\"\n      \"    $field_member$ = $name$;\\n\"\n      \"  }\\n\"\n      \"  // @@protoc_insertion_point(field_set_allocated:$full_name$)\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid MessageOneofFieldGenerator::\nGenerateClearingCode(io::Printer* printer) const {\n  map<string, string> variables(variables_);\n  variables[\"this_message\"] = dependent_field_ ? DependentBaseDownCast() : \"\";\n  if (SupportsArenas(descriptor_)) {\n    printer->Print(variables,\n      \"if ($this_message$GetArenaNoVirtual() == NULL) {\\n\"\n      \"  delete $this_message$$oneof_prefix$$name$_;\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables,\n      \"delete $this_message$$oneof_prefix$$name$_;\\n\");\n  }\n}\n\nvoid MessageOneofFieldGenerator::\nGenerateSwappingCode(io::Printer* printer) const {\n  // Don't print any swapping code. Swapping the union will swap this field.\n}\n\nvoid MessageOneofFieldGenerator::\nGenerateConstructorCode(io::Printer* printer) const {\n  // Don't print any constructor code. The field is in a union. We allocate\n  // space only when this field is used.\n}\n\n// ===================================================================\n\nRepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator(\n    const FieldDescriptor* descriptor, const Options& options)\n    : FieldGenerator(options),\n      descriptor_(descriptor),\n      dependent_field_(options.proto_h && IsFieldDependent(descriptor)),\n      dependent_getter_(dependent_field_ && options.safe_boundary_check) {\n  SetMessageVariables(descriptor, &variables_, options);\n}\n\nRepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() {}\n\nvoid RepeatedMessageFieldGenerator::\nGeneratePrivateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"::google::protobuf::RepeatedPtrField< $type$ > $name$_;\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::\nInternalGenerateTypeDependentAccessorDeclarations(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$deprecated_attr$$type$* mutable_$name$(int index);\\n\"\n    \"$deprecated_attr$$type$* add_$name$();\\n\");\n  if (dependent_getter_) {\n    printer->Print(variables_,\n      \"$deprecated_attr$const ::google::protobuf::RepeatedPtrField< $type$ >&\\n\"\n      \"    $name$() const;\\n\");\n  }\n  printer->Print(variables_,\n    \"$deprecated_attr$::google::protobuf::RepeatedPtrField< $type$ >*\\n\"\n    \"    mutable_$name$();\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::\nGenerateDependentAccessorDeclarations(io::Printer* printer) const {\n  if (dependent_getter_) {\n    printer->Print(variables_,\n      \"$deprecated_attr$const $type$& $name$(int index) const;\\n\");\n  }\n  if (dependent_field_) {\n    InternalGenerateTypeDependentAccessorDeclarations(printer);\n  }\n}\n\nvoid RepeatedMessageFieldGenerator::\nGenerateAccessorDeclarations(io::Printer* printer) const {\n  if (!dependent_getter_) {\n    printer->Print(variables_,\n      \"$deprecated_attr$const $type$& $name$(int index) const;\\n\");\n  }\n  if (!dependent_field_) {\n    InternalGenerateTypeDependentAccessorDeclarations(printer);\n  }\n  if (!dependent_getter_) {\n    printer->Print(variables_,\n      \"$deprecated_attr$const ::google::protobuf::RepeatedPtrField< $type$ >&\\n\"\n      \"    $name$() const;\\n\");\n  }\n}\n\nvoid RepeatedMessageFieldGenerator::\nGenerateDependentInlineAccessorDefinitions(io::Printer* printer) const {\n  if (!dependent_field_) {\n    return;\n  }\n  map<string, string> variables(variables_);\n  // For the CRTP base class, all mutation methods are dependent, and so\n  // they must be in the header.\n  variables[\"dependent_classname\"] =\n      DependentBaseClassTemplateName(descriptor_->containing_type()) + \"<T>\";\n  variables[\"this_message\"] = DependentBaseDownCast();\n  variables[\"this_const_message\"] = DependentBaseConstDownCast();\n\n  if (dependent_getter_) {\n    printer->Print(variables,\n      \"template <class T>\\n\"\n      \"inline const $type$& $dependent_classname$::$name$(int index) const {\\n\"\n      \"  // @@protoc_insertion_point(field_get:$full_name$)\\n\"\n      \"  return $this_const_message$$name$_.$cppget$(index);\\n\"\n      \"}\\n\");\n  }\n\n  // Generate per-element accessors:\n  printer->Print(variables,\n    \"template <class T>\\n\"\n    \"inline $type$* $dependent_classname$::mutable_$name$(int index) {\\n\"\n    // TODO(dlj): move insertion points\n    \"  // @@protoc_insertion_point(field_mutable:$full_name$)\\n\"\n    \"  return $this_message$$name$_.Mutable(index);\\n\"\n    \"}\\n\"\n    \"template <class T>\\n\"\n    \"inline $type$* $dependent_classname$::add_$name$() {\\n\"\n    \"  // @@protoc_insertion_point(field_add:$full_name$)\\n\"\n    \"  return $this_message$$name$_.Add();\\n\"\n    \"}\\n\");\n\n\n  if (dependent_getter_) {\n    printer->Print(variables,\n      \"template <class T>\\n\"\n      \"inline const ::google::protobuf::RepeatedPtrField< $type$ >&\\n\"\n      \"$dependent_classname$::$name$() const {\\n\"\n      \"  // @@protoc_insertion_point(field_list:$full_name$)\\n\"\n      \"  return $this_const_message$$name$_;\\n\"\n      \"}\\n\");\n  }\n\n  // Generate mutable access to the entire list:\n  printer->Print(variables,\n    \"template <class T>\\n\"\n    \"inline ::google::protobuf::RepeatedPtrField< $type$ >*\\n\"\n    \"$dependent_classname$::mutable_$name$() {\\n\"\n    \"  // @@protoc_insertion_point(field_mutable_list:$full_name$)\\n\"\n    \"  return &$this_message$$name$_;\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::\nGenerateInlineAccessorDefinitions(io::Printer* printer,\n                                  bool is_inline) const {\n  map<string, string> variables(variables_);\n  variables[\"inline\"] = is_inline ? \"inline \" : \"\";\n\n  if (!dependent_getter_) {\n    printer->Print(variables,\n      \"$inline$\"\n      \"const $type$& $classname$::$name$(int index) const {\\n\"\n      \"  // @@protoc_insertion_point(field_get:$full_name$)\\n\"\n      \"  return $name$_.$cppget$(index);\\n\"\n      \"}\\n\");\n  }\n\n  if (!dependent_field_) {\n    printer->Print(variables,\n      \"$inline$\"\n      \"$type$* $classname$::mutable_$name$(int index) {\\n\"\n      // TODO(dlj): move insertion points\n      \"  // @@protoc_insertion_point(field_mutable:$full_name$)\\n\"\n      \"  return $name$_.Mutable(index);\\n\"\n      \"}\\n\"\n      \"$inline$\"\n      \"$type$* $classname$::add_$name$() {\\n\"\n      \"  // @@protoc_insertion_point(field_add:$full_name$)\\n\"\n      \"  return $name$_.Add();\\n\"\n      \"}\\n\");\n  }\n\n\n  if (!dependent_field_) {\n    printer->Print(variables,\n      \"$inline$\"\n      \"::google::protobuf::RepeatedPtrField< $type$ >*\\n\"\n      \"$classname$::mutable_$name$() {\\n\"\n      \"  // @@protoc_insertion_point(field_mutable_list:$full_name$)\\n\"\n      \"  return &$name$_;\\n\"\n      \"}\\n\");\n  }\n  if (!dependent_getter_) {\n    printer->Print(variables,\n      \"$inline$\"\n      \"const ::google::protobuf::RepeatedPtrField< $type$ >&\\n\"\n      \"$classname$::$name$() const {\\n\"\n      \"  // @@protoc_insertion_point(field_list:$full_name$)\\n\"\n      \"  return $name$_;\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid RepeatedMessageFieldGenerator::\nGenerateClearingCode(io::Printer* printer) const {\n  map<string, string> variables(variables_);\n  variables[\"this_message\"] = dependent_field_ ? DependentBaseDownCast() : \"\";\n  printer->Print(variables, \"$this_message$$name$_.Clear();\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_.MergeFrom(from.$name$_);\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::\nGenerateSwappingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_.UnsafeArenaSwap(&other->$name$_);\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::\nGenerateConstructorCode(io::Printer* printer) const {\n  // Not needed for repeated fields.\n}\n\nvoid RepeatedMessageFieldGenerator::\nGenerateMergeFromCodedStream(io::Printer* printer) const {\n  if (descriptor_->type() == FieldDescriptor::TYPE_MESSAGE) {\n    printer->Print(variables_,\n      \"DO_(::google::protobuf::internal::WireFormatLite::\"\n      \"ReadMessageNoVirtualNoRecursionDepth(\\n\"\n      \"      input, add_$name$()));\\n\");\n  } else {\n    printer->Print(variables_,\n      \"DO_(::google::protobuf::internal::WireFormatLite::\"\n      \"ReadGroupNoVirtualNoRecursionDepth(\\n\"\n      \"      $number$, input, add_$name$()));\\n\");\n  }\n}\n\nvoid RepeatedMessageFieldGenerator::\nGenerateSerializeWithCachedSizes(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"for (unsigned int i = 0, n = this->$name$_size(); i < n; i++) {\\n\"\n    \"  ::google::protobuf::internal::WireFormatLite::Write$stream_writer$(\\n\"\n    \"    $number$, this->$name$(i), output);\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::\nGenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"for (unsigned int i = 0, n = this->$name$_size(); i < n; i++) {\\n\"\n    \"  target = ::google::protobuf::internal::WireFormatLite::\\n\"\n    \"    InternalWrite$declared_type$NoVirtualToArray(\\n\"\n    \"      $number$, this->$name$(i), false, target);\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::\nGenerateByteSize(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"total_size += $tag_size$ * this->$name$_size();\\n\"\n    \"for (int i = 0; i < this->$name$_size(); i++) {\\n\"\n    \"  total_size +=\\n\"\n    \"    ::google::protobuf::internal::WireFormatLite::$declared_type$SizeNoVirtual(\\n\"\n    \"      this->$name$(i));\\n\"\n    \"}\\n\");\n}\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_message_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__\n\n#include <map>\n#include <string>\n#include <google/protobuf/compiler/cpp/cpp_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\nclass MessageFieldGenerator : public FieldGenerator {\n public:\n  MessageFieldGenerator(const FieldDescriptor* descriptor,\n                        const Options& options);\n  ~MessageFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  void GeneratePrivateMembers(io::Printer* printer) const;\n  void GenerateDependentAccessorDeclarations(io::Printer* printer) const;\n  void GenerateAccessorDeclarations(io::Printer* printer) const;\n  void GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const;\n  void GenerateInlineAccessorDefinitions(io::Printer* printer,\n                                         bool is_inline) const;\n  void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const;\n  void GenerateClearingCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateSwappingCode(io::Printer* printer) const;\n  void GenerateConstructorCode(io::Printer* printer) const;\n  void GenerateMergeFromCodedStream(io::Printer* printer) const;\n  void GenerateSerializeWithCachedSizes(io::Printer* printer) const;\n  void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;\n  void GenerateByteSize(io::Printer* printer) const;\n\n protected:\n  void GenerateArenaManipulationCode(const map<string, string>& variables,\n                                     io::Printer* printer) const;\n\n  virtual void GenerateGetterDeclaration(io::Printer* printer) const;\n\n  const FieldDescriptor* descriptor_;\n  const bool dependent_field_;\n  map<string, string> variables_;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator);\n};\n\nclass MessageOneofFieldGenerator : public MessageFieldGenerator {\n public:\n  MessageOneofFieldGenerator(const FieldDescriptor* descriptor,\n                             const Options& options);\n  ~MessageOneofFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  void GenerateDependentAccessorDeclarations(io::Printer* printer) const;\n  void GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const;\n  void GenerateInlineAccessorDefinitions(io::Printer* printer,\n                                         bool is_inline) const;\n  void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const;\n  void GenerateClearingCode(io::Printer* printer) const;\n  void GenerateSwappingCode(io::Printer* printer) const;\n  void GenerateConstructorCode(io::Printer* printer) const;\n\n protected:\n  void GenerateGetterDeclaration(io::Printer* printer) const;\n\n private:\n  void InternalGenerateInlineAccessorDefinitions(\n      const map<string, string>& variables, io::Printer* printer) const;\n\n  const bool dependent_base_;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageOneofFieldGenerator);\n};\n\nclass RepeatedMessageFieldGenerator : public FieldGenerator {\n public:\n  RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor,\n                                const Options& options);\n  ~RepeatedMessageFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  void GeneratePrivateMembers(io::Printer* printer) const;\n  void GenerateDependentAccessorDeclarations(io::Printer* printer) const;\n  void GenerateAccessorDeclarations(io::Printer* printer) const;\n  void GenerateDependentInlineAccessorDefinitions(io::Printer* printer) const;\n  void GenerateInlineAccessorDefinitions(io::Printer* printer,\n                                         bool is_inline) const;\n  void GenerateClearingCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateSwappingCode(io::Printer* printer) const;\n  void GenerateConstructorCode(io::Printer* printer) const;\n  void GenerateMergeFromCodedStream(io::Printer* printer) const;\n  void GenerateSerializeWithCachedSizes(io::Printer* printer) const;\n  void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;\n  void GenerateByteSize(io::Printer* printer) const;\n\n private:\n  void InternalGenerateTypeDependentAccessorDeclarations(\n      io::Printer* printer) const;\n\n  const FieldDescriptor* descriptor_;\n  const bool dependent_field_;\n  const bool dependent_getter_;\n  map<string, string> variables_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator);\n};\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_CPP_MESSAGE_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_options.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: rennie@google.com (Jeffrey Rennie)\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__\n#define GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__\n\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\n// Generator options (see generator.cc for a description of each):\nstruct Options {\n  Options()\n      : safe_boundary_check(false),\n        proto_h(false),\n        allow_import_public(true),\n        annotate_headers(false),\n        enforce_lite(false) {}\n\n  string dllexport_decl;\n  bool safe_boundary_check;\n  bool proto_h;\n  bool allow_import_public;\n  bool annotate_headers;\n  bool enforce_lite;\n  string annotation_pragma_name;\n  string annotation_guard_name;\n};\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//\n// TODO(kenton):  Share code with the versions of this test in other languages?\n//   It seemed like parameterizing it would add more complexity than it is\n//   worth.\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#include <google/protobuf/compiler/cpp/cpp_generator.h>\n#include <google/protobuf/compiler/command_line_interface.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/io/printer.h>\n\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\nnamespace {\n\nclass TestGenerator : public CodeGenerator {\n public:\n  TestGenerator() {}\n  ~TestGenerator() {}\n\n  virtual bool Generate(const FileDescriptor* file,\n                        const string& parameter,\n                        GeneratorContext* context,\n                        string* error) const {\n    TryInsert(\"test.pb.h\", \"includes\", context);\n    TryInsert(\"test.pb.h\", \"namespace_scope\", context);\n    TryInsert(\"test.pb.h\", \"global_scope\", context);\n    TryInsert(\"test.pb.h\", \"class_scope:foo.Bar\", context);\n    TryInsert(\"test.pb.h\", \"class_scope:foo.Bar.Baz\", context);\n\n    TryInsert(\"test.pb.cc\", \"includes\", context);\n    TryInsert(\"test.pb.cc\", \"namespace_scope\", context);\n    TryInsert(\"test.pb.cc\", \"global_scope\", context);\n\n    // Check field accessors for an optional int32:\n    TryInsert(\"test.pb.h\", \"field_get:foo.Bar.optInt\", context);\n    TryInsert(\"test.pb.h\", \"field_set:foo.Bar.optInt\", context);\n\n    // Check field accessors for a repeated int32:\n    TryInsert(\"test.pb.h\", \"field_get:foo.Bar.repeatedInt\", context);\n    TryInsert(\"test.pb.h\", \"field_set:foo.Bar.repeatedInt\", context);\n\n    // Check field accessors for a required string:\n    TryInsert(\"test.pb.h\", \"field_get:foo.Bar.requiredString\", context);\n    TryInsert(\"test.pb.h\", \"field_set:foo.Bar.requiredString\", context);\n    TryInsert(\"test.pb.h\", \"field_set_char:foo.Bar.requiredString\", context);\n    TryInsert(\"test.pb.h\", \"field_set_pointer:foo.Bar.requiredString\", context);\n    TryInsert(\"test.pb.h\", \"field_mutable:foo.Bar.requiredString\", context);\n    TryInsert(\"test.pb.h\", \"field_set_allocated:foo.Bar.requiredString\",\n              context);\n    TryInsert(\"test.pb.h\", \"field_set_char:foo.Bar.requiredString\", context);\n    TryInsert(\"test.pb.h\", \"field_set_pointer:foo.Bar.requiredString\", context);\n\n    // Check field accessors for a repeated string:\n    TryInsert(\"test.pb.h\", \"field_get:foo.Bar.repeatedString\", context);\n    TryInsert(\"test.pb.h\", \"field_set:foo.Bar.repeatedString\", context);\n    TryInsert(\"test.pb.h\", \"field_set_char:foo.Bar.repeatedString\", context);\n    TryInsert(\"test.pb.h\", \"field_set_pointer:foo.Bar.repeatedString\", context);\n    TryInsert(\"test.pb.h\", \"field_mutable:foo.Bar.repeatedString\", context);\n    TryInsert(\"test.pb.h\", \"field_set_char:foo.Bar.repeatedString\", context);\n    TryInsert(\"test.pb.h\", \"field_set_pointer:foo.Bar.repeatedString\", context);\n\n    // Check field accessors for an int inside oneof{}:\n    TryInsert(\"test.pb.h\", \"field_get:foo.Bar.oneOfInt\", context);\n    TryInsert(\"test.pb.h\", \"field_set:foo.Bar.oneOfInt\", context);\n\n    // Check field accessors for a string inside oneof{}:\n    TryInsert(\"test.pb.h\", \"field_get:foo.Bar.oneOfString\", context);\n    TryInsert(\"test.pb.h\", \"field_set:foo.Bar.oneOfString\", context);\n    TryInsert(\"test.pb.h\", \"field_set_char:foo.Bar.oneOfString\", context);\n    TryInsert(\"test.pb.h\", \"field_set_pointer:foo.Bar.oneOfString\", context);\n    TryInsert(\"test.pb.h\", \"field_mutable:foo.Bar.oneOfString\", context);\n    TryInsert(\"test.pb.h\", \"field_set_allocated:foo.Bar.oneOfString\", context);\n    TryInsert(\"test.pb.h\", \"field_set_char:foo.Bar.oneOfString\", context);\n    TryInsert(\"test.pb.h\", \"field_set_pointer:foo.Bar.oneOfString\", context);\n\n    // Check field accessors for an optional message:\n    TryInsert(\"test.pb.h\", \"field_get:foo.Bar.optMessage\", context);\n    TryInsert(\"test.pb.h\", \"field_mutable:foo.Bar.optMessage\", context);\n    TryInsert(\"test.pb.h\", \"field_set_allocated:foo.Bar.optMessage\", context);\n\n    // Check field accessors for a repeated message:\n    TryInsert(\"test.pb.h\", \"field_add:foo.Bar.repeatedMessage\", context);\n    TryInsert(\"test.pb.h\", \"field_get:foo.Bar.repeatedMessage\", context);\n    TryInsert(\"test.pb.h\", \"field_list:foo.Bar.repeatedMessage\", context);\n    TryInsert(\"test.pb.h\", \"field_mutable:foo.Bar.repeatedMessage\", context);\n    TryInsert(\"test.pb.h\", \"field_mutable_list:foo.Bar.repeatedMessage\",\n              context);\n\n    // Check field accessors for a message inside oneof{}:\n    TryInsert(\"test.pb.h\", \"field_get:foo.Bar.oneOfMessage\", context);\n    TryInsert(\"test.pb.h\", \"field_mutable:foo.Bar.oneOfMessage\", context);\n    TryInsert(\"test.pb.h\", \"field_set_allocated:foo.Bar.oneOfMessage\", context);\n\n    // Check field accessors for an optional enum:\n    TryInsert(\"test.pb.h\", \"field_get:foo.Bar.optEnum\", context);\n    TryInsert(\"test.pb.h\", \"field_set:foo.Bar.optEnum\", context);\n\n    // Check field accessors for a repeated enum:\n    TryInsert(\"test.pb.h\", \"field_get:foo.Bar.repeatedEnum\", context);\n    TryInsert(\"test.pb.h\", \"field_set:foo.Bar.repeatedEnum\", context);\n    TryInsert(\"test.pb.h\", \"field_add:foo.Bar.repeatedEnum\", context);\n    TryInsert(\"test.pb.h\", \"field_list:foo.Bar.repeatedEnum\", context);\n    TryInsert(\"test.pb.h\", \"field_mutable_list:foo.Bar.repeatedEnum\", context);\n\n    // Check field accessors for an enum inside oneof{}:\n    TryInsert(\"test.pb.h\", \"field_get:foo.Bar.oneOfEnum\", context);\n    TryInsert(\"test.pb.h\", \"field_set:foo.Bar.oneOfEnum\", context);\n\n    // Check field accessors for a required cord:\n    TryInsert(\"test.pb.h\", \"field_get:foo.Bar.requiredCord\", context);\n    TryInsert(\"test.pb.h\", \"field_set:foo.Bar.requiredCord\", context);\n    TryInsert(\"test.pb.h\", \"field_mutable:foo.Bar.requiredCord\", context);\n\n    // Check field accessors for a repeated cord:\n    TryInsert(\"test.pb.h\", \"field_get:foo.Bar.repeatedCord\", context);\n    TryInsert(\"test.pb.h\", \"field_set:foo.Bar.repeatedCord\", context);\n    TryInsert(\"test.pb.h\", \"field_add:foo.Bar.repeatedCord\", context);\n    TryInsert(\"test.pb.h\", \"field_list:foo.Bar.repeatedCord\", context);\n    TryInsert(\"test.pb.h\", \"field_mutable:foo.Bar.repeatedCord\", context);\n    TryInsert(\"test.pb.h\", \"field_mutable_list:foo.Bar.repeatedCord\", context);\n\n    // Check field accessors for a cord inside oneof{}:\n    TryInsert(\"test.pb.h\", \"field_get:foo.Bar.oneOfCord\", context);\n    TryInsert(\"test.pb.h\", \"field_set:foo.Bar.oneOfCord\", context);\n    TryInsert(\"test.pb.h\", \"field_mutable:foo.Bar.oneOfCord\", context);\n\n    return true;\n  }\n\n  void TryInsert(const string& filename, const string& insertion_point,\n                 GeneratorContext* context) const {\n    google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(\n        context->OpenForInsert(filename, insertion_point));\n    io::Printer printer(output.get(), '$');\n    printer.Print(\"// inserted $name$\\n\", \"name\", insertion_point);\n  }\n};\n\n// This test verifies that all the expected insertion points exist.  It does\n// not verify that they are correctly-placed; that would require actually\n// compiling the output which is a bit more than I care to do for this test.\nTEST(CppPluginTest, PluginTest) {\n  GOOGLE_CHECK_OK(File::SetContents(TestTempDir() + \"/test.proto\",\n                             \"syntax = \\\"proto2\\\";\\n\"\n                             \"package foo;\\n\"\n                             \"\\n\"\n                             \"enum Thud { VALUE = 0; }\\n\"\n                             \"\\n\"\n                             \"message Bar {\\n\"\n                             \"  message Baz {}\\n\"\n                             \"  optional int32 optInt = 1;\\n\"\n                             \"  repeated int32 repeatedInt = 2;\\n\"\n                             \"\\n\"\n                             \"  required string requiredString = 3;\\n\"\n                             \"  repeated string repeatedString = 4;\\n\"\n                             \"\\n\"\n                             \"  optional Baz optMessage = 6;\\n\"\n                             \"  repeated Baz repeatedMessage = 7;\\n\"\n                             \"\\n\"\n                             \"  optional Thud optEnum = 8;\\n\"\n                             \"  repeated Thud repeatedEnum = 9;\\n\"\n                             \"\\n\"\n                             \"  required string requiredCord = 10 [\\n\"\n                             \"    ctype = CORD\\n\"\n                             \"  ];\\n\"\n                             \"  repeated string repeatedCord = 11 [\\n\"\n                             \"    ctype = CORD\\n\"\n                             \"  ];\\n\"\n                             \"\\n\"\n                             \"  oneof Qux {\\n\"\n                             \"    int64 oneOfInt = 20;\\n\"\n                             \"    string oneOfString = 21;\\n\"\n                             \"    Baz oneOfMessage = 22;\\n\"\n                             \"    Thud oneOfEnum = 23;\"\n                             \"    string oneOfCord = 24 [\\n\"\n                             \"      ctype = CORD\\n\"\n                             \"    ];\\n\"\n                             \"  }\\n\"\n                             \"}\\n\",\n                             true));\n\n  google::protobuf::compiler::CommandLineInterface cli;\n  cli.SetInputsAreProtoPathRelative(true);\n\n  CppGenerator cpp_generator;\n  TestGenerator test_generator;\n  cli.RegisterGenerator(\"--cpp_out\", &cpp_generator, \"\");\n  cli.RegisterGenerator(\"--test_out\", &test_generator, \"\");\n\n  string proto_path = \"-I\" + TestTempDir();\n  string cpp_out = \"--cpp_out=\" + TestTempDir();\n  string test_out = \"--test_out=\" + TestTempDir();\n\n  const char* argv[] = {\n    \"protoc\",\n    proto_path.c_str(),\n    cpp_out.c_str(),\n    test_out.c_str(),\n    \"test.proto\"\n  };\n\n  EXPECT_EQ(0, cli.Run(5, argv));\n}\n\n}  // namespace\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/cpp/cpp_primitive_field.h>\n#include <google/protobuf/compiler/cpp/cpp_helpers.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\nusing internal::WireFormatLite;\n\nnamespace {\n\n// For encodings with fixed sizes, returns that size in bytes.  Otherwise\n// returns -1.\nint FixedSize(FieldDescriptor::Type type) {\n  switch (type) {\n    case FieldDescriptor::TYPE_INT32   : return -1;\n    case FieldDescriptor::TYPE_INT64   : return -1;\n    case FieldDescriptor::TYPE_UINT32  : return -1;\n    case FieldDescriptor::TYPE_UINT64  : return -1;\n    case FieldDescriptor::TYPE_SINT32  : return -1;\n    case FieldDescriptor::TYPE_SINT64  : return -1;\n    case FieldDescriptor::TYPE_FIXED32 : return WireFormatLite::kFixed32Size;\n    case FieldDescriptor::TYPE_FIXED64 : return WireFormatLite::kFixed64Size;\n    case FieldDescriptor::TYPE_SFIXED32: return WireFormatLite::kSFixed32Size;\n    case FieldDescriptor::TYPE_SFIXED64: return WireFormatLite::kSFixed64Size;\n    case FieldDescriptor::TYPE_FLOAT   : return WireFormatLite::kFloatSize;\n    case FieldDescriptor::TYPE_DOUBLE  : return WireFormatLite::kDoubleSize;\n\n    case FieldDescriptor::TYPE_BOOL    : return WireFormatLite::kBoolSize;\n    case FieldDescriptor::TYPE_ENUM    : return -1;\n\n    case FieldDescriptor::TYPE_STRING  : return -1;\n    case FieldDescriptor::TYPE_BYTES   : return -1;\n    case FieldDescriptor::TYPE_GROUP   : return -1;\n    case FieldDescriptor::TYPE_MESSAGE : return -1;\n\n    // No default because we want the compiler to complain if any new\n    // types are added.\n  }\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return -1;\n}\n\nvoid SetPrimitiveVariables(const FieldDescriptor* descriptor,\n                           map<string, string>* variables,\n                           const Options& options) {\n  SetCommonFieldVariables(descriptor, variables, options);\n  (*variables)[\"type\"] = PrimitiveTypeName(descriptor->cpp_type());\n  (*variables)[\"default\"] = DefaultValue(descriptor);\n  (*variables)[\"tag\"] = SimpleItoa(internal::WireFormat::MakeTag(descriptor));\n  int fixed_size = FixedSize(descriptor->type());\n  if (fixed_size != -1) {\n    (*variables)[\"fixed_size\"] = SimpleItoa(fixed_size);\n  }\n  (*variables)[\"wire_format_field_type\"] =\n      \"::google::protobuf::internal::WireFormatLite::\" + FieldDescriptorProto_Type_Name(\n          static_cast<FieldDescriptorProto_Type>(descriptor->type()));\n  (*variables)[\"full_name\"] = descriptor->full_name();\n}\n\n}  // namespace\n\n// ===================================================================\n\nPrimitiveFieldGenerator::PrimitiveFieldGenerator(\n    const FieldDescriptor* descriptor, const Options& options)\n    : FieldGenerator(options), descriptor_(descriptor) {\n  SetPrimitiveVariables(descriptor, &variables_, options);\n}\n\nPrimitiveFieldGenerator::~PrimitiveFieldGenerator() {}\n\nvoid PrimitiveFieldGenerator::\nGeneratePrivateMembers(io::Printer* printer) const {\n  printer->Print(variables_, \"$type$ $name$_;\\n\");\n}\n\nvoid PrimitiveFieldGenerator::\nGenerateAccessorDeclarations(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$deprecated_attr$$type$ $name$() const;\\n\"\n    \"$deprecated_attr$void set_$name$($type$ value);\\n\");\n}\n\nvoid PrimitiveFieldGenerator::\nGenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const {\n  map<string, string> variables(variables_);\n  variables[\"inline\"] = is_inline ? \"inline\" : \"\";\n  printer->Print(variables,\n    \"$inline$ $type$ $classname$::$name$() const {\\n\"\n    \"  // @@protoc_insertion_point(field_get:$full_name$)\\n\"\n    \"  return $name$_;\\n\"\n    \"}\\n\"\n    \"$inline$ void $classname$::set_$name$($type$ value) {\\n\"\n    \"  $set_hasbit$\\n\"\n    \"  $name$_ = value;\\n\"\n    \"  // @@protoc_insertion_point(field_set:$full_name$)\\n\"\n    \"}\\n\");\n}\n\nvoid PrimitiveFieldGenerator::\nGenerateClearingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_ = $default$;\\n\");\n}\n\nvoid PrimitiveFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"set_$name$(from.$name$());\\n\");\n}\n\nvoid PrimitiveFieldGenerator::\nGenerateSwappingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"std::swap($name$_, other->$name$_);\\n\");\n}\n\nvoid PrimitiveFieldGenerator::\nGenerateConstructorCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_ = $default$;\\n\");\n}\n\nvoid PrimitiveFieldGenerator::\nGenerateMergeFromCodedStream(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\\n\"\n    \"         $type$, $wire_format_field_type$>(\\n\"\n    \"       input, &$name$_)));\\n\"\n    \"$set_hasbit$\\n\");\n}\n\nvoid PrimitiveFieldGenerator::\nGenerateSerializeWithCachedSizes(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"::google::protobuf::internal::WireFormatLite::Write$declared_type$(\"\n      \"$number$, this->$name$(), output);\\n\");\n}\n\nvoid PrimitiveFieldGenerator::\nGenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"target = ::google::protobuf::internal::WireFormatLite::Write$declared_type$ToArray(\"\n      \"$number$, this->$name$(), target);\\n\");\n}\n\nvoid PrimitiveFieldGenerator::\nGenerateByteSize(io::Printer* printer) const {\n  int fixed_size = FixedSize(descriptor_->type());\n  if (fixed_size == -1) {\n    printer->Print(variables_,\n      \"total_size += $tag_size$ +\\n\"\n      \"  ::google::protobuf::internal::WireFormatLite::$declared_type$Size(\\n\"\n      \"    this->$name$());\\n\");\n  } else {\n    printer->Print(variables_,\n      \"total_size += $tag_size$ + $fixed_size$;\\n\");\n  }\n}\n\n// ===================================================================\n\nPrimitiveOneofFieldGenerator::\nPrimitiveOneofFieldGenerator(const FieldDescriptor* descriptor,\n                             const Options& options)\n  : PrimitiveFieldGenerator(descriptor, options) {\n  SetCommonOneofFieldVariables(descriptor, &variables_);\n}\n\nPrimitiveOneofFieldGenerator::~PrimitiveOneofFieldGenerator() {}\n\nvoid PrimitiveOneofFieldGenerator::\nGenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const {\n  map<string, string> variables(variables_);\n  variables[\"inline\"] = is_inline ? \"inline\" : \"\";\n  printer->Print(variables,\n    \"$inline$ $type$ $classname$::$name$() const {\\n\"\n    \"  // @@protoc_insertion_point(field_get:$full_name$)\\n\"\n    \"  if (has_$name$()) {\\n\"\n    \"    return $oneof_prefix$$name$_;\\n\"\n    \"  }\\n\"\n    \"  return $default$;\\n\"\n    \"}\\n\"\n    \"$inline$ void $classname$::set_$name$($type$ value) {\\n\"\n    \"  if (!has_$name$()) {\\n\"\n    \"    clear_$oneof_name$();\\n\"\n    \"    set_has_$name$();\\n\"\n    \"  }\\n\"\n    \"  $oneof_prefix$$name$_ = value;\\n\"\n    \"  // @@protoc_insertion_point(field_set:$full_name$)\\n\"\n    \"}\\n\");\n}\n\nvoid PrimitiveOneofFieldGenerator::\nGenerateClearingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$oneof_prefix$$name$_ = $default$;\\n\");\n}\n\nvoid PrimitiveOneofFieldGenerator::\nGenerateSwappingCode(io::Printer* printer) const {\n  // Don't print any swapping code. Swapping the union will swap this field.\n}\n\nvoid PrimitiveOneofFieldGenerator::\nGenerateConstructorCode(io::Printer* printer) const {\n  printer->Print(\n      variables_,\n      \"  $classname$_default_oneof_instance_->$name$_ = $default$;\\n\");\n}\n\nvoid PrimitiveOneofFieldGenerator::\nGenerateMergeFromCodedStream(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"clear_$oneof_name$();\\n\"\n    \"DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\\n\"\n    \"         $type$, $wire_format_field_type$>(\\n\"\n    \"       input, &$oneof_prefix$$name$_)));\\n\"\n    \"set_has_$name$();\\n\");\n}\n\n// ===================================================================\n\nRepeatedPrimitiveFieldGenerator::RepeatedPrimitiveFieldGenerator(\n    const FieldDescriptor* descriptor, const Options& options)\n    : FieldGenerator(options), descriptor_(descriptor) {\n  SetPrimitiveVariables(descriptor, &variables_, options);\n\n  if (descriptor->is_packed()) {\n    variables_[\"packed_reader\"] = \"ReadPackedPrimitive\";\n    variables_[\"repeated_reader\"] = \"ReadRepeatedPrimitiveNoInline\";\n  } else {\n    variables_[\"packed_reader\"] = \"ReadPackedPrimitiveNoInline\";\n    variables_[\"repeated_reader\"] = \"ReadRepeatedPrimitive\";\n  }\n}\n\nRepeatedPrimitiveFieldGenerator::~RepeatedPrimitiveFieldGenerator() {}\n\nvoid RepeatedPrimitiveFieldGenerator::\nGeneratePrivateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"::google::protobuf::RepeatedField< $type$ > $name$_;\\n\");\n  if (descriptor_->is_packed() &&\n      HasGeneratedMethods(descriptor_->file(), options_)) {\n    printer->Print(variables_,\n      \"mutable int _$name$_cached_byte_size_;\\n\");\n  }\n}\n\nvoid RepeatedPrimitiveFieldGenerator::\nGenerateAccessorDeclarations(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$deprecated_attr$$type$ $name$(int index) const;\\n\"\n    \"$deprecated_attr$void set_$name$(int index, $type$ value);\\n\"\n    \"$deprecated_attr$void add_$name$($type$ value);\\n\");\n  printer->Print(variables_,\n    \"$deprecated_attr$const ::google::protobuf::RepeatedField< $type$ >&\\n\"\n    \"    $name$() const;\\n\"\n    \"$deprecated_attr$::google::protobuf::RepeatedField< $type$ >*\\n\"\n    \"    mutable_$name$();\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::\nGenerateInlineAccessorDefinitions(io::Printer* printer, bool is_inline) const {\n  map<string, string> variables(variables_);\n  variables[\"inline\"] = is_inline ? \"inline\" : \"\";\n  printer->Print(variables,\n    \"$inline$ $type$ $classname$::$name$(int index) const {\\n\"\n    \"  // @@protoc_insertion_point(field_get:$full_name$)\\n\"\n    \"  return $name$_.Get(index);\\n\"\n    \"}\\n\"\n    \"$inline$ void $classname$::set_$name$(int index, $type$ value) {\\n\"\n    \"  $name$_.Set(index, value);\\n\"\n    \"  // @@protoc_insertion_point(field_set:$full_name$)\\n\"\n    \"}\\n\"\n    \"$inline$ void $classname$::add_$name$($type$ value) {\\n\"\n    \"  $name$_.Add(value);\\n\"\n    \"  // @@protoc_insertion_point(field_add:$full_name$)\\n\"\n    \"}\\n\");\n  printer->Print(variables,\n    \"$inline$ const ::google::protobuf::RepeatedField< $type$ >&\\n\"\n    \"$classname$::$name$() const {\\n\"\n    \"  // @@protoc_insertion_point(field_list:$full_name$)\\n\"\n    \"  return $name$_;\\n\"\n    \"}\\n\"\n    \"$inline$ ::google::protobuf::RepeatedField< $type$ >*\\n\"\n    \"$classname$::mutable_$name$() {\\n\"\n    \"  // @@protoc_insertion_point(field_mutable_list:$full_name$)\\n\"\n    \"  return &$name$_;\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::\nGenerateClearingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_.Clear();\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_.MergeFrom(from.$name$_);\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::\nGenerateSwappingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_.UnsafeArenaSwap(&other->$name$_);\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::\nGenerateConstructorCode(io::Printer* printer) const {\n  // Not needed for repeated fields.\n}\n\nvoid RepeatedPrimitiveFieldGenerator::\nGenerateMergeFromCodedStream(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"DO_((::google::protobuf::internal::WireFormatLite::$repeated_reader$<\\n\"\n    \"         $type$, $wire_format_field_type$>(\\n\"\n    \"       $tag_size$, $tag$, input, this->mutable_$name$())));\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::\nGenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"DO_((::google::protobuf::internal::WireFormatLite::$packed_reader$<\\n\"\n    \"         $type$, $wire_format_field_type$>(\\n\"\n    \"       input, this->mutable_$name$())));\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::\nGenerateSerializeWithCachedSizes(io::Printer* printer) const {\n  if (descriptor_->is_packed()) {\n    // Write the tag and the size.\n    printer->Print(variables_,\n      \"if (this->$name$_size() > 0) {\\n\"\n      \"  ::google::protobuf::internal::WireFormatLite::WriteTag(\"\n          \"$number$, \"\n          \"::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, \"\n          \"output);\\n\"\n      \"  output->WriteVarint32(_$name$_cached_byte_size_);\\n\"\n      \"}\\n\");\n  }\n  printer->Print(variables_,\n      \"for (int i = 0; i < this->$name$_size(); i++) {\\n\");\n  if (descriptor_->is_packed()) {\n    printer->Print(variables_,\n      \"  ::google::protobuf::internal::WireFormatLite::Write$declared_type$NoTag(\\n\"\n      \"    this->$name$(i), output);\\n\");\n  } else {\n    printer->Print(variables_,\n      \"  ::google::protobuf::internal::WireFormatLite::Write$declared_type$(\\n\"\n      \"    $number$, this->$name$(i), output);\\n\");\n  }\n  printer->Print(\"}\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::\nGenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {\n  if (descriptor_->is_packed()) {\n    // Write the tag and the size.\n    printer->Print(variables_,\n      \"if (this->$name$_size() > 0) {\\n\"\n      \"  target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray(\\n\"\n      \"    $number$,\\n\"\n      \"    ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\\n\"\n      \"    target);\\n\"\n      \"  target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(\\n\"\n      \"    _$name$_cached_byte_size_, target);\\n\"\n      \"}\\n\");\n  }\n  printer->Print(variables_,\n      \"for (int i = 0; i < this->$name$_size(); i++) {\\n\");\n  if (descriptor_->is_packed()) {\n    printer->Print(variables_,\n      \"  target = ::google::protobuf::internal::WireFormatLite::\\n\"\n      \"    Write$declared_type$NoTagToArray(this->$name$(i), target);\\n\");\n  } else {\n    printer->Print(variables_,\n      \"  target = ::google::protobuf::internal::WireFormatLite::\\n\"\n      \"    Write$declared_type$ToArray($number$, this->$name$(i), target);\\n\");\n  }\n  printer->Print(\"}\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::\nGenerateByteSize(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"{\\n\"\n    \"  int data_size = 0;\\n\");\n  printer->Indent();\n  int fixed_size = FixedSize(descriptor_->type());\n  if (fixed_size == -1) {\n    printer->Print(variables_,\n      \"for (int i = 0; i < this->$name$_size(); i++) {\\n\"\n      \"  data_size += ::google::protobuf::internal::WireFormatLite::\\n\"\n      \"    $declared_type$Size(this->$name$(i));\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables_,\n      \"data_size = $fixed_size$ * this->$name$_size();\\n\");\n  }\n\n  if (descriptor_->is_packed()) {\n    printer->Print(variables_,\n      \"if (data_size > 0) {\\n\"\n      \"  total_size += $tag_size$ +\\n\"\n      \"    ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);\\n\"\n      \"}\\n\"\n      \"GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\\n\"\n      \"_$name$_cached_byte_size_ = data_size;\\n\"\n      \"GOOGLE_SAFE_CONCURRENT_WRITES_END();\\n\"\n      \"total_size += data_size;\\n\");\n  } else {\n    printer->Print(variables_,\n      \"total_size += $tag_size$ * this->$name$_size() + data_size;\\n\");\n  }\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_primitive_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_PRIMITIVE_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_CPP_PRIMITIVE_FIELD_H__\n\n#include <map>\n#include <string>\n#include <google/protobuf/compiler/cpp/cpp_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\nclass PrimitiveFieldGenerator : public FieldGenerator {\n public:\n  PrimitiveFieldGenerator(const FieldDescriptor* descriptor,\n                          const Options& options);\n  ~PrimitiveFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  void GeneratePrivateMembers(io::Printer* printer) const;\n  void GenerateAccessorDeclarations(io::Printer* printer) const;\n  void GenerateInlineAccessorDefinitions(io::Printer* printer,\n                                         bool is_inline) const;\n  void GenerateClearingCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateSwappingCode(io::Printer* printer) const;\n  void GenerateConstructorCode(io::Printer* printer) const;\n  void GenerateMergeFromCodedStream(io::Printer* printer) const;\n  void GenerateSerializeWithCachedSizes(io::Printer* printer) const;\n  void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;\n  void GenerateByteSize(io::Printer* printer) const;\n\n protected:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator);\n};\n\nclass PrimitiveOneofFieldGenerator : public PrimitiveFieldGenerator {\n public:\n  PrimitiveOneofFieldGenerator(const FieldDescriptor* descriptor,\n                               const Options& options);\n  ~PrimitiveOneofFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  void GenerateInlineAccessorDefinitions(io::Printer* printer,\n                                         bool is_inline) const;\n  void GenerateClearingCode(io::Printer* printer) const;\n  void GenerateSwappingCode(io::Printer* printer) const;\n  void GenerateConstructorCode(io::Printer* printer) const;\n  void GenerateMergeFromCodedStream(io::Printer* printer) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveOneofFieldGenerator);\n};\n\nclass RepeatedPrimitiveFieldGenerator : public FieldGenerator {\n public:\n  RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor,\n                                  const Options& options);\n  ~RepeatedPrimitiveFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  void GeneratePrivateMembers(io::Printer* printer) const;\n  void GenerateAccessorDeclarations(io::Printer* printer) const;\n  void GenerateInlineAccessorDefinitions(io::Printer* printer,\n                                         bool is_inline) const;\n  void GenerateClearingCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateSwappingCode(io::Printer* printer) const;\n  void GenerateConstructorCode(io::Printer* printer) const;\n  void GenerateMergeFromCodedStream(io::Printer* printer) const;\n  void GenerateMergeFromCodedStreamWithPacking(io::Printer* printer) const;\n  void GenerateSerializeWithCachedSizes(io::Printer* printer) const;\n  void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;\n  void GenerateByteSize(io::Printer* printer) const;\n\n private:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPrimitiveFieldGenerator);\n};\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_CPP_PRIMITIVE_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_service.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/cpp/cpp_service.h>\n#include <google/protobuf/compiler/cpp/cpp_helpers.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\nServiceGenerator::ServiceGenerator(const ServiceDescriptor* descriptor,\n                                   const Options& options)\n  : descriptor_(descriptor) {\n  vars_[\"classname\"] = descriptor_->name();\n  vars_[\"full_name\"] = descriptor_->full_name();\n  if (options.dllexport_decl.empty()) {\n    vars_[\"dllexport\"] = \"\";\n  } else {\n    vars_[\"dllexport\"] = options.dllexport_decl + \" \";\n  }\n}\n\nServiceGenerator::~ServiceGenerator() {}\n\nvoid ServiceGenerator::GenerateDeclarations(io::Printer* printer) {\n  // Forward-declare the stub type.\n  printer->Print(vars_,\n    \"class $classname$_Stub;\\n\"\n    \"\\n\");\n\n  GenerateInterface(printer);\n  GenerateStubDefinition(printer);\n}\n\nvoid ServiceGenerator::GenerateInterface(io::Printer* printer) {\n  printer->Print(vars_,\n    \"class $dllexport$$classname$ : public ::google::protobuf::Service {\\n\"\n    \" protected:\\n\"\n    \"  // This class should be treated as an abstract interface.\\n\"\n    \"  inline $classname$() {};\\n\"\n    \" public:\\n\"\n    \"  virtual ~$classname$();\\n\");\n  printer->Indent();\n\n  printer->Print(vars_,\n    \"\\n\"\n    \"typedef $classname$_Stub Stub;\\n\"\n    \"\\n\"\n    \"static const ::google::protobuf::ServiceDescriptor* descriptor();\\n\"\n    \"\\n\");\n\n  GenerateMethodSignatures(VIRTUAL, printer);\n\n  printer->Print(\n    \"\\n\"\n    \"// implements Service ----------------------------------------------\\n\"\n    \"\\n\"\n    \"const ::google::protobuf::ServiceDescriptor* GetDescriptor();\\n\"\n    \"void CallMethod(const ::google::protobuf::MethodDescriptor* method,\\n\"\n    \"                ::google::protobuf::RpcController* controller,\\n\"\n    \"                const ::google::protobuf::Message* request,\\n\"\n    \"                ::google::protobuf::Message* response,\\n\"\n    \"                ::google::protobuf::Closure* done);\\n\"\n    \"const ::google::protobuf::Message& GetRequestPrototype(\\n\"\n    \"  const ::google::protobuf::MethodDescriptor* method) const;\\n\"\n    \"const ::google::protobuf::Message& GetResponsePrototype(\\n\"\n    \"  const ::google::protobuf::MethodDescriptor* method) const;\\n\");\n\n  printer->Outdent();\n  printer->Print(vars_,\n    \"\\n\"\n    \" private:\\n\"\n    \"  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS($classname$);\\n\"\n    \"};\\n\"\n    \"\\n\");\n}\n\nvoid ServiceGenerator::GenerateStubDefinition(io::Printer* printer) {\n  printer->Print(vars_,\n    \"class $dllexport$$classname$_Stub : public $classname$ {\\n\"\n    \" public:\\n\");\n\n  printer->Indent();\n\n  printer->Print(vars_,\n    \"$classname$_Stub(::google::protobuf::RpcChannel* channel);\\n\"\n    \"$classname$_Stub(::google::protobuf::RpcChannel* channel,\\n\"\n    \"                 ::google::protobuf::Service::ChannelOwnership ownership);\\n\"\n    \"~$classname$_Stub();\\n\"\n    \"\\n\"\n    \"inline ::google::protobuf::RpcChannel* channel() { return channel_; }\\n\"\n    \"\\n\"\n    \"// implements $classname$ ------------------------------------------\\n\"\n    \"\\n\");\n\n  GenerateMethodSignatures(NON_VIRTUAL, printer);\n\n  printer->Outdent();\n  printer->Print(vars_,\n    \" private:\\n\"\n    \"  ::google::protobuf::RpcChannel* channel_;\\n\"\n    \"  bool owns_channel_;\\n\"\n    \"  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS($classname$_Stub);\\n\"\n    \"};\\n\"\n    \"\\n\");\n}\n\nvoid ServiceGenerator::GenerateMethodSignatures(\n    VirtualOrNon virtual_or_non, io::Printer* printer) {\n  for (int i = 0; i < descriptor_->method_count(); i++) {\n    const MethodDescriptor* method = descriptor_->method(i);\n    map<string, string> sub_vars;\n    sub_vars[\"name\"] = method->name();\n    sub_vars[\"input_type\"] = ClassName(method->input_type(), true);\n    sub_vars[\"output_type\"] = ClassName(method->output_type(), true);\n    sub_vars[\"virtual\"] = virtual_or_non == VIRTUAL ? \"virtual \" : \"\";\n\n    printer->Print(sub_vars,\n      \"$virtual$void $name$(::google::protobuf::RpcController* controller,\\n\"\n      \"                     const $input_type$* request,\\n\"\n      \"                     $output_type$* response,\\n\"\n      \"                     ::google::protobuf::Closure* done);\\n\");\n  }\n}\n\n// ===================================================================\n\nvoid ServiceGenerator::GenerateDescriptorInitializer(\n    io::Printer* printer, int index) {\n  map<string, string> vars;\n  vars[\"classname\"] = descriptor_->name();\n  vars[\"index\"] = SimpleItoa(index);\n\n  printer->Print(vars,\n    \"$classname$_descriptor_ = file->service($index$);\\n\");\n}\n\n// ===================================================================\n\nvoid ServiceGenerator::GenerateImplementation(io::Printer* printer) {\n  printer->Print(vars_,\n    \"$classname$::~$classname$() {}\\n\"\n    \"\\n\"\n    \"const ::google::protobuf::ServiceDescriptor* $classname$::descriptor() {\\n\"\n    \"  protobuf_AssignDescriptorsOnce();\\n\"\n    \"  return $classname$_descriptor_;\\n\"\n    \"}\\n\"\n    \"\\n\"\n    \"const ::google::protobuf::ServiceDescriptor* $classname$::GetDescriptor() {\\n\"\n    \"  protobuf_AssignDescriptorsOnce();\\n\"\n    \"  return $classname$_descriptor_;\\n\"\n    \"}\\n\"\n    \"\\n\");\n\n  // Generate methods of the interface.\n  GenerateNotImplementedMethods(printer);\n  GenerateCallMethod(printer);\n  GenerateGetPrototype(REQUEST, printer);\n  GenerateGetPrototype(RESPONSE, printer);\n\n  // Generate stub implementation.\n  printer->Print(vars_,\n    \"$classname$_Stub::$classname$_Stub(::google::protobuf::RpcChannel* channel)\\n\"\n    \"  : channel_(channel), owns_channel_(false) {}\\n\"\n    \"$classname$_Stub::$classname$_Stub(\\n\"\n    \"    ::google::protobuf::RpcChannel* channel,\\n\"\n    \"    ::google::protobuf::Service::ChannelOwnership ownership)\\n\"\n    \"  : channel_(channel),\\n\"\n    \"    owns_channel_(ownership == ::google::protobuf::Service::STUB_OWNS_CHANNEL) {}\\n\"\n    \"$classname$_Stub::~$classname$_Stub() {\\n\"\n    \"  if (owns_channel_) delete channel_;\\n\"\n    \"}\\n\"\n    \"\\n\");\n\n  GenerateStubMethods(printer);\n}\n\nvoid ServiceGenerator::GenerateNotImplementedMethods(io::Printer* printer) {\n  for (int i = 0; i < descriptor_->method_count(); i++) {\n    const MethodDescriptor* method = descriptor_->method(i);\n    map<string, string> sub_vars;\n    sub_vars[\"classname\"] = descriptor_->name();\n    sub_vars[\"name\"] = method->name();\n    sub_vars[\"index\"] = SimpleItoa(i);\n    sub_vars[\"input_type\"] = ClassName(method->input_type(), true);\n    sub_vars[\"output_type\"] = ClassName(method->output_type(), true);\n\n    printer->Print(sub_vars,\n      \"void $classname$::$name$(::google::protobuf::RpcController* controller,\\n\"\n      \"                         const $input_type$*,\\n\"\n      \"                         $output_type$*,\\n\"\n      \"                         ::google::protobuf::Closure* done) {\\n\"\n      \"  controller->SetFailed(\\\"Method $name$() not implemented.\\\");\\n\"\n      \"  done->Run();\\n\"\n      \"}\\n\"\n      \"\\n\");\n  }\n}\n\nvoid ServiceGenerator::GenerateCallMethod(io::Printer* printer) {\n  printer->Print(vars_,\n    \"void $classname$::CallMethod(const ::google::protobuf::MethodDescriptor* method,\\n\"\n    \"                             ::google::protobuf::RpcController* controller,\\n\"\n    \"                             const ::google::protobuf::Message* request,\\n\"\n    \"                             ::google::protobuf::Message* response,\\n\"\n    \"                             ::google::protobuf::Closure* done) {\\n\"\n    \"  GOOGLE_DCHECK_EQ(method->service(), $classname$_descriptor_);\\n\"\n    \"  switch(method->index()) {\\n\");\n\n  for (int i = 0; i < descriptor_->method_count(); i++) {\n    const MethodDescriptor* method = descriptor_->method(i);\n    map<string, string> sub_vars;\n    sub_vars[\"name\"] = method->name();\n    sub_vars[\"index\"] = SimpleItoa(i);\n    sub_vars[\"input_type\"] = ClassName(method->input_type(), true);\n    sub_vars[\"output_type\"] = ClassName(method->output_type(), true);\n\n    // Note:  down_cast does not work here because it only works on pointers,\n    //   not references.\n    printer->Print(sub_vars,\n      \"    case $index$:\\n\"\n      \"      $name$(controller,\\n\"\n      \"             ::google::protobuf::down_cast<const $input_type$*>(request),\\n\"\n      \"             ::google::protobuf::down_cast< $output_type$*>(response),\\n\"\n      \"             done);\\n\"\n      \"      break;\\n\");\n  }\n\n  printer->Print(vars_,\n    \"    default:\\n\"\n    \"      GOOGLE_LOG(FATAL) << \\\"Bad method index; this should never happen.\\\";\\n\"\n    \"      break;\\n\"\n    \"  }\\n\"\n    \"}\\n\"\n    \"\\n\");\n}\n\nvoid ServiceGenerator::GenerateGetPrototype(RequestOrResponse which,\n                                            io::Printer* printer) {\n  if (which == REQUEST) {\n    printer->Print(vars_,\n      \"const ::google::protobuf::Message& $classname$::GetRequestPrototype(\\n\");\n  } else {\n    printer->Print(vars_,\n      \"const ::google::protobuf::Message& $classname$::GetResponsePrototype(\\n\");\n  }\n\n  printer->Print(vars_,\n    \"    const ::google::protobuf::MethodDescriptor* method) const {\\n\"\n    \"  GOOGLE_DCHECK_EQ(method->service(), descriptor());\\n\"\n    \"  switch(method->index()) {\\n\");\n\n  for (int i = 0; i < descriptor_->method_count(); i++) {\n    const MethodDescriptor* method = descriptor_->method(i);\n    const Descriptor* type =\n      (which == REQUEST) ? method->input_type() : method->output_type();\n\n    map<string, string> sub_vars;\n    sub_vars[\"index\"] = SimpleItoa(i);\n    sub_vars[\"type\"] = ClassName(type, true);\n\n    printer->Print(sub_vars,\n      \"    case $index$:\\n\"\n      \"      return $type$::default_instance();\\n\");\n  }\n\n  printer->Print(\n    \"    default:\\n\"\n    \"      GOOGLE_LOG(FATAL) << \\\"Bad method index; this should never happen.\\\";\\n\"\n    \"      return *::google::protobuf::MessageFactory::generated_factory()\\n\"\n    \"          ->GetPrototype(method->$input_or_output$_type());\\n\"\n    \"  }\\n\"\n    \"}\\n\"\n    \"\\n\",\n    \"input_or_output\", which == REQUEST ? \"input\" : \"output\");\n}\n\nvoid ServiceGenerator::GenerateStubMethods(io::Printer* printer) {\n  for (int i = 0; i < descriptor_->method_count(); i++) {\n    const MethodDescriptor* method = descriptor_->method(i);\n    map<string, string> sub_vars;\n    sub_vars[\"classname\"] = descriptor_->name();\n    sub_vars[\"name\"] = method->name();\n    sub_vars[\"index\"] = SimpleItoa(i);\n    sub_vars[\"input_type\"] = ClassName(method->input_type(), true);\n    sub_vars[\"output_type\"] = ClassName(method->output_type(), true);\n\n    printer->Print(sub_vars,\n      \"void $classname$_Stub::$name$(::google::protobuf::RpcController* controller,\\n\"\n      \"                              const $input_type$* request,\\n\"\n      \"                              $output_type$* response,\\n\"\n      \"                              ::google::protobuf::Closure* done) {\\n\"\n      \"  channel_->CallMethod(descriptor()->method($index$),\\n\"\n      \"                       controller, request, response, done);\\n\"\n      \"}\\n\");\n  }\n}\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_service.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_SERVICE_H__\n#define GOOGLE_PROTOBUF_COMPILER_CPP_SERVICE_H__\n\n#include <map>\n#include <string>\n#include <google/protobuf/compiler/cpp/cpp_options.h>\n#include <google/protobuf/descriptor.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace io {\n    class Printer;             // printer.h\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\nclass ServiceGenerator {\n public:\n  // See generator.cc for the meaning of dllexport_decl.\n  explicit ServiceGenerator(const ServiceDescriptor* descriptor,\n                            const Options& options);\n  ~ServiceGenerator();\n\n  // Header stuff.\n\n  // Generate the class definitions for the service's interface and the\n  // stub implementation.\n  void GenerateDeclarations(io::Printer* printer);\n\n  // Source file stuff.\n\n  // Generate code that initializes the global variable storing the service's\n  // descriptor.\n  void GenerateDescriptorInitializer(io::Printer* printer, int index);\n\n  // Generate implementations of everything declared by GenerateDeclarations().\n  void GenerateImplementation(io::Printer* printer);\n\n private:\n  enum RequestOrResponse { REQUEST, RESPONSE };\n  enum VirtualOrNon { VIRTUAL, NON_VIRTUAL };\n\n  // Header stuff.\n\n  // Generate the service abstract interface.\n  void GenerateInterface(io::Printer* printer);\n\n  // Generate the stub class definition.\n  void GenerateStubDefinition(io::Printer* printer);\n\n  // Prints signatures for all methods in the\n  void GenerateMethodSignatures(VirtualOrNon virtual_or_non,\n                                io::Printer* printer);\n\n  // Source file stuff.\n\n  // Generate the default implementations of the service methods, which\n  // produce a \"not implemented\" error.\n  void GenerateNotImplementedMethods(io::Printer* printer);\n\n  // Generate the CallMethod() method of the service.\n  void GenerateCallMethod(io::Printer* printer);\n\n  // Generate the Get{Request,Response}Prototype() methods.\n  void GenerateGetPrototype(RequestOrResponse which, io::Printer* printer);\n\n  // Generate the stub's implementations of the service methods.\n  void GenerateStubMethods(io::Printer* printer);\n\n  const ServiceDescriptor* descriptor_;\n  map<string, string> vars_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceGenerator);\n};\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_CPP_SERVICE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_string_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/cpp/cpp_string_field.h>\n#include <google/protobuf/compiler/cpp/cpp_helpers.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\nnamespace {\n\nvoid SetStringVariables(const FieldDescriptor* descriptor,\n                        map<string, string>* variables,\n                        const Options& options) {\n  SetCommonFieldVariables(descriptor, variables, options);\n  (*variables)[\"default\"] = DefaultValue(descriptor);\n  (*variables)[\"default_length\"] =\n      SimpleItoa(descriptor->default_value_string().length());\n  string default_variable_string =\n      descriptor->default_value_string().empty()\n          ? \"&::google::protobuf::internal::GetEmptyStringAlreadyInited()\"\n          : \"_default_\" + FieldName(descriptor) + \"_\";\n  (*variables)[\"default_variable\"] = default_variable_string;\n  (*variables)[\"default_value_init\"] =\n      descriptor->default_value_string().empty()\n      ? \"\" : \"*\" + default_variable_string;\n  (*variables)[\"pointer_type\"] =\n      descriptor->type() == FieldDescriptor::TYPE_BYTES ? \"void\" : \"char\";\n  // NOTE: Escaped here to unblock proto1->proto2 migration.\n  // TODO(liujisi): Extend this to apply for other conflicting methods.\n  (*variables)[\"release_name\"] =\n      SafeFunctionName(descriptor->containing_type(),\n                       descriptor, \"release_\");\n  (*variables)[\"full_name\"] = descriptor->full_name();\n\n  (*variables)[\"string_piece\"] = \"::std::string\";\n}\n\n}  // namespace\n\n// ===================================================================\n\nStringFieldGenerator::StringFieldGenerator(const FieldDescriptor* descriptor,\n                                           const Options& options)\n    : FieldGenerator(options), descriptor_(descriptor) {\n  SetStringVariables(descriptor, &variables_, options);\n}\n\nStringFieldGenerator::~StringFieldGenerator() {}\n\nvoid StringFieldGenerator::\nGeneratePrivateMembers(io::Printer* printer) const {\n  // N.B. that we continue to use |ArenaStringPtr| instead of |string*| for\n  // string fields, even when SupportArenas(descriptor_) == false. Why?\n  // The simple answer is to avoid unmaintainable complexity. The reflection\n  // code assumes ArenaStringPtrs. These are *almost* in-memory-compatible with\n  // string*, except for the pointer tags and related ownership semantics. We\n  // could modify the runtime code to use string* for the not-supporting-arenas\n  // case, but this would require a way to detect which type of class was\n  // generated (adding overhead and complexity to GeneratedMessageReflection)\n  // and littering the runtime code paths with conditionals. It's simpler to\n  // stick with this but use lightweight accessors that assume arena == NULL.\n  // There should be very little overhead anyway because it's just a tagged\n  // pointer in-memory.\n  printer->Print(variables_, \"::google::protobuf::internal::ArenaStringPtr $name$_;\\n\");\n}\n\nvoid StringFieldGenerator::\nGenerateStaticMembers(io::Printer* printer) const {\n  if (!descriptor_->default_value_string().empty()) {\n    printer->Print(variables_, \"static ::std::string* $default_variable$;\\n\");\n  }\n}\n\nvoid StringFieldGenerator::\nGenerateAccessorDeclarations(io::Printer* printer) const {\n  // If we're using StringFieldGenerator for a field with a ctype, it's\n  // because that ctype isn't actually implemented.  In particular, this is\n  // true of ctype=CORD and ctype=STRING_PIECE in the open source release.\n  // We aren't releasing Cord because it has too many Google-specific\n  // dependencies and we aren't releasing StringPiece because it's hardly\n  // useful outside of Google and because it would get confusing to have\n  // multiple instances of the StringPiece class in different libraries (PCRE\n  // already includes it for their C++ bindings, which came from Google).\n  //\n  // In any case, we make all the accessors private while still actually\n  // using a string to represent the field internally.  This way, we can\n  // guarantee that if we do ever implement the ctype, it won't break any\n  // existing users who might be -- for whatever reason -- already using .proto\n  // files that applied the ctype.  The field can still be accessed via the\n  // reflection interface since the reflection interface is independent of\n  // the string's underlying representation.\n\n  bool unknown_ctype =\n      descriptor_->options().ctype() != EffectiveStringCType(descriptor_);\n\n  if (unknown_ctype) {\n    printer->Outdent();\n    printer->Print(\n      \" private:\\n\"\n      \"  // Hidden due to unknown ctype option.\\n\");\n    printer->Indent();\n  }\n\n  printer->Print(variables_,\n    \"$deprecated_attr$const ::std::string& $name$() const;\\n\"\n    \"$deprecated_attr$void set_$name$(const ::std::string& value);\\n\"\n    \"$deprecated_attr$void set_$name$(const char* value);\\n\"\n    \"$deprecated_attr$void set_$name$(const $pointer_type$* value, size_t size)\"\n                 \";\\n\"\n    \"$deprecated_attr$::std::string* mutable_$name$();\\n\"\n    \"$deprecated_attr$::std::string* $release_name$();\\n\"\n    \"$deprecated_attr$void set_allocated_$name$(::std::string* $name$);\\n\");\n  if (SupportsArenas(descriptor_)) {\n    printer->Print(variables_,\n      \"$deprecated_attr$::std::string* unsafe_arena_release_$name$();\\n\"\n      \"$deprecated_attr$void unsafe_arena_set_allocated_$name$(\\n\"\n      \"    ::std::string* $name$);\\n\");\n  }\n\n\n  if (unknown_ctype) {\n    printer->Outdent();\n    printer->Print(\" public:\\n\");\n    printer->Indent();\n  }\n}\n\nvoid StringFieldGenerator::\nGenerateInlineAccessorDefinitions(io::Printer* printer,\n                                  bool is_inline) const {\n  map<string, string> variables(variables_);\n  variables[\"inline\"] = is_inline ? \"inline\" : \"\";\n  if (SupportsArenas(descriptor_)) {\n    printer->Print(variables,\n      \"$inline$ const ::std::string& $classname$::$name$() const {\\n\"\n      \"  // @@protoc_insertion_point(field_get:$full_name$)\\n\"\n      \"  return $name$_.Get($default_variable$);\\n\"\n      \"}\\n\"\n      \"$inline$ void $classname$::set_$name$(const ::std::string& value) {\\n\"\n      \"  $set_hasbit$\\n\"\n      \"  $name$_.Set($default_variable$, value, GetArenaNoVirtual());\\n\"\n      \"  // @@protoc_insertion_point(field_set:$full_name$)\\n\"\n      \"}\\n\"\n      \"$inline$ void $classname$::set_$name$(const char* value) {\\n\"\n      \"  $set_hasbit$\\n\"\n      \"  $name$_.Set($default_variable$, $string_piece$(value),\\n\"\n      \"              GetArenaNoVirtual());\\n\"\n      \"  // @@protoc_insertion_point(field_set_char:$full_name$)\\n\"\n      \"}\\n\"\n      \"$inline$ \"\n      \"void $classname$::set_$name$(const $pointer_type$* value,\\n\"\n      \"    size_t size) {\\n\"\n      \"  $set_hasbit$\\n\"\n      \"  $name$_.Set($default_variable$, $string_piece$(\\n\"\n      \"      reinterpret_cast<const char*>(value), size), GetArenaNoVirtual());\\n\"\n      \"  // @@protoc_insertion_point(field_set_pointer:$full_name$)\\n\"\n      \"}\\n\"\n      \"$inline$ ::std::string* $classname$::mutable_$name$() {\\n\"\n      \"  $set_hasbit$\\n\"\n      \"  // @@protoc_insertion_point(field_mutable:$full_name$)\\n\"\n      \"  return $name$_.Mutable($default_variable$, GetArenaNoVirtual());\\n\"\n      \"}\\n\"\n      \"$inline$ ::std::string* $classname$::$release_name$() {\\n\"\n      \"  // @@protoc_insertion_point(field_release:$full_name$)\\n\"\n      \"  $clear_hasbit$\\n\"\n      \"  return $name$_.Release($default_variable$, GetArenaNoVirtual());\\n\"\n      \"}\\n\"\n      \"$inline$ ::std::string* $classname$::unsafe_arena_release_$name$() {\\n\"\n      \"  // @@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\\n\"\n      \"  GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\\n\"\n      \"  $clear_hasbit$\\n\"\n      \"  return $name$_.UnsafeArenaRelease($default_variable$,\\n\"\n      \"      GetArenaNoVirtual());\\n\"\n      \"}\\n\"\n      \"$inline$ void $classname$::set_allocated_$name$(::std::string* $name$) {\\n\"\n      \"  if ($name$ != NULL) {\\n\"\n      \"    $set_hasbit$\\n\"\n      \"  } else {\\n\"\n      \"    $clear_hasbit$\\n\"\n      \"  }\\n\"\n      \"  $name$_.SetAllocated($default_variable$, $name$,\\n\"\n      \"      GetArenaNoVirtual());\\n\"\n      \"  // @@protoc_insertion_point(field_set_allocated:$full_name$)\\n\"\n      \"}\\n\"\n      \"$inline$ void $classname$::unsafe_arena_set_allocated_$name$(\\n\"\n      \"    ::std::string* $name$) {\\n\"\n      \"  GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\\n\"\n      \"  if ($name$ != NULL) {\\n\"\n      \"    $set_hasbit$\\n\"\n      \"  } else {\\n\"\n      \"    $clear_hasbit$\\n\"\n      \"  }\\n\"\n      \"  $name$_.UnsafeArenaSetAllocated($default_variable$,\\n\"\n      \"      $name$, GetArenaNoVirtual());\\n\"\n      \"  // @@protoc_insertion_point(field_unsafe_arena_set_allocated:\"\n      \"$full_name$)\\n\"\n      \"}\\n\");\n  } else {\n    // No-arena case.\n    printer->Print(variables,\n      \"$inline$ const ::std::string& $classname$::$name$() const {\\n\"\n      \"  // @@protoc_insertion_point(field_get:$full_name$)\\n\"\n      \"  return $name$_.GetNoArena($default_variable$);\\n\"\n      \"}\\n\"\n      \"$inline$ void $classname$::set_$name$(const ::std::string& value) {\\n\"\n      \"  $set_hasbit$\\n\"\n      \"  $name$_.SetNoArena($default_variable$, value);\\n\"\n      \"  // @@protoc_insertion_point(field_set:$full_name$)\\n\"\n      \"}\\n\"\n      \"$inline$ void $classname$::set_$name$(const char* value) {\\n\"\n      \"  $set_hasbit$\\n\"\n      \"  $name$_.SetNoArena($default_variable$, $string_piece$(value));\\n\"\n      \"  // @@protoc_insertion_point(field_set_char:$full_name$)\\n\"\n      \"}\\n\"\n      \"$inline$ \"\n      \"void $classname$::set_$name$(const $pointer_type$* value, \"\n      \"size_t size) {\\n\"\n      \"  $set_hasbit$\\n\"\n      \"  $name$_.SetNoArena($default_variable$,\\n\"\n      \"      $string_piece$(reinterpret_cast<const char*>(value), size));\\n\"\n      \"  // @@protoc_insertion_point(field_set_pointer:$full_name$)\\n\"\n      \"}\\n\"\n      \"$inline$ ::std::string* $classname$::mutable_$name$() {\\n\"\n      \"  $set_hasbit$\\n\"\n      \"  // @@protoc_insertion_point(field_mutable:$full_name$)\\n\"\n      \"  return $name$_.MutableNoArena($default_variable$);\\n\"\n      \"}\\n\"\n      \"$inline$ ::std::string* $classname$::$release_name$() {\\n\"\n      \"  // @@protoc_insertion_point(field_release:$full_name$)\\n\"\n      \"  $clear_hasbit$\\n\"\n      \"  return $name$_.ReleaseNoArena($default_variable$);\\n\"\n      \"}\\n\"\n      \"$inline$ void $classname$::set_allocated_$name$(::std::string* $name$) {\\n\"\n      \"  if ($name$ != NULL) {\\n\"\n      \"    $set_hasbit$\\n\"\n      \"  } else {\\n\"\n      \"    $clear_hasbit$\\n\"\n      \"  }\\n\"\n      \"  $name$_.SetAllocatedNoArena($default_variable$, $name$);\\n\"\n      \"  // @@protoc_insertion_point(field_set_allocated:$full_name$)\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid StringFieldGenerator::\nGenerateNonInlineAccessorDefinitions(io::Printer* printer) const {\n  if (!descriptor_->default_value_string().empty()) {\n    // Initialized in GenerateDefaultInstanceAllocator.\n    printer->Print(variables_,\n      \"::std::string* $classname$::$default_variable$ = NULL;\\n\");\n  }\n}\n\nvoid StringFieldGenerator::\nGenerateClearingCode(io::Printer* printer) const {\n  // Two-dimension specialization here: supporting arenas or not, and default\n  // value is the empty string or not. Complexity here ensures the minimal\n  // number of branches / amount of extraneous code at runtime (given that the\n  // below methods are inlined one-liners)!\n  if (SupportsArenas(descriptor_)) {\n    if (descriptor_->default_value_string().empty()) {\n      printer->Print(variables_,\n        \"$name$_.ClearToEmpty($default_variable$, GetArenaNoVirtual());\\n\");\n    } else {\n      printer->Print(variables_,\n        \"$name$_.ClearToDefault($default_variable$, GetArenaNoVirtual());\\n\");\n    }\n  } else {\n    if (descriptor_->default_value_string().empty()) {\n      printer->Print(variables_,\n        \"$name$_.ClearToEmptyNoArena($default_variable$);\\n\");\n    } else {\n      printer->Print(variables_,\n        \"$name$_.ClearToDefaultNoArena($default_variable$);\\n\");\n    }\n  }\n}\n\nvoid StringFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  if (SupportsArenas(descriptor_) || descriptor_->containing_oneof() != NULL) {\n    // TODO(gpike): improve this\n    printer->Print(variables_, \"set_$name$(from.$name$());\\n\");\n  } else {\n    printer->Print(variables_,\n      \"$set_hasbit$\\n\"\n      \"$name$_.AssignWithDefault($default_variable$, from.$name$_);\\n\");\n  }\n}\n\nvoid StringFieldGenerator::\nGenerateSwappingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_.Swap(&other->$name$_);\\n\");\n}\n\nvoid StringFieldGenerator::\nGenerateConstructorCode(io::Printer* printer) const {\n  printer->Print(variables_,\n      \"$name$_.UnsafeSetDefault($default_variable$);\\n\");\n}\n\nvoid StringFieldGenerator::\nGenerateDestructorCode(io::Printer* printer) const {\n  if (SupportsArenas(descriptor_)) {\n    printer->Print(variables_,\n      \"$name$_.Destroy($default_variable$, GetArenaNoVirtual());\\n\");\n  } else {\n    printer->Print(variables_,\n      \"$name$_.DestroyNoArena($default_variable$);\\n\");\n  }\n}\n\nvoid StringFieldGenerator::\nGenerateDefaultInstanceAllocator(io::Printer* printer) const {\n  if (!descriptor_->default_value_string().empty()) {\n    printer->Print(variables_,\n      \"$classname$::$default_variable$ =\\n\"\n      \"    new ::std::string($default$, $default_length$);\\n\");\n  }\n}\n\nvoid StringFieldGenerator::\nGenerateShutdownCode(io::Printer* printer) const {\n  if (!descriptor_->default_value_string().empty()) {\n    printer->Print(variables_,\n      \"delete $classname$::$default_variable$;\\n\");\n  }\n}\n\nvoid StringFieldGenerator::\nGenerateMergeFromCodedStream(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"DO_(::google::protobuf::internal::WireFormatLite::Read$declared_type$(\\n\"\n    \"      input, this->mutable_$name$()));\\n\");\n\n  if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {\n    GenerateUtf8CheckCodeForString(\n        descriptor_, options_, true, variables_,\n        \"this->$name$().data(), this->$name$().length(),\\n\", printer);\n  }\n}\n\nvoid StringFieldGenerator::\nGenerateSerializeWithCachedSizes(io::Printer* printer) const {\n  if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {\n    GenerateUtf8CheckCodeForString(\n        descriptor_, options_, false, variables_,\n        \"this->$name$().data(), this->$name$().length(),\\n\", printer);\n  }\n  printer->Print(variables_,\n    \"::google::protobuf::internal::WireFormatLite::Write$declared_type$MaybeAliased(\\n\"\n    \"  $number$, this->$name$(), output);\\n\");\n}\n\nvoid StringFieldGenerator::\nGenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {\n  if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {\n    GenerateUtf8CheckCodeForString(\n        descriptor_, options_, false, variables_,\n        \"this->$name$().data(), this->$name$().length(),\\n\", printer);\n  }\n  printer->Print(variables_,\n    \"target =\\n\"\n    \"  ::google::protobuf::internal::WireFormatLite::Write$declared_type$ToArray(\\n\"\n    \"    $number$, this->$name$(), target);\\n\");\n}\n\nvoid StringFieldGenerator::\nGenerateByteSize(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"total_size += $tag_size$ +\\n\"\n    \"  ::google::protobuf::internal::WireFormatLite::$declared_type$Size(\\n\"\n    \"    this->$name$());\\n\");\n}\n\n// ===================================================================\n\nStringOneofFieldGenerator::\nStringOneofFieldGenerator(const FieldDescriptor* descriptor,\n                          const Options& options)\n    : StringFieldGenerator(descriptor, options),\n      dependent_field_(options.proto_h) {\n  SetCommonOneofFieldVariables(descriptor, &variables_);\n}\n\nStringOneofFieldGenerator::~StringOneofFieldGenerator() {}\n\nvoid StringOneofFieldGenerator::\nGenerateInlineAccessorDefinitions(io::Printer* printer,\n                                  bool is_inline) const {\n  map<string, string> variables(variables_);\n  variables[\"inline\"] = is_inline ? \"inline\" : \"\";\n  if (SupportsArenas(descriptor_)) {\n    printer->Print(variables,\n      \"$inline$ const ::std::string& $classname$::$name$() const {\\n\"\n      \"  // @@protoc_insertion_point(field_get:$full_name$)\\n\"\n      \"  if (has_$name$()) {\\n\"\n      \"    return $oneof_prefix$$name$_.Get($default_variable$);\\n\"\n      \"  }\\n\"\n      \"  return *$default_variable$;\\n\"\n      \"}\\n\"\n      \"$inline$ void $classname$::set_$name$(const ::std::string& value) {\\n\"\n      \"  if (!has_$name$()) {\\n\"\n      \"    clear_$oneof_name$();\\n\"\n      \"    set_has_$name$();\\n\"\n      \"    $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\\n\"\n      \"  }\\n\"\n      \"  $oneof_prefix$$name$_.Set($default_variable$, value,\\n\"\n      \"      GetArenaNoVirtual());\\n\"\n      \"  // @@protoc_insertion_point(field_set:$full_name$)\\n\"\n      \"}\\n\"\n      \"$inline$ void $classname$::set_$name$(const char* value) {\\n\"\n      \"  if (!has_$name$()) {\\n\"\n      \"    clear_$oneof_name$();\\n\"\n      \"    set_has_$name$();\\n\"\n      \"    $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\\n\"\n      \"  }\\n\"\n      \"  $oneof_prefix$$name$_.Set($default_variable$,\\n\"\n      \"      $string_piece$(value), GetArenaNoVirtual());\\n\"\n      \"  // @@protoc_insertion_point(field_set_char:$full_name$)\\n\"\n      \"}\\n\"\n      \"$inline$ \"\n      \"void $classname$::set_$name$(const $pointer_type$* value,\\n\"\n      \"                             size_t size) {\\n\"\n      \"  if (!has_$name$()) {\\n\"\n      \"    clear_$oneof_name$();\\n\"\n      \"    set_has_$name$();\\n\"\n      \"    $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\\n\"\n      \"  }\\n\"\n      \"  $oneof_prefix$$name$_.Set($default_variable$, $string_piece$(\\n\"\n      \"      reinterpret_cast<const char*>(value), size),\\n\"\n      \"      GetArenaNoVirtual());\\n\"\n      \"  // @@protoc_insertion_point(field_set_pointer:$full_name$)\\n\"\n      \"}\\n\"\n      \"$inline$ ::std::string* $classname$::mutable_$name$() {\\n\"\n      \"  if (!has_$name$()) {\\n\"\n      \"    clear_$oneof_name$();\\n\"\n      \"    set_has_$name$();\\n\"\n      \"    $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\\n\"\n      \"  }\\n\"\n      \"  return $oneof_prefix$$name$_.Mutable($default_variable$,\\n\"\n      \"      GetArenaNoVirtual());\\n\"\n      \"  // @@protoc_insertion_point(field_mutable:$full_name$)\\n\"\n      \"}\\n\"\n      \"$inline$ ::std::string* $classname$::$release_name$() {\\n\"\n      \"  // @@protoc_insertion_point(field_release:$full_name$)\\n\"\n      \"  if (has_$name$()) {\\n\"\n      \"    clear_has_$oneof_name$();\\n\"\n      \"    return $oneof_prefix$$name$_.Release($default_variable$,\\n\"\n      \"        GetArenaNoVirtual());\\n\"\n      \"  } else {\\n\"\n      \"    return NULL;\\n\"\n      \"  }\\n\"\n      \"}\\n\"\n      \"$inline$ ::std::string* $classname$::unsafe_arena_release_$name$() {\\n\"\n      \"  // @@protoc_insertion_point(field_unsafe_arena_release:$full_name$)\\n\"\n      \"  GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\\n\"\n      \"  if (has_$name$()) {\\n\"\n      \"    clear_has_$oneof_name$();\\n\"\n      \"    return $oneof_prefix$$name$_.UnsafeArenaRelease(\\n\"\n      \"        $default_variable$, GetArenaNoVirtual());\\n\"\n      \"  } else {\\n\"\n      \"    return NULL;\\n\"\n      \"  }\\n\"\n      \"}\\n\"\n      \"$inline$ void $classname$::set_allocated_$name$(::std::string* $name$) {\\n\"\n      \"  if (!has_$name$()) {\\n\"\n      \"    $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\\n\"\n      \"  }\\n\"\n      \"  clear_$oneof_name$();\\n\"\n      \"  if ($name$ != NULL) {\\n\"\n      \"    set_has_$name$();\\n\"\n      \"    $oneof_prefix$$name$_.SetAllocated($default_variable$, $name$,\\n\"\n      \"        GetArenaNoVirtual());\\n\"\n      \"  }\\n\"\n      \"  // @@protoc_insertion_point(field_set_allocated:$full_name$)\\n\"\n      \"}\\n\"\n      \"$inline$ void $classname$::unsafe_arena_set_allocated_$name$(\"\n      \"::std::string* $name$) {\\n\"\n      \"  GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\\n\"\n      \"  if (!has_$name$()) {\\n\"\n      \"    $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\\n\"\n      \"  }\\n\"\n      \"  clear_$oneof_name$();\\n\"\n      \"  if ($name$) {\\n\"\n      \"    set_has_$name$();\\n\"\n      \"    $oneof_prefix$$name$_.UnsafeArenaSetAllocated($default_variable$, \"\n      \"$name$, GetArenaNoVirtual());\\n\"\n      \"  }\\n\"\n      \"  // @@protoc_insertion_point(field_unsafe_arena_set_allocated:\"\n      \"$full_name$)\\n\"\n      \"}\\n\");\n  } else {\n    // No-arena case.\n    printer->Print(variables,\n      \"$inline$ const ::std::string& $classname$::$name$() const {\\n\"\n      \"  // @@protoc_insertion_point(field_get:$full_name$)\\n\"\n      \"  if (has_$name$()) {\\n\"\n      \"    return $oneof_prefix$$name$_.GetNoArena($default_variable$);\\n\"\n      \"  }\\n\"\n      \"  return *$default_variable$;\\n\"\n      \"}\\n\"\n      \"$inline$ void $classname$::set_$name$(const ::std::string& value) {\\n\"\n      \"  // @@protoc_insertion_point(field_set:$full_name$)\\n\"\n      \"  if (!has_$name$()) {\\n\"\n      \"    clear_$oneof_name$();\\n\"\n      \"    set_has_$name$();\\n\"\n      \"    $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\\n\"\n      \"  }\\n\"\n      \"  $oneof_prefix$$name$_.SetNoArena($default_variable$, value);\\n\"\n      \"  // @@protoc_insertion_point(field_set:$full_name$)\\n\"\n      \"}\\n\"\n      \"$inline$ void $classname$::set_$name$(const char* value) {\\n\"\n      \"  if (!has_$name$()) {\\n\"\n      \"    clear_$oneof_name$();\\n\"\n      \"    set_has_$name$();\\n\"\n      \"    $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\\n\"\n      \"  }\\n\"\n      \"  $oneof_prefix$$name$_.SetNoArena($default_variable$,\\n\"\n      \"      $string_piece$(value));\\n\"\n      \"  // @@protoc_insertion_point(field_set_char:$full_name$)\\n\"\n      \"}\\n\"\n      \"$inline$ \"\n      \"void $classname$::set_$name$(const $pointer_type$* value, size_t size) {\\n\"\n      \"  if (!has_$name$()) {\\n\"\n      \"    clear_$oneof_name$();\\n\"\n      \"    set_has_$name$();\\n\"\n      \"    $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\\n\"\n      \"  }\\n\"\n      \"  $oneof_prefix$$name$_.SetNoArena($default_variable$, $string_piece$(\\n\"\n      \"      reinterpret_cast<const char*>(value), size));\\n\"\n      \"  // @@protoc_insertion_point(field_set_pointer:$full_name$)\\n\"\n      \"}\\n\"\n      \"$inline$ ::std::string* $classname$::mutable_$name$() {\\n\"\n      \"  if (!has_$name$()) {\\n\"\n      \"    clear_$oneof_name$();\\n\"\n      \"    set_has_$name$();\\n\"\n      \"    $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\\n\"\n      \"  }\\n\"\n      \"  // @@protoc_insertion_point(field_mutable:$full_name$)\\n\"\n      \"  return $oneof_prefix$$name$_.MutableNoArena($default_variable$);\\n\"\n      \"}\\n\"\n      \"$inline$ ::std::string* $classname$::$release_name$() {\\n\"\n      \"  // @@protoc_insertion_point(field_release:$full_name$)\\n\"\n      \"  if (has_$name$()) {\\n\"\n      \"    clear_has_$oneof_name$();\\n\"\n      \"    return $oneof_prefix$$name$_.ReleaseNoArena($default_variable$);\\n\"\n      \"  } else {\\n\"\n      \"    return NULL;\\n\"\n      \"  }\\n\"\n      \"}\\n\"\n      \"$inline$ void $classname$::set_allocated_$name$(::std::string* $name$) {\\n\"\n      \"  if (!has_$name$()) {\\n\"\n      \"    $oneof_prefix$$name$_.UnsafeSetDefault($default_variable$);\\n\"\n      \"  }\\n\"\n      \"  clear_$oneof_name$();\\n\"\n      \"  if ($name$ != NULL) {\\n\"\n      \"    set_has_$name$();\\n\"\n      \"    $oneof_prefix$$name$_.SetAllocatedNoArena($default_variable$,\\n\"\n      \"        $name$);\\n\"\n      \"  }\\n\"\n      \"  // @@protoc_insertion_point(field_set_allocated:$full_name$)\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid StringOneofFieldGenerator::\nGenerateClearingCode(io::Printer* printer) const {\n  map<string, string> variables(variables_);\n  if (dependent_field_) {\n    variables[\"this_message\"] = DependentBaseDownCast();\n    // This clearing code may be in the dependent base class. If the default\n    // value is an empty string, then the $default_variable$ is a global\n    // singleton. If the default is not empty, we need to down-cast to get the\n    // default value's global singleton instance. See SetStringVariables() for\n    // possible values of default_variable.\n    if (!descriptor_->default_value_string().empty()) {\n      variables[\"default_variable\"] =\n          DependentBaseDownCast() + variables[\"default_variable\"];\n    }\n  } else {\n    variables[\"this_message\"] = \"\";\n  }\n  if (SupportsArenas(descriptor_)) {\n    printer->Print(variables,\n      \"$this_message$$oneof_prefix$$name$_.Destroy($default_variable$,\\n\"\n      \"    $this_message$GetArenaNoVirtual());\\n\");\n  } else {\n    printer->Print(variables,\n      \"$this_message$$oneof_prefix$$name$_.\"\n      \"DestroyNoArena($default_variable$);\\n\");\n  }\n}\n\nvoid StringOneofFieldGenerator::\nGenerateSwappingCode(io::Printer* printer) const {\n  // Don't print any swapping code. Swapping the union will swap this field.\n}\n\nvoid StringOneofFieldGenerator::\nGenerateConstructorCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"  $classname$_default_oneof_instance_->$name$_.UnsafeSetDefault(\"\n    \"$default_variable$);\\n\");\n}\n\nvoid StringOneofFieldGenerator::\nGenerateDestructorCode(io::Printer* printer) const {\n  if (SupportsArenas(descriptor_)) {\n    printer->Print(variables_,\n      \"if (has_$name$()) {\\n\"\n      \"  $oneof_prefix$$name$_.Destroy($default_variable$,\\n\"\n      \"      GetArenaNoVirtual());\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables_,\n      \"if (has_$name$()) {\\n\"\n      \"  $oneof_prefix$$name$_.DestroyNoArena($default_variable$);\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid StringOneofFieldGenerator::\nGenerateMergeFromCodedStream(io::Printer* printer) const {\n    printer->Print(variables_,\n      \"DO_(::google::protobuf::internal::WireFormatLite::Read$declared_type$(\\n\"\n      \"      input, this->mutable_$name$()));\\n\");\n\n  if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {\n    GenerateUtf8CheckCodeForString(\n        descriptor_, options_, true, variables_,\n        \"this->$name$().data(), this->$name$().length(),\\n\", printer);\n  }\n}\n\n\n// ===================================================================\n\nRepeatedStringFieldGenerator::RepeatedStringFieldGenerator(\n    const FieldDescriptor* descriptor, const Options& options)\n    : FieldGenerator(options), descriptor_(descriptor) {\n  SetStringVariables(descriptor, &variables_, options);\n}\n\nRepeatedStringFieldGenerator::~RepeatedStringFieldGenerator() {}\n\nvoid RepeatedStringFieldGenerator::\nGeneratePrivateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"::google::protobuf::RepeatedPtrField< ::std::string> $name$_;\\n\");\n}\n\nvoid RepeatedStringFieldGenerator::\nGenerateAccessorDeclarations(io::Printer* printer) const {\n  // See comment above about unknown ctypes.\n  bool unknown_ctype =\n      descriptor_->options().ctype() != EffectiveStringCType(descriptor_);\n\n  if (unknown_ctype) {\n    printer->Outdent();\n    printer->Print(\n      \" private:\\n\"\n      \"  // Hidden due to unknown ctype option.\\n\");\n    printer->Indent();\n  }\n\n  printer->Print(variables_,\n    \"$deprecated_attr$const ::std::string& $name$(int index) const;\\n\"\n    \"$deprecated_attr$::std::string* mutable_$name$(int index);\\n\"\n    \"$deprecated_attr$void set_$name$(int index, const ::std::string& value);\\n\"\n    \"$deprecated_attr$void set_$name$(int index, const char* value);\\n\"\n    \"\"\n    \"$deprecated_attr$void set_$name$(\"\n                 \"int index, const $pointer_type$* value, size_t size);\\n\"\n    \"$deprecated_attr$::std::string* add_$name$();\\n\"\n    \"$deprecated_attr$void add_$name$(const ::std::string& value);\\n\"\n    \"$deprecated_attr$void add_$name$(const char* value);\\n\"\n    \"$deprecated_attr$void add_$name$(const $pointer_type$* value, size_t size)\"\n                 \";\\n\");\n\n  printer->Print(variables_,\n    \"$deprecated_attr$const ::google::protobuf::RepeatedPtrField< ::std::string>& $name$() \"\n                 \"const;\\n\"\n    \"$deprecated_attr$::google::protobuf::RepeatedPtrField< ::std::string>* mutable_$name$()\"\n                 \";\\n\");\n\n  if (unknown_ctype) {\n    printer->Outdent();\n    printer->Print(\" public:\\n\");\n    printer->Indent();\n  }\n}\n\nvoid RepeatedStringFieldGenerator::\nGenerateInlineAccessorDefinitions(io::Printer* printer,\n                                  bool is_inline) const {\n  map<string, string> variables(variables_);\n  variables[\"inline\"] = is_inline ? \"inline\" : \"\";\n  printer->Print(variables,\n    \"$inline$ const ::std::string& $classname$::$name$(int index) const {\\n\"\n    \"  // @@protoc_insertion_point(field_get:$full_name$)\\n\"\n    \"  return $name$_.$cppget$(index);\\n\"\n    \"}\\n\"\n    \"$inline$ ::std::string* $classname$::mutable_$name$(int index) {\\n\"\n    \"  // @@protoc_insertion_point(field_mutable:$full_name$)\\n\"\n    \"  return $name$_.Mutable(index);\\n\"\n    \"}\\n\"\n    \"$inline$ void $classname$::set_$name$(int index, const ::std::string& value) {\\n\"\n    \"  // @@protoc_insertion_point(field_set:$full_name$)\\n\"\n    \"  $name$_.Mutable(index)->assign(value);\\n\"\n    \"}\\n\"\n    \"$inline$ void $classname$::set_$name$(int index, const char* value) {\\n\"\n    \"  $name$_.Mutable(index)->assign(value);\\n\"\n    \"  // @@protoc_insertion_point(field_set_char:$full_name$)\\n\"\n    \"}\\n\"\n    \"$inline$ void \"\n    \"$classname$::set_$name$\"\n    \"(int index, const $pointer_type$* value, size_t size) {\\n\"\n    \"  $name$_.Mutable(index)->assign(\\n\"\n    \"    reinterpret_cast<const char*>(value), size);\\n\"\n    \"  // @@protoc_insertion_point(field_set_pointer:$full_name$)\\n\"\n    \"}\\n\"\n    \"$inline$ ::std::string* $classname$::add_$name$() {\\n\"\n    \"  // @@protoc_insertion_point(field_add_mutable:$full_name$)\\n\"\n    \"  return $name$_.Add();\\n\"\n    \"}\\n\"\n    \"$inline$ void $classname$::add_$name$(const ::std::string& value) {\\n\"\n    \"  $name$_.Add()->assign(value);\\n\"\n    \"  // @@protoc_insertion_point(field_add:$full_name$)\\n\"\n    \"}\\n\"\n    \"$inline$ void $classname$::add_$name$(const char* value) {\\n\"\n    \"  $name$_.Add()->assign(value);\\n\"\n    \"  // @@protoc_insertion_point(field_add_char:$full_name$)\\n\"\n    \"}\\n\"\n    \"$inline$ void \"\n    \"$classname$::add_$name$(const $pointer_type$* value, size_t size) {\\n\"\n    \"  $name$_.Add()->assign(reinterpret_cast<const char*>(value), size);\\n\"\n    \"  // @@protoc_insertion_point(field_add_pointer:$full_name$)\\n\"\n    \"}\\n\");\n  printer->Print(variables,\n    \"$inline$ const ::google::protobuf::RepeatedPtrField< ::std::string>&\\n\"\n    \"$classname$::$name$() const {\\n\"\n    \"  // @@protoc_insertion_point(field_list:$full_name$)\\n\"\n    \"  return $name$_;\\n\"\n    \"}\\n\"\n    \"$inline$ ::google::protobuf::RepeatedPtrField< ::std::string>*\\n\"\n    \"$classname$::mutable_$name$() {\\n\"\n    \"  // @@protoc_insertion_point(field_mutable_list:$full_name$)\\n\"\n    \"  return &$name$_;\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedStringFieldGenerator::\nGenerateClearingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_.Clear();\\n\");\n}\n\nvoid RepeatedStringFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_.MergeFrom(from.$name$_);\\n\");\n}\n\nvoid RepeatedStringFieldGenerator::\nGenerateSwappingCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_.UnsafeArenaSwap(&other->$name$_);\\n\");\n}\n\nvoid RepeatedStringFieldGenerator::\nGenerateConstructorCode(io::Printer* printer) const {\n  // Not needed for repeated fields.\n}\n\nvoid RepeatedStringFieldGenerator::\nGenerateMergeFromCodedStream(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"DO_(::google::protobuf::internal::WireFormatLite::Read$declared_type$(\\n\"\n    \"      input, this->add_$name$()));\\n\");\n  if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {\n    GenerateUtf8CheckCodeForString(\n        descriptor_, options_, true, variables_,\n        \"this->$name$(this->$name$_size() - 1).data(),\\n\"\n        \"this->$name$(this->$name$_size() - 1).length(),\\n\",\n        printer);\n  }\n}\n\nvoid RepeatedStringFieldGenerator::\nGenerateSerializeWithCachedSizes(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"for (int i = 0; i < this->$name$_size(); i++) {\\n\");\n  printer->Indent();\n  if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {\n    GenerateUtf8CheckCodeForString(\n        descriptor_, options_, false, variables_,\n        \"this->$name$(i).data(), this->$name$(i).length(),\\n\", printer);\n  }\n  printer->Outdent();\n  printer->Print(variables_,\n    \"  ::google::protobuf::internal::WireFormatLite::Write$declared_type$(\\n\"\n    \"    $number$, this->$name$(i), output);\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedStringFieldGenerator::\nGenerateSerializeWithCachedSizesToArray(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"for (int i = 0; i < this->$name$_size(); i++) {\\n\");\n  printer->Indent();\n  if (descriptor_->type() == FieldDescriptor::TYPE_STRING) {\n    GenerateUtf8CheckCodeForString(\n        descriptor_, options_, false, variables_,\n        \"this->$name$(i).data(), this->$name$(i).length(),\\n\", printer);\n  }\n  printer->Outdent();\n  printer->Print(variables_,\n    \"  target = ::google::protobuf::internal::WireFormatLite::\\n\"\n    \"    Write$declared_type$ToArray($number$, this->$name$(i), target);\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedStringFieldGenerator::\nGenerateByteSize(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"total_size += $tag_size$ * this->$name$_size();\\n\"\n    \"for (int i = 0; i < this->$name$_size(); i++) {\\n\"\n    \"  total_size += ::google::protobuf::internal::WireFormatLite::$declared_type$Size(\\n\"\n    \"    this->$name$(i));\\n\"\n    \"}\\n\");\n}\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_string_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_STRING_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_CPP_STRING_FIELD_H__\n\n#include <map>\n#include <string>\n#include <google/protobuf/compiler/cpp/cpp_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\nclass StringFieldGenerator : public FieldGenerator {\n public:\n  StringFieldGenerator(const FieldDescriptor* descriptor,\n                       const Options& options);\n  ~StringFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  void GeneratePrivateMembers(io::Printer* printer) const;\n  void GenerateStaticMembers(io::Printer* printer) const;\n  void GenerateAccessorDeclarations(io::Printer* printer) const;\n  void GenerateInlineAccessorDefinitions(io::Printer* printer,\n                                         bool is_inline) const;\n  void GenerateNonInlineAccessorDefinitions(io::Printer* printer) const;\n  void GenerateClearingCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateSwappingCode(io::Printer* printer) const;\n  void GenerateConstructorCode(io::Printer* printer) const;\n  void GenerateDestructorCode(io::Printer* printer) const;\n  void GenerateDefaultInstanceAllocator(io::Printer* printer) const;\n  void GenerateShutdownCode(io::Printer* printer) const;\n  void GenerateMergeFromCodedStream(io::Printer* printer) const;\n  void GenerateSerializeWithCachedSizes(io::Printer* printer) const;\n  void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;\n  void GenerateByteSize(io::Printer* printer) const;\n\n protected:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringFieldGenerator);\n};\n\nclass StringOneofFieldGenerator : public StringFieldGenerator {\n public:\n  StringOneofFieldGenerator(const FieldDescriptor* descriptor,\n                            const Options& options);\n  ~StringOneofFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  void GenerateInlineAccessorDefinitions(io::Printer* printer,\n                                         bool is_inline) const;\n  void GenerateClearingCode(io::Printer* printer) const;\n  void GenerateSwappingCode(io::Printer* printer) const;\n  void GenerateConstructorCode(io::Printer* printer) const;\n  void GenerateDestructorCode(io::Printer* printer) const;\n  void GenerateMergeFromCodedStream(io::Printer* printer) const;\n\n private:\n  const bool dependent_field_;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringOneofFieldGenerator);\n};\n\nclass RepeatedStringFieldGenerator : public FieldGenerator {\n public:\n  RepeatedStringFieldGenerator(const FieldDescriptor* descriptor,\n                               const Options& options);\n  ~RepeatedStringFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  void GeneratePrivateMembers(io::Printer* printer) const;\n  void GenerateAccessorDeclarations(io::Printer* printer) const;\n  void GenerateInlineAccessorDefinitions(io::Printer* printer,\n                                         bool is_inline) const;\n  void GenerateClearingCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateSwappingCode(io::Printer* printer) const;\n  void GenerateConstructorCode(io::Printer* printer) const;\n  void GenerateMergeFromCodedStream(io::Printer* printer) const;\n  void GenerateSerializeWithCachedSizes(io::Printer* printer) const;\n  void GenerateSerializeWithCachedSizesToArray(io::Printer* printer) const;\n  void GenerateByteSize(io::Printer* printer) const;\n\n private:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedStringFieldGenerator);\n};\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_CPP_STRING_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This file tests that various identifiers work as field and type names even\n// though the same identifiers are used internally by the C++ code generator.\n\nsyntax = \"proto2\";\n\n// Some generic_services option(s) added automatically.\n// See:  http://go/proto2-generic-services-default\noption cc_generic_services = true;     // auto-added\n\n// We don't put this in a package within proto2 because we need to make sure\n// that the generated code doesn't depend on being in the proto2 namespace.\npackage protobuf_unittest;\n\n// Test that fields can have names like \"input\" and \"i\" which are also used\n// internally by the code generator for local variables.\nmessage TestConflictingSymbolNames {\n  message BuildDescriptors {}\n  message TypeTraits {}\n\n  optional int32 input = 1;\n  optional int32 output = 2;\n  optional string length = 3;\n  repeated int32 i = 4;\n  repeated string new_element = 5 [ctype=STRING_PIECE];\n  optional int32 total_size = 6;\n  optional int32 tag = 7;\n\n  enum TestEnum { FOO = 0; }\n  message Data1 { repeated int32 data = 1; }\n  message Data2 { repeated TestEnum data = 1; }\n  message Data3 { repeated string data = 1; }\n  message Data4 { repeated Data4 data = 1; }\n  message Data5 { repeated string data = 1 [ctype=STRING_PIECE]; }\n  message Data6 { repeated string data = 1 [ctype=CORD]; }\n\n  optional int32 source = 8;\n  optional int32 value = 9;\n  optional int32 file = 10;\n  optional int32 from = 11;\n  optional int32 handle_uninterpreted = 12;\n  repeated int32 index = 13;\n  optional int32 controller = 14;\n  optional int32 already_here = 15;\n\n  optional uint32 uint32 = 16;\n  optional uint64 uint64 = 17;\n  optional string string = 18;\n  optional int32 memset = 19;\n  optional int32 int32 = 20;\n  optional int64 int64 = 21;\n\n  optional uint32 cached_size = 22;\n  optional uint32 extensions = 23;\n  optional uint32 bit = 24;\n  optional uint32 bits = 25;\n  optional uint32 offsets = 26;\n  optional uint32 reflection = 27;\n\n  message Cord {}\n  optional string some_cord = 28 [ctype=CORD];\n\n  message StringPiece {}\n  optional string some_string_piece = 29 [ctype=STRING_PIECE];\n\n  // Some keywords.\n  optional uint32 int = 30;\n  optional uint32 friend = 31;\n  optional uint32 class = 37;\n  optional uint32 typedecl = 39;\n  optional uint32 auto = 40;\n\n  // The generator used to #define a macro called \"DO\" inside the .cc file.\n  message DO {}\n  optional DO do = 32;\n\n  // Some template parameter names for extensions.\n  optional int32 field_type = 33;\n  optional bool is_packed = 34;\n\n  // test conflicting release_$name$. \"length\" and \"do\" field in this message\n  // must remain string or message fields to make the test valid.\n  optional string release_length = 35;\n  // A more extreme case, the field name \"do\" here is a keyword, which will be\n  // escaped to \"do_\" already. Test there is no conflict even with escaped field\n  // names.\n  optional DO release_do = 36;\n\n  // For clashing local variables in Serialize and ByteSize calculation.\n  optional string target = 38;\n\n  extensions 1000 to max;  // NO_PROTO3\n}\n\nmessage TestConflictingSymbolNamesExtension {                    // NO_PROTO3\n  extend TestConflictingSymbolNames {                            // NO_PROTO3\n    repeated int32 repeated_int32_ext = 20423638 [packed=true];  // NO_PROTO3\n  }                                                              // NO_PROTO3\n}                                                                // NO_PROTO3\n\nmessage TestConflictingEnumNames {  // NO_PROTO3\n  enum NestedConflictingEnum {      // NO_PROTO3\n    and = 1;                        // NO_PROTO3\n    class = 2;                      // NO_PROTO3\n    int = 3;                        // NO_PROTO3\n    typedef = 4;                    // NO_PROTO3\n    XOR = 5;                        // NO_PROTO3\n  }                                 // NO_PROTO3\n\n  optional NestedConflictingEnum conflicting_enum = 1;  // NO_PROTO3\n}  // NO_PROTO3\n\nenum ConflictingEnum {  // NO_PROTO3\n  NOT_EQ = 1;           // NO_PROTO3\n  volatile = 2;         // NO_PROTO3\n  return = 3;           // NO_PROTO3\n}  // NO_PROTO3\n\nmessage DummyMessage {}\n\nservice TestConflictingMethodNames {\n  rpc Closure(DummyMessage) returns (DummyMessage);\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Test that proto2 compiler can generate valid code when the enum value\n// is INT_MAX. Note that this is a compile-only test and this proto is not\n// referenced in any C++ code.\nsyntax = \"proto2\";\n\npackage protobuf_unittest;\n\nmessage TestLargeEnumValue {\n  enum EnumWithLargeValue {\n    VALUE_1 = 1;\n    VALUE_MAX = 0x7fffffff;\n  }\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// To test the code generator, we actually use it to generate code for\n// google/protobuf/unittest.proto, then test that.  This means that we\n// are actually testing the parser and other parts of the system at the same\n// time, and that problems in the generator may show up as compile-time errors\n// rather than unittest failures, which may be surprising.  However, testing\n// the output of the C++ generator directly would be very hard.  We can't very\n// well just check it against golden files since those files would have to be\n// updated for any small change; such a test would be very brittle and probably\n// not very helpful.  What we really want to test is that the code compiles\n// correctly and produces the interfaces we expect, which is why this test\n// is written this way.\n\n#include <google/protobuf/compiler/cpp/cpp_unittest.h>\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <vector>\n\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/unittest_optimize_for.pb.h>\n#include <google/protobuf/unittest_embed_optimize_for.pb.h>\n#if !defined(GOOGLE_PROTOBUF_CMAKE_BUILD) && !defined(_MSC_VER)\n// We exclude this large proto from cmake build because it's too large for\n// visual studio to compile (report internal errors).\n#include <google/protobuf/unittest_enormous_descriptor.pb.h>\n#endif\n#include <google/protobuf/unittest_no_generic_services.pb.h>\n#include <google/protobuf/test_util.h>\n#include <google/protobuf/compiler/cpp/cpp_helpers.h>\n#include <google/protobuf/compiler/cpp/cpp_test_bad_identifiers.pb.h>\n#include <google/protobuf/compiler/importer.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/dynamic_message.h>\n\n#include <google/protobuf/stubs/callback.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n#include <google/protobuf/stubs/stl_util.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\n\n// Can't use an anonymous namespace here due to brokenness of Tru64 compiler.\nnamespace cpp_unittest {\n\nnamespace protobuf_unittest = ::protobuf_unittest;\n\n\nclass MockErrorCollector : public MultiFileErrorCollector {\n public:\n  MockErrorCollector() {}\n  ~MockErrorCollector() {}\n\n  string text_;\n\n  // implements ErrorCollector ---------------------------------------\n  void AddError(const string& filename, int line, int column,\n                const string& message) {\n    strings::SubstituteAndAppend(&text_, \"$0:$1:$2: $3\\n\",\n                                 filename, line, column, message);\n  }\n};\n\n#ifndef PROTOBUF_TEST_NO_DESCRIPTORS\n\n// Test that generated code has proper descriptors:\n// Parse a descriptor directly (using google::protobuf::compiler::Importer) and\n// compare it to the one that was produced by generated code.\nTEST(GeneratedDescriptorTest, IdenticalDescriptors) {\n  const FileDescriptor* generated_descriptor =\n    unittest::TestAllTypes::descriptor()->file();\n\n  // Set up the Importer.\n  MockErrorCollector error_collector;\n  DiskSourceTree source_tree;\n  source_tree.MapPath(\"\", TestSourceDir());\n  Importer importer(&source_tree, &error_collector);\n\n  // Import (parse) unittest.proto.\n  const FileDescriptor* parsed_descriptor =\n    importer.Import(\"google/protobuf/unittest.proto\");\n  EXPECT_EQ(\"\", error_collector.text_);\n  ASSERT_TRUE(parsed_descriptor != NULL);\n\n  // Test that descriptors are generated correctly by converting them to\n  // FileDescriptorProtos and comparing.\n  FileDescriptorProto generated_decsriptor_proto, parsed_descriptor_proto;\n  generated_descriptor->CopyTo(&generated_decsriptor_proto);\n  parsed_descriptor->CopyTo(&parsed_descriptor_proto);\n\n  EXPECT_EQ(parsed_descriptor_proto.DebugString(),\n            generated_decsriptor_proto.DebugString());\n}\n\n#if !defined(GOOGLE_PROTOBUF_CMAKE_BUILD) && !defined(_MSC_VER)\n// Test that generated code has proper descriptors:\n// Touch a descriptor generated from an enormous message to validate special\n// handling for descriptors exceeding the C++ standard's recommended minimum\n// limit for string literal size\nTEST(GeneratedDescriptorTest, EnormousDescriptor) {\n  const Descriptor* generated_descriptor =\n    TestEnormousDescriptor::descriptor();\n\n  EXPECT_TRUE(generated_descriptor != NULL);\n}\n#endif\n\n#endif  // !PROTOBUF_TEST_NO_DESCRIPTORS\n\n// ===================================================================\n\nTEST(GeneratedMessageTest, Defaults) {\n  // Check that all default values are set correctly in the initial message.\n  unittest::TestAllTypes message;\n\n  TestUtil::ExpectClear(message);\n\n  // Messages should return pointers to default instances until first use.\n  // (This is not checked by ExpectClear() since it is not actually true after\n  // the fields have been set and then cleared.)\n  EXPECT_EQ(&unittest::TestAllTypes::OptionalGroup::default_instance(),\n            &message.optionalgroup());\n  EXPECT_EQ(&unittest::TestAllTypes::NestedMessage::default_instance(),\n            &message.optional_nested_message());\n  EXPECT_EQ(&unittest::ForeignMessage::default_instance(),\n            &message.optional_foreign_message());\n  EXPECT_EQ(&unittest_import::ImportMessage::default_instance(),\n            &message.optional_import_message());\n}\n\n#ifndef PROTOBUF_USE_DLLS\nTEST(GeneratedMessageTest, Int32StringConversion) {\n  EXPECT_EQ(\"971\", Int32ToString(971));\n  EXPECT_EQ(\"(~0x7fffffff)\", Int32ToString(kint32min));\n  EXPECT_EQ(\"2147483647\", Int32ToString(kint32max));\n}\n\nTEST(GeneratedMessageTest, Int64StringConversion) {\n  EXPECT_EQ(\"GOOGLE_LONGLONG(971)\", Int64ToString(971));\n  EXPECT_EQ(\"GOOGLE_LONGLONG(-2147483648)\", Int64ToString(kint32min));\n  EXPECT_EQ(\"GOOGLE_LONGLONG(~0x7fffffffffffffff)\", Int64ToString(kint64min));\n  EXPECT_EQ(\"GOOGLE_LONGLONG(9223372036854775807)\", Int64ToString(kint64max));\n}\n#endif  // !PROTOBUF_USE_DLLS\n\nTEST(GeneratedMessageTest, FloatingPointDefaults) {\n  const unittest::TestExtremeDefaultValues& extreme_default =\n      unittest::TestExtremeDefaultValues::default_instance();\n\n  EXPECT_EQ(0.0f, extreme_default.zero_float());\n  EXPECT_EQ(1.0f, extreme_default.one_float());\n  EXPECT_EQ(1.5f, extreme_default.small_float());\n  EXPECT_EQ(-1.0f, extreme_default.negative_one_float());\n  EXPECT_EQ(-1.5f, extreme_default.negative_float());\n  EXPECT_EQ(2.0e8f, extreme_default.large_float());\n  EXPECT_EQ(-8e-28f, extreme_default.small_negative_float());\n  EXPECT_EQ(numeric_limits<double>::infinity(),\n            extreme_default.inf_double());\n  EXPECT_EQ(-numeric_limits<double>::infinity(),\n            extreme_default.neg_inf_double());\n  EXPECT_TRUE(extreme_default.nan_double() != extreme_default.nan_double());\n  EXPECT_EQ(numeric_limits<float>::infinity(),\n            extreme_default.inf_float());\n  EXPECT_EQ(-numeric_limits<float>::infinity(),\n            extreme_default.neg_inf_float());\n  EXPECT_TRUE(extreme_default.nan_float() != extreme_default.nan_float());\n}\n\nTEST(GeneratedMessageTest, Trigraph) {\n  const unittest::TestExtremeDefaultValues& extreme_default =\n      unittest::TestExtremeDefaultValues::default_instance();\n\n  EXPECT_EQ(\"? ? ?? ?? ??? ?\\?/ ?\\?-\", extreme_default.cpp_trigraph());\n}\n\nTEST(GeneratedMessageTest, ExtremeSmallIntegerDefault) {\n  const unittest::TestExtremeDefaultValues& extreme_default =\n      unittest::TestExtremeDefaultValues::default_instance();\n  EXPECT_EQ(~0x7fffffff, kint32min);\n  EXPECT_EQ(GOOGLE_LONGLONG(~0x7fffffffffffffff), kint64min);\n  EXPECT_EQ(kint32min, extreme_default.really_small_int32());\n  EXPECT_EQ(kint64min, extreme_default.really_small_int64());\n}\n\nTEST(GeneratedMessageTest, Accessors) {\n  // Set every field to a unique value then go back and check all those\n  // values.\n  unittest::TestAllTypes message;\n\n  TestUtil::SetAllFields(&message);\n  TestUtil::ExpectAllFieldsSet(message);\n\n  TestUtil::ModifyRepeatedFields(&message);\n  TestUtil::ExpectRepeatedFieldsModified(message);\n}\n\nTEST(GeneratedMessageTest, MutableStringDefault) {\n  // mutable_foo() for a string should return a string initialized to its\n  // default value.\n  unittest::TestAllTypes message;\n\n  EXPECT_EQ(\"hello\", *message.mutable_default_string());\n\n  // Note that the first time we call mutable_foo(), we get a newly-allocated\n  // string, but if we clear it and call it again, we get the same object again.\n  // We should verify that it has its default value in both cases.\n  message.set_default_string(\"blah\");\n  message.Clear();\n\n  EXPECT_EQ(\"hello\", *message.mutable_default_string());\n}\n\nTEST(GeneratedMessageTest, StringDefaults) {\n  unittest::TestExtremeDefaultValues message;\n  // Check if '\\000' can be used in default string value.\n  EXPECT_EQ(string(\"hel\\000lo\", 6), message.string_with_zero());\n  EXPECT_EQ(string(\"wor\\000ld\", 6), message.bytes_with_zero());\n}\n\nTEST(GeneratedMessageTest, ReleaseString) {\n  // Check that release_foo() starts out NULL, and gives us a value\n  // that we can delete after it's been set.\n  unittest::TestAllTypes message;\n\n  EXPECT_EQ(NULL, message.release_default_string());\n  EXPECT_FALSE(message.has_default_string());\n  EXPECT_EQ(\"hello\", message.default_string());\n\n  message.set_default_string(\"blah\");\n  EXPECT_TRUE(message.has_default_string());\n  google::protobuf::scoped_ptr<string> str(message.release_default_string());\n  EXPECT_FALSE(message.has_default_string());\n  ASSERT_TRUE(str != NULL);\n  EXPECT_EQ(\"blah\", *str);\n\n  EXPECT_EQ(NULL, message.release_default_string());\n  EXPECT_FALSE(message.has_default_string());\n  EXPECT_EQ(\"hello\", message.default_string());\n}\n\nTEST(GeneratedMessageTest, ReleaseMessage) {\n  // Check that release_foo() starts out NULL, and gives us a value\n  // that we can delete after it's been set.\n  unittest::TestAllTypes message;\n\n  EXPECT_EQ(NULL, message.release_optional_nested_message());\n  EXPECT_FALSE(message.has_optional_nested_message());\n\n  message.mutable_optional_nested_message()->set_bb(1);\n  google::protobuf::scoped_ptr<unittest::TestAllTypes::NestedMessage> nest(\n      message.release_optional_nested_message());\n  EXPECT_FALSE(message.has_optional_nested_message());\n  ASSERT_TRUE(nest != NULL);\n  EXPECT_EQ(1, nest->bb());\n\n  EXPECT_EQ(NULL, message.release_optional_nested_message());\n  EXPECT_FALSE(message.has_optional_nested_message());\n}\n\nTEST(GeneratedMessageTest, SetAllocatedString) {\n  // Check that set_allocated_foo() works for strings.\n  unittest::TestAllTypes message;\n\n  EXPECT_FALSE(message.has_optional_string());\n  const string kHello(\"hello\");\n  message.set_optional_string(kHello);\n  EXPECT_TRUE(message.has_optional_string());\n\n  message.set_allocated_optional_string(NULL);\n  EXPECT_FALSE(message.has_optional_string());\n  EXPECT_EQ(\"\", message.optional_string());\n\n  message.set_allocated_optional_string(new string(kHello));\n  EXPECT_TRUE(message.has_optional_string());\n  EXPECT_EQ(kHello, message.optional_string());\n}\n\nTEST(GeneratedMessageTest, SetAllocatedMessage) {\n  // Check that set_allocated_foo() can be called in all cases.\n  unittest::TestAllTypes message;\n\n  EXPECT_FALSE(message.has_optional_nested_message());\n\n  message.mutable_optional_nested_message()->set_bb(1);\n  EXPECT_TRUE(message.has_optional_nested_message());\n\n  message.set_allocated_optional_nested_message(NULL);\n  EXPECT_FALSE(message.has_optional_nested_message());\n  EXPECT_EQ(&unittest::TestAllTypes::NestedMessage::default_instance(),\n            &message.optional_nested_message());\n\n  message.mutable_optional_nested_message()->set_bb(1);\n  unittest::TestAllTypes::NestedMessage* nest =\n      message.release_optional_nested_message();\n  ASSERT_TRUE(nest != NULL);\n  EXPECT_FALSE(message.has_optional_nested_message());\n\n  message.set_allocated_optional_nested_message(nest);\n  EXPECT_TRUE(message.has_optional_nested_message());\n  EXPECT_EQ(1, message.optional_nested_message().bb());\n}\n\nTEST(GeneratedMessageTest, Clear) {\n  // Set every field to a unique value, clear the message, then check that\n  // it is cleared.\n  unittest::TestAllTypes message;\n\n  TestUtil::SetAllFields(&message);\n  message.Clear();\n  TestUtil::ExpectClear(message);\n\n  // Unlike with the defaults test, we do NOT expect that requesting embedded\n  // messages will return a pointer to the default instance.  Instead, they\n  // should return the objects that were created when mutable_blah() was\n  // called.\n  EXPECT_NE(&unittest::TestAllTypes::OptionalGroup::default_instance(),\n            &message.optionalgroup());\n  EXPECT_NE(&unittest::TestAllTypes::NestedMessage::default_instance(),\n            &message.optional_nested_message());\n  EXPECT_NE(&unittest::ForeignMessage::default_instance(),\n            &message.optional_foreign_message());\n  EXPECT_NE(&unittest_import::ImportMessage::default_instance(),\n            &message.optional_import_message());\n}\n\nTEST(GeneratedMessageTest, EmbeddedNullsInBytesCharStar) {\n  unittest::TestAllTypes message;\n\n  const char* value = \"\\0lalala\\0\\0\";\n  message.set_optional_bytes(value, 9);\n  ASSERT_EQ(9, message.optional_bytes().size());\n  EXPECT_EQ(0, memcmp(value, message.optional_bytes().data(), 9));\n\n  message.add_repeated_bytes(value, 9);\n  ASSERT_EQ(9, message.repeated_bytes(0).size());\n  EXPECT_EQ(0, memcmp(value, message.repeated_bytes(0).data(), 9));\n}\n\nTEST(GeneratedMessageTest, ClearOneField) {\n  // Set every field to a unique value, then clear one value and insure that\n  // only that one value is cleared.\n  unittest::TestAllTypes message;\n\n  TestUtil::SetAllFields(&message);\n  int64 original_value = message.optional_int64();\n\n  // Clear the field and make sure it shows up as cleared.\n  message.clear_optional_int64();\n  EXPECT_FALSE(message.has_optional_int64());\n  EXPECT_EQ(0, message.optional_int64());\n\n  // Other adjacent fields should not be cleared.\n  EXPECT_TRUE(message.has_optional_int32());\n  EXPECT_TRUE(message.has_optional_uint32());\n\n  // Make sure if we set it again, then all fields are set.\n  message.set_optional_int64(original_value);\n  TestUtil::ExpectAllFieldsSet(message);\n}\n\nTEST(GeneratedMessageTest, StringCharStarLength) {\n  // Verify that we can use a char*,length to set one of the string fields.\n  unittest::TestAllTypes message;\n  message.set_optional_string(\"abcdef\", 3);\n  EXPECT_EQ(\"abc\", message.optional_string());\n\n  // Verify that we can use a char*,length to add to a repeated string field.\n  message.add_repeated_string(\"abcdef\", 3);\n  EXPECT_EQ(1, message.repeated_string_size());\n  EXPECT_EQ(\"abc\", message.repeated_string(0));\n\n  // Verify that we can use a char*,length to set a repeated string field.\n  message.set_repeated_string(0, \"wxyz\", 2);\n  EXPECT_EQ(\"wx\", message.repeated_string(0));\n}\n\n\nTEST(GeneratedMessageTest, CopyFrom) {\n  unittest::TestAllTypes message1, message2;\n\n  TestUtil::SetAllFields(&message1);\n  message2.CopyFrom(message1);\n  TestUtil::ExpectAllFieldsSet(message2);\n\n  // Copying from self should be a no-op.\n  message2.CopyFrom(message2);\n  TestUtil::ExpectAllFieldsSet(message2);\n}\n\n\nTEST(GeneratedMessageTest, SwapWithEmpty) {\n  unittest::TestAllTypes message1, message2;\n  TestUtil::SetAllFields(&message1);\n\n  TestUtil::ExpectAllFieldsSet(message1);\n  TestUtil::ExpectClear(message2);\n  message1.Swap(&message2);\n  TestUtil::ExpectAllFieldsSet(message2);\n  TestUtil::ExpectClear(message1);\n}\n\nTEST(GeneratedMessageTest, SwapWithSelf) {\n  unittest::TestAllTypes message;\n  TestUtil::SetAllFields(&message);\n  TestUtil::ExpectAllFieldsSet(message);\n  message.Swap(&message);\n  TestUtil::ExpectAllFieldsSet(message);\n}\n\nTEST(GeneratedMessageTest, SwapWithOther) {\n  unittest::TestAllTypes message1, message2;\n\n  message1.set_optional_int32(123);\n  message1.set_optional_string(\"abc\");\n  message1.mutable_optional_nested_message()->set_bb(1);\n  message1.set_optional_nested_enum(unittest::TestAllTypes::FOO);\n  message1.add_repeated_int32(1);\n  message1.add_repeated_int32(2);\n  message1.add_repeated_string(\"a\");\n  message1.add_repeated_string(\"b\");\n  message1.add_repeated_nested_message()->set_bb(7);\n  message1.add_repeated_nested_message()->set_bb(8);\n  message1.add_repeated_nested_enum(unittest::TestAllTypes::FOO);\n  message1.add_repeated_nested_enum(unittest::TestAllTypes::BAR);\n\n  message2.set_optional_int32(456);\n  message2.set_optional_string(\"def\");\n  message2.mutable_optional_nested_message()->set_bb(2);\n  message2.set_optional_nested_enum(unittest::TestAllTypes::BAR);\n  message2.add_repeated_int32(3);\n  message2.add_repeated_string(\"c\");\n  message2.add_repeated_nested_message()->set_bb(9);\n  message2.add_repeated_nested_enum(unittest::TestAllTypes::BAZ);\n\n  message1.Swap(&message2);\n\n  EXPECT_EQ(456, message1.optional_int32());\n  EXPECT_EQ(\"def\", message1.optional_string());\n  EXPECT_EQ(2, message1.optional_nested_message().bb());\n  EXPECT_EQ(unittest::TestAllTypes::BAR, message1.optional_nested_enum());\n  ASSERT_EQ(1, message1.repeated_int32_size());\n  EXPECT_EQ(3, message1.repeated_int32(0));\n  ASSERT_EQ(1, message1.repeated_string_size());\n  EXPECT_EQ(\"c\", message1.repeated_string(0));\n  ASSERT_EQ(1, message1.repeated_nested_message_size());\n  EXPECT_EQ(9, message1.repeated_nested_message(0).bb());\n  ASSERT_EQ(1, message1.repeated_nested_enum_size());\n  EXPECT_EQ(unittest::TestAllTypes::BAZ, message1.repeated_nested_enum(0));\n\n  EXPECT_EQ(123, message2.optional_int32());\n  EXPECT_EQ(\"abc\", message2.optional_string());\n  EXPECT_EQ(1, message2.optional_nested_message().bb());\n  EXPECT_EQ(unittest::TestAllTypes::FOO, message2.optional_nested_enum());\n  ASSERT_EQ(2, message2.repeated_int32_size());\n  EXPECT_EQ(1, message2.repeated_int32(0));\n  EXPECT_EQ(2, message2.repeated_int32(1));\n  ASSERT_EQ(2, message2.repeated_string_size());\n  EXPECT_EQ(\"a\", message2.repeated_string(0));\n  EXPECT_EQ(\"b\", message2.repeated_string(1));\n  ASSERT_EQ(2, message2.repeated_nested_message_size());\n  EXPECT_EQ(7, message2.repeated_nested_message(0).bb());\n  EXPECT_EQ(8, message2.repeated_nested_message(1).bb());\n  ASSERT_EQ(2, message2.repeated_nested_enum_size());\n  EXPECT_EQ(unittest::TestAllTypes::FOO, message2.repeated_nested_enum(0));\n  EXPECT_EQ(unittest::TestAllTypes::BAR, message2.repeated_nested_enum(1));\n}\n\nTEST(GeneratedMessageTest, CopyConstructor) {\n  unittest::TestAllTypes message1;\n  TestUtil::SetAllFields(&message1);\n\n  unittest::TestAllTypes message2(message1);\n  TestUtil::ExpectAllFieldsSet(message2);\n}\n\nTEST(GeneratedMessageTest, CopyAssignmentOperator) {\n  unittest::TestAllTypes message1;\n  TestUtil::SetAllFields(&message1);\n\n  unittest::TestAllTypes message2;\n  message2 = message1;\n  TestUtil::ExpectAllFieldsSet(message2);\n\n  // Make sure that self-assignment does something sane.\n  message2.operator=(message2);\n  TestUtil::ExpectAllFieldsSet(message2);\n}\n\n#if !defined(PROTOBUF_TEST_NO_DESCRIPTORS) || \\\n    !defined(GOOGLE_PROTOBUF_NO_RTTI)\nTEST(GeneratedMessageTest, UpcastCopyFrom) {\n  // Test the CopyFrom method that takes in the generic const Message&\n  // parameter.\n  unittest::TestAllTypes message1, message2;\n\n  TestUtil::SetAllFields(&message1);\n\n  const Message* source = implicit_cast<const Message*>(&message1);\n  message2.CopyFrom(*source);\n\n  TestUtil::ExpectAllFieldsSet(message2);\n}\n#endif\n\n#ifndef PROTOBUF_TEST_NO_DESCRIPTORS\n\nTEST(GeneratedMessageTest, DynamicMessageCopyFrom) {\n  // Test copying from a DynamicMessage, which must fall back to using\n  // reflection.\n  unittest::TestAllTypes message2;\n\n  // Construct a new version of the dynamic message via the factory.\n  DynamicMessageFactory factory;\n  google::protobuf::scoped_ptr<Message> message1;\n  message1.reset(factory.GetPrototype(\n                     unittest::TestAllTypes::descriptor())->New());\n\n  TestUtil::ReflectionTester reflection_tester(\n    unittest::TestAllTypes::descriptor());\n  reflection_tester.SetAllFieldsViaReflection(message1.get());\n\n  message2.CopyFrom(*message1);\n\n  TestUtil::ExpectAllFieldsSet(message2);\n}\n\n#endif  // !PROTOBUF_TEST_NO_DESCRIPTORS\n\nTEST(GeneratedMessageTest, NonEmptyMergeFrom) {\n  // Test merging with a non-empty message. Code is a modified form\n  // of that found in google/protobuf/reflection_ops_unittest.cc.\n  unittest::TestAllTypes message1, message2;\n\n  TestUtil::SetAllFields(&message1);\n\n  // This field will test merging into an empty spot.\n  message2.set_optional_int32(message1.optional_int32());\n  message1.clear_optional_int32();\n\n  // This tests overwriting.\n  message2.set_optional_string(message1.optional_string());\n  message1.set_optional_string(\"something else\");\n\n  // This tests concatenating.\n  message2.add_repeated_int32(message1.repeated_int32(1));\n  int32 i = message1.repeated_int32(0);\n  message1.clear_repeated_int32();\n  message1.add_repeated_int32(i);\n\n  message1.MergeFrom(message2);\n\n  TestUtil::ExpectAllFieldsSet(message1);\n}\n\n#if !defined(PROTOBUF_TEST_NO_DESCRIPTORS) || \\\n    !defined(GOOGLE_PROTOBUF_NO_RTTI)\n#ifdef PROTOBUF_HAS_DEATH_TEST\n\nTEST(GeneratedMessageTest, MergeFromSelf) {\n  unittest::TestAllTypes message;\n  EXPECT_DEATH(message.MergeFrom(message), \"Check failed:.*pb[.]cc\");\n  EXPECT_DEATH(message.MergeFrom(implicit_cast<const Message&>(message)),\n               \"Check failed:.*pb[.]cc\");\n}\n\n#endif  // PROTOBUF_HAS_DEATH_TEST\n#endif  // !PROTOBUF_TEST_NO_DESCRIPTORS || !GOOGLE_PROTOBUF_NO_RTTI\n\n// Test the generated SerializeWithCachedSizesToArray(),\nTEST(GeneratedMessageTest, SerializationToArray) {\n  unittest::TestAllTypes message1, message2;\n  string data;\n  TestUtil::SetAllFields(&message1);\n  int size = message1.ByteSize();\n  data.resize(size);\n  uint8* start = reinterpret_cast<uint8*>(string_as_array(&data));\n  uint8* end = message1.SerializeWithCachedSizesToArray(start);\n  EXPECT_EQ(size, end - start);\n  EXPECT_TRUE(message2.ParseFromString(data));\n  TestUtil::ExpectAllFieldsSet(message2);\n\n}\n\nTEST(GeneratedMessageTest, PackedFieldsSerializationToArray) {\n  unittest::TestPackedTypes packed_message1, packed_message2;\n  string packed_data;\n  TestUtil::SetPackedFields(&packed_message1);\n  int packed_size = packed_message1.ByteSize();\n  packed_data.resize(packed_size);\n  uint8* start = reinterpret_cast<uint8*>(string_as_array(&packed_data));\n  uint8* end = packed_message1.SerializeWithCachedSizesToArray(start);\n  EXPECT_EQ(packed_size, end - start);\n  EXPECT_TRUE(packed_message2.ParseFromString(packed_data));\n  TestUtil::ExpectPackedFieldsSet(packed_message2);\n}\n\n// Test the generated SerializeWithCachedSizes() by forcing the buffer to write\n// one byte at a time.\nTEST(GeneratedMessageTest, SerializationToStream) {\n  unittest::TestAllTypes message1, message2;\n  TestUtil::SetAllFields(&message1);\n  int size = message1.ByteSize();\n  string data;\n  data.resize(size);\n  {\n    // Allow the output stream to buffer only one byte at a time.\n    io::ArrayOutputStream array_stream(string_as_array(&data), size, 1);\n    io::CodedOutputStream output_stream(&array_stream);\n    message1.SerializeWithCachedSizes(&output_stream);\n    EXPECT_FALSE(output_stream.HadError());\n    EXPECT_EQ(size, output_stream.ByteCount());\n  }\n  EXPECT_TRUE(message2.ParseFromString(data));\n  TestUtil::ExpectAllFieldsSet(message2);\n\n}\n\nTEST(GeneratedMessageTest, PackedFieldsSerializationToStream) {\n  unittest::TestPackedTypes message1, message2;\n  TestUtil::SetPackedFields(&message1);\n  int size = message1.ByteSize();\n  string data;\n  data.resize(size);\n  {\n    // Allow the output stream to buffer only one byte at a time.\n    io::ArrayOutputStream array_stream(string_as_array(&data), size, 1);\n    io::CodedOutputStream output_stream(&array_stream);\n    message1.SerializeWithCachedSizes(&output_stream);\n    EXPECT_FALSE(output_stream.HadError());\n    EXPECT_EQ(size, output_stream.ByteCount());\n  }\n  EXPECT_TRUE(message2.ParseFromString(data));\n  TestUtil::ExpectPackedFieldsSet(message2);\n}\n\n\nTEST(GeneratedMessageTest, Required) {\n  // Test that IsInitialized() returns false if required fields are missing.\n  unittest::TestRequired message;\n\n  EXPECT_FALSE(message.IsInitialized());\n  message.set_a(1);\n  EXPECT_FALSE(message.IsInitialized());\n  message.set_b(2);\n  EXPECT_FALSE(message.IsInitialized());\n  message.set_c(3);\n  EXPECT_TRUE(message.IsInitialized());\n}\n\nTEST(GeneratedMessageTest, RequiredForeign) {\n  // Test that IsInitialized() returns false if required fields in nested\n  // messages are missing.\n  unittest::TestRequiredForeign message;\n\n  EXPECT_TRUE(message.IsInitialized());\n\n  message.mutable_optional_message();\n  EXPECT_FALSE(message.IsInitialized());\n\n  message.mutable_optional_message()->set_a(1);\n  message.mutable_optional_message()->set_b(2);\n  message.mutable_optional_message()->set_c(3);\n  EXPECT_TRUE(message.IsInitialized());\n\n  message.add_repeated_message();\n  EXPECT_FALSE(message.IsInitialized());\n\n  message.mutable_repeated_message(0)->set_a(1);\n  message.mutable_repeated_message(0)->set_b(2);\n  message.mutable_repeated_message(0)->set_c(3);\n  EXPECT_TRUE(message.IsInitialized());\n}\n\nTEST(GeneratedMessageTest, ForeignNested) {\n  // Test that TestAllTypes::NestedMessage can be embedded directly into\n  // another message.\n  unittest::TestForeignNested message;\n\n  // If this compiles and runs without crashing, it must work.  We have\n  // nothing more to test.\n  unittest::TestAllTypes::NestedMessage* nested =\n    message.mutable_foreign_nested();\n  nested->set_bb(1);\n}\n\nTEST(GeneratedMessageTest, ReallyLargeTagNumber) {\n  // Test that really large tag numbers don't break anything.\n  unittest::TestReallyLargeTagNumber message1, message2;\n  string data;\n\n  // For the most part, if this compiles and runs then we're probably good.\n  // (The most likely cause for failure would be if something were attempting\n  // to allocate a lookup table of some sort using tag numbers as the index.)\n  // We'll try serializing just for fun.\n  message1.set_a(1234);\n  message1.set_bb(5678);\n  message1.SerializeToString(&data);\n  EXPECT_TRUE(message2.ParseFromString(data));\n  EXPECT_EQ(1234, message2.a());\n  EXPECT_EQ(5678, message2.bb());\n}\n\nTEST(GeneratedMessageTest, MutualRecursion) {\n  // Test that mutually-recursive message types work.\n  unittest::TestMutualRecursionA message;\n  unittest::TestMutualRecursionA* nested = message.mutable_bb()->mutable_a();\n  unittest::TestMutualRecursionA* nested2 = nested->mutable_bb()->mutable_a();\n\n  // Again, if the above compiles and runs, that's all we really have to\n  // test, but just for run we'll check that the system didn't somehow come\n  // up with a pointer loop...\n  EXPECT_NE(&message, nested);\n  EXPECT_NE(&message, nested2);\n  EXPECT_NE(nested, nested2);\n}\n\nTEST(GeneratedMessageTest, CamelCaseFieldNames) {\n  // This test is mainly checking that the following compiles, which verifies\n  // that the field names were coerced to lower-case.\n  //\n  // Protocol buffers standard style is to use lowercase-with-underscores for\n  // field names.  Some old proto1 .protos unfortunately used camel-case field\n  // names.  In proto1, these names were forced to lower-case.  So, we do the\n  // same thing in proto2.\n\n  unittest::TestCamelCaseFieldNames message;\n\n  message.set_primitivefield(2);\n  message.set_stringfield(\"foo\");\n  message.set_enumfield(unittest::FOREIGN_FOO);\n  message.mutable_messagefield()->set_c(6);\n\n  message.add_repeatedprimitivefield(8);\n  message.add_repeatedstringfield(\"qux\");\n  message.add_repeatedenumfield(unittest::FOREIGN_BAR);\n  message.add_repeatedmessagefield()->set_c(15);\n\n  EXPECT_EQ(2, message.primitivefield());\n  EXPECT_EQ(\"foo\", message.stringfield());\n  EXPECT_EQ(unittest::FOREIGN_FOO, message.enumfield());\n  EXPECT_EQ(6, message.messagefield().c());\n\n  EXPECT_EQ(8, message.repeatedprimitivefield(0));\n  EXPECT_EQ(\"qux\", message.repeatedstringfield(0));\n  EXPECT_EQ(unittest::FOREIGN_BAR, message.repeatedenumfield(0));\n  EXPECT_EQ(15, message.repeatedmessagefield(0).c());\n}\n\nTEST(GeneratedMessageTest, TestConflictingSymbolNames) {\n  // test_bad_identifiers.proto successfully compiled, then it works.  The\n  // following is just a token usage to insure that the code is, in fact,\n  // being compiled and linked.\n\n  protobuf_unittest::TestConflictingSymbolNames message;\n  message.set_uint32(1);\n  EXPECT_EQ(3, message.ByteSize());\n\n  message.set_friend_(5);\n  EXPECT_EQ(5, message.friend_());\n\n  message.set_class_(6);\n  EXPECT_EQ(6, message.class_());\n\n  // Instantiate extension template functions to test conflicting template\n  // parameter names.\n  typedef protobuf_unittest::TestConflictingSymbolNamesExtension ExtensionMessage;\n  message.AddExtension(ExtensionMessage::repeated_int32_ext, 123);\n  EXPECT_EQ(123,\n            message.GetExtension(ExtensionMessage::repeated_int32_ext, 0));\n}\n\nTEST(GeneratedMessageTest, TestConflictingEnumNames) {\n  protobuf_unittest::TestConflictingEnumNames message;\n  message.set_conflicting_enum(protobuf_unittest::TestConflictingEnumNames_NestedConflictingEnum_and_);\n  EXPECT_EQ(1, message.conflicting_enum());\n  message.set_conflicting_enum(protobuf_unittest::TestConflictingEnumNames_NestedConflictingEnum_XOR);\n  EXPECT_EQ(5, message.conflicting_enum());\n\n\n  protobuf_unittest::ConflictingEnum conflicting_enum;\n  conflicting_enum = protobuf_unittest::NOT_EQ;\n  EXPECT_EQ(1, conflicting_enum);\n  conflicting_enum = protobuf_unittest::return_;\n  EXPECT_EQ(3, conflicting_enum);\n}\n\n#ifndef PROTOBUF_TEST_NO_DESCRIPTORS\n\nTEST(GeneratedMessageTest, TestOptimizedForSize) {\n  // We rely on the tests in reflection_ops_unittest and wire_format_unittest\n  // to really test that reflection-based methods work.  Here we are mostly\n  // just making sure that TestOptimizedForSize actually builds and seems to\n  // function.\n\n  protobuf_unittest::TestOptimizedForSize message, message2;\n  message.set_i(1);\n  message.mutable_msg()->set_c(2);\n  message2.CopyFrom(message);\n  EXPECT_EQ(1, message2.i());\n  EXPECT_EQ(2, message2.msg().c());\n}\n\nTEST(GeneratedMessageTest, TestEmbedOptimizedForSize) {\n  // Verifies that something optimized for speed can contain something optimized\n  // for size.\n\n  protobuf_unittest::TestEmbedOptimizedForSize message, message2;\n  message.mutable_optional_message()->set_i(1);\n  message.add_repeated_message()->mutable_msg()->set_c(2);\n  string data;\n  message.SerializeToString(&data);\n  ASSERT_TRUE(message2.ParseFromString(data));\n  EXPECT_EQ(1, message2.optional_message().i());\n  EXPECT_EQ(2, message2.repeated_message(0).msg().c());\n}\n\nTEST(GeneratedMessageTest, TestSpaceUsed) {\n  unittest::TestAllTypes message1;\n  // sizeof provides a lower bound on SpaceUsed().\n  EXPECT_LE(sizeof(unittest::TestAllTypes), message1.SpaceUsed());\n  const int empty_message_size = message1.SpaceUsed();\n\n  // Setting primitive types shouldn't affect the space used.\n  message1.set_optional_int32(123);\n  message1.set_optional_int64(12345);\n  message1.set_optional_uint32(123);\n  message1.set_optional_uint64(12345);\n  EXPECT_EQ(empty_message_size, message1.SpaceUsed());\n\n  // On some STL implementations, setting the string to a small value should\n  // only increase SpaceUsed() by the size of a string object, though this is\n  // not true everywhere.\n  message1.set_optional_string(\"abc\");\n  EXPECT_LE(empty_message_size + sizeof(string), message1.SpaceUsed());\n\n  // Setting a string to a value larger than the string object itself should\n  // increase SpaceUsed(), because it cannot store the value internally.\n  message1.set_optional_string(string(sizeof(string) + 1, 'x'));\n  int min_expected_increase = message1.optional_string().capacity() +\n      sizeof(string);\n  EXPECT_LE(empty_message_size + min_expected_increase,\n            message1.SpaceUsed());\n\n  int previous_size = message1.SpaceUsed();\n  // Adding an optional message should increase the size by the size of the\n  // nested message type. NestedMessage is simple enough (1 int field) that it\n  // is equal to sizeof(NestedMessage)\n  message1.mutable_optional_nested_message();\n  ASSERT_EQ(sizeof(unittest::TestAllTypes::NestedMessage),\n            message1.optional_nested_message().SpaceUsed());\n  EXPECT_EQ(previous_size +\n            sizeof(unittest::TestAllTypes::NestedMessage),\n            message1.SpaceUsed());\n}\n\nTEST(GeneratedMessageTest, TestOneofSpaceUsed) {\n  unittest::TestOneof2 message1;\n  EXPECT_LE(sizeof(unittest::TestOneof2), message1.SpaceUsed());\n\n  const int empty_message_size = message1.SpaceUsed();\n  // Setting primitive types shouldn't affect the space used.\n  message1.set_foo_int(123);\n  message1.set_bar_int(12345);\n  EXPECT_EQ(empty_message_size, message1.SpaceUsed());\n\n  // Setting a string in oneof to a small value should only increase SpaceUsed()\n  // by the size of a string object.\n  message1.set_foo_string(\"abc\");\n  EXPECT_LE(empty_message_size + sizeof(string), message1.SpaceUsed());\n\n  // Setting a string in oneof to a value larger than the string object itself\n  // should increase SpaceUsed(), because it cannot store the value internally.\n  message1.set_foo_string(string(sizeof(string) + 1, 'x'));\n  int min_expected_increase = message1.foo_string().capacity() +\n      sizeof(string);\n  EXPECT_LE(empty_message_size + min_expected_increase,\n            message1.SpaceUsed());\n\n  // Setting a message in oneof should delete the other fields and increase the\n  // size by the size of the nested message type. NestedMessage is simple enough\n  // that it is equal to sizeof(NestedMessage)\n  message1.mutable_foo_message();\n  ASSERT_EQ(sizeof(unittest::TestOneof2::NestedMessage),\n            message1.foo_message().SpaceUsed());\n  EXPECT_EQ(empty_message_size +\n            sizeof(unittest::TestOneof2::NestedMessage),\n            message1.SpaceUsed());\n}\n\n#endif  // !PROTOBUF_TEST_NO_DESCRIPTORS\n\n\nTEST(GeneratedMessageTest, FieldConstantValues) {\n  unittest::TestRequired message;\n  EXPECT_EQ(unittest::TestAllTypes_NestedMessage::kBbFieldNumber, 1);\n  EXPECT_EQ(unittest::TestAllTypes::kOptionalInt32FieldNumber, 1);\n  EXPECT_EQ(unittest::TestAllTypes::kOptionalgroupFieldNumber, 16);\n  EXPECT_EQ(unittest::TestAllTypes::kOptionalNestedMessageFieldNumber, 18);\n  EXPECT_EQ(unittest::TestAllTypes::kOptionalNestedEnumFieldNumber, 21);\n  EXPECT_EQ(unittest::TestAllTypes::kRepeatedInt32FieldNumber, 31);\n  EXPECT_EQ(unittest::TestAllTypes::kRepeatedgroupFieldNumber, 46);\n  EXPECT_EQ(unittest::TestAllTypes::kRepeatedNestedMessageFieldNumber, 48);\n  EXPECT_EQ(unittest::TestAllTypes::kRepeatedNestedEnumFieldNumber, 51);\n}\n\nTEST(GeneratedMessageTest, ExtensionConstantValues) {\n  EXPECT_EQ(unittest::TestRequired::kSingleFieldNumber, 1000);\n  EXPECT_EQ(unittest::TestRequired::kMultiFieldNumber, 1001);\n  EXPECT_EQ(unittest::kOptionalInt32ExtensionFieldNumber, 1);\n  EXPECT_EQ(unittest::kOptionalgroupExtensionFieldNumber, 16);\n  EXPECT_EQ(unittest::kOptionalNestedMessageExtensionFieldNumber, 18);\n  EXPECT_EQ(unittest::kOptionalNestedEnumExtensionFieldNumber, 21);\n  EXPECT_EQ(unittest::kRepeatedInt32ExtensionFieldNumber, 31);\n  EXPECT_EQ(unittest::kRepeatedgroupExtensionFieldNumber, 46);\n  EXPECT_EQ(unittest::kRepeatedNestedMessageExtensionFieldNumber, 48);\n  EXPECT_EQ(unittest::kRepeatedNestedEnumExtensionFieldNumber, 51);\n}\n\nTEST(GeneratedMessageTest, ParseFromTruncated) {\n  const string long_string = string(128, 'q');\n  FileDescriptorProto p;\n  p.add_extension()->set_name(long_string);\n  const string msg = p.SerializeAsString();\n  int successful_count = 0;\n  for (int i = 0; i <= msg.size(); i++) {\n    if (p.ParseFromArray(msg.c_str(), i)) {\n      ++successful_count;\n    }\n  }\n  // We don't really care about how often we succeeded.\n  // As long as we didn't crash, we're happy.\n  EXPECT_GE(successful_count, 1);\n}\n\n// ===================================================================\n\nTEST(GeneratedEnumTest, EnumValuesAsSwitchCases) {\n  // Test that our nested enum values can be used as switch cases.  This test\n  // doesn't actually do anything, the proof that it works is that it\n  // compiles.\n  int i =0;\n  unittest::TestAllTypes::NestedEnum a = unittest::TestAllTypes::BAR;\n  switch (a) {\n    case unittest::TestAllTypes::FOO:\n      i = 1;\n      break;\n    case unittest::TestAllTypes::BAR:\n      i = 2;\n      break;\n    case unittest::TestAllTypes::BAZ:\n      i = 3;\n      break;\n    case unittest::TestAllTypes::NEG:\n      i = -1;\n      break;\n    // no default case:  We want to make sure the compiler recognizes that\n    //   all cases are covered.  (GCC warns if you do not cover all cases of\n    //   an enum in a switch.)\n  }\n\n  // Token check just for fun.\n  EXPECT_EQ(2, i);\n}\n\nTEST(GeneratedEnumTest, IsValidValue) {\n  // Test enum IsValidValue.\n  EXPECT_TRUE(unittest::TestAllTypes::NestedEnum_IsValid(1));\n  EXPECT_TRUE(unittest::TestAllTypes::NestedEnum_IsValid(2));\n  EXPECT_TRUE(unittest::TestAllTypes::NestedEnum_IsValid(3));\n\n  EXPECT_FALSE(unittest::TestAllTypes::NestedEnum_IsValid(0));\n  EXPECT_FALSE(unittest::TestAllTypes::NestedEnum_IsValid(4));\n\n  // Make sure it also works when there are dups.\n  EXPECT_TRUE(unittest::TestEnumWithDupValue_IsValid(1));\n  EXPECT_TRUE(unittest::TestEnumWithDupValue_IsValid(2));\n  EXPECT_TRUE(unittest::TestEnumWithDupValue_IsValid(3));\n\n  EXPECT_FALSE(unittest::TestEnumWithDupValue_IsValid(0));\n  EXPECT_FALSE(unittest::TestEnumWithDupValue_IsValid(4));\n}\n\nTEST(GeneratedEnumTest, MinAndMax) {\n  EXPECT_EQ(unittest::TestAllTypes::NEG,\n            unittest::TestAllTypes::NestedEnum_MIN);\n  EXPECT_EQ(unittest::TestAllTypes::BAZ,\n            unittest::TestAllTypes::NestedEnum_MAX);\n  EXPECT_EQ(4, unittest::TestAllTypes::NestedEnum_ARRAYSIZE);\n\n  EXPECT_EQ(unittest::FOREIGN_FOO, unittest::ForeignEnum_MIN);\n  EXPECT_EQ(unittest::FOREIGN_BAZ, unittest::ForeignEnum_MAX);\n  EXPECT_EQ(7, unittest::ForeignEnum_ARRAYSIZE);\n\n  EXPECT_EQ(1, unittest::TestEnumWithDupValue_MIN);\n  EXPECT_EQ(3, unittest::TestEnumWithDupValue_MAX);\n  EXPECT_EQ(4, unittest::TestEnumWithDupValue_ARRAYSIZE);\n\n  EXPECT_EQ(unittest::SPARSE_E, unittest::TestSparseEnum_MIN);\n  EXPECT_EQ(unittest::SPARSE_C, unittest::TestSparseEnum_MAX);\n  EXPECT_EQ(12589235, unittest::TestSparseEnum_ARRAYSIZE);\n\n  // Make sure we can take the address of _MIN, _MAX and _ARRAYSIZE.\n  void* null_pointer = 0;  // NULL may be integer-type, not pointer-type.\n  EXPECT_NE(null_pointer, &unittest::TestAllTypes::NestedEnum_MIN);\n  EXPECT_NE(null_pointer, &unittest::TestAllTypes::NestedEnum_MAX);\n  EXPECT_NE(null_pointer, &unittest::TestAllTypes::NestedEnum_ARRAYSIZE);\n\n  EXPECT_NE(null_pointer, &unittest::ForeignEnum_MIN);\n  EXPECT_NE(null_pointer, &unittest::ForeignEnum_MAX);\n  EXPECT_NE(null_pointer, &unittest::ForeignEnum_ARRAYSIZE);\n\n  // Make sure we can use _MIN and _MAX as switch cases.\n  switch (unittest::SPARSE_A) {\n    case unittest::TestSparseEnum_MIN:\n    case unittest::TestSparseEnum_MAX:\n      break;\n    default:\n      break;\n  }\n}\n\n#ifndef PROTOBUF_TEST_NO_DESCRIPTORS\n\nTEST(GeneratedEnumTest, Name) {\n  // \"Names\" in the presence of dup values are a bit arbitrary.\n  EXPECT_EQ(\"FOO1\", unittest::TestEnumWithDupValue_Name(unittest::FOO1));\n  EXPECT_EQ(\"FOO1\", unittest::TestEnumWithDupValue_Name(unittest::FOO2));\n\n  EXPECT_EQ(\"SPARSE_A\", unittest::TestSparseEnum_Name(unittest::SPARSE_A));\n  EXPECT_EQ(\"SPARSE_B\", unittest::TestSparseEnum_Name(unittest::SPARSE_B));\n  EXPECT_EQ(\"SPARSE_C\", unittest::TestSparseEnum_Name(unittest::SPARSE_C));\n  EXPECT_EQ(\"SPARSE_D\", unittest::TestSparseEnum_Name(unittest::SPARSE_D));\n  EXPECT_EQ(\"SPARSE_E\", unittest::TestSparseEnum_Name(unittest::SPARSE_E));\n  EXPECT_EQ(\"SPARSE_F\", unittest::TestSparseEnum_Name(unittest::SPARSE_F));\n  EXPECT_EQ(\"SPARSE_G\", unittest::TestSparseEnum_Name(unittest::SPARSE_G));\n}\n\nTEST(GeneratedEnumTest, Parse) {\n  unittest::TestEnumWithDupValue dup_value = unittest::FOO1;\n  EXPECT_TRUE(unittest::TestEnumWithDupValue_Parse(\"FOO1\", &dup_value));\n  EXPECT_EQ(unittest::FOO1, dup_value);\n  EXPECT_TRUE(unittest::TestEnumWithDupValue_Parse(\"FOO2\", &dup_value));\n  EXPECT_EQ(unittest::FOO2, dup_value);\n  EXPECT_FALSE(unittest::TestEnumWithDupValue_Parse(\"FOO\", &dup_value));\n}\n\nTEST(GeneratedEnumTest, GetEnumDescriptor) {\n  EXPECT_EQ(unittest::TestAllTypes::NestedEnum_descriptor(),\n            GetEnumDescriptor<unittest::TestAllTypes::NestedEnum>());\n  EXPECT_EQ(unittest::ForeignEnum_descriptor(),\n            GetEnumDescriptor<unittest::ForeignEnum>());\n  EXPECT_EQ(unittest::TestEnumWithDupValue_descriptor(),\n            GetEnumDescriptor<unittest::TestEnumWithDupValue>());\n  EXPECT_EQ(unittest::TestSparseEnum_descriptor(),\n            GetEnumDescriptor<unittest::TestSparseEnum>());\n}\n\nenum NonProtoEnum {\n  kFoo = 1,\n};\n\nTEST(GeneratedEnumTest, IsProtoEnumTypeTrait) {\n  EXPECT_TRUE(is_proto_enum<unittest::TestAllTypes::NestedEnum>::value);\n  EXPECT_TRUE(is_proto_enum<unittest::ForeignEnum>::value);\n  EXPECT_TRUE(is_proto_enum<unittest::TestEnumWithDupValue>::value);\n  EXPECT_TRUE(is_proto_enum<unittest::TestSparseEnum>::value);\n\n  EXPECT_FALSE(is_proto_enum<int>::value);\n  EXPECT_FALSE(is_proto_enum<NonProtoEnum>::value);\n}\n\n#endif  // PROTOBUF_TEST_NO_DESCRIPTORS\n\n// ===================================================================\n\n#ifndef PROTOBUF_TEST_NO_DESCRIPTORS\n\n// Support code for testing services.\nclass GeneratedServiceTest : public testing::Test {\n protected:\n  class MockTestService : public unittest::TestService {\n   public:\n    MockTestService()\n      : called_(false),\n        method_(\"\"),\n        controller_(NULL),\n        request_(NULL),\n        response_(NULL),\n        done_(NULL) {}\n\n    ~MockTestService() {}\n\n    void Reset() { called_ = false; }\n\n    // implements TestService ----------------------------------------\n\n    void Foo(RpcController* controller,\n             const unittest::FooRequest* request,\n             unittest::FooResponse* response,\n             Closure* done) {\n      ASSERT_FALSE(called_);\n      called_ = true;\n      method_ = \"Foo\";\n      controller_ = controller;\n      request_ = request;\n      response_ = response;\n      done_ = done;\n    }\n\n    void Bar(RpcController* controller,\n             const unittest::BarRequest* request,\n             unittest::BarResponse* response,\n             Closure* done) {\n      ASSERT_FALSE(called_);\n      called_ = true;\n      method_ = \"Bar\";\n      controller_ = controller;\n      request_ = request;\n      response_ = response;\n      done_ = done;\n    }\n\n    // ---------------------------------------------------------------\n\n    bool called_;\n    string method_;\n    RpcController* controller_;\n    const Message* request_;\n    Message* response_;\n    Closure* done_;\n  };\n\n  class MockRpcChannel : public RpcChannel {\n   public:\n    MockRpcChannel()\n      : called_(false),\n        method_(NULL),\n        controller_(NULL),\n        request_(NULL),\n        response_(NULL),\n        done_(NULL),\n        destroyed_(NULL) {}\n\n    ~MockRpcChannel() {\n      if (destroyed_ != NULL) *destroyed_ = true;\n    }\n\n    void Reset() { called_ = false; }\n\n    // implements TestService ----------------------------------------\n\n    void CallMethod(const MethodDescriptor* method,\n                    RpcController* controller,\n                    const Message* request,\n                    Message* response,\n                    Closure* done) {\n      ASSERT_FALSE(called_);\n      called_ = true;\n      method_ = method;\n      controller_ = controller;\n      request_ = request;\n      response_ = response;\n      done_ = done;\n    }\n\n    // ---------------------------------------------------------------\n\n    bool called_;\n    const MethodDescriptor* method_;\n    RpcController* controller_;\n    const Message* request_;\n    Message* response_;\n    Closure* done_;\n    bool* destroyed_;\n  };\n\n  class MockController : public RpcController {\n   public:\n    void Reset() {\n      ADD_FAILURE() << \"Reset() not expected during this test.\";\n    }\n    bool Failed() const {\n      ADD_FAILURE() << \"Failed() not expected during this test.\";\n      return false;\n    }\n    string ErrorText() const {\n      ADD_FAILURE() << \"ErrorText() not expected during this test.\";\n      return \"\";\n    }\n    void StartCancel() {\n      ADD_FAILURE() << \"StartCancel() not expected during this test.\";\n    }\n    void SetFailed(const string& reason) {\n      ADD_FAILURE() << \"SetFailed() not expected during this test.\";\n    }\n    bool IsCanceled() const {\n      ADD_FAILURE() << \"IsCanceled() not expected during this test.\";\n      return false;\n    }\n    void NotifyOnCancel(Closure* callback) {\n      ADD_FAILURE() << \"NotifyOnCancel() not expected during this test.\";\n    }\n  };\n\n  GeneratedServiceTest()\n    : descriptor_(unittest::TestService::descriptor()),\n      foo_(descriptor_->FindMethodByName(\"Foo\")),\n      bar_(descriptor_->FindMethodByName(\"Bar\")),\n      stub_(&mock_channel_),\n      done_(::google::protobuf::internal::NewPermanentCallback(&DoNothing)) {}\n\n  virtual void SetUp() {\n    ASSERT_TRUE(foo_ != NULL);\n    ASSERT_TRUE(bar_ != NULL);\n  }\n\n  const ServiceDescriptor* descriptor_;\n  const MethodDescriptor* foo_;\n  const MethodDescriptor* bar_;\n\n  MockTestService mock_service_;\n  MockController mock_controller_;\n\n  MockRpcChannel mock_channel_;\n  unittest::TestService::Stub stub_;\n\n  // Just so we don't have to re-define these with every test.\n  unittest::FooRequest foo_request_;\n  unittest::FooResponse foo_response_;\n  unittest::BarRequest bar_request_;\n  unittest::BarResponse bar_response_;\n  google::protobuf::scoped_ptr<Closure> done_;\n};\n\nTEST_F(GeneratedServiceTest, GetDescriptor) {\n  // Test that GetDescriptor() works.\n\n  EXPECT_EQ(descriptor_, mock_service_.GetDescriptor());\n}\n\nTEST_F(GeneratedServiceTest, GetChannel) {\n  EXPECT_EQ(&mock_channel_, stub_.channel());\n}\n\nTEST_F(GeneratedServiceTest, OwnsChannel) {\n  MockRpcChannel* channel = new MockRpcChannel;\n  bool destroyed = false;\n  channel->destroyed_ = &destroyed;\n\n  {\n    unittest::TestService::Stub owning_stub(channel,\n                                            Service::STUB_OWNS_CHANNEL);\n    EXPECT_FALSE(destroyed);\n  }\n\n  EXPECT_TRUE(destroyed);\n}\n\nTEST_F(GeneratedServiceTest, CallMethod) {\n  // Test that CallMethod() works.\n\n  // Call Foo() via CallMethod().\n  mock_service_.CallMethod(foo_, &mock_controller_,\n                           &foo_request_, &foo_response_, done_.get());\n\n  ASSERT_TRUE(mock_service_.called_);\n\n  EXPECT_EQ(\"Foo\"            , mock_service_.method_    );\n  EXPECT_EQ(&mock_controller_, mock_service_.controller_);\n  EXPECT_EQ(&foo_request_    , mock_service_.request_   );\n  EXPECT_EQ(&foo_response_   , mock_service_.response_  );\n  EXPECT_EQ(done_.get()      , mock_service_.done_      );\n\n  // Try again, but call Bar() instead.\n  mock_service_.Reset();\n  mock_service_.CallMethod(bar_, &mock_controller_,\n                           &bar_request_, &bar_response_, done_.get());\n\n  ASSERT_TRUE(mock_service_.called_);\n  EXPECT_EQ(\"Bar\", mock_service_.method_);\n}\n\nTEST_F(GeneratedServiceTest, CallMethodTypeFailure) {\n  // Verify death if we call Foo() with Bar's message types.\n\n#ifdef PROTOBUF_HAS_DEATH_TEST  // death tests do not work on Windows yet\n  EXPECT_DEBUG_DEATH(\n    mock_service_.CallMethod(foo_, &mock_controller_,\n                             &foo_request_, &bar_response_, done_.get()),\n    \"dynamic_cast\");\n\n  mock_service_.Reset();\n  EXPECT_DEBUG_DEATH(\n    mock_service_.CallMethod(foo_, &mock_controller_,\n                             &bar_request_, &foo_response_, done_.get()),\n    \"dynamic_cast\");\n#endif  // PROTOBUF_HAS_DEATH_TEST\n}\n\nTEST_F(GeneratedServiceTest, GetPrototypes) {\n  // Test Get{Request,Response}Prototype() methods.\n\n  EXPECT_EQ(&unittest::FooRequest::default_instance(),\n            &mock_service_.GetRequestPrototype(foo_));\n  EXPECT_EQ(&unittest::BarRequest::default_instance(),\n            &mock_service_.GetRequestPrototype(bar_));\n\n  EXPECT_EQ(&unittest::FooResponse::default_instance(),\n            &mock_service_.GetResponsePrototype(foo_));\n  EXPECT_EQ(&unittest::BarResponse::default_instance(),\n            &mock_service_.GetResponsePrototype(bar_));\n}\n\nTEST_F(GeneratedServiceTest, Stub) {\n  // Test that the stub class works.\n\n  // Call Foo() via the stub.\n  stub_.Foo(&mock_controller_, &foo_request_, &foo_response_, done_.get());\n\n  ASSERT_TRUE(mock_channel_.called_);\n\n  EXPECT_EQ(foo_             , mock_channel_.method_    );\n  EXPECT_EQ(&mock_controller_, mock_channel_.controller_);\n  EXPECT_EQ(&foo_request_    , mock_channel_.request_   );\n  EXPECT_EQ(&foo_response_   , mock_channel_.response_  );\n  EXPECT_EQ(done_.get()      , mock_channel_.done_      );\n\n  // Call Bar() via the stub.\n  mock_channel_.Reset();\n  stub_.Bar(&mock_controller_, &bar_request_, &bar_response_, done_.get());\n\n  ASSERT_TRUE(mock_channel_.called_);\n  EXPECT_EQ(bar_, mock_channel_.method_);\n}\n\nTEST_F(GeneratedServiceTest, NotImplemented) {\n  // Test that failing to implement a method of a service causes it to fail\n  // with a \"not implemented\" error message.\n\n  // A service which doesn't implement any methods.\n  class UnimplementedService : public unittest::TestService {\n   public:\n    UnimplementedService() {}\n  };\n\n  UnimplementedService unimplemented_service;\n\n  // And a controller which expects to get a \"not implemented\" error.\n  class ExpectUnimplementedController : public MockController {\n   public:\n    ExpectUnimplementedController() : called_(false) {}\n\n    void SetFailed(const string& reason) {\n      EXPECT_FALSE(called_);\n      called_ = true;\n      EXPECT_EQ(\"Method Foo() not implemented.\", reason);\n    }\n\n    bool called_;\n  };\n\n  ExpectUnimplementedController controller;\n\n  // Call Foo.\n  unimplemented_service.Foo(&controller, &foo_request_, &foo_response_,\n                            done_.get());\n\n  EXPECT_TRUE(controller.called_);\n}\n\n// ===================================================================\n\nclass OneofTest : public testing::Test {\n protected:\n  virtual void SetUp() {\n  }\n\n  void ExpectEnumCasesWork(const unittest::TestOneof2 &message) {\n    switch (message.foo_case()) {\n      case unittest::TestOneof2::kFooInt:\n        EXPECT_TRUE(message.has_foo_int());\n        break;\n      case unittest::TestOneof2::kFooString:\n        EXPECT_TRUE(message.has_foo_string());\n        break;\n      case unittest::TestOneof2::kFooCord:\n        EXPECT_TRUE(message.has_foo_cord());\n        break;\n      case unittest::TestOneof2::kFooStringPiece:\n        EXPECT_TRUE(message.has_foo_string_piece());\n        break;\n      case unittest::TestOneof2::kFooBytes:\n        EXPECT_TRUE(message.has_foo_bytes());\n        break;\n      case unittest::TestOneof2::kFooEnum:\n        EXPECT_TRUE(message.has_foo_enum());\n        break;\n      case unittest::TestOneof2::kFooMessage:\n        EXPECT_TRUE(message.has_foo_message());\n        break;\n      case unittest::TestOneof2::kFoogroup:\n        EXPECT_TRUE(message.has_foogroup());\n        break;\n      case unittest::TestOneof2::kFooLazyMessage:\n        EXPECT_TRUE(message.has_foo_lazy_message());\n        break;\n      case unittest::TestOneof2::FOO_NOT_SET:\n        break;\n    }\n  }\n};\n\nTEST_F(OneofTest, SettingOneFieldClearsOthers) {\n  unittest::TestOneof2 message;\n\n  message.set_foo_int(123);\n  EXPECT_TRUE(message.has_foo_int());\n  TestUtil::ExpectAtMostOneFieldSetInOneof(message);\n\n  message.set_foo_string(\"foo\");\n  EXPECT_TRUE(message.has_foo_string());\n  TestUtil::ExpectAtMostOneFieldSetInOneof(message);\n\n\n  message.set_foo_bytes(\"qux\");\n  EXPECT_TRUE(message.has_foo_bytes());\n  TestUtil::ExpectAtMostOneFieldSetInOneof(message);\n\n  message.set_foo_enum(unittest::TestOneof2::FOO);\n  EXPECT_TRUE(message.has_foo_enum());\n  TestUtil::ExpectAtMostOneFieldSetInOneof(message);\n\n  message.mutable_foo_message()->set_qux_int(234);\n  EXPECT_TRUE(message.has_foo_message());\n  TestUtil::ExpectAtMostOneFieldSetInOneof(message);\n\n  message.mutable_foogroup()->set_a(345);\n  EXPECT_TRUE(message.has_foogroup());\n  TestUtil::ExpectAtMostOneFieldSetInOneof(message);\n\n\n  // we repeat this because we didn't test if this properly clears other fields\n  // at the beginning.\n  message.set_foo_int(123);\n  EXPECT_TRUE(message.has_foo_int());\n  TestUtil::ExpectAtMostOneFieldSetInOneof(message);\n}\n\nTEST_F(OneofTest, EnumCases) {\n  unittest::TestOneof2 message;\n\n  message.set_foo_int(123);\n  ExpectEnumCasesWork(message);\n  message.set_foo_string(\"foo\");\n  ExpectEnumCasesWork(message);\n  message.set_foo_bytes(\"qux\");\n  ExpectEnumCasesWork(message);\n  message.set_foo_enum(unittest::TestOneof2::FOO);\n  ExpectEnumCasesWork(message);\n  message.mutable_foo_message()->set_qux_int(234);\n  ExpectEnumCasesWork(message);\n  message.mutable_foogroup()->set_a(345);\n  ExpectEnumCasesWork(message);\n}\n\nTEST_F(OneofTest, PrimitiveType) {\n  unittest::TestOneof2 message;\n  // Unset field returns default value\n  EXPECT_EQ(message.foo_int(), 0);\n\n  message.set_foo_int(123);\n  EXPECT_TRUE(message.has_foo_int());\n  EXPECT_EQ(message.foo_int(), 123);\n  message.clear_foo_int();\n  EXPECT_FALSE(message.has_foo_int());\n}\n\nTEST_F(OneofTest, EnumType) {\n  unittest::TestOneof2 message;\n  // Unset field returns default value\n  EXPECT_EQ(message.foo_enum(), 1);\n\n  message.set_foo_enum(unittest::TestOneof2::FOO);\n  EXPECT_TRUE(message.has_foo_enum());\n  EXPECT_EQ(message.foo_enum(), unittest::TestOneof2::FOO);\n  message.clear_foo_enum();\n  EXPECT_FALSE(message.has_foo_enum());\n}\n\nTEST_F(OneofTest, SetString) {\n  // Check that setting a string field in various ways works\n  unittest::TestOneof2 message;\n\n  // Unset field returns default value\n  EXPECT_EQ(message.foo_string(), \"\");\n\n  message.set_foo_string(\"foo\");\n  EXPECT_TRUE(message.has_foo_string());\n  EXPECT_EQ(message.foo_string(), \"foo\");\n  message.clear_foo_string();\n  EXPECT_FALSE(message.has_foo_string());\n\n  message.set_foo_string(string(\"bar\"));\n  EXPECT_TRUE(message.has_foo_string());\n  EXPECT_EQ(message.foo_string(), \"bar\");\n  message.clear_foo_string();\n  EXPECT_FALSE(message.has_foo_string());\n\n\n  message.set_foo_string(\"qux\", 3);\n  EXPECT_TRUE(message.has_foo_string());\n  EXPECT_EQ(message.foo_string(), \"qux\");\n  message.clear_foo_string();\n  EXPECT_FALSE(message.has_foo_string());\n\n  message.mutable_foo_string()->assign(\"quux\");\n  EXPECT_TRUE(message.has_foo_string());\n  EXPECT_EQ(message.foo_string(), \"quux\");\n  message.clear_foo_string();\n  EXPECT_FALSE(message.has_foo_string());\n\n  message.set_foo_string(\"corge\");\n  EXPECT_TRUE(message.has_foo_string());\n  EXPECT_EQ(message.foo_string(), \"corge\");\n  message.clear_foo_string();\n  EXPECT_FALSE(message.has_foo_string());\n}\n\nTEST_F(OneofTest, ReleaseString) {\n  // Check that release_foo() starts out NULL, and gives us a value\n  // that we can delete after it's been set.\n  unittest::TestOneof2 message;\n\n  EXPECT_EQ(NULL, message.release_foo_string());\n  EXPECT_FALSE(message.has_foo_string());\n\n  message.set_foo_string(\"blah\");\n  EXPECT_TRUE(message.has_foo_string());\n  google::protobuf::scoped_ptr<string> str(message.release_foo_string());\n  EXPECT_FALSE(message.has_foo_string());\n  ASSERT_TRUE(str != NULL);\n  EXPECT_EQ(\"blah\", *str);\n\n  EXPECT_EQ(NULL, message.release_foo_string());\n  EXPECT_FALSE(message.has_foo_string());\n}\n\nTEST_F(OneofTest, SetAllocatedString) {\n  // Check that set_allocated_foo() works for strings.\n  unittest::TestOneof2 message;\n\n  EXPECT_FALSE(message.has_foo_string());\n  const string kHello(\"hello\");\n  message.set_foo_string(kHello);\n  EXPECT_TRUE(message.has_foo_string());\n\n  message.set_allocated_foo_string(NULL);\n  EXPECT_FALSE(message.has_foo_string());\n  EXPECT_EQ(\"\", message.foo_string());\n\n  message.set_allocated_foo_string(new string(kHello));\n  EXPECT_TRUE(message.has_foo_string());\n  EXPECT_EQ(kHello, message.foo_string());\n}\n\n\nTEST_F(OneofTest, SetMessage) {\n  // Check that setting a message field works\n  unittest::TestOneof2 message;\n\n  // Unset field returns default instance\n  EXPECT_EQ(&message.foo_message(),\n            &unittest::TestOneof2_NestedMessage::default_instance());\n  EXPECT_EQ(message.foo_message().qux_int(), 0);\n\n  message.mutable_foo_message()->set_qux_int(234);\n  EXPECT_TRUE(message.has_foo_message());\n  EXPECT_EQ(message.foo_message().qux_int(), 234);\n  message.clear_foo_message();\n  EXPECT_FALSE(message.has_foo_message());\n}\n\nTEST_F(OneofTest, ReleaseMessage) {\n  // Check that release_foo() starts out NULL, and gives us a value\n  // that we can delete after it's been set.\n  unittest::TestOneof2 message;\n\n  EXPECT_EQ(NULL, message.release_foo_message());\n  EXPECT_FALSE(message.has_foo_message());\n\n  message.mutable_foo_message()->set_qux_int(1);\n  EXPECT_TRUE(message.has_foo_message());\n  google::protobuf::scoped_ptr<unittest::TestOneof2_NestedMessage> mes(\n      message.release_foo_message());\n  EXPECT_FALSE(message.has_foo_message());\n  ASSERT_TRUE(mes != NULL);\n  EXPECT_EQ(1, mes->qux_int());\n\n  EXPECT_EQ(NULL, message.release_foo_message());\n  EXPECT_FALSE(message.has_foo_message());\n}\n\nTEST_F(OneofTest, SetAllocatedMessage) {\n  // Check that set_allocated_foo() works for messages.\n  unittest::TestOneof2 message;\n\n  EXPECT_FALSE(message.has_foo_message());\n\n  message.mutable_foo_message()->set_qux_int(1);\n  EXPECT_TRUE(message.has_foo_message());\n\n  message.set_allocated_foo_message(NULL);\n  EXPECT_FALSE(message.has_foo_message());\n  EXPECT_EQ(&message.foo_message(),\n            &unittest::TestOneof2_NestedMessage::default_instance());\n\n  message.mutable_foo_message()->set_qux_int(1);\n  unittest::TestOneof2_NestedMessage* mes = message.release_foo_message();\n  ASSERT_TRUE(mes != NULL);\n  EXPECT_FALSE(message.has_foo_message());\n\n  message.set_allocated_foo_message(mes);\n  EXPECT_TRUE(message.has_foo_message());\n  EXPECT_EQ(1, message.foo_message().qux_int());\n}\n\n\nTEST_F(OneofTest, Clear) {\n  unittest::TestOneof2 message;\n\n  message.set_foo_int(1);\n  EXPECT_TRUE(message.has_foo_int());\n  message.clear_foo_int();\n  EXPECT_FALSE(message.has_foo_int());\n}\n\nTEST_F(OneofTest, Defaults) {\n  unittest::TestOneof2 message;\n\n  EXPECT_FALSE(message.has_foo_int());\n  EXPECT_EQ(message.foo_int(), 0);\n\n  EXPECT_FALSE(message.has_foo_string());\n  EXPECT_EQ(message.foo_string(), \"\");\n\n\n  EXPECT_FALSE(message.has_foo_bytes());\n  EXPECT_EQ(message.foo_bytes(), \"\");\n\n  EXPECT_FALSE(message.has_foo_enum());\n  EXPECT_EQ(message.foo_enum(), 1);\n\n  EXPECT_FALSE(message.has_foo_message());\n  EXPECT_EQ(message.foo_message().qux_int(), 0);\n\n  EXPECT_FALSE(message.has_foogroup());\n  EXPECT_EQ(message.foogroup().a(), 0);\n\n\n  EXPECT_FALSE(message.has_bar_int());\n  EXPECT_EQ(message.bar_int(), 5);\n\n  EXPECT_FALSE(message.has_bar_string());\n  EXPECT_EQ(message.bar_string(), \"STRING\");\n\n\n  EXPECT_FALSE(message.has_bar_bytes());\n  EXPECT_EQ(message.bar_bytes(), \"BYTES\");\n\n  EXPECT_FALSE(message.has_bar_enum());\n  EXPECT_EQ(message.bar_enum(), 2);\n}\n\nTEST_F(OneofTest, SwapWithEmpty) {\n  unittest::TestOneof2 message1, message2;\n  message1.set_foo_string(\"FOO\");\n  EXPECT_TRUE(message1.has_foo_string());\n  message1.Swap(&message2);\n  EXPECT_FALSE(message1.has_foo_string());\n  EXPECT_TRUE(message2.has_foo_string());\n  EXPECT_EQ(message2.foo_string(), \"FOO\");\n}\n\nTEST_F(OneofTest, SwapWithSelf) {\n  unittest::TestOneof2 message;\n  message.set_foo_string(\"FOO\");\n  EXPECT_TRUE(message.has_foo_string());\n  message.Swap(&message);\n  EXPECT_TRUE(message.has_foo_string());\n  EXPECT_EQ(message.foo_string(), \"FOO\");\n}\n\nTEST_F(OneofTest, SwapBothHasFields) {\n  unittest::TestOneof2 message1, message2;\n\n  message1.set_foo_string(\"FOO\");\n  EXPECT_TRUE(message1.has_foo_string());\n  message2.mutable_foo_message()->set_qux_int(1);\n  EXPECT_TRUE(message2.has_foo_message());\n\n  message1.Swap(&message2);\n  EXPECT_FALSE(message1.has_foo_string());\n  EXPECT_FALSE(message2.has_foo_message());\n  EXPECT_TRUE(message1.has_foo_message());\n  EXPECT_EQ(message1.foo_message().qux_int(), 1);\n  EXPECT_TRUE(message2.has_foo_string());\n  EXPECT_EQ(message2.foo_string(), \"FOO\");\n}\n\nTEST_F(OneofTest, CopyConstructor) {\n  unittest::TestOneof2 message1;\n  message1.set_foo_bytes(\"FOO\");\n\n  unittest::TestOneof2 message2(message1);\n  EXPECT_TRUE(message2.has_foo_bytes());\n  EXPECT_EQ(message2.foo_bytes(), \"FOO\");\n}\n\nTEST_F(OneofTest, CopyFrom) {\n  unittest::TestOneof2 message1, message2;\n  message1.set_foo_enum(unittest::TestOneof2::BAR);\n  EXPECT_TRUE(message1.has_foo_enum());\n\n  message2.CopyFrom(message1);\n  EXPECT_TRUE(message2.has_foo_enum());\n  EXPECT_EQ(message2.foo_enum(), unittest::TestOneof2::BAR);\n\n  // Copying from self should be a no-op.\n  message2.CopyFrom(message2);\n  EXPECT_TRUE(message2.has_foo_enum());\n  EXPECT_EQ(message2.foo_enum(), unittest::TestOneof2::BAR);\n}\n\nTEST_F(OneofTest, CopyAssignmentOperator) {\n  unittest::TestOneof2 message1;\n  message1.mutable_foo_message()->set_qux_int(123);\n  EXPECT_TRUE(message1.has_foo_message());\n\n  unittest::TestOneof2 message2;\n  message2 = message1;\n  EXPECT_EQ(message2.foo_message().qux_int(), 123);\n\n  // Make sure that self-assignment does something sane.\n  message2 = message2;\n  EXPECT_EQ(message2.foo_message().qux_int(), 123);\n}\n\nTEST_F(OneofTest, UpcastCopyFrom) {\n  // Test the CopyFrom method that takes in the generic const Message&\n  // parameter.\n  unittest::TestOneof2 message1, message2;\n  message1.mutable_foogroup()->set_a(123);\n  EXPECT_TRUE(message1.has_foogroup());\n\n  const Message* source = implicit_cast<const Message*>(&message1);\n  message2.CopyFrom(*source);\n\n  EXPECT_TRUE(message2.has_foogroup());\n  EXPECT_EQ(message2.foogroup().a(), 123);\n}\n\n// Test the generated SerializeWithCachedSizesToArray(),\n// This indirectly tests MergePartialFromCodedStream()\n// We have to test each field type separately because we cannot set them at the\n// same time\nTEST_F(OneofTest, SerializationToArray) {\n  // Primitive type\n  {\n    unittest::TestOneof2 message1, message2;\n    string data;\n    message1.set_foo_int(123);\n    int size = message1.ByteSize();\n    data.resize(size);\n    uint8* start = reinterpret_cast<uint8*>(string_as_array(&data));\n    uint8* end = message1.SerializeWithCachedSizesToArray(start);\n    EXPECT_EQ(size, end - start);\n    EXPECT_TRUE(message2.ParseFromString(data));\n    EXPECT_EQ(message2.foo_int(), 123);\n  }\n\n  // String\n  {\n    unittest::TestOneof2 message1, message2;\n    string data;\n    message1.set_foo_string(\"foo\");\n    int size = message1.ByteSize();\n    data.resize(size);\n    uint8* start = reinterpret_cast<uint8*>(string_as_array(&data));\n    uint8* end = message1.SerializeWithCachedSizesToArray(start);\n    EXPECT_EQ(size, end - start);\n    EXPECT_TRUE(message2.ParseFromString(data));\n    EXPECT_EQ(message2.foo_string(), \"foo\");\n  }\n\n\n  // Bytes\n  {\n    unittest::TestOneof2 message1, message2;\n    string data;\n    message1.set_foo_bytes(\"qux\");\n    int size = message1.ByteSize();\n    data.resize(size);\n    uint8* start = reinterpret_cast<uint8*>(string_as_array(&data));\n    uint8* end = message1.SerializeWithCachedSizesToArray(start);\n    EXPECT_EQ(size, end - start);\n    EXPECT_TRUE(message2.ParseFromString(data));\n    EXPECT_EQ(message2.foo_bytes(), \"qux\");\n  }\n\n  // Enum\n  {\n    unittest::TestOneof2 message1, message2;\n    string data;\n    message1.set_foo_enum(unittest::TestOneof2::FOO);\n    int size = message1.ByteSize();\n    data.resize(size);\n    uint8* start = reinterpret_cast<uint8*>(string_as_array(&data));\n    uint8* end = message1.SerializeWithCachedSizesToArray(start);\n    EXPECT_EQ(size, end - start);\n    EXPECT_TRUE(message2.ParseFromString(data));\n    EXPECT_EQ(message2.foo_enum(), unittest::TestOneof2::FOO);\n  }\n\n  // Message\n  {\n    unittest::TestOneof2 message1, message2;\n    string data;\n    message1.mutable_foo_message()->set_qux_int(234);\n    int size = message1.ByteSize();\n    data.resize(size);\n    uint8* start = reinterpret_cast<uint8*>(string_as_array(&data));\n    uint8* end = message1.SerializeWithCachedSizesToArray(start);\n    EXPECT_EQ(size, end - start);\n    EXPECT_TRUE(message2.ParseFromString(data));\n    EXPECT_EQ(message2.foo_message().qux_int(), 234);\n  }\n\n  // Group\n  {\n    unittest::TestOneof2 message1, message2;\n    string data;\n    message1.mutable_foogroup()->set_a(345);\n    int size = message1.ByteSize();\n    data.resize(size);\n    uint8* start = reinterpret_cast<uint8*>(string_as_array(&data));\n    uint8* end = message1.SerializeWithCachedSizesToArray(start);\n    EXPECT_EQ(size, end - start);\n    EXPECT_TRUE(message2.ParseFromString(data));\n    EXPECT_EQ(message2.foogroup().a(), 345);\n  }\n\n}\n\n// Test the generated SerializeWithCachedSizes() by forcing the buffer to write\n// one byte at a time.\n// This indirectly tests MergePartialFromCodedStream()\n// We have to test each field type separately because we cannot set them at the\n// same time\nTEST_F(OneofTest, SerializationToStream) {\n  // Primitive type\n  {\n    unittest::TestOneof2 message1, message2;\n    string data;\n    message1.set_foo_int(123);\n    int size = message1.ByteSize();\n    data.resize(size);\n\n    {\n      // Allow the output stream to buffer only one byte at a time.\n      io::ArrayOutputStream array_stream(string_as_array(&data), size, 1);\n      io::CodedOutputStream output_stream(&array_stream);\n      message1.SerializeWithCachedSizes(&output_stream);\n      EXPECT_FALSE(output_stream.HadError());\n      EXPECT_EQ(size, output_stream.ByteCount());\n    }\n\n    EXPECT_TRUE(message2.ParseFromString(data));\n    EXPECT_EQ(message2.foo_int(), 123);\n  }\n\n  // String\n  {\n    unittest::TestOneof2 message1, message2;\n    string data;\n    message1.set_foo_string(\"foo\");\n    int size = message1.ByteSize();\n    data.resize(size);\n\n    {\n      // Allow the output stream to buffer only one byte at a time.\n      io::ArrayOutputStream array_stream(string_as_array(&data), size, 1);\n      io::CodedOutputStream output_stream(&array_stream);\n      message1.SerializeWithCachedSizes(&output_stream);\n      EXPECT_FALSE(output_stream.HadError());\n      EXPECT_EQ(size, output_stream.ByteCount());\n    }\n\n    EXPECT_TRUE(message2.ParseFromString(data));\n    EXPECT_EQ(message2.foo_string(), \"foo\");\n  }\n\n\n  // Bytes\n  {\n    unittest::TestOneof2 message1, message2;\n    string data;\n    message1.set_foo_bytes(\"qux\");\n    int size = message1.ByteSize();\n    data.resize(size);\n\n    {\n      // Allow the output stream to buffer only one byte at a time.\n      io::ArrayOutputStream array_stream(string_as_array(&data), size, 1);\n      io::CodedOutputStream output_stream(&array_stream);\n      message1.SerializeWithCachedSizes(&output_stream);\n      EXPECT_FALSE(output_stream.HadError());\n      EXPECT_EQ(size, output_stream.ByteCount());\n    }\n\n    EXPECT_TRUE(message2.ParseFromString(data));\n    EXPECT_EQ(message2.foo_bytes(), \"qux\");\n  }\n\n  // Enum\n  {\n    unittest::TestOneof2 message1, message2;\n    string data;\n    message1.set_foo_enum(unittest::TestOneof2::FOO);\n    int size = message1.ByteSize();\n    data.resize(size);\n\n    {\n      // Allow the output stream to buffer only one byte at a time.\n      io::ArrayOutputStream array_stream(string_as_array(&data), size, 1);\n      io::CodedOutputStream output_stream(&array_stream);\n      message1.SerializeWithCachedSizes(&output_stream);\n      EXPECT_FALSE(output_stream.HadError());\n      EXPECT_EQ(size, output_stream.ByteCount());\n    }\n\n    EXPECT_TRUE(message2.ParseFromString(data));\n    EXPECT_EQ(message2.foo_enum(), unittest::TestOneof2::FOO);\n  }\n\n  // Message\n  {\n    unittest::TestOneof2 message1, message2;\n    string data;\n    message1.mutable_foo_message()->set_qux_int(234);\n    int size = message1.ByteSize();\n    data.resize(size);\n\n    {\n      // Allow the output stream to buffer only one byte at a time.\n      io::ArrayOutputStream array_stream(string_as_array(&data), size, 1);\n      io::CodedOutputStream output_stream(&array_stream);\n      message1.SerializeWithCachedSizes(&output_stream);\n      EXPECT_FALSE(output_stream.HadError());\n      EXPECT_EQ(size, output_stream.ByteCount());\n    }\n\n    EXPECT_TRUE(message2.ParseFromString(data));\n    EXPECT_EQ(message2.foo_message().qux_int(), 234);\n  }\n\n  // Group\n  {\n    unittest::TestOneof2 message1, message2;\n    string data;\n    message1.mutable_foogroup()->set_a(345);\n    int size = message1.ByteSize();\n    data.resize(size);\n\n    {\n      // Allow the output stream to buffer only one byte at a time.\n      io::ArrayOutputStream array_stream(string_as_array(&data), size, 1);\n      io::CodedOutputStream output_stream(&array_stream);\n      message1.SerializeWithCachedSizes(&output_stream);\n      EXPECT_FALSE(output_stream.HadError());\n      EXPECT_EQ(size, output_stream.ByteCount());\n    }\n\n    EXPECT_TRUE(message2.ParseFromString(data));\n    EXPECT_EQ(message2.foogroup().a(), 345);\n  }\n\n}\n\nTEST_F(OneofTest, MergeFrom) {\n  unittest::TestOneof2 message1, message2;\n\n  message1.set_foo_int(123);\n  message2.MergeFrom(message1);\n  TestUtil::ExpectAtMostOneFieldSetInOneof(message2);\n  EXPECT_TRUE(message2.has_foo_int());\n  EXPECT_EQ(message2.foo_int(), 123);\n\n  message1.set_foo_string(\"foo\");\n  message2.MergeFrom(message1);\n  TestUtil::ExpectAtMostOneFieldSetInOneof(message2);\n  EXPECT_TRUE(message2.has_foo_string());\n  EXPECT_EQ(message2.foo_string(), \"foo\");\n\n\n  message1.set_foo_bytes(\"qux\");\n  message2.MergeFrom(message1);\n  TestUtil::ExpectAtMostOneFieldSetInOneof(message2);\n  EXPECT_TRUE(message2.has_foo_bytes());\n  EXPECT_EQ(message2.foo_bytes(), \"qux\");\n\n  message1.set_foo_enum(unittest::TestOneof2::FOO);\n  message2.MergeFrom(message1);\n  TestUtil::ExpectAtMostOneFieldSetInOneof(message2);\n  EXPECT_TRUE(message2.has_foo_enum());\n  EXPECT_EQ(message2.foo_enum(), unittest::TestOneof2::FOO);\n\n  message1.mutable_foo_message()->set_qux_int(234);\n  message2.MergeFrom(message1);\n  TestUtil::ExpectAtMostOneFieldSetInOneof(message2);\n  EXPECT_TRUE(message2.has_foo_message());\n  EXPECT_EQ(message2.foo_message().qux_int(), 234);\n\n  message1.mutable_foogroup()->set_a(345);\n  message2.MergeFrom(message1);\n  TestUtil::ExpectAtMostOneFieldSetInOneof(message2);\n  EXPECT_TRUE(message2.has_foogroup());\n  EXPECT_EQ(message2.foogroup().a(), 345);\n\n}\n\n}  // namespace cpp_unittest\n}  // namespace cpp\n}  // namespace compiler\n\nnamespace no_generic_services_test {\n  // Verify that no class called \"TestService\" was defined in\n  // unittest_no_generic_services.pb.h by defining a different type by the same\n  // name.  If such a service was generated, this will not compile.\n  struct TestService {\n    int i;\n  };\n}\n\nnamespace compiler {\nnamespace cpp {\nnamespace cpp_unittest {\n\nTEST_F(GeneratedServiceTest, NoGenericServices) {\n  // Verify that non-services in unittest_no_generic_services.proto were\n  // generated.\n  no_generic_services_test::TestMessage message;\n  message.set_a(1);\n  message.SetExtension(no_generic_services_test::test_extension, 123);\n  no_generic_services_test::TestEnum e = no_generic_services_test::FOO;\n  EXPECT_EQ(e, 1);\n\n  // Verify that a ServiceDescriptor is generated for the service even if the\n  // class itself is not.\n  const FileDescriptor* file =\n      no_generic_services_test::TestMessage::descriptor()->file();\n\n  ASSERT_EQ(1, file->service_count());\n  EXPECT_EQ(\"TestService\", file->service(0)->name());\n  ASSERT_EQ(1, file->service(0)->method_count());\n  EXPECT_EQ(\"Foo\", file->service(0)->method(0)->name());\n}\n\n#endif  // !PROTOBUF_TEST_NO_DESCRIPTORS\n\n// ===================================================================\n\n// This test must run last.  It verifies that descriptors were or were not\n// initialized depending on whether PROTOBUF_TEST_NO_DESCRIPTORS was defined.\n// When this is defined, we skip all tests which are expected to trigger\n// descriptor initialization.  This verifies that everything else still works\n// if descriptors are not initialized.\nTEST(DescriptorInitializationTest, Initialized) {\n#ifdef PROTOBUF_TEST_NO_DESCRIPTORS\n  bool should_have_descriptors = false;\n#else\n  bool should_have_descriptors = true;\n#endif\n\n  EXPECT_EQ(should_have_descriptors,\n    DescriptorPool::generated_pool()->InternalIsFileLoaded(\n      \"google/protobuf/unittest.proto\"));\n}\n\n}  // namespace cpp_unittest\n\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/cpp_unittest.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This header declares the namespace google::protobuf::protobuf_unittest in order to expose\n// any problems with the generated class names. We use this header to ensure\n// unittest.cc will declare the namespace prior to other includes, while obeying\n// normal include ordering.\n//\n// When generating a class name of \"foo.Bar\" we must ensure we prefix the class\n// name with \"::\", in case the namespace google::protobuf::foo exists. We intentionally\n// trigger that case here by declaring google::protobuf::protobuf_unittest.\n//\n// See ClassName in helpers.h for more details.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_UNITTEST_H__\n#define GOOGLE_PROTOBUF_COMPILER_CPP_UNITTEST_H__\n\nnamespace google {\nnamespace protobuf {\nnamespace protobuf_unittest {}\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_CPP_UNITTEST_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/cpp/metadata_test.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#include <google/protobuf/compiler/cpp/cpp_helpers.h>\n#include <google/protobuf/compiler/cpp/cpp_generator.h>\n#include <google/protobuf/compiler/command_line_interface.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl_lite.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/descriptor.pb.h>\n\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace cpp {\nnamespace {\n\n// A CodeGenerator that captures the FileDescriptor it's passed as a\n// FileDescriptorProto.\nclass DescriptorCapturingGenerator : public CodeGenerator {\n public:\n  // Does not own file; file must outlive the Generator.\n  explicit DescriptorCapturingGenerator(FileDescriptorProto* file)\n      : file_(file) {}\n\n  virtual bool Generate(const FileDescriptor* file, const string& parameter,\n                        GeneratorContext* context, string* error) const {\n    file->CopyTo(file_);\n    return true;\n  }\n\n private:\n  FileDescriptorProto* file_;\n};\n\nclass CppMetadataTest : public ::testing::Test {\n public:\n  // Adds a file with name `filename` and content `data`.\n  void AddFile(const string& filename, const string& data) {\n    GOOGLE_CHECK_OK(File::SetContents(TestTempDir() + \"/\" + filename, data,\n                               true));\n  }\n\n  // Tries to capture a FileDescriptorProto, GeneratedCodeInfo, and output\n  // code from the previously added file with name `filename`. Returns true on\n  // success. If pb_h is non-null, expects a .pb.h and a .pb.h.meta (copied to\n  // pb_h and pb_h_info respecfively); similarly for proto_h and proto_h_info.\n  bool CaptureMetadata(const string& filename, FileDescriptorProto* file,\n                       string* pb_h, GeneratedCodeInfo* pb_h_info,\n                       string* proto_h, GeneratedCodeInfo* proto_h_info,\n                       string* pb_cc) {\n    google::protobuf::compiler::CommandLineInterface cli;\n    cli.SetInputsAreProtoPathRelative(true);\n\n    CppGenerator cpp_generator;\n    DescriptorCapturingGenerator capturing_generator(file);\n    cli.RegisterGenerator(\"--cpp_out\", &cpp_generator, \"\");\n    cli.RegisterGenerator(\"--capture_out\", &capturing_generator, \"\");\n\n    string proto_path = \"-I\" + TestTempDir();\n    string cpp_out =\n        \"--cpp_out=annotate_headers=true,\"\n        \"annotation_pragma_name=pragma_name,\"\n        \"annotation_guard_name=guard_name:\" +\n        TestTempDir();\n    string capture_out = \"--capture_out=\" + TestTempDir();\n\n    const char* argv[] = {\"protoc\", proto_path.c_str(), cpp_out.c_str(),\n                          capture_out.c_str(), filename.c_str()};\n\n    if (cli.Run(5, argv) != 0) {\n      return false;\n    }\n\n    string output_base = TestTempDir() + \"/\" + StripProto(filename);\n\n    if (pb_cc != NULL) {\n      GOOGLE_CHECK_OK(\n          File::GetContents(output_base + \".pb.cc\", pb_cc, true));\n    }\n\n    if (pb_h != NULL && pb_h_info != NULL) {\n      GOOGLE_CHECK_OK(\n          File::GetContents(output_base + \".pb.h\", pb_h, true));\n      if (!DecodeMetadata(output_base + \".pb.h.meta\", pb_h_info)) {\n        return false;\n      }\n    }\n\n    if (proto_h != NULL && proto_h_info != NULL) {\n      GOOGLE_CHECK_OK(File::GetContents(output_base + \".proto.h\", proto_h,\n                                 true));\n      if (!DecodeMetadata(output_base + \".proto.h.meta\", proto_h_info)) {\n        return false;\n      }\n    }\n\n    return true;\n  }\n\n private:\n  // Decodes GeneratedCodeInfo stored in path and copies it to info.\n  // Returns true on success.\n  bool DecodeMetadata(const string& path, GeneratedCodeInfo* info) {\n    string data;\n    GOOGLE_CHECK_OK(File::GetContents(path, &data, true));\n    io::ArrayInputStream input(data.data(), data.size());\n    return info->ParseFromZeroCopyStream(&input);\n  }\n};\n\nconst char kSmallTestFile[] =\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"package foo;\\n\"\n    \"enum Enum { VALUE = 0; }\\n\"\n    \"message Message { }\\n\";\n\n// Finds the Annotation for a given source file and path (or returns null if it\n// couldn't).\nconst GeneratedCodeInfo::Annotation* FindAnnotationOnPath(\n    const GeneratedCodeInfo& info, const string& source_file,\n    const vector<int>& path) {\n  for (int i = 0; i < info.annotation_size(); ++i) {\n    const GeneratedCodeInfo::Annotation* annotation = &info.annotation(i);\n    if (annotation->source_file() != source_file ||\n        annotation->path_size() != path.size()) {\n      continue;\n    }\n    int node = 0;\n    for (; node < path.size(); ++node) {\n      if (annotation->path(node) != path[node]) {\n        break;\n      }\n    }\n    if (node == path.size()) {\n      return annotation;\n    }\n  }\n  return NULL;\n}\n\n// Returns true if the provided annotation covers a given substring in\n// file_content.\nbool AnnotationMatchesSubstring(const string& file_content,\n                                const GeneratedCodeInfo::Annotation* annotation,\n                                const string& expected_text) {\n  uint32 begin = annotation->begin();\n  uint32 end = annotation->end();\n  if (end < begin || end > file_content.size()) {\n    return false;\n  }\n  return file_content.substr(begin, end - begin) == expected_text;\n}\n\nTEST_F(CppMetadataTest, CapturesEnumNames) {\n  FileDescriptorProto file;\n  GeneratedCodeInfo info;\n  string pb_h;\n  AddFile(\"test.proto\", kSmallTestFile);\n  EXPECT_TRUE(\n      CaptureMetadata(\"test.proto\", &file, &pb_h, &info, NULL, NULL, NULL));\n  EXPECT_EQ(\"Enum\", file.enum_type(0).name());\n  vector<int> enum_path;\n  enum_path.push_back(FileDescriptorProto::kEnumTypeFieldNumber);\n  enum_path.push_back(0);\n  const GeneratedCodeInfo::Annotation* enum_annotation =\n      FindAnnotationOnPath(info, \"test.proto\", enum_path);\n  EXPECT_TRUE(NULL != enum_annotation);\n  EXPECT_TRUE(AnnotationMatchesSubstring(pb_h, enum_annotation, \"Enum\"));\n}\n\nTEST_F(CppMetadataTest, AddsPragma) {\n  FileDescriptorProto file;\n  GeneratedCodeInfo info;\n  string pb_h;\n  AddFile(\"test.proto\", kSmallTestFile);\n  EXPECT_TRUE(\n      CaptureMetadata(\"test.proto\", &file, &pb_h, &info, NULL, NULL, NULL));\n  EXPECT_TRUE(pb_h.find(\"#ifdef guard_name\") != string::npos);\n  EXPECT_TRUE(pb_h.find(\"#pragma pragma_name \\\"test.pb.h.meta\\\"\") !=\n              string::npos);\n}\n\nTEST_F(CppMetadataTest, CapturesMessageNames) {\n  FileDescriptorProto file;\n  GeneratedCodeInfo info;\n  string pb_h;\n  AddFile(\"test.proto\", kSmallTestFile);\n  EXPECT_TRUE(\n      CaptureMetadata(\"test.proto\", &file, &pb_h, &info, NULL, NULL, NULL));\n  EXPECT_EQ(\"Message\", file.message_type(0).name());\n  vector<int> message_path;\n  message_path.push_back(FileDescriptorProto::kMessageTypeFieldNumber);\n  message_path.push_back(0);\n  const GeneratedCodeInfo::Annotation* message_annotation =\n      FindAnnotationOnPath(info, \"test.proto\", message_path);\n  EXPECT_TRUE(NULL != message_annotation);\n  EXPECT_TRUE(AnnotationMatchesSubstring(pb_h, message_annotation, \"Message\"));\n}\n\n}  // namespace\n}  // namespace cpp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\n// Functions to create C# XML documentation comments.\n// Currently this only includes documentation comments containing text specified as comments\n// in the .proto file; documentation comments generated just from field/message/enum/proto names\n// is inlined in the relevant code. If more control is required, that code can be moved here.\n\nvoid WriteDocCommentBodyImpl(io::Printer* printer, SourceLocation location) {\n    string comments = location.leading_comments.empty() ?\n        location.trailing_comments : location.leading_comments;\n    if (comments.empty()) {\n        return;\n    }\n    // XML escaping... no need for apostrophes etc as the whole text is going to be a child\n    // node of a summary element, not part of an attribute.\n    comments = StringReplace(comments, \"&\", \"&amp;\", true);\n    comments = StringReplace(comments, \"<\", \"&lt;\", true);\n    vector<string> lines = Split(comments, \"\\n\", false /* skip_empty */);\n    // TODO: We really should work out which part to put in the summary and which to put in the remarks...\n    // but that needs to be part of a bigger effort to understand the markdown better anyway.\n    printer->Print(\"/// <summary>\\n\");\n    bool last_was_empty = false;\n    // We squash multiple blank lines down to one, and remove any trailing blank lines. We need\n    // to preserve the blank lines themselves, as this is relevant in the markdown.\n    // Note that we can't remove leading or trailing whitespace as *that's* relevant in markdown too.\n    // (We don't skip \"just whitespace\" lines, either.)\n    for (std::vector<string>::iterator it = lines.begin(); it != lines.end(); ++it) {\n        string line = *it;\n        if (line.empty()) {\n            last_was_empty = true;\n        } else {\n            if (last_was_empty) {\n                printer->Print(\"///\\n\");\n            }\n            last_was_empty = false;\n            printer->Print(\"/// $line$\\n\", \"line\", *it);\n        }\n    }\n    printer->Print(\"/// </summary>\\n\");\n}\n\ntemplate <typename DescriptorType>\nstatic void WriteDocCommentBody(\n    io::Printer* printer, const DescriptorType* descriptor) {\n    SourceLocation location;\n    if (descriptor->GetSourceLocation(&location)) {\n        WriteDocCommentBodyImpl(printer, location);\n    }\n}\n\nvoid WriteMessageDocComment(io::Printer* printer, const Descriptor* message) {\n    WriteDocCommentBody(printer, message);\n}\n\nvoid WritePropertyDocComment(io::Printer* printer, const FieldDescriptor* field) {\n    WriteDocCommentBody(printer, field);\n}\n\nvoid WriteEnumDocComment(io::Printer* printer, const EnumDescriptor* enumDescriptor) {\n    WriteDocCommentBody(printer, enumDescriptor);\n}\nvoid WriteEnumValueDocComment(io::Printer* printer, const EnumValueDescriptor* value) {\n    WriteDocCommentBody(printer, value);\n}\n\nvoid WriteMethodDocComment(io::Printer* printer, const MethodDescriptor* method) {\n    WriteDocCommentBody(printer, method);\n}\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_doc_comment.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_DOC_COMMENT_H__\n#define GOOGLE_PROTOBUF_COMPILER_CSHARP_DOC_COMMENT_H__\n\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/descriptor.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n    void WriteMessageDocComment(io::Printer* printer, const Descriptor* message);\n    void WritePropertyDocComment(io::Printer* printer, const FieldDescriptor* field);\n    void WriteEnumDocComment(io::Printer* printer, const EnumDescriptor* enumDescriptor);\n    void WriteEnumValueDocComment(io::Printer* printer, const EnumValueDescriptor* value);\n    void WriteMethodDocComment(io::Printer* printer, const MethodDescriptor* method);\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_CSHARP_DOC_COMMENT_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_enum.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <sstream>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/plugin.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/stubs/strutil.h>\n\n#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>\n#include <google/protobuf/compiler/csharp/csharp_enum.h>\n#include <google/protobuf/compiler/csharp/csharp_helpers.h>\n#include <google/protobuf/compiler/csharp/csharp_options.h>\n\nusing google::protobuf::internal::scoped_ptr;\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nEnumGenerator::EnumGenerator(const EnumDescriptor* descriptor, const Options* options) :\n    SourceGeneratorBase(descriptor->file(), options),\n    descriptor_(descriptor) {\n}\n\nEnumGenerator::~EnumGenerator() {\n}\n\nvoid EnumGenerator::Generate(io::Printer* printer) {\n  WriteEnumDocComment(printer, descriptor_);\n  printer->Print(\"$access_level$ enum $name$ {\\n\",\n                 \"access_level\", class_access_level(),\n                 \"name\", descriptor_->name());\n  printer->Indent();\n  std::set<string> used_names;\n  for (int i = 0; i < descriptor_->value_count(); i++) {\n      WriteEnumValueDocComment(printer, descriptor_->value(i));\n      string original_name = descriptor_->value(i)->name();\n      string name = options()->legacy_enum_values\n          ? descriptor_->value(i)->name()\n          : GetEnumValueName(descriptor_->name(), descriptor_->value(i)->name());\n      // Make sure we don't get any duplicate names due to prefix removal.\n      while (!used_names.insert(name).second) {\n        // It's possible we'll end up giving this warning multiple times, but that's better than not at all.\n        GOOGLE_LOG(WARNING) << \"Duplicate enum value \" << name << \" (originally \" << original_name\n          << \") in \" << descriptor_->name() << \"; adding underscore to distinguish\";\n        name += \"_\";\n      }\n      printer->Print(\"[pbr::OriginalName(\\\"$original_name$\\\")] $name$ = $number$,\\n\",\n         \"original_name\", original_name,\n         \"name\", name,\n         \"number\", SimpleItoa(descriptor_->value(i)->number()));         \n  }\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n  printer->Print(\"\\n\");\n}\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_enum.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_ENUM_H__\n#define GOOGLE_PROTOBUF_COMPILER_CSHARP_ENUM_H__\n\n#include <string>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/csharp/csharp_source_generator_base.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nclass EnumGenerator : public SourceGeneratorBase {\n public:\n  EnumGenerator(const EnumDescriptor* descriptor, const Options* options);\n  ~EnumGenerator();\n\n  void Generate(io::Printer* printer);\n\n private:\n  const EnumDescriptor* descriptor_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator);\n};\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMPILER_CSHARP_ENUM_H__\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_enum_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <sstream>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/plugin.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n\n#include <google/protobuf/compiler/csharp/csharp_helpers.h>\n#include <google/protobuf/compiler/csharp/csharp_options.h>\n#include <google/protobuf/compiler/csharp/csharp_enum_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nEnumFieldGenerator::EnumFieldGenerator(const FieldDescriptor* descriptor,\n                                       int fieldOrdinal, const Options *options)\n    : PrimitiveFieldGenerator(descriptor, fieldOrdinal, options) {\n}\n\nEnumFieldGenerator::~EnumFieldGenerator() {\n}\n\nvoid EnumFieldGenerator::GenerateParsingCode(io::Printer* printer) {\n  printer->Print(variables_,\n    \"$name$_ = ($type_name$) input.ReadEnum();\\n\");\n}\n\nvoid EnumFieldGenerator::GenerateSerializationCode(io::Printer* printer) {\n  printer->Print(variables_,\n    \"if ($has_property_check$) {\\n\"\n    \"  output.WriteRawTag($tag_bytes$);\\n\"\n    \"  output.WriteEnum((int) $property_name$);\\n\"\n    \"}\\n\");\n}\n\nvoid EnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if ($has_property_check$) {\\n\"\n      \"  size += $tag_size$ + pb::CodedOutputStream.ComputeEnumSize((int) $property_name$);\\n\"\n    \"}\\n\");\n}\n\nvoid EnumFieldGenerator::GenerateCodecCode(io::Printer* printer) {\n    printer->Print(\n        variables_,\n        \"pb::FieldCodec.ForEnum($tag$, x => (int) x, x => ($type_name$) x)\");\n}\n\nEnumOneofFieldGenerator::EnumOneofFieldGenerator(\n    const FieldDescriptor* descriptor, int fieldOrdinal, const Options *options)\n  : PrimitiveOneofFieldGenerator(descriptor, fieldOrdinal, options) {\n}\n\nEnumOneofFieldGenerator::~EnumOneofFieldGenerator() {\n}\n\nvoid EnumOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) {\n  // TODO(jonskeet): What about if we read the default value?\n  printer->Print(\n    variables_,\n    \"$oneof_name$_ = input.ReadEnum();\\n\"\n    \"$oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\\n\");\n}\n\nvoid EnumOneofFieldGenerator::GenerateSerializationCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if ($has_property_check$) {\\n\"\n    \"  output.WriteRawTag($tag_bytes$);\\n\"\n    \"  output.WriteEnum((int) $property_name$);\\n\"\n    \"}\\n\");\n}\n\nvoid EnumOneofFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if ($has_property_check$) {\\n\"\n    \"  size += $tag_size$ + pb::CodedOutputStream.ComputeEnumSize((int) $property_name$);\\n\"\n    \"}\\n\");\n}\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_enum_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_ENUM_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_CSHARP_ENUM_FIELD_H__\n\n#include <string>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/csharp/csharp_primitive_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nclass EnumFieldGenerator : public PrimitiveFieldGenerator {\n public:\n  EnumFieldGenerator(const FieldDescriptor* descriptor,\n                     int fieldOrdinal,\n                     const Options *options);\n  ~EnumFieldGenerator();\n\n  virtual void GenerateCodecCode(io::Printer* printer);\n  virtual void GenerateParsingCode(io::Printer* printer);\n  virtual void GenerateSerializationCode(io::Printer* printer);\n  virtual void GenerateSerializedSizeCode(io::Printer* printer);\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator);\n};\n\nclass EnumOneofFieldGenerator : public PrimitiveOneofFieldGenerator {\n public:\n  EnumOneofFieldGenerator(const FieldDescriptor* descriptor,\n                          int fieldOrdinal,\n                          const Options *options);\n  ~EnumOneofFieldGenerator();\n\n  virtual void GenerateParsingCode(io::Printer* printer);\n  virtual void GenerateSerializationCode(io::Printer* printer);\n  virtual void GenerateSerializedSizeCode(io::Printer* printer);\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumOneofFieldGenerator);\n};\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMPILER_CSHARP_ENUM_FIELD_H__\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_field_base.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <limits>\n#include <sstream>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/plugin.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/stubs/mathlimits.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/wire_format.h>\n\n#include <google/protobuf/compiler/csharp/csharp_field_base.h>\n#include <google/protobuf/compiler/csharp/csharp_helpers.h>\n#include <google/protobuf/compiler/csharp/csharp_names.h>\n\nusing google::protobuf::internal::scoped_ptr;\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nvoid FieldGeneratorBase::SetCommonFieldVariables(\n    map<string, string>* variables) {\n  // Note: this will be valid even though the tag emitted for packed and unpacked versions of\n  // repeated fields varies by wire format. The wire format is encoded in the bottom 3 bits, which\n  // never effects the tag size.\n  int tag_size = internal::WireFormat::TagSize(descriptor_->number(), descriptor_->type());\n  uint tag = internal::WireFormat::MakeTag(descriptor_);\n  uint8 tag_array[5];\n  io::CodedOutputStream::WriteTagToArray(tag, tag_array);\n  string tag_bytes = SimpleItoa(tag_array[0]);\n  for (int i = 1; i < tag_size; i++) {\n    tag_bytes += \", \" + SimpleItoa(tag_array[i]);\n  }\n\n  (*variables)[\"access_level\"] = \"public\";\n  (*variables)[\"tag\"] = SimpleItoa(tag);\n  (*variables)[\"tag_size\"] = SimpleItoa(tag_size);\n  (*variables)[\"tag_bytes\"] = tag_bytes;\n\n  (*variables)[\"property_name\"] = property_name();\n  (*variables)[\"type_name\"] = type_name();\n  (*variables)[\"name\"] = name();\n  (*variables)[\"descriptor_name\"] = descriptor_->name();\n  (*variables)[\"default_value\"] = default_value();\n  if (has_default_value()) {\n    (*variables)[\"name_def_message\"] =\n      (*variables)[\"name\"] + \"_ = \" + (*variables)[\"default_value\"];\n  } else {\n    (*variables)[\"name_def_message\"] = (*variables)[\"name\"] + \"_\";\n  }\n  (*variables)[\"capitalized_type_name\"] = capitalized_type_name();\n  (*variables)[\"number\"] = number();\n  (*variables)[\"has_property_check\"] =\n    (*variables)[\"property_name\"] + \" != \" + (*variables)[\"default_value\"];\n  (*variables)[\"other_has_property_check\"] = \"other.\" +\n    (*variables)[\"property_name\"] + \" != \" + (*variables)[\"default_value\"];\n}\n\nvoid FieldGeneratorBase::SetCommonOneofFieldVariables(\n    map<string, string>* variables) {\n  (*variables)[\"oneof_name\"] = oneof_name();\n  (*variables)[\"has_property_check\"] =\n    oneof_name() + \"Case_ == \" + oneof_property_name() +\n    \"OneofCase.\" + property_name();\n  (*variables)[\"oneof_property_name\"] = oneof_property_name();\n}\n\nFieldGeneratorBase::FieldGeneratorBase(const FieldDescriptor* descriptor,\n                                       int fieldOrdinal, const Options* options)\n    : SourceGeneratorBase(descriptor->file(), options),\n      descriptor_(descriptor),\n      fieldOrdinal_(fieldOrdinal) {\n  SetCommonFieldVariables(&variables_);\n}\n\nFieldGeneratorBase::~FieldGeneratorBase() {\n}\n\nvoid FieldGeneratorBase::GenerateFreezingCode(io::Printer* printer) {\n  // No-op: only message fields and repeated fields need\n  // special handling for freezing, so default to not generating any code.\n}\n\nvoid FieldGeneratorBase::GenerateCodecCode(io::Printer* printer) {\n    // No-op: expect this to be overridden by appropriate types.\n    // Could fail if we get called here though...\n}\n\nvoid FieldGeneratorBase::AddDeprecatedFlag(io::Printer* printer) {\n  if (descriptor_->options().deprecated())\n  {\n    printer->Print(\"[global::System.ObsoleteAttribute]\\n\");\n  }\n}\n\nvoid FieldGeneratorBase::AddPublicMemberAttributes(io::Printer* printer) {\n  AddDeprecatedFlag(printer);\n  WriteGeneratedCodeAttributes(printer);\n}\n\nstd::string FieldGeneratorBase::oneof_property_name() {\n  return UnderscoresToCamelCase(descriptor_->containing_oneof()->name(), true);\n}\n\nstd::string FieldGeneratorBase::oneof_name() {\n  return UnderscoresToCamelCase(descriptor_->containing_oneof()->name(), false);\n}\n\nstd::string FieldGeneratorBase::property_name() {\n  return GetPropertyName(descriptor_);\n}\n\nstd::string FieldGeneratorBase::name() {\n  return UnderscoresToCamelCase(GetFieldName(descriptor_), false);\n}\n\nstd::string FieldGeneratorBase::type_name() {\n  return type_name(descriptor_);\n}\n\nstd::string FieldGeneratorBase::type_name(const FieldDescriptor* descriptor) {\n  switch (descriptor->type()) {\n    case FieldDescriptor::TYPE_ENUM:\n      return GetClassName(descriptor->enum_type());\n    case FieldDescriptor::TYPE_MESSAGE:\n    case FieldDescriptor::TYPE_GROUP:\n      if (IsWrapperType(descriptor)) {\n        const FieldDescriptor* wrapped_field =\n            descriptor->message_type()->field(0);\n        string wrapped_field_type_name = type_name(wrapped_field);\n        // String and ByteString go to the same type; other wrapped types\n        // go to the nullable equivalent.\n        if (wrapped_field->type() == FieldDescriptor::TYPE_STRING ||\n            wrapped_field->type() == FieldDescriptor::TYPE_BYTES) {\n          return wrapped_field_type_name;\n        } else {\n          return wrapped_field_type_name + \"?\";\n        }\n      }\n      return GetClassName(descriptor->message_type());\n    case FieldDescriptor::TYPE_DOUBLE:\n      return \"double\";\n    case FieldDescriptor::TYPE_FLOAT:\n      return \"float\";\n    case FieldDescriptor::TYPE_INT64:\n      return \"long\";\n    case FieldDescriptor::TYPE_UINT64:\n      return \"ulong\";\n    case FieldDescriptor::TYPE_INT32:\n      return \"int\";\n    case FieldDescriptor::TYPE_FIXED64:\n      return \"ulong\";\n    case FieldDescriptor::TYPE_FIXED32:\n      return \"uint\";\n    case FieldDescriptor::TYPE_BOOL:\n      return \"bool\";\n    case FieldDescriptor::TYPE_STRING:\n      return \"string\";\n    case FieldDescriptor::TYPE_BYTES:\n      return \"pb::ByteString\";\n    case FieldDescriptor::TYPE_UINT32:\n      return \"uint\";\n    case FieldDescriptor::TYPE_SFIXED32:\n      return \"int\";\n    case FieldDescriptor::TYPE_SFIXED64:\n      return \"long\";\n    case FieldDescriptor::TYPE_SINT32:\n      return \"int\";\n    case FieldDescriptor::TYPE_SINT64:\n      return \"long\";\n    default:\n      GOOGLE_LOG(FATAL)<< \"Unknown field type.\";\n      return \"\";\n  }\n}\n\nbool FieldGeneratorBase::has_default_value() {\n  switch (descriptor_->type()) {\n    case FieldDescriptor::TYPE_ENUM:\n    case FieldDescriptor::TYPE_MESSAGE:\n    case FieldDescriptor::TYPE_GROUP:\n      return true;\n    case FieldDescriptor::TYPE_DOUBLE:\n      return descriptor_->default_value_double() != 0.0;\n    case FieldDescriptor::TYPE_FLOAT:\n      return descriptor_->default_value_float() != 0.0;\n    case FieldDescriptor::TYPE_INT64:\n      return descriptor_->default_value_int64() != 0L;\n    case FieldDescriptor::TYPE_UINT64:\n      return descriptor_->default_value_uint64() != 0L;\n    case FieldDescriptor::TYPE_INT32:\n      return descriptor_->default_value_int32() != 0;\n    case FieldDescriptor::TYPE_FIXED64:\n      return descriptor_->default_value_uint64() != 0L;\n    case FieldDescriptor::TYPE_FIXED32:\n      return descriptor_->default_value_uint32() != 0;\n    case FieldDescriptor::TYPE_BOOL:\n      return descriptor_->default_value_bool();\n    case FieldDescriptor::TYPE_STRING:\n      return true;\n    case FieldDescriptor::TYPE_BYTES:\n      return true;\n    case FieldDescriptor::TYPE_UINT32:\n      return descriptor_->default_value_uint32() != 0;\n    case FieldDescriptor::TYPE_SFIXED32:\n      return descriptor_->default_value_int32() != 0;\n    case FieldDescriptor::TYPE_SFIXED64:\n      return descriptor_->default_value_int64() != 0L;\n    case FieldDescriptor::TYPE_SINT32:\n      return descriptor_->default_value_int32() != 0;\n    case FieldDescriptor::TYPE_SINT64:\n      return descriptor_->default_value_int64() != 0L;\n    default:\n      GOOGLE_LOG(FATAL)<< \"Unknown field type.\";\n      return true;\n  }\n}\n\nbool FieldGeneratorBase::is_nullable_type() {\n  switch (descriptor_->type()) {\n    case FieldDescriptor::TYPE_ENUM:\n    case FieldDescriptor::TYPE_DOUBLE:\n    case FieldDescriptor::TYPE_FLOAT:\n    case FieldDescriptor::TYPE_INT64:\n    case FieldDescriptor::TYPE_UINT64:\n    case FieldDescriptor::TYPE_INT32:\n    case FieldDescriptor::TYPE_FIXED64:\n    case FieldDescriptor::TYPE_FIXED32:\n    case FieldDescriptor::TYPE_BOOL:\n    case FieldDescriptor::TYPE_UINT32:\n    case FieldDescriptor::TYPE_SFIXED32:\n    case FieldDescriptor::TYPE_SFIXED64:\n    case FieldDescriptor::TYPE_SINT32:\n    case FieldDescriptor::TYPE_SINT64:\n      return false;\n\n    case FieldDescriptor::TYPE_MESSAGE:\n    case FieldDescriptor::TYPE_GROUP:\n    case FieldDescriptor::TYPE_STRING:\n    case FieldDescriptor::TYPE_BYTES:\n      return true;\n\n    default:\n      GOOGLE_LOG(FATAL)<< \"Unknown field type.\";\n      return true;\n  }\n}\n\nbool AllPrintableAscii(const std::string& text) {\n  for(int i = 0; i < text.size(); i++) {\n    if (text[i] < 0x20 || text[i] > 0x7e) {\n      return false;\n    }\n  }\n  return true;\n}\n\nstd::string FieldGeneratorBase::GetStringDefaultValueInternal() {\n  // No other default values needed for proto3...\n  return \"\\\"\\\"\";\n}\n\nstd::string FieldGeneratorBase::GetBytesDefaultValueInternal() {\n  // No other default values needed for proto3...\n  return \"pb::ByteString.Empty\";\n}\n\nstd::string FieldGeneratorBase::default_value() {\n    return default_value(descriptor_);\n}\n\nstd::string FieldGeneratorBase::default_value(const FieldDescriptor* descriptor) {\n  switch (descriptor->type()) {\n    case FieldDescriptor::TYPE_ENUM:\n      // All proto3 enums have a default value of 0, and there's an implicit conversion from the constant 0 to\n      // any C# enum. This means we don't need to work out what we actually mapped the enum value name to.\n     return \"0\";\n    case FieldDescriptor::TYPE_MESSAGE:\n    case FieldDescriptor::TYPE_GROUP:\n      if (IsWrapperType(descriptor)) {\n        const FieldDescriptor* wrapped_field = descriptor->message_type()->field(0);\n        return default_value(wrapped_field);\n      } else {\n        return \"null\";\n      }\n    case FieldDescriptor::TYPE_DOUBLE: {\n      double value = descriptor->default_value_double();\n      if (value == numeric_limits<double>::infinity()) {\n        return \"double.PositiveInfinity\";\n      } else if (value == -numeric_limits<double>::infinity()) {\n        return \"double.NegativeInfinity\";\n      } else if (MathLimits<double>::IsNaN(value)) {\n        return \"double.NaN\";\n      }\n      return SimpleDtoa(value) + \"D\";\n    }\n    case FieldDescriptor::TYPE_FLOAT: {\n      float value = descriptor->default_value_float();\n      if (value == numeric_limits<float>::infinity()) {\n        return \"float.PositiveInfinity\";\n      } else if (value == -numeric_limits<float>::infinity()) {\n        return \"float.NegativeInfinity\";\n      } else if (MathLimits<float>::IsNaN(value)) {\n        return \"float.NaN\";\n      }\n      return SimpleFtoa(value) + \"F\";\n    }\n    case FieldDescriptor::TYPE_INT64:\n      return SimpleItoa(descriptor->default_value_int64()) + \"L\";\n    case FieldDescriptor::TYPE_UINT64:\n      return SimpleItoa(descriptor->default_value_uint64()) + \"UL\";\n    case FieldDescriptor::TYPE_INT32:\n      return SimpleItoa(descriptor->default_value_int32());\n    case FieldDescriptor::TYPE_FIXED64:\n      return SimpleItoa(descriptor->default_value_uint64()) + \"UL\";\n    case FieldDescriptor::TYPE_FIXED32:\n      return SimpleItoa(descriptor->default_value_uint32());\n    case FieldDescriptor::TYPE_BOOL:\n      if (descriptor->default_value_bool()) {\n        return \"true\";\n      } else {\n        return \"false\";\n      }\n    case FieldDescriptor::TYPE_STRING:\n      return GetStringDefaultValueInternal();\n    case FieldDescriptor::TYPE_BYTES:\n      return GetBytesDefaultValueInternal();\n    case FieldDescriptor::TYPE_UINT32:\n      return SimpleItoa(descriptor->default_value_uint32());\n    case FieldDescriptor::TYPE_SFIXED32:\n      return SimpleItoa(descriptor->default_value_int32());\n    case FieldDescriptor::TYPE_SFIXED64:\n      return SimpleItoa(descriptor->default_value_int64()) + \"L\";\n    case FieldDescriptor::TYPE_SINT32:\n      return SimpleItoa(descriptor->default_value_int32());\n    case FieldDescriptor::TYPE_SINT64:\n      return SimpleItoa(descriptor->default_value_int64()) + \"L\";\n    default:\n      GOOGLE_LOG(FATAL)<< \"Unknown field type.\";\n      return \"\";\n  }\n}\n\nstd::string FieldGeneratorBase::number() {\n  return SimpleItoa(descriptor_->number());\n}\n\nstd::string FieldGeneratorBase::capitalized_type_name() {\n  switch (descriptor_->type()) {\n    case FieldDescriptor::TYPE_ENUM:\n      return \"Enum\";\n    case FieldDescriptor::TYPE_MESSAGE:\n      return \"Message\";\n    case FieldDescriptor::TYPE_GROUP:\n      return \"Group\";\n    case FieldDescriptor::TYPE_DOUBLE:\n      return \"Double\";\n    case FieldDescriptor::TYPE_FLOAT:\n      return \"Float\";\n    case FieldDescriptor::TYPE_INT64:\n      return \"Int64\";\n    case FieldDescriptor::TYPE_UINT64:\n      return \"UInt64\";\n    case FieldDescriptor::TYPE_INT32:\n      return \"Int32\";\n    case FieldDescriptor::TYPE_FIXED64:\n      return \"Fixed64\";\n    case FieldDescriptor::TYPE_FIXED32:\n      return \"Fixed32\";\n    case FieldDescriptor::TYPE_BOOL:\n      return \"Bool\";\n    case FieldDescriptor::TYPE_STRING:\n      return \"String\";\n    case FieldDescriptor::TYPE_BYTES:\n      return \"Bytes\";\n    case FieldDescriptor::TYPE_UINT32:\n      return \"UInt32\";\n    case FieldDescriptor::TYPE_SFIXED32:\n      return \"SFixed32\";\n    case FieldDescriptor::TYPE_SFIXED64:\n      return \"SFixed64\";\n    case FieldDescriptor::TYPE_SINT32:\n      return \"SInt32\";\n    case FieldDescriptor::TYPE_SINT64:\n      return \"SInt64\";\n    default:\n      GOOGLE_LOG(FATAL)<< \"Unknown field type.\";\n      return \"\";\n  }\n}\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_field_base.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_FIELD_BASE_H__\n#define GOOGLE_PROTOBUF_COMPILER_CSHARP_FIELD_BASE_H__\n\n#include <string>\n#include <google/protobuf/stubs/strutil.h>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/csharp/csharp_source_generator_base.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nclass FieldGeneratorBase : public SourceGeneratorBase {\n public:\n  FieldGeneratorBase(const FieldDescriptor* descriptor,\n                     int fieldOrdinal,\n                     const Options* options);\n  ~FieldGeneratorBase();\n\n  virtual void GenerateCloningCode(io::Printer* printer) = 0;\n  virtual void GenerateFreezingCode(io::Printer* printer);\n  virtual void GenerateCodecCode(io::Printer* printer);\n  virtual void GenerateMembers(io::Printer* printer) = 0;\n  virtual void GenerateMergingCode(io::Printer* printer) = 0;\n  virtual void GenerateParsingCode(io::Printer* printer) = 0;\n  virtual void GenerateSerializationCode(io::Printer* printer) = 0;\n  virtual void GenerateSerializedSizeCode(io::Printer* printer) = 0;\n\n  virtual void WriteHash(io::Printer* printer) = 0;\n  virtual void WriteEquals(io::Printer* printer) = 0;\n  // Currently unused, as we use reflection to generate JSON\n  virtual void WriteToString(io::Printer* printer) = 0;\n\n protected:\n  const FieldDescriptor* descriptor_;\n  const int fieldOrdinal_;\n  map<string, string> variables_;\n\n  void AddDeprecatedFlag(io::Printer* printer);\n  void AddNullCheck(io::Printer* printer);\n  void AddNullCheck(io::Printer* printer, const std::string& name);\n\n  void AddPublicMemberAttributes(io::Printer* printer);\n  void SetCommonOneofFieldVariables(map<string, string>* variables);\n\n  std::string oneof_property_name();\n  std::string oneof_name();\n  std::string property_name();\n  std::string name();\n  std::string type_name();\n  std::string type_name(const FieldDescriptor* descriptor);\n  bool has_default_value();\n  bool is_nullable_type();\n  std::string default_value();\n  std::string default_value(const FieldDescriptor* descriptor);\n  std::string number();\n  std::string capitalized_type_name();\n\n private:\n  void SetCommonFieldVariables(map<string, string>* variables);\n  std::string GetStringDefaultValueInternal();\n  std::string GetBytesDefaultValueInternal();\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorBase);\n};\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMPILER_CSHARP_FIELD_BASE_H__\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_generator.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <sstream>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/plugin.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/stubs/strutil.h>\n\n#include <google/protobuf/compiler/csharp/csharp_generator.h>\n#include <google/protobuf/compiler/csharp/csharp_helpers.h>\n#include <google/protobuf/compiler/csharp/csharp_names.h>\n#include <google/protobuf/compiler/csharp/csharp_options.h>\n#include <google/protobuf/compiler/csharp/csharp_reflection_class.h>\n\nusing google::protobuf::internal::scoped_ptr;\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nvoid GenerateFile(const google::protobuf::FileDescriptor* file,\n                  io::Printer* printer,\n                  const Options* options) {\n  ReflectionClassGenerator reflectionClassGenerator(file, options);\n  reflectionClassGenerator.Generate(printer);\n}\n\nbool Generator::Generate(\n    const FileDescriptor* file,\n    const string& parameter,\n    GeneratorContext* generator_context,\n    string* error) const {\n\n  vector<pair<string, string> > options;\n  ParseGeneratorParameter(parameter, &options);\n\n  // We only support proto3 - but we make an exception for descriptor.proto.\n  if (file->syntax() != FileDescriptor::SYNTAX_PROTO3 && !IsDescriptorProto(file)) {\n    *error = \"C# code generation only supports proto3 syntax\";\n    return false;\n  }\n\n  struct Options cli_options;\n\n  for (int i = 0; i < options.size(); i++) {\n    if (options[i].first == \"file_extension\") {\n      cli_options.file_extension = options[i].second;\n    } else if (options[i].first == \"base_namespace\") {\n      cli_options.base_namespace = options[i].second;\n      cli_options.base_namespace_specified = true;\n    } else if (options[i].first == \"internal_access\") {\n      cli_options.internal_access = true;\n    } else if (options[i].first == \"legacy_enum_values\") {\n      // TODO: Remove this before final release\n      cli_options.legacy_enum_values = true;\n    } else {\n      *error = \"Unknown generator option: \" + options[i].first;\n      return false;\n    }\n  }\n\n  string filename_error = \"\";\n  std::string filename = GetOutputFile(file,\n      cli_options.file_extension,\n      cli_options.base_namespace_specified,\n      cli_options.base_namespace,\n      &filename_error);\n\n  if (filename.empty()) {\n    *error = filename_error;\n    return false;\n  }\n  scoped_ptr<io::ZeroCopyOutputStream> output(\n      generator_context->Open(filename));\n  io::Printer printer(output.get(), '$');\n\n  GenerateFile(file, &printer, &cli_options);\n\n  return true;\n}\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_generator.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_GENERATOR_H__\n#define GOOGLE_PROTOBUF_COMPILER_CSHARP_GENERATOR_H__\n\n#include <string>\n\n#include <google/protobuf/compiler/code_generator.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nclass LIBPROTOC_EXPORT Generator\n    : public google::protobuf::compiler::CodeGenerator {\n  virtual bool Generate(\n      const FileDescriptor* file,\n      const string& parameter,\n      GeneratorContext* generator_context,\n      string* error) const;\n};\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMPILER_CSHARP_GENERATOR_H__\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2014 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <memory>\n\n#include <google/protobuf/compiler/command_line_interface.h>\n#include <google/protobuf/compiler/csharp/csharp_helpers.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/io/printer.h>\n\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n#include <google/protobuf/testing/file.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\nnamespace {\n\nTEST(CSharpEnumValue, PascalCasedPrefixStripping) {\n  EXPECT_EQ(\"Bar\", GetEnumValueName(\"Foo\", \"BAR\"));\n  EXPECT_EQ(\"BarBaz\", GetEnumValueName(\"Foo\", \"BAR_BAZ\"));\n  EXPECT_EQ(\"Bar\", GetEnumValueName(\"Foo\", \"FOO_BAR\"));\n  EXPECT_EQ(\"Bar\", GetEnumValueName(\"Foo\", \"FOO__BAR\"));\n  EXPECT_EQ(\"BarBaz\", GetEnumValueName(\"Foo\", \"FOO_BAR_BAZ\"));\n  EXPECT_EQ(\"BarBaz\", GetEnumValueName(\"Foo\", \"Foo_BarBaz\"));\n  EXPECT_EQ(\"Bar\", GetEnumValueName(\"FO_O\", \"FOO_BAR\"));\n  EXPECT_EQ(\"Bar\", GetEnumValueName(\"FOO\", \"F_O_O_BAR\"));\n  EXPECT_EQ(\"Bar\", GetEnumValueName(\"Foo\", \"BAR\"));\n  EXPECT_EQ(\"BarBaz\", GetEnumValueName(\"Foo\", \"BAR_BAZ\"));\n  EXPECT_EQ(\"Foo\", GetEnumValueName(\"Foo\", \"FOO\"));\n  EXPECT_EQ(\"Foo\", GetEnumValueName(\"Foo\", \"FOO___\"));\n  // Identifiers can't start with digits\n  EXPECT_EQ(\"_2Bar\", GetEnumValueName(\"Foo\", \"FOO_2_BAR\"));\n  EXPECT_EQ(\"_2\", GetEnumValueName(\"Foo\", \"FOO___2\"));\n}\n\n}  // namespace\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_helpers.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <algorithm>\n#include <google/protobuf/stubs/hash.h>\n#include <limits>\n#include <vector>\n\n#include <google/protobuf/compiler/csharp/csharp_helpers.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n\n#include <google/protobuf/compiler/csharp/csharp_field_base.h>\n#include <google/protobuf/compiler/csharp/csharp_enum_field.h>\n#include <google/protobuf/compiler/csharp/csharp_map_field.h>\n#include <google/protobuf/compiler/csharp/csharp_message_field.h>\n#include <google/protobuf/compiler/csharp/csharp_options.h>\n#include <google/protobuf/compiler/csharp/csharp_primitive_field.h>\n#include <google/protobuf/compiler/csharp/csharp_repeated_enum_field.h>\n#include <google/protobuf/compiler/csharp/csharp_repeated_message_field.h>\n#include <google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h>\n#include <google/protobuf/compiler/csharp/csharp_wrapper_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nCSharpType GetCSharpType(FieldDescriptor::Type type) {\n  switch (type) {\n    case FieldDescriptor::TYPE_INT32:\n      return CSHARPTYPE_INT32;\n    case FieldDescriptor::TYPE_INT64:\n      return CSHARPTYPE_INT64;\n    case FieldDescriptor::TYPE_UINT32:\n      return CSHARPTYPE_UINT32;\n    case FieldDescriptor::TYPE_UINT64:\n      return CSHARPTYPE_UINT32;\n    case FieldDescriptor::TYPE_SINT32:\n      return CSHARPTYPE_INT32;\n    case FieldDescriptor::TYPE_SINT64:\n      return CSHARPTYPE_INT64;\n    case FieldDescriptor::TYPE_FIXED32:\n      return CSHARPTYPE_UINT32;\n    case FieldDescriptor::TYPE_FIXED64:\n      return CSHARPTYPE_UINT64;\n    case FieldDescriptor::TYPE_SFIXED32:\n      return CSHARPTYPE_INT32;\n    case FieldDescriptor::TYPE_SFIXED64:\n      return CSHARPTYPE_INT64;\n    case FieldDescriptor::TYPE_FLOAT:\n      return CSHARPTYPE_FLOAT;\n    case FieldDescriptor::TYPE_DOUBLE:\n      return CSHARPTYPE_DOUBLE;\n    case FieldDescriptor::TYPE_BOOL:\n      return CSHARPTYPE_BOOL;\n    case FieldDescriptor::TYPE_ENUM:\n      return CSHARPTYPE_ENUM;\n    case FieldDescriptor::TYPE_STRING:\n      return CSHARPTYPE_STRING;\n    case FieldDescriptor::TYPE_BYTES:\n      return CSHARPTYPE_BYTESTRING;\n    case FieldDescriptor::TYPE_GROUP:\n      return CSHARPTYPE_MESSAGE;\n    case FieldDescriptor::TYPE_MESSAGE:\n      return CSHARPTYPE_MESSAGE;\n\n      // No default because we want the compiler to complain if any new\n      // types are added.\n  }\n  GOOGLE_LOG(FATAL)<< \"Can't get here.\";\n  return (CSharpType) -1;\n}\n\nstd::string StripDotProto(const std::string& proto_file) {\n  int lastindex = proto_file.find_last_of(\".\");\n  return proto_file.substr(0, lastindex);\n}\n\nstd::string GetFileNamespace(const FileDescriptor* descriptor) {\n  if (descriptor->options().has_csharp_namespace()) {\n    return descriptor->options().csharp_namespace();\n  }\n  return UnderscoresToCamelCase(descriptor->package(), true, true);\n}\n\n// Returns the Pascal-cased last part of the proto file. For example,\n// input of \"google/protobuf/foo_bar.proto\" would result in \"FooBar\".\nstd::string GetFileNameBase(const FileDescriptor* descriptor) {\n    std::string proto_file = descriptor->name();\n    int lastslash = proto_file.find_last_of(\"/\");\n    std::string base = proto_file.substr(lastslash + 1);\n    return UnderscoresToPascalCase(StripDotProto(base));\n}\n\nstd::string GetReflectionClassUnqualifiedName(const FileDescriptor* descriptor) {\n  // TODO: Detect collisions with existing messages,\n  // and append an underscore if necessary.\n  return GetFileNameBase(descriptor) + \"Reflection\";\n}\n\n// TODO(jtattermusch): can we reuse a utility function?\nstd::string UnderscoresToCamelCase(const std::string& input,\n                                   bool cap_next_letter,\n                                   bool preserve_period) {\n  string result;\n  // Note:  I distrust ctype.h due to locales.\n  for (int i = 0; i < input.size(); i++) {\n    if ('a' <= input[i] && input[i] <= 'z') {\n      if (cap_next_letter) {\n        result += input[i] + ('A' - 'a');\n      } else {\n        result += input[i];\n      }\n      cap_next_letter = false;\n    } else if ('A' <= input[i] && input[i] <= 'Z') {\n      if (i == 0 && !cap_next_letter) {\n        // Force first letter to lower-case unless explicitly told to\n        // capitalize it.\n        result += input[i] + ('a' - 'A');\n      } else {\n        // Capital letters after the first are left as-is.\n        result += input[i];\n      }\n      cap_next_letter = false;\n    } else if ('0' <= input[i] && input[i] <= '9') {\n      result += input[i];\n      cap_next_letter = true;\n    } else {\n      cap_next_letter = true;\n      if (input[i] == '.' && preserve_period) {\n        result += '.';\n      }\n    }\n  }\n  // Add a trailing \"_\" if the name should be altered.\n  if (input[input.size() - 1] == '#') {\n    result += '_';\n  }\n  return result;\n}\n\nstd::string UnderscoresToPascalCase(const std::string& input) {\n  return UnderscoresToCamelCase(input, true);\n}\n\n// Convert a string which is expected to be SHOUTY_CASE (but may not be *precisely* shouty)\n// into a PascalCase string. Precise rules implemented:\n\n// Previous input character      Current character         Case\n// Any                           Non-alphanumeric          Skipped\n// None - first char of input    Alphanumeric              Upper\n// Non-letter (e.g. _ or 1)      Alphanumeric              Upper\n// Numeric                       Alphanumeric              Upper\n// Lower letter                  Alphanumeric              Same as current\n// Upper letter                  Alphanumeric              Lower\nstd::string ShoutyToPascalCase(const std::string& input) {\n  string result;\n  // Simple way of implementing \"always start with upper\"\n  char previous = '_';\n  for (int i = 0; i < input.size(); i++) {\n    char current = input[i];\n    if (!ascii_isalnum(current)) {\n      previous = current;\n      continue;      \n    }\n    if (!ascii_isalnum(previous)) {\n      result += ascii_toupper(current);\n    } else if (ascii_isdigit(previous)) {\n      result += ascii_toupper(current);\n    } else if (ascii_islower(previous)) {\n      result += current;\n    } else {\n      result += ascii_tolower(current);\n    }\n    previous = current;\n  }\n  return result;\n}\n\n// Attempt to remove a prefix from a value, ignoring casing and skipping underscores.\n// (foo, foo_bar) => bar - underscore after prefix is skipped\n// (FOO, foo_bar) => bar - casing is ignored\n// (foo_bar, foobarbaz) => baz - underscore in prefix is ignored\n// (foobar, foo_barbaz) => baz - underscore in value is ignored\n// (foo, bar) => bar - prefix isn't matched; return original value\nstd::string TryRemovePrefix(const std::string& prefix, const std::string& value) {\n  // First normalize to a lower-case no-underscores prefix to match against\n  std::string prefix_to_match = \"\";\n  for (size_t i = 0; i < prefix.size(); i++) {\n    if (prefix[i] != '_') {\n      prefix_to_match += ascii_tolower(prefix[i]);\n    }\n  }\n  \n  // This keeps track of how much of value we've consumed\n  size_t prefix_index, value_index;\n  for (prefix_index = 0, value_index = 0;\n      prefix_index < prefix_to_match.size() && value_index < value.size();\n      value_index++) {\n    // Skip over underscores in the value\n    if (value[value_index] == '_') {\n      continue;\n    }\n    if (ascii_tolower(value[value_index]) != prefix_to_match[prefix_index++]) {\n      // Failed to match the prefix - bail out early.\n      return value;\n    }\n  }\n\n  // If we didn't finish looking through the prefix, we can't strip it.\n  if (prefix_index < prefix_to_match.size()) {\n    return value;\n  }\n\n  // Step over any underscores after the prefix\n  while (value_index < value.size() && value[value_index] == '_') {\n    value_index++;\n  }\n\n  // If there's nothing left (e.g. it was a prefix with only underscores afterwards), don't strip.\n  if (value_index == value.size()) {\n    return value;\n  }\n\n  return value.substr(value_index);\n}\n\n// Format the enum value name in a pleasant way for C#:\n// - Strip the enum name as a prefix if possible\n// - Convert to PascalCase.\n// For example, an enum called Color with a value of COLOR_BLUE should\n// result in an enum value in C# called just Blue\nstd::string GetEnumValueName(const std::string& enum_name, const std::string& enum_value_name) {\n  std::string stripped = TryRemovePrefix(enum_name, enum_value_name);\n  std::string result = ShoutyToPascalCase(stripped);\n  // Just in case we have an enum name of FOO and a value of FOO_2... make sure the returned\n  // string is a valid identifier.\n  if (ascii_isdigit(result[0])) {\n    result = \"_\" + result;\n  }\n  return result;\n}\n\nstd::string ToCSharpName(const std::string& name, const FileDescriptor* file) {\n  std::string result = GetFileNamespace(file);\n  if (result != \"\") {\n    result += '.';\n  }\n  string classname;\n  if (file->package().empty()) {\n    classname = name;\n  } else {\n    // Strip the proto package from full_name since we've replaced it with\n    // the C# namespace.\n    classname = name.substr(file->package().size() + 1);\n  }\n  result += StringReplace(classname, \".\", \".Types.\", true);\n  return \"global::\" + result;\n}\n\nstd::string GetReflectionClassName(const FileDescriptor* descriptor) {\n  std::string result = GetFileNamespace(descriptor);\n  if (!result.empty()) {\n    result += '.';\n  }\n  result += GetReflectionClassUnqualifiedName(descriptor);\n  return \"global::\" + result;\n}\n\nstd::string GetClassName(const Descriptor* descriptor) {\n  return ToCSharpName(descriptor->full_name(), descriptor->file());\n}\n\nstd::string GetClassName(const EnumDescriptor* descriptor) {\n  return ToCSharpName(descriptor->full_name(), descriptor->file());\n}\n\n// Groups are hacky:  The name of the field is just the lower-cased name\n// of the group type.  In C#, though, we would like to retain the original\n// capitalization of the type name.\nstd::string GetFieldName(const FieldDescriptor* descriptor) {\n  if (descriptor->type() == FieldDescriptor::TYPE_GROUP) {\n    return descriptor->message_type()->name();\n  } else {\n    return descriptor->name();\n  }\n}\n\nstd::string GetFieldConstantName(const FieldDescriptor* field) {\n  return GetPropertyName(field) + \"FieldNumber\";\n}\n\nstd::string GetPropertyName(const FieldDescriptor* descriptor) {\n  // TODO(jtattermusch): consider introducing csharp_property_name field option\n  std::string property_name = UnderscoresToPascalCase(GetFieldName(descriptor));\n  // Avoid either our own type name or reserved names. Note that not all names\n  // are reserved - a field called to_string, write_to etc would still cause a problem.\n  // There are various ways of ending up with naming collisions, but we try to avoid obvious\n  // ones.\n  if (property_name == descriptor->containing_type()->name()\n      || property_name == \"Types\"\n      || property_name == \"Descriptor\") {\n    property_name += \"_\";\n  }\n  return property_name;\n}\n\nstd::string GetOutputFile(\n    const google::protobuf::FileDescriptor* descriptor,\n    const std::string file_extension,\n    const bool generate_directories,\n    const std::string base_namespace,\n    string* error) {\n  string relative_filename = GetFileNameBase(descriptor) + file_extension;\n  if (!generate_directories) {\n    return relative_filename;\n  }\n  string ns = GetFileNamespace(descriptor);\n  string namespace_suffix = ns;\n  if (!base_namespace.empty()) {\n    // Check that the base_namespace is either equal to or a leading part of\n    // the file namespace. This isn't just a simple prefix; \"Foo.B\" shouldn't\n    // be regarded as a prefix of \"Foo.Bar\". The simplest option is to add \".\"\n    // to both.\n    string extended_ns = ns + \".\";\n    if (extended_ns.find(base_namespace + \".\") != 0) {\n      *error = \"Namespace \" + ns + \" is not a prefix namespace of base namespace \" + base_namespace;\n      return \"\"; // This will be ignored, because we've set an error.\n    }\n    namespace_suffix = ns.substr(base_namespace.length());\n    if (namespace_suffix.find(\".\") == 0) {\n      namespace_suffix = namespace_suffix.substr(1);\n    }\n  }\n\n  string namespace_dir = StringReplace(namespace_suffix, \".\", \"/\", true);\n  if (!namespace_dir.empty()) {\n    namespace_dir += \"/\";\n  }\n  return namespace_dir + relative_filename;\n}\n\n// TODO: c&p from Java protoc plugin\n// For encodings with fixed sizes, returns that size in bytes.  Otherwise\n// returns -1.\nint GetFixedSize(FieldDescriptor::Type type) {\n  switch (type) {\n    case FieldDescriptor::TYPE_INT32   : return -1;\n    case FieldDescriptor::TYPE_INT64   : return -1;\n    case FieldDescriptor::TYPE_UINT32  : return -1;\n    case FieldDescriptor::TYPE_UINT64  : return -1;\n    case FieldDescriptor::TYPE_SINT32  : return -1;\n    case FieldDescriptor::TYPE_SINT64  : return -1;\n    case FieldDescriptor::TYPE_FIXED32 : return internal::WireFormatLite::kFixed32Size;\n    case FieldDescriptor::TYPE_FIXED64 : return internal::WireFormatLite::kFixed64Size;\n    case FieldDescriptor::TYPE_SFIXED32: return internal::WireFormatLite::kSFixed32Size;\n    case FieldDescriptor::TYPE_SFIXED64: return internal::WireFormatLite::kSFixed64Size;\n    case FieldDescriptor::TYPE_FLOAT   : return internal::WireFormatLite::kFloatSize;\n    case FieldDescriptor::TYPE_DOUBLE  : return internal::WireFormatLite::kDoubleSize;\n\n    case FieldDescriptor::TYPE_BOOL    : return internal::WireFormatLite::kBoolSize;\n    case FieldDescriptor::TYPE_ENUM    : return -1;\n\n    case FieldDescriptor::TYPE_STRING  : return -1;\n    case FieldDescriptor::TYPE_BYTES   : return -1;\n    case FieldDescriptor::TYPE_GROUP   : return -1;\n    case FieldDescriptor::TYPE_MESSAGE : return -1;\n\n    // No default because we want the compiler to complain if any new\n    // types are added.\n  }\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return -1;\n}\n\nstatic const char base64_chars[] =\n    \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\nstd::string StringToBase64(const std::string& input) {\n  std::string result;\n  size_t remaining = input.size();\n  const unsigned char *src = (const unsigned char*) input.c_str();\n  while (remaining > 2) {\n    result += base64_chars[src[0] >> 2];\n    result += base64_chars[((src[0] & 0x3) << 4) | (src[1] >> 4)];\n    result += base64_chars[((src[1] & 0xf) << 2) | (src[2] >> 6)];\n    result += base64_chars[src[2] & 0x3f];\n    remaining -= 3;\n    src += 3;\n  }\n  switch (remaining) {\n    case 2:\n      result += base64_chars[src[0] >> 2];\n      result += base64_chars[((src[0] & 0x3) << 4) | (src[1] >> 4)];\n      result += base64_chars[(src[1] & 0xf) << 2];\n      result += '=';\n      src += 2;\n      break;\n    case 1:\n      result += base64_chars[src[0] >> 2];\n      result += base64_chars[((src[0] & 0x3) << 4)];\n      result += '=';\n      result += '=';\n      src += 1;\n      break;\n  }\n  return result;\n}\n\nstd::string FileDescriptorToBase64(const FileDescriptor* descriptor) {\n  std::string fdp_bytes;\n  FileDescriptorProto fdp;\n  descriptor->CopyTo(&fdp);\n  fdp.SerializeToString(&fdp_bytes);\n  return StringToBase64(fdp_bytes);\n}\n\nFieldGeneratorBase* CreateFieldGenerator(const FieldDescriptor* descriptor,\n                                         int fieldOrdinal,\n                                         const Options* options) {\n  switch (descriptor->type()) {\n    case FieldDescriptor::TYPE_GROUP:\n    case FieldDescriptor::TYPE_MESSAGE:\n      if (descriptor->is_repeated()) {\n        if (descriptor->is_map()) {\n          return new MapFieldGenerator(descriptor, fieldOrdinal, options);\n        } else {\n          return new RepeatedMessageFieldGenerator(descriptor, fieldOrdinal, options);\n        }\n      } else {\n        if (IsWrapperType(descriptor)) {\n          if (descriptor->containing_oneof()) {\n            return new WrapperOneofFieldGenerator(descriptor, fieldOrdinal, options);\n          } else {\n            return new WrapperFieldGenerator(descriptor, fieldOrdinal, options);\n          }\n        } else {\n          if (descriptor->containing_oneof()) {\n            return new MessageOneofFieldGenerator(descriptor, fieldOrdinal, options);\n          } else {\n            return new MessageFieldGenerator(descriptor, fieldOrdinal, options);\n          }\n        }\n      }\n    case FieldDescriptor::TYPE_ENUM:\n      if (descriptor->is_repeated()) {\n        return new RepeatedEnumFieldGenerator(descriptor, fieldOrdinal, options);\n      } else {\n        if (descriptor->containing_oneof()) {\n          return new EnumOneofFieldGenerator(descriptor, fieldOrdinal, options);\n        } else {\n          return new EnumFieldGenerator(descriptor, fieldOrdinal, options);\n        }\n      }\n    default:\n      if (descriptor->is_repeated()) {\n        return new RepeatedPrimitiveFieldGenerator(descriptor, fieldOrdinal, options);\n      } else {\n        if (descriptor->containing_oneof()) {\n          return new PrimitiveOneofFieldGenerator(descriptor, fieldOrdinal, options);\n        } else {\n          return new PrimitiveFieldGenerator(descriptor, fieldOrdinal, options);\n        }\n      }\n  }\n}\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_helpers.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_HELPERS_H__\n#define GOOGLE_PROTOBUF_COMPILER_CSHARP_HELPERS_H__\n\n#include <string>\n#include <google/protobuf/stubs/port.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/io/printer.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nstruct Options;\nclass FieldGeneratorBase;\n\n// TODO: start using this enum.\nenum CSharpType {\n  CSHARPTYPE_INT32 = 1,\n  CSHARPTYPE_INT64 = 2,\n  CSHARPTYPE_UINT32 = 3,\n  CSHARPTYPE_UINT64 = 4,\n  CSHARPTYPE_FLOAT = 5,\n  CSHARPTYPE_DOUBLE = 6,\n  CSHARPTYPE_BOOL = 7,\n  CSHARPTYPE_STRING = 8,\n  CSHARPTYPE_BYTESTRING = 9,\n  CSHARPTYPE_MESSAGE = 10,\n  CSHARPTYPE_ENUM = 11,\n  MAX_CSHARPTYPE = 11\n};\n\n// Converts field type to corresponding C# type.\nCSharpType GetCSharpType(FieldDescriptor::Type type);\n\nstd::string StripDotProto(const std::string& proto_file);\n\n// Gets unqualified name of the reflection class\nstd::string GetReflectionClassUnqualifiedName(const FileDescriptor* descriptor);\n\nstd::string GetClassName(const EnumDescriptor* descriptor);\n\nstd::string GetFieldName(const FieldDescriptor* descriptor);\n\nstd::string GetFieldConstantName(const FieldDescriptor* field);\n\nstd::string GetPropertyName(const FieldDescriptor* descriptor);\n\nint GetFixedSize(FieldDescriptor::Type type);\n\nstd::string UnderscoresToCamelCase(const std::string& input,\n                                   bool cap_next_letter,\n                                   bool preserve_period);\n\ninline std::string UnderscoresToCamelCase(const std::string& input, bool cap_next_letter) {\n  return UnderscoresToCamelCase(input, cap_next_letter, false);\n}\n\nstd::string UnderscoresToPascalCase(const std::string& input);\n\n// Note that we wouldn't normally want to export this (we're not expecting\n// it to be used outside libprotoc itself) but this exposes it for testing.\nstd::string LIBPROTOBUF_EXPORT GetEnumValueName(const std::string& enum_name, const std::string& enum_value_name);\n\n// TODO(jtattermusch): perhaps we could move this to strutil\nstd::string StringToBase64(const std::string& input);\n\nstd::string FileDescriptorToBase64(const FileDescriptor* descriptor);\n\nFieldGeneratorBase* CreateFieldGenerator(const FieldDescriptor* descriptor,\n                                         int fieldOrdinal,\n                                         const Options* options);\n\n// Determines whether the given message is a map entry message,\n// i.e. one implicitly created by protoc due to a map<key, value> field.\ninline bool IsMapEntryMessage(const Descriptor* descriptor) {\n  return descriptor->options().map_entry();\n}\n\n// Determines whether we're generating code for the proto representation of\n// descriptors etc, for use in the runtime. This is the only type which is\n// allowed to use proto2 syntax, and it generates internal classes.\ninline bool IsDescriptorProto(const FileDescriptor* descriptor) {\n  return descriptor->name() == \"google/protobuf/descriptor.proto\";\n}\n\ninline bool IsWrapperType(const FieldDescriptor* descriptor) {\n  return descriptor->type() == FieldDescriptor::TYPE_MESSAGE &&\n      descriptor->message_type()->file()->name() == \"google/protobuf/wrappers.proto\";\n}\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_CSHARP_HELPERS_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_map_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2015 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <sstream>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/plugin.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/stubs/strutil.h>\n\n#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>\n#include <google/protobuf/compiler/csharp/csharp_helpers.h>\n#include <google/protobuf/compiler/csharp/csharp_map_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nMapFieldGenerator::MapFieldGenerator(const FieldDescriptor* descriptor,\n                                     int fieldOrdinal,\n                                     const Options* options)\n    : FieldGeneratorBase(descriptor, fieldOrdinal, options) {\n}\n\nMapFieldGenerator::~MapFieldGenerator() {\n}\n\nvoid MapFieldGenerator::GenerateMembers(io::Printer* printer) {   \n  const FieldDescriptor* key_descriptor =\n      descriptor_->message_type()->FindFieldByName(\"key\");\n  const FieldDescriptor* value_descriptor =\n      descriptor_->message_type()->FindFieldByName(\"value\");\n  variables_[\"key_type_name\"] = type_name(key_descriptor);\n  variables_[\"value_type_name\"] = type_name(value_descriptor);\n  scoped_ptr<FieldGeneratorBase> key_generator(\n      CreateFieldGenerator(key_descriptor, 1, this->options()));\n  scoped_ptr<FieldGeneratorBase> value_generator(\n      CreateFieldGenerator(value_descriptor, 2, this->options()));\n\n  printer->Print(\n    variables_,\n    \"private static readonly pbc::MapField<$key_type_name$, $value_type_name$>.Codec _map_$name$_codec\\n\"\n    \"    = new pbc::MapField<$key_type_name$, $value_type_name$>.Codec(\");\n  key_generator->GenerateCodecCode(printer);\n  printer->Print(\", \");\n  value_generator->GenerateCodecCode(printer);\n  printer->Print(\n    variables_,\n    \", $tag$);\\n\"\n    \"private readonly pbc::MapField<$key_type_name$, $value_type_name$> $name$_ = new pbc::MapField<$key_type_name$, $value_type_name$>();\\n\");\n  WritePropertyDocComment(printer, descriptor_);\n  AddPublicMemberAttributes(printer);\n  printer->Print(\n    variables_,\n    \"$access_level$ pbc::MapField<$key_type_name$, $value_type_name$> $property_name$ {\\n\"\n    \"  get { return $name$_; }\\n\"\n    \"}\\n\");\n}\n\nvoid MapFieldGenerator::GenerateMergingCode(io::Printer* printer) {\n  printer->Print(\n      variables_,\n      \"$name$_.Add(other.$name$_);\\n\");\n}\n\nvoid MapFieldGenerator::GenerateParsingCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"$name$_.AddEntriesFrom(input, _map_$name$_codec);\\n\");\n}\n\nvoid MapFieldGenerator::GenerateSerializationCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"$name$_.WriteTo(output, _map_$name$_codec);\\n\");\n}\n\nvoid MapFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"size += $name$_.CalculateSize(_map_$name$_codec);\\n\");\n}\n\nvoid MapFieldGenerator::WriteHash(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"hash ^= $property_name$.GetHashCode();\\n\");\n}\nvoid MapFieldGenerator::WriteEquals(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if (!$property_name$.Equals(other.$property_name$)) return false;\\n\");\n}\n\nvoid MapFieldGenerator::WriteToString(io::Printer* printer) {\n    // TODO: If we ever actually use ToString, we'll need to impleme this...\n}\n\nvoid MapFieldGenerator::GenerateCloningCode(io::Printer* printer) {\n  printer->Print(variables_,\n    \"$name$_ = other.$name$_.Clone();\\n\");\n}\n\nvoid MapFieldGenerator::GenerateFreezingCode(io::Printer* printer) {\n}\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_map_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_MAP_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_CSHARP_MAP_FIELD_H__\n\n#include <string>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/csharp/csharp_field_base.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nclass MapFieldGenerator : public FieldGeneratorBase {\n public:\n  MapFieldGenerator(const FieldDescriptor* descriptor,\n                    int fieldOrdinal,\n                    const Options* options);\n  ~MapFieldGenerator();\n\n  virtual void GenerateCloningCode(io::Printer* printer);\n  virtual void GenerateFreezingCode(io::Printer* printer);\n  virtual void GenerateMembers(io::Printer* printer);\n  virtual void GenerateMergingCode(io::Printer* printer);\n  virtual void GenerateParsingCode(io::Printer* printer);\n  virtual void GenerateSerializationCode(io::Printer* printer);\n  virtual void GenerateSerializedSizeCode(io::Printer* printer);\n\n  virtual void WriteHash(io::Printer* printer);\n  virtual void WriteEquals(io::Printer* printer);\n  virtual void WriteToString(io::Printer* printer);\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldGenerator);\n};\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMPILER_CSHARP_MAP_FIELD_H__\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_message.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <sstream>\n#include <algorithm>\n#include <map>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/plugin.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/wire_format_lite.h>\n\n#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>\n#include <google/protobuf/compiler/csharp/csharp_enum.h>\n#include <google/protobuf/compiler/csharp/csharp_field_base.h>\n#include <google/protobuf/compiler/csharp/csharp_helpers.h>\n#include <google/protobuf/compiler/csharp/csharp_message.h>\n#include <google/protobuf/compiler/csharp/csharp_names.h>\n\nusing google::protobuf::internal::scoped_ptr;\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nbool CompareFieldNumbers(const FieldDescriptor* d1, const FieldDescriptor* d2) {\n  return d1->number() < d2->number();\n}\n\nMessageGenerator::MessageGenerator(const Descriptor* descriptor,\n                                   const Options* options)\n    : SourceGeneratorBase(descriptor->file(), options),\n      descriptor_(descriptor) {\n\n  // sorted field names\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    field_names_.push_back(descriptor_->field(i)->name());\n  }\n  std::sort(field_names_.begin(), field_names_.end());\n\n  // fields by number\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    fields_by_number_.push_back(descriptor_->field(i));\n  }\n  std::sort(fields_by_number_.begin(), fields_by_number_.end(),\n            CompareFieldNumbers);\n}\n\nMessageGenerator::~MessageGenerator() {\n}\n\nstd::string MessageGenerator::class_name() {\n  return descriptor_->name();\n}\n\nstd::string MessageGenerator::full_class_name() {\n  return GetClassName(descriptor_);\n}\n\nconst std::vector<std::string>& MessageGenerator::field_names() {\n  return field_names_;\n}\n\nconst std::vector<const FieldDescriptor*>& MessageGenerator::fields_by_number() {\n  return fields_by_number_;\n}\n\nvoid MessageGenerator::Generate(io::Printer* printer) {\n  map<string, string> vars;\n  vars[\"class_name\"] = class_name();\n  vars[\"access_level\"] = class_access_level();\n\n  WriteMessageDocComment(printer, descriptor_);\n  printer->Print(\n    vars,\n    \"$access_level$ sealed partial class $class_name$ : pb::IMessage<$class_name$> {\\n\");\n  printer->Indent();\n\n  // All static fields and properties\n  printer->Print(\n\t  vars,\n\t  \"private static readonly pb::MessageParser<$class_name$> _parser = new pb::MessageParser<$class_name$>(() => new $class_name$());\\n\");\n\n  WriteGeneratedCodeAttributes(printer);\n  printer->Print(\n\t  vars,\n\t  \"public static pb::MessageParser<$class_name$> Parser { get { return _parser; } }\\n\\n\");\n\n  // Access the message descriptor via the relevant file descriptor or containing message descriptor.\n  if (!descriptor_->containing_type()) {\n    vars[\"descriptor_accessor\"] = GetReflectionClassName(descriptor_->file())\n        + \".Descriptor.MessageTypes[\" + SimpleItoa(descriptor_->index()) + \"]\";\n  } else {\n    vars[\"descriptor_accessor\"] = GetClassName(descriptor_->containing_type())\n        + \".Descriptor.NestedTypes[\" + SimpleItoa(descriptor_->index()) + \"]\";\n  }\n\n  WriteGeneratedCodeAttributes(printer);\n  printer->Print(\n\tvars,\n\t\"public static pbr::MessageDescriptor Descriptor {\\n\"\n\t\"  get { return $descriptor_accessor$; }\\n\"\n\t\"}\\n\"\n\t\"\\n\");\n  WriteGeneratedCodeAttributes(printer);\n  printer->Print(\n\tvars,\n    \"pbr::MessageDescriptor pb::IMessage.Descriptor {\\n\"\n    \"  get { return Descriptor; }\\n\"\n    \"}\\n\"\n    \"\\n\");\n\n  // Parameterless constructor and partial OnConstruction method.\n  WriteGeneratedCodeAttributes(printer);\n  printer->Print(\n    vars,\n    \"public $class_name$() {\\n\"\n    \"  OnConstruction();\\n\"\n    \"}\\n\\n\"\n    \"partial void OnConstruction();\\n\\n\");\n\n  GenerateCloningCode(printer);\n  GenerateFreezingCode(printer);\n\n  // Fields/properties\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* fieldDescriptor = descriptor_->field(i);\n\n    // Rats: we lose the debug comment here :(\n    printer->Print(\n      \"/// <summary>Field number for the \\\"$field_name$\\\" field.</summary>\\n\"\n      \"public const int $field_constant_name$ = $index$;\\n\",\n      \"field_name\", fieldDescriptor->name(),\n      \"field_constant_name\", GetFieldConstantName(fieldDescriptor),\n      \"index\", SimpleItoa(fieldDescriptor->number()));\n    scoped_ptr<FieldGeneratorBase> generator(\n        CreateFieldGeneratorInternal(fieldDescriptor));\n    generator->GenerateMembers(printer);\n    printer->Print(\"\\n\");\n  }\n\n  // oneof properties\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    vars[\"name\"] = UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), false);\n    vars[\"property_name\"] = UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), true);\n    vars[\"original_name\"] = descriptor_->oneof_decl(i)->name();\n    printer->Print(\n      vars,\n      \"private object $name$_;\\n\"\n      \"/// <summary>Enum of possible cases for the \\\"$original_name$\\\" oneof.</summary>\\n\"\n      \"public enum $property_name$OneofCase {\\n\");\n    printer->Indent();\n    printer->Print(\"None = 0,\\n\");\n    for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {\n      const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);\n      printer->Print(\"$field_property_name$ = $index$,\\n\",\n                     \"field_property_name\", GetPropertyName(field),\n                     \"index\", SimpleItoa(field->number()));\n    }\n    printer->Outdent();\n    printer->Print(\"}\\n\");\n    // TODO: Should we put the oneof .proto comments here?\n    // It's unclear exactly where they should go.\n\tprinter->Print(\n\t  vars,\n\t  \"private $property_name$OneofCase $name$Case_ = $property_name$OneofCase.None;\\n\");\n\tWriteGeneratedCodeAttributes(printer);\n\tprinter->Print(\n\t  vars,\n\t  \"public $property_name$OneofCase $property_name$Case {\\n\"\n\t  \"  get { return $name$Case_; }\\n\"\n\t  \"}\\n\\n\");\n\tWriteGeneratedCodeAttributes(printer);\n\tprinter->Print(\n\t  vars,\n      \"public void Clear$property_name$() {\\n\"\n      \"  $name$Case_ = $property_name$OneofCase.None;\\n\"\n      \"  $name$_ = null;\\n\"\n      \"}\\n\\n\");\n  }\n\n  // Standard methods\n  GenerateFrameworkMethods(printer);\n  GenerateMessageSerializationMethods(printer);\n  GenerateMergingMethods(printer);\n\n  // Nested messages and enums\n  if (HasNestedGeneratedTypes()) {\n    printer->Print(\n      vars,\n      \"#region Nested types\\n\"\n      \"/// <summary>Container for nested types declared in the $class_name$ message type.</summary>\\n\");\n    WriteGeneratedCodeAttributes(printer);\n    printer->Print(\"public static partial class Types {\\n\");\n    printer->Indent();\n    for (int i = 0; i < descriptor_->enum_type_count(); i++) {\n      EnumGenerator enumGenerator(descriptor_->enum_type(i), this->options());\n      enumGenerator.Generate(printer);\n    }\n    for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n      // Don't generate nested types for maps...\n      if (!IsMapEntryMessage(descriptor_->nested_type(i))) {\n        MessageGenerator messageGenerator(\n            descriptor_->nested_type(i), this->options());\n        messageGenerator.Generate(printer);\n      }\n    }\n    printer->Outdent();\n    printer->Print(\"}\\n\"\n                   \"#endregion\\n\"\n                   \"\\n\");\n  }\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n  printer->Print(\"\\n\");\n}\n\n// Helper to work out whether we need to generate a class to hold nested types/enums.\n// Only tricky because we don't want to generate map entry types.\nbool MessageGenerator::HasNestedGeneratedTypes()\n{\n  if (descriptor_->enum_type_count() > 0) {\n    return true;\n  }\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    if (!IsMapEntryMessage(descriptor_->nested_type(i))) {\n      return true;\n    }\n  }\n  return false;\n}\n\nvoid MessageGenerator::GenerateCloningCode(io::Printer* printer) {\n  map<string, string> vars;\n  WriteGeneratedCodeAttributes(printer);\n  vars[\"class_name\"] = class_name();\n    printer->Print(\n    vars,\n    \"public $class_name$($class_name$ other) : this() {\\n\");\n  printer->Indent();\n  // Clone non-oneof fields first\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    if (!descriptor_->field(i)->containing_oneof()) {\n      scoped_ptr<FieldGeneratorBase> generator(\n        CreateFieldGeneratorInternal(descriptor_->field(i)));\n      generator->GenerateCloningCode(printer);\n    }\n  }\n  // Clone just the right field for each oneof\n  for (int i = 0; i < descriptor_->oneof_decl_count(); ++i) {\n    vars[\"name\"] = UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), false);\n    vars[\"property_name\"] = UnderscoresToCamelCase(\n        descriptor_->oneof_decl(i)->name(), true);\n    printer->Print(vars, \"switch (other.$property_name$Case) {\\n\");\n    printer->Indent();\n    for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {\n      const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);\n      scoped_ptr<FieldGeneratorBase> generator(CreateFieldGeneratorInternal(field));\n      vars[\"field_property_name\"] = GetPropertyName(field);\n      printer->Print(\n          vars,\n          \"case $property_name$OneofCase.$field_property_name$:\\n\");\n      printer->Indent();\n      generator->GenerateCloningCode(printer);\n      printer->Print(\"break;\\n\");\n      printer->Outdent();\n    }\n    printer->Outdent();\n    printer->Print(\"}\\n\\n\");\n  }\n\n  printer->Outdent();\n  printer->Print(\"}\\n\\n\");\n\n  WriteGeneratedCodeAttributes(printer);\n  printer->Print(\n    vars,\n    \"public $class_name$ Clone() {\\n\"\n    \"  return new $class_name$(this);\\n\"\n    \"}\\n\\n\");\n}\n\nvoid MessageGenerator::GenerateFreezingCode(io::Printer* printer) {\n}\n\nvoid MessageGenerator::GenerateFrameworkMethods(io::Printer* printer) {\n    map<string, string> vars;\n    vars[\"class_name\"] = class_name();\n\n    // Equality\n\tWriteGeneratedCodeAttributes(printer);\n    printer->Print(\n        vars,\n        \"public override bool Equals(object other) {\\n\"\n        \"  return Equals(other as $class_name$);\\n\"\n        \"}\\n\\n\");\n\tWriteGeneratedCodeAttributes(printer);\n\tprinter->Print(\n\t    vars,\n        \"public bool Equals($class_name$ other) {\\n\"\n        \"  if (ReferenceEquals(other, null)) {\\n\"\n        \"    return false;\\n\"\n        \"  }\\n\"\n        \"  if (ReferenceEquals(other, this)) {\\n\"\n        \"    return true;\\n\"\n        \"  }\\n\");\n    printer->Indent();\n    for (int i = 0; i < descriptor_->field_count(); i++) {\n        scoped_ptr<FieldGeneratorBase> generator(\n            CreateFieldGeneratorInternal(descriptor_->field(i)));\n        generator->WriteEquals(printer);\n    }\n    for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n        printer->Print(\"if ($property_name$Case != other.$property_name$Case) return false;\\n\",\n            \"property_name\", UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), true));\n    }\n    printer->Outdent();\n    printer->Print(\n        \"  return true;\\n\"\n        \"}\\n\\n\");\n\n    // GetHashCode\n    // Start with a non-zero value to easily distinguish between null and \"empty\" messages.\n\tWriteGeneratedCodeAttributes(printer);\n\tprinter->Print(\n        \"public override int GetHashCode() {\\n\"\n        \"  int hash = 1;\\n\");\n    printer->Indent();\n    for (int i = 0; i < descriptor_->field_count(); i++) {\n        scoped_ptr<FieldGeneratorBase> generator(\n            CreateFieldGeneratorInternal(descriptor_->field(i)));\n        generator->WriteHash(printer);\n    }\n    for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n        printer->Print(\"hash ^= (int) $name$Case_;\\n\",\n            \"name\", UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), false));\n    }\n    printer->Print(\"return hash;\\n\");\n    printer->Outdent();\n    printer->Print(\"}\\n\\n\");\n\n\tWriteGeneratedCodeAttributes(printer);\n\tprinter->Print(\n        \"public override string ToString() {\\n\"\n        \"  return pb::JsonFormatter.ToDiagnosticString(this);\\n\"\n        \"}\\n\\n\");\n}\n\nvoid MessageGenerator::GenerateMessageSerializationMethods(io::Printer* printer) {\n  WriteGeneratedCodeAttributes(printer);\n  printer->Print(\n      \"public void WriteTo(pb::CodedOutputStream output) {\\n\");\n  printer->Indent();\n\n  // Serialize all the fields\n  for (int i = 0; i < fields_by_number().size(); i++) {\n    scoped_ptr<FieldGeneratorBase> generator(\n      CreateFieldGeneratorInternal(fields_by_number()[i]));\n    generator->GenerateSerializationCode(printer);\n  }\n\n  // TODO(jonskeet): Memoize size of frozen messages?\n  printer->Outdent();\n  printer->Print(\n\t\"}\\n\"\n\t\"\\n\");\n  WriteGeneratedCodeAttributes(printer);\n  printer->Print(\n    \"public int CalculateSize() {\\n\");\n  printer->Indent();\n  printer->Print(\"int size = 0;\\n\");\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    scoped_ptr<FieldGeneratorBase> generator(\n        CreateFieldGeneratorInternal(descriptor_->field(i)));\n    generator->GenerateSerializedSizeCode(printer);\n  }\n  printer->Print(\"return size;\\n\");\n  printer->Outdent();\n  printer->Print(\"}\\n\\n\");\n}\n\nvoid MessageGenerator::GenerateMergingMethods(io::Printer* printer) {\n  // Note:  These are separate from GenerateMessageSerializationMethods()\n  //   because they need to be generated even for messages that are optimized\n  //   for code size.\n  map<string, string> vars;\n  vars[\"class_name\"] = class_name();\n\n  WriteGeneratedCodeAttributes(printer);\n  printer->Print(\n    vars,\n    \"public void MergeFrom($class_name$ other) {\\n\");\n  printer->Indent();\n  printer->Print(\n    \"if (other == null) {\\n\"\n    \"  return;\\n\"\n    \"}\\n\");\n  // Merge non-oneof fields\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    if (!descriptor_->field(i)->containing_oneof()) {      \n      scoped_ptr<FieldGeneratorBase> generator(\n          CreateFieldGeneratorInternal(descriptor_->field(i)));\n      generator->GenerateMergingCode(printer);\n    }\n  }\n  // Merge oneof fields\n  for (int i = 0; i < descriptor_->oneof_decl_count(); ++i) {\n    vars[\"name\"] = UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), false);\n    vars[\"property_name\"] = UnderscoresToCamelCase(descriptor_->oneof_decl(i)->name(), true);\n    printer->Print(vars, \"switch (other.$property_name$Case) {\\n\");\n    printer->Indent();\n    for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {\n      const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);\n      vars[\"field_property_name\"] = GetPropertyName(field);\n      printer->Print(\n        vars,\n        \"case $property_name$OneofCase.$field_property_name$:\\n\"\n        \"  $field_property_name$ = other.$field_property_name$;\\n\"\n        \"  break;\\n\");\n    }\n    printer->Outdent();\n    printer->Print(\"}\\n\\n\");\n  }\n  printer->Outdent();\n  printer->Print(\"}\\n\\n\");\n  WriteGeneratedCodeAttributes(printer);\n  printer->Print(\"public void MergeFrom(pb::CodedInputStream input) {\\n\");\n  printer->Indent();\n  printer->Print(\n    \"uint tag;\\n\"\n    \"while ((tag = input.ReadTag()) != 0) {\\n\"\n    \"  switch(tag) {\\n\");\n  printer->Indent();\n  printer->Indent();\n  printer->Print(\n    \"default:\\n\"\n    \"  input.SkipLastField();\\n\" // We're not storing the data, but we still need to consume it.\n    \"  break;\\n\");\n  for (int i = 0; i < fields_by_number().size(); i++) {\n    const FieldDescriptor* field = fields_by_number()[i];\n    internal::WireFormatLite::WireType wt =\n        internal::WireFormat::WireTypeForFieldType(field->type());\n    uint32 tag = internal::WireFormatLite::MakeTag(field->number(), wt);\n    // Handle both packed and unpacked repeated fields with the same Read*Array call;\n    // the two generated cases are the packed and unpacked tags.\n    // TODO(jonskeet): Check that is_packable is equivalent to\n    // is_repeated && wt in { VARINT, FIXED32, FIXED64 }.\n    // It looks like it is...\n    if (field->is_packable()) {\n      printer->Print(\n        \"case $packed_tag$:\\n\",\n        \"packed_tag\",\n        SimpleItoa(\n            internal::WireFormatLite::MakeTag(\n                field->number(),\n                internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED)));\n    }\n\n    printer->Print(\"case $tag$: {\\n\", \"tag\", SimpleItoa(tag));\n    printer->Indent();\n    scoped_ptr<FieldGeneratorBase> generator(\n        CreateFieldGeneratorInternal(field));\n    generator->GenerateParsingCode(printer);\n    printer->Print(\"break;\\n\");\n    printer->Outdent();\n    printer->Print(\"}\\n\");\n  }\n  printer->Outdent();\n  printer->Print(\"}\\n\"); // switch\n  printer->Outdent();\n  printer->Print(\"}\\n\"); // while\n  printer->Outdent();\n  printer->Print(\"}\\n\\n\"); // method\n}\n\nint MessageGenerator::GetFieldOrdinal(const FieldDescriptor* descriptor) {\n  for (int i = 0; i < field_names().size(); i++) {\n    if (field_names()[i] == descriptor->name()) {\n      return i;\n    }\n  }\n  GOOGLE_LOG(DFATAL)<< \"Could not find ordinal for field \" << descriptor->name();\n  return -1;\n}\n\nFieldGeneratorBase* MessageGenerator::CreateFieldGeneratorInternal(\n    const FieldDescriptor* descriptor) {\n  return CreateFieldGenerator(descriptor, GetFieldOrdinal(descriptor), this->options());\n}\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_message.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_MESSAGE_H__\n#define GOOGLE_PROTOBUF_COMPILER_CSHARP_MESSAGE_H__\n\n#include <string>\n#include <vector>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/csharp/csharp_source_generator_base.h>\n#include <google/protobuf/compiler/csharp/csharp_helpers.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nclass FieldGeneratorBase;\n\nclass MessageGenerator : public SourceGeneratorBase {\n public:\n  MessageGenerator(const Descriptor* descriptor, const Options* options);\n  ~MessageGenerator();\n\n  void GenerateCloningCode(io::Printer* printer);\n  void GenerateFreezingCode(io::Printer* printer);\n  void GenerateFrameworkMethods(io::Printer* printer);\n  void Generate(io::Printer* printer);\n\n private:\n  const Descriptor* descriptor_;\n  std::vector<std::string> field_names_;\n  std::vector<const FieldDescriptor*> fields_by_number_;\n\n  void GenerateMessageSerializationMethods(io::Printer* printer);\n  void GenerateMergingMethods(io::Printer* printer);\n\n  int GetFieldOrdinal(const FieldDescriptor* descriptor);\n  FieldGeneratorBase* CreateFieldGeneratorInternal(\n      const FieldDescriptor* descriptor);\n\n  bool HasNestedGeneratedTypes();\n\n  std::string class_name();\n  std::string full_class_name();\n\n  // field names sorted alphabetically\n  const std::vector<std::string>& field_names();\n\n  // field descriptors sorted by number\n  const std::vector<const FieldDescriptor*>& fields_by_number();\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);\n};\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMPILER_CSHARP_MESSAGE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_message_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <sstream>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/plugin.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/stubs/strutil.h>\n\n#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>\n#include <google/protobuf/compiler/csharp/csharp_helpers.h>\n#include <google/protobuf/compiler/csharp/csharp_message_field.h>\n#include <google/protobuf/compiler/csharp/csharp_options.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nMessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor,\n                                             int fieldOrdinal,\n                                             const Options *options)\n    : FieldGeneratorBase(descriptor, fieldOrdinal, options) {\n  variables_[\"has_property_check\"] = name() + \"_ != null\";\n  variables_[\"has_not_property_check\"] = name() + \"_ == null\";\n}\n\nMessageFieldGenerator::~MessageFieldGenerator() {\n\n}\n\nvoid MessageFieldGenerator::GenerateMembers(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"private $type_name$ $name$_;\\n\");\n  WritePropertyDocComment(printer, descriptor_);\n  AddPublicMemberAttributes(printer);\n  printer->Print(\n    variables_,\n    \"$access_level$ $type_name$ $property_name$ {\\n\"\n    \"  get { return $name$_; }\\n\"\n    \"  set {\\n\"\n    \"    $name$_ = value;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n}\n\nvoid MessageFieldGenerator::GenerateMergingCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if (other.$has_property_check$) {\\n\"\n    \"  if ($has_not_property_check$) {\\n\"\n    \"    $name$_ = new $type_name$();\\n\"\n    \"  }\\n\"\n    \"  $property_name$.MergeFrom(other.$property_name$);\\n\"\n    \"}\\n\");\n}\n\nvoid MessageFieldGenerator::GenerateParsingCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if ($has_not_property_check$) {\\n\"\n    \"  $name$_ = new $type_name$();\\n\"\n    \"}\\n\"\n    // TODO(jonskeet): Do we really need merging behaviour like this?\n    \"input.ReadMessage($name$_);\\n\"); // No need to support TYPE_GROUP...\n}\n\nvoid MessageFieldGenerator::GenerateSerializationCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if ($has_property_check$) {\\n\"\n    \"  output.WriteRawTag($tag_bytes$);\\n\"\n    \"  output.WriteMessage($property_name$);\\n\"\n    \"}\\n\");\n}\n\nvoid MessageFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if ($has_property_check$) {\\n\"\n    \"  size += $tag_size$ + pb::CodedOutputStream.ComputeMessageSize($property_name$);\\n\"\n    \"}\\n\");\n}\n\nvoid MessageFieldGenerator::WriteHash(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if ($has_property_check$) hash ^= $property_name$.GetHashCode();\\n\");\n}\nvoid MessageFieldGenerator::WriteEquals(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if (!object.Equals($property_name$, other.$property_name$)) return false;\\n\");\n}\nvoid MessageFieldGenerator::WriteToString(io::Printer* printer) {\n  variables_[\"field_name\"] = GetFieldName(descriptor_);\n  printer->Print(\n    variables_,\n    \"PrintField(\\\"$field_name$\\\", has$property_name$, $name$_, writer);\\n\");\n}\n\nvoid MessageFieldGenerator::GenerateCloningCode(io::Printer* printer) {\n  printer->Print(variables_,\n    \"$property_name$ = other.$has_property_check$ ? other.$property_name$.Clone() : null;\\n\");\n}\n\nvoid MessageFieldGenerator::GenerateFreezingCode(io::Printer* printer) {\n}\n\nvoid MessageFieldGenerator::GenerateCodecCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"pb::FieldCodec.ForMessage($tag$, $type_name$.Parser)\");\n}\n\nMessageOneofFieldGenerator::MessageOneofFieldGenerator(\n    const FieldDescriptor* descriptor,\n\t  int fieldOrdinal,\n    const Options *options)\n    : MessageFieldGenerator(descriptor, fieldOrdinal, options) {\n  SetCommonOneofFieldVariables(&variables_);\n}\n\nMessageOneofFieldGenerator::~MessageOneofFieldGenerator() {\n\n}\n\nvoid MessageOneofFieldGenerator::GenerateMembers(io::Printer* printer) {\n  WritePropertyDocComment(printer, descriptor_);\n  AddPublicMemberAttributes(printer);\n  printer->Print(\n    variables_,\n    \"$access_level$ $type_name$ $property_name$ {\\n\"\n    \"  get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : null; }\\n\"\n    \"  set {\\n\"\n    \"    $oneof_name$_ = value;\\n\"\n    \"    $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$property_name$;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n}\n\nvoid MessageOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) {\n  // TODO(jonskeet): We may be able to do better than this\n  printer->Print(\n    variables_,\n    \"$type_name$ subBuilder = new $type_name$();\\n\"\n    \"if ($has_property_check$) {\\n\"\n    \"  subBuilder.MergeFrom($property_name$);\\n\"\n    \"}\\n\"\n    \"input.ReadMessage(subBuilder);\\n\" // No support of TYPE_GROUP\n    \"$property_name$ = subBuilder;\\n\");\n}\n\nvoid MessageOneofFieldGenerator::WriteToString(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"PrintField(\\\"$descriptor_name$\\\", $has_property_check$, $oneof_name$_, writer);\\n\");\n}\n\nvoid MessageOneofFieldGenerator::GenerateCloningCode(io::Printer* printer) {\n  printer->Print(variables_,\n    \"$property_name$ = other.$property_name$.Clone();\\n\");\n}\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_message_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_MESSAGE_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_CSHARP_MESSAGE_FIELD_H__\n\n#include <string>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/csharp/csharp_field_base.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nclass MessageFieldGenerator : public FieldGeneratorBase {\n public:\n  MessageFieldGenerator(const FieldDescriptor* descriptor,\n                        int fieldOrdinal,\n                        const Options *options);\n  ~MessageFieldGenerator();\n\n  virtual void GenerateCodecCode(io::Printer* printer);\n  virtual void GenerateCloningCode(io::Printer* printer);\n  virtual void GenerateFreezingCode(io::Printer* printer);\n  virtual void GenerateMembers(io::Printer* printer);\n  virtual void GenerateMergingCode(io::Printer* printer);\n  virtual void GenerateParsingCode(io::Printer* printer);\n  virtual void GenerateSerializationCode(io::Printer* printer);\n  virtual void GenerateSerializedSizeCode(io::Printer* printer);\n\n  virtual void WriteHash(io::Printer* printer);\n  virtual void WriteEquals(io::Printer* printer);\n  virtual void WriteToString(io::Printer* printer);\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator);\n};\n\nclass MessageOneofFieldGenerator : public MessageFieldGenerator {\n public:\n  MessageOneofFieldGenerator(const FieldDescriptor* descriptor,\n                             int fieldOrdinal,\n                             const Options *options);\n  ~MessageOneofFieldGenerator();\n\n  virtual void GenerateCloningCode(io::Printer* printer);\n  virtual void GenerateMembers(io::Printer* printer);\n  virtual void WriteToString(io::Printer* printer);\n  virtual void GenerateParsingCode(io::Printer* printer);\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageOneofFieldGenerator);\n};\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMPILER_CSHARP_MESSAGE_FIELD_H__\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_names.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Provides a mechanism for mapping a descriptor to the\n// fully-qualified name of the corresponding C# class.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__\n#define GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__\n\n#include <string>\n\nnamespace google {\nnamespace protobuf {\n\nclass Descriptor;\nclass EnumDescriptor;\nclass FileDescriptor;\nclass ServiceDescriptor;\n\nnamespace compiler {\nnamespace csharp {\n\n// Requires:\n//   descriptor != NULL\n//\n// Returns:\n//   The namespace to use for given file descriptor.\nstring GetFileNamespace(const FileDescriptor* descriptor);\n\n// Requires:\n//   descriptor != NULL\n//\n// Returns:\n//   The fully-qualified C# class name.\nstring GetClassName(const Descriptor* descriptor);\n\n// Requires:\n//   descriptor != NULL\n//\n// Returns:\n//   The fully-qualified name of the C# class that provides\n//   access to the file descriptor. Proto compiler generates\n//   such class for each .proto file processed.\nstring GetReflectionClassName(const FileDescriptor* descriptor);\n\n// Generates output file name for given file descriptor. If generate_directories\n// is true, the output file will be put under directory corresponding to file's\n// namespace. base_namespace can be used to strip some of the top level\n// directories. E.g. for file with namespace \"Bar.Foo\" and base_namespace=\"Bar\",\n// the resulting file will be put under directory \"Foo\" (and not \"Bar/Foo\").\n//\n// Requires:\n//   descriptor != NULL\n//   error != NULL\n//\n//  Returns:\n//    The file name to use as output file for given file descriptor. In case\n//    of failure, this function will return empty string and error parameter\n//    will contain the error message.\nstring GetOutputFile(\n    const google::protobuf::FileDescriptor* descriptor,\n    const string file_extension,\n    const bool generate_directories,\n    const string base_namespace,\n    string* error);\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMPILER_CSHARP_NAMES_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_options.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_OPTIONS_H__\n#define GOOGLE_PROTOBUF_COMPILER_CSHARP_OPTIONS_H__\n\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\n// Generator options (used by csharp_generator.cc):\nstruct Options {\n  Options() :\n      file_extension(\".cs\"),\n      base_namespace(\"\"),\n      base_namespace_specified(false),\n      internal_access(false),\n      legacy_enum_values(false) {\n  }\n  // Extension of the generated file. Defaults to \".cs\"\n  string file_extension;\n  // Base namespace to use to create directory hierarchy. Defaults to \"\".\n  // This option allows the simple creation of a conventional C# file layout,\n  // where directories are created relative to a project-specific base\n  // namespace. For example, in a project with a base namespace of PetShop, a\n  // proto of user.proto with a C# namespace of PetShop.Model.Shared would\n  // generate Model/Shared/User.cs underneath the specified --csharp_out\n  // directory.\n  //\n  // If no base namespace is specified, all files are generated in the\n  // --csharp_out directory, with no subdirectories created automatically.\n  string base_namespace;\n  // Whether the base namespace has been explicitly specified by the user.\n  // This is required as the base namespace can be explicitly set to the empty\n  // string, meaning \"create a full directory hierarchy, starting from the first\n  // segment of the namespace.\"\n  bool base_namespace_specified;\n  // Whether the generated classes should have accessibility level of \"internal\".\n  // Defaults to false that generates \"public\" classes.\n  bool internal_access;\n  // By default, C# codegen now uses PascalCased enum values names, after\n  // removing the enum type name as a prefix (if it *is* a prefix of the value).\n  // Setting this option reverts to the previous behavior of just copying the\n  // value name specified in the .proto file, allowing gradual migration.\n  // This option will be removed before final release.\n  bool legacy_enum_values;\n};\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_CSHARP_OPTIONS_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <sstream>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/plugin.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/stubs/strutil.h>\n\n#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>\n#include <google/protobuf/compiler/csharp/csharp_helpers.h>\n#include <google/protobuf/compiler/csharp/csharp_options.h>\n#include <google/protobuf/compiler/csharp/csharp_primitive_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nPrimitiveFieldGenerator::PrimitiveFieldGenerator(\n    const FieldDescriptor* descriptor, int fieldOrdinal, const Options *options)\n    : FieldGeneratorBase(descriptor, fieldOrdinal, options) {\n  // TODO(jonskeet): Make this cleaner...\n  is_value_type = descriptor->type() != FieldDescriptor::TYPE_STRING\n      && descriptor->type() != FieldDescriptor::TYPE_BYTES;\n  if (!is_value_type) {\n    variables_[\"has_property_check\"] = variables_[\"property_name\"] + \".Length != 0\";\n    variables_[\"other_has_property_check\"] = \"other.\" + variables_[\"property_name\"] + \".Length != 0\";\n  }\n}\n\nPrimitiveFieldGenerator::~PrimitiveFieldGenerator() {\n}\n\nvoid PrimitiveFieldGenerator::GenerateMembers(io::Printer* printer) {\n  // TODO(jonskeet): Work out whether we want to prevent the fields from ever being\n  // null, or whether we just handle it, in the cases of bytes and string.\n  // (Basically, should null-handling code be in the getter or the setter?)\n  printer->Print(\n    variables_,\n    \"private $type_name$ $name_def_message$;\\n\");\n  WritePropertyDocComment(printer, descriptor_);\n  AddPublicMemberAttributes(printer);\n  printer->Print(\n    variables_,\n    \"$access_level$ $type_name$ $property_name$ {\\n\"\n    \"  get { return $name$_; }\\n\"\n    \"  set {\\n\");\n  if (is_value_type) {\n    printer->Print(\n      variables_,\n      \"    $name$_ = value;\\n\");\n  } else {\n    printer->Print(\n      variables_,\n      \"    $name$_ = pb::ProtoPreconditions.CheckNotNull(value, \\\"value\\\");\\n\");\n  }\n  printer->Print(\n    \"  }\\n\"\n    \"}\\n\");\n}\n\nvoid PrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if ($other_has_property_check$) {\\n\"\n    \"  $property_name$ = other.$property_name$;\\n\"\n    \"}\\n\");\n}\n\nvoid PrimitiveFieldGenerator::GenerateParsingCode(io::Printer* printer) {\n  // Note: invoke the property setter rather than writing straight to the field,\n  // so that we can normalize \"null to empty\" for strings and bytes.\n  printer->Print(\n    variables_,\n    \"$property_name$ = input.Read$capitalized_type_name$();\\n\");\n}\n\nvoid PrimitiveFieldGenerator::GenerateSerializationCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if ($has_property_check$) {\\n\"\n    \"  output.WriteRawTag($tag_bytes$);\\n\"\n    \"  output.Write$capitalized_type_name$($property_name$);\\n\"\n    \"}\\n\");\n}\n\nvoid PrimitiveFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if ($has_property_check$) {\\n\");\n  printer->Indent();\n  int fixedSize = GetFixedSize(descriptor_->type());\n  if (fixedSize == -1) {\n    printer->Print(\n      variables_,\n      \"size += $tag_size$ + pb::CodedOutputStream.Compute$capitalized_type_name$Size($property_name$);\\n\");\n  } else {\n    printer->Print(\n      \"size += $tag_size$ + $fixed_size$;\\n\",\n      \"fixed_size\", SimpleItoa(fixedSize),\n      \"tag_size\", variables_[\"tag_size\"]);\n  }\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid PrimitiveFieldGenerator::WriteHash(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if ($has_property_check$) hash ^= $property_name$.GetHashCode();\\n\");\n}\nvoid PrimitiveFieldGenerator::WriteEquals(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if ($property_name$ != other.$property_name$) return false;\\n\");\n}\nvoid PrimitiveFieldGenerator::WriteToString(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"PrintField(\\\"$descriptor_name$\\\", $has_property_check$, $property_name$, writer);\\n\");\n}\n\nvoid PrimitiveFieldGenerator::GenerateCloningCode(io::Printer* printer) {\n  printer->Print(variables_,\n    \"$name$_ = other.$name$_;\\n\");\n}\n\nvoid PrimitiveFieldGenerator::GenerateCodecCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"pb::FieldCodec.For$capitalized_type_name$($tag$)\");\n}\n\nPrimitiveOneofFieldGenerator::PrimitiveOneofFieldGenerator(\n    const FieldDescriptor* descriptor, int fieldOrdinal, const Options *options)\n    : PrimitiveFieldGenerator(descriptor, fieldOrdinal, options) {\n  SetCommonOneofFieldVariables(&variables_);\n}\n\nPrimitiveOneofFieldGenerator::~PrimitiveOneofFieldGenerator() {\n}\n\nvoid PrimitiveOneofFieldGenerator::GenerateMembers(io::Printer* printer) {\n  WritePropertyDocComment(printer, descriptor_);\n  AddPublicMemberAttributes(printer);\n  printer->Print(\n    variables_,\n    \"$access_level$ $type_name$ $property_name$ {\\n\"\n    \"  get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : $default_value$; }\\n\"\n    \"  set {\\n\");\n    if (is_value_type) {\n      printer->Print(\n        variables_,\n        \"    $oneof_name$_ = value;\\n\");\n    } else {\n      printer->Print(\n        variables_,\n        \"    $oneof_name$_ = pb::ProtoPreconditions.CheckNotNull(value, \\\"value\\\");\\n\");\n    }\n    printer->Print(\n      variables_,\n      \"    $oneof_name$Case_ = $oneof_property_name$OneofCase.$property_name$;\\n\"\n      \"  }\\n\"\n      \"}\\n\");\n}\n\nvoid PrimitiveOneofFieldGenerator::WriteToString(io::Printer* printer) {\n  printer->Print(variables_,\n    \"PrintField(\\\"$descriptor_name$\\\", $has_property_check$, $oneof_name$_, writer);\\n\");\n}\n\nvoid PrimitiveOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) {\n    printer->Print(\n      variables_,\n      \"$property_name$ = input.Read$capitalized_type_name$();\\n\");\n}\n\nvoid PrimitiveOneofFieldGenerator::GenerateCloningCode(io::Printer* printer) {\n  printer->Print(variables_,\n    \"$property_name$ = other.$property_name$;\\n\");\n}\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_primitive_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_PRIMITIVE_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_CSHARP_PRIMITIVE_FIELD_H__\n\n#include <string>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/csharp/csharp_field_base.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nstruct Options;\n\nclass PrimitiveFieldGenerator : public FieldGeneratorBase {\n public:\n  PrimitiveFieldGenerator(const FieldDescriptor* descriptor,\n                          int fieldOrdinal,\n                          const Options *options);\n  ~PrimitiveFieldGenerator();\n\n  virtual void GenerateCodecCode(io::Printer* printer);\n  virtual void GenerateCloningCode(io::Printer* printer);\n  virtual void GenerateMembers(io::Printer* printer);\n  virtual void GenerateMergingCode(io::Printer* printer);\n  virtual void GenerateParsingCode(io::Printer* printer);\n  virtual void GenerateSerializationCode(io::Printer* printer);\n  virtual void GenerateSerializedSizeCode(io::Printer* printer);\n\n  virtual void WriteHash(io::Printer* printer);\n  virtual void WriteEquals(io::Printer* printer);\n  virtual void WriteToString(io::Printer* printer);\n\n protected:\n  bool is_value_type;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator);\n};\n\nclass PrimitiveOneofFieldGenerator : public PrimitiveFieldGenerator {\n public:\n  PrimitiveOneofFieldGenerator(const FieldDescriptor* descriptor,\n                               int fieldOrdinal,\n                               const Options *options);\n  ~PrimitiveOneofFieldGenerator();\n\n  virtual void GenerateCloningCode(io::Printer* printer);\n  virtual void GenerateMembers(io::Printer* printer);\n  virtual void WriteToString(io::Printer* printer);\n  virtual void GenerateParsingCode(io::Printer* printer);\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveOneofFieldGenerator);\n};\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMPILER_CSHARP_PRIMITIVE_FIELD_H__\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <sstream>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/plugin.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/stubs/strutil.h>\n\n\n#include <google/protobuf/compiler/csharp/csharp_enum.h>\n#include <google/protobuf/compiler/csharp/csharp_helpers.h>\n#include <google/protobuf/compiler/csharp/csharp_message.h>\n#include <google/protobuf/compiler/csharp/csharp_names.h>\n#include <google/protobuf/compiler/csharp/csharp_options.h>\n#include <google/protobuf/compiler/csharp/csharp_reflection_class.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nReflectionClassGenerator::ReflectionClassGenerator(const FileDescriptor* file,\n                                                   const Options* options)\n    : SourceGeneratorBase(file, options),\n      file_(file) {\n  namespace_ = GetFileNamespace(file);\n  reflectionClassname_ = GetReflectionClassUnqualifiedName(file);\n}\n\nReflectionClassGenerator::~ReflectionClassGenerator() {\n}\n\nvoid ReflectionClassGenerator::Generate(io::Printer* printer) {\n  WriteIntroduction(printer);\n\n  WriteDescriptor(printer);\n  // Close the class declaration.\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n\n  // write children: Enums\n  if (file_->enum_type_count() > 0) {\n    printer->Print(\"#region Enums\\n\");\n    for (int i = 0; i < file_->enum_type_count(); i++) {\n      EnumGenerator enumGenerator(file_->enum_type(i), this->options());\n      enumGenerator.Generate(printer);\n    }\n    printer->Print(\"#endregion\\n\");\n    printer->Print(\"\\n\");\n  }\n\n  // write children: Messages\n  if (file_->message_type_count() > 0) {\n    printer->Print(\"#region Messages\\n\");\n    for (int i = 0; i < file_->message_type_count(); i++) {\n      MessageGenerator messageGenerator(file_->message_type(i), this->options());\n      messageGenerator.Generate(printer);\n    }\n    printer->Print(\"#endregion\\n\");\n    printer->Print(\"\\n\");\n  }\n\n  // TODO(jtattermusch): add insertion point for services.\n\n  if (!namespace_.empty()) {\n    printer->Outdent();\n    printer->Print(\"}\\n\");\n  }\n  printer->Print(\"\\n\");\n  printer->Print(\"#endregion Designer generated code\\n\");\n}\n\nvoid ReflectionClassGenerator::WriteIntroduction(io::Printer* printer) {\n  printer->Print(\n    \"// Generated by the protocol buffer compiler.  DO NOT EDIT!\\n\"\n    \"// source: $file_name$\\n\"\n    \"#pragma warning disable 1591, 0612, 3021\\n\"\n    \"#region Designer generated code\\n\"\n    \"\\n\"\n    \"using pb = global::Google.Protobuf;\\n\"\n    \"using pbc = global::Google.Protobuf.Collections;\\n\"\n    \"using pbr = global::Google.Protobuf.Reflection;\\n\"\n    \"using scg = global::System.Collections.Generic;\\n\",\n    \"file_name\", file_->name());\n\n  if (!namespace_.empty()) {\n    printer->Print(\"namespace $namespace$ {\\n\", \"namespace\", namespace_);\n    printer->Indent();\n    printer->Print(\"\\n\");\n  }\n\n  printer->Print(\n    \"/// <summary>Holder for reflection information generated from $file_name$</summary>\\n\"\n    \"$access_level$ static partial class $reflection_class_name$ {\\n\"\n    \"\\n\",\n    \"file_name\", file_->name(),\n    \"access_level\", class_access_level(),\n    \"reflection_class_name\", reflectionClassname_);\n  printer->Indent();\n}\n\nvoid ReflectionClassGenerator::WriteDescriptor(io::Printer* printer) {\n  printer->Print(\n    \"#region Descriptor\\n\"\n    \"/// <summary>File descriptor for $file_name$</summary>\\n\"\n    \"public static pbr::FileDescriptor Descriptor {\\n\"\n    \"  get { return descriptor; }\\n\"\n    \"}\\n\"\n    \"private static pbr::FileDescriptor descriptor;\\n\"\n    \"\\n\"\n    \"static $reflection_class_name$() {\\n\",\n    \"file_name\", file_->name(),\n    \"reflection_class_name\", reflectionClassname_);\n  printer->Indent();\n  printer->Print(\n    \"byte[] descriptorData = global::System.Convert.FromBase64String(\\n\");\n  printer->Indent();\n  printer->Indent();\n  printer->Print(\"string.Concat(\\n\");\n  printer->Indent();\n\n  // TODO(jonskeet): Consider a C#-escaping format here instead of just Base64.\n  std::string base64 = FileDescriptorToBase64(file_);\n  while (base64.size() > 60) {\n    printer->Print(\"\\\"$base64$\\\",\\n\", \"base64\", base64.substr(0, 60));\n    base64 = base64.substr(60);\n  }\n  printer->Print(\"\\\"$base64$\\\"));\\n\", \"base64\", base64);\n  printer->Outdent();\n  printer->Outdent();\n  printer->Outdent();\n\n  // -----------------------------------------------------------------\n  // Invoke InternalBuildGeneratedFileFrom() to build the file.\n  printer->Print(\n      \"descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,\\n\");\n  printer->Print(\"    new pbr::FileDescriptor[] { \");\n  for (int i = 0; i < file_->dependency_count(); i++) {\n    // descriptor.proto is special: we don't allow access to the generated code, but there's\n    // a separately-exposed property to get at the file descriptor, specifically to allow this\n    // kind of dependency.\n    if (IsDescriptorProto(file_->dependency(i))) {\n      printer->Print(\"pbr::FileDescriptor.DescriptorProtoFileDescriptor, \");\n    } else {\n      printer->Print(\n      \"$full_reflection_class_name$.Descriptor, \",\n      \"full_reflection_class_name\",\n      GetReflectionClassName(file_->dependency(i)));\n    }\n  }\n  printer->Print(\"},\\n\"\n      \"    new pbr::GeneratedClrTypeInfo(\");\n  // Specify all the generated code information, recursively.\n  if (file_->enum_type_count() > 0) {\n      printer->Print(\"new[] {\");\n      for (int i = 0; i < file_->enum_type_count(); i++) {\n          printer->Print(\"typeof($type_name$), \", \"type_name\", GetClassName(file_->enum_type(i)));\n      }\n      printer->Print(\"}, \");\n  }\n  else {\n      printer->Print(\"null, \");\n  }\n  if (file_->message_type_count() > 0) {\n      printer->Print(\"new pbr::GeneratedClrTypeInfo[] {\\n\");\n      printer->Indent();\n      printer->Indent();\n      printer->Indent();\n      for (int i = 0; i < file_->message_type_count(); i++) {\n          WriteGeneratedCodeInfo(file_->message_type(i), printer, i == file_->message_type_count() - 1);\n      }\n      printer->Outdent();\n      printer->Print(\"\\n}));\\n\");\n      printer->Outdent();\n      printer->Outdent();\n  }\n  else {\n      printer->Print(\"null));\\n\");\n  }\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n  printer->Print(\"#endregion\\n\\n\");\n}\n\n// Write out the generated code for a particular message. This consists of the CLR type, property names\n// corresponding to fields, names corresponding to oneofs, nested enums, and nested types. Each array part\n// can be specified as null if it would be empty, to make the generated code somewhat simpler to read.\n// We write a line break at the end of each generated code info, so that in the final file we'll see all\n// the types, pre-ordered depth first, one per line. The indentation will be slightly unusual,\n// in that it will look like a single array when it's actually constructing a tree, but it'll be easy to\n// read even with multiple levels of nesting.\n// The \"last\" parameter indicates whether this message descriptor is the last one being printed in this immediate\n// context. It governs whether or not a trailing comma and newline is written after the constructor, effectively\n// just controlling the formatting in the generated code.\nvoid ReflectionClassGenerator::WriteGeneratedCodeInfo(const Descriptor* descriptor, io::Printer* printer, bool last) {\n  if (IsMapEntryMessage(descriptor)) {\n    printer->Print(\"null, \");\n    return;\n  }\n  // Generated message type\n  printer->Print(\"new pbr::GeneratedClrTypeInfo(typeof($type_name$), $type_name$.Parser, \", \"type_name\", GetClassName(descriptor));\n  \n  // Fields\n  if (descriptor->field_count() > 0) {\n      std::vector<std::string> fields;\n      for (int i = 0; i < descriptor->field_count(); i++) {\n          fields.push_back(GetPropertyName(descriptor->field(i)));\n      }\n      printer->Print(\"new[]{ \\\"$fields$\\\" }, \", \"fields\", JoinStrings(fields, \"\\\", \\\"\"));\n  }\n  else {\n      printer->Print(\"null, \");\n  }\n\n  // Oneofs\n  if (descriptor->oneof_decl_count() > 0) {\n      std::vector<std::string> oneofs;\n      for (int i = 0; i < descriptor->oneof_decl_count(); i++) {\n          oneofs.push_back(UnderscoresToCamelCase(descriptor->oneof_decl(i)->name(), true));\n      }\n      printer->Print(\"new[]{ \\\"$oneofs$\\\" }, \", \"oneofs\", JoinStrings(oneofs, \"\\\", \\\"\"));\n  }\n  else {\n      printer->Print(\"null, \");\n  }\n\n  // Nested enums\n  if (descriptor->enum_type_count() > 0) {\n      std::vector<std::string> enums;\n      for (int i = 0; i < descriptor->enum_type_count(); i++) {\n          enums.push_back(GetClassName(descriptor->enum_type(i)));\n      }\n      printer->Print(\"new[]{ typeof($enums$) }, \", \"enums\", JoinStrings(enums, \"), typeof(\"));\n  }\n  else {\n      printer->Print(\"null, \");\n  }\n\n  // Nested types\n  if (descriptor->nested_type_count() > 0) {\n      // Need to specify array type explicitly here, as all elements may be null. \n      printer->Print(\"new pbr::GeneratedClrTypeInfo[] { \");\n      for (int i = 0; i < descriptor->nested_type_count(); i++) {\n          WriteGeneratedCodeInfo(descriptor->nested_type(i), printer, i == descriptor->nested_type_count() - 1);\n      }\n      printer->Print(\"}\");\n  }\n  else {\n      printer->Print(\"null\");\n  }\n  printer->Print(last ? \")\" : \"),\\n\");\n}\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_reflection_class.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_REFLECTION_CLASS_H__\n#define GOOGLE_PROTOBUF_COMPILER_CSHARP_REFLECTION_CLASS_H__\n\n#include <string>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/csharp/csharp_source_generator_base.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nclass ReflectionClassGenerator : public SourceGeneratorBase {\n public:\n  ReflectionClassGenerator(const FileDescriptor* file, const Options* options);\n  ~ReflectionClassGenerator();\n\n  void Generate(io::Printer* printer);\n\n private:\n  const FileDescriptor* file_;\n\n  std::string namespace_;\n  std::string reflectionClassname_;\n\n  void WriteIntroduction(io::Printer* printer);\n  void WriteDescriptor(io::Printer* printer);\n  void WriteGeneratedCodeInfo(const Descriptor* descriptor,\n                              io::Printer* printer,\n                              bool last);\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ReflectionClassGenerator);\n};\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMPILER_CSHARP_REFLECTION_CLASS_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <sstream>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/plugin.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/wire_format.h>\n\n#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>\n#include <google/protobuf/compiler/csharp/csharp_helpers.h>\n#include <google/protobuf/compiler/csharp/csharp_repeated_enum_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nRepeatedEnumFieldGenerator::RepeatedEnumFieldGenerator(\n    const FieldDescriptor* descriptor, int fieldOrdinal, const Options *options)\n    : FieldGeneratorBase(descriptor, fieldOrdinal, options) {\n}\n\nRepeatedEnumFieldGenerator::~RepeatedEnumFieldGenerator() {\n\n}\n\nvoid RepeatedEnumFieldGenerator::GenerateMembers(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"private static readonly pb::FieldCodec<$type_name$> _repeated_$name$_codec\\n\"\n    \"    = pb::FieldCodec.ForEnum($tag$, x => (int) x, x => ($type_name$) x);\\n\");\n  printer->Print(variables_,\n    \"private readonly pbc::RepeatedField<$type_name$> $name$_ = new pbc::RepeatedField<$type_name$>();\\n\");\n  WritePropertyDocComment(printer, descriptor_);\n  AddPublicMemberAttributes(printer);\n  printer->Print(\n    variables_,\n    \"$access_level$ pbc::RepeatedField<$type_name$> $property_name$ {\\n\"\n    \"  get { return $name$_; }\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::GenerateMergingCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"$name$_.Add(other.$name$_);\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::GenerateParsingCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"$name$_.AddEntriesFrom(input, _repeated_$name$_codec);\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::GenerateSerializationCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"$name$_.WriteTo(output, _repeated_$name$_codec);\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) {  \n  printer->Print(\n    variables_,\n    \"size += $name$_.CalculateSize(_repeated_$name$_codec);\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::WriteHash(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"hash ^= $name$_.GetHashCode();\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::WriteEquals(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if(!$name$_.Equals(other.$name$_)) return false;\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::WriteToString(io::Printer* printer) {\n  printer->Print(variables_,\n    \"PrintField(\\\"$descriptor_name$\\\", $name$_, writer);\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::GenerateCloningCode(io::Printer* printer) {\n  printer->Print(variables_,\n    \"$name$_ = other.$name$_.Clone();\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::GenerateFreezingCode(io::Printer* printer) {\n}\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_ENUM_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_ENUM_FIELD_H__\n\n#include <string>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/csharp/csharp_field_base.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\n// TODO(jonskeet): Refactor repeated field support; all the implementations are *really* similar. We\n// should probably have a RepeatedFieldGeneratorBase.\nclass RepeatedEnumFieldGenerator : public FieldGeneratorBase {\n public:\n  RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor,\n                             int fieldOrdinal,\n                             const Options *options);\n  ~RepeatedEnumFieldGenerator();\n\n  virtual void GenerateCloningCode(io::Printer* printer);\n  virtual void GenerateFreezingCode(io::Printer* printer);\n  virtual void GenerateMembers(io::Printer* printer);\n  virtual void GenerateMergingCode(io::Printer* printer);\n  virtual void GenerateParsingCode(io::Printer* printer);\n  virtual void GenerateSerializationCode(io::Printer* printer);\n  virtual void GenerateSerializedSizeCode(io::Printer* printer);\n\n  virtual void WriteHash(io::Printer* printer);\n  virtual void WriteEquals(io::Printer* printer);\n  virtual void WriteToString(io::Printer* printer);\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedEnumFieldGenerator);\n};\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_ENUM_FIELD_H__\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <sstream>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/plugin.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n\n#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>\n#include <google/protobuf/compiler/csharp/csharp_helpers.h>\n#include <google/protobuf/compiler/csharp/csharp_repeated_message_field.h>\n#include <google/protobuf/compiler/csharp/csharp_message_field.h>\n#include <google/protobuf/compiler/csharp/csharp_wrapper_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nRepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator(\n    const FieldDescriptor* descriptor, int fieldOrdinal, const Options *options)\n    : FieldGeneratorBase(descriptor, fieldOrdinal, options) {\n}\n\nRepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() {\n\n}\n\nvoid RepeatedMessageFieldGenerator::GenerateMembers(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"private static readonly pb::FieldCodec<$type_name$> _repeated_$name$_codec\\n\"\n    \"    = \");\n  // Don't want to duplicate the codec code here... maybe we should have a\n  // \"create single field generator for this repeated field\"\n  // function, but it doesn't seem worth it for just this.\n  if (IsWrapperType(descriptor_)) {\n    scoped_ptr<FieldGeneratorBase> single_generator(\n      new WrapperFieldGenerator(descriptor_, fieldOrdinal_, this->options()));\n    single_generator->GenerateCodecCode(printer);\n  } else {\n    scoped_ptr<FieldGeneratorBase> single_generator(\n      new MessageFieldGenerator(descriptor_, fieldOrdinal_, this->options()));\n    single_generator->GenerateCodecCode(printer);\n  }\n  printer->Print(\";\\n\");\n  printer->Print(\n    variables_,\n    \"private readonly pbc::RepeatedField<$type_name$> $name$_ = new pbc::RepeatedField<$type_name$>();\\n\");\n  WritePropertyDocComment(printer, descriptor_);\n  AddPublicMemberAttributes(printer);\n  printer->Print(\n    variables_,\n    \"$access_level$ pbc::RepeatedField<$type_name$> $property_name$ {\\n\"\n    \"  get { return $name$_; }\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::GenerateMergingCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"$name$_.Add(other.$name$_);\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::GenerateParsingCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"$name$_.AddEntriesFrom(input, _repeated_$name$_codec);\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::GenerateSerializationCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"$name$_.WriteTo(output, _repeated_$name$_codec);\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"size += $name$_.CalculateSize(_repeated_$name$_codec);\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::WriteHash(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"hash ^= $name$_.GetHashCode();\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::WriteEquals(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if(!$name$_.Equals(other.$name$_)) return false;\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::WriteToString(io::Printer* printer) {\n  variables_[\"field_name\"] = GetFieldName(descriptor_);\n  printer->Print(\n    variables_,\n    \"PrintField(\\\"$field_name$\\\", $name$_, writer);\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::GenerateCloningCode(io::Printer* printer) {\n  printer->Print(variables_,\n    \"$name$_ = other.$name$_.Clone();\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::GenerateFreezingCode(io::Printer* printer) {\n}\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_MESSAGE_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_MESSAGE_FIELD_H__\n\n#include <string>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/csharp/csharp_field_base.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nstruct Options;\n\nclass RepeatedMessageFieldGenerator : public FieldGeneratorBase {\n public:\n  RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor,\n                                int fieldOrdinal,\n                                const Options *options);\n  ~RepeatedMessageFieldGenerator();\n\n  virtual void GenerateCloningCode(io::Printer* printer);\n  virtual void GenerateFreezingCode(io::Printer* printer);\n  virtual void GenerateMembers(io::Printer* printer);\n  virtual void GenerateMergingCode(io::Printer* printer);\n  virtual void GenerateParsingCode(io::Printer* printer);\n  virtual void GenerateSerializationCode(io::Printer* printer);\n  virtual void GenerateSerializedSizeCode(io::Printer* printer);\n\n  virtual void WriteHash(io::Printer* printer);\n  virtual void WriteEquals(io::Printer* printer);\n  virtual void WriteToString(io::Printer* printer);\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator);\n};\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_MESSAGE_FIELD_H__\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <sstream>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/plugin.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/wire_format.h>\n\n#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>\n#include <google/protobuf/compiler/csharp/csharp_helpers.h>\n#include <google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nRepeatedPrimitiveFieldGenerator::RepeatedPrimitiveFieldGenerator(\n    const FieldDescriptor* descriptor, int fieldOrdinal, const Options *options)\n    : FieldGeneratorBase(descriptor, fieldOrdinal, options) {\n}\n\nRepeatedPrimitiveFieldGenerator::~RepeatedPrimitiveFieldGenerator() {\n\n}\n\nvoid RepeatedPrimitiveFieldGenerator::GenerateMembers(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"private static readonly pb::FieldCodec<$type_name$> _repeated_$name$_codec\\n\"\n    \"    = pb::FieldCodec.For$capitalized_type_name$($tag$);\\n\");\n  printer->Print(variables_,\n    \"private readonly pbc::RepeatedField<$type_name$> $name$_ = new pbc::RepeatedField<$type_name$>();\\n\");\n  WritePropertyDocComment(printer, descriptor_);\n  AddPublicMemberAttributes(printer);\n  printer->Print(\n    variables_,\n    \"$access_level$ pbc::RepeatedField<$type_name$> $property_name$ {\\n\"\n    \"  get { return $name$_; }\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::GenerateMergingCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"$name$_.Add(other.$name$_);\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::GenerateParsingCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"$name$_.AddEntriesFrom(input, _repeated_$name$_codec);\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::GenerateSerializationCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"$name$_.WriteTo(output, _repeated_$name$_codec);\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"size += $name$_.CalculateSize(_repeated_$name$_codec);\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::WriteHash(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"hash ^= $name$_.GetHashCode();\\n\");\n}\nvoid RepeatedPrimitiveFieldGenerator::WriteEquals(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if(!$name$_.Equals(other.$name$_)) return false;\\n\");\n}\nvoid RepeatedPrimitiveFieldGenerator::WriteToString(io::Printer* printer) {\n  printer->Print(variables_,\n    \"PrintField(\\\"$descriptor_name$\\\", $name$_, writer);\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::GenerateCloningCode(io::Printer* printer) {\n  printer->Print(variables_,\n    \"$name$_ = other.$name$_.Clone();\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::GenerateFreezingCode(io::Printer* printer) {\n}\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_PRIMITIVE_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_PRIMITIVE_FIELD_H__\n\n#include <string>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/csharp/csharp_field_base.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nclass RepeatedPrimitiveFieldGenerator : public FieldGeneratorBase {\n public:\n  RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor, int fieldOrdinal, const Options *options);\n  ~RepeatedPrimitiveFieldGenerator();\n\n  virtual void GenerateCloningCode(io::Printer* printer);\n  virtual void GenerateFreezingCode(io::Printer* printer);\n  virtual void GenerateMembers(io::Printer* printer);\n  virtual void GenerateMergingCode(io::Printer* printer);\n  virtual void GenerateParsingCode(io::Printer* printer);\n  virtual void GenerateSerializationCode(io::Printer* printer);\n  virtual void GenerateSerializedSizeCode(io::Printer* printer);\n\n  virtual void WriteHash(io::Printer* printer);\n  virtual void WriteEquals(io::Printer* printer);\n  virtual void WriteToString(io::Printer* printer);\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPrimitiveFieldGenerator);\n};\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMPILER_CSHARP_REPEATED_PRIMITIVE_FIELD_H__\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <sstream>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/plugin.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n\n#include <google/protobuf/compiler/csharp/csharp_source_generator_base.h>\n#include <google/protobuf/compiler/csharp/csharp_helpers.h>\n#include <google/protobuf/compiler/csharp/csharp_names.h>\n#include <google/protobuf/compiler/csharp/csharp_options.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nSourceGeneratorBase::SourceGeneratorBase(const FileDescriptor* descriptor,\n                                         const Options *options)\n    : descriptor_(descriptor), options_(options) {\n}\n\nSourceGeneratorBase::~SourceGeneratorBase() {\n}\n\nvoid SourceGeneratorBase::WriteGeneratedCodeAttributes(io::Printer* printer) {\n  printer->Print(\"[global::System.Diagnostics.DebuggerNonUserCodeAttribute]\\n\");\n}\n\nstd::string SourceGeneratorBase::class_access_level() {\n  return (IsDescriptorProto(descriptor_) || this->options()->internal_access) ? \"internal\" : \"public\";\n}\n\nconst Options* SourceGeneratorBase::options() {\n  return this->options_;\n}\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_SOURCE_GENERATOR_BASE_H__\n#define GOOGLE_PROTOBUF_COMPILER_CSHARP_SOURCE_GENERATOR_BASE_H__\n\n#include <string>\n\n#include <google/protobuf/compiler/code_generator.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nstruct Options;\n\nclass SourceGeneratorBase {\n protected:\n  SourceGeneratorBase(const FileDescriptor* descriptor, const Options* options);\n  virtual ~SourceGeneratorBase();\n\n  std::string class_access_level();\n  const Options* options();\n\n  // Write any attributes used to decorate generated function members (methods and properties).\n  // Should not be used to decorate types.\n  void WriteGeneratedCodeAttributes(io::Printer* printer);\n\n private:\n  const FileDescriptor* descriptor_;\n  const Options *options_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SourceGeneratorBase);\n};\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMPILER_CSHARP_SOURCE_GENERATOR_BASE_H__\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <sstream>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/plugin.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n\n#include <google/protobuf/compiler/csharp/csharp_doc_comment.h>\n#include <google/protobuf/compiler/csharp/csharp_helpers.h>\n#include <google/protobuf/compiler/csharp/csharp_options.h>\n#include <google/protobuf/compiler/csharp/csharp_wrapper_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nWrapperFieldGenerator::WrapperFieldGenerator(const FieldDescriptor* descriptor,\n                                       int fieldOrdinal, const Options *options)\n    : FieldGeneratorBase(descriptor, fieldOrdinal, options) {\n  variables_[\"has_property_check\"] = name() + \"_ != null\";\n  variables_[\"has_not_property_check\"] = name() + \"_ == null\";\n  const FieldDescriptor* wrapped_field = descriptor->message_type()->field(0);\n  is_value_type = wrapped_field->type() != FieldDescriptor::TYPE_STRING &&\n      wrapped_field->type() != FieldDescriptor::TYPE_BYTES;\n  if (is_value_type) {\n    variables_[\"nonnullable_type_name\"] = type_name(wrapped_field);\n  }\n}\n\nWrapperFieldGenerator::~WrapperFieldGenerator() {\n}\n\nvoid WrapperFieldGenerator::GenerateMembers(io::Printer* printer) {\n  printer->Print(\n        variables_,\n        \"private static readonly pb::FieldCodec<$type_name$> _single_$name$_codec = \");\n  GenerateCodecCode(printer);\n  printer->Print(\n    variables_,\n    \";\\n\"\n    \"private $type_name$ $name$_;\\n\");\n  WritePropertyDocComment(printer, descriptor_);\n  AddPublicMemberAttributes(printer);\n  printer->Print(\n    variables_,\n    \"$access_level$ $type_name$ $property_name$ {\\n\"\n    \"  get { return $name$_; }\\n\"\n    \"  set {\\n\"\n    \"    $name$_ = value;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n}\n\nvoid WrapperFieldGenerator::GenerateMergingCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if (other.$has_property_check$) {\\n\"\n    \"  if ($has_not_property_check$ || other.$property_name$ != $default_value$) {\\n\"\n    \"    $property_name$ = other.$property_name$;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n}\n\nvoid WrapperFieldGenerator::GenerateParsingCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"$type_name$ value = _single_$name$_codec.Read(input);\\n\"\n    \"if ($has_not_property_check$ || value != $default_value$) {\\n\"\n    \"  $property_name$ = value;\\n\"\n    \"}\\n\");\n}\n\nvoid WrapperFieldGenerator::GenerateSerializationCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if ($has_property_check$) {\\n\"\n    \"  _single_$name$_codec.WriteTagAndValue(output, $property_name$);\\n\"\n    \"}\\n\");\n}\n\nvoid WrapperFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if ($has_property_check$) {\\n\"\n    \"  size += _single_$name$_codec.CalculateSizeWithTag($property_name$);\\n\"\n    \"}\\n\");\n}\n\nvoid WrapperFieldGenerator::WriteHash(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if ($has_property_check$) hash ^= $property_name$.GetHashCode();\\n\");\n}\n\nvoid WrapperFieldGenerator::WriteEquals(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"if ($property_name$ != other.$property_name$) return false;\\n\");\n}\n\nvoid WrapperFieldGenerator::WriteToString(io::Printer* printer) {\n  // TODO: Implement if we ever actually need it...\n}\n\nvoid WrapperFieldGenerator::GenerateCloningCode(io::Printer* printer) {\n  printer->Print(variables_,\n    \"$property_name$ = other.$property_name$;\\n\");\n}\n\nvoid WrapperFieldGenerator::GenerateCodecCode(io::Printer* printer) {\n  if (is_value_type) {\n    printer->Print(\n      variables_,\n      \"pb::FieldCodec.ForStructWrapper<$nonnullable_type_name$>($tag$)\");\n  } else {\n    printer->Print(\n      variables_,\n      \"pb::FieldCodec.ForClassWrapper<$type_name$>($tag$)\");\n  }\n}\n\nWrapperOneofFieldGenerator::WrapperOneofFieldGenerator(\n    const FieldDescriptor* descriptor, int fieldOrdinal, const Options *options)\n    : WrapperFieldGenerator(descriptor, fieldOrdinal, options) {\n    SetCommonOneofFieldVariables(&variables_);\n}\n\nWrapperOneofFieldGenerator::~WrapperOneofFieldGenerator() {\n}\n\nvoid WrapperOneofFieldGenerator::GenerateMembers(io::Printer* printer) {\n  // Note: deliberately _oneof_$name$_codec, not _$oneof_name$_codec... we have one codec per field.\n  printer->Print(\n        variables_,\n        \"private static readonly pb::FieldCodec<$type_name$> _oneof_$name$_codec = \");\n  GenerateCodecCode(printer);\n  printer->Print(\";\\n\");\n  WritePropertyDocComment(printer, descriptor_);\n  AddPublicMemberAttributes(printer);\n  printer->Print(\n    variables_,\n    \"$access_level$ $type_name$ $property_name$ {\\n\"\n    \"  get { return $has_property_check$ ? ($type_name$) $oneof_name$_ : ($type_name$) null; }\\n\"\n    \"  set {\\n\"\n    \"    $oneof_name$_ = value;\\n\"\n    \"    $oneof_name$Case_ = value == null ? $oneof_property_name$OneofCase.None : $oneof_property_name$OneofCase.$property_name$;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n}\n\nvoid WrapperOneofFieldGenerator::GenerateParsingCode(io::Printer* printer) {\n  printer->Print(\n    variables_,\n    \"$property_name$ = _oneof_$name$_codec.Read(input);\\n\");\n}\n\nvoid WrapperOneofFieldGenerator::GenerateSerializationCode(io::Printer* printer) {\n  // TODO: I suspect this is wrong...\n  printer->Print(\n    variables_,\n    \"if ($has_property_check$) {\\n\"\n    \"  _oneof_$name$_codec.WriteTagAndValue(output, ($type_name$) $oneof_name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid WrapperOneofFieldGenerator::GenerateSerializedSizeCode(io::Printer* printer) {\n  // TODO: I suspect this is wrong...\n  printer->Print(\n    variables_,\n    \"if ($has_property_check$) {\\n\"\n    \"  size += _oneof_$name$_codec.CalculateSizeWithTag($property_name$);\\n\"\n    \"}\\n\");\n}\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_CSHARP_WRAPPER_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_CSHARP_WRAPPER_FIELD_H__\n\n#include <string>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/csharp/csharp_field_base.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace csharp {\n\nstruct Options;\n\nclass WrapperFieldGenerator : public FieldGeneratorBase {\n public:\n  WrapperFieldGenerator(const FieldDescriptor* descriptor,\n                        int fieldOrdinal,\n                        const Options *options);\n  ~WrapperFieldGenerator();\n\n  virtual void GenerateCodecCode(io::Printer* printer);\n  virtual void GenerateCloningCode(io::Printer* printer);\n  virtual void GenerateMembers(io::Printer* printer);\n  virtual void GenerateMergingCode(io::Printer* printer);\n  virtual void GenerateParsingCode(io::Printer* printer);\n  virtual void GenerateSerializationCode(io::Printer* printer);\n  virtual void GenerateSerializedSizeCode(io::Printer* printer);\n\n  virtual void WriteHash(io::Printer* printer);\n  virtual void WriteEquals(io::Printer* printer);\n  virtual void WriteToString(io::Printer* printer);\n\n private:\n  bool is_value_type; // True for int32 etc; false for bytes and string\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(WrapperFieldGenerator);\n};\n\nclass WrapperOneofFieldGenerator : public WrapperFieldGenerator {\n public:\n  WrapperOneofFieldGenerator(const FieldDescriptor* descriptor,\n                             int fieldOrdinal,\n                             const Options *options);\n  ~WrapperOneofFieldGenerator();\n\n  virtual void GenerateMembers(io::Printer* printer);\n  virtual void GenerateParsingCode(io::Printer* printer);\n  virtual void GenerateSerializationCode(io::Printer* printer);\n  virtual void GenerateSerializedSizeCode(io::Printer* printer);\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(WrapperOneofFieldGenerator);\n};\n\n}  // namespace csharp\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMPILER_CSHARP_WRAPPER_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/importer.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifdef _MSC_VER\n#include <io.h>\n#else\n#include <unistd.h>\n#endif\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n#include <errno.h>\n\n#include <algorithm>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#include <google/protobuf/compiler/importer.h>\n\n#include <google/protobuf/compiler/parser.h>\n#include <google/protobuf/io/tokenizer.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\n\n#ifdef _WIN32\n#ifndef F_OK\n#define F_OK 00  // not defined by MSVC for whatever reason\n#endif\n#include <ctype.h>\n#endif\n\n// Returns true if the text looks like a Windows-style absolute path, starting\n// with a drive letter.  Example:  \"C:\\foo\".  TODO(kenton):  Share this with\n// copy in command_line_interface.cc?\nstatic bool IsWindowsAbsolutePath(const string& text) {\n#if defined(_WIN32) || defined(__CYGWIN__)\n  return text.size() >= 3 && text[1] == ':' &&\n         isalpha(text[0]) &&\n         (text[2] == '/' || text[2] == '\\\\') &&\n         text.find_last_of(':') == 1;\n#else\n  return false;\n#endif\n}\n\nMultiFileErrorCollector::~MultiFileErrorCollector() {}\n\n// This class serves two purposes:\n// - It implements the ErrorCollector interface (used by Tokenizer and Parser)\n//   in terms of MultiFileErrorCollector, using a particular filename.\n// - It lets us check if any errors have occurred.\nclass SourceTreeDescriptorDatabase::SingleFileErrorCollector\n    : public io::ErrorCollector {\n public:\n  SingleFileErrorCollector(const string& filename,\n                           MultiFileErrorCollector* multi_file_error_collector)\n    : filename_(filename),\n      multi_file_error_collector_(multi_file_error_collector),\n      had_errors_(false) {}\n  ~SingleFileErrorCollector() {}\n\n  bool had_errors() { return had_errors_; }\n\n  // implements ErrorCollector ---------------------------------------\n  void AddError(int line, int column, const string& message) {\n    if (multi_file_error_collector_ != NULL) {\n      multi_file_error_collector_->AddError(filename_, line, column, message);\n    }\n    had_errors_ = true;\n  }\n\n private:\n  string filename_;\n  MultiFileErrorCollector* multi_file_error_collector_;\n  bool had_errors_;\n};\n\n// ===================================================================\n\nSourceTreeDescriptorDatabase::SourceTreeDescriptorDatabase(\n    SourceTree* source_tree)\n  : source_tree_(source_tree),\n    error_collector_(NULL),\n    using_validation_error_collector_(false),\n    validation_error_collector_(this) {}\n\nSourceTreeDescriptorDatabase::~SourceTreeDescriptorDatabase() {}\n\nbool SourceTreeDescriptorDatabase::FindFileByName(\n    const string& filename, FileDescriptorProto* output) {\n  google::protobuf::scoped_ptr<io::ZeroCopyInputStream> input(source_tree_->Open(filename));\n  if (input == NULL) {\n    if (error_collector_ != NULL) {\n      error_collector_->AddError(filename, -1, 0,\n                                 source_tree_->GetLastErrorMessage());\n    }\n    return false;\n  }\n\n  // Set up the tokenizer and parser.\n  SingleFileErrorCollector file_error_collector(filename, error_collector_);\n  io::Tokenizer tokenizer(input.get(), &file_error_collector);\n\n  Parser parser;\n  if (error_collector_ != NULL) {\n    parser.RecordErrorsTo(&file_error_collector);\n  }\n  if (using_validation_error_collector_) {\n    parser.RecordSourceLocationsTo(&source_locations_);\n  }\n\n  // Parse it.\n  output->set_name(filename);\n  return parser.Parse(&tokenizer, output) &&\n         !file_error_collector.had_errors();\n}\n\nbool SourceTreeDescriptorDatabase::FindFileContainingSymbol(\n    const string& symbol_name, FileDescriptorProto* output) {\n  return false;\n}\n\nbool SourceTreeDescriptorDatabase::FindFileContainingExtension(\n    const string& containing_type, int field_number,\n    FileDescriptorProto* output) {\n  return false;\n}\n\n// -------------------------------------------------------------------\n\nSourceTreeDescriptorDatabase::ValidationErrorCollector::\nValidationErrorCollector(SourceTreeDescriptorDatabase* owner)\n  : owner_(owner) {}\n\nSourceTreeDescriptorDatabase::ValidationErrorCollector::\n~ValidationErrorCollector() {}\n\nvoid SourceTreeDescriptorDatabase::ValidationErrorCollector::AddError(\n    const string& filename,\n    const string& element_name,\n    const Message* descriptor,\n    ErrorLocation location,\n    const string& message) {\n  if (owner_->error_collector_ == NULL) return;\n\n  int line, column;\n  owner_->source_locations_.Find(descriptor, location, &line, &column);\n  owner_->error_collector_->AddError(filename, line, column, message);\n}\n\nvoid SourceTreeDescriptorDatabase::ValidationErrorCollector::AddWarning(\n    const string& filename,\n    const string& element_name,\n    const Message* descriptor,\n    ErrorLocation location,\n    const string& message) {\n  if (owner_->error_collector_ == NULL) return;\n\n  int line, column;\n  owner_->source_locations_.Find(descriptor, location, &line, &column);\n  owner_->error_collector_->AddWarning(filename, line, column, message);\n}\n\n// ===================================================================\n\nImporter::Importer(SourceTree* source_tree,\n                   MultiFileErrorCollector* error_collector)\n  : database_(source_tree),\n    pool_(&database_, database_.GetValidationErrorCollector()) {\n  pool_.EnforceWeakDependencies(true);\n  database_.RecordErrorsTo(error_collector);\n}\n\nImporter::~Importer() {}\n\nconst FileDescriptor* Importer::Import(const string& filename) {\n  return pool_.FindFileByName(filename);\n}\n\nvoid Importer::AddUnusedImportTrackFile(const string& file_name) {\n  pool_.AddUnusedImportTrackFile(file_name);\n}\n\nvoid Importer::ClearUnusedImportTrackFiles() {\n  pool_.ClearUnusedImportTrackFiles();\n}\n\n// ===================================================================\n\nSourceTree::~SourceTree() {}\n\nstring SourceTree::GetLastErrorMessage() {\n  return \"File not found.\";\n}\n\nDiskSourceTree::DiskSourceTree() {}\n\nDiskSourceTree::~DiskSourceTree() {}\n\nstatic inline char LastChar(const string& str) {\n  return str[str.size() - 1];\n}\n\n// Given a path, returns an equivalent path with these changes:\n// - On Windows, any backslashes are replaced with forward slashes.\n// - Any instances of the directory \".\" are removed.\n// - Any consecutive '/'s are collapsed into a single slash.\n// Note that the resulting string may be empty.\n//\n// TODO(kenton):  It would be nice to handle \"..\", e.g. so that we can figure\n//   out that \"foo/bar.proto\" is inside \"baz/../foo\".  However, if baz is a\n//   symlink or doesn't exist, then things get complicated, and we can't\n//   actually determine this without investigating the filesystem, probably\n//   in non-portable ways.  So, we punt.\n//\n// TODO(kenton):  It would be nice to use realpath() here except that it\n//   resolves symbolic links.  This could cause problems if people place\n//   symbolic links in their source tree.  For example, if you executed:\n//     protoc --proto_path=foo foo/bar/baz.proto\n//   then if foo/bar is a symbolic link, foo/bar/baz.proto will canonicalize\n//   to a path which does not appear to be under foo, and thus the compiler\n//   will complain that baz.proto is not inside the --proto_path.\nstatic string CanonicalizePath(string path) {\n#ifdef _WIN32\n  // The Win32 API accepts forward slashes as a path delimiter even though\n  // backslashes are standard.  Let's avoid confusion and use only forward\n  // slashes.\n  if (HasPrefixString(path, \"\\\\\\\\\")) {\n    // Avoid converting two leading backslashes.\n    path = \"\\\\\\\\\" + StringReplace(path.substr(2), \"\\\\\", \"/\", true);\n  } else {\n    path = StringReplace(path, \"\\\\\", \"/\", true);\n  }\n#endif\n\n  vector<string> canonical_parts;\n  vector<string> parts = Split(\n      path, \"/\", true);  // Note:  Removes empty parts.\n  for (int i = 0; i < parts.size(); i++) {\n    if (parts[i] == \".\") {\n      // Ignore.\n    } else {\n      canonical_parts.push_back(parts[i]);\n    }\n  }\n  string result = Join(canonical_parts, \"/\");\n  if (!path.empty() && path[0] == '/') {\n    // Restore leading slash.\n    result = '/' + result;\n  }\n  if (!path.empty() && LastChar(path) == '/' &&\n      !result.empty() && LastChar(result) != '/') {\n    // Restore trailing slash.\n    result += '/';\n  }\n  return result;\n}\n\nstatic inline bool ContainsParentReference(const string& path) {\n  return path == \"..\" ||\n         HasPrefixString(path, \"../\") ||\n         HasSuffixString(path, \"/..\") ||\n         path.find(\"/../\") != string::npos;\n}\n\n// Maps a file from an old location to a new one.  Typically, old_prefix is\n// a virtual path and new_prefix is its corresponding disk path.  Returns\n// false if the filename did not start with old_prefix, otherwise replaces\n// old_prefix with new_prefix and stores the result in *result.  Examples:\n//   string result;\n//   assert(ApplyMapping(\"foo/bar\", \"\", \"baz\", &result));\n//   assert(result == \"baz/foo/bar\");\n//\n//   assert(ApplyMapping(\"foo/bar\", \"foo\", \"baz\", &result));\n//   assert(result == \"baz/bar\");\n//\n//   assert(ApplyMapping(\"foo\", \"foo\", \"bar\", &result));\n//   assert(result == \"bar\");\n//\n//   assert(!ApplyMapping(\"foo/bar\", \"baz\", \"qux\", &result));\n//   assert(!ApplyMapping(\"foo/bar\", \"baz\", \"qux\", &result));\n//   assert(!ApplyMapping(\"foobar\", \"foo\", \"baz\", &result));\nstatic bool ApplyMapping(const string& filename,\n                         const string& old_prefix,\n                         const string& new_prefix,\n                         string* result) {\n  if (old_prefix.empty()) {\n    // old_prefix matches any relative path.\n    if (ContainsParentReference(filename)) {\n      // We do not allow the file name to use \"..\".\n      return false;\n    }\n    if (HasPrefixString(filename, \"/\") ||\n        IsWindowsAbsolutePath(filename)) {\n      // This is an absolute path, so it isn't matched by the empty string.\n      return false;\n    }\n    result->assign(new_prefix);\n    if (!result->empty()) result->push_back('/');\n    result->append(filename);\n    return true;\n  } else if (HasPrefixString(filename, old_prefix)) {\n    // old_prefix is a prefix of the filename.  Is it the whole filename?\n    if (filename.size() == old_prefix.size()) {\n      // Yep, it's an exact match.\n      *result = new_prefix;\n      return true;\n    } else {\n      // Not an exact match.  Is the next character a '/'?  Otherwise,\n      // this isn't actually a match at all.  E.g. the prefix \"foo/bar\"\n      // does not match the filename \"foo/barbaz\".\n      int after_prefix_start = -1;\n      if (filename[old_prefix.size()] == '/') {\n        after_prefix_start = old_prefix.size() + 1;\n      } else if (filename[old_prefix.size() - 1] == '/') {\n        // old_prefix is never empty, and canonicalized paths never have\n        // consecutive '/' characters.\n        after_prefix_start = old_prefix.size();\n      }\n      if (after_prefix_start != -1) {\n        // Yep.  So the prefixes are directories and the filename is a file\n        // inside them.\n        string after_prefix = filename.substr(after_prefix_start);\n        if (ContainsParentReference(after_prefix)) {\n          // We do not allow the file name to use \"..\".\n          return false;\n        }\n        result->assign(new_prefix);\n        if (!result->empty()) result->push_back('/');\n        result->append(after_prefix);\n        return true;\n      }\n    }\n  }\n\n  return false;\n}\n\nvoid DiskSourceTree::MapPath(const string& virtual_path,\n                             const string& disk_path) {\n  mappings_.push_back(Mapping(virtual_path, CanonicalizePath(disk_path)));\n}\n\nDiskSourceTree::DiskFileToVirtualFileResult\nDiskSourceTree::DiskFileToVirtualFile(\n    const string& disk_file,\n    string* virtual_file,\n    string* shadowing_disk_file) {\n  int mapping_index = -1;\n  string canonical_disk_file = CanonicalizePath(disk_file);\n\n  for (int i = 0; i < mappings_.size(); i++) {\n    // Apply the mapping in reverse.\n    if (ApplyMapping(canonical_disk_file, mappings_[i].disk_path,\n                     mappings_[i].virtual_path, virtual_file)) {\n      // Success.\n      mapping_index = i;\n      break;\n    }\n  }\n\n  if (mapping_index == -1) {\n    return NO_MAPPING;\n  }\n\n  // Iterate through all mappings with higher precedence and verify that none\n  // of them map this file to some other existing file.\n  for (int i = 0; i < mapping_index; i++) {\n    if (ApplyMapping(*virtual_file, mappings_[i].virtual_path,\n                     mappings_[i].disk_path, shadowing_disk_file)) {\n      if (access(shadowing_disk_file->c_str(), F_OK) >= 0) {\n        // File exists.\n        return SHADOWED;\n      }\n    }\n  }\n  shadowing_disk_file->clear();\n\n  // Verify that we can open the file.  Note that this also has the side-effect\n  // of verifying that we are not canonicalizing away any non-existent\n  // directories.\n  google::protobuf::scoped_ptr<io::ZeroCopyInputStream> stream(OpenDiskFile(disk_file));\n  if (stream == NULL) {\n    return CANNOT_OPEN;\n  }\n\n  return SUCCESS;\n}\n\nbool DiskSourceTree::VirtualFileToDiskFile(const string& virtual_file,\n                                           string* disk_file) {\n  google::protobuf::scoped_ptr<io::ZeroCopyInputStream> stream(\n      OpenVirtualFile(virtual_file, disk_file));\n  return stream != NULL;\n}\n\nio::ZeroCopyInputStream* DiskSourceTree::Open(const string& filename) {\n  return OpenVirtualFile(filename, NULL);\n}\n\nstring DiskSourceTree::GetLastErrorMessage() {\n  return last_error_message_;\n}\n\nio::ZeroCopyInputStream* DiskSourceTree::OpenVirtualFile(\n    const string& virtual_file,\n    string* disk_file) {\n  if (virtual_file != CanonicalizePath(virtual_file) ||\n      ContainsParentReference(virtual_file)) {\n    // We do not allow importing of paths containing things like \"..\" or\n    // consecutive slashes since the compiler expects files to be uniquely\n    // identified by file name.\n    last_error_message_ = \"Backslashes, consecutive slashes, \\\".\\\", or \\\"..\\\" \"\n                          \"are not allowed in the virtual path\";\n    return NULL;\n  }\n\n  for (int i = 0; i < mappings_.size(); i++) {\n    string temp_disk_file;\n    if (ApplyMapping(virtual_file, mappings_[i].virtual_path,\n                     mappings_[i].disk_path, &temp_disk_file)) {\n      io::ZeroCopyInputStream* stream = OpenDiskFile(temp_disk_file);\n      if (stream != NULL) {\n        if (disk_file != NULL) {\n          *disk_file = temp_disk_file;\n        }\n        return stream;\n      }\n\n      if (errno == EACCES) {\n        // The file exists but is not readable.\n        last_error_message_ = \"Read access is denied for file: \" +\n                              temp_disk_file;\n        return NULL;\n      }\n    }\n  }\n  last_error_message_ = \"File not found.\";\n  return NULL;\n}\n\nio::ZeroCopyInputStream* DiskSourceTree::OpenDiskFile(\n    const string& filename) {\n  int file_descriptor;\n  do {\n    file_descriptor = open(filename.c_str(), O_RDONLY);\n  } while (file_descriptor < 0 && errno == EINTR);\n  if (file_descriptor >= 0) {\n    io::FileInputStream* result = new io::FileInputStream(file_descriptor);\n    result->SetCloseOnDelete(true);\n    return result;\n  } else {\n    return NULL;\n  }\n}\n\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/importer.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This file is the public interface to the .proto file parser.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_IMPORTER_H__\n#define GOOGLE_PROTOBUF_COMPILER_IMPORTER_H__\n\n#include <string>\n#include <vector>\n#include <set>\n#include <utility>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor_database.h>\n#include <google/protobuf/compiler/parser.h>\n\nnamespace google {\nnamespace protobuf {\n\nnamespace io { class ZeroCopyInputStream; }\n\nnamespace compiler {\n\n// Defined in this file.\nclass Importer;\nclass MultiFileErrorCollector;\nclass SourceTree;\nclass DiskSourceTree;\n\n// TODO(kenton):  Move all SourceTree stuff to a separate file?\n\n// An implementation of DescriptorDatabase which loads files from a SourceTree\n// and parses them.\n//\n// Note:  This class is not thread-safe since it maintains a table of source\n//   code locations for error reporting.  However, when a DescriptorPool wraps\n//   a DescriptorDatabase, it uses mutex locking to make sure only one method\n//   of the database is called at a time, even if the DescriptorPool is used\n//   from multiple threads.  Therefore, there is only a problem if you create\n//   multiple DescriptorPools wrapping the same SourceTreeDescriptorDatabase\n//   and use them from multiple threads.\n//\n// Note:  This class does not implement FindFileContainingSymbol() or\n//   FindFileContainingExtension(); these will always return false.\nclass LIBPROTOBUF_EXPORT SourceTreeDescriptorDatabase : public DescriptorDatabase {\n public:\n  SourceTreeDescriptorDatabase(SourceTree* source_tree);\n  ~SourceTreeDescriptorDatabase();\n\n  // Instructs the SourceTreeDescriptorDatabase to report any parse errors\n  // to the given MultiFileErrorCollector.  This should be called before\n  // parsing.  error_collector must remain valid until either this method\n  // is called again or the SourceTreeDescriptorDatabase is destroyed.\n  void RecordErrorsTo(MultiFileErrorCollector* error_collector) {\n    error_collector_ = error_collector;\n  }\n\n  // Gets a DescriptorPool::ErrorCollector which records errors to the\n  // MultiFileErrorCollector specified with RecordErrorsTo().  This collector\n  // has the ability to determine exact line and column numbers of errors\n  // from the information given to it by the DescriptorPool.\n  DescriptorPool::ErrorCollector* GetValidationErrorCollector() {\n    using_validation_error_collector_ = true;\n    return &validation_error_collector_;\n  }\n\n  // implements DescriptorDatabase -----------------------------------\n  bool FindFileByName(const string& filename, FileDescriptorProto* output);\n  bool FindFileContainingSymbol(const string& symbol_name,\n                                FileDescriptorProto* output);\n  bool FindFileContainingExtension(const string& containing_type,\n                                   int field_number,\n                                   FileDescriptorProto* output);\n\n private:\n  class SingleFileErrorCollector;\n\n  SourceTree* source_tree_;\n  MultiFileErrorCollector* error_collector_;\n\n  class LIBPROTOBUF_EXPORT ValidationErrorCollector : public DescriptorPool::ErrorCollector {\n   public:\n    ValidationErrorCollector(SourceTreeDescriptorDatabase* owner);\n    ~ValidationErrorCollector();\n\n    // implements ErrorCollector ---------------------------------------\n    void AddError(const string& filename,\n                  const string& element_name,\n                  const Message* descriptor,\n                  ErrorLocation location,\n                  const string& message);\n\n    virtual void AddWarning(const string& filename,\n                            const string& element_name,\n                            const Message* descriptor,\n                            ErrorLocation location,\n                            const string& message);\n\n   private:\n    SourceTreeDescriptorDatabase* owner_;\n  };\n  friend class ValidationErrorCollector;\n\n  bool using_validation_error_collector_;\n  SourceLocationTable source_locations_;\n  ValidationErrorCollector validation_error_collector_;\n};\n\n// Simple interface for parsing .proto files.  This wraps the process\n// of opening the file, parsing it with a Parser, recursively parsing all its\n// imports, and then cross-linking the results to produce a FileDescriptor.\n//\n// This is really just a thin wrapper around SourceTreeDescriptorDatabase.\n// You may find that SourceTreeDescriptorDatabase is more flexible.\n//\n// TODO(kenton):  I feel like this class is not well-named.\nclass LIBPROTOBUF_EXPORT Importer {\n public:\n  Importer(SourceTree* source_tree,\n           MultiFileErrorCollector* error_collector);\n  ~Importer();\n\n  // Import the given file and build a FileDescriptor representing it.  If\n  // the file is already in the DescriptorPool, the existing FileDescriptor\n  // will be returned.  The FileDescriptor is property of the DescriptorPool,\n  // and will remain valid until it is destroyed.  If any errors occur, they\n  // will be reported using the error collector and Import() will return NULL.\n  //\n  // A particular Importer object will only report errors for a particular\n  // file once.  All future attempts to import the same file will return NULL\n  // without reporting any errors.  The idea is that you might want to import\n  // a lot of files without seeing the same errors over and over again.  If\n  // you want to see errors for the same files repeatedly, you can use a\n  // separate Importer object to import each one (but use the same\n  // DescriptorPool so that they can be cross-linked).\n  const FileDescriptor* Import(const string& filename);\n\n  // The DescriptorPool in which all imported FileDescriptors and their\n  // contents are stored.\n  inline const DescriptorPool* pool() const {\n    return &pool_;\n  }\n\n  void AddUnusedImportTrackFile(const string& file_name);\n  void ClearUnusedImportTrackFiles();\n\n private:\n  SourceTreeDescriptorDatabase database_;\n  DescriptorPool pool_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Importer);\n};\n\n// If the importer encounters problems while trying to import the proto files,\n// it reports them to a MultiFileErrorCollector.\nclass LIBPROTOBUF_EXPORT MultiFileErrorCollector {\n public:\n  inline MultiFileErrorCollector() {}\n  virtual ~MultiFileErrorCollector();\n\n  // Line and column numbers are zero-based.  A line number of -1 indicates\n  // an error with the entire file (e.g. \"not found\").\n  virtual void AddError(const string& filename, int line, int column,\n                        const string& message) = 0;\n\n  virtual void AddWarning(const string& filename, int line, int column,\n                          const string& message) {}\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MultiFileErrorCollector);\n};\n\n// Abstract interface which represents a directory tree containing proto files.\n// Used by the default implementation of Importer to resolve import statements\n// Most users will probably want to use the DiskSourceTree implementation,\n// below.\nclass LIBPROTOBUF_EXPORT SourceTree {\n public:\n  inline SourceTree() {}\n  virtual ~SourceTree();\n\n  // Open the given file and return a stream that reads it, or NULL if not\n  // found.  The caller takes ownership of the returned object.  The filename\n  // must be a path relative to the root of the source tree and must not\n  // contain \".\" or \"..\" components.\n  virtual io::ZeroCopyInputStream* Open(const string& filename) = 0;\n\n  // If Open() returns NULL, calling this method immediately will return an\n  // description of the error.\n  // Subclasses should implement this method and return a meaningful value for\n  // better error reporting.\n  // TODO(xiaofeng): change this to a pure virtual function.\n  virtual string GetLastErrorMessage();\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SourceTree);\n};\n\n// An implementation of SourceTree which loads files from locations on disk.\n// Multiple mappings can be set up to map locations in the DiskSourceTree to\n// locations in the physical filesystem.\nclass LIBPROTOBUF_EXPORT DiskSourceTree : public SourceTree {\n public:\n  DiskSourceTree();\n  ~DiskSourceTree();\n\n  // Map a path on disk to a location in the SourceTree.  The path may be\n  // either a file or a directory.  If it is a directory, the entire tree\n  // under it will be mapped to the given virtual location.  To map a directory\n  // to the root of the source tree, pass an empty string for virtual_path.\n  //\n  // If multiple mapped paths apply when opening a file, they will be searched\n  // in order.  For example, if you do:\n  //   MapPath(\"bar\", \"foo/bar\");\n  //   MapPath(\"\", \"baz\");\n  // and then you do:\n  //   Open(\"bar/qux\");\n  // the DiskSourceTree will first try to open foo/bar/qux, then baz/bar/qux,\n  // returning the first one that opens successfuly.\n  //\n  // disk_path may be an absolute path or relative to the current directory,\n  // just like a path you'd pass to open().\n  void MapPath(const string& virtual_path, const string& disk_path);\n\n  // Return type for DiskFileToVirtualFile().\n  enum DiskFileToVirtualFileResult {\n    SUCCESS,\n    SHADOWED,\n    CANNOT_OPEN,\n    NO_MAPPING\n  };\n\n  // Given a path to a file on disk, find a virtual path mapping to that\n  // file.  The first mapping created with MapPath() whose disk_path contains\n  // the filename is used.  However, that virtual path may not actually be\n  // usable to open the given file.  Possible return values are:\n  // * SUCCESS: The mapping was found.  *virtual_file is filled in so that\n  //   calling Open(*virtual_file) will open the file named by disk_file.\n  // * SHADOWED: A mapping was found, but using Open() to open this virtual\n  //   path will end up returning some different file.  This is because some\n  //   other mapping with a higher precedence also matches this virtual path\n  //   and maps it to a different file that exists on disk.  *virtual_file\n  //   is filled in as it would be in the SUCCESS case.  *shadowing_disk_file\n  //   is filled in with the disk path of the file which would be opened if\n  //   you were to call Open(*virtual_file).\n  // * CANNOT_OPEN: The mapping was found and was not shadowed, but the\n  //   file specified cannot be opened.  When this value is returned,\n  //   errno will indicate the reason the file cannot be opened.  *virtual_file\n  //   will be set to the virtual path as in the SUCCESS case, even though\n  //   it is not useful.\n  // * NO_MAPPING: Indicates that no mapping was found which contains this\n  //   file.\n  DiskFileToVirtualFileResult\n    DiskFileToVirtualFile(const string& disk_file,\n                          string* virtual_file,\n                          string* shadowing_disk_file);\n\n  // Given a virtual path, find the path to the file on disk.\n  // Return true and update disk_file with the on-disk path if the file exists.\n  // Return false and leave disk_file untouched if the file doesn't exist.\n  bool VirtualFileToDiskFile(const string& virtual_file, string* disk_file);\n\n  // implements SourceTree -------------------------------------------\n  virtual io::ZeroCopyInputStream* Open(const string& filename);\n\n  virtual string GetLastErrorMessage();\n\n private:\n  struct Mapping {\n    string virtual_path;\n    string disk_path;\n\n    inline Mapping(const string& virtual_path_param,\n                   const string& disk_path_param)\n      : virtual_path(virtual_path_param), disk_path(disk_path_param) {}\n  };\n  vector<Mapping> mappings_;\n  string last_error_message_;\n\n  // Like Open(), but returns the on-disk path in disk_file if disk_file is\n  // non-NULL and the file could be successfully opened.\n  io::ZeroCopyInputStream* OpenVirtualFile(const string& virtual_file,\n                                           string* disk_file);\n\n  // Like Open() but given the actual on-disk path.\n  io::ZeroCopyInputStream* OpenDiskFile(const string& filename);\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DiskSourceTree);\n};\n\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_IMPORTER_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/importer_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/importer.h>\n\n#include <google/protobuf/stubs/hash.h>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n#include <google/protobuf/stubs/map_util.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\n\nnamespace {\n\nbool FileExists(const string& path) {\n  return File::Exists(path);\n}\n\n#define EXPECT_SUBSTRING(needle, haystack) \\\n  EXPECT_PRED_FORMAT2(testing::IsSubstring, (needle), (haystack))\n\nclass MockErrorCollector : public MultiFileErrorCollector {\n public:\n  MockErrorCollector() {}\n  ~MockErrorCollector() {}\n\n  string text_;\n  string warning_text_;\n\n  // implements ErrorCollector ---------------------------------------\n  void AddError(const string& filename, int line, int column,\n                const string& message) {\n    strings::SubstituteAndAppend(&text_, \"$0:$1:$2: $3\\n\",\n                                 filename, line, column, message);\n  }\n\n  void AddWarning(const string& filename, int line, int column,\n                  const string& message) {\n    strings::SubstituteAndAppend(&warning_text_, \"$0:$1:$2: $3\\n\",\n                                 filename, line, column, message);\n  }\n};\n\n// -------------------------------------------------------------------\n\n// A dummy implementation of SourceTree backed by a simple map.\nclass MockSourceTree : public SourceTree {\n public:\n  MockSourceTree() {}\n  ~MockSourceTree() {}\n\n  void AddFile(const string& name, const char* contents) {\n    files_[name] = contents;\n  }\n\n  // implements SourceTree -------------------------------------------\n  io::ZeroCopyInputStream* Open(const string& filename) {\n    const char* contents = FindPtrOrNull(files_, filename);\n    if (contents == NULL) {\n      return NULL;\n    } else {\n      return new io::ArrayInputStream(contents, strlen(contents));\n    }\n  }\n\n  string GetLastErrorMessage() {\n    return \"File not found.\";\n  }\n\n private:\n  hash_map<string, const char*> files_;\n};\n\n// ===================================================================\n\nclass ImporterTest : public testing::Test {\n protected:\n  ImporterTest()\n    : importer_(&source_tree_, &error_collector_) {}\n\n  void AddFile(const string& filename, const char* text) {\n    source_tree_.AddFile(filename, text);\n  }\n\n  // Return the collected error text\n  string error() const { return error_collector_.text_; }\n  string warning() const { return error_collector_.warning_text_; }\n\n  MockErrorCollector error_collector_;\n  MockSourceTree source_tree_;\n  Importer importer_;\n};\n\nTEST_F(ImporterTest, Import) {\n  // Test normal importing.\n  AddFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Foo {}\\n\");\n\n  const FileDescriptor* file = importer_.Import(\"foo.proto\");\n  EXPECT_EQ(\"\", error_collector_.text_);\n  ASSERT_TRUE(file != NULL);\n\n  ASSERT_EQ(1, file->message_type_count());\n  EXPECT_EQ(\"Foo\", file->message_type(0)->name());\n\n  // Importing again should return same object.\n  EXPECT_EQ(file, importer_.Import(\"foo.proto\"));\n}\n\nTEST_F(ImporterTest, ImportNested) {\n  // Test that importing a file which imports another file works.\n  AddFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"import \\\"bar.proto\\\";\\n\"\n    \"message Foo {\\n\"\n    \"  optional Bar bar = 1;\\n\"\n    \"}\\n\");\n  AddFile(\"bar.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message Bar {}\\n\");\n\n  // Note that both files are actually parsed by the first call to Import()\n  // here, since foo.proto imports bar.proto.  The second call just returns\n  // the same ProtoFile for bar.proto which was constructed while importing\n  // foo.proto.  We test that this is the case below by checking that bar\n  // is among foo's dependencies (by pointer).\n  const FileDescriptor* foo = importer_.Import(\"foo.proto\");\n  const FileDescriptor* bar = importer_.Import(\"bar.proto\");\n  EXPECT_EQ(\"\", error_collector_.text_);\n  ASSERT_TRUE(foo != NULL);\n  ASSERT_TRUE(bar != NULL);\n\n  // Check that foo's dependency is the same object as bar.\n  ASSERT_EQ(1, foo->dependency_count());\n  EXPECT_EQ(bar, foo->dependency(0));\n\n  // Check that foo properly cross-links bar.\n  ASSERT_EQ(1, foo->message_type_count());\n  ASSERT_EQ(1, bar->message_type_count());\n  ASSERT_EQ(1, foo->message_type(0)->field_count());\n  ASSERT_EQ(FieldDescriptor::TYPE_MESSAGE,\n            foo->message_type(0)->field(0)->type());\n  EXPECT_EQ(bar->message_type(0),\n            foo->message_type(0)->field(0)->message_type());\n}\n\nTEST_F(ImporterTest, FileNotFound) {\n  // Error:  Parsing a file that doesn't exist.\n  EXPECT_TRUE(importer_.Import(\"foo.proto\") == NULL);\n  EXPECT_EQ(\n    \"foo.proto:-1:0: File not found.\\n\",\n    error_collector_.text_);\n}\n\nTEST_F(ImporterTest, ImportNotFound) {\n  // Error:  Importing a file that doesn't exist.\n  AddFile(\"foo.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"import \\\"bar.proto\\\";\\n\");\n\n  EXPECT_TRUE(importer_.Import(\"foo.proto\") == NULL);\n  EXPECT_EQ(\n    \"bar.proto:-1:0: File not found.\\n\"\n    \"foo.proto:-1:0: Import \\\"bar.proto\\\" was not found or had errors.\\n\",\n    error_collector_.text_);\n}\n\nTEST_F(ImporterTest, RecursiveImport) {\n  // Error:  Recursive import.\n  AddFile(\"recursive1.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"import \\\"recursive2.proto\\\";\\n\");\n  AddFile(\"recursive2.proto\",\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"import \\\"recursive1.proto\\\";\\n\");\n\n  EXPECT_TRUE(importer_.Import(\"recursive1.proto\") == NULL);\n  EXPECT_EQ(\n    \"recursive1.proto:-1:0: File recursively imports itself: recursive1.proto \"\n      \"-> recursive2.proto -> recursive1.proto\\n\"\n    \"recursive2.proto:-1:0: Import \\\"recursive1.proto\\\" was not found \"\n      \"or had errors.\\n\"\n    \"recursive1.proto:-1:0: Import \\\"recursive2.proto\\\" was not found \"\n      \"or had errors.\\n\",\n    error_collector_.text_);\n}\n\n\n// ===================================================================\n\nclass DiskSourceTreeTest : public testing::Test {\n protected:\n  virtual void SetUp() {\n    dirnames_.push_back(TestTempDir() + \"/test_proto2_import_path_1\");\n    dirnames_.push_back(TestTempDir() + \"/test_proto2_import_path_2\");\n\n    for (int i = 0; i < dirnames_.size(); i++) {\n      if (FileExists(dirnames_[i])) {\n        File::DeleteRecursively(dirnames_[i], NULL, NULL);\n      }\n      GOOGLE_CHECK_OK(File::CreateDir(dirnames_[i], 0777));\n    }\n  }\n\n  virtual void TearDown() {\n    for (int i = 0; i < dirnames_.size(); i++) {\n      if (FileExists(dirnames_[i])) {\n        File::DeleteRecursively(dirnames_[i], NULL, NULL);\n      }\n    }\n  }\n\n  void AddFile(const string& filename, const char* contents) {\n    GOOGLE_CHECK_OK(File::SetContents(filename, contents, true));\n  }\n\n  void AddSubdir(const string& dirname) {\n    GOOGLE_CHECK_OK(File::CreateDir(dirname, 0777));\n  }\n\n  void ExpectFileContents(const string& filename,\n                          const char* expected_contents) {\n    google::protobuf::scoped_ptr<io::ZeroCopyInputStream> input(source_tree_.Open(filename));\n\n    ASSERT_FALSE(input == NULL);\n\n    // Read all the data from the file.\n    string file_contents;\n    const void* data;\n    int size;\n    while (input->Next(&data, &size)) {\n      file_contents.append(reinterpret_cast<const char*>(data), size);\n    }\n\n    EXPECT_EQ(expected_contents, file_contents);\n  }\n\n  void ExpectCannotOpenFile(const string& filename,\n                            const string& error_message) {\n    google::protobuf::scoped_ptr<io::ZeroCopyInputStream> input(source_tree_.Open(filename));\n    EXPECT_TRUE(input == NULL);\n    EXPECT_EQ(error_message, source_tree_.GetLastErrorMessage());\n  }\n\n  DiskSourceTree source_tree_;\n\n  // Paths of two on-disk directories to use during the test.\n  vector<string> dirnames_;\n};\n\nTEST_F(DiskSourceTreeTest, MapRoot) {\n  // Test opening a file in a directory that is mapped to the root of the\n  // source tree.\n  AddFile(dirnames_[0] + \"/foo\", \"Hello World!\");\n  source_tree_.MapPath(\"\", dirnames_[0]);\n\n  ExpectFileContents(\"foo\", \"Hello World!\");\n  ExpectCannotOpenFile(\"bar\", \"File not found.\");\n}\n\nTEST_F(DiskSourceTreeTest, MapDirectory) {\n  // Test opening a file in a directory that is mapped to somewhere other\n  // than the root of the source tree.\n\n  AddFile(dirnames_[0] + \"/foo\", \"Hello World!\");\n  source_tree_.MapPath(\"baz\", dirnames_[0]);\n\n  ExpectFileContents(\"baz/foo\", \"Hello World!\");\n  ExpectCannotOpenFile(\"baz/bar\", \"File not found.\");\n  ExpectCannotOpenFile(\"foo\", \"File not found.\");\n  ExpectCannotOpenFile(\"bar\", \"File not found.\");\n\n  // Non-canonical file names should not work.\n  ExpectCannotOpenFile(\"baz//foo\",\n                       \"Backslashes, consecutive slashes, \\\".\\\", or \\\"..\\\" are \"\n                       \"not allowed in the virtual path\");\n  ExpectCannotOpenFile(\"baz/../baz/foo\",\n                       \"Backslashes, consecutive slashes, \\\".\\\", or \\\"..\\\" are \"\n                       \"not allowed in the virtual path\");\n  ExpectCannotOpenFile(\"baz/./foo\",\n                       \"Backslashes, consecutive slashes, \\\".\\\", or \\\"..\\\" are \"\n                       \"not allowed in the virtual path\");\n  ExpectCannotOpenFile(\"baz/foo/\", \"File not found.\");\n}\n\nTEST_F(DiskSourceTreeTest, NoParent) {\n  // Test that we cannot open files in a parent of a mapped directory.\n\n  AddFile(dirnames_[0] + \"/foo\", \"Hello World!\");\n  AddSubdir(dirnames_[0] + \"/bar\");\n  AddFile(dirnames_[0] + \"/bar/baz\", \"Blah.\");\n  source_tree_.MapPath(\"\", dirnames_[0] + \"/bar\");\n\n  ExpectFileContents(\"baz\", \"Blah.\");\n  ExpectCannotOpenFile(\"../foo\",\n                       \"Backslashes, consecutive slashes, \\\".\\\", or \\\"..\\\" are \"\n                       \"not allowed in the virtual path\");\n  ExpectCannotOpenFile(\"../bar/baz\",\n                       \"Backslashes, consecutive slashes, \\\".\\\", or \\\"..\\\" are \"\n                       \"not allowed in the virtual path\");\n}\n\nTEST_F(DiskSourceTreeTest, MapFile) {\n  // Test opening a file that is mapped directly into the source tree.\n\n  AddFile(dirnames_[0] + \"/foo\", \"Hello World!\");\n  source_tree_.MapPath(\"foo\", dirnames_[0] + \"/foo\");\n\n  ExpectFileContents(\"foo\", \"Hello World!\");\n  ExpectCannotOpenFile(\"bar\", \"File not found.\");\n}\n\nTEST_F(DiskSourceTreeTest, SearchMultipleDirectories) {\n  // Test mapping and searching multiple directories.\n\n  AddFile(dirnames_[0] + \"/foo\", \"Hello World!\");\n  AddFile(dirnames_[1] + \"/foo\", \"This file should be hidden.\");\n  AddFile(dirnames_[1] + \"/bar\", \"Goodbye World!\");\n  source_tree_.MapPath(\"\", dirnames_[0]);\n  source_tree_.MapPath(\"\", dirnames_[1]);\n\n  ExpectFileContents(\"foo\", \"Hello World!\");\n  ExpectFileContents(\"bar\", \"Goodbye World!\");\n  ExpectCannotOpenFile(\"baz\", \"File not found.\");\n}\n\nTEST_F(DiskSourceTreeTest, OrderingTrumpsSpecificity) {\n  // Test that directories are always searched in order, even when a latter\n  // directory is more-specific than a former one.\n\n  // Create the \"bar\" directory so we can put a file in it.\n  GOOGLE_CHECK_OK(File::CreateDir(dirnames_[0] + \"/bar\", 0777));\n\n  // Add files and map paths.\n  AddFile(dirnames_[0] + \"/bar/foo\", \"Hello World!\");\n  AddFile(dirnames_[1] + \"/foo\", \"This file should be hidden.\");\n  source_tree_.MapPath(\"\", dirnames_[0]);\n  source_tree_.MapPath(\"bar\", dirnames_[1]);\n\n  // Check.\n  ExpectFileContents(\"bar/foo\", \"Hello World!\");\n}\n\nTEST_F(DiskSourceTreeTest, DiskFileToVirtualFile) {\n  // Test DiskFileToVirtualFile.\n\n  AddFile(dirnames_[0] + \"/foo\", \"Hello World!\");\n  AddFile(dirnames_[1] + \"/foo\", \"This file should be hidden.\");\n  source_tree_.MapPath(\"bar\", dirnames_[0]);\n  source_tree_.MapPath(\"bar\", dirnames_[1]);\n\n  string virtual_file;\n  string shadowing_disk_file;\n\n  EXPECT_EQ(DiskSourceTree::NO_MAPPING,\n    source_tree_.DiskFileToVirtualFile(\n      \"/foo\", &virtual_file, &shadowing_disk_file));\n\n  EXPECT_EQ(DiskSourceTree::SHADOWED,\n    source_tree_.DiskFileToVirtualFile(\n      dirnames_[1] + \"/foo\", &virtual_file, &shadowing_disk_file));\n  EXPECT_EQ(\"bar/foo\", virtual_file);\n  EXPECT_EQ(dirnames_[0] + \"/foo\", shadowing_disk_file);\n\n  EXPECT_EQ(DiskSourceTree::CANNOT_OPEN,\n    source_tree_.DiskFileToVirtualFile(\n      dirnames_[1] + \"/baz\", &virtual_file, &shadowing_disk_file));\n  EXPECT_EQ(\"bar/baz\", virtual_file);\n\n  EXPECT_EQ(DiskSourceTree::SUCCESS,\n    source_tree_.DiskFileToVirtualFile(\n      dirnames_[0] + \"/foo\", &virtual_file, &shadowing_disk_file));\n  EXPECT_EQ(\"bar/foo\", virtual_file);\n}\n\nTEST_F(DiskSourceTreeTest, DiskFileToVirtualFileCanonicalization) {\n  // Test handling of \"..\", \".\", etc. in DiskFileToVirtualFile().\n\n  source_tree_.MapPath(\"dir1\", \"..\");\n  source_tree_.MapPath(\"dir2\", \"../../foo\");\n  source_tree_.MapPath(\"dir3\", \"./foo/bar/.\");\n  source_tree_.MapPath(\"dir4\", \".\");\n  source_tree_.MapPath(\"\", \"/qux\");\n  source_tree_.MapPath(\"dir5\", \"/quux/\");\n\n  string virtual_file;\n  string shadowing_disk_file;\n\n  // \"../..\" should not be considered to be under \"..\".\n  EXPECT_EQ(DiskSourceTree::NO_MAPPING,\n    source_tree_.DiskFileToVirtualFile(\n      \"../../baz\", &virtual_file, &shadowing_disk_file));\n\n  // \"/foo\" is not mapped (it should not be misintepreted as being under \".\").\n  EXPECT_EQ(DiskSourceTree::NO_MAPPING,\n    source_tree_.DiskFileToVirtualFile(\n      \"/foo\", &virtual_file, &shadowing_disk_file));\n\n#ifdef WIN32\n  // \"C:\\foo\" is not mapped (it should not be misintepreted as being under \".\").\n  EXPECT_EQ(DiskSourceTree::NO_MAPPING,\n    source_tree_.DiskFileToVirtualFile(\n      \"C:\\\\foo\", &virtual_file, &shadowing_disk_file));\n#endif  // WIN32\n\n  // But \"../baz\" should be.\n  EXPECT_EQ(DiskSourceTree::CANNOT_OPEN,\n    source_tree_.DiskFileToVirtualFile(\n      \"../baz\", &virtual_file, &shadowing_disk_file));\n  EXPECT_EQ(\"dir1/baz\", virtual_file);\n\n  // \"../../foo/baz\" is under \"../../foo\".\n  EXPECT_EQ(DiskSourceTree::CANNOT_OPEN,\n    source_tree_.DiskFileToVirtualFile(\n      \"../../foo/baz\", &virtual_file, &shadowing_disk_file));\n  EXPECT_EQ(\"dir2/baz\", virtual_file);\n\n  // \"foo/./bar/baz\" is under \"./foo/bar/.\".\n  EXPECT_EQ(DiskSourceTree::CANNOT_OPEN,\n    source_tree_.DiskFileToVirtualFile(\n      \"foo/bar/baz\", &virtual_file, &shadowing_disk_file));\n  EXPECT_EQ(\"dir3/baz\", virtual_file);\n\n  // \"bar\" is under \".\".\n  EXPECT_EQ(DiskSourceTree::CANNOT_OPEN,\n    source_tree_.DiskFileToVirtualFile(\n      \"bar\", &virtual_file, &shadowing_disk_file));\n  EXPECT_EQ(\"dir4/bar\", virtual_file);\n\n  // \"/qux/baz\" is under \"/qux\".\n  EXPECT_EQ(DiskSourceTree::CANNOT_OPEN,\n    source_tree_.DiskFileToVirtualFile(\n      \"/qux/baz\", &virtual_file, &shadowing_disk_file));\n  EXPECT_EQ(\"baz\", virtual_file);\n\n  // \"/quux/bar\" is under \"/quux\".\n  EXPECT_EQ(DiskSourceTree::CANNOT_OPEN,\n    source_tree_.DiskFileToVirtualFile(\n      \"/quux/bar\", &virtual_file, &shadowing_disk_file));\n  EXPECT_EQ(\"dir5/bar\", virtual_file);\n}\n\nTEST_F(DiskSourceTreeTest, VirtualFileToDiskFile) {\n  // Test VirtualFileToDiskFile.\n\n  AddFile(dirnames_[0] + \"/foo\", \"Hello World!\");\n  AddFile(dirnames_[1] + \"/foo\", \"This file should be hidden.\");\n  AddFile(dirnames_[1] + \"/quux\", \"This file should not be hidden.\");\n  source_tree_.MapPath(\"bar\", dirnames_[0]);\n  source_tree_.MapPath(\"bar\", dirnames_[1]);\n\n  // Existent files, shadowed and non-shadowed case.\n  string disk_file;\n  EXPECT_TRUE(source_tree_.VirtualFileToDiskFile(\"bar/foo\", &disk_file));\n  EXPECT_EQ(dirnames_[0] + \"/foo\", disk_file);\n  EXPECT_TRUE(source_tree_.VirtualFileToDiskFile(\"bar/quux\", &disk_file));\n  EXPECT_EQ(dirnames_[1] + \"/quux\", disk_file);\n\n  // Nonexistent file in existent directory and vice versa.\n  string not_touched = \"not touched\";\n  EXPECT_FALSE(source_tree_.VirtualFileToDiskFile(\"bar/baz\", &not_touched));\n  EXPECT_EQ(\"not touched\", not_touched);\n  EXPECT_FALSE(source_tree_.VirtualFileToDiskFile(\"baz/foo\", &not_touched));\n  EXPECT_EQ(\"not touched\", not_touched);\n\n  // Accept NULL as output parameter.\n  EXPECT_TRUE(source_tree_.VirtualFileToDiskFile(\"bar/foo\", NULL));\n  EXPECT_FALSE(source_tree_.VirtualFileToDiskFile(\"baz/foo\", NULL));\n}\n\n}  // namespace\n\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_context.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/compiler/java/java_context.h>\n\n#include <google/protobuf/compiler/java/java_field.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/map_util.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nContext::Context(const FileDescriptor* file, const Options& options)\n    : name_resolver_(new ClassNameResolver), options_(options) {\n  InitializeFieldGeneratorInfo(file);\n}\n\nContext::~Context() {\n}\n\nClassNameResolver* Context::GetNameResolver() {\n  return name_resolver_.get();\n}\n\nnamespace {\n// Whether two fields have conflicting accessors (assuming name1 and name2\n// are different). name1 and name2 are field1 and field2's camel-case name\n// respectively.\nbool IsConflicting(const FieldDescriptor* field1, const string& name1,\n                   const FieldDescriptor* field2, const string& name2,\n                   string* info) {\n  if (field1->is_repeated()) {\n    if (field2->is_repeated()) {\n      // Both fields are repeated.\n      return false;\n    } else {\n      // field1 is repeated, and field2 is not.\n      if (name1 + \"Count\" == name2) {\n        *info = \"both repeated field \\\"\" + field1->name() + \"\\\" and singular \" +\n            \"field \\\"\" + field2->name() + \"\\\" generates the method \\\"\" +\n            \"get\" + name1 + \"Count()\\\"\";\n        return true;\n      }\n      if (name1 + \"List\" == name2) {\n        *info = \"both repeated field \\\"\" + field1->name() + \"\\\" and singular \" +\n            \"field \\\"\" + field2->name() + \"\\\" generates the method \\\"\" +\n            \"get\" + name1 + \"List()\\\"\";\n        return true;\n      }\n      // Well, there are obviously many more conflicting cases, but it probably\n      // doesn't worth the effort to exhaust all of them because they rarely\n      // happen and as we are continuing adding new methods/changing existing\n      // methods the number of different conflicting cases will keep growing.\n      // We can just add more cases here when they are found in the real world.\n      return false;\n    }\n  } else {\n    if (field2->is_repeated()) {\n      return IsConflicting(field2, name2, field1, name1, info);\n    } else {\n      // None of the two fields are repeated.\n      return false;\n    }\n  }\n}\n}  // namespace\n\nvoid Context::InitializeFieldGeneratorInfo(const FileDescriptor* file) {\n  for (int i = 0; i < file->message_type_count(); ++i) {\n    InitializeFieldGeneratorInfoForMessage(file->message_type(i));\n  }\n}\n\nvoid Context::InitializeFieldGeneratorInfoForMessage(\n    const Descriptor* message) {\n  for (int i = 0; i < message->nested_type_count(); ++i) {\n    InitializeFieldGeneratorInfoForMessage(message->nested_type(i));\n  }\n  vector<const FieldDescriptor*> fields;\n  for (int i = 0; i < message->field_count(); ++i) {\n    fields.push_back(message->field(i));\n  }\n  InitializeFieldGeneratorInfoForFields(fields);\n\n  for (int i = 0; i < message->oneof_decl_count(); ++i) {\n    const OneofDescriptor* oneof = message->oneof_decl(i);\n    OneofGeneratorInfo info;\n    info.name = UnderscoresToCamelCase(oneof->name(), false);\n    info.capitalized_name = UnderscoresToCamelCase(oneof->name(), true);\n    oneof_generator_info_map_[oneof] = info;\n  }\n}\n\nvoid Context::InitializeFieldGeneratorInfoForFields(\n    const vector<const FieldDescriptor*>& fields) {\n  // Find out all fields that conflict with some other field in the same\n  // message.\n  vector<bool> is_conflict(fields.size());\n  vector<string> conflict_reason(fields.size());\n  for (int i = 0; i < fields.size(); ++i) {\n    const FieldDescriptor* field = fields[i];\n    const string& name = UnderscoresToCapitalizedCamelCase(field);\n    for (int j = i + 1; j < fields.size(); ++j) {\n      const FieldDescriptor* other = fields[j];\n      const string& other_name = UnderscoresToCapitalizedCamelCase(other);\n      if (name == other_name) {\n        is_conflict[i] = is_conflict[j] = true;\n        conflict_reason[i] = conflict_reason[j] =\n            \"capitalized name of field \\\"\" + field->name() +\n            \"\\\" conflicts with field \\\"\" + other->name() + \"\\\"\";\n      } else if (IsConflicting(field, name, other, other_name,\n                               &conflict_reason[j])) {\n        is_conflict[i] = is_conflict[j] = true;\n        conflict_reason[i] = conflict_reason[j];\n      }\n    }\n    if (is_conflict[i]) {\n      GOOGLE_LOG(WARNING) << \"field \\\"\" << field->full_name() << \"\\\" is conflicting \"\n                   << \"with another field: \" << conflict_reason[i];\n    }\n  }\n  for (int i = 0; i < fields.size(); ++i) {\n    const FieldDescriptor* field = fields[i];\n    FieldGeneratorInfo info;\n    info.name = UnderscoresToCamelCase(field);\n    info.capitalized_name = UnderscoresToCapitalizedCamelCase(field);\n    // For fields conflicting with some other fields, we append the field\n    // number to their field names in generated code to avoid conflicts.\n    if (is_conflict[i]) {\n      info.name += SimpleItoa(field->number());\n      info.capitalized_name += SimpleItoa(field->number());\n      info.disambiguated_reason = conflict_reason[i];\n    }\n    field_generator_info_map_[field] = info;\n  }\n}\n\nconst FieldGeneratorInfo* Context::GetFieldGeneratorInfo(\n    const FieldDescriptor* field) const {\n  const FieldGeneratorInfo* result =\n      FindOrNull(field_generator_info_map_, field);\n  if (result == NULL) {\n    GOOGLE_LOG(FATAL) << \"Can not find FieldGeneratorInfo for field: \"\n               << field->full_name();\n  }\n  return result;\n}\n\nconst OneofGeneratorInfo* Context::GetOneofGeneratorInfo(\n    const OneofDescriptor* oneof) const {\n  const OneofGeneratorInfo* result =\n      FindOrNull(oneof_generator_info_map_, oneof);\n  if (result == NULL) {\n    GOOGLE_LOG(FATAL) << \"Can not find OneofGeneratorInfo for oneof: \"\n               << oneof->name();\n  }\n  return result;\n}\n\n// Does this message class have generated parsing, serialization, and other\n// standard methods for which reflection-based fallback implementations exist?\nbool Context::HasGeneratedMethods(const Descriptor* descriptor) const {\n  return options_.enforce_lite ||\n         descriptor->file()->options().optimize_for() != FileOptions::CODE_SIZE;\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_context.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_CONTEXT_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_CONTEXT_H__\n\n#include <map>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <vector>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/compiler/java/java_options.h>\n\nnamespace google {\nnamespace protobuf {\n  class FileDescriptor;\n  class FieldDescriptor;\n  class OneofDescriptor;\n  class Descriptor;\n  class EnumDescriptor;\n  namespace compiler {\n    namespace java {\n      class ClassNameResolver;  // name_resolver.h\n    }\n  }\n}  // namespace protobuf\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nstruct FieldGeneratorInfo;\nstruct OneofGeneratorInfo;\n// A context object holds the information that is shared among all code\n// generators.\nclass Context {\n public:\n  Context(const FileDescriptor* file, const Options& options);\n  ~Context();\n\n  // Get the name resolver associated with this context. The resolver\n  // can be used to map descriptors to Java class names.\n  ClassNameResolver* GetNameResolver();\n\n  // Get the FieldGeneratorInfo for a given field.\n  const FieldGeneratorInfo* GetFieldGeneratorInfo(\n      const FieldDescriptor* field) const;\n\n  // Get the OneofGeneratorInfo for a given oneof.\n  const OneofGeneratorInfo* GetOneofGeneratorInfo(\n      const OneofDescriptor* oneof) const;\n\n  const Options& options() const { return options_; }\n\n  // Enforces all the files (including transitive dependencies) to use\n  // LiteRuntime.\n\n  bool EnforceLite() const { return options_.enforce_lite; }\n\n  // Does this message class have generated parsing, serialization, and other\n  // standard methods for which reflection-based fallback implementations exist?\n  bool HasGeneratedMethods(const Descriptor* descriptor) const;\n\n private:\n  void InitializeFieldGeneratorInfo(const FileDescriptor* file);\n  void InitializeFieldGeneratorInfoForMessage(const Descriptor* message);\n  void InitializeFieldGeneratorInfoForFields(\n      const vector<const FieldDescriptor*>& fields);\n\n  google::protobuf::scoped_ptr<ClassNameResolver> name_resolver_;\n  map<const FieldDescriptor*, FieldGeneratorInfo> field_generator_info_map_;\n  map<const OneofDescriptor*, OneofGeneratorInfo> oneof_generator_info_map_;\n  Options options_;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Context);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_CONTEXT_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_doc_comment.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n\n#include <vector>\n\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nstring EscapeJavadoc(const string& input) {\n  string result;\n  result.reserve(input.size() * 2);\n\n  char prev = '*';\n\n  for (string::size_type i = 0; i < input.size(); i++) {\n    char c = input[i];\n    switch (c) {\n      case '*':\n        // Avoid \"/*\".\n        if (prev == '/') {\n          result.append(\"&#42;\");\n        } else {\n          result.push_back(c);\n        }\n        break;\n      case '/':\n        // Avoid \"*/\".\n        if (prev == '*') {\n          result.append(\"&#47;\");\n        } else {\n          result.push_back(c);\n        }\n        break;\n      case '@':\n        // '@' starts javadoc tags including the @deprecated tag, which will\n        // cause a compile-time error if inserted before a declaration that\n        // does not have a corresponding @Deprecated annotation.\n        result.append(\"&#64;\");\n        break;\n      case '<':\n        // Avoid interpretation as HTML.\n        result.append(\"&lt;\");\n        break;\n      case '>':\n        // Avoid interpretation as HTML.\n        result.append(\"&gt;\");\n        break;\n      case '&':\n        // Avoid interpretation as HTML.\n        result.append(\"&amp;\");\n        break;\n      case '\\\\':\n        // Java interprets Unicode escape sequences anywhere!\n        result.append(\"&#92;\");\n        break;\n      default:\n        result.push_back(c);\n        break;\n    }\n\n    prev = c;\n  }\n\n  return result;\n}\n\nstatic void WriteDocCommentBodyForLocation(\n    io::Printer* printer, const SourceLocation& location) {\n  string comments = location.leading_comments.empty() ?\n      location.trailing_comments : location.leading_comments;\n  if (!comments.empty()) {\n    // TODO(kenton):  Ideally we should parse the comment text as Markdown and\n    //   write it back as HTML, but this requires a Markdown parser.  For now\n    //   we just use <pre> to get fixed-width text formatting.\n\n    // If the comment itself contains block comment start or end markers,\n    // HTML-escape them so that they don't accidentally close the doc comment.\n    comments = EscapeJavadoc(comments);\n\n    vector<string> lines = Split(comments, \"\\n\");\n    while (!lines.empty() && lines.back().empty()) {\n      lines.pop_back();\n    }\n\n    printer->Print(\" * <pre>\\n\");\n    for (int i = 0; i < lines.size(); i++) {\n      // Most lines should start with a space.  Watch out for lines that start\n      // with a /, since putting that right after the leading asterisk will\n      // close the comment.\n      if (!lines[i].empty() && lines[i][0] == '/') {\n        printer->Print(\" * $line$\\n\", \"line\", lines[i]);\n      } else {\n        printer->Print(\" *$line$\\n\", \"line\", lines[i]);\n      }\n    }\n    printer->Print(\n        \" * </pre>\\n\"\n        \" *\\n\");\n  }\n}\n\ntemplate <typename DescriptorType>\nstatic void WriteDocCommentBody(\n    io::Printer* printer, const DescriptorType* descriptor) {\n  SourceLocation location;\n  if (descriptor->GetSourceLocation(&location)) {\n    WriteDocCommentBodyForLocation(printer, location);\n  }\n}\n\nstatic string FirstLineOf(const string& value) {\n  string result = value;\n\n  string::size_type pos = result.find_first_of('\\n');\n  if (pos != string::npos) {\n    result.erase(pos);\n  }\n\n  // If line ends in an opening brace, make it \"{ ... }\" so it looks nice.\n  if (!result.empty() && result[result.size() - 1] == '{') {\n    result.append(\" ... }\");\n  }\n\n  return result;\n}\n\nvoid WriteMessageDocComment(io::Printer* printer, const Descriptor* message) {\n  printer->Print(\"/**\\n\");\n  WriteDocCommentBody(printer, message);\n  printer->Print(\n    \" * Protobuf type {@code $fullname$}\\n\"\n    \" */\\n\",\n    \"fullname\", EscapeJavadoc(message->full_name()));\n}\n\nvoid WriteFieldDocComment(io::Printer* printer, const FieldDescriptor* field) {\n  // In theory we should have slightly different comments for setters, getters,\n  // etc., but in practice everyone already knows the difference between these\n  // so it's redundant information.\n\n  // We start the comment with the main body based on the comments from the\n  // .proto file (if present). We then end with the field declaration, e.g.:\n  //   optional string foo = 5;\n  // If the field is a group, the debug string might end with {.\n  printer->Print(\"/**\\n\");\n  WriteDocCommentBody(printer, field);\n  printer->Print(\n    \" * <code>$def$</code>\\n\",\n    \"def\", EscapeJavadoc(FirstLineOf(field->DebugString())));\n  printer->Print(\" */\\n\");\n}\n\nvoid WriteEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_) {\n  printer->Print(\"/**\\n\");\n  WriteDocCommentBody(printer, enum_);\n  printer->Print(\n    \" * Protobuf enum {@code $fullname$}\\n\"\n    \" */\\n\",\n    \"fullname\", EscapeJavadoc(enum_->full_name()));\n}\n\nvoid WriteEnumValueDocComment(io::Printer* printer,\n                              const EnumValueDescriptor* value) {\n  printer->Print(\"/**\\n\");\n  WriteDocCommentBody(printer, value);\n  printer->Print(\n    \" * <code>$def$</code>\\n\"\n    \" */\\n\",\n    \"def\", EscapeJavadoc(FirstLineOf(value->DebugString())));\n}\n\nvoid WriteServiceDocComment(io::Printer* printer,\n                            const ServiceDescriptor* service) {\n  printer->Print(\"/**\\n\");\n  WriteDocCommentBody(printer, service);\n  printer->Print(\n    \" * Protobuf service {@code $fullname$}\\n\"\n    \" */\\n\",\n    \"fullname\", EscapeJavadoc(service->full_name()));\n}\n\nvoid WriteMethodDocComment(io::Printer* printer,\n                           const MethodDescriptor* method) {\n  printer->Print(\"/**\\n\");\n  WriteDocCommentBody(printer, method);\n  printer->Print(\n    \" * <code>$def$</code>\\n\"\n    \" */\\n\",\n    \"def\", EscapeJavadoc(FirstLineOf(method->DebugString())));\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_doc_comment.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_DOC_COMMENT_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_DOC_COMMENT_H__\n\n#include <google/protobuf/descriptor.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace io {\n    class Printer;             // printer.h\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nvoid WriteMessageDocComment(io::Printer* printer, const Descriptor* message);\nvoid WriteFieldDocComment(io::Printer* printer, const FieldDescriptor* field);\nvoid WriteEnumDocComment(io::Printer* printer, const EnumDescriptor* enum_);\nvoid WriteEnumValueDocComment(io::Printer* printer,\n                              const EnumValueDescriptor* value);\nvoid WriteServiceDocComment(io::Printer* printer,\n                            const ServiceDescriptor* service);\nvoid WriteMethodDocComment(io::Printer* printer,\n                           const MethodDescriptor* method);\n\n// Exposed for testing only.\nLIBPROTOC_EXPORT string EscapeJavadoc(const string& input);\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_DOC_COMMENT_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_doc_comment_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\nnamespace {\n\nTEST(JavaDocCommentTest, Escaping) {\n  EXPECT_EQ(\"foo /&#42; bar *&#47; baz\", EscapeJavadoc(\"foo /* bar */ baz\"));\n  EXPECT_EQ(\"foo /&#42;&#47; baz\", EscapeJavadoc(\"foo /*/ baz\"));\n  EXPECT_EQ(\"{&#64;foo}\", EscapeJavadoc(\"{@foo}\"));\n  EXPECT_EQ(\"&lt;i&gt;&amp;&lt;/i&gt;\", EscapeJavadoc(\"<i>&</i>\"));\n  EXPECT_EQ(\"foo&#92;u1234bar\", EscapeJavadoc(\"foo\\\\u1234bar\"));\n  EXPECT_EQ(\"&#64;deprecated\", EscapeJavadoc(\"@deprecated\"));\n}\n\n// TODO(kenton):  It's hard to write a robust test of the doc comments -- we\n//   can only really compare the output against a golden value, which is a\n//   fairly tedious and fragile testing strategy.  If we want to go that route,\n//   it probably makes sense to bite the bullet and write a test that compares\n//   the whole generated output for unittest.proto against a golden value, with\n//   a very simple script that can be run to regenerate it with the latest code.\n//   This would mean that updates to the golden file would have to be included\n//   in any change to the code generator, which would actually be fairly useful\n//   as it allows the reviewer to see clearly how the generated code is\n//   changing.\n\n}  // namespace\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_enum.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_enum.h>\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nnamespace {\nbool EnumHasCustomOptions(const EnumDescriptor* descriptor) {\n  if (descriptor->options().unknown_fields().field_count() > 0) return true;\n  for (int i = 0; i < descriptor->value_count(); ++i) {\n    const EnumValueDescriptor* value = descriptor->value(i);\n    if (value->options().unknown_fields().field_count() > 0) return true;\n  }\n  return false;\n}\n}  // namespace\n\nEnumGenerator::EnumGenerator(const EnumDescriptor* descriptor,\n                             bool immutable_api,\n                             Context* context)\n  : descriptor_(descriptor), immutable_api_(immutable_api),\n    context_(context),\n    name_resolver_(context->GetNameResolver())  {\n  for (int i = 0; i < descriptor_->value_count(); i++) {\n    const EnumValueDescriptor* value = descriptor_->value(i);\n    const EnumValueDescriptor* canonical_value =\n      descriptor_->FindValueByNumber(value->number());\n\n    if (value == canonical_value) {\n      canonical_values_.push_back(value);\n    } else {\n      Alias alias;\n      alias.value = value;\n      alias.canonical_value = canonical_value;\n      aliases_.push_back(alias);\n    }\n  }\n}\n\nEnumGenerator::~EnumGenerator() {}\n\nvoid EnumGenerator::Generate(io::Printer* printer) {\n  WriteEnumDocComment(printer, descriptor_);\n  MaybePrintGeneratedAnnotation(context_, printer, descriptor_, immutable_api_);\n  printer->Print(\n      \"public enum $classname$\\n\"\n      \"    implements com.google.protobuf.ProtocolMessageEnum {\\n\",\n      \"classname\", descriptor_->name());\n  printer->Annotate(\"classname\", descriptor_);\n  printer->Indent();\n\n  bool ordinal_is_index = true;\n  string index_text = \"ordinal()\";\n  for (int i = 0; i < canonical_values_.size(); i++) {\n    if (canonical_values_[i]->index() != i) {\n      ordinal_is_index = false;\n      index_text = \"index\";\n      break;\n    }\n  }\n\n  for (int i = 0; i < canonical_values_.size(); i++) {\n    map<string, string> vars;\n    vars[\"name\"] = canonical_values_[i]->name();\n    vars[\"index\"] = SimpleItoa(canonical_values_[i]->index());\n    vars[\"number\"] = SimpleItoa(canonical_values_[i]->number());\n    WriteEnumValueDocComment(printer, canonical_values_[i]);\n    if (canonical_values_[i]->options().deprecated()) {\n      printer->Print(\"@java.lang.Deprecated\\n\");\n    }\n    if (ordinal_is_index) {\n      printer->Print(vars,\n        \"$name$($number$),\\n\");\n    } else {\n      printer->Print(vars,\n        \"$name$($index$, $number$),\\n\");\n    }\n  }\n\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    if (ordinal_is_index) {\n      printer->Print(\"UNRECOGNIZED(-1),\\n\");\n    } else {\n      printer->Print(\"UNRECOGNIZED(-1, -1),\\n\");\n    }\n  }\n\n  printer->Print(\n    \";\\n\"\n    \"\\n\");\n\n  // -----------------------------------------------------------------\n\n  for (int i = 0; i < aliases_.size(); i++) {\n    map<string, string> vars;\n    vars[\"classname\"] = descriptor_->name();\n    vars[\"name\"] = aliases_[i].value->name();\n    vars[\"canonical_name\"] = aliases_[i].canonical_value->name();\n    WriteEnumValueDocComment(printer, aliases_[i].value);\n    printer->Print(vars,\n      \"public static final $classname$ $name$ = $canonical_name$;\\n\");\n  }\n\n  for (int i = 0; i < descriptor_->value_count(); i++) {\n    map<string, string> vars;\n    vars[\"name\"] = descriptor_->value(i)->name();\n    vars[\"number\"] = SimpleItoa(descriptor_->value(i)->number());\n    WriteEnumValueDocComment(printer, descriptor_->value(i));\n    printer->Print(vars,\n      \"public static final int $name$_VALUE = $number$;\\n\");\n  }\n  printer->Print(\"\\n\");\n\n  // -----------------------------------------------------------------\n\n  printer->Print(\n    \"\\n\"\n    \"public final int getNumber() {\\n\");\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    if (ordinal_is_index) {\n      printer->Print(\n        \"  if (this == UNRECOGNIZED) {\\n\"\n        \"    throw new java.lang.IllegalArgumentException(\\n\"\n        \"        \\\"Can't get the number of an unknown enum value.\\\");\\n\"\n        \"  }\\n\");\n    } else {\n      printer->Print(\n        \"  if (index == -1) {\\n\"\n        \"    throw new java.lang.IllegalArgumentException(\\n\"\n        \"        \\\"Can't get the number of an unknown enum value.\\\");\\n\"\n        \"  }\\n\");\n    }\n  }\n  printer->Print(\n    \"  return value;\\n\"\n    \"}\\n\"\n    \"\\n\"\n    \"/**\\n\"\n    \" * @deprecated Use {@link #forNumber(int)} instead.\\n\"\n    \" */\\n\"\n    \"@java.lang.Deprecated\\n\"\n    \"public static $classname$ valueOf(int value) {\\n\"\n    \"  return forNumber(value);\\n\"\n    \"}\\n\"\n    \"\\n\"\n    \"public static $classname$ forNumber(int value) {\\n\"\n    \"  switch (value) {\\n\",\n    \"classname\", descriptor_->name());\n  printer->Indent();\n  printer->Indent();\n\n  for (int i = 0; i < canonical_values_.size(); i++) {\n    printer->Print(\n      \"case $number$: return $name$;\\n\",\n      \"name\", canonical_values_[i]->name(),\n      \"number\", SimpleItoa(canonical_values_[i]->number()));\n  }\n\n  printer->Outdent();\n  printer->Outdent();\n  printer->Print(\n    \"    default: return null;\\n\"\n    \"  }\\n\"\n    \"}\\n\"\n    \"\\n\"\n    \"public static com.google.protobuf.Internal.EnumLiteMap<$classname$>\\n\"\n    \"    internalGetValueMap() {\\n\"\n    \"  return internalValueMap;\\n\"\n    \"}\\n\"\n    \"private static final com.google.protobuf.Internal.EnumLiteMap<\\n\"\n    \"    $classname$> internalValueMap =\\n\"\n    \"      new com.google.protobuf.Internal.EnumLiteMap<$classname$>() {\\n\"\n    \"        public $classname$ findValueByNumber(int number) {\\n\"\n    \"          return $classname$.forNumber(number);\\n\"\n    \"        }\\n\"\n    \"      };\\n\"\n    \"\\n\",\n    \"classname\", descriptor_->name());\n\n  // -----------------------------------------------------------------\n  // Reflection\n\n  if (HasDescriptorMethods(descriptor_, context_->EnforceLite())) {\n    printer->Print(\n      \"public final com.google.protobuf.Descriptors.EnumValueDescriptor\\n\"\n      \"    getValueDescriptor() {\\n\"\n      \"  return getDescriptor().getValues().get($index_text$);\\n\"\n      \"}\\n\"\n      \"public final com.google.protobuf.Descriptors.EnumDescriptor\\n\"\n      \"    getDescriptorForType() {\\n\"\n      \"  return getDescriptor();\\n\"\n      \"}\\n\"\n      \"public static final com.google.protobuf.Descriptors.EnumDescriptor\\n\"\n      \"    getDescriptor() {\\n\",\n      \"index_text\", index_text);\n\n    // TODO(kenton):  Cache statically?  Note that we can't access descriptors\n    //   at module init time because it wouldn't work with descriptor.proto, but\n    //   we can cache the value the first time getDescriptor() is called.\n    if (descriptor_->containing_type() == NULL) {\n      if (!MultipleJavaFiles(descriptor_->file(), immutable_api_)) {\n        printer->Print(\n          \"  return $file$.getDescriptor().getEnumTypes().get($index$);\\n\",\n          \"file\", name_resolver_->GetClassName(descriptor_->file(),\n                                               immutable_api_),\n          \"index\", SimpleItoa(descriptor_->index()));\n      } else {\n        printer->Indent();\n        if (EnumHasCustomOptions(descriptor_)) {\n          // We need to load the immutable classes in order to parse custom\n          // options. However, since file level enums (no outer class) are\n          // shared by immutable code and mutable code, the immutable classes\n          // may not exist. So we try to use Java reflection to retrieve the\n          // descriptor from immutable classes.\n          printer->Print(\n            \"try {\\n\"\n            \"  java.lang.Class immutableFileClass =\\n\"\n            \"      java.lang.Class.forName(\\\"$immutable_file_class_name$\\\");\\n\"\n            \"  @java.lang.SuppressWarnings(\\\"unchecked\\\")\\n\"\n            \"  java.lang.reflect.Method m =\\n\"\n            \"      immutableFileClass.getMethod(\\\"getDescriptor\\\");\\n\"\n            \"  com.google.protobuf.Descriptors.FileDescriptor file =\\n\"\n            \"      (com.google.protobuf.Descriptors.FileDescriptor)\\n\"\n            \"          m.invoke(immutableFileClass);\\n\"\n            \"  return file.getEnumTypes().get($index$);\\n\"\n            \"} catch (java.lang.Exception e) {\\n\"\n            // Immutable classes cannot be found. Proceed as if custom options\n            // don't exist.\n            \"}\\n\",\n            \"immutable_file_class_name\",\n            name_resolver_->GetImmutableClassName(descriptor_->file()),\n            \"index\", SimpleItoa(descriptor_->index()));\n        }\n        printer->Print(\n          \"return $immutable_package$.$descriptor_class$.$descriptor$\\n\"\n          \"    .getEnumTypes().get($index$);\\n\",\n          \"immutable_package\", FileJavaPackage(descriptor_->file(), true),\n          \"descriptor_class\",\n          name_resolver_->GetDescriptorClassName(descriptor_->file()),\n          \"descriptor\", \"getDescriptor()\",\n          \"index\", SimpleItoa(descriptor_->index()));\n        printer->Outdent();\n      }\n    } else {\n      printer->Print(\n          \"  return $parent$.$descriptor$.getEnumTypes().get($index$);\\n\",\n          \"parent\", name_resolver_->GetClassName(descriptor_->containing_type(),\n                                                 immutable_api_),\n          \"descriptor\", descriptor_->containing_type()->options()\n                        .no_standard_descriptor_accessor()\n                        ? \"getDefaultInstance().getDescriptorForType()\"\n                        : \"getDescriptor()\",\n          \"index\", SimpleItoa(descriptor_->index()));\n    }\n\n    printer->Print(\n      \"}\\n\"\n      \"\\n\"\n      \"private static final $classname$[] VALUES = \",\n      \"classname\", descriptor_->name());\n\n    if (CanUseEnumValues()) {\n      // If the constants we are going to output are exactly the ones we\n      // have declared in the Java enum in the same order, then we can use\n      // the values() method that the Java compiler automatically generates\n      // for every enum.\n      printer->Print(\"values();\\n\");\n    } else {\n      printer->Print(\n        \"{\\n\"\n        \"  \");\n      for (int i = 0; i < descriptor_->value_count(); i++) {\n        printer->Print(\"$name$, \",\n          \"name\", descriptor_->value(i)->name());\n      }\n      printer->Print(\n          \"\\n\"\n          \"};\\n\");\n    }\n\n    printer->Print(\n      \"\\n\"\n      \"public static $classname$ valueOf(\\n\"\n      \"    com.google.protobuf.Descriptors.EnumValueDescriptor desc) {\\n\"\n      \"  if (desc.getType() != getDescriptor()) {\\n\"\n      \"    throw new java.lang.IllegalArgumentException(\\n\"\n      \"      \\\"EnumValueDescriptor is not for this type.\\\");\\n\"\n      \"  }\\n\",\n      \"classname\", descriptor_->name());\n    if (SupportUnknownEnumValue(descriptor_->file())) {\n      printer->Print(\n        \"  if (desc.getIndex() == -1) {\\n\"\n        \"    return UNRECOGNIZED;\\n\"\n        \"  }\\n\");\n    }\n    printer->Print(\n      \"  return VALUES[desc.getIndex()];\\n\"\n      \"}\\n\"\n      \"\\n\");\n\n    if (!ordinal_is_index) {\n      printer->Print(\"private final int index;\\n\");\n    }\n  }\n\n  // -----------------------------------------------------------------\n\n  printer->Print(\n    \"private final int value;\\n\\n\");\n\n  if (ordinal_is_index) {\n    printer->Print(\n      \"private $classname$(int value) {\\n\",\n      \"classname\", descriptor_->name());\n  } else {\n    printer->Print(\n      \"private $classname$(int index, int value) {\\n\",\n      \"classname\", descriptor_->name());\n  }\n  if (HasDescriptorMethods(descriptor_, context_->EnforceLite()) &&\n      !ordinal_is_index) {\n    printer->Print(\"  this.index = index;\\n\");\n  }\n  printer->Print(\n    \"  this.value = value;\\n\"\n    \"}\\n\");\n\n  printer->Print(\n    \"\\n\"\n    \"// @@protoc_insertion_point(enum_scope:$full_name$)\\n\",\n    \"full_name\", descriptor_->full_name());\n\n  printer->Outdent();\n  printer->Print(\"}\\n\\n\");\n}\n\nbool EnumGenerator::CanUseEnumValues() {\n  if (canonical_values_.size() != descriptor_->value_count()) {\n    return false;\n  }\n  for (int i = 0; i < descriptor_->value_count(); i++) {\n    if (descriptor_->value(i)->name() != canonical_values_[i]->name()) {\n      return false;\n    }\n  }\n  return true;\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_enum.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_H__\n\n#include <string>\n#include <vector>\n#include <google/protobuf/descriptor.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace compiler {\n    namespace java {\n      class Context;           // context.h\n      class ClassNameResolver; // name_resolver.h\n    }\n  }\n  namespace io {\n    class Printer;             // printer.h\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nclass EnumGenerator {\n public:\n  EnumGenerator(const EnumDescriptor* descriptor, bool immutable_api,\n                Context* context);\n  ~EnumGenerator();\n\n  void Generate(io::Printer* printer);\n\n private:\n  const EnumDescriptor* descriptor_;\n\n  // The proto language allows multiple enum constants to have the same numeric\n  // value.  Java, however, does not allow multiple enum constants to be\n  // considered equivalent.  We treat the first defined constant for any\n  // given numeric value as \"canonical\" and the rest as aliases of that\n  // canonical value.\n  vector<const EnumValueDescriptor*> canonical_values_;\n\n  struct Alias {\n    const EnumValueDescriptor* value;\n    const EnumValueDescriptor* canonical_value;\n  };\n  vector<Alias> aliases_;\n\n  bool immutable_api_;\n\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n\n  bool CanUseEnumValues();\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_enum_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n#include <google/protobuf/compiler/java/java_enum_field.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nnamespace {\n\nvoid SetEnumVariables(const FieldDescriptor* descriptor,\n                      int messageBitIndex,\n                      int builderBitIndex,\n                      const FieldGeneratorInfo* info,\n                      ClassNameResolver* name_resolver,\n                      map<string, string>* variables) {\n  SetCommonFieldVariables(descriptor, info, variables);\n\n  (*variables)[\"type\"] =\n      name_resolver->GetImmutableClassName(descriptor->enum_type());\n  (*variables)[\"mutable_type\"] =\n      name_resolver->GetMutableClassName(descriptor->enum_type());\n  (*variables)[\"default\"] = ImmutableDefaultValue(descriptor, name_resolver);\n  (*variables)[\"default_number\"] = SimpleItoa(\n      descriptor->default_value_enum()->number());\n  (*variables)[\"tag\"] = SimpleItoa(internal::WireFormat::MakeTag(descriptor));\n  (*variables)[\"tag_size\"] = SimpleItoa(\n      internal::WireFormat::TagSize(descriptor->number(), GetType(descriptor)));\n  // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported\n  // by the proto compiler\n  (*variables)[\"deprecation\"] = descriptor->options().deprecated()\n      ? \"@java.lang.Deprecated \" : \"\";\n  (*variables)[\"on_changed\"] = \"onChanged();\";\n  // Use deprecated valueOf() method to be compatible with old generated code\n  // for v2.5.0/v2.6.1.\n  // TODO(xiaofeng): Use \"forNumber\" when we no longer support compatibility\n  // with v2.5.0/v2.6.1.\n  (*variables)[\"for_number\"] = \"valueOf\";\n\n  if (SupportFieldPresence(descriptor->file())) {\n    // For singular messages and builders, one bit is used for the hasField bit.\n    (*variables)[\"get_has_field_bit_message\"] = GenerateGetBit(messageBitIndex);\n    (*variables)[\"get_has_field_bit_builder\"] = GenerateGetBit(builderBitIndex);\n\n    // Note that these have a trailing \";\".\n    (*variables)[\"set_has_field_bit_message\"] =\n        GenerateSetBit(messageBitIndex) + \";\";\n    (*variables)[\"set_has_field_bit_builder\"] =\n        GenerateSetBit(builderBitIndex) + \";\";\n    (*variables)[\"clear_has_field_bit_builder\"] =\n        GenerateClearBit(builderBitIndex) + \";\";\n\n    (*variables)[\"is_field_present_message\"] = GenerateGetBit(messageBitIndex);\n  } else {\n    (*variables)[\"set_has_field_bit_message\"] = \"\";\n    (*variables)[\"set_has_field_bit_builder\"] = \"\";\n    (*variables)[\"clear_has_field_bit_builder\"] = \"\";\n\n    (*variables)[\"is_field_present_message\"] =\n        (*variables)[\"name\"] + \"_ != \" +\n        (*variables)[\"default\"] + \".getNumber()\";\n  }\n\n  // For repated builders, one bit is used for whether the array is immutable.\n  (*variables)[\"get_mutable_bit_builder\"] = GenerateGetBit(builderBitIndex);\n  (*variables)[\"set_mutable_bit_builder\"] = GenerateSetBit(builderBitIndex);\n  (*variables)[\"clear_mutable_bit_builder\"] = GenerateClearBit(builderBitIndex);\n\n  // For repeated fields, one bit is used for whether the array is immutable\n  // in the parsing constructor.\n  (*variables)[\"get_mutable_bit_parser\"] =\n      GenerateGetBitMutableLocal(builderBitIndex);\n  (*variables)[\"set_mutable_bit_parser\"] =\n      GenerateSetBitMutableLocal(builderBitIndex);\n\n  (*variables)[\"get_has_field_bit_from_local\"] =\n      GenerateGetBitFromLocal(builderBitIndex);\n  (*variables)[\"set_has_field_bit_to_local\"] =\n      GenerateSetBitToLocal(messageBitIndex);\n\n  if (SupportUnknownEnumValue(descriptor->file())) {\n    (*variables)[\"unknown\"] = (*variables)[\"type\"] + \".UNRECOGNIZED\";\n  } else {\n    (*variables)[\"unknown\"] = (*variables)[\"default\"];\n  }\n}\n\n}  // namespace\n\n// ===================================================================\n\nImmutableEnumFieldGenerator::\nImmutableEnumFieldGenerator(const FieldDescriptor* descriptor,\n                            int messageBitIndex,\n                            int builderBitIndex,\n                            Context* context)\n  : descriptor_(descriptor), messageBitIndex_(messageBitIndex),\n    builderBitIndex_(builderBitIndex),\n    name_resolver_(context->GetNameResolver()) {\n  SetEnumVariables(descriptor, messageBitIndex, builderBitIndex,\n                   context->GetFieldGeneratorInfo(descriptor),\n                   name_resolver_, &variables_);\n}\n\nImmutableEnumFieldGenerator::~ImmutableEnumFieldGenerator() {}\n\nint ImmutableEnumFieldGenerator::GetNumBitsForMessage() const {\n  return 1;\n}\n\nint ImmutableEnumFieldGenerator::GetNumBitsForBuilder() const {\n  return 1;\n}\n\nvoid ImmutableEnumFieldGenerator::\nGenerateInterfaceMembers(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$boolean has$capitalized_name$();\\n\");\n  }\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$int get$capitalized_name$Value();\\n\");\n  }\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$$type$ get$capitalized_name$();\\n\");\n}\n\nvoid ImmutableEnumFieldGenerator::\nGenerateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"private int $name$_;\\n\");\n  PrintExtraFieldInfo(variables_, printer);\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $get_has_field_bit_message$;\\n\"\n      \"}\\n\");\n  }\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public int get$capitalized_name$Value() {\\n\"\n      \"  return $name$_;\\n\"\n      \"}\\n\");\n  }\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  $type$ result = $type$.$for_number$($name$_);\\n\"\n    \"  return result == null ? $unknown$ : result;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableEnumFieldGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"private int $name$_ = $default_number$;\\n\");\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $get_has_field_bit_builder$;\\n\"\n      \"}\\n\");\n  }\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public int get$capitalized_name$Value() {\\n\"\n      \"  return $name$_;\\n\"\n      \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public Builder set$capitalized_name$Value(int value) {\\n\"\n      \"  $name$_ = value;\\n\"\n      \"  $on_changed$\\n\"\n      \"  return this;\\n\"\n      \"}\\n\");\n  }\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  $type$ result = $type$.$for_number$($name$_);\\n\"\n    \"  return result == null ? $unknown$ : result;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$($type$ value) {\\n\"\n    \"  if (value == null) {\\n\"\n    \"    throw new NullPointerException();\\n\"\n    \"  }\\n\"\n    \"  $set_has_field_bit_builder$\\n\"\n    \"  $name$_ = value.getNumber();\\n\"\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  $clear_has_field_bit_builder$\\n\"\n    \"  $name$_ = $default_number$;\\n\"\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableEnumFieldGenerator::\nGenerateFieldBuilderInitializationCode(io::Printer* printer)  const {\n  // noop for enums\n}\n\nvoid ImmutableEnumFieldGenerator::\nGenerateInitializationCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_ = $default_number$;\\n\");\n}\n\nvoid ImmutableEnumFieldGenerator::\nGenerateBuilderClearCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$_ = $default_number$;\\n\"\n    \"$clear_has_field_bit_builder$\\n\");\n}\n\nvoid ImmutableEnumFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    printer->Print(variables_,\n      \"if (other.has$capitalized_name$()) {\\n\"\n      \"  set$capitalized_name$(other.get$capitalized_name$());\\n\"\n      \"}\\n\");\n  } else if (SupportUnknownEnumValue(descriptor_->file())) {\n    printer->Print(variables_,\n      \"if (other.$name$_ != $default_number$) {\\n\"\n      \"  set$capitalized_name$Value(other.get$capitalized_name$Value());\\n\"\n      \"}\\n\");\n  } else {\n    GOOGLE_LOG(FATAL) << \"Can't reach here.\";\n  }\n}\n\nvoid ImmutableEnumFieldGenerator::\nGenerateBuildingCode(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    printer->Print(variables_,\n      \"if ($get_has_field_bit_from_local$) {\\n\"\n      \"  $set_has_field_bit_to_local$;\\n\"\n      \"}\\n\");\n  }\n  printer->Print(variables_,\n    \"result.$name$_ = $name$_;\\n\");\n}\n\nvoid ImmutableEnumFieldGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    printer->Print(variables_,\n      \"int rawValue = input.readEnum();\\n\"\n      \"$set_has_field_bit_message$\\n\"\n      \"$name$_ = rawValue;\\n\");\n  } else {\n    printer->Print(variables_,\n      \"int rawValue = input.readEnum();\\n\"\n      \"$type$ value = $type$.$for_number$(rawValue);\\n\"\n      \"if (value == null) {\\n\");\n    if (PreserveUnknownFields(descriptor_->containing_type())) {\n      printer->Print(variables_,\n        \"  unknownFields.mergeVarintField($number$, rawValue);\\n\");\n    }\n    printer->Print(variables_,\n      \"} else {\\n\"\n      \"  $set_has_field_bit_message$\\n\"\n      \"  $name$_ = rawValue;\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid ImmutableEnumFieldGenerator::\nGenerateParsingDoneCode(io::Printer* printer) const {\n  // noop for enums\n}\n\nvoid ImmutableEnumFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($is_field_present_message$) {\\n\"\n    \"  output.writeEnum($number$, $name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableEnumFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($is_field_present_message$) {\\n\"\n    \"  size += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .computeEnumSize($number$, $name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableEnumFieldGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"result = result && $name$_ == other.$name$_;\\n\");\n}\n\nvoid ImmutableEnumFieldGenerator::\nGenerateHashCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"hash = (37 * hash) + $constant_name$;\\n\"\n    \"hash = (53 * hash) + $name$_;\\n\");\n}\n\nstring ImmutableEnumFieldGenerator::GetBoxedType() const {\n  return name_resolver_->GetImmutableClassName(descriptor_->enum_type());\n}\n\n// ===================================================================\n\nImmutableEnumOneofFieldGenerator::\nImmutableEnumOneofFieldGenerator(const FieldDescriptor* descriptor,\n                                 int messageBitIndex,\n                                 int builderBitIndex,\n                                 Context* context)\n    : ImmutableEnumFieldGenerator(\n          descriptor, messageBitIndex, builderBitIndex, context) {\n  const OneofGeneratorInfo* info =\n      context->GetOneofGeneratorInfo(descriptor->containing_oneof());\n  SetCommonOneofVariables(descriptor, info, &variables_);\n}\n\nImmutableEnumOneofFieldGenerator::\n~ImmutableEnumOneofFieldGenerator() {}\n\nvoid ImmutableEnumOneofFieldGenerator::\nGenerateMembers(io::Printer* printer) const {\n  PrintExtraFieldInfo(variables_, printer);\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $has_oneof_case_message$;\\n\"\n      \"}\\n\");\n  }\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public int get$capitalized_name$Value() {\\n\"\n      \"  if ($has_oneof_case_message$) {\\n\"\n      \"    return (java.lang.Integer) $oneof_name$_;\\n\"\n      \"  }\\n\"\n      \"  return $default_number$;\\n\"\n      \"}\\n\");\n  }\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    $type$ result = $type$.$for_number$(\\n\"\n    \"        (java.lang.Integer) $oneof_name$_);\\n\"\n    \"    return result == null ? $unknown$ : result;\\n\"\n    \"  }\\n\"\n    \"  return $default$;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableEnumOneofFieldGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $has_oneof_case_message$;\\n\"\n      \"}\\n\");\n  }\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public int get$capitalized_name$Value() {\\n\"\n      \"  if ($has_oneof_case_message$) {\\n\"\n      \"    return ((java.lang.Integer) $oneof_name$_).intValue();\\n\"\n      \"  }\\n\"\n      \"  return $default_number$;\\n\"\n      \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public Builder set$capitalized_name$Value(int value) {\\n\"\n      \"  $set_oneof_case_message$;\\n\"\n      \"  $oneof_name$_ = value;\\n\"\n      \"  $on_changed$\\n\"\n      \"  return this;\\n\"\n      \"}\\n\");\n  }\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    $type$ result = $type$.$for_number$(\\n\"\n    \"        (java.lang.Integer) $oneof_name$_);\\n\"\n    \"    return result == null ? $unknown$ : result;\\n\"\n    \"  }\\n\"\n    \"  return $default$;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$($type$ value) {\\n\"\n    \"  if (value == null) {\\n\"\n    \"    throw new NullPointerException();\\n\"\n    \"  }\\n\"\n    \"  $set_oneof_case_message$;\\n\"\n    \"  $oneof_name$_ = value.getNumber();\\n\"\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    $clear_oneof_case_message$;\\n\"\n    \"    $oneof_name$_ = null;\\n\"\n    \"    $on_changed$\\n\"\n    \"  }\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableEnumOneofFieldGenerator::\nGenerateBuildingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  result.$oneof_name$_ = $oneof_name$_;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableEnumOneofFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    printer->Print(variables_,\n      \"set$capitalized_name$Value(other.get$capitalized_name$Value());\\n\");\n  } else {\n    printer->Print(variables_,\n      \"set$capitalized_name$(other.get$capitalized_name$());\\n\");\n  }\n}\n\nvoid ImmutableEnumOneofFieldGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    printer->Print(variables_,\n      \"int rawValue = input.readEnum();\\n\"\n      \"$set_oneof_case_message$;\\n\"\n      \"$oneof_name$_ = rawValue;\\n\");\n  } else {\n    printer->Print(variables_,\n      \"int rawValue = input.readEnum();\\n\"\n      \"$type$ value = $type$.$for_number$(rawValue);\\n\"\n      \"if (value == null) {\\n\");\n    if (PreserveUnknownFields(descriptor_->containing_type())) {\n      printer->Print(variables_,\n        \"  unknownFields.mergeVarintField($number$, rawValue);\\n\");\n    }\n    printer->Print(variables_,\n      \"} else {\\n\"\n      \"  $set_oneof_case_message$;\\n\"\n      \"  $oneof_name$_ = rawValue;\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid ImmutableEnumOneofFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  output.writeEnum($number$, ((java.lang.Integer) $oneof_name$_));\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableEnumOneofFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  size += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .computeEnumSize($number$, ((java.lang.Integer) $oneof_name$_));\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableEnumOneofFieldGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    printer->Print(variables_,\n      \"result = result && get$capitalized_name$Value()\\n\"\n      \"    == other.get$capitalized_name$Value();\\n\");\n  } else {\n    printer->Print(variables_,\n      \"result = result && get$capitalized_name$()\\n\"\n      \"    .equals(other.get$capitalized_name$());\\n\");\n  }\n}\n\nvoid ImmutableEnumOneofFieldGenerator::\nGenerateHashCode(io::Printer* printer) const {\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    printer->Print(variables_,\n      \"hash = (37 * hash) + $constant_name$;\\n\"\n      \"hash = (53 * hash) + get$capitalized_name$Value();\\n\");\n  } else {\n    printer->Print(variables_,\n      \"hash = (37 * hash) + $constant_name$;\\n\"\n      \"hash = (53 * hash) + get$capitalized_name$().getNumber();\\n\");\n  }\n}\n\n// ===================================================================\n\nRepeatedImmutableEnumFieldGenerator::\nRepeatedImmutableEnumFieldGenerator(const FieldDescriptor* descriptor,\n                                    int messageBitIndex,\n                                    int builderBitIndex,\n                                    Context* context)\n  : descriptor_(descriptor), messageBitIndex_(messageBitIndex),\n    builderBitIndex_(builderBitIndex), context_(context),\n    name_resolver_(context->GetNameResolver()) {\n  SetEnumVariables(descriptor, messageBitIndex, builderBitIndex,\n                   context->GetFieldGeneratorInfo(descriptor),\n                   name_resolver_, &variables_);\n}\n\nRepeatedImmutableEnumFieldGenerator::~RepeatedImmutableEnumFieldGenerator() {}\n\nint RepeatedImmutableEnumFieldGenerator::GetNumBitsForMessage() const {\n  return 0;\n}\n\nint RepeatedImmutableEnumFieldGenerator::GetNumBitsForBuilder() const {\n  return 1;\n}\n\nvoid RepeatedImmutableEnumFieldGenerator::\nGenerateInterfaceMembers(io::Printer* printer) const {\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$java.util.List<$type$> get$capitalized_name$List();\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$int get$capitalized_name$Count();\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$$type$ get$capitalized_name$(int index);\\n\");\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$java.util.List<java.lang.Integer>\\n\"\n      \"get$capitalized_name$ValueList();\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$int get$capitalized_name$Value(int index);\\n\");\n  }\n}\n\nvoid RepeatedImmutableEnumFieldGenerator::\nGenerateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"private java.util.List<java.lang.Integer> $name$_;\\n\"\n    \"private static final com.google.protobuf.Internal.ListAdapter.Converter<\\n\"\n    \"    java.lang.Integer, $type$> $name$_converter_ =\\n\"\n    \"        new com.google.protobuf.Internal.ListAdapter.Converter<\\n\"\n    \"            java.lang.Integer, $type$>() {\\n\"\n    \"          public $type$ convert(java.lang.Integer from) {\\n\"\n    \"            $type$ result = $type$.$for_number$(from);\\n\"\n    \"            return result == null ? $unknown$ : result;\\n\"\n    \"          }\\n\"\n    \"        };\\n\");\n  PrintExtraFieldInfo(variables_, printer);\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.util.List<$type$> get$capitalized_name$List() {\\n\"\n    \"  return new com.google.protobuf.Internal.ListAdapter<\\n\"\n    \"      java.lang.Integer, $type$>($name$_, $name$_converter_);\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public int get$capitalized_name$Count() {\\n\"\n    \"  return $name$_.size();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$(int index) {\\n\"\n    \"  return $name$_converter_.convert($name$_.get(index));\\n\"\n    \"}\\n\");\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public java.util.List<java.lang.Integer>\\n\"\n      \"get$capitalized_name$ValueList() {\\n\"\n      \"  return $name$_;\\n\"\n      \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public int get$capitalized_name$Value(int index) {\\n\"\n      \"  return $name$_.get(index);\\n\"\n      \"}\\n\");\n  }\n\n  if (descriptor_->is_packed() &&\n      context_->HasGeneratedMethods(descriptor_->containing_type())) {\n    printer->Print(variables_,\n      \"private int $name$MemoizedSerializedSize;\\n\");\n  }\n}\n\nvoid RepeatedImmutableEnumFieldGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    // One field is the list and the other field keeps track of whether the\n    // list is immutable. If it's immutable, the invariant is that it must\n    // either an instance of Collections.emptyList() or it's an ArrayList\n    // wrapped in a Collections.unmodifiableList() wrapper and nobody else has\n    // a refererence to the underlying ArrayList. This invariant allows us to\n    // share instances of lists between protocol buffers avoiding expensive\n    // memory allocations. Note, immutable is a strong guarantee here -- not\n    // just that the list cannot be modified via the reference but that the\n    // list can never be modified.\n    \"private java.util.List<java.lang.Integer> $name$_ =\\n\"\n    \"  java.util.Collections.emptyList();\\n\"\n\n    \"private void ensure$capitalized_name$IsMutable() {\\n\"\n    \"  if (!$get_mutable_bit_builder$) {\\n\"\n    \"    $name$_ = new java.util.ArrayList<java.lang.Integer>($name$_);\\n\"\n    \"    $set_mutable_bit_builder$;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    // Note:  We return an unmodifiable list because otherwise the caller\n    //   could hold on to the returned list and modify it after the message\n    //   has been built, thus mutating the message which is supposed to be\n    //   immutable.\n    \"$deprecation$public java.util.List<$type$> get$capitalized_name$List() {\\n\"\n    \"  return new com.google.protobuf.Internal.ListAdapter<\\n\"\n    \"      java.lang.Integer, $type$>($name$_, $name$_converter_);\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public int get$capitalized_name$Count() {\\n\"\n    \"  return $name$_.size();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$(int index) {\\n\"\n    \"  return $name$_converter_.convert($name$_.get(index));\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    int index, $type$ value) {\\n\"\n    \"  if (value == null) {\\n\"\n    \"    throw new NullPointerException();\\n\"\n    \"  }\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.set(index, value.getNumber());\\n\"\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder add$capitalized_name$($type$ value) {\\n\"\n    \"  if (value == null) {\\n\"\n    \"    throw new NullPointerException();\\n\"\n    \"  }\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.add(value.getNumber());\\n\"\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder addAll$capitalized_name$(\\n\"\n    \"    java.lang.Iterable<? extends $type$> values) {\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  for ($type$ value : values) {\\n\"\n    \"    $name$_.add(value.getNumber());\\n\"\n    \"  }\\n\"\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  $name$_ = java.util.Collections.emptyList();\\n\"\n    \"  $clear_mutable_bit_builder$;\\n\"\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public java.util.List<java.lang.Integer>\\n\"\n      \"get$capitalized_name$ValueList() {\\n\"\n      \"  return java.util.Collections.unmodifiableList($name$_);\\n\"\n      \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public int get$capitalized_name$Value(int index) {\\n\"\n      \"  return $name$_.get(index);\\n\"\n      \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public Builder set$capitalized_name$Value(\\n\"\n      \"    int index, int value) {\\n\"\n      \"  ensure$capitalized_name$IsMutable();\\n\"\n      \"  $name$_.set(index, value);\\n\"\n      \"  $on_changed$\\n\"\n      \"  return this;\\n\"\n      \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public Builder add$capitalized_name$Value(int value) {\\n\"\n      \"  ensure$capitalized_name$IsMutable();\\n\"\n      \"  $name$_.add(value);\\n\"\n      \"  $on_changed$\\n\"\n      \"  return this;\\n\"\n      \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public Builder addAll$capitalized_name$Value(\\n\"\n      \"    java.lang.Iterable<java.lang.Integer> values) {\\n\"\n      \"  ensure$capitalized_name$IsMutable();\\n\"\n      \"  for (int value : values) {\\n\"\n      \"    $name$_.add(value);\\n\"\n      \"  }\\n\"\n      \"  $on_changed$\\n\"\n      \"  return this;\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid RepeatedImmutableEnumFieldGenerator::\nGenerateFieldBuilderInitializationCode(io::Printer* printer)  const {\n  // noop for enums\n}\n\nvoid RepeatedImmutableEnumFieldGenerator::\nGenerateInitializationCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_ = java.util.Collections.emptyList();\\n\");\n}\n\nvoid RepeatedImmutableEnumFieldGenerator::\nGenerateBuilderClearCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$_ = java.util.Collections.emptyList();\\n\"\n    \"$clear_mutable_bit_builder$;\\n\");\n}\n\nvoid RepeatedImmutableEnumFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  // The code below does two optimizations:\n  //   1. If the other list is empty, there's nothing to do. This ensures we\n  //      don't allocate a new array if we already have an immutable one.\n  //   2. If the other list is non-empty and our current list is empty, we can\n  //      reuse the other list which is guaranteed to be immutable.\n  printer->Print(variables_,\n    \"if (!other.$name$_.isEmpty()) {\\n\"\n    \"  if ($name$_.isEmpty()) {\\n\"\n    \"    $name$_ = other.$name$_;\\n\"\n    \"    $clear_mutable_bit_builder$;\\n\"\n    \"  } else {\\n\"\n    \"    ensure$capitalized_name$IsMutable();\\n\"\n    \"    $name$_.addAll(other.$name$_);\\n\"\n    \"  }\\n\"\n    \"  $on_changed$\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableEnumFieldGenerator::\nGenerateBuildingCode(io::Printer* printer) const {\n  // The code below ensures that the result has an immutable list. If our\n  // list is immutable, we can just reuse it. If not, we make it immutable.\n  printer->Print(variables_,\n    \"if ($get_mutable_bit_builder$) {\\n\"\n    \"  $name$_ = java.util.Collections.unmodifiableList($name$_);\\n\"\n    \"  $clear_mutable_bit_builder$;\\n\"\n    \"}\\n\"\n    \"result.$name$_ = $name$_;\\n\");\n}\n\nvoid RepeatedImmutableEnumFieldGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  // Read and store the enum\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    printer->Print(variables_,\n      \"int rawValue = input.readEnum();\\n\"\n      \"if (!$get_mutable_bit_parser$) {\\n\"\n      \"  $name$_ = new java.util.ArrayList<java.lang.Integer>();\\n\"\n      \"  $set_mutable_bit_parser$;\\n\"\n      \"}\\n\"\n      \"$name$_.add(rawValue);\\n\");\n  } else {\n    printer->Print(variables_,\n      \"int rawValue = input.readEnum();\\n\"\n      \"$type$ value = $type$.$for_number$(rawValue);\\n\"\n        \"if (value == null) {\\n\");\n    if (PreserveUnknownFields(descriptor_->containing_type())) {\n      printer->Print(variables_,\n        \"  unknownFields.mergeVarintField($number$, rawValue);\\n\");\n    }\n    printer->Print(variables_,\n      \"} else {\\n\"\n      \"  if (!$get_mutable_bit_parser$) {\\n\"\n      \"    $name$_ = new java.util.ArrayList<java.lang.Integer>();\\n\"\n      \"    $set_mutable_bit_parser$;\\n\"\n      \"  }\\n\"\n      \"  $name$_.add(rawValue);\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid RepeatedImmutableEnumFieldGenerator::\nGenerateParsingCodeFromPacked(io::Printer* printer) const {\n  // Wrap GenerateParsingCode's contents with a while loop.\n\n  printer->Print(variables_,\n    \"int length = input.readRawVarint32();\\n\"\n    \"int oldLimit = input.pushLimit(length);\\n\"\n    \"while(input.getBytesUntilLimit() > 0) {\\n\");\n  printer->Indent();\n\n  GenerateParsingCode(printer);\n\n  printer->Outdent();\n  printer->Print(variables_,\n    \"}\\n\"\n    \"input.popLimit(oldLimit);\\n\");\n}\n\nvoid RepeatedImmutableEnumFieldGenerator::\nGenerateParsingDoneCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($get_mutable_bit_parser$) {\\n\"\n    \"  $name$_ = java.util.Collections.unmodifiableList($name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableEnumFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  if (descriptor_->is_packed()) {\n    printer->Print(variables_,\n      \"if (get$capitalized_name$List().size() > 0) {\\n\"\n      \"  output.writeUInt32NoTag($tag$);\\n\"\n      \"  output.writeUInt32NoTag($name$MemoizedSerializedSize);\\n\"\n      \"}\\n\"\n      \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n      \"  output.writeEnumNoTag($name$_.get(i));\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables_,\n      \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n      \"  output.writeEnum($number$, $name$_.get(i));\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid RepeatedImmutableEnumFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"{\\n\"\n    \"  int dataSize = 0;\\n\");\n  printer->Indent();\n\n  printer->Print(variables_,\n    \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n    \"  dataSize += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .computeEnumSizeNoTag($name$_.get(i));\\n\"\n    \"}\\n\");\n  printer->Print(\n    \"size += dataSize;\\n\");\n  if (descriptor_->is_packed()) {\n    printer->Print(variables_,\n      \"if (!get$capitalized_name$List().isEmpty()) {\"\n      \"  size += $tag_size$;\\n\"\n      \"  size += com.google.protobuf.CodedOutputStream\\n\"\n      \"    .computeUInt32SizeNoTag(dataSize);\\n\"\n      \"}\");\n  } else {\n    printer->Print(variables_,\n      \"size += $tag_size$ * $name$_.size();\\n\");\n  }\n\n  // cache the data size for packed fields.\n  if (descriptor_->is_packed()) {\n    printer->Print(variables_,\n      \"$name$MemoizedSerializedSize = dataSize;\\n\");\n  }\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid RepeatedImmutableEnumFieldGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"result = result && $name$_.equals(other.$name$_);\\n\");\n}\n\nvoid RepeatedImmutableEnumFieldGenerator::\nGenerateHashCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (get$capitalized_name$Count() > 0) {\\n\"\n    \"  hash = (37 * hash) + $constant_name$;\\n\"\n    \"  hash = (53 * hash) + $name$_.hashCode();\\n\"\n    \"}\\n\");\n}\n\nstring RepeatedImmutableEnumFieldGenerator::GetBoxedType() const {\n  return name_resolver_->GetImmutableClassName(descriptor_->enum_type());\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_enum_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_H__\n\n#include <map>\n#include <string>\n#include <google/protobuf/compiler/java/java_field.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace compiler {\n    namespace java {\n      class Context;            // context.h\n      class ClassNameResolver;  // name_resolver.h\n    }\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nclass ImmutableEnumFieldGenerator : public ImmutableFieldGenerator {\n public:\n  explicit ImmutableEnumFieldGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~ImmutableEnumFieldGenerator();\n\n  // implements ImmutableFieldGenerator ---------------------------------------\n  int GetNumBitsForMessage() const;\n  int GetNumBitsForBuilder() const;\n  void GenerateInterfaceMembers(io::Printer* printer) const;\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateInitializationCode(io::Printer* printer) const;\n  void GenerateBuilderClearCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateBuildingCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateParsingDoneCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCode(io::Printer* printer) const;\n\n  string GetBoxedType() const;\n\n protected:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n  const int messageBitIndex_;\n  const int builderBitIndex_;\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableEnumFieldGenerator);\n};\n\nclass ImmutableEnumOneofFieldGenerator : public ImmutableEnumFieldGenerator {\n public:\n  ImmutableEnumOneofFieldGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~ImmutableEnumOneofFieldGenerator();\n\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateBuildingCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCode(io::Printer* printer) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableEnumOneofFieldGenerator);\n};\n\nclass RepeatedImmutableEnumFieldGenerator : public ImmutableFieldGenerator {\n public:\n  explicit RepeatedImmutableEnumFieldGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~RepeatedImmutableEnumFieldGenerator();\n\n  // implements ImmutableFieldGenerator ---------------------------------------\n  int GetNumBitsForMessage() const;\n  int GetNumBitsForBuilder() const;\n  void GenerateInterfaceMembers(io::Printer* printer) const;\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateInitializationCode(io::Printer* printer) const;\n  void GenerateBuilderClearCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateBuildingCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateParsingCodeFromPacked(io::Printer* printer) const;\n  void GenerateParsingDoneCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCode(io::Printer* printer) const;\n\n  string GetBoxedType() const;\n\n private:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n  const int messageBitIndex_;\n  const int builderBitIndex_;\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableEnumFieldGenerator);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_enum_field_lite.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n#include <google/protobuf/compiler/java/java_enum_field_lite.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nnamespace {\n\nvoid SetEnumVariables(const FieldDescriptor* descriptor,\n                      int messageBitIndex,\n                      int builderBitIndex,\n                      const FieldGeneratorInfo* info,\n                      ClassNameResolver* name_resolver,\n                      map<string, string>* variables) {\n  SetCommonFieldVariables(descriptor, info, variables);\n\n  (*variables)[\"type\"] =\n      name_resolver->GetImmutableClassName(descriptor->enum_type());\n  (*variables)[\"mutable_type\"] =\n      name_resolver->GetMutableClassName(descriptor->enum_type());\n  (*variables)[\"default\"] = ImmutableDefaultValue(descriptor, name_resolver);\n  (*variables)[\"default_number\"] = SimpleItoa(\n      descriptor->default_value_enum()->number());\n  (*variables)[\"tag\"] = SimpleItoa(internal::WireFormat::MakeTag(descriptor));\n  (*variables)[\"tag_size\"] = SimpleItoa(\n      internal::WireFormat::TagSize(descriptor->number(), GetType(descriptor)));\n  // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported\n  // by the proto compiler\n  (*variables)[\"deprecation\"] = descriptor->options().deprecated()\n      ? \"@java.lang.Deprecated \" : \"\";\n\n  if (SupportFieldPresence(descriptor->file())) {\n    // For singular messages and builders, one bit is used for the hasField bit.\n    (*variables)[\"get_has_field_bit_message\"] = GenerateGetBit(messageBitIndex);\n\n    // Note that these have a trailing \";\".\n    (*variables)[\"set_has_field_bit_message\"] =\n        GenerateSetBit(messageBitIndex) + \";\";\n    (*variables)[\"clear_has_field_bit_message\"] =\n        GenerateClearBit(messageBitIndex) + \";\";\n\n    (*variables)[\"is_field_present_message\"] = GenerateGetBit(messageBitIndex);\n  } else {\n    (*variables)[\"set_has_field_bit_message\"] = \"\";\n    (*variables)[\"clear_has_field_bit_message\"] = \"\";\n\n    (*variables)[\"is_field_present_message\"] =\n        (*variables)[\"name\"] + \"_ != \" +\n        (*variables)[\"default\"] + \".getNumber()\";\n  }\n\n  // For repeated builders, the underlying list tracks mutability state.\n  (*variables)[\"is_mutable\"] = (*variables)[\"name\"] + \"_.isModifiable()\";\n\n  (*variables)[\"get_has_field_bit_from_local\"] =\n      GenerateGetBitFromLocal(builderBitIndex);\n  (*variables)[\"set_has_field_bit_to_local\"] =\n      GenerateSetBitToLocal(messageBitIndex);\n\n  if (SupportUnknownEnumValue(descriptor->file())) {\n    (*variables)[\"unknown\"] = (*variables)[\"type\"] + \".UNRECOGNIZED\";\n  } else {\n    (*variables)[\"unknown\"] = (*variables)[\"default\"];\n  }\n}\n\n}  // namespace\n\n// ===================================================================\n\nImmutableEnumFieldLiteGenerator::\nImmutableEnumFieldLiteGenerator(const FieldDescriptor* descriptor,\n                            int messageBitIndex,\n                            int builderBitIndex,\n                            Context* context)\n  : descriptor_(descriptor), messageBitIndex_(messageBitIndex),\n    builderBitIndex_(builderBitIndex),\n    name_resolver_(context->GetNameResolver()) {\n  SetEnumVariables(descriptor, messageBitIndex, builderBitIndex,\n                   context->GetFieldGeneratorInfo(descriptor),\n                   name_resolver_, &variables_);\n}\n\nImmutableEnumFieldLiteGenerator::~ImmutableEnumFieldLiteGenerator() {}\n\nint ImmutableEnumFieldLiteGenerator::GetNumBitsForMessage() const {\n  return 1;\n}\n\nint ImmutableEnumFieldLiteGenerator::GetNumBitsForBuilder() const {\n  return 0;\n}\n\nvoid ImmutableEnumFieldLiteGenerator::\nGenerateInterfaceMembers(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$boolean has$capitalized_name$();\\n\");\n  }\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$int get$capitalized_name$Value();\\n\");\n  }\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$$type$ get$capitalized_name$();\\n\");\n}\n\nvoid ImmutableEnumFieldLiteGenerator::\nGenerateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"private int $name$_;\\n\");\n  PrintExtraFieldInfo(variables_, printer);\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $get_has_field_bit_message$;\\n\"\n      \"}\\n\");\n  }\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public int get$capitalized_name$Value() {\\n\"\n      \"  return $name$_;\\n\"\n      \"}\\n\");\n  }\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  $type$ result = $type$.forNumber($name$_);\\n\"\n    \"  return result == null ? $unknown$ : result;\\n\"\n    \"}\\n\");\n\n  // Generate private setters for the builder to proxy into.\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"private void set$capitalized_name$Value(int value) {\\n\"\n      \"  $set_has_field_bit_message$\"\n      \"  $name$_ = value;\\n\"\n      \"}\\n\");\n  }\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$($type$ value) {\\n\"\n    \"  if (value == null) {\\n\"\n    \"    throw new NullPointerException();\\n\"\n    \"  }\\n\"\n    \"  $set_has_field_bit_message$\\n\"\n    \"  $name$_ = value.getNumber();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void clear$capitalized_name$() {\\n\"\n    \"  $clear_has_field_bit_message$\\n\"\n    \"  $name$_ = $default_number$;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableEnumFieldLiteGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return instance.has$capitalized_name$();\\n\"\n      \"}\\n\");\n  }\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public int get$capitalized_name$Value() {\\n\"\n      \"  return instance.get$capitalized_name$Value();\\n\"\n      \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public Builder set$capitalized_name$Value(int value) {\\n\"\n      \"  copyOnWrite();\\n\"\n      \"  instance.set$capitalized_name$Value(value);\\n\"\n      \"  return this;\\n\"\n      \"}\\n\");\n  }\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  return instance.get$capitalized_name$();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$($type$ value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$(value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.clear$capitalized_name$();\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableEnumFieldLiteGenerator::\nGenerateFieldBuilderInitializationCode(io::Printer* printer)  const {\n  // noop for enums\n}\n\nvoid ImmutableEnumFieldLiteGenerator::\nGenerateInitializationCode(io::Printer* printer) const {\n  if (!IsDefaultValueJavaDefault(descriptor_)) {\n    printer->Print(variables_, \"$name$_ = $default_number$;\\n\");\n  }\n}\n\nvoid ImmutableEnumFieldLiteGenerator::\nGenerateVisitCode(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    printer->Print(variables_,\n      \"$name$_ = visitor.visitInt(has$capitalized_name$(), $name$_,\\n\"\n      \"    other.has$capitalized_name$(), other.$name$_);\\n\");\n  } else if (SupportUnknownEnumValue(descriptor_->file())) {\n    printer->Print(variables_,\n      \"$name$_ = visitor.visitInt($name$_ != $default_number$, $name$_,\"\n      \"    other.$name$_ != $default_number$, other.$name$_);\\n\");\n  } else {\n    GOOGLE_LOG(FATAL) << \"Can't reach here.\";\n  }\n}\n\nvoid ImmutableEnumFieldLiteGenerator::\nGenerateDynamicMethodMakeImmutableCode(io::Printer* printer) const {\n  // noop for scalars\n}\n\nvoid ImmutableEnumFieldLiteGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    printer->Print(variables_,\n      \"int rawValue = input.readEnum();\\n\"\n      \"$set_has_field_bit_message$\\n\"\n      \"$name$_ = rawValue;\\n\");\n  } else {\n    printer->Print(variables_,\n      \"int rawValue = input.readEnum();\\n\"\n      \"$type$ value = $type$.forNumber(rawValue);\\n\"\n      \"if (value == null) {\\n\");\n    if (PreserveUnknownFields(descriptor_->containing_type())) {\n      printer->Print(variables_,\n        \"  super.mergeVarintField($number$, rawValue);\\n\");\n    }\n    printer->Print(variables_,\n      \"} else {\\n\"\n      \"  $set_has_field_bit_message$\\n\"\n      \"  $name$_ = rawValue;\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid ImmutableEnumFieldLiteGenerator::\nGenerateParsingDoneCode(io::Printer* printer) const {\n  // noop for enums\n}\n\nvoid ImmutableEnumFieldLiteGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($is_field_present_message$) {\\n\"\n    \"  output.writeEnum($number$, $name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableEnumFieldLiteGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($is_field_present_message$) {\\n\"\n    \"  size += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .computeEnumSize($number$, $name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableEnumFieldLiteGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"result = result && $name$_ == other.$name$_;\\n\");\n}\n\nvoid ImmutableEnumFieldLiteGenerator::\nGenerateHashCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"hash = (37 * hash) + $constant_name$;\\n\"\n    \"hash = (53 * hash) + $name$_;\\n\");\n}\n\nstring ImmutableEnumFieldLiteGenerator::GetBoxedType() const {\n  return name_resolver_->GetImmutableClassName(descriptor_->enum_type());\n}\n\n// ===================================================================\n\nImmutableEnumOneofFieldLiteGenerator::\nImmutableEnumOneofFieldLiteGenerator(const FieldDescriptor* descriptor,\n                                 int messageBitIndex,\n                                 int builderBitIndex,\n                                 Context* context)\n    : ImmutableEnumFieldLiteGenerator(\n          descriptor, messageBitIndex, builderBitIndex, context) {\n  const OneofGeneratorInfo* info =\n      context->GetOneofGeneratorInfo(descriptor->containing_oneof());\n  SetCommonOneofVariables(descriptor, info, &variables_);\n}\n\nImmutableEnumOneofFieldLiteGenerator::\n~ImmutableEnumOneofFieldLiteGenerator() {}\n\nvoid ImmutableEnumOneofFieldLiteGenerator::\nGenerateMembers(io::Printer* printer) const {\n  PrintExtraFieldInfo(variables_, printer);\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $has_oneof_case_message$;\\n\"\n      \"}\\n\");\n  }\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public int get$capitalized_name$Value() {\\n\"\n      \"  if ($has_oneof_case_message$) {\\n\"\n      \"    return (java.lang.Integer) $oneof_name$_;\\n\"\n      \"  }\\n\"\n      \"  return $default_number$;\\n\"\n      \"}\\n\");\n  }\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    $type$ result = $type$.forNumber((java.lang.Integer) $oneof_name$_);\\n\"\n    \"    return result == null ? $unknown$ : result;\\n\"\n    \"  }\\n\"\n    \"  return $default$;\\n\"\n    \"}\\n\");\n\n  // Generate private setters for the builder to proxy into.\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"private void set$capitalized_name$Value(int value) {\\n\"\n      \"  $set_oneof_case_message$;\\n\"\n      \"  $oneof_name$_ = value;\\n\"\n      \"}\\n\");\n  }\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$($type$ value) {\\n\"\n    \"  if (value == null) {\\n\"\n    \"    throw new NullPointerException();\\n\"\n    \"  }\\n\"\n    \"  $set_oneof_case_message$;\\n\"\n    \"  $oneof_name$_ = value.getNumber();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void clear$capitalized_name$() {\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    $clear_oneof_case_message$;\\n\"\n    \"    $oneof_name$_ = null;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableEnumOneofFieldLiteGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return instance.has$capitalized_name$();\\n\"\n      \"}\\n\");\n  }\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public int get$capitalized_name$Value() {\\n\"\n      \"  return instance.get$capitalized_name$Value();\\n\"\n      \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public Builder set$capitalized_name$Value(int value) {\\n\"\n      \"  copyOnWrite();\\n\"\n      \"  instance.set$capitalized_name$Value(value);\\n\"\n      \"  return this;\\n\"\n      \"}\\n\");\n  }\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  return instance.get$capitalized_name$();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$($type$ value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$(value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.clear$capitalized_name$();\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableEnumOneofFieldLiteGenerator::\nGenerateVisitCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$oneof_name$_ = visitor.visitOneofInt(\\n\"\n    \"   $has_oneof_case_message$, $oneof_name$_, other.$oneof_name$_);\\n\");\n}\n\nvoid ImmutableEnumOneofFieldLiteGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    printer->Print(variables_,\n      \"int rawValue = input.readEnum();\\n\"\n      \"$set_oneof_case_message$;\\n\"\n      \"$oneof_name$_ = rawValue;\\n\");\n  } else {\n    printer->Print(variables_,\n      \"int rawValue = input.readEnum();\\n\"\n      \"$type$ value = $type$.forNumber(rawValue);\\n\"\n      \"if (value == null) {\\n\");\n    if (PreserveUnknownFields(descriptor_->containing_type())) {\n      printer->Print(variables_,\n        \"  super.mergeVarintField($number$, rawValue);\\n\");\n    }\n    printer->Print(variables_,\n      \"} else {\\n\"\n      \"  $set_oneof_case_message$;\\n\"\n      \"  $oneof_name$_ = rawValue;\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid ImmutableEnumOneofFieldLiteGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  output.writeEnum($number$, ((java.lang.Integer) $oneof_name$_));\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableEnumOneofFieldLiteGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  size += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .computeEnumSize($number$, ((java.lang.Integer) $oneof_name$_));\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableEnumOneofFieldLiteGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    printer->Print(variables_,\n      \"result = result && get$capitalized_name$Value()\\n\"\n      \"    == other.get$capitalized_name$Value();\\n\");\n  } else {\n    printer->Print(variables_,\n      \"result = result && get$capitalized_name$()\\n\"\n      \"    .equals(other.get$capitalized_name$());\\n\");\n  }\n}\n\nvoid ImmutableEnumOneofFieldLiteGenerator::\nGenerateHashCode(io::Printer* printer) const {\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    printer->Print(variables_,\n      \"hash = (37 * hash) + $constant_name$;\\n\"\n      \"hash = (53 * hash) + get$capitalized_name$Value();\\n\");\n  } else {\n    printer->Print(variables_,\n      \"hash = (37 * hash) + $constant_name$;\\n\"\n      \"hash = (53 * hash) + get$capitalized_name$().getNumber();\\n\");\n  }\n}\n\n// ===================================================================\n\nRepeatedImmutableEnumFieldLiteGenerator::\nRepeatedImmutableEnumFieldLiteGenerator(const FieldDescriptor* descriptor,\n                                    int messageBitIndex,\n                                    int builderBitIndex,\n                                    Context* context)\n  : descriptor_(descriptor), messageBitIndex_(messageBitIndex),\n    builderBitIndex_(builderBitIndex), context_(context),\n    name_resolver_(context->GetNameResolver()) {\n  SetEnumVariables(descriptor, messageBitIndex, builderBitIndex,\n                   context->GetFieldGeneratorInfo(descriptor),\n                   name_resolver_, &variables_);\n}\n\nRepeatedImmutableEnumFieldLiteGenerator::\n~RepeatedImmutableEnumFieldLiteGenerator() {}\n\nint RepeatedImmutableEnumFieldLiteGenerator::GetNumBitsForMessage() const {\n  return 0;\n}\n\nint RepeatedImmutableEnumFieldLiteGenerator::GetNumBitsForBuilder() const {\n  return 0;\n}\n\nvoid RepeatedImmutableEnumFieldLiteGenerator::\nGenerateInterfaceMembers(io::Printer* printer) const {\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$java.util.List<$type$> get$capitalized_name$List();\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$int get$capitalized_name$Count();\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$$type$ get$capitalized_name$(int index);\\n\");\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$java.util.List<java.lang.Integer>\\n\"\n      \"get$capitalized_name$ValueList();\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$int get$capitalized_name$Value(int index);\\n\");\n  }\n}\n\nvoid RepeatedImmutableEnumFieldLiteGenerator::\nGenerateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"private com.google.protobuf.Internal.IntList $name$_;\\n\"\n    \"private static final com.google.protobuf.Internal.ListAdapter.Converter<\\n\"\n    \"    java.lang.Integer, $type$> $name$_converter_ =\\n\"\n    \"        new com.google.protobuf.Internal.ListAdapter.Converter<\\n\"\n    \"            java.lang.Integer, $type$>() {\\n\"\n    \"          public $type$ convert(java.lang.Integer from) {\\n\"\n    \"            $type$ result = $type$.forNumber(from);\\n\"\n    \"            return result == null ? $unknown$ : result;\\n\"\n    \"          }\\n\"\n    \"        };\\n\");\n  PrintExtraFieldInfo(variables_, printer);\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.util.List<$type$> get$capitalized_name$List() {\\n\"\n    \"  return new com.google.protobuf.Internal.ListAdapter<\\n\"\n    \"      java.lang.Integer, $type$>($name$_, $name$_converter_);\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public int get$capitalized_name$Count() {\\n\"\n    \"  return $name$_.size();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$(int index) {\\n\"\n    \"  return $name$_converter_.convert($name$_.getInt(index));\\n\"\n    \"}\\n\");\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public java.util.List<java.lang.Integer>\\n\"\n      \"get$capitalized_name$ValueList() {\\n\"\n      \"  return $name$_;\\n\"\n      \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public int get$capitalized_name$Value(int index) {\\n\"\n      \"  return $name$_.getInt(index);\\n\"\n      \"}\\n\");\n  }\n\n  if (descriptor_->options().packed() &&\n      context_->HasGeneratedMethods(descriptor_->containing_type())) {\n    printer->Print(variables_,\n      \"private int $name$MemoizedSerializedSize;\\n\");\n  }\n\n  // Generate private setters for the builder to proxy into.\n  printer->Print(variables_,\n    \"private void ensure$capitalized_name$IsMutable() {\\n\"\n    \"  if (!$is_mutable$) {\\n\"\n    \"    $name$_ =\\n\"\n    \"        com.google.protobuf.GeneratedMessageLite.mutableCopy($name$_);\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$(\\n\"\n    \"    int index, $type$ value) {\\n\"\n    \"  if (value == null) {\\n\"\n    \"    throw new NullPointerException();\\n\"\n    \"  }\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.setInt(index, value.getNumber());\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void add$capitalized_name$($type$ value) {\\n\"\n    \"  if (value == null) {\\n\"\n    \"    throw new NullPointerException();\\n\"\n    \"  }\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.addInt(value.getNumber());\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void addAll$capitalized_name$(\\n\"\n    \"    java.lang.Iterable<? extends $type$> values) {\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  for ($type$ value : values) {\\n\"\n    \"    $name$_.addInt(value.getNumber());\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void clear$capitalized_name$() {\\n\"\n    \"  $name$_ = emptyIntList();\\n\"\n    \"}\\n\");\n\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"private void set$capitalized_name$Value(\\n\"\n      \"    int index, int value) {\\n\"\n      \"  ensure$capitalized_name$IsMutable();\\n\"\n      \"  $name$_.setInt(index, value);\\n\"\n      \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"private void add$capitalized_name$Value(int value) {\\n\"\n      \"  ensure$capitalized_name$IsMutable();\\n\"\n      \"  $name$_.addInt(value);\\n\"\n      \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"private void addAll$capitalized_name$Value(\\n\"\n      \"    java.lang.Iterable<java.lang.Integer> values) {\\n\"\n      \"  ensure$capitalized_name$IsMutable();\\n\"\n      \"  for (int value : values) {\\n\"\n      \"    $name$_.addInt(value);\\n\"\n      \"  }\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid RepeatedImmutableEnumFieldLiteGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.util.List<$type$> get$capitalized_name$List() {\\n\"\n    \"  return instance.get$capitalized_name$List();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public int get$capitalized_name$Count() {\\n\"\n    \"  return instance.get$capitalized_name$Count();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$(int index) {\\n\"\n    \"  return instance.get$capitalized_name$(index);\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    int index, $type$ value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$(index, value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder add$capitalized_name$($type$ value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.add$capitalized_name$(value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder addAll$capitalized_name$(\\n\"\n    \"    java.lang.Iterable<? extends $type$> values) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.addAll$capitalized_name$(values);\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.clear$capitalized_name$();\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public java.util.List<java.lang.Integer>\\n\"\n      \"get$capitalized_name$ValueList() {\\n\"\n      \"  return java.util.Collections.unmodifiableList(\\n\"\n      \"      instance.get$capitalized_name$ValueList());\\n\"\n      \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public int get$capitalized_name$Value(int index) {\\n\"\n      \"  return instance.get$capitalized_name$Value(index);\\n\"\n      \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public Builder set$capitalized_name$Value(\\n\"\n      \"    int index, int value) {\\n\"\n      \"  copyOnWrite();\\n\"\n      \"  instance.set$capitalized_name$Value(index, value);\\n\"\n      \"  return this;\\n\"\n      \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public Builder add$capitalized_name$Value(int value) {\\n\"\n      \"  instance.add$capitalized_name$Value(value);\\n\"\n      \"  return this;\\n\"\n      \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public Builder addAll$capitalized_name$Value(\\n\"\n      \"    java.lang.Iterable<java.lang.Integer> values) {\\n\"\n      \"  copyOnWrite();\\n\"\n      \"  instance.addAll$capitalized_name$Value(values);\\n\"\n      \"  return this;\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid RepeatedImmutableEnumFieldLiteGenerator::\nGenerateFieldBuilderInitializationCode(io::Printer* printer)  const {\n  // noop for enums\n}\n\nvoid RepeatedImmutableEnumFieldLiteGenerator::\nGenerateInitializationCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_ = emptyIntList();\\n\");\n}\n\nvoid RepeatedImmutableEnumFieldLiteGenerator::\nGenerateVisitCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$_= visitor.visitIntList($name$_, other.$name$_);\\n\");\n}\n\nvoid RepeatedImmutableEnumFieldLiteGenerator::\nGenerateDynamicMethodMakeImmutableCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$_.makeImmutable();\\n\");\n}\n\nvoid RepeatedImmutableEnumFieldLiteGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  // Read and store the enum\n  printer->Print(variables_,\n    \"if (!$is_mutable$) {\\n\"\n    \"  $name$_ =\\n\"\n    \"      com.google.protobuf.GeneratedMessageLite.mutableCopy($name$_);\\n\"\n    \"}\\n\");\n\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    printer->Print(variables_,\n      \"$name$_.addInt(input.readEnum());\\n\");\n  } else {\n    printer->Print(variables_,\n      \"int rawValue = input.readEnum();\\n\"\n      \"$type$ value = $type$.forNumber(rawValue);\\n\"\n      \"if (value == null) {\\n\"\n      // We store the unknown value in unknown fields.\n      \"  super.mergeVarintField($number$, rawValue);\\n\"\n      \"} else {\\n\"\n      \"  $name$_.addInt(rawValue);\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid RepeatedImmutableEnumFieldLiteGenerator::\nGenerateParsingCodeFromPacked(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (!$is_mutable$) {\\n\"\n    \"  $name$_ =\\n\"\n    \"      com.google.protobuf.GeneratedMessageLite.mutableCopy($name$_);\\n\"\n    \"}\\n\");\n\n  printer->Print(variables_,\n    \"int length = input.readRawVarint32();\\n\"\n    \"int oldLimit = input.pushLimit(length);\\n\"\n    \"while(input.getBytesUntilLimit() > 0) {\\n\");\n  printer->Indent();\n\n  // Read and store the enum\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    printer->Print(variables_,\n      \"$name$_.addInt(input.readEnum());\\n\");\n  } else {\n    printer->Print(variables_,\n      \"int rawValue = input.readEnum();\\n\"\n      \"$type$ value = $type$.forNumber(rawValue);\\n\"\n      \"if (value == null) {\\n\"\n      // We store the unknown value in unknown fields.\n      \"  super.mergeVarintField($number$, rawValue);\\n\"\n      \"} else {\\n\"\n      \"  $name$_.addInt(rawValue);\\n\"\n      \"}\\n\");\n  }\n\n  printer->Outdent();\n  printer->Print(variables_,\n    \"}\\n\"\n    \"input.popLimit(oldLimit);\\n\");\n}\n\nvoid RepeatedImmutableEnumFieldLiteGenerator::\nGenerateParsingDoneCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($is_mutable$) {\\n\"\n    \"  $name$_.makeImmutable();\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableEnumFieldLiteGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  if (descriptor_->options().packed()) {\n    printer->Print(variables_,\n      \"if (get$capitalized_name$List().size() > 0) {\\n\"\n      \"  output.writeUInt32NoTag($tag$);\\n\"\n      \"  output.writeUInt32NoTag($name$MemoizedSerializedSize);\\n\"\n      \"}\\n\"\n      \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n      \"  output.writeEnumNoTag($name$_.getInt(i));\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables_,\n      \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n      \"  output.writeEnum($number$, $name$_.getInt(i));\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid RepeatedImmutableEnumFieldLiteGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"{\\n\"\n    \"  int dataSize = 0;\\n\");\n  printer->Indent();\n\n  printer->Print(variables_,\n    \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n    \"  dataSize += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .computeEnumSizeNoTag($name$_.getInt(i));\\n\"\n    \"}\\n\");\n  printer->Print(\n    \"size += dataSize;\\n\");\n  if (descriptor_->options().packed()) {\n    printer->Print(variables_,\n      \"if (!get$capitalized_name$List().isEmpty()) {\"\n      \"  size += $tag_size$;\\n\"\n      \"  size += com.google.protobuf.CodedOutputStream\\n\"\n      \"    .computeUInt32SizeNoTag(dataSize);\\n\"\n      \"}\");\n  } else {\n    printer->Print(variables_,\n      \"size += $tag_size$ * $name$_.size();\\n\");\n  }\n\n  // cache the data size for packed fields.\n  if (descriptor_->options().packed()) {\n    printer->Print(variables_,\n      \"$name$MemoizedSerializedSize = dataSize;\\n\");\n  }\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid RepeatedImmutableEnumFieldLiteGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"result = result && $name$_.equals(other.$name$_);\\n\");\n}\n\nvoid RepeatedImmutableEnumFieldLiteGenerator::\nGenerateHashCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (get$capitalized_name$Count() > 0) {\\n\"\n    \"  hash = (37 * hash) + $constant_name$;\\n\"\n    \"  hash = (53 * hash) + $name$_.hashCode();\\n\"\n    \"}\\n\");\n}\n\nstring RepeatedImmutableEnumFieldLiteGenerator::GetBoxedType() const {\n  return name_resolver_->GetImmutableClassName(descriptor_->enum_type());\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_enum_field_lite.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_LITE_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_LITE_H__\n\n#include <map>\n#include <string>\n#include <google/protobuf/compiler/java/java_field.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace compiler {\n    namespace java {\n      class Context;            // context.h\n      class ClassNameResolver;  // name_resolver.h\n    }\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nclass ImmutableEnumFieldLiteGenerator : public ImmutableFieldLiteGenerator {\n public:\n  explicit ImmutableEnumFieldLiteGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~ImmutableEnumFieldLiteGenerator();\n\n  // implements ImmutableFieldLiteGenerator ------------------------------------\n  int GetNumBitsForMessage() const;\n  int GetNumBitsForBuilder() const;\n  void GenerateInterfaceMembers(io::Printer* printer) const;\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateInitializationCode(io::Printer* printer) const;\n  void GenerateVisitCode(io::Printer* printer) const;\n  void GenerateDynamicMethodMakeImmutableCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateParsingDoneCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCode(io::Printer* printer) const;\n\n  string GetBoxedType() const;\n\n protected:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n  const int messageBitIndex_;\n  const int builderBitIndex_;\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableEnumFieldLiteGenerator);\n};\n\nclass ImmutableEnumOneofFieldLiteGenerator\n    : public ImmutableEnumFieldLiteGenerator {\n public:\n  ImmutableEnumOneofFieldLiteGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~ImmutableEnumOneofFieldLiteGenerator();\n\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateVisitCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCode(io::Printer* printer) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableEnumOneofFieldLiteGenerator);\n};\n\nclass RepeatedImmutableEnumFieldLiteGenerator\n    : public ImmutableFieldLiteGenerator {\n public:\n  explicit RepeatedImmutableEnumFieldLiteGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~RepeatedImmutableEnumFieldLiteGenerator();\n\n  // implements ImmutableFieldLiteGenerator ------------------------------------\n  int GetNumBitsForMessage() const;\n  int GetNumBitsForBuilder() const;\n  void GenerateInterfaceMembers(io::Printer* printer) const;\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateInitializationCode(io::Printer* printer) const;\n  void GenerateVisitCode(io::Printer* printer) const;\n  void GenerateDynamicMethodMakeImmutableCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateParsingCodeFromPacked(io::Printer* printer) const;\n  void GenerateParsingDoneCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCode(io::Printer* printer) const;\n\n  string GetBoxedType() const;\n\n private:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n  const int messageBitIndex_;\n  const int builderBitIndex_;\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableEnumFieldLiteGenerator);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_FIELD_LITE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_enum_lite.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_enum_lite.h>\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nnamespace {\nbool EnumHasCustomOptions(const EnumDescriptor* descriptor) {\n  if (descriptor->options().unknown_fields().field_count() > 0) return true;\n  for (int i = 0; i < descriptor->value_count(); ++i) {\n    const EnumValueDescriptor* value = descriptor->value(i);\n    if (value->options().unknown_fields().field_count() > 0) return true;\n  }\n  return false;\n}\n}  // namespace\n\nEnumLiteGenerator::EnumLiteGenerator(const EnumDescriptor* descriptor,\n                                     bool immutable_api, Context* context)\n    : descriptor_(descriptor),\n      immutable_api_(immutable_api),\n      context_(context),\n      name_resolver_(context->GetNameResolver()) {\n  for (int i = 0; i < descriptor_->value_count(); i++) {\n    const EnumValueDescriptor* value = descriptor_->value(i);\n    const EnumValueDescriptor* canonical_value =\n      descriptor_->FindValueByNumber(value->number());\n\n    if (value == canonical_value) {\n      canonical_values_.push_back(value);\n    } else {\n      Alias alias;\n      alias.value = value;\n      alias.canonical_value = canonical_value;\n      aliases_.push_back(alias);\n    }\n  }\n}\n\nEnumLiteGenerator::~EnumLiteGenerator() {}\n\nvoid EnumLiteGenerator::Generate(io::Printer* printer) {\n  WriteEnumDocComment(printer, descriptor_);\n  MaybePrintGeneratedAnnotation(context_, printer, descriptor_, immutable_api_);\n  printer->Print(\n      \"public enum $classname$\\n\"\n      \"    implements com.google.protobuf.Internal.EnumLite {\\n\",\n      \"classname\", descriptor_->name());\n  printer->Annotate(\"classname\", descriptor_);\n  printer->Indent();\n\n  for (int i = 0; i < canonical_values_.size(); i++) {\n    map<string, string> vars;\n    vars[\"name\"] = canonical_values_[i]->name();\n    vars[\"number\"] = SimpleItoa(canonical_values_[i]->number());\n    WriteEnumValueDocComment(printer, canonical_values_[i]);\n    if (canonical_values_[i]->options().deprecated()) {\n      printer->Print(\"@java.lang.Deprecated\\n\");\n    }\n    printer->Print(vars,\n      \"$name$($number$),\\n\");\n  }\n\n  if (SupportUnknownEnumValue(descriptor_->file())) {\n    printer->Print(\"UNRECOGNIZED(-1),\\n\");\n  }\n\n  printer->Print(\n    \";\\n\"\n    \"\\n\");\n\n  // -----------------------------------------------------------------\n\n  for (int i = 0; i < aliases_.size(); i++) {\n    map<string, string> vars;\n    vars[\"classname\"] = descriptor_->name();\n    vars[\"name\"] = aliases_[i].value->name();\n    vars[\"canonical_name\"] = aliases_[i].canonical_value->name();\n    WriteEnumValueDocComment(printer, aliases_[i].value);\n    printer->Print(vars,\n      \"public static final $classname$ $name$ = $canonical_name$;\\n\");\n  }\n\n  for (int i = 0; i < descriptor_->value_count(); i++) {\n    map<string, string> vars;\n    vars[\"name\"] = descriptor_->value(i)->name();\n    vars[\"number\"] = SimpleItoa(descriptor_->value(i)->number());\n    WriteEnumValueDocComment(printer, descriptor_->value(i));\n    printer->Print(vars,\n      \"public static final int $name$_VALUE = $number$;\\n\");\n  }\n  printer->Print(\"\\n\");\n\n  // -----------------------------------------------------------------\n\n  printer->Print(\n    \"\\n\"\n    \"public final int getNumber() {\\n\"\n    \"  return value;\\n\"\n    \"}\\n\"\n    \"\\n\"\n    \"/**\\n\"\n    \" * @deprecated Use {@link #forNumber(int)} instead.\\n\"\n    \" */\\n\"\n    \"@java.lang.Deprecated\\n\"\n    \"public static $classname$ valueOf(int value) {\\n\"\n    \"  return forNumber(value);\\n\"\n    \"}\\n\"\n    \"\\n\"\n    \"public static $classname$ forNumber(int value) {\\n\"\n    \"  switch (value) {\\n\",\n    \"classname\", descriptor_->name());\n  printer->Indent();\n  printer->Indent();\n\n  for (int i = 0; i < canonical_values_.size(); i++) {\n    printer->Print(\n      \"case $number$: return $name$;\\n\",\n      \"name\", canonical_values_[i]->name(),\n      \"number\", SimpleItoa(canonical_values_[i]->number()));\n  }\n\n  printer->Outdent();\n  printer->Outdent();\n  printer->Print(\n    \"    default: return null;\\n\"\n    \"  }\\n\"\n    \"}\\n\"\n    \"\\n\"\n    \"public static com.google.protobuf.Internal.EnumLiteMap<$classname$>\\n\"\n    \"    internalGetValueMap() {\\n\"\n    \"  return internalValueMap;\\n\"\n    \"}\\n\"\n    \"private static final com.google.protobuf.Internal.EnumLiteMap<\\n\"\n    \"    $classname$> internalValueMap =\\n\"\n    \"      new com.google.protobuf.Internal.EnumLiteMap<$classname$>() {\\n\"\n    \"        public $classname$ findValueByNumber(int number) {\\n\"\n    \"          return $classname$.forNumber(number);\\n\"\n    \"        }\\n\"\n    \"      };\\n\"\n    \"\\n\",\n    \"classname\", descriptor_->name());\n\n  printer->Print(\n    \"private final int value;\\n\\n\"\n    \"private $classname$(int value) {\\n\",\n    \"classname\", descriptor_->name());\n  printer->Print(\n    \"  this.value = value;\\n\"\n    \"}\\n\");\n\n  printer->Print(\n    \"\\n\"\n    \"// @@protoc_insertion_point(enum_scope:$full_name$)\\n\",\n    \"full_name\", descriptor_->full_name());\n\n  printer->Outdent();\n  printer->Print(\"}\\n\\n\");\n}\n\nbool EnumLiteGenerator::CanUseEnumValues() {\n  if (canonical_values_.size() != descriptor_->value_count()) {\n    return false;\n  }\n  for (int i = 0; i < descriptor_->value_count(); i++) {\n    if (descriptor_->value(i)->name() != canonical_values_[i]->name()) {\n      return false;\n    }\n  }\n  return true;\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_enum_lite.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_LITE_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_LITE_H__\n\n#include <string>\n#include <vector>\n#include <google/protobuf/descriptor.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace compiler {\n    namespace java {\n      class Context;           // context.h\n      class ClassNameResolver; // name_resolver.h\n    }\n  }\n  namespace io {\n    class Printer;             // printer.h\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nclass EnumLiteGenerator {\n public:\n  EnumLiteGenerator(const EnumDescriptor* descriptor, bool immutable_api,\n                    Context* context);\n  ~EnumLiteGenerator();\n\n  void Generate(io::Printer* printer);\n\n private:\n  const EnumDescriptor* descriptor_;\n\n  // The proto language allows multiple enum constants to have the same numeric\n  // value.  Java, however, does not allow multiple enum constants to be\n  // considered equivalent.  We treat the first defined constant for any\n  // given numeric value as \"canonical\" and the rest as aliases of that\n  // canonical value.\n  vector<const EnumValueDescriptor*> canonical_values_;\n\n  struct Alias {\n    const EnumValueDescriptor* value;\n    const EnumValueDescriptor* canonical_value;\n  };\n  vector<Alias> aliases_;\n\n  bool immutable_api_;\n\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n\n  bool CanUseEnumValues();\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumLiteGenerator);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_ENUM_LITE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_extension.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/java/java_extension.h>\n\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nImmutableExtensionGenerator::ImmutableExtensionGenerator(\n    const FieldDescriptor* descriptor, Context* context)\n  : descriptor_(descriptor), context_(context),\n    name_resolver_(context->GetNameResolver()) {\n  if (descriptor_->extension_scope() != NULL) {\n    scope_ = name_resolver_->GetImmutableClassName(\n        descriptor_->extension_scope());\n  } else {\n    scope_ = name_resolver_->GetImmutableClassName(descriptor_->file());\n  }\n}\n\nImmutableExtensionGenerator::~ImmutableExtensionGenerator() {}\n\n// Initializes the vars referenced in the generated code templates.\nvoid ExtensionGenerator::InitTemplateVars(const FieldDescriptor* descriptor,\n                                          const string& scope,\n                                          bool immutable,\n                                          ClassNameResolver* name_resolver,\n                                          map<string, string>* vars_pointer) {\n  map<string, string> &vars = *vars_pointer;\n  vars[\"scope\"] = scope;\n  vars[\"name\"] = UnderscoresToCamelCase(descriptor);\n  vars[\"containing_type\"] =\n      name_resolver->GetClassName(descriptor->containing_type(), immutable);\n  vars[\"number\"] = SimpleItoa(descriptor->number());\n  vars[\"constant_name\"] = FieldConstantName(descriptor);\n  vars[\"index\"] = SimpleItoa(descriptor->index());\n  vars[\"default\"] = descriptor->is_repeated() ?\n      \"\" : DefaultValue(descriptor, immutable, name_resolver);\n  vars[\"type_constant\"] = FieldTypeName(GetType(descriptor));\n  vars[\"packed\"] = descriptor->options().packed() ? \"true\" : \"false\";\n  vars[\"enum_map\"] = \"null\";\n  vars[\"prototype\"] = \"null\";\n\n  JavaType java_type = GetJavaType(descriptor);\n  string singular_type;\n  switch (java_type) {\n    case JAVATYPE_MESSAGE:\n      singular_type = name_resolver->GetClassName(descriptor->message_type(),\n                                                   immutable);\n      vars[\"prototype\"] = singular_type + \".getDefaultInstance()\";\n      break;\n    case JAVATYPE_ENUM:\n      singular_type = name_resolver->GetClassName(descriptor->enum_type(),\n                                                   immutable);\n      vars[\"enum_map\"] = singular_type + \".internalGetValueMap()\";\n      break;\n    case JAVATYPE_STRING:\n      singular_type = \"java.lang.String\";\n      break;\n    case JAVATYPE_BYTES:\n      singular_type = immutable ? \"com.google.protobuf.ByteString\" : \"byte[]\";\n      break;\n    default:\n      singular_type = BoxedPrimitiveTypeName(java_type);\n      break;\n  }\n  vars[\"type\"] = descriptor->is_repeated() ?\n      \"java.util.List<\" + singular_type + \">\" : singular_type;\n  vars[\"singular_type\"] = singular_type;\n}\n\nvoid ImmutableExtensionGenerator::Generate(io::Printer* printer) {\n  map<string, string> vars;\n  const bool kUseImmutableNames = true;\n  InitTemplateVars(descriptor_, scope_, kUseImmutableNames, name_resolver_,\n                   &vars);\n  printer->Print(vars,\n      \"public static final int $constant_name$ = $number$;\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  if (descriptor_->extension_scope() == NULL) {\n    // Non-nested\n    printer->Print(\n        vars,\n        \"public static final\\n\"\n        \"  com.google.protobuf.GeneratedMessage.GeneratedExtension<\\n\"\n        \"    $containing_type$,\\n\"\n        \"    $type$> $name$ = com.google.protobuf.GeneratedMessage\\n\"\n        \"        .newFileScopedGeneratedExtension(\\n\"\n        \"      $singular_type$.class,\\n\"\n        \"      $prototype$);\\n\");\n  } else {\n    // Nested\n    printer->Print(\n        vars,\n        \"public static final\\n\"\n        \"  com.google.protobuf.GeneratedMessage.GeneratedExtension<\\n\"\n        \"    $containing_type$,\\n\"\n        \"    $type$> $name$ = com.google.protobuf.GeneratedMessage\\n\"\n        \"        .newMessageScopedGeneratedExtension(\\n\"\n        \"      $scope$.getDefaultInstance(),\\n\"\n        \"      $index$,\\n\"\n        \"      $singular_type$.class,\\n\"\n        \"      $prototype$);\\n\");\n  }\n}\n\nint ImmutableExtensionGenerator::GenerateNonNestedInitializationCode(\n    io::Printer* printer) {\n  int bytecode_estimate = 0;\n  if (descriptor_->extension_scope() == NULL) {\n    // Only applies to non-nested extensions.\n    printer->Print(\n        \"$name$.internalInit(descriptor.getExtensions().get($index$));\\n\",\n        \"name\", UnderscoresToCamelCase(descriptor_),\n        \"index\", SimpleItoa(descriptor_->index()));\n    bytecode_estimate += 21;\n  }\n  return bytecode_estimate;\n}\n\nint ImmutableExtensionGenerator::GenerateRegistrationCode(\n    io::Printer* printer) {\n  printer->Print(\n    \"registry.add($scope$.$name$);\\n\",\n    \"scope\", scope_,\n    \"name\", UnderscoresToCamelCase(descriptor_));\n  return 7;\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_extension.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\n  class FieldDescriptor;       // descriptor.h\n  namespace compiler {\n    namespace java {\n      class Context;           // context.h\n      class ClassNameResolver; // name_resolver.h\n    }\n  }\n  namespace io {\n    class Printer;             // printer.h\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\n// Generates code for an extension, which may be within the scope of some\n// message or may be at file scope.  This is much simpler than FieldGenerator\n// since extensions are just simple identifiers with interesting types.\nclass ExtensionGenerator {\n public:\n  explicit ExtensionGenerator() {}\n  virtual ~ExtensionGenerator() {}\n\n  virtual void Generate(io::Printer* printer) = 0;\n\n  // Returns an estimate of the number of bytes the printed code will compile to\n  virtual int GenerateNonNestedInitializationCode(io::Printer* printer) = 0;\n\n  // Returns an estimate of the number of bytes the printed code will compile to\n  virtual int GenerateRegistrationCode(io::Printer* printer) = 0;\n\n protected:\n  static void InitTemplateVars(const FieldDescriptor* descriptor,\n                               const string& scope,\n                               bool immutable,\n                               ClassNameResolver* name_resolver,\n                               map<string, string>* vars_pointer);\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator);\n};\n\nclass ImmutableExtensionGenerator : public ExtensionGenerator {\n public:\n  explicit ImmutableExtensionGenerator(const FieldDescriptor* descriptor,\n                                       Context* context);\n  virtual ~ImmutableExtensionGenerator();\n\n  virtual void Generate(io::Printer* printer);\n  virtual int GenerateNonNestedInitializationCode(io::Printer* printer);\n  virtual int GenerateRegistrationCode(io::Printer* printer);\n\n protected:\n  const FieldDescriptor* descriptor_;\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n  string scope_;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableExtensionGenerator);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_extension_lite.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/compiler/java/java_extension_lite.h>\n\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nImmutableExtensionLiteGenerator::ImmutableExtensionLiteGenerator(\n    const FieldDescriptor* descriptor, Context* context)\n  : descriptor_(descriptor), context_(context),\n    name_resolver_(context->GetNameResolver()) {\n  if (descriptor_->extension_scope() != NULL) {\n    scope_ = name_resolver_->GetImmutableClassName(\n        descriptor_->extension_scope());\n  } else {\n    scope_ = name_resolver_->GetImmutableClassName(descriptor_->file());\n  }\n}\n\nImmutableExtensionLiteGenerator::~ImmutableExtensionLiteGenerator() {}\n\nvoid ImmutableExtensionLiteGenerator::Generate(io::Printer* printer) {\n  map<string, string> vars;\n  const bool kUseImmutableNames = true;\n  InitTemplateVars(descriptor_, scope_, kUseImmutableNames, name_resolver_,\n                   &vars);\n  printer->Print(vars,\n      \"public static final int $constant_name$ = $number$;\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  if (descriptor_->is_repeated()) {\n    printer->Print(\n        vars,\n        \"public static final\\n\"\n        \"  com.google.protobuf.GeneratedMessageLite.GeneratedExtension<\\n\"\n        \"    $containing_type$,\\n\"\n        \"    $type$> $name$ = com.google.protobuf.GeneratedMessageLite\\n\"\n        \"        .newRepeatedGeneratedExtension(\\n\"\n        \"      $containing_type$.getDefaultInstance(),\\n\"\n        \"      $prototype$,\\n\"\n        \"      $enum_map$,\\n\"\n        \"      $number$,\\n\"\n        \"      com.google.protobuf.WireFormat.FieldType.$type_constant$,\\n\"\n        \"      $packed$,\\n\"\n        \"      $singular_type$.class);\\n\");\n  } else {\n    printer->Print(\n        vars,\n        \"public static final\\n\"\n        \"  com.google.protobuf.GeneratedMessageLite.GeneratedExtension<\\n\"\n        \"    $containing_type$,\\n\"\n        \"    $type$> $name$ = com.google.protobuf.GeneratedMessageLite\\n\"\n        \"        .newSingularGeneratedExtension(\\n\"\n        \"      $containing_type$.getDefaultInstance(),\\n\"\n        \"      $default$,\\n\"\n        \"      $prototype$,\\n\"\n        \"      $enum_map$,\\n\"\n        \"      $number$,\\n\"\n        \"      com.google.protobuf.WireFormat.FieldType.$type_constant$,\\n\"\n        \"      $singular_type$.class);\\n\");\n  }\n}\n\nint ImmutableExtensionLiteGenerator::GenerateNonNestedInitializationCode(\n    io::Printer* printer) {\n  return 0;\n}\n\nint ImmutableExtensionLiteGenerator::GenerateRegistrationCode(\n    io::Printer* printer) {\n  printer->Print(\n    \"registry.add($scope$.$name$);\\n\",\n    \"scope\", scope_,\n    \"name\", UnderscoresToCamelCase(descriptor_));\n  return 7;\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_extension_lite.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_LITE_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_LITE_H__\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/compiler/java/java_extension.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\n// Generates code for a lite extension, which may be within the scope of some\n// message or may be at file scope.  This is much simpler than FieldGenerator\n// since extensions are just simple identifiers with interesting types.\nclass ImmutableExtensionLiteGenerator : public ExtensionGenerator {\n public:\n  explicit ImmutableExtensionLiteGenerator(const FieldDescriptor* descriptor,\n                                           Context* context);\n  virtual ~ImmutableExtensionLiteGenerator();\n\n  virtual void Generate(io::Printer* printer);\n\n  // Returns an estimate of the number of bytes the printed code will compile to\n  virtual int GenerateNonNestedInitializationCode(io::Printer* printer);\n\n  // Returns an estimate of the number of bytes the printed code will compile to\n  virtual int GenerateRegistrationCode(io::Printer* printer);\n\n private:\n  const FieldDescriptor* descriptor_;\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n  string scope_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableExtensionLiteGenerator);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_EXTENSION_LITE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/java/java_field.h>\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_enum_field.h>\n#include <google/protobuf/compiler/java/java_enum_field_lite.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_lazy_message_field.h>\n#include <google/protobuf/compiler/java/java_lazy_message_field_lite.h>\n#include <google/protobuf/compiler/java/java_map_field.h>\n#include <google/protobuf/compiler/java/java_map_field_lite.h>\n#include <google/protobuf/compiler/java/java_message_field.h>\n#include <google/protobuf/compiler/java/java_message_field_lite.h>\n#include <google/protobuf/compiler/java/java_primitive_field.h>\n#include <google/protobuf/compiler/java/java_primitive_field_lite.h>\n#include <google/protobuf/compiler/java/java_string_field.h>\n#include <google/protobuf/compiler/java/java_string_field_lite.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nnamespace {\n\nImmutableFieldGenerator* MakeImmutableGenerator(\n    const FieldDescriptor* field, int messageBitIndex, int builderBitIndex,\n    Context* context) {\n  if (field->is_repeated()) {\n    switch (GetJavaType(field)) {\n      case JAVATYPE_MESSAGE:\n        if (IsMapEntry(field->message_type())) {\n          return new ImmutableMapFieldGenerator(\n              field, messageBitIndex, builderBitIndex, context);\n        } else {\n          if (IsLazy(field, context->EnforceLite())) {\n            return new RepeatedImmutableLazyMessageFieldGenerator(\n                field, messageBitIndex, builderBitIndex, context);\n          } else {\n            return new RepeatedImmutableMessageFieldGenerator(\n                field, messageBitIndex, builderBitIndex, context);\n          }\n        }\n      case JAVATYPE_ENUM:\n        return new RepeatedImmutableEnumFieldGenerator(\n            field, messageBitIndex, builderBitIndex, context);\n      case JAVATYPE_STRING:\n        return new RepeatedImmutableStringFieldGenerator(\n            field, messageBitIndex, builderBitIndex, context);\n      default:\n        return new RepeatedImmutablePrimitiveFieldGenerator(\n            field, messageBitIndex, builderBitIndex, context);\n    }\n  } else {\n    if (field->containing_oneof()) {\n      switch (GetJavaType(field)) {\n        case JAVATYPE_MESSAGE:\n          if (IsLazy(field, context->EnforceLite())) {\n            return new ImmutableLazyMessageOneofFieldGenerator(\n                field, messageBitIndex, builderBitIndex, context);\n          } else {\n            return new ImmutableMessageOneofFieldGenerator(\n                field, messageBitIndex, builderBitIndex, context);\n          }\n        case JAVATYPE_ENUM:\n          return new ImmutableEnumOneofFieldGenerator(\n              field, messageBitIndex, builderBitIndex, context);\n        case JAVATYPE_STRING:\n          return new ImmutableStringOneofFieldGenerator(\n              field, messageBitIndex, builderBitIndex, context);\n        default:\n          return new ImmutablePrimitiveOneofFieldGenerator(\n              field, messageBitIndex, builderBitIndex, context);\n      }\n    } else {\n      switch (GetJavaType(field)) {\n        case JAVATYPE_MESSAGE:\n          if (IsLazy(field, context->EnforceLite())) {\n            return new ImmutableLazyMessageFieldGenerator(\n                field, messageBitIndex, builderBitIndex, context);\n          } else {\n            return new ImmutableMessageFieldGenerator(\n                field, messageBitIndex, builderBitIndex, context);\n          }\n        case JAVATYPE_ENUM:\n          return new ImmutableEnumFieldGenerator(\n              field, messageBitIndex, builderBitIndex, context);\n        case JAVATYPE_STRING:\n          return new ImmutableStringFieldGenerator(\n              field, messageBitIndex, builderBitIndex, context);\n        default:\n          return new ImmutablePrimitiveFieldGenerator(\n              field, messageBitIndex, builderBitIndex, context);\n      }\n    }\n  }\n}\n\nImmutableFieldLiteGenerator* MakeImmutableLiteGenerator(\n    const FieldDescriptor* field, int messageBitIndex, int builderBitIndex,\n    Context* context) {\n  if (field->is_repeated()) {\n    switch (GetJavaType(field)) {\n      case JAVATYPE_MESSAGE:\n        if (IsMapEntry(field->message_type())) {\n          return new ImmutableMapFieldLiteGenerator(\n              field, messageBitIndex, builderBitIndex, context);\n        } else {\n          if (IsLazy(field, context->EnforceLite())) {\n            return new RepeatedImmutableLazyMessageFieldLiteGenerator(\n                field, messageBitIndex, builderBitIndex, context);\n          } else {\n            return new RepeatedImmutableMessageFieldLiteGenerator(\n                field, messageBitIndex, builderBitIndex, context);\n          }\n        }\n      case JAVATYPE_ENUM:\n        return new RepeatedImmutableEnumFieldLiteGenerator(\n            field, messageBitIndex, builderBitIndex, context);\n      case JAVATYPE_STRING:\n        return new RepeatedImmutableStringFieldLiteGenerator(\n            field, messageBitIndex, builderBitIndex, context);\n      default:\n        return new RepeatedImmutablePrimitiveFieldLiteGenerator(\n            field, messageBitIndex, builderBitIndex, context);\n    }\n  } else {\n    if (field->containing_oneof()) {\n      switch (GetJavaType(field)) {\n        case JAVATYPE_MESSAGE:\n          if (IsLazy(field, context->EnforceLite())) {\n            return new ImmutableLazyMessageOneofFieldLiteGenerator(\n                field, messageBitIndex, builderBitIndex, context);\n          } else {\n            return new ImmutableMessageOneofFieldLiteGenerator(\n                field, messageBitIndex, builderBitIndex, context);\n          }\n        case JAVATYPE_ENUM:\n          return new ImmutableEnumOneofFieldLiteGenerator(\n              field, messageBitIndex, builderBitIndex, context);\n        case JAVATYPE_STRING:\n          return new ImmutableStringOneofFieldLiteGenerator(\n              field, messageBitIndex, builderBitIndex, context);\n        default:\n          return new ImmutablePrimitiveOneofFieldLiteGenerator(\n              field, messageBitIndex, builderBitIndex, context);\n      }\n    } else {\n      switch (GetJavaType(field)) {\n        case JAVATYPE_MESSAGE:\n          if (IsLazy(field, context->EnforceLite())) {\n            return new ImmutableLazyMessageFieldLiteGenerator(\n                field, messageBitIndex, builderBitIndex, context);\n          } else {\n            return new ImmutableMessageFieldLiteGenerator(\n                field, messageBitIndex, builderBitIndex, context);\n          }\n        case JAVATYPE_ENUM:\n          return new ImmutableEnumFieldLiteGenerator(\n              field, messageBitIndex, builderBitIndex, context);\n        case JAVATYPE_STRING:\n          return new ImmutableStringFieldLiteGenerator(\n              field, messageBitIndex, builderBitIndex, context);\n        default:\n          return new ImmutablePrimitiveFieldLiteGenerator(\n              field, messageBitIndex, builderBitIndex, context);\n      }\n    }\n  }\n}\n\n\nstatic inline void ReportUnexpectedPackedFieldsCall(io::Printer* printer) {\n  // Reaching here indicates a bug. Cases are:\n  //   - This FieldGenerator should support packing,\n  //     but this method should be overridden.\n  //   - This FieldGenerator doesn't support packing, and this method\n  //     should never have been called.\n  GOOGLE_LOG(FATAL) << \"GenerateParsingCodeFromPacked() \"\n             << \"called on field generator that does not support packing.\";\n}\n\n}  // namespace\n\nImmutableFieldGenerator::~ImmutableFieldGenerator() {}\n\nvoid ImmutableFieldGenerator::\nGenerateParsingCodeFromPacked(io::Printer* printer) const {\n  ReportUnexpectedPackedFieldsCall(printer);\n}\n\nImmutableFieldLiteGenerator::~ImmutableFieldLiteGenerator() {}\n\nvoid ImmutableFieldLiteGenerator::\nGenerateParsingCodeFromPacked(io::Printer* printer) const {\n  ReportUnexpectedPackedFieldsCall(printer);\n}\n\n// ===================================================================\n\ntemplate <>\nFieldGeneratorMap<ImmutableFieldGenerator>::FieldGeneratorMap(\n    const Descriptor* descriptor, Context* context)\n    : descriptor_(descriptor),\n      field_generators_(new google::protobuf::scoped_ptr<\n          ImmutableFieldGenerator>[descriptor->field_count()]) {\n\n  // Construct all the FieldGenerators and assign them bit indices for their\n  // bit fields.\n  int messageBitIndex = 0;\n  int builderBitIndex = 0;\n  for (int i = 0; i < descriptor->field_count(); i++) {\n    ImmutableFieldGenerator* generator = MakeImmutableGenerator(\n        descriptor->field(i), messageBitIndex, builderBitIndex, context);\n    field_generators_[i].reset(generator);\n    messageBitIndex += generator->GetNumBitsForMessage();\n    builderBitIndex += generator->GetNumBitsForBuilder();\n  }\n}\n\ntemplate<>\nFieldGeneratorMap<ImmutableFieldGenerator>::~FieldGeneratorMap() {}\n\ntemplate <>\nFieldGeneratorMap<ImmutableFieldLiteGenerator>::FieldGeneratorMap(\n    const Descriptor* descriptor, Context* context)\n    : descriptor_(descriptor),\n      field_generators_(new google::protobuf::scoped_ptr<\n          ImmutableFieldLiteGenerator>[descriptor->field_count()]) {\n  // Construct all the FieldGenerators and assign them bit indices for their\n  // bit fields.\n  int messageBitIndex = 0;\n  int builderBitIndex = 0;\n  for (int i = 0; i < descriptor->field_count(); i++) {\n    ImmutableFieldLiteGenerator* generator = MakeImmutableLiteGenerator(\n        descriptor->field(i), messageBitIndex, builderBitIndex, context);\n    field_generators_[i].reset(generator);\n    messageBitIndex += generator->GetNumBitsForMessage();\n    builderBitIndex += generator->GetNumBitsForBuilder();\n  }\n}\n\ntemplate<>\nFieldGeneratorMap<ImmutableFieldLiteGenerator>::~FieldGeneratorMap() {}\n\n\nvoid SetCommonFieldVariables(const FieldDescriptor* descriptor,\n                             const FieldGeneratorInfo* info,\n                             map<string, string>* variables) {\n  (*variables)[\"field_name\"] = descriptor->name();\n  (*variables)[\"name\"] = info->name;\n  (*variables)[\"capitalized_name\"] = info->capitalized_name;\n  (*variables)[\"disambiguated_reason\"] = info->disambiguated_reason;\n  (*variables)[\"constant_name\"] = FieldConstantName(descriptor);\n  (*variables)[\"number\"] = SimpleItoa(descriptor->number());\n}\n\nvoid SetCommonOneofVariables(const FieldDescriptor* descriptor,\n                             const OneofGeneratorInfo* info,\n                             map<string, string>* variables) {\n  (*variables)[\"oneof_name\"] = info->name;\n  (*variables)[\"oneof_capitalized_name\"] = info->capitalized_name;\n  (*variables)[\"oneof_index\"] =\n      SimpleItoa(descriptor->containing_oneof()->index());\n  (*variables)[\"set_oneof_case_message\"] = info->name +\n      \"Case_ = \" + SimpleItoa(descriptor->number());\n  (*variables)[\"clear_oneof_case_message\"] = info->name +\n      \"Case_ = 0\";\n  (*variables)[\"has_oneof_case_message\"] = info->name +\n      \"Case_ == \" + SimpleItoa(descriptor->number());\n}\n\nvoid PrintExtraFieldInfo(const map<string, string>& variables,\n                         io::Printer* printer) {\n  const map<string, string>::const_iterator it =\n      variables.find(\"disambiguated_reason\");\n  if (it != variables.end() && !it->second.empty()) {\n    printer->Print(\n        variables,\n        \"// An alternative name is used for field \\\"$field_name$\\\" because:\\n\"\n        \"//     $disambiguated_reason$\\n\");\n  }\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_FIELD_H__\n\n#include <map>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/stubs/logging.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace compiler {\n    namespace java {\n      class Context;                // context.h\n      class ClassNameResolver;      // name_resolver.h\n    }\n  }\n  namespace io {\n    class Printer;                  // printer.h\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nclass ImmutableFieldGenerator {\n public:\n  ImmutableFieldGenerator() {}\n  virtual ~ImmutableFieldGenerator();\n\n  virtual int GetNumBitsForMessage() const = 0;\n  virtual int GetNumBitsForBuilder() const = 0;\n  virtual void GenerateInterfaceMembers(io::Printer* printer) const = 0;\n  virtual void GenerateMembers(io::Printer* printer) const = 0;\n  virtual void GenerateBuilderMembers(io::Printer* printer) const = 0;\n  virtual void GenerateInitializationCode(io::Printer* printer) const = 0;\n  virtual void GenerateBuilderClearCode(io::Printer* printer) const = 0;\n  virtual void GenerateMergingCode(io::Printer* printer) const = 0;\n  virtual void GenerateBuildingCode(io::Printer* printer) const = 0;\n  virtual void GenerateParsingCode(io::Printer* printer) const = 0;\n  virtual void GenerateParsingCodeFromPacked(io::Printer* printer) const;\n  virtual void GenerateParsingDoneCode(io::Printer* printer) const = 0;\n  virtual void GenerateSerializationCode(io::Printer* printer) const = 0;\n  virtual void GenerateSerializedSizeCode(io::Printer* printer) const = 0;\n  virtual void GenerateFieldBuilderInitializationCode(io::Printer* printer)\n      const = 0;\n\n  virtual void GenerateEqualsCode(io::Printer* printer) const = 0;\n  virtual void GenerateHashCode(io::Printer* printer) const = 0;\n\n  virtual string GetBoxedType() const = 0;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableFieldGenerator);\n};\n\nclass ImmutableFieldLiteGenerator {\n public:\n  ImmutableFieldLiteGenerator() {}\n  virtual ~ImmutableFieldLiteGenerator();\n\n  virtual int GetNumBitsForMessage() const = 0;\n  virtual int GetNumBitsForBuilder() const = 0;\n  virtual void GenerateInterfaceMembers(io::Printer* printer) const = 0;\n  virtual void GenerateMembers(io::Printer* printer) const = 0;\n  virtual void GenerateBuilderMembers(io::Printer* printer) const = 0;\n  virtual void GenerateInitializationCode(io::Printer* printer) const = 0;\n  virtual void GenerateVisitCode(io::Printer* printer) const = 0;\n  virtual void GenerateDynamicMethodMakeImmutableCode(io::Printer* printer)\n      const = 0;\n  virtual void GenerateParsingCode(io::Printer* printer) const = 0;\n  virtual void GenerateParsingCodeFromPacked(io::Printer* printer) const;\n  virtual void GenerateParsingDoneCode(io::Printer* printer) const = 0;\n  virtual void GenerateSerializationCode(io::Printer* printer) const = 0;\n  virtual void GenerateSerializedSizeCode(io::Printer* printer) const = 0;\n  virtual void GenerateFieldBuilderInitializationCode(io::Printer* printer)\n      const = 0;\n\n  virtual void GenerateEqualsCode(io::Printer* printer) const = 0;\n  virtual void GenerateHashCode(io::Printer* printer) const = 0;\n\n  virtual string GetBoxedType() const = 0;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableFieldLiteGenerator);\n};\n\n\n// Convenience class which constructs FieldGenerators for a Descriptor.\ntemplate<typename FieldGeneratorType>\nclass FieldGeneratorMap {\n public:\n  explicit FieldGeneratorMap(const Descriptor* descriptor,\n                             Context* context);\n  ~FieldGeneratorMap();\n\n  const FieldGeneratorType& get(const FieldDescriptor* field) const;\n\n private:\n  const Descriptor* descriptor_;\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n  google::protobuf::scoped_array<google::protobuf::scoped_ptr<FieldGeneratorType> > field_generators_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap);\n};\n\ntemplate<typename FieldGeneratorType>\ninline const FieldGeneratorType&\nFieldGeneratorMap<FieldGeneratorType>::get(const FieldDescriptor* field) const {\n  GOOGLE_CHECK_EQ(field->containing_type(), descriptor_);\n  return *field_generators_[field->index()];\n}\n\n// Instantiate template for mutable and immutable maps.\ntemplate<>\nFieldGeneratorMap<ImmutableFieldGenerator>::\nFieldGeneratorMap(const Descriptor* descriptor,\n                  Context* context);\n\ntemplate<>\nFieldGeneratorMap<ImmutableFieldGenerator>::~FieldGeneratorMap();\n\n\n// Field information used in FieldGeneartors.\nstruct FieldGeneratorInfo {\n  string name;\n  string capitalized_name;\n  string disambiguated_reason;\n};\n\n// Oneof information used in OneofFieldGeneartors.\nstruct OneofGeneratorInfo {\n  string name;\n  string capitalized_name;\n};\n\n// Set some common variables used in variable FieldGenerators.\nvoid SetCommonFieldVariables(const FieldDescriptor* descriptor,\n                             const FieldGeneratorInfo* info,\n                             map<string, string>* variables);\n\n// Set some common oneof variables used in OneofFieldGenerators.\nvoid SetCommonOneofVariables(const FieldDescriptor* descriptor,\n                             const OneofGeneratorInfo* info,\n                             map<string, string>* variables);\n\n// Print useful comments before a field's accessors.\nvoid PrintExtraFieldInfo(const map<string, string>& variables,\n                         io::Printer* printer);\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_file.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/java/java_file.h>\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <set>\n\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_enum.h>\n#include <google/protobuf/compiler/java/java_enum_lite.h>\n#include <google/protobuf/compiler/java/java_extension.h>\n#include <google/protobuf/compiler/java/java_generator_factory.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_message.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/compiler/java/java_service.h>\n#include <google/protobuf/compiler/java/java_shared_code_generator.h>\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/dynamic_message.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nnamespace {\n\nstruct FieldDescriptorCompare {\n  bool operator ()(const FieldDescriptor* f1, const FieldDescriptor* f2) {\n    if(f1 == NULL) {\n      return false;\n    }\n    if(f2 == NULL) {\n      return true;\n    }\n    return f1->full_name() < f2->full_name();\n  }\n};\n\ntypedef std::set<const FieldDescriptor*, FieldDescriptorCompare> FieldDescriptorSet;\n\n// Recursively searches the given message to collect extensions.\n// Returns true if all the extensions can be recognized. The extensions will be\n// appended in to the extensions parameter.\n// Returns false when there are unknown fields, in which case the data in the\n// extensions output parameter is not reliable and should be discarded.\nbool CollectExtensions(const Message& message,\n                       FieldDescriptorSet* extensions) {\n  const Reflection* reflection = message.GetReflection();\n\n  // There are unknown fields that could be extensions, thus this call fails.\n  if (reflection->GetUnknownFields(message).field_count() > 0) return false;\n\n  vector<const FieldDescriptor*> fields;\n  reflection->ListFields(message, &fields);\n\n  for (int i = 0; i < fields.size(); i++) {\n    if (fields[i]->is_extension()) extensions->insert(fields[i]);\n\n    if (GetJavaType(fields[i]) == JAVATYPE_MESSAGE) {\n      if (fields[i]->is_repeated()) {\n        int size = reflection->FieldSize(message, fields[i]);\n        for (int j = 0; j < size; j++) {\n          const Message& sub_message =\n            reflection->GetRepeatedMessage(message, fields[i], j);\n          if (!CollectExtensions(sub_message, extensions)) return false;\n        }\n      } else {\n        const Message& sub_message = reflection->GetMessage(message, fields[i]);\n        if (!CollectExtensions(sub_message, extensions)) return false;\n      }\n    }\n  }\n\n  return true;\n}\n\n// Finds all extensions in the given message and its sub-messages.  If the\n// message contains unknown fields (which could be extensions), then those\n// extensions are defined in alternate_pool.\n// The message will be converted to a DynamicMessage backed by alternate_pool\n// in order to handle this case.\nvoid CollectExtensions(const FileDescriptorProto& file_proto,\n                       const DescriptorPool& alternate_pool,\n                       FieldDescriptorSet* extensions,\n                       const string& file_data) {\n  if (!CollectExtensions(file_proto, extensions)) {\n    // There are unknown fields in the file_proto, which are probably\n    // extensions. We need to parse the data into a dynamic message based on the\n    // builder-pool to find out all extensions.\n    const Descriptor* file_proto_desc = alternate_pool.FindMessageTypeByName(\n        file_proto.GetDescriptor()->full_name());\n    GOOGLE_CHECK(file_proto_desc)\n        << \"Find unknown fields in FileDescriptorProto when building \"\n        << file_proto.name()\n        << \". It's likely that those fields are custom options, however, \"\n           \"descriptor.proto is not in the transitive dependencies. \"\n           \"This normally should not happen. Please report a bug.\";\n    DynamicMessageFactory factory;\n    google::protobuf::scoped_ptr<Message> dynamic_file_proto(\n        factory.GetPrototype(file_proto_desc)->New());\n    GOOGLE_CHECK(dynamic_file_proto.get() != NULL);\n    GOOGLE_CHECK(dynamic_file_proto->ParseFromString(file_data));\n\n    // Collect the extensions again from the dynamic message. There should be no\n    // more unknown fields this time, i.e. all the custom options should be\n    // parsed as extensions now.\n    extensions->clear();\n    GOOGLE_CHECK(CollectExtensions(*dynamic_file_proto, extensions))\n        << \"Find unknown fields in FileDescriptorProto when building \"\n        << file_proto.name()\n        << \". It's likely that those fields are custom options, however, \"\n           \"those options cannot be recognized in the builder pool. \"\n           \"This normally should not happen. Please report a bug.\";\n  }\n}\n\n// Compare two field descriptors, returning true if the first should come\n// before the second.\nbool CompareFieldsByName(const FieldDescriptor *a, const FieldDescriptor *b) {\n  return a->full_name() < b->full_name();\n}\n\n// Our static initialization methods can become very, very large.\n// So large that if we aren't careful we end up blowing the JVM's\n// 64K bytes of bytecode/method. Fortunately, since these static\n// methods are executed only once near the beginning of a program,\n// there's usually plenty of stack space available and we can\n// extend our methods by simply chaining them to another method\n// with a tail call. This inserts the sequence call-next-method,\n// end this one, begin-next-method as needed.\nvoid MaybeRestartJavaMethod(io::Printer* printer,\n                            int *bytecode_estimate,\n                            int *method_num,\n                            const char *chain_statement,\n                            const char *method_decl) {\n  // The goal here is to stay under 64K bytes of jvm bytecode/method,\n  // since otherwise we hit a hardcoded limit in the jvm and javac will\n  // then fail with the error \"code too large\". This limit lets our\n  // estimates be off by a factor of two and still we're okay.\n  static const int bytesPerMethod = kMaxStaticSize;\n\n  if ((*bytecode_estimate) > bytesPerMethod) {\n    ++(*method_num);\n    printer->Print(chain_statement, \"method_num\", SimpleItoa(*method_num));\n    printer->Outdent();\n    printer->Print(\"}\\n\");\n    printer->Print(method_decl, \"method_num\", SimpleItoa(*method_num));\n    printer->Indent();\n    *bytecode_estimate = 0;\n  }\n}\n\n\n}  // namespace\n\nFileGenerator::FileGenerator(const FileDescriptor* file, const Options& options,\n                             bool immutable_api)\n    : file_(file),\n      java_package_(FileJavaPackage(file, immutable_api)),\n      message_generators_(\n          new google::protobuf::scoped_ptr<MessageGenerator>[file->message_type_count()]),\n      extension_generators_(\n          new google::protobuf::scoped_ptr<ExtensionGenerator>[file->extension_count()]),\n      context_(new Context(file, options)),\n      name_resolver_(context_->GetNameResolver()),\n      options_(options),\n      immutable_api_(immutable_api) {\n  classname_ = name_resolver_->GetFileClassName(file, immutable_api);\n  generator_factory_.reset(\n      new ImmutableGeneratorFactory(context_.get()));\n  for (int i = 0; i < file_->message_type_count(); ++i) {\n    message_generators_[i].reset(\n        generator_factory_->NewMessageGenerator(file_->message_type(i)));\n  }\n  for (int i = 0; i < file_->extension_count(); ++i) {\n    extension_generators_[i].reset(\n        generator_factory_->NewExtensionGenerator(file_->extension(i)));\n  }\n}\n\nFileGenerator::~FileGenerator() {}\n\nbool FileGenerator::Validate(string* error) {\n  // Check that no class name matches the file's class name.  This is a common\n  // problem that leads to Java compile errors that can be hard to understand.\n  // It's especially bad when using the java_multiple_files, since we would\n  // end up overwriting the outer class with one of the inner ones.\n  if (name_resolver_->HasConflictingClassName(file_, classname_)) {\n    error->assign(file_->name());\n    error->append(\n      \": Cannot generate Java output because the file's outer class name, \\\"\");\n    error->append(classname_);\n    error->append(\n      \"\\\", matches the name of one of the types declared inside it.  \"\n      \"Please either rename the type or use the java_outer_classname \"\n      \"option to specify a different outer class name for the .proto file.\");\n    return false;\n  }\n  return true;\n}\n\nvoid FileGenerator::Generate(io::Printer* printer) {\n  // We don't import anything because we refer to all classes by their\n  // fully-qualified names in the generated source.\n  printer->Print(\n    \"// Generated by the protocol buffer compiler.  DO NOT EDIT!\\n\"\n    \"// source: $filename$\\n\"\n    \"\\n\",\n    \"filename\", file_->name());\n  if (!java_package_.empty()) {\n    printer->Print(\n      \"package $package$;\\n\"\n      \"\\n\",\n      \"package\", java_package_);\n  }\n  PrintGeneratedAnnotation(\n      printer, '$', options_.annotate_code ? classname_ + \".java.pb.meta\" : \"\");\n  printer->Print(\n      \"public final class $classname$ {\\n\"\n      \"  private $ctor$() {}\\n\",\n      \"classname\", classname_, \"ctor\", classname_);\n  printer->Annotate(\"classname\", file_->name());\n  printer->Indent();\n\n  // -----------------------------------------------------------------\n\n  printer->Print(\n    \"public static void registerAllExtensions(\\n\"\n    \"    com.google.protobuf.ExtensionRegistryLite registry) {\\n\");\n\n  printer->Indent();\n\n  for (int i = 0; i < file_->extension_count(); i++) {\n    extension_generators_[i]->GenerateRegistrationCode(printer);\n  }\n\n  for (int i = 0; i < file_->message_type_count(); i++) {\n    message_generators_[i]->GenerateExtensionRegistrationCode(printer);\n  }\n\n  printer->Outdent();\n  printer->Print(\n    \"}\\n\");\n  if (HasDescriptorMethods(file_, context_->EnforceLite())) {\n    // Overload registerAllExtensions for the non-lite usage to\n    // redundantly maintain the original signature (this is\n    // redundant because ExtensionRegistryLite now invokes\n    // ExtensionRegistry in the non-lite usage). Intent is\n    // to remove this in the future.\n    printer->Print(\n      \"\\n\"\n      \"public static void registerAllExtensions(\\n\"\n      \"    com.google.protobuf.ExtensionRegistry registry) {\\n\"\n      \"  registerAllExtensions(\\n\"\n      \"      (com.google.protobuf.ExtensionRegistryLite) registry);\\n\"\n      \"}\\n\");\n  }\n\n  // -----------------------------------------------------------------\n\n  if (!MultipleJavaFiles(file_, immutable_api_)) {\n    for (int i = 0; i < file_->enum_type_count(); i++) {\n      if (HasDescriptorMethods(file_, context_->EnforceLite())) {\n        EnumGenerator(file_->enum_type(i), immutable_api_, context_.get())\n            .Generate(printer);\n      } else {\n        EnumLiteGenerator(file_->enum_type(i), immutable_api_, context_.get())\n            .Generate(printer);\n      }\n    }\n    for (int i = 0; i < file_->message_type_count(); i++) {\n      message_generators_[i]->GenerateInterface(printer);\n      message_generators_[i]->Generate(printer);\n    }\n    if (HasGenericServices(file_, context_->EnforceLite())) {\n      for (int i = 0; i < file_->service_count(); i++) {\n        google::protobuf::scoped_ptr<ServiceGenerator> generator(\n            generator_factory_->NewServiceGenerator(file_->service(i)));\n        generator->Generate(printer);\n      }\n    }\n  }\n\n  // Extensions must be generated in the outer class since they are values,\n  // not classes.\n  for (int i = 0; i < file_->extension_count(); i++) {\n    extension_generators_[i]->Generate(printer);\n  }\n\n  // Static variables. We'd like them to be final if possible, but due to\n  // the JVM's 64k size limit on static blocks, we have to initialize some\n  // of them in methods; thus they cannot be final.\n  int static_block_bytecode_estimate = 0;\n  for (int i = 0; i < file_->message_type_count(); i++) {\n    message_generators_[i]->GenerateStaticVariables(\n        printer, &static_block_bytecode_estimate);\n  }\n\n  printer->Print(\"\\n\");\n\n  if (HasDescriptorMethods(file_, context_->EnforceLite())) {\n    if (immutable_api_) {\n      GenerateDescriptorInitializationCodeForImmutable(printer);\n    } else {\n      GenerateDescriptorInitializationCodeForMutable(printer);\n    }\n  } else {\n    printer->Print(\n      \"static {\\n\");\n    printer->Indent();\n    int bytecode_estimate = 0;\n    int method_num = 0;\n\n    for (int i = 0; i < file_->message_type_count(); i++) {\n      bytecode_estimate += message_generators_[i]->GenerateStaticVariableInitializers(printer);\n      MaybeRestartJavaMethod(\n        printer,\n        &bytecode_estimate, &method_num,\n        \"_clinit_autosplit_$method_num$();\\n\",\n        \"private static void _clinit_autosplit_$method_num$() {\\n\");\n    }\n\n    printer->Outdent();\n    printer->Print(\n      \"}\\n\");\n  }\n\n  printer->Print(\n    \"\\n\"\n    \"// @@protoc_insertion_point(outer_class_scope)\\n\");\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid FileGenerator::GenerateDescriptorInitializationCodeForImmutable(\n    io::Printer* printer) {\n  printer->Print(\n    \"public static com.google.protobuf.Descriptors.FileDescriptor\\n\"\n    \"    getDescriptor() {\\n\"\n    \"  return descriptor;\\n\"\n    \"}\\n\"\n    \"private static $final$ com.google.protobuf.Descriptors.FileDescriptor\\n\"\n    \"    descriptor;\\n\"\n    \"static {\\n\",\n    // TODO(dweis): Mark this as final.\n    \"final\", \"\");\n  printer->Indent();\n\n  SharedCodeGenerator shared_code_generator(file_, options_);\n  shared_code_generator.GenerateDescriptors(printer);\n\n  int bytecode_estimate = 0;\n  int method_num = 0;\n\n  for (int i = 0; i < file_->message_type_count(); i++) {\n    bytecode_estimate += message_generators_[i]->GenerateStaticVariableInitializers(printer);\n    MaybeRestartJavaMethod(\n      printer,\n      &bytecode_estimate, &method_num,\n      \"_clinit_autosplit_dinit_$method_num$();\\n\",\n      \"private static void _clinit_autosplit_dinit_$method_num$() {\\n\");\n  }\n  for (int i = 0; i < file_->extension_count(); i++) {\n    bytecode_estimate += extension_generators_[i]->GenerateNonNestedInitializationCode(printer);\n    MaybeRestartJavaMethod(\n      printer,\n      &bytecode_estimate, &method_num,\n      \"_clinit_autosplit_dinit_$method_num$();\\n\",\n      \"private static void _clinit_autosplit_dinit_$method_num$() {\\n\");\n  }\n\n  // Proto compiler builds a DescriptorPool, which holds all the descriptors to\n  // generate, when processing the \".proto\" files. We call this DescriptorPool\n  // the parsed pool (a.k.a. file_->pool()).\n  //\n  // Note that when users try to extend the (.*)DescriptorProto in their\n  // \".proto\" files, it does not affect the pre-built FileDescriptorProto class\n  // in proto compiler. When we put the descriptor data in the file_proto, those\n  // extensions become unknown fields.\n  //\n  // Now we need to find out all the extension value to the (.*)DescriptorProto\n  // in the file_proto message, and prepare an ExtensionRegistry to return.\n  //\n  // To find those extensions, we need to parse the data into a dynamic message\n  // of the FileDescriptor based on the builder-pool, then we can use\n  // reflections to find all extension fields\n  FileDescriptorProto file_proto;\n  file_->CopyTo(&file_proto);\n  string file_data;\n  file_proto.SerializeToString(&file_data);\n  FieldDescriptorSet extensions;\n  CollectExtensions(file_proto, *file_->pool(), &extensions, file_data);\n\n  if (extensions.size() > 0) {\n    // Must construct an ExtensionRegistry containing all existing extensions\n    // and use it to parse the descriptor data again to recognize extensions.\n    printer->Print(\n      \"com.google.protobuf.ExtensionRegistry registry =\\n\"\n      \"    com.google.protobuf.ExtensionRegistry.newInstance();\\n\");\n    FieldDescriptorSet::iterator it;\n    for (it = extensions.begin(); it != extensions.end(); it++) {\n      google::protobuf::scoped_ptr<ExtensionGenerator> generator(\n          generator_factory_->NewExtensionGenerator(*it));\n      bytecode_estimate += generator->GenerateRegistrationCode(printer);\n      MaybeRestartJavaMethod(\n        printer,\n        &bytecode_estimate, &method_num,\n        \"_clinit_autosplit_dinit_$method_num$(registry);\\n\",\n        \"private static void _clinit_autosplit_dinit_$method_num$(\\n\"\n        \"    com.google.protobuf.ExtensionRegistry registry) {\\n\");\n    }\n    printer->Print(\n      \"com.google.protobuf.Descriptors.FileDescriptor\\n\"\n      \"    .internalUpdateFileDescriptor(descriptor, registry);\\n\");\n  }\n\n  // Force descriptor initialization of all dependencies.\n  for (int i = 0; i < file_->dependency_count(); i++) {\n    if (ShouldIncludeDependency(file_->dependency(i), true)) {\n      string dependency =\n          name_resolver_->GetImmutableClassName(file_->dependency(i));\n      printer->Print(\n        \"$dependency$.getDescriptor();\\n\",\n        \"dependency\", dependency);\n    }\n  }\n\n  printer->Outdent();\n  printer->Print(\n    \"}\\n\");\n}\n\nvoid FileGenerator::GenerateDescriptorInitializationCodeForMutable(io::Printer* printer) {\n  printer->Print(\n    \"public static com.google.protobuf.Descriptors.FileDescriptor\\n\"\n    \"    getDescriptor() {\\n\"\n    \"  return descriptor;\\n\"\n    \"}\\n\"\n    \"private static final com.google.protobuf.Descriptors.FileDescriptor\\n\"\n    \"    descriptor;\\n\"\n    \"static {\\n\");\n  printer->Indent();\n\n  printer->Print(\n    \"descriptor = $immutable_package$.$descriptor_classname$.descriptor;\\n\",\n    \"immutable_package\", FileJavaPackage(file_, true),\n    \"descriptor_classname\", name_resolver_->GetDescriptorClassName(file_));\n\n  for (int i = 0; i < file_->message_type_count(); i++) {\n    message_generators_[i]->GenerateStaticVariableInitializers(printer);\n  }\n  for (int i = 0; i < file_->extension_count(); i++) {\n    extension_generators_[i]->GenerateNonNestedInitializationCode(printer);\n  }\n\n  // Check if custom options exist. If any, try to load immutable classes since\n  // custom options are only represented with immutable messages.\n  FileDescriptorProto file_proto;\n  file_->CopyTo(&file_proto);\n  string file_data;\n  file_proto.SerializeToString(&file_data);\n  FieldDescriptorSet extensions;\n  CollectExtensions(file_proto, *file_->pool(), &extensions, file_data);\n\n  if (extensions.size() > 0) {\n    // Try to load immutable messages' outer class. Its initialization code\n    // will take care of interpreting custom options.\n    printer->Print(\n      \"try {\\n\"\n      // Note that we have to load the immutable class dynamically here as\n      // we want the mutable code to be independent from the immutable code\n      // at compile time. It is required to implement dual-compile for\n      // mutable and immutable API in blaze.\n      \"  java.lang.Class immutableClass = java.lang.Class.forName(\\n\"\n      \"      \\\"$immutable_classname$\\\");\\n\"\n      \"} catch (java.lang.ClassNotFoundException e) {\\n\"\n      // The immutable class can not be found. Custom options are left\n      // as unknown fields.\n      // TODO(xiaofeng): inform the user with a warning?\n      \"}\\n\",\n      \"immutable_classname\", name_resolver_->GetImmutableClassName(file_));\n  }\n\n  // Force descriptor initialization of all dependencies.\n  for (int i = 0; i < file_->dependency_count(); i++) {\n    if (ShouldIncludeDependency(file_->dependency(i), false)) {\n      string dependency = name_resolver_->GetMutableClassName(\n          file_->dependency(i));\n      printer->Print(\n        \"$dependency$.getDescriptor();\\n\",\n        \"dependency\", dependency);\n    }\n  }\n\n  printer->Outdent();\n  printer->Print(\n    \"}\\n\");\n}\n\ntemplate <typename GeneratorClass, typename DescriptorClass>\nstatic void GenerateSibling(const string& package_dir,\n                            const string& java_package,\n                            const DescriptorClass* descriptor,\n                            GeneratorContext* context,\n                            vector<string>* file_list, bool annotate_code,\n                            vector<string>* annotation_list,\n                            const string& name_suffix,\n                            GeneratorClass* generator,\n                            void (GeneratorClass::*pfn)(io::Printer* printer)) {\n  string filename = package_dir + descriptor->name() + name_suffix + \".java\";\n  file_list->push_back(filename);\n  string info_full_path = filename + \".pb.meta\";\n  GeneratedCodeInfo annotations;\n  io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(\n      &annotations);\n\n  google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(context->Open(filename));\n  io::Printer printer(output.get(), '$',\n                      annotate_code ? &annotation_collector : NULL);\n\n  printer.Print(\n    \"// Generated by the protocol buffer compiler.  DO NOT EDIT!\\n\"\n    \"// source: $filename$\\n\"\n    \"\\n\",\n    \"filename\", descriptor->file()->name());\n  if (!java_package.empty()) {\n    printer.Print(\n      \"package $package$;\\n\"\n      \"\\n\",\n      \"package\", java_package);\n  }\n\n  (generator->*pfn)(&printer);\n\n  if (annotate_code) {\n    google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> info_output(\n        context->Open(info_full_path));\n    annotations.SerializeToZeroCopyStream(info_output.get());\n    annotation_list->push_back(info_full_path);\n  }\n}\n\nvoid FileGenerator::GenerateSiblings(const string& package_dir,\n                                     GeneratorContext* context,\n                                     vector<string>* file_list,\n                                     vector<string>* annotation_list) {\n  if (MultipleJavaFiles(file_, immutable_api_)) {\n    for (int i = 0; i < file_->enum_type_count(); i++) {\n      if (HasDescriptorMethods(file_, context_->EnforceLite())) {\n        EnumGenerator generator(file_->enum_type(i), immutable_api_,\n                                context_.get());\n        GenerateSibling<EnumGenerator>(\n            package_dir, java_package_, file_->enum_type(i), context, file_list,\n            options_.annotate_code, annotation_list, \"\", &generator,\n            &EnumGenerator::Generate);\n      } else {\n        EnumLiteGenerator generator(file_->enum_type(i), immutable_api_,\n                                    context_.get());\n        GenerateSibling<EnumLiteGenerator>(\n            package_dir, java_package_, file_->enum_type(i), context, file_list,\n            options_.annotate_code, annotation_list, \"\", &generator,\n            &EnumLiteGenerator::Generate);\n      }\n    }\n    for (int i = 0; i < file_->message_type_count(); i++) {\n      if (immutable_api_) {\n        GenerateSibling<MessageGenerator>(\n            package_dir, java_package_, file_->message_type(i), context,\n            file_list, options_.annotate_code, annotation_list, \"OrBuilder\",\n            message_generators_[i].get(), &MessageGenerator::GenerateInterface);\n      }\n      GenerateSibling<MessageGenerator>(\n          package_dir, java_package_, file_->message_type(i), context,\n          file_list, options_.annotate_code, annotation_list, \"\",\n          message_generators_[i].get(), &MessageGenerator::Generate);\n    }\n    if (HasGenericServices(file_, context_->EnforceLite())) {\n      for (int i = 0; i < file_->service_count(); i++) {\n        google::protobuf::scoped_ptr<ServiceGenerator> generator(\n            generator_factory_->NewServiceGenerator(file_->service(i)));\n        GenerateSibling<ServiceGenerator>(\n            package_dir, java_package_, file_->service(i), context, file_list,\n            options_.annotate_code, annotation_list, \"\", generator.get(),\n            &ServiceGenerator::Generate);\n      }\n    }\n  }\n}\n\nbool FileGenerator::ShouldIncludeDependency(\n    const FileDescriptor* descriptor, bool immutable_api) {\n  return true;\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_file.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <string>\n#include <vector>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/compiler/java/java_options.h>\n\nnamespace google {\nnamespace protobuf {\n  class FileDescriptor;          // descriptor.h\n  namespace io {\n    class Printer;               // printer.h\n  }\n  namespace compiler {\n    class GeneratorContext;      // code_generator.h\n    namespace java {\n      class Context;             // context.h\n      class MessageGenerator;    // message.h\n      class GeneratorFactory;    // generator_factory.h\n      class ExtensionGenerator;  // extension.h\n      class ClassNameResolver;   // name_resolver.h\n    }\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nclass FileGenerator {\n public:\n  FileGenerator(const FileDescriptor* file, const Options& options,\n                bool immutable_api = true);\n  ~FileGenerator();\n\n  // Checks for problems that would otherwise lead to cryptic compile errors.\n  // Returns true if there are no problems, or writes an error description to\n  // the given string and returns false otherwise.\n  bool Validate(string* error);\n\n  void Generate(io::Printer* printer);\n\n  // If we aren't putting everything into one file, this will write all the\n  // files other than the outer file (i.e. one for each message, enum, and\n  // service type).\n  void GenerateSiblings(const string& package_dir,\n                        GeneratorContext* generator_context,\n                        vector<string>* file_list,\n                        vector<string>* annotation_list);\n\n  const string& java_package() { return java_package_; }\n  const string& classname()    { return classname_;    }\n\n private:\n  void GenerateDescriptorInitializationCodeForImmutable(io::Printer* printer);\n  void GenerateDescriptorInitializationCodeForMutable(io::Printer* printer);\n\n  bool ShouldIncludeDependency(const FileDescriptor* descriptor,\n                               bool immutable_api_);\n\n  const FileDescriptor* file_;\n  string java_package_;\n  string classname_;\n\n  google::protobuf::scoped_array<google::protobuf::scoped_ptr<MessageGenerator> > message_generators_;\n  google::protobuf::scoped_array<google::protobuf::scoped_ptr<ExtensionGenerator> > extension_generators_;\n  google::protobuf::scoped_ptr<GeneratorFactory> generator_factory_;\n  google::protobuf::scoped_ptr<Context> context_;\n  ClassNameResolver* name_resolver_;\n  const Options options_;\n  bool immutable_api_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_FILE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_generator.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/java/java_generator.h>\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#include <google/protobuf/compiler/java/java_file.h>\n#include <google/protobuf/compiler/java/java_generator_factory.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_options.h>\n#include <google/protobuf/compiler/java/java_shared_code_generator.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\n\nJavaGenerator::JavaGenerator() {}\nJavaGenerator::~JavaGenerator() {}\n\nbool JavaGenerator::Generate(const FileDescriptor* file,\n                             const string& parameter,\n                             GeneratorContext* context,\n                             string* error) const {\n  // -----------------------------------------------------------------\n  // parse generator options\n\n\n  vector<pair<string, string> > options;\n  ParseGeneratorParameter(parameter, &options);\n  Options file_options;\n\n  for (int i = 0; i < options.size(); i++) {\n    if (options[i].first == \"output_list_file\") {\n      file_options.output_list_file = options[i].second;\n    } else if (options[i].first == \"immutable\") {\n      file_options.generate_immutable_code = true;\n    } else if (options[i].first == \"mutable\") {\n      file_options.generate_mutable_code = true;\n    } else if (options[i].first == \"shared\") {\n      file_options.generate_shared_code = true;\n    } else if (options[i].first == \"annotate_code\") {\n      file_options.annotate_code = true;\n    } else if (options[i].first == \"annotation_list_file\") {\n      file_options.annotation_list_file = options[i].second;\n    } else {\n      *error = \"Unknown generator option: \" + options[i].first;\n      return false;\n    }\n  }\n\n  if (file_options.enforce_lite && file_options.generate_mutable_code) {\n    *error = \"lite runtime generator option cannot be used with mutable API.\";\n    return false;\n  }\n\n  // By default we generate immutable code and shared code for immutable API.\n  if (!file_options.generate_immutable_code &&\n      !file_options.generate_mutable_code &&\n      !file_options.generate_shared_code) {\n    file_options.generate_immutable_code = true;\n    file_options.generate_shared_code = true;\n  }\n\n  // -----------------------------------------------------------------\n\n\n  vector<string> all_files;\n  vector<string> all_annotations;\n\n\n  vector<FileGenerator*> file_generators;\n  if (file_options.generate_immutable_code) {\n    file_generators.push_back(new FileGenerator(file, file_options,\n                                                /* immutable = */ true));\n  }\n  if (file_options.generate_mutable_code) {\n    file_generators.push_back(new FileGenerator(file, file_options,\n                                                /* mutable = */ false));\n  }\n  for (int i = 0; i < file_generators.size(); ++i) {\n    if (!file_generators[i]->Validate(error)) {\n      for (int j = 0; j < file_generators.size(); ++j) {\n        delete file_generators[j];\n      }\n      return false;\n    }\n  }\n\n  for (int i = 0; i < file_generators.size(); ++i) {\n    FileGenerator* file_generator = file_generators[i];\n\n    string package_dir = JavaPackageToDir(file_generator->java_package());\n\n    string java_filename = package_dir;\n    java_filename += file_generator->classname();\n    java_filename += \".java\";\n    all_files.push_back(java_filename);\n    string info_full_path = java_filename + \".pb.meta\";\n    if (file_options.annotate_code) {\n      all_annotations.push_back(info_full_path);\n    }\n\n    // Generate main java file.\n    google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(\n        context->Open(java_filename));\n    GeneratedCodeInfo annotations;\n    io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(\n        &annotations);\n    io::Printer printer(output.get(), '$', file_options.annotate_code\n                                               ? &annotation_collector\n                                               : NULL);\n\n    file_generator->Generate(&printer);\n\n    // Generate sibling files.\n    file_generator->GenerateSiblings(package_dir, context, &all_files,\n                                     &all_annotations);\n\n    if (file_options.annotate_code) {\n      google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> info_output(\n          context->Open(info_full_path));\n      annotations.SerializeToZeroCopyStream(info_output.get());\n    }\n  }\n\n  for (int i = 0; i < file_generators.size(); ++i) {\n    delete file_generators[i];\n  }\n  file_generators.clear();\n\n  // Generate output list if requested.\n  if (!file_options.output_list_file.empty()) {\n    // Generate output list.  This is just a simple text file placed in a\n    // deterministic location which lists the .java files being generated.\n    google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> srclist_raw_output(\n        context->Open(file_options.output_list_file));\n    io::Printer srclist_printer(srclist_raw_output.get(), '$');\n    for (int i = 0; i < all_files.size(); i++) {\n      srclist_printer.Print(\"$filename$\\n\", \"filename\", all_files[i]);\n    }\n  }\n\n  if (!file_options.annotation_list_file.empty()) {\n    // Generate output list.  This is just a simple text file placed in a\n    // deterministic location which lists the .java files being generated.\n    google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> annotation_list_raw_output(\n        context->Open(file_options.annotation_list_file));\n    io::Printer annotation_list_printer(annotation_list_raw_output.get(), '$');\n    for (int i = 0; i < all_annotations.size(); i++) {\n      annotation_list_printer.Print(\"$filename$\\n\", \"filename\",\n                                    all_annotations[i]);\n    }\n  }\n\n  return true;\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_generator.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Generates Java code for a given .proto file.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__\n\n#include <string>\n#include <google/protobuf/compiler/code_generator.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\n// CodeGenerator implementation which generates Java code.  If you create your\n// own protocol compiler binary and you want it to support Java output, you\n// can do so by registering an instance of this CodeGenerator with the\n// CommandLineInterface in your main() function.\nclass LIBPROTOC_EXPORT JavaGenerator : public CodeGenerator {\n public:\n  JavaGenerator();\n  ~JavaGenerator();\n\n  // implements CodeGenerator ----------------------------------------\n  bool Generate(const FileDescriptor* file,\n                const string& parameter,\n                GeneratorContext* context,\n                string* error) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(JavaGenerator);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_generator_factory.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: liujisi@google.com (Pherl Liu)\n\n#include <google/protobuf/compiler/java/java_generator_factory.h>\n\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_enum_field.h>\n#include <google/protobuf/compiler/java/java_extension.h>\n#include <google/protobuf/compiler/java/java_extension_lite.h>\n#include <google/protobuf/compiler/java/java_field.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_message.h>\n#include <google/protobuf/compiler/java/java_message_lite.h>\n#include <google/protobuf/compiler/java/java_service.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nGeneratorFactory::GeneratorFactory() {}\nGeneratorFactory::~GeneratorFactory() {}\n\n// ===================================================================\n\nImmutableGeneratorFactory::ImmutableGeneratorFactory(\n    Context* context) : context_(context) {\n}\nImmutableGeneratorFactory::~ImmutableGeneratorFactory() {}\n\nMessageGenerator* ImmutableGeneratorFactory::NewMessageGenerator(\n    const Descriptor* descriptor) const {\n  if (HasDescriptorMethods(descriptor, context_->EnforceLite())) {\n    return new ImmutableMessageGenerator(descriptor, context_);\n  } else {\n    return new ImmutableMessageLiteGenerator(descriptor, context_);\n  }\n}\n\nExtensionGenerator* ImmutableGeneratorFactory::NewExtensionGenerator(\n    const FieldDescriptor* descriptor) const {\n  if (HasDescriptorMethods(descriptor->file(), context_->EnforceLite())) {\n    return new ImmutableExtensionGenerator(descriptor, context_);\n  } else {\n    return new ImmutableExtensionLiteGenerator(descriptor, context_);\n  }\n}\n\nServiceGenerator* ImmutableGeneratorFactory::NewServiceGenerator(\n    const ServiceDescriptor* descriptor) const {\n  return new ImmutableServiceGenerator(descriptor, context_);\n}\n\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_generator_factory.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: liujisi@google.com (Pherl Liu)\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_FACTORY_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_FACTORY_H__\n\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\n  class FieldDescriptor;         // descriptor.h\n  class Descriptor;              // descriptor.h\n  class ServiceDescriptor;       // descriptor.h\n  namespace compiler {\n    namespace java {\n      class MessageGenerator;    // message.h\n      class ExtensionGenerator;  // extension.h\n      class ServiceGenerator;    // service.h\n      class Context;             // context.h\n    }\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nclass GeneratorFactory {\n public:\n  GeneratorFactory();\n  virtual ~GeneratorFactory();\n\n  virtual MessageGenerator* NewMessageGenerator(\n      const Descriptor* descriptor) const = 0;\n\n  virtual ExtensionGenerator* NewExtensionGenerator(\n      const FieldDescriptor* descriptor) const = 0;\n\n  virtual ServiceGenerator* NewServiceGenerator(\n      const ServiceDescriptor* descriptor) const = 0;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratorFactory);\n};\n\n// Factory that creates generators for immutable-default messages.\nclass ImmutableGeneratorFactory : public GeneratorFactory {\n public:\n  ImmutableGeneratorFactory(Context* context);\n  virtual ~ImmutableGeneratorFactory();\n\n  virtual MessageGenerator* NewMessageGenerator(\n      const Descriptor* descriptor) const;\n\n  virtual ExtensionGenerator* NewExtensionGenerator(\n      const FieldDescriptor* descriptor) const;\n\n  virtual ServiceGenerator* NewServiceGenerator(\n      const ServiceDescriptor* descriptor) const;\n\n private:\n  Context* context_;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableGeneratorFactory);\n};\n\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_GENERATOR_FACTORY_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_helpers.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <algorithm>\n#include <google/protobuf/stubs/hash.h>\n#include <limits>\n#include <vector>\n\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nusing internal::WireFormat;\nusing internal::WireFormatLite;\n\nconst char kThickSeparator[] =\n  \"// ===================================================================\\n\";\nconst char kThinSeparator[] =\n  \"// -------------------------------------------------------------------\\n\";\n\nnamespace {\n\nconst char* kDefaultPackage = \"\";\n\n// Names that should be avoided as field names.\n// Using them will cause the compiler to generate accessors whose names are\n// colliding with methods defined in base classes.\nconst char* kForbiddenWordList[] = {\n  // message base class:\n  \"cached_size\", \"serialized_size\",\n  // java.lang.Object:\n  \"class\",\n};\n\nbool IsForbidden(const string& field_name) {\n  for (int i = 0; i < GOOGLE_ARRAYSIZE(kForbiddenWordList); ++i) {\n    if (field_name == kForbiddenWordList[i]) {\n      return true;\n    }\n  }\n  return false;\n}\n\nstring FieldName(const FieldDescriptor* field) {\n  string field_name;\n  // Groups are hacky:  The name of the field is just the lower-cased name\n  // of the group type.  In Java, though, we would like to retain the original\n  // capitalization of the type name.\n  if (GetType(field) == FieldDescriptor::TYPE_GROUP) {\n    field_name = field->message_type()->name();\n  } else {\n    field_name = field->name();\n  }\n  if (IsForbidden(field_name)) {\n    // Append a trailing \"#\" to indicate that the name should be decorated to\n    // avoid collision with other names.\n    field_name += \"#\";\n  }\n  return field_name;\n}\n\n\n}  // namespace\n\nvoid PrintGeneratedAnnotation(io::Printer* printer, char delimiter,\n                              const string& annotation_file) {\n  if (annotation_file.empty()) {\n    return;\n  }\n  string ptemplate =\n      \"@javax.annotation.Generated(value=\\\"protoc\\\", comments=\\\"annotations:\";\n  ptemplate.push_back(delimiter);\n  ptemplate.append(\"annotation_file\");\n  ptemplate.push_back(delimiter);\n  ptemplate.append(\"\\\")\\n\");\n  printer->Print(ptemplate.c_str(), \"annotation_file\", annotation_file);\n}\n\nstring UnderscoresToCamelCase(const string& input, bool cap_next_letter) {\n  string result;\n  // Note:  I distrust ctype.h due to locales.\n  for (int i = 0; i < input.size(); i++) {\n    if ('a' <= input[i] && input[i] <= 'z') {\n      if (cap_next_letter) {\n        result += input[i] + ('A' - 'a');\n      } else {\n        result += input[i];\n      }\n      cap_next_letter = false;\n    } else if ('A' <= input[i] && input[i] <= 'Z') {\n      if (i == 0 && !cap_next_letter) {\n        // Force first letter to lower-case unless explicitly told to\n        // capitalize it.\n        result += input[i] + ('a' - 'A');\n      } else {\n        // Capital letters after the first are left as-is.\n        result += input[i];\n      }\n      cap_next_letter = false;\n    } else if ('0' <= input[i] && input[i] <= '9') {\n      result += input[i];\n      cap_next_letter = true;\n    } else {\n      cap_next_letter = true;\n    }\n  }\n  // Add a trailing \"_\" if the name should be altered.\n  if (input[input.size() - 1] == '#') {\n    result += '_';\n  }\n  return result;\n}\n\nstring UnderscoresToCamelCase(const FieldDescriptor* field) {\n  return UnderscoresToCamelCase(FieldName(field), false);\n}\n\nstring UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field) {\n  return UnderscoresToCamelCase(FieldName(field), true);\n}\n\nstring UnderscoresToCamelCase(const MethodDescriptor* method) {\n  return UnderscoresToCamelCase(method->name(), false);\n}\n\nstring UniqueFileScopeIdentifier(const Descriptor* descriptor) {\n  return \"static_\" + StringReplace(descriptor->full_name(), \".\", \"_\", true);\n}\n\nstring StripProto(const string& filename) {\n  if (HasSuffixString(filename, \".protodevel\")) {\n    return StripSuffixString(filename, \".protodevel\");\n  } else {\n    return StripSuffixString(filename, \".proto\");\n  }\n}\n\nstring FileClassName(const FileDescriptor* file, bool immutable) {\n  ClassNameResolver name_resolver;\n  return name_resolver.GetFileClassName(file, immutable);\n}\n\nstring FileJavaPackage(const FileDescriptor* file, bool immutable) {\n  string result;\n\n  if (file->options().has_java_package()) {\n    result = file->options().java_package();\n  } else {\n    result = kDefaultPackage;\n    if (!file->package().empty()) {\n      if (!result.empty()) result += '.';\n      result += file->package();\n    }\n  }\n\n  return result;\n}\n\nstring JavaPackageToDir(string package_name) {\n  string package_dir =\n    StringReplace(package_name, \".\", \"/\", true);\n  if (!package_dir.empty()) package_dir += \"/\";\n  return package_dir;\n}\n\n// TODO(xiaofeng): This function is only kept for it's publicly referenced.\n// It should be removed after mutable API up-integration.\nstring ToJavaName(const string& full_name,\n                  const FileDescriptor* file) {\n  string result;\n  if (file->options().java_multiple_files()) {\n    result = FileJavaPackage(file);\n  } else {\n    result = ClassName(file);\n  }\n  if (!result.empty()) {\n    result += '.';\n  }\n  if (file->package().empty()) {\n    result += full_name;\n  } else {\n    // Strip the proto package from full_name since we've replaced it with\n    // the Java package.\n    result += full_name.substr(file->package().size() + 1);\n  }\n  return result;\n}\n\nstring ClassName(const Descriptor* descriptor) {\n  ClassNameResolver name_resolver;\n  return name_resolver.GetClassName(descriptor, true);\n}\n\nstring ClassName(const EnumDescriptor* descriptor) {\n  ClassNameResolver name_resolver;\n  return name_resolver.GetClassName(descriptor, true);\n}\n\nstring ClassName(const ServiceDescriptor* descriptor) {\n  ClassNameResolver name_resolver;\n  return name_resolver.GetClassName(descriptor, true);\n}\n\nstring ClassName(const FileDescriptor* descriptor) {\n  ClassNameResolver name_resolver;\n  return name_resolver.GetClassName(descriptor, true);\n}\n\nstring ExtraMessageInterfaces(const Descriptor* descriptor) {\n  string interfaces = \"// @@protoc_insertion_point(message_implements:\"\n      + descriptor->full_name() + \")\";\n  return interfaces;\n}\n\n\nstring ExtraBuilderInterfaces(const Descriptor* descriptor) {\n  string interfaces = \"// @@protoc_insertion_point(builder_implements:\"\n      + descriptor->full_name() + \")\";\n  return interfaces;\n}\n\nstring ExtraMessageOrBuilderInterfaces(const Descriptor* descriptor) {\n  string interfaces = \"// @@protoc_insertion_point(interface_extends:\"\n      + descriptor->full_name() + \")\";\n  return interfaces;\n}\n\nstring FieldConstantName(const FieldDescriptor *field) {\n  string name = field->name() + \"_FIELD_NUMBER\";\n  UpperString(&name);\n  return name;\n}\n\nFieldDescriptor::Type GetType(const FieldDescriptor* field) {\n  return field->type();\n}\n\nJavaType GetJavaType(const FieldDescriptor* field) {\n  switch (GetType(field)) {\n    case FieldDescriptor::TYPE_INT32:\n    case FieldDescriptor::TYPE_UINT32:\n    case FieldDescriptor::TYPE_SINT32:\n    case FieldDescriptor::TYPE_FIXED32:\n    case FieldDescriptor::TYPE_SFIXED32:\n      return JAVATYPE_INT;\n\n    case FieldDescriptor::TYPE_INT64:\n    case FieldDescriptor::TYPE_UINT64:\n    case FieldDescriptor::TYPE_SINT64:\n    case FieldDescriptor::TYPE_FIXED64:\n    case FieldDescriptor::TYPE_SFIXED64:\n      return JAVATYPE_LONG;\n\n    case FieldDescriptor::TYPE_FLOAT:\n      return JAVATYPE_FLOAT;\n\n    case FieldDescriptor::TYPE_DOUBLE:\n      return JAVATYPE_DOUBLE;\n\n    case FieldDescriptor::TYPE_BOOL:\n      return JAVATYPE_BOOLEAN;\n\n    case FieldDescriptor::TYPE_STRING:\n      return JAVATYPE_STRING;\n\n    case FieldDescriptor::TYPE_BYTES:\n      return JAVATYPE_BYTES;\n\n    case FieldDescriptor::TYPE_ENUM:\n      return JAVATYPE_ENUM;\n\n    case FieldDescriptor::TYPE_GROUP:\n    case FieldDescriptor::TYPE_MESSAGE:\n      return JAVATYPE_MESSAGE;\n\n    // No default because we want the compiler to complain if any new\n    // types are added.\n  }\n\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return JAVATYPE_INT;\n}\n\nconst char* PrimitiveTypeName(JavaType type) {\n  switch (type) {\n    case JAVATYPE_INT    : return \"int\";\n    case JAVATYPE_LONG   : return \"long\";\n    case JAVATYPE_FLOAT  : return \"float\";\n    case JAVATYPE_DOUBLE : return \"double\";\n    case JAVATYPE_BOOLEAN: return \"boolean\";\n    case JAVATYPE_STRING : return \"java.lang.String\";\n    case JAVATYPE_BYTES  : return \"com.google.protobuf.ByteString\";\n    case JAVATYPE_ENUM   : return NULL;\n    case JAVATYPE_MESSAGE: return NULL;\n\n    // No default because we want the compiler to complain if any new\n    // JavaTypes are added.\n  }\n\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return NULL;\n}\n\nconst char* BoxedPrimitiveTypeName(JavaType type) {\n  switch (type) {\n    case JAVATYPE_INT    : return \"java.lang.Integer\";\n    case JAVATYPE_LONG   : return \"java.lang.Long\";\n    case JAVATYPE_FLOAT  : return \"java.lang.Float\";\n    case JAVATYPE_DOUBLE : return \"java.lang.Double\";\n    case JAVATYPE_BOOLEAN: return \"java.lang.Boolean\";\n    case JAVATYPE_STRING : return \"java.lang.String\";\n    case JAVATYPE_BYTES  : return \"com.google.protobuf.ByteString\";\n    case JAVATYPE_ENUM   : return NULL;\n    case JAVATYPE_MESSAGE: return NULL;\n\n    // No default because we want the compiler to complain if any new\n    // JavaTypes are added.\n  }\n\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return NULL;\n}\n\nconst char* FieldTypeName(FieldDescriptor::Type field_type) {\n  switch (field_type) {\n    case FieldDescriptor::TYPE_INT32   : return \"INT32\";\n    case FieldDescriptor::TYPE_UINT32  : return \"UINT32\";\n    case FieldDescriptor::TYPE_SINT32  : return \"SINT32\";\n    case FieldDescriptor::TYPE_FIXED32 : return \"FIXED32\";\n    case FieldDescriptor::TYPE_SFIXED32: return \"SFIXED32\";\n    case FieldDescriptor::TYPE_INT64   : return \"INT64\";\n    case FieldDescriptor::TYPE_UINT64  : return \"UINT64\";\n    case FieldDescriptor::TYPE_SINT64  : return \"SINT64\";\n    case FieldDescriptor::TYPE_FIXED64 : return \"FIXED64\";\n    case FieldDescriptor::TYPE_SFIXED64: return \"SFIXED64\";\n    case FieldDescriptor::TYPE_FLOAT   : return \"FLOAT\";\n    case FieldDescriptor::TYPE_DOUBLE  : return \"DOUBLE\";\n    case FieldDescriptor::TYPE_BOOL    : return \"BOOL\";\n    case FieldDescriptor::TYPE_STRING  : return \"STRING\";\n    case FieldDescriptor::TYPE_BYTES   : return \"BYTES\";\n    case FieldDescriptor::TYPE_ENUM    : return \"ENUM\";\n    case FieldDescriptor::TYPE_GROUP   : return \"GROUP\";\n    case FieldDescriptor::TYPE_MESSAGE : return \"MESSAGE\";\n\n    // No default because we want the compiler to complain if any new\n    // types are added.\n  }\n\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return NULL;\n}\n\nbool AllAscii(const string& text) {\n  for (int i = 0; i < text.size(); i++) {\n    if ((text[i] & 0x80) != 0) {\n      return false;\n    }\n  }\n  return true;\n}\n\nstring DefaultValue(const FieldDescriptor* field, bool immutable,\n                    ClassNameResolver* name_resolver) {\n  // Switch on CppType since we need to know which default_value_* method\n  // of FieldDescriptor to call.\n  switch (field->cpp_type()) {\n    case FieldDescriptor::CPPTYPE_INT32:\n      return SimpleItoa(field->default_value_int32());\n    case FieldDescriptor::CPPTYPE_UINT32:\n      // Need to print as a signed int since Java has no unsigned.\n      return SimpleItoa(static_cast<int32>(field->default_value_uint32()));\n    case FieldDescriptor::CPPTYPE_INT64:\n      return SimpleItoa(field->default_value_int64()) + \"L\";\n    case FieldDescriptor::CPPTYPE_UINT64:\n      return SimpleItoa(static_cast<int64>(field->default_value_uint64())) +\n             \"L\";\n    case FieldDescriptor::CPPTYPE_DOUBLE: {\n      double value = field->default_value_double();\n      if (value == numeric_limits<double>::infinity()) {\n        return \"Double.POSITIVE_INFINITY\";\n      } else if (value == -numeric_limits<double>::infinity()) {\n        return \"Double.NEGATIVE_INFINITY\";\n      } else if (value != value) {\n        return \"Double.NaN\";\n      } else {\n        return SimpleDtoa(value) + \"D\";\n      }\n    }\n    case FieldDescriptor::CPPTYPE_FLOAT: {\n      float value = field->default_value_float();\n      if (value == numeric_limits<float>::infinity()) {\n        return \"Float.POSITIVE_INFINITY\";\n      } else if (value == -numeric_limits<float>::infinity()) {\n        return \"Float.NEGATIVE_INFINITY\";\n      } else if (value != value) {\n        return \"Float.NaN\";\n      } else {\n        return SimpleFtoa(value) + \"F\";\n      }\n    }\n    case FieldDescriptor::CPPTYPE_BOOL:\n      return field->default_value_bool() ? \"true\" : \"false\";\n    case FieldDescriptor::CPPTYPE_STRING:\n      if (GetType(field) == FieldDescriptor::TYPE_BYTES) {\n        if (field->has_default_value()) {\n          // See comments in Internal.java for gory details.\n          return strings::Substitute(\n            \"com.google.protobuf.Internal.bytesDefaultValue(\\\"$0\\\")\",\n            CEscape(field->default_value_string()));\n        } else {\n          return \"com.google.protobuf.ByteString.EMPTY\";\n        }\n      } else {\n        if (AllAscii(field->default_value_string())) {\n          // All chars are ASCII.  In this case CEscape() works fine.\n          return \"\\\"\" + CEscape(field->default_value_string()) + \"\\\"\";\n        } else {\n          // See comments in Internal.java for gory details.\n          return strings::Substitute(\n              \"com.google.protobuf.Internal.stringDefaultValue(\\\"$0\\\")\",\n              CEscape(field->default_value_string()));\n        }\n      }\n\n    case FieldDescriptor::CPPTYPE_ENUM:\n      return name_resolver->GetClassName(field->enum_type(), immutable) + \".\" +\n          field->default_value_enum()->name();\n\n    case FieldDescriptor::CPPTYPE_MESSAGE:\n      return name_resolver->GetClassName(field->message_type(), immutable) +\n          \".getDefaultInstance()\";\n\n    // No default because we want the compiler to complain if any new\n    // types are added.\n  }\n\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return \"\";\n}\n\nbool IsDefaultValueJavaDefault(const FieldDescriptor* field) {\n  // Switch on CppType since we need to know which default_value_* method\n  // of FieldDescriptor to call.\n  switch (field->cpp_type()) {\n    case FieldDescriptor::CPPTYPE_INT32:\n      return field->default_value_int32() == 0;\n    case FieldDescriptor::CPPTYPE_UINT32:\n      return field->default_value_uint32() == 0;\n    case FieldDescriptor::CPPTYPE_INT64:\n      return field->default_value_int64() == 0L;\n    case FieldDescriptor::CPPTYPE_UINT64:\n      return field->default_value_uint64() == 0L;\n    case FieldDescriptor::CPPTYPE_DOUBLE:\n      return field->default_value_double() == 0.0;\n    case FieldDescriptor::CPPTYPE_FLOAT:\n      return field->default_value_float() == 0.0;\n    case FieldDescriptor::CPPTYPE_BOOL:\n      return field->default_value_bool() == false;\n    case FieldDescriptor::CPPTYPE_ENUM:\n      return field->default_value_enum()->number() == 0;\n    case FieldDescriptor::CPPTYPE_STRING:\n    case FieldDescriptor::CPPTYPE_MESSAGE:\n      return false;\n\n    // No default because we want the compiler to complain if any new\n    // types are added.\n  }\n\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return false;\n}\n\nbool IsByteStringWithCustomDefaultValue(const FieldDescriptor* field) {\n  return GetJavaType(field) == JAVATYPE_BYTES &&\n         field->default_value_string() != \"\";\n}\n\nconst char* bit_masks[] = {\n  \"0x00000001\",\n  \"0x00000002\",\n  \"0x00000004\",\n  \"0x00000008\",\n  \"0x00000010\",\n  \"0x00000020\",\n  \"0x00000040\",\n  \"0x00000080\",\n\n  \"0x00000100\",\n  \"0x00000200\",\n  \"0x00000400\",\n  \"0x00000800\",\n  \"0x00001000\",\n  \"0x00002000\",\n  \"0x00004000\",\n  \"0x00008000\",\n\n  \"0x00010000\",\n  \"0x00020000\",\n  \"0x00040000\",\n  \"0x00080000\",\n  \"0x00100000\",\n  \"0x00200000\",\n  \"0x00400000\",\n  \"0x00800000\",\n\n  \"0x01000000\",\n  \"0x02000000\",\n  \"0x04000000\",\n  \"0x08000000\",\n  \"0x10000000\",\n  \"0x20000000\",\n  \"0x40000000\",\n  \"0x80000000\",\n};\n\nstring GetBitFieldName(int index) {\n  string varName = \"bitField\";\n  varName += SimpleItoa(index);\n  varName += \"_\";\n  return varName;\n}\n\nstring GetBitFieldNameForBit(int bitIndex) {\n  return GetBitFieldName(bitIndex / 32);\n}\n\nnamespace {\n\nstring GenerateGetBitInternal(const string& prefix, int bitIndex) {\n  string varName = prefix + GetBitFieldNameForBit(bitIndex);\n  int bitInVarIndex = bitIndex % 32;\n\n  string mask = bit_masks[bitInVarIndex];\n  string result = \"((\" + varName + \" & \" + mask + \") == \" + mask + \")\";\n  return result;\n}\n\nstring GenerateSetBitInternal(const string& prefix, int bitIndex) {\n  string varName = prefix + GetBitFieldNameForBit(bitIndex);\n  int bitInVarIndex = bitIndex % 32;\n\n  string mask = bit_masks[bitInVarIndex];\n  string result = varName + \" |= \" + mask;\n  return result;\n}\n\n}  // namespace\n\nstring GenerateGetBit(int bitIndex) {\n  return GenerateGetBitInternal(\"\", bitIndex);\n}\n\nstring GenerateSetBit(int bitIndex) {\n  return GenerateSetBitInternal(\"\", bitIndex);\n}\n\nstring GenerateClearBit(int bitIndex) {\n  string varName = GetBitFieldNameForBit(bitIndex);\n  int bitInVarIndex = bitIndex % 32;\n\n  string mask = bit_masks[bitInVarIndex];\n  string result = varName + \" = (\" + varName + \" & ~\" + mask + \")\";\n  return result;\n}\n\nstring GenerateGetBitFromLocal(int bitIndex) {\n  return GenerateGetBitInternal(\"from_\", bitIndex);\n}\n\nstring GenerateSetBitToLocal(int bitIndex) {\n  return GenerateSetBitInternal(\"to_\", bitIndex);\n}\n\nstring GenerateGetBitMutableLocal(int bitIndex) {\n  return GenerateGetBitInternal(\"mutable_\", bitIndex);\n}\n\nstring GenerateSetBitMutableLocal(int bitIndex) {\n  return GenerateSetBitInternal(\"mutable_\", bitIndex);\n}\n\nbool IsReferenceType(JavaType type) {\n  switch (type) {\n    case JAVATYPE_INT    : return false;\n    case JAVATYPE_LONG   : return false;\n    case JAVATYPE_FLOAT  : return false;\n    case JAVATYPE_DOUBLE : return false;\n    case JAVATYPE_BOOLEAN: return false;\n    case JAVATYPE_STRING : return true;\n    case JAVATYPE_BYTES  : return true;\n    case JAVATYPE_ENUM   : return true;\n    case JAVATYPE_MESSAGE: return true;\n\n    // No default because we want the compiler to complain if any new\n    // JavaTypes are added.\n  }\n\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return false;\n}\n\nconst char* GetCapitalizedType(const FieldDescriptor* field, bool immutable) {\n  switch (GetType(field)) {\n    case FieldDescriptor::TYPE_INT32   : return \"Int32\";\n    case FieldDescriptor::TYPE_UINT32  : return \"UInt32\";\n    case FieldDescriptor::TYPE_SINT32  : return \"SInt32\";\n    case FieldDescriptor::TYPE_FIXED32 : return \"Fixed32\";\n    case FieldDescriptor::TYPE_SFIXED32: return \"SFixed32\";\n    case FieldDescriptor::TYPE_INT64   : return \"Int64\";\n    case FieldDescriptor::TYPE_UINT64  : return \"UInt64\";\n    case FieldDescriptor::TYPE_SINT64  : return \"SInt64\";\n    case FieldDescriptor::TYPE_FIXED64 : return \"Fixed64\";\n    case FieldDescriptor::TYPE_SFIXED64: return \"SFixed64\";\n    case FieldDescriptor::TYPE_FLOAT   : return \"Float\";\n    case FieldDescriptor::TYPE_DOUBLE  : return \"Double\";\n    case FieldDescriptor::TYPE_BOOL    : return \"Bool\";\n    case FieldDescriptor::TYPE_STRING  : return \"String\";\n    case FieldDescriptor::TYPE_BYTES   : {\n      return \"Bytes\";\n    }\n    case FieldDescriptor::TYPE_ENUM    : return \"Enum\";\n    case FieldDescriptor::TYPE_GROUP   : return \"Group\";\n    case FieldDescriptor::TYPE_MESSAGE : return \"Message\";\n\n    // No default because we want the compiler to complain if any new\n    // types are added.\n  }\n\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return NULL;\n}\n\n// For encodings with fixed sizes, returns that size in bytes.  Otherwise\n// returns -1.\nint FixedSize(FieldDescriptor::Type type) {\n  switch (type) {\n    case FieldDescriptor::TYPE_INT32   : return -1;\n    case FieldDescriptor::TYPE_INT64   : return -1;\n    case FieldDescriptor::TYPE_UINT32  : return -1;\n    case FieldDescriptor::TYPE_UINT64  : return -1;\n    case FieldDescriptor::TYPE_SINT32  : return -1;\n    case FieldDescriptor::TYPE_SINT64  : return -1;\n    case FieldDescriptor::TYPE_FIXED32 : return WireFormatLite::kFixed32Size;\n    case FieldDescriptor::TYPE_FIXED64 : return WireFormatLite::kFixed64Size;\n    case FieldDescriptor::TYPE_SFIXED32: return WireFormatLite::kSFixed32Size;\n    case FieldDescriptor::TYPE_SFIXED64: return WireFormatLite::kSFixed64Size;\n    case FieldDescriptor::TYPE_FLOAT   : return WireFormatLite::kFloatSize;\n    case FieldDescriptor::TYPE_DOUBLE  : return WireFormatLite::kDoubleSize;\n\n    case FieldDescriptor::TYPE_BOOL    : return WireFormatLite::kBoolSize;\n    case FieldDescriptor::TYPE_ENUM    : return -1;\n\n    case FieldDescriptor::TYPE_STRING  : return -1;\n    case FieldDescriptor::TYPE_BYTES   : return -1;\n    case FieldDescriptor::TYPE_GROUP   : return -1;\n    case FieldDescriptor::TYPE_MESSAGE : return -1;\n\n    // No default because we want the compiler to complain if any new\n    // types are added.\n  }\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return -1;\n}\n\n// Sort the fields of the given Descriptor by number into a new[]'d array\n// and return it. The caller should delete the returned array.\nconst FieldDescriptor** SortFieldsByNumber(const Descriptor* descriptor) {\n  const FieldDescriptor** fields =\n    new const FieldDescriptor*[descriptor->field_count()];\n  for (int i = 0; i < descriptor->field_count(); i++) {\n    fields[i] = descriptor->field(i);\n  }\n  std::sort(fields, fields + descriptor->field_count(),\n            FieldOrderingByNumber());\n  return fields;\n}\n\n// Returns true if the message type has any required fields.  If it doesn't,\n// we can optimize out calls to its isInitialized() method.\n//\n// already_seen is used to avoid checking the same type multiple times\n// (and also to protect against recursion).\nbool HasRequiredFields(\n    const Descriptor* type,\n    hash_set<const Descriptor*>* already_seen) {\n  if (already_seen->count(type) > 0) {\n    // The type is already in cache.  This means that either:\n    // a. The type has no required fields.\n    // b. We are in the midst of checking if the type has required fields,\n    //    somewhere up the stack.  In this case, we know that if the type\n    //    has any required fields, they'll be found when we return to it,\n    //    and the whole call to HasRequiredFields() will return true.\n    //    Therefore, we don't have to check if this type has required fields\n    //    here.\n    return false;\n  }\n  already_seen->insert(type);\n\n  // If the type has extensions, an extension with message type could contain\n  // required fields, so we have to be conservative and assume such an\n  // extension exists.\n  if (type->extension_range_count() > 0) return true;\n\n  for (int i = 0; i < type->field_count(); i++) {\n    const FieldDescriptor* field = type->field(i);\n    if (field->is_required()) {\n      return true;\n    }\n    if (GetJavaType(field) == JAVATYPE_MESSAGE) {\n      if (HasRequiredFields(field->message_type(), already_seen)) {\n        return true;\n      }\n    }\n  }\n\n  return false;\n}\n\nbool HasRequiredFields(const Descriptor* type) {\n  hash_set<const Descriptor*> already_seen;\n  return HasRequiredFields(type, &already_seen);\n}\n\nbool HasRepeatedFields(const Descriptor* descriptor) {\n  for (int i = 0; i < descriptor->field_count(); ++i) {\n    const FieldDescriptor* field = descriptor->field(i);\n    if (field->is_repeated()) {\n      return true;\n    }\n  }\n  return false;\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_helpers.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_HELPERS_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_HELPERS_H__\n\n#include <string>\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/descriptor.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\n// Commonly-used separator comments.  Thick is a line of '=', thin is a line\n// of '-'.\nextern const char kThickSeparator[];\nextern const char kThinSeparator[];\n\n// If annotation_file is non-empty, prints a javax.annotation.Generated\n// annotation to the given Printer. annotation_file will be referenced in the\n// annotation's comments field. delimiter should be the Printer's delimiter\n// character. annotation_file will be included verbatim into a Java literal\n// string, so it should not contain quotes or invalid Java escape sequences;\n// however, these are unlikely to appear in practice, as the value of\n// annotation_file should be generated from the filename of the source file\n// being annotated (which in turn must be a Java identifier plus \".java\").\nvoid PrintGeneratedAnnotation(io::Printer* printer, char delimiter = '$',\n                              const string& annotation_file = \"\");\n\n// Converts a name to camel-case. If cap_first_letter is true, capitalize the\n// first letter.\nstring UnderscoresToCamelCase(const string& name, bool cap_first_letter);\n// Converts the field's name to camel-case, e.g. \"foo_bar_baz\" becomes\n// \"fooBarBaz\" or \"FooBarBaz\", respectively.\nstring UnderscoresToCamelCase(const FieldDescriptor* field);\nstring UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field);\n\n// Similar, but for method names.  (Typically, this merely has the effect\n// of lower-casing the first letter of the name.)\nstring UnderscoresToCamelCase(const MethodDescriptor* method);\n\n// Get an identifier that uniquely identifies this type within the file.\n// This is used to declare static variables related to this type at the\n// outermost file scope.\nstring UniqueFileScopeIdentifier(const Descriptor* descriptor);\n\n// Strips \".proto\" or \".protodevel\" from the end of a filename.\nstring StripProto(const string& filename);\n\n// Gets the unqualified class name for the file.  For each .proto file, there\n// will be one Java class containing all the immutable messages and another\n// Java class containing all the mutable messages.\n// TODO(xiaofeng): remove the default value after updating client code.\nstring FileClassName(const FileDescriptor* file, bool immutable = true);\n\n// Returns the file's Java package name.\nstring FileJavaPackage(const FileDescriptor* file, bool immutable = true);\n\n// Returns output directory for the given package name.\nstring JavaPackageToDir(string package_name);\n\n// Converts the given fully-qualified name in the proto namespace to its\n// fully-qualified name in the Java namespace, given that it is in the given\n// file.\n// TODO(xiaofeng): this method is deprecated and should be removed in the\n// future.\nstring ToJavaName(const string& full_name,\n                  const FileDescriptor* file);\n\n// TODO(xiaofeng): the following methods are kept for they are exposed\n// publicly in //google/protobuf/compiler/java/names.h. They return\n// immutable names only and should be removed after mutable API is\n// integrated into google3.\nstring ClassName(const Descriptor* descriptor);\nstring ClassName(const EnumDescriptor* descriptor);\nstring ClassName(const ServiceDescriptor* descriptor);\nstring ClassName(const FileDescriptor* descriptor);\n\n// Comma-separate list of option-specified interfaces implemented by the\n// Message, to follow the \"implements\" declaration of the Message definition.\nstring ExtraMessageInterfaces(const Descriptor* descriptor);\n// Comma-separate list of option-specified interfaces implemented by the\n// MutableMessage, to follow the \"implements\" declaration of the MutableMessage\n// definition.\nstring ExtraMutableMessageInterfaces(const Descriptor* descriptor);\n// Comma-separate list of option-specified interfaces implemented by the\n// Builder, to follow the \"implements\" declaration of the Builder definition.\nstring ExtraBuilderInterfaces(const Descriptor* descriptor);\n// Comma-separate list of option-specified interfaces extended by the\n// MessageOrBuilder, to follow the \"extends\" declaration of the\n// MessageOrBuilder definition.\nstring ExtraMessageOrBuilderInterfaces(const Descriptor* descriptor);\n\n// Get the unqualified Java class name for mutable messages. i.e. without\n// package or outer classnames.\ninline string ShortMutableJavaClassName(const Descriptor* descriptor) {\n  return descriptor->name();\n}\n\n\n// Whether we should generate multiple java files for messages.\ninline bool MultipleJavaFiles(\n    const FileDescriptor* descriptor, bool immutable) {\n  return descriptor->options().java_multiple_files();\n}\n\n// Returns true if `descriptor` will be written to its own .java file.\n// `immutable` should be set to true if we're generating for the immutable API.\ntemplate <typename Descriptor>\nbool IsOwnFile(const Descriptor* descriptor, bool immutable) {\n  return descriptor->containing_type() == NULL &&\n         MultipleJavaFiles(descriptor->file(), immutable);\n}\n\ntemplate <>\ninline bool IsOwnFile(const ServiceDescriptor* descriptor, bool immutable) {\n  return MultipleJavaFiles(descriptor->file(), immutable);\n}\n\n// If `descriptor` describes an object with its own .java file,\n// returns the name (relative to that .java file) of the file that stores\n// annotation data for that descriptor. `suffix` is usually empty, but may\n// (e.g.) be \"OrBuilder\" for some generated interfaces.\ntemplate <typename Descriptor>\nstring AnnotationFileName(const Descriptor* descriptor, const string& suffix) {\n  return descriptor->name() + suffix + \".java.pb.meta\";\n}\n\ntemplate <typename Descriptor>\nvoid MaybePrintGeneratedAnnotation(Context* context, io::Printer* printer,\n                                   Descriptor* descriptor, bool immutable,\n                                   const string& suffix = \"\") {\n  if (context->options().annotate_code && IsOwnFile(descriptor, immutable)) {\n    PrintGeneratedAnnotation(printer, '$',\n                             AnnotationFileName(descriptor, suffix));\n  }\n}\n\n// Get the unqualified name that should be used for a field's field\n// number constant.\nstring FieldConstantName(const FieldDescriptor *field);\n\n// Returns the type of the FieldDescriptor.\n// This does nothing interesting for the open source release, but is used for\n// hacks that improve compatibility with version 1 protocol buffers at Google.\nFieldDescriptor::Type GetType(const FieldDescriptor* field);\n\nenum JavaType {\n  JAVATYPE_INT,\n  JAVATYPE_LONG,\n  JAVATYPE_FLOAT,\n  JAVATYPE_DOUBLE,\n  JAVATYPE_BOOLEAN,\n  JAVATYPE_STRING,\n  JAVATYPE_BYTES,\n  JAVATYPE_ENUM,\n  JAVATYPE_MESSAGE\n};\n\nJavaType GetJavaType(const FieldDescriptor* field);\n\nconst char* PrimitiveTypeName(JavaType type);\n\n// Get the fully-qualified class name for a boxed primitive type, e.g.\n// \"java.lang.Integer\" for JAVATYPE_INT.  Returns NULL for enum and message\n// types.\nconst char* BoxedPrimitiveTypeName(JavaType type);\n\n// Get the name of the java enum constant representing this type. E.g.,\n// \"INT32\" for FieldDescriptor::TYPE_INT32. The enum constant's full\n// name is \"com.google.protobuf.WireFormat.FieldType.INT32\".\nconst char* FieldTypeName(const FieldDescriptor::Type field_type);\n\nclass ClassNameResolver;\nstring DefaultValue(const FieldDescriptor* field, bool immutable,\n                    ClassNameResolver* name_resolver);\ninline string ImmutableDefaultValue(const FieldDescriptor* field,\n                                    ClassNameResolver* name_resolver) {\n  return DefaultValue(field, true, name_resolver);\n}\nbool IsDefaultValueJavaDefault(const FieldDescriptor* field);\nbool IsByteStringWithCustomDefaultValue(const FieldDescriptor* field);\n\n// Does this message class have descriptor and reflection methods?\ninline bool HasDescriptorMethods(const Descriptor* descriptor,\n                                 bool enforce_lite) {\n  return !enforce_lite &&\n         descriptor->file()->options().optimize_for() !=\n             FileOptions::LITE_RUNTIME;\n}\ninline bool HasDescriptorMethods(const EnumDescriptor* descriptor,\n                                 bool enforce_lite) {\n  return !enforce_lite &&\n         descriptor->file()->options().optimize_for() !=\n             FileOptions::LITE_RUNTIME;\n}\ninline bool HasDescriptorMethods(const FileDescriptor* descriptor,\n                                 bool enforce_lite) {\n  return !enforce_lite &&\n         descriptor->options().optimize_for() != FileOptions::LITE_RUNTIME;\n}\n\n// Should we generate generic services for this file?\ninline bool HasGenericServices(const FileDescriptor *file, bool enforce_lite) {\n  return file->service_count() > 0 &&\n         HasDescriptorMethods(file, enforce_lite) &&\n         file->options().java_generic_services();\n}\n\ninline bool IsLazy(const FieldDescriptor* descriptor, bool enforce_lite) {\n  // Currently, the proto-lite version supports lazy field.\n  // TODO(niwasaki): Support lazy fields also for other proto runtimes.\n  if (HasDescriptorMethods(descriptor->file(), enforce_lite)) {\n    return false;\n  }\n  return descriptor->options().lazy();\n}\n\n// Methods for shared bitfields.\n\n// Gets the name of the shared bitfield for the given index.\nstring GetBitFieldName(int index);\n\n// Gets the name of the shared bitfield for the given bit index.\n// Effectively, GetBitFieldName(bitIndex / 32)\nstring GetBitFieldNameForBit(int bitIndex);\n\n// Generates the java code for the expression that returns the boolean value\n// of the bit of the shared bitfields for the given bit index.\n// Example: \"((bitField1_ & 0x04) == 0x04)\"\nstring GenerateGetBit(int bitIndex);\n\n// Generates the java code for the expression that sets the bit of the shared\n// bitfields for the given bit index.\n// Example: \"bitField1_ = (bitField1_ | 0x04)\"\nstring GenerateSetBit(int bitIndex);\n\n// Generates the java code for the expression that clears the bit of the shared\n// bitfields for the given bit index.\n// Example: \"bitField1_ = (bitField1_ & ~0x04)\"\nstring GenerateClearBit(int bitIndex);\n\n// Does the same as GenerateGetBit but operates on the bit field on a local\n// variable. This is used by the builder to copy the value in the builder to\n// the message.\n// Example: \"((from_bitField1_ & 0x04) == 0x04)\"\nstring GenerateGetBitFromLocal(int bitIndex);\n\n// Does the same as GenerateSetBit but operates on the bit field on a local\n// variable. This is used by the builder to copy the value in the builder to\n// the message.\n// Example: \"to_bitField1_ = (to_bitField1_ | 0x04)\"\nstring GenerateSetBitToLocal(int bitIndex);\n\n// Does the same as GenerateGetBit but operates on the bit field on a local\n// variable. This is used by the parsing constructor to record if a repeated\n// field is mutable.\n// Example: \"((mutable_bitField1_ & 0x04) == 0x04)\"\nstring GenerateGetBitMutableLocal(int bitIndex);\n\n// Does the same as GenerateSetBit but operates on the bit field on a local\n// variable. This is used by the parsing constructor to record if a repeated\n// field is mutable.\n// Example: \"mutable_bitField1_ = (mutable_bitField1_ | 0x04)\"\nstring GenerateSetBitMutableLocal(int bitIndex);\n\n// Returns whether the JavaType is a reference type.\nbool IsReferenceType(JavaType type);\n\n// Returns the capitalized name for calling relative functions in\n// CodedInputStream\nconst char* GetCapitalizedType(const FieldDescriptor* field, bool immutable);\n\n// For encodings with fixed sizes, returns that size in bytes.  Otherwise\n// returns -1.\nint FixedSize(FieldDescriptor::Type type);\n\n// Comparators used to sort fields in MessageGenerator\nstruct FieldOrderingByNumber {\n  inline bool operator()(const FieldDescriptor* a,\n                         const FieldDescriptor* b) const {\n    return a->number() < b->number();\n  }\n};\n\nstruct ExtensionRangeOrdering {\n  bool operator()(const Descriptor::ExtensionRange* a,\n                  const Descriptor::ExtensionRange* b) const {\n    return a->start < b->start;\n  }\n};\n\n// Sort the fields of the given Descriptor by number into a new[]'d array\n// and return it. The caller should delete the returned array.\nconst FieldDescriptor** SortFieldsByNumber(const Descriptor* descriptor);\n\n// Does this message class have any packed fields?\ninline bool HasPackedFields(const Descriptor* descriptor) {\n  for (int i = 0; i < descriptor->field_count(); i++) {\n    if (descriptor->field(i)->is_packed()) {\n      return true;\n    }\n  }\n  return false;\n}\n\n// Check a message type and its sub-message types recursively to see if any of\n// them has a required field. Return true if a required field is found.\nbool HasRequiredFields(const Descriptor* descriptor);\n\n// Whether a .proto file supports field presence test for non-message types.\ninline bool SupportFieldPresence(const FileDescriptor* descriptor) {\n  return descriptor->syntax() != FileDescriptor::SYNTAX_PROTO3;\n}\n\n// Whether generate classes expose public PARSER instances.\ninline bool ExposePublicParser(const FileDescriptor* descriptor) {\n  // TODO(liujisi): Mark the PARSER private in 3.1.x releases.\n  return descriptor->syntax() == FileDescriptor::SYNTAX_PROTO2;\n}\n\n// Whether unknown enum values are kept (i.e., not stored in UnknownFieldSet\n// but in the message and can be queried using additional getters that return\n// ints.\ninline bool SupportUnknownEnumValue(const FileDescriptor* descriptor) {\n  return descriptor->syntax() == FileDescriptor::SYNTAX_PROTO3;\n}\n\n// Check whether a mesasge has repeated fields.\nbool HasRepeatedFields(const Descriptor* descriptor);\n\ninline bool IsMapEntry(const Descriptor* descriptor) {\n  return descriptor->options().map_entry();\n}\n\ninline bool IsMapField(const FieldDescriptor* descriptor) {\n  return descriptor->is_map();\n}\n\ninline bool PreserveUnknownFields(const Descriptor* descriptor) {\n  return descriptor->file()->syntax() != FileDescriptor::SYNTAX_PROTO3;\n}\n\ninline bool IsAnyMessage(const Descriptor* descriptor) {\n  return descriptor->full_name() == \"google.protobuf.Any\";\n}\n\ninline bool CheckUtf8(const FieldDescriptor* descriptor) {\n  return descriptor->file()->syntax() == FileDescriptor::SYNTAX_PROTO3 ||\n      descriptor->file()->options().java_string_check_utf8();\n}\n\ninline string GeneratedCodeVersionSuffix() {\n  return \"V3\";\n}\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_HELPERS_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_lazy_message_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: niwasaki@google.com (Naoki Iwasaki)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_lazy_message_field.h>\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/io/printer.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nImmutableLazyMessageFieldGenerator::\nImmutableLazyMessageFieldGenerator(\n    const FieldDescriptor* descriptor,\n    int messageBitIndex,\n    int builderBitIndex,\n    Context* context)\n    : ImmutableMessageFieldGenerator(\n          descriptor, messageBitIndex, builderBitIndex, context) {\n}\n\nImmutableLazyMessageFieldGenerator::~ImmutableLazyMessageFieldGenerator() {}\n\nvoid ImmutableLazyMessageFieldGenerator::\nGenerateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"private com.google.protobuf.LazyFieldLite $name$_ =\\n\"\n    \"    new com.google.protobuf.LazyFieldLite();\\n\");\n\n  PrintExtraFieldInfo(variables_, printer);\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n    \"  return $get_has_field_bit_message$;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  return ($type$) $name$_.getValue($type$.getDefaultInstance());\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder() {\\n\"\n    \"  return $name$_;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableLazyMessageFieldGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  // When using nested-builders, the code initially works just like the\n  // non-nested builder case. It only creates a nested builder lazily on\n  // demand and then forever delegates to it after creation.\n\n  printer->Print(variables_,\n    \"private com.google.protobuf.LazyFieldLite $name$_ =\\n\"\n    \"    new com.google.protobuf.LazyFieldLite();\\n\");\n\n  printer->Print(variables_,\n    // If this builder is non-null, it is used and the other fields are\n    // ignored.\n    \"private com.google.protobuf.SingleFieldBuilder$ver$<\\n\"\n    \"    $type$, $type$.Builder, $type$OrBuilder> $name$Builder_;\"\n    \"\\n\");\n\n  // The comments above the methods below are based on a hypothetical\n  // field of type \"Field\" called \"Field\".\n\n  // boolean hasField()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n    \"  return $get_has_field_bit_builder$;\\n\"\n    \"}\\n\");\n\n    printer->Print(variables_,\n      \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n      \"  return ($type$) $name$_.getValue($type$.getDefaultInstance());\\n\"\n      \"}\\n\");\n\n  // Field.Builder setField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder set$capitalized_name$($type$ value)\",\n\n    \"if (value == null) {\\n\"\n    \"  throw new NullPointerException();\\n\"\n    \"}\\n\"\n    \"$name$_.setValue(value);\\n\"\n    \"$on_changed$\\n\",\n\n     NULL,  // Lazy fields are supported only for lite-runtime.\n\n    \"$set_has_field_bit_builder$;\\n\"\n    \"return this;\\n\");\n\n  // Field.Builder setField(Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    $type$.Builder builderForValue)\",\n\n    \"$name$_.setValue(builderForValue.build());\\n\"\n    \"$on_changed$\\n\",\n\n    NULL,\n\n    \"$set_has_field_bit_builder$;\\n\"\n    \"return this;\\n\");\n\n  // Field.Builder mergeField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder merge$capitalized_name$($type$ value)\",\n\n    \"if ($get_has_field_bit_builder$ &&\\n\"\n    \"    !$name$_.containsDefaultInstance()) {\\n\"\n    \"  $name$_.setValue(\\n\"\n    \"    $type$.newBuilder(\\n\"\n    \"        get$capitalized_name$()).mergeFrom(value).buildPartial());\\n\"\n    \"} else {\\n\"\n    \"  $name$_.setValue(value);\\n\"\n    \"}\\n\"\n    \"$on_changed$\\n\",\n\n    NULL,\n\n    \"$set_has_field_bit_builder$;\\n\"\n    \"return this;\\n\");\n\n  // Field.Builder clearField()\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder clear$capitalized_name$()\",\n\n    \"$name$_.clear();\\n\"\n    \"$on_changed$\\n\",\n\n    NULL,\n\n    \"$clear_has_field_bit_builder$;\\n\"\n    \"return this;\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$.Builder get$capitalized_name$Builder() {\\n\"\n    \"  $set_has_field_bit_builder$;\\n\"\n    \"  $on_changed$\\n\"\n    \"  return get$capitalized_name$FieldBuilder().getBuilder();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder() {\\n\"\n    \"  if ($name$Builder_ != null) {\\n\"\n    \"    return $name$Builder_.getMessageOrBuilder();\\n\"\n    \"  } else {\\n\"\n    \"    return $name$_;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private com.google.protobuf.SingleFieldBuilder$ver$<\\n\"\n    \"    $type$, $type$.Builder, $type$OrBuilder> \\n\"\n    \"    get$capitalized_name$FieldBuilder() {\\n\"\n    \"  if ($name$Builder_ == null) {\\n\"\n    \"    $name$Builder_ = new com.google.protobuf.SingleFieldBuilder$ver$<\\n\"\n    \"        $type$, $type$.Builder, $type$OrBuilder>(\\n\"\n    \"            $name$_,\\n\"\n    \"            getParentForChildren(),\\n\"\n    \"            isClean());\\n\"\n    \"    $name$_ = null;\\n\"\n    \"  }\\n\"\n    \"  return $name$Builder_;\\n\"\n    \"}\\n\");\n}\n\n\nvoid ImmutableLazyMessageFieldGenerator::\nGenerateInitializationCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_.clear();\\n\");\n}\n\nvoid ImmutableLazyMessageFieldGenerator::\nGenerateBuilderClearCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_.clear();\\n\");\n  printer->Print(variables_, \"$clear_has_field_bit_builder$;\\n\");\n}\n\nvoid ImmutableLazyMessageFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (other.has$capitalized_name$()) {\\n\"\n    \"  $name$_.merge(other.$name$_);\\n\"\n    \"  $set_has_field_bit_builder$;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableLazyMessageFieldGenerator::\nGenerateBuildingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n      \"if ($get_has_field_bit_from_local$) {\\n\"\n      \"  $set_has_field_bit_to_local$;\\n\"\n      \"}\\n\");\n\n  printer->Print(variables_,\n      \"result.$name$_.set(\\n\"\n      \"    $name$_);\\n\");\n}\n\nvoid ImmutableLazyMessageFieldGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$_.setByteString(input.readBytes(), extensionRegistry);\\n\");\n  printer->Print(variables_,\n    \"$set_has_field_bit_message$;\\n\");\n}\n\nvoid ImmutableLazyMessageFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  // Do not de-serialize lazy fields.\n  printer->Print(variables_,\n    \"if ($get_has_field_bit_message$) {\\n\"\n    \"  output.writeBytes($number$, $name$_.toByteString());\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableLazyMessageFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($get_has_field_bit_message$) {\\n\"\n    \"  size += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .computeLazyFieldSize($number$, $name$_);\\n\"\n    \"}\\n\");\n}\n\n// ===================================================================\n\nImmutableLazyMessageOneofFieldGenerator::\nImmutableLazyMessageOneofFieldGenerator(const FieldDescriptor* descriptor,\n                                        int messageBitIndex,\n                                        int builderBitIndex,\n                                        Context* context)\n    : ImmutableLazyMessageFieldGenerator(\n          descriptor, messageBitIndex, builderBitIndex, context) {\n  const OneofGeneratorInfo* info =\n      context->GetOneofGeneratorInfo(descriptor->containing_oneof());\n  SetCommonOneofVariables(descriptor, info, &variables_);\n  variables_[\"lazy_type\"] = \"com.google.protobuf.LazyFieldLite\";\n}\n\nImmutableLazyMessageOneofFieldGenerator::\n~ImmutableLazyMessageOneofFieldGenerator() {}\n\nvoid ImmutableLazyMessageOneofFieldGenerator::\nGenerateMembers(io::Printer* printer) const {\n  PrintExtraFieldInfo(variables_, printer);\n  WriteFieldDocComment(printer, descriptor_);\n\n  printer->Print(variables_,\n    \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n    \"  return $has_oneof_case_message$;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    return ($type$) (($lazy_type$) $oneof_name$_).getValue(\\n\"\n    \"        $type$.getDefaultInstance());\\n\"\n    \"  }\\n\"\n    \"  return $type$.getDefaultInstance();\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableLazyMessageOneofFieldGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  // boolean hasField()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n    \"  return $has_oneof_case_message$;\\n\"\n    \"}\\n\");\n\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    return ($type$) (($lazy_type$) $oneof_name$_).getValue(\\n\"\n    \"        $type$.getDefaultInstance());\\n\"\n    \"  }\\n\"\n    \"  return $type$.getDefaultInstance();\\n\"\n    \"}\\n\");\n\n  // Field.Builder setField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder set$capitalized_name$($type$ value)\",\n\n    \"if (value == null) {\\n\"\n    \"  throw new NullPointerException();\\n\"\n    \"}\\n\"\n    \"if (!($has_oneof_case_message$)) {\\n\"\n    \"  $oneof_name$_ = new $lazy_type$();\\n\"\n    \"  $set_oneof_case_message$;\\n\"\n    \"}\\n\"\n    \"(($lazy_type$) $oneof_name$_).setValue(value);\\n\"\n    \"$on_changed$\\n\",\n\n     NULL,  // Lazy fields are supported only for lite-runtime.\n\n    \"return this;\\n\");\n\n  // Field.Builder setField(Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    $type$.Builder builderForValue)\",\n\n    \"if (!($has_oneof_case_message$)) {\\n\"\n    \"  $oneof_name$_ = new $lazy_type$();\\n\"\n    \"  $set_oneof_case_message$;\\n\"\n    \"}\\n\"\n    \"(($lazy_type$) $oneof_name$_).setValue(builderForValue.build());\\n\"\n    \"$on_changed$\\n\",\n\n    NULL,\n\n    \"return this;\\n\");\n\n  // Field.Builder mergeField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder merge$capitalized_name$($type$ value)\",\n\n    \"if ($has_oneof_case_message$ &&\\n\"\n    \"    !(($lazy_type$) $oneof_name$_).containsDefaultInstance()) {\\n\"\n    \"  (($lazy_type$) $oneof_name$_).setValue(\\n\"\n    \"    $type$.newBuilder(\\n\"\n    \"        get$capitalized_name$()).mergeFrom(value).buildPartial());\\n\"\n    \"} else {\\n\"\n    \"  if (!($has_oneof_case_message$)) {\\n\"\n    \"    $oneof_name$_ = new $lazy_type$();\\n\"\n    \"    $set_oneof_case_message$;\\n\"\n    \"  }\\n\"\n    \"  (($lazy_type$) $oneof_name$_).setValue(value);\\n\"\n    \"}\\n\"\n    \"$on_changed$\\n\",\n\n    NULL,\n\n    \"return this;\\n\");\n\n  // Field.Builder clearField()\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder clear$capitalized_name$()\",\n\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  $clear_oneof_case_message$;\\n\"\n    \"  $oneof_name$_ = null;\\n\"\n    \"  $on_changed$\\n\"\n    \"}\\n\",\n\n    NULL,\n\n    \"return this;\\n\");\n}\n\nvoid ImmutableLazyMessageOneofFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (!($has_oneof_case_message$)) {\\n\"\n    \"  $oneof_name$_ = new $lazy_type$();\\n\"\n    \"}\\n\"\n    \"(($lazy_type$) $oneof_name$_).merge(\\n\"\n    \"    ($lazy_type$) other.$oneof_name$_);\\n\"\n    \"$set_oneof_case_message$;\\n\");\n}\n\nvoid ImmutableLazyMessageOneofFieldGenerator::\nGenerateBuildingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n                 \"if ($has_oneof_case_message$) {\\n\");\n  printer->Indent();\n\n  printer->Print(variables_,\n      \"result.$oneof_name$_ = new $lazy_type$();\\n\"\n      \"(($lazy_type$) result.$oneof_name$_).set(\\n\"\n      \"    (($lazy_type$) $oneof_name$_));\\n\");\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid ImmutableLazyMessageOneofFieldGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (!($has_oneof_case_message$)) {\\n\"\n    \"  $oneof_name$_ = new $lazy_type$();\\n\"\n    \"}\\n\"\n    \"(($lazy_type$) $oneof_name$_).setByteString(\\n\"\n    \"    input.readBytes(), extensionRegistry);\\n\"\n    \"$set_oneof_case_message$;\\n\");\n}\n\nvoid ImmutableLazyMessageOneofFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  // Do not de-serialize lazy fields.\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  output.writeBytes(\\n\"\n    \"      $number$, (($lazy_type$) $oneof_name$_).toByteString());\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableLazyMessageOneofFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  size += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .computeLazyFieldSize($number$, ($lazy_type$) $oneof_name$_);\\n\"\n    \"}\\n\");\n}\n\n// ===================================================================\n\nRepeatedImmutableLazyMessageFieldGenerator::\nRepeatedImmutableLazyMessageFieldGenerator(\n    const FieldDescriptor* descriptor,\n    int messageBitIndex,\n    int builderBitIndex,\n    Context* context)\n    : RepeatedImmutableMessageFieldGenerator(\n          descriptor, messageBitIndex, builderBitIndex, context) {\n}\n\n\nRepeatedImmutableLazyMessageFieldGenerator::\n~RepeatedImmutableLazyMessageFieldGenerator() {}\n\nvoid RepeatedImmutableLazyMessageFieldGenerator::\nGenerateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"private java.util.List<com.google.protobuf.LazyFieldLite> $name$_;\\n\");\n  PrintExtraFieldInfo(variables_, printer);\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.util.List<$type$>\\n\"\n    \"    get$capitalized_name$List() {\\n\"\n    \"  java.util.List<$type$> list =\\n\"\n    \"      new java.util.ArrayList<$type$>($name$_.size());\\n\"\n    \"  for (com.google.protobuf.LazyFieldLite lf : $name$_) {\\n\"\n    \"    list.add(($type$) lf.getValue($type$.getDefaultInstance()));\\n\"\n    \"  }\\n\"\n    \"  return list;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.util.List<? extends $type$OrBuilder>\\n\"\n    \"    get$capitalized_name$OrBuilderList() {\\n\"\n    \"  return get$capitalized_name$List();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public int get$capitalized_name$Count() {\\n\"\n    \"  return $name$_.size();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$(int index) {\\n\"\n    \"  return ($type$)\\n\"\n    \"      $name$_.get(index).getValue($type$.getDefaultInstance());\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder(\\n\"\n    \"    int index) {\\n\"\n    \"  return ($type$OrBuilder)\\n\"\n    \"      $name$_.get(index).getValue($type$.getDefaultInstance());\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableLazyMessageFieldGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  // When using nested-builders, the code initially works just like the\n  // non-nested builder case. It only creates a nested builder lazily on\n  // demand and then forever delegates to it after creation.\n\n  printer->Print(variables_,\n    \"private java.util.List<com.google.protobuf.LazyFieldLite> $name$_ =\\n\"\n    \"  java.util.Collections.emptyList();\\n\"\n\n    \"private void ensure$capitalized_name$IsMutable() {\\n\"\n    \"  if (!$get_mutable_bit_builder$) {\\n\"\n    \"    $name$_ =\\n\"\n    \"        new java.util.ArrayList<com.google.protobuf.LazyFieldLite>(\\n\"\n    \"            $name$_);\\n\"\n    \"    $set_mutable_bit_builder$;\\n\"\n    \"   }\\n\"\n    \"}\\n\"\n    \"\\n\");\n\n  printer->Print(variables_,\n    // If this builder is non-null, it is used and the other fields are\n    // ignored.\n    \"private com.google.protobuf.RepeatedFieldBuilder$ver$<\\n\"\n    \"    $type$, $type$.Builder, $type$OrBuilder> $name$Builder_;\\n\"\n    \"\\n\");\n\n  // The comments above the methods below are based on a hypothetical\n  // repeated field of type \"Field\" called \"RepeatedField\".\n\n  // List<Field> getRepeatedFieldList()\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public java.util.List<$type$> get$capitalized_name$List()\",\n\n    \"java.util.List<$type$> list =\\n\"\n    \"    new java.util.ArrayList<$type$>($name$_.size());\\n\"\n    \"for (com.google.protobuf.LazyFieldLite lf : $name$_) {\\n\"\n    \"  list.add(($type$) lf.getValue($type$.getDefaultInstance()));\\n\"\n    \"}\\n\"\n    \"return java.util.Collections.unmodifiableList(list);\\n\",\n\n    \"return $name$Builder_.getMessageList();\\n\",\n\n    NULL);\n\n  // int getRepeatedFieldCount()\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public int get$capitalized_name$Count()\",\n\n    \"return $name$_.size();\\n\",\n    \"return $name$Builder_.getCount();\\n\",\n\n    NULL);\n\n  // Field getRepeatedField(int index)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public $type$ get$capitalized_name$(int index)\",\n\n    \"return ($type$) $name$_.get(index).getValue(\\n\"\n    \"    $type$.getDefaultInstance());\\n\",\n\n    \"return $name$Builder_.getMessage(index);\\n\",\n\n    NULL);\n\n  // Builder setRepeatedField(int index, Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    int index, $type$ value)\",\n    \"if (value == null) {\\n\"\n    \"  throw new NullPointerException();\\n\"\n    \"}\\n\"\n    \"ensure$capitalized_name$IsMutable();\\n\"\n    \"$name$_.set(index, com.google.protobuf.LazyFieldLite.fromValue(value));\\n\"\n    \"$on_changed$\\n\",\n    \"$name$Builder_.setMessage(index, value);\\n\",\n    \"return this;\\n\");\n\n  // Builder setRepeatedField(int index, Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    int index, $type$.Builder builderForValue)\",\n\n    \"ensure$capitalized_name$IsMutable();\\n\"\n    \"$name$_.set(index, com.google.protobuf.LazyFieldLite.fromValue(\\n\"\n    \"    builderForValue.build()));\\n\"\n    \"$on_changed$\\n\",\n\n    \"$name$Builder_.setMessage(index, builderForValue.build());\\n\",\n\n    \"return this;\\n\");\n\n  // Builder addRepeatedField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder add$capitalized_name$($type$ value)\",\n\n    \"if (value == null) {\\n\"\n    \"  throw new NullPointerException();\\n\"\n    \"}\\n\"\n    \"ensure$capitalized_name$IsMutable();\\n\"\n    \"$name$_.add(com.google.protobuf.LazyFieldLite.fromValue(value));\\n\"\n\n    \"$on_changed$\\n\",\n\n    \"$name$Builder_.addMessage(value);\\n\",\n\n    \"return this;\\n\");\n\n  // Builder addRepeatedField(int index, Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder add$capitalized_name$(\\n\"\n    \"    int index, $type$ value)\",\n\n    \"if (value == null) {\\n\"\n    \"  throw new NullPointerException();\\n\"\n    \"}\\n\"\n    \"ensure$capitalized_name$IsMutable();\\n\"\n    \"$name$_.add(index, com.google.protobuf.LazyFieldLite.fromValue(value));\\n\"\n    \"$on_changed$\\n\",\n\n    \"$name$Builder_.addMessage(index, value);\\n\",\n\n    \"return this;\\n\");\n\n  // Builder addRepeatedField(Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder add$capitalized_name$(\\n\"\n    \"    $type$.Builder builderForValue)\",\n\n    \"ensure$capitalized_name$IsMutable();\\n\"\n    \"$name$_.add(com.google.protobuf.LazyFieldLite.fromValue(\\n\"\n    \"    builderForValue.build()));\\n\"\n    \"$on_changed$\\n\",\n\n    \"$name$Builder_.addMessage(builderForValue.build());\\n\",\n\n    \"return this;\\n\");\n\n  // Builder addRepeatedField(int index, Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder add$capitalized_name$(\\n\"\n    \"    int index, $type$.Builder builderForValue)\",\n\n    \"ensure$capitalized_name$IsMutable();\\n\"\n    \"$name$_.add(index, com.google.protobuf.LazyFieldLite.fromValue(\\n\"\n    \"    builderForValue.build()));\\n\"\n    \"$on_changed$\\n\",\n\n    \"$name$Builder_.addMessage(index, builderForValue.build());\\n\",\n\n    \"return this;\\n\");\n\n  // Builder addAllRepeatedField(Iterable<Field> values)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder addAll$capitalized_name$(\\n\"\n    \"    java.lang.Iterable<? extends $type$> values)\",\n\n    \"ensure$capitalized_name$IsMutable();\\n\"\n    \"for (com.google.protobuf.MessageLite v : values) {\\n\"\n    \"  $name$_.add(com.google.protobuf.LazyFieldLite.fromValue(v));\\n\"\n    \"}\\n\"\n    \"$on_changed$\\n\",\n\n    \"$name$Builder_.addAllMessages(values);\\n\",\n\n    \"return this;\\n\");\n\n  // Builder clearAllRepeatedField()\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder clear$capitalized_name$()\",\n\n    \"$name$_ = java.util.Collections.emptyList();\\n\"\n    \"$clear_mutable_bit_builder$;\\n\"\n    \"$on_changed$\\n\",\n\n    \"$name$Builder_.clear();\\n\",\n\n    \"return this;\\n\");\n\n  // Builder removeRepeatedField(int index)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder remove$capitalized_name$(int index)\",\n\n    \"ensure$capitalized_name$IsMutable();\\n\"\n    \"$name$_.remove(index);\\n\"\n    \"$on_changed$\\n\",\n\n    \"$name$Builder_.remove(index);\\n\",\n\n    \"return this;\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$.Builder get$capitalized_name$Builder(\\n\"\n    \"    int index) {\\n\"\n    \"  return get$capitalized_name$FieldBuilder().getBuilder(index);\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n      printer->Print(variables_,\n    \"$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder(\\n\"\n    \"    int index) {\\n\"\n    \"  if ($name$Builder_ == null) {\\n\"\n    \"    return $name$_.get(index);\"\n    \"  } else {\\n\"\n    \"    return $name$Builder_.getMessageOrBuilder(index);\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n      printer->Print(variables_,\n    \"$deprecation$public java.util.List<? extends $type$OrBuilder> \\n\"\n    \"     get$capitalized_name$OrBuilderList() {\\n\"\n    \"  if ($name$Builder_ != null) {\\n\"\n    \"    return $name$Builder_.getMessageOrBuilderList();\\n\"\n    \"  } else {\\n\"\n    \"    return java.util.Collections.unmodifiableList($name$_);\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n      printer->Print(variables_,\n    \"$deprecation$public $type$.Builder add$capitalized_name$Builder() {\\n\"\n    \"  return get$capitalized_name$FieldBuilder().addBuilder(\\n\"\n    \"      $type$.getDefaultInstance());\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n      printer->Print(variables_,\n    \"$deprecation$public $type$.Builder add$capitalized_name$Builder(\\n\"\n    \"    int index) {\\n\"\n    \"  return get$capitalized_name$FieldBuilder().addBuilder(\\n\"\n    \"      index, $type$.getDefaultInstance());\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n      printer->Print(variables_,\n    \"$deprecation$public java.util.List<$type$.Builder> \\n\"\n    \"     get$capitalized_name$BuilderList() {\\n\"\n    \"  return get$capitalized_name$FieldBuilder().getBuilderList();\\n\"\n    \"}\\n\"\n    \"private com.google.protobuf.RepeatedFieldBuilder$ver$<\\n\"\n    \"    $type$, $type$.Builder, $type$OrBuilder> \\n\"\n    \"    get$capitalized_name$FieldBuilder() {\\n\"\n    \"  if ($name$Builder_ == null) {\\n\"\n    \"    $name$Builder_ = new com.google.protobuf.RepeatedFieldBuilder$ver$<\\n\"\n    \"        $type$, $type$.Builder, $type$OrBuilder>(\\n\"\n    \"            $name$_,\\n\"\n    \"            $get_mutable_bit_builder$,\\n\"\n    \"            getParentForChildren(),\\n\"\n    \"            isClean());\\n\"\n    \"    $name$_ = null;\\n\"\n    \"  }\\n\"\n    \"  return $name$Builder_;\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableLazyMessageFieldGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (!$get_mutable_bit_parser$) {\\n\"\n    \"  $name$_ =\\n\"\n    \"      new java.util.ArrayList<com.google.protobuf.LazyFieldLite>();\\n\"\n    \"  $set_mutable_bit_parser$;\\n\"\n    \"}\\n\"\n    \"$name$_.add(new com.google.protobuf.LazyFieldLite(\\n\"\n    \"    extensionRegistry, input.readBytes()));\\n\");\n}\n\nvoid RepeatedImmutableLazyMessageFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n    \"  output.writeBytes($number$, $name$_.get(i).toByteString());\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableLazyMessageFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n    \"  size += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .computeLazyFieldSize($number$, $name$_.get(i));\\n\"\n    \"}\\n\");\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_lazy_message_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: niwasaki@google.com (Naoki Iwasaki)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_LAZY_MESSAGE_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_LAZY_MESSAGE_FIELD_H__\n\n#include <google/protobuf/compiler/java/java_field.h>\n#include <google/protobuf/compiler/java/java_message_field.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace compiler {\n    namespace java {\n      class Context;  // context.h\n    }\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nclass ImmutableLazyMessageFieldGenerator\n    : public ImmutableMessageFieldGenerator {\n public:\n  explicit ImmutableLazyMessageFieldGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~ImmutableLazyMessageFieldGenerator();\n\n  // overroads ImmutableMessageFieldGenerator ---------------------------------\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateInitializationCode(io::Printer* printer) const;\n  void GenerateBuilderClearCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateBuildingCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableLazyMessageFieldGenerator);\n};\n\nclass ImmutableLazyMessageOneofFieldGenerator\n    : public ImmutableLazyMessageFieldGenerator {\n public:\n  ImmutableLazyMessageOneofFieldGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~ImmutableLazyMessageOneofFieldGenerator();\n\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateBuildingCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableLazyMessageOneofFieldGenerator);\n};\n\nclass RepeatedImmutableLazyMessageFieldGenerator\n    : public RepeatedImmutableMessageFieldGenerator {\n public:\n  explicit RepeatedImmutableLazyMessageFieldGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~RepeatedImmutableLazyMessageFieldGenerator();\n\n  // overroads RepeatedImmutableMessageFieldGenerator -------------------------\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableLazyMessageFieldGenerator);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_LAZY_MESSAGE_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: niwasaki@google.com (Naoki Iwasaki)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_lazy_message_field_lite.h>\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/io/printer.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nImmutableLazyMessageFieldLiteGenerator::\nImmutableLazyMessageFieldLiteGenerator(\n    const FieldDescriptor* descriptor,\n    int messageBitIndex,\n    int builderBitIndex,\n    Context* context)\n    : ImmutableMessageFieldLiteGenerator(\n          descriptor, messageBitIndex, builderBitIndex, context) {\n}\n\nImmutableLazyMessageFieldLiteGenerator::\n~ImmutableLazyMessageFieldLiteGenerator() {}\n\nvoid ImmutableLazyMessageFieldLiteGenerator::\nGenerateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"private com.google.protobuf.LazyFieldLite $name$_;\");\n\n  PrintExtraFieldInfo(variables_, printer);\n  WriteFieldDocComment(printer, descriptor_);\n  if (SupportFieldPresence(descriptor_->file())) {\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $get_has_field_bit_message$;\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $name$_ != null;\\n\"\n      \"}\\n\");\n  }\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  if ($name$_ == null) {\\n\"\n    \"    return $type$.getDefaultInstance();\\n\"\n    \"  }\\n\"\n    \"  return ($type$) $name$_.getValue($type$.getDefaultInstance());\\n\"\n   \"}\\n\");\n\n  // Field.Builder setField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$($type$ value) {\\n\"\n    \"  if (value == null) {\\n\"\n    \"    throw new NullPointerException();\\n\"\n    \"  }\\n\"\n    \"  if ($name$_ == null) {\\n\"\n    \"    $name$_ = new com.google.protobuf.LazyFieldLite();\\n\"\n    \"  }\\n\"\n    \"  $name$_.setValue(value);\\n\"\n    \"  $set_has_field_bit_message$\\n\"\n    \"}\\n\");\n\n  // Field.Builder setField(Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$(\\n\"\n    \"    $type$.Builder builderForValue) {\\n\"\n    \"  if ($name$_ == null) {\\n\"\n    \"    $name$_ = new com.google.protobuf.LazyFieldLite();\\n\"\n    \"  }\\n\"\n    \"  $name$_.setValue(builderForValue.build());\\n\"\n    \"  $set_has_field_bit_message$\\n\"\n    \"}\\n\");\n\n  // Field.Builder mergeField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void merge$capitalized_name$($type$ value) {\\n\"\n    \"  if (has$capitalized_name$() &&\\n\"\n    \"      !$name$_.containsDefaultInstance()) {\\n\"\n    \"    $name$_.setValue(\\n\"\n    \"      $type$.newBuilder(\\n\"\n    \"          get$capitalized_name$()).mergeFrom(value).buildPartial());\\n\"\n    \"  } else {\\n\"\n    \"    if ($name$_ == null) {\\n\"\n    \"      $name$_ = new com.google.protobuf.LazyFieldLite();\\n\"\n    \"    }\\n\"\n    \"    $name$_.setValue(value);\\n\"\n    \"    $set_has_field_bit_message$\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n\n  // Field.Builder clearField()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void clear$capitalized_name$() {\\n\"\n    \"  $name$_ = null;\\n\"\n    \"  $clear_has_field_bit_message$;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableLazyMessageFieldLiteGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  // The comments above the methods below are based on a hypothetical\n  // field of type \"Field\" called \"Field\".\n\n  // boolean hasField()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n    \"  return instance.has$capitalized_name$();\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  return instance.get$capitalized_name$();\\n\"\n    \"}\\n\");\n\n  // Field.Builder setField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$($type$ value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$(value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Field.Builder setField(Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    $type$.Builder builderForValue) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$(builderForValue);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Field.Builder mergeField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder merge$capitalized_name$($type$ value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.merge$capitalized_name$(value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Field.Builder clearField()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.clear$capitalized_name$();\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\n\nvoid ImmutableLazyMessageFieldLiteGenerator::\nGenerateInitializationCode(io::Printer* printer) const {}\n\nvoid ImmutableLazyMessageFieldLiteGenerator::\nGenerateVisitCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$_ = visitor.visitLazyMessage($name$_, other.$name$_);\\n\");\n}\n\nvoid ImmutableLazyMessageFieldLiteGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($name$_ == null) {\\n\"\n    \"  $name$_ = new com.google.protobuf.LazyFieldLite();\\n\"\n    \"}\\n\"\n    \"$name$_.mergeFrom(input, extensionRegistry);\\n\");\n  printer->Print(variables_,\n    \"$set_has_field_bit_message$\\n\");\n}\n\nvoid ImmutableLazyMessageFieldLiteGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  // Do not de-serialize lazy fields.\n  printer->Print(variables_,\n    \"if (has$capitalized_name$()) {\\n\"\n    \"  output.writeBytes($number$, $name$_.toByteString());\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableLazyMessageFieldLiteGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (has$capitalized_name$()) {\\n\"\n    \"  size += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .computeLazyFieldSize($number$, $name$_);\\n\"\n    \"}\\n\");\n}\n\n// ===================================================================\n\nImmutableLazyMessageOneofFieldLiteGenerator::\nImmutableLazyMessageOneofFieldLiteGenerator(const FieldDescriptor* descriptor,\n                                            int messageBitIndex,\n                                            int builderBitIndex,\n                                            Context* context)\n    : ImmutableLazyMessageFieldLiteGenerator(\n          descriptor, messageBitIndex, builderBitIndex, context) {\n  const OneofGeneratorInfo* info =\n      context->GetOneofGeneratorInfo(descriptor->containing_oneof());\n  SetCommonOneofVariables(descriptor, info, &variables_);\n  variables_[\"lazy_type\"] = \"com.google.protobuf.LazyFieldLite\";\n}\n\nImmutableLazyMessageOneofFieldLiteGenerator::\n~ImmutableLazyMessageOneofFieldLiteGenerator() {}\n\nvoid ImmutableLazyMessageOneofFieldLiteGenerator::\nGenerateMembers(io::Printer* printer) const {\n  PrintExtraFieldInfo(variables_, printer);\n  WriteFieldDocComment(printer, descriptor_);\n\n  printer->Print(variables_,\n    \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n    \"  return $has_oneof_case_message$;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    return ($type$) (($lazy_type$) $oneof_name$_).getValue(\\n\"\n    \"        $type$.getDefaultInstance());\\n\"\n    \"  }\\n\"\n    \"  return $type$.getDefaultInstance();\\n\"\n    \"}\\n\");\n\n  // Field.Builder setField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$($type$ value) {\\n\"\n    \"  if (value == null) {\\n\"\n    \"    throw new NullPointerException();\\n\"\n    \"  }\\n\"\n    \"  if (!($has_oneof_case_message$)) {\\n\"\n    \"    $oneof_name$_ = new $lazy_type$();\\n\"\n    \"    $set_oneof_case_message$;\\n\"\n    \"  }\\n\"\n    \"  (($lazy_type$) $oneof_name$_).setValue(value);\\n\"\n    \"}\\n\");\n\n  // Field.Builder setField(Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$(\\n\"\n    \"    $type$.Builder builderForValue) {\\n\"\n    \"  if (!($has_oneof_case_message$)) {\\n\"\n    \"    $oneof_name$_ = new $lazy_type$();\\n\"\n    \"    $set_oneof_case_message$;\\n\"\n    \"  }\\n\"\n    \"  (($lazy_type$) $oneof_name$_).setValue(builderForValue.build());\\n\"\n    \"}\\n\");\n\n  // Field.Builder mergeField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void merge$capitalized_name$($type$ value) {\\n\"\n    \"  if ($has_oneof_case_message$ &&\\n\"\n    \"      !(($lazy_type$) $oneof_name$_).containsDefaultInstance()) {\\n\"\n    \"    (($lazy_type$) $oneof_name$_).setValue(\\n\"\n    \"       $type$.newBuilder(\\n\"\n    \"          get$capitalized_name$()).mergeFrom(value).buildPartial());\\n\"\n    \"  } else {\\n\"\n    \"    if (!($has_oneof_case_message$)) {\\n\"\n    \"      $oneof_name$_ = new $lazy_type$();\\n\"\n    \"      $set_oneof_case_message$;\\n\"\n    \"    }\\n\"\n    \"    (($lazy_type$) $oneof_name$_).setValue(value);\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n\n  // Field.Builder clearField()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void clear$capitalized_name$() {\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    $clear_oneof_case_message$;\\n\"\n    \"    $oneof_name$_ = null;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableLazyMessageOneofFieldLiteGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  // boolean hasField()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n    \"  return instance.has$capitalized_name$();\\n\"\n    \"}\\n\");\n\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  return instance.get$capitalized_name$();\\n\"\n    \"}\\n\");\n\n  // Field.Builder setField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$($type$ value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$(value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Field.Builder setField(Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    $type$.Builder builderForValue) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$(builderForValue);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Field.Builder mergeField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder merge$capitalized_name$($type$ value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.merge$capitalized_name$(value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Field.Builder clearField()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.clear$capitalized_name$();\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableLazyMessageOneofFieldLiteGenerator::\nGenerateVisitCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$oneof_name$_ = visitor.visitOneofLazyMessage(\\n\"\n    \"    $has_oneof_case_message$,\\n\"\n    \"    ($lazy_type$) $oneof_name$_,\\n\"\n    \"    ($lazy_type$) other.$oneof_name$_);\\n\");\n}\n\nvoid ImmutableLazyMessageOneofFieldLiteGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (!($has_oneof_case_message$)) {\\n\"\n    \"  $oneof_name$_ = new $lazy_type$();\\n\"\n    \"}\\n\"\n    \"(($lazy_type$) $oneof_name$_).mergeFrom(input, extensionRegistry);\\n\"\n    \"$set_oneof_case_message$;\\n\");\n}\n\nvoid ImmutableLazyMessageOneofFieldLiteGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  // Do not de-serialize lazy fields.\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  output.writeBytes(\\n\"\n    \"      $number$, (($lazy_type$) $oneof_name$_).toByteString());\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableLazyMessageOneofFieldLiteGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  size += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .computeLazyFieldSize($number$, ($lazy_type$) $oneof_name$_);\\n\"\n    \"}\\n\");\n}\n\n// ===================================================================\n\nRepeatedImmutableLazyMessageFieldLiteGenerator::\nRepeatedImmutableLazyMessageFieldLiteGenerator(\n    const FieldDescriptor* descriptor,\n    int messageBitIndex,\n    int builderBitIndex,\n    Context* context)\n    : RepeatedImmutableMessageFieldLiteGenerator(\n          descriptor, messageBitIndex, builderBitIndex, context) {\n}\n\n\nRepeatedImmutableLazyMessageFieldLiteGenerator::\n~RepeatedImmutableLazyMessageFieldLiteGenerator() {}\n\nvoid RepeatedImmutableLazyMessageFieldLiteGenerator::\nGenerateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"private com.google.protobuf.Internal.ProtobufList<\\n\"\n    \"    com.google.protobuf.LazyFieldLite> $name$_;\\n\");\n  PrintExtraFieldInfo(variables_, printer);\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.util.List<$type$>\\n\"\n    \"    get$capitalized_name$List() {\\n\"\n    \"  java.util.List<$type$> list =\\n\"\n    \"      new java.util.ArrayList<$type$>($name$_.size());\\n\"\n    \"  for (com.google.protobuf.LazyFieldLite lf : $name$_) {\\n\"\n    \"    list.add(($type$) lf.getValue($type$.getDefaultInstance()));\\n\"\n    \"  }\\n\"\n    // TODO(dweis): Make this list immutable?\n    \"  return list;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.util.List<? extends $type$OrBuilder>\\n\"\n    \"    get$capitalized_name$OrBuilderList() {\\n\"\n    \"  return get$capitalized_name$List();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public int get$capitalized_name$Count() {\\n\"\n    \"  return $name$_.size();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$(int index) {\\n\"\n    \"  return ($type$)\\n\"\n    \"      $name$_.get(index).getValue($type$.getDefaultInstance());\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder(\\n\"\n    \"    int index) {\\n\"\n    \"  return ($type$OrBuilder)\\n\"\n    \"      $name$_.get(index).getValue($type$.getDefaultInstance());\\n\"\n    \"}\\n\");\n\n  printer->Print(variables_,\n    \"private void ensure$capitalized_name$IsMutable() {\\n\"\n    \"  if (!$is_mutable$) {\\n\"\n    \"    $name$_ =\\n\"\n    \"        com.google.protobuf.GeneratedMessageLite.mutableCopy($name$_);\\n\"\n    \"   }\\n\"\n    \"}\\n\"\n    \"\\n\");\n\n  // Builder setRepeatedField(int index, Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$(\\n\"\n    \"    int index, $type$ value) {\\n\"\n    \"  if (value == null) {\\n\"\n    \"    throw new NullPointerException();\\n\"\n    \"  }\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.set(\\n\"\n    \"      index, com.google.protobuf.LazyFieldLite.fromValue(value));\\n\"\n    \"}\\n\");\n\n  // Builder setRepeatedField(int index, Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$(\\n\"\n    \"    int index, $type$.Builder builderForValue) {\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.set(index, com.google.protobuf.LazyFieldLite.fromValue(\\n\"\n    \"      builderForValue.build()));\\n\"\n    \"}\\n\");\n\n  // Builder addRepeatedField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void add$capitalized_name$($type$ value) {\\n\"\n    \"  if (value == null) {\\n\"\n    \"    throw new NullPointerException();\\n\"\n    \"  }\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.add(com.google.protobuf.LazyFieldLite.fromValue(value));\\n\"\n    \"}\\n\");\n\n  // Builder addRepeatedField(int index, Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void add$capitalized_name$(\\n\"\n    \"    int index, $type$ value) {\\n\"\n    \"  if (value == null) {\\n\"\n    \"    throw new NullPointerException();\\n\"\n    \"  }\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.add(\\n\"\n    \"      index, com.google.protobuf.LazyFieldLite.fromValue(value));\\n\"\n    \"}\\n\");\n\n  // Builder addRepeatedField(Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void add$capitalized_name$(\\n\"\n    \"    $type$.Builder builderForValue) {\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.add(com.google.protobuf.LazyFieldLite.fromValue(\\n\"\n    \"      builderForValue.build()));\\n\"\n    \"}\\n\");\n\n  // Builder addRepeatedField(int index, Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void add$capitalized_name$(\\n\"\n    \"    int index, $type$.Builder builderForValue) {\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.add(index, com.google.protobuf.LazyFieldLite.fromValue(\\n\"\n    \"      builderForValue.build()));\\n\"\n    \"}\\n\");\n\n  // Builder addAllRepeatedField(Iterable<Field> values)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void addAll$capitalized_name$(\\n\"\n    \"    java.lang.Iterable<? extends $type$> values) {\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  for (com.google.protobuf.MessageLite v : values) {\\n\"\n    \"    $name$_.add(com.google.protobuf.LazyFieldLite.fromValue(v));\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n\n  // Builder clearAllRepeatedField()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void clear$capitalized_name$() {\\n\"\n    \"  $name$_ = emptyProtobufList();\\n\"\n    \"}\\n\");\n\n  // Builder removeRepeatedField(int index)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void remove$capitalized_name$(int index) {\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.remove(index);\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableLazyMessageFieldLiteGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  // List<Field> getRepeatedFieldList()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.util.List<$type$> get$capitalized_name$List() {\\n\"\n    \"  return java.util.Collections.unmodifiableList(\\n\"\n    \"      instance.get$capitalized_name$List());\\n\"\n    \"}\\n\");\n\n  // int getRepeatedFieldCount()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public int get$capitalized_name$Count() {\\n\"\n    \"  return instance.get$capitalized_name$Count();\\n\"\n    \"}\\n\");\n\n  // Field getRepeatedField(int index)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$(int index) {\\n\"\n    \"  return instance.get$capitalized_name$(index);\\n\"\n    \"}\\n\");\n\n  // Builder setRepeatedField(int index, Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    int index, $type$ value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$(index, value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Builder setRepeatedField(int index, Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    int index, $type$.Builder builderForValue) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$(index, builderForValue);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Builder addRepeatedField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder add$capitalized_name$($type$ value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.add$capitalized_name$(value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Builder addRepeatedField(int index, Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder add$capitalized_name$(\\n\"\n    \"    int index, $type$ value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.add$capitalized_name$(index, value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Builder addRepeatedField(Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder add$capitalized_name$(\\n\"\n    \"    $type$.Builder builderForValue) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.add$capitalized_name$(builderForValue);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Builder addRepeatedField(int index, Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder add$capitalized_name$(\\n\"\n    \"    int index, $type$.Builder builderForValue) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.add$capitalized_name$(index, builderForValue);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Builder addAllRepeatedField(Iterable<Field> values)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder addAll$capitalized_name$(\\n\"\n    \"    java.lang.Iterable<? extends $type$> values) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.addAll$capitalized_name$(values);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Builder clearAllRepeatedField()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.clear$capitalized_name$();\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Builder removeRepeatedField(int index)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder remove$capitalized_name$(int index) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.remove$capitalized_name$(index);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableLazyMessageFieldLiteGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (!$is_mutable$) {\\n\"\n    \"  $name$_ =\\n\"\n    \"      com.google.protobuf.GeneratedMessageLite.mutableCopy($name$_);\\n\"\n    \"}\\n\"\n    \"$name$_.add(new com.google.protobuf.LazyFieldLite(\\n\"\n    \"    extensionRegistry, input.readBytes()));\\n\");\n}\n\nvoid RepeatedImmutableLazyMessageFieldLiteGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n    \"  output.writeBytes($number$, $name$_.get(i).toByteString());\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableLazyMessageFieldLiteGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n    \"  size += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .computeLazyFieldSize($number$, $name$_.get(i));\\n\"\n    \"}\\n\");\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_lazy_message_field_lite.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: niwasaki@google.com (Naoki Iwasaki)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_LAZY_MESSAGE_FIELD_LITE_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_LAZY_MESSAGE_FIELD_LITE_H__\n\n#include <google/protobuf/compiler/java/java_field.h>\n#include <google/protobuf/compiler/java/java_message_field_lite.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace compiler {\n    namespace java {\n      class Context;  // context.h\n    }\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nclass ImmutableLazyMessageFieldLiteGenerator\n    : public ImmutableMessageFieldLiteGenerator {\n public:\n  explicit ImmutableLazyMessageFieldLiteGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~ImmutableLazyMessageFieldLiteGenerator();\n\n  // overroads ImmutableMessageFieldLiteGenerator ------------------------------\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateInitializationCode(io::Printer* printer) const;\n  void GenerateVisitCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableLazyMessageFieldLiteGenerator);\n};\n\nclass ImmutableLazyMessageOneofFieldLiteGenerator\n    : public ImmutableLazyMessageFieldLiteGenerator {\n public:\n  ImmutableLazyMessageOneofFieldLiteGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~ImmutableLazyMessageOneofFieldLiteGenerator();\n\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateVisitCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableLazyMessageOneofFieldLiteGenerator);\n};\n\nclass RepeatedImmutableLazyMessageFieldLiteGenerator\n    : public RepeatedImmutableMessageFieldLiteGenerator {\n public:\n  explicit RepeatedImmutableLazyMessageFieldLiteGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~RepeatedImmutableLazyMessageFieldLiteGenerator();\n\n  // overroads RepeatedImmutableMessageFieldLiteGenerator ----------------------\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableLazyMessageFieldLiteGenerator);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_LAZY_MESSAGE_FIELD_LITE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_map_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/compiler/java/java_map_field.h>\n\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/io/printer.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nnamespace {\n\nconst FieldDescriptor* KeyField(const FieldDescriptor* descriptor) {\n  GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());\n  const Descriptor* message = descriptor->message_type();\n  GOOGLE_CHECK(message->options().map_entry());\n  return message->FindFieldByName(\"key\");\n}\n\nconst FieldDescriptor* ValueField(const FieldDescriptor* descriptor) {\n  GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());\n  const Descriptor* message = descriptor->message_type();\n  GOOGLE_CHECK(message->options().map_entry());\n  return message->FindFieldByName(\"value\");\n}\n\nstring TypeName(const FieldDescriptor* field,\n                ClassNameResolver* name_resolver,\n                bool boxed) {\n  if (GetJavaType(field) == JAVATYPE_MESSAGE) {\n    return name_resolver->GetImmutableClassName(field->message_type());\n  } else if (GetJavaType(field) == JAVATYPE_ENUM) {\n    return name_resolver->GetImmutableClassName(field->enum_type());\n  } else {\n    return boxed ? BoxedPrimitiveTypeName(GetJavaType(field))\n                 : PrimitiveTypeName(GetJavaType(field));\n  }\n}\n\nstring WireType(const FieldDescriptor* field) {\n  return \"com.google.protobuf.WireFormat.FieldType.\" +\n      string(FieldTypeName(field->type()));\n}\n\nvoid SetMessageVariables(const FieldDescriptor* descriptor,\n                         int messageBitIndex,\n                         int builderBitIndex,\n                         const FieldGeneratorInfo* info,\n                         Context* context,\n                         map<string, string>* variables) {\n  SetCommonFieldVariables(descriptor, info, variables);\n  ClassNameResolver* name_resolver = context->GetNameResolver();\n\n  (*variables)[\"type\"] =\n      name_resolver->GetImmutableClassName(descriptor->message_type());\n  const FieldDescriptor* key = KeyField(descriptor);\n  const FieldDescriptor* value = ValueField(descriptor);\n  const JavaType keyJavaType = GetJavaType(key);\n  const JavaType valueJavaType = GetJavaType(value);\n\n  (*variables)[\"key_type\"] = TypeName(key, name_resolver, false);\n  (*variables)[\"boxed_key_type\"] = TypeName(key, name_resolver, true);\n  (*variables)[\"key_wire_type\"] = WireType(key);\n  (*variables)[\"key_default_value\"] = DefaultValue(key, true, name_resolver);\n  (*variables)[\"key_null_check\"] = IsReferenceType(keyJavaType) ?\n      \"if (key == null) { throw new java.lang.NullPointerException(); }\" : \"\";\n  (*variables)[\"value_null_check\"] = IsReferenceType(valueJavaType) ?\n      \"if (value == null) { throw new java.lang.NullPointerException(); }\" : \"\";\n  if (valueJavaType == JAVATYPE_ENUM) {\n    // We store enums as Integers internally.\n    (*variables)[\"value_type\"] = \"int\";\n    (*variables)[\"boxed_value_type\"] = \"java.lang.Integer\";\n    (*variables)[\"value_wire_type\"] = WireType(value);\n    (*variables)[\"value_default_value\"] =\n        DefaultValue(value, true, name_resolver) + \".getNumber()\";\n\n    (*variables)[\"value_enum_type\"] = TypeName(value, name_resolver, false);\n\n    if (SupportUnknownEnumValue(descriptor->file())) {\n      // Map unknown values to a special UNRECOGNIZED value if supported.\n      (*variables)[\"unrecognized_value\"] =\n          (*variables)[\"value_enum_type\"] + \".UNRECOGNIZED\";\n    } else {\n      // Map unknown values to the default value if we don't have UNRECOGNIZED.\n      (*variables)[\"unrecognized_value\"] =\n          DefaultValue(value, true, name_resolver);\n    }\n  } else {\n    (*variables)[\"value_type\"] = TypeName(value, name_resolver, false);\n    (*variables)[\"boxed_value_type\"] = TypeName(value, name_resolver, true);\n    (*variables)[\"value_wire_type\"] = WireType(value);\n    (*variables)[\"value_default_value\"] =\n        DefaultValue(value, true, name_resolver);\n  }\n  (*variables)[\"type_parameters\"] =\n      (*variables)[\"boxed_key_type\"] + \", \" + (*variables)[\"boxed_value_type\"];\n  // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported\n  // by the proto compiler\n  (*variables)[\"deprecation\"] = descriptor->options().deprecated()\n      ? \"@java.lang.Deprecated \" : \"\";\n  (*variables)[\"on_changed\"] = \"onChanged();\";\n\n  // For repeated fields, one bit is used for whether the array is immutable\n  // in the parsing constructor.\n  (*variables)[\"get_mutable_bit_parser\"] =\n      GenerateGetBitMutableLocal(builderBitIndex);\n  (*variables)[\"set_mutable_bit_parser\"] =\n      GenerateSetBitMutableLocal(builderBitIndex);\n\n  (*variables)[\"default_entry\"] = (*variables)[\"capitalized_name\"] +\n      \"DefaultEntryHolder.defaultEntry\";\n  (*variables)[\"map_field_parameter\"] = (*variables)[\"default_entry\"];\n  (*variables)[\"descriptor\"] =\n      name_resolver->GetImmutableClassName(descriptor->file()) +\n      \".internal_\" + UniqueFileScopeIdentifier(descriptor->message_type()) +\n      \"_descriptor, \";\n}\n\n}  // namespace\n\nImmutableMapFieldGenerator::\nImmutableMapFieldGenerator(const FieldDescriptor* descriptor,\n                                       int messageBitIndex,\n                                       int builderBitIndex,\n                                       Context* context)\n  : descriptor_(descriptor), name_resolver_(context->GetNameResolver())  {\n  SetMessageVariables(descriptor, messageBitIndex, builderBitIndex,\n                      context->GetFieldGeneratorInfo(descriptor),\n                      context, &variables_);\n}\n\nImmutableMapFieldGenerator::\n~ImmutableMapFieldGenerator() {}\n\nint ImmutableMapFieldGenerator::GetNumBitsForMessage() const {\n  return 0;\n}\n\nint ImmutableMapFieldGenerator::GetNumBitsForBuilder() const {\n  return 1;\n}\n\nvoid ImmutableMapFieldGenerator::\nGenerateInterfaceMembers(io::Printer* printer) const {\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(\n      variables_,\n      \"$deprecation$int get$capitalized_name$Count();\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(\n      variables_,\n      \"$deprecation$boolean contains$capitalized_name$(\\n\"\n      \"    $key_type$ key);\\n\");\n  if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {\n    printer->Print(\n        variables_,\n        \"/**\\n\"\n        \" * Use {@link #get$capitalized_name$Map()} instead.\\n\"\n        \" */\\n\"\n        \"@java.lang.Deprecated\\n\"\n        \"java.util.Map<$boxed_key_type$, $value_enum_type$>\\n\"\n        \"get$capitalized_name$();\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$java.util.Map<$boxed_key_type$, $value_enum_type$>\\n\"\n        \"get$capitalized_name$Map();\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$$value_enum_type$ get$capitalized_name$OrDefault(\\n\"\n        \"    $key_type$ key,\\n\"\n        \"    $value_enum_type$ defaultValue);\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$$value_enum_type$ get$capitalized_name$OrThrow(\\n\"\n        \"    $key_type$ key);\\n\");\n    if (SupportUnknownEnumValue(descriptor_->file())) {\n      printer->Print(\n          variables_,\n          \"/**\\n\"\n          \" * Use {@link #get$capitalized_name$ValueMap()} instead.\\n\"\n          \" */\\n\"\n          \"@java.lang.Deprecated\\n\"\n          \"java.util.Map<$type_parameters$>\\n\"\n          \"get$capitalized_name$Value();\\n\");\n      WriteFieldDocComment(printer, descriptor_);\n      printer->Print(\n          variables_,\n          \"$deprecation$java.util.Map<$type_parameters$>\\n\"\n          \"get$capitalized_name$ValueMap();\\n\");\n      WriteFieldDocComment(printer, descriptor_);\n      printer->Print(\n          variables_,\n          \"$deprecation$\\n\"\n          \"$value_type$ get$capitalized_name$ValueOrDefault(\\n\"\n          \"    $key_type$ key,\\n\"\n          \"    $value_type$ defaultValue);\\n\");\n      WriteFieldDocComment(printer, descriptor_);\n      printer->Print(\n          variables_,\n          \"$deprecation$\\n\"\n          \"$value_type$ get$capitalized_name$ValueOrThrow(\\n\"\n          \"    $key_type$ key);\\n\");\n    }\n  } else {\n    printer->Print(\n        variables_,\n        \"/**\\n\"\n        \" * Use {@link #get$capitalized_name$Map()} instead.\\n\"\n        \" */\\n\"\n        \"@java.lang.Deprecated\\n\"\n        \"java.util.Map<$type_parameters$>\\n\"\n        \"get$capitalized_name$();\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$java.util.Map<$type_parameters$>\\n\"\n        \"get$capitalized_name$Map();\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\\n\"\n        \"$value_type$ get$capitalized_name$OrDefault(\\n\"\n        \"    $key_type$ key,\\n\"\n        \"    $value_type$ defaultValue);\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\\n\"\n        \"$value_type$ get$capitalized_name$OrThrow(\\n\"\n        \"    $key_type$ key);\\n\");\n  }\n}\n\nvoid ImmutableMapFieldGenerator::\nGenerateMembers(io::Printer* printer) const {\n  printer->Print(\n      variables_,\n      \"private static final class $capitalized_name$DefaultEntryHolder {\\n\"\n      \"  static final com.google.protobuf.MapEntry<\\n\"\n      \"      $type_parameters$> defaultEntry =\\n\"\n      \"          com.google.protobuf.MapEntry\\n\"\n      \"          .<$type_parameters$>newDefaultInstance(\\n\"\n      \"              $descriptor$\\n\"\n      \"              $key_wire_type$,\\n\"\n      \"              $key_default_value$,\\n\"\n      \"              $value_wire_type$,\\n\"\n      \"              $value_default_value$);\\n\"\n      \"}\\n\");\n  printer->Print(\n      variables_,\n      \"private com.google.protobuf.MapField<\\n\"\n      \"    $type_parameters$> $name$_;\\n\"\n      \"private com.google.protobuf.MapField<$type_parameters$>\\n\"\n      \"internalGet$capitalized_name$() {\\n\"\n      \"  if ($name$_ == null) {\\n\"\n      \"    return com.google.protobuf.MapField.emptyMapField(\\n\"\n      \"        $map_field_parameter$);\\n\"\n      \"  }\\n\"\n      \"  return $name$_;\\n\"\n      \"}\\n\");\n  if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {\n    printer->Print(\n        variables_,\n        \"private static final\\n\"\n        \"com.google.protobuf.Internal.MapAdapter.Converter<\\n\"\n        \"    java.lang.Integer, $value_enum_type$> $name$ValueConverter =\\n\"\n        \"        com.google.protobuf.Internal.MapAdapter.newEnumConverter(\\n\"\n        \"            $value_enum_type$.internalGetValueMap(),\\n\"\n        \"            $unrecognized_value$);\\n\");\n  }\n  GenerateMapGetters(printer);\n}\n\nvoid ImmutableMapFieldGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  printer->Print(\n      variables_,\n      \"private com.google.protobuf.MapField<\\n\"\n      \"    $type_parameters$> $name$_;\\n\"\n      \"private com.google.protobuf.MapField<$type_parameters$>\\n\"\n      \"internalGet$capitalized_name$() {\\n\"\n      \"  if ($name$_ == null) {\\n\"\n      \"    return com.google.protobuf.MapField.emptyMapField(\\n\"\n      \"        $map_field_parameter$);\\n\"\n      \"  }\\n\"\n      \"  return $name$_;\\n\"\n      \"}\\n\"\n      \"private com.google.protobuf.MapField<$type_parameters$>\\n\"\n      \"internalGetMutable$capitalized_name$() {\\n\"\n      \"  $on_changed$;\\n\"\n      \"  if ($name$_ == null) {\\n\"\n      \"    $name$_ = com.google.protobuf.MapField.newMapField(\\n\"\n      \"        $map_field_parameter$);\\n\"\n      \"  }\\n\"\n      \"  if (!$name$_.isMutable()) {\\n\"\n      \"    $name$_ = $name$_.copy();\\n\"\n      \"  }\\n\"\n      \"  return $name$_;\\n\"\n      \"}\\n\");\n  GenerateMapGetters(printer);\n  printer->Print(\n      variables_,\n      \"$deprecation$\\n\"\n      \"public Builder clear$capitalized_name$() {\\n\"\n      \"  getMutable$capitalized_name$().clear();\\n\"\n      \"  return this;\\n\"\n      \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(\n      variables_,\n      \"$deprecation$\\n\"\n      \"public Builder remove$capitalized_name$(\\n\"\n      \"    $key_type$ key) {\\n\"\n      \"  $key_null_check$\\n\"\n      \"  getMutable$capitalized_name$().remove(key);\\n\"\n      \"  return this;\\n\"\n      \"}\\n\");\n  if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {\n    printer->Print(\n        variables_,\n        \"/**\\n\"\n        \" * Use alternate mutation accessors instead.\\n\"\n        \" */\\n\"\n        \"@java.lang.Deprecated\\n\"\n        \"public java.util.Map<$boxed_key_type$, $value_enum_type$>\\n\"\n        \"getMutable$capitalized_name$() {\\n\"\n        \"  return new com.google.protobuf.Internal.MapAdapter<\\n\"\n        \"      $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\\n\"\n        \"          internalGetMutable$capitalized_name$().getMutableMap(),\\n\"\n        \"          $name$ValueConverter);\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$public Builder put$capitalized_name$(\\n\"\n        \"    $key_type$ key,\\n\"\n        \"    $value_enum_type$ value) {\\n\"\n        \"  $key_null_check$\\n\"\n        \"  $value_null_check$\\n\"\n        \"  getMutable$capitalized_name$().put(key, value);\\n\"\n        \"  return this;\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        // TODO(arielb): null check map keys/values here and everywhere else\n        // related to putAll\n        \"$deprecation$public Builder putAll$capitalized_name$(\\n\"\n        \"    java.util.Map<$boxed_key_type$, $value_enum_type$> values) {\\n\"\n        \"  getMutable$capitalized_name$().putAll(values);\\n\"\n        \"  return this;\\n\"\n        \"}\\n\");\n    if (SupportUnknownEnumValue(descriptor_->file())) {\n      printer->Print(\n          variables_,\n          \"/**\\n\"\n          \" * Use alternate mutation accessors instead.\\n\"\n          \" */\\n\"\n          \"@java.lang.Deprecated\\n\"\n          \"public java.util.Map<$boxed_key_type$, $boxed_value_type$>\\n\"\n          \"getMutable$capitalized_name$Value() {\\n\"\n          \"  return internalGetMutable$capitalized_name$().getMutableMap();\\n\"\n          \"}\\n\");\n      WriteFieldDocComment(printer, descriptor_);\n      printer->Print(\n          variables_,\n          \"$deprecation$public Builder put$capitalized_name$Value(\\n\"\n          \"    $key_type$ key,\\n\"\n          \"    $value_type$ value) {\\n\"\n          \"  $key_null_check$\\n\"\n          \"  if ($value_enum_type$.forNumber(value) == null) {\\n\"\n          \"    throw new java.lang.IllegalArgumentException();\\n\"\n          \"  }\\n\"\n          \"  getMutable$capitalized_name$Value().put(key, value);\\n\"\n          \"  return this;\\n\"\n          \"}\\n\");\n      WriteFieldDocComment(printer, descriptor_);\n      printer->Print(\n          variables_,\n          \"$deprecation$public Builder putAll$capitalized_name$Value(\\n\"\n          \"    java.util.Map<$boxed_key_type$, $boxed_value_type$> values) {\\n\"\n          \"  getMutable$capitalized_name$Value().putAll(values);\\n\"\n          \"  return this;\\n\"\n          \"}\\n\");\n    }\n  } else {\n    printer->Print(\n        variables_,\n        \"/**\\n\"\n        \" * Use alternate mutation accessors instead.\\n\"\n        \" */\\n\"\n        \"@java.lang.Deprecated\\n\"\n        \"public java.util.Map<$type_parameters$>\\n\"\n        \"getMutable$capitalized_name$() {\\n\"\n        \"  return internalGetMutable$capitalized_name$().getMutableMap();\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\"\n        \"public Builder put$capitalized_name$(\\n\"\n        \"    $key_type$ key,\\n\"\n        \"    $value_type$ value) {\\n\"\n        \"  $key_null_check$\\n\"\n        \"  $value_null_check$\\n\"\n        \"  getMutable$capitalized_name$().put(key, value);\\n\"\n        \"  return this;\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\\n\"\n        \"public Builder putAll$capitalized_name$(\\n\"\n        \"    java.util.Map<$type_parameters$> values) {\\n\"\n        \"  getMutable$capitalized_name$().putAll(values);\\n\"\n        \"  return this;\\n\"\n        \"}\\n\");\n  }\n}\n\nvoid ImmutableMapFieldGenerator::\nGenerateMapGetters(io::Printer* printer) const {\n  printer->Print(\n      variables_,\n      \"$deprecation$\\n\"\n      \"public int get$capitalized_name$Count() {\\n\"\n      \"  return internalGet$capitalized_name$().getMap().size();\\n\"\n      \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(\n      variables_,\n      \"$deprecation$\\n\"\n      \"public boolean contains$capitalized_name$(\\n\"\n      \"    $key_type$ key) {\\n\"\n      \"  $key_null_check$\\n\"\n      \"  return internalGet$capitalized_name$().getMap().containsKey(key);\\n\"\n      \"}\\n\");\n  if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {\n    printer->Print(\n        variables_,\n        \"/**\\n\"\n        \" * Use {@link #get$capitalized_name$Map()} instead.\\n\"\n        \" */\\n\"\n        \"@java.lang.Deprecated\\n\"\n        \"public java.util.Map<$boxed_key_type$, $value_enum_type$>\\n\"\n        \"get$capitalized_name$() {\\n\"\n        \"  return get$capitalized_name$Map();\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\\n\"\n        \"public java.util.Map<$boxed_key_type$, $value_enum_type$>\\n\"\n        \"get$capitalized_name$Map() {\\n\"\n        \"  return new com.google.protobuf.Internal.MapAdapter<\\n\"\n        \"      $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\\n\"\n        \"          internalGet$capitalized_name$().getMap(),\\n\"\n        \"          $name$ValueConverter);\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\\n\"\n        \"public $value_enum_type$ get$capitalized_name$OrDefault(\\n\"\n        \"    $key_type$ key,\\n\"\n        \"    $value_enum_type$ defaultValue) {\\n\"\n        \"  $key_null_check$\\n\"\n        \"  java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\\n\"\n        \"      internalGet$capitalized_name$().getMap();\\n\"\n        \"  return map.containsKey(key)\\n\"\n        \"         ? $name$ValueConverter.doForward(map.get(key))\\n\"\n        \"         : defaultValue;\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\\n\"\n        \"public $value_enum_type$ get$capitalized_name$OrThrow(\\n\"\n        \"    $key_type$ key) {\\n\"\n        \"  $key_null_check$\\n\"\n        \"  java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\\n\"\n        \"      internalGet$capitalized_name$().getMap();\\n\"\n        \"  if (!map.containsKey(key)) {\\n\"\n        \"    throw new java.lang.IllegalArgumentException();\\n\"\n        \"  }\\n\"\n        \"  return $name$ValueConverter.doForward(map.get(key));\\n\"\n        \"}\\n\");\n    if (SupportUnknownEnumValue(descriptor_->file())) {\n      printer->Print(\n          variables_,\n          \"/**\\n\"\n          \" * Use {@link #get$capitalized_name$ValueMap()} instead.\\n\"\n          \" */\\n\"\n          \"@java.lang.Deprecated\\n\"\n          \"public java.util.Map<$boxed_key_type$, $boxed_value_type$>\\n\"\n          \"get$capitalized_name$Value() {\\n\"\n          \"  return get$capitalized_name$ValueMap();\\n\"\n          \"}\\n\");\n      WriteFieldDocComment(printer, descriptor_);\n      printer->Print(\n          variables_,\n          \"$deprecation$\\n\"\n          \"public java.util.Map<$boxed_key_type$, $boxed_value_type$>\\n\"\n          \"get$capitalized_name$ValueMap() {\\n\"\n          \"  return internalGet$capitalized_name$().getMap();\\n\"\n          \"}\\n\");\n      WriteFieldDocComment(printer, descriptor_);\n      printer->Print(\n          variables_,\n          \"$deprecation$\\n\"\n          \"public $value_type$ get$capitalized_name$ValueOrDefault(\\n\"\n          \"    $key_type$ key,\\n\"\n          \"    $value_type$ defaultValue) {\\n\"\n          \"  $key_null_check$\\n\"\n          \"  java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\\n\"\n          \"      internalGet$capitalized_name$().getMap();\\n\"\n          \"  return map.containsKey(key) ? map.get(key) : defaultValue;\\n\"\n          \"}\\n\");\n      WriteFieldDocComment(printer, descriptor_);\n      printer->Print(\n          variables_,\n          \"$deprecation$\\n\"\n          \"public $value_type$ get$capitalized_name$ValueOrThrow(\\n\"\n          \"    $key_type$ key) {\\n\"\n          \"  $key_null_check$\\n\"\n          \"  java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\\n\"\n          \"      internalGet$capitalized_name$().getMap();\\n\"\n          \"  if (!map.containsKey(key)) {\\n\"\n          \"    throw new java.lang.IllegalArgumentException();\\n\"\n          \"  }\\n\"\n          \"  return map.get(key);\\n\"\n          \"}\\n\");\n    }\n  } else {\n    printer->Print(\n        variables_,\n        \"/**\\n\"\n        \" * Use {@link #get$capitalized_name$Map()} instead.\\n\"\n        \" */\\n\"\n        \"@java.lang.Deprecated\\n\"\n        \"public java.util.Map<$type_parameters$> get$capitalized_name$() {\\n\"\n        \"  return get$capitalized_name$Map();\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\\n\"\n        \"public java.util.Map<$type_parameters$> get$capitalized_name$Map() {\\n\"\n        \"  return internalGet$capitalized_name$().getMap();\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\\n\"\n        \"public $value_type$ get$capitalized_name$OrDefault(\\n\"\n        \"    $key_type$ key,\\n\"\n        \"    $value_type$ defaultValue) {\\n\"\n        \"  $key_null_check$\\n\"\n        \"  java.util.Map<$type_parameters$> map =\\n\"\n        \"      internalGet$capitalized_name$().getMap();\\n\"\n        \"  return map.containsKey(key) ? map.get(key) : defaultValue;\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\\n\"\n        \"public $value_type$ get$capitalized_name$OrThrow(\\n\"\n        \"    $key_type$ key) {\\n\"\n        \"  $key_null_check$\\n\"\n        \"  java.util.Map<$type_parameters$> map =\\n\"\n        \"      internalGet$capitalized_name$().getMap();\\n\"\n        \"  if (!map.containsKey(key)) {\\n\"\n        \"    throw new java.lang.IllegalArgumentException();\\n\"\n        \"  }\\n\"\n        \"  return map.get(key);\\n\"\n        \"}\\n\");\n  }\n}\n\nvoid ImmutableMapFieldGenerator::\nGenerateFieldBuilderInitializationCode(io::Printer* printer)  const {\n  // Nothing to initialize.\n}\n\nvoid ImmutableMapFieldGenerator::\nGenerateInitializationCode(io::Printer* printer) const {\n  // Nothing to initialize.\n}\n\nvoid ImmutableMapFieldGenerator::\nGenerateBuilderClearCode(io::Printer* printer) const {\n  printer->Print(\n      variables_,\n      \"internalGetMutable$capitalized_name$().clear();\\n\");\n}\n\nvoid ImmutableMapFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  printer->Print(\n      variables_,\n      \"internalGetMutable$capitalized_name$().mergeFrom(\\n\"\n      \"    other.internalGet$capitalized_name$());\\n\");\n}\n\nvoid ImmutableMapFieldGenerator::\nGenerateBuildingCode(io::Printer* printer) const {\n  printer->Print(\n      variables_,\n      \"result.$name$_ = internalGet$capitalized_name$();\\n\"\n      \"result.$name$_.makeImmutable();\\n\");\n}\n\nvoid ImmutableMapFieldGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  printer->Print(\n      variables_,\n      \"if (!$get_mutable_bit_parser$) {\\n\"\n      \"  $name$_ = com.google.protobuf.MapField.newMapField(\\n\"\n      \"      $map_field_parameter$);\\n\"\n      \"  $set_mutable_bit_parser$;\\n\"\n      \"}\\n\");\n  if (!SupportUnknownEnumValue(descriptor_->file()) &&\n      GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {\n    printer->Print(\n        variables_,\n        \"com.google.protobuf.ByteString bytes = input.readBytes();\\n\"\n        \"com.google.protobuf.MapEntry<$type_parameters$>\\n\"\n        \"$name$ = $default_entry$.getParserForType().parseFrom(bytes);\\n\");\n    printer->Print(\n        variables_,\n        \"if ($value_enum_type$.forNumber($name$.getValue()) == null) {\\n\"\n        \"  unknownFields.mergeLengthDelimitedField($number$, bytes);\\n\"\n        \"} else {\\n\"\n        \"  $name$_.getMutableMap().put($name$.getKey(), $name$.getValue());\\n\"\n        \"}\\n\");\n  } else {\n    printer->Print(\n        variables_,\n        \"com.google.protobuf.MapEntry<$type_parameters$>\\n\"\n        \"$name$ = input.readMessage(\\n\"\n        \"    $default_entry$.getParserForType(), extensionRegistry);\\n\"\n        \"$name$_.getMutableMap().put($name$.getKey(), $name$.getValue());\\n\");\n  }\n}\n\nvoid ImmutableMapFieldGenerator::\nGenerateParsingDoneCode(io::Printer* printer) const {\n  // Nothing to do here.\n}\n\nvoid ImmutableMapFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(\n      variables_,\n      \"for (java.util.Map.Entry<$type_parameters$> entry\\n\"\n      \"     : internalGet$capitalized_name$().getMap().entrySet()) {\\n\"\n      \"  com.google.protobuf.MapEntry<$type_parameters$>\\n\"\n      \"  $name$ = $default_entry$.newBuilderForType()\\n\"\n      \"      .setKey(entry.getKey())\\n\"\n      \"      .setValue(entry.getValue())\\n\"\n      \"      .build();\\n\"\n      \"  output.writeMessage($number$, $name$);\\n\"\n      \"}\\n\");\n}\n\nvoid ImmutableMapFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(\n      variables_,\n      \"for (java.util.Map.Entry<$type_parameters$> entry\\n\"\n      \"     : internalGet$capitalized_name$().getMap().entrySet()) {\\n\"\n      \"  com.google.protobuf.MapEntry<$type_parameters$>\\n\"\n      \"  $name$ = $default_entry$.newBuilderForType()\\n\"\n      \"      .setKey(entry.getKey())\\n\"\n      \"      .setValue(entry.getValue())\\n\"\n      \"      .build();\\n\"\n      \"  size += com.google.protobuf.CodedOutputStream\\n\"\n      \"      .computeMessageSize($number$, $name$);\\n\"\n      \"}\\n\");\n}\n\nvoid ImmutableMapFieldGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  printer->Print(\n      variables_,\n      \"result = result && internalGet$capitalized_name$().equals(\\n\"\n      \"    other.internalGet$capitalized_name$());\\n\");\n}\n\nvoid ImmutableMapFieldGenerator::\nGenerateHashCode(io::Printer* printer) const {\n  printer->Print(\n      variables_,\n      \"if (!internalGet$capitalized_name$().getMap().isEmpty()) {\\n\"\n      \"  hash = (37 * hash) + $constant_name$;\\n\"\n      \"  hash = (53 * hash) + internalGet$capitalized_name$().hashCode();\\n\"\n      \"}\\n\");\n}\n\nstring ImmutableMapFieldGenerator::GetBoxedType() const {\n  return name_resolver_->GetImmutableClassName(descriptor_->message_type());\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_map_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_H__\n\n#include <google/protobuf/compiler/java/java_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nclass ImmutableMapFieldGenerator : public ImmutableFieldGenerator {\n public:\n  explicit ImmutableMapFieldGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~ImmutableMapFieldGenerator();\n\n  // implements ImmutableFieldGenerator ---------------------------------------\n  int GetNumBitsForMessage() const;\n  int GetNumBitsForBuilder() const;\n  void GenerateInterfaceMembers(io::Printer* printer) const;\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateInitializationCode(io::Printer* printer) const;\n  void GenerateBuilderClearCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateBuildingCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateParsingDoneCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCode(io::Printer* printer) const;\n\n  string GetBoxedType() const;\n\n private:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n  ClassNameResolver* name_resolver_;\n  void GenerateMapGetters(io::Printer* printer) const;\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_map_field_lite.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/compiler/java/java_map_field_lite.h>\n\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/io/printer.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nnamespace {\n\nconst FieldDescriptor* KeyField(const FieldDescriptor* descriptor) {\n  GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());\n  const Descriptor* message = descriptor->message_type();\n  GOOGLE_CHECK(message->options().map_entry());\n  return message->FindFieldByName(\"key\");\n}\n\nconst FieldDescriptor* ValueField(const FieldDescriptor* descriptor) {\n  GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());\n  const Descriptor* message = descriptor->message_type();\n  GOOGLE_CHECK(message->options().map_entry());\n  return message->FindFieldByName(\"value\");\n}\n\nstring TypeName(const FieldDescriptor* field,\n                ClassNameResolver* name_resolver,\n                bool boxed) {\n  if (GetJavaType(field) == JAVATYPE_MESSAGE) {\n    return name_resolver->GetImmutableClassName(field->message_type());\n  } else if (GetJavaType(field) == JAVATYPE_ENUM) {\n    return name_resolver->GetImmutableClassName(field->enum_type());\n  } else {\n    return boxed ? BoxedPrimitiveTypeName(GetJavaType(field))\n                 : PrimitiveTypeName(GetJavaType(field));\n  }\n}\n\nstring WireType(const FieldDescriptor* field) {\n  return \"com.google.protobuf.WireFormat.FieldType.\" +\n      string(FieldTypeName(field->type()));\n}\n\nvoid SetMessageVariables(const FieldDescriptor* descriptor,\n                         int messageBitIndex,\n                         int builderBitIndex,\n                         const FieldGeneratorInfo* info,\n                         Context* context,\n                         map<string, string>* variables) {\n  SetCommonFieldVariables(descriptor, info, variables);\n\n  ClassNameResolver* name_resolver = context->GetNameResolver();\n  (*variables)[\"type\"] =\n      name_resolver->GetImmutableClassName(descriptor->message_type());\n  const FieldDescriptor* key = KeyField(descriptor);\n  const FieldDescriptor* value = ValueField(descriptor);\n  const JavaType keyJavaType = GetJavaType(key);\n  const JavaType valueJavaType = GetJavaType(value);\n\n  (*variables)[\"key_type\"] = TypeName(key, name_resolver, false);\n  (*variables)[\"boxed_key_type\"] = TypeName(key, name_resolver, true);\n  (*variables)[\"key_wire_type\"] = WireType(key);\n  (*variables)[\"key_default_value\"] = DefaultValue(key, true, name_resolver);\n  (*variables)[\"key_null_check\"] = IsReferenceType(keyJavaType) ?\n      \"if (key == null) { throw new java.lang.NullPointerException(); }\" : \"\";\n  (*variables)[\"value_null_check\"] = IsReferenceType(valueJavaType) ?\n      \"if (value == null) { throw new java.lang.NullPointerException(); }\" : \"\";\n\n  if (GetJavaType(value) == JAVATYPE_ENUM) {\n    // We store enums as Integers internally.\n    (*variables)[\"value_type\"] = \"int\";\n    (*variables)[\"boxed_value_type\"] = \"java.lang.Integer\";\n    (*variables)[\"value_wire_type\"] = WireType(value);\n    (*variables)[\"value_default_value\"] =\n        DefaultValue(value, true, name_resolver) + \".getNumber()\";\n\n    (*variables)[\"value_enum_type\"] = TypeName(value, name_resolver, false);\n\n    if (SupportUnknownEnumValue(descriptor->file())) {\n      // Map unknown values to a special UNRECOGNIZED value if supported.\n      (*variables)[\"unrecognized_value\"] =\n          (*variables)[\"value_enum_type\"] + \".UNRECOGNIZED\";\n    } else {\n      // Map unknown values to the default value if we don't have UNRECOGNIZED.\n      (*variables)[\"unrecognized_value\"] =\n          DefaultValue(value, true, name_resolver);\n    }\n  } else {\n    (*variables)[\"value_type\"] = TypeName(value, name_resolver, false);\n    (*variables)[\"boxed_value_type\"] = TypeName(value, name_resolver, true);\n    (*variables)[\"value_wire_type\"] = WireType(value);\n    (*variables)[\"value_default_value\"] =\n        DefaultValue(value, true, name_resolver);\n  }\n  (*variables)[\"type_parameters\"] =\n      (*variables)[\"boxed_key_type\"] + \", \" + (*variables)[\"boxed_value_type\"];\n  // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported\n  // by the proto compiler\n  (*variables)[\"deprecation\"] = descriptor->options().deprecated()\n      ? \"@java.lang.Deprecated \" : \"\";\n\n  (*variables)[\"default_entry\"] = (*variables)[\"capitalized_name\"] +\n      \"DefaultEntryHolder.defaultEntry\";\n}\n\n}  // namespace\n\nImmutableMapFieldLiteGenerator::\nImmutableMapFieldLiteGenerator(const FieldDescriptor* descriptor,\n                                       int messageBitIndex,\n                                       int builderBitIndex,\n                                       Context* context)\n  : descriptor_(descriptor), name_resolver_(context->GetNameResolver())  {\n  SetMessageVariables(descriptor, messageBitIndex, builderBitIndex,\n                      context->GetFieldGeneratorInfo(descriptor),\n                      context, &variables_);\n}\n\nImmutableMapFieldLiteGenerator::\n~ImmutableMapFieldLiteGenerator() {}\n\nint ImmutableMapFieldLiteGenerator::GetNumBitsForMessage() const {\n  return 0;\n}\n\nint ImmutableMapFieldLiteGenerator::GetNumBitsForBuilder() const {\n  return 0;\n}\n\nvoid ImmutableMapFieldLiteGenerator::\nGenerateInterfaceMembers(io::Printer* printer) const {\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(\n      variables_,\n      \"$deprecation$int get$capitalized_name$Count();\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(\n      variables_,\n      \"$deprecation$boolean contains$capitalized_name$(\\n\"\n      \"    $key_type$ key);\\n\");\n  if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {\n    printer->Print(\n        variables_,\n        \"/**\\n\"\n        \" * Use {@link #get$capitalized_name$Map()} instead.\\n\"\n        \" */\\n\"\n        \"@java.lang.Deprecated\\n\"\n        \"java.util.Map<$boxed_key_type$, $value_enum_type$>\\n\"\n        \"get$capitalized_name$();\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$java.util.Map<$boxed_key_type$, $value_enum_type$>\\n\"\n        \"get$capitalized_name$Map();\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$$value_enum_type$ get$capitalized_name$OrDefault(\\n\"\n        \"    $key_type$ key,\\n\"\n        \"    $value_enum_type$ defaultValue);\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$$value_enum_type$ get$capitalized_name$OrThrow(\\n\"\n        \"    $key_type$ key);\\n\");\n    if (SupportUnknownEnumValue(descriptor_->file())) {\n      printer->Print(\n          variables_,\n          \"/**\\n\"\n          \" * Use {@link #get$capitalized_name$ValueMap()} instead.\\n\"\n          \" */\\n\"\n          \"@java.lang.Deprecated\\n\"\n          \"java.util.Map<$type_parameters$>\\n\"\n          \"get$capitalized_name$Value();\\n\");\n      WriteFieldDocComment(printer, descriptor_);\n      printer->Print(\n          variables_,\n          \"$deprecation$java.util.Map<$type_parameters$>\\n\"\n          \"get$capitalized_name$ValueMap();\\n\");\n      WriteFieldDocComment(printer, descriptor_);\n      printer->Print(\n          variables_,\n          \"$deprecation$\\n\"\n          \"$value_type$ get$capitalized_name$ValueOrDefault(\\n\"\n          \"    $key_type$ key,\\n\"\n          \"    $value_type$ defaultValue);\\n\");\n      WriteFieldDocComment(printer, descriptor_);\n      printer->Print(\n          variables_,\n          \"$deprecation$\\n\"\n          \"$value_type$ get$capitalized_name$ValueOrThrow(\\n\"\n          \"    $key_type$ key);\\n\");\n    }\n  } else {\n    printer->Print(\n        variables_,\n        \"/**\\n\"\n        \" * Use {@link #get$capitalized_name$Map()} instead.\\n\"\n        \" */\\n\"\n        \"@java.lang.Deprecated\\n\"\n        \"java.util.Map<$type_parameters$>\\n\"\n        \"get$capitalized_name$();\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$java.util.Map<$type_parameters$>\\n\"\n        \"get$capitalized_name$Map();\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\\n\"\n        \"$value_type$ get$capitalized_name$OrDefault(\\n\"\n        \"    $key_type$ key,\\n\"\n        \"    $value_type$ defaultValue);\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\\n\"\n        \"$value_type$ get$capitalized_name$OrThrow(\\n\"\n        \"    $key_type$ key);\\n\");\n  }\n}\n\nvoid ImmutableMapFieldLiteGenerator::\nGenerateMembers(io::Printer* printer) const {\n  printer->Print(\n      variables_,\n      \"private static final class $capitalized_name$DefaultEntryHolder {\\n\"\n      \"  static final com.google.protobuf.MapEntryLite<\\n\"\n      \"      $type_parameters$> defaultEntry =\\n\"\n      \"          com.google.protobuf.MapEntryLite\\n\"\n      \"          .<$type_parameters$>newDefaultInstance(\\n\"\n      \"              $key_wire_type$,\\n\"\n      \"              $key_default_value$,\\n\"\n      \"              $value_wire_type$,\\n\"\n      \"              $value_default_value$);\\n\"\n      \"}\\n\");\n  printer->Print(\n      variables_,\n      \"private com.google.protobuf.MapFieldLite<\\n\"\n      \"    $type_parameters$> $name$_ =\\n\"\n      \"        com.google.protobuf.MapFieldLite.emptyMapField();\\n\"\n      \"private com.google.protobuf.MapFieldLite<$type_parameters$>\\n\"\n      \"internalGet$capitalized_name$() {\\n\"\n      \"  return $name$_;\\n\"\n      \"}\\n\"\n      \"private com.google.protobuf.MapFieldLite<$type_parameters$>\\n\"\n      \"internalGetMutable$capitalized_name$() {\\n\"\n      \"  if (!$name$_.isMutable()) {\\n\"\n      \"    $name$_ = $name$_.mutableCopy();\\n\"\n      \"  }\\n\"\n      \"  return $name$_;\\n\"\n      \"}\\n\");\n  printer->Print(\n      variables_,\n      \"$deprecation$\\n\"\n      \"public int get$capitalized_name$Count() {\\n\"\n      \"  return internalGet$capitalized_name$().size();\\n\"\n      \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(\n      variables_,\n      \"$deprecation$\\n\"\n      \"public boolean contains$capitalized_name$(\\n\"\n      \"    $key_type$ key) {\\n\"\n      \"  $key_null_check$\\n\"\n      \"  return internalGet$capitalized_name$().containsKey(key);\\n\"\n      \"}\\n\");\n  if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {\n    printer->Print(\n        variables_,\n        \"private static final\\n\"\n        \"com.google.protobuf.Internal.MapAdapter.Converter<\\n\"\n        \"    java.lang.Integer, $value_enum_type$> $name$ValueConverter =\\n\"\n        \"        com.google.protobuf.Internal.MapAdapter.newEnumConverter(\\n\"\n        \"            $value_enum_type$.internalGetValueMap(),\\n\"\n        \"            $unrecognized_value$);\\n\");\n    printer->Print(\n        variables_,\n        \"/**\\n\"\n        \" * Use {@link #get$capitalized_name$Map()} instead.\\n\"\n        \" */\\n\"\n        \"@java.lang.Deprecated\\n\"\n        \"public java.util.Map<$boxed_key_type$, $value_enum_type$>\\n\"\n        \"get$capitalized_name$() {\\n\"\n        \"  return get$capitalized_name$Map();\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\\n\"\n        \"public java.util.Map<$boxed_key_type$, $value_enum_type$>\\n\"\n        \"get$capitalized_name$Map() {\\n\"\n        \"  return java.util.Collections.unmodifiableMap(\\n\"\n        \"      new com.google.protobuf.Internal.MapAdapter<\\n\"\n        \"        $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\\n\"\n        \"            internalGet$capitalized_name$(),\\n\"\n        \"            $name$ValueConverter));\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\\n\"\n        \"public $value_enum_type$ get$capitalized_name$OrDefault(\\n\"\n        \"    $key_type$ key,\\n\"\n        \"    $value_enum_type$ defaultValue) {\\n\"\n        \"  $key_null_check$\\n\"\n        \"  java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\\n\"\n        \"      internalGet$capitalized_name$();\\n\"\n        \"  return map.containsKey(key)\\n\"\n        \"         ? $name$ValueConverter.doForward(map.get(key))\\n\"\n        \"         : defaultValue;\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\\n\"\n        \"public $value_enum_type$ get$capitalized_name$OrThrow(\\n\"\n        \"    $key_type$ key) {\\n\"\n        \"  $key_null_check$\\n\"\n        \"  java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\\n\"\n        \"      internalGet$capitalized_name$();\\n\"\n        \"  if (!map.containsKey(key)) {\\n\"\n        \"    throw new java.lang.IllegalArgumentException();\\n\"\n        \"  }\\n\"\n        \"  return $name$ValueConverter.doForward(map.get(key));\\n\"\n        \"}\\n\");\n    if (SupportUnknownEnumValue(descriptor_->file())) {\n      printer->Print(\n          variables_,\n          \"/**\\n\"\n          \" * Use {@link #get$capitalized_name$ValueMap()} instead.\\n\"\n          \" */\\n\"\n          \"@java.lang.Deprecated\\n\"\n          \"public java.util.Map<$boxed_key_type$, $boxed_value_type$>\\n\"\n          \"get$capitalized_name$Value() {\\n\"\n          \"  return get$capitalized_name$ValueMap();\\n\"\n          \"}\\n\");\n      WriteFieldDocComment(printer, descriptor_);\n      printer->Print(\n          variables_,\n          \"$deprecation$\\n\"\n          \"public java.util.Map<$boxed_key_type$, $boxed_value_type$>\\n\"\n          \"get$capitalized_name$ValueMap() {\\n\"\n          \"  return java.util.Collections.unmodifiableMap(\\n\"\n          \"      internalGet$capitalized_name$());\\n\"\n          \"}\\n\");\n      WriteFieldDocComment(printer, descriptor_);\n      printer->Print(\n          variables_,\n          \"$deprecation$\\n\"\n          \"public $value_type$ get$capitalized_name$ValueOrDefault(\\n\"\n          \"    $key_type$ key,\\n\"\n          \"    $value_type$ defaultValue) {\\n\"\n          \"  $key_null_check$\\n\"\n          \"  java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\\n\"\n          \"      internalGet$capitalized_name$();\\n\"\n          \"  return map.containsKey(key) ? map.get(key) : defaultValue;\\n\"\n          \"}\\n\");\n      WriteFieldDocComment(printer, descriptor_);\n      printer->Print(\n          variables_,\n          \"$deprecation$\\n\"\n          \"public $value_type$ get$capitalized_name$ValueOrThrow(\\n\"\n          \"    $key_type$ key) {\\n\"\n          \"  $key_null_check$\\n\"\n          \"  java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\\n\"\n          \"      internalGet$capitalized_name$();\\n\"\n          \"  if (!map.containsKey(key)) {\\n\"\n          \"    throw new java.lang.IllegalArgumentException();\\n\"\n          \"  }\\n\"\n          \"  return map.get(key);\\n\"\n          \"}\\n\");\n    }\n  } else {\n    printer->Print(\n        variables_,\n        \"/**\\n\"\n        \" * Use {@link #get$capitalized_name$Map()} instead.\\n\"\n        \" */\\n\"\n        \"@java.lang.Deprecated\\n\"\n        \"public java.util.Map<$type_parameters$> get$capitalized_name$() {\\n\"\n        \"  return get$capitalized_name$Map();\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\\n\"\n        \"public java.util.Map<$type_parameters$> get$capitalized_name$Map() {\\n\"\n        \"  return java.util.Collections.unmodifiableMap(\\n\"\n        \"      internalGet$capitalized_name$());\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\\n\"\n        \"public $value_type$ get$capitalized_name$OrDefault(\\n\"\n        \"    $key_type$ key,\\n\"\n        \"    $value_type$ defaultValue) {\\n\"\n        \"  $key_null_check$\\n\"\n        \"  java.util.Map<$type_parameters$> map =\\n\"\n        \"      internalGet$capitalized_name$();\\n\"\n        \"  return map.containsKey(key) ? map.get(key) : defaultValue;\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\\n\"\n        \"public $value_type$ get$capitalized_name$OrThrow(\\n\"\n        \"    $key_type$ key) {\\n\"\n        \"  $key_null_check$\\n\"\n        \"  java.util.Map<$type_parameters$> map =\\n\"\n        \"      internalGet$capitalized_name$();\\n\"\n        \"  if (!map.containsKey(key)) {\\n\"\n        \"    throw new java.lang.IllegalArgumentException();\\n\"\n        \"  }\\n\"\n        \"  return map.get(key);\\n\"\n        \"}\\n\");\n  }\n\n  // Generate private setters for the builder to proxy into.\n  if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"private java.util.Map<$boxed_key_type$, $value_enum_type$>\\n\"\n        \"getMutable$capitalized_name$Map() {\\n\"\n        \"  return new com.google.protobuf.Internal.MapAdapter<\\n\"\n        \"      $boxed_key_type$, $value_enum_type$, java.lang.Integer>(\\n\"\n        \"          internalGetMutable$capitalized_name$(),\\n\"\n        \"          $name$ValueConverter);\\n\"\n        \"}\\n\");\n    if (SupportUnknownEnumValue(descriptor_->file())) {\n      WriteFieldDocComment(printer, descriptor_);\n      printer->Print(\n          variables_,\n          \"private java.util.Map<$boxed_key_type$, $boxed_value_type$>\\n\"\n          \"getMutable$capitalized_name$ValueMap() {\\n\"\n          \"  return internalGetMutable$capitalized_name$();\\n\"\n          \"}\\n\");\n    }\n  } else {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"private java.util.Map<$type_parameters$>\\n\"\n        \"getMutable$capitalized_name$Map() {\\n\"\n        \"  return internalGetMutable$capitalized_name$();\\n\"\n        \"}\\n\");\n  }\n}\n\nvoid ImmutableMapFieldLiteGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  printer->Print(\n      variables_,\n      \"$deprecation$\\n\"\n      \"public int get$capitalized_name$Count() {\\n\"\n      \"  return instance.get$capitalized_name$Map().size();\\n\"\n      \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(\n      variables_,\n      \"$deprecation$\\n\"\n      \"public boolean contains$capitalized_name$(\\n\"\n      \"    $key_type$ key) {\\n\"\n      \"  $key_null_check$\\n\"\n      \"  return instance.get$capitalized_name$Map().containsKey(key);\\n\"\n      \"}\\n\");\n  printer->Print(\n      variables_,\n      \"$deprecation$\\n\"\n      \"public Builder clear$capitalized_name$() {\\n\"\n      \"  copyOnWrite();\\n\"\n      \"  instance.getMutable$capitalized_name$Map().clear();\\n\"\n      \"  return this;\\n\"\n      \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(\n      variables_,\n      \"$deprecation$\\n\"\n      \"public Builder remove$capitalized_name$(\\n\"\n      \"    $key_type$ key) {\\n\"\n      \"  $key_null_check$\\n\"\n      \"  copyOnWrite();\\n\"\n      \"  instance.getMutable$capitalized_name$Map().remove(key);\\n\"\n      \"  return this;\\n\"\n      \"}\\n\");\n  if (GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {\n    printer->Print(\n        variables_,\n        \"/**\\n\"\n        \" * Use {@link #get$capitalized_name$Map()} instead.\\n\"\n        \" */\\n\"\n        \"@java.lang.Deprecated\\n\"\n        \"public java.util.Map<$boxed_key_type$, $value_enum_type$>\\n\"\n        \"get$capitalized_name$() {\\n\"\n        \"  return get$capitalized_name$Map();\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\\n\"\n        \"public java.util.Map<$boxed_key_type$, $value_enum_type$>\\n\"\n        \"get$capitalized_name$Map() {\\n\"\n        \"  return java.util.Collections.unmodifiableMap(\\n\"\n        \"      instance.get$capitalized_name$Map());\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\\n\"\n        \"public $value_enum_type$ get$capitalized_name$OrDefault(\\n\"\n        \"    $key_type$ key,\\n\"\n        \"    $value_enum_type$ defaultValue) {\\n\"\n        \"  $key_null_check$\\n\"\n        \"  java.util.Map<$boxed_key_type$, $value_enum_type$> map =\\n\"\n        \"      instance.get$capitalized_name$Map();\\n\"\n        \"  return map.containsKey(key)\\n\"\n        \"         ? map.get(key)\\n\"\n        \"         : defaultValue;\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\\n\"\n        \"public $value_enum_type$ get$capitalized_name$OrThrow(\\n\"\n        \"    $key_type$ key) {\\n\"\n        \"  $key_null_check$\\n\"\n        \"  java.util.Map<$boxed_key_type$, $value_enum_type$> map =\\n\"\n        \"      instance.get$capitalized_name$Map();\\n\"\n        \"  if (!map.containsKey(key)) {\\n\"\n        \"    throw new java.lang.IllegalArgumentException();\\n\"\n        \"  }\\n\"\n        \"  return map.get(key);\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$public Builder put$capitalized_name$(\\n\"\n        \"    $key_type$ key,\\n\"\n        \"    $value_enum_type$ value) {\\n\"\n        \"  $key_null_check$\\n\"\n        \"  $value_null_check$\\n\"\n        \"  copyOnWrite();\\n\"\n        \"  instance.getMutable$capitalized_name$Map().put(key, value);\\n\"\n        \"  return this;\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$public Builder putAll$capitalized_name$(\\n\"\n        \"    java.util.Map<$boxed_key_type$, $value_enum_type$> values) {\\n\"\n        \"  copyOnWrite();\\n\"\n        \"  instance.getMutable$capitalized_name$Map().putAll(values);\\n\"\n        \"  return this;\\n\"\n        \"}\\n\");\n    if (SupportUnknownEnumValue(descriptor_->file())) {\n      printer->Print(\n          variables_,\n          \"/**\\n\"\n          \" * Use {@link #get$capitalized_name$ValueMap()} instead.\\n\"\n          \" */\\n\"\n          \"@java.lang.Deprecated\\n\"\n          \"public java.util.Map<$boxed_key_type$, $boxed_value_type$>\\n\"\n          \"get$capitalized_name$Value() {\\n\"\n          \"  return get$capitalized_name$ValueMap();\\n\"\n          \"}\\n\");\n      WriteFieldDocComment(printer, descriptor_);\n      printer->Print(\n          variables_,\n          \"$deprecation$\\n\"\n          \"public java.util.Map<$boxed_key_type$, $boxed_value_type$>\\n\"\n          \"get$capitalized_name$ValueMap() {\\n\"\n          \"  return java.util.Collections.unmodifiableMap(\\n\"\n          \"      instance.get$capitalized_name$ValueMap());\\n\"\n          \"}\\n\");\n      WriteFieldDocComment(printer, descriptor_);\n      printer->Print(\n          variables_,\n          \"$deprecation$\\n\"\n          \"public $value_type$ get$capitalized_name$ValueOrDefault(\\n\"\n          \"    $key_type$ key,\\n\"\n          \"    $value_type$ defaultValue) {\\n\"\n          \"  $key_null_check$\\n\"\n          \"  java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\\n\"\n          \"      instance.get$capitalized_name$ValueMap();\\n\"\n          \"  return map.containsKey(key) ? map.get(key) : defaultValue;\\n\"\n          \"}\\n\");\n      WriteFieldDocComment(printer, descriptor_);\n      printer->Print(\n          variables_,\n          \"$deprecation$\\n\"\n          \"public $value_type$ get$capitalized_name$ValueOrThrow(\\n\"\n          \"    $key_type$ key) {\\n\"\n          \"  $key_null_check$\\n\"\n          \"  java.util.Map<$boxed_key_type$, $boxed_value_type$> map =\\n\"\n          \"      instance.get$capitalized_name$ValueMap();\\n\"\n          \"  if (!map.containsKey(key)) {\\n\"\n          \"    throw new java.lang.IllegalArgumentException();\\n\"\n          \"  }\\n\"\n          \"  return map.get(key);\\n\"\n          \"}\\n\");\n      WriteFieldDocComment(printer, descriptor_);\n      printer->Print(\n          variables_,\n          \"$deprecation$public Builder put$capitalized_name$Value(\\n\"\n          \"    $key_type$ key,\\n\"\n          \"    $value_type$ value) {\\n\"\n          \"  $key_null_check$\\n\"\n          \"  if ($value_enum_type$.forNumber(value) == null) {\\n\"\n          \"    throw new java.lang.IllegalArgumentException();\\n\"\n          \"  }\\n\"\n          \"  copyOnWrite();\\n\"\n          \"  instance.getMutable$capitalized_name$ValueMap().put(key, value);\\n\"\n          \"  return this;\\n\"\n          \"}\\n\");\n      WriteFieldDocComment(printer, descriptor_);\n      printer->Print(\n          variables_,\n          \"$deprecation$public Builder putAll$capitalized_name$Value(\\n\"\n          \"    java.util.Map<$boxed_key_type$, $boxed_value_type$> values) {\\n\"\n          \"  copyOnWrite();\\n\"\n          \"  instance.getMutable$capitalized_name$ValueMap().putAll(values);\\n\"\n          \"  return this;\\n\"\n          \"}\\n\");\n    }\n  } else {\n    printer->Print(\n        variables_,\n        \"/**\\n\"\n        \" * Use {@link #get$capitalized_name$Map()} instead.\\n\"\n        \" */\\n\"\n        \"@java.lang.Deprecated\\n\"\n        \"public java.util.Map<$type_parameters$> get$capitalized_name$() {\\n\"\n        \"  return get$capitalized_name$Map();\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\"\n        \"public java.util.Map<$type_parameters$> get$capitalized_name$Map() {\\n\"\n        \"  return java.util.Collections.unmodifiableMap(\\n\"\n        \"      instance.get$capitalized_name$Map());\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\\n\"\n        \"public $value_type$ get$capitalized_name$OrDefault(\\n\"\n        \"    $key_type$ key,\\n\"\n        \"    $value_type$ defaultValue) {\\n\"\n        \"  $key_null_check$\\n\"\n        \"  java.util.Map<$type_parameters$> map =\\n\"\n        \"      instance.get$capitalized_name$Map();\\n\"\n        \"  return map.containsKey(key) ? map.get(key) : defaultValue;\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\\n\"\n        \"public $value_type$ get$capitalized_name$OrThrow(\\n\"\n        \"    $key_type$ key) {\\n\"\n        \"  $key_null_check$\\n\"\n        \"  java.util.Map<$type_parameters$> map =\\n\"\n        \"      instance.get$capitalized_name$Map();\\n\"\n        \"  if (!map.containsKey(key)) {\\n\"\n        \"    throw new java.lang.IllegalArgumentException();\\n\"\n        \"  }\\n\"\n        \"  return map.get(key);\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\"\n        \"public Builder put$capitalized_name$(\\n\"\n        \"    $key_type$ key,\\n\"\n        \"    $value_type$ value) {\\n\"\n        \"  $key_null_check$\\n\"\n        \"  $value_null_check$\\n\"\n        \"  copyOnWrite();\\n\"\n        \"  instance.getMutable$capitalized_name$Map().put(key, value);\\n\"\n        \"  return this;\\n\"\n        \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(\n        variables_,\n        \"$deprecation$\"\n        \"public Builder putAll$capitalized_name$(\\n\"\n        \"    java.util.Map<$type_parameters$> values) {\\n\"\n        \"  copyOnWrite();\\n\"\n        \"  instance.getMutable$capitalized_name$Map().putAll(values);\\n\"\n        \"  return this;\\n\"\n        \"}\\n\");\n  }\n}\n\nvoid ImmutableMapFieldLiteGenerator::\nGenerateFieldBuilderInitializationCode(io::Printer* printer)  const {\n  // Nothing to initialize.\n}\n\nvoid ImmutableMapFieldLiteGenerator::\nGenerateInitializationCode(io::Printer* printer) const {\n  // Nothing to initialize.\n}\n\nvoid ImmutableMapFieldLiteGenerator::\nGenerateVisitCode(io::Printer* printer) const {\n  printer->Print(\n      variables_,\n      \"$name$_ = visitor.visitMap(\\n\"\n      \"    $name$_, other.internalGet$capitalized_name$());\\n\");\n}\n\nvoid ImmutableMapFieldLiteGenerator::\nGenerateDynamicMethodMakeImmutableCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$_.makeImmutable();\\n\");\n}\n\nvoid ImmutableMapFieldLiteGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  printer->Print(\n      variables_,\n      \"if (!$name$_.isMutable()) {\\n\"\n      \"  $name$_ = $name$_.mutableCopy();\\n\"\n      \"}\\n\");\n  if (!SupportUnknownEnumValue(descriptor_->file()) &&\n      GetJavaType(ValueField(descriptor_)) == JAVATYPE_ENUM) {\n    printer->Print(\n        variables_,\n        \"com.google.protobuf.ByteString bytes = input.readBytes();\\n\"\n        \"java.util.Map.Entry<$type_parameters$> $name$ =\\n\"\n        \"    $default_entry$.parseEntry(bytes, extensionRegistry);\\n\");\n    printer->Print(\n        variables_,\n        \"if ($value_enum_type$.forNumber($name$.getValue()) == null) {\\n\"\n        \"  super.mergeLengthDelimitedField($number$, bytes);\\n\"\n        \"} else {\\n\"\n        \"  $name$_.put($name$);\\n\"\n        \"}\\n\");\n  } else {\n    printer->Print(\n        variables_,\n        \"$default_entry$.parseInto($name$_, input, extensionRegistry);\");\n  }\n}\n\nvoid ImmutableMapFieldLiteGenerator::\nGenerateParsingDoneCode(io::Printer* printer) const {\n  // Nothing to do here.\n}\n\nvoid ImmutableMapFieldLiteGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(\n      variables_,\n      \"for (java.util.Map.Entry<$type_parameters$> entry\\n\"\n      \"     : internalGet$capitalized_name$().entrySet()) {\\n\"\n      \"  $default_entry$.serializeTo(\\n\"\n      \"      output, $number$, entry.getKey(), entry.getValue());\\n\"\n      \"}\\n\");\n}\n\nvoid ImmutableMapFieldLiteGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(\n      variables_,\n      \"for (java.util.Map.Entry<$type_parameters$> entry\\n\"\n      \"     : internalGet$capitalized_name$().entrySet()) {\\n\"\n      \"  size += $default_entry$.computeMessageSize(\\n\"\n      \"    $number$, entry.getKey(), entry.getValue());\\n\"\n      \"}\\n\");\n}\n\nvoid ImmutableMapFieldLiteGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  printer->Print(\n      variables_,\n      \"result = result && internalGet$capitalized_name$().equals(\\n\"\n      \"    other.internalGet$capitalized_name$());\\n\");\n}\n\nvoid ImmutableMapFieldLiteGenerator::\nGenerateHashCode(io::Printer* printer) const {\n  printer->Print(\n      variables_,\n      \"if (!internalGet$capitalized_name$().isEmpty()) {\\n\"\n      \"  hash = (37 * hash) + $constant_name$;\\n\"\n      \"  hash = (53 * hash) + internalGet$capitalized_name$().hashCode();\\n\"\n      \"}\\n\");\n}\n\nstring ImmutableMapFieldLiteGenerator::GetBoxedType() const {\n  return name_resolver_->GetImmutableClassName(descriptor_->message_type());\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_map_field_lite.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_LITE_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_LITE_H__\n\n#include <google/protobuf/compiler/java/java_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nclass ImmutableMapFieldLiteGenerator : public ImmutableFieldLiteGenerator {\n public:\n  explicit ImmutableMapFieldLiteGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~ImmutableMapFieldLiteGenerator();\n\n  // implements ImmutableFieldLiteGenerator ------------------------------------\n  int GetNumBitsForMessage() const;\n  int GetNumBitsForBuilder() const;\n  void GenerateInterfaceMembers(io::Printer* printer) const;\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateInitializationCode(io::Printer* printer) const;\n  void GenerateVisitCode(io::Printer* printer) const;\n  void GenerateDynamicMethodMakeImmutableCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateParsingDoneCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCode(io::Printer* printer) const;\n\n  string GetBoxedType() const;\n\n private:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n  ClassNameResolver* name_resolver_;\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_MAP_FIELD_LITE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_message.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/java/java_message.h>\n\n#include <algorithm>\n#include <google/protobuf/stubs/hash.h>\n#include <map>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <vector>\n\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n#include <google/protobuf/compiler/java/java_enum.h>\n#include <google/protobuf/compiler/java/java_extension.h>\n#include <google/protobuf/compiler/java/java_generator_factory.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_message_builder.h>\n#include <google/protobuf/compiler/java/java_message_builder_lite.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nusing internal::WireFormat;\nusing internal::WireFormatLite;\n\nnamespace {\nbool GenerateHasBits(const Descriptor* descriptor) {\n  return SupportFieldPresence(descriptor->file()) ||\n      HasRepeatedFields(descriptor);\n}\n\nstring MapValueImmutableClassdName(const Descriptor* descriptor,\n                                   ClassNameResolver* name_resolver) {\n  const FieldDescriptor* value_field = descriptor->FindFieldByName(\"value\");\n  GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, value_field->type());\n  return name_resolver->GetImmutableClassName(value_field->message_type());\n}\n}  // namespace\n\n// ===================================================================\n\nMessageGenerator::MessageGenerator(const Descriptor* descriptor)\n  : descriptor_(descriptor) {}\n\nMessageGenerator::~MessageGenerator() {}\n\n// ===================================================================\nImmutableMessageGenerator::ImmutableMessageGenerator(\n    const Descriptor* descriptor, Context* context)\n  : MessageGenerator(descriptor), context_(context),\n    name_resolver_(context->GetNameResolver()),\n    field_generators_(descriptor, context_) {\n  GOOGLE_CHECK(HasDescriptorMethods(descriptor->file(), context->EnforceLite()))\n      << \"Generator factory error: A non-lite message generator is used to \"\n         \"generate lite messages.\";\n}\n\nImmutableMessageGenerator::~ImmutableMessageGenerator() {}\n\nvoid ImmutableMessageGenerator::GenerateStaticVariables(\n    io::Printer* printer, int* bytecode_estimate) {\n  // Because descriptor.proto (com.google.protobuf.DescriptorProtos) is\n  // used in the construction of descriptors, we have a tricky bootstrapping\n  // problem.  To help control static initialization order, we make sure all\n  // descriptors and other static data that depends on them are members of\n  // the outermost class in the file.  This way, they will be initialized in\n  // a deterministic order.\n\n  map<string, string> vars;\n  vars[\"identifier\"] = UniqueFileScopeIdentifier(descriptor_);\n  vars[\"index\"] = SimpleItoa(descriptor_->index());\n  vars[\"classname\"] = name_resolver_->GetImmutableClassName(descriptor_);\n  if (descriptor_->containing_type() != NULL) {\n    vars[\"parent\"] = UniqueFileScopeIdentifier(\n        descriptor_->containing_type());\n  }\n  if (MultipleJavaFiles(descriptor_->file(), /* immutable = */ true)) {\n    // We can only make these package-private since the classes that use them\n    // are in separate files.\n    vars[\"private\"] = \"\";\n  } else {\n    vars[\"private\"] = \"private \";\n  }\n  if (*bytecode_estimate <= kMaxStaticSize) {\n    vars[\"final\"] = \"final \";\n  } else {\n    vars[\"final\"] = \"\";\n  }\n\n  // The descriptor for this type.\n  printer->Print(vars,\n    // TODO(teboring): final needs to be added back. The way to fix it is to\n    // generate methods that can construct the types, and then still declare the\n    // types, and then init them in clinit with the new method calls.\n    \"$private$static $final$com.google.protobuf.Descriptors.Descriptor\\n\"\n    \"  internal_$identifier$_descriptor;\\n\");\n  *bytecode_estimate += 30;\n\n  // And the FieldAccessorTable.\n  GenerateFieldAccessorTable(printer, bytecode_estimate);\n\n  // Generate static members for all nested types.\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    // TODO(kenton):  Reuse MessageGenerator objects?\n    ImmutableMessageGenerator(descriptor_->nested_type(i), context_)\n        .GenerateStaticVariables(printer, bytecode_estimate);\n  }\n}\n\nint ImmutableMessageGenerator::GenerateStaticVariableInitializers(\n    io::Printer* printer) {\n  int bytecode_estimate = 0;\n  map<string, string> vars;\n  vars[\"identifier\"] = UniqueFileScopeIdentifier(descriptor_);\n  vars[\"index\"] = SimpleItoa(descriptor_->index());\n  vars[\"classname\"] = name_resolver_->GetImmutableClassName(descriptor_);\n  if (descriptor_->containing_type() != NULL) {\n    vars[\"parent\"] = UniqueFileScopeIdentifier(\n        descriptor_->containing_type());\n  }\n\n  // The descriptor for this type.\n  if (descriptor_->containing_type() == NULL) {\n    printer->Print(vars,\n      \"internal_$identifier$_descriptor =\\n\"\n      \"  getDescriptor().getMessageTypes().get($index$);\\n\");\n    bytecode_estimate += 30;\n  } else {\n    printer->Print(vars,\n      \"internal_$identifier$_descriptor =\\n\"\n      \"  internal_$parent$_descriptor.getNestedTypes().get($index$);\\n\");\n    bytecode_estimate += 30;\n  }\n\n  // And the FieldAccessorTable.\n  bytecode_estimate += GenerateFieldAccessorTableInitializer(printer);\n\n  // Generate static member initializers for all nested types.\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    // TODO(kenton):  Reuse MessageGenerator objects?\n    bytecode_estimate +=\n        ImmutableMessageGenerator(descriptor_->nested_type(i), context_)\n            .GenerateStaticVariableInitializers(printer);\n  }\n  return bytecode_estimate;\n}\n\nvoid ImmutableMessageGenerator::\nGenerateFieldAccessorTable(io::Printer* printer, int* bytecode_estimate) {\n  map<string, string> vars;\n  vars[\"identifier\"] = UniqueFileScopeIdentifier(descriptor_);\n  if (MultipleJavaFiles(descriptor_->file(), /* immutable = */ true)) {\n    // We can only make these package-private since the classes that use them\n    // are in separate files.\n    vars[\"private\"] = \"\";\n  } else {\n    vars[\"private\"] = \"private \";\n  }\n  if (*bytecode_estimate <= kMaxStaticSize) {\n    vars[\"final\"] = \"final \";\n  } else {\n    vars[\"final\"] = \"\";\n  }\n  vars[\"ver\"] = GeneratedCodeVersionSuffix();\n  printer->Print(vars,\n    \"$private$static $final$\\n\"\n    \"  com.google.protobuf.GeneratedMessage$ver$.FieldAccessorTable\\n\"\n    \"    internal_$identifier$_fieldAccessorTable;\\n\");\n\n  // 6 bytes per field and oneof\n  *bytecode_estimate += 10 + 6 * descriptor_->field_count()\n      + 6 * descriptor_->oneof_decl_count();\n}\n\nint ImmutableMessageGenerator::\nGenerateFieldAccessorTableInitializer(io::Printer* printer) {\n  int bytecode_estimate = 10;\n  printer->Print(\n    \"internal_$identifier$_fieldAccessorTable = new\\n\"\n    \"  com.google.protobuf.GeneratedMessage$ver$.FieldAccessorTable(\\n\"\n    \"    internal_$identifier$_descriptor,\\n\"\n    \"    new java.lang.String[] { \",\n    \"identifier\", UniqueFileScopeIdentifier(descriptor_),\n    \"ver\", GeneratedCodeVersionSuffix());\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n    const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);\n    bytecode_estimate += 6;\n    printer->Print(\n      \"\\\"$field_name$\\\", \",\n      \"field_name\", info->capitalized_name);\n  }\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    const OneofDescriptor* oneof = descriptor_->oneof_decl(i);\n    const OneofGeneratorInfo* info = context_->GetOneofGeneratorInfo(oneof);\n    bytecode_estimate += 6;\n    printer->Print(\n      \"\\\"$oneof_name$\\\", \",\n      \"oneof_name\", info->capitalized_name);\n  }\n  printer->Print(\"});\\n\");\n  return bytecode_estimate;\n}\n\n// ===================================================================\n\nvoid ImmutableMessageGenerator::GenerateInterface(io::Printer* printer) {\n  MaybePrintGeneratedAnnotation(context_, printer, descriptor_,\n                                /* immutable = */ true, \"OrBuilder\");\n  if (descriptor_->extension_range_count() > 0) {\n    printer->Print(\n        \"public interface $classname$OrBuilder$idend$ extends\\n\"\n        \"    $extra_interfaces$\\n\"\n        \"    com.google.protobuf.GeneratedMessage$ver$.\\n\"\n        \"        ExtendableMessageOrBuilder<$classname$> {\\n\",\n        \"extra_interfaces\", ExtraMessageOrBuilderInterfaces(descriptor_),\n        \"classname\", descriptor_->name(),\n        \"idend\", \"\", \"ver\", GeneratedCodeVersionSuffix());\n  } else {\n    printer->Print(\n        \"public interface $classname$OrBuilder$idend$ extends\\n\"\n        \"    $extra_interfaces$\\n\"\n        \"    com.google.protobuf.MessageOrBuilder {\\n\",\n        \"extra_interfaces\", ExtraMessageOrBuilderInterfaces(descriptor_),\n        \"classname\", descriptor_->name(),\n        \"idend\", \"\");\n  }\n  printer->Annotate(\"classname\", \"idend\", descriptor_);\n\n  printer->Indent();\n    for (int i = 0; i < descriptor_->field_count(); i++) {\n      printer->Print(\"\\n\");\n      field_generators_.get(descriptor_->field(i))\n                       .GenerateInterfaceMembers(printer);\n    }\n    for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n      printer->Print(\n          \"\\n\"\n          \"public $classname$.$oneof_capitalized_name$Case \"\n          \"get$oneof_capitalized_name$Case();\\n\",\n          \"oneof_capitalized_name\",\n          context_->GetOneofGeneratorInfo(\n              descriptor_->oneof_decl(i))->capitalized_name,\n          \"classname\",\n          context_->GetNameResolver()->GetImmutableClassName(\n              descriptor_));\n    }\n  printer->Outdent();\n\n  printer->Print(\"}\\n\");\n}\n\n// ===================================================================\n\nvoid ImmutableMessageGenerator::Generate(io::Printer* printer) {\n  bool is_own_file = IsOwnFile(descriptor_, /* immutable = */ true);\n\n  map<string, string> variables;\n  variables[\"static\"] = is_own_file ? \" \" : \" static \";\n  variables[\"classname\"] = descriptor_->name();\n  variables[\"extra_interfaces\"] = ExtraMessageInterfaces(descriptor_);\n  variables[\"ver\"] = GeneratedCodeVersionSuffix();\n\n  WriteMessageDocComment(printer, descriptor_);\n  MaybePrintGeneratedAnnotation(context_, printer, descriptor_,\n                                /* immutable = */ true);\n\n  // The builder_type stores the super type name of the nested Builder class.\n  string builder_type;\n  if (descriptor_->extension_range_count() > 0) {\n    printer->Print(variables,\n                   \"public $static$final class $classname$ extends\\n\");\n    printer->Annotate(\"classname\", descriptor_);\n    printer->Print(\n        variables,\n        \"    com.google.protobuf.GeneratedMessage$ver$.ExtendableMessage<\\n\"\n        \"      $classname$> implements\\n\"\n        \"    $extra_interfaces$\\n\"\n        \"    $classname$OrBuilder {\\n\");\n    builder_type = strings::Substitute(\n        \"com.google.protobuf.GeneratedMessage$1.ExtendableBuilder<$0, ?>\",\n        name_resolver_->GetImmutableClassName(descriptor_),\n        GeneratedCodeVersionSuffix());\n  } else {\n    printer->Print(variables,\n                   \"public $static$final class $classname$ extends\\n\");\n    printer->Annotate(\"classname\", descriptor_);\n    printer->Print(variables,\n      \"    com.google.protobuf.GeneratedMessage$ver$ implements\\n\"\n      \"    $extra_interfaces$\\n\"\n      \"    $classname$OrBuilder {\\n\");\n    builder_type = strings::Substitute(\n        \"com.google.protobuf.GeneratedMessage$0.Builder<?>\",\n        GeneratedCodeVersionSuffix());\n  }\n  printer->Indent();\n  // Using builder_type, instead of Builder, prevents the Builder class from\n  // being loaded into PermGen space when the default instance is created.\n  // This optimizes the PermGen space usage for clients that do not modify\n  // messages.\n  printer->Print(\n    \"// Use $classname$.newBuilder() to construct.\\n\"\n    \"private $classname$($buildertype$ builder) {\\n\"\n    \"  super(builder);\\n\"\n    \"}\\n\",\n    \"classname\", descriptor_->name(),\n    \"buildertype\", builder_type);\n  printer->Print(\n    \"private $classname$() {\\n\",\n    \"classname\", descriptor_->name());\n  printer->Indent();\n  GenerateInitializers(printer);\n  printer->Outdent();\n  printer->Print(\n    \"}\\n\"\n    \"\\n\");\n\n  printer->Print(\n    \"@java.lang.Override\\n\"\n    \"public final com.google.protobuf.UnknownFieldSet\\n\"\n    \"getUnknownFields() {\\n\");\n  if (PreserveUnknownFields(descriptor_)) {\n    printer->Print(\n      \"  return this.unknownFields;\\n\");\n  } else {\n    printer->Print(\n      \"  return com.google.protobuf.UnknownFieldSet.getDefaultInstance();\\n\");\n  }\n  printer->Print(\n    \"}\\n\");\n\n  if (context_->HasGeneratedMethods(descriptor_)) {\n    GenerateParsingConstructor(printer);\n  }\n\n  GenerateDescriptorMethods(printer);\n\n  // Nested types\n  for (int i = 0; i < descriptor_->enum_type_count(); i++) {\n    EnumGenerator(descriptor_->enum_type(i), true, context_)\n        .Generate(printer);\n  }\n\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    // Don't generate Java classes for map entry messages.\n    if (IsMapEntry(descriptor_->nested_type(i))) continue;\n    ImmutableMessageGenerator messageGenerator(\n        descriptor_->nested_type(i), context_);\n    messageGenerator.GenerateInterface(printer);\n    messageGenerator.Generate(printer);\n  }\n\n  if (GenerateHasBits(descriptor_)) {\n    // Integers for bit fields.\n    int totalBits = 0;\n    for (int i = 0; i < descriptor_->field_count(); i++) {\n      totalBits += field_generators_.get(descriptor_->field(i))\n          .GetNumBitsForMessage();\n    }\n    int totalInts = (totalBits + 31) / 32;\n    for (int i = 0; i < totalInts; i++) {\n      printer->Print(\"private int $bit_field_name$;\\n\",\n        \"bit_field_name\", GetBitFieldName(i));\n    }\n  }\n\n  // oneof\n  map<string, string> vars;\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    vars[\"oneof_name\"] = context_->GetOneofGeneratorInfo(\n        descriptor_->oneof_decl(i))->name;\n    vars[\"oneof_capitalized_name\"] = context_->GetOneofGeneratorInfo(\n        descriptor_->oneof_decl(i))->capitalized_name;\n    vars[\"oneof_index\"] = SimpleItoa(descriptor_->oneof_decl(i)->index());\n    // oneofCase_ and oneof_\n    printer->Print(vars,\n      \"private int $oneof_name$Case_ = 0;\\n\"\n      \"private java.lang.Object $oneof_name$_;\\n\");\n    // OneofCase enum\n    printer->Print(vars,\n      \"public enum $oneof_capitalized_name$Case\\n\"\n      \"    implements com.google.protobuf.Internal.EnumLite {\\n\");\n    printer->Indent();\n    for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {\n      const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);\n      printer->Print(\n        \"$field_name$($field_number$),\\n\",\n        \"field_name\",\n        ToUpper(field->name()),\n        \"field_number\",\n        SimpleItoa(field->number()));\n    }\n    printer->Print(\n      \"$cap_oneof_name$_NOT_SET(0);\\n\",\n      \"cap_oneof_name\",\n      ToUpper(vars[\"oneof_name\"]));\n    printer->Print(vars,\n      \"private final int value;\\n\"\n      \"private $oneof_capitalized_name$Case(int value) {\\n\"\n      \"  this.value = value;\\n\"\n      \"}\\n\");\n    printer->Print(vars,\n      \"/**\\n\"\n      \" * @deprecated Use {@link #forNumber(int)} instead.\\n\"\n      \" */\\n\"\n      \"@java.lang.Deprecated\\n\"\n      \"public static $oneof_capitalized_name$Case valueOf(int value) {\\n\"\n      \"  return forNumber(value);\\n\"\n      \"}\\n\"\n      \"\\n\"\n      \"public static $oneof_capitalized_name$Case forNumber(int value) {\\n\"\n      \"  switch (value) {\\n\");\n    for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {\n      const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);\n      printer->Print(\n        \"    case $field_number$: return $field_name$;\\n\",\n        \"field_number\",\n        SimpleItoa(field->number()),\n        \"field_name\",\n        ToUpper(field->name()));\n    }\n    printer->Print(\n      \"    case 0: return $cap_oneof_name$_NOT_SET;\\n\"\n      \"    default: return null;\\n\"\n      \"  }\\n\"\n      \"}\\n\"\n      \"public int getNumber() {\\n\"\n      \"  return this.value;\\n\"\n      \"}\\n\",\n      \"cap_oneof_name\", ToUpper(vars[\"oneof_name\"]));\n    printer->Outdent();\n    printer->Print(\"};\\n\\n\");\n    // oneofCase()\n    printer->Print(vars,\n      \"public $oneof_capitalized_name$Case\\n\"\n      \"get$oneof_capitalized_name$Case() {\\n\"\n      \"  return $oneof_capitalized_name$Case.forNumber(\\n\"\n      \"      $oneof_name$Case_);\\n\"\n      \"}\\n\"\n      \"\\n\");\n  }\n\n  if (IsAnyMessage(descriptor_)) {\n    GenerateAnyMethods(printer);\n  }\n\n  // Fields\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    printer->Print(\"public static final int $constant_name$ = $number$;\\n\",\n      \"constant_name\", FieldConstantName(descriptor_->field(i)),\n      \"number\", SimpleItoa(descriptor_->field(i)->number()));\n    field_generators_.get(descriptor_->field(i)).GenerateMembers(printer);\n    printer->Print(\"\\n\");\n  }\n\n  if (context_->HasGeneratedMethods(descriptor_)) {\n    GenerateIsInitialized(printer);\n    GenerateMessageSerializationMethods(printer);\n    GenerateEqualsAndHashCode(printer);\n  }\n\n\n  GenerateParseFromMethods(printer);\n  GenerateBuilder(printer);\n\n  printer->Print(\n    \"\\n\"\n    \"// @@protoc_insertion_point(class_scope:$full_name$)\\n\",\n    \"full_name\", descriptor_->full_name());\n\n\n  // Carefully initialize the default instance in such a way that it doesn't\n  // conflict with other initialization.\n  printer->Print(\n    \"private static final $classname$ DEFAULT_INSTANCE;\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n  printer->Print(\n    \"static {\\n\"\n    \"  DEFAULT_INSTANCE = new $classname$();\\n\"\n    \"}\\n\"\n    \"\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n\n  printer->Print(\n      \"public static $classname$ getDefaultInstance() {\\n\"\n      \"  return DEFAULT_INSTANCE;\\n\"\n      \"}\\n\"\n      \"\\n\",\n      \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n\n  GenerateParser(printer);\n\n  printer->Print(\n    \"public $classname$ getDefaultInstanceForType() {\\n\"\n    \"  return DEFAULT_INSTANCE;\\n\"\n    \"}\\n\"\n    \"\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n\n  // Extensions must be declared after the DEFAULT_INSTANCE is initialized\n  // because the DEFAULT_INSTANCE is used by the extension to lazily retrieve\n  // the outer class's FileDescriptor.\n  for (int i = 0; i < descriptor_->extension_count(); i++) {\n    ImmutableExtensionGenerator(descriptor_->extension(i), context_)\n        .Generate(printer);\n  }\n\n  printer->Outdent();\n  printer->Print(\"}\\n\\n\");\n}\n\n\n// ===================================================================\n\nvoid ImmutableMessageGenerator::\nGenerateMessageSerializationMethods(io::Printer* printer) {\n  google::protobuf::scoped_array<const FieldDescriptor * > sorted_fields(\n      SortFieldsByNumber(descriptor_));\n\n  vector<const Descriptor::ExtensionRange*> sorted_extensions;\n  for (int i = 0; i < descriptor_->extension_range_count(); ++i) {\n    sorted_extensions.push_back(descriptor_->extension_range(i));\n  }\n  std::sort(sorted_extensions.begin(), sorted_extensions.end(),\n            ExtensionRangeOrdering());\n\n  printer->Print(\n    \"public void writeTo(com.google.protobuf.CodedOutputStream output)\\n\"\n    \"                    throws java.io.IOException {\\n\");\n  printer->Indent();\n  if (HasPackedFields(descriptor_)) {\n    // writeTo(CodedOutputStream output) might be invoked without\n    // getSerializedSize() ever being called, but we need the memoized\n    // sizes in case this message has packed fields. Rather than emit checks for\n    // each packed field, just call getSerializedSize() up front.\n    // In most cases, getSerializedSize() will have already been called anyway\n    // by one of the wrapper writeTo() methods, making this call cheap.\n    printer->Print(\n      \"getSerializedSize();\\n\");\n  }\n\n  if (descriptor_->extension_range_count() > 0) {\n    if (descriptor_->options().message_set_wire_format()) {\n      printer->Print(\n        \"com.google.protobuf.GeneratedMessage$ver$\\n\"\n        \"  .ExtendableMessage<$classname$>.ExtensionWriter\\n\"\n        \"    extensionWriter = newMessageSetExtensionWriter();\\n\",\n        \"classname\", name_resolver_->GetImmutableClassName(descriptor_),\n        \"ver\", GeneratedCodeVersionSuffix());\n    } else {\n      printer->Print(\n        \"com.google.protobuf.GeneratedMessage$ver$\\n\"\n        \"  .ExtendableMessage<$classname$>.ExtensionWriter\\n\"\n        \"    extensionWriter = newExtensionWriter();\\n\",\n        \"classname\", name_resolver_->GetImmutableClassName(descriptor_),\n        \"ver\", GeneratedCodeVersionSuffix());\n    }\n  }\n\n  // Merge the fields and the extension ranges, both sorted by field number.\n  for (int i = 0, j = 0;\n       i < descriptor_->field_count() || j < sorted_extensions.size();\n       ) {\n    if (i == descriptor_->field_count()) {\n      GenerateSerializeOneExtensionRange(printer, sorted_extensions[j++]);\n    } else if (j == sorted_extensions.size()) {\n      GenerateSerializeOneField(printer, sorted_fields[i++]);\n    } else if (sorted_fields[i]->number() < sorted_extensions[j]->start) {\n      GenerateSerializeOneField(printer, sorted_fields[i++]);\n    } else {\n      GenerateSerializeOneExtensionRange(printer, sorted_extensions[j++]);\n    }\n  }\n\n  if (PreserveUnknownFields(descriptor_)) {\n    if (descriptor_->options().message_set_wire_format()) {\n      printer->Print(\n        \"unknownFields.writeAsMessageSetTo(output);\\n\");\n    } else {\n      printer->Print(\n        \"unknownFields.writeTo(output);\\n\");\n    }\n  }\n\n  printer->Outdent();\n  printer->Print(\n    \"}\\n\"\n    \"\\n\"\n    \"public int getSerializedSize() {\\n\"\n    \"  int size = memoizedSize;\\n\"\n    \"  if (size != -1) return size;\\n\"\n    \"\\n\"\n    \"  size = 0;\\n\");\n  printer->Indent();\n\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    field_generators_.get(sorted_fields[i]).GenerateSerializedSizeCode(printer);\n  }\n\n  if (descriptor_->extension_range_count() > 0) {\n    if (descriptor_->options().message_set_wire_format()) {\n      printer->Print(\n        \"size += extensionsSerializedSizeAsMessageSet();\\n\");\n    } else {\n      printer->Print(\n        \"size += extensionsSerializedSize();\\n\");\n    }\n  }\n\n  if (PreserveUnknownFields(descriptor_)) {\n    if (descriptor_->options().message_set_wire_format()) {\n      printer->Print(\n        \"size += unknownFields.getSerializedSizeAsMessageSet();\\n\");\n    } else {\n      printer->Print(\n        \"size += unknownFields.getSerializedSize();\\n\");\n    }\n  }\n\n  printer->Outdent();\n  printer->Print(\n    \"  memoizedSize = size;\\n\"\n    \"  return size;\\n\"\n    \"}\\n\"\n    \"\\n\");\n\n  printer->Print(\n    \"private static final long serialVersionUID = 0L;\\n\");\n}\n\nvoid ImmutableMessageGenerator::\nGenerateParseFromMethods(io::Printer* printer) {\n  // Note:  These are separate from GenerateMessageSerializationMethods()\n  //   because they need to be generated even for messages that are optimized\n  //   for code size.\n  printer->Print(\n    \"public static $classname$ parseFrom(\\n\"\n    \"    com.google.protobuf.ByteString data)\\n\"\n    \"    throws com.google.protobuf.InvalidProtocolBufferException {\\n\"\n    \"  return PARSER.parseFrom(data);\\n\"\n    \"}\\n\"\n    \"public static $classname$ parseFrom(\\n\"\n    \"    com.google.protobuf.ByteString data,\\n\"\n    \"    com.google.protobuf.ExtensionRegistryLite extensionRegistry)\\n\"\n    \"    throws com.google.protobuf.InvalidProtocolBufferException {\\n\"\n    \"  return PARSER.parseFrom(data, extensionRegistry);\\n\"\n    \"}\\n\"\n    \"public static $classname$ parseFrom(byte[] data)\\n\"\n    \"    throws com.google.protobuf.InvalidProtocolBufferException {\\n\"\n    \"  return PARSER.parseFrom(data);\\n\"\n    \"}\\n\"\n    \"public static $classname$ parseFrom(\\n\"\n    \"    byte[] data,\\n\"\n    \"    com.google.protobuf.ExtensionRegistryLite extensionRegistry)\\n\"\n    \"    throws com.google.protobuf.InvalidProtocolBufferException {\\n\"\n    \"  return PARSER.parseFrom(data, extensionRegistry);\\n\"\n    \"}\\n\"\n    \"public static $classname$ parseFrom(java.io.InputStream input)\\n\"\n    \"    throws java.io.IOException {\\n\"\n    \"  return com.google.protobuf.GeneratedMessage$ver$\\n\"\n    \"      .parseWithIOException(PARSER, input);\\n\"\n    \"}\\n\"\n    \"public static $classname$ parseFrom(\\n\"\n    \"    java.io.InputStream input,\\n\"\n    \"    com.google.protobuf.ExtensionRegistryLite extensionRegistry)\\n\"\n    \"    throws java.io.IOException {\\n\"\n    \"  return com.google.protobuf.GeneratedMessage$ver$\\n\"\n    \"      .parseWithIOException(PARSER, input, extensionRegistry);\\n\"\n    \"}\\n\"\n    \"public static $classname$ parseDelimitedFrom(java.io.InputStream input)\\n\"\n    \"    throws java.io.IOException {\\n\"\n    \"  return com.google.protobuf.GeneratedMessage$ver$\\n\"\n    \"      .parseDelimitedWithIOException(PARSER, input);\\n\"\n    \"}\\n\"\n    \"public static $classname$ parseDelimitedFrom(\\n\"\n    \"    java.io.InputStream input,\\n\"\n    \"    com.google.protobuf.ExtensionRegistryLite extensionRegistry)\\n\"\n    \"    throws java.io.IOException {\\n\"\n    \"  return com.google.protobuf.GeneratedMessage$ver$\\n\"\n    \"      .parseDelimitedWithIOException(PARSER, input, extensionRegistry);\\n\"\n    \"}\\n\"\n    \"public static $classname$ parseFrom(\\n\"\n    \"    com.google.protobuf.CodedInputStream input)\\n\"\n    \"    throws java.io.IOException {\\n\"\n    \"  return com.google.protobuf.GeneratedMessage$ver$\\n\"\n    \"      .parseWithIOException(PARSER, input);\\n\"\n    \"}\\n\"\n    \"public static $classname$ parseFrom(\\n\"\n    \"    com.google.protobuf.CodedInputStream input,\\n\"\n    \"    com.google.protobuf.ExtensionRegistryLite extensionRegistry)\\n\"\n    \"    throws java.io.IOException {\\n\"\n    \"  return com.google.protobuf.GeneratedMessage$ver$\\n\"\n    \"      .parseWithIOException(PARSER, input, extensionRegistry);\\n\"\n    \"}\\n\"\n    \"\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_),\n    \"ver\", GeneratedCodeVersionSuffix());\n}\n\nvoid ImmutableMessageGenerator::GenerateSerializeOneField(\n    io::Printer* printer, const FieldDescriptor* field) {\n  field_generators_.get(field).GenerateSerializationCode(printer);\n}\n\nvoid ImmutableMessageGenerator::GenerateSerializeOneExtensionRange(\n    io::Printer* printer, const Descriptor::ExtensionRange* range) {\n  printer->Print(\n    \"extensionWriter.writeUntil($end$, output);\\n\",\n    \"end\", SimpleItoa(range->end));\n}\n\n// ===================================================================\n\nvoid ImmutableMessageGenerator::GenerateBuilder(io::Printer* printer) {\n  // LITE_RUNTIME implements this at the GeneratedMessageLite level.\n  printer->Print(\n    \"public Builder newBuilderForType() { return newBuilder(); }\\n\");\n\n  printer->Print(\n    \"public static Builder newBuilder() {\\n\"\n    \"  return DEFAULT_INSTANCE.toBuilder();\\n\"\n    \"}\\n\"\n    \"public static Builder newBuilder($classname$ prototype) {\\n\"\n    \"  return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);\\n\"\n    \"}\\n\"\n    \"public Builder toBuilder() {\\n\"\n    \"  return this == DEFAULT_INSTANCE\\n\"\n    \"      ? new Builder() : new Builder().mergeFrom(this);\\n\"\n    \"}\\n\"\n    \"\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n\n  printer->Print(\n    \"@java.lang.Override\\n\"\n    \"protected Builder newBuilderForType(\\n\"\n    \"    com.google.protobuf.GeneratedMessage$ver$.BuilderParent parent) {\\n\"\n    \"  Builder builder = new Builder(parent);\\n\"\n    \"  return builder;\\n\"\n    \"}\\n\",\n    \"ver\", GeneratedCodeVersionSuffix());\n\n  MessageBuilderGenerator builderGenerator(descriptor_, context_);\n  builderGenerator.Generate(printer);\n}\n\nvoid ImmutableMessageGenerator::\nGenerateDescriptorMethods(io::Printer* printer) {\n  if (!descriptor_->options().no_standard_descriptor_accessor()) {\n    printer->Print(\n      \"public static final com.google.protobuf.Descriptors.Descriptor\\n\"\n      \"    getDescriptor() {\\n\"\n      \"  return $fileclass$.internal_$identifier$_descriptor;\\n\"\n      \"}\\n\"\n      \"\\n\",\n      \"fileclass\", name_resolver_->GetImmutableClassName(descriptor_->file()),\n      \"identifier\", UniqueFileScopeIdentifier(descriptor_));\n  }\n  vector<const FieldDescriptor*> map_fields;\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n    if (GetJavaType(field) == JAVATYPE_MESSAGE &&\n        IsMapEntry(field->message_type())) {\n      map_fields.push_back(field);\n    }\n  }\n  if (!map_fields.empty()) {\n    printer->Print(\n      \"@SuppressWarnings({\\\"rawtypes\\\"})\\n\"\n      \"protected com.google.protobuf.MapField internalGetMapField(\\n\"\n      \"    int number) {\\n\"\n      \"  switch (number) {\\n\");\n    printer->Indent();\n    printer->Indent();\n    for (int i = 0; i < map_fields.size(); ++i) {\n      const FieldDescriptor* field = map_fields[i];\n      const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);\n      printer->Print(\n        \"case $number$:\\n\"\n        \"  return internalGet$capitalized_name$();\\n\",\n        \"number\", SimpleItoa(field->number()),\n        \"capitalized_name\", info->capitalized_name);\n    }\n    printer->Print(\n        \"default:\\n\"\n        \"  throw new RuntimeException(\\n\"\n        \"      \\\"Invalid map field number: \\\" + number);\\n\");\n    printer->Outdent();\n    printer->Outdent();\n    printer->Print(\n        \"  }\\n\"\n        \"}\\n\");\n  }\n  printer->Print(\n    \"protected com.google.protobuf.GeneratedMessage$ver$.FieldAccessorTable\\n\"\n    \"    internalGetFieldAccessorTable() {\\n\"\n    \"  return $fileclass$.internal_$identifier$_fieldAccessorTable\\n\"\n    \"      .ensureFieldAccessorsInitialized(\\n\"\n    \"          $classname$.class, $classname$.Builder.class);\\n\"\n    \"}\\n\"\n    \"\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_),\n    \"fileclass\", name_resolver_->GetImmutableClassName(descriptor_->file()),\n    \"identifier\", UniqueFileScopeIdentifier(descriptor_),\n    \"ver\", GeneratedCodeVersionSuffix());\n}\n\n// ===================================================================\n\nvoid ImmutableMessageGenerator::GenerateIsInitialized(\n    io::Printer* printer) {\n  // Memoizes whether the protocol buffer is fully initialized (has all\n  // required fields). -1 means not yet computed. 0 means false and 1 means\n  // true.\n  printer->Print(\n    \"private byte memoizedIsInitialized = -1;\\n\");\n  printer->Print(\n    \"public final boolean isInitialized() {\\n\");\n  printer->Indent();\n\n  // Don't directly compare to -1 to avoid an Android x86 JIT bug.\n  printer->Print(\n    \"byte isInitialized = memoizedIsInitialized;\\n\"\n    \"if (isInitialized == 1) return true;\\n\"\n    \"if (isInitialized == 0) return false;\\n\"\n    \"\\n\");\n\n  // Check that all required fields in this message are set.\n  // TODO(kenton):  We can optimize this when we switch to putting all the\n  //   \"has\" fields into a single bitfield.\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n    const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);\n\n    if (field->is_required()) {\n      printer->Print(\n        \"if (!has$name$()) {\\n\"\n        \"  memoizedIsInitialized = 0;\\n\"\n        \"  return false;\\n\"\n        \"}\\n\",\n        \"name\", info->capitalized_name);\n    }\n  }\n\n  // Now check that all embedded messages are initialized.\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n    const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);\n    if (GetJavaType(field) == JAVATYPE_MESSAGE &&\n        HasRequiredFields(field->message_type())) {\n      switch (field->label()) {\n        case FieldDescriptor::LABEL_REQUIRED:\n          printer->Print(\n            \"if (!get$name$().isInitialized()) {\\n\"\n             \"  memoizedIsInitialized = 0;\\n\"\n             \"  return false;\\n\"\n             \"}\\n\",\n            \"type\", name_resolver_->GetImmutableClassName(\n                field->message_type()),\n            \"name\", info->capitalized_name);\n          break;\n        case FieldDescriptor::LABEL_OPTIONAL:\n          if (!SupportFieldPresence(descriptor_->file()) &&\n              field->containing_oneof() != NULL) {\n            const OneofDescriptor* oneof = field->containing_oneof();\n            const OneofGeneratorInfo* oneof_info =\n                context_->GetOneofGeneratorInfo(oneof);\n            printer->Print(\n              \"if ($oneof_name$Case_ == $field_number$) {\\n\",\n              \"oneof_name\", oneof_info->name,\n              \"field_number\", SimpleItoa(field->number()));\n          } else {\n            printer->Print(\n              \"if (has$name$()) {\\n\",\n              \"name\", info->capitalized_name);\n          }\n          printer->Print(\n            \"  if (!get$name$().isInitialized()) {\\n\"\n            \"    memoizedIsInitialized = 0;\\n\"\n            \"    return false;\\n\"\n            \"  }\\n\"\n            \"}\\n\",\n            \"name\", info->capitalized_name);\n          break;\n        case FieldDescriptor::LABEL_REPEATED:\n          if (IsMapEntry(field->message_type())) {\n            printer->Print(\n              \"for ($type$ item : get$name$().values()) {\\n\"\n              \"  if (!item.isInitialized()) {\\n\"\n              \"    memoizedIsInitialized = 0;\\n\"\n              \"    return false;\\n\"\n              \"  }\\n\"\n              \"}\\n\",\n              \"type\", MapValueImmutableClassdName(field->message_type(),\n                                                  name_resolver_),\n              \"name\", info->capitalized_name);\n          } else {\n            printer->Print(\n              \"for (int i = 0; i < get$name$Count(); i++) {\\n\"\n              \"  if (!get$name$(i).isInitialized()) {\\n\"\n              \"    memoizedIsInitialized = 0;\\n\"\n              \"    return false;\\n\"\n              \"  }\\n\"\n              \"}\\n\",\n              \"type\", name_resolver_->GetImmutableClassName(\n                  field->message_type()),\n              \"name\", info->capitalized_name);\n          }\n          break;\n      }\n    }\n  }\n\n  if (descriptor_->extension_range_count() > 0) {\n    printer->Print(\n      \"if (!extensionsAreInitialized()) {\\n\"\n      \"  memoizedIsInitialized = 0;\\n\"\n      \"  return false;\\n\"\n      \"}\\n\");\n  }\n\n  printer->Outdent();\n\n  printer->Print(\n    \"  memoizedIsInitialized = 1;\\n\");\n\n  printer->Print(\n    \"  return true;\\n\"\n    \"}\\n\"\n    \"\\n\");\n}\n\n// ===================================================================\n\nnamespace {\nbool CheckHasBitsForEqualsAndHashCode(const FieldDescriptor* field) {\n  if (field->is_repeated()) {\n    return false;\n  }\n  if (SupportFieldPresence(field->file())) {\n    return true;\n  }\n  return GetJavaType(field) == JAVATYPE_MESSAGE &&\n      field->containing_oneof() == NULL;\n}\n}  // namespace\n\nvoid ImmutableMessageGenerator::\nGenerateEqualsAndHashCode(io::Printer* printer) {\n  printer->Print(\n    \"@java.lang.Override\\n\"\n    \"public boolean equals(final java.lang.Object obj) {\\n\");\n  printer->Indent();\n  printer->Print(\n    \"if (obj == this) {\\n\"\n    \" return true;\\n\"\n    \"}\\n\"\n    \"if (!(obj instanceof $classname$)) {\\n\"\n    \"  return super.equals(obj);\\n\"\n    \"}\\n\"\n    \"$classname$ other = ($classname$) obj;\\n\"\n    \"\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n\n  printer->Print(\"boolean result = true;\\n\");\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n    if (field->containing_oneof() == NULL) {\n      const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);\n      bool check_has_bits = CheckHasBitsForEqualsAndHashCode(field);\n      if (check_has_bits) {\n        printer->Print(\n          \"result = result && (has$name$() == other.has$name$());\\n\"\n          \"if (has$name$()) {\\n\",\n          \"name\", info->capitalized_name);\n        printer->Indent();\n      }\n      field_generators_.get(field).GenerateEqualsCode(printer);\n      if (check_has_bits) {\n        printer->Outdent();\n        printer->Print(\n          \"}\\n\");\n      }\n    }\n  }\n\n  // Compare oneofs.\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    printer->Print(\n      \"result = result && get$oneof_capitalized_name$Case().equals(\\n\"\n      \"    other.get$oneof_capitalized_name$Case());\\n\",\n      \"oneof_capitalized_name\",\n      context_->GetOneofGeneratorInfo(\n          descriptor_->oneof_decl(i))->capitalized_name);\n    printer->Print(\n      \"if (!result) return false;\\n\"\n      \"switch ($oneof_name$Case_) {\\n\",\n      \"oneof_name\",\n      context_->GetOneofGeneratorInfo(\n          descriptor_->oneof_decl(i))->name);\n    printer->Indent();\n    for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {\n      const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);\n      printer->Print(\n        \"case $field_number$:\\n\",\n        \"field_number\",\n        SimpleItoa(field->number()));\n      printer->Indent();\n      field_generators_.get(field).GenerateEqualsCode(printer);\n      printer->Print(\"break;\\n\");\n      printer->Outdent();\n    }\n    printer->Print(\n      \"case 0:\\n\"\n      \"default:\\n\");\n    printer->Outdent();\n    printer->Print(\"}\\n\");\n  }\n\n  if (PreserveUnknownFields(descriptor_)) {\n    // Always consider unknown fields for equality. This will sometimes return\n    // false for non-canonical ordering when running in LITE_RUNTIME but it's\n    // the best we can do.\n    printer->Print(\n      \"result = result && unknownFields.equals(other.unknownFields);\\n\");\n  }\n  if (descriptor_->extension_range_count() > 0) {\n    printer->Print(\n      \"result = result &&\\n\"\n      \"    getExtensionFields().equals(other.getExtensionFields());\\n\");\n  }\n  printer->Print(\n    \"return result;\\n\");\n  printer->Outdent();\n  printer->Print(\n    \"}\\n\"\n    \"\\n\");\n\n  printer->Print(\n    \"@java.lang.Override\\n\"\n    \"public int hashCode() {\\n\");\n  printer->Indent();\n  printer->Print(\n    \"if (memoizedHashCode != 0) {\\n\");\n  printer->Indent();\n  printer->Print(\n    \"return memoizedHashCode;\\n\");\n  printer->Outdent();\n  printer->Print(\n    \"}\\n\"\n    \"int hash = 41;\\n\");\n\n  printer->Print(\"hash = (19 * hash) + getDescriptorForType().hashCode();\\n\");\n\n  // hashCode non-oneofs.\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n    if (field->containing_oneof() == NULL) {\n      const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);\n      bool check_has_bits = CheckHasBitsForEqualsAndHashCode(field);\n      if (check_has_bits) {\n        printer->Print(\n          \"if (has$name$()) {\\n\",\n          \"name\", info->capitalized_name);\n        printer->Indent();\n      }\n      field_generators_.get(field).GenerateHashCode(printer);\n      if (check_has_bits) {\n        printer->Outdent();\n        printer->Print(\"}\\n\");\n      }\n    }\n  }\n\n  // hashCode oneofs.\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    printer->Print(\n      \"switch ($oneof_name$Case_) {\\n\",\n      \"oneof_name\",\n      context_->GetOneofGeneratorInfo(\n          descriptor_->oneof_decl(i))->name);\n    printer->Indent();\n    for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {\n      const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);\n      printer->Print(\n        \"case $field_number$:\\n\",\n        \"field_number\",\n        SimpleItoa(field->number()));\n      printer->Indent();\n      field_generators_.get(field).GenerateHashCode(printer);\n      printer->Print(\"break;\\n\");\n      printer->Outdent();\n    }\n    printer->Print(\n      \"case 0:\\n\"\n      \"default:\\n\");\n    printer->Outdent();\n    printer->Print(\"}\\n\");\n  }\n\n  if (descriptor_->extension_range_count() > 0) {\n    printer->Print(\n      \"hash = hashFields(hash, getExtensionFields());\\n\");\n  }\n\n  printer->Print(\n    \"hash = (29 * hash) + unknownFields.hashCode();\\n\");\n  printer->Print(\n    \"memoizedHashCode = hash;\\n\"\n    \"return hash;\\n\");\n  printer->Outdent();\n  printer->Print(\n    \"}\\n\"\n    \"\\n\");\n}\n\n// ===================================================================\n\nvoid ImmutableMessageGenerator::\nGenerateExtensionRegistrationCode(io::Printer* printer) {\n  for (int i = 0; i < descriptor_->extension_count(); i++) {\n    ImmutableExtensionGenerator(descriptor_->extension(i), context_)\n      .GenerateRegistrationCode(printer);\n  }\n\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    ImmutableMessageGenerator(descriptor_->nested_type(i), context_)\n      .GenerateExtensionRegistrationCode(printer);\n  }\n}\n\n// ===================================================================\nvoid ImmutableMessageGenerator::\nGenerateParsingConstructor(io::Printer* printer) {\n  google::protobuf::scoped_array<const FieldDescriptor * > sorted_fields(\n      SortFieldsByNumber(descriptor_));\n\n  printer->Print(\n      \"private $classname$(\\n\"\n      \"    com.google.protobuf.CodedInputStream input,\\n\"\n      \"    com.google.protobuf.ExtensionRegistryLite extensionRegistry)\\n\"\n      \"    throws com.google.protobuf.InvalidProtocolBufferException {\\n\",\n      \"classname\", descriptor_->name());\n  printer->Indent();\n\n  // Initialize all fields to default.\n  printer->Print(\n      \"this();\\n\");\n\n  // Use builder bits to track mutable repeated fields.\n  int totalBuilderBits = 0;\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const ImmutableFieldGenerator& field =\n        field_generators_.get(descriptor_->field(i));\n    totalBuilderBits += field.GetNumBitsForBuilder();\n  }\n  int totalBuilderInts = (totalBuilderBits + 31) / 32;\n  for (int i = 0; i < totalBuilderInts; i++) {\n    printer->Print(\"int mutable_$bit_field_name$ = 0;\\n\",\n      \"bit_field_name\", GetBitFieldName(i));\n  }\n\n  if (PreserveUnknownFields(descriptor_)) {\n    printer->Print(\n      \"com.google.protobuf.UnknownFieldSet.Builder unknownFields =\\n\"\n      \"    com.google.protobuf.UnknownFieldSet.newBuilder();\\n\");\n  }\n\n  printer->Print(\n      \"try {\\n\");\n  printer->Indent();\n\n  printer->Print(\n    \"boolean done = false;\\n\"\n    \"while (!done) {\\n\");\n  printer->Indent();\n\n  printer->Print(\n    \"int tag = input.readTag();\\n\"\n    \"switch (tag) {\\n\");\n  printer->Indent();\n\n  printer->Print(\n    \"case 0:\\n\"          // zero signals EOF / limit reached\n    \"  done = true;\\n\"\n    \"  break;\\n\");\n\n  if (PreserveUnknownFields(descriptor_)) {\n    printer->Print(\n      \"default: {\\n\"\n      \"  if (!parseUnknownField(input, unknownFields,\\n\"\n      \"                         extensionRegistry, tag)) {\\n\"\n      \"    done = true;\\n\"  // it's an endgroup tag\n      \"  }\\n\"\n      \"  break;\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(\n      \"default: {\\n\"\n      \"  if (!input.skipField(tag)) {\\n\"\n      \"    done = true;\\n\"  // it's an endgroup tag\n      \"  }\\n\"\n      \"  break;\\n\"\n      \"}\\n\");\n  }\n\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = sorted_fields[i];\n    uint32 tag = WireFormatLite::MakeTag(field->number(),\n      WireFormat::WireTypeForFieldType(field->type()));\n\n    printer->Print(\n      \"case $tag$: {\\n\",\n      \"tag\", SimpleItoa(tag));\n    printer->Indent();\n\n    field_generators_.get(field).GenerateParsingCode(printer);\n\n    printer->Outdent();\n    printer->Print(\n      \"  break;\\n\"\n      \"}\\n\");\n\n    if (field->is_packable()) {\n      // To make packed = true wire compatible, we generate parsing code from a\n      // packed version of this field regardless of field->options().packed().\n      uint32 packed_tag = WireFormatLite::MakeTag(field->number(),\n        WireFormatLite::WIRETYPE_LENGTH_DELIMITED);\n      printer->Print(\n        \"case $tag$: {\\n\",\n        \"tag\", SimpleItoa(packed_tag));\n      printer->Indent();\n\n      field_generators_.get(field).GenerateParsingCodeFromPacked(printer);\n\n      printer->Outdent();\n      printer->Print(\n        \"  break;\\n\"\n        \"}\\n\");\n    }\n  }\n\n  printer->Outdent();\n  printer->Outdent();\n  printer->Print(\n      \"  }\\n\"     // switch (tag)\n      \"}\\n\");     // while (!done)\n\n  printer->Outdent();\n  printer->Print(\n      \"} catch (com.google.protobuf.InvalidProtocolBufferException e) {\\n\"\n      \"  throw e.setUnfinishedMessage(this);\\n\"\n      \"} catch (java.io.IOException e) {\\n\"\n      \"  throw new com.google.protobuf.InvalidProtocolBufferException(\\n\"\n      \"      e).setUnfinishedMessage(this);\\n\"\n      \"} finally {\\n\");\n  printer->Indent();\n\n  // Make repeated field list immutable.\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = sorted_fields[i];\n    field_generators_.get(field).GenerateParsingDoneCode(printer);\n  }\n\n  if (PreserveUnknownFields(descriptor_)) {\n    // Make unknown fields immutable.\n    printer->Print(\"this.unknownFields = unknownFields.build();\\n\");\n  }\n\n  // Make extensions immutable.\n  printer->Print(\n      \"makeExtensionsImmutable();\\n\");\n\n  printer->Outdent();\n  printer->Outdent();\n  printer->Print(\n      \"  }\\n\"     // finally\n      \"}\\n\");\n}\n\n// ===================================================================\nvoid ImmutableMessageGenerator::GenerateParser(io::Printer* printer) {\n  printer->Print(\n      \"$visibility$ static final com.google.protobuf.Parser<$classname$>\\n\"\n      \"    PARSER = new com.google.protobuf.AbstractParser<$classname$>() {\\n\",\n      \"visibility\",\n      ExposePublicParser(descriptor_->file()) ? \"@java.lang.Deprecated public\"\n                                              : \"private\",\n      \"classname\", descriptor_->name());\n  printer->Indent();\n  printer->Print(\n      \"public $classname$ parsePartialFrom(\\n\"\n      \"    com.google.protobuf.CodedInputStream input,\\n\"\n      \"    com.google.protobuf.ExtensionRegistryLite extensionRegistry)\\n\"\n      \"    throws com.google.protobuf.InvalidProtocolBufferException {\\n\",\n      \"classname\", descriptor_->name());\n  if (context_->HasGeneratedMethods(descriptor_)) {\n    printer->Print(\n        \"    return new $classname$(input, extensionRegistry);\\n\",\n        \"classname\", descriptor_->name());\n  } else {\n    // When parsing constructor isn't generated, use builder to parse\n    // messages. Note, will fallback to use reflection based mergeFieldFrom()\n    // in AbstractMessage.Builder.\n    printer->Indent();\n    printer->Print(\n        \"Builder builder = newBuilder();\\n\"\n        \"try {\\n\"\n        \"  builder.mergeFrom(input, extensionRegistry);\\n\"\n        \"} catch (com.google.protobuf.InvalidProtocolBufferException e) {\\n\"\n        \"  throw e.setUnfinishedMessage(builder.buildPartial());\\n\"\n        \"} catch (java.io.IOException e) {\\n\"\n        \"  throw new com.google.protobuf.InvalidProtocolBufferException(\\n\"\n        \"      e.getMessage()).setUnfinishedMessage(\\n\"\n        \"          builder.buildPartial());\\n\"\n        \"}\\n\"\n        \"return builder.buildPartial();\\n\");\n    printer->Outdent();\n  }\n  printer->Print(\n        \"}\\n\");\n  printer->Outdent();\n  printer->Print(\n      \"};\\n\"\n      \"\\n\");\n\n  printer->Print(\n      \"public static com.google.protobuf.Parser<$classname$> parser() {\\n\"\n      \"  return PARSER;\\n\"\n      \"}\\n\"\n      \"\\n\"\n      \"@java.lang.Override\\n\"\n      \"public com.google.protobuf.Parser<$classname$> getParserForType() {\\n\"\n      \"  return PARSER;\\n\"\n      \"}\\n\"\n      \"\\n\",\n      \"classname\", descriptor_->name());\n}\n\n// ===================================================================\nvoid ImmutableMessageGenerator::GenerateInitializers(io::Printer* printer) {\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    if (!descriptor_->field(i)->containing_oneof()) {\n      field_generators_.get(descriptor_->field(i))\n          .GenerateInitializationCode(printer);\n    }\n  }\n}\n\n\nvoid ImmutableMessageGenerator::GenerateAnyMethods(io::Printer* printer) {\n  printer->Print(\n    \"private static String getTypeUrl(\\n\"\n    \"    java.lang.String typeUrlPrefix,\\n\"\n    \"    com.google.protobuf.Descriptors.Descriptor descriptor) {\\n\"\n    \"  return typeUrlPrefix.endsWith(\\\"/\\\")\\n\"\n    \"      ? typeUrlPrefix + descriptor.getFullName()\\n\"\n    \"      : typeUrlPrefix + \\\"/\\\" + descriptor.getFullName();\\n\"\n    \"}\\n\"\n    \"\\n\"\n    \"private static String getTypeNameFromTypeUrl(\\n\"\n    \"    java.lang.String typeUrl) {\\n\"\n    \"  int pos = typeUrl.lastIndexOf('/');\\n\"\n    \"  return pos == -1 ? \\\"\\\" : typeUrl.substring(pos + 1);\\n\"\n    \"}\\n\"\n    \"\\n\"\n    \"public static <T extends com.google.protobuf.Message> Any pack(\\n\"\n    \"    T message) {\\n\"\n    \"  return Any.newBuilder()\\n\"\n    \"      .setTypeUrl(getTypeUrl(\\\"type.googleapis.com\\\",\\n\"\n    \"                             message.getDescriptorForType()))\\n\"\n    \"      .setValue(message.toByteString())\\n\"\n    \"      .build();\\n\"\n    \"}\\n\"\n    \"\\n\"\n    \"/**\\n\"\n    \" * Packs a message uisng the given type URL prefix. The type URL will\\n\"\n    \" * be constructed by concatenating the message type's full name to the\\n\"\n    \" * prefix with an optional \\\"/\\\" separator if the prefix doesn't end\\n\"\n    \" * with \\\"/\\\" already.\\n\"\n    \" */\\n\"\n    \"public static <T extends com.google.protobuf.Message> Any pack(\\n\"\n    \"    T message, java.lang.String typeUrlPrefix) {\\n\"\n    \"  return Any.newBuilder()\\n\"\n    \"      .setTypeUrl(getTypeUrl(typeUrlPrefix,\\n\"\n    \"                             message.getDescriptorForType()))\\n\"\n    \"      .setValue(message.toByteString())\\n\"\n    \"      .build();\\n\"\n    \"}\\n\"\n    \"\\n\"\n    \"public <T extends com.google.protobuf.Message> boolean is(\\n\"\n    \"    java.lang.Class<T> clazz) {\\n\"\n    \"  T defaultInstance =\\n\"\n    \"      com.google.protobuf.Internal.getDefaultInstance(clazz);\\n\"\n    \"  return getTypeNameFromTypeUrl(getTypeUrl()).equals(\\n\"\n    \"      defaultInstance.getDescriptorForType().getFullName());\\n\"\n    \"}\\n\"\n    \"\\n\"\n    \"private volatile com.google.protobuf.Message cachedUnpackValue;\\n\"\n    \"\\n\"\n    \"public <T extends com.google.protobuf.Message> T unpack(\\n\"\n    \"    java.lang.Class<T> clazz)\\n\"\n    \"    throws com.google.protobuf.InvalidProtocolBufferException {\\n\"\n    \"  if (!is(clazz)) {\\n\"\n    \"    throw new com.google.protobuf.InvalidProtocolBufferException(\\n\"\n    \"        \\\"Type of the Any message does not match the given class.\\\");\\n\"\n    \"  }\\n\"\n    \"  if (cachedUnpackValue != null) {\\n\"\n    \"    return (T) cachedUnpackValue;\\n\"\n    \"  }\\n\"\n    \"  T defaultInstance =\\n\"\n    \"      com.google.protobuf.Internal.getDefaultInstance(clazz);\\n\"\n    \"  T result = (T) defaultInstance.getParserForType()\\n\"\n    \"      .parseFrom(getValue());\\n\"\n    \"  cachedUnpackValue = result;\\n\"\n    \"  return result;\\n\"\n    \"}\\n\");\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_message.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__\n\n#include <string>\n#include <map>\n#include <google/protobuf/compiler/java/java_field.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace compiler {\n    namespace java {\n      class Context;           // context.h\n      class ClassNameResolver; // name_resolver.h\n    }\n  }\n  namespace io {\n    class Printer;             // printer.h\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nstatic const int kMaxStaticSize = 1 << 15;  // aka 32k\n\nclass MessageGenerator {\n public:\n  explicit MessageGenerator(const Descriptor* descriptor);\n  virtual ~MessageGenerator();\n\n  // All static variables have to be declared at the top-level of the file\n  // so that we can control initialization order, which is important for\n  // DescriptorProto bootstrapping to work.\n  virtual void GenerateStaticVariables(\n      io::Printer* printer, int* bytecode_estimate) = 0;\n\n  // Output code which initializes the static variables generated by\n  // GenerateStaticVariables(). Returns an estimate of bytecode size.\n  virtual int GenerateStaticVariableInitializers(io::Printer* printer) = 0;\n\n  // Generate the class itself.\n  virtual void Generate(io::Printer* printer) = 0;\n\n  // Generates the base interface that both the class and its builder implement\n  virtual void GenerateInterface(io::Printer* printer) = 0;\n\n  // Generate code to register all contained extensions with an\n  // ExtensionRegistry.\n  virtual void GenerateExtensionRegistrationCode(io::Printer* printer) = 0;\n\n protected:\n  const Descriptor* descriptor_;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);\n};\n\nclass ImmutableMessageGenerator : public MessageGenerator {\n public:\n  ImmutableMessageGenerator(const Descriptor* descriptor, Context* context);\n  virtual ~ImmutableMessageGenerator();\n\n  virtual void Generate(io::Printer* printer);\n  virtual void GenerateInterface(io::Printer* printer);\n  virtual void GenerateExtensionRegistrationCode(io::Printer* printer);\n  virtual void GenerateStaticVariables(\n      io::Printer* printer, int* bytecode_estimate);\n\n  // Returns an estimate of the number of bytes the printed code will compile to\n  virtual int GenerateStaticVariableInitializers(io::Printer* printer);\n\n private:\n\n  void GenerateFieldAccessorTable(io::Printer* printer, int* bytecode_estimate);\n\n  // Returns an estimate of the number of bytes the printed code will compile to\n  int GenerateFieldAccessorTableInitializer(io::Printer* printer);\n\n  void GenerateMessageSerializationMethods(io::Printer* printer);\n  void GenerateParseFromMethods(io::Printer* printer);\n  void GenerateSerializeOneField(io::Printer* printer,\n                                 const FieldDescriptor* field);\n  void GenerateSerializeOneExtensionRange(\n      io::Printer* printer, const Descriptor::ExtensionRange* range);\n\n  void GenerateBuilder(io::Printer* printer);\n  void GenerateIsInitialized(io::Printer* printer);\n  void GenerateDescriptorMethods(io::Printer* printer);\n  void GenerateInitializers(io::Printer* printer);\n  void GenerateEqualsAndHashCode(io::Printer* printer);\n  void GenerateParser(io::Printer* printer);\n  void GenerateParsingConstructor(io::Printer* printer);\n  void GenerateAnyMethods(io::Printer* printer);\n\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n  FieldGeneratorMap<ImmutableFieldGenerator> field_generators_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageGenerator);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_message_builder.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: dweis@google.com (Daniel Weis)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/java/java_message_builder.h>\n\n#include <algorithm>\n#include <google/protobuf/stubs/hash.h>\n#include <map>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <vector>\n\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n#include <google/protobuf/compiler/java/java_enum.h>\n#include <google/protobuf/compiler/java/java_extension.h>\n#include <google/protobuf/compiler/java/java_generator_factory.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nnamespace {\nbool GenerateHasBits(const Descriptor* descriptor) {\n  return SupportFieldPresence(descriptor->file()) ||\n      HasRepeatedFields(descriptor);\n}\n\nstring MapValueImmutableClassdName(const Descriptor* descriptor,\n                                   ClassNameResolver* name_resolver) {\n  const FieldDescriptor* value_field = descriptor->FindFieldByName(\"value\");\n  GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, value_field->type());\n  return name_resolver->GetImmutableClassName(value_field->message_type());\n}\n}  // namespace\n\nMessageBuilderGenerator::MessageBuilderGenerator(\n    const Descriptor* descriptor, Context* context)\n  : descriptor_(descriptor), context_(context),\n    name_resolver_(context->GetNameResolver()),\n    field_generators_(descriptor, context_) {\n  GOOGLE_CHECK(HasDescriptorMethods(descriptor->file(), context->EnforceLite()))\n      << \"Generator factory error: A non-lite message generator is used to \"\n         \"generate lite messages.\";\n}\n\nMessageBuilderGenerator::~MessageBuilderGenerator() {}\n\nvoid MessageBuilderGenerator::\nGenerate(io::Printer* printer) {\n  WriteMessageDocComment(printer, descriptor_);\n  if (descriptor_->extension_range_count() > 0) {\n    printer->Print(\n      \"public static final class Builder extends\\n\"\n      \"    com.google.protobuf.GeneratedMessage$ver$.ExtendableBuilder<\\n\"\n      \"      $classname$, Builder> implements\\n\"\n      \"    $extra_interfaces$\\n\"\n      \"    $classname$OrBuilder {\\n\",\n      \"classname\", name_resolver_->GetImmutableClassName(descriptor_),\n      \"extra_interfaces\", ExtraBuilderInterfaces(descriptor_),\n      \"ver\", GeneratedCodeVersionSuffix());\n  } else {\n    printer->Print(\n      \"public static final class Builder extends\\n\"\n      \"    com.google.protobuf.GeneratedMessage$ver$.Builder<Builder> implements\\n\"\n      \"    $extra_interfaces$\\n\"\n      \"    $classname$OrBuilder {\\n\",\n      \"classname\", name_resolver_->GetImmutableClassName(descriptor_),\n      \"extra_interfaces\", ExtraBuilderInterfaces(descriptor_),\n      \"ver\", GeneratedCodeVersionSuffix());\n  }\n  printer->Indent();\n\n  GenerateDescriptorMethods(printer);\n  GenerateCommonBuilderMethods(printer);\n\n  if (context_->HasGeneratedMethods(descriptor_)) {\n    GenerateIsInitialized(printer);\n    GenerateBuilderParsingMethods(printer);\n  }\n\n  // oneof\n  map<string, string> vars;\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    vars[\"oneof_name\"] = context_->GetOneofGeneratorInfo(\n        descriptor_->oneof_decl(i))->name;\n    vars[\"oneof_capitalized_name\"] = context_->GetOneofGeneratorInfo(\n        descriptor_->oneof_decl(i))->capitalized_name;\n    vars[\"oneof_index\"] = SimpleItoa(descriptor_->oneof_decl(i)->index());\n    // oneofCase_ and oneof_\n    printer->Print(vars,\n      \"private int $oneof_name$Case_ = 0;\\n\"\n      \"private java.lang.Object $oneof_name$_;\\n\");\n    // oneofCase() and clearOneof()\n    printer->Print(vars,\n      \"public $oneof_capitalized_name$Case\\n\"\n      \"    get$oneof_capitalized_name$Case() {\\n\"\n      \"  return $oneof_capitalized_name$Case.forNumber(\\n\"\n      \"      $oneof_name$Case_);\\n\"\n      \"}\\n\"\n      \"\\n\"\n      \"public Builder clear$oneof_capitalized_name$() {\\n\"\n      \"  $oneof_name$Case_ = 0;\\n\"\n      \"  $oneof_name$_ = null;\\n\");\n    printer->Print(\"  onChanged();\\n\");\n    printer->Print(\n      \"  return this;\\n\"\n      \"}\\n\"\n      \"\\n\");\n  }\n\n  if (GenerateHasBits(descriptor_)) {\n    // Integers for bit fields.\n    int totalBits = 0;\n    for (int i = 0; i < descriptor_->field_count(); i++) {\n      totalBits += field_generators_.get(descriptor_->field(i))\n          .GetNumBitsForBuilder();\n    }\n    int totalInts = (totalBits + 31) / 32;\n    for (int i = 0; i < totalInts; i++) {\n      printer->Print(\"private int $bit_field_name$;\\n\",\n        \"bit_field_name\", GetBitFieldName(i));\n    }\n  }\n\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    printer->Print(\"\\n\");\n    field_generators_.get(descriptor_->field(i))\n                     .GenerateBuilderMembers(printer);\n  }\n\n  if (!PreserveUnknownFields(descriptor_)) {\n    printer->Print(\n      \"public final Builder setUnknownFields(\\n\"\n      \"    final com.google.protobuf.UnknownFieldSet unknownFields) {\\n\"\n      \"  return this;\\n\"\n      \"}\\n\"\n      \"\\n\"\n      \"public final Builder mergeUnknownFields(\\n\"\n      \"    final com.google.protobuf.UnknownFieldSet unknownFields) {\\n\"\n      \"  return this;\\n\"\n      \"}\\n\"\n      \"\\n\");\n  } else {\n    printer->Print(\n      \"public final Builder setUnknownFields(\\n\"\n      \"    final com.google.protobuf.UnknownFieldSet unknownFields) {\\n\"\n      \"  return super.setUnknownFields(unknownFields);\\n\"\n      \"}\\n\"\n      \"\\n\"\n      \"public final Builder mergeUnknownFields(\\n\"\n      \"    final com.google.protobuf.UnknownFieldSet unknownFields) {\\n\"\n      \"  return super.mergeUnknownFields(unknownFields);\\n\"\n      \"}\\n\"\n      \"\\n\");\n  }\n\n  printer->Print(\n    \"\\n\"\n    \"// @@protoc_insertion_point(builder_scope:$full_name$)\\n\",\n    \"full_name\", descriptor_->full_name());\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\n// ===================================================================\n\nvoid MessageBuilderGenerator::\nGenerateDescriptorMethods(io::Printer* printer) {\n  if (!descriptor_->options().no_standard_descriptor_accessor()) {\n    printer->Print(\n      \"public static final com.google.protobuf.Descriptors.Descriptor\\n\"\n      \"    getDescriptor() {\\n\"\n      \"  return $fileclass$.internal_$identifier$_descriptor;\\n\"\n      \"}\\n\"\n      \"\\n\",\n      \"fileclass\", name_resolver_->GetImmutableClassName(descriptor_->file()),\n      \"identifier\", UniqueFileScopeIdentifier(descriptor_));\n  }\n  vector<const FieldDescriptor*> map_fields;\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n    if (GetJavaType(field) == JAVATYPE_MESSAGE &&\n        IsMapEntry(field->message_type())) {\n      map_fields.push_back(field);\n    }\n  }\n  if (!map_fields.empty()) {\n    printer->Print(\n      \"@SuppressWarnings({\\\"rawtypes\\\"})\\n\"\n      \"protected com.google.protobuf.MapField internalGetMapField(\\n\"\n      \"    int number) {\\n\"\n      \"  switch (number) {\\n\");\n    printer->Indent();\n    printer->Indent();\n    for (int i = 0; i < map_fields.size(); ++i) {\n      const FieldDescriptor* field = map_fields[i];\n      const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);\n      printer->Print(\n        \"case $number$:\\n\"\n        \"  return internalGet$capitalized_name$();\\n\",\n        \"number\", SimpleItoa(field->number()),\n        \"capitalized_name\", info->capitalized_name);\n    }\n    printer->Print(\n        \"default:\\n\"\n        \"  throw new RuntimeException(\\n\"\n        \"      \\\"Invalid map field number: \\\" + number);\\n\");\n    printer->Outdent();\n    printer->Outdent();\n    printer->Print(\n        \"  }\\n\"\n        \"}\\n\");\n    printer->Print(\n      \"@SuppressWarnings({\\\"rawtypes\\\"})\\n\"\n      \"protected com.google.protobuf.MapField internalGetMutableMapField(\\n\"\n      \"    int number) {\\n\"\n      \"  switch (number) {\\n\");\n    printer->Indent();\n    printer->Indent();\n    for (int i = 0; i < map_fields.size(); ++i) {\n      const FieldDescriptor* field = map_fields[i];\n      const FieldGeneratorInfo* info =\n          context_->GetFieldGeneratorInfo(field);\n      printer->Print(\n        \"case $number$:\\n\"\n        \"  return internalGetMutable$capitalized_name$();\\n\",\n        \"number\", SimpleItoa(field->number()),\n        \"capitalized_name\", info->capitalized_name);\n    }\n    printer->Print(\n        \"default:\\n\"\n        \"  throw new RuntimeException(\\n\"\n        \"      \\\"Invalid map field number: \\\" + number);\\n\");\n    printer->Outdent();\n    printer->Outdent();\n    printer->Print(\n        \"  }\\n\"\n        \"}\\n\");\n  }\n  printer->Print(\n    \"protected com.google.protobuf.GeneratedMessage$ver$.FieldAccessorTable\\n\"\n    \"    internalGetFieldAccessorTable() {\\n\"\n    \"  return $fileclass$.internal_$identifier$_fieldAccessorTable\\n\"\n    \"      .ensureFieldAccessorsInitialized(\\n\"\n    \"          $classname$.class, $classname$.Builder.class);\\n\"\n    \"}\\n\"\n    \"\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_),\n    \"fileclass\", name_resolver_->GetImmutableClassName(descriptor_->file()),\n    \"identifier\", UniqueFileScopeIdentifier(descriptor_),\n    \"ver\", GeneratedCodeVersionSuffix());\n}\n\n// ===================================================================\n\nvoid MessageBuilderGenerator::\nGenerateCommonBuilderMethods(io::Printer* printer) {\n  printer->Print(\n      \"// Construct using $classname$.newBuilder()\\n\"\n      \"private Builder() {\\n\"\n      \"  maybeForceBuilderInitialization();\\n\"\n      \"}\\n\"\n      \"\\n\",\n      \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n\n  printer->Print(\n    \"private Builder(\\n\"\n    \"    com.google.protobuf.GeneratedMessage$ver$.BuilderParent parent) {\\n\"\n    \"  super(parent);\\n\"\n    \"  maybeForceBuilderInitialization();\\n\"\n    \"}\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_),\n    \"ver\", GeneratedCodeVersionSuffix());\n\n  printer->Print(\n    \"private void maybeForceBuilderInitialization() {\\n\"\n    \"  if (com.google.protobuf.GeneratedMessage$ver$\\n\"\n    \"          .alwaysUseFieldBuilders) {\\n\",\n    \"ver\", GeneratedCodeVersionSuffix());\n\n  printer->Indent();\n  printer->Indent();\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    if (!descriptor_->field(i)->containing_oneof()) {\n      field_generators_.get(descriptor_->field(i))\n          .GenerateFieldBuilderInitializationCode(printer);\n    }\n  }\n  printer->Outdent();\n  printer->Outdent();\n\n  printer->Print(\n    \"  }\\n\"\n    \"}\\n\");\n\n  printer->Print(\n    \"public Builder clear() {\\n\"\n    \"  super.clear();\\n\");\n\n  printer->Indent();\n\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    if (!descriptor_->field(i)->containing_oneof()) {\n      field_generators_.get(descriptor_->field(i))\n          .GenerateBuilderClearCode(printer);\n    }\n  }\n\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    printer->Print(\n      \"$oneof_name$Case_ = 0;\\n\"\n      \"$oneof_name$_ = null;\\n\",\n      \"oneof_name\", context_->GetOneofGeneratorInfo(\n          descriptor_->oneof_decl(i))->name);\n  }\n\n  printer->Outdent();\n\n  printer->Print(\n    \"  return this;\\n\"\n    \"}\\n\"\n    \"\\n\");\n\n  printer->Print(\n    \"public com.google.protobuf.Descriptors.Descriptor\\n\"\n    \"    getDescriptorForType() {\\n\"\n    \"  return $fileclass$.internal_$identifier$_descriptor;\\n\"\n    \"}\\n\"\n    \"\\n\",\n    \"fileclass\", name_resolver_->GetImmutableClassName(descriptor_->file()),\n    \"identifier\", UniqueFileScopeIdentifier(descriptor_));\n\n  // LITE runtime implements this in GeneratedMessageLite.\n  printer->Print(\n    \"public $classname$ getDefaultInstanceForType() {\\n\"\n    \"  return $classname$.getDefaultInstance();\\n\"\n    \"}\\n\"\n    \"\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n\n  printer->Print(\n    \"public $classname$ build() {\\n\"\n    \"  $classname$ result = buildPartial();\\n\"\n    \"  if (!result.isInitialized()) {\\n\"\n    \"    throw newUninitializedMessageException(result);\\n\"\n    \"  }\\n\"\n    \"  return result;\\n\"\n    \"}\\n\"\n    \"\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n\n  printer->Print(\n    \"public $classname$ buildPartial() {\\n\"\n    \"  $classname$ result = new $classname$(this);\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n\n  printer->Indent();\n\n  int totalBuilderBits = 0;\n  int totalMessageBits = 0;\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const ImmutableFieldGenerator& field =\n        field_generators_.get(descriptor_->field(i));\n    totalBuilderBits += field.GetNumBitsForBuilder();\n    totalMessageBits += field.GetNumBitsForMessage();\n  }\n  int totalBuilderInts = (totalBuilderBits + 31) / 32;\n  int totalMessageInts = (totalMessageBits + 31) / 32;\n\n  if (GenerateHasBits(descriptor_)) {\n    // Local vars for from and to bit fields to avoid accessing the builder and\n    // message over and over for these fields. Seems to provide a slight\n    // perforamance improvement in micro benchmark and this is also what proto1\n    // code does.\n    for (int i = 0; i < totalBuilderInts; i++) {\n      printer->Print(\"int from_$bit_field_name$ = $bit_field_name$;\\n\",\n        \"bit_field_name\", GetBitFieldName(i));\n    }\n    for (int i = 0; i < totalMessageInts; i++) {\n      printer->Print(\"int to_$bit_field_name$ = 0;\\n\",\n        \"bit_field_name\", GetBitFieldName(i));\n    }\n  }\n\n  // Output generation code for each field.\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    field_generators_.get(descriptor_->field(i)).GenerateBuildingCode(printer);\n  }\n\n  if (GenerateHasBits(descriptor_)) {\n    // Copy the bit field results to the generated message\n    for (int i = 0; i < totalMessageInts; i++) {\n      printer->Print(\"result.$bit_field_name$ = to_$bit_field_name$;\\n\",\n        \"bit_field_name\", GetBitFieldName(i));\n    }\n  }\n\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    printer->Print(\"result.$oneof_name$Case_ = $oneof_name$Case_;\\n\",\n                   \"oneof_name\", context_->GetOneofGeneratorInfo(\n                       descriptor_->oneof_decl(i))->name);\n  }\n\n  printer->Outdent();\n\n  printer->Print(\n    \"  onBuilt();\\n\");\n\n  printer->Print(\n    \"  return result;\\n\"\n    \"}\\n\"\n    \"\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n\n  printer->Print(\n    \"public Builder clone() {\\n\"\n    \"  return (Builder) super.clone();\\n\"\n    \"}\\n\"\n    \"public Builder setField(\\n\"\n    \"    com.google.protobuf.Descriptors.FieldDescriptor field,\\n\"\n    \"    Object value) {\\n\"\n    \"  return (Builder) super.setField(field, value);\\n\"\n    \"}\\n\"\n    \"public Builder clearField(\\n\"\n    \"    com.google.protobuf.Descriptors.FieldDescriptor field) {\\n\"\n    \"  return (Builder) super.clearField(field);\\n\"\n    \"}\\n\"\n    \"public Builder clearOneof(\\n\"\n    \"    com.google.protobuf.Descriptors.OneofDescriptor oneof) {\\n\"\n    \"  return (Builder) super.clearOneof(oneof);\\n\"\n    \"}\\n\"\n    \"public Builder setRepeatedField(\\n\"\n    \"    com.google.protobuf.Descriptors.FieldDescriptor field,\\n\"\n    \"    int index, Object value) {\\n\"\n    \"  return (Builder) super.setRepeatedField(field, index, value);\\n\"\n    \"}\\n\"\n    \"public Builder addRepeatedField(\\n\"\n    \"    com.google.protobuf.Descriptors.FieldDescriptor field,\\n\"\n    \"    Object value) {\\n\"\n    \"  return (Builder) super.addRepeatedField(field, value);\\n\"\n    \"}\\n\");\n\n  if (descriptor_->extension_range_count() > 0) {\n    printer->Print(\n      \"public <Type> Builder setExtension(\\n\"\n      \"    com.google.protobuf.GeneratedMessage.GeneratedExtension<\\n\"\n      \"        $classname$, Type> extension,\\n\"\n      \"    Type value) {\\n\"\n      \"  return (Builder) super.setExtension(extension, value);\\n\"\n      \"}\\n\"\n      \"public <Type> Builder setExtension(\\n\"\n      \"    com.google.protobuf.GeneratedMessage.GeneratedExtension<\\n\"\n      \"        $classname$, java.util.List<Type>> extension,\\n\"\n      \"    int index, Type value) {\\n\"\n      \"  return (Builder) super.setExtension(extension, index, value);\\n\"\n      \"}\\n\"\n      \"public <Type> Builder addExtension(\\n\"\n      \"    com.google.protobuf.GeneratedMessage.GeneratedExtension<\\n\"\n      \"        $classname$, java.util.List<Type>> extension,\\n\"\n      \"    Type value) {\\n\"\n      \"  return (Builder) super.addExtension(extension, value);\\n\"\n      \"}\\n\"\n      \"public <Type> Builder clearExtension(\\n\"\n      \"    com.google.protobuf.GeneratedMessage.GeneratedExtension<\\n\"\n      \"        $classname$, ?> extension) {\\n\"\n      \"  return (Builder) super.clearExtension(extension);\\n\"\n      \"}\\n\",\n      \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n  }\n\n  // -----------------------------------------------------------------\n\n  if (context_->HasGeneratedMethods(descriptor_)) {\n    printer->Print(\n      \"public Builder mergeFrom(com.google.protobuf.Message other) {\\n\"\n      \"  if (other instanceof $classname$) {\\n\"\n      \"    return mergeFrom(($classname$)other);\\n\"\n      \"  } else {\\n\"\n      \"    super.mergeFrom(other);\\n\"\n      \"    return this;\\n\"\n      \"  }\\n\"\n      \"}\\n\"\n      \"\\n\",\n      \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n\n    printer->Print(\n      \"public Builder mergeFrom($classname$ other) {\\n\"\n      // Optimization:  If other is the default instance, we know none of its\n      //   fields are set so we can skip the merge.\n      \"  if (other == $classname$.getDefaultInstance()) return this;\\n\",\n      \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n    printer->Indent();\n\n    for (int i = 0; i < descriptor_->field_count(); i++) {\n      if (!descriptor_->field(i)->containing_oneof()) {\n        field_generators_.get(\n            descriptor_->field(i)).GenerateMergingCode(printer);\n      }\n    }\n\n    // Merge oneof fields.\n    for (int i = 0; i < descriptor_->oneof_decl_count(); ++i) {\n      printer->Print(\n        \"switch (other.get$oneof_capitalized_name$Case()) {\\n\",\n        \"oneof_capitalized_name\",\n        context_->GetOneofGeneratorInfo(\n            descriptor_->oneof_decl(i))->capitalized_name);\n      printer->Indent();\n      for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {\n        const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);\n        printer->Print(\n          \"case $field_name$: {\\n\",\n          \"field_name\",\n          ToUpper(field->name()));\n        printer->Indent();\n        field_generators_.get(field).GenerateMergingCode(printer);\n        printer->Print(\n            \"break;\\n\");\n        printer->Outdent();\n        printer->Print(\n            \"}\\n\");\n      }\n      printer->Print(\n        \"case $cap_oneof_name$_NOT_SET: {\\n\"\n        \"  break;\\n\"\n        \"}\\n\",\n        \"cap_oneof_name\",\n        ToUpper(context_->GetOneofGeneratorInfo(\n            descriptor_->oneof_decl(i))->name));\n      printer->Outdent();\n      printer->Print(\n          \"}\\n\");\n    }\n\n    printer->Outdent();\n\n    // if message type has extensions\n    if (descriptor_->extension_range_count() > 0) {\n      printer->Print(\n        \"  this.mergeExtensionFields(other);\\n\");\n    }\n\n    if (PreserveUnknownFields(descriptor_)) {\n      printer->Print(\n        \"  this.mergeUnknownFields(other.unknownFields);\\n\");\n    }\n\n    printer->Print(\n      \"  onChanged();\\n\");\n\n    printer->Print(\n      \"  return this;\\n\"\n      \"}\\n\"\n      \"\\n\");\n\n  }\n}\n\n// ===================================================================\n\nvoid MessageBuilderGenerator::\nGenerateBuilderParsingMethods(io::Printer* printer) {\n  printer->Print(\n    \"public Builder mergeFrom(\\n\"\n    \"    com.google.protobuf.CodedInputStream input,\\n\"\n    \"    com.google.protobuf.ExtensionRegistryLite extensionRegistry)\\n\"\n    \"    throws java.io.IOException {\\n\"\n    \"  $classname$ parsedMessage = null;\\n\"\n    \"  try {\\n\"\n    \"    parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);\\n\"\n    \"  } catch (com.google.protobuf.InvalidProtocolBufferException e) {\\n\"\n    \"    parsedMessage = ($classname$) e.getUnfinishedMessage();\\n\"\n    \"    throw e.unwrapIOException();\\n\"\n    \"  } finally {\\n\"\n    \"    if (parsedMessage != null) {\\n\"\n    \"      mergeFrom(parsedMessage);\\n\"\n    \"    }\\n\"\n    \"  }\\n\"\n    \"  return this;\\n\"\n    \"}\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n}\n\n// ===================================================================\n\nvoid MessageBuilderGenerator::GenerateIsInitialized(\n    io::Printer* printer) {\n  printer->Print(\n    \"public final boolean isInitialized() {\\n\");\n  printer->Indent();\n\n  // Check that all required fields in this message are set.\n  // TODO(kenton):  We can optimize this when we switch to putting all the\n  //   \"has\" fields into a single bitfield.\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n    const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);\n\n    if (field->is_required()) {\n      printer->Print(\n        \"if (!has$name$()) {\\n\"\n        \"  return false;\\n\"\n        \"}\\n\",\n        \"name\", info->capitalized_name);\n    }\n  }\n\n  // Now check that all embedded messages are initialized.\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n    const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);\n    if (GetJavaType(field) == JAVATYPE_MESSAGE &&\n        HasRequiredFields(field->message_type())) {\n      switch (field->label()) {\n        case FieldDescriptor::LABEL_REQUIRED:\n          printer->Print(\n            \"if (!get$name$().isInitialized()) {\\n\"\n             \"  return false;\\n\"\n             \"}\\n\",\n            \"type\", name_resolver_->GetImmutableClassName(\n                field->message_type()),\n            \"name\", info->capitalized_name);\n          break;\n        case FieldDescriptor::LABEL_OPTIONAL:\n          if (!SupportFieldPresence(descriptor_->file()) &&\n              field->containing_oneof() != NULL) {\n            const OneofDescriptor* oneof = field->containing_oneof();\n            const OneofGeneratorInfo* oneof_info =\n                context_->GetOneofGeneratorInfo(oneof);\n            printer->Print(\n              \"if ($oneof_name$Case_ == $field_number$) {\\n\",\n              \"oneof_name\", oneof_info->name,\n              \"field_number\", SimpleItoa(field->number()));\n          } else {\n            printer->Print(\n              \"if (has$name$()) {\\n\",\n              \"name\", info->capitalized_name);\n          }\n          printer->Print(\n            \"  if (!get$name$().isInitialized()) {\\n\"\n            \"    return false;\\n\"\n            \"  }\\n\"\n            \"}\\n\",\n            \"name\", info->capitalized_name);\n          break;\n        case FieldDescriptor::LABEL_REPEATED:\n          if (IsMapEntry(field->message_type())) {\n            printer->Print(\n              \"for ($type$ item : get$name$().values()) {\\n\"\n              \"  if (!item.isInitialized()) {\\n\"\n              \"    return false;\\n\"\n              \"  }\\n\"\n              \"}\\n\",\n              \"type\", MapValueImmutableClassdName(field->message_type(),\n                                                  name_resolver_),\n              \"name\", info->capitalized_name);\n          } else {\n            printer->Print(\n              \"for (int i = 0; i < get$name$Count(); i++) {\\n\"\n              \"  if (!get$name$(i).isInitialized()) {\\n\"\n              \"    return false;\\n\"\n              \"  }\\n\"\n              \"}\\n\",\n              \"type\", name_resolver_->GetImmutableClassName(\n                  field->message_type()),\n              \"name\", info->capitalized_name);\n          }\n          break;\n      }\n    }\n  }\n\n  if (descriptor_->extension_range_count() > 0) {\n    printer->Print(\n      \"if (!extensionsAreInitialized()) {\\n\"\n      \"  return false;\\n\"\n      \"}\\n\");\n  }\n\n  printer->Outdent();\n\n  printer->Print(\n    \"  return true;\\n\"\n    \"}\\n\"\n    \"\\n\");\n}\n\n// ===================================================================\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_message_builder.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: dweis@google.com (Daniel Weis)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_H__\n\n#include <string>\n#include <map>\n#include <google/protobuf/compiler/java/java_field.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace compiler {\n    namespace java {\n      class Context;           // context.h\n      class ClassNameResolver; // name_resolver.h\n    }\n  }\n  namespace io {\n    class Printer;             // printer.h\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nclass MessageBuilderGenerator {\n public:\n  explicit MessageBuilderGenerator(const Descriptor* descriptor,\n                                   Context* context);\n  virtual ~MessageBuilderGenerator();\n\n  virtual void Generate(io::Printer* printer);\n\n private:\n  void GenerateCommonBuilderMethods(io::Printer* printer);\n  void GenerateDescriptorMethods(io::Printer* printer);\n  void GenerateBuilderParsingMethods(io::Printer* printer);\n  void GenerateIsInitialized(io::Printer* printer);\n\n  const Descriptor* descriptor_;\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n  FieldGeneratorMap<ImmutableFieldGenerator> field_generators_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageBuilderGenerator);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_message_builder_lite.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: dweis@google.com (Daniel Weis)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/java/java_message_builder_lite.h>\n\n#include <algorithm>\n#include <google/protobuf/stubs/hash.h>\n#include <map>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <vector>\n\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n#include <google/protobuf/compiler/java/java_enum.h>\n#include <google/protobuf/compiler/java/java_extension.h>\n#include <google/protobuf/compiler/java/java_generator_factory.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nnamespace {\nbool GenerateHasBits(const Descriptor* descriptor) {\n  return SupportFieldPresence(descriptor->file()) ||\n      HasRepeatedFields(descriptor);\n}\n\nstring MapValueImmutableClassdName(const Descriptor* descriptor,\n                                   ClassNameResolver* name_resolver) {\n  const FieldDescriptor* value_field = descriptor->FindFieldByName(\"value\");\n  GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, value_field->type());\n  return name_resolver->GetImmutableClassName(value_field->message_type());\n}\n}  // namespace\n\nMessageBuilderLiteGenerator::MessageBuilderLiteGenerator(\n    const Descriptor* descriptor, Context* context)\n  : descriptor_(descriptor), context_(context),\n    name_resolver_(context->GetNameResolver()),\n    field_generators_(descriptor, context_) {\n  GOOGLE_CHECK(!HasDescriptorMethods(descriptor->file(), context->EnforceLite()))\n      << \"Generator factory error: A lite message generator is used to \"\n         \"generate non-lite messages.\";\n}\n\nMessageBuilderLiteGenerator::~MessageBuilderLiteGenerator() {}\n\nvoid MessageBuilderLiteGenerator::\nGenerate(io::Printer* printer) {\n  WriteMessageDocComment(printer, descriptor_);\n  printer->Print(\n    \"public static final class Builder extends\\n\"\n    \"    com.google.protobuf.GeneratedMessageLite.$extendible$Builder<\\n\"\n    \"      $classname$, Builder> implements\\n\"\n    \"    $extra_interfaces$\\n\"\n    \"    $classname$OrBuilder {\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_),\n    \"extra_interfaces\", ExtraBuilderInterfaces(descriptor_),\n    \"extendible\",\n    descriptor_->extension_range_count() > 0 ? \"Extendable\" : \"\");\n  printer->Indent();\n\n  GenerateCommonBuilderMethods(printer);\n\n  // oneof\n  map<string, string> vars;\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    vars[\"oneof_name\"] = context_->GetOneofGeneratorInfo(\n        descriptor_->oneof_decl(i))->name;\n    vars[\"oneof_capitalized_name\"] = context_->GetOneofGeneratorInfo(\n        descriptor_->oneof_decl(i))->capitalized_name;\n    vars[\"oneof_index\"] = SimpleItoa(descriptor_->oneof_decl(i)->index());\n\n    // oneofCase() and clearOneof()\n    printer->Print(vars,\n      \"public $oneof_capitalized_name$Case\\n\"\n      \"    get$oneof_capitalized_name$Case() {\\n\"\n      \"  return instance.get$oneof_capitalized_name$Case();\\n\"\n      \"}\\n\"\n      \"\\n\"\n      \"public Builder clear$oneof_capitalized_name$() {\\n\"\n      \"  copyOnWrite();\\n\"\n      \"  instance.clear$oneof_capitalized_name$();\\n\"\n      \"  return this;\\n\"\n      \"}\\n\"\n      \"\\n\");\n  }\n\n  if (GenerateHasBits(descriptor_)) {\n    // Integers for bit fields.\n    int totalBits = 0;\n    for (int i = 0; i < descriptor_->field_count(); i++) {\n      totalBits += field_generators_.get(descriptor_->field(i))\n          .GetNumBitsForBuilder();\n    }\n    int totalInts = (totalBits + 31) / 32;\n    for (int i = 0; i < totalInts; i++) {\n      printer->Print(\"private int $bit_field_name$;\\n\",\n        \"bit_field_name\", GetBitFieldName(i));\n    }\n  }\n\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    printer->Print(\"\\n\");\n    field_generators_.get(descriptor_->field(i))\n                     .GenerateBuilderMembers(printer);\n  }\n\n  printer->Print(\n    \"\\n\"\n    \"// @@protoc_insertion_point(builder_scope:$full_name$)\\n\",\n    \"full_name\", descriptor_->full_name());\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\n// ===================================================================\n\nvoid MessageBuilderLiteGenerator::\nGenerateCommonBuilderMethods(io::Printer* printer) {\n  printer->Print(\n    \"// Construct using $classname$.newBuilder()\\n\"\n    \"private Builder() {\\n\"\n    \"  super(DEFAULT_INSTANCE);\\n\"\n    \"}\\n\"\n    \"\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n}\n\n// ===================================================================\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_message_builder_lite.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: dweis@google.com (Daniel Weis)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_LITE_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_LITE_H__\n\n#include <string>\n#include <map>\n#include <google/protobuf/compiler/java/java_field.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace compiler {\n    namespace java {\n      class Context;           // context.h\n      class ClassNameResolver; // name_resolver.h\n    }\n  }\n  namespace io {\n    class Printer;             // printer.h\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nclass MessageBuilderLiteGenerator {\n public:\n  explicit MessageBuilderLiteGenerator(const Descriptor* descriptor,\n                                   Context* context);\n  virtual ~MessageBuilderLiteGenerator();\n\n  virtual void Generate(io::Printer* printer);\n\n private:\n  void GenerateCommonBuilderMethods(io::Printer* printer);\n\n  const Descriptor* descriptor_;\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n  FieldGeneratorMap<ImmutableFieldLiteGenerator> field_generators_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageBuilderLiteGenerator);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_BUILDER_LITE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_message_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_message_field.h>\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nnamespace {\n\nvoid SetMessageVariables(const FieldDescriptor* descriptor,\n                         int messageBitIndex,\n                         int builderBitIndex,\n                         const FieldGeneratorInfo* info,\n                         ClassNameResolver* name_resolver,\n                         map<string, string>* variables) {\n  SetCommonFieldVariables(descriptor, info, variables);\n\n  (*variables)[\"type\"] =\n      name_resolver->GetImmutableClassName(descriptor->message_type());\n  (*variables)[\"mutable_type\"] =\n      name_resolver->GetMutableClassName(descriptor->message_type());\n  (*variables)[\"group_or_message\"] =\n    (GetType(descriptor) == FieldDescriptor::TYPE_GROUP) ?\n    \"Group\" : \"Message\";\n  // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported\n  // by the proto compiler\n  (*variables)[\"deprecation\"] = descriptor->options().deprecated()\n      ? \"@java.lang.Deprecated \" : \"\";\n  (*variables)[\"on_changed\"] = \"onChanged();\";\n  (*variables)[\"ver\"] = GeneratedCodeVersionSuffix();\n  (*variables)[\"get_parser\"] =\n      ExposePublicParser(descriptor->message_type()->file())\n          ? \"PARSER\" : \"parser()\";\n\n  if (SupportFieldPresence(descriptor->file())) {\n    // For singular messages and builders, one bit is used for the hasField bit.\n    (*variables)[\"get_has_field_bit_message\"] = GenerateGetBit(messageBitIndex);\n    (*variables)[\"get_has_field_bit_builder\"] = GenerateGetBit(builderBitIndex);\n\n    // Note that these have a trailing \";\".\n    (*variables)[\"set_has_field_bit_message\"] =\n        GenerateSetBit(messageBitIndex) + \";\";\n    (*variables)[\"set_has_field_bit_builder\"] =\n        GenerateSetBit(builderBitIndex) + \";\";\n    (*variables)[\"clear_has_field_bit_builder\"] =\n        GenerateClearBit(builderBitIndex) + \";\";\n\n    (*variables)[\"is_field_present_message\"] = GenerateGetBit(messageBitIndex);\n  } else {\n    (*variables)[\"set_has_field_bit_message\"] = \"\";\n    (*variables)[\"set_has_field_bit_builder\"] = \"\";\n    (*variables)[\"clear_has_field_bit_builder\"] = \"\";\n\n    (*variables)[\"is_field_present_message\"] =\n        (*variables)[\"name\"] + \"_ != null\";\n  }\n\n  // For repated builders, one bit is used for whether the array is immutable.\n  (*variables)[\"get_mutable_bit_builder\"] = GenerateGetBit(builderBitIndex);\n  (*variables)[\"set_mutable_bit_builder\"] = GenerateSetBit(builderBitIndex);\n  (*variables)[\"clear_mutable_bit_builder\"] = GenerateClearBit(builderBitIndex);\n\n  // For repeated fields, one bit is used for whether the array is immutable\n  // in the parsing constructor.\n  (*variables)[\"get_mutable_bit_parser\"] =\n      GenerateGetBitMutableLocal(builderBitIndex);\n  (*variables)[\"set_mutable_bit_parser\"] =\n      GenerateSetBitMutableLocal(builderBitIndex);\n\n  (*variables)[\"get_has_field_bit_from_local\"] =\n      GenerateGetBitFromLocal(builderBitIndex);\n  (*variables)[\"set_has_field_bit_to_local\"] =\n      GenerateSetBitToLocal(messageBitIndex);\n}\n\n}  // namespace\n\n// ===================================================================\n\nImmutableMessageFieldGenerator::\nImmutableMessageFieldGenerator(const FieldDescriptor* descriptor,\n                      int messageBitIndex,\n                      int builderBitIndex,\n                      Context* context)\n  : descriptor_(descriptor), messageBitIndex_(messageBitIndex),\n    builderBitIndex_(builderBitIndex), context_(context),\n    name_resolver_(context->GetNameResolver()) {\n    SetMessageVariables(descriptor, messageBitIndex, builderBitIndex,\n                        context->GetFieldGeneratorInfo(descriptor),\n                        name_resolver_, &variables_);\n}\n\nImmutableMessageFieldGenerator::~ImmutableMessageFieldGenerator() {}\n\nint ImmutableMessageFieldGenerator::GetNumBitsForMessage() const {\n  return 1;\n}\n\nint ImmutableMessageFieldGenerator::GetNumBitsForBuilder() const {\n  return 1;\n}\n\nvoid ImmutableMessageFieldGenerator::\nGenerateInterfaceMembers(io::Printer* printer) const {\n  // TODO(jonp): In the future, consider having a method specific to the\n  // interface so that builders can choose dynamically to either return a\n  // message or a nested builder, so that asking for the interface doesn't\n  // cause a message to ever be built.\n  if (SupportFieldPresence(descriptor_->file()) ||\n      descriptor_->containing_oneof() == NULL) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$boolean has$capitalized_name$();\\n\");\n  }\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$$type$ get$capitalized_name$();\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$$type$OrBuilder get$capitalized_name$OrBuilder();\\n\");\n}\n\nvoid ImmutableMessageFieldGenerator::\nGenerateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"private $type$ $name$_;\\n\");\n  PrintExtraFieldInfo(variables_, printer);\n\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $get_has_field_bit_message$;\\n\"\n      \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n      \"  return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\\n\"\n      \"}\\n\");\n\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public $type$OrBuilder \"\n      \"get$capitalized_name$OrBuilder() {\\n\"\n      \"  return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\\n\"\n      \"}\\n\");\n  } else {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $name$_ != null;\\n\"\n      \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n      \"  return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\\n\"\n      \"}\\n\");\n\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public $type$OrBuilder \"\n      \"get$capitalized_name$OrBuilder() {\\n\"\n      \"  return get$capitalized_name$();\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid ImmutableMessageFieldGenerator::PrintNestedBuilderCondition(\n    io::Printer* printer,\n    const char* regular_case,\n    const char* nested_builder_case) const {\n  printer->Print(variables_, \"if ($name$Builder_ == null) {\\n\");\n  printer->Indent();\n  printer->Print(variables_, regular_case);\n  printer->Outdent();\n  printer->Print(\"} else {\\n\");\n  printer->Indent();\n  printer->Print(variables_, nested_builder_case);\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid ImmutableMessageFieldGenerator::PrintNestedBuilderFunction(\n    io::Printer* printer,\n    const char* method_prototype,\n    const char* regular_case,\n    const char* nested_builder_case,\n    const char* trailing_code) const {\n  printer->Print(variables_, method_prototype);\n  printer->Print(\" {\\n\");\n  printer->Indent();\n  PrintNestedBuilderCondition(printer, regular_case, nested_builder_case);\n  if (trailing_code != NULL) {\n    printer->Print(variables_, trailing_code);\n  }\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid ImmutableMessageFieldGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  // When using nested-builders, the code initially works just like the\n  // non-nested builder case. It only creates a nested builder lazily on\n  // demand and then forever delegates to it after creation.\n\n  bool support_field_presence = SupportFieldPresence(descriptor_->file());\n\n  printer->Print(variables_,\n    \"private $type$ $name$_ = null;\\n\");\n\n  printer->Print(variables_,\n      // If this builder is non-null, it is used and the other fields are\n      // ignored.\n      \"private com.google.protobuf.SingleFieldBuilder$ver$<\\n\"\n      \"    $type$, $type$.Builder, $type$OrBuilder> $name$Builder_;\"\n      \"\\n\");\n\n  // The comments above the methods below are based on a hypothetical\n  // field of type \"Field\" called \"Field\".\n\n  // boolean hasField()\n  WriteFieldDocComment(printer, descriptor_);\n  if (support_field_presence) {\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $get_has_field_bit_builder$;\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $name$Builder_ != null || $name$_ != null;\\n\"\n      \"}\\n\");\n  }\n\n  // Field getField()\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public $type$ get$capitalized_name$()\",\n    \"return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\\n\",\n    \"return $name$Builder_.getMessage();\\n\",\n    NULL);\n\n  // Field.Builder setField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder set$capitalized_name$($type$ value)\",\n\n    \"if (value == null) {\\n\"\n    \"  throw new NullPointerException();\\n\"\n    \"}\\n\"\n    \"$name$_ = value;\\n\"\n    \"$on_changed$\\n\",\n\n    \"$name$Builder_.setMessage(value);\\n\",\n\n    \"$set_has_field_bit_builder$\\n\"\n    \"return this;\\n\");\n\n  // Field.Builder setField(Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    $type$.Builder builderForValue)\",\n\n    \"$name$_ = builderForValue.build();\\n\"\n    \"$on_changed$\\n\",\n\n    \"$name$Builder_.setMessage(builderForValue.build());\\n\",\n\n    \"$set_has_field_bit_builder$\\n\"\n    \"return this;\\n\");\n\n  // Field.Builder mergeField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder merge$capitalized_name$($type$ value)\",\n\n    support_field_presence\n        ? \"if ($get_has_field_bit_builder$ &&\\n\"\n          \"    $name$_ != null &&\\n\"\n          \"    $name$_ != $type$.getDefaultInstance()) {\\n\"\n          \"  $name$_ =\\n\"\n          \"    $type$.newBuilder($name$_).mergeFrom(value).buildPartial();\\n\"\n          \"} else {\\n\"\n          \"  $name$_ = value;\\n\"\n          \"}\\n\"\n          \"$on_changed$\\n\"\n        : \"if ($name$_ != null) {\\n\"\n          \"  $name$_ =\\n\"\n          \"    $type$.newBuilder($name$_).mergeFrom(value).buildPartial();\\n\"\n          \"} else {\\n\"\n          \"  $name$_ = value;\\n\"\n          \"}\\n\"\n          \"$on_changed$\\n\",\n\n    \"$name$Builder_.mergeFrom(value);\\n\",\n\n    \"$set_has_field_bit_builder$\\n\"\n    \"return this;\\n\");\n\n  // Field.Builder clearField()\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder clear$capitalized_name$()\",\n\n    \"$name$_ = null;\\n\"\n    \"$on_changed$\\n\",\n\n    support_field_presence\n        ? \"$name$Builder_.clear();\\n\"\n        : \"$name$_ = null;\\n\"\n          \"$name$Builder_ = null;\\n\",\n\n    \"$clear_has_field_bit_builder$\\n\"\n    \"return this;\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$.Builder get$capitalized_name$Builder() {\\n\"\n    \"  $set_has_field_bit_builder$\\n\"\n    \"  $on_changed$\\n\"\n    \"  return get$capitalized_name$FieldBuilder().getBuilder();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder() {\\n\"\n    \"  if ($name$Builder_ != null) {\\n\"\n    \"    return $name$Builder_.getMessageOrBuilder();\\n\"\n    \"  } else {\\n\"\n    \"    return $name$_ == null ?\\n\"\n    \"        $type$.getDefaultInstance() : $name$_;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private com.google.protobuf.SingleFieldBuilder$ver$<\\n\"\n    \"    $type$, $type$.Builder, $type$OrBuilder> \\n\"\n    \"    get$capitalized_name$FieldBuilder() {\\n\"\n    \"  if ($name$Builder_ == null) {\\n\"\n    \"    $name$Builder_ = new com.google.protobuf.SingleFieldBuilder$ver$<\\n\"\n    \"        $type$, $type$.Builder, $type$OrBuilder>(\\n\"\n    \"            get$capitalized_name$(),\\n\"\n    \"            getParentForChildren(),\\n\"\n    \"            isClean());\\n\"\n    \"    $name$_ = null;\\n\"\n    \"  }\\n\"\n    \"  return $name$Builder_;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableMessageFieldGenerator::\nGenerateFieldBuilderInitializationCode(io::Printer* printer)  const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    printer->Print(variables_,\n      \"get$capitalized_name$FieldBuilder();\\n\");\n  }\n}\n\n\nvoid ImmutableMessageFieldGenerator::\nGenerateInitializationCode(io::Printer* printer) const {}\n\nvoid ImmutableMessageFieldGenerator::\nGenerateBuilderClearCode(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    PrintNestedBuilderCondition(printer,\n      \"$name$_ = null;\\n\",\n\n      \"$name$Builder_.clear();\\n\");\n    printer->Print(variables_, \"$clear_has_field_bit_builder$\\n\");\n  } else {\n    PrintNestedBuilderCondition(printer,\n      \"$name$_ = null;\\n\",\n\n      \"$name$_ = null;\\n\"\n      \"$name$Builder_ = null;\\n\");\n  }\n}\n\nvoid ImmutableMessageFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (other.has$capitalized_name$()) {\\n\"\n    \"  merge$capitalized_name$(other.get$capitalized_name$());\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableMessageFieldGenerator::\nGenerateBuildingCode(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    printer->Print(variables_,\n        \"if ($get_has_field_bit_from_local$) {\\n\"\n        \"  $set_has_field_bit_to_local$;\\n\"\n        \"}\\n\");\n  }\n\n  PrintNestedBuilderCondition(printer,\n    \"result.$name$_ = $name$_;\\n\",\n\n    \"result.$name$_ = $name$Builder_.build();\\n\");\n}\n\nvoid ImmutableMessageFieldGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$type$.Builder subBuilder = null;\\n\"\n    \"if ($is_field_present_message$) {\\n\"\n    \"  subBuilder = $name$_.toBuilder();\\n\"\n    \"}\\n\");\n\n  if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) {\n    printer->Print(variables_,\n      \"$name$_ = input.readGroup($number$, $type$.$get_parser$,\\n\"\n      \"    extensionRegistry);\\n\");\n  } else {\n    printer->Print(variables_,\n      \"$name$_ = input.readMessage($type$.$get_parser$, extensionRegistry);\\n\");\n  }\n\n  printer->Print(variables_,\n    \"if (subBuilder != null) {\\n\"\n    \"  subBuilder.mergeFrom($name$_);\\n\"\n    \"  $name$_ = subBuilder.buildPartial();\\n\"\n    \"}\\n\"\n    \"$set_has_field_bit_message$\\n\");\n}\n\nvoid ImmutableMessageFieldGenerator::\nGenerateParsingDoneCode(io::Printer* printer) const {\n  // noop for messages.\n}\n\nvoid ImmutableMessageFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($is_field_present_message$) {\\n\"\n    \"  output.write$group_or_message$($number$, get$capitalized_name$());\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableMessageFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($is_field_present_message$) {\\n\"\n    \"  size += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .compute$group_or_message$Size($number$, get$capitalized_name$());\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableMessageFieldGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"result = result && get$capitalized_name$()\\n\"\n    \"    .equals(other.get$capitalized_name$());\\n\");\n}\n\nvoid ImmutableMessageFieldGenerator::\nGenerateHashCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"hash = (37 * hash) + $constant_name$;\\n\"\n    \"hash = (53 * hash) + get$capitalized_name$().hashCode();\\n\");\n}\n\nstring ImmutableMessageFieldGenerator::GetBoxedType() const {\n  return name_resolver_->GetImmutableClassName(descriptor_->message_type());\n}\n\n// ===================================================================\n\nImmutableMessageOneofFieldGenerator::\nImmutableMessageOneofFieldGenerator(const FieldDescriptor* descriptor,\n                                 int messageBitIndex,\n                                 int builderBitIndex,\n                                 Context* context)\n    : ImmutableMessageFieldGenerator(\n          descriptor, messageBitIndex, builderBitIndex, context) {\n  const OneofGeneratorInfo* info =\n      context->GetOneofGeneratorInfo(descriptor->containing_oneof());\n  SetCommonOneofVariables(descriptor, info, &variables_);\n}\n\nImmutableMessageOneofFieldGenerator::\n~ImmutableMessageOneofFieldGenerator() {}\n\nvoid ImmutableMessageOneofFieldGenerator::\nGenerateMembers(io::Printer* printer) const {\n  PrintExtraFieldInfo(variables_, printer);\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $has_oneof_case_message$;\\n\"\n      \"}\\n\");\n  }\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"     return ($type$) $oneof_name$_;\\n\"\n    \"  }\\n\"\n    \"  return $type$.getDefaultInstance();\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder() {\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"     return ($type$) $oneof_name$_;\\n\"\n    \"  }\\n\"\n    \"  return $type$.getDefaultInstance();\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableMessageOneofFieldGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  // When using nested-builders, the code initially works just like the\n  // non-nested builder case. It only creates a nested builder lazily on\n  // demand and then forever delegates to it after creation.\n  printer->Print(variables_,\n    // If this builder is non-null, it is used and the other fields are\n    // ignored.\n    \"private com.google.protobuf.SingleFieldBuilder$ver$<\\n\"\n    \"    $type$, $type$.Builder, $type$OrBuilder> $name$Builder_;\"\n    \"\\n\");\n\n  // The comments above the methods below are based on a hypothetical\n  // field of type \"Field\" called \"Field\".\n\n  if (SupportFieldPresence(descriptor_->file())) {\n    // boolean hasField()\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $has_oneof_case_message$;\\n\"\n      \"}\\n\");\n  }\n\n  // Field getField()\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public $type$ get$capitalized_name$()\",\n\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  return ($type$) $oneof_name$_;\\n\"\n    \"}\\n\"\n    \"return $type$.getDefaultInstance();\\n\",\n\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  return $name$Builder_.getMessage();\\n\"\n    \"}\\n\"\n    \"return $type$.getDefaultInstance();\\n\",\n\n    NULL);\n\n  // Field.Builder setField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder set$capitalized_name$($type$ value)\",\n\n    \"if (value == null) {\\n\"\n    \"  throw new NullPointerException();\\n\"\n    \"}\\n\"\n    \"$oneof_name$_ = value;\\n\"\n    \"$on_changed$\\n\",\n\n    \"$name$Builder_.setMessage(value);\\n\",\n\n    \"$set_oneof_case_message$;\\n\"\n    \"return this;\\n\");\n\n  // Field.Builder setField(Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    $type$.Builder builderForValue)\",\n\n    \"$oneof_name$_ = builderForValue.build();\\n\"\n    \"$on_changed$\\n\",\n\n    \"$name$Builder_.setMessage(builderForValue.build());\\n\",\n\n    \"$set_oneof_case_message$;\\n\"\n    \"return this;\\n\");\n\n  // Field.Builder mergeField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder merge$capitalized_name$($type$ value)\",\n\n    \"if ($has_oneof_case_message$ &&\\n\"\n    \"    $oneof_name$_ != $type$.getDefaultInstance()) {\\n\"\n    \"  $oneof_name$_ = $type$.newBuilder(($type$) $oneof_name$_)\\n\"\n    \"      .mergeFrom(value).buildPartial();\\n\"\n    \"} else {\\n\"\n    \"  $oneof_name$_ = value;\\n\"\n    \"}\\n\"\n    \"$on_changed$\\n\",\n\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  $name$Builder_.mergeFrom(value);\\n\"\n    \"}\\n\"\n    \"$name$Builder_.setMessage(value);\\n\",\n\n    \"$set_oneof_case_message$;\\n\"\n    \"return this;\\n\");\n\n  // Field.Builder clearField()\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder clear$capitalized_name$()\",\n\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  $clear_oneof_case_message$;\\n\"\n    \"  $oneof_name$_ = null;\\n\"\n    \"  $on_changed$\\n\"\n    \"}\\n\",\n\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  $clear_oneof_case_message$;\\n\"\n    \"  $oneof_name$_ = null;\\n\"\n    \"}\\n\"\n    \"$name$Builder_.clear();\\n\",\n\n    \"return this;\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$.Builder get$capitalized_name$Builder() {\\n\"\n    \"  return get$capitalized_name$FieldBuilder().getBuilder();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder() {\\n\"\n    \"  if (($has_oneof_case_message$) && ($name$Builder_ != null)) {\\n\"\n    \"    return $name$Builder_.getMessageOrBuilder();\\n\"\n    \"  } else {\\n\"\n    \"    if ($has_oneof_case_message$) {\\n\"\n    \"      return ($type$) $oneof_name$_;\\n\"\n    \"    }\\n\"\n    \"    return $type$.getDefaultInstance();\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private com.google.protobuf.SingleFieldBuilder$ver$<\\n\"\n    \"    $type$, $type$.Builder, $type$OrBuilder> \\n\"\n    \"    get$capitalized_name$FieldBuilder() {\\n\"\n    \"  if ($name$Builder_ == null) {\\n\"\n    \"    if (!($has_oneof_case_message$)) {\\n\"\n    \"      $oneof_name$_ = $type$.getDefaultInstance();\\n\"\n    \"    }\\n\"\n    \"    $name$Builder_ = new com.google.protobuf.SingleFieldBuilder$ver$<\\n\"\n    \"        $type$, $type$.Builder, $type$OrBuilder>(\\n\"\n    \"            ($type$) $oneof_name$_,\\n\"\n    \"            getParentForChildren(),\\n\"\n    \"            isClean());\\n\"\n    \"    $oneof_name$_ = null;\\n\"\n    \"  }\\n\"\n    \"  $set_oneof_case_message$;\\n\"\n    \"  $on_changed$;\\n\"\n    \"  return $name$Builder_;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableMessageOneofFieldGenerator::\nGenerateBuildingCode(io::Printer* printer) const {\n\n  printer->Print(variables_,\n                 \"if ($has_oneof_case_message$) {\\n\");\n  printer->Indent();\n\n  PrintNestedBuilderCondition(printer,\n    \"result.$oneof_name$_ = $oneof_name$_;\\n\",\n\n    \"result.$oneof_name$_ = $name$Builder_.build();\\n\");\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid ImmutableMessageOneofFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"merge$capitalized_name$(other.get$capitalized_name$());\\n\");\n}\n\nvoid ImmutableMessageOneofFieldGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$type$.Builder subBuilder = null;\\n\"\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  subBuilder = (($type$) $oneof_name$_).toBuilder();\\n\"\n    \"}\\n\");\n\n  if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) {\n    printer->Print(variables_,\n      \"$oneof_name$_ = input.readGroup($number$, $type$.$get_parser$,\\n\"\n      \"    extensionRegistry);\\n\");\n  } else {\n    printer->Print(variables_,\n      \"$oneof_name$_ =\\n\"\n      \"    input.readMessage($type$.$get_parser$, extensionRegistry);\\n\");\n  }\n\n  printer->Print(variables_,\n    \"if (subBuilder != null) {\\n\"\n    \"  subBuilder.mergeFrom(($type$) $oneof_name$_);\\n\"\n    \"  $oneof_name$_ = subBuilder.buildPartial();\\n\"\n    \"}\\n\");\n  printer->Print(variables_,\n    \"$set_oneof_case_message$;\\n\");\n}\n\nvoid ImmutableMessageOneofFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  output.write$group_or_message$($number$, ($type$) $oneof_name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableMessageOneofFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  size += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .compute$group_or_message$Size($number$, ($type$) $oneof_name$_);\\n\"\n    \"}\\n\");\n}\n\n// ===================================================================\n\nRepeatedImmutableMessageFieldGenerator::\nRepeatedImmutableMessageFieldGenerator(const FieldDescriptor* descriptor,\n                                       int messageBitIndex,\n                                       int builderBitIndex,\n                                       Context* context)\n  : descriptor_(descriptor), messageBitIndex_(messageBitIndex),\n    builderBitIndex_(builderBitIndex), context_(context),\n    name_resolver_(context->GetNameResolver())  {\n  SetMessageVariables(descriptor, messageBitIndex, builderBitIndex,\n                      context->GetFieldGeneratorInfo(descriptor),\n                      name_resolver_, &variables_);\n}\n\nRepeatedImmutableMessageFieldGenerator::\n~RepeatedImmutableMessageFieldGenerator() {}\n\nint RepeatedImmutableMessageFieldGenerator::GetNumBitsForMessage() const {\n  return 0;\n}\n\nint RepeatedImmutableMessageFieldGenerator::GetNumBitsForBuilder() const {\n  return 1;\n}\n\nvoid RepeatedImmutableMessageFieldGenerator::\nGenerateInterfaceMembers(io::Printer* printer) const {\n  // TODO(jonp): In the future, consider having methods specific to the\n  // interface so that builders can choose dynamically to either return a\n  // message or a nested builder, so that asking for the interface doesn't\n  // cause a message to ever be built.\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$java.util.List<$type$> \\n\"\n    \"    get$capitalized_name$List();\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$$type$ get$capitalized_name$(int index);\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$int get$capitalized_name$Count();\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$java.util.List<? extends $type$OrBuilder> \\n\"\n    \"    get$capitalized_name$OrBuilderList();\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$$type$OrBuilder get$capitalized_name$OrBuilder(\\n\"\n    \"    int index);\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldGenerator::\nGenerateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"private java.util.List<$type$> $name$_;\\n\");\n  PrintExtraFieldInfo(variables_, printer);\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.util.List<$type$> get$capitalized_name$List() {\\n\"\n    \"  return $name$_;\\n\"   // note:  unmodifiable list\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.util.List<? extends $type$OrBuilder> \\n\"\n    \"    get$capitalized_name$OrBuilderList() {\\n\"\n    \"  return $name$_;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public int get$capitalized_name$Count() {\\n\"\n    \"  return $name$_.size();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$(int index) {\\n\"\n    \"  return $name$_.get(index);\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder(\\n\"\n    \"    int index) {\\n\"\n    \"  return $name$_.get(index);\\n\"\n    \"}\\n\");\n\n}\n\nvoid RepeatedImmutableMessageFieldGenerator::PrintNestedBuilderCondition(\n    io::Printer* printer,\n    const char* regular_case,\n    const char* nested_builder_case) const {\n  printer->Print(variables_, \"if ($name$Builder_ == null) {\\n\");\n  printer->Indent();\n  printer->Print(variables_, regular_case);\n  printer->Outdent();\n  printer->Print(\"} else {\\n\");\n  printer->Indent();\n  printer->Print(variables_, nested_builder_case);\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldGenerator::PrintNestedBuilderFunction(\n    io::Printer* printer,\n    const char* method_prototype,\n    const char* regular_case,\n    const char* nested_builder_case,\n    const char* trailing_code) const {\n  printer->Print(variables_, method_prototype);\n  printer->Print(\" {\\n\");\n  printer->Indent();\n  PrintNestedBuilderCondition(printer, regular_case, nested_builder_case);\n  if (trailing_code != NULL) {\n    printer->Print(variables_, trailing_code);\n  }\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  // When using nested-builders, the code initially works just like the\n  // non-nested builder case. It only creates a nested builder lazily on\n  // demand and then forever delegates to it after creation.\n\n  printer->Print(variables_,\n    // Used when the builder is null.\n    // One field is the list and the other field keeps track of whether the\n    // list is immutable. If it's immutable, the invariant is that it must\n    // either an instance of Collections.emptyList() or it's an ArrayList\n    // wrapped in a Collections.unmodifiableList() wrapper and nobody else has\n    // a refererence to the underlying ArrayList. This invariant allows us to\n    // share instances of lists between protocol buffers avoiding expensive\n    // memory allocations. Note, immutable is a strong guarantee here -- not\n    // just that the list cannot be modified via the reference but that the\n    // list can never be modified.\n    \"private java.util.List<$type$> $name$_ =\\n\"\n    \"  java.util.Collections.emptyList();\\n\"\n\n    \"private void ensure$capitalized_name$IsMutable() {\\n\"\n    \"  if (!$get_mutable_bit_builder$) {\\n\"\n    \"    $name$_ = new java.util.ArrayList<$type$>($name$_);\\n\"\n    \"    $set_mutable_bit_builder$;\\n\"\n    \"   }\\n\"\n    \"}\\n\"\n    \"\\n\");\n\n  printer->Print(variables_,\n    // If this builder is non-null, it is used and the other fields are\n    // ignored.\n    \"private com.google.protobuf.RepeatedFieldBuilder$ver$<\\n\"\n    \"    $type$, $type$.Builder, $type$OrBuilder> $name$Builder_;\\n\"\n    \"\\n\");\n\n  // The comments above the methods below are based on a hypothetical\n  // repeated field of type \"Field\" called \"RepeatedField\".\n\n  // List<Field> getRepeatedFieldList()\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public java.util.List<$type$> get$capitalized_name$List()\",\n\n    \"return java.util.Collections.unmodifiableList($name$_);\\n\",\n    \"return $name$Builder_.getMessageList();\\n\",\n\n    NULL);\n\n  // int getRepeatedFieldCount()\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public int get$capitalized_name$Count()\",\n\n    \"return $name$_.size();\\n\",\n    \"return $name$Builder_.getCount();\\n\",\n\n    NULL);\n\n  // Field getRepeatedField(int index)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public $type$ get$capitalized_name$(int index)\",\n\n    \"return $name$_.get(index);\\n\",\n\n    \"return $name$Builder_.getMessage(index);\\n\",\n\n    NULL);\n\n  // Builder setRepeatedField(int index, Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    int index, $type$ value)\",\n    \"if (value == null) {\\n\"\n    \"  throw new NullPointerException();\\n\"\n    \"}\\n\"\n    \"ensure$capitalized_name$IsMutable();\\n\"\n    \"$name$_.set(index, value);\\n\"\n    \"$on_changed$\\n\",\n    \"$name$Builder_.setMessage(index, value);\\n\",\n    \"return this;\\n\");\n\n  // Builder setRepeatedField(int index, Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    int index, $type$.Builder builderForValue)\",\n\n    \"ensure$capitalized_name$IsMutable();\\n\"\n    \"$name$_.set(index, builderForValue.build());\\n\"\n    \"$on_changed$\\n\",\n\n    \"$name$Builder_.setMessage(index, builderForValue.build());\\n\",\n\n    \"return this;\\n\");\n\n  // Builder addRepeatedField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder add$capitalized_name$($type$ value)\",\n\n    \"if (value == null) {\\n\"\n    \"  throw new NullPointerException();\\n\"\n    \"}\\n\"\n    \"ensure$capitalized_name$IsMutable();\\n\"\n    \"$name$_.add(value);\\n\"\n\n    \"$on_changed$\\n\",\n\n    \"$name$Builder_.addMessage(value);\\n\",\n\n    \"return this;\\n\");\n\n  // Builder addRepeatedField(int index, Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder add$capitalized_name$(\\n\"\n    \"    int index, $type$ value)\",\n\n    \"if (value == null) {\\n\"\n    \"  throw new NullPointerException();\\n\"\n    \"}\\n\"\n    \"ensure$capitalized_name$IsMutable();\\n\"\n    \"$name$_.add(index, value);\\n\"\n    \"$on_changed$\\n\",\n\n    \"$name$Builder_.addMessage(index, value);\\n\",\n\n    \"return this;\\n\");\n\n  // Builder addRepeatedField(Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder add$capitalized_name$(\\n\"\n    \"    $type$.Builder builderForValue)\",\n\n    \"ensure$capitalized_name$IsMutable();\\n\"\n    \"$name$_.add(builderForValue.build());\\n\"\n    \"$on_changed$\\n\",\n\n    \"$name$Builder_.addMessage(builderForValue.build());\\n\",\n\n    \"return this;\\n\");\n\n  // Builder addRepeatedField(int index, Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder add$capitalized_name$(\\n\"\n    \"    int index, $type$.Builder builderForValue)\",\n\n    \"ensure$capitalized_name$IsMutable();\\n\"\n    \"$name$_.add(index, builderForValue.build());\\n\"\n    \"$on_changed$\\n\",\n\n    \"$name$Builder_.addMessage(index, builderForValue.build());\\n\",\n\n    \"return this;\\n\");\n\n  // Builder addAllRepeatedField(Iterable<Field> values)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder addAll$capitalized_name$(\\n\"\n    \"    java.lang.Iterable<? extends $type$> values)\",\n\n    \"ensure$capitalized_name$IsMutable();\\n\"\n    \"com.google.protobuf.AbstractMessageLite.Builder.addAll(\\n\"\n    \"    values, $name$_);\\n\"\n    \"$on_changed$\\n\",\n\n    \"$name$Builder_.addAllMessages(values);\\n\",\n\n    \"return this;\\n\");\n\n  // Builder clearAllRepeatedField()\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder clear$capitalized_name$()\",\n\n    \"$name$_ = java.util.Collections.emptyList();\\n\"\n    \"$clear_mutable_bit_builder$;\\n\"\n    \"$on_changed$\\n\",\n\n    \"$name$Builder_.clear();\\n\",\n\n    \"return this;\\n\");\n\n  // Builder removeRepeatedField(int index)\n  WriteFieldDocComment(printer, descriptor_);\n  PrintNestedBuilderFunction(printer,\n    \"$deprecation$public Builder remove$capitalized_name$(int index)\",\n\n    \"ensure$capitalized_name$IsMutable();\\n\"\n    \"$name$_.remove(index);\\n\"\n    \"$on_changed$\\n\",\n\n    \"$name$Builder_.remove(index);\\n\",\n\n    \"return this;\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$.Builder get$capitalized_name$Builder(\\n\"\n    \"    int index) {\\n\"\n    \"  return get$capitalized_name$FieldBuilder().getBuilder(index);\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n      printer->Print(variables_,\n    \"$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder(\\n\"\n    \"    int index) {\\n\"\n    \"  if ($name$Builder_ == null) {\\n\"\n    \"    return $name$_.get(index);\"\n    \"  } else {\\n\"\n    \"    return $name$Builder_.getMessageOrBuilder(index);\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n      printer->Print(variables_,\n    \"$deprecation$public java.util.List<? extends $type$OrBuilder> \\n\"\n    \"     get$capitalized_name$OrBuilderList() {\\n\"\n    \"  if ($name$Builder_ != null) {\\n\"\n    \"    return $name$Builder_.getMessageOrBuilderList();\\n\"\n    \"  } else {\\n\"\n    \"    return java.util.Collections.unmodifiableList($name$_);\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n      printer->Print(variables_,\n    \"$deprecation$public $type$.Builder add$capitalized_name$Builder() {\\n\"\n    \"  return get$capitalized_name$FieldBuilder().addBuilder(\\n\"\n    \"      $type$.getDefaultInstance());\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n      printer->Print(variables_,\n    \"$deprecation$public $type$.Builder add$capitalized_name$Builder(\\n\"\n    \"    int index) {\\n\"\n    \"  return get$capitalized_name$FieldBuilder().addBuilder(\\n\"\n    \"      index, $type$.getDefaultInstance());\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n      printer->Print(variables_,\n    \"$deprecation$public java.util.List<$type$.Builder> \\n\"\n    \"     get$capitalized_name$BuilderList() {\\n\"\n    \"  return get$capitalized_name$FieldBuilder().getBuilderList();\\n\"\n    \"}\\n\"\n    \"private com.google.protobuf.RepeatedFieldBuilder$ver$<\\n\"\n    \"    $type$, $type$.Builder, $type$OrBuilder> \\n\"\n    \"    get$capitalized_name$FieldBuilder() {\\n\"\n    \"  if ($name$Builder_ == null) {\\n\"\n    \"    $name$Builder_ = new com.google.protobuf.RepeatedFieldBuilder$ver$<\\n\"\n    \"        $type$, $type$.Builder, $type$OrBuilder>(\\n\"\n    \"            $name$_,\\n\"\n    \"            $get_mutable_bit_builder$,\\n\"\n    \"            getParentForChildren(),\\n\"\n    \"            isClean());\\n\"\n    \"    $name$_ = null;\\n\"\n    \"  }\\n\"\n    \"  return $name$Builder_;\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldGenerator::\nGenerateFieldBuilderInitializationCode(io::Printer* printer)  const {\n  printer->Print(variables_,\n    \"get$capitalized_name$FieldBuilder();\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldGenerator::\nGenerateInitializationCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_ = java.util.Collections.emptyList();\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldGenerator::\nGenerateBuilderClearCode(io::Printer* printer) const {\n  PrintNestedBuilderCondition(printer,\n    \"$name$_ = java.util.Collections.emptyList();\\n\"\n    \"$clear_mutable_bit_builder$;\\n\",\n\n    \"$name$Builder_.clear();\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  // The code below does two optimizations (non-nested builder case):\n  //   1. If the other list is empty, there's nothing to do. This ensures we\n  //      don't allocate a new array if we already have an immutable one.\n  //   2. If the other list is non-empty and our current list is empty, we can\n  //      reuse the other list which is guaranteed to be immutable.\n  PrintNestedBuilderCondition(printer,\n    \"if (!other.$name$_.isEmpty()) {\\n\"\n    \"  if ($name$_.isEmpty()) {\\n\"\n    \"    $name$_ = other.$name$_;\\n\"\n    \"    $clear_mutable_bit_builder$;\\n\"\n    \"  } else {\\n\"\n    \"    ensure$capitalized_name$IsMutable();\\n\"\n    \"    $name$_.addAll(other.$name$_);\\n\"\n    \"  }\\n\"\n    \"  $on_changed$\\n\"\n    \"}\\n\",\n\n    \"if (!other.$name$_.isEmpty()) {\\n\"\n    \"  if ($name$Builder_.isEmpty()) {\\n\"\n    \"    $name$Builder_.dispose();\\n\"\n    \"    $name$Builder_ = null;\\n\"\n    \"    $name$_ = other.$name$_;\\n\"\n    \"    $clear_mutable_bit_builder$;\\n\"\n    \"    $name$Builder_ = \\n\"\n    \"      com.google.protobuf.GeneratedMessage$ver$.alwaysUseFieldBuilders ?\\n\"\n    \"         get$capitalized_name$FieldBuilder() : null;\\n\"\n    \"  } else {\\n\"\n    \"    $name$Builder_.addAllMessages(other.$name$_);\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldGenerator::\nGenerateBuildingCode(io::Printer* printer) const {\n  // The code below (non-nested builder case) ensures that the result has an\n  // immutable list. If our list is immutable, we can just reuse it. If not,\n  // we make it immutable.\n  PrintNestedBuilderCondition(printer,\n    \"if ($get_mutable_bit_builder$) {\\n\"\n    \"  $name$_ = java.util.Collections.unmodifiableList($name$_);\\n\"\n    \"  $clear_mutable_bit_builder$;\\n\"\n    \"}\\n\"\n    \"result.$name$_ = $name$_;\\n\",\n\n    \"result.$name$_ = $name$Builder_.build();\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (!$get_mutable_bit_parser$) {\\n\"\n    \"  $name$_ = new java.util.ArrayList<$type$>();\\n\"\n    \"  $set_mutable_bit_parser$;\\n\"\n    \"}\\n\");\n\n  if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) {\n    printer->Print(variables_,\n      \"$name$_.add(input.readGroup($number$, $type$.$get_parser$,\\n\"\n      \"    extensionRegistry));\\n\");\n  } else {\n    printer->Print(variables_,\n      \"$name$_.add(\\n\"\n      \"    input.readMessage($type$.$get_parser$, extensionRegistry));\\n\");\n  }\n}\n\nvoid RepeatedImmutableMessageFieldGenerator::\nGenerateParsingDoneCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($get_mutable_bit_parser$) {\\n\"\n    \"  $name$_ = java.util.Collections.unmodifiableList($name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n    \"  output.write$group_or_message$($number$, $name$_.get(i));\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n    \"  size += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .compute$group_or_message$Size($number$, $name$_.get(i));\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"result = result && get$capitalized_name$List()\\n\"\n    \"    .equals(other.get$capitalized_name$List());\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldGenerator::\nGenerateHashCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (get$capitalized_name$Count() > 0) {\\n\"\n    \"  hash = (37 * hash) + $constant_name$;\\n\"\n    \"  hash = (53 * hash) + get$capitalized_name$List().hashCode();\\n\"\n    \"}\\n\");\n}\n\nstring RepeatedImmutableMessageFieldGenerator::GetBoxedType() const {\n  return name_resolver_->GetImmutableClassName(descriptor_->message_type());\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_message_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_H__\n\n#include <map>\n#include <string>\n#include <google/protobuf/compiler/java/java_field.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace compiler {\n    namespace java {\n      class Context;           // context.h\n      class ClassNameResolver; // name_resolver.h\n    }\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nclass ImmutableMessageFieldGenerator : public ImmutableFieldGenerator {\n public:\n  explicit ImmutableMessageFieldGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~ImmutableMessageFieldGenerator();\n\n  // implements ImmutableFieldGenerator ---------------------------------------\n  int GetNumBitsForMessage() const;\n  int GetNumBitsForBuilder() const;\n  void GenerateInterfaceMembers(io::Printer* printer) const;\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateInitializationCode(io::Printer* printer) const;\n  void GenerateBuilderClearCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateBuildingCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateParsingDoneCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCode(io::Printer* printer) const;\n\n  string GetBoxedType() const;\n\n protected:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n  const int messageBitIndex_;\n  const int builderBitIndex_;\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n\n  void PrintNestedBuilderCondition(io::Printer* printer,\n      const char* regular_case, const char* nested_builder_case) const;\n  void PrintNestedBuilderFunction(io::Printer* printer,\n      const char* method_prototype, const char* regular_case,\n      const char* nested_builder_case,\n      const char* trailing_code) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageFieldGenerator);\n};\n\nclass ImmutableMessageOneofFieldGenerator\n    : public ImmutableMessageFieldGenerator {\n public:\n  ImmutableMessageOneofFieldGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~ImmutableMessageOneofFieldGenerator();\n\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateBuildingCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageOneofFieldGenerator);\n};\n\nclass RepeatedImmutableMessageFieldGenerator : public ImmutableFieldGenerator {\n public:\n  explicit RepeatedImmutableMessageFieldGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~RepeatedImmutableMessageFieldGenerator();\n\n  // implements ImmutableFieldGenerator ---------------------------------------\n  int GetNumBitsForMessage() const;\n  int GetNumBitsForBuilder() const;\n  void GenerateInterfaceMembers(io::Printer* printer) const;\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateInitializationCode(io::Printer* printer) const;\n  void GenerateBuilderClearCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateBuildingCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateParsingDoneCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCode(io::Printer* printer) const;\n\n  string GetBoxedType() const;\n\n protected:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n  const int messageBitIndex_;\n  const int builderBitIndex_;\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n\n  void PrintNestedBuilderCondition(io::Printer* printer,\n      const char* regular_case, const char* nested_builder_case) const;\n  void PrintNestedBuilderFunction(io::Printer* printer,\n      const char* method_prototype, const char* regular_case,\n      const char* nested_builder_case,\n      const char* trailing_code) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableMessageFieldGenerator);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_message_field_lite.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_message_field_lite.h>\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nnamespace {\n\nvoid SetMessageVariables(const FieldDescriptor* descriptor,\n                         int messageBitIndex,\n                         int builderBitIndex,\n                         const FieldGeneratorInfo* info,\n                         ClassNameResolver* name_resolver,\n                         map<string, string>* variables) {\n  SetCommonFieldVariables(descriptor, info, variables);\n\n  (*variables)[\"type\"] =\n      name_resolver->GetImmutableClassName(descriptor->message_type());\n  (*variables)[\"mutable_type\"] =\n      name_resolver->GetMutableClassName(descriptor->message_type());\n  (*variables)[\"group_or_message\"] =\n    (GetType(descriptor) == FieldDescriptor::TYPE_GROUP) ?\n    \"Group\" : \"Message\";\n  // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported\n  // by the proto compiler\n  (*variables)[\"deprecation\"] = descriptor->options().deprecated()\n      ? \"@java.lang.Deprecated \" : \"\";\n\n  if (SupportFieldPresence(descriptor->file())) {\n    // For singular messages and builders, one bit is used for the hasField bit.\n    (*variables)[\"get_has_field_bit_message\"] = GenerateGetBit(messageBitIndex);\n\n    // Note that these have a trailing \";\".\n    (*variables)[\"set_has_field_bit_message\"] =\n        GenerateSetBit(messageBitIndex) + \";\";\n    (*variables)[\"clear_has_field_bit_message\"] =\n        GenerateClearBit(messageBitIndex) + \";\";\n\n    (*variables)[\"is_field_present_message\"] = GenerateGetBit(messageBitIndex);\n  } else {\n    (*variables)[\"set_has_field_bit_message\"] = \"\";\n    (*variables)[\"clear_has_field_bit_message\"] = \"\";\n\n    (*variables)[\"is_field_present_message\"] =\n        (*variables)[\"name\"] + \"_ != null\";\n  }\n\n  // For repeated builders, the underlying list tracks mutability state.\n  (*variables)[\"is_mutable\"] = (*variables)[\"name\"] + \"_.isModifiable()\";\n\n  (*variables)[\"get_has_field_bit_from_local\"] =\n      GenerateGetBitFromLocal(builderBitIndex);\n  (*variables)[\"set_has_field_bit_to_local\"] =\n      GenerateSetBitToLocal(messageBitIndex);\n}\n\n}  // namespace\n\n// ===================================================================\n\nImmutableMessageFieldLiteGenerator::\nImmutableMessageFieldLiteGenerator(const FieldDescriptor* descriptor,\n                      int messageBitIndex,\n                      int builderBitIndex,\n                      Context* context)\n  : descriptor_(descriptor), messageBitIndex_(messageBitIndex),\n    builderBitIndex_(builderBitIndex), context_(context),\n    name_resolver_(context->GetNameResolver()) {\n    SetMessageVariables(descriptor, messageBitIndex, builderBitIndex,\n                        context->GetFieldGeneratorInfo(descriptor),\n                        name_resolver_, &variables_);\n}\n\nImmutableMessageFieldLiteGenerator::~ImmutableMessageFieldLiteGenerator() {}\n\nint ImmutableMessageFieldLiteGenerator::GetNumBitsForMessage() const {\n  return 1;\n}\n\nint ImmutableMessageFieldLiteGenerator::GetNumBitsForBuilder() const {\n  return 0;\n}\n\nvoid ImmutableMessageFieldLiteGenerator::\nGenerateInterfaceMembers(io::Printer* printer) const {\n  // TODO(jonp): In the future, consider having a method specific to the\n  // interface so that builders can choose dynamically to either return a\n  // message or a nested builder, so that asking for the interface doesn't\n  // cause a message to ever be built.\n  if (SupportFieldPresence(descriptor_->file()) ||\n      descriptor_->containing_oneof() == NULL) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$boolean has$capitalized_name$();\\n\");\n  }\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$$type$ get$capitalized_name$();\\n\");\n}\n\nvoid ImmutableMessageFieldLiteGenerator::\nGenerateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"private $type$ $name$_;\\n\");\n  PrintExtraFieldInfo(variables_, printer);\n\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $get_has_field_bit_message$;\\n\"\n      \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n      \"  return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\\n\"\n      \"}\\n\");\n  } else {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $name$_ != null;\\n\"\n      \"}\\n\");\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n      \"  return $name$_ == null ? $type$.getDefaultInstance() : $name$_;\\n\"\n      \"}\\n\");\n  }\n\n  // Field.Builder setField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$($type$ value) {\\n\"\n    \"  if (value == null) {\\n\"\n    \"    throw new NullPointerException();\\n\"\n    \"  }\\n\"\n    \"  $name$_ = value;\\n\"\n    \"  $set_has_field_bit_message$\\n\"\n    \"  }\\n\");\n\n  // Field.Builder setField(Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$(\\n\"\n    \"    $type$.Builder builderForValue) {\\n\"\n    \"  $name$_ = builderForValue.build();\\n\"\n    \"  $set_has_field_bit_message$\\n\"\n    \"}\\n\");\n\n  // Field.Builder mergeField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void merge$capitalized_name$($type$ value) {\\n\"\n    \"  if ($name$_ != null &&\\n\"\n    \"      $name$_ != $type$.getDefaultInstance()) {\\n\"\n    \"    $name$_ =\\n\"\n    \"      $type$.newBuilder($name$_).mergeFrom(value).buildPartial();\\n\"\n    \"  } else {\\n\"\n    \"    $name$_ = value;\\n\"\n    \"  }\\n\"\n    \"  $set_has_field_bit_message$\\n\"\n    \"}\\n\");\n\n  // Field.Builder clearField()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void clear$capitalized_name$() {\"\n    \"  $name$_ = null;\\n\"\n    \"  $clear_has_field_bit_message$\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableMessageFieldLiteGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  // The comments above the methods below are based on a hypothetical\n  // field of type \"Field\" called \"Field\".\n\n  // boolean hasField()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n    \"  return instance.has$capitalized_name$();\\n\"\n    \"}\\n\");\n\n  // Field getField()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  return instance.get$capitalized_name$();\\n\"\n    \"}\\n\");\n\n  // Field.Builder setField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$($type$ value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$(value);\\n\"\n    \"  return this;\\n\"\n    \"  }\\n\");\n\n  // Field.Builder setField(Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    $type$.Builder builderForValue) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$(builderForValue);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Field.Builder mergeField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder merge$capitalized_name$($type$ value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.merge$capitalized_name$(value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Field.Builder clearField()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.clear$capitalized_name$();\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableMessageFieldLiteGenerator::\nGenerateFieldBuilderInitializationCode(io::Printer* printer)  const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    printer->Print(variables_,\n      \"get$capitalized_name$FieldBuilder();\\n\");\n  }\n}\n\n\nvoid ImmutableMessageFieldLiteGenerator::\nGenerateInitializationCode(io::Printer* printer) const {}\n\nvoid ImmutableMessageFieldLiteGenerator::\nGenerateVisitCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$_ = visitor.visitMessage($name$_, other.$name$_);\\n\");\n}\n\nvoid ImmutableMessageFieldLiteGenerator::\nGenerateDynamicMethodMakeImmutableCode(io::Printer* printer) const {\n  // noop for scalars\n}\n\nvoid ImmutableMessageFieldLiteGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  // TODO(dweis): Update this code to avoid the builder allocation and instead\n  // only allocate a submessage that isn't made immutable. Rely on the top\n  // message calling makeImmutable once done to actually traverse the tree and\n  // finalize state. This will avoid:\n  // - transitive builder allocations\n  // - the extra transitive iteration for streamed fields\n  // - reallocations for copying repeated fields\n  printer->Print(variables_,\n      \"$type$.Builder subBuilder = null;\\n\"\n      \"if ($is_field_present_message$) {\\n\"\n      \"  subBuilder = $name$_.toBuilder();\\n\"\n      \"}\\n\");\n\n    if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) {\n      printer->Print(variables_,\n        \"$name$_ = input.readGroup($number$, $type$.parser(),\\n\"\n        \"    extensionRegistry);\\n\");\n    } else {\n      printer->Print(variables_,\n        \"$name$_ = input.readMessage($type$.parser(), extensionRegistry);\\n\");\n    }\n\n  printer->Print(variables_,\n    \"if (subBuilder != null) {\\n\"\n    \"  subBuilder.mergeFrom($name$_);\\n\"\n    \"  $name$_ = subBuilder.buildPartial();\\n\"\n    \"}\\n\"\n    \"$set_has_field_bit_message$\\n\");\n}\n\nvoid ImmutableMessageFieldLiteGenerator::\nGenerateParsingDoneCode(io::Printer* printer) const {\n  // noop for messages.\n}\n\nvoid ImmutableMessageFieldLiteGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($is_field_present_message$) {\\n\"\n    \"  output.write$group_or_message$($number$, get$capitalized_name$());\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableMessageFieldLiteGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($is_field_present_message$) {\\n\"\n    \"  size += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .compute$group_or_message$Size($number$, get$capitalized_name$());\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableMessageFieldLiteGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"result = result && get$capitalized_name$()\\n\"\n    \"    .equals(other.get$capitalized_name$());\\n\");\n}\n\nvoid ImmutableMessageFieldLiteGenerator::\nGenerateHashCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"hash = (37 * hash) + $constant_name$;\\n\"\n    \"hash = (53 * hash) + get$capitalized_name$().hashCode();\\n\");\n}\n\nstring ImmutableMessageFieldLiteGenerator::GetBoxedType() const {\n  return name_resolver_->GetImmutableClassName(descriptor_->message_type());\n}\n\n// ===================================================================\n\nImmutableMessageOneofFieldLiteGenerator::\nImmutableMessageOneofFieldLiteGenerator(const FieldDescriptor* descriptor,\n                                 int messageBitIndex,\n                                 int builderBitIndex,\n                                 Context* context)\n    : ImmutableMessageFieldLiteGenerator(\n          descriptor, messageBitIndex, builderBitIndex, context) {\n  const OneofGeneratorInfo* info =\n      context->GetOneofGeneratorInfo(descriptor->containing_oneof());\n  SetCommonOneofVariables(descriptor, info, &variables_);\n}\n\nImmutableMessageOneofFieldLiteGenerator::\n~ImmutableMessageOneofFieldLiteGenerator() {}\n\nvoid ImmutableMessageOneofFieldLiteGenerator::\nGenerateMembers(io::Printer* printer) const {\n  PrintExtraFieldInfo(variables_, printer);\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $has_oneof_case_message$;\\n\"\n      \"}\\n\");\n  }\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"     return ($type$) $oneof_name$_;\\n\"\n    \"  }\\n\"\n    \"  return $type$.getDefaultInstance();\\n\"\n    \"}\\n\");\n\n  // Field.Builder setField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$($type$ value) {\\n\"\n    \"  if (value == null) {\\n\"\n    \"    throw new NullPointerException();\\n\"\n    \"  }\\n\"\n    \"  $oneof_name$_ = value;\\n\"\n    \"  $set_oneof_case_message$;\\n\"\n    \"}\\n\");\n\n  // Field.Builder setField(Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$(\\n\"\n    \"    $type$.Builder builderForValue) {\\n\"\n    \"  $oneof_name$_ = builderForValue.build();\\n\"\n    \"  $set_oneof_case_message$;\\n\"\n    \"}\\n\");\n\n  // Field.Builder mergeField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void merge$capitalized_name$($type$ value) {\\n\"\n    \"  if ($has_oneof_case_message$ &&\\n\"\n    \"      $oneof_name$_ != $type$.getDefaultInstance()) {\\n\"\n    \"    $oneof_name$_ = $type$.newBuilder(($type$) $oneof_name$_)\\n\"\n    \"        .mergeFrom(value).buildPartial();\\n\"\n    \"  } else {\\n\"\n    \"    $oneof_name$_ = value;\\n\"\n    \"  }\\n\"\n    \"  $set_oneof_case_message$;\\n\"\n    \"}\\n\");\n\n  // Field.Builder clearField()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void clear$capitalized_name$() {\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    $clear_oneof_case_message$;\\n\"\n    \"    $oneof_name$_ = null;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableMessageOneofFieldLiteGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  // The comments above the methods below are based on a hypothetical\n  // field of type \"Field\" called \"Field\".\n\n  if (SupportFieldPresence(descriptor_->file())) {\n    // boolean hasField()\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return instance.has$capitalized_name$();\\n\"\n      \"}\\n\");\n  }\n\n  // Field getField()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  return instance.get$capitalized_name$();\\n\"\n    \"}\\n\");\n\n  // Field.Builder setField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$($type$ value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$(value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Field.Builder setField(Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    $type$.Builder builderForValue) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$(builderForValue);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Field.Builder mergeField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder merge$capitalized_name$($type$ value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.merge$capitalized_name$(value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Field.Builder clearField()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.clear$capitalized_name$();\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableMessageOneofFieldLiteGenerator::\nGenerateVisitCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$oneof_name$_ = visitor.visitOneofMessage(\\n\"\n    \"    $has_oneof_case_message$,\\n\"\n    \"    $oneof_name$_,\\n\"\n    \"    other.$oneof_name$_);\\n\");\n}\n\nvoid ImmutableMessageOneofFieldLiteGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$type$.Builder subBuilder = null;\\n\"\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  subBuilder = (($type$) $oneof_name$_).toBuilder();\\n\"\n    \"}\\n\");\n\n    if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) {\n      printer->Print(variables_,\n        \"$oneof_name$_ = input.readGroup($number$, $type$.parser(),\\n\"\n        \"    extensionRegistry);\\n\");\n    } else {\n      printer->Print(variables_,\n        \"$oneof_name$_ =\\n\"\n        \"     input.readMessage($type$.parser(), extensionRegistry);\\n\");\n    }\n\n  printer->Print(variables_,\n    \"if (subBuilder != null) {\\n\"\n    \"  subBuilder.mergeFrom(($type$) $oneof_name$_);\\n\"\n    \"  $oneof_name$_ = subBuilder.buildPartial();\\n\"\n    \"}\\n\");\n  printer->Print(variables_,\n    \"$set_oneof_case_message$;\\n\");\n}\n\nvoid ImmutableMessageOneofFieldLiteGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  output.write$group_or_message$($number$, ($type$) $oneof_name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableMessageOneofFieldLiteGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  size += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .compute$group_or_message$Size($number$, ($type$) $oneof_name$_);\\n\"\n    \"}\\n\");\n}\n\n// ===================================================================\n\nRepeatedImmutableMessageFieldLiteGenerator::\nRepeatedImmutableMessageFieldLiteGenerator(const FieldDescriptor* descriptor,\n                                       int messageBitIndex,\n                                       int builderBitIndex,\n                                       Context* context)\n  : descriptor_(descriptor), messageBitIndex_(messageBitIndex),\n    builderBitIndex_(builderBitIndex), context_(context),\n    name_resolver_(context->GetNameResolver())  {\n  SetMessageVariables(descriptor, messageBitIndex, builderBitIndex,\n                      context->GetFieldGeneratorInfo(descriptor),\n                      name_resolver_, &variables_);\n}\n\nRepeatedImmutableMessageFieldLiteGenerator::\n~RepeatedImmutableMessageFieldLiteGenerator() {}\n\nint RepeatedImmutableMessageFieldLiteGenerator::GetNumBitsForMessage() const {\n  return 0;\n}\n\nint RepeatedImmutableMessageFieldLiteGenerator::GetNumBitsForBuilder() const {\n  return 0;\n}\n\nvoid RepeatedImmutableMessageFieldLiteGenerator::\nGenerateInterfaceMembers(io::Printer* printer) const {\n  // TODO(jonp): In the future, consider having methods specific to the\n  // interface so that builders can choose dynamically to either return a\n  // message or a nested builder, so that asking for the interface doesn't\n  // cause a message to ever be built.\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$java.util.List<$type$> \\n\"\n    \"    get$capitalized_name$List();\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$$type$ get$capitalized_name$(int index);\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$int get$capitalized_name$Count();\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldLiteGenerator::\nGenerateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"private com.google.protobuf.Internal.ProtobufList<$type$> $name$_;\\n\");\n  PrintExtraFieldInfo(variables_, printer);\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.util.List<$type$> get$capitalized_name$List() {\\n\"\n    \"  return $name$_;\\n\"   // note:  unmodifiable list\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.util.List<? extends $type$OrBuilder> \\n\"\n    \"    get$capitalized_name$OrBuilderList() {\\n\"\n    \"  return $name$_;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public int get$capitalized_name$Count() {\\n\"\n    \"  return $name$_.size();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$(int index) {\\n\"\n    \"  return $name$_.get(index);\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$OrBuilder get$capitalized_name$OrBuilder(\\n\"\n    \"    int index) {\\n\"\n    \"  return $name$_.get(index);\\n\"\n    \"}\\n\");\n\n  printer->Print(variables_,\n    \"private void ensure$capitalized_name$IsMutable() {\\n\"\n    \"  if (!$is_mutable$) {\\n\"\n    \"    $name$_ =\\n\"\n    \"        com.google.protobuf.GeneratedMessageLite.mutableCopy($name$_);\\n\"\n    \"   }\\n\"\n    \"}\\n\"\n    \"\\n\");\n\n  // Builder setRepeatedField(int index, Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$(\\n\"\n    \"    int index, $type$ value) {\\n\"\n    \"  if (value == null) {\\n\"\n    \"    throw new NullPointerException();\\n\"\n    \"  }\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.set(index, value);\\n\"\n    \"}\\n\");\n\n  // Builder setRepeatedField(int index, Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$(\\n\"\n    \"    int index, $type$.Builder builderForValue) {\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.set(index, builderForValue.build());\\n\"\n    \"}\\n\");\n\n  // Builder addRepeatedField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void add$capitalized_name$($type$ value) {\\n\"\n    \"  if (value == null) {\\n\"\n    \"    throw new NullPointerException();\\n\"\n    \"  }\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.add(value);\\n\"\n    \"}\\n\");\n\n  // Builder addRepeatedField(int index, Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void add$capitalized_name$(\\n\"\n    \"    int index, $type$ value) {\\n\"\n    \"  if (value == null) {\\n\"\n    \"    throw new NullPointerException();\\n\"\n    \"  }\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.add(index, value);\\n\"\n    \"}\\n\");\n  // Builder addRepeatedField(Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void add$capitalized_name$(\\n\"\n    \"    $type$.Builder builderForValue) {\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.add(builderForValue.build());\\n\"\n    \"}\\n\");\n\n  // Builder addRepeatedField(int index, Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void add$capitalized_name$(\\n\"\n    \"    int index, $type$.Builder builderForValue) {\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.add(index, builderForValue.build());\\n\"\n    \"}\\n\");\n\n  // Builder addAllRepeatedField(Iterable<Field> values)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void addAll$capitalized_name$(\\n\"\n    \"    java.lang.Iterable<? extends $type$> values) {\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  com.google.protobuf.AbstractMessageLite.addAll(\\n\"\n    \"      values, $name$_);\\n\"\n    \"}\\n\");\n\n  // Builder clearAllRepeatedField()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void clear$capitalized_name$() {\\n\"\n    \"  $name$_ = emptyProtobufList();\\n\"\n    \"}\\n\");\n\n  // Builder removeRepeatedField(int index)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void remove$capitalized_name$(int index) {\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.remove(index);\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldLiteGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  // The comments above the methods below are based on a hypothetical\n  // repeated field of type \"Field\" called \"RepeatedField\".\n\n  // List<Field> getRepeatedFieldList()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.util.List<$type$> get$capitalized_name$List() {\\n\"\n    \"  return java.util.Collections.unmodifiableList(\\n\"\n    \"      instance.get$capitalized_name$List());\\n\"\n    \"}\\n\");\n\n  // int getRepeatedFieldCount()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public int get$capitalized_name$Count() {\\n\"\n    \"  return instance.get$capitalized_name$Count();\\n\"\n    \"}\");\n\n  // Field getRepeatedField(int index)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$(int index) {\\n\"\n    \"  return instance.get$capitalized_name$(index);\\n\"\n    \"}\\n\");\n\n  // Builder setRepeatedField(int index, Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    int index, $type$ value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$(index, value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Builder setRepeatedField(int index, Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    int index, $type$.Builder builderForValue) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$(index, builderForValue);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Builder addRepeatedField(Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder add$capitalized_name$($type$ value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.add$capitalized_name$(value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Builder addRepeatedField(int index, Field value)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder add$capitalized_name$(\\n\"\n    \"    int index, $type$ value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.add$capitalized_name$(index, value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  // Builder addRepeatedField(Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder add$capitalized_name$(\\n\"\n    \"    $type$.Builder builderForValue) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.add$capitalized_name$(builderForValue);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Builder addRepeatedField(int index, Field.Builder builderForValue)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder add$capitalized_name$(\\n\"\n    \"    int index, $type$.Builder builderForValue) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.add$capitalized_name$(index, builderForValue);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Builder addAllRepeatedField(Iterable<Field> values)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder addAll$capitalized_name$(\\n\"\n    \"    java.lang.Iterable<? extends $type$> values) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.addAll$capitalized_name$(values);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Builder clearAllRepeatedField()\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.clear$capitalized_name$();\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  // Builder removeRepeatedField(int index)\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder remove$capitalized_name$(int index) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.remove$capitalized_name$(index);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldLiteGenerator::\nGenerateFieldBuilderInitializationCode(io::Printer* printer)  const {\n  printer->Print(variables_,\n    \"get$capitalized_name$FieldBuilder();\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldLiteGenerator::\nGenerateInitializationCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_ = emptyProtobufList();\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldLiteGenerator::\nGenerateVisitCode(io::Printer* printer) const {\n  printer->Print(variables_,\n      \"$name$_= visitor.visitList($name$_, other.$name$_);\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldLiteGenerator::\nGenerateDynamicMethodMakeImmutableCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$_.makeImmutable();\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldLiteGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (!$is_mutable$) {\\n\"\n    \"  $name$_ =\\n\"\n    \"      com.google.protobuf.GeneratedMessageLite.mutableCopy($name$_);\\n\"\n    \"}\\n\");\n\n    if (GetType(descriptor_) == FieldDescriptor::TYPE_GROUP) {\n      printer->Print(variables_,\n        \"$name$_.add(input.readGroup($number$, $type$.parser(),\\n\"\n        \"    extensionRegistry));\\n\");\n    } else {\n      printer->Print(variables_,\n        \"$name$_.add(\\n\"\n        \"    input.readMessage($type$.parser(), extensionRegistry));\\n\");\n    }\n}\n\nvoid RepeatedImmutableMessageFieldLiteGenerator::\nGenerateParsingDoneCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($is_mutable$) {\\n\"\n    \"  $name$_.makeImmutable();\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldLiteGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n    \"  output.write$group_or_message$($number$, $name$_.get(i));\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldLiteGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n    \"  size += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .compute$group_or_message$Size($number$, $name$_.get(i));\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldLiteGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"result = result && get$capitalized_name$List()\\n\"\n    \"    .equals(other.get$capitalized_name$List());\\n\");\n}\n\nvoid RepeatedImmutableMessageFieldLiteGenerator::\nGenerateHashCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (get$capitalized_name$Count() > 0) {\\n\"\n    \"  hash = (37 * hash) + $constant_name$;\\n\"\n    \"  hash = (53 * hash) + get$capitalized_name$List().hashCode();\\n\"\n    \"}\\n\");\n}\n\nstring RepeatedImmutableMessageFieldLiteGenerator::GetBoxedType() const {\n  return name_resolver_->GetImmutableClassName(descriptor_->message_type());\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_message_field_lite.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_LITE_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_LITE_H__\n\n#include <map>\n#include <string>\n#include <google/protobuf/compiler/java/java_field.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace compiler {\n    namespace java {\n      class Context;           // context.h\n      class ClassNameResolver; // name_resolver.h\n    }\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nclass ImmutableMessageFieldLiteGenerator : public ImmutableFieldLiteGenerator {\n public:\n  explicit ImmutableMessageFieldLiteGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~ImmutableMessageFieldLiteGenerator();\n\n  // implements ImmutableFieldLiteGenerator ------------------------------------\n  int GetNumBitsForMessage() const;\n  int GetNumBitsForBuilder() const;\n  void GenerateInterfaceMembers(io::Printer* printer) const;\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateInitializationCode(io::Printer* printer) const;\n  void GenerateVisitCode(io::Printer* printer) const;\n  void GenerateDynamicMethodMakeImmutableCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateParsingDoneCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCode(io::Printer* printer) const;\n\n  string GetBoxedType() const;\n\n protected:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n  const int messageBitIndex_;\n  const int builderBitIndex_;\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageFieldLiteGenerator);\n};\n\nclass ImmutableMessageOneofFieldLiteGenerator\n    : public ImmutableMessageFieldLiteGenerator {\n public:\n  ImmutableMessageOneofFieldLiteGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~ImmutableMessageOneofFieldLiteGenerator();\n\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateVisitCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageOneofFieldLiteGenerator);\n};\n\nclass RepeatedImmutableMessageFieldLiteGenerator\n    : public ImmutableFieldLiteGenerator {\n public:\n  explicit RepeatedImmutableMessageFieldLiteGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~RepeatedImmutableMessageFieldLiteGenerator();\n\n  // implements ImmutableFieldLiteGenerator ------------------------------------\n  int GetNumBitsForMessage() const;\n  int GetNumBitsForBuilder() const;\n  void GenerateInterfaceMembers(io::Printer* printer) const;\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateInitializationCode(io::Printer* printer) const;\n  void GenerateVisitCode(io::Printer* printer) const;\n  void GenerateDynamicMethodMakeImmutableCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateParsingDoneCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCode(io::Printer* printer) const;\n\n  string GetBoxedType() const;\n\n protected:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n  const int messageBitIndex_;\n  const int builderBitIndex_;\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableMessageFieldLiteGenerator);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_FIELD_LITE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_message_lite.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: dweis@google.com (Daniel Weis)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/java/java_message_lite.h>\n\n#include <algorithm>\n#include <google/protobuf/stubs/hash.h>\n#include <map>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <vector>\n\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n#include <google/protobuf/compiler/java/java_enum_lite.h>\n#include <google/protobuf/compiler/java/java_extension_lite.h>\n#include <google/protobuf/compiler/java/java_generator_factory.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_message_builder.h>\n#include <google/protobuf/compiler/java/java_message_builder_lite.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nusing internal::WireFormat;\nusing internal::WireFormatLite;\n\nnamespace {\nbool GenerateHasBits(const Descriptor* descriptor) {\n  return SupportFieldPresence(descriptor->file()) ||\n      HasRepeatedFields(descriptor);\n}\n\nstring MapValueImmutableClassdName(const Descriptor* descriptor,\n                                   ClassNameResolver* name_resolver) {\n  const FieldDescriptor* value_field = descriptor->FindFieldByName(\"value\");\n  GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, value_field->type());\n  return name_resolver->GetImmutableClassName(value_field->message_type());\n}\n}  // namespace\n\n// ===================================================================\nImmutableMessageLiteGenerator::ImmutableMessageLiteGenerator(\n    const Descriptor* descriptor, Context* context)\n  : MessageGenerator(descriptor), context_(context),\n    name_resolver_(context->GetNameResolver()),\n    field_generators_(descriptor, context_) {\n  GOOGLE_CHECK(!HasDescriptorMethods(descriptor->file(), context->EnforceLite()))\n      << \"Generator factory error: A lite message generator is used to \"\n         \"generate non-lite messages.\";\n}\n\nImmutableMessageLiteGenerator::~ImmutableMessageLiteGenerator() {}\n\nvoid ImmutableMessageLiteGenerator::GenerateStaticVariables(\n    io::Printer* printer, int* bytecode_estimate) {\n  // Generate static members for all nested types.\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    // TODO(kenton):  Reuse MessageGenerator objects?\n    ImmutableMessageLiteGenerator(descriptor_->nested_type(i), context_)\n        .GenerateStaticVariables(printer, bytecode_estimate);\n  }\n}\n\nint ImmutableMessageLiteGenerator::GenerateStaticVariableInitializers(\n    io::Printer* printer) {\n  int bytecode_estimate = 0;\n  // Generate static member initializers for all nested types.\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    // TODO(kenton):  Reuse MessageGenerator objects?\n    bytecode_estimate +=\n        ImmutableMessageLiteGenerator(descriptor_->nested_type(i), context_)\n            .GenerateStaticVariableInitializers(printer);\n  }\n  return bytecode_estimate;\n}\n\n// ===================================================================\n\nvoid ImmutableMessageLiteGenerator::GenerateInterface(io::Printer* printer) {\n  MaybePrintGeneratedAnnotation(context_, printer, descriptor_,\n                                /* immutable = */ true, \"OrBuilder\");\n  if (descriptor_->extension_range_count() > 0) {\n    printer->Print(\n        \"public interface $classname$OrBuilder$idend$ extends \\n\"\n        \"    $extra_interfaces$\\n\"\n        \"     com.google.protobuf.GeneratedMessageLite.\\n\"\n        \"          ExtendableMessageOrBuilder<\\n\"\n        \"              $classname$, $classname$.Builder> {\\n\",\n        \"extra_interfaces\", ExtraMessageOrBuilderInterfaces(descriptor_),\n        \"classname\", descriptor_->name(),\n        \"idend\", \"\");\n  } else {\n    printer->Print(\n        \"public interface $classname$OrBuilder$idend$ extends\\n\"\n        \"    $extra_interfaces$\\n\"\n        \"    com.google.protobuf.MessageLiteOrBuilder {\\n\",\n        \"extra_interfaces\", ExtraMessageOrBuilderInterfaces(descriptor_),\n        \"classname\", descriptor_->name(),\n        \"idend\", \"\");\n  }\n  printer->Annotate(\"classname\", \"idend\", descriptor_);\n\n  printer->Indent();\n    for (int i = 0; i < descriptor_->field_count(); i++) {\n      printer->Print(\"\\n\");\n      field_generators_.get(descriptor_->field(i))\n                       .GenerateInterfaceMembers(printer);\n    }\n    for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n      printer->Print(\n          \"\\n\"\n          \"public $classname$.$oneof_capitalized_name$Case \"\n          \"get$oneof_capitalized_name$Case();\\n\",\n          \"oneof_capitalized_name\",\n          context_->GetOneofGeneratorInfo(\n              descriptor_->oneof_decl(i))->capitalized_name,\n          \"classname\",\n          context_->GetNameResolver()->GetImmutableClassName(descriptor_));\n    }\n  printer->Outdent();\n\n  printer->Print(\"}\\n\");\n}\n\n// ===================================================================\n\nvoid ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {\n  bool is_own_file = IsOwnFile(descriptor_, /* immutable = */ true);\n\n  map<string, string> variables;\n  variables[\"static\"] = is_own_file ? \" \" : \" static \";\n  variables[\"classname\"] = descriptor_->name();\n  variables[\"extra_interfaces\"] = ExtraMessageInterfaces(descriptor_);\n\n  WriteMessageDocComment(printer, descriptor_);\n  MaybePrintGeneratedAnnotation(context_, printer, descriptor_,\n                                /* immutable = */ true);\n\n  // The builder_type stores the super type name of the nested Builder class.\n  string builder_type;\n  if (descriptor_->extension_range_count() > 0) {\n    printer->Print(variables,\n      \"public $static$final class $classname$ extends\\n\"\n      \"    com.google.protobuf.GeneratedMessageLite.ExtendableMessage<\\n\"\n      \"      $classname$, $classname$.Builder> implements\\n\"\n      \"    $extra_interfaces$\\n\"\n      \"    $classname$OrBuilder {\\n\");\n    builder_type = strings::Substitute(\n        \"com.google.protobuf.GeneratedMessageLite.ExtendableBuilder<$0, ?>\",\n        name_resolver_->GetImmutableClassName(descriptor_));\n  } else {\n    printer->Print(variables,\n        \"public $static$final class $classname$ extends\\n\"\n        \"    com.google.protobuf.GeneratedMessageLite<\\n\"\n        \"        $classname$, $classname$.Builder> implements\\n\"\n        \"    $extra_interfaces$\\n\"\n        \"    $classname$OrBuilder {\\n\");\n\n    builder_type = \"com.google.protobuf.GeneratedMessageLite.Builder\";\n  }\n  printer->Indent();\n\n\n  GenerateConstructor(printer);\n\n  // Nested types\n  for (int i = 0; i < descriptor_->enum_type_count(); i++) {\n    EnumLiteGenerator(descriptor_->enum_type(i), true, context_)\n        .Generate(printer);\n  }\n\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    // Don't generate Java classes for map entry messages.\n    if (IsMapEntry(descriptor_->nested_type(i))) continue;\n    ImmutableMessageLiteGenerator messageGenerator(\n        descriptor_->nested_type(i), context_);\n    messageGenerator.GenerateInterface(printer);\n    messageGenerator.Generate(printer);\n  }\n\n  if (GenerateHasBits(descriptor_)) {\n    // Integers for bit fields.\n    int totalBits = 0;\n    for (int i = 0; i < descriptor_->field_count(); i++) {\n      totalBits += field_generators_.get(descriptor_->field(i))\n          .GetNumBitsForMessage();\n    }\n    int totalInts = (totalBits + 31) / 32;\n    for (int i = 0; i < totalInts; i++) {\n      printer->Print(\"private int $bit_field_name$;\\n\",\n        \"bit_field_name\", GetBitFieldName(i));\n    }\n  }\n\n  // oneof\n  map<string, string> vars;\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    vars[\"oneof_name\"] = context_->GetOneofGeneratorInfo(\n        descriptor_->oneof_decl(i))->name;\n    vars[\"oneof_capitalized_name\"] = context_->GetOneofGeneratorInfo(\n        descriptor_->oneof_decl(i))->capitalized_name;\n    vars[\"oneof_index\"] = SimpleItoa(descriptor_->oneof_decl(i)->index());\n    // oneofCase_ and oneof_\n    printer->Print(vars,\n      \"private int $oneof_name$Case_ = 0;\\n\"\n      \"private java.lang.Object $oneof_name$_;\\n\");\n    // OneofCase enum\n    printer->Print(vars,\n      \"public enum $oneof_capitalized_name$Case\\n\"\n      \"    implements com.google.protobuf.Internal.EnumLite {\\n\");\n    printer->Indent();\n    for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {\n      const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);\n      printer->Print(\n        \"$field_name$($field_number$),\\n\",\n        \"field_name\",\n        ToUpper(field->name()),\n        \"field_number\",\n        SimpleItoa(field->number()));\n    }\n    printer->Print(\n      \"$cap_oneof_name$_NOT_SET(0);\\n\",\n      \"cap_oneof_name\",\n      ToUpper(vars[\"oneof_name\"]));\n    printer->Print(vars,\n      \"private final int value;\\n\"\n      \"private $oneof_capitalized_name$Case(int value) {\\n\"\n      \"  this.value = value;\\n\"\n      \"}\\n\");\n    printer->Print(vars,\n      \"/**\\n\"\n      \" * @deprecated Use {@link #forNumber(int)} instead.\\n\"\n      \" */\\n\"\n      \"@java.lang.Deprecated\\n\"\n      \"public static $oneof_capitalized_name$Case valueOf(int value) {\\n\"\n      \"  return forNumber(value);\\n\"\n      \"}\\n\"\n      \"\\n\"\n      \"public static $oneof_capitalized_name$Case forNumber(int value) {\\n\"\n      \"  switch (value) {\\n\");\n    for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {\n      const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);\n      printer->Print(\n        \"    case $field_number$: return $field_name$;\\n\",\n        \"field_number\",\n        SimpleItoa(field->number()),\n        \"field_name\",\n        ToUpper(field->name()));\n    }\n    printer->Print(\n      \"    case 0: return $cap_oneof_name$_NOT_SET;\\n\"\n      \"    default: return null;\\n\"\n      \"  }\\n\"\n      \"}\\n\"\n      \"public int getNumber() {\\n\"\n      \"  return this.value;\\n\"\n      \"}\\n\",\n      \"cap_oneof_name\", ToUpper(vars[\"oneof_name\"]));\n    printer->Outdent();\n    printer->Print(\"};\\n\\n\");\n    // oneofCase()\n    printer->Print(vars,\n      \"public $oneof_capitalized_name$Case\\n\"\n      \"get$oneof_capitalized_name$Case() {\\n\"\n      \"  return $oneof_capitalized_name$Case.forNumber(\\n\"\n      \"      $oneof_name$Case_);\\n\"\n      \"}\\n\"\n      \"\\n\"\n      \"private void clear$oneof_capitalized_name$() {\\n\"\n      \"  $oneof_name$Case_ = 0;\\n\"\n      \"  $oneof_name$_ = null;\\n\"\n      \"}\\n\"\n      \"\\n\");\n  }\n\n  // Fields\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    printer->Print(\"public static final int $constant_name$ = $number$;\\n\",\n      \"constant_name\", FieldConstantName(descriptor_->field(i)),\n      \"number\", SimpleItoa(descriptor_->field(i)->number()));\n    field_generators_.get(descriptor_->field(i)).GenerateMembers(printer);\n    printer->Print(\"\\n\");\n  }\n\n  GenerateMessageSerializationMethods(printer);\n\n  GenerateParseFromMethods(printer);\n  GenerateBuilder(printer);\n\n  if (HasRequiredFields(descriptor_)) {\n    // Memoizes whether the protocol buffer is fully initialized (has all\n    // required fields). -1 means not yet computed. 0 means false and 1 means\n    // true.\n    printer->Print(\n      \"private byte memoizedIsInitialized = -1;\\n\");\n  }\n\n  printer->Print(\n    \"protected final Object dynamicMethod(\\n\"\n    \"    com.google.protobuf.GeneratedMessageLite.MethodToInvoke method,\\n\"\n    \"    Object arg0, Object arg1) {\\n\"\n    \"  switch (method) {\\n\"\n    \"    case NEW_MUTABLE_INSTANCE: {\\n\"\n    \"      return new $classname$();\\n\"\n    \"    }\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n\n  printer->Indent();\n  printer->Indent();\n\n  printer->Print(\n    \"case IS_INITIALIZED: {\\n\");\n  printer->Indent();\n  GenerateDynamicMethodIsInitialized(printer);\n  printer->Outdent();\n\n  printer->Print(\n    \"}\\n\"\n    \"case MAKE_IMMUTABLE: {\\n\");\n\n  printer->Indent();\n  GenerateDynamicMethodMakeImmutable(printer);\n  printer->Outdent();\n\n  printer->Print(\n    \"}\\n\"\n    \"case NEW_BUILDER: {\\n\");\n\n  printer->Indent();\n  GenerateDynamicMethodNewBuilder(printer);\n  printer->Outdent();\n\n  printer->Print(\n    \"}\\n\"\n    \"case VISIT: {\\n\");\n\n  printer->Indent();\n  GenerateDynamicMethodVisit(printer);\n  printer->Outdent();\n\n  printer->Print(\n    \"}\\n\"\n    \"case MERGE_FROM_STREAM: {\\n\");\n\n  printer->Indent();\n  GenerateDynamicMethodMergeFromStream(printer);\n  printer->Outdent();\n\n  printer->Print(\n    \"}\\n\"\n    \"case GET_DEFAULT_INSTANCE: {\\n\"\n    \"  return DEFAULT_INSTANCE;\\n\"\n    \"}\\n\"\n    \"case GET_PARSER: {\\n\"\n    // Generally one would use the lazy initialization holder pattern for\n    // manipulating static fields but that has exceptional cost on Android as\n    // it will generate an extra class for every message. Instead, use the\n    // double-check locking pattern which works just as well.\n    \"  if (PARSER == null) {\"\n    \"    synchronized ($classname$.class) {\\n\"\n    \"      if (PARSER == null) {\\n\"\n    \"        PARSER = new DefaultInstanceBasedParser(DEFAULT_INSTANCE);\\n\"\n    \"      }\\n\"\n    \"    }\\n\"\n    \"  }\\n\"\n    \"  return PARSER;\\n\"\n    \"}\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n\n  printer->Outdent();\n  printer->Outdent();\n\n  printer->Print(\n    \"  }\\n\"\n    \"  throw new UnsupportedOperationException();\\n\"\n    \"}\\n\"\n    \"\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n\n  printer->Print(\n    \"\\n\"\n    \"// @@protoc_insertion_point(class_scope:$full_name$)\\n\",\n    \"full_name\", descriptor_->full_name());\n\n\n  // Carefully initialize the default instance in such a way that it doesn't\n  // conflict with other initialization.\n  printer->Print(\n    \"private static final $classname$ DEFAULT_INSTANCE;\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n\n  printer->Print(\n    \"static {\\n\"\n    \"  DEFAULT_INSTANCE = new $classname$();\\n\"\n    \"  DEFAULT_INSTANCE.makeImmutable();\\n\"\n    \"}\\n\"\n    \"\\n\",\n    \"classname\", descriptor_->name());\n  printer->Print(\n      \"public static $classname$ getDefaultInstance() {\\n\"\n      \"  return DEFAULT_INSTANCE;\\n\"\n      \"}\\n\"\n      \"\\n\",\n      \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n\n  GenerateParser(printer);\n\n  // Extensions must be declared after the DEFAULT_INSTANCE is initialized\n  // because the DEFAULT_INSTANCE is used by the extension to lazily retrieve\n  // the outer class's FileDescriptor.\n  for (int i = 0; i < descriptor_->extension_count(); i++) {\n    ImmutableExtensionLiteGenerator(descriptor_->extension(i), context_)\n        .Generate(printer);\n  }\n\n  printer->Outdent();\n  printer->Print(\"}\\n\\n\");\n}\n\n// ===================================================================\n\nvoid ImmutableMessageLiteGenerator::\nGenerateMessageSerializationMethods(io::Printer* printer) {\n  google::protobuf::scoped_array<const FieldDescriptor * > sorted_fields(\n      SortFieldsByNumber(descriptor_));\n\n  vector<const Descriptor::ExtensionRange*> sorted_extensions;\n  for (int i = 0; i < descriptor_->extension_range_count(); ++i) {\n    sorted_extensions.push_back(descriptor_->extension_range(i));\n  }\n  std::sort(sorted_extensions.begin(), sorted_extensions.end(),\n            ExtensionRangeOrdering());\n\n  printer->Print(\n    \"public void writeTo(com.google.protobuf.CodedOutputStream output)\\n\"\n    \"                    throws java.io.IOException {\\n\");\n  printer->Indent();\n  if (HasPackedFields(descriptor_)) {\n    // writeTo(CodedOutputStream output) might be invoked without\n    // getSerializedSize() ever being called, but we need the memoized\n    // sizes in case this message has packed fields. Rather than emit checks for\n    // each packed field, just call getSerializedSize() up front.\n    // In most cases, getSerializedSize() will have already been called anyway\n    // by one of the wrapper writeTo() methods, making this call cheap.\n    printer->Print(\n      \"getSerializedSize();\\n\");\n  }\n\n  if (descriptor_->extension_range_count() > 0) {\n    if (descriptor_->options().message_set_wire_format()) {\n      printer->Print(\n        \"com.google.protobuf.GeneratedMessageLite\\n\"\n        \"  .ExtendableMessage<$classname$, $classname$.Builder>\\n\"\n        \"    .ExtensionWriter extensionWriter =\\n\"\n        \"      newMessageSetExtensionWriter();\\n\",\n        \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n    } else {\n      printer->Print(\n        \"com.google.protobuf.GeneratedMessageLite\\n\"\n        \"  .ExtendableMessage<$classname$, $classname$.Builder>\\n\"\n        \"    .ExtensionWriter extensionWriter =\\n\"\n        \"      newExtensionWriter();\\n\",\n        \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n    }\n  }\n\n  // Merge the fields and the extension ranges, both sorted by field number.\n  for (int i = 0, j = 0;\n       i < descriptor_->field_count() || j < sorted_extensions.size();\n       ) {\n    if (i == descriptor_->field_count()) {\n      GenerateSerializeOneExtensionRange(printer, sorted_extensions[j++]);\n    } else if (j == sorted_extensions.size()) {\n      GenerateSerializeOneField(printer, sorted_fields[i++]);\n    } else if (sorted_fields[i]->number() < sorted_extensions[j]->start) {\n      GenerateSerializeOneField(printer, sorted_fields[i++]);\n    } else {\n      GenerateSerializeOneExtensionRange(printer, sorted_extensions[j++]);\n    }\n  }\n\n  if (PreserveUnknownFields(descriptor_)) {\n    printer->Print(\n      \"unknownFields.writeTo(output);\\n\");\n  }\n\n  printer->Outdent();\n  printer->Print(\n    \"}\\n\"\n    \"\\n\"\n    \"public int getSerializedSize() {\\n\"\n    \"  int size = memoizedSerializedSize;\\n\"\n    \"  if (size != -1) return size;\\n\"\n    \"\\n\"\n    \"  size = 0;\\n\");\n  printer->Indent();\n\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    field_generators_.get(sorted_fields[i]).GenerateSerializedSizeCode(printer);\n  }\n\n  if (descriptor_->extension_range_count() > 0) {\n    if (descriptor_->options().message_set_wire_format()) {\n      printer->Print(\n        \"size += extensionsSerializedSizeAsMessageSet();\\n\");\n    } else {\n      printer->Print(\n        \"size += extensionsSerializedSize();\\n\");\n    }\n  }\n\n  if (PreserveUnknownFields(descriptor_)) {\n    printer->Print(\n      \"size += unknownFields.getSerializedSize();\\n\");\n  }\n\n  printer->Outdent();\n  printer->Print(\n    \"  memoizedSerializedSize = size;\\n\"\n    \"  return size;\\n\"\n    \"}\\n\"\n    \"\\n\");\n}\n\nvoid ImmutableMessageLiteGenerator::\nGenerateParseFromMethods(io::Printer* printer) {\n  // Note:  These are separate from GenerateMessageSerializationMethods()\n  //   because they need to be generated even for messages that are optimized\n  //   for code size.\n  printer->Print(\n    \"public static $classname$ parseFrom(\\n\"\n    \"    com.google.protobuf.ByteString data)\\n\"\n    \"    throws com.google.protobuf.InvalidProtocolBufferException {\\n\"\n    \"  return com.google.protobuf.GeneratedMessageLite.parseFrom(\\n\"\n    \"      DEFAULT_INSTANCE, data);\\n\"\n    \"}\\n\"\n    \"public static $classname$ parseFrom(\\n\"\n    \"    com.google.protobuf.ByteString data,\\n\"\n    \"    com.google.protobuf.ExtensionRegistryLite extensionRegistry)\\n\"\n    \"    throws com.google.protobuf.InvalidProtocolBufferException {\\n\"\n    \"  return com.google.protobuf.GeneratedMessageLite.parseFrom(\\n\"\n    \"      DEFAULT_INSTANCE, data, extensionRegistry);\\n\"\n    \"}\\n\"\n    \"public static $classname$ parseFrom(byte[] data)\\n\"\n    \"    throws com.google.protobuf.InvalidProtocolBufferException {\\n\"\n    \"  return com.google.protobuf.GeneratedMessageLite.parseFrom(\\n\"\n    \"      DEFAULT_INSTANCE, data);\\n\"\n    \"}\\n\"\n    \"public static $classname$ parseFrom(\\n\"\n    \"    byte[] data,\\n\"\n    \"    com.google.protobuf.ExtensionRegistryLite extensionRegistry)\\n\"\n    \"    throws com.google.protobuf.InvalidProtocolBufferException {\\n\"\n    \"  return com.google.protobuf.GeneratedMessageLite.parseFrom(\\n\"\n    \"      DEFAULT_INSTANCE, data, extensionRegistry);\\n\"\n    \"}\\n\"\n    \"public static $classname$ parseFrom(java.io.InputStream input)\\n\"\n    \"    throws java.io.IOException {\\n\"\n    \"  return com.google.protobuf.GeneratedMessageLite.parseFrom(\\n\"\n    \"      DEFAULT_INSTANCE, input);\\n\"\n    \"}\\n\"\n    \"public static $classname$ parseFrom(\\n\"\n    \"    java.io.InputStream input,\\n\"\n    \"    com.google.protobuf.ExtensionRegistryLite extensionRegistry)\\n\"\n    \"    throws java.io.IOException {\\n\"\n    \"  return com.google.protobuf.GeneratedMessageLite.parseFrom(\\n\"\n    \"      DEFAULT_INSTANCE, input, extensionRegistry);\\n\"\n    \"}\\n\"\n    \"public static $classname$ parseDelimitedFrom(java.io.InputStream input)\\n\"\n    \"    throws java.io.IOException {\\n\"\n    \"  return parseDelimitedFrom(DEFAULT_INSTANCE, input);\\n\"\n    \"}\\n\"\n    \"public static $classname$ parseDelimitedFrom(\\n\"\n    \"    java.io.InputStream input,\\n\"\n    \"    com.google.protobuf.ExtensionRegistryLite extensionRegistry)\\n\"\n    \"    throws java.io.IOException {\\n\"\n    \"  return parseDelimitedFrom(DEFAULT_INSTANCE, input, extensionRegistry);\\n\"\n    \"}\\n\"\n    \"public static $classname$ parseFrom(\\n\"\n    \"    com.google.protobuf.CodedInputStream input)\\n\"\n    \"    throws java.io.IOException {\\n\"\n    \"  return com.google.protobuf.GeneratedMessageLite.parseFrom(\\n\"\n    \"      DEFAULT_INSTANCE, input);\\n\"\n    \"}\\n\"\n    \"public static $classname$ parseFrom(\\n\"\n    \"    com.google.protobuf.CodedInputStream input,\\n\"\n    \"    com.google.protobuf.ExtensionRegistryLite extensionRegistry)\\n\"\n    \"    throws java.io.IOException {\\n\"\n    \"  return com.google.protobuf.GeneratedMessageLite.parseFrom(\\n\"\n    \"      DEFAULT_INSTANCE, input, extensionRegistry);\\n\"\n    \"}\\n\"\n    \"\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n}\n\nvoid ImmutableMessageLiteGenerator::GenerateSerializeOneField(\n    io::Printer* printer, const FieldDescriptor* field) {\n  field_generators_.get(field).GenerateSerializationCode(printer);\n}\n\nvoid ImmutableMessageLiteGenerator::GenerateSerializeOneExtensionRange(\n    io::Printer* printer, const Descriptor::ExtensionRange* range) {\n  printer->Print(\n    \"extensionWriter.writeUntil($end$, output);\\n\",\n    \"end\", SimpleItoa(range->end));\n}\n\n// ===================================================================\n\nvoid ImmutableMessageLiteGenerator::GenerateBuilder(io::Printer* printer) {\n  printer->Print(\n    \"public static Builder newBuilder() {\\n\"\n    \"  return DEFAULT_INSTANCE.toBuilder();\\n\"\n    \"}\\n\"\n    \"public static Builder newBuilder($classname$ prototype) {\\n\"\n    \"  return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);\\n\"\n    \"}\\n\"\n    \"\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n\n  MessageBuilderLiteGenerator builderGenerator(descriptor_, context_);\n  builderGenerator.Generate(printer);\n}\n\n// ===================================================================\n\nvoid ImmutableMessageLiteGenerator::GenerateDynamicMethodIsInitialized(\n    io::Printer* printer) {\n  // Returns null for false, DEFAULT_INSTANCE for true.\n  if (!HasRequiredFields(descriptor_)) {\n    printer->Print(\"return DEFAULT_INSTANCE;\\n\");\n    return;\n  }\n\n  // Don't directly compare to -1 to avoid an Android x86 JIT bug.\n  printer->Print(\n    \"byte isInitialized = memoizedIsInitialized;\\n\"\n    \"if (isInitialized == 1) return DEFAULT_INSTANCE;\\n\"\n    \"if (isInitialized == 0) return null;\\n\"\n    \"\\n\"\n    \"boolean shouldMemoize = ((Boolean) arg0).booleanValue();\\n\");\n\n  // Check that all required fields in this message are set.\n  // TODO(kenton):  We can optimize this when we switch to putting all the\n  //   \"has\" fields into a single bitfield.\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n    const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);\n\n    if (field->is_required()) {\n      printer->Print(\n        \"if (!has$name$()) {\\n\"\n        \"  if (shouldMemoize) {\\n\"\n        \"    memoizedIsInitialized = 0;\\n\"\n        \"  }\\n\"\n        \"  return null;\\n\"\n        \"}\\n\",\n        \"name\", info->capitalized_name);\n    }\n  }\n\n  // Now check that all embedded messages are initialized.\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n    const FieldGeneratorInfo* info = context_->GetFieldGeneratorInfo(field);\n    if (GetJavaType(field) == JAVATYPE_MESSAGE &&\n        HasRequiredFields(field->message_type())) {\n      switch (field->label()) {\n        case FieldDescriptor::LABEL_REQUIRED:\n          printer->Print(\n            \"if (!get$name$().isInitialized()) {\\n\"\n            \"  if (shouldMemoize) {\\n\"\n            \"    memoizedIsInitialized = 0;\\n\"\n            \"  }\\n\"\n            \"  return null;\\n\"\n            \"}\\n\",\n            \"type\", name_resolver_->GetImmutableClassName(\n                field->message_type()),\n            \"name\", info->capitalized_name);\n          break;\n        case FieldDescriptor::LABEL_OPTIONAL:\n          if (!SupportFieldPresence(descriptor_->file()) &&\n              field->containing_oneof() != NULL) {\n            const OneofDescriptor* oneof = field->containing_oneof();\n            const OneofGeneratorInfo* oneof_info =\n                context_->GetOneofGeneratorInfo(oneof);\n            printer->Print(\n              \"if ($oneof_name$Case_ == $field_number$) {\\n\",\n              \"oneof_name\", oneof_info->name,\n              \"field_number\", SimpleItoa(field->number()));\n          } else {\n            printer->Print(\n              \"if (has$name$()) {\\n\",\n              \"name\", info->capitalized_name);\n          }\n          printer->Print(\n            \"  if (!get$name$().isInitialized()) {\\n\"\n            \"    if (shouldMemoize) {\\n\"\n            \"      memoizedIsInitialized = 0;\\n\"\n            \"    }\\n\"\n            \"    return null;\\n\"\n            \"  }\\n\"\n            \"}\\n\",\n            \"name\", info->capitalized_name);\n          break;\n        case FieldDescriptor::LABEL_REPEATED:\n          if (IsMapEntry(field->message_type())) {\n            printer->Print(\n              \"for ($type$ item : get$name$().values()) {\\n\"\n              \"  if (!item.isInitialized()) {\\n\"\n              \"    if (shouldMemoize) {\\n\"\n              \"      memoizedIsInitialized = 0;\\n\"\n              \"    }\\n\"\n              \"    return null;\\n\"\n              \"  }\\n\"\n              \"}\\n\",\n              \"type\", MapValueImmutableClassdName(field->message_type(),\n                                                  name_resolver_),\n              \"name\", info->capitalized_name);\n          } else {\n            printer->Print(\n              \"for (int i = 0; i < get$name$Count(); i++) {\\n\"\n              \"  if (!get$name$(i).isInitialized()) {\\n\"\n              \"    if (shouldMemoize) {\\n\"\n              \"      memoizedIsInitialized = 0;\\n\"\n              \"    }\\n\"\n              \"    return null;\\n\"\n              \"  }\\n\"\n              \"}\\n\",\n              \"type\", name_resolver_->GetImmutableClassName(\n                  field->message_type()),\n              \"name\", info->capitalized_name);\n          }\n          break;\n      }\n    }\n  }\n\n  if (descriptor_->extension_range_count() > 0) {\n    printer->Print(\n      \"if (!extensionsAreInitialized()) {\\n\"\n      \"  if (shouldMemoize) {\\n\"\n      \"    memoizedIsInitialized = 0;\\n\"\n      \"  }\\n\"\n      \"  return null;\\n\"\n      \"}\\n\");\n  }\n\n  printer->Print(\n    \"if (shouldMemoize) memoizedIsInitialized = 1;\\n\");\n\n  printer->Print(\n    \"return DEFAULT_INSTANCE;\\n\"\n    \"\\n\");\n}\n\n// ===================================================================\n\nvoid ImmutableMessageLiteGenerator::GenerateDynamicMethodMakeImmutable(\n    io::Printer* printer) {\n\n  // Output generation code for each field.\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    field_generators_.get(descriptor_->field(i))\n        .GenerateDynamicMethodMakeImmutableCode(printer);\n  }\n\n  printer->Print(\n    \"return null;\\n\");\n}\n\n// ===================================================================\n\nvoid ImmutableMessageLiteGenerator::GenerateDynamicMethodNewBuilder(\n    io::Printer* printer) {\n  printer->Print(\n    \"return new Builder();\\n\");\n}\n\n// ===================================================================\n\nvoid ImmutableMessageLiteGenerator::GenerateDynamicMethodVisit(\n    io::Printer* printer) {\n  printer->Print(\n    \"Visitor visitor = (Visitor) arg0;\\n\"\n    \"$classname$ other = ($classname$) arg1;\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    if (!descriptor_->field(i)->containing_oneof()) {\n      field_generators_.get(\n          descriptor_->field(i)).GenerateVisitCode(printer);\n    }\n  }\n\n  // Merge oneof fields.\n  for (int i = 0; i < descriptor_->oneof_decl_count(); ++i) {\n    printer->Print(\n      \"switch (other.get$oneof_capitalized_name$Case()) {\\n\",\n      \"oneof_capitalized_name\",\n      context_->GetOneofGeneratorInfo(\n          descriptor_->oneof_decl(i))->capitalized_name);\n    printer->Indent();\n    for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {\n      const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);\n      printer->Print(\n        \"case $field_name$: {\\n\",\n        \"field_name\",\n        ToUpper(field->name()));\n      printer->Indent();\n      field_generators_.get(field).GenerateVisitCode(printer);\n      printer->Print(\n          \"break;\\n\");\n      printer->Outdent();\n      printer->Print(\n          \"}\\n\");\n    }\n    printer->Print(\n      \"case $cap_oneof_name$_NOT_SET: {\\n\"\n      \"  visitor.visitOneofNotSet($oneof_name$Case_ != 0);\\n\"\n      \"  break;\\n\"\n      \"}\\n\",\n      \"cap_oneof_name\",\n      ToUpper(context_->GetOneofGeneratorInfo(\n          descriptor_->oneof_decl(i))->name),\n      \"oneof_name\",\n      context_->GetOneofGeneratorInfo(\n          descriptor_->oneof_decl(i))->name);\n    printer->Outdent();\n    printer->Print(\n      \"}\\n\");\n  }\n\n  printer->Print(\n    \"if (visitor == com.google.protobuf.GeneratedMessageLite.MergeFromVisitor\\n\"\n    \"    .INSTANCE) {\\n\");\n  printer->Indent();\n  for (int i = 0; i < descriptor_->oneof_decl_count(); ++i) {\n    const OneofDescriptor* field = descriptor_->oneof_decl(i);\n    printer->Print(\n      \"if (other.$oneof_name$Case_ != 0) {\\n\"\n      \"  $oneof_name$Case_ = other.$oneof_name$Case_;\\n\"\n      \"}\\n\",\n      \"oneof_name\", context_->GetOneofGeneratorInfo(field)->name);\n  }\n\n  if (GenerateHasBits(descriptor_)) {\n    // Integers for bit fields.\n    int totalBits = 0;\n    for (int i = 0; i < descriptor_->field_count(); i++) {\n      totalBits += field_generators_.get(descriptor_->field(i))\n          .GetNumBitsForMessage();\n    }\n    int totalInts = (totalBits + 31) / 32;\n\n    for (int i = 0; i < totalInts; i++) {\n      printer->Print(\n        \"$bit_field_name$ |= other.$bit_field_name$;\\n\",\n        \"bit_field_name\", GetBitFieldName(i));\n    }\n  }\n  printer->Outdent();\n  printer->Print(\n    \"}\\n\");\n\n\n  printer->Print(\n    \"return this;\\n\");\n}\n\n// ===================================================================\n\nvoid ImmutableMessageLiteGenerator::GenerateDynamicMethodMergeFromStream(\n    io::Printer* printer) {\n  printer->Print(\n      \"com.google.protobuf.CodedInputStream input =\\n\"\n      \"    (com.google.protobuf.CodedInputStream) arg0;\\n\"\n      \"com.google.protobuf.ExtensionRegistryLite extensionRegistry =\\n\"\n      \"    (com.google.protobuf.ExtensionRegistryLite) arg1;\\n\"\n      \"try {\\n\");\n  printer->Indent();\n\n  printer->Print(\n    \"boolean done = false;\\n\"\n    \"while (!done) {\\n\");\n  printer->Indent();\n\n  printer->Print(\n    \"int tag = input.readTag();\\n\"\n    \"switch (tag) {\\n\");\n  printer->Indent();\n\n  printer->Print(\n    \"case 0:\\n\"          // zero signals EOF / limit reached\n    \"  done = true;\\n\"\n    \"  break;\\n\");\n\n  if (PreserveUnknownFields(descriptor_)) {\n    if (descriptor_->extension_range_count() > 0) {\n      printer->Print(\n        \"default: {\\n\"\n        \"  if (!parseUnknownField(getDefaultInstanceForType(),\\n\"\n        \"                         input, extensionRegistry, tag)) {\\n\"\n        \"    done = true;\\n\"  // it's an endgroup tag\n        \"  }\\n\"\n        \"  break;\\n\"\n        \"}\\n\");\n    } else {\n      printer->Print(\n        \"default: {\\n\"\n        \"  if (!parseUnknownField(tag, input)) {\\n\"\n        \"    done = true;\\n\"  // it's an endgroup tag\n        \"  }\\n\"\n        \"  break;\\n\"\n        \"}\\n\");\n    }\n  } else {\n    printer->Print(\n      \"default: {\\n\"\n      \"  if (!input.skipField(tag)) {\\n\"\n      \"    done = true;\\n\"  // it's an endgroup tag\n      \"  }\\n\"\n      \"  break;\\n\"\n      \"}\\n\");\n  }\n\n  google::protobuf::scoped_array<const FieldDescriptor * > sorted_fields(\n      SortFieldsByNumber(descriptor_));\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = sorted_fields[i];\n    uint32 tag = WireFormatLite::MakeTag(field->number(),\n      WireFormat::WireTypeForFieldType(field->type()));\n\n    printer->Print(\n      \"case $tag$: {\\n\",\n      \"tag\", SimpleItoa(tag));\n    printer->Indent();\n\n    field_generators_.get(field).GenerateParsingCode(printer);\n\n    printer->Outdent();\n    printer->Print(\n      \"  break;\\n\"\n      \"}\\n\");\n\n    if (field->is_packable()) {\n      // To make packed = true wire compatible, we generate parsing code from a\n      // packed version of this field regardless of field->options().packed().\n      uint32 packed_tag = WireFormatLite::MakeTag(field->number(),\n        WireFormatLite::WIRETYPE_LENGTH_DELIMITED);\n      printer->Print(\n        \"case $tag$: {\\n\",\n        \"tag\", SimpleItoa(packed_tag));\n      printer->Indent();\n\n      field_generators_.get(field).GenerateParsingCodeFromPacked(printer);\n\n      printer->Outdent();\n      printer->Print(\n        \"  break;\\n\"\n        \"}\\n\");\n    }\n  }\n\n  printer->Outdent();\n  printer->Outdent();\n  printer->Print(\n      \"  }\\n\"     // switch (tag)\n      \"}\\n\");     // while (!done)\n\n  printer->Outdent();\n  printer->Print(\n      \"} catch (com.google.protobuf.InvalidProtocolBufferException e) {\\n\"\n      \"  throw new RuntimeException(e.setUnfinishedMessage(this));\\n\"\n      \"} catch (java.io.IOException e) {\\n\"\n      \"  throw new RuntimeException(\\n\"\n      \"      new com.google.protobuf.InvalidProtocolBufferException(\\n\"\n      \"          e.getMessage()).setUnfinishedMessage(this));\\n\"\n      \"} finally {\\n\");\n  printer->Indent();\n\n  printer->Outdent();\n  printer->Print(\n      \"}\\n\");     // finally\n}\n\n// ===================================================================\n\nnamespace {\nbool CheckHasBitsForEqualsAndHashCode(const FieldDescriptor* field) {\n  if (field->is_repeated()) {\n    return false;\n  }\n  if (SupportFieldPresence(field->file())) {\n    return true;\n  }\n  return GetJavaType(field) == JAVATYPE_MESSAGE &&\n      field->containing_oneof() == NULL;\n}\n}  // namespace\n\n// ===================================================================\n\nvoid ImmutableMessageLiteGenerator::\nGenerateExtensionRegistrationCode(io::Printer* printer) {\n  for (int i = 0; i < descriptor_->extension_count(); i++) {\n    ImmutableExtensionLiteGenerator(descriptor_->extension(i), context_)\n      .GenerateRegistrationCode(printer);\n  }\n\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    ImmutableMessageLiteGenerator(descriptor_->nested_type(i), context_)\n      .GenerateExtensionRegistrationCode(printer);\n  }\n}\n\n// ===================================================================\nvoid ImmutableMessageLiteGenerator::\nGenerateConstructor(io::Printer* printer) {\n  printer->Print(\n      \"private $classname$() {\\n\",\n      \"classname\", descriptor_->name());\n  printer->Indent();\n\n  // Initialize all fields to default.\n  GenerateInitializers(printer);\n\n  printer->Outdent();\n  printer->Print(\n      \"}\\n\");\n}\n\n// ===================================================================\nvoid ImmutableMessageLiteGenerator::GenerateParser(io::Printer* printer) {\n  printer->Print(\n      \"private static volatile com.google.protobuf.Parser<$classname$> PARSER;\\n\"\n      \"\\n\"\n      \"public static com.google.protobuf.Parser<$classname$> parser() {\\n\"\n      \"  return DEFAULT_INSTANCE.getParserForType();\\n\"\n      \"}\\n\",\n      \"classname\", descriptor_->name());\n}\n\n// ===================================================================\nvoid ImmutableMessageLiteGenerator::GenerateInitializers(io::Printer* printer) {\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    if (!descriptor_->field(i)->containing_oneof()) {\n      field_generators_.get(descriptor_->field(i))\n          .GenerateInitializationCode(printer);\n    }\n  }\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_message_lite.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: dweis@google.com (Daniel Weis)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_LITE_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_LITE_H__\n\n#include <string>\n#include <map>\n#include <google/protobuf/compiler/java/java_field.h>\n#include <google/protobuf/compiler/java/java_message.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nclass ImmutableMessageLiteGenerator : public MessageGenerator {\n public:\n  ImmutableMessageLiteGenerator(const Descriptor* descriptor, Context* context);\n  virtual ~ImmutableMessageLiteGenerator();\n\n  virtual void Generate(io::Printer* printer);\n  virtual void GenerateInterface(io::Printer* printer);\n  virtual void GenerateExtensionRegistrationCode(io::Printer* printer);\n  virtual void GenerateStaticVariables(\n      io::Printer* printer, int* bytecode_estimate);\n  virtual int GenerateStaticVariableInitializers(io::Printer* printer);\n\n private:\n\n  void GenerateMessageSerializationMethods(io::Printer* printer);\n  void GenerateParseFromMethods(io::Printer* printer);\n  void GenerateSerializeOneField(io::Printer* printer,\n                                 const FieldDescriptor* field);\n  void GenerateSerializeOneExtensionRange(\n      io::Printer* printer, const Descriptor::ExtensionRange* range);\n\n  void GenerateBuilder(io::Printer* printer);\n  void GenerateDynamicMethodIsInitialized(io::Printer* printer);\n  void GenerateDynamicMethodMakeImmutable(io::Printer* printer);\n  void GenerateDynamicMethodVisit(io::Printer* printer);\n  void GenerateDynamicMethodMergeFromStream(io::Printer* printer);\n  void GenerateDynamicMethodNewBuilder(io::Printer* printer);\n  void GenerateInitializers(io::Printer* printer);\n  void GenerateEqualsAndHashCode(io::Printer* printer);\n  void GenerateParser(io::Printer* printer);\n  void GenerateConstructor(io::Printer* printer);\n\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n  FieldGeneratorMap<ImmutableFieldLiteGenerator> field_generators_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableMessageLiteGenerator);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_MESSAGE_LITE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_name_resolver.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/stubs/substitute.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nnamespace {\n// A suffix that will be appended to the file's outer class name if the name\n// conflicts with some other types defined in the file.\nconst char* kOuterClassNameSuffix = \"OuterClass\";\n\n// Strip package name from a descriptor's full name.\n// For example:\n//   Full name   : foo.Bar.Baz\n//   Package name: foo\n//   After strip : Bar.Baz\nstring StripPackageName(const string& full_name,\n                        const FileDescriptor* file) {\n  if (file->package().empty()) {\n    return full_name;\n  } else {\n    // Strip package name\n    return full_name.substr(file->package().size() + 1);\n  }\n}\n\n// Get the name of a message's Java class without package name prefix.\nstring ClassNameWithoutPackage(const Descriptor* descriptor,\n                               bool immutable) {\n  return StripPackageName(descriptor->full_name(),\n                          descriptor->file());\n}\n\n// Get the name of an enum's Java class without package name prefix.\nstring ClassNameWithoutPackage(const EnumDescriptor* descriptor,\n                               bool immutable) {\n  // Doesn't append \"Mutable\" for enum type's name.\n  const Descriptor* message_descriptor = descriptor->containing_type();\n  if (message_descriptor == NULL) {\n    return descriptor->name();\n  } else {\n    return ClassNameWithoutPackage(message_descriptor, immutable) +\n           \".\" + descriptor->name();\n  }\n}\n\n// Get the name of a service's Java class without package name prefix.\nstring ClassNameWithoutPackage(const ServiceDescriptor* descriptor,\n                               bool immutable) {\n  string full_name = StripPackageName(descriptor->full_name(),\n                                      descriptor->file());\n  // We don't allow nested service definitions.\n  GOOGLE_CHECK(full_name.find('.') == string::npos);\n  return full_name;\n}\n\n// Check whether a given message or its nested types has the given class name.\nbool MessageHasConflictingClassName(const Descriptor* message,\n                                    const string& classname) {\n  if (message->name() == classname) return true;\n  for (int i = 0; i < message->nested_type_count(); ++i) {\n    if (MessageHasConflictingClassName(message->nested_type(i), classname)) {\n      return true;\n    }\n  }\n  for (int i = 0; i < message->enum_type_count(); ++i) {\n    if (message->enum_type(i)->name() == classname) {\n      return true;\n    }\n  }\n  return false;\n}\n\n}  // namespace\n\nClassNameResolver::ClassNameResolver() {\n}\n\nClassNameResolver::~ClassNameResolver() {\n}\n\nstring ClassNameResolver::GetFileDefaultImmutableClassName(\n    const FileDescriptor* file) {\n  string basename;\n  string::size_type last_slash = file->name().find_last_of('/');\n  if (last_slash == string::npos) {\n    basename = file->name();\n  } else {\n    basename = file->name().substr(last_slash + 1);\n  }\n  return UnderscoresToCamelCase(StripProto(basename), true);\n}\n\nstring ClassNameResolver::GetFileImmutableClassName(\n    const FileDescriptor* file) {\n  string& class_name = file_immutable_outer_class_names_[file];\n  if (class_name.empty()) {\n    if (file->options().has_java_outer_classname()) {\n      class_name = file->options().java_outer_classname();\n    } else {\n      class_name = GetFileDefaultImmutableClassName(file);\n      if (HasConflictingClassName(file, class_name)) {\n        class_name += kOuterClassNameSuffix;\n      }\n    }\n  }\n  return class_name;\n}\n\nstring ClassNameResolver::GetFileClassName(const FileDescriptor* file,\n                                           bool immutable) {\n  if (immutable) {\n    return GetFileImmutableClassName(file);\n  } else {\n    return \"Mutable\" + GetFileImmutableClassName(file);\n  }\n}\n\n// Check whether there is any type defined in the proto file that has\n// the given class name.\nbool ClassNameResolver::HasConflictingClassName(\n    const FileDescriptor* file, const string& classname) {\n  for (int i = 0; i < file->enum_type_count(); i++) {\n    if (file->enum_type(i)->name() == classname) {\n      return true;\n    }\n  }\n  for (int i = 0; i < file->service_count(); i++) {\n    if (file->service(i)->name() == classname) {\n      return true;\n    }\n  }\n  for (int i = 0; i < file->message_type_count(); i++) {\n    if (MessageHasConflictingClassName(file->message_type(i), classname)) {\n      return true;\n    }\n  }\n  return false;\n}\n\nstring ClassNameResolver::GetDescriptorClassName(\n    const FileDescriptor* descriptor) {\n  return GetFileImmutableClassName(descriptor);\n}\n\nstring ClassNameResolver::GetClassName(const FileDescriptor* descriptor,\n                                       bool immutable) {\n  string result = FileJavaPackage(descriptor, immutable);\n  if (!result.empty()) result += '.';\n  result += GetFileClassName(descriptor, immutable);\n  return result;\n}\n\n// Get the full name of a Java class by prepending the Java package name\n// or outer class name.\nstring ClassNameResolver::GetClassFullName(const string& name_without_package,\n                                           const FileDescriptor* file,\n                                           bool immutable,\n                                           bool multiple_files) {\n  string result;\n  if (multiple_files) {\n    result = FileJavaPackage(file, immutable);\n  } else {\n    result = GetClassName(file, immutable);\n  }\n  if (!result.empty()) {\n    result += '.';\n  }\n  result += name_without_package;\n  return result;\n}\n\nstring ClassNameResolver::GetClassName(const Descriptor* descriptor,\n                                       bool immutable) {\n  return GetClassFullName(ClassNameWithoutPackage(descriptor, immutable),\n                          descriptor->file(), immutable,\n                          MultipleJavaFiles(descriptor->file(), immutable));\n}\n\nstring ClassNameResolver::GetClassName(const EnumDescriptor* descriptor,\n                                       bool immutable) {\n  return GetClassFullName(ClassNameWithoutPackage(descriptor, immutable),\n                          descriptor->file(), immutable,\n                          MultipleJavaFiles(descriptor->file(), immutable));\n}\n\nstring ClassNameResolver::GetClassName(const ServiceDescriptor* descriptor,\n                                       bool immutable) {\n  return GetClassFullName(ClassNameWithoutPackage(descriptor, immutable),\n                          descriptor->file(), immutable,\n                          MultipleJavaFiles(descriptor->file(), immutable));\n}\n\n// Get the Java Class style full name of a message.\nstring ClassNameResolver::GetJavaClassFullName(\n    const string& name_without_package,\n    const FileDescriptor* file,\n    bool immutable) {\n  string result;\n  if (MultipleJavaFiles(file, immutable)) {\n    result = FileJavaPackage(file, immutable);\n    if (!result.empty()) result += '.';\n  } else {\n    result = GetClassName(file, immutable);\n    if (!result.empty()) result += '$';\n  }\n  result += StringReplace(name_without_package, \".\", \"$\", true);\n  return result;\n}\n\nstring ClassNameResolver::GetExtensionIdentifierName(\n    const FieldDescriptor* descriptor, bool immutable) {\n  return GetClassName(descriptor->containing_type(), immutable) + \".\" +\n         descriptor->name();\n}\n\n\nstring ClassNameResolver::GetJavaImmutableClassName(\n    const Descriptor* descriptor) {\n  return GetJavaClassFullName(\n      ClassNameWithoutPackage(descriptor, true),\n      descriptor->file(), true);\n}\n\nstring ClassNameResolver::GetJavaImmutableClassName(\n    const EnumDescriptor* descriptor) {\n  return GetJavaClassFullName(\n      ClassNameWithoutPackage(descriptor, true),\n      descriptor->file(), true);\n}\n\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_name_resolver.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_NAME_RESOLVER_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_NAME_RESOLVER_H__\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\nclass Descriptor;\nclass EnumDescriptor;\nclass FieldDescriptor;\nclass FileDescriptor;\nclass ServiceDescriptor;\n\nnamespace compiler {\nnamespace java {\n\n// Used to get the Java class related names for a given descriptor. It caches\n// the results to avoid redundant calculation across multiple name queries.\n// Thread-safety note: This class is *not* thread-safe.\nclass ClassNameResolver {\n public:\n  ClassNameResolver();\n  ~ClassNameResolver();\n\n  // Gets the unqualified outer class name for the file.\n  string GetFileClassName(const FileDescriptor* file, bool immutable);\n  // Gets the unqualified immutable outer class name of a file.\n  string GetFileImmutableClassName(const FileDescriptor* file);\n  // Gets the unqualified default immutable outer class name of a file\n  // (converted from the proto file's name).\n  string GetFileDefaultImmutableClassName(const FileDescriptor* file);\n\n  // Check whether there is any type defined in the proto file that has\n  // the given class name.\n  bool HasConflictingClassName(const FileDescriptor* file,\n                               const string& classname);\n\n  // Gets the name of the outer class that holds descriptor information.\n  // Descriptors are shared between immutable messages and mutable messages.\n  // Since both of them are generated optionally, the descriptors need to be\n  // put in another common place.\n  string GetDescriptorClassName(const FileDescriptor* file);\n\n  // Gets the fully-qualified class name corresponding to the given descriptor.\n  string GetClassName(const Descriptor* descriptor, bool immutable);\n  string GetClassName(const EnumDescriptor* descriptor, bool immutable);\n  string GetClassName(const ServiceDescriptor* descriptor, bool immutable);\n  string GetClassName(const FileDescriptor* descriptor, bool immutable);\n\n  template<class DescriptorType>\n  string GetImmutableClassName(const DescriptorType* descriptor) {\n    return GetClassName(descriptor, true);\n  }\n  template<class DescriptorType>\n  string GetMutableClassName(const DescriptorType* descriptor) {\n    return GetClassName(descriptor, false);\n  }\n\n  // Gets the fully qualified name of an extension identifier.\n  string GetExtensionIdentifierName(const FieldDescriptor* descriptor,\n                                    bool immutable);\n\n  // Gets the fully qualified name for generated classes in Java convention.\n  // Nested classes will be separated using '$' instead of '.'\n  // For example:\n  //   com.package.OuterClass$OuterMessage$InnerMessage\n  string GetJavaImmutableClassName(const Descriptor* descriptor);\n  string GetJavaImmutableClassName(const EnumDescriptor* descriptor);\n private:\n  // Get the full name of a Java class by prepending the Java package name\n  // or outer class name.\n  string GetClassFullName(const string& name_without_package,\n                          const FileDescriptor* file,\n                          bool immutable,\n                          bool multiple_files);\n  // Get the Java Class style full name of a message.\n  string GetJavaClassFullName(\n      const string& name_without_package,\n      const FileDescriptor* file,\n      bool immutable);\n  // Caches the result to provide better performance.\n  map<const FileDescriptor*, string> file_immutable_outer_class_names_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ClassNameResolver);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_NAME_RESOLVER_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_names.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Provides a mechanism for mapping a descriptor to the\n// fully-qualified name of the corresponding Java class.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_NAMES_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_NAMES_H__\n\n#include <string>\n\nnamespace google {\nnamespace protobuf {\n\nclass Descriptor;\nclass EnumDescriptor;\nclass FileDescriptor;\nclass ServiceDescriptor;\n\nnamespace compiler {\nnamespace java {\n\n// Requires:\n//   descriptor != NULL\n//\n// Returns:\n//   The fully-qualified Java class name.\nstring ClassName(const Descriptor* descriptor);\n\n// Requires:\n//   descriptor != NULL\n//\n// Returns:\n//   The fully-qualified Java class name.\nstring ClassName(const EnumDescriptor* descriptor);\n\n// Requires:\n//   descriptor != NULL\n//\n// Returns:\n//   The fully-qualified Java class name.\nstring ClassName(const FileDescriptor* descriptor);\n\n// Requires:\n//   descriptor != NULL\n//\n// Returns:\n//   The fully-qualified Java class name.\nstring ClassName(const ServiceDescriptor* descriptor);\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_NAMES_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_options.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_OPTIONS_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_OPTIONS_H__\n\n#include <string>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\n// Generator options\nstruct Options {\n  Options()\n      : generate_immutable_code(false),\n        generate_mutable_code(false),\n        generate_shared_code(false),\n        enforce_lite(false),\n        annotate_code(false) {\n  }\n\n  bool generate_immutable_code;\n  bool generate_mutable_code;\n  bool generate_shared_code;\n  // When set, the protoc will generate the current files and all the transitive\n  // dependencies as lite runtime.\n  bool enforce_lite;\n  // If true, we should build .meta files and emit @Generated annotations into\n  // generated code.\n  bool annotate_code;\n  // Name of a file where we will write a list of generated .meta file names,\n  // one per line.\n  string annotation_list_file;\n  // Name of a file where we will write a list of generated file names, one\n  // per line.\n  string output_list_file;\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_OPTIONS_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_plugin_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//\n// TODO(kenton):  Share code with the versions of this test in other languages?\n//   It seemed like parameterizing it would add more complexity than it is\n//   worth.\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#include <google/protobuf/compiler/java/java_generator.h>\n#include <google/protobuf/compiler/command_line_interface.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/io/printer.h>\n\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\nnamespace {\n\nclass TestGenerator : public CodeGenerator {\n public:\n  TestGenerator() {}\n  ~TestGenerator() {}\n\n  virtual bool Generate(const FileDescriptor* file,\n                        const string& parameter,\n                        GeneratorContext* context,\n                        string* error) const {\n    string filename = \"Test.java\";\n    TryInsert(filename, \"outer_class_scope\", context);\n    TryInsert(filename, \"class_scope:foo.Bar\", context);\n    TryInsert(filename, \"class_scope:foo.Bar.Baz\", context);\n    TryInsert(filename, \"builder_scope:foo.Bar\", context);\n    TryInsert(filename, \"builder_scope:foo.Bar.Baz\", context);\n    TryInsert(filename, \"enum_scope:foo.Qux\", context);\n    return true;\n  }\n\n  void TryInsert(const string& filename, const string& insertion_point,\n                 GeneratorContext* context) const {\n    google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(\n        context->OpenForInsert(filename, insertion_point));\n    io::Printer printer(output.get(), '$');\n    printer.Print(\"// inserted $name$\\n\", \"name\", insertion_point);\n  }\n};\n\n// This test verifies that all the expected insertion points exist.  It does\n// not verify that they are correctly-placed; that would require actually\n// compiling the output which is a bit more than I care to do for this test.\nTEST(JavaPluginTest, PluginTest) {\n  GOOGLE_CHECK_OK(File::SetContents(TestTempDir() + \"/test.proto\",\n                             \"syntax = \\\"proto2\\\";\\n\"\n                             \"package foo;\\n\"\n                             \"option java_package = \\\"\\\";\\n\"\n                             \"option java_outer_classname = \\\"Test\\\";\\n\"\n                             \"message Bar {\\n\"\n                             \"  message Baz {}\\n\"\n                             \"}\\n\"\n                             \"enum Qux { BLAH = 1; }\\n\",\n                             true));\n\n  google::protobuf::compiler::CommandLineInterface cli;\n  cli.SetInputsAreProtoPathRelative(true);\n\n  JavaGenerator java_generator;\n  TestGenerator test_generator;\n  cli.RegisterGenerator(\"--java_out\", &java_generator, \"\");\n  cli.RegisterGenerator(\"--test_out\", &test_generator, \"\");\n\n  string proto_path = \"-I\" + TestTempDir();\n  string java_out = \"--java_out=\" + TestTempDir();\n  string test_out = \"--test_out=\" + TestTempDir();\n\n  const char* argv[] = {\n    \"protoc\",\n    proto_path.c_str(),\n    java_out.c_str(),\n    test_out.c_str(),\n    \"test.proto\"\n  };\n\n  EXPECT_EQ(0, cli.Run(5, argv));\n}\n\n}  // namespace\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_primitive_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/compiler/java/java_primitive_field.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nusing internal::WireFormat;\nusing internal::WireFormatLite;\n\nnamespace {\n\nvoid SetPrimitiveVariables(const FieldDescriptor* descriptor,\n                           int messageBitIndex,\n                           int builderBitIndex,\n                           const FieldGeneratorInfo* info,\n                           ClassNameResolver* name_resolver,\n                           map<string, string>* variables) {\n  SetCommonFieldVariables(descriptor, info, variables);\n\n  (*variables)[\"type\"] = PrimitiveTypeName(GetJavaType(descriptor));\n  (*variables)[\"boxed_type\"] = BoxedPrimitiveTypeName(GetJavaType(descriptor));\n  (*variables)[\"field_type\"] = (*variables)[\"type\"];\n  (*variables)[\"field_list_type\"] = \"java.util.List<\" +\n      (*variables)[\"boxed_type\"] + \">\";\n  (*variables)[\"empty_list\"] = \"java.util.Collections.emptyList()\";\n  (*variables)[\"default\"] = ImmutableDefaultValue(descriptor, name_resolver);\n  (*variables)[\"default_init\"] = IsDefaultValueJavaDefault(descriptor) ?\n      \"\" : (\"= \" + ImmutableDefaultValue(descriptor, name_resolver));\n  (*variables)[\"capitalized_type\"] =\n      GetCapitalizedType(descriptor, /* immutable = */ true);\n  (*variables)[\"tag\"] = SimpleItoa(WireFormat::MakeTag(descriptor));\n  (*variables)[\"tag_size\"] = SimpleItoa(\n      WireFormat::TagSize(descriptor->number(), GetType(descriptor)));\n  if (IsReferenceType(GetJavaType(descriptor))) {\n    (*variables)[\"null_check\"] =\n        \"  if (value == null) {\\n\"\n        \"    throw new NullPointerException();\\n\"\n        \"  }\\n\";\n  } else {\n    (*variables)[\"null_check\"] = \"\";\n  }\n  // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported\n  // by the proto compiler\n  (*variables)[\"deprecation\"] = descriptor->options().deprecated()\n      ? \"@java.lang.Deprecated \" : \"\";\n  int fixed_size = FixedSize(GetType(descriptor));\n  if (fixed_size != -1) {\n    (*variables)[\"fixed_size\"] = SimpleItoa(fixed_size);\n  }\n  (*variables)[\"on_changed\"] = \"onChanged();\";\n\n  if (SupportFieldPresence(descriptor->file())) {\n    // For singular messages and builders, one bit is used for the hasField bit.\n    (*variables)[\"get_has_field_bit_message\"] = GenerateGetBit(messageBitIndex);\n    (*variables)[\"get_has_field_bit_builder\"] = GenerateGetBit(builderBitIndex);\n\n    // Note that these have a trailing \";\".\n    (*variables)[\"set_has_field_bit_message\"] =\n        GenerateSetBit(messageBitIndex) + \";\";\n    (*variables)[\"set_has_field_bit_builder\"] =\n        GenerateSetBit(builderBitIndex) + \";\";\n    (*variables)[\"clear_has_field_bit_builder\"] =\n        GenerateClearBit(builderBitIndex) + \";\";\n\n    (*variables)[\"is_field_present_message\"] = GenerateGetBit(messageBitIndex);\n  } else {\n    (*variables)[\"set_has_field_bit_message\"] = \"\";\n    (*variables)[\"set_has_field_bit_builder\"] = \"\";\n    (*variables)[\"clear_has_field_bit_builder\"] = \"\";\n\n    if (descriptor->type() == FieldDescriptor::TYPE_BYTES) {\n      (*variables)[\"is_field_present_message\"] =\n          \"!\" + (*variables)[\"name\"] + \"_.isEmpty()\";\n    } else {\n      (*variables)[\"is_field_present_message\"] =\n          (*variables)[\"name\"] + \"_ != \" + (*variables)[\"default\"];\n    }\n  }\n\n  // For repated builders, one bit is used for whether the array is immutable.\n  (*variables)[\"get_mutable_bit_builder\"] = GenerateGetBit(builderBitIndex);\n  (*variables)[\"set_mutable_bit_builder\"] = GenerateSetBit(builderBitIndex);\n  (*variables)[\"clear_mutable_bit_builder\"] = GenerateClearBit(builderBitIndex);\n\n  // For repeated fields, one bit is used for whether the array is immutable\n  // in the parsing constructor.\n  (*variables)[\"get_mutable_bit_parser\"] =\n      GenerateGetBitMutableLocal(builderBitIndex);\n  (*variables)[\"set_mutable_bit_parser\"] =\n      GenerateSetBitMutableLocal(builderBitIndex);\n\n  (*variables)[\"get_has_field_bit_from_local\"] =\n      GenerateGetBitFromLocal(builderBitIndex);\n  (*variables)[\"set_has_field_bit_to_local\"] =\n      GenerateSetBitToLocal(messageBitIndex);\n}\n\n}  // namespace\n\n// ===================================================================\n\nImmutablePrimitiveFieldGenerator::\nImmutablePrimitiveFieldGenerator(const FieldDescriptor* descriptor,\n                                 int messageBitIndex,\n                                 int builderBitIndex,\n                                 Context* context)\n  : descriptor_(descriptor), messageBitIndex_(messageBitIndex),\n    builderBitIndex_(builderBitIndex), context_(context),\n    name_resolver_(context->GetNameResolver()) {\n  SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex,\n                        context->GetFieldGeneratorInfo(descriptor),\n                        name_resolver_, &variables_);\n}\n\nImmutablePrimitiveFieldGenerator::~ImmutablePrimitiveFieldGenerator() {}\n\nint ImmutablePrimitiveFieldGenerator::GetNumBitsForMessage() const {\n  return 1;\n}\n\nint ImmutablePrimitiveFieldGenerator::GetNumBitsForBuilder() const {\n  return 1;\n}\n\nvoid ImmutablePrimitiveFieldGenerator::\nGenerateInterfaceMembers(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$boolean has$capitalized_name$();\\n\");\n  }\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$$type$ get$capitalized_name$();\\n\");\n}\n\nvoid ImmutablePrimitiveFieldGenerator::\nGenerateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"private $field_type$ $name$_;\\n\");\n  PrintExtraFieldInfo(variables_, printer);\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $get_has_field_bit_message$;\\n\"\n      \"}\\n\");\n  }\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  return $name$_;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutablePrimitiveFieldGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"private $field_type$ $name$_ $default_init$;\\n\");\n\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $get_has_field_bit_builder$;\\n\"\n      \"}\\n\");\n  }\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  return $name$_;\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$($type$ value) {\\n\"\n    \"$null_check$\"\n    \"  $set_has_field_bit_builder$\\n\"\n    \"  $name$_ = value;\\n\"\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  $clear_has_field_bit_builder$\\n\");\n  JavaType type = GetJavaType(descriptor_);\n  if (type == JAVATYPE_STRING || type == JAVATYPE_BYTES) {\n    // The default value is not a simple literal so we want to avoid executing\n    // it multiple times.  Instead, get the default out of the default instance.\n    printer->Print(variables_,\n      \"  $name$_ = getDefaultInstance().get$capitalized_name$();\\n\");\n  } else {\n    printer->Print(variables_,\n      \"  $name$_ = $default$;\\n\");\n  }\n  printer->Print(variables_,\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutablePrimitiveFieldGenerator::\nGenerateFieldBuilderInitializationCode(io::Printer* printer)  const {\n  // noop for primitives\n}\n\nvoid ImmutablePrimitiveFieldGenerator::\nGenerateInitializationCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_ = $default$;\\n\");\n}\n\nvoid ImmutablePrimitiveFieldGenerator::\nGenerateBuilderClearCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$_ = $default$;\\n\"\n    \"$clear_has_field_bit_builder$\\n\");\n}\n\nvoid ImmutablePrimitiveFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    printer->Print(variables_,\n      \"if (other.has$capitalized_name$()) {\\n\"\n      \"  set$capitalized_name$(other.get$capitalized_name$());\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables_,\n      \"if (other.get$capitalized_name$() != $default$) {\\n\"\n      \"  set$capitalized_name$(other.get$capitalized_name$());\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid ImmutablePrimitiveFieldGenerator::\nGenerateBuildingCode(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    printer->Print(variables_,\n      \"if ($get_has_field_bit_from_local$) {\\n\"\n      \"  $set_has_field_bit_to_local$;\\n\"\n      \"}\\n\");\n  }\n  printer->Print(variables_,\n    \"result.$name$_ = $name$_;\\n\");\n}\n\nvoid ImmutablePrimitiveFieldGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$set_has_field_bit_message$\\n\"\n    \"$name$_ = input.read$capitalized_type$();\\n\");\n}\n\nvoid ImmutablePrimitiveFieldGenerator::\nGenerateParsingDoneCode(io::Printer* printer) const {\n  // noop for primitives.\n}\n\nvoid ImmutablePrimitiveFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($is_field_present_message$) {\\n\"\n    \"  output.write$capitalized_type$($number$, $name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutablePrimitiveFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($is_field_present_message$) {\\n\"\n    \"  size += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .compute$capitalized_type$Size($number$, $name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutablePrimitiveFieldGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  switch (GetJavaType(descriptor_)) {\n    case JAVATYPE_INT:\n    case JAVATYPE_LONG:\n    case JAVATYPE_BOOLEAN:\n      printer->Print(variables_,\n        \"result = result && (get$capitalized_name$()\\n\"\n        \"    == other.get$capitalized_name$());\\n\");\n      break;\n\n    case JAVATYPE_FLOAT:\n      printer->Print(variables_,\n        \"result = result && (\\n\"\n        \"    java.lang.Float.floatToIntBits(get$capitalized_name$())\\n\"\n        \"    == java.lang.Float.floatToIntBits(\\n\"\n        \"        other.get$capitalized_name$()));\\n\");\n      break;\n\n    case JAVATYPE_DOUBLE:\n      printer->Print(variables_,\n        \"result = result && (\\n\"\n        \"    java.lang.Double.doubleToLongBits(get$capitalized_name$())\\n\"\n        \"    == java.lang.Double.doubleToLongBits(\\n\"\n        \"        other.get$capitalized_name$()));\\n\");\n      break;\n\n    case JAVATYPE_STRING:\n    case JAVATYPE_BYTES:\n      printer->Print(variables_,\n        \"result = result && get$capitalized_name$()\\n\"\n        \"    .equals(other.get$capitalized_name$());\\n\");\n      break;\n\n    case JAVATYPE_ENUM:\n    case JAVATYPE_MESSAGE:\n    default:\n      GOOGLE_LOG(FATAL) << \"Can't get here.\";\n      break;\n  }\n}\n\nvoid ImmutablePrimitiveFieldGenerator::\nGenerateHashCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"hash = (37 * hash) + $constant_name$;\\n\");\n  switch (GetJavaType(descriptor_)) {\n    case JAVATYPE_INT:\n      printer->Print(variables_,\n        \"hash = (53 * hash) + get$capitalized_name$();\\n\");\n      break;\n\n    case JAVATYPE_LONG:\n      printer->Print(variables_,\n        \"hash = (53 * hash) + com.google.protobuf.Internal.hashLong(\\n\"\n        \"    get$capitalized_name$());\\n\");\n      break;\n\n    case JAVATYPE_BOOLEAN:\n      printer->Print(variables_,\n        \"hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(\\n\"\n        \"    get$capitalized_name$());\\n\");\n      break;\n\n    case JAVATYPE_FLOAT:\n      printer->Print(variables_,\n        \"hash = (53 * hash) + java.lang.Float.floatToIntBits(\\n\"\n        \"    get$capitalized_name$());\\n\");\n      break;\n\n    case JAVATYPE_DOUBLE:\n      printer->Print(variables_,\n        \"hash = (53 * hash) + com.google.protobuf.Internal.hashLong(\\n\"\n        \"    java.lang.Double.doubleToLongBits(get$capitalized_name$()));\\n\");\n      break;\n\n    case JAVATYPE_STRING:\n    case JAVATYPE_BYTES:\n      printer->Print(variables_,\n        \"hash = (53 * hash) + get$capitalized_name$().hashCode();\\n\");\n      break;\n\n    case JAVATYPE_ENUM:\n    case JAVATYPE_MESSAGE:\n    default:\n      GOOGLE_LOG(FATAL) << \"Can't get here.\";\n      break;\n  }\n}\n\nstring ImmutablePrimitiveFieldGenerator::GetBoxedType() const {\n  return BoxedPrimitiveTypeName(GetJavaType(descriptor_));\n}\n\n// ===================================================================\n\nImmutablePrimitiveOneofFieldGenerator::\nImmutablePrimitiveOneofFieldGenerator(const FieldDescriptor* descriptor,\n                                 int messageBitIndex,\n                                 int builderBitIndex,\n                                 Context* context)\n    : ImmutablePrimitiveFieldGenerator(\n          descriptor, messageBitIndex, builderBitIndex, context) {\n  const OneofGeneratorInfo* info =\n      context->GetOneofGeneratorInfo(descriptor->containing_oneof());\n  SetCommonOneofVariables(descriptor, info, &variables_);\n}\n\nImmutablePrimitiveOneofFieldGenerator::\n~ImmutablePrimitiveOneofFieldGenerator() {}\n\nvoid ImmutablePrimitiveOneofFieldGenerator::\nGenerateMembers(io::Printer* printer) const {\n  PrintExtraFieldInfo(variables_, printer);\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $has_oneof_case_message$;\\n\"\n      \"}\\n\");\n  }\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    return ($boxed_type$) $oneof_name$_;\\n\"\n    \"  }\\n\"\n    \"  return $default$;\\n\"\n    \"}\\n\");\n}\n\n\nvoid ImmutablePrimitiveOneofFieldGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $has_oneof_case_message$;\\n\"\n      \"}\\n\");\n  }\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    return ($boxed_type$) $oneof_name$_;\\n\"\n    \"  }\\n\"\n    \"  return $default$;\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$($type$ value) {\\n\"\n    \"$null_check$\"\n    \"  $set_oneof_case_message$;\\n\"\n    \"  $oneof_name$_ = value;\\n\"\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    $clear_oneof_case_message$;\\n\"\n    \"    $oneof_name$_ = null;\\n\"\n    \"    $on_changed$\\n\"\n    \"  }\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutablePrimitiveOneofFieldGenerator::\nGenerateBuildingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  result.$oneof_name$_ = $oneof_name$_;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutablePrimitiveOneofFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"set$capitalized_name$(other.get$capitalized_name$());\\n\");\n}\n\nvoid ImmutablePrimitiveOneofFieldGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$set_oneof_case_message$;\\n\"\n    \"$oneof_name$_ = input.read$capitalized_type$();\\n\");\n}\n\nvoid ImmutablePrimitiveOneofFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  output.write$capitalized_type$(\\n\"\n    \"      $number$, ($type$)(($boxed_type$) $oneof_name$_));\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutablePrimitiveOneofFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  size += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .compute$capitalized_type$Size(\\n\"\n    \"        $number$, ($type$)(($boxed_type$) $oneof_name$_));\\n\"\n    \"}\\n\");\n}\n\n// ===================================================================\n\nRepeatedImmutablePrimitiveFieldGenerator::\nRepeatedImmutablePrimitiveFieldGenerator(const FieldDescriptor* descriptor,\n                                         int messageBitIndex,\n                                         int builderBitIndex,\n                                         Context* context)\n  : descriptor_(descriptor), messageBitIndex_(messageBitIndex),\n    builderBitIndex_(builderBitIndex), context_(context),\n    name_resolver_(context->GetNameResolver()) {\n  SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex,\n                        context->GetFieldGeneratorInfo(descriptor),\n                        name_resolver_, &variables_);\n}\n\nRepeatedImmutablePrimitiveFieldGenerator::\n~RepeatedImmutablePrimitiveFieldGenerator() {}\n\nint RepeatedImmutablePrimitiveFieldGenerator::GetNumBitsForMessage() const {\n  return 0;\n}\n\nint RepeatedImmutablePrimitiveFieldGenerator::GetNumBitsForBuilder() const {\n  return 1;\n}\n\nvoid RepeatedImmutablePrimitiveFieldGenerator::\nGenerateInterfaceMembers(io::Printer* printer) const {\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$java.util.List<$boxed_type$> get$capitalized_name$List();\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$int get$capitalized_name$Count();\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$$type$ get$capitalized_name$(int index);\\n\");\n}\n\n\nvoid RepeatedImmutablePrimitiveFieldGenerator::\nGenerateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"private $field_list_type$ $name$_;\\n\");\n  PrintExtraFieldInfo(variables_, printer);\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.util.List<$boxed_type$>\\n\"\n    \"    get$capitalized_name$List() {\\n\"\n    \"  return $name$_;\\n\"   // note:  unmodifiable list\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public int get$capitalized_name$Count() {\\n\"\n    \"  return $name$_.size();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$(int index) {\\n\"\n    \"  return $name$_.get(index);\\n\"\n    \"}\\n\");\n\n  if (descriptor_->is_packed() &&\n      context_->HasGeneratedMethods(descriptor_->containing_type())) {\n    printer->Print(variables_,\n      \"private int $name$MemoizedSerializedSize = -1;\\n\");\n  }\n}\n\nvoid RepeatedImmutablePrimitiveFieldGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  // One field is the list and the bit field keeps track of whether the\n  // list is immutable. If it's immutable, the invariant is that it must\n  // either an instance of Collections.emptyList() or it's an ArrayList\n  // wrapped in a Collections.unmodifiableList() wrapper and nobody else has\n  // a refererence to the underlying ArrayList. This invariant allows us to\n  // share instances of lists between protocol buffers avoiding expensive\n  // memory allocations. Note, immutable is a strong guarantee here -- not\n  // just that the list cannot be modified via the reference but that the\n  // list can never be modified.\n  printer->Print(variables_,\n    \"private $field_list_type$ $name$_ = $empty_list$;\\n\");\n\n  printer->Print(variables_,\n    \"private void ensure$capitalized_name$IsMutable() {\\n\"\n    \"  if (!$get_mutable_bit_builder$) {\\n\"\n    \"    $name$_ = new java.util.ArrayList<$boxed_type$>($name$_);\\n\"\n    \"    $set_mutable_bit_builder$;\\n\"\n    \"   }\\n\"\n    \"}\\n\");\n\n    // Note:  We return an unmodifiable list because otherwise the caller\n    //   could hold on to the returned list and modify it after the message\n    //   has been built, thus mutating the message which is supposed to be\n    //   immutable.\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.util.List<$boxed_type$>\\n\"\n    \"    get$capitalized_name$List() {\\n\"\n    \"  return java.util.Collections.unmodifiableList($name$_);\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public int get$capitalized_name$Count() {\\n\"\n    \"  return $name$_.size();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$(int index) {\\n\"\n    \"  return $name$_.get(index);\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    int index, $type$ value) {\\n\"\n    \"$null_check$\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.set(index, value);\\n\"\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder add$capitalized_name$($type$ value) {\\n\"\n    \"$null_check$\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.add(value);\\n\"\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder addAll$capitalized_name$(\\n\"\n    \"    java.lang.Iterable<? extends $boxed_type$> values) {\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  com.google.protobuf.AbstractMessageLite.Builder.addAll(\\n\"\n    \"      values, $name$_);\\n\"\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  $name$_ = $empty_list$;\\n\"\n    \"  $clear_mutable_bit_builder$;\\n\"\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutablePrimitiveFieldGenerator::\nGenerateFieldBuilderInitializationCode(io::Printer* printer)  const {\n  // noop for primitives\n}\n\nvoid RepeatedImmutablePrimitiveFieldGenerator::\nGenerateInitializationCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_ = $empty_list$;\\n\");\n}\n\nvoid RepeatedImmutablePrimitiveFieldGenerator::\nGenerateBuilderClearCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$_ = $empty_list$;\\n\"\n    \"$clear_mutable_bit_builder$;\\n\");\n}\n\nvoid RepeatedImmutablePrimitiveFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  // The code below does two optimizations:\n  //   1. If the other list is empty, there's nothing to do. This ensures we\n  //      don't allocate a new array if we already have an immutable one.\n  //   2. If the other list is non-empty and our current list is empty, we can\n  //      reuse the other list which is guaranteed to be immutable.\n  printer->Print(variables_,\n    \"if (!other.$name$_.isEmpty()) {\\n\"\n    \"  if ($name$_.isEmpty()) {\\n\"\n    \"    $name$_ = other.$name$_;\\n\"\n    \"    $clear_mutable_bit_builder$;\\n\"\n    \"  } else {\\n\"\n    \"    ensure$capitalized_name$IsMutable();\\n\"\n    \"    $name$_.addAll(other.$name$_);\\n\"\n    \"  }\\n\"\n    \"  $on_changed$\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutablePrimitiveFieldGenerator::\nGenerateBuildingCode(io::Printer* printer) const {\n  // The code below ensures that the result has an immutable list. If our\n  // list is immutable, we can just reuse it. If not, we make it immutable.\n  printer->Print(variables_,\n    \"if ($get_mutable_bit_builder$) {\\n\"\n    \"  $name$_ = java.util.Collections.unmodifiableList($name$_);\\n\"\n    \"  $clear_mutable_bit_builder$;\\n\"\n    \"}\\n\"\n    \"result.$name$_ = $name$_;\\n\");\n}\n\nvoid RepeatedImmutablePrimitiveFieldGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (!$get_mutable_bit_parser$) {\\n\"\n    \"  $name$_ = new java.util.ArrayList<$boxed_type$>();\\n\"\n    \"  $set_mutable_bit_parser$;\\n\"\n    \"}\\n\"\n    \"$name$_.add(input.read$capitalized_type$());\\n\");\n}\n\nvoid RepeatedImmutablePrimitiveFieldGenerator::\nGenerateParsingCodeFromPacked(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"int length = input.readRawVarint32();\\n\"\n    \"int limit = input.pushLimit(length);\\n\"\n    \"if (!$get_mutable_bit_parser$ && input.getBytesUntilLimit() > 0) {\\n\"\n    \"  $name$_ = new java.util.ArrayList<$boxed_type$>();\\n\"\n    \"  $set_mutable_bit_parser$;\\n\"\n    \"}\\n\"\n    \"while (input.getBytesUntilLimit() > 0) {\\n\"\n    \"  $name$_.add(input.read$capitalized_type$());\\n\"\n    \"}\\n\"\n    \"input.popLimit(limit);\\n\");\n}\n\nvoid RepeatedImmutablePrimitiveFieldGenerator::\nGenerateParsingDoneCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($get_mutable_bit_parser$) {\\n\"\n    \"  $name$_ = java.util.Collections.unmodifiableList($name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutablePrimitiveFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  if (descriptor_->is_packed()) {\n    // We invoke getSerializedSize in writeTo for messages that have packed\n    // fields in ImmutableMessageGenerator::GenerateMessageSerializationMethods.\n    // That makes it safe to rely on the memoized size here.\n    printer->Print(variables_,\n      \"if (get$capitalized_name$List().size() > 0) {\\n\"\n      \"  output.writeUInt32NoTag($tag$);\\n\"\n      \"  output.writeUInt32NoTag($name$MemoizedSerializedSize);\\n\"\n      \"}\\n\"\n      \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n      \"  output.write$capitalized_type$NoTag($name$_.get(i));\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables_,\n      \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n      \"  output.write$capitalized_type$($number$, $name$_.get(i));\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid RepeatedImmutablePrimitiveFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"{\\n\"\n    \"  int dataSize = 0;\\n\");\n  printer->Indent();\n\n  if (FixedSize(GetType(descriptor_)) == -1) {\n    printer->Print(variables_,\n      \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n      \"  dataSize += com.google.protobuf.CodedOutputStream\\n\"\n      \"    .compute$capitalized_type$SizeNoTag($name$_.get(i));\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables_,\n      \"dataSize = $fixed_size$ * get$capitalized_name$List().size();\\n\");\n  }\n\n  printer->Print(\n      \"size += dataSize;\\n\");\n\n  if (descriptor_->is_packed()) {\n    printer->Print(variables_,\n      \"if (!get$capitalized_name$List().isEmpty()) {\\n\"\n      \"  size += $tag_size$;\\n\"\n      \"  size += com.google.protobuf.CodedOutputStream\\n\"\n      \"      .computeInt32SizeNoTag(dataSize);\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables_,\n      \"size += $tag_size$ * get$capitalized_name$List().size();\\n\");\n  }\n\n  // cache the data size for packed fields.\n  if (descriptor_->is_packed()) {\n    printer->Print(variables_,\n      \"$name$MemoizedSerializedSize = dataSize;\\n\");\n  }\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid RepeatedImmutablePrimitiveFieldGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"result = result && get$capitalized_name$List()\\n\"\n    \"    .equals(other.get$capitalized_name$List());\\n\");\n}\n\nvoid RepeatedImmutablePrimitiveFieldGenerator::\nGenerateHashCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (get$capitalized_name$Count() > 0) {\\n\"\n    \"  hash = (37 * hash) + $constant_name$;\\n\"\n    \"  hash = (53 * hash) + get$capitalized_name$List().hashCode();\\n\"\n    \"}\\n\");\n}\n\nstring RepeatedImmutablePrimitiveFieldGenerator::GetBoxedType() const {\n  return BoxedPrimitiveTypeName(GetJavaType(descriptor_));\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_primitive_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_H__\n\n#include <map>\n#include <string>\n#include <google/protobuf/compiler/java/java_field.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace compiler {\n    namespace java {\n      class Context;           // context.h\n      class ClassNameResolver; // name_resolver.h\n    }\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nclass ImmutablePrimitiveFieldGenerator : public ImmutableFieldGenerator {\n public:\n  explicit ImmutablePrimitiveFieldGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~ImmutablePrimitiveFieldGenerator();\n\n  // implements ImmutableFieldGenerator ---------------------------------------\n  int GetNumBitsForMessage() const;\n  int GetNumBitsForBuilder() const;\n  void GenerateInterfaceMembers(io::Printer* printer) const;\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateInitializationCode(io::Printer* printer) const;\n  void GenerateBuilderClearCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateBuildingCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateParsingDoneCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCode(io::Printer* printer) const;\n\n  string GetBoxedType() const;\n\n protected:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n  const int messageBitIndex_;\n  const int builderBitIndex_;\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutablePrimitiveFieldGenerator);\n};\n\nclass ImmutablePrimitiveOneofFieldGenerator\n    : public ImmutablePrimitiveFieldGenerator {\n public:\n  ImmutablePrimitiveOneofFieldGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~ImmutablePrimitiveOneofFieldGenerator();\n\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateBuildingCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutablePrimitiveOneofFieldGenerator);\n};\n\nclass RepeatedImmutablePrimitiveFieldGenerator\n    : public ImmutableFieldGenerator {\n public:\n  explicit RepeatedImmutablePrimitiveFieldGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  virtual ~RepeatedImmutablePrimitiveFieldGenerator();\n\n  // implements ImmutableFieldGenerator ---------------------------------------\n  int GetNumBitsForMessage() const;\n  int GetNumBitsForBuilder() const;\n  void GenerateInterfaceMembers(io::Printer* printer) const;\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateInitializationCode(io::Printer* printer) const;\n  void GenerateBuilderClearCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateBuildingCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateParsingCodeFromPacked(io::Printer* printer) const;\n  void GenerateParsingDoneCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCode(io::Printer* printer) const;\n\n  string GetBoxedType() const;\n\n private:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n  const int messageBitIndex_;\n  const int builderBitIndex_;\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutablePrimitiveFieldGenerator);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/compiler/java/java_primitive_field_lite.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nusing internal::WireFormat;\nusing internal::WireFormatLite;\n\nnamespace {\n\nvoid SetPrimitiveVariables(const FieldDescriptor* descriptor,\n                           int messageBitIndex,\n                           int builderBitIndex,\n                           const FieldGeneratorInfo* info,\n                           ClassNameResolver* name_resolver,\n                           map<string, string>* variables) {\n  SetCommonFieldVariables(descriptor, info, variables);\n  JavaType javaType = GetJavaType(descriptor);\n  (*variables)[\"type\"] = PrimitiveTypeName(javaType);\n  (*variables)[\"boxed_type\"] = BoxedPrimitiveTypeName(javaType);\n  (*variables)[\"field_type\"] = (*variables)[\"type\"];\n  (*variables)[\"default\"] = ImmutableDefaultValue(descriptor, name_resolver);\n  (*variables)[\"capitalized_type\"] =\n      GetCapitalizedType(descriptor, /* immutable = */ true);\n  (*variables)[\"tag\"] = SimpleItoa(WireFormat::MakeTag(descriptor));\n  (*variables)[\"tag_size\"] = SimpleItoa(\n      WireFormat::TagSize(descriptor->number(), GetType(descriptor)));\n\n  string capitalized_type = UnderscoresToCamelCase(PrimitiveTypeName(javaType),\n                                                   true /* cap_next_letter */);\n  switch (javaType) {\n    case JAVATYPE_INT:\n    case JAVATYPE_LONG:\n    case JAVATYPE_FLOAT:\n    case JAVATYPE_DOUBLE:\n    case JAVATYPE_BOOLEAN:\n      (*variables)[\"field_list_type\"] =\n          \"com.google.protobuf.Internal.\" + capitalized_type + \"List\";\n      (*variables)[\"empty_list\"] = \"empty\" + capitalized_type + \"List()\";\n      (*variables)[\"make_name_unmodifiable\"] =\n          (*variables)[\"name\"] + \"_.makeImmutable()\";\n      (*variables)[\"repeated_get\"] =\n          (*variables)[\"name\"] + \"_.get\" + capitalized_type;\n      (*variables)[\"repeated_add\"] =\n          (*variables)[\"name\"] + \"_.add\" + capitalized_type;\n      (*variables)[\"repeated_set\"] =\n          (*variables)[\"name\"] + \"_.set\" + capitalized_type;\n      (*variables)[\"visit_type\"] = capitalized_type;\n      (*variables)[\"visit_type_list\"] = \"visit\" + capitalized_type + \"List\";\n      break;\n    default:\n      (*variables)[\"field_list_type\"] =\n          \"com.google.protobuf.Internal.ProtobufList<\" +\n          (*variables)[\"boxed_type\"] + \">\";\n      (*variables)[\"empty_list\"] = \"emptyProtobufList()\";\n      (*variables)[\"make_name_unmodifiable\"] =\n          (*variables)[\"name\"] + \"_.makeImmutable()\";\n      (*variables)[\"repeated_get\"] = (*variables)[\"name\"] + \"_.get\";\n      (*variables)[\"repeated_add\"] = (*variables)[\"name\"] + \"_.add\";\n      (*variables)[\"repeated_set\"] = (*variables)[\"name\"] + \"_.set\";\n      (*variables)[\"visit_type\"] = \"ByteString\";\n      (*variables)[\"visit_type_list\"] = \"visitList\";\n  }\n\n  if (javaType == JAVATYPE_BYTES) {\n    (*variables)[\"bytes_default\"] =\n        ToUpper((*variables)[\"name\"]) + \"_DEFAULT_VALUE\";\n  }\n\n  if (IsReferenceType(javaType)) {\n    (*variables)[\"null_check\"] =\n        \"  if (value == null) {\\n\"\n        \"    throw new NullPointerException();\\n\"\n        \"  }\\n\";\n  } else {\n    (*variables)[\"null_check\"] = \"\";\n  }\n  // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported\n  // by the proto compiler\n  (*variables)[\"deprecation\"] = descriptor->options().deprecated()\n      ? \"@java.lang.Deprecated \" : \"\";\n  int fixed_size = FixedSize(GetType(descriptor));\n  if (fixed_size != -1) {\n    (*variables)[\"fixed_size\"] = SimpleItoa(fixed_size);\n  }\n\n  if (SupportFieldPresence(descriptor->file())) {\n    // For singular messages and builders, one bit is used for the hasField bit.\n    (*variables)[\"get_has_field_bit_message\"] = GenerateGetBit(messageBitIndex);\n\n    // Note that these have a trailing \";\".\n    (*variables)[\"set_has_field_bit_message\"] =\n        GenerateSetBit(messageBitIndex) + \";\";\n    (*variables)[\"clear_has_field_bit_message\"] =\n        GenerateClearBit(messageBitIndex) + \";\";\n\n    (*variables)[\"is_field_present_message\"] = GenerateGetBit(messageBitIndex);\n  } else {\n    (*variables)[\"set_has_field_bit_message\"] = \"\";\n    (*variables)[\"set_has_field_bit_message\"] = \"\";\n    (*variables)[\"clear_has_field_bit_message\"] = \"\";\n\n    if (descriptor->type() == FieldDescriptor::TYPE_BYTES) {\n      (*variables)[\"is_field_present_message\"] =\n          \"!\" + (*variables)[\"name\"] + \"_.isEmpty()\";\n    } else {\n      (*variables)[\"is_field_present_message\"] =\n          (*variables)[\"name\"] + \"_ != \" + (*variables)[\"default\"];\n    }\n  }\n\n  // For repeated builders, the underlying list tracks mutability state.\n  (*variables)[\"is_mutable\"] = (*variables)[\"name\"] + \"_.isModifiable()\";\n\n  (*variables)[\"get_has_field_bit_from_local\"] =\n      GenerateGetBitFromLocal(builderBitIndex);\n  (*variables)[\"set_has_field_bit_to_local\"] =\n      GenerateSetBitToLocal(messageBitIndex);\n}\n\n}  // namespace\n\n// ===================================================================\n\nImmutablePrimitiveFieldLiteGenerator::\nImmutablePrimitiveFieldLiteGenerator(const FieldDescriptor* descriptor,\n                                 int messageBitIndex,\n                                 int builderBitIndex,\n                                 Context* context)\n  : descriptor_(descriptor), messageBitIndex_(messageBitIndex),\n    builderBitIndex_(builderBitIndex), context_(context),\n    name_resolver_(context->GetNameResolver()) {\n  SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex,\n                        context->GetFieldGeneratorInfo(descriptor),\n                        name_resolver_, &variables_);\n}\n\nImmutablePrimitiveFieldLiteGenerator::~ImmutablePrimitiveFieldLiteGenerator() {}\n\nint ImmutablePrimitiveFieldLiteGenerator::GetNumBitsForMessage() const {\n  return 1;\n}\n\nint ImmutablePrimitiveFieldLiteGenerator::GetNumBitsForBuilder() const {\n  return 0;\n}\n\nvoid ImmutablePrimitiveFieldLiteGenerator::\nGenerateInterfaceMembers(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$boolean has$capitalized_name$();\\n\");\n  }\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$$type$ get$capitalized_name$();\\n\");\n}\n\nvoid ImmutablePrimitiveFieldLiteGenerator::\nGenerateMembers(io::Printer* printer) const {\n  if (IsByteStringWithCustomDefaultValue(descriptor_)) {\n    // allocate this once statically since we know ByteStrings are immutable\n    // values that can be reused.\n    printer->Print(\n        variables_,\n        \"private static final $field_type$ $bytes_default$ = $default$;\\n\");\n  }\n  printer->Print(variables_,\n    \"private $field_type$ $name$_;\\n\");\n  PrintExtraFieldInfo(variables_, printer);\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $get_has_field_bit_message$;\\n\"\n      \"}\\n\");\n  }\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  return $name$_;\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$($type$ value) {\\n\"\n    \"$null_check$\"\n    \"  $set_has_field_bit_message$\\n\"\n    \"  $name$_ = value;\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void clear$capitalized_name$() {\\n\"\n    \"  $clear_has_field_bit_message$\\n\");\n  JavaType type = GetJavaType(descriptor_);\n  if (type == JAVATYPE_STRING || type == JAVATYPE_BYTES) {\n    // The default value is not a simple literal so we want to avoid executing\n    // it multiple times.  Instead, get the default out of the default instance.\n    printer->Print(variables_,\n      \"  $name$_ = getDefaultInstance().get$capitalized_name$();\\n\");\n  } else {\n    printer->Print(variables_,\n      \"  $name$_ = $default$;\\n\");\n  }\n  printer->Print(variables_,\n    \"}\\n\");\n}\n\nvoid ImmutablePrimitiveFieldLiteGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return instance.has$capitalized_name$();\\n\"\n      \"}\\n\");\n  }\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  return instance.get$capitalized_name$();\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$($type$ value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$(value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.clear$capitalized_name$();\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutablePrimitiveFieldLiteGenerator::\nGenerateFieldBuilderInitializationCode(io::Printer* printer)  const {\n  // noop for primitives\n}\n\nvoid ImmutablePrimitiveFieldLiteGenerator::\nGenerateInitializationCode(io::Printer* printer) const {\n  if (IsByteStringWithCustomDefaultValue(descriptor_)) {\n    printer->Print(variables_, \"$name$_ = $bytes_default$;\\n\");\n  } else if (!IsDefaultValueJavaDefault(descriptor_)) {\n    printer->Print(variables_, \"$name$_ = $default$;\\n\");\n  }\n}\n\nvoid ImmutablePrimitiveFieldLiteGenerator::\nGenerateBuilderClearCode(io::Printer* printer) const {\n  // noop for primitives\n}\n\nvoid ImmutablePrimitiveFieldLiteGenerator::\nGenerateVisitCode(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    printer->Print(variables_,\n      \"$name$_ = visitor.visit$visit_type$(\\n\"\n      \"    has$capitalized_name$(), $name$_,\\n\"\n      \"    other.has$capitalized_name$(), other.$name$_);\\n\");\n  } else {\n    printer->Print(variables_,\n      \"$name$_ = visitor.visit$visit_type$($name$_ != $default$, $name$_,\\n\"\n      \"    other.$name$_ != $default$, other.$name$_);\\n\");\n  }\n}\n\nvoid ImmutablePrimitiveFieldLiteGenerator::\nGenerateBuildingCode(io::Printer* printer) const {\n  // noop for primitives\n}\n\nvoid ImmutablePrimitiveFieldLiteGenerator::\nGenerateDynamicMethodMakeImmutableCode(io::Printer* printer) const {\n  // noop for scalars\n}\n\nvoid ImmutablePrimitiveFieldLiteGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$set_has_field_bit_message$\\n\"\n    \"$name$_ = input.read$capitalized_type$();\\n\");\n}\n\nvoid ImmutablePrimitiveFieldLiteGenerator::\nGenerateParsingDoneCode(io::Printer* printer) const {\n  // noop for primitives.\n}\n\nvoid ImmutablePrimitiveFieldLiteGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($is_field_present_message$) {\\n\"\n    \"  output.write$capitalized_type$($number$, $name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutablePrimitiveFieldLiteGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($is_field_present_message$) {\\n\"\n    \"  size += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .compute$capitalized_type$Size($number$, $name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutablePrimitiveFieldLiteGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  switch (GetJavaType(descriptor_)) {\n    case JAVATYPE_INT:\n    case JAVATYPE_LONG:\n    case JAVATYPE_BOOLEAN:\n      printer->Print(variables_,\n        \"result = result && (get$capitalized_name$()\\n\"\n        \"    == other.get$capitalized_name$());\\n\");\n      break;\n\n    case JAVATYPE_FLOAT:\n      printer->Print(variables_,\n        \"result = result && (\\n\"\n        \"    java.lang.Float.floatToIntBits(get$capitalized_name$())\\n\"\n        \"    == java.lang.Float.floatToIntBits(\\n\"\n        \"        other.get$capitalized_name$()));\\n\");\n      break;\n\n    case JAVATYPE_DOUBLE:\n      printer->Print(variables_,\n        \"result = result && (\\n\"\n        \"    java.lang.Double.doubleToLongBits(get$capitalized_name$())\\n\"\n        \"    == java.lang.Double.doubleToLongBits(\\n\"\n        \"        other.get$capitalized_name$()));\\n\");\n      break;\n\n    case JAVATYPE_STRING:\n    case JAVATYPE_BYTES:\n      printer->Print(variables_,\n        \"result = result && get$capitalized_name$()\\n\"\n        \"    .equals(other.get$capitalized_name$());\\n\");\n      break;\n\n    case JAVATYPE_ENUM:\n    case JAVATYPE_MESSAGE:\n    default:\n      GOOGLE_LOG(FATAL) << \"Can't get here.\";\n      break;\n  }\n}\n\nvoid ImmutablePrimitiveFieldLiteGenerator::\nGenerateHashCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"hash = (37 * hash) + $constant_name$;\\n\");\n  switch (GetJavaType(descriptor_)) {\n    case JAVATYPE_INT:\n      printer->Print(variables_,\n        \"hash = (53 * hash) + get$capitalized_name$();\\n\");\n      break;\n\n    case JAVATYPE_LONG:\n      printer->Print(variables_,\n        \"hash = (53 * hash) + com.google.protobuf.Internal.hashLong(\\n\"\n        \"    get$capitalized_name$());\\n\");\n      break;\n\n    case JAVATYPE_BOOLEAN:\n      printer->Print(variables_,\n        \"hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(\\n\"\n        \"    get$capitalized_name$());\\n\");\n      break;\n\n    case JAVATYPE_FLOAT:\n      printer->Print(variables_,\n        \"hash = (53 * hash) + java.lang.Float.floatToIntBits(\\n\"\n        \"    get$capitalized_name$());\\n\");\n      break;\n\n    case JAVATYPE_DOUBLE:\n      printer->Print(variables_,\n        \"hash = (53 * hash) + com.google.protobuf.Internal.hashLong(\\n\"\n        \"    java.lang.Double.doubleToLongBits(get$capitalized_name$()));\\n\");\n      break;\n\n    case JAVATYPE_STRING:\n    case JAVATYPE_BYTES:\n      printer->Print(variables_,\n        \"hash = (53 * hash) + get$capitalized_name$().hashCode();\\n\");\n      break;\n\n    case JAVATYPE_ENUM:\n    case JAVATYPE_MESSAGE:\n    default:\n      GOOGLE_LOG(FATAL) << \"Can't get here.\";\n      break;\n  }\n}\n\nstring ImmutablePrimitiveFieldLiteGenerator::GetBoxedType() const {\n  return BoxedPrimitiveTypeName(GetJavaType(descriptor_));\n}\n\n// ===================================================================\n\nImmutablePrimitiveOneofFieldLiteGenerator::\nImmutablePrimitiveOneofFieldLiteGenerator(const FieldDescriptor* descriptor,\n                                 int messageBitIndex,\n                                 int builderBitIndex,\n                                 Context* context)\n    : ImmutablePrimitiveFieldLiteGenerator(\n          descriptor, messageBitIndex, builderBitIndex, context) {\n  const OneofGeneratorInfo* info =\n      context->GetOneofGeneratorInfo(descriptor->containing_oneof());\n  SetCommonOneofVariables(descriptor, info, &variables_);\n}\n\nImmutablePrimitiveOneofFieldLiteGenerator::\n~ImmutablePrimitiveOneofFieldLiteGenerator() {}\n\nvoid ImmutablePrimitiveOneofFieldLiteGenerator::\nGenerateMembers(io::Printer* printer) const {\n  PrintExtraFieldInfo(variables_, printer);\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $has_oneof_case_message$;\\n\"\n      \"}\\n\");\n  }\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    return ($boxed_type$) $oneof_name$_;\\n\"\n    \"  }\\n\"\n    \"  return $default$;\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$($type$ value) {\\n\"\n    \"$null_check$\"\n    \"  $set_oneof_case_message$;\\n\"\n    \"  $oneof_name$_ = value;\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void clear$capitalized_name$() {\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    $clear_oneof_case_message$;\\n\"\n    \"    $oneof_name$_ = null;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n}\n\n\nvoid ImmutablePrimitiveOneofFieldLiteGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return instance.has$capitalized_name$();\\n\"\n      \"}\\n\");\n  }\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$() {\\n\"\n    \"  return instance.get$capitalized_name$();\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$($type$ value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$(value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.clear$capitalized_name$();\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutablePrimitiveOneofFieldLiteGenerator::\nGenerateBuildingCode(io::Printer* printer) const {\n  // noop for primitives\n}\n\nvoid ImmutablePrimitiveOneofFieldLiteGenerator::\nGenerateVisitCode(io::Printer* printer) const {\n  printer->Print(variables_,\n      \"$oneof_name$_ = visitor.visitOneof$visit_type$(\\n\"\n      \"    $has_oneof_case_message$, $oneof_name$_, other.$oneof_name$_);\\n\");\n}\n\nvoid ImmutablePrimitiveOneofFieldLiteGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$set_oneof_case_message$;\\n\"\n    \"$oneof_name$_ = input.read$capitalized_type$();\\n\");\n}\n\nvoid ImmutablePrimitiveOneofFieldLiteGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  output.write$capitalized_type$(\\n\"\n    \"      $number$, ($type$)(($boxed_type$) $oneof_name$_));\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutablePrimitiveOneofFieldLiteGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  size += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .compute$capitalized_type$Size(\\n\"\n    \"        $number$, ($type$)(($boxed_type$) $oneof_name$_));\\n\"\n    \"}\\n\");\n}\n\n// ===================================================================\n\nRepeatedImmutablePrimitiveFieldLiteGenerator::\nRepeatedImmutablePrimitiveFieldLiteGenerator(const FieldDescriptor* descriptor,\n                                         int messageBitIndex,\n                                         int builderBitIndex,\n                                         Context* context)\n  : descriptor_(descriptor), messageBitIndex_(messageBitIndex),\n    builderBitIndex_(builderBitIndex), context_(context),\n    name_resolver_(context->GetNameResolver()) {\n  SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex,\n                        context->GetFieldGeneratorInfo(descriptor),\n                        name_resolver_, &variables_);\n}\n\nRepeatedImmutablePrimitiveFieldLiteGenerator::\n~RepeatedImmutablePrimitiveFieldLiteGenerator() {}\n\nint RepeatedImmutablePrimitiveFieldLiteGenerator::GetNumBitsForMessage() const {\n  return 0;\n}\n\nint RepeatedImmutablePrimitiveFieldLiteGenerator::GetNumBitsForBuilder() const {\n  return 0;\n}\n\nvoid RepeatedImmutablePrimitiveFieldLiteGenerator::\nGenerateInterfaceMembers(io::Printer* printer) const {\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$java.util.List<$boxed_type$> get$capitalized_name$List();\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$int get$capitalized_name$Count();\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$$type$ get$capitalized_name$(int index);\\n\");\n}\n\n\nvoid RepeatedImmutablePrimitiveFieldLiteGenerator::\nGenerateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"private $field_list_type$ $name$_;\\n\");\n  PrintExtraFieldInfo(variables_, printer);\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.util.List<$boxed_type$>\\n\"\n    \"    get$capitalized_name$List() {\\n\"\n    \"  return $name$_;\\n\"   // note:  unmodifiable list\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public int get$capitalized_name$Count() {\\n\"\n    \"  return $name$_.size();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$(int index) {\\n\"\n    \"  return $repeated_get$(index);\\n\"\n    \"}\\n\");\n\n  if (descriptor_->options().packed() &&\n      context_->HasGeneratedMethods(descriptor_->containing_type())) {\n    printer->Print(variables_,\n      \"private int $name$MemoizedSerializedSize = -1;\\n\");\n  }\n\n  printer->Print(variables_,\n    \"private void ensure$capitalized_name$IsMutable() {\\n\"\n    \"  if (!$is_mutable$) {\\n\"\n    \"    $name$_ =\\n\"\n    \"        com.google.protobuf.GeneratedMessageLite.mutableCopy($name$_);\\n\"\n    \"   }\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$(\\n\"\n    \"    int index, $type$ value) {\\n\"\n    \"$null_check$\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $repeated_set$(index, value);\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void add$capitalized_name$($type$ value) {\\n\"\n    \"$null_check$\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $repeated_add$(value);\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void addAll$capitalized_name$(\\n\"\n    \"    java.lang.Iterable<? extends $boxed_type$> values) {\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  com.google.protobuf.AbstractMessageLite.addAll(\\n\"\n    \"      values, $name$_);\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void clear$capitalized_name$() {\\n\"\n    \"  $name$_ = $empty_list$;\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutablePrimitiveFieldLiteGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.util.List<$boxed_type$>\\n\"\n    \"    get$capitalized_name$List() {\\n\"\n    \"  return java.util.Collections.unmodifiableList(\\n\"\n    \"      instance.get$capitalized_name$List());\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public int get$capitalized_name$Count() {\\n\"\n    \"  return instance.get$capitalized_name$Count();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public $type$ get$capitalized_name$(int index) {\\n\"\n    \"  return instance.get$capitalized_name$(index);\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    int index, $type$ value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$(index, value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder add$capitalized_name$($type$ value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.add$capitalized_name$(value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder addAll$capitalized_name$(\\n\"\n    \"    java.lang.Iterable<? extends $boxed_type$> values) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.addAll$capitalized_name$(values);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.clear$capitalized_name$();\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutablePrimitiveFieldLiteGenerator::\nGenerateFieldBuilderInitializationCode(io::Printer* printer)  const {\n  // noop for primitives\n}\n\nvoid RepeatedImmutablePrimitiveFieldLiteGenerator::\nGenerateInitializationCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_ = $empty_list$;\\n\");\n}\n\nvoid RepeatedImmutablePrimitiveFieldLiteGenerator::\nGenerateBuilderClearCode(io::Printer* printer) const {\n  // noop for primitives\n}\n\nvoid RepeatedImmutablePrimitiveFieldLiteGenerator::\nGenerateVisitCode(io::Printer* printer) const {\n  printer->Print(variables_,\n      \"$name$_= visitor.$visit_type_list$($name$_, other.$name$_);\\n\");\n}\n\nvoid RepeatedImmutablePrimitiveFieldLiteGenerator::\nGenerateBuildingCode(io::Printer* printer) const {\n  // noop for primitives\n}\n\nvoid RepeatedImmutablePrimitiveFieldLiteGenerator::\nGenerateDynamicMethodMakeImmutableCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$_.makeImmutable();\\n\");\n}\n\nvoid RepeatedImmutablePrimitiveFieldLiteGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  // TODO(dweis): Scan the input buffer to count, then initialize\n  // appropriately.\n  // TODO(dweis): Scan the input buffer to count and ensure capacity.\n  printer->Print(variables_,\n    \"if (!$is_mutable$) {\\n\"\n    \"  $name$_ =\\n\"\n    \"      com.google.protobuf.GeneratedMessageLite.mutableCopy($name$_);\\n\"\n    \"}\\n\"\n    \"$repeated_add$(input.read$capitalized_type$());\\n\");\n}\n\nvoid RepeatedImmutablePrimitiveFieldLiteGenerator::\nGenerateParsingCodeFromPacked(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"int length = input.readRawVarint32();\\n\"\n    \"int limit = input.pushLimit(length);\\n\"\n    \"if (!$is_mutable$ && input.getBytesUntilLimit() > 0) {\\n\");\n\n  int fixed_size = FixedSize(GetType(descriptor_));\n  if (fixed_size == -1) {\n    // TODO(dweis): Scan the input buffer to count, then initialize\n    // appropriately.\n    printer->Print(variables_,\n      \"  $name$_ =\\n\"\n      \"      com.google.protobuf.GeneratedMessageLite.mutableCopy($name$_);\\n\");\n  } else {\n    printer->Print(variables_,\n      \"  final int currentSize = $name$_.size();\\n\"\n      \"  $name$_ = $name$_.mutableCopyWithCapacity(\\n\"\n      \"      currentSize + (length/$fixed_size$));\\n\");\n  }\n\n  // TODO(dweis): Scan the input buffer to count and ensure capacity.\n  printer->Print(variables_,\n    \"}\\n\"\n    \"while (input.getBytesUntilLimit() > 0) {\\n\"\n    \"  $repeated_add$(input.read$capitalized_type$());\\n\"\n    \"}\\n\"\n    \"input.popLimit(limit);\\n\");\n}\n\nvoid RepeatedImmutablePrimitiveFieldLiteGenerator::\nGenerateParsingDoneCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($is_mutable$) {\\n\"\n    \"  $make_name_unmodifiable$;\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutablePrimitiveFieldLiteGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  if (descriptor_->options().packed()) {\n    // We invoke getSerializedSize in writeTo for messages that have packed\n    // fields in ImmutableMessageGenerator::GenerateMessageSerializationMethods.\n    // That makes it safe to rely on the memoized size here.\n    printer->Print(variables_,\n      \"if (get$capitalized_name$List().size() > 0) {\\n\"\n      \"  output.writeUInt32NoTag($tag$);\\n\"\n      \"  output.writeUInt32NoTag($name$MemoizedSerializedSize);\\n\"\n      \"}\\n\"\n      \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n      \"  output.write$capitalized_type$NoTag($repeated_get$(i));\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables_,\n      \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n      \"  output.write$capitalized_type$($number$, $repeated_get$(i));\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid RepeatedImmutablePrimitiveFieldLiteGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"{\\n\"\n    \"  int dataSize = 0;\\n\");\n  printer->Indent();\n\n  if (FixedSize(GetType(descriptor_)) == -1) {\n    printer->Print(variables_,\n      \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n      \"  dataSize += com.google.protobuf.CodedOutputStream\\n\"\n      \"    .compute$capitalized_type$SizeNoTag($repeated_get$(i));\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables_,\n      \"dataSize = $fixed_size$ * get$capitalized_name$List().size();\\n\");\n  }\n\n  printer->Print(\n      \"size += dataSize;\\n\");\n\n  if (descriptor_->options().packed()) {\n    printer->Print(variables_,\n      \"if (!get$capitalized_name$List().isEmpty()) {\\n\"\n      \"  size += $tag_size$;\\n\"\n      \"  size += com.google.protobuf.CodedOutputStream\\n\"\n      \"      .computeInt32SizeNoTag(dataSize);\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables_,\n      \"size += $tag_size$ * get$capitalized_name$List().size();\\n\");\n  }\n\n  // cache the data size for packed fields.\n  if (descriptor_->options().packed()) {\n    printer->Print(variables_,\n      \"$name$MemoizedSerializedSize = dataSize;\\n\");\n  }\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid RepeatedImmutablePrimitiveFieldLiteGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"result = result && get$capitalized_name$List()\\n\"\n    \"    .equals(other.get$capitalized_name$List());\\n\");\n}\n\nvoid RepeatedImmutablePrimitiveFieldLiteGenerator::\nGenerateHashCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (get$capitalized_name$Count() > 0) {\\n\"\n    \"  hash = (37 * hash) + $constant_name$;\\n\"\n    \"  hash = (53 * hash) + get$capitalized_name$List().hashCode();\\n\"\n    \"}\\n\");\n}\n\nstring RepeatedImmutablePrimitiveFieldLiteGenerator::GetBoxedType() const {\n  return BoxedPrimitiveTypeName(GetJavaType(descriptor_));\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_primitive_field_lite.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_LITE_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_LITE_H__\n\n#include <map>\n#include <string>\n#include <google/protobuf/compiler/java/java_field.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace compiler {\n    namespace java {\n      class Context;           // context.h\n      class ClassNameResolver; // name_resolver.h\n    }\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nclass ImmutablePrimitiveFieldLiteGenerator\n    : public ImmutableFieldLiteGenerator {\n public:\n  explicit ImmutablePrimitiveFieldLiteGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~ImmutablePrimitiveFieldLiteGenerator();\n\n  // implements ImmutableFieldLiteGenerator ------------------------------------\n  int GetNumBitsForMessage() const;\n  int GetNumBitsForBuilder() const;\n  void GenerateInterfaceMembers(io::Printer* printer) const;\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateInitializationCode(io::Printer* printer) const;\n  void GenerateBuilderClearCode(io::Printer* printer) const;\n  void GenerateVisitCode(io::Printer* printer) const;\n  void GenerateBuildingCode(io::Printer* printer) const;\n  void GenerateDynamicMethodMakeImmutableCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateParsingDoneCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCode(io::Printer* printer) const;\n\n  string GetBoxedType() const;\n\n protected:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n  const int messageBitIndex_;\n  const int builderBitIndex_;\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutablePrimitiveFieldLiteGenerator);\n};\n\nclass ImmutablePrimitiveOneofFieldLiteGenerator\n    : public ImmutablePrimitiveFieldLiteGenerator {\n public:\n  ImmutablePrimitiveOneofFieldLiteGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~ImmutablePrimitiveOneofFieldLiteGenerator();\n\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateBuildingCode(io::Printer* printer) const;\n  void GenerateVisitCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutablePrimitiveOneofFieldLiteGenerator);\n};\n\nclass RepeatedImmutablePrimitiveFieldLiteGenerator\n    : public ImmutableFieldLiteGenerator {\n public:\n  explicit RepeatedImmutablePrimitiveFieldLiteGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  virtual ~RepeatedImmutablePrimitiveFieldLiteGenerator();\n\n  // implements ImmutableFieldLiteGenerator ------------------------------------\n  int GetNumBitsForMessage() const;\n  int GetNumBitsForBuilder() const;\n  void GenerateInterfaceMembers(io::Printer* printer) const;\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateInitializationCode(io::Printer* printer) const;\n  void GenerateBuilderClearCode(io::Printer* printer) const;\n  void GenerateVisitCode(io::Printer* printer) const;\n  void GenerateBuildingCode(io::Printer* printer) const;\n  void GenerateDynamicMethodMakeImmutableCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateParsingCodeFromPacked(io::Printer* printer) const;\n  void GenerateParsingDoneCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCode(io::Printer* printer) const;\n\n  string GetBoxedType() const;\n\n private:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n  const int messageBitIndex_;\n  const int builderBitIndex_;\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutablePrimitiveFieldLiteGenerator);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_PRIMITIVE_FIELD_LITE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_service.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/java/java_service.h>\n\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nServiceGenerator::ServiceGenerator(const ServiceDescriptor* descriptor)\n  : descriptor_(descriptor) {}\n\nServiceGenerator::~ServiceGenerator() {}\n\n// ===================================================================\nImmutableServiceGenerator::ImmutableServiceGenerator(\n    const ServiceDescriptor* descriptor, Context* context)\n    : ServiceGenerator(descriptor), context_(context),\n    name_resolver_(context->GetNameResolver()) {}\n\nImmutableServiceGenerator::~ImmutableServiceGenerator() {}\n\nvoid ImmutableServiceGenerator::Generate(io::Printer* printer) {\n  bool is_own_file = IsOwnFile(descriptor_, /* immutable = */ true);\n  WriteServiceDocComment(printer, descriptor_);\n  MaybePrintGeneratedAnnotation(context_, printer, descriptor_,\n                                /* immutable = */ true);\n  printer->Print(\n    \"public $static$ abstract class $classname$\\n\"\n    \"    implements com.google.protobuf.Service {\\n\",\n    \"static\", is_own_file ? \"\" : \"static\",\n    \"classname\", descriptor_->name());\n  printer->Indent();\n\n  printer->Print(\n    \"protected $classname$() {}\\n\\n\",\n    \"classname\", descriptor_->name());\n\n  GenerateInterface(printer);\n\n  GenerateNewReflectiveServiceMethod(printer);\n  GenerateNewReflectiveBlockingServiceMethod(printer);\n\n  GenerateAbstractMethods(printer);\n\n  // Generate getDescriptor() and getDescriptorForType().\n  printer->Print(\n    \"public static final\\n\"\n    \"    com.google.protobuf.Descriptors.ServiceDescriptor\\n\"\n    \"    getDescriptor() {\\n\"\n    \"  return $file$.getDescriptor().getServices().get($index$);\\n\"\n    \"}\\n\",\n    \"file\", name_resolver_->GetImmutableClassName(descriptor_->file()),\n    \"index\", SimpleItoa(descriptor_->index()));\n  GenerateGetDescriptorForType(printer);\n\n  // Generate more stuff.\n  GenerateCallMethod(printer);\n  GenerateGetPrototype(REQUEST, printer);\n  GenerateGetPrototype(RESPONSE, printer);\n  GenerateStub(printer);\n  GenerateBlockingStub(printer);\n\n  // Add an insertion point.\n  printer->Print(\n    \"\\n\"\n    \"// @@protoc_insertion_point(class_scope:$full_name$)\\n\",\n    \"full_name\", descriptor_->full_name());\n\n  printer->Outdent();\n  printer->Print(\"}\\n\\n\");\n}\n\nvoid ImmutableServiceGenerator::GenerateGetDescriptorForType(\n    io::Printer* printer) {\n  printer->Print(\n    \"public final com.google.protobuf.Descriptors.ServiceDescriptor\\n\"\n    \"    getDescriptorForType() {\\n\"\n    \"  return getDescriptor();\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableServiceGenerator::GenerateInterface(io::Printer* printer) {\n  printer->Print(\"public interface Interface {\\n\");\n  printer->Indent();\n  GenerateAbstractMethods(printer);\n  printer->Outdent();\n  printer->Print(\"}\\n\\n\");\n}\n\nvoid ImmutableServiceGenerator::GenerateNewReflectiveServiceMethod(\n    io::Printer* printer) {\n  printer->Print(\n    \"public static com.google.protobuf.Service newReflectiveService(\\n\"\n    \"    final Interface impl) {\\n\"\n    \"  return new $classname$() {\\n\",\n    \"classname\", descriptor_->name());\n  printer->Indent();\n  printer->Indent();\n\n  for (int i = 0; i < descriptor_->method_count(); i++) {\n    const MethodDescriptor* method = descriptor_->method(i);\n    printer->Print(\"@java.lang.Override\\n\");\n    GenerateMethodSignature(printer, method, IS_CONCRETE);\n    printer->Print(\n      \" {\\n\"\n      \"  impl.$method$(controller, request, done);\\n\"\n      \"}\\n\\n\",\n      \"method\", UnderscoresToCamelCase(method));\n  }\n\n  printer->Outdent();\n  printer->Print(\"};\\n\");\n  printer->Outdent();\n  printer->Print(\"}\\n\\n\");\n}\n\nvoid ImmutableServiceGenerator::GenerateNewReflectiveBlockingServiceMethod(\n    io::Printer* printer) {\n  printer->Print(\n    \"public static com.google.protobuf.BlockingService\\n\"\n    \"    newReflectiveBlockingService(final BlockingInterface impl) {\\n\"\n    \"  return new com.google.protobuf.BlockingService() {\\n\");\n  printer->Indent();\n  printer->Indent();\n\n  GenerateGetDescriptorForType(printer);\n\n  GenerateCallBlockingMethod(printer);\n  GenerateGetPrototype(REQUEST, printer);\n  GenerateGetPrototype(RESPONSE, printer);\n\n  printer->Outdent();\n  printer->Print(\"};\\n\");\n  printer->Outdent();\n  printer->Print(\"}\\n\\n\");\n}\n\nvoid ImmutableServiceGenerator::GenerateAbstractMethods(io::Printer* printer) {\n  for (int i = 0; i < descriptor_->method_count(); i++) {\n    const MethodDescriptor* method = descriptor_->method(i);\n    WriteMethodDocComment(printer, method);\n    GenerateMethodSignature(printer, method, IS_ABSTRACT);\n    printer->Print(\";\\n\\n\");\n  }\n}\n\nvoid ImmutableServiceGenerator::GenerateCallMethod(io::Printer* printer) {\n  printer->Print(\n    \"\\n\"\n    \"public final void callMethod(\\n\"\n    \"    com.google.protobuf.Descriptors.MethodDescriptor method,\\n\"\n    \"    com.google.protobuf.RpcController controller,\\n\"\n    \"    com.google.protobuf.Message request,\\n\"\n    \"    com.google.protobuf.RpcCallback<\\n\"\n    \"      com.google.protobuf.Message> done) {\\n\"\n    \"  if (method.getService() != getDescriptor()) {\\n\"\n    \"    throw new java.lang.IllegalArgumentException(\\n\"\n    \"      \\\"Service.callMethod() given method descriptor for wrong \\\" +\\n\"\n    \"      \\\"service type.\\\");\\n\"\n    \"  }\\n\"\n    \"  switch(method.getIndex()) {\\n\");\n  printer->Indent();\n  printer->Indent();\n\n  for (int i = 0; i < descriptor_->method_count(); i++) {\n    const MethodDescriptor* method = descriptor_->method(i);\n    map<string, string> vars;\n    vars[\"index\"] = SimpleItoa(i);\n    vars[\"method\"] = UnderscoresToCamelCase(method);\n    vars[\"input\"] = name_resolver_->GetImmutableClassName(\n        method->input_type());\n    vars[\"output\"] = name_resolver_->GetImmutableClassName(\n        method->output_type());\n    printer->Print(vars,\n      \"case $index$:\\n\"\n      \"  this.$method$(controller, ($input$)request,\\n\"\n      \"    com.google.protobuf.RpcUtil.<$output$>specializeCallback(\\n\"\n      \"      done));\\n\"\n      \"  return;\\n\");\n  }\n\n  printer->Print(\n    \"default:\\n\"\n    \"  throw new java.lang.AssertionError(\\\"Can't get here.\\\");\\n\");\n\n  printer->Outdent();\n  printer->Outdent();\n\n  printer->Print(\n    \"  }\\n\"\n    \"}\\n\"\n    \"\\n\");\n}\n\nvoid ImmutableServiceGenerator::GenerateCallBlockingMethod(\n    io::Printer* printer) {\n  printer->Print(\n    \"\\n\"\n    \"public final com.google.protobuf.Message callBlockingMethod(\\n\"\n    \"    com.google.protobuf.Descriptors.MethodDescriptor method,\\n\"\n    \"    com.google.protobuf.RpcController controller,\\n\"\n    \"    com.google.protobuf.Message request)\\n\"\n    \"    throws com.google.protobuf.ServiceException {\\n\"\n    \"  if (method.getService() != getDescriptor()) {\\n\"\n    \"    throw new java.lang.IllegalArgumentException(\\n\"\n    \"      \\\"Service.callBlockingMethod() given method descriptor for \\\" +\\n\"\n    \"      \\\"wrong service type.\\\");\\n\"\n    \"  }\\n\"\n    \"  switch(method.getIndex()) {\\n\");\n  printer->Indent();\n  printer->Indent();\n\n  for (int i = 0; i < descriptor_->method_count(); i++) {\n    const MethodDescriptor* method = descriptor_->method(i);\n    map<string, string> vars;\n    vars[\"index\"] = SimpleItoa(i);\n    vars[\"method\"] = UnderscoresToCamelCase(method);\n    vars[\"input\"] = name_resolver_->GetImmutableClassName(\n        method->input_type());\n    vars[\"output\"] = name_resolver_->GetImmutableClassName(\n        method->output_type());\n    printer->Print(vars,\n      \"case $index$:\\n\"\n      \"  return impl.$method$(controller, ($input$)request);\\n\");\n  }\n\n  printer->Print(\n    \"default:\\n\"\n    \"  throw new java.lang.AssertionError(\\\"Can't get here.\\\");\\n\");\n\n  printer->Outdent();\n  printer->Outdent();\n\n  printer->Print(\n    \"  }\\n\"\n    \"}\\n\"\n    \"\\n\");\n}\n\nvoid ImmutableServiceGenerator::GenerateGetPrototype(RequestOrResponse which,\n                                            io::Printer* printer) {\n  /*\n   * TODO(cpovirk): The exception message says \"Service.foo\" when it may be\n   * \"BlockingService.foo.\"  Consider fixing.\n   */\n  printer->Print(\n    \"public final com.google.protobuf.Message\\n\"\n    \"    get$request_or_response$Prototype(\\n\"\n    \"    com.google.protobuf.Descriptors.MethodDescriptor method) {\\n\"\n    \"  if (method.getService() != getDescriptor()) {\\n\"\n    \"    throw new java.lang.IllegalArgumentException(\\n\"\n    \"      \\\"Service.get$request_or_response$Prototype() given method \\\" +\\n\"\n    \"      \\\"descriptor for wrong service type.\\\");\\n\"\n    \"  }\\n\"\n    \"  switch(method.getIndex()) {\\n\",\n    \"request_or_response\", (which == REQUEST) ? \"Request\" : \"Response\");\n  printer->Indent();\n  printer->Indent();\n\n  for (int i = 0; i < descriptor_->method_count(); i++) {\n    const MethodDescriptor* method = descriptor_->method(i);\n    map<string, string> vars;\n    vars[\"index\"] = SimpleItoa(i);\n    vars[\"type\"] = name_resolver_->GetImmutableClassName(\n      (which == REQUEST) ? method->input_type() : method->output_type());\n    printer->Print(vars,\n      \"case $index$:\\n\"\n      \"  return $type$.getDefaultInstance();\\n\");\n  }\n\n  printer->Print(\n    \"default:\\n\"\n    \"  throw new java.lang.AssertionError(\\\"Can't get here.\\\");\\n\");\n\n  printer->Outdent();\n  printer->Outdent();\n\n  printer->Print(\n    \"  }\\n\"\n    \"}\\n\"\n    \"\\n\");\n}\n\nvoid ImmutableServiceGenerator::GenerateStub(io::Printer* printer) {\n  printer->Print(\n    \"public static Stub newStub(\\n\"\n    \"    com.google.protobuf.RpcChannel channel) {\\n\"\n    \"  return new Stub(channel);\\n\"\n    \"}\\n\"\n    \"\\n\"\n    \"public static final class Stub extends $classname$ implements Interface {\"\n    \"\\n\",\n    \"classname\", name_resolver_->GetImmutableClassName(descriptor_));\n  printer->Indent();\n\n  printer->Print(\n    \"private Stub(com.google.protobuf.RpcChannel channel) {\\n\"\n    \"  this.channel = channel;\\n\"\n    \"}\\n\"\n    \"\\n\"\n    \"private final com.google.protobuf.RpcChannel channel;\\n\"\n    \"\\n\"\n    \"public com.google.protobuf.RpcChannel getChannel() {\\n\"\n    \"  return channel;\\n\"\n    \"}\\n\");\n\n  for (int i = 0; i < descriptor_->method_count(); i++) {\n    const MethodDescriptor* method = descriptor_->method(i);\n    printer->Print(\"\\n\");\n    GenerateMethodSignature(printer, method, IS_CONCRETE);\n    printer->Print(\" {\\n\");\n    printer->Indent();\n\n    map<string, string> vars;\n    vars[\"index\"] = SimpleItoa(i);\n    vars[\"output\"] = name_resolver_->GetImmutableClassName(\n        method->output_type());\n    printer->Print(vars,\n      \"channel.callMethod(\\n\"\n      \"  getDescriptor().getMethods().get($index$),\\n\"\n      \"  controller,\\n\"\n      \"  request,\\n\"\n      \"  $output$.getDefaultInstance(),\\n\"\n      \"  com.google.protobuf.RpcUtil.generalizeCallback(\\n\"\n      \"    done,\\n\"\n      \"    $output$.class,\\n\"\n      \"    $output$.getDefaultInstance()));\\n\");\n\n    printer->Outdent();\n    printer->Print(\"}\\n\");\n  }\n\n  printer->Outdent();\n  printer->Print(\n    \"}\\n\"\n    \"\\n\");\n}\n\nvoid ImmutableServiceGenerator::GenerateBlockingStub(io::Printer* printer) {\n  printer->Print(\n    \"public static BlockingInterface newBlockingStub(\\n\"\n    \"    com.google.protobuf.BlockingRpcChannel channel) {\\n\"\n    \"  return new BlockingStub(channel);\\n\"\n    \"}\\n\"\n    \"\\n\");\n\n  printer->Print(\n    \"public interface BlockingInterface {\");\n  printer->Indent();\n\n  for (int i = 0; i < descriptor_->method_count(); i++) {\n    const MethodDescriptor* method = descriptor_->method(i);\n    GenerateBlockingMethodSignature(printer, method);\n    printer->Print(\";\\n\");\n  }\n\n  printer->Outdent();\n  printer->Print(\n    \"}\\n\"\n    \"\\n\");\n\n  printer->Print(\n    \"private static final class BlockingStub implements BlockingInterface {\\n\");\n  printer->Indent();\n\n  printer->Print(\n    \"private BlockingStub(com.google.protobuf.BlockingRpcChannel channel) {\\n\"\n    \"  this.channel = channel;\\n\"\n    \"}\\n\"\n    \"\\n\"\n    \"private final com.google.protobuf.BlockingRpcChannel channel;\\n\");\n\n  for (int i = 0; i < descriptor_->method_count(); i++) {\n    const MethodDescriptor* method = descriptor_->method(i);\n    GenerateBlockingMethodSignature(printer, method);\n    printer->Print(\" {\\n\");\n    printer->Indent();\n\n    map<string, string> vars;\n    vars[\"index\"] = SimpleItoa(i);\n    vars[\"output\"] = name_resolver_->GetImmutableClassName(\n        method->output_type());\n    printer->Print(vars,\n      \"return ($output$) channel.callBlockingMethod(\\n\"\n      \"  getDescriptor().getMethods().get($index$),\\n\"\n      \"  controller,\\n\"\n      \"  request,\\n\"\n      \"  $output$.getDefaultInstance());\\n\");\n\n    printer->Outdent();\n    printer->Print(\n      \"}\\n\"\n      \"\\n\");\n  }\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid ImmutableServiceGenerator::GenerateMethodSignature(io::Printer* printer,\n                                               const MethodDescriptor* method,\n                                               IsAbstract is_abstract) {\n  map<string, string> vars;\n  vars[\"name\"] = UnderscoresToCamelCase(method);\n  vars[\"input\"] = name_resolver_->GetImmutableClassName(method->input_type());\n  vars[\"output\"] = name_resolver_->GetImmutableClassName(method->output_type());\n  vars[\"abstract\"] = (is_abstract == IS_ABSTRACT) ? \"abstract\" : \"\";\n  printer->Print(vars,\n    \"public $abstract$ void $name$(\\n\"\n    \"    com.google.protobuf.RpcController controller,\\n\"\n    \"    $input$ request,\\n\"\n    \"    com.google.protobuf.RpcCallback<$output$> done)\");\n}\n\nvoid ImmutableServiceGenerator::GenerateBlockingMethodSignature(\n    io::Printer* printer,\n    const MethodDescriptor* method) {\n  map<string, string> vars;\n  vars[\"method\"] = UnderscoresToCamelCase(method);\n  vars[\"input\"] = name_resolver_->GetImmutableClassName(method->input_type());\n  vars[\"output\"] = name_resolver_->GetImmutableClassName(method->output_type());\n  printer->Print(vars,\n    \"\\n\"\n    \"public $output$ $method$(\\n\"\n    \"    com.google.protobuf.RpcController controller,\\n\"\n    \"    $input$ request)\\n\"\n    \"    throws com.google.protobuf.ServiceException\");\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_service.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_SERVICE_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_SERVICE_H__\n\n#include <map>\n#include <google/protobuf/descriptor.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace compiler {\n    namespace java {\n      class Context;            // context.h\n      class ClassNameResolver;  // name_resolver.h\n    }\n  }\n  namespace io {\n    class Printer;              // printer.h\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nclass ServiceGenerator {\n public:\n  explicit ServiceGenerator(const ServiceDescriptor* descriptor);\n  virtual ~ServiceGenerator();\n\n  virtual void Generate(io::Printer* printer) = 0;\n\n  enum RequestOrResponse { REQUEST, RESPONSE };\n  enum IsAbstract { IS_ABSTRACT, IS_CONCRETE };\n\n protected:\n  const ServiceDescriptor* descriptor_;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceGenerator);\n};\n\nclass ImmutableServiceGenerator : public ServiceGenerator {\n public:\n  ImmutableServiceGenerator(const ServiceDescriptor* descriptor,\n                            Context* context);\n  virtual ~ImmutableServiceGenerator();\n\n  virtual void Generate(io::Printer* printer);\n\n private:\n\n  // Generate the getDescriptorForType() method.\n  void GenerateGetDescriptorForType(io::Printer* printer);\n\n  // Generate a Java interface for the service.\n  void GenerateInterface(io::Printer* printer);\n\n  // Generate newReflectiveService() method.\n  void GenerateNewReflectiveServiceMethod(io::Printer* printer);\n\n  // Generate newReflectiveBlockingService() method.\n  void GenerateNewReflectiveBlockingServiceMethod(io::Printer* printer);\n\n  // Generate abstract method declarations for all methods.\n  void GenerateAbstractMethods(io::Printer* printer);\n\n  // Generate the implementation of Service.callMethod().\n  void GenerateCallMethod(io::Printer* printer);\n\n  // Generate the implementation of BlockingService.callBlockingMethod().\n  void GenerateCallBlockingMethod(io::Printer* printer);\n\n  // Generate the implementations of Service.get{Request,Response}Prototype().\n  void GenerateGetPrototype(RequestOrResponse which, io::Printer* printer);\n\n  // Generate a stub implementation of the service.\n  void GenerateStub(io::Printer* printer);\n\n  // Generate a method signature, possibly abstract, without body or trailing\n  // semicolon.\n  void GenerateMethodSignature(io::Printer* printer,\n                               const MethodDescriptor* method,\n                               IsAbstract is_abstract);\n\n  // Generate a blocking stub interface and implementation of the service.\n  void GenerateBlockingStub(io::Printer* printer);\n\n  // Generate the method signature for one method of a blocking stub.\n  void GenerateBlockingMethodSignature(io::Printer* printer,\n                                       const MethodDescriptor* method);\n\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableServiceGenerator);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n#endif  // NET_PROTO2_COMPILER_JAVA_SERVICE_H__\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_shared_code_generator.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: xiaofeng@google.com (Feng Xiao)\n\n#include <google/protobuf/compiler/java/java_shared_code_generator.h>\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nSharedCodeGenerator::SharedCodeGenerator(const FileDescriptor* file,\n                                         const Options& options)\n    : name_resolver_(new ClassNameResolver), file_(file), options_(options) {}\n\nSharedCodeGenerator::~SharedCodeGenerator() {\n}\n\nvoid SharedCodeGenerator::Generate(GeneratorContext* context,\n                                   vector<string>* file_list,\n                                   vector<string>* annotation_file_list) {\n  string java_package = FileJavaPackage(file_);\n  string package_dir = JavaPackageToDir(java_package);\n\n  if (HasDescriptorMethods(file_, options_.enforce_lite)) {\n    // Generate descriptors.\n    string classname = name_resolver_->GetDescriptorClassName(file_);\n    string filename = package_dir + classname + \".java\";\n    file_list->push_back(filename);\n    google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(context->Open(filename));\n    GeneratedCodeInfo annotations;\n    io::AnnotationProtoCollector<GeneratedCodeInfo> annotation_collector(\n        &annotations);\n    google::protobuf::scoped_ptr<io::Printer> printer(\n        new io::Printer(output.get(), '$',\n                        options_.annotate_code ? &annotation_collector : NULL));\n    string info_relative_path = classname + \".java.pb.meta\";\n    string info_full_path = filename + \".pb.meta\";\n    printer->Print(\n        \"// Generated by the protocol buffer compiler.  DO NOT EDIT!\\n\"\n        \"// source: $filename$\\n\"\n        \"\\n\",\n        \"filename\", file_->name());\n    if (!java_package.empty()) {\n      printer->Print(\n        \"package $package$;\\n\"\n        \"\\n\",\n        \"package\", java_package);\n    }\n    PrintGeneratedAnnotation(printer.get(), '$',\n                             options_.annotate_code ? info_relative_path : \"\");\n    printer->Print(\n        \"public final class $classname$ {\\n\"\n        \"  public static com.google.protobuf.Descriptors.FileDescriptor\\n\"\n        \"      descriptor;\\n\"\n        \"  static {\\n\",\n        \"classname\", classname);\n    printer->Annotate(\"classname\", file_->name());\n    printer->Indent();\n    printer->Indent();\n    GenerateDescriptors(printer.get());\n    printer->Outdent();\n    printer->Outdent();\n    printer->Print(\n      \"  }\\n\"\n      \"}\\n\");\n\n    if (options_.annotate_code) {\n      google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> info_output(\n          context->Open(info_full_path));\n      annotations.SerializeToZeroCopyStream(info_output.get());\n      annotation_file_list->push_back(info_full_path);\n    }\n\n    printer.reset();\n    output.reset();\n  }\n}\n\n\nvoid SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) {\n  // Embed the descriptor.  We simply serialize the entire FileDescriptorProto\n  // and embed it as a string literal, which is parsed and built into real\n  // descriptors at initialization time.  We unfortunately have to put it in\n  // a string literal, not a byte array, because apparently using a literal\n  // byte array causes the Java compiler to generate *instructions* to\n  // initialize each and every byte of the array, e.g. as if you typed:\n  //   b[0] = 123; b[1] = 456; b[2] = 789;\n  // This makes huge bytecode files and can easily hit the compiler's internal\n  // code size limits (error \"code to large\").  String literals are apparently\n  // embedded raw, which is what we want.\n  FileDescriptorProto file_proto;\n  file_->CopyTo(&file_proto);\n\n\n  string file_data;\n  file_proto.SerializeToString(&file_data);\n\n  printer->Print(\n    \"java.lang.String[] descriptorData = {\\n\");\n  printer->Indent();\n\n  // Only write 40 bytes per line.\n  static const int kBytesPerLine = 40;\n  for (int i = 0; i < file_data.size(); i += kBytesPerLine) {\n    if (i > 0) {\n      // Every 400 lines, start a new string literal, in order to avoid the\n      // 64k length limit.\n      if (i % 400 == 0) {\n        printer->Print(\",\\n\");\n      } else {\n        printer->Print(\" +\\n\");\n      }\n    }\n    printer->Print(\"\\\"$data$\\\"\",\n      \"data\", CEscape(file_data.substr(i, kBytesPerLine)));\n  }\n\n  printer->Outdent();\n  printer->Print(\"\\n};\\n\");\n\n  // -----------------------------------------------------------------\n  // Create the InternalDescriptorAssigner.\n\n  printer->Print(\n    \"com.google.protobuf.Descriptors.FileDescriptor.\"\n    \"InternalDescriptorAssigner assigner =\\n\"\n    \"    new com.google.protobuf.Descriptors.FileDescriptor.\"\n    \"    InternalDescriptorAssigner() {\\n\"\n    \"      public com.google.protobuf.ExtensionRegistry assignDescriptors(\\n\"\n    \"          com.google.protobuf.Descriptors.FileDescriptor root) {\\n\"\n    \"        descriptor = root;\\n\"\n    // Custom options will be handled when immutable messages' outer class is\n    // loaded. Here we just return null and let custom options be unknown\n    // fields.\n    \"        return null;\\n\"\n    \"      }\\n\"\n    \"    };\\n\");\n\n  // -----------------------------------------------------------------\n  // Find out all dependencies.\n  vector<pair<string, string> > dependencies;\n  for (int i = 0; i < file_->dependency_count(); i++) {\n    if (ShouldIncludeDependency(file_->dependency(i))) {\n      string filename = file_->dependency(i)->name();\n      string classname = FileJavaPackage(file_->dependency(i)) + \".\" +\n                         name_resolver_->GetDescriptorClassName(\n                             file_->dependency(i));\n      dependencies.push_back(std::make_pair(filename, classname));\n    }\n  }\n\n  // -----------------------------------------------------------------\n  // Invoke internalBuildGeneratedFileFrom() to build the file.\n  printer->Print(\n    \"com.google.protobuf.Descriptors.FileDescriptor\\n\"\n    \"  .internalBuildGeneratedFileFrom(descriptorData,\\n\");\n  printer->Print(\n    \"    new com.google.protobuf.Descriptors.FileDescriptor[] {\\n\");\n\n  for (int i = 0; i < dependencies.size(); i++) {\n    const string& dependency = dependencies[i].second;\n    printer->Print(\n        \"      $dependency$.getDescriptor(),\\n\",\n        \"dependency\", dependency);\n  }\n\n  printer->Print(\n    \"    }, assigner);\\n\");\n}\n\nbool SharedCodeGenerator::ShouldIncludeDependency(\n    const FileDescriptor* descriptor) {\n  return true;\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_shared_code_generator.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: xiaofeng@google.com (Feng Xiao)\n//\n// Generators that generate shared code between immutable API and mutable API.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_SHARED_CODE_GENERATOR_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_SHARED_CODE_GENERATOR_H__\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <string>\n#include <vector>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/compiler/java/java_options.h>\n\nnamespace google {\nnamespace protobuf {\n  class FileDescriptor;        // descriptor.h\n  namespace compiler {\n    class GeneratorContext;    // code_generator.h\n    namespace java {\n      class ClassNameResolver;       // name_resolver.h\n    }\n  }\n  namespace io {\n    class Printer;             // printer.h\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\n// A generator that generates code that are shared between immutable API\n// and mutable API. Currently only descriptors are shared.\nclass SharedCodeGenerator {\n public:\n  SharedCodeGenerator(const FileDescriptor* file, const Options& options);\n  ~SharedCodeGenerator();\n\n  void Generate(GeneratorContext* generator_context, vector<string>* file_list,\n                vector<string>* annotation_file_list);\n\n  void GenerateDescriptors(io::Printer* printer);\n\n private:\n  // Returns whether the dependency should be included in the output file.\n  // Always returns true for opensource, but used internally at Google to help\n  // improve compatibility with version 1 of protocol buffers.\n  bool ShouldIncludeDependency(const FileDescriptor* descriptor);\n\n  google::protobuf::scoped_ptr<ClassNameResolver> name_resolver_;\n  const FileDescriptor* file_;\n  const Options options_;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SharedCodeGenerator);\n};\n\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_SHARED_CODE_GENERATOR_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_string_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n// Author: jonp@google.com (Jon Perlow)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/compiler/java/java_string_field.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nusing internal::WireFormat;\nusing internal::WireFormatLite;\n\nnamespace {\n\nvoid SetPrimitiveVariables(const FieldDescriptor* descriptor,\n                           int messageBitIndex,\n                           int builderBitIndex,\n                           const FieldGeneratorInfo* info,\n                           ClassNameResolver* name_resolver,\n                           map<string, string>* variables) {\n  SetCommonFieldVariables(descriptor, info, variables);\n\n  (*variables)[\"empty_list\"] = \"com.google.protobuf.LazyStringArrayList.EMPTY\";\n\n  (*variables)[\"default\"] = ImmutableDefaultValue(descriptor, name_resolver);\n  (*variables)[\"default_init\"] =\n      \"= \" + ImmutableDefaultValue(descriptor, name_resolver);\n  (*variables)[\"capitalized_type\"] = \"String\";\n  (*variables)[\"tag\"] = SimpleItoa(WireFormat::MakeTag(descriptor));\n  (*variables)[\"tag_size\"] = SimpleItoa(\n      WireFormat::TagSize(descriptor->number(), GetType(descriptor)));\n  (*variables)[\"null_check\"] =\n      \"  if (value == null) {\\n\"\n      \"    throw new NullPointerException();\\n\"\n      \"  }\\n\";\n  (*variables)[\"writeString\"] =\n      \"com.google.protobuf.GeneratedMessage\" + GeneratedCodeVersionSuffix() +\n      \".writeString\";\n  (*variables)[\"computeStringSize\"] =\n      \"com.google.protobuf.GeneratedMessage\" + GeneratedCodeVersionSuffix() +\n      \".computeStringSize\";\n\n  // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported\n  // by the proto compiler\n  (*variables)[\"deprecation\"] = descriptor->options().deprecated()\n      ? \"@java.lang.Deprecated \" : \"\";\n  (*variables)[\"on_changed\"] = \"onChanged();\";\n\n  if (SupportFieldPresence(descriptor->file())) {\n    // For singular messages and builders, one bit is used for the hasField bit.\n    (*variables)[\"get_has_field_bit_message\"] = GenerateGetBit(messageBitIndex);\n    (*variables)[\"get_has_field_bit_builder\"] = GenerateGetBit(builderBitIndex);\n\n    // Note that these have a trailing \";\".\n    (*variables)[\"set_has_field_bit_message\"] =\n        GenerateSetBit(messageBitIndex) + \";\";\n    (*variables)[\"set_has_field_bit_builder\"] =\n        GenerateSetBit(builderBitIndex) + \";\";\n    (*variables)[\"clear_has_field_bit_builder\"] =\n        GenerateClearBit(builderBitIndex) + \";\";\n\n    (*variables)[\"is_field_present_message\"] = GenerateGetBit(messageBitIndex);\n  } else {\n    (*variables)[\"set_has_field_bit_message\"] = \"\";\n    (*variables)[\"set_has_field_bit_builder\"] = \"\";\n    (*variables)[\"clear_has_field_bit_builder\"] = \"\";\n\n    (*variables)[\"is_field_present_message\"] =\n        \"!get\" + (*variables)[\"capitalized_name\"] + \"Bytes().isEmpty()\";\n  }\n\n  // For repeated builders, one bit is used for whether the array is immutable.\n  (*variables)[\"get_mutable_bit_builder\"] = GenerateGetBit(builderBitIndex);\n  (*variables)[\"set_mutable_bit_builder\"] = GenerateSetBit(builderBitIndex);\n  (*variables)[\"clear_mutable_bit_builder\"] = GenerateClearBit(builderBitIndex);\n\n  // For repeated fields, one bit is used for whether the array is immutable\n  // in the parsing constructor.\n  (*variables)[\"get_mutable_bit_parser\"] =\n      GenerateGetBitMutableLocal(builderBitIndex);\n  (*variables)[\"set_mutable_bit_parser\"] =\n      GenerateSetBitMutableLocal(builderBitIndex);\n\n  (*variables)[\"get_has_field_bit_from_local\"] =\n      GenerateGetBitFromLocal(builderBitIndex);\n  (*variables)[\"set_has_field_bit_to_local\"] =\n      GenerateSetBitToLocal(messageBitIndex);\n}\n\n}  // namespace\n\n// ===================================================================\n\nImmutableStringFieldGenerator::\nImmutableStringFieldGenerator(const FieldDescriptor* descriptor,\n                              int messageBitIndex,\n                              int builderBitIndex,\n                              Context* context)\n  : descriptor_(descriptor), messageBitIndex_(messageBitIndex),\n    builderBitIndex_(builderBitIndex), context_(context),\n    name_resolver_(context->GetNameResolver()) {\n  SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex,\n                        context->GetFieldGeneratorInfo(descriptor),\n                        name_resolver_, &variables_);\n}\n\nImmutableStringFieldGenerator::~ImmutableStringFieldGenerator() {}\n\nint ImmutableStringFieldGenerator::GetNumBitsForMessage() const {\n  return 1;\n}\n\nint ImmutableStringFieldGenerator::GetNumBitsForBuilder() const {\n  return 1;\n}\n\n// A note about how strings are handled. This code used to just store a String\n// in the Message. This had two issues:\n//\n//  1. It wouldn't roundtrip byte arrays that were not vaid UTF-8 encoded\n//     strings, but rather fields that were raw bytes incorrectly marked\n//     as strings in the proto file. This is common because in the proto1\n//     syntax, string was the way to indicate bytes and C++ engineers can\n//     easily make this mistake without affecting the C++ API. By converting to\n//     strings immediately, some java code might corrupt these byte arrays as\n//     it passes through a java server even if the field was never accessed by\n//     application code.\n//\n//  2. There's a performance hit to converting between bytes and strings and\n//     it many cases, the field is never even read by the application code. This\n//     avoids unnecessary conversions in the common use cases.\n//\n// So now, the field for String is maintained as an Object reference which can\n// either store a String or a ByteString. The code uses an instanceof check\n// to see which one it has and converts to the other one if needed. It remembers\n// the last value requested (in a thread safe manner) as this is most likely\n// the one needed next. The thread safety is such that if two threads both\n// convert the field because the changes made by each thread were not visible to\n// the other, they may cause a conversion to happen more times than would\n// otherwise be necessary. This was deemed better than adding synchronization\n// overhead. It will not cause any corruption issues or affect the behavior of\n// the API. The instanceof check is also highly optimized in the JVM and we\n// decided it was better to reduce the memory overhead by not having two\n// separate fields but rather use dynamic type checking.\n//\n// For single fields, the logic for this is done inside the generated code. For\n// repeated fields, the logic is done in LazyStringArrayList and\n// UnmodifiableLazyStringList.\nvoid ImmutableStringFieldGenerator::\nGenerateInterfaceMembers(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$boolean has$capitalized_name$();\\n\");\n  }\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$java.lang.String get$capitalized_name$();\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$com.google.protobuf.ByteString\\n\"\n    \"    get$capitalized_name$Bytes();\\n\");\n}\n\nvoid ImmutableStringFieldGenerator::\nGenerateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"private volatile java.lang.Object $name$_;\\n\");\n  PrintExtraFieldInfo(variables_, printer);\n\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $get_has_field_bit_message$;\\n\"\n      \"}\\n\");\n  }\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.lang.String get$capitalized_name$() {\\n\"\n    \"  java.lang.Object ref = $name$_;\\n\"\n    \"  if (ref instanceof java.lang.String) {\\n\"\n    \"    return (java.lang.String) ref;\\n\"\n    \"  } else {\\n\"\n    \"    com.google.protobuf.ByteString bs = \\n\"\n    \"        (com.google.protobuf.ByteString) ref;\\n\"\n      \"    java.lang.String s = bs.toStringUtf8();\\n\");\n  if (CheckUtf8(descriptor_)) {\n    printer->Print(variables_,\n      \"    $name$_ = s;\\n\");\n  } else {\n    printer->Print(variables_,\n      \"    if (bs.isValidUtf8()) {\\n\"\n      \"      $name$_ = s;\\n\"\n      \"    }\\n\");\n  }\n  printer->Print(variables_,\n    \"    return s;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public com.google.protobuf.ByteString\\n\"\n    \"    get$capitalized_name$Bytes() {\\n\"\n    \"  java.lang.Object ref = $name$_;\\n\"\n    \"  if (ref instanceof java.lang.String) {\\n\"\n    \"    com.google.protobuf.ByteString b = \\n\"\n    \"        com.google.protobuf.ByteString.copyFromUtf8(\\n\"\n    \"            (java.lang.String) ref);\\n\"\n    \"    $name$_ = b;\\n\"\n    \"    return b;\\n\"\n    \"  } else {\\n\"\n    \"    return (com.google.protobuf.ByteString) ref;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableStringFieldGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"private java.lang.Object $name$_ $default_init$;\\n\");\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $get_has_field_bit_builder$;\\n\"\n      \"}\\n\");\n  }\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.lang.String get$capitalized_name$() {\\n\"\n    \"  java.lang.Object ref = $name$_;\\n\"\n    \"  if (!(ref instanceof java.lang.String)) {\\n\"\n    \"    com.google.protobuf.ByteString bs =\\n\"\n    \"        (com.google.protobuf.ByteString) ref;\\n\"\n    \"    java.lang.String s = bs.toStringUtf8();\\n\");\n  if (CheckUtf8(descriptor_)) {\n    printer->Print(variables_,\n      \"    $name$_ = s;\\n\");\n  } else {\n    printer->Print(variables_,\n      \"    if (bs.isValidUtf8()) {\\n\"\n      \"      $name$_ = s;\\n\"\n      \"    }\\n\");\n  }\n  printer->Print(variables_,\n    \"    return s;\\n\"\n    \"  } else {\\n\"\n    \"    return (java.lang.String) ref;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public com.google.protobuf.ByteString\\n\"\n    \"    get$capitalized_name$Bytes() {\\n\"\n    \"  java.lang.Object ref = $name$_;\\n\"\n    \"  if (ref instanceof String) {\\n\"\n    \"    com.google.protobuf.ByteString b = \\n\"\n    \"        com.google.protobuf.ByteString.copyFromUtf8(\\n\"\n    \"            (java.lang.String) ref);\\n\"\n    \"    $name$_ = b;\\n\"\n    \"    return b;\\n\"\n    \"  } else {\\n\"\n    \"    return (com.google.protobuf.ByteString) ref;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    java.lang.String value) {\\n\"\n    \"$null_check$\"\n    \"  $set_has_field_bit_builder$\\n\"\n    \"  $name$_ = value;\\n\"\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  $clear_has_field_bit_builder$\\n\");\n  // The default value is not a simple literal so we want to avoid executing\n  // it multiple times.  Instead, get the default out of the default instance.\n  printer->Print(variables_,\n    \"  $name$_ = getDefaultInstance().get$capitalized_name$();\\n\");\n  printer->Print(variables_,\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$Bytes(\\n\"\n    \"    com.google.protobuf.ByteString value) {\\n\"\n    \"$null_check$\");\n  if (CheckUtf8(descriptor_)) {\n    printer->Print(variables_,\n      \"  checkByteStringIsUtf8(value);\\n\");\n  }\n  printer->Print(variables_,\n    \"  $set_has_field_bit_builder$\\n\"\n    \"  $name$_ = value;\\n\"\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableStringFieldGenerator::\nGenerateFieldBuilderInitializationCode(io::Printer* printer)  const {\n  // noop for primitives\n}\n\nvoid ImmutableStringFieldGenerator::\nGenerateInitializationCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_ = $default$;\\n\");\n}\n\nvoid ImmutableStringFieldGenerator::\nGenerateBuilderClearCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$_ = $default$;\\n\"\n    \"$clear_has_field_bit_builder$\\n\");\n}\n\nvoid ImmutableStringFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    // Allow a slight breach of abstraction here in order to avoid forcing\n    // all string fields to Strings when copying fields from a Message.\n    printer->Print(variables_,\n      \"if (other.has$capitalized_name$()) {\\n\"\n      \"  $set_has_field_bit_builder$\\n\"\n      \"  $name$_ = other.$name$_;\\n\"\n      \"  $on_changed$\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables_,\n      \"if (!other.get$capitalized_name$().isEmpty()) {\\n\"\n      \"  $name$_ = other.$name$_;\\n\"\n      \"  $on_changed$\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid ImmutableStringFieldGenerator::\nGenerateBuildingCode(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    printer->Print(variables_,\n      \"if ($get_has_field_bit_from_local$) {\\n\"\n      \"  $set_has_field_bit_to_local$;\\n\"\n      \"}\\n\");\n  }\n  printer->Print(variables_,\n    \"result.$name$_ = $name$_;\\n\");\n}\n\nvoid ImmutableStringFieldGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  if (CheckUtf8(descriptor_)) {\n    printer->Print(variables_,\n      \"java.lang.String s = input.readStringRequireUtf8();\\n\"\n      \"$set_has_field_bit_message$\\n\"\n      \"$name$_ = s;\\n\");\n  } else {\n    printer->Print(variables_,\n      \"com.google.protobuf.ByteString bs = input.readBytes();\\n\"\n      \"$set_has_field_bit_message$\\n\"\n      \"$name$_ = bs;\\n\");\n  }\n}\n\nvoid ImmutableStringFieldGenerator::\nGenerateParsingDoneCode(io::Printer* printer) const {\n  // noop for strings.\n}\n\nvoid ImmutableStringFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($is_field_present_message$) {\\n\"\n    \"  $writeString$(output, $number$, $name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableStringFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($is_field_present_message$) {\\n\"\n    \"  size += $computeStringSize$($number$, $name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableStringFieldGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"result = result && get$capitalized_name$()\\n\"\n    \"    .equals(other.get$capitalized_name$());\\n\");\n}\n\nvoid ImmutableStringFieldGenerator::\nGenerateHashCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"hash = (37 * hash) + $constant_name$;\\n\");\n  printer->Print(variables_,\n    \"hash = (53 * hash) + get$capitalized_name$().hashCode();\\n\");\n}\n\nstring ImmutableStringFieldGenerator::GetBoxedType() const {\n  return \"java.lang.String\";\n}\n\n// ===================================================================\n\nImmutableStringOneofFieldGenerator::\nImmutableStringOneofFieldGenerator(const FieldDescriptor* descriptor,\n                                   int messageBitIndex,\n                                   int builderBitIndex,\n                                   Context* context)\n    : ImmutableStringFieldGenerator(\n          descriptor, messageBitIndex, builderBitIndex, context) {\n  const OneofGeneratorInfo* info =\n      context->GetOneofGeneratorInfo(descriptor->containing_oneof());\n  SetCommonOneofVariables(descriptor, info, &variables_);\n}\n\nImmutableStringOneofFieldGenerator::\n~ImmutableStringOneofFieldGenerator() {}\n\nvoid ImmutableStringOneofFieldGenerator::\nGenerateMembers(io::Printer* printer) const {\n  PrintExtraFieldInfo(variables_, printer);\n\n  if (SupportFieldPresence(descriptor_->file())) {\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n    \"  return $has_oneof_case_message$;\\n\"\n    \"}\\n\");\n  }\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.lang.String get$capitalized_name$() {\\n\"\n    \"  java.lang.Object ref $default_init$;\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    ref = $oneof_name$_;\\n\"\n    \"  }\\n\"\n    \"  if (ref instanceof java.lang.String) {\\n\"\n    \"    return (java.lang.String) ref;\\n\"\n    \"  } else {\\n\"\n    \"    com.google.protobuf.ByteString bs = \\n\"\n    \"        (com.google.protobuf.ByteString) ref;\\n\"\n    \"    java.lang.String s = bs.toStringUtf8();\\n\");\n  if (CheckUtf8(descriptor_)) {\n    printer->Print(variables_,\n    \"    if ($has_oneof_case_message$) {\\n\"\n    \"      $oneof_name$_ = s;\\n\"\n    \"    }\\n\");\n  } else {\n    printer->Print(variables_,\n    \"    if (bs.isValidUtf8() && ($has_oneof_case_message$)) {\\n\"\n    \"      $oneof_name$_ = s;\\n\"\n    \"    }\\n\");\n  }\n  printer->Print(variables_,\n    \"    return s;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n\n  printer->Print(variables_,\n    \"$deprecation$public com.google.protobuf.ByteString\\n\"\n    \"    get$capitalized_name$Bytes() {\\n\"\n    \"  java.lang.Object ref $default_init$;\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    ref = $oneof_name$_;\\n\"\n    \"  }\\n\"\n    \"  if (ref instanceof java.lang.String) {\\n\"\n    \"    com.google.protobuf.ByteString b = \\n\"\n    \"        com.google.protobuf.ByteString.copyFromUtf8(\\n\"\n    \"            (java.lang.String) ref);\\n\"\n    \"    if ($has_oneof_case_message$) {\\n\"\n    \"      $oneof_name$_ = b;\\n\"\n    \"    }\\n\"\n    \"    return b;\\n\"\n    \"  } else {\\n\"\n    \"    return (com.google.protobuf.ByteString) ref;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableStringOneofFieldGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $has_oneof_case_message$;\\n\"\n      \"}\\n\");\n  }\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.lang.String get$capitalized_name$() {\\n\"\n    \"  java.lang.Object ref $default_init$;\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    ref = $oneof_name$_;\\n\"\n    \"  }\\n\"\n    \"  if (!(ref instanceof java.lang.String)) {\\n\"\n    \"    com.google.protobuf.ByteString bs =\\n\"\n    \"        (com.google.protobuf.ByteString) ref;\\n\"\n    \"    java.lang.String s = bs.toStringUtf8();\\n\"\n    \"    if ($has_oneof_case_message$) {\\n\");\n  if (CheckUtf8(descriptor_)) {\n    printer->Print(variables_,\n      \"      $oneof_name$_ = s;\\n\");\n  } else {\n    printer->Print(variables_,\n      \"      if (bs.isValidUtf8()) {\\n\"\n      \"        $oneof_name$_ = s;\\n\"\n      \"      }\\n\");\n  }\n  printer->Print(variables_,\n    \"    }\\n\"\n    \"    return s;\\n\"\n    \"  } else {\\n\"\n    \"    return (java.lang.String) ref;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public com.google.protobuf.ByteString\\n\"\n    \"    get$capitalized_name$Bytes() {\\n\"\n    \"  java.lang.Object ref $default_init$;\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    ref = $oneof_name$_;\\n\"\n    \"  }\\n\"\n    \"  if (ref instanceof String) {\\n\"\n    \"    com.google.protobuf.ByteString b = \\n\"\n    \"        com.google.protobuf.ByteString.copyFromUtf8(\\n\"\n    \"            (java.lang.String) ref);\\n\"\n    \"    if ($has_oneof_case_message$) {\\n\"\n    \"      $oneof_name$_ = b;\\n\"\n    \"    }\\n\"\n    \"    return b;\\n\"\n    \"  } else {\\n\"\n    \"    return (com.google.protobuf.ByteString) ref;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    java.lang.String value) {\\n\"\n    \"$null_check$\"\n    \"  $set_oneof_case_message$;\\n\"\n    \"  $oneof_name$_ = value;\\n\"\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    $clear_oneof_case_message$;\\n\"\n    \"    $oneof_name$_ = null;\\n\"\n    \"    $on_changed$\\n\"\n    \"  }\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$Bytes(\\n\"\n    \"    com.google.protobuf.ByteString value) {\\n\"\n    \"$null_check$\");\n  if (CheckUtf8(descriptor_)) {\n    printer->Print(variables_,\n      \"  checkByteStringIsUtf8(value);\\n\");\n  }\n  printer->Print(variables_,\n    \"  $set_oneof_case_message$;\\n\"\n    \"  $oneof_name$_ = value;\\n\"\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableStringOneofFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  // Allow a slight breach of abstraction here in order to avoid forcing\n  // all string fields to Strings when copying fields from a Message.\n  printer->Print(variables_,\n    \"$set_oneof_case_message$;\\n\"\n    \"$oneof_name$_ = other.$oneof_name$_;\\n\"\n    \"$on_changed$\\n\");\n}\n\nvoid ImmutableStringOneofFieldGenerator::\nGenerateBuildingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  result.$oneof_name$_ = $oneof_name$_;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableStringOneofFieldGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  if (CheckUtf8(descriptor_)) {\n    printer->Print(variables_,\n      \"java.lang.String s = input.readStringRequireUtf8();\\n\"\n      \"$set_oneof_case_message$;\\n\"\n      \"$oneof_name$_ = s;\\n\");\n  } else {\n    printer->Print(variables_,\n      \"com.google.protobuf.ByteString bs = input.readBytes();\\n\"\n      \"$set_oneof_case_message$;\\n\"\n      \"$oneof_name$_ = bs;\\n\");\n  }\n}\n\nvoid ImmutableStringOneofFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  $writeString$(output, $number$, $oneof_name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableStringOneofFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  size += $computeStringSize$($number$, $oneof_name$_);\\n\"\n    \"}\\n\");\n}\n\n// ===================================================================\n\nRepeatedImmutableStringFieldGenerator::\nRepeatedImmutableStringFieldGenerator(const FieldDescriptor* descriptor,\n                                      int messageBitIndex,\n                                      int builderBitIndex,\n                                      Context* context)\n  : descriptor_(descriptor), messageBitIndex_(messageBitIndex),\n    builderBitIndex_(builderBitIndex), context_(context),\n    name_resolver_(context->GetNameResolver()) {\n  SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex,\n                        context->GetFieldGeneratorInfo(descriptor),\n                        name_resolver_, &variables_);\n}\n\nRepeatedImmutableStringFieldGenerator::\n~RepeatedImmutableStringFieldGenerator() {}\n\nint RepeatedImmutableStringFieldGenerator::GetNumBitsForMessage() const {\n  return 0;\n}\n\nint RepeatedImmutableStringFieldGenerator::GetNumBitsForBuilder() const {\n  return 1;\n}\n\nvoid RepeatedImmutableStringFieldGenerator::\nGenerateInterfaceMembers(io::Printer* printer) const {\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    // NOTE: the same method in the implementation class actually returns\n    // com.google.protobuf.ProtocolStringList (a subclass of List). It's\n    // changed between protobuf 2.5.0 release and protobuf 2.6.1 release.\n    // To retain binary compatibility with both 2.5.0 and 2.6.1 generated\n    // code, we make this interface method return List so both methods\n    // with different return types exist in the compiled byte code.\n    \"$deprecation$java.util.List<java.lang.String>\\n\"\n    \"    get$capitalized_name$List();\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$int get$capitalized_name$Count();\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$java.lang.String get$capitalized_name$(int index);\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$com.google.protobuf.ByteString\\n\"\n    \"    get$capitalized_name$Bytes(int index);\\n\");\n}\n\n\nvoid RepeatedImmutableStringFieldGenerator::\nGenerateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"private com.google.protobuf.LazyStringList $name$_;\\n\");\n  PrintExtraFieldInfo(variables_, printer);\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public com.google.protobuf.ProtocolStringList\\n\"\n    \"    get$capitalized_name$List() {\\n\"\n    \"  return $name$_;\\n\"   // note:  unmodifiable list\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public int get$capitalized_name$Count() {\\n\"\n    \"  return $name$_.size();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.lang.String get$capitalized_name$(int index) {\\n\"\n    \"  return $name$_.get(index);\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public com.google.protobuf.ByteString\\n\"\n    \"    get$capitalized_name$Bytes(int index) {\\n\"\n    \"  return $name$_.getByteString(index);\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableStringFieldGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  // One field is the list and the bit field keeps track of whether the\n  // list is immutable. If it's immutable, the invariant is that it must\n  // either an instance of Collections.emptyList() or it's an ArrayList\n  // wrapped in a Collections.unmodifiableList() wrapper and nobody else has\n  // a refererence to the underlying ArrayList. This invariant allows us to\n  // share instances of lists between protocol buffers avoiding expensive\n  // memory allocations. Note, immutable is a strong guarantee here -- not\n  // just that the list cannot be modified via the reference but that the\n  // list can never be modified.\n  printer->Print(variables_,\n    \"private com.google.protobuf.LazyStringList $name$_ = $empty_list$;\\n\");\n\n  printer->Print(variables_,\n    \"private void ensure$capitalized_name$IsMutable() {\\n\"\n    \"  if (!$get_mutable_bit_builder$) {\\n\"\n    \"    $name$_ = new com.google.protobuf.LazyStringArrayList($name$_);\\n\"\n    \"    $set_mutable_bit_builder$;\\n\"\n    \"   }\\n\"\n    \"}\\n\");\n\n    // Note:  We return an unmodifiable list because otherwise the caller\n    //   could hold on to the returned list and modify it after the message\n    //   has been built, thus mutating the message which is supposed to be\n    //   immutable.\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public com.google.protobuf.ProtocolStringList\\n\"\n    \"    get$capitalized_name$List() {\\n\"\n    \"  return $name$_.getUnmodifiableView();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public int get$capitalized_name$Count() {\\n\"\n    \"  return $name$_.size();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.lang.String get$capitalized_name$(int index) {\\n\"\n    \"  return $name$_.get(index);\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public com.google.protobuf.ByteString\\n\"\n    \"    get$capitalized_name$Bytes(int index) {\\n\"\n    \"  return $name$_.getByteString(index);\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    int index, java.lang.String value) {\\n\"\n    \"$null_check$\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.set(index, value);\\n\"\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder add$capitalized_name$(\\n\"\n    \"    java.lang.String value) {\\n\"\n    \"$null_check$\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.add(value);\\n\"\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder addAll$capitalized_name$(\\n\"\n    \"    java.lang.Iterable<java.lang.String> values) {\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  com.google.protobuf.AbstractMessageLite.Builder.addAll(\\n\"\n    \"      values, $name$_);\\n\"\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  $name$_ = $empty_list$;\\n\"\n    \"  $clear_mutable_bit_builder$;\\n\"\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder add$capitalized_name$Bytes(\\n\"\n    \"    com.google.protobuf.ByteString value) {\\n\"\n    \"$null_check$\");\n  if (CheckUtf8(descriptor_)) {\n    printer->Print(variables_,\n      \"  checkByteStringIsUtf8(value);\\n\");\n  }\n  printer->Print(variables_,\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.add(value);\\n\"\n    \"  $on_changed$\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableStringFieldGenerator::\nGenerateFieldBuilderInitializationCode(io::Printer* printer)  const {\n  // noop for primitives\n}\n\nvoid RepeatedImmutableStringFieldGenerator::\nGenerateInitializationCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_ = $empty_list$;\\n\");\n}\n\nvoid RepeatedImmutableStringFieldGenerator::\nGenerateBuilderClearCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$_ = $empty_list$;\\n\"\n    \"$clear_mutable_bit_builder$;\\n\");\n}\n\nvoid RepeatedImmutableStringFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  // The code below does two optimizations:\n  //   1. If the other list is empty, there's nothing to do. This ensures we\n  //      don't allocate a new array if we already have an immutable one.\n  //   2. If the other list is non-empty and our current list is empty, we can\n  //      reuse the other list which is guaranteed to be immutable.\n  printer->Print(variables_,\n    \"if (!other.$name$_.isEmpty()) {\\n\"\n    \"  if ($name$_.isEmpty()) {\\n\"\n    \"    $name$_ = other.$name$_;\\n\"\n    \"    $clear_mutable_bit_builder$;\\n\"\n    \"  } else {\\n\"\n    \"    ensure$capitalized_name$IsMutable();\\n\"\n    \"    $name$_.addAll(other.$name$_);\\n\"\n    \"  }\\n\"\n    \"  $on_changed$\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableStringFieldGenerator::\nGenerateBuildingCode(io::Printer* printer) const {\n  // The code below ensures that the result has an immutable list. If our\n  // list is immutable, we can just reuse it. If not, we make it immutable.\n\n  printer->Print(variables_,\n    \"if ($get_mutable_bit_builder$) {\\n\"\n    \"  $name$_ = $name$_.getUnmodifiableView();\\n\"\n    \"  $clear_mutable_bit_builder$;\\n\"\n    \"}\\n\"\n    \"result.$name$_ = $name$_;\\n\");\n}\n\nvoid RepeatedImmutableStringFieldGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  if (CheckUtf8(descriptor_)) {\n    printer->Print(variables_,\n    \"java.lang.String s = input.readStringRequireUtf8();\\n\");\n  } else {\n    printer->Print(variables_,\n    \"com.google.protobuf.ByteString bs = input.readBytes();\\n\");\n  }\n  printer->Print(variables_,\n    \"if (!$get_mutable_bit_parser$) {\\n\"\n    \"  $name$_ = new com.google.protobuf.LazyStringArrayList();\\n\"\n    \"  $set_mutable_bit_parser$;\\n\"\n    \"}\\n\");\n  if (CheckUtf8(descriptor_)) {\n    printer->Print(variables_,\n      \"$name$_.add(s);\\n\");\n  } else {\n    printer->Print(variables_,\n      \"$name$_.add(bs);\\n\");\n  }\n}\n\nvoid RepeatedImmutableStringFieldGenerator::\nGenerateParsingDoneCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($get_mutable_bit_parser$) {\\n\"\n    \"  $name$_ = $name$_.getUnmodifiableView();\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableStringFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n    \"  $writeString$(output, $number$, $name$_.getRaw(i));\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableStringFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"{\\n\"\n    \"  int dataSize = 0;\\n\");\n  printer->Indent();\n\n  printer->Print(variables_,\n    \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n    \"  dataSize += computeStringSizeNoTag($name$_.getRaw(i));\\n\"\n    \"}\\n\");\n\n  printer->Print(\n      \"size += dataSize;\\n\");\n\n  printer->Print(variables_,\n    \"size += $tag_size$ * get$capitalized_name$List().size();\\n\");\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid RepeatedImmutableStringFieldGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"result = result && get$capitalized_name$List()\\n\"\n    \"    .equals(other.get$capitalized_name$List());\\n\");\n}\n\nvoid RepeatedImmutableStringFieldGenerator::\nGenerateHashCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (get$capitalized_name$Count() > 0) {\\n\"\n    \"  hash = (37 * hash) + $constant_name$;\\n\"\n    \"  hash = (53 * hash) + get$capitalized_name$List().hashCode();\\n\"\n    \"}\\n\");\n}\n\nstring RepeatedImmutableStringFieldGenerator::GetBoxedType() const {\n  return \"String\";\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_string_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n// Author: jonp@google.com (Jon Perlow)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_H__\n\n#include <map>\n#include <string>\n#include <google/protobuf/compiler/java/java_field.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace compiler {\n    namespace java {\n      class Context;           // context.h\n      class ClassNameResolver; // name_resolver.h\n    }\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nclass ImmutableStringFieldGenerator : public ImmutableFieldGenerator {\n public:\n  explicit ImmutableStringFieldGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~ImmutableStringFieldGenerator();\n\n  // implements ImmutableFieldGenerator ---------------------------------------\n  int GetNumBitsForMessage() const;\n  int GetNumBitsForBuilder() const;\n  void GenerateInterfaceMembers(io::Printer* printer) const;\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateInitializationCode(io::Printer* printer) const;\n  void GenerateBuilderClearCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateBuildingCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateParsingDoneCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCode(io::Printer* printer) const;\n\n  string GetBoxedType() const;\n\n protected:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n  const int messageBitIndex_;\n  const int builderBitIndex_;\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableStringFieldGenerator);\n};\n\nclass ImmutableStringOneofFieldGenerator\n    : public ImmutableStringFieldGenerator {\n public:\n  ImmutableStringOneofFieldGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~ImmutableStringOneofFieldGenerator();\n\n private:\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateBuildingCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableStringOneofFieldGenerator);\n};\n\nclass RepeatedImmutableStringFieldGenerator : public ImmutableFieldGenerator {\n public:\n  explicit RepeatedImmutableStringFieldGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~RepeatedImmutableStringFieldGenerator();\n\n  // implements ImmutableFieldGenerator ---------------------------------------\n  int GetNumBitsForMessage() const;\n  int GetNumBitsForBuilder() const;\n  void GenerateInterfaceMembers(io::Printer* printer) const;\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateInitializationCode(io::Printer* printer) const;\n  void GenerateBuilderClearCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateBuildingCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateParsingDoneCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCode(io::Printer* printer) const;\n\n  string GetBoxedType() const;\n\n private:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n  const int messageBitIndex_;\n  const int builderBitIndex_;\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableStringFieldGenerator);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_string_field_lite.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n// Author: jonp@google.com (Jon Perlow)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/compiler/java/java_context.h>\n#include <google/protobuf/compiler/java/java_doc_comment.h>\n#include <google/protobuf/compiler/java/java_helpers.h>\n#include <google/protobuf/compiler/java/java_name_resolver.h>\n#include <google/protobuf/compiler/java/java_string_field_lite.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nusing internal::WireFormat;\nusing internal::WireFormatLite;\n\nnamespace {\n\nvoid SetPrimitiveVariables(const FieldDescriptor* descriptor,\n                           int messageBitIndex,\n                           int builderBitIndex,\n                           const FieldGeneratorInfo* info,\n                           ClassNameResolver* name_resolver,\n                           map<string, string>* variables) {\n  SetCommonFieldVariables(descriptor, info, variables);\n\n  (*variables)[\"empty_list\"] =\n      \"com.google.protobuf.GeneratedMessageLite.emptyProtobufList()\";\n\n  (*variables)[\"default\"] = ImmutableDefaultValue(descriptor, name_resolver);\n  (*variables)[\"default_init\"] =\n      \"= \" + ImmutableDefaultValue(descriptor, name_resolver);\n  (*variables)[\"capitalized_type\"] = \"String\";\n  (*variables)[\"tag\"] = SimpleItoa(WireFormat::MakeTag(descriptor));\n  (*variables)[\"tag_size\"] = SimpleItoa(\n      WireFormat::TagSize(descriptor->number(), GetType(descriptor)));\n  (*variables)[\"null_check\"] =\n      \"  if (value == null) {\\n\"\n      \"    throw new NullPointerException();\\n\"\n      \"  }\\n\";\n\n  // TODO(birdo): Add @deprecated javadoc when generating javadoc is supported\n  // by the proto compiler\n  (*variables)[\"deprecation\"] = descriptor->options().deprecated()\n      ? \"@java.lang.Deprecated \" : \"\";\n\n  if (SupportFieldPresence(descriptor->file())) {\n    // For singular messages and builders, one bit is used for the hasField bit.\n    (*variables)[\"get_has_field_bit_message\"] = GenerateGetBit(messageBitIndex);\n\n    // Note that these have a trailing \";\".\n    (*variables)[\"set_has_field_bit_message\"] =\n        GenerateSetBit(messageBitIndex) + \";\";\n    (*variables)[\"clear_has_field_bit_message\"] =\n        GenerateClearBit(messageBitIndex) + \";\";\n\n    (*variables)[\"is_field_present_message\"] = GenerateGetBit(messageBitIndex);\n  } else {\n    (*variables)[\"set_has_field_bit_message\"] = \"\";\n    (*variables)[\"clear_has_field_bit_message\"] = \"\";\n\n    (*variables)[\"is_field_present_message\"] =\n        \"!\" + (*variables)[\"name\"] + \"_.isEmpty()\";\n  }\n\n  // For repeated builders, the underlying list tracks mutability state.\n  (*variables)[\"is_mutable\"] = (*variables)[\"name\"] + \"_.isModifiable()\";\n\n  (*variables)[\"get_has_field_bit_from_local\"] =\n      GenerateGetBitFromLocal(builderBitIndex);\n  (*variables)[\"set_has_field_bit_to_local\"] =\n      GenerateSetBitToLocal(messageBitIndex);\n}\n\n}  // namespace\n\n// ===================================================================\n\nImmutableStringFieldLiteGenerator::\nImmutableStringFieldLiteGenerator(const FieldDescriptor* descriptor,\n                              int messageBitIndex,\n                              int builderBitIndex,\n                              Context* context)\n  : descriptor_(descriptor), messageBitIndex_(messageBitIndex),\n    builderBitIndex_(builderBitIndex), context_(context),\n    name_resolver_(context->GetNameResolver()) {\n  SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex,\n                        context->GetFieldGeneratorInfo(descriptor),\n                        name_resolver_, &variables_);\n}\n\nImmutableStringFieldLiteGenerator::~ImmutableStringFieldLiteGenerator() {}\n\nint ImmutableStringFieldLiteGenerator::GetNumBitsForMessage() const {\n  return 1;\n}\n\nint ImmutableStringFieldLiteGenerator::GetNumBitsForBuilder() const {\n  return 0;\n}\n\n// A note about how strings are handled. In the SPEED and CODE_SIZE runtimes,\n// strings are not stored as java.lang.String in the Message because of two\n// issues:\n//\n//  1. It wouldn't roundtrip byte arrays that were not vaid UTF-8 encoded\n//     strings, but rather fields that were raw bytes incorrectly marked\n//     as strings in the proto file. This is common because in the proto1\n//     syntax, string was the way to indicate bytes and C++ engineers can\n//     easily make this mistake without affecting the C++ API. By converting to\n//     strings immediately, some java code might corrupt these byte arrays as\n//     it passes through a java server even if the field was never accessed by\n//     application code.\n//\n//  2. There's a performance hit to converting between bytes and strings and\n//     it many cases, the field is never even read by the application code. This\n//     avoids unnecessary conversions in the common use cases.\n//\n// In the LITE_RUNTIME, we store strings as java.lang.String because we assume\n// that the users of this runtime are not subject to proto1 constraints and are\n// running code on devices that are user facing. That is, the developers are\n// properly incentivized to only fetch the data they need to read and wish to\n// reduce the number of allocations incurred when running on a user's device.\n\n// TODO(dweis): Consider dropping all of the *Bytes() methods. They really\n//     shouldn't be necessary or used on devices.\nvoid ImmutableStringFieldLiteGenerator::\nGenerateInterfaceMembers(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$boolean has$capitalized_name$();\\n\");\n  }\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$java.lang.String get$capitalized_name$();\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$com.google.protobuf.ByteString\\n\"\n    \"    get$capitalized_name$Bytes();\\n\");\n}\n\nvoid ImmutableStringFieldLiteGenerator::\nGenerateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"private java.lang.String $name$_;\\n\");\n  PrintExtraFieldInfo(variables_, printer);\n\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return $get_has_field_bit_message$;\\n\"\n      \"}\\n\");\n  }\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.lang.String get$capitalized_name$() {\\n\"\n    \"  return $name$_;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public com.google.protobuf.ByteString\\n\"\n    \"    get$capitalized_name$Bytes() {\\n\"\n    \"  return com.google.protobuf.ByteString.copyFromUtf8($name$_);\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$(\\n\"\n    \"    java.lang.String value) {\\n\"\n    \"$null_check$\"\n    \"  $set_has_field_bit_message$\\n\"\n    \"  $name$_ = value;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void clear$capitalized_name$() {\\n\"\n    \"  $clear_has_field_bit_message$\\n\"\n    // The default value is not a simple literal so we want to avoid executing\n    // it multiple times.  Instead, get the default out of the default instance.\n    \"  $name$_ = getDefaultInstance().get$capitalized_name$();\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$Bytes(\\n\"\n    \"    com.google.protobuf.ByteString value) {\\n\"\n    \"$null_check$\");\n  if (CheckUtf8(descriptor_)) {\n    printer->Print(variables_,\n      \"  checkByteStringIsUtf8(value);\\n\");\n  }\n  printer->Print(variables_,\n    \"  $set_has_field_bit_message$\\n\"\n    \"  $name$_ = value.toStringUtf8();\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableStringFieldLiteGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return instance.has$capitalized_name$();\\n\"\n      \"}\\n\");\n  }\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.lang.String get$capitalized_name$() {\\n\"\n    \"  return instance.get$capitalized_name$();\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public com.google.protobuf.ByteString\\n\"\n    \"    get$capitalized_name$Bytes() {\\n\"\n    \"  return instance.get$capitalized_name$Bytes();\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    java.lang.String value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$(value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.clear$capitalized_name$();\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$Bytes(\\n\"\n    \"    com.google.protobuf.ByteString value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$Bytes(value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableStringFieldLiteGenerator::\nGenerateFieldBuilderInitializationCode(io::Printer* printer)  const {\n  // noop for strings\n}\n\nvoid ImmutableStringFieldLiteGenerator::\nGenerateInitializationCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_ = $default$;\\n\");\n}\n\nvoid ImmutableStringFieldLiteGenerator::\nGenerateVisitCode(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    printer->Print(variables_,\n      \"$name$_ = visitor.visitString(\\n\"\n      \"    has$capitalized_name$(), $name$_,\\n\"\n      \"    other.has$capitalized_name$(), other.$name$_);\\n\");\n  } else {\n    printer->Print(variables_,\n      \"$name$_ = visitor.visitString(!$name$_.isEmpty(), $name$_,\\n\"\n      \"    !other.$name$_.isEmpty(), other.$name$_);\\n\");\n  }\n}\n\nvoid ImmutableStringFieldLiteGenerator::\nGenerateDynamicMethodMakeImmutableCode(io::Printer* printer) const {\n  // noop for scalars\n}\n\nvoid ImmutableStringFieldLiteGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  if (CheckUtf8(descriptor_)) {\n    printer->Print(variables_,\n      \"String s = input.readStringRequireUtf8();\\n\"\n      \"$set_has_field_bit_message$\\n\"\n      \"$name$_ = s;\\n\");\n  } else {\n    // Lite runtime should attempt to reduce allocations by attempting to\n    // construct the string directly from the input stream buffer. This avoids\n    // spurious intermediary ByteString allocations, cutting overall allocations\n    // in half.\n    printer->Print(variables_,\n      \"String s = input.readString();\\n\"\n      \"$set_has_field_bit_message$\\n\"\n      \"$name$_ = s;\\n\");\n  }\n}\n\nvoid ImmutableStringFieldLiteGenerator::\nGenerateParsingDoneCode(io::Printer* printer) const {\n  // noop for strings\n}\n\nvoid ImmutableStringFieldLiteGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  // Lite runtime should reduce allocations by serializing the string directly.\n  // This avoids spurious intermediary ByteString allocations, cutting overall\n  // allocations in half.\n  printer->Print(variables_,\n    \"if ($is_field_present_message$) {\\n\"\n    \"  output.writeString($number$, get$capitalized_name$());\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableStringFieldLiteGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  // Lite runtime should reduce allocations by computing on the string directly.\n  // This avoids spurious intermediary ByteString allocations, cutting overall\n  // allocations in half.\n  printer->Print(variables_,\n    \"if ($is_field_present_message$) {\\n\"\n    \"  size += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .computeStringSize($number$, get$capitalized_name$());\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableStringFieldLiteGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"result = result && get$capitalized_name$()\\n\"\n    \"    .equals(other.get$capitalized_name$());\\n\");\n}\n\nvoid ImmutableStringFieldLiteGenerator::\nGenerateHashCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"hash = (37 * hash) + $constant_name$;\\n\");\n  printer->Print(variables_,\n    \"hash = (53 * hash) + get$capitalized_name$().hashCode();\\n\");\n}\n\nstring ImmutableStringFieldLiteGenerator::GetBoxedType() const {\n  return \"java.lang.String\";\n}\n\n// ===================================================================\n\nImmutableStringOneofFieldLiteGenerator::\nImmutableStringOneofFieldLiteGenerator(const FieldDescriptor* descriptor,\n                                   int messageBitIndex,\n                                   int builderBitIndex,\n                                   Context* context)\n    : ImmutableStringFieldLiteGenerator(\n          descriptor, messageBitIndex, builderBitIndex, context) {\n  const OneofGeneratorInfo* info =\n      context->GetOneofGeneratorInfo(descriptor->containing_oneof());\n  SetCommonOneofVariables(descriptor, info, &variables_);\n}\n\nImmutableStringOneofFieldLiteGenerator::\n~ImmutableStringOneofFieldLiteGenerator() {}\n\nvoid ImmutableStringOneofFieldLiteGenerator::\nGenerateMembers(io::Printer* printer) const {\n  PrintExtraFieldInfo(variables_, printer);\n\n  if (SupportFieldPresence(descriptor_->file())) {\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n    \"  return $has_oneof_case_message$;\\n\"\n    \"}\\n\");\n  }\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.lang.String get$capitalized_name$() {\\n\"\n    \"  java.lang.String ref $default_init$;\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    ref = (java.lang.String) $oneof_name$_;\\n\"\n    \"  }\\n\"\n    \"  return ref;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n\n  printer->Print(variables_,\n    \"$deprecation$public com.google.protobuf.ByteString\\n\"\n    \"    get$capitalized_name$Bytes() {\\n\"\n    \"  java.lang.String ref $default_init$;\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    ref = (java.lang.String) $oneof_name$_;\\n\"\n    \"  }\\n\"\n    \"  return com.google.protobuf.ByteString.copyFromUtf8(ref);\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$(\\n\"\n    \"    java.lang.String value) {\\n\"\n    \"$null_check$\"\n    \"  $set_oneof_case_message$;\\n\"\n    \"  $oneof_name$_ = value;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void clear$capitalized_name$() {\\n\"\n    \"  if ($has_oneof_case_message$) {\\n\"\n    \"    $clear_oneof_case_message$;\\n\"\n    \"    $oneof_name$_ = null;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$Bytes(\\n\"\n    \"    com.google.protobuf.ByteString value) {\\n\"\n    \"$null_check$\");\n  if (CheckUtf8(descriptor_)) {\n    printer->Print(variables_,\n      \"  checkByteStringIsUtf8(value);\\n\");\n  }\n  printer->Print(variables_,\n    \"  $set_oneof_case_message$;\\n\"\n    \"  $oneof_name$_ = value.toStringUtf8();\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableStringOneofFieldLiteGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  if (SupportFieldPresence(descriptor_->file())) {\n    WriteFieldDocComment(printer, descriptor_);\n    printer->Print(variables_,\n      \"$deprecation$public boolean has$capitalized_name$() {\\n\"\n      \"  return instance.has$capitalized_name$();\\n\"\n      \"}\\n\");\n  }\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.lang.String get$capitalized_name$() {\\n\"\n    \"  return instance.get$capitalized_name$();\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public com.google.protobuf.ByteString\\n\"\n    \"    get$capitalized_name$Bytes() {\\n\"\n    \"  return instance.get$capitalized_name$Bytes();\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    java.lang.String value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$(value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.clear$capitalized_name$();\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$Bytes(\\n\"\n    \"    com.google.protobuf.ByteString value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$Bytes(value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableStringOneofFieldLiteGenerator::\nGenerateVisitCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$oneof_name$_ = visitor.visitOneofString(\\n\"\n    \"   $has_oneof_case_message$, $oneof_name$_, other.$oneof_name$_);\\n\");\n}\n\nvoid ImmutableStringOneofFieldLiteGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  if (CheckUtf8(descriptor_)) {\n    printer->Print(variables_,\n      \"String s = input.readStringRequireUtf8();\\n\"\n      \"$set_oneof_case_message$;\\n\"\n      \"$oneof_name$_ = s;\\n\");\n  } else {\n    // Lite runtime should attempt to reduce allocations by attempting to\n    // construct the string directly from the input stream buffer. This avoids\n    // spurious intermediary ByteString allocations, cutting overall allocations\n    // in half.\n    printer->Print(variables_,\n      \"String s = input.readString();\\n\"\n      \"$set_oneof_case_message$;\\n\"\n      \"$oneof_name$_ = s;\\n\");\n  }\n}\n\nvoid ImmutableStringOneofFieldLiteGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  // Lite runtime should reduce allocations by serializing the string directly.\n  // This avoids spurious intermediary ByteString allocations, cutting overall\n  // allocations in half.\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  output.writeString($number$, get$capitalized_name$());\\n\"\n    \"}\\n\");\n}\n\nvoid ImmutableStringOneofFieldLiteGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  // Lite runtime should reduce allocations by computing on the string directly.\n  // This avoids spurious intermediary ByteString allocations, cutting overall\n  // allocations in half.\n  printer->Print(variables_,\n    \"if ($has_oneof_case_message$) {\\n\"\n    \"  size += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .computeStringSize($number$, get$capitalized_name$());\\n\"\n    \"}\\n\");\n}\n\n// ===================================================================\n\nRepeatedImmutableStringFieldLiteGenerator::\nRepeatedImmutableStringFieldLiteGenerator(const FieldDescriptor* descriptor,\n                                      int messageBitIndex,\n                                      int builderBitIndex,\n                                      Context* context)\n  : descriptor_(descriptor), messageBitIndex_(messageBitIndex),\n    builderBitIndex_(builderBitIndex), context_(context),\n    name_resolver_(context->GetNameResolver()) {\n  SetPrimitiveVariables(descriptor, messageBitIndex, builderBitIndex,\n                        context->GetFieldGeneratorInfo(descriptor),\n                        name_resolver_, &variables_);\n}\n\nRepeatedImmutableStringFieldLiteGenerator::\n~RepeatedImmutableStringFieldLiteGenerator() {}\n\nint RepeatedImmutableStringFieldLiteGenerator::GetNumBitsForMessage() const {\n  return 0;\n}\n\nint RepeatedImmutableStringFieldLiteGenerator::GetNumBitsForBuilder() const {\n  return 0;\n}\n\nvoid RepeatedImmutableStringFieldLiteGenerator::\nGenerateInterfaceMembers(io::Printer* printer) const {\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$java.util.List<String>\\n\"\n    \"    get$capitalized_name$List();\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$int get$capitalized_name$Count();\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$java.lang.String get$capitalized_name$(int index);\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$com.google.protobuf.ByteString\\n\"\n    \"    get$capitalized_name$Bytes(int index);\\n\");\n}\n\n\nvoid RepeatedImmutableStringFieldLiteGenerator::\nGenerateMembers(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"private com.google.protobuf.Internal.ProtobufList<String> $name$_;\\n\");\n  PrintExtraFieldInfo(variables_, printer);\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.util.List<String> get$capitalized_name$List() {\\n\"\n    \"  return $name$_;\\n\"   // note:  unmodifiable list\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public int get$capitalized_name$Count() {\\n\"\n    \"  return $name$_.size();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.lang.String get$capitalized_name$(int index) {\\n\"\n    \"  return $name$_.get(index);\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public com.google.protobuf.ByteString\\n\"\n    \"    get$capitalized_name$Bytes(int index) {\\n\"\n    \"  return com.google.protobuf.ByteString.copyFromUtf8(\\n\"\n    \"      $name$_.get(index));\\n\"\n    \"}\\n\");\n\n  printer->Print(variables_,\n    \"private void ensure$capitalized_name$IsMutable() {\\n\"\n    \"  if (!$is_mutable$) {\\n\"\n    \"    $name$_ =\\n\"\n    \"        com.google.protobuf.GeneratedMessageLite.mutableCopy($name$_);\\n\"\n    \"   }\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void set$capitalized_name$(\\n\"\n    \"    int index, java.lang.String value) {\\n\"\n    \"$null_check$\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.set(index, value);\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void add$capitalized_name$(\\n\"\n    \"    java.lang.String value) {\\n\"\n    \"$null_check$\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.add(value);\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void addAll$capitalized_name$(\\n\"\n    \"    java.lang.Iterable<java.lang.String> values) {\\n\"\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  com.google.protobuf.AbstractMessageLite.addAll(\\n\"\n    \"      values, $name$_);\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void clear$capitalized_name$() {\\n\"\n    \"  $name$_ = $empty_list$;\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"private void add$capitalized_name$Bytes(\\n\"\n    \"    com.google.protobuf.ByteString value) {\\n\"\n    \"$null_check$\");\n  if (CheckUtf8(descriptor_)) {\n    printer->Print(variables_,\n      \"  checkByteStringIsUtf8(value);\\n\");\n  }\n  printer->Print(variables_,\n    \"  ensure$capitalized_name$IsMutable();\\n\"\n    \"  $name$_.add(value.toStringUtf8());\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableStringFieldLiteGenerator::\nGenerateBuilderMembers(io::Printer* printer) const {\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.util.List<String>\\n\"\n    \"    get$capitalized_name$List() {\\n\"\n    \"  return java.util.Collections.unmodifiableList(\\n\"\n    \"      instance.get$capitalized_name$List());\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public int get$capitalized_name$Count() {\\n\"\n    \"  return instance.get$capitalized_name$Count();\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public java.lang.String get$capitalized_name$(int index) {\\n\"\n    \"  return instance.get$capitalized_name$(index);\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public com.google.protobuf.ByteString\\n\"\n    \"    get$capitalized_name$Bytes(int index) {\\n\"\n    \"  return instance.get$capitalized_name$Bytes(index);\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder set$capitalized_name$(\\n\"\n    \"    int index, java.lang.String value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.set$capitalized_name$(index, value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder add$capitalized_name$(\\n\"\n    \"    java.lang.String value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.add$capitalized_name$(value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder addAll$capitalized_name$(\\n\"\n    \"    java.lang.Iterable<java.lang.String> values) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.addAll$capitalized_name$(values);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder clear$capitalized_name$() {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.clear$capitalized_name$();\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n\n  WriteFieldDocComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"$deprecation$public Builder add$capitalized_name$Bytes(\\n\"\n    \"    com.google.protobuf.ByteString value) {\\n\"\n    \"  copyOnWrite();\\n\"\n    \"  instance.add$capitalized_name$Bytes(value);\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableStringFieldLiteGenerator::\nGenerateFieldBuilderInitializationCode(io::Printer* printer)  const {\n  // noop for strings\n}\n\nvoid RepeatedImmutableStringFieldLiteGenerator::\nGenerateInitializationCode(io::Printer* printer) const {\n  printer->Print(variables_, \"$name$_ = $empty_list$;\\n\");\n}\n\nvoid RepeatedImmutableStringFieldLiteGenerator::\nGenerateVisitCode(io::Printer* printer) const {\n  printer->Print(variables_,\n      \"$name$_= visitor.visitList($name$_, other.$name$_);\\n\");\n}\n\nvoid RepeatedImmutableStringFieldLiteGenerator::\nGenerateDynamicMethodMakeImmutableCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$_.makeImmutable();\\n\");\n}\n\nvoid RepeatedImmutableStringFieldLiteGenerator::\nGenerateParsingCode(io::Printer* printer) const {\n  if (CheckUtf8(descriptor_)) {\n    printer->Print(variables_,\n    \"String s = input.readStringRequireUtf8();\\n\");\n  } else {\n    // Lite runtime should attempt to reduce allocations by attempting to\n    // construct the string directly from the input stream buffer. This avoids\n    // spurious intermediary ByteString allocations, cutting overall allocations\n    // in half.\n    printer->Print(variables_,\n    \"String s = input.readString();\\n\");\n  }\n  printer->Print(variables_,\n    \"if (!$is_mutable$) {\\n\"\n    \"  $name$_ =\\n\"\n    \"      com.google.protobuf.GeneratedMessageLite.mutableCopy($name$_);\\n\"\n    \"}\\n\");\n  printer->Print(variables_,\n    \"$name$_.add(s);\\n\");\n}\n\nvoid RepeatedImmutableStringFieldLiteGenerator::\nGenerateParsingDoneCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($is_mutable$) {\\n\"\n    \"  $name$_.makeImmutable();\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableStringFieldLiteGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  // Lite runtime should reduce allocations by serializing the string directly.\n  // This avoids spurious intermediary ByteString allocations, cutting overall\n  // allocations in half.\n  printer->Print(variables_,\n    \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n    \"  output.writeString($number$, $name$_.get(i));\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedImmutableStringFieldLiteGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  // Lite runtime should reduce allocations by computing on the string directly.\n  // This avoids spurious intermediary ByteString allocations, cutting overall\n  // allocations in half.\n  printer->Print(variables_,\n    \"{\\n\"\n    \"  int dataSize = 0;\\n\");\n  printer->Indent();\n\n  printer->Print(variables_,\n    \"for (int i = 0; i < $name$_.size(); i++) {\\n\"\n    \"  dataSize += com.google.protobuf.CodedOutputStream\\n\"\n    \"    .computeStringSizeNoTag($name$_.get(i));\\n\"\n    \"}\\n\");\n\n  printer->Print(\n      \"size += dataSize;\\n\");\n\n\n  printer->Print(variables_,\n    \"size += $tag_size$ * get$capitalized_name$List().size();\\n\");\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid RepeatedImmutableStringFieldLiteGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"result = result && get$capitalized_name$List()\\n\"\n    \"    .equals(other.get$capitalized_name$List());\\n\");\n}\n\nvoid RepeatedImmutableStringFieldLiteGenerator::\nGenerateHashCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (get$capitalized_name$Count() > 0) {\\n\"\n    \"  hash = (37 * hash) + $constant_name$;\\n\"\n    \"  hash = (53 * hash) + get$capitalized_name$List().hashCode();\\n\"\n    \"}\\n\");\n}\n\nstring RepeatedImmutableStringFieldLiteGenerator::GetBoxedType() const {\n  return \"String\";\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/java/java_string_field_lite.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n// Author: jonp@google.com (Jon Perlow)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_LITE_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_LITE_H__\n\n#include <map>\n#include <string>\n#include <google/protobuf/compiler/java/java_field.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace compiler {\n    namespace java {\n      class Context;           // context.h\n      class ClassNameResolver; // name_resolver.h\n    }\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace java {\n\nclass ImmutableStringFieldLiteGenerator : public ImmutableFieldLiteGenerator {\n public:\n  explicit ImmutableStringFieldLiteGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~ImmutableStringFieldLiteGenerator();\n\n  // implements ImmutableFieldLiteGenerator ------------------------------------\n  int GetNumBitsForMessage() const;\n  int GetNumBitsForBuilder() const;\n  void GenerateInterfaceMembers(io::Printer* printer) const;\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateInitializationCode(io::Printer* printer) const;\n  void GenerateVisitCode(io::Printer* printer) const;\n  void GenerateDynamicMethodMakeImmutableCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateParsingDoneCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCode(io::Printer* printer) const;\n\n  string GetBoxedType() const;\n\n protected:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n  const int messageBitIndex_;\n  const int builderBitIndex_;\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableStringFieldLiteGenerator);\n};\n\nclass ImmutableStringOneofFieldLiteGenerator\n    : public ImmutableStringFieldLiteGenerator {\n public:\n  ImmutableStringOneofFieldLiteGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~ImmutableStringOneofFieldLiteGenerator();\n\n private:\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateVisitCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ImmutableStringOneofFieldLiteGenerator);\n};\n\nclass RepeatedImmutableStringFieldLiteGenerator\n    : public ImmutableFieldLiteGenerator {\n public:\n  explicit RepeatedImmutableStringFieldLiteGenerator(\n      const FieldDescriptor* descriptor, int messageBitIndex,\n      int builderBitIndex, Context* context);\n  ~RepeatedImmutableStringFieldLiteGenerator();\n\n  // implements ImmutableFieldLiteGenerator ------------------------------------\n  int GetNumBitsForMessage() const;\n  int GetNumBitsForBuilder() const;\n  void GenerateInterfaceMembers(io::Printer* printer) const;\n  void GenerateMembers(io::Printer* printer) const;\n  void GenerateBuilderMembers(io::Printer* printer) const;\n  void GenerateInitializationCode(io::Printer* printer) const;\n  void GenerateVisitCode(io::Printer* printer) const;\n  void GenerateDynamicMethodMakeImmutableCode(io::Printer* printer) const;\n  void GenerateParsingCode(io::Printer* printer) const;\n  void GenerateParsingDoneCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateFieldBuilderInitializationCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCode(io::Printer* printer) const;\n\n  string GetBoxedType() const;\n\n private:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n  const int messageBitIndex_;\n  const int builderBitIndex_;\n  Context* context_;\n  ClassNameResolver* name_resolver_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedImmutableStringFieldLiteGenerator);\n};\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVA_STRING_FIELD_LITE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_enum.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/compiler/javanano/javanano_params.h>\n#include <google/protobuf/compiler/javanano/javanano_enum.h>\n#include <google/protobuf/compiler/javanano/javanano_helpers.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\nEnumGenerator::EnumGenerator(const EnumDescriptor* descriptor, const Params& params)\n  : params_(params), descriptor_(descriptor) {\n  for (int i = 0; i < descriptor_->value_count(); i++) {\n    const EnumValueDescriptor* value = descriptor_->value(i);\n    const EnumValueDescriptor* canonical_value =\n      descriptor_->FindValueByNumber(value->number());\n\n    if (value == canonical_value) {\n      canonical_values_.push_back(value);\n    } else {\n      Alias alias;\n      alias.value = value;\n      alias.canonical_value = canonical_value;\n      aliases_.push_back(alias);\n    }\n  }\n}\n\nEnumGenerator::~EnumGenerator() {}\n\nvoid EnumGenerator::Generate(io::Printer* printer) {\n  printer->Print(\n      \"\\n\"\n      \"// enum $classname$\\n\",\n      \"classname\", descriptor_->name());\n\n  const string classname = RenameJavaKeywords(descriptor_->name());\n\n  // Start of container interface\n  // If generating intdefs, we use the container interface as the intdef if\n  // present. Otherwise, we just make an empty @interface parallel to the\n  // constants.\n  bool use_intdef = params_.generate_intdefs();\n  bool use_shell_class = params_.java_enum_style();\n  if (use_intdef) {\n    // @IntDef annotation so tools can enforce correctness\n    // Annotations will be discarded by the compiler\n    printer->Print(\"@java.lang.annotation.Retention(\"\n      \"java.lang.annotation.RetentionPolicy.SOURCE)\\n\"\n      \"@android.support.annotation.IntDef({\\n\");\n    printer->Indent();\n    for (int i = 0; i < canonical_values_.size(); i++) {\n      const string constant_name =\n          RenameJavaKeywords(canonical_values_[i]->name());\n      if (use_shell_class) {\n        printer->Print(\"$classname$.$name$,\\n\",\n          \"classname\", classname,\n          \"name\", constant_name);\n      } else {\n        printer->Print(\"$name$,\\n\", \"name\", constant_name);\n      }\n    }\n    printer->Outdent();\n    printer->Print(\"})\\n\");\n  }\n  if (use_shell_class || use_intdef) {\n    printer->Print(\n      \"public $at_for_intdef$interface $classname$ {\\n\",\n      \"classname\", classname,\n      \"at_for_intdef\", use_intdef ? \"@\" : \"\");\n    if (use_shell_class) {\n        printer->Indent();\n    } else {\n        printer->Print(\"}\\n\\n\");\n    }\n  }\n\n  // Canonical values\n  for (int i = 0; i < canonical_values_.size(); i++) {\n    printer->Print(\n      \"public static final int $name$ = $canonical_value$;\\n\",\n      \"name\", RenameJavaKeywords(canonical_values_[i]->name()),\n      \"canonical_value\", SimpleItoa(canonical_values_[i]->number()));\n  }\n\n  // Aliases\n  for (int i = 0; i < aliases_.size(); i++) {\n    printer->Print(\n      \"public static final int $name$ = $canonical_name$;\\n\",\n      \"name\", RenameJavaKeywords(aliases_[i].value->name()),\n      \"canonical_name\", RenameJavaKeywords(aliases_[i].canonical_value->name()));\n  }\n\n  // End of container interface\n  if (use_shell_class) {\n    printer->Outdent();\n    printer->Print(\"}\\n\");\n  }\n}\n\n}  // namespace javanano\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_enum.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_ENUM_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVANANO_ENUM_H__\n\n#include <string>\n#include <vector>\n\n#include <google/protobuf/compiler/javanano/javanano_params.h>\n#include <google/protobuf/descriptor.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace io {\n    class Printer;             // printer.h\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\nclass EnumGenerator {\n public:\n  explicit EnumGenerator(const EnumDescriptor* descriptor, const Params& params);\n  ~EnumGenerator();\n\n  void Generate(io::Printer* printer);\n\n private:\n  const Params& params_;\n  const EnumDescriptor* descriptor_;\n\n  // The proto language allows multiple enum constants to have the same numeric\n  // value.  Java, however, does not allow multiple enum constants to be\n  // considered equivalent.  We treat the first defined constant for any\n  // given numeric value as \"canonical\" and the rest as aliases of that\n  // canonical value.\n  vector<const EnumValueDescriptor*> canonical_values_;\n\n  struct Alias {\n    const EnumValueDescriptor* value;\n    const EnumValueDescriptor* canonical_value;\n  };\n  vector<Alias> aliases_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator);\n};\n\n}  // namespace javanano\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVANANO_ENUM_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_enum_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/compiler/javanano/javanano_enum_field.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/compiler/javanano/javanano_helpers.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\nnamespace {\n\n// TODO(kenton):  Factor out a \"SetCommonFieldVariables()\" to get rid of\n//   repeat code between this and the other field types.\nvoid SetEnumVariables(const Params& params,\n    const FieldDescriptor* descriptor, map<string, string>* variables) {\n  (*variables)[\"name\"] =\n    RenameJavaKeywords(UnderscoresToCamelCase(descriptor));\n  (*variables)[\"capitalized_name\"] =\n    RenameJavaKeywords(UnderscoresToCapitalizedCamelCase(descriptor));\n  (*variables)[\"number\"] = SimpleItoa(descriptor->number());\n  if (params.use_reference_types_for_primitives()\n      && !params.reftypes_primitive_enums()\n      && !descriptor->is_repeated()) {\n    (*variables)[\"type\"] = \"java.lang.Integer\";\n    (*variables)[\"default\"] = \"null\";\n  } else {\n    (*variables)[\"type\"] = \"int\";\n    (*variables)[\"default\"] = DefaultValue(params, descriptor);\n  }\n  (*variables)[\"repeated_default\"] =\n      \"com.google.protobuf.nano.WireFormatNano.EMPTY_INT_ARRAY\";\n  (*variables)[\"tag\"] = SimpleItoa(internal::WireFormat::MakeTag(descriptor));\n  (*variables)[\"tag_size\"] = SimpleItoa(\n      internal::WireFormat::TagSize(descriptor->number(), descriptor->type()));\n  (*variables)[\"non_packed_tag\"] = SimpleItoa(\n      internal::WireFormatLite::MakeTag(descriptor->number(),\n          internal::WireFormat::WireTypeForFieldType(descriptor->type())));\n  (*variables)[\"message_name\"] = descriptor->containing_type()->name();\n  const EnumDescriptor* enum_type = descriptor->enum_type();\n  (*variables)[\"message_type_intdef\"] = \"@\"\n      + ToJavaName(params, enum_type->name(), true,\n          enum_type->containing_type(), enum_type->file());\n}\n\nvoid LoadEnumValues(const Params& params,\n    const EnumDescriptor* enum_descriptor, vector<string>* canonical_values) {\n  string enum_class_name = ClassName(params, enum_descriptor);\n  for (int i = 0; i < enum_descriptor->value_count(); i++) {\n    const EnumValueDescriptor* value = enum_descriptor->value(i);\n    const EnumValueDescriptor* canonical_value =\n        enum_descriptor->FindValueByNumber(value->number());\n    if (value == canonical_value) {\n      canonical_values->push_back(\n          enum_class_name + \".\" + RenameJavaKeywords(value->name()));\n    }\n  }\n}\n\nvoid PrintCaseLabels(\n    io::Printer* printer, const vector<string>& canonical_values) {\n  for (int i = 0; i < canonical_values.size(); i++) {\n    printer->Print(\n      \"  case $value$:\\n\",\n      \"value\", canonical_values[i]);\n  }\n}\n\n}  // namespace\n\n// ===================================================================\n\nEnumFieldGenerator::\nEnumFieldGenerator(const FieldDescriptor* descriptor, const Params& params)\n  : FieldGenerator(params), descriptor_(descriptor) {\n  SetEnumVariables(params, descriptor, &variables_);\n  LoadEnumValues(params, descriptor->enum_type(), &canonical_values_);\n}\n\nEnumFieldGenerator::~EnumFieldGenerator() {}\n\nvoid EnumFieldGenerator::\nGenerateMembers(io::Printer* printer, bool /* unused lazy_init */) const {\n  if (params_.generate_intdefs()) {\n    printer->Print(variables_, \"$message_type_intdef$\\n\");\n  }\n  printer->Print(variables_, \"public $type$ $name$;\\n\");\n\n  if (params_.generate_has()) {\n    printer->Print(variables_,\n      \"public boolean has$capitalized_name$;\\n\");\n  }\n}\n\nvoid EnumFieldGenerator::\nGenerateClearCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$ = $default$;\\n\");\n\n  if (params_.generate_has()) {\n    printer->Print(variables_,\n      \"has$capitalized_name$ = false;\\n\");\n  }\n}\n\nvoid EnumFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"int value = input.readInt32();\\n\"\n    \"switch (value) {\\n\");\n  PrintCaseLabels(printer, canonical_values_);\n  printer->Print(variables_,\n    \"    this.$name$ = value;\\n\");\n  if (params_.generate_has()) {\n    printer->Print(variables_,\n      \"    has$capitalized_name$ = true;\\n\");\n  }\n  printer->Print(\n    \"    break;\\n\"\n    \"}\\n\");\n  // No default case: in case of invalid value from the wire, preserve old\n  // field value. Also we are not storing the invalid value into the unknown\n  // fields, because there is no way to get the value out.\n}\n\nvoid EnumFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  if (descriptor_->is_required() && !params_.generate_has()) {\n    // Always serialize a required field if we don't have the 'has' signal.\n    printer->Print(variables_,\n      \"output.writeInt32($number$, this.$name$);\\n\");\n  } else {\n    if (params_.generate_has()) {\n      printer->Print(variables_,\n        \"if (this.$name$ != $default$ || has$capitalized_name$) {\\n\");\n    } else {\n      printer->Print(variables_,\n        \"if (this.$name$ != $default$) {\\n\");\n    }\n    printer->Print(variables_,\n      \"  output.writeInt32($number$, this.$name$);\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid EnumFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  if (descriptor_->is_required() && !params_.generate_has()) {\n    printer->Print(variables_,\n      \"size += com.google.protobuf.nano.CodedOutputByteBufferNano\\n\"\n      \"  .computeInt32Size($number$, this.$name$);\\n\");\n  } else {\n    if (params_.generate_has()) {\n      printer->Print(variables_,\n        \"if (this.$name$ != $default$ || has$capitalized_name$) {\\n\");\n    } else {\n      printer->Print(variables_,\n        \"if (this.$name$ != $default$) {\\n\");\n    }\n    printer->Print(variables_,\n      \"  size += com.google.protobuf.nano.CodedOutputByteBufferNano\\n\"\n      \"    .computeInt32Size($number$, this.$name$);\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid EnumFieldGenerator::GenerateEqualsCode(io::Printer* printer) const {\n  if (params_.use_reference_types_for_primitives()\n        && !params_.reftypes_primitive_enums()) {\n    printer->Print(variables_,\n      \"if (this.$name$ == null) {\\n\"\n      \"  if (other.$name$ != null) {\\n\"\n      \"    return false;\\n\"\n      \"  }\\n\"\n      \"} else if (!this.$name$.equals(other.$name$)) {\\n\"\n      \"  return false;\"\n      \"}\\n\");\n  } else {\n    // We define equality as serialized form equality. If generate_has(),\n    // then if the field value equals the default value in both messages,\n    // but one's 'has' field is set and the other's is not, the serialized\n    // forms are different and we should return false.\n    printer->Print(variables_,\n      \"if (this.$name$ != other.$name$\");\n    if (params_.generate_has()) {\n      printer->Print(variables_,\n        \"\\n\"\n        \"    || (this.$name$ == $default$\\n\"\n        \"        && this.has$capitalized_name$ != other.has$capitalized_name$)\");\n    }\n    printer->Print(\") {\\n\"\n      \"  return false;\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid EnumFieldGenerator::GenerateHashCodeCode(io::Printer* printer) const {\n  printer->Print(\n    \"result = 31 * result + \");\n  if (params_.use_reference_types_for_primitives()\n        && !params_.reftypes_primitive_enums()) {\n    printer->Print(variables_,\n      \"(this.$name$ == null ? 0 : this.$name$)\");\n  } else {\n    printer->Print(variables_,\n      \"this.$name$\");\n  }\n  printer->Print(\";\\n\");\n}\n\n// ===================================================================\n\nAccessorEnumFieldGenerator::\nAccessorEnumFieldGenerator(const FieldDescriptor* descriptor,\n    const Params& params, int has_bit_index)\n  : FieldGenerator(params), descriptor_(descriptor) {\n  SetEnumVariables(params, descriptor, &variables_);\n  LoadEnumValues(params, descriptor->enum_type(), &canonical_values_);\n  SetBitOperationVariables(\"has\", has_bit_index, &variables_);\n}\n\nAccessorEnumFieldGenerator::~AccessorEnumFieldGenerator() {}\n\nvoid AccessorEnumFieldGenerator::\nGenerateMembers(io::Printer* printer, bool /* unused lazy_init */) const {\n  printer->Print(variables_, \"private int $name$_;\\n\");\n  if (params_.generate_intdefs()) {\n    printer->Print(variables_, \"$message_type_intdef$\\n\");\n  }\n  printer->Print(variables_,\n    \"public int get$capitalized_name$() {\\n\"\n    \"  return $name$_;\\n\"\n    \"}\\n\"\n    \"public $message_name$ set$capitalized_name$(\");\n  if (params_.generate_intdefs()) {\n    printer->Print(variables_,\n      \"\\n\"\n      \"    $message_type_intdef$ \");\n  }\n  printer->Print(variables_,\n    \"int value) {\\n\"\n    \"  $name$_ = value;\\n\"\n    \"  $set_has$;\\n\"\n    \"  return this;\\n\"\n    \"}\\n\"\n    \"public boolean has$capitalized_name$() {\\n\"\n    \"  return $get_has$;\\n\"\n    \"}\\n\"\n    \"public $message_name$ clear$capitalized_name$() {\\n\"\n    \"  $name$_ = $default$;\\n\"\n    \"  $clear_has$;\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid AccessorEnumFieldGenerator::\nGenerateClearCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$_ = $default$;\\n\");\n}\n\nvoid AccessorEnumFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"int value = input.readInt32();\\n\"\n    \"switch (value) {\\n\");\n  PrintCaseLabels(printer, canonical_values_);\n  printer->Print(variables_,\n    \"    $name$_ = value;\\n\"\n    \"    $set_has$;\\n\"\n    \"    break;\\n\"\n    \"}\\n\");\n  // No default case: in case of invalid value from the wire, preserve old\n  // field value. Also we are not storing the invalid value into the unknown\n  // fields, because there is no way to get the value out.\n}\n\nvoid AccessorEnumFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($get_has$) {\\n\"\n    \"  output.writeInt32($number$, $name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid AccessorEnumFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($get_has$) {\\n\"\n    \"  size += com.google.protobuf.nano.CodedOutputByteBufferNano\\n\"\n    \"    .computeInt32Size($number$, $name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid AccessorEnumFieldGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($different_has$\\n\"\n    \"    || $name$_ != other.$name$_) {\\n\"\n    \"  return false;\\n\"\n    \"}\\n\");\n}\n\nvoid AccessorEnumFieldGenerator::\nGenerateHashCodeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"result = 31 * result + $name$_;\\n\");\n}\n\n// ===================================================================\n\nRepeatedEnumFieldGenerator::\nRepeatedEnumFieldGenerator(const FieldDescriptor* descriptor, const Params& params)\n  : FieldGenerator(params), descriptor_(descriptor) {\n  SetEnumVariables(params, descriptor, &variables_);\n  LoadEnumValues(params, descriptor->enum_type(), &canonical_values_);\n}\n\nRepeatedEnumFieldGenerator::~RepeatedEnumFieldGenerator() {}\n\nvoid RepeatedEnumFieldGenerator::\nGenerateMembers(io::Printer* printer, bool /* unused lazy_init */) const {\n  printer->Print(variables_,\n    \"public $type$[] $name$;\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::\nGenerateClearCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$ = $repeated_default$;\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  // First, figure out the maximum length of the array, then parse,\n  // and finally copy the valid values to the field.\n  printer->Print(variables_,\n    \"int length = com.google.protobuf.nano.WireFormatNano\\n\"\n    \"    .getRepeatedFieldArrayLength(input, $non_packed_tag$);\\n\"\n    \"int[] validValues = new int[length];\\n\"\n    \"int validCount = 0;\\n\"\n    \"for (int i = 0; i < length; i++) {\\n\"\n    \"  if (i != 0) { // tag for first value already consumed.\\n\"\n    \"    input.readTag();\\n\"\n    \"  }\\n\"\n    \"  int value = input.readInt32();\\n\"\n    \"  switch (value) {\\n\");\n  printer->Indent();\n  PrintCaseLabels(printer, canonical_values_);\n  printer->Outdent();\n  printer->Print(variables_,\n    \"      validValues[validCount++] = value;\\n\"\n    \"      break;\\n\"\n    \"  }\\n\"\n    \"}\\n\"\n    \"if (validCount != 0) {\\n\"\n    \"  int i = this.$name$ == null ? 0 : this.$name$.length;\\n\"\n    \"  if (i == 0 && validCount == validValues.length) {\\n\"\n    \"    this.$name$ = validValues;\\n\"\n    \"  } else {\\n\"\n    \"    int[] newArray = new int[i + validCount];\\n\"\n    \"    if (i != 0) {\\n\"\n    \"      java.lang.System.arraycopy(this.$name$, 0, newArray, 0, i);\\n\"\n    \"    }\\n\"\n    \"    java.lang.System.arraycopy(validValues, 0, newArray, i, validCount);\\n\"\n    \"    this.$name$ = newArray;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::\nGenerateMergingCodeFromPacked(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"int bytes = input.readRawVarint32();\\n\"\n    \"int limit = input.pushLimit(bytes);\\n\"\n    \"// First pass to compute array length.\\n\"\n    \"int arrayLength = 0;\\n\"\n    \"int startPos = input.getPosition();\\n\"\n    \"while (input.getBytesUntilLimit() > 0) {\\n\"\n    \"  switch (input.readInt32()) {\\n\");\n  printer->Indent();\n  PrintCaseLabels(printer, canonical_values_);\n  printer->Outdent();\n  printer->Print(variables_,\n    \"      arrayLength++;\\n\"\n    \"      break;\\n\"\n    \"  }\\n\"\n    \"}\\n\"\n    \"if (arrayLength != 0) {\\n\"\n    \"  input.rewindToPosition(startPos);\\n\"\n    \"  int i = this.$name$ == null ? 0 : this.$name$.length;\\n\"\n    \"  int[] newArray = new int[i + arrayLength];\\n\"\n    \"  if (i != 0) {\\n\"\n    \"    java.lang.System.arraycopy(this.$name$, 0, newArray, 0, i);\\n\"\n    \"  }\\n\"\n    \"  while (input.getBytesUntilLimit() > 0) {\\n\"\n    \"    int value = input.readInt32();\\n\"\n    \"    switch (value) {\\n\");\n  printer->Indent();\n  printer->Indent();\n  PrintCaseLabels(printer, canonical_values_);\n  printer->Outdent();\n  printer->Outdent();\n  printer->Print(variables_,\n    \"        newArray[i++] = value;\\n\"\n    \"        break;\\n\"\n    \"    }\\n\"\n    \"  }\\n\"\n    \"  this.$name$ = newArray;\\n\"\n    \"}\\n\"\n    \"input.popLimit(limit);\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::\nGenerateRepeatedDataSizeCode(io::Printer* printer) const {\n  // Creates a variable dataSize and puts the serialized size in there.\n  printer->Print(variables_,\n    \"int dataSize = 0;\\n\"\n    \"for (int i = 0; i < this.$name$.length; i++) {\\n\"\n    \"  int element = this.$name$[i];\\n\"\n    \"  dataSize += com.google.protobuf.nano.CodedOutputByteBufferNano\\n\"\n    \"      .computeInt32SizeNoTag(element);\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (this.$name$ != null && this.$name$.length > 0) {\\n\");\n  printer->Indent();\n\n  if (descriptor_->options().packed()) {\n    GenerateRepeatedDataSizeCode(printer);\n    printer->Print(variables_,\n      \"output.writeRawVarint32($tag$);\\n\"\n      \"output.writeRawVarint32(dataSize);\\n\"\n      \"for (int i = 0; i < this.$name$.length; i++) {\\n\"\n      \"  output.writeRawVarint32(this.$name$[i]);\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables_,\n      \"for (int i = 0; i < this.$name$.length; i++) {\\n\"\n      \"  output.writeInt32($number$, this.$name$[i]);\\n\"\n      \"}\\n\");\n  }\n\n  printer->Outdent();\n  printer->Print(variables_,\n    \"}\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (this.$name$ != null && this.$name$.length > 0) {\\n\");\n  printer->Indent();\n\n  GenerateRepeatedDataSizeCode(printer);\n\n  printer->Print(\n    \"size += dataSize;\\n\");\n  if (descriptor_->options().packed()) {\n    printer->Print(variables_,\n      \"size += $tag_size$;\\n\"\n      \"size += com.google.protobuf.nano.CodedOutputByteBufferNano\\n\"\n      \"    .computeRawVarint32Size(dataSize);\\n\");\n  } else {\n    printer->Print(variables_,\n      \"size += $tag_size$ * this.$name$.length;\\n\");\n  }\n\n  printer->Outdent();\n\n  printer->Print(\n    \"}\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::\nGenerateFixClonedCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (this.$name$ != null && this.$name$.length > 0) {\\n\"\n    \"  cloned.$name$ = this.$name$.clone();\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (!com.google.protobuf.nano.InternalNano.equals(\\n\"\n    \"    this.$name$, other.$name$)) {\\n\"\n    \"  return false;\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedEnumFieldGenerator::\nGenerateHashCodeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"result = 31 * result\\n\"\n    \"    + com.google.protobuf.nano.InternalNano.hashCode(this.$name$);\\n\");\n}\n\n}  // namespace javanano\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_enum_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_ENUM_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVANANO_ENUM_FIELD_H__\n\n#include <map>\n#include <string>\n#include <vector>\n#include <google/protobuf/compiler/javanano/javanano_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\nclass EnumFieldGenerator : public FieldGenerator {\n public:\n  explicit EnumFieldGenerator(\n      const FieldDescriptor* descriptor, const Params& params);\n  ~EnumFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  void GenerateMembers(io::Printer* printer, bool lazy_init) const;\n  void GenerateClearCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCodeCode(io::Printer* printer) const;\n\n private:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n  vector<string> canonical_values_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator);\n};\n\nclass AccessorEnumFieldGenerator : public FieldGenerator {\n public:\n  explicit AccessorEnumFieldGenerator(const FieldDescriptor* descriptor,\n      const Params& params, int has_bit_index);\n  ~AccessorEnumFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  void GenerateMembers(io::Printer* printer, bool lazy_init) const;\n  void GenerateClearCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCodeCode(io::Printer* printer) const;\n\n private:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n  vector<string> canonical_values_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(AccessorEnumFieldGenerator);\n};\n\nclass RepeatedEnumFieldGenerator : public FieldGenerator {\n public:\n  explicit RepeatedEnumFieldGenerator(\n      const FieldDescriptor* descriptor, const Params& params);\n  ~RepeatedEnumFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  void GenerateMembers(io::Printer* printer, bool lazy_init) const;\n  void GenerateClearCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateMergingCodeFromPacked(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCodeCode(io::Printer* printer) const;\n  void GenerateFixClonedCode(io::Printer* printer) const;\n\n private:\n  void GenerateRepeatedDataSizeCode(io::Printer* printer) const;\n\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n  vector<string> canonical_values_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedEnumFieldGenerator);\n};\n\n}  // namespace javanano\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVANANO_ENUM_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_extension.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: bduff@google.com (Brian Duff)\n\n#include <google/protobuf/compiler/javanano/javanano_extension.h>\n#include <google/protobuf/compiler/javanano/javanano_helpers.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/wire_format.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\nusing internal::WireFormat;\nusing internal::WireFormatLite;\n\nnamespace {\n\nconst char* GetTypeConstantName(const FieldDescriptor::Type type) {\n  switch (type) {\n    case FieldDescriptor::TYPE_INT32   : return \"TYPE_INT32\"   ;\n    case FieldDescriptor::TYPE_UINT32  : return \"TYPE_UINT32\"  ;\n    case FieldDescriptor::TYPE_SINT32  : return \"TYPE_SINT32\"  ;\n    case FieldDescriptor::TYPE_FIXED32 : return \"TYPE_FIXED32\" ;\n    case FieldDescriptor::TYPE_SFIXED32: return \"TYPE_SFIXED32\";\n    case FieldDescriptor::TYPE_INT64   : return \"TYPE_INT64\"   ;\n    case FieldDescriptor::TYPE_UINT64  : return \"TYPE_UINT64\"  ;\n    case FieldDescriptor::TYPE_SINT64  : return \"TYPE_SINT64\"  ;\n    case FieldDescriptor::TYPE_FIXED64 : return \"TYPE_FIXED64\" ;\n    case FieldDescriptor::TYPE_SFIXED64: return \"TYPE_SFIXED64\";\n    case FieldDescriptor::TYPE_FLOAT   : return \"TYPE_FLOAT\"   ;\n    case FieldDescriptor::TYPE_DOUBLE  : return \"TYPE_DOUBLE\"  ;\n    case FieldDescriptor::TYPE_BOOL    : return \"TYPE_BOOL\"    ;\n    case FieldDescriptor::TYPE_STRING  : return \"TYPE_STRING\"  ;\n    case FieldDescriptor::TYPE_BYTES   : return \"TYPE_BYTES\"   ;\n    case FieldDescriptor::TYPE_ENUM    : return \"TYPE_ENUM\"    ;\n    case FieldDescriptor::TYPE_GROUP   : return \"TYPE_GROUP\"   ;\n    case FieldDescriptor::TYPE_MESSAGE : return \"TYPE_MESSAGE\" ;\n\n    // No default because we want the compiler to complain if any new\n    // types are added.\n  }\n\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return NULL;\n}\n\n}  // namespace\n\nvoid SetVariables(const FieldDescriptor* descriptor, const Params params,\n                  map<string, string>* variables) {\n  (*variables)[\"extends\"] = ClassName(params, descriptor->containing_type());\n  (*variables)[\"name\"] = RenameJavaKeywords(UnderscoresToCamelCase(descriptor));\n  bool repeated = descriptor->is_repeated();\n  (*variables)[\"repeated\"] = repeated ? \"Repeated\" : \"\";\n  (*variables)[\"type\"] = GetTypeConstantName(descriptor->type());\n  JavaType java_type = GetJavaType(descriptor->type());\n  string tag = SimpleItoa(WireFormat::MakeTag(descriptor));\n  if (java_type == JAVATYPE_MESSAGE) {\n    (*variables)[\"ext_type\"] = \"MessageTyped\";\n    string message_type = ClassName(params, descriptor->message_type());\n    if (repeated) {\n      message_type += \"[]\";\n    }\n    (*variables)[\"class\"] = message_type;\n    // For message typed extensions, tags_params contains a single tag\n    // for both singular and repeated cases.\n    (*variables)[\"tag_params\"] = tag;\n  } else {\n    (*variables)[\"ext_type\"] = \"PrimitiveTyped\";\n    if (!repeated) {\n      (*variables)[\"class\"] = BoxedPrimitiveTypeName(java_type);\n      (*variables)[\"tag_params\"] = tag;\n    } else {\n      (*variables)[\"class\"] = PrimitiveTypeName(java_type) + \"[]\";\n      if (!descriptor->is_packable()) {\n        // Non-packable: nonPackedTag == tag, packedTag == 0\n        (*variables)[\"tag_params\"] = tag + \", \" + tag + \", 0\";\n      } else if (descriptor->options().packed()) {\n        // Packable and packed: tag == packedTag\n        string non_packed_tag = SimpleItoa(WireFormatLite::MakeTag(\n            descriptor->number(),\n            WireFormat::WireTypeForFieldType(descriptor->type())));\n        (*variables)[\"tag_params\"] = tag + \", \" + non_packed_tag + \", \" + tag;\n      } else {\n        // Packable and not packed: tag == nonPackedTag\n        string packed_tag = SimpleItoa(WireFormatLite::MakeTag(\n            descriptor->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED));\n        (*variables)[\"tag_params\"] = tag + \", \" + tag + \", \" + packed_tag;\n      }\n    }\n  }\n}\n\nExtensionGenerator::\nExtensionGenerator(const FieldDescriptor* descriptor, const Params& params)\n  : params_(params), descriptor_(descriptor) {\n  SetVariables(descriptor, params, &variables_);\n}\n\nExtensionGenerator::~ExtensionGenerator() {}\n\nvoid ExtensionGenerator::Generate(io::Printer* printer) const {\n  printer->Print(\"\\n\");\n  PrintFieldComment(printer, descriptor_);\n  printer->Print(variables_,\n    \"public static final com.google.protobuf.nano.Extension<\\n\"\n    \"    $extends$,\\n\"\n    \"    $class$> $name$ =\\n\"\n    \"        com.google.protobuf.nano.Extension.create$repeated$$ext_type$(\\n\"\n    \"            com.google.protobuf.nano.Extension.$type$,\\n\"\n    \"            $class$.class,\\n\"\n    \"            $tag_params$L);\\n\");\n}\n\n}  // namespace javanano\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_extension.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: bduff@google.com (Brian Duff)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_EXTENSION_H_\n#define GOOGLE_PROTOBUF_COMPILER_JAVANANO_EXTENSION_H_\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/compiler/javanano/javanano_params.h>\n#include <google/protobuf/descriptor.pb.h>\n\n\nnamespace google {\nnamespace protobuf {\n  namespace io {\n    class Printer;             // printer.h\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\nclass ExtensionGenerator {\n public:\n  explicit ExtensionGenerator(const FieldDescriptor* descriptor, const Params& params);\n  ~ExtensionGenerator();\n\n  void Generate(io::Printer* printer) const;\n\n private:\n  const Params& params_;\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator);\n};\n\n}  // namespace javanano\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVANANO_EXTENSION_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/javanano/javanano_field.h>\n#include <google/protobuf/compiler/javanano/javanano_helpers.h>\n#include <google/protobuf/compiler/javanano/javanano_primitive_field.h>\n#include <google/protobuf/compiler/javanano/javanano_enum_field.h>\n#include <google/protobuf/compiler/javanano/javanano_map_field.h>\n#include <google/protobuf/compiler/javanano/javanano_message_field.h>\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\nFieldGenerator::~FieldGenerator() {}\n\nbool FieldGenerator::SavedDefaultNeeded() const {\n  // No saved default for this field by default.\n  // Subclasses whose instances may need saved defaults will override this\n  // and return the appropriate value.\n  return false;\n}\n\nvoid FieldGenerator::GenerateInitSavedDefaultCode(io::Printer* printer) const {\n  // No saved default for this field by default.\n  // Subclasses whose instances may need saved defaults will override this\n  // and generate the appropriate init code to the printer.\n}\n\nvoid FieldGenerator::GenerateMergingCodeFromPacked(io::Printer* printer) const {\n  // Reaching here indicates a bug. Cases are:\n  //   - This FieldGenerator should support packing, but this method should be\n  //     overridden.\n  //   - This FieldGenerator doesn't support packing, and this method should\n  //     never have been called.\n  GOOGLE_LOG(FATAL) << \"GenerateParsingCodeFromPacked() \"\n             << \"called on field generator that does not support packing.\";\n}\n\n// =============================================\n\nFieldGeneratorMap::FieldGeneratorMap(\n    const Descriptor* descriptor, const Params &params)\n  : descriptor_(descriptor),\n    field_generators_(\n      new scoped_ptr<FieldGenerator>[descriptor->field_count()]) {\n\n  int next_has_bit_index = 0;\n  bool saved_defaults_needed = false;\n  // Construct all the FieldGenerators.\n  for (int i = 0; i < descriptor->field_count(); i++) {\n    FieldGenerator* field_generator = MakeGenerator(\n        descriptor->field(i), params, &next_has_bit_index);\n    saved_defaults_needed = saved_defaults_needed\n        || field_generator->SavedDefaultNeeded();\n    field_generators_[i].reset(field_generator);\n  }\n  total_bits_ = next_has_bit_index;\n  saved_defaults_needed_ = saved_defaults_needed;\n}\n\nFieldGenerator* FieldGeneratorMap::MakeGenerator(const FieldDescriptor* field,\n    const Params &params, int* next_has_bit_index) {\n  JavaType java_type = GetJavaType(field);\n  if (field->is_repeated()) {\n    switch (java_type) {\n      case JAVATYPE_MESSAGE:\n        if (IsMapEntry(field->message_type())) {\n          return new MapFieldGenerator(field, params);\n        } else {\n          return new RepeatedMessageFieldGenerator(field, params);\n        }\n      case JAVATYPE_ENUM:\n        return new RepeatedEnumFieldGenerator(field, params);\n      default:\n        return new RepeatedPrimitiveFieldGenerator(field, params);\n    }\n  } else if (field->containing_oneof()) {\n    switch (java_type) {\n      case JAVATYPE_MESSAGE:\n        return new MessageOneofFieldGenerator(field, params);\n      case JAVATYPE_ENUM:\n      default:\n        return new PrimitiveOneofFieldGenerator(field, params);\n    }\n  } else if (params.optional_field_accessors() && field->is_optional()\n      && java_type != JAVATYPE_MESSAGE) {\n    // We need a has-bit for each primitive/enum field because their default\n    // values could be same as explicitly set values. But we don't need it\n    // for a message field because they have no defaults and Nano uses 'null'\n    // for unset messages, which cannot be set explicitly.\n    switch (java_type) {\n      case JAVATYPE_ENUM:\n        return new AccessorEnumFieldGenerator(\n            field, params, (*next_has_bit_index)++);\n      default:\n        return new AccessorPrimitiveFieldGenerator(\n            field, params, (*next_has_bit_index)++);\n    }\n  } else {\n    switch (java_type) {\n      case JAVATYPE_MESSAGE:\n        return new MessageFieldGenerator(field, params);\n      case JAVATYPE_ENUM:\n        return new EnumFieldGenerator(field, params);\n      default:\n        return new PrimitiveFieldGenerator(field, params);\n    }\n  }\n}\n\nFieldGeneratorMap::~FieldGeneratorMap() {}\n\nconst FieldGenerator& FieldGeneratorMap::get(\n    const FieldDescriptor* field) const {\n  GOOGLE_CHECK_EQ(field->containing_type(), descriptor_);\n  return *field_generators_[field->index()];\n}\n\nvoid SetCommonOneofVariables(const FieldDescriptor* descriptor,\n                             map<string, string>* variables) {\n  (*variables)[\"oneof_name\"] =\n      UnderscoresToCamelCase(descriptor->containing_oneof());\n  (*variables)[\"oneof_capitalized_name\"] =\n      UnderscoresToCapitalizedCamelCase(descriptor->containing_oneof());\n  (*variables)[\"oneof_index\"] =\n      SimpleItoa(descriptor->containing_oneof()->index());\n  (*variables)[\"set_oneof_case\"] =\n      \"this.\" + (*variables)[\"oneof_name\"] +\n      \"Case_ = \" + SimpleItoa(descriptor->number());\n  (*variables)[\"clear_oneof_case\"] =\n      \"this.\" + (*variables)[\"oneof_name\"] + \"Case_ = 0\";\n  (*variables)[\"has_oneof_case\"] =\n      \"this.\" + (*variables)[\"oneof_name\"] + \"Case_ == \" +\n      SimpleItoa(descriptor->number());\n}\n\nvoid GenerateOneofFieldEquals(const FieldDescriptor* descriptor,\n                              const map<string, string>& variables,\n                              io::Printer* printer) {\n  if (GetJavaType(descriptor) == JAVATYPE_BYTES) {\n    printer->Print(variables,\n      \"if (this.has$capitalized_name$()) {\\n\"\n      \"  if (!java.util.Arrays.equals((byte[]) this.$oneof_name$_,\\n\"\n      \"                               (byte[]) other.$oneof_name$_)) {\\n\"\n      \"    return false;\\n\"\n      \"  }\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables,\n      \"if (this.has$capitalized_name$()) {\\n\"\n      \"  if (!this.$oneof_name$_.equals(other.$oneof_name$_)) {\\n\"\n      \"    return false;\\n\"\n      \"  }\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid GenerateOneofFieldHashCode(const FieldDescriptor* descriptor,\n                                const map<string, string>& variables,\n                                io::Printer* printer) {\n  if (GetJavaType(descriptor) == JAVATYPE_BYTES) {\n    printer->Print(variables,\n      \"result = 31 * result + ($has_oneof_case$\\n\"\n      \"   ? java.util.Arrays.hashCode((byte[]) this.$oneof_name$_) : 0);\\n\");\n  } else {\n    printer->Print(variables,\n      \"result = 31 * result +\\n\"\n      \"  ($has_oneof_case$ ? this.$oneof_name$_.hashCode() : 0);\\n\");\n  }\n}\n\n}  // namespace javanano\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVANANO_FIELD_H__\n\n#include <map>\n#include <string>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/compiler/javanano/javanano_params.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace io {\n    class Printer;             // printer.h\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\nclass FieldGenerator {\n public:\n  FieldGenerator(const Params& params) : params_(params) {}\n  virtual ~FieldGenerator();\n\n  virtual bool SavedDefaultNeeded() const;\n  virtual void GenerateInitSavedDefaultCode(io::Printer* printer) const;\n\n  // Generates code for Java fields and methods supporting this field.\n  // If this field needs a saved default (SavedDefaultNeeded() is true),\n  // then @lazy_init controls how the static field for that default value\n  // and its initialization code should be generated. If @lazy_init is\n  // true, the static field is not declared final and the initialization\n  // code is generated only when GenerateInitSavedDefaultCode is called;\n  // otherwise, the static field is declared final and initialized inline.\n  // GenerateInitSavedDefaultCode will not be called in the latter case.\n  virtual void GenerateMembers(\n      io::Printer* printer, bool lazy_init) const = 0;\n\n  virtual void GenerateClearCode(io::Printer* printer) const = 0;\n  virtual void GenerateMergingCode(io::Printer* printer) const = 0;\n\n  // Generates code to merge from packed serialized form. The default\n  // implementation will fail; subclasses which can handle packed serialized\n  // forms will override this and print appropriate code to the printer.\n  virtual void GenerateMergingCodeFromPacked(io::Printer* printer) const;\n\n  virtual void GenerateSerializationCode(io::Printer* printer) const = 0;\n  virtual void GenerateSerializedSizeCode(io::Printer* printer) const = 0;\n  virtual void GenerateEqualsCode(io::Printer* printer) const = 0;\n  virtual void GenerateHashCodeCode(io::Printer* printer) const = 0;\n  virtual void GenerateFixClonedCode(io::Printer* printer) const {}\n\n protected:\n  const Params& params_;\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGenerator);\n};\n\n// Convenience class which constructs FieldGenerators for a Descriptor.\nclass FieldGeneratorMap {\n public:\n  explicit FieldGeneratorMap(const Descriptor* descriptor, const Params &params);\n  ~FieldGeneratorMap();\n\n  const FieldGenerator& get(const FieldDescriptor* field) const;\n  int total_bits() const { return total_bits_; }\n  bool saved_defaults_needed() const { return saved_defaults_needed_; }\n\n private:\n  const Descriptor* descriptor_;\n  scoped_array<scoped_ptr<FieldGenerator> > field_generators_;\n  int total_bits_;\n  bool saved_defaults_needed_;\n\n  static FieldGenerator* MakeGenerator(const FieldDescriptor* field,\n      const Params &params, int* next_has_bit_index);\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap);\n};\n\nvoid SetCommonOneofVariables(const FieldDescriptor* descriptor,\n                             map<string, string>* variables);\nvoid GenerateOneofFieldEquals(const FieldDescriptor* descriptor,\n                              const map<string, string>& variables,\n                              io::Printer* printer);\nvoid GenerateOneofFieldHashCode(const FieldDescriptor* descriptor,\n                                const map<string, string>& variables,\n                                io::Printer* printer);\n\n}  // namespace javanano\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVANANO_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_file.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <iostream>\n\n#include <google/protobuf/compiler/javanano/javanano_file.h>\n#include <google/protobuf/compiler/javanano/javanano_enum.h>\n#include <google/protobuf/compiler/javanano/javanano_extension.h>\n#include <google/protobuf/compiler/javanano/javanano_helpers.h>\n#include <google/protobuf/compiler/javanano/javanano_message.h>\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\nnamespace {\n\n// Recursively searches the given message to see if it contains any extensions.\nbool UsesExtensions(const Message& message) {\n  const Reflection* reflection = message.GetReflection();\n\n  // We conservatively assume that unknown fields are extensions.\n  if (reflection->GetUnknownFields(message).field_count() > 0) return true;\n\n  vector<const FieldDescriptor*> fields;\n  reflection->ListFields(message, &fields);\n\n  for (int i = 0; i < fields.size(); i++) {\n    if (fields[i]->is_extension()) return true;\n\n    if (fields[i]->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n      if (fields[i]->is_repeated()) {\n        int size = reflection->FieldSize(message, fields[i]);\n        for (int j = 0; j < size; j++) {\n          const Message& sub_message =\n            reflection->GetRepeatedMessage(message, fields[i], j);\n          if (UsesExtensions(sub_message)) return true;\n        }\n      } else {\n        const Message& sub_message = reflection->GetMessage(message, fields[i]);\n        if (UsesExtensions(sub_message)) return true;\n      }\n    }\n  }\n\n  return false;\n}\n\n}  // namespace\n\nFileGenerator::FileGenerator(const FileDescriptor* file, const Params& params)\n  : file_(file),\n    params_(params),\n    java_package_(FileJavaPackage(params, file)),\n    classname_(FileClassName(params, file)) {}\n\nFileGenerator::~FileGenerator() {}\n\nbool FileGenerator::Validate(string* error) {\n  // Check for extensions\n  FileDescriptorProto file_proto;\n  file_->CopyTo(&file_proto);\n  if (UsesExtensions(file_proto) && !params_.store_unknown_fields()) {\n    error->assign(file_->name());\n    error->append(\n        \": Java NANO_RUNTIME only supports extensions when the \"\n        \"'store_unknown_fields' generator option is 'true'.\");\n    return false;\n  }\n\n  if (file_->service_count() != 0 && !params_.ignore_services()) {\n    error->assign(file_->name());\n    error->append(\n      \": Java NANO_RUNTIME does not support services\\\"\");\n    return false;\n  }\n\n  if (!IsOuterClassNeeded(params_, file_)) {\n    return true;\n  }\n\n  // Check whether legacy javanano generator would omit the outer class.\n  if (!params_.has_java_outer_classname(file_->name())\n      && file_->message_type_count() == 1\n      && file_->enum_type_count() == 0 && file_->extension_count() == 0) {\n    cout << \"INFO: \" << file_->name() << \":\" << endl;\n    cout << \"Javanano generator has changed to align with java generator. \"\n        \"An outer class will be created for this file and the single message \"\n        \"in the file will become a nested class. Use java_multiple_files to \"\n        \"skip generating the outer class, or set an explicit \"\n        \"java_outer_classname to suppress this message.\" << endl;\n  }\n\n  // Check that no class name matches the file's class name.  This is a common\n  // problem that leads to Java compile errors that can be hard to understand.\n  // It's especially bad when using the java_multiple_files, since we would\n  // end up overwriting the outer class with one of the inner ones.\n  bool found_conflict = false;\n  for (int i = 0; !found_conflict && i < file_->message_type_count(); i++) {\n    if (file_->message_type(i)->name() == classname_) {\n      found_conflict = true;\n    }\n  }\n  if (params_.java_enum_style()) {\n    for (int i = 0; !found_conflict && i < file_->enum_type_count(); i++) {\n      if (file_->enum_type(i)->name() == classname_) {\n        found_conflict = true;\n      }\n    }\n  }\n  if (found_conflict) {\n    error->assign(file_->name());\n    error->append(\n      \": Cannot generate Java output because the file's outer class name, \\\"\");\n    error->append(classname_);\n    error->append(\n      \"\\\", matches the name of one of the types declared inside it.  \"\n      \"Please either rename the type or use the java_outer_classname \"\n      \"option to specify a different outer class name for the .proto file.\");\n    return false;\n  }\n  return true;\n}\n\nvoid FileGenerator::Generate(io::Printer* printer) {\n  // We don't import anything because we refer to all classes by their\n  // fully-qualified names in the generated source.\n  printer->Print(\n    \"// Generated by the protocol buffer compiler.  DO NOT EDIT!\\n\");\n  if (!java_package_.empty()) {\n    printer->Print(\n      \"\\n\"\n      \"package $package$;\\n\",\n      \"package\", java_package_);\n  }\n\n  // Note: constants (from enums, emitted in the loop below) may have the same names as constants\n  // in the nested classes. This causes Java warnings, but is not fatal, so we suppress those\n  // warnings here in the top-most class declaration.\n  printer->Print(\n    \"\\n\"\n    \"@SuppressWarnings(\\\"hiding\\\")\\n\"\n    \"public interface $classname$ {\\n\",\n    \"classname\", classname_);\n  printer->Indent();\n\n  // -----------------------------------------------------------------\n\n  // Extensions.\n  for (int i = 0; i < file_->extension_count(); i++) {\n    ExtensionGenerator(file_->extension(i), params_).Generate(printer);\n  }\n\n  // Enums.\n  for (int i = 0; i < file_->enum_type_count(); i++) {\n    EnumGenerator(file_->enum_type(i), params_).Generate(printer);\n  }\n\n  // Messages.\n  if (!params_.java_multiple_files(file_->name())) {\n    for (int i = 0; i < file_->message_type_count(); i++) {\n      MessageGenerator(file_->message_type(i), params_).Generate(printer);\n    }\n  }\n\n  // Static variables.\n  for (int i = 0; i < file_->message_type_count(); i++) {\n    // TODO(kenton):  Reuse MessageGenerator objects?\n    MessageGenerator(file_->message_type(i), params_).GenerateStaticVariables(printer);\n  }\n\n  printer->Outdent();\n  printer->Print(\n    \"}\\n\");\n}\n\ntemplate<typename GeneratorClass, typename DescriptorClass>\nstatic void GenerateSibling(const string& package_dir,\n                            const string& java_package,\n                            const DescriptorClass* descriptor,\n                            GeneratorContext* output_directory,\n                            vector<string>* file_list,\n                            const Params& params) {\n  string filename = package_dir + descriptor->name() + \".java\";\n  file_list->push_back(filename);\n\n  scoped_ptr<io::ZeroCopyOutputStream> output(\n    output_directory->Open(filename));\n  io::Printer printer(output.get(), '$');\n\n  printer.Print(\n    \"// Generated by the protocol buffer compiler.  DO NOT EDIT!\\n\");\n  if (!java_package.empty()) {\n    printer.Print(\n      \"\\n\"\n      \"package $package$;\\n\",\n      \"package\", java_package);\n  }\n\n  GeneratorClass(descriptor, params).Generate(&printer);\n}\n\nvoid FileGenerator::GenerateSiblings(const string& package_dir,\n                                     GeneratorContext* output_directory,\n                                     vector<string>* file_list) {\n  if (params_.java_multiple_files(file_->name())) {\n    for (int i = 0; i < file_->message_type_count(); i++) {\n      GenerateSibling<MessageGenerator>(package_dir, java_package_,\n                                        file_->message_type(i),\n                                        output_directory, file_list, params_);\n    }\n\n    if (params_.java_enum_style()) {\n      for (int i = 0; i < file_->enum_type_count(); i++) {\n        GenerateSibling<EnumGenerator>(package_dir, java_package_,\n                                       file_->enum_type(i),\n                                       output_directory, file_list, params_);\n      }\n    }\n  }\n}\n\n}  // namespace javanano\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_file.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_FILE_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVANANO_FILE_H__\n\n#include <string>\n#include <vector>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/compiler/javanano/javanano_params.h>\n\nnamespace google {\nnamespace protobuf {\n  class FileDescriptor;        // descriptor.h\n  namespace io {\n    class Printer;             // printer.h\n  }\n  namespace compiler {\n    class GeneratorContext;     // code_generator.h\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\nclass FileGenerator {\n public:\n  explicit FileGenerator(const FileDescriptor* file, const Params& params);\n  ~FileGenerator();\n\n  // Checks for problems that would otherwise lead to cryptic compile errors.\n  // Returns true if there are no problems, or writes an error description to\n  // the given string and returns false otherwise.\n  bool Validate(string* error);\n\n  void Generate(io::Printer* printer);\n\n  // If we aren't putting everything into one file, this will write all the\n  // files other than the outer file (i.e. one for each message, enum, and\n  // service type).\n  void GenerateSiblings(const string& package_dir,\n                        GeneratorContext* output_directory,\n                        vector<string>* file_list);\n\n  const string& java_package() { return java_package_; }\n  const string& classname()    { return classname_;    }\n\n private:\n  const FileDescriptor* file_;\n  const Params& params_;\n  string java_package_;\n  string classname_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator);\n};\n\n}  // namespace javanano\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVANANO_FILE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_generator.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/compiler/javanano/javanano_params.h>\n#include <google/protobuf/compiler/javanano/javanano_generator.h>\n#include <google/protobuf/compiler/javanano/javanano_file.h>\n#include <google/protobuf/compiler/javanano/javanano_helpers.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\nnamespace {\n\nstring TrimString(const string& s) {\n  string::size_type start = s.find_first_not_of(\" \\n\\r\\t\");\n  if (start == string::npos) {\n    return \"\";\n  }\n  string::size_type end = s.find_last_not_of(\" \\n\\r\\t\") + 1;\n  return s.substr(start, end - start);\n}\n\n} // namespace\n\nvoid UpdateParamsRecursively(Params& params,\n    const FileDescriptor* file) {\n  // Add any parameters for this file\n  if (file->options().has_java_outer_classname()) {\n    params.set_java_outer_classname(\n      file->name(), file->options().java_outer_classname());\n  }\n  if (file->options().has_java_package()) {\n    string result = file->options().java_package();\n    if (!result.empty()) {\n      result += \".\";\n    }\n    result += \"nano\";\n    params.set_java_package(\n      file->name(), result);\n  }\n  if (file->options().has_java_multiple_files()) {\n    params.set_java_multiple_files(\n      file->name(), file->options().java_multiple_files());\n  }\n\n  // Loop through all dependent files recursively\n  // adding dep\n  for (int i = 0; i < file->dependency_count(); i++) {\n    UpdateParamsRecursively(params, file->dependency(i));\n  }\n}\n\nJavaNanoGenerator::JavaNanoGenerator() {}\nJavaNanoGenerator::~JavaNanoGenerator() {}\n\nbool JavaNanoGenerator::Generate(const FileDescriptor* file,\n                             const string& parameter,\n                             GeneratorContext* output_directory,\n                             string* error) const {\n  vector<pair<string, string> > options;\n\n  ParseGeneratorParameter(parameter, &options);\n\n  // -----------------------------------------------------------------\n  // parse generator options\n\n  // Name a file where we will write a list of generated file names, one\n  // per line.\n  string output_list_file;\n  Params params(file->name());\n\n  // Update per file params\n  UpdateParamsRecursively(params, file);\n\n  // Replace any existing options with ones from command line\n  for (int i = 0; i < options.size(); i++) {\n    string option_name = TrimString(options[i].first);\n    string option_value = TrimString(options[i].second);\n    if (option_name == \"output_list_file\") {\n      output_list_file = option_value;\n    } else if (option_name == \"java_package\") {\n        vector<string> parts;\n        SplitStringUsing(option_value, \"|\", &parts);\n        if (parts.size() != 2) {\n          *error = \"Bad java_package, expecting filename|PackageName found '\"\n            + option_value + \"'\";\n          return false;\n        }\n        params.set_java_package(parts[0], parts[1]);\n    } else if (option_name == \"java_outer_classname\") {\n        vector<string> parts;\n        SplitStringUsing(option_value, \"|\", &parts);\n        if (parts.size() != 2) {\n          *error = \"Bad java_outer_classname, \"\n                   \"expecting filename|ClassName found '\"\n                   + option_value + \"'\";\n          return false;\n        }\n        params.set_java_outer_classname(parts[0], parts[1]);\n    } else if (option_name == \"store_unknown_fields\") {\n      params.set_store_unknown_fields(option_value == \"true\");\n    } else if (option_name == \"java_multiple_files\") {\n      params.set_override_java_multiple_files(option_value == \"true\");\n    } else if (option_name == \"java_nano_generate_has\") {\n      params.set_generate_has(option_value == \"true\");\n    } else if (option_name == \"enum_style\") {\n      params.set_java_enum_style(option_value == \"java\");\n    } else if (option_name == \"optional_field_style\") {\n      params.set_optional_field_accessors(option_value == \"accessors\");\n      params.set_use_reference_types_for_primitives(option_value == \"reftypes\"\n          || option_value == \"reftypes_compat_mode\");\n      params.set_reftypes_primitive_enums(\n          option_value == \"reftypes_compat_mode\");\n      if (option_value == \"reftypes_compat_mode\") {\n        params.set_generate_clear(false);\n      }\n    } else if (option_name == \"generate_equals\") {\n      params.set_generate_equals(option_value == \"true\");\n    } else if (option_name == \"ignore_services\") {\n      params.set_ignore_services(option_value == \"true\");\n    } else if (option_name == \"parcelable_messages\") {\n      params.set_parcelable_messages(option_value == \"true\");\n    } else if (option_name == \"generate_clone\") {\n      params.set_generate_clone(option_value == \"true\");\n    } else if (option_name == \"generate_intdefs\") {\n      params.set_generate_intdefs(option_value == \"true\");\n    } else if (option_name == \"generate_clear\") {\n      params.set_generate_clear(option_value == \"true\");\n    } else {\n      *error = \"Ignore unknown javanano generator option: \" + option_name;\n    }\n  }\n\n  // Check illegal parameter combinations\n  // Note: the enum-like optional_field_style generator param ensures\n  // that we can never have illegal combinations of field styles\n  // (e.g. reftypes and accessors can't be on at the same time).\n  if (params.generate_has()\n      && (params.optional_field_accessors()\n          || params.use_reference_types_for_primitives())) {\n    error->assign(\"java_nano_generate_has=true cannot be used in conjunction\"\n        \" with optional_field_style=accessors or optional_field_style=reftypes\");\n    return false;\n  }\n\n  // -----------------------------------------------------------------\n\n  FileGenerator file_generator(file, params);\n  if (!file_generator.Validate(error)) {\n    return false;\n  }\n\n  string package_dir =\n    StringReplace(file_generator.java_package(), \".\", \"/\", true);\n  if (!package_dir.empty()) package_dir += \"/\";\n\n  vector<string> all_files;\n\n  if (IsOuterClassNeeded(params, file)) {\n    string java_filename = package_dir;\n    java_filename += file_generator.classname();\n    java_filename += \".java\";\n    all_files.push_back(java_filename);\n\n    // Generate main java file.\n    scoped_ptr<io::ZeroCopyOutputStream> output(\n      output_directory->Open(java_filename));\n    io::Printer printer(output.get(), '$');\n    file_generator.Generate(&printer);\n  }\n\n  // Generate sibling files.\n  file_generator.GenerateSiblings(package_dir, output_directory, &all_files);\n\n  // Generate output list if requested.\n  if (!output_list_file.empty()) {\n    // Generate output list.  This is just a simple text file placed in a\n    // deterministic location which lists the .java files being generated.\n    scoped_ptr<io::ZeroCopyOutputStream> srclist_raw_output(\n      output_directory->Open(output_list_file));\n    io::Printer srclist_printer(srclist_raw_output.get(), '$');\n    for (int i = 0; i < all_files.size(); i++) {\n      srclist_printer.Print(\"$filename$\\n\", \"filename\", all_files[i]);\n    }\n  }\n\n  return true;\n}\n\n}  // namespace java\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_generator.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Generates Java nano code for a given .proto file.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_NANO_GENERATOR_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVANANO_NANO_GENERATOR_H__\n\n#include <string>\n#include <google/protobuf/compiler/code_generator.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\n// CodeGenerator implementation which generates Java nano code.  If you create your\n// own protocol compiler binary and you want it to support Java output for the\n// nano runtime, you can do so by registering an instance of this CodeGenerator with\n// the CommandLineInterface in your main() function.\nclass LIBPROTOC_EXPORT JavaNanoGenerator : public CodeGenerator {\n public:\n  JavaNanoGenerator();\n  ~JavaNanoGenerator();\n\n  // implements CodeGenerator ----------------------------------------\n  bool Generate(const FileDescriptor* file,\n                const string& parameter,\n                GeneratorContext* output_directory,\n                string* error) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(JavaNanoGenerator);\n};\n\n}  // namespace javanano\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVANANO_NANO_GENERATOR_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_helpers.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <limits>\n#include <vector>\n\n#include <google/protobuf/compiler/javanano/javanano_helpers.h>\n#include <google/protobuf/compiler/javanano/javanano_params.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/stubs/hash.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\nconst char kThickSeparator[] =\n  \"// ===================================================================\\n\";\nconst char kThinSeparator[] =\n  \"// -------------------------------------------------------------------\\n\";\n\nclass RenameKeywords {\n private:\n  hash_set<string> java_keywords_set_;\n\n public:\n  RenameKeywords() {\n    static const char* kJavaKeywordsList[] = {\n      // Reserved Java Keywords\n      \"abstract\", \"assert\", \"boolean\", \"break\", \"byte\", \"case\", \"catch\",\n      \"char\", \"class\", \"const\", \"continue\", \"default\", \"do\", \"double\", \"else\",\n      \"enum\", \"extends\", \"final\", \"finally\", \"float\", \"for\", \"goto\", \"if\",\n      \"implements\", \"import\", \"instanceof\", \"int\", \"interface\", \"long\",\n      \"native\", \"new\", \"package\", \"private\", \"protected\", \"public\", \"return\",\n      \"short\", \"static\", \"strictfp\", \"super\", \"switch\", \"synchronized\",\n      \"this\", \"throw\", \"throws\", \"transient\", \"try\", \"void\", \"volatile\", \"while\",\n\n      // Reserved Keywords for Literals\n      \"false\", \"null\", \"true\"\n    };\n\n    for (int i = 0; i < GOOGLE_ARRAYSIZE(kJavaKeywordsList); i++) {\n      java_keywords_set_.insert(kJavaKeywordsList[i]);\n    }\n  }\n\n  // Used to rename the a field name if it's a java keyword.  Specifically\n  // this is used to rename the [\"name\"] or [\"capitalized_name\"] field params.\n  // (http://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html)\n  string RenameJavaKeywordsImpl(const string& input) {\n    string result = input;\n\n    if (java_keywords_set_.find(result) != java_keywords_set_.end()) {\n      result += \"_\";\n    }\n\n    return result;\n  }\n\n};\n\nstatic RenameKeywords sRenameKeywords;\n\nnamespace {\n\nconst char* kDefaultPackage = \"\";\n\nconst string& FieldName(const FieldDescriptor* field) {\n  // Groups are hacky:  The name of the field is just the lower-cased name\n  // of the group type.  In Java, though, we would like to retain the original\n  // capitalization of the type name.\n  if (field->type() == FieldDescriptor::TYPE_GROUP) {\n    return field->message_type()->name();\n  } else {\n    return field->name();\n  }\n}\n\nstring UnderscoresToCamelCaseImpl(const string& input, bool cap_next_letter) {\n  string result;\n  // Note:  I distrust ctype.h due to locales.\n  for (int i = 0; i < input.size(); i++) {\n    if ('a' <= input[i] && input[i] <= 'z') {\n      if (cap_next_letter) {\n        result += input[i] + ('A' - 'a');\n      } else {\n        result += input[i];\n      }\n      cap_next_letter = false;\n    } else if ('A' <= input[i] && input[i] <= 'Z') {\n      if (i == 0 && !cap_next_letter) {\n        // Force first letter to lower-case unless explicitly told to\n        // capitalize it.\n        result += input[i] + ('a' - 'A');\n      } else {\n        // Capital letters after the first are left as-is.\n        result += input[i];\n      }\n      cap_next_letter = false;\n    } else if ('0' <= input[i] && input[i] <= '9') {\n      result += input[i];\n      cap_next_letter = true;\n    } else {\n      cap_next_letter = true;\n    }\n  }\n  return result;\n}\n\n}  // namespace\n\nstring UnderscoresToCamelCase(const FieldDescriptor* field) {\n  return UnderscoresToCamelCaseImpl(FieldName(field), false);\n}\n\nstring UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field) {\n  return UnderscoresToCamelCaseImpl(FieldName(field), true);\n}\n\nstring UnderscoresToCamelCase(const MethodDescriptor* method) {\n  return UnderscoresToCamelCaseImpl(method->name(), false);\n}\n\nstring UnderscoresToCamelCase(const OneofDescriptor* oneof) {\n  return UnderscoresToCamelCaseImpl(oneof->name(), false);\n}\n\nstring UnderscoresToCapitalizedCamelCase(const OneofDescriptor* oneof) {\n  return UnderscoresToCamelCaseImpl(oneof->name(), true);\n}\n\nstring RenameJavaKeywords(const string& input) {\n  return sRenameKeywords.RenameJavaKeywordsImpl(input);\n}\n\nstring StripProto(const string& filename) {\n  if (HasSuffixString(filename, \".protodevel\")) {\n    return StripSuffixString(filename, \".protodevel\");\n  } else {\n    return StripSuffixString(filename, \".proto\");\n  }\n}\n\nstring FileClassName(const Params& params, const FileDescriptor* file) {\n  if (params.has_java_outer_classname(file->name())) {\n    return params.java_outer_classname(file->name());\n  } else {\n    // Use the filename itself with underscores removed\n    // and a CamelCase style name.\n    string basename;\n    string::size_type last_slash = file->name().find_last_of('/');\n    if (last_slash == string::npos) {\n      basename = file->name();\n    } else {\n      basename = file->name().substr(last_slash + 1);\n    }\n    return UnderscoresToCamelCaseImpl(StripProto(basename), true);\n  }\n}\n\nstring FileJavaPackage(const Params& params, const FileDescriptor* file) {\n  if (params.has_java_package(file->name())) {\n    return params.java_package(file->name());\n  } else {\n    string result = kDefaultPackage;\n    if (!file->package().empty()) {\n      if (!result.empty()) result += '.';\n      result += file->package();\n    }\n\n    if (!result.empty()) {\n      result += \".\";\n    }\n    result += \"nano\";\n\n    return result;\n  }\n}\n\nbool IsOuterClassNeeded(const Params& params, const FileDescriptor* file) {\n  // If java_multiple_files is false, the outer class is always needed.\n  if (!params.java_multiple_files(file->name())) {\n    return true;\n  }\n\n  // File-scope extensions need the outer class as the scope.\n  if (file->extension_count() != 0) {\n    return true;\n  }\n\n  // If container interfaces are not generated, file-scope enums need the\n  // outer class as the scope.\n  if (file->enum_type_count() != 0 && !params.java_enum_style()) {\n    return true;\n  }\n\n  return false;\n}\n\nstring ToJavaName(const Params& params, const string& name, bool is_class,\n    const Descriptor* parent, const FileDescriptor* file) {\n  string result;\n  if (parent != NULL) {\n    result.append(ClassName(params, parent));\n  } else if (is_class && params.java_multiple_files(file->name())) {\n    result.append(FileJavaPackage(params, file));\n  } else {\n    result.append(ClassName(params, file));\n  }\n  if (!result.empty()) result.append(1, '.');\n  result.append(RenameJavaKeywords(name));\n  return result;\n}\n\nstring ClassName(const Params& params, const FileDescriptor* descriptor) {\n  string result = FileJavaPackage(params, descriptor);\n  if (!result.empty()) result += '.';\n  result += FileClassName(params, descriptor);\n  return result;\n}\n\nstring ClassName(const Params& params, const EnumDescriptor* descriptor) {\n  const Descriptor* parent = descriptor->containing_type();\n  // When using Java enum style, an enum's class name contains the enum name.\n  // Use the standard ToJavaName translation.\n  if (params.java_enum_style()) {\n    return ToJavaName(params, descriptor->name(), true, parent,\n                      descriptor->file());\n  }\n  // Otherwise the enum members are accessed from the enclosing class.\n  if (parent != NULL) {\n    return ClassName(params, parent);\n  } else {\n    return ClassName(params, descriptor->file());\n  }\n}\n\nstring FieldConstantName(const FieldDescriptor *field) {\n  string name = field->name() + \"_FIELD_NUMBER\";\n  UpperString(&name);\n  return name;\n}\n\nstring FieldDefaultConstantName(const FieldDescriptor *field) {\n  return \"_\" + RenameJavaKeywords(UnderscoresToCamelCase(field)) + \"Default\";\n}\n\nvoid PrintFieldComment(io::Printer* printer, const FieldDescriptor* field) {\n  // We don't want to print group bodies so we cut off after the first line\n  // (the second line for extensions).\n  string def = field->DebugString();\n  string::size_type first_line_end = def.find_first_of('\\n');\n  printer->Print(\"// $def$\\n\",\n    \"def\", def.substr(0, first_line_end));\n  if (field->is_extension()) {\n    string::size_type second_line_start = first_line_end + 1;\n    string::size_type second_line_length =\n        def.find('\\n', second_line_start) - second_line_start;\n    printer->Print(\"// $def$\\n\",\n      \"def\", def.substr(second_line_start, second_line_length));\n  }\n}\n\nJavaType GetJavaType(FieldDescriptor::Type field_type) {\n  switch (field_type) {\n    case FieldDescriptor::TYPE_INT32:\n    case FieldDescriptor::TYPE_UINT32:\n    case FieldDescriptor::TYPE_SINT32:\n    case FieldDescriptor::TYPE_FIXED32:\n    case FieldDescriptor::TYPE_SFIXED32:\n      return JAVATYPE_INT;\n\n    case FieldDescriptor::TYPE_INT64:\n    case FieldDescriptor::TYPE_UINT64:\n    case FieldDescriptor::TYPE_SINT64:\n    case FieldDescriptor::TYPE_FIXED64:\n    case FieldDescriptor::TYPE_SFIXED64:\n      return JAVATYPE_LONG;\n\n    case FieldDescriptor::TYPE_FLOAT:\n      return JAVATYPE_FLOAT;\n\n    case FieldDescriptor::TYPE_DOUBLE:\n      return JAVATYPE_DOUBLE;\n\n    case FieldDescriptor::TYPE_BOOL:\n      return JAVATYPE_BOOLEAN;\n\n    case FieldDescriptor::TYPE_STRING:\n      return JAVATYPE_STRING;\n\n    case FieldDescriptor::TYPE_BYTES:\n      return JAVATYPE_BYTES;\n\n    case FieldDescriptor::TYPE_ENUM:\n      return JAVATYPE_ENUM;\n\n    case FieldDescriptor::TYPE_GROUP:\n    case FieldDescriptor::TYPE_MESSAGE:\n      return JAVATYPE_MESSAGE;\n\n    // No default because we want the compiler to complain if any new\n    // types are added.\n  }\n\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return JAVATYPE_INT;\n}\n\nstring PrimitiveTypeName(JavaType type) {\n  switch (type) {\n    case JAVATYPE_INT    : return \"int\";\n    case JAVATYPE_LONG   : return \"long\";\n    case JAVATYPE_FLOAT  : return \"float\";\n    case JAVATYPE_DOUBLE : return \"double\";\n    case JAVATYPE_BOOLEAN: return \"boolean\";\n    case JAVATYPE_STRING : return \"java.lang.String\";\n    case JAVATYPE_BYTES  : return \"byte[]\";\n    case JAVATYPE_ENUM   : return \"int\";\n    case JAVATYPE_MESSAGE: return \"\";\n\n    // No default because we want the compiler to complain if any new\n    // JavaTypes are added.\n  }\n\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return \"\";\n}\n\nstring BoxedPrimitiveTypeName(JavaType type) {\n  switch (type) {\n    case JAVATYPE_INT    : return \"java.lang.Integer\";\n    case JAVATYPE_LONG   : return \"java.lang.Long\";\n    case JAVATYPE_FLOAT  : return \"java.lang.Float\";\n    case JAVATYPE_DOUBLE : return \"java.lang.Double\";\n    case JAVATYPE_BOOLEAN: return \"java.lang.Boolean\";\n    case JAVATYPE_STRING : return \"java.lang.String\";\n    case JAVATYPE_BYTES  : return \"byte[]\";\n    case JAVATYPE_ENUM   : return \"java.lang.Integer\";\n    case JAVATYPE_MESSAGE: return \"\";\n\n    // No default because we want the compiler to complain if any new\n    // JavaTypes are added.\n  }\n\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return \"\";\n}\n\nstring EmptyArrayName(const Params& params, const FieldDescriptor* field) {\n  switch (GetJavaType(field)) {\n    case JAVATYPE_INT    : return \"com.google.protobuf.nano.WireFormatNano.EMPTY_INT_ARRAY\";\n    case JAVATYPE_LONG   : return \"com.google.protobuf.nano.WireFormatNano.EMPTY_LONG_ARRAY\";\n    case JAVATYPE_FLOAT  : return \"com.google.protobuf.nano.WireFormatNano.EMPTY_FLOAT_ARRAY\";\n    case JAVATYPE_DOUBLE : return \"com.google.protobuf.nano.WireFormatNano.EMPTY_DOUBLE_ARRAY\";\n    case JAVATYPE_BOOLEAN: return \"com.google.protobuf.nano.WireFormatNano.EMPTY_BOOLEAN_ARRAY\";\n    case JAVATYPE_STRING : return \"com.google.protobuf.nano.WireFormatNano.EMPTY_STRING_ARRAY\";\n    case JAVATYPE_BYTES  : return \"com.google.protobuf.nano.WireFormatNano.EMPTY_BYTES_ARRAY\";\n    case JAVATYPE_ENUM   : return \"com.google.protobuf.nano.WireFormatNano.EMPTY_INT_ARRAY\";\n    case JAVATYPE_MESSAGE: return ClassName(params, field->message_type()) + \".EMPTY_ARRAY\";\n\n    // No default because we want the compiler to complain if any new\n    // JavaTypes are added.\n  }\n\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return \"\";\n}\n\nstring DefaultValue(const Params& params, const FieldDescriptor* field) {\n  if (field->label() == FieldDescriptor::LABEL_REPEATED) {\n    return EmptyArrayName(params, field);\n  }\n\n  if (params.use_reference_types_for_primitives()) {\n    if (params.reftypes_primitive_enums()\n          && field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {\n      return \"Integer.MIN_VALUE\";\n    }\n    return \"null\";\n  }\n\n  // Switch on cpp_type since we need to know which default_value_* method\n  // of FieldDescriptor to call.\n  switch (field->cpp_type()) {\n    case FieldDescriptor::CPPTYPE_INT32:\n      return SimpleItoa(field->default_value_int32());\n    case FieldDescriptor::CPPTYPE_UINT32:\n      // Need to print as a signed int since Java has no unsigned.\n      return SimpleItoa(static_cast<int32>(field->default_value_uint32()));\n    case FieldDescriptor::CPPTYPE_INT64:\n      return SimpleItoa(field->default_value_int64()) + \"L\";\n    case FieldDescriptor::CPPTYPE_UINT64:\n      return SimpleItoa(static_cast<int64>(field->default_value_uint64())) +\n             \"L\";\n    case FieldDescriptor::CPPTYPE_DOUBLE: {\n      double value = field->default_value_double();\n      if (value == numeric_limits<double>::infinity()) {\n        return \"Double.POSITIVE_INFINITY\";\n      } else if (value == -numeric_limits<double>::infinity()) {\n        return \"Double.NEGATIVE_INFINITY\";\n      } else if (value != value) {\n        return \"Double.NaN\";\n      } else {\n        return SimpleDtoa(value) + \"D\";\n      }\n    }\n    case FieldDescriptor::CPPTYPE_FLOAT: {\n      float value = field->default_value_float();\n      if (value == numeric_limits<float>::infinity()) {\n        return \"Float.POSITIVE_INFINITY\";\n      } else if (value == -numeric_limits<float>::infinity()) {\n        return \"Float.NEGATIVE_INFINITY\";\n      } else if (value != value) {\n        return \"Float.NaN\";\n      } else {\n        return SimpleFtoa(value) + \"F\";\n      }\n    }\n    case FieldDescriptor::CPPTYPE_BOOL:\n      return field->default_value_bool() ? \"true\" : \"false\";\n    case FieldDescriptor::CPPTYPE_STRING:\n      if (!field->default_value_string().empty()) {\n        // Point it to the static final in the generated code.\n        return FieldDefaultConstantName(field);\n      } else {\n        if (field->type() == FieldDescriptor::TYPE_BYTES) {\n          return \"com.google.protobuf.nano.WireFormatNano.EMPTY_BYTES\";\n        } else {\n          return \"\\\"\\\"\";\n        }\n      }\n\n    case FieldDescriptor::CPPTYPE_ENUM:\n      return ClassName(params, field->enum_type()) + \".\" +\n             RenameJavaKeywords(field->default_value_enum()->name());\n\n    case FieldDescriptor::CPPTYPE_MESSAGE:\n      return \"null\";\n\n    // No default because we want the compiler to complain if any new\n    // types are added.\n  }\n\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return \"\";\n}\n\n\nstatic const char* kBitMasks[] = {\n  \"0x00000001\",\n  \"0x00000002\",\n  \"0x00000004\",\n  \"0x00000008\",\n  \"0x00000010\",\n  \"0x00000020\",\n  \"0x00000040\",\n  \"0x00000080\",\n\n  \"0x00000100\",\n  \"0x00000200\",\n  \"0x00000400\",\n  \"0x00000800\",\n  \"0x00001000\",\n  \"0x00002000\",\n  \"0x00004000\",\n  \"0x00008000\",\n\n  \"0x00010000\",\n  \"0x00020000\",\n  \"0x00040000\",\n  \"0x00080000\",\n  \"0x00100000\",\n  \"0x00200000\",\n  \"0x00400000\",\n  \"0x00800000\",\n\n  \"0x01000000\",\n  \"0x02000000\",\n  \"0x04000000\",\n  \"0x08000000\",\n  \"0x10000000\",\n  \"0x20000000\",\n  \"0x40000000\",\n  \"0x80000000\",\n};\n\nstring GetBitFieldName(int index) {\n  string var_name = \"bitField\";\n  var_name += SimpleItoa(index);\n  var_name += \"_\";\n  return var_name;\n}\n\nstring GetBitFieldNameForBit(int bit_index) {\n  return GetBitFieldName(bit_index / 32);\n}\n\nstring GenerateGetBit(int bit_index) {\n  string var_name = GetBitFieldNameForBit(bit_index);\n  int bit_in_var_index = bit_index % 32;\n\n  string mask = kBitMasks[bit_in_var_index];\n  string result = \"((\" + var_name + \" & \" + mask + \") != 0)\";\n  return result;\n}\n\nstring GenerateSetBit(int bit_index) {\n  string var_name = GetBitFieldNameForBit(bit_index);\n  int bit_in_var_index = bit_index % 32;\n\n  string mask = kBitMasks[bit_in_var_index];\n  string result = var_name + \" |= \" + mask;\n  return result;\n}\n\nstring GenerateClearBit(int bit_index) {\n  string var_name = GetBitFieldNameForBit(bit_index);\n  int bit_in_var_index = bit_index % 32;\n\n  string mask = kBitMasks[bit_in_var_index];\n  string result = var_name + \" = (\" + var_name + \" & ~\" + mask + \")\";\n  return result;\n}\n\nstring GenerateDifferentBit(int bit_index) {\n  string var_name = GetBitFieldNameForBit(bit_index);\n  int bit_in_var_index = bit_index % 32;\n\n  string mask = kBitMasks[bit_in_var_index];\n  string result = \"((\" + var_name + \" & \" + mask\n      + \") != (other.\" + var_name + \" & \" + mask + \"))\";\n  return result;\n}\n\nvoid SetBitOperationVariables(const string name,\n    int bitIndex, map<string, string>* variables) {\n  (*variables)[\"get_\" + name] = GenerateGetBit(bitIndex);\n  (*variables)[\"set_\" + name] = GenerateSetBit(bitIndex);\n  (*variables)[\"clear_\" + name] = GenerateClearBit(bitIndex);\n  (*variables)[\"different_\" + name] = GenerateDifferentBit(bitIndex);\n}\n\nbool HasMapField(const Descriptor* descriptor) {\n  for (int i = 0; i < descriptor->field_count(); ++i) {\n    const FieldDescriptor* field = descriptor->field(i);\n    if (field->type() == FieldDescriptor::TYPE_MESSAGE &&\n        IsMapEntry(field->message_type())) {\n      return true;\n    }\n  }\n  return false;\n}\n\n}  // namespace javanano\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_helpers.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_HELPERS_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVANANO_HELPERS_H__\n\n#include <string>\n#include <google/protobuf/compiler/javanano/javanano_params.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/io/printer.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\n// Commonly-used separator comments.  Thick is a line of '=', thin is a line\n// of '-'.\nextern const char kThickSeparator[];\nextern const char kThinSeparator[];\n\n// Converts the field's name to camel-case, e.g. \"foo_bar_baz\" becomes\n// \"fooBarBaz\" or \"FooBarBaz\", respectively.\nstring UnderscoresToCamelCase(const FieldDescriptor* field);\nstring UnderscoresToCamelCase(const OneofDescriptor* oneof);\nstring UnderscoresToCapitalizedCamelCase(const FieldDescriptor* field);\nstring UnderscoresToCapitalizedCamelCase(const OneofDescriptor* oneof);\n\n// Appends an \"_\" to the end of a field where the name is a reserved java\n// keyword.  For example int32 public = 1 will generate int public_.\nstring RenameJavaKeywords(const string& input);\n\n// Similar, but for method names.  (Typically, this merely has the effect\n// of lower-casing the first letter of the name.)\nstring UnderscoresToCamelCase(const MethodDescriptor* method);\n\n// Strips \".proto\" or \".protodevel\" from the end of a filename.\nstring StripProto(const string& filename);\n\n// Gets the unqualified class name for the file.  Each .proto file becomes a\n// single Java class, with all its contents nested in that class.\nstring FileClassName(const Params& params, const FileDescriptor* file);\n\n// Returns the file's Java package name.\nstring FileJavaPackage(const Params& params, const FileDescriptor* file);\n\n// Returns whether the Java outer class is needed, i.e. whether the option\n// java_multiple_files is false, or the proto file contains any file-scope\n// enums/extensions.\nbool IsOuterClassNeeded(const Params& params, const FileDescriptor* file);\n\n// Converts the given simple name of a proto entity to its fully-qualified name\n// in the Java namespace, given that it is in the given file enclosed in the\n// given parent message (or NULL for file-scope entities). Whether the file's\n// outer class name should be included in the return value depends on factors\n// inferrable from the given arguments, including is_class which indicates\n// whether the entity translates to a Java class.\nstring ToJavaName(const Params& params, const string& name, bool is_class,\n    const Descriptor* parent, const FileDescriptor* file);\n\n// These return the fully-qualified class name corresponding to the given\n// descriptor.\ninline string ClassName(const Params& params, const Descriptor* descriptor) {\n  return ToJavaName(params, descriptor->name(), true,\n                    descriptor->containing_type(), descriptor->file());\n}\nstring ClassName(const Params& params, const EnumDescriptor* descriptor);\ninline string ClassName(const Params& params,\n    const ServiceDescriptor* descriptor) {\n  return ToJavaName(params, descriptor->name(), true, NULL, descriptor->file());\n}\ninline string ExtensionIdentifierName(const Params& params,\n    const FieldDescriptor* descriptor) {\n  return ToJavaName(params, descriptor->name(), false,\n                    descriptor->extension_scope(), descriptor->file());\n}\nstring ClassName(const Params& params, const FileDescriptor* descriptor);\n\n// Get the unqualified name that should be used for a field's field\n// number constant.\nstring FieldConstantName(const FieldDescriptor *field);\n\nstring FieldDefaultConstantName(const FieldDescriptor *field);\n\n// Print the field's proto-syntax definition as a comment.\nvoid PrintFieldComment(io::Printer* printer, const FieldDescriptor* field);\n\nenum JavaType {\n  JAVATYPE_INT,\n  JAVATYPE_LONG,\n  JAVATYPE_FLOAT,\n  JAVATYPE_DOUBLE,\n  JAVATYPE_BOOLEAN,\n  JAVATYPE_STRING,\n  JAVATYPE_BYTES,\n  JAVATYPE_ENUM,\n  JAVATYPE_MESSAGE\n};\n\nJavaType GetJavaType(FieldDescriptor::Type field_type);\n\ninline JavaType GetJavaType(const FieldDescriptor* field) {\n  return GetJavaType(field->type());\n}\n\nstring PrimitiveTypeName(JavaType type);\n\n// Get the fully-qualified class name for a boxed primitive type, e.g.\n// \"java.lang.Integer\" for JAVATYPE_INT.  Returns NULL for enum and message\n// types.\nstring BoxedPrimitiveTypeName(JavaType type);\n\nstring EmptyArrayName(const Params& params, const FieldDescriptor* field);\n\nstring DefaultValue(const Params& params, const FieldDescriptor* field);\n\n\n// Methods for shared bitfields.\n\n// Gets the name of the shared bitfield for the given field index.\nstring GetBitFieldName(int index);\n\n// Gets the name of the shared bitfield for the given bit index.\n// Effectively, GetBitFieldName(bit_index / 32)\nstring GetBitFieldNameForBit(int bit_index);\n\n// Generates the java code for the expression that returns whether the bit at\n// the given bit index is set.\n// Example: \"((bitField1_ & 0x04000000) != 0)\"\nstring GenerateGetBit(int bit_index);\n\n// Generates the java code for the expression that sets the bit at the given\n// bit index.\n// Example: \"bitField1_ |= 0x04000000\"\nstring GenerateSetBit(int bit_index);\n\n// Generates the java code for the expression that clears the bit at the given\n// bit index.\n// Example: \"bitField1_ = (bitField1_ & ~0x04000000)\"\nstring GenerateClearBit(int bit_index);\n\n// Generates the java code for the expression that returns whether the bit at\n// the given bit index contains different values in the current object and\n// another object accessible via the variable 'other'.\n// Example: \"((bitField1_ & 0x04000000) != (other.bitField1_ & 0x04000000))\"\nstring GenerateDifferentBit(int bit_index);\n\n// Sets the 'get_*', 'set_*', 'clear_*' and 'different_*' variables, where * is\n// the given name of the bit, to the appropriate Java expressions for the given\n// bit index.\nvoid SetBitOperationVariables(const string name,\n    int bitIndex, map<string, string>* variables);\n\ninline bool IsMapEntry(const Descriptor* descriptor) {\n  // TODO(liujisi): Add an option to turn on maps for proto2 syntax as well.\n  return descriptor->options().map_entry() &&\n      descriptor->file()->syntax() == FileDescriptor::SYNTAX_PROTO3;\n}\n\nbool HasMapField(const Descriptor* descriptor);\n\n}  // namespace javanano\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVANANO_HELPERS_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_map_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/compiler/javanano/javanano_map_field.h>\n#include <google/protobuf/compiler/javanano/javanano_helpers.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\nnamespace {\n\nstring TypeName(const Params& params, const FieldDescriptor* field,\n                bool boxed) {\n  JavaType java_type = GetJavaType(field);\n  switch (java_type) {\n    case JAVATYPE_MESSAGE:\n      return ClassName(params, field->message_type());\n    case JAVATYPE_INT:\n    case JAVATYPE_LONG:\n    case JAVATYPE_FLOAT:\n    case JAVATYPE_DOUBLE:\n    case JAVATYPE_BOOLEAN:\n    case JAVATYPE_STRING:\n    case JAVATYPE_BYTES:\n    case JAVATYPE_ENUM:\n      if (boxed) {\n        return BoxedPrimitiveTypeName(java_type);\n      } else {\n        return PrimitiveTypeName(java_type);\n      }\n    // No default because we want the compiler to complain if any new JavaTypes\n    // are added..\n  }\n\n  GOOGLE_LOG(FATAL) << \"should not reach here.\";\n  return \"\";\n}\n\nconst FieldDescriptor* KeyField(const FieldDescriptor* descriptor) {\n  GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());\n  const Descriptor* message = descriptor->message_type();\n  GOOGLE_CHECK(message->options().map_entry());\n  return message->FindFieldByName(\"key\");\n}\n\nconst FieldDescriptor* ValueField(const FieldDescriptor* descriptor) {\n  GOOGLE_CHECK_EQ(FieldDescriptor::TYPE_MESSAGE, descriptor->type());\n  const Descriptor* message = descriptor->message_type();\n  GOOGLE_CHECK(message->options().map_entry());\n  return message->FindFieldByName(\"value\");\n}\n\nvoid SetMapVariables(const Params& params,\n    const FieldDescriptor* descriptor, map<string, string>* variables) {\n  const FieldDescriptor* key = KeyField(descriptor);\n  const FieldDescriptor* value = ValueField(descriptor);\n  (*variables)[\"name\"] =\n    RenameJavaKeywords(UnderscoresToCamelCase(descriptor));\n  (*variables)[\"number\"] = SimpleItoa(descriptor->number());\n  (*variables)[\"key_type\"] = TypeName(params, key, false);\n  (*variables)[\"boxed_key_type\"] = TypeName(params,key, true);\n  (*variables)[\"key_desc_type\"] =\n      \"TYPE_\" + ToUpper(FieldDescriptor::TypeName(key->type()));\n  (*variables)[\"key_tag\"] = SimpleItoa(internal::WireFormat::MakeTag(key));\n  (*variables)[\"value_type\"] = TypeName(params, value, false);\n  (*variables)[\"boxed_value_type\"] = TypeName(params, value, true);\n  (*variables)[\"value_desc_type\"] =\n      \"TYPE_\" + ToUpper(FieldDescriptor::TypeName(value->type()));\n  (*variables)[\"value_tag\"] = SimpleItoa(internal::WireFormat::MakeTag(value));\n  (*variables)[\"type_parameters\"] =\n      (*variables)[\"boxed_key_type\"] + \", \" + (*variables)[\"boxed_value_type\"];\n  (*variables)[\"value_default\"] =\n      value->type() == FieldDescriptor::TYPE_MESSAGE\n          ? \"new \" + (*variables)[\"value_type\"] + \"()\"\n          : \"null\";\n}\n}  // namespace\n\n// ===================================================================\nMapFieldGenerator::MapFieldGenerator(const FieldDescriptor* descriptor,\n                                     const Params& params)\n    : FieldGenerator(params), descriptor_(descriptor) {\n  SetMapVariables(params, descriptor, &variables_);\n}\n\nMapFieldGenerator::~MapFieldGenerator() {}\n\nvoid MapFieldGenerator::\nGenerateMembers(io::Printer* printer, bool /* unused lazy_init */) const {\n  printer->Print(variables_,\n    \"public java.util.Map<$type_parameters$> $name$;\\n\");\n}\n\nvoid MapFieldGenerator::\nGenerateClearCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$ = null;\\n\");\n}\n\nvoid MapFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"this.$name$ = com.google.protobuf.nano.InternalNano.mergeMapEntry(\\n\"\n    \"  input, this.$name$, mapFactory,\\n\"\n    \"  com.google.protobuf.nano.InternalNano.$key_desc_type$,\\n\"\n    \"  com.google.protobuf.nano.InternalNano.$value_desc_type$,\\n\"\n    \"  $value_default$,\\n\"\n    \"  $key_tag$, $value_tag$);\\n\"\n    \"\\n\");\n}\n\nvoid MapFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (this.$name$ != null) {\\n\"\n    \"  com.google.protobuf.nano.InternalNano.serializeMapField(\\n\"\n    \"    output, this.$name$, $number$,\\n\"\n    \"  com.google.protobuf.nano.InternalNano.$key_desc_type$,\\n\"\n    \"  com.google.protobuf.nano.InternalNano.$value_desc_type$);\\n\"\n    \"}\\n\");\n}\n\nvoid MapFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (this.$name$ != null) {\\n\"\n    \"  size += com.google.protobuf.nano.InternalNano.computeMapFieldSize(\\n\"\n    \"    this.$name$, $number$,\\n\"\n    \"  com.google.protobuf.nano.InternalNano.$key_desc_type$,\\n\"\n    \"  com.google.protobuf.nano.InternalNano.$value_desc_type$);\\n\"\n    \"}\\n\");\n}\n\nvoid MapFieldGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (!com.google.protobuf.nano.InternalNano.equals(\\n\"\n    \"  this.$name$, other.$name$)) {\\n\"\n    \"  return false;\\n\"\n    \"}\\n\");\n}\n\nvoid MapFieldGenerator::\nGenerateHashCodeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"result = 31 * result +\\n\"\n    \"    com.google.protobuf.nano.InternalNano.hashCode(this.$name$);\\n\");\n}\n\n}  // namespace javanano\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_map_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_MAP_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVANANO_MAP_FIELD_H__\n\n#include <map>\n#include <string>\n#include <vector>\n#include <google/protobuf/compiler/javanano/javanano_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\nclass MapFieldGenerator : public FieldGenerator {\n public:\n  explicit MapFieldGenerator(\n      const FieldDescriptor* descriptor, const Params& params);\n  ~MapFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  void GenerateMembers(io::Printer* printer, bool lazy_init) const;\n  void GenerateClearCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCodeCode(io::Printer* printer) const;\n\n private:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldGenerator);\n};\n\n}  // namespace javanano\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVANANO_MAP_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_message.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <algorithm>\n#include <google/protobuf/stubs/hash.h>\n#include <google/protobuf/compiler/javanano/javanano_message.h>\n#include <google/protobuf/compiler/javanano/javanano_enum.h>\n#include <google/protobuf/compiler/javanano/javanano_extension.h>\n#include <google/protobuf/compiler/javanano/javanano_helpers.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/descriptor.pb.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\nusing internal::WireFormat;\nusing internal::WireFormatLite;\n\nnamespace {\n\nstruct FieldOrderingByNumber {\n  inline bool operator()(const FieldDescriptor* a,\n                         const FieldDescriptor* b) const {\n    return a->number() < b->number();\n  }\n};\n\n// Sort the fields of the given Descriptor by number into a new[]'d array\n// and return it.\nconst FieldDescriptor** SortFieldsByNumber(const Descriptor* descriptor) {\n  const FieldDescriptor** fields =\n    new const FieldDescriptor*[descriptor->field_count()];\n  for (int i = 0; i < descriptor->field_count(); i++) {\n    fields[i] = descriptor->field(i);\n  }\n  sort(fields, fields + descriptor->field_count(),\n       FieldOrderingByNumber());\n  return fields;\n}\n\n}  // namespace\n\n// ===================================================================\n\nMessageGenerator::MessageGenerator(const Descriptor* descriptor, const Params& params)\n  : params_(params),\n    descriptor_(descriptor),\n    field_generators_(descriptor, params) {\n}\n\nMessageGenerator::~MessageGenerator() {}\n\nvoid MessageGenerator::GenerateStaticVariables(io::Printer* printer) {\n  // Generate static members for all nested types.\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    // TODO(kenton):  Reuse MessageGenerator objects?\n    if (IsMapEntry(descriptor_->nested_type(i))) continue;\n    MessageGenerator(descriptor_->nested_type(i), params_)\n      .GenerateStaticVariables(printer);\n  }\n}\n\nvoid MessageGenerator::GenerateStaticVariableInitializers(\n    io::Printer* printer) {\n  // Generate static member initializers for all nested types.\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n   // TODO(kenton):  Reuse MessageGenerator objects?\n    if (IsMapEntry(descriptor_->nested_type(i))) continue;\n    MessageGenerator(descriptor_->nested_type(i), params_)\n      .GenerateStaticVariableInitializers(printer);\n  }\n}\n\nvoid MessageGenerator::Generate(io::Printer* printer) {\n  if (!params_.store_unknown_fields() &&\n      (descriptor_->extension_count() != 0 || descriptor_->extension_range_count() != 0)) {\n    GOOGLE_LOG(FATAL) << \"Extensions are only supported in NANO_RUNTIME if the \"\n        \"'store_unknown_fields' generator option is 'true'\\n\";\n  }\n\n  const string& file_name = descriptor_->file()->name();\n  bool is_own_file =\n    params_.java_multiple_files(file_name)\n      && descriptor_->containing_type() == NULL;\n\n  if (is_own_file) {\n    // Note: constants (from enums and fields requiring stored defaults, emitted in the loop below)\n    // may have the same names as constants in the nested classes. This causes Java warnings, but\n    // is not fatal, so we suppress those warnings here in the top-most class declaration.\n    printer->Print(\n      \"\\n\"\n      \"@SuppressWarnings(\\\"hiding\\\")\\n\"\n      \"public final class $classname$ extends\\n\",\n      \"classname\", descriptor_->name());\n  } else {\n    printer->Print(\n      \"\\n\"\n      \"public static final class $classname$ extends\\n\",\n      \"classname\", descriptor_->name());\n  }\n  if (params_.store_unknown_fields() && params_.parcelable_messages()) {\n    printer->Print(\n      \"    com.google.protobuf.nano.android.ParcelableExtendableMessageNano<$classname$>\",\n      \"classname\", descriptor_->name());\n  } else if (params_.store_unknown_fields()) {\n    printer->Print(\n      \"    com.google.protobuf.nano.ExtendableMessageNano<$classname$>\",\n      \"classname\", descriptor_->name());\n  } else if (params_.parcelable_messages()) {\n    printer->Print(\n      \"    com.google.protobuf.nano.android.ParcelableMessageNano\");\n  } else {\n    printer->Print(\n      \"    com.google.protobuf.nano.MessageNano\");\n  }\n  if (params_.generate_clone()) {\n    printer->Print(\" implements java.lang.Cloneable {\\n\");\n  } else {\n    printer->Print(\" {\\n\");\n  }\n  printer->Indent();\n\n  if (params_.parcelable_messages()) {\n    printer->Print(\n      \"\\n\"\n      \"// Used by Parcelable\\n\"\n      \"@SuppressWarnings({\\\"unused\\\"})\\n\"\n      \"public static final android.os.Parcelable.Creator<$classname$> CREATOR =\\n\"\n      \"    new com.google.protobuf.nano.android.ParcelableMessageNanoCreator<\\n\"\n      \"        $classname$>($classname$.class);\\n\",\n      \"classname\", descriptor_->name());\n  }\n\n  // Nested types and extensions\n  for (int i = 0; i < descriptor_->extension_count(); i++) {\n    ExtensionGenerator(descriptor_->extension(i), params_).Generate(printer);\n  }\n\n  for (int i = 0; i < descriptor_->enum_type_count(); i++) {\n    EnumGenerator(descriptor_->enum_type(i), params_).Generate(printer);\n  }\n\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    if (IsMapEntry(descriptor_->nested_type(i))) continue;\n    MessageGenerator(descriptor_->nested_type(i), params_).Generate(printer);\n  }\n\n  // oneof\n  map<string, string> vars;\n  vars[\"message_name\"] = descriptor_->name();\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    const OneofDescriptor* oneof_desc = descriptor_->oneof_decl(i);\n    vars[\"oneof_name\"] = UnderscoresToCamelCase(oneof_desc);\n    vars[\"oneof_capitalized_name\"] =\n        UnderscoresToCapitalizedCamelCase(oneof_desc);\n    vars[\"oneof_index\"] = SimpleItoa(oneof_desc->index());\n    // Oneof Constants\n    for (int j = 0; j < oneof_desc->field_count(); j++) {\n      const FieldDescriptor* field = oneof_desc->field(j);\n      vars[\"number\"] = SimpleItoa(field->number());\n      vars[\"cap_field_name\"] = ToUpper(field->name());\n      printer->Print(vars,\n        \"public static final int $cap_field_name$_FIELD_NUMBER = $number$;\\n\");\n    }\n    // oneofCase_ and oneof_\n    printer->Print(vars,\n      \"private int $oneof_name$Case_ = 0;\\n\"\n      \"private java.lang.Object $oneof_name$_;\\n\");\n    printer->Print(vars,\n      \"public int get$oneof_capitalized_name$Case() {\\n\"\n      \"  return this.$oneof_name$Case_;\\n\"\n      \"}\\n\");\n    // Oneof clear\n    printer->Print(vars,\n      \"public $message_name$ clear$oneof_capitalized_name$() {\\n\"\n      \"  this.$oneof_name$Case_ = 0;\\n\"\n      \"  this.$oneof_name$_ = null;\\n\"\n      \"  return this;\\n\"\n      \"}\\n\");\n  }\n\n  // Lazy initialization of otherwise static final fields can help prevent the\n  // class initializer from being generated. We want to prevent it because it\n  // stops ProGuard from inlining any methods in this class into call sites and\n  // therefore reducing the method count. However, extensions are best kept as\n  // public static final fields with initializers, so with their existence we\n  // won't bother with lazy initialization.\n  bool lazy_init = descriptor_->extension_count() == 0;\n\n  // Empty array\n  if (lazy_init) {\n    printer->Print(\n      \"\\n\"\n      \"private static volatile $classname$[] _emptyArray;\\n\"\n      \"public static $classname$[] emptyArray() {\\n\"\n      \"  // Lazily initializes the empty array\\n\"\n      \"  if (_emptyArray == null) {\\n\"\n      \"    synchronized (\\n\"\n      \"        com.google.protobuf.nano.InternalNano.LAZY_INIT_LOCK) {\\n\"\n      \"      if (_emptyArray == null) {\\n\"\n      \"        _emptyArray = new $classname$[0];\\n\"\n      \"      }\\n\"\n      \"    }\\n\"\n      \"  }\\n\"\n      \"  return _emptyArray;\\n\"\n      \"}\\n\",\n      \"classname\", descriptor_->name());\n  } else {\n    printer->Print(\n      \"\\n\"\n      \"private static final $classname$[] EMPTY_ARRAY = {};\\n\"\n      \"public static $classname$[] emptyArray() {\\n\"\n      \"  return EMPTY_ARRAY;\\n\"\n      \"}\\n\",\n      \"classname\", descriptor_->name());\n  }\n\n  // Integers for bit fields\n  int totalInts = (field_generators_.total_bits() + 31) / 32;\n  if (totalInts > 0) {\n    printer->Print(\"\\n\");\n    for (int i = 0; i < totalInts; i++) {\n      printer->Print(\"private int $bit_field_name$;\\n\",\n        \"bit_field_name\", GetBitFieldName(i));\n    }\n  }\n\n  // Fields and maybe their default values\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    printer->Print(\"\\n\");\n    PrintFieldComment(printer, descriptor_->field(i));\n    field_generators_.get(descriptor_->field(i)).GenerateMembers(\n        printer, lazy_init);\n  }\n\n  // Constructor, with lazy init code if needed\n  if (lazy_init && field_generators_.saved_defaults_needed()) {\n    printer->Print(\n      \"\\n\"\n      \"private static volatile boolean _classInitialized;\\n\"\n      \"\\n\"\n      \"public $classname$() {\\n\"\n      \"  // Lazily initializes the field defaults\\n\"\n      \"  if (!_classInitialized) {\\n\"\n      \"    synchronized (\\n\"\n      \"        com.google.protobuf.nano.InternalNano.LAZY_INIT_LOCK) {\\n\"\n      \"      if (!_classInitialized) {\\n\",\n      \"classname\", descriptor_->name());\n    printer->Indent();\n    printer->Indent();\n    printer->Indent();\n    printer->Indent();\n    for (int i = 0; i < descriptor_->field_count(); i++) {\n      field_generators_.get(descriptor_->field(i))\n          .GenerateInitSavedDefaultCode(printer);\n    }\n    printer->Outdent();\n    printer->Outdent();\n    printer->Outdent();\n    printer->Outdent();\n    printer->Print(\n      \"        _classInitialized = true;\\n\"\n      \"      }\\n\"\n      \"    }\\n\"\n      \"  }\\n\");\n    if (params_.generate_clear()) {\n      printer->Print(\"  clear();\\n\");\n    }\n    printer->Print(\"}\\n\");\n  } else {\n    printer->Print(\n      \"\\n\"\n      \"public $classname$() {\\n\",\n      \"classname\", descriptor_->name());\n    if (params_.generate_clear()) {\n      printer->Print(\"  clear();\\n\");\n    } else {\n      printer->Indent();\n      GenerateFieldInitializers(printer);\n      printer->Outdent();\n    }\n    printer->Print(\"}\\n\");\n  }\n\n  // Other methods in this class\n\n  GenerateClear(printer);\n\n  if (params_.generate_clone()) {\n    GenerateClone(printer);\n  }\n\n  if (params_.generate_equals()) {\n    GenerateEquals(printer);\n    GenerateHashCode(printer);\n  }\n\n  GenerateMessageSerializationMethods(printer);\n  GenerateMergeFromMethods(printer);\n  GenerateParseFromMethods(printer);\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\n// ===================================================================\n\nvoid MessageGenerator::\nGenerateMessageSerializationMethods(io::Printer* printer) {\n  // Rely on the parent implementations of writeTo() and getSerializedSize()\n  // if there are no fields to serialize in this message.\n  if (descriptor_->field_count() == 0) {\n    return;\n  }\n\n  scoped_array<const FieldDescriptor*> sorted_fields(\n    SortFieldsByNumber(descriptor_));\n\n  printer->Print(\n    \"\\n\"\n    \"@Override\\n\"\n    \"public void writeTo(com.google.protobuf.nano.CodedOutputByteBufferNano output)\\n\"\n    \"    throws java.io.IOException {\\n\");\n  printer->Indent();\n\n  // Output the fields in sorted order\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    GenerateSerializeOneField(printer, sorted_fields[i]);\n  }\n\n  // The parent implementation will write any unknown fields if necessary.\n  printer->Print(\n    \"super.writeTo(output);\\n\");\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n\n  // The parent implementation will get the serialized size for unknown\n  // fields if necessary.\n  printer->Print(\n    \"\\n\"\n    \"@Override\\n\"\n    \"protected int computeSerializedSize() {\\n\"\n    \"  int size = super.computeSerializedSize();\\n\");\n  printer->Indent();\n\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    field_generators_.get(sorted_fields[i]).GenerateSerializedSizeCode(printer);\n  }\n\n  printer->Outdent();\n  printer->Print(\n    \"  return size;\\n\"\n    \"}\\n\");\n}\n\nvoid MessageGenerator::GenerateMergeFromMethods(io::Printer* printer) {\n  scoped_array<const FieldDescriptor*> sorted_fields(\n    SortFieldsByNumber(descriptor_));\n\n  printer->Print(\n    \"\\n\"\n    \"@Override\\n\"\n    \"public $classname$ mergeFrom(\\n\"\n    \"        com.google.protobuf.nano.CodedInputByteBufferNano input)\\n\"\n    \"    throws java.io.IOException {\\n\",\n    \"classname\", descriptor_->name());\n\n  printer->Indent();\n  if (HasMapField(descriptor_)) {\n    printer->Print(\n      \"com.google.protobuf.nano.MapFactories.MapFactory mapFactory =\\n\"\n      \"  com.google.protobuf.nano.MapFactories.getMapFactory();\\n\");\n  }\n\n  printer->Print(\n    \"while (true) {\\n\");\n  printer->Indent();\n\n  printer->Print(\n    \"int tag = input.readTag();\\n\"\n    \"switch (tag) {\\n\");\n  printer->Indent();\n\n  printer->Print(\n    \"case 0:\\n\"          // zero signals EOF / limit reached\n    \"  return this;\\n\"\n    \"default: {\\n\");\n\n  printer->Indent();\n  if (params_.store_unknown_fields()) {\n    printer->Print(\n        \"if (!storeUnknownField(input, tag)) {\\n\"\n        \"  return this;\\n\"\n        \"}\\n\");\n  } else {\n    printer->Print(\n        \"if (!com.google.protobuf.nano.WireFormatNano.parseUnknownField(input, tag)) {\\n\"\n        \"  return this;\\n\"   // it's an endgroup tag\n        \"}\\n\");\n  }\n  printer->Print(\"break;\\n\");\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = sorted_fields[i];\n    uint32 tag = WireFormatLite::MakeTag(field->number(),\n      WireFormat::WireTypeForFieldType(field->type()));\n\n    printer->Print(\n      \"case $tag$: {\\n\",\n      \"tag\", SimpleItoa(tag));\n    printer->Indent();\n\n    field_generators_.get(field).GenerateMergingCode(printer);\n\n    printer->Outdent();\n    printer->Print(\n      \"  break;\\n\"\n      \"}\\n\");\n\n    if (field->is_packable()) {\n      // To make packed = true wire compatible, we generate parsing code from a\n      // packed version of this field regardless of field->options().packed().\n      uint32 packed_tag = WireFormatLite::MakeTag(field->number(),\n        WireFormatLite::WIRETYPE_LENGTH_DELIMITED);\n      printer->Print(\n        \"case $tag$: {\\n\",\n        \"tag\", SimpleItoa(packed_tag));\n      printer->Indent();\n\n      field_generators_.get(field).GenerateMergingCodeFromPacked(printer);\n\n      printer->Outdent();\n      printer->Print(\n        \"  break;\\n\"\n        \"}\\n\");\n    }\n  }\n\n  printer->Outdent();\n  printer->Outdent();\n  printer->Outdent();\n  printer->Print(\n    \"    }\\n\"     // switch (tag)\n    \"  }\\n\"       // while (true)\n    \"}\\n\");\n}\n\nvoid MessageGenerator::\nGenerateParseFromMethods(io::Printer* printer) {\n  // Note:  These are separate from GenerateMessageSerializationMethods()\n  //   because they need to be generated even for messages that are optimized\n  //   for code size.\n  printer->Print(\n    \"\\n\"\n    \"public static $classname$ parseFrom(byte[] data)\\n\"\n    \"    throws com.google.protobuf.nano.InvalidProtocolBufferNanoException {\\n\"\n    \"  return com.google.protobuf.nano.MessageNano.mergeFrom(new $classname$(), data);\\n\"\n    \"}\\n\"\n    \"\\n\"\n    \"public static $classname$ parseFrom(\\n\"\n    \"        com.google.protobuf.nano.CodedInputByteBufferNano input)\\n\"\n    \"    throws java.io.IOException {\\n\"\n    \"  return new $classname$().mergeFrom(input);\\n\"\n    \"}\\n\",\n    \"classname\", descriptor_->name());\n}\n\nvoid MessageGenerator::GenerateSerializeOneField(\n    io::Printer* printer, const FieldDescriptor* field) {\n  field_generators_.get(field).GenerateSerializationCode(printer);\n}\n\nvoid MessageGenerator::GenerateClear(io::Printer* printer) {\n  if (!params_.generate_clear()) {\n    return;\n  }\n  printer->Print(\n    \"\\n\"\n    \"public $classname$ clear() {\\n\",\n    \"classname\", descriptor_->name());\n  printer->Indent();\n\n  GenerateFieldInitializers(printer);\n\n  printer->Outdent();\n  printer->Print(\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid MessageGenerator::GenerateFieldInitializers(io::Printer* printer) {\n  // Clear bit fields.\n  int totalInts = (field_generators_.total_bits() + 31) / 32;\n  for (int i = 0; i < totalInts; i++) {\n    printer->Print(\"$bit_field_name$ = 0;\\n\",\n      \"bit_field_name\", GetBitFieldName(i));\n  }\n\n  // Call clear for all of the fields.\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n    field_generators_.get(field).GenerateClearCode(printer);\n  }\n\n  // Clear oneofs.\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    printer->Print(\n      \"clear$oneof_capitalized_name$();\\n\",\n      \"oneof_capitalized_name\", UnderscoresToCapitalizedCamelCase(\n          descriptor_->oneof_decl(i)));\n  }\n\n  // Clear unknown fields.\n  if (params_.store_unknown_fields()) {\n    printer->Print(\"unknownFieldData = null;\\n\");\n  }\n  printer->Print(\"cachedSize = -1;\\n\");\n}\n\nvoid MessageGenerator::GenerateClone(io::Printer* printer) {\n  printer->Print(\n    \"@Override\\n\"\n    \"public $classname$ clone() {\\n\",\n    \"classname\", descriptor_->name());\n  printer->Indent();\n\n  printer->Print(\n    \"$classname$ cloned;\\n\"\n    \"try {\\n\"\n    \"  cloned = ($classname$) super.clone();\\n\"\n    \"} catch (java.lang.CloneNotSupportedException e) {\\n\"\n    \"  throw new java.lang.AssertionError(e);\\n\"\n    \"}\\n\",\n    \"classname\", descriptor_->name());\n\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    field_generators_.get(descriptor_->field(i)).GenerateFixClonedCode(printer);\n  }\n\n  printer->Outdent();\n  printer->Print(\n    \"  return cloned;\\n\"\n    \"}\\n\"\n    \"\\n\");\n}\n\nvoid MessageGenerator::GenerateEquals(io::Printer* printer) {\n  // Don't override if there are no fields. We could generate an\n  // equals method that compares types, but often empty messages\n  // are used as namespaces.\n  if (descriptor_->field_count() == 0 && !params_.store_unknown_fields()) {\n    return;\n  }\n\n  printer->Print(\n    \"\\n\"\n    \"@Override\\n\"\n    \"public boolean equals(Object o) {\\n\");\n  printer->Indent();\n  printer->Print(\n    \"if (o == this) {\\n\"\n    \"  return true;\\n\"\n    \"}\\n\"\n    \"if (!(o instanceof $classname$)) {\\n\"\n    \"  return false;\\n\"\n    \"}\\n\"\n    \"$classname$ other = ($classname$) o;\\n\",\n    \"classname\", descriptor_->name());\n\n  // Checking oneof case before checking each oneof field.\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    const OneofDescriptor* oneof_desc = descriptor_->oneof_decl(i);\n    printer->Print(\n      \"if (this.$oneof_name$Case_ != other.$oneof_name$Case_) {\\n\"\n      \"  return false;\\n\"\n      \"}\\n\",\n      \"oneof_name\", UnderscoresToCamelCase(oneof_desc));\n  }\n\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n    field_generators_.get(field).GenerateEqualsCode(printer);\n  }\n\n  if (params_.store_unknown_fields()) {\n    printer->Print(\n      \"if (unknownFieldData == null || unknownFieldData.isEmpty()) {\\n\"\n      \"  return other.unknownFieldData == null || other.unknownFieldData.isEmpty();\\n\"\n      \"} else {\\n\"\n      \"  return unknownFieldData.equals(other.unknownFieldData);\\n\"\n      \"}\");\n  } else {\n    printer->Print(\n      \"return true;\\n\");\n  }\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid MessageGenerator::GenerateHashCode(io::Printer* printer) {\n  if (descriptor_->field_count() == 0 && !params_.store_unknown_fields()) {\n    return;\n  }\n\n  printer->Print(\n    \"\\n\"\n    \"@Override\\n\"\n    \"public int hashCode() {\\n\");\n  printer->Indent();\n\n  printer->Print(\"int result = 17;\\n\");\n  printer->Print(\"result = 31 * result + getClass().getName().hashCode();\\n\");\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n    field_generators_.get(field).GenerateHashCodeCode(printer);\n  }\n\n  if (params_.store_unknown_fields()) {\n    printer->Print(\n      \"result = 31 * result + \\n\"\n      \"  (unknownFieldData == null || unknownFieldData.isEmpty() ? 0 : \\n\"\n      \"  unknownFieldData.hashCode());\\n\");\n  }\n\n  printer->Print(\"return result;\\n\");\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\n// ===================================================================\n\n}  // namespace javanano\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_message.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_MESSAGE_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVANANO_MESSAGE_H__\n\n#include <string>\n#include <google/protobuf/compiler/javanano/javanano_helpers.h>\n#include <google/protobuf/compiler/javanano/javanano_field.h>\n#include <google/protobuf/compiler/javanano/javanano_params.h>\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace io {\n    class Printer;             // printer.h\n  }\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\nclass MessageGenerator {\n public:\n  explicit MessageGenerator(const Descriptor* descriptor, const Params& params);\n  ~MessageGenerator();\n\n  // All static variables have to be declared at the top-level of the file\n  // so that we can control initialization order, which is important for\n  // DescriptorProto bootstrapping to work.\n  void GenerateStaticVariables(io::Printer* printer);\n\n  // Output code which initializes the static variables generated by\n  // GenerateStaticVariables().\n  void GenerateStaticVariableInitializers(io::Printer* printer);\n\n  // Generate the class itself.\n  void Generate(io::Printer* printer);\n\n private:\n  void GenerateMessageSerializationMethods(io::Printer* printer);\n  void GenerateMergeFromMethods(io::Printer* printer);\n  void GenerateParseFromMethods(io::Printer* printer);\n  void GenerateSerializeOneField(io::Printer* printer,\n                                 const FieldDescriptor* field);\n\n  void GenerateClear(io::Printer* printer);\n  void GenerateFieldInitializers(io::Printer* printer);\n  void GenerateEquals(io::Printer* printer);\n  void GenerateHashCode(io::Printer* printer);\n  void GenerateClone(io::Printer* printer);\n\n  const Params& params_;\n  const Descriptor* descriptor_;\n  FieldGeneratorMap field_generators_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);\n};\n\n}  // namespace javanano\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVANANO_MESSAGE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_message_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/compiler/javanano/javanano_message_field.h>\n#include <google/protobuf/compiler/javanano/javanano_helpers.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\nusing internal::WireFormat;\nusing internal::WireFormatLite;\n\nnamespace {\n\n// TODO(kenton):  Factor out a \"SetCommonFieldVariables()\" to get rid of\n//   repeat code between this and the other field types.\nvoid SetMessageVariables(const Params& params,\n    const FieldDescriptor* descriptor, map<string, string>* variables) {\n  (*variables)[\"name\"] =\n    RenameJavaKeywords(UnderscoresToCamelCase(descriptor));\n  (*variables)[\"capitalized_name\"] =\n    RenameJavaKeywords(UnderscoresToCapitalizedCamelCase(descriptor));\n  (*variables)[\"number\"] = SimpleItoa(descriptor->number());\n  (*variables)[\"type\"] = ClassName(params, descriptor->message_type());\n  (*variables)[\"group_or_message\"] =\n    (descriptor->type() == FieldDescriptor::TYPE_GROUP) ?\n    \"Group\" : \"Message\";\n  (*variables)[\"message_name\"] = descriptor->containing_type()->name();\n  //(*variables)[\"message_type\"] = descriptor->message_type()->name();\n  (*variables)[\"tag\"] = SimpleItoa(WireFormat::MakeTag(descriptor));\n}\n\n}  // namespace\n\n// ===================================================================\n\nMessageFieldGenerator::\nMessageFieldGenerator(const FieldDescriptor* descriptor, const Params& params)\n  : FieldGenerator(params), descriptor_(descriptor) {\n  SetMessageVariables(params, descriptor, &variables_);\n}\n\nMessageFieldGenerator::~MessageFieldGenerator() {}\n\nvoid MessageFieldGenerator::\nGenerateMembers(io::Printer* printer, bool /* unused lazy_init */) const {\n  printer->Print(variables_,\n    \"public $type$ $name$;\\n\");\n}\n\nvoid MessageFieldGenerator::\nGenerateClearCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$ = null;\\n\");\n}\n\nvoid MessageFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (this.$name$ == null) {\\n\"\n    \"  this.$name$ = new $type$();\\n\"\n    \"}\\n\");\n\n  if (descriptor_->type() == FieldDescriptor::TYPE_GROUP) {\n    printer->Print(variables_,\n      \"input.readGroup(this.$name$, $number$);\\n\");\n  } else {\n    printer->Print(variables_,\n      \"input.readMessage(this.$name$);\\n\");\n  }\n}\n\nvoid MessageFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (this.$name$ != null) {\\n\"\n    \"  output.write$group_or_message$($number$, this.$name$);\\n\"\n    \"}\\n\");\n}\n\nvoid MessageFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (this.$name$ != null) {\\n\"\n    \"  size += com.google.protobuf.nano.CodedOutputByteBufferNano\\n\"\n    \"    .compute$group_or_message$Size($number$, this.$name$);\\n\"\n    \"}\\n\");\n}\n\nvoid MessageFieldGenerator::\nGenerateFixClonedCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (this.$name$ != null) {\\n\"\n    \"  cloned.$name$ = this.$name$.clone();\\n\"\n    \"}\\n\");\n}\n\nvoid MessageFieldGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (this.$name$ == null) { \\n\"\n    \"  if (other.$name$ != null) {\\n\"\n    \"    return false;\\n\"\n    \"  }\\n\"\n    \"} else {\\n\"\n    \"  if (!this.$name$.equals(other.$name$)) {\\n\"\n    \"    return false;\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n}\n\nvoid MessageFieldGenerator::\nGenerateHashCodeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"result = 31 * result +\\n\"\n    \"    (this.$name$ == null ? 0 : this.$name$.hashCode());\\n\");\n}\n// ===================================================================\n\nMessageOneofFieldGenerator::MessageOneofFieldGenerator(\n    const FieldDescriptor* descriptor, const Params& params)\n    : FieldGenerator(params), descriptor_(descriptor) {\n    SetMessageVariables(params, descriptor, &variables_);\n    SetCommonOneofVariables(descriptor, &variables_);\n}\n\nMessageOneofFieldGenerator::~MessageOneofFieldGenerator() {}\n\nvoid MessageOneofFieldGenerator::\nGenerateMembers(io::Printer* printer, bool /* unused lazy_init */) const {\n  printer->Print(variables_,\n    \"public boolean has$capitalized_name$() {\\n\"\n    \"  return $has_oneof_case$;\\n\"\n    \"}\\n\"\n    \"public $type$ get$capitalized_name$() {\\n\"\n    \"  if ($has_oneof_case$) {\\n\"\n    \"    return ($type$) this.$oneof_name$_;\\n\"\n    \"  }\\n\"\n    \"  return null;\\n\"\n    \"}\\n\"\n    \"public $message_name$ set$capitalized_name$($type$ value) {\\n\"\n    \"  if (value == null) { throw new java.lang.NullPointerException(); }\\n\"\n    \"  $set_oneof_case$;\\n\"\n    \"  this.$oneof_name$_ = value;\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid MessageOneofFieldGenerator::\nGenerateClearCode(io::Printer* printer) const {\n  // No clear method for oneof fields.\n}\n\nvoid MessageOneofFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (!($has_oneof_case$)) {\\n\"\n    \"  this.$oneof_name$_ = new $type$();\\n\"\n    \"}\\n\"\n    \"input.readMessage(\\n\"\n    \"    (com.google.protobuf.nano.MessageNano) this.$oneof_name$_);\\n\"\n    \"$set_oneof_case$;\\n\");\n}\n\nvoid MessageOneofFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case$) {\\n\"\n    \"  output.writeMessage($number$,\\n\"\n    \"      (com.google.protobuf.nano.MessageNano) this.$oneof_name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid MessageOneofFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case$) {\\n\"\n    \"  size += com.google.protobuf.nano.CodedOutputByteBufferNano\\n\"\n    \"    .computeMessageSize($number$,\\n\"\n    \"        (com.google.protobuf.nano.MessageNano) this.$oneof_name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid MessageOneofFieldGenerator::\nGenerateFixClonedCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (this.$oneof_name$ != null) {\\n\"\n    \"  cloned.$oneof_name$ = this.$oneof_name$.clone();\\n\"\n    \"}\\n\");\n}\n\nvoid MessageOneofFieldGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  GenerateOneofFieldEquals(descriptor_, variables_, printer);\n}\n\nvoid MessageOneofFieldGenerator::\nGenerateHashCodeCode(io::Printer* printer) const {\n  GenerateOneofFieldHashCode(descriptor_, variables_, printer);\n}\n\n// ===================================================================\n\nRepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator(\n    const FieldDescriptor* descriptor, const Params& params)\n    : FieldGenerator(params), descriptor_(descriptor) {\n  SetMessageVariables(params, descriptor, &variables_);\n}\n\nRepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() {}\n\nvoid RepeatedMessageFieldGenerator::\nGenerateMembers(io::Printer* printer, bool /* unused lazy_init */) const {\n  printer->Print(variables_,\n    \"public $type$[] $name$;\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::\nGenerateClearCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$ = $type$.emptyArray();\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  // First, figure out the length of the array, then parse.\n  printer->Print(variables_,\n    \"int arrayLength = com.google.protobuf.nano.WireFormatNano\\n\"\n    \"    .getRepeatedFieldArrayLength(input, $tag$);\\n\"\n    \"int i = this.$name$ == null ? 0 : this.$name$.length;\\n\"\n    \"$type$[] newArray =\\n\"\n    \"    new $type$[i + arrayLength];\\n\"\n    \"if (i != 0) {\\n\"\n    \"  java.lang.System.arraycopy(this.$name$, 0, newArray, 0, i);\\n\"\n    \"}\\n\"\n    \"for (; i < newArray.length - 1; i++) {\\n\"\n    \"  newArray[i] = new $type$();\\n\");\n\n  if (descriptor_->type() == FieldDescriptor::TYPE_GROUP) {\n    printer->Print(variables_,\n      \"  input.readGroup(newArray[i], $number$);\\n\");\n  } else {\n    printer->Print(variables_,\n      \"  input.readMessage(newArray[i]);\\n\");\n  }\n\n  printer->Print(variables_,\n    \"  input.readTag();\\n\"\n    \"}\\n\"\n    \"// Last one without readTag.\\n\"\n    \"newArray[i] = new $type$();\\n\");\n\n  if (descriptor_->type() == FieldDescriptor::TYPE_GROUP) {\n    printer->Print(variables_,\n      \"input.readGroup(newArray[i], $number$);\\n\");\n  } else {\n    printer->Print(variables_,\n      \"input.readMessage(newArray[i]);\\n\");\n  }\n\n  printer->Print(variables_,\n    \"this.$name$ = newArray;\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (this.$name$ != null && this.$name$.length > 0) {\\n\"\n    \"  for (int i = 0; i < this.$name$.length; i++) {\\n\"\n    \"    $type$ element = this.$name$[i];\\n\"\n    \"    if (element != null) {\\n\"\n    \"      output.write$group_or_message$($number$, element);\\n\"\n    \"    }\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (this.$name$ != null && this.$name$.length > 0) {\\n\"\n    \"  for (int i = 0; i < this.$name$.length; i++) {\\n\"\n    \"    $type$ element = this.$name$[i];\\n\"\n    \"    if (element != null) {\\n\"\n    \"      size += com.google.protobuf.nano.CodedOutputByteBufferNano\\n\"\n    \"        .compute$group_or_message$Size($number$, element);\\n\"\n    \"    }\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::\nGenerateFixClonedCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (this.$name$ != null && this.$name$.length > 0) {\\n\"\n    \"  cloned.$name$ = new $type$[this.$name$.length];\\n\"\n    \"  for (int i = 0; i < this.$name$.length; i++) {\\n\"\n    \"    if (this.$name$[i] != null) {\\n\"\n    \"      cloned.$name$[i] = this.$name$[i].clone();\\n\"\n    \"    }\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (!com.google.protobuf.nano.InternalNano.equals(\\n\"\n    \"    this.$name$, other.$name$)) {\\n\"\n    \"  return false;\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedMessageFieldGenerator::\nGenerateHashCodeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"result = 31 * result\\n\"\n    \"    + com.google.protobuf.nano.InternalNano.hashCode(this.$name$);\\n\");\n}\n\n}  // namespace javanano\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_message_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_MESSAGE_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVANANO_MESSAGE_FIELD_H__\n\n#include <map>\n#include <string>\n#include <google/protobuf/compiler/javanano/javanano_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\nclass MessageFieldGenerator : public FieldGenerator {\n public:\n  explicit MessageFieldGenerator(\n      const FieldDescriptor* descriptor, const Params& params);\n  ~MessageFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  void GenerateMembers(io::Printer* printer, bool lazy_init) const;\n  void GenerateClearCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCodeCode(io::Printer* printer) const;\n  void GenerateFixClonedCode(io::Printer* printer) const;\n\n private:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator);\n};\n\nclass MessageOneofFieldGenerator : public FieldGenerator {\n public:\n  explicit MessageOneofFieldGenerator(const FieldDescriptor* descriptor,\n                                      const Params& params);\n  ~MessageOneofFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  void GenerateMembers(io::Printer* printer, bool lazy_init) const;\n  void GenerateClearCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCodeCode(io::Printer* printer) const;\n  void GenerateFixClonedCode(io::Printer* printer) const;\n\n private:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageOneofFieldGenerator);\n};\n\nclass RepeatedMessageFieldGenerator : public FieldGenerator {\n public:\n  explicit RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor,\n        const Params& params);\n  ~RepeatedMessageFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  void GenerateMembers(io::Printer* printer, bool lazy_init) const;\n  void GenerateClearCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCodeCode(io::Printer* printer) const;\n  void GenerateFixClonedCode(io::Printer* printer) const;\n\n private:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator);\n};\n\n}  // namespace javanano\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVANANO_MESSAGE_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_params.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2010 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: wink@google.com (Wink Saville)\n\n#ifndef PROTOBUF_COMPILER_JAVANANO_JAVANANO_PARAMS_H_\n#define PROTOBUF_COMPILER_JAVANANO_JAVANANO_PARAMS_H_\n\n#include <map>\n#include <set>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\nenum eMultipleFiles { JAVANANO_MUL_UNSET, JAVANANO_MUL_FALSE, JAVANANO_MUL_TRUE };\n\n// Parameters for used by the generators\nclass Params {\n public:\n  typedef map<string, string> NameMap;\n  typedef set<string> NameSet;\n private:\n  string empty_;\n  string base_name_;\n  eMultipleFiles override_java_multiple_files_;\n  bool store_unknown_fields_;\n  NameMap java_packages_;\n  NameMap java_outer_classnames_;\n  NameSet java_multiple_files_;\n  bool generate_has_;\n  bool java_enum_style_;\n  bool optional_field_accessors_;\n  bool use_reference_types_for_primitives_;\n  bool generate_equals_;\n  bool ignore_services_;\n  bool parcelable_messages_;\n  bool reftypes_primitive_enums_;\n  bool generate_clear_;\n  bool generate_clone_;\n  bool generate_intdefs_;\n\n public:\n  Params(const string & base_name) :\n    empty_(\"\"),\n    base_name_(base_name),\n    override_java_multiple_files_(JAVANANO_MUL_UNSET),\n    store_unknown_fields_(false),\n    generate_has_(false),\n    java_enum_style_(false),\n    optional_field_accessors_(false),\n    use_reference_types_for_primitives_(false),\n    generate_equals_(false),\n    ignore_services_(false),\n    parcelable_messages_(false),\n    reftypes_primitive_enums_(false),\n    generate_clear_(true),\n    generate_clone_(false),\n    generate_intdefs_(false) {\n  }\n\n  const string& base_name() const {\n    return base_name_;\n  }\n\n  bool has_java_package(const string& file_name) const {\n    return java_packages_.find(file_name)\n                        != java_packages_.end();\n  }\n  void set_java_package(const string& file_name,\n      const string& java_package) {\n    java_packages_[file_name] = java_package;\n  }\n  const string& java_package(const string& file_name) const {\n    NameMap::const_iterator itr;\n\n    itr = java_packages_.find(file_name);\n    if  (itr == java_packages_.end()) {\n      return empty_;\n    } else {\n      return itr->second;\n    }\n  }\n  const NameMap& java_packages() {\n    return java_packages_;\n  }\n\n  bool has_java_outer_classname(const string& file_name) const {\n    return java_outer_classnames_.find(file_name)\n                        != java_outer_classnames_.end();\n  }\n  void set_java_outer_classname(const string& file_name,\n      const string& java_outer_classname) {\n    java_outer_classnames_[file_name] = java_outer_classname;\n  }\n  const string& java_outer_classname(const string& file_name) const {\n    NameMap::const_iterator itr;\n\n    itr = java_outer_classnames_.find(file_name);\n    if  (itr == java_outer_classnames_.end()) {\n      return empty_;\n    } else {\n      return itr->second;\n    }\n  }\n  const NameMap& java_outer_classnames() {\n    return java_outer_classnames_;\n  }\n\n  void set_override_java_multiple_files(bool java_multiple_files) {\n    if (java_multiple_files) {\n      override_java_multiple_files_ = JAVANANO_MUL_TRUE;\n    } else {\n      override_java_multiple_files_ = JAVANANO_MUL_FALSE;\n    }\n  }\n  void clear_override_java_multiple_files() {\n    override_java_multiple_files_ = JAVANANO_MUL_UNSET;\n  }\n\n  void set_java_multiple_files(const string& file_name, bool value) {\n    if (value) {\n      java_multiple_files_.insert(file_name);\n    } else {\n      java_multiple_files_.erase(file_name);\n    }\n  }\n  bool java_multiple_files(const string& file_name) const {\n    switch (override_java_multiple_files_) {\n      case JAVANANO_MUL_FALSE:\n        return false;\n      case JAVANANO_MUL_TRUE:\n        return true;\n      default:\n        return java_multiple_files_.find(file_name)\n                != java_multiple_files_.end();\n    }\n  }\n\n  void set_store_unknown_fields(bool value) {\n    store_unknown_fields_ = value;\n  }\n  bool store_unknown_fields() const {\n    return store_unknown_fields_;\n  }\n\n  void set_generate_has(bool value) {\n    generate_has_ = value;\n  }\n  bool generate_has() const {\n    return generate_has_;\n  }\n\n  void set_java_enum_style(bool value) {\n    java_enum_style_ = value;\n  }\n  bool java_enum_style() const {\n    return java_enum_style_;\n  }\n\n  void set_optional_field_accessors(bool value) {\n    optional_field_accessors_ = value;\n  }\n  bool optional_field_accessors() const {\n    return optional_field_accessors_;\n  }\n\n  void set_use_reference_types_for_primitives(bool value) {\n    use_reference_types_for_primitives_ = value;\n  }\n  bool use_reference_types_for_primitives() const {\n    return use_reference_types_for_primitives_;\n  }\n\n  void set_generate_equals(bool value) {\n    generate_equals_ = value;\n  }\n  bool generate_equals() const {\n    return generate_equals_;\n  }\n\n  void set_ignore_services(bool value) {\n    ignore_services_ = value;\n  }\n  bool ignore_services() const {\n    return ignore_services_;\n  }\n\n  void set_parcelable_messages(bool value) {\n    parcelable_messages_ = value;\n  }\n  bool parcelable_messages() const {\n    return parcelable_messages_;\n  }\n\n  void set_reftypes_primitive_enums(bool value) {\n    reftypes_primitive_enums_ = value;\n  }\n  bool reftypes_primitive_enums() const {\n    return reftypes_primitive_enums_;\n  }\n\n  void set_generate_clear(bool value) {\n    generate_clear_ = value;\n  }\n  bool generate_clear() const {\n    return generate_clear_;\n  }\n\n  void set_generate_clone(bool value) {\n    generate_clone_ = value;\n  }\n  bool generate_clone() const {\n    return generate_clone_;\n  }\n\n  void set_generate_intdefs(bool value) {\n    generate_intdefs_ = value;\n  }\n  bool generate_intdefs() const {\n    return generate_intdefs_;\n  }\n};\n\n}  // namespace javanano\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n#endif  // PROTOBUF_COMPILER_JAVANANO_JAVANANO_PARAMS_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <map>\n#include <math.h>\n#include <string>\n\n#include <google/protobuf/compiler/javanano/javanano_primitive_field.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/compiler/javanano/javanano_helpers.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\nusing internal::WireFormat;\nusing internal::WireFormatLite;\n\nnamespace {\n\nbool IsReferenceType(JavaType type) {\n  switch (type) {\n    case JAVATYPE_INT    : return false;\n    case JAVATYPE_LONG   : return false;\n    case JAVATYPE_FLOAT  : return false;\n    case JAVATYPE_DOUBLE : return false;\n    case JAVATYPE_BOOLEAN: return false;\n    case JAVATYPE_STRING : return true;\n    case JAVATYPE_BYTES  : return true;\n    case JAVATYPE_ENUM   : return false;\n    case JAVATYPE_MESSAGE: return true;\n\n    // No default because we want the compiler to complain if any new\n    // JavaTypes are added.\n  }\n\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return false;\n}\n\nbool IsArrayType(JavaType type) {\n  switch (type) {\n    case JAVATYPE_INT    : return false;\n    case JAVATYPE_LONG   : return false;\n    case JAVATYPE_FLOAT  : return false;\n    case JAVATYPE_DOUBLE : return false;\n    case JAVATYPE_BOOLEAN: return false;\n    case JAVATYPE_STRING : return false;\n    case JAVATYPE_BYTES  : return true;\n    case JAVATYPE_ENUM   : return false;\n    case JAVATYPE_MESSAGE: return false;\n\n    // No default because we want the compiler to complain if any new\n    // JavaTypes are added.\n  }\n\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return false;\n}\n\nconst char* GetCapitalizedType(const FieldDescriptor* field) {\n  switch (field->type()) {\n    case FieldDescriptor::TYPE_INT32   : return \"Int32\"   ;\n    case FieldDescriptor::TYPE_UINT32  : return \"UInt32\"  ;\n    case FieldDescriptor::TYPE_SINT32  : return \"SInt32\"  ;\n    case FieldDescriptor::TYPE_FIXED32 : return \"Fixed32\" ;\n    case FieldDescriptor::TYPE_SFIXED32: return \"SFixed32\";\n    case FieldDescriptor::TYPE_INT64   : return \"Int64\"   ;\n    case FieldDescriptor::TYPE_UINT64  : return \"UInt64\"  ;\n    case FieldDescriptor::TYPE_SINT64  : return \"SInt64\"  ;\n    case FieldDescriptor::TYPE_FIXED64 : return \"Fixed64\" ;\n    case FieldDescriptor::TYPE_SFIXED64: return \"SFixed64\";\n    case FieldDescriptor::TYPE_FLOAT   : return \"Float\"   ;\n    case FieldDescriptor::TYPE_DOUBLE  : return \"Double\"  ;\n    case FieldDescriptor::TYPE_BOOL    : return \"Bool\"    ;\n    case FieldDescriptor::TYPE_STRING  : return \"String\"  ;\n    case FieldDescriptor::TYPE_BYTES   : return \"Bytes\"   ;\n    case FieldDescriptor::TYPE_ENUM    : return \"Enum\"    ;\n    case FieldDescriptor::TYPE_GROUP   : return \"Group\"   ;\n    case FieldDescriptor::TYPE_MESSAGE : return \"Message\" ;\n\n    // No default because we want the compiler to complain if any new\n    // types are added.\n  }\n\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return NULL;\n}\n\n// For encodings with fixed sizes, returns that size in bytes.  Otherwise\n// returns -1.\nint FixedSize(FieldDescriptor::Type type) {\n  switch (type) {\n    case FieldDescriptor::TYPE_INT32   : return -1;\n    case FieldDescriptor::TYPE_INT64   : return -1;\n    case FieldDescriptor::TYPE_UINT32  : return -1;\n    case FieldDescriptor::TYPE_UINT64  : return -1;\n    case FieldDescriptor::TYPE_SINT32  : return -1;\n    case FieldDescriptor::TYPE_SINT64  : return -1;\n    case FieldDescriptor::TYPE_FIXED32 : return WireFormatLite::kFixed32Size;\n    case FieldDescriptor::TYPE_FIXED64 : return WireFormatLite::kFixed64Size;\n    case FieldDescriptor::TYPE_SFIXED32: return WireFormatLite::kSFixed32Size;\n    case FieldDescriptor::TYPE_SFIXED64: return WireFormatLite::kSFixed64Size;\n    case FieldDescriptor::TYPE_FLOAT   : return WireFormatLite::kFloatSize;\n    case FieldDescriptor::TYPE_DOUBLE  : return WireFormatLite::kDoubleSize;\n\n    case FieldDescriptor::TYPE_BOOL    : return WireFormatLite::kBoolSize;\n    case FieldDescriptor::TYPE_ENUM    : return -1;\n\n    case FieldDescriptor::TYPE_STRING  : return -1;\n    case FieldDescriptor::TYPE_BYTES   : return -1;\n    case FieldDescriptor::TYPE_GROUP   : return -1;\n    case FieldDescriptor::TYPE_MESSAGE : return -1;\n\n    // No default because we want the compiler to complain if any new\n    // types are added.\n  }\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return -1;\n}\n\nbool AllAscii(const string& text) {\n  for (int i = 0; i < text.size(); i++) {\n    if ((text[i] & 0x80) != 0) {\n      return false;\n    }\n  }\n  return true;\n}\n\n\nvoid SetPrimitiveVariables(const FieldDescriptor* descriptor, const Params params,\n                           map<string, string>* variables) {\n  (*variables)[\"name\"] =\n    RenameJavaKeywords(UnderscoresToCamelCase(descriptor));\n  (*variables)[\"capitalized_name\"] =\n    RenameJavaKeywords(UnderscoresToCapitalizedCamelCase(descriptor));\n  (*variables)[\"number\"] = SimpleItoa(descriptor->number());\n  if (params.use_reference_types_for_primitives()\n      && !descriptor->is_repeated()) {\n    (*variables)[\"type\"] = BoxedPrimitiveTypeName(GetJavaType(descriptor));\n  } else {\n    (*variables)[\"type\"] = PrimitiveTypeName(GetJavaType(descriptor));\n  }\n  // Deals with defaults. For C++-string types (string and bytes),\n  // we might need to have the generated code do the unicode decoding\n  // (see comments in InternalNano.java for gory details.). We would\n  // like to do this once into a static field and re-use that from\n  // then on.\n  if (descriptor->cpp_type() == FieldDescriptor::CPPTYPE_STRING &&\n      !descriptor->default_value_string().empty() &&\n      !params.use_reference_types_for_primitives()) {\n    if (descriptor->type() == FieldDescriptor::TYPE_BYTES) {\n      (*variables)[\"default\"] = DefaultValue(params, descriptor);\n      (*variables)[\"default_constant\"] = FieldDefaultConstantName(descriptor);\n      (*variables)[\"default_constant_value\"] = strings::Substitute(\n          \"com.google.protobuf.nano.InternalNano.bytesDefaultValue(\\\"$0\\\")\",\n          CEscape(descriptor->default_value_string()));\n      (*variables)[\"default_copy_if_needed\"] =\n          (*variables)[\"default\"] + \".clone()\";\n    } else if (AllAscii(descriptor->default_value_string())) {\n      // All chars are ASCII.  In this case directly referencing a\n      // CEscape()'d string literal works fine.\n      (*variables)[\"default\"] =\n          \"\\\"\" + CEscape(descriptor->default_value_string()) + \"\\\"\";\n      (*variables)[\"default_copy_if_needed\"] = (*variables)[\"default\"];\n    } else {\n      // Strings where some chars are non-ASCII. We need to save the\n      // default value.\n      (*variables)[\"default\"] = DefaultValue(params, descriptor);\n      (*variables)[\"default_constant\"] = FieldDefaultConstantName(descriptor);\n      (*variables)[\"default_constant_value\"] = strings::Substitute(\n          \"com.google.protobuf.nano.InternalNano.stringDefaultValue(\\\"$0\\\")\",\n          CEscape(descriptor->default_value_string()));\n      (*variables)[\"default_copy_if_needed\"] = (*variables)[\"default\"];\n    }\n  } else {\n    // Non-string, non-bytes field. Defaults are literals.\n    (*variables)[\"default\"] = DefaultValue(params, descriptor);\n    (*variables)[\"default_copy_if_needed\"] = (*variables)[\"default\"];\n  }\n  (*variables)[\"boxed_type\"] = BoxedPrimitiveTypeName(GetJavaType(descriptor));\n  (*variables)[\"capitalized_type\"] = GetCapitalizedType(descriptor);\n  (*variables)[\"tag\"] = SimpleItoa(WireFormat::MakeTag(descriptor));\n  (*variables)[\"tag_size\"] = SimpleItoa(\n      WireFormat::TagSize(descriptor->number(), descriptor->type()));\n  (*variables)[\"non_packed_tag\"] = SimpleItoa(\n      internal::WireFormatLite::MakeTag(descriptor->number(),\n          internal::WireFormat::WireTypeForFieldType(descriptor->type())));\n  int fixed_size = FixedSize(descriptor->type());\n  if (fixed_size != -1) {\n    (*variables)[\"fixed_size\"] = SimpleItoa(fixed_size);\n  }\n  (*variables)[\"message_name\"] = descriptor->containing_type()->name();\n  (*variables)[\"empty_array_name\"] = EmptyArrayName(params, descriptor);\n}\n}  // namespace\n\n// ===================================================================\n\nPrimitiveFieldGenerator::\nPrimitiveFieldGenerator(const FieldDescriptor* descriptor, const Params& params)\n  : FieldGenerator(params), descriptor_(descriptor) {\n  SetPrimitiveVariables(descriptor, params, &variables_);\n}\n\nPrimitiveFieldGenerator::~PrimitiveFieldGenerator() {}\n\nbool PrimitiveFieldGenerator::SavedDefaultNeeded() const {\n  return variables_.find(\"default_constant\") != variables_.end();\n}\n\nvoid PrimitiveFieldGenerator::GenerateInitSavedDefaultCode(io::Printer* printer) const {\n  if (variables_.find(\"default_constant\") != variables_.end()) {\n    printer->Print(variables_,\n      \"$default_constant$ = $default_constant_value$;\\n\");\n  }\n}\n\nvoid PrimitiveFieldGenerator::\nGenerateMembers(io::Printer* printer, bool lazy_init) const {\n  if (variables_.find(\"default_constant\") != variables_.end()) {\n    // Those primitive types that need a saved default.\n    if (lazy_init) {\n      printer->Print(variables_,\n        \"private static $type$ $default_constant$;\\n\");\n    } else {\n      printer->Print(variables_,\n        \"private static final $type$ $default_constant$ =\\n\"\n        \"    $default_constant_value$;\\n\");\n    }\n  }\n\n  printer->Print(variables_,\n    \"public $type$ $name$;\\n\");\n\n  if (params_.generate_has()) {\n    printer->Print(variables_,\n      \"public boolean has$capitalized_name$;\\n\");\n  }\n}\n\nvoid PrimitiveFieldGenerator::\nGenerateClearCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$ = $default_copy_if_needed$;\\n\");\n\n  if (params_.generate_has()) {\n    printer->Print(variables_,\n      \"has$capitalized_name$ = false;\\n\");\n  }\n}\n\nvoid PrimitiveFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"this.$name$ = input.read$capitalized_type$();\\n\");\n\n  if (params_.generate_has()) {\n    printer->Print(variables_,\n      \"has$capitalized_name$ = true;\\n\");\n  }\n}\n\nvoid PrimitiveFieldGenerator::\nGenerateSerializationConditional(io::Printer* printer) const {\n  if (params_.use_reference_types_for_primitives()) {\n    // For reference type mode, serialize based on equality\n    // to null.\n    printer->Print(variables_,\n      \"if (this.$name$ != null) {\\n\");\n    return;\n  }\n  if (params_.generate_has()) {\n    printer->Print(variables_,\n      \"if (has$capitalized_name$ || \");\n  } else {\n    printer->Print(variables_,\n      \"if (\");\n  }\n  JavaType java_type = GetJavaType(descriptor_);\n  if (IsArrayType(java_type)) {\n    printer->Print(variables_,\n      \"!java.util.Arrays.equals(this.$name$, $default$)) {\\n\");\n  } else if (IsReferenceType(java_type)) {\n    printer->Print(variables_,\n      \"!this.$name$.equals($default$)) {\\n\");\n  } else if (java_type == JAVATYPE_FLOAT) {\n    printer->Print(variables_,\n      \"java.lang.Float.floatToIntBits(this.$name$)\\n\"\n      \"    != java.lang.Float.floatToIntBits($default$)) {\\n\");\n  } else if (java_type == JAVATYPE_DOUBLE) {\n    printer->Print(variables_,\n      \"java.lang.Double.doubleToLongBits(this.$name$)\\n\"\n      \"    != java.lang.Double.doubleToLongBits($default$)) {\\n\");\n  } else {\n    printer->Print(variables_,\n      \"this.$name$ != $default$) {\\n\");\n  }\n}\n\nvoid PrimitiveFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  if (descriptor_->is_required() && !params_.generate_has()) {\n    // Always serialize a required field if we don't have the 'has' signal.\n    printer->Print(variables_,\n      \"output.write$capitalized_type$($number$, this.$name$);\\n\");\n  } else {\n    GenerateSerializationConditional(printer);\n    printer->Print(variables_,\n      \"  output.write$capitalized_type$($number$, this.$name$);\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid PrimitiveFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  if (descriptor_->is_required() && !params_.generate_has()) {\n    printer->Print(variables_,\n      \"size += com.google.protobuf.nano.CodedOutputByteBufferNano\\n\"\n      \"    .compute$capitalized_type$Size($number$, this.$name$);\\n\");\n  } else {\n    GenerateSerializationConditional(printer);\n    printer->Print(variables_,\n      \"  size += com.google.protobuf.nano.CodedOutputByteBufferNano\\n\"\n      \"      .compute$capitalized_type$Size($number$, this.$name$);\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid RepeatedPrimitiveFieldGenerator::\nGenerateFixClonedCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (this.$name$ != null && this.$name$.length > 0) {\\n\"\n    \"  cloned.$name$ = this.$name$.clone();\\n\"\n    \"}\\n\");\n}\n\nvoid PrimitiveFieldGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  // We define equality as serialized form equality. If generate_has(),\n  // then if the field value equals the default value in both messages,\n  // but one's 'has' field is set and the other's is not, the serialized\n  // forms are different and we should return false.\n  JavaType java_type = GetJavaType(descriptor_);\n  if (java_type == JAVATYPE_BYTES) {\n    printer->Print(variables_,\n      \"if (!java.util.Arrays.equals(this.$name$, other.$name$)\");\n    if (params_.generate_has()) {\n      printer->Print(variables_,\n        \"\\n\"\n        \"    || (java.util.Arrays.equals(this.$name$, $default$)\\n\"\n        \"        && this.has$capitalized_name$ != other.has$capitalized_name$)\");\n    }\n    printer->Print(\") {\\n\"\n      \"  return false;\\n\"\n      \"}\\n\");\n  } else if (java_type == JAVATYPE_STRING\n      || params_.use_reference_types_for_primitives()) {\n    printer->Print(variables_,\n      \"if (this.$name$ == null) {\\n\"\n      \"  if (other.$name$ != null) {\\n\"\n      \"    return false;\\n\"\n      \"  }\\n\"\n      \"} else if (!this.$name$.equals(other.$name$)\");\n    if (params_.generate_has()) {\n      printer->Print(variables_,\n        \"\\n\"\n        \"    || (this.$name$.equals($default$)\\n\"\n        \"        && this.has$capitalized_name$ != other.has$capitalized_name$)\");\n    }\n    printer->Print(\") {\\n\"\n      \"  return false;\\n\"\n      \"}\\n\");\n  } else if (java_type == JAVATYPE_FLOAT) {\n    printer->Print(variables_,\n      \"{\\n\"\n      \"  int bits = java.lang.Float.floatToIntBits(this.$name$);\\n\"\n      \"  if (bits != java.lang.Float.floatToIntBits(other.$name$)\");\n    if (params_.generate_has()) {\n      printer->Print(variables_,\n        \"\\n\"\n        \"      || (bits == java.lang.Float.floatToIntBits($default$)\\n\"\n        \"          && this.has$capitalized_name$ != other.has$capitalized_name$)\");\n    }\n    printer->Print(\") {\\n\"\n      \"    return false;\\n\"\n      \"  }\\n\"\n      \"}\\n\");\n  } else if (java_type == JAVATYPE_DOUBLE) {\n    printer->Print(variables_,\n      \"{\\n\"\n      \"  long bits = java.lang.Double.doubleToLongBits(this.$name$);\\n\"\n      \"  if (bits != java.lang.Double.doubleToLongBits(other.$name$)\");\n    if (params_.generate_has()) {\n      printer->Print(variables_,\n        \"\\n\"\n        \"      || (bits == java.lang.Double.doubleToLongBits($default$)\\n\"\n        \"          && this.has$capitalized_name$ != other.has$capitalized_name$)\");\n    }\n    printer->Print(\") {\\n\"\n      \"    return false;\\n\"\n      \"  }\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables_,\n      \"if (this.$name$ != other.$name$\");\n    if (params_.generate_has()) {\n      printer->Print(variables_,\n        \"\\n\"\n        \"    || (this.$name$ == $default$\\n\"\n        \"        && this.has$capitalized_name$ != other.has$capitalized_name$)\");\n    }\n    printer->Print(\") {\\n\"\n      \"  return false;\\n\"\n      \"}\\n\");\n  }\n}\n\nvoid PrimitiveFieldGenerator::\nGenerateHashCodeCode(io::Printer* printer) const {\n  JavaType java_type = GetJavaType(descriptor_);\n  if (java_type == JAVATYPE_BYTES) {\n    printer->Print(variables_,\n      \"result = 31 * result + java.util.Arrays.hashCode(this.$name$);\\n\");\n  } else if (java_type == JAVATYPE_STRING\n      || params_.use_reference_types_for_primitives()) {\n    printer->Print(variables_,\n      \"result = 31 * result\\n\"\n      \"    + (this.$name$ == null ? 0 : this.$name$.hashCode());\\n\");\n  } else {\n    switch (java_type) {\n      // For all Java primitive types below, the hash codes match the\n      // results of BoxedType.valueOf(primitiveValue).hashCode().\n      case JAVATYPE_INT:\n        printer->Print(variables_,\n          \"result = 31 * result + this.$name$;\\n\");\n        break;\n      case JAVATYPE_LONG:\n        printer->Print(variables_,\n          \"result = 31 * result\\n\"\n          \"    + (int) (this.$name$ ^ (this.$name$ >>> 32));\\n\");\n        break;\n      case JAVATYPE_FLOAT:\n        printer->Print(variables_,\n          \"result = 31 * result\\n\"\n          \"    + java.lang.Float.floatToIntBits(this.$name$);\\n\");\n        break;\n      case JAVATYPE_DOUBLE:\n        printer->Print(variables_,\n          \"{\\n\"\n          \"  long v = java.lang.Double.doubleToLongBits(this.$name$);\\n\"\n          \"  result = 31 * result + (int) (v ^ (v >>> 32));\\n\"\n          \"}\\n\");\n        break;\n      case JAVATYPE_BOOLEAN:\n        printer->Print(variables_,\n          \"result = 31 * result + (this.$name$ ? 1231 : 1237);\\n\");\n        break;\n      default:\n        GOOGLE_LOG(ERROR) << \"unknown java type for primitive field\";\n        break;\n    }\n  }\n}\n\n// ===================================================================\n\nAccessorPrimitiveFieldGenerator::\nAccessorPrimitiveFieldGenerator(const FieldDescriptor* descriptor,\n     const Params& params, int has_bit_index)\n  : FieldGenerator(params), descriptor_(descriptor) {\n  SetPrimitiveVariables(descriptor, params, &variables_);\n  SetBitOperationVariables(\"has\", has_bit_index, &variables_);\n}\n\nAccessorPrimitiveFieldGenerator::~AccessorPrimitiveFieldGenerator() {}\n\nbool AccessorPrimitiveFieldGenerator::SavedDefaultNeeded() const {\n  return variables_.find(\"default_constant\") != variables_.end();\n}\n\nvoid AccessorPrimitiveFieldGenerator::\nGenerateInitSavedDefaultCode(io::Printer* printer) const {\n  if (variables_.find(\"default_constant\") != variables_.end()) {\n    printer->Print(variables_,\n      \"$default_constant$ = $default_constant_value$;\\n\");\n  }\n}\n\nvoid AccessorPrimitiveFieldGenerator::\nGenerateMembers(io::Printer* printer, bool lazy_init) const {\n  if (variables_.find(\"default_constant\") != variables_.end()) {\n    // Those primitive types that need a saved default.\n    if (lazy_init) {\n      printer->Print(variables_,\n        \"private static $type$ $default_constant$;\\n\");\n    } else {\n      printer->Print(variables_,\n        \"private static final $type$ $default_constant$ =\\n\"\n        \"    $default_constant_value$;\\n\");\n    }\n  }\n  printer->Print(variables_,\n    \"private $type$ $name$_;\\n\"\n    \"public $type$ get$capitalized_name$() {\\n\"\n    \"  return $name$_;\\n\"\n    \"}\\n\"\n    \"public $message_name$ set$capitalized_name$($type$ value) {\\n\");\n  if (IsReferenceType(GetJavaType(descriptor_))) {\n    printer->Print(variables_,\n      \"  if (value == null) {\\n\"\n      \"    throw new java.lang.NullPointerException();\\n\"\n      \"  }\\n\");\n  }\n  printer->Print(variables_,\n    \"  $name$_ = value;\\n\"\n    \"  $set_has$;\\n\"\n    \"  return this;\\n\"\n    \"}\\n\"\n    \"public boolean has$capitalized_name$() {\\n\"\n    \"  return $get_has$;\\n\"\n    \"}\\n\"\n    \"public $message_name$ clear$capitalized_name$() {\\n\"\n    \"  $name$_ = $default_copy_if_needed$;\\n\"\n    \"  $clear_has$;\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid AccessorPrimitiveFieldGenerator::\nGenerateClearCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$_ = $default_copy_if_needed$;\\n\");\n}\n\nvoid AccessorPrimitiveFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$_ = input.read$capitalized_type$();\\n\"\n    \"$set_has$;\\n\");\n}\n\nvoid AccessorPrimitiveFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($get_has$) {\\n\"\n    \"  output.write$capitalized_type$($number$, $name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid AccessorPrimitiveFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($get_has$) {\\n\"\n    \"  size += com.google.protobuf.nano.CodedOutputByteBufferNano\\n\"\n    \"      .compute$capitalized_type$Size($number$, $name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid AccessorPrimitiveFieldGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  switch (GetJavaType(descriptor_)) {\n    // For all Java primitive types below, the equality checks match the\n    // results of BoxedType.valueOf(primitiveValue).equals(otherValue).\n    case JAVATYPE_FLOAT:\n      printer->Print(variables_,\n        \"if ($different_has$\\n\"\n        \"    || java.lang.Float.floatToIntBits($name$_)\\n\"\n        \"        != java.lang.Float.floatToIntBits(other.$name$_)) {\\n\"\n        \"  return false;\\n\"\n        \"}\\n\");\n      break;\n    case JAVATYPE_DOUBLE:\n      printer->Print(variables_,\n        \"if ($different_has$\\n\"\n        \"    || java.lang.Double.doubleToLongBits($name$_)\\n\"\n        \"        != java.lang.Double.doubleToLongBits(other.$name$_)) {\\n\"\n        \"  return false;\\n\"\n        \"}\\n\");\n      break;\n    case JAVATYPE_INT:\n    case JAVATYPE_LONG:\n    case JAVATYPE_BOOLEAN:\n      printer->Print(variables_,\n        \"if ($different_has$\\n\"\n        \"    || $name$_ != other.$name$_) {\\n\"\n        \"  return false;\\n\"\n        \"}\\n\");\n      break;\n    case JAVATYPE_STRING:\n      // Accessor style would guarantee $name$_ non-null\n      printer->Print(variables_,\n        \"if ($different_has$\\n\"\n        \"    || !$name$_.equals(other.$name$_)) {\\n\"\n        \"  return false;\\n\"\n        \"}\\n\");\n      break;\n    case JAVATYPE_BYTES:\n      // Accessor style would guarantee $name$_ non-null\n      printer->Print(variables_,\n        \"if ($different_has$\\n\"\n        \"    || !java.util.Arrays.equals($name$_, other.$name$_)) {\\n\"\n        \"  return false;\\n\"\n        \"}\\n\");\n      break;\n    default:\n      GOOGLE_LOG(ERROR) << \"unknown java type for primitive field\";\n      break;\n  }\n}\n\nvoid AccessorPrimitiveFieldGenerator::\nGenerateHashCodeCode(io::Printer* printer) const {\n  switch (GetJavaType(descriptor_)) {\n    // For all Java primitive types below, the hash codes match the\n    // results of BoxedType.valueOf(primitiveValue).hashCode().\n    case JAVATYPE_INT:\n      printer->Print(variables_,\n        \"result = 31 * result + $name$_;\\n\");\n      break;\n    case JAVATYPE_LONG:\n      printer->Print(variables_,\n        \"result = 31 * result + (int) ($name$_ ^ ($name$_ >>> 32));\\n\");\n      break;\n    case JAVATYPE_FLOAT:\n      printer->Print(variables_,\n        \"result = 31 * result +\\n\"\n        \"    java.lang.Float.floatToIntBits($name$_);\\n\");\n      break;\n    case JAVATYPE_DOUBLE:\n      printer->Print(variables_,\n        \"{\\n\"\n        \"  long v = java.lang.Double.doubleToLongBits($name$_);\\n\"\n        \"  result = 31 * result + (int) (v ^ (v >>> 32));\\n\"\n        \"}\\n\");\n      break;\n    case JAVATYPE_BOOLEAN:\n      printer->Print(variables_,\n        \"result = 31 * result + ($name$_ ? 1231 : 1237);\\n\");\n      break;\n    case JAVATYPE_STRING:\n      // Accessor style would guarantee $name$_ non-null\n      printer->Print(variables_,\n        \"result = 31 * result + $name$_.hashCode();\\n\");\n      break;\n    case JAVATYPE_BYTES:\n      // Accessor style would guarantee $name$_ non-null\n      printer->Print(variables_,\n        \"result = 31 * result + java.util.Arrays.hashCode($name$_);\\n\");\n      break;\n    default:\n      GOOGLE_LOG(ERROR) << \"unknown java type for primitive field\";\n      break;\n  }\n}\n\n// ===================================================================\n\nPrimitiveOneofFieldGenerator::PrimitiveOneofFieldGenerator(\n    const FieldDescriptor* descriptor, const Params& params)\n  : FieldGenerator(params), descriptor_(descriptor) {\n    SetPrimitiveVariables(descriptor, params, &variables_);\n    SetCommonOneofVariables(descriptor, &variables_);\n}\n\nPrimitiveOneofFieldGenerator::~PrimitiveOneofFieldGenerator() {}\n\nvoid PrimitiveOneofFieldGenerator::GenerateMembers(\n    io::Printer* printer, bool /*unused lazy_init*/) const {\n  printer->Print(variables_,\n    \"public boolean has$capitalized_name$() {\\n\"\n    \"  return $has_oneof_case$;\\n\"\n    \"}\\n\"\n    \"public $type$ get$capitalized_name$() {\\n\"\n    \"  if ($has_oneof_case$) {\\n\"\n    \"    return ($type$) ($boxed_type$) this.$oneof_name$_;\\n\"\n    \"  }\\n\"\n    \"  return $default$;\\n\"\n    \"}\\n\"\n    \"public $message_name$ set$capitalized_name$($type$ value) {\\n\"\n    \"  $set_oneof_case$;\\n\"\n    \"  this.$oneof_name$_ = value;\\n\"\n    \"  return this;\\n\"\n    \"}\\n\");\n}\n\nvoid PrimitiveOneofFieldGenerator::GenerateClearCode(\n    io::Printer* printer) const {\n  // No clear method for oneof fields.\n}\n\nvoid PrimitiveOneofFieldGenerator::GenerateMergingCode(\n    io::Printer* printer) const {\n  printer->Print(variables_,\n    \"this.$oneof_name$_ = input.read$capitalized_type$();\\n\"\n    \"$set_oneof_case$;\\n\");\n}\n\nvoid PrimitiveOneofFieldGenerator::GenerateSerializationCode(\n    io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case$) {\\n\"\n    \"  output.write$capitalized_type$(\\n\"\n    \"      $number$, ($boxed_type$) this.$oneof_name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid PrimitiveOneofFieldGenerator::GenerateSerializedSizeCode(\n    io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if ($has_oneof_case$) {\\n\"\n    \"  size += com.google.protobuf.nano.CodedOutputByteBufferNano\\n\"\n    \"      .compute$capitalized_type$Size(\\n\"\n    \"          $number$, ($boxed_type$) this.$oneof_name$_);\\n\"\n    \"}\\n\");\n}\n\nvoid PrimitiveOneofFieldGenerator::GenerateEqualsCode(\n    io::Printer* printer) const {\n  GenerateOneofFieldEquals(descriptor_, variables_, printer);\n}\n\nvoid PrimitiveOneofFieldGenerator::GenerateHashCodeCode(\n    io::Printer* printer) const {\n  GenerateOneofFieldHashCode(descriptor_, variables_, printer);\n}\n\n// ===================================================================\n\nRepeatedPrimitiveFieldGenerator::RepeatedPrimitiveFieldGenerator(\n    const FieldDescriptor* descriptor, const Params& params)\n  : FieldGenerator(params), descriptor_(descriptor) {\n  SetPrimitiveVariables(descriptor, params, &variables_);\n}\n\nRepeatedPrimitiveFieldGenerator::~RepeatedPrimitiveFieldGenerator() {}\n\nvoid RepeatedPrimitiveFieldGenerator::\nGenerateMembers(io::Printer* printer, bool /*unused init_defaults*/) const {\n  printer->Print(variables_,\n    \"public $type$[] $name$;\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::\nGenerateClearCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"$name$ = $default$;\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::\nGenerateMergingCode(io::Printer* printer) const {\n  // First, figure out the length of the array, then parse.\n  printer->Print(variables_,\n    \"int arrayLength = com.google.protobuf.nano.WireFormatNano\\n\"\n    \"    .getRepeatedFieldArrayLength(input, $non_packed_tag$);\\n\"\n    \"int i = this.$name$ == null ? 0 : this.$name$.length;\\n\");\n\n  if (GetJavaType(descriptor_) == JAVATYPE_BYTES) {\n    printer->Print(variables_,\n      \"byte[][] newArray = new byte[i + arrayLength][];\\n\");\n  } else {\n    printer->Print(variables_,\n      \"$type$[] newArray = new $type$[i + arrayLength];\\n\");\n  }\n  printer->Print(variables_,\n    \"if (i != 0) {\\n\"\n    \"  java.lang.System.arraycopy(this.$name$, 0, newArray, 0, i);\\n\"\n    \"}\\n\"\n    \"for (; i < newArray.length - 1; i++) {\\n\"\n    \"  newArray[i] = input.read$capitalized_type$();\\n\"\n    \"  input.readTag();\\n\"\n    \"}\\n\"\n    \"// Last one without readTag.\\n\"\n    \"newArray[i] = input.read$capitalized_type$();\\n\"\n    \"this.$name$ = newArray;\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::\nGenerateMergingCodeFromPacked(io::Printer* printer) const {\n  printer->Print(\n    \"int length = input.readRawVarint32();\\n\"\n    \"int limit = input.pushLimit(length);\\n\");\n\n  // If we know the elements will all be of the same size, the arrayLength\n  // can be calculated much more easily. However, FixedSize() returns 1 for\n  // repeated bool fields, which are guaranteed to have the fixed size of\n  // 1 byte per value only if we control the output. On the wire they can\n  // legally appear as variable-size integers, so we need to use the slow\n  // way for repeated bool fields.\n  if (descriptor_->type() == FieldDescriptor::TYPE_BOOL\n      || FixedSize(descriptor_->type()) == -1) {\n    printer->Print(variables_,\n      \"// First pass to compute array length.\\n\"\n      \"int arrayLength = 0;\\n\"\n      \"int startPos = input.getPosition();\\n\"\n      \"while (input.getBytesUntilLimit() > 0) {\\n\"\n      \"  input.read$capitalized_type$();\\n\"\n      \"  arrayLength++;\\n\"\n      \"}\\n\"\n      \"input.rewindToPosition(startPos);\\n\");\n  } else {\n    printer->Print(variables_,\n      \"int arrayLength = length / $fixed_size$;\\n\");\n  }\n\n  printer->Print(variables_,\n    \"int i = this.$name$ == null ? 0 : this.$name$.length;\\n\"\n    \"$type$[] newArray = new $type$[i + arrayLength];\\n\"\n    \"if (i != 0) {\\n\"\n    \"  java.lang.System.arraycopy(this.$name$, 0, newArray, 0, i);\\n\"\n    \"}\\n\"\n    \"for (; i < newArray.length; i++) {\\n\"\n    \"  newArray[i] = input.read$capitalized_type$();\\n\"\n    \"}\\n\"\n    \"this.$name$ = newArray;\\n\"\n    \"input.popLimit(limit);\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::\nGenerateRepeatedDataSizeCode(io::Printer* printer) const {\n  // Creates a variable dataSize and puts the serialized size in there.\n  // If the element type is a Java reference type, also generates\n  // dataCount which stores the number of non-null elements in the field.\n  if (IsReferenceType(GetJavaType(descriptor_))) {\n    printer->Print(variables_,\n      \"int dataCount = 0;\\n\"\n      \"int dataSize = 0;\\n\"\n      \"for (int i = 0; i < this.$name$.length; i++) {\\n\"\n      \"  $type$ element = this.$name$[i];\\n\"\n      \"  if (element != null) {\\n\"\n      \"    dataCount++;\\n\"\n      \"    dataSize += com.google.protobuf.nano.CodedOutputByteBufferNano\\n\"\n      \"        .compute$capitalized_type$SizeNoTag(element);\\n\"\n      \"  }\\n\"\n      \"}\\n\");\n  } else if (FixedSize(descriptor_->type()) == -1) {\n    printer->Print(variables_,\n      \"int dataSize = 0;\\n\"\n      \"for (int i = 0; i < this.$name$.length; i++) {\\n\"\n      \"  $type$ element = this.$name$[i];\\n\"\n      \"  dataSize += com.google.protobuf.nano.CodedOutputByteBufferNano\\n\"\n      \"      .compute$capitalized_type$SizeNoTag(element);\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables_,\n      \"int dataSize = $fixed_size$ * this.$name$.length;\\n\");\n  }\n}\n\nvoid RepeatedPrimitiveFieldGenerator::\nGenerateSerializationCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (this.$name$ != null && this.$name$.length > 0) {\\n\");\n  printer->Indent();\n\n  if (descriptor_->is_packable() && descriptor_->options().packed()) {\n    GenerateRepeatedDataSizeCode(printer);\n    printer->Print(variables_,\n      \"output.writeRawVarint32($tag$);\\n\"\n      \"output.writeRawVarint32(dataSize);\\n\"\n      \"for (int i = 0; i < this.$name$.length; i++) {\\n\"\n      \"  output.write$capitalized_type$NoTag(this.$name$[i]);\\n\"\n      \"}\\n\");\n  } else if (IsReferenceType(GetJavaType(descriptor_))) {\n    printer->Print(variables_,\n      \"for (int i = 0; i < this.$name$.length; i++) {\\n\"\n      \"  $type$ element = this.$name$[i];\\n\"\n      \"  if (element != null) {\\n\"\n      \"    output.write$capitalized_type$($number$, element);\\n\"\n      \"  }\\n\"\n      \"}\\n\");\n  } else {\n    printer->Print(variables_,\n      \"for (int i = 0; i < this.$name$.length; i++) {\\n\"\n      \"  output.write$capitalized_type$($number$, this.$name$[i]);\\n\"\n      \"}\\n\");\n  }\n\n  printer->Outdent();\n  printer->Print(\"}\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::\nGenerateSerializedSizeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (this.$name$ != null && this.$name$.length > 0) {\\n\");\n  printer->Indent();\n\n  GenerateRepeatedDataSizeCode(printer);\n\n  printer->Print(\n    \"size += dataSize;\\n\");\n  if (descriptor_->is_packable() && descriptor_->options().packed()) {\n    printer->Print(variables_,\n      \"size += $tag_size$;\\n\"\n      \"size += com.google.protobuf.nano.CodedOutputByteBufferNano\\n\"\n      \"    .computeRawVarint32Size(dataSize);\\n\");\n  } else if (IsReferenceType(GetJavaType(descriptor_))) {\n    printer->Print(variables_,\n      \"size += $tag_size$ * dataCount;\\n\");\n  } else {\n    printer->Print(variables_,\n      \"size += $tag_size$ * this.$name$.length;\\n\");\n  }\n\n  printer->Outdent();\n\n  printer->Print(\n    \"}\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::\nGenerateEqualsCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"if (!com.google.protobuf.nano.InternalNano.equals(\\n\"\n    \"    this.$name$, other.$name$)) {\\n\"\n    \"  return false;\\n\"\n    \"}\\n\");\n}\n\nvoid RepeatedPrimitiveFieldGenerator::\nGenerateHashCodeCode(io::Printer* printer) const {\n  printer->Print(variables_,\n    \"result = 31 * result\\n\"\n    \"    + com.google.protobuf.nano.InternalNano.hashCode(this.$name$);\\n\");\n}\n\n}  // namespace javanano\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/javanano/javanano_primitive_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// http://code.google.com/p/protobuf/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JAVANANO_PRIMITIVE_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_JAVANANO_PRIMITIVE_FIELD_H__\n\n#include <map>\n#include <string>\n#include <google/protobuf/compiler/javanano/javanano_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace javanano {\n\nclass PrimitiveFieldGenerator : public FieldGenerator {\n public:\n  explicit PrimitiveFieldGenerator(\n      const FieldDescriptor* descriptor, const Params& params);\n  ~PrimitiveFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  bool SavedDefaultNeeded() const;\n  void GenerateInitSavedDefaultCode(io::Printer* printer) const;\n  void GenerateMembers(io::Printer* printer, bool lazy_init) const;\n  void GenerateClearCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCodeCode(io::Printer* printer) const;\n\n private:\n  void GenerateSerializationConditional(io::Printer* printer) const;\n\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator);\n};\n\nclass AccessorPrimitiveFieldGenerator : public FieldGenerator {\n public:\n  explicit AccessorPrimitiveFieldGenerator(const FieldDescriptor* descriptor,\n      const Params &params, int has_bit_index);\n  ~AccessorPrimitiveFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  bool SavedDefaultNeeded() const;\n  void GenerateInitSavedDefaultCode(io::Printer* printer) const;\n  void GenerateMembers(io::Printer* printer, bool lazy_init) const;\n  void GenerateClearCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCodeCode(io::Printer* printer) const;\n\n private:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(AccessorPrimitiveFieldGenerator);\n};\n\nclass PrimitiveOneofFieldGenerator : public FieldGenerator {\n public:\n  explicit PrimitiveOneofFieldGenerator(\n      const FieldDescriptor* descriptor, const Params& params);\n  ~PrimitiveOneofFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  void GenerateMembers(io::Printer* printer, bool lazy_init) const;\n  void GenerateClearCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCodeCode(io::Printer* printer) const;\n\n private:\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveOneofFieldGenerator);\n};\n\nclass RepeatedPrimitiveFieldGenerator : public FieldGenerator {\n public:\n  explicit RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor,\n                                           const Params& params);\n  ~RepeatedPrimitiveFieldGenerator();\n\n  // implements FieldGenerator ---------------------------------------\n  void GenerateMembers(io::Printer* printer, bool lazy_init) const;\n  void GenerateClearCode(io::Printer* printer) const;\n  void GenerateMergingCode(io::Printer* printer) const;\n  void GenerateMergingCodeFromPacked(io::Printer* printer) const;\n  void GenerateSerializationCode(io::Printer* printer) const;\n  void GenerateSerializedSizeCode(io::Printer* printer) const;\n  void GenerateEqualsCode(io::Printer* printer) const;\n  void GenerateHashCodeCode(io::Printer* printer) const;\n  void GenerateFixClonedCode(io::Printer* printer) const;\n\n private:\n  void GenerateRepeatedDataSizeCode(io::Printer* printer) const;\n\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPrimitiveFieldGenerator);\n};\n\n}  // namespace javanano\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JAVANANO_PRIMITIVE_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/js/js_generator.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include \"google/protobuf/compiler/js/js_generator.h\"\n\n#include <assert.h>\n#include <algorithm>\n#include <limits>\n#include <map>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <string>\n#include <utility>\n#include <vector>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/stringprintf.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace js {\n\n// Sorted list of JavaScript keywords. These cannot be used as names. If they\n// appear, we prefix them with \"pb_\".\nconst char* kKeyword[] = {\n  \"abstract\",\n  \"boolean\",\n  \"break\",\n  \"byte\",\n  \"case\",\n  \"catch\",\n  \"char\",\n  \"class\",\n  \"const\",\n  \"continue\",\n  \"debugger\",\n  \"default\",\n  \"delete\",\n  \"do\",\n  \"double\",\n  \"else\",\n  \"enum\",\n  \"export\",\n  \"extends\",\n  \"false\",\n  \"final\",\n  \"finally\",\n  \"float\",\n  \"for\",\n  \"function\",\n  \"goto\",\n  \"if\",\n  \"implements\",\n  \"import\",\n  \"in\",\n  \"instanceof\",\n  \"int\",\n  \"interface\",\n  \"long\",\n  \"native\",\n  \"new\",\n  \"null\",\n  \"package\",\n  \"private\",\n  \"protected\",\n  \"public\",\n  \"return\",\n  \"short\",\n  \"static\",\n  \"super\",\n  \"switch\",\n  \"synchronized\",\n  \"this\",\n  \"throw\",\n  \"throws\",\n  \"transient\",\n  \"try\",\n  \"typeof\",\n  \"var\",\n  \"void\",\n  \"volatile\",\n  \"while\",\n  \"with\",\n};\n\nstatic const int kNumKeyword = sizeof(kKeyword) / sizeof(char*);\n\nnamespace {\n\n// The mode of operation for bytes fields. Historically JSPB always carried\n// bytes as JS {string}, containing base64 content by convention. With binary\n// and proto3 serialization the new convention is to represent it as binary\n// data in Uint8Array. See b/26173701 for background on the migration.\nenum BytesMode {\n  BYTES_DEFAULT,  // Default type for getBytesField to return.\n  BYTES_B64,      // Explicitly coerce to base64 string where needed.\n  BYTES_U8,       // Explicitly coerce to Uint8Array where needed.\n};\n\nbool IsReserved(const string& ident) {\n  for (int i = 0; i < kNumKeyword; i++) {\n    if (ident == kKeyword[i]) {\n      return true;\n    }\n  }\n  return false;\n}\n\n// Returns a copy of |filename| with any trailing \".protodevel\" or \".proto\n// suffix stripped.\n// TODO(haberman): Unify with copy in compiler/cpp/internal/helpers.cc.\nstring StripProto(const string& filename) {\n  const char* suffix = HasSuffixString(filename, \".protodevel\")\n      ? \".protodevel\" : \".proto\";\n  return StripSuffixString(filename, suffix);\n}\n\n// Given a filename like foo/bar/baz.proto, returns the corresponding JavaScript\n// file foo/bar/baz.js.\nstring GetJSFilename(const string& filename) {\n  return StripProto(filename) + \"_pb.js\";\n}\n\n// Given a filename like foo/bar/baz.proto, returns the root directory\n// path ../../\nstring GetRootPath(const string& from_filename, const string& to_filename) {\n  if (to_filename.find(\"google/protobuf\") == 0) {\n    // Well-known types (.proto files in the google/protobuf directory) are\n    // assumed to come from the 'google-protobuf' npm package.  We may want to\n    // generalize this exception later by letting others put generated code in\n    // their own npm packages.\n    return \"google-protobuf/\";\n  }\n\n  size_t slashes = std::count(from_filename.begin(), from_filename.end(), '/');\n  if (slashes == 0) {\n    return \"./\";\n  }\n  string result = \"\";\n  for (size_t i = 0; i < slashes; i++) {\n    result += \"../\";\n  }\n  return result;\n}\n\n// Returns the alias we assign to the module of the given .proto filename\n// when importing.\nstring ModuleAlias(const string& filename) {\n  // This scheme could technically cause problems if a file includes any 2 of:\n  //   foo/bar_baz.proto\n  //   foo_bar_baz.proto\n  //   foo_bar/baz.proto\n  //\n  // We'll worry about this problem if/when we actually see it.  This name isn't\n  // exposed to users so we can change it later if we need to.\n  string basename = StripProto(filename);\n  StripString(&basename, \"-\", '$');\n  StripString(&basename, \"/\", '_');\n  return basename + \"_pb\";\n}\n\n// Returns the fully normalized JavaScript path for the given\n// file descriptor's package.\nstring GetPath(const GeneratorOptions& options,\n               const FileDescriptor* file) {\n  if (!options.namespace_prefix.empty()) {\n    return options.namespace_prefix;\n  } else if (!file->package().empty()) {\n    return \"proto.\" + file->package();\n  } else {\n    return \"proto\";\n  }\n}\n\n// Forward declare, so that GetPrefix can call this method,\n// which in turn, calls GetPrefix.\nstring GetPath(const GeneratorOptions& options,\n               const Descriptor* descriptor);\n\n// Returns the path prefix for a message or enumeration that\n// lives under the given file and containing type.\nstring GetPrefix(const GeneratorOptions& options,\n                 const FileDescriptor* file_descriptor,\n                 const Descriptor* containing_type) {\n  string prefix = \"\";\n\n  if (containing_type == NULL) {\n    prefix = GetPath(options, file_descriptor);\n  } else {\n    prefix = GetPath(options, containing_type);\n  }\n\n  if (!prefix.empty()) {\n    prefix += \".\";\n  }\n\n  return prefix;\n}\n\n\n// Returns the fully normalized JavaScript path for the given\n// message descriptor.\nstring GetPath(const GeneratorOptions& options,\n               const Descriptor* descriptor) {\n  return GetPrefix(\n      options, descriptor->file(),\n      descriptor->containing_type()) + descriptor->name();\n}\n\n\n// Returns the fully normalized JavaScript path for the given\n// field's containing message descriptor.\nstring GetPath(const GeneratorOptions& options,\n               const FieldDescriptor* descriptor) {\n  return GetPath(options, descriptor->containing_type());\n}\n\n// Returns the fully normalized JavaScript path for the given\n// enumeration descriptor.\nstring GetPath(const GeneratorOptions& options,\n               const EnumDescriptor* enum_descriptor) {\n  return GetPrefix(\n      options, enum_descriptor->file(),\n      enum_descriptor->containing_type()) + enum_descriptor->name();\n}\n\n\n// Returns the fully normalized JavaScript path for the given\n// enumeration value descriptor.\nstring GetPath(const GeneratorOptions& options,\n               const EnumValueDescriptor* value_descriptor) {\n  return GetPath(\n      options,\n      value_descriptor->type()) + \".\" + value_descriptor->name();\n}\n\nstring MaybeCrossFileRef(const GeneratorOptions& options,\n                         const FileDescriptor* from_file,\n                         const Descriptor* to_message) {\n  if (options.import_style == GeneratorOptions::IMPORT_COMMONJS &&\n      from_file != to_message->file()) {\n    // Cross-file ref in CommonJS needs to use the module alias instead of\n    // the global name.\n    return ModuleAlias(to_message->file()->name()) + \".\" + to_message->name();\n  } else {\n    // Within a single file we use a full name.\n    return GetPath(options, to_message);\n  }\n}\n\nstring SubmessageTypeRef(const GeneratorOptions& options,\n                         const FieldDescriptor* field) {\n  GOOGLE_CHECK(field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE);\n  return MaybeCrossFileRef(options, field->file(), field->message_type());\n}\n\n// - Object field name: LOWER_UNDERSCORE -> LOWER_CAMEL, except for group fields\n// (UPPER_CAMEL -> LOWER_CAMEL), with \"List\" (or \"Map\") appended if appropriate,\n// and with reserved words triggering a \"pb_\" prefix.\n// - Getters/setters: LOWER_UNDERSCORE -> UPPER_CAMEL, except for group fields\n// (use the name directly), then append \"List\" if appropriate, then append \"$\"\n// if resulting name is equal to a reserved word.\n// - Enums: just uppercase.\n\n// Locale-independent version of ToLower that deals only with ASCII A-Z.\nchar ToLowerASCII(char c) {\n  if (c >= 'A' && c <= 'Z') {\n    return (c - 'A') + 'a';\n  } else {\n    return c;\n  }\n}\n\nvector<string> ParseLowerUnderscore(const string& input) {\n  vector<string> words;\n  string running = \"\";\n  for (int i = 0; i < input.size(); i++) {\n    if (input[i] == '_') {\n      if (!running.empty()) {\n        words.push_back(running);\n        running.clear();\n      }\n    } else {\n      running += ToLowerASCII(input[i]);\n    }\n  }\n  if (!running.empty()) {\n    words.push_back(running);\n  }\n  return words;\n}\n\nvector<string> ParseUpperCamel(const string& input) {\n  vector<string> words;\n  string running = \"\";\n  for (int i = 0; i < input.size(); i++) {\n    if (input[i] >= 'A' && input[i] <= 'Z' && !running.empty()) {\n      words.push_back(running);\n      running.clear();\n    }\n    running += ToLowerASCII(input[i]);\n  }\n  if (!running.empty()) {\n    words.push_back(running);\n  }\n  return words;\n}\n\nstring ToLowerCamel(const vector<string>& words) {\n  string result;\n  for (int i = 0; i < words.size(); i++) {\n    string word = words[i];\n    if (i == 0 && (word[0] >= 'A' && word[0] <= 'Z')) {\n      word[0] = (word[0] - 'A') + 'a';\n    } else if (i != 0 && (word[0] >= 'a' && word[0] <= 'z')) {\n      word[0] = (word[0] - 'a') + 'A';\n    }\n    result += word;\n  }\n  return result;\n}\n\nstring ToUpperCamel(const vector<string>& words) {\n  string result;\n  for (int i = 0; i < words.size(); i++) {\n    string word = words[i];\n    if (word[0] >= 'a' && word[0] <= 'z') {\n      word[0] = (word[0] - 'a') + 'A';\n    }\n    result += word;\n  }\n  return result;\n}\n\n// Based on code from descriptor.cc (Thanks Kenton!)\n// Uppercases the entire string, turning ValueName into\n// VALUENAME.\nstring ToEnumCase(const string& input) {\n  string result;\n  result.reserve(input.size());\n\n  for (int i = 0; i < input.size(); i++) {\n    if ('a' <= input[i] && input[i] <= 'z') {\n      result.push_back(input[i] - 'a' + 'A');\n    } else {\n      result.push_back(input[i]);\n    }\n  }\n\n  return result;\n}\n\nstring ToFileName(const string& input) {\n  string result;\n  result.reserve(input.size());\n\n  for (int i = 0; i < input.size(); i++) {\n    if ('A' <= input[i] && input[i] <= 'Z') {\n      result.push_back(input[i] - 'A' + 'a');\n    } else {\n      result.push_back(input[i]);\n    }\n  }\n\n  return result;\n}\n\n// When we're generating one output file per type name, this is the filename\n// that top-level extensions should go in.\nstring GetExtensionFileName(const GeneratorOptions& options,\n                            const FileDescriptor* file) {\n  return options.output_dir + \"/\" + ToFileName(GetPath(options, file)) + \".js\";\n}\n\n// When we're generating one output file per type name, this is the filename\n// that a top-level message should go in.\nstring GetMessageFileName(const GeneratorOptions& options,\n                          const Descriptor* desc) {\n  return options.output_dir + \"/\" + ToFileName(desc->name()) + \".js\";\n}\n\n// When we're generating one output file per type name, this is the filename\n// that a top-level message should go in.\nstring GetEnumFileName(const GeneratorOptions& options,\n                       const EnumDescriptor* desc) {\n  return options.output_dir + \"/\" + ToFileName(desc->name()) + \".js\";\n}\n\n// Returns the message/response ID, if set.\nstring GetMessageId(const Descriptor* desc) {\n  return string();\n}\n\nbool IgnoreExtensionField(const FieldDescriptor* field) {\n  // Exclude descriptor extensions from output \"to avoid clutter\" (from original\n  // codegen).\n  return field->is_extension() &&\n         field->containing_type()->file()->name() ==\n             \"google/protobuf/descriptor.proto\";\n}\n\n\n// Used inside Google only -- do not remove.\nbool IsResponse(const Descriptor* desc) { return false; }\n\nbool IgnoreField(const FieldDescriptor* field) {\n  return IgnoreExtensionField(field);\n}\n\n\n// Do we ignore this message type?\nbool IgnoreMessage(const GeneratorOptions& options, const Descriptor* d) {\n  return d->options().map_entry();\n}\n\n// Does JSPB ignore this entire oneof? True only if all fields are ignored.\nbool IgnoreOneof(const OneofDescriptor* oneof) {\n  for (int i = 0; i < oneof->field_count(); i++) {\n    if (!IgnoreField(oneof->field(i))) {\n      return false;\n    }\n  }\n  return true;\n}\n\nstring JSIdent(const GeneratorOptions& options,\n               const FieldDescriptor* field,\n               bool is_upper_camel,\n               bool is_map) {\n  string result;\n  if (field->type() == FieldDescriptor::TYPE_GROUP) {\n    result = is_upper_camel ?\n        ToUpperCamel(ParseUpperCamel(field->message_type()->name())) :\n        ToLowerCamel(ParseUpperCamel(field->message_type()->name()));\n  } else {\n    result = is_upper_camel ?\n        ToUpperCamel(ParseLowerUnderscore(field->name())) :\n        ToLowerCamel(ParseLowerUnderscore(field->name()));\n  }\n  if (is_map || (field->is_map())) {\n    // JSPB-style or proto3-style map.\n    result += \"Map\";\n  } else if (field->is_repeated()) {\n    // Repeated field.\n    result += \"List\";\n  }\n  return result;\n}\n\nstring JSObjectFieldName(const GeneratorOptions& options,\n                         const FieldDescriptor* field) {\n  string name = JSIdent(\n      options,\n      field,\n      /* is_upper_camel = */ false,\n      /* is_map = */ false);\n  if (IsReserved(name)) {\n    name = \"pb_\" + name;\n  }\n  return name;\n}\n\nstring JSByteGetterSuffix(BytesMode bytes_mode) {\n  switch (bytes_mode) {\n    case BYTES_DEFAULT:\n      return \"\";\n    case BYTES_B64:\n      return \"B64\";\n    case BYTES_U8:\n      return \"U8\";\n    default:\n      assert(false);\n  }\n  return \"\";\n}\n\n// Returns the field name as a capitalized portion of a getter/setter method\n// name, e.g. MyField for .getMyField().\nstring JSGetterName(const GeneratorOptions& options,\n                    const FieldDescriptor* field,\n                    BytesMode bytes_mode = BYTES_DEFAULT) {\n  string name = JSIdent(options, field,\n                        /* is_upper_camel = */ true,\n                        /* is_map = */ false);\n  if (field->type() == FieldDescriptor::TYPE_BYTES) {\n    string suffix = JSByteGetterSuffix(bytes_mode);\n    if (!suffix.empty()) {\n      name += \"_as\" + suffix;\n    }\n  }\n  if (name == \"Extension\" || name == \"JsPbMessageId\") {\n    // Avoid conflicts with base-class names.\n    name += \"$\";\n  }\n  return name;\n}\n\nstring JSMapGetterName(const GeneratorOptions& options,\n                       const FieldDescriptor* field) {\n  return JSIdent(options, field,\n                 /* is_upper_camel = */ true,\n                 /* is_map = */ true);\n}\n\n\n\nstring JSOneofName(const OneofDescriptor* oneof) {\n  return ToUpperCamel(ParseLowerUnderscore(oneof->name()));\n}\n\n// Returns the index corresponding to this field in the JSPB array (underlying\n// data storage array).\nstring JSFieldIndex(const FieldDescriptor* field) {\n  // Determine whether this field is a member of a group. Group fields are a bit\n  // wonky: their \"containing type\" is a message type created just for the\n  // group, and that type's parent type has a field with the group-message type\n  // as its message type and TYPE_GROUP as its field type. For such fields, the\n  // index we use is relative to the field number of the group submessage field.\n  // For all other fields, we just use the field number.\n  const Descriptor* containing_type = field->containing_type();\n  const Descriptor* parent_type = containing_type->containing_type();\n  if (parent_type != NULL) {\n    for (int i = 0; i < parent_type->field_count(); i++) {\n      if (parent_type->field(i)->type() == FieldDescriptor::TYPE_GROUP &&\n          parent_type->field(i)->message_type() == containing_type) {\n        return SimpleItoa(field->number() - parent_type->field(i)->number());\n      }\n    }\n  }\n  return SimpleItoa(field->number());\n}\n\nstring JSOneofIndex(const OneofDescriptor* oneof) {\n  int index = -1;\n  for (int i = 0; i < oneof->containing_type()->oneof_decl_count(); i++) {\n    const OneofDescriptor* o = oneof->containing_type()->oneof_decl(i);\n    // If at least one field in this oneof is not JSPB-ignored, count the oneof.\n    for (int j = 0; j < o->field_count(); j++) {\n      const FieldDescriptor* f = o->field(j);\n      if (!IgnoreField(f)) {\n        index++;\n        break;  // inner loop\n      }\n    }\n    if (o == oneof) {\n      break;\n    }\n  }\n  return SimpleItoa(index);\n}\n\n// Decodes a codepoint in \\x0000 -- \\xFFFF.\nuint16 DecodeUTF8Codepoint(uint8* bytes, size_t* length) {\n  if (*length == 0) {\n    return 0;\n  }\n  size_t expected = 0;\n  if ((*bytes & 0x80) == 0) {\n    expected = 1;\n  } else if ((*bytes & 0xe0) == 0xc0) {\n    expected = 2;\n  } else if ((*bytes & 0xf0) == 0xe0) {\n    expected = 3;\n  } else {\n    // Too long -- don't accept.\n    *length = 0;\n    return 0;\n  }\n\n  if (*length < expected) {\n    // Not enough bytes -- don't accept.\n    *length = 0;\n    return 0;\n  }\n\n  *length = expected;\n  switch (expected) {\n    case 1: return bytes[0];\n    case 2: return ((bytes[0] & 0x1F) << 6)  |\n                   ((bytes[1] & 0x3F) << 0);\n    case 3: return ((bytes[0] & 0x0F) << 12) |\n                   ((bytes[1] & 0x3F) << 6)  |\n                   ((bytes[2] & 0x3F) << 0);\n    default: return 0;\n  }\n}\n\n// Escapes the contents of a string to be included within double-quotes (\"\") in\n// JavaScript. The input data should be a UTF-8 encoded C++ string of chars.\n// Returns false if |out| was truncated because |in| contained invalid UTF-8 or\n// codepoints outside the BMP.\n// TODO(lukestebbing): Support codepoints outside the BMP.\nbool EscapeJSString(const string& in, string* out) {\n  size_t decoded = 0;\n  for (size_t i = 0; i < in.size(); i += decoded) {\n    uint16 codepoint = 0;\n    // Decode the next UTF-8 codepoint.\n    size_t have_bytes = in.size() - i;\n    uint8 bytes[3] = {\n        static_cast<uint8>(in[i]),\n        static_cast<uint8>(((i + 1) < in.size()) ? in[i + 1] : 0),\n        static_cast<uint8>(((i + 2) < in.size()) ? in[i + 2] : 0),\n    };\n    codepoint = DecodeUTF8Codepoint(bytes, &have_bytes);\n    if (have_bytes == 0) {\n      return false;\n    }\n    decoded = have_bytes;\n\n    switch (codepoint) {\n      case '\\'': *out += \"\\\\x27\"; break;\n      case '\"': *out += \"\\\\x22\"; break;\n      case '<': *out += \"\\\\x3c\"; break;\n      case '=': *out += \"\\\\x3d\"; break;\n      case '>': *out += \"\\\\x3e\"; break;\n      case '&': *out += \"\\\\x26\"; break;\n      case '\\b': *out += \"\\\\b\"; break;\n      case '\\t': *out += \"\\\\t\"; break;\n      case '\\n': *out += \"\\\\n\"; break;\n      case '\\f': *out += \"\\\\f\"; break;\n      case '\\r': *out += \"\\\\r\"; break;\n      case '\\\\': *out += \"\\\\\\\\\"; break;\n      default:\n        // TODO(lukestebbing): Once we're supporting codepoints outside the BMP,\n        // use a single Unicode codepoint escape if the output language is\n        // ECMAScript 2015 or above. Otherwise, use a surrogate pair.\n        // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#String_literals\n        if (codepoint >= 0x20 && codepoint <= 0x7e) {\n          *out += static_cast<char>(codepoint);\n        } else if (codepoint >= 0x100) {\n          *out += StringPrintf(\"\\\\u%04x\", codepoint);\n        } else {\n          *out += StringPrintf(\"\\\\x%02x\", codepoint);\n        }\n        break;\n    }\n  }\n  return true;\n}\n\nstring EscapeBase64(const string& in) {\n  static const char* kAlphabet =\n      \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n  string result;\n\n  for (size_t i = 0; i < in.size(); i += 3) {\n    int value = (in[i] << 16) |\n        (((i + 1) < in.size()) ? (in[i + 1] << 8) : 0) |\n        (((i + 2) < in.size()) ? (in[i + 2] << 0) : 0);\n    result += kAlphabet[(value >> 18) & 0x3f];\n    result += kAlphabet[(value >> 12) & 0x3f];\n    if ((i + 1) < in.size()) {\n      result += kAlphabet[(value >>  6) & 0x3f];\n    } else {\n      result += '=';\n    }\n    if ((i + 2) < in.size()) {\n      result += kAlphabet[(value >>  0) & 0x3f];\n    } else {\n      result += '=';\n    }\n  }\n\n  return result;\n}\n\n// Post-process the result of SimpleFtoa/SimpleDtoa to *exactly* match the\n// original codegen's formatting (which is just .toString() on java.lang.Double\n// or java.lang.Float).\nstring PostProcessFloat(string result) {\n  // If inf, -inf or nan, replace with +Infinity, -Infinity or NaN.\n  if (result == \"inf\") {\n    return \"Infinity\";\n  } else if (result == \"-inf\") {\n    return \"-Infinity\";\n  } else if (result == \"nan\") {\n    return \"NaN\";\n  }\n\n  // If scientific notation (e.g., \"1e10\"), (i) capitalize the \"e\", (ii)\n  // ensure that the mantissa (portion prior to the \"e\") has at least one\n  // fractional digit (after the decimal point), and (iii) strip any unnecessary\n  // leading zeroes and/or '+' signs from the exponent.\n  string::size_type exp_pos = result.find('e');\n  if (exp_pos != string::npos) {\n    string mantissa = result.substr(0, exp_pos);\n    string exponent = result.substr(exp_pos + 1);\n\n    // Add \".0\" to mantissa if no fractional part exists.\n    if (mantissa.find('.') == string::npos) {\n      mantissa += \".0\";\n    }\n\n    // Strip the sign off the exponent and store as |exp_neg|.\n    bool exp_neg = false;\n    if (!exponent.empty() && exponent[0] == '+') {\n      exponent = exponent.substr(1);\n    } else if (!exponent.empty() && exponent[0] == '-') {\n      exp_neg = true;\n      exponent = exponent.substr(1);\n    }\n\n    // Strip any leading zeroes off the exponent.\n    while (exponent.size() > 1 && exponent[0] == '0') {\n      exponent = exponent.substr(1);\n    }\n\n    return mantissa + \"E\" + string(exp_neg ? \"-\" : \"\") + exponent;\n  }\n\n  // Otherwise, this is an ordinary decimal number. Append \".0\" if result has no\n  // decimal/fractional part in order to match output of original codegen.\n  if (result.find('.') == string::npos) {\n    result += \".0\";\n  }\n\n  return result;\n}\n\nstring FloatToString(float value) {\n  string result = SimpleFtoa(value);\n  return PostProcessFloat(result);\n}\n\nstring DoubleToString(double value) {\n  string result = SimpleDtoa(value);\n  return PostProcessFloat(result);\n}\n\nstring MaybeNumberString(const FieldDescriptor* field, const string& orig) {\n  return orig;\n}\n\nstring JSFieldDefault(const FieldDescriptor* field) {\n  switch (field->cpp_type()) {\n    case FieldDescriptor::CPPTYPE_INT32:\n      return MaybeNumberString(\n          field, SimpleItoa(field->default_value_int32()));\n    case FieldDescriptor::CPPTYPE_UINT32:\n      // The original codegen is in Java, and Java protobufs store unsigned\n      // integer values as signed integer values. In order to exactly match the\n      // output, we need to reinterpret as base-2 signed. Ugh.\n      return MaybeNumberString(\n          field, SimpleItoa(static_cast<int32>(field->default_value_uint32())));\n    case FieldDescriptor::CPPTYPE_INT64:\n      return MaybeNumberString(\n          field, SimpleItoa(field->default_value_int64()));\n    case FieldDescriptor::CPPTYPE_UINT64:\n      // See above note for uint32 -- reinterpreting as signed.\n      return MaybeNumberString(\n          field, SimpleItoa(static_cast<int64>(field->default_value_uint64())));\n    case FieldDescriptor::CPPTYPE_ENUM:\n      return SimpleItoa(field->default_value_enum()->number());\n    case FieldDescriptor::CPPTYPE_BOOL:\n      return field->default_value_bool() ? \"true\" : \"false\";\n    case FieldDescriptor::CPPTYPE_FLOAT:\n      return FloatToString(field->default_value_float());\n    case FieldDescriptor::CPPTYPE_DOUBLE:\n      return DoubleToString(field->default_value_double());\n    case FieldDescriptor::CPPTYPE_STRING:\n      if (field->type() == FieldDescriptor::TYPE_STRING) {\n        string out;\n        bool is_valid = EscapeJSString(field->default_value_string(), &out);\n        if (!is_valid) {\n          // TODO(lukestebbing): Decide whether this should be a hard error.\n          GOOGLE_LOG(WARNING) << \"The default value for field \" << field->full_name()\n                       << \" was truncated since it contained invalid UTF-8 or\"\n                          \" codepoints outside the basic multilingual plane.\";\n        }\n        return \"\\\"\" + out + \"\\\"\";\n      } else {  // Bytes\n        return \"\\\"\" + EscapeBase64(field->default_value_string()) + \"\\\"\";\n      }\n    case FieldDescriptor::CPPTYPE_MESSAGE:\n      return \"null\";\n  }\n  GOOGLE_LOG(FATAL) << \"Shouldn't reach here.\";\n  return \"\";\n}\n\nstring ProtoTypeName(const GeneratorOptions& options,\n                     const FieldDescriptor* field) {\n  switch (field->type()) {\n    case FieldDescriptor::TYPE_BOOL:\n      return \"bool\";\n    case FieldDescriptor::TYPE_INT32:\n      return \"int32\";\n    case FieldDescriptor::TYPE_UINT32:\n      return \"uint32\";\n    case FieldDescriptor::TYPE_SINT32:\n      return \"sint32\";\n    case FieldDescriptor::TYPE_FIXED32:\n      return \"fixed32\";\n    case FieldDescriptor::TYPE_SFIXED32:\n      return \"sfixed32\";\n    case FieldDescriptor::TYPE_INT64:\n      return \"int64\";\n    case FieldDescriptor::TYPE_UINT64:\n      return \"uint64\";\n    case FieldDescriptor::TYPE_SINT64:\n      return \"sint64\";\n    case FieldDescriptor::TYPE_FIXED64:\n      return \"fixed64\";\n    case FieldDescriptor::TYPE_SFIXED64:\n      return \"sfixed64\";\n    case FieldDescriptor::TYPE_FLOAT:\n      return \"float\";\n    case FieldDescriptor::TYPE_DOUBLE:\n      return \"double\";\n    case FieldDescriptor::TYPE_STRING:\n      return \"string\";\n    case FieldDescriptor::TYPE_BYTES:\n      return \"bytes\";\n    case FieldDescriptor::TYPE_GROUP:\n      return GetPath(options, field->message_type());\n    case FieldDescriptor::TYPE_ENUM:\n      return GetPath(options, field->enum_type());\n    case FieldDescriptor::TYPE_MESSAGE:\n      return GetPath(options, field->message_type());\n    default:\n      return \"\";\n  }\n}\n\nstring JSIntegerTypeName(const FieldDescriptor* field) {\n  return \"number\";\n}\n\nstring JSStringTypeName(const GeneratorOptions& options,\n                        const FieldDescriptor* field,\n                        BytesMode bytes_mode) {\n  if (field->type() == FieldDescriptor::TYPE_BYTES) {\n    switch (bytes_mode) {\n      case BYTES_DEFAULT:\n        return \"(string|Uint8Array)\";\n      case BYTES_B64:\n        return \"string\";\n      case BYTES_U8:\n        return \"Uint8Array\";\n      default:\n        assert(false);\n    }\n  }\n  return \"string\";\n}\n\nstring JSTypeName(const GeneratorOptions& options,\n                  const FieldDescriptor* field,\n                  BytesMode bytes_mode) {\n  switch (field->cpp_type()) {\n    case FieldDescriptor::CPPTYPE_BOOL:\n      return \"boolean\";\n    case FieldDescriptor::CPPTYPE_INT32:\n      return JSIntegerTypeName(field);\n    case FieldDescriptor::CPPTYPE_INT64:\n      return JSIntegerTypeName(field);\n    case FieldDescriptor::CPPTYPE_UINT32:\n      return JSIntegerTypeName(field);\n    case FieldDescriptor::CPPTYPE_UINT64:\n      return JSIntegerTypeName(field);\n    case FieldDescriptor::CPPTYPE_FLOAT:\n      return \"number\";\n    case FieldDescriptor::CPPTYPE_DOUBLE:\n      return \"number\";\n    case FieldDescriptor::CPPTYPE_STRING:\n      return JSStringTypeName(options, field, bytes_mode);\n    case FieldDescriptor::CPPTYPE_ENUM:\n      return GetPath(options, field->enum_type());\n    case FieldDescriptor::CPPTYPE_MESSAGE:\n      return GetPath(options, field->message_type());\n    default:\n      return \"\";\n  }\n}\n\nbool HasFieldPresence(const FieldDescriptor* field);\n\nstring JSFieldTypeAnnotation(const GeneratorOptions& options,\n                             const FieldDescriptor* field,\n                             bool force_optional,\n                             bool force_present,\n                             bool singular_if_not_packed,\n                             BytesMode bytes_mode = BYTES_DEFAULT) {\n  bool is_primitive =\n      (field->cpp_type() != FieldDescriptor::CPPTYPE_ENUM &&\n       field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE &&\n        (field->type() != FieldDescriptor::TYPE_BYTES ||\n            bytes_mode == BYTES_B64));\n\n  string jstype = JSTypeName(options, field, bytes_mode);\n\n  if (field->is_repeated() &&\n      (field->is_packed() || !singular_if_not_packed)) {\n    if (field->type() == FieldDescriptor::TYPE_BYTES &&\n        bytes_mode == BYTES_DEFAULT) {\n      jstype = \"(Array<!Uint8Array>|Array<string>)\";\n    } else {\n      if (!is_primitive) {\n        jstype = \"!\" + jstype;\n      }\n      jstype = \"Array.<\" + jstype + \">\";\n    }\n    if (!force_optional) {\n      jstype = \"!\" + jstype;\n    }\n  }\n\n  if (field->is_optional() && is_primitive &&\n      force_optional && !force_present) {\n    jstype += \"?\";\n  } else if (field->is_required() && !is_primitive && !force_optional) {\n    jstype = \"!\" + jstype;\n  }\n\n  if (force_optional && HasFieldPresence(field)) {\n    jstype += \"|undefined\";\n  }\n  if (force_present && jstype[0] != '!' && !is_primitive) {\n    jstype = \"!\" + jstype;\n  }\n\n  return jstype;\n}\n\nstring JSBinaryReaderMethodType(const FieldDescriptor* field) {\n  string name = field->type_name();\n  if (name[0] >= 'a' && name[0] <= 'z') {\n    name[0] = (name[0] - 'a') + 'A';\n  }\n\n  return name;\n}\n\nstring JSBinaryReadWriteMethodName(const FieldDescriptor* field,\n                                   bool is_writer) {\n  string name = JSBinaryReaderMethodType(field);\n  if (field->is_packed()) {\n    name = \"Packed\" + name;\n  } else if (is_writer && field->is_repeated()) {\n    name = \"Repeated\" + name;\n  }\n  return name;\n}\n\nstring JSBinaryReaderMethodName(const GeneratorOptions& options,\n                                const FieldDescriptor* field) {\n  if (options.binary) {\n    return \"jspb.BinaryReader.prototype.read\" +\n           JSBinaryReadWriteMethodName(field, /* is_writer = */ false);\n  } else {\n    return \"null\";\n  }\n}\n\nstring JSBinaryWriterMethodName(const GeneratorOptions& options,\n                                const FieldDescriptor* field) {\n  if (options.binary) {\n    return \"jspb.BinaryWriter.prototype.write\" +\n           JSBinaryReadWriteMethodName(field, /* is_writer = */ true);\n  } else {\n    return \"null\";\n  }\n}\n\nstring JSReturnClause(const FieldDescriptor* desc) {\n  return \"\";\n}\n\nstring JSReturnDoc(const GeneratorOptions& options,\n                   const FieldDescriptor* desc) {\n  return \"\";\n}\n\nbool HasRepeatedFields(const Descriptor* desc) {\n  for (int i = 0; i < desc->field_count(); i++) {\n    if (desc->field(i)->is_repeated() && !desc->field(i)->is_map()) {\n      return true;\n    }\n  }\n  return false;\n}\n\nstatic const char* kRepeatedFieldArrayName = \".repeatedFields_\";\n\nstring RepeatedFieldsArrayName(const GeneratorOptions& options,\n                               const Descriptor* desc) {\n  return HasRepeatedFields(desc) ?\n      (GetPath(options, desc) + kRepeatedFieldArrayName) : \"null\";\n}\n\nbool HasOneofFields(const Descriptor* desc) {\n  for (int i = 0; i < desc->field_count(); i++) {\n    if (desc->field(i)->containing_oneof()) {\n      return true;\n    }\n  }\n  return false;\n}\n\nstatic const char* kOneofGroupArrayName = \".oneofGroups_\";\n\nstring OneofFieldsArrayName(const GeneratorOptions& options,\n                            const Descriptor* desc) {\n  return HasOneofFields(desc) ?\n      (GetPath(options, desc) + kOneofGroupArrayName) : \"null\";\n}\n\nstring RepeatedFieldNumberList(const Descriptor* desc) {\n  std::vector<string> numbers;\n  for (int i = 0; i < desc->field_count(); i++) {\n    if (desc->field(i)->is_repeated() && !desc->field(i)->is_map()) {\n      numbers.push_back(JSFieldIndex(desc->field(i)));\n    }\n  }\n  return \"[\" + Join(numbers, \",\") + \"]\";\n}\n\nstring OneofGroupList(const Descriptor* desc) {\n  // List of arrays (one per oneof), each of which is a list of field indices\n  std::vector<string> oneof_entries;\n  for (int i = 0; i < desc->oneof_decl_count(); i++) {\n    const OneofDescriptor* oneof = desc->oneof_decl(i);\n    if (IgnoreOneof(oneof)) {\n      continue;\n    }\n\n    std::vector<string> oneof_fields;\n    for (int j = 0; j < oneof->field_count(); j++) {\n      if (IgnoreField(oneof->field(j))) {\n        continue;\n      }\n      oneof_fields.push_back(JSFieldIndex(oneof->field(j)));\n    }\n    oneof_entries.push_back(\"[\" + Join(oneof_fields, \",\") + \"]\");\n  }\n  return \"[\" + Join(oneof_entries, \",\") + \"]\";\n}\n\nstring JSOneofArray(const GeneratorOptions& options,\n                    const FieldDescriptor* field) {\n  return OneofFieldsArrayName(options, field->containing_type()) + \"[\" +\n      JSOneofIndex(field->containing_oneof()) + \"]\";\n}\n\nstring RelativeTypeName(const FieldDescriptor* field) {\n  assert(field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM ||\n         field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE);\n  // For a field with an enum or message type, compute a name relative to the\n  // path name of the message type containing this field.\n  string package = field->file()->package();\n  string containing_type = field->containing_type()->full_name() + \".\";\n  string type = (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) ?\n      field->enum_type()->full_name() : field->message_type()->full_name();\n\n  // |prefix| is advanced as we find separators '.' past the common package\n  // prefix that yield common prefixes in the containing type's name and this\n  // type's name.\n  int prefix = 0;\n  for (int i = 0; i < type.size() && i < containing_type.size(); i++) {\n    if (type[i] != containing_type[i]) {\n      break;\n    }\n    if (type[i] == '.' && i >= package.size()) {\n      prefix = i + 1;\n    }\n  }\n\n  return type.substr(prefix);\n}\n\nstring JSExtensionsObjectName(const GeneratorOptions& options,\n                              const FileDescriptor* from_file,\n                              const Descriptor* desc) {\n  if (desc->full_name() == \"google.protobuf.bridge.MessageSet\") {\n    // TODO(haberman): fix this for the IMPORT_COMMONJS case.\n    return \"jspb.Message.messageSetExtensions\";\n  } else {\n    return MaybeCrossFileRef(options, from_file, desc) + \".extensions\";\n  }\n}\n\nstatic const int kMapKeyField = 1;\nstatic const int kMapValueField = 2;\n\nconst FieldDescriptor* MapFieldKey(const FieldDescriptor* field) {\n  assert(field->is_map());\n  return field->message_type()->FindFieldByNumber(kMapKeyField);\n}\n\nconst FieldDescriptor* MapFieldValue(const FieldDescriptor* field) {\n  assert(field->is_map());\n  return field->message_type()->FindFieldByNumber(kMapValueField);\n}\n\nstring FieldDefinition(const GeneratorOptions& options,\n                       const FieldDescriptor* field) {\n  if (field->is_map()) {\n    const FieldDescriptor* key_field = MapFieldKey(field);\n    const FieldDescriptor* value_field = MapFieldValue(field);\n    string key_type = ProtoTypeName(options, key_field);\n    string value_type;\n    if (value_field->type() == FieldDescriptor::TYPE_ENUM ||\n        value_field->type() == FieldDescriptor::TYPE_MESSAGE) {\n      value_type = RelativeTypeName(value_field);\n    } else {\n      value_type = ProtoTypeName(options, value_field);\n    }\n    return StringPrintf(\"map<%s, %s> %s = %d;\",\n                        key_type.c_str(),\n                        value_type.c_str(),\n                        field->name().c_str(),\n                        field->number());\n  } else {\n    string qualifier = field->is_repeated() ? \"repeated\" :\n        (field->is_optional() ? \"optional\" : \"required\");\n    string type, name;\n    if (field->type() == FieldDescriptor::TYPE_ENUM ||\n        field->type() == FieldDescriptor::TYPE_MESSAGE) {\n      type = RelativeTypeName(field);\n      name = field->name();\n    } else if (field->type() == FieldDescriptor::TYPE_GROUP) {\n      type = \"group\";\n      name = field->message_type()->name();\n    } else {\n      type = ProtoTypeName(options, field);\n      name = field->name();\n    }\n    return StringPrintf(\"%s %s %s = %d;\",\n                        qualifier.c_str(),\n                        type.c_str(),\n                        name.c_str(),\n                        field->number());\n  }\n}\n\nstring FieldComments(const FieldDescriptor* field, BytesMode bytes_mode) {\n  string comments;\n  if (field->cpp_type() == FieldDescriptor::CPPTYPE_BOOL) {\n    comments +=\n        \" * Note that Boolean fields may be set to 0/1 when serialized from \"\n        \"a Java server.\\n\"\n        \" * You should avoid comparisons like {@code val === true/false} in \"\n        \"those cases.\\n\";\n  }\n  if (field->is_repeated()) {\n    comments +=\n        \" * If you change this array by adding, removing or replacing \"\n        \"elements, or if you\\n\"\n        \" * replace the array itself, then you must call the setter to \"\n        \"update it.\\n\";\n  }\n  if (field->type() == FieldDescriptor::TYPE_BYTES && bytes_mode == BYTES_U8) {\n    comments +=\n        \" * Note that Uint8Array is not supported on all browsers.\\n\"\n        \" * @see http://caniuse.com/Uint8Array\\n\";\n  }\n  return comments;\n}\n\nbool ShouldGenerateExtension(const FieldDescriptor* field) {\n  return\n      field->is_extension() &&\n      !IgnoreField(field);\n}\n\nbool HasExtensions(const Descriptor* desc) {\n  for (int i = 0; i < desc->extension_count(); i++) {\n    if (ShouldGenerateExtension(desc->extension(i))) {\n      return true;\n    }\n  }\n  for (int i = 0; i < desc->nested_type_count(); i++) {\n    if (HasExtensions(desc->nested_type(i))) {\n      return true;\n    }\n  }\n  return false;\n}\n\nbool HasExtensions(const FileDescriptor* file) {\n  for (int i = 0; i < file->extension_count(); i++) {\n    if (ShouldGenerateExtension(file->extension(i))) {\n      return true;\n    }\n  }\n  for (int i = 0; i < file->message_type_count(); i++) {\n    if (HasExtensions(file->message_type(i))) {\n      return true;\n    }\n  }\n  return false;\n}\n\nbool IsExtendable(const Descriptor* desc) {\n  return desc->extension_range_count() > 0;\n}\n\n// Returns the max index in the underlying data storage array beyond which the\n// extension object is used.\nstring GetPivot(const Descriptor* desc) {\n  static const int kDefaultPivot = (1 << 29);  // max field number (29 bits)\n\n  // Find the max field number\n  int max_field_number = 0;\n  for (int i = 0; i < desc->field_count(); i++) {\n    if (!IgnoreField(desc->field(i)) &&\n        desc->field(i)->number() > max_field_number) {\n      max_field_number = desc->field(i)->number();\n    }\n  }\n\n  int pivot = -1;\n  if (IsExtendable(desc)) {\n    pivot = ((max_field_number + 1) < kDefaultPivot) ?\n        (max_field_number + 1) : kDefaultPivot;\n  }\n\n  return SimpleItoa(pivot);\n}\n\n// Returns true for fields that represent \"null\" as distinct from the default\n// value. See http://go/proto3#heading=h.kozewqqcqhuz for more information.\nbool HasFieldPresence(const FieldDescriptor* field) {\n  if (field->is_repeated()) {\n    return false;\n  }\n\n  return\n      (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) ||\n      (field->containing_oneof() != NULL) ||\n      (field->file()->syntax() != FileDescriptor::SYNTAX_PROTO3);\n}\n\n// For proto3 fields without presence, returns a string representing the default\n// value in JavaScript. See http://go/proto3#heading=h.kozewqqcqhuz for more\n// information.\nstring Proto3PrimitiveFieldDefault(const FieldDescriptor* field) {\n  switch (field->cpp_type()) {\n    case FieldDescriptor::CPPTYPE_INT32:\n    case FieldDescriptor::CPPTYPE_INT64:\n    case FieldDescriptor::CPPTYPE_UINT32:\n    case FieldDescriptor::CPPTYPE_UINT64: {\n      return \"0\";\n    }\n\n    case FieldDescriptor::CPPTYPE_ENUM:\n    case FieldDescriptor::CPPTYPE_FLOAT:\n    case FieldDescriptor::CPPTYPE_DOUBLE:\n      return \"0\";\n\n    case FieldDescriptor::CPPTYPE_BOOL:\n      return \"false\";\n\n    case FieldDescriptor::CPPTYPE_STRING:  // includes BYTES\n      return \"\\\"\\\"\";\n\n    default:\n      // MESSAGE is handled separately.\n      assert(false);\n      return \"\";\n  }\n}\n\n// We use this to implement the semantics that same file can be generated\n// multiple times, but the last one wins.  We never actually write the files,\n// but we keep a set of which descriptors were the final one for a given\n// filename.\nclass FileDeduplicator {\n public:\n  explicit FileDeduplicator(const GeneratorOptions& options)\n      : error_on_conflict_(options.error_on_name_conflict) {}\n\n  bool AddFile(const string& filename, const void* desc, string* error) {\n    if (descs_by_filename_.find(filename) != descs_by_filename_.end()) {\n      if (error_on_conflict_) {\n        *error = \"Name conflict: file name \" + filename +\n                 \" would be generated by two descriptors\";\n        return false;\n      }\n      allowed_descs_.erase(descs_by_filename_[filename]);\n    }\n\n    descs_by_filename_[filename] = desc;\n    allowed_descs_.insert(desc);\n    return true;\n  }\n\n  void GetAllowedSet(set<const void*>* allowed_set) {\n    *allowed_set = allowed_descs_;\n  }\n\n private:\n  bool error_on_conflict_;\n  map<string, const void*> descs_by_filename_;\n  set<const void*> allowed_descs_;\n};\n\nvoid DepthFirstSearch(const FileDescriptor* file,\n                      vector<const FileDescriptor*>* list,\n                      set<const FileDescriptor*>* seen) {\n  if (!seen->insert(file).second) {\n    return;\n  }\n\n  // Add all dependencies.\n  for (int i = 0; i < file->dependency_count(); i++) {\n    DepthFirstSearch(file->dependency(i), list, seen);\n  }\n\n  // Add this file.\n  list->push_back(file);\n}\n\n// A functor for the predicate to remove_if() below.  Returns true if a given\n// FileDescriptor is not in the given set.\nclass NotInSet {\n public:\n  explicit NotInSet(const set<const FileDescriptor*>& file_set)\n      : file_set_(file_set) {}\n\n  bool operator()(const FileDescriptor* file) {\n    return file_set_.count(file) == 0;\n  }\n\n private:\n  const set<const FileDescriptor*>& file_set_;\n};\n\n// This function generates an ordering of the input FileDescriptors that matches\n// the logic of the old code generator.  The order is significant because two\n// different input files can generate the same output file, and the last one\n// needs to win.\nvoid GenerateJspbFileOrder(const vector<const FileDescriptor*>& input,\n                           vector<const FileDescriptor*>* ordered) {\n  // First generate an ordering of all reachable files (including dependencies)\n  // with depth-first search.  This mimics the behavior of --include_imports,\n  // which is what the old codegen used.\n  ordered->clear();\n  set<const FileDescriptor*> seen;\n  set<const FileDescriptor*> input_set;\n  for (int i = 0; i < input.size(); i++) {\n    DepthFirstSearch(input[i], ordered, &seen);\n    input_set.insert(input[i]);\n  }\n\n  // Now remove the entries that are not actually in our input list.\n  ordered->erase(\n      std::remove_if(ordered->begin(), ordered->end(), NotInSet(input_set)),\n      ordered->end());\n}\n\n// If we're generating code in file-per-type mode, avoid overwriting files\n// by choosing the last descriptor that writes each filename and permitting\n// only those to generate code.\n\nbool GenerateJspbAllowedSet(const GeneratorOptions& options,\n                            const vector<const FileDescriptor*>& files,\n                            set<const void*>* allowed_set,\n                            string* error) {\n  vector<const FileDescriptor*> files_ordered;\n  GenerateJspbFileOrder(files, &files_ordered);\n\n  // Choose the last descriptor for each filename.\n  FileDeduplicator dedup(options);\n  for (int i = 0; i < files_ordered.size(); i++) {\n    for (int j = 0; j < files_ordered[i]->message_type_count(); j++) {\n      const Descriptor* desc = files_ordered[i]->message_type(j);\n      if (!dedup.AddFile(GetMessageFileName(options, desc), desc, error)) {\n        return false;\n      }\n    }\n    for (int j = 0; j < files_ordered[i]->enum_type_count(); j++) {\n      const EnumDescriptor* desc = files_ordered[i]->enum_type(j);\n      if (!dedup.AddFile(GetEnumFileName(options, desc), desc, error)) {\n        return false;\n      }\n    }\n\n    // Pull out all free-floating extensions and generate files for those too.\n    bool has_extension = false;\n\n    for (int j = 0; j < files_ordered[i]->extension_count(); j++) {\n      if (ShouldGenerateExtension(files_ordered[i]->extension(j))) {\n        has_extension = true;\n      }\n    }\n\n    if (has_extension) {\n      if (!dedup.AddFile(GetExtensionFileName(options, files_ordered[i]),\n                         files_ordered[i], error)) {\n        return false;\n      }\n    }\n  }\n\n  dedup.GetAllowedSet(allowed_set);\n\n  return true;\n}\n\n}  // anonymous namespace\n\nvoid Generator::GenerateHeader(const GeneratorOptions& options,\n                               io::Printer* printer) const {\n  printer->Print(\"/**\\n\"\n                 \" * @fileoverview\\n\"\n                 \" * @enhanceable\\n\"\n                 \" * @public\\n\"\n                 \" */\\n\"\n                 \"// GENERATED CODE -- DO NOT EDIT!\\n\"\n                 \"\\n\");\n}\n\nvoid Generator::FindProvidesForFile(const GeneratorOptions& options,\n                                    io::Printer* printer,\n                                    const FileDescriptor* file,\n                                    std::set<string>* provided) const {\n  for (int i = 0; i < file->message_type_count(); i++) {\n    FindProvidesForMessage(options, printer, file->message_type(i), provided);\n  }\n  for (int i = 0; i < file->enum_type_count(); i++) {\n    FindProvidesForEnum(options, printer, file->enum_type(i), provided);\n  }\n}\n\nvoid Generator::FindProvides(const GeneratorOptions& options,\n                             io::Printer* printer,\n                             const vector<const FileDescriptor*>& files,\n                             std::set<string>* provided) const {\n  for (int i = 0; i < files.size(); i++) {\n    FindProvidesForFile(options, printer, files[i], provided);\n  }\n\n  printer->Print(\"\\n\");\n}\n\nvoid Generator::FindProvidesForMessage(\n    const GeneratorOptions& options,\n    io::Printer* printer,\n    const Descriptor* desc,\n    std::set<string>* provided) const {\n  if (IgnoreMessage(options, desc)) {\n    return;\n  }\n\n  string name = GetPath(options, desc);\n  provided->insert(name);\n\n  for (int i = 0; i < desc->enum_type_count(); i++) {\n    FindProvidesForEnum(options, printer, desc->enum_type(i),\n                        provided);\n  }\n  for (int i = 0; i < desc->nested_type_count(); i++) {\n    FindProvidesForMessage(options, printer, desc->nested_type(i),\n                           provided);\n  }\n}\n\nvoid Generator::FindProvidesForEnum(const GeneratorOptions& options,\n                                    io::Printer* printer,\n                                    const EnumDescriptor* enumdesc,\n                                    std::set<string>* provided) const {\n  string name = GetPath(options, enumdesc);\n  provided->insert(name);\n}\n\nvoid Generator::FindProvidesForFields(\n    const GeneratorOptions& options,\n    io::Printer* printer,\n    const vector<const FieldDescriptor*>& fields,\n    std::set<string>* provided) const {\n  for (int i = 0; i < fields.size(); i++) {\n    const FieldDescriptor* field = fields[i];\n\n    if (IgnoreField(field)) {\n      continue;\n    }\n\n    string name =\n        GetPath(options, field->file()) + \".\" +\n        JSObjectFieldName(options, field);\n    provided->insert(name);\n  }\n}\n\nvoid Generator::GenerateProvides(const GeneratorOptions& options,\n                                 io::Printer* printer,\n                                 std::set<string>* provided) const {\n  for (std::set<string>::iterator it = provided->begin();\n       it != provided->end(); ++it) {\n    printer->Print(\"goog.provide('$name$');\\n\",\n                   \"name\", *it);\n  }\n}\n\nvoid Generator::GenerateRequiresForMessage(const GeneratorOptions& options,\n                                           io::Printer* printer,\n                                           const Descriptor* desc,\n                                           std::set<string>* provided) const {\n  std::set<string> required;\n  std::set<string> forwards;\n  bool have_message = false;\n  FindRequiresForMessage(options, desc,\n                         &required, &forwards, &have_message);\n\n  GenerateRequiresImpl(options, printer, &required, &forwards, provided,\n                       /* require_jspb = */ have_message,\n                       /* require_extension = */ HasExtensions(desc));\n}\n\nvoid Generator::GenerateRequiresForLibrary(\n    const GeneratorOptions& options, io::Printer* printer,\n    const vector<const FileDescriptor*>& files,\n    std::set<string>* provided) const {\n  GOOGLE_CHECK_EQ(options.import_style, GeneratorOptions::IMPORT_CLOSURE);\n  // For Closure imports we need to import every message type individually.\n  std::set<string> required;\n  std::set<string> forwards;\n  bool have_extensions = false;\n  bool have_message = false;\n\n  for (int i = 0; i < files.size(); i++) {\n    for (int j = 0; j < files[i]->message_type_count(); j++) {\n      const Descriptor* desc = files[i]->message_type(j);\n      if (!IgnoreMessage(options, desc)) {\n        FindRequiresForMessage(options, desc, &required, &forwards,\n                               &have_message);\n      }\n    }\n\n    if (!have_extensions && HasExtensions(files[i])) {\n      have_extensions = true;\n    }\n\n    for (int j = 0; j < files[i]->extension_count(); j++) {\n      const FieldDescriptor* extension = files[i]->extension(j);\n      if (IgnoreField(extension)) {\n        continue;\n      }\n      if (extension->containing_type()->full_name() !=\n        \"google.protobuf.bridge.MessageSet\") {\n        required.insert(GetPath(options, extension->containing_type()));\n      }\n      FindRequiresForField(options, extension, &required, &forwards);\n      have_extensions = true;\n    }\n  }\n\n  GenerateRequiresImpl(options, printer, &required, &forwards, provided,\n                       /* require_jspb = */ have_message,\n                       /* require_extension = */ have_extensions);\n}\n\nvoid Generator::GenerateRequiresForExtensions(\n    const GeneratorOptions& options, io::Printer* printer,\n    const vector<const FieldDescriptor*>& fields,\n    std::set<string>* provided) const {\n  std::set<string> required;\n  std::set<string> forwards;\n  for (int i = 0; i < fields.size(); i++) {\n    const FieldDescriptor* field = fields[i];\n    if (IgnoreField(field)) {\n      continue;\n    }\n    FindRequiresForExtension(options, field, &required, &forwards);\n  }\n\n  GenerateRequiresImpl(options, printer, &required, &forwards, provided,\n                       /* require_jspb = */ false,\n                       /* require_extension = */ fields.size() > 0);\n}\n\nvoid Generator::GenerateRequiresImpl(const GeneratorOptions& options,\n                                     io::Printer* printer,\n                                     std::set<string>* required,\n                                     std::set<string>* forwards,\n                                     std::set<string>* provided,\n                                     bool require_jspb,\n                                     bool require_extension) const {\n  if (require_jspb) {\n    printer->Print(\n        \"goog.require('jspb.Message');\\n\");\n    if (options.binary) {\n      printer->Print(\n          \"goog.require('jspb.BinaryReader');\\n\"\n          \"goog.require('jspb.BinaryWriter');\\n\");\n    }\n  }\n  if (require_extension) {\n    printer->Print(\n        \"goog.require('jspb.ExtensionFieldInfo');\\n\");\n  }\n\n  std::set<string>::iterator it;\n  for (it = required->begin(); it != required->end(); ++it) {\n    if (provided->find(*it) != provided->end()) {\n      continue;\n    }\n    printer->Print(\"goog.require('$name$');\\n\",\n                   \"name\", *it);\n  }\n\n  printer->Print(\"\\n\");\n\n  for (it = forwards->begin(); it != forwards->end(); ++it) {\n    if (provided->find(*it) != provided->end()) {\n      continue;\n    }\n    printer->Print(\"goog.forwardDeclare('$name$');\\n\",\n                   \"name\", *it);\n  }\n}\n\nbool NamespaceOnly(const Descriptor* desc) {\n  return false;\n}\n\nvoid Generator::FindRequiresForMessage(\n    const GeneratorOptions& options,\n    const Descriptor* desc,\n    std::set<string>* required,\n    std::set<string>* forwards,\n    bool* have_message) const {\n\n\n  if (!NamespaceOnly(desc)) {\n    *have_message = true;\n    for (int i = 0; i < desc->field_count(); i++) {\n      const FieldDescriptor* field = desc->field(i);\n      if (IgnoreField(field)) {\n        continue;\n      }\n      FindRequiresForField(options, field, required, forwards);\n    }\n  }\n\n  for (int i = 0; i < desc->extension_count(); i++) {\n    const FieldDescriptor* field = desc->extension(i);\n    if (IgnoreField(field)) {\n      continue;\n    }\n    FindRequiresForExtension(options, field, required, forwards);\n  }\n\n  for (int i = 0; i < desc->nested_type_count(); i++) {\n    FindRequiresForMessage(options, desc->nested_type(i), required, forwards,\n                           have_message);\n  }\n}\n\nvoid Generator::FindRequiresForField(const GeneratorOptions& options,\n                                     const FieldDescriptor* field,\n                                     std::set<string>* required,\n                                     std::set<string>* forwards) const {\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM &&\n        // N.B.: file-level extensions with enum type do *not* create\n        // dependencies, as per original codegen.\n        !(field->is_extension() && field->extension_scope() == NULL)) {\n      if (options.add_require_for_enums) {\n        required->insert(GetPath(options, field->enum_type()));\n      } else {\n        forwards->insert(GetPath(options, field->enum_type()));\n      }\n    } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n      if (!IgnoreMessage(options, field->message_type())) {\n        required->insert(GetPath(options, field->message_type()));\n      }\n    }\n}\n\nvoid Generator::FindRequiresForExtension(const GeneratorOptions& options,\n                                         const FieldDescriptor* field,\n                                         std::set<string>* required,\n                                         std::set<string>* forwards) const {\n    if (field->containing_type()->full_name() != \"google.protobuf.bridge.MessageSet\") {\n      required->insert(GetPath(options, field->containing_type()));\n    }\n    FindRequiresForField(options, field, required, forwards);\n}\n\nvoid Generator::GenerateTestOnly(const GeneratorOptions& options,\n                                 io::Printer* printer) const {\n  if (options.testonly) {\n    printer->Print(\"goog.setTestOnly();\\n\\n\");\n  }\n  printer->Print(\"\\n\");\n}\n\nvoid Generator::GenerateClassesAndEnums(const GeneratorOptions& options,\n                                        io::Printer* printer,\n                                        const FileDescriptor* file) const {\n  for (int i = 0; i < file->message_type_count(); i++) {\n    GenerateClass(options, printer, file->message_type(i));\n  }\n  for (int i = 0; i < file->enum_type_count(); i++) {\n    GenerateEnum(options, printer, file->enum_type(i));\n  }\n}\n\nvoid Generator::GenerateClass(const GeneratorOptions& options,\n                              io::Printer* printer,\n                              const Descriptor* desc) const {\n  if (IgnoreMessage(options, desc)) {\n    return;\n  }\n\n  if (!NamespaceOnly(desc)) {\n    printer->Print(\"\\n\");\n    GenerateClassConstructor(options, printer, desc);\n    GenerateClassFieldInfo(options, printer, desc);\n\n\n    GenerateClassToObject(options, printer, desc);\n    if (options.binary) {\n      // These must come *before* the extension-field info generation in\n      // GenerateClassRegistration so that references to the binary\n      // serialization/deserialization functions may be placed in the extension\n      // objects.\n      GenerateClassDeserializeBinary(options, printer, desc);\n      GenerateClassSerializeBinary(options, printer, desc);\n    }\n    GenerateClassClone(options, printer, desc);\n    GenerateClassRegistration(options, printer, desc);\n    GenerateClassFields(options, printer, desc);\n    if (IsExtendable(desc) && desc->full_name() != \"google.protobuf.bridge.MessageSet\") {\n      GenerateClassExtensionFieldInfo(options, printer, desc);\n    }\n\n    if (options.import_style != GeneratorOptions:: IMPORT_CLOSURE) {\n      for (int i = 0; i < desc->extension_count(); i++) {\n        GenerateExtension(options, printer, desc->extension(i));\n      }\n    }\n  }\n\n  // Recurse on nested types.\n  for (int i = 0; i < desc->enum_type_count(); i++) {\n    GenerateEnum(options, printer, desc->enum_type(i));\n  }\n  for (int i = 0; i < desc->nested_type_count(); i++) {\n    GenerateClass(options, printer, desc->nested_type(i));\n  }\n}\n\nvoid Generator::GenerateClassConstructor(const GeneratorOptions& options,\n                                         io::Printer* printer,\n                                         const Descriptor* desc) const {\n  printer->Print(\n      \"/**\\n\"\n      \" * Generated by JsPbCodeGenerator.\\n\"\n      \" * @param {Array=} opt_data Optional initial data array, typically \"\n      \"from a\\n\"\n      \" * server response, or constructed directly in Javascript. The array \"\n      \"is used\\n\"\n      \" * in place and becomes part of the constructed object. It is not \"\n      \"cloned.\\n\"\n      \" * If no data is provided, the constructed object will be empty, but \"\n      \"still\\n\"\n      \" * valid.\\n\"\n      \" * @extends {jspb.Message}\\n\"\n      \" * @constructor\\n\"\n      \" */\\n\"\n      \"$classname$ = function(opt_data) {\\n\",\n      \"classname\", GetPath(options, desc));\n  string message_id = GetMessageId(desc);\n  printer->Print(\n      \"  jspb.Message.initialize(this, opt_data, $messageId$, $pivot$, \"\n      \"$rptfields$, $oneoffields$);\\n\",\n      \"messageId\", !message_id.empty() ?\n                   (\"'\" + message_id + \"'\") :\n                   (IsResponse(desc) ? \"''\" : \"0\"),\n      \"pivot\", GetPivot(desc),\n      \"rptfields\", RepeatedFieldsArrayName(options, desc),\n      \"oneoffields\", OneofFieldsArrayName(options, desc));\n  printer->Print(\n      \"};\\n\"\n      \"goog.inherits($classname$, jspb.Message);\\n\"\n      \"if (goog.DEBUG && !COMPILED) {\\n\"\n      \"  $classname$.displayName = '$classname$';\\n\"\n      \"}\\n\",\n      \"classname\", GetPath(options, desc));\n}\n\nvoid Generator::GenerateClassFieldInfo(const GeneratorOptions& options,\n                                       io::Printer* printer,\n                                       const Descriptor* desc) const {\n  if (HasRepeatedFields(desc)) {\n    printer->Print(\n        \"/**\\n\"\n        \" * List of repeated fields within this message type.\\n\"\n        \" * @private {!Array<number>}\\n\"\n        \" * @const\\n\"\n        \" */\\n\"\n        \"$classname$$rptfieldarray$ = $rptfields$;\\n\"\n        \"\\n\",\n        \"classname\", GetPath(options, desc),\n        \"rptfieldarray\", kRepeatedFieldArrayName,\n        \"rptfields\", RepeatedFieldNumberList(desc));\n  }\n\n  if (HasOneofFields(desc)) {\n    printer->Print(\n        \"/**\\n\"\n        \" * Oneof group definitions for this message. Each group defines the \"\n        \"field\\n\"\n        \" * numbers belonging to that group. When of these fields' value is \"\n        \"set, all\\n\"\n        \" * other fields in the group are cleared. During deserialization, if \"\n        \"multiple\\n\"\n        \" * fields are encountered for a group, only the last value seen will \"\n        \"be kept.\\n\"\n        \" * @private {!Array<!Array<number>>}\\n\"\n        \" * @const\\n\"\n        \" */\\n\"\n        \"$classname$$oneofgrouparray$ = $oneofgroups$;\\n\"\n        \"\\n\",\n        \"classname\", GetPath(options, desc),\n        \"oneofgrouparray\", kOneofGroupArrayName,\n        \"oneofgroups\", OneofGroupList(desc));\n\n    for (int i = 0; i < desc->oneof_decl_count(); i++) {\n      if (IgnoreOneof(desc->oneof_decl(i))) {\n        continue;\n      }\n      GenerateOneofCaseDefinition(options, printer, desc->oneof_decl(i));\n    }\n  }\n}\n\nvoid Generator::GenerateClassXid(const GeneratorOptions& options,\n                                 io::Printer* printer,\n                                 const Descriptor* desc) const {\n  printer->Print(\n      \"\\n\"\n      \"\\n\"\n      \"$class$.prototype.messageXid = xid('$class$');\\n\",\n      \"class\", GetPath(options, desc));\n}\n\nvoid Generator::GenerateOneofCaseDefinition(\n    const GeneratorOptions& options,\n    io::Printer* printer,\n    const OneofDescriptor* oneof) const {\n  printer->Print(\n      \"/**\\n\"\n      \" * @enum {number}\\n\"\n      \" */\\n\"\n      \"$classname$.$oneof$Case = {\\n\"\n      \"  $upcase$_NOT_SET: 0\",\n      \"classname\", GetPath(options, oneof->containing_type()),\n      \"oneof\", JSOneofName(oneof),\n      \"upcase\", ToEnumCase(oneof->name()));\n\n  for (int i = 0; i < oneof->field_count(); i++) {\n    if (IgnoreField(oneof->field(i))) {\n      continue;\n    }\n\n    printer->Print(\n        \",\\n\"\n        \"  $upcase$: $number$\",\n        \"upcase\", ToEnumCase(oneof->field(i)->name()),\n        \"number\", JSFieldIndex(oneof->field(i)));\n  }\n\n  printer->Print(\n      \"\\n\"\n      \"};\\n\"\n      \"\\n\"\n      \"/**\\n\"\n      \" * @return {$class$.$oneof$Case}\\n\"\n      \" */\\n\"\n      \"$class$.prototype.get$oneof$Case = function() {\\n\"\n      \"  return /** @type {$class$.$oneof$Case} */(jspb.Message.\"\n      \"computeOneofCase(this, $class$.oneofGroups_[$oneofindex$]));\\n\"\n      \"};\\n\"\n      \"\\n\",\n      \"class\", GetPath(options, oneof->containing_type()),\n      \"oneof\", JSOneofName(oneof),\n      \"oneofindex\", JSOneofIndex(oneof));\n}\n\nvoid Generator::GenerateClassToObject(const GeneratorOptions& options,\n                                      io::Printer* printer,\n                                      const Descriptor* desc) const {\n  printer->Print(\n      \"\\n\"\n      \"\\n\"\n      \"if (jspb.Message.GENERATE_TO_OBJECT) {\\n\"\n      \"/**\\n\"\n      \" * Creates an object representation of this proto suitable for use in \"\n      \"Soy templates.\\n\"\n      \" * Field names that are reserved in JavaScript and will be renamed to \"\n      \"pb_name.\\n\"\n      \" * To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.\\n\"\n      \" * For the list of reserved names please see:\\n\"\n      \" *     com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS.\\n\"\n      \" * @param {boolean=} opt_includeInstance Whether to include the JSPB \"\n      \"instance\\n\"\n      \" *     for transitional soy proto support: http://goto/soy-param-\"\n      \"migration\\n\"\n      \" * @return {!Object}\\n\"\n      \" */\\n\"\n      \"$classname$.prototype.toObject = function(opt_includeInstance) {\\n\"\n      \"  return $classname$.toObject(opt_includeInstance, this);\\n\"\n      \"};\\n\"\n      \"\\n\"\n      \"\\n\"\n      \"/**\\n\"\n      \" * Static version of the {@see toObject} method.\\n\"\n      \" * @param {boolean|undefined} includeInstance Whether to include the \"\n      \"JSPB\\n\"\n      \" *     instance for transitional soy proto support:\\n\"\n      \" *     http://goto/soy-param-migration\\n\"\n      \" * @param {!$classname$} msg The msg instance to transform.\\n\"\n      \" * @return {!Object}\\n\"\n      \" */\\n\"\n      \"$classname$.toObject = function(includeInstance, msg) {\\n\"\n      \"  var f, obj = {\",\n      \"classname\", GetPath(options, desc));\n\n  bool first = true;\n  for (int i = 0; i < desc->field_count(); i++) {\n    const FieldDescriptor* field = desc->field(i);\n    if (IgnoreField(field)) {\n      continue;\n    }\n\n    if (!first) {\n      printer->Print(\",\\n    \");\n    } else {\n      printer->Print(\"\\n    \");\n      first = false;\n    }\n\n    GenerateClassFieldToObject(options, printer, field);\n  }\n\n  if (!first) {\n    printer->Print(\"\\n  };\\n\\n\");\n  } else {\n    printer->Print(\"\\n\\n  };\\n\\n\");\n  }\n\n  if (IsExtendable(desc)) {\n    printer->Print(\n        \"  jspb.Message.toObjectExtension(/** @type {!jspb.Message} */ (msg), \"\n        \"obj,\\n\"\n        \"      $extObject$, $class$.prototype.getExtension,\\n\"\n        \"      includeInstance);\\n\",\n        \"extObject\", JSExtensionsObjectName(options, desc->file(), desc),\n        \"class\", GetPath(options, desc));\n  }\n\n  printer->Print(\n      \"  if (includeInstance) {\\n\"\n      \"    obj.$$jspbMessageInstance = msg;\\n\"\n      \"  }\\n\"\n      \"  return obj;\\n\"\n      \"};\\n\"\n      \"}\\n\"\n      \"\\n\"\n      \"\\n\",\n      \"classname\", GetPath(options, desc));\n}\n\nvoid Generator::GenerateClassFieldToObject(const GeneratorOptions& options,\n                                           io::Printer* printer,\n                                           const FieldDescriptor* field) const {\n  printer->Print(\"$fieldname$: \",\n                 \"fieldname\", JSObjectFieldName(options, field));\n\n  if (field->is_map()) {\n    printer->Print(\"(f = msg.get$name$(true)) ? f.toArray() : []\",\n                   \"name\", JSGetterName(options, field));\n  } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n    // Message field.\n    if (field->is_repeated()) {\n      {\n        printer->Print(\"jspb.Message.toObjectList(msg.get$getter$(),\\n\"\n                       \"    $type$.toObject, includeInstance)\",\n                       \"getter\", JSGetterName(options, field),\n                       \"type\", SubmessageTypeRef(options, field));\n      }\n    } else {\n      printer->Print(\"(f = msg.get$getter$()) && \"\n                     \"$type$.toObject(includeInstance, f)\",\n                     \"getter\", JSGetterName(options, field),\n                     \"type\", SubmessageTypeRef(options, field));\n    }\n  } else {\n    // Simple field (singular or repeated).\n    if ((!HasFieldPresence(field) && !field->is_repeated()) ||\n        field->type() == FieldDescriptor::TYPE_BYTES) {\n      // Delegate to the generated get<field>() method in order not to duplicate\n      // the proto3-field-default-value or byte-coercion logic here.\n      printer->Print(\"msg.get$getter$()\",\n                     \"getter\", JSGetterName(options, field, BYTES_B64));\n    } else {\n      if (field->has_default_value()) {\n        printer->Print(\"!msg.has$name$() ? $defaultValue$ : \",\n                       \"name\", JSGetterName(options, field),\n                       \"defaultValue\", JSFieldDefault(field));\n      }\n      if (field->cpp_type() == FieldDescriptor::CPPTYPE_FLOAT ||\n          field->cpp_type() == FieldDescriptor::CPPTYPE_DOUBLE) {\n        if (field->is_repeated()) {\n          printer->Print(\"jspb.Message.getRepeatedFloatingPointField(\"\n                         \"msg, $index$)\",\n                         \"index\", JSFieldIndex(field));\n        } else if (field->is_optional() && !field->has_default_value()) {\n          printer->Print(\"jspb.Message.getOptionalFloatingPointField(\"\n                         \"msg, $index$)\",\n                         \"index\", JSFieldIndex(field));\n        } else {\n          // Convert \"NaN\" to NaN.\n          printer->Print(\"+jspb.Message.getField(msg, $index$)\",\n                         \"index\", JSFieldIndex(field));\n        }\n      } else {\n        printer->Print(\"jspb.Message.getField(msg, $index$)\",\n                       \"index\", JSFieldIndex(field));\n      }\n    }\n  }\n}\n\nvoid Generator::GenerateClassFromObject(const GeneratorOptions& options,\n                                        io::Printer* printer,\n                                        const Descriptor* desc) const {\n  printer->Print(\n      \"if (jspb.Message.GENERATE_FROM_OBJECT) {\\n\"\n      \"/**\\n\"\n      \" * Loads data from an object into a new instance of this proto.\\n\"\n      \" * @param {!Object} obj The object representation of this proto to\\n\"\n      \" *     load the data from.\\n\"\n      \" * @return {!$classname$}\\n\"\n      \" */\\n\"\n      \"$classname$.fromObject = function(obj) {\\n\"\n      \"  var f, msg = new $classname$();\\n\",\n      \"classname\", GetPath(options, desc));\n\n  for (int i = 0; i < desc->field_count(); i++) {\n    const FieldDescriptor* field = desc->field(i);\n    GenerateClassFieldFromObject(options, printer, field);\n  }\n\n  printer->Print(\n      \"  return msg;\\n\"\n      \"};\\n\"\n      \"}\\n\");\n}\n\nvoid Generator::GenerateClassFieldFromObject(\n    const GeneratorOptions& options,\n    io::Printer* printer,\n    const FieldDescriptor* field) const {\n\n  if (field->is_map()) {\n    // `msg` is a newly-constructed message object that has not yet built any\n    // map containers wrapping underlying arrays, so we can simply directly set\n    // the array here without fear of a stale wrapper.\n    printer->Print(\n        \"  goog.isDef(obj.$name$) && \"\n        \"jspb.Message.setField(msg, $index$, obj.$name$);\\n\",\n        \"name\", JSObjectFieldName(options, field),\n        \"index\", JSFieldIndex(field));\n  } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n    // Message field (singular or repeated)\n    if (field->is_repeated()) {\n      {\n        printer->Print(\n            \"  goog.isDef(obj.$name$) && \"\n            \"jspb.Message.setRepeatedWrapperField(\\n\"\n            \"      msg, $index$, goog.array.map(obj.$name$, function(i) {\\n\"\n            \"        return $fieldclass$.fromObject(i);\\n\"\n            \"      }));\\n\",\n            \"name\", JSObjectFieldName(options, field),\n            \"index\", JSFieldIndex(field),\n            \"fieldclass\", SubmessageTypeRef(options, field));\n      }\n    } else {\n      printer->Print(\n          \"  goog.isDef(obj.$name$) && jspb.Message.setWrapperField(\\n\"\n          \"      msg, $index$, $fieldclass$.fromObject(obj.$name$));\\n\",\n          \"name\", JSObjectFieldName(options, field),\n          \"index\", JSFieldIndex(field),\n          \"fieldclass\", SubmessageTypeRef(options, field));\n    }\n  } else {\n    // Simple (primitive) field.\n    printer->Print(\n        \"  goog.isDef(obj.$name$) && jspb.Message.setField(msg, $index$, \"\n        \"obj.$name$);\\n\",\n        \"name\", JSObjectFieldName(options, field),\n        \"index\", JSFieldIndex(field));\n  }\n}\n\nvoid Generator::GenerateClassClone(const GeneratorOptions& options,\n                                   io::Printer* printer,\n                                   const Descriptor* desc) const {\n  printer->Print(\n      \"/**\\n\"\n      \" * Creates a deep clone of this proto. No data is shared with the \"\n      \"original.\\n\"\n      \" * @return {!$name$} The clone.\\n\"\n      \" */\\n\"\n      \"$name$.prototype.cloneMessage = function() {\\n\"\n      \"  return /** @type {!$name$} */ (jspb.Message.cloneMessage(this));\\n\"\n      \"};\\n\\n\\n\",\n      \"name\", GetPath(options, desc));\n}\n\nvoid Generator::GenerateClassRegistration(const GeneratorOptions& options,\n                                          io::Printer* printer,\n                                          const Descriptor* desc) const {\n  // Register any extensions defined inside this message type.\n  for (int i = 0; i < desc->extension_count(); i++) {\n    const FieldDescriptor* extension = desc->extension(i);\n    if (ShouldGenerateExtension(extension)) {\n      GenerateExtension(options, printer, extension);\n    }\n  }\n\n}\n\nvoid Generator::GenerateClassFields(const GeneratorOptions& options,\n                                    io::Printer* printer,\n                                    const Descriptor* desc) const {\n  for (int i = 0; i < desc->field_count(); i++) {\n    if (!IgnoreField(desc->field(i))) {\n      GenerateClassField(options, printer, desc->field(i));\n    }\n  }\n}\n\nvoid GenerateBytesWrapper(const GeneratorOptions& options,\n                          io::Printer* printer,\n                          const FieldDescriptor* field,\n                          BytesMode bytes_mode) {\n  string type =\n      JSFieldTypeAnnotation(options, field,\n                            /* force_optional = */ false,\n                            /* force_present = */ !HasFieldPresence(field),\n                            /* singular_if_not_packed = */ false,\n                            bytes_mode);\n  printer->Print(\n      \"/**\\n\"\n      \" * $fielddef$\\n\"\n      \"$comment$\"\n      \" * This is a type-conversion wrapper around `get$defname$()`\\n\"\n      \" * @return {$type$}\\n\"\n      \" */\\n\"\n      \"$class$.prototype.get$name$ = function() {\\n\"\n      \"  return /** @type {$type$} */ (jspb.Message.bytes$list$As$suffix$(\\n\"\n      \"      this.get$defname$()));\\n\"\n      \"};\\n\"\n      \"\\n\"\n      \"\\n\",\n      \"fielddef\", FieldDefinition(options, field),\n      \"comment\", FieldComments(field, bytes_mode),\n      \"type\", type,\n      \"class\", GetPath(options, field->containing_type()),\n      \"name\", JSGetterName(options, field, bytes_mode),\n      \"list\", field->is_repeated() ? \"List\" : \"\",\n      \"suffix\", JSByteGetterSuffix(bytes_mode),\n      \"defname\", JSGetterName(options, field, BYTES_DEFAULT));\n}\n\n\nvoid Generator::GenerateClassField(const GeneratorOptions& options,\n                                   io::Printer* printer,\n                                   const FieldDescriptor* field) const {\n  if (field->is_map()) {\n    const FieldDescriptor* key_field = MapFieldKey(field);\n    const FieldDescriptor* value_field = MapFieldValue(field);\n    // Map field: special handling to instantiate the map object on demand.\n    string key_type =\n        JSFieldTypeAnnotation(\n            options, key_field,\n            /* force_optional = */ false,\n            /* force_present = */ true,\n            /* singular_if_not_packed = */ false);\n    string value_type =\n        JSFieldTypeAnnotation(\n            options, value_field,\n            /* force_optional = */ false,\n            /* force_present = */ true,\n            /* singular_if_not_packed = */ false);\n\n    printer->Print(\n        \"/**\\n\"\n        \" * $fielddef$\\n\"\n        \" * @param {boolean=} opt_noLazyCreate Do not create the map if\\n\"\n        \" * empty, instead returning `undefined`\\n\"\n        \" * @return {!jspb.Map<$keytype$,$valuetype$>}\\n\"\n        \" */\\n\",\n        \"fielddef\", FieldDefinition(options, field),\n        \"keytype\", key_type,\n        \"valuetype\", value_type);\n    printer->Print(\n        \"$class$.prototype.get$name$ = function(opt_noLazyCreate) {\\n\"\n        \"  return /** @type {!jspb.Map<$keytype$,$valuetype$>} */ (\\n\",\n        \"class\", GetPath(options, field->containing_type()),\n        \"name\", JSGetterName(options, field),\n        \"keytype\", key_type,\n        \"valuetype\", value_type);\n    printer->Print(\n        \"      jspb.Message.getMapField(this, $index$, opt_noLazyCreate\",\n        \"index\", JSFieldIndex(field));\n\n    if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) {\n      printer->Print(\",\\n\"\n          \"      $messageType$\",\n            \"messageType\", GetPath(options, value_field->message_type()));\n    } else if (options.binary) {\n      printer->Print(\",\\n\"\n          \"      null\");\n    }\n\n    printer->Print(\n        \"));\\n\");\n\n    printer->Print(\n        \"};\\n\"\n        \"\\n\"\n        \"\\n\");\n  } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n    // Message field: special handling in order to wrap the underlying data\n    // array with a message object.\n\n    printer->Print(\n        \"/**\\n\"\n        \" * $fielddef$\\n\"\n        \"$comment$\"\n        \" * @return {$type$}\\n\"\n        \" */\\n\",\n        \"fielddef\", FieldDefinition(options, field),\n        \"comment\", FieldComments(field, BYTES_DEFAULT),\n        \"type\", JSFieldTypeAnnotation(options, field,\n                                      /* force_optional = */ false,\n                                      /* force_present = */ false,\n                                      /* singular_if_not_packed = */ false));\n    printer->Print(\n        \"$class$.prototype.get$name$ = function() {\\n\"\n        \"  return /** @type{$type$} */ (\\n\"\n        \"    jspb.Message.get$rpt$WrapperField(this, $wrapperclass$, \"\n        \"$index$$required$));\\n\"\n        \"};\\n\"\n        \"\\n\"\n        \"\\n\",\n        \"class\", GetPath(options, field->containing_type()),\n        \"name\", JSGetterName(options, field),\n        \"type\", JSFieldTypeAnnotation(options, field,\n                                      /* force_optional = */ false,\n                                      /* force_present = */ false,\n                                      /* singular_if_not_packed = */ false),\n        \"rpt\", (field->is_repeated() ? \"Repeated\" : \"\"),\n        \"index\", JSFieldIndex(field),\n        \"wrapperclass\", SubmessageTypeRef(options, field),\n        \"required\", (field->label() == FieldDescriptor::LABEL_REQUIRED ?\n                     \", 1\" : \"\"));\n    printer->Print(\n        \"/** @param {$optionaltype$} value $returndoc$ */\\n\"\n        \"$class$.prototype.set$name$ = function(value) {\\n\"\n        \"  jspb.Message.set$oneoftag$$repeatedtag$WrapperField(\",\n        \"optionaltype\",\n        JSFieldTypeAnnotation(options, field,\n                              /* force_optional = */ true,\n                              /* force_present = */ false,\n                              /* singular_if_not_packed = */ false),\n        \"returndoc\", JSReturnDoc(options, field),\n        \"class\", GetPath(options, field->containing_type()),\n        \"name\", JSGetterName(options, field),\n        \"oneoftag\", (field->containing_oneof() ? \"Oneof\" : \"\"),\n        \"repeatedtag\", (field->is_repeated() ? \"Repeated\" : \"\"));\n\n    printer->Print(\n        \"this, $index$$oneofgroup$, value);$returnvalue$\\n\"\n        \"};\\n\"\n        \"\\n\"\n        \"\\n\",\n        \"index\", JSFieldIndex(field),\n        \"oneofgroup\", (field->containing_oneof() ?\n                       (\", \" + JSOneofArray(options, field)) : \"\"),\n        \"returnvalue\", JSReturnClause(field));\n\n    printer->Print(\n        \"$class$.prototype.clear$name$ = function() {\\n\"\n        \"  this.set$name$($clearedvalue$);$returnvalue$\\n\"\n        \"};\\n\"\n        \"\\n\"\n        \"\\n\",\n        \"class\", GetPath(options, field->containing_type()),\n        \"name\", JSGetterName(options, field),\n        \"clearedvalue\", (field->is_repeated() ? \"[]\" : \"undefined\"),\n        \"returnvalue\", JSReturnClause(field));\n\n  } else {\n    bool untyped =\n        false;\n\n    // Simple (primitive) field, either singular or repeated.\n\n    // TODO(b/26173701): Always use BYTES_DEFAULT for the getter return type;\n    // at this point we \"lie\" to non-binary users and tell the the return\n    // type is always base64 string, pending a LSC to migrate to typed getters.\n    BytesMode bytes_mode =\n        field->type() == FieldDescriptor::TYPE_BYTES && !options.binary ?\n            BYTES_B64 : BYTES_DEFAULT;\n    string typed_annotation =\n        JSFieldTypeAnnotation(options, field,\n                              /* force_optional = */ false,\n                              /* force_present = */ !HasFieldPresence(field),\n                              /* singular_if_not_packed = */ false,\n                              /* bytes_mode = */ bytes_mode);\n    if (untyped) {\n      printer->Print(\n          \"/**\\n\"\n          \" * @return {?} Raw field, untyped.\\n\"\n          \" */\\n\");\n    } else {\n      printer->Print(\n          \"/**\\n\"\n          \" * $fielddef$\\n\"\n          \"$comment$\"\n          \" * @return {$type$}\\n\"\n          \" */\\n\",\n          \"fielddef\", FieldDefinition(options, field),\n          \"comment\", FieldComments(field, bytes_mode),\n          \"type\", typed_annotation);\n    }\n\n    printer->Print(\n        \"$class$.prototype.get$name$ = function() {\\n\",\n        \"class\", GetPath(options, field->containing_type()),\n        \"name\", JSGetterName(options, field));\n\n    if (untyped) {\n      printer->Print(\n          \"  return \");\n    } else {\n      printer->Print(\n          \"  return /** @type {$type$} */ (\",\n          \"type\", typed_annotation);\n    }\n\n    // For proto3 fields without presence, use special getters that will return\n    // defaults when the field is unset, possibly constructing a value if\n    // required.\n    if (!HasFieldPresence(field) && !field->is_repeated()) {\n      printer->Print(\"jspb.Message.getFieldProto3(this, $index$, $default$)\",\n                     \"index\", JSFieldIndex(field),\n                     \"default\", Proto3PrimitiveFieldDefault(field));\n    } else {\n      if (!field->is_repeated()) {\n        printer->Print(\"!this.has$name$() ? $defaultValue$ : \",\n                       \"name\", JSGetterName(options, field),\n                       \"defaultValue\", JSFieldDefault(field));\n      }\n      if (field->cpp_type() == FieldDescriptor::CPPTYPE_FLOAT ||\n          field->cpp_type() == FieldDescriptor::CPPTYPE_DOUBLE) {\n        if (field->is_repeated()) {\n          printer->Print(\"jspb.Message.getRepeatedFloatingPointField(\"\n                         \"this, $index$)\",\n                         \"index\", JSFieldIndex(field));\n        } else {\n          // Convert \"NaN\" to NaN.\n          printer->Print(\"+jspb.Message.getField(this, $index$)\",\n                         \"index\", JSFieldIndex(field));\n        }\n      } else {\n        printer->Print(\"jspb.Message.getField(this, $index$)\",\n                       \"index\", JSFieldIndex(field));\n      }\n    }\n\n    if (untyped) {\n      printer->Print(\n          \";\\n\"\n          \"};\\n\"\n          \"\\n\"\n          \"\\n\");\n    } else {\n      printer->Print(\n          \");\\n\"\n          \"};\\n\"\n          \"\\n\"\n          \"\\n\");\n    }\n\n    if (field->type() == FieldDescriptor::TYPE_BYTES && !untyped) {\n      GenerateBytesWrapper(options, printer, field, BYTES_B64);\n      GenerateBytesWrapper(options, printer, field, BYTES_U8);\n    }\n\n    if (untyped) {\n      printer->Print(\n          \"/**\\n\"\n          \" * @param {*} value $returndoc$\\n\"\n          \" */\\n\",\n          \"returndoc\", JSReturnDoc(options, field));\n    } else {\n      printer->Print(\n          \"/** @param {$optionaltype$} value $returndoc$ */\\n\",\n          \"optionaltype\",\n          JSFieldTypeAnnotation(options, field,\n                                /* force_optional = */ true,\n                                /* force_present = */ !HasFieldPresence(field),\n                                /* singular_if_not_packed = */ false),\n          \"returndoc\", JSReturnDoc(options, field));\n    }\n    printer->Print(\n        \"$class$.prototype.set$name$ = function(value) {\\n\"\n        \"  jspb.Message.set$oneoftag$Field(this, $index$\",\n        \"class\", GetPath(options, field->containing_type()),\n        \"name\", JSGetterName(options, field),\n        \"oneoftag\", (field->containing_oneof() ? \"Oneof\" : \"\"),\n        \"index\", JSFieldIndex(field));\n    printer->Print(\n        \"$oneofgroup$, $type$value$rptvalueinit$$typeclose$);$returnvalue$\\n\"\n        \"};\\n\"\n        \"\\n\"\n        \"\\n\",\n        \"type\",\n        untyped ? \"/** @type{string|number|boolean|Array|undefined} */(\" : \"\",\n        \"typeclose\", untyped ? \")\" : \"\",\n        \"oneofgroup\",\n        (field->containing_oneof() ? (\", \" + JSOneofArray(options, field))\n                                   : \"\"),\n        \"returnvalue\", JSReturnClause(field), \"rptvalueinit\",\n        (field->is_repeated() ? \" || []\" : \"\"));\n\n    if (untyped) {\n      printer->Print(\n          \"/**\\n\"\n          \" * Clears the value. $returndoc$\\n\"\n          \" */\\n\",\n          \"returndoc\", JSReturnDoc(options, field));\n    }\n\n    if (HasFieldPresence(field) || field->is_repeated()) {\n      printer->Print(\n          \"$class$.prototype.clear$name$ = function() {\\n\"\n          \"  jspb.Message.set$oneoftag$Field(this, $index$$oneofgroup$, \",\n          \"class\", GetPath(options, field->containing_type()),\n          \"name\", JSGetterName(options, field),\n          \"oneoftag\", (field->containing_oneof() ? \"Oneof\" : \"\"),\n          \"oneofgroup\", (field->containing_oneof() ?\n                         (\", \" + JSOneofArray(options, field)) : \"\"),\n          \"index\", JSFieldIndex(field));\n      printer->Print(\n          \"$clearedvalue$);$returnvalue$\\n\"\n          \"};\\n\"\n          \"\\n\"\n          \"\\n\",\n          \"clearedvalue\", (field->is_repeated() ? \"[]\" : \"undefined\"),\n          \"returnvalue\", JSReturnClause(field));\n    }\n  }\n\n  if (HasFieldPresence(field)) {\n    printer->Print(\n        \"/**\\n\"\n        \" * Returns whether this field is set.\\n\"\n        \" * @return{!boolean}\\n\"\n        \" */\\n\"\n        \"$class$.prototype.has$name$ = function() {\\n\"\n        \"  return jspb.Message.getField(this, $index$) != null;\\n\"\n        \"};\\n\"\n        \"\\n\"\n        \"\\n\",\n        \"class\", GetPath(options, field->containing_type()),\n        \"name\", JSGetterName(options, field),\n        \"index\", JSFieldIndex(field));\n  }\n}\n\nvoid Generator::GenerateClassExtensionFieldInfo(const GeneratorOptions& options,\n                                                io::Printer* printer,\n                                                const Descriptor* desc) const {\n  if (IsExtendable(desc)) {\n    printer->Print(\n        \"\\n\"\n        \"/**\\n\"\n        \" * The extensions registered with this message class. This is a \"\n        \"map of\\n\"\n        \" * extension field number to fieldInfo object.\\n\"\n        \" *\\n\"\n        \" * For example:\\n\"\n        \" *     { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, \"\n        \"ctor: proto.example.MyMessage} }\\n\"\n        \" *\\n\"\n        \" * fieldName contains the JsCompiler renamed field name property \"\n        \"so that it\\n\"\n        \" * works in OPTIMIZED mode.\\n\"\n        \" *\\n\"\n        \" * @type {!Object.<number, jspb.ExtensionFieldInfo>}\\n\"\n        \" */\\n\"\n        \"$class$.extensions = {};\\n\"\n        \"\\n\",\n        \"class\", GetPath(options, desc));\n\n    if (options.binary) {\n      printer->Print(\n          \"\\n\"\n          \"/**\\n\"\n          \" * The extensions registered with this message class. This is a \"\n          \"map of\\n\"\n          \" * extension field number to fieldInfo object.\\n\"\n          \" *\\n\"\n          \" * For example:\\n\"\n          \" *     { 123: {fieldIndex: 123, fieldName: {my_field_name: 0}, \"\n          \"ctor: proto.example.MyMessage} }\\n\"\n          \" *\\n\"\n          \" * fieldName contains the JsCompiler renamed field name property \"\n          \"so that it\\n\"\n          \" * works in OPTIMIZED mode.\\n\"\n          \" *\\n\"\n          \" * @type {!Object.<number, jspb.ExtensionFieldInfo>}\\n\"\n          \" */\\n\"\n          \"$class$.extensionsBinary = {};\\n\"\n          \"\\n\",\n          \"class\", GetPath(options, desc));\n    }\n  }\n}\n\n\nvoid Generator::GenerateClassDeserializeBinary(const GeneratorOptions& options,\n                                               io::Printer* printer,\n                                               const Descriptor* desc) const {\n  // TODO(cfallin): Handle lazy decoding when requested by field option and/or\n  // by default for 'bytes' fields and packed repeated fields.\n\n  printer->Print(\n      \"/**\\n\"\n      \" * Deserializes binary data (in protobuf wire format).\\n\"\n      \" * @param {jspb.ByteSource} bytes The bytes to deserialize.\\n\"\n      \" * @return {!$class$}\\n\"\n      \" */\\n\"\n      \"$class$.deserializeBinary = function(bytes) {\\n\"\n      \"  var reader = new jspb.BinaryReader(bytes);\\n\"\n      \"  var msg = new $class$;\\n\"\n      \"  return $class$.deserializeBinaryFromReader(msg, reader);\\n\"\n      \"};\\n\"\n      \"\\n\"\n      \"\\n\"\n      \"/**\\n\"\n      \" * Deserializes binary data (in protobuf wire format) from the\\n\"\n      \" * given reader into the given message object.\\n\"\n      \" * @param {!$class$} msg The message object to deserialize into.\\n\"\n      \" * @param {!jspb.BinaryReader} reader The BinaryReader to use.\\n\"\n      \" * @return {!$class$}\\n\"\n      \" */\\n\"\n      \"$class$.deserializeBinaryFromReader = function(msg, reader) {\\n\"\n      \"  while (reader.nextField()) {\\n\"\n      \"    if (reader.isEndGroup()) {\\n\"\n      \"      break;\\n\"\n      \"    }\\n\"\n      \"    var field = reader.getFieldNumber();\\n\"\n      \"    switch (field) {\\n\",\n      \"class\", GetPath(options, desc));\n\n  for (int i = 0; i < desc->field_count(); i++) {\n    GenerateClassDeserializeBinaryField(options, printer, desc->field(i));\n  }\n\n  printer->Print(\n      \"    default:\\n\");\n  if (IsExtendable(desc)) {\n    printer->Print(\n        \"      jspb.Message.readBinaryExtension(msg, reader, $extobj$Binary,\\n\"\n        \"        $class$.prototype.getExtension,\\n\"\n        \"        $class$.prototype.setExtension);\\n\"\n        \"      break;\\n\",\n        \"extobj\", JSExtensionsObjectName(options, desc->file(), desc),\n        \"class\", GetPath(options, desc));\n  } else {\n    printer->Print(\n        \"      reader.skipField();\\n\"\n        \"      break;\\n\");\n  }\n\n  printer->Print(\n      \"    }\\n\"\n      \"  }\\n\"\n      \"  return msg;\\n\"\n      \"};\\n\"\n      \"\\n\"\n      \"\\n\");\n}\n\nvoid Generator::GenerateClassDeserializeBinaryField(\n    const GeneratorOptions& options,\n    io::Printer* printer,\n    const FieldDescriptor* field) const {\n\n  printer->Print(\"    case $num$:\\n\",\n                 \"num\", SimpleItoa(field->number()));\n\n  if (field->is_map()) {\n    const FieldDescriptor* key_field = MapFieldKey(field);\n    const FieldDescriptor* value_field = MapFieldValue(field);\n    printer->Print(\n        \"      var value = msg.get$name$();\\n\"\n        \"      reader.readMessage(value, function(message, reader) {\\n\",\n        \"name\", JSGetterName(options, field));\n\n    printer->Print(\"        jspb.Map.deserializeBinary(message, reader, \"\n                   \"$keyReaderFn$, $valueReaderFn$\",\n          \"keyReaderFn\", JSBinaryReaderMethodName(options, key_field),\n          \"valueReaderFn\", JSBinaryReaderMethodName(options, value_field));\n\n    if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) {\n      printer->Print(\", $messageType$.deserializeBinaryFromReader\",\n          \"messageType\", GetPath(options, value_field->message_type()));\n    }\n\n    printer->Print(\");\\n\");\n    printer->Print(\"         });\\n\");\n  } else {\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n      printer->Print(\n          \"      var value = new $fieldclass$;\\n\"\n          \"      reader.read$msgOrGroup$($grpfield$value,\"\n          \"$fieldclass$.deserializeBinaryFromReader);\\n\",\n        \"fieldclass\", SubmessageTypeRef(options, field),\n          \"msgOrGroup\", (field->type() == FieldDescriptor::TYPE_GROUP) ?\n                        \"Group\" : \"Message\",\n          \"grpfield\", (field->type() == FieldDescriptor::TYPE_GROUP) ?\n                      (SimpleItoa(field->number()) + \", \") : \"\");\n    } else {\n      printer->Print(\n          \"      var value = /** @type {$fieldtype$} */ \"\n          \"(reader.read$reader$());\\n\",\n          \"fieldtype\", JSFieldTypeAnnotation(options, field, false, true,\n                                             /* singular_if_not_packed */ true,\n                                             BYTES_U8),\n          \"reader\",\n          JSBinaryReadWriteMethodName(field, /* is_writer = */ false));\n    }\n\n    if (field->is_repeated() && !field->is_packed()) {\n      // Repeated fields receive a |value| one at at a time; append to array\n      // returned by get$name$(). Annoyingly, we have to call 'set' after\n      // changing the array.\n      printer->Print(\"      msg.get$name$().push(value);\\n\", \"name\",\n                     JSGetterName(options, field));\n      printer->Print(\"      msg.set$name$(msg.get$name$());\\n\", \"name\",\n                     JSGetterName(options, field));\n    } else {\n      // Singular fields, and packed repeated fields, receive a |value| either\n      // as the field's value or as the array of all the field's values; set\n      // this as the field's value directly.\n      printer->Print(\n          \"      msg.set$name$(value);\\n\",\n          \"name\", JSGetterName(options, field));\n    }\n  }\n\n  printer->Print(\"      break;\\n\");\n}\n\nvoid Generator::GenerateClassSerializeBinary(const GeneratorOptions& options,\n                                             io::Printer* printer,\n                                             const Descriptor* desc) const {\n  printer->Print(\n      \"/**\\n\"\n      \" * Class method variant: serializes the given message to binary data\\n\"\n      \" * (in protobuf wire format), writing to the given BinaryWriter.\\n\"\n      \" * @param {!$class$} message\\n\"\n      \" * @param {!jspb.BinaryWriter} writer\\n\"\n      \" */\\n\"\n      \"$class$.serializeBinaryToWriter = function(message, \"\n      \"writer) {\\n\"\n      \"  message.serializeBinaryToWriter(writer);\\n\"\n      \"};\\n\"\n      \"\\n\"\n      \"\\n\"\n      \"/**\\n\"\n      \" * Serializes the message to binary data (in protobuf wire format).\\n\"\n      \" * @return {!Uint8Array}\\n\"\n      \" */\\n\"\n      \"$class$.prototype.serializeBinary = function() {\\n\"\n      \"  var writer = new jspb.BinaryWriter();\\n\"\n      \"  this.serializeBinaryToWriter(writer);\\n\"\n      \"  return writer.getResultBuffer();\\n\"\n      \"};\\n\"\n      \"\\n\"\n      \"\\n\"\n      \"/**\\n\"\n      \" * Serializes the message to binary data (in protobuf wire format),\\n\"\n      \" * writing to the given BinaryWriter.\\n\"\n      \" * @param {!jspb.BinaryWriter} writer\\n\"\n      \" */\\n\"\n      \"$class$.prototype.serializeBinaryToWriter = function (writer) {\\n\"\n      \"  var f = undefined;\\n\",\n      \"class\", GetPath(options, desc));\n\n  for (int i = 0; i < desc->field_count(); i++) {\n    GenerateClassSerializeBinaryField(options, printer, desc->field(i));\n  }\n\n  if (IsExtendable(desc)) {\n    printer->Print(\n        \"  jspb.Message.serializeBinaryExtensions(this, writer,\\n\"\n        \"    $extobj$Binary, $class$.prototype.getExtension);\\n\",\n        \"extobj\", JSExtensionsObjectName(options, desc->file(), desc),\n        \"class\", GetPath(options, desc));\n  }\n\n  printer->Print(\n      \"};\\n\"\n      \"\\n\"\n      \"\\n\");\n}\n\nvoid Generator::GenerateClassSerializeBinaryField(\n    const GeneratorOptions& options,\n    io::Printer* printer,\n    const FieldDescriptor* field) const {\n  if (HasFieldPresence(field) &&\n      field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) {\n    printer->Print(\n        \"  f = jspb.Message.getField(this, $index$);\\n\",\n        \"index\", JSFieldIndex(field));\n  } else {\n    printer->Print(\n        \"  f = this.get$name$($nolazy$);\\n\",\n        \"name\", JSGetterName(options, field, BYTES_U8),\n        // No lazy creation for maps containers -- fastpath the empty case.\n        \"nolazy\", (field->is_map()) ? \"true\" : \"\");\n  }\n\n\n  // Print an `if (condition)` statement that evaluates to true if the field\n  // goes on the wire.\n  if (field->is_map()) {\n    printer->Print(\n        \"  if (f && f.getLength() > 0) {\\n\");\n  } else if (field->is_repeated()) {\n    printer->Print(\n        \"  if (f.length > 0) {\\n\");\n  } else {\n    if (HasFieldPresence(field)) {\n      printer->Print(\n          \"  if (f != null) {\\n\");\n    } else {\n      // No field presence: serialize onto the wire only if value is\n      // non-default.  Defaults are documented here:\n      // https://goto.google.com/lhdfm\n      switch (field->cpp_type()) {\n        case FieldDescriptor::CPPTYPE_INT32:\n        case FieldDescriptor::CPPTYPE_INT64:\n        case FieldDescriptor::CPPTYPE_UINT32:\n        case FieldDescriptor::CPPTYPE_UINT64: {\n          {\n            printer->Print(\"  if (f !== 0) {\\n\");\n          }\n          break;\n        }\n\n        case FieldDescriptor::CPPTYPE_ENUM:\n        case FieldDescriptor::CPPTYPE_FLOAT:\n        case FieldDescriptor::CPPTYPE_DOUBLE:\n          printer->Print(\n              \"  if (f !== 0.0) {\\n\");\n          break;\n        case FieldDescriptor::CPPTYPE_BOOL:\n          printer->Print(\n              \"  if (f) {\\n\");\n          break;\n        case FieldDescriptor::CPPTYPE_STRING:\n          printer->Print(\n              \"  if (f.length > 0) {\\n\");\n          break;\n        default:\n          assert(false);\n          break;\n      }\n    }\n  }\n\n  // Write the field on the wire.\n  if (field->is_map()) {\n    const FieldDescriptor* key_field = MapFieldKey(field);\n    const FieldDescriptor* value_field = MapFieldValue(field);\n    printer->Print(\n        \"    f.serializeBinary($index$, writer, \"\n                              \"$keyWriterFn$, $valueWriterFn$\",\n        \"index\", SimpleItoa(field->number()),\n        \"keyWriterFn\", JSBinaryWriterMethodName(options, key_field),\n        \"valueWriterFn\", JSBinaryWriterMethodName(options, value_field));\n\n    if (value_field->type() == FieldDescriptor::TYPE_MESSAGE) {\n      printer->Print(\", $messageType$.serializeBinaryToWriter\",\n          \"messageType\", GetPath(options, value_field->message_type()));\n    }\n\n    printer->Print(\");\\n\");\n  } else {\n    printer->Print(\n        \"    writer.write$method$(\\n\"\n        \"      $index$,\\n\"\n        \"      f\",\n        \"method\", JSBinaryReadWriteMethodName(field, /* is_writer = */ true),\n        \"index\", SimpleItoa(field->number()));\n\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&\n        !(field->is_map())) {\n      printer->Print(\n          \",\\n\"\n          \"      $submsg$.serializeBinaryToWriter\\n\",\n        \"submsg\", SubmessageTypeRef(options, field));\n    } else {\n      printer->Print(\"\\n\");\n    }\n\n    printer->Print(\n        \"    );\\n\");\n  }\n\n  // Close the `if`.\n  printer->Print(\n      \"  }\\n\");\n}\n\nvoid Generator::GenerateEnum(const GeneratorOptions& options,\n                             io::Printer* printer,\n                             const EnumDescriptor* enumdesc) const {\n  printer->Print(\n      \"/**\\n\"\n      \" * @enum {number}\\n\"\n      \" */\\n\"\n      \"$name$ = {\\n\",\n      \"name\", GetPath(options, enumdesc));\n\n  for (int i = 0; i < enumdesc->value_count(); i++) {\n    const EnumValueDescriptor* value = enumdesc->value(i);\n    printer->Print(\n        \"  $name$: $value$$comma$\\n\",\n        \"name\", ToEnumCase(value->name()),\n        \"value\", SimpleItoa(value->number()),\n        \"comma\", (i == enumdesc->value_count() - 1) ? \"\" : \",\");\n  }\n\n  printer->Print(\n      \"};\\n\"\n      \"\\n\");\n}\n\nvoid Generator::GenerateExtension(const GeneratorOptions& options,\n                                  io::Printer* printer,\n                                  const FieldDescriptor* field) const {\n  string extension_scope =\n      (field->extension_scope() ?\n       GetPath(options, field->extension_scope()) :\n       GetPath(options, field->file()));\n\n  printer->Print(\n      \"\\n\"\n      \"/**\\n\"\n      \" * A tuple of {field number, class constructor} for the extension\\n\"\n      \" * field named `$name$`.\\n\"\n      \" * @type {!jspb.ExtensionFieldInfo.<$extensionType$>}\\n\"\n      \" */\\n\"\n      \"$class$.$name$ = new jspb.ExtensionFieldInfo(\\n\",\n      \"name\", JSObjectFieldName(options, field),\n      \"class\", extension_scope,\n      \"extensionType\", JSFieldTypeAnnotation(\n          options, field,\n          /* force_optional = */ false,\n          /* force_present = */ true,\n          /* singular_if_not_packed = */ false));\n  printer->Print(\n      \"    $index$,\\n\"\n      \"    {$name$: 0},\\n\"\n      \"    $ctor$,\\n\"\n      \"     /** @type {?function((boolean|undefined),!jspb.Message=): \"\n      \"!Object} */ (\\n\"\n      \"         $toObject$),\\n\"\n      \"    $repeated$);\\n\",\n      \"index\", SimpleItoa(field->number()),\n      \"name\", JSObjectFieldName(options, field),\n      \"ctor\", (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE ?\n               SubmessageTypeRef(options, field) : string(\"null\")),\n      \"toObject\", (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE ?\n                   (SubmessageTypeRef(options, field) + \".toObject\") :\n                   string(\"null\")),\n      \"repeated\", (field->is_repeated() ? \"1\" : \"0\"));\n\n  if (options.binary) {\n    printer->Print(\n        \"\\n\"\n        \"$extendName$Binary[$index$] = new jspb.ExtensionFieldBinaryInfo(\\n\"\n        \"    $class$.$name$,\\n\"\n        \"    $binaryReaderFn$,\\n\"\n        \"    $binaryWriterFn$,\\n\"\n        \"    $binaryMessageSerializeFn$,\\n\"\n        \"    $binaryMessageDeserializeFn$,\\n\",\n        \"extendName\", JSExtensionsObjectName(options, field->file(),\n                                             field->containing_type()),\n        \"index\", SimpleItoa(field->number()),\n        \"class\", extension_scope,\n        \"name\", JSObjectFieldName(options, field),\n        \"binaryReaderFn\", JSBinaryReaderMethodName(options, field),\n        \"binaryWriterFn\", JSBinaryWriterMethodName(options, field),\n        \"binaryMessageSerializeFn\",\n        (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) ?\n        (SubmessageTypeRef(options, field) +\n         \".serializeBinaryToWriter\") : \"null\",\n        \"binaryMessageDeserializeFn\",\n        (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) ?\n        (SubmessageTypeRef(options, field) +\n         \".deserializeBinaryFromReader\") : \"null\");\n\n    printer->Print(\n        \"    $isPacked$);\\n\",\n        \"isPacked\", (field->is_packed() ? \"true\" : \"false\"));\n  }\n\n  printer->Print(\n      \"// This registers the extension field with the extended class, so that\\n\"\n      \"// toObject() will function correctly.\\n\"\n      \"$extendName$[$index$] = $class$.$name$;\\n\"\n      \"\\n\",\n      \"extendName\", JSExtensionsObjectName(options, field->file(),\n                                           field->containing_type()),\n      \"index\", SimpleItoa(field->number()),\n      \"class\", extension_scope,\n      \"name\", JSObjectFieldName(options, field));\n}\n\nbool GeneratorOptions::ParseFromOptions(\n    const vector< pair< string, string > >& options,\n    string* error) {\n  for (int i = 0; i < options.size(); i++) {\n    if (options[i].first == \"add_require_for_enums\") {\n      if (options[i].second != \"\") {\n        *error = \"Unexpected option value for add_require_for_enums\";\n        return false;\n      }\n      add_require_for_enums = true;\n    } else if (options[i].first == \"binary\") {\n      if (options[i].second != \"\") {\n        *error = \"Unexpected option value for binary\";\n        return false;\n      }\n      binary = true;\n    } else if (options[i].first == \"testonly\") {\n      if (options[i].second != \"\") {\n        *error = \"Unexpected option value for testonly\";\n        return false;\n      }\n      testonly = true;\n    } else if (options[i].first == \"error_on_name_conflict\") {\n      if (options[i].second != \"\") {\n        *error = \"Unexpected option value for error_on_name_conflict\";\n        return false;\n      }\n      error_on_name_conflict = true;\n    } else if (options[i].first == \"output_dir\") {\n      output_dir = options[i].second;\n    } else if (options[i].first == \"namespace_prefix\") {\n      namespace_prefix = options[i].second;\n    } else if (options[i].first == \"library\") {\n      library = options[i].second;\n    } else if (options[i].first == \"import_style\") {\n      if (options[i].second == \"closure\") {\n        import_style = IMPORT_CLOSURE;\n      } else if (options[i].second == \"commonjs\") {\n        import_style = IMPORT_COMMONJS;\n      } else if (options[i].second == \"browser\") {\n        import_style = IMPORT_BROWSER;\n      } else if (options[i].second == \"es6\") {\n        import_style = IMPORT_ES6;\n      } else {\n        *error = \"Unknown import style \" + options[i].second + \", expected \" +\n                 \"one of: closure, commonjs, browser, es6.\";\n      }\n    } else {\n      // Assume any other option is an output directory, as long as it is a bare\n      // `key` rather than a `key=value` option.\n      if (options[i].second != \"\") {\n        *error = \"Unknown option: \" + options[i].first;\n        return false;\n      }\n      output_dir = options[i].first;\n    }\n  }\n\n  if (!library.empty() && import_style != IMPORT_CLOSURE) {\n    *error = \"The library option should only be used for \"\n             \"import_style=closure\";\n  }\n\n  return true;\n}\n\nvoid Generator::GenerateFilesInDepOrder(\n    const GeneratorOptions& options,\n    io::Printer* printer,\n    const vector<const FileDescriptor*>& files) const {\n  // Build a std::set over all files so that the DFS can detect when it recurses\n  // into a dep not specified in the user's command line.\n  std::set<const FileDescriptor*> all_files(files.begin(), files.end());\n  // Track the in-progress set of files that have been generated already.\n  std::set<const FileDescriptor*> generated;\n  for (int i = 0; i < files.size(); i++) {\n    GenerateFileAndDeps(options, printer, files[i], &all_files, &generated);\n  }\n}\n\nvoid Generator::GenerateFileAndDeps(\n    const GeneratorOptions& options,\n    io::Printer* printer,\n    const FileDescriptor* root,\n    std::set<const FileDescriptor*>* all_files,\n    std::set<const FileDescriptor*>* generated) const {\n  // Skip if already generated.\n  if (generated->find(root) != generated->end()) {\n    return;\n  }\n  generated->insert(root);\n\n  // Generate all dependencies before this file's content.\n  for (int i = 0; i < root->dependency_count(); i++) {\n    const FileDescriptor* dep = root->dependency(i);\n    GenerateFileAndDeps(options, printer, dep, all_files, generated);\n  }\n\n  // Generate this file's content.  Only generate if the file is part of the\n  // original set requested to be generated; i.e., don't take all transitive\n  // deps down to the roots.\n  if (all_files->find(root) != all_files->end()) {\n    GenerateClassesAndEnums(options, printer, root);\n  }\n}\n\nvoid Generator::GenerateFile(const GeneratorOptions& options,\n                             io::Printer* printer,\n                             const FileDescriptor* file) const {\n  GenerateHeader(options, printer);\n\n  // Generate \"require\" statements.\n  if (options.import_style == GeneratorOptions::IMPORT_COMMONJS) {\n    printer->Print(\"var jspb = require('google-protobuf');\\n\");\n    printer->Print(\"var goog = jspb;\\n\");\n    printer->Print(\"var global = Function('return this')();\\n\\n\");\n\n    for (int i = 0; i < file->dependency_count(); i++) {\n      const string& name = file->dependency(i)->name();\n      printer->Print(\n          \"var $alias$ = require('$file$');\\n\",\n          \"alias\", ModuleAlias(name),\n          \"file\", GetRootPath(file->name(), name) + GetJSFilename(name));\n    }\n  }\n\n  // We aren't using Closure's import system, but we use goog.exportSymbol()\n  // to construct the expected tree of objects, eg.\n  //\n  //   goog.exportSymbol('foo.bar.Baz', null, this);\n  //\n  //   // Later generated code expects foo.bar = {} to exist:\n  //   foo.bar.Baz = function() { /* ... */ }\n  set<string> provided;\n\n  // Cover the case where this file declares extensions but no messages.\n  // This will ensure that the file-level object will be declared to hold\n  // the extensions.\n  for (int i = 0; i < file->extension_count(); i++) {\n    provided.insert(file->extension(i)->full_name());\n  }\n\n  FindProvidesForFile(options, printer, file, &provided);\n  for (std::set<string>::iterator it = provided.begin();\n       it != provided.end(); ++it) {\n    printer->Print(\"goog.exportSymbol('$name$', null, global);\\n\",\n                   \"name\", *it);\n  }\n\n  GenerateClassesAndEnums(options, printer, file);\n\n  // Extensions nested inside messages are emitted inside\n  // GenerateClassesAndEnums().\n  for (int i = 0; i < file->extension_count(); i++) {\n    GenerateExtension(options, printer, file->extension(i));\n  }\n\n  if (options.import_style == GeneratorOptions::IMPORT_COMMONJS) {\n    printer->Print(\"goog.object.extend(exports, $package$);\\n\",\n                   \"package\", GetPath(options, file));\n  }\n}\n\nbool Generator::GenerateAll(const vector<const FileDescriptor*>& files,\n                            const string& parameter,\n                            GeneratorContext* context,\n                            string* error) const {\n  vector< pair< string, string > > option_pairs;\n  ParseGeneratorParameter(parameter, &option_pairs);\n  GeneratorOptions options;\n  if (!options.ParseFromOptions(option_pairs, error)) {\n    return false;\n  }\n\n\n  // There are three schemes for where output files go:\n  //\n  // - import_style = IMPORT_CLOSURE, library non-empty: all output in one file\n  // - import_style = IMPORT_CLOSURE, library empty: one output file per type\n  // - import_style != IMPORT_CLOSURE: one output file per .proto file\n  if (options.import_style == GeneratorOptions::IMPORT_CLOSURE &&\n      options.library != \"\") {\n    // All output should go in a single file.\n    string filename = options.output_dir + \"/\" + options.library + \".js\";\n    google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(context->Open(filename));\n    GOOGLE_CHECK(output.get());\n    io::Printer printer(output.get(), '$');\n\n    // Pull out all extensions -- we need these to generate all\n    // provides/requires.\n    vector<const FieldDescriptor*> extensions;\n    for (int i = 0; i < files.size(); i++) {\n      for (int j = 0; j < files[i]->extension_count(); j++) {\n        const FieldDescriptor* extension = files[i]->extension(j);\n        extensions.push_back(extension);\n      }\n    }\n\n    GenerateHeader(options, &printer);\n\n    std::set<string> provided;\n    FindProvides(options, &printer, files, &provided);\n    FindProvidesForFields(options, &printer, extensions, &provided);\n    GenerateProvides(options, &printer, &provided);\n    GenerateTestOnly(options, &printer);\n    GenerateRequiresForLibrary(options, &printer, files, &provided);\n\n    GenerateFilesInDepOrder(options, &printer, files);\n\n    for (int i = 0; i < extensions.size(); i++) {\n      if (ShouldGenerateExtension(extensions[i])) {\n        GenerateExtension(options, &printer, extensions[i]);\n      }\n    }\n\n    if (printer.failed()) {\n      return false;\n    }\n  } else if (options.import_style == GeneratorOptions::IMPORT_CLOSURE) {\n    set<const void*> allowed_set;\n    if (!GenerateJspbAllowedSet(options, files, &allowed_set, error)) {\n      return false;\n    }\n\n    for (int i = 0; i < files.size(); i++) {\n      const FileDescriptor* file = files[i];\n      for (int j = 0; j < file->message_type_count(); j++) {\n        const Descriptor* desc = file->message_type(j);\n        if (allowed_set.count(desc) == 0) {\n          continue;\n        }\n\n        string filename = GetMessageFileName(options, desc);\n        google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(\n            context->Open(filename));\n        GOOGLE_CHECK(output.get());\n        io::Printer printer(output.get(), '$');\n\n        GenerateHeader(options, &printer);\n\n        std::set<string> provided;\n        FindProvidesForMessage(options, &printer, desc, &provided);\n        GenerateProvides(options, &printer, &provided);\n        GenerateTestOnly(options, &printer);\n        GenerateRequiresForMessage(options, &printer, desc, &provided);\n\n        GenerateClass(options, &printer, desc);\n\n        if (printer.failed()) {\n          return false;\n        }\n      }\n      for (int j = 0; j < file->enum_type_count(); j++) {\n        const EnumDescriptor* enumdesc = file->enum_type(j);\n        if (allowed_set.count(enumdesc) == 0) {\n          continue;\n        }\n\n        string filename = GetEnumFileName(options, enumdesc);\n        google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(\n            context->Open(filename));\n        GOOGLE_CHECK(output.get());\n        io::Printer printer(output.get(), '$');\n\n        GenerateHeader(options, &printer);\n\n        std::set<string> provided;\n        FindProvidesForEnum(options, &printer, enumdesc, &provided);\n        GenerateProvides(options, &printer, &provided);\n        GenerateTestOnly(options, &printer);\n\n        GenerateEnum(options, &printer, enumdesc);\n\n        if (printer.failed()) {\n          return false;\n        }\n      }\n      // File-level extensions (message-level extensions are generated under\n      // the enclosing message).\n      if (allowed_set.count(file) == 1) {\n        string filename = GetExtensionFileName(options, file);\n\n        google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(\n            context->Open(filename));\n        GOOGLE_CHECK(output.get());\n        io::Printer printer(output.get(), '$');\n\n        GenerateHeader(options, &printer);\n\n        std::set<string> provided;\n        vector<const FieldDescriptor*> fields;\n\n        for (int j = 0; j < files[i]->extension_count(); j++) {\n          if (ShouldGenerateExtension(files[i]->extension(j))) {\n            fields.push_back(files[i]->extension(j));\n          }\n        }\n\n        FindProvidesForFields(options, &printer, fields, &provided);\n        GenerateProvides(options, &printer, &provided);\n        GenerateTestOnly(options, &printer);\n        GenerateRequiresForExtensions(options, &printer, fields, &provided);\n\n        for (int j = 0; j < files[i]->extension_count(); j++) {\n          if (ShouldGenerateExtension(files[i]->extension(j))) {\n            GenerateExtension(options, &printer, files[i]->extension(j));\n          }\n        }\n      }\n    }\n  } else {\n    // Generate one output file per input (.proto) file.\n\n    for (int i = 0; i < files.size(); i++) {\n      const google::protobuf::FileDescriptor* file = files[i];\n\n      string filename = options.output_dir + \"/\" + GetJSFilename(file->name());\n      google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(context->Open(filename));\n      GOOGLE_CHECK(output.get());\n      io::Printer printer(output.get(), '$');\n\n      GenerateFile(options, &printer, file);\n\n      if (printer.failed()) {\n        return false;\n      }\n    }\n  }\n\n  return true;\n}\n\n}  // namespace js\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/js/js_generator.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_JS_GENERATOR_H__\n#define GOOGLE_PROTOBUF_COMPILER_JS_GENERATOR_H__\n\n#include <string>\n#include <set>\n\n#include <google/protobuf/compiler/code_generator.h>\n\nnamespace google {\nnamespace protobuf {\n\nclass Descriptor;\nclass EnumDescriptor;\nclass FieldDescriptor;\nclass OneofDescriptor;\nclass FileDescriptor;\n\nnamespace io { class Printer; }\n\nnamespace compiler {\nnamespace js {\n\nstruct GeneratorOptions {\n  // Add a `goog.requires()` call for each enum type used. If not set, a forward\n  // declaration with `goog.forwardDeclare` is produced instead.\n  bool add_require_for_enums;\n  // Set this as a test-only module via `goog.setTestOnly();`.\n  bool testonly;\n  // Output path.\n  string output_dir;\n  // Namespace prefix.\n  string namespace_prefix;\n  // Create a library with name <name>_lib.js rather than a separate .js file\n  // per type?\n  string library;\n  // Error if there are two types that would generate the same output file?\n  bool error_on_name_conflict;\n  // Enable binary-format support?\n  bool binary;\n  // What style of imports should be used.\n  enum ImportStyle {\n    IMPORT_CLOSURE,    // goog.require()\n    IMPORT_COMMONJS,   // require()\n    IMPORT_BROWSER,    // no import statements\n    IMPORT_ES6,        // import { member } from ''\n  } import_style;\n\n  GeneratorOptions()\n      : add_require_for_enums(false),\n        testonly(false),\n        output_dir(\".\"),\n        namespace_prefix(\"\"),\n        library(\"\"),\n        error_on_name_conflict(false),\n        binary(false),\n        import_style(IMPORT_CLOSURE) {}\n\n  bool ParseFromOptions(\n      const vector< pair< string, string > >& options,\n      string* error);\n};\n\nclass LIBPROTOC_EXPORT Generator : public CodeGenerator {\n public:\n  Generator() {}\n  virtual ~Generator() {}\n\n  virtual bool Generate(const FileDescriptor* file,\n                        const string& parameter,\n                        GeneratorContext* context,\n                        string* error) const {\n    *error = \"Unimplemented Generate() method. Call GenerateAll() instead.\";\n    return false;\n  }\n\n  virtual bool HasGenerateAll() const { return true; }\n\n  virtual bool GenerateAll(const vector<const FileDescriptor*>& files,\n                           const string& parameter,\n                           GeneratorContext* context,\n                           string* error) const;\n\n private:\n  void GenerateHeader(const GeneratorOptions& options,\n                      io::Printer* printer) const;\n\n  // Generate goog.provides() calls.\n  void FindProvides(const GeneratorOptions& options,\n                    io::Printer* printer,\n                    const vector<const FileDescriptor*>& file,\n                    std::set<string>* provided) const;\n  void FindProvidesForFile(const GeneratorOptions& options,\n                           io::Printer* printer,\n                           const FileDescriptor* file,\n                           std::set<string>* provided) const;\n  void FindProvidesForMessage(const GeneratorOptions& options,\n                              io::Printer* printer,\n                              const Descriptor* desc,\n                              std::set<string>* provided) const;\n  void FindProvidesForEnum(const GeneratorOptions& options,\n                           io::Printer* printer,\n                           const EnumDescriptor* enumdesc,\n                           std::set<string>* provided) const;\n  // For extension fields at file scope.\n  void FindProvidesForFields(const GeneratorOptions& options,\n                             io::Printer* printer,\n                             const vector<const FieldDescriptor*>& fields,\n                             std::set<string>* provided) const;\n  // Print the goog.provides() found by the methods above.\n  void GenerateProvides(const GeneratorOptions& options,\n                        io::Printer* printer,\n                        std::set<string>* provided) const;\n\n  // Generate goog.setTestOnly() if indicated.\n  void GenerateTestOnly(const GeneratorOptions& options,\n                        io::Printer* printer) const;\n\n  // Generate goog.requires() calls.\n  void GenerateRequiresForLibrary(const GeneratorOptions& options,\n                                  io::Printer* printer,\n                                  const vector<const FileDescriptor*>& files,\n                                  std::set<string>* provided) const;\n  void GenerateRequiresForMessage(const GeneratorOptions& options,\n                        io::Printer* printer,\n                        const Descriptor* desc,\n                        std::set<string>* provided) const;\n  // For extension fields at file scope.\n  void GenerateRequiresForExtensions(\n      const GeneratorOptions& options, io::Printer* printer,\n      const vector<const FieldDescriptor*>& fields,\n      std::set<string>* provided) const;\n  void GenerateRequiresImpl(const GeneratorOptions& options,\n                            io::Printer* printer,\n                            std::set<string>* required,\n                            std::set<string>* forwards,\n                            std::set<string>* provided,\n                            bool require_jspb,\n                            bool require_extension) const;\n  void FindRequiresForMessage(const GeneratorOptions& options,\n                              const Descriptor* desc,\n                              std::set<string>* required,\n                              std::set<string>* forwards,\n                              bool* have_message) const;\n  void FindRequiresForField(const GeneratorOptions& options,\n                            const FieldDescriptor* field,\n                            std::set<string>* required,\n                            std::set<string>* forwards) const;\n  void FindRequiresForExtension(const GeneratorOptions& options,\n                                const FieldDescriptor* field,\n                                std::set<string>* required,\n                                std::set<string>* forwards) const;\n\n  void GenerateFile(const GeneratorOptions& options,\n                    io::Printer* printer,\n                    const FileDescriptor* file) const;\n\n  // Generate definitions for all message classes and enums in all files,\n  // processing the files in dependence order.\n  void GenerateFilesInDepOrder(const GeneratorOptions& options,\n                               io::Printer* printer,\n                               const vector<const FileDescriptor*>& file) const;\n  // Helper for above.\n  void GenerateFileAndDeps(const GeneratorOptions& options,\n                           io::Printer* printer,\n                           const FileDescriptor* root,\n                           std::set<const FileDescriptor*>* all_files,\n                           std::set<const FileDescriptor*>* generated) const;\n\n  // Generate definitions for all message classes and enums.\n  void GenerateClassesAndEnums(const GeneratorOptions& options,\n                               io::Printer* printer,\n                               const FileDescriptor* file) const;\n\n  // Generate definition for one class.\n  void GenerateClass(const GeneratorOptions& options,\n                     io::Printer* printer,\n                     const Descriptor* desc) const;\n  void GenerateClassConstructor(const GeneratorOptions& options,\n                                io::Printer* printer,\n                                const Descriptor* desc) const;\n  void GenerateClassFieldInfo(const GeneratorOptions& options,\n                              io::Printer* printer,\n                              const Descriptor* desc) const;\n  void GenerateClassXid(const GeneratorOptions& options,\n                        io::Printer* printer,\n                        const Descriptor* desc) const;\n  void GenerateOneofCaseDefinition(const GeneratorOptions& options,\n                                   io::Printer* printer,\n                                   const OneofDescriptor* oneof) const;\n  void GenerateClassToObject(const GeneratorOptions& options,\n                             io::Printer* printer,\n                             const Descriptor* desc) const;\n  void GenerateClassFieldToObject(const GeneratorOptions& options,\n                                  io::Printer* printer,\n                                  const FieldDescriptor* field) const;\n  void GenerateClassFromObject(const GeneratorOptions& options,\n                               io::Printer* printer,\n                               const Descriptor* desc) const;\n  void GenerateClassFieldFromObject(const GeneratorOptions& options,\n                                    io::Printer* printer,\n                                    const FieldDescriptor* field) const;\n  void GenerateClassClone(const GeneratorOptions& options,\n                          io::Printer* printer,\n                          const Descriptor* desc) const;\n  void GenerateClassRegistration(const GeneratorOptions& options,\n                                 io::Printer* printer,\n                                 const Descriptor* desc) const;\n  void GenerateClassFields(const GeneratorOptions& options,\n                           io::Printer* printer,\n                           const Descriptor* desc) const;\n  void GenerateClassField(const GeneratorOptions& options,\n                          io::Printer* printer,\n                          const FieldDescriptor* desc) const;\n  void GenerateClassExtensionFieldInfo(const GeneratorOptions& options,\n                                       io::Printer* printer,\n                                       const Descriptor* desc) const;\n  void GenerateClassDeserialize(const GeneratorOptions& options,\n                                io::Printer* printer,\n                                const Descriptor* desc) const;\n  void GenerateClassDeserializeBinary(const GeneratorOptions& options,\n                                      io::Printer* printer,\n                                      const Descriptor* desc) const;\n  void GenerateClassDeserializeBinaryField(const GeneratorOptions& options,\n                                           io::Printer* printer,\n                                           const FieldDescriptor* field) const;\n  void GenerateClassSerializeBinary(const GeneratorOptions& options,\n                                    io::Printer* printer,\n                                    const Descriptor* desc) const;\n  void GenerateClassSerializeBinaryField(const GeneratorOptions& options,\n                                         io::Printer* printer,\n                                         const FieldDescriptor* field) const;\n\n  // Generate definition for one enum.\n  void GenerateEnum(const GeneratorOptions& options,\n                    io::Printer* printer,\n                    const EnumDescriptor* enumdesc) const;\n\n  // Generate an extension definition.\n  void GenerateExtension(const GeneratorOptions& options,\n                         io::Printer* printer,\n                         const FieldDescriptor* field) const;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Generator);\n};\n\n}  // namespace js\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_JS_GENERATOR_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/main.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n\n#include <google/protobuf/compiler/command_line_interface.h>\n#include <google/protobuf/compiler/cpp/cpp_generator.h>\n#include <google/protobuf/compiler/python/python_generator.h>\n#include <google/protobuf/compiler/java/java_generator.h>\n#include <google/protobuf/compiler/javanano/javanano_generator.h>\n// TODO(teboring): Add it back when php implementation is ready\n// #include <google/protobuf/compiler/php/php_generator.h>\n#include <google/protobuf/compiler/ruby/ruby_generator.h>\n#include <google/protobuf/compiler/csharp/csharp_generator.h>\n#include <google/protobuf/compiler/objectivec/objectivec_generator.h>\n#include <google/protobuf/compiler/js/js_generator.h>\n\nint main(int argc, char* argv[]) {\n\n  google::protobuf::compiler::CommandLineInterface cli;\n  cli.AllowPlugins(\"protoc-\");\n\n  // Proto2 C++\n  google::protobuf::compiler::cpp::CppGenerator cpp_generator;\n  cli.RegisterGenerator(\"--cpp_out\", \"--cpp_opt\", &cpp_generator,\n                        \"Generate C++ header and source.\");\n\n  // Proto2 Java\n  google::protobuf::compiler::java::JavaGenerator java_generator;\n  cli.RegisterGenerator(\"--java_out\", &java_generator,\n                        \"Generate Java source file.\");\n\n\n  // Proto2 Python\n  google::protobuf::compiler::python::Generator py_generator;\n  cli.RegisterGenerator(\"--python_out\", &py_generator,\n                        \"Generate Python source file.\");\n\n  // Java Nano\n  google::protobuf::compiler::javanano::JavaNanoGenerator javanano_generator;\n  cli.RegisterGenerator(\"--javanano_out\", &javanano_generator,\n                        \"Generate Java Nano source file.\");\n\n  // TODO(teboring): Add it back when php implementation is ready\n  // PHP\n  // google::protobuf::compiler::php::Generator php_generator;\n  // cli.RegisterGenerator(\"--php_out\", &php_generator,\n  //                      \"Generate PHP source file.\");\n\n  // Ruby\n  google::protobuf::compiler::ruby::Generator rb_generator;\n  cli.RegisterGenerator(\"--ruby_out\", &rb_generator,\n                        \"Generate Ruby source file.\");\n\n  // CSharp\n  google::protobuf::compiler::csharp::Generator csharp_generator;\n  cli.RegisterGenerator(\"--csharp_out\", \"--csharp_opt\", &csharp_generator,\n                        \"Generate C# source file.\");\n\n  // Objective C\n  google::protobuf::compiler::objectivec::ObjectiveCGenerator objc_generator;\n  cli.RegisterGenerator(\"--objc_out\", \"--objc_opt\", &objc_generator,\n                        \"Generate Objective C header and source.\");\n\n  // JavaScript\n  google::protobuf::compiler::js::Generator js_generator;\n  cli.RegisterGenerator(\"--js_out\", &js_generator,\n                        \"Generate JavaScript source.\");\n\n  return cli.Run(argc, argv);\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/mock_code_generator.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n\n#include <google/protobuf/compiler/mock_code_generator.h>\n\n#include <stdlib.h>\n#include <iostream>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <vector>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\n\n// Returns the list of the names of files in all_files in the form of a\n// comma-separated string.\nstring CommaSeparatedList(const vector<const FileDescriptor*> all_files) {\n  vector<string> names;\n  for (int i = 0; i < all_files.size(); i++) {\n    names.push_back(all_files[i]->name());\n  }\n  return Join(names, \",\");\n}\n\nstatic const char* kFirstInsertionPointName = \"first_mock_insertion_point\";\nstatic const char* kSecondInsertionPointName = \"second_mock_insertion_point\";\nstatic const char* kFirstInsertionPoint =\n    \"# @@protoc_insertion_point(first_mock_insertion_point) is here\\n\";\nstatic const char* kSecondInsertionPoint =\n    \"  # @@protoc_insertion_point(second_mock_insertion_point) is here\\n\";\n\nMockCodeGenerator::MockCodeGenerator(const string& name)\n    : name_(name) {}\n\nMockCodeGenerator::~MockCodeGenerator() {}\n\nvoid MockCodeGenerator::ExpectGenerated(\n    const string& name,\n    const string& parameter,\n    const string& insertions,\n    const string& file,\n    const string& first_message_name,\n    const string& first_parsed_file_name,\n    const string& output_directory) {\n  string content;\n  GOOGLE_CHECK_OK(\n      File::GetContents(output_directory + \"/\" + GetOutputFileName(name, file),\n                        &content, true));\n\n  vector<string> lines = Split(content, \"\\n\", true);\n\n  while (!lines.empty() && lines.back().empty()) {\n    lines.pop_back();\n  }\n  for (int i = 0; i < lines.size(); i++) {\n    lines[i] += \"\\n\";\n  }\n\n  vector<string> insertion_list;\n  if (!insertions.empty()) {\n    SplitStringUsing(insertions, \",\", &insertion_list);\n  }\n\n  EXPECT_EQ(lines.size(), 3 + insertion_list.size() * 2);\n  EXPECT_EQ(GetOutputFileContent(name, parameter, file,\n                                 first_parsed_file_name, first_message_name),\n            lines[0]);\n\n  EXPECT_EQ(kFirstInsertionPoint, lines[1 + insertion_list.size()]);\n  EXPECT_EQ(kSecondInsertionPoint, lines[2 + insertion_list.size() * 2]);\n\n  for (int i = 0; i < insertion_list.size(); i++) {\n    EXPECT_EQ(GetOutputFileContent(insertion_list[i], \"first_insert\",\n                                   file, file, first_message_name),\n              lines[1 + i]);\n    // Second insertion point is indented, so the inserted text should\n    // automatically be indented too.\n    EXPECT_EQ(\"  \" + GetOutputFileContent(insertion_list[i], \"second_insert\",\n                                          file, file, first_message_name),\n              lines[2 + insertion_list.size() + i]);\n  }\n}\n\nbool MockCodeGenerator::Generate(\n    const FileDescriptor* file,\n    const string& parameter,\n    GeneratorContext* context,\n    string* error) const {\n  for (int i = 0; i < file->message_type_count(); i++) {\n    if (HasPrefixString(file->message_type(i)->name(), \"MockCodeGenerator_\")) {\n      string command = StripPrefixString(file->message_type(i)->name(),\n                                         \"MockCodeGenerator_\");\n      if (command == \"Error\") {\n        *error = \"Saw message type MockCodeGenerator_Error.\";\n        return false;\n      } else if (command == \"Exit\") {\n        std::cerr << \"Saw message type MockCodeGenerator_Exit.\" << std::endl;\n        exit(123);\n      } else if (command == \"Abort\") {\n        std::cerr << \"Saw message type MockCodeGenerator_Abort.\" << std::endl;\n        abort();\n      } else if (command == \"HasSourceCodeInfo\") {\n        FileDescriptorProto file_descriptor_proto;\n        file->CopySourceCodeInfoTo(&file_descriptor_proto);\n        bool has_source_code_info =\n            file_descriptor_proto.has_source_code_info() &&\n            file_descriptor_proto.source_code_info().location_size() > 0;\n        std::cerr << \"Saw message type MockCodeGenerator_HasSourceCodeInfo: \"\n                  << has_source_code_info << \".\" << std::endl;\n        abort();\n      } else if (command == \"HasJsonName\") {\n        FieldDescriptorProto field_descriptor_proto;\n        file->message_type(i)->field(0)->CopyTo(&field_descriptor_proto);\n        std::cerr << \"Saw json_name: \"\n                  << field_descriptor_proto.has_json_name() << std::endl;\n        abort();\n      } else {\n        GOOGLE_LOG(FATAL) << \"Unknown MockCodeGenerator command: \" << command;\n      }\n    }\n  }\n\n  if (HasPrefixString(parameter, \"insert=\")) {\n    vector<string> insert_into;\n    SplitStringUsing(StripPrefixString(parameter, \"insert=\"),\n                     \",\", &insert_into);\n\n    for (int i = 0; i < insert_into.size(); i++) {\n      {\n        google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(context->OpenForInsert(\n            GetOutputFileName(insert_into[i], file), kFirstInsertionPointName));\n        io::Printer printer(output.get(), '$');\n        printer.PrintRaw(GetOutputFileContent(name_, \"first_insert\",\n                                              file, context));\n        if (printer.failed()) {\n          *error = \"MockCodeGenerator detected write error.\";\n          return false;\n        }\n      }\n\n      {\n        google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(\n            context->OpenForInsert(GetOutputFileName(insert_into[i], file),\n                                   kSecondInsertionPointName));\n        io::Printer printer(output.get(), '$');\n        printer.PrintRaw(GetOutputFileContent(name_, \"second_insert\",\n                                              file, context));\n        if (printer.failed()) {\n          *error = \"MockCodeGenerator detected write error.\";\n          return false;\n        }\n      }\n    }\n  } else {\n    google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(\n        context->Open(GetOutputFileName(name_, file)));\n\n    io::Printer printer(output.get(), '$');\n    printer.PrintRaw(GetOutputFileContent(name_, parameter,\n                                          file, context));\n    printer.PrintRaw(kFirstInsertionPoint);\n    printer.PrintRaw(kSecondInsertionPoint);\n\n    if (printer.failed()) {\n      *error = \"MockCodeGenerator detected write error.\";\n      return false;\n    }\n  }\n\n  return true;\n}\n\nstring MockCodeGenerator::GetOutputFileName(const string& generator_name,\n                                            const FileDescriptor* file) {\n  return GetOutputFileName(generator_name, file->name());\n}\n\nstring MockCodeGenerator::GetOutputFileName(const string& generator_name,\n                                            const string& file) {\n  return file + \".MockCodeGenerator.\" + generator_name;\n}\n\nstring MockCodeGenerator::GetOutputFileContent(\n    const string& generator_name,\n    const string& parameter,\n    const FileDescriptor* file,\n    GeneratorContext *context) {\n  vector<const FileDescriptor*> all_files;\n  context->ListParsedFiles(&all_files);\n  return GetOutputFileContent(\n      generator_name, parameter, file->name(),\n      CommaSeparatedList(all_files),\n      file->message_type_count() > 0 ?\n          file->message_type(0)->name() : \"(none)\");\n}\n\nstring MockCodeGenerator::GetOutputFileContent(\n    const string& generator_name,\n    const string& parameter,\n    const string& file,\n    const string& parsed_file_list,\n    const string& first_message_name) {\n  return strings::Substitute(\"$0: $1, $2, $3, $4\\n\",\n      generator_name, parameter, file,\n      first_message_name, parsed_file_list);\n}\n\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/mock_code_generator.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_MOCK_CODE_GENERATOR_H__\n#define GOOGLE_PROTOBUF_COMPILER_MOCK_CODE_GENERATOR_H__\n\n#include <string>\n\n#include <google/protobuf/compiler/code_generator.h>\n\nnamespace google {\nnamespace protobuf {\nclass FileDescriptor;\n}  // namespace protobuf\n\nnamespace protobuf {\nnamespace compiler {\n\n// A mock CodeGenerator, used by command_line_interface_unittest.  This is in\n// its own file so that it can be used both directly and as a plugin.\n//\n// Generate() produces some output which can be checked by ExpectCalled().  The\n// generator can run in a different process (e.g. a plugin).\n//\n// If the parameter is \"insert=NAMES\", the MockCodeGenerator will insert lines\n// into the files generated by other MockCodeGenerators instead of creating\n// its own file.  NAMES is a comma-separated list of the names of those other\n// MockCodeGenerators.\n//\n// MockCodeGenerator will also modify its behavior slightly if the input file\n// contains a message type with one of the following names:\n//   MockCodeGenerator_Error:  Causes Generate() to return false and set the\n//     error message to \"Saw message type MockCodeGenerator_Error.\"\n//   MockCodeGenerator_Exit:  Generate() prints \"Saw message type\n//     MockCodeGenerator_Exit.\" to stderr and then calls exit(123).\n//   MockCodeGenerator_Abort:  Generate() prints \"Saw message type\n//     MockCodeGenerator_Abort.\" to stderr and then calls abort().\n//   MockCodeGenerator_HasSourceCodeInfo:  Causes Generate() to abort after\n//     printing \"Saw message type MockCodeGenerator_HasSourceCodeInfo: FOO.\" to\n//     stderr, where FOO is \"1\" if the supplied FileDescriptorProto has source\n//     code info, and \"0\" otherwise.\nclass MockCodeGenerator : public CodeGenerator {\n public:\n  MockCodeGenerator(const string& name);\n  virtual ~MockCodeGenerator();\n\n  // Expect (via gTest) that a MockCodeGenerator with the given name was called\n  // with the given parameters by inspecting the output location.\n  //\n  // |insertions| is a comma-separated list of names of MockCodeGenerators which\n  // should have inserted lines into this file.\n  // |parsed_file_list| is a comma-separated list of names of the files\n  // that are being compiled together in this run.\n  static void ExpectGenerated(const string& name,\n                              const string& parameter,\n                              const string& insertions,\n                              const string& file,\n                              const string& first_message_name,\n                              const string& parsed_file_list,\n                              const string& output_directory);\n\n  // Get the name of the file which would be written by the given generator.\n  static string GetOutputFileName(const string& generator_name,\n                                  const FileDescriptor* file);\n  static string GetOutputFileName(const string& generator_name,\n                                  const string& file);\n\n  // implements CodeGenerator ----------------------------------------\n\n  virtual bool Generate(const FileDescriptor* file,\n                        const string& parameter,\n                        GeneratorContext* context,\n                        string* error) const;\n\n private:\n  string name_;\n\n  static string GetOutputFileContent(const string& generator_name,\n                                     const string& parameter,\n                                     const FileDescriptor* file,\n                                     GeneratorContext *context);\n  static string GetOutputFileContent(const string& generator_name,\n                                     const string& parameter,\n                                     const string& file,\n                                     const string& parsed_file_list,\n                                     const string& first_message_name);\n};\n\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_MOCK_CODE_GENERATOR_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/compiler/objectivec/objectivec_enum.h>\n#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace objectivec {\n\nEnumGenerator::EnumGenerator(const EnumDescriptor* descriptor)\n    : descriptor_(descriptor),\n      name_(EnumName(descriptor_)) {\n  for (int i = 0; i < descriptor_->value_count(); i++) {\n    const EnumValueDescriptor* value = descriptor_->value(i);\n    const EnumValueDescriptor* canonical_value =\n        descriptor_->FindValueByNumber(value->number());\n\n    if (value == canonical_value) {\n      base_values_.push_back(value);\n    }\n    all_values_.push_back(value);\n  }\n}\n\nEnumGenerator::~EnumGenerator() {}\n\nvoid EnumGenerator::GenerateHeader(io::Printer* printer) {\n  string enum_comments;\n  SourceLocation location;\n  if (descriptor_->GetSourceLocation(&location)) {\n    enum_comments = BuildCommentsString(location);\n  } else {\n    enum_comments = \"\";\n  }\n\n  printer->Print(\n      \"#pragma mark - Enum $name$\\n\"\n      \"\\n\",\n      \"name\", name_);\n\n  printer->Print(\"$comments$typedef$deprecated_attribute$ GPB_ENUM($name$) {\\n\",\n                 \"comments\", enum_comments,\n                 \"deprecated_attribute\", GetOptionalDeprecatedAttribute(descriptor_),\n                 \"name\", name_);\n  printer->Indent();\n\n  if (HasPreservingUnknownEnumSemantics(descriptor_->file())) {\n    // Include the unknown value.\n    printer->Print(\n      \"/// Value used if any message's field encounters a value that is not defined\\n\"\n      \"/// by this enum. The message will also have C functions to get/set the rawValue\\n\"\n      \"/// of the field.\\n\"\n      \"$name$_GPBUnrecognizedEnumeratorValue = kGPBUnrecognizedEnumeratorValue,\\n\",\n      \"name\", name_);\n  }\n  for (int i = 0; i < all_values_.size(); i++) {\n    SourceLocation location;\n    if (all_values_[i]->GetSourceLocation(&location)) {\n      string comments = BuildCommentsString(location).c_str();\n      if (comments.length() > 0) {\n        if (i > 0) {\n          printer->Print(\"\\n\");\n        }\n        printer->Print(comments.c_str());\n      }\n    }\n\n    printer->Print(\n        \"$name$$deprecated_attribute$ = $value$,\\n\",\n        \"name\", EnumValueName(all_values_[i]),\n        \"deprecated_attribute\", GetOptionalDeprecatedAttribute(all_values_[i]),\n        \"value\", SimpleItoa(all_values_[i]->number()));\n  }\n  printer->Outdent();\n  printer->Print(\n      \"};\\n\"\n      \"\\n\"\n      \"GPBEnumDescriptor *$name$_EnumDescriptor(void);\\n\"\n      \"\\n\"\n      \"/// Checks to see if the given value is defined by the enum or was not known at\\n\"\n      \"/// the time this source was generated.\\n\"\n      \"BOOL $name$_IsValidValue(int32_t value);\\n\"\n      \"\\n\",\n      \"name\", name_);\n}\n\nvoid EnumGenerator::GenerateSource(io::Printer* printer) {\n  printer->Print(\n      \"#pragma mark - Enum $name$\\n\"\n      \"\\n\",\n      \"name\", name_);\n\n  // Note: For the TextFormat decode info, we can't use the enum value as\n  // the key because protocol buffer enums have 'allow_alias', which lets\n  // a value be used more than once. Instead, the index into the list of\n  // enum value descriptions is used. Note: start with -1 so the first one\n  // will be zero.\n  TextFormatDecodeData text_format_decode_data;\n  int enum_value_description_key = -1;\n  string text_blob;\n\n  for (int i = 0; i < all_values_.size(); i++) {\n    ++enum_value_description_key;\n    string short_name(EnumValueShortName(all_values_[i]));\n    text_blob += short_name + '\\0';\n    if (UnCamelCaseEnumShortName(short_name) != all_values_[i]->name()) {\n      text_format_decode_data.AddString(enum_value_description_key, short_name,\n                                        all_values_[i]->name());\n    }\n  }\n\n  printer->Print(\n      \"GPBEnumDescriptor *$name$_EnumDescriptor(void) {\\n\"\n      \"  static GPBEnumDescriptor *descriptor = NULL;\\n\"\n      \"  if (!descriptor) {\\n\",\n      \"name\", name_);\n\n  static const int kBytesPerLine = 40;  // allow for escaping\n  printer->Print(\n      \"    static const char *valueNames =\");\n  for (int i = 0; i < text_blob.size(); i += kBytesPerLine) {\n    printer->Print(\n        \"\\n        \\\"$data$\\\"\",\n        \"data\", EscapeTrigraphs(CEscape(text_blob.substr(i, kBytesPerLine))));\n  }\n  printer->Print(\n      \";\\n\"\n      \"    static const int32_t values[] = {\\n\");\n  for (int i = 0; i < all_values_.size(); i++) {\n    printer->Print(\"        $name$,\\n\",  \"name\", EnumValueName(all_values_[i]));\n  }\n  printer->Print(\"    };\\n\");\n\n  if (text_format_decode_data.num_entries() == 0) {\n    printer->Print(\n        \"    GPBEnumDescriptor *worker =\\n\"\n        \"        [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol($name$)\\n\"\n        \"                                       valueNames:valueNames\\n\"\n        \"                                           values:values\\n\"\n        \"                                            count:(uint32_t)(sizeof(values) / sizeof(int32_t))\\n\"\n        \"                                     enumVerifier:$name$_IsValidValue];\\n\",\n        \"name\", name_);\n    } else {\n      printer->Print(\n        \"    static const char *extraTextFormatInfo = \\\"$extraTextFormatInfo$\\\";\\n\"\n        \"    GPBEnumDescriptor *worker =\\n\"\n        \"        [GPBEnumDescriptor allocDescriptorForName:GPBNSStringifySymbol($name$)\\n\"\n        \"                                       valueNames:valueNames\\n\"\n        \"                                           values:values\\n\"\n        \"                                            count:(uint32_t)(sizeof(values) / sizeof(int32_t))\\n\"\n        \"                                     enumVerifier:$name$_IsValidValue\\n\"\n        \"                              extraTextFormatInfo:extraTextFormatInfo];\\n\",\n        \"name\", name_,\n        \"extraTextFormatInfo\", CEscape(text_format_decode_data.Data()));\n    }\n    printer->Print(\n      \"    if (!OSAtomicCompareAndSwapPtrBarrier(nil, worker, (void * volatile *)&descriptor)) {\\n\"\n      \"      [worker release];\\n\"\n      \"    }\\n\"\n      \"  }\\n\"\n      \"  return descriptor;\\n\"\n      \"}\\n\\n\");\n\n  printer->Print(\n      \"BOOL $name$_IsValidValue(int32_t value__) {\\n\"\n      \"  switch (value__) {\\n\",\n      \"name\", name_);\n\n  for (int i = 0; i < base_values_.size(); i++) {\n    printer->Print(\n        \"    case $name$:\\n\",\n        \"name\", EnumValueName(base_values_[i]));\n  }\n\n  printer->Print(\n      \"      return YES;\\n\"\n      \"    default:\\n\"\n      \"      return NO;\\n\"\n      \"  }\\n\"\n      \"}\\n\\n\");\n}\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_enum.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_ENUM_H__\n#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_ENUM_H__\n\n#include <string>\n#include <set>\n#include <vector>\n#include <google/protobuf/descriptor.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\nclass Printer;  // printer.h\n}\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace objectivec {\n\nclass EnumGenerator {\n public:\n  explicit EnumGenerator(const EnumDescriptor* descriptor);\n  ~EnumGenerator();\n\n  void GenerateHeader(io::Printer* printer);\n  void GenerateSource(io::Printer* printer);\n\n  const string& name() const { return name_; }\n\n private:\n  const EnumDescriptor* descriptor_;\n  vector<const EnumValueDescriptor*> base_values_;\n  vector<const EnumValueDescriptor*> all_values_;\n  const string name_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumGenerator);\n};\n\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_ENUM_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/compiler/objectivec/objectivec_enum_field.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace objectivec {\n\nnamespace {\n\nvoid SetEnumVariables(const FieldDescriptor* descriptor,\n                      map<string, string>* variables) {\n  string type = EnumName(descriptor->enum_type());\n  (*variables)[\"storage_type\"] = type;\n  // For non repeated fields, if it was defined in a different file, the\n  // property decls need to use \"enum NAME\" rather than just \"NAME\" to support\n  // the forward declaration of the enums.\n  if (!descriptor->is_repeated() &&\n      (descriptor->file() != descriptor->enum_type()->file())) {\n    (*variables)[\"property_type\"] = \"enum \" + type;\n  }\n  (*variables)[\"enum_verifier\"] = type + \"_IsValidValue\";\n  (*variables)[\"enum_desc_func\"] = type + \"_EnumDescriptor\";\n\n  (*variables)[\"dataTypeSpecific_name\"] = \"enumDescFunc\";\n  (*variables)[\"dataTypeSpecific_value\"] = (*variables)[\"enum_desc_func\"];\n\n  const Descriptor* msg_descriptor = descriptor->containing_type();\n  (*variables)[\"owning_message_class\"] = ClassName(msg_descriptor);\n}\n}  // namespace\n\nEnumFieldGenerator::EnumFieldGenerator(const FieldDescriptor* descriptor,\n                                       const Options& options)\n    : SingleFieldGenerator(descriptor, options) {\n  SetEnumVariables(descriptor, &variables_);\n}\n\nEnumFieldGenerator::~EnumFieldGenerator() {}\n\nvoid EnumFieldGenerator::GenerateCFunctionDeclarations(\n    io::Printer* printer) const {\n  if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) {\n    return;\n  }\n\n  printer->Print(\n      variables_,\n      \"/// Fetches the raw value of a @c $owning_message_class$'s @c $name$ property, even\\n\"\n      \"/// if the value was not defined by the enum at the time the code was generated.\\n\"\n      \"int32_t $owning_message_class$_$capitalized_name$_RawValue($owning_message_class$ *message);\\n\"\n      \"/// Sets the raw value of an @c $owning_message_class$'s @c $name$ property, allowing\\n\"\n      \"/// it to be set to a value that was not defined by the enum at the time the code\\n\"\n      \"/// was generated.\\n\"\n      \"void Set$owning_message_class$_$capitalized_name$_RawValue($owning_message_class$ *message, int32_t value);\\n\"\n      \"\\n\");\n}\n\nvoid EnumFieldGenerator::GenerateCFunctionImplementations(\n    io::Printer* printer) const {\n  if (!HasPreservingUnknownEnumSemantics(descriptor_->file())) return;\n\n  printer->Print(\n      variables_,\n      \"int32_t $owning_message_class$_$capitalized_name$_RawValue($owning_message_class$ *message) {\\n\"\n      \"  GPBDescriptor *descriptor = [$owning_message_class$ descriptor];\\n\"\n      \"  GPBFieldDescriptor *field = [descriptor fieldWithNumber:$field_number_name$];\\n\"\n      \"  return GPBGetMessageInt32Field(message, field);\\n\"\n      \"}\\n\"\n      \"\\n\"\n      \"void Set$owning_message_class$_$capitalized_name$_RawValue($owning_message_class$ *message, int32_t value) {\\n\"\n      \"  GPBDescriptor *descriptor = [$owning_message_class$ descriptor];\\n\"\n      \"  GPBFieldDescriptor *field = [descriptor fieldWithNumber:$field_number_name$];\\n\"\n      \"  GPBSetInt32IvarWithFieldInternal(message, field, value, descriptor.file.syntax);\\n\"\n      \"}\\n\"\n      \"\\n\");\n}\n\nvoid EnumFieldGenerator::DetermineForwardDeclarations(\n    set<string>* fwd_decls) const {\n  SingleFieldGenerator::DetermineForwardDeclarations(fwd_decls);\n  // If it is an enum defined in a different file, then we'll need a forward\n  // declaration for it.  When it is in our file, all the enums are output\n  // before the message, so it will be declared before it is needed.\n  if (descriptor_->file() != descriptor_->enum_type()->file()) {\n    // Enum name is already in \"storage_type\".\n    const string& name = variable(\"storage_type\");\n    fwd_decls->insert(\"GPB_ENUM_FWD_DECLARE(\" + name + \")\");\n  }\n}\n\nRepeatedEnumFieldGenerator::RepeatedEnumFieldGenerator(\n    const FieldDescriptor* descriptor, const Options& options)\n    : RepeatedFieldGenerator(descriptor, options) {\n  SetEnumVariables(descriptor, &variables_);\n  variables_[\"array_storage_type\"] = \"GPBEnumArray\";\n}\n\nRepeatedEnumFieldGenerator::~RepeatedEnumFieldGenerator() {}\n\nvoid RepeatedEnumFieldGenerator::FinishInitialization(void) {\n  RepeatedFieldGenerator::FinishInitialization();\n  variables_[\"array_comment\"] =\n      \"// |\" + variables_[\"name\"] + \"| contains |\" + variables_[\"storage_type\"] + \"|\\n\";\n}\n\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_ENUM_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_ENUM_FIELD_H__\n\n#include <map>\n#include <string>\n#include <google/protobuf/compiler/objectivec/objectivec_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace objectivec {\n\nclass EnumFieldGenerator : public SingleFieldGenerator {\n  friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field,\n                                              const Options& options);\n\n public:\n  virtual void GenerateCFunctionDeclarations(io::Printer* printer) const;\n  virtual void GenerateCFunctionImplementations(io::Printer* printer) const;\n  virtual void DetermineForwardDeclarations(set<string>* fwd_decls) const;\n\n protected:\n  EnumFieldGenerator(const FieldDescriptor* descriptor, const Options& options);\n  virtual ~EnumFieldGenerator();\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumFieldGenerator);\n};\n\nclass RepeatedEnumFieldGenerator : public RepeatedFieldGenerator {\n  friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field,\n                                              const Options& options);\n\n public:\n  virtual void FinishInitialization();\n\n protected:\n  RepeatedEnumFieldGenerator(const FieldDescriptor* descriptor,\n                             const Options& options);\n  virtual ~RepeatedEnumFieldGenerator();\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedEnumFieldGenerator);\n};\n\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_ENUM_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <iostream>\n\n#include <google/protobuf/compiler/objectivec/objectivec_extension.h>\n#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/io/printer.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace objectivec {\n\nExtensionGenerator::ExtensionGenerator(const string& root_class_name,\n                                       const FieldDescriptor* descriptor)\n    : method_name_(ExtensionMethodName(descriptor)),\n      root_class_and_method_name_(root_class_name + \"_\" + method_name_),\n      descriptor_(descriptor) {\n  if (descriptor->is_map()) {\n    // NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some\n    // error cases, so it seems to be ok to use as a back door for errors.\n    cerr << \"error: Extension is a map<>!\"\n         << \" That used to be blocked by the compiler.\" << endl;\n    cerr.flush();\n    abort();\n  }\n}\n\nExtensionGenerator::~ExtensionGenerator() {}\n\nvoid ExtensionGenerator::GenerateMembersHeader(io::Printer* printer) {\n  map<string, string> vars;\n  vars[\"method_name\"] = method_name_;\n  SourceLocation location;\n  if (descriptor_->GetSourceLocation(&location)) {\n    vars[\"comments\"] = BuildCommentsString(location);\n  } else {\n    vars[\"comments\"] = \"\";\n  }\n  printer->Print(vars,\n                 \"$comments$\"\n                 \"+ (GPBExtensionDescriptor *)$method_name$;\\n\");\n}\n\nvoid ExtensionGenerator::GenerateStaticVariablesInitialization(\n    io::Printer* printer) {\n  map<string, string> vars;\n  vars[\"root_class_and_method_name\"] = root_class_and_method_name_;\n  vars[\"extended_type\"] = ClassName(descriptor_->containing_type());\n  vars[\"number\"] = SimpleItoa(descriptor_->number());\n\n  std::vector<string> options;\n  if (descriptor_->is_repeated()) options.push_back(\"GPBExtensionRepeated\");\n  if (descriptor_->is_packed()) options.push_back(\"GPBExtensionPacked\");\n  if (descriptor_->containing_type()->options().message_set_wire_format())\n    options.push_back(\"GPBExtensionSetWireFormat\");\n\n  vars[\"options\"] = BuildFlagsString(options);\n\n  ObjectiveCType objc_type = GetObjectiveCType(descriptor_);\n  string singular_type;\n  if (objc_type == OBJECTIVECTYPE_MESSAGE) {\n    vars[\"type\"] = string(\"GPBStringifySymbol(\") +\n                   ClassName(descriptor_->message_type()) + \")\";\n  } else {\n    vars[\"type\"] = \"NULL\";\n  }\n\n  vars[\"default_name\"] = GPBGenericValueFieldName(descriptor_);\n  if (descriptor_->is_repeated()) {\n    vars[\"default\"] = \"nil\";\n  } else {\n    vars[\"default\"] = DefaultValue(descriptor_);\n  }\n  string type = GetCapitalizedType(descriptor_);\n  vars[\"extension_type\"] = string(\"GPBDataType\") + type;\n\n  if (objc_type == OBJECTIVECTYPE_ENUM) {\n    vars[\"enum_desc_func_name\"] =\n         EnumName(descriptor_->enum_type()) + \"_EnumDescriptor\";\n  } else {\n    vars[\"enum_desc_func_name\"] = \"NULL\";\n  }\n\n  printer->Print(vars,\n                 \"{\\n\"\n                 \"  .defaultValue.$default_name$ = $default$,\\n\"\n                 \"  .singletonName = GPBStringifySymbol($root_class_and_method_name$),\\n\"\n                 \"  .extendedClass = GPBStringifySymbol($extended_type$),\\n\"\n                 \"  .messageOrGroupClassName = $type$,\\n\"\n                 \"  .enumDescriptorFunc = $enum_desc_func_name$,\\n\"\n                 \"  .fieldNumber = $number$,\\n\"\n                 \"  .dataType = $extension_type$,\\n\"\n                 \"  .options = $options$,\\n\"\n                 \"},\\n\");\n}\n\nvoid ExtensionGenerator::GenerateRegistrationSource(io::Printer* printer) {\n  printer->Print(\n      \"[registry addExtension:$root_class_and_method_name$];\\n\",\n      \"root_class_and_method_name\", root_class_and_method_name_);\n}\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_extension.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_EXTENSION_H__\n#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_EXTENSION_H__\n\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\nclass FieldDescriptor;  // descriptor.h\nnamespace io {\nclass Printer;  // printer.h\n}\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace objectivec {\n\nclass ExtensionGenerator {\n public:\n  ExtensionGenerator(const string& root_class_name,\n                     const FieldDescriptor* descriptor);\n  ~ExtensionGenerator();\n\n  void GenerateMembersHeader(io::Printer* printer);\n  void GenerateStaticVariablesInitialization(io::Printer* printer);\n  void GenerateRegistrationSource(io::Printer* printer);\n\n private:\n  string method_name_;\n  string root_class_and_method_name_;\n  const FieldDescriptor* descriptor_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionGenerator);\n};\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MESSAGE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <iostream>\n\n#include <google/protobuf/compiler/objectivec/objectivec_field.h>\n#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>\n#include <google/protobuf/compiler/objectivec/objectivec_enum_field.h>\n#include <google/protobuf/compiler/objectivec/objectivec_map_field.h>\n#include <google/protobuf/compiler/objectivec/objectivec_message_field.h>\n#include <google/protobuf/compiler/objectivec/objectivec_primitive_field.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace objectivec {\n\nnamespace {\n\nvoid SetCommonFieldVariables(const FieldDescriptor* descriptor,\n                             map<string, string>* variables) {\n  string camel_case_name = FieldName(descriptor);\n  string raw_field_name;\n  if (descriptor->type() == FieldDescriptor::TYPE_GROUP) {\n    raw_field_name = descriptor->message_type()->name();\n  } else {\n    raw_field_name = descriptor->name();\n  }\n  // The logic here has to match -[GGPBFieldDescriptor textFormatName].\n  const string un_camel_case_name(\n      UnCamelCaseFieldName(camel_case_name, descriptor));\n  const bool needs_custom_name = (raw_field_name != un_camel_case_name);\n\n  SourceLocation location;\n  if (descriptor->GetSourceLocation(&location)) {\n    (*variables)[\"comments\"] = BuildCommentsString(location);\n  } else {\n    (*variables)[\"comments\"] = \"\\n\";\n  }\n  const string& classname = ClassName(descriptor->containing_type());\n  (*variables)[\"classname\"] = classname;\n  (*variables)[\"name\"] = camel_case_name;\n  const string& capitalized_name = FieldNameCapitalized(descriptor);\n  (*variables)[\"capitalized_name\"] = capitalized_name;\n  (*variables)[\"raw_field_name\"] = raw_field_name;\n  (*variables)[\"field_number_name\"] =\n      classname + \"_FieldNumber_\" + capitalized_name;\n  (*variables)[\"field_number\"] = SimpleItoa(descriptor->number());\n  (*variables)[\"field_type\"] = GetCapitalizedType(descriptor);\n  (*variables)[\"deprecated_attribute\"] = GetOptionalDeprecatedAttribute(descriptor);\n  std::vector<string> field_flags;\n  if (descriptor->is_repeated()) field_flags.push_back(\"GPBFieldRepeated\");\n  if (descriptor->is_required()) field_flags.push_back(\"GPBFieldRequired\");\n  if (descriptor->is_optional()) field_flags.push_back(\"GPBFieldOptional\");\n  if (descriptor->is_packed()) field_flags.push_back(\"GPBFieldPacked\");\n\n  // ObjC custom flags.\n  if (descriptor->has_default_value())\n    field_flags.push_back(\"GPBFieldHasDefaultValue\");\n  if (needs_custom_name) field_flags.push_back(\"GPBFieldTextFormatNameCustom\");\n  if (descriptor->type() == FieldDescriptor::TYPE_ENUM) {\n    field_flags.push_back(\"GPBFieldHasEnumDescriptor\");\n  }\n\n  (*variables)[\"fieldflags\"] = BuildFlagsString(field_flags);\n\n  (*variables)[\"default\"] = DefaultValue(descriptor);\n  (*variables)[\"default_name\"] = GPBGenericValueFieldName(descriptor);\n\n  (*variables)[\"dataTypeSpecific_name\"] = \"className\";\n  (*variables)[\"dataTypeSpecific_value\"] = \"NULL\";\n\n  (*variables)[\"storage_offset_value\"] =\n      \"(uint32_t)offsetof(\" + classname + \"__storage_, \" + camel_case_name + \")\";\n  (*variables)[\"storage_offset_comment\"] = \"\";\n\n  // Clear some common things so they can be set just when needed.\n  (*variables)[\"storage_attribute\"] = \"\";\n}\n\n}  // namespace\n\nFieldGenerator* FieldGenerator::Make(const FieldDescriptor* field,\n                                     const Options& options) {\n  FieldGenerator* result = NULL;\n  if (field->is_repeated()) {\n    switch (GetObjectiveCType(field)) {\n      case OBJECTIVECTYPE_MESSAGE: {\n        if (field->is_map()) {\n          result = new MapFieldGenerator(field, options);\n        } else {\n          result = new RepeatedMessageFieldGenerator(field, options);\n        }\n        break;\n      }\n      case OBJECTIVECTYPE_ENUM:\n        result = new RepeatedEnumFieldGenerator(field, options);\n        break;\n      default:\n        result = new RepeatedPrimitiveFieldGenerator(field, options);\n        break;\n    }\n  } else {\n    switch (GetObjectiveCType(field)) {\n      case OBJECTIVECTYPE_MESSAGE: {\n        result = new MessageFieldGenerator(field, options);\n        break;\n      }\n      case OBJECTIVECTYPE_ENUM:\n        result = new EnumFieldGenerator(field, options);\n        break;\n      default:\n        if (IsReferenceType(field)) {\n          result = new PrimitiveObjFieldGenerator(field, options);\n        } else {\n          result = new PrimitiveFieldGenerator(field, options);\n        }\n        break;\n    }\n  }\n  result->FinishInitialization();\n  return result;\n}\n\nFieldGenerator::FieldGenerator(const FieldDescriptor* descriptor,\n                               const Options& options)\n    : descriptor_(descriptor) {\n  SetCommonFieldVariables(descriptor, &variables_);\n}\n\nFieldGenerator::~FieldGenerator() {}\n\nvoid FieldGenerator::GenerateFieldNumberConstant(io::Printer* printer) const {\n  printer->Print(\n      variables_,\n      \"$field_number_name$ = $field_number$,\\n\");\n}\n\nvoid FieldGenerator::GenerateCFunctionDeclarations(\n    io::Printer* printer) const {\n  // Nothing\n}\n\nvoid FieldGenerator::GenerateCFunctionImplementations(\n    io::Printer* printer) const {\n  // Nothing\n}\n\nvoid FieldGenerator::DetermineForwardDeclarations(\n    set<string>* fwd_decls) const {\n  // Nothing\n}\n\nvoid FieldGenerator::GenerateFieldDescription(\n    io::Printer* printer, bool include_default) const {\n  // Printed in the same order as the structure decl.\n  if (include_default) {\n    printer->Print(\n        variables_,\n        \"{\\n\"\n        \"  .defaultValue.$default_name$ = $default$,\\n\"\n        \"  .core.name = \\\"$name$\\\",\\n\"\n        \"  .core.dataTypeSpecific.$dataTypeSpecific_name$ = $dataTypeSpecific_value$,\\n\"\n        \"  .core.number = $field_number_name$,\\n\"\n        \"  .core.hasIndex = $has_index$,\\n\"\n        \"  .core.offset = $storage_offset_value$,$storage_offset_comment$\\n\"\n        \"  .core.flags = $fieldflags$,\\n\"\n        \"  .core.dataType = GPBDataType$field_type$,\\n\"\n        \"},\\n\");\n  } else {\n    printer->Print(\n        variables_,\n        \"{\\n\"\n        \"  .name = \\\"$name$\\\",\\n\"\n        \"  .dataTypeSpecific.$dataTypeSpecific_name$ = $dataTypeSpecific_value$,\\n\"\n        \"  .number = $field_number_name$,\\n\"\n        \"  .hasIndex = $has_index$,\\n\"\n        \"  .offset = $storage_offset_value$,$storage_offset_comment$\\n\"\n        \"  .flags = $fieldflags$,\\n\"\n        \"  .dataType = GPBDataType$field_type$,\\n\"\n        \"},\\n\");\n  }\n}\n\nvoid FieldGenerator::SetRuntimeHasBit(int has_index) {\n  variables_[\"has_index\"] = SimpleItoa(has_index);\n}\n\nvoid FieldGenerator::SetNoHasBit(void) {\n  variables_[\"has_index\"] = \"GPBNoHasBit\";\n}\n\nint FieldGenerator::ExtraRuntimeHasBitsNeeded(void) const {\n  return 0;\n}\n\nvoid FieldGenerator::SetExtraRuntimeHasBitsBase(int index_base) {\n  // NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some\n  // error cases, so it seems to be ok to use as a back door for errors.\n  cerr << \"Error: should have overridden SetExtraRuntimeHasBitsBase().\" << endl;\n  cerr.flush();\n  abort();\n}\n\nvoid FieldGenerator::SetOneofIndexBase(int index_base) {\n  if (descriptor_->containing_oneof() != NULL) {\n    int index = descriptor_->containing_oneof()->index() + index_base;\n    // Flip the sign to mark it as a oneof.\n    variables_[\"has_index\"] = SimpleItoa(-index);\n  }\n}\n\nvoid FieldGenerator::FinishInitialization(void) {\n  // If \"property_type\" wasn't set, make it \"storage_type\".\n  if ((variables_.find(\"property_type\") == variables_.end()) &&\n      (variables_.find(\"storage_type\") != variables_.end())) {\n    variables_[\"property_type\"] = variable(\"storage_type\");\n  }\n}\n\nSingleFieldGenerator::SingleFieldGenerator(const FieldDescriptor* descriptor,\n                                           const Options& options)\n    : FieldGenerator(descriptor, options) {\n  // Nothing\n}\n\nSingleFieldGenerator::~SingleFieldGenerator() {}\n\nvoid SingleFieldGenerator::GenerateFieldStorageDeclaration(\n    io::Printer* printer) const {\n  printer->Print(variables_, \"$storage_type$ $name$;\\n\");\n}\n\nvoid SingleFieldGenerator::GeneratePropertyDeclaration(\n    io::Printer* printer) const {\n  printer->Print(variables_, \"$comments$\");\n  printer->Print(\n      variables_,\n      \"@property(nonatomic, readwrite) $property_type$ $name$$deprecated_attribute$;\\n\"\n      \"\\n\");\n  if (WantsHasProperty()) {\n    printer->Print(\n        variables_,\n        \"@property(nonatomic, readwrite) BOOL has$capitalized_name$$deprecated_attribute$;\\n\");\n  }\n}\n\nvoid SingleFieldGenerator::GeneratePropertyImplementation(\n    io::Printer* printer) const {\n  if (WantsHasProperty()) {\n    printer->Print(variables_, \"@dynamic has$capitalized_name$, $name$;\\n\");\n  } else {\n    printer->Print(variables_, \"@dynamic $name$;\\n\");\n  }\n}\n\nbool SingleFieldGenerator::WantsHasProperty(void) const {\n  if (descriptor_->containing_oneof() != NULL) {\n    // If in a oneof, it uses the oneofcase instead of a has bit.\n    return false;\n  }\n  if (HasFieldPresence(descriptor_->file())) {\n    // In proto1/proto2, every field has a has_$name$() method.\n    return true;\n  }\n  return false;\n}\n\nbool SingleFieldGenerator::RuntimeUsesHasBit(void) const {\n  if (descriptor_->containing_oneof() != NULL) {\n    // The oneof tracks what is set instead.\n    return false;\n  }\n  return true;\n}\n\nObjCObjFieldGenerator::ObjCObjFieldGenerator(const FieldDescriptor* descriptor,\n                                             const Options& options)\n    : SingleFieldGenerator(descriptor, options) {\n  variables_[\"property_storage_attribute\"] = \"strong\";\n  if (IsRetainedName(variables_[\"name\"])) {\n    variables_[\"storage_attribute\"] = \" NS_RETURNS_NOT_RETAINED\";\n  }\n}\n\nObjCObjFieldGenerator::~ObjCObjFieldGenerator() {}\n\nvoid ObjCObjFieldGenerator::GenerateFieldStorageDeclaration(\n    io::Printer* printer) const {\n  printer->Print(variables_, \"$storage_type$ *$name$;\\n\");\n}\n\nvoid ObjCObjFieldGenerator::GeneratePropertyDeclaration(\n    io::Printer* printer) const {\n\n  // Differs from SingleFieldGenerator::GeneratePropertyDeclaration() in that\n  // it uses pointers and deals with Objective C's rules around storage name\n  // conventions (init*, new*, etc.)\n\n  printer->Print(variables_, \"$comments$\");\n  printer->Print(\n      variables_,\n      \"@property(nonatomic, readwrite, $property_storage_attribute$, null_resettable) $property_type$ *$name$$storage_attribute$$deprecated_attribute$;\\n\");\n  if (WantsHasProperty()) {\n    printer->Print(\n        variables_,\n        \"/// Test to see if @c $name$ has been set.\\n\"\n        \"@property(nonatomic, readwrite) BOOL has$capitalized_name$$deprecated_attribute$;\\n\");\n  }\n  if (IsInitName(variables_.find(\"name\")->second)) {\n    // If property name starts with init we need to annotate it to get past ARC.\n    // http://stackoverflow.com/questions/18723226/how-do-i-annotate-an-objective-c-property-with-an-objc-method-family/18723227#18723227\n    printer->Print(variables_,\n                   \"- ($property_type$ *)$name$ GPB_METHOD_FAMILY_NONE$deprecated_attribute$;\\n\");\n  }\n  printer->Print(\"\\n\");\n}\n\nRepeatedFieldGenerator::RepeatedFieldGenerator(\n    const FieldDescriptor* descriptor, const Options& options)\n    : ObjCObjFieldGenerator(descriptor, options) {\n  // Default to no comment and let the cases needing it fill it in.\n  variables_[\"array_comment\"] = \"\";\n}\n\nRepeatedFieldGenerator::~RepeatedFieldGenerator() {}\n\nvoid RepeatedFieldGenerator::FinishInitialization(void) {\n  FieldGenerator::FinishInitialization();\n  if (variables_.find(\"array_property_type\") == variables_.end()) {\n    variables_[\"array_property_type\"] = variable(\"array_storage_type\");\n  }\n}\n\nvoid RepeatedFieldGenerator::GenerateFieldStorageDeclaration(\n    io::Printer* printer) const {\n  printer->Print(variables_, \"$array_storage_type$ *$name$;\\n\");\n}\n\nvoid RepeatedFieldGenerator::GeneratePropertyImplementation(\n    io::Printer* printer) const {\n  printer->Print(variables_, \"@dynamic $name$, $name$_Count;\\n\");\n}\n\nvoid RepeatedFieldGenerator::GeneratePropertyDeclaration(\n    io::Printer* printer) const {\n\n  // Repeated fields don't need the has* properties, but they do expose a\n  // *Count (to check without autocreation).  So for the field property we need\n  // the same logic as ObjCObjFieldGenerator::GeneratePropertyDeclaration() for\n  // dealing with needing Objective C's rules around storage name conventions\n  // (init*, new*, etc.)\n\n  printer->Print(\n      variables_,\n      \"$comments$\"\n      \"$array_comment$\"\n      \"@property(nonatomic, readwrite, strong, null_resettable) $array_property_type$ *$name$$storage_attribute$$deprecated_attribute$;\\n\"\n      \"/// The number of items in @c $name$ without causing the array to be created.\\n\"\n      \"@property(nonatomic, readonly) NSUInteger $name$_Count$deprecated_attribute$;\\n\");\n  if (IsInitName(variables_.find(\"name\")->second)) {\n    // If property name starts with init we need to annotate it to get past ARC.\n    // http://stackoverflow.com/questions/18723226/how-do-i-annotate-an-objective-c-property-with-an-objc-method-family/18723227#18723227\n    printer->Print(variables_,\n                   \"- ($array_property_type$ *)$name$ GPB_METHOD_FAMILY_NONE$deprecated_attribute$;\\n\");\n  }\n  printer->Print(\"\\n\");\n}\n\nbool RepeatedFieldGenerator::WantsHasProperty(void) const {\n  // Consumer check the array size/existance rather than a has bit.\n  return false;\n}\n\nbool RepeatedFieldGenerator::RuntimeUsesHasBit(void) const {\n  return false;  // The array having anything is what is used.\n}\n\nFieldGeneratorMap::FieldGeneratorMap(const Descriptor* descriptor,\n                                     const Options& options)\n    : descriptor_(descriptor),\n      field_generators_(\n          new scoped_ptr<FieldGenerator>[descriptor->field_count()]),\n      extension_generators_(\n          new scoped_ptr<FieldGenerator>[descriptor->extension_count()]) {\n  // Construct all the FieldGenerators.\n  for (int i = 0; i < descriptor->field_count(); i++) {\n    field_generators_[i].reset(\n        FieldGenerator::Make(descriptor->field(i), options));\n  }\n  for (int i = 0; i < descriptor->extension_count(); i++) {\n    extension_generators_[i].reset(\n        FieldGenerator::Make(descriptor->extension(i), options));\n  }\n}\n\nFieldGeneratorMap::~FieldGeneratorMap() {}\n\nconst FieldGenerator& FieldGeneratorMap::get(\n    const FieldDescriptor* field) const {\n  GOOGLE_CHECK_EQ(field->containing_type(), descriptor_);\n  return *field_generators_[field->index()];\n}\n\nconst FieldGenerator& FieldGeneratorMap::get_extension(int index) const {\n  return *extension_generators_[index];\n}\n\nint FieldGeneratorMap::CalculateHasBits(void) {\n  int total_bits = 0;\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    if (field_generators_[i]->RuntimeUsesHasBit()) {\n      field_generators_[i]->SetRuntimeHasBit(total_bits);\n      ++total_bits;\n    } else {\n      field_generators_[i]->SetNoHasBit();\n    }\n    int extra_bits = field_generators_[i]->ExtraRuntimeHasBitsNeeded();\n    if (extra_bits) {\n      field_generators_[i]->SetExtraRuntimeHasBitsBase(total_bits);\n      total_bits += extra_bits;\n    }\n  }\n  return total_bits;\n}\n\nvoid FieldGeneratorMap::SetOneofIndexBase(int index_base) {\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    field_generators_[i]->SetOneofIndexBase(index_base);\n  }\n}\n\nbool FieldGeneratorMap::DoesAnyFieldHaveNonZeroDefault(void) const {\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    if (HasNonZeroDefaultValue(descriptor_->field(i))) {\n      return true;\n    }\n  }\n\n  return false;\n}\n\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_FIELD_H__\n\n#include <map>\n#include <string>\n#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/descriptor.h>\n\nnamespace google {\nnamespace protobuf {\n\nnamespace io {\nclass Printer;  // printer.h\n}  // namespace io\n\nnamespace compiler {\nnamespace objectivec {\n\nclass FieldGenerator {\n public:\n  static FieldGenerator* Make(const FieldDescriptor* field,\n                              const Options& options);\n\n  virtual ~FieldGenerator();\n\n  // Exposed for subclasses to fill in.\n  virtual void GenerateFieldStorageDeclaration(io::Printer* printer) const = 0;\n  virtual void GeneratePropertyDeclaration(io::Printer* printer) const = 0;\n  virtual void GeneratePropertyImplementation(io::Printer* printer) const = 0;\n\n  // Called by GenerateFieldDescription, exposed for classes that need custom\n  // generation.\n\n  // Exposed for subclasses to extend, base does nothing.\n  virtual void GenerateCFunctionDeclarations(io::Printer* printer) const;\n  virtual void GenerateCFunctionImplementations(io::Printer* printer) const;\n\n  // Exposed for subclasses, should always call it on the parent class also.\n  virtual void DetermineForwardDeclarations(set<string>* fwd_decls) const;\n\n  // Used during generation, not intended to be extended by subclasses.\n  void GenerateFieldDescription(\n      io::Printer* printer, bool include_default) const;\n  void GenerateFieldNumberConstant(io::Printer* printer) const;\n\n  // Exposed to get and set the has bits information.\n  virtual bool RuntimeUsesHasBit(void) const = 0;\n  void SetRuntimeHasBit(int has_index);\n  void SetNoHasBit(void);\n  virtual int ExtraRuntimeHasBitsNeeded(void) const;\n  virtual void SetExtraRuntimeHasBitsBase(int index_base);\n  void SetOneofIndexBase(int index_base);\n\n  string variable(const char* key) const {\n    return variables_.find(key)->second;\n  }\n\n  bool needs_textformat_name_support() const {\n    const string& field_flags = variable(\"fieldflags\");\n    return field_flags.find(\"GPBFieldTextFormatNameCustom\") != string::npos;\n  }\n  string generated_objc_name() const { return variable(\"name\"); }\n  string raw_field_name() const { return variable(\"raw_field_name\"); }\n\n protected:\n  FieldGenerator(const FieldDescriptor* descriptor, const Options& options);\n\n  virtual void FinishInitialization(void);\n  virtual bool WantsHasProperty(void) const = 0;\n\n  const FieldDescriptor* descriptor_;\n  map<string, string> variables_;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGenerator);\n};\n\nclass SingleFieldGenerator : public FieldGenerator {\n public:\n  virtual ~SingleFieldGenerator();\n\n  virtual void GenerateFieldStorageDeclaration(io::Printer* printer) const;\n  virtual void GeneratePropertyDeclaration(io::Printer* printer) const;\n\n  virtual void GeneratePropertyImplementation(io::Printer* printer) const;\n\n  virtual bool RuntimeUsesHasBit(void) const;\n\n protected:\n  SingleFieldGenerator(const FieldDescriptor* descriptor,\n                       const Options& options);\n  virtual bool WantsHasProperty(void) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SingleFieldGenerator);\n};\n\n// Subclass with common support for when the field ends up as an ObjC Object.\nclass ObjCObjFieldGenerator : public SingleFieldGenerator {\n public:\n  virtual ~ObjCObjFieldGenerator();\n\n  virtual void GenerateFieldStorageDeclaration(io::Printer* printer) const;\n  virtual void GeneratePropertyDeclaration(io::Printer* printer) const;\n\n protected:\n  ObjCObjFieldGenerator(const FieldDescriptor* descriptor,\n                        const Options& options);\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjCObjFieldGenerator);\n};\n\nclass RepeatedFieldGenerator : public ObjCObjFieldGenerator {\n public:\n  virtual ~RepeatedFieldGenerator();\n\n  virtual void GenerateFieldStorageDeclaration(io::Printer* printer) const;\n  virtual void GeneratePropertyDeclaration(io::Printer* printer) const;\n\n  virtual void GeneratePropertyImplementation(io::Printer* printer) const;\n\n  virtual bool RuntimeUsesHasBit(void) const;\n\n protected:\n  RepeatedFieldGenerator(const FieldDescriptor* descriptor,\n                         const Options& options);\n  virtual void FinishInitialization(void);\n  virtual bool WantsHasProperty(void) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedFieldGenerator);\n};\n\n// Convenience class which constructs FieldGenerators for a Descriptor.\nclass FieldGeneratorMap {\n public:\n  FieldGeneratorMap(const Descriptor* descriptor, const Options& options);\n  ~FieldGeneratorMap();\n\n  const FieldGenerator& get(const FieldDescriptor* field) const;\n  const FieldGenerator& get_extension(int index) const;\n\n  // Assigns the has bits and returns the number of bits needed.\n  int CalculateHasBits(void);\n\n  void SetOneofIndexBase(int index_base);\n\n  // Check if any field of this message has a non zero default.\n  bool DoesAnyFieldHaveNonZeroDefault(void) const;\n\n private:\n  const Descriptor* descriptor_;\n  scoped_array<scoped_ptr<FieldGenerator> > field_generators_;\n  scoped_array<scoped_ptr<FieldGenerator> > extension_generators_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldGeneratorMap);\n};\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_file.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/compiler/objectivec/objectivec_file.h>\n#include <google/protobuf/compiler/objectivec/objectivec_enum.h>\n#include <google/protobuf/compiler/objectivec/objectivec_extension.h>\n#include <google/protobuf/compiler/objectivec/objectivec_message.h>\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/stubs/stl_util.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <iostream>\n#include <sstream>\n\n// NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some\n// error cases, so it seems to be ok to use as a back door for errors.\n\nnamespace google {\nnamespace protobuf {\n\n// This is also found in GPBBootstrap.h, and needs to be kept in sync.  It\n// is the version check done to ensure generated code works with the current\n// runtime being used.\nconst int32 GOOGLE_PROTOBUF_OBJC_GEN_VERSION = 30001;\n\nnamespace compiler {\nnamespace objectivec {\n\nnamespace {\n\nclass ImportWriter {\n public:\n  ImportWriter(const Options& options)\n      : options_(options),\n        need_to_parse_mapping_file_(true) {}\n\n  void AddFile(const FileGenerator* file);\n  void Print(io::Printer *printer) const;\n\n private:\n  class ProtoFrameworkCollector : public LineConsumer {\n   public:\n    ProtoFrameworkCollector(map<string, string>* inout_proto_file_to_framework_name)\n        : map_(inout_proto_file_to_framework_name) {}\n\n    virtual bool ConsumeLine(const StringPiece& line, string* out_error);\n\n   private:\n    map<string, string>* map_;\n  };\n\n  void ParseFrameworkMappings();\n\n  const Options options_;\n  map<string, string> proto_file_to_framework_name_;\n  bool need_to_parse_mapping_file_;\n\n  vector<string> protobuf_framework_imports_;\n  vector<string> protobuf_non_framework_imports_;\n  vector<string> other_framework_imports_;\n  vector<string> other_imports_;\n};\n\nvoid ImportWriter::AddFile(const FileGenerator* file) {\n  const FileDescriptor* file_descriptor = file->Descriptor();\n  const string extension(\".pbobjc.h\");\n\n  if (IsProtobufLibraryBundledProtoFile(file_descriptor)) {\n    protobuf_framework_imports_.push_back(\n        FilePathBasename(file_descriptor) + extension);\n    protobuf_non_framework_imports_.push_back(file->Path() + extension);\n    return;\n  }\n\n  // Lazy parse any mappings.\n  if (need_to_parse_mapping_file_) {\n    ParseFrameworkMappings();\n  }\n\n  map<string, string>::iterator proto_lookup =\n      proto_file_to_framework_name_.find(file_descriptor->name());\n  if (proto_lookup != proto_file_to_framework_name_.end()) {\n    other_framework_imports_.push_back(\n        proto_lookup->second + \"/\" +\n        FilePathBasename(file_descriptor) + extension);\n    return;\n  }\n\n  if (!options_.generate_for_named_framework.empty()) {\n    other_framework_imports_.push_back(\n        options_.generate_for_named_framework + \"/\" +\n        FilePathBasename(file_descriptor) + extension);\n    return;\n  }\n\n  other_imports_.push_back(file->Path() + extension);\n}\n\nvoid ImportWriter::Print(io::Printer* printer) const {\n  assert(protobuf_non_framework_imports_.size() ==\n         protobuf_framework_imports_.size());\n\n  bool add_blank_line = false;\n\n  if (protobuf_framework_imports_.size() > 0) {\n    const string framework_name(ProtobufLibraryFrameworkName);\n    const string cpp_symbol(ProtobufFrameworkImportSymbol(framework_name));\n\n    printer->Print(\n        \"#if $cpp_symbol$\\n\",\n        \"cpp_symbol\", cpp_symbol);\n    for (vector<string>::const_iterator iter = protobuf_framework_imports_.begin();\n         iter != protobuf_framework_imports_.end(); ++iter) {\n      printer->Print(\n          \" #import <$framework_name$/$header$>\\n\",\n          \"framework_name\", framework_name,\n          \"header\", *iter);\n    }\n    printer->Print(\n        \"#else\\n\");\n    for (vector<string>::const_iterator iter = protobuf_non_framework_imports_.begin();\n         iter != protobuf_non_framework_imports_.end(); ++iter) {\n      printer->Print(\n          \" #import \\\"$header$\\\"\\n\",\n          \"header\", *iter);\n    }\n    printer->Print(\n        \"#endif\\n\");\n\n    add_blank_line = true;\n  }\n\n  if (other_framework_imports_.size() > 0) {\n    if (add_blank_line) {\n      printer->Print(\"\\n\");\n    }\n\n    for (vector<string>::const_iterator iter = other_framework_imports_.begin();\n         iter != other_framework_imports_.end(); ++iter) {\n      printer->Print(\n          \" #import <$header$>\\n\",\n          \"header\", *iter);\n    }\n\n    add_blank_line = true;\n  }\n\n  if (other_imports_.size() > 0) {\n    if (add_blank_line) {\n      printer->Print(\"\\n\");\n    }\n\n    for (vector<string>::const_iterator iter = other_imports_.begin();\n         iter != other_imports_.end(); ++iter) {\n      printer->Print(\n          \" #import \\\"$header$\\\"\\n\",\n          \"header\", *iter);\n    }\n  }\n}\n\nvoid ImportWriter::ParseFrameworkMappings() {\n  need_to_parse_mapping_file_ = false;\n  if (options_.named_framework_to_proto_path_mappings_path.empty()) {\n    return;  // Nothing to do.\n  }\n\n  ProtoFrameworkCollector collector(&proto_file_to_framework_name_);\n  string parse_error;\n  if (!ParseSimpleFile(options_.named_framework_to_proto_path_mappings_path,\n                       &collector, &parse_error)) {\n    cerr << \"error parsing \" << options_.named_framework_to_proto_path_mappings_path\n         << \" : \" << parse_error << endl;\n    cerr.flush();\n  }\n}\n\nbool ImportWriter::ProtoFrameworkCollector::ConsumeLine(\n    const StringPiece& line, string* out_error) {\n  int offset = line.find(':');\n  if (offset == StringPiece::npos) {\n    *out_error =\n        string(\"Framework/proto file mapping line without colon sign: '\") +\n        line.ToString() + \"'.\";\n    return false;\n  }\n  StringPiece framework_name(line, 0, offset);\n  StringPiece proto_file_list(line, offset + 1, line.length() - offset - 1);\n  StringPieceTrimWhitespace(&framework_name);\n\n  int start = 0;\n  while (start < proto_file_list.length()) {\n    offset = proto_file_list.find(',', start);\n    if (offset == StringPiece::npos) {\n      offset = proto_file_list.length();\n    }\n\n    StringPiece proto_file(proto_file_list, start, offset - start);\n    StringPieceTrimWhitespace(&proto_file);\n    if (proto_file.size() != 0) {\n      map<string, string>::iterator existing_entry =\n          map_->find(proto_file.ToString());\n      if (existing_entry != map_->end()) {\n        cerr << \"warning: duplicate proto file reference, replacing framework entry for '\"\n             << proto_file.ToString() << \"' with '\" << framework_name.ToString()\n             << \"' (was '\" << existing_entry->second << \"').\" << endl;\n        cerr.flush();\n      }\n\n      if (proto_file.find(' ') != StringPiece::npos) {\n        cerr << \"note: framework mapping file had a proto file with a space in, hopefully that isn't a missing comma: '\"\n             << proto_file.ToString() << \"'\" << endl;\n        cerr.flush();\n      }\n\n      (*map_)[proto_file.ToString()] = framework_name.ToString();\n    }\n\n    start = offset + 1;\n  }\n\n  return true;\n}\n\n}  // namespace\n\n\nFileGenerator::FileGenerator(const FileDescriptor *file, const Options& options)\n    : file_(file),\n      root_class_name_(FileClassName(file)),\n      is_public_dep_(false),\n      options_(options) {\n  for (int i = 0; i < file_->enum_type_count(); i++) {\n    EnumGenerator *generator = new EnumGenerator(file_->enum_type(i));\n    enum_generators_.push_back(generator);\n  }\n  for (int i = 0; i < file_->message_type_count(); i++) {\n    MessageGenerator *generator =\n        new MessageGenerator(root_class_name_, file_->message_type(i), options_);\n    message_generators_.push_back(generator);\n  }\n  for (int i = 0; i < file_->extension_count(); i++) {\n    ExtensionGenerator *generator =\n        new ExtensionGenerator(root_class_name_, file_->extension(i));\n    extension_generators_.push_back(generator);\n  }\n}\n\nFileGenerator::~FileGenerator() {\n  STLDeleteContainerPointers(dependency_generators_.begin(),\n                             dependency_generators_.end());\n  STLDeleteContainerPointers(enum_generators_.begin(), enum_generators_.end());\n  STLDeleteContainerPointers(message_generators_.begin(),\n                             message_generators_.end());\n  STLDeleteContainerPointers(extension_generators_.begin(),\n                             extension_generators_.end());\n}\n\nvoid FileGenerator::GenerateHeader(io::Printer *printer) {\n  PrintFileRuntimePreamble(printer, \"GPBProtocolBuffers.h\");\n\n  // Add some verification that the generated code matches the source the\n  // code is being compiled with.\n  printer->Print(\n      \"#if GOOGLE_PROTOBUF_OBJC_GEN_VERSION != $protoc_gen_objc_version$\\n\"\n      \"#error This file was generated by a different version of protoc which is incompatible with your Protocol Buffer library sources.\\n\"\n      \"#endif\\n\"\n      \"\\n\",\n      \"protoc_gen_objc_version\",\n      SimpleItoa(GOOGLE_PROTOBUF_OBJC_GEN_VERSION));\n\n  // #import any headers for \"public imports\" in the proto file.\n  {\n    ImportWriter import_writer(options_);\n    const vector<FileGenerator *> &dependency_generators = DependencyGenerators();\n    for (vector<FileGenerator *>::const_iterator iter =\n             dependency_generators.begin();\n         iter != dependency_generators.end(); ++iter) {\n      if ((*iter)->IsPublicDependency()) {\n        import_writer.AddFile(*iter);\n      }\n    }\n    import_writer.Print(printer);\n  }\n\n  // Note:\n  //  deprecated-declarations suppression is only needed if some place in this\n  //    proto file is something deprecated or if it references something from\n  //    another file that is deprecated.\n  printer->Print(\n      \"// @@protoc_insertion_point(imports)\\n\"\n      \"\\n\"\n      \"#pragma clang diagnostic push\\n\"\n      \"#pragma clang diagnostic ignored \\\"-Wdeprecated-declarations\\\"\\n\"\n      \"\\n\"\n      \"CF_EXTERN_C_BEGIN\\n\"\n      \"\\n\");\n\n  set<string> fwd_decls;\n  for (vector<MessageGenerator *>::iterator iter = message_generators_.begin();\n       iter != message_generators_.end(); ++iter) {\n    (*iter)->DetermineForwardDeclarations(&fwd_decls);\n  }\n  for (set<string>::const_iterator i(fwd_decls.begin());\n       i != fwd_decls.end(); ++i) {\n    printer->Print(\"$value$;\\n\", \"value\", *i);\n  }\n  if (fwd_decls.begin() != fwd_decls.end()) {\n    printer->Print(\"\\n\");\n  }\n\n  printer->Print(\n      \"NS_ASSUME_NONNULL_BEGIN\\n\"\n      \"\\n\");\n\n  // need to write out all enums first\n  for (vector<EnumGenerator *>::iterator iter = enum_generators_.begin();\n       iter != enum_generators_.end(); ++iter) {\n    (*iter)->GenerateHeader(printer);\n  }\n\n  for (vector<MessageGenerator *>::iterator iter = message_generators_.begin();\n       iter != message_generators_.end(); ++iter) {\n    (*iter)->GenerateEnumHeader(printer);\n  }\n\n  // For extensions to chain together, the Root gets created even if there\n  // are no extensions.\n  printer->Print(\n      \"#pragma mark - $root_class_name$\\n\"\n      \"\\n\"\n      \"/// Exposes the extension registry for this file.\\n\"\n      \"///\\n\"\n      \"/// The base class provides:\\n\"\n      \"/// @code\\n\"\n      \"///   + (GPBExtensionRegistry *)extensionRegistry;\\n\"\n      \"/// @endcode\\n\"\n      \"/// which is a @c GPBExtensionRegistry that includes all the extensions defined by\\n\"\n      \"/// this file and all files that it depends on.\\n\"\n      \"@interface $root_class_name$ : GPBRootObject\\n\"\n      \"@end\\n\"\n      \"\\n\",\n      \"root_class_name\", root_class_name_);\n\n  if (extension_generators_.size() > 0) {\n    // The dynamic methods block is only needed if there are extensions.\n    printer->Print(\n        \"@interface $root_class_name$ (DynamicMethods)\\n\",\n        \"root_class_name\", root_class_name_);\n\n    for (vector<ExtensionGenerator *>::iterator iter =\n             extension_generators_.begin();\n         iter != extension_generators_.end(); ++iter) {\n      (*iter)->GenerateMembersHeader(printer);\n    }\n\n    printer->Print(\"@end\\n\\n\");\n  }  // extension_generators_.size() > 0\n\n  for (vector<MessageGenerator *>::iterator iter = message_generators_.begin();\n       iter != message_generators_.end(); ++iter) {\n    (*iter)->GenerateMessageHeader(printer);\n  }\n\n  printer->Print(\n      \"NS_ASSUME_NONNULL_END\\n\"\n      \"\\n\"\n      \"CF_EXTERN_C_END\\n\"\n      \"\\n\"\n      \"#pragma clang diagnostic pop\\n\"\n      \"\\n\"\n      \"// @@protoc_insertion_point(global_scope)\\n\");\n}\n\nvoid FileGenerator::GenerateSource(io::Printer *printer) {\n  // #import the runtime support.\n  PrintFileRuntimePreamble(printer, \"GPBProtocolBuffers_RuntimeSupport.h\");\n\n  {\n    ImportWriter import_writer(options_);\n\n    // #import the header for this proto file.\n    import_writer.AddFile(this);\n\n    // #import the headers for anything that a plain dependency of this proto\n    // file (that means they were just an include, not a \"public\" include).\n    const vector<FileGenerator *> &dependency_generators =\n        DependencyGenerators();\n    for (vector<FileGenerator *>::const_iterator iter =\n             dependency_generators.begin();\n         iter != dependency_generators.end(); ++iter) {\n      if (!(*iter)->IsPublicDependency()) {\n        import_writer.AddFile(*iter);\n      }\n    }\n\n    import_writer.Print(printer);\n  }\n\n  bool includes_oneof = false;\n  for (vector<MessageGenerator *>::iterator iter = message_generators_.begin();\n       iter != message_generators_.end(); ++iter) {\n    if ((*iter)->IncludesOneOfDefinition()) {\n      includes_oneof = true;\n      break;\n    }\n  }\n\n  // Note:\n  //  deprecated-declarations suppression is only needed if some place in this\n  //    proto file is something deprecated or if it references something from\n  //    another file that is deprecated.\n  printer->Print(\n      \"// @@protoc_insertion_point(imports)\\n\"\n      \"\\n\"\n      \"#pragma clang diagnostic push\\n\"\n      \"#pragma clang diagnostic ignored \\\"-Wdeprecated-declarations\\\"\\n\");\n  if (includes_oneof) {\n    // The generated code for oneof's uses direct ivar access, suppress the\n    // warning incase developer turn that on in the context they compile the\n    // generated code.\n    printer->Print(\n        \"#pragma clang diagnostic ignored \\\"-Wdirect-ivar-access\\\"\\n\");\n  }\n\n  printer->Print(\n      \"\\n\"\n      \"#pragma mark - $root_class_name$\\n\"\n      \"\\n\"\n      \"@implementation $root_class_name$\\n\\n\",\n      \"root_class_name\", root_class_name_);\n\n  // Generate the extension initialization structures for the top level and\n  // any nested messages.\n  ostringstream extensions_stringstream;\n  if (file_->extension_count() + file_->message_type_count() > 0) {\n    io::OstreamOutputStream extensions_outputstream(&extensions_stringstream);\n    io::Printer extensions_printer(&extensions_outputstream, '$');\n    for (vector<ExtensionGenerator *>::iterator iter =\n             extension_generators_.begin();\n         iter != extension_generators_.end(); ++iter) {\n      (*iter)->GenerateStaticVariablesInitialization(&extensions_printer);\n    }\n    for (vector<MessageGenerator *>::iterator iter =\n             message_generators_.begin();\n         iter != message_generators_.end(); ++iter) {\n      (*iter)->GenerateStaticVariablesInitialization(&extensions_printer);\n    }\n    extensions_stringstream.flush();\n  }\n\n  // If there were any extensions or this file has any dependencies, output\n  // a registry to override to create the file specific registry.\n  const string& extensions_str = extensions_stringstream.str();\n  if (extensions_str.length() > 0 || file_->dependency_count() > 0) {\n    printer->Print(\n        \"+ (GPBExtensionRegistry*)extensionRegistry {\\n\"\n        \"  // This is called by +initialize so there is no need to worry\\n\"\n        \"  // about thread safety and initialization of registry.\\n\"\n        \"  static GPBExtensionRegistry* registry = nil;\\n\"\n        \"  if (!registry) {\\n\"\n        \"    GPBDebugCheckRuntimeVersion();\\n\"\n        \"    registry = [[GPBExtensionRegistry alloc] init];\\n\");\n\n    printer->Indent();\n    printer->Indent();\n\n    if (extensions_str.length() > 0) {\n      printer->Print(\n          \"static GPBExtensionDescription descriptions[] = {\\n\");\n      printer->Indent();\n      printer->Print(extensions_str.c_str());\n      printer->Outdent();\n      printer->Print(\n          \"};\\n\"\n          \"for (size_t i = 0; i < sizeof(descriptions) / sizeof(descriptions[0]); ++i) {\\n\"\n          \"  GPBExtensionDescriptor *extension =\\n\"\n          \"      [[GPBExtensionDescriptor alloc] initWithExtensionDescription:&descriptions[i]];\\n\"\n          \"  [registry addExtension:extension];\\n\"\n          \"  [self globallyRegisterExtension:extension];\\n\"\n          \"  [extension release];\\n\"\n          \"}\\n\");\n    }\n\n    const vector<FileGenerator *> &dependency_generators =\n        DependencyGenerators();\n    for (vector<FileGenerator *>::const_iterator iter =\n             dependency_generators.begin();\n         iter != dependency_generators.end(); ++iter) {\n      printer->Print(\n          \"[registry addExtensions:[$dependency$ extensionRegistry]];\\n\",\n          \"dependency\", (*iter)->RootClassName());\n    }\n\n    printer->Outdent();\n    printer->Outdent();\n\n    printer->Print(\n        \"  }\\n\"\n        \"  return registry;\\n\"\n        \"}\\n\"\n        \"\\n\");\n  }\n\n  printer->Print(\"@end\\n\\n\");\n\n  // File descriptor only needed if there are messages to use it.\n  if (message_generators_.size() > 0) {\n    string syntax;\n    switch (file_->syntax()) {\n      case FileDescriptor::SYNTAX_UNKNOWN:\n        syntax = \"GPBFileSyntaxUnknown\";\n        break;\n      case FileDescriptor::SYNTAX_PROTO2:\n        syntax = \"GPBFileSyntaxProto2\";\n        break;\n      case FileDescriptor::SYNTAX_PROTO3:\n        syntax = \"GPBFileSyntaxProto3\";\n        break;\n    }\n    printer->Print(\n        \"#pragma mark - $root_class_name$_FileDescriptor\\n\"\n        \"\\n\"\n        \"static GPBFileDescriptor *$root_class_name$_FileDescriptor(void) {\\n\"\n        \"  // This is called by +initialize so there is no need to worry\\n\"\n        \"  // about thread safety of the singleton.\\n\"\n        \"  static GPBFileDescriptor *descriptor = NULL;\\n\"\n        \"  if (!descriptor) {\\n\"\n        \"    GPBDebugCheckRuntimeVersion();\\n\"\n        \"    descriptor = [[GPBFileDescriptor alloc] initWithPackage:@\\\"$package$\\\"\\n\"\n        \"                                                     syntax:$syntax$];\\n\"\n        \"  }\\n\"\n        \"  return descriptor;\\n\"\n        \"}\\n\"\n        \"\\n\",\n        \"root_class_name\", root_class_name_,\n        \"package\", file_->package(),\n        \"syntax\", syntax);\n  }\n\n  for (vector<EnumGenerator *>::iterator iter = enum_generators_.begin();\n       iter != enum_generators_.end(); ++iter) {\n    (*iter)->GenerateSource(printer);\n  }\n  for (vector<MessageGenerator *>::iterator iter = message_generators_.begin();\n       iter != message_generators_.end(); ++iter) {\n    (*iter)->GenerateSource(printer);\n  }\n\n  printer->Print(\n    \"\\n\"\n    \"#pragma clang diagnostic pop\\n\"\n    \"\\n\"\n    \"// @@protoc_insertion_point(global_scope)\\n\");\n}\n\nconst vector<FileGenerator *> &FileGenerator::DependencyGenerators() {\n  if (file_->dependency_count() != dependency_generators_.size()) {\n    set<string> public_import_names;\n    for (int i = 0; i < file_->public_dependency_count(); i++) {\n      public_import_names.insert(file_->public_dependency(i)->name());\n    }\n    for (int i = 0; i < file_->dependency_count(); i++) {\n      FileGenerator *generator =\n          new FileGenerator(file_->dependency(i), options_);\n      const string& name = file_->dependency(i)->name();\n      bool public_import = (public_import_names.count(name) != 0);\n      generator->SetIsPublicDependency(public_import);\n      dependency_generators_.push_back(generator);\n    }\n  }\n  return dependency_generators_;\n}\n\n// Helper to print the import of the runtime support at the top of generated\n// files. This currently only supports the runtime coming from a framework\n// as defined by the official CocoaPod.\nvoid FileGenerator::PrintFileRuntimePreamble(\n    io::Printer* printer, const string& header_to_import) const {\n  printer->Print(\n      \"// Generated by the protocol buffer compiler.  DO NOT EDIT!\\n\"\n      \"// source: $filename$\\n\"\n      \"\\n\",\n      \"filename\", file_->name());\n\n  const string framework_name(ProtobufLibraryFrameworkName);\n  const string cpp_symbol(ProtobufFrameworkImportSymbol(framework_name));\n  printer->Print(\n      \"// This CPP symbol can be defined to use imports that match up to the framework\\n\"\n      \"// imports needed when using CocoaPods.\\n\"\n      \"#if !defined($cpp_symbol$)\\n\"\n      \" #define $cpp_symbol$ 0\\n\"\n      \"#endif\\n\"\n      \"\\n\"\n      \"#if $cpp_symbol$\\n\"\n      \" #import <$framework_name$/$header$>\\n\"\n      \"#else\\n\"\n      \" #import \\\"$header$\\\"\\n\"\n      \"#endif\\n\"\n      \"\\n\",\n      \"cpp_symbol\", cpp_symbol,\n      \"header\", header_to_import,\n      \"framework_name\", framework_name);\n}\n\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_file.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_FILE_H__\n#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_FILE_H__\n\n#include <string>\n#include <set>\n#include <vector>\n#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\nclass FileDescriptor;  // descriptor.h\nnamespace io {\nclass Printer;  // printer.h\n}\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace objectivec {\n\nclass EnumGenerator;\nclass ExtensionGenerator;\nclass MessageGenerator;\n\nclass FileGenerator {\n public:\n  FileGenerator(const FileDescriptor* file, const Options& options);\n  ~FileGenerator();\n\n  void GenerateSource(io::Printer* printer);\n  void GenerateHeader(io::Printer* printer);\n\n  const string& RootClassName() const { return root_class_name_; }\n  const string Path() const { return FilePath(file_); }\n  const FileDescriptor* Descriptor() const { return file_; }\n\n  bool IsPublicDependency() const { return is_public_dep_; }\n\n protected:\n  void SetIsPublicDependency(bool is_public_dep) {\n    is_public_dep_ = is_public_dep;\n  }\n\n private:\n  const FileDescriptor* file_;\n  string root_class_name_;\n\n  // Access this field through the DependencyGenerators accessor call below.\n  // Do not reference it directly.\n  vector<FileGenerator*> dependency_generators_;\n\n  vector<EnumGenerator*> enum_generators_;\n  vector<MessageGenerator*> message_generators_;\n  vector<ExtensionGenerator*> extension_generators_;\n  bool is_public_dep_;\n\n  const Options options_;\n\n  const vector<FileGenerator*>& DependencyGenerators();\n  void PrintFileRuntimePreamble(\n      io::Printer* printer, const string& header_to_import) const;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileGenerator);\n};\n\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_FILE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_generator.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <iostream>\n#include <google/protobuf/compiler/objectivec/objectivec_generator.h>\n#include <google/protobuf/compiler/objectivec/objectivec_file.h>\n#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace objectivec {\n\nObjectiveCGenerator::ObjectiveCGenerator() {}\n\nObjectiveCGenerator::~ObjectiveCGenerator() {}\n\nbool ObjectiveCGenerator::Generate(const FileDescriptor* file,\n                                   const string& parameter,\n                                   OutputDirectory* output_directory,\n                                   string* error) const {\n  // -----------------------------------------------------------------\n  // Parse generator options. These options are passed to the compiler using the\n  // --objc_opt flag. The options are passed as a comma separated list of\n  // options along with their values. If the option appears multiple times, only\n  // the last value will be considered.\n  //\n  // e.g. protoc ... --objc_opt=expected_prefixes=file.txt,generate_for_named_framework=MyFramework\n\n  Options generation_options;\n\n  vector<pair<string, string> > options;\n  ParseGeneratorParameter(parameter, &options);\n  for (int i = 0; i < options.size(); i++) {\n    if (options[i].first == \"expected_prefixes_path\") {\n      // Path to find a file containing the expected prefixes\n      // (objc_class_prefix \"PREFIX\") for proto packages (package NAME). The\n      // generator will then issue warnings/errors if in the proto files being\n      // generated the option is not listed/wrong/etc in the file.\n      //\n      // The format of the file is:\n      //   - An entry is a line of \"package=prefix\".\n      //   - Comments start with \"#\".\n      //   - A comment can go on a line after a expected package/prefix pair.\n      //     (i.e. - \"package=prefix # comment\")\n      //\n      // There is no validation that the prefixes are good prefixes, it is\n      // assumed that they are when you create the file.\n      generation_options.expected_prefixes_path = options[i].second;\n    } else if (options[i].first == \"generate_for_named_framework\") {\n      // The name of the framework that protos are being generated for. This\n      // will cause the #import statements to be framework based using this\n      // name (i.e. - \"#import <NAME/proto.pbobjc.h>).\n      //\n      // NOTE: If this option is used with\n      // named_framework_to_proto_path_mappings_path, then this is effectively\n      // the \"default\" framework name used for everything that wasn't mapped by\n      // the mapping file.\n      generation_options.generate_for_named_framework = options[i].second;\n    } else if (options[i].first == \"named_framework_to_proto_path_mappings_path\") {\n      // Path to find a file containing the list of framework names and proto\n      // files. The generator uses this to decide if a proto file\n      // referenced should use a framework style import vs. a user level import\n      // (#import <FRAMEWORK/file.pbobjc.h> vs #import \"dir/file.pbobjc.h\").\n      //\n      // The format of the file is:\n      //   - An entry is a line of \"frameworkName: file.proto, dir/file2.proto\".\n      //   - Comments start with \"#\".\n      //   - A comment can go on a line after a expected package/prefix pair.\n      //     (i.e. - \"frameworkName: file.proto # comment\")\n      //\n      // Any number of files can be listed for a framework, just separate them\n      // with commas.\n      //\n      // There can be multiple lines listing the same frameworkName incase it\n      // has a lot of proto files included in it; having multiple lines makes\n      // things easier to read. If a proto file is not configured in the\n      // mappings file, it will use the default framework name if one was passed\n      // with generate_for_named_framework, or the relative path to it's include\n      // path otherwise.\n      generation_options.named_framework_to_proto_path_mappings_path = options[i].second;\n    } else {\n      *error = \"error: Unknown generator option: \" + options[i].first;\n      return false;\n    }\n  }\n\n  // -----------------------------------------------------------------\n\n  // Validate the objc prefix/package pairing.\n  if (!ValidateObjCClassPrefix(file, generation_options, error)) {\n    // *error will have been filled in.\n    return false;\n  }\n\n  FileGenerator file_generator(file, generation_options);\n  string filepath = FilePath(file);\n\n  // Generate header.\n  {\n    scoped_ptr<io::ZeroCopyOutputStream> output(\n        output_directory->Open(filepath + \".pbobjc.h\"));\n    io::Printer printer(output.get(), '$');\n    file_generator.GenerateHeader(&printer);\n  }\n\n  // Generate m file.\n  {\n    scoped_ptr<io::ZeroCopyOutputStream> output(\n        output_directory->Open(filepath + \".pbobjc.m\"));\n    io::Printer printer(output.get(), '$');\n    file_generator.GenerateSource(&printer);\n  }\n\n  return true;\n}\n\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_generator.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Generates ObjectiveC code for a given .proto file.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_GENERATOR_H__\n#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_GENERATOR_H__\n\n#include <string>\n#include <google/protobuf/compiler/code_generator.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace objectivec {\n\nclass LIBPROTOC_EXPORT ObjectiveCGenerator : public CodeGenerator {\n public:\n  ObjectiveCGenerator();\n  ~ObjectiveCGenerator();\n\n  // implements CodeGenerator ----------------------------------------\n  bool Generate(const FileDescriptor* file, const string& parameter,\n                OutputDirectory* output_directory, string* error) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjectiveCGenerator);\n};\n\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_GENERATOR_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifdef _MSC_VER\n#include <io.h>\n#else\n#include <unistd.h>\n#endif\n#include <climits>\n#include <errno.h>\n#include <fcntl.h>\n#include <fstream>\n#include <iostream>\n#include <sstream>\n#include <stdlib.h>\n#include <vector>\n\n#include <google/protobuf/stubs/hash.h>\n#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/strutil.h>\n\n// NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some\n// error cases, so it seems to be ok to use as a back door for errors.\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace objectivec {\n\nOptions::Options() {\n  // Default is the value of the env for the package prefixes.\n  const char* file_path = getenv(\"GPB_OBJC_EXPECTED_PACKAGE_PREFIXES\");\n  if (file_path) {\n    expected_prefixes_path = file_path;\n  }\n}\n\nnamespace {\n\nhash_set<string> MakeWordsMap(const char* const words[], size_t num_words) {\n  hash_set<string> result;\n  for (int i = 0; i < num_words; i++) {\n    result.insert(words[i]);\n  }\n  return result;\n}\n\nconst char* const kUpperSegmentsList[] = {\"url\", \"http\", \"https\"};\n\nhash_set<string> kUpperSegments =\n    MakeWordsMap(kUpperSegmentsList, GOOGLE_ARRAYSIZE(kUpperSegmentsList));\n\nbool ascii_isnewline(char c) {\n  return c == '\\n' || c == '\\r';\n}\n\n// Internal helper for name handing.\n// Do not expose this outside of helpers, stick to having functions for specific\n// cases (ClassName(), FieldName()), so there is always consistent suffix rules.\nstring UnderscoresToCamelCase(const string& input, bool first_capitalized) {\n  vector<string> values;\n  string current;\n\n  bool last_char_was_number = false;\n  bool last_char_was_lower = false;\n  bool last_char_was_upper = false;\n  for (int i = 0; i < input.size(); i++) {\n    char c = input[i];\n    if (ascii_isdigit(c)) {\n      if (!last_char_was_number) {\n        values.push_back(current);\n        current = \"\";\n      }\n      current += c;\n      last_char_was_number = last_char_was_lower = last_char_was_upper = false;\n      last_char_was_number = true;\n    } else if (ascii_islower(c)) {\n      // lowercase letter can follow a lowercase or uppercase letter\n      if (!last_char_was_lower && !last_char_was_upper) {\n        values.push_back(current);\n        current = \"\";\n      }\n      current += c;  // already lower\n      last_char_was_number = last_char_was_lower = last_char_was_upper = false;\n      last_char_was_lower = true;\n    } else if (ascii_isupper(c)) {\n      if (!last_char_was_upper) {\n        values.push_back(current);\n        current = \"\";\n      }\n      current += ascii_tolower(c);\n      last_char_was_number = last_char_was_lower = last_char_was_upper = false;\n      last_char_was_upper = true;\n    } else {\n      last_char_was_number = last_char_was_lower = last_char_was_upper = false;\n    }\n  }\n  values.push_back(current);\n\n  string result;\n  bool first_segment_forces_upper = false;\n  for (vector<string>::iterator i = values.begin(); i != values.end(); ++i) {\n    string value = *i;\n    bool all_upper = (kUpperSegments.count(value) > 0);\n    if (all_upper && (result.length() == 0)) {\n      first_segment_forces_upper = true;\n    }\n    for (int j = 0; j < value.length(); j++) {\n      if (j == 0 || all_upper) {\n        value[j] = ascii_toupper(value[j]);\n      } else {\n        // Nothing, already in lower.\n      }\n    }\n    result += value;\n  }\n  if ((result.length() != 0) &&\n      !first_capitalized &&\n      !first_segment_forces_upper) {\n    result[0] = ascii_tolower(result[0]);\n  }\n  return result;\n}\n\nconst char* const kReservedWordList[] = {\n    // Objective C \"keywords\" that aren't in C\n    // From\n    // http://stackoverflow.com/questions/1873630/reserved-keywords-in-objective-c\n    \"id\", \"_cmd\", \"super\", \"in\", \"out\", \"inout\", \"bycopy\", \"byref\", \"oneway\",\n    \"self\",\n\n    // C/C++ keywords (Incl C++ 0x11)\n    // From http://en.cppreference.com/w/cpp/keywords\n    \"and\", \"and_eq\", \"alignas\", \"alignof\", \"asm\", \"auto\", \"bitand\", \"bitor\",\n    \"bool\", \"break\", \"case\", \"catch\", \"char\", \"char16_t\", \"char32_t\", \"class\",\n    \"compl\", \"const\", \"constexpr\", \"const_cast\", \"continue\", \"decltype\",\n    \"default\", \"delete\", \"double\", \"dynamic_cast\", \"else\", \"enum\", \"explicit\",\n    \"export\", \"extern \", \"false\", \"float\", \"for\", \"friend\", \"goto\", \"if\",\n    \"inline\", \"int\", \"long\", \"mutable\", \"namespace\", \"new\", \"noexcept\", \"not\",\n    \"not_eq\", \"nullptr\", \"operator\", \"or\", \"or_eq\", \"private\", \"protected\",\n    \"public\", \"register\", \"reinterpret_cast\", \"return\", \"short\", \"signed\",\n    \"sizeof\", \"static\", \"static_assert\", \"static_cast\", \"struct\", \"switch\",\n    \"template\", \"this\", \"thread_local\", \"throw\", \"true\", \"try\", \"typedef\",\n    \"typeid\", \"typename\", \"union\", \"unsigned\", \"using\", \"virtual\", \"void\",\n    \"volatile\", \"wchar_t\", \"while\", \"xor\", \"xor_eq\",\n\n    // C99 keywords\n    // From\n    // http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8l.doc%2Flanguage%2Fref%2Fkeyw.htm\n    \"restrict\",\n\n    // Objective-C Runtime typedefs\n    // From <obc/runtime.h>\n    \"Category\", \"Ivar\", \"Method\", \"Protocol\",\n\n    // NSObject Methods\n    // new is covered by C++ keywords.\n    \"description\", \"debugDescription\", \"finalize\", \"hash\", \"dealloc\", \"init\",\n    \"class\", \"superclass\", \"retain\", \"release\", \"autorelease\", \"retainCount\",\n    \"zone\", \"isProxy\", \"copy\", \"mutableCopy\", \"classForCoder\",\n\n    // GPBMessage Methods\n    // Only need to add instance methods that may conflict with\n    // method declared in protos. The main cases are methods\n    // that take no arguments, or setFoo:/hasFoo: type methods.\n    \"clear\", \"data\", \"delimitedData\", \"descriptor\", \"extensionRegistry\",\n    \"extensionsCurrentlySet\", \"isInitialized\", \"serializedSize\",\n    \"sortedExtensionsInUse\", \"unknownFields\",\n\n    // MacTypes.h names\n    \"Fixed\", \"Fract\", \"Size\", \"LogicalAddress\", \"PhysicalAddress\", \"ByteCount\",\n    \"ByteOffset\", \"Duration\", \"AbsoluteTime\", \"OptionBits\", \"ItemCount\",\n    \"PBVersion\", \"ScriptCode\", \"LangCode\", \"RegionCode\", \"OSType\",\n    \"ProcessSerialNumber\", \"Point\", \"Rect\", \"FixedPoint\", \"FixedRect\", \"Style\",\n    \"StyleParameter\", \"StyleField\", \"TimeScale\", \"TimeBase\", \"TimeRecord\",\n};\n\nhash_set<string> kReservedWords =\n    MakeWordsMap(kReservedWordList, GOOGLE_ARRAYSIZE(kReservedWordList));\n\nstring SanitizeNameForObjC(const string& input, const string& extension) {\n  if (kReservedWords.count(input) > 0) {\n    return input + extension;\n  }\n  return input;\n}\n\nstring NameFromFieldDescriptor(const FieldDescriptor* field) {\n  if (field->type() == FieldDescriptor::TYPE_GROUP) {\n    return field->message_type()->name();\n  } else {\n    return field->name();\n  }\n}\n\nvoid PathSplit(const string& path, string* directory, string* basename) {\n  string::size_type last_slash = path.rfind('/');\n  if (last_slash == string::npos) {\n    if (directory) {\n      *directory = \"\";\n    }\n    if (basename) {\n      *basename = path;\n    }\n  } else {\n    if (directory) {\n      *directory = path.substr(0, last_slash);\n    }\n    if (basename) {\n      *basename = path.substr(last_slash + 1);\n    }\n  }\n}\n\nbool IsSpecialName(const string& name, const string* special_names,\n                   size_t count) {\n  for (size_t i = 0; i < count; ++i) {\n    size_t length = special_names[i].length();\n    if (name.compare(0, length, special_names[i]) == 0) {\n      if (name.length() > length) {\n        // If name is longer than the retained_name[i] that it matches\n        // the next character must be not lower case (newton vs newTon vs\n        // new_ton).\n        return !ascii_islower(name[length]);\n      } else {\n        return true;\n      }\n    }\n  }\n  return false;\n}\n\n}  // namespace\n\n// Escape C++ trigraphs by escaping question marks to \\?\nstring EscapeTrigraphs(const string& to_escape) {\n  return StringReplace(to_escape, \"?\", \"\\\\?\", true);\n}\n\nstring StripProto(const string& filename) {\n  if (HasSuffixString(filename, \".protodevel\")) {\n    return StripSuffixString(filename, \".protodevel\");\n  } else {\n    return StripSuffixString(filename, \".proto\");\n  }\n}\n\nvoid StringPieceTrimWhitespace(StringPiece* input) {\n  while (!input->empty() && ascii_isspace(*input->data())) {\n    input->remove_prefix(1);\n  }\n  while (!input->empty() && ascii_isspace((*input)[input->length() - 1])) {\n    input->remove_suffix(1);\n  }\n}\n\n\nbool IsRetainedName(const string& name) {\n  // List of prefixes from\n  // http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html\n  static const string retained_names[] = {\"new\", \"alloc\", \"copy\",\n                                          \"mutableCopy\"};\n  return IsSpecialName(name, retained_names,\n                       sizeof(retained_names) / sizeof(retained_names[0]));\n}\n\nbool IsInitName(const string& name) {\n  static const string init_names[] = {\"init\"};\n  return IsSpecialName(name, init_names,\n                       sizeof(init_names) / sizeof(init_names[0]));\n}\n\nstring BaseFileName(const FileDescriptor* file) {\n  string basename;\n  PathSplit(file->name(), NULL, &basename);\n  return basename;\n}\n\nstring FilePath(const FileDescriptor* file) {\n  string output;\n  string basename;\n  string directory;\n  PathSplit(file->name(), &directory, &basename);\n  if (directory.length() > 0) {\n    output = directory + \"/\";\n  }\n  basename = StripProto(basename);\n\n  // CamelCase to be more ObjC friendly.\n  basename = UnderscoresToCamelCase(basename, true);\n\n  output += basename;\n  return output;\n}\n\nstring FilePathBasename(const FileDescriptor* file) {\n  string output;\n  string basename;\n  string directory;\n  PathSplit(file->name(), &directory, &basename);\n  basename = StripProto(basename);\n\n  // CamelCase to be more ObjC friendly.\n  output = UnderscoresToCamelCase(basename, true);\n\n  return output;\n}\n\nstring FileClassPrefix(const FileDescriptor* file) {\n  // Default is empty string, no need to check has_objc_class_prefix.\n  string result = file->options().objc_class_prefix();\n  return result;\n}\n\nstring FileClassName(const FileDescriptor* file) {\n  string name = FileClassPrefix(file);\n  name += UnderscoresToCamelCase(StripProto(BaseFileName(file)), true);\n  name += \"Root\";\n  // There aren't really any reserved words that end in \"Root\", but playing\n  // it safe and checking.\n  return SanitizeNameForObjC(name, \"_RootClass\");\n}\n\nstring ClassNameWorker(const Descriptor* descriptor) {\n  string name;\n  if (descriptor->containing_type() != NULL) {\n    name = ClassNameWorker(descriptor->containing_type());\n    name += \"_\";\n  }\n  return name + descriptor->name();\n}\n\nstring ClassNameWorker(const EnumDescriptor* descriptor) {\n  string name;\n  if (descriptor->containing_type() != NULL) {\n    name = ClassNameWorker(descriptor->containing_type());\n    name += \"_\";\n  }\n  return name + descriptor->name();\n}\n\nstring ClassName(const Descriptor* descriptor) {\n  // 1. Message names are used as is (style calls for CamelCase, trust it).\n  // 2. Check for reserved word at the very end and then suffix things.\n  string prefix = FileClassPrefix(descriptor->file());\n  string name = ClassNameWorker(descriptor);\n  return SanitizeNameForObjC(prefix + name, \"_Class\");\n}\n\nstring EnumName(const EnumDescriptor* descriptor) {\n  // 1. Enum names are used as is (style calls for CamelCase, trust it).\n  // 2. Check for reserved word at the every end and then suffix things.\n  //      message Fixed {\n  //        message Size {...}\n  //        enum Mumble {...}\n  //      ...\n  //      }\n  //    yields Fixed_Class, Fixed_Size.\n  string name = FileClassPrefix(descriptor->file());\n  name += ClassNameWorker(descriptor);\n  return SanitizeNameForObjC(name, \"_Enum\");\n}\n\nstring EnumValueName(const EnumValueDescriptor* descriptor) {\n  // Because of the Switch enum compatibility, the name on the enum has to have\n  // the suffix handing, so it slightly diverges from how nested classes work.\n  //   enum Fixed {\n  //     FOO = 1\n  //   }\n  // yields Fixed_Enum and Fixed_Enum_Foo (not Fixed_Foo).\n  const string& class_name = EnumName(descriptor->type());\n  const string& value_str = UnderscoresToCamelCase(descriptor->name(), true);\n  const string& name = class_name + \"_\" + value_str;\n  // There aren't really any reserved words with an underscore and a leading\n  // capital letter, but playing it safe and checking.\n  return SanitizeNameForObjC(name, \"_Value\");\n}\n\nstring EnumValueShortName(const EnumValueDescriptor* descriptor) {\n  // Enum value names (EnumValueName above) are the enum name turned into\n  // a class name and then the value name is CamelCased and concatenated; the\n  // whole thing then gets sanitized for reserved words.\n  // The \"short name\" is intended to be the final leaf, the value name; but\n  // you can't simply send that off to sanitize as that could result in it\n  // getting modified when the full name didn't.  For example enum\n  // \"StorageModes\" has a value \"retain\".  So the full name is\n  // \"StorageModes_Retain\", but if we sanitize \"retain\" it would become\n  // \"RetainValue\".\n  // So the right way to get the short name is to take the full enum name\n  // and then strip off the enum name (leaving the value name and anything\n  // done by sanitize).\n  const string& class_name = EnumName(descriptor->type());\n  const string& long_name_prefix = class_name + \"_\";\n  const string& long_name = EnumValueName(descriptor);\n  return StripPrefixString(long_name, long_name_prefix);\n}\n\nstring UnCamelCaseEnumShortName(const string& name) {\n  string result;\n  for (int i = 0; i < name.size(); i++) {\n    char c = name[i];\n    if (i > 0 && ascii_isupper(c)) {\n      result += '_';\n    }\n    result += ascii_toupper(c);\n  }\n  return result;\n}\n\nstring ExtensionMethodName(const FieldDescriptor* descriptor) {\n  const string& name = NameFromFieldDescriptor(descriptor);\n  const string& result = UnderscoresToCamelCase(name, false);\n  return SanitizeNameForObjC(result, \"_Extension\");\n}\n\nstring FieldName(const FieldDescriptor* field) {\n  const string& name = NameFromFieldDescriptor(field);\n  string result = UnderscoresToCamelCase(name, false);\n  if (field->is_repeated() && !field->is_map()) {\n    // Add \"Array\" before do check for reserved worlds.\n    result += \"Array\";\n  } else {\n    // If it wasn't repeated, but ends in \"Array\", force on the _p suffix.\n    if (HasSuffixString(result, \"Array\")) {\n      result += \"_p\";\n    }\n  }\n  return SanitizeNameForObjC(result, \"_p\");\n}\n\nstring FieldNameCapitalized(const FieldDescriptor* field) {\n  // Want the same suffix handling, so upcase the first letter of the other\n  // name.\n  string result = FieldName(field);\n  if (result.length() > 0) {\n    result[0] = ascii_toupper(result[0]);\n  }\n  return result;\n}\n\nstring OneofEnumName(const OneofDescriptor* descriptor) {\n  const Descriptor* fieldDescriptor = descriptor->containing_type();\n  string name = ClassName(fieldDescriptor);\n  name += \"_\" + UnderscoresToCamelCase(descriptor->name(), true) + \"_OneOfCase\";\n  // No sanitize needed because the OS never has names that end in _OneOfCase.\n  return name;\n}\n\nstring OneofName(const OneofDescriptor* descriptor) {\n  string name = UnderscoresToCamelCase(descriptor->name(), false);\n  // No sanitize needed because it gets OneOfCase added and that shouldn't\n  // ever conflict.\n  return name;\n}\n\nstring OneofNameCapitalized(const OneofDescriptor* descriptor) {\n  // Use the common handling and then up-case the first letter.\n  string result = OneofName(descriptor);\n  if (result.length() > 0) {\n    result[0] = ascii_toupper(result[0]);\n  }\n  return result;\n}\n\nstring UnCamelCaseFieldName(const string& name, const FieldDescriptor* field) {\n  string worker(name);\n  if (HasSuffixString(worker, \"_p\")) {\n    worker = StripSuffixString(worker, \"_p\");\n  }\n  if (field->is_repeated() && HasSuffixString(worker, \"Array\")) {\n    worker = StripSuffixString(worker, \"Array\");\n  }\n  if (field->type() == FieldDescriptor::TYPE_GROUP) {\n    if (worker.length() > 0) {\n      if (ascii_islower(worker[0])) {\n        worker[0] = ascii_toupper(worker[0]);\n      }\n    }\n    return worker;\n  } else {\n    string result;\n    for (int i = 0; i < worker.size(); i++) {\n      char c = worker[i];\n      if (ascii_isupper(c)) {\n        if (i > 0) {\n          result += '_';\n        }\n        result += ascii_tolower(c);\n      } else {\n        result += c;\n      }\n    }\n    return result;\n  }\n}\n\nstring GetCapitalizedType(const FieldDescriptor* field) {\n  switch (field->type()) {\n    case FieldDescriptor::TYPE_INT32:\n      return \"Int32\";\n    case FieldDescriptor::TYPE_UINT32:\n      return \"UInt32\";\n    case FieldDescriptor::TYPE_SINT32:\n      return \"SInt32\";\n    case FieldDescriptor::TYPE_FIXED32:\n      return \"Fixed32\";\n    case FieldDescriptor::TYPE_SFIXED32:\n      return \"SFixed32\";\n    case FieldDescriptor::TYPE_INT64:\n      return \"Int64\";\n    case FieldDescriptor::TYPE_UINT64:\n      return \"UInt64\";\n    case FieldDescriptor::TYPE_SINT64:\n      return \"SInt64\";\n    case FieldDescriptor::TYPE_FIXED64:\n      return \"Fixed64\";\n    case FieldDescriptor::TYPE_SFIXED64:\n      return \"SFixed64\";\n    case FieldDescriptor::TYPE_FLOAT:\n      return \"Float\";\n    case FieldDescriptor::TYPE_DOUBLE:\n      return \"Double\";\n    case FieldDescriptor::TYPE_BOOL:\n      return \"Bool\";\n    case FieldDescriptor::TYPE_STRING:\n      return \"String\";\n    case FieldDescriptor::TYPE_BYTES:\n      return \"Bytes\";\n    case FieldDescriptor::TYPE_ENUM:\n      return \"Enum\";\n    case FieldDescriptor::TYPE_GROUP:\n      return \"Group\";\n    case FieldDescriptor::TYPE_MESSAGE:\n      return \"Message\";\n  }\n\n  // Some compilers report reaching end of function even though all cases of\n  // the enum are handed in the switch.\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return NULL;\n}\n\nObjectiveCType GetObjectiveCType(FieldDescriptor::Type field_type) {\n  switch (field_type) {\n    case FieldDescriptor::TYPE_INT32:\n    case FieldDescriptor::TYPE_SINT32:\n    case FieldDescriptor::TYPE_SFIXED32:\n      return OBJECTIVECTYPE_INT32;\n\n    case FieldDescriptor::TYPE_UINT32:\n    case FieldDescriptor::TYPE_FIXED32:\n      return OBJECTIVECTYPE_UINT32;\n\n    case FieldDescriptor::TYPE_INT64:\n    case FieldDescriptor::TYPE_SINT64:\n    case FieldDescriptor::TYPE_SFIXED64:\n      return OBJECTIVECTYPE_INT64;\n\n    case FieldDescriptor::TYPE_UINT64:\n    case FieldDescriptor::TYPE_FIXED64:\n      return OBJECTIVECTYPE_UINT64;\n\n    case FieldDescriptor::TYPE_FLOAT:\n      return OBJECTIVECTYPE_FLOAT;\n\n    case FieldDescriptor::TYPE_DOUBLE:\n      return OBJECTIVECTYPE_DOUBLE;\n\n    case FieldDescriptor::TYPE_BOOL:\n      return OBJECTIVECTYPE_BOOLEAN;\n\n    case FieldDescriptor::TYPE_STRING:\n      return OBJECTIVECTYPE_STRING;\n\n    case FieldDescriptor::TYPE_BYTES:\n      return OBJECTIVECTYPE_DATA;\n\n    case FieldDescriptor::TYPE_ENUM:\n      return OBJECTIVECTYPE_ENUM;\n\n    case FieldDescriptor::TYPE_GROUP:\n    case FieldDescriptor::TYPE_MESSAGE:\n      return OBJECTIVECTYPE_MESSAGE;\n  }\n\n  // Some compilers report reaching end of function even though all cases of\n  // the enum are handed in the switch.\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return OBJECTIVECTYPE_INT32;\n}\n\nbool IsPrimitiveType(const FieldDescriptor* field) {\n  ObjectiveCType type = GetObjectiveCType(field);\n  switch (type) {\n    case OBJECTIVECTYPE_INT32:\n    case OBJECTIVECTYPE_UINT32:\n    case OBJECTIVECTYPE_INT64:\n    case OBJECTIVECTYPE_UINT64:\n    case OBJECTIVECTYPE_FLOAT:\n    case OBJECTIVECTYPE_DOUBLE:\n    case OBJECTIVECTYPE_BOOLEAN:\n    case OBJECTIVECTYPE_ENUM:\n      return true;\n      break;\n    default:\n      return false;\n  }\n}\n\nbool IsReferenceType(const FieldDescriptor* field) {\n  return !IsPrimitiveType(field);\n}\n\nstatic string HandleExtremeFloatingPoint(string val, bool add_float_suffix) {\n  if (val == \"nan\") {\n    return \"NAN\";\n  } else if (val == \"inf\") {\n    return \"INFINITY\";\n  } else if (val == \"-inf\") {\n    return \"-INFINITY\";\n  } else {\n    // float strings with ., e or E need to have f appended\n    if (add_float_suffix &&\n        (val.find(\".\") != string::npos || val.find(\"e\") != string::npos ||\n         val.find(\"E\") != string::npos)) {\n      val += \"f\";\n    }\n    return val;\n  }\n}\n\nstring GPBGenericValueFieldName(const FieldDescriptor* field) {\n  // Returns the field within the GPBGenericValue union to use for the given\n  // field.\n  if (field->is_repeated()) {\n      return \"valueMessage\";\n  }\n  switch (field->cpp_type()) {\n    case FieldDescriptor::CPPTYPE_INT32:\n      return \"valueInt32\";\n    case FieldDescriptor::CPPTYPE_UINT32:\n      return \"valueUInt32\";\n    case FieldDescriptor::CPPTYPE_INT64:\n      return \"valueInt64\";\n    case FieldDescriptor::CPPTYPE_UINT64:\n      return \"valueUInt64\";\n    case FieldDescriptor::CPPTYPE_FLOAT:\n      return \"valueFloat\";\n    case FieldDescriptor::CPPTYPE_DOUBLE:\n      return \"valueDouble\";\n    case FieldDescriptor::CPPTYPE_BOOL:\n      return \"valueBool\";\n    case FieldDescriptor::CPPTYPE_STRING:\n      if (field->type() == FieldDescriptor::TYPE_BYTES) {\n        return \"valueData\";\n      } else {\n        return \"valueString\";\n      }\n    case FieldDescriptor::CPPTYPE_ENUM:\n      return \"valueEnum\";\n    case FieldDescriptor::CPPTYPE_MESSAGE:\n      return \"valueMessage\";\n  }\n\n  // Some compilers report reaching end of function even though all cases of\n  // the enum are handed in the switch.\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return NULL;\n}\n\n\nstring DefaultValue(const FieldDescriptor* field) {\n  // Repeated fields don't have defaults.\n  if (field->is_repeated()) {\n    return \"nil\";\n  }\n\n  // Switch on cpp_type since we need to know which default_value_* method\n  // of FieldDescriptor to call.\n  switch (field->cpp_type()) {\n    case FieldDescriptor::CPPTYPE_INT32:\n      // gcc and llvm reject the decimal form of kint32min and kint64min.\n      if (field->default_value_int32() == INT_MIN) {\n        return \"-0x80000000\";\n      }\n      return SimpleItoa(field->default_value_int32());\n    case FieldDescriptor::CPPTYPE_UINT32:\n      return SimpleItoa(field->default_value_uint32()) + \"U\";\n    case FieldDescriptor::CPPTYPE_INT64:\n      // gcc and llvm reject the decimal form of kint32min and kint64min.\n      if (field->default_value_int64() == LLONG_MIN) {\n        return \"-0x8000000000000000LL\";\n      }\n      return SimpleItoa(field->default_value_int64()) + \"LL\";\n    case FieldDescriptor::CPPTYPE_UINT64:\n      return SimpleItoa(field->default_value_uint64()) + \"ULL\";\n    case FieldDescriptor::CPPTYPE_DOUBLE:\n      return HandleExtremeFloatingPoint(\n          SimpleDtoa(field->default_value_double()), false);\n    case FieldDescriptor::CPPTYPE_FLOAT:\n      return HandleExtremeFloatingPoint(\n          SimpleFtoa(field->default_value_float()), true);\n    case FieldDescriptor::CPPTYPE_BOOL:\n      return field->default_value_bool() ? \"YES\" : \"NO\";\n    case FieldDescriptor::CPPTYPE_STRING: {\n      const bool has_default_value = field->has_default_value();\n      const string& default_string = field->default_value_string();\n      if (!has_default_value || default_string.length() == 0) {\n        // If the field is defined as being the empty string,\n        // then we will just assign to nil, as the empty string is the\n        // default for both strings and data.\n        return \"nil\";\n      }\n      if (field->type() == FieldDescriptor::TYPE_BYTES) {\n        // We want constant fields in our data structures so we can\n        // declare them as static. To achieve this we cheat and stuff\n        // a escaped c string (prefixed with a length) into the data\n        // field, and cast it to an (NSData*) so it will compile.\n        // The runtime library knows how to handle it.\n\n        // Must convert to a standard byte order for packing length into\n        // a cstring.\n        uint32 length = ghtonl(default_string.length());\n        string bytes((const char*)&length, sizeof(length));\n        bytes.append(default_string);\n        return \"(NSData*)\\\"\" + EscapeTrigraphs(CEscape(bytes)) + \"\\\"\";\n      } else {\n        return \"@\\\"\" + EscapeTrigraphs(CEscape(default_string)) + \"\\\"\";\n      }\n    }\n    case FieldDescriptor::CPPTYPE_ENUM:\n      return EnumValueName(field->default_value_enum());\n    case FieldDescriptor::CPPTYPE_MESSAGE:\n      return \"nil\";\n  }\n\n  // Some compilers report reaching end of function even though all cases of\n  // the enum are handed in the switch.\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return NULL;\n}\n\nbool HasNonZeroDefaultValue(const FieldDescriptor* field) {\n  // Repeated fields don't have defaults.\n  if (field->is_repeated()) {\n    return false;\n  }\n\n  // As much as checking field->has_default_value() seems useful, it isn't\n  // because of enums. proto2 syntax allows the first item in an enum (the\n  // default) to be non zero. So checking field->has_default_value() would\n  // result in missing this non zero default.  See MessageWithOneBasedEnum in\n  // objectivec/Tests/unittest_objc.proto for a test Message to confirm this.\n\n  // Some proto file set the default to the zero value, so make sure the value\n  // isn't the zero case.\n  switch (field->cpp_type()) {\n    case FieldDescriptor::CPPTYPE_INT32:\n      return field->default_value_int32() != 0;\n    case FieldDescriptor::CPPTYPE_UINT32:\n      return field->default_value_uint32() != 0U;\n    case FieldDescriptor::CPPTYPE_INT64:\n      return field->default_value_int64() != 0LL;\n    case FieldDescriptor::CPPTYPE_UINT64:\n      return field->default_value_uint64() != 0ULL;\n    case FieldDescriptor::CPPTYPE_DOUBLE:\n      return field->default_value_double() != 0.0;\n    case FieldDescriptor::CPPTYPE_FLOAT:\n      return field->default_value_float() != 0.0f;\n    case FieldDescriptor::CPPTYPE_BOOL:\n      return field->default_value_bool();\n    case FieldDescriptor::CPPTYPE_STRING: {\n      const string& default_string = field->default_value_string();\n      return default_string.length() != 0;\n    }\n    case FieldDescriptor::CPPTYPE_ENUM:\n      return field->default_value_enum()->number() != 0;\n    case FieldDescriptor::CPPTYPE_MESSAGE:\n      return false;\n  }\n\n  // Some compilers report reaching end of function even though all cases of\n  // the enum are handed in the switch.\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return false;\n}\n\nstring BuildFlagsString(const vector<string>& strings) {\n  if (strings.size() == 0) {\n    return \"0\";\n  }\n  string string;\n  for (size_t i = 0; i != strings.size(); ++i) {\n    if (i > 0) {\n      string.append(\" | \");\n    }\n    string.append(strings[i]);\n  }\n  return string;\n}\n\nstring BuildCommentsString(const SourceLocation& location) {\n  const string& comments = location.leading_comments.empty()\n                               ? location.trailing_comments\n                               : location.leading_comments;\n  vector<string> lines;\n  SplitStringAllowEmpty(comments, \"\\n\", &lines);\n  while (!lines.empty() && lines.back().empty()) {\n    lines.pop_back();\n  }\n  string prefix(\"///\");\n  string suffix(\"\\n\");\n  string final_comments;\n  for (int i = 0; i < lines.size(); i++) {\n    // HeaderDoc uses '\\' and '@' for markers; escape them.\n    const string line = StringReplace(lines[i], \"\\\\\", \"\\\\\\\\\", true);\n    final_comments +=\n        prefix + StringReplace(line, \"@\", \"\\\\@\", true) + suffix;\n  }\n  return final_comments;\n}\n\n// Making these a generator option for folks that don't use CocoaPods, but do\n// want to put the library in a framework is an interesting question. The\n// problem is it means changing sources shipped with the library to actually\n// use a different value; so it isn't as simple as a option.\nconst char* const ProtobufLibraryFrameworkName = \"Protobuf\";\n\nstring ProtobufFrameworkImportSymbol(const string& framework_name) {\n  // GPB_USE_[framework_name]_FRAMEWORK_IMPORTS\n  string result = string(\"GPB_USE_\");\n  result += ToUpper(framework_name);\n  result += \"_FRAMEWORK_IMPORTS\";\n  return result;\n}\n\nbool IsProtobufLibraryBundledProtoFile(const FileDescriptor* file) {\n  // We don't check the name prefix or proto package because some files\n  // (descriptor.proto), aren't shipped generated by the library, so this\n  // seems to be the safest way to only catch the ones shipped.\n  const string name = file->name();\n  if (name == \"google/protobuf/any.proto\" ||\n      name == \"google/protobuf/api.proto\" ||\n      name == \"google/protobuf/duration.proto\" ||\n      name == \"google/protobuf/empty.proto\" ||\n      name == \"google/protobuf/field_mask.proto\" ||\n      name == \"google/protobuf/source_context.proto\" ||\n      name == \"google/protobuf/struct.proto\" ||\n      name == \"google/protobuf/timestamp.proto\" ||\n      name == \"google/protobuf/type.proto\" ||\n      name == \"google/protobuf/wrappers.proto\") {\n    return true;\n  }\n  return false;\n}\n\nbool ReadLine(StringPiece* input, StringPiece* line) {\n  for (int len = 0; len < input->size(); ++len) {\n    if (ascii_isnewline((*input)[len])) {\n      *line = StringPiece(input->data(), len);\n      ++len;  // advance over the newline\n      *input = StringPiece(input->data() + len, input->size() - len);\n      return true;\n    }\n  }\n  return false;  // Ran out of input with no newline.\n}\n\nvoid RemoveComment(StringPiece* input) {\n  int offset = input->find('#');\n  if (offset != StringPiece::npos) {\n    input->remove_suffix(input->length() - offset);\n  }\n}\n\nnamespace {\n\nclass ExpectedPrefixesCollector : public LineConsumer {\n public:\n  ExpectedPrefixesCollector(map<string, string>* inout_package_to_prefix_map)\n      : prefix_map_(inout_package_to_prefix_map) {}\n\n  virtual bool ConsumeLine(const StringPiece& line, string* out_error);\n\n private:\n  map<string, string>* prefix_map_;\n};\n\nbool ExpectedPrefixesCollector::ConsumeLine(\n    const StringPiece& line, string* out_error) {\n  int offset = line.find('=');\n  if (offset == StringPiece::npos) {\n    *out_error =\n        string(\"Expected prefixes file line without equal sign: '\") +\n        line.ToString() + \"'.\";\n    return false;\n  }\n  StringPiece package(line, 0, offset);\n  StringPiece prefix(line, offset + 1, line.length() - offset - 1);\n  StringPieceTrimWhitespace(&package);\n  StringPieceTrimWhitespace(&prefix);\n  // Don't really worry about error checking the package/prefix for\n  // being valid.  Assume the file is validated when it is created/edited.\n  (*prefix_map_)[package.ToString()] = prefix.ToString();\n  return true;\n}\n\nbool LoadExpectedPackagePrefixes(const Options &generation_options,\n                                 map<string, string>* prefix_map,\n                                 string* out_error) {\n  if (generation_options.expected_prefixes_path.empty()) {\n    return true;\n  }\n\n  ExpectedPrefixesCollector collector(prefix_map);\n  return ParseSimpleFile(\n      generation_options.expected_prefixes_path, &collector, out_error);\n}\n\n}  // namespace\n\nbool ValidateObjCClassPrefix(const FileDescriptor* file,\n                             const Options& generation_options,\n                             string* out_error) {\n  const string prefix = file->options().objc_class_prefix();\n  const string package = file->package();\n\n  // NOTE: src/google/protobuf/compiler/plugin.cc makes use of cerr for some\n  // error cases, so it seems to be ok to use as a back door for warnings.\n\n  // Load any expected package prefixes to validate against those.\n  map<string, string> expected_package_prefixes;\n  if (!LoadExpectedPackagePrefixes(generation_options,\n                                   &expected_package_prefixes,\n                                   out_error)) {\n    return false;\n  }\n\n  // Check: Error - See if there was an expected prefix for the package and\n  // report if it doesn't match (wrong or missing).\n  map<string, string>::iterator package_match =\n      expected_package_prefixes.find(package);\n  if (package_match != expected_package_prefixes.end()) {\n    // There was an entry, and...\n    if (package_match->second == prefix) {\n      // ...it matches.  All good, out of here!\n      return true;\n    } else {\n      // ...it didn't match!\n      *out_error = \"error: Expected 'option objc_class_prefix = \\\"\" +\n                   package_match->second + \"\\\";' for package '\" + package +\n                   \"' in '\" + file->name() + \"'\";\n      if (prefix.length()) {\n        *out_error += \"; but found '\" + prefix + \"' instead\";\n      }\n      *out_error += \".\";\n      return false;\n    }\n  }\n\n  // If there was no prefix option, we're done at this point.\n  if (prefix.length() == 0) {\n    // No prefix, nothing left to check.\n    return true;\n  }\n\n  // Check: Error - Make sure the prefix wasn't expected for a different\n  // package (overlap is allowed, but it has to be listed as an expected\n  // overlap).\n  for (map<string, string>::iterator i = expected_package_prefixes.begin();\n       i != expected_package_prefixes.end(); ++i) {\n    if (i->second == prefix) {\n      *out_error =\n          \"error: Found 'option objc_class_prefix = \\\"\" + prefix +\n          \"\\\";' in '\" + file->name() +\n          \"'; that prefix is already used for 'package \" + i->first +\n          \";'. It can only be reused by listing it in the expected file (\" +\n          generation_options.expected_prefixes_path + \").\";\n      return false;  // Only report first usage of the prefix.\n    }\n  }\n\n  // Check: Warning - Make sure the prefix is is a reasonable value according\n  // to Apple's rules (the checks above implicitly whitelist anything that\n  // doesn't meet these rules).\n  if (!ascii_isupper(prefix[0])) {\n    cerr << endl\n         << \"protoc:0: warning: Invalid 'option objc_class_prefix = \\\"\"\n         << prefix << \"\\\";' in '\" << file->name() << \"';\"\n         << \" it should start with a capital letter.\" << endl;\n    cerr.flush();\n  }\n  if (prefix.length() < 3) {\n    // Apple reserves 2 character prefixes for themselves. They do use some\n    // 3 character prefixes, but they haven't updated the rules/docs.\n    cerr << endl\n         << \"protoc:0: warning: Invalid 'option objc_class_prefix = \\\"\"\n         << prefix << \"\\\";' in '\" << file->name() << \"';\"\n         << \" Apple recommends they should be at least 3 characters long.\"\n         << endl;\n    cerr.flush();\n  }\n\n  // Check: Warning - If the given package/prefix pair wasn't expected, issue a\n  // warning issue a warning suggesting it gets added to the file.\n  if (!expected_package_prefixes.empty()) {\n    cerr << endl\n         << \"protoc:0: warning: Found unexpected 'option objc_class_prefix = \\\"\"\n         << prefix << \"\\\";' in '\" << file->name() << \"';\"\n         << \" consider adding it to the expected prefixes file (\"\n         << generation_options.expected_prefixes_path << \").\" << endl;\n    cerr.flush();\n  }\n\n  return true;\n}\n\nTextFormatDecodeData::TextFormatDecodeData() { }\n\nTextFormatDecodeData::~TextFormatDecodeData() { }\n\nvoid TextFormatDecodeData::AddString(int32 key,\n                                     const string& input_for_decode,\n                                     const string& desired_output) {\n  for (vector<DataEntry>::const_iterator i = entries_.begin();\n       i != entries_.end(); ++i) {\n    if (i->first == key) {\n      cerr << \"error: duplicate key (\" << key\n           << \") making TextFormat data, input: \\\"\" << input_for_decode\n           << \"\\\", desired: \\\"\" << desired_output << \"\\\".\" << endl;\n      cerr.flush();\n      abort();\n    }\n  }\n\n  const string& data = TextFormatDecodeData::DecodeDataForString(\n      input_for_decode, desired_output);\n  entries_.push_back(DataEntry(key, data));\n}\n\nstring TextFormatDecodeData::Data() const {\n  ostringstream data_stringstream;\n\n  if (num_entries() > 0) {\n    io::OstreamOutputStream data_outputstream(&data_stringstream);\n    io::CodedOutputStream output_stream(&data_outputstream);\n\n    output_stream.WriteVarint32(num_entries());\n    for (vector<DataEntry>::const_iterator i = entries_.begin();\n         i != entries_.end(); ++i) {\n      output_stream.WriteVarint32(i->first);\n      output_stream.WriteString(i->second);\n    }\n  }\n\n  data_stringstream.flush();\n  return data_stringstream.str();\n}\n\nnamespace {\n\n// Helper to build up the decode data for a string.\nclass DecodeDataBuilder {\n public:\n  DecodeDataBuilder() { Reset(); }\n\n  bool AddCharacter(const char desired, const char input);\n  void AddUnderscore() {\n    Push();\n    need_underscore_ = true;\n  }\n  string Finish() {\n    Push();\n    return decode_data_;\n  }\n\n private:\n  static const uint8 kAddUnderscore = 0x80;\n\n  static const uint8 kOpAsIs        = 0x00;\n  static const uint8 kOpFirstUpper  = 0x40;\n  static const uint8 kOpFirstLower  = 0x20;\n  static const uint8 kOpAllUpper    = 0x60;\n\n  static const int kMaxSegmentLen     = 0x1f;\n\n  void AddChar(const char desired) {\n    ++segment_len_;\n    is_all_upper_ &= ascii_isupper(desired);\n  }\n\n  void Push() {\n    uint8 op = (op_ | segment_len_);\n    if (need_underscore_) op |= kAddUnderscore;\n    if (op != 0) {\n      decode_data_ += (char)op;\n    }\n    Reset();\n  }\n\n  bool AddFirst(const char desired, const char input) {\n    if (desired == input) {\n      op_ = kOpAsIs;\n    } else if (desired == ascii_toupper(input)) {\n      op_ = kOpFirstUpper;\n    } else if (desired == ascii_tolower(input)) {\n      op_ = kOpFirstLower;\n    } else {\n      // Can't be transformed to match.\n      return false;\n    }\n    AddChar(desired);\n    return true;\n  }\n\n  void Reset() {\n    need_underscore_ = false;\n    op_ = 0;\n    segment_len_ = 0;\n    is_all_upper_ = true;\n  }\n\n  bool need_underscore_;\n  bool is_all_upper_;\n  uint8 op_;\n  int segment_len_;\n\n  string decode_data_;\n};\n\nbool DecodeDataBuilder::AddCharacter(const char desired, const char input) {\n  // If we've hit the max size, push to start a new segment.\n  if (segment_len_ == kMaxSegmentLen) {\n    Push();\n  }\n  if (segment_len_ == 0) {\n    return AddFirst(desired, input);\n  }\n\n  // Desired and input match...\n  if (desired == input) {\n    // If we aren't transforming it, or we're upper casing it and it is\n    // supposed to be uppercase; just add it to the segment.\n    if ((op_ != kOpAllUpper) || ascii_isupper(desired)) {\n      AddChar(desired);\n      return true;\n    }\n\n    // Add the current segment, and start the next one.\n    Push();\n    return AddFirst(desired, input);\n  }\n\n  // If we need to uppercase, and everything so far has been uppercase,\n  // promote op to AllUpper.\n  if ((desired == ascii_toupper(input)) && is_all_upper_) {\n    op_ = kOpAllUpper;\n    AddChar(desired);\n    return true;\n  }\n\n  // Give up, push and start a new segment.\n  Push();\n  return AddFirst(desired, input);\n}\n\n// If decode data can't be generated, a directive for the raw string\n// is used instead.\nstring DirectDecodeString(const string& str) {\n  string result;\n  result += (char)'\\0';  // Marker for full string.\n  result += str;\n  result += (char)'\\0';  // End of string.\n  return result;\n}\n\n}  // namespace\n\n// static\nstring TextFormatDecodeData::DecodeDataForString(const string& input_for_decode,\n                                                 const string& desired_output) {\n  if ((input_for_decode.size() == 0) || (desired_output.size() == 0)) {\n    cerr << \"error: got empty string for making TextFormat data, input: \\\"\"\n         << input_for_decode << \"\\\", desired: \\\"\" << desired_output << \"\\\".\"\n         << endl;\n    cerr.flush();\n    abort();\n  }\n  if ((input_for_decode.find('\\0') != string::npos) ||\n      (desired_output.find('\\0') != string::npos)) {\n    cerr << \"error: got a null char in a string for making TextFormat data,\"\n         << \" input: \\\"\" << CEscape(input_for_decode) << \"\\\", desired: \\\"\"\n         << CEscape(desired_output) << \"\\\".\" << endl;\n    cerr.flush();\n    abort();\n  }\n\n  DecodeDataBuilder builder;\n\n  // Walk the output building it from the input.\n  int x = 0;\n  for (int y = 0; y < desired_output.size(); y++) {\n    const char d = desired_output[y];\n    if (d == '_') {\n      builder.AddUnderscore();\n      continue;\n    }\n\n    if (x >= input_for_decode.size()) {\n      // Out of input, no way to encode it, just return a full decode.\n      return DirectDecodeString(desired_output);\n    }\n    if (builder.AddCharacter(d, input_for_decode[x])) {\n      ++x;  // Consumed one input\n    } else {\n      // Couldn't transform for the next character, just return a full decode.\n      return DirectDecodeString(desired_output);\n    }\n  }\n\n  if (x != input_for_decode.size()) {\n    // Extra input (suffix from name sanitizing?), just return a full decode.\n    return DirectDecodeString(desired_output);\n  }\n\n  // Add the end marker.\n  return builder.Finish() + (char)'\\0';\n}\n\nnamespace {\n\nclass Parser {\n public:\n  Parser(LineConsumer* line_consumer)\n      : line_consumer_(line_consumer), line_(0) {}\n\n  // Parses a check of input, returning success/failure.\n  bool ParseChunk(StringPiece chunk);\n\n  // Should be called to finish parsing (after all input has been provided via\n  // ParseChunk()).  Returns success/failure.\n  bool Finish();\n\n  int last_line() const { return line_; }\n  string error_str() const { return error_str_; }\n\n private:\n  bool ParseLoop();\n\n  LineConsumer* line_consumer_;\n  int line_;\n  string error_str_;\n  StringPiece p_;\n  string leftover_;\n};\n\nbool Parser::ParseChunk(StringPiece chunk) {\n  if (!leftover_.empty()) {\n    chunk.AppendToString(&leftover_);\n    p_ = StringPiece(leftover_);\n  } else {\n    p_ = chunk;\n  }\n  bool result = ParseLoop();\n  if (p_.empty()) {\n    leftover_.clear();\n  } else {\n    leftover_ = p_.ToString();\n  }\n  return result;\n}\n\nbool Parser::Finish() {\n  if (leftover_.empty()) {\n    return true;\n  }\n  // Force a newline onto the end to finish parsing.\n  leftover_ += \"\\n\";\n  p_ = StringPiece(leftover_);\n  if (!ParseLoop()) {\n    return false;\n  }\n  return p_.empty();  // Everything used?\n}\n\nbool Parser::ParseLoop() {\n  StringPiece line;\n  while (ReadLine(&p_, &line)) {\n    ++line_;\n    RemoveComment(&line);\n    StringPieceTrimWhitespace(&line);\n    if (line.size() == 0) {\n      continue;  // Blank line.\n    }\n    if (!line_consumer_->ConsumeLine(line, &error_str_)) {\n      return false;\n    }\n  }\n  return true;\n}\n\n}  // namespace\n\nLineConsumer::LineConsumer() {}\n\nLineConsumer::~LineConsumer() {}\n\nbool ParseSimpleFile(\n    const string& path, LineConsumer* line_consumer, string* out_error) {\n  int fd;\n  do {\n    fd = open(path.c_str(), O_RDONLY);\n  } while (fd < 0 && errno == EINTR);\n  if (fd < 0) {\n    *out_error =\n        string(\"error: Unable to open \\\"\") + path + \"\\\", \" + strerror(errno);\n    return false;\n  }\n  io::FileInputStream file_stream(fd);\n  file_stream.SetCloseOnDelete(true);\n\n  Parser parser(line_consumer);\n  const void* buf;\n  int buf_len;\n  while (file_stream.Next(&buf, &buf_len)) {\n    if (buf_len == 0) {\n      continue;\n    }\n\n    if (!parser.ParseChunk(StringPiece(static_cast<const char*>(buf), buf_len))) {\n      *out_error =\n          string(\"error: \") + path +\n          \" Line \" + SimpleItoa(parser.last_line()) + \", \" + parser.error_str();\n      return false;\n    }\n  }\n  return parser.Finish();\n}\n\n\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_helpers.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_HELPERS_H__\n#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_HELPERS_H__\n\n#include <string>\n#include <vector>\n\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace objectivec {\n\n// Generator options (see objectivec_generator.cc for a description of each):\nstruct Options {\n  Options();\n  string expected_prefixes_path;\n  string generate_for_named_framework;\n  string named_framework_to_proto_path_mappings_path;\n};\n\n// Escape C++ trigraphs by escaping question marks to \"\\?\".\nstring EscapeTrigraphs(const string& to_escape);\n\n// Strips \".proto\" or \".protodevel\" from the end of a filename.\nstring StripProto(const string& filename);\n\n// Remove white space from either end of a StringPiece.\nvoid StringPieceTrimWhitespace(StringPiece* input);\n\n// Returns true if the name requires a ns_returns_not_retained attribute applied\n// to it.\nbool IsRetainedName(const string& name);\n\n// Returns true if the name starts with \"init\" and will need to have special\n// handling under ARC.\nbool IsInitName(const string& name);\n\n// Gets the path of the file we're going to generate (sans the .pb.h\n// extension).  The path will be dependent on the objectivec package\n// declared in the proto package.\nstring FilePath(const FileDescriptor* file);\n\n// Just like FilePath(), but without the directory part.\nstring FilePathBasename(const FileDescriptor* file);\n\n// Gets the name of the root class we'll generate in the file.  This class\n// is not meant for external consumption, but instead contains helpers that\n// the rest of the classes need\nstring FileClassName(const FileDescriptor* file);\n\n// These return the fully-qualified class name corresponding to the given\n// descriptor.\nstring ClassName(const Descriptor* descriptor);\nstring EnumName(const EnumDescriptor* descriptor);\n\n// Returns the fully-qualified name of the enum value corresponding to the\n// the descriptor.\nstring EnumValueName(const EnumValueDescriptor* descriptor);\n\n// Returns the name of the enum value corresponding to the descriptor.\nstring EnumValueShortName(const EnumValueDescriptor* descriptor);\n\n// Reverse what an enum does.\nstring UnCamelCaseEnumShortName(const string& name);\n\n// Returns the name to use for the extension (used as the method off the file's\n// Root class).\nstring ExtensionMethodName(const FieldDescriptor* descriptor);\n\n// Returns the transformed field name.\nstring FieldName(const FieldDescriptor* field);\nstring FieldNameCapitalized(const FieldDescriptor* field);\n\n// Returns the transformed oneof name.\nstring OneofEnumName(const OneofDescriptor* descriptor);\nstring OneofName(const OneofDescriptor* descriptor);\nstring OneofNameCapitalized(const OneofDescriptor* descriptor);\n\ninline bool HasFieldPresence(const FileDescriptor* file) {\n  return file->syntax() != FileDescriptor::SYNTAX_PROTO3;\n}\n\ninline bool HasPreservingUnknownEnumSemantics(const FileDescriptor* file) {\n  return file->syntax() == FileDescriptor::SYNTAX_PROTO3;\n}\n\ninline bool IsMapEntryMessage(const Descriptor* descriptor) {\n  return descriptor->options().map_entry();\n}\n\n// Reverse of the above.\nstring UnCamelCaseFieldName(const string& name, const FieldDescriptor* field);\n\nenum ObjectiveCType {\n  OBJECTIVECTYPE_INT32,\n  OBJECTIVECTYPE_UINT32,\n  OBJECTIVECTYPE_INT64,\n  OBJECTIVECTYPE_UINT64,\n  OBJECTIVECTYPE_FLOAT,\n  OBJECTIVECTYPE_DOUBLE,\n  OBJECTIVECTYPE_BOOLEAN,\n  OBJECTIVECTYPE_STRING,\n  OBJECTIVECTYPE_DATA,\n  OBJECTIVECTYPE_ENUM,\n  OBJECTIVECTYPE_MESSAGE\n};\n\ntemplate<class TDescriptor>\nstring GetOptionalDeprecatedAttribute(const TDescriptor* descriptor, bool preSpace = true, bool postNewline = false) {\n  if (descriptor->options().deprecated()) {\n    string result = \"DEPRECATED_ATTRIBUTE\";\n    if (preSpace) {\n      result.insert(0, \" \");\n    }\n    if (postNewline) {\n      result.append(\"\\n\");\n    }\n    return result;\n  } else {\n    return \"\";\n  }\n}\n\nstring GetCapitalizedType(const FieldDescriptor* field);\n\nObjectiveCType GetObjectiveCType(FieldDescriptor::Type field_type);\n\ninline ObjectiveCType GetObjectiveCType(const FieldDescriptor* field) {\n  return GetObjectiveCType(field->type());\n}\n\nbool IsPrimitiveType(const FieldDescriptor* field);\nbool IsReferenceType(const FieldDescriptor* field);\n\nstring GPBGenericValueFieldName(const FieldDescriptor* field);\nstring DefaultValue(const FieldDescriptor* field);\nbool HasNonZeroDefaultValue(const FieldDescriptor* field);\n\nstring BuildFlagsString(const vector<string>& strings);\n\n// Builds a HeaderDoc style comment out of the comments in the .proto file.\nstring BuildCommentsString(const SourceLocation& location);\n\n// The name the commonly used by the library when built as a framework.\n// This lines up to the name used in the CocoaPod.\nextern const char* const ProtobufLibraryFrameworkName;\n// Returns the CPP symbol name to use as the gate for framework style imports\n// for the given framework name to use.\nstring ProtobufFrameworkImportSymbol(const string& framework_name);\n\n// Checks if the file is one of the proto's bundled with the library.\nbool IsProtobufLibraryBundledProtoFile(const FileDescriptor* file);\n\n// Checks the prefix for a given file and outputs any warnings needed, if\n// there are flat out errors, then out_error is filled in and the result is\n// false.\nbool ValidateObjCClassPrefix(const FileDescriptor* file,\n                             const Options& generation_options,\n                             string* out_error);\n\n// Generate decode data needed for ObjC's GPBDecodeTextFormatName() to transform\n// the input into the expected output.\nclass LIBPROTOC_EXPORT TextFormatDecodeData {\n public:\n  TextFormatDecodeData();\n  ~TextFormatDecodeData();\n\n  void AddString(int32 key, const string& input_for_decode,\n                 const string& desired_output);\n  size_t num_entries() const { return entries_.size(); }\n  string Data() const;\n\n  static string DecodeDataForString(const string& input_for_decode,\n                                    const string& desired_output);\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TextFormatDecodeData);\n\n  typedef std::pair<int32, string> DataEntry;\n  vector<DataEntry> entries_;\n};\n\n// Helper for parsing simple files.\nclass LIBPROTOC_EXPORT LineConsumer {\n public:\n  LineConsumer();\n  virtual ~LineConsumer();\n  virtual bool ConsumeLine(const StringPiece& line, string* out_error) = 0;\n};\n\nbool ParseSimpleFile(\n    const string& path, LineConsumer* line_consumer, string* out_error);\n\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_HELPERS_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2014 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace objectivec {\nnamespace {\n\nTEST(ObjCHelper, TextFormatDecodeData_DecodeDataForString_RawStrings) {\n  string input_for_decode(\"abcdefghIJ\");\n  string desired_output_for_decode;\n  string expected;\n  string result;\n\n  // Different data, can't transform.\n\n  desired_output_for_decode = \"zbcdefghIJ\";\n  expected = string(\"\\0zbcdefghIJ\\0\", 12);\n  result = TextFormatDecodeData::DecodeDataForString(input_for_decode,\n                                                     desired_output_for_decode);\n  EXPECT_EQ(expected, result);\n\n  desired_output_for_decode = \"abcdezghIJ\";\n  expected = string(\"\\0abcdezghIJ\\0\", 12);\n  result = TextFormatDecodeData::DecodeDataForString(input_for_decode,\n                                                     desired_output_for_decode);\n  EXPECT_EQ(expected, result);\n\n  // Shortened data, can't transform.\n\n  desired_output_for_decode = \"abcdefghI\";\n  expected = string(\"\\0abcdefghI\\0\", 11);\n  result = TextFormatDecodeData::DecodeDataForString(input_for_decode,\n                                                     desired_output_for_decode);\n  EXPECT_EQ(expected, result);\n\n  // Extra data, can't transform.\n\n  desired_output_for_decode = \"abcdefghIJz\";\n  expected = string(\"\\0abcdefghIJz\\0\", 13);\n  result = TextFormatDecodeData::DecodeDataForString(input_for_decode,\n                                                     desired_output_for_decode);\n  EXPECT_EQ(expected, result);\n}\n\nTEST(ObjCHelper, TextFormatDecodeData_DecodeDataForString_ByteCodes) {\n  string input_for_decode(\"abcdefghIJ\");\n  string desired_output_for_decode;\n  string expected;\n  string result;\n\n  desired_output_for_decode = \"abcdefghIJ\";\n  expected = string(\"\\x0A\\x0\", 2);\n  result = TextFormatDecodeData::DecodeDataForString(input_for_decode,\n                                                     desired_output_for_decode);\n  EXPECT_EQ(expected, result);\n\n  desired_output_for_decode = \"_AbcdefghIJ\";\n  expected = string(\"\\xCA\\x0\", 2);\n  result = TextFormatDecodeData::DecodeDataForString(input_for_decode,\n                                                     desired_output_for_decode);\n  EXPECT_EQ(expected, result);\n\n  desired_output_for_decode = \"ABCD__EfghI_j\";\n  expected = string(\"\\x64\\x80\\xC5\\xA1\\x0\", 5);\n  result = TextFormatDecodeData::DecodeDataForString(input_for_decode,\n                                                     desired_output_for_decode);\n  EXPECT_EQ(expected, result);\n\n  // Long name so multiple decode ops are needed.\n\n  input_for_decode =\n      \"longFieldNameIsLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1000\";\n  desired_output_for_decode =\n      \"long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_1000\";\n  expected = string(\"\\x04\\xA5\\xA4\\xA2\\xBF\\x1F\\x0E\\x84\\x0\", 9);\n  result = TextFormatDecodeData::DecodeDataForString(input_for_decode,\n                                                     desired_output_for_decode);\n  EXPECT_EQ(expected, result);\n}\n\n// Death tests do not work on Windows as of yet.\n#ifdef PROTOBUF_HAS_DEATH_TEST\nTEST(ObjCHelperDeathTest, TextFormatDecodeData_DecodeDataForString_Failures) {\n  // Empty inputs.\n\n  EXPECT_EXIT(TextFormatDecodeData::DecodeDataForString(\"\", \"\"),\n              ::testing::KilledBySignal(SIGABRT),\n              \"error: got empty string for making TextFormat data, input:\");\n  EXPECT_EXIT(TextFormatDecodeData::DecodeDataForString(\"a\", \"\"),\n              ::testing::KilledBySignal(SIGABRT),\n              \"error: got empty string for making TextFormat data, input:\");\n  EXPECT_EXIT(TextFormatDecodeData::DecodeDataForString(\"\", \"a\"),\n              ::testing::KilledBySignal(SIGABRT),\n              \"error: got empty string for making TextFormat data, input:\");\n\n  // Null char in the string.\n\n  string str_with_null_char(\"ab\\0c\", 4);\n  EXPECT_EXIT(\n      TextFormatDecodeData::DecodeDataForString(str_with_null_char, \"def\"),\n      ::testing::KilledBySignal(SIGABRT),\n      \"error: got a null char in a string for making TextFormat data, input:\");\n  EXPECT_EXIT(\n      TextFormatDecodeData::DecodeDataForString(\"def\", str_with_null_char),\n      ::testing::KilledBySignal(SIGABRT),\n      \"error: got a null char in a string for making TextFormat data, input:\");\n}\n#endif  // PROTOBUF_HAS_DEATH_TEST\n\nTEST(ObjCHelper, TextFormatDecodeData_RawStrings) {\n  TextFormatDecodeData decode_data;\n\n  // Different data, can't transform.\n  decode_data.AddString(1, \"abcdefghIJ\", \"zbcdefghIJ\");\n  decode_data.AddString(3, \"abcdefghIJ\", \"abcdezghIJ\");\n  // Shortened data, can't transform.\n  decode_data.AddString(2, \"abcdefghIJ\", \"abcdefghI\");\n  // Extra data, can't transform.\n  decode_data.AddString(4, \"abcdefghIJ\", \"abcdefghIJz\");\n\n  EXPECT_EQ(4, decode_data.num_entries());\n\n  uint8 expected_data[] = {\n      0x4,\n      0x1, 0x0, 'z', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'I', 'J', 0x0,\n      0x3, 0x0, 'a', 'b', 'c', 'd', 'e', 'z', 'g', 'h', 'I', 'J', 0x0,\n      0x2, 0x0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'I', 0x0,\n      0x4, 0x0, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'I', 'J', 'z', 0x0,\n  };\n  string expected((const char*)expected_data, sizeof(expected_data));\n\n  EXPECT_EQ(expected, decode_data.Data());\n}\n\nTEST(ObjCHelper, TextFormatDecodeData_ByteCodes) {\n  TextFormatDecodeData decode_data;\n\n  decode_data.AddString(1, \"abcdefghIJ\", \"abcdefghIJ\");\n  decode_data.AddString(3, \"abcdefghIJ\", \"_AbcdefghIJ\");\n  decode_data.AddString(2, \"abcdefghIJ\", \"Abcd_EfghIJ\");\n  decode_data.AddString(4, \"abcdefghIJ\", \"ABCD__EfghI_j\");\n  decode_data.AddString(1000,\n                        \"longFieldNameIsLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1000\",\n                        \"long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_1000\");\n\n  EXPECT_EQ(5, decode_data.num_entries());\n\n  uint8 expected_data[] = {\n      0x5,\n      // All as is (00 op)\n      0x1,  0x0A, 0x0,\n      // Underscore, upper + 9 (10 op)\n      0x3,  0xCA, 0x0,\n      //  Upper + 3 (10 op), underscore, upper + 5 (10 op)\n      0x2,  0x44, 0xC6, 0x0,\n      // All Upper for 4 (11 op), underscore, underscore, upper + 5 (10 op),\n      // underscore, lower + 0 (01 op)\n      0x4,  0x64, 0x80, 0xC5, 0xA1, 0x0,\n      // 2 byte key: as is + 3 (00 op), underscore, lower + 4 (01 op),\n      //   underscore, lower + 3 (01 op), underscore, lower + 1 (01 op),\n      //   underscore, lower + 30 (01 op), as is + 30 (00 op), as is + 13 (00\n      //   op),\n      //   underscore, as is + 3 (00 op)\n      0xE8, 0x07, 0x04, 0xA5, 0xA4, 0xA2, 0xBF, 0x1F, 0x0E, 0x84, 0x0,\n  };\n  string expected((const char*)expected_data, sizeof(expected_data));\n\n  EXPECT_EQ(expected, decode_data.Data());\n}\n\n\n// Death tests do not work on Windows as of yet.\n#ifdef PROTOBUF_HAS_DEATH_TEST\nTEST(ObjCHelperDeathTest, TextFormatDecodeData_Failures) {\n  TextFormatDecodeData decode_data;\n\n  // Empty inputs.\n\n  EXPECT_EXIT(decode_data.AddString(1, \"\", \"\"),\n              ::testing::KilledBySignal(SIGABRT),\n              \"error: got empty string for making TextFormat data, input:\");\n  EXPECT_EXIT(decode_data.AddString(1, \"a\", \"\"),\n              ::testing::KilledBySignal(SIGABRT),\n              \"error: got empty string for making TextFormat data, input:\");\n  EXPECT_EXIT(decode_data.AddString(1, \"\", \"a\"),\n              ::testing::KilledBySignal(SIGABRT),\n              \"error: got empty string for making TextFormat data, input:\");\n\n  // Null char in the string.\n\n  string str_with_null_char(\"ab\\0c\", 4);\n  EXPECT_EXIT(\n      decode_data.AddString(1, str_with_null_char, \"def\"),\n      ::testing::KilledBySignal(SIGABRT),\n      \"error: got a null char in a string for making TextFormat data, input:\");\n  EXPECT_EXIT(\n      decode_data.AddString(1, \"def\", str_with_null_char),\n      ::testing::KilledBySignal(SIGABRT),\n      \"error: got a null char in a string for making TextFormat data, input:\");\n\n  // Duplicate keys\n\n  decode_data.AddString(1, \"abcdefghIJ\", \"abcdefghIJ\");\n  decode_data.AddString(3, \"abcdefghIJ\", \"_AbcdefghIJ\");\n  decode_data.AddString(2, \"abcdefghIJ\", \"Abcd_EfghIJ\");\n  EXPECT_EXIT(decode_data.AddString(2, \"xyz\", \"x_yz\"),\n              ::testing::KilledBySignal(SIGABRT),\n              \"error: duplicate key \\\\(2\\\\) making TextFormat data, input:\");\n}\n#endif  // PROTOBUF_HAS_DEATH_TEST\n\n// TODO(thomasvl): Should probably add some unittests for all the special cases\n// of name mangling (class name, field name, enum names).  Rather than doing\n// this with an ObjC test in the objectivec directory, we should be able to\n// use src/google/protobuf/compiler/importer* (like other tests) to support a\n// virtual file system to feed in protos, once we have the Descriptor tree, the\n// tests could use the helper methods for generating names and validate the\n// right things are happening.\n\n}  // namespace\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2015 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/compiler/objectivec/objectivec_map_field.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace objectivec {\n\n// MapFieldGenerator uses RepeatedFieldGenerator as the parent because it\n// provides a bunch of things (no has* methods, comments for contained type,\n// etc.).\n\nnamespace {\n\nconst char* MapEntryTypeName(const FieldDescriptor* descriptor, bool isKey) {\n  ObjectiveCType type = GetObjectiveCType(descriptor);\n  switch (type) {\n    case OBJECTIVECTYPE_INT32:\n      return \"Int32\";\n    case OBJECTIVECTYPE_UINT32:\n      return \"UInt32\";\n    case OBJECTIVECTYPE_INT64:\n      return \"Int64\";\n    case OBJECTIVECTYPE_UINT64:\n      return \"UInt64\";\n    case OBJECTIVECTYPE_FLOAT:\n      return \"Float\";\n    case OBJECTIVECTYPE_DOUBLE:\n      return \"Double\";\n    case OBJECTIVECTYPE_BOOLEAN:\n      return \"Bool\";\n    case OBJECTIVECTYPE_STRING:\n      return (isKey ? \"String\" : \"Object\");\n    case OBJECTIVECTYPE_DATA:\n      return \"Object\";\n    case OBJECTIVECTYPE_ENUM:\n      return \"Enum\";\n    case OBJECTIVECTYPE_MESSAGE:\n      return \"Object\";\n  }\n\n  // Some compilers report reaching end of function even though all cases of\n  // the enum are handed in the switch.\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return NULL;\n}\n\n}  // namespace\n\nMapFieldGenerator::MapFieldGenerator(const FieldDescriptor* descriptor,\n                                     const Options& options)\n    : RepeatedFieldGenerator(descriptor, options) {\n  const FieldDescriptor* key_descriptor =\n      descriptor->message_type()->FindFieldByName(\"key\");\n  const FieldDescriptor* value_descriptor =\n      descriptor->message_type()->FindFieldByName(\"value\");\n  value_field_generator_.reset(FieldGenerator::Make(value_descriptor, options));\n\n  // Pull over some variables_ from the value.\n  variables_[\"field_type\"] = value_field_generator_->variable(\"field_type\");\n  variables_[\"default\"] = value_field_generator_->variable(\"default\");\n  variables_[\"default_name\"] = value_field_generator_->variable(\"default_name\");\n\n  // Build custom field flags.\n  std::vector<string> field_flags;\n  field_flags.push_back(\"GPBFieldMapKey\" + GetCapitalizedType(key_descriptor));\n  // Pull over the current text format custom name values that was calculated.\n  if (variables_[\"fieldflags\"].find(\"GPBFieldTextFormatNameCustom\") !=\n      string::npos) {\n    field_flags.push_back(\"GPBFieldTextFormatNameCustom\");\n  }\n  // Pull over some info from the value's flags.\n  const string& value_field_flags =\n      value_field_generator_->variable(\"fieldflags\");\n  if (value_field_flags.find(\"GPBFieldHasDefaultValue\") != string::npos) {\n    field_flags.push_back(\"GPBFieldHasDefaultValue\");\n  }\n  if (value_field_flags.find(\"GPBFieldHasEnumDescriptor\") != string::npos) {\n    field_flags.push_back(\"GPBFieldHasEnumDescriptor\");\n  }\n  variables_[\"fieldflags\"] = BuildFlagsString(field_flags);\n\n  ObjectiveCType value_objc_type = GetObjectiveCType(value_descriptor);\n  const bool value_is_object_type =\n      ((value_objc_type == OBJECTIVECTYPE_STRING) ||\n       (value_objc_type == OBJECTIVECTYPE_DATA) ||\n       (value_objc_type == OBJECTIVECTYPE_MESSAGE));\n  if ((GetObjectiveCType(key_descriptor) == OBJECTIVECTYPE_STRING) &&\n      value_is_object_type) {\n    variables_[\"array_storage_type\"] = \"NSMutableDictionary\";\n    variables_[\"array_property_type\"] =\n        \"NSMutableDictionary<NSString*, \" +\n        value_field_generator_->variable(\"storage_type\") + \"*>\";\n  } else {\n    string class_name(\"GPB\");\n    class_name += MapEntryTypeName(key_descriptor, true);\n    class_name += MapEntryTypeName(value_descriptor, false);\n    class_name += \"Dictionary\";\n    variables_[\"array_storage_type\"] = class_name;\n    if (value_is_object_type) {\n      variables_[\"array_property_type\"] =\n          class_name + \"<\" +\n          value_field_generator_->variable(\"storage_type\") + \"*>\";\n    }\n  }\n\n  variables_[\"dataTypeSpecific_name\"] =\n      value_field_generator_->variable(\"dataTypeSpecific_name\");\n  variables_[\"dataTypeSpecific_value\"] =\n      value_field_generator_->variable(\"dataTypeSpecific_value\");\n}\n\nMapFieldGenerator::~MapFieldGenerator() {}\n\nvoid MapFieldGenerator::FinishInitialization(void) {\n  RepeatedFieldGenerator::FinishInitialization();\n  // Use the array_comment support in RepeatedFieldGenerator to output what the\n  // values in the map are.\n  const FieldDescriptor* value_descriptor =\n      descriptor_->message_type()->FindFieldByName(\"value\");\n  if (GetObjectiveCType(value_descriptor) == OBJECTIVECTYPE_ENUM) {\n    variables_[\"array_comment\"] =\n        \"// |\" + variables_[\"name\"] + \"| values are |\" + value_field_generator_->variable(\"storage_type\") + \"|\\n\";\n  }\n}\n\nvoid MapFieldGenerator::DetermineForwardDeclarations(\n    set<string>* fwd_decls) const {\n  RepeatedFieldGenerator::DetermineForwardDeclarations(fwd_decls);\n  const FieldDescriptor* value_descriptor =\n      descriptor_->message_type()->FindFieldByName(\"value\");\n  if (GetObjectiveCType(value_descriptor) == OBJECTIVECTYPE_MESSAGE) {\n    const string& value_storage_type =\n        value_field_generator_->variable(\"storage_type\");\n    fwd_decls->insert(\"@class \" + value_storage_type);\n  }\n}\n\n\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_map_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2015 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MAP_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MAP_FIELD_H__\n\n#include <map>\n#include <string>\n#include <google/protobuf/compiler/objectivec/objectivec_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace objectivec {\n\nclass MapFieldGenerator : public RepeatedFieldGenerator {\n  friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field,\n                                              const Options& options);\n\n public:\n  virtual void FinishInitialization(void);\n\n protected:\n  MapFieldGenerator(const FieldDescriptor* descriptor, const Options& options);\n  virtual ~MapFieldGenerator();\n\n  virtual void DetermineForwardDeclarations(set<string>* fwd_decls) const;\n\n private:\n  scoped_ptr<FieldGenerator> value_field_generator_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapFieldGenerator);\n};\n\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MAP_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_message.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <algorithm>\n#include <iostream>\n#include <sstream>\n\n#include <google/protobuf/stubs/hash.h>\n#include <google/protobuf/compiler/objectivec/objectivec_message.h>\n#include <google/protobuf/compiler/objectivec/objectivec_enum.h>\n#include <google/protobuf/compiler/objectivec/objectivec_extension.h>\n#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>\n#include <google/protobuf/stubs/stl_util.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n#include <google/protobuf/descriptor.pb.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace objectivec {\n\nusing internal::WireFormat;\nusing internal::WireFormatLite;\n\nnamespace {\nstruct FieldOrderingByNumber {\n  inline bool operator()(const FieldDescriptor* a,\n                         const FieldDescriptor* b) const {\n    return a->number() < b->number();\n  }\n};\n\nint OrderGroupForFieldDescriptor(const FieldDescriptor* descriptor) {\n  // The first item in the object structure is our uint32[] for has bits.\n  // We then want to order things to make the instances as small as\n  // possible. So we follow the has bits with:\n  //   1. Anything always 4 bytes - float, *32, enums\n  //   2. Anything that is always a pointer (they will be 8 bytes on 64 bit\n  //      builds and 4 bytes on 32bit builds.\n  //   3. Anything always 8 bytes - double, *64\n  //\n  // NOTE: Bools aren't listed, they were stored in the has bits.\n  //\n  // Why? Using 64bit builds as an example, this means worse case, we have\n  // enough bools that we overflow 1 byte from 4 byte alignment, so 3 bytes\n  // are wasted before the 4 byte values. Then if we have an odd number of\n  // those 4 byte values, the 8 byte values will be pushed down by 32bits to\n  // keep them aligned. But the structure will end 8 byte aligned, so no\n  // waste on the end. If you did the reverse order, you could waste 4 bytes\n  // before the first 8 byte value (after the has array), then a single\n  // bool on the end would need 7 bytes of padding to make the overall\n  // structure 8 byte aligned; so 11 bytes, wasted total.\n\n  // Anything repeated is a GPB*Array/NSArray, so pointer.\n  if (descriptor->is_repeated()) {\n    return 3;\n  }\n\n  switch (descriptor->type()) {\n    // All always 8 bytes.\n    case FieldDescriptor::TYPE_DOUBLE:\n    case FieldDescriptor::TYPE_INT64:\n    case FieldDescriptor::TYPE_SINT64:\n    case FieldDescriptor::TYPE_UINT64:\n    case FieldDescriptor::TYPE_SFIXED64:\n    case FieldDescriptor::TYPE_FIXED64:\n      return 4;\n\n    // Pointers (string and bytes are NSString and NSData); 8 or 4 bytes\n    // depending on the build architecture.\n    case FieldDescriptor::TYPE_GROUP:\n    case FieldDescriptor::TYPE_MESSAGE:\n    case FieldDescriptor::TYPE_STRING:\n    case FieldDescriptor::TYPE_BYTES:\n      return 3;\n\n    // All always 4 bytes (enums are int32s).\n    case FieldDescriptor::TYPE_FLOAT:\n    case FieldDescriptor::TYPE_INT32:\n    case FieldDescriptor::TYPE_SINT32:\n    case FieldDescriptor::TYPE_UINT32:\n    case FieldDescriptor::TYPE_SFIXED32:\n    case FieldDescriptor::TYPE_FIXED32:\n    case FieldDescriptor::TYPE_ENUM:\n      return 2;\n\n    // 0 bytes. Stored in the has bits.\n    case FieldDescriptor::TYPE_BOOL:\n      return 99;  // End of the list (doesn't really matter).\n  }\n\n  // Some compilers report reaching end of function even though all cases of\n  // the enum are handed in the switch.\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return 0;\n}\n\nstruct FieldOrderingByStorageSize {\n  inline bool operator()(const FieldDescriptor* a,\n                         const FieldDescriptor* b) const {\n    // Order by grouping.\n    const int order_group_a = OrderGroupForFieldDescriptor(a);\n    const int order_group_b = OrderGroupForFieldDescriptor(b);\n    if (order_group_a != order_group_b) {\n      return order_group_a < order_group_b;\n    }\n    // Within the group, order by field number (provides stable ordering).\n    return a->number() < b->number();\n  }\n};\n\nstruct ExtensionRangeOrdering {\n  bool operator()(const Descriptor::ExtensionRange* a,\n                  const Descriptor::ExtensionRange* b) const {\n    return a->start < b->start;\n  }\n};\n\n// Sort the fields of the given Descriptor by number into a new[]'d array\n// and return it.\nconst FieldDescriptor** SortFieldsByNumber(const Descriptor* descriptor) {\n  const FieldDescriptor** fields =\n      new const FieldDescriptor* [descriptor->field_count()];\n  for (int i = 0; i < descriptor->field_count(); i++) {\n    fields[i] = descriptor->field(i);\n  }\n  sort(fields, fields + descriptor->field_count(), FieldOrderingByNumber());\n  return fields;\n}\n\n// Sort the fields of the given Descriptor by storage size into a new[]'d\n// array and return it.\nconst FieldDescriptor** SortFieldsByStorageSize(const Descriptor* descriptor) {\n  const FieldDescriptor** fields =\n      new const FieldDescriptor* [descriptor->field_count()];\n  for (int i = 0; i < descriptor->field_count(); i++) {\n    fields[i] = descriptor->field(i);\n  }\n  sort(fields, fields + descriptor->field_count(),\n       FieldOrderingByStorageSize());\n  return fields;\n}\n}  // namespace\n\nMessageGenerator::MessageGenerator(const string& root_classname,\n                                   const Descriptor* descriptor,\n                                   const Options& options)\n    : root_classname_(root_classname),\n      descriptor_(descriptor),\n      field_generators_(descriptor, options),\n      class_name_(ClassName(descriptor_)) {\n  for (int i = 0; i < descriptor_->extension_count(); i++) {\n    extension_generators_.push_back(\n        new ExtensionGenerator(class_name_, descriptor_->extension(i)));\n  }\n\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    OneofGenerator* generator = new OneofGenerator(descriptor_->oneof_decl(i));\n    oneof_generators_.push_back(generator);\n  }\n\n  for (int i = 0; i < descriptor_->enum_type_count(); i++) {\n    EnumGenerator* generator = new EnumGenerator(descriptor_->enum_type(i));\n    enum_generators_.push_back(generator);\n  }\n\n  for (int i = 0; i < descriptor_->nested_type_count(); i++) {\n    MessageGenerator* generator =\n        new MessageGenerator(root_classname_,\n                             descriptor_->nested_type(i),\n                             options);\n    nested_message_generators_.push_back(generator);\n  }\n}\n\nMessageGenerator::~MessageGenerator() {\n  STLDeleteContainerPointers(extension_generators_.begin(),\n                             extension_generators_.end());\n  STLDeleteContainerPointers(enum_generators_.begin(), enum_generators_.end());\n  STLDeleteContainerPointers(nested_message_generators_.begin(),\n                             nested_message_generators_.end());\n  STLDeleteContainerPointers(oneof_generators_.begin(),\n                             oneof_generators_.end());\n}\n\nvoid MessageGenerator::GenerateStaticVariablesInitialization(\n    io::Printer* printer) {\n  for (vector<ExtensionGenerator*>::iterator iter =\n           extension_generators_.begin();\n       iter != extension_generators_.end(); ++iter) {\n    (*iter)->GenerateStaticVariablesInitialization(printer);\n  }\n\n  for (vector<MessageGenerator*>::iterator iter =\n           nested_message_generators_.begin();\n       iter != nested_message_generators_.end(); ++iter) {\n    (*iter)->GenerateStaticVariablesInitialization(printer);\n  }\n}\n\nvoid MessageGenerator::DetermineForwardDeclarations(set<string>* fwd_decls) {\n  if (!IsMapEntryMessage(descriptor_)) {\n    for (int i = 0; i < descriptor_->field_count(); i++) {\n      const FieldDescriptor* fieldDescriptor = descriptor_->field(i);\n      field_generators_.get(fieldDescriptor)\n          .DetermineForwardDeclarations(fwd_decls);\n    }\n  }\n\n  for (vector<MessageGenerator*>::iterator iter =\n           nested_message_generators_.begin();\n       iter != nested_message_generators_.end(); ++iter) {\n    (*iter)->DetermineForwardDeclarations(fwd_decls);\n  }\n}\n\nbool MessageGenerator::IncludesOneOfDefinition() const {\n  if (!oneof_generators_.empty()) {\n    return true;\n  }\n\n  for (vector<MessageGenerator*>::const_iterator iter =\n           nested_message_generators_.begin();\n       iter != nested_message_generators_.end(); ++iter) {\n    if ((*iter)->IncludesOneOfDefinition()) {\n      return true;\n    }\n  }\n\n  return false;\n}\n\nvoid MessageGenerator::GenerateEnumHeader(io::Printer* printer) {\n  for (vector<EnumGenerator*>::iterator iter = enum_generators_.begin();\n       iter != enum_generators_.end(); ++iter) {\n    (*iter)->GenerateHeader(printer);\n  }\n\n  for (vector<MessageGenerator*>::iterator iter =\n           nested_message_generators_.begin();\n       iter != nested_message_generators_.end(); ++iter) {\n    (*iter)->GenerateEnumHeader(printer);\n  }\n}\n\nvoid MessageGenerator::GenerateExtensionRegistrationSource(\n    io::Printer* printer) {\n  for (vector<ExtensionGenerator*>::iterator iter =\n           extension_generators_.begin();\n       iter != extension_generators_.end(); ++iter) {\n    (*iter)->GenerateRegistrationSource(printer);\n  }\n\n  for (vector<MessageGenerator*>::iterator iter =\n           nested_message_generators_.begin();\n       iter != nested_message_generators_.end(); ++iter) {\n    (*iter)->GenerateExtensionRegistrationSource(printer);\n  }\n}\n\nvoid MessageGenerator::GenerateMessageHeader(io::Printer* printer) {\n  // This a a map entry message, just recurse and do nothing directly.\n  if (IsMapEntryMessage(descriptor_)) {\n    for (vector<MessageGenerator*>::iterator iter =\n             nested_message_generators_.begin();\n         iter != nested_message_generators_.end(); ++iter) {\n      (*iter)->GenerateMessageHeader(printer);\n    }\n    return;\n  }\n\n  printer->Print(\n      \"#pragma mark - $classname$\\n\"\n      \"\\n\",\n      \"classname\", class_name_);\n\n  if (descriptor_->field_count()) {\n    scoped_array<const FieldDescriptor*> sorted_fields(\n        SortFieldsByNumber(descriptor_));\n\n    printer->Print(\"typedef GPB_ENUM($classname$_FieldNumber) {\\n\",\n                   \"classname\", class_name_);\n    printer->Indent();\n\n    for (int i = 0; i < descriptor_->field_count(); i++) {\n      field_generators_.get(sorted_fields[i])\n          .GenerateFieldNumberConstant(printer);\n    }\n\n    printer->Outdent();\n    printer->Print(\"};\\n\\n\");\n  }\n\n  for (vector<OneofGenerator*>::iterator iter = oneof_generators_.begin();\n       iter != oneof_generators_.end(); ++iter) {\n    (*iter)->GenerateCaseEnum(printer);\n  }\n\n  string message_comments;\n  SourceLocation location;\n  if (descriptor_->GetSourceLocation(&location)) {\n    message_comments = BuildCommentsString(location);\n  } else {\n    message_comments = \"\";\n  }\n\n  printer->Print(\n      \"$comments$$deprecated_attribute$@interface $classname$ : GPBMessage\\n\\n\",\n      \"classname\", class_name_,\n      \"deprecated_attribute\", GetOptionalDeprecatedAttribute(descriptor_, false, true),\n      \"comments\", message_comments);\n\n  vector<char> seen_oneofs(descriptor_->oneof_decl_count(), 0);\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n    if (field->containing_oneof() != NULL) {\n      const int oneof_index = field->containing_oneof()->index();\n      if (!seen_oneofs[oneof_index]) {\n        seen_oneofs[oneof_index] = 1;\n        oneof_generators_[oneof_index]->GeneratePublicCasePropertyDeclaration(\n            printer);\n      }\n    }\n    field_generators_.get(field).GeneratePropertyDeclaration(printer);\n  }\n\n  printer->Print(\"@end\\n\\n\");\n\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    field_generators_.get(descriptor_->field(i))\n        .GenerateCFunctionDeclarations(printer);\n  }\n\n  if (!oneof_generators_.empty()) {\n    for (vector<OneofGenerator*>::iterator iter = oneof_generators_.begin();\n         iter != oneof_generators_.end(); ++iter) {\n      (*iter)->GenerateClearFunctionDeclaration(printer);\n    }\n    printer->Print(\"\\n\");\n  }\n\n  if (descriptor_->extension_count() > 0) {\n    printer->Print(\"@interface $classname$ (DynamicMethods)\\n\\n\",\n                   \"classname\", class_name_);\n    for (vector<ExtensionGenerator*>::iterator iter =\n             extension_generators_.begin();\n         iter != extension_generators_.end(); ++iter) {\n      (*iter)->GenerateMembersHeader(printer);\n    }\n    printer->Print(\"@end\\n\\n\");\n  }\n\n  for (vector<MessageGenerator*>::iterator iter =\n           nested_message_generators_.begin();\n       iter != nested_message_generators_.end(); ++iter) {\n    (*iter)->GenerateMessageHeader(printer);\n  }\n}\n\nvoid MessageGenerator::GenerateSource(io::Printer* printer) {\n  if (!IsMapEntryMessage(descriptor_)) {\n    printer->Print(\n        \"#pragma mark - $classname$\\n\"\n        \"\\n\",\n        \"classname\", class_name_);\n\n    printer->Print(\"@implementation $classname$\\n\\n\",\n                   \"classname\", class_name_);\n\n    for (vector<OneofGenerator*>::iterator iter = oneof_generators_.begin();\n         iter != oneof_generators_.end(); ++iter) {\n      (*iter)->GeneratePropertyImplementation(printer);\n    }\n\n    for (int i = 0; i < descriptor_->field_count(); i++) {\n      field_generators_.get(descriptor_->field(i))\n          .GeneratePropertyImplementation(printer);\n    }\n\n    scoped_array<const FieldDescriptor*> sorted_fields(\n        SortFieldsByNumber(descriptor_));\n    scoped_array<const FieldDescriptor*> size_order_fields(\n        SortFieldsByStorageSize(descriptor_));\n\n    vector<const Descriptor::ExtensionRange*> sorted_extensions;\n    for (int i = 0; i < descriptor_->extension_range_count(); ++i) {\n      sorted_extensions.push_back(descriptor_->extension_range(i));\n    }\n\n    sort(sorted_extensions.begin(), sorted_extensions.end(),\n         ExtensionRangeOrdering());\n\n    // Assign has bits:\n    // 1. FieldGeneratorMap::CalculateHasBits() loops through the fields seeing\n    //    who needs has bits and assigning them.\n    // 2. FieldGenerator::SetOneofIndexBase() overrides has_bit with a negative\n    //    index that groups all the elements in the oneof.\n    size_t num_has_bits = field_generators_.CalculateHasBits();\n    size_t sizeof_has_storage = (num_has_bits + 31) / 32;\n    if (sizeof_has_storage == 0) {\n      // In the case where no field needs has bits, don't let the _has_storage_\n      // end up as zero length (zero length arrays are sort of a grey area\n      // since it has to be at the start of the struct). This also ensures a\n      // field with only oneofs keeps the required negative indices they need.\n      sizeof_has_storage = 1;\n    }\n    // Tell all the fields the oneof base.\n    for (vector<OneofGenerator*>::iterator iter = oneof_generators_.begin();\n         iter != oneof_generators_.end(); ++iter) {\n      (*iter)->SetOneofIndexBase(sizeof_has_storage);\n    }\n    field_generators_.SetOneofIndexBase(sizeof_has_storage);\n    // sizeof_has_storage needs enough bits for the single fields that aren't in\n    // any oneof, and then one int32 for each oneof (to store the field number).\n    sizeof_has_storage += descriptor_->oneof_decl_count();\n\n    printer->Print(\n        \"\\n\"\n        \"typedef struct $classname$__storage_ {\\n\"\n        \"  uint32_t _has_storage_[$sizeof_has_storage$];\\n\",\n        \"classname\", class_name_,\n        \"sizeof_has_storage\", SimpleItoa(sizeof_has_storage));\n    printer->Indent();\n\n    for (int i = 0; i < descriptor_->field_count(); i++) {\n      field_generators_.get(size_order_fields[i])\n          .GenerateFieldStorageDeclaration(printer);\n    }\n    printer->Outdent();\n\n    printer->Print(\"} $classname$__storage_;\\n\\n\", \"classname\", class_name_);\n\n\n    printer->Print(\n        \"// This method is threadsafe because it is initially called\\n\"\n        \"// in +initialize for each subclass.\\n\"\n        \"+ (GPBDescriptor *)descriptor {\\n\"\n        \"  static GPBDescriptor *descriptor = nil;\\n\"\n        \"  if (!descriptor) {\\n\");\n\n    TextFormatDecodeData text_format_decode_data;\n    bool has_fields = descriptor_->field_count() > 0;\n    bool need_defaults = field_generators_.DoesAnyFieldHaveNonZeroDefault();\n    string field_description_type;\n    if (need_defaults) {\n      field_description_type = \"GPBMessageFieldDescriptionWithDefault\";\n    } else {\n      field_description_type = \"GPBMessageFieldDescription\";\n    }\n    if (has_fields) {\n      printer->Print(\n          \"    static $field_description_type$ fields[] = {\\n\",\n          \"field_description_type\", field_description_type);\n      printer->Indent();\n      printer->Indent();\n      printer->Indent();\n      for (int i = 0; i < descriptor_->field_count(); ++i) {\n        const FieldGenerator& field_generator =\n            field_generators_.get(sorted_fields[i]);\n        field_generator.GenerateFieldDescription(printer, need_defaults);\n        if (field_generator.needs_textformat_name_support()) {\n          text_format_decode_data.AddString(sorted_fields[i]->number(),\n                                            field_generator.generated_objc_name(),\n                                            field_generator.raw_field_name());\n        }\n      }\n      printer->Outdent();\n      printer->Outdent();\n      printer->Outdent();\n      printer->Print(\n          \"    };\\n\");\n    }\n\n    map<string, string> vars;\n    vars[\"classname\"] = class_name_;\n    vars[\"rootclassname\"] = root_classname_;\n    vars[\"fields\"] = has_fields ? \"fields\" : \"NULL\";\n    if (has_fields) {\n      vars[\"fields_count\"] =\n          \"(uint32_t)(sizeof(fields) / sizeof(\" + field_description_type + \"))\";\n    } else {\n      vars[\"fields_count\"] = \"0\";\n    }\n\n    std::vector<string> init_flags;\n    if (need_defaults) {\n      init_flags.push_back(\"GPBDescriptorInitializationFlag_FieldsWithDefault\");\n    }\n    if (descriptor_->options().message_set_wire_format()) {\n      init_flags.push_back(\"GPBDescriptorInitializationFlag_WireFormat\");\n    }\n    vars[\"init_flags\"] = BuildFlagsString(init_flags);\n\n    printer->Print(\n        vars,\n        \"    GPBDescriptor *localDescriptor =\\n\"\n        \"        [GPBDescriptor allocDescriptorForClass:[$classname$ class]\\n\"\n        \"                                     rootClass:[$rootclassname$ class]\\n\"\n        \"                                          file:$rootclassname$_FileDescriptor()\\n\"\n        \"                                        fields:$fields$\\n\"\n        \"                                    fieldCount:$fields_count$\\n\"\n        \"                                   storageSize:sizeof($classname$__storage_)\\n\"\n        \"                                         flags:$init_flags$];\\n\");\n    if (oneof_generators_.size() != 0) {\n      printer->Print(\n          \"    static const char *oneofs[] = {\\n\");\n      for (vector<OneofGenerator*>::iterator iter = oneof_generators_.begin();\n           iter != oneof_generators_.end(); ++iter) {\n        printer->Print(\n            \"      \\\"$name$\\\",\\n\",\n            \"name\", (*iter)->DescriptorName());\n      }\n      printer->Print(\n          \"    };\\n\"\n          \"    [localDescriptor setupOneofs:oneofs\\n\"\n          \"                           count:(uint32_t)(sizeof(oneofs) / sizeof(char*))\\n\"\n          \"                   firstHasIndex:$first_has_index$];\\n\",\n          \"first_has_index\", oneof_generators_[0]->HasIndexAsString());\n    }\n    if (text_format_decode_data.num_entries() != 0) {\n      const string text_format_data_str(text_format_decode_data.Data());\n      printer->Print(\n          \"#if !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS\\n\"\n          \"    static const char *extraTextFormatInfo =\");\n      static const int kBytesPerLine = 40;  // allow for escaping\n      for (int i = 0; i < text_format_data_str.size(); i += kBytesPerLine) {\n        printer->Print(\n            \"\\n        \\\"$data$\\\"\",\n            \"data\", EscapeTrigraphs(\n                CEscape(text_format_data_str.substr(i, kBytesPerLine))));\n      }\n      printer->Print(\n          \";\\n\"\n          \"    [localDescriptor setupExtraTextInfo:extraTextFormatInfo];\\n\"\n          \"#endif  // !GPBOBJC_SKIP_MESSAGE_TEXTFORMAT_EXTRAS\\n\");\n    }\n    if (sorted_extensions.size() != 0) {\n      printer->Print(\n          \"    static const GPBExtensionRange ranges[] = {\\n\");\n      for (int i = 0; i < sorted_extensions.size(); i++) {\n        printer->Print(\"      { .start = $start$, .end = $end$ },\\n\",\n                       \"start\", SimpleItoa(sorted_extensions[i]->start),\n                       \"end\", SimpleItoa(sorted_extensions[i]->end));\n      }\n      printer->Print(\n          \"    };\\n\"\n          \"    [localDescriptor setupExtensionRanges:ranges\\n\"\n          \"                                    count:(uint32_t)(sizeof(ranges) / sizeof(GPBExtensionRange))];\\n\");\n    }\n    printer->Print(\n        \"    NSAssert(descriptor == nil, @\\\"Startup recursed!\\\");\\n\"\n        \"    descriptor = localDescriptor;\\n\"\n        \"  }\\n\"\n        \"  return descriptor;\\n\"\n        \"}\\n\\n\"\n        \"@end\\n\\n\");\n\n    for (int i = 0; i < descriptor_->field_count(); i++) {\n      field_generators_.get(descriptor_->field(i))\n          .GenerateCFunctionImplementations(printer);\n    }\n\n    for (vector<OneofGenerator*>::iterator iter = oneof_generators_.begin();\n         iter != oneof_generators_.end(); ++iter) {\n      (*iter)->GenerateClearFunctionImplementation(printer);\n    }\n  }\n\n  for (vector<EnumGenerator*>::iterator iter = enum_generators_.begin();\n       iter != enum_generators_.end(); ++iter) {\n    (*iter)->GenerateSource(printer);\n  }\n\n  for (vector<MessageGenerator*>::iterator iter =\n           nested_message_generators_.begin();\n       iter != nested_message_generators_.end(); ++iter) {\n    (*iter)->GenerateSource(printer);\n  }\n}\n\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_message.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MESSAGE_H__\n#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MESSAGE_H__\n\n#include <string>\n#include <set>\n#include <vector>\n#include <google/protobuf/compiler/objectivec/objectivec_field.h>\n#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>\n#include <google/protobuf/compiler/objectivec/objectivec_oneof.h>\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\n\nnamespace io {\nclass Printer;  // printer.h\n}  // namespace io\n\nnamespace compiler {\nnamespace objectivec {\n\nclass ExtensionGenerator;\nclass EnumGenerator;\n\nclass MessageGenerator {\n public:\n  MessageGenerator(const string& root_classname,\n                   const Descriptor* descriptor,\n                   const Options& options);\n  ~MessageGenerator();\n\n  void GenerateStaticVariablesInitialization(io::Printer* printer);\n  void GenerateEnumHeader(io::Printer* printer);\n  void GenerateMessageHeader(io::Printer* printer);\n  void GenerateSource(io::Printer* printer);\n  void GenerateExtensionRegistrationSource(io::Printer* printer);\n  void DetermineForwardDeclarations(set<string>* fwd_decls);\n\n  // Checks if the message or a nested message includes a oneof definition.\n  bool IncludesOneOfDefinition() const;\n\n private:\n  void GenerateParseFromMethodsHeader(io::Printer* printer);\n\n  void GenerateSerializeOneFieldSource(io::Printer* printer,\n                                       const FieldDescriptor* field);\n  void GenerateSerializeOneExtensionRangeSource(\n      io::Printer* printer, const Descriptor::ExtensionRange* range);\n\n  void GenerateMessageDescriptionSource(io::Printer* printer);\n  void GenerateDescriptionOneFieldSource(io::Printer* printer,\n                                         const FieldDescriptor* field);\n\n  const string root_classname_;\n  const Descriptor* descriptor_;\n  FieldGeneratorMap field_generators_;\n  const string class_name_;\n  vector<ExtensionGenerator*> extension_generators_;\n  vector<EnumGenerator*> enum_generators_;\n  vector<MessageGenerator*> nested_message_generators_;\n  vector<OneofGenerator*> oneof_generators_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageGenerator);\n};\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MESSAGE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/compiler/objectivec/objectivec_message_field.h>\n#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace objectivec {\n\nnamespace {\n\nvoid SetMessageVariables(const FieldDescriptor* descriptor,\n                         map<string, string>* variables) {\n  const string& message_type = ClassName(descriptor->message_type());\n  (*variables)[\"type\"] = message_type;\n  (*variables)[\"containing_class\"] = ClassName(descriptor->containing_type());\n  (*variables)[\"storage_type\"] = message_type;\n  (*variables)[\"group_or_message\"] =\n      (descriptor->type() == FieldDescriptor::TYPE_GROUP) ? \"Group\" : \"Message\";\n\n  (*variables)[\"dataTypeSpecific_value\"] = \"GPBStringifySymbol(\" + message_type + \")\";\n}\n\n}  // namespace\n\nMessageFieldGenerator::MessageFieldGenerator(const FieldDescriptor* descriptor,\n                                             const Options& options)\n    : ObjCObjFieldGenerator(descriptor, options) {\n  SetMessageVariables(descriptor, &variables_);\n}\n\nMessageFieldGenerator::~MessageFieldGenerator() {}\n\nvoid MessageFieldGenerator::DetermineForwardDeclarations(\n    set<string>* fwd_decls) const {\n  ObjCObjFieldGenerator::DetermineForwardDeclarations(fwd_decls);\n  // Class name is already in \"storage_type\".\n  fwd_decls->insert(\"@class \" + variable(\"storage_type\"));\n}\n\nbool MessageFieldGenerator::WantsHasProperty(void) const {\n  if (descriptor_->containing_oneof() != NULL) {\n    // If in a oneof, it uses the oneofcase instead of a has bit.\n    return false;\n  }\n  // In both proto2 & proto3, message fields have a has* property to tell\n  // when it is a non default value.\n  return true;\n}\n\nRepeatedMessageFieldGenerator::RepeatedMessageFieldGenerator(\n    const FieldDescriptor* descriptor, const Options& options)\n    : RepeatedFieldGenerator(descriptor, options) {\n  SetMessageVariables(descriptor, &variables_);\n  variables_[\"array_storage_type\"] = \"NSMutableArray\";\n  variables_[\"array_property_type\"] =\n      \"NSMutableArray<\" + variables_[\"storage_type\"] + \"*>\";\n}\n\nRepeatedMessageFieldGenerator::~RepeatedMessageFieldGenerator() {}\n\nvoid RepeatedMessageFieldGenerator::DetermineForwardDeclarations(\n    set<string>* fwd_decls) const {\n  RepeatedFieldGenerator::DetermineForwardDeclarations(fwd_decls);\n  // Class name is already in \"storage_type\".\n  fwd_decls->insert(\"@class \" + variable(\"storage_type\"));\n}\n\n\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_message_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MESSAGE_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MESSAGE_FIELD_H__\n\n#include <map>\n#include <string>\n#include <google/protobuf/compiler/objectivec/objectivec_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace objectivec {\n\nclass MessageFieldGenerator : public ObjCObjFieldGenerator {\n  friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field,\n                                              const Options& options);\n\n protected:\n  MessageFieldGenerator(const FieldDescriptor* descriptor,\n                        const Options& options);\n  virtual ~MessageFieldGenerator();\n  virtual bool WantsHasProperty(void) const;\n\n public:\n  virtual void DetermineForwardDeclarations(set<string>* fwd_decls) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFieldGenerator);\n};\n\nclass RepeatedMessageFieldGenerator : public RepeatedFieldGenerator {\n  friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field,\n                                              const Options& options);\n\n protected:\n  RepeatedMessageFieldGenerator(const FieldDescriptor* descriptor,\n                                const Options& options);\n  virtual ~RepeatedMessageFieldGenerator();\n\n public:\n  virtual void DetermineForwardDeclarations(set<string>* fwd_decls) const;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedMessageFieldGenerator);\n};\n\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_MESSAGE_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/compiler/objectivec/objectivec_oneof.h>\n#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace objectivec {\n\nOneofGenerator::OneofGenerator(const OneofDescriptor* descriptor)\n    : descriptor_(descriptor) {\n  variables_[\"enum_name\"] = OneofEnumName(descriptor_);\n  variables_[\"name\"] = OneofName(descriptor_);\n  variables_[\"capitalized_name\"] = OneofNameCapitalized(descriptor_);\n  variables_[\"raw_index\"] = SimpleItoa(descriptor_->index());\n  const Descriptor* msg_descriptor = descriptor_->containing_type();\n  variables_[\"owning_message_class\"] = ClassName(msg_descriptor);\n\n  string comments;\n  SourceLocation location;\n  if (descriptor_->GetSourceLocation(&location)) {\n    comments = BuildCommentsString(location);\n  } else {\n    comments = \"\";\n  }\n  variables_[\"comments\"] = comments;\n}\n\nOneofGenerator::~OneofGenerator() {}\n\nvoid OneofGenerator::SetOneofIndexBase(int index_base) {\n  int index = descriptor_->index() + index_base;\n  // Flip the sign to mark it as a oneof.\n  variables_[\"index\"] = SimpleItoa(-index);\n}\n\nvoid OneofGenerator::GenerateCaseEnum(io::Printer* printer) {\n  printer->Print(\n      variables_,\n      \"typedef GPB_ENUM($enum_name$) {\\n\");\n  printer->Indent();\n  printer->Print(\n      variables_,\n      \"$enum_name$_GPBUnsetOneOfCase = 0,\\n\");\n  string enum_name = variables_[\"enum_name\"];\n  for (int j = 0; j < descriptor_->field_count(); j++) {\n    const FieldDescriptor* field = descriptor_->field(j);\n    string field_name = FieldNameCapitalized(field);\n    printer->Print(\n        \"$enum_name$_$field_name$ = $field_number$,\\n\",\n        \"enum_name\", enum_name,\n        \"field_name\", field_name,\n        \"field_number\", SimpleItoa(field->number()));\n  }\n  printer->Outdent();\n  printer->Print(\n      \"};\\n\"\n      \"\\n\");\n}\n\nvoid OneofGenerator::GeneratePublicCasePropertyDeclaration(\n    io::Printer* printer) {\n  printer->Print(\n      variables_,\n      \"$comments$\"\n      \"@property(nonatomic, readonly) $enum_name$ $name$OneOfCase;\\n\"\n      \"\\n\");\n}\n\nvoid OneofGenerator::GenerateClearFunctionDeclaration(io::Printer* printer) {\n  printer->Print(\n      variables_,\n      \"/// Clears whatever value was set for the oneof '$name$'.\\n\"\n      \"void $owning_message_class$_Clear$capitalized_name$OneOfCase($owning_message_class$ *message);\\n\");\n}\n\nvoid OneofGenerator::GeneratePropertyImplementation(io::Printer* printer) {\n  printer->Print(\n      variables_,\n      \"@dynamic $name$OneOfCase;\\n\");\n}\n\nvoid OneofGenerator::GenerateClearFunctionImplementation(io::Printer* printer) {\n  printer->Print(\n      variables_,\n      \"void $owning_message_class$_Clear$capitalized_name$OneOfCase($owning_message_class$ *message) {\\n\"\n      \"  GPBDescriptor *descriptor = [message descriptor];\\n\"\n      \"  GPBOneofDescriptor *oneof = [descriptor.oneofs objectAtIndex:$raw_index$];\\n\"\n      \"  GPBMaybeClearOneof(message, oneof, $index$, 0);\\n\"\n      \"}\\n\");\n}\n\nstring OneofGenerator::DescriptorName(void) const {\n  return variables_.find(\"name\")->second;\n}\n\nstring OneofGenerator::HasIndexAsString(void) const {\n  return variables_.find(\"index\")->second;\n}\n\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_oneof.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_ONEOF_H__\n#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_ONEOF_H__\n\n#include <string>\n#include <set>\n#include <vector>\n#include <google/protobuf/descriptor.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\nclass Printer;  // printer.h\n}\n}\n\nnamespace protobuf {\nnamespace compiler {\nnamespace objectivec {\n\nclass OneofGenerator {\n public:\n  explicit OneofGenerator(const OneofDescriptor* descriptor);\n  ~OneofGenerator();\n\n  void SetOneofIndexBase(int index_base);\n\n  void GenerateCaseEnum(io::Printer* printer);\n\n  void GeneratePublicCasePropertyDeclaration(io::Printer* printer);\n  void GenerateClearFunctionDeclaration(io::Printer* printer);\n\n  void GeneratePropertyImplementation(io::Printer* printer);\n  void GenerateClearFunctionImplementation(io::Printer* printer);\n\n  string DescriptorName(void) const;\n  string HasIndexAsString(void) const;\n\n private:\n  const OneofDescriptor* descriptor_;\n  map<string, string> variables_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(OneofGenerator);\n};\n\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_ONEOF_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/compiler/objectivec/objectivec_primitive_field.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/compiler/objectivec/objectivec_helpers.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace objectivec {\n\nusing internal::WireFormat;\nusing internal::WireFormatLite;\n\nnamespace {\n\nconst char* PrimitiveTypeName(const FieldDescriptor* descriptor) {\n  ObjectiveCType type = GetObjectiveCType(descriptor);\n  switch (type) {\n    case OBJECTIVECTYPE_INT32:\n      return \"int32_t\";\n    case OBJECTIVECTYPE_UINT32:\n      return \"uint32_t\";\n    case OBJECTIVECTYPE_INT64:\n      return \"int64_t\";\n    case OBJECTIVECTYPE_UINT64:\n      return \"uint64_t\";\n    case OBJECTIVECTYPE_FLOAT:\n      return \"float\";\n    case OBJECTIVECTYPE_DOUBLE:\n      return \"double\";\n    case OBJECTIVECTYPE_BOOLEAN:\n      return \"BOOL\";\n    case OBJECTIVECTYPE_STRING:\n      return \"NSString\";\n    case OBJECTIVECTYPE_DATA:\n      return \"NSData\";\n    case OBJECTIVECTYPE_ENUM:\n      return \"int32_t\";\n    case OBJECTIVECTYPE_MESSAGE:\n      return NULL;  // Messages go through objectivec_message_field.cc|h.\n  }\n\n  // Some compilers report reaching end of function even though all cases of\n  // the enum are handed in the switch.\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return NULL;\n}\n\nconst char* PrimitiveArrayTypeName(const FieldDescriptor* descriptor) {\n  ObjectiveCType type = GetObjectiveCType(descriptor);\n  switch (type) {\n    case OBJECTIVECTYPE_INT32:\n      return \"Int32\";\n    case OBJECTIVECTYPE_UINT32:\n      return \"UInt32\";\n    case OBJECTIVECTYPE_INT64:\n      return \"Int64\";\n    case OBJECTIVECTYPE_UINT64:\n      return \"UInt64\";\n    case OBJECTIVECTYPE_FLOAT:\n      return \"Float\";\n    case OBJECTIVECTYPE_DOUBLE:\n      return \"Double\";\n    case OBJECTIVECTYPE_BOOLEAN:\n      return \"Bool\";\n    case OBJECTIVECTYPE_STRING:\n      return \"\";  // Want NSArray\n    case OBJECTIVECTYPE_DATA:\n      return \"\";  // Want NSArray\n    case OBJECTIVECTYPE_ENUM:\n      return \"Enum\";\n    case OBJECTIVECTYPE_MESSAGE:\n      // Want NSArray (but goes through objectivec_message_field.cc|h).\n      return \"\";\n  }\n\n  // Some compilers report reaching end of function even though all cases of\n  // the enum are handed in the switch.\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return NULL;\n}\n\nvoid SetPrimitiveVariables(const FieldDescriptor* descriptor,\n                           map<string, string>* variables) {\n  std::string primitive_name = PrimitiveTypeName(descriptor);\n  (*variables)[\"type\"] = primitive_name;\n  (*variables)[\"storage_type\"] = primitive_name;\n}\n\n}  // namespace\n\nPrimitiveFieldGenerator::PrimitiveFieldGenerator(\n    const FieldDescriptor* descriptor, const Options& options)\n    : SingleFieldGenerator(descriptor, options) {\n  SetPrimitiveVariables(descriptor, &variables_);\n}\n\nPrimitiveFieldGenerator::~PrimitiveFieldGenerator() {}\n\nvoid PrimitiveFieldGenerator::GenerateFieldStorageDeclaration(\n    io::Printer* printer) const {\n  if (GetObjectiveCType(descriptor_) == OBJECTIVECTYPE_BOOLEAN) {\n    // Nothing, BOOLs are stored in the has bits.\n  } else {\n    SingleFieldGenerator::GenerateFieldStorageDeclaration(printer);\n  }\n}\n\nint PrimitiveFieldGenerator::ExtraRuntimeHasBitsNeeded(void) const {\n  if (GetObjectiveCType(descriptor_) == OBJECTIVECTYPE_BOOLEAN) {\n    // Reserve a bit for the storage of the boolean.\n    return 1;\n  }\n  return 0;\n}\n\nvoid PrimitiveFieldGenerator::SetExtraRuntimeHasBitsBase(int has_base) {\n  if (GetObjectiveCType(descriptor_) == OBJECTIVECTYPE_BOOLEAN) {\n    // Set into the offset the has bit to use for the actual value.\n    variables_[\"storage_offset_value\"] = SimpleItoa(has_base);\n    variables_[\"storage_offset_comment\"] =\n        \"  // Stored in _has_storage_ to save space.\";\n  }\n}\n\nPrimitiveObjFieldGenerator::PrimitiveObjFieldGenerator(\n    const FieldDescriptor* descriptor, const Options& options)\n    : ObjCObjFieldGenerator(descriptor, options) {\n  SetPrimitiveVariables(descriptor, &variables_);\n  variables_[\"property_storage_attribute\"] = \"copy\";\n}\n\nPrimitiveObjFieldGenerator::~PrimitiveObjFieldGenerator() {}\n\nRepeatedPrimitiveFieldGenerator::RepeatedPrimitiveFieldGenerator(\n    const FieldDescriptor* descriptor, const Options& options)\n    : RepeatedFieldGenerator(descriptor, options) {\n  SetPrimitiveVariables(descriptor, &variables_);\n\n  string base_name = PrimitiveArrayTypeName(descriptor);\n  if (base_name.length()) {\n    variables_[\"array_storage_type\"] = \"GPB\" + base_name + \"Array\";\n  } else {\n    variables_[\"array_storage_type\"] = \"NSMutableArray\";\n    variables_[\"array_property_type\"] =\n        \"NSMutableArray<\" + variables_[\"storage_type\"] + \"*>\";\n  }\n}\n\nRepeatedPrimitiveFieldGenerator::~RepeatedPrimitiveFieldGenerator() {}\n\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_PRIMITIVE_FIELD_H__\n#define GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_PRIMITIVE_FIELD_H__\n\n#include <map>\n#include <string>\n#include <google/protobuf/compiler/objectivec/objectivec_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace objectivec {\n\nclass PrimitiveFieldGenerator : public SingleFieldGenerator {\n  friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field,\n                                              const Options& options);\n\n protected:\n  PrimitiveFieldGenerator(const FieldDescriptor* descriptor,\n                          const Options& options);\n  virtual ~PrimitiveFieldGenerator();\n\n  virtual void GenerateFieldStorageDeclaration(io::Printer* printer) const;\n\n  virtual int ExtraRuntimeHasBitsNeeded(void) const;\n  virtual void SetExtraRuntimeHasBitsBase(int index_base);\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveFieldGenerator);\n};\n\nclass PrimitiveObjFieldGenerator : public ObjCObjFieldGenerator {\n  friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field,\n                                              const Options& options);\n\n protected:\n  PrimitiveObjFieldGenerator(const FieldDescriptor* descriptor,\n                             const Options& options);\n  virtual ~PrimitiveObjFieldGenerator();\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(PrimitiveObjFieldGenerator);\n};\n\nclass RepeatedPrimitiveFieldGenerator : public RepeatedFieldGenerator {\n  friend FieldGenerator* FieldGenerator::Make(const FieldDescriptor* field,\n                                              const Options& options);\n\n protected:\n  RepeatedPrimitiveFieldGenerator(const FieldDescriptor* descriptor,\n                                  const Options& options);\n  virtual ~RepeatedPrimitiveFieldGenerator();\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPrimitiveFieldGenerator);\n};\n\n}  // namespace objectivec\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMPILER_OBJECTIVEC_PRIMITIVE_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/package_info.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This file exists solely to document the google::protobuf::compiler namespace.\n// It is not compiled into anything, but it may be read by an automated\n// documentation generator.\n\nnamespace google {\n\nnamespace protobuf {\n\n// Implementation of the Protocol Buffer compiler.\n//\n// This package contains code for parsing .proto files and generating code\n// based on them.  There are two reasons you might be interested in this\n// package:\n// - You want to parse .proto files at runtime.  In this case, you should\n//   look at importer.h.  Since this functionality is widely useful, it is\n//   included in the libprotobuf base library; you do not have to link against\n//   libprotoc.\n// - You want to write a custom protocol compiler which generates different\n//   kinds of code, e.g. code in a different language which is not supported\n//   by the official compiler.  For this purpose, command_line_interface.h\n//   provides you with a complete compiler front-end, so all you need to do\n//   is write a custom implementation of CodeGenerator and a trivial main()\n//   function.  You can even make your compiler support the official languages\n//   in addition to your own.  Since this functionality is only useful to those\n//   writing custom compilers, it is in a separate library called \"libprotoc\"\n//   which you will have to link against.\nnamespace compiler {}\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/parser.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Recursive descent FTW.\n\n#include <float.h>\n#include <google/protobuf/stubs/hash.h>\n#include <limits>\n\n\n#include <google/protobuf/compiler/parser.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/io/tokenizer.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/map_util.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\n\nusing internal::WireFormat;\n\nnamespace {\n\ntypedef hash_map<string, FieldDescriptorProto::Type> TypeNameMap;\n\nTypeNameMap MakeTypeNameTable() {\n  TypeNameMap result;\n\n  result[\"double\"  ] = FieldDescriptorProto::TYPE_DOUBLE;\n  result[\"float\"   ] = FieldDescriptorProto::TYPE_FLOAT;\n  result[\"uint64\"  ] = FieldDescriptorProto::TYPE_UINT64;\n  result[\"fixed64\" ] = FieldDescriptorProto::TYPE_FIXED64;\n  result[\"fixed32\" ] = FieldDescriptorProto::TYPE_FIXED32;\n  result[\"bool\"    ] = FieldDescriptorProto::TYPE_BOOL;\n  result[\"string\"  ] = FieldDescriptorProto::TYPE_STRING;\n  result[\"group\"   ] = FieldDescriptorProto::TYPE_GROUP;\n\n  result[\"bytes\"   ] = FieldDescriptorProto::TYPE_BYTES;\n  result[\"uint32\"  ] = FieldDescriptorProto::TYPE_UINT32;\n  result[\"sfixed32\"] = FieldDescriptorProto::TYPE_SFIXED32;\n  result[\"sfixed64\"] = FieldDescriptorProto::TYPE_SFIXED64;\n  result[\"int32\"   ] = FieldDescriptorProto::TYPE_INT32;\n  result[\"int64\"   ] = FieldDescriptorProto::TYPE_INT64;\n  result[\"sint32\"  ] = FieldDescriptorProto::TYPE_SINT32;\n  result[\"sint64\"  ] = FieldDescriptorProto::TYPE_SINT64;\n\n  return result;\n}\n\nconst TypeNameMap kTypeNames = MakeTypeNameTable();\n\n// Camel-case the field name and append \"Entry\" for generated map entry name.\n// e.g. map<KeyType, ValueType> foo_map => FooMapEntry\nstring MapEntryName(const string& field_name) {\n  string result;\n  static const char kSuffix[] = \"Entry\";\n  result.reserve(field_name.size() + sizeof(kSuffix));\n  bool cap_next = true;\n  for (int i = 0; i < field_name.size(); ++i) {\n    if (field_name[i] == '_') {\n      cap_next = true;\n    } else if (cap_next) {\n      // Note: Do not use ctype.h due to locales.\n      if ('a' <= field_name[i] && field_name[i] <= 'z') {\n        result.push_back(field_name[i] - 'a' + 'A');\n      } else {\n        result.push_back(field_name[i]);\n      }\n      cap_next = false;\n    } else {\n      result.push_back(field_name[i]);\n    }\n  }\n  result.append(kSuffix);\n  return result;\n}\n\n}  // anonymous namespace\n\n// Makes code slightly more readable.  The meaning of \"DO(foo)\" is\n// \"Execute foo and fail if it fails.\", where failure is indicated by\n// returning false.\n#define DO(STATEMENT) if (STATEMENT) {} else return false\n\n// ===================================================================\n\nParser::Parser()\n  : input_(NULL),\n    error_collector_(NULL),\n    source_location_table_(NULL),\n    had_errors_(false),\n    require_syntax_identifier_(false),\n    stop_after_syntax_identifier_(false) {\n}\n\nParser::~Parser() {\n}\n\n// ===================================================================\n\ninline bool Parser::LookingAt(const char* text) {\n  return input_->current().text == text;\n}\n\ninline bool Parser::LookingAtType(io::Tokenizer::TokenType token_type) {\n  return input_->current().type == token_type;\n}\n\ninline bool Parser::AtEnd() {\n  return LookingAtType(io::Tokenizer::TYPE_END);\n}\n\nbool Parser::TryConsume(const char* text) {\n  if (LookingAt(text)) {\n    input_->Next();\n    return true;\n  } else {\n    return false;\n  }\n}\n\nbool Parser::Consume(const char* text, const char* error) {\n  if (TryConsume(text)) {\n    return true;\n  } else {\n    AddError(error);\n    return false;\n  }\n}\n\nbool Parser::Consume(const char* text) {\n  if (TryConsume(text)) {\n    return true;\n  } else {\n    AddError(\"Expected \\\"\" + string(text) + \"\\\".\");\n    return false;\n  }\n}\n\nbool Parser::ConsumeIdentifier(string* output, const char* error) {\n  if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) {\n    *output = input_->current().text;\n    input_->Next();\n    return true;\n  } else {\n    AddError(error);\n    return false;\n  }\n}\n\nbool Parser::ConsumeInteger(int* output, const char* error) {\n  if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) {\n    uint64 value = 0;\n    if (!io::Tokenizer::ParseInteger(input_->current().text,\n                                     kint32max, &value)) {\n      AddError(\"Integer out of range.\");\n      // We still return true because we did, in fact, parse an integer.\n    }\n    *output = value;\n    input_->Next();\n    return true;\n  } else {\n    AddError(error);\n    return false;\n  }\n}\n\nbool Parser::ConsumeSignedInteger(int* output, const char* error) {\n  bool is_negative = false;\n  uint64 max_value = kint32max;\n  if (TryConsume(\"-\")) {\n    is_negative = true;\n    max_value += 1;\n  }\n  uint64 value = 0;\n  DO(ConsumeInteger64(max_value, &value, error));\n  if (is_negative) value *= -1;\n  *output = value;\n  return true;\n}\n\nbool Parser::ConsumeInteger64(uint64 max_value, uint64* output,\n                              const char* error) {\n  if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) {\n    if (!io::Tokenizer::ParseInteger(input_->current().text, max_value,\n                                     output)) {\n      AddError(\"Integer out of range.\");\n      // We still return true because we did, in fact, parse an integer.\n      *output = 0;\n    }\n    input_->Next();\n    return true;\n  } else {\n    AddError(error);\n    return false;\n  }\n}\n\nbool Parser::ConsumeNumber(double* output, const char* error) {\n  if (LookingAtType(io::Tokenizer::TYPE_FLOAT)) {\n    *output = io::Tokenizer::ParseFloat(input_->current().text);\n    input_->Next();\n    return true;\n  } else if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) {\n    // Also accept integers.\n    uint64 value = 0;\n    if (!io::Tokenizer::ParseInteger(input_->current().text,\n                                     kuint64max, &value)) {\n      AddError(\"Integer out of range.\");\n      // We still return true because we did, in fact, parse a number.\n    }\n    *output = value;\n    input_->Next();\n    return true;\n  } else if (LookingAt(\"inf\")) {\n    *output = numeric_limits<double>::infinity();\n    input_->Next();\n    return true;\n  } else if (LookingAt(\"nan\")) {\n    *output = numeric_limits<double>::quiet_NaN();\n    input_->Next();\n    return true;\n  } else {\n    AddError(error);\n    return false;\n  }\n}\n\nbool Parser::ConsumeString(string* output, const char* error) {\n  if (LookingAtType(io::Tokenizer::TYPE_STRING)) {\n    io::Tokenizer::ParseString(input_->current().text, output);\n    input_->Next();\n    // Allow C++ like concatenation of adjacent string tokens.\n    while (LookingAtType(io::Tokenizer::TYPE_STRING)) {\n      io::Tokenizer::ParseStringAppend(input_->current().text, output);\n      input_->Next();\n    }\n    return true;\n  } else {\n    AddError(error);\n    return false;\n  }\n}\n\nbool Parser::TryConsumeEndOfDeclaration(\n    const char* text, const LocationRecorder* location) {\n  if (LookingAt(text)) {\n    string leading, trailing;\n    vector<string> detached;\n    input_->NextWithComments(&trailing, &detached, &leading);\n\n    // Save the leading comments for next time, and recall the leading comments\n    // from last time.\n    leading.swap(upcoming_doc_comments_);\n\n    if (location != NULL) {\n      upcoming_detached_comments_.swap(detached);\n      location->AttachComments(&leading, &trailing, &detached);\n    } else if (strcmp(text, \"}\") == 0) {\n      // If the current location is null and we are finishing the current scope,\n      // drop pending upcoming detached comments.\n      upcoming_detached_comments_.swap(detached);\n    } else {\n      // Otherwise, append the new detached comments to the existing upcoming\n      // detached comments.\n      upcoming_detached_comments_.insert(upcoming_detached_comments_.end(),\n                                         detached.begin(), detached.end());\n    }\n\n    return true;\n  } else {\n    return false;\n  }\n}\n\nbool Parser::ConsumeEndOfDeclaration(\n    const char* text, const LocationRecorder* location) {\n  if (TryConsumeEndOfDeclaration(text, location)) {\n    return true;\n  } else {\n    AddError(\"Expected \\\"\" + string(text) + \"\\\".\");\n    return false;\n  }\n}\n\n// -------------------------------------------------------------------\n\nvoid Parser::AddError(int line, int column, const string& error) {\n  if (error_collector_ != NULL) {\n    error_collector_->AddError(line, column, error);\n  }\n  had_errors_ = true;\n}\n\nvoid Parser::AddError(const string& error) {\n  AddError(input_->current().line, input_->current().column, error);\n}\n\n// -------------------------------------------------------------------\n\nParser::LocationRecorder::LocationRecorder(Parser* parser)\n  : parser_(parser),\n    location_(parser_->source_code_info_->add_location()) {\n  location_->add_span(parser_->input_->current().line);\n  location_->add_span(parser_->input_->current().column);\n}\n\nParser::LocationRecorder::LocationRecorder(const LocationRecorder& parent) {\n  Init(parent);\n}\n\nParser::LocationRecorder::LocationRecorder(const LocationRecorder& parent,\n                                           int path1) {\n  Init(parent);\n  AddPath(path1);\n}\n\nParser::LocationRecorder::LocationRecorder(const LocationRecorder& parent,\n                                           int path1, int path2) {\n  Init(parent);\n  AddPath(path1);\n  AddPath(path2);\n}\n\nvoid Parser::LocationRecorder::Init(const LocationRecorder& parent) {\n  parser_ = parent.parser_;\n  location_ = parser_->source_code_info_->add_location();\n  location_->mutable_path()->CopyFrom(parent.location_->path());\n\n  location_->add_span(parser_->input_->current().line);\n  location_->add_span(parser_->input_->current().column);\n}\n\nParser::LocationRecorder::~LocationRecorder() {\n  if (location_->span_size() <= 2) {\n    EndAt(parser_->input_->previous());\n  }\n}\n\nvoid Parser::LocationRecorder::AddPath(int path_component) {\n  location_->add_path(path_component);\n}\n\nvoid Parser::LocationRecorder::StartAt(const io::Tokenizer::Token& token) {\n  location_->set_span(0, token.line);\n  location_->set_span(1, token.column);\n}\n\nvoid Parser::LocationRecorder::StartAt(const LocationRecorder& other) {\n  location_->set_span(0, other.location_->span(0));\n  location_->set_span(1, other.location_->span(1));\n}\n\nvoid Parser::LocationRecorder::EndAt(const io::Tokenizer::Token& token) {\n  if (token.line != location_->span(0)) {\n    location_->add_span(token.line);\n  }\n  location_->add_span(token.end_column);\n}\n\nvoid Parser::LocationRecorder::RecordLegacyLocation(const Message* descriptor,\n    DescriptorPool::ErrorCollector::ErrorLocation location) {\n  if (parser_->source_location_table_ != NULL) {\n    parser_->source_location_table_->Add(\n        descriptor, location, location_->span(0), location_->span(1));\n  }\n}\n\nvoid Parser::LocationRecorder::AttachComments(\n    string* leading, string* trailing,\n    vector<string>* detached_comments) const {\n  GOOGLE_CHECK(!location_->has_leading_comments());\n  GOOGLE_CHECK(!location_->has_trailing_comments());\n\n  if (!leading->empty()) {\n    location_->mutable_leading_comments()->swap(*leading);\n  }\n  if (!trailing->empty()) {\n    location_->mutable_trailing_comments()->swap(*trailing);\n  }\n  for (int i = 0; i < detached_comments->size(); ++i) {\n    location_->add_leading_detached_comments()->swap(\n        (*detached_comments)[i]);\n  }\n  detached_comments->clear();\n}\n\n// -------------------------------------------------------------------\n\nvoid Parser::SkipStatement() {\n  while (true) {\n    if (AtEnd()) {\n      return;\n    } else if (LookingAtType(io::Tokenizer::TYPE_SYMBOL)) {\n      if (TryConsumeEndOfDeclaration(\";\", NULL)) {\n        return;\n      } else if (TryConsume(\"{\")) {\n        SkipRestOfBlock();\n        return;\n      } else if (LookingAt(\"}\")) {\n        return;\n      }\n    }\n    input_->Next();\n  }\n}\n\nvoid Parser::SkipRestOfBlock() {\n  while (true) {\n    if (AtEnd()) {\n      return;\n    } else if (LookingAtType(io::Tokenizer::TYPE_SYMBOL)) {\n      if (TryConsumeEndOfDeclaration(\"}\", NULL)) {\n        return;\n      } else if (TryConsume(\"{\")) {\n        SkipRestOfBlock();\n      }\n    }\n    input_->Next();\n  }\n}\n\n// ===================================================================\n\nbool Parser::ValidateEnum(const EnumDescriptorProto* proto) {\n  bool has_allow_alias = false;\n  bool allow_alias = false;\n\n  for (int i = 0; i < proto->options().uninterpreted_option_size(); i++) {\n    const UninterpretedOption option = proto->options().uninterpreted_option(i);\n    if (option.name_size() > 1) {\n      continue;\n    }\n    if (!option.name(0).is_extension() &&\n        option.name(0).name_part() == \"allow_alias\") {\n      has_allow_alias = true;\n      if (option.identifier_value() == \"true\") {\n        allow_alias = true;\n      }\n      break;\n    }\n  }\n\n  if (has_allow_alias && !allow_alias) {\n    string error =\n        \"\\\"\" + proto->name() +\n        \"\\\" declares 'option allow_alias = false;' which has no effect. \"\n        \"Please remove the declaration.\";\n    // This needlessly clutters declarations with nops.\n    AddError(error);\n    return false;\n  }\n\n  set<int> used_values;\n  bool has_duplicates = false;\n  for (int i = 0; i < proto->value_size(); ++i) {\n    const EnumValueDescriptorProto enum_value = proto->value(i);\n    if (used_values.find(enum_value.number()) != used_values.end()) {\n      has_duplicates = true;\n      break;\n    } else {\n      used_values.insert(enum_value.number());\n    }\n  }\n  if (allow_alias && !has_duplicates) {\n    string error =\n        \"\\\"\" + proto->name() +\n        \"\\\" declares support for enum aliases but no enum values share field \"\n        \"numbers. Please remove the unnecessary 'option allow_alias = true;' \"\n        \"declaration.\";\n    // Generate an error if an enum declares support for duplicate enum values\n    // and does not use it protect future authors.\n    AddError(error);\n    return false;\n  }\n\n  return true;\n}\n\nbool Parser::Parse(io::Tokenizer* input, FileDescriptorProto* file) {\n  input_ = input;\n  had_errors_ = false;\n  syntax_identifier_.clear();\n\n  // Note that |file| could be NULL at this point if\n  // stop_after_syntax_identifier_ is true.  So, we conservatively allocate\n  // SourceCodeInfo on the stack, then swap it into the FileDescriptorProto\n  // later on.\n  SourceCodeInfo source_code_info;\n  source_code_info_ = &source_code_info;\n\n  vector<string> top_doc_comments;\n  if (LookingAtType(io::Tokenizer::TYPE_START)) {\n    // Advance to first token.\n    input_->NextWithComments(NULL, &upcoming_detached_comments_,\n                             &upcoming_doc_comments_);\n  }\n\n  {\n    LocationRecorder root_location(this);\n\n    if (require_syntax_identifier_ || LookingAt(\"syntax\")) {\n      if (!ParseSyntaxIdentifier(root_location)) {\n        // Don't attempt to parse the file if we didn't recognize the syntax\n        // identifier.\n        return false;\n      }\n      // Store the syntax into the file.\n      if (file != NULL) file->set_syntax(syntax_identifier_);\n    } else if (!stop_after_syntax_identifier_) {\n      GOOGLE_LOG(WARNING) << \"No syntax specified for the proto file: \"\n                   << file->name() << \". Please use 'syntax = \\\"proto2\\\";' \"\n                   << \"or 'syntax = \\\"proto3\\\";' to specify a syntax \"\n                   << \"version. (Defaulted to proto2 syntax.)\";\n      syntax_identifier_ = \"proto2\";\n    }\n\n    if (stop_after_syntax_identifier_) return !had_errors_;\n\n    // Repeatedly parse statements until we reach the end of the file.\n    while (!AtEnd()) {\n      if (!ParseTopLevelStatement(file, root_location)) {\n        // This statement failed to parse.  Skip it, but keep looping to parse\n        // other statements.\n        SkipStatement();\n\n        if (LookingAt(\"}\")) {\n          AddError(\"Unmatched \\\"}\\\".\");\n          input_->NextWithComments(NULL, &upcoming_detached_comments_,\n                                   &upcoming_doc_comments_);\n        }\n      }\n    }\n  }\n\n  input_ = NULL;\n  source_code_info_ = NULL;\n  source_code_info.Swap(file->mutable_source_code_info());\n  return !had_errors_;\n}\n\nbool Parser::ParseSyntaxIdentifier(const LocationRecorder& parent) {\n  LocationRecorder syntax_location(parent,\n                                   FileDescriptorProto::kSyntaxFieldNumber);\n  DO(Consume(\n      \"syntax\",\n      \"File must begin with a syntax statement, e.g. 'syntax = \\\"proto2\\\";'.\"));\n  DO(Consume(\"=\"));\n  io::Tokenizer::Token syntax_token = input_->current();\n  string syntax;\n  DO(ConsumeString(&syntax, \"Expected syntax identifier.\"));\n  DO(ConsumeEndOfDeclaration(\";\", &syntax_location));\n\n  syntax_identifier_ = syntax;\n\n  if (syntax != \"proto2\" && syntax != \"proto3\" &&\n      !stop_after_syntax_identifier_) {\n    AddError(syntax_token.line, syntax_token.column,\n      \"Unrecognized syntax identifier \\\"\" + syntax + \"\\\".  This parser \"\n      \"only recognizes \\\"proto2\\\" and \\\"proto3\\\".\");\n    return false;\n  }\n\n  return true;\n}\n\nbool Parser::ParseTopLevelStatement(FileDescriptorProto* file,\n                                    const LocationRecorder& root_location) {\n  if (TryConsumeEndOfDeclaration(\";\", NULL)) {\n    // empty statement; ignore\n    return true;\n  } else if (LookingAt(\"message\")) {\n    LocationRecorder location(root_location,\n      FileDescriptorProto::kMessageTypeFieldNumber, file->message_type_size());\n    return ParseMessageDefinition(file->add_message_type(), location, file);\n  } else if (LookingAt(\"enum\")) {\n    LocationRecorder location(root_location,\n      FileDescriptorProto::kEnumTypeFieldNumber, file->enum_type_size());\n    return ParseEnumDefinition(file->add_enum_type(), location, file);\n  } else if (LookingAt(\"service\")) {\n    LocationRecorder location(root_location,\n      FileDescriptorProto::kServiceFieldNumber, file->service_size());\n    return ParseServiceDefinition(file->add_service(), location, file);\n  } else if (LookingAt(\"extend\")) {\n    LocationRecorder location(root_location,\n        FileDescriptorProto::kExtensionFieldNumber);\n    return ParseExtend(file->mutable_extension(),\n                       file->mutable_message_type(),\n                       root_location,\n                       FileDescriptorProto::kMessageTypeFieldNumber,\n                       location, file);\n  } else if (LookingAt(\"import\")) {\n    return ParseImport(file->mutable_dependency(),\n                       file->mutable_public_dependency(),\n                       file->mutable_weak_dependency(),\n                       root_location, file);\n  } else if (LookingAt(\"package\")) {\n    return ParsePackage(file, root_location, file);\n  } else if (LookingAt(\"option\")) {\n    LocationRecorder location(root_location,\n        FileDescriptorProto::kOptionsFieldNumber);\n    return ParseOption(file->mutable_options(), location, file,\n                       OPTION_STATEMENT);\n  } else {\n    AddError(\"Expected top-level statement (e.g. \\\"message\\\").\");\n    return false;\n  }\n}\n\n// -------------------------------------------------------------------\n// Messages\n\nbool Parser::ParseMessageDefinition(\n    DescriptorProto* message,\n    const LocationRecorder& message_location,\n    const FileDescriptorProto* containing_file) {\n  DO(Consume(\"message\"));\n  {\n    LocationRecorder location(message_location,\n                              DescriptorProto::kNameFieldNumber);\n    location.RecordLegacyLocation(\n        message, DescriptorPool::ErrorCollector::NAME);\n    DO(ConsumeIdentifier(message->mutable_name(), \"Expected message name.\"));\n  }\n  DO(ParseMessageBlock(message, message_location, containing_file));\n  return true;\n}\n\nnamespace {\n\nconst int kMaxExtensionRangeSentinel = -1;\n\nbool IsMessageSetWireFormatMessage(const DescriptorProto& message) {\n  const MessageOptions& options = message.options();\n  for (int i = 0; i < options.uninterpreted_option_size(); ++i) {\n    const UninterpretedOption& uninterpreted = options.uninterpreted_option(i);\n    if (uninterpreted.name_size() == 1 &&\n        uninterpreted.name(0).name_part() == \"message_set_wire_format\" &&\n        uninterpreted.identifier_value() == \"true\") {\n      return true;\n    }\n  }\n  return false;\n}\n\n// Modifies any extension ranges that specified 'max' as the end of the\n// extension range, and sets them to the type-specific maximum. The actual max\n// tag number can only be determined after all options have been parsed.\nvoid AdjustExtensionRangesWithMaxEndNumber(DescriptorProto* message) {\n  const bool is_message_set = IsMessageSetWireFormatMessage(*message);\n  const int max_extension_number = is_message_set ?\n      kint32max :\n      FieldDescriptor::kMaxNumber + 1;\n  for (int i = 0; i < message->extension_range_size(); ++i) {\n    if (message->extension_range(i).end() == kMaxExtensionRangeSentinel) {\n      message->mutable_extension_range(i)->set_end(max_extension_number);\n    }\n  }\n}\n\n}  // namespace\n\nbool Parser::ParseMessageBlock(DescriptorProto* message,\n                               const LocationRecorder& message_location,\n                               const FileDescriptorProto* containing_file) {\n  DO(ConsumeEndOfDeclaration(\"{\", &message_location));\n\n  while (!TryConsumeEndOfDeclaration(\"}\", NULL)) {\n    if (AtEnd()) {\n      AddError(\"Reached end of input in message definition (missing '}').\");\n      return false;\n    }\n\n    if (!ParseMessageStatement(message, message_location, containing_file)) {\n      // This statement failed to parse.  Skip it, but keep looping to parse\n      // other statements.\n      SkipStatement();\n    }\n  }\n\n  if (message->extension_range_size() > 0) {\n    AdjustExtensionRangesWithMaxEndNumber(message);\n  }\n  return true;\n}\n\nbool Parser::ParseMessageStatement(DescriptorProto* message,\n                                   const LocationRecorder& message_location,\n                                   const FileDescriptorProto* containing_file) {\n  if (TryConsumeEndOfDeclaration(\";\", NULL)) {\n    // empty statement; ignore\n    return true;\n  } else if (LookingAt(\"message\")) {\n    LocationRecorder location(message_location,\n                              DescriptorProto::kNestedTypeFieldNumber,\n                              message->nested_type_size());\n    return ParseMessageDefinition(message->add_nested_type(), location,\n                                  containing_file);\n  } else if (LookingAt(\"enum\")) {\n    LocationRecorder location(message_location,\n                              DescriptorProto::kEnumTypeFieldNumber,\n                              message->enum_type_size());\n    return ParseEnumDefinition(message->add_enum_type(), location,\n                               containing_file);\n  } else if (LookingAt(\"extensions\")) {\n    LocationRecorder location(message_location,\n                              DescriptorProto::kExtensionRangeFieldNumber);\n    return ParseExtensions(message, location, containing_file);\n  } else if (LookingAt(\"reserved\")) {\n    return ParseReserved(message, message_location);\n  } else if (LookingAt(\"extend\")) {\n    LocationRecorder location(message_location,\n                              DescriptorProto::kExtensionFieldNumber);\n    return ParseExtend(message->mutable_extension(),\n                       message->mutable_nested_type(),\n                       message_location,\n                       DescriptorProto::kNestedTypeFieldNumber,\n                       location, containing_file);\n  } else if (LookingAt(\"option\")) {\n    LocationRecorder location(message_location,\n                              DescriptorProto::kOptionsFieldNumber);\n    return ParseOption(message->mutable_options(), location,\n                       containing_file, OPTION_STATEMENT);\n  } else if (LookingAt(\"oneof\")) {\n    int oneof_index = message->oneof_decl_size();\n    LocationRecorder oneof_location(message_location,\n                                    DescriptorProto::kOneofDeclFieldNumber,\n                                    oneof_index);\n\n    return ParseOneof(message->add_oneof_decl(), message,\n                      oneof_index, oneof_location, message_location,\n                      containing_file);\n  } else {\n    LocationRecorder location(message_location,\n                              DescriptorProto::kFieldFieldNumber,\n                              message->field_size());\n    return ParseMessageField(message->add_field(),\n                             message->mutable_nested_type(),\n                             message_location,\n                             DescriptorProto::kNestedTypeFieldNumber,\n                             location,\n                             containing_file);\n  }\n}\n\nbool Parser::ParseMessageField(FieldDescriptorProto* field,\n                               RepeatedPtrField<DescriptorProto>* messages,\n                               const LocationRecorder& parent_location,\n                               int location_field_number_for_nested_type,\n                               const LocationRecorder& field_location,\n                               const FileDescriptorProto* containing_file) {\n  {\n    LocationRecorder location(field_location,\n                              FieldDescriptorProto::kLabelFieldNumber);\n    FieldDescriptorProto::Label label;\n    if (ParseLabel(&label, containing_file)) {\n      field->set_label(label);\n      if (label == FieldDescriptorProto::LABEL_OPTIONAL &&\n          syntax_identifier_ == \"proto3\") {\n        AddError(\n            \"Explicit 'optional' labels are disallowed in the Proto3 syntax. \"\n            \"To define 'optional' fields in Proto3, simply remove the \"\n            \"'optional' label, as fields are 'optional' by default.\");\n      }\n    }\n  }\n\n  return ParseMessageFieldNoLabel(field, messages, parent_location,\n                                  location_field_number_for_nested_type,\n                                  field_location,\n                                  containing_file);\n}\n\nbool Parser::ParseMessageFieldNoLabel(\n    FieldDescriptorProto* field,\n    RepeatedPtrField<DescriptorProto>* messages,\n    const LocationRecorder& parent_location,\n    int location_field_number_for_nested_type,\n    const LocationRecorder& field_location,\n    const FileDescriptorProto* containing_file) {\n  MapField map_field;\n  // Parse type.\n  {\n    LocationRecorder location(field_location);  // add path later\n    location.RecordLegacyLocation(field, DescriptorPool::ErrorCollector::TYPE);\n\n    bool type_parsed = false;\n    FieldDescriptorProto::Type type = FieldDescriptorProto::TYPE_INT32;\n    string type_name;\n\n    // Special case map field. We only treat the field as a map field if the\n    // field type name starts with the word \"map\" with a following \"<\".\n    if (TryConsume(\"map\")) {\n      if (LookingAt(\"<\")) {\n        map_field.is_map_field = true;\n      } else {\n        // False positive\n        type_parsed = true;\n        type_name = \"map\";\n      }\n    }\n    if (map_field.is_map_field) {\n      if (field->has_oneof_index()) {\n        AddError(\"Map fields are not allowed in oneofs.\");\n        return false;\n      }\n      if (field->has_label()) {\n        AddError(\n            \"Field labels (required/optional/repeated) are not allowed on \"\n            \"map fields.\");\n        return false;\n      }\n      if (field->has_extendee()) {\n        AddError(\"Map fields are not allowed to be extensions.\");\n        return false;\n      }\n      field->set_label(FieldDescriptorProto::LABEL_REPEATED);\n      DO(Consume(\"<\"));\n      DO(ParseType(&map_field.key_type, &map_field.key_type_name));\n      DO(Consume(\",\"));\n      DO(ParseType(&map_field.value_type, &map_field.value_type_name));\n      DO(Consume(\">\"));\n      // Defer setting of the type name of the map field until the\n      // field name is parsed. Add the source location though.\n      location.AddPath(FieldDescriptorProto::kTypeNameFieldNumber);\n    } else {\n      // Handle the case where no explicit label is given for a non-map field.\n      if (!field->has_label() && DefaultToOptionalFields()) {\n        field->set_label(FieldDescriptorProto::LABEL_OPTIONAL);\n      }\n      if (!field->has_label()) {\n        AddError(\"Expected \\\"required\\\", \\\"optional\\\", or \\\"repeated\\\".\");\n        // We can actually reasonably recover here by just assuming the user\n        // forgot the label altogether.\n        field->set_label(FieldDescriptorProto::LABEL_OPTIONAL);\n      }\n\n      // Handle the case where the actual type is a message or enum named \"map\",\n      // which we already consumed in the code above.\n      if (!type_parsed) {\n        DO(ParseType(&type, &type_name));\n      }\n      if (type_name.empty()) {\n        location.AddPath(FieldDescriptorProto::kTypeFieldNumber);\n        field->set_type(type);\n      } else {\n        location.AddPath(FieldDescriptorProto::kTypeNameFieldNumber);\n        field->set_type_name(type_name);\n      }\n    }\n  }\n\n  // Parse name and '='.\n  io::Tokenizer::Token name_token = input_->current();\n  {\n    LocationRecorder location(field_location,\n                              FieldDescriptorProto::kNameFieldNumber);\n    location.RecordLegacyLocation(field, DescriptorPool::ErrorCollector::NAME);\n    DO(ConsumeIdentifier(field->mutable_name(), \"Expected field name.\"));\n  }\n  DO(Consume(\"=\", \"Missing field number.\"));\n\n  // Parse field number.\n  {\n    LocationRecorder location(field_location,\n                              FieldDescriptorProto::kNumberFieldNumber);\n    location.RecordLegacyLocation(\n        field, DescriptorPool::ErrorCollector::NUMBER);\n    int number;\n    DO(ConsumeInteger(&number, \"Expected field number.\"));\n    field->set_number(number);\n  }\n\n  // Parse options.\n  DO(ParseFieldOptions(field, field_location, containing_file));\n\n  // Deal with groups.\n  if (field->has_type() && field->type() == FieldDescriptorProto::TYPE_GROUP) {\n    // Awkward:  Since a group declares both a message type and a field, we\n    //   have to create overlapping locations.\n    LocationRecorder group_location(parent_location);\n    group_location.StartAt(field_location);\n    group_location.AddPath(location_field_number_for_nested_type);\n    group_location.AddPath(messages->size());\n\n    DescriptorProto* group = messages->Add();\n    group->set_name(field->name());\n\n    // Record name location to match the field name's location.\n    {\n      LocationRecorder location(group_location,\n                                DescriptorProto::kNameFieldNumber);\n      location.StartAt(name_token);\n      location.EndAt(name_token);\n      location.RecordLegacyLocation(\n          group, DescriptorPool::ErrorCollector::NAME);\n    }\n\n    // The field's type_name also comes from the name.  Confusing!\n    {\n      LocationRecorder location(field_location,\n                                FieldDescriptorProto::kTypeNameFieldNumber);\n      location.StartAt(name_token);\n      location.EndAt(name_token);\n    }\n\n    // As a hack for backwards-compatibility, we force the group name to start\n    // with a capital letter and lower-case the field name.  New code should\n    // not use groups; it should use nested messages.\n    if (group->name()[0] < 'A' || 'Z' < group->name()[0]) {\n      AddError(name_token.line, name_token.column,\n        \"Group names must start with a capital letter.\");\n    }\n    LowerString(field->mutable_name());\n\n    field->set_type_name(group->name());\n    if (LookingAt(\"{\")) {\n      DO(ParseMessageBlock(group, group_location, containing_file));\n    } else {\n      AddError(\"Missing group body.\");\n      return false;\n    }\n  } else {\n    DO(ConsumeEndOfDeclaration(\";\", &field_location));\n  }\n\n  // Create a map entry type if this is a map field.\n  if (map_field.is_map_field) {\n    GenerateMapEntry(map_field, field, messages);\n  }\n\n  return true;\n}\n\nvoid Parser::GenerateMapEntry(const MapField& map_field,\n                              FieldDescriptorProto* field,\n                              RepeatedPtrField<DescriptorProto>* messages) {\n  DescriptorProto* entry = messages->Add();\n  string entry_name = MapEntryName(field->name());\n  field->set_type_name(entry_name);\n  entry->set_name(entry_name);\n  entry->mutable_options()->set_map_entry(true);\n  FieldDescriptorProto* key_field = entry->add_field();\n  key_field->set_name(\"key\");\n  key_field->set_label(FieldDescriptorProto::LABEL_OPTIONAL);\n  key_field->set_number(1);\n  if (map_field.key_type_name.empty()) {\n    key_field->set_type(map_field.key_type);\n  } else {\n    key_field->set_type_name(map_field.key_type_name);\n  }\n  FieldDescriptorProto* value_field = entry->add_field();\n  value_field->set_name(\"value\");\n  value_field->set_label(FieldDescriptorProto::LABEL_OPTIONAL);\n  value_field->set_number(2);\n  if (map_field.value_type_name.empty()) {\n    value_field->set_type(map_field.value_type);\n  } else {\n    value_field->set_type_name(map_field.value_type_name);\n  }\n  // Propagate the \"enforce_utf8\" option to key and value fields if they\n  // are strings. This helps simplify the implementation of code generators\n  // and also reflection-based parsing code.\n  //\n  // The following definition:\n  //   message Foo {\n  //     map<string, string> value = 1 [enforce_utf8 = false];\n  //   }\n  // will be interpreted as:\n  //   message Foo {\n  //     message ValueEntry {\n  //       option map_entry = true;\n  //       string key = 1 [enforce_utf8 = false];\n  //       string value = 2 [enforce_utf8 = false];\n  //     }\n  //     repeated ValueEntry value = 1 [enforce_utf8 = false];\n  //  }\n  //\n  // TODO(xiaofeng): Remove this when the \"enforce_utf8\" option is removed\n  // from protocol compiler.\n  for (int i = 0; i < field->options().uninterpreted_option_size(); ++i) {\n    const UninterpretedOption& option =\n        field->options().uninterpreted_option(i);\n    if (option.name_size() == 1 &&\n        option.name(0).name_part() == \"enforce_utf8\" &&\n        !option.name(0).is_extension()) {\n      if (key_field->type() == FieldDescriptorProto::TYPE_STRING) {\n        key_field->mutable_options()->add_uninterpreted_option()\n            ->CopyFrom(option);\n      }\n      if (value_field->type() == FieldDescriptorProto::TYPE_STRING) {\n        value_field->mutable_options()->add_uninterpreted_option()\n            ->CopyFrom(option);\n      }\n    }\n  }\n}\n\nbool Parser::ParseFieldOptions(FieldDescriptorProto* field,\n                               const LocationRecorder& field_location,\n                               const FileDescriptorProto* containing_file) {\n  if (!LookingAt(\"[\")) return true;\n\n  LocationRecorder location(field_location,\n                            FieldDescriptorProto::kOptionsFieldNumber);\n\n  DO(Consume(\"[\"));\n\n  // Parse field options.\n  do {\n    if (LookingAt(\"default\")) {\n      // We intentionally pass field_location rather than location here, since\n      // the default value is not actually an option.\n      DO(ParseDefaultAssignment(field, field_location, containing_file));\n    } else if (LookingAt(\"json_name\")) {\n      // Like default value, this \"json_name\" is not an actual option.\n      DO(ParseJsonName(field, field_location, containing_file));\n    } else {\n      DO(ParseOption(field->mutable_options(), location,\n                     containing_file, OPTION_ASSIGNMENT));\n    }\n  } while (TryConsume(\",\"));\n\n  DO(Consume(\"]\"));\n  return true;\n}\n\nbool Parser::ParseDefaultAssignment(\n    FieldDescriptorProto* field,\n    const LocationRecorder& field_location,\n    const FileDescriptorProto* containing_file) {\n  if (field->has_default_value()) {\n    AddError(\"Already set option \\\"default\\\".\");\n    field->clear_default_value();\n  }\n\n  DO(Consume(\"default\"));\n  DO(Consume(\"=\"));\n\n  LocationRecorder location(field_location,\n                            FieldDescriptorProto::kDefaultValueFieldNumber);\n  location.RecordLegacyLocation(\n      field, DescriptorPool::ErrorCollector::DEFAULT_VALUE);\n  string* default_value = field->mutable_default_value();\n\n  if (!field->has_type()) {\n    // The field has a type name, but we don't know if it is a message or an\n    // enum yet. (If it were a primitive type, |field| would have a type set\n    // already.) In this case, simply take the current string as the default\n    // value; we will catch the error later if it is not a valid enum value.\n    // (N.B. that we do not check whether the current token is an identifier:\n    // doing so throws strange errors when the user mistypes a primitive\n    // typename and we assume it's an enum. E.g.: \"optional int foo = 1 [default\n    // = 42]\". In such a case the fundamental error is really that \"int\" is not\n    // a type, not that \"42\" is not an identifier. See b/12533582.)\n    *default_value = input_->current().text;\n    input_->Next();\n    return true;\n  }\n\n  switch (field->type()) {\n    case FieldDescriptorProto::TYPE_INT32:\n    case FieldDescriptorProto::TYPE_INT64:\n    case FieldDescriptorProto::TYPE_SINT32:\n    case FieldDescriptorProto::TYPE_SINT64:\n    case FieldDescriptorProto::TYPE_SFIXED32:\n    case FieldDescriptorProto::TYPE_SFIXED64: {\n      uint64 max_value = kint64max;\n      if (field->type() == FieldDescriptorProto::TYPE_INT32 ||\n          field->type() == FieldDescriptorProto::TYPE_SINT32 ||\n          field->type() == FieldDescriptorProto::TYPE_SFIXED32) {\n        max_value = kint32max;\n      }\n\n      // These types can be negative.\n      if (TryConsume(\"-\")) {\n        default_value->append(\"-\");\n        // Two's complement always has one more negative value than positive.\n        ++max_value;\n      }\n      // Parse the integer to verify that it is not out-of-range.\n      uint64 value;\n      DO(ConsumeInteger64(max_value, &value,\n                          \"Expected integer for field default value.\"));\n      // And stringify it again.\n      default_value->append(SimpleItoa(value));\n      break;\n    }\n\n    case FieldDescriptorProto::TYPE_UINT32:\n    case FieldDescriptorProto::TYPE_UINT64:\n    case FieldDescriptorProto::TYPE_FIXED32:\n    case FieldDescriptorProto::TYPE_FIXED64: {\n      uint64 max_value = kuint64max;\n      if (field->type() == FieldDescriptorProto::TYPE_UINT32 ||\n          field->type() == FieldDescriptorProto::TYPE_FIXED32) {\n        max_value = kuint32max;\n      }\n\n      // Numeric, not negative.\n      if (TryConsume(\"-\")) {\n        AddError(\"Unsigned field can't have negative default value.\");\n      }\n      // Parse the integer to verify that it is not out-of-range.\n      uint64 value;\n      DO(ConsumeInteger64(max_value, &value,\n                          \"Expected integer for field default value.\"));\n      // And stringify it again.\n      default_value->append(SimpleItoa(value));\n      break;\n    }\n\n    case FieldDescriptorProto::TYPE_FLOAT:\n    case FieldDescriptorProto::TYPE_DOUBLE:\n      // These types can be negative.\n      if (TryConsume(\"-\")) {\n        default_value->append(\"-\");\n      }\n      // Parse the integer because we have to convert hex integers to decimal\n      // floats.\n      double value;\n      DO(ConsumeNumber(&value, \"Expected number.\"));\n      // And stringify it again.\n      default_value->append(SimpleDtoa(value));\n      break;\n\n    case FieldDescriptorProto::TYPE_BOOL:\n      if (TryConsume(\"true\")) {\n        default_value->assign(\"true\");\n      } else if (TryConsume(\"false\")) {\n        default_value->assign(\"false\");\n      } else {\n        AddError(\"Expected \\\"true\\\" or \\\"false\\\".\");\n        return false;\n      }\n      break;\n\n    case FieldDescriptorProto::TYPE_STRING:\n      // Note: When file opton java_string_check_utf8 is true, if a\n      // non-string representation (eg byte[]) is later supported, it must\n      // be checked for UTF-8-ness.\n      DO(ConsumeString(default_value, \"Expected string for field default \"\n                       \"value.\"));\n      break;\n\n    case FieldDescriptorProto::TYPE_BYTES:\n      DO(ConsumeString(default_value, \"Expected string.\"));\n      *default_value = CEscape(*default_value);\n      break;\n\n    case FieldDescriptorProto::TYPE_ENUM:\n      DO(ConsumeIdentifier(default_value, \"Expected enum identifier for field \"\n                                          \"default value.\"));\n      break;\n\n    case FieldDescriptorProto::TYPE_MESSAGE:\n    case FieldDescriptorProto::TYPE_GROUP:\n      AddError(\"Messages can't have default values.\");\n      return false;\n  }\n\n  return true;\n}\n\nbool Parser::ParseJsonName(\n    FieldDescriptorProto* field,\n    const LocationRecorder& field_location,\n    const FileDescriptorProto* containing_file) {\n  if (field->has_json_name()) {\n    AddError(\"Already set option \\\"json_name\\\".\");\n    field->clear_json_name();\n  }\n\n  DO(Consume(\"json_name\"));\n  DO(Consume(\"=\"));\n\n  LocationRecorder location(field_location,\n                            FieldDescriptorProto::kJsonNameFieldNumber);\n  location.RecordLegacyLocation(\n      field, DescriptorPool::ErrorCollector::OPTION_VALUE);\n  DO(ConsumeString(field->mutable_json_name(),\n                   \"Expected string for JSON name.\"));\n  return true;\n}\n\n\nbool Parser::ParseOptionNamePart(UninterpretedOption* uninterpreted_option,\n                                 const LocationRecorder& part_location,\n                                 const FileDescriptorProto* containing_file) {\n  UninterpretedOption::NamePart* name = uninterpreted_option->add_name();\n  string identifier;  // We parse identifiers into this string.\n  if (LookingAt(\"(\")) {  // This is an extension.\n    DO(Consume(\"(\"));\n\n    {\n      LocationRecorder location(\n          part_location, UninterpretedOption::NamePart::kNamePartFieldNumber);\n      // An extension name consists of dot-separated identifiers, and may begin\n      // with a dot.\n      if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) {\n        DO(ConsumeIdentifier(&identifier, \"Expected identifier.\"));\n        name->mutable_name_part()->append(identifier);\n      }\n      while (LookingAt(\".\")) {\n        DO(Consume(\".\"));\n        name->mutable_name_part()->append(\".\");\n        DO(ConsumeIdentifier(&identifier, \"Expected identifier.\"));\n        name->mutable_name_part()->append(identifier);\n      }\n    }\n\n    DO(Consume(\")\"));\n    name->set_is_extension(true);\n  } else {  // This is a regular field.\n    LocationRecorder location(\n        part_location, UninterpretedOption::NamePart::kNamePartFieldNumber);\n    DO(ConsumeIdentifier(&identifier, \"Expected identifier.\"));\n    name->mutable_name_part()->append(identifier);\n    name->set_is_extension(false);\n  }\n  return true;\n}\n\nbool Parser::ParseUninterpretedBlock(string* value) {\n  // Note that enclosing braces are not added to *value.\n  // We do NOT use ConsumeEndOfStatement for this brace because it's delimiting\n  // an expression, not a block of statements.\n  DO(Consume(\"{\"));\n  int brace_depth = 1;\n  while (!AtEnd()) {\n    if (LookingAt(\"{\")) {\n      brace_depth++;\n    } else if (LookingAt(\"}\")) {\n      brace_depth--;\n      if (brace_depth == 0) {\n        input_->Next();\n        return true;\n      }\n    }\n    // TODO(sanjay): Interpret line/column numbers to preserve formatting\n    if (!value->empty()) value->push_back(' ');\n    value->append(input_->current().text);\n    input_->Next();\n  }\n  AddError(\"Unexpected end of stream while parsing aggregate value.\");\n  return false;\n}\n\n// We don't interpret the option here. Instead we store it in an\n// UninterpretedOption, to be interpreted later.\nbool Parser::ParseOption(Message* options,\n                         const LocationRecorder& options_location,\n                         const FileDescriptorProto* containing_file,\n                         OptionStyle style) {\n  // Create an entry in the uninterpreted_option field.\n  const FieldDescriptor* uninterpreted_option_field = options->GetDescriptor()->\n      FindFieldByName(\"uninterpreted_option\");\n  GOOGLE_CHECK(uninterpreted_option_field != NULL)\n      << \"No field named \\\"uninterpreted_option\\\" in the Options proto.\";\n\n  const Reflection* reflection = options->GetReflection();\n\n  LocationRecorder location(\n      options_location, uninterpreted_option_field->number(),\n      reflection->FieldSize(*options, uninterpreted_option_field));\n\n  if (style == OPTION_STATEMENT) {\n    DO(Consume(\"option\"));\n  }\n\n  UninterpretedOption* uninterpreted_option = down_cast<UninterpretedOption*>(\n      options->GetReflection()->AddMessage(options,\n                                           uninterpreted_option_field));\n\n  // Parse dot-separated name.\n  {\n    LocationRecorder name_location(location,\n                                   UninterpretedOption::kNameFieldNumber);\n    name_location.RecordLegacyLocation(\n        uninterpreted_option, DescriptorPool::ErrorCollector::OPTION_NAME);\n\n    {\n      LocationRecorder part_location(name_location,\n                                     uninterpreted_option->name_size());\n      DO(ParseOptionNamePart(uninterpreted_option, part_location,\n                             containing_file));\n    }\n\n    while (LookingAt(\".\")) {\n      DO(Consume(\".\"));\n      LocationRecorder part_location(name_location,\n                                     uninterpreted_option->name_size());\n      DO(ParseOptionNamePart(uninterpreted_option, part_location,\n                             containing_file));\n    }\n  }\n\n  DO(Consume(\"=\"));\n\n  {\n    LocationRecorder value_location(location);\n    value_location.RecordLegacyLocation(\n        uninterpreted_option, DescriptorPool::ErrorCollector::OPTION_VALUE);\n\n    // All values are a single token, except for negative numbers, which consist\n    // of a single '-' symbol, followed by a positive number.\n    bool is_negative = TryConsume(\"-\");\n\n    switch (input_->current().type) {\n      case io::Tokenizer::TYPE_START:\n        GOOGLE_LOG(FATAL) << \"Trying to read value before any tokens have been read.\";\n        return false;\n\n      case io::Tokenizer::TYPE_END:\n        AddError(\"Unexpected end of stream while parsing option value.\");\n        return false;\n\n      case io::Tokenizer::TYPE_IDENTIFIER: {\n        value_location.AddPath(\n            UninterpretedOption::kIdentifierValueFieldNumber);\n        if (is_negative) {\n          AddError(\"Invalid '-' symbol before identifier.\");\n          return false;\n        }\n        string value;\n        DO(ConsumeIdentifier(&value, \"Expected identifier.\"));\n        uninterpreted_option->set_identifier_value(value);\n        break;\n      }\n\n      case io::Tokenizer::TYPE_INTEGER: {\n        uint64 value;\n        uint64 max_value =\n            is_negative ? static_cast<uint64>(kint64max) + 1 : kuint64max;\n        DO(ConsumeInteger64(max_value, &value, \"Expected integer.\"));\n        if (is_negative) {\n          value_location.AddPath(\n              UninterpretedOption::kNegativeIntValueFieldNumber);\n          uninterpreted_option->set_negative_int_value(\n              -static_cast<int64>(value));\n        } else {\n          value_location.AddPath(\n              UninterpretedOption::kPositiveIntValueFieldNumber);\n          uninterpreted_option->set_positive_int_value(value);\n        }\n        break;\n      }\n\n      case io::Tokenizer::TYPE_FLOAT: {\n        value_location.AddPath(UninterpretedOption::kDoubleValueFieldNumber);\n        double value;\n        DO(ConsumeNumber(&value, \"Expected number.\"));\n        uninterpreted_option->set_double_value(is_negative ? -value : value);\n        break;\n      }\n\n      case io::Tokenizer::TYPE_STRING: {\n        value_location.AddPath(UninterpretedOption::kStringValueFieldNumber);\n        if (is_negative) {\n          AddError(\"Invalid '-' symbol before string.\");\n          return false;\n        }\n        string value;\n        DO(ConsumeString(&value, \"Expected string.\"));\n        uninterpreted_option->set_string_value(value);\n        break;\n      }\n\n      case io::Tokenizer::TYPE_SYMBOL:\n        if (LookingAt(\"{\")) {\n          value_location.AddPath(\n              UninterpretedOption::kAggregateValueFieldNumber);\n          DO(ParseUninterpretedBlock(\n              uninterpreted_option->mutable_aggregate_value()));\n        } else {\n          AddError(\"Expected option value.\");\n          return false;\n        }\n        break;\n    }\n  }\n\n  if (style == OPTION_STATEMENT) {\n    DO(ConsumeEndOfDeclaration(\";\", &location));\n  }\n\n  return true;\n}\n\nbool Parser::ParseExtensions(DescriptorProto* message,\n                             const LocationRecorder& extensions_location,\n                             const FileDescriptorProto* containing_file) {\n  // Parse the declaration.\n  DO(Consume(\"extensions\"));\n\n  do {\n    // Note that kExtensionRangeFieldNumber was already pushed by the parent.\n    LocationRecorder location(extensions_location,\n                              message->extension_range_size());\n\n    DescriptorProto::ExtensionRange* range = message->add_extension_range();\n    location.RecordLegacyLocation(\n        range, DescriptorPool::ErrorCollector::NUMBER);\n\n    int start, end;\n    io::Tokenizer::Token start_token;\n\n    {\n      LocationRecorder start_location(\n          location, DescriptorProto::ExtensionRange::kStartFieldNumber);\n      start_token = input_->current();\n      DO(ConsumeInteger(&start, \"Expected field number range.\"));\n    }\n\n    if (TryConsume(\"to\")) {\n      LocationRecorder end_location(\n          location, DescriptorProto::ExtensionRange::kEndFieldNumber);\n      if (TryConsume(\"max\")) {\n        // Set to the sentinel value - 1 since we increment the value below.\n        // The actual value of the end of the range should be set with\n        // AdjustExtensionRangesWithMaxEndNumber.\n        end = kMaxExtensionRangeSentinel - 1;\n      } else {\n        DO(ConsumeInteger(&end, \"Expected integer.\"));\n      }\n    } else {\n      LocationRecorder end_location(\n          location, DescriptorProto::ExtensionRange::kEndFieldNumber);\n      end_location.StartAt(start_token);\n      end_location.EndAt(start_token);\n      end = start;\n    }\n\n    // Users like to specify inclusive ranges, but in code we like the end\n    // number to be exclusive.\n    ++end;\n\n    range->set_start(start);\n    range->set_end(end);\n  } while (TryConsume(\",\"));\n\n  DO(ConsumeEndOfDeclaration(\";\", &extensions_location));\n  return true;\n}\n\n// This is similar to extension range parsing, except that \"max\" is not\n// supported, and accepts field name literals.\nbool Parser::ParseReserved(DescriptorProto* message,\n                           const LocationRecorder& message_location) {\n  // Parse the declaration.\n  DO(Consume(\"reserved\"));\n  if (LookingAtType(io::Tokenizer::TYPE_STRING)) {\n    LocationRecorder location(message_location,\n                              DescriptorProto::kReservedNameFieldNumber);\n    return ParseReservedNames(message, location);\n  } else {\n    LocationRecorder location(message_location,\n                              DescriptorProto::kReservedRangeFieldNumber);\n    return ParseReservedNumbers(message, location);\n  }\n}\n\n\nbool Parser::ParseReservedNames(DescriptorProto* message,\n                                const LocationRecorder& parent_location) {\n  do {\n    LocationRecorder location(parent_location, message->reserved_name_size());\n    DO(ConsumeString(message->add_reserved_name(), \"Expected field name.\"));\n  } while (TryConsume(\",\"));\n  DO(ConsumeEndOfDeclaration(\";\", &parent_location));\n  return true;\n}\n\nbool Parser::ParseReservedNumbers(DescriptorProto* message,\n                                  const LocationRecorder& parent_location) {\n  bool first = true;\n  do {\n    LocationRecorder location(parent_location, message->reserved_range_size());\n\n    DescriptorProto::ReservedRange* range = message->add_reserved_range();\n    int start, end;\n    io::Tokenizer::Token start_token;\n    {\n      LocationRecorder start_location(\n          location, DescriptorProto::ReservedRange::kStartFieldNumber);\n      start_token = input_->current();\n      DO(ConsumeInteger(&start, (first ?\n                                 \"Expected field name or number range.\" :\n                                 \"Expected field number range.\")));\n    }\n\n    if (TryConsume(\"to\")) {\n      LocationRecorder end_location(\n          location, DescriptorProto::ReservedRange::kEndFieldNumber);\n      DO(ConsumeInteger(&end, \"Expected integer.\"));\n    } else {\n      LocationRecorder end_location(\n          location, DescriptorProto::ReservedRange::kEndFieldNumber);\n      end_location.StartAt(start_token);\n      end_location.EndAt(start_token);\n      end = start;\n    }\n\n    // Users like to specify inclusive ranges, but in code we like the end\n    // number to be exclusive.\n    ++end;\n\n    range->set_start(start);\n    range->set_end(end);\n    first = false;\n  } while (TryConsume(\",\"));\n\n  DO(ConsumeEndOfDeclaration(\";\", &parent_location));\n  return true;\n}\n\nbool Parser::ParseExtend(RepeatedPtrField<FieldDescriptorProto>* extensions,\n                         RepeatedPtrField<DescriptorProto>* messages,\n                         const LocationRecorder& parent_location,\n                         int location_field_number_for_nested_type,\n                         const LocationRecorder& extend_location,\n                         const FileDescriptorProto* containing_file) {\n  DO(Consume(\"extend\"));\n\n  // Parse the extendee type.\n  io::Tokenizer::Token extendee_start = input_->current();\n  string extendee;\n  DO(ParseUserDefinedType(&extendee));\n  io::Tokenizer::Token extendee_end = input_->previous();\n\n  // Parse the block.\n  DO(ConsumeEndOfDeclaration(\"{\", &extend_location));\n\n  bool is_first = true;\n\n  do {\n    if (AtEnd()) {\n      AddError(\"Reached end of input in extend definition (missing '}').\");\n      return false;\n    }\n\n    // Note that kExtensionFieldNumber was already pushed by the parent.\n    LocationRecorder location(extend_location, extensions->size());\n\n    FieldDescriptorProto* field = extensions->Add();\n\n    {\n      LocationRecorder extendee_location(\n          location, FieldDescriptorProto::kExtendeeFieldNumber);\n      extendee_location.StartAt(extendee_start);\n      extendee_location.EndAt(extendee_end);\n\n      if (is_first) {\n        extendee_location.RecordLegacyLocation(\n            field, DescriptorPool::ErrorCollector::EXTENDEE);\n        is_first = false;\n      }\n    }\n\n    field->set_extendee(extendee);\n\n    if (!ParseMessageField(field, messages, parent_location,\n                           location_field_number_for_nested_type,\n                           location,\n                           containing_file)) {\n      // This statement failed to parse.  Skip it, but keep looping to parse\n      // other statements.\n      SkipStatement();\n    }\n  } while (!TryConsumeEndOfDeclaration(\"}\", NULL));\n\n  return true;\n}\n\nbool Parser::ParseOneof(OneofDescriptorProto* oneof_decl,\n                        DescriptorProto* containing_type,\n                        int oneof_index,\n                        const LocationRecorder& oneof_location,\n                        const LocationRecorder& containing_type_location,\n                        const FileDescriptorProto* containing_file) {\n  DO(Consume(\"oneof\"));\n\n  {\n    LocationRecorder name_location(oneof_location,\n                                   OneofDescriptorProto::kNameFieldNumber);\n    DO(ConsumeIdentifier(oneof_decl->mutable_name(), \"Expected oneof name.\"));\n  }\n\n  DO(ConsumeEndOfDeclaration(\"{\", &oneof_location));\n\n  do {\n    if (AtEnd()) {\n      AddError(\"Reached end of input in oneof definition (missing '}').\");\n      return false;\n    }\n\n    if (LookingAt(\"option\")) {\n      LocationRecorder option_location(\n          oneof_location, OneofDescriptorProto::kOptionsFieldNumber);\n      if (!ParseOption(oneof_decl->mutable_options(), option_location,\n                       containing_file, OPTION_STATEMENT)) {\n        return false;\n      }\n      continue;\n    }\n\n    // Print a nice error if the user accidentally tries to place a label\n    // on an individual member of a oneof.\n    if (LookingAt(\"required\") ||\n        LookingAt(\"optional\") ||\n        LookingAt(\"repeated\")) {\n      AddError(\"Fields in oneofs must not have labels (required / optional \"\n               \"/ repeated).\");\n      // We can continue parsing here because we understand what the user\n      // meant.  The error report will still make parsing fail overall.\n      input_->Next();\n    }\n\n    LocationRecorder field_location(containing_type_location,\n                                    DescriptorProto::kFieldFieldNumber,\n                                    containing_type->field_size());\n\n    FieldDescriptorProto* field = containing_type->add_field();\n    field->set_label(FieldDescriptorProto::LABEL_OPTIONAL);\n    field->set_oneof_index(oneof_index);\n\n    if (!ParseMessageFieldNoLabel(field,\n                                  containing_type->mutable_nested_type(),\n                                  containing_type_location,\n                                  DescriptorProto::kNestedTypeFieldNumber,\n                                  field_location,\n                                  containing_file)) {\n      // This statement failed to parse.  Skip it, but keep looping to parse\n      // other statements.\n      SkipStatement();\n    }\n  } while (!TryConsumeEndOfDeclaration(\"}\", NULL));\n\n  return true;\n}\n\n// -------------------------------------------------------------------\n// Enums\n\nbool Parser::ParseEnumDefinition(EnumDescriptorProto* enum_type,\n                                 const LocationRecorder& enum_location,\n                                 const FileDescriptorProto* containing_file) {\n  DO(Consume(\"enum\"));\n\n  {\n    LocationRecorder location(enum_location,\n                              EnumDescriptorProto::kNameFieldNumber);\n    location.RecordLegacyLocation(\n        enum_type, DescriptorPool::ErrorCollector::NAME);\n    DO(ConsumeIdentifier(enum_type->mutable_name(), \"Expected enum name.\"));\n  }\n\n  DO(ParseEnumBlock(enum_type, enum_location, containing_file));\n\n  DO(ValidateEnum(enum_type));\n\n  return true;\n}\n\nbool Parser::ParseEnumBlock(EnumDescriptorProto* enum_type,\n                            const LocationRecorder& enum_location,\n                            const FileDescriptorProto* containing_file) {\n  DO(ConsumeEndOfDeclaration(\"{\", &enum_location));\n\n  while (!TryConsumeEndOfDeclaration(\"}\", NULL)) {\n    if (AtEnd()) {\n      AddError(\"Reached end of input in enum definition (missing '}').\");\n      return false;\n    }\n\n    if (!ParseEnumStatement(enum_type, enum_location, containing_file)) {\n      // This statement failed to parse.  Skip it, but keep looping to parse\n      // other statements.\n      SkipStatement();\n    }\n  }\n\n  return true;\n}\n\nbool Parser::ParseEnumStatement(EnumDescriptorProto* enum_type,\n                                const LocationRecorder& enum_location,\n                                const FileDescriptorProto* containing_file) {\n  if (TryConsumeEndOfDeclaration(\";\", NULL)) {\n    // empty statement; ignore\n    return true;\n  } else if (LookingAt(\"option\")) {\n    LocationRecorder location(enum_location,\n                              EnumDescriptorProto::kOptionsFieldNumber);\n    return ParseOption(enum_type->mutable_options(), location,\n                       containing_file, OPTION_STATEMENT);\n  } else {\n    LocationRecorder location(enum_location,\n        EnumDescriptorProto::kValueFieldNumber, enum_type->value_size());\n    return ParseEnumConstant(enum_type->add_value(), location, containing_file);\n  }\n}\n\nbool Parser::ParseEnumConstant(EnumValueDescriptorProto* enum_value,\n                               const LocationRecorder& enum_value_location,\n                               const FileDescriptorProto* containing_file) {\n  // Parse name.\n  {\n    LocationRecorder location(enum_value_location,\n                              EnumValueDescriptorProto::kNameFieldNumber);\n    location.RecordLegacyLocation(\n        enum_value, DescriptorPool::ErrorCollector::NAME);\n    DO(ConsumeIdentifier(enum_value->mutable_name(),\n                         \"Expected enum constant name.\"));\n  }\n\n  DO(Consume(\"=\", \"Missing numeric value for enum constant.\"));\n\n  // Parse value.\n  {\n    LocationRecorder location(\n        enum_value_location, EnumValueDescriptorProto::kNumberFieldNumber);\n    location.RecordLegacyLocation(\n        enum_value, DescriptorPool::ErrorCollector::NUMBER);\n\n    int number;\n    DO(ConsumeSignedInteger(&number, \"Expected integer.\"));\n    enum_value->set_number(number);\n  }\n\n  DO(ParseEnumConstantOptions(enum_value, enum_value_location,\n                              containing_file));\n\n  DO(ConsumeEndOfDeclaration(\";\", &enum_value_location));\n\n  return true;\n}\n\nbool Parser::ParseEnumConstantOptions(\n    EnumValueDescriptorProto* value,\n    const LocationRecorder& enum_value_location,\n    const FileDescriptorProto* containing_file) {\n  if (!LookingAt(\"[\")) return true;\n\n  LocationRecorder location(\n      enum_value_location, EnumValueDescriptorProto::kOptionsFieldNumber);\n\n  DO(Consume(\"[\"));\n\n  do {\n    DO(ParseOption(value->mutable_options(), location,\n                   containing_file, OPTION_ASSIGNMENT));\n  } while (TryConsume(\",\"));\n\n  DO(Consume(\"]\"));\n  return true;\n}\n\n// -------------------------------------------------------------------\n// Services\n\nbool Parser::ParseServiceDefinition(\n    ServiceDescriptorProto* service,\n    const LocationRecorder& service_location,\n    const FileDescriptorProto* containing_file) {\n  DO(Consume(\"service\"));\n\n  {\n    LocationRecorder location(service_location,\n                              ServiceDescriptorProto::kNameFieldNumber);\n    location.RecordLegacyLocation(\n        service, DescriptorPool::ErrorCollector::NAME);\n    DO(ConsumeIdentifier(service->mutable_name(), \"Expected service name.\"));\n  }\n\n  DO(ParseServiceBlock(service, service_location, containing_file));\n  return true;\n}\n\nbool Parser::ParseServiceBlock(ServiceDescriptorProto* service,\n                               const LocationRecorder& service_location,\n                               const FileDescriptorProto* containing_file) {\n  DO(ConsumeEndOfDeclaration(\"{\", &service_location));\n\n  while (!TryConsumeEndOfDeclaration(\"}\", NULL)) {\n    if (AtEnd()) {\n      AddError(\"Reached end of input in service definition (missing '}').\");\n      return false;\n    }\n\n    if (!ParseServiceStatement(service, service_location, containing_file)) {\n      // This statement failed to parse.  Skip it, but keep looping to parse\n      // other statements.\n      SkipStatement();\n    }\n  }\n\n  return true;\n}\n\nbool Parser::ParseServiceStatement(ServiceDescriptorProto* service,\n                                   const LocationRecorder& service_location,\n                                   const FileDescriptorProto* containing_file) {\n  if (TryConsumeEndOfDeclaration(\";\", NULL)) {\n    // empty statement; ignore\n    return true;\n  } else if (LookingAt(\"option\")) {\n    LocationRecorder location(\n        service_location, ServiceDescriptorProto::kOptionsFieldNumber);\n    return ParseOption(service->mutable_options(), location,\n                       containing_file, OPTION_STATEMENT);\n  } else {\n    LocationRecorder location(service_location,\n        ServiceDescriptorProto::kMethodFieldNumber, service->method_size());\n    return ParseServiceMethod(service->add_method(), location, containing_file);\n  }\n}\n\nbool Parser::ParseServiceMethod(MethodDescriptorProto* method,\n                                const LocationRecorder& method_location,\n                                const FileDescriptorProto* containing_file) {\n  DO(Consume(\"rpc\"));\n\n  {\n    LocationRecorder location(method_location,\n                              MethodDescriptorProto::kNameFieldNumber);\n    location.RecordLegacyLocation(\n        method, DescriptorPool::ErrorCollector::NAME);\n    DO(ConsumeIdentifier(method->mutable_name(), \"Expected method name.\"));\n  }\n\n  // Parse input type.\n  DO(Consume(\"(\"));\n  {\n    if (LookingAt(\"stream\")) {\n      LocationRecorder location(\n          method_location, MethodDescriptorProto::kClientStreamingFieldNumber);\n      location.RecordLegacyLocation(\n          method, DescriptorPool::ErrorCollector::OTHER);\n      method->set_client_streaming(true);\n      DO(Consume(\"stream\"));\n\n    }\n    LocationRecorder location(method_location,\n                              MethodDescriptorProto::kInputTypeFieldNumber);\n    location.RecordLegacyLocation(\n        method, DescriptorPool::ErrorCollector::INPUT_TYPE);\n    DO(ParseUserDefinedType(method->mutable_input_type()));\n  }\n  DO(Consume(\")\"));\n\n  // Parse output type.\n  DO(Consume(\"returns\"));\n  DO(Consume(\"(\"));\n  {\n    if (LookingAt(\"stream\")) {\n      LocationRecorder location(\n          method_location, MethodDescriptorProto::kServerStreamingFieldNumber);\n      location.RecordLegacyLocation(\n          method, DescriptorPool::ErrorCollector::OTHER);\n      DO(Consume(\"stream\"));\n      method->set_server_streaming(true);\n\n    }\n    LocationRecorder location(method_location,\n                              MethodDescriptorProto::kOutputTypeFieldNumber);\n    location.RecordLegacyLocation(\n        method, DescriptorPool::ErrorCollector::OUTPUT_TYPE);\n    DO(ParseUserDefinedType(method->mutable_output_type()));\n  }\n  DO(Consume(\")\"));\n\n  if (LookingAt(\"{\")) {\n    // Options!\n    DO(ParseMethodOptions(method_location, containing_file,\n                          MethodDescriptorProto::kOptionsFieldNumber,\n                          method->mutable_options()));\n  } else {\n    DO(ConsumeEndOfDeclaration(\";\", &method_location));\n  }\n\n  return true;\n}\n\n\nbool Parser::ParseMethodOptions(const LocationRecorder& parent_location,\n                                const FileDescriptorProto* containing_file,\n                                const int optionsFieldNumber,\n                                Message* mutable_options) {\n  // Options!\n  ConsumeEndOfDeclaration(\"{\", &parent_location);\n  while (!TryConsumeEndOfDeclaration(\"}\", NULL)) {\n    if (AtEnd()) {\n      AddError(\"Reached end of input in method options (missing '}').\");\n      return false;\n    }\n\n    if (TryConsumeEndOfDeclaration(\";\", NULL)) {\n      // empty statement; ignore\n    } else {\n      LocationRecorder location(parent_location,\n                                optionsFieldNumber);\n      if (!ParseOption(mutable_options, location,\n                       containing_file, OPTION_STATEMENT)) {\n        // This statement failed to parse.  Skip it, but keep looping to\n        // parse other statements.\n        SkipStatement();\n      }\n    }\n  }\n\n  return true;\n}\n\n// -------------------------------------------------------------------\n\nbool Parser::ParseLabel(FieldDescriptorProto::Label* label,\n                        const FileDescriptorProto* containing_file) {\n  if (TryConsume(\"optional\")) {\n    *label = FieldDescriptorProto::LABEL_OPTIONAL;\n    return true;\n  } else if (TryConsume(\"repeated\")) {\n    *label = FieldDescriptorProto::LABEL_REPEATED;\n    return true;\n  } else if (TryConsume(\"required\")) {\n    *label = FieldDescriptorProto::LABEL_REQUIRED;\n    return true;\n  }\n  return false;\n}\n\nbool Parser::ParseType(FieldDescriptorProto::Type* type,\n                       string* type_name) {\n  TypeNameMap::const_iterator iter = kTypeNames.find(input_->current().text);\n  if (iter != kTypeNames.end()) {\n    *type = iter->second;\n    input_->Next();\n  } else {\n    DO(ParseUserDefinedType(type_name));\n  }\n  return true;\n}\n\nbool Parser::ParseUserDefinedType(string* type_name) {\n  type_name->clear();\n\n  TypeNameMap::const_iterator iter = kTypeNames.find(input_->current().text);\n  if (iter != kTypeNames.end()) {\n    // Note:  The only place enum types are allowed is for field types, but\n    //   if we are parsing a field type then we would not get here because\n    //   primitives are allowed there as well.  So this error message doesn't\n    //   need to account for enums.\n    AddError(\"Expected message type.\");\n\n    // Pretend to accept this type so that we can go on parsing.\n    *type_name = input_->current().text;\n    input_->Next();\n    return true;\n  }\n\n  // A leading \".\" means the name is fully-qualified.\n  if (TryConsume(\".\")) type_name->append(\".\");\n\n  // Consume the first part of the name.\n  string identifier;\n  DO(ConsumeIdentifier(&identifier, \"Expected type name.\"));\n  type_name->append(identifier);\n\n  // Consume more parts.\n  while (TryConsume(\".\")) {\n    type_name->append(\".\");\n    DO(ConsumeIdentifier(&identifier, \"Expected identifier.\"));\n    type_name->append(identifier);\n  }\n\n  return true;\n}\n\n// ===================================================================\n\nbool Parser::ParsePackage(FileDescriptorProto* file,\n                          const LocationRecorder& root_location,\n                          const FileDescriptorProto* containing_file) {\n  if (file->has_package()) {\n    AddError(\"Multiple package definitions.\");\n    // Don't append the new package to the old one.  Just replace it.  Not\n    // that it really matters since this is an error anyway.\n    file->clear_package();\n  }\n\n  DO(Consume(\"package\"));\n\n  {\n    LocationRecorder location(root_location,\n                              FileDescriptorProto::kPackageFieldNumber);\n    location.RecordLegacyLocation(file, DescriptorPool::ErrorCollector::NAME);\n\n    while (true) {\n      string identifier;\n      DO(ConsumeIdentifier(&identifier, \"Expected identifier.\"));\n      file->mutable_package()->append(identifier);\n      if (!TryConsume(\".\")) break;\n      file->mutable_package()->append(\".\");\n    }\n\n    location.EndAt(input_->previous());\n\n    DO(ConsumeEndOfDeclaration(\";\", &location));\n  }\n\n  return true;\n}\n\nbool Parser::ParseImport(RepeatedPtrField<string>* dependency,\n                         RepeatedField<int32>* public_dependency,\n                         RepeatedField<int32>* weak_dependency,\n                         const LocationRecorder& root_location,\n                         const FileDescriptorProto* containing_file) {\n  DO(Consume(\"import\"));\n  if (LookingAt(\"public\")) {\n    LocationRecorder location(\n        root_location, FileDescriptorProto::kPublicDependencyFieldNumber,\n        public_dependency->size());\n    DO(Consume(\"public\"));\n    *public_dependency->Add() = dependency->size();\n  } else if (LookingAt(\"weak\")) {\n    LocationRecorder location(\n        root_location, FileDescriptorProto::kWeakDependencyFieldNumber,\n        weak_dependency->size());\n    DO(Consume(\"weak\"));\n    *weak_dependency->Add() = dependency->size();\n  }\n  {\n    LocationRecorder location(root_location,\n                              FileDescriptorProto::kDependencyFieldNumber,\n                              dependency->size());\n    DO(ConsumeString(dependency->Add(),\n      \"Expected a string naming the file to import.\"));\n\n    location.EndAt(input_->previous());\n\n    DO(ConsumeEndOfDeclaration(\";\", &location));\n  }\n  return true;\n}\n\n// ===================================================================\n\nSourceLocationTable::SourceLocationTable() {}\nSourceLocationTable::~SourceLocationTable() {}\n\nbool SourceLocationTable::Find(\n    const Message* descriptor,\n    DescriptorPool::ErrorCollector::ErrorLocation location,\n    int* line, int* column) const {\n  const pair<int, int>* result =\n      FindOrNull(location_map_, std::make_pair(descriptor, location));\n  if (result == NULL) {\n    *line   = -1;\n    *column = 0;\n    return false;\n  } else {\n    *line   = result->first;\n    *column = result->second;\n    return true;\n  }\n}\n\nvoid SourceLocationTable::Add(\n    const Message* descriptor,\n    DescriptorPool::ErrorCollector::ErrorLocation location,\n    int line, int column) {\n  location_map_[std::make_pair(descriptor, location)] =\n      std::make_pair(line, column);\n}\n\nvoid SourceLocationTable::Clear() {\n  location_map_.clear();\n}\n\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/parser.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Implements parsing of .proto files to FileDescriptorProtos.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_PARSER_H__\n#define GOOGLE_PROTOBUF_COMPILER_PARSER_H__\n\n#include <map>\n#include <string>\n#include <utility>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/io/tokenizer.h>\n\nnamespace google {\nnamespace protobuf { class Message; }\n\nnamespace protobuf {\nnamespace compiler {\n\n// Defined in this file.\nclass Parser;\nclass SourceLocationTable;\n\n// Implements parsing of protocol definitions (such as .proto files).\n//\n// Note that most users will be more interested in the Importer class.\n// Parser is a lower-level class which simply converts a single .proto file\n// to a FileDescriptorProto.  It does not resolve import directives or perform\n// many other kinds of validation needed to construct a complete\n// FileDescriptor.\nclass LIBPROTOBUF_EXPORT Parser {\n public:\n  Parser();\n  ~Parser();\n\n  // Parse the entire input and construct a FileDescriptorProto representing\n  // it.  Returns true if no errors occurred, false otherwise.\n  bool Parse(io::Tokenizer* input, FileDescriptorProto* file);\n\n  // Optional features:\n\n  // DEPRECATED:  New code should use the SourceCodeInfo embedded in the\n  //   FileDescriptorProto.\n  //\n  // Requests that locations of certain definitions be recorded to the given\n  // SourceLocationTable while parsing.  This can be used to look up exact line\n  // and column numbers for errors reported by DescriptorPool during validation.\n  // Set to NULL (the default) to discard source location information.\n  void RecordSourceLocationsTo(SourceLocationTable* location_table) {\n    source_location_table_ = location_table;\n  }\n\n  // Requests that errors be recorded to the given ErrorCollector while\n  // parsing.  Set to NULL (the default) to discard error messages.\n  void RecordErrorsTo(io::ErrorCollector* error_collector) {\n    error_collector_ = error_collector;\n  }\n\n  // Returns the identifier used in the \"syntax = \" declaration, if one was\n  // seen during the last call to Parse(), or the empty string otherwise.\n  const string& GetSyntaxIdentifier() { return syntax_identifier_; }\n\n  // If set true, input files will be required to begin with a syntax\n  // identifier.  Otherwise, files may omit this.  If a syntax identifier\n  // is provided, it must be 'syntax = \"proto2\";' and must appear at the\n  // top of this file regardless of whether or not it was required.\n  void SetRequireSyntaxIdentifier(bool value) {\n    require_syntax_identifier_ = value;\n  }\n\n  // Call SetStopAfterSyntaxIdentifier(true) to tell the parser to stop\n  // parsing as soon as it has seen the syntax identifier, or lack thereof.\n  // This is useful for quickly identifying the syntax of the file without\n  // parsing the whole thing.  If this is enabled, no error will be recorded\n  // if the syntax identifier is something other than \"proto2\" (since\n  // presumably the caller intends to deal with that), but other kinds of\n  // errors (e.g. parse errors) will still be reported.  When this is enabled,\n  // you may pass a NULL FileDescriptorProto to Parse().\n  void SetStopAfterSyntaxIdentifier(bool value) {\n    stop_after_syntax_identifier_ = value;\n  }\n\n private:\n  class LocationRecorder;\n\n  // =================================================================\n  // Error recovery helpers\n\n  // Consume the rest of the current statement.  This consumes tokens\n  // until it sees one of:\n  //   ';'  Consumes the token and returns.\n  //   '{'  Consumes the brace then calls SkipRestOfBlock().\n  //   '}'  Returns without consuming.\n  //   EOF  Returns (can't consume).\n  // The Parser often calls SkipStatement() after encountering a syntax\n  // error.  This allows it to go on parsing the following lines, allowing\n  // it to report more than just one error in the file.\n  void SkipStatement();\n\n  // Consume the rest of the current block, including nested blocks,\n  // ending after the closing '}' is encountered and consumed, or at EOF.\n  void SkipRestOfBlock();\n\n  // -----------------------------------------------------------------\n  // Single-token consuming helpers\n  //\n  // These make parsing code more readable.\n\n  // True if the current token is TYPE_END.\n  inline bool AtEnd();\n\n  // True if the next token matches the given text.\n  inline bool LookingAt(const char* text);\n  // True if the next token is of the given type.\n  inline bool LookingAtType(io::Tokenizer::TokenType token_type);\n\n  // If the next token exactly matches the text given, consume it and return\n  // true.  Otherwise, return false without logging an error.\n  bool TryConsume(const char* text);\n\n  // These attempt to read some kind of token from the input.  If successful,\n  // they return true.  Otherwise they return false and add the given error\n  // to the error list.\n\n  // Consume a token with the exact text given.\n  bool Consume(const char* text, const char* error);\n  // Same as above, but automatically generates the error \"Expected \\\"text\\\".\",\n  // where \"text\" is the expected token text.\n  bool Consume(const char* text);\n  // Consume a token of type IDENTIFIER and store its text in \"output\".\n  bool ConsumeIdentifier(string* output, const char* error);\n  // Consume an integer and store its value in \"output\".\n  bool ConsumeInteger(int* output, const char* error);\n  // Consume a signed integer and store its value in \"output\".\n  bool ConsumeSignedInteger(int* output, const char* error);\n  // Consume a 64-bit integer and store its value in \"output\".  If the value\n  // is greater than max_value, an error will be reported.\n  bool ConsumeInteger64(uint64 max_value, uint64* output, const char* error);\n  // Consume a number and store its value in \"output\".  This will accept\n  // tokens of either INTEGER or FLOAT type.\n  bool ConsumeNumber(double* output, const char* error);\n  // Consume a string literal and store its (unescaped) value in \"output\".\n  bool ConsumeString(string* output, const char* error);\n\n  // Consume a token representing the end of the statement.  Comments between\n  // this token and the next will be harvested for documentation.  The given\n  // LocationRecorder should refer to the declaration that was just parsed;\n  // it will be populated with these comments.\n  //\n  // TODO(kenton):  The LocationRecorder is const because historically locations\n  //   have been passed around by const reference, for no particularly good\n  //   reason.  We should probably go through and change them all to mutable\n  //   pointer to make this more intuitive.\n  bool TryConsumeEndOfDeclaration(\n      const char* text, const LocationRecorder* location);\n  bool TryConsumeEndOfDeclarationFinishScope(\n      const char* text, const LocationRecorder* location);\n\n  bool ConsumeEndOfDeclaration(\n      const char* text, const LocationRecorder* location);\n\n  // -----------------------------------------------------------------\n  // Error logging helpers\n\n  // Invokes error_collector_->AddError(), if error_collector_ is not NULL.\n  void AddError(int line, int column, const string& error);\n\n  // Invokes error_collector_->AddError() with the line and column number\n  // of the current token.\n  void AddError(const string& error);\n\n  // Records a location in the SourceCodeInfo.location table (see\n  // descriptor.proto).  We use RAII to ensure that the start and end locations\n  // are recorded -- the constructor records the start location and the\n  // destructor records the end location.  Since the parser is\n  // recursive-descent, this works out beautifully.\n  class LIBPROTOBUF_EXPORT LocationRecorder {\n   public:\n    // Construct the file's \"root\" location.\n    LocationRecorder(Parser* parser);\n\n    // Construct a location that represents a declaration nested within the\n    // given parent.  E.g. a field's location is nested within the location\n    // for a message type.  The parent's path will be copied, so you should\n    // call AddPath() only to add the path components leading from the parent\n    // to the child (as opposed to leading from the root to the child).\n    LocationRecorder(const LocationRecorder& parent);\n\n    // Convenience constructors that call AddPath() one or two times.\n    LocationRecorder(const LocationRecorder& parent, int path1);\n    LocationRecorder(const LocationRecorder& parent, int path1, int path2);\n\n    ~LocationRecorder();\n\n    // Add a path component.  See SourceCodeInfo.Location.path in\n    // descriptor.proto.\n    void AddPath(int path_component);\n\n    // By default the location is considered to start at the current token at\n    // the time the LocationRecorder is created.  StartAt() sets the start\n    // location to the given token instead.\n    void StartAt(const io::Tokenizer::Token& token);\n\n    // Start at the same location as some other LocationRecorder.\n    void StartAt(const LocationRecorder& other);\n\n    // By default the location is considered to end at the previous token at\n    // the time the LocationRecorder is destroyed.  EndAt() sets the end\n    // location to the given token instead.\n    void EndAt(const io::Tokenizer::Token& token);\n\n    // Records the start point of this location to the SourceLocationTable that\n    // was passed to RecordSourceLocationsTo(), if any.  SourceLocationTable\n    // is an older way of keeping track of source locations which is still\n    // used in some places.\n    void RecordLegacyLocation(const Message* descriptor,\n        DescriptorPool::ErrorCollector::ErrorLocation location);\n\n    // Attaches leading and trailing comments to the location.  The two strings\n    // will be swapped into place, so after this is called *leading and\n    // *trailing will be empty.\n    //\n    // TODO(kenton):  See comment on TryConsumeEndOfDeclaration(), above, for\n    //   why this is const.\n    void AttachComments(string* leading, string* trailing,\n                        vector<string>* detached_comments) const;\n\n   private:\n    // Indexes of parent and current location in the parent\n    // SourceCodeInfo.location repeated field. For top-level elements,\n    // parent_index_ is -1.\n    Parser* parser_;\n    SourceCodeInfo::Location* location_;\n\n    void Init(const LocationRecorder& parent);\n  };\n\n  // =================================================================\n  // Parsers for various language constructs\n\n  // Parses the \"syntax = \\\"proto2\\\";\" line at the top of the file.  Returns\n  // false if it failed to parse or if the syntax identifier was not\n  // recognized.\n  bool ParseSyntaxIdentifier(const LocationRecorder& parent);\n\n  // These methods parse various individual bits of code.  They return\n  // false if they completely fail to parse the construct.  In this case,\n  // it is probably necessary to skip the rest of the statement to recover.\n  // However, if these methods return true, it does NOT mean that there\n  // were no errors; only that there were no *syntax* errors.  For instance,\n  // if a service method is defined using proper syntax but uses a primitive\n  // type as its input or output, ParseMethodField() still returns true\n  // and only reports the error by calling AddError().  In practice, this\n  // makes logic much simpler for the caller.\n\n  // Parse a top-level message, enum, service, etc.\n  bool ParseTopLevelStatement(FileDescriptorProto* file,\n                              const LocationRecorder& root_location);\n\n  // Parse various language high-level language construrcts.\n  bool ParseMessageDefinition(DescriptorProto* message,\n                              const LocationRecorder& message_location,\n                              const FileDescriptorProto* containing_file);\n  bool ParseEnumDefinition(EnumDescriptorProto* enum_type,\n                           const LocationRecorder& enum_location,\n                           const FileDescriptorProto* containing_file);\n  bool ParseServiceDefinition(ServiceDescriptorProto* service,\n                              const LocationRecorder& service_location,\n                              const FileDescriptorProto* containing_file);\n  bool ParsePackage(FileDescriptorProto* file,\n                    const LocationRecorder& root_location,\n                    const FileDescriptorProto* containing_file);\n  bool ParseImport(RepeatedPtrField<string>* dependency,\n                   RepeatedField<int32>* public_dependency,\n                   RepeatedField<int32>* weak_dependency,\n                   const LocationRecorder& root_location,\n                   const FileDescriptorProto* containing_file);\n\n  // These methods parse the contents of a message, enum, or service type and\n  // add them to the given object.  They consume the entire block including\n  // the beginning and ending brace.\n  bool ParseMessageBlock(DescriptorProto* message,\n                         const LocationRecorder& message_location,\n                         const FileDescriptorProto* containing_file);\n  bool ParseEnumBlock(EnumDescriptorProto* enum_type,\n                      const LocationRecorder& enum_location,\n                      const FileDescriptorProto* containing_file);\n  bool ParseServiceBlock(ServiceDescriptorProto* service,\n                         const LocationRecorder& service_location,\n                         const FileDescriptorProto* containing_file);\n\n  // Parse one statement within a message, enum, or service block, including\n  // final semicolon.\n  bool ParseMessageStatement(DescriptorProto* message,\n                             const LocationRecorder& message_location,\n                             const FileDescriptorProto* containing_file);\n  bool ParseEnumStatement(EnumDescriptorProto* message,\n                          const LocationRecorder& enum_location,\n                          const FileDescriptorProto* containing_file);\n  bool ParseServiceStatement(ServiceDescriptorProto* message,\n                             const LocationRecorder& service_location,\n                             const FileDescriptorProto* containing_file);\n\n  // Parse a field of a message.  If the field is a group, its type will be\n  // added to \"messages\".\n  //\n  // parent_location and location_field_number_for_nested_type are needed when\n  // parsing groups -- we need to generate a nested message type within the\n  // parent and record its location accordingly.  Since the parent could be\n  // either a FileDescriptorProto or a DescriptorProto, we must pass in the\n  // correct field number to use.\n  bool ParseMessageField(FieldDescriptorProto* field,\n                         RepeatedPtrField<DescriptorProto>* messages,\n                         const LocationRecorder& parent_location,\n                         int location_field_number_for_nested_type,\n                         const LocationRecorder& field_location,\n                         const FileDescriptorProto* containing_file);\n\n  // Like ParseMessageField() but expects the label has already been filled in\n  // by the caller.\n  bool ParseMessageFieldNoLabel(FieldDescriptorProto* field,\n                                RepeatedPtrField<DescriptorProto>* messages,\n                                const LocationRecorder& parent_location,\n                                int location_field_number_for_nested_type,\n                                const LocationRecorder& field_location,\n                                const FileDescriptorProto* containing_file);\n\n  // Parse an \"extensions\" declaration.\n  bool ParseExtensions(DescriptorProto* message,\n                       const LocationRecorder& extensions_location,\n                       const FileDescriptorProto* containing_file);\n\n  // Parse a \"reserved\" declaration.\n  bool ParseReserved(DescriptorProto* message,\n                     const LocationRecorder& message_location);\n  bool ParseReservedNames(DescriptorProto* message,\n                          const LocationRecorder& parent_location);\n  bool ParseReservedNumbers(DescriptorProto* message,\n                            const LocationRecorder& parent_location);\n\n  // Parse an \"extend\" declaration.  (See also comments for\n  // ParseMessageField().)\n  bool ParseExtend(RepeatedPtrField<FieldDescriptorProto>* extensions,\n                   RepeatedPtrField<DescriptorProto>* messages,\n                   const LocationRecorder& parent_location,\n                   int location_field_number_for_nested_type,\n                   const LocationRecorder& extend_location,\n                   const FileDescriptorProto* containing_file);\n\n  // Parse a \"oneof\" declaration.  The caller is responsible for setting\n  // oneof_decl->label() since it will have had to parse the label before it\n  // knew it was parsing a oneof.\n  bool ParseOneof(OneofDescriptorProto* oneof_decl,\n                  DescriptorProto* containing_type,\n                  int oneof_index,\n                  const LocationRecorder& oneof_location,\n                  const LocationRecorder& containing_type_location,\n                  const FileDescriptorProto* containing_file);\n\n  // Parse a single enum value within an enum block.\n  bool ParseEnumConstant(EnumValueDescriptorProto* enum_value,\n                         const LocationRecorder& enum_value_location,\n                         const FileDescriptorProto* containing_file);\n\n  // Parse enum constant options, i.e. the list in square brackets at the end\n  // of the enum constant value definition.\n  bool ParseEnumConstantOptions(EnumValueDescriptorProto* value,\n                                const LocationRecorder& enum_value_location,\n                                const FileDescriptorProto* containing_file);\n\n  // Parse a single method within a service definition.\n  bool ParseServiceMethod(MethodDescriptorProto* method,\n                          const LocationRecorder& method_location,\n                          const FileDescriptorProto* containing_file);\n\n\n  // Parse options of a single method or stream.\n  bool ParseMethodOptions(const LocationRecorder& parent_location,\n                          const FileDescriptorProto* containing_file,\n                          const int optionsFieldNumber,\n                          Message* mutable_options);\n\n  // Parse \"required\", \"optional\", or \"repeated\" and fill in \"label\"\n  // with the value. Returns true if such a label is consumed.\n  bool ParseLabel(FieldDescriptorProto::Label* label,\n                  const FileDescriptorProto* containing_file);\n\n  // Parse a type name and fill in \"type\" (if it is a primitive) or\n  // \"type_name\" (if it is not) with the type parsed.\n  bool ParseType(FieldDescriptorProto::Type* type,\n                 string* type_name);\n  // Parse a user-defined type and fill in \"type_name\" with the name.\n  // If a primitive type is named, it is treated as an error.\n  bool ParseUserDefinedType(string* type_name);\n\n  // Parses field options, i.e. the stuff in square brackets at the end\n  // of a field definition.  Also parses default value.\n  bool ParseFieldOptions(FieldDescriptorProto* field,\n                         const LocationRecorder& field_location,\n                         const FileDescriptorProto* containing_file);\n\n  // Parse the \"default\" option.  This needs special handling because its\n  // type is the field's type.\n  bool ParseDefaultAssignment(FieldDescriptorProto* field,\n                              const LocationRecorder& field_location,\n                              const FileDescriptorProto* containing_file);\n\n  bool ParseJsonName(FieldDescriptorProto* field,\n                     const LocationRecorder& field_location,\n                     const FileDescriptorProto* containing_file);\n\n  enum OptionStyle {\n    OPTION_ASSIGNMENT,  // just \"name = value\"\n    OPTION_STATEMENT    // \"option name = value;\"\n  };\n\n  // Parse a single option name/value pair, e.g. \"ctype = CORD\".  The name\n  // identifies a field of the given Message, and the value of that field\n  // is set to the parsed value.\n  bool ParseOption(Message* options,\n                   const LocationRecorder& options_location,\n                   const FileDescriptorProto* containing_file,\n                   OptionStyle style);\n\n  // Parses a single part of a multipart option name. A multipart name consists\n  // of names separated by dots. Each name is either an identifier or a series\n  // of identifiers separated by dots and enclosed in parentheses. E.g.,\n  // \"foo.(bar.baz).qux\".\n  bool ParseOptionNamePart(UninterpretedOption* uninterpreted_option,\n                           const LocationRecorder& part_location,\n                           const FileDescriptorProto* containing_file);\n\n  // Parses a string surrounded by balanced braces.  Strips off the outer\n  // braces and stores the enclosed string in *value.\n  // E.g.,\n  //     { foo }                     *value gets 'foo'\n  //     { foo { bar: box } }        *value gets 'foo { bar: box }'\n  //     {}                          *value gets ''\n  //\n  // REQUIRES: LookingAt(\"{\")\n  // When finished successfully, we are looking at the first token past\n  // the ending brace.\n  bool ParseUninterpretedBlock(string* value);\n\n  struct MapField {\n    // Whether the field is a map field.\n    bool is_map_field;\n    // The types of the key and value if they are primitive types.\n    FieldDescriptorProto::Type key_type;\n    FieldDescriptorProto::Type value_type;\n    // Or the type names string if the types are customized types.\n    string key_type_name;\n    string value_type_name;\n\n    MapField() : is_map_field(false) {}\n  };\n  // Desugar the map syntax to generate a nested map entry message.\n  void GenerateMapEntry(const MapField& map_field, FieldDescriptorProto* field,\n                        RepeatedPtrField<DescriptorProto>* messages);\n\n  // Whether fields without label default to optional fields.\n  bool DefaultToOptionalFields() const {\n    return syntax_identifier_ == \"proto3\";\n  }\n\n\n  bool ValidateEnum(const EnumDescriptorProto* proto);\n\n  // =================================================================\n\n  io::Tokenizer* input_;\n  io::ErrorCollector* error_collector_;\n  SourceCodeInfo* source_code_info_;\n  SourceLocationTable* source_location_table_;  // legacy\n  bool had_errors_;\n  bool require_syntax_identifier_;\n  bool stop_after_syntax_identifier_;\n  string syntax_identifier_;\n\n  // Leading doc comments for the next declaration.  These are not complete\n  // yet; use ConsumeEndOfDeclaration() to get the complete comments.\n  string upcoming_doc_comments_;\n\n  // Detached comments are not connected to any syntax entities. Elements in\n  // this vector are paragraphs of comments separated by empty lines. The\n  // detached comments will be put into the leading_detached_comments field for\n  // the next element (See SourceCodeInfo.Location in descriptor.proto), when\n  // ConsumeEndOfDeclaration() is called.\n  vector<string> upcoming_detached_comments_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Parser);\n};\n\n// A table mapping (descriptor, ErrorLocation) pairs -- as reported by\n// DescriptorPool when validating descriptors -- to line and column numbers\n// within the original source code.\n//\n// This is semi-obsolete:  FileDescriptorProto.source_code_info now contains\n// far more complete information about source locations.  However, as of this\n// writing you still need to use SourceLocationTable when integrating with\n// DescriptorPool.\nclass LIBPROTOBUF_EXPORT SourceLocationTable {\n public:\n  SourceLocationTable();\n  ~SourceLocationTable();\n\n  // Finds the precise location of the given error and fills in *line and\n  // *column with the line and column numbers.  If not found, sets *line to\n  // -1 and *column to 0 (since line = -1 is used to mean \"error has no exact\n  // location\" in the ErrorCollector interface).  Returns true if found, false\n  // otherwise.\n  bool Find(const Message* descriptor,\n            DescriptorPool::ErrorCollector::ErrorLocation location,\n            int* line, int* column) const;\n\n  // Adds a location to the table.\n  void Add(const Message* descriptor,\n           DescriptorPool::ErrorCollector::ErrorLocation location,\n           int line, int column);\n\n  // Clears the contents of the table.\n  void Clear();\n\n private:\n  typedef map<\n    pair<const Message*, DescriptorPool::ErrorCollector::ErrorLocation>,\n    pair<int, int> > LocationMap;\n  LocationMap location_map_;\n};\n\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_PARSER_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/parser_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <vector>\n#include <algorithm>\n#include <map>\n\n#include <google/protobuf/compiler/parser.h>\n\n#include <google/protobuf/io/tokenizer.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/text_format.h>\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/unittest_custom_options.pb.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n#include <google/protobuf/stubs/map_util.h>\n\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\n\nnamespace {\n\nclass MockErrorCollector : public io::ErrorCollector {\n public:\n  MockErrorCollector() {}\n  ~MockErrorCollector() {}\n\n  string text_;\n\n  // implements ErrorCollector ---------------------------------------\n  void AddError(int line, int column, const string& message) {\n    strings::SubstituteAndAppend(&text_, \"$0:$1: $2\\n\",\n                                 line, column, message);\n  }\n};\n\nclass MockValidationErrorCollector : public DescriptorPool::ErrorCollector {\n public:\n  MockValidationErrorCollector(const SourceLocationTable& source_locations,\n                               io::ErrorCollector* wrapped_collector)\n    : source_locations_(source_locations),\n      wrapped_collector_(wrapped_collector) {}\n  ~MockValidationErrorCollector() {}\n\n  // implements ErrorCollector ---------------------------------------\n  void AddError(const string& filename,\n                const string& element_name,\n                const Message* descriptor,\n                ErrorLocation location,\n                const string& message) {\n    int line, column;\n    source_locations_.Find(descriptor, location, &line, &column);\n    wrapped_collector_->AddError(line, column, message);\n  }\n\n private:\n  const SourceLocationTable& source_locations_;\n  io::ErrorCollector* wrapped_collector_;\n};\n\nclass ParserTest : public testing::Test {\n protected:\n  ParserTest()\n    : require_syntax_identifier_(false) {}\n\n  // Set up the parser to parse the given text.\n  void SetupParser(const char* text) {\n    raw_input_.reset(new io::ArrayInputStream(text, strlen(text)));\n    input_.reset(new io::Tokenizer(raw_input_.get(), &error_collector_));\n    parser_.reset(new Parser());\n    parser_->RecordErrorsTo(&error_collector_);\n    parser_->SetRequireSyntaxIdentifier(require_syntax_identifier_);\n  }\n\n  // Parse the input and expect that the resulting FileDescriptorProto matches\n  // the given output.  The output is a FileDescriptorProto in protocol buffer\n  // text format.\n  void ExpectParsesTo(const char* input, const char* output) {\n    SetupParser(input);\n    FileDescriptorProto actual, expected;\n\n    parser_->Parse(input_.get(), &actual);\n    EXPECT_EQ(io::Tokenizer::TYPE_END, input_->current().type);\n    ASSERT_EQ(\"\", error_collector_.text_);\n\n    // We don't cover SourceCodeInfo in these tests.\n    actual.clear_source_code_info();\n\n    // Parse the ASCII representation in order to canonicalize it.  We could\n    // just compare directly to actual.DebugString(), but that would require\n    // that the caller precisely match the formatting that DebugString()\n    // produces.\n    ASSERT_TRUE(TextFormat::ParseFromString(output, &expected));\n\n    // Compare by comparing debug strings.\n    // TODO(kenton):  Use differencer, once it is available.\n    EXPECT_EQ(expected.DebugString(), actual.DebugString());\n  }\n\n  // Parse the text and expect that the given errors are reported.\n  void ExpectHasErrors(const char* text, const char* expected_errors) {\n    ExpectHasEarlyExitErrors(text, expected_errors);\n    EXPECT_EQ(io::Tokenizer::TYPE_END, input_->current().type);\n  }\n\n  // Same as above but does not expect that the parser parses the complete\n  // input.\n  void ExpectHasEarlyExitErrors(const char* text, const char* expected_errors) {\n    SetupParser(text);\n    FileDescriptorProto file;\n    parser_->Parse(input_.get(), &file);\n    EXPECT_EQ(expected_errors, error_collector_.text_);\n  }\n\n  // Parse the text as a file and validate it (with a DescriptorPool), and\n  // expect that the validation step reports the given errors.\n  void ExpectHasValidationErrors(const char* text,\n                                 const char* expected_errors) {\n    SetupParser(text);\n    SourceLocationTable source_locations;\n    parser_->RecordSourceLocationsTo(&source_locations);\n\n    FileDescriptorProto file;\n    file.set_name(\"foo.proto\");\n    parser_->Parse(input_.get(), &file);\n    EXPECT_EQ(io::Tokenizer::TYPE_END, input_->current().type);\n    ASSERT_EQ(\"\", error_collector_.text_);\n\n    MockValidationErrorCollector validation_error_collector(\n      source_locations, &error_collector_);\n    EXPECT_TRUE(pool_.BuildFileCollectingErrors(\n      file, &validation_error_collector) == NULL);\n    EXPECT_EQ(expected_errors, error_collector_.text_);\n  }\n\n  MockErrorCollector error_collector_;\n  DescriptorPool pool_;\n\n  google::protobuf::scoped_ptr<io::ZeroCopyInputStream> raw_input_;\n  google::protobuf::scoped_ptr<io::Tokenizer> input_;\n  google::protobuf::scoped_ptr<Parser> parser_;\n  bool require_syntax_identifier_;\n};\n\n// ===================================================================\n\nTEST_F(ParserTest, StopAfterSyntaxIdentifier) {\n  SetupParser(\n    \"// blah\\n\"\n    \"syntax = \\\"foobar\\\";\\n\"\n    \"this line will not be parsed\\n\");\n  parser_->SetStopAfterSyntaxIdentifier(true);\n  EXPECT_TRUE(parser_->Parse(input_.get(), NULL));\n  EXPECT_EQ(\"\", error_collector_.text_);\n  EXPECT_EQ(\"foobar\", parser_->GetSyntaxIdentifier());\n}\n\nTEST_F(ParserTest, StopAfterOmittedSyntaxIdentifier) {\n  SetupParser(\n    \"// blah\\n\"\n    \"this line will not be parsed\\n\");\n  parser_->SetStopAfterSyntaxIdentifier(true);\n  EXPECT_TRUE(parser_->Parse(input_.get(), NULL));\n  EXPECT_EQ(\"\", error_collector_.text_);\n  EXPECT_EQ(\"\", parser_->GetSyntaxIdentifier());\n}\n\nTEST_F(ParserTest, StopAfterSyntaxIdentifierWithErrors) {\n  SetupParser(\n    \"// blah\\n\"\n    \"syntax = error;\\n\");\n  parser_->SetStopAfterSyntaxIdentifier(true);\n  EXPECT_FALSE(parser_->Parse(input_.get(), NULL));\n  EXPECT_EQ(\"1:9: Expected syntax identifier.\\n\", error_collector_.text_);\n}\n\nTEST_F(ParserTest, WarnIfSyntaxIdentifierOmmitted) {\n  SetupParser(\"message A {}\");\n  FileDescriptorProto file;\n  CaptureTestStderr();\n  EXPECT_TRUE(parser_->Parse(input_.get(), &file));\n  EXPECT_TRUE(\n      GetCapturedTestStderr().find(\"No syntax specified\") != string::npos);\n}\n\n// ===================================================================\n\ntypedef ParserTest ParseMessageTest;\n\nTEST_F(ParseMessageTest, IgnoreBOM) {\n  char input[] = \"   message TestMessage {\\n\"\n      \"  required int32 foo = 1;\\n\"\n      \"}\\n\";\n  // Set UTF-8 BOM.\n  input[0] = (char)0xEF;\n  input[1] = (char)0xBB;\n  input[2] = (char)0xBF;\n  ExpectParsesTo(input,\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  field { name:\\\"foo\\\" label:LABEL_REQUIRED type:TYPE_INT32 number:1 }\"\n    \"}\");\n}\n\nTEST_F(ParseMessageTest, BOMError) {\n  char input[] = \"   message TestMessage {\\n\"\n      \"  required int32 foo = 1;\\n\"\n      \"}\\n\";\n  input[0] = (char)0xEF;\n  ExpectHasErrors(input,\n                  \"0:1: Proto file starts with 0xEF but not UTF-8 BOM. \"\n                  \"Only UTF-8 is accepted for proto file.\\n\"\n                  \"0:0: Expected top-level statement (e.g. \\\"message\\\").\\n\");\n}\n\nTEST_F(ParseMessageTest, SimpleMessage) {\n  ExpectParsesTo(\n    \"message TestMessage {\\n\"\n    \"  required int32 foo = 1;\\n\"\n    \"}\\n\",\n\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  field { name:\\\"foo\\\" label:LABEL_REQUIRED type:TYPE_INT32 number:1 }\"\n    \"}\");\n}\n\nTEST_F(ParseMessageTest, ImplicitSyntaxIdentifier) {\n  require_syntax_identifier_ = false;\n  ExpectParsesTo(\n    \"message TestMessage {\\n\"\n    \"  required int32 foo = 1;\\n\"\n    \"}\\n\",\n\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  field { name:\\\"foo\\\" label:LABEL_REQUIRED type:TYPE_INT32 number:1 }\"\n    \"}\");\n  EXPECT_EQ(\"proto2\", parser_->GetSyntaxIdentifier());\n}\n\nTEST_F(ParseMessageTest, ExplicitSyntaxIdentifier) {\n  ExpectParsesTo(\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message TestMessage {\\n\"\n    \"  required int32 foo = 1;\\n\"\n    \"}\\n\",\n\n    \"syntax: 'proto2' \"\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  field { name:\\\"foo\\\" label:LABEL_REQUIRED type:TYPE_INT32 number:1 }\"\n    \"}\");\n  EXPECT_EQ(\"proto2\", parser_->GetSyntaxIdentifier());\n}\n\nTEST_F(ParseMessageTest, ExplicitRequiredSyntaxIdentifier) {\n  require_syntax_identifier_ = true;\n  ExpectParsesTo(\n    \"syntax = \\\"proto2\\\";\\n\"\n    \"message TestMessage {\\n\"\n    \"  required int32 foo = 1;\\n\"\n    \"}\\n\",\n\n    \"syntax: 'proto2' \"\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  field { name:\\\"foo\\\" label:LABEL_REQUIRED type:TYPE_INT32 number:1 }\"\n    \"}\");\n  EXPECT_EQ(\"proto2\", parser_->GetSyntaxIdentifier());\n}\n\nTEST_F(ParseMessageTest, SimpleFields) {\n  ExpectParsesTo(\n    \"message TestMessage {\\n\"\n    \"  required int32 foo = 15;\\n\"\n    \"  optional int32 bar = 34;\\n\"\n    \"  repeated int32 baz = 3;\\n\"\n    \"}\\n\",\n\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  field { name:\\\"foo\\\" label:LABEL_REQUIRED type:TYPE_INT32 number:15 }\"\n    \"  field { name:\\\"bar\\\" label:LABEL_OPTIONAL type:TYPE_INT32 number:34 }\"\n    \"  field { name:\\\"baz\\\" label:LABEL_REPEATED type:TYPE_INT32 number:3  }\"\n    \"}\");\n}\n\nTEST_F(ParseMessageTest, PrimitiveFieldTypes) {\n  ExpectParsesTo(\n    \"message TestMessage {\\n\"\n    \"  required int32    foo = 1;\\n\"\n    \"  required int64    foo = 1;\\n\"\n    \"  required uint32   foo = 1;\\n\"\n    \"  required uint64   foo = 1;\\n\"\n    \"  required sint32   foo = 1;\\n\"\n    \"  required sint64   foo = 1;\\n\"\n    \"  required fixed32  foo = 1;\\n\"\n    \"  required fixed64  foo = 1;\\n\"\n    \"  required sfixed32 foo = 1;\\n\"\n    \"  required sfixed64 foo = 1;\\n\"\n    \"  required float    foo = 1;\\n\"\n    \"  required double   foo = 1;\\n\"\n    \"  required string   foo = 1;\\n\"\n    \"  required bytes    foo = 1;\\n\"\n    \"  required bool     foo = 1;\\n\"\n    \"}\\n\",\n\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  field { name:\\\"foo\\\" label:LABEL_REQUIRED type:TYPE_INT32    number:1 }\"\n    \"  field { name:\\\"foo\\\" label:LABEL_REQUIRED type:TYPE_INT64    number:1 }\"\n    \"  field { name:\\\"foo\\\" label:LABEL_REQUIRED type:TYPE_UINT32   number:1 }\"\n    \"  field { name:\\\"foo\\\" label:LABEL_REQUIRED type:TYPE_UINT64   number:1 }\"\n    \"  field { name:\\\"foo\\\" label:LABEL_REQUIRED type:TYPE_SINT32   number:1 }\"\n    \"  field { name:\\\"foo\\\" label:LABEL_REQUIRED type:TYPE_SINT64   number:1 }\"\n    \"  field { name:\\\"foo\\\" label:LABEL_REQUIRED type:TYPE_FIXED32  number:1 }\"\n    \"  field { name:\\\"foo\\\" label:LABEL_REQUIRED type:TYPE_FIXED64  number:1 }\"\n    \"  field { name:\\\"foo\\\" label:LABEL_REQUIRED type:TYPE_SFIXED32 number:1 }\"\n    \"  field { name:\\\"foo\\\" label:LABEL_REQUIRED type:TYPE_SFIXED64 number:1 }\"\n    \"  field { name:\\\"foo\\\" label:LABEL_REQUIRED type:TYPE_FLOAT    number:1 }\"\n    \"  field { name:\\\"foo\\\" label:LABEL_REQUIRED type:TYPE_DOUBLE   number:1 }\"\n    \"  field { name:\\\"foo\\\" label:LABEL_REQUIRED type:TYPE_STRING   number:1 }\"\n    \"  field { name:\\\"foo\\\" label:LABEL_REQUIRED type:TYPE_BYTES    number:1 }\"\n    \"  field { name:\\\"foo\\\" label:LABEL_REQUIRED type:TYPE_BOOL     number:1 }\"\n    \"}\");\n}\n\nTEST_F(ParseMessageTest, FieldDefaults) {\n  ExpectParsesTo(\n    \"message TestMessage {\\n\"\n    \"  required int32  foo = 1 [default=  1  ];\\n\"\n    \"  required int32  foo = 1 [default= -2  ];\\n\"\n    \"  required int64  foo = 1 [default=  3  ];\\n\"\n    \"  required int64  foo = 1 [default= -4  ];\\n\"\n    \"  required uint32 foo = 1 [default=  5  ];\\n\"\n    \"  required uint64 foo = 1 [default=  6  ];\\n\"\n    \"  required float  foo = 1 [default=  7.5];\\n\"\n    \"  required float  foo = 1 [default= -8.5];\\n\"\n    \"  required float  foo = 1 [default=  9  ];\\n\"\n    \"  required double foo = 1 [default= 10.5];\\n\"\n    \"  required double foo = 1 [default=-11.5];\\n\"\n    \"  required double foo = 1 [default= 12  ];\\n\"\n    \"  required double foo = 1 [default= inf ];\\n\"\n    \"  required double foo = 1 [default=-inf ];\\n\"\n    \"  required double foo = 1 [default= nan ];\\n\"\n    \"  required string foo = 1 [default='13\\\\001'];\\n\"\n    \"  required string foo = 1 [default='a' \\\"b\\\" \\n \\\"c\\\"];\\n\"\n    \"  required bytes  foo = 1 [default='14\\\\002'];\\n\"\n    \"  required bytes  foo = 1 [default='a' \\\"b\\\" \\n 'c'];\\n\"\n    \"  required bool   foo = 1 [default=true ];\\n\"\n    \"  required Foo    foo = 1 [default=FOO  ];\\n\"\n\n    \"  required int32  foo = 1 [default= 0x7FFFFFFF];\\n\"\n    \"  required int32  foo = 1 [default=-0x80000000];\\n\"\n    \"  required uint32 foo = 1 [default= 0xFFFFFFFF];\\n\"\n    \"  required int64  foo = 1 [default= 0x7FFFFFFFFFFFFFFF];\\n\"\n    \"  required int64  foo = 1 [default=-0x8000000000000000];\\n\"\n    \"  required uint64 foo = 1 [default= 0xFFFFFFFFFFFFFFFF];\\n\"\n    \"  required double foo = 1 [default= 0xabcd];\\n\"\n    \"}\\n\",\n\n#define ETC \"name:\\\"foo\\\" label:LABEL_REQUIRED number:1\"\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  field { type:TYPE_INT32   default_value:\\\"1\\\"         \" ETC \" }\"\n    \"  field { type:TYPE_INT32   default_value:\\\"-2\\\"        \" ETC \" }\"\n    \"  field { type:TYPE_INT64   default_value:\\\"3\\\"         \" ETC \" }\"\n    \"  field { type:TYPE_INT64   default_value:\\\"-4\\\"        \" ETC \" }\"\n    \"  field { type:TYPE_UINT32  default_value:\\\"5\\\"         \" ETC \" }\"\n    \"  field { type:TYPE_UINT64  default_value:\\\"6\\\"         \" ETC \" }\"\n    \"  field { type:TYPE_FLOAT   default_value:\\\"7.5\\\"       \" ETC \" }\"\n    \"  field { type:TYPE_FLOAT   default_value:\\\"-8.5\\\"      \" ETC \" }\"\n    \"  field { type:TYPE_FLOAT   default_value:\\\"9\\\"         \" ETC \" }\"\n    \"  field { type:TYPE_DOUBLE  default_value:\\\"10.5\\\"      \" ETC \" }\"\n    \"  field { type:TYPE_DOUBLE  default_value:\\\"-11.5\\\"     \" ETC \" }\"\n    \"  field { type:TYPE_DOUBLE  default_value:\\\"12\\\"        \" ETC \" }\"\n    \"  field { type:TYPE_DOUBLE  default_value:\\\"inf\\\"       \" ETC \" }\"\n    \"  field { type:TYPE_DOUBLE  default_value:\\\"-inf\\\"      \" ETC \" }\"\n    \"  field { type:TYPE_DOUBLE  default_value:\\\"nan\\\"       \" ETC \" }\"\n    \"  field { type:TYPE_STRING  default_value:\\\"13\\\\001\\\"   \" ETC \" }\"\n    \"  field { type:TYPE_STRING  default_value:\\\"abc\\\"       \" ETC \" }\"\n    \"  field { type:TYPE_BYTES   default_value:\\\"14\\\\\\\\002\\\" \" ETC \" }\"\n    \"  field { type:TYPE_BYTES   default_value:\\\"abc\\\"       \" ETC \" }\"\n    \"  field { type:TYPE_BOOL    default_value:\\\"true\\\"      \" ETC \" }\"\n    \"  field { type_name:\\\"Foo\\\" default_value:\\\"FOO\\\"       \" ETC \" }\"\n\n    \"  field {\"\n    \"    type:TYPE_INT32   default_value:\\\"2147483647\\\"           \" ETC\n    \"  }\"\n    \"  field {\"\n    \"    type:TYPE_INT32   default_value:\\\"-2147483648\\\"          \" ETC\n    \"  }\"\n    \"  field {\"\n    \"    type:TYPE_UINT32  default_value:\\\"4294967295\\\"           \" ETC\n    \"  }\"\n    \"  field {\"\n    \"    type:TYPE_INT64   default_value:\\\"9223372036854775807\\\"  \" ETC\n    \"  }\"\n    \"  field {\"\n    \"    type:TYPE_INT64   default_value:\\\"-9223372036854775808\\\" \" ETC\n    \"  }\"\n    \"  field {\"\n    \"    type:TYPE_UINT64  default_value:\\\"18446744073709551615\\\" \" ETC\n    \"  }\"\n    \"  field {\"\n    \"    type:TYPE_DOUBLE  default_value:\\\"43981\\\"                \" ETC\n    \"  }\"\n    \"}\");\n#undef ETC\n}\n\nTEST_F(ParseMessageTest, FieldJsonName) {\n  ExpectParsesTo(\n    \"message TestMessage {\\n\"\n    \"  optional string foo = 1 [json_name = \\\"@type\\\"];\\n\"\n    \"}\\n\",\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  field {\\n\"\n    \"    name: \\\"foo\\\" label: LABEL_OPTIONAL type: TYPE_STRING number: 1\"\n    \"    json_name: \\\"@type\\\"\\n\"\n    \"  }\\n\"\n    \"}\\n\");\n}\n\nTEST_F(ParseMessageTest, FieldOptions) {\n  ExpectParsesTo(\n    \"message TestMessage {\\n\"\n    \"  optional string foo = 1\\n\"\n    \"      [ctype=CORD, (foo)=7, foo.(.bar.baz).qux.quux.(corge)=-33, \\n\"\n    \"       (quux)=\\\"x\\040y\\\", (baz.qux)=hey];\\n\"\n    \"}\\n\",\n\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  field { name: \\\"foo\\\" label: LABEL_OPTIONAL type: TYPE_STRING number: 1\"\n    \"          options { uninterpreted_option: { name { name_part: \\\"ctype\\\" \"\n    \"                                                   is_extension: false } \"\n    \"                                            identifier_value: \\\"CORD\\\"  }\"\n    \"                    uninterpreted_option: { name { name_part: \\\"foo\\\" \"\n    \"                                                   is_extension: true } \"\n    \"                                            positive_int_value: 7  }\"\n    \"                    uninterpreted_option: { name { name_part: \\\"foo\\\" \"\n    \"                                                   is_extension: false } \"\n    \"                                            name { name_part: \\\".bar.baz\\\"\"\n    \"                                                   is_extension: true } \"\n    \"                                            name { name_part: \\\"qux\\\" \"\n    \"                                                   is_extension: false } \"\n    \"                                            name { name_part: \\\"quux\\\" \"\n    \"                                                   is_extension: false } \"\n    \"                                            name { name_part: \\\"corge\\\" \"\n    \"                                                   is_extension: true } \"\n    \"                                            negative_int_value: -33 }\"\n    \"                    uninterpreted_option: { name { name_part: \\\"quux\\\" \"\n    \"                                                   is_extension: true } \"\n    \"                                            string_value: \\\"x y\\\" }\"\n    \"                    uninterpreted_option: { name { name_part: \\\"baz.qux\\\" \"\n    \"                                                   is_extension: true } \"\n    \"                                            identifier_value: \\\"hey\\\" }\"\n    \"          }\"\n    \"  }\"\n    \"}\");\n}\n\nTEST_F(ParseMessageTest, Oneof) {\n  ExpectParsesTo(\n    \"message TestMessage {\\n\"\n    \"  oneof foo {\\n\"\n    \"    int32 a = 1;\\n\"\n    \"    string b = 2;\\n\"\n    \"    TestMessage c = 3;\\n\"\n    \"    group D = 4 { optional int32 i = 5; }\\n\"\n    \"  }\\n\"\n    \"}\\n\",\n\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  field { name:\\\"a\\\" label:LABEL_OPTIONAL type:TYPE_INT32 number:1 \"\n    \"          oneof_index:0 }\"\n    \"  field { name:\\\"b\\\" label:LABEL_OPTIONAL type:TYPE_STRING number:2 \"\n    \"          oneof_index:0 }\"\n    \"  field { name:\\\"c\\\" label:LABEL_OPTIONAL type_name:\\\"TestMessage\\\" \"\n    \"          number:3 oneof_index:0 }\"\n    \"  field { name:\\\"d\\\" label:LABEL_OPTIONAL type:TYPE_GROUP \"\n    \"          type_name:\\\"D\\\" number:4 oneof_index:0 }\"\n    \"  oneof_decl {\"\n    \"    name: \\\"foo\\\"\"\n    \"  }\"\n    \"  nested_type {\"\n    \"    name: \\\"D\\\"\"\n    \"    field { name:\\\"i\\\" label:LABEL_OPTIONAL type:TYPE_INT32 number:5 }\"\n    \"  }\"\n    \"}\");\n}\n\nTEST_F(ParseMessageTest, MultipleOneofs) {\n  ExpectParsesTo(\n    \"message TestMessage {\\n\"\n    \"  oneof foo {\\n\"\n    \"    int32 a = 1;\\n\"\n    \"    string b = 2;\\n\"\n    \"  }\\n\"\n    \"  oneof bar {\\n\"\n    \"    int32 c = 3;\\n\"\n    \"    string d = 4;\\n\"\n    \"  }\\n\"\n    \"}\\n\",\n\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  field { name:\\\"a\\\" label:LABEL_OPTIONAL type:TYPE_INT32 number:1 \"\n    \"          oneof_index:0 }\"\n    \"  field { name:\\\"b\\\" label:LABEL_OPTIONAL type:TYPE_STRING number:2 \"\n    \"          oneof_index:0 }\"\n    \"  field { name:\\\"c\\\" label:LABEL_OPTIONAL type:TYPE_INT32 number:3 \"\n    \"          oneof_index:1 }\"\n    \"  field { name:\\\"d\\\" label:LABEL_OPTIONAL type:TYPE_STRING number:4 \"\n    \"          oneof_index:1 }\"\n    \"  oneof_decl {\"\n    \"    name: \\\"foo\\\"\"\n    \"  }\"\n    \"  oneof_decl {\"\n    \"    name: \\\"bar\\\"\"\n    \"  }\"\n    \"}\");\n}\n\nTEST_F(ParseMessageTest, Maps) {\n  ExpectParsesTo(\n    \"message TestMessage {\\n\"\n    \"  map<int32, string> primitive_type_map = 1;\\n\"\n    \"  map<KeyType, ValueType> composite_type_map = 2;\\n\"\n    \"}\\n\",\n\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  nested_type {\"\n    \"    name: \\\"PrimitiveTypeMapEntry\\\"\"\n    \"    field { \"\n    \"       name: \\\"key\\\" number: 1 label:LABEL_OPTIONAL\"\n    \"       type:TYPE_INT32\"\n    \"    }\"\n    \"    field { \"\n    \"       name: \\\"value\\\" number: 2 label:LABEL_OPTIONAL\"\n    \"       type:TYPE_STRING\"\n    \"    }\"\n    \"    options { map_entry: true }\"\n    \"  }\"\n    \"  nested_type {\"\n    \"    name: \\\"CompositeTypeMapEntry\\\"\"\n    \"    field { \"\n    \"       name: \\\"key\\\" number: 1 label:LABEL_OPTIONAL\"\n    \"       type_name: \\\"KeyType\\\"\"\n    \"    }\"\n    \"    field { \"\n    \"       name: \\\"value\\\" number: 2 label:LABEL_OPTIONAL\"\n    \"       type_name: \\\"ValueType\\\"\"\n    \"    }\"\n    \"    options { map_entry: true }\"\n    \"  }\"\n    \"  field {\"\n    \"    name: \\\"primitive_type_map\\\"\"\n    \"    label: LABEL_REPEATED\"\n    \"    type_name: \\\"PrimitiveTypeMapEntry\\\"\"\n    \"    number: 1\"\n    \"  }\"\n    \"  field {\"\n    \"    name: \\\"composite_type_map\\\"\"\n    \"    label: LABEL_REPEATED\"\n    \"    type_name: \\\"CompositeTypeMapEntry\\\"\"\n    \"    number: 2\"\n    \"  }\"\n    \"}\");\n}\n\nTEST_F(ParseMessageTest, Group) {\n  ExpectParsesTo(\n    \"message TestMessage {\\n\"\n    \"  optional group TestGroup = 1 {};\\n\"\n    \"}\\n\",\n\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  nested_type { name: \\\"TestGroup\\\" }\"\n    \"  field { name:\\\"testgroup\\\" label:LABEL_OPTIONAL number:1\"\n    \"          type:TYPE_GROUP type_name: \\\"TestGroup\\\" }\"\n    \"}\");\n}\n\nTEST_F(ParseMessageTest, NestedMessage) {\n  ExpectParsesTo(\n    \"message TestMessage {\\n\"\n    \"  message Nested {}\\n\"\n    \"  optional Nested test_nested = 1;\\n\"\n    \"}\\n\",\n\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  nested_type { name: \\\"Nested\\\" }\"\n    \"  field { name:\\\"test_nested\\\" label:LABEL_OPTIONAL number:1\"\n    \"          type_name: \\\"Nested\\\" }\"\n    \"}\");\n}\n\nTEST_F(ParseMessageTest, NestedEnum) {\n  ExpectParsesTo(\n    \"message TestMessage {\\n\"\n    \"  enum NestedEnum {}\\n\"\n    \"  optional NestedEnum test_enum = 1;\\n\"\n    \"}\\n\",\n\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  enum_type { name: \\\"NestedEnum\\\" }\"\n    \"  field { name:\\\"test_enum\\\" label:LABEL_OPTIONAL number:1\"\n    \"          type_name: \\\"NestedEnum\\\" }\"\n    \"}\");\n}\n\nTEST_F(ParseMessageTest, ReservedRange) {\n  ExpectParsesTo(\n    \"message TestMessage {\\n\"\n    \"  required int32 foo = 1;\\n\"\n    \"  reserved 2, 15, 9 to 11, 3;\\n\"\n    \"}\\n\",\n\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  field { name:\\\"foo\\\" label:LABEL_REQUIRED type:TYPE_INT32 number:1 }\"\n    \"  reserved_range { start:2   end:3         }\"\n    \"  reserved_range { start:15  end:16        }\"\n    \"  reserved_range { start:9   end:12        }\"\n    \"  reserved_range { start:3   end:4         }\"\n    \"}\");\n}\n\nTEST_F(ParseMessageTest, ReservedNames) {\n  ExpectParsesTo(\n    \"message TestMessage {\\n\"\n    \"  reserved \\\"foo\\\", \\\"bar\\\";\\n\"\n    \"}\\n\",\n\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  reserved_name: \\\"foo\\\"\"\n    \"  reserved_name: \\\"bar\\\"\"\n    \"}\");\n}\n\nTEST_F(ParseMessageTest, ExtensionRange) {\n  ExpectParsesTo(\n    \"message TestMessage {\\n\"\n    \"  extensions 10 to 19;\\n\"\n    \"  extensions 30 to max;\\n\"\n    \"}\\n\",\n\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  extension_range { start:10 end:20        }\"\n    \"  extension_range { start:30 end:536870912 }\"\n    \"}\");\n}\n\nTEST_F(ParseMessageTest, CompoundExtensionRange) {\n  ExpectParsesTo(\n    \"message TestMessage {\\n\"\n    \"  extensions 2, 15, 9 to 11, 100 to max, 3;\\n\"\n    \"}\\n\",\n\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  extension_range { start:2   end:3         }\"\n    \"  extension_range { start:15  end:16        }\"\n    \"  extension_range { start:9   end:12        }\"\n    \"  extension_range { start:100 end:536870912 }\"\n    \"  extension_range { start:3   end:4         }\"\n    \"}\");\n}\n\nTEST_F(ParseMessageTest, LargerMaxForMessageSetWireFormatMessages) {\n  // Messages using the message_set_wire_format option can accept larger\n  // extension numbers, as the numbers are not encoded as int32 field values\n  // rather than tags.\n  ExpectParsesTo(\n    \"message TestMessage {\\n\"\n    \"  extensions 4 to max;\\n\"\n    \"  option message_set_wire_format = true;\\n\"\n    \"}\\n\",\n\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"    extension_range { start:4 end: 0x7fffffff }\"\n    \"  options {\\n\"\n    \"    uninterpreted_option { \\n\"\n    \"      name {\\n\"\n    \"        name_part: \\\"message_set_wire_format\\\"\\n\"\n    \"        is_extension: false\\n\"\n    \"      }\\n\"\n    \"      identifier_value: \\\"true\\\"\\n\"\n    \"    }\\n\"\n    \"  }\\n\"\n    \"}\");\n}\n\nTEST_F(ParseMessageTest, Extensions) {\n  ExpectParsesTo(\n    \"extend Extendee1 { optional int32 foo = 12; }\\n\"\n    \"extend Extendee2 { repeated TestMessage bar = 22; }\\n\",\n\n    \"extension { name:\\\"foo\\\" label:LABEL_OPTIONAL type:TYPE_INT32 number:12\"\n    \"            extendee: \\\"Extendee1\\\" } \"\n    \"extension { name:\\\"bar\\\" label:LABEL_REPEATED number:22\"\n    \"            type_name:\\\"TestMessage\\\" extendee: \\\"Extendee2\\\" }\");\n}\n\nTEST_F(ParseMessageTest, ExtensionsInMessageScope) {\n  ExpectParsesTo(\n    \"message TestMessage {\\n\"\n    \"  extend Extendee1 { optional int32 foo = 12; }\\n\"\n    \"  extend Extendee2 { repeated TestMessage bar = 22; }\\n\"\n    \"}\\n\",\n\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  extension { name:\\\"foo\\\" label:LABEL_OPTIONAL type:TYPE_INT32 number:12\"\n    \"              extendee: \\\"Extendee1\\\" }\"\n    \"  extension { name:\\\"bar\\\" label:LABEL_REPEATED number:22\"\n    \"              type_name:\\\"TestMessage\\\" extendee: \\\"Extendee2\\\" }\"\n    \"}\");\n}\n\nTEST_F(ParseMessageTest, MultipleExtensionsOneExtendee) {\n  ExpectParsesTo(\n    \"extend Extendee1 {\\n\"\n    \"  optional int32 foo = 12;\\n\"\n    \"  repeated TestMessage bar = 22;\\n\"\n    \"}\\n\",\n\n    \"extension { name:\\\"foo\\\" label:LABEL_OPTIONAL type:TYPE_INT32 number:12\"\n    \"            extendee: \\\"Extendee1\\\" } \"\n    \"extension { name:\\\"bar\\\" label:LABEL_REPEATED number:22\"\n    \"            type_name:\\\"TestMessage\\\" extendee: \\\"Extendee1\\\" }\");\n}\n\nTEST_F(ParseMessageTest, OptionalLabelProto3) {\n  ExpectParsesTo(\n    \"syntax = \\\"proto3\\\";\\n\"\n    \"message TestMessage {\\n\"\n    \"  int32 foo = 1;\\n\"\n    \"}\\n\",\n\n    \"syntax: \\\"proto3\\\" \"\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  field { name:\\\"foo\\\" label:LABEL_OPTIONAL type:TYPE_INT32 number:1 } }\");\n}\n\n// ===================================================================\n\ntypedef ParserTest ParseEnumTest;\n\nTEST_F(ParseEnumTest, SimpleEnum) {\n  ExpectParsesTo(\n    \"enum TestEnum {\\n\"\n    \"  FOO = 0;\\n\"\n    \"}\\n\",\n\n    \"enum_type {\"\n    \"  name: \\\"TestEnum\\\"\"\n    \"  value { name:\\\"FOO\\\" number:0 }\"\n    \"}\");\n}\n\nTEST_F(ParseEnumTest, Values) {\n  ExpectParsesTo(\n    \"enum TestEnum {\\n\"\n    \"  FOO = 13;\\n\"\n    \"  BAR = -10;\\n\"\n    \"  BAZ = 500;\\n\"\n    \"  HEX_MAX = 0x7FFFFFFF;\\n\"\n    \"  HEX_MIN = -0x80000000;\\n\"\n    \"  INT_MAX = 2147483647;\\n\"\n    \"  INT_MIN = -2147483648;\\n\"\n    \"}\\n\",\n\n    \"enum_type {\"\n    \"  name: \\\"TestEnum\\\"\"\n    \"  value { name:\\\"FOO\\\" number:13 }\"\n    \"  value { name:\\\"BAR\\\" number:-10 }\"\n    \"  value { name:\\\"BAZ\\\" number:500 }\"\n    \"  value { name:\\\"HEX_MAX\\\" number:2147483647 }\"\n    \"  value { name:\\\"HEX_MIN\\\" number:-2147483648 }\"\n    \"  value { name:\\\"INT_MAX\\\" number:2147483647 }\"\n    \"  value { name:\\\"INT_MIN\\\" number:-2147483648 }\"\n    \"}\");\n}\n\nTEST_F(ParseEnumTest, ValueOptions) {\n  ExpectParsesTo(\n    \"enum TestEnum {\\n\"\n    \"  FOO = 13;\\n\"\n    \"  BAR = -10 [ (something.text) = 'abc' ];\\n\"\n    \"  BAZ = 500 [ (something.text) = 'def', other = 1 ];\\n\"\n    \"}\\n\",\n\n    \"enum_type {\"\n    \"  name: \\\"TestEnum\\\"\"\n    \"  value { name: \\\"FOO\\\" number: 13 }\"\n    \"  value { name: \\\"BAR\\\" number: -10 \"\n    \"    options { \"\n    \"      uninterpreted_option { \"\n    \"        name { name_part: \\\"something.text\\\" is_extension: true } \"\n    \"        string_value: \\\"abc\\\" \"\n    \"      } \"\n    \"    } \"\n    \"  } \"\n    \"  value { name: \\\"BAZ\\\" number: 500 \"\n    \"    options { \"\n    \"      uninterpreted_option { \"\n    \"        name { name_part: \\\"something.text\\\" is_extension: true } \"\n    \"        string_value: \\\"def\\\" \"\n    \"      } \"\n    \"      uninterpreted_option { \"\n    \"        name { name_part: \\\"other\\\" is_extension: false } \"\n    \"        positive_int_value: 1 \"\n    \"      } \"\n    \"    } \"\n    \"  } \"\n    \"}\");\n}\n\n// ===================================================================\n\ntypedef ParserTest ParseServiceTest;\n\nTEST_F(ParseServiceTest, SimpleService) {\n  ExpectParsesTo(\n    \"service TestService {\\n\"\n    \"  rpc Foo(In) returns (Out);\\n\"\n    \"}\\n\",\n\n    \"service {\"\n    \"  name: \\\"TestService\\\"\"\n    \"  method { name:\\\"Foo\\\" input_type:\\\"In\\\" output_type:\\\"Out\\\" }\"\n    \"}\");\n}\n\nTEST_F(ParseServiceTest, MethodsAndStreams) {\n  ExpectParsesTo(\n    \"service TestService {\\n\"\n    \"  rpc Foo(In1) returns (Out1);\\n\"\n    \"  rpc Bar(In2) returns (Out2);\\n\"\n    \"  rpc Baz(In3) returns (Out3);\\n\"\n    \"}\\n\",\n\n    \"service {\"\n    \"  name: \\\"TestService\\\"\"\n    \"  method { name:\\\"Foo\\\" input_type:\\\"In1\\\" output_type:\\\"Out1\\\" }\"\n    \"  method { name:\\\"Bar\\\" input_type:\\\"In2\\\" output_type:\\\"Out2\\\" }\"\n    \"  method { name:\\\"Baz\\\" input_type:\\\"In3\\\" output_type:\\\"Out3\\\" }\"\n    \"}\");\n}\n\n\n\n// ===================================================================\n// imports and packages\n\ntypedef ParserTest ParseMiscTest;\n\nTEST_F(ParseMiscTest, ParseImport) {\n  ExpectParsesTo(\n    \"import \\\"foo/bar/baz.proto\\\";\\n\",\n    \"dependency: \\\"foo/bar/baz.proto\\\"\");\n}\n\nTEST_F(ParseMiscTest, ParseMultipleImports) {\n  ExpectParsesTo(\n    \"import \\\"foo.proto\\\";\\n\"\n    \"import \\\"bar.proto\\\";\\n\"\n    \"import \\\"baz.proto\\\";\\n\",\n    \"dependency: \\\"foo.proto\\\"\"\n    \"dependency: \\\"bar.proto\\\"\"\n    \"dependency: \\\"baz.proto\\\"\");\n}\n\nTEST_F(ParseMiscTest, ParsePublicImports) {\n  ExpectParsesTo(\n    \"import \\\"foo.proto\\\";\\n\"\n    \"import public \\\"bar.proto\\\";\\n\"\n    \"import \\\"baz.proto\\\";\\n\"\n    \"import public \\\"qux.proto\\\";\\n\",\n    \"dependency: \\\"foo.proto\\\"\"\n    \"dependency: \\\"bar.proto\\\"\"\n    \"dependency: \\\"baz.proto\\\"\"\n    \"dependency: \\\"qux.proto\\\"\"\n    \"public_dependency: 1 \"\n    \"public_dependency: 3 \");\n}\n\nTEST_F(ParseMiscTest, ParsePackage) {\n  ExpectParsesTo(\n    \"package foo.bar.baz;\\n\",\n    \"package: \\\"foo.bar.baz\\\"\");\n}\n\nTEST_F(ParseMiscTest, ParsePackageWithSpaces) {\n  ExpectParsesTo(\n    \"package foo   .   bar.  \\n\"\n    \"  baz;\\n\",\n    \"package: \\\"foo.bar.baz\\\"\");\n}\n\n// ===================================================================\n// options\n\nTEST_F(ParseMiscTest, ParseFileOptions) {\n  ExpectParsesTo(\n    \"option java_package = \\\"com.google.foo\\\";\\n\"\n    \"option optimize_for = CODE_SIZE;\",\n\n    \"options {\"\n    \"uninterpreted_option { name { name_part: \\\"java_package\\\" \"\n    \"                              is_extension: false }\"\n    \"                       string_value: \\\"com.google.foo\\\"} \"\n    \"uninterpreted_option { name { name_part: \\\"optimize_for\\\" \"\n    \"                              is_extension: false }\"\n    \"                       identifier_value: \\\"CODE_SIZE\\\" } \"\n    \"}\");\n}\n\n// ===================================================================\n// Error tests\n//\n// There are a very large number of possible errors that the parser could\n// report, so it's infeasible to test every single one of them.  Instead,\n// we test each unique call to AddError() in parser.h.  This does not mean\n// we are testing every possible error that Parser can generate because\n// each variant of the Consume() helper only counts as one unique call to\n// AddError().\n\ntypedef ParserTest ParseErrorTest;\n\nTEST_F(ParseErrorTest, MissingSyntaxIdentifier) {\n  require_syntax_identifier_ = true;\n  ExpectHasEarlyExitErrors(\"message TestMessage {}\",\n                           \"0:0: File must begin with a syntax statement, e.g. \"\n                           \"'syntax = \\\"proto2\\\";'.\\n\");\n  EXPECT_EQ(\"\", parser_->GetSyntaxIdentifier());\n}\n\nTEST_F(ParseErrorTest, UnknownSyntaxIdentifier) {\n  ExpectHasEarlyExitErrors(\n    \"syntax = \\\"no_such_syntax\\\";\",\n    \"0:9: Unrecognized syntax identifier \\\"no_such_syntax\\\".  This parser \"\n      \"only recognizes \\\"proto2\\\" and \\\"proto3\\\".\\n\");\n  EXPECT_EQ(\"no_such_syntax\", parser_->GetSyntaxIdentifier());\n}\n\nTEST_F(ParseErrorTest, SimpleSyntaxError) {\n  ExpectHasErrors(\n    \"message TestMessage @#$ { blah }\",\n    \"0:20: Expected \\\"{\\\".\\n\");\n  EXPECT_EQ(\"proto2\", parser_->GetSyntaxIdentifier());\n}\n\nTEST_F(ParseErrorTest, ExpectedTopLevel) {\n  ExpectHasErrors(\n    \"blah;\",\n    \"0:0: Expected top-level statement (e.g. \\\"message\\\").\\n\");\n}\n\nTEST_F(ParseErrorTest, UnmatchedCloseBrace) {\n  // This used to cause an infinite loop.  Doh.\n  ExpectHasErrors(\n    \"}\",\n    \"0:0: Expected top-level statement (e.g. \\\"message\\\").\\n\"\n    \"0:0: Unmatched \\\"}\\\".\\n\");\n}\n\n// -------------------------------------------------------------------\n// Message errors\n\nTEST_F(ParseErrorTest, MessageMissingName) {\n  ExpectHasErrors(\n    \"message {}\",\n    \"0:8: Expected message name.\\n\");\n}\n\nTEST_F(ParseErrorTest, MessageMissingBody) {\n  ExpectHasErrors(\n    \"message TestMessage;\",\n    \"0:19: Expected \\\"{\\\".\\n\");\n}\n\nTEST_F(ParseErrorTest, EofInMessage) {\n  ExpectHasErrors(\n    \"message TestMessage {\",\n    \"0:21: Reached end of input in message definition (missing '}').\\n\");\n}\n\nTEST_F(ParseErrorTest, MissingFieldNumber) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  optional int32 foo;\\n\"\n    \"}\\n\",\n    \"1:20: Missing field number.\\n\");\n}\n\nTEST_F(ParseErrorTest, ExpectedFieldNumber) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  optional int32 foo = ;\\n\"\n    \"}\\n\",\n    \"1:23: Expected field number.\\n\");\n}\n\nTEST_F(ParseErrorTest, FieldNumberOutOfRange) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  optional int32 foo = 0x100000000;\\n\"\n    \"}\\n\",\n    \"1:23: Integer out of range.\\n\");\n}\n\nTEST_F(ParseErrorTest, MissingLabel) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  int32 foo = 1;\\n\"\n    \"}\\n\",\n    \"1:2: Expected \\\"required\\\", \\\"optional\\\", or \\\"repeated\\\".\\n\");\n}\n\nTEST_F(ParseErrorTest, ExpectedOptionName) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  optional uint32 foo = 1 [];\\n\"\n    \"}\\n\",\n    \"1:27: Expected identifier.\\n\");\n}\n\nTEST_F(ParseErrorTest, NonExtensionOptionNameBeginningWithDot) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  optional uint32 foo = 1 [.foo=1];\\n\"\n    \"}\\n\",\n    \"1:27: Expected identifier.\\n\");\n}\n\nTEST_F(ParseErrorTest, DefaultValueTypeMismatch) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  optional uint32 foo = 1 [default=true];\\n\"\n    \"}\\n\",\n    \"1:35: Expected integer for field default value.\\n\");\n}\n\nTEST_F(ParseErrorTest, DefaultValueNotBoolean) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  optional bool foo = 1 [default=blah];\\n\"\n    \"}\\n\",\n    \"1:33: Expected \\\"true\\\" or \\\"false\\\".\\n\");\n}\n\nTEST_F(ParseErrorTest, DefaultValueNotString) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  optional string foo = 1 [default=1];\\n\"\n    \"}\\n\",\n    \"1:35: Expected string for field default value.\\n\");\n}\n\nTEST_F(ParseErrorTest, DefaultValueUnsignedNegative) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  optional uint32 foo = 1 [default=-1];\\n\"\n    \"}\\n\",\n    \"1:36: Unsigned field can't have negative default value.\\n\");\n}\n\nTEST_F(ParseErrorTest, DefaultValueTooLarge) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  optional int32  foo = 1 [default= 0x80000000];\\n\"\n    \"  optional int32  foo = 1 [default=-0x80000001];\\n\"\n    \"  optional uint32 foo = 1 [default= 0x100000000];\\n\"\n    \"  optional int64  foo = 1 [default= 0x80000000000000000];\\n\"\n    \"  optional int64  foo = 1 [default=-0x80000000000000001];\\n\"\n    \"  optional uint64 foo = 1 [default= 0x100000000000000000];\\n\"\n    \"}\\n\",\n    \"1:36: Integer out of range.\\n\"\n    \"2:36: Integer out of range.\\n\"\n    \"3:36: Integer out of range.\\n\"\n    \"4:36: Integer out of range.\\n\"\n    \"5:36: Integer out of range.\\n\"\n    \"6:36: Integer out of range.\\n\");\n}\n\nTEST_F(ParseErrorTest, JsonNameNotString) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  optional string foo = 1 [json_name=1];\\n\"\n    \"}\\n\",\n    \"1:37: Expected string for JSON name.\\n\");\n}\n\nTEST_F(ParseErrorTest, DuplicateJsonName) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  optional uint32 foo = 1 [json_name=\\\"a\\\",json_name=\\\"b\\\"];\\n\"\n    \"}\\n\",\n    \"1:41: Already set option \\\"json_name\\\".\\n\");\n}\n\nTEST_F(ParseErrorTest, EnumValueOutOfRange) {\n  ExpectHasErrors(\n    \"enum TestEnum {\\n\"\n    \"  HEX_TOO_BIG   =  0x80000000;\\n\"\n    \"  HEX_TOO_SMALL = -0x80000001;\\n\"\n    \"  INT_TOO_BIG   =  2147483648;\\n\"\n    \"  INT_TOO_SMALL = -2147483649;\\n\"\n    \"}\\n\",\n    \"1:19: Integer out of range.\\n\"\n    \"2:19: Integer out of range.\\n\"\n    \"3:19: Integer out of range.\\n\"\n    \"4:19: Integer out of range.\\n\");\n}\n\nTEST_F(ParseErrorTest, EnumAllowAliasFalse) {\n  ExpectHasErrors(\n    \"enum Foo {\\n\"\n    \"  option allow_alias = false;\\n\"\n    \"  BAR = 1;\\n\"\n    \"  BAZ = 2;\\n\"\n    \"}\\n\",\n    \"5:0: \\\"Foo\\\" declares 'option allow_alias = false;' which has no effect. \"\n    \"Please remove the declaration.\\n\");\n}\n\nTEST_F(ParseErrorTest, UnnecessaryEnumAllowAlias) {\n  ExpectHasErrors(\n    \"enum Foo {\\n\"\n    \"  option allow_alias = true;\\n\"\n    \"  BAR = 1;\\n\"\n    \"  BAZ = 2;\\n\"\n    \"}\\n\",\n    \"5:0: \\\"Foo\\\" declares support for enum aliases but no enum values share \"\n    \"field numbers. Please remove the unnecessary 'option allow_alias = true;' \"\n    \"declaration.\\n\");\n}\n\nTEST_F(ParseErrorTest, DefaultValueMissing) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  optional uint32 foo = 1 [default=];\\n\"\n    \"}\\n\",\n    \"1:35: Expected integer for field default value.\\n\");\n}\n\nTEST_F(ParseErrorTest, DefaultValueForGroup) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  optional group Foo = 1 [default=blah] {}\\n\"\n    \"}\\n\",\n    \"1:34: Messages can't have default values.\\n\");\n}\n\nTEST_F(ParseErrorTest, DuplicateDefaultValue) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  optional uint32 foo = 1 [default=1,default=2];\\n\"\n    \"}\\n\",\n    \"1:37: Already set option \\\"default\\\".\\n\");\n}\n\nTEST_F(ParseErrorTest, MissingOneofName) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  oneof {\\n\"\n    \"    int32 bar = 1;\\n\"\n    \"  }\\n\"\n    \"}\\n\",\n    \"1:8: Expected oneof name.\\n\");\n}\n\nTEST_F(ParseErrorTest, LabelInOneof) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  oneof foo {\\n\"\n    \"    optional int32 bar = 1;\\n\"\n    \"  }\\n\"\n    \"}\\n\",\n    \"2:4: Fields in oneofs must not have labels (required / optional \"\n      \"/ repeated).\\n\");\n}\n\nTEST_F(ParseErrorTest, MapInOneof) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  oneof foo {\\n\"\n    \"    map<int32, int32> foo_map = 1;\\n\"\n    \"    map message_field = 2;\\n\"  // a normal message field is OK\n    \"  }\\n\"\n    \"}\\n\",\n    \"2:7: Map fields are not allowed in oneofs.\\n\");\n}\n\nTEST_F(ParseErrorTest, LabelForMap) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  optional map<int32, int32> int_map = 1;\\n\"\n    \"  required map<int32, int32> int_map2 = 2;\\n\"\n    \"  repeated map<int32, int32> int_map3 = 3;\\n\"\n    \"  optional map map_message = 4;\\n\"  // a normal message field is OK\n    \"}\\n\",\n    \"1:14: Field labels (required/optional/repeated) are not allowed on map \"\n    \"fields.\\n\"\n    \"2:14: Field labels (required/optional/repeated) are not allowed on map \"\n    \"fields.\\n\"\n    \"3:14: Field labels (required/optional/repeated) are not allowed on map \"\n    \"fields.\\n\");\n}\n\nTEST_F(ParseErrorTest, MalformedMaps) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  map map_message = 1;\\n\"   // a normal message field lacking label\n    \"  map<string> str_map = 2;\\n\"\n    \"  map<string,> str_map2 = 3;\\n\"\n    \"  map<,string> str_map3 = 4;\\n\"\n    \"  map<> empty_map = 5;\\n\"\n    \"  map<string,string str_map6 = 6;\\n\"\n    \"}\"\n    \"extend SomeMessage {\\n\"\n    \"  map<int32, int32> int_map = 1;\\n\"\n    \"}\",\n    \"1:6: Expected \\\"required\\\", \\\"optional\\\", or \\\"repeated\\\".\\n\"\n    \"2:12: Expected \\\",\\\".\\n\"\n    \"3:13: Expected type name.\\n\"\n    \"4:6: Expected type name.\\n\"\n    \"5:6: Expected type name.\\n\"\n    \"6:20: Expected \\\">\\\".\\n\"\n    \"8:5: Map fields are not allowed to be extensions.\\n\");\n}\n\nTEST_F(ParseErrorTest, GroupNotCapitalized) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  optional group foo = 1 {}\\n\"\n    \"}\\n\",\n    \"1:17: Group names must start with a capital letter.\\n\");\n}\n\nTEST_F(ParseErrorTest, GroupMissingBody) {\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  optional group Foo = 1;\\n\"\n    \"}\\n\",\n    \"1:24: Missing group body.\\n\");\n}\n\nTEST_F(ParseErrorTest, ExtendingPrimitive) {\n  ExpectHasErrors(\n    \"extend int32 { optional string foo = 4; }\\n\",\n    \"0:7: Expected message type.\\n\");\n}\n\nTEST_F(ParseErrorTest, ErrorInExtension) {\n  ExpectHasErrors(\n    \"message Foo { extensions 100 to 199; }\\n\"\n    \"extend Foo { optional string foo; }\\n\",\n    \"1:32: Missing field number.\\n\");\n}\n\nTEST_F(ParseErrorTest, MultipleParseErrors) {\n  // When a statement has a parse error, the parser should be able to continue\n  // parsing at the next statement.\n  ExpectHasErrors(\n    \"message TestMessage {\\n\"\n    \"  optional int32 foo;\\n\"\n    \"  !invalid statement ending in a block { blah blah { blah } blah }\\n\"\n    \"  optional int32 bar = 3 {}\\n\"\n    \"}\\n\",\n    \"1:20: Missing field number.\\n\"\n    \"2:2: Expected \\\"required\\\", \\\"optional\\\", or \\\"repeated\\\".\\n\"\n    \"2:2: Expected type name.\\n\"\n    \"3:25: Expected \\\";\\\".\\n\");\n}\n\nTEST_F(ParseErrorTest, EofInAggregateValue) {\n  ExpectHasErrors(\n      \"option (fileopt) = { i:100\\n\",\n      \"1:0: Unexpected end of stream while parsing aggregate value.\\n\");\n}\n\nTEST_F(ParseErrorTest, ExplicitOptionalLabelProto3) {\n  ExpectHasErrors(\n      \"syntax = 'proto3';\\n\"\n      \"message TestMessage {\\n\"\n      \"  optional int32 foo = 1;\\n\"\n      \"}\\n\",\n      \"2:11: Explicit 'optional' labels are disallowed in the Proto3 syntax. \"\n      \"To define 'optional' fields in Proto3, simply remove the 'optional' \"\n      \"label, as fields are 'optional' by default.\\n\");\n}\n\n\n// -------------------------------------------------------------------\n// Enum errors\n\nTEST_F(ParseErrorTest, EofInEnum) {\n  ExpectHasErrors(\n    \"enum TestEnum {\",\n    \"0:15: Reached end of input in enum definition (missing '}').\\n\");\n}\n\nTEST_F(ParseErrorTest, EnumValueMissingNumber) {\n  ExpectHasErrors(\n    \"enum TestEnum {\\n\"\n    \"  FOO;\\n\"\n    \"}\\n\",\n    \"1:5: Missing numeric value for enum constant.\\n\");\n}\n\n// -------------------------------------------------------------------\n// Reserved field number errors\n\nTEST_F(ParseErrorTest, ReservedMaxNotAllowed) {\n  ExpectHasErrors(\n    \"message Foo {\\n\"\n    \"  reserved 10 to max;\\n\"\n    \"}\\n\",\n    \"1:17: Expected integer.\\n\");\n}\n\nTEST_F(ParseErrorTest, ReservedMixNameAndNumber) {\n  ExpectHasErrors(\n    \"message Foo {\\n\"\n    \"  reserved 10, \\\"foo\\\";\\n\"\n    \"}\\n\",\n    \"1:15: Expected field number range.\\n\");\n}\n\nTEST_F(ParseErrorTest, ReservedMissingQuotes) {\n  ExpectHasErrors(\n    \"message Foo {\\n\"\n    \"  reserved foo;\\n\"\n    \"}\\n\",\n    \"1:11: Expected field name or number range.\\n\");\n}\n\n// -------------------------------------------------------------------\n// Service errors\n\nTEST_F(ParseErrorTest, EofInService) {\n  ExpectHasErrors(\n    \"service TestService {\",\n    \"0:21: Reached end of input in service definition (missing '}').\\n\");\n}\n\nTEST_F(ParseErrorTest, ServiceMethodPrimitiveParams) {\n  ExpectHasErrors(\n    \"service TestService {\\n\"\n    \"  rpc Foo(int32) returns (string);\\n\"\n    \"}\\n\",\n    \"1:10: Expected message type.\\n\"\n    \"1:26: Expected message type.\\n\");\n}\n\n\nTEST_F(ParseErrorTest, EofInMethodOptions) {\n  ExpectHasErrors(\n    \"service TestService {\\n\"\n    \"  rpc Foo(Bar) returns(Bar) {\",\n    \"1:29: Reached end of input in method options (missing '}').\\n\"\n    \"1:29: Reached end of input in service definition (missing '}').\\n\");\n}\n\n\nTEST_F(ParseErrorTest, PrimitiveMethodInput) {\n  ExpectHasErrors(\n    \"service TestService {\\n\"\n    \"  rpc Foo(int32) returns(Bar);\\n\"\n    \"}\\n\",\n    \"1:10: Expected message type.\\n\");\n}\n\n\nTEST_F(ParseErrorTest, MethodOptionTypeError) {\n  // This used to cause an infinite loop.\n  ExpectHasErrors(\n    \"message Baz {}\\n\"\n    \"service Foo {\\n\"\n    \"  rpc Bar(Baz) returns(Baz) { option invalid syntax; }\\n\"\n    \"}\\n\",\n    \"2:45: Expected \\\"=\\\".\\n\");\n}\n\n\n// -------------------------------------------------------------------\n// Import and package errors\n\nTEST_F(ParseErrorTest, ImportNotQuoted) {\n  ExpectHasErrors(\n    \"import foo;\\n\",\n    \"0:7: Expected a string naming the file to import.\\n\");\n}\n\nTEST_F(ParseErrorTest, MultiplePackagesInFile) {\n  ExpectHasErrors(\n    \"package foo;\\n\"\n    \"package bar;\\n\",\n    \"1:0: Multiple package definitions.\\n\");\n}\n\n// ===================================================================\n// Test that errors detected by DescriptorPool correctly report line and\n// column numbers.  We have one test for every call to RecordLocation() in\n// parser.cc.\n\ntypedef ParserTest ParserValidationErrorTest;\n\nTEST_F(ParserValidationErrorTest, PackageNameError) {\n  // Create another file which defines symbol \"foo\".\n  FileDescriptorProto other_file;\n  other_file.set_name(\"bar.proto\");\n  other_file.add_message_type()->set_name(\"foo\");\n  EXPECT_TRUE(pool_.BuildFile(other_file) != NULL);\n\n  // Now try to define it as a package.\n  ExpectHasValidationErrors(\n    \"package foo.bar;\",\n    \"0:8: \\\"foo\\\" is already defined (as something other than a package) \"\n      \"in file \\\"bar.proto\\\".\\n\");\n}\n\nTEST_F(ParserValidationErrorTest, MessageNameError) {\n  ExpectHasValidationErrors(\n    \"message Foo {}\\n\"\n    \"message Foo {}\\n\",\n    \"1:8: \\\"Foo\\\" is already defined.\\n\");\n}\n\nTEST_F(ParserValidationErrorTest, FieldNameError) {\n  ExpectHasValidationErrors(\n    \"message Foo {\\n\"\n    \"  optional int32 bar = 1;\\n\"\n    \"  optional int32 bar = 2;\\n\"\n    \"}\\n\",\n    \"2:17: \\\"bar\\\" is already defined in \\\"Foo\\\".\\n\");\n}\n\nTEST_F(ParserValidationErrorTest, FieldTypeError) {\n  ExpectHasValidationErrors(\n    \"message Foo {\\n\"\n    \"  optional Baz bar = 1;\\n\"\n    \"}\\n\",\n    \"1:11: \\\"Baz\\\" is not defined.\\n\");\n}\n\nTEST_F(ParserValidationErrorTest, FieldNumberError) {\n  ExpectHasValidationErrors(\n    \"message Foo {\\n\"\n    \"  optional int32 bar = 0;\\n\"\n    \"}\\n\",\n    \"1:23: Field numbers must be positive integers.\\n\");\n}\n\nTEST_F(ParserValidationErrorTest, FieldExtendeeError) {\n  ExpectHasValidationErrors(\n    \"extend Baz { optional int32 bar = 1; }\\n\",\n    \"0:7: \\\"Baz\\\" is not defined.\\n\");\n}\n\nTEST_F(ParserValidationErrorTest, FieldDefaultValueError) {\n  ExpectHasValidationErrors(\n    \"enum Baz { QUX = 1; }\\n\"\n    \"message Foo {\\n\"\n    \"  optional Baz bar = 1 [default=NO_SUCH_VALUE];\\n\"\n    \"}\\n\",\n    \"2:32: Enum type \\\"Baz\\\" has no value named \\\"NO_SUCH_VALUE\\\".\\n\");\n}\n\nTEST_F(ParserValidationErrorTest, FileOptionNameError) {\n  ExpectHasValidationErrors(\n    \"option foo = 5;\",\n    \"0:7: Option \\\"foo\\\" unknown.\\n\");\n}\n\nTEST_F(ParserValidationErrorTest, FileOptionValueError) {\n  ExpectHasValidationErrors(\n    \"option java_outer_classname = 5;\",\n    \"0:30: Value must be quoted string for string option \"\n    \"\\\"google.protobuf.FileOptions.java_outer_classname\\\".\\n\");\n}\n\nTEST_F(ParserValidationErrorTest, FieldOptionNameError) {\n  ExpectHasValidationErrors(\n    \"message Foo {\\n\"\n    \"  optional bool bar = 1 [foo=1];\\n\"\n    \"}\\n\",\n    \"1:25: Option \\\"foo\\\" unknown.\\n\");\n}\n\nTEST_F(ParserValidationErrorTest, FieldOptionValueError) {\n  ExpectHasValidationErrors(\n    \"message Foo {\\n\"\n    \"  optional int32 bar = 1 [ctype=1];\\n\"\n    \"}\\n\",\n    \"1:32: Value must be identifier for enum-valued option \"\n    \"\\\"google.protobuf.FieldOptions.ctype\\\".\\n\");\n}\n\nTEST_F(ParserValidationErrorTest, ExtensionRangeNumberError) {\n  ExpectHasValidationErrors(\n    \"message Foo {\\n\"\n    \"  extensions 0;\\n\"\n    \"}\\n\",\n    \"1:13: Extension numbers must be positive integers.\\n\");\n}\n\nTEST_F(ParserValidationErrorTest, EnumNameError) {\n  ExpectHasValidationErrors(\n    \"enum Foo {A = 1;}\\n\"\n    \"enum Foo {B = 1;}\\n\",\n    \"1:5: \\\"Foo\\\" is already defined.\\n\");\n}\n\nTEST_F(ParserValidationErrorTest, EnumValueNameError) {\n  ExpectHasValidationErrors(\n    \"enum Foo {\\n\"\n    \"  BAR = 1;\\n\"\n    \"  BAR = 1;\\n\"\n    \"}\\n\",\n    \"2:2: \\\"BAR\\\" is already defined.\\n\");\n}\n\nTEST_F(ParserValidationErrorTest, ServiceNameError) {\n  ExpectHasValidationErrors(\n    \"service Foo {}\\n\"\n    \"service Foo {}\\n\",\n    \"1:8: \\\"Foo\\\" is already defined.\\n\");\n}\n\nTEST_F(ParserValidationErrorTest, MethodNameError) {\n  ExpectHasValidationErrors(\n    \"message Baz {}\\n\"\n    \"service Foo {\\n\"\n    \"  rpc Bar(Baz) returns(Baz);\\n\"\n    \"  rpc Bar(Baz) returns(Baz);\\n\"\n    \"}\\n\",\n    \"3:6: \\\"Bar\\\" is already defined in \\\"Foo\\\".\\n\");\n}\n\n\nTEST_F(ParserValidationErrorTest, MethodInputTypeError) {\n  ExpectHasValidationErrors(\n    \"message Baz {}\\n\"\n    \"service Foo {\\n\"\n    \"  rpc Bar(Qux) returns(Baz);\\n\"\n    \"}\\n\",\n    \"2:10: \\\"Qux\\\" is not defined.\\n\");\n}\n\n\nTEST_F(ParserValidationErrorTest, MethodOutputTypeError) {\n  ExpectHasValidationErrors(\n    \"message Baz {}\\n\"\n    \"service Foo {\\n\"\n    \"  rpc Bar(Baz) returns(Qux);\\n\"\n    \"}\\n\",\n    \"2:23: \\\"Qux\\\" is not defined.\\n\");\n}\n\n\nTEST_F(ParserValidationErrorTest, ResovledUndefinedError) {\n  // Create another file which defines symbol \".base.bar\".\n  FileDescriptorProto other_file;\n  other_file.set_name(\"base.proto\");\n  other_file.set_package(\"base\");\n  other_file.add_message_type()->set_name(\"bar\");\n  EXPECT_TRUE(pool_.BuildFile(other_file) != NULL);\n\n  // Define \"foo.base\" and try \"base.bar\".\n  // \"base.bar\" is resolved to \"foo.base.bar\" which is not defined.\n  ExpectHasValidationErrors(\n    \"package foo.base;\\n\"\n    \"import \\\"base.proto\\\";\\n\"\n    \"message qux {\\n\"\n    \"  optional base.bar baz = 1;\\n\"\n    \"  optional .base.bar quz = 2;\\n\"\n    \"}\\n\",\n    \"3:11: \\\"base.bar\\\" is resolved to \\\"foo.base.bar\\\",\"\n    \" which is not defined. The innermost scope is searched first \"\n    \"in name resolution. Consider using a leading '.'(i.e., \\\".base.bar\\\")\"\n    \" to start from the outermost scope.\\n\");\n}\n\nTEST_F(ParserValidationErrorTest, ResovledUndefinedOptionError) {\n  // Build descriptor message in test pool\n  FileDescriptorProto descriptor_proto;\n  DescriptorProto::descriptor()->file()->CopyTo(&descriptor_proto);\n  ASSERT_TRUE(pool_.BuildFile(descriptor_proto) != NULL);\n\n  // base2.proto:\n  //   package baz\n  //   import google/protobuf/descriptor.proto\n  //   message Bar { optional int32 foo = 1; }\n  //   extend FileOptions { optional Bar bar = 7672757; }\n  FileDescriptorProto other_file;\n  other_file.set_name(\"base2.proto\");\n  other_file.set_package(\"baz\");\n  other_file.add_dependency();\n  other_file.set_dependency(0, descriptor_proto.name());\n\n  DescriptorProto* message(other_file.add_message_type());\n  message->set_name(\"Bar\");\n  FieldDescriptorProto* field(message->add_field());\n  field->set_name(\"foo\");\n  field->set_number(1);\n  field->set_label(FieldDescriptorProto_Label_LABEL_OPTIONAL);\n  field->set_type(FieldDescriptorProto_Type_TYPE_INT32);\n\n  FieldDescriptorProto* extension(other_file.add_extension());\n  extension->set_name(\"bar\");\n  extension->set_number(7672757);\n  extension->set_label(FieldDescriptorProto_Label_LABEL_OPTIONAL);\n  extension->set_type(FieldDescriptorProto_Type_TYPE_MESSAGE);\n  extension->set_type_name(\"Bar\");\n  extension->set_extendee(\"google.protobuf.FileOptions\");\n\n  EXPECT_TRUE(pool_.BuildFile(other_file) != NULL);\n\n  // qux.proto:\n  //   package qux.baz\n  //   option (baz.bar).foo = 1;\n  //\n  // Although \"baz.bar\" is already defined, the lookup code will try\n  // \"qux.baz.bar\", since it's the match from the innermost scope,\n  // which will cause a symbol not defined error.\n  ExpectHasValidationErrors(\n      \"package qux.baz;\\n\"\n      \"import \\\"base2.proto\\\";\\n\"\n      \"option (baz.bar).foo = 1;\\n\",\n      \"2:7: Option \\\"(baz.bar)\\\" is resolved to \\\"(qux.baz.bar)\\\",\"\n      \" which is not defined. The innermost scope is searched first \"\n      \"in name resolution. Consider using a leading '.'(i.e., \\\"(.baz.bar)\\\")\"\n      \" to start from the outermost scope.\\n\");\n}\n\n// ===================================================================\n// Test that the output from FileDescriptor::DebugString() (and all other\n// descriptor types) is parseable, and results in the same Descriptor\n// definitions again afoter parsing (note, however, that the order of messages\n// cannot be guaranteed to be the same)\n\ntypedef ParserTest ParseDescriptorDebugTest;\n\nclass CompareDescriptorNames {\n public:\n  bool operator()(const DescriptorProto* left,\n                  const DescriptorProto* right) const {\n    return left->name() < right->name();\n  }\n};\n\n// Sorts nested DescriptorProtos of a DescriptoProto, by name.\nvoid SortMessages(DescriptorProto *descriptor_proto) {\n  int size = descriptor_proto->nested_type_size();\n  // recursively sort; we can't guarantee the order of nested messages either\n  for (int i = 0; i < size; ++i) {\n    SortMessages(descriptor_proto->mutable_nested_type(i));\n  }\n  DescriptorProto **data =\n    descriptor_proto->mutable_nested_type()->mutable_data();\n  std::sort(data, data + size, CompareDescriptorNames());\n}\n\n// Sorts DescriptorProtos belonging to a FileDescriptorProto, by name.\nvoid SortMessages(FileDescriptorProto *file_descriptor_proto) {\n  int size = file_descriptor_proto->message_type_size();\n  // recursively sort; we can't guarantee the order of nested messages either\n  for (int i = 0; i < size; ++i) {\n    SortMessages(file_descriptor_proto->mutable_message_type(i));\n  }\n  DescriptorProto **data =\n    file_descriptor_proto->mutable_message_type()->mutable_data();\n  std::sort(data, data + size, CompareDescriptorNames());\n}\n\n// Strips the message and enum field type names for comparison purpose only.\nvoid StripFieldTypeName(DescriptorProto* proto) {\n  for (int i = 0; i < proto->field_size(); ++i) {\n    string type_name = proto->field(i).type_name();\n    string::size_type pos = type_name.find_last_of(\".\");\n    if (pos != string::npos) {\n      proto->mutable_field(i)->mutable_type_name()->assign(\n          type_name.begin() + pos + 1, type_name.end());\n    }\n  }\n  for (int i = 0; i < proto->nested_type_size(); ++i) {\n    StripFieldTypeName(proto->mutable_nested_type(i));\n  }\n}\n\nvoid StripFieldTypeName(FileDescriptorProto* file_proto) {\n  for (int i = 0; i < file_proto->message_type_size(); ++i) {\n    StripFieldTypeName(file_proto->mutable_message_type(i));\n  }\n}\n\nTEST_F(ParseDescriptorDebugTest, TestAllDescriptorTypes) {\n  const FileDescriptor* original_file =\n     protobuf_unittest::TestAllTypes::descriptor()->file();\n  FileDescriptorProto expected;\n  original_file->CopyTo(&expected);\n\n  // Get the DebugString of the unittest.proto FileDecriptor, which includes\n  // all other descriptor types\n  string debug_string = original_file->DebugString();\n\n  // Parse the debug string\n  SetupParser(debug_string.c_str());\n  FileDescriptorProto parsed;\n  parser_->Parse(input_.get(), &parsed);\n  EXPECT_EQ(io::Tokenizer::TYPE_END, input_->current().type);\n  ASSERT_EQ(\"\", error_collector_.text_)\n      << \"Failed to parse:\\n\" << debug_string;\n\n  // We now have a FileDescriptorProto, but to compare with the expected we\n  // need to link to a FileDecriptor, then output back to a proto. We'll\n  // also need to give it the same name as the original.\n  parsed.set_name(\"google/protobuf/unittest.proto\");\n  // We need the imported dependency before we can build our parsed proto\n  const FileDescriptor* public_import =\n      protobuf_unittest_import::PublicImportMessage::descriptor()->file();\n  FileDescriptorProto public_import_proto;\n  public_import->CopyTo(&public_import_proto);\n  ASSERT_TRUE(pool_.BuildFile(public_import_proto) != NULL);\n  const FileDescriptor* import =\n       protobuf_unittest_import::ImportMessage::descriptor()->file();\n  FileDescriptorProto import_proto;\n  import->CopyTo(&import_proto);\n  ASSERT_TRUE(pool_.BuildFile(import_proto) != NULL);\n  const FileDescriptor* actual = pool_.BuildFile(parsed);\n  parsed.Clear();\n  ASSERT_TRUE(actual != NULL)\n      << \"Failed to validate:\\n\" << debug_string;\n  actual->CopyTo(&parsed);\n  ASSERT_TRUE(actual != NULL);\n\n  // The messages might be in different orders, making them hard to compare.\n  // So, sort the messages in the descriptor protos (including nested messages,\n  // recursively).\n  SortMessages(&expected);\n  SortMessages(&parsed);\n\n  // I really wanted to use StringDiff here for the debug output on fail,\n  // but the strings are too long for it, and if I increase its max size,\n  // we get a memory allocation failure :(\n  EXPECT_EQ(expected.DebugString(), parsed.DebugString());\n}\n\nTEST_F(ParseDescriptorDebugTest, TestCustomOptions) {\n  const FileDescriptor* original_file =\n     protobuf_unittest::AggregateMessage::descriptor()->file();\n  FileDescriptorProto expected;\n  original_file->CopyTo(&expected);\n\n  string debug_string = original_file->DebugString();\n\n  // Parse the debug string\n  SetupParser(debug_string.c_str());\n  FileDescriptorProto parsed;\n  parser_->Parse(input_.get(), &parsed);\n  EXPECT_EQ(io::Tokenizer::TYPE_END, input_->current().type);\n  ASSERT_EQ(\"\", error_collector_.text_);\n\n  // We now have a FileDescriptorProto, but to compare with the expected we\n  // need to link to a FileDecriptor, then output back to a proto. We'll\n  // also need to give it the same name as the original.\n  parsed.set_name(original_file->name());\n\n  // unittest_custom_options.proto depends on descriptor.proto.\n  const FileDescriptor* import = FileDescriptorProto::descriptor()->file();\n  FileDescriptorProto import_proto;\n  import->CopyTo(&import_proto);\n  ASSERT_TRUE(pool_.BuildFile(import_proto) != NULL);\n  const FileDescriptor* actual = pool_.BuildFile(parsed);\n  ASSERT_TRUE(actual != NULL);\n  parsed.Clear();\n  actual->CopyTo(&parsed);\n\n  // The messages might be in different orders, making them hard to compare.\n  // So, sort the messages in the descriptor protos (including nested messages,\n  // recursively).\n  SortMessages(&expected);\n  SortMessages(&parsed);\n\n  EXPECT_EQ(expected.DebugString(), parsed.DebugString());\n}\n\n// Ensure that DebugStringWithOptions(), with |include_comments| set to true,\n// includes comments from the original parser input in all of the appropriate\n// places.\nTEST_F(ParseDescriptorDebugTest, TestCommentsInDebugString) {\n  SetupParser(\n      \"// Detached comment before syntax.\\n\"\n      \"\\n\"\n      \"// Syntax comment.\\n\"\n      \"syntax = \\\"proto2\\\";\\n\"\n      \"\\n\"\n      \"// Detached comment before package.\\n\"\n      \"\\n\"\n      \"// Package comment.\\n\"\n      \"package comment_test;\\n\"\n      \"\\n\"\n      \"// Detached comment before TestMessage1.\\n\"\n      \"\\n\"\n      \"// Message comment.\\n\"\n      \"//\\n\"\n      \"// More detail in message comment.\\n\"\n      \"message TestMessage1 {\\n\"\n      \"\\n\"\n      \"  // Detached comment before foo.\\n\"\n      \"\\n\"\n      \"  // Field comment.\\n\"\n      \"  optional int32 foo = 1;\\n\"\n      \"\\n\"\n      \"  // Detached comment before NestedMessage.\\n\"\n      \"\\n\"\n      \"  // Nested-message comment.\\n\"\n      \"  message NestedMessage {\\n\"\n      \"    optional int32 bar = 1;\\n\"\n      \"  }\\n\"\n      \"}\\n\"\n      \"\\n\"\n      \"// Detached comment before MyEnumType.\\n\"\n      \"\\n\"\n      \"// Enum comment.\\n\"\n      \"enum MyEnumType {\\n\"\n      \"\\n\"\n      \"  // Detached comment before ASDF.\\n\"\n      \"\\n\"\n      \"  // Enum-value comment.\\n\"\n      \"  ASDF = 1;\\n\"\n      \"}\\n\"\n      \"\\n\"\n      \"// Detached comment before MyService.\\n\"\n      \"\\n\"\n      \"// Service comment.\\n\"\n      \"service MyService {\\n\"\n      \"\\n\"\n      \"  // Detached comment before MyRPCCall.\\n\"\n      \"\\n\"\n      \"  // RPC comment.\\n\"\n      \"  rpc MyRPCCall(TestMessage1) returns (TestMessage1) { }\\n\"\n      \"}\\n\");\n\n  FileDescriptorProto parsed_desc;\n  parsed_desc.set_name(\"foo.proto\");\n  SourceLocationTable source_locations;\n  parser_->RecordSourceLocationsTo(&source_locations);\n  parser_->Parse(input_.get(), &parsed_desc);\n  EXPECT_EQ(io::Tokenizer::TYPE_END, input_->current().type);\n  ASSERT_EQ(\"\", error_collector_.text_);\n\n  // We need to import the FileDescriptorProto to get a FileDescriptor.\n  MockValidationErrorCollector collector(source_locations, &error_collector_);\n  const FileDescriptor* descriptor =\n      pool_.BuildFileCollectingErrors(parsed_desc, &collector);\n  ASSERT_TRUE(descriptor != NULL);\n\n  // Ensure that each of the comments appears somewhere in the DebugString().\n  // We don't test the exact comment placement or formatting, because we do not\n  // want to be too fragile here.\n  const char* expected_comments[] = {\n    \"Detached comment before syntax.\",\n    \"Syntax comment.\",\n    \"Detached comment before package.\",\n    \"Package comment.\",\n    \"Detached comment before TestMessage1.\",\n    \"Message comment.\",\n    \"More detail in message comment.\",\n    \"Detached comment before foo.\",\n    \"Field comment\",\n    \"Detached comment before NestedMessage.\",\n    \"Nested-message comment\",\n    \"Detached comment before MyEnumType.\",\n    \"Enum comment\",\n    \"Detached comment before ASDF.\",\n    \"Enum-value comment\",\n    \"Detached comment before MyService.\",\n    \"Service comment\",\n    \"Detached comment before MyRPCCall.\",\n    \"RPC comment\",\n  };\n\n  DebugStringOptions debug_string_options;\n  debug_string_options.include_comments = true;\n\n  {\n    const string debug_string =\n        descriptor->DebugStringWithOptions(debug_string_options);\n\n    for (int i = 0; i < GOOGLE_ARRAYSIZE(expected_comments); ++i) {\n      string::size_type found_pos = debug_string.find(expected_comments[i]);\n      EXPECT_TRUE(found_pos != string::npos)\n          << \"\\\"\" << expected_comments[i] << \"\\\" not found.\";\n    }\n\n    // Result of DebugStringWithOptions should be parseable.\n    SetupParser(debug_string.c_str());\n    FileDescriptorProto parsed;\n    parser_->Parse(input_.get(), &parsed);\n    EXPECT_EQ(io::Tokenizer::TYPE_END, input_->current().type);\n    ASSERT_EQ(\"\", error_collector_.text_)\n        << \"Failed to parse:\\n\" << debug_string;\n  }\n\n}\n\nTEST_F(ParseDescriptorDebugTest, TestMaps) {\n  SetupParser(\n      \"syntax = \\\"proto3\\\"; \"\n      \"message Foo { \"\n      \"  message Bar { } \"\n      \"  map<int32, Bar> enum_message_map = 1; \"\n      \"  map<string, float> primitive_map = 2; \"\n      \"} \");\n  FileDescriptorProto original;\n  EXPECT_TRUE(parser_->Parse(input_.get(), &original));\n  original.set_name(\"foo.proto\");\n  const FileDescriptor* file = pool_.BuildFile(original);\n  ASSERT_TRUE(file != NULL);\n\n  // Make sure the debug string uses map syntax and does not have the auto\n  // generated entry.\n  string debug_string = file->DebugString();\n  EXPECT_TRUE(debug_string.find(\"map<\") != string::npos);\n  EXPECT_TRUE(debug_string.find(\"option map_entry\") == string::npos);\n  EXPECT_TRUE(debug_string.find(\"MapEntry\") == string::npos);\n\n  // Make sure the descriptor debug string is parsable.\n  FileDescriptorProto parsed;\n  SetupParser(debug_string.c_str());\n  parsed.set_name(\"foo.proto\");\n  ASSERT_TRUE(parser_->Parse(input_.get(), &parsed));\n\n  original.clear_source_code_info();\n  parsed.clear_source_code_info();\n  StripFieldTypeName(&original);\n  StripFieldTypeName(&parsed);\n  EXPECT_EQ(original.DebugString(), parsed.DebugString());\n}\n\n// ===================================================================\n// SourceCodeInfo tests.\n\n// Follows a path -- as defined by SourceCodeInfo.Location.path -- from a\n// message to a particular sub-field.\n// * If the target is itself a message, sets *output_message to point at it,\n//   *output_field to NULL, and *output_index to -1.\n// * Otherwise, if the target is an element of a repeated field, sets\n//   *output_message to the containing message, *output_field to the descriptor\n//   of the field, and *output_index to the index of the element.\n// * Otherwise, the target is a field (possibly a repeated field, but not any\n//   one element).  Sets *output_message to the containing message,\n//   *output_field to the descriptor of the field, and *output_index to -1.\n// Returns true if the path was valid, false otherwise.  A gTest failure is\n// recorded before returning false.\nbool FollowPath(const Message& root,\n                const int* path_begin, const int* path_end,\n                const Message** output_message,\n                const FieldDescriptor** output_field,\n                int* output_index) {\n  if (path_begin == path_end) {\n    // Path refers to this whole message.\n    *output_message = &root;\n    *output_field = NULL;\n    *output_index = -1;\n    return true;\n  }\n\n  const Descriptor* descriptor = root.GetDescriptor();\n  const Reflection* reflection = root.GetReflection();\n\n  const FieldDescriptor* field = descriptor->FindFieldByNumber(*path_begin);\n\n  if (field == NULL) {\n    ADD_FAILURE() << descriptor->name() << \" has no field number: \"\n                  << *path_begin;\n    return false;\n  }\n\n  ++path_begin;\n\n  if (field->is_repeated()) {\n    if (path_begin == path_end) {\n      // Path refers to the whole repeated field.\n      *output_message = &root;\n      *output_field = field;\n      *output_index = -1;\n      return true;\n    }\n\n    int index = *path_begin++;\n    int size = reflection->FieldSize(root, field);\n\n    if (index >= size) {\n      ADD_FAILURE() << descriptor->name() << \".\" << field->name()\n                    << \" has size \" << size << \", but path contained index: \"\n                    << index;\n      return false;\n    }\n\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n      // Descend into child message.\n      const Message& child = reflection->GetRepeatedMessage(root, field, index);\n      return FollowPath(child, path_begin, path_end,\n                        output_message, output_field, output_index);\n    } else if (path_begin == path_end) {\n      // Path refers to this element.\n      *output_message = &root;\n      *output_field = field;\n      *output_index = index;\n      return true;\n    } else {\n      ADD_FAILURE() << descriptor->name() << \".\" << field->name()\n                    << \" is not a message; cannot descend into it.\";\n      return false;\n    }\n  } else {\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n      const Message& child = reflection->GetMessage(root, field);\n      return FollowPath(child, path_begin, path_end,\n                        output_message, output_field, output_index);\n    } else if (path_begin == path_end) {\n      // Path refers to this field.\n      *output_message = &root;\n      *output_field = field;\n      *output_index = -1;\n      return true;\n    } else {\n      ADD_FAILURE() << descriptor->name() << \".\" << field->name()\n                    << \" is not a message; cannot descend into it.\";\n      return false;\n    }\n  }\n}\n\n// Check if two spans are equal.\nbool CompareSpans(const RepeatedField<int>& span1,\n                  const RepeatedField<int>& span2) {\n  if (span1.size() != span2.size()) return false;\n  for (int i = 0; i < span1.size(); i++) {\n    if (span1.Get(i) != span2.Get(i)) return false;\n  }\n  return true;\n}\n\n// Test fixture for source info tests, which check that source locations are\n// recorded correctly in FileDescriptorProto.source_code_info.location.\nclass SourceInfoTest : public ParserTest {\n protected:\n  // The parsed file (initialized by Parse()).\n  FileDescriptorProto file_;\n\n  // Parse the given text as a .proto file and populate the spans_ map with\n  // all the source location spans in its SourceCodeInfo table.\n  bool Parse(const char* text) {\n    ExtractMarkers(text);\n    SetupParser(text_without_markers_.c_str());\n    if (!parser_->Parse(input_.get(), &file_)) {\n      return false;\n    }\n\n    const SourceCodeInfo& source_info = file_.source_code_info();\n    for (int i = 0; i < source_info.location_size(); i++) {\n      const SourceCodeInfo::Location& location = source_info.location(i);\n      const Message* descriptor_proto = NULL;\n      const FieldDescriptor* field = NULL;\n      int index = 0;\n      if (!FollowPath(file_, location.path().begin(), location.path().end(),\n                      &descriptor_proto, &field, &index)) {\n        return false;\n      }\n\n      spans_.insert(\n          std::make_pair(SpanKey(*descriptor_proto, field, index), &location));\n    }\n\n    return true;\n  }\n\n  virtual void TearDown() {\n    EXPECT_TRUE(spans_.empty())\n        << \"Forgot to call HasSpan() for:\\n\"\n        << spans_.begin()->second->DebugString();\n  }\n\n  // -----------------------------------------------------------------\n  // HasSpan() checks that the span of source code delimited by the given\n  // tags (comments) correspond via the SourceCodeInfo table to the given\n  // part of the FileDescriptorProto.  (If unclear, look at the actual tests;\n  // it should quickly become obvious.)\n\n  bool HasSpan(char start_marker, char end_marker,\n               const Message& descriptor_proto) {\n    return HasSpanWithComment(\n        start_marker, end_marker, descriptor_proto, NULL, -1, NULL, NULL, NULL);\n  }\n\n  bool HasSpanWithComment(char start_marker, char end_marker,\n                          const Message& descriptor_proto,\n                          const char* expected_leading_comments,\n                          const char* expected_trailing_comments,\n                          const char* expected_leading_detached_comments) {\n    return HasSpanWithComment(\n        start_marker, end_marker, descriptor_proto, NULL, -1,\n        expected_leading_comments, expected_trailing_comments,\n        expected_leading_detached_comments);\n  }\n\n  bool HasSpan(char start_marker, char end_marker,\n               const Message& descriptor_proto, const string& field_name) {\n    return HasSpan(start_marker, end_marker, descriptor_proto, field_name, -1);\n  }\n\n  bool HasSpan(char start_marker, char end_marker,\n               const Message& descriptor_proto, const string& field_name,\n               int index) {\n    return HasSpan(start_marker, end_marker, descriptor_proto,\n                   field_name, index, NULL, NULL, NULL);\n  }\n\n  bool HasSpan(char start_marker, char end_marker,\n               const Message& descriptor_proto,\n               const string& field_name, int index,\n               const char* expected_leading_comments,\n               const char* expected_trailing_comments,\n               const char* expected_leading_detached_comments) {\n    const FieldDescriptor* field =\n        descriptor_proto.GetDescriptor()->FindFieldByName(field_name);\n    if (field == NULL) {\n      ADD_FAILURE() << descriptor_proto.GetDescriptor()->name()\n                    << \" has no such field: \" << field_name;\n      return false;\n    }\n\n    return HasSpanWithComment(\n        start_marker, end_marker, descriptor_proto, field, index,\n        expected_leading_comments, expected_trailing_comments,\n        expected_leading_detached_comments);\n  }\n\n  bool HasSpan(const Message& descriptor_proto) {\n    return HasSpanWithComment(\n        '\\0', '\\0', descriptor_proto, NULL, -1, NULL, NULL, NULL);\n  }\n\n  bool HasSpan(const Message& descriptor_proto, const string& field_name) {\n    return HasSpan('\\0', '\\0', descriptor_proto, field_name, -1);\n  }\n\n  bool HasSpan(const Message& descriptor_proto, const string& field_name,\n               int index) {\n    return HasSpan('\\0', '\\0', descriptor_proto, field_name, index);\n  }\n\n  bool HasSpanWithComment(\n      char start_marker, char end_marker, const Message& descriptor_proto,\n      const FieldDescriptor* field, int index,\n      const char* expected_leading_comments,\n      const char* expected_trailing_comments,\n      const char* expected_leading_detached_comments) {\n    pair<SpanMap::iterator, SpanMap::iterator> range =\n        spans_.equal_range(SpanKey(descriptor_proto, field, index));\n\n    if (start_marker == '\\0') {\n      if (range.first == range.second) {\n        return false;\n      } else {\n        spans_.erase(range.first);\n        return true;\n      }\n    } else {\n      pair<int, int> start_pos = FindOrDie(markers_, start_marker);\n      pair<int, int> end_pos = FindOrDie(markers_, end_marker);\n\n      RepeatedField<int> expected_span;\n      expected_span.Add(start_pos.first);\n      expected_span.Add(start_pos.second);\n      if (end_pos.first != start_pos.first) {\n        expected_span.Add(end_pos.first);\n      }\n      expected_span.Add(end_pos.second);\n\n      for (SpanMap::iterator iter = range.first; iter != range.second; ++iter) {\n        if (CompareSpans(expected_span, iter->second->span())) {\n          if (expected_leading_comments == NULL) {\n            EXPECT_FALSE(iter->second->has_leading_comments());\n          } else {\n            EXPECT_TRUE(iter->second->has_leading_comments());\n            EXPECT_EQ(expected_leading_comments,\n                      iter->second->leading_comments());\n          }\n          if (expected_trailing_comments == NULL) {\n            EXPECT_FALSE(iter->second->has_trailing_comments());\n          } else {\n            EXPECT_TRUE(iter->second->has_trailing_comments());\n            EXPECT_EQ(expected_trailing_comments,\n                      iter->second->trailing_comments());\n          }\n          if (expected_leading_detached_comments == NULL) {\n            EXPECT_EQ(0, iter->second->leading_detached_comments_size());\n          } else {\n            EXPECT_EQ(\n                expected_leading_detached_comments,\n                Join(iter->second->leading_detached_comments(), \"\\n\"));\n          }\n\n          spans_.erase(iter);\n          return true;\n        }\n      }\n\n      return false;\n    }\n  }\n\n private:\n  struct SpanKey {\n    const Message* descriptor_proto;\n    const FieldDescriptor* field;\n    int index;\n\n    inline SpanKey() {}\n    inline SpanKey(const Message& descriptor_proto_param,\n                   const FieldDescriptor* field_param,\n                   int index_param)\n        : descriptor_proto(&descriptor_proto_param), field(field_param),\n          index(index_param) {}\n\n    inline bool operator<(const SpanKey& other) const {\n      if (descriptor_proto < other.descriptor_proto) return true;\n      if (descriptor_proto > other.descriptor_proto) return false;\n      if (field < other.field) return true;\n      if (field > other.field) return false;\n      return index < other.index;\n    }\n  };\n\n  typedef multimap<SpanKey, const SourceCodeInfo::Location*> SpanMap;\n  SpanMap spans_;\n  map<char, pair<int, int> > markers_;\n  string text_without_markers_;\n\n  void ExtractMarkers(const char* text) {\n    markers_.clear();\n    text_without_markers_.clear();\n    int line = 0;\n    int column = 0;\n    while (*text != '\\0') {\n      if (*text == '$') {\n        ++text;\n        GOOGLE_CHECK_NE('\\0', *text);\n        if (*text == '$') {\n          text_without_markers_ += '$';\n          ++column;\n        } else {\n          markers_[*text] = std::make_pair(line, column);\n          ++text;\n          GOOGLE_CHECK_EQ('$', *text);\n        }\n      } else if (*text == '\\n') {\n        ++line;\n        column = 0;\n        text_without_markers_ += *text;\n      } else {\n        text_without_markers_ += *text;\n        ++column;\n      }\n      ++text;\n    }\n  }\n};\n\nTEST_F(SourceInfoTest, BasicFileDecls) {\n  EXPECT_TRUE(Parse(\n      \"$a$syntax = \\\"proto2\\\";$i$\\n\"\n      \"package $b$foo.bar$c$;\\n\"\n      \"import $d$\\\"baz.proto\\\"$e$;\\n\"\n      \"import $f$\\\"qux.proto\\\"$g$;$h$\\n\"\n      \"\\n\"\n      \"// comment ignored\\n\"));\n\n  EXPECT_TRUE(HasSpan('a', 'h', file_));\n  EXPECT_TRUE(HasSpan('b', 'c', file_, \"package\"));\n  EXPECT_TRUE(HasSpan('d', 'e', file_, \"dependency\", 0));\n  EXPECT_TRUE(HasSpan('f', 'g', file_, \"dependency\", 1));\n  EXPECT_TRUE(HasSpan('a', 'i', file_, \"syntax\"));\n}\n\nTEST_F(SourceInfoTest, Messages) {\n  EXPECT_TRUE(Parse(\n      \"$a$message $b$Foo$c$ {}$d$\\n\"\n      \"$e$message $f$Bar$g$ {}$h$\\n\"));\n\n  EXPECT_TRUE(HasSpan('a', 'd', file_.message_type(0)));\n  EXPECT_TRUE(HasSpan('b', 'c', file_.message_type(0), \"name\"));\n  EXPECT_TRUE(HasSpan('e', 'h', file_.message_type(1)));\n  EXPECT_TRUE(HasSpan('f', 'g', file_.message_type(1), \"name\"));\n\n  // Ignore these.\n  EXPECT_TRUE(HasSpan(file_));\n}\n\nTEST_F(SourceInfoTest, Fields) {\n  EXPECT_TRUE(Parse(\n      \"message Foo {\\n\"\n      \"  $a$optional$b$ $c$int32$d$ $e$bar$f$ = $g$1$h$;$i$\\n\"\n      \"  $j$repeated$k$ $l$X.Y$m$ $n$baz$o$ = $p$2$q$;$r$\\n\"\n      \"}\\n\"));\n\n  const FieldDescriptorProto& field1 = file_.message_type(0).field(0);\n  const FieldDescriptorProto& field2 = file_.message_type(0).field(1);\n\n  EXPECT_TRUE(HasSpan('a', 'i', field1));\n  EXPECT_TRUE(HasSpan('a', 'b', field1, \"label\"));\n  EXPECT_TRUE(HasSpan('c', 'd', field1, \"type\"));\n  EXPECT_TRUE(HasSpan('e', 'f', field1, \"name\"));\n  EXPECT_TRUE(HasSpan('g', 'h', field1, \"number\"));\n\n  EXPECT_TRUE(HasSpan('j', 'r', field2));\n  EXPECT_TRUE(HasSpan('j', 'k', field2, \"label\"));\n  EXPECT_TRUE(HasSpan('l', 'm', field2, \"type_name\"));\n  EXPECT_TRUE(HasSpan('n', 'o', field2, \"name\"));\n  EXPECT_TRUE(HasSpan('p', 'q', field2, \"number\"));\n\n  // Ignore these.\n  EXPECT_TRUE(HasSpan(file_));\n  EXPECT_TRUE(HasSpan(file_.message_type(0)));\n  EXPECT_TRUE(HasSpan(file_.message_type(0), \"name\"));\n}\n\nTEST_F(SourceInfoTest, Extensions) {\n  EXPECT_TRUE(Parse(\n      \"$a$extend $b$Foo$c$ {\\n\"\n      \"  $d$optional$e$ int32 bar = 1;$f$\\n\"\n      \"  $g$repeated$h$ X.Y baz = 2;$i$\\n\"\n      \"}$j$\\n\"\n      \"$k$extend $l$Bar$m$ {\\n\"\n      \"  $n$optional int32 qux = 1;$o$\\n\"\n      \"}$p$\\n\"));\n\n  const FieldDescriptorProto& field1 = file_.extension(0);\n  const FieldDescriptorProto& field2 = file_.extension(1);\n  const FieldDescriptorProto& field3 = file_.extension(2);\n\n  EXPECT_TRUE(HasSpan('a', 'j', file_, \"extension\"));\n  EXPECT_TRUE(HasSpan('k', 'p', file_, \"extension\"));\n\n  EXPECT_TRUE(HasSpan('d', 'f', field1));\n  EXPECT_TRUE(HasSpan('d', 'e', field1, \"label\"));\n  EXPECT_TRUE(HasSpan('b', 'c', field1, \"extendee\"));\n\n  EXPECT_TRUE(HasSpan('g', 'i', field2));\n  EXPECT_TRUE(HasSpan('g', 'h', field2, \"label\"));\n  EXPECT_TRUE(HasSpan('b', 'c', field2, \"extendee\"));\n\n  EXPECT_TRUE(HasSpan('n', 'o', field3));\n  EXPECT_TRUE(HasSpan('l', 'm', field3, \"extendee\"));\n\n  // Ignore these.\n  EXPECT_TRUE(HasSpan(file_));\n  EXPECT_TRUE(HasSpan(field1, \"type\"));\n  EXPECT_TRUE(HasSpan(field1, \"name\"));\n  EXPECT_TRUE(HasSpan(field1, \"number\"));\n  EXPECT_TRUE(HasSpan(field2, \"type_name\"));\n  EXPECT_TRUE(HasSpan(field2, \"name\"));\n  EXPECT_TRUE(HasSpan(field2, \"number\"));\n  EXPECT_TRUE(HasSpan(field3, \"label\"));\n  EXPECT_TRUE(HasSpan(field3, \"type\"));\n  EXPECT_TRUE(HasSpan(field3, \"name\"));\n  EXPECT_TRUE(HasSpan(field3, \"number\"));\n}\n\nTEST_F(SourceInfoTest, NestedExtensions) {\n  EXPECT_TRUE(Parse(\n      \"message Message {\\n\"\n      \"  $a$extend $b$Foo$c$ {\\n\"\n      \"    $d$optional$e$ int32 bar = 1;$f$\\n\"\n      \"    $g$repeated$h$ X.Y baz = 2;$i$\\n\"\n      \"  }$j$\\n\"\n      \"  $k$extend $l$Bar$m$ {\\n\"\n      \"    $n$optional int32 qux = 1;$o$\\n\"\n      \"  }$p$\\n\"\n      \"}\\n\"));\n\n  const FieldDescriptorProto& field1 = file_.message_type(0).extension(0);\n  const FieldDescriptorProto& field2 = file_.message_type(0).extension(1);\n  const FieldDescriptorProto& field3 = file_.message_type(0).extension(2);\n\n  EXPECT_TRUE(HasSpan('a', 'j', file_.message_type(0), \"extension\"));\n  EXPECT_TRUE(HasSpan('k', 'p', file_.message_type(0), \"extension\"));\n\n  EXPECT_TRUE(HasSpan('d', 'f', field1));\n  EXPECT_TRUE(HasSpan('d', 'e', field1, \"label\"));\n  EXPECT_TRUE(HasSpan('b', 'c', field1, \"extendee\"));\n\n  EXPECT_TRUE(HasSpan('g', 'i', field2));\n  EXPECT_TRUE(HasSpan('g', 'h', field2, \"label\"));\n  EXPECT_TRUE(HasSpan('b', 'c', field2, \"extendee\"));\n\n  EXPECT_TRUE(HasSpan('n', 'o', field3));\n  EXPECT_TRUE(HasSpan('l', 'm', field3, \"extendee\"));\n\n  // Ignore these.\n  EXPECT_TRUE(HasSpan(file_));\n  EXPECT_TRUE(HasSpan(file_.message_type(0)));\n  EXPECT_TRUE(HasSpan(file_.message_type(0), \"name\"));\n  EXPECT_TRUE(HasSpan(field1, \"type\"));\n  EXPECT_TRUE(HasSpan(field1, \"name\"));\n  EXPECT_TRUE(HasSpan(field1, \"number\"));\n  EXPECT_TRUE(HasSpan(field2, \"type_name\"));\n  EXPECT_TRUE(HasSpan(field2, \"name\"));\n  EXPECT_TRUE(HasSpan(field2, \"number\"));\n  EXPECT_TRUE(HasSpan(field3, \"label\"));\n  EXPECT_TRUE(HasSpan(field3, \"type\"));\n  EXPECT_TRUE(HasSpan(field3, \"name\"));\n  EXPECT_TRUE(HasSpan(field3, \"number\"));\n}\n\nTEST_F(SourceInfoTest, ExtensionRanges) {\n  EXPECT_TRUE(Parse(\n      \"message Message {\\n\"\n      \"  $a$extensions $b$1$c$ to $d$4$e$, $f$6$g$;$h$\\n\"\n      \"  $i$extensions $j$8$k$ to $l$max$m$;$n$\\n\"\n      \"}\\n\"));\n\n  const DescriptorProto::ExtensionRange& range1 =\n      file_.message_type(0).extension_range(0);\n  const DescriptorProto::ExtensionRange& range2 =\n      file_.message_type(0).extension_range(1);\n  const DescriptorProto::ExtensionRange& range3 =\n      file_.message_type(0).extension_range(2);\n\n  EXPECT_TRUE(HasSpan('a', 'h', file_.message_type(0), \"extension_range\"));\n  EXPECT_TRUE(HasSpan('i', 'n', file_.message_type(0), \"extension_range\"));\n\n  EXPECT_TRUE(HasSpan('b', 'e', range1));\n  EXPECT_TRUE(HasSpan('b', 'c', range1, \"start\"));\n  EXPECT_TRUE(HasSpan('d', 'e', range1, \"end\"));\n\n  EXPECT_TRUE(HasSpan('f', 'g', range2));\n  EXPECT_TRUE(HasSpan('f', 'g', range2, \"start\"));\n  EXPECT_TRUE(HasSpan('f', 'g', range2, \"end\"));\n\n  EXPECT_TRUE(HasSpan('j', 'm', range3));\n  EXPECT_TRUE(HasSpan('j', 'k', range3, \"start\"));\n  EXPECT_TRUE(HasSpan('l', 'm', range3, \"end\"));\n\n  // Ignore these.\n  EXPECT_TRUE(HasSpan(file_));\n  EXPECT_TRUE(HasSpan(file_.message_type(0)));\n  EXPECT_TRUE(HasSpan(file_.message_type(0), \"name\"));\n}\n\nTEST_F(SourceInfoTest, Oneofs) {\n  EXPECT_TRUE(Parse(\n      \"message Foo {\\n\"\n      \"  $a$oneof $c$foo$d$ {\\n\"\n      \"    $e$int32$f$ $g$a$h$ = $i$1$j$;$k$\\n\"\n      \"  }$r$\\n\"\n      \"}\\n\"));\n\n  const OneofDescriptorProto& oneof_decl = file_.message_type(0).oneof_decl(0);\n  const FieldDescriptorProto& field = file_.message_type(0).field(0);\n\n  EXPECT_TRUE(HasSpan('a', 'r', oneof_decl));\n  EXPECT_TRUE(HasSpan('c', 'd', oneof_decl, \"name\"));\n\n  EXPECT_TRUE(HasSpan('e', 'k', field));\n  EXPECT_TRUE(HasSpan('e', 'f', field, \"type\"));\n  EXPECT_TRUE(HasSpan('g', 'h', field, \"name\"));\n  EXPECT_TRUE(HasSpan('i', 'j', field, \"number\"));\n\n  // Ignore these.\n  EXPECT_TRUE(HasSpan(file_));\n  EXPECT_TRUE(HasSpan(file_.message_type(0)));\n  EXPECT_TRUE(HasSpan(file_.message_type(0), \"name\"));\n}\n\nTEST_F(SourceInfoTest, NestedMessages) {\n  EXPECT_TRUE(Parse(\n      \"message Foo {\\n\"\n      \"  $a$message $b$Bar$c$ {\\n\"\n      \"    $d$message $e$Baz$f$ {}$g$\\n\"\n      \"  }$h$\\n\"\n      \"  $i$message $j$Qux$k$ {}$l$\\n\"\n      \"}\\n\"));\n\n  const DescriptorProto& bar = file_.message_type(0).nested_type(0);\n  const DescriptorProto& baz = bar.nested_type(0);\n  const DescriptorProto& qux = file_.message_type(0).nested_type(1);\n\n  EXPECT_TRUE(HasSpan('a', 'h', bar));\n  EXPECT_TRUE(HasSpan('b', 'c', bar, \"name\"));\n  EXPECT_TRUE(HasSpan('d', 'g', baz));\n  EXPECT_TRUE(HasSpan('e', 'f', baz, \"name\"));\n  EXPECT_TRUE(HasSpan('i', 'l', qux));\n  EXPECT_TRUE(HasSpan('j', 'k', qux, \"name\"));\n\n  // Ignore these.\n  EXPECT_TRUE(HasSpan(file_));\n  EXPECT_TRUE(HasSpan(file_.message_type(0)));\n  EXPECT_TRUE(HasSpan(file_.message_type(0), \"name\"));\n}\n\nTEST_F(SourceInfoTest, Groups) {\n  EXPECT_TRUE(Parse(\n      \"message Foo {\\n\"\n      \"  message Bar {}\\n\"\n      \"  $a$optional$b$ $c$group$d$ $e$Baz$f$ = $g$1$h$ {\\n\"\n      \"    $i$message Qux {}$j$\\n\"\n      \"  }$k$\\n\"\n      \"}\\n\"));\n\n  const DescriptorProto& bar = file_.message_type(0).nested_type(0);\n  const DescriptorProto& baz = file_.message_type(0).nested_type(1);\n  const DescriptorProto& qux = baz.nested_type(0);\n  const FieldDescriptorProto& field = file_.message_type(0).field(0);\n\n  EXPECT_TRUE(HasSpan('a', 'k', field));\n  EXPECT_TRUE(HasSpan('a', 'b', field, \"label\"));\n  EXPECT_TRUE(HasSpan('c', 'd', field, \"type\"));\n  EXPECT_TRUE(HasSpan('e', 'f', field, \"name\"));\n  EXPECT_TRUE(HasSpan('e', 'f', field, \"type_name\"));\n  EXPECT_TRUE(HasSpan('g', 'h', field, \"number\"));\n\n  EXPECT_TRUE(HasSpan('a', 'k', baz));\n  EXPECT_TRUE(HasSpan('e', 'f', baz, \"name\"));\n  EXPECT_TRUE(HasSpan('i', 'j', qux));\n\n  // Ignore these.\n  EXPECT_TRUE(HasSpan(file_));\n  EXPECT_TRUE(HasSpan(file_.message_type(0)));\n  EXPECT_TRUE(HasSpan(file_.message_type(0), \"name\"));\n  EXPECT_TRUE(HasSpan(bar));\n  EXPECT_TRUE(HasSpan(bar, \"name\"));\n  EXPECT_TRUE(HasSpan(qux, \"name\"));\n}\n\nTEST_F(SourceInfoTest, Enums) {\n  EXPECT_TRUE(Parse(\n      \"$a$enum $b$Foo$c$ {}$d$\\n\"\n      \"$e$enum $f$Bar$g$ {}$h$\\n\"));\n\n  EXPECT_TRUE(HasSpan('a', 'd', file_.enum_type(0)));\n  EXPECT_TRUE(HasSpan('b', 'c', file_.enum_type(0), \"name\"));\n  EXPECT_TRUE(HasSpan('e', 'h', file_.enum_type(1)));\n  EXPECT_TRUE(HasSpan('f', 'g', file_.enum_type(1), \"name\"));\n\n  // Ignore these.\n  EXPECT_TRUE(HasSpan(file_));\n}\n\nTEST_F(SourceInfoTest, EnumValues) {\n  EXPECT_TRUE(Parse(\n      \"enum Foo {\\n\"\n      \"  $a$BAR$b$ = $c$1$d$;$e$\\n\"\n      \"  $f$BAZ$g$ = $h$2$i$;$j$\\n\"\n      \"}\"));\n\n  const EnumValueDescriptorProto& bar = file_.enum_type(0).value(0);\n  const EnumValueDescriptorProto& baz = file_.enum_type(0).value(1);\n\n  EXPECT_TRUE(HasSpan('a', 'e', bar));\n  EXPECT_TRUE(HasSpan('a', 'b', bar, \"name\"));\n  EXPECT_TRUE(HasSpan('c', 'd', bar, \"number\"));\n  EXPECT_TRUE(HasSpan('f', 'j', baz));\n  EXPECT_TRUE(HasSpan('f', 'g', baz, \"name\"));\n  EXPECT_TRUE(HasSpan('h', 'i', baz, \"number\"));\n\n  // Ignore these.\n  EXPECT_TRUE(HasSpan(file_));\n  EXPECT_TRUE(HasSpan(file_.enum_type(0)));\n  EXPECT_TRUE(HasSpan(file_.enum_type(0), \"name\"));\n}\n\nTEST_F(SourceInfoTest, NestedEnums) {\n  EXPECT_TRUE(Parse(\n      \"message Foo {\\n\"\n      \"  $a$enum $b$Bar$c$ {}$d$\\n\"\n      \"  $e$enum $f$Baz$g$ {}$h$\\n\"\n      \"}\\n\"));\n\n  const EnumDescriptorProto& bar = file_.message_type(0).enum_type(0);\n  const EnumDescriptorProto& baz = file_.message_type(0).enum_type(1);\n\n  EXPECT_TRUE(HasSpan('a', 'd', bar));\n  EXPECT_TRUE(HasSpan('b', 'c', bar, \"name\"));\n  EXPECT_TRUE(HasSpan('e', 'h', baz));\n  EXPECT_TRUE(HasSpan('f', 'g', baz, \"name\"));\n\n  // Ignore these.\n  EXPECT_TRUE(HasSpan(file_));\n  EXPECT_TRUE(HasSpan(file_.message_type(0)));\n  EXPECT_TRUE(HasSpan(file_.message_type(0), \"name\"));\n}\n\nTEST_F(SourceInfoTest, Services) {\n  EXPECT_TRUE(Parse(\n      \"$a$service $b$Foo$c$ {}$d$\\n\"\n      \"$e$service $f$Bar$g$ {}$h$\\n\"));\n\n  EXPECT_TRUE(HasSpan('a', 'd', file_.service(0)));\n  EXPECT_TRUE(HasSpan('b', 'c', file_.service(0), \"name\"));\n  EXPECT_TRUE(HasSpan('e', 'h', file_.service(1)));\n  EXPECT_TRUE(HasSpan('f', 'g', file_.service(1), \"name\"));\n\n  // Ignore these.\n  EXPECT_TRUE(HasSpan(file_));\n}\n\nTEST_F(SourceInfoTest, MethodsAndStreams) {\n  EXPECT_TRUE(Parse(\n      \"service Foo {\\n\"\n      \"  $a$rpc $b$Bar$c$($d$X$e$) returns($f$Y$g$);$h$\"\n      \"  $i$rpc $j$Baz$k$($l$Z$m$) returns($n$W$o$);$p$\"\n      \"}\"));\n\n  const MethodDescriptorProto& bar = file_.service(0).method(0);\n  const MethodDescriptorProto& baz = file_.service(0).method(1);\n\n  EXPECT_TRUE(HasSpan('a', 'h', bar));\n  EXPECT_TRUE(HasSpan('b', 'c', bar, \"name\"));\n  EXPECT_TRUE(HasSpan('d', 'e', bar, \"input_type\"));\n  EXPECT_TRUE(HasSpan('f', 'g', bar, \"output_type\"));\n\n  EXPECT_TRUE(HasSpan('i', 'p', baz));\n  EXPECT_TRUE(HasSpan('j', 'k', baz, \"name\"));\n  EXPECT_TRUE(HasSpan('l', 'm', baz, \"input_type\"));\n  EXPECT_TRUE(HasSpan('n', 'o', baz, \"output_type\"));\n\n  // Ignore these.\n  EXPECT_TRUE(HasSpan(file_));\n  EXPECT_TRUE(HasSpan(file_.service(0)));\n  EXPECT_TRUE(HasSpan(file_.service(0), \"name\"));\n}\n\n\nTEST_F(SourceInfoTest, Options) {\n  EXPECT_TRUE(Parse(\n      \"$a$option $b$foo$c$.$d$($e$bar.baz$f$)$g$ = \"\n          \"$h$123$i$;$j$\\n\"\n      \"$k$option qux = $l$-123$m$;$n$\\n\"\n      \"$o$option corge = $p$abc$q$;$r$\\n\"\n      \"$s$option grault = $t$'blah'$u$;$v$\\n\"\n      \"$w$option garply = $x${ yadda yadda }$y$;$z$\\n\"\n      \"$0$option waldo = $1$123.0$2$;$3$\\n\"\n  ));\n\n  const UninterpretedOption& option1 = file_.options().uninterpreted_option(0);\n  const UninterpretedOption& option2 = file_.options().uninterpreted_option(1);\n  const UninterpretedOption& option3 = file_.options().uninterpreted_option(2);\n  const UninterpretedOption& option4 = file_.options().uninterpreted_option(3);\n  const UninterpretedOption& option5 = file_.options().uninterpreted_option(4);\n  const UninterpretedOption& option6 = file_.options().uninterpreted_option(5);\n\n  EXPECT_TRUE(HasSpan('a', 'j', file_.options()));\n  EXPECT_TRUE(HasSpan('a', 'j', option1));\n  EXPECT_TRUE(HasSpan('b', 'g', option1, \"name\"));\n  EXPECT_TRUE(HasSpan('b', 'c', option1.name(0)));\n  EXPECT_TRUE(HasSpan('b', 'c', option1.name(0), \"name_part\"));\n  EXPECT_TRUE(HasSpan('d', 'g', option1.name(1)));\n  EXPECT_TRUE(HasSpan('e', 'f', option1.name(1), \"name_part\"));\n  EXPECT_TRUE(HasSpan('h', 'i', option1, \"positive_int_value\"));\n\n  EXPECT_TRUE(HasSpan('k', 'n', file_.options()));\n  EXPECT_TRUE(HasSpan('l', 'm', option2, \"negative_int_value\"));\n\n  EXPECT_TRUE(HasSpan('o', 'r', file_.options()));\n  EXPECT_TRUE(HasSpan('p', 'q', option3, \"identifier_value\"));\n\n  EXPECT_TRUE(HasSpan('s', 'v', file_.options()));\n  EXPECT_TRUE(HasSpan('t', 'u', option4, \"string_value\"));\n\n  EXPECT_TRUE(HasSpan('w', 'z', file_.options()));\n  EXPECT_TRUE(HasSpan('x', 'y', option5, \"aggregate_value\"));\n\n  EXPECT_TRUE(HasSpan('0', '3', file_.options()));\n  EXPECT_TRUE(HasSpan('1', '2', option6, \"double_value\"));\n\n  // Ignore these.\n  EXPECT_TRUE(HasSpan(file_));\n  EXPECT_TRUE(HasSpan(option2));\n  EXPECT_TRUE(HasSpan(option3));\n  EXPECT_TRUE(HasSpan(option4));\n  EXPECT_TRUE(HasSpan(option5));\n  EXPECT_TRUE(HasSpan(option6));\n  EXPECT_TRUE(HasSpan(option2, \"name\"));\n  EXPECT_TRUE(HasSpan(option3, \"name\"));\n  EXPECT_TRUE(HasSpan(option4, \"name\"));\n  EXPECT_TRUE(HasSpan(option5, \"name\"));\n  EXPECT_TRUE(HasSpan(option6, \"name\"));\n  EXPECT_TRUE(HasSpan(option2.name(0)));\n  EXPECT_TRUE(HasSpan(option3.name(0)));\n  EXPECT_TRUE(HasSpan(option4.name(0)));\n  EXPECT_TRUE(HasSpan(option5.name(0)));\n  EXPECT_TRUE(HasSpan(option6.name(0)));\n  EXPECT_TRUE(HasSpan(option2.name(0), \"name_part\"));\n  EXPECT_TRUE(HasSpan(option3.name(0), \"name_part\"));\n  EXPECT_TRUE(HasSpan(option4.name(0), \"name_part\"));\n  EXPECT_TRUE(HasSpan(option5.name(0), \"name_part\"));\n  EXPECT_TRUE(HasSpan(option6.name(0), \"name_part\"));\n}\n\nTEST_F(SourceInfoTest, ScopedOptions) {\n  EXPECT_TRUE(Parse(\n    \"message Foo {\\n\"\n    \"  $a$option mopt = 1;$b$\\n\"\n    \"}\\n\"\n    \"enum Bar {\\n\"\n    \"  $c$option eopt = 1;$d$\\n\"\n    \"}\\n\"\n    \"service Baz {\\n\"\n    \"  $e$option sopt = 1;$f$\\n\"\n    \"  rpc M(X) returns(Y) {\\n\"\n    \"    $g$option mopt = 1;$h$\\n\"\n    \"  }\\n\"\n    \"  rpc MS4($1$stream$2$ X) returns($3$stream$4$ Y) {\\n\"\n    \"    $k$option mopt = 1;$l$\\n\"\n    \"  }\\n\"\n    \"}\\n\"));\n\n  EXPECT_TRUE(HasSpan('a', 'b', file_.message_type(0).options()));\n  EXPECT_TRUE(HasSpan('c', 'd', file_.enum_type(0).options()));\n  EXPECT_TRUE(HasSpan('e', 'f', file_.service(0).options()));\n  EXPECT_TRUE(HasSpan('g', 'h', file_.service(0).method(0).options()));\n\n  // Ignore these.\n  EXPECT_TRUE(HasSpan(file_));\n  EXPECT_TRUE(HasSpan(file_.message_type(0)));\n  EXPECT_TRUE(HasSpan(file_.message_type(0), \"name\"));\n  EXPECT_TRUE(HasSpan(file_.message_type(0).options()\n                      .uninterpreted_option(0)));\n  EXPECT_TRUE(HasSpan(file_.message_type(0).options()\n                      .uninterpreted_option(0), \"name\"));\n  EXPECT_TRUE(HasSpan(file_.message_type(0).options()\n                      .uninterpreted_option(0).name(0)));\n  EXPECT_TRUE(HasSpan(file_.message_type(0).options()\n                      .uninterpreted_option(0).name(0), \"name_part\"));\n  EXPECT_TRUE(HasSpan(file_.message_type(0).options()\n                      .uninterpreted_option(0), \"positive_int_value\"));\n  EXPECT_TRUE(HasSpan(file_.enum_type(0)));\n  EXPECT_TRUE(HasSpan(file_.enum_type(0), \"name\"));\n  EXPECT_TRUE(HasSpan(file_.enum_type(0).options()\n                      .uninterpreted_option(0)));\n  EXPECT_TRUE(HasSpan(file_.enum_type(0).options()\n                      .uninterpreted_option(0), \"name\"));\n  EXPECT_TRUE(HasSpan(file_.enum_type(0).options()\n                      .uninterpreted_option(0).name(0)));\n  EXPECT_TRUE(HasSpan(file_.enum_type(0).options()\n                      .uninterpreted_option(0).name(0), \"name_part\"));\n  EXPECT_TRUE(HasSpan(file_.enum_type(0).options()\n                      .uninterpreted_option(0), \"positive_int_value\"));\n  EXPECT_TRUE(HasSpan(file_.service(0)));\n  EXPECT_TRUE(HasSpan(file_.service(0), \"name\"));\n  EXPECT_TRUE(HasSpan(file_.service(0).method(0)));\n  EXPECT_TRUE(HasSpan(file_.service(0).options()\n                      .uninterpreted_option(0)));\n  EXPECT_TRUE(HasSpan(file_.service(0).options()\n                      .uninterpreted_option(0), \"name\"));\n  EXPECT_TRUE(HasSpan(file_.service(0).options()\n                      .uninterpreted_option(0).name(0)));\n  EXPECT_TRUE(HasSpan(file_.service(0).options()\n                      .uninterpreted_option(0).name(0), \"name_part\"));\n  EXPECT_TRUE(HasSpan(file_.service(0).options()\n                      .uninterpreted_option(0), \"positive_int_value\"));\n  EXPECT_TRUE(HasSpan(file_.service(0).method(0), \"name\"));\n  EXPECT_TRUE(HasSpan(file_.service(0).method(0), \"input_type\"));\n  EXPECT_TRUE(HasSpan(file_.service(0).method(0), \"output_type\"));\n  EXPECT_TRUE(HasSpan(file_.service(0).method(0).options()\n                      .uninterpreted_option(0)));\n  EXPECT_TRUE(HasSpan(file_.service(0).method(0).options()\n                      .uninterpreted_option(0), \"name\"));\n  EXPECT_TRUE(HasSpan(file_.service(0).method(0).options()\n                      .uninterpreted_option(0).name(0)));\n  EXPECT_TRUE(HasSpan(file_.service(0).method(0).options()\n                      .uninterpreted_option(0).name(0), \"name_part\"));\n  EXPECT_TRUE(HasSpan(file_.service(0).method(0).options()\n                      .uninterpreted_option(0), \"positive_int_value\"));\n\n  EXPECT_TRUE(HasSpan('k', 'l', file_.service(0).method(1).options()));\n  EXPECT_TRUE(HasSpan(file_.service(0).method(1)));\n  EXPECT_TRUE(HasSpan(file_.service(0).method(1), \"name\"));\n  EXPECT_TRUE(HasSpan(file_.service(0).method(1), \"input_type\"));\n  EXPECT_TRUE(HasSpan(file_.service(0).method(1), \"output_type\"));\n  EXPECT_TRUE(HasSpan(file_.service(0).method(1).options()\n                      .uninterpreted_option(0)));\n  EXPECT_TRUE(HasSpan(file_.service(0).method(1).options()\n                      .uninterpreted_option(0), \"name\"));\n  EXPECT_TRUE(HasSpan(file_.service(0).method(1).options()\n                      .uninterpreted_option(0).name(0)));\n  EXPECT_TRUE(HasSpan(file_.service(0).method(1).options()\n                      .uninterpreted_option(0).name(0), \"name_part\"));\n  EXPECT_TRUE(HasSpan(file_.service(0).method(1).options()\n                      .uninterpreted_option(0), \"positive_int_value\"));\n  EXPECT_TRUE(HasSpan('1', '2', file_.service(0).method(1),\n                      \"client_streaming\"));\n  EXPECT_TRUE(HasSpan('3', '4', file_.service(0).method(1),\n                      \"server_streaming\"));\n}\n\nTEST_F(SourceInfoTest, FieldOptions) {\n  // The actual \"name = value\" pairs are parsed by the same code as for\n  // top-level options so we won't re-test that -- just make sure that the\n  // syntax used for field options is understood.\n  EXPECT_TRUE(Parse(\n      \"message Foo {\"\n      \"  optional int32 bar = 1 \"\n          \"$a$[default=$b$123$c$,$d$opt1=123$e$,\"\n          \"$f$opt2='hi'$g$]$h$;\"\n      \"}\\n\"\n  ));\n\n  const FieldDescriptorProto& field = file_.message_type(0).field(0);\n  const UninterpretedOption& option1 = field.options().uninterpreted_option(0);\n  const UninterpretedOption& option2 = field.options().uninterpreted_option(1);\n\n  EXPECT_TRUE(HasSpan('a', 'h', field.options()));\n  EXPECT_TRUE(HasSpan('b', 'c', field, \"default_value\"));\n  EXPECT_TRUE(HasSpan('d', 'e', option1));\n  EXPECT_TRUE(HasSpan('f', 'g', option2));\n\n  // Ignore these.\n  EXPECT_TRUE(HasSpan(file_));\n  EXPECT_TRUE(HasSpan(file_.message_type(0)));\n  EXPECT_TRUE(HasSpan(file_.message_type(0), \"name\"));\n  EXPECT_TRUE(HasSpan(field));\n  EXPECT_TRUE(HasSpan(field, \"label\"));\n  EXPECT_TRUE(HasSpan(field, \"type\"));\n  EXPECT_TRUE(HasSpan(field, \"name\"));\n  EXPECT_TRUE(HasSpan(field, \"number\"));\n  EXPECT_TRUE(HasSpan(option1, \"name\"));\n  EXPECT_TRUE(HasSpan(option2, \"name\"));\n  EXPECT_TRUE(HasSpan(option1.name(0)));\n  EXPECT_TRUE(HasSpan(option2.name(0)));\n  EXPECT_TRUE(HasSpan(option1.name(0), \"name_part\"));\n  EXPECT_TRUE(HasSpan(option2.name(0), \"name_part\"));\n  EXPECT_TRUE(HasSpan(option1, \"positive_int_value\"));\n  EXPECT_TRUE(HasSpan(option2, \"string_value\"));\n}\n\nTEST_F(SourceInfoTest, EnumValueOptions) {\n  // The actual \"name = value\" pairs are parsed by the same code as for\n  // top-level options so we won't re-test that -- just make sure that the\n  // syntax used for enum options is understood.\n  EXPECT_TRUE(Parse(\n      \"enum Foo {\"\n      \"  BAR = 1 $a$[$b$opt1=123$c$,$d$opt2='hi'$e$]$f$;\"\n      \"}\\n\"\n  ));\n\n  const EnumValueDescriptorProto& value = file_.enum_type(0).value(0);\n  const UninterpretedOption& option1 = value.options().uninterpreted_option(0);\n  const UninterpretedOption& option2 = value.options().uninterpreted_option(1);\n\n  EXPECT_TRUE(HasSpan('a', 'f', value.options()));\n  EXPECT_TRUE(HasSpan('b', 'c', option1));\n  EXPECT_TRUE(HasSpan('d', 'e', option2));\n\n  // Ignore these.\n  EXPECT_TRUE(HasSpan(file_));\n  EXPECT_TRUE(HasSpan(file_.enum_type(0)));\n  EXPECT_TRUE(HasSpan(file_.enum_type(0), \"name\"));\n  EXPECT_TRUE(HasSpan(value));\n  EXPECT_TRUE(HasSpan(value, \"name\"));\n  EXPECT_TRUE(HasSpan(value, \"number\"));\n  EXPECT_TRUE(HasSpan(option1, \"name\"));\n  EXPECT_TRUE(HasSpan(option2, \"name\"));\n  EXPECT_TRUE(HasSpan(option1.name(0)));\n  EXPECT_TRUE(HasSpan(option2.name(0)));\n  EXPECT_TRUE(HasSpan(option1.name(0), \"name_part\"));\n  EXPECT_TRUE(HasSpan(option2.name(0), \"name_part\"));\n  EXPECT_TRUE(HasSpan(option1, \"positive_int_value\"));\n  EXPECT_TRUE(HasSpan(option2, \"string_value\"));\n}\n\nTEST_F(SourceInfoTest, DocComments) {\n  EXPECT_TRUE(Parse(\n      \"// Foo leading\\n\"\n      \"// line 2\\n\"\n      \"$a$message Foo {\\n\"\n      \"  // Foo trailing\\n\"\n      \"  // line 2\\n\"\n      \"\\n\"\n      \"  // detached\\n\"\n      \"\\n\"\n      \"  // bar leading\\n\"\n      \"  $b$optional int32 bar = 1;$c$\\n\"\n      \"  // bar trailing\\n\"\n      \"}$d$\\n\"\n      \"// ignored\\n\"\n  ));\n\n  const DescriptorProto& foo = file_.message_type(0);\n  const FieldDescriptorProto& bar = foo.field(0);\n\n  EXPECT_TRUE(HasSpanWithComment('a', 'd', foo,\n      \" Foo leading\\n line 2\\n\",\n      \" Foo trailing\\n line 2\\n\",\n      NULL));\n  EXPECT_TRUE(HasSpanWithComment('b', 'c', bar,\n      \" bar leading\\n\",\n      \" bar trailing\\n\",\n      \" detached\\n\"));\n\n  // Ignore these.\n  EXPECT_TRUE(HasSpan(file_));\n  EXPECT_TRUE(HasSpan(foo, \"name\"));\n  EXPECT_TRUE(HasSpan(bar, \"label\"));\n  EXPECT_TRUE(HasSpan(bar, \"type\"));\n  EXPECT_TRUE(HasSpan(bar, \"name\"));\n  EXPECT_TRUE(HasSpan(bar, \"number\"));\n}\n\nTEST_F(SourceInfoTest, DocComments2) {\n  EXPECT_TRUE(Parse(\n      \"// detached before message.\\n\"\n      \"\\n\"\n      \"// Foo leading\\n\"\n      \"// line 2\\n\"\n      \"$a$message Foo {\\n\"\n      \"  /* Foo trailing\\n\"\n      \"   * line 2 */\\n\"\n      \"  // detached\\n\"\n      \"  /* bar leading\\n\"\n      \"   */\"\n      \"  $b$optional int32 bar = 1;$c$  // bar trailing\\n\"\n      \"  // ignored detached\\n\"\n      \"}$d$\\n\"\n      \"// ignored\\n\"\n      \"\\n\"\n      \"// detached before option\\n\"\n      \"\\n\"\n      \"// option leading\\n\"\n      \"$e$option baz = 123;$f$\\n\"\n      \"// option trailing\\n\"\n  ));\n\n  const DescriptorProto& foo = file_.message_type(0);\n  const FieldDescriptorProto& bar = foo.field(0);\n  const UninterpretedOption& baz = file_.options().uninterpreted_option(0);\n\n  EXPECT_TRUE(HasSpanWithComment('a', 'd', foo,\n      \" Foo leading\\n line 2\\n\",\n      \" Foo trailing\\n line 2 \",\n      \" detached before message.\\n\"));\n  EXPECT_TRUE(HasSpanWithComment('b', 'c', bar,\n      \" bar leading\\n\",\n      \" bar trailing\\n\",\n      \" detached\\n\"));\n  EXPECT_TRUE(HasSpanWithComment('e', 'f', baz,\n      \" option leading\\n\",\n      \" option trailing\\n\",\n      \" detached before option\\n\"));\n\n  // Ignore these.\n  EXPECT_TRUE(HasSpan(file_));\n  EXPECT_TRUE(HasSpan(foo, \"name\"));\n  EXPECT_TRUE(HasSpan(bar, \"label\"));\n  EXPECT_TRUE(HasSpan(bar, \"type\"));\n  EXPECT_TRUE(HasSpan(bar, \"name\"));\n  EXPECT_TRUE(HasSpan(bar, \"number\"));\n  EXPECT_TRUE(HasSpan(file_.options()));\n  EXPECT_TRUE(HasSpan(baz, \"name\"));\n  EXPECT_TRUE(HasSpan(baz.name(0)));\n  EXPECT_TRUE(HasSpan(baz.name(0), \"name_part\"));\n  EXPECT_TRUE(HasSpan(baz, \"positive_int_value\"));\n}\n\nTEST_F(SourceInfoTest, DocComments3) {\n  EXPECT_TRUE(Parse(\n      \"$a$message Foo {\\n\"\n      \"  // bar leading\\n\"\n      \"  $b$optional int32 bar = 1 [(baz.qux) = {}];$c$\\n\"\n      \"  // bar trailing\\n\"\n      \"}$d$\\n\"\n      \"// ignored\\n\"\n  ));\n\n  const DescriptorProto& foo = file_.message_type(0);\n  const FieldDescriptorProto& bar = foo.field(0);\n\n  EXPECT_TRUE(HasSpanWithComment('b', 'c', bar,\n      \" bar leading\\n\",\n      \" bar trailing\\n\",\n      NULL));\n\n  // Ignore these.\n  EXPECT_TRUE(HasSpan(file_));\n  EXPECT_TRUE(HasSpan(foo));\n  EXPECT_TRUE(HasSpan(foo, \"name\"));\n  EXPECT_TRUE(HasSpan(bar, \"label\"));\n  EXPECT_TRUE(HasSpan(bar, \"type\"));\n  EXPECT_TRUE(HasSpan(bar, \"name\"));\n  EXPECT_TRUE(HasSpan(bar, \"number\"));\n  EXPECT_TRUE(HasSpan(bar.options()));\n  EXPECT_TRUE(HasSpan(bar.options().uninterpreted_option(0)));\n  EXPECT_TRUE(HasSpan(bar.options().uninterpreted_option(0), \"name\"));\n  EXPECT_TRUE(HasSpan(bar.options().uninterpreted_option(0).name(0)));\n  EXPECT_TRUE(HasSpan(\n      bar.options().uninterpreted_option(0).name(0), \"name_part\"));\n  EXPECT_TRUE(HasSpan(\n      bar.options().uninterpreted_option(0), \"aggregate_value\"));\n}\n\nTEST_F(SourceInfoTest, DocCommentsTopLevel) {\n  EXPECT_TRUE(Parse(\n      \"// detached before syntax paragraph 1\\n\"\n      \"\\n\"\n      \"// detached before syntax paragraph 2\\n\"\n      \"\\n\"\n      \"// syntax leading\\n\"\n      \"$a$syntax = \\\"proto2\\\";$b$\\n\"\n      \"// syntax trailing\\n\"\n      \"\\n\"\n      \"// syntax-package detached comments\\n\"\n      \"\\n\"\n      \";\\n\"\n      \"\\n\"\n      \"// detached after empty before package\\n\"\n      \"\\n\"\n      \"// package leading\\n\"\n      \"package $c$foo$d$;\\n\"\n      \"// package trailing\\n\"\n      \"\\n\"\n      \"// ignored detach\\n\"\n      \"\\n\"));\n\n  EXPECT_TRUE(HasSpan('a', 'b', file_, \"syntax\", -1,\n      \" syntax leading\\n\",\n      \" syntax trailing\\n\",\n      \" detached before syntax paragraph 1\\n\"\n      \"\\n\"\n      \" detached before syntax paragraph 2\\n\"));\n  EXPECT_TRUE(HasSpan('c', 'd', file_, \"package\", -1,\n      \" package leading\\n\",\n      \" package trailing\\n\",\n      \" syntax-package detached comments\\n\"\n      \"\\n\"\n      \" detached after empty before package\\n\"));\n\n  // ignore these.\n  EXPECT_TRUE(HasSpan(file_));\n}\n\nTEST_F(SourceInfoTest, DocCommentsOneof) {\n  EXPECT_TRUE(Parse(\n      \"// Foo leading\\n\"\n      \"$a$message Foo {\\n\"\n      \"  /* Foo trailing\\n\"\n      \"   */\\n\"\n      \"  // detached before oneof\\n\"\n      \"  /* bar leading\\n\"\n      \"   * line 2 */\\n\"\n      \"  $b$oneof bar {\\n\"\n      \"  /* bar trailing\\n\"\n      \"   * line 2 */\\n\"\n      \"  // detached before bar_int\\n\"\n      \"  /* bar_int leading\\n\"\n      \"   */\\n\"\n      \"  $c$int32 bar_int = 1;$d$  // bar_int trailing\\n\"\n      \"  // detach comment ignored\\n\"\n      \"  }$e$\\n\"\n      \"}$f$\\n\"));\n\n  const DescriptorProto& foo = file_.message_type(0);\n  const OneofDescriptorProto& bar = foo.oneof_decl(0);\n  const FieldDescriptorProto& bar_int = foo.field(0);\n\n  EXPECT_TRUE(HasSpanWithComment('a', 'f', foo,\n      \" Foo leading\\n\",\n      \" Foo trailing\\n\",\n      NULL));\n  EXPECT_TRUE(HasSpanWithComment('b', 'e', bar,\n      \" bar leading\\n line 2 \",\n      \" bar trailing\\n line 2 \",\n      \" detached before oneof\\n\"));\n  EXPECT_TRUE(HasSpanWithComment('c', 'd', bar_int,\n      \" bar_int leading\\n\",\n      \" bar_int trailing\\n\",\n      \" detached before bar_int\\n\"));\n\n  // Ignore these.\n  EXPECT_TRUE(HasSpan(file_));\n  EXPECT_TRUE(HasSpan(foo, \"name\"));\n  EXPECT_TRUE(HasSpan(bar, \"name\"));\n  EXPECT_TRUE(HasSpan(bar_int, \"type\"));\n  EXPECT_TRUE(HasSpan(bar_int, \"name\"));\n  EXPECT_TRUE(HasSpan(bar_int, \"number\"));\n}\n\n// ===================================================================\n\n}  // anonymous namespace\n\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/plugin.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n\n#include <google/protobuf/compiler/plugin.h>\n\n#include <iostream>\n#include <set>\n\n#ifdef _WIN32\n#include <io.h>\n#include <fcntl.h>\n#ifndef STDIN_FILENO\n#define STDIN_FILENO 0\n#endif\n#ifndef STDOUT_FILENO\n#define STDOUT_FILENO 1\n#endif\n#else\n#include <unistd.h>\n#endif\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/compiler/plugin.pb.h>\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\n\nclass GeneratorResponseContext : public GeneratorContext {\n public:\n  GeneratorResponseContext(CodeGeneratorResponse* response,\n                           const vector<const FileDescriptor*>& parsed_files)\n      : response_(response),\n        parsed_files_(parsed_files) {}\n  virtual ~GeneratorResponseContext() {}\n\n  // implements GeneratorContext --------------------------------------\n\n  virtual io::ZeroCopyOutputStream* Open(const string& filename) {\n    CodeGeneratorResponse::File* file = response_->add_file();\n    file->set_name(filename);\n    return new io::StringOutputStream(file->mutable_content());\n  }\n\n  virtual io::ZeroCopyOutputStream* OpenForInsert(\n      const string& filename, const string& insertion_point) {\n    CodeGeneratorResponse::File* file = response_->add_file();\n    file->set_name(filename);\n    file->set_insertion_point(insertion_point);\n    return new io::StringOutputStream(file->mutable_content());\n  }\n\n  void ListParsedFiles(vector<const FileDescriptor*>* output) {\n    *output = parsed_files_;\n  }\n\n private:\n  CodeGeneratorResponse* response_;\n  const vector<const FileDescriptor*>& parsed_files_;\n};\n\nbool GenerateCode(const CodeGeneratorRequest& request,\n    const CodeGenerator& generator, CodeGeneratorResponse* response,\n    string* error_msg) {\n  DescriptorPool pool;\n  for (int i = 0; i < request.proto_file_size(); i++) {\n    const FileDescriptor* file = pool.BuildFile(request.proto_file(i));\n    if (file == NULL) {\n      // BuildFile() already wrote an error message.\n      return false;\n    }\n  }\n\n  vector<const FileDescriptor*> parsed_files;\n  for (int i = 0; i < request.file_to_generate_size(); i++) {\n    parsed_files.push_back(pool.FindFileByName(request.file_to_generate(i)));\n    if (parsed_files.back() == NULL) {\n      *error_msg = \"protoc asked plugin to generate a file but \"\n                   \"did not provide a descriptor for the file: \" +\n                   request.file_to_generate(i);\n      return false;\n    }\n  }\n\n  GeneratorResponseContext context(response, parsed_files);\n\n  if (generator.HasGenerateAll()) {\n    string error;\n    bool succeeded = generator.GenerateAll(\n        parsed_files, request.parameter(), &context, &error);\n\n    if (!succeeded && error.empty()) {\n      error = \"Code generator returned false but provided no error \"\n              \"description.\";\n    }\n    if (!error.empty()) {\n      response->set_error(error);\n    }\n  } else {\n    for (int i = 0; i < parsed_files.size(); i++) {\n      const FileDescriptor* file = parsed_files[i];\n\n      string error;\n      bool succeeded = generator.Generate(\n          file, request.parameter(), &context, &error);\n\n      if (!succeeded && error.empty()) {\n        error = \"Code generator returned false but provided no error \"\n                \"description.\";\n      }\n      if (!error.empty()) {\n        response->set_error(file->name() + \": \" + error);\n        break;\n      }\n    }\n  }\n\n  return true;\n}\n\nint PluginMain(int argc, char* argv[], const CodeGenerator* generator) {\n\n  if (argc > 1) {\n    std::cerr << argv[0] << \": Unknown option: \" << argv[1] << std::endl;\n    return 1;\n  }\n\n#ifdef _WIN32\n  _setmode(STDIN_FILENO, _O_BINARY);\n  _setmode(STDOUT_FILENO, _O_BINARY);\n#endif\n\n  CodeGeneratorRequest request;\n  if (!request.ParseFromFileDescriptor(STDIN_FILENO)) {\n    std::cerr << argv[0] << \": protoc sent unparseable request to plugin.\"\n              << std::endl;\n    return 1;\n  }\n\n  string error_msg;\n  CodeGeneratorResponse response;\n\n  if (GenerateCode(request, *generator, &response, &error_msg)) {\n    if (!response.SerializeToFileDescriptor(STDOUT_FILENO)) {\n      std::cerr << argv[0] << \": Error writing to stdout.\" << std::endl;\n      return 1;\n    }\n  } else {\n    if (!error_msg.empty()) {\n      std::cerr << argv[0] << \": \" << error_msg << std::endl;\n    }\n    return 1;\n  }\n\n  return 0;\n}\n\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/plugin.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//\n// Front-end for protoc code generator plugins written in C++.\n//\n// To implement a protoc plugin in C++, simply write an implementation of\n// CodeGenerator, then create a main() function like:\n//   int main(int argc, char* argv[]) {\n//     MyCodeGenerator generator;\n//     return google::protobuf::compiler::PluginMain(argc, argv, &generator);\n//   }\n// You must link your plugin against libprotobuf and libprotoc.\n//\n// The core part of PluginMain is to invoke the given CodeGenerator on a\n// CodeGeneratorRequest to generate a CodeGeneratorResponse. This part is\n// abstracted out and made into function GenerateCode so that it can be reused,\n// for example, to implement a variant of PluginMain that does some\n// preprocessing on the input CodeGeneratorRequest before feeding the request\n// to the given code generator.\n//\n// To get protoc to use the plugin, do one of the following:\n// * Place the plugin binary somewhere in the PATH and give it the name\n//   \"protoc-gen-NAME\" (replacing \"NAME\" with the name of your plugin).  If you\n//   then invoke protoc with the parameter --NAME_out=OUT_DIR (again, replace\n//   \"NAME\" with your plugin's name), protoc will invoke your plugin to generate\n//   the output, which will be placed in OUT_DIR.\n// * Place the plugin binary anywhere, with any name, and pass the --plugin\n//   parameter to protoc to direct it to your plugin like so:\n//     protoc --plugin=protoc-gen-NAME=path/to/mybinary --NAME_out=OUT_DIR\n//   On Windows, make sure to include the .exe suffix:\n//     protoc --plugin=protoc-gen-NAME=path/to/mybinary.exe --NAME_out=OUT_DIR\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__\n#define GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__\n\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\n\nclass CodeGenerator;    // code_generator.h\nclass CodeGeneratorRequest;\nclass CodeGeneratorResponse;\n\n// Implements main() for a protoc plugin exposing the given code generator.\nLIBPROTOC_EXPORT int PluginMain(int argc, char* argv[], const CodeGenerator* generator);\n\n// Generates code using the given code generator. Returns true if the code\n// generation is successful. If the code geneartion fails, error_msg may be\n// populated to describe the failure cause.\nbool GenerateCode(const CodeGeneratorRequest& request,\n    const CodeGenerator& generator, CodeGeneratorResponse* response,\n    string* error_msg);\n\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_PLUGIN_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/plugin.pb.cc",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/compiler/plugin.proto\n\n#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION\n#include <google/protobuf/compiler/plugin.pb.h>\n\n#include <algorithm>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/port.h>\n#include <google/protobuf/stubs/once.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/generated_message_reflection.h>\n#include <google/protobuf/reflection_ops.h>\n#include <google/protobuf/wire_format.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\n\nnamespace {\n\nconst ::google::protobuf::Descriptor* CodeGeneratorRequest_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  CodeGeneratorRequest_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* CodeGeneratorResponse_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  CodeGeneratorResponse_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* CodeGeneratorResponse_File_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  CodeGeneratorResponse_File_reflection_ = NULL;\n\n}  // namespace\n\n\nvoid protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() {\n  protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();\n  const ::google::protobuf::FileDescriptor* file =\n    ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(\n      \"google/protobuf/compiler/plugin.proto\");\n  GOOGLE_CHECK(file != NULL);\n  CodeGeneratorRequest_descriptor_ = file->message_type(0);\n  static const int CodeGeneratorRequest_offsets_[3] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, file_to_generate_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, parameter_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, proto_file_),\n  };\n  CodeGeneratorRequest_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      CodeGeneratorRequest_descriptor_,\n      CodeGeneratorRequest::default_instance_,\n      CodeGeneratorRequest_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _has_bits_[0]),\n      -1,\n      -1,\n      sizeof(CodeGeneratorRequest),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorRequest, _internal_metadata_),\n      -1);\n  CodeGeneratorResponse_descriptor_ = file->message_type(1);\n  static const int CodeGeneratorResponse_offsets_[2] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, error_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, file_),\n  };\n  CodeGeneratorResponse_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      CodeGeneratorResponse_descriptor_,\n      CodeGeneratorResponse::default_instance_,\n      CodeGeneratorResponse_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _has_bits_[0]),\n      -1,\n      -1,\n      sizeof(CodeGeneratorResponse),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse, _internal_metadata_),\n      -1);\n  CodeGeneratorResponse_File_descriptor_ = CodeGeneratorResponse_descriptor_->nested_type(0);\n  static const int CodeGeneratorResponse_File_offsets_[3] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, name_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, insertion_point_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, content_),\n  };\n  CodeGeneratorResponse_File_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      CodeGeneratorResponse_File_descriptor_,\n      CodeGeneratorResponse_File::default_instance_,\n      CodeGeneratorResponse_File_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _has_bits_[0]),\n      -1,\n      -1,\n      sizeof(CodeGeneratorResponse_File),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(CodeGeneratorResponse_File, _internal_metadata_),\n      -1);\n}\n\nnamespace {\n\nGOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);\ninline void protobuf_AssignDescriptorsOnce() {\n  ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,\n                 &protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto);\n}\n\nvoid protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_RegisterTypes(const ::std::string&) {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      CodeGeneratorRequest_descriptor_, &CodeGeneratorRequest::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      CodeGeneratorResponse_descriptor_, &CodeGeneratorResponse::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      CodeGeneratorResponse_File_descriptor_, &CodeGeneratorResponse_File::default_instance());\n}\n\n}  // namespace\n\nvoid protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto() {\n  delete CodeGeneratorRequest::default_instance_;\n  delete CodeGeneratorRequest_reflection_;\n  delete CodeGeneratorResponse::default_instance_;\n  delete CodeGeneratorResponse_reflection_;\n  delete CodeGeneratorResponse_File::default_instance_;\n  delete CodeGeneratorResponse_File_reflection_;\n}\n\nvoid protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto() {\n  static bool already_here = false;\n  if (already_here) return;\n  already_here = true;\n  GOOGLE_PROTOBUF_VERIFY_VERSION;\n\n  ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(\n    \"\\n%google/protobuf/compiler/plugin.proto\\022\"\n    \"\\030google.protobuf.compiler\\032 google/protob\"\n    \"uf/descriptor.proto\\\"}\\n\\024CodeGeneratorRequ\"\n    \"est\\022\\030\\n\\020file_to_generate\\030\\001 \\003(\\t\\022\\021\\n\\tparamet\"\n    \"er\\030\\002 \\001(\\t\\0228\\n\\nproto_file\\030\\017 \\003(\\0132$.google.pr\"\n    \"otobuf.FileDescriptorProto\\\"\\252\\001\\n\\025CodeGener\"\n    \"atorResponse\\022\\r\\n\\005error\\030\\001 \\001(\\t\\022B\\n\\004file\\030\\017 \\003(\"\n    \"\\01324.google.protobuf.compiler.CodeGenerat\"\n    \"orResponse.File\\032>\\n\\004File\\022\\014\\n\\004name\\030\\001 \\001(\\t\\022\\027\\n\"\n    \"\\017insertion_point\\030\\002 \\001(\\t\\022\\017\\n\\007content\\030\\017 \\001(\\tB\"\n    \"7\\n\\034com.google.protobuf.compilerB\\014PluginP\"\n    \"rotosZ\\tplugin_go\", 456);\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(\n    \"google/protobuf/compiler/plugin.proto\", &protobuf_RegisterTypes);\n  CodeGeneratorRequest::default_instance_ = new CodeGeneratorRequest();\n  CodeGeneratorResponse::default_instance_ = new CodeGeneratorResponse();\n  CodeGeneratorResponse_File::default_instance_ = new CodeGeneratorResponse_File();\n  CodeGeneratorRequest::default_instance_->InitAsDefaultInstance();\n  CodeGeneratorResponse::default_instance_->InitAsDefaultInstance();\n  CodeGeneratorResponse_File::default_instance_->InitAsDefaultInstance();\n  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto);\n}\n\n// Force AddDescriptors() to be called at static initialization time.\nstruct StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto {\n  StaticDescriptorInitializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto() {\n    protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();\n  }\n} static_descriptor_initializer_google_2fprotobuf_2fcompiler_2fplugin_2eproto_;\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int CodeGeneratorRequest::kFileToGenerateFieldNumber;\nconst int CodeGeneratorRequest::kParameterFieldNumber;\nconst int CodeGeneratorRequest::kProtoFileFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nCodeGeneratorRequest::CodeGeneratorRequest()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorRequest)\n}\n\nvoid CodeGeneratorRequest::InitAsDefaultInstance() {\n}\n\nCodeGeneratorRequest::CodeGeneratorRequest(const CodeGeneratorRequest& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorRequest)\n}\n\nvoid CodeGeneratorRequest::SharedCtor() {\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  parameter_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nCodeGeneratorRequest::~CodeGeneratorRequest() {\n  // @@protoc_insertion_point(destructor:google.protobuf.compiler.CodeGeneratorRequest)\n  SharedDtor();\n}\n\nvoid CodeGeneratorRequest::SharedDtor() {\n  parameter_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n  }\n}\n\nvoid CodeGeneratorRequest::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* CodeGeneratorRequest::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return CodeGeneratorRequest_descriptor_;\n}\n\nconst CodeGeneratorRequest& CodeGeneratorRequest::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();\n  return *default_instance_;\n}\n\nCodeGeneratorRequest* CodeGeneratorRequest::default_instance_ = NULL;\n\nCodeGeneratorRequest* CodeGeneratorRequest::New(::google::protobuf::Arena* arena) const {\n  CodeGeneratorRequest* n = new CodeGeneratorRequest;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid CodeGeneratorRequest::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorRequest)\n  if (has_parameter()) {\n    parameter_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  }\n  file_to_generate_.Clear();\n  proto_file_.Clear();\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool CodeGeneratorRequest::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.compiler.CodeGeneratorRequest)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // repeated string file_to_generate = 1;\n      case 1: {\n        if (tag == 10) {\n         parse_file_to_generate:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->add_file_to_generate()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->file_to_generate(this->file_to_generate_size() - 1).data(),\n            this->file_to_generate(this->file_to_generate_size() - 1).length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.compiler.CodeGeneratorRequest.file_to_generate\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(10)) goto parse_file_to_generate;\n        if (input->ExpectTag(18)) goto parse_parameter;\n        break;\n      }\n\n      // optional string parameter = 2;\n      case 2: {\n        if (tag == 18) {\n         parse_parameter:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_parameter()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->parameter().data(), this->parameter().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.compiler.CodeGeneratorRequest.parameter\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(122)) goto parse_proto_file;\n        break;\n      }\n\n      // repeated .google.protobuf.FileDescriptorProto proto_file = 15;\n      case 15: {\n        if (tag == 122) {\n         parse_proto_file:\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_proto_file:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_proto_file()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(122)) goto parse_loop_proto_file;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.compiler.CodeGeneratorRequest)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.compiler.CodeGeneratorRequest)\n  return false;\n#undef DO_\n}\n\nvoid CodeGeneratorRequest::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.compiler.CodeGeneratorRequest)\n  // repeated string file_to_generate = 1;\n  for (int i = 0; i < this->file_to_generate_size(); i++) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->file_to_generate(i).data(), this->file_to_generate(i).length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.compiler.CodeGeneratorRequest.file_to_generate\");\n    ::google::protobuf::internal::WireFormatLite::WriteString(\n      1, this->file_to_generate(i), output);\n  }\n\n  // optional string parameter = 2;\n  if (has_parameter()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->parameter().data(), this->parameter().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.compiler.CodeGeneratorRequest.parameter\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      2, this->parameter(), output);\n  }\n\n  // repeated .google.protobuf.FileDescriptorProto proto_file = 15;\n  for (unsigned int i = 0, n = this->proto_file_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      15, this->proto_file(i), output);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.compiler.CodeGeneratorRequest)\n}\n\n::google::protobuf::uint8* CodeGeneratorRequest::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorRequest)\n  // repeated string file_to_generate = 1;\n  for (int i = 0; i < this->file_to_generate_size(); i++) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->file_to_generate(i).data(), this->file_to_generate(i).length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.compiler.CodeGeneratorRequest.file_to_generate\");\n    target = ::google::protobuf::internal::WireFormatLite::\n      WriteStringToArray(1, this->file_to_generate(i), target);\n  }\n\n  // optional string parameter = 2;\n  if (has_parameter()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->parameter().data(), this->parameter().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.compiler.CodeGeneratorRequest.parameter\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        2, this->parameter(), target);\n  }\n\n  // repeated .google.protobuf.FileDescriptorProto proto_file = 15;\n  for (unsigned int i = 0, n = this->proto_file_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        15, this->proto_file(i), false, target);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.CodeGeneratorRequest)\n  return target;\n}\n\nint CodeGeneratorRequest::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorRequest)\n  int total_size = 0;\n\n  // optional string parameter = 2;\n  if (has_parameter()) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::StringSize(\n        this->parameter());\n  }\n\n  // repeated string file_to_generate = 1;\n  total_size += 1 * this->file_to_generate_size();\n  for (int i = 0; i < this->file_to_generate_size(); i++) {\n    total_size += ::google::protobuf::internal::WireFormatLite::StringSize(\n      this->file_to_generate(i));\n  }\n\n  // repeated .google.protobuf.FileDescriptorProto proto_file = 15;\n  total_size += 1 * this->proto_file_size();\n  for (int i = 0; i < this->proto_file_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->proto_file(i));\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid CodeGeneratorRequest::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const CodeGeneratorRequest* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const CodeGeneratorRequest>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.compiler.CodeGeneratorRequest)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.CodeGeneratorRequest)\n    MergeFrom(*source);\n  }\n}\n\nvoid CodeGeneratorRequest::MergeFrom(const CodeGeneratorRequest& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorRequest)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  file_to_generate_.MergeFrom(from.file_to_generate_);\n  proto_file_.MergeFrom(from.proto_file_);\n  if (from._has_bits_[1 / 32] & (0xffu << (1 % 32))) {\n    if (from.has_parameter()) {\n      set_has_parameter();\n      parameter_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.parameter_);\n    }\n  }\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid CodeGeneratorRequest::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.compiler.CodeGeneratorRequest)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid CodeGeneratorRequest::CopyFrom(const CodeGeneratorRequest& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorRequest)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool CodeGeneratorRequest::IsInitialized() const {\n\n  if (!::google::protobuf::internal::AllAreInitialized(this->proto_file())) return false;\n  return true;\n}\n\nvoid CodeGeneratorRequest::Swap(CodeGeneratorRequest* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid CodeGeneratorRequest::InternalSwap(CodeGeneratorRequest* other) {\n  file_to_generate_.UnsafeArenaSwap(&other->file_to_generate_);\n  parameter_.Swap(&other->parameter_);\n  proto_file_.UnsafeArenaSwap(&other->proto_file_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata CodeGeneratorRequest::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = CodeGeneratorRequest_descriptor_;\n  metadata.reflection = CodeGeneratorRequest_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// CodeGeneratorRequest\n\n// repeated string file_to_generate = 1;\nint CodeGeneratorRequest::file_to_generate_size() const {\n  return file_to_generate_.size();\n}\nvoid CodeGeneratorRequest::clear_file_to_generate() {\n  file_to_generate_.Clear();\n}\n const ::std::string& CodeGeneratorRequest::file_to_generate(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)\n  return file_to_generate_.Get(index);\n}\n ::std::string* CodeGeneratorRequest::mutable_file_to_generate(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)\n  return file_to_generate_.Mutable(index);\n}\n void CodeGeneratorRequest::set_file_to_generate(int index, const ::std::string& value) {\n  // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)\n  file_to_generate_.Mutable(index)->assign(value);\n}\n void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) {\n  file_to_generate_.Mutable(index)->assign(value);\n  // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)\n}\n void CodeGeneratorRequest::set_file_to_generate(int index, const char* value, size_t size) {\n  file_to_generate_.Mutable(index)->assign(\n    reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)\n}\n ::std::string* CodeGeneratorRequest::add_file_to_generate() {\n  // @@protoc_insertion_point(field_add_mutable:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)\n  return file_to_generate_.Add();\n}\n void CodeGeneratorRequest::add_file_to_generate(const ::std::string& value) {\n  file_to_generate_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)\n}\n void CodeGeneratorRequest::add_file_to_generate(const char* value) {\n  file_to_generate_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)\n}\n void CodeGeneratorRequest::add_file_to_generate(const char* value, size_t size) {\n  file_to_generate_.Add()->assign(reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_add_pointer:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)\n}\n const ::google::protobuf::RepeatedPtrField< ::std::string>&\nCodeGeneratorRequest::file_to_generate() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)\n  return file_to_generate_;\n}\n ::google::protobuf::RepeatedPtrField< ::std::string>*\nCodeGeneratorRequest::mutable_file_to_generate() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)\n  return &file_to_generate_;\n}\n\n// optional string parameter = 2;\nbool CodeGeneratorRequest::has_parameter() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\nvoid CodeGeneratorRequest::set_has_parameter() {\n  _has_bits_[0] |= 0x00000002u;\n}\nvoid CodeGeneratorRequest::clear_has_parameter() {\n  _has_bits_[0] &= ~0x00000002u;\n}\nvoid CodeGeneratorRequest::clear_parameter() {\n  parameter_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_parameter();\n}\n const ::std::string& CodeGeneratorRequest::parameter() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.parameter)\n  return parameter_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void CodeGeneratorRequest::set_parameter(const ::std::string& value) {\n  set_has_parameter();\n  parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter)\n}\n void CodeGeneratorRequest::set_parameter(const char* value) {\n  set_has_parameter();\n  parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.parameter)\n}\n void CodeGeneratorRequest::set_parameter(const char* value, size_t size) {\n  set_has_parameter();\n  parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorRequest.parameter)\n}\n ::std::string* CodeGeneratorRequest::mutable_parameter() {\n  set_has_parameter();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.parameter)\n  return parameter_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* CodeGeneratorRequest::release_parameter() {\n  // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.parameter)\n  clear_has_parameter();\n  return parameter_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void CodeGeneratorRequest::set_allocated_parameter(::std::string* parameter) {\n  if (parameter != NULL) {\n    set_has_parameter();\n  } else {\n    clear_has_parameter();\n  }\n  parameter_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), parameter);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.parameter)\n}\n\n// repeated .google.protobuf.FileDescriptorProto proto_file = 15;\nint CodeGeneratorRequest::proto_file_size() const {\n  return proto_file_.size();\n}\nvoid CodeGeneratorRequest::clear_proto_file() {\n  proto_file_.Clear();\n}\nconst ::google::protobuf::FileDescriptorProto& CodeGeneratorRequest::proto_file(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.proto_file)\n  return proto_file_.Get(index);\n}\n::google::protobuf::FileDescriptorProto* CodeGeneratorRequest::mutable_proto_file(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.proto_file)\n  return proto_file_.Mutable(index);\n}\n::google::protobuf::FileDescriptorProto* CodeGeneratorRequest::add_proto_file() {\n  // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.proto_file)\n  return proto_file_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >*\nCodeGeneratorRequest::mutable_proto_file() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorRequest.proto_file)\n  return &proto_file_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >&\nCodeGeneratorRequest::proto_file() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorRequest.proto_file)\n  return proto_file_;\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int CodeGeneratorResponse_File::kNameFieldNumber;\nconst int CodeGeneratorResponse_File::kInsertionPointFieldNumber;\nconst int CodeGeneratorResponse_File::kContentFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nCodeGeneratorResponse_File::CodeGeneratorResponse_File()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorResponse.File)\n}\n\nvoid CodeGeneratorResponse_File::InitAsDefaultInstance() {\n}\n\nCodeGeneratorResponse_File::CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse.File)\n}\n\nvoid CodeGeneratorResponse_File::SharedCtor() {\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  insertion_point_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  content_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nCodeGeneratorResponse_File::~CodeGeneratorResponse_File() {\n  // @@protoc_insertion_point(destructor:google.protobuf.compiler.CodeGeneratorResponse.File)\n  SharedDtor();\n}\n\nvoid CodeGeneratorResponse_File::SharedDtor() {\n  name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  insertion_point_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  content_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n  }\n}\n\nvoid CodeGeneratorResponse_File::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* CodeGeneratorResponse_File::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return CodeGeneratorResponse_File_descriptor_;\n}\n\nconst CodeGeneratorResponse_File& CodeGeneratorResponse_File::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();\n  return *default_instance_;\n}\n\nCodeGeneratorResponse_File* CodeGeneratorResponse_File::default_instance_ = NULL;\n\nCodeGeneratorResponse_File* CodeGeneratorResponse_File::New(::google::protobuf::Arena* arena) const {\n  CodeGeneratorResponse_File* n = new CodeGeneratorResponse_File;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid CodeGeneratorResponse_File::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse.File)\n  if (_has_bits_[0 / 32] & 7u) {\n    if (has_name()) {\n      name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    if (has_insertion_point()) {\n      insertion_point_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    if (has_content()) {\n      content_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n  }\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool CodeGeneratorResponse_File::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.compiler.CodeGeneratorResponse.File)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional string name = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_name()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->name().data(), this->name().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.compiler.CodeGeneratorResponse.File.name\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_insertion_point;\n        break;\n      }\n\n      // optional string insertion_point = 2;\n      case 2: {\n        if (tag == 18) {\n         parse_insertion_point:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_insertion_point()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->insertion_point().data(), this->insertion_point().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(122)) goto parse_content;\n        break;\n      }\n\n      // optional string content = 15;\n      case 15: {\n        if (tag == 122) {\n         parse_content:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_content()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->content().data(), this->content().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.compiler.CodeGeneratorResponse.File.content\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.compiler.CodeGeneratorResponse.File)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.compiler.CodeGeneratorResponse.File)\n  return false;\n#undef DO_\n}\n\nvoid CodeGeneratorResponse_File::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.compiler.CodeGeneratorResponse.File)\n  // optional string name = 1;\n  if (has_name()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.compiler.CodeGeneratorResponse.File.name\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      1, this->name(), output);\n  }\n\n  // optional string insertion_point = 2;\n  if (has_insertion_point()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->insertion_point().data(), this->insertion_point().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      2, this->insertion_point(), output);\n  }\n\n  // optional string content = 15;\n  if (has_content()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->content().data(), this->content().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.compiler.CodeGeneratorResponse.File.content\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      15, this->content(), output);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.compiler.CodeGeneratorResponse.File)\n}\n\n::google::protobuf::uint8* CodeGeneratorResponse_File::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse.File)\n  // optional string name = 1;\n  if (has_name()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.compiler.CodeGeneratorResponse.File.name\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        1, this->name(), target);\n  }\n\n  // optional string insertion_point = 2;\n  if (has_insertion_point()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->insertion_point().data(), this->insertion_point().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        2, this->insertion_point(), target);\n  }\n\n  // optional string content = 15;\n  if (has_content()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->content().data(), this->content().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.compiler.CodeGeneratorResponse.File.content\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        15, this->content(), target);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.CodeGeneratorResponse.File)\n  return target;\n}\n\nint CodeGeneratorResponse_File::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse.File)\n  int total_size = 0;\n\n  if (_has_bits_[0 / 32] & 7u) {\n    // optional string name = 1;\n    if (has_name()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->name());\n    }\n\n    // optional string insertion_point = 2;\n    if (has_insertion_point()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->insertion_point());\n    }\n\n    // optional string content = 15;\n    if (has_content()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->content());\n    }\n\n  }\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid CodeGeneratorResponse_File::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse.File)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const CodeGeneratorResponse_File* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const CodeGeneratorResponse_File>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.compiler.CodeGeneratorResponse.File)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.CodeGeneratorResponse.File)\n    MergeFrom(*source);\n  }\n}\n\nvoid CodeGeneratorResponse_File::MergeFrom(const CodeGeneratorResponse_File& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse.File)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {\n    if (from.has_name()) {\n      set_has_name();\n      name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);\n    }\n    if (from.has_insertion_point()) {\n      set_has_insertion_point();\n      insertion_point_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.insertion_point_);\n    }\n    if (from.has_content()) {\n      set_has_content();\n      content_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.content_);\n    }\n  }\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid CodeGeneratorResponse_File::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.compiler.CodeGeneratorResponse.File)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid CodeGeneratorResponse_File::CopyFrom(const CodeGeneratorResponse_File& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorResponse.File)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool CodeGeneratorResponse_File::IsInitialized() const {\n\n  return true;\n}\n\nvoid CodeGeneratorResponse_File::Swap(CodeGeneratorResponse_File* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid CodeGeneratorResponse_File::InternalSwap(CodeGeneratorResponse_File* other) {\n  name_.Swap(&other->name_);\n  insertion_point_.Swap(&other->insertion_point_);\n  content_.Swap(&other->content_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata CodeGeneratorResponse_File::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = CodeGeneratorResponse_File_descriptor_;\n  metadata.reflection = CodeGeneratorResponse_File_reflection_;\n  return metadata;\n}\n\n\n// -------------------------------------------------------------------\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int CodeGeneratorResponse::kErrorFieldNumber;\nconst int CodeGeneratorResponse::kFileFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nCodeGeneratorResponse::CodeGeneratorResponse()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.compiler.CodeGeneratorResponse)\n}\n\nvoid CodeGeneratorResponse::InitAsDefaultInstance() {\n}\n\nCodeGeneratorResponse::CodeGeneratorResponse(const CodeGeneratorResponse& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.compiler.CodeGeneratorResponse)\n}\n\nvoid CodeGeneratorResponse::SharedCtor() {\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  error_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nCodeGeneratorResponse::~CodeGeneratorResponse() {\n  // @@protoc_insertion_point(destructor:google.protobuf.compiler.CodeGeneratorResponse)\n  SharedDtor();\n}\n\nvoid CodeGeneratorResponse::SharedDtor() {\n  error_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n  }\n}\n\nvoid CodeGeneratorResponse::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* CodeGeneratorResponse::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return CodeGeneratorResponse_descriptor_;\n}\n\nconst CodeGeneratorResponse& CodeGeneratorResponse::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();\n  return *default_instance_;\n}\n\nCodeGeneratorResponse* CodeGeneratorResponse::default_instance_ = NULL;\n\nCodeGeneratorResponse* CodeGeneratorResponse::New(::google::protobuf::Arena* arena) const {\n  CodeGeneratorResponse* n = new CodeGeneratorResponse;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid CodeGeneratorResponse::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.compiler.CodeGeneratorResponse)\n  if (has_error()) {\n    error_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  }\n  file_.Clear();\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool CodeGeneratorResponse::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.compiler.CodeGeneratorResponse)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional string error = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_error()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->error().data(), this->error().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.compiler.CodeGeneratorResponse.error\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(122)) goto parse_file;\n        break;\n      }\n\n      // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;\n      case 15: {\n        if (tag == 122) {\n         parse_file:\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_file:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_file()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(122)) goto parse_loop_file;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.compiler.CodeGeneratorResponse)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.compiler.CodeGeneratorResponse)\n  return false;\n#undef DO_\n}\n\nvoid CodeGeneratorResponse::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.compiler.CodeGeneratorResponse)\n  // optional string error = 1;\n  if (has_error()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->error().data(), this->error().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.compiler.CodeGeneratorResponse.error\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      1, this->error(), output);\n  }\n\n  // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;\n  for (unsigned int i = 0, n = this->file_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      15, this->file(i), output);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.compiler.CodeGeneratorResponse)\n}\n\n::google::protobuf::uint8* CodeGeneratorResponse::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.compiler.CodeGeneratorResponse)\n  // optional string error = 1;\n  if (has_error()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->error().data(), this->error().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.compiler.CodeGeneratorResponse.error\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        1, this->error(), target);\n  }\n\n  // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;\n  for (unsigned int i = 0, n = this->file_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        15, this->file(i), false, target);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.compiler.CodeGeneratorResponse)\n  return target;\n}\n\nint CodeGeneratorResponse::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.compiler.CodeGeneratorResponse)\n  int total_size = 0;\n\n  // optional string error = 1;\n  if (has_error()) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::StringSize(\n        this->error());\n  }\n\n  // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;\n  total_size += 1 * this->file_size();\n  for (int i = 0; i < this->file_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->file(i));\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid CodeGeneratorResponse::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const CodeGeneratorResponse* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const CodeGeneratorResponse>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.compiler.CodeGeneratorResponse)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.compiler.CodeGeneratorResponse)\n    MergeFrom(*source);\n  }\n}\n\nvoid CodeGeneratorResponse::MergeFrom(const CodeGeneratorResponse& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.compiler.CodeGeneratorResponse)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  file_.MergeFrom(from.file_);\n  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {\n    if (from.has_error()) {\n      set_has_error();\n      error_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.error_);\n    }\n  }\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid CodeGeneratorResponse::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.compiler.CodeGeneratorResponse)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid CodeGeneratorResponse::CopyFrom(const CodeGeneratorResponse& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.compiler.CodeGeneratorResponse)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool CodeGeneratorResponse::IsInitialized() const {\n\n  return true;\n}\n\nvoid CodeGeneratorResponse::Swap(CodeGeneratorResponse* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid CodeGeneratorResponse::InternalSwap(CodeGeneratorResponse* other) {\n  error_.Swap(&other->error_);\n  file_.UnsafeArenaSwap(&other->file_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata CodeGeneratorResponse::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = CodeGeneratorResponse_descriptor_;\n  metadata.reflection = CodeGeneratorResponse_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// CodeGeneratorResponse_File\n\n// optional string name = 1;\nbool CodeGeneratorResponse_File::has_name() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\nvoid CodeGeneratorResponse_File::set_has_name() {\n  _has_bits_[0] |= 0x00000001u;\n}\nvoid CodeGeneratorResponse_File::clear_has_name() {\n  _has_bits_[0] &= ~0x00000001u;\n}\nvoid CodeGeneratorResponse_File::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_name();\n}\n const ::std::string& CodeGeneratorResponse_File::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void CodeGeneratorResponse_File::set_name(const ::std::string& value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name)\n}\n void CodeGeneratorResponse_File::set_name(const char* value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.name)\n}\n void CodeGeneratorResponse_File::set_name(const char* value, size_t size) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.name)\n}\n ::std::string* CodeGeneratorResponse_File::mutable_name() {\n  set_has_name();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* CodeGeneratorResponse_File::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.name)\n  clear_has_name();\n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void CodeGeneratorResponse_File::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    set_has_name();\n  } else {\n    clear_has_name();\n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name)\n}\n\n// optional string insertion_point = 2;\nbool CodeGeneratorResponse_File::has_insertion_point() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\nvoid CodeGeneratorResponse_File::set_has_insertion_point() {\n  _has_bits_[0] |= 0x00000002u;\n}\nvoid CodeGeneratorResponse_File::clear_has_insertion_point() {\n  _has_bits_[0] &= ~0x00000002u;\n}\nvoid CodeGeneratorResponse_File::clear_insertion_point() {\n  insertion_point_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_insertion_point();\n}\n const ::std::string& CodeGeneratorResponse_File::insertion_point() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)\n  return insertion_point_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void CodeGeneratorResponse_File::set_insertion_point(const ::std::string& value) {\n  set_has_insertion_point();\n  insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)\n}\n void CodeGeneratorResponse_File::set_insertion_point(const char* value) {\n  set_has_insertion_point();\n  insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)\n}\n void CodeGeneratorResponse_File::set_insertion_point(const char* value, size_t size) {\n  set_has_insertion_point();\n  insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)\n}\n ::std::string* CodeGeneratorResponse_File::mutable_insertion_point() {\n  set_has_insertion_point();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)\n  return insertion_point_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* CodeGeneratorResponse_File::release_insertion_point() {\n  // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)\n  clear_has_insertion_point();\n  return insertion_point_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void CodeGeneratorResponse_File::set_allocated_insertion_point(::std::string* insertion_point) {\n  if (insertion_point != NULL) {\n    set_has_insertion_point();\n  } else {\n    clear_has_insertion_point();\n  }\n  insertion_point_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), insertion_point);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)\n}\n\n// optional string content = 15;\nbool CodeGeneratorResponse_File::has_content() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\nvoid CodeGeneratorResponse_File::set_has_content() {\n  _has_bits_[0] |= 0x00000004u;\n}\nvoid CodeGeneratorResponse_File::clear_has_content() {\n  _has_bits_[0] &= ~0x00000004u;\n}\nvoid CodeGeneratorResponse_File::clear_content() {\n  content_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_content();\n}\n const ::std::string& CodeGeneratorResponse_File::content() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.content)\n  return content_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void CodeGeneratorResponse_File::set_content(const ::std::string& value) {\n  set_has_content();\n  content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content)\n}\n void CodeGeneratorResponse_File::set_content(const char* value) {\n  set_has_content();\n  content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.content)\n}\n void CodeGeneratorResponse_File::set_content(const char* value, size_t size) {\n  set_has_content();\n  content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.content)\n}\n ::std::string* CodeGeneratorResponse_File::mutable_content() {\n  set_has_content();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.content)\n  return content_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* CodeGeneratorResponse_File::release_content() {\n  // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.content)\n  clear_has_content();\n  return content_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void CodeGeneratorResponse_File::set_allocated_content(::std::string* content) {\n  if (content != NULL) {\n    set_has_content();\n  } else {\n    clear_has_content();\n  }\n  content_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), content);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content)\n}\n\n// -------------------------------------------------------------------\n\n// CodeGeneratorResponse\n\n// optional string error = 1;\nbool CodeGeneratorResponse::has_error() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\nvoid CodeGeneratorResponse::set_has_error() {\n  _has_bits_[0] |= 0x00000001u;\n}\nvoid CodeGeneratorResponse::clear_has_error() {\n  _has_bits_[0] &= ~0x00000001u;\n}\nvoid CodeGeneratorResponse::clear_error() {\n  error_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_error();\n}\n const ::std::string& CodeGeneratorResponse::error() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.error)\n  return error_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void CodeGeneratorResponse::set_error(const ::std::string& value) {\n  set_has_error();\n  error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error)\n}\n void CodeGeneratorResponse::set_error(const char* value) {\n  set_has_error();\n  error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.error)\n}\n void CodeGeneratorResponse::set_error(const char* value, size_t size) {\n  set_has_error();\n  error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.error)\n}\n ::std::string* CodeGeneratorResponse::mutable_error() {\n  set_has_error();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.error)\n  return error_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* CodeGeneratorResponse::release_error() {\n  // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.error)\n  clear_has_error();\n  return error_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void CodeGeneratorResponse::set_allocated_error(::std::string* error) {\n  if (error != NULL) {\n    set_has_error();\n  } else {\n    clear_has_error();\n  }\n  error_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), error);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.error)\n}\n\n// repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;\nint CodeGeneratorResponse::file_size() const {\n  return file_.size();\n}\nvoid CodeGeneratorResponse::clear_file() {\n  file_.Clear();\n}\nconst ::google::protobuf::compiler::CodeGeneratorResponse_File& CodeGeneratorResponse::file(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.file)\n  return file_.Get(index);\n}\n::google::protobuf::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::mutable_file(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.file)\n  return file_.Mutable(index);\n}\n::google::protobuf::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::add_file() {\n  // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorResponse.file)\n  return file_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >*\nCodeGeneratorResponse::mutable_file() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorResponse.file)\n  return &file_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >&\nCodeGeneratorResponse::file() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorResponse.file)\n  return file_;\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n// @@protoc_insertion_point(global_scope)\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/plugin.pb.h",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/compiler/plugin.proto\n\n#ifndef PROTOBUF_google_2fprotobuf_2fcompiler_2fplugin_2eproto__INCLUDED\n#define PROTOBUF_google_2fprotobuf_2fcompiler_2fplugin_2eproto__INCLUDED\n\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n\n#if GOOGLE_PROTOBUF_VERSION < 3000000\n#error This file was generated by a newer version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please update\n#error your headers.\n#endif\n#if 3000000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION\n#error This file was generated by an older version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please\n#error regenerate this file with a newer version of protoc.\n#endif\n\n#include <google/protobuf/arena.h>\n#include <google/protobuf/arenastring.h>\n#include <google/protobuf/generated_message_util.h>\n#include <google/protobuf/metadata.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/extension_set.h>\n#include <google/protobuf/unknown_field_set.h>\n#include <google/protobuf/descriptor.pb.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\n\n// Internal implementation detail -- do not call these.\nvoid LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();\nvoid protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();\nvoid protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto();\n\nclass CodeGeneratorRequest;\nclass CodeGeneratorResponse;\nclass CodeGeneratorResponse_File;\n\n// ===================================================================\n\nclass LIBPROTOC_EXPORT CodeGeneratorRequest : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorRequest) */ {\n public:\n  CodeGeneratorRequest();\n  virtual ~CodeGeneratorRequest();\n\n  CodeGeneratorRequest(const CodeGeneratorRequest& from);\n\n  inline CodeGeneratorRequest& operator=(const CodeGeneratorRequest& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const CodeGeneratorRequest& default_instance();\n\n  void Swap(CodeGeneratorRequest* other);\n\n  // implements Message ----------------------------------------------\n\n  inline CodeGeneratorRequest* New() const { return New(NULL); }\n\n  CodeGeneratorRequest* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const CodeGeneratorRequest& from);\n  void MergeFrom(const CodeGeneratorRequest& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(CodeGeneratorRequest* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // repeated string file_to_generate = 1;\n  int file_to_generate_size() const;\n  void clear_file_to_generate();\n  static const int kFileToGenerateFieldNumber = 1;\n  const ::std::string& file_to_generate(int index) const;\n  ::std::string* mutable_file_to_generate(int index);\n  void set_file_to_generate(int index, const ::std::string& value);\n  void set_file_to_generate(int index, const char* value);\n  void set_file_to_generate(int index, const char* value, size_t size);\n  ::std::string* add_file_to_generate();\n  void add_file_to_generate(const ::std::string& value);\n  void add_file_to_generate(const char* value);\n  void add_file_to_generate(const char* value, size_t size);\n  const ::google::protobuf::RepeatedPtrField< ::std::string>& file_to_generate() const;\n  ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_file_to_generate();\n\n  // optional string parameter = 2;\n  bool has_parameter() const;\n  void clear_parameter();\n  static const int kParameterFieldNumber = 2;\n  const ::std::string& parameter() const;\n  void set_parameter(const ::std::string& value);\n  void set_parameter(const char* value);\n  void set_parameter(const char* value, size_t size);\n  ::std::string* mutable_parameter();\n  ::std::string* release_parameter();\n  void set_allocated_parameter(::std::string* parameter);\n\n  // repeated .google.protobuf.FileDescriptorProto proto_file = 15;\n  int proto_file_size() const;\n  void clear_proto_file();\n  static const int kProtoFileFieldNumber = 15;\n  const ::google::protobuf::FileDescriptorProto& proto_file(int index) const;\n  ::google::protobuf::FileDescriptorProto* mutable_proto_file(int index);\n  ::google::protobuf::FileDescriptorProto* add_proto_file();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >*\n      mutable_proto_file();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >&\n      proto_file() const;\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorRequest)\n private:\n  inline void set_has_parameter();\n  inline void clear_has_parameter();\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::RepeatedPtrField< ::std::string> file_to_generate_;\n  ::google::protobuf::internal::ArenaStringPtr parameter_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto > proto_file_;\n  friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto();\n\n  void InitAsDefaultInstance();\n  static CodeGeneratorRequest* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOC_EXPORT CodeGeneratorResponse_File : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse.File) */ {\n public:\n  CodeGeneratorResponse_File();\n  virtual ~CodeGeneratorResponse_File();\n\n  CodeGeneratorResponse_File(const CodeGeneratorResponse_File& from);\n\n  inline CodeGeneratorResponse_File& operator=(const CodeGeneratorResponse_File& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const CodeGeneratorResponse_File& default_instance();\n\n  void Swap(CodeGeneratorResponse_File* other);\n\n  // implements Message ----------------------------------------------\n\n  inline CodeGeneratorResponse_File* New() const { return New(NULL); }\n\n  CodeGeneratorResponse_File* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const CodeGeneratorResponse_File& from);\n  void MergeFrom(const CodeGeneratorResponse_File& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(CodeGeneratorResponse_File* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional string name = 1;\n  bool has_name() const;\n  void clear_name();\n  static const int kNameFieldNumber = 1;\n  const ::std::string& name() const;\n  void set_name(const ::std::string& value);\n  void set_name(const char* value);\n  void set_name(const char* value, size_t size);\n  ::std::string* mutable_name();\n  ::std::string* release_name();\n  void set_allocated_name(::std::string* name);\n\n  // optional string insertion_point = 2;\n  bool has_insertion_point() const;\n  void clear_insertion_point();\n  static const int kInsertionPointFieldNumber = 2;\n  const ::std::string& insertion_point() const;\n  void set_insertion_point(const ::std::string& value);\n  void set_insertion_point(const char* value);\n  void set_insertion_point(const char* value, size_t size);\n  ::std::string* mutable_insertion_point();\n  ::std::string* release_insertion_point();\n  void set_allocated_insertion_point(::std::string* insertion_point);\n\n  // optional string content = 15;\n  bool has_content() const;\n  void clear_content();\n  static const int kContentFieldNumber = 15;\n  const ::std::string& content() const;\n  void set_content(const ::std::string& value);\n  void set_content(const char* value);\n  void set_content(const char* value, size_t size);\n  ::std::string* mutable_content();\n  ::std::string* release_content();\n  void set_allocated_content(::std::string* content);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse.File)\n private:\n  inline void set_has_name();\n  inline void clear_has_name();\n  inline void set_has_insertion_point();\n  inline void clear_has_insertion_point();\n  inline void set_has_content();\n  inline void clear_has_content();\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::internal::ArenaStringPtr name_;\n  ::google::protobuf::internal::ArenaStringPtr insertion_point_;\n  ::google::protobuf::internal::ArenaStringPtr content_;\n  friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto();\n\n  void InitAsDefaultInstance();\n  static CodeGeneratorResponse_File* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOC_EXPORT CodeGeneratorResponse : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.compiler.CodeGeneratorResponse) */ {\n public:\n  CodeGeneratorResponse();\n  virtual ~CodeGeneratorResponse();\n\n  CodeGeneratorResponse(const CodeGeneratorResponse& from);\n\n  inline CodeGeneratorResponse& operator=(const CodeGeneratorResponse& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const CodeGeneratorResponse& default_instance();\n\n  void Swap(CodeGeneratorResponse* other);\n\n  // implements Message ----------------------------------------------\n\n  inline CodeGeneratorResponse* New() const { return New(NULL); }\n\n  CodeGeneratorResponse* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const CodeGeneratorResponse& from);\n  void MergeFrom(const CodeGeneratorResponse& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(CodeGeneratorResponse* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  typedef CodeGeneratorResponse_File File;\n\n  // accessors -------------------------------------------------------\n\n  // optional string error = 1;\n  bool has_error() const;\n  void clear_error();\n  static const int kErrorFieldNumber = 1;\n  const ::std::string& error() const;\n  void set_error(const ::std::string& value);\n  void set_error(const char* value);\n  void set_error(const char* value, size_t size);\n  ::std::string* mutable_error();\n  ::std::string* release_error();\n  void set_allocated_error(::std::string* error);\n\n  // repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;\n  int file_size() const;\n  void clear_file();\n  static const int kFileFieldNumber = 15;\n  const ::google::protobuf::compiler::CodeGeneratorResponse_File& file(int index) const;\n  ::google::protobuf::compiler::CodeGeneratorResponse_File* mutable_file(int index);\n  ::google::protobuf::compiler::CodeGeneratorResponse_File* add_file();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >*\n      mutable_file();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >&\n      file() const;\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.compiler.CodeGeneratorResponse)\n private:\n  inline void set_has_error();\n  inline void clear_has_error();\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::internal::ArenaStringPtr error_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File > file_;\n  friend void LIBPROTOC_EXPORT protobuf_AddDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fcompiler_2fplugin_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fcompiler_2fplugin_2eproto();\n\n  void InitAsDefaultInstance();\n  static CodeGeneratorResponse* default_instance_;\n};\n// ===================================================================\n\n\n// ===================================================================\n\n#if !PROTOBUF_INLINE_NOT_IN_HEADERS\n// CodeGeneratorRequest\n\n// repeated string file_to_generate = 1;\ninline int CodeGeneratorRequest::file_to_generate_size() const {\n  return file_to_generate_.size();\n}\ninline void CodeGeneratorRequest::clear_file_to_generate() {\n  file_to_generate_.Clear();\n}\ninline const ::std::string& CodeGeneratorRequest::file_to_generate(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)\n  return file_to_generate_.Get(index);\n}\ninline ::std::string* CodeGeneratorRequest::mutable_file_to_generate(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)\n  return file_to_generate_.Mutable(index);\n}\ninline void CodeGeneratorRequest::set_file_to_generate(int index, const ::std::string& value) {\n  // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)\n  file_to_generate_.Mutable(index)->assign(value);\n}\ninline void CodeGeneratorRequest::set_file_to_generate(int index, const char* value) {\n  file_to_generate_.Mutable(index)->assign(value);\n  // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)\n}\ninline void CodeGeneratorRequest::set_file_to_generate(int index, const char* value, size_t size) {\n  file_to_generate_.Mutable(index)->assign(\n    reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)\n}\ninline ::std::string* CodeGeneratorRequest::add_file_to_generate() {\n  // @@protoc_insertion_point(field_add_mutable:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)\n  return file_to_generate_.Add();\n}\ninline void CodeGeneratorRequest::add_file_to_generate(const ::std::string& value) {\n  file_to_generate_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)\n}\ninline void CodeGeneratorRequest::add_file_to_generate(const char* value) {\n  file_to_generate_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add_char:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)\n}\ninline void CodeGeneratorRequest::add_file_to_generate(const char* value, size_t size) {\n  file_to_generate_.Add()->assign(reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_add_pointer:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)\n}\ninline const ::google::protobuf::RepeatedPtrField< ::std::string>&\nCodeGeneratorRequest::file_to_generate() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)\n  return file_to_generate_;\n}\ninline ::google::protobuf::RepeatedPtrField< ::std::string>*\nCodeGeneratorRequest::mutable_file_to_generate() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorRequest.file_to_generate)\n  return &file_to_generate_;\n}\n\n// optional string parameter = 2;\ninline bool CodeGeneratorRequest::has_parameter() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\ninline void CodeGeneratorRequest::set_has_parameter() {\n  _has_bits_[0] |= 0x00000002u;\n}\ninline void CodeGeneratorRequest::clear_has_parameter() {\n  _has_bits_[0] &= ~0x00000002u;\n}\ninline void CodeGeneratorRequest::clear_parameter() {\n  parameter_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_parameter();\n}\ninline const ::std::string& CodeGeneratorRequest::parameter() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.parameter)\n  return parameter_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void CodeGeneratorRequest::set_parameter(const ::std::string& value) {\n  set_has_parameter();\n  parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorRequest.parameter)\n}\ninline void CodeGeneratorRequest::set_parameter(const char* value) {\n  set_has_parameter();\n  parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorRequest.parameter)\n}\ninline void CodeGeneratorRequest::set_parameter(const char* value, size_t size) {\n  set_has_parameter();\n  parameter_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorRequest.parameter)\n}\ninline ::std::string* CodeGeneratorRequest::mutable_parameter() {\n  set_has_parameter();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.parameter)\n  return parameter_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* CodeGeneratorRequest::release_parameter() {\n  // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorRequest.parameter)\n  clear_has_parameter();\n  return parameter_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void CodeGeneratorRequest::set_allocated_parameter(::std::string* parameter) {\n  if (parameter != NULL) {\n    set_has_parameter();\n  } else {\n    clear_has_parameter();\n  }\n  parameter_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), parameter);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorRequest.parameter)\n}\n\n// repeated .google.protobuf.FileDescriptorProto proto_file = 15;\ninline int CodeGeneratorRequest::proto_file_size() const {\n  return proto_file_.size();\n}\ninline void CodeGeneratorRequest::clear_proto_file() {\n  proto_file_.Clear();\n}\ninline const ::google::protobuf::FileDescriptorProto& CodeGeneratorRequest::proto_file(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorRequest.proto_file)\n  return proto_file_.Get(index);\n}\ninline ::google::protobuf::FileDescriptorProto* CodeGeneratorRequest::mutable_proto_file(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorRequest.proto_file)\n  return proto_file_.Mutable(index);\n}\ninline ::google::protobuf::FileDescriptorProto* CodeGeneratorRequest::add_proto_file() {\n  // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorRequest.proto_file)\n  return proto_file_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >*\nCodeGeneratorRequest::mutable_proto_file() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorRequest.proto_file)\n  return &proto_file_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >&\nCodeGeneratorRequest::proto_file() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorRequest.proto_file)\n  return proto_file_;\n}\n\n// -------------------------------------------------------------------\n\n// CodeGeneratorResponse_File\n\n// optional string name = 1;\ninline bool CodeGeneratorResponse_File::has_name() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\ninline void CodeGeneratorResponse_File::set_has_name() {\n  _has_bits_[0] |= 0x00000001u;\n}\ninline void CodeGeneratorResponse_File::clear_has_name() {\n  _has_bits_[0] &= ~0x00000001u;\n}\ninline void CodeGeneratorResponse_File::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_name();\n}\ninline const ::std::string& CodeGeneratorResponse_File::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void CodeGeneratorResponse_File::set_name(const ::std::string& value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.name)\n}\ninline void CodeGeneratorResponse_File::set_name(const char* value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.name)\n}\ninline void CodeGeneratorResponse_File::set_name(const char* value, size_t size) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.name)\n}\ninline ::std::string* CodeGeneratorResponse_File::mutable_name() {\n  set_has_name();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* CodeGeneratorResponse_File::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.name)\n  clear_has_name();\n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void CodeGeneratorResponse_File::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    set_has_name();\n  } else {\n    clear_has_name();\n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.name)\n}\n\n// optional string insertion_point = 2;\ninline bool CodeGeneratorResponse_File::has_insertion_point() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\ninline void CodeGeneratorResponse_File::set_has_insertion_point() {\n  _has_bits_[0] |= 0x00000002u;\n}\ninline void CodeGeneratorResponse_File::clear_has_insertion_point() {\n  _has_bits_[0] &= ~0x00000002u;\n}\ninline void CodeGeneratorResponse_File::clear_insertion_point() {\n  insertion_point_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_insertion_point();\n}\ninline const ::std::string& CodeGeneratorResponse_File::insertion_point() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)\n  return insertion_point_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void CodeGeneratorResponse_File::set_insertion_point(const ::std::string& value) {\n  set_has_insertion_point();\n  insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)\n}\ninline void CodeGeneratorResponse_File::set_insertion_point(const char* value) {\n  set_has_insertion_point();\n  insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)\n}\ninline void CodeGeneratorResponse_File::set_insertion_point(const char* value, size_t size) {\n  set_has_insertion_point();\n  insertion_point_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)\n}\ninline ::std::string* CodeGeneratorResponse_File::mutable_insertion_point() {\n  set_has_insertion_point();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)\n  return insertion_point_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* CodeGeneratorResponse_File::release_insertion_point() {\n  // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)\n  clear_has_insertion_point();\n  return insertion_point_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void CodeGeneratorResponse_File::set_allocated_insertion_point(::std::string* insertion_point) {\n  if (insertion_point != NULL) {\n    set_has_insertion_point();\n  } else {\n    clear_has_insertion_point();\n  }\n  insertion_point_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), insertion_point);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.insertion_point)\n}\n\n// optional string content = 15;\ninline bool CodeGeneratorResponse_File::has_content() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\ninline void CodeGeneratorResponse_File::set_has_content() {\n  _has_bits_[0] |= 0x00000004u;\n}\ninline void CodeGeneratorResponse_File::clear_has_content() {\n  _has_bits_[0] &= ~0x00000004u;\n}\ninline void CodeGeneratorResponse_File::clear_content() {\n  content_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_content();\n}\ninline const ::std::string& CodeGeneratorResponse_File::content() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.File.content)\n  return content_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void CodeGeneratorResponse_File::set_content(const ::std::string& value) {\n  set_has_content();\n  content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.File.content)\n}\ninline void CodeGeneratorResponse_File::set_content(const char* value) {\n  set_has_content();\n  content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.File.content)\n}\ninline void CodeGeneratorResponse_File::set_content(const char* value, size_t size) {\n  set_has_content();\n  content_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.File.content)\n}\ninline ::std::string* CodeGeneratorResponse_File::mutable_content() {\n  set_has_content();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.File.content)\n  return content_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* CodeGeneratorResponse_File::release_content() {\n  // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.File.content)\n  clear_has_content();\n  return content_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void CodeGeneratorResponse_File::set_allocated_content(::std::string* content) {\n  if (content != NULL) {\n    set_has_content();\n  } else {\n    clear_has_content();\n  }\n  content_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), content);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.File.content)\n}\n\n// -------------------------------------------------------------------\n\n// CodeGeneratorResponse\n\n// optional string error = 1;\ninline bool CodeGeneratorResponse::has_error() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\ninline void CodeGeneratorResponse::set_has_error() {\n  _has_bits_[0] |= 0x00000001u;\n}\ninline void CodeGeneratorResponse::clear_has_error() {\n  _has_bits_[0] &= ~0x00000001u;\n}\ninline void CodeGeneratorResponse::clear_error() {\n  error_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_error();\n}\ninline const ::std::string& CodeGeneratorResponse::error() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.error)\n  return error_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void CodeGeneratorResponse::set_error(const ::std::string& value) {\n  set_has_error();\n  error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.compiler.CodeGeneratorResponse.error)\n}\ninline void CodeGeneratorResponse::set_error(const char* value) {\n  set_has_error();\n  error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.compiler.CodeGeneratorResponse.error)\n}\ninline void CodeGeneratorResponse::set_error(const char* value, size_t size) {\n  set_has_error();\n  error_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.compiler.CodeGeneratorResponse.error)\n}\ninline ::std::string* CodeGeneratorResponse::mutable_error() {\n  set_has_error();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.error)\n  return error_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* CodeGeneratorResponse::release_error() {\n  // @@protoc_insertion_point(field_release:google.protobuf.compiler.CodeGeneratorResponse.error)\n  clear_has_error();\n  return error_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void CodeGeneratorResponse::set_allocated_error(::std::string* error) {\n  if (error != NULL) {\n    set_has_error();\n  } else {\n    clear_has_error();\n  }\n  error_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), error);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.compiler.CodeGeneratorResponse.error)\n}\n\n// repeated .google.protobuf.compiler.CodeGeneratorResponse.File file = 15;\ninline int CodeGeneratorResponse::file_size() const {\n  return file_.size();\n}\ninline void CodeGeneratorResponse::clear_file() {\n  file_.Clear();\n}\ninline const ::google::protobuf::compiler::CodeGeneratorResponse_File& CodeGeneratorResponse::file(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.compiler.CodeGeneratorResponse.file)\n  return file_.Get(index);\n}\ninline ::google::protobuf::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::mutable_file(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.compiler.CodeGeneratorResponse.file)\n  return file_.Mutable(index);\n}\ninline ::google::protobuf::compiler::CodeGeneratorResponse_File* CodeGeneratorResponse::add_file() {\n  // @@protoc_insertion_point(field_add:google.protobuf.compiler.CodeGeneratorResponse.file)\n  return file_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >*\nCodeGeneratorResponse::mutable_file() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.compiler.CodeGeneratorResponse.file)\n  return &file_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::compiler::CodeGeneratorResponse_File >&\nCodeGeneratorResponse::file() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.compiler.CodeGeneratorResponse.file)\n  return file_;\n}\n\n#endif  // !PROTOBUF_INLINE_NOT_IN_HEADERS\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n// @@protoc_insertion_point(global_scope)\n\n#endif  // PROTOBUF_google_2fprotobuf_2fcompiler_2fplugin_2eproto__INCLUDED\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/plugin.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//\n// WARNING:  The plugin interface is currently EXPERIMENTAL and is subject to\n//   change.\n//\n// protoc (aka the Protocol Compiler) can be extended via plugins.  A plugin is\n// just a program that reads a CodeGeneratorRequest from stdin and writes a\n// CodeGeneratorResponse to stdout.\n//\n// Plugins written using C++ can use google/protobuf/compiler/plugin.h instead\n// of dealing with the raw protocol defined here.\n//\n// A plugin executable needs only to be placed somewhere in the path.  The\n// plugin should be named \"protoc-gen-$NAME\", and will then be used when the\n// flag \"--${NAME}_out\" is passed to protoc.\n\nsyntax = \"proto2\";\npackage google.protobuf.compiler;\noption java_package = \"com.google.protobuf.compiler\";\noption java_outer_classname = \"PluginProtos\";\n\noption go_package = \"plugin_go\";\n\nimport \"google/protobuf/descriptor.proto\";\n\n// An encoded CodeGeneratorRequest is written to the plugin's stdin.\nmessage CodeGeneratorRequest {\n  // The .proto files that were explicitly listed on the command-line.  The\n  // code generator should generate code only for these files.  Each file's\n  // descriptor will be included in proto_file, below.\n  repeated string file_to_generate = 1;\n\n  // The generator parameter passed on the command-line.\n  optional string parameter = 2;\n\n  // FileDescriptorProtos for all files in files_to_generate and everything\n  // they import.  The files will appear in topological order, so each file\n  // appears before any file that imports it.\n  //\n  // protoc guarantees that all proto_files will be written after\n  // the fields above, even though this is not technically guaranteed by the\n  // protobuf wire format.  This theoretically could allow a plugin to stream\n  // in the FileDescriptorProtos and handle them one by one rather than read\n  // the entire set into memory at once.  However, as of this writing, this\n  // is not similarly optimized on protoc's end -- it will store all fields in\n  // memory at once before sending them to the plugin.\n  repeated FileDescriptorProto proto_file = 15;\n}\n\n// The plugin writes an encoded CodeGeneratorResponse to stdout.\nmessage CodeGeneratorResponse {\n  // Error message.  If non-empty, code generation failed.  The plugin process\n  // should exit with status code zero even if it reports an error in this way.\n  //\n  // This should be used to indicate errors in .proto files which prevent the\n  // code generator from generating correct code.  Errors which indicate a\n  // problem in protoc itself -- such as the input CodeGeneratorRequest being\n  // unparseable -- should be reported by writing a message to stderr and\n  // exiting with a non-zero status code.\n  optional string error = 1;\n\n  // Represents a single generated file.\n  message File {\n    // The file name, relative to the output directory.  The name must not\n    // contain \".\" or \"..\" components and must be relative, not be absolute (so,\n    // the file cannot lie outside the output directory).  \"/\" must be used as\n    // the path separator, not \"\\\".\n    //\n    // If the name is omitted, the content will be appended to the previous\n    // file.  This allows the generator to break large files into small chunks,\n    // and allows the generated text to be streamed back to protoc so that large\n    // files need not reside completely in memory at one time.  Note that as of\n    // this writing protoc does not optimize for this -- it will read the entire\n    // CodeGeneratorResponse before writing files to disk.\n    optional string name = 1;\n\n    // If non-empty, indicates that the named file should already exist, and the\n    // content here is to be inserted into that file at a defined insertion\n    // point.  This feature allows a code generator to extend the output\n    // produced by another code generator.  The original generator may provide\n    // insertion points by placing special annotations in the file that look\n    // like:\n    //   @@protoc_insertion_point(NAME)\n    // The annotation can have arbitrary text before and after it on the line,\n    // which allows it to be placed in a comment.  NAME should be replaced with\n    // an identifier naming the point -- this is what other generators will use\n    // as the insertion_point.  Code inserted at this point will be placed\n    // immediately above the line containing the insertion point (thus multiple\n    // insertions to the same point will come out in the order they were added).\n    // The double-@ is intended to make it unlikely that the generated code\n    // could contain things that look like insertion points by accident.\n    //\n    // For example, the C++ code generator places the following line in the\n    // .pb.h files that it generates:\n    //   // @@protoc_insertion_point(namespace_scope)\n    // This line appears within the scope of the file's package namespace, but\n    // outside of any particular class.  Another plugin can then specify the\n    // insertion_point \"namespace_scope\" to generate additional classes or\n    // other declarations that should be placed in this scope.\n    //\n    // Note that if the line containing the insertion point begins with\n    // whitespace, the same whitespace will be added to every line of the\n    // inserted text.  This is useful for languages like Python, where\n    // indentation matters.  In these languages, the insertion point comment\n    // should be indented the same amount as any inserted code will need to be\n    // in order to work correctly in that context.\n    //\n    // The code generator that generates the initial file and the one which\n    // inserts into it must both run as part of a single invocation of protoc.\n    // Code generators are executed in the order in which they appear on the\n    // command line.\n    //\n    // If |insertion_point| is present, |name| must also be present.\n    optional string insertion_point = 2;\n\n    // The file contents.\n    optional string content = 15;\n  }\n  repeated File file = 15;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/python/python_generator.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n//#PY25 compatible generated code for GAE.\n// Copyright 2007 Google Inc. All Rights Reserved.\n// Author: robinson@google.com (Will Robinson)\n//\n// This module outputs pure-Python protocol message classes that will\n// largely be constructed at runtime via the metaclass in reflection.py.\n// In other words, our job is basically to output a Python equivalent\n// of the C++ *Descriptor objects, and fix up all circular references\n// within these objects.\n//\n// Note that the runtime performance of protocol message classes created in\n// this way is expected to be lousy.  The plan is to create an alternate\n// generator that outputs a Python/C extension module that lets\n// performance-minded Python code leverage the fast C++ implementation\n// directly.\n\n#include <algorithm>\n#include <google/protobuf/stubs/hash.h>\n#include <limits>\n#include <map>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <string>\n#include <utility>\n#include <vector>\n\n#include <google/protobuf/compiler/python/python_generator.h>\n#include <google/protobuf/descriptor.pb.h>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/stringprintf.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace python {\n\nnamespace {\n\n// Returns a copy of |filename| with any trailing \".protodevel\" or \".proto\n// suffix stripped.\n// TODO(robinson): Unify with copy in compiler/cpp/internal/helpers.cc.\nstring StripProto(const string& filename) {\n  const char* suffix = HasSuffixString(filename, \".protodevel\")\n      ? \".protodevel\" : \".proto\";\n  return StripSuffixString(filename, suffix);\n}\n\n\n// Returns the Python module name expected for a given .proto filename.\nstring ModuleName(const string& filename) {\n  string basename = StripProto(filename);\n  StripString(&basename, \"-\", '_');\n  StripString(&basename, \"/\", '.');\n  return basename + \"_pb2\";\n}\n\n\n// Returns the alias we assign to the module of the given .proto filename\n// when importing. See testPackageInitializationImport in\n// google/protobuf/python/reflection_test.py\n// to see why we need the alias.\nstring ModuleAlias(const string& filename) {\n  string module_name = ModuleName(filename);\n  // We can't have dots in the module name, so we replace each with _dot_.\n  // But that could lead to a collision between a.b and a_dot_b, so we also\n  // duplicate each underscore.\n  GlobalReplaceSubstring(\"_\", \"__\", &module_name);\n  GlobalReplaceSubstring(\".\", \"_dot_\", &module_name);\n  return module_name;\n}\n\n// Keywords reserved by the Python language.\nconst char* const kKeywords[] = {\n    \"False\",   \"None\",     \"True\",     \"and\",    \"as\",    \"assert\", \"break\",\n    \"class\",   \"continue\", \"def\",      \"del\",    \"elif\",  \"else\",   \"except\",\n    \"finally\", \"for\",      \"from\",     \"global\", \"if\",    \"import\", \"in\",\n    \"is\",      \"lambda\",   \"nonlocal\", \"not\",    \"or\",    \"pass\",   \"raise\",\n    \"return\",  \"try\",      \"while\",    \"with\",   \"yield\",\n};\nconst char* const* kKeywordsEnd =\n    kKeywords + (sizeof(kKeywords) / sizeof(kKeywords[0]));\n\nbool ContainsPythonKeyword(const string& module_name) {\n  vector<string> tokens = Split(module_name, \".\");\n  for (int i = 0; i < tokens.size(); ++i) {\n    if (std::find(kKeywords, kKeywordsEnd, tokens[i]) != kKeywordsEnd) {\n      return true;\n    }\n  }\n  return false;\n}\n\n\n// Returns the name of all containing types for descriptor,\n// in order from outermost to innermost, followed by descriptor's\n// own name.  Each name is separated by |separator|.\ntemplate <typename DescriptorT>\nstring NamePrefixedWithNestedTypes(const DescriptorT& descriptor,\n                                   const string& separator) {\n  string name = descriptor.name();\n  for (const Descriptor* current = descriptor.containing_type();\n       current != NULL; current = current->containing_type()) {\n    name = current->name() + separator + name;\n  }\n  return name;\n}\n\n\n// Name of the class attribute where we store the Python\n// descriptor.Descriptor instance for the generated class.\n// Must stay consistent with the _DESCRIPTOR_KEY constant\n// in proto2/public/reflection.py.\nconst char kDescriptorKey[] = \"DESCRIPTOR\";\n\n\n// Does the file have top-level enums?\ninline bool HasTopLevelEnums(const FileDescriptor *file) {\n  return file->enum_type_count() > 0;\n}\n\n\n// Should we generate generic services for this file?\ninline bool HasGenericServices(const FileDescriptor *file) {\n  return file->service_count() > 0 &&\n         file->options().py_generic_services();\n}\n\n\n// Prints the common boilerplate needed at the top of every .py\n// file output by this generator.\nvoid PrintTopBoilerplate(\n    io::Printer* printer, const FileDescriptor* file, bool descriptor_proto) {\n  // TODO(robinson): Allow parameterization of Python version?\n  printer->Print(\n      \"# Generated by the protocol buffer compiler.  DO NOT EDIT!\\n\"\n      \"# source: $filename$\\n\"\n      \"\\nimport sys\\n_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))\"  //##PY25\n      \"\\n\",\n      \"filename\", file->name());\n  if (HasTopLevelEnums(file)) {\n    printer->Print(\n        \"from google.protobuf.internal import enum_type_wrapper\\n\");\n  }\n  printer->Print(\n      \"from google.protobuf import descriptor as _descriptor\\n\"\n      \"from google.protobuf import message as _message\\n\"\n      \"from google.protobuf import reflection as _reflection\\n\"\n      \"from google.protobuf import symbol_database as \"\n      \"_symbol_database\\n\");\n  if (HasGenericServices(file)) {\n    printer->Print(\n        \"from google.protobuf import service as _service\\n\"\n        \"from google.protobuf import service_reflection\\n\");\n  }\n\n  // Avoid circular imports if this module is descriptor_pb2.\n  if (!descriptor_proto) {\n    printer->Print(\n        \"from google.protobuf import descriptor_pb2\\n\");\n  }\n  printer->Print(\n      \"# @@protoc_insertion_point(imports)\\n\\n\"\n      \"_sym_db = _symbol_database.Default()\\n\");\n  printer->Print(\"\\n\\n\");\n}\n\n\n// Returns a Python literal giving the default value for a field.\n// If the field specifies no explicit default value, we'll return\n// the default default value for the field type (zero for numbers,\n// empty string for strings, empty list for repeated fields, and\n// None for non-repeated, composite fields).\n//\n// TODO(robinson): Unify with code from\n// //compiler/cpp/internal/primitive_field.cc\n// //compiler/cpp/internal/enum_field.cc\n// //compiler/cpp/internal/string_field.cc\nstring StringifyDefaultValue(const FieldDescriptor& field) {\n  if (field.is_repeated()) {\n    return \"[]\";\n  }\n\n  switch (field.cpp_type()) {\n    case FieldDescriptor::CPPTYPE_INT32:\n      return SimpleItoa(field.default_value_int32());\n    case FieldDescriptor::CPPTYPE_UINT32:\n      return SimpleItoa(field.default_value_uint32());\n    case FieldDescriptor::CPPTYPE_INT64:\n      return SimpleItoa(field.default_value_int64());\n    case FieldDescriptor::CPPTYPE_UINT64:\n      return SimpleItoa(field.default_value_uint64());\n    case FieldDescriptor::CPPTYPE_DOUBLE: {\n      double value = field.default_value_double();\n      if (value == numeric_limits<double>::infinity()) {\n        // Python pre-2.6 on Windows does not parse \"inf\" correctly.  However,\n        // a numeric literal that is too big for a double will become infinity.\n        return \"1e10000\";\n      } else if (value == -numeric_limits<double>::infinity()) {\n        // See above.\n        return \"-1e10000\";\n      } else if (value != value) {\n        // infinity * 0 = nan\n        return \"(1e10000 * 0)\";\n      } else {\n        return \"float(\" + SimpleDtoa(value) + \")\";\n      }\n    }\n    case FieldDescriptor::CPPTYPE_FLOAT: {\n      float value = field.default_value_float();\n      if (value == numeric_limits<float>::infinity()) {\n        // Python pre-2.6 on Windows does not parse \"inf\" correctly.  However,\n        // a numeric literal that is too big for a double will become infinity.\n        return \"1e10000\";\n      } else if (value == -numeric_limits<float>::infinity()) {\n        // See above.\n        return \"-1e10000\";\n      } else if (value != value) {\n        // infinity - infinity = nan\n        return \"(1e10000 * 0)\";\n      } else {\n        return \"float(\" + SimpleFtoa(value) + \")\";\n      }\n    }\n    case FieldDescriptor::CPPTYPE_BOOL:\n      return field.default_value_bool() ? \"True\" : \"False\";\n    case FieldDescriptor::CPPTYPE_ENUM:\n      return SimpleItoa(field.default_value_enum()->number());\n    case FieldDescriptor::CPPTYPE_STRING:\n//##!PY25      return \"b\\\"\" + CEscape(field.default_value_string()) +\n//##!PY25             (field.type() != FieldDescriptor::TYPE_STRING ? \"\\\"\" :\n//##!PY25               \"\\\".decode('utf-8')\");\n      return \"_b(\\\"\" + CEscape(field.default_value_string()) +  //##PY25\n             (field.type() != FieldDescriptor::TYPE_STRING ? \"\\\")\" :  //##PY25\n               \"\\\").decode('utf-8')\");  //##PY25\n    case FieldDescriptor::CPPTYPE_MESSAGE:\n      return \"None\";\n  }\n  // (We could add a default case above but then we wouldn't get the nice\n  // compiler warning when a new type is added.)\n  GOOGLE_LOG(FATAL) << \"Not reached.\";\n  return \"\";\n}\n\nstring StringifySyntax(FileDescriptor::Syntax syntax) {\n  switch (syntax) {\n    case FileDescriptor::SYNTAX_PROTO2:\n      return \"proto2\";\n    case FileDescriptor::SYNTAX_PROTO3:\n      return \"proto3\";\n    case FileDescriptor::SYNTAX_UNKNOWN:\n    default:\n      GOOGLE_LOG(FATAL) << \"Unsupported syntax; this generator only supports proto2 \"\n                    \"and proto3 syntax.\";\n      return \"\";\n  }\n}\n\n\n}  // namespace\n\n\nGenerator::Generator() : file_(NULL) {\n}\n\nGenerator::~Generator() {\n}\n\nbool Generator::Generate(const FileDescriptor* file,\n                         const string& parameter,\n                         GeneratorContext* context,\n                         string* error) const {\n\n  // Completely serialize all Generate() calls on this instance.  The\n  // thread-safety constraints of the CodeGenerator interface aren't clear so\n  // just be as conservative as possible.  It's easier to relax this later if\n  // we need to, but I doubt it will be an issue.\n  // TODO(kenton):  The proper thing to do would be to allocate any state on\n  //   the stack and use that, so that the Generator class itself does not need\n  //   to have any mutable members.  Then it is implicitly thread-safe.\n  MutexLock lock(&mutex_);\n  file_ = file;\n  string module_name = ModuleName(file->name());\n  string filename = module_name;\n  StripString(&filename, \".\", '/');\n  filename += \".py\";\n\n  FileDescriptorProto fdp;\n  file_->CopyTo(&fdp);\n  fdp.SerializeToString(&file_descriptor_serialized_);\n\n\n  google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(context->Open(filename));\n  GOOGLE_CHECK(output.get());\n  io::Printer printer(output.get(), '$');\n  printer_ = &printer;\n\n  PrintTopBoilerplate(printer_, file_, GeneratingDescriptorProto());\n  PrintImports();\n  PrintFileDescriptor();\n  PrintTopLevelEnums();\n  PrintTopLevelExtensions();\n  PrintAllNestedEnumsInFile();\n  PrintMessageDescriptors();\n  FixForeignFieldsInDescriptors();\n  PrintMessages();\n  // We have to fix up the extensions after the message classes themselves,\n  // since they need to call static RegisterExtension() methods on these\n  // classes.\n  FixForeignFieldsInExtensions();\n  // Descriptor options may have custom extensions. These custom options\n  // can only be successfully parsed after we register corresponding\n  // extensions. Therefore we parse all options again here to recognize\n  // custom options that may be unknown when we define the descriptors.\n  FixAllDescriptorOptions();\n  if (HasGenericServices(file)) {\n    PrintServices();\n  }\n\n  printer.Print(\n    \"# @@protoc_insertion_point(module_scope)\\n\");\n\n  return !printer.failed();\n}\n\n// Prints Python imports for all modules imported by |file|.\nvoid Generator::PrintImports() const {\n  for (int i = 0; i < file_->dependency_count(); ++i) {\n    const string& filename = file_->dependency(i)->name();\n\n    string module_name = ModuleName(filename);\n    string module_alias = ModuleAlias(filename);\n    if (ContainsPythonKeyword(module_name)) {\n      // If the module path contains a Python keyword, we have to quote the\n      // module name and import it using importlib. Otherwise the usual kind of\n      // import statement would result in a syntax error from the presence of\n      // the keyword.\n      printer_->Print(\"import importlib\\n\");\n      printer_->Print(\"$alias$ = importlib.import_module('$name$')\\n\", \"alias\",\n                      module_alias, \"name\", module_name);\n    } else {\n      int last_dot_pos = module_name.rfind('.');\n      string import_statement;\n      if (last_dot_pos == string::npos) {\n        // NOTE(petya): this is not tested as it would require a protocol buffer\n        // outside of any package, and I don't think that is easily achievable.\n        import_statement = \"import \" + module_name;\n      } else {\n        import_statement = \"from \" + module_name.substr(0, last_dot_pos) +\n                           \" import \" + module_name.substr(last_dot_pos + 1);\n      }\n      printer_->Print(\"$statement$ as $alias$\\n\", \"statement\", import_statement,\n                      \"alias\", module_alias);\n    }\n\n    CopyPublicDependenciesAliases(module_alias, file_->dependency(i));\n  }\n  printer_->Print(\"\\n\");\n\n  // Print public imports.\n  for (int i = 0; i < file_->public_dependency_count(); ++i) {\n    string module_name = ModuleName(file_->public_dependency(i)->name());\n    printer_->Print(\"from $module$ import *\\n\", \"module\", module_name);\n  }\n  printer_->Print(\"\\n\");\n}\n\n// Prints the single file descriptor for this file.\nvoid Generator::PrintFileDescriptor() const {\n  map<string, string> m;\n  m[\"descriptor_name\"] = kDescriptorKey;\n  m[\"name\"] = file_->name();\n  m[\"package\"] = file_->package();\n  m[\"syntax\"] = StringifySyntax(file_->syntax());\n  const char file_descriptor_template[] =\n      \"$descriptor_name$ = _descriptor.FileDescriptor(\\n\"\n      \"  name='$name$',\\n\"\n      \"  package='$package$',\\n\"\n      \"  syntax='$syntax$',\\n\";\n  printer_->Print(m, file_descriptor_template);\n  printer_->Indent();\n  printer_->Print(\n//##!PY25      \"serialized_pb=b'$value$'\\n\",\n      \"serialized_pb=_b('$value$')\\n\",  //##PY25\n      \"value\", strings::CHexEscape(file_descriptor_serialized_));\n  if (file_->dependency_count() != 0) {\n    printer_->Print(\",\\ndependencies=[\");\n    for (int i = 0; i < file_->dependency_count(); ++i) {\n      string module_alias = ModuleAlias(file_->dependency(i)->name());\n      printer_->Print(\"$module_alias$.DESCRIPTOR,\", \"module_alias\",\n                      module_alias);\n    }\n    printer_->Print(\"]\");\n  }\n\n  // TODO(falk): Also print options and fix the message_type, enum_type,\n  //             service and extension later in the generation.\n\n  printer_->Outdent();\n  printer_->Print(\")\\n\");\n  printer_->Print(\"_sym_db.RegisterFileDescriptor($name$)\\n\", \"name\",\n                  kDescriptorKey);\n  printer_->Print(\"\\n\");\n}\n\n// Prints descriptors and module-level constants for all top-level\n// enums defined in |file|.\nvoid Generator::PrintTopLevelEnums() const {\n  vector<pair<string, int> > top_level_enum_values;\n  for (int i = 0; i < file_->enum_type_count(); ++i) {\n    const EnumDescriptor& enum_descriptor = *file_->enum_type(i);\n    PrintEnum(enum_descriptor);\n    printer_->Print(\"$name$ = \"\n                    \"enum_type_wrapper.EnumTypeWrapper($descriptor_name$)\",\n                    \"name\", enum_descriptor.name(),\n                    \"descriptor_name\",\n                    ModuleLevelDescriptorName(enum_descriptor));\n    printer_->Print(\"\\n\");\n\n    for (int j = 0; j < enum_descriptor.value_count(); ++j) {\n      const EnumValueDescriptor& value_descriptor = *enum_descriptor.value(j);\n      top_level_enum_values.push_back(\n          std::make_pair(value_descriptor.name(), value_descriptor.number()));\n    }\n  }\n\n  for (int i = 0; i < top_level_enum_values.size(); ++i) {\n    printer_->Print(\"$name$ = $value$\\n\",\n                    \"name\", top_level_enum_values[i].first,\n                    \"value\", SimpleItoa(top_level_enum_values[i].second));\n  }\n  printer_->Print(\"\\n\");\n}\n\n// Prints all enums contained in all message types in |file|.\nvoid Generator::PrintAllNestedEnumsInFile() const {\n  for (int i = 0; i < file_->message_type_count(); ++i) {\n    PrintNestedEnums(*file_->message_type(i));\n  }\n}\n\n// Prints a Python statement assigning the appropriate module-level\n// enum name to a Python EnumDescriptor object equivalent to\n// enum_descriptor.\nvoid Generator::PrintEnum(const EnumDescriptor& enum_descriptor) const {\n  map<string, string> m;\n  string module_level_descriptor_name =\n      ModuleLevelDescriptorName(enum_descriptor);\n  m[\"descriptor_name\"] = module_level_descriptor_name;\n  m[\"name\"] = enum_descriptor.name();\n  m[\"full_name\"] = enum_descriptor.full_name();\n  m[\"file\"] = kDescriptorKey;\n  const char enum_descriptor_template[] =\n      \"$descriptor_name$ = _descriptor.EnumDescriptor(\\n\"\n      \"  name='$name$',\\n\"\n      \"  full_name='$full_name$',\\n\"\n      \"  filename=None,\\n\"\n      \"  file=$file$,\\n\"\n      \"  values=[\\n\";\n  string options_string;\n  enum_descriptor.options().SerializeToString(&options_string);\n  printer_->Print(m, enum_descriptor_template);\n  printer_->Indent();\n  printer_->Indent();\n  for (int i = 0; i < enum_descriptor.value_count(); ++i) {\n    PrintEnumValueDescriptor(*enum_descriptor.value(i));\n    printer_->Print(\",\\n\");\n  }\n  printer_->Outdent();\n  printer_->Print(\"],\\n\");\n  printer_->Print(\"containing_type=None,\\n\");\n  printer_->Print(\"options=$options_value$,\\n\",\n                  \"options_value\",\n                  OptionsValue(\"EnumOptions\", options_string));\n  EnumDescriptorProto edp;\n  PrintSerializedPbInterval(enum_descriptor, edp);\n  printer_->Outdent();\n  printer_->Print(\")\\n\");\n  printer_->Print(\"_sym_db.RegisterEnumDescriptor($name$)\\n\", \"name\",\n                  module_level_descriptor_name);\n  printer_->Print(\"\\n\");\n}\n\n// Recursively prints enums in nested types within descriptor, then\n// prints enums contained at the top level in descriptor.\nvoid Generator::PrintNestedEnums(const Descriptor& descriptor) const {\n  for (int i = 0; i < descriptor.nested_type_count(); ++i) {\n    PrintNestedEnums(*descriptor.nested_type(i));\n  }\n\n  for (int i = 0; i < descriptor.enum_type_count(); ++i) {\n    PrintEnum(*descriptor.enum_type(i));\n  }\n}\n\nvoid Generator::PrintTopLevelExtensions() const {\n  const bool is_extension = true;\n  for (int i = 0; i < file_->extension_count(); ++i) {\n    const FieldDescriptor& extension_field = *file_->extension(i);\n    string constant_name = extension_field.name() + \"_FIELD_NUMBER\";\n    UpperString(&constant_name);\n    printer_->Print(\"$constant_name$ = $number$\\n\",\n      \"constant_name\", constant_name,\n      \"number\", SimpleItoa(extension_field.number()));\n    printer_->Print(\"$name$ = \", \"name\", extension_field.name());\n    PrintFieldDescriptor(extension_field, is_extension);\n    printer_->Print(\"\\n\");\n  }\n  printer_->Print(\"\\n\");\n}\n\n// Prints Python equivalents of all Descriptors in |file|.\nvoid Generator::PrintMessageDescriptors() const {\n  for (int i = 0; i < file_->message_type_count(); ++i) {\n    PrintDescriptor(*file_->message_type(i));\n    printer_->Print(\"\\n\");\n  }\n}\n\nvoid Generator::PrintServices() const {\n  for (int i = 0; i < file_->service_count(); ++i) {\n    PrintServiceDescriptor(*file_->service(i));\n    PrintServiceClass(*file_->service(i));\n    PrintServiceStub(*file_->service(i));\n    printer_->Print(\"\\n\");\n  }\n}\n\nvoid Generator::PrintServiceDescriptor(\n    const ServiceDescriptor& descriptor) const {\n  printer_->Print(\"\\n\");\n  string service_name = ModuleLevelServiceDescriptorName(descriptor);\n  string options_string;\n  descriptor.options().SerializeToString(&options_string);\n\n  printer_->Print(\n      \"$service_name$ = _descriptor.ServiceDescriptor(\\n\",\n      \"service_name\", service_name);\n  printer_->Indent();\n  map<string, string> m;\n  m[\"name\"] = descriptor.name();\n  m[\"full_name\"] = descriptor.full_name();\n  m[\"file\"] = kDescriptorKey;\n  m[\"index\"] = SimpleItoa(descriptor.index());\n  m[\"options_value\"] = OptionsValue(\"ServiceOptions\", options_string);\n  const char required_function_arguments[] =\n      \"name='$name$',\\n\"\n      \"full_name='$full_name$',\\n\"\n      \"file=$file$,\\n\"\n      \"index=$index$,\\n\"\n      \"options=$options_value$,\\n\";\n  printer_->Print(m, required_function_arguments);\n\n  ServiceDescriptorProto sdp;\n  PrintSerializedPbInterval(descriptor, sdp);\n\n  printer_->Print(\"methods=[\\n\");\n  for (int i = 0; i < descriptor.method_count(); ++i) {\n    const MethodDescriptor* method = descriptor.method(i);\n    method->options().SerializeToString(&options_string);\n\n    m.clear();\n    m[\"name\"] = method->name();\n    m[\"full_name\"] = method->full_name();\n    m[\"index\"] = SimpleItoa(method->index());\n    m[\"serialized_options\"] = CEscape(options_string);\n    m[\"input_type\"] = ModuleLevelDescriptorName(*(method->input_type()));\n    m[\"output_type\"] = ModuleLevelDescriptorName(*(method->output_type()));\n    m[\"options_value\"] = OptionsValue(\"MethodOptions\", options_string);\n    printer_->Print(\"_descriptor.MethodDescriptor(\\n\");\n    printer_->Indent();\n    printer_->Print(\n        m,\n        \"name='$name$',\\n\"\n        \"full_name='$full_name$',\\n\"\n        \"index=$index$,\\n\"\n        \"containing_service=None,\\n\"\n        \"input_type=$input_type$,\\n\"\n        \"output_type=$output_type$,\\n\"\n        \"options=$options_value$,\\n\");\n    printer_->Outdent();\n    printer_->Print(\"),\\n\");\n  }\n\n  printer_->Outdent();\n  printer_->Print(\"])\\n\\n\");\n}\n\n\nvoid Generator::PrintDescriptorKeyAndModuleName(\n    const ServiceDescriptor& descriptor) const {\n  printer_->Print(\n      \"$descriptor_key$ = $descriptor_name$,\\n\",\n      \"descriptor_key\", kDescriptorKey,\n      \"descriptor_name\", ModuleLevelServiceDescriptorName(descriptor));\n  printer_->Print(\n      \"__module__ = '$module_name$'\\n\",\n      \"module_name\", ModuleName(file_->name()));\n}\n\nvoid Generator::PrintServiceClass(const ServiceDescriptor& descriptor) const {\n  // Print the service.\n  printer_->Print(\"$class_name$ = service_reflection.GeneratedServiceType(\"\n                  \"'$class_name$', (_service.Service,), dict(\\n\",\n                  \"class_name\", descriptor.name());\n  printer_->Indent();\n  Generator::PrintDescriptorKeyAndModuleName(descriptor);\n  printer_->Print(\"))\\n\\n\");\n  printer_->Outdent();\n}\n\nvoid Generator::PrintServiceStub(const ServiceDescriptor& descriptor) const {\n  // Print the service stub.\n  printer_->Print(\"$class_name$_Stub = \"\n                  \"service_reflection.GeneratedServiceStubType(\"\n                  \"'$class_name$_Stub', ($class_name$,), dict(\\n\",\n                  \"class_name\", descriptor.name());\n  printer_->Indent();\n  Generator::PrintDescriptorKeyAndModuleName(descriptor);\n  printer_->Print(\"))\\n\\n\");\n  printer_->Outdent();\n}\n\n// Prints statement assigning ModuleLevelDescriptorName(message_descriptor)\n// to a Python Descriptor object for message_descriptor.\n//\n// Mutually recursive with PrintNestedDescriptors().\nvoid Generator::PrintDescriptor(const Descriptor& message_descriptor) const {\n  PrintNestedDescriptors(message_descriptor);\n\n  printer_->Print(\"\\n\");\n  printer_->Print(\"$descriptor_name$ = _descriptor.Descriptor(\\n\",\n                  \"descriptor_name\",\n                  ModuleLevelDescriptorName(message_descriptor));\n  printer_->Indent();\n  map<string, string> m;\n  m[\"name\"] = message_descriptor.name();\n  m[\"full_name\"] = message_descriptor.full_name();\n  m[\"file\"] = kDescriptorKey;\n  const char required_function_arguments[] =\n      \"name='$name$',\\n\"\n      \"full_name='$full_name$',\\n\"\n      \"filename=None,\\n\"\n      \"file=$file$,\\n\"\n      \"containing_type=None,\\n\";\n  printer_->Print(m, required_function_arguments);\n  PrintFieldsInDescriptor(message_descriptor);\n  PrintExtensionsInDescriptor(message_descriptor);\n\n  // Nested types\n  printer_->Print(\"nested_types=[\");\n  for (int i = 0; i < message_descriptor.nested_type_count(); ++i) {\n    const string nested_name = ModuleLevelDescriptorName(\n        *message_descriptor.nested_type(i));\n    printer_->Print(\"$name$, \", \"name\", nested_name);\n  }\n  printer_->Print(\"],\\n\");\n\n  // Enum types\n  printer_->Print(\"enum_types=[\\n\");\n  printer_->Indent();\n  for (int i = 0; i < message_descriptor.enum_type_count(); ++i) {\n    const string descriptor_name = ModuleLevelDescriptorName(\n        *message_descriptor.enum_type(i));\n    printer_->Print(descriptor_name.c_str());\n    printer_->Print(\",\\n\");\n  }\n  printer_->Outdent();\n  printer_->Print(\"],\\n\");\n  string options_string;\n  message_descriptor.options().SerializeToString(&options_string);\n  printer_->Print(\n      \"options=$options_value$,\\n\"\n      \"is_extendable=$extendable$,\\n\"\n      \"syntax='$syntax$'\",\n      \"options_value\", OptionsValue(\"MessageOptions\", options_string),\n      \"extendable\", message_descriptor.extension_range_count() > 0 ?\n                      \"True\" : \"False\",\n      \"syntax\", StringifySyntax(message_descriptor.file()->syntax()));\n  printer_->Print(\",\\n\");\n\n  // Extension ranges\n  printer_->Print(\"extension_ranges=[\");\n  for (int i = 0; i < message_descriptor.extension_range_count(); ++i) {\n    const Descriptor::ExtensionRange* range =\n        message_descriptor.extension_range(i);\n    printer_->Print(\"($start$, $end$), \",\n                    \"start\", SimpleItoa(range->start),\n                    \"end\", SimpleItoa(range->end));\n  }\n  printer_->Print(\"],\\n\");\n  printer_->Print(\"oneofs=[\\n\");\n  printer_->Indent();\n  for (int i = 0; i < message_descriptor.oneof_decl_count(); ++i) {\n    const OneofDescriptor* desc = message_descriptor.oneof_decl(i);\n    map<string, string> m;\n    m[\"name\"] = desc->name();\n    m[\"full_name\"] = desc->full_name();\n    m[\"index\"] = SimpleItoa(desc->index());\n    string options_string =\n        OptionsValue(\"OneofOptions\", desc->options().SerializeAsString());\n    if (options_string == \"None\") {\n      m[\"options\"] = \"\";\n    } else {\n      m[\"options\"] = \", options=\" + options_string;\n    }\n    printer_->Print(\n        m,\n        \"_descriptor.OneofDescriptor(\\n\"\n        \"  name='$name$', full_name='$full_name$',\\n\"\n        \"  index=$index$, containing_type=None, fields=[]$options$),\\n\");\n  }\n  printer_->Outdent();\n  printer_->Print(\"],\\n\");\n  // Serialization of proto\n  DescriptorProto edp;\n  PrintSerializedPbInterval(message_descriptor, edp);\n\n  printer_->Outdent();\n  printer_->Print(\")\\n\");\n}\n\n// Prints Python Descriptor objects for all nested types contained in\n// message_descriptor.\n//\n// Mutually recursive with PrintDescriptor().\nvoid Generator::PrintNestedDescriptors(\n    const Descriptor& containing_descriptor) const {\n  for (int i = 0; i < containing_descriptor.nested_type_count(); ++i) {\n    PrintDescriptor(*containing_descriptor.nested_type(i));\n  }\n}\n\n// Prints all messages in |file|.\nvoid Generator::PrintMessages() const {\n  for (int i = 0; i < file_->message_type_count(); ++i) {\n    vector<string> to_register;\n    PrintMessage(*file_->message_type(i), \"\", &to_register);\n    for (int j = 0; j < to_register.size(); ++j) {\n      printer_->Print(\"_sym_db.RegisterMessage($name$)\\n\", \"name\",\n                      to_register[j]);\n    }\n    printer_->Print(\"\\n\");\n  }\n}\n\n// Prints a Python class for the given message descriptor.  We defer to the\n// metaclass to do almost all of the work of actually creating a useful class.\n// The purpose of this function and its many helper functions above is merely\n// to output a Python version of the descriptors, which the metaclass in\n// reflection.py will use to construct the meat of the class itself.\n//\n// Mutually recursive with PrintNestedMessages().\n// Collect nested message names to_register for the symbol_database.\nvoid Generator::PrintMessage(const Descriptor& message_descriptor,\n                             const string& prefix,\n                             vector<string>* to_register) const {\n  string qualified_name(prefix + message_descriptor.name());\n  to_register->push_back(qualified_name);\n  printer_->Print(\n      \"$name$ = _reflection.GeneratedProtocolMessageType('$name$', \"\n      \"(_message.Message,), dict(\\n\",\n      \"name\", message_descriptor.name());\n  printer_->Indent();\n\n  PrintNestedMessages(message_descriptor, qualified_name + \".\", to_register);\n  map<string, string> m;\n  m[\"descriptor_key\"] = kDescriptorKey;\n  m[\"descriptor_name\"] = ModuleLevelDescriptorName(message_descriptor);\n  printer_->Print(m, \"$descriptor_key$ = $descriptor_name$,\\n\");\n  printer_->Print(\"__module__ = '$module_name$'\\n\",\n                  \"module_name\", ModuleName(file_->name()));\n  printer_->Print(\"# @@protoc_insertion_point(class_scope:$full_name$)\\n\",\n                  \"full_name\", message_descriptor.full_name());\n  printer_->Print(\"))\\n\");\n  printer_->Outdent();\n}\n\n// Prints all nested messages within |containing_descriptor|.\n// Mutually recursive with PrintMessage().\nvoid Generator::PrintNestedMessages(const Descriptor& containing_descriptor,\n                                    const string& prefix,\n                                    vector<string>* to_register) const {\n  for (int i = 0; i < containing_descriptor.nested_type_count(); ++i) {\n    printer_->Print(\"\\n\");\n    PrintMessage(*containing_descriptor.nested_type(i), prefix, to_register);\n    printer_->Print(\",\\n\");\n  }\n}\n\n// Recursively fixes foreign fields in all nested types in |descriptor|, then\n// sets the message_type and enum_type of all message and enum fields to point\n// to their respective descriptors.\n// Args:\n//   descriptor: descriptor to print fields for.\n//   containing_descriptor: if descriptor is a nested type, this is its\n//       containing type, or NULL if this is a root/top-level type.\nvoid Generator::FixForeignFieldsInDescriptor(\n    const Descriptor& descriptor,\n    const Descriptor* containing_descriptor) const {\n  for (int i = 0; i < descriptor.nested_type_count(); ++i) {\n    FixForeignFieldsInDescriptor(*descriptor.nested_type(i), &descriptor);\n  }\n\n  for (int i = 0; i < descriptor.field_count(); ++i) {\n    const FieldDescriptor& field_descriptor = *descriptor.field(i);\n    FixForeignFieldsInField(&descriptor, field_descriptor, \"fields_by_name\");\n  }\n\n  FixContainingTypeInDescriptor(descriptor, containing_descriptor);\n  for (int i = 0; i < descriptor.enum_type_count(); ++i) {\n    const EnumDescriptor& enum_descriptor = *descriptor.enum_type(i);\n    FixContainingTypeInDescriptor(enum_descriptor, &descriptor);\n  }\n  for (int i = 0; i < descriptor.oneof_decl_count(); ++i) {\n    map<string, string> m;\n    const OneofDescriptor* oneof = descriptor.oneof_decl(i);\n    m[\"descriptor_name\"] = ModuleLevelDescriptorName(descriptor);\n    m[\"oneof_name\"] = oneof->name();\n    for (int j = 0; j < oneof->field_count(); ++j) {\n      m[\"field_name\"] = oneof->field(j)->name();\n      printer_->Print(\n          m,\n          \"$descriptor_name$.oneofs_by_name['$oneof_name$'].fields.append(\\n\"\n          \"  $descriptor_name$.fields_by_name['$field_name$'])\\n\");\n      printer_->Print(\n          m,\n          \"$descriptor_name$.fields_by_name['$field_name$'].containing_oneof = \"\n          \"$descriptor_name$.oneofs_by_name['$oneof_name$']\\n\");\n    }\n  }\n}\n\nvoid Generator::AddMessageToFileDescriptor(const Descriptor& descriptor) const {\n  map<string, string> m;\n  m[\"descriptor_name\"] = kDescriptorKey;\n  m[\"message_name\"] = descriptor.name();\n  m[\"message_descriptor_name\"] = ModuleLevelDescriptorName(descriptor);\n  const char file_descriptor_template[] =\n      \"$descriptor_name$.message_types_by_name['$message_name$'] = \"\n      \"$message_descriptor_name$\\n\";\n  printer_->Print(m, file_descriptor_template);\n}\n\nvoid Generator::AddEnumToFileDescriptor(\n    const EnumDescriptor& descriptor) const {\n  map<string, string> m;\n  m[\"descriptor_name\"] = kDescriptorKey;\n  m[\"enum_name\"] = descriptor.name();\n  m[\"enum_descriptor_name\"] = ModuleLevelDescriptorName(descriptor);\n  const char file_descriptor_template[] =\n      \"$descriptor_name$.enum_types_by_name['$enum_name$'] = \"\n      \"$enum_descriptor_name$\\n\";\n  printer_->Print(m, file_descriptor_template);\n}\n\nvoid Generator::AddExtensionToFileDescriptor(\n    const FieldDescriptor& descriptor) const {\n  map<string, string> m;\n  m[\"descriptor_name\"] = kDescriptorKey;\n  m[\"field_name\"] = descriptor.name();\n  const char file_descriptor_template[] =\n      \"$descriptor_name$.extensions_by_name['$field_name$'] = \"\n      \"$field_name$\\n\";\n  printer_->Print(m, file_descriptor_template);\n}\n\n// Sets any necessary message_type and enum_type attributes\n// for the Python version of |field|.\n//\n// containing_type may be NULL, in which case this is a module-level field.\n//\n// python_dict_name is the name of the Python dict where we should\n// look the field up in the containing type.  (e.g., fields_by_name\n// or extensions_by_name).  We ignore python_dict_name if containing_type\n// is NULL.\nvoid Generator::FixForeignFieldsInField(const Descriptor* containing_type,\n                                        const FieldDescriptor& field,\n                                        const string& python_dict_name) const {\n  const string field_referencing_expression = FieldReferencingExpression(\n      containing_type, field, python_dict_name);\n  map<string, string> m;\n  m[\"field_ref\"] = field_referencing_expression;\n  const Descriptor* foreign_message_type = field.message_type();\n  if (foreign_message_type) {\n    m[\"foreign_type\"] = ModuleLevelDescriptorName(*foreign_message_type);\n    printer_->Print(m, \"$field_ref$.message_type = $foreign_type$\\n\");\n  }\n  const EnumDescriptor* enum_type = field.enum_type();\n  if (enum_type) {\n    m[\"enum_type\"] = ModuleLevelDescriptorName(*enum_type);\n    printer_->Print(m, \"$field_ref$.enum_type = $enum_type$\\n\");\n  }\n}\n\n// Returns the module-level expression for the given FieldDescriptor.\n// Only works for fields in the .proto file this Generator is generating for.\n//\n// containing_type may be NULL, in which case this is a module-level field.\n//\n// python_dict_name is the name of the Python dict where we should\n// look the field up in the containing type.  (e.g., fields_by_name\n// or extensions_by_name).  We ignore python_dict_name if containing_type\n// is NULL.\nstring Generator::FieldReferencingExpression(\n    const Descriptor* containing_type,\n    const FieldDescriptor& field,\n    const string& python_dict_name) const {\n  // We should only ever be looking up fields in the current file.\n  // The only things we refer to from other files are message descriptors.\n  GOOGLE_CHECK_EQ(field.file(), file_) << field.file()->name() << \" vs. \"\n                                << file_->name();\n  if (!containing_type) {\n    return field.name();\n  }\n  return strings::Substitute(\n      \"$0.$1['$2']\",\n      ModuleLevelDescriptorName(*containing_type),\n      python_dict_name, field.name());\n}\n\n// Prints containing_type for nested descriptors or enum descriptors.\ntemplate <typename DescriptorT>\nvoid Generator::FixContainingTypeInDescriptor(\n    const DescriptorT& descriptor,\n    const Descriptor* containing_descriptor) const {\n  if (containing_descriptor != NULL) {\n    const string nested_name = ModuleLevelDescriptorName(descriptor);\n    const string parent_name = ModuleLevelDescriptorName(\n        *containing_descriptor);\n    printer_->Print(\n        \"$nested_name$.containing_type = $parent_name$\\n\",\n        \"nested_name\", nested_name,\n        \"parent_name\", parent_name);\n  }\n}\n\n// Prints statements setting the message_type and enum_type fields in the\n// Python descriptor objects we've already output in ths file.  We must\n// do this in a separate step due to circular references (otherwise, we'd\n// just set everything in the initial assignment statements).\nvoid Generator::FixForeignFieldsInDescriptors() const {\n  for (int i = 0; i < file_->message_type_count(); ++i) {\n    FixForeignFieldsInDescriptor(*file_->message_type(i), NULL);\n  }\n  for (int i = 0; i < file_->message_type_count(); ++i) {\n    AddMessageToFileDescriptor(*file_->message_type(i));\n  }\n  for (int i = 0; i < file_->enum_type_count(); ++i) {\n    AddEnumToFileDescriptor(*file_->enum_type(i));\n  }\n  for (int i = 0; i < file_->extension_count(); ++i) {\n    AddExtensionToFileDescriptor(*file_->extension(i));\n  }\n  printer_->Print(\"\\n\");\n}\n\n// We need to not only set any necessary message_type fields, but\n// also need to call RegisterExtension() on each message we're\n// extending.\nvoid Generator::FixForeignFieldsInExtensions() const {\n  // Top-level extensions.\n  for (int i = 0; i < file_->extension_count(); ++i) {\n    FixForeignFieldsInExtension(*file_->extension(i));\n  }\n  // Nested extensions.\n  for (int i = 0; i < file_->message_type_count(); ++i) {\n    FixForeignFieldsInNestedExtensions(*file_->message_type(i));\n  }\n  printer_->Print(\"\\n\");\n}\n\nvoid Generator::FixForeignFieldsInExtension(\n    const FieldDescriptor& extension_field) const {\n  GOOGLE_CHECK(extension_field.is_extension());\n  // extension_scope() will be NULL for top-level extensions, which is\n  // exactly what FixForeignFieldsInField() wants.\n  FixForeignFieldsInField(extension_field.extension_scope(), extension_field,\n                          \"extensions_by_name\");\n\n  map<string, string> m;\n  // Confusingly, for FieldDescriptors that happen to be extensions,\n  // containing_type() means \"extended type.\"\n  // On the other hand, extension_scope() will give us what we normally\n  // mean by containing_type().\n  m[\"extended_message_class\"] = ModuleLevelMessageName(\n      *extension_field.containing_type());\n  m[\"field\"] = FieldReferencingExpression(extension_field.extension_scope(),\n                                          extension_field,\n                                          \"extensions_by_name\");\n  printer_->Print(m, \"$extended_message_class$.RegisterExtension($field$)\\n\");\n}\n\nvoid Generator::FixForeignFieldsInNestedExtensions(\n    const Descriptor& descriptor) const {\n  // Recursively fix up extensions in all nested types.\n  for (int i = 0; i < descriptor.nested_type_count(); ++i) {\n    FixForeignFieldsInNestedExtensions(*descriptor.nested_type(i));\n  }\n  // Fix up extensions directly contained within this type.\n  for (int i = 0; i < descriptor.extension_count(); ++i) {\n    FixForeignFieldsInExtension(*descriptor.extension(i));\n  }\n}\n\n// Returns a Python expression that instantiates a Python EnumValueDescriptor\n// object for the given C++ descriptor.\nvoid Generator::PrintEnumValueDescriptor(\n    const EnumValueDescriptor& descriptor) const {\n  // TODO(robinson): Fix up EnumValueDescriptor \"type\" fields.\n  // More circular references.  ::sigh::\n  string options_string;\n  descriptor.options().SerializeToString(&options_string);\n  map<string, string> m;\n  m[\"name\"] = descriptor.name();\n  m[\"index\"] = SimpleItoa(descriptor.index());\n  m[\"number\"] = SimpleItoa(descriptor.number());\n  m[\"options\"] = OptionsValue(\"EnumValueOptions\", options_string);\n  printer_->Print(\n      m,\n      \"_descriptor.EnumValueDescriptor(\\n\"\n      \"  name='$name$', index=$index$, number=$number$,\\n\"\n      \"  options=$options$,\\n\"\n      \"  type=None)\");\n}\n\n// Returns a Python expression that calls descriptor._ParseOptions using\n// the given descriptor class name and serialized options protobuf string.\nstring Generator::OptionsValue(\n    const string& class_name, const string& serialized_options) const {\n  if (serialized_options.length() == 0 || GeneratingDescriptorProto()) {\n    return \"None\";\n  } else {\n    string full_class_name = \"descriptor_pb2.\" + class_name;\n//##!PY25    return \"_descriptor._ParseOptions(\" + full_class_name + \"(), b'\"\n//##!PY25        + CEscape(serialized_options)+ \"')\";\n    return \"_descriptor._ParseOptions(\" + full_class_name + \"(), _b('\"  //##PY25\n        + CEscape(serialized_options)+ \"'))\";  //##PY25\n  }\n}\n\n// Prints an expression for a Python FieldDescriptor for |field|.\nvoid Generator::PrintFieldDescriptor(\n    const FieldDescriptor& field, bool is_extension) const {\n  string options_string;\n  field.options().SerializeToString(&options_string);\n  map<string, string> m;\n  m[\"name\"] = field.name();\n  m[\"full_name\"] = field.full_name();\n  m[\"index\"] = SimpleItoa(field.index());\n  m[\"number\"] = SimpleItoa(field.number());\n  m[\"type\"] = SimpleItoa(field.type());\n  m[\"cpp_type\"] = SimpleItoa(field.cpp_type());\n  m[\"label\"] = SimpleItoa(field.label());\n  m[\"has_default_value\"] = field.has_default_value() ? \"True\" : \"False\";\n  m[\"default_value\"] = StringifyDefaultValue(field);\n  m[\"is_extension\"] = is_extension ? \"True\" : \"False\";\n  m[\"options\"] = OptionsValue(\"FieldOptions\", options_string);\n  // We always set message_type and enum_type to None at this point, and then\n  // these fields in correctly after all referenced descriptors have been\n  // defined and/or imported (see FixForeignFieldsInDescriptors()).\n  const char field_descriptor_decl[] =\n    \"_descriptor.FieldDescriptor(\\n\"\n    \"  name='$name$', full_name='$full_name$', index=$index$,\\n\"\n    \"  number=$number$, type=$type$, cpp_type=$cpp_type$, label=$label$,\\n\"\n    \"  has_default_value=$has_default_value$, default_value=$default_value$,\\n\"\n    \"  message_type=None, enum_type=None, containing_type=None,\\n\"\n    \"  is_extension=$is_extension$, extension_scope=None,\\n\"\n    \"  options=$options$)\";\n  printer_->Print(m, field_descriptor_decl);\n}\n\n// Helper for Print{Fields,Extensions}InDescriptor().\nvoid Generator::PrintFieldDescriptorsInDescriptor(\n    const Descriptor& message_descriptor,\n    bool is_extension,\n    const string& list_variable_name,\n    int (Descriptor::*CountFn)() const,\n    const FieldDescriptor* (Descriptor::*GetterFn)(int) const) const {\n  printer_->Print(\"$list$=[\\n\", \"list\", list_variable_name);\n  printer_->Indent();\n  for (int i = 0; i < (message_descriptor.*CountFn)(); ++i) {\n    PrintFieldDescriptor(*(message_descriptor.*GetterFn)(i),\n                         is_extension);\n    printer_->Print(\",\\n\");\n  }\n  printer_->Outdent();\n  printer_->Print(\"],\\n\");\n}\n\n// Prints a statement assigning \"fields\" to a list of Python FieldDescriptors,\n// one for each field present in message_descriptor.\nvoid Generator::PrintFieldsInDescriptor(\n    const Descriptor& message_descriptor) const {\n  const bool is_extension = false;\n  PrintFieldDescriptorsInDescriptor(\n      message_descriptor, is_extension, \"fields\",\n      &Descriptor::field_count, &Descriptor::field);\n}\n\n// Prints a statement assigning \"extensions\" to a list of Python\n// FieldDescriptors, one for each extension present in message_descriptor.\nvoid Generator::PrintExtensionsInDescriptor(\n    const Descriptor& message_descriptor) const {\n  const bool is_extension = true;\n  PrintFieldDescriptorsInDescriptor(\n      message_descriptor, is_extension, \"extensions\",\n      &Descriptor::extension_count, &Descriptor::extension);\n}\n\nbool Generator::GeneratingDescriptorProto() const {\n  return file_->name() == \"google/protobuf/descriptor.proto\";\n}\n\n// Returns the unique Python module-level identifier given to a descriptor.\n// This name is module-qualified iff the given descriptor describes an\n// entity that doesn't come from the current file.\ntemplate <typename DescriptorT>\nstring Generator::ModuleLevelDescriptorName(\n    const DescriptorT& descriptor) const {\n  // FIXME(robinson):\n  // We currently don't worry about collisions with underscores in the type\n  // names, so these would collide in nasty ways if found in the same file:\n  //   OuterProto.ProtoA.ProtoB\n  //   OuterProto_ProtoA.ProtoB  # Underscore instead of period.\n  // As would these:\n  //   OuterProto.ProtoA_.ProtoB\n  //   OuterProto.ProtoA._ProtoB  # Leading vs. trailing underscore.\n  // (Contrived, but certainly possible).\n  //\n  // The C++ implementation doesn't guard against this either.  Leaving\n  // it for now...\n  string name = NamePrefixedWithNestedTypes(descriptor, \"_\");\n  UpperString(&name);\n  // Module-private for now.  Easy to make public later; almost impossible\n  // to make private later.\n  name = \"_\" + name;\n  // We now have the name relative to its own module.  Also qualify with\n  // the module name iff this descriptor is from a different .proto file.\n  if (descriptor.file() != file_) {\n    name = ModuleAlias(descriptor.file()->name()) + \".\" + name;\n  }\n  return name;\n}\n\n// Returns the name of the message class itself, not the descriptor.\n// Like ModuleLevelDescriptorName(), module-qualifies the name iff\n// the given descriptor describes an entity that doesn't come from\n// the current file.\nstring Generator::ModuleLevelMessageName(const Descriptor& descriptor) const {\n  string name = NamePrefixedWithNestedTypes(descriptor, \".\");\n  if (descriptor.file() != file_) {\n    name = ModuleAlias(descriptor.file()->name()) + \".\" + name;\n  }\n  return name;\n}\n\n// Returns the unique Python module-level identifier given to a service\n// descriptor.\nstring Generator::ModuleLevelServiceDescriptorName(\n    const ServiceDescriptor& descriptor) const {\n  string name = descriptor.name();\n  UpperString(&name);\n  name = \"_\" + name;\n  if (descriptor.file() != file_) {\n    name = ModuleAlias(descriptor.file()->name()) + \".\" + name;\n  }\n  return name;\n}\n\n// Prints standard constructor arguments serialized_start and serialized_end.\n// Args:\n//   descriptor: The cpp descriptor to have a serialized reference.\n//   proto: A proto\n// Example printer output:\n// serialized_start=41,\n// serialized_end=43,\n//\ntemplate <typename DescriptorT, typename DescriptorProtoT>\nvoid Generator::PrintSerializedPbInterval(\n    const DescriptorT& descriptor, DescriptorProtoT& proto) const {\n  descriptor.CopyTo(&proto);\n  string sp;\n  proto.SerializeToString(&sp);\n  int offset = file_descriptor_serialized_.find(sp);\n  GOOGLE_CHECK_GE(offset, 0);\n\n  printer_->Print(\"serialized_start=$serialized_start$,\\n\"\n                  \"serialized_end=$serialized_end$,\\n\",\n                  \"serialized_start\", SimpleItoa(offset),\n                  \"serialized_end\", SimpleItoa(offset + sp.size()));\n}\n\nnamespace {\nvoid PrintDescriptorOptionsFixingCode(const string& descriptor,\n                                      const string& options,\n                                      io::Printer* printer) {\n  // TODO(xiaofeng): I have added a method _SetOptions() to DescriptorBase\n  // in proto2 python runtime but it couldn't be used here because appengine\n  // uses a snapshot version of the library in which the new method is not\n  // yet present. After appengine has synced their runtime library, the code\n  // below should be cleaned up to use _SetOptions().\n  printer->Print(\n      \"$descriptor$.has_options = True\\n\"\n      \"$descriptor$._options = $options$\\n\",\n      \"descriptor\", descriptor, \"options\", options);\n}\n}  // namespace\n\n// Prints expressions that set the options field of all descriptors.\nvoid Generator::FixAllDescriptorOptions() const {\n  // Prints an expression that sets the file descriptor's options.\n  string file_options = OptionsValue(\n      \"FileOptions\", file_->options().SerializeAsString());\n  if (file_options != \"None\") {\n    PrintDescriptorOptionsFixingCode(kDescriptorKey, file_options, printer_);\n  }\n  // Prints expressions that set the options for all top level enums.\n  for (int i = 0; i < file_->enum_type_count(); ++i) {\n    const EnumDescriptor& enum_descriptor = *file_->enum_type(i);\n    FixOptionsForEnum(enum_descriptor);\n  }\n  // Prints expressions that set the options for all top level extensions.\n  for (int i = 0; i < file_->extension_count(); ++i) {\n    const FieldDescriptor& field = *file_->extension(i);\n    FixOptionsForField(field);\n  }\n  // Prints expressions that set the options for all messages, nested enums,\n  // nested extensions and message fields.\n  for (int i = 0; i < file_->message_type_count(); ++i) {\n    FixOptionsForMessage(*file_->message_type(i));\n  }\n}\n\nvoid Generator::FixOptionsForOneof(const OneofDescriptor& oneof) const {\n  string oneof_options = OptionsValue(\n      \"OneofOptions\", oneof.options().SerializeAsString());\n  if (oneof_options != \"None\") {\n    string oneof_name = strings::Substitute(\n        \"$0.$1['$2']\",\n        ModuleLevelDescriptorName(*oneof.containing_type()),\n        \"oneofs_by_name\", oneof.name());\n    PrintDescriptorOptionsFixingCode(oneof_name, oneof_options, printer_);\n  }\n}\n\n// Prints expressions that set the options for an enum descriptor and its\n// value descriptors.\nvoid Generator::FixOptionsForEnum(const EnumDescriptor& enum_descriptor) const {\n  string descriptor_name = ModuleLevelDescriptorName(enum_descriptor);\n  string enum_options = OptionsValue(\n      \"EnumOptions\", enum_descriptor.options().SerializeAsString());\n  if (enum_options != \"None\") {\n    PrintDescriptorOptionsFixingCode(descriptor_name, enum_options, printer_);\n  }\n  for (int i = 0; i < enum_descriptor.value_count(); ++i) {\n    const EnumValueDescriptor& value_descriptor = *enum_descriptor.value(i);\n    string value_options = OptionsValue(\n        \"EnumValueOptions\", value_descriptor.options().SerializeAsString());\n    if (value_options != \"None\") {\n      PrintDescriptorOptionsFixingCode(\n          StringPrintf(\"%s.values_by_name[\\\"%s\\\"]\", descriptor_name.c_str(),\n                       value_descriptor.name().c_str()),\n          value_options, printer_);\n    }\n  }\n}\n\n// Prints expressions that set the options for field descriptors (including\n// extensions).\nvoid Generator::FixOptionsForField(\n    const FieldDescriptor& field) const {\n  string field_options = OptionsValue(\n      \"FieldOptions\", field.options().SerializeAsString());\n  if (field_options != \"None\") {\n    string field_name;\n    if (field.is_extension()) {\n      if (field.extension_scope() == NULL) {\n        // Top level extensions.\n        field_name = field.name();\n      } else {\n        field_name = FieldReferencingExpression(\n            field.extension_scope(), field, \"extensions_by_name\");\n      }\n    } else {\n      field_name = FieldReferencingExpression(\n          field.containing_type(), field, \"fields_by_name\");\n    }\n    PrintDescriptorOptionsFixingCode(field_name, field_options, printer_);\n  }\n}\n\n// Prints expressions that set the options for a message and all its inner\n// types (nested messages, nested enums, extensions, fields).\nvoid Generator::FixOptionsForMessage(const Descriptor& descriptor) const {\n  // Nested messages.\n  for (int i = 0; i < descriptor.nested_type_count(); ++i) {\n    FixOptionsForMessage(*descriptor.nested_type(i));\n  }\n  // Oneofs.\n  for (int i = 0; i < descriptor.oneof_decl_count(); ++i) {\n    FixOptionsForOneof(*descriptor.oneof_decl(i));\n  }\n  // Enums.\n  for (int i = 0; i < descriptor.enum_type_count(); ++i) {\n    FixOptionsForEnum(*descriptor.enum_type(i));\n  }\n  // Fields.\n  for (int i = 0; i < descriptor.field_count(); ++i) {\n    const FieldDescriptor& field = *descriptor.field(i);\n    FixOptionsForField(field);\n  }\n  // Extensions.\n  for (int i = 0; i < descriptor.extension_count(); ++i) {\n    const FieldDescriptor& field = *descriptor.extension(i);\n    FixOptionsForField(field);\n  }\n  // Message option for this message.\n  string message_options = OptionsValue(\n      \"MessageOptions\", descriptor.options().SerializeAsString());\n  if (message_options != \"None\") {\n    string descriptor_name = ModuleLevelDescriptorName(descriptor);\n    PrintDescriptorOptionsFixingCode(descriptor_name,\n                                     message_options,\n                                     printer_);\n  }\n}\n\n// If a dependency forwards other files through public dependencies, let's\n// copy over the corresponding module aliases.\nvoid Generator::CopyPublicDependenciesAliases(\n    const string& copy_from, const FileDescriptor* file) const {\n  for (int i = 0; i < file->public_dependency_count(); ++i) {\n    string module_alias = ModuleAlias(file->public_dependency(i)->name());\n    printer_->Print(\"$alias$ = $copy_from$.$alias$\\n\", \"alias\", module_alias,\n                    \"copy_from\", copy_from);\n    CopyPublicDependenciesAliases(copy_from, file->public_dependency(i));\n  }\n}\n\n}  // namespace python\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/python/python_generator.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: robinson@google.com (Will Robinson)\n//\n// Generates Python code for a given .proto file.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__\n#define GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__\n\n#include <string>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/stubs/mutex.h>\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\n\nclass Descriptor;\nclass EnumDescriptor;\nclass EnumValueDescriptor;\nclass FieldDescriptor;\nclass OneofDescriptor;\nclass ServiceDescriptor;\n\nnamespace io { class Printer; }\n\nnamespace compiler {\nnamespace python {\n\n// CodeGenerator implementation for generated Python protocol buffer classes.\n// If you create your own protocol compiler binary and you want it to support\n// Python output, you can do so by registering an instance of this\n// CodeGenerator with the CommandLineInterface in your main() function.\nclass LIBPROTOC_EXPORT Generator : public CodeGenerator {\n public:\n  Generator();\n  virtual ~Generator();\n\n  // CodeGenerator methods.\n  virtual bool Generate(const FileDescriptor* file,\n                        const string& parameter,\n                        GeneratorContext* generator_context,\n                        string* error) const;\n\n private:\n  void PrintImports() const;\n  void PrintFileDescriptor() const;\n  void PrintTopLevelEnums() const;\n  void PrintAllNestedEnumsInFile() const;\n  void PrintNestedEnums(const Descriptor& descriptor) const;\n  void PrintEnum(const EnumDescriptor& enum_descriptor) const;\n\n  void PrintTopLevelExtensions() const;\n\n  void PrintFieldDescriptor(\n      const FieldDescriptor& field, bool is_extension) const;\n  void PrintFieldDescriptorsInDescriptor(\n      const Descriptor& message_descriptor,\n      bool is_extension,\n      const string& list_variable_name,\n      int (Descriptor::*CountFn)() const,\n      const FieldDescriptor* (Descriptor::*GetterFn)(int) const) const;\n  void PrintFieldsInDescriptor(const Descriptor& message_descriptor) const;\n  void PrintExtensionsInDescriptor(const Descriptor& message_descriptor) const;\n  void PrintMessageDescriptors() const;\n  void PrintDescriptor(const Descriptor& message_descriptor) const;\n  void PrintNestedDescriptors(const Descriptor& containing_descriptor) const;\n\n  void PrintMessages() const;\n  void PrintMessage(const Descriptor& message_descriptor, const string& prefix,\n                    vector<string>* to_register) const;\n  void PrintNestedMessages(const Descriptor& containing_descriptor,\n                           const string& prefix,\n                           vector<string>* to_register) const;\n\n  void FixForeignFieldsInDescriptors() const;\n  void FixForeignFieldsInDescriptor(\n      const Descriptor& descriptor,\n      const Descriptor* containing_descriptor) const;\n  void FixForeignFieldsInField(const Descriptor* containing_type,\n                               const FieldDescriptor& field,\n                               const string& python_dict_name) const;\n  void AddMessageToFileDescriptor(const Descriptor& descriptor) const;\n  void AddEnumToFileDescriptor(const EnumDescriptor& descriptor) const;\n  void AddExtensionToFileDescriptor(const FieldDescriptor& descriptor) const;\n  string FieldReferencingExpression(const Descriptor* containing_type,\n                                    const FieldDescriptor& field,\n                                    const string& python_dict_name) const;\n  template <typename DescriptorT>\n  void FixContainingTypeInDescriptor(\n      const DescriptorT& descriptor,\n      const Descriptor* containing_descriptor) const;\n\n  void FixForeignFieldsInExtensions() const;\n  void FixForeignFieldsInExtension(\n      const FieldDescriptor& extension_field) const;\n  void FixForeignFieldsInNestedExtensions(const Descriptor& descriptor) const;\n\n  void PrintServices() const;\n  void PrintServiceDescriptor(const ServiceDescriptor& descriptor) const;\n  void PrintServiceClass(const ServiceDescriptor& descriptor) const;\n  void PrintServiceStub(const ServiceDescriptor& descriptor) const;\n  void PrintDescriptorKeyAndModuleName(\n      const ServiceDescriptor& descriptor) const ;\n\n  void PrintEnumValueDescriptor(const EnumValueDescriptor& descriptor) const;\n  string OptionsValue(const string& class_name,\n                      const string& serialized_options) const;\n  bool GeneratingDescriptorProto() const;\n\n  template <typename DescriptorT>\n  string ModuleLevelDescriptorName(const DescriptorT& descriptor) const;\n  string ModuleLevelMessageName(const Descriptor& descriptor) const;\n  string ModuleLevelServiceDescriptorName(\n      const ServiceDescriptor& descriptor) const;\n\n  template <typename DescriptorT, typename DescriptorProtoT>\n  void PrintSerializedPbInterval(\n      const DescriptorT& descriptor, DescriptorProtoT& proto) const;\n\n  void FixAllDescriptorOptions() const;\n  void FixOptionsForField(const FieldDescriptor& field) const;\n  void FixOptionsForOneof(const OneofDescriptor& oneof) const;\n  void FixOptionsForEnum(const EnumDescriptor& descriptor) const;\n  void FixOptionsForMessage(const Descriptor& descriptor) const;\n\n  void CopyPublicDependenciesAliases(\n      const string& copy_from, const FileDescriptor* file) const;\n\n  // Very coarse-grained lock to ensure that Generate() is reentrant.\n  // Guards file_, printer_ and file_descriptor_serialized_.\n  mutable Mutex mutex_;\n  mutable const FileDescriptor* file_;  // Set in Generate().  Under mutex_.\n  mutable string file_descriptor_serialized_;\n  mutable io::Printer* printer_;  // Set in Generate().  Under mutex_.\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Generator);\n};\n\n}  // namespace python\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_PYTHON_GENERATOR_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/python/python_plugin_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//\n// TODO(kenton):  Share code with the versions of this test in other languages?\n//   It seemed like parameterizing it would add more complexity than it is\n//   worth.\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#include <google/protobuf/compiler/python/python_generator.h>\n#include <google/protobuf/compiler/command_line_interface.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/io/printer.h>\n\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace python {\nnamespace {\n\nclass TestGenerator : public CodeGenerator {\n public:\n  TestGenerator() {}\n  ~TestGenerator() {}\n\n  virtual bool Generate(const FileDescriptor* file,\n                        const string& parameter,\n                        GeneratorContext* context,\n                        string* error) const {\n    TryInsert(\"test_pb2.py\", \"imports\", context);\n    TryInsert(\"test_pb2.py\", \"module_scope\", context);\n    TryInsert(\"test_pb2.py\", \"class_scope:foo.Bar\", context);\n    TryInsert(\"test_pb2.py\", \"class_scope:foo.Bar.Baz\", context);\n    return true;\n  }\n\n  void TryInsert(const string& filename, const string& insertion_point,\n                 GeneratorContext* context) const {\n    google::protobuf::scoped_ptr<io::ZeroCopyOutputStream> output(\n        context->OpenForInsert(filename, insertion_point));\n    io::Printer printer(output.get(), '$');\n    printer.Print(\"// inserted $name$\\n\", \"name\", insertion_point);\n  }\n};\n\n// This test verifies that all the expected insertion points exist.  It does\n// not verify that they are correctly-placed; that would require actually\n// compiling the output which is a bit more than I care to do for this test.\nTEST(PythonPluginTest, PluginTest) {\n  GOOGLE_CHECK_OK(File::SetContents(TestTempDir() + \"/test.proto\",\n                             \"syntax = \\\"proto2\\\";\\n\"\n                             \"package foo;\\n\"\n                             \"message Bar {\\n\"\n                             \"  message Baz {}\\n\"\n                             \"}\\n\",\n                             true));\n\n  google::protobuf::compiler::CommandLineInterface cli;\n  cli.SetInputsAreProtoPathRelative(true);\n\n  python::Generator python_generator;\n  TestGenerator test_generator;\n  cli.RegisterGenerator(\"--python_out\", &python_generator, \"\");\n  cli.RegisterGenerator(\"--test_out\", &test_generator, \"\");\n\n  string proto_path = \"-I\" + TestTempDir();\n  string python_out = \"--python_out=\" + TestTempDir();\n  string test_out = \"--test_out=\" + TestTempDir();\n\n  const char* argv[] = {\n    \"protoc\",\n    proto_path.c_str(),\n    python_out.c_str(),\n    test_out.c_str(),\n    \"test.proto\"\n  };\n\n  EXPECT_EQ(0, cli.Run(5, argv));\n}\n\n// This test verifies that the generated Python output uses regular imports (as\n// opposed to importlib) in the usual case where the .proto file paths do not\n// not contain any Python keywords.\nTEST(PythonPluginTest, ImportTest) {\n  // Create files test1.proto and test2.proto with the former importing the\n  // latter.\n  GOOGLE_CHECK_OK(File::SetContents(TestTempDir() + \"/test1.proto\",\n                             \"syntax = \\\"proto3\\\";\\n\"\n                             \"package foo;\\n\"\n                             \"import \\\"test2.proto\\\";\"\n                             \"message Message1 {\\n\"\n                             \"  Message2 message_2 = 1;\\n\"\n                             \"}\\n\",\n                             true));\n  GOOGLE_CHECK_OK(File::SetContents(TestTempDir() + \"/test2.proto\",\n                             \"syntax = \\\"proto3\\\";\\n\"\n                             \"package foo;\\n\"\n                             \"message Message2 {}\\n\",\n                             true));\n\n  google::protobuf::compiler::CommandLineInterface cli;\n  cli.SetInputsAreProtoPathRelative(true);\n  python::Generator python_generator;\n  cli.RegisterGenerator(\"--python_out\", &python_generator, \"\");\n  string proto_path = \"-I\" + TestTempDir();\n  string python_out = \"--python_out=\" + TestTempDir();\n  const char* argv[] = {\"protoc\", proto_path.c_str(), \"-I.\", python_out.c_str(),\n                        \"test1.proto\"};\n  ASSERT_EQ(0, cli.Run(5, argv));\n\n  // Loop over the lines of the generated code and verify that we find an\n  // ordinary Python import but do not find the string \"importlib\".\n  string output;\n  GOOGLE_CHECK_OK(File::GetContents(TestTempDir() + \"/test1_pb2.py\", &output,\n                             true));\n  std::vector<string> lines = Split(output, \"\\n\");\n  string expected_import = \"import test2_pb2\";\n  bool found_expected_import = false;\n  for (int i = 0; i < lines.size(); ++i) {\n    if (lines[i].find(expected_import) != string::npos) {\n      found_expected_import = true;\n    }\n    EXPECT_EQ(string::npos, lines[i].find(\"importlib\"));\n  }\n  EXPECT_TRUE(found_expected_import);\n}\n\n}  // namespace\n}  // namespace python\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/ruby/ruby_generated_code.proto",
    "content": "syntax = \"proto3\";\n\npackage A.B.C;\n\nmessage TestMessage {\n  int32 optional_int32 = 1;\n  int64 optional_int64 = 2;\n  uint32 optional_uint32 = 3;\n  uint64 optional_uint64 = 4;\n  bool optional_bool = 5;\n  double optional_double = 6;\n  float optional_float = 7;\n  string optional_string = 8;\n  bytes optional_bytes = 9;\n  TestEnum optional_enum = 10;\n  TestMessage optional_msg = 11;\n\n  repeated int32 repeated_int32 = 21;\n  repeated int64 repeated_int64 = 22;\n  repeated uint32 repeated_uint32 = 23;\n  repeated uint64 repeated_uint64 = 24;\n  repeated bool repeated_bool = 25;\n  repeated double repeated_double = 26;\n  repeated float repeated_float = 27;\n  repeated string repeated_string = 28;\n  repeated bytes repeated_bytes = 29;\n  repeated TestEnum repeated_enum = 30;\n  repeated TestMessage repeated_msg = 31;\n\n  oneof my_oneof {\n    int32 oneof_int32 = 41;\n    int64 oneof_int64 = 42;\n    uint32 oneof_uint32 = 43;\n    uint64 oneof_uint64 = 44;\n    bool oneof_bool = 45;\n    double oneof_double = 46;\n    float oneof_float = 47;\n    string oneof_string = 48;\n    bytes oneof_bytes = 49;\n    TestEnum oneof_enum = 50;\n    TestMessage oneof_msg = 51;\n  }\n\n  map<int32, string> map_int32_string = 61;\n  map<int64, string> map_int64_string = 62;\n  map<uint32, string> map_uint32_string = 63;\n  map<uint64, string> map_uint64_string = 64;\n  map<bool, string> map_bool_string = 65;\n  map<string, string> map_string_string = 66;\n  map<string, TestMessage> map_string_msg = 67;\n  map<string, TestEnum> map_string_enum = 68;\n  map<string, int32> map_string_int32 = 69;\n  map<string, bool> map_string_bool = 70;\n\n  message NestedMessage {\n    int32 foo = 1;\n  }\n\n  NestedMessage nested_message = 80;\n}\n\nenum TestEnum {\n  Default = 0;\n  A = 1;\n  B = 2;\n  C = 3;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/ruby/ruby_generated_code_pb.rb",
    "content": "# Generated by the protocol buffer compiler.  DO NOT EDIT!\n# source: ruby_generated_code.proto\n\nrequire 'google/protobuf'\n\nGoogle::Protobuf::DescriptorPool.generated_pool.build do\n  add_message \"A.B.C.TestMessage\" do\n    optional :optional_int32, :int32, 1\n    optional :optional_int64, :int64, 2\n    optional :optional_uint32, :uint32, 3\n    optional :optional_uint64, :uint64, 4\n    optional :optional_bool, :bool, 5\n    optional :optional_double, :double, 6\n    optional :optional_float, :float, 7\n    optional :optional_string, :string, 8\n    optional :optional_bytes, :bytes, 9\n    optional :optional_enum, :enum, 10, \"A.B.C.TestEnum\"\n    optional :optional_msg, :message, 11, \"A.B.C.TestMessage\"\n    repeated :repeated_int32, :int32, 21\n    repeated :repeated_int64, :int64, 22\n    repeated :repeated_uint32, :uint32, 23\n    repeated :repeated_uint64, :uint64, 24\n    repeated :repeated_bool, :bool, 25\n    repeated :repeated_double, :double, 26\n    repeated :repeated_float, :float, 27\n    repeated :repeated_string, :string, 28\n    repeated :repeated_bytes, :bytes, 29\n    repeated :repeated_enum, :enum, 30, \"A.B.C.TestEnum\"\n    repeated :repeated_msg, :message, 31, \"A.B.C.TestMessage\"\n    map :map_int32_string, :int32, :string, 61\n    map :map_int64_string, :int64, :string, 62\n    map :map_uint32_string, :uint32, :string, 63\n    map :map_uint64_string, :uint64, :string, 64\n    map :map_bool_string, :bool, :string, 65\n    map :map_string_string, :string, :string, 66\n    map :map_string_msg, :string, :message, 67, \"A.B.C.TestMessage\"\n    map :map_string_enum, :string, :enum, 68, \"A.B.C.TestEnum\"\n    map :map_string_int32, :string, :int32, 69\n    map :map_string_bool, :string, :bool, 70\n    optional :nested_message, :message, 80, \"A.B.C.TestMessage.NestedMessage\"\n    oneof :my_oneof do\n      optional :oneof_int32, :int32, 41\n      optional :oneof_int64, :int64, 42\n      optional :oneof_uint32, :uint32, 43\n      optional :oneof_uint64, :uint64, 44\n      optional :oneof_bool, :bool, 45\n      optional :oneof_double, :double, 46\n      optional :oneof_float, :float, 47\n      optional :oneof_string, :string, 48\n      optional :oneof_bytes, :bytes, 49\n      optional :oneof_enum, :enum, 50, \"A.B.C.TestEnum\"\n      optional :oneof_msg, :message, 51, \"A.B.C.TestMessage\"\n    end\n  end\n  add_message \"A.B.C.TestMessage.NestedMessage\" do\n    optional :foo, :int32, 1\n  end\n  add_enum \"A.B.C.TestEnum\" do\n    value :Default, 0\n    value :A, 1\n    value :B, 2\n    value :C, 3\n  end\nend\n\nmodule A\n  module B\n    module C\n      TestMessage = Google::Protobuf::DescriptorPool.generated_pool.lookup(\"A.B.C.TestMessage\").msgclass\n      TestMessage::NestedMessage = Google::Protobuf::DescriptorPool.generated_pool.lookup(\"A.B.C.TestMessage.NestedMessage\").msgclass\n      TestEnum = Google::Protobuf::DescriptorPool.generated_pool.lookup(\"A.B.C.TestEnum\").enummodule\n    end\n  end\nend\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/ruby/ruby_generator.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <sstream>\n\n#include <google/protobuf/compiler/code_generator.h>\n#include <google/protobuf/compiler/plugin.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n\n#include <google/protobuf/compiler/ruby/ruby_generator.h>\n\nusing google::protobuf::internal::scoped_ptr;\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace ruby {\n\n// Forward decls.\nstd::string IntToString(int32 value);\nstd::string GetRequireName(const std::string& proto_file);\nstd::string LabelForField(google::protobuf::FieldDescriptor* field);\nstd::string TypeName(google::protobuf::FieldDescriptor* field);\nvoid GenerateMessage(const google::protobuf::Descriptor* message,\n                     google::protobuf::io::Printer* printer);\nvoid GenerateEnum(const google::protobuf::EnumDescriptor* en,\n                  google::protobuf::io::Printer* printer);\nvoid GenerateMessageAssignment(\n    const std::string& prefix,\n    const google::protobuf::Descriptor* message,\n    google::protobuf::io::Printer* printer);\nvoid GenerateEnumAssignment(\n    const std::string& prefix,\n    const google::protobuf::EnumDescriptor* en,\n    google::protobuf::io::Printer* printer);\n\nstd::string IntToString(int32 value) {\n  std::ostringstream os;\n  os << value;\n  return os.str();\n}\n\nstd::string GetRequireName(const std::string& proto_file) {\n  int lastindex = proto_file.find_last_of(\".\");\n  return proto_file.substr(0, lastindex) + \"_pb\";\n}\n\nstd::string GetOutputFilename(const std::string& proto_file) {\n  return GetRequireName(proto_file) + \".rb\";\n}\n\nstd::string LabelForField(const google::protobuf::FieldDescriptor* field) {\n  switch (field->label()) {\n    case FieldDescriptor::LABEL_OPTIONAL: return \"optional\";\n    case FieldDescriptor::LABEL_REQUIRED: return \"required\";\n    case FieldDescriptor::LABEL_REPEATED: return \"repeated\";\n    default: assert(false); return \"\";\n  }\n}\n\nstd::string TypeName(const google::protobuf::FieldDescriptor* field) {\n  switch (field->type()) {\n    case FieldDescriptor::TYPE_INT32: return \"int32\";\n    case FieldDescriptor::TYPE_INT64: return \"int64\";\n    case FieldDescriptor::TYPE_UINT32: return \"uint32\";\n    case FieldDescriptor::TYPE_UINT64: return \"uint64\";\n    case FieldDescriptor::TYPE_SINT32: return \"sint32\";\n    case FieldDescriptor::TYPE_SINT64: return \"sint64\";\n    case FieldDescriptor::TYPE_FIXED32: return \"fixed32\";\n    case FieldDescriptor::TYPE_FIXED64: return \"fixed64\";\n    case FieldDescriptor::TYPE_SFIXED32: return \"sfixed32\";\n    case FieldDescriptor::TYPE_SFIXED64: return \"sfixed64\";\n    case FieldDescriptor::TYPE_DOUBLE: return \"double\";\n    case FieldDescriptor::TYPE_FLOAT: return \"float\";\n    case FieldDescriptor::TYPE_BOOL: return \"bool\";\n    case FieldDescriptor::TYPE_ENUM: return \"enum\";\n    case FieldDescriptor::TYPE_STRING: return \"string\";\n    case FieldDescriptor::TYPE_BYTES: return \"bytes\";\n    case FieldDescriptor::TYPE_MESSAGE: return \"message\";\n    case FieldDescriptor::TYPE_GROUP: return \"group\";\n    default: assert(false); return \"\";\n  }\n}\n\nvoid GenerateField(const google::protobuf::FieldDescriptor* field,\n                   google::protobuf::io::Printer* printer) {\n\n  if (field->is_map()) {\n    const FieldDescriptor* key_field =\n        field->message_type()->FindFieldByNumber(1);\n    const FieldDescriptor* value_field =\n        field->message_type()->FindFieldByNumber(2);\n\n    printer->Print(\n      \"map :$name$, :$key_type$, :$value_type$, $number$\",\n      \"name\", field->name(),\n      \"key_type\", TypeName(key_field),\n      \"value_type\", TypeName(value_field),\n      \"number\", IntToString(field->number()));\n\n    if (value_field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n      printer->Print(\n        \", \\\"$subtype$\\\"\\n\",\n        \"subtype\", value_field->message_type()->full_name());\n    } else if (value_field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {\n      printer->Print(\n        \", \\\"$subtype$\\\"\\n\",\n        \"subtype\", value_field->enum_type()->full_name());\n    } else {\n      printer->Print(\"\\n\");\n    }\n  } else {\n\n    printer->Print(\n      \"$label$ :$name$, \",\n      \"label\", LabelForField(field),\n      \"name\", field->name());\n    printer->Print(\n      \":$type$, $number$\",\n      \"type\", TypeName(field),\n      \"number\", IntToString(field->number()));\n\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n      printer->Print(\n        \", \\\"$subtype$\\\"\\n\",\n       \"subtype\", field->message_type()->full_name());\n    } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {\n      printer->Print(\n        \", \\\"$subtype$\\\"\\n\",\n        \"subtype\", field->enum_type()->full_name());\n    } else {\n      printer->Print(\"\\n\");\n    }\n  }\n}\n\nvoid GenerateOneof(const google::protobuf::OneofDescriptor* oneof,\n                   google::protobuf::io::Printer* printer) {\n  printer->Print(\n      \"oneof :$name$ do\\n\",\n      \"name\", oneof->name());\n  printer->Indent();\n\n  for (int i = 0; i < oneof->field_count(); i++) {\n    const FieldDescriptor* field = oneof->field(i);\n    GenerateField(field, printer);\n  }\n\n  printer->Outdent();\n  printer->Print(\"end\\n\");\n}\n\nvoid GenerateMessage(const google::protobuf::Descriptor* message,\n                     google::protobuf::io::Printer* printer) {\n\n  // Don't generate MapEntry messages -- we use the Ruby extension's native\n  // support for map fields instead.\n  if (message->options().map_entry()) {\n    return;\n  }\n\n  printer->Print(\n    \"add_message \\\"$name$\\\" do\\n\",\n    \"name\", message->full_name());\n  printer->Indent();\n\n  for (int i = 0; i < message->field_count(); i++) {\n    const FieldDescriptor* field = message->field(i);\n    if (!field->containing_oneof()) {\n      GenerateField(field, printer);\n    }\n  }\n\n  for (int i = 0; i < message->oneof_decl_count(); i++) {\n    const OneofDescriptor* oneof = message->oneof_decl(i);\n    GenerateOneof(oneof, printer);\n  }\n\n  printer->Outdent();\n  printer->Print(\"end\\n\");\n\n  for (int i = 0; i < message->nested_type_count(); i++) {\n    GenerateMessage(message->nested_type(i), printer);\n  }\n  for (int i = 0; i < message->enum_type_count(); i++) {\n    GenerateEnum(message->enum_type(i), printer);\n  }\n}\n\nvoid GenerateEnum(const google::protobuf::EnumDescriptor* en,\n                  google::protobuf::io::Printer* printer) {\n  printer->Print(\n    \"add_enum \\\"$name$\\\" do\\n\",\n    \"name\", en->full_name());\n  printer->Indent();\n\n  for (int i = 0; i < en->value_count(); i++) {\n    const EnumValueDescriptor* value = en->value(i);\n    printer->Print(\n      \"value :$name$, $number$\\n\",\n      \"name\", value->name(),\n      \"number\", IntToString(value->number()));\n  }\n\n  printer->Outdent();\n  printer->Print(\n    \"end\\n\");\n}\n\n// Locale-agnostic utility functions.\nbool IsLower(char ch) { return ch >= 'a' && ch <= 'z'; }\n\nbool IsUpper(char ch) { return ch >= 'A' && ch <= 'Z'; }\n\nbool IsAlpha(char ch) { return IsLower(ch) || IsUpper(ch); }\n\nchar ToUpper(char ch) { return IsLower(ch) ? (ch - 'a' + 'A') : ch; }\n\n\n// Package names in protobuf are snake_case by convention, but Ruby module\n// names must be PascalCased.\n//\n//   foo_bar_baz -> FooBarBaz\nstd::string PackageToModule(const std::string& name) {\n  bool next_upper = true;\n  std::string result;\n  result.reserve(name.size());\n\n  for (int i = 0; i < name.size(); i++) {\n    if (name[i] == '_') {\n      next_upper = true;\n    } else {\n      if (next_upper) {\n        result.push_back(ToUpper(name[i]));\n      } else {\n        result.push_back(name[i]);\n      }\n      next_upper = false;\n    }\n  }\n\n  return result;\n}\n\n// Class and enum names in protobuf should be PascalCased by convention, but\n// since there is nothing enforcing this we need to ensure that they are valid\n// Ruby constants.  That mainly means making sure that the first character is\n// an upper-case letter.\nstd::string RubifyConstant(const std::string& name) {\n  std::string ret = name;\n  if (!ret.empty()) {\n    if (IsLower(ret[0])) {\n      // If it starts with a lowercase letter, capitalize it.\n      ret[0] = ToUpper(ret[0]);\n    } else if (!IsAlpha(ret[0])) {\n      // Otherwise (e.g. if it begins with an underscore), we need to come up\n      // with some prefix that starts with a capital letter. We could be smarter\n      // here, e.g. try to strip leading underscores, but this may cause other\n      // problems if the user really intended the name. So let's just prepend a\n      // well-known suffix.\n      ret = \"PB_\" + ret;\n    }\n  }\n\n  return ret;\n}\n\nvoid GenerateMessageAssignment(\n    const std::string& prefix,\n    const google::protobuf::Descriptor* message,\n    google::protobuf::io::Printer* printer) {\n\n  // Don't generate MapEntry messages -- we use the Ruby extension's native\n  // support for map fields instead.\n  if (message->options().map_entry()) {\n    return;\n  }\n\n  printer->Print(\n    \"$prefix$$name$ = \",\n    \"prefix\", prefix,\n    \"name\", RubifyConstant(message->name()));\n  printer->Print(\n    \"Google::Protobuf::DescriptorPool.generated_pool.\"\n    \"lookup(\\\"$full_name$\\\").msgclass\\n\",\n    \"full_name\", message->full_name());\n\n  std::string nested_prefix = prefix + message->name() + \"::\";\n  for (int i = 0; i < message->nested_type_count(); i++) {\n    GenerateMessageAssignment(nested_prefix, message->nested_type(i), printer);\n  }\n  for (int i = 0; i < message->enum_type_count(); i++) {\n    GenerateEnumAssignment(nested_prefix, message->enum_type(i), printer);\n  }\n}\n\nvoid GenerateEnumAssignment(\n    const std::string& prefix,\n    const google::protobuf::EnumDescriptor* en,\n    google::protobuf::io::Printer* printer) {\n  printer->Print(\n    \"$prefix$$name$ = \",\n    \"prefix\", prefix,\n    \"name\", RubifyConstant(en->name()));\n  printer->Print(\n    \"Google::Protobuf::DescriptorPool.generated_pool.\"\n    \"lookup(\\\"$full_name$\\\").enummodule\\n\",\n    \"full_name\", en->full_name());\n}\n\nint GeneratePackageModules(\n    std::string package_name,\n    google::protobuf::io::Printer* printer) {\n  int levels = 0;\n  while (!package_name.empty()) {\n    size_t dot_index = package_name.find(\".\");\n    string component;\n    if (dot_index == string::npos) {\n      component = package_name;\n      package_name = \"\";\n    } else {\n      component = package_name.substr(0, dot_index);\n      package_name = package_name.substr(dot_index + 1);\n    }\n    component = PackageToModule(component);\n    printer->Print(\n      \"module $name$\\n\",\n      \"name\", component);\n    printer->Indent();\n    levels++;\n  }\n  return levels;\n}\n\nvoid EndPackageModules(\n    int levels,\n    google::protobuf::io::Printer* printer) {\n  while (levels > 0) {\n    levels--;\n    printer->Outdent();\n    printer->Print(\n      \"end\\n\");\n  }\n}\n\nbool UsesTypeFromFile(const Descriptor* message, const FileDescriptor* file,\n                      string* error) {\n  for (int i = 0; i < message->field_count(); i++) {\n    const FieldDescriptor* field = message->field(i);\n    if ((field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&\n         field->message_type()->file() == file) ||\n        (field->type() == FieldDescriptor::TYPE_ENUM &&\n         field->enum_type()->file() == file)) {\n      *error = \"proto3 message field \" + field->full_name() + \" in file \" +\n               file->name() + \" has a dependency on a type from proto2 file \" +\n               file->name() +\n               \".  Ruby doesn't support proto2 yet, so we must fail.\";\n      return true;\n    }\n  }\n\n  for (int i = 0; i < message->nested_type_count(); i++) {\n    if (UsesTypeFromFile(message->nested_type(i), file, error)) {\n      return true;\n    }\n  }\n\n  return false;\n}\n\n// Ruby doesn't currently support proto2.  This causes a failure even for proto3\n// files that import proto2.  But in some cases, the proto2 file is only being\n// imported to extend another proto2 message.  The prime example is declaring\n// custom options by extending FileOptions/FieldOptions/etc.\n//\n// If the proto3 messages don't have any proto2 submessages, it is safe to omit\n// the dependency completely.  Users won't be able to use any proto2 extensions,\n// but they already couldn't because proto2 messages aren't supported.\n//\n// If/when we add proto2 support, we should remove this.\nbool MaybeEmitDependency(const FileDescriptor* import,\n                         const FileDescriptor* from,\n                         io::Printer* printer,\n                         string* error) {\n  if (import->syntax() == FileDescriptor::SYNTAX_PROTO2) {\n    for (int i = 0; i < from->message_type_count(); i++) {\n      if (UsesTypeFromFile(from->message_type(i), import, error)) {\n        // Error text was already set by UsesTypeFromFile().\n        return false;\n      }\n    }\n\n    // Ok to omit this proto2 dependency -- so we won't print anything.\n    GOOGLE_LOG(WARNING) << \"Omitting proto2 dependency '\" << import->name()\n                        << \"' from proto3 output file '\"\n                        << GetOutputFilename(from->name())\n                        << \"' because we don't support proto2 and no proto2 \"\n                           \"types from that file are being used.\";\n    return true;\n  } else {\n    printer->Print(\n      \"require '$name$'\\n\", \"name\", GetRequireName(import->name()));\n    return true;\n  }\n}\n\nbool GenerateFile(const FileDescriptor* file, io::Printer* printer,\n                  string* error) {\n  printer->Print(\n    \"# Generated by the protocol buffer compiler.  DO NOT EDIT!\\n\"\n    \"# source: $filename$\\n\"\n    \"\\n\",\n    \"filename\", file->name());\n\n  printer->Print(\n    \"require 'google/protobuf'\\n\\n\");\n\n  for (int i = 0; i < file->dependency_count(); i++) {\n    if (!MaybeEmitDependency(file->dependency(i), file, printer, error)) {\n      return false;\n    }\n  }\n\n  printer->Print(\n    \"Google::Protobuf::DescriptorPool.generated_pool.build do\\n\");\n  printer->Indent();\n  for (int i = 0; i < file->message_type_count(); i++) {\n    GenerateMessage(file->message_type(i), printer);\n  }\n  for (int i = 0; i < file->enum_type_count(); i++) {\n    GenerateEnum(file->enum_type(i), printer);\n  }\n  printer->Outdent();\n  printer->Print(\n    \"end\\n\\n\");\n\n  int levels = GeneratePackageModules(file->package(), printer);\n  for (int i = 0; i < file->message_type_count(); i++) {\n    GenerateMessageAssignment(\"\", file->message_type(i), printer);\n  }\n  for (int i = 0; i < file->enum_type_count(); i++) {\n    GenerateEnumAssignment(\"\", file->enum_type(i), printer);\n  }\n  EndPackageModules(levels, printer);\n  return true;\n}\n\nbool Generator::Generate(\n    const FileDescriptor* file,\n    const string& parameter,\n    GeneratorContext* generator_context,\n    string* error) const {\n\n  if (file->syntax() != FileDescriptor::SYNTAX_PROTO3) {\n    *error =\n        \"Can only generate Ruby code for proto3 .proto files.\\n\"\n        \"Please add 'syntax = \\\"proto3\\\";' to the top of your .proto file.\\n\";\n    return false;\n  }\n\n  scoped_ptr<io::ZeroCopyOutputStream> output(\n      generator_context->Open(GetOutputFilename(file->name())));\n  io::Printer printer(output.get(), '$');\n\n  return GenerateFile(file, &printer, error);\n}\n\n}  // namespace ruby\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/ruby/ruby_generator.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_RUBY_GENERATOR_H__\n#define GOOGLE_PROTOBUF_COMPILER_RUBY_GENERATOR_H__\n\n#include <string>\n\n#include <google/protobuf/compiler/code_generator.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace ruby {\n\nclass LIBPROTOC_EXPORT Generator\n    : public google::protobuf::compiler::CodeGenerator {\n  virtual bool Generate(\n      const FileDescriptor* file,\n      const string& parameter,\n      GeneratorContext* generator_context,\n      string* error) const;\n};\n\n}  // namespace ruby\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMPILER_RUBY_GENERATOR_H__\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2014 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <memory>\n\n#include <google/protobuf/compiler/ruby/ruby_generator.h>\n#include <google/protobuf/compiler/command_line_interface.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/io/printer.h>\n\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n#include <google/protobuf/testing/file.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\nnamespace ruby {\nnamespace {\n\nstring FindRubyTestDir() {\n  return TestSourceDir() + \"/google/protobuf/compiler/ruby\";\n}\n\n// This test is a simple golden-file test over the output of the Ruby code\n// generator. When we make changes to the Ruby extension and alter the Ruby code\n// generator to use those changes, we should (i) manually test the output of the\n// code generator with the extension, and (ii) update the golden output above.\n// Some day, we may integrate build systems between protoc and the language\n// extensions to the point where we can do this test in a more automated way.\n\nTEST(RubyGeneratorTest, GeneratorTest) {\n  string ruby_tests = FindRubyTestDir();\n\n  google::protobuf::compiler::CommandLineInterface cli;\n  cli.SetInputsAreProtoPathRelative(true);\n\n  ruby::Generator ruby_generator;\n  cli.RegisterGenerator(\"--ruby_out\", &ruby_generator, \"\");\n\n  // Copy generated_code.proto to the temporary test directory.\n  string test_input;\n  GOOGLE_CHECK_OK(File::GetContents(\n      ruby_tests + \"/ruby_generated_code.proto\",\n      &test_input,\n      true));\n  GOOGLE_CHECK_OK(File::SetContents(\n      TestTempDir() + \"/ruby_generated_code.proto\",\n      test_input,\n      true));\n\n  // Invoke the proto compiler (we will be inside TestTempDir() at this point).\n  string ruby_out = \"--ruby_out=\" + TestTempDir();\n  string proto_path = \"--proto_path=\" + TestTempDir();\n  const char* argv[] = {\n    \"protoc\",\n    ruby_out.c_str(),\n    proto_path.c_str(),\n    \"ruby_generated_code.proto\",\n  };\n\n  EXPECT_EQ(0, cli.Run(4, argv));\n\n  // Load the generated output and compare to the expected result.\n  string output;\n  GOOGLE_CHECK_OK(File::GetContents(\n      TestTempDir() + \"/ruby_generated_code_pb.rb\",\n      &output,\n      true));\n  string expected_output;\n  GOOGLE_CHECK_OK(File::GetContents(\n      ruby_tests + \"/ruby_generated_code_pb.rb\",\n      &expected_output,\n      true));\n  EXPECT_EQ(expected_output, output);\n}\n\n}  // namespace\n}  // namespace ruby\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/subprocess.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n\n#include <google/protobuf/compiler/subprocess.h>\n\n#include <algorithm>\n#include <iostream>\n\n#ifndef _WIN32\n#include <errno.h>\n#include <sys/select.h>\n#include <sys/wait.h>\n#include <signal.h>\n#endif\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/stubs/substitute.h>\n\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\n\n#ifdef _WIN32\n\nstatic void CloseHandleOrDie(HANDLE handle) {\n  if (!CloseHandle(handle)) {\n    GOOGLE_LOG(FATAL) << \"CloseHandle: \"\n                      << Subprocess::Win32ErrorMessage(GetLastError());\n  }\n}\n\nSubprocess::Subprocess()\n    : process_start_error_(ERROR_SUCCESS),\n      child_handle_(NULL), child_stdin_(NULL), child_stdout_(NULL) {}\n\nSubprocess::~Subprocess() {\n  if (child_stdin_ != NULL) {\n    CloseHandleOrDie(child_stdin_);\n  }\n  if (child_stdout_ != NULL) {\n    CloseHandleOrDie(child_stdout_);\n  }\n}\n\nvoid Subprocess::Start(const string& program, SearchMode search_mode) {\n  // Create the pipes.\n  HANDLE stdin_pipe_read;\n  HANDLE stdin_pipe_write;\n  HANDLE stdout_pipe_read;\n  HANDLE stdout_pipe_write;\n\n  if (!CreatePipe(&stdin_pipe_read, &stdin_pipe_write, NULL, 0)) {\n    GOOGLE_LOG(FATAL) << \"CreatePipe: \" << Win32ErrorMessage(GetLastError());\n  }\n  if (!CreatePipe(&stdout_pipe_read, &stdout_pipe_write, NULL, 0)) {\n    GOOGLE_LOG(FATAL) << \"CreatePipe: \" << Win32ErrorMessage(GetLastError());\n  }\n\n  // Make child side of the pipes inheritable.\n  if (!SetHandleInformation(stdin_pipe_read,\n                            HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) {\n    GOOGLE_LOG(FATAL) << \"SetHandleInformation: \"\n                      << Win32ErrorMessage(GetLastError());\n  }\n  if (!SetHandleInformation(stdout_pipe_write,\n                            HANDLE_FLAG_INHERIT, HANDLE_FLAG_INHERIT)) {\n    GOOGLE_LOG(FATAL) << \"SetHandleInformation: \"\n                      << Win32ErrorMessage(GetLastError());\n  }\n\n  // Setup STARTUPINFO to redirect handles.\n  STARTUPINFOA startup_info;\n  ZeroMemory(&startup_info, sizeof(startup_info));\n  startup_info.cb = sizeof(startup_info);\n  startup_info.dwFlags = STARTF_USESTDHANDLES;\n  startup_info.hStdInput = stdin_pipe_read;\n  startup_info.hStdOutput = stdout_pipe_write;\n  startup_info.hStdError = GetStdHandle(STD_ERROR_HANDLE);\n\n  if (startup_info.hStdError == INVALID_HANDLE_VALUE) {\n    GOOGLE_LOG(FATAL) << \"GetStdHandle: \"\n                      << Win32ErrorMessage(GetLastError());\n  }\n\n  // CreateProcess() mutates its second parameter.  WTF?\n  char* name_copy = strdup(program.c_str());\n\n  // Create the process.\n  PROCESS_INFORMATION process_info;\n\n  if (CreateProcessA((search_mode == SEARCH_PATH) ? NULL : program.c_str(),\n                     (search_mode == SEARCH_PATH) ? name_copy : NULL,\n                     NULL,  // process security attributes\n                     NULL,  // thread security attributes\n                     TRUE,  // inherit handles?\n                     0,     // obscure creation flags\n                     NULL,  // environment (inherit from parent)\n                     NULL,  // current directory (inherit from parent)\n                     &startup_info,\n                     &process_info)) {\n    child_handle_ = process_info.hProcess;\n    CloseHandleOrDie(process_info.hThread);\n    child_stdin_ = stdin_pipe_write;\n    child_stdout_ = stdout_pipe_read;\n  } else {\n    process_start_error_ = GetLastError();\n    CloseHandleOrDie(stdin_pipe_write);\n    CloseHandleOrDie(stdout_pipe_read);\n  }\n\n  CloseHandleOrDie(stdin_pipe_read);\n  CloseHandleOrDie(stdout_pipe_write);\n  free(name_copy);\n}\n\nbool Subprocess::Communicate(const Message& input, Message* output,\n                             string* error) {\n  if (process_start_error_ != ERROR_SUCCESS) {\n    *error = Win32ErrorMessage(process_start_error_);\n    return false;\n  }\n\n  GOOGLE_CHECK(child_handle_ != NULL) << \"Must call Start() first.\";\n\n  string input_data = input.SerializeAsString();\n  string output_data;\n\n  int input_pos = 0;\n\n  while (child_stdout_ != NULL) {\n    HANDLE handles[2];\n    int handle_count = 0;\n\n    if (child_stdin_ != NULL) {\n      handles[handle_count++] = child_stdin_;\n    }\n    if (child_stdout_ != NULL) {\n      handles[handle_count++] = child_stdout_;\n    }\n\n    DWORD wait_result =\n        WaitForMultipleObjects(handle_count, handles, FALSE, INFINITE);\n\n    HANDLE signaled_handle = NULL;\n    if (wait_result >= WAIT_OBJECT_0 &&\n        wait_result < WAIT_OBJECT_0 + handle_count) {\n      signaled_handle = handles[wait_result - WAIT_OBJECT_0];\n    } else if (wait_result == WAIT_FAILED) {\n      GOOGLE_LOG(FATAL) << \"WaitForMultipleObjects: \"\n                        << Win32ErrorMessage(GetLastError());\n    } else {\n      GOOGLE_LOG(FATAL) << \"WaitForMultipleObjects: Unexpected return code: \"\n                        << wait_result;\n    }\n\n    if (signaled_handle == child_stdin_) {\n      DWORD n;\n      if (!WriteFile(child_stdin_,\n                     input_data.data() + input_pos,\n                     input_data.size() - input_pos,\n                     &n, NULL)) {\n        // Child closed pipe.  Presumably it will report an error later.\n        // Pretend we're done for now.\n        input_pos = input_data.size();\n      } else {\n        input_pos += n;\n      }\n\n      if (input_pos == input_data.size()) {\n        // We're done writing.  Close.\n        CloseHandleOrDie(child_stdin_);\n        child_stdin_ = NULL;\n      }\n    } else if (signaled_handle == child_stdout_) {\n      char buffer[4096];\n      DWORD n;\n\n      if (!ReadFile(child_stdout_, buffer, sizeof(buffer), &n, NULL)) {\n        // We're done reading.  Close.\n        CloseHandleOrDie(child_stdout_);\n        child_stdout_ = NULL;\n      } else {\n        output_data.append(buffer, n);\n      }\n    }\n  }\n\n  if (child_stdin_ != NULL) {\n    // Child did not finish reading input before it closed the output.\n    // Presumably it exited with an error.\n    CloseHandleOrDie(child_stdin_);\n    child_stdin_ = NULL;\n  }\n\n  DWORD wait_result = WaitForSingleObject(child_handle_, INFINITE);\n\n  if (wait_result == WAIT_FAILED) {\n    GOOGLE_LOG(FATAL) << \"WaitForSingleObject: \"\n                      << Win32ErrorMessage(GetLastError());\n  } else if (wait_result != WAIT_OBJECT_0) {\n    GOOGLE_LOG(FATAL) << \"WaitForSingleObject: Unexpected return code: \"\n                      << wait_result;\n  }\n\n  DWORD exit_code;\n  if (!GetExitCodeProcess(child_handle_, &exit_code)) {\n    GOOGLE_LOG(FATAL) << \"GetExitCodeProcess: \"\n                      << Win32ErrorMessage(GetLastError());\n  }\n\n  CloseHandleOrDie(child_handle_);\n  child_handle_ = NULL;\n\n  if (exit_code != 0) {\n    *error = strings::Substitute(\n        \"Plugin failed with status code $0.\", exit_code);\n    return false;\n  }\n\n  if (!output->ParseFromString(output_data)) {\n    *error = \"Plugin output is unparseable: \" + CEscape(output_data);\n    return false;\n  }\n\n  return true;\n}\n\nstring Subprocess::Win32ErrorMessage(DWORD error_code) {\n  char* message;\n\n  // WTF?\n  FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |\n                FORMAT_MESSAGE_FROM_SYSTEM |\n                FORMAT_MESSAGE_IGNORE_INSERTS,\n                NULL, error_code, 0,\n                (LPTSTR)&message,  // NOT A BUG!\n                0, NULL);\n\n  string result = message;\n  LocalFree(message);\n  return result;\n}\n\n// ===================================================================\n\n#else  // _WIN32\n\nSubprocess::Subprocess()\n    : child_pid_(-1), child_stdin_(-1), child_stdout_(-1) {}\n\nSubprocess::~Subprocess() {\n  if (child_stdin_ != -1) {\n    close(child_stdin_);\n  }\n  if (child_stdout_ != -1) {\n    close(child_stdout_);\n  }\n}\n\nvoid Subprocess::Start(const string& program, SearchMode search_mode) {\n  // Note that we assume that there are no other threads, thus we don't have to\n  // do crazy stuff like using socket pairs or avoiding libc locks.\n\n  // [0] is read end, [1] is write end.\n  int stdin_pipe[2];\n  int stdout_pipe[2];\n\n  GOOGLE_CHECK(pipe(stdin_pipe) != -1);\n  GOOGLE_CHECK(pipe(stdout_pipe) != -1);\n\n  char* argv[2] = { strdup(program.c_str()), NULL };\n\n  child_pid_ = fork();\n  if (child_pid_ == -1) {\n    GOOGLE_LOG(FATAL) << \"fork: \" << strerror(errno);\n  } else if (child_pid_ == 0) {\n    // We are the child.\n    dup2(stdin_pipe[0], STDIN_FILENO);\n    dup2(stdout_pipe[1], STDOUT_FILENO);\n\n    close(stdin_pipe[0]);\n    close(stdin_pipe[1]);\n    close(stdout_pipe[0]);\n    close(stdout_pipe[1]);\n\n    switch (search_mode) {\n      case SEARCH_PATH:\n        execvp(argv[0], argv);\n        break;\n      case EXACT_NAME:\n        execv(argv[0], argv);\n        break;\n    }\n\n    // Write directly to STDERR_FILENO to avoid stdio code paths that may do\n    // stuff that is unsafe here.\n    int ignored;\n    ignored = write(STDERR_FILENO, argv[0], strlen(argv[0]));\n    const char* message = \": program not found or is not executable\\n\";\n    ignored = write(STDERR_FILENO, message, strlen(message));\n    (void) ignored;\n\n    // Must use _exit() rather than exit() to avoid flushing output buffers\n    // that will also be flushed by the parent.\n    _exit(1);\n  } else {\n    free(argv[0]);\n\n    close(stdin_pipe[0]);\n    close(stdout_pipe[1]);\n\n    child_stdin_ = stdin_pipe[1];\n    child_stdout_ = stdout_pipe[0];\n  }\n}\n\nbool Subprocess::Communicate(const Message& input, Message* output,\n                             string* error) {\n\n  GOOGLE_CHECK_NE(child_stdin_, -1) << \"Must call Start() first.\";\n\n  // The \"sighandler_t\" typedef is GNU-specific, so define our own.\n  typedef void SignalHandler(int);\n\n  // Make sure SIGPIPE is disabled so that if the child dies it doesn't kill us.\n  SignalHandler* old_pipe_handler = signal(SIGPIPE, SIG_IGN);\n\n  string input_data = input.SerializeAsString();\n  string output_data;\n\n  int input_pos = 0;\n  int max_fd = std::max(child_stdin_, child_stdout_);\n\n  while (child_stdout_ != -1) {\n    fd_set read_fds;\n    fd_set write_fds;\n    FD_ZERO(&read_fds);\n    FD_ZERO(&write_fds);\n    if (child_stdout_ != -1) {\n      FD_SET(child_stdout_, &read_fds);\n    }\n    if (child_stdin_ != -1) {\n      FD_SET(child_stdin_, &write_fds);\n    }\n\n    if (select(max_fd + 1, &read_fds, &write_fds, NULL, NULL) < 0) {\n      if (errno == EINTR) {\n        // Interrupted by signal.  Try again.\n        continue;\n      } else {\n        GOOGLE_LOG(FATAL) << \"select: \" << strerror(errno);\n      }\n    }\n\n    if (child_stdin_ != -1 && FD_ISSET(child_stdin_, &write_fds)) {\n      int n = write(child_stdin_, input_data.data() + input_pos,\n                                  input_data.size() - input_pos);\n      if (n < 0) {\n        // Child closed pipe.  Presumably it will report an error later.\n        // Pretend we're done for now.\n        input_pos = input_data.size();\n      } else {\n        input_pos += n;\n      }\n\n      if (input_pos == input_data.size()) {\n        // We're done writing.  Close.\n        close(child_stdin_);\n        child_stdin_ = -1;\n      }\n    }\n\n    if (child_stdout_ != -1 && FD_ISSET(child_stdout_, &read_fds)) {\n      char buffer[4096];\n      int n = read(child_stdout_, buffer, sizeof(buffer));\n\n      if (n > 0) {\n        output_data.append(buffer, n);\n      } else {\n        // We're done reading.  Close.\n        close(child_stdout_);\n        child_stdout_ = -1;\n      }\n    }\n  }\n\n  if (child_stdin_ != -1) {\n    // Child did not finish reading input before it closed the output.\n    // Presumably it exited with an error.\n    close(child_stdin_);\n    child_stdin_ = -1;\n  }\n\n  int status;\n  while (waitpid(child_pid_, &status, 0) == -1) {\n    if (errno != EINTR) {\n      GOOGLE_LOG(FATAL) << \"waitpid: \" << strerror(errno);\n    }\n  }\n\n  // Restore SIGPIPE handling.\n  signal(SIGPIPE, old_pipe_handler);\n\n  if (WIFEXITED(status)) {\n    if (WEXITSTATUS(status) != 0) {\n      int error_code = WEXITSTATUS(status);\n      *error = strings::Substitute(\n          \"Plugin failed with status code $0.\", error_code);\n      return false;\n    }\n  } else if (WIFSIGNALED(status)) {\n    int signal = WTERMSIG(status);\n    *error = strings::Substitute(\n        \"Plugin killed by signal $0.\", signal);\n    return false;\n  } else {\n    *error = \"Neither WEXITSTATUS nor WTERMSIG is true?\";\n    return false;\n  }\n\n  if (!output->ParseFromString(output_data)) {\n    *error = \"Plugin output is unparseable: \" + CEscape(output_data);\n    return false;\n  }\n\n  return true;\n}\n\n#endif  // !_WIN32\n\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/subprocess.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n\n#ifndef GOOGLE_PROTOBUF_COMPILER_SUBPROCESS_H__\n#define GOOGLE_PROTOBUF_COMPILER_SUBPROCESS_H__\n\n#ifdef _WIN32\n#define WIN32_LEAN_AND_MEAN   // right...\n#include <windows.h>\n#else  // _WIN32\n#include <sys/types.h>\n#include <unistd.h>\n#endif  // !_WIN32\n#include <google/protobuf/stubs/common.h>\n\n#include <string>\n\n\nnamespace google {\nnamespace protobuf {\n\nclass Message;\n\nnamespace compiler {\n\n// Utility class for launching sub-processes.\nclass LIBPROTOC_EXPORT Subprocess {\n public:\n  Subprocess();\n  ~Subprocess();\n\n  enum SearchMode {\n    SEARCH_PATH,   // Use PATH environment variable.\n    EXACT_NAME     // Program is an exact file name; don't use the PATH.\n  };\n\n  // Start the subprocess.  Currently we don't provide a way to specify\n  // arguments as protoc plugins don't have any.\n  void Start(const string& program, SearchMode search_mode);\n\n  // Serialize the input message and pipe it to the subprocess's stdin, then\n  // close the pipe.  Meanwhile, read from the subprocess's stdout and parse\n  // the data into *output.  All this is done carefully to avoid deadlocks.\n  // Returns true if successful.  On any sort of error, returns false and sets\n  // *error to a description of the problem.\n  bool Communicate(const Message& input, Message* output, string* error);\n\n#ifdef _WIN32\n  // Given an error code, returns a human-readable error message.  This is\n  // defined here so that CommandLineInterface can share it.\n  static string Win32ErrorMessage(DWORD error_code);\n#endif\n\n private:\n#ifdef _WIN32\n  DWORD process_start_error_;\n  HANDLE child_handle_;\n\n  // The file handles for our end of the child's pipes.  We close each and\n  // set it to NULL when no longer needed.\n  HANDLE child_stdin_;\n  HANDLE child_stdout_;\n\n#else  // _WIN32\n  pid_t child_pid_;\n\n  // The file descriptors for our end of the child's pipes.  We close each and\n  // set it to -1 when no longer needed.\n  int child_stdin_;\n  int child_stdout_;\n\n#endif  // !_WIN32\n};\n\n}  // namespace compiler\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_COMPILER_SUBPROCESS_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/test_plugin.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//\n// This is a dummy code generator plugin used by\n// command_line_interface_unittest.\n\n#include <string>\n#include <stdlib.h>\n#include <google/protobuf/compiler/plugin.h>\n#include <google/protobuf/compiler/mock_code_generator.h>\n#include <google/protobuf/stubs/strutil.h>\n\nint main(int argc, char* argv[]) {\n#ifdef _MSC_VER\n  // Don't print a silly message or stick a modal dialog box in my face,\n  // please.\n  _set_abort_behavior(0, ~0);\n#endif  // !_MSC_VER\n\n  google::protobuf::compiler::MockCodeGenerator generator(\"test_plugin\");\n  return google::protobuf::compiler::PluginMain(argc, argv, &generator);\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/zip_output_unittest.sh",
    "content": "#!/bin/sh\n#\n# Protocol Buffers - Google's data interchange format\n# Copyright 2009 Google Inc.  All rights reserved.\n# https://developers.google.com/protocol-buffers/\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n# Author: kenton@google.com (Kenton Varda)\n#\n# Test protoc's zip output mode.\n\nfail() {\n  echo \"$@\" >&2\n  exit 1\n}\n\nTEST_TMPDIR=.\nPROTOC=./protoc\n\necho '\n  syntax = \"proto2\";\n  option java_multiple_files = true;\n  option java_package = \"test.jar\";\n  option java_outer_classname = \"Outer\";\n  message Foo {}\n  message Bar {}\n' > $TEST_TMPDIR/testzip.proto\n\n$PROTOC \\\n    --cpp_out=$TEST_TMPDIR/testzip.zip --python_out=$TEST_TMPDIR/testzip.zip \\\n    --java_out=$TEST_TMPDIR/testzip.jar -I$TEST_TMPDIR testzip.proto \\\n    || fail 'protoc failed.'\n\necho \"Testing output to zip...\"\nif unzip -h > /dev/null; then\n  unzip -t $TEST_TMPDIR/testzip.zip > $TEST_TMPDIR/testzip.list || fail 'unzip failed.'\n\n  grep 'testing: testzip\\.pb\\.cc *OK$' $TEST_TMPDIR/testzip.list > /dev/null \\\n    || fail 'testzip.pb.cc not found in output zip.'\n  grep 'testing: testzip\\.pb\\.h *OK$' $TEST_TMPDIR/testzip.list > /dev/null \\\n    || fail 'testzip.pb.h not found in output zip.'\n  grep 'testing: testzip_pb2\\.py *OK$' $TEST_TMPDIR/testzip.list > /dev/null \\\n    || fail 'testzip_pb2.py not found in output zip.'\n  grep -i 'manifest' $TEST_TMPDIR/testzip.list > /dev/null \\\n    && fail 'Zip file contained manifest.'\nelse\n  echo \"Warning:  'unzip' command not available.  Skipping test.\"\nfi\n\necho \"Testing output to jar...\"\nif jar c $TEST_TMPDIR/testzip.proto > /dev/null; then\n  jar tf $TEST_TMPDIR/testzip.jar > $TEST_TMPDIR/testzip.list || fail 'jar failed.'\n\n  grep '^test/jar/Foo\\.java$' $TEST_TMPDIR/testzip.list > /dev/null \\\n    || fail 'Foo.java not found in output jar.'\n  grep '^test/jar/Bar\\.java$' $TEST_TMPDIR/testzip.list > /dev/null \\\n    || fail 'Bar.java not found in output jar.'\n  grep '^test/jar/Outer\\.java$' $TEST_TMPDIR/testzip.list > /dev/null \\\n    || fail 'Outer.java not found in output jar.'\n  grep '^META-INF/MANIFEST\\.MF$' $TEST_TMPDIR/testzip.list > /dev/null \\\n    || fail 'Manifest not found in output jar.'\nelse\n  echo \"Warning:  'jar' command not available.  Skipping test.\"\nfi\n\necho PASS\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/zip_writer.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: ambrose@google.com (Ambrose Feinstein),\n//         kenton@google.com (Kenton Varda)\n//\n// Based on http://www.pkware.com/documents/casestudies/APPNOTE.TXT\n\n#include <google/protobuf/compiler/zip_writer.h>\n#include <google/protobuf/io/coded_stream.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\n\nstatic const uint32 kCRC32Table[256] = {\n  0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,\n  0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,\n  0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,\n  0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,\n  0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,\n  0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,\n  0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,\n  0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,\n  0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,\n  0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,\n  0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,\n  0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,\n  0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,\n  0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,\n  0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,\n  0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,\n  0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,\n  0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,\n  0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,\n  0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,\n  0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,\n  0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,\n  0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,\n  0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,\n  0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,\n  0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,\n  0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,\n  0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,\n  0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,\n  0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,\n  0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,\n  0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,\n  0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,\n  0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,\n  0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,\n  0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,\n  0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,\n  0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,\n  0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,\n  0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,\n  0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,\n  0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,\n  0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d\n};\n\nstatic uint32 ComputeCRC32(const string &buf) {\n  uint32 x = ~0U;\n  for (int i = 0; i < buf.size(); ++i) {\n    unsigned char c = buf[i];\n    x = kCRC32Table[(x ^ c) & 0xff] ^ (x >> 8);\n  }\n  return ~x;\n}\n\nstatic void WriteShort(io::CodedOutputStream *out, uint16 val) {\n  uint8 p[2];\n  p[0] = static_cast<uint8>(val);\n  p[1] = static_cast<uint8>(val >> 8);\n  out->WriteRaw(p, 2);\n}\n\nZipWriter::ZipWriter(io::ZeroCopyOutputStream* raw_output)\n  : raw_output_(raw_output) {}\nZipWriter::~ZipWriter() {}\n\nbool ZipWriter::Write(const string& filename, const string& contents) {\n  FileInfo info;\n\n  info.name = filename;\n  uint16 filename_size = filename.size();\n  info.offset = raw_output_->ByteCount();\n  info.size = contents.size();\n  info.crc32 = ComputeCRC32(contents);\n\n  files_.push_back(info);\n\n  // write file header\n  io::CodedOutputStream output(raw_output_);\n  output.WriteLittleEndian32(0x04034b50);  // magic\n  WriteShort(&output, 10);  // version needed to extract\n  WriteShort(&output, 0);  // flags\n  WriteShort(&output, 0);  // compression method: stored\n  WriteShort(&output, 0);  // last modified time\n  WriteShort(&output, 0);  // last modified date\n  output.WriteLittleEndian32(info.crc32);  // crc-32\n  output.WriteLittleEndian32(info.size);  // compressed size\n  output.WriteLittleEndian32(info.size);  // uncompressed size\n  WriteShort(&output, filename_size);  // file name length\n  WriteShort(&output, 0);   // extra field length\n  output.WriteString(filename);  // file name\n  output.WriteString(contents);  // file data\n\n  return !output.HadError();\n}\n\nbool ZipWriter::WriteDirectory() {\n  uint16 num_entries = files_.size();\n  uint32 dir_ofs = raw_output_->ByteCount();\n\n  // write central directory\n  io::CodedOutputStream output(raw_output_);\n  for (int i = 0; i < num_entries; ++i) {\n    const string &filename = files_[i].name;\n    uint16 filename_size = filename.size();\n    uint32 crc32 = files_[i].crc32;\n    uint32 size = files_[i].size;\n    uint32 offset = files_[i].offset;\n\n    output.WriteLittleEndian32(0x02014b50);  // magic\n    WriteShort(&output, 10);  // version made by\n    WriteShort(&output, 10);  // version needed to extract\n    WriteShort(&output, 0);  // flags\n    WriteShort(&output, 0);  // compression method: stored\n    WriteShort(&output, 0);  // last modified time\n    WriteShort(&output, 0);  // last modified date\n    output.WriteLittleEndian32(crc32);  // crc-32\n    output.WriteLittleEndian32(size);  // compressed size\n    output.WriteLittleEndian32(size);  // uncompressed size\n    WriteShort(&output, filename_size);  // file name length\n    WriteShort(&output, 0);   // extra field length\n    WriteShort(&output, 0);   // file comment length\n    WriteShort(&output, 0);   // starting disk number\n    WriteShort(&output, 0);   // internal file attributes\n    output.WriteLittleEndian32(0);  // external file attributes\n    output.WriteLittleEndian32(offset);  // local header offset\n    output.WriteString(filename);  // file name\n  }\n  uint32 dir_len = output.ByteCount();\n\n  // write end of central directory marker\n  output.WriteLittleEndian32(0x06054b50);  // magic\n  WriteShort(&output, 0);  // disk number\n  WriteShort(&output, 0);  // disk with start of central directory\n  WriteShort(&output, num_entries);  // central directory entries (this disk)\n  WriteShort(&output, num_entries);  // central directory entries (total)\n  output.WriteLittleEndian32(dir_len);  // central directory byte size\n  output.WriteLittleEndian32(dir_ofs);  // central directory offset\n  WriteShort(&output, 0);   // comment length\n\n  return output.HadError();\n}\n\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/compiler/zip_writer.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n\n#include <vector>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace compiler {\n\nclass ZipWriter {\n public:\n  ZipWriter(io::ZeroCopyOutputStream* raw_output);\n  ~ZipWriter();\n\n  bool Write(const string& filename, const string& contents);\n  bool WriteDirectory();\n\n private:\n  struct FileInfo {\n    string name;\n    uint32 offset;\n    uint32 size;\n    uint32 crc32;\n  };\n\n  io::ZeroCopyOutputStream* raw_output_;\n  vector<FileInfo> files_;\n};\n\n}  // namespace compiler\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/descriptor.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/stubs/hash.h>\n#include <map>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <set>\n#include <string>\n#include <vector>\n#include <algorithm>\n#include <limits>\n\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor_database.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/dynamic_message.h>\n#include <google/protobuf/generated_message_util.h>\n#include <google/protobuf/text_format.h>\n#include <google/protobuf/unknown_field_set.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/io/strtod.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/tokenizer.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/mutex.h>\n#include <google/protobuf/stubs/once.h>\n#include <google/protobuf/stubs/stringprintf.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n#include <google/protobuf/stubs/map_util.h>\n#include <google/protobuf/stubs/stl_util.h>\n\n#undef PACKAGE  // autoheader #defines this.  :(\n\nnamespace google {\nnamespace protobuf {\n\nconst FieldDescriptor::CppType\nFieldDescriptor::kTypeToCppTypeMap[MAX_TYPE + 1] = {\n  static_cast<CppType>(0),  // 0 is reserved for errors\n\n  CPPTYPE_DOUBLE,   // TYPE_DOUBLE\n  CPPTYPE_FLOAT,    // TYPE_FLOAT\n  CPPTYPE_INT64,    // TYPE_INT64\n  CPPTYPE_UINT64,   // TYPE_UINT64\n  CPPTYPE_INT32,    // TYPE_INT32\n  CPPTYPE_UINT64,   // TYPE_FIXED64\n  CPPTYPE_UINT32,   // TYPE_FIXED32\n  CPPTYPE_BOOL,     // TYPE_BOOL\n  CPPTYPE_STRING,   // TYPE_STRING\n  CPPTYPE_MESSAGE,  // TYPE_GROUP\n  CPPTYPE_MESSAGE,  // TYPE_MESSAGE\n  CPPTYPE_STRING,   // TYPE_BYTES\n  CPPTYPE_UINT32,   // TYPE_UINT32\n  CPPTYPE_ENUM,     // TYPE_ENUM\n  CPPTYPE_INT32,    // TYPE_SFIXED32\n  CPPTYPE_INT64,    // TYPE_SFIXED64\n  CPPTYPE_INT32,    // TYPE_SINT32\n  CPPTYPE_INT64,    // TYPE_SINT64\n};\n\nconst char * const FieldDescriptor::kTypeToName[MAX_TYPE + 1] = {\n  \"ERROR\",     // 0 is reserved for errors\n\n  \"double\",    // TYPE_DOUBLE\n  \"float\",     // TYPE_FLOAT\n  \"int64\",     // TYPE_INT64\n  \"uint64\",    // TYPE_UINT64\n  \"int32\",     // TYPE_INT32\n  \"fixed64\",   // TYPE_FIXED64\n  \"fixed32\",   // TYPE_FIXED32\n  \"bool\",      // TYPE_BOOL\n  \"string\",    // TYPE_STRING\n  \"group\",     // TYPE_GROUP\n  \"message\",   // TYPE_MESSAGE\n  \"bytes\",     // TYPE_BYTES\n  \"uint32\",    // TYPE_UINT32\n  \"enum\",      // TYPE_ENUM\n  \"sfixed32\",  // TYPE_SFIXED32\n  \"sfixed64\",  // TYPE_SFIXED64\n  \"sint32\",    // TYPE_SINT32\n  \"sint64\",    // TYPE_SINT64\n};\n\nconst char * const FieldDescriptor::kCppTypeToName[MAX_CPPTYPE + 1] = {\n  \"ERROR\",     // 0 is reserved for errors\n\n  \"int32\",     // CPPTYPE_INT32\n  \"int64\",     // CPPTYPE_INT64\n  \"uint32\",    // CPPTYPE_UINT32\n  \"uint64\",    // CPPTYPE_UINT64\n  \"double\",    // CPPTYPE_DOUBLE\n  \"float\",     // CPPTYPE_FLOAT\n  \"bool\",      // CPPTYPE_BOOL\n  \"enum\",      // CPPTYPE_ENUM\n  \"string\",    // CPPTYPE_STRING\n  \"message\",   // CPPTYPE_MESSAGE\n};\n\nconst char * const FieldDescriptor::kLabelToName[MAX_LABEL + 1] = {\n  \"ERROR\",     // 0 is reserved for errors\n\n  \"optional\",  // LABEL_OPTIONAL\n  \"required\",  // LABEL_REQUIRED\n  \"repeated\",  // LABEL_REPEATED\n};\n\nconst char* FileDescriptor::SyntaxName(FileDescriptor::Syntax syntax) {\n  switch (syntax) {\n    case SYNTAX_PROTO2:\n      return \"proto2\";\n    case SYNTAX_PROTO3:\n      return \"proto3\";\n    case SYNTAX_UNKNOWN:\n      return \"unknown\";\n  }\n  GOOGLE_LOG(FATAL) << \"can't reach here.\";\n  return NULL;\n}\n\nstatic const char * const kNonLinkedWeakMessageReplacementName = \"google.protobuf.Empty\";\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int FieldDescriptor::kMaxNumber;\nconst int FieldDescriptor::kFirstReservedNumber;\nconst int FieldDescriptor::kLastReservedNumber;\n#endif\n\nnamespace {\n\nstring ToCamelCase(const string& input, bool lower_first) {\n  bool capitalize_next = !lower_first;\n  string result;\n  result.reserve(input.size());\n\n  for (int i = 0; i < input.size(); i++) {\n    if (input[i] == '_') {\n      capitalize_next = true;\n    } else if (capitalize_next) {\n      // Note:  I distrust ctype.h due to locales.\n      if ('a' <= input[i] && input[i] <= 'z') {\n        result.push_back(input[i] - 'a' + 'A');\n      } else {\n        result.push_back(input[i]);\n      }\n      capitalize_next = false;\n    } else {\n      result.push_back(input[i]);\n    }\n  }\n\n  // Lower-case the first letter.\n  if (lower_first && !result.empty() && 'A' <= result[0] && result[0] <= 'Z') {\n      result[0] = result[0] - 'A' + 'a';\n  }\n\n  return result;\n}\n\n// A DescriptorPool contains a bunch of hash_maps to implement the\n// various Find*By*() methods.  Since hashtable lookups are O(1), it's\n// most efficient to construct a fixed set of large hash_maps used by\n// all objects in the pool rather than construct one or more small\n// hash_maps for each object.\n//\n// The keys to these hash_maps are (parent, name) or (parent, number)\n// pairs.  Unfortunately STL doesn't provide hash functions for pair<>,\n// so we must invent our own.\n//\n// TODO(kenton):  Use StringPiece rather than const char* in keys?  It would\n//   be a lot cleaner but we'd just have to convert it back to const char*\n//   for the open source release.\n\ntypedef pair<const void*, const char*> PointerStringPair;\n\nstruct PointerStringPairEqual {\n  inline bool operator()(const PointerStringPair& a,\n                         const PointerStringPair& b) const {\n    return a.first == b.first && strcmp(a.second, b.second) == 0;\n  }\n};\n\ntemplate<typename PairType>\nstruct PointerIntegerPairHash {\n  size_t operator()(const PairType& p) const {\n    // FIXME(kenton):  What is the best way to compute this hash?  I have\n    // no idea!  This seems a bit better than an XOR.\n    return reinterpret_cast<intptr_t>(p.first) * ((1 << 16) - 1) + p.second;\n  }\n\n#ifdef _MSC_VER\n  // Used only by MSVC and platforms where hash_map is not available.\n  static const size_t bucket_size = 4;\n  static const size_t min_buckets = 8;\n#endif\n  inline bool operator()(const PairType& a, const PairType& b) const {\n    return a.first < b.first ||\n          (a.first == b.first && a.second < b.second);\n  }\n};\n\ntypedef pair<const Descriptor*, int> DescriptorIntPair;\ntypedef pair<const EnumDescriptor*, int> EnumIntPair;\n\nstruct PointerStringPairHash {\n  size_t operator()(const PointerStringPair& p) const {\n    // FIXME(kenton):  What is the best way to compute this hash?  I have\n    // no idea!  This seems a bit better than an XOR.\n    hash<const char*> cstring_hash;\n    return reinterpret_cast<intptr_t>(p.first) * ((1 << 16) - 1) +\n           cstring_hash(p.second);\n  }\n\n#ifdef _MSC_VER\n  // Used only by MSVC and platforms where hash_map is not available.\n  static const size_t bucket_size = 4;\n  static const size_t min_buckets = 8;\n#endif\n  inline bool operator()(const PointerStringPair& a,\n                         const PointerStringPair& b) const {\n    if (a.first < b.first) return true;\n    if (a.first > b.first) return false;\n    return strcmp(a.second, b.second) < 0;\n  }\n};\n\n\nstruct Symbol {\n  enum Type {\n    NULL_SYMBOL, MESSAGE, FIELD, ONEOF, ENUM, ENUM_VALUE, SERVICE, METHOD,\n    PACKAGE\n  };\n  Type type;\n  union {\n    const Descriptor* descriptor;\n    const FieldDescriptor* field_descriptor;\n    const OneofDescriptor* oneof_descriptor;\n    const EnumDescriptor* enum_descriptor;\n    const EnumValueDescriptor* enum_value_descriptor;\n    const ServiceDescriptor* service_descriptor;\n    const MethodDescriptor* method_descriptor;\n    const FileDescriptor* package_file_descriptor;\n  };\n\n  inline Symbol() : type(NULL_SYMBOL) { descriptor = NULL; }\n  inline bool IsNull() const { return type == NULL_SYMBOL; }\n  inline bool IsType() const {\n    return type == MESSAGE || type == ENUM;\n  }\n  inline bool IsAggregate() const {\n    return type == MESSAGE || type == PACKAGE\n        || type == ENUM || type == SERVICE;\n  }\n\n#define CONSTRUCTOR(TYPE, TYPE_CONSTANT, FIELD)  \\\n  inline explicit Symbol(const TYPE* value) {    \\\n    type = TYPE_CONSTANT;                        \\\n    this->FIELD = value;                         \\\n  }\n\n  CONSTRUCTOR(Descriptor         , MESSAGE   , descriptor             )\n  CONSTRUCTOR(FieldDescriptor    , FIELD     , field_descriptor       )\n  CONSTRUCTOR(OneofDescriptor    , ONEOF     , oneof_descriptor       )\n  CONSTRUCTOR(EnumDescriptor     , ENUM      , enum_descriptor        )\n  CONSTRUCTOR(EnumValueDescriptor, ENUM_VALUE, enum_value_descriptor  )\n  CONSTRUCTOR(ServiceDescriptor  , SERVICE   , service_descriptor     )\n  CONSTRUCTOR(MethodDescriptor   , METHOD    , method_descriptor      )\n  CONSTRUCTOR(FileDescriptor     , PACKAGE   , package_file_descriptor)\n#undef CONSTRUCTOR\n\n  const FileDescriptor* GetFile() const {\n    switch (type) {\n      case NULL_SYMBOL: return NULL;\n      case MESSAGE    : return descriptor           ->file();\n      case FIELD      : return field_descriptor     ->file();\n      case ONEOF      : return oneof_descriptor     ->containing_type()->file();\n      case ENUM       : return enum_descriptor      ->file();\n      case ENUM_VALUE : return enum_value_descriptor->type()->file();\n      case SERVICE    : return service_descriptor   ->file();\n      case METHOD     : return method_descriptor    ->service()->file();\n      case PACKAGE    : return package_file_descriptor;\n    }\n    return NULL;\n  }\n};\n\nconst Symbol kNullSymbol;\n\ntypedef hash_map<const char*, Symbol,\n                 hash<const char*>, streq>\n  SymbolsByNameMap;\ntypedef hash_map<PointerStringPair, Symbol,\n                 PointerStringPairHash, PointerStringPairEqual>\n  SymbolsByParentMap;\ntypedef hash_map<const char*, const FileDescriptor*,\n                 hash<const char*>, streq>\n  FilesByNameMap;\ntypedef hash_map<PointerStringPair, const FieldDescriptor*,\n                 PointerStringPairHash, PointerStringPairEqual>\n  FieldsByNameMap;\ntypedef hash_map<DescriptorIntPair, const FieldDescriptor*,\n                 PointerIntegerPairHash<DescriptorIntPair> >\n  FieldsByNumberMap;\ntypedef hash_map<EnumIntPair, const EnumValueDescriptor*,\n                 PointerIntegerPairHash<EnumIntPair> >\n  EnumValuesByNumberMap;\n// This is a map rather than a hash_map, since we use it to iterate\n// through all the extensions that extend a given Descriptor, and an\n// ordered data structure that implements lower_bound is convenient\n// for that.\ntypedef map<DescriptorIntPair, const FieldDescriptor*>\n  ExtensionsGroupedByDescriptorMap;\ntypedef hash_map<string, const SourceCodeInfo_Location*> LocationsByPathMap;\n\nset<string>* allowed_proto3_extendees_ = NULL;\nGOOGLE_PROTOBUF_DECLARE_ONCE(allowed_proto3_extendees_init_);\n\nvoid DeleteAllowedProto3Extendee() {\n  delete allowed_proto3_extendees_;\n}\n\nvoid InitAllowedProto3Extendee() {\n  allowed_proto3_extendees_ = new set<string>;\n  const char* kOptionNames[] = {\n      \"FileOptions\",      \"MessageOptions\", \"FieldOptions\", \"EnumOptions\",\n      \"EnumValueOptions\", \"ServiceOptions\", \"MethodOptions\"};\n  for (int i = 0; i < GOOGLE_ARRAYSIZE(kOptionNames); ++i) {\n    // descriptor.proto has a different package name in opensource. We allow\n    // both so the opensource protocol compiler can also compile internal\n    // proto3 files with custom options. See: b/27567912\n    allowed_proto3_extendees_->insert(string(\"google.protobuf.\") +\n                                      kOptionNames[i]);\n    // Split the word to trick the opensource processing scripts so they\n    // will keep the origial package name.\n    allowed_proto3_extendees_->insert(string(\"proto\") + \"2.\" + kOptionNames[i]);\n  }\n\n  google::protobuf::internal::OnShutdown(&DeleteAllowedProto3Extendee);\n}\n\n// Checks whether the extendee type is allowed in proto3.\n// Only extensions to descriptor options are allowed. We use name comparison\n// instead of comparing the descriptor directly because the extensions may be\n// defined in a different pool.\nbool AllowedExtendeeInProto3(const string& name) {\n  ::google::protobuf::GoogleOnceInit(&allowed_proto3_extendees_init_, &InitAllowedProto3Extendee);\n  return allowed_proto3_extendees_->find(name) !=\n         allowed_proto3_extendees_->end();\n}\n\n}  // anonymous namespace\n\n// ===================================================================\n// DescriptorPool::Tables\n\nclass DescriptorPool::Tables {\n public:\n  Tables();\n  ~Tables();\n\n  // Record the current state of the tables to the stack of checkpoints.\n  // Each call to AddCheckpoint() must be paired with exactly one call to either\n  // ClearLastCheckpoint() or RollbackToLastCheckpoint().\n  //\n  // This is used when building files, since some kinds of validation errors\n  // cannot be detected until the file's descriptors have already been added to\n  // the tables.\n  //\n  // This supports recursive checkpoints, since building a file may trigger\n  // recursive building of other files. Note that recursive checkpoints are not\n  // normally necessary; explicit dependencies are built prior to checkpointing.\n  // So although we recursively build transitive imports, there is at most one\n  // checkpoint in the stack during dependency building.\n  //\n  // Recursive checkpoints only arise during cross-linking of the descriptors.\n  // Symbol references must be resolved, via DescriptorBuilder::FindSymbol and\n  // friends. If the pending file references an unknown symbol\n  // (e.g., it is not defined in the pending file's explicit dependencies), and\n  // the pool is using a fallback database, and that database contains a file\n  // defining that symbol, and that file has not yet been built by the pool,\n  // the pool builds the file during cross-linking, leading to another\n  // checkpoint.\n  void AddCheckpoint();\n\n  // Mark the last checkpoint as having cleared successfully, removing it from\n  // the stack. If the stack is empty, all pending symbols will be committed.\n  //\n  // Note that this does not guarantee that the symbols added since the last\n  // checkpoint won't be rolled back: if a checkpoint gets rolled back,\n  // everything past that point gets rolled back, including symbols added after\n  // checkpoints that were pushed onto the stack after it and marked as cleared.\n  void ClearLastCheckpoint();\n\n  // Roll back the Tables to the state of the checkpoint at the top of the\n  // stack, removing everything that was added after that point.\n  void RollbackToLastCheckpoint();\n\n  // The stack of files which are currently being built.  Used to detect\n  // cyclic dependencies when loading files from a DescriptorDatabase.  Not\n  // used when fallback_database_ == NULL.\n  vector<string> pending_files_;\n\n  // A set of files which we have tried to load from the fallback database\n  // and encountered errors.  We will not attempt to load them again during\n  // execution of the current public API call, but for compatibility with\n  // legacy clients, this is cleared at the beginning of each public API call.\n  // Not used when fallback_database_ == NULL.\n  hash_set<string> known_bad_files_;\n\n  // A set of symbols which we have tried to load from the fallback database\n  // and encountered errors. We will not attempt to load them again during\n  // execution of the current public API call, but for compatibility with\n  // legacy clients, this is cleared at the beginning of each public API call.\n  hash_set<string> known_bad_symbols_;\n\n  // The set of descriptors for which we've already loaded the full\n  // set of extensions numbers from fallback_database_.\n  hash_set<const Descriptor*> extensions_loaded_from_db_;\n\n  // -----------------------------------------------------------------\n  // Finding items.\n\n  // Find symbols.  This returns a null Symbol (symbol.IsNull() is true)\n  // if not found.\n  inline Symbol FindSymbol(const string& key) const;\n\n  // This implements the body of DescriptorPool::Find*ByName().  It should\n  // really be a private method of DescriptorPool, but that would require\n  // declaring Symbol in descriptor.h, which would drag all kinds of other\n  // stuff into the header.  Yay C++.\n  Symbol FindByNameHelper(\n    const DescriptorPool* pool, const string& name);\n\n  // These return NULL if not found.\n  inline const FileDescriptor* FindFile(const string& key) const;\n  inline const FieldDescriptor* FindExtension(const Descriptor* extendee,\n                                              int number);\n  inline void FindAllExtensions(const Descriptor* extendee,\n                                vector<const FieldDescriptor*>* out) const;\n\n  // -----------------------------------------------------------------\n  // Adding items.\n\n  // These add items to the corresponding tables.  They return false if\n  // the key already exists in the table.  For AddSymbol(), the string passed\n  // in must be one that was constructed using AllocateString(), as it will\n  // be used as a key in the symbols_by_name_ map without copying.\n  bool AddSymbol(const string& full_name, Symbol symbol);\n  bool AddFile(const FileDescriptor* file);\n  bool AddExtension(const FieldDescriptor* field);\n\n  // -----------------------------------------------------------------\n  // Allocating memory.\n\n  // Allocate an object which will be reclaimed when the pool is\n  // destroyed.  Note that the object's destructor will never be called,\n  // so its fields must be plain old data (primitive data types and\n  // pointers).  All of the descriptor types are such objects.\n  template<typename Type> Type* Allocate();\n\n  // Allocate an array of objects which will be reclaimed when the\n  // pool in destroyed.  Again, destructors are never called.\n  template<typename Type> Type* AllocateArray(int count);\n\n  // Allocate a string which will be destroyed when the pool is destroyed.\n  // The string is initialized to the given value for convenience.\n  string* AllocateString(const string& value);\n\n  // Allocate a protocol message object.  Some older versions of GCC have\n  // trouble understanding explicit template instantiations in some cases, so\n  // in those cases we have to pass a dummy pointer of the right type as the\n  // parameter instead of specifying the type explicitly.\n  template<typename Type> Type* AllocateMessage(Type* dummy = NULL);\n\n  // Allocate a FileDescriptorTables object.\n  FileDescriptorTables* AllocateFileTables();\n\n private:\n  vector<string*> strings_;    // All strings in the pool.\n  vector<Message*> messages_;  // All messages in the pool.\n  vector<FileDescriptorTables*> file_tables_;  // All file tables in the pool.\n  vector<void*> allocations_;  // All other memory allocated in the pool.\n\n  SymbolsByNameMap      symbols_by_name_;\n  FilesByNameMap        files_by_name_;\n  ExtensionsGroupedByDescriptorMap extensions_;\n\n  struct CheckPoint {\n    explicit CheckPoint(const Tables* tables)\n      : strings_before_checkpoint(tables->strings_.size()),\n        messages_before_checkpoint(tables->messages_.size()),\n        file_tables_before_checkpoint(tables->file_tables_.size()),\n        allocations_before_checkpoint(tables->allocations_.size()),\n        pending_symbols_before_checkpoint(\n            tables->symbols_after_checkpoint_.size()),\n        pending_files_before_checkpoint(\n            tables->files_after_checkpoint_.size()),\n        pending_extensions_before_checkpoint(\n            tables->extensions_after_checkpoint_.size()) {\n    }\n    int strings_before_checkpoint;\n    int messages_before_checkpoint;\n    int file_tables_before_checkpoint;\n    int allocations_before_checkpoint;\n    int pending_symbols_before_checkpoint;\n    int pending_files_before_checkpoint;\n    int pending_extensions_before_checkpoint;\n  };\n  vector<CheckPoint> checkpoints_;\n  vector<const char*      > symbols_after_checkpoint_;\n  vector<const char*      > files_after_checkpoint_;\n  vector<DescriptorIntPair> extensions_after_checkpoint_;\n\n  // Allocate some bytes which will be reclaimed when the pool is\n  // destroyed.\n  void* AllocateBytes(int size);\n};\n\n// Contains tables specific to a particular file.  These tables are not\n// modified once the file has been constructed, so they need not be\n// protected by a mutex.  This makes operations that depend only on the\n// contents of a single file -- e.g. Descriptor::FindFieldByName() --\n// lock-free.\n//\n// For historical reasons, the definitions of the methods of\n// FileDescriptorTables and DescriptorPool::Tables are interleaved below.\n// These used to be a single class.\nclass FileDescriptorTables {\n public:\n  FileDescriptorTables();\n  ~FileDescriptorTables();\n\n  // Empty table, used with placeholder files.\n  inline static const FileDescriptorTables& GetEmptyInstance();\n\n  // -----------------------------------------------------------------\n  // Finding items.\n\n  // Find symbols.  These return a null Symbol (symbol.IsNull() is true)\n  // if not found.\n  inline Symbol FindNestedSymbol(const void* parent,\n                                 const string& name) const;\n  inline Symbol FindNestedSymbolOfType(const void* parent,\n                                       const string& name,\n                                       const Symbol::Type type) const;\n\n  // These return NULL if not found.\n  inline const FieldDescriptor* FindFieldByNumber(\n    const Descriptor* parent, int number) const;\n  inline const FieldDescriptor* FindFieldByLowercaseName(\n    const void* parent, const string& lowercase_name) const;\n  inline const FieldDescriptor* FindFieldByCamelcaseName(\n    const void* parent, const string& camelcase_name) const;\n  inline const EnumValueDescriptor* FindEnumValueByNumber(\n    const EnumDescriptor* parent, int number) const;\n  // This creates a new EnumValueDescriptor if not found, in a thread-safe way.\n  inline const EnumValueDescriptor* FindEnumValueByNumberCreatingIfUnknown(\n      const EnumDescriptor* parent, int number) const;\n\n  // -----------------------------------------------------------------\n  // Adding items.\n\n  // These add items to the corresponding tables.  They return false if\n  // the key already exists in the table.  For AddAliasUnderParent(), the\n  // string passed in must be one that was constructed using AllocateString(),\n  // as it will be used as a key in the symbols_by_parent_ map without copying.\n  bool AddAliasUnderParent(const void* parent, const string& name,\n                           Symbol symbol);\n  bool AddFieldByNumber(const FieldDescriptor* field);\n  bool AddEnumValueByNumber(const EnumValueDescriptor* value);\n\n  // Adds the field to the lowercase_name and camelcase_name maps.  Never\n  // fails because we allow duplicates; the first field by the name wins.\n  void AddFieldByStylizedNames(const FieldDescriptor* field);\n\n  // Populates p->first->locations_by_path_ from p->second.\n  // Unusual signature dictated by GoogleOnceDynamic.\n  static void BuildLocationsByPath(\n      pair<const FileDescriptorTables*, const SourceCodeInfo*>* p);\n\n  // Returns the location denoted by the specified path through info,\n  // or NULL if not found.\n  // The value of info must be that of the corresponding FileDescriptor.\n  // (Conceptually a pure function, but stateful as an optimisation.)\n  const SourceCodeInfo_Location* GetSourceLocation(\n      const vector<int>& path, const SourceCodeInfo* info) const;\n\n private:\n  SymbolsByParentMap    symbols_by_parent_;\n  FieldsByNameMap       fields_by_lowercase_name_;\n  FieldsByNameMap       fields_by_camelcase_name_;\n  FieldsByNumberMap     fields_by_number_;       // Not including extensions.\n  EnumValuesByNumberMap enum_values_by_number_;\n  mutable EnumValuesByNumberMap unknown_enum_values_by_number_\n      GOOGLE_GUARDED_BY(unknown_enum_values_mu_);\n\n  // Populated on first request to save space, hence constness games.\n  mutable GoogleOnceDynamic locations_by_path_once_;\n  mutable LocationsByPathMap locations_by_path_;\n\n  // Mutex to protect the unknown-enum-value map due to dynamic\n  // EnumValueDescriptor creation on unknown values.\n  mutable Mutex unknown_enum_values_mu_;\n};\n\nDescriptorPool::Tables::Tables()\n    // Start some hash_map and hash_set objects with a small # of buckets\n    : known_bad_files_(3),\n      known_bad_symbols_(3),\n      extensions_loaded_from_db_(3),\n      symbols_by_name_(3),\n      files_by_name_(3) {}\n\n\nDescriptorPool::Tables::~Tables() {\n  GOOGLE_DCHECK(checkpoints_.empty());\n  // Note that the deletion order is important, since the destructors of some\n  // messages may refer to objects in allocations_.\n  STLDeleteElements(&messages_);\n  for (int i = 0; i < allocations_.size(); i++) {\n    operator delete(allocations_[i]);\n  }\n  STLDeleteElements(&strings_);\n  STLDeleteElements(&file_tables_);\n}\n\nFileDescriptorTables::FileDescriptorTables()\n    // Initialize all the hash tables to start out with a small # of buckets\n    : symbols_by_parent_(3),\n      fields_by_lowercase_name_(3),\n      fields_by_camelcase_name_(3),\n      fields_by_number_(3),\n      enum_values_by_number_(3),\n      unknown_enum_values_by_number_(3) {\n}\n\nFileDescriptorTables::~FileDescriptorTables() {}\n\nnamespace {\n\nFileDescriptorTables* file_descriptor_tables_ = NULL;\nGOOGLE_PROTOBUF_DECLARE_ONCE(file_descriptor_tables_once_init_);\n\nvoid DeleteFileDescriptorTables() {\n  delete file_descriptor_tables_;\n  file_descriptor_tables_ = NULL;\n}\n\nvoid InitFileDescriptorTables() {\n  file_descriptor_tables_ = new FileDescriptorTables();\n  internal::OnShutdown(&DeleteFileDescriptorTables);\n}\n\ninline void InitFileDescriptorTablesOnce() {\n  ::google::protobuf::GoogleOnceInit(\n      &file_descriptor_tables_once_init_, &InitFileDescriptorTables);\n}\n\n}  // anonymous namespace\n\ninline const FileDescriptorTables& FileDescriptorTables::GetEmptyInstance() {\n  InitFileDescriptorTablesOnce();\n  return *file_descriptor_tables_;\n}\n\nvoid DescriptorPool::Tables::AddCheckpoint() {\n  checkpoints_.push_back(CheckPoint(this));\n}\n\nvoid DescriptorPool::Tables::ClearLastCheckpoint() {\n  GOOGLE_DCHECK(!checkpoints_.empty());\n  checkpoints_.pop_back();\n  if (checkpoints_.empty()) {\n    // All checkpoints have been cleared: we can now commit all of the pending\n    // data.\n    symbols_after_checkpoint_.clear();\n    files_after_checkpoint_.clear();\n    extensions_after_checkpoint_.clear();\n  }\n}\n\nvoid DescriptorPool::Tables::RollbackToLastCheckpoint() {\n  GOOGLE_DCHECK(!checkpoints_.empty());\n  const CheckPoint& checkpoint = checkpoints_.back();\n\n  for (int i = checkpoint.pending_symbols_before_checkpoint;\n       i < symbols_after_checkpoint_.size();\n       i++) {\n    symbols_by_name_.erase(symbols_after_checkpoint_[i]);\n  }\n  for (int i = checkpoint.pending_files_before_checkpoint;\n       i < files_after_checkpoint_.size();\n       i++) {\n    files_by_name_.erase(files_after_checkpoint_[i]);\n  }\n  for (int i = checkpoint.pending_extensions_before_checkpoint;\n       i < extensions_after_checkpoint_.size();\n       i++) {\n    extensions_.erase(extensions_after_checkpoint_[i]);\n  }\n\n  symbols_after_checkpoint_.resize(\n      checkpoint.pending_symbols_before_checkpoint);\n  files_after_checkpoint_.resize(checkpoint.pending_files_before_checkpoint);\n  extensions_after_checkpoint_.resize(\n      checkpoint.pending_extensions_before_checkpoint);\n\n  STLDeleteContainerPointers(\n      strings_.begin() + checkpoint.strings_before_checkpoint, strings_.end());\n  STLDeleteContainerPointers(\n      messages_.begin() + checkpoint.messages_before_checkpoint,\n      messages_.end());\n  STLDeleteContainerPointers(\n      file_tables_.begin() + checkpoint.file_tables_before_checkpoint,\n      file_tables_.end());\n  for (int i = checkpoint.allocations_before_checkpoint;\n       i < allocations_.size();\n       i++) {\n    operator delete(allocations_[i]);\n  }\n\n  strings_.resize(checkpoint.strings_before_checkpoint);\n  messages_.resize(checkpoint.messages_before_checkpoint);\n  file_tables_.resize(checkpoint.file_tables_before_checkpoint);\n  allocations_.resize(checkpoint.allocations_before_checkpoint);\n  checkpoints_.pop_back();\n}\n\n// -------------------------------------------------------------------\n\ninline Symbol DescriptorPool::Tables::FindSymbol(const string& key) const {\n  const Symbol* result = FindOrNull(symbols_by_name_, key.c_str());\n  if (result == NULL) {\n    return kNullSymbol;\n  } else {\n    return *result;\n  }\n}\n\ninline Symbol FileDescriptorTables::FindNestedSymbol(\n    const void* parent, const string& name) const {\n  const Symbol* result =\n    FindOrNull(symbols_by_parent_, PointerStringPair(parent, name.c_str()));\n  if (result == NULL) {\n    return kNullSymbol;\n  } else {\n    return *result;\n  }\n}\n\ninline Symbol FileDescriptorTables::FindNestedSymbolOfType(\n    const void* parent, const string& name, const Symbol::Type type) const {\n  Symbol result = FindNestedSymbol(parent, name);\n  if (result.type != type) return kNullSymbol;\n  return result;\n}\n\nSymbol DescriptorPool::Tables::FindByNameHelper(\n    const DescriptorPool* pool, const string& name) {\n  MutexLockMaybe lock(pool->mutex_);\n  known_bad_symbols_.clear();\n  known_bad_files_.clear();\n  Symbol result = FindSymbol(name);\n\n  if (result.IsNull() && pool->underlay_ != NULL) {\n    // Symbol not found; check the underlay.\n    result =\n      pool->underlay_->tables_->FindByNameHelper(pool->underlay_, name);\n  }\n\n  if (result.IsNull()) {\n    // Symbol still not found, so check fallback database.\n    if (pool->TryFindSymbolInFallbackDatabase(name)) {\n      result = FindSymbol(name);\n    }\n  }\n\n  return result;\n}\n\ninline const FileDescriptor* DescriptorPool::Tables::FindFile(\n    const string& key) const {\n  return FindPtrOrNull(files_by_name_, key.c_str());\n}\n\ninline const FieldDescriptor* FileDescriptorTables::FindFieldByNumber(\n    const Descriptor* parent, int number) const {\n  return FindPtrOrNull(fields_by_number_, std::make_pair(parent, number));\n}\n\ninline const FieldDescriptor* FileDescriptorTables::FindFieldByLowercaseName(\n    const void* parent, const string& lowercase_name) const {\n  return FindPtrOrNull(fields_by_lowercase_name_,\n                       PointerStringPair(parent, lowercase_name.c_str()));\n}\n\ninline const FieldDescriptor* FileDescriptorTables::FindFieldByCamelcaseName(\n    const void* parent, const string& camelcase_name) const {\n  return FindPtrOrNull(fields_by_camelcase_name_,\n                       PointerStringPair(parent, camelcase_name.c_str()));\n}\n\ninline const EnumValueDescriptor* FileDescriptorTables::FindEnumValueByNumber(\n    const EnumDescriptor* parent, int number) const {\n  return FindPtrOrNull(enum_values_by_number_, std::make_pair(parent, number));\n}\n\ninline const EnumValueDescriptor*\nFileDescriptorTables::FindEnumValueByNumberCreatingIfUnknown(\n    const EnumDescriptor* parent, int number) const {\n  // First try, with map of compiled-in values.\n  {\n    const EnumValueDescriptor* desc =\n        FindPtrOrNull(enum_values_by_number_, std::make_pair(parent, number));\n    if (desc != NULL) {\n      return desc;\n    }\n  }\n  // Second try, with reader lock held on unknown enum values: common case.\n  {\n    ReaderMutexLock l(&unknown_enum_values_mu_);\n    const EnumValueDescriptor* desc = FindPtrOrNull(\n        unknown_enum_values_by_number_, std::make_pair(parent, number));\n    if (desc != NULL) {\n      return desc;\n    }\n  }\n  // If not found, try again with writer lock held, and create new descriptor if\n  // necessary.\n  {\n    WriterMutexLock l(&unknown_enum_values_mu_);\n    const EnumValueDescriptor* desc = FindPtrOrNull(\n        unknown_enum_values_by_number_, std::make_pair(parent, number));\n    if (desc != NULL) {\n      return desc;\n    }\n\n    // Create an EnumValueDescriptor dynamically. We don't insert it into the\n    // EnumDescriptor (it's not a part of the enum as originally defined), but\n    // we do insert it into the table so that we can return the same pointer\n    // later.\n    string enum_value_name = StringPrintf(\n        \"UNKNOWN_ENUM_VALUE_%s_%d\", parent->name().c_str(), number);\n    DescriptorPool::Tables* tables =\n        const_cast<DescriptorPool::Tables*>(DescriptorPool::generated_pool()->\n                                            tables_.get());\n    EnumValueDescriptor* result = tables->Allocate<EnumValueDescriptor>();\n    result->name_ = tables->AllocateString(enum_value_name);\n    result->full_name_ = tables->AllocateString(parent->full_name() +\n                                                \".\" + enum_value_name);\n    result->number_ = number;\n    result->type_ = parent;\n    result->options_ = &EnumValueOptions::default_instance();\n    InsertIfNotPresent(&unknown_enum_values_by_number_,\n                       std::make_pair(parent, number), result);\n    return result;\n  }\n}\n\n\ninline const FieldDescriptor* DescriptorPool::Tables::FindExtension(\n    const Descriptor* extendee, int number) {\n  return FindPtrOrNull(extensions_, std::make_pair(extendee, number));\n}\n\ninline void DescriptorPool::Tables::FindAllExtensions(\n    const Descriptor* extendee, vector<const FieldDescriptor*>* out) const {\n  ExtensionsGroupedByDescriptorMap::const_iterator it =\n      extensions_.lower_bound(std::make_pair(extendee, 0));\n  for (; it != extensions_.end() && it->first.first == extendee; ++it) {\n    out->push_back(it->second);\n  }\n}\n\n// -------------------------------------------------------------------\n\nbool DescriptorPool::Tables::AddSymbol(\n    const string& full_name, Symbol symbol) {\n  if (InsertIfNotPresent(&symbols_by_name_, full_name.c_str(), symbol)) {\n    symbols_after_checkpoint_.push_back(full_name.c_str());\n    return true;\n  } else {\n    return false;\n  }\n}\n\nbool FileDescriptorTables::AddAliasUnderParent(\n    const void* parent, const string& name, Symbol symbol) {\n  PointerStringPair by_parent_key(parent, name.c_str());\n  return InsertIfNotPresent(&symbols_by_parent_, by_parent_key, symbol);\n}\n\nbool DescriptorPool::Tables::AddFile(const FileDescriptor* file) {\n  if (InsertIfNotPresent(&files_by_name_, file->name().c_str(), file)) {\n    files_after_checkpoint_.push_back(file->name().c_str());\n    return true;\n  } else {\n    return false;\n  }\n}\n\nvoid FileDescriptorTables::AddFieldByStylizedNames(\n    const FieldDescriptor* field) {\n  const void* parent;\n  if (field->is_extension()) {\n    if (field->extension_scope() == NULL) {\n      parent = field->file();\n    } else {\n      parent = field->extension_scope();\n    }\n  } else {\n    parent = field->containing_type();\n  }\n\n  PointerStringPair lowercase_key(parent, field->lowercase_name().c_str());\n  InsertIfNotPresent(&fields_by_lowercase_name_, lowercase_key, field);\n\n  PointerStringPair camelcase_key(parent, field->camelcase_name().c_str());\n  InsertIfNotPresent(&fields_by_camelcase_name_, camelcase_key, field);\n}\n\nbool FileDescriptorTables::AddFieldByNumber(const FieldDescriptor* field) {\n  DescriptorIntPair key(field->containing_type(), field->number());\n  return InsertIfNotPresent(&fields_by_number_, key, field);\n}\n\nbool FileDescriptorTables::AddEnumValueByNumber(\n    const EnumValueDescriptor* value) {\n  EnumIntPair key(value->type(), value->number());\n  return InsertIfNotPresent(&enum_values_by_number_, key, value);\n}\n\nbool DescriptorPool::Tables::AddExtension(const FieldDescriptor* field) {\n  DescriptorIntPair key(field->containing_type(), field->number());\n  if (InsertIfNotPresent(&extensions_, key, field)) {\n    extensions_after_checkpoint_.push_back(key);\n    return true;\n  } else {\n    return false;\n  }\n}\n\n// -------------------------------------------------------------------\n\ntemplate<typename Type>\nType* DescriptorPool::Tables::Allocate() {\n  return reinterpret_cast<Type*>(AllocateBytes(sizeof(Type)));\n}\n\ntemplate<typename Type>\nType* DescriptorPool::Tables::AllocateArray(int count) {\n  return reinterpret_cast<Type*>(AllocateBytes(sizeof(Type) * count));\n}\n\nstring* DescriptorPool::Tables::AllocateString(const string& value) {\n  string* result = new string(value);\n  strings_.push_back(result);\n  return result;\n}\n\ntemplate<typename Type>\nType* DescriptorPool::Tables::AllocateMessage(Type* /* dummy */) {\n  Type* result = new Type;\n  messages_.push_back(result);\n  return result;\n}\n\nFileDescriptorTables* DescriptorPool::Tables::AllocateFileTables() {\n  FileDescriptorTables* result = new FileDescriptorTables;\n  file_tables_.push_back(result);\n  return result;\n}\n\nvoid* DescriptorPool::Tables::AllocateBytes(int size) {\n  // TODO(kenton):  Would it be worthwhile to implement this in some more\n  // sophisticated way?  Probably not for the open source release, but for\n  // internal use we could easily plug in one of our existing memory pool\n  // allocators...\n  if (size == 0) return NULL;\n\n  void* result = operator new(size);\n  allocations_.push_back(result);\n  return result;\n}\n\nvoid FileDescriptorTables::BuildLocationsByPath(\n    pair<const FileDescriptorTables*, const SourceCodeInfo*>* p) {\n  for (int i = 0, len = p->second->location_size(); i < len; ++i) {\n    const SourceCodeInfo_Location* loc = &p->second->location().Get(i);\n    p->first->locations_by_path_[Join(loc->path(), \",\")] = loc;\n  }\n}\n\nconst SourceCodeInfo_Location* FileDescriptorTables::GetSourceLocation(\n    const vector<int>& path, const SourceCodeInfo* info) const {\n  pair<const FileDescriptorTables*, const SourceCodeInfo*> p(\n      std::make_pair(this, info));\n  locations_by_path_once_.Init(&FileDescriptorTables::BuildLocationsByPath, &p);\n  return FindPtrOrNull(locations_by_path_, Join(path, \",\"));\n}\n\n// ===================================================================\n// DescriptorPool\n\nDescriptorPool::ErrorCollector::~ErrorCollector() {}\n\nDescriptorPool::DescriptorPool()\n  : mutex_(NULL),\n    fallback_database_(NULL),\n    default_error_collector_(NULL),\n    underlay_(NULL),\n    tables_(new Tables),\n    enforce_dependencies_(true),\n    allow_unknown_(false),\n    enforce_weak_(false) {}\n\nDescriptorPool::DescriptorPool(DescriptorDatabase* fallback_database,\n                               ErrorCollector* error_collector)\n  : mutex_(new Mutex),\n    fallback_database_(fallback_database),\n    default_error_collector_(error_collector),\n    underlay_(NULL),\n    tables_(new Tables),\n    enforce_dependencies_(true),\n    allow_unknown_(false),\n    enforce_weak_(false) {\n}\n\nDescriptorPool::DescriptorPool(const DescriptorPool* underlay)\n  : mutex_(NULL),\n    fallback_database_(NULL),\n    default_error_collector_(NULL),\n    underlay_(underlay),\n    tables_(new Tables),\n    enforce_dependencies_(true),\n    allow_unknown_(false),\n    enforce_weak_(false) {}\n\nDescriptorPool::~DescriptorPool() {\n  if (mutex_ != NULL) delete mutex_;\n}\n\n// DescriptorPool::BuildFile() defined later.\n// DescriptorPool::BuildFileCollectingErrors() defined later.\n\nvoid DescriptorPool::InternalDontEnforceDependencies() {\n  enforce_dependencies_ = false;\n}\n\nvoid DescriptorPool::AddUnusedImportTrackFile(const string& file_name) {\n  unused_import_track_files_.insert(file_name);\n}\n\nvoid DescriptorPool::ClearUnusedImportTrackFiles() {\n  unused_import_track_files_.clear();\n}\n\nbool DescriptorPool::InternalIsFileLoaded(const string& filename) const {\n  MutexLockMaybe lock(mutex_);\n  return tables_->FindFile(filename) != NULL;\n}\n\n// generated_pool ====================================================\n\nnamespace {\n\n\nEncodedDescriptorDatabase* generated_database_ = NULL;\nDescriptorPool* generated_pool_ = NULL;\nGOOGLE_PROTOBUF_DECLARE_ONCE(generated_pool_init_);\n\nvoid DeleteGeneratedPool() {\n  delete generated_database_;\n  generated_database_ = NULL;\n  delete generated_pool_;\n  generated_pool_ = NULL;\n}\n\nstatic void InitGeneratedPool() {\n  generated_database_ = new EncodedDescriptorDatabase;\n  generated_pool_ = new DescriptorPool(generated_database_);\n\n  internal::OnShutdown(&DeleteGeneratedPool);\n}\n\ninline void InitGeneratedPoolOnce() {\n  ::google::protobuf::GoogleOnceInit(&generated_pool_init_, &InitGeneratedPool);\n}\n\n}  // anonymous namespace\n\nconst DescriptorPool* DescriptorPool::generated_pool() {\n  InitGeneratedPoolOnce();\n  return generated_pool_;\n}\n\n\nDescriptorPool* DescriptorPool::internal_generated_pool() {\n  InitGeneratedPoolOnce();\n  return generated_pool_;\n}\n\nvoid DescriptorPool::InternalAddGeneratedFile(\n    const void* encoded_file_descriptor, int size) {\n  // So, this function is called in the process of initializing the\n  // descriptors for generated proto classes.  Each generated .pb.cc file\n  // has an internal procedure called AddDescriptors() which is called at\n  // process startup, and that function calls this one in order to register\n  // the raw bytes of the FileDescriptorProto representing the file.\n  //\n  // We do not actually construct the descriptor objects right away.  We just\n  // hang on to the bytes until they are actually needed.  We actually construct\n  // the descriptor the first time one of the following things happens:\n  // * Someone calls a method like descriptor(), GetDescriptor(), or\n  //   GetReflection() on the generated types, which requires returning the\n  //   descriptor or an object based on it.\n  // * Someone looks up the descriptor in DescriptorPool::generated_pool().\n  //\n  // Once one of these happens, the DescriptorPool actually parses the\n  // FileDescriptorProto and generates a FileDescriptor (and all its children)\n  // based on it.\n  //\n  // Note that FileDescriptorProto is itself a generated protocol message.\n  // Therefore, when we parse one, we have to be very careful to avoid using\n  // any descriptor-based operations, since this might cause infinite recursion\n  // or deadlock.\n  InitGeneratedPoolOnce();\n  GOOGLE_CHECK(generated_database_->Add(encoded_file_descriptor, size));\n}\n\n\n// Find*By* methods ==================================================\n\n// TODO(kenton):  There's a lot of repeated code here, but I'm not sure if\n//   there's any good way to factor it out.  Think about this some time when\n//   there's nothing more important to do (read: never).\n\nconst FileDescriptor* DescriptorPool::FindFileByName(const string& name) const {\n  MutexLockMaybe lock(mutex_);\n  tables_->known_bad_symbols_.clear();\n  tables_->known_bad_files_.clear();\n  const FileDescriptor* result = tables_->FindFile(name);\n  if (result != NULL) return result;\n  if (underlay_ != NULL) {\n    result = underlay_->FindFileByName(name);\n    if (result != NULL) return result;\n  }\n  if (TryFindFileInFallbackDatabase(name)) {\n    result = tables_->FindFile(name);\n    if (result != NULL) return result;\n  }\n  return NULL;\n}\n\nconst FileDescriptor* DescriptorPool::FindFileContainingSymbol(\n    const string& symbol_name) const {\n  MutexLockMaybe lock(mutex_);\n  tables_->known_bad_symbols_.clear();\n  tables_->known_bad_files_.clear();\n  Symbol result = tables_->FindSymbol(symbol_name);\n  if (!result.IsNull()) return result.GetFile();\n  if (underlay_ != NULL) {\n    const FileDescriptor* file_result =\n      underlay_->FindFileContainingSymbol(symbol_name);\n    if (file_result != NULL) return file_result;\n  }\n  if (TryFindSymbolInFallbackDatabase(symbol_name)) {\n    result = tables_->FindSymbol(symbol_name);\n    if (!result.IsNull()) return result.GetFile();\n  }\n  return NULL;\n}\n\nconst Descriptor* DescriptorPool::FindMessageTypeByName(\n    const string& name) const {\n  Symbol result = tables_->FindByNameHelper(this, name);\n  return (result.type == Symbol::MESSAGE) ? result.descriptor : NULL;\n}\n\nconst FieldDescriptor* DescriptorPool::FindFieldByName(\n    const string& name) const {\n  Symbol result = tables_->FindByNameHelper(this, name);\n  if (result.type == Symbol::FIELD &&\n      !result.field_descriptor->is_extension()) {\n    return result.field_descriptor;\n  } else {\n    return NULL;\n  }\n}\n\nconst FieldDescriptor* DescriptorPool::FindExtensionByName(\n    const string& name) const {\n  Symbol result = tables_->FindByNameHelper(this, name);\n  if (result.type == Symbol::FIELD &&\n      result.field_descriptor->is_extension()) {\n    return result.field_descriptor;\n  } else {\n    return NULL;\n  }\n}\n\nconst OneofDescriptor* DescriptorPool::FindOneofByName(\n    const string& name) const {\n  Symbol result = tables_->FindByNameHelper(this, name);\n  return (result.type == Symbol::ONEOF) ? result.oneof_descriptor : NULL;\n}\n\nconst EnumDescriptor* DescriptorPool::FindEnumTypeByName(\n    const string& name) const {\n  Symbol result = tables_->FindByNameHelper(this, name);\n  return (result.type == Symbol::ENUM) ? result.enum_descriptor : NULL;\n}\n\nconst EnumValueDescriptor* DescriptorPool::FindEnumValueByName(\n    const string& name) const {\n  Symbol result = tables_->FindByNameHelper(this, name);\n  return (result.type == Symbol::ENUM_VALUE) ?\n    result.enum_value_descriptor : NULL;\n}\n\nconst ServiceDescriptor* DescriptorPool::FindServiceByName(\n    const string& name) const {\n  Symbol result = tables_->FindByNameHelper(this, name);\n  return (result.type == Symbol::SERVICE) ? result.service_descriptor : NULL;\n}\n\nconst MethodDescriptor* DescriptorPool::FindMethodByName(\n    const string& name) const {\n  Symbol result = tables_->FindByNameHelper(this, name);\n  return (result.type == Symbol::METHOD) ? result.method_descriptor : NULL;\n}\n\nconst FieldDescriptor* DescriptorPool::FindExtensionByNumber(\n    const Descriptor* extendee, int number) const {\n  MutexLockMaybe lock(mutex_);\n  tables_->known_bad_symbols_.clear();\n  tables_->known_bad_files_.clear();\n  const FieldDescriptor* result = tables_->FindExtension(extendee, number);\n  if (result != NULL) {\n    return result;\n  }\n  if (underlay_ != NULL) {\n    result = underlay_->FindExtensionByNumber(extendee, number);\n    if (result != NULL) return result;\n  }\n  if (TryFindExtensionInFallbackDatabase(extendee, number)) {\n    result = tables_->FindExtension(extendee, number);\n    if (result != NULL) {\n      return result;\n    }\n  }\n  return NULL;\n}\n\nvoid DescriptorPool::FindAllExtensions(\n    const Descriptor* extendee, vector<const FieldDescriptor*>* out) const {\n  MutexLockMaybe lock(mutex_);\n  tables_->known_bad_symbols_.clear();\n  tables_->known_bad_files_.clear();\n\n  // Initialize tables_->extensions_ from the fallback database first\n  // (but do this only once per descriptor).\n  if (fallback_database_ != NULL &&\n      tables_->extensions_loaded_from_db_.count(extendee) == 0) {\n    vector<int> numbers;\n    if (fallback_database_->FindAllExtensionNumbers(extendee->full_name(),\n                                                    &numbers)) {\n      for (int i = 0; i < numbers.size(); ++i) {\n        int number = numbers[i];\n        if (tables_->FindExtension(extendee, number) == NULL) {\n          TryFindExtensionInFallbackDatabase(extendee, number);\n        }\n      }\n      tables_->extensions_loaded_from_db_.insert(extendee);\n    }\n  }\n\n  tables_->FindAllExtensions(extendee, out);\n  if (underlay_ != NULL) {\n    underlay_->FindAllExtensions(extendee, out);\n  }\n}\n\n\n// -------------------------------------------------------------------\n\nconst FieldDescriptor*\nDescriptor::FindFieldByNumber(int key) const {\n  const FieldDescriptor* result =\n    file()->tables_->FindFieldByNumber(this, key);\n  if (result == NULL || result->is_extension()) {\n    return NULL;\n  } else {\n    return result;\n  }\n}\n\nconst FieldDescriptor*\nDescriptor::FindFieldByLowercaseName(const string& key) const {\n  const FieldDescriptor* result =\n    file()->tables_->FindFieldByLowercaseName(this, key);\n  if (result == NULL || result->is_extension()) {\n    return NULL;\n  } else {\n    return result;\n  }\n}\n\nconst FieldDescriptor*\nDescriptor::FindFieldByCamelcaseName(const string& key) const {\n  const FieldDescriptor* result =\n    file()->tables_->FindFieldByCamelcaseName(this, key);\n  if (result == NULL || result->is_extension()) {\n    return NULL;\n  } else {\n    return result;\n  }\n}\n\nconst FieldDescriptor*\nDescriptor::FindFieldByName(const string& key) const {\n  Symbol result =\n    file()->tables_->FindNestedSymbolOfType(this, key, Symbol::FIELD);\n  if (!result.IsNull() && !result.field_descriptor->is_extension()) {\n    return result.field_descriptor;\n  } else {\n    return NULL;\n  }\n}\n\nconst OneofDescriptor*\nDescriptor::FindOneofByName(const string& key) const {\n  Symbol result =\n    file()->tables_->FindNestedSymbolOfType(this, key, Symbol::ONEOF);\n  if (!result.IsNull()) {\n    return result.oneof_descriptor;\n  } else {\n    return NULL;\n  }\n}\n\nconst FieldDescriptor*\nDescriptor::FindExtensionByName(const string& key) const {\n  Symbol result =\n    file()->tables_->FindNestedSymbolOfType(this, key, Symbol::FIELD);\n  if (!result.IsNull() && result.field_descriptor->is_extension()) {\n    return result.field_descriptor;\n  } else {\n    return NULL;\n  }\n}\n\nconst FieldDescriptor*\nDescriptor::FindExtensionByLowercaseName(const string& key) const {\n  const FieldDescriptor* result =\n    file()->tables_->FindFieldByLowercaseName(this, key);\n  if (result == NULL || !result->is_extension()) {\n    return NULL;\n  } else {\n    return result;\n  }\n}\n\nconst FieldDescriptor*\nDescriptor::FindExtensionByCamelcaseName(const string& key) const {\n  const FieldDescriptor* result =\n    file()->tables_->FindFieldByCamelcaseName(this, key);\n  if (result == NULL || !result->is_extension()) {\n    return NULL;\n  } else {\n    return result;\n  }\n}\n\nconst Descriptor*\nDescriptor::FindNestedTypeByName(const string& key) const {\n  Symbol result =\n    file()->tables_->FindNestedSymbolOfType(this, key, Symbol::MESSAGE);\n  if (!result.IsNull()) {\n    return result.descriptor;\n  } else {\n    return NULL;\n  }\n}\n\nconst EnumDescriptor*\nDescriptor::FindEnumTypeByName(const string& key) const {\n  Symbol result =\n    file()->tables_->FindNestedSymbolOfType(this, key, Symbol::ENUM);\n  if (!result.IsNull()) {\n    return result.enum_descriptor;\n  } else {\n    return NULL;\n  }\n}\n\nconst EnumValueDescriptor*\nDescriptor::FindEnumValueByName(const string& key) const {\n  Symbol result =\n    file()->tables_->FindNestedSymbolOfType(this, key, Symbol::ENUM_VALUE);\n  if (!result.IsNull()) {\n    return result.enum_value_descriptor;\n  } else {\n    return NULL;\n  }\n}\n\nconst EnumValueDescriptor*\nEnumDescriptor::FindValueByName(const string& key) const {\n  Symbol result =\n    file()->tables_->FindNestedSymbolOfType(this, key, Symbol::ENUM_VALUE);\n  if (!result.IsNull()) {\n    return result.enum_value_descriptor;\n  } else {\n    return NULL;\n  }\n}\n\nconst EnumValueDescriptor*\nEnumDescriptor::FindValueByNumber(int key) const {\n  return file()->tables_->FindEnumValueByNumber(this, key);\n}\n\nconst EnumValueDescriptor*\nEnumDescriptor::FindValueByNumberCreatingIfUnknown(int key) const {\n  return file()->tables_->FindEnumValueByNumberCreatingIfUnknown(this, key);\n}\n\nconst MethodDescriptor*\nServiceDescriptor::FindMethodByName(const string& key) const {\n  Symbol result =\n    file()->tables_->FindNestedSymbolOfType(this, key, Symbol::METHOD);\n  if (!result.IsNull()) {\n    return result.method_descriptor;\n  } else {\n    return NULL;\n  }\n}\n\nconst Descriptor*\nFileDescriptor::FindMessageTypeByName(const string& key) const {\n  Symbol result = tables_->FindNestedSymbolOfType(this, key, Symbol::MESSAGE);\n  if (!result.IsNull()) {\n    return result.descriptor;\n  } else {\n    return NULL;\n  }\n}\n\nconst EnumDescriptor*\nFileDescriptor::FindEnumTypeByName(const string& key) const {\n  Symbol result = tables_->FindNestedSymbolOfType(this, key, Symbol::ENUM);\n  if (!result.IsNull()) {\n    return result.enum_descriptor;\n  } else {\n    return NULL;\n  }\n}\n\nconst EnumValueDescriptor*\nFileDescriptor::FindEnumValueByName(const string& key) const {\n  Symbol result =\n    tables_->FindNestedSymbolOfType(this, key, Symbol::ENUM_VALUE);\n  if (!result.IsNull()) {\n    return result.enum_value_descriptor;\n  } else {\n    return NULL;\n  }\n}\n\nconst ServiceDescriptor*\nFileDescriptor::FindServiceByName(const string& key) const {\n  Symbol result = tables_->FindNestedSymbolOfType(this, key, Symbol::SERVICE);\n  if (!result.IsNull()) {\n    return result.service_descriptor;\n  } else {\n    return NULL;\n  }\n}\n\nconst FieldDescriptor*\nFileDescriptor::FindExtensionByName(const string& key) const {\n  Symbol result = tables_->FindNestedSymbolOfType(this, key, Symbol::FIELD);\n  if (!result.IsNull() && result.field_descriptor->is_extension()) {\n    return result.field_descriptor;\n  } else {\n    return NULL;\n  }\n}\n\nconst FieldDescriptor*\nFileDescriptor::FindExtensionByLowercaseName(const string& key) const {\n  const FieldDescriptor* result = tables_->FindFieldByLowercaseName(this, key);\n  if (result == NULL || !result->is_extension()) {\n    return NULL;\n  } else {\n    return result;\n  }\n}\n\nconst FieldDescriptor*\nFileDescriptor::FindExtensionByCamelcaseName(const string& key) const {\n  const FieldDescriptor* result = tables_->FindFieldByCamelcaseName(this, key);\n  if (result == NULL || !result->is_extension()) {\n    return NULL;\n  } else {\n    return result;\n  }\n}\n\nconst Descriptor::ExtensionRange*\nDescriptor::FindExtensionRangeContainingNumber(int number) const {\n  // Linear search should be fine because we don't expect a message to have\n  // more than a couple extension ranges.\n  for (int i = 0; i < extension_range_count(); i++) {\n    if (number >= extension_range(i)->start &&\n        number <  extension_range(i)->end) {\n      return extension_range(i);\n    }\n  }\n  return NULL;\n}\n\nconst Descriptor::ReservedRange*\nDescriptor::FindReservedRangeContainingNumber(int number) const {\n  // TODO(chrisn): Consider a non-linear search.\n  for (int i = 0; i < reserved_range_count(); i++) {\n    if (number >= reserved_range(i)->start &&\n        number <  reserved_range(i)->end) {\n      return reserved_range(i);\n    }\n  }\n  return NULL;\n}\n\n// -------------------------------------------------------------------\n\nbool DescriptorPool::TryFindFileInFallbackDatabase(const string& name) const {\n  if (fallback_database_ == NULL) return false;\n\n  if (tables_->known_bad_files_.count(name) > 0) return false;\n\n  FileDescriptorProto file_proto;\n  if (!fallback_database_->FindFileByName(name, &file_proto) ||\n      BuildFileFromDatabase(file_proto) == NULL) {\n    tables_->known_bad_files_.insert(name);\n    return false;\n  }\n  return true;\n}\n\nbool DescriptorPool::IsSubSymbolOfBuiltType(const string& name) const {\n  string prefix = name;\n  for (;;) {\n    string::size_type dot_pos = prefix.find_last_of('.');\n    if (dot_pos == string::npos) {\n      break;\n    }\n    prefix = prefix.substr(0, dot_pos);\n    Symbol symbol = tables_->FindSymbol(prefix);\n    // If the symbol type is anything other than PACKAGE, then its complete\n    // definition is already known.\n    if (!symbol.IsNull() && symbol.type != Symbol::PACKAGE) {\n      return true;\n    }\n  }\n  if (underlay_ != NULL) {\n    // Check to see if any prefix of this symbol exists in the underlay.\n    return underlay_->IsSubSymbolOfBuiltType(name);\n  }\n  return false;\n}\n\nbool DescriptorPool::TryFindSymbolInFallbackDatabase(const string& name) const {\n  if (fallback_database_ == NULL) return false;\n\n  if (tables_->known_bad_symbols_.count(name) > 0) return false;\n\n  FileDescriptorProto file_proto;\n  if (// We skip looking in the fallback database if the name is a sub-symbol\n      // of any descriptor that already exists in the descriptor pool (except\n      // for package descriptors).  This is valid because all symbols except\n      // for packages are defined in a single file, so if the symbol exists\n      // then we should already have its definition.\n      //\n      // The other reason to do this is to support \"overriding\" type\n      // definitions by merging two databases that define the same type.  (Yes,\n      // people do this.)  The main difficulty with making this work is that\n      // FindFileContainingSymbol() is allowed to return both false positives\n      // (e.g., SimpleDescriptorDatabase, UpgradedDescriptorDatabase) and false\n      // negatives (e.g. ProtoFileParser, SourceTreeDescriptorDatabase).\n      // When two such databases are merged, looking up a non-existent\n      // sub-symbol of a type that already exists in the descriptor pool can\n      // result in an attempt to load multiple definitions of the same type.\n      // The check below avoids this.\n      IsSubSymbolOfBuiltType(name)\n\n      // Look up file containing this symbol in fallback database.\n      || !fallback_database_->FindFileContainingSymbol(name, &file_proto)\n\n      // Check if we've already built this file. If so, it apparently doesn't\n      // contain the symbol we're looking for.  Some DescriptorDatabases\n      // return false positives.\n      || tables_->FindFile(file_proto.name()) != NULL\n\n      // Build the file.\n      || BuildFileFromDatabase(file_proto) == NULL) {\n    tables_->known_bad_symbols_.insert(name);\n    return false;\n  }\n\n  return true;\n}\n\nbool DescriptorPool::TryFindExtensionInFallbackDatabase(\n    const Descriptor* containing_type, int field_number) const {\n  if (fallback_database_ == NULL) return false;\n\n  FileDescriptorProto file_proto;\n  if (!fallback_database_->FindFileContainingExtension(\n        containing_type->full_name(), field_number, &file_proto)) {\n    return false;\n  }\n\n  if (tables_->FindFile(file_proto.name()) != NULL) {\n    // We've already loaded this file, and it apparently doesn't contain the\n    // extension we're looking for.  Some DescriptorDatabases return false\n    // positives.\n    return false;\n  }\n\n  if (BuildFileFromDatabase(file_proto) == NULL) {\n    return false;\n  }\n\n  return true;\n}\n\n// ===================================================================\n\nbool FieldDescriptor::is_map() const {\n  return type() == TYPE_MESSAGE && message_type()->options().map_entry();\n}\n\nstring FieldDescriptor::DefaultValueAsString(bool quote_string_type) const {\n  GOOGLE_CHECK(has_default_value()) << \"No default value\";\n  switch (cpp_type()) {\n    case CPPTYPE_INT32:\n      return SimpleItoa(default_value_int32());\n      break;\n    case CPPTYPE_INT64:\n      return SimpleItoa(default_value_int64());\n      break;\n    case CPPTYPE_UINT32:\n      return SimpleItoa(default_value_uint32());\n      break;\n    case CPPTYPE_UINT64:\n      return SimpleItoa(default_value_uint64());\n      break;\n    case CPPTYPE_FLOAT:\n      return SimpleFtoa(default_value_float());\n      break;\n    case CPPTYPE_DOUBLE:\n      return SimpleDtoa(default_value_double());\n      break;\n    case CPPTYPE_BOOL:\n      return default_value_bool() ? \"true\" : \"false\";\n      break;\n    case CPPTYPE_STRING:\n      if (quote_string_type) {\n        return \"\\\"\" + CEscape(default_value_string()) + \"\\\"\";\n      } else {\n        if (type() == TYPE_BYTES) {\n          return CEscape(default_value_string());\n        } else {\n          return default_value_string();\n        }\n      }\n      break;\n    case CPPTYPE_ENUM:\n      return default_value_enum()->name();\n      break;\n    case CPPTYPE_MESSAGE:\n      GOOGLE_LOG(DFATAL) << \"Messages can't have default values!\";\n      break;\n  }\n  GOOGLE_LOG(FATAL) << \"Can't get here: failed to get default value as string\";\n  return \"\";\n}\n\n// CopyTo methods ====================================================\n\nvoid FileDescriptor::CopyTo(FileDescriptorProto* proto) const {\n  proto->set_name(name());\n  if (!package().empty()) proto->set_package(package());\n  // TODO(liujisi): Also populate when syntax=\"proto2\".\n  if (syntax() == SYNTAX_PROTO3) proto->set_syntax(SyntaxName(syntax()));\n\n  for (int i = 0; i < dependency_count(); i++) {\n    proto->add_dependency(dependency(i)->name());\n  }\n\n  for (int i = 0; i < public_dependency_count(); i++) {\n    proto->add_public_dependency(public_dependencies_[i]);\n  }\n\n  for (int i = 0; i < weak_dependency_count(); i++) {\n    proto->add_weak_dependency(weak_dependencies_[i]);\n  }\n\n  for (int i = 0; i < message_type_count(); i++) {\n    message_type(i)->CopyTo(proto->add_message_type());\n  }\n  for (int i = 0; i < enum_type_count(); i++) {\n    enum_type(i)->CopyTo(proto->add_enum_type());\n  }\n  for (int i = 0; i < service_count(); i++) {\n    service(i)->CopyTo(proto->add_service());\n  }\n  for (int i = 0; i < extension_count(); i++) {\n    extension(i)->CopyTo(proto->add_extension());\n  }\n\n  if (&options() != &FileOptions::default_instance()) {\n    proto->mutable_options()->CopyFrom(options());\n  }\n}\n\nvoid FileDescriptor::CopyJsonNameTo(FileDescriptorProto* proto) const {\n  if (message_type_count() != proto->message_type_size() ||\n      extension_count() != proto->extension_size()) {\n    GOOGLE_LOG(ERROR) << \"Cannot copy json_name to a proto of a different size.\";\n    return;\n  }\n  for (int i = 0; i < message_type_count(); i++) {\n    message_type(i)->CopyJsonNameTo(proto->mutable_message_type(i));\n  }\n  for (int i = 0; i < extension_count(); i++) {\n    extension(i)->CopyJsonNameTo(proto->mutable_extension(i));\n  }\n}\n\nvoid FileDescriptor::CopySourceCodeInfoTo(FileDescriptorProto* proto) const {\n  if (source_code_info_ &&\n      source_code_info_ != &SourceCodeInfo::default_instance()) {\n    proto->mutable_source_code_info()->CopyFrom(*source_code_info_);\n  }\n}\n\nvoid Descriptor::CopyTo(DescriptorProto* proto) const {\n  proto->set_name(name());\n\n  for (int i = 0; i < field_count(); i++) {\n    field(i)->CopyTo(proto->add_field());\n  }\n  for (int i = 0; i < oneof_decl_count(); i++) {\n    oneof_decl(i)->CopyTo(proto->add_oneof_decl());\n  }\n  for (int i = 0; i < nested_type_count(); i++) {\n    nested_type(i)->CopyTo(proto->add_nested_type());\n  }\n  for (int i = 0; i < enum_type_count(); i++) {\n    enum_type(i)->CopyTo(proto->add_enum_type());\n  }\n  for (int i = 0; i < extension_range_count(); i++) {\n    DescriptorProto::ExtensionRange* range = proto->add_extension_range();\n    range->set_start(extension_range(i)->start);\n    range->set_end(extension_range(i)->end);\n  }\n  for (int i = 0; i < extension_count(); i++) {\n    extension(i)->CopyTo(proto->add_extension());\n  }\n  for (int i = 0; i < reserved_range_count(); i++) {\n    DescriptorProto::ReservedRange* range = proto->add_reserved_range();\n    range->set_start(reserved_range(i)->start);\n    range->set_end(reserved_range(i)->end);\n  }\n  for (int i = 0; i < reserved_name_count(); i++) {\n    proto->add_reserved_name(reserved_name(i));\n  }\n\n  if (&options() != &MessageOptions::default_instance()) {\n    proto->mutable_options()->CopyFrom(options());\n  }\n}\n\nvoid Descriptor::CopyJsonNameTo(DescriptorProto* proto) const {\n  if (field_count() != proto->field_size() ||\n      nested_type_count() != proto->nested_type_size() ||\n      extension_count() != proto->extension_size()) {\n    GOOGLE_LOG(ERROR) << \"Cannot copy json_name to a proto of a different size.\";\n    return;\n  }\n  for (int i = 0; i < field_count(); i++) {\n    field(i)->CopyJsonNameTo(proto->mutable_field(i));\n  }\n  for (int i = 0; i < nested_type_count(); i++) {\n    nested_type(i)->CopyJsonNameTo(proto->mutable_nested_type(i));\n  }\n  for (int i = 0; i < extension_count(); i++) {\n    extension(i)->CopyJsonNameTo(proto->mutable_extension(i));\n  }\n}\n\nvoid FieldDescriptor::CopyTo(FieldDescriptorProto* proto) const {\n  proto->set_name(name());\n  proto->set_number(number());\n  if (has_json_name_) {\n    proto->set_json_name(json_name());\n  }\n\n  // Some compilers do not allow static_cast directly between two enum types,\n  // so we must cast to int first.\n  proto->set_label(static_cast<FieldDescriptorProto::Label>(\n                     implicit_cast<int>(label())));\n  proto->set_type(static_cast<FieldDescriptorProto::Type>(\n                    implicit_cast<int>(type())));\n\n  if (is_extension()) {\n    if (!containing_type()->is_unqualified_placeholder_) {\n      proto->set_extendee(\".\");\n    }\n    proto->mutable_extendee()->append(containing_type()->full_name());\n  }\n\n  if (cpp_type() == CPPTYPE_MESSAGE) {\n    if (message_type()->is_placeholder_) {\n      // We don't actually know if the type is a message type.  It could be\n      // an enum.\n      proto->clear_type();\n    }\n\n    if (!message_type()->is_unqualified_placeholder_) {\n      proto->set_type_name(\".\");\n    }\n    proto->mutable_type_name()->append(message_type()->full_name());\n  } else if (cpp_type() == CPPTYPE_ENUM) {\n    if (!enum_type()->is_unqualified_placeholder_) {\n      proto->set_type_name(\".\");\n    }\n    proto->mutable_type_name()->append(enum_type()->full_name());\n  }\n\n  if (has_default_value()) {\n    proto->set_default_value(DefaultValueAsString(false));\n  }\n\n  if (containing_oneof() != NULL && !is_extension()) {\n    proto->set_oneof_index(containing_oneof()->index());\n  }\n\n  if (&options() != &FieldOptions::default_instance()) {\n    proto->mutable_options()->CopyFrom(options());\n  }\n}\n\nvoid FieldDescriptor::CopyJsonNameTo(FieldDescriptorProto* proto) const {\n  proto->set_json_name(json_name());\n}\n\nvoid OneofDescriptor::CopyTo(OneofDescriptorProto* proto) const {\n  proto->set_name(name());\n  if (&options() != &OneofOptions::default_instance()) {\n    proto->mutable_options()->CopyFrom(options());\n  }\n}\n\nvoid EnumDescriptor::CopyTo(EnumDescriptorProto* proto) const {\n  proto->set_name(name());\n\n  for (int i = 0; i < value_count(); i++) {\n    value(i)->CopyTo(proto->add_value());\n  }\n\n  if (&options() != &EnumOptions::default_instance()) {\n    proto->mutable_options()->CopyFrom(options());\n  }\n}\n\nvoid EnumValueDescriptor::CopyTo(EnumValueDescriptorProto* proto) const {\n  proto->set_name(name());\n  proto->set_number(number());\n\n  if (&options() != &EnumValueOptions::default_instance()) {\n    proto->mutable_options()->CopyFrom(options());\n  }\n}\n\nvoid ServiceDescriptor::CopyTo(ServiceDescriptorProto* proto) const {\n  proto->set_name(name());\n\n  for (int i = 0; i < method_count(); i++) {\n    method(i)->CopyTo(proto->add_method());\n  }\n\n  if (&options() != &ServiceOptions::default_instance()) {\n    proto->mutable_options()->CopyFrom(options());\n  }\n}\n\nvoid MethodDescriptor::CopyTo(MethodDescriptorProto* proto) const {\n  proto->set_name(name());\n\n  if (!input_type()->is_unqualified_placeholder_) {\n    proto->set_input_type(\".\");\n  }\n  proto->mutable_input_type()->append(input_type()->full_name());\n\n  if (!output_type()->is_unqualified_placeholder_) {\n    proto->set_output_type(\".\");\n  }\n  proto->mutable_output_type()->append(output_type()->full_name());\n\n  if (&options() != &MethodOptions::default_instance()) {\n    proto->mutable_options()->CopyFrom(options());\n  }\n\n  if (client_streaming_) {\n    proto->set_client_streaming(true);\n  }\n  if (server_streaming_) {\n    proto->set_server_streaming(true);\n  }\n}\n\n// DebugString methods ===============================================\n\nnamespace {\n\n// Used by each of the option formatters.\nbool RetrieveOptions(int depth,\n                     const Message &options,\n                     vector<string> *option_entries) {\n  option_entries->clear();\n  const Reflection* reflection = options.GetReflection();\n  vector<const FieldDescriptor*> fields;\n  reflection->ListFields(options, &fields);\n  for (int i = 0; i < fields.size(); i++) {\n    int count = 1;\n    bool repeated = false;\n    if (fields[i]->is_repeated()) {\n      count = reflection->FieldSize(options, fields[i]);\n      repeated = true;\n    }\n    for (int j = 0; j < count; j++) {\n      string fieldval;\n      if (fields[i]->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n        string tmp;\n        TextFormat::Printer printer;\n        printer.SetInitialIndentLevel(depth + 1);\n        printer.PrintFieldValueToString(options, fields[i],\n                                        repeated ? j : -1, &tmp);\n        fieldval.append(\"{\\n\");\n        fieldval.append(tmp);\n        fieldval.append(depth * 2, ' ');\n        fieldval.append(\"}\");\n      } else {\n        TextFormat::PrintFieldValueToString(options, fields[i],\n                                            repeated ? j : -1, &fieldval);\n      }\n      string name;\n      if (fields[i]->is_extension()) {\n        name = \"(.\" + fields[i]->full_name() + \")\";\n      } else {\n        name = fields[i]->name();\n      }\n      option_entries->push_back(name + \" = \" + fieldval);\n    }\n  }\n  return !option_entries->empty();\n}\n\n// Formats options that all appear together in brackets. Does not include\n// brackets.\nbool FormatBracketedOptions(int depth, const Message &options, string *output) {\n  vector<string> all_options;\n  if (RetrieveOptions(depth, options, &all_options)) {\n    output->append(Join(all_options, \", \"));\n  }\n  return !all_options.empty();\n}\n\n// Formats options one per line\nbool FormatLineOptions(int depth, const Message &options, string *output) {\n  string prefix(depth * 2, ' ');\n  vector<string> all_options;\n  if (RetrieveOptions(depth, options, &all_options)) {\n    for (int i = 0; i < all_options.size(); i++) {\n      strings::SubstituteAndAppend(output, \"$0option $1;\\n\",\n                                   prefix, all_options[i]);\n    }\n  }\n  return !all_options.empty();\n}\n\nclass SourceLocationCommentPrinter {\n public:\n  template<typename DescType>\n  SourceLocationCommentPrinter(const DescType* desc,\n                               const string& prefix,\n                               const DebugStringOptions& options)\n      : options_(options), prefix_(prefix) {\n    // Perform the SourceLocation lookup only if we're including user comments,\n    // because the lookup is fairly expensive.\n    have_source_loc_ = options.include_comments &&\n        desc->GetSourceLocation(&source_loc_);\n  }\n  SourceLocationCommentPrinter(const FileDescriptor* file,\n                               const vector<int>& path,\n                               const string& prefix,\n                               const DebugStringOptions& options)\n      : options_(options), prefix_(prefix) {\n    // Perform the SourceLocation lookup only if we're including user comments,\n    // because the lookup is fairly expensive.\n    have_source_loc_ = options.include_comments &&\n        file->GetSourceLocation(path, &source_loc_);\n  }\n  void AddPreComment(string* output) {\n    if (have_source_loc_) {\n      // Detached leading comments.\n      for (int i = 0 ; i < source_loc_.leading_detached_comments.size(); ++i) {\n        *output += FormatComment(source_loc_.leading_detached_comments[i]);\n        *output += \"\\n\";\n      }\n      // Attached leading comments.\n      if (!source_loc_.leading_comments.empty()) {\n        *output += FormatComment(source_loc_.leading_comments);\n      }\n    }\n  }\n  void AddPostComment(string* output) {\n    if (have_source_loc_ && source_loc_.trailing_comments.size() > 0) {\n      *output += FormatComment(source_loc_.trailing_comments);\n    }\n  }\n\n  // Format comment such that each line becomes a full-line C++-style comment in\n  // the DebugString() output.\n  string FormatComment(const string& comment_text) {\n    string stripped_comment = comment_text;\n    StripWhitespace(&stripped_comment);\n    vector<string> lines = Split(stripped_comment, \"\\n\");\n    string output;\n    for (int i = 0; i < lines.size(); ++i) {\n      const string& line = lines[i];\n      strings::SubstituteAndAppend(&output, \"$0// $1\\n\", prefix_, line);\n    }\n    return output;\n  }\n\n private:\n\n  bool have_source_loc_;\n  SourceLocation source_loc_;\n  DebugStringOptions options_;\n  string prefix_;\n};\n\n}  // anonymous namespace\n\nstring FileDescriptor::DebugString() const {\n  DebugStringOptions options;  // default options\n  return DebugStringWithOptions(options);\n}\n\nstring FileDescriptor::DebugStringWithOptions(\n    const DebugStringOptions& debug_string_options) const {\n  string contents;\n  {\n    vector<int> path;\n    path.push_back(FileDescriptorProto::kSyntaxFieldNumber);\n    SourceLocationCommentPrinter syntax_comment(\n        this, path, \"\", debug_string_options);\n    syntax_comment.AddPreComment(&contents);\n    strings::SubstituteAndAppend(&contents, \"syntax = \\\"$0\\\";\\n\\n\",\n                                 SyntaxName(syntax()));\n    syntax_comment.AddPostComment(&contents);\n  }\n\n  SourceLocationCommentPrinter\n      comment_printer(this, \"\", debug_string_options);\n  comment_printer.AddPreComment(&contents);\n\n  set<int> public_dependencies;\n  set<int> weak_dependencies;\n  public_dependencies.insert(public_dependencies_,\n                             public_dependencies_ + public_dependency_count_);\n  weak_dependencies.insert(weak_dependencies_,\n                           weak_dependencies_ + weak_dependency_count_);\n\n  for (int i = 0; i < dependency_count(); i++) {\n    if (public_dependencies.count(i) > 0) {\n      strings::SubstituteAndAppend(&contents, \"import public \\\"$0\\\";\\n\",\n                                   dependency(i)->name());\n    } else if (weak_dependencies.count(i) > 0) {\n      strings::SubstituteAndAppend(&contents, \"import weak \\\"$0\\\";\\n\",\n                                   dependency(i)->name());\n    } else {\n      strings::SubstituteAndAppend(&contents, \"import \\\"$0\\\";\\n\",\n                                   dependency(i)->name());\n    }\n  }\n\n  if (!package().empty()) {\n    vector<int> path;\n    path.push_back(FileDescriptorProto::kPackageFieldNumber);\n    SourceLocationCommentPrinter package_comment(\n        this, path, \"\", debug_string_options);\n    package_comment.AddPreComment(&contents);\n    strings::SubstituteAndAppend(&contents, \"package $0;\\n\\n\", package());\n    package_comment.AddPostComment(&contents);\n  }\n\n  if (FormatLineOptions(0, options(), &contents)) {\n    contents.append(\"\\n\");  // add some space if we had options\n  }\n\n  for (int i = 0; i < enum_type_count(); i++) {\n    enum_type(i)->DebugString(0, &contents, debug_string_options);\n    contents.append(\"\\n\");\n  }\n\n  // Find all the 'group' type extensions; we will not output their nested\n  // definitions (those will be done with their group field descriptor).\n  set<const Descriptor*> groups;\n  for (int i = 0; i < extension_count(); i++) {\n    if (extension(i)->type() == FieldDescriptor::TYPE_GROUP) {\n      groups.insert(extension(i)->message_type());\n    }\n  }\n\n  for (int i = 0; i < message_type_count(); i++) {\n    if (groups.count(message_type(i)) == 0) {\n      message_type(i)->DebugString(0, &contents, debug_string_options,\n                                   /* include_opening_clause */ true);\n      contents.append(\"\\n\");\n    }\n  }\n\n  for (int i = 0; i < service_count(); i++) {\n    service(i)->DebugString(&contents, debug_string_options);\n    contents.append(\"\\n\");\n  }\n\n  const Descriptor* containing_type = NULL;\n  for (int i = 0; i < extension_count(); i++) {\n    if (extension(i)->containing_type() != containing_type) {\n      if (i > 0) contents.append(\"}\\n\\n\");\n      containing_type = extension(i)->containing_type();\n      strings::SubstituteAndAppend(&contents, \"extend .$0 {\\n\",\n                                   containing_type->full_name());\n    }\n    extension(i)->DebugString(1, FieldDescriptor::PRINT_LABEL, &contents,\n                              debug_string_options);\n  }\n  if (extension_count() > 0) contents.append(\"}\\n\\n\");\n\n  comment_printer.AddPostComment(&contents);\n\n  return contents;\n}\n\nstring Descriptor::DebugString() const {\n  DebugStringOptions options;  // default options\n  return DebugStringWithOptions(options);\n}\n\nstring Descriptor::DebugStringWithOptions(\n    const DebugStringOptions& options) const {\n  string contents;\n  DebugString(0, &contents, options, /* include_opening_clause */ true);\n  return contents;\n}\n\nvoid Descriptor::DebugString(int depth, string *contents,\n                             const DebugStringOptions&\n                             debug_string_options,\n                             bool include_opening_clause) const {\n  if (options().map_entry()) {\n    // Do not generate debug string for auto-generated map-entry type.\n    return;\n  }\n  string prefix(depth * 2, ' ');\n  ++depth;\n\n  SourceLocationCommentPrinter\n      comment_printer(this, prefix, debug_string_options);\n  comment_printer.AddPreComment(contents);\n\n  if (include_opening_clause) {\n    strings::SubstituteAndAppend(contents, \"$0message $1\", prefix, name());\n  }\n  contents->append(\" {\\n\");\n\n  FormatLineOptions(depth, options(), contents);\n\n  // Find all the 'group' types for fields and extensions; we will not output\n  // their nested definitions (those will be done with their group field\n  // descriptor).\n  set<const Descriptor*> groups;\n  for (int i = 0; i < field_count(); i++) {\n    if (field(i)->type() == FieldDescriptor::TYPE_GROUP) {\n      groups.insert(field(i)->message_type());\n    }\n  }\n  for (int i = 0; i < extension_count(); i++) {\n    if (extension(i)->type() == FieldDescriptor::TYPE_GROUP) {\n      groups.insert(extension(i)->message_type());\n    }\n  }\n\n  for (int i = 0; i < nested_type_count(); i++) {\n    if (groups.count(nested_type(i)) == 0) {\n      nested_type(i)->DebugString(depth, contents, debug_string_options,\n                                  /* include_opening_clause */ true);\n    }\n  }\n  for (int i = 0; i < enum_type_count(); i++) {\n    enum_type(i)->DebugString(depth, contents, debug_string_options);\n  }\n  for (int i = 0; i < field_count(); i++) {\n    if (field(i)->containing_oneof() == NULL) {\n      field(i)->DebugString(depth, FieldDescriptor::PRINT_LABEL, contents,\n                            debug_string_options);\n    } else if (field(i)->containing_oneof()->field(0) == field(i)) {\n      // This is the first field in this oneof, so print the whole oneof.\n      field(i)->containing_oneof()->DebugString(depth, contents,\n                                                debug_string_options);\n    }\n  }\n\n  for (int i = 0; i < extension_range_count(); i++) {\n    strings::SubstituteAndAppend(contents, \"$0  extensions $1 to $2;\\n\",\n                                 prefix,\n                                 extension_range(i)->start,\n                                 extension_range(i)->end - 1);\n  }\n\n  // Group extensions by what they extend, so they can be printed out together.\n  const Descriptor* containing_type = NULL;\n  for (int i = 0; i < extension_count(); i++) {\n    if (extension(i)->containing_type() != containing_type) {\n      if (i > 0) strings::SubstituteAndAppend(contents, \"$0  }\\n\", prefix);\n      containing_type = extension(i)->containing_type();\n      strings::SubstituteAndAppend(contents, \"$0  extend .$1 {\\n\",\n                                   prefix, containing_type->full_name());\n    }\n    extension(i)->DebugString(\n        depth + 1, FieldDescriptor::PRINT_LABEL, contents,\n        debug_string_options);\n  }\n  if (extension_count() > 0)\n    strings::SubstituteAndAppend(contents, \"$0  }\\n\", prefix);\n\n  if (reserved_range_count() > 0) {\n    strings::SubstituteAndAppend(contents, \"$0  reserved \", prefix);\n    for (int i = 0; i < reserved_range_count(); i++) {\n      const Descriptor::ReservedRange* range = reserved_range(i);\n      if (range->end == range->start + 1) {\n        strings::SubstituteAndAppend(contents, \"$0, \", range->start);\n      } else {\n        strings::SubstituteAndAppend(contents, \"$0 to $1, \",\n                                     range->start, range->end - 1);\n      }\n    }\n    contents->replace(contents->size() - 2, 2, \";\\n\");\n  }\n\n  if (reserved_name_count() > 0) {\n    strings::SubstituteAndAppend(contents, \"$0  reserved \", prefix);\n    for (int i = 0; i < reserved_name_count(); i++) {\n      strings::SubstituteAndAppend(contents, \"\\\"$0\\\", \",\n                                   CEscape(reserved_name(i)));\n    }\n    contents->replace(contents->size() - 2, 2, \";\\n\");\n  }\n\n  strings::SubstituteAndAppend(contents, \"$0}\\n\", prefix);\n  comment_printer.AddPostComment(contents);\n}\n\nstring FieldDescriptor::DebugString() const {\n  DebugStringOptions options;  // default options\n  return DebugStringWithOptions(options);\n}\n\nstring FieldDescriptor::DebugStringWithOptions(\n    const DebugStringOptions& debug_string_options) const {\n  string contents;\n  int depth = 0;\n  if (is_extension()) {\n    strings::SubstituteAndAppend(&contents, \"extend .$0 {\\n\",\n                                 containing_type()->full_name());\n    depth = 1;\n  }\n  DebugString(depth, PRINT_LABEL, &contents, debug_string_options);\n  if (is_extension()) {\n    contents.append(\"}\\n\");\n  }\n  return contents;\n}\n\n// The field type string used in FieldDescriptor::DebugString()\nstring FieldDescriptor::FieldTypeNameDebugString() const {\n  switch(type()) {\n    case TYPE_MESSAGE:\n      return \".\" + message_type()->full_name();\n    case TYPE_ENUM:\n      return \".\" + enum_type()->full_name();\n    default:\n      return kTypeToName[type()];\n  }\n}\n\nvoid FieldDescriptor::DebugString(int depth,\n                                  PrintLabelFlag print_label_flag,\n                                  string *contents,\n                                  const DebugStringOptions&\n                                  debug_string_options) const {\n  string prefix(depth * 2, ' ');\n  string field_type;\n\n  // Special case map fields.\n  if (is_map()) {\n    strings::SubstituteAndAppend(\n        &field_type, \"map<$0, $1>\",\n        message_type()->field(0)->FieldTypeNameDebugString(),\n        message_type()->field(1)->FieldTypeNameDebugString());\n  } else {\n    field_type = FieldTypeNameDebugString();\n  }\n\n  string label;\n  if (print_label_flag == PRINT_LABEL && !is_map()) {\n    label = kLabelToName[this->label()];\n    label.push_back(' ');\n  }\n\n  SourceLocationCommentPrinter\n      comment_printer(this, prefix, debug_string_options);\n  comment_printer.AddPreComment(contents);\n\n  strings::SubstituteAndAppend(contents, \"$0$1$2 $3 = $4\",\n                               prefix,\n                               label,\n                               field_type,\n                               type() == TYPE_GROUP ? message_type()->name() :\n                                                      name(),\n                               number());\n\n  bool bracketed = false;\n  if (has_default_value()) {\n    bracketed = true;\n    strings::SubstituteAndAppend(contents, \" [default = $0\",\n                                 DefaultValueAsString(true));\n  }\n\n  string formatted_options;\n  if (FormatBracketedOptions(depth, options(), &formatted_options)) {\n    contents->append(bracketed ? \", \" : \" [\");\n    bracketed = true;\n    contents->append(formatted_options);\n  }\n\n  if (bracketed) {\n    contents->append(\"]\");\n  }\n\n  if (type() == TYPE_GROUP) {\n    if (debug_string_options.elide_group_body) {\n      contents->append(\" { ... };\\n\");\n    } else {\n      message_type()->DebugString(depth, contents, debug_string_options,\n                                  /* include_opening_clause */ false);\n    }\n  } else {\n    contents->append(\";\\n\");\n  }\n\n  comment_printer.AddPostComment(contents);\n}\n\nstring OneofDescriptor::DebugString() const {\n  DebugStringOptions options;  // default values\n  return DebugStringWithOptions(options);\n}\n\nstring OneofDescriptor::DebugStringWithOptions(\n    const DebugStringOptions& options) const {\n  string contents;\n  DebugString(0, &contents, options);\n  return contents;\n}\n\nvoid OneofDescriptor::DebugString(int depth, string* contents,\n                                  const DebugStringOptions&\n                                  debug_string_options) const {\n  string prefix(depth * 2, ' ');\n  ++depth;\n  SourceLocationCommentPrinter\n      comment_printer(this, prefix, debug_string_options);\n  comment_printer.AddPreComment(contents);\n  strings::SubstituteAndAppend(\n      contents, \"$0 oneof $1 {\", prefix, name());\n\n  FormatLineOptions(depth, options(), contents);\n\n  if (debug_string_options.elide_oneof_body) {\n    contents->append(\" ... }\\n\");\n  } else {\n    for (int i = 0; i < field_count(); i++) {\n      field(i)->DebugString(depth, FieldDescriptor::OMIT_LABEL, contents,\n                            debug_string_options);\n    }\n    strings::SubstituteAndAppend(contents, \"$0}\\n\", prefix);\n  }\n  comment_printer.AddPostComment(contents);\n}\n\nstring EnumDescriptor::DebugString() const {\n  DebugStringOptions options;  // default values\n  return DebugStringWithOptions(options);\n}\n\nstring EnumDescriptor::DebugStringWithOptions(\n    const DebugStringOptions& options) const {\n  string contents;\n  DebugString(0, &contents, options);\n  return contents;\n}\n\nvoid EnumDescriptor::DebugString(int depth, string *contents,\n                                 const DebugStringOptions&\n                                 debug_string_options) const {\n  string prefix(depth * 2, ' ');\n  ++depth;\n\n  SourceLocationCommentPrinter\n      comment_printer(this, prefix, debug_string_options);\n  comment_printer.AddPreComment(contents);\n\n  strings::SubstituteAndAppend(contents, \"$0enum $1 {\\n\",\n                               prefix, name());\n\n  FormatLineOptions(depth, options(), contents);\n\n  for (int i = 0; i < value_count(); i++) {\n    value(i)->DebugString(depth, contents, debug_string_options);\n  }\n  strings::SubstituteAndAppend(contents, \"$0}\\n\", prefix);\n\n  comment_printer.AddPostComment(contents);\n}\n\nstring EnumValueDescriptor::DebugString() const {\n  DebugStringOptions options;  // default values\n  return DebugStringWithOptions(options);\n}\n\nstring EnumValueDescriptor::DebugStringWithOptions(\n    const DebugStringOptions& options) const {\n  string contents;\n  DebugString(0, &contents, options);\n  return contents;\n}\n\nvoid EnumValueDescriptor::DebugString(int depth, string *contents,\n                                      const DebugStringOptions&\n                                      debug_string_options) const {\n  string prefix(depth * 2, ' ');\n\n  SourceLocationCommentPrinter\n      comment_printer(this, prefix, debug_string_options);\n  comment_printer.AddPreComment(contents);\n\n  strings::SubstituteAndAppend(contents, \"$0$1 = $2\",\n                               prefix, name(), number());\n\n  string formatted_options;\n  if (FormatBracketedOptions(depth, options(), &formatted_options)) {\n    strings::SubstituteAndAppend(contents, \" [$0]\", formatted_options);\n  }\n  contents->append(\";\\n\");\n\n  comment_printer.AddPostComment(contents);\n}\n\nstring ServiceDescriptor::DebugString() const {\n  DebugStringOptions options;  // default values\n  return DebugStringWithOptions(options);\n}\n\nstring ServiceDescriptor::DebugStringWithOptions(\n    const DebugStringOptions& options) const {\n  string contents;\n  DebugString(&contents, options);\n  return contents;\n}\n\nvoid ServiceDescriptor::DebugString(string *contents,\n                                    const DebugStringOptions&\n                                    debug_string_options) const {\n  SourceLocationCommentPrinter\n      comment_printer(this, /* prefix */ \"\", debug_string_options);\n  comment_printer.AddPreComment(contents);\n\n  strings::SubstituteAndAppend(contents, \"service $0 {\\n\", name());\n\n  FormatLineOptions(1, options(), contents);\n\n  for (int i = 0; i < method_count(); i++) {\n    method(i)->DebugString(1, contents, debug_string_options);\n  }\n\n  contents->append(\"}\\n\");\n\n  comment_printer.AddPostComment(contents);\n}\n\nstring MethodDescriptor::DebugString() const {\n  DebugStringOptions options;  // default values\n  return DebugStringWithOptions(options);\n}\n\nstring MethodDescriptor::DebugStringWithOptions(\n    const DebugStringOptions& options) const {\n  string contents;\n  DebugString(0, &contents, options);\n  return contents;\n}\n\nvoid MethodDescriptor::DebugString(int depth, string *contents,\n                                   const DebugStringOptions&\n                                   debug_string_options) const {\n  string prefix(depth * 2, ' ');\n  ++depth;\n\n  SourceLocationCommentPrinter\n      comment_printer(this, prefix, debug_string_options);\n  comment_printer.AddPreComment(contents);\n\n  strings::SubstituteAndAppend(contents, \"$0rpc $1($4.$2) returns ($5.$3)\",\n                               prefix, name(),\n                               input_type()->full_name(),\n                               output_type()->full_name(),\n                               client_streaming() ? \"stream \" : \"\",\n                               server_streaming() ? \"stream \" : \"\");\n\n  string formatted_options;\n  if (FormatLineOptions(depth, options(), &formatted_options)) {\n    strings::SubstituteAndAppend(contents, \" {\\n$0$1}\\n\",\n                                 formatted_options, prefix);\n  } else {\n    contents->append(\";\\n\");\n  }\n\n  comment_printer.AddPostComment(contents);\n}\n\n\n// Location methods ===============================================\n\nbool FileDescriptor::GetSourceLocation(const vector<int>& path,\n                                       SourceLocation* out_location) const {\n  GOOGLE_CHECK_NOTNULL(out_location);\n  if (source_code_info_) {\n    if (const SourceCodeInfo_Location* loc =\n        tables_->GetSourceLocation(path, source_code_info_)) {\n      const RepeatedField<int32>& span = loc->span();\n      if (span.size() == 3 || span.size() == 4) {\n        out_location->start_line   = span.Get(0);\n        out_location->start_column = span.Get(1);\n        out_location->end_line     = span.Get(span.size() == 3 ? 0 : 2);\n        out_location->end_column   = span.Get(span.size() - 1);\n\n        out_location->leading_comments = loc->leading_comments();\n        out_location->trailing_comments = loc->trailing_comments();\n        out_location->leading_detached_comments.assign(\n            loc->leading_detached_comments().begin(),\n            loc->leading_detached_comments().end());\n        return true;\n      }\n    }\n  }\n  return false;\n}\n\nbool FileDescriptor::GetSourceLocation(SourceLocation* out_location) const {\n  vector<int> path;  // empty path for root FileDescriptor\n  return GetSourceLocation(path, out_location);\n}\n\nbool FieldDescriptor::is_packed() const {\n  if (!is_packable()) return false;\n  if (file_->syntax() == FileDescriptor::SYNTAX_PROTO2) {\n    return (options_ != NULL) && options_->packed();\n  } else {\n    return options_ == NULL || !options_->has_packed() || options_->packed();\n  }\n}\n\nbool Descriptor::GetSourceLocation(SourceLocation* out_location) const {\n  vector<int> path;\n  GetLocationPath(&path);\n  return file()->GetSourceLocation(path, out_location);\n}\n\nbool FieldDescriptor::GetSourceLocation(SourceLocation* out_location) const {\n  vector<int> path;\n  GetLocationPath(&path);\n  return file()->GetSourceLocation(path, out_location);\n}\n\nbool OneofDescriptor::GetSourceLocation(SourceLocation* out_location) const {\n  vector<int> path;\n  GetLocationPath(&path);\n  return containing_type()->file()->GetSourceLocation(path, out_location);\n}\n\nbool EnumDescriptor::GetSourceLocation(SourceLocation* out_location) const {\n  vector<int> path;\n  GetLocationPath(&path);\n  return file()->GetSourceLocation(path, out_location);\n}\n\nbool MethodDescriptor::GetSourceLocation(SourceLocation* out_location) const {\n  vector<int> path;\n  GetLocationPath(&path);\n  return service()->file()->GetSourceLocation(path, out_location);\n}\n\nbool ServiceDescriptor::GetSourceLocation(SourceLocation* out_location) const {\n  vector<int> path;\n  GetLocationPath(&path);\n  return file()->GetSourceLocation(path, out_location);\n}\n\nbool EnumValueDescriptor::GetSourceLocation(\n    SourceLocation* out_location) const {\n  vector<int> path;\n  GetLocationPath(&path);\n  return type()->file()->GetSourceLocation(path, out_location);\n}\n\nvoid Descriptor::GetLocationPath(vector<int>* output) const {\n  if (containing_type()) {\n    containing_type()->GetLocationPath(output);\n    output->push_back(DescriptorProto::kNestedTypeFieldNumber);\n    output->push_back(index());\n  } else {\n    output->push_back(FileDescriptorProto::kMessageTypeFieldNumber);\n    output->push_back(index());\n  }\n}\n\nvoid FieldDescriptor::GetLocationPath(vector<int>* output) const {\n  if (is_extension()) {\n    if (extension_scope() == NULL) {\n      output->push_back(FileDescriptorProto::kExtensionFieldNumber);\n      output->push_back(index());\n    } else {\n      extension_scope()->GetLocationPath(output);\n      output->push_back(DescriptorProto::kExtensionFieldNumber);\n      output->push_back(index());\n    }\n  } else {\n    containing_type()->GetLocationPath(output);\n    output->push_back(DescriptorProto::kFieldFieldNumber);\n    output->push_back(index());\n  }\n}\n\nvoid OneofDescriptor::GetLocationPath(vector<int>* output) const {\n  containing_type()->GetLocationPath(output);\n  output->push_back(DescriptorProto::kOneofDeclFieldNumber);\n  output->push_back(index());\n}\n\nvoid EnumDescriptor::GetLocationPath(vector<int>* output) const {\n  if (containing_type()) {\n    containing_type()->GetLocationPath(output);\n    output->push_back(DescriptorProto::kEnumTypeFieldNumber);\n    output->push_back(index());\n  } else {\n    output->push_back(FileDescriptorProto::kEnumTypeFieldNumber);\n    output->push_back(index());\n  }\n}\n\nvoid EnumValueDescriptor::GetLocationPath(vector<int>* output) const {\n  type()->GetLocationPath(output);\n  output->push_back(EnumDescriptorProto::kValueFieldNumber);\n  output->push_back(index());\n}\n\nvoid ServiceDescriptor::GetLocationPath(vector<int>* output) const {\n  output->push_back(FileDescriptorProto::kServiceFieldNumber);\n  output->push_back(index());\n}\n\nvoid MethodDescriptor::GetLocationPath(vector<int>* output) const {\n  service()->GetLocationPath(output);\n  output->push_back(ServiceDescriptorProto::kMethodFieldNumber);\n  output->push_back(index());\n}\n\n// ===================================================================\n\nnamespace {\n\n// Represents an options message to interpret. Extension names in the option\n// name are resolved relative to name_scope. element_name and orig_opt are\n// used only for error reporting (since the parser records locations against\n// pointers in the original options, not the mutable copy). The Message must be\n// one of the Options messages in descriptor.proto.\nstruct OptionsToInterpret {\n  OptionsToInterpret(const string& ns,\n                     const string& el,\n                     const Message* orig_opt,\n                     Message* opt)\n      : name_scope(ns),\n        element_name(el),\n        original_options(orig_opt),\n        options(opt) {\n  }\n  string name_scope;\n  string element_name;\n  const Message* original_options;\n  Message* options;\n};\n\n}  // namespace\n\nclass DescriptorBuilder {\n public:\n  DescriptorBuilder(const DescriptorPool* pool,\n                    DescriptorPool::Tables* tables,\n                    DescriptorPool::ErrorCollector* error_collector);\n  ~DescriptorBuilder();\n\n  const FileDescriptor* BuildFile(const FileDescriptorProto& proto);\n\n private:\n  friend class OptionInterpreter;\n\n  // Non-recursive part of BuildFile functionality.\n  const FileDescriptor* BuildFileImpl(const FileDescriptorProto& proto);\n\n  const DescriptorPool* pool_;\n  DescriptorPool::Tables* tables_;  // for convenience\n  DescriptorPool::ErrorCollector* error_collector_;\n\n  // As we build descriptors we store copies of the options messages in\n  // them. We put pointers to those copies in this vector, as we build, so we\n  // can later (after cross-linking) interpret those options.\n  vector<OptionsToInterpret> options_to_interpret_;\n\n  bool had_errors_;\n  string filename_;\n  FileDescriptor* file_;\n  FileDescriptorTables* file_tables_;\n  set<const FileDescriptor*> dependencies_;\n\n  // unused_dependency_ is used to record the unused imported files.\n  // Note: public import is not considered.\n  set<const FileDescriptor*> unused_dependency_;\n\n  // If LookupSymbol() finds a symbol that is in a file which is not a declared\n  // dependency of this file, it will fail, but will set\n  // possible_undeclared_dependency_ to point at that file.  This is only used\n  // by AddNotDefinedError() to report a more useful error message.\n  // possible_undeclared_dependency_name_ is the name of the symbol that was\n  // actually found in possible_undeclared_dependency_, which may be a parent\n  // of the symbol actually looked for.\n  const FileDescriptor* possible_undeclared_dependency_;\n  string possible_undeclared_dependency_name_;\n\n  // If LookupSymbol() could resolve a symbol which is not defined,\n  // record the resolved name.  This is only used by AddNotDefinedError()\n  // to report a more useful error message.\n  string undefine_resolved_name_;\n\n  void AddError(const string& element_name,\n                const Message& descriptor,\n                DescriptorPool::ErrorCollector::ErrorLocation location,\n                const string& error);\n  void AddError(const string& element_name,\n                const Message& descriptor,\n                DescriptorPool::ErrorCollector::ErrorLocation location,\n                const char* error);\n  void AddRecursiveImportError(const FileDescriptorProto& proto, int from_here);\n  void AddTwiceListedError(const FileDescriptorProto& proto, int index);\n  void AddImportError(const FileDescriptorProto& proto, int index);\n\n  // Adds an error indicating that undefined_symbol was not defined.  Must\n  // only be called after LookupSymbol() fails.\n  void AddNotDefinedError(\n    const string& element_name,\n    const Message& descriptor,\n    DescriptorPool::ErrorCollector::ErrorLocation location,\n    const string& undefined_symbol);\n\n  void AddWarning(const string& element_name, const Message& descriptor,\n                  DescriptorPool::ErrorCollector::ErrorLocation location,\n                  const string& error);\n\n  // Silly helper which determines if the given file is in the given package.\n  // I.e., either file->package() == package_name or file->package() is a\n  // nested package within package_name.\n  bool IsInPackage(const FileDescriptor* file, const string& package_name);\n\n  // Helper function which finds all public dependencies of the given file, and\n  // stores the them in the dependencies_ set in the builder.\n  void RecordPublicDependencies(const FileDescriptor* file);\n\n  // Like tables_->FindSymbol(), but additionally:\n  // - Search the pool's underlay if not found in tables_.\n  // - Insure that the resulting Symbol is from one of the file's declared\n  //   dependencies.\n  Symbol FindSymbol(const string& name);\n\n  // Like FindSymbol() but does not require that the symbol is in one of the\n  // file's declared dependencies.\n  Symbol FindSymbolNotEnforcingDeps(const string& name);\n\n  // This implements the body of FindSymbolNotEnforcingDeps().\n  Symbol FindSymbolNotEnforcingDepsHelper(const DescriptorPool* pool,\n                                          const string& name);\n\n  // Like FindSymbol(), but looks up the name relative to some other symbol\n  // name.  This first searches siblings of relative_to, then siblings of its\n  // parents, etc.  For example, LookupSymbol(\"foo.bar\", \"baz.qux.corge\") makes\n  // the following calls, returning the first non-null result:\n  // FindSymbol(\"baz.qux.foo.bar\"), FindSymbol(\"baz.foo.bar\"),\n  // FindSymbol(\"foo.bar\").  If AllowUnknownDependencies() has been called\n  // on the DescriptorPool, this will generate a placeholder type if\n  // the name is not found (unless the name itself is malformed).  The\n  // placeholder_type parameter indicates what kind of placeholder should be\n  // constructed in this case.  The resolve_mode parameter determines whether\n  // any symbol is returned, or only symbols that are types.  Note, however,\n  // that LookupSymbol may still return a non-type symbol in LOOKUP_TYPES mode,\n  // if it believes that's all it could refer to.  The caller should always\n  // check that it receives the type of symbol it was expecting.\n  enum PlaceholderType {\n    PLACEHOLDER_MESSAGE,\n    PLACEHOLDER_ENUM,\n    PLACEHOLDER_EXTENDABLE_MESSAGE\n  };\n  enum ResolveMode {\n    LOOKUP_ALL, LOOKUP_TYPES\n  };\n  Symbol LookupSymbol(const string& name, const string& relative_to,\n                      PlaceholderType placeholder_type = PLACEHOLDER_MESSAGE,\n                      ResolveMode resolve_mode = LOOKUP_ALL);\n\n  // Like LookupSymbol() but will not return a placeholder even if\n  // AllowUnknownDependencies() has been used.\n  Symbol LookupSymbolNoPlaceholder(const string& name,\n                                   const string& relative_to,\n                                   ResolveMode resolve_mode = LOOKUP_ALL);\n\n  // Creates a placeholder type suitable for return from LookupSymbol().  May\n  // return kNullSymbol if the name is not a valid type name.\n  Symbol NewPlaceholder(const string& name, PlaceholderType placeholder_type);\n\n  // Creates a placeholder file.  Never returns NULL.  This is used when an\n  // import is not found and AllowUnknownDependencies() is enabled.\n  FileDescriptor* NewPlaceholderFile(const string& name);\n\n  // Calls tables_->AddSymbol() and records an error if it fails.  Returns\n  // true if successful or false if failed, though most callers can ignore\n  // the return value since an error has already been recorded.\n  bool AddSymbol(const string& full_name,\n                 const void* parent, const string& name,\n                 const Message& proto, Symbol symbol);\n\n  // Like AddSymbol(), but succeeds if the symbol is already defined as long\n  // as the existing definition is also a package (because it's OK to define\n  // the same package in two different files).  Also adds all parents of the\n  // packgae to the symbol table (e.g. AddPackage(\"foo.bar\", ...) will add\n  // \"foo.bar\" and \"foo\" to the table).\n  void AddPackage(const string& name, const Message& proto,\n                  const FileDescriptor* file);\n\n  // Checks that the symbol name contains only alphanumeric characters and\n  // underscores.  Records an error otherwise.\n  void ValidateSymbolName(const string& name, const string& full_name,\n                          const Message& proto);\n\n  // Like ValidateSymbolName(), but the name is allowed to contain periods and\n  // an error is indicated by returning false (not recording the error).\n  bool ValidateQualifiedName(const string& name);\n\n  // Used by BUILD_ARRAY macro (below) to avoid having to have the type\n  // specified as a macro parameter.\n  template <typename Type>\n  inline void AllocateArray(int size, Type** output) {\n    *output = tables_->AllocateArray<Type>(size);\n  }\n\n  // Allocates a copy of orig_options in tables_ and stores it in the\n  // descriptor. Remembers its uninterpreted options, to be interpreted\n  // later. DescriptorT must be one of the Descriptor messages from\n  // descriptor.proto.\n  template<class DescriptorT> void AllocateOptions(\n      const typename DescriptorT::OptionsType& orig_options,\n      DescriptorT* descriptor);\n  // Specialization for FileOptions.\n  void AllocateOptions(const FileOptions& orig_options,\n                       FileDescriptor* descriptor);\n\n  // Implementation for AllocateOptions(). Don't call this directly.\n  template<class DescriptorT> void AllocateOptionsImpl(\n      const string& name_scope,\n      const string& element_name,\n      const typename DescriptorT::OptionsType& orig_options,\n      DescriptorT* descriptor);\n\n  // These methods all have the same signature for the sake of the BUILD_ARRAY\n  // macro, below.\n  void BuildMessage(const DescriptorProto& proto,\n                    const Descriptor* parent,\n                    Descriptor* result);\n  void BuildFieldOrExtension(const FieldDescriptorProto& proto,\n                             const Descriptor* parent,\n                             FieldDescriptor* result,\n                             bool is_extension);\n  void BuildField(const FieldDescriptorProto& proto,\n                  const Descriptor* parent,\n                  FieldDescriptor* result) {\n    BuildFieldOrExtension(proto, parent, result, false);\n  }\n  void BuildExtension(const FieldDescriptorProto& proto,\n                      const Descriptor* parent,\n                      FieldDescriptor* result) {\n    BuildFieldOrExtension(proto, parent, result, true);\n  }\n  void BuildExtensionRange(const DescriptorProto::ExtensionRange& proto,\n                           const Descriptor* parent,\n                           Descriptor::ExtensionRange* result);\n  void BuildReservedRange(const DescriptorProto::ReservedRange& proto,\n                           const Descriptor* parent,\n                           Descriptor::ReservedRange* result);\n  void BuildOneof(const OneofDescriptorProto& proto,\n                  Descriptor* parent,\n                  OneofDescriptor* result);\n  void BuildEnum(const EnumDescriptorProto& proto,\n                 const Descriptor* parent,\n                 EnumDescriptor* result);\n  void BuildEnumValue(const EnumValueDescriptorProto& proto,\n                      const EnumDescriptor* parent,\n                      EnumValueDescriptor* result);\n  void BuildService(const ServiceDescriptorProto& proto,\n                    const void* dummy,\n                    ServiceDescriptor* result);\n  void BuildMethod(const MethodDescriptorProto& proto,\n                   const ServiceDescriptor* parent,\n                   MethodDescriptor* result);\n\n  void LogUnusedDependency(const FileDescriptorProto& proto,\n                           const FileDescriptor* result);\n\n  // Must be run only after building.\n  //\n  // NOTE: Options will not be available during cross-linking, as they\n  // have not yet been interpreted. Defer any handling of options to the\n  // Validate*Options methods.\n  void CrossLinkFile(FileDescriptor* file, const FileDescriptorProto& proto);\n  void CrossLinkMessage(Descriptor* message, const DescriptorProto& proto);\n  void CrossLinkField(FieldDescriptor* field,\n                      const FieldDescriptorProto& proto);\n  void CrossLinkEnum(EnumDescriptor* enum_type,\n                     const EnumDescriptorProto& proto);\n  void CrossLinkEnumValue(EnumValueDescriptor* enum_value,\n                          const EnumValueDescriptorProto& proto);\n  void CrossLinkService(ServiceDescriptor* service,\n                        const ServiceDescriptorProto& proto);\n  void CrossLinkMethod(MethodDescriptor* method,\n                       const MethodDescriptorProto& proto);\n\n  // Must be run only after cross-linking.\n  void InterpretOptions();\n\n  // A helper class for interpreting options.\n  class OptionInterpreter {\n   public:\n    // Creates an interpreter that operates in the context of the pool of the\n    // specified builder, which must not be NULL. We don't take ownership of the\n    // builder.\n    explicit OptionInterpreter(DescriptorBuilder* builder);\n\n    ~OptionInterpreter();\n\n    // Interprets the uninterpreted options in the specified Options message.\n    // On error, calls AddError() on the underlying builder and returns false.\n    // Otherwise returns true.\n    bool InterpretOptions(OptionsToInterpret* options_to_interpret);\n\n    class AggregateOptionFinder;\n\n   private:\n    // Interprets uninterpreted_option_ on the specified message, which\n    // must be the mutable copy of the original options message to which\n    // uninterpreted_option_ belongs.\n    bool InterpretSingleOption(Message* options);\n\n    // Adds the uninterpreted_option to the given options message verbatim.\n    // Used when AllowUnknownDependencies() is in effect and we can't find\n    // the option's definition.\n    void AddWithoutInterpreting(const UninterpretedOption& uninterpreted_option,\n                                Message* options);\n\n    // A recursive helper function that drills into the intermediate fields\n    // in unknown_fields to check if field innermost_field is set on the\n    // innermost message. Returns false and sets an error if so.\n    bool ExamineIfOptionIsSet(\n        vector<const FieldDescriptor*>::const_iterator intermediate_fields_iter,\n        vector<const FieldDescriptor*>::const_iterator intermediate_fields_end,\n        const FieldDescriptor* innermost_field, const string& debug_msg_name,\n        const UnknownFieldSet& unknown_fields);\n\n    // Validates the value for the option field of the currently interpreted\n    // option and then sets it on the unknown_field.\n    bool SetOptionValue(const FieldDescriptor* option_field,\n                        UnknownFieldSet* unknown_fields);\n\n    // Parses an aggregate value for a CPPTYPE_MESSAGE option and\n    // saves it into *unknown_fields.\n    bool SetAggregateOption(const FieldDescriptor* option_field,\n                            UnknownFieldSet* unknown_fields);\n\n    // Convenience functions to set an int field the right way, depending on\n    // its wire type (a single int CppType can represent multiple wire types).\n    void SetInt32(int number, int32 value, FieldDescriptor::Type type,\n                  UnknownFieldSet* unknown_fields);\n    void SetInt64(int number, int64 value, FieldDescriptor::Type type,\n                  UnknownFieldSet* unknown_fields);\n    void SetUInt32(int number, uint32 value, FieldDescriptor::Type type,\n                   UnknownFieldSet* unknown_fields);\n    void SetUInt64(int number, uint64 value, FieldDescriptor::Type type,\n                   UnknownFieldSet* unknown_fields);\n\n    // A helper function that adds an error at the specified location of the\n    // option we're currently interpreting, and returns false.\n    bool AddOptionError(DescriptorPool::ErrorCollector::ErrorLocation location,\n                        const string& msg) {\n      builder_->AddError(options_to_interpret_->element_name,\n                         *uninterpreted_option_, location, msg);\n      return false;\n    }\n\n    // A helper function that adds an error at the location of the option name\n    // and returns false.\n    bool AddNameError(const string& msg) {\n      return AddOptionError(DescriptorPool::ErrorCollector::OPTION_NAME, msg);\n    }\n\n    // A helper function that adds an error at the location of the option name\n    // and returns false.\n    bool AddValueError(const string& msg) {\n      return AddOptionError(DescriptorPool::ErrorCollector::OPTION_VALUE, msg);\n    }\n\n    // We interpret against this builder's pool. Is never NULL. We don't own\n    // this pointer.\n    DescriptorBuilder* builder_;\n\n    // The options we're currently interpreting, or NULL if we're not in a call\n    // to InterpretOptions.\n    const OptionsToInterpret* options_to_interpret_;\n\n    // The option we're currently interpreting within options_to_interpret_, or\n    // NULL if we're not in a call to InterpretOptions(). This points to a\n    // submessage of the original option, not the mutable copy. Therefore we\n    // can use it to find locations recorded by the parser.\n    const UninterpretedOption* uninterpreted_option_;\n\n    // Factory used to create the dynamic messages we need to parse\n    // any aggregate option values we encounter.\n    DynamicMessageFactory dynamic_factory_;\n\n    GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(OptionInterpreter);\n  };\n\n  // Work-around for broken compilers:  According to the C++ standard,\n  // OptionInterpreter should have access to the private members of any class\n  // which has declared DescriptorBuilder as a friend.  Unfortunately some old\n  // versions of GCC and other compilers do not implement this correctly.  So,\n  // we have to have these intermediate methods to provide access.  We also\n  // redundantly declare OptionInterpreter a friend just to make things extra\n  // clear for these bad compilers.\n  friend class OptionInterpreter;\n  friend class OptionInterpreter::AggregateOptionFinder;\n\n  static inline bool get_allow_unknown(const DescriptorPool* pool) {\n    return pool->allow_unknown_;\n  }\n  static inline bool get_enforce_weak(const DescriptorPool* pool) {\n    return pool->enforce_weak_;\n  }\n  static inline bool get_is_placeholder(const Descriptor* descriptor) {\n    return descriptor->is_placeholder_;\n  }\n  static inline void assert_mutex_held(const DescriptorPool* pool) {\n    if (pool->mutex_ != NULL) {\n      pool->mutex_->AssertHeld();\n    }\n  }\n\n  // Must be run only after options have been interpreted.\n  //\n  // NOTE: Validation code must only reference the options in the mutable\n  // descriptors, which are the ones that have been interpreted. The const\n  // proto references are passed in only so they can be provided to calls to\n  // AddError(). Do not look at their options, which have not been interpreted.\n  void ValidateFileOptions(FileDescriptor* file,\n                           const FileDescriptorProto& proto);\n  void ValidateMessageOptions(Descriptor* message,\n                              const DescriptorProto& proto);\n  void ValidateFieldOptions(FieldDescriptor* field,\n                            const FieldDescriptorProto& proto);\n  void ValidateEnumOptions(EnumDescriptor* enm,\n                           const EnumDescriptorProto& proto);\n  void ValidateEnumValueOptions(EnumValueDescriptor* enum_value,\n                                const EnumValueDescriptorProto& proto);\n  void ValidateServiceOptions(ServiceDescriptor* service,\n                              const ServiceDescriptorProto& proto);\n  void ValidateMethodOptions(MethodDescriptor* method,\n                             const MethodDescriptorProto& proto);\n  void ValidateProto3(FileDescriptor* file,\n                      const FileDescriptorProto& proto);\n  void ValidateProto3Message(Descriptor* message,\n                             const DescriptorProto& proto);\n  void ValidateProto3Field(FieldDescriptor* field,\n                           const FieldDescriptorProto& proto);\n  void ValidateProto3Enum(EnumDescriptor* enm,\n                          const EnumDescriptorProto& proto);\n\n  // Returns true if the map entry message is compatible with the\n  // auto-generated entry message from map fields syntax.\n  bool ValidateMapEntry(FieldDescriptor* field,\n                        const FieldDescriptorProto& proto);\n\n  // Recursively detects naming conflicts with map entry types for a\n  // better error message.\n  void DetectMapConflicts(const Descriptor* message,\n                          const DescriptorProto& proto);\n\n};\n\nconst FileDescriptor* DescriptorPool::BuildFile(\n    const FileDescriptorProto& proto) {\n  GOOGLE_CHECK(fallback_database_ == NULL)\n    << \"Cannot call BuildFile on a DescriptorPool that uses a \"\n       \"DescriptorDatabase.  You must instead find a way to get your file \"\n       \"into the underlying database.\";\n  GOOGLE_CHECK(mutex_ == NULL);   // Implied by the above GOOGLE_CHECK.\n  tables_->known_bad_symbols_.clear();\n  tables_->known_bad_files_.clear();\n  return DescriptorBuilder(this, tables_.get(), NULL).BuildFile(proto);\n}\n\nconst FileDescriptor* DescriptorPool::BuildFileCollectingErrors(\n    const FileDescriptorProto& proto,\n    ErrorCollector* error_collector) {\n  GOOGLE_CHECK(fallback_database_ == NULL)\n    << \"Cannot call BuildFile on a DescriptorPool that uses a \"\n       \"DescriptorDatabase.  You must instead find a way to get your file \"\n       \"into the underlying database.\";\n  GOOGLE_CHECK(mutex_ == NULL);   // Implied by the above GOOGLE_CHECK.\n  tables_->known_bad_symbols_.clear();\n  tables_->known_bad_files_.clear();\n  return DescriptorBuilder(this, tables_.get(),\n                           error_collector).BuildFile(proto);\n}\n\nconst FileDescriptor* DescriptorPool::BuildFileFromDatabase(\n    const FileDescriptorProto& proto) const {\n  mutex_->AssertHeld();\n  if (tables_->known_bad_files_.count(proto.name()) > 0) {\n    return NULL;\n  }\n  const FileDescriptor* result =\n      DescriptorBuilder(this, tables_.get(),\n                        default_error_collector_).BuildFile(proto);\n  if (result == NULL) {\n    tables_->known_bad_files_.insert(proto.name());\n  }\n  return result;\n}\n\nDescriptorBuilder::DescriptorBuilder(\n    const DescriptorPool* pool,\n    DescriptorPool::Tables* tables,\n    DescriptorPool::ErrorCollector* error_collector)\n  : pool_(pool),\n    tables_(tables),\n    error_collector_(error_collector),\n    had_errors_(false),\n    possible_undeclared_dependency_(NULL),\n    undefine_resolved_name_(\"\") {}\n\nDescriptorBuilder::~DescriptorBuilder() {}\n\nvoid DescriptorBuilder::AddError(\n    const string& element_name,\n    const Message& descriptor,\n    DescriptorPool::ErrorCollector::ErrorLocation location,\n    const string& error) {\n  if (error_collector_ == NULL) {\n    if (!had_errors_) {\n      GOOGLE_LOG(ERROR) << \"Invalid proto descriptor for file \\\"\" << filename_\n                 << \"\\\":\";\n    }\n    GOOGLE_LOG(ERROR) << \"  \" << element_name << \": \" << error;\n  } else {\n    error_collector_->AddError(filename_, element_name,\n                               &descriptor, location, error);\n  }\n  had_errors_ = true;\n}\n\nvoid DescriptorBuilder::AddError(\n    const string& element_name,\n    const Message& descriptor,\n    DescriptorPool::ErrorCollector::ErrorLocation location,\n    const char* error) {\n  AddError(element_name, descriptor, location, string(error));\n}\n\nvoid DescriptorBuilder::AddNotDefinedError(\n    const string& element_name,\n    const Message& descriptor,\n    DescriptorPool::ErrorCollector::ErrorLocation location,\n    const string& undefined_symbol) {\n  if (possible_undeclared_dependency_ == NULL &&\n      undefine_resolved_name_.empty()) {\n    AddError(element_name, descriptor, location,\n             \"\\\"\" + undefined_symbol + \"\\\" is not defined.\");\n  } else {\n    if (possible_undeclared_dependency_ != NULL) {\n      AddError(element_name, descriptor, location,\n               \"\\\"\" + possible_undeclared_dependency_name_ +\n               \"\\\" seems to be defined in \\\"\" +\n               possible_undeclared_dependency_->name() + \"\\\", which is not \"\n               \"imported by \\\"\" + filename_ + \"\\\".  To use it here, please \"\n               \"add the necessary import.\");\n    }\n    if (!undefine_resolved_name_.empty()) {\n      AddError(element_name, descriptor, location,\n               \"\\\"\" + undefined_symbol + \"\\\" is resolved to \\\"\" +\n               undefine_resolved_name_ + \"\\\", which is not defined. \"\n               \"The innermost scope is searched first in name resolution. \"\n               \"Consider using a leading '.'(i.e., \\\".\"\n               + undefined_symbol +\n               \"\\\") to start from the outermost scope.\");\n    }\n  }\n}\n\nvoid DescriptorBuilder::AddWarning(\n    const string& element_name, const Message& descriptor,\n    DescriptorPool::ErrorCollector::ErrorLocation location,\n    const string& error) {\n  if (error_collector_ == NULL) {\n    GOOGLE_LOG(WARNING) << filename_ << \" \" << element_name << \": \" << error;\n  } else {\n    error_collector_->AddWarning(filename_, element_name, &descriptor, location,\n                                 error);\n  }\n}\n\nbool DescriptorBuilder::IsInPackage(const FileDescriptor* file,\n                                    const string& package_name) {\n  return HasPrefixString(file->package(), package_name) &&\n           (file->package().size() == package_name.size() ||\n            file->package()[package_name.size()] == '.');\n}\n\nvoid DescriptorBuilder::RecordPublicDependencies(const FileDescriptor* file) {\n  if (file == NULL || !dependencies_.insert(file).second) return;\n  for (int i = 0; file != NULL && i < file->public_dependency_count(); i++) {\n    RecordPublicDependencies(file->public_dependency(i));\n  }\n}\n\nSymbol DescriptorBuilder::FindSymbolNotEnforcingDepsHelper(\n    const DescriptorPool* pool, const string& name) {\n  // If we are looking at an underlay, we must lock its mutex_, since we are\n  // accessing the underlay's tables_ directly.\n  MutexLockMaybe lock((pool == pool_) ? NULL : pool->mutex_);\n\n  Symbol result = pool->tables_->FindSymbol(name);\n  if (result.IsNull() && pool->underlay_ != NULL) {\n    // Symbol not found; check the underlay.\n    result = FindSymbolNotEnforcingDepsHelper(pool->underlay_, name);\n  }\n\n  if (result.IsNull()) {\n    // In theory, we shouldn't need to check fallback_database_ because the\n    // symbol should be in one of its file's direct dependencies, and we have\n    // already loaded those by the time we get here.  But we check anyway so\n    // that we can generate better error message when dependencies are missing\n    // (i.e., \"missing dependency\" rather than \"type is not defined\").\n    if (pool->TryFindSymbolInFallbackDatabase(name)) {\n      result = pool->tables_->FindSymbol(name);\n    }\n  }\n\n  return result;\n}\n\nSymbol DescriptorBuilder::FindSymbolNotEnforcingDeps(const string& name) {\n  return FindSymbolNotEnforcingDepsHelper(pool_, name);\n}\n\nSymbol DescriptorBuilder::FindSymbol(const string& name) {\n  Symbol result = FindSymbolNotEnforcingDeps(name);\n\n  if (result.IsNull()) return result;\n\n  if (!pool_->enforce_dependencies_) {\n    // Hack for CompilerUpgrader.\n    return result;\n  }\n\n  // Only find symbols which were defined in this file or one of its\n  // dependencies.\n  const FileDescriptor* file = result.GetFile();\n  if (file == file_ || dependencies_.count(file) > 0) {\n    unused_dependency_.erase(file);\n    return result;\n  }\n\n  if (result.type == Symbol::PACKAGE) {\n    // Arg, this is overcomplicated.  The symbol is a package name.  It could\n    // be that the package was defined in multiple files.  result.GetFile()\n    // returns the first file we saw that used this package.  We've determined\n    // that that file is not a direct dependency of the file we are currently\n    // building, but it could be that some other file which *is* a direct\n    // dependency also defines the same package.  We can't really rule out this\n    // symbol unless none of the dependencies define it.\n    if (IsInPackage(file_, name)) return result;\n    for (set<const FileDescriptor*>::const_iterator it = dependencies_.begin();\n         it != dependencies_.end(); ++it) {\n      // Note:  A dependency may be NULL if it was not found or had errors.\n      if (*it != NULL && IsInPackage(*it, name)) return result;\n    }\n  }\n\n  possible_undeclared_dependency_ = file;\n  possible_undeclared_dependency_name_ = name;\n  return kNullSymbol;\n}\n\nSymbol DescriptorBuilder::LookupSymbolNoPlaceholder(\n    const string& name, const string& relative_to, ResolveMode resolve_mode) {\n  possible_undeclared_dependency_ = NULL;\n  undefine_resolved_name_.clear();\n\n  if (name.size() > 0 && name[0] == '.') {\n    // Fully-qualified name.\n    return FindSymbol(name.substr(1));\n  }\n\n  // If name is something like \"Foo.Bar.baz\", and symbols named \"Foo\" are\n  // defined in multiple parent scopes, we only want to find \"Bar.baz\" in the\n  // innermost one.  E.g., the following should produce an error:\n  //   message Bar { message Baz {} }\n  //   message Foo {\n  //     message Bar {\n  //     }\n  //     optional Bar.Baz baz = 1;\n  //   }\n  // So, we look for just \"Foo\" first, then look for \"Bar.baz\" within it if\n  // found.\n  string::size_type name_dot_pos = name.find_first_of('.');\n  string first_part_of_name;\n  if (name_dot_pos == string::npos) {\n    first_part_of_name = name;\n  } else {\n    first_part_of_name = name.substr(0, name_dot_pos);\n  }\n\n  string scope_to_try(relative_to);\n\n  while (true) {\n    // Chop off the last component of the scope.\n    string::size_type dot_pos = scope_to_try.find_last_of('.');\n    if (dot_pos == string::npos) {\n      return FindSymbol(name);\n    } else {\n      scope_to_try.erase(dot_pos);\n    }\n\n    // Append \".first_part_of_name\" and try to find.\n    string::size_type old_size = scope_to_try.size();\n    scope_to_try.append(1, '.');\n    scope_to_try.append(first_part_of_name);\n    Symbol result = FindSymbol(scope_to_try);\n    if (!result.IsNull()) {\n      if (first_part_of_name.size() < name.size()) {\n        // name is a compound symbol, of which we only found the first part.\n        // Now try to look up the rest of it.\n        if (result.IsAggregate()) {\n          scope_to_try.append(name, first_part_of_name.size(),\n                              name.size() - first_part_of_name.size());\n          result = FindSymbol(scope_to_try);\n          if (result.IsNull()) {\n            undefine_resolved_name_ = scope_to_try;\n          }\n          return result;\n        } else {\n          // We found a symbol but it's not an aggregate.  Continue the loop.\n        }\n      } else {\n        if (resolve_mode == LOOKUP_TYPES && !result.IsType()) {\n          // We found a symbol but it's not a type.  Continue the loop.\n        } else {\n          return result;\n        }\n      }\n    }\n\n    // Not found.  Remove the name so we can try again.\n    scope_to_try.erase(old_size);\n  }\n}\n\nSymbol DescriptorBuilder::LookupSymbol(\n    const string& name, const string& relative_to,\n    PlaceholderType placeholder_type, ResolveMode resolve_mode) {\n  Symbol result = LookupSymbolNoPlaceholder(\n      name, relative_to, resolve_mode);\n  if (result.IsNull() && pool_->allow_unknown_) {\n    // Not found, but AllowUnknownDependencies() is enabled.  Return a\n    // placeholder instead.\n    result = NewPlaceholder(name, placeholder_type);\n  }\n  return result;\n}\n\nSymbol DescriptorBuilder::NewPlaceholder(const string& name,\n                                         PlaceholderType placeholder_type) {\n  // Compute names.\n  const string* placeholder_full_name;\n  const string* placeholder_name;\n  const string* placeholder_package;\n\n  if (!ValidateQualifiedName(name)) return kNullSymbol;\n  if (name[0] == '.') {\n    // Fully-qualified.\n    placeholder_full_name = tables_->AllocateString(name.substr(1));\n  } else {\n    placeholder_full_name = tables_->AllocateString(name);\n  }\n\n  string::size_type dotpos = placeholder_full_name->find_last_of('.');\n  if (dotpos != string::npos) {\n    placeholder_package = tables_->AllocateString(\n      placeholder_full_name->substr(0, dotpos));\n    placeholder_name = tables_->AllocateString(\n      placeholder_full_name->substr(dotpos + 1));\n  } else {\n    placeholder_package = &internal::GetEmptyString();\n    placeholder_name = placeholder_full_name;\n  }\n\n  // Create the placeholders.\n  FileDescriptor* placeholder_file = NewPlaceholderFile(\n      *placeholder_full_name + \".placeholder.proto\");\n  placeholder_file->package_ = placeholder_package;\n\n  if (placeholder_type == PLACEHOLDER_ENUM) {\n    placeholder_file->enum_type_count_ = 1;\n    placeholder_file->enum_types_ =\n      tables_->AllocateArray<EnumDescriptor>(1);\n\n    EnumDescriptor* placeholder_enum = &placeholder_file->enum_types_[0];\n    memset(placeholder_enum, 0, sizeof(*placeholder_enum));\n\n    placeholder_enum->full_name_ = placeholder_full_name;\n    placeholder_enum->name_ = placeholder_name;\n    placeholder_enum->file_ = placeholder_file;\n    placeholder_enum->options_ = &EnumOptions::default_instance();\n    placeholder_enum->is_placeholder_ = true;\n    placeholder_enum->is_unqualified_placeholder_ = (name[0] != '.');\n\n    // Enums must have at least one value.\n    placeholder_enum->value_count_ = 1;\n    placeholder_enum->values_ = tables_->AllocateArray<EnumValueDescriptor>(1);\n\n    EnumValueDescriptor* placeholder_value = &placeholder_enum->values_[0];\n    memset(placeholder_value, 0, sizeof(*placeholder_value));\n\n    placeholder_value->name_ = tables_->AllocateString(\"PLACEHOLDER_VALUE\");\n    // Note that enum value names are siblings of their type, not children.\n    placeholder_value->full_name_ =\n      placeholder_package->empty() ? placeholder_value->name_ :\n        tables_->AllocateString(*placeholder_package + \".PLACEHOLDER_VALUE\");\n\n    placeholder_value->number_ = 0;\n    placeholder_value->type_ = placeholder_enum;\n    placeholder_value->options_ = &EnumValueOptions::default_instance();\n\n    return Symbol(placeholder_enum);\n  } else {\n    placeholder_file->message_type_count_ = 1;\n    placeholder_file->message_types_ =\n      tables_->AllocateArray<Descriptor>(1);\n\n    Descriptor* placeholder_message = &placeholder_file->message_types_[0];\n    memset(placeholder_message, 0, sizeof(*placeholder_message));\n\n    placeholder_message->full_name_ = placeholder_full_name;\n    placeholder_message->name_ = placeholder_name;\n    placeholder_message->file_ = placeholder_file;\n    placeholder_message->options_ = &MessageOptions::default_instance();\n    placeholder_message->is_placeholder_ = true;\n    placeholder_message->is_unqualified_placeholder_ = (name[0] != '.');\n\n    if (placeholder_type == PLACEHOLDER_EXTENDABLE_MESSAGE) {\n      placeholder_message->extension_range_count_ = 1;\n      placeholder_message->extension_ranges_ =\n        tables_->AllocateArray<Descriptor::ExtensionRange>(1);\n      placeholder_message->extension_ranges_->start = 1;\n      // kMaxNumber + 1 because ExtensionRange::end is exclusive.\n      placeholder_message->extension_ranges_->end =\n        FieldDescriptor::kMaxNumber + 1;\n    }\n\n    return Symbol(placeholder_message);\n  }\n}\n\nFileDescriptor* DescriptorBuilder::NewPlaceholderFile(\n    const string& name) {\n  FileDescriptor* placeholder = tables_->Allocate<FileDescriptor>();\n  memset(placeholder, 0, sizeof(*placeholder));\n\n  placeholder->name_ = tables_->AllocateString(name);\n  placeholder->package_ = &internal::GetEmptyString();\n  placeholder->pool_ = pool_;\n  placeholder->options_ = &FileOptions::default_instance();\n  placeholder->tables_ = &FileDescriptorTables::GetEmptyInstance();\n  placeholder->source_code_info_ = &SourceCodeInfo::default_instance();\n  placeholder->is_placeholder_ = true;\n  placeholder->syntax_ = FileDescriptor::SYNTAX_PROTO2;\n  // All other fields are zero or NULL.\n\n  return placeholder;\n}\n\nbool DescriptorBuilder::AddSymbol(\n    const string& full_name, const void* parent, const string& name,\n    const Message& proto, Symbol symbol) {\n  // If the caller passed NULL for the parent, the symbol is at file scope.\n  // Use its file as the parent instead.\n  if (parent == NULL) parent = file_;\n\n  if (tables_->AddSymbol(full_name, symbol)) {\n    if (!file_tables_->AddAliasUnderParent(parent, name, symbol)) {\n      GOOGLE_LOG(DFATAL) << \"\\\"\" << full_name << \"\\\" not previously defined in \"\n                     \"symbols_by_name_, but was defined in symbols_by_parent_; \"\n                     \"this shouldn't be possible.\";\n      return false;\n    }\n    return true;\n  } else {\n    const FileDescriptor* other_file = tables_->FindSymbol(full_name).GetFile();\n    if (other_file == file_) {\n      string::size_type dot_pos = full_name.find_last_of('.');\n      if (dot_pos == string::npos) {\n        AddError(full_name, proto, DescriptorPool::ErrorCollector::NAME,\n                 \"\\\"\" + full_name + \"\\\" is already defined.\");\n      } else {\n        AddError(full_name, proto, DescriptorPool::ErrorCollector::NAME,\n                 \"\\\"\" + full_name.substr(dot_pos + 1) +\n                 \"\\\" is already defined in \\\"\" +\n                 full_name.substr(0, dot_pos) + \"\\\".\");\n      }\n    } else {\n      // Symbol seems to have been defined in a different file.\n      AddError(full_name, proto, DescriptorPool::ErrorCollector::NAME,\n               \"\\\"\" + full_name + \"\\\" is already defined in file \\\"\" +\n               other_file->name() + \"\\\".\");\n    }\n    return false;\n  }\n}\n\nvoid DescriptorBuilder::AddPackage(\n    const string& name, const Message& proto, const FileDescriptor* file) {\n  if (tables_->AddSymbol(name, Symbol(file))) {\n    // Success.  Also add parent package, if any.\n    string::size_type dot_pos = name.find_last_of('.');\n    if (dot_pos == string::npos) {\n      // No parents.\n      ValidateSymbolName(name, name, proto);\n    } else {\n      // Has parent.\n      string* parent_name = tables_->AllocateString(name.substr(0, dot_pos));\n      AddPackage(*parent_name, proto, file);\n      ValidateSymbolName(name.substr(dot_pos + 1), name, proto);\n    }\n  } else {\n    Symbol existing_symbol = tables_->FindSymbol(name);\n    // It's OK to redefine a package.\n    if (existing_symbol.type != Symbol::PACKAGE) {\n      // Symbol seems to have been defined in a different file.\n      AddError(name, proto, DescriptorPool::ErrorCollector::NAME,\n               \"\\\"\" + name + \"\\\" is already defined (as something other than \"\n               \"a package) in file \\\"\" + existing_symbol.GetFile()->name() +\n               \"\\\".\");\n    }\n  }\n}\n\nvoid DescriptorBuilder::ValidateSymbolName(\n    const string& name, const string& full_name, const Message& proto) {\n  if (name.empty()) {\n    AddError(full_name, proto, DescriptorPool::ErrorCollector::NAME,\n             \"Missing name.\");\n  } else {\n    for (int i = 0; i < name.size(); i++) {\n      // I don't trust isalnum() due to locales.  :(\n      if ((name[i] < 'a' || 'z' < name[i]) &&\n          (name[i] < 'A' || 'Z' < name[i]) &&\n          (name[i] < '0' || '9' < name[i]) &&\n          (name[i] != '_')) {\n        AddError(full_name, proto, DescriptorPool::ErrorCollector::NAME,\n                 \"\\\"\" + name + \"\\\" is not a valid identifier.\");\n      }\n    }\n  }\n}\n\nbool DescriptorBuilder::ValidateQualifiedName(const string& name) {\n  bool last_was_period = false;\n\n  for (int i = 0; i < name.size(); i++) {\n    // I don't trust isalnum() due to locales.  :(\n    if (('a' <= name[i] && name[i] <= 'z') ||\n        ('A' <= name[i] && name[i] <= 'Z') ||\n        ('0' <= name[i] && name[i] <= '9') ||\n        (name[i] == '_')) {\n      last_was_period = false;\n    } else if (name[i] == '.') {\n      if (last_was_period) return false;\n      last_was_period = true;\n    } else {\n      return false;\n    }\n  }\n\n  return !name.empty() && !last_was_period;\n}\n\n// -------------------------------------------------------------------\n\n// This generic implementation is good for all descriptors except\n// FileDescriptor.\ntemplate<class DescriptorT> void DescriptorBuilder::AllocateOptions(\n    const typename DescriptorT::OptionsType& orig_options,\n    DescriptorT* descriptor) {\n  AllocateOptionsImpl(descriptor->full_name(), descriptor->full_name(),\n                      orig_options, descriptor);\n}\n\n// We specialize for FileDescriptor.\nvoid DescriptorBuilder::AllocateOptions(const FileOptions& orig_options,\n                                        FileDescriptor* descriptor) {\n  // We add the dummy token so that LookupSymbol does the right thing.\n  AllocateOptionsImpl(descriptor->package() + \".dummy\", descriptor->name(),\n                      orig_options, descriptor);\n}\n\ntemplate<class DescriptorT> void DescriptorBuilder::AllocateOptionsImpl(\n    const string& name_scope,\n    const string& element_name,\n    const typename DescriptorT::OptionsType& orig_options,\n    DescriptorT* descriptor) {\n  // We need to use a dummy pointer to work around a bug in older versions of\n  // GCC.  Otherwise, the following two lines could be replaced with:\n  //   typename DescriptorT::OptionsType* options =\n  //       tables_->AllocateMessage<typename DescriptorT::OptionsType>();\n  typename DescriptorT::OptionsType* const dummy = NULL;\n  typename DescriptorT::OptionsType* options = tables_->AllocateMessage(dummy);\n  // Avoid using MergeFrom()/CopyFrom() in this class to make it -fno-rtti\n  // friendly. Without RTTI, MergeFrom() and CopyFrom() will fallback to the\n  // reflection based method, which requires the Descriptor. However, we are in\n  // the middle of building the descriptors, thus the deadlock.\n  options->ParseFromString(orig_options.SerializeAsString());\n  descriptor->options_ = options;\n\n  // Don't add to options_to_interpret_ unless there were uninterpreted\n  // options.  This not only avoids unnecessary work, but prevents a\n  // bootstrapping problem when building descriptors for descriptor.proto.\n  // descriptor.proto does not contain any uninterpreted options, but\n  // attempting to interpret options anyway will cause\n  // OptionsType::GetDescriptor() to be called which may then deadlock since\n  // we're still trying to build it.\n  if (options->uninterpreted_option_size() > 0) {\n    options_to_interpret_.push_back(\n        OptionsToInterpret(name_scope, element_name, &orig_options, options));\n  }\n}\n\n\n// A common pattern:  We want to convert a repeated field in the descriptor\n// to an array of values, calling some method to build each value.\n#define BUILD_ARRAY(INPUT, OUTPUT, NAME, METHOD, PARENT)             \\\n  OUTPUT->NAME##_count_ = INPUT.NAME##_size();                       \\\n  AllocateArray(INPUT.NAME##_size(), &OUTPUT->NAME##s_);             \\\n  for (int i = 0; i < INPUT.NAME##_size(); i++) {                    \\\n    METHOD(INPUT.NAME(i), PARENT, OUTPUT->NAME##s_ + i);             \\\n  }\n\nvoid DescriptorBuilder::AddRecursiveImportError(\n    const FileDescriptorProto& proto, int from_here) {\n  string error_message(\"File recursively imports itself: \");\n  for (int i = from_here; i < tables_->pending_files_.size(); i++) {\n    error_message.append(tables_->pending_files_[i]);\n    error_message.append(\" -> \");\n  }\n  error_message.append(proto.name());\n\n  AddError(proto.name(), proto, DescriptorPool::ErrorCollector::OTHER,\n           error_message);\n}\n\nvoid DescriptorBuilder::AddTwiceListedError(const FileDescriptorProto& proto,\n                                            int index) {\n  AddError(proto.name(), proto, DescriptorPool::ErrorCollector::OTHER,\n           \"Import \\\"\" + proto.dependency(index) + \"\\\" was listed twice.\");\n}\n\nvoid DescriptorBuilder::AddImportError(const FileDescriptorProto& proto,\n                                       int index) {\n  string message;\n  if (pool_->fallback_database_ == NULL) {\n    message = \"Import \\\"\" + proto.dependency(index) +\n              \"\\\" has not been loaded.\";\n  } else {\n    message = \"Import \\\"\" + proto.dependency(index) +\n              \"\\\" was not found or had errors.\";\n  }\n  AddError(proto.name(), proto, DescriptorPool::ErrorCollector::OTHER, message);\n}\n\nstatic bool ExistingFileMatchesProto(const FileDescriptor* existing_file,\n                                     const FileDescriptorProto& proto) {\n  FileDescriptorProto existing_proto;\n  existing_file->CopyTo(&existing_proto);\n  // TODO(liujisi): Remove it when CopyTo supports copying syntax params when\n  // syntax=\"proto2\".\n  if (existing_file->syntax() == FileDescriptor::SYNTAX_PROTO2 &&\n      proto.has_syntax()) {\n    existing_proto.set_syntax(\n        existing_file->SyntaxName(existing_file->syntax()));\n  }\n\n  return existing_proto.SerializeAsString() == proto.SerializeAsString();\n}\n\nconst FileDescriptor* DescriptorBuilder::BuildFile(\n    const FileDescriptorProto& proto) {\n  filename_ = proto.name();\n\n  // Check if the file already exists and is identical to the one being built.\n  // Note:  This only works if the input is canonical -- that is, it\n  //   fully-qualifies all type names, has no UninterpretedOptions, etc.\n  //   This is fine, because this idempotency \"feature\" really only exists to\n  //   accommodate one hack in the proto1->proto2 migration layer.\n  const FileDescriptor* existing_file = tables_->FindFile(filename_);\n  if (existing_file != NULL) {\n    // File already in pool.  Compare the existing one to the input.\n    if (ExistingFileMatchesProto(existing_file, proto)) {\n      // They're identical.  Return the existing descriptor.\n      return existing_file;\n    }\n\n    // Not a match.  The error will be detected and handled later.\n  }\n\n  // Check to see if this file is already on the pending files list.\n  // TODO(kenton):  Allow recursive imports?  It may not work with some\n  //   (most?) programming languages.  E.g., in C++, a forward declaration\n  //   of a type is not sufficient to allow it to be used even in a\n  //   generated header file due to inlining.  This could perhaps be\n  //   worked around using tricks involving inserting #include statements\n  //   mid-file, but that's pretty ugly, and I'm pretty sure there are\n  //   some languages out there that do not allow recursive dependencies\n  //   at all.\n  for (int i = 0; i < tables_->pending_files_.size(); i++) {\n    if (tables_->pending_files_[i] == proto.name()) {\n      AddRecursiveImportError(proto, i);\n      return NULL;\n    }\n  }\n\n  // If we have a fallback_database_, attempt to load all dependencies now,\n  // before checkpointing tables_.  This avoids confusion with recursive\n  // checkpoints.\n  if (pool_->fallback_database_ != NULL) {\n    tables_->pending_files_.push_back(proto.name());\n    for (int i = 0; i < proto.dependency_size(); i++) {\n      if (tables_->FindFile(proto.dependency(i)) == NULL &&\n          (pool_->underlay_ == NULL ||\n           pool_->underlay_->FindFileByName(proto.dependency(i)) == NULL)) {\n        // We don't care what this returns since we'll find out below anyway.\n        pool_->TryFindFileInFallbackDatabase(proto.dependency(i));\n      }\n    }\n    tables_->pending_files_.pop_back();\n  }\n  return BuildFileImpl(proto);\n}\n\nconst FileDescriptor* DescriptorBuilder::BuildFileImpl(\n    const FileDescriptorProto& proto) {\n  // Checkpoint the tables so that we can roll back if something goes wrong.\n  tables_->AddCheckpoint();\n\n  FileDescriptor* result = tables_->Allocate<FileDescriptor>();\n  file_ = result;\n\n  result->is_placeholder_ = false;\n  if (proto.has_source_code_info()) {\n    SourceCodeInfo *info = tables_->AllocateMessage<SourceCodeInfo>();\n    info->CopyFrom(proto.source_code_info());\n    result->source_code_info_ = info;\n  } else {\n    result->source_code_info_ = &SourceCodeInfo::default_instance();\n  }\n\n  file_tables_ = tables_->AllocateFileTables();\n  file_->tables_ = file_tables_;\n\n  if (!proto.has_name()) {\n    AddError(\"\", proto, DescriptorPool::ErrorCollector::OTHER,\n             \"Missing field: FileDescriptorProto.name.\");\n  }\n\n  // TODO(liujisi): Report error when the syntax is empty after all the protos\n  // have added the syntax statement.\n  if (proto.syntax().empty() || proto.syntax() == \"proto2\") {\n    file_->syntax_ = FileDescriptor::SYNTAX_PROTO2;\n  } else if (proto.syntax() == \"proto3\") {\n    file_->syntax_ = FileDescriptor::SYNTAX_PROTO3;\n  } else {\n    file_->syntax_ = FileDescriptor::SYNTAX_UNKNOWN;\n    AddError(proto.name(), proto, DescriptorPool::ErrorCollector::OTHER,\n             \"Unrecognized syntax: \" + proto.syntax());\n  }\n\n  result->name_ = tables_->AllocateString(proto.name());\n  if (proto.has_package()) {\n    result->package_ = tables_->AllocateString(proto.package());\n  } else {\n    // We cannot rely on proto.package() returning a valid string if\n    // proto.has_package() is false, because we might be running at static\n    // initialization time, in which case default values have not yet been\n    // initialized.\n    result->package_ = tables_->AllocateString(\"\");\n  }\n  result->pool_ = pool_;\n\n  // Add to tables.\n  if (!tables_->AddFile(result)) {\n    AddError(proto.name(), proto, DescriptorPool::ErrorCollector::OTHER,\n             \"A file with this name is already in the pool.\");\n    // Bail out early so that if this is actually the exact same file, we\n    // don't end up reporting that every single symbol is already defined.\n    tables_->RollbackToLastCheckpoint();\n    return NULL;\n  }\n  if (!result->package().empty()) {\n    AddPackage(result->package(), proto, result);\n  }\n\n  // Make sure all dependencies are loaded.\n  set<string> seen_dependencies;\n  result->dependency_count_ = proto.dependency_size();\n  result->dependencies_ =\n    tables_->AllocateArray<const FileDescriptor*>(proto.dependency_size());\n  unused_dependency_.clear();\n  set<int> weak_deps;\n  for (int i = 0; i < proto.weak_dependency_size(); ++i) {\n    weak_deps.insert(proto.weak_dependency(i));\n  }\n  for (int i = 0; i < proto.dependency_size(); i++) {\n    if (!seen_dependencies.insert(proto.dependency(i)).second) {\n      AddTwiceListedError(proto, i);\n    }\n\n    const FileDescriptor* dependency = tables_->FindFile(proto.dependency(i));\n    if (dependency == NULL && pool_->underlay_ != NULL) {\n      dependency = pool_->underlay_->FindFileByName(proto.dependency(i));\n    }\n\n    if (dependency == NULL) {\n      if (pool_->allow_unknown_ ||\n          (!pool_->enforce_weak_ && weak_deps.find(i) != weak_deps.end())) {\n        dependency = NewPlaceholderFile(proto.dependency(i));\n      } else {\n        AddImportError(proto, i);\n      }\n    } else {\n      // Add to unused_dependency_ to track unused imported files.\n      // Note: do not track unused imported files for public import.\n      if (pool_->enforce_dependencies_ &&\n          (pool_->unused_import_track_files_.find(proto.name()) !=\n           pool_->unused_import_track_files_.end()) &&\n          (dependency->public_dependency_count() == 0)) {\n        unused_dependency_.insert(dependency);\n      }\n    }\n\n    result->dependencies_[i] = dependency;\n  }\n\n  // Check public dependencies.\n  int public_dependency_count = 0;\n  result->public_dependencies_ = tables_->AllocateArray<int>(\n      proto.public_dependency_size());\n  for (int i = 0; i < proto.public_dependency_size(); i++) {\n    // Only put valid public dependency indexes.\n    int index = proto.public_dependency(i);\n    if (index >= 0 && index < proto.dependency_size()) {\n      result->public_dependencies_[public_dependency_count++] = index;\n      // Do not track unused imported files for public import.\n      unused_dependency_.erase(result->dependency(index));\n    } else {\n      AddError(proto.name(), proto,\n               DescriptorPool::ErrorCollector::OTHER,\n               \"Invalid public dependency index.\");\n    }\n  }\n  result->public_dependency_count_ = public_dependency_count;\n\n  // Build dependency set\n  dependencies_.clear();\n  for (int i = 0; i < result->dependency_count(); i++) {\n    RecordPublicDependencies(result->dependency(i));\n  }\n\n  // Check weak dependencies.\n  int weak_dependency_count = 0;\n  result->weak_dependencies_ = tables_->AllocateArray<int>(\n      proto.weak_dependency_size());\n  for (int i = 0; i < proto.weak_dependency_size(); i++) {\n    int index = proto.weak_dependency(i);\n    if (index >= 0 && index < proto.dependency_size()) {\n      result->weak_dependencies_[weak_dependency_count++] = index;\n    } else {\n      AddError(proto.name(), proto,\n               DescriptorPool::ErrorCollector::OTHER,\n               \"Invalid weak dependency index.\");\n    }\n  }\n  result->weak_dependency_count_ = weak_dependency_count;\n\n  // Convert children.\n  BUILD_ARRAY(proto, result, message_type, BuildMessage  , NULL);\n  BUILD_ARRAY(proto, result, enum_type   , BuildEnum     , NULL);\n  BUILD_ARRAY(proto, result, service     , BuildService  , NULL);\n  BUILD_ARRAY(proto, result, extension   , BuildExtension, NULL);\n\n  // Copy options.\n  if (!proto.has_options()) {\n    result->options_ = NULL;  // Will set to default_instance later.\n  } else {\n    AllocateOptions(proto.options(), result);\n  }\n\n  // Note that the following steps must occur in exactly the specified order.\n\n  // Cross-link.\n  CrossLinkFile(result, proto);\n\n  // Interpret any remaining uninterpreted options gathered into\n  // options_to_interpret_ during descriptor building.  Cross-linking has made\n  // extension options known, so all interpretations should now succeed.\n  if (!had_errors_) {\n    OptionInterpreter option_interpreter(this);\n    for (vector<OptionsToInterpret>::iterator iter =\n             options_to_interpret_.begin();\n         iter != options_to_interpret_.end(); ++iter) {\n      option_interpreter.InterpretOptions(&(*iter));\n    }\n    options_to_interpret_.clear();\n  }\n\n  // Validate options.\n  if (!had_errors_) {\n    ValidateFileOptions(result, proto);\n  }\n\n  // Additional naming conflict check for map entry types. Only need to check\n  // this if there are already errors.\n  if (had_errors_) {\n    for (int i = 0; i < proto.message_type_size(); ++i) {\n      DetectMapConflicts(result->message_type(i), proto.message_type(i));\n    }\n  }\n\n\n  if (!unused_dependency_.empty()) {\n    LogUnusedDependency(proto, result);\n  }\n\n  if (had_errors_) {\n    tables_->RollbackToLastCheckpoint();\n    return NULL;\n  } else {\n    tables_->ClearLastCheckpoint();\n    return result;\n  }\n}\n\nvoid DescriptorBuilder::BuildMessage(const DescriptorProto& proto,\n                                     const Descriptor* parent,\n                                     Descriptor* result) {\n  const string& scope = (parent == NULL) ?\n    file_->package() : parent->full_name();\n  string* full_name = tables_->AllocateString(scope);\n  if (!full_name->empty()) full_name->append(1, '.');\n  full_name->append(proto.name());\n\n  ValidateSymbolName(proto.name(), *full_name, proto);\n\n  result->name_            = tables_->AllocateString(proto.name());\n  result->full_name_       = full_name;\n  result->file_            = file_;\n  result->containing_type_ = parent;\n  result->is_placeholder_  = false;\n  result->is_unqualified_placeholder_ = false;\n\n  // Build oneofs first so that fields and extension ranges can refer to them.\n  BUILD_ARRAY(proto, result, oneof_decl     , BuildOneof         , result);\n  BUILD_ARRAY(proto, result, field          , BuildField         , result);\n  BUILD_ARRAY(proto, result, nested_type    , BuildMessage       , result);\n  BUILD_ARRAY(proto, result, enum_type      , BuildEnum          , result);\n  BUILD_ARRAY(proto, result, extension_range, BuildExtensionRange, result);\n  BUILD_ARRAY(proto, result, extension      , BuildExtension     , result);\n  BUILD_ARRAY(proto, result, reserved_range , BuildReservedRange , result);\n\n  // Copy reserved names.\n  int reserved_name_count = proto.reserved_name_size();\n  result->reserved_name_count_ = reserved_name_count;\n  result->reserved_names_ =\n      tables_->AllocateArray<const string*>(reserved_name_count);\n  for (int i = 0; i < reserved_name_count; ++i) {\n    result->reserved_names_[i] =\n        tables_->AllocateString(proto.reserved_name(i));\n  }\n\n  // Copy options.\n  if (!proto.has_options()) {\n    result->options_ = NULL;  // Will set to default_instance later.\n  } else {\n    AllocateOptions(proto.options(), result);\n  }\n\n  AddSymbol(result->full_name(), parent, result->name(),\n            proto, Symbol(result));\n\n  for (int i = 0; i < proto.reserved_range_size(); i++) {\n    const DescriptorProto_ReservedRange& range1 = proto.reserved_range(i);\n    for (int j = i + 1; j < proto.reserved_range_size(); j++) {\n      const DescriptorProto_ReservedRange& range2 = proto.reserved_range(j);\n      if (range1.end() > range2.start() && range2.end() > range1.start()) {\n        AddError(result->full_name(), proto.reserved_range(i),\n                 DescriptorPool::ErrorCollector::NUMBER,\n                 strings::Substitute(\"Reserved range $0 to $1 overlaps with \"\n                                     \"already-defined range $2 to $3.\",\n                                     range2.start(), range2.end() - 1,\n                                     range1.start(), range1.end() - 1));\n      }\n    }\n  }\n\n  hash_set<string> reserved_name_set;\n  for (int i = 0; i < proto.reserved_name_size(); i++) {\n    const string& name = proto.reserved_name(i);\n    if (reserved_name_set.find(name) == reserved_name_set.end()) {\n      reserved_name_set.insert(name);\n    } else {\n      AddError(name, proto, DescriptorPool::ErrorCollector::NAME,\n               strings::Substitute(\n                 \"Field name \\\"$0\\\" is reserved multiple times.\",\n                 name));\n    }\n  }\n\n  for (int i = 0; i < result->field_count(); i++) {\n    const FieldDescriptor* field = result->field(i);\n    for (int j = 0; j < result->extension_range_count(); j++) {\n      const Descriptor::ExtensionRange* range = result->extension_range(j);\n      if (range->start <= field->number() && field->number() < range->end) {\n        AddError(field->full_name(), proto.extension_range(j),\n                 DescriptorPool::ErrorCollector::NUMBER,\n                 strings::Substitute(\n                   \"Extension range $0 to $1 includes field \\\"$2\\\" ($3).\",\n                   range->start, range->end - 1,\n                   field->name(), field->number()));\n      }\n    }\n    for (int j = 0; j < result->reserved_range_count(); j++) {\n      const Descriptor::ReservedRange* range = result->reserved_range(j);\n      if (range->start <= field->number() && field->number() < range->end) {\n        AddError(field->full_name(), proto.reserved_range(j),\n                 DescriptorPool::ErrorCollector::NUMBER,\n                 strings::Substitute(\n                   \"Field \\\"$0\\\" uses reserved number $1.\",\n                   field->name(), field->number()));\n      }\n    }\n    if (reserved_name_set.find(field->name()) != reserved_name_set.end()) {\n      AddError(field->full_name(), proto.field(i),\n               DescriptorPool::ErrorCollector::NAME,\n               strings::Substitute(\n                 \"Field name \\\"$0\\\" is reserved.\", field->name()));\n    }\n  }\n\n  // Check that extension ranges don't overlap and don't include\n  // reserved field numbers.\n  for (int i = 0; i < result->extension_range_count(); i++) {\n    const Descriptor::ExtensionRange* range1 = result->extension_range(i);\n    for (int j = 0; j < result->reserved_range_count(); j++) {\n      const Descriptor::ReservedRange* range2 = result->reserved_range(j);\n      if (range1->end > range2->start && range2->end > range1->start) {\n        AddError(result->full_name(), proto.extension_range(j),\n                 DescriptorPool::ErrorCollector::NUMBER,\n                 strings::Substitute(\"Extension range $0 to $1 overlaps with \"\n                                     \"reserved range $2 to $3.\",\n                                     range1->start, range1->end - 1,\n                                     range2->start, range2->end - 1));\n      }\n    }\n    for (int j = i + 1; j < result->extension_range_count(); j++) {\n      const Descriptor::ExtensionRange* range2 = result->extension_range(j);\n      if (range1->end > range2->start && range2->end > range1->start) {\n        AddError(result->full_name(), proto.extension_range(j),\n                 DescriptorPool::ErrorCollector::NUMBER,\n                 strings::Substitute(\"Extension range $0 to $1 overlaps with \"\n                                     \"already-defined range $2 to $3.\",\n                                     range2->start, range2->end - 1,\n                                     range1->start, range1->end - 1));\n      }\n    }\n  }\n}\n\n\nvoid DescriptorBuilder::BuildFieldOrExtension(const FieldDescriptorProto& proto,\n                                              const Descriptor* parent,\n                                              FieldDescriptor* result,\n                                              bool is_extension) {\n  const string& scope = (parent == NULL) ?\n    file_->package() : parent->full_name();\n  string* full_name = tables_->AllocateString(scope);\n  if (!full_name->empty()) full_name->append(1, '.');\n  full_name->append(proto.name());\n\n  ValidateSymbolName(proto.name(), *full_name, proto);\n\n  result->name_         = tables_->AllocateString(proto.name());\n  result->full_name_    = full_name;\n  result->file_         = file_;\n  result->number_       = proto.number();\n  result->is_extension_ = is_extension;\n\n  // If .proto files follow the style guide then the name should already be\n  // lower-cased.  If that's the case we can just reuse the string we already\n  // allocated rather than allocate a new one.\n  string lowercase_name(proto.name());\n  LowerString(&lowercase_name);\n  if (lowercase_name == proto.name()) {\n    result->lowercase_name_ = result->name_;\n  } else {\n    result->lowercase_name_ = tables_->AllocateString(lowercase_name);\n  }\n\n  // Don't bother with the above optimization for camel-case names since\n  // .proto files that follow the guide shouldn't be using names in this\n  // format, so the optimization wouldn't help much.\n  result->camelcase_name_ =\n      tables_->AllocateString(ToCamelCase(proto.name(),\n                                          /* lower_first = */ true));\n\n  if (proto.has_json_name()) {\n    result->has_json_name_ = true;\n    result->json_name_ = tables_->AllocateString(proto.json_name());\n  } else {\n    result->has_json_name_ = false;\n    result->json_name_ = result->camelcase_name_;\n  }\n\n  // Some compilers do not allow static_cast directly between two enum types,\n  // so we must cast to int first.\n  result->type_  = static_cast<FieldDescriptor::Type>(\n                     implicit_cast<int>(proto.type()));\n  result->label_ = static_cast<FieldDescriptor::Label>(\n                     implicit_cast<int>(proto.label()));\n\n  // An extension cannot have a required field (b/13365836).\n  if (result->is_extension_ &&\n      result->label_ == FieldDescriptor::LABEL_REQUIRED) {\n    AddError(result->full_name(), proto,\n             // Error location `TYPE`: we would really like to indicate\n             // `LABEL`, but the `ErrorLocation` enum has no entry for this, and\n             // we don't necessarily know about all implementations of the\n             // `ErrorCollector` interface to extend them to handle the new\n             // error location type properly.\n             DescriptorPool::ErrorCollector::TYPE,\n             \"Message extensions cannot have required fields.\");\n  }\n\n  // Some of these may be filled in when cross-linking.\n  result->containing_type_ = NULL;\n  result->extension_scope_ = NULL;\n  result->message_type_ = NULL;\n  result->enum_type_ = NULL;\n\n  result->has_default_value_ = proto.has_default_value();\n  if (proto.has_default_value() && result->is_repeated()) {\n    AddError(result->full_name(), proto,\n             DescriptorPool::ErrorCollector::DEFAULT_VALUE,\n             \"Repeated fields can't have default values.\");\n  }\n\n  if (proto.has_type()) {\n    if (proto.has_default_value()) {\n      char* end_pos = NULL;\n      switch (result->cpp_type()) {\n        case FieldDescriptor::CPPTYPE_INT32:\n          result->default_value_int32_ =\n            strtol(proto.default_value().c_str(), &end_pos, 0);\n          break;\n        case FieldDescriptor::CPPTYPE_INT64:\n          result->default_value_int64_ =\n            strto64(proto.default_value().c_str(), &end_pos, 0);\n          break;\n        case FieldDescriptor::CPPTYPE_UINT32:\n          result->default_value_uint32_ =\n            strtoul(proto.default_value().c_str(), &end_pos, 0);\n          break;\n        case FieldDescriptor::CPPTYPE_UINT64:\n          result->default_value_uint64_ =\n            strtou64(proto.default_value().c_str(), &end_pos, 0);\n          break;\n        case FieldDescriptor::CPPTYPE_FLOAT:\n          if (proto.default_value() == \"inf\") {\n            result->default_value_float_ = numeric_limits<float>::infinity();\n          } else if (proto.default_value() == \"-inf\") {\n            result->default_value_float_ = -numeric_limits<float>::infinity();\n          } else if (proto.default_value() == \"nan\") {\n            result->default_value_float_ = numeric_limits<float>::quiet_NaN();\n          } else  {\n            result->default_value_float_ = io::SafeDoubleToFloat(\n                io::NoLocaleStrtod(proto.default_value().c_str(), &end_pos));\n          }\n          break;\n        case FieldDescriptor::CPPTYPE_DOUBLE:\n          if (proto.default_value() == \"inf\") {\n            result->default_value_double_ = numeric_limits<double>::infinity();\n          } else if (proto.default_value() == \"-inf\") {\n            result->default_value_double_ = -numeric_limits<double>::infinity();\n          } else if (proto.default_value() == \"nan\") {\n            result->default_value_double_ = numeric_limits<double>::quiet_NaN();\n          } else  {\n            result->default_value_double_ =\n                io::NoLocaleStrtod(proto.default_value().c_str(), &end_pos);\n          }\n          break;\n        case FieldDescriptor::CPPTYPE_BOOL:\n          if (proto.default_value() == \"true\") {\n            result->default_value_bool_ = true;\n          } else if (proto.default_value() == \"false\") {\n            result->default_value_bool_ = false;\n          } else {\n            AddError(result->full_name(), proto,\n                     DescriptorPool::ErrorCollector::DEFAULT_VALUE,\n                     \"Boolean default must be true or false.\");\n          }\n          break;\n        case FieldDescriptor::CPPTYPE_ENUM:\n          // This will be filled in when cross-linking.\n          result->default_value_enum_ = NULL;\n          break;\n        case FieldDescriptor::CPPTYPE_STRING:\n          if (result->type() == FieldDescriptor::TYPE_BYTES) {\n            result->default_value_string_ = tables_->AllocateString(\n              UnescapeCEscapeString(proto.default_value()));\n          } else {\n            result->default_value_string_ =\n                tables_->AllocateString(proto.default_value());\n          }\n          break;\n        case FieldDescriptor::CPPTYPE_MESSAGE:\n          AddError(result->full_name(), proto,\n                   DescriptorPool::ErrorCollector::DEFAULT_VALUE,\n                   \"Messages can't have default values.\");\n          result->has_default_value_ = false;\n          break;\n      }\n\n      if (end_pos != NULL) {\n        // end_pos is only set non-NULL by the parsers for numeric types, above.\n        // This checks that the default was non-empty and had no extra junk\n        // after the end of the number.\n        if (proto.default_value().empty() || *end_pos != '\\0') {\n          AddError(result->full_name(), proto,\n                   DescriptorPool::ErrorCollector::DEFAULT_VALUE,\n                   \"Couldn't parse default value \\\"\" + proto.default_value() +\n                   \"\\\".\");\n        }\n      }\n    } else {\n      // No explicit default value\n      switch (result->cpp_type()) {\n        case FieldDescriptor::CPPTYPE_INT32:\n          result->default_value_int32_ = 0;\n          break;\n        case FieldDescriptor::CPPTYPE_INT64:\n          result->default_value_int64_ = 0;\n          break;\n        case FieldDescriptor::CPPTYPE_UINT32:\n          result->default_value_uint32_ = 0;\n          break;\n        case FieldDescriptor::CPPTYPE_UINT64:\n          result->default_value_uint64_ = 0;\n          break;\n        case FieldDescriptor::CPPTYPE_FLOAT:\n          result->default_value_float_ = 0.0f;\n          break;\n        case FieldDescriptor::CPPTYPE_DOUBLE:\n          result->default_value_double_ = 0.0;\n          break;\n        case FieldDescriptor::CPPTYPE_BOOL:\n          result->default_value_bool_ = false;\n          break;\n        case FieldDescriptor::CPPTYPE_ENUM:\n          // This will be filled in when cross-linking.\n          result->default_value_enum_ = NULL;\n          break;\n        case FieldDescriptor::CPPTYPE_STRING:\n          result->default_value_string_ = &internal::GetEmptyString();\n          break;\n        case FieldDescriptor::CPPTYPE_MESSAGE:\n          break;\n      }\n    }\n  }\n\n  if (result->number() <= 0) {\n    AddError(result->full_name(), proto, DescriptorPool::ErrorCollector::NUMBER,\n             \"Field numbers must be positive integers.\");\n  } else if (!is_extension && result->number() > FieldDescriptor::kMaxNumber) {\n    // Only validate that the number is within the valid field range if it is\n    // not an extension. Since extension numbers are validated with the\n    // extendee's valid set of extension numbers, and those are in turn\n    // validated against the max allowed number, the check is unnecessary for\n    // extension fields.\n    // This avoids cross-linking issues that arise when attempting to check if\n    // the extendee is a message_set_wire_format message, which has a higher max\n    // on extension numbers.\n    AddError(result->full_name(), proto, DescriptorPool::ErrorCollector::NUMBER,\n             strings::Substitute(\"Field numbers cannot be greater than $0.\",\n                                 FieldDescriptor::kMaxNumber));\n  } else if (result->number() >= FieldDescriptor::kFirstReservedNumber &&\n             result->number() <= FieldDescriptor::kLastReservedNumber) {\n    AddError(result->full_name(), proto, DescriptorPool::ErrorCollector::NUMBER,\n             strings::Substitute(\n               \"Field numbers $0 through $1 are reserved for the protocol \"\n               \"buffer library implementation.\",\n               FieldDescriptor::kFirstReservedNumber,\n               FieldDescriptor::kLastReservedNumber));\n  }\n\n  if (is_extension) {\n    if (!proto.has_extendee()) {\n      AddError(result->full_name(), proto,\n               DescriptorPool::ErrorCollector::EXTENDEE,\n               \"FieldDescriptorProto.extendee not set for extension field.\");\n    }\n\n    result->extension_scope_ = parent;\n\n    if (proto.has_oneof_index()) {\n      AddError(result->full_name(), proto,\n               DescriptorPool::ErrorCollector::OTHER,\n               \"FieldDescriptorProto.oneof_index should not be set for \"\n               \"extensions.\");\n    }\n\n    // Fill in later (maybe).\n    result->containing_oneof_ = NULL;\n  } else {\n    if (proto.has_extendee()) {\n      AddError(result->full_name(), proto,\n               DescriptorPool::ErrorCollector::EXTENDEE,\n               \"FieldDescriptorProto.extendee set for non-extension field.\");\n    }\n\n    result->containing_type_ = parent;\n\n    if (proto.has_oneof_index()) {\n      if (proto.oneof_index() < 0 ||\n          proto.oneof_index() >= parent->oneof_decl_count()) {\n        AddError(result->full_name(), proto,\n                 DescriptorPool::ErrorCollector::OTHER,\n                 strings::Substitute(\"FieldDescriptorProto.oneof_index $0 is \"\n                                     \"out of range for type \\\"$1\\\".\",\n                                     proto.oneof_index(),\n                                     parent->name()));\n        result->containing_oneof_ = NULL;\n      } else {\n        result->containing_oneof_ = parent->oneof_decl(proto.oneof_index());\n      }\n    } else {\n      result->containing_oneof_ = NULL;\n    }\n  }\n\n  // Copy options.\n  if (!proto.has_options()) {\n    result->options_ = NULL;  // Will set to default_instance later.\n  } else {\n    AllocateOptions(proto.options(), result);\n  }\n\n\n  AddSymbol(result->full_name(), parent, result->name(),\n            proto, Symbol(result));\n}\n\nvoid DescriptorBuilder::BuildExtensionRange(\n    const DescriptorProto::ExtensionRange& proto,\n    const Descriptor* parent,\n    Descriptor::ExtensionRange* result) {\n  result->start = proto.start();\n  result->end = proto.end();\n  if (result->start <= 0) {\n    AddError(parent->full_name(), proto,\n             DescriptorPool::ErrorCollector::NUMBER,\n             \"Extension numbers must be positive integers.\");\n  }\n\n  // Checking of the upper bound of the extension range is deferred until after\n  // options interpreting. This allows messages with message_set_wire_format to\n  // have extensions beyond FieldDescriptor::kMaxNumber, since the extension\n  // numbers are actually used as int32s in the message_set_wire_format.\n\n  if (result->start >= result->end) {\n    AddError(parent->full_name(), proto,\n             DescriptorPool::ErrorCollector::NUMBER,\n             \"Extension range end number must be greater than start number.\");\n  }\n}\n\nvoid DescriptorBuilder::BuildReservedRange(\n    const DescriptorProto::ReservedRange& proto,\n    const Descriptor* parent,\n    Descriptor::ReservedRange* result) {\n  result->start = proto.start();\n  result->end = proto.end();\n  if (result->start <= 0) {\n    AddError(parent->full_name(), proto,\n             DescriptorPool::ErrorCollector::NUMBER,\n             \"Reserved numbers must be positive integers.\");\n  }\n}\n\nvoid DescriptorBuilder::BuildOneof(const OneofDescriptorProto& proto,\n                                   Descriptor* parent,\n                                   OneofDescriptor* result) {\n  string* full_name = tables_->AllocateString(parent->full_name());\n  full_name->append(1, '.');\n  full_name->append(proto.name());\n\n  ValidateSymbolName(proto.name(), *full_name, proto);\n\n  result->name_ = tables_->AllocateString(proto.name());\n  result->full_name_ = full_name;\n\n  result->containing_type_ = parent;\n\n  // We need to fill these in later.\n  result->field_count_ = 0;\n  result->fields_ = NULL;\n\n  // Copy options.\n  if (!proto.has_options()) {\n    result->options_ = NULL;  // Will set to default_instance later.\n  } else {\n    AllocateOptions(proto.options(), result);\n  }\n\n  AddSymbol(result->full_name(), parent, result->name(),\n            proto, Symbol(result));\n}\n\nvoid DescriptorBuilder::BuildEnum(const EnumDescriptorProto& proto,\n                                  const Descriptor* parent,\n                                  EnumDescriptor* result) {\n  const string& scope = (parent == NULL) ?\n    file_->package() : parent->full_name();\n  string* full_name = tables_->AllocateString(scope);\n  if (!full_name->empty()) full_name->append(1, '.');\n  full_name->append(proto.name());\n\n  ValidateSymbolName(proto.name(), *full_name, proto);\n\n  result->name_            = tables_->AllocateString(proto.name());\n  result->full_name_       = full_name;\n  result->file_            = file_;\n  result->containing_type_ = parent;\n  result->is_placeholder_  = false;\n  result->is_unqualified_placeholder_ = false;\n\n  if (proto.value_size() == 0) {\n    // We cannot allow enums with no values because this would mean there\n    // would be no valid default value for fields of this type.\n    AddError(result->full_name(), proto,\n             DescriptorPool::ErrorCollector::NAME,\n             \"Enums must contain at least one value.\");\n  }\n\n  BUILD_ARRAY(proto, result, value, BuildEnumValue, result);\n\n  // Copy options.\n  if (!proto.has_options()) {\n    result->options_ = NULL;  // Will set to default_instance later.\n  } else {\n    AllocateOptions(proto.options(), result);\n  }\n\n  AddSymbol(result->full_name(), parent, result->name(),\n            proto, Symbol(result));\n}\n\nvoid DescriptorBuilder::BuildEnumValue(const EnumValueDescriptorProto& proto,\n                                       const EnumDescriptor* parent,\n                                       EnumValueDescriptor* result) {\n  result->name_   = tables_->AllocateString(proto.name());\n  result->number_ = proto.number();\n  result->type_   = parent;\n\n  // Note:  full_name for enum values is a sibling to the parent's name, not a\n  //   child of it.\n  string* full_name = tables_->AllocateString(*parent->full_name_);\n  full_name->resize(full_name->size() - parent->name_->size());\n  full_name->append(*result->name_);\n  result->full_name_ = full_name;\n\n  ValidateSymbolName(proto.name(), *full_name, proto);\n\n  // Copy options.\n  if (!proto.has_options()) {\n    result->options_ = NULL;  // Will set to default_instance later.\n  } else {\n    AllocateOptions(proto.options(), result);\n  }\n\n  // Again, enum values are weird because we makes them appear as siblings\n  // of the enum type instead of children of it.  So, we use\n  // parent->containing_type() as the value's parent.\n  bool added_to_outer_scope =\n    AddSymbol(result->full_name(), parent->containing_type(), result->name(),\n              proto, Symbol(result));\n\n  // However, we also want to be able to search for values within a single\n  // enum type, so we add it as a child of the enum type itself, too.\n  // Note:  This could fail, but if it does, the error has already been\n  //   reported by the above AddSymbol() call, so we ignore the return code.\n  bool added_to_inner_scope =\n    file_tables_->AddAliasUnderParent(parent, result->name(), Symbol(result));\n\n  if (added_to_inner_scope && !added_to_outer_scope) {\n    // This value did not conflict with any values defined in the same enum,\n    // but it did conflict with some other symbol defined in the enum type's\n    // scope.  Let's print an additional error to explain this.\n    string outer_scope;\n    if (parent->containing_type() == NULL) {\n      outer_scope = file_->package();\n    } else {\n      outer_scope = parent->containing_type()->full_name();\n    }\n\n    if (outer_scope.empty()) {\n      outer_scope = \"the global scope\";\n    } else {\n      outer_scope = \"\\\"\" + outer_scope + \"\\\"\";\n    }\n\n    AddError(result->full_name(), proto,\n             DescriptorPool::ErrorCollector::NAME,\n             \"Note that enum values use C++ scoping rules, meaning that \"\n             \"enum values are siblings of their type, not children of it.  \"\n             \"Therefore, \\\"\" + result->name() + \"\\\" must be unique within \"\n             + outer_scope + \", not just within \\\"\" + parent->name() + \"\\\".\");\n  }\n\n  // An enum is allowed to define two numbers that refer to the same value.\n  // FindValueByNumber() should return the first such value, so we simply\n  // ignore AddEnumValueByNumber()'s return code.\n  file_tables_->AddEnumValueByNumber(result);\n}\n\nvoid DescriptorBuilder::BuildService(const ServiceDescriptorProto& proto,\n                                     const void* /* dummy */,\n                                     ServiceDescriptor* result) {\n  string* full_name = tables_->AllocateString(file_->package());\n  if (!full_name->empty()) full_name->append(1, '.');\n  full_name->append(proto.name());\n\n  ValidateSymbolName(proto.name(), *full_name, proto);\n\n  result->name_      = tables_->AllocateString(proto.name());\n  result->full_name_ = full_name;\n  result->file_      = file_;\n\n  BUILD_ARRAY(proto, result, method, BuildMethod, result);\n\n  // Copy options.\n  if (!proto.has_options()) {\n    result->options_ = NULL;  // Will set to default_instance later.\n  } else {\n    AllocateOptions(proto.options(), result);\n  }\n\n  AddSymbol(result->full_name(), NULL, result->name(),\n            proto, Symbol(result));\n}\n\nvoid DescriptorBuilder::BuildMethod(const MethodDescriptorProto& proto,\n                                    const ServiceDescriptor* parent,\n                                    MethodDescriptor* result) {\n  result->name_    = tables_->AllocateString(proto.name());\n  result->service_ = parent;\n\n  string* full_name = tables_->AllocateString(parent->full_name());\n  full_name->append(1, '.');\n  full_name->append(*result->name_);\n  result->full_name_ = full_name;\n\n  ValidateSymbolName(proto.name(), *full_name, proto);\n\n  // These will be filled in when cross-linking.\n  result->input_type_ = NULL;\n  result->output_type_ = NULL;\n\n  // Copy options.\n  if (!proto.has_options()) {\n    result->options_ = NULL;  // Will set to default_instance later.\n  } else {\n    AllocateOptions(proto.options(), result);\n  }\n\n  result->client_streaming_ = proto.client_streaming();\n  result->server_streaming_ = proto.server_streaming();\n\n  AddSymbol(result->full_name(), parent, result->name(),\n            proto, Symbol(result));\n}\n\n#undef BUILD_ARRAY\n\n// -------------------------------------------------------------------\n\nvoid DescriptorBuilder::CrossLinkFile(\n    FileDescriptor* file, const FileDescriptorProto& proto) {\n  if (file->options_ == NULL) {\n    file->options_ = &FileOptions::default_instance();\n  }\n\n  for (int i = 0; i < file->message_type_count(); i++) {\n    CrossLinkMessage(&file->message_types_[i], proto.message_type(i));\n  }\n\n  for (int i = 0; i < file->extension_count(); i++) {\n    CrossLinkField(&file->extensions_[i], proto.extension(i));\n  }\n\n  for (int i = 0; i < file->enum_type_count(); i++) {\n    CrossLinkEnum(&file->enum_types_[i], proto.enum_type(i));\n  }\n\n  for (int i = 0; i < file->service_count(); i++) {\n    CrossLinkService(&file->services_[i], proto.service(i));\n  }\n}\n\nvoid DescriptorBuilder::CrossLinkMessage(\n    Descriptor* message, const DescriptorProto& proto) {\n  if (message->options_ == NULL) {\n    message->options_ = &MessageOptions::default_instance();\n  }\n\n  for (int i = 0; i < message->nested_type_count(); i++) {\n    CrossLinkMessage(&message->nested_types_[i], proto.nested_type(i));\n  }\n\n  for (int i = 0; i < message->enum_type_count(); i++) {\n    CrossLinkEnum(&message->enum_types_[i], proto.enum_type(i));\n  }\n\n  for (int i = 0; i < message->field_count(); i++) {\n    CrossLinkField(&message->fields_[i], proto.field(i));\n  }\n\n  for (int i = 0; i < message->extension_count(); i++) {\n    CrossLinkField(&message->extensions_[i], proto.extension(i));\n  }\n\n  // Set up field array for each oneof.\n\n  // First count the number of fields per oneof.\n  for (int i = 0; i < message->field_count(); i++) {\n    const OneofDescriptor* oneof_decl = message->field(i)->containing_oneof();\n    if (oneof_decl != NULL) {\n      // Make sure fields belonging to the same oneof are defined consecutively.\n      // This enables optimizations in codegens and reflection libraries to\n      // skip fields in the oneof group, as only one of the field can be set.\n      // Note that field_count() returns how many fields in this oneof we have\n      // seen so far. field_count() > 0 guarantees that i > 0, so field(i-1) is\n      // safe.\n      if (oneof_decl->field_count() > 0 &&\n          message->field(i - 1)->containing_oneof() != oneof_decl) {\n        AddError(\n            message->full_name() + \".\" + message->field(i - 1)->name(),\n            proto.field(i - 1), DescriptorPool::ErrorCollector::OTHER,\n            strings::Substitute(\n                \"Fields in the same oneof must be defined consecutively. \"\n                \"\\\"$0\\\" cannot be defined before the completion of the \"\n                \"\\\"$1\\\" oneof definition.\",\n                message->field(i - 1)->name(), oneof_decl->name()));\n      }\n      // Must go through oneof_decls_ array to get a non-const version of the\n      // OneofDescriptor.\n      ++message->oneof_decls_[oneof_decl->index()].field_count_;\n    }\n  }\n\n  // Then allocate the arrays.\n  for (int i = 0; i < message->oneof_decl_count(); i++) {\n    OneofDescriptor* oneof_decl = &message->oneof_decls_[i];\n\n    if (oneof_decl->field_count() == 0) {\n      AddError(message->full_name() + \".\" + oneof_decl->name(),\n               proto.oneof_decl(i),\n               DescriptorPool::ErrorCollector::NAME,\n               \"Oneof must have at least one field.\");\n    }\n\n    oneof_decl->fields_ =\n      tables_->AllocateArray<const FieldDescriptor*>(oneof_decl->field_count_);\n    oneof_decl->field_count_ = 0;\n\n    if (oneof_decl->options_ == NULL) {\n      oneof_decl->options_ = &OneofOptions::default_instance();\n    }\n  }\n\n  // Then fill them in.\n  for (int i = 0; i < message->field_count(); i++) {\n    const OneofDescriptor* oneof_decl = message->field(i)->containing_oneof();\n    if (oneof_decl != NULL) {\n      OneofDescriptor* mutable_oneof_decl =\n          &message->oneof_decls_[oneof_decl->index()];\n      message->fields_[i].index_in_oneof_ = mutable_oneof_decl->field_count_;\n      mutable_oneof_decl->fields_[mutable_oneof_decl->field_count_++] =\n          message->field(i);\n    }\n  }\n}\n\nvoid DescriptorBuilder::CrossLinkField(\n    FieldDescriptor* field, const FieldDescriptorProto& proto) {\n  if (field->options_ == NULL) {\n    field->options_ = &FieldOptions::default_instance();\n  }\n\n  if (proto.has_extendee()) {\n    Symbol extendee = LookupSymbol(proto.extendee(), field->full_name(),\n                                   PLACEHOLDER_EXTENDABLE_MESSAGE);\n    if (extendee.IsNull()) {\n      AddNotDefinedError(field->full_name(), proto,\n                         DescriptorPool::ErrorCollector::EXTENDEE,\n                         proto.extendee());\n      return;\n    } else if (extendee.type != Symbol::MESSAGE) {\n      AddError(field->full_name(), proto,\n               DescriptorPool::ErrorCollector::EXTENDEE,\n               \"\\\"\" + proto.extendee() + \"\\\" is not a message type.\");\n      return;\n    }\n    field->containing_type_ = extendee.descriptor;\n\n    const Descriptor::ExtensionRange* extension_range = field->containing_type()\n        ->FindExtensionRangeContainingNumber(field->number());\n\n    if (extension_range == NULL) {\n      AddError(field->full_name(), proto,\n               DescriptorPool::ErrorCollector::NUMBER,\n               strings::Substitute(\"\\\"$0\\\" does not declare $1 as an \"\n                                   \"extension number.\",\n                                   field->containing_type()->full_name(),\n                                   field->number()));\n    }\n  }\n\n  if (field->containing_oneof() != NULL) {\n    if (field->label() != FieldDescriptor::LABEL_OPTIONAL) {\n      // Note that this error will never happen when parsing .proto files.\n      // It can only happen if you manually construct a FileDescriptorProto\n      // that is incorrect.\n      AddError(field->full_name(), proto,\n               DescriptorPool::ErrorCollector::NAME,\n               \"Fields of oneofs must themselves have label LABEL_OPTIONAL.\");\n    }\n  }\n\n  if (proto.has_type_name()) {\n    // Assume we are expecting a message type unless the proto contains some\n    // evidence that it expects an enum type.  This only makes a difference if\n    // we end up creating a placeholder.\n    bool expecting_enum = (proto.type() == FieldDescriptorProto::TYPE_ENUM) ||\n                          proto.has_default_value();\n\n    Symbol type =\n      LookupSymbol(proto.type_name(), field->full_name(),\n                   expecting_enum ? PLACEHOLDER_ENUM : PLACEHOLDER_MESSAGE,\n                   LOOKUP_TYPES);\n\n    // If the type is a weak type, we change the type to a google.protobuf.Empty field.\n    if (type.IsNull() && !pool_->enforce_weak_ && proto.options().weak()) {\n      type = FindSymbol(kNonLinkedWeakMessageReplacementName);\n    }\n\n    if (type.IsNull()) {\n      AddNotDefinedError(field->full_name(), proto,\n                         DescriptorPool::ErrorCollector::TYPE,\n                         proto.type_name());\n      return;\n    }\n\n    if (!proto.has_type()) {\n      // Choose field type based on symbol.\n      if (type.type == Symbol::MESSAGE) {\n        field->type_ = FieldDescriptor::TYPE_MESSAGE;\n      } else if (type.type == Symbol::ENUM) {\n        field->type_ = FieldDescriptor::TYPE_ENUM;\n      } else {\n        AddError(field->full_name(), proto,\n                 DescriptorPool::ErrorCollector::TYPE,\n                 \"\\\"\" + proto.type_name() + \"\\\" is not a type.\");\n        return;\n      }\n    }\n\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n      if (type.type != Symbol::MESSAGE) {\n        AddError(field->full_name(), proto,\n                 DescriptorPool::ErrorCollector::TYPE,\n                 \"\\\"\" + proto.type_name() + \"\\\" is not a message type.\");\n        return;\n      }\n      field->message_type_ = type.descriptor;\n\n      if (field->has_default_value()) {\n        AddError(field->full_name(), proto,\n                 DescriptorPool::ErrorCollector::DEFAULT_VALUE,\n                 \"Messages can't have default values.\");\n      }\n    } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {\n      if (type.type != Symbol::ENUM) {\n        AddError(field->full_name(), proto,\n                 DescriptorPool::ErrorCollector::TYPE,\n                 \"\\\"\" + proto.type_name() + \"\\\" is not an enum type.\");\n        return;\n      }\n      field->enum_type_ = type.enum_descriptor;\n\n      if (field->enum_type()->is_placeholder_) {\n        // We can't look up default values for placeholder types.  We'll have\n        // to just drop them.\n        field->has_default_value_ = false;\n      }\n\n      if (field->has_default_value()) {\n        // Ensure that the default value is an identifier. Parser cannot always\n        // verify this because it does not have complete type information.\n        // N.B. that this check yields better error messages but is not\n        // necessary for correctness (an enum symbol must be a valid identifier\n        // anyway), only for better errors.\n        if (!io::Tokenizer::IsIdentifier(proto.default_value())) {\n          AddError(field->full_name(), proto,\n                   DescriptorPool::ErrorCollector::DEFAULT_VALUE,\n                   \"Default value for an enum field must be an identifier.\");\n        } else {\n          // We can't just use field->enum_type()->FindValueByName() here\n          // because that locks the pool's mutex, which we have already locked\n          // at this point.\n          Symbol default_value =\n            LookupSymbolNoPlaceholder(proto.default_value(),\n                                      field->enum_type()->full_name());\n\n          if (default_value.type == Symbol::ENUM_VALUE &&\n              default_value.enum_value_descriptor->type() ==\n              field->enum_type()) {\n            field->default_value_enum_ = default_value.enum_value_descriptor;\n          } else {\n            AddError(field->full_name(), proto,\n                     DescriptorPool::ErrorCollector::DEFAULT_VALUE,\n                     \"Enum type \\\"\" + field->enum_type()->full_name() +\n                     \"\\\" has no value named \\\"\" + proto.default_value() +\n                     \"\\\".\");\n          }\n        }\n      } else if (field->enum_type()->value_count() > 0) {\n        // All enums must have at least one value, or we would have reported\n        // an error elsewhere.  We use the first defined value as the default\n        // if a default is not explicitly defined.\n        field->default_value_enum_ = field->enum_type()->value(0);\n      }\n    } else {\n      AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE,\n               \"Field with primitive type has type_name.\");\n    }\n  } else {\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE ||\n        field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {\n      AddError(field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE,\n               \"Field with message or enum type missing type_name.\");\n    }\n  }\n\n  // Add the field to the fields-by-number table.\n  // Note:  We have to do this *after* cross-linking because extensions do not\n  //   know their containing type until now.\n  if (!file_tables_->AddFieldByNumber(field)) {\n    const FieldDescriptor* conflicting_field =\n      file_tables_->FindFieldByNumber(field->containing_type(),\n                                      field->number());\n    if (field->is_extension()) {\n      AddError(field->full_name(), proto,\n               DescriptorPool::ErrorCollector::NUMBER,\n               strings::Substitute(\"Extension number $0 has already been used \"\n                                   \"in \\\"$1\\\" by extension \\\"$2\\\".\",\n                                   field->number(),\n                                   field->containing_type()->full_name(),\n                                   conflicting_field->full_name()));\n    } else {\n      AddError(field->full_name(), proto,\n               DescriptorPool::ErrorCollector::NUMBER,\n               strings::Substitute(\"Field number $0 has already been used in \"\n                                   \"\\\"$1\\\" by field \\\"$2\\\".\",\n                                   field->number(),\n                                   field->containing_type()->full_name(),\n                                   conflicting_field->name()));\n    }\n  } else {\n    if (field->is_extension()) {\n      if (!tables_->AddExtension(field)) {\n        const FieldDescriptor* conflicting_field =\n            tables_->FindExtension(field->containing_type(), field->number());\n        string error_msg = strings::Substitute(\n            \"Extension number $0 has already been used in \\\"$1\\\" by extension \"\n            \"\\\"$2\\\" defined in $3.\",\n            field->number(),\n            field->containing_type()->full_name(),\n            conflicting_field->full_name(),\n            conflicting_field->file()->name());\n        // Conflicting extension numbers should be an error. However, before\n        // turning this into an error we need to fix all existing broken\n        // protos first.\n        // TODO(xiaofeng): Change this to an error.\n        AddWarning(field->full_name(), proto,\n                   DescriptorPool::ErrorCollector::NUMBER, error_msg);\n      }\n    }\n  }\n\n  // Add the field to the lowercase-name and camelcase-name tables.\n  file_tables_->AddFieldByStylizedNames(field);\n}\n\nvoid DescriptorBuilder::CrossLinkEnum(\n    EnumDescriptor* enum_type, const EnumDescriptorProto& proto) {\n  if (enum_type->options_ == NULL) {\n    enum_type->options_ = &EnumOptions::default_instance();\n  }\n\n  for (int i = 0; i < enum_type->value_count(); i++) {\n    CrossLinkEnumValue(&enum_type->values_[i], proto.value(i));\n  }\n}\n\nvoid DescriptorBuilder::CrossLinkEnumValue(\n    EnumValueDescriptor* enum_value,\n    const EnumValueDescriptorProto& /* proto */) {\n  if (enum_value->options_ == NULL) {\n    enum_value->options_ = &EnumValueOptions::default_instance();\n  }\n}\n\nvoid DescriptorBuilder::CrossLinkService(\n    ServiceDescriptor* service, const ServiceDescriptorProto& proto) {\n  if (service->options_ == NULL) {\n    service->options_ = &ServiceOptions::default_instance();\n  }\n\n  for (int i = 0; i < service->method_count(); i++) {\n    CrossLinkMethod(&service->methods_[i], proto.method(i));\n  }\n}\n\nvoid DescriptorBuilder::CrossLinkMethod(\n    MethodDescriptor* method, const MethodDescriptorProto& proto) {\n  if (method->options_ == NULL) {\n    method->options_ = &MethodOptions::default_instance();\n  }\n\n  Symbol input_type = LookupSymbol(proto.input_type(), method->full_name());\n  if (input_type.IsNull()) {\n    AddNotDefinedError(method->full_name(), proto,\n                       DescriptorPool::ErrorCollector::INPUT_TYPE,\n                       proto.input_type());\n  } else if (input_type.type != Symbol::MESSAGE) {\n    AddError(method->full_name(), proto,\n             DescriptorPool::ErrorCollector::INPUT_TYPE,\n             \"\\\"\" + proto.input_type() + \"\\\" is not a message type.\");\n  } else {\n    method->input_type_ = input_type.descriptor;\n  }\n\n  Symbol output_type = LookupSymbol(proto.output_type(), method->full_name());\n  if (output_type.IsNull()) {\n    AddNotDefinedError(method->full_name(), proto,\n                       DescriptorPool::ErrorCollector::OUTPUT_TYPE,\n                       proto.output_type());\n  } else if (output_type.type != Symbol::MESSAGE) {\n    AddError(method->full_name(), proto,\n             DescriptorPool::ErrorCollector::OUTPUT_TYPE,\n             \"\\\"\" + proto.output_type() + \"\\\" is not a message type.\");\n  } else {\n    method->output_type_ = output_type.descriptor;\n  }\n}\n\n// -------------------------------------------------------------------\n\n#define VALIDATE_OPTIONS_FROM_ARRAY(descriptor, array_name, type)  \\\n  for (int i = 0; i < descriptor->array_name##_count(); ++i) {     \\\n    Validate##type##Options(descriptor->array_name##s_ + i,        \\\n                            proto.array_name(i));                  \\\n  }\n\n// Determine if the file uses optimize_for = LITE_RUNTIME, being careful to\n// avoid problems that exist at init time.\nstatic bool IsLite(const FileDescriptor* file) {\n  // TODO(kenton):  I don't even remember how many of these conditions are\n  //   actually possible.  I'm just being super-safe.\n  return file != NULL &&\n         &file->options() != &FileOptions::default_instance() &&\n         file->options().optimize_for() == FileOptions::LITE_RUNTIME;\n}\n\nvoid DescriptorBuilder::ValidateFileOptions(FileDescriptor* file,\n                                            const FileDescriptorProto& proto) {\n  VALIDATE_OPTIONS_FROM_ARRAY(file, message_type, Message);\n  VALIDATE_OPTIONS_FROM_ARRAY(file, enum_type, Enum);\n  VALIDATE_OPTIONS_FROM_ARRAY(file, service, Service);\n  VALIDATE_OPTIONS_FROM_ARRAY(file, extension, Field);\n\n  // Lite files can only be imported by other Lite files.\n  if (!IsLite(file)) {\n    for (int i = 0; i < file->dependency_count(); i++) {\n      if (IsLite(file->dependency(i))) {\n        AddError(\n          file->name(), proto,\n          DescriptorPool::ErrorCollector::OTHER,\n          \"Files that do not use optimize_for = LITE_RUNTIME cannot import \"\n          \"files which do use this option.  This file is not lite, but it \"\n          \"imports \\\"\" + file->dependency(i)->name() + \"\\\" which is.\");\n        break;\n      }\n    }\n  }\n  if (file->syntax() == FileDescriptor::SYNTAX_PROTO3) {\n    ValidateProto3(file, proto);\n  }\n}\n\nvoid DescriptorBuilder::ValidateProto3(\n    FileDescriptor* file, const FileDescriptorProto& proto) {\n  for (int i = 0; i < file->extension_count(); ++i) {\n    ValidateProto3Field(file->extensions_ + i, proto.extension(i));\n  }\n  for (int i = 0; i < file->message_type_count(); ++i) {\n    ValidateProto3Message(file->message_types_ + i, proto.message_type(i));\n  }\n  for (int i = 0; i < file->enum_type_count(); ++i) {\n    ValidateProto3Enum(file->enum_types_ + i, proto.enum_type(i));\n  }\n}\n\nstatic string ToLowercaseWithoutUnderscores(const string& name) {\n  string result;\n  for (int i = 0; i < name.size(); ++i) {\n    if (name[i] != '_') {\n      if (name[i] >= 'A' && name[i] <= 'Z') {\n        result.push_back(name[i] - 'A' + 'a');\n      } else {\n        result.push_back(name[i]);\n      }\n    }\n  }\n  return result;\n}\n\nvoid DescriptorBuilder::ValidateProto3Message(\n    Descriptor* message, const DescriptorProto& proto) {\n  for (int i = 0; i < message->nested_type_count(); ++i) {\n    ValidateProto3Message(message->nested_types_ + i,\n                                 proto.nested_type(i));\n  }\n  for (int i = 0; i < message->enum_type_count(); ++i) {\n    ValidateProto3Enum(message->enum_types_ + i,\n                              proto.enum_type(i));\n  }\n  for (int i = 0; i < message->field_count(); ++i) {\n    ValidateProto3Field(message->fields_ + i, proto.field(i));\n  }\n  for (int i = 0; i < message->extension_count(); ++i) {\n    ValidateProto3Field(message->extensions_ +i, proto.extension(i));\n  }\n  if (message->extension_range_count() > 0) {\n    AddError(message->full_name(), proto,\n             DescriptorPool::ErrorCollector::OTHER,\n             \"Extension ranges are not allowed in proto3.\");\n  }\n  if (message->options().message_set_wire_format()) {\n    // Using MessageSet doesn't make sense since we disallow extensions.\n    AddError(message->full_name(), proto,\n             DescriptorPool::ErrorCollector::OTHER,\n             \"MessageSet is not supported in proto3.\");\n  }\n\n  // In proto3, we reject field names if they conflict in camelCase.\n  // Note that we currently enforce a stricter rule: Field names must be\n  // unique after being converted to lowercase with underscores removed.\n  map<string, const FieldDescriptor*> name_to_field;\n  for (int i = 0; i < message->field_count(); ++i) {\n    string lowercase_name = ToLowercaseWithoutUnderscores(\n        message->field(i)->name());\n    if (name_to_field.find(lowercase_name) != name_to_field.end()) {\n      AddError(message->full_name(), proto,\n               DescriptorPool::ErrorCollector::OTHER,\n               \"The JSON camel-case name of field \\\"\" +\n               message->field(i)->name() + \"\\\" conflicts with field \\\"\" +\n               name_to_field[lowercase_name]->name() + \"\\\". This is not \" +\n               \"allowed in proto3.\");\n    } else {\n      name_to_field[lowercase_name] = message->field(i);\n    }\n  }\n}\n\nvoid DescriptorBuilder::ValidateProto3Field(\n    FieldDescriptor* field, const FieldDescriptorProto& proto) {\n  if (field->is_extension() &&\n      !AllowedExtendeeInProto3(field->containing_type()->full_name())) {\n    AddError(field->full_name(), proto,\n             DescriptorPool::ErrorCollector::OTHER,\n             \"Extensions in proto3 are only allowed for defining options.\");\n  }\n  if (field->is_required()) {\n    AddError(field->full_name(), proto,\n             DescriptorPool::ErrorCollector::OTHER,\n             \"Required fields are not allowed in proto3.\");\n  }\n  if (field->has_default_value()) {\n    AddError(\n        field->full_name(), proto, DescriptorPool::ErrorCollector::OTHER,\n        \"Explicit default values are not allowed in proto3.\");\n  }\n  if (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM &&\n      field->enum_type() &&\n      field->enum_type()->file()->syntax() != FileDescriptor::SYNTAX_PROTO3) {\n    // Proto3 messages can only use Proto3 enum types; otherwise we can't\n    // guarantee that the default value is zero.\n    AddError(field->full_name(), proto,\n             DescriptorPool::ErrorCollector::TYPE,\n             \"Enum type \\\"\" + field->enum_type()->full_name() +\n             \"\\\" is not a proto3 enum, but is used in \\\"\" +\n             field->containing_type()->full_name() +\n             \"\\\" which is a proto3 message type.\");\n  }\n  if (field->type() == FieldDescriptor::TYPE_GROUP) {\n    AddError(field->full_name(), proto,\n             DescriptorPool::ErrorCollector::TYPE,\n             \"Groups are not supported in proto3 syntax.\");\n  }\n}\n\nvoid DescriptorBuilder::ValidateProto3Enum(\n    EnumDescriptor* enm, const EnumDescriptorProto& proto) {\n  if (enm->value_count() > 0 && enm->value(0)->number() != 0) {\n    AddError(\n        enm->full_name(), proto, DescriptorPool::ErrorCollector::OTHER,\n        \"The first enum value must be zero in proto3.\");\n  }\n}\n\n\nvoid DescriptorBuilder::ValidateMessageOptions(Descriptor* message,\n                                               const DescriptorProto& proto) {\n  VALIDATE_OPTIONS_FROM_ARRAY(message, field, Field);\n  VALIDATE_OPTIONS_FROM_ARRAY(message, nested_type, Message);\n  VALIDATE_OPTIONS_FROM_ARRAY(message, enum_type, Enum);\n  VALIDATE_OPTIONS_FROM_ARRAY(message, extension, Field);\n\n  const int64 max_extension_range =\n      static_cast<int64>(message->options().message_set_wire_format() ?\n                         kint32max :\n                         FieldDescriptor::kMaxNumber);\n  for (int i = 0; i < message->extension_range_count(); ++i) {\n    if (message->extension_range(i)->end > max_extension_range + 1) {\n      AddError(\n          message->full_name(), proto.extension_range(i),\n          DescriptorPool::ErrorCollector::NUMBER,\n          strings::Substitute(\"Extension numbers cannot be greater than $0.\",\n                              max_extension_range));\n    }\n  }\n\n}\n\nvoid DescriptorBuilder::ValidateFieldOptions(FieldDescriptor* field,\n    const FieldDescriptorProto& proto) {\n  // Only message type fields may be lazy.\n  if (field->options().lazy()) {\n    if (field->type() != FieldDescriptor::TYPE_MESSAGE) {\n      AddError(field->full_name(), proto,\n               DescriptorPool::ErrorCollector::TYPE,\n               \"[lazy = true] can only be specified for submessage fields.\");\n    }\n  }\n\n  // Only repeated primitive fields may be packed.\n  if (field->options().packed() && !field->is_packable()) {\n    AddError(\n      field->full_name(), proto,\n      DescriptorPool::ErrorCollector::TYPE,\n      \"[packed = true] can only be specified for repeated primitive fields.\");\n  }\n\n  // Note:  Default instance may not yet be initialized here, so we have to\n  //   avoid reading from it.\n  if (field->containing_type_ != NULL &&\n      &field->containing_type()->options() !=\n      &MessageOptions::default_instance() &&\n      field->containing_type()->options().message_set_wire_format()) {\n    if (field->is_extension()) {\n      if (!field->is_optional() ||\n          field->type() != FieldDescriptor::TYPE_MESSAGE) {\n        AddError(field->full_name(), proto,\n                 DescriptorPool::ErrorCollector::TYPE,\n                 \"Extensions of MessageSets must be optional messages.\");\n      }\n    } else {\n      AddError(field->full_name(), proto,\n               DescriptorPool::ErrorCollector::NAME,\n               \"MessageSets cannot have fields, only extensions.\");\n    }\n  }\n\n  // Lite extensions can only be of Lite types.\n  if (IsLite(field->file()) &&\n      field->containing_type_ != NULL &&\n      !IsLite(field->containing_type()->file())) {\n    AddError(field->full_name(), proto,\n             DescriptorPool::ErrorCollector::EXTENDEE,\n             \"Extensions to non-lite types can only be declared in non-lite \"\n             \"files.  Note that you cannot extend a non-lite type to contain \"\n             \"a lite type, but the reverse is allowed.\");\n  }\n\n  // Validate map types.\n  if (field->is_map()) {\n    if (!ValidateMapEntry(field, proto)) {\n      AddError(field->full_name(), proto,\n               DescriptorPool::ErrorCollector::OTHER,\n               \"map_entry should not be set explicitly. Use map<KeyType, \"\n               \"ValueType> instead.\");\n    }\n  }\n\n}\n\nvoid DescriptorBuilder::ValidateEnumOptions(EnumDescriptor* enm,\n                                            const EnumDescriptorProto& proto) {\n  VALIDATE_OPTIONS_FROM_ARRAY(enm, value, EnumValue);\n  if (!enm->options().has_allow_alias() || !enm->options().allow_alias()) {\n    map<int, string> used_values;\n    for (int i = 0; i < enm->value_count(); ++i) {\n      const EnumValueDescriptor* enum_value = enm->value(i);\n      if (used_values.find(enum_value->number()) != used_values.end()) {\n        string error =\n            \"\\\"\" + enum_value->full_name() +\n            \"\\\" uses the same enum value as \\\"\" +\n            used_values[enum_value->number()] + \"\\\". If this is intended, set \"\n            \"'option allow_alias = true;' to the enum definition.\";\n        if (!enm->options().allow_alias()) {\n          // Generate error if duplicated enum values are explicitly disallowed.\n          AddError(enm->full_name(), proto,\n                   DescriptorPool::ErrorCollector::NUMBER,\n                   error);\n        } else {\n          // Generate warning if duplicated values are found but the option\n          // isn't set.\n          GOOGLE_LOG(ERROR) << error;\n        }\n      } else {\n        used_values[enum_value->number()] = enum_value->full_name();\n      }\n    }\n  }\n}\n\nvoid DescriptorBuilder::ValidateEnumValueOptions(\n    EnumValueDescriptor* /* enum_value */,\n    const EnumValueDescriptorProto& /* proto */) {\n  // Nothing to do so far.\n}\nvoid DescriptorBuilder::ValidateServiceOptions(ServiceDescriptor* service,\n    const ServiceDescriptorProto& proto) {\n  if (IsLite(service->file()) &&\n      (service->file()->options().cc_generic_services() ||\n       service->file()->options().java_generic_services())) {\n    AddError(service->full_name(), proto,\n             DescriptorPool::ErrorCollector::NAME,\n             \"Files with optimize_for = LITE_RUNTIME cannot define services \"\n             \"unless you set both options cc_generic_services and \"\n             \"java_generic_sevices to false.\");\n  }\n\n  VALIDATE_OPTIONS_FROM_ARRAY(service, method, Method);\n}\n\nvoid DescriptorBuilder::ValidateMethodOptions(MethodDescriptor* /* method */,\n    const MethodDescriptorProto& /* proto */) {\n  // Nothing to do so far.\n}\n\nbool DescriptorBuilder::ValidateMapEntry(FieldDescriptor* field,\n                                         const FieldDescriptorProto& proto) {\n  const Descriptor* message = field->message_type();\n  if (// Must not contain extensions, extension range or nested message or\n      // enums\n      message->extension_count() != 0 ||\n      field->label() != FieldDescriptor::LABEL_REPEATED ||\n      message->extension_range_count() != 0 ||\n      message->nested_type_count() != 0 || message->enum_type_count() != 0 ||\n      // Must contain exactly two fields\n      message->field_count() != 2 ||\n      // Field name and message name must match\n      message->name() != ToCamelCase(field->name(), false) + \"Entry\" ||\n      // Entry message must be in the same containing type of the field.\n      field->containing_type() != message->containing_type()) {\n    return false;\n  }\n\n  const FieldDescriptor* key = message->field(0);\n  const FieldDescriptor* value = message->field(1);\n  if (key->label() != FieldDescriptor::LABEL_OPTIONAL || key->number() != 1 ||\n      key->name() != \"key\") {\n    return false;\n  }\n  if (value->label() != FieldDescriptor::LABEL_OPTIONAL ||\n      value->number() != 2 || value->name() != \"value\") {\n    return false;\n  }\n\n  // Check key types are legal.\n  switch (key->type()) {\n    case FieldDescriptor::TYPE_ENUM:\n      AddError(\n          field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE,\n          \"Key in map fields cannot be enum types.\");\n      break;\n    case FieldDescriptor::TYPE_FLOAT:\n    case FieldDescriptor::TYPE_DOUBLE:\n    case FieldDescriptor::TYPE_MESSAGE:\n    case FieldDescriptor::TYPE_GROUP:\n    case FieldDescriptor::TYPE_BYTES:\n      AddError(\n          field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE,\n          \"Key in map fields cannot be float/double, bytes or message types.\");\n      break;\n    case FieldDescriptor::TYPE_BOOL:\n    case FieldDescriptor::TYPE_INT32:\n    case FieldDescriptor::TYPE_INT64:\n    case FieldDescriptor::TYPE_SINT32:\n    case FieldDescriptor::TYPE_SINT64:\n    case FieldDescriptor::TYPE_STRING:\n    case FieldDescriptor::TYPE_UINT32:\n    case FieldDescriptor::TYPE_UINT64:\n    case FieldDescriptor::TYPE_FIXED32:\n    case FieldDescriptor::TYPE_FIXED64:\n    case FieldDescriptor::TYPE_SFIXED32:\n    case FieldDescriptor::TYPE_SFIXED64:\n      // Legal cases\n      break;\n    // Do not add a default, so that the compiler will complain when new types\n    // are added.\n  }\n\n  if (value->type() == FieldDescriptor::TYPE_ENUM) {\n    if (value->enum_type()->value(0)->number() != 0) {\n      AddError(\n          field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE,\n          \"Enum value in map must define 0 as the first value.\");\n    }\n  }\n\n  return true;\n}\n\nvoid DescriptorBuilder::DetectMapConflicts(const Descriptor* message,\n                                           const DescriptorProto& proto) {\n  map<string, const Descriptor*> seen_types;\n  for (int i = 0; i < message->nested_type_count(); ++i) {\n    const Descriptor* nested = message->nested_type(i);\n    pair<map<string, const Descriptor*>::iterator, bool> result =\n        seen_types.insert(std::make_pair(nested->name(), nested));\n    if (!result.second) {\n      if (result.first->second->options().map_entry() ||\n          nested->options().map_entry()) {\n        AddError(message->full_name(), proto,\n                 DescriptorPool::ErrorCollector::NAME,\n                 \"Expanded map entry type \" + nested->name() +\n                 \" conflicts with an existing nested message type.\");\n      }\n    }\n    // Recursively test on the nested types.\n    DetectMapConflicts(message->nested_type(i), proto.nested_type(i));\n  }\n  // Check for conflicted field names.\n  for (int i = 0; i < message->field_count(); ++i) {\n    const FieldDescriptor* field = message->field(i);\n    map<string, const Descriptor*>::iterator iter =\n        seen_types.find(field->name());\n    if (iter != seen_types.end() && iter->second->options().map_entry()) {\n      AddError(message->full_name(), proto,\n               DescriptorPool::ErrorCollector::NAME,\n               \"Expanded map entry type \" + iter->second->name() +\n               \" conflicts with an existing field.\");\n    }\n  }\n  // Check for conflicted enum names.\n  for (int i = 0; i < message->enum_type_count(); ++i) {\n    const EnumDescriptor* enum_desc = message->enum_type(i);\n    map<string, const Descriptor*>::iterator iter =\n        seen_types.find(enum_desc->name());\n    if (iter != seen_types.end() && iter->second->options().map_entry()) {\n      AddError(message->full_name(), proto,\n               DescriptorPool::ErrorCollector::NAME,\n               \"Expanded map entry type \" + iter->second->name() +\n               \" conflicts with an existing enum type.\");\n    }\n  }\n  // Check for conflicted oneof names.\n  for (int i = 0; i < message->oneof_decl_count(); ++i) {\n    const OneofDescriptor* oneof_desc = message->oneof_decl(i);\n    map<string, const Descriptor*>::iterator iter =\n        seen_types.find(oneof_desc->name());\n    if (iter != seen_types.end() && iter->second->options().map_entry()) {\n      AddError(message->full_name(), proto,\n               DescriptorPool::ErrorCollector::NAME,\n               \"Expanded map entry type \" + iter->second->name() +\n               \" conflicts with an existing oneof type.\");\n    }\n  }\n}\n\n\n#undef VALIDATE_OPTIONS_FROM_ARRAY\n\n// -------------------------------------------------------------------\n\nDescriptorBuilder::OptionInterpreter::OptionInterpreter(\n    DescriptorBuilder* builder) : builder_(builder) {\n  GOOGLE_CHECK(builder_);\n}\n\nDescriptorBuilder::OptionInterpreter::~OptionInterpreter() {\n}\n\nbool DescriptorBuilder::OptionInterpreter::InterpretOptions(\n    OptionsToInterpret* options_to_interpret) {\n  // Note that these may be in different pools, so we can't use the same\n  // descriptor and reflection objects on both.\n  Message* options = options_to_interpret->options;\n  const Message* original_options = options_to_interpret->original_options;\n\n  bool failed = false;\n  options_to_interpret_ = options_to_interpret;\n\n  // Find the uninterpreted_option field in the mutable copy of the options\n  // and clear them, since we're about to interpret them.\n  const FieldDescriptor* uninterpreted_options_field =\n      options->GetDescriptor()->FindFieldByName(\"uninterpreted_option\");\n  GOOGLE_CHECK(uninterpreted_options_field != NULL)\n      << \"No field named \\\"uninterpreted_option\\\" in the Options proto.\";\n  options->GetReflection()->ClearField(options, uninterpreted_options_field);\n\n  // Find the uninterpreted_option field in the original options.\n  const FieldDescriptor* original_uninterpreted_options_field =\n      original_options->GetDescriptor()->\n          FindFieldByName(\"uninterpreted_option\");\n  GOOGLE_CHECK(original_uninterpreted_options_field != NULL)\n      << \"No field named \\\"uninterpreted_option\\\" in the Options proto.\";\n\n  const int num_uninterpreted_options = original_options->GetReflection()->\n      FieldSize(*original_options, original_uninterpreted_options_field);\n  for (int i = 0; i < num_uninterpreted_options; ++i) {\n    uninterpreted_option_ = down_cast<const UninterpretedOption*>(\n        &original_options->GetReflection()->GetRepeatedMessage(\n            *original_options, original_uninterpreted_options_field, i));\n    if (!InterpretSingleOption(options)) {\n      // Error already added by InterpretSingleOption().\n      failed = true;\n      break;\n    }\n  }\n  // Reset these, so we don't have any dangling pointers.\n  uninterpreted_option_ = NULL;\n  options_to_interpret_ = NULL;\n\n  if (!failed) {\n    // InterpretSingleOption() added the interpreted options in the\n    // UnknownFieldSet, in case the option isn't yet known to us.  Now we\n    // serialize the options message and deserialize it back.  That way, any\n    // option fields that we do happen to know about will get moved from the\n    // UnknownFieldSet into the real fields, and thus be available right away.\n    // If they are not known, that's OK too. They will get reparsed into the\n    // UnknownFieldSet and wait there until the message is parsed by something\n    // that does know about the options.\n    string buf;\n    GOOGLE_CHECK(options->AppendPartialToString(&buf))\n        << \"Protocol message could not be serialized.\";\n    GOOGLE_CHECK(options->ParsePartialFromString(buf))\n        << \"Protocol message serialized itself in invalid fashion.\";\n    if (!options->IsInitialized()) {\n      builder_->AddWarning(\n          options_to_interpret->element_name, *original_options,\n          DescriptorPool::ErrorCollector::OTHER,\n          \"Options could not be fully parsed using the proto descriptors \"\n          \"compiled into this binary. Missing required fields: \" +\n          options->InitializationErrorString());\n    }\n  }\n  return !failed;\n}\n\nbool DescriptorBuilder::OptionInterpreter::InterpretSingleOption(\n    Message* options) {\n  // First do some basic validation.\n  if (uninterpreted_option_->name_size() == 0) {\n    // This should never happen unless the parser has gone seriously awry or\n    // someone has manually created the uninterpreted option badly.\n    return AddNameError(\"Option must have a name.\");\n  }\n  if (uninterpreted_option_->name(0).name_part() == \"uninterpreted_option\") {\n    return AddNameError(\"Option must not use reserved name \"\n                        \"\\\"uninterpreted_option\\\".\");\n  }\n\n  const Descriptor* options_descriptor = NULL;\n  // Get the options message's descriptor from the builder's pool, so that we\n  // get the version that knows about any extension options declared in the\n  // file we're currently building. The descriptor should be there as long as\n  // the file we're building imported \"google/protobuf/descriptors.proto\".\n\n  // Note that we use DescriptorBuilder::FindSymbolNotEnforcingDeps(), not\n  // DescriptorPool::FindMessageTypeByName() because we're already holding the\n  // pool's mutex, and the latter method locks it again.  We don't use\n  // FindSymbol() because files that use custom options only need to depend on\n  // the file that defines the option, not descriptor.proto itself.\n  Symbol symbol = builder_->FindSymbolNotEnforcingDeps(\n    options->GetDescriptor()->full_name());\n  if (!symbol.IsNull() && symbol.type == Symbol::MESSAGE) {\n    options_descriptor = symbol.descriptor;\n  } else {\n    // The options message's descriptor was not in the builder's pool, so use\n    // the standard version from the generated pool. We're not holding the\n    // generated pool's mutex, so we can search it the straightforward way.\n    options_descriptor = options->GetDescriptor();\n  }\n  GOOGLE_CHECK(options_descriptor);\n\n  // We iterate over the name parts to drill into the submessages until we find\n  // the leaf field for the option. As we drill down we remember the current\n  // submessage's descriptor in |descriptor| and the next field in that\n  // submessage in |field|. We also track the fields we're drilling down\n  // through in |intermediate_fields|. As we go, we reconstruct the full option\n  // name in |debug_msg_name|, for use in error messages.\n  const Descriptor* descriptor = options_descriptor;\n  const FieldDescriptor* field = NULL;\n  vector<const FieldDescriptor*> intermediate_fields;\n  string debug_msg_name = \"\";\n\n  for (int i = 0; i < uninterpreted_option_->name_size(); ++i) {\n    const string& name_part = uninterpreted_option_->name(i).name_part();\n    if (debug_msg_name.size() > 0) {\n      debug_msg_name += \".\";\n    }\n    if (uninterpreted_option_->name(i).is_extension()) {\n      debug_msg_name += \"(\" + name_part + \")\";\n      // Search for the extension's descriptor as an extension in the builder's\n      // pool. Note that we use DescriptorBuilder::LookupSymbol(), not\n      // DescriptorPool::FindExtensionByName(), for two reasons: 1) It allows\n      // relative lookups, and 2) because we're already holding the pool's\n      // mutex, and the latter method locks it again.\n      symbol = builder_->LookupSymbol(name_part,\n                                      options_to_interpret_->name_scope);\n      if (!symbol.IsNull() && symbol.type == Symbol::FIELD) {\n        field = symbol.field_descriptor;\n      }\n      // If we don't find the field then the field's descriptor was not in the\n      // builder's pool, but there's no point in looking in the generated\n      // pool. We require that you import the file that defines any extensions\n      // you use, so they must be present in the builder's pool.\n    } else {\n      debug_msg_name += name_part;\n      // Search for the field's descriptor as a regular field.\n      field = descriptor->FindFieldByName(name_part);\n    }\n\n    if (field == NULL) {\n      if (get_allow_unknown(builder_->pool_)) {\n        // We can't find the option, but AllowUnknownDependencies() is enabled,\n        // so we will just leave it as uninterpreted.\n        AddWithoutInterpreting(*uninterpreted_option_, options);\n        return true;\n      } else if (!(builder_->undefine_resolved_name_).empty()) {\n        // Option is resolved to a name which is not defined.\n        return AddNameError(\n            \"Option \\\"\" + debug_msg_name + \"\\\" is resolved to \\\"(\" +\n            builder_->undefine_resolved_name_ +\n            \")\\\", which is not defined. The innermost scope is searched first \"\n            \"in name resolution. Consider using a leading '.'(i.e., \\\"(.\" +\n            debug_msg_name.substr(1) +\n            \"\\\") to start from the outermost scope.\");\n      } else {\n        return AddNameError(\"Option \\\"\" + debug_msg_name + \"\\\" unknown.\");\n      }\n    } else if (field->containing_type() != descriptor) {\n      if (get_is_placeholder(field->containing_type())) {\n        // The field is an extension of a placeholder type, so we can't\n        // reliably verify whether it is a valid extension to use here (e.g.\n        // we don't know if it is an extension of the correct *Options message,\n        // or if it has a valid field number, etc.).  Just leave it as\n        // uninterpreted instead.\n        AddWithoutInterpreting(*uninterpreted_option_, options);\n        return true;\n      } else {\n        // This can only happen if, due to some insane misconfiguration of the\n        // pools, we find the options message in one pool but the field in\n        // another. This would probably imply a hefty bug somewhere.\n        return AddNameError(\"Option field \\\"\" + debug_msg_name +\n                            \"\\\" is not a field or extension of message \\\"\" +\n                            descriptor->name() + \"\\\".\");\n      }\n    } else if (i < uninterpreted_option_->name_size() - 1) {\n      if (field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) {\n        return AddNameError(\"Option \\\"\" +  debug_msg_name +\n                            \"\\\" is an atomic type, not a message.\");\n      } else if (field->is_repeated()) {\n        return AddNameError(\"Option field \\\"\" + debug_msg_name +\n                            \"\\\" is a repeated message. Repeated message \"\n                            \"options must be initialized using an \"\n                            \"aggregate value.\");\n      } else {\n        // Drill down into the submessage.\n        intermediate_fields.push_back(field);\n        descriptor = field->message_type();\n      }\n    }\n  }\n\n  // We've found the leaf field. Now we use UnknownFieldSets to set its value\n  // on the options message. We do so because the message may not yet know\n  // about its extension fields, so we may not be able to set the fields\n  // directly. But the UnknownFieldSets will serialize to the same wire-format\n  // message, so reading that message back in once the extension fields are\n  // known will populate them correctly.\n\n  // First see if the option is already set.\n  if (!field->is_repeated() && !ExamineIfOptionIsSet(\n          intermediate_fields.begin(),\n          intermediate_fields.end(),\n          field, debug_msg_name,\n          options->GetReflection()->GetUnknownFields(*options))) {\n    return false;  // ExamineIfOptionIsSet() already added the error.\n  }\n\n\n  // First set the value on the UnknownFieldSet corresponding to the\n  // innermost message.\n  google::protobuf::scoped_ptr<UnknownFieldSet> unknown_fields(new UnknownFieldSet());\n  if (!SetOptionValue(field, unknown_fields.get())) {\n    return false;  // SetOptionValue() already added the error.\n  }\n\n  // Now wrap the UnknownFieldSet with UnknownFieldSets corresponding to all\n  // the intermediate messages.\n  for (vector<const FieldDescriptor*>::reverse_iterator iter =\n           intermediate_fields.rbegin();\n       iter != intermediate_fields.rend(); ++iter) {\n    google::protobuf::scoped_ptr<UnknownFieldSet> parent_unknown_fields(\n        new UnknownFieldSet());\n    switch ((*iter)->type()) {\n      case FieldDescriptor::TYPE_MESSAGE: {\n        io::StringOutputStream outstr(\n            parent_unknown_fields->AddLengthDelimited((*iter)->number()));\n        io::CodedOutputStream out(&outstr);\n        internal::WireFormat::SerializeUnknownFields(*unknown_fields, &out);\n        GOOGLE_CHECK(!out.HadError())\n            << \"Unexpected failure while serializing option submessage \"\n            << debug_msg_name << \"\\\".\";\n        break;\n      }\n\n      case FieldDescriptor::TYPE_GROUP: {\n         parent_unknown_fields->AddGroup((*iter)->number())\n                              ->MergeFrom(*unknown_fields);\n        break;\n      }\n\n      default:\n        GOOGLE_LOG(FATAL) << \"Invalid wire type for CPPTYPE_MESSAGE: \"\n                   << (*iter)->type();\n        return false;\n    }\n    unknown_fields.reset(parent_unknown_fields.release());\n  }\n\n  // Now merge the UnknownFieldSet corresponding to the top-level message into\n  // the options message.\n  options->GetReflection()->MutableUnknownFields(options)->MergeFrom(\n      *unknown_fields);\n\n  return true;\n}\n\nvoid DescriptorBuilder::OptionInterpreter::AddWithoutInterpreting(\n    const UninterpretedOption& uninterpreted_option, Message* options) {\n  const FieldDescriptor* field =\n    options->GetDescriptor()->FindFieldByName(\"uninterpreted_option\");\n  GOOGLE_CHECK(field != NULL);\n\n  options->GetReflection()->AddMessage(options, field)\n    ->CopyFrom(uninterpreted_option);\n}\n\nbool DescriptorBuilder::OptionInterpreter::ExamineIfOptionIsSet(\n    vector<const FieldDescriptor*>::const_iterator intermediate_fields_iter,\n    vector<const FieldDescriptor*>::const_iterator intermediate_fields_end,\n    const FieldDescriptor* innermost_field, const string& debug_msg_name,\n    const UnknownFieldSet& unknown_fields) {\n  // We do linear searches of the UnknownFieldSet and its sub-groups.  This\n  // should be fine since it's unlikely that any one options structure will\n  // contain more than a handful of options.\n\n  if (intermediate_fields_iter == intermediate_fields_end) {\n    // We're at the innermost submessage.\n    for (int i = 0; i < unknown_fields.field_count(); i++) {\n      if (unknown_fields.field(i).number() == innermost_field->number()) {\n        return AddNameError(\"Option \\\"\" + debug_msg_name +\n                            \"\\\" was already set.\");\n      }\n    }\n    return true;\n  }\n\n  for (int i = 0; i < unknown_fields.field_count(); i++) {\n    if (unknown_fields.field(i).number() ==\n        (*intermediate_fields_iter)->number()) {\n      const UnknownField* unknown_field = &unknown_fields.field(i);\n      FieldDescriptor::Type type = (*intermediate_fields_iter)->type();\n      // Recurse into the next submessage.\n      switch (type) {\n        case FieldDescriptor::TYPE_MESSAGE:\n          if (unknown_field->type() == UnknownField::TYPE_LENGTH_DELIMITED) {\n            UnknownFieldSet intermediate_unknown_fields;\n            if (intermediate_unknown_fields.ParseFromString(\n                    unknown_field->length_delimited()) &&\n                !ExamineIfOptionIsSet(intermediate_fields_iter + 1,\n                                      intermediate_fields_end,\n                                      innermost_field, debug_msg_name,\n                                      intermediate_unknown_fields)) {\n              return false;  // Error already added.\n            }\n          }\n          break;\n\n        case FieldDescriptor::TYPE_GROUP:\n          if (unknown_field->type() == UnknownField::TYPE_GROUP) {\n            if (!ExamineIfOptionIsSet(intermediate_fields_iter + 1,\n                                      intermediate_fields_end,\n                                      innermost_field, debug_msg_name,\n                                      unknown_field->group())) {\n              return false;  // Error already added.\n            }\n          }\n          break;\n\n        default:\n          GOOGLE_LOG(FATAL) << \"Invalid wire type for CPPTYPE_MESSAGE: \" << type;\n          return false;\n      }\n    }\n  }\n  return true;\n}\n\nbool DescriptorBuilder::OptionInterpreter::SetOptionValue(\n    const FieldDescriptor* option_field,\n    UnknownFieldSet* unknown_fields) {\n  // We switch on the CppType to validate.\n  switch (option_field->cpp_type()) {\n\n    case FieldDescriptor::CPPTYPE_INT32:\n      if (uninterpreted_option_->has_positive_int_value()) {\n        if (uninterpreted_option_->positive_int_value() >\n            static_cast<uint64>(kint32max)) {\n          return AddValueError(\"Value out of range for int32 option \\\"\" +\n                               option_field->full_name() + \"\\\".\");\n        } else {\n          SetInt32(option_field->number(),\n                   uninterpreted_option_->positive_int_value(),\n                   option_field->type(), unknown_fields);\n        }\n      } else if (uninterpreted_option_->has_negative_int_value()) {\n        if (uninterpreted_option_->negative_int_value() <\n            static_cast<int64>(kint32min)) {\n          return AddValueError(\"Value out of range for int32 option \\\"\" +\n                               option_field->full_name() + \"\\\".\");\n        } else {\n          SetInt32(option_field->number(),\n                   uninterpreted_option_->negative_int_value(),\n                   option_field->type(), unknown_fields);\n        }\n      } else {\n        return AddValueError(\"Value must be integer for int32 option \\\"\" +\n                             option_field->full_name() + \"\\\".\");\n      }\n      break;\n\n    case FieldDescriptor::CPPTYPE_INT64:\n      if (uninterpreted_option_->has_positive_int_value()) {\n        if (uninterpreted_option_->positive_int_value() >\n            static_cast<uint64>(kint64max)) {\n          return AddValueError(\"Value out of range for int64 option \\\"\" +\n                               option_field->full_name() + \"\\\".\");\n        } else {\n          SetInt64(option_field->number(),\n                   uninterpreted_option_->positive_int_value(),\n                   option_field->type(), unknown_fields);\n        }\n      } else if (uninterpreted_option_->has_negative_int_value()) {\n        SetInt64(option_field->number(),\n                 uninterpreted_option_->negative_int_value(),\n                 option_field->type(), unknown_fields);\n      } else {\n        return AddValueError(\"Value must be integer for int64 option \\\"\" +\n                             option_field->full_name() + \"\\\".\");\n      }\n      break;\n\n    case FieldDescriptor::CPPTYPE_UINT32:\n      if (uninterpreted_option_->has_positive_int_value()) {\n        if (uninterpreted_option_->positive_int_value() > kuint32max) {\n          return AddValueError(\"Value out of range for uint32 option \\\"\" +\n                               option_field->name() + \"\\\".\");\n        } else {\n          SetUInt32(option_field->number(),\n                    uninterpreted_option_->positive_int_value(),\n                    option_field->type(), unknown_fields);\n        }\n      } else {\n        return AddValueError(\"Value must be non-negative integer for uint32 \"\n                             \"option \\\"\" + option_field->full_name() + \"\\\".\");\n      }\n      break;\n\n    case FieldDescriptor::CPPTYPE_UINT64:\n      if (uninterpreted_option_->has_positive_int_value()) {\n        SetUInt64(option_field->number(),\n                  uninterpreted_option_->positive_int_value(),\n                  option_field->type(), unknown_fields);\n      } else {\n        return AddValueError(\"Value must be non-negative integer for uint64 \"\n                             \"option \\\"\" + option_field->full_name() + \"\\\".\");\n      }\n      break;\n\n    case FieldDescriptor::CPPTYPE_FLOAT: {\n      float value;\n      if (uninterpreted_option_->has_double_value()) {\n        value = uninterpreted_option_->double_value();\n      } else if (uninterpreted_option_->has_positive_int_value()) {\n        value = uninterpreted_option_->positive_int_value();\n      } else if (uninterpreted_option_->has_negative_int_value()) {\n        value = uninterpreted_option_->negative_int_value();\n      } else {\n        return AddValueError(\"Value must be number for float option \\\"\" +\n                             option_field->full_name() + \"\\\".\");\n      }\n      unknown_fields->AddFixed32(option_field->number(),\n          google::protobuf::internal::WireFormatLite::EncodeFloat(value));\n      break;\n    }\n\n    case FieldDescriptor::CPPTYPE_DOUBLE: {\n      double value;\n      if (uninterpreted_option_->has_double_value()) {\n        value = uninterpreted_option_->double_value();\n      } else if (uninterpreted_option_->has_positive_int_value()) {\n        value = uninterpreted_option_->positive_int_value();\n      } else if (uninterpreted_option_->has_negative_int_value()) {\n        value = uninterpreted_option_->negative_int_value();\n      } else {\n        return AddValueError(\"Value must be number for double option \\\"\" +\n                             option_field->full_name() + \"\\\".\");\n      }\n      unknown_fields->AddFixed64(option_field->number(),\n          google::protobuf::internal::WireFormatLite::EncodeDouble(value));\n      break;\n    }\n\n    case FieldDescriptor::CPPTYPE_BOOL:\n      uint64 value;\n      if (!uninterpreted_option_->has_identifier_value()) {\n        return AddValueError(\"Value must be identifier for boolean option \"\n                             \"\\\"\" + option_field->full_name() + \"\\\".\");\n      }\n      if (uninterpreted_option_->identifier_value() == \"true\") {\n        value = 1;\n      } else if (uninterpreted_option_->identifier_value() == \"false\") {\n        value = 0;\n      } else {\n        return AddValueError(\"Value must be \\\"true\\\" or \\\"false\\\" for boolean \"\n                             \"option \\\"\" + option_field->full_name() + \"\\\".\");\n      }\n      unknown_fields->AddVarint(option_field->number(), value);\n      break;\n\n    case FieldDescriptor::CPPTYPE_ENUM: {\n      if (!uninterpreted_option_->has_identifier_value()) {\n        return AddValueError(\"Value must be identifier for enum-valued option \"\n                             \"\\\"\" + option_field->full_name() + \"\\\".\");\n      }\n      const EnumDescriptor* enum_type = option_field->enum_type();\n      const string& value_name = uninterpreted_option_->identifier_value();\n      const EnumValueDescriptor* enum_value = NULL;\n\n      if (enum_type->file()->pool() != DescriptorPool::generated_pool()) {\n        // Note that the enum value's fully-qualified name is a sibling of the\n        // enum's name, not a child of it.\n        string fully_qualified_name = enum_type->full_name();\n        fully_qualified_name.resize(fully_qualified_name.size() -\n                                    enum_type->name().size());\n        fully_qualified_name += value_name;\n\n        // Search for the enum value's descriptor in the builder's pool. Note\n        // that we use DescriptorBuilder::FindSymbolNotEnforcingDeps(), not\n        // DescriptorPool::FindEnumValueByName() because we're already holding\n        // the pool's mutex, and the latter method locks it again.\n        Symbol symbol =\n          builder_->FindSymbolNotEnforcingDeps(fully_qualified_name);\n        if (!symbol.IsNull() && symbol.type == Symbol::ENUM_VALUE) {\n          if (symbol.enum_value_descriptor->type() != enum_type) {\n            return AddValueError(\"Enum type \\\"\" + enum_type->full_name() +\n                \"\\\" has no value named \\\"\" + value_name + \"\\\" for option \\\"\" +\n                option_field->full_name() +\n                \"\\\". This appears to be a value from a sibling type.\");\n          } else {\n            enum_value = symbol.enum_value_descriptor;\n          }\n        }\n      } else {\n        // The enum type is in the generated pool, so we can search for the\n        // value there.\n        enum_value = enum_type->FindValueByName(value_name);\n      }\n\n      if (enum_value == NULL) {\n        return AddValueError(\"Enum type \\\"\" +\n                             option_field->enum_type()->full_name() +\n                             \"\\\" has no value named \\\"\" + value_name + \"\\\" for \"\n                             \"option \\\"\" + option_field->full_name() + \"\\\".\");\n      } else {\n        // Sign-extension is not a problem, since we cast directly from int32 to\n        // uint64, without first going through uint32.\n        unknown_fields->AddVarint(option_field->number(),\n          static_cast<uint64>(static_cast<int64>(enum_value->number())));\n      }\n      break;\n    }\n\n    case FieldDescriptor::CPPTYPE_STRING:\n      if (!uninterpreted_option_->has_string_value()) {\n        return AddValueError(\"Value must be quoted string for string option \"\n                             \"\\\"\" + option_field->full_name() + \"\\\".\");\n      }\n      // The string has already been unquoted and unescaped by the parser.\n      unknown_fields->AddLengthDelimited(option_field->number(),\n          uninterpreted_option_->string_value());\n      break;\n\n    case FieldDescriptor::CPPTYPE_MESSAGE:\n      if (!SetAggregateOption(option_field, unknown_fields)) {\n        return false;\n      }\n      break;\n  }\n\n  return true;\n}\n\nclass DescriptorBuilder::OptionInterpreter::AggregateOptionFinder\n    : public TextFormat::Finder {\n public:\n  DescriptorBuilder* builder_;\n\n  virtual const FieldDescriptor* FindExtension(\n      Message* message, const string& name) const {\n    assert_mutex_held(builder_->pool_);\n    const Descriptor* descriptor = message->GetDescriptor();\n    Symbol result = builder_->LookupSymbolNoPlaceholder(\n        name, descriptor->full_name());\n    if (result.type == Symbol::FIELD &&\n        result.field_descriptor->is_extension()) {\n      return result.field_descriptor;\n    } else if (result.type == Symbol::MESSAGE &&\n               descriptor->options().message_set_wire_format()) {\n      const Descriptor* foreign_type = result.descriptor;\n      // The text format allows MessageSet items to be specified using\n      // the type name, rather than the extension identifier. If the symbol\n      // lookup returned a Message, and the enclosing Message has\n      // message_set_wire_format = true, then return the message set\n      // extension, if one exists.\n      for (int i = 0; i < foreign_type->extension_count(); i++) {\n        const FieldDescriptor* extension = foreign_type->extension(i);\n        if (extension->containing_type() == descriptor &&\n            extension->type() == FieldDescriptor::TYPE_MESSAGE &&\n            extension->is_optional() &&\n            extension->message_type() == foreign_type) {\n          // Found it.\n          return extension;\n        }\n      }\n    }\n    return NULL;\n  }\n};\n\n// A custom error collector to record any text-format parsing errors\nnamespace {\nclass AggregateErrorCollector : public io::ErrorCollector {\n public:\n  string error_;\n\n  virtual void AddError(int /* line */, int /* column */,\n                        const string& message) {\n    if (!error_.empty()) {\n      error_ += \"; \";\n    }\n    error_ += message;\n  }\n\n  virtual void AddWarning(int /* line */, int /* column */,\n                          const string& /* message */) {\n    // Ignore warnings\n  }\n};\n}\n\n// We construct a dynamic message of the type corresponding to\n// option_field, parse the supplied text-format string into this\n// message, and serialize the resulting message to produce the value.\nbool DescriptorBuilder::OptionInterpreter::SetAggregateOption(\n    const FieldDescriptor* option_field,\n    UnknownFieldSet* unknown_fields) {\n  if (!uninterpreted_option_->has_aggregate_value()) {\n    return AddValueError(\"Option \\\"\" + option_field->full_name() +\n                         \"\\\" is a message. To set the entire message, use \"\n                         \"syntax like \\\"\" + option_field->name() +\n                         \" = { <proto text format> }\\\". \"\n                         \"To set fields within it, use \"\n                         \"syntax like \\\"\" + option_field->name() +\n                         \".foo = value\\\".\");\n  }\n\n  const Descriptor* type = option_field->message_type();\n  google::protobuf::scoped_ptr<Message> dynamic(dynamic_factory_.GetPrototype(type)->New());\n  GOOGLE_CHECK(dynamic.get() != NULL)\n      << \"Could not create an instance of \" << option_field->DebugString();\n\n  AggregateErrorCollector collector;\n  AggregateOptionFinder finder;\n  finder.builder_ = builder_;\n  TextFormat::Parser parser;\n  parser.RecordErrorsTo(&collector);\n  parser.SetFinder(&finder);\n  if (!parser.ParseFromString(uninterpreted_option_->aggregate_value(),\n                              dynamic.get())) {\n    AddValueError(\"Error while parsing option value for \\\"\" +\n                  option_field->name() + \"\\\": \" + collector.error_);\n    return false;\n  } else {\n    string serial;\n    dynamic->SerializeToString(&serial);  // Never fails\n    if (option_field->type() == FieldDescriptor::TYPE_MESSAGE) {\n      unknown_fields->AddLengthDelimited(option_field->number(), serial);\n    } else {\n      GOOGLE_CHECK_EQ(option_field->type(),  FieldDescriptor::TYPE_GROUP);\n      UnknownFieldSet* group = unknown_fields->AddGroup(option_field->number());\n      group->ParseFromString(serial);\n    }\n    return true;\n  }\n}\n\nvoid DescriptorBuilder::OptionInterpreter::SetInt32(int number, int32 value,\n    FieldDescriptor::Type type, UnknownFieldSet* unknown_fields) {\n  switch (type) {\n    case FieldDescriptor::TYPE_INT32:\n      unknown_fields->AddVarint(number,\n        static_cast<uint64>(static_cast<int64>(value)));\n      break;\n\n    case FieldDescriptor::TYPE_SFIXED32:\n      unknown_fields->AddFixed32(number, static_cast<uint32>(value));\n      break;\n\n    case FieldDescriptor::TYPE_SINT32:\n      unknown_fields->AddVarint(number,\n          google::protobuf::internal::WireFormatLite::ZigZagEncode32(value));\n      break;\n\n    default:\n      GOOGLE_LOG(FATAL) << \"Invalid wire type for CPPTYPE_INT32: \" << type;\n      break;\n  }\n}\n\nvoid DescriptorBuilder::OptionInterpreter::SetInt64(int number, int64 value,\n    FieldDescriptor::Type type, UnknownFieldSet* unknown_fields) {\n  switch (type) {\n    case FieldDescriptor::TYPE_INT64:\n      unknown_fields->AddVarint(number, static_cast<uint64>(value));\n      break;\n\n    case FieldDescriptor::TYPE_SFIXED64:\n      unknown_fields->AddFixed64(number, static_cast<uint64>(value));\n      break;\n\n    case FieldDescriptor::TYPE_SINT64:\n      unknown_fields->AddVarint(number,\n          google::protobuf::internal::WireFormatLite::ZigZagEncode64(value));\n      break;\n\n    default:\n      GOOGLE_LOG(FATAL) << \"Invalid wire type for CPPTYPE_INT64: \" << type;\n      break;\n  }\n}\n\nvoid DescriptorBuilder::OptionInterpreter::SetUInt32(int number, uint32 value,\n    FieldDescriptor::Type type, UnknownFieldSet* unknown_fields) {\n  switch (type) {\n    case FieldDescriptor::TYPE_UINT32:\n      unknown_fields->AddVarint(number, static_cast<uint64>(value));\n      break;\n\n    case FieldDescriptor::TYPE_FIXED32:\n      unknown_fields->AddFixed32(number, static_cast<uint32>(value));\n      break;\n\n    default:\n      GOOGLE_LOG(FATAL) << \"Invalid wire type for CPPTYPE_UINT32: \" << type;\n      break;\n  }\n}\n\nvoid DescriptorBuilder::OptionInterpreter::SetUInt64(int number, uint64 value,\n    FieldDescriptor::Type type, UnknownFieldSet* unknown_fields) {\n  switch (type) {\n    case FieldDescriptor::TYPE_UINT64:\n      unknown_fields->AddVarint(number, value);\n      break;\n\n    case FieldDescriptor::TYPE_FIXED64:\n      unknown_fields->AddFixed64(number, value);\n      break;\n\n    default:\n      GOOGLE_LOG(FATAL) << \"Invalid wire type for CPPTYPE_UINT64: \" << type;\n      break;\n  }\n}\n\nvoid DescriptorBuilder::LogUnusedDependency(const FileDescriptorProto& proto,\n                                            const FileDescriptor* result) {\n\n  if (!unused_dependency_.empty()) {\n    std::set<string> annotation_extensions;\n    annotation_extensions.insert(\"google.protobuf.MessageOptions\");\n    annotation_extensions.insert(\"google.protobuf.FileOptions\");\n    annotation_extensions.insert(\"google.protobuf.FieldOptions\");\n    annotation_extensions.insert(\"google.protobuf.EnumOptions\");\n    annotation_extensions.insert(\"google.protobuf.EnumValueOptions\");\n    annotation_extensions.insert(\"google.protobuf.ServiceOptions\");\n    annotation_extensions.insert(\"google.protobuf.MethodOptions\");\n    annotation_extensions.insert(\"google.protobuf.StreamOptions\");\n    for (set<const FileDescriptor*>::const_iterator\n             it = unused_dependency_.begin();\n         it != unused_dependency_.end(); ++it) {\n      // Do not log warnings for proto files which extend annotations.\n      int i;\n      for (i = 0 ; i < (*it)->extension_count(); ++i) {\n        if (annotation_extensions.find(\n                (*it)->extension(i)->containing_type()->full_name())\n            != annotation_extensions.end()) {\n          break;\n        }\n      }\n      // Log warnings for unused imported files.\n      if (i == (*it)->extension_count()) {\n        string error_message = \"Import \" + (*it)->name() + \" but not used.\";\n        AddWarning((*it)->name(), proto, DescriptorPool::ErrorCollector::OTHER,\n                   error_message);\n      }\n    }\n  }\n}\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/descriptor.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This file contains classes which describe a type of protocol message.\n// You can use a message's descriptor to learn at runtime what fields\n// it contains and what the types of those fields are.  The Message\n// interface also allows you to dynamically access and modify individual\n// fields by passing the FieldDescriptor of the field you are interested\n// in.\n//\n// Most users will not care about descriptors, because they will write\n// code specific to certain protocol types and will simply use the classes\n// generated by the protocol compiler directly.  Advanced users who want\n// to operate on arbitrary types (not known at compile time) may want to\n// read descriptors in order to learn about the contents of a message.\n// A very small number of users will want to construct their own\n// Descriptors, either because they are implementing Message manually or\n// because they are writing something like the protocol compiler.\n//\n// For an example of how you might use descriptors, see the code example\n// at the top of message.h.\n\n#ifndef GOOGLE_PROTOBUF_DESCRIPTOR_H__\n#define GOOGLE_PROTOBUF_DESCRIPTOR_H__\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <set>\n#include <string>\n#include <vector>\n#include <google/protobuf/stubs/common.h>\n\n// TYPE_BOOL is defined in the MacOS's ConditionalMacros.h.\n#ifdef TYPE_BOOL\n#undef TYPE_BOOL\n#endif  // TYPE_BOOL\n\nnamespace google {\nnamespace protobuf {\n\n// Defined in this file.\nclass Descriptor;\nclass FieldDescriptor;\nclass OneofDescriptor;\nclass EnumDescriptor;\nclass EnumValueDescriptor;\nclass ServiceDescriptor;\nclass MethodDescriptor;\nclass FileDescriptor;\nclass DescriptorDatabase;\nclass DescriptorPool;\n\n// Defined in descriptor.proto\nclass DescriptorProto;\nclass FieldDescriptorProto;\nclass OneofDescriptorProto;\nclass EnumDescriptorProto;\nclass EnumValueDescriptorProto;\nclass ServiceDescriptorProto;\nclass MethodDescriptorProto;\nclass FileDescriptorProto;\nclass MessageOptions;\nclass FieldOptions;\nclass OneofOptions;\nclass EnumOptions;\nclass EnumValueOptions;\nclass ServiceOptions;\nclass MethodOptions;\nclass FileOptions;\nclass UninterpretedOption;\nclass SourceCodeInfo;\n\n// Defined in message.h\nclass Message;\n\n// Defined in descriptor.cc\nclass DescriptorBuilder;\nclass FileDescriptorTables;\n\n// Defined in unknown_field_set.h.\nclass UnknownField;\n\n// Defined in generated_message_reflection.h.\nnamespace internal {\nclass GeneratedMessageReflection;\n}  // namespace internal\n\n// Defined in command_line_interface.cc\nnamespace compiler {\nclass CommandLineInterface;\n}  // namespace compiler\n\nnamespace descriptor_unittest {\nclass DescriptorTest;\n}  // namespace descriptor_unittest\n\n// Defined in printer.h\nnamespace io {\nclass Printer;\n}  // namespace io\n\n// NB, all indices are zero-based.\nstruct SourceLocation {\n  int start_line;\n  int end_line;\n  int start_column;\n  int end_column;\n\n  // Doc comments found at the source location.\n  // See the comments in SourceCodeInfo.Location (descriptor.proto) for details.\n  string leading_comments;\n  string trailing_comments;\n  vector<string> leading_detached_comments;\n};\n\n// Options when generating machine-parsable output from a descriptor with\n// DebugString().\nstruct DebugStringOptions {\n  // include original user comments as recorded in SourceLocation entries. N.B.\n  // that this must be |false| by default: several other pieces of code (for\n  // example, the C++ code generation for fields in the proto compiler) rely on\n  // DebugString() output being unobstructed by user comments.\n  bool include_comments;\n  // If true, elide the braced body in the debug string.\n  bool elide_group_body;\n  bool elide_oneof_body;\n\n  DebugStringOptions()\n      : include_comments(false),\n        elide_group_body(false),\n        elide_oneof_body(false) {}\n};\n\n// Describes a type of protocol message, or a particular group within a\n// message.  To obtain the Descriptor for a given message object, call\n// Message::GetDescriptor().  Generated message classes also have a\n// static method called descriptor() which returns the type's descriptor.\n// Use DescriptorPool to construct your own descriptors.\nclass LIBPROTOBUF_EXPORT Descriptor {\n public:\n  // The name of the message type, not including its scope.\n  const string& name() const;\n\n  // The fully-qualified name of the message type, scope delimited by\n  // periods.  For example, message type \"Foo\" which is declared in package\n  // \"bar\" has full name \"bar.Foo\".  If a type \"Baz\" is nested within\n  // Foo, Baz's full_name is \"bar.Foo.Baz\".  To get only the part that\n  // comes after the last '.', use name().\n  const string& full_name() const;\n\n  // Index of this descriptor within the file or containing type's message\n  // type array.\n  int index() const;\n\n  // The .proto file in which this message type was defined.  Never NULL.\n  const FileDescriptor* file() const;\n\n  // If this Descriptor describes a nested type, this returns the type\n  // in which it is nested.  Otherwise, returns NULL.\n  const Descriptor* containing_type() const;\n\n  // Get options for this message type.  These are specified in the .proto file\n  // by placing lines like \"option foo = 1234;\" in the message definition.\n  // Allowed options are defined by MessageOptions in\n  // google/protobuf/descriptor.proto, and any available extensions of that\n  // message.\n  const MessageOptions& options() const;\n\n  // Write the contents of this Descriptor into the given DescriptorProto.\n  // The target DescriptorProto must be clear before calling this; if it\n  // isn't, the result may be garbage.\n  void CopyTo(DescriptorProto* proto) const;\n\n  // Write the contents of this decriptor in a human-readable form. Output\n  // will be suitable for re-parsing.\n  string DebugString() const;\n\n  // Similar to DebugString(), but additionally takes options (e.g.,\n  // include original user comments in output).\n  string DebugStringWithOptions(const DebugStringOptions& options) const;\n\n  // Returns true if this is a placeholder for an unknown type. This will\n  // only be the case if this descriptor comes from a DescriptorPool\n  // with AllowUnknownDependencies() set.\n  bool is_placeholder() const;\n\n  // Field stuff -----------------------------------------------------\n\n  // The number of fields in this message type.\n  int field_count() const;\n  // Gets a field by index, where 0 <= index < field_count().\n  // These are returned in the order they were defined in the .proto file.\n  const FieldDescriptor* field(int index) const;\n\n  // Looks up a field by declared tag number.  Returns NULL if no such field\n  // exists.\n  const FieldDescriptor* FindFieldByNumber(int number) const;\n  // Looks up a field by name.  Returns NULL if no such field exists.\n  const FieldDescriptor* FindFieldByName(const string& name) const;\n\n  // Looks up a field by lowercased name (as returned by lowercase_name()).\n  // This lookup may be ambiguous if multiple field names differ only by case,\n  // in which case the field returned is chosen arbitrarily from the matches.\n  const FieldDescriptor* FindFieldByLowercaseName(\n      const string& lowercase_name) const;\n\n  // Looks up a field by camel-case name (as returned by camelcase_name()).\n  // This lookup may be ambiguous if multiple field names differ in a way that\n  // leads them to have identical camel-case names, in which case the field\n  // returned is chosen arbitrarily from the matches.\n  const FieldDescriptor* FindFieldByCamelcaseName(\n      const string& camelcase_name) const;\n\n  // The number of oneofs in this message type.\n  int oneof_decl_count() const;\n  // Get a oneof by index, where 0 <= index < oneof_decl_count().\n  // These are returned in the order they were defined in the .proto file.\n  const OneofDescriptor* oneof_decl(int index) const;\n\n  // Looks up a oneof by name.  Returns NULL if no such oneof exists.\n  const OneofDescriptor* FindOneofByName(const string& name) const;\n\n  // Nested type stuff -----------------------------------------------\n\n  // The number of nested types in this message type.\n  int nested_type_count() const;\n  // Gets a nested type by index, where 0 <= index < nested_type_count().\n  // These are returned in the order they were defined in the .proto file.\n  const Descriptor* nested_type(int index) const;\n\n  // Looks up a nested type by name.  Returns NULL if no such nested type\n  // exists.\n  const Descriptor* FindNestedTypeByName(const string& name) const;\n\n  // Enum stuff ------------------------------------------------------\n\n  // The number of enum types in this message type.\n  int enum_type_count() const;\n  // Gets an enum type by index, where 0 <= index < enum_type_count().\n  // These are returned in the order they were defined in the .proto file.\n  const EnumDescriptor* enum_type(int index) const;\n\n  // Looks up an enum type by name.  Returns NULL if no such enum type exists.\n  const EnumDescriptor* FindEnumTypeByName(const string& name) const;\n\n  // Looks up an enum value by name, among all enum types in this message.\n  // Returns NULL if no such value exists.\n  const EnumValueDescriptor* FindEnumValueByName(const string& name) const;\n\n  // Extensions ------------------------------------------------------\n\n  // A range of field numbers which are designated for third-party\n  // extensions.\n  struct ExtensionRange {\n    int start;  // inclusive\n    int end;    // exclusive\n  };\n\n  // The number of extension ranges in this message type.\n  int extension_range_count() const;\n  // Gets an extension range by index, where 0 <= index <\n  // extension_range_count(). These are returned in the order they were defined\n  // in the .proto file.\n  const ExtensionRange* extension_range(int index) const;\n\n  // Returns true if the number is in one of the extension ranges.\n  bool IsExtensionNumber(int number) const;\n\n  // Returns NULL if no extension range contains the given number.\n  const ExtensionRange* FindExtensionRangeContainingNumber(int number) const;\n\n  // The number of extensions -- extending *other* messages -- that were\n  // defined nested within this message type's scope.\n  int extension_count() const;\n  // Get an extension by index, where 0 <= index < extension_count().\n  // These are returned in the order they were defined in the .proto file.\n  const FieldDescriptor* extension(int index) const;\n\n  // Looks up a named extension (which extends some *other* message type)\n  // defined within this message type's scope.\n  const FieldDescriptor* FindExtensionByName(const string& name) const;\n\n  // Similar to FindFieldByLowercaseName(), but finds extensions defined within\n  // this message type's scope.\n  const FieldDescriptor* FindExtensionByLowercaseName(const string& name) const;\n\n  // Similar to FindFieldByCamelcaseName(), but finds extensions defined within\n  // this message type's scope.\n  const FieldDescriptor* FindExtensionByCamelcaseName(const string& name) const;\n\n  // Reserved fields -------------------------------------------------\n\n  // A range of reserved field numbers.\n  struct ReservedRange {\n    int start;  // inclusive\n    int end;    // exclusive\n  };\n\n  // The number of reserved ranges in this message type.\n  int reserved_range_count() const;\n  // Gets an reserved range by index, where 0 <= index <\n  // reserved_range_count(). These are returned in the order they were defined\n  // in the .proto file.\n  const ReservedRange* reserved_range(int index) const;\n\n  // Returns true if the number is in one of the reserved ranges.\n  bool IsReservedNumber(int number) const;\n\n  // Returns NULL if no reserved range contains the given number.\n  const ReservedRange* FindReservedRangeContainingNumber(int number) const;\n\n  // The number of reserved field names in this message type.\n  int reserved_name_count() const;\n\n  // Gets a reserved name by index, where 0 <= index < reserved_name_count().\n  const string& reserved_name(int index) const;\n\n  // Returns true if the field name is reserved.\n  bool IsReservedName(const string& name) const;\n\n  // Source Location ---------------------------------------------------\n\n  // Updates |*out_location| to the source location of the complete\n  // extent of this message declaration.  Returns false and leaves\n  // |*out_location| unchanged iff location information was not available.\n  bool GetSourceLocation(SourceLocation* out_location) const;\n\n private:\n  typedef MessageOptions OptionsType;\n\n  // Allows tests to test CopyTo(proto, true).\n  friend class ::google::protobuf::descriptor_unittest::DescriptorTest;\n\n  // Allows access to GetLocationPath for annotations.\n  friend class ::google::protobuf::io::Printer;\n\n  // Fill the json_name field of FieldDescriptorProto.\n  void CopyJsonNameTo(DescriptorProto* proto) const;\n\n  // Internal version of DebugString; controls the level of indenting for\n  // correct depth. Takes |options| to control debug-string options, and\n  // |include_opening_clause| to indicate whether the \"message ... \" part of the\n  // clause has already been generated (this varies depending on context).\n  void DebugString(int depth, string *contents,\n                   const DebugStringOptions& options,\n                   bool include_opening_clause) const;\n\n  // Walks up the descriptor tree to generate the source location path\n  // to this descriptor from the file root.\n  void GetLocationPath(std::vector<int>* output) const;\n\n  const string* name_;\n  const string* full_name_;\n  const FileDescriptor* file_;\n  const Descriptor* containing_type_;\n  const MessageOptions* options_;\n\n  // True if this is a placeholder for an unknown type.\n  bool is_placeholder_;\n  // True if this is a placeholder and the type name wasn't fully-qualified.\n  bool is_unqualified_placeholder_;\n\n  int field_count_;\n  FieldDescriptor* fields_;\n  int oneof_decl_count_;\n  OneofDescriptor* oneof_decls_;\n  int nested_type_count_;\n  Descriptor* nested_types_;\n  int enum_type_count_;\n  EnumDescriptor* enum_types_;\n  int extension_range_count_;\n  ExtensionRange* extension_ranges_;\n  int extension_count_;\n  FieldDescriptor* extensions_;\n  int reserved_range_count_;\n  ReservedRange* reserved_ranges_;\n  int reserved_name_count_;\n  const string** reserved_names_;\n  // IMPORTANT:  If you add a new field, make sure to search for all instances\n  // of Allocate<Descriptor>() and AllocateArray<Descriptor>() in descriptor.cc\n  // and update them to initialize the field.\n\n  // Must be constructed using DescriptorPool.\n  Descriptor() {}\n  friend class DescriptorBuilder;\n  friend class EnumDescriptor;\n  friend class FieldDescriptor;\n  friend class OneofDescriptor;\n  friend class MethodDescriptor;\n  friend class FileDescriptor;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Descriptor);\n};\n\n// Describes a single field of a message.  To get the descriptor for a given\n// field, first get the Descriptor for the message in which it is defined,\n// then call Descriptor::FindFieldByName().  To get a FieldDescriptor for\n// an extension, do one of the following:\n// - Get the Descriptor or FileDescriptor for its containing scope, then\n//   call Descriptor::FindExtensionByName() or\n//   FileDescriptor::FindExtensionByName().\n// - Given a DescriptorPool, call DescriptorPool::FindExtensionByNumber().\n// - Given a Reflection for a message object, call\n//   Reflection::FindKnownExtensionByName() or\n//   Reflection::FindKnownExtensionByNumber().\n// Use DescriptorPool to construct your own descriptors.\nclass LIBPROTOBUF_EXPORT FieldDescriptor {\n public:\n  // Identifies a field type.  0 is reserved for errors.  The order is weird\n  // for historical reasons.  Types 12 and up are new in proto2.\n  enum Type {\n    TYPE_DOUBLE         = 1,   // double, exactly eight bytes on the wire.\n    TYPE_FLOAT          = 2,   // float, exactly four bytes on the wire.\n    TYPE_INT64          = 3,   // int64, varint on the wire.  Negative numbers\n                               // take 10 bytes.  Use TYPE_SINT64 if negative\n                               // values are likely.\n    TYPE_UINT64         = 4,   // uint64, varint on the wire.\n    TYPE_INT32          = 5,   // int32, varint on the wire.  Negative numbers\n                               // take 10 bytes.  Use TYPE_SINT32 if negative\n                               // values are likely.\n    TYPE_FIXED64        = 6,   // uint64, exactly eight bytes on the wire.\n    TYPE_FIXED32        = 7,   // uint32, exactly four bytes on the wire.\n    TYPE_BOOL           = 8,   // bool, varint on the wire.\n    TYPE_STRING         = 9,   // UTF-8 text.\n    TYPE_GROUP          = 10,  // Tag-delimited message.  Deprecated.\n    TYPE_MESSAGE        = 11,  // Length-delimited message.\n\n    TYPE_BYTES          = 12,  // Arbitrary byte array.\n    TYPE_UINT32         = 13,  // uint32, varint on the wire\n    TYPE_ENUM           = 14,  // Enum, varint on the wire\n    TYPE_SFIXED32       = 15,  // int32, exactly four bytes on the wire\n    TYPE_SFIXED64       = 16,  // int64, exactly eight bytes on the wire\n    TYPE_SINT32         = 17,  // int32, ZigZag-encoded varint on the wire\n    TYPE_SINT64         = 18,  // int64, ZigZag-encoded varint on the wire\n\n    MAX_TYPE            = 18,  // Constant useful for defining lookup tables\n                               // indexed by Type.\n  };\n\n  // Specifies the C++ data type used to represent the field.  There is a\n  // fixed mapping from Type to CppType where each Type maps to exactly one\n  // CppType.  0 is reserved for errors.\n  enum CppType {\n    CPPTYPE_INT32       = 1,     // TYPE_INT32, TYPE_SINT32, TYPE_SFIXED32\n    CPPTYPE_INT64       = 2,     // TYPE_INT64, TYPE_SINT64, TYPE_SFIXED64\n    CPPTYPE_UINT32      = 3,     // TYPE_UINT32, TYPE_FIXED32\n    CPPTYPE_UINT64      = 4,     // TYPE_UINT64, TYPE_FIXED64\n    CPPTYPE_DOUBLE      = 5,     // TYPE_DOUBLE\n    CPPTYPE_FLOAT       = 6,     // TYPE_FLOAT\n    CPPTYPE_BOOL        = 7,     // TYPE_BOOL\n    CPPTYPE_ENUM        = 8,     // TYPE_ENUM\n    CPPTYPE_STRING      = 9,     // TYPE_STRING, TYPE_BYTES\n    CPPTYPE_MESSAGE     = 10,    // TYPE_MESSAGE, TYPE_GROUP\n\n    MAX_CPPTYPE         = 10,    // Constant useful for defining lookup tables\n                                 // indexed by CppType.\n  };\n\n  // Identifies whether the field is optional, required, or repeated.  0 is\n  // reserved for errors.\n  enum Label {\n    LABEL_OPTIONAL      = 1,    // optional\n    LABEL_REQUIRED      = 2,    // required\n    LABEL_REPEATED      = 3,    // repeated\n\n    MAX_LABEL           = 3,    // Constant useful for defining lookup tables\n                                // indexed by Label.\n  };\n\n  // Valid field numbers are positive integers up to kMaxNumber.\n  static const int kMaxNumber = (1 << 29) - 1;\n\n  // First field number reserved for the protocol buffer library implementation.\n  // Users may not declare fields that use reserved numbers.\n  static const int kFirstReservedNumber = 19000;\n  // Last field number reserved for the protocol buffer library implementation.\n  // Users may not declare fields that use reserved numbers.\n  static const int kLastReservedNumber  = 19999;\n\n  const string& name() const;        // Name of this field within the message.\n  const string& full_name() const;   // Fully-qualified name of the field.\n  const string& json_name() const;   // JSON name of this field.\n  const FileDescriptor* file() const;// File in which this field was defined.\n  bool is_extension() const;         // Is this an extension field?\n  int number() const;                // Declared tag number.\n\n  // Same as name() except converted to lower-case.  This (and especially the\n  // FindFieldByLowercaseName() method) can be useful when parsing formats\n  // which prefer to use lowercase naming style.  (Although, technically\n  // field names should be lowercased anyway according to the protobuf style\n  // guide, so this only makes a difference when dealing with old .proto files\n  // which do not follow the guide.)\n  const string& lowercase_name() const;\n\n  // Same as name() except converted to camel-case.  In this conversion, any\n  // time an underscore appears in the name, it is removed and the next\n  // letter is capitalized.  Furthermore, the first letter of the name is\n  // lower-cased.  Examples:\n  //   FooBar -> fooBar\n  //   foo_bar -> fooBar\n  //   fooBar -> fooBar\n  // This (and especially the FindFieldByCamelcaseName() method) can be useful\n  // when parsing formats which prefer to use camel-case naming style.\n  const string& camelcase_name() const;\n\n  Type type() const;                  // Declared type of this field.\n  const char* type_name() const;      // Name of the declared type.\n  CppType cpp_type() const;           // C++ type of this field.\n  const char* cpp_type_name() const;  // Name of the C++ type.\n  Label label() const;                // optional/required/repeated\n\n  bool is_required() const;      // shorthand for label() == LABEL_REQUIRED\n  bool is_optional() const;      // shorthand for label() == LABEL_OPTIONAL\n  bool is_repeated() const;      // shorthand for label() == LABEL_REPEATED\n  bool is_packable() const;      // shorthand for is_repeated() &&\n                                 //               IsTypePackable(type())\n  bool is_packed() const;        // shorthand for is_packable() &&\n                                 //               options().packed()\n  bool is_map() const;           // shorthand for type() == TYPE_MESSAGE &&\n                                 // message_type()->options().map_entry()\n\n  // Index of this field within the message's field array, or the file or\n  // extension scope's extensions array.\n  int index() const;\n\n  // Does this field have an explicitly-declared default value?\n  bool has_default_value() const;\n\n  // Get the field default value if cpp_type() == CPPTYPE_INT32.  If no\n  // explicit default was defined, the default is 0.\n  int32 default_value_int32() const;\n  // Get the field default value if cpp_type() == CPPTYPE_INT64.  If no\n  // explicit default was defined, the default is 0.\n  int64 default_value_int64() const;\n  // Get the field default value if cpp_type() == CPPTYPE_UINT32.  If no\n  // explicit default was defined, the default is 0.\n  uint32 default_value_uint32() const;\n  // Get the field default value if cpp_type() == CPPTYPE_UINT64.  If no\n  // explicit default was defined, the default is 0.\n  uint64 default_value_uint64() const;\n  // Get the field default value if cpp_type() == CPPTYPE_FLOAT.  If no\n  // explicit default was defined, the default is 0.0.\n  float default_value_float() const;\n  // Get the field default value if cpp_type() == CPPTYPE_DOUBLE.  If no\n  // explicit default was defined, the default is 0.0.\n  double default_value_double() const;\n  // Get the field default value if cpp_type() == CPPTYPE_BOOL.  If no\n  // explicit default was defined, the default is false.\n  bool default_value_bool() const;\n  // Get the field default value if cpp_type() == CPPTYPE_ENUM.  If no\n  // explicit default was defined, the default is the first value defined\n  // in the enum type (all enum types are required to have at least one value).\n  // This never returns NULL.\n  const EnumValueDescriptor* default_value_enum() const;\n  // Get the field default value if cpp_type() == CPPTYPE_STRING.  If no\n  // explicit default was defined, the default is the empty string.\n  const string& default_value_string() const;\n\n  // The Descriptor for the message of which this is a field.  For extensions,\n  // this is the extended type.  Never NULL.\n  const Descriptor* containing_type() const;\n\n  // If the field is a member of a oneof, this is the one, otherwise this is\n  // NULL.\n  const OneofDescriptor* containing_oneof() const;\n\n  // If the field is a member of a oneof, returns the index in that oneof.\n  int index_in_oneof() const;\n\n  // An extension may be declared within the scope of another message.  If this\n  // field is an extension (is_extension() is true), then extension_scope()\n  // returns that message, or NULL if the extension was declared at global\n  // scope.  If this is not an extension, extension_scope() is undefined (may\n  // assert-fail).\n  const Descriptor* extension_scope() const;\n\n  // If type is TYPE_MESSAGE or TYPE_GROUP, returns a descriptor for the\n  // message or the group type.  Otherwise, returns null.\n  const Descriptor* message_type() const;\n  // If type is TYPE_ENUM, returns a descriptor for the enum.  Otherwise,\n  // returns null.\n  const EnumDescriptor* enum_type() const;\n\n  // Get the FieldOptions for this field.  This includes things listed in\n  // square brackets after the field definition.  E.g., the field:\n  //   optional string text = 1 [ctype=CORD];\n  // has the \"ctype\" option set.  Allowed options are defined by FieldOptions\n  // in google/protobuf/descriptor.proto, and any available extensions of that\n  // message.\n  const FieldOptions& options() const;\n\n  // See Descriptor::CopyTo().\n  void CopyTo(FieldDescriptorProto* proto) const;\n\n  // See Descriptor::DebugString().\n  string DebugString() const;\n\n  // See Descriptor::DebugStringWithOptions().\n  string DebugStringWithOptions(const DebugStringOptions& options) const;\n\n  // Helper method to get the CppType for a particular Type.\n  static CppType TypeToCppType(Type type);\n\n  // Helper method to get the name of a Type.\n  static const char* TypeName(Type type);\n\n  // Helper method to get the name of a CppType.\n  static const char* CppTypeName(CppType cpp_type);\n\n  // Return true iff [packed = true] is valid for fields of this type.\n  static inline bool IsTypePackable(Type field_type);\n\n  // Source Location ---------------------------------------------------\n\n  // Updates |*out_location| to the source location of the complete\n  // extent of this field declaration.  Returns false and leaves\n  // |*out_location| unchanged iff location information was not available.\n  bool GetSourceLocation(SourceLocation* out_location) const;\n\n private:\n  typedef FieldOptions OptionsType;\n\n  // Allows access to GetLocationPath for annotations.\n  friend class ::google::protobuf::io::Printer;\n\n  // Fill the json_name field of FieldDescriptorProto.\n  void CopyJsonNameTo(FieldDescriptorProto* proto) const;\n\n  // See Descriptor::DebugString().\n  enum PrintLabelFlag { PRINT_LABEL, OMIT_LABEL };\n  void DebugString(int depth, PrintLabelFlag print_label_flag,\n                   string* contents, const DebugStringOptions& options) const;\n\n  // formats the default value appropriately and returns it as a string.\n  // Must have a default value to call this. If quote_string_type is true, then\n  // types of CPPTYPE_STRING whill be surrounded by quotes and CEscaped.\n  string DefaultValueAsString(bool quote_string_type) const;\n\n  // Helper function that returns the field type name for DebugString.\n  string FieldTypeNameDebugString() const;\n\n  // Walks up the descriptor tree to generate the source location path\n  // to this descriptor from the file root.\n  void GetLocationPath(std::vector<int>* output) const;\n\n  const string* name_;\n  const string* full_name_;\n  const string* lowercase_name_;\n  const string* camelcase_name_;\n  // Whether the user has specified the json_name field option in the .proto\n  // file.\n  bool has_json_name_;\n  // If has_json_name_ is true, it's the value specified by the user.\n  // Otherwise, it has the same value as lowercase_name_.\n  const string* json_name_;\n  const FileDescriptor* file_;\n  int number_;\n  Type type_;\n  Label label_;\n  bool is_extension_;\n  int index_in_oneof_;\n  const Descriptor* containing_type_;\n  const OneofDescriptor* containing_oneof_;\n  const Descriptor* extension_scope_;\n  const Descriptor* message_type_;\n  const EnumDescriptor* enum_type_;\n  const FieldOptions* options_;\n  // IMPORTANT:  If you add a new field, make sure to search for all instances\n  // of Allocate<FieldDescriptor>() and AllocateArray<FieldDescriptor>() in\n  // descriptor.cc and update them to initialize the field.\n\n  bool has_default_value_;\n  union {\n    int32  default_value_int32_;\n    int64  default_value_int64_;\n    uint32 default_value_uint32_;\n    uint64 default_value_uint64_;\n    float  default_value_float_;\n    double default_value_double_;\n    bool   default_value_bool_;\n\n    const EnumValueDescriptor* default_value_enum_;\n    const string* default_value_string_;\n  };\n\n  static const CppType kTypeToCppTypeMap[MAX_TYPE + 1];\n\n  static const char * const kTypeToName[MAX_TYPE + 1];\n\n  static const char * const kCppTypeToName[MAX_CPPTYPE + 1];\n\n  static const char * const kLabelToName[MAX_LABEL + 1];\n\n  // Must be constructed using DescriptorPool.\n  FieldDescriptor() {}\n  friend class DescriptorBuilder;\n  friend class FileDescriptor;\n  friend class Descriptor;\n  friend class OneofDescriptor;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldDescriptor);\n};\n\n// Describes a oneof defined in a message type.\nclass LIBPROTOBUF_EXPORT OneofDescriptor {\n public:\n  const string& name() const;       // Name of this oneof.\n  const string& full_name() const;  // Fully-qualified name of the oneof.\n\n  // Index of this oneof within the message's oneof array.\n  int index() const;\n\n  // The Descriptor for the message containing this oneof.\n  const Descriptor* containing_type() const;\n\n  // The number of (non-extension) fields which are members of this oneof.\n  int field_count() const;\n  // Get a member of this oneof, in the order in which they were declared in the\n  // .proto file.  Does not include extensions.\n  const FieldDescriptor* field(int index) const;\n\n  const OneofOptions& options() const;\n\n  // See Descriptor::CopyTo().\n  void CopyTo(OneofDescriptorProto* proto) const;\n\n  // See Descriptor::DebugString().\n  string DebugString() const;\n\n  // See Descriptor::DebugStringWithOptions().\n  string DebugStringWithOptions(const DebugStringOptions& options) const;\n\n  // Source Location ---------------------------------------------------\n\n  // Updates |*out_location| to the source location of the complete\n  // extent of this oneof declaration.  Returns false and leaves\n  // |*out_location| unchanged iff location information was not available.\n  bool GetSourceLocation(SourceLocation* out_location) const;\n\n private:\n  typedef OneofOptions OptionsType;\n\n  // Allows access to GetLocationPath for annotations.\n  friend class ::google::protobuf::io::Printer;\n\n  // See Descriptor::DebugString().\n  void DebugString(int depth, string* contents,\n                   const DebugStringOptions& options) const;\n\n  // Walks up the descriptor tree to generate the source location path\n  // to this descriptor from the file root.\n  void GetLocationPath(std::vector<int>* output) const;\n\n  const string* name_;\n  const string* full_name_;\n  const Descriptor* containing_type_;\n  bool is_extendable_;\n  int field_count_;\n  const FieldDescriptor** fields_;\n  const OneofOptions* options_;\n\n  // IMPORTANT:  If you add a new field, make sure to search for all instances\n  // of Allocate<OneofDescriptor>() and AllocateArray<OneofDescriptor>()\n  // in descriptor.cc and update them to initialize the field.\n\n  // Must be constructed using DescriptorPool.\n  OneofDescriptor() {}\n  friend class DescriptorBuilder;\n  friend class Descriptor;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(OneofDescriptor);\n};\n\n// Describes an enum type defined in a .proto file.  To get the EnumDescriptor\n// for a generated enum type, call TypeName_descriptor().  Use DescriptorPool\n// to construct your own descriptors.\nclass LIBPROTOBUF_EXPORT EnumDescriptor {\n public:\n  // The name of this enum type in the containing scope.\n  const string& name() const;\n\n  // The fully-qualified name of the enum type, scope delimited by periods.\n  const string& full_name() const;\n\n  // Index of this enum within the file or containing message's enum array.\n  int index() const;\n\n  // The .proto file in which this enum type was defined.  Never NULL.\n  const FileDescriptor* file() const;\n\n  // The number of values for this EnumDescriptor.  Guaranteed to be greater\n  // than zero.\n  int value_count() const;\n  // Gets a value by index, where 0 <= index < value_count().\n  // These are returned in the order they were defined in the .proto file.\n  const EnumValueDescriptor* value(int index) const;\n\n  // Looks up a value by name.  Returns NULL if no such value exists.\n  const EnumValueDescriptor* FindValueByName(const string& name) const;\n  // Looks up a value by number.  Returns NULL if no such value exists.  If\n  // multiple values have this number, the first one defined is returned.\n  const EnumValueDescriptor* FindValueByNumber(int number) const;\n\n  // If this enum type is nested in a message type, this is that message type.\n  // Otherwise, NULL.\n  const Descriptor* containing_type() const;\n\n  // Get options for this enum type.  These are specified in the .proto file by\n  // placing lines like \"option foo = 1234;\" in the enum definition.  Allowed\n  // options are defined by EnumOptions in google/protobuf/descriptor.proto,\n  // and any available extensions of that message.\n  const EnumOptions& options() const;\n\n  // See Descriptor::CopyTo().\n  void CopyTo(EnumDescriptorProto* proto) const;\n\n  // See Descriptor::DebugString().\n  string DebugString() const;\n\n  // See Descriptor::DebugStringWithOptions().\n  string DebugStringWithOptions(const DebugStringOptions& options) const;\n\n\n  // Returns true if this is a placeholder for an unknown enum. This will\n  // only be the case if this descriptor comes from a DescriptorPool\n  // with AllowUnknownDependencies() set.\n  bool is_placeholder() const;\n\n  // Source Location ---------------------------------------------------\n\n  // Updates |*out_location| to the source location of the complete\n  // extent of this enum declaration.  Returns false and leaves\n  // |*out_location| unchanged iff location information was not available.\n  bool GetSourceLocation(SourceLocation* out_location) const;\n\n private:\n  typedef EnumOptions OptionsType;\n\n  // Allows access to GetLocationPath for annotations.\n  friend class ::google::protobuf::io::Printer;\n\n  // Looks up a value by number.  If the value does not exist, dynamically\n  // creates a new EnumValueDescriptor for that value, assuming that it was\n  // unknown. If a new descriptor is created, this is done in a thread-safe way,\n  // and future calls will return the same value descriptor pointer.\n  //\n  // This is private but is used by GeneratedMessageReflection (which is\n  // friended below) to return a valid EnumValueDescriptor from GetEnum() when\n  // this feature is enabled.\n  const EnumValueDescriptor*\n      FindValueByNumberCreatingIfUnknown(int number) const;\n\n\n  // See Descriptor::DebugString().\n  void DebugString(int depth, string *contents,\n                   const DebugStringOptions& options) const;\n\n  // Walks up the descriptor tree to generate the source location path\n  // to this descriptor from the file root.\n  void GetLocationPath(std::vector<int>* output) const;\n\n  const string* name_;\n  const string* full_name_;\n  const FileDescriptor* file_;\n  const Descriptor* containing_type_;\n  const EnumOptions* options_;\n\n  // True if this is a placeholder for an unknown type.\n  bool is_placeholder_;\n  // True if this is a placeholder and the type name wasn't fully-qualified.\n  bool is_unqualified_placeholder_;\n\n  int value_count_;\n  EnumValueDescriptor* values_;\n  // IMPORTANT:  If you add a new field, make sure to search for all instances\n  // of Allocate<EnumDescriptor>() and AllocateArray<EnumDescriptor>() in\n  // descriptor.cc and update them to initialize the field.\n\n  // Must be constructed using DescriptorPool.\n  EnumDescriptor() {}\n  friend class DescriptorBuilder;\n  friend class Descriptor;\n  friend class FieldDescriptor;\n  friend class EnumValueDescriptor;\n  friend class FileDescriptor;\n  friend class internal::GeneratedMessageReflection;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumDescriptor);\n};\n\n// Describes an individual enum constant of a particular type.  To get the\n// EnumValueDescriptor for a given enum value, first get the EnumDescriptor\n// for its type, then use EnumDescriptor::FindValueByName() or\n// EnumDescriptor::FindValueByNumber().  Use DescriptorPool to construct\n// your own descriptors.\nclass LIBPROTOBUF_EXPORT EnumValueDescriptor {\n public:\n  const string& name() const;  // Name of this enum constant.\n  int index() const;           // Index within the enums's Descriptor.\n  int number() const;          // Numeric value of this enum constant.\n\n  // The full_name of an enum value is a sibling symbol of the enum type.\n  // e.g. the full name of FieldDescriptorProto::TYPE_INT32 is actually\n  // \"google.protobuf.FieldDescriptorProto.TYPE_INT32\", NOT\n  // \"google.protobuf.FieldDescriptorProto.Type.TYPE_INT32\".  This is to conform\n  // with C++ scoping rules for enums.\n  const string& full_name() const;\n\n  // The type of this value.  Never NULL.\n  const EnumDescriptor* type() const;\n\n  // Get options for this enum value.  These are specified in the .proto file\n  // by adding text like \"[foo = 1234]\" after an enum value definition.\n  // Allowed options are defined by EnumValueOptions in\n  // google/protobuf/descriptor.proto, and any available extensions of that\n  // message.\n  const EnumValueOptions& options() const;\n\n  // See Descriptor::CopyTo().\n  void CopyTo(EnumValueDescriptorProto* proto) const;\n\n  // See Descriptor::DebugString().\n  string DebugString() const;\n\n  // See Descriptor::DebugStringWithOptions().\n  string DebugStringWithOptions(const DebugStringOptions& options) const;\n\n\n  // Source Location ---------------------------------------------------\n\n  // Updates |*out_location| to the source location of the complete\n  // extent of this enum value declaration.  Returns false and leaves\n  // |*out_location| unchanged iff location information was not available.\n  bool GetSourceLocation(SourceLocation* out_location) const;\n\n private:\n  typedef EnumValueOptions OptionsType;\n\n  // Allows access to GetLocationPath for annotations.\n  friend class ::google::protobuf::io::Printer;\n\n  // See Descriptor::DebugString().\n  void DebugString(int depth, string *contents,\n                   const DebugStringOptions& options) const;\n\n  // Walks up the descriptor tree to generate the source location path\n  // to this descriptor from the file root.\n  void GetLocationPath(std::vector<int>* output) const;\n\n  const string* name_;\n  const string* full_name_;\n  int number_;\n  const EnumDescriptor* type_;\n  const EnumValueOptions* options_;\n  // IMPORTANT:  If you add a new field, make sure to search for all instances\n  // of Allocate<EnumValueDescriptor>() and AllocateArray<EnumValueDescriptor>()\n  // in descriptor.cc and update them to initialize the field.\n\n  // Must be constructed using DescriptorPool.\n  EnumValueDescriptor() {}\n  friend class DescriptorBuilder;\n  friend class EnumDescriptor;\n  friend class FileDescriptorTables;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EnumValueDescriptor);\n};\n\n// Describes an RPC service.  To get the ServiceDescriptor for a service,\n// call Service::GetDescriptor().  Generated service classes also have a\n// static method called descriptor() which returns the type's\n// ServiceDescriptor.  Use DescriptorPool to construct your own descriptors.\nclass LIBPROTOBUF_EXPORT ServiceDescriptor {\n public:\n  // The name of the service, not including its containing scope.\n  const string& name() const;\n  // The fully-qualified name of the service, scope delimited by periods.\n  const string& full_name() const;\n  // Index of this service within the file's services array.\n  int index() const;\n\n  // The .proto file in which this service was defined.  Never NULL.\n  const FileDescriptor* file() const;\n\n  // Get options for this service type.  These are specified in the .proto file\n  // by placing lines like \"option foo = 1234;\" in the service definition.\n  // Allowed options are defined by ServiceOptions in\n  // google/protobuf/descriptor.proto, and any available extensions of that\n  // message.\n  const ServiceOptions& options() const;\n\n  // The number of methods this service defines.\n  int method_count() const;\n  // Gets a MethodDescriptor by index, where 0 <= index < method_count().\n  // These are returned in the order they were defined in the .proto file.\n  const MethodDescriptor* method(int index) const;\n\n  // Look up a MethodDescriptor by name.\n  const MethodDescriptor* FindMethodByName(const string& name) const;\n  // See Descriptor::CopyTo().\n  void CopyTo(ServiceDescriptorProto* proto) const;\n\n  // See Descriptor::DebugString().\n  string DebugString() const;\n\n  // See Descriptor::DebugStringWithOptions().\n  string DebugStringWithOptions(const DebugStringOptions& options) const;\n\n\n  // Source Location ---------------------------------------------------\n\n  // Updates |*out_location| to the source location of the complete\n  // extent of this service declaration.  Returns false and leaves\n  // |*out_location| unchanged iff location information was not available.\n  bool GetSourceLocation(SourceLocation* out_location) const;\n\n private:\n  typedef ServiceOptions OptionsType;\n\n  // Allows access to GetLocationPath for annotations.\n  friend class ::google::protobuf::io::Printer;\n\n  // See Descriptor::DebugString().\n  void DebugString(string *contents, const DebugStringOptions& options) const;\n\n  // Walks up the descriptor tree to generate the source location path\n  // to this descriptor from the file root.\n  void GetLocationPath(std::vector<int>* output) const;\n\n  const string* name_;\n  const string* full_name_;\n  const FileDescriptor* file_;\n  const ServiceOptions* options_;\n  int method_count_;\n  MethodDescriptor* methods_;\n  // IMPORTANT:  If you add a new field, make sure to search for all instances\n  // of Allocate<ServiceDescriptor>() and AllocateArray<ServiceDescriptor>() in\n  // descriptor.cc and update them to initialize the field.\n\n  // Must be constructed using DescriptorPool.\n  ServiceDescriptor() {}\n  friend class DescriptorBuilder;\n  friend class FileDescriptor;\n  friend class MethodDescriptor;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ServiceDescriptor);\n};\n\n// Describes an individual service method.  To obtain a MethodDescriptor given\n// a service, first get its ServiceDescriptor, then call\n// ServiceDescriptor::FindMethodByName().  Use DescriptorPool to construct your\n// own descriptors.\nclass LIBPROTOBUF_EXPORT MethodDescriptor {\n public:\n  // Name of this method, not including containing scope.\n  const string& name() const;\n  // The fully-qualified name of the method, scope delimited by periods.\n  const string& full_name() const;\n  // Index within the service's Descriptor.\n  int index() const;\n\n  // Gets the service to which this method belongs.  Never NULL.\n  const ServiceDescriptor* service() const;\n\n  // Gets the type of protocol message which this method accepts as input.\n  const Descriptor* input_type() const;\n  // Gets the type of protocol message which this message produces as output.\n  const Descriptor* output_type() const;\n\n  // Gets whether the client streams multiple requests.\n  bool client_streaming() const;\n  // Gets whether the server streams multiple responses.\n  bool server_streaming() const;\n\n  // Get options for this method.  These are specified in the .proto file by\n  // placing lines like \"option foo = 1234;\" in curly-braces after a method\n  // declaration.  Allowed options are defined by MethodOptions in\n  // google/protobuf/descriptor.proto, and any available extensions of that\n  // message.\n  const MethodOptions& options() const;\n\n  // See Descriptor::CopyTo().\n  void CopyTo(MethodDescriptorProto* proto) const;\n\n  // See Descriptor::DebugString().\n  string DebugString() const;\n\n  // See Descriptor::DebugStringWithOptions().\n  string DebugStringWithOptions(const DebugStringOptions& options) const;\n\n\n  // Source Location ---------------------------------------------------\n\n  // Updates |*out_location| to the source location of the complete\n  // extent of this method declaration.  Returns false and leaves\n  // |*out_location| unchanged iff location information was not available.\n  bool GetSourceLocation(SourceLocation* out_location) const;\n\n private:\n  typedef MethodOptions OptionsType;\n\n  // Allows access to GetLocationPath for annotations.\n  friend class ::google::protobuf::io::Printer;\n\n  // See Descriptor::DebugString().\n  void DebugString(int depth, string *contents,\n                   const DebugStringOptions& options) const;\n\n  // Walks up the descriptor tree to generate the source location path\n  // to this descriptor from the file root.\n  void GetLocationPath(std::vector<int>* output) const;\n\n  const string* name_;\n  const string* full_name_;\n  const ServiceDescriptor* service_;\n  const Descriptor* input_type_;\n  const Descriptor* output_type_;\n  const MethodOptions* options_;\n  bool client_streaming_;\n  bool server_streaming_;\n  // IMPORTANT:  If you add a new field, make sure to search for all instances\n  // of Allocate<MethodDescriptor>() and AllocateArray<MethodDescriptor>() in\n  // descriptor.cc and update them to initialize the field.\n\n  // Must be constructed using DescriptorPool.\n  MethodDescriptor() {}\n  friend class DescriptorBuilder;\n  friend class ServiceDescriptor;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MethodDescriptor);\n};\n\n\n// Describes a whole .proto file.  To get the FileDescriptor for a compiled-in\n// file, get the descriptor for something defined in that file and call\n// descriptor->file().  Use DescriptorPool to construct your own descriptors.\nclass LIBPROTOBUF_EXPORT FileDescriptor {\n public:\n  // The filename, relative to the source tree.\n  // e.g. \"google/protobuf/descriptor.proto\"\n  const string& name() const;\n\n  // The package, e.g. \"google.protobuf.compiler\".\n  const string& package() const;\n\n  // The DescriptorPool in which this FileDescriptor and all its contents were\n  // allocated.  Never NULL.\n  const DescriptorPool* pool() const;\n\n  // The number of files imported by this one.\n  int dependency_count() const;\n  // Gets an imported file by index, where 0 <= index < dependency_count().\n  // These are returned in the order they were defined in the .proto file.\n  const FileDescriptor* dependency(int index) const;\n\n  // The number of files public imported by this one.\n  // The public dependency list is a subset of the dependency list.\n  int public_dependency_count() const;\n  // Gets a public imported file by index, where 0 <= index <\n  // public_dependency_count().\n  // These are returned in the order they were defined in the .proto file.\n  const FileDescriptor* public_dependency(int index) const;\n\n  // The number of files that are imported for weak fields.\n  // The weak dependency list is a subset of the dependency list.\n  int weak_dependency_count() const;\n  // Gets a weak imported file by index, where 0 <= index <\n  // weak_dependency_count().\n  // These are returned in the order they were defined in the .proto file.\n  const FileDescriptor* weak_dependency(int index) const;\n\n  // Number of top-level message types defined in this file.  (This does not\n  // include nested types.)\n  int message_type_count() const;\n  // Gets a top-level message type, where 0 <= index < message_type_count().\n  // These are returned in the order they were defined in the .proto file.\n  const Descriptor* message_type(int index) const;\n\n  // Number of top-level enum types defined in this file.  (This does not\n  // include nested types.)\n  int enum_type_count() const;\n  // Gets a top-level enum type, where 0 <= index < enum_type_count().\n  // These are returned in the order they were defined in the .proto file.\n  const EnumDescriptor* enum_type(int index) const;\n\n  // Number of services defined in this file.\n  int service_count() const;\n  // Gets a service, where 0 <= index < service_count().\n  // These are returned in the order they were defined in the .proto file.\n  const ServiceDescriptor* service(int index) const;\n\n  // Number of extensions defined at file scope.  (This does not include\n  // extensions nested within message types.)\n  int extension_count() const;\n  // Gets an extension's descriptor, where 0 <= index < extension_count().\n  // These are returned in the order they were defined in the .proto file.\n  const FieldDescriptor* extension(int index) const;\n\n  // Get options for this file.  These are specified in the .proto file by\n  // placing lines like \"option foo = 1234;\" at the top level, outside of any\n  // other definitions.  Allowed options are defined by FileOptions in\n  // google/protobuf/descriptor.proto, and any available extensions of that\n  // message.\n  const FileOptions& options() const;\n\n  // Syntax of this file.\n  enum Syntax {\n    SYNTAX_UNKNOWN = 0,\n    SYNTAX_PROTO2  = 2,\n    SYNTAX_PROTO3  = 3,\n  };\n  Syntax syntax() const;\n  static const char* SyntaxName(Syntax syntax);\n\n  // Find a top-level message type by name.  Returns NULL if not found.\n  const Descriptor* FindMessageTypeByName(const string& name) const;\n  // Find a top-level enum type by name.  Returns NULL if not found.\n  const EnumDescriptor* FindEnumTypeByName(const string& name) const;\n  // Find an enum value defined in any top-level enum by name.  Returns NULL if\n  // not found.\n  const EnumValueDescriptor* FindEnumValueByName(const string& name) const;\n  // Find a service definition by name.  Returns NULL if not found.\n  const ServiceDescriptor* FindServiceByName(const string& name) const;\n  // Find a top-level extension definition by name.  Returns NULL if not found.\n  const FieldDescriptor* FindExtensionByName(const string& name) const;\n  // Similar to FindExtensionByName(), but searches by lowercased-name.  See\n  // Descriptor::FindFieldByLowercaseName().\n  const FieldDescriptor* FindExtensionByLowercaseName(const string& name) const;\n  // Similar to FindExtensionByName(), but searches by camelcased-name.  See\n  // Descriptor::FindFieldByCamelcaseName().\n  const FieldDescriptor* FindExtensionByCamelcaseName(const string& name) const;\n\n  // See Descriptor::CopyTo().\n  // Notes:\n  // - This method does NOT copy source code information since it is relatively\n  //   large and rarely needed.  See CopySourceCodeInfoTo() below.\n  void CopyTo(FileDescriptorProto* proto) const;\n  // Write the source code information of this FileDescriptor into the given\n  // FileDescriptorProto.  See CopyTo() above.\n  void CopySourceCodeInfoTo(FileDescriptorProto* proto) const;\n  // Fill the json_name field of FieldDescriptorProto for all fields. Can only\n  // be called after CopyTo().\n  void CopyJsonNameTo(FileDescriptorProto* proto) const;\n\n  // See Descriptor::DebugString().\n  string DebugString() const;\n\n  // See Descriptor::DebugStringWithOptions().\n  string DebugStringWithOptions(const DebugStringOptions& options) const;\n\n  // Returns true if this is a placeholder for an unknown file. This will\n  // only be the case if this descriptor comes from a DescriptorPool\n  // with AllowUnknownDependencies() set.\n  bool is_placeholder() const;\n\n  // Updates |*out_location| to the source location of the complete extent of\n  // this file declaration (namely, the empty path).\n  bool GetSourceLocation(SourceLocation* out_location) const;\n\n  // Updates |*out_location| to the source location of the complete\n  // extent of the declaration or declaration-part denoted by |path|.\n  // Returns false and leaves |*out_location| unchanged iff location\n  // information was not available.  (See SourceCodeInfo for\n  // description of path encoding.)\n  bool GetSourceLocation(const std::vector<int>& path,\n                         SourceLocation* out_location) const;\n\n private:\n  typedef FileOptions OptionsType;\n\n  const string* name_;\n  const string* package_;\n  const DescriptorPool* pool_;\n  int dependency_count_;\n  const FileDescriptor** dependencies_;\n  int public_dependency_count_;\n  int* public_dependencies_;\n  int weak_dependency_count_;\n  int* weak_dependencies_;\n  int message_type_count_;\n  Descriptor* message_types_;\n  int enum_type_count_;\n  EnumDescriptor* enum_types_;\n  int service_count_;\n  ServiceDescriptor* services_;\n  int extension_count_;\n  Syntax syntax_;\n  bool is_placeholder_;\n  FieldDescriptor* extensions_;\n  const FileOptions* options_;\n\n  const FileDescriptorTables* tables_;\n  const SourceCodeInfo* source_code_info_;\n  // IMPORTANT:  If you add a new field, make sure to search for all instances\n  // of Allocate<FileDescriptor>() and AllocateArray<FileDescriptor>() in\n  // descriptor.cc and update them to initialize the field.\n\n  FileDescriptor() {}\n  friend class DescriptorBuilder;\n  friend class Descriptor;\n  friend class FieldDescriptor;\n  friend class OneofDescriptor;\n  friend class EnumDescriptor;\n  friend class EnumValueDescriptor;\n  friend class MethodDescriptor;\n  friend class ServiceDescriptor;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileDescriptor);\n};\n\n// ===================================================================\n\n// Used to construct descriptors.\n//\n// Normally you won't want to build your own descriptors.  Message classes\n// constructed by the protocol compiler will provide them for you.  However,\n// if you are implementing Message on your own, or if you are writing a\n// program which can operate on totally arbitrary types and needs to load\n// them from some sort of database, you might need to.\n//\n// Since Descriptors are composed of a whole lot of cross-linked bits of\n// data that would be a pain to put together manually, the\n// DescriptorPool class is provided to make the process easier.  It can\n// take a FileDescriptorProto (defined in descriptor.proto), validate it,\n// and convert it to a set of nicely cross-linked Descriptors.\n//\n// DescriptorPool also helps with memory management.  Descriptors are\n// composed of many objects containing static data and pointers to each\n// other.  In all likelihood, when it comes time to delete this data,\n// you'll want to delete it all at once.  In fact, it is not uncommon to\n// have a whole pool of descriptors all cross-linked with each other which\n// you wish to delete all at once.  This class represents such a pool, and\n// handles the memory management for you.\n//\n// You can also search for descriptors within a DescriptorPool by name, and\n// extensions by number.\nclass LIBPROTOBUF_EXPORT DescriptorPool {\n public:\n  // Create a normal, empty DescriptorPool.\n  DescriptorPool();\n\n  // Constructs a DescriptorPool that, when it can't find something among the\n  // descriptors already in the pool, looks for it in the given\n  // DescriptorDatabase.\n  // Notes:\n  // - If a DescriptorPool is constructed this way, its BuildFile*() methods\n  //   must not be called (they will assert-fail).  The only way to populate\n  //   the pool with descriptors is to call the Find*By*() methods.\n  // - The Find*By*() methods may block the calling thread if the\n  //   DescriptorDatabase blocks.  This in turn means that parsing messages\n  //   may block if they need to look up extensions.\n  // - The Find*By*() methods will use mutexes for thread-safety, thus making\n  //   them slower even when they don't have to fall back to the database.\n  //   In fact, even the Find*By*() methods of descriptor objects owned by\n  //   this pool will be slower, since they will have to obtain locks too.\n  // - An ErrorCollector may optionally be given to collect validation errors\n  //   in files loaded from the database.  If not given, errors will be printed\n  //   to GOOGLE_LOG(ERROR).  Remember that files are built on-demand, so this\n  //   ErrorCollector may be called from any thread that calls one of the\n  //   Find*By*() methods.\n  // - The DescriptorDatabase must not be mutated during the lifetime of\n  //   the DescriptorPool. Even if the client takes care to avoid data races,\n  //   changes to the content of the DescriptorDatabase may not be reflected\n  //   in subsequent lookups in the DescriptorPool.\n  class ErrorCollector;\n  explicit DescriptorPool(DescriptorDatabase* fallback_database,\n                          ErrorCollector* error_collector = NULL);\n\n  ~DescriptorPool();\n\n  // Get a pointer to the generated pool.  Generated protocol message classes\n  // which are compiled into the binary will allocate their descriptors in\n  // this pool.  Do not add your own descriptors to this pool.\n  static const DescriptorPool* generated_pool();\n\n\n  // Find a FileDescriptor in the pool by file name.  Returns NULL if not\n  // found.\n  const FileDescriptor* FindFileByName(const string& name) const;\n\n  // Find the FileDescriptor in the pool which defines the given symbol.\n  // If any of the Find*ByName() methods below would succeed, then this is\n  // equivalent to calling that method and calling the result's file() method.\n  // Otherwise this returns NULL.\n  const FileDescriptor* FindFileContainingSymbol(\n      const string& symbol_name) const;\n\n  // Looking up descriptors ------------------------------------------\n  // These find descriptors by fully-qualified name.  These will find both\n  // top-level descriptors and nested descriptors.  They return NULL if not\n  // found.\n\n  const Descriptor* FindMessageTypeByName(const string& name) const;\n  const FieldDescriptor* FindFieldByName(const string& name) const;\n  const FieldDescriptor* FindExtensionByName(const string& name) const;\n  const OneofDescriptor* FindOneofByName(const string& name) const;\n  const EnumDescriptor* FindEnumTypeByName(const string& name) const;\n  const EnumValueDescriptor* FindEnumValueByName(const string& name) const;\n  const ServiceDescriptor* FindServiceByName(const string& name) const;\n  const MethodDescriptor* FindMethodByName(const string& name) const;\n\n  // Finds an extension of the given type by number.  The extendee must be\n  // a member of this DescriptorPool or one of its underlays.\n  const FieldDescriptor* FindExtensionByNumber(const Descriptor* extendee,\n                                               int number) const;\n\n  // Finds extensions of extendee. The extensions will be appended to\n  // out in an undefined order. Only extensions defined directly in\n  // this DescriptorPool or one of its underlays are guaranteed to be\n  // found: extensions defined in the fallback database might not be found\n  // depending on the database implementation.\n  void FindAllExtensions(const Descriptor* extendee,\n                         std::vector<const FieldDescriptor*>* out) const;\n\n  // Building descriptors --------------------------------------------\n\n  // When converting a FileDescriptorProto to a FileDescriptor, various\n  // errors might be detected in the input.  The caller may handle these\n  // programmatically by implementing an ErrorCollector.\n  class LIBPROTOBUF_EXPORT ErrorCollector {\n   public:\n    inline ErrorCollector() {}\n    virtual ~ErrorCollector();\n\n    // These constants specify what exact part of the construct is broken.\n    // This is useful e.g. for mapping the error back to an exact location\n    // in a .proto file.\n    enum ErrorLocation {\n      NAME,              // the symbol name, or the package name for files\n      NUMBER,            // field or extension range number\n      TYPE,              // field type\n      EXTENDEE,          // field extendee\n      DEFAULT_VALUE,     // field default value\n      INPUT_TYPE,        // method input type\n      OUTPUT_TYPE,       // method output type\n      OPTION_NAME,       // name in assignment\n      OPTION_VALUE,      // value in option assignment\n      OTHER              // some other problem\n    };\n\n    // Reports an error in the FileDescriptorProto. Use this function if the\n    // problem occurred should interrupt building the FileDescriptorProto.\n    virtual void AddError(\n      const string& filename,      // File name in which the error occurred.\n      const string& element_name,  // Full name of the erroneous element.\n      const Message* descriptor,   // Descriptor of the erroneous element.\n      ErrorLocation location,      // One of the location constants, above.\n      const string& message        // Human-readable error message.\n      ) = 0;\n\n    // Reports a warning in the FileDescriptorProto. Use this function if the\n    // problem occurred should NOT interrupt building the FileDescriptorProto.\n    virtual void AddWarning(\n      const string& /*filename*/,      // File name in which the error occurred.\n      const string& /*element_name*/,  // Full name of the erroneous element.\n      const Message* /*descriptor*/,   // Descriptor of the erroneous element.\n      ErrorLocation /*location*/,      // One of the location constants, above.\n      const string& /*message*/        // Human-readable error message.\n      ) {}\n\n   private:\n    GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ErrorCollector);\n  };\n\n  // Convert the FileDescriptorProto to real descriptors and place them in\n  // this DescriptorPool.  All dependencies of the file must already be in\n  // the pool.  Returns the resulting FileDescriptor, or NULL if there were\n  // problems with the input (e.g. the message was invalid, or dependencies\n  // were missing).  Details about the errors are written to GOOGLE_LOG(ERROR).\n  const FileDescriptor* BuildFile(const FileDescriptorProto& proto);\n\n  // Same as BuildFile() except errors are sent to the given ErrorCollector.\n  const FileDescriptor* BuildFileCollectingErrors(\n    const FileDescriptorProto& proto,\n    ErrorCollector* error_collector);\n\n  // By default, it is an error if a FileDescriptorProto contains references\n  // to types or other files that are not found in the DescriptorPool (or its\n  // backing DescriptorDatabase, if any).  If you call\n  // AllowUnknownDependencies(), however, then unknown types and files\n  // will be replaced by placeholder descriptors (which can be identified by\n  // the is_placeholder() method).  This can allow you to\n  // perform some useful operations with a .proto file even if you do not\n  // have access to other .proto files on which it depends.  However, some\n  // heuristics must be used to fill in the gaps in information, and these\n  // can lead to descriptors which are inaccurate.  For example, the\n  // DescriptorPool may be forced to guess whether an unknown type is a message\n  // or an enum, as well as what package it resides in.  Furthermore,\n  // placeholder types will not be discoverable via FindMessageTypeByName()\n  // and similar methods, which could confuse some descriptor-based algorithms.\n  // Generally, the results of this option should be handled with extreme care.\n  void AllowUnknownDependencies() { allow_unknown_ = true; }\n\n  // By default, weak imports are allowed to be missing, in which case we will\n  // use a placeholder for the dependency and convert the field to be an Empty\n  // message field. If you call EnforceWeakDependencies(true), however, the\n  // DescriptorPool will report a import not found error.\n  void EnforceWeakDependencies(bool enforce) { enforce_weak_ = enforce; }\n\n  // Internal stuff --------------------------------------------------\n  // These methods MUST NOT be called from outside the proto2 library.\n  // These methods may contain hidden pitfalls and may be removed in a\n  // future library version.\n\n  // Create a DescriptorPool which is overlaid on top of some other pool.\n  // If you search for a descriptor in the overlay and it is not found, the\n  // underlay will be searched as a backup.  If the underlay has its own\n  // underlay, that will be searched next, and so on.  This also means that\n  // files built in the overlay will be cross-linked with the underlay's\n  // descriptors if necessary.  The underlay remains property of the caller;\n  // it must remain valid for the lifetime of the newly-constructed pool.\n  //\n  // Example:  Say you want to parse a .proto file at runtime in order to use\n  // its type with a DynamicMessage.  Say this .proto file has dependencies,\n  // but you know that all the dependencies will be things that are already\n  // compiled into the binary.  For ease of use, you'd like to load the types\n  // right out of generated_pool() rather than have to parse redundant copies\n  // of all these .protos and runtime.  But, you don't want to add the parsed\n  // types directly into generated_pool(): this is not allowed, and would be\n  // bad design anyway.  So, instead, you could use generated_pool() as an\n  // underlay for a new DescriptorPool in which you add only the new file.\n  //\n  // WARNING:  Use of underlays can lead to many subtle gotchas.  Instead,\n  //   try to formulate what you want to do in terms of DescriptorDatabases.\n  explicit DescriptorPool(const DescriptorPool* underlay);\n\n  // Called by generated classes at init time to add their descriptors to\n  // generated_pool.  Do NOT call this in your own code!  filename must be a\n  // permanent string (e.g. a string literal).\n  static void InternalAddGeneratedFile(\n      const void* encoded_file_descriptor, int size);\n\n\n  // For internal use only:  Gets a non-const pointer to the generated pool.\n  // This is called at static-initialization time only, so thread-safety is\n  // not a concern.  If both an underlay and a fallback database are present,\n  // the underlay takes precedence.\n  static DescriptorPool* internal_generated_pool();\n\n  // For internal use only:  Changes the behavior of BuildFile() such that it\n  // allows the file to make reference to message types declared in other files\n  // which it did not officially declare as dependencies.\n  void InternalDontEnforceDependencies();\n\n  // For internal use only.\n  void internal_set_underlay(const DescriptorPool* underlay) {\n    underlay_ = underlay;\n  }\n\n  // For internal (unit test) use only:  Returns true if a FileDescriptor has\n  // been constructed for the given file, false otherwise.  Useful for testing\n  // lazy descriptor initialization behavior.\n  bool InternalIsFileLoaded(const string& filename) const;\n\n\n  // Add a file to unused_import_track_files_. DescriptorBuilder will log\n  // warnings for those files if there is any unused import.\n  void AddUnusedImportTrackFile(const string& file_name);\n  void ClearUnusedImportTrackFiles();\n\n private:\n  friend class Descriptor;\n  friend class FieldDescriptor;\n  friend class EnumDescriptor;\n  friend class ServiceDescriptor;\n  friend class FileDescriptor;\n  friend class DescriptorBuilder;\n  friend class FileDescriptorTables;\n\n  // Return true if the given name is a sub-symbol of any non-package\n  // descriptor that already exists in the descriptor pool.  (The full\n  // definition of such types is already known.)\n  bool IsSubSymbolOfBuiltType(const string& name) const;\n\n  // Tries to find something in the fallback database and link in the\n  // corresponding proto file.  Returns true if successful, in which case\n  // the caller should search for the thing again.  These are declared\n  // const because they are called by (semantically) const methods.\n  bool TryFindFileInFallbackDatabase(const string& name) const;\n  bool TryFindSymbolInFallbackDatabase(const string& name) const;\n  bool TryFindExtensionInFallbackDatabase(const Descriptor* containing_type,\n                                          int field_number) const;\n\n  // Like BuildFile() but called internally when the file has been loaded from\n  // fallback_database_.  Declared const because it is called by (semantically)\n  // const methods.\n  const FileDescriptor* BuildFileFromDatabase(\n    const FileDescriptorProto& proto) const;\n\n  // If fallback_database_ is NULL, this is NULL.  Otherwise, this is a mutex\n  // which must be locked while accessing tables_.\n  Mutex* mutex_;\n\n  // See constructor.\n  DescriptorDatabase* fallback_database_;\n  ErrorCollector* default_error_collector_;\n  const DescriptorPool* underlay_;\n\n  // This class contains a lot of hash maps with complicated types that\n  // we'd like to keep out of the header.\n  class Tables;\n  google::protobuf::scoped_ptr<Tables> tables_;\n\n  bool enforce_dependencies_;\n  bool allow_unknown_;\n  bool enforce_weak_;\n  std::set<string> unused_import_track_files_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DescriptorPool);\n};\n\n// inline methods ====================================================\n\n// These macros makes this repetitive code more readable.\n#define PROTOBUF_DEFINE_ACCESSOR(CLASS, FIELD, TYPE) \\\n  inline TYPE CLASS::FIELD() const { return FIELD##_; }\n\n// Strings fields are stored as pointers but returned as const references.\n#define PROTOBUF_DEFINE_STRING_ACCESSOR(CLASS, FIELD) \\\n  inline const string& CLASS::FIELD() const { return *FIELD##_; }\n\n// Arrays take an index parameter, obviously.\n#define PROTOBUF_DEFINE_ARRAY_ACCESSOR(CLASS, FIELD, TYPE) \\\n  inline TYPE CLASS::FIELD(int index) const { return FIELD##s_ + index; }\n\n#define PROTOBUF_DEFINE_OPTIONS_ACCESSOR(CLASS, TYPE) \\\n  inline const TYPE& CLASS::options() const { return *options_; }\n\nPROTOBUF_DEFINE_STRING_ACCESSOR(Descriptor, name)\nPROTOBUF_DEFINE_STRING_ACCESSOR(Descriptor, full_name)\nPROTOBUF_DEFINE_ACCESSOR(Descriptor, file, const FileDescriptor*)\nPROTOBUF_DEFINE_ACCESSOR(Descriptor, containing_type, const Descriptor*)\n\nPROTOBUF_DEFINE_ACCESSOR(Descriptor, field_count, int)\nPROTOBUF_DEFINE_ACCESSOR(Descriptor, oneof_decl_count, int)\nPROTOBUF_DEFINE_ACCESSOR(Descriptor, nested_type_count, int)\nPROTOBUF_DEFINE_ACCESSOR(Descriptor, enum_type_count, int)\n\nPROTOBUF_DEFINE_ARRAY_ACCESSOR(Descriptor, field, const FieldDescriptor*)\nPROTOBUF_DEFINE_ARRAY_ACCESSOR(Descriptor, oneof_decl, const OneofDescriptor*)\nPROTOBUF_DEFINE_ARRAY_ACCESSOR(Descriptor, nested_type, const Descriptor*)\nPROTOBUF_DEFINE_ARRAY_ACCESSOR(Descriptor, enum_type, const EnumDescriptor*)\n\nPROTOBUF_DEFINE_ACCESSOR(Descriptor, extension_range_count, int)\nPROTOBUF_DEFINE_ACCESSOR(Descriptor, extension_count, int)\nPROTOBUF_DEFINE_ARRAY_ACCESSOR(Descriptor, extension_range,\n                               const Descriptor::ExtensionRange*)\nPROTOBUF_DEFINE_ARRAY_ACCESSOR(Descriptor, extension,\n                               const FieldDescriptor*)\n\nPROTOBUF_DEFINE_ACCESSOR(Descriptor, reserved_range_count, int)\nPROTOBUF_DEFINE_ARRAY_ACCESSOR(Descriptor, reserved_range,\n                               const Descriptor::ReservedRange*)\nPROTOBUF_DEFINE_ACCESSOR(Descriptor, reserved_name_count, int)\n\nPROTOBUF_DEFINE_OPTIONS_ACCESSOR(Descriptor, MessageOptions)\nPROTOBUF_DEFINE_ACCESSOR(Descriptor, is_placeholder, bool)\n\nPROTOBUF_DEFINE_STRING_ACCESSOR(FieldDescriptor, name)\nPROTOBUF_DEFINE_STRING_ACCESSOR(FieldDescriptor, full_name)\nPROTOBUF_DEFINE_STRING_ACCESSOR(FieldDescriptor, json_name)\nPROTOBUF_DEFINE_STRING_ACCESSOR(FieldDescriptor, lowercase_name)\nPROTOBUF_DEFINE_STRING_ACCESSOR(FieldDescriptor, camelcase_name)\nPROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, file, const FileDescriptor*)\nPROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, number, int)\nPROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, is_extension, bool)\nPROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, type, FieldDescriptor::Type)\nPROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, label, FieldDescriptor::Label)\nPROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, containing_type, const Descriptor*)\nPROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, containing_oneof,\n                         const OneofDescriptor*)\nPROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, index_in_oneof, int)\nPROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, extension_scope, const Descriptor*)\nPROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, message_type, const Descriptor*)\nPROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, enum_type, const EnumDescriptor*)\nPROTOBUF_DEFINE_OPTIONS_ACCESSOR(FieldDescriptor, FieldOptions)\nPROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, has_default_value, bool)\nPROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_int32 , int32 )\nPROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_int64 , int64 )\nPROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_uint32, uint32)\nPROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_uint64, uint64)\nPROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_float , float )\nPROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_double, double)\nPROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_bool  , bool  )\nPROTOBUF_DEFINE_ACCESSOR(FieldDescriptor, default_value_enum,\n                         const EnumValueDescriptor*)\nPROTOBUF_DEFINE_STRING_ACCESSOR(FieldDescriptor, default_value_string)\n\nPROTOBUF_DEFINE_STRING_ACCESSOR(OneofDescriptor, name)\nPROTOBUF_DEFINE_STRING_ACCESSOR(OneofDescriptor, full_name)\nPROTOBUF_DEFINE_ACCESSOR(OneofDescriptor, containing_type, const Descriptor*)\nPROTOBUF_DEFINE_ACCESSOR(OneofDescriptor, field_count, int)\nPROTOBUF_DEFINE_OPTIONS_ACCESSOR(OneofDescriptor, OneofOptions)\n\nPROTOBUF_DEFINE_STRING_ACCESSOR(EnumDescriptor, name)\nPROTOBUF_DEFINE_STRING_ACCESSOR(EnumDescriptor, full_name)\nPROTOBUF_DEFINE_ACCESSOR(EnumDescriptor, file, const FileDescriptor*)\nPROTOBUF_DEFINE_ACCESSOR(EnumDescriptor, containing_type, const Descriptor*)\nPROTOBUF_DEFINE_ACCESSOR(EnumDescriptor, value_count, int)\nPROTOBUF_DEFINE_ARRAY_ACCESSOR(EnumDescriptor, value,\n                               const EnumValueDescriptor*)\nPROTOBUF_DEFINE_OPTIONS_ACCESSOR(EnumDescriptor, EnumOptions)\nPROTOBUF_DEFINE_ACCESSOR(EnumDescriptor, is_placeholder, bool)\n\nPROTOBUF_DEFINE_STRING_ACCESSOR(EnumValueDescriptor, name)\nPROTOBUF_DEFINE_STRING_ACCESSOR(EnumValueDescriptor, full_name)\nPROTOBUF_DEFINE_ACCESSOR(EnumValueDescriptor, number, int)\nPROTOBUF_DEFINE_ACCESSOR(EnumValueDescriptor, type, const EnumDescriptor*)\nPROTOBUF_DEFINE_OPTIONS_ACCESSOR(EnumValueDescriptor, EnumValueOptions)\n\nPROTOBUF_DEFINE_STRING_ACCESSOR(ServiceDescriptor, name)\nPROTOBUF_DEFINE_STRING_ACCESSOR(ServiceDescriptor, full_name)\nPROTOBUF_DEFINE_ACCESSOR(ServiceDescriptor, file, const FileDescriptor*)\nPROTOBUF_DEFINE_ACCESSOR(ServiceDescriptor, method_count, int)\nPROTOBUF_DEFINE_ARRAY_ACCESSOR(ServiceDescriptor, method,\n                               const MethodDescriptor*)\nPROTOBUF_DEFINE_OPTIONS_ACCESSOR(ServiceDescriptor, ServiceOptions)\n\nPROTOBUF_DEFINE_STRING_ACCESSOR(MethodDescriptor, name)\nPROTOBUF_DEFINE_STRING_ACCESSOR(MethodDescriptor, full_name)\nPROTOBUF_DEFINE_ACCESSOR(MethodDescriptor, service, const ServiceDescriptor*)\nPROTOBUF_DEFINE_ACCESSOR(MethodDescriptor, input_type, const Descriptor*)\nPROTOBUF_DEFINE_ACCESSOR(MethodDescriptor, output_type, const Descriptor*)\nPROTOBUF_DEFINE_OPTIONS_ACCESSOR(MethodDescriptor, MethodOptions)\nPROTOBUF_DEFINE_ACCESSOR(MethodDescriptor, client_streaming, bool)\nPROTOBUF_DEFINE_ACCESSOR(MethodDescriptor, server_streaming, bool)\n\nPROTOBUF_DEFINE_STRING_ACCESSOR(FileDescriptor, name)\nPROTOBUF_DEFINE_STRING_ACCESSOR(FileDescriptor, package)\nPROTOBUF_DEFINE_ACCESSOR(FileDescriptor, pool, const DescriptorPool*)\nPROTOBUF_DEFINE_ACCESSOR(FileDescriptor, dependency_count, int)\nPROTOBUF_DEFINE_ACCESSOR(FileDescriptor, public_dependency_count, int)\nPROTOBUF_DEFINE_ACCESSOR(FileDescriptor, weak_dependency_count, int)\nPROTOBUF_DEFINE_ACCESSOR(FileDescriptor, message_type_count, int)\nPROTOBUF_DEFINE_ACCESSOR(FileDescriptor, enum_type_count, int)\nPROTOBUF_DEFINE_ACCESSOR(FileDescriptor, service_count, int)\nPROTOBUF_DEFINE_ACCESSOR(FileDescriptor, extension_count, int)\nPROTOBUF_DEFINE_OPTIONS_ACCESSOR(FileDescriptor, FileOptions)\nPROTOBUF_DEFINE_ACCESSOR(FileDescriptor, is_placeholder, bool)\n\nPROTOBUF_DEFINE_ARRAY_ACCESSOR(FileDescriptor, message_type, const Descriptor*)\nPROTOBUF_DEFINE_ARRAY_ACCESSOR(FileDescriptor, enum_type, const EnumDescriptor*)\nPROTOBUF_DEFINE_ARRAY_ACCESSOR(FileDescriptor, service,\n                               const ServiceDescriptor*)\nPROTOBUF_DEFINE_ARRAY_ACCESSOR(FileDescriptor, extension,\n                               const FieldDescriptor*)\n\n#undef PROTOBUF_DEFINE_ACCESSOR\n#undef PROTOBUF_DEFINE_STRING_ACCESSOR\n#undef PROTOBUF_DEFINE_ARRAY_ACCESSOR\n\n// A few accessors differ from the macros...\n\ninline bool Descriptor::IsExtensionNumber(int number) const {\n  return FindExtensionRangeContainingNumber(number) != NULL;\n}\n\ninline bool Descriptor::IsReservedNumber(int number) const {\n  return FindReservedRangeContainingNumber(number) != NULL;\n}\n\ninline bool Descriptor::IsReservedName(const string& name) const {\n  for (int i = 0; i < reserved_name_count(); i++) {\n    if (name == reserved_name(i)) {\n      return true;\n    }\n  }\n  return false;\n}\n\n// Can't use PROTOBUF_DEFINE_ARRAY_ACCESSOR because reserved_names_ is actually\n// an array of pointers rather than the usual array of objects.\ninline const string& Descriptor::reserved_name(int index) const {\n  return *reserved_names_[index];\n}\n\ninline bool FieldDescriptor::is_required() const {\n  return label() == LABEL_REQUIRED;\n}\n\ninline bool FieldDescriptor::is_optional() const {\n  return label() == LABEL_OPTIONAL;\n}\n\ninline bool FieldDescriptor::is_repeated() const {\n  return label() == LABEL_REPEATED;\n}\n\ninline bool FieldDescriptor::is_packable() const {\n  return is_repeated() && IsTypePackable(type());\n}\n\n// To save space, index() is computed by looking at the descriptor's position\n// in the parent's array of children.\ninline int FieldDescriptor::index() const {\n  if (!is_extension_) {\n    return static_cast<int>(this - containing_type_->fields_);\n  } else if (extension_scope_ != NULL) {\n    return static_cast<int>(this - extension_scope_->extensions_);\n  } else {\n    return static_cast<int>(this - file_->extensions_);\n  }\n}\n\ninline int Descriptor::index() const {\n  if (containing_type_ == NULL) {\n    return static_cast<int>(this - file_->message_types_);\n  } else {\n    return static_cast<int>(this - containing_type_->nested_types_);\n  }\n}\n\ninline int OneofDescriptor::index() const {\n  return static_cast<int>(this - containing_type_->oneof_decls_);\n}\n\ninline int EnumDescriptor::index() const {\n  if (containing_type_ == NULL) {\n    return static_cast<int>(this - file_->enum_types_);\n  } else {\n    return static_cast<int>(this - containing_type_->enum_types_);\n  }\n}\n\ninline int EnumValueDescriptor::index() const {\n  return static_cast<int>(this - type_->values_);\n}\n\ninline int ServiceDescriptor::index() const {\n  return static_cast<int>(this - file_->services_);\n}\n\ninline int MethodDescriptor::index() const {\n  return static_cast<int>(this - service_->methods_);\n}\n\ninline const char* FieldDescriptor::type_name() const {\n  return kTypeToName[type_];\n}\n\ninline FieldDescriptor::CppType FieldDescriptor::cpp_type() const {\n  return kTypeToCppTypeMap[type_];\n}\n\ninline const char* FieldDescriptor::cpp_type_name() const {\n  return kCppTypeToName[kTypeToCppTypeMap[type_]];\n}\n\ninline FieldDescriptor::CppType FieldDescriptor::TypeToCppType(Type type) {\n  return kTypeToCppTypeMap[type];\n}\n\ninline const char* FieldDescriptor::TypeName(Type type) {\n  return kTypeToName[type];\n}\n\ninline const char* FieldDescriptor::CppTypeName(CppType cpp_type) {\n  return kCppTypeToName[cpp_type];\n}\n\ninline bool FieldDescriptor::IsTypePackable(Type field_type) {\n  return (field_type != FieldDescriptor::TYPE_STRING &&\n          field_type != FieldDescriptor::TYPE_GROUP &&\n          field_type != FieldDescriptor::TYPE_MESSAGE &&\n          field_type != FieldDescriptor::TYPE_BYTES);\n}\n\ninline const FileDescriptor* FileDescriptor::dependency(int index) const {\n  return dependencies_[index];\n}\n\ninline const FileDescriptor* FileDescriptor::public_dependency(\n    int index) const {\n  return dependencies_[public_dependencies_[index]];\n}\n\ninline const FileDescriptor* FileDescriptor::weak_dependency(\n    int index) const {\n  return dependencies_[weak_dependencies_[index]];\n}\n\ninline FileDescriptor::Syntax FileDescriptor::syntax() const {\n  return syntax_;\n}\n\n// Can't use PROTOBUF_DEFINE_ARRAY_ACCESSOR because fields_ is actually an array\n// of pointers rather than the usual array of objects.\ninline const FieldDescriptor* OneofDescriptor::field(int index) const {\n  return fields_[index];\n}\n\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_DESCRIPTOR_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/descriptor.pb.cc",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/descriptor.proto\n\n#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION\n#include <google/protobuf/descriptor.pb.h>\n\n#include <algorithm>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/port.h>\n#include <google/protobuf/stubs/once.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/generated_message_reflection.h>\n#include <google/protobuf/reflection_ops.h>\n#include <google/protobuf/wire_format.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\n\nnamespace {\n\nconst ::google::protobuf::Descriptor* FileDescriptorSet_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  FileDescriptorSet_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* FileDescriptorProto_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  FileDescriptorProto_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* DescriptorProto_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  DescriptorProto_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* DescriptorProto_ExtensionRange_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  DescriptorProto_ExtensionRange_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* DescriptorProto_ReservedRange_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  DescriptorProto_ReservedRange_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* FieldDescriptorProto_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  FieldDescriptorProto_reflection_ = NULL;\nconst ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Type_descriptor_ = NULL;\nconst ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Label_descriptor_ = NULL;\nconst ::google::protobuf::Descriptor* OneofDescriptorProto_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  OneofDescriptorProto_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* EnumDescriptorProto_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  EnumDescriptorProto_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* EnumValueDescriptorProto_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  EnumValueDescriptorProto_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* ServiceDescriptorProto_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  ServiceDescriptorProto_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* MethodDescriptorProto_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  MethodDescriptorProto_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* FileOptions_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  FileOptions_reflection_ = NULL;\nconst ::google::protobuf::EnumDescriptor* FileOptions_OptimizeMode_descriptor_ = NULL;\nconst ::google::protobuf::Descriptor* MessageOptions_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  MessageOptions_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* FieldOptions_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  FieldOptions_reflection_ = NULL;\nconst ::google::protobuf::EnumDescriptor* FieldOptions_CType_descriptor_ = NULL;\nconst ::google::protobuf::EnumDescriptor* FieldOptions_JSType_descriptor_ = NULL;\nconst ::google::protobuf::Descriptor* OneofOptions_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  OneofOptions_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* EnumOptions_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  EnumOptions_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* EnumValueOptions_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  EnumValueOptions_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* ServiceOptions_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  ServiceOptions_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* MethodOptions_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  MethodOptions_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* UninterpretedOption_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  UninterpretedOption_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* UninterpretedOption_NamePart_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  UninterpretedOption_NamePart_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* SourceCodeInfo_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  SourceCodeInfo_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* SourceCodeInfo_Location_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  SourceCodeInfo_Location_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* GeneratedCodeInfo_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  GeneratedCodeInfo_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* GeneratedCodeInfo_Annotation_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  GeneratedCodeInfo_Annotation_reflection_ = NULL;\n\n}  // namespace\n\n\nvoid protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto() {\n  protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  const ::google::protobuf::FileDescriptor* file =\n    ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(\n      \"google/protobuf/descriptor.proto\");\n  GOOGLE_CHECK(file != NULL);\n  FileDescriptorSet_descriptor_ = file->message_type(0);\n  static const int FileDescriptorSet_offsets_[1] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, file_),\n  };\n  FileDescriptorSet_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      FileDescriptorSet_descriptor_,\n      FileDescriptorSet::default_instance_,\n      FileDescriptorSet_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _has_bits_[0]),\n      -1,\n      -1,\n      sizeof(FileDescriptorSet),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorSet, _internal_metadata_),\n      -1);\n  FileDescriptorProto_descriptor_ = file->message_type(1);\n  static const int FileDescriptorProto_offsets_[12] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, name_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, package_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, dependency_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, public_dependency_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, weak_dependency_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, message_type_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, enum_type_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, service_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, extension_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, options_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, source_code_info_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, syntax_),\n  };\n  FileDescriptorProto_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      FileDescriptorProto_descriptor_,\n      FileDescriptorProto::default_instance_,\n      FileDescriptorProto_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _has_bits_[0]),\n      -1,\n      -1,\n      sizeof(FileDescriptorProto),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileDescriptorProto, _internal_metadata_),\n      -1);\n  DescriptorProto_descriptor_ = file->message_type(2);\n  static const int DescriptorProto_offsets_[10] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, name_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, field_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, extension_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, nested_type_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, enum_type_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, extension_range_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, oneof_decl_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, options_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, reserved_range_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, reserved_name_),\n  };\n  DescriptorProto_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      DescriptorProto_descriptor_,\n      DescriptorProto::default_instance_,\n      DescriptorProto_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _has_bits_[0]),\n      -1,\n      -1,\n      sizeof(DescriptorProto),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto, _internal_metadata_),\n      -1);\n  DescriptorProto_ExtensionRange_descriptor_ = DescriptorProto_descriptor_->nested_type(0);\n  static const int DescriptorProto_ExtensionRange_offsets_[2] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, start_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, end_),\n  };\n  DescriptorProto_ExtensionRange_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      DescriptorProto_ExtensionRange_descriptor_,\n      DescriptorProto_ExtensionRange::default_instance_,\n      DescriptorProto_ExtensionRange_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _has_bits_[0]),\n      -1,\n      -1,\n      sizeof(DescriptorProto_ExtensionRange),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ExtensionRange, _internal_metadata_),\n      -1);\n  DescriptorProto_ReservedRange_descriptor_ = DescriptorProto_descriptor_->nested_type(1);\n  static const int DescriptorProto_ReservedRange_offsets_[2] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, start_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, end_),\n  };\n  DescriptorProto_ReservedRange_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      DescriptorProto_ReservedRange_descriptor_,\n      DescriptorProto_ReservedRange::default_instance_,\n      DescriptorProto_ReservedRange_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _has_bits_[0]),\n      -1,\n      -1,\n      sizeof(DescriptorProto_ReservedRange),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DescriptorProto_ReservedRange, _internal_metadata_),\n      -1);\n  FieldDescriptorProto_descriptor_ = file->message_type(3);\n  static const int FieldDescriptorProto_offsets_[10] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, name_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, number_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, label_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, type_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, type_name_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, extendee_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, default_value_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, oneof_index_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, json_name_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, options_),\n  };\n  FieldDescriptorProto_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      FieldDescriptorProto_descriptor_,\n      FieldDescriptorProto::default_instance_,\n      FieldDescriptorProto_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _has_bits_[0]),\n      -1,\n      -1,\n      sizeof(FieldDescriptorProto),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldDescriptorProto, _internal_metadata_),\n      -1);\n  FieldDescriptorProto_Type_descriptor_ = FieldDescriptorProto_descriptor_->enum_type(0);\n  FieldDescriptorProto_Label_descriptor_ = FieldDescriptorProto_descriptor_->enum_type(1);\n  OneofDescriptorProto_descriptor_ = file->message_type(4);\n  static const int OneofDescriptorProto_offsets_[2] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, name_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, options_),\n  };\n  OneofDescriptorProto_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      OneofDescriptorProto_descriptor_,\n      OneofDescriptorProto::default_instance_,\n      OneofDescriptorProto_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _has_bits_[0]),\n      -1,\n      -1,\n      sizeof(OneofDescriptorProto),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofDescriptorProto, _internal_metadata_),\n      -1);\n  EnumDescriptorProto_descriptor_ = file->message_type(5);\n  static const int EnumDescriptorProto_offsets_[3] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, name_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, value_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, options_),\n  };\n  EnumDescriptorProto_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      EnumDescriptorProto_descriptor_,\n      EnumDescriptorProto::default_instance_,\n      EnumDescriptorProto_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _has_bits_[0]),\n      -1,\n      -1,\n      sizeof(EnumDescriptorProto),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumDescriptorProto, _internal_metadata_),\n      -1);\n  EnumValueDescriptorProto_descriptor_ = file->message_type(6);\n  static const int EnumValueDescriptorProto_offsets_[3] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, name_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, number_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, options_),\n  };\n  EnumValueDescriptorProto_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      EnumValueDescriptorProto_descriptor_,\n      EnumValueDescriptorProto::default_instance_,\n      EnumValueDescriptorProto_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _has_bits_[0]),\n      -1,\n      -1,\n      sizeof(EnumValueDescriptorProto),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueDescriptorProto, _internal_metadata_),\n      -1);\n  ServiceDescriptorProto_descriptor_ = file->message_type(7);\n  static const int ServiceDescriptorProto_offsets_[3] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, name_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, method_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, options_),\n  };\n  ServiceDescriptorProto_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      ServiceDescriptorProto_descriptor_,\n      ServiceDescriptorProto::default_instance_,\n      ServiceDescriptorProto_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _has_bits_[0]),\n      -1,\n      -1,\n      sizeof(ServiceDescriptorProto),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceDescriptorProto, _internal_metadata_),\n      -1);\n  MethodDescriptorProto_descriptor_ = file->message_type(8);\n  static const int MethodDescriptorProto_offsets_[6] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, name_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, input_type_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, output_type_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, options_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, client_streaming_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, server_streaming_),\n  };\n  MethodDescriptorProto_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      MethodDescriptorProto_descriptor_,\n      MethodDescriptorProto::default_instance_,\n      MethodDescriptorProto_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _has_bits_[0]),\n      -1,\n      -1,\n      sizeof(MethodDescriptorProto),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodDescriptorProto, _internal_metadata_),\n      -1);\n  FileOptions_descriptor_ = file->message_type(9);\n  static const int FileOptions_offsets_[15] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_package_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_outer_classname_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_multiple_files_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_generate_equals_and_hash_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_string_check_utf8_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, optimize_for_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, go_package_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_generic_services_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, java_generic_services_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, py_generic_services_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, deprecated_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, cc_enable_arenas_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, objc_class_prefix_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, csharp_namespace_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, uninterpreted_option_),\n  };\n  FileOptions_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      FileOptions_descriptor_,\n      FileOptions::default_instance_,\n      FileOptions_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _has_bits_[0]),\n      -1,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _extensions_),\n      sizeof(FileOptions),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FileOptions, _internal_metadata_),\n      -1);\n  FileOptions_OptimizeMode_descriptor_ = FileOptions_descriptor_->enum_type(0);\n  MessageOptions_descriptor_ = file->message_type(10);\n  static const int MessageOptions_offsets_[5] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, message_set_wire_format_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, no_standard_descriptor_accessor_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, deprecated_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, map_entry_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, uninterpreted_option_),\n  };\n  MessageOptions_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      MessageOptions_descriptor_,\n      MessageOptions::default_instance_,\n      MessageOptions_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _has_bits_[0]),\n      -1,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _extensions_),\n      sizeof(MessageOptions),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MessageOptions, _internal_metadata_),\n      -1);\n  FieldOptions_descriptor_ = file->message_type(11);\n  static const int FieldOptions_offsets_[7] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, ctype_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, packed_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, jstype_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, lazy_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, deprecated_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, weak_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, uninterpreted_option_),\n  };\n  FieldOptions_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      FieldOptions_descriptor_,\n      FieldOptions::default_instance_,\n      FieldOptions_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _has_bits_[0]),\n      -1,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _extensions_),\n      sizeof(FieldOptions),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldOptions, _internal_metadata_),\n      -1);\n  FieldOptions_CType_descriptor_ = FieldOptions_descriptor_->enum_type(0);\n  FieldOptions_JSType_descriptor_ = FieldOptions_descriptor_->enum_type(1);\n  OneofOptions_descriptor_ = file->message_type(12);\n  static const int OneofOptions_offsets_[1] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, uninterpreted_option_),\n  };\n  OneofOptions_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      OneofOptions_descriptor_,\n      OneofOptions::default_instance_,\n      OneofOptions_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _has_bits_[0]),\n      -1,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _extensions_),\n      sizeof(OneofOptions),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(OneofOptions, _internal_metadata_),\n      -1);\n  EnumOptions_descriptor_ = file->message_type(13);\n  static const int EnumOptions_offsets_[3] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, allow_alias_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, deprecated_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, uninterpreted_option_),\n  };\n  EnumOptions_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      EnumOptions_descriptor_,\n      EnumOptions::default_instance_,\n      EnumOptions_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _has_bits_[0]),\n      -1,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _extensions_),\n      sizeof(EnumOptions),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumOptions, _internal_metadata_),\n      -1);\n  EnumValueOptions_descriptor_ = file->message_type(14);\n  static const int EnumValueOptions_offsets_[2] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, deprecated_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, uninterpreted_option_),\n  };\n  EnumValueOptions_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      EnumValueOptions_descriptor_,\n      EnumValueOptions::default_instance_,\n      EnumValueOptions_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _has_bits_[0]),\n      -1,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _extensions_),\n      sizeof(EnumValueOptions),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValueOptions, _internal_metadata_),\n      -1);\n  ServiceOptions_descriptor_ = file->message_type(15);\n  static const int ServiceOptions_offsets_[2] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, deprecated_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, uninterpreted_option_),\n  };\n  ServiceOptions_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      ServiceOptions_descriptor_,\n      ServiceOptions::default_instance_,\n      ServiceOptions_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _has_bits_[0]),\n      -1,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _extensions_),\n      sizeof(ServiceOptions),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ServiceOptions, _internal_metadata_),\n      -1);\n  MethodOptions_descriptor_ = file->message_type(16);\n  static const int MethodOptions_offsets_[2] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, deprecated_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, uninterpreted_option_),\n  };\n  MethodOptions_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      MethodOptions_descriptor_,\n      MethodOptions::default_instance_,\n      MethodOptions_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _has_bits_[0]),\n      -1,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _extensions_),\n      sizeof(MethodOptions),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MethodOptions, _internal_metadata_),\n      -1);\n  UninterpretedOption_descriptor_ = file->message_type(17);\n  static const int UninterpretedOption_offsets_[7] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, name_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, identifier_value_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, positive_int_value_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, negative_int_value_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, double_value_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, string_value_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, aggregate_value_),\n  };\n  UninterpretedOption_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      UninterpretedOption_descriptor_,\n      UninterpretedOption::default_instance_,\n      UninterpretedOption_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _has_bits_[0]),\n      -1,\n      -1,\n      sizeof(UninterpretedOption),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption, _internal_metadata_),\n      -1);\n  UninterpretedOption_NamePart_descriptor_ = UninterpretedOption_descriptor_->nested_type(0);\n  static const int UninterpretedOption_NamePart_offsets_[2] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, name_part_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, is_extension_),\n  };\n  UninterpretedOption_NamePart_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      UninterpretedOption_NamePart_descriptor_,\n      UninterpretedOption_NamePart::default_instance_,\n      UninterpretedOption_NamePart_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _has_bits_[0]),\n      -1,\n      -1,\n      sizeof(UninterpretedOption_NamePart),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UninterpretedOption_NamePart, _internal_metadata_),\n      -1);\n  SourceCodeInfo_descriptor_ = file->message_type(18);\n  static const int SourceCodeInfo_offsets_[1] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, location_),\n  };\n  SourceCodeInfo_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      SourceCodeInfo_descriptor_,\n      SourceCodeInfo::default_instance_,\n      SourceCodeInfo_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _has_bits_[0]),\n      -1,\n      -1,\n      sizeof(SourceCodeInfo),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo, _internal_metadata_),\n      -1);\n  SourceCodeInfo_Location_descriptor_ = SourceCodeInfo_descriptor_->nested_type(0);\n  static const int SourceCodeInfo_Location_offsets_[5] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, path_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, span_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, leading_comments_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, trailing_comments_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, leading_detached_comments_),\n  };\n  SourceCodeInfo_Location_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      SourceCodeInfo_Location_descriptor_,\n      SourceCodeInfo_Location::default_instance_,\n      SourceCodeInfo_Location_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _has_bits_[0]),\n      -1,\n      -1,\n      sizeof(SourceCodeInfo_Location),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceCodeInfo_Location, _internal_metadata_),\n      -1);\n  GeneratedCodeInfo_descriptor_ = file->message_type(19);\n  static const int GeneratedCodeInfo_offsets_[1] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, annotation_),\n  };\n  GeneratedCodeInfo_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      GeneratedCodeInfo_descriptor_,\n      GeneratedCodeInfo::default_instance_,\n      GeneratedCodeInfo_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _has_bits_[0]),\n      -1,\n      -1,\n      sizeof(GeneratedCodeInfo),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo, _internal_metadata_),\n      -1);\n  GeneratedCodeInfo_Annotation_descriptor_ = GeneratedCodeInfo_descriptor_->nested_type(0);\n  static const int GeneratedCodeInfo_Annotation_offsets_[4] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, path_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, source_file_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, begin_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, end_),\n  };\n  GeneratedCodeInfo_Annotation_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      GeneratedCodeInfo_Annotation_descriptor_,\n      GeneratedCodeInfo_Annotation::default_instance_,\n      GeneratedCodeInfo_Annotation_offsets_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _has_bits_[0]),\n      -1,\n      -1,\n      sizeof(GeneratedCodeInfo_Annotation),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(GeneratedCodeInfo_Annotation, _internal_metadata_),\n      -1);\n}\n\nnamespace {\n\nGOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);\ninline void protobuf_AssignDescriptorsOnce() {\n  ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,\n                 &protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto);\n}\n\nvoid protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_RegisterTypes(const ::std::string&) {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      FileDescriptorSet_descriptor_, &FileDescriptorSet::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      FileDescriptorProto_descriptor_, &FileDescriptorProto::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      DescriptorProto_descriptor_, &DescriptorProto::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      DescriptorProto_ExtensionRange_descriptor_, &DescriptorProto_ExtensionRange::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      DescriptorProto_ReservedRange_descriptor_, &DescriptorProto_ReservedRange::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      FieldDescriptorProto_descriptor_, &FieldDescriptorProto::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      OneofDescriptorProto_descriptor_, &OneofDescriptorProto::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      EnumDescriptorProto_descriptor_, &EnumDescriptorProto::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      EnumValueDescriptorProto_descriptor_, &EnumValueDescriptorProto::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      ServiceDescriptorProto_descriptor_, &ServiceDescriptorProto::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      MethodDescriptorProto_descriptor_, &MethodDescriptorProto::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      FileOptions_descriptor_, &FileOptions::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      MessageOptions_descriptor_, &MessageOptions::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      FieldOptions_descriptor_, &FieldOptions::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      OneofOptions_descriptor_, &OneofOptions::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      EnumOptions_descriptor_, &EnumOptions::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      EnumValueOptions_descriptor_, &EnumValueOptions::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      ServiceOptions_descriptor_, &ServiceOptions::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      MethodOptions_descriptor_, &MethodOptions::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      UninterpretedOption_descriptor_, &UninterpretedOption::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      UninterpretedOption_NamePart_descriptor_, &UninterpretedOption_NamePart::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      SourceCodeInfo_descriptor_, &SourceCodeInfo::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      SourceCodeInfo_Location_descriptor_, &SourceCodeInfo_Location::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      GeneratedCodeInfo_descriptor_, &GeneratedCodeInfo::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      GeneratedCodeInfo_Annotation_descriptor_, &GeneratedCodeInfo_Annotation::default_instance());\n}\n\n}  // namespace\n\nvoid protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto() {\n  delete FileDescriptorSet::default_instance_;\n  delete FileDescriptorSet_reflection_;\n  delete FileDescriptorProto::default_instance_;\n  delete FileDescriptorProto_reflection_;\n  delete DescriptorProto::default_instance_;\n  delete DescriptorProto_reflection_;\n  delete DescriptorProto_ExtensionRange::default_instance_;\n  delete DescriptorProto_ExtensionRange_reflection_;\n  delete DescriptorProto_ReservedRange::default_instance_;\n  delete DescriptorProto_ReservedRange_reflection_;\n  delete FieldDescriptorProto::default_instance_;\n  delete FieldDescriptorProto_reflection_;\n  delete OneofDescriptorProto::default_instance_;\n  delete OneofDescriptorProto_reflection_;\n  delete EnumDescriptorProto::default_instance_;\n  delete EnumDescriptorProto_reflection_;\n  delete EnumValueDescriptorProto::default_instance_;\n  delete EnumValueDescriptorProto_reflection_;\n  delete ServiceDescriptorProto::default_instance_;\n  delete ServiceDescriptorProto_reflection_;\n  delete MethodDescriptorProto::default_instance_;\n  delete MethodDescriptorProto_reflection_;\n  delete FileOptions::default_instance_;\n  delete FileOptions_reflection_;\n  delete MessageOptions::default_instance_;\n  delete MessageOptions_reflection_;\n  delete FieldOptions::default_instance_;\n  delete FieldOptions_reflection_;\n  delete OneofOptions::default_instance_;\n  delete OneofOptions_reflection_;\n  delete EnumOptions::default_instance_;\n  delete EnumOptions_reflection_;\n  delete EnumValueOptions::default_instance_;\n  delete EnumValueOptions_reflection_;\n  delete ServiceOptions::default_instance_;\n  delete ServiceOptions_reflection_;\n  delete MethodOptions::default_instance_;\n  delete MethodOptions_reflection_;\n  delete UninterpretedOption::default_instance_;\n  delete UninterpretedOption_reflection_;\n  delete UninterpretedOption_NamePart::default_instance_;\n  delete UninterpretedOption_NamePart_reflection_;\n  delete SourceCodeInfo::default_instance_;\n  delete SourceCodeInfo_reflection_;\n  delete SourceCodeInfo_Location::default_instance_;\n  delete SourceCodeInfo_Location_reflection_;\n  delete GeneratedCodeInfo::default_instance_;\n  delete GeneratedCodeInfo_reflection_;\n  delete GeneratedCodeInfo_Annotation::default_instance_;\n  delete GeneratedCodeInfo_Annotation_reflection_;\n}\n\nvoid protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto() {\n  static bool already_here = false;\n  if (already_here) return;\n  already_here = true;\n  GOOGLE_PROTOBUF_VERIFY_VERSION;\n\n  ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(\n    \"\\n google/protobuf/descriptor.proto\\022\\017goog\"\n    \"le.protobuf\\\"G\\n\\021FileDescriptorSet\\0222\\n\\004file\"\n    \"\\030\\001 \\003(\\0132$.google.protobuf.FileDescriptorP\"\n    \"roto\\\"\\333\\003\\n\\023FileDescriptorProto\\022\\014\\n\\004name\\030\\001 \\001\"\n    \"(\\t\\022\\017\\n\\007package\\030\\002 \\001(\\t\\022\\022\\n\\ndependency\\030\\003 \\003(\\t\\022\"\n    \"\\031\\n\\021public_dependency\\030\\n \\003(\\005\\022\\027\\n\\017weak_depen\"\n    \"dency\\030\\013 \\003(\\005\\0226\\n\\014message_type\\030\\004 \\003(\\0132 .goog\"\n    \"le.protobuf.DescriptorProto\\0227\\n\\tenum_type\"\n    \"\\030\\005 \\003(\\0132$.google.protobuf.EnumDescriptorP\"\n    \"roto\\0228\\n\\007service\\030\\006 \\003(\\0132\\'.google.protobuf.\"\n    \"ServiceDescriptorProto\\0228\\n\\textension\\030\\007 \\003(\"\n    \"\\0132%.google.protobuf.FieldDescriptorProto\"\n    \"\\022-\\n\\007options\\030\\010 \\001(\\0132\\034.google.protobuf.File\"\n    \"Options\\0229\\n\\020source_code_info\\030\\t \\001(\\0132\\037.goog\"\n    \"le.protobuf.SourceCodeInfo\\022\\016\\n\\006syntax\\030\\014 \\001\"\n    \"(\\t\\\"\\360\\004\\n\\017DescriptorProto\\022\\014\\n\\004name\\030\\001 \\001(\\t\\0224\\n\\005\"\n    \"field\\030\\002 \\003(\\0132%.google.protobuf.FieldDescr\"\n    \"iptorProto\\0228\\n\\textension\\030\\006 \\003(\\0132%.google.p\"\n    \"rotobuf.FieldDescriptorProto\\0225\\n\\013nested_t\"\n    \"ype\\030\\003 \\003(\\0132 .google.protobuf.DescriptorPr\"\n    \"oto\\0227\\n\\tenum_type\\030\\004 \\003(\\0132$.google.protobuf\"\n    \".EnumDescriptorProto\\022H\\n\\017extension_range\\030\"\n    \"\\005 \\003(\\0132/.google.protobuf.DescriptorProto.\"\n    \"ExtensionRange\\0229\\n\\noneof_decl\\030\\010 \\003(\\0132%.goo\"\n    \"gle.protobuf.OneofDescriptorProto\\0220\\n\\007opt\"\n    \"ions\\030\\007 \\001(\\0132\\037.google.protobuf.MessageOpti\"\n    \"ons\\022F\\n\\016reserved_range\\030\\t \\003(\\0132..google.pro\"\n    \"tobuf.DescriptorProto.ReservedRange\\022\\025\\n\\rr\"\n    \"eserved_name\\030\\n \\003(\\t\\032,\\n\\016ExtensionRange\\022\\r\\n\\005\"\n    \"start\\030\\001 \\001(\\005\\022\\013\\n\\003end\\030\\002 \\001(\\005\\032+\\n\\rReservedRang\"\n    \"e\\022\\r\\n\\005start\\030\\001 \\001(\\005\\022\\013\\n\\003end\\030\\002 \\001(\\005\\\"\\274\\005\\n\\024FieldD\"\n    \"escriptorProto\\022\\014\\n\\004name\\030\\001 \\001(\\t\\022\\016\\n\\006number\\030\\003\"\n    \" \\001(\\005\\022:\\n\\005label\\030\\004 \\001(\\0162+.google.protobuf.Fi\"\n    \"eldDescriptorProto.Label\\0228\\n\\004type\\030\\005 \\001(\\0162*\"\n    \".google.protobuf.FieldDescriptorProto.Ty\"\n    \"pe\\022\\021\\n\\ttype_name\\030\\006 \\001(\\t\\022\\020\\n\\010extendee\\030\\002 \\001(\\t\\022\"\n    \"\\025\\n\\rdefault_value\\030\\007 \\001(\\t\\022\\023\\n\\013oneof_index\\030\\t \"\n    \"\\001(\\005\\022\\021\\n\\tjson_name\\030\\n \\001(\\t\\022.\\n\\007options\\030\\010 \\001(\\0132\"\n    \"\\035.google.protobuf.FieldOptions\\\"\\266\\002\\n\\004Type\\022\"\n    \"\\017\\n\\013TYPE_DOUBLE\\020\\001\\022\\016\\n\\nTYPE_FLOAT\\020\\002\\022\\016\\n\\nTYPE\"\n    \"_INT64\\020\\003\\022\\017\\n\\013TYPE_UINT64\\020\\004\\022\\016\\n\\nTYPE_INT32\\020\"\n    \"\\005\\022\\020\\n\\014TYPE_FIXED64\\020\\006\\022\\020\\n\\014TYPE_FIXED32\\020\\007\\022\\r\\n\"\n    \"\\tTYPE_BOOL\\020\\010\\022\\017\\n\\013TYPE_STRING\\020\\t\\022\\016\\n\\nTYPE_GR\"\n    \"OUP\\020\\n\\022\\020\\n\\014TYPE_MESSAGE\\020\\013\\022\\016\\n\\nTYPE_BYTES\\020\\014\\022\"\n    \"\\017\\n\\013TYPE_UINT32\\020\\r\\022\\r\\n\\tTYPE_ENUM\\020\\016\\022\\021\\n\\rTYPE_\"\n    \"SFIXED32\\020\\017\\022\\021\\n\\rTYPE_SFIXED64\\020\\020\\022\\017\\n\\013TYPE_SI\"\n    \"NT32\\020\\021\\022\\017\\n\\013TYPE_SINT64\\020\\022\\\"C\\n\\005Label\\022\\022\\n\\016LABE\"\n    \"L_OPTIONAL\\020\\001\\022\\022\\n\\016LABEL_REQUIRED\\020\\002\\022\\022\\n\\016LABE\"\n    \"L_REPEATED\\020\\003\\\"T\\n\\024OneofDescriptorProto\\022\\014\\n\\004\"\n    \"name\\030\\001 \\001(\\t\\022.\\n\\007options\\030\\002 \\001(\\0132\\035.google.pro\"\n    \"tobuf.OneofOptions\\\"\\214\\001\\n\\023EnumDescriptorPro\"\n    \"to\\022\\014\\n\\004name\\030\\001 \\001(\\t\\0228\\n\\005value\\030\\002 \\003(\\0132).google\"\n    \".protobuf.EnumValueDescriptorProto\\022-\\n\\007op\"\n    \"tions\\030\\003 \\001(\\0132\\034.google.protobuf.EnumOption\"\n    \"s\\\"l\\n\\030EnumValueDescriptorProto\\022\\014\\n\\004name\\030\\001 \"\n    \"\\001(\\t\\022\\016\\n\\006number\\030\\002 \\001(\\005\\0222\\n\\007options\\030\\003 \\001(\\0132!.g\"\n    \"oogle.protobuf.EnumValueOptions\\\"\\220\\001\\n\\026Serv\"\n    \"iceDescriptorProto\\022\\014\\n\\004name\\030\\001 \\001(\\t\\0226\\n\\006meth\"\n    \"od\\030\\002 \\003(\\0132&.google.protobuf.MethodDescrip\"\n    \"torProto\\0220\\n\\007options\\030\\003 \\001(\\0132\\037.google.proto\"\n    \"buf.ServiceOptions\\\"\\301\\001\\n\\025MethodDescriptorP\"\n    \"roto\\022\\014\\n\\004name\\030\\001 \\001(\\t\\022\\022\\n\\ninput_type\\030\\002 \\001(\\t\\022\\023\"\n    \"\\n\\013output_type\\030\\003 \\001(\\t\\022/\\n\\007options\\030\\004 \\001(\\0132\\036.g\"\n    \"oogle.protobuf.MethodOptions\\022\\037\\n\\020client_s\"\n    \"treaming\\030\\005 \\001(\\010:\\005false\\022\\037\\n\\020server_streamin\"\n    \"g\\030\\006 \\001(\\010:\\005false\\\"\\207\\005\\n\\013FileOptions\\022\\024\\n\\014java_p\"\n    \"ackage\\030\\001 \\001(\\t\\022\\034\\n\\024java_outer_classname\\030\\010 \\001\"\n    \"(\\t\\022\\\"\\n\\023java_multiple_files\\030\\n \\001(\\010:\\005false\\022,\"\n    \"\\n\\035java_generate_equals_and_hash\\030\\024 \\001(\\010:\\005f\"\n    \"alse\\022%\\n\\026java_string_check_utf8\\030\\033 \\001(\\010:\\005fa\"\n    \"lse\\022F\\n\\014optimize_for\\030\\t \\001(\\0162).google.proto\"\n    \"buf.FileOptions.OptimizeMode:\\005SPEED\\022\\022\\n\\ng\"\n    \"o_package\\030\\013 \\001(\\t\\022\\\"\\n\\023cc_generic_services\\030\\020\"\n    \" \\001(\\010:\\005false\\022$\\n\\025java_generic_services\\030\\021 \\001\"\n    \"(\\010:\\005false\\022\\\"\\n\\023py_generic_services\\030\\022 \\001(\\010:\\005\"\n    \"false\\022\\031\\n\\ndeprecated\\030\\027 \\001(\\010:\\005false\\022\\037\\n\\020cc_e\"\n    \"nable_arenas\\030\\037 \\001(\\010:\\005false\\022\\031\\n\\021objc_class_\"\n    \"prefix\\030$ \\001(\\t\\022\\030\\n\\020csharp_namespace\\030% \\001(\\t\\022C\"\n    \"\\n\\024uninterpreted_option\\030\\347\\007 \\003(\\0132$.google.p\"\n    \"rotobuf.UninterpretedOption\\\":\\n\\014OptimizeM\"\n    \"ode\\022\\t\\n\\005SPEED\\020\\001\\022\\r\\n\\tCODE_SIZE\\020\\002\\022\\020\\n\\014LITE_RU\"\n    \"NTIME\\020\\003*\\t\\010\\350\\007\\020\\200\\200\\200\\200\\002J\\004\\010&\\020\\'\\\"\\346\\001\\n\\016MessageOpti\"\n    \"ons\\022&\\n\\027message_set_wire_format\\030\\001 \\001(\\010:\\005fa\"\n    \"lse\\022.\\n\\037no_standard_descriptor_accessor\\030\\002\"\n    \" \\001(\\010:\\005false\\022\\031\\n\\ndeprecated\\030\\003 \\001(\\010:\\005false\\022\\021\"\n    \"\\n\\tmap_entry\\030\\007 \\001(\\010\\022C\\n\\024uninterpreted_optio\"\n    \"n\\030\\347\\007 \\003(\\0132$.google.protobuf.Uninterpreted\"\n    \"Option*\\t\\010\\350\\007\\020\\200\\200\\200\\200\\002\\\"\\230\\003\\n\\014FieldOptions\\022:\\n\\005ct\"\n    \"ype\\030\\001 \\001(\\0162#.google.protobuf.FieldOptions\"\n    \".CType:\\006STRING\\022\\016\\n\\006packed\\030\\002 \\001(\\010\\022\\?\\n\\006jstype\"\n    \"\\030\\006 \\001(\\0162$.google.protobuf.FieldOptions.JS\"\n    \"Type:\\tJS_NORMAL\\022\\023\\n\\004lazy\\030\\005 \\001(\\010:\\005false\\022\\031\\n\\n\"\n    \"deprecated\\030\\003 \\001(\\010:\\005false\\022\\023\\n\\004weak\\030\\n \\001(\\010:\\005f\"\n    \"alse\\022C\\n\\024uninterpreted_option\\030\\347\\007 \\003(\\0132$.go\"\n    \"ogle.protobuf.UninterpretedOption\\\"/\\n\\005CTy\"\n    \"pe\\022\\n\\n\\006STRING\\020\\000\\022\\010\\n\\004CORD\\020\\001\\022\\020\\n\\014STRING_PIECE\"\n    \"\\020\\002\\\"5\\n\\006JSType\\022\\r\\n\\tJS_NORMAL\\020\\000\\022\\r\\n\\tJS_STRING\"\n    \"\\020\\001\\022\\r\\n\\tJS_NUMBER\\020\\002*\\t\\010\\350\\007\\020\\200\\200\\200\\200\\002\\\"^\\n\\014OneofOpt\"\n    \"ions\\022C\\n\\024uninterpreted_option\\030\\347\\007 \\003(\\0132$.go\"\n    \"ogle.protobuf.UninterpretedOption*\\t\\010\\350\\007\\020\\200\"\n    \"\\200\\200\\200\\002\\\"\\215\\001\\n\\013EnumOptions\\022\\023\\n\\013allow_alias\\030\\002 \\001(\"\n    \"\\010\\022\\031\\n\\ndeprecated\\030\\003 \\001(\\010:\\005false\\022C\\n\\024uninterp\"\n    \"reted_option\\030\\347\\007 \\003(\\0132$.google.protobuf.Un\"\n    \"interpretedOption*\\t\\010\\350\\007\\020\\200\\200\\200\\200\\002\\\"}\\n\\020EnumValu\"\n    \"eOptions\\022\\031\\n\\ndeprecated\\030\\001 \\001(\\010:\\005false\\022C\\n\\024u\"\n    \"ninterpreted_option\\030\\347\\007 \\003(\\0132$.google.prot\"\n    \"obuf.UninterpretedOption*\\t\\010\\350\\007\\020\\200\\200\\200\\200\\002\\\"{\\n\\016S\"\n    \"erviceOptions\\022\\031\\n\\ndeprecated\\030! \\001(\\010:\\005false\"\n    \"\\022C\\n\\024uninterpreted_option\\030\\347\\007 \\003(\\0132$.google\"\n    \".protobuf.UninterpretedOption*\\t\\010\\350\\007\\020\\200\\200\\200\\200\\002\"\n    \"\\\"z\\n\\rMethodOptions\\022\\031\\n\\ndeprecated\\030! \\001(\\010:\\005f\"\n    \"alse\\022C\\n\\024uninterpreted_option\\030\\347\\007 \\003(\\0132$.go\"\n    \"ogle.protobuf.UninterpretedOption*\\t\\010\\350\\007\\020\\200\"\n    \"\\200\\200\\200\\002\\\"\\236\\002\\n\\023UninterpretedOption\\022;\\n\\004name\\030\\002 \\003\"\n    \"(\\0132-.google.protobuf.UninterpretedOption\"\n    \".NamePart\\022\\030\\n\\020identifier_value\\030\\003 \\001(\\t\\022\\032\\n\\022p\"\n    \"ositive_int_value\\030\\004 \\001(\\004\\022\\032\\n\\022negative_int_\"\n    \"value\\030\\005 \\001(\\003\\022\\024\\n\\014double_value\\030\\006 \\001(\\001\\022\\024\\n\\014str\"\n    \"ing_value\\030\\007 \\001(\\014\\022\\027\\n\\017aggregate_value\\030\\010 \\001(\\t\"\n    \"\\0323\\n\\010NamePart\\022\\021\\n\\tname_part\\030\\001 \\002(\\t\\022\\024\\n\\014is_ex\"\n    \"tension\\030\\002 \\002(\\010\\\"\\325\\001\\n\\016SourceCodeInfo\\022:\\n\\010loca\"\n    \"tion\\030\\001 \\003(\\0132(.google.protobuf.SourceCodeI\"\n    \"nfo.Location\\032\\206\\001\\n\\010Location\\022\\020\\n\\004path\\030\\001 \\003(\\005B\"\n    \"\\002\\020\\001\\022\\020\\n\\004span\\030\\002 \\003(\\005B\\002\\020\\001\\022\\030\\n\\020leading_comment\"\n    \"s\\030\\003 \\001(\\t\\022\\031\\n\\021trailing_comments\\030\\004 \\001(\\t\\022!\\n\\031le\"\n    \"ading_detached_comments\\030\\006 \\003(\\t\\\"\\247\\001\\n\\021Genera\"\n    \"tedCodeInfo\\022A\\n\\nannotation\\030\\001 \\003(\\0132-.google\"\n    \".protobuf.GeneratedCodeInfo.Annotation\\032O\"\n    \"\\n\\nAnnotation\\022\\020\\n\\004path\\030\\001 \\003(\\005B\\002\\020\\001\\022\\023\\n\\013source\"\n    \"_file\\030\\002 \\001(\\t\\022\\r\\n\\005begin\\030\\003 \\001(\\005\\022\\013\\n\\003end\\030\\004 \\001(\\005B\"\n    \"[\\n\\023com.google.protobufB\\020DescriptorProtos\"\n    \"H\\001Z\\ndescriptor\\240\\001\\001\\242\\002\\003GPB\\252\\002\\032Google.Protobu\"\n    \"f.Reflection\", 5292);\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(\n    \"google/protobuf/descriptor.proto\", &protobuf_RegisterTypes);\n  FileDescriptorSet::default_instance_ = new FileDescriptorSet();\n  FileDescriptorProto::default_instance_ = new FileDescriptorProto();\n  DescriptorProto::default_instance_ = new DescriptorProto();\n  DescriptorProto_ExtensionRange::default_instance_ = new DescriptorProto_ExtensionRange();\n  DescriptorProto_ReservedRange::default_instance_ = new DescriptorProto_ReservedRange();\n  FieldDescriptorProto::default_instance_ = new FieldDescriptorProto();\n  OneofDescriptorProto::default_instance_ = new OneofDescriptorProto();\n  EnumDescriptorProto::default_instance_ = new EnumDescriptorProto();\n  EnumValueDescriptorProto::default_instance_ = new EnumValueDescriptorProto();\n  ServiceDescriptorProto::default_instance_ = new ServiceDescriptorProto();\n  MethodDescriptorProto::default_instance_ = new MethodDescriptorProto();\n  FileOptions::default_instance_ = new FileOptions();\n  MessageOptions::default_instance_ = new MessageOptions();\n  FieldOptions::default_instance_ = new FieldOptions();\n  OneofOptions::default_instance_ = new OneofOptions();\n  EnumOptions::default_instance_ = new EnumOptions();\n  EnumValueOptions::default_instance_ = new EnumValueOptions();\n  ServiceOptions::default_instance_ = new ServiceOptions();\n  MethodOptions::default_instance_ = new MethodOptions();\n  UninterpretedOption::default_instance_ = new UninterpretedOption();\n  UninterpretedOption_NamePart::default_instance_ = new UninterpretedOption_NamePart();\n  SourceCodeInfo::default_instance_ = new SourceCodeInfo();\n  SourceCodeInfo_Location::default_instance_ = new SourceCodeInfo_Location();\n  GeneratedCodeInfo::default_instance_ = new GeneratedCodeInfo();\n  GeneratedCodeInfo_Annotation::default_instance_ = new GeneratedCodeInfo_Annotation();\n  FileDescriptorSet::default_instance_->InitAsDefaultInstance();\n  FileDescriptorProto::default_instance_->InitAsDefaultInstance();\n  DescriptorProto::default_instance_->InitAsDefaultInstance();\n  DescriptorProto_ExtensionRange::default_instance_->InitAsDefaultInstance();\n  DescriptorProto_ReservedRange::default_instance_->InitAsDefaultInstance();\n  FieldDescriptorProto::default_instance_->InitAsDefaultInstance();\n  OneofDescriptorProto::default_instance_->InitAsDefaultInstance();\n  EnumDescriptorProto::default_instance_->InitAsDefaultInstance();\n  EnumValueDescriptorProto::default_instance_->InitAsDefaultInstance();\n  ServiceDescriptorProto::default_instance_->InitAsDefaultInstance();\n  MethodDescriptorProto::default_instance_->InitAsDefaultInstance();\n  FileOptions::default_instance_->InitAsDefaultInstance();\n  MessageOptions::default_instance_->InitAsDefaultInstance();\n  FieldOptions::default_instance_->InitAsDefaultInstance();\n  OneofOptions::default_instance_->InitAsDefaultInstance();\n  EnumOptions::default_instance_->InitAsDefaultInstance();\n  EnumValueOptions::default_instance_->InitAsDefaultInstance();\n  ServiceOptions::default_instance_->InitAsDefaultInstance();\n  MethodOptions::default_instance_->InitAsDefaultInstance();\n  UninterpretedOption::default_instance_->InitAsDefaultInstance();\n  UninterpretedOption_NamePart::default_instance_->InitAsDefaultInstance();\n  SourceCodeInfo::default_instance_->InitAsDefaultInstance();\n  SourceCodeInfo_Location::default_instance_->InitAsDefaultInstance();\n  GeneratedCodeInfo::default_instance_->InitAsDefaultInstance();\n  GeneratedCodeInfo_Annotation::default_instance_->InitAsDefaultInstance();\n  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto);\n}\n\n// Force AddDescriptors() to be called at static initialization time.\nstruct StaticDescriptorInitializer_google_2fprotobuf_2fdescriptor_2eproto {\n  StaticDescriptorInitializer_google_2fprotobuf_2fdescriptor_2eproto() {\n    protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  }\n} static_descriptor_initializer_google_2fprotobuf_2fdescriptor_2eproto_;\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int FileDescriptorSet::kFileFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nFileDescriptorSet::FileDescriptorSet()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.FileDescriptorSet)\n}\n\nvoid FileDescriptorSet::InitAsDefaultInstance() {\n}\n\nFileDescriptorSet::FileDescriptorSet(const FileDescriptorSet& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.FileDescriptorSet)\n}\n\nvoid FileDescriptorSet::SharedCtor() {\n  _cached_size_ = 0;\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nFileDescriptorSet::~FileDescriptorSet() {\n  // @@protoc_insertion_point(destructor:google.protobuf.FileDescriptorSet)\n  SharedDtor();\n}\n\nvoid FileDescriptorSet::SharedDtor() {\n  if (this != default_instance_) {\n  }\n}\n\nvoid FileDescriptorSet::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* FileDescriptorSet::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return FileDescriptorSet_descriptor_;\n}\n\nconst FileDescriptorSet& FileDescriptorSet::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nFileDescriptorSet* FileDescriptorSet::default_instance_ = NULL;\n\nFileDescriptorSet* FileDescriptorSet::New(::google::protobuf::Arena* arena) const {\n  FileDescriptorSet* n = new FileDescriptorSet;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid FileDescriptorSet::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.FileDescriptorSet)\n  file_.Clear();\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool FileDescriptorSet::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.FileDescriptorSet)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // repeated .google.protobuf.FileDescriptorProto file = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_file:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_file()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(10)) goto parse_loop_file;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.FileDescriptorSet)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.FileDescriptorSet)\n  return false;\n#undef DO_\n}\n\nvoid FileDescriptorSet::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.FileDescriptorSet)\n  // repeated .google.protobuf.FileDescriptorProto file = 1;\n  for (unsigned int i = 0, n = this->file_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      1, this->file(i), output);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.FileDescriptorSet)\n}\n\n::google::protobuf::uint8* FileDescriptorSet::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FileDescriptorSet)\n  // repeated .google.protobuf.FileDescriptorProto file = 1;\n  for (unsigned int i = 0, n = this->file_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        1, this->file(i), false, target);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FileDescriptorSet)\n  return target;\n}\n\nint FileDescriptorSet::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileDescriptorSet)\n  int total_size = 0;\n\n  // repeated .google.protobuf.FileDescriptorProto file = 1;\n  total_size += 1 * this->file_size();\n  for (int i = 0; i < this->file_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->file(i));\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid FileDescriptorSet::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FileDescriptorSet)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const FileDescriptorSet* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const FileDescriptorSet>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.FileDescriptorSet)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FileDescriptorSet)\n    MergeFrom(*source);\n  }\n}\n\nvoid FileDescriptorSet::MergeFrom(const FileDescriptorSet& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorSet)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  file_.MergeFrom(from.file_);\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid FileDescriptorSet::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.FileDescriptorSet)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid FileDescriptorSet::CopyFrom(const FileDescriptorSet& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FileDescriptorSet)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool FileDescriptorSet::IsInitialized() const {\n\n  if (!::google::protobuf::internal::AllAreInitialized(this->file())) return false;\n  return true;\n}\n\nvoid FileDescriptorSet::Swap(FileDescriptorSet* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid FileDescriptorSet::InternalSwap(FileDescriptorSet* other) {\n  file_.UnsafeArenaSwap(&other->file_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata FileDescriptorSet::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = FileDescriptorSet_descriptor_;\n  metadata.reflection = FileDescriptorSet_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// FileDescriptorSet\n\n// repeated .google.protobuf.FileDescriptorProto file = 1;\nint FileDescriptorSet::file_size() const {\n  return file_.size();\n}\nvoid FileDescriptorSet::clear_file() {\n  file_.Clear();\n}\nconst ::google::protobuf::FileDescriptorProto& FileDescriptorSet::file(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorSet.file)\n  return file_.Get(index);\n}\n::google::protobuf::FileDescriptorProto* FileDescriptorSet::mutable_file(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorSet.file)\n  return file_.Mutable(index);\n}\n::google::protobuf::FileDescriptorProto* FileDescriptorSet::add_file() {\n  // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorSet.file)\n  return file_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >*\nFileDescriptorSet::mutable_file() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorSet.file)\n  return &file_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >&\nFileDescriptorSet::file() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorSet.file)\n  return file_;\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int FileDescriptorProto::kNameFieldNumber;\nconst int FileDescriptorProto::kPackageFieldNumber;\nconst int FileDescriptorProto::kDependencyFieldNumber;\nconst int FileDescriptorProto::kPublicDependencyFieldNumber;\nconst int FileDescriptorProto::kWeakDependencyFieldNumber;\nconst int FileDescriptorProto::kMessageTypeFieldNumber;\nconst int FileDescriptorProto::kEnumTypeFieldNumber;\nconst int FileDescriptorProto::kServiceFieldNumber;\nconst int FileDescriptorProto::kExtensionFieldNumber;\nconst int FileDescriptorProto::kOptionsFieldNumber;\nconst int FileDescriptorProto::kSourceCodeInfoFieldNumber;\nconst int FileDescriptorProto::kSyntaxFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nFileDescriptorProto::FileDescriptorProto()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.FileDescriptorProto)\n}\n\nvoid FileDescriptorProto::InitAsDefaultInstance() {\n  options_ = const_cast< ::google::protobuf::FileOptions*>(&::google::protobuf::FileOptions::default_instance());\n  source_code_info_ = const_cast< ::google::protobuf::SourceCodeInfo*>(&::google::protobuf::SourceCodeInfo::default_instance());\n}\n\nFileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.FileDescriptorProto)\n}\n\nvoid FileDescriptorProto::SharedCtor() {\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  options_ = NULL;\n  source_code_info_ = NULL;\n  syntax_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nFileDescriptorProto::~FileDescriptorProto() {\n  // @@protoc_insertion_point(destructor:google.protobuf.FileDescriptorProto)\n  SharedDtor();\n}\n\nvoid FileDescriptorProto::SharedDtor() {\n  name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  syntax_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n    delete options_;\n    delete source_code_info_;\n  }\n}\n\nvoid FileDescriptorProto::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* FileDescriptorProto::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return FileDescriptorProto_descriptor_;\n}\n\nconst FileDescriptorProto& FileDescriptorProto::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nFileDescriptorProto* FileDescriptorProto::default_instance_ = NULL;\n\nFileDescriptorProto* FileDescriptorProto::New(::google::protobuf::Arena* arena) const {\n  FileDescriptorProto* n = new FileDescriptorProto;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid FileDescriptorProto::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.FileDescriptorProto)\n  if (_has_bits_[0 / 32] & 3u) {\n    if (has_name()) {\n      name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    if (has_package()) {\n      package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n  }\n  if (_has_bits_[8 / 32] & 3584u) {\n    if (has_options()) {\n      if (options_ != NULL) options_->::google::protobuf::FileOptions::Clear();\n    }\n    if (has_source_code_info()) {\n      if (source_code_info_ != NULL) source_code_info_->::google::protobuf::SourceCodeInfo::Clear();\n    }\n    if (has_syntax()) {\n      syntax_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n  }\n  dependency_.Clear();\n  public_dependency_.Clear();\n  weak_dependency_.Clear();\n  message_type_.Clear();\n  enum_type_.Clear();\n  service_.Clear();\n  extension_.Clear();\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool FileDescriptorProto::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.FileDescriptorProto)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional string name = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_name()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->name().data(), this->name().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.FileDescriptorProto.name\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_package;\n        break;\n      }\n\n      // optional string package = 2;\n      case 2: {\n        if (tag == 18) {\n         parse_package:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_package()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->package().data(), this->package().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.FileDescriptorProto.package\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(26)) goto parse_dependency;\n        break;\n      }\n\n      // repeated string dependency = 3;\n      case 3: {\n        if (tag == 26) {\n         parse_dependency:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->add_dependency()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->dependency(this->dependency_size() - 1).data(),\n            this->dependency(this->dependency_size() - 1).length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.FileDescriptorProto.dependency\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(26)) goto parse_dependency;\n        if (input->ExpectTag(34)) goto parse_message_type;\n        break;\n      }\n\n      // repeated .google.protobuf.DescriptorProto message_type = 4;\n      case 4: {\n        if (tag == 34) {\n         parse_message_type:\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_message_type:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_message_type()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(34)) goto parse_loop_message_type;\n        if (input->ExpectTag(42)) goto parse_loop_enum_type;\n        input->UnsafeDecrementRecursionDepth();\n        break;\n      }\n\n      // repeated .google.protobuf.EnumDescriptorProto enum_type = 5;\n      case 5: {\n        if (tag == 42) {\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_enum_type:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_enum_type()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(42)) goto parse_loop_enum_type;\n        if (input->ExpectTag(50)) goto parse_loop_service;\n        input->UnsafeDecrementRecursionDepth();\n        break;\n      }\n\n      // repeated .google.protobuf.ServiceDescriptorProto service = 6;\n      case 6: {\n        if (tag == 50) {\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_service:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_service()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(50)) goto parse_loop_service;\n        if (input->ExpectTag(58)) goto parse_loop_extension;\n        input->UnsafeDecrementRecursionDepth();\n        break;\n      }\n\n      // repeated .google.protobuf.FieldDescriptorProto extension = 7;\n      case 7: {\n        if (tag == 58) {\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_extension:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_extension()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(58)) goto parse_loop_extension;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectTag(66)) goto parse_options;\n        break;\n      }\n\n      // optional .google.protobuf.FileOptions options = 8;\n      case 8: {\n        if (tag == 66) {\n         parse_options:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\n               input, mutable_options()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(74)) goto parse_source_code_info;\n        break;\n      }\n\n      // optional .google.protobuf.SourceCodeInfo source_code_info = 9;\n      case 9: {\n        if (tag == 74) {\n         parse_source_code_info:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\n               input, mutable_source_code_info()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(80)) goto parse_public_dependency;\n        break;\n      }\n\n      // repeated int32 public_dependency = 10;\n      case 10: {\n        if (tag == 80) {\n         parse_public_dependency:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 1, 80, input, this->mutable_public_dependency())));\n        } else if (tag == 82) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 input, this->mutable_public_dependency())));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(80)) goto parse_public_dependency;\n        if (input->ExpectTag(88)) goto parse_weak_dependency;\n        break;\n      }\n\n      // repeated int32 weak_dependency = 11;\n      case 11: {\n        if (tag == 88) {\n         parse_weak_dependency:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitive<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 1, 88, input, this->mutable_weak_dependency())));\n        } else if (tag == 90) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 input, this->mutable_weak_dependency())));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(88)) goto parse_weak_dependency;\n        if (input->ExpectTag(98)) goto parse_syntax;\n        break;\n      }\n\n      // optional string syntax = 12;\n      case 12: {\n        if (tag == 98) {\n         parse_syntax:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_syntax()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->syntax().data(), this->syntax().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.FileDescriptorProto.syntax\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.FileDescriptorProto)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.FileDescriptorProto)\n  return false;\n#undef DO_\n}\n\nvoid FileDescriptorProto::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.FileDescriptorProto)\n  // optional string name = 1;\n  if (has_name()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FileDescriptorProto.name\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      1, this->name(), output);\n  }\n\n  // optional string package = 2;\n  if (has_package()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->package().data(), this->package().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FileDescriptorProto.package\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      2, this->package(), output);\n  }\n\n  // repeated string dependency = 3;\n  for (int i = 0; i < this->dependency_size(); i++) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->dependency(i).data(), this->dependency(i).length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FileDescriptorProto.dependency\");\n    ::google::protobuf::internal::WireFormatLite::WriteString(\n      3, this->dependency(i), output);\n  }\n\n  // repeated .google.protobuf.DescriptorProto message_type = 4;\n  for (unsigned int i = 0, n = this->message_type_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      4, this->message_type(i), output);\n  }\n\n  // repeated .google.protobuf.EnumDescriptorProto enum_type = 5;\n  for (unsigned int i = 0, n = this->enum_type_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      5, this->enum_type(i), output);\n  }\n\n  // repeated .google.protobuf.ServiceDescriptorProto service = 6;\n  for (unsigned int i = 0, n = this->service_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      6, this->service(i), output);\n  }\n\n  // repeated .google.protobuf.FieldDescriptorProto extension = 7;\n  for (unsigned int i = 0, n = this->extension_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      7, this->extension(i), output);\n  }\n\n  // optional .google.protobuf.FileOptions options = 8;\n  if (has_options()) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      8, *this->options_, output);\n  }\n\n  // optional .google.protobuf.SourceCodeInfo source_code_info = 9;\n  if (has_source_code_info()) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      9, *this->source_code_info_, output);\n  }\n\n  // repeated int32 public_dependency = 10;\n  for (int i = 0; i < this->public_dependency_size(); i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt32(\n      10, this->public_dependency(i), output);\n  }\n\n  // repeated int32 weak_dependency = 11;\n  for (int i = 0; i < this->weak_dependency_size(); i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt32(\n      11, this->weak_dependency(i), output);\n  }\n\n  // optional string syntax = 12;\n  if (has_syntax()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->syntax().data(), this->syntax().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FileDescriptorProto.syntax\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      12, this->syntax(), output);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.FileDescriptorProto)\n}\n\n::google::protobuf::uint8* FileDescriptorProto::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FileDescriptorProto)\n  // optional string name = 1;\n  if (has_name()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FileDescriptorProto.name\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        1, this->name(), target);\n  }\n\n  // optional string package = 2;\n  if (has_package()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->package().data(), this->package().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FileDescriptorProto.package\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        2, this->package(), target);\n  }\n\n  // repeated string dependency = 3;\n  for (int i = 0; i < this->dependency_size(); i++) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->dependency(i).data(), this->dependency(i).length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FileDescriptorProto.dependency\");\n    target = ::google::protobuf::internal::WireFormatLite::\n      WriteStringToArray(3, this->dependency(i), target);\n  }\n\n  // repeated .google.protobuf.DescriptorProto message_type = 4;\n  for (unsigned int i = 0, n = this->message_type_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        4, this->message_type(i), false, target);\n  }\n\n  // repeated .google.protobuf.EnumDescriptorProto enum_type = 5;\n  for (unsigned int i = 0, n = this->enum_type_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        5, this->enum_type(i), false, target);\n  }\n\n  // repeated .google.protobuf.ServiceDescriptorProto service = 6;\n  for (unsigned int i = 0, n = this->service_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        6, this->service(i), false, target);\n  }\n\n  // repeated .google.protobuf.FieldDescriptorProto extension = 7;\n  for (unsigned int i = 0, n = this->extension_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        7, this->extension(i), false, target);\n  }\n\n  // optional .google.protobuf.FileOptions options = 8;\n  if (has_options()) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        8, *this->options_, false, target);\n  }\n\n  // optional .google.protobuf.SourceCodeInfo source_code_info = 9;\n  if (has_source_code_info()) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        9, *this->source_code_info_, false, target);\n  }\n\n  // repeated int32 public_dependency = 10;\n  for (int i = 0; i < this->public_dependency_size(); i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      WriteInt32ToArray(10, this->public_dependency(i), target);\n  }\n\n  // repeated int32 weak_dependency = 11;\n  for (int i = 0; i < this->weak_dependency_size(); i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      WriteInt32ToArray(11, this->weak_dependency(i), target);\n  }\n\n  // optional string syntax = 12;\n  if (has_syntax()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->syntax().data(), this->syntax().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FileDescriptorProto.syntax\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        12, this->syntax(), target);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FileDescriptorProto)\n  return target;\n}\n\nint FileDescriptorProto::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileDescriptorProto)\n  int total_size = 0;\n\n  if (_has_bits_[0 / 32] & 3u) {\n    // optional string name = 1;\n    if (has_name()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->name());\n    }\n\n    // optional string package = 2;\n    if (has_package()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->package());\n    }\n\n  }\n  if (_has_bits_[9 / 32] & 3584u) {\n    // optional .google.protobuf.FileOptions options = 8;\n    if (has_options()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n          *this->options_);\n    }\n\n    // optional .google.protobuf.SourceCodeInfo source_code_info = 9;\n    if (has_source_code_info()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n          *this->source_code_info_);\n    }\n\n    // optional string syntax = 12;\n    if (has_syntax()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->syntax());\n    }\n\n  }\n  // repeated string dependency = 3;\n  total_size += 1 * this->dependency_size();\n  for (int i = 0; i < this->dependency_size(); i++) {\n    total_size += ::google::protobuf::internal::WireFormatLite::StringSize(\n      this->dependency(i));\n  }\n\n  // repeated int32 public_dependency = 10;\n  {\n    int data_size = 0;\n    for (int i = 0; i < this->public_dependency_size(); i++) {\n      data_size += ::google::protobuf::internal::WireFormatLite::\n        Int32Size(this->public_dependency(i));\n    }\n    total_size += 1 * this->public_dependency_size() + data_size;\n  }\n\n  // repeated int32 weak_dependency = 11;\n  {\n    int data_size = 0;\n    for (int i = 0; i < this->weak_dependency_size(); i++) {\n      data_size += ::google::protobuf::internal::WireFormatLite::\n        Int32Size(this->weak_dependency(i));\n    }\n    total_size += 1 * this->weak_dependency_size() + data_size;\n  }\n\n  // repeated .google.protobuf.DescriptorProto message_type = 4;\n  total_size += 1 * this->message_type_size();\n  for (int i = 0; i < this->message_type_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->message_type(i));\n  }\n\n  // repeated .google.protobuf.EnumDescriptorProto enum_type = 5;\n  total_size += 1 * this->enum_type_size();\n  for (int i = 0; i < this->enum_type_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->enum_type(i));\n  }\n\n  // repeated .google.protobuf.ServiceDescriptorProto service = 6;\n  total_size += 1 * this->service_size();\n  for (int i = 0; i < this->service_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->service(i));\n  }\n\n  // repeated .google.protobuf.FieldDescriptorProto extension = 7;\n  total_size += 1 * this->extension_size();\n  for (int i = 0; i < this->extension_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->extension(i));\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid FileDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FileDescriptorProto)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const FileDescriptorProto* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const FileDescriptorProto>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.FileDescriptorProto)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FileDescriptorProto)\n    MergeFrom(*source);\n  }\n}\n\nvoid FileDescriptorProto::MergeFrom(const FileDescriptorProto& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileDescriptorProto)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  dependency_.MergeFrom(from.dependency_);\n  public_dependency_.MergeFrom(from.public_dependency_);\n  weak_dependency_.MergeFrom(from.weak_dependency_);\n  message_type_.MergeFrom(from.message_type_);\n  enum_type_.MergeFrom(from.enum_type_);\n  service_.MergeFrom(from.service_);\n  extension_.MergeFrom(from.extension_);\n  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {\n    if (from.has_name()) {\n      set_has_name();\n      name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);\n    }\n    if (from.has_package()) {\n      set_has_package();\n      package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.package_);\n    }\n  }\n  if (from._has_bits_[9 / 32] & (0xffu << (9 % 32))) {\n    if (from.has_options()) {\n      mutable_options()->::google::protobuf::FileOptions::MergeFrom(from.options());\n    }\n    if (from.has_source_code_info()) {\n      mutable_source_code_info()->::google::protobuf::SourceCodeInfo::MergeFrom(from.source_code_info());\n    }\n    if (from.has_syntax()) {\n      set_has_syntax();\n      syntax_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.syntax_);\n    }\n  }\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid FileDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.FileDescriptorProto)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid FileDescriptorProto::CopyFrom(const FileDescriptorProto& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FileDescriptorProto)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool FileDescriptorProto::IsInitialized() const {\n\n  if (!::google::protobuf::internal::AllAreInitialized(this->message_type())) return false;\n  if (!::google::protobuf::internal::AllAreInitialized(this->enum_type())) return false;\n  if (!::google::protobuf::internal::AllAreInitialized(this->service())) return false;\n  if (!::google::protobuf::internal::AllAreInitialized(this->extension())) return false;\n  if (has_options()) {\n    if (!this->options_->IsInitialized()) return false;\n  }\n  return true;\n}\n\nvoid FileDescriptorProto::Swap(FileDescriptorProto* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid FileDescriptorProto::InternalSwap(FileDescriptorProto* other) {\n  name_.Swap(&other->name_);\n  package_.Swap(&other->package_);\n  dependency_.UnsafeArenaSwap(&other->dependency_);\n  public_dependency_.UnsafeArenaSwap(&other->public_dependency_);\n  weak_dependency_.UnsafeArenaSwap(&other->weak_dependency_);\n  message_type_.UnsafeArenaSwap(&other->message_type_);\n  enum_type_.UnsafeArenaSwap(&other->enum_type_);\n  service_.UnsafeArenaSwap(&other->service_);\n  extension_.UnsafeArenaSwap(&other->extension_);\n  std::swap(options_, other->options_);\n  std::swap(source_code_info_, other->source_code_info_);\n  syntax_.Swap(&other->syntax_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata FileDescriptorProto::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = FileDescriptorProto_descriptor_;\n  metadata.reflection = FileDescriptorProto_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// FileDescriptorProto\n\n// optional string name = 1;\nbool FileDescriptorProto::has_name() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\nvoid FileDescriptorProto::set_has_name() {\n  _has_bits_[0] |= 0x00000001u;\n}\nvoid FileDescriptorProto::clear_has_name() {\n  _has_bits_[0] &= ~0x00000001u;\n}\nvoid FileDescriptorProto::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_name();\n}\n const ::std::string& FileDescriptorProto::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FileDescriptorProto::set_name(const ::std::string& value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.name)\n}\n void FileDescriptorProto::set_name(const char* value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.name)\n}\n void FileDescriptorProto::set_name(const char* value, size_t size) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.name)\n}\n ::std::string* FileDescriptorProto::mutable_name() {\n  set_has_name();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* FileDescriptorProto::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.name)\n  clear_has_name();\n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FileDescriptorProto::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    set_has_name();\n  } else {\n    clear_has_name();\n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.name)\n}\n\n// optional string package = 2;\nbool FileDescriptorProto::has_package() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\nvoid FileDescriptorProto::set_has_package() {\n  _has_bits_[0] |= 0x00000002u;\n}\nvoid FileDescriptorProto::clear_has_package() {\n  _has_bits_[0] &= ~0x00000002u;\n}\nvoid FileDescriptorProto::clear_package() {\n  package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_package();\n}\n const ::std::string& FileDescriptorProto::package() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.package)\n  return package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FileDescriptorProto::set_package(const ::std::string& value) {\n  set_has_package();\n  package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.package)\n}\n void FileDescriptorProto::set_package(const char* value) {\n  set_has_package();\n  package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.package)\n}\n void FileDescriptorProto::set_package(const char* value, size_t size) {\n  set_has_package();\n  package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.package)\n}\n ::std::string* FileDescriptorProto::mutable_package() {\n  set_has_package();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.package)\n  return package_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* FileDescriptorProto::release_package() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.package)\n  clear_has_package();\n  return package_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FileDescriptorProto::set_allocated_package(::std::string* package) {\n  if (package != NULL) {\n    set_has_package();\n  } else {\n    clear_has_package();\n  }\n  package_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), package);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.package)\n}\n\n// repeated string dependency = 3;\nint FileDescriptorProto::dependency_size() const {\n  return dependency_.size();\n}\nvoid FileDescriptorProto::clear_dependency() {\n  dependency_.Clear();\n}\n const ::std::string& FileDescriptorProto::dependency(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.dependency)\n  return dependency_.Get(index);\n}\n ::std::string* FileDescriptorProto::mutable_dependency(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.dependency)\n  return dependency_.Mutable(index);\n}\n void FileDescriptorProto::set_dependency(int index, const ::std::string& value) {\n  // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency)\n  dependency_.Mutable(index)->assign(value);\n}\n void FileDescriptorProto::set_dependency(int index, const char* value) {\n  dependency_.Mutable(index)->assign(value);\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.dependency)\n}\n void FileDescriptorProto::set_dependency(int index, const char* value, size_t size) {\n  dependency_.Mutable(index)->assign(\n    reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.dependency)\n}\n ::std::string* FileDescriptorProto::add_dependency() {\n  // @@protoc_insertion_point(field_add_mutable:google.protobuf.FileDescriptorProto.dependency)\n  return dependency_.Add();\n}\n void FileDescriptorProto::add_dependency(const ::std::string& value) {\n  dependency_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency)\n}\n void FileDescriptorProto::add_dependency(const char* value) {\n  dependency_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add_char:google.protobuf.FileDescriptorProto.dependency)\n}\n void FileDescriptorProto::add_dependency(const char* value, size_t size) {\n  dependency_.Add()->assign(reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_add_pointer:google.protobuf.FileDescriptorProto.dependency)\n}\n const ::google::protobuf::RepeatedPtrField< ::std::string>&\nFileDescriptorProto::dependency() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.dependency)\n  return dependency_;\n}\n ::google::protobuf::RepeatedPtrField< ::std::string>*\nFileDescriptorProto::mutable_dependency() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.dependency)\n  return &dependency_;\n}\n\n// repeated int32 public_dependency = 10;\nint FileDescriptorProto::public_dependency_size() const {\n  return public_dependency_.size();\n}\nvoid FileDescriptorProto::clear_public_dependency() {\n  public_dependency_.Clear();\n}\n ::google::protobuf::int32 FileDescriptorProto::public_dependency(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.public_dependency)\n  return public_dependency_.Get(index);\n}\n void FileDescriptorProto::set_public_dependency(int index, ::google::protobuf::int32 value) {\n  public_dependency_.Set(index, value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.public_dependency)\n}\n void FileDescriptorProto::add_public_dependency(::google::protobuf::int32 value) {\n  public_dependency_.Add(value);\n  // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.public_dependency)\n}\n const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&\nFileDescriptorProto::public_dependency() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.public_dependency)\n  return public_dependency_;\n}\n ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*\nFileDescriptorProto::mutable_public_dependency() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.public_dependency)\n  return &public_dependency_;\n}\n\n// repeated int32 weak_dependency = 11;\nint FileDescriptorProto::weak_dependency_size() const {\n  return weak_dependency_.size();\n}\nvoid FileDescriptorProto::clear_weak_dependency() {\n  weak_dependency_.Clear();\n}\n ::google::protobuf::int32 FileDescriptorProto::weak_dependency(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.weak_dependency)\n  return weak_dependency_.Get(index);\n}\n void FileDescriptorProto::set_weak_dependency(int index, ::google::protobuf::int32 value) {\n  weak_dependency_.Set(index, value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.weak_dependency)\n}\n void FileDescriptorProto::add_weak_dependency(::google::protobuf::int32 value) {\n  weak_dependency_.Add(value);\n  // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.weak_dependency)\n}\n const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&\nFileDescriptorProto::weak_dependency() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.weak_dependency)\n  return weak_dependency_;\n}\n ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*\nFileDescriptorProto::mutable_weak_dependency() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.weak_dependency)\n  return &weak_dependency_;\n}\n\n// repeated .google.protobuf.DescriptorProto message_type = 4;\nint FileDescriptorProto::message_type_size() const {\n  return message_type_.size();\n}\nvoid FileDescriptorProto::clear_message_type() {\n  message_type_.Clear();\n}\nconst ::google::protobuf::DescriptorProto& FileDescriptorProto::message_type(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.message_type)\n  return message_type_.Get(index);\n}\n::google::protobuf::DescriptorProto* FileDescriptorProto::mutable_message_type(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.message_type)\n  return message_type_.Mutable(index);\n}\n::google::protobuf::DescriptorProto* FileDescriptorProto::add_message_type() {\n  // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.message_type)\n  return message_type_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >*\nFileDescriptorProto::mutable_message_type() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.message_type)\n  return &message_type_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >&\nFileDescriptorProto::message_type() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.message_type)\n  return message_type_;\n}\n\n// repeated .google.protobuf.EnumDescriptorProto enum_type = 5;\nint FileDescriptorProto::enum_type_size() const {\n  return enum_type_.size();\n}\nvoid FileDescriptorProto::clear_enum_type() {\n  enum_type_.Clear();\n}\nconst ::google::protobuf::EnumDescriptorProto& FileDescriptorProto::enum_type(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.enum_type)\n  return enum_type_.Get(index);\n}\n::google::protobuf::EnumDescriptorProto* FileDescriptorProto::mutable_enum_type(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.enum_type)\n  return enum_type_.Mutable(index);\n}\n::google::protobuf::EnumDescriptorProto* FileDescriptorProto::add_enum_type() {\n  // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.enum_type)\n  return enum_type_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >*\nFileDescriptorProto::mutable_enum_type() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.enum_type)\n  return &enum_type_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >&\nFileDescriptorProto::enum_type() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.enum_type)\n  return enum_type_;\n}\n\n// repeated .google.protobuf.ServiceDescriptorProto service = 6;\nint FileDescriptorProto::service_size() const {\n  return service_.size();\n}\nvoid FileDescriptorProto::clear_service() {\n  service_.Clear();\n}\nconst ::google::protobuf::ServiceDescriptorProto& FileDescriptorProto::service(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.service)\n  return service_.Get(index);\n}\n::google::protobuf::ServiceDescriptorProto* FileDescriptorProto::mutable_service(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.service)\n  return service_.Mutable(index);\n}\n::google::protobuf::ServiceDescriptorProto* FileDescriptorProto::add_service() {\n  // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.service)\n  return service_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto >*\nFileDescriptorProto::mutable_service() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.service)\n  return &service_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto >&\nFileDescriptorProto::service() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.service)\n  return service_;\n}\n\n// repeated .google.protobuf.FieldDescriptorProto extension = 7;\nint FileDescriptorProto::extension_size() const {\n  return extension_.size();\n}\nvoid FileDescriptorProto::clear_extension() {\n  extension_.Clear();\n}\nconst ::google::protobuf::FieldDescriptorProto& FileDescriptorProto::extension(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.extension)\n  return extension_.Get(index);\n}\n::google::protobuf::FieldDescriptorProto* FileDescriptorProto::mutable_extension(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.extension)\n  return extension_.Mutable(index);\n}\n::google::protobuf::FieldDescriptorProto* FileDescriptorProto::add_extension() {\n  // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.extension)\n  return extension_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >*\nFileDescriptorProto::mutable_extension() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.extension)\n  return &extension_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >&\nFileDescriptorProto::extension() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.extension)\n  return extension_;\n}\n\n// optional .google.protobuf.FileOptions options = 8;\nbool FileDescriptorProto::has_options() const {\n  return (_has_bits_[0] & 0x00000200u) != 0;\n}\nvoid FileDescriptorProto::set_has_options() {\n  _has_bits_[0] |= 0x00000200u;\n}\nvoid FileDescriptorProto::clear_has_options() {\n  _has_bits_[0] &= ~0x00000200u;\n}\nvoid FileDescriptorProto::clear_options() {\n  if (options_ != NULL) options_->::google::protobuf::FileOptions::Clear();\n  clear_has_options();\n}\nconst ::google::protobuf::FileOptions& FileDescriptorProto::options() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.options)\n  return options_ != NULL ? *options_ : *default_instance_->options_;\n}\n::google::protobuf::FileOptions* FileDescriptorProto::mutable_options() {\n  set_has_options();\n  if (options_ == NULL) {\n    options_ = new ::google::protobuf::FileOptions;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.options)\n  return options_;\n}\n::google::protobuf::FileOptions* FileDescriptorProto::release_options() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.options)\n  clear_has_options();\n  ::google::protobuf::FileOptions* temp = options_;\n  options_ = NULL;\n  return temp;\n}\nvoid FileDescriptorProto::set_allocated_options(::google::protobuf::FileOptions* options) {\n  delete options_;\n  options_ = options;\n  if (options) {\n    set_has_options();\n  } else {\n    clear_has_options();\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.options)\n}\n\n// optional .google.protobuf.SourceCodeInfo source_code_info = 9;\nbool FileDescriptorProto::has_source_code_info() const {\n  return (_has_bits_[0] & 0x00000400u) != 0;\n}\nvoid FileDescriptorProto::set_has_source_code_info() {\n  _has_bits_[0] |= 0x00000400u;\n}\nvoid FileDescriptorProto::clear_has_source_code_info() {\n  _has_bits_[0] &= ~0x00000400u;\n}\nvoid FileDescriptorProto::clear_source_code_info() {\n  if (source_code_info_ != NULL) source_code_info_->::google::protobuf::SourceCodeInfo::Clear();\n  clear_has_source_code_info();\n}\nconst ::google::protobuf::SourceCodeInfo& FileDescriptorProto::source_code_info() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.source_code_info)\n  return source_code_info_ != NULL ? *source_code_info_ : *default_instance_->source_code_info_;\n}\n::google::protobuf::SourceCodeInfo* FileDescriptorProto::mutable_source_code_info() {\n  set_has_source_code_info();\n  if (source_code_info_ == NULL) {\n    source_code_info_ = new ::google::protobuf::SourceCodeInfo;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.source_code_info)\n  return source_code_info_;\n}\n::google::protobuf::SourceCodeInfo* FileDescriptorProto::release_source_code_info() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.source_code_info)\n  clear_has_source_code_info();\n  ::google::protobuf::SourceCodeInfo* temp = source_code_info_;\n  source_code_info_ = NULL;\n  return temp;\n}\nvoid FileDescriptorProto::set_allocated_source_code_info(::google::protobuf::SourceCodeInfo* source_code_info) {\n  delete source_code_info_;\n  source_code_info_ = source_code_info;\n  if (source_code_info) {\n    set_has_source_code_info();\n  } else {\n    clear_has_source_code_info();\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.source_code_info)\n}\n\n// optional string syntax = 12;\nbool FileDescriptorProto::has_syntax() const {\n  return (_has_bits_[0] & 0x00000800u) != 0;\n}\nvoid FileDescriptorProto::set_has_syntax() {\n  _has_bits_[0] |= 0x00000800u;\n}\nvoid FileDescriptorProto::clear_has_syntax() {\n  _has_bits_[0] &= ~0x00000800u;\n}\nvoid FileDescriptorProto::clear_syntax() {\n  syntax_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_syntax();\n}\n const ::std::string& FileDescriptorProto::syntax() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.syntax)\n  return syntax_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FileDescriptorProto::set_syntax(const ::std::string& value) {\n  set_has_syntax();\n  syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.syntax)\n}\n void FileDescriptorProto::set_syntax(const char* value) {\n  set_has_syntax();\n  syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.syntax)\n}\n void FileDescriptorProto::set_syntax(const char* value, size_t size) {\n  set_has_syntax();\n  syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.syntax)\n}\n ::std::string* FileDescriptorProto::mutable_syntax() {\n  set_has_syntax();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.syntax)\n  return syntax_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* FileDescriptorProto::release_syntax() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.syntax)\n  clear_has_syntax();\n  return syntax_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FileDescriptorProto::set_allocated_syntax(::std::string* syntax) {\n  if (syntax != NULL) {\n    set_has_syntax();\n  } else {\n    clear_has_syntax();\n  }\n  syntax_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), syntax);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.syntax)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int DescriptorProto_ExtensionRange::kStartFieldNumber;\nconst int DescriptorProto_ExtensionRange::kEndFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nDescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto.ExtensionRange)\n}\n\nvoid DescriptorProto_ExtensionRange::InitAsDefaultInstance() {\n}\n\nDescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(const DescriptorProto_ExtensionRange& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto.ExtensionRange)\n}\n\nvoid DescriptorProto_ExtensionRange::SharedCtor() {\n  _cached_size_ = 0;\n  start_ = 0;\n  end_ = 0;\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nDescriptorProto_ExtensionRange::~DescriptorProto_ExtensionRange() {\n  // @@protoc_insertion_point(destructor:google.protobuf.DescriptorProto.ExtensionRange)\n  SharedDtor();\n}\n\nvoid DescriptorProto_ExtensionRange::SharedDtor() {\n  if (this != default_instance_) {\n  }\n}\n\nvoid DescriptorProto_ExtensionRange::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* DescriptorProto_ExtensionRange::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return DescriptorProto_ExtensionRange_descriptor_;\n}\n\nconst DescriptorProto_ExtensionRange& DescriptorProto_ExtensionRange::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nDescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::default_instance_ = NULL;\n\nDescriptorProto_ExtensionRange* DescriptorProto_ExtensionRange::New(::google::protobuf::Arena* arena) const {\n  DescriptorProto_ExtensionRange* n = new DescriptorProto_ExtensionRange;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid DescriptorProto_ExtensionRange::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto.ExtensionRange)\n#if defined(__clang__)\n#define ZR_HELPER_(f) \\\n  _Pragma(\"clang diagnostic push\") \\\n  _Pragma(\"clang diagnostic ignored \\\"-Winvalid-offsetof\\\"\") \\\n  __builtin_offsetof(DescriptorProto_ExtensionRange, f) \\\n  _Pragma(\"clang diagnostic pop\")\n#else\n#define ZR_HELPER_(f) reinterpret_cast<char*>(\\\n  &reinterpret_cast<DescriptorProto_ExtensionRange*>(16)->f)\n#endif\n\n#define ZR_(first, last) do {\\\n  ::memset(&first, 0,\\\n           ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\\\n} while (0)\n\n  ZR_(start_, end_);\n\n#undef ZR_HELPER_\n#undef ZR_\n\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool DescriptorProto_ExtensionRange::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.DescriptorProto.ExtensionRange)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional int32 start = 1;\n      case 1: {\n        if (tag == 8) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 input, &start_)));\n          set_has_start();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(16)) goto parse_end;\n        break;\n      }\n\n      // optional int32 end = 2;\n      case 2: {\n        if (tag == 16) {\n         parse_end:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 input, &end_)));\n          set_has_end();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.DescriptorProto.ExtensionRange)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.DescriptorProto.ExtensionRange)\n  return false;\n#undef DO_\n}\n\nvoid DescriptorProto_ExtensionRange::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.DescriptorProto.ExtensionRange)\n  // optional int32 start = 1;\n  if (has_start()) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->start(), output);\n  }\n\n  // optional int32 end = 2;\n  if (has_end()) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->end(), output);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.DescriptorProto.ExtensionRange)\n}\n\n::google::protobuf::uint8* DescriptorProto_ExtensionRange::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DescriptorProto.ExtensionRange)\n  // optional int32 start = 1;\n  if (has_start()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->start(), target);\n  }\n\n  // optional int32 end = 2;\n  if (has_end()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->end(), target);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.DescriptorProto.ExtensionRange)\n  return target;\n}\n\nint DescriptorProto_ExtensionRange::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto.ExtensionRange)\n  int total_size = 0;\n\n  if (_has_bits_[0 / 32] & 3u) {\n    // optional int32 start = 1;\n    if (has_start()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::Int32Size(\n          this->start());\n    }\n\n    // optional int32 end = 2;\n    if (has_end()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::Int32Size(\n          this->end());\n    }\n\n  }\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid DescriptorProto_ExtensionRange::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DescriptorProto.ExtensionRange)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const DescriptorProto_ExtensionRange* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const DescriptorProto_ExtensionRange>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.DescriptorProto.ExtensionRange)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DescriptorProto.ExtensionRange)\n    MergeFrom(*source);\n  }\n}\n\nvoid DescriptorProto_ExtensionRange::MergeFrom(const DescriptorProto_ExtensionRange& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ExtensionRange)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {\n    if (from.has_start()) {\n      set_start(from.start());\n    }\n    if (from.has_end()) {\n      set_end(from.end());\n    }\n  }\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid DescriptorProto_ExtensionRange::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.DescriptorProto.ExtensionRange)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid DescriptorProto_ExtensionRange::CopyFrom(const DescriptorProto_ExtensionRange& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DescriptorProto.ExtensionRange)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool DescriptorProto_ExtensionRange::IsInitialized() const {\n\n  return true;\n}\n\nvoid DescriptorProto_ExtensionRange::Swap(DescriptorProto_ExtensionRange* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid DescriptorProto_ExtensionRange::InternalSwap(DescriptorProto_ExtensionRange* other) {\n  std::swap(start_, other->start_);\n  std::swap(end_, other->end_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata DescriptorProto_ExtensionRange::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = DescriptorProto_ExtensionRange_descriptor_;\n  metadata.reflection = DescriptorProto_ExtensionRange_reflection_;\n  return metadata;\n}\n\n\n// -------------------------------------------------------------------\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int DescriptorProto_ReservedRange::kStartFieldNumber;\nconst int DescriptorProto_ReservedRange::kEndFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nDescriptorProto_ReservedRange::DescriptorProto_ReservedRange()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto.ReservedRange)\n}\n\nvoid DescriptorProto_ReservedRange::InitAsDefaultInstance() {\n}\n\nDescriptorProto_ReservedRange::DescriptorProto_ReservedRange(const DescriptorProto_ReservedRange& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto.ReservedRange)\n}\n\nvoid DescriptorProto_ReservedRange::SharedCtor() {\n  _cached_size_ = 0;\n  start_ = 0;\n  end_ = 0;\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nDescriptorProto_ReservedRange::~DescriptorProto_ReservedRange() {\n  // @@protoc_insertion_point(destructor:google.protobuf.DescriptorProto.ReservedRange)\n  SharedDtor();\n}\n\nvoid DescriptorProto_ReservedRange::SharedDtor() {\n  if (this != default_instance_) {\n  }\n}\n\nvoid DescriptorProto_ReservedRange::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* DescriptorProto_ReservedRange::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return DescriptorProto_ReservedRange_descriptor_;\n}\n\nconst DescriptorProto_ReservedRange& DescriptorProto_ReservedRange::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nDescriptorProto_ReservedRange* DescriptorProto_ReservedRange::default_instance_ = NULL;\n\nDescriptorProto_ReservedRange* DescriptorProto_ReservedRange::New(::google::protobuf::Arena* arena) const {\n  DescriptorProto_ReservedRange* n = new DescriptorProto_ReservedRange;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid DescriptorProto_ReservedRange::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto.ReservedRange)\n#if defined(__clang__)\n#define ZR_HELPER_(f) \\\n  _Pragma(\"clang diagnostic push\") \\\n  _Pragma(\"clang diagnostic ignored \\\"-Winvalid-offsetof\\\"\") \\\n  __builtin_offsetof(DescriptorProto_ReservedRange, f) \\\n  _Pragma(\"clang diagnostic pop\")\n#else\n#define ZR_HELPER_(f) reinterpret_cast<char*>(\\\n  &reinterpret_cast<DescriptorProto_ReservedRange*>(16)->f)\n#endif\n\n#define ZR_(first, last) do {\\\n  ::memset(&first, 0,\\\n           ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\\\n} while (0)\n\n  ZR_(start_, end_);\n\n#undef ZR_HELPER_\n#undef ZR_\n\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool DescriptorProto_ReservedRange::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.DescriptorProto.ReservedRange)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional int32 start = 1;\n      case 1: {\n        if (tag == 8) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 input, &start_)));\n          set_has_start();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(16)) goto parse_end;\n        break;\n      }\n\n      // optional int32 end = 2;\n      case 2: {\n        if (tag == 16) {\n         parse_end:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 input, &end_)));\n          set_has_end();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.DescriptorProto.ReservedRange)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.DescriptorProto.ReservedRange)\n  return false;\n#undef DO_\n}\n\nvoid DescriptorProto_ReservedRange::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.DescriptorProto.ReservedRange)\n  // optional int32 start = 1;\n  if (has_start()) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->start(), output);\n  }\n\n  // optional int32 end = 2;\n  if (has_end()) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->end(), output);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.DescriptorProto.ReservedRange)\n}\n\n::google::protobuf::uint8* DescriptorProto_ReservedRange::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DescriptorProto.ReservedRange)\n  // optional int32 start = 1;\n  if (has_start()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->start(), target);\n  }\n\n  // optional int32 end = 2;\n  if (has_end()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->end(), target);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.DescriptorProto.ReservedRange)\n  return target;\n}\n\nint DescriptorProto_ReservedRange::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto.ReservedRange)\n  int total_size = 0;\n\n  if (_has_bits_[0 / 32] & 3u) {\n    // optional int32 start = 1;\n    if (has_start()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::Int32Size(\n          this->start());\n    }\n\n    // optional int32 end = 2;\n    if (has_end()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::Int32Size(\n          this->end());\n    }\n\n  }\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid DescriptorProto_ReservedRange::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DescriptorProto.ReservedRange)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const DescriptorProto_ReservedRange* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const DescriptorProto_ReservedRange>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.DescriptorProto.ReservedRange)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DescriptorProto.ReservedRange)\n    MergeFrom(*source);\n  }\n}\n\nvoid DescriptorProto_ReservedRange::MergeFrom(const DescriptorProto_ReservedRange& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto.ReservedRange)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {\n    if (from.has_start()) {\n      set_start(from.start());\n    }\n    if (from.has_end()) {\n      set_end(from.end());\n    }\n  }\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid DescriptorProto_ReservedRange::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.DescriptorProto.ReservedRange)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid DescriptorProto_ReservedRange::CopyFrom(const DescriptorProto_ReservedRange& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DescriptorProto.ReservedRange)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool DescriptorProto_ReservedRange::IsInitialized() const {\n\n  return true;\n}\n\nvoid DescriptorProto_ReservedRange::Swap(DescriptorProto_ReservedRange* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid DescriptorProto_ReservedRange::InternalSwap(DescriptorProto_ReservedRange* other) {\n  std::swap(start_, other->start_);\n  std::swap(end_, other->end_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata DescriptorProto_ReservedRange::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = DescriptorProto_ReservedRange_descriptor_;\n  metadata.reflection = DescriptorProto_ReservedRange_reflection_;\n  return metadata;\n}\n\n\n// -------------------------------------------------------------------\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int DescriptorProto::kNameFieldNumber;\nconst int DescriptorProto::kFieldFieldNumber;\nconst int DescriptorProto::kExtensionFieldNumber;\nconst int DescriptorProto::kNestedTypeFieldNumber;\nconst int DescriptorProto::kEnumTypeFieldNumber;\nconst int DescriptorProto::kExtensionRangeFieldNumber;\nconst int DescriptorProto::kOneofDeclFieldNumber;\nconst int DescriptorProto::kOptionsFieldNumber;\nconst int DescriptorProto::kReservedRangeFieldNumber;\nconst int DescriptorProto::kReservedNameFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nDescriptorProto::DescriptorProto()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.DescriptorProto)\n}\n\nvoid DescriptorProto::InitAsDefaultInstance() {\n  options_ = const_cast< ::google::protobuf::MessageOptions*>(&::google::protobuf::MessageOptions::default_instance());\n}\n\nDescriptorProto::DescriptorProto(const DescriptorProto& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.DescriptorProto)\n}\n\nvoid DescriptorProto::SharedCtor() {\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  options_ = NULL;\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nDescriptorProto::~DescriptorProto() {\n  // @@protoc_insertion_point(destructor:google.protobuf.DescriptorProto)\n  SharedDtor();\n}\n\nvoid DescriptorProto::SharedDtor() {\n  name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n    delete options_;\n  }\n}\n\nvoid DescriptorProto::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* DescriptorProto::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return DescriptorProto_descriptor_;\n}\n\nconst DescriptorProto& DescriptorProto::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nDescriptorProto* DescriptorProto::default_instance_ = NULL;\n\nDescriptorProto* DescriptorProto::New(::google::protobuf::Arena* arena) const {\n  DescriptorProto* n = new DescriptorProto;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid DescriptorProto::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.DescriptorProto)\n  if (_has_bits_[0 / 32] & 129u) {\n    if (has_name()) {\n      name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    if (has_options()) {\n      if (options_ != NULL) options_->::google::protobuf::MessageOptions::Clear();\n    }\n  }\n  field_.Clear();\n  extension_.Clear();\n  nested_type_.Clear();\n  enum_type_.Clear();\n  extension_range_.Clear();\n  oneof_decl_.Clear();\n  reserved_range_.Clear();\n  reserved_name_.Clear();\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool DescriptorProto::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.DescriptorProto)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional string name = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_name()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->name().data(), this->name().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.DescriptorProto.name\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_field;\n        break;\n      }\n\n      // repeated .google.protobuf.FieldDescriptorProto field = 2;\n      case 2: {\n        if (tag == 18) {\n         parse_field:\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_field:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_field()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_loop_field;\n        if (input->ExpectTag(26)) goto parse_loop_nested_type;\n        input->UnsafeDecrementRecursionDepth();\n        break;\n      }\n\n      // repeated .google.protobuf.DescriptorProto nested_type = 3;\n      case 3: {\n        if (tag == 26) {\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_nested_type:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_nested_type()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(26)) goto parse_loop_nested_type;\n        if (input->ExpectTag(34)) goto parse_loop_enum_type;\n        input->UnsafeDecrementRecursionDepth();\n        break;\n      }\n\n      // repeated .google.protobuf.EnumDescriptorProto enum_type = 4;\n      case 4: {\n        if (tag == 34) {\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_enum_type:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_enum_type()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(34)) goto parse_loop_enum_type;\n        if (input->ExpectTag(42)) goto parse_loop_extension_range;\n        input->UnsafeDecrementRecursionDepth();\n        break;\n      }\n\n      // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;\n      case 5: {\n        if (tag == 42) {\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_extension_range:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_extension_range()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(42)) goto parse_loop_extension_range;\n        if (input->ExpectTag(50)) goto parse_loop_extension;\n        input->UnsafeDecrementRecursionDepth();\n        break;\n      }\n\n      // repeated .google.protobuf.FieldDescriptorProto extension = 6;\n      case 6: {\n        if (tag == 50) {\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_extension:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_extension()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(50)) goto parse_loop_extension;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectTag(58)) goto parse_options;\n        break;\n      }\n\n      // optional .google.protobuf.MessageOptions options = 7;\n      case 7: {\n        if (tag == 58) {\n         parse_options:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\n               input, mutable_options()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(66)) goto parse_oneof_decl;\n        break;\n      }\n\n      // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;\n      case 8: {\n        if (tag == 66) {\n         parse_oneof_decl:\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_oneof_decl:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_oneof_decl()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(66)) goto parse_loop_oneof_decl;\n        if (input->ExpectTag(74)) goto parse_loop_reserved_range;\n        input->UnsafeDecrementRecursionDepth();\n        break;\n      }\n\n      // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;\n      case 9: {\n        if (tag == 74) {\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_reserved_range:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_reserved_range()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(74)) goto parse_loop_reserved_range;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectTag(82)) goto parse_reserved_name;\n        break;\n      }\n\n      // repeated string reserved_name = 10;\n      case 10: {\n        if (tag == 82) {\n         parse_reserved_name:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->add_reserved_name()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->reserved_name(this->reserved_name_size() - 1).data(),\n            this->reserved_name(this->reserved_name_size() - 1).length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.DescriptorProto.reserved_name\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(82)) goto parse_reserved_name;\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.DescriptorProto)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.DescriptorProto)\n  return false;\n#undef DO_\n}\n\nvoid DescriptorProto::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.DescriptorProto)\n  // optional string name = 1;\n  if (has_name()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.DescriptorProto.name\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      1, this->name(), output);\n  }\n\n  // repeated .google.protobuf.FieldDescriptorProto field = 2;\n  for (unsigned int i = 0, n = this->field_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      2, this->field(i), output);\n  }\n\n  // repeated .google.protobuf.DescriptorProto nested_type = 3;\n  for (unsigned int i = 0, n = this->nested_type_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      3, this->nested_type(i), output);\n  }\n\n  // repeated .google.protobuf.EnumDescriptorProto enum_type = 4;\n  for (unsigned int i = 0, n = this->enum_type_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      4, this->enum_type(i), output);\n  }\n\n  // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;\n  for (unsigned int i = 0, n = this->extension_range_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      5, this->extension_range(i), output);\n  }\n\n  // repeated .google.protobuf.FieldDescriptorProto extension = 6;\n  for (unsigned int i = 0, n = this->extension_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      6, this->extension(i), output);\n  }\n\n  // optional .google.protobuf.MessageOptions options = 7;\n  if (has_options()) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      7, *this->options_, output);\n  }\n\n  // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;\n  for (unsigned int i = 0, n = this->oneof_decl_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      8, this->oneof_decl(i), output);\n  }\n\n  // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;\n  for (unsigned int i = 0, n = this->reserved_range_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      9, this->reserved_range(i), output);\n  }\n\n  // repeated string reserved_name = 10;\n  for (int i = 0; i < this->reserved_name_size(); i++) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->reserved_name(i).data(), this->reserved_name(i).length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.DescriptorProto.reserved_name\");\n    ::google::protobuf::internal::WireFormatLite::WriteString(\n      10, this->reserved_name(i), output);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.DescriptorProto)\n}\n\n::google::protobuf::uint8* DescriptorProto::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DescriptorProto)\n  // optional string name = 1;\n  if (has_name()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.DescriptorProto.name\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        1, this->name(), target);\n  }\n\n  // repeated .google.protobuf.FieldDescriptorProto field = 2;\n  for (unsigned int i = 0, n = this->field_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        2, this->field(i), false, target);\n  }\n\n  // repeated .google.protobuf.DescriptorProto nested_type = 3;\n  for (unsigned int i = 0, n = this->nested_type_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        3, this->nested_type(i), false, target);\n  }\n\n  // repeated .google.protobuf.EnumDescriptorProto enum_type = 4;\n  for (unsigned int i = 0, n = this->enum_type_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        4, this->enum_type(i), false, target);\n  }\n\n  // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;\n  for (unsigned int i = 0, n = this->extension_range_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        5, this->extension_range(i), false, target);\n  }\n\n  // repeated .google.protobuf.FieldDescriptorProto extension = 6;\n  for (unsigned int i = 0, n = this->extension_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        6, this->extension(i), false, target);\n  }\n\n  // optional .google.protobuf.MessageOptions options = 7;\n  if (has_options()) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        7, *this->options_, false, target);\n  }\n\n  // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;\n  for (unsigned int i = 0, n = this->oneof_decl_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        8, this->oneof_decl(i), false, target);\n  }\n\n  // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;\n  for (unsigned int i = 0, n = this->reserved_range_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        9, this->reserved_range(i), false, target);\n  }\n\n  // repeated string reserved_name = 10;\n  for (int i = 0; i < this->reserved_name_size(); i++) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->reserved_name(i).data(), this->reserved_name(i).length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.DescriptorProto.reserved_name\");\n    target = ::google::protobuf::internal::WireFormatLite::\n      WriteStringToArray(10, this->reserved_name(i), target);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.DescriptorProto)\n  return target;\n}\n\nint DescriptorProto::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.DescriptorProto)\n  int total_size = 0;\n\n  if (_has_bits_[0 / 32] & 129u) {\n    // optional string name = 1;\n    if (has_name()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->name());\n    }\n\n    // optional .google.protobuf.MessageOptions options = 7;\n    if (has_options()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n          *this->options_);\n    }\n\n  }\n  // repeated .google.protobuf.FieldDescriptorProto field = 2;\n  total_size += 1 * this->field_size();\n  for (int i = 0; i < this->field_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->field(i));\n  }\n\n  // repeated .google.protobuf.FieldDescriptorProto extension = 6;\n  total_size += 1 * this->extension_size();\n  for (int i = 0; i < this->extension_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->extension(i));\n  }\n\n  // repeated .google.protobuf.DescriptorProto nested_type = 3;\n  total_size += 1 * this->nested_type_size();\n  for (int i = 0; i < this->nested_type_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->nested_type(i));\n  }\n\n  // repeated .google.protobuf.EnumDescriptorProto enum_type = 4;\n  total_size += 1 * this->enum_type_size();\n  for (int i = 0; i < this->enum_type_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->enum_type(i));\n  }\n\n  // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;\n  total_size += 1 * this->extension_range_size();\n  for (int i = 0; i < this->extension_range_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->extension_range(i));\n  }\n\n  // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;\n  total_size += 1 * this->oneof_decl_size();\n  for (int i = 0; i < this->oneof_decl_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->oneof_decl(i));\n  }\n\n  // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;\n  total_size += 1 * this->reserved_range_size();\n  for (int i = 0; i < this->reserved_range_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->reserved_range(i));\n  }\n\n  // repeated string reserved_name = 10;\n  total_size += 1 * this->reserved_name_size();\n  for (int i = 0; i < this->reserved_name_size(); i++) {\n    total_size += ::google::protobuf::internal::WireFormatLite::StringSize(\n      this->reserved_name(i));\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid DescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DescriptorProto)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const DescriptorProto* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const DescriptorProto>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.DescriptorProto)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DescriptorProto)\n    MergeFrom(*source);\n  }\n}\n\nvoid DescriptorProto::MergeFrom(const DescriptorProto& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DescriptorProto)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  field_.MergeFrom(from.field_);\n  extension_.MergeFrom(from.extension_);\n  nested_type_.MergeFrom(from.nested_type_);\n  enum_type_.MergeFrom(from.enum_type_);\n  extension_range_.MergeFrom(from.extension_range_);\n  oneof_decl_.MergeFrom(from.oneof_decl_);\n  reserved_range_.MergeFrom(from.reserved_range_);\n  reserved_name_.MergeFrom(from.reserved_name_);\n  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {\n    if (from.has_name()) {\n      set_has_name();\n      name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);\n    }\n    if (from.has_options()) {\n      mutable_options()->::google::protobuf::MessageOptions::MergeFrom(from.options());\n    }\n  }\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid DescriptorProto::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.DescriptorProto)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid DescriptorProto::CopyFrom(const DescriptorProto& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DescriptorProto)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool DescriptorProto::IsInitialized() const {\n\n  if (!::google::protobuf::internal::AllAreInitialized(this->field())) return false;\n  if (!::google::protobuf::internal::AllAreInitialized(this->extension())) return false;\n  if (!::google::protobuf::internal::AllAreInitialized(this->nested_type())) return false;\n  if (!::google::protobuf::internal::AllAreInitialized(this->enum_type())) return false;\n  if (!::google::protobuf::internal::AllAreInitialized(this->oneof_decl())) return false;\n  if (has_options()) {\n    if (!this->options_->IsInitialized()) return false;\n  }\n  return true;\n}\n\nvoid DescriptorProto::Swap(DescriptorProto* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid DescriptorProto::InternalSwap(DescriptorProto* other) {\n  name_.Swap(&other->name_);\n  field_.UnsafeArenaSwap(&other->field_);\n  extension_.UnsafeArenaSwap(&other->extension_);\n  nested_type_.UnsafeArenaSwap(&other->nested_type_);\n  enum_type_.UnsafeArenaSwap(&other->enum_type_);\n  extension_range_.UnsafeArenaSwap(&other->extension_range_);\n  oneof_decl_.UnsafeArenaSwap(&other->oneof_decl_);\n  std::swap(options_, other->options_);\n  reserved_range_.UnsafeArenaSwap(&other->reserved_range_);\n  reserved_name_.UnsafeArenaSwap(&other->reserved_name_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata DescriptorProto::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = DescriptorProto_descriptor_;\n  metadata.reflection = DescriptorProto_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// DescriptorProto_ExtensionRange\n\n// optional int32 start = 1;\nbool DescriptorProto_ExtensionRange::has_start() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\nvoid DescriptorProto_ExtensionRange::set_has_start() {\n  _has_bits_[0] |= 0x00000001u;\n}\nvoid DescriptorProto_ExtensionRange::clear_has_start() {\n  _has_bits_[0] &= ~0x00000001u;\n}\nvoid DescriptorProto_ExtensionRange::clear_start() {\n  start_ = 0;\n  clear_has_start();\n}\n ::google::protobuf::int32 DescriptorProto_ExtensionRange::start() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.start)\n  return start_;\n}\n void DescriptorProto_ExtensionRange::set_start(::google::protobuf::int32 value) {\n  set_has_start();\n  start_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.start)\n}\n\n// optional int32 end = 2;\nbool DescriptorProto_ExtensionRange::has_end() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\nvoid DescriptorProto_ExtensionRange::set_has_end() {\n  _has_bits_[0] |= 0x00000002u;\n}\nvoid DescriptorProto_ExtensionRange::clear_has_end() {\n  _has_bits_[0] &= ~0x00000002u;\n}\nvoid DescriptorProto_ExtensionRange::clear_end() {\n  end_ = 0;\n  clear_has_end();\n}\n ::google::protobuf::int32 DescriptorProto_ExtensionRange::end() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.end)\n  return end_;\n}\n void DescriptorProto_ExtensionRange::set_end(::google::protobuf::int32 value) {\n  set_has_end();\n  end_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.end)\n}\n\n// -------------------------------------------------------------------\n\n// DescriptorProto_ReservedRange\n\n// optional int32 start = 1;\nbool DescriptorProto_ReservedRange::has_start() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\nvoid DescriptorProto_ReservedRange::set_has_start() {\n  _has_bits_[0] |= 0x00000001u;\n}\nvoid DescriptorProto_ReservedRange::clear_has_start() {\n  _has_bits_[0] &= ~0x00000001u;\n}\nvoid DescriptorProto_ReservedRange::clear_start() {\n  start_ = 0;\n  clear_has_start();\n}\n ::google::protobuf::int32 DescriptorProto_ReservedRange::start() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.start)\n  return start_;\n}\n void DescriptorProto_ReservedRange::set_start(::google::protobuf::int32 value) {\n  set_has_start();\n  start_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.start)\n}\n\n// optional int32 end = 2;\nbool DescriptorProto_ReservedRange::has_end() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\nvoid DescriptorProto_ReservedRange::set_has_end() {\n  _has_bits_[0] |= 0x00000002u;\n}\nvoid DescriptorProto_ReservedRange::clear_has_end() {\n  _has_bits_[0] &= ~0x00000002u;\n}\nvoid DescriptorProto_ReservedRange::clear_end() {\n  end_ = 0;\n  clear_has_end();\n}\n ::google::protobuf::int32 DescriptorProto_ReservedRange::end() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.end)\n  return end_;\n}\n void DescriptorProto_ReservedRange::set_end(::google::protobuf::int32 value) {\n  set_has_end();\n  end_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.end)\n}\n\n// -------------------------------------------------------------------\n\n// DescriptorProto\n\n// optional string name = 1;\nbool DescriptorProto::has_name() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\nvoid DescriptorProto::set_has_name() {\n  _has_bits_[0] |= 0x00000001u;\n}\nvoid DescriptorProto::clear_has_name() {\n  _has_bits_[0] &= ~0x00000001u;\n}\nvoid DescriptorProto::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_name();\n}\n const ::std::string& DescriptorProto::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void DescriptorProto::set_name(const ::std::string& value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.name)\n}\n void DescriptorProto::set_name(const char* value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.DescriptorProto.name)\n}\n void DescriptorProto::set_name(const char* value, size_t size) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.DescriptorProto.name)\n}\n ::std::string* DescriptorProto::mutable_name() {\n  set_has_name();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* DescriptorProto::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.name)\n  clear_has_name();\n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void DescriptorProto::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    set_has_name();\n  } else {\n    clear_has_name();\n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.DescriptorProto.name)\n}\n\n// repeated .google.protobuf.FieldDescriptorProto field = 2;\nint DescriptorProto::field_size() const {\n  return field_.size();\n}\nvoid DescriptorProto::clear_field() {\n  field_.Clear();\n}\nconst ::google::protobuf::FieldDescriptorProto& DescriptorProto::field(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.field)\n  return field_.Get(index);\n}\n::google::protobuf::FieldDescriptorProto* DescriptorProto::mutable_field(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.field)\n  return field_.Mutable(index);\n}\n::google::protobuf::FieldDescriptorProto* DescriptorProto::add_field() {\n  // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.field)\n  return field_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >*\nDescriptorProto::mutable_field() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.field)\n  return &field_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >&\nDescriptorProto::field() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.field)\n  return field_;\n}\n\n// repeated .google.protobuf.FieldDescriptorProto extension = 6;\nint DescriptorProto::extension_size() const {\n  return extension_.size();\n}\nvoid DescriptorProto::clear_extension() {\n  extension_.Clear();\n}\nconst ::google::protobuf::FieldDescriptorProto& DescriptorProto::extension(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.extension)\n  return extension_.Get(index);\n}\n::google::protobuf::FieldDescriptorProto* DescriptorProto::mutable_extension(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.extension)\n  return extension_.Mutable(index);\n}\n::google::protobuf::FieldDescriptorProto* DescriptorProto::add_extension() {\n  // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.extension)\n  return extension_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >*\nDescriptorProto::mutable_extension() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.extension)\n  return &extension_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >&\nDescriptorProto::extension() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.extension)\n  return extension_;\n}\n\n// repeated .google.protobuf.DescriptorProto nested_type = 3;\nint DescriptorProto::nested_type_size() const {\n  return nested_type_.size();\n}\nvoid DescriptorProto::clear_nested_type() {\n  nested_type_.Clear();\n}\nconst ::google::protobuf::DescriptorProto& DescriptorProto::nested_type(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.nested_type)\n  return nested_type_.Get(index);\n}\n::google::protobuf::DescriptorProto* DescriptorProto::mutable_nested_type(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.nested_type)\n  return nested_type_.Mutable(index);\n}\n::google::protobuf::DescriptorProto* DescriptorProto::add_nested_type() {\n  // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.nested_type)\n  return nested_type_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >*\nDescriptorProto::mutable_nested_type() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.nested_type)\n  return &nested_type_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >&\nDescriptorProto::nested_type() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.nested_type)\n  return nested_type_;\n}\n\n// repeated .google.protobuf.EnumDescriptorProto enum_type = 4;\nint DescriptorProto::enum_type_size() const {\n  return enum_type_.size();\n}\nvoid DescriptorProto::clear_enum_type() {\n  enum_type_.Clear();\n}\nconst ::google::protobuf::EnumDescriptorProto& DescriptorProto::enum_type(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.enum_type)\n  return enum_type_.Get(index);\n}\n::google::protobuf::EnumDescriptorProto* DescriptorProto::mutable_enum_type(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.enum_type)\n  return enum_type_.Mutable(index);\n}\n::google::protobuf::EnumDescriptorProto* DescriptorProto::add_enum_type() {\n  // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.enum_type)\n  return enum_type_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >*\nDescriptorProto::mutable_enum_type() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.enum_type)\n  return &enum_type_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >&\nDescriptorProto::enum_type() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.enum_type)\n  return enum_type_;\n}\n\n// repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;\nint DescriptorProto::extension_range_size() const {\n  return extension_range_.size();\n}\nvoid DescriptorProto::clear_extension_range() {\n  extension_range_.Clear();\n}\nconst ::google::protobuf::DescriptorProto_ExtensionRange& DescriptorProto::extension_range(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.extension_range)\n  return extension_range_.Get(index);\n}\n::google::protobuf::DescriptorProto_ExtensionRange* DescriptorProto::mutable_extension_range(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.extension_range)\n  return extension_range_.Mutable(index);\n}\n::google::protobuf::DescriptorProto_ExtensionRange* DescriptorProto::add_extension_range() {\n  // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.extension_range)\n  return extension_range_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange >*\nDescriptorProto::mutable_extension_range() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.extension_range)\n  return &extension_range_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange >&\nDescriptorProto::extension_range() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.extension_range)\n  return extension_range_;\n}\n\n// repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;\nint DescriptorProto::oneof_decl_size() const {\n  return oneof_decl_.size();\n}\nvoid DescriptorProto::clear_oneof_decl() {\n  oneof_decl_.Clear();\n}\nconst ::google::protobuf::OneofDescriptorProto& DescriptorProto::oneof_decl(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.oneof_decl)\n  return oneof_decl_.Get(index);\n}\n::google::protobuf::OneofDescriptorProto* DescriptorProto::mutable_oneof_decl(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.oneof_decl)\n  return oneof_decl_.Mutable(index);\n}\n::google::protobuf::OneofDescriptorProto* DescriptorProto::add_oneof_decl() {\n  // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.oneof_decl)\n  return oneof_decl_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto >*\nDescriptorProto::mutable_oneof_decl() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.oneof_decl)\n  return &oneof_decl_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto >&\nDescriptorProto::oneof_decl() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.oneof_decl)\n  return oneof_decl_;\n}\n\n// optional .google.protobuf.MessageOptions options = 7;\nbool DescriptorProto::has_options() const {\n  return (_has_bits_[0] & 0x00000080u) != 0;\n}\nvoid DescriptorProto::set_has_options() {\n  _has_bits_[0] |= 0x00000080u;\n}\nvoid DescriptorProto::clear_has_options() {\n  _has_bits_[0] &= ~0x00000080u;\n}\nvoid DescriptorProto::clear_options() {\n  if (options_ != NULL) options_->::google::protobuf::MessageOptions::Clear();\n  clear_has_options();\n}\nconst ::google::protobuf::MessageOptions& DescriptorProto::options() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.options)\n  return options_ != NULL ? *options_ : *default_instance_->options_;\n}\n::google::protobuf::MessageOptions* DescriptorProto::mutable_options() {\n  set_has_options();\n  if (options_ == NULL) {\n    options_ = new ::google::protobuf::MessageOptions;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.options)\n  return options_;\n}\n::google::protobuf::MessageOptions* DescriptorProto::release_options() {\n  // @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.options)\n  clear_has_options();\n  ::google::protobuf::MessageOptions* temp = options_;\n  options_ = NULL;\n  return temp;\n}\nvoid DescriptorProto::set_allocated_options(::google::protobuf::MessageOptions* options) {\n  delete options_;\n  options_ = options;\n  if (options) {\n    set_has_options();\n  } else {\n    clear_has_options();\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.DescriptorProto.options)\n}\n\n// repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;\nint DescriptorProto::reserved_range_size() const {\n  return reserved_range_.size();\n}\nvoid DescriptorProto::clear_reserved_range() {\n  reserved_range_.Clear();\n}\nconst ::google::protobuf::DescriptorProto_ReservedRange& DescriptorProto::reserved_range(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.reserved_range)\n  return reserved_range_.Get(index);\n}\n::google::protobuf::DescriptorProto_ReservedRange* DescriptorProto::mutable_reserved_range(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.reserved_range)\n  return reserved_range_.Mutable(index);\n}\n::google::protobuf::DescriptorProto_ReservedRange* DescriptorProto::add_reserved_range() {\n  // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_range)\n  return reserved_range_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ReservedRange >*\nDescriptorProto::mutable_reserved_range() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.reserved_range)\n  return &reserved_range_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ReservedRange >&\nDescriptorProto::reserved_range() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.reserved_range)\n  return reserved_range_;\n}\n\n// repeated string reserved_name = 10;\nint DescriptorProto::reserved_name_size() const {\n  return reserved_name_.size();\n}\nvoid DescriptorProto::clear_reserved_name() {\n  reserved_name_.Clear();\n}\n const ::std::string& DescriptorProto::reserved_name(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.reserved_name)\n  return reserved_name_.Get(index);\n}\n ::std::string* DescriptorProto::mutable_reserved_name(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.reserved_name)\n  return reserved_name_.Mutable(index);\n}\n void DescriptorProto::set_reserved_name(int index, const ::std::string& value) {\n  // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name)\n  reserved_name_.Mutable(index)->assign(value);\n}\n void DescriptorProto::set_reserved_name(int index, const char* value) {\n  reserved_name_.Mutable(index)->assign(value);\n  // @@protoc_insertion_point(field_set_char:google.protobuf.DescriptorProto.reserved_name)\n}\n void DescriptorProto::set_reserved_name(int index, const char* value, size_t size) {\n  reserved_name_.Mutable(index)->assign(\n    reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.DescriptorProto.reserved_name)\n}\n ::std::string* DescriptorProto::add_reserved_name() {\n  // @@protoc_insertion_point(field_add_mutable:google.protobuf.DescriptorProto.reserved_name)\n  return reserved_name_.Add();\n}\n void DescriptorProto::add_reserved_name(const ::std::string& value) {\n  reserved_name_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name)\n}\n void DescriptorProto::add_reserved_name(const char* value) {\n  reserved_name_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add_char:google.protobuf.DescriptorProto.reserved_name)\n}\n void DescriptorProto::add_reserved_name(const char* value, size_t size) {\n  reserved_name_.Add()->assign(reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_add_pointer:google.protobuf.DescriptorProto.reserved_name)\n}\n const ::google::protobuf::RepeatedPtrField< ::std::string>&\nDescriptorProto::reserved_name() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.reserved_name)\n  return reserved_name_;\n}\n ::google::protobuf::RepeatedPtrField< ::std::string>*\nDescriptorProto::mutable_reserved_name() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.reserved_name)\n  return &reserved_name_;\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\nconst ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Type_descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return FieldDescriptorProto_Type_descriptor_;\n}\nbool FieldDescriptorProto_Type_IsValid(int value) {\n  switch(value) {\n    case 1:\n    case 2:\n    case 3:\n    case 4:\n    case 5:\n    case 6:\n    case 7:\n    case 8:\n    case 9:\n    case 10:\n    case 11:\n    case 12:\n    case 13:\n    case 14:\n    case 15:\n    case 16:\n    case 17:\n    case 18:\n      return true;\n    default:\n      return false;\n  }\n}\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst FieldDescriptorProto_Type FieldDescriptorProto::TYPE_DOUBLE;\nconst FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FLOAT;\nconst FieldDescriptorProto_Type FieldDescriptorProto::TYPE_INT64;\nconst FieldDescriptorProto_Type FieldDescriptorProto::TYPE_UINT64;\nconst FieldDescriptorProto_Type FieldDescriptorProto::TYPE_INT32;\nconst FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FIXED64;\nconst FieldDescriptorProto_Type FieldDescriptorProto::TYPE_FIXED32;\nconst FieldDescriptorProto_Type FieldDescriptorProto::TYPE_BOOL;\nconst FieldDescriptorProto_Type FieldDescriptorProto::TYPE_STRING;\nconst FieldDescriptorProto_Type FieldDescriptorProto::TYPE_GROUP;\nconst FieldDescriptorProto_Type FieldDescriptorProto::TYPE_MESSAGE;\nconst FieldDescriptorProto_Type FieldDescriptorProto::TYPE_BYTES;\nconst FieldDescriptorProto_Type FieldDescriptorProto::TYPE_UINT32;\nconst FieldDescriptorProto_Type FieldDescriptorProto::TYPE_ENUM;\nconst FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SFIXED32;\nconst FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SFIXED64;\nconst FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SINT32;\nconst FieldDescriptorProto_Type FieldDescriptorProto::TYPE_SINT64;\nconst FieldDescriptorProto_Type FieldDescriptorProto::Type_MIN;\nconst FieldDescriptorProto_Type FieldDescriptorProto::Type_MAX;\nconst int FieldDescriptorProto::Type_ARRAYSIZE;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\nconst ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Label_descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return FieldDescriptorProto_Label_descriptor_;\n}\nbool FieldDescriptorProto_Label_IsValid(int value) {\n  switch(value) {\n    case 1:\n    case 2:\n    case 3:\n      return true;\n    default:\n      return false;\n  }\n}\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst FieldDescriptorProto_Label FieldDescriptorProto::LABEL_OPTIONAL;\nconst FieldDescriptorProto_Label FieldDescriptorProto::LABEL_REQUIRED;\nconst FieldDescriptorProto_Label FieldDescriptorProto::LABEL_REPEATED;\nconst FieldDescriptorProto_Label FieldDescriptorProto::Label_MIN;\nconst FieldDescriptorProto_Label FieldDescriptorProto::Label_MAX;\nconst int FieldDescriptorProto::Label_ARRAYSIZE;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int FieldDescriptorProto::kNameFieldNumber;\nconst int FieldDescriptorProto::kNumberFieldNumber;\nconst int FieldDescriptorProto::kLabelFieldNumber;\nconst int FieldDescriptorProto::kTypeFieldNumber;\nconst int FieldDescriptorProto::kTypeNameFieldNumber;\nconst int FieldDescriptorProto::kExtendeeFieldNumber;\nconst int FieldDescriptorProto::kDefaultValueFieldNumber;\nconst int FieldDescriptorProto::kOneofIndexFieldNumber;\nconst int FieldDescriptorProto::kJsonNameFieldNumber;\nconst int FieldDescriptorProto::kOptionsFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nFieldDescriptorProto::FieldDescriptorProto()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.FieldDescriptorProto)\n}\n\nvoid FieldDescriptorProto::InitAsDefaultInstance() {\n  options_ = const_cast< ::google::protobuf::FieldOptions*>(&::google::protobuf::FieldOptions::default_instance());\n}\n\nFieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.FieldDescriptorProto)\n}\n\nvoid FieldDescriptorProto::SharedCtor() {\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  number_ = 0;\n  label_ = 1;\n  type_ = 1;\n  type_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  extendee_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  default_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  oneof_index_ = 0;\n  json_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  options_ = NULL;\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nFieldDescriptorProto::~FieldDescriptorProto() {\n  // @@protoc_insertion_point(destructor:google.protobuf.FieldDescriptorProto)\n  SharedDtor();\n}\n\nvoid FieldDescriptorProto::SharedDtor() {\n  name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  type_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  extendee_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  default_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  json_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n    delete options_;\n  }\n}\n\nvoid FieldDescriptorProto::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* FieldDescriptorProto::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return FieldDescriptorProto_descriptor_;\n}\n\nconst FieldDescriptorProto& FieldDescriptorProto::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nFieldDescriptorProto* FieldDescriptorProto::default_instance_ = NULL;\n\nFieldDescriptorProto* FieldDescriptorProto::New(::google::protobuf::Arena* arena) const {\n  FieldDescriptorProto* n = new FieldDescriptorProto;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid FieldDescriptorProto::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.FieldDescriptorProto)\n  if (_has_bits_[0 / 32] & 255u) {\n    if (has_name()) {\n      name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    number_ = 0;\n    label_ = 1;\n    type_ = 1;\n    if (has_type_name()) {\n      type_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    if (has_extendee()) {\n      extendee_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    if (has_default_value()) {\n      default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    oneof_index_ = 0;\n  }\n  if (_has_bits_[8 / 32] & 768u) {\n    if (has_json_name()) {\n      json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    if (has_options()) {\n      if (options_ != NULL) options_->::google::protobuf::FieldOptions::Clear();\n    }\n  }\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool FieldDescriptorProto::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.FieldDescriptorProto)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional string name = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_name()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->name().data(), this->name().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.FieldDescriptorProto.name\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_extendee;\n        break;\n      }\n\n      // optional string extendee = 2;\n      case 2: {\n        if (tag == 18) {\n         parse_extendee:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_extendee()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->extendee().data(), this->extendee().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.FieldDescriptorProto.extendee\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(24)) goto parse_number;\n        break;\n      }\n\n      // optional int32 number = 3;\n      case 3: {\n        if (tag == 24) {\n         parse_number:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 input, &number_)));\n          set_has_number();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(32)) goto parse_label;\n        break;\n      }\n\n      // optional .google.protobuf.FieldDescriptorProto.Label label = 4;\n      case 4: {\n        if (tag == 32) {\n         parse_label:\n          int value;\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n                 input, &value)));\n          if (::google::protobuf::FieldDescriptorProto_Label_IsValid(value)) {\n            set_label(static_cast< ::google::protobuf::FieldDescriptorProto_Label >(value));\n          } else {\n            mutable_unknown_fields()->AddVarint(4, value);\n          }\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(40)) goto parse_type;\n        break;\n      }\n\n      // optional .google.protobuf.FieldDescriptorProto.Type type = 5;\n      case 5: {\n        if (tag == 40) {\n         parse_type:\n          int value;\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n                 input, &value)));\n          if (::google::protobuf::FieldDescriptorProto_Type_IsValid(value)) {\n            set_type(static_cast< ::google::protobuf::FieldDescriptorProto_Type >(value));\n          } else {\n            mutable_unknown_fields()->AddVarint(5, value);\n          }\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(50)) goto parse_type_name;\n        break;\n      }\n\n      // optional string type_name = 6;\n      case 6: {\n        if (tag == 50) {\n         parse_type_name:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_type_name()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->type_name().data(), this->type_name().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.FieldDescriptorProto.type_name\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(58)) goto parse_default_value;\n        break;\n      }\n\n      // optional string default_value = 7;\n      case 7: {\n        if (tag == 58) {\n         parse_default_value:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_default_value()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->default_value().data(), this->default_value().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.FieldDescriptorProto.default_value\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(66)) goto parse_options;\n        break;\n      }\n\n      // optional .google.protobuf.FieldOptions options = 8;\n      case 8: {\n        if (tag == 66) {\n         parse_options:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\n               input, mutable_options()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(72)) goto parse_oneof_index;\n        break;\n      }\n\n      // optional int32 oneof_index = 9;\n      case 9: {\n        if (tag == 72) {\n         parse_oneof_index:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 input, &oneof_index_)));\n          set_has_oneof_index();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(82)) goto parse_json_name;\n        break;\n      }\n\n      // optional string json_name = 10;\n      case 10: {\n        if (tag == 82) {\n         parse_json_name:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_json_name()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->json_name().data(), this->json_name().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.FieldDescriptorProto.json_name\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.FieldDescriptorProto)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.FieldDescriptorProto)\n  return false;\n#undef DO_\n}\n\nvoid FieldDescriptorProto::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.FieldDescriptorProto)\n  // optional string name = 1;\n  if (has_name()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FieldDescriptorProto.name\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      1, this->name(), output);\n  }\n\n  // optional string extendee = 2;\n  if (has_extendee()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->extendee().data(), this->extendee().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FieldDescriptorProto.extendee\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      2, this->extendee(), output);\n  }\n\n  // optional int32 number = 3;\n  if (has_number()) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->number(), output);\n  }\n\n  // optional .google.protobuf.FieldDescriptorProto.Label label = 4;\n  if (has_label()) {\n    ::google::protobuf::internal::WireFormatLite::WriteEnum(\n      4, this->label(), output);\n  }\n\n  // optional .google.protobuf.FieldDescriptorProto.Type type = 5;\n  if (has_type()) {\n    ::google::protobuf::internal::WireFormatLite::WriteEnum(\n      5, this->type(), output);\n  }\n\n  // optional string type_name = 6;\n  if (has_type_name()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->type_name().data(), this->type_name().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FieldDescriptorProto.type_name\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      6, this->type_name(), output);\n  }\n\n  // optional string default_value = 7;\n  if (has_default_value()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->default_value().data(), this->default_value().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FieldDescriptorProto.default_value\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      7, this->default_value(), output);\n  }\n\n  // optional .google.protobuf.FieldOptions options = 8;\n  if (has_options()) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      8, *this->options_, output);\n  }\n\n  // optional int32 oneof_index = 9;\n  if (has_oneof_index()) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt32(9, this->oneof_index(), output);\n  }\n\n  // optional string json_name = 10;\n  if (has_json_name()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->json_name().data(), this->json_name().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FieldDescriptorProto.json_name\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      10, this->json_name(), output);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.FieldDescriptorProto)\n}\n\n::google::protobuf::uint8* FieldDescriptorProto::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldDescriptorProto)\n  // optional string name = 1;\n  if (has_name()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FieldDescriptorProto.name\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        1, this->name(), target);\n  }\n\n  // optional string extendee = 2;\n  if (has_extendee()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->extendee().data(), this->extendee().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FieldDescriptorProto.extendee\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        2, this->extendee(), target);\n  }\n\n  // optional int32 number = 3;\n  if (has_number()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->number(), target);\n  }\n\n  // optional .google.protobuf.FieldDescriptorProto.Label label = 4;\n  if (has_label()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(\n      4, this->label(), target);\n  }\n\n  // optional .google.protobuf.FieldDescriptorProto.Type type = 5;\n  if (has_type()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(\n      5, this->type(), target);\n  }\n\n  // optional string type_name = 6;\n  if (has_type_name()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->type_name().data(), this->type_name().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FieldDescriptorProto.type_name\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        6, this->type_name(), target);\n  }\n\n  // optional string default_value = 7;\n  if (has_default_value()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->default_value().data(), this->default_value().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FieldDescriptorProto.default_value\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        7, this->default_value(), target);\n  }\n\n  // optional .google.protobuf.FieldOptions options = 8;\n  if (has_options()) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        8, *this->options_, false, target);\n  }\n\n  // optional int32 oneof_index = 9;\n  if (has_oneof_index()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(9, this->oneof_index(), target);\n  }\n\n  // optional string json_name = 10;\n  if (has_json_name()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->json_name().data(), this->json_name().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FieldDescriptorProto.json_name\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        10, this->json_name(), target);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FieldDescriptorProto)\n  return target;\n}\n\nint FieldDescriptorProto::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldDescriptorProto)\n  int total_size = 0;\n\n  if (_has_bits_[0 / 32] & 255u) {\n    // optional string name = 1;\n    if (has_name()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->name());\n    }\n\n    // optional int32 number = 3;\n    if (has_number()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::Int32Size(\n          this->number());\n    }\n\n    // optional .google.protobuf.FieldDescriptorProto.Label label = 4;\n    if (has_label()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::EnumSize(this->label());\n    }\n\n    // optional .google.protobuf.FieldDescriptorProto.Type type = 5;\n    if (has_type()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::EnumSize(this->type());\n    }\n\n    // optional string type_name = 6;\n    if (has_type_name()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->type_name());\n    }\n\n    // optional string extendee = 2;\n    if (has_extendee()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->extendee());\n    }\n\n    // optional string default_value = 7;\n    if (has_default_value()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->default_value());\n    }\n\n    // optional int32 oneof_index = 9;\n    if (has_oneof_index()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::Int32Size(\n          this->oneof_index());\n    }\n\n  }\n  if (_has_bits_[8 / 32] & 768u) {\n    // optional string json_name = 10;\n    if (has_json_name()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->json_name());\n    }\n\n    // optional .google.protobuf.FieldOptions options = 8;\n    if (has_options()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n          *this->options_);\n    }\n\n  }\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid FieldDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FieldDescriptorProto)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const FieldDescriptorProto* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const FieldDescriptorProto>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.FieldDescriptorProto)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FieldDescriptorProto)\n    MergeFrom(*source);\n  }\n}\n\nvoid FieldDescriptorProto::MergeFrom(const FieldDescriptorProto& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldDescriptorProto)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {\n    if (from.has_name()) {\n      set_has_name();\n      name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);\n    }\n    if (from.has_number()) {\n      set_number(from.number());\n    }\n    if (from.has_label()) {\n      set_label(from.label());\n    }\n    if (from.has_type()) {\n      set_type(from.type());\n    }\n    if (from.has_type_name()) {\n      set_has_type_name();\n      type_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_name_);\n    }\n    if (from.has_extendee()) {\n      set_has_extendee();\n      extendee_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.extendee_);\n    }\n    if (from.has_default_value()) {\n      set_has_default_value();\n      default_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.default_value_);\n    }\n    if (from.has_oneof_index()) {\n      set_oneof_index(from.oneof_index());\n    }\n  }\n  if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) {\n    if (from.has_json_name()) {\n      set_has_json_name();\n      json_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.json_name_);\n    }\n    if (from.has_options()) {\n      mutable_options()->::google::protobuf::FieldOptions::MergeFrom(from.options());\n    }\n  }\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid FieldDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.FieldDescriptorProto)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid FieldDescriptorProto::CopyFrom(const FieldDescriptorProto& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FieldDescriptorProto)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool FieldDescriptorProto::IsInitialized() const {\n\n  if (has_options()) {\n    if (!this->options_->IsInitialized()) return false;\n  }\n  return true;\n}\n\nvoid FieldDescriptorProto::Swap(FieldDescriptorProto* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid FieldDescriptorProto::InternalSwap(FieldDescriptorProto* other) {\n  name_.Swap(&other->name_);\n  std::swap(number_, other->number_);\n  std::swap(label_, other->label_);\n  std::swap(type_, other->type_);\n  type_name_.Swap(&other->type_name_);\n  extendee_.Swap(&other->extendee_);\n  default_value_.Swap(&other->default_value_);\n  std::swap(oneof_index_, other->oneof_index_);\n  json_name_.Swap(&other->json_name_);\n  std::swap(options_, other->options_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata FieldDescriptorProto::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = FieldDescriptorProto_descriptor_;\n  metadata.reflection = FieldDescriptorProto_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// FieldDescriptorProto\n\n// optional string name = 1;\nbool FieldDescriptorProto::has_name() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\nvoid FieldDescriptorProto::set_has_name() {\n  _has_bits_[0] |= 0x00000001u;\n}\nvoid FieldDescriptorProto::clear_has_name() {\n  _has_bits_[0] &= ~0x00000001u;\n}\nvoid FieldDescriptorProto::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_name();\n}\n const ::std::string& FieldDescriptorProto::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FieldDescriptorProto::set_name(const ::std::string& value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.name)\n}\n void FieldDescriptorProto::set_name(const char* value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.name)\n}\n void FieldDescriptorProto::set_name(const char* value, size_t size) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.name)\n}\n ::std::string* FieldDescriptorProto::mutable_name() {\n  set_has_name();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* FieldDescriptorProto::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.name)\n  clear_has_name();\n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FieldDescriptorProto::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    set_has_name();\n  } else {\n    clear_has_name();\n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.name)\n}\n\n// optional int32 number = 3;\nbool FieldDescriptorProto::has_number() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\nvoid FieldDescriptorProto::set_has_number() {\n  _has_bits_[0] |= 0x00000002u;\n}\nvoid FieldDescriptorProto::clear_has_number() {\n  _has_bits_[0] &= ~0x00000002u;\n}\nvoid FieldDescriptorProto::clear_number() {\n  number_ = 0;\n  clear_has_number();\n}\n ::google::protobuf::int32 FieldDescriptorProto::number() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.number)\n  return number_;\n}\n void FieldDescriptorProto::set_number(::google::protobuf::int32 value) {\n  set_has_number();\n  number_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.number)\n}\n\n// optional .google.protobuf.FieldDescriptorProto.Label label = 4;\nbool FieldDescriptorProto::has_label() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\nvoid FieldDescriptorProto::set_has_label() {\n  _has_bits_[0] |= 0x00000004u;\n}\nvoid FieldDescriptorProto::clear_has_label() {\n  _has_bits_[0] &= ~0x00000004u;\n}\nvoid FieldDescriptorProto::clear_label() {\n  label_ = 1;\n  clear_has_label();\n}\n ::google::protobuf::FieldDescriptorProto_Label FieldDescriptorProto::label() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.label)\n  return static_cast< ::google::protobuf::FieldDescriptorProto_Label >(label_);\n}\n void FieldDescriptorProto::set_label(::google::protobuf::FieldDescriptorProto_Label value) {\n  assert(::google::protobuf::FieldDescriptorProto_Label_IsValid(value));\n  set_has_label();\n  label_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.label)\n}\n\n// optional .google.protobuf.FieldDescriptorProto.Type type = 5;\nbool FieldDescriptorProto::has_type() const {\n  return (_has_bits_[0] & 0x00000008u) != 0;\n}\nvoid FieldDescriptorProto::set_has_type() {\n  _has_bits_[0] |= 0x00000008u;\n}\nvoid FieldDescriptorProto::clear_has_type() {\n  _has_bits_[0] &= ~0x00000008u;\n}\nvoid FieldDescriptorProto::clear_type() {\n  type_ = 1;\n  clear_has_type();\n}\n ::google::protobuf::FieldDescriptorProto_Type FieldDescriptorProto::type() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.type)\n  return static_cast< ::google::protobuf::FieldDescriptorProto_Type >(type_);\n}\n void FieldDescriptorProto::set_type(::google::protobuf::FieldDescriptorProto_Type value) {\n  assert(::google::protobuf::FieldDescriptorProto_Type_IsValid(value));\n  set_has_type();\n  type_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type)\n}\n\n// optional string type_name = 6;\nbool FieldDescriptorProto::has_type_name() const {\n  return (_has_bits_[0] & 0x00000010u) != 0;\n}\nvoid FieldDescriptorProto::set_has_type_name() {\n  _has_bits_[0] |= 0x00000010u;\n}\nvoid FieldDescriptorProto::clear_has_type_name() {\n  _has_bits_[0] &= ~0x00000010u;\n}\nvoid FieldDescriptorProto::clear_type_name() {\n  type_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_type_name();\n}\n const ::std::string& FieldDescriptorProto::type_name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.type_name)\n  return type_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FieldDescriptorProto::set_type_name(const ::std::string& value) {\n  set_has_type_name();\n  type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type_name)\n}\n void FieldDescriptorProto::set_type_name(const char* value) {\n  set_has_type_name();\n  type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.type_name)\n}\n void FieldDescriptorProto::set_type_name(const char* value, size_t size) {\n  set_has_type_name();\n  type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.type_name)\n}\n ::std::string* FieldDescriptorProto::mutable_type_name() {\n  set_has_type_name();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.type_name)\n  return type_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* FieldDescriptorProto::release_type_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.type_name)\n  clear_has_type_name();\n  return type_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FieldDescriptorProto::set_allocated_type_name(::std::string* type_name) {\n  if (type_name != NULL) {\n    set_has_type_name();\n  } else {\n    clear_has_type_name();\n  }\n  type_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type_name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.type_name)\n}\n\n// optional string extendee = 2;\nbool FieldDescriptorProto::has_extendee() const {\n  return (_has_bits_[0] & 0x00000020u) != 0;\n}\nvoid FieldDescriptorProto::set_has_extendee() {\n  _has_bits_[0] |= 0x00000020u;\n}\nvoid FieldDescriptorProto::clear_has_extendee() {\n  _has_bits_[0] &= ~0x00000020u;\n}\nvoid FieldDescriptorProto::clear_extendee() {\n  extendee_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_extendee();\n}\n const ::std::string& FieldDescriptorProto::extendee() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.extendee)\n  return extendee_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FieldDescriptorProto::set_extendee(const ::std::string& value) {\n  set_has_extendee();\n  extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.extendee)\n}\n void FieldDescriptorProto::set_extendee(const char* value) {\n  set_has_extendee();\n  extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.extendee)\n}\n void FieldDescriptorProto::set_extendee(const char* value, size_t size) {\n  set_has_extendee();\n  extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.extendee)\n}\n ::std::string* FieldDescriptorProto::mutable_extendee() {\n  set_has_extendee();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.extendee)\n  return extendee_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* FieldDescriptorProto::release_extendee() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.extendee)\n  clear_has_extendee();\n  return extendee_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FieldDescriptorProto::set_allocated_extendee(::std::string* extendee) {\n  if (extendee != NULL) {\n    set_has_extendee();\n  } else {\n    clear_has_extendee();\n  }\n  extendee_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), extendee);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.extendee)\n}\n\n// optional string default_value = 7;\nbool FieldDescriptorProto::has_default_value() const {\n  return (_has_bits_[0] & 0x00000040u) != 0;\n}\nvoid FieldDescriptorProto::set_has_default_value() {\n  _has_bits_[0] |= 0x00000040u;\n}\nvoid FieldDescriptorProto::clear_has_default_value() {\n  _has_bits_[0] &= ~0x00000040u;\n}\nvoid FieldDescriptorProto::clear_default_value() {\n  default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_default_value();\n}\n const ::std::string& FieldDescriptorProto::default_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.default_value)\n  return default_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FieldDescriptorProto::set_default_value(const ::std::string& value) {\n  set_has_default_value();\n  default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.default_value)\n}\n void FieldDescriptorProto::set_default_value(const char* value) {\n  set_has_default_value();\n  default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.default_value)\n}\n void FieldDescriptorProto::set_default_value(const char* value, size_t size) {\n  set_has_default_value();\n  default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.default_value)\n}\n ::std::string* FieldDescriptorProto::mutable_default_value() {\n  set_has_default_value();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.default_value)\n  return default_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* FieldDescriptorProto::release_default_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.default_value)\n  clear_has_default_value();\n  return default_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FieldDescriptorProto::set_allocated_default_value(::std::string* default_value) {\n  if (default_value != NULL) {\n    set_has_default_value();\n  } else {\n    clear_has_default_value();\n  }\n  default_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), default_value);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.default_value)\n}\n\n// optional int32 oneof_index = 9;\nbool FieldDescriptorProto::has_oneof_index() const {\n  return (_has_bits_[0] & 0x00000080u) != 0;\n}\nvoid FieldDescriptorProto::set_has_oneof_index() {\n  _has_bits_[0] |= 0x00000080u;\n}\nvoid FieldDescriptorProto::clear_has_oneof_index() {\n  _has_bits_[0] &= ~0x00000080u;\n}\nvoid FieldDescriptorProto::clear_oneof_index() {\n  oneof_index_ = 0;\n  clear_has_oneof_index();\n}\n ::google::protobuf::int32 FieldDescriptorProto::oneof_index() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.oneof_index)\n  return oneof_index_;\n}\n void FieldDescriptorProto::set_oneof_index(::google::protobuf::int32 value) {\n  set_has_oneof_index();\n  oneof_index_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.oneof_index)\n}\n\n// optional string json_name = 10;\nbool FieldDescriptorProto::has_json_name() const {\n  return (_has_bits_[0] & 0x00000100u) != 0;\n}\nvoid FieldDescriptorProto::set_has_json_name() {\n  _has_bits_[0] |= 0x00000100u;\n}\nvoid FieldDescriptorProto::clear_has_json_name() {\n  _has_bits_[0] &= ~0x00000100u;\n}\nvoid FieldDescriptorProto::clear_json_name() {\n  json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_json_name();\n}\n const ::std::string& FieldDescriptorProto::json_name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.json_name)\n  return json_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FieldDescriptorProto::set_json_name(const ::std::string& value) {\n  set_has_json_name();\n  json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.json_name)\n}\n void FieldDescriptorProto::set_json_name(const char* value) {\n  set_has_json_name();\n  json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.json_name)\n}\n void FieldDescriptorProto::set_json_name(const char* value, size_t size) {\n  set_has_json_name();\n  json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.json_name)\n}\n ::std::string* FieldDescriptorProto::mutable_json_name() {\n  set_has_json_name();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.json_name)\n  return json_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* FieldDescriptorProto::release_json_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.json_name)\n  clear_has_json_name();\n  return json_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FieldDescriptorProto::set_allocated_json_name(::std::string* json_name) {\n  if (json_name != NULL) {\n    set_has_json_name();\n  } else {\n    clear_has_json_name();\n  }\n  json_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), json_name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.json_name)\n}\n\n// optional .google.protobuf.FieldOptions options = 8;\nbool FieldDescriptorProto::has_options() const {\n  return (_has_bits_[0] & 0x00000200u) != 0;\n}\nvoid FieldDescriptorProto::set_has_options() {\n  _has_bits_[0] |= 0x00000200u;\n}\nvoid FieldDescriptorProto::clear_has_options() {\n  _has_bits_[0] &= ~0x00000200u;\n}\nvoid FieldDescriptorProto::clear_options() {\n  if (options_ != NULL) options_->::google::protobuf::FieldOptions::Clear();\n  clear_has_options();\n}\nconst ::google::protobuf::FieldOptions& FieldDescriptorProto::options() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.options)\n  return options_ != NULL ? *options_ : *default_instance_->options_;\n}\n::google::protobuf::FieldOptions* FieldDescriptorProto::mutable_options() {\n  set_has_options();\n  if (options_ == NULL) {\n    options_ = new ::google::protobuf::FieldOptions;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.options)\n  return options_;\n}\n::google::protobuf::FieldOptions* FieldDescriptorProto::release_options() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.options)\n  clear_has_options();\n  ::google::protobuf::FieldOptions* temp = options_;\n  options_ = NULL;\n  return temp;\n}\nvoid FieldDescriptorProto::set_allocated_options(::google::protobuf::FieldOptions* options) {\n  delete options_;\n  options_ = options;\n  if (options) {\n    set_has_options();\n  } else {\n    clear_has_options();\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.options)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int OneofDescriptorProto::kNameFieldNumber;\nconst int OneofDescriptorProto::kOptionsFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nOneofDescriptorProto::OneofDescriptorProto()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.OneofDescriptorProto)\n}\n\nvoid OneofDescriptorProto::InitAsDefaultInstance() {\n  options_ = const_cast< ::google::protobuf::OneofOptions*>(&::google::protobuf::OneofOptions::default_instance());\n}\n\nOneofDescriptorProto::OneofDescriptorProto(const OneofDescriptorProto& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.OneofDescriptorProto)\n}\n\nvoid OneofDescriptorProto::SharedCtor() {\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  options_ = NULL;\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nOneofDescriptorProto::~OneofDescriptorProto() {\n  // @@protoc_insertion_point(destructor:google.protobuf.OneofDescriptorProto)\n  SharedDtor();\n}\n\nvoid OneofDescriptorProto::SharedDtor() {\n  name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n    delete options_;\n  }\n}\n\nvoid OneofDescriptorProto::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* OneofDescriptorProto::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return OneofDescriptorProto_descriptor_;\n}\n\nconst OneofDescriptorProto& OneofDescriptorProto::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nOneofDescriptorProto* OneofDescriptorProto::default_instance_ = NULL;\n\nOneofDescriptorProto* OneofDescriptorProto::New(::google::protobuf::Arena* arena) const {\n  OneofDescriptorProto* n = new OneofDescriptorProto;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid OneofDescriptorProto::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.OneofDescriptorProto)\n  if (_has_bits_[0 / 32] & 3u) {\n    if (has_name()) {\n      name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    if (has_options()) {\n      if (options_ != NULL) options_->::google::protobuf::OneofOptions::Clear();\n    }\n  }\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool OneofDescriptorProto::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.OneofDescriptorProto)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional string name = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_name()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->name().data(), this->name().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.OneofDescriptorProto.name\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_options;\n        break;\n      }\n\n      // optional .google.protobuf.OneofOptions options = 2;\n      case 2: {\n        if (tag == 18) {\n         parse_options:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\n               input, mutable_options()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.OneofDescriptorProto)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.OneofDescriptorProto)\n  return false;\n#undef DO_\n}\n\nvoid OneofDescriptorProto::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.OneofDescriptorProto)\n  // optional string name = 1;\n  if (has_name()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.OneofDescriptorProto.name\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      1, this->name(), output);\n  }\n\n  // optional .google.protobuf.OneofOptions options = 2;\n  if (has_options()) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      2, *this->options_, output);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.OneofDescriptorProto)\n}\n\n::google::protobuf::uint8* OneofDescriptorProto::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.OneofDescriptorProto)\n  // optional string name = 1;\n  if (has_name()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.OneofDescriptorProto.name\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        1, this->name(), target);\n  }\n\n  // optional .google.protobuf.OneofOptions options = 2;\n  if (has_options()) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        2, *this->options_, false, target);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.OneofDescriptorProto)\n  return target;\n}\n\nint OneofDescriptorProto::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.OneofDescriptorProto)\n  int total_size = 0;\n\n  if (_has_bits_[0 / 32] & 3u) {\n    // optional string name = 1;\n    if (has_name()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->name());\n    }\n\n    // optional .google.protobuf.OneofOptions options = 2;\n    if (has_options()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n          *this->options_);\n    }\n\n  }\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid OneofDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.OneofDescriptorProto)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const OneofDescriptorProto* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const OneofDescriptorProto>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.OneofDescriptorProto)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.OneofDescriptorProto)\n    MergeFrom(*source);\n  }\n}\n\nvoid OneofDescriptorProto::MergeFrom(const OneofDescriptorProto& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofDescriptorProto)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {\n    if (from.has_name()) {\n      set_has_name();\n      name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);\n    }\n    if (from.has_options()) {\n      mutable_options()->::google::protobuf::OneofOptions::MergeFrom(from.options());\n    }\n  }\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid OneofDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.OneofDescriptorProto)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid OneofDescriptorProto::CopyFrom(const OneofDescriptorProto& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.OneofDescriptorProto)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool OneofDescriptorProto::IsInitialized() const {\n\n  if (has_options()) {\n    if (!this->options_->IsInitialized()) return false;\n  }\n  return true;\n}\n\nvoid OneofDescriptorProto::Swap(OneofDescriptorProto* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid OneofDescriptorProto::InternalSwap(OneofDescriptorProto* other) {\n  name_.Swap(&other->name_);\n  std::swap(options_, other->options_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata OneofDescriptorProto::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = OneofDescriptorProto_descriptor_;\n  metadata.reflection = OneofDescriptorProto_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// OneofDescriptorProto\n\n// optional string name = 1;\nbool OneofDescriptorProto::has_name() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\nvoid OneofDescriptorProto::set_has_name() {\n  _has_bits_[0] |= 0x00000001u;\n}\nvoid OneofDescriptorProto::clear_has_name() {\n  _has_bits_[0] &= ~0x00000001u;\n}\nvoid OneofDescriptorProto::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_name();\n}\n const ::std::string& OneofDescriptorProto::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void OneofDescriptorProto::set_name(const ::std::string& value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.OneofDescriptorProto.name)\n}\n void OneofDescriptorProto::set_name(const char* value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.OneofDescriptorProto.name)\n}\n void OneofDescriptorProto::set_name(const char* value, size_t size) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.OneofDescriptorProto.name)\n}\n ::std::string* OneofDescriptorProto::mutable_name() {\n  set_has_name();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.OneofDescriptorProto.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* OneofDescriptorProto::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.OneofDescriptorProto.name)\n  clear_has_name();\n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void OneofDescriptorProto::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    set_has_name();\n  } else {\n    clear_has_name();\n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.OneofDescriptorProto.name)\n}\n\n// optional .google.protobuf.OneofOptions options = 2;\nbool OneofDescriptorProto::has_options() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\nvoid OneofDescriptorProto::set_has_options() {\n  _has_bits_[0] |= 0x00000002u;\n}\nvoid OneofDescriptorProto::clear_has_options() {\n  _has_bits_[0] &= ~0x00000002u;\n}\nvoid OneofDescriptorProto::clear_options() {\n  if (options_ != NULL) options_->::google::protobuf::OneofOptions::Clear();\n  clear_has_options();\n}\nconst ::google::protobuf::OneofOptions& OneofDescriptorProto::options() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.options)\n  return options_ != NULL ? *options_ : *default_instance_->options_;\n}\n::google::protobuf::OneofOptions* OneofDescriptorProto::mutable_options() {\n  set_has_options();\n  if (options_ == NULL) {\n    options_ = new ::google::protobuf::OneofOptions;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.OneofDescriptorProto.options)\n  return options_;\n}\n::google::protobuf::OneofOptions* OneofDescriptorProto::release_options() {\n  // @@protoc_insertion_point(field_release:google.protobuf.OneofDescriptorProto.options)\n  clear_has_options();\n  ::google::protobuf::OneofOptions* temp = options_;\n  options_ = NULL;\n  return temp;\n}\nvoid OneofDescriptorProto::set_allocated_options(::google::protobuf::OneofOptions* options) {\n  delete options_;\n  options_ = options;\n  if (options) {\n    set_has_options();\n  } else {\n    clear_has_options();\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.OneofDescriptorProto.options)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int EnumDescriptorProto::kNameFieldNumber;\nconst int EnumDescriptorProto::kValueFieldNumber;\nconst int EnumDescriptorProto::kOptionsFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nEnumDescriptorProto::EnumDescriptorProto()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.EnumDescriptorProto)\n}\n\nvoid EnumDescriptorProto::InitAsDefaultInstance() {\n  options_ = const_cast< ::google::protobuf::EnumOptions*>(&::google::protobuf::EnumOptions::default_instance());\n}\n\nEnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumDescriptorProto)\n}\n\nvoid EnumDescriptorProto::SharedCtor() {\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  options_ = NULL;\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nEnumDescriptorProto::~EnumDescriptorProto() {\n  // @@protoc_insertion_point(destructor:google.protobuf.EnumDescriptorProto)\n  SharedDtor();\n}\n\nvoid EnumDescriptorProto::SharedDtor() {\n  name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n    delete options_;\n  }\n}\n\nvoid EnumDescriptorProto::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* EnumDescriptorProto::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return EnumDescriptorProto_descriptor_;\n}\n\nconst EnumDescriptorProto& EnumDescriptorProto::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nEnumDescriptorProto* EnumDescriptorProto::default_instance_ = NULL;\n\nEnumDescriptorProto* EnumDescriptorProto::New(::google::protobuf::Arena* arena) const {\n  EnumDescriptorProto* n = new EnumDescriptorProto;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid EnumDescriptorProto::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumDescriptorProto)\n  if (_has_bits_[0 / 32] & 5u) {\n    if (has_name()) {\n      name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    if (has_options()) {\n      if (options_ != NULL) options_->::google::protobuf::EnumOptions::Clear();\n    }\n  }\n  value_.Clear();\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool EnumDescriptorProto::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.EnumDescriptorProto)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional string name = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_name()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->name().data(), this->name().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.EnumDescriptorProto.name\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_value;\n        break;\n      }\n\n      // repeated .google.protobuf.EnumValueDescriptorProto value = 2;\n      case 2: {\n        if (tag == 18) {\n         parse_value:\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_value:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_value()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_loop_value;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectTag(26)) goto parse_options;\n        break;\n      }\n\n      // optional .google.protobuf.EnumOptions options = 3;\n      case 3: {\n        if (tag == 26) {\n         parse_options:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\n               input, mutable_options()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.EnumDescriptorProto)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.EnumDescriptorProto)\n  return false;\n#undef DO_\n}\n\nvoid EnumDescriptorProto::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.EnumDescriptorProto)\n  // optional string name = 1;\n  if (has_name()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.EnumDescriptorProto.name\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      1, this->name(), output);\n  }\n\n  // repeated .google.protobuf.EnumValueDescriptorProto value = 2;\n  for (unsigned int i = 0, n = this->value_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      2, this->value(i), output);\n  }\n\n  // optional .google.protobuf.EnumOptions options = 3;\n  if (has_options()) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      3, *this->options_, output);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.EnumDescriptorProto)\n}\n\n::google::protobuf::uint8* EnumDescriptorProto::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumDescriptorProto)\n  // optional string name = 1;\n  if (has_name()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.EnumDescriptorProto.name\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        1, this->name(), target);\n  }\n\n  // repeated .google.protobuf.EnumValueDescriptorProto value = 2;\n  for (unsigned int i = 0, n = this->value_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        2, this->value(i), false, target);\n  }\n\n  // optional .google.protobuf.EnumOptions options = 3;\n  if (has_options()) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        3, *this->options_, false, target);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumDescriptorProto)\n  return target;\n}\n\nint EnumDescriptorProto::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumDescriptorProto)\n  int total_size = 0;\n\n  if (_has_bits_[0 / 32] & 5u) {\n    // optional string name = 1;\n    if (has_name()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->name());\n    }\n\n    // optional .google.protobuf.EnumOptions options = 3;\n    if (has_options()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n          *this->options_);\n    }\n\n  }\n  // repeated .google.protobuf.EnumValueDescriptorProto value = 2;\n  total_size += 1 * this->value_size();\n  for (int i = 0; i < this->value_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->value(i));\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid EnumDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumDescriptorProto)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const EnumDescriptorProto* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const EnumDescriptorProto>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.EnumDescriptorProto)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumDescriptorProto)\n    MergeFrom(*source);\n  }\n}\n\nvoid EnumDescriptorProto::MergeFrom(const EnumDescriptorProto& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumDescriptorProto)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  value_.MergeFrom(from.value_);\n  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {\n    if (from.has_name()) {\n      set_has_name();\n      name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);\n    }\n    if (from.has_options()) {\n      mutable_options()->::google::protobuf::EnumOptions::MergeFrom(from.options());\n    }\n  }\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid EnumDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.EnumDescriptorProto)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid EnumDescriptorProto::CopyFrom(const EnumDescriptorProto& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumDescriptorProto)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool EnumDescriptorProto::IsInitialized() const {\n\n  if (!::google::protobuf::internal::AllAreInitialized(this->value())) return false;\n  if (has_options()) {\n    if (!this->options_->IsInitialized()) return false;\n  }\n  return true;\n}\n\nvoid EnumDescriptorProto::Swap(EnumDescriptorProto* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid EnumDescriptorProto::InternalSwap(EnumDescriptorProto* other) {\n  name_.Swap(&other->name_);\n  value_.UnsafeArenaSwap(&other->value_);\n  std::swap(options_, other->options_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata EnumDescriptorProto::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = EnumDescriptorProto_descriptor_;\n  metadata.reflection = EnumDescriptorProto_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// EnumDescriptorProto\n\n// optional string name = 1;\nbool EnumDescriptorProto::has_name() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\nvoid EnumDescriptorProto::set_has_name() {\n  _has_bits_[0] |= 0x00000001u;\n}\nvoid EnumDescriptorProto::clear_has_name() {\n  _has_bits_[0] &= ~0x00000001u;\n}\nvoid EnumDescriptorProto::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_name();\n}\n const ::std::string& EnumDescriptorProto::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void EnumDescriptorProto::set_name(const ::std::string& value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.name)\n}\n void EnumDescriptorProto::set_name(const char* value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.EnumDescriptorProto.name)\n}\n void EnumDescriptorProto::set_name(const char* value, size_t size) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumDescriptorProto.name)\n}\n ::std::string* EnumDescriptorProto::mutable_name() {\n  set_has_name();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* EnumDescriptorProto::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.EnumDescriptorProto.name)\n  clear_has_name();\n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void EnumDescriptorProto::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    set_has_name();\n  } else {\n    clear_has_name();\n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumDescriptorProto.name)\n}\n\n// repeated .google.protobuf.EnumValueDescriptorProto value = 2;\nint EnumDescriptorProto::value_size() const {\n  return value_.size();\n}\nvoid EnumDescriptorProto::clear_value() {\n  value_.Clear();\n}\nconst ::google::protobuf::EnumValueDescriptorProto& EnumDescriptorProto::value(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.value)\n  return value_.Get(index);\n}\n::google::protobuf::EnumValueDescriptorProto* EnumDescriptorProto::mutable_value(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.value)\n  return value_.Mutable(index);\n}\n::google::protobuf::EnumValueDescriptorProto* EnumDescriptorProto::add_value() {\n  // @@protoc_insertion_point(field_add:google.protobuf.EnumDescriptorProto.value)\n  return value_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >*\nEnumDescriptorProto::mutable_value() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumDescriptorProto.value)\n  return &value_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >&\nEnumDescriptorProto::value() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.EnumDescriptorProto.value)\n  return value_;\n}\n\n// optional .google.protobuf.EnumOptions options = 3;\nbool EnumDescriptorProto::has_options() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\nvoid EnumDescriptorProto::set_has_options() {\n  _has_bits_[0] |= 0x00000004u;\n}\nvoid EnumDescriptorProto::clear_has_options() {\n  _has_bits_[0] &= ~0x00000004u;\n}\nvoid EnumDescriptorProto::clear_options() {\n  if (options_ != NULL) options_->::google::protobuf::EnumOptions::Clear();\n  clear_has_options();\n}\nconst ::google::protobuf::EnumOptions& EnumDescriptorProto::options() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.options)\n  return options_ != NULL ? *options_ : *default_instance_->options_;\n}\n::google::protobuf::EnumOptions* EnumDescriptorProto::mutable_options() {\n  set_has_options();\n  if (options_ == NULL) {\n    options_ = new ::google::protobuf::EnumOptions;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.options)\n  return options_;\n}\n::google::protobuf::EnumOptions* EnumDescriptorProto::release_options() {\n  // @@protoc_insertion_point(field_release:google.protobuf.EnumDescriptorProto.options)\n  clear_has_options();\n  ::google::protobuf::EnumOptions* temp = options_;\n  options_ = NULL;\n  return temp;\n}\nvoid EnumDescriptorProto::set_allocated_options(::google::protobuf::EnumOptions* options) {\n  delete options_;\n  options_ = options;\n  if (options) {\n    set_has_options();\n  } else {\n    clear_has_options();\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumDescriptorProto.options)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int EnumValueDescriptorProto::kNameFieldNumber;\nconst int EnumValueDescriptorProto::kNumberFieldNumber;\nconst int EnumValueDescriptorProto::kOptionsFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nEnumValueDescriptorProto::EnumValueDescriptorProto()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.EnumValueDescriptorProto)\n}\n\nvoid EnumValueDescriptorProto::InitAsDefaultInstance() {\n  options_ = const_cast< ::google::protobuf::EnumValueOptions*>(&::google::protobuf::EnumValueOptions::default_instance());\n}\n\nEnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProto& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValueDescriptorProto)\n}\n\nvoid EnumValueDescriptorProto::SharedCtor() {\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  number_ = 0;\n  options_ = NULL;\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nEnumValueDescriptorProto::~EnumValueDescriptorProto() {\n  // @@protoc_insertion_point(destructor:google.protobuf.EnumValueDescriptorProto)\n  SharedDtor();\n}\n\nvoid EnumValueDescriptorProto::SharedDtor() {\n  name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n    delete options_;\n  }\n}\n\nvoid EnumValueDescriptorProto::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* EnumValueDescriptorProto::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return EnumValueDescriptorProto_descriptor_;\n}\n\nconst EnumValueDescriptorProto& EnumValueDescriptorProto::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nEnumValueDescriptorProto* EnumValueDescriptorProto::default_instance_ = NULL;\n\nEnumValueDescriptorProto* EnumValueDescriptorProto::New(::google::protobuf::Arena* arena) const {\n  EnumValueDescriptorProto* n = new EnumValueDescriptorProto;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid EnumValueDescriptorProto::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValueDescriptorProto)\n  if (_has_bits_[0 / 32] & 7u) {\n    if (has_name()) {\n      name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    number_ = 0;\n    if (has_options()) {\n      if (options_ != NULL) options_->::google::protobuf::EnumValueOptions::Clear();\n    }\n  }\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool EnumValueDescriptorProto::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.EnumValueDescriptorProto)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional string name = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_name()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->name().data(), this->name().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.EnumValueDescriptorProto.name\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(16)) goto parse_number;\n        break;\n      }\n\n      // optional int32 number = 2;\n      case 2: {\n        if (tag == 16) {\n         parse_number:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 input, &number_)));\n          set_has_number();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(26)) goto parse_options;\n        break;\n      }\n\n      // optional .google.protobuf.EnumValueOptions options = 3;\n      case 3: {\n        if (tag == 26) {\n         parse_options:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\n               input, mutable_options()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.EnumValueDescriptorProto)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.EnumValueDescriptorProto)\n  return false;\n#undef DO_\n}\n\nvoid EnumValueDescriptorProto::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.EnumValueDescriptorProto)\n  // optional string name = 1;\n  if (has_name()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.EnumValueDescriptorProto.name\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      1, this->name(), output);\n  }\n\n  // optional int32 number = 2;\n  if (has_number()) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->number(), output);\n  }\n\n  // optional .google.protobuf.EnumValueOptions options = 3;\n  if (has_options()) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      3, *this->options_, output);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.EnumValueDescriptorProto)\n}\n\n::google::protobuf::uint8* EnumValueDescriptorProto::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumValueDescriptorProto)\n  // optional string name = 1;\n  if (has_name()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.EnumValueDescriptorProto.name\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        1, this->name(), target);\n  }\n\n  // optional int32 number = 2;\n  if (has_number()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->number(), target);\n  }\n\n  // optional .google.protobuf.EnumValueOptions options = 3;\n  if (has_options()) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        3, *this->options_, false, target);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumValueDescriptorProto)\n  return target;\n}\n\nint EnumValueDescriptorProto::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValueDescriptorProto)\n  int total_size = 0;\n\n  if (_has_bits_[0 / 32] & 7u) {\n    // optional string name = 1;\n    if (has_name()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->name());\n    }\n\n    // optional int32 number = 2;\n    if (has_number()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::Int32Size(\n          this->number());\n    }\n\n    // optional .google.protobuf.EnumValueOptions options = 3;\n    if (has_options()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n          *this->options_);\n    }\n\n  }\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid EnumValueDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumValueDescriptorProto)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const EnumValueDescriptorProto* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const EnumValueDescriptorProto>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.EnumValueDescriptorProto)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumValueDescriptorProto)\n    MergeFrom(*source);\n  }\n}\n\nvoid EnumValueDescriptorProto::MergeFrom(const EnumValueDescriptorProto& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueDescriptorProto)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {\n    if (from.has_name()) {\n      set_has_name();\n      name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);\n    }\n    if (from.has_number()) {\n      set_number(from.number());\n    }\n    if (from.has_options()) {\n      mutable_options()->::google::protobuf::EnumValueOptions::MergeFrom(from.options());\n    }\n  }\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid EnumValueDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.EnumValueDescriptorProto)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid EnumValueDescriptorProto::CopyFrom(const EnumValueDescriptorProto& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumValueDescriptorProto)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool EnumValueDescriptorProto::IsInitialized() const {\n\n  if (has_options()) {\n    if (!this->options_->IsInitialized()) return false;\n  }\n  return true;\n}\n\nvoid EnumValueDescriptorProto::Swap(EnumValueDescriptorProto* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid EnumValueDescriptorProto::InternalSwap(EnumValueDescriptorProto* other) {\n  name_.Swap(&other->name_);\n  std::swap(number_, other->number_);\n  std::swap(options_, other->options_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata EnumValueDescriptorProto::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = EnumValueDescriptorProto_descriptor_;\n  metadata.reflection = EnumValueDescriptorProto_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// EnumValueDescriptorProto\n\n// optional string name = 1;\nbool EnumValueDescriptorProto::has_name() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\nvoid EnumValueDescriptorProto::set_has_name() {\n  _has_bits_[0] |= 0x00000001u;\n}\nvoid EnumValueDescriptorProto::clear_has_name() {\n  _has_bits_[0] &= ~0x00000001u;\n}\nvoid EnumValueDescriptorProto::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_name();\n}\n const ::std::string& EnumValueDescriptorProto::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void EnumValueDescriptorProto::set_name(const ::std::string& value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.name)\n}\n void EnumValueDescriptorProto::set_name(const char* value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.EnumValueDescriptorProto.name)\n}\n void EnumValueDescriptorProto::set_name(const char* value, size_t size) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumValueDescriptorProto.name)\n}\n ::std::string* EnumValueDescriptorProto::mutable_name() {\n  set_has_name();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueDescriptorProto.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* EnumValueDescriptorProto::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.EnumValueDescriptorProto.name)\n  clear_has_name();\n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void EnumValueDescriptorProto::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    set_has_name();\n  } else {\n    clear_has_name();\n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValueDescriptorProto.name)\n}\n\n// optional int32 number = 2;\nbool EnumValueDescriptorProto::has_number() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\nvoid EnumValueDescriptorProto::set_has_number() {\n  _has_bits_[0] |= 0x00000002u;\n}\nvoid EnumValueDescriptorProto::clear_has_number() {\n  _has_bits_[0] &= ~0x00000002u;\n}\nvoid EnumValueDescriptorProto::clear_number() {\n  number_ = 0;\n  clear_has_number();\n}\n ::google::protobuf::int32 EnumValueDescriptorProto::number() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.number)\n  return number_;\n}\n void EnumValueDescriptorProto::set_number(::google::protobuf::int32 value) {\n  set_has_number();\n  number_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.number)\n}\n\n// optional .google.protobuf.EnumValueOptions options = 3;\nbool EnumValueDescriptorProto::has_options() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\nvoid EnumValueDescriptorProto::set_has_options() {\n  _has_bits_[0] |= 0x00000004u;\n}\nvoid EnumValueDescriptorProto::clear_has_options() {\n  _has_bits_[0] &= ~0x00000004u;\n}\nvoid EnumValueDescriptorProto::clear_options() {\n  if (options_ != NULL) options_->::google::protobuf::EnumValueOptions::Clear();\n  clear_has_options();\n}\nconst ::google::protobuf::EnumValueOptions& EnumValueDescriptorProto::options() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.options)\n  return options_ != NULL ? *options_ : *default_instance_->options_;\n}\n::google::protobuf::EnumValueOptions* EnumValueDescriptorProto::mutable_options() {\n  set_has_options();\n  if (options_ == NULL) {\n    options_ = new ::google::protobuf::EnumValueOptions;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueDescriptorProto.options)\n  return options_;\n}\n::google::protobuf::EnumValueOptions* EnumValueDescriptorProto::release_options() {\n  // @@protoc_insertion_point(field_release:google.protobuf.EnumValueDescriptorProto.options)\n  clear_has_options();\n  ::google::protobuf::EnumValueOptions* temp = options_;\n  options_ = NULL;\n  return temp;\n}\nvoid EnumValueDescriptorProto::set_allocated_options(::google::protobuf::EnumValueOptions* options) {\n  delete options_;\n  options_ = options;\n  if (options) {\n    set_has_options();\n  } else {\n    clear_has_options();\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValueDescriptorProto.options)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int ServiceDescriptorProto::kNameFieldNumber;\nconst int ServiceDescriptorProto::kMethodFieldNumber;\nconst int ServiceDescriptorProto::kOptionsFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nServiceDescriptorProto::ServiceDescriptorProto()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.ServiceDescriptorProto)\n}\n\nvoid ServiceDescriptorProto::InitAsDefaultInstance() {\n  options_ = const_cast< ::google::protobuf::ServiceOptions*>(&::google::protobuf::ServiceOptions::default_instance());\n}\n\nServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.ServiceDescriptorProto)\n}\n\nvoid ServiceDescriptorProto::SharedCtor() {\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  options_ = NULL;\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nServiceDescriptorProto::~ServiceDescriptorProto() {\n  // @@protoc_insertion_point(destructor:google.protobuf.ServiceDescriptorProto)\n  SharedDtor();\n}\n\nvoid ServiceDescriptorProto::SharedDtor() {\n  name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n    delete options_;\n  }\n}\n\nvoid ServiceDescriptorProto::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* ServiceDescriptorProto::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return ServiceDescriptorProto_descriptor_;\n}\n\nconst ServiceDescriptorProto& ServiceDescriptorProto::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nServiceDescriptorProto* ServiceDescriptorProto::default_instance_ = NULL;\n\nServiceDescriptorProto* ServiceDescriptorProto::New(::google::protobuf::Arena* arena) const {\n  ServiceDescriptorProto* n = new ServiceDescriptorProto;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid ServiceDescriptorProto::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.ServiceDescriptorProto)\n  if (_has_bits_[0 / 32] & 5u) {\n    if (has_name()) {\n      name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    if (has_options()) {\n      if (options_ != NULL) options_->::google::protobuf::ServiceOptions::Clear();\n    }\n  }\n  method_.Clear();\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool ServiceDescriptorProto::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.ServiceDescriptorProto)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional string name = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_name()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->name().data(), this->name().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.ServiceDescriptorProto.name\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_method;\n        break;\n      }\n\n      // repeated .google.protobuf.MethodDescriptorProto method = 2;\n      case 2: {\n        if (tag == 18) {\n         parse_method:\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_method:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_method()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_loop_method;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectTag(26)) goto parse_options;\n        break;\n      }\n\n      // optional .google.protobuf.ServiceOptions options = 3;\n      case 3: {\n        if (tag == 26) {\n         parse_options:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\n               input, mutable_options()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.ServiceDescriptorProto)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.ServiceDescriptorProto)\n  return false;\n#undef DO_\n}\n\nvoid ServiceDescriptorProto::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.ServiceDescriptorProto)\n  // optional string name = 1;\n  if (has_name()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.ServiceDescriptorProto.name\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      1, this->name(), output);\n  }\n\n  // repeated .google.protobuf.MethodDescriptorProto method = 2;\n  for (unsigned int i = 0, n = this->method_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      2, this->method(i), output);\n  }\n\n  // optional .google.protobuf.ServiceOptions options = 3;\n  if (has_options()) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      3, *this->options_, output);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.ServiceDescriptorProto)\n}\n\n::google::protobuf::uint8* ServiceDescriptorProto::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ServiceDescriptorProto)\n  // optional string name = 1;\n  if (has_name()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.ServiceDescriptorProto.name\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        1, this->name(), target);\n  }\n\n  // repeated .google.protobuf.MethodDescriptorProto method = 2;\n  for (unsigned int i = 0, n = this->method_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        2, this->method(i), false, target);\n  }\n\n  // optional .google.protobuf.ServiceOptions options = 3;\n  if (has_options()) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        3, *this->options_, false, target);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.ServiceDescriptorProto)\n  return target;\n}\n\nint ServiceDescriptorProto::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.ServiceDescriptorProto)\n  int total_size = 0;\n\n  if (_has_bits_[0 / 32] & 5u) {\n    // optional string name = 1;\n    if (has_name()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->name());\n    }\n\n    // optional .google.protobuf.ServiceOptions options = 3;\n    if (has_options()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n          *this->options_);\n    }\n\n  }\n  // repeated .google.protobuf.MethodDescriptorProto method = 2;\n  total_size += 1 * this->method_size();\n  for (int i = 0; i < this->method_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->method(i));\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid ServiceDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.ServiceDescriptorProto)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const ServiceDescriptorProto* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const ServiceDescriptorProto>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.ServiceDescriptorProto)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.ServiceDescriptorProto)\n    MergeFrom(*source);\n  }\n}\n\nvoid ServiceDescriptorProto::MergeFrom(const ServiceDescriptorProto& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceDescriptorProto)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  method_.MergeFrom(from.method_);\n  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {\n    if (from.has_name()) {\n      set_has_name();\n      name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);\n    }\n    if (from.has_options()) {\n      mutable_options()->::google::protobuf::ServiceOptions::MergeFrom(from.options());\n    }\n  }\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid ServiceDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.ServiceDescriptorProto)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid ServiceDescriptorProto::CopyFrom(const ServiceDescriptorProto& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.ServiceDescriptorProto)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool ServiceDescriptorProto::IsInitialized() const {\n\n  if (!::google::protobuf::internal::AllAreInitialized(this->method())) return false;\n  if (has_options()) {\n    if (!this->options_->IsInitialized()) return false;\n  }\n  return true;\n}\n\nvoid ServiceDescriptorProto::Swap(ServiceDescriptorProto* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid ServiceDescriptorProto::InternalSwap(ServiceDescriptorProto* other) {\n  name_.Swap(&other->name_);\n  method_.UnsafeArenaSwap(&other->method_);\n  std::swap(options_, other->options_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata ServiceDescriptorProto::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = ServiceDescriptorProto_descriptor_;\n  metadata.reflection = ServiceDescriptorProto_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// ServiceDescriptorProto\n\n// optional string name = 1;\nbool ServiceDescriptorProto::has_name() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\nvoid ServiceDescriptorProto::set_has_name() {\n  _has_bits_[0] |= 0x00000001u;\n}\nvoid ServiceDescriptorProto::clear_has_name() {\n  _has_bits_[0] &= ~0x00000001u;\n}\nvoid ServiceDescriptorProto::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_name();\n}\n const ::std::string& ServiceDescriptorProto::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void ServiceDescriptorProto::set_name(const ::std::string& value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.ServiceDescriptorProto.name)\n}\n void ServiceDescriptorProto::set_name(const char* value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.ServiceDescriptorProto.name)\n}\n void ServiceDescriptorProto::set_name(const char* value, size_t size) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.ServiceDescriptorProto.name)\n}\n ::std::string* ServiceDescriptorProto::mutable_name() {\n  set_has_name();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* ServiceDescriptorProto::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.ServiceDescriptorProto.name)\n  clear_has_name();\n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void ServiceDescriptorProto::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    set_has_name();\n  } else {\n    clear_has_name();\n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.ServiceDescriptorProto.name)\n}\n\n// repeated .google.protobuf.MethodDescriptorProto method = 2;\nint ServiceDescriptorProto::method_size() const {\n  return method_.size();\n}\nvoid ServiceDescriptorProto::clear_method() {\n  method_.Clear();\n}\nconst ::google::protobuf::MethodDescriptorProto& ServiceDescriptorProto::method(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.method)\n  return method_.Get(index);\n}\n::google::protobuf::MethodDescriptorProto* ServiceDescriptorProto::mutable_method(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.method)\n  return method_.Mutable(index);\n}\n::google::protobuf::MethodDescriptorProto* ServiceDescriptorProto::add_method() {\n  // @@protoc_insertion_point(field_add:google.protobuf.ServiceDescriptorProto.method)\n  return method_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >*\nServiceDescriptorProto::mutable_method() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.ServiceDescriptorProto.method)\n  return &method_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >&\nServiceDescriptorProto::method() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.ServiceDescriptorProto.method)\n  return method_;\n}\n\n// optional .google.protobuf.ServiceOptions options = 3;\nbool ServiceDescriptorProto::has_options() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\nvoid ServiceDescriptorProto::set_has_options() {\n  _has_bits_[0] |= 0x00000004u;\n}\nvoid ServiceDescriptorProto::clear_has_options() {\n  _has_bits_[0] &= ~0x00000004u;\n}\nvoid ServiceDescriptorProto::clear_options() {\n  if (options_ != NULL) options_->::google::protobuf::ServiceOptions::Clear();\n  clear_has_options();\n}\nconst ::google::protobuf::ServiceOptions& ServiceDescriptorProto::options() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.options)\n  return options_ != NULL ? *options_ : *default_instance_->options_;\n}\n::google::protobuf::ServiceOptions* ServiceDescriptorProto::mutable_options() {\n  set_has_options();\n  if (options_ == NULL) {\n    options_ = new ::google::protobuf::ServiceOptions;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.options)\n  return options_;\n}\n::google::protobuf::ServiceOptions* ServiceDescriptorProto::release_options() {\n  // @@protoc_insertion_point(field_release:google.protobuf.ServiceDescriptorProto.options)\n  clear_has_options();\n  ::google::protobuf::ServiceOptions* temp = options_;\n  options_ = NULL;\n  return temp;\n}\nvoid ServiceDescriptorProto::set_allocated_options(::google::protobuf::ServiceOptions* options) {\n  delete options_;\n  options_ = options;\n  if (options) {\n    set_has_options();\n  } else {\n    clear_has_options();\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.ServiceDescriptorProto.options)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int MethodDescriptorProto::kNameFieldNumber;\nconst int MethodDescriptorProto::kInputTypeFieldNumber;\nconst int MethodDescriptorProto::kOutputTypeFieldNumber;\nconst int MethodDescriptorProto::kOptionsFieldNumber;\nconst int MethodDescriptorProto::kClientStreamingFieldNumber;\nconst int MethodDescriptorProto::kServerStreamingFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nMethodDescriptorProto::MethodDescriptorProto()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.MethodDescriptorProto)\n}\n\nvoid MethodDescriptorProto::InitAsDefaultInstance() {\n  options_ = const_cast< ::google::protobuf::MethodOptions*>(&::google::protobuf::MethodOptions::default_instance());\n}\n\nMethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.MethodDescriptorProto)\n}\n\nvoid MethodDescriptorProto::SharedCtor() {\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  input_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  output_type_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  options_ = NULL;\n  client_streaming_ = false;\n  server_streaming_ = false;\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nMethodDescriptorProto::~MethodDescriptorProto() {\n  // @@protoc_insertion_point(destructor:google.protobuf.MethodDescriptorProto)\n  SharedDtor();\n}\n\nvoid MethodDescriptorProto::SharedDtor() {\n  name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  input_type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  output_type_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n    delete options_;\n  }\n}\n\nvoid MethodDescriptorProto::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* MethodDescriptorProto::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return MethodDescriptorProto_descriptor_;\n}\n\nconst MethodDescriptorProto& MethodDescriptorProto::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nMethodDescriptorProto* MethodDescriptorProto::default_instance_ = NULL;\n\nMethodDescriptorProto* MethodDescriptorProto::New(::google::protobuf::Arena* arena) const {\n  MethodDescriptorProto* n = new MethodDescriptorProto;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid MethodDescriptorProto::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.MethodDescriptorProto)\n#if defined(__clang__)\n#define ZR_HELPER_(f) \\\n  _Pragma(\"clang diagnostic push\") \\\n  _Pragma(\"clang diagnostic ignored \\\"-Winvalid-offsetof\\\"\") \\\n  __builtin_offsetof(MethodDescriptorProto, f) \\\n  _Pragma(\"clang diagnostic pop\")\n#else\n#define ZR_HELPER_(f) reinterpret_cast<char*>(\\\n  &reinterpret_cast<MethodDescriptorProto*>(16)->f)\n#endif\n\n#define ZR_(first, last) do {\\\n  ::memset(&first, 0,\\\n           ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\\\n} while (0)\n\n  if (_has_bits_[0 / 32] & 63u) {\n    ZR_(client_streaming_, server_streaming_);\n    if (has_name()) {\n      name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    if (has_input_type()) {\n      input_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    if (has_output_type()) {\n      output_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    if (has_options()) {\n      if (options_ != NULL) options_->::google::protobuf::MethodOptions::Clear();\n    }\n  }\n\n#undef ZR_HELPER_\n#undef ZR_\n\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool MethodDescriptorProto::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.MethodDescriptorProto)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional string name = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_name()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->name().data(), this->name().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.MethodDescriptorProto.name\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_input_type;\n        break;\n      }\n\n      // optional string input_type = 2;\n      case 2: {\n        if (tag == 18) {\n         parse_input_type:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_input_type()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->input_type().data(), this->input_type().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.MethodDescriptorProto.input_type\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(26)) goto parse_output_type;\n        break;\n      }\n\n      // optional string output_type = 3;\n      case 3: {\n        if (tag == 26) {\n         parse_output_type:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_output_type()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->output_type().data(), this->output_type().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.MethodDescriptorProto.output_type\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(34)) goto parse_options;\n        break;\n      }\n\n      // optional .google.protobuf.MethodOptions options = 4;\n      case 4: {\n        if (tag == 34) {\n         parse_options:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\n               input, mutable_options()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(40)) goto parse_client_streaming;\n        break;\n      }\n\n      // optional bool client_streaming = 5 [default = false];\n      case 5: {\n        if (tag == 40) {\n         parse_client_streaming:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &client_streaming_)));\n          set_has_client_streaming();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(48)) goto parse_server_streaming;\n        break;\n      }\n\n      // optional bool server_streaming = 6 [default = false];\n      case 6: {\n        if (tag == 48) {\n         parse_server_streaming:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &server_streaming_)));\n          set_has_server_streaming();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.MethodDescriptorProto)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.MethodDescriptorProto)\n  return false;\n#undef DO_\n}\n\nvoid MethodDescriptorProto::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.MethodDescriptorProto)\n  // optional string name = 1;\n  if (has_name()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.MethodDescriptorProto.name\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      1, this->name(), output);\n  }\n\n  // optional string input_type = 2;\n  if (has_input_type()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->input_type().data(), this->input_type().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.MethodDescriptorProto.input_type\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      2, this->input_type(), output);\n  }\n\n  // optional string output_type = 3;\n  if (has_output_type()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->output_type().data(), this->output_type().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.MethodDescriptorProto.output_type\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      3, this->output_type(), output);\n  }\n\n  // optional .google.protobuf.MethodOptions options = 4;\n  if (has_options()) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      4, *this->options_, output);\n  }\n\n  // optional bool client_streaming = 5 [default = false];\n  if (has_client_streaming()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(5, this->client_streaming(), output);\n  }\n\n  // optional bool server_streaming = 6 [default = false];\n  if (has_server_streaming()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(6, this->server_streaming(), output);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.MethodDescriptorProto)\n}\n\n::google::protobuf::uint8* MethodDescriptorProto::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.MethodDescriptorProto)\n  // optional string name = 1;\n  if (has_name()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.MethodDescriptorProto.name\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        1, this->name(), target);\n  }\n\n  // optional string input_type = 2;\n  if (has_input_type()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->input_type().data(), this->input_type().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.MethodDescriptorProto.input_type\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        2, this->input_type(), target);\n  }\n\n  // optional string output_type = 3;\n  if (has_output_type()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->output_type().data(), this->output_type().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.MethodDescriptorProto.output_type\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        3, this->output_type(), target);\n  }\n\n  // optional .google.protobuf.MethodOptions options = 4;\n  if (has_options()) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        4, *this->options_, false, target);\n  }\n\n  // optional bool client_streaming = 5 [default = false];\n  if (has_client_streaming()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(5, this->client_streaming(), target);\n  }\n\n  // optional bool server_streaming = 6 [default = false];\n  if (has_server_streaming()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(6, this->server_streaming(), target);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.MethodDescriptorProto)\n  return target;\n}\n\nint MethodDescriptorProto::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.MethodDescriptorProto)\n  int total_size = 0;\n\n  if (_has_bits_[0 / 32] & 63u) {\n    // optional string name = 1;\n    if (has_name()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->name());\n    }\n\n    // optional string input_type = 2;\n    if (has_input_type()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->input_type());\n    }\n\n    // optional string output_type = 3;\n    if (has_output_type()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->output_type());\n    }\n\n    // optional .google.protobuf.MethodOptions options = 4;\n    if (has_options()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n          *this->options_);\n    }\n\n    // optional bool client_streaming = 5 [default = false];\n    if (has_client_streaming()) {\n      total_size += 1 + 1;\n    }\n\n    // optional bool server_streaming = 6 [default = false];\n    if (has_server_streaming()) {\n      total_size += 1 + 1;\n    }\n\n  }\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid MethodDescriptorProto::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.MethodDescriptorProto)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const MethodDescriptorProto* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const MethodDescriptorProto>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.MethodDescriptorProto)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.MethodDescriptorProto)\n    MergeFrom(*source);\n  }\n}\n\nvoid MethodDescriptorProto::MergeFrom(const MethodDescriptorProto& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodDescriptorProto)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {\n    if (from.has_name()) {\n      set_has_name();\n      name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);\n    }\n    if (from.has_input_type()) {\n      set_has_input_type();\n      input_type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.input_type_);\n    }\n    if (from.has_output_type()) {\n      set_has_output_type();\n      output_type_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.output_type_);\n    }\n    if (from.has_options()) {\n      mutable_options()->::google::protobuf::MethodOptions::MergeFrom(from.options());\n    }\n    if (from.has_client_streaming()) {\n      set_client_streaming(from.client_streaming());\n    }\n    if (from.has_server_streaming()) {\n      set_server_streaming(from.server_streaming());\n    }\n  }\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid MethodDescriptorProto::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.MethodDescriptorProto)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid MethodDescriptorProto::CopyFrom(const MethodDescriptorProto& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.MethodDescriptorProto)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool MethodDescriptorProto::IsInitialized() const {\n\n  if (has_options()) {\n    if (!this->options_->IsInitialized()) return false;\n  }\n  return true;\n}\n\nvoid MethodDescriptorProto::Swap(MethodDescriptorProto* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid MethodDescriptorProto::InternalSwap(MethodDescriptorProto* other) {\n  name_.Swap(&other->name_);\n  input_type_.Swap(&other->input_type_);\n  output_type_.Swap(&other->output_type_);\n  std::swap(options_, other->options_);\n  std::swap(client_streaming_, other->client_streaming_);\n  std::swap(server_streaming_, other->server_streaming_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata MethodDescriptorProto::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = MethodDescriptorProto_descriptor_;\n  metadata.reflection = MethodDescriptorProto_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// MethodDescriptorProto\n\n// optional string name = 1;\nbool MethodDescriptorProto::has_name() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\nvoid MethodDescriptorProto::set_has_name() {\n  _has_bits_[0] |= 0x00000001u;\n}\nvoid MethodDescriptorProto::clear_has_name() {\n  _has_bits_[0] &= ~0x00000001u;\n}\nvoid MethodDescriptorProto::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_name();\n}\n const ::std::string& MethodDescriptorProto::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void MethodDescriptorProto::set_name(const ::std::string& value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.name)\n}\n void MethodDescriptorProto::set_name(const char* value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.name)\n}\n void MethodDescriptorProto::set_name(const char* value, size_t size) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.name)\n}\n ::std::string* MethodDescriptorProto::mutable_name() {\n  set_has_name();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* MethodDescriptorProto::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.name)\n  clear_has_name();\n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void MethodDescriptorProto::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    set_has_name();\n  } else {\n    clear_has_name();\n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.name)\n}\n\n// optional string input_type = 2;\nbool MethodDescriptorProto::has_input_type() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\nvoid MethodDescriptorProto::set_has_input_type() {\n  _has_bits_[0] |= 0x00000002u;\n}\nvoid MethodDescriptorProto::clear_has_input_type() {\n  _has_bits_[0] &= ~0x00000002u;\n}\nvoid MethodDescriptorProto::clear_input_type() {\n  input_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_input_type();\n}\n const ::std::string& MethodDescriptorProto::input_type() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.input_type)\n  return input_type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void MethodDescriptorProto::set_input_type(const ::std::string& value) {\n  set_has_input_type();\n  input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.input_type)\n}\n void MethodDescriptorProto::set_input_type(const char* value) {\n  set_has_input_type();\n  input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.input_type)\n}\n void MethodDescriptorProto::set_input_type(const char* value, size_t size) {\n  set_has_input_type();\n  input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.input_type)\n}\n ::std::string* MethodDescriptorProto::mutable_input_type() {\n  set_has_input_type();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.input_type)\n  return input_type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* MethodDescriptorProto::release_input_type() {\n  // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.input_type)\n  clear_has_input_type();\n  return input_type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void MethodDescriptorProto::set_allocated_input_type(::std::string* input_type) {\n  if (input_type != NULL) {\n    set_has_input_type();\n  } else {\n    clear_has_input_type();\n  }\n  input_type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), input_type);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.input_type)\n}\n\n// optional string output_type = 3;\nbool MethodDescriptorProto::has_output_type() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\nvoid MethodDescriptorProto::set_has_output_type() {\n  _has_bits_[0] |= 0x00000004u;\n}\nvoid MethodDescriptorProto::clear_has_output_type() {\n  _has_bits_[0] &= ~0x00000004u;\n}\nvoid MethodDescriptorProto::clear_output_type() {\n  output_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_output_type();\n}\n const ::std::string& MethodDescriptorProto::output_type() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.output_type)\n  return output_type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void MethodDescriptorProto::set_output_type(const ::std::string& value) {\n  set_has_output_type();\n  output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.output_type)\n}\n void MethodDescriptorProto::set_output_type(const char* value) {\n  set_has_output_type();\n  output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.output_type)\n}\n void MethodDescriptorProto::set_output_type(const char* value, size_t size) {\n  set_has_output_type();\n  output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.output_type)\n}\n ::std::string* MethodDescriptorProto::mutable_output_type() {\n  set_has_output_type();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.output_type)\n  return output_type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* MethodDescriptorProto::release_output_type() {\n  // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.output_type)\n  clear_has_output_type();\n  return output_type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void MethodDescriptorProto::set_allocated_output_type(::std::string* output_type) {\n  if (output_type != NULL) {\n    set_has_output_type();\n  } else {\n    clear_has_output_type();\n  }\n  output_type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), output_type);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.output_type)\n}\n\n// optional .google.protobuf.MethodOptions options = 4;\nbool MethodDescriptorProto::has_options() const {\n  return (_has_bits_[0] & 0x00000008u) != 0;\n}\nvoid MethodDescriptorProto::set_has_options() {\n  _has_bits_[0] |= 0x00000008u;\n}\nvoid MethodDescriptorProto::clear_has_options() {\n  _has_bits_[0] &= ~0x00000008u;\n}\nvoid MethodDescriptorProto::clear_options() {\n  if (options_ != NULL) options_->::google::protobuf::MethodOptions::Clear();\n  clear_has_options();\n}\nconst ::google::protobuf::MethodOptions& MethodDescriptorProto::options() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.options)\n  return options_ != NULL ? *options_ : *default_instance_->options_;\n}\n::google::protobuf::MethodOptions* MethodDescriptorProto::mutable_options() {\n  set_has_options();\n  if (options_ == NULL) {\n    options_ = new ::google::protobuf::MethodOptions;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.options)\n  return options_;\n}\n::google::protobuf::MethodOptions* MethodDescriptorProto::release_options() {\n  // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.options)\n  clear_has_options();\n  ::google::protobuf::MethodOptions* temp = options_;\n  options_ = NULL;\n  return temp;\n}\nvoid MethodDescriptorProto::set_allocated_options(::google::protobuf::MethodOptions* options) {\n  delete options_;\n  options_ = options;\n  if (options) {\n    set_has_options();\n  } else {\n    clear_has_options();\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.options)\n}\n\n// optional bool client_streaming = 5 [default = false];\nbool MethodDescriptorProto::has_client_streaming() const {\n  return (_has_bits_[0] & 0x00000010u) != 0;\n}\nvoid MethodDescriptorProto::set_has_client_streaming() {\n  _has_bits_[0] |= 0x00000010u;\n}\nvoid MethodDescriptorProto::clear_has_client_streaming() {\n  _has_bits_[0] &= ~0x00000010u;\n}\nvoid MethodDescriptorProto::clear_client_streaming() {\n  client_streaming_ = false;\n  clear_has_client_streaming();\n}\n bool MethodDescriptorProto::client_streaming() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.client_streaming)\n  return client_streaming_;\n}\n void MethodDescriptorProto::set_client_streaming(bool value) {\n  set_has_client_streaming();\n  client_streaming_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.client_streaming)\n}\n\n// optional bool server_streaming = 6 [default = false];\nbool MethodDescriptorProto::has_server_streaming() const {\n  return (_has_bits_[0] & 0x00000020u) != 0;\n}\nvoid MethodDescriptorProto::set_has_server_streaming() {\n  _has_bits_[0] |= 0x00000020u;\n}\nvoid MethodDescriptorProto::clear_has_server_streaming() {\n  _has_bits_[0] &= ~0x00000020u;\n}\nvoid MethodDescriptorProto::clear_server_streaming() {\n  server_streaming_ = false;\n  clear_has_server_streaming();\n}\n bool MethodDescriptorProto::server_streaming() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.server_streaming)\n  return server_streaming_;\n}\n void MethodDescriptorProto::set_server_streaming(bool value) {\n  set_has_server_streaming();\n  server_streaming_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.server_streaming)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\nconst ::google::protobuf::EnumDescriptor* FileOptions_OptimizeMode_descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return FileOptions_OptimizeMode_descriptor_;\n}\nbool FileOptions_OptimizeMode_IsValid(int value) {\n  switch(value) {\n    case 1:\n    case 2:\n    case 3:\n      return true;\n    default:\n      return false;\n  }\n}\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst FileOptions_OptimizeMode FileOptions::SPEED;\nconst FileOptions_OptimizeMode FileOptions::CODE_SIZE;\nconst FileOptions_OptimizeMode FileOptions::LITE_RUNTIME;\nconst FileOptions_OptimizeMode FileOptions::OptimizeMode_MIN;\nconst FileOptions_OptimizeMode FileOptions::OptimizeMode_MAX;\nconst int FileOptions::OptimizeMode_ARRAYSIZE;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int FileOptions::kJavaPackageFieldNumber;\nconst int FileOptions::kJavaOuterClassnameFieldNumber;\nconst int FileOptions::kJavaMultipleFilesFieldNumber;\nconst int FileOptions::kJavaGenerateEqualsAndHashFieldNumber;\nconst int FileOptions::kJavaStringCheckUtf8FieldNumber;\nconst int FileOptions::kOptimizeForFieldNumber;\nconst int FileOptions::kGoPackageFieldNumber;\nconst int FileOptions::kCcGenericServicesFieldNumber;\nconst int FileOptions::kJavaGenericServicesFieldNumber;\nconst int FileOptions::kPyGenericServicesFieldNumber;\nconst int FileOptions::kDeprecatedFieldNumber;\nconst int FileOptions::kCcEnableArenasFieldNumber;\nconst int FileOptions::kObjcClassPrefixFieldNumber;\nconst int FileOptions::kCsharpNamespaceFieldNumber;\nconst int FileOptions::kUninterpretedOptionFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nFileOptions::FileOptions()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.FileOptions)\n}\n\nvoid FileOptions::InitAsDefaultInstance() {\n}\n\nFileOptions::FileOptions(const FileOptions& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.FileOptions)\n}\n\nvoid FileOptions::SharedCtor() {\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  java_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  java_outer_classname_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  java_multiple_files_ = false;\n  java_generate_equals_and_hash_ = false;\n  java_string_check_utf8_ = false;\n  optimize_for_ = 1;\n  go_package_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  cc_generic_services_ = false;\n  java_generic_services_ = false;\n  py_generic_services_ = false;\n  deprecated_ = false;\n  cc_enable_arenas_ = false;\n  objc_class_prefix_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  csharp_namespace_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nFileOptions::~FileOptions() {\n  // @@protoc_insertion_point(destructor:google.protobuf.FileOptions)\n  SharedDtor();\n}\n\nvoid FileOptions::SharedDtor() {\n  java_package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  java_outer_classname_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  go_package_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  objc_class_prefix_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  csharp_namespace_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n  }\n}\n\nvoid FileOptions::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* FileOptions::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return FileOptions_descriptor_;\n}\n\nconst FileOptions& FileOptions::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nFileOptions* FileOptions::default_instance_ = NULL;\n\nFileOptions* FileOptions::New(::google::protobuf::Arena* arena) const {\n  FileOptions* n = new FileOptions;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid FileOptions::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.FileOptions)\n  _extensions_.Clear();\n#if defined(__clang__)\n#define ZR_HELPER_(f) \\\n  _Pragma(\"clang diagnostic push\") \\\n  _Pragma(\"clang diagnostic ignored \\\"-Winvalid-offsetof\\\"\") \\\n  __builtin_offsetof(FileOptions, f) \\\n  _Pragma(\"clang diagnostic pop\")\n#else\n#define ZR_HELPER_(f) reinterpret_cast<char*>(\\\n  &reinterpret_cast<FileOptions*>(16)->f)\n#endif\n\n#define ZR_(first, last) do {\\\n  ::memset(&first, 0,\\\n           ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\\\n} while (0)\n\n  if (_has_bits_[0 / 32] & 255u) {\n    ZR_(java_multiple_files_, cc_generic_services_);\n    if (has_java_package()) {\n      java_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    if (has_java_outer_classname()) {\n      java_outer_classname_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    optimize_for_ = 1;\n    if (has_go_package()) {\n      go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n  }\n  if (_has_bits_[8 / 32] & 16128u) {\n    ZR_(java_generic_services_, cc_enable_arenas_);\n    if (has_objc_class_prefix()) {\n      objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    if (has_csharp_namespace()) {\n      csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n  }\n\n#undef ZR_HELPER_\n#undef ZR_\n\n  uninterpreted_option_.Clear();\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool FileOptions::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.FileOptions)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional string java_package = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_java_package()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->java_package().data(), this->java_package().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.FileOptions.java_package\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(66)) goto parse_java_outer_classname;\n        break;\n      }\n\n      // optional string java_outer_classname = 8;\n      case 8: {\n        if (tag == 66) {\n         parse_java_outer_classname:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_java_outer_classname()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->java_outer_classname().data(), this->java_outer_classname().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.FileOptions.java_outer_classname\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(72)) goto parse_optimize_for;\n        break;\n      }\n\n      // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];\n      case 9: {\n        if (tag == 72) {\n         parse_optimize_for:\n          int value;\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n                 input, &value)));\n          if (::google::protobuf::FileOptions_OptimizeMode_IsValid(value)) {\n            set_optimize_for(static_cast< ::google::protobuf::FileOptions_OptimizeMode >(value));\n          } else {\n            mutable_unknown_fields()->AddVarint(9, value);\n          }\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(80)) goto parse_java_multiple_files;\n        break;\n      }\n\n      // optional bool java_multiple_files = 10 [default = false];\n      case 10: {\n        if (tag == 80) {\n         parse_java_multiple_files:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &java_multiple_files_)));\n          set_has_java_multiple_files();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(90)) goto parse_go_package;\n        break;\n      }\n\n      // optional string go_package = 11;\n      case 11: {\n        if (tag == 90) {\n         parse_go_package:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_go_package()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->go_package().data(), this->go_package().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.FileOptions.go_package\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(128)) goto parse_cc_generic_services;\n        break;\n      }\n\n      // optional bool cc_generic_services = 16 [default = false];\n      case 16: {\n        if (tag == 128) {\n         parse_cc_generic_services:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &cc_generic_services_)));\n          set_has_cc_generic_services();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(136)) goto parse_java_generic_services;\n        break;\n      }\n\n      // optional bool java_generic_services = 17 [default = false];\n      case 17: {\n        if (tag == 136) {\n         parse_java_generic_services:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &java_generic_services_)));\n          set_has_java_generic_services();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(144)) goto parse_py_generic_services;\n        break;\n      }\n\n      // optional bool py_generic_services = 18 [default = false];\n      case 18: {\n        if (tag == 144) {\n         parse_py_generic_services:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &py_generic_services_)));\n          set_has_py_generic_services();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(160)) goto parse_java_generate_equals_and_hash;\n        break;\n      }\n\n      // optional bool java_generate_equals_and_hash = 20 [default = false];\n      case 20: {\n        if (tag == 160) {\n         parse_java_generate_equals_and_hash:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &java_generate_equals_and_hash_)));\n          set_has_java_generate_equals_and_hash();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(184)) goto parse_deprecated;\n        break;\n      }\n\n      // optional bool deprecated = 23 [default = false];\n      case 23: {\n        if (tag == 184) {\n         parse_deprecated:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &deprecated_)));\n          set_has_deprecated();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(216)) goto parse_java_string_check_utf8;\n        break;\n      }\n\n      // optional bool java_string_check_utf8 = 27 [default = false];\n      case 27: {\n        if (tag == 216) {\n         parse_java_string_check_utf8:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &java_string_check_utf8_)));\n          set_has_java_string_check_utf8();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(248)) goto parse_cc_enable_arenas;\n        break;\n      }\n\n      // optional bool cc_enable_arenas = 31 [default = false];\n      case 31: {\n        if (tag == 248) {\n         parse_cc_enable_arenas:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &cc_enable_arenas_)));\n          set_has_cc_enable_arenas();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(290)) goto parse_objc_class_prefix;\n        break;\n      }\n\n      // optional string objc_class_prefix = 36;\n      case 36: {\n        if (tag == 290) {\n         parse_objc_class_prefix:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_objc_class_prefix()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->objc_class_prefix().data(), this->objc_class_prefix().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.FileOptions.objc_class_prefix\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(298)) goto parse_csharp_namespace;\n        break;\n      }\n\n      // optional string csharp_namespace = 37;\n      case 37: {\n        if (tag == 298) {\n         parse_csharp_namespace:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_csharp_namespace()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->csharp_namespace().data(), this->csharp_namespace().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.FileOptions.csharp_namespace\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(7994)) goto parse_uninterpreted_option;\n        break;\n      }\n\n      // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n      case 999: {\n        if (tag == 7994) {\n         parse_uninterpreted_option:\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_uninterpreted_option:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_uninterpreted_option()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        if ((8000u <= tag)) {\n          DO_(_extensions_.ParseField(tag, input, default_instance_,\n                                      mutable_unknown_fields()));\n          continue;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.FileOptions)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.FileOptions)\n  return false;\n#undef DO_\n}\n\nvoid FileOptions::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.FileOptions)\n  // optional string java_package = 1;\n  if (has_java_package()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->java_package().data(), this->java_package().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FileOptions.java_package\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      1, this->java_package(), output);\n  }\n\n  // optional string java_outer_classname = 8;\n  if (has_java_outer_classname()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->java_outer_classname().data(), this->java_outer_classname().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FileOptions.java_outer_classname\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      8, this->java_outer_classname(), output);\n  }\n\n  // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];\n  if (has_optimize_for()) {\n    ::google::protobuf::internal::WireFormatLite::WriteEnum(\n      9, this->optimize_for(), output);\n  }\n\n  // optional bool java_multiple_files = 10 [default = false];\n  if (has_java_multiple_files()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(10, this->java_multiple_files(), output);\n  }\n\n  // optional string go_package = 11;\n  if (has_go_package()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->go_package().data(), this->go_package().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FileOptions.go_package\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      11, this->go_package(), output);\n  }\n\n  // optional bool cc_generic_services = 16 [default = false];\n  if (has_cc_generic_services()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(16, this->cc_generic_services(), output);\n  }\n\n  // optional bool java_generic_services = 17 [default = false];\n  if (has_java_generic_services()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(17, this->java_generic_services(), output);\n  }\n\n  // optional bool py_generic_services = 18 [default = false];\n  if (has_py_generic_services()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(18, this->py_generic_services(), output);\n  }\n\n  // optional bool java_generate_equals_and_hash = 20 [default = false];\n  if (has_java_generate_equals_and_hash()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(20, this->java_generate_equals_and_hash(), output);\n  }\n\n  // optional bool deprecated = 23 [default = false];\n  if (has_deprecated()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(23, this->deprecated(), output);\n  }\n\n  // optional bool java_string_check_utf8 = 27 [default = false];\n  if (has_java_string_check_utf8()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(27, this->java_string_check_utf8(), output);\n  }\n\n  // optional bool cc_enable_arenas = 31 [default = false];\n  if (has_cc_enable_arenas()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(31, this->cc_enable_arenas(), output);\n  }\n\n  // optional string objc_class_prefix = 36;\n  if (has_objc_class_prefix()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->objc_class_prefix().data(), this->objc_class_prefix().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FileOptions.objc_class_prefix\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      36, this->objc_class_prefix(), output);\n  }\n\n  // optional string csharp_namespace = 37;\n  if (has_csharp_namespace()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->csharp_namespace().data(), this->csharp_namespace().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FileOptions.csharp_namespace\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      37, this->csharp_namespace(), output);\n  }\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      999, this->uninterpreted_option(i), output);\n  }\n\n  // Extension range [1000, 536870912)\n  _extensions_.SerializeWithCachedSizes(\n      1000, 536870912, output);\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.FileOptions)\n}\n\n::google::protobuf::uint8* FileOptions::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FileOptions)\n  // optional string java_package = 1;\n  if (has_java_package()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->java_package().data(), this->java_package().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FileOptions.java_package\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        1, this->java_package(), target);\n  }\n\n  // optional string java_outer_classname = 8;\n  if (has_java_outer_classname()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->java_outer_classname().data(), this->java_outer_classname().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FileOptions.java_outer_classname\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        8, this->java_outer_classname(), target);\n  }\n\n  // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];\n  if (has_optimize_for()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(\n      9, this->optimize_for(), target);\n  }\n\n  // optional bool java_multiple_files = 10 [default = false];\n  if (has_java_multiple_files()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(10, this->java_multiple_files(), target);\n  }\n\n  // optional string go_package = 11;\n  if (has_go_package()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->go_package().data(), this->go_package().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FileOptions.go_package\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        11, this->go_package(), target);\n  }\n\n  // optional bool cc_generic_services = 16 [default = false];\n  if (has_cc_generic_services()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(16, this->cc_generic_services(), target);\n  }\n\n  // optional bool java_generic_services = 17 [default = false];\n  if (has_java_generic_services()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(17, this->java_generic_services(), target);\n  }\n\n  // optional bool py_generic_services = 18 [default = false];\n  if (has_py_generic_services()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(18, this->py_generic_services(), target);\n  }\n\n  // optional bool java_generate_equals_and_hash = 20 [default = false];\n  if (has_java_generate_equals_and_hash()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(20, this->java_generate_equals_and_hash(), target);\n  }\n\n  // optional bool deprecated = 23 [default = false];\n  if (has_deprecated()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(23, this->deprecated(), target);\n  }\n\n  // optional bool java_string_check_utf8 = 27 [default = false];\n  if (has_java_string_check_utf8()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(27, this->java_string_check_utf8(), target);\n  }\n\n  // optional bool cc_enable_arenas = 31 [default = false];\n  if (has_cc_enable_arenas()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(31, this->cc_enable_arenas(), target);\n  }\n\n  // optional string objc_class_prefix = 36;\n  if (has_objc_class_prefix()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->objc_class_prefix().data(), this->objc_class_prefix().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FileOptions.objc_class_prefix\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        36, this->objc_class_prefix(), target);\n  }\n\n  // optional string csharp_namespace = 37;\n  if (has_csharp_namespace()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->csharp_namespace().data(), this->csharp_namespace().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.FileOptions.csharp_namespace\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        37, this->csharp_namespace(), target);\n  }\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        999, this->uninterpreted_option(i), false, target);\n  }\n\n  // Extension range [1000, 536870912)\n  target = _extensions_.InternalSerializeWithCachedSizesToArray(\n      1000, 536870912, false, target);\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FileOptions)\n  return target;\n}\n\nint FileOptions::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FileOptions)\n  int total_size = 0;\n\n  if (_has_bits_[0 / 32] & 255u) {\n    // optional string java_package = 1;\n    if (has_java_package()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->java_package());\n    }\n\n    // optional string java_outer_classname = 8;\n    if (has_java_outer_classname()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->java_outer_classname());\n    }\n\n    // optional bool java_multiple_files = 10 [default = false];\n    if (has_java_multiple_files()) {\n      total_size += 1 + 1;\n    }\n\n    // optional bool java_generate_equals_and_hash = 20 [default = false];\n    if (has_java_generate_equals_and_hash()) {\n      total_size += 2 + 1;\n    }\n\n    // optional bool java_string_check_utf8 = 27 [default = false];\n    if (has_java_string_check_utf8()) {\n      total_size += 2 + 1;\n    }\n\n    // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];\n    if (has_optimize_for()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::EnumSize(this->optimize_for());\n    }\n\n    // optional string go_package = 11;\n    if (has_go_package()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->go_package());\n    }\n\n    // optional bool cc_generic_services = 16 [default = false];\n    if (has_cc_generic_services()) {\n      total_size += 2 + 1;\n    }\n\n  }\n  if (_has_bits_[8 / 32] & 16128u) {\n    // optional bool java_generic_services = 17 [default = false];\n    if (has_java_generic_services()) {\n      total_size += 2 + 1;\n    }\n\n    // optional bool py_generic_services = 18 [default = false];\n    if (has_py_generic_services()) {\n      total_size += 2 + 1;\n    }\n\n    // optional bool deprecated = 23 [default = false];\n    if (has_deprecated()) {\n      total_size += 2 + 1;\n    }\n\n    // optional bool cc_enable_arenas = 31 [default = false];\n    if (has_cc_enable_arenas()) {\n      total_size += 2 + 1;\n    }\n\n    // optional string objc_class_prefix = 36;\n    if (has_objc_class_prefix()) {\n      total_size += 2 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->objc_class_prefix());\n    }\n\n    // optional string csharp_namespace = 37;\n    if (has_csharp_namespace()) {\n      total_size += 2 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->csharp_namespace());\n    }\n\n  }\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  total_size += 2 * this->uninterpreted_option_size();\n  for (int i = 0; i < this->uninterpreted_option_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->uninterpreted_option(i));\n  }\n\n  total_size += _extensions_.ByteSize();\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid FileOptions::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FileOptions)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const FileOptions* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const FileOptions>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.FileOptions)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FileOptions)\n    MergeFrom(*source);\n  }\n}\n\nvoid FileOptions::MergeFrom(const FileOptions& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FileOptions)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  uninterpreted_option_.MergeFrom(from.uninterpreted_option_);\n  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {\n    if (from.has_java_package()) {\n      set_has_java_package();\n      java_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_package_);\n    }\n    if (from.has_java_outer_classname()) {\n      set_has_java_outer_classname();\n      java_outer_classname_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.java_outer_classname_);\n    }\n    if (from.has_java_multiple_files()) {\n      set_java_multiple_files(from.java_multiple_files());\n    }\n    if (from.has_java_generate_equals_and_hash()) {\n      set_java_generate_equals_and_hash(from.java_generate_equals_and_hash());\n    }\n    if (from.has_java_string_check_utf8()) {\n      set_java_string_check_utf8(from.java_string_check_utf8());\n    }\n    if (from.has_optimize_for()) {\n      set_optimize_for(from.optimize_for());\n    }\n    if (from.has_go_package()) {\n      set_has_go_package();\n      go_package_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.go_package_);\n    }\n    if (from.has_cc_generic_services()) {\n      set_cc_generic_services(from.cc_generic_services());\n    }\n  }\n  if (from._has_bits_[8 / 32] & (0xffu << (8 % 32))) {\n    if (from.has_java_generic_services()) {\n      set_java_generic_services(from.java_generic_services());\n    }\n    if (from.has_py_generic_services()) {\n      set_py_generic_services(from.py_generic_services());\n    }\n    if (from.has_deprecated()) {\n      set_deprecated(from.deprecated());\n    }\n    if (from.has_cc_enable_arenas()) {\n      set_cc_enable_arenas(from.cc_enable_arenas());\n    }\n    if (from.has_objc_class_prefix()) {\n      set_has_objc_class_prefix();\n      objc_class_prefix_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.objc_class_prefix_);\n    }\n    if (from.has_csharp_namespace()) {\n      set_has_csharp_namespace();\n      csharp_namespace_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.csharp_namespace_);\n    }\n  }\n  _extensions_.MergeFrom(from._extensions_);\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid FileOptions::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.FileOptions)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid FileOptions::CopyFrom(const FileOptions& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FileOptions)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool FileOptions::IsInitialized() const {\n\n  if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;\n\n  if (!_extensions_.IsInitialized()) return false;  return true;\n}\n\nvoid FileOptions::Swap(FileOptions* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid FileOptions::InternalSwap(FileOptions* other) {\n  java_package_.Swap(&other->java_package_);\n  java_outer_classname_.Swap(&other->java_outer_classname_);\n  std::swap(java_multiple_files_, other->java_multiple_files_);\n  std::swap(java_generate_equals_and_hash_, other->java_generate_equals_and_hash_);\n  std::swap(java_string_check_utf8_, other->java_string_check_utf8_);\n  std::swap(optimize_for_, other->optimize_for_);\n  go_package_.Swap(&other->go_package_);\n  std::swap(cc_generic_services_, other->cc_generic_services_);\n  std::swap(java_generic_services_, other->java_generic_services_);\n  std::swap(py_generic_services_, other->py_generic_services_);\n  std::swap(deprecated_, other->deprecated_);\n  std::swap(cc_enable_arenas_, other->cc_enable_arenas_);\n  objc_class_prefix_.Swap(&other->objc_class_prefix_);\n  csharp_namespace_.Swap(&other->csharp_namespace_);\n  uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n  _extensions_.Swap(&other->_extensions_);\n}\n\n::google::protobuf::Metadata FileOptions::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = FileOptions_descriptor_;\n  metadata.reflection = FileOptions_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// FileOptions\n\n// optional string java_package = 1;\nbool FileOptions::has_java_package() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\nvoid FileOptions::set_has_java_package() {\n  _has_bits_[0] |= 0x00000001u;\n}\nvoid FileOptions::clear_has_java_package() {\n  _has_bits_[0] &= ~0x00000001u;\n}\nvoid FileOptions::clear_java_package() {\n  java_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_java_package();\n}\n const ::std::string& FileOptions::java_package() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_package)\n  return java_package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FileOptions::set_java_package(const ::std::string& value) {\n  set_has_java_package();\n  java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_package)\n}\n void FileOptions::set_java_package(const char* value) {\n  set_has_java_package();\n  java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.java_package)\n}\n void FileOptions::set_java_package(const char* value, size_t size) {\n  set_has_java_package();\n  java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.java_package)\n}\n ::std::string* FileOptions::mutable_java_package() {\n  set_has_java_package();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.java_package)\n  return java_package_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* FileOptions::release_java_package() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.java_package)\n  clear_has_java_package();\n  return java_package_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FileOptions::set_allocated_java_package(::std::string* java_package) {\n  if (java_package != NULL) {\n    set_has_java_package();\n  } else {\n    clear_has_java_package();\n  }\n  java_package_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), java_package);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.java_package)\n}\n\n// optional string java_outer_classname = 8;\nbool FileOptions::has_java_outer_classname() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\nvoid FileOptions::set_has_java_outer_classname() {\n  _has_bits_[0] |= 0x00000002u;\n}\nvoid FileOptions::clear_has_java_outer_classname() {\n  _has_bits_[0] &= ~0x00000002u;\n}\nvoid FileOptions::clear_java_outer_classname() {\n  java_outer_classname_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_java_outer_classname();\n}\n const ::std::string& FileOptions::java_outer_classname() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_outer_classname)\n  return java_outer_classname_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FileOptions::set_java_outer_classname(const ::std::string& value) {\n  set_has_java_outer_classname();\n  java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_outer_classname)\n}\n void FileOptions::set_java_outer_classname(const char* value) {\n  set_has_java_outer_classname();\n  java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.java_outer_classname)\n}\n void FileOptions::set_java_outer_classname(const char* value, size_t size) {\n  set_has_java_outer_classname();\n  java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.java_outer_classname)\n}\n ::std::string* FileOptions::mutable_java_outer_classname() {\n  set_has_java_outer_classname();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.java_outer_classname)\n  return java_outer_classname_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* FileOptions::release_java_outer_classname() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.java_outer_classname)\n  clear_has_java_outer_classname();\n  return java_outer_classname_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FileOptions::set_allocated_java_outer_classname(::std::string* java_outer_classname) {\n  if (java_outer_classname != NULL) {\n    set_has_java_outer_classname();\n  } else {\n    clear_has_java_outer_classname();\n  }\n  java_outer_classname_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), java_outer_classname);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.java_outer_classname)\n}\n\n// optional bool java_multiple_files = 10 [default = false];\nbool FileOptions::has_java_multiple_files() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\nvoid FileOptions::set_has_java_multiple_files() {\n  _has_bits_[0] |= 0x00000004u;\n}\nvoid FileOptions::clear_has_java_multiple_files() {\n  _has_bits_[0] &= ~0x00000004u;\n}\nvoid FileOptions::clear_java_multiple_files() {\n  java_multiple_files_ = false;\n  clear_has_java_multiple_files();\n}\n bool FileOptions::java_multiple_files() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_multiple_files)\n  return java_multiple_files_;\n}\n void FileOptions::set_java_multiple_files(bool value) {\n  set_has_java_multiple_files();\n  java_multiple_files_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_multiple_files)\n}\n\n// optional bool java_generate_equals_and_hash = 20 [default = false];\nbool FileOptions::has_java_generate_equals_and_hash() const {\n  return (_has_bits_[0] & 0x00000008u) != 0;\n}\nvoid FileOptions::set_has_java_generate_equals_and_hash() {\n  _has_bits_[0] |= 0x00000008u;\n}\nvoid FileOptions::clear_has_java_generate_equals_and_hash() {\n  _has_bits_[0] &= ~0x00000008u;\n}\nvoid FileOptions::clear_java_generate_equals_and_hash() {\n  java_generate_equals_and_hash_ = false;\n  clear_has_java_generate_equals_and_hash();\n}\n bool FileOptions::java_generate_equals_and_hash() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_generate_equals_and_hash)\n  return java_generate_equals_and_hash_;\n}\n void FileOptions::set_java_generate_equals_and_hash(bool value) {\n  set_has_java_generate_equals_and_hash();\n  java_generate_equals_and_hash_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_generate_equals_and_hash)\n}\n\n// optional bool java_string_check_utf8 = 27 [default = false];\nbool FileOptions::has_java_string_check_utf8() const {\n  return (_has_bits_[0] & 0x00000010u) != 0;\n}\nvoid FileOptions::set_has_java_string_check_utf8() {\n  _has_bits_[0] |= 0x00000010u;\n}\nvoid FileOptions::clear_has_java_string_check_utf8() {\n  _has_bits_[0] &= ~0x00000010u;\n}\nvoid FileOptions::clear_java_string_check_utf8() {\n  java_string_check_utf8_ = false;\n  clear_has_java_string_check_utf8();\n}\n bool FileOptions::java_string_check_utf8() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_string_check_utf8)\n  return java_string_check_utf8_;\n}\n void FileOptions::set_java_string_check_utf8(bool value) {\n  set_has_java_string_check_utf8();\n  java_string_check_utf8_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_string_check_utf8)\n}\n\n// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];\nbool FileOptions::has_optimize_for() const {\n  return (_has_bits_[0] & 0x00000020u) != 0;\n}\nvoid FileOptions::set_has_optimize_for() {\n  _has_bits_[0] |= 0x00000020u;\n}\nvoid FileOptions::clear_has_optimize_for() {\n  _has_bits_[0] &= ~0x00000020u;\n}\nvoid FileOptions::clear_optimize_for() {\n  optimize_for_ = 1;\n  clear_has_optimize_for();\n}\n ::google::protobuf::FileOptions_OptimizeMode FileOptions::optimize_for() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.optimize_for)\n  return static_cast< ::google::protobuf::FileOptions_OptimizeMode >(optimize_for_);\n}\n void FileOptions::set_optimize_for(::google::protobuf::FileOptions_OptimizeMode value) {\n  assert(::google::protobuf::FileOptions_OptimizeMode_IsValid(value));\n  set_has_optimize_for();\n  optimize_for_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.optimize_for)\n}\n\n// optional string go_package = 11;\nbool FileOptions::has_go_package() const {\n  return (_has_bits_[0] & 0x00000040u) != 0;\n}\nvoid FileOptions::set_has_go_package() {\n  _has_bits_[0] |= 0x00000040u;\n}\nvoid FileOptions::clear_has_go_package() {\n  _has_bits_[0] &= ~0x00000040u;\n}\nvoid FileOptions::clear_go_package() {\n  go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_go_package();\n}\n const ::std::string& FileOptions::go_package() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.go_package)\n  return go_package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FileOptions::set_go_package(const ::std::string& value) {\n  set_has_go_package();\n  go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.go_package)\n}\n void FileOptions::set_go_package(const char* value) {\n  set_has_go_package();\n  go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.go_package)\n}\n void FileOptions::set_go_package(const char* value, size_t size) {\n  set_has_go_package();\n  go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.go_package)\n}\n ::std::string* FileOptions::mutable_go_package() {\n  set_has_go_package();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.go_package)\n  return go_package_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* FileOptions::release_go_package() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.go_package)\n  clear_has_go_package();\n  return go_package_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FileOptions::set_allocated_go_package(::std::string* go_package) {\n  if (go_package != NULL) {\n    set_has_go_package();\n  } else {\n    clear_has_go_package();\n  }\n  go_package_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), go_package);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.go_package)\n}\n\n// optional bool cc_generic_services = 16 [default = false];\nbool FileOptions::has_cc_generic_services() const {\n  return (_has_bits_[0] & 0x00000080u) != 0;\n}\nvoid FileOptions::set_has_cc_generic_services() {\n  _has_bits_[0] |= 0x00000080u;\n}\nvoid FileOptions::clear_has_cc_generic_services() {\n  _has_bits_[0] &= ~0x00000080u;\n}\nvoid FileOptions::clear_cc_generic_services() {\n  cc_generic_services_ = false;\n  clear_has_cc_generic_services();\n}\n bool FileOptions::cc_generic_services() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.cc_generic_services)\n  return cc_generic_services_;\n}\n void FileOptions::set_cc_generic_services(bool value) {\n  set_has_cc_generic_services();\n  cc_generic_services_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.cc_generic_services)\n}\n\n// optional bool java_generic_services = 17 [default = false];\nbool FileOptions::has_java_generic_services() const {\n  return (_has_bits_[0] & 0x00000100u) != 0;\n}\nvoid FileOptions::set_has_java_generic_services() {\n  _has_bits_[0] |= 0x00000100u;\n}\nvoid FileOptions::clear_has_java_generic_services() {\n  _has_bits_[0] &= ~0x00000100u;\n}\nvoid FileOptions::clear_java_generic_services() {\n  java_generic_services_ = false;\n  clear_has_java_generic_services();\n}\n bool FileOptions::java_generic_services() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_generic_services)\n  return java_generic_services_;\n}\n void FileOptions::set_java_generic_services(bool value) {\n  set_has_java_generic_services();\n  java_generic_services_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_generic_services)\n}\n\n// optional bool py_generic_services = 18 [default = false];\nbool FileOptions::has_py_generic_services() const {\n  return (_has_bits_[0] & 0x00000200u) != 0;\n}\nvoid FileOptions::set_has_py_generic_services() {\n  _has_bits_[0] |= 0x00000200u;\n}\nvoid FileOptions::clear_has_py_generic_services() {\n  _has_bits_[0] &= ~0x00000200u;\n}\nvoid FileOptions::clear_py_generic_services() {\n  py_generic_services_ = false;\n  clear_has_py_generic_services();\n}\n bool FileOptions::py_generic_services() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.py_generic_services)\n  return py_generic_services_;\n}\n void FileOptions::set_py_generic_services(bool value) {\n  set_has_py_generic_services();\n  py_generic_services_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.py_generic_services)\n}\n\n// optional bool deprecated = 23 [default = false];\nbool FileOptions::has_deprecated() const {\n  return (_has_bits_[0] & 0x00000400u) != 0;\n}\nvoid FileOptions::set_has_deprecated() {\n  _has_bits_[0] |= 0x00000400u;\n}\nvoid FileOptions::clear_has_deprecated() {\n  _has_bits_[0] &= ~0x00000400u;\n}\nvoid FileOptions::clear_deprecated() {\n  deprecated_ = false;\n  clear_has_deprecated();\n}\n bool FileOptions::deprecated() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.deprecated)\n  return deprecated_;\n}\n void FileOptions::set_deprecated(bool value) {\n  set_has_deprecated();\n  deprecated_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.deprecated)\n}\n\n// optional bool cc_enable_arenas = 31 [default = false];\nbool FileOptions::has_cc_enable_arenas() const {\n  return (_has_bits_[0] & 0x00000800u) != 0;\n}\nvoid FileOptions::set_has_cc_enable_arenas() {\n  _has_bits_[0] |= 0x00000800u;\n}\nvoid FileOptions::clear_has_cc_enable_arenas() {\n  _has_bits_[0] &= ~0x00000800u;\n}\nvoid FileOptions::clear_cc_enable_arenas() {\n  cc_enable_arenas_ = false;\n  clear_has_cc_enable_arenas();\n}\n bool FileOptions::cc_enable_arenas() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.cc_enable_arenas)\n  return cc_enable_arenas_;\n}\n void FileOptions::set_cc_enable_arenas(bool value) {\n  set_has_cc_enable_arenas();\n  cc_enable_arenas_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.cc_enable_arenas)\n}\n\n// optional string objc_class_prefix = 36;\nbool FileOptions::has_objc_class_prefix() const {\n  return (_has_bits_[0] & 0x00001000u) != 0;\n}\nvoid FileOptions::set_has_objc_class_prefix() {\n  _has_bits_[0] |= 0x00001000u;\n}\nvoid FileOptions::clear_has_objc_class_prefix() {\n  _has_bits_[0] &= ~0x00001000u;\n}\nvoid FileOptions::clear_objc_class_prefix() {\n  objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_objc_class_prefix();\n}\n const ::std::string& FileOptions::objc_class_prefix() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.objc_class_prefix)\n  return objc_class_prefix_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FileOptions::set_objc_class_prefix(const ::std::string& value) {\n  set_has_objc_class_prefix();\n  objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.objc_class_prefix)\n}\n void FileOptions::set_objc_class_prefix(const char* value) {\n  set_has_objc_class_prefix();\n  objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.objc_class_prefix)\n}\n void FileOptions::set_objc_class_prefix(const char* value, size_t size) {\n  set_has_objc_class_prefix();\n  objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.objc_class_prefix)\n}\n ::std::string* FileOptions::mutable_objc_class_prefix() {\n  set_has_objc_class_prefix();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.objc_class_prefix)\n  return objc_class_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* FileOptions::release_objc_class_prefix() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.objc_class_prefix)\n  clear_has_objc_class_prefix();\n  return objc_class_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FileOptions::set_allocated_objc_class_prefix(::std::string* objc_class_prefix) {\n  if (objc_class_prefix != NULL) {\n    set_has_objc_class_prefix();\n  } else {\n    clear_has_objc_class_prefix();\n  }\n  objc_class_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), objc_class_prefix);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.objc_class_prefix)\n}\n\n// optional string csharp_namespace = 37;\nbool FileOptions::has_csharp_namespace() const {\n  return (_has_bits_[0] & 0x00002000u) != 0;\n}\nvoid FileOptions::set_has_csharp_namespace() {\n  _has_bits_[0] |= 0x00002000u;\n}\nvoid FileOptions::clear_has_csharp_namespace() {\n  _has_bits_[0] &= ~0x00002000u;\n}\nvoid FileOptions::clear_csharp_namespace() {\n  csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_csharp_namespace();\n}\n const ::std::string& FileOptions::csharp_namespace() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_namespace)\n  return csharp_namespace_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FileOptions::set_csharp_namespace(const ::std::string& value) {\n  set_has_csharp_namespace();\n  csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_namespace)\n}\n void FileOptions::set_csharp_namespace(const char* value) {\n  set_has_csharp_namespace();\n  csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.csharp_namespace)\n}\n void FileOptions::set_csharp_namespace(const char* value, size_t size) {\n  set_has_csharp_namespace();\n  csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_namespace)\n}\n ::std::string* FileOptions::mutable_csharp_namespace() {\n  set_has_csharp_namespace();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.csharp_namespace)\n  return csharp_namespace_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* FileOptions::release_csharp_namespace() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.csharp_namespace)\n  clear_has_csharp_namespace();\n  return csharp_namespace_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void FileOptions::set_allocated_csharp_namespace(::std::string* csharp_namespace) {\n  if (csharp_namespace != NULL) {\n    set_has_csharp_namespace();\n  } else {\n    clear_has_csharp_namespace();\n  }\n  csharp_namespace_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), csharp_namespace);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace)\n}\n\n// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\nint FileOptions::uninterpreted_option_size() const {\n  return uninterpreted_option_.size();\n}\nvoid FileOptions::clear_uninterpreted_option() {\n  uninterpreted_option_.Clear();\n}\nconst ::google::protobuf::UninterpretedOption& FileOptions::uninterpreted_option(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.uninterpreted_option)\n  return uninterpreted_option_.Get(index);\n}\n::google::protobuf::UninterpretedOption* FileOptions::mutable_uninterpreted_option(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.uninterpreted_option)\n  return uninterpreted_option_.Mutable(index);\n}\n::google::protobuf::UninterpretedOption* FileOptions::add_uninterpreted_option() {\n  // @@protoc_insertion_point(field_add:google.protobuf.FileOptions.uninterpreted_option)\n  return uninterpreted_option_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\nFileOptions::mutable_uninterpreted_option() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileOptions.uninterpreted_option)\n  return &uninterpreted_option_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\nFileOptions::uninterpreted_option() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.FileOptions.uninterpreted_option)\n  return uninterpreted_option_;\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int MessageOptions::kMessageSetWireFormatFieldNumber;\nconst int MessageOptions::kNoStandardDescriptorAccessorFieldNumber;\nconst int MessageOptions::kDeprecatedFieldNumber;\nconst int MessageOptions::kMapEntryFieldNumber;\nconst int MessageOptions::kUninterpretedOptionFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nMessageOptions::MessageOptions()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.MessageOptions)\n}\n\nvoid MessageOptions::InitAsDefaultInstance() {\n}\n\nMessageOptions::MessageOptions(const MessageOptions& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.MessageOptions)\n}\n\nvoid MessageOptions::SharedCtor() {\n  _cached_size_ = 0;\n  message_set_wire_format_ = false;\n  no_standard_descriptor_accessor_ = false;\n  deprecated_ = false;\n  map_entry_ = false;\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nMessageOptions::~MessageOptions() {\n  // @@protoc_insertion_point(destructor:google.protobuf.MessageOptions)\n  SharedDtor();\n}\n\nvoid MessageOptions::SharedDtor() {\n  if (this != default_instance_) {\n  }\n}\n\nvoid MessageOptions::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* MessageOptions::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return MessageOptions_descriptor_;\n}\n\nconst MessageOptions& MessageOptions::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nMessageOptions* MessageOptions::default_instance_ = NULL;\n\nMessageOptions* MessageOptions::New(::google::protobuf::Arena* arena) const {\n  MessageOptions* n = new MessageOptions;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid MessageOptions::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.MessageOptions)\n  _extensions_.Clear();\n#if defined(__clang__)\n#define ZR_HELPER_(f) \\\n  _Pragma(\"clang diagnostic push\") \\\n  _Pragma(\"clang diagnostic ignored \\\"-Winvalid-offsetof\\\"\") \\\n  __builtin_offsetof(MessageOptions, f) \\\n  _Pragma(\"clang diagnostic pop\")\n#else\n#define ZR_HELPER_(f) reinterpret_cast<char*>(\\\n  &reinterpret_cast<MessageOptions*>(16)->f)\n#endif\n\n#define ZR_(first, last) do {\\\n  ::memset(&first, 0,\\\n           ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\\\n} while (0)\n\n  ZR_(message_set_wire_format_, map_entry_);\n\n#undef ZR_HELPER_\n#undef ZR_\n\n  uninterpreted_option_.Clear();\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool MessageOptions::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.MessageOptions)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional bool message_set_wire_format = 1 [default = false];\n      case 1: {\n        if (tag == 8) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &message_set_wire_format_)));\n          set_has_message_set_wire_format();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(16)) goto parse_no_standard_descriptor_accessor;\n        break;\n      }\n\n      // optional bool no_standard_descriptor_accessor = 2 [default = false];\n      case 2: {\n        if (tag == 16) {\n         parse_no_standard_descriptor_accessor:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &no_standard_descriptor_accessor_)));\n          set_has_no_standard_descriptor_accessor();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(24)) goto parse_deprecated;\n        break;\n      }\n\n      // optional bool deprecated = 3 [default = false];\n      case 3: {\n        if (tag == 24) {\n         parse_deprecated:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &deprecated_)));\n          set_has_deprecated();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(56)) goto parse_map_entry;\n        break;\n      }\n\n      // optional bool map_entry = 7;\n      case 7: {\n        if (tag == 56) {\n         parse_map_entry:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &map_entry_)));\n          set_has_map_entry();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(7994)) goto parse_uninterpreted_option;\n        break;\n      }\n\n      // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n      case 999: {\n        if (tag == 7994) {\n         parse_uninterpreted_option:\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_uninterpreted_option:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_uninterpreted_option()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        if ((8000u <= tag)) {\n          DO_(_extensions_.ParseField(tag, input, default_instance_,\n                                      mutable_unknown_fields()));\n          continue;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.MessageOptions)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.MessageOptions)\n  return false;\n#undef DO_\n}\n\nvoid MessageOptions::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.MessageOptions)\n  // optional bool message_set_wire_format = 1 [default = false];\n  if (has_message_set_wire_format()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->message_set_wire_format(), output);\n  }\n\n  // optional bool no_standard_descriptor_accessor = 2 [default = false];\n  if (has_no_standard_descriptor_accessor()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->no_standard_descriptor_accessor(), output);\n  }\n\n  // optional bool deprecated = 3 [default = false];\n  if (has_deprecated()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(3, this->deprecated(), output);\n  }\n\n  // optional bool map_entry = 7;\n  if (has_map_entry()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(7, this->map_entry(), output);\n  }\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      999, this->uninterpreted_option(i), output);\n  }\n\n  // Extension range [1000, 536870912)\n  _extensions_.SerializeWithCachedSizes(\n      1000, 536870912, output);\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.MessageOptions)\n}\n\n::google::protobuf::uint8* MessageOptions::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.MessageOptions)\n  // optional bool message_set_wire_format = 1 [default = false];\n  if (has_message_set_wire_format()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->message_set_wire_format(), target);\n  }\n\n  // optional bool no_standard_descriptor_accessor = 2 [default = false];\n  if (has_no_standard_descriptor_accessor()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->no_standard_descriptor_accessor(), target);\n  }\n\n  // optional bool deprecated = 3 [default = false];\n  if (has_deprecated()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(3, this->deprecated(), target);\n  }\n\n  // optional bool map_entry = 7;\n  if (has_map_entry()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(7, this->map_entry(), target);\n  }\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        999, this->uninterpreted_option(i), false, target);\n  }\n\n  // Extension range [1000, 536870912)\n  target = _extensions_.InternalSerializeWithCachedSizesToArray(\n      1000, 536870912, false, target);\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.MessageOptions)\n  return target;\n}\n\nint MessageOptions::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.MessageOptions)\n  int total_size = 0;\n\n  if (_has_bits_[0 / 32] & 15u) {\n    // optional bool message_set_wire_format = 1 [default = false];\n    if (has_message_set_wire_format()) {\n      total_size += 1 + 1;\n    }\n\n    // optional bool no_standard_descriptor_accessor = 2 [default = false];\n    if (has_no_standard_descriptor_accessor()) {\n      total_size += 1 + 1;\n    }\n\n    // optional bool deprecated = 3 [default = false];\n    if (has_deprecated()) {\n      total_size += 1 + 1;\n    }\n\n    // optional bool map_entry = 7;\n    if (has_map_entry()) {\n      total_size += 1 + 1;\n    }\n\n  }\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  total_size += 2 * this->uninterpreted_option_size();\n  for (int i = 0; i < this->uninterpreted_option_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->uninterpreted_option(i));\n  }\n\n  total_size += _extensions_.ByteSize();\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid MessageOptions::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.MessageOptions)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const MessageOptions* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const MessageOptions>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.MessageOptions)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.MessageOptions)\n    MergeFrom(*source);\n  }\n}\n\nvoid MessageOptions::MergeFrom(const MessageOptions& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MessageOptions)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  uninterpreted_option_.MergeFrom(from.uninterpreted_option_);\n  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {\n    if (from.has_message_set_wire_format()) {\n      set_message_set_wire_format(from.message_set_wire_format());\n    }\n    if (from.has_no_standard_descriptor_accessor()) {\n      set_no_standard_descriptor_accessor(from.no_standard_descriptor_accessor());\n    }\n    if (from.has_deprecated()) {\n      set_deprecated(from.deprecated());\n    }\n    if (from.has_map_entry()) {\n      set_map_entry(from.map_entry());\n    }\n  }\n  _extensions_.MergeFrom(from._extensions_);\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid MessageOptions::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.MessageOptions)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid MessageOptions::CopyFrom(const MessageOptions& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.MessageOptions)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool MessageOptions::IsInitialized() const {\n\n  if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;\n\n  if (!_extensions_.IsInitialized()) return false;  return true;\n}\n\nvoid MessageOptions::Swap(MessageOptions* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid MessageOptions::InternalSwap(MessageOptions* other) {\n  std::swap(message_set_wire_format_, other->message_set_wire_format_);\n  std::swap(no_standard_descriptor_accessor_, other->no_standard_descriptor_accessor_);\n  std::swap(deprecated_, other->deprecated_);\n  std::swap(map_entry_, other->map_entry_);\n  uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n  _extensions_.Swap(&other->_extensions_);\n}\n\n::google::protobuf::Metadata MessageOptions::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = MessageOptions_descriptor_;\n  metadata.reflection = MessageOptions_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// MessageOptions\n\n// optional bool message_set_wire_format = 1 [default = false];\nbool MessageOptions::has_message_set_wire_format() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\nvoid MessageOptions::set_has_message_set_wire_format() {\n  _has_bits_[0] |= 0x00000001u;\n}\nvoid MessageOptions::clear_has_message_set_wire_format() {\n  _has_bits_[0] &= ~0x00000001u;\n}\nvoid MessageOptions::clear_message_set_wire_format() {\n  message_set_wire_format_ = false;\n  clear_has_message_set_wire_format();\n}\n bool MessageOptions::message_set_wire_format() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.message_set_wire_format)\n  return message_set_wire_format_;\n}\n void MessageOptions::set_message_set_wire_format(bool value) {\n  set_has_message_set_wire_format();\n  message_set_wire_format_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.message_set_wire_format)\n}\n\n// optional bool no_standard_descriptor_accessor = 2 [default = false];\nbool MessageOptions::has_no_standard_descriptor_accessor() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\nvoid MessageOptions::set_has_no_standard_descriptor_accessor() {\n  _has_bits_[0] |= 0x00000002u;\n}\nvoid MessageOptions::clear_has_no_standard_descriptor_accessor() {\n  _has_bits_[0] &= ~0x00000002u;\n}\nvoid MessageOptions::clear_no_standard_descriptor_accessor() {\n  no_standard_descriptor_accessor_ = false;\n  clear_has_no_standard_descriptor_accessor();\n}\n bool MessageOptions::no_standard_descriptor_accessor() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.no_standard_descriptor_accessor)\n  return no_standard_descriptor_accessor_;\n}\n void MessageOptions::set_no_standard_descriptor_accessor(bool value) {\n  set_has_no_standard_descriptor_accessor();\n  no_standard_descriptor_accessor_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.no_standard_descriptor_accessor)\n}\n\n// optional bool deprecated = 3 [default = false];\nbool MessageOptions::has_deprecated() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\nvoid MessageOptions::set_has_deprecated() {\n  _has_bits_[0] |= 0x00000004u;\n}\nvoid MessageOptions::clear_has_deprecated() {\n  _has_bits_[0] &= ~0x00000004u;\n}\nvoid MessageOptions::clear_deprecated() {\n  deprecated_ = false;\n  clear_has_deprecated();\n}\n bool MessageOptions::deprecated() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.deprecated)\n  return deprecated_;\n}\n void MessageOptions::set_deprecated(bool value) {\n  set_has_deprecated();\n  deprecated_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.deprecated)\n}\n\n// optional bool map_entry = 7;\nbool MessageOptions::has_map_entry() const {\n  return (_has_bits_[0] & 0x00000008u) != 0;\n}\nvoid MessageOptions::set_has_map_entry() {\n  _has_bits_[0] |= 0x00000008u;\n}\nvoid MessageOptions::clear_has_map_entry() {\n  _has_bits_[0] &= ~0x00000008u;\n}\nvoid MessageOptions::clear_map_entry() {\n  map_entry_ = false;\n  clear_has_map_entry();\n}\n bool MessageOptions::map_entry() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.map_entry)\n  return map_entry_;\n}\n void MessageOptions::set_map_entry(bool value) {\n  set_has_map_entry();\n  map_entry_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.map_entry)\n}\n\n// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\nint MessageOptions::uninterpreted_option_size() const {\n  return uninterpreted_option_.size();\n}\nvoid MessageOptions::clear_uninterpreted_option() {\n  uninterpreted_option_.Clear();\n}\nconst ::google::protobuf::UninterpretedOption& MessageOptions::uninterpreted_option(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.uninterpreted_option)\n  return uninterpreted_option_.Get(index);\n}\n::google::protobuf::UninterpretedOption* MessageOptions::mutable_uninterpreted_option(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.MessageOptions.uninterpreted_option)\n  return uninterpreted_option_.Mutable(index);\n}\n::google::protobuf::UninterpretedOption* MessageOptions::add_uninterpreted_option() {\n  // @@protoc_insertion_point(field_add:google.protobuf.MessageOptions.uninterpreted_option)\n  return uninterpreted_option_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\nMessageOptions::mutable_uninterpreted_option() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.MessageOptions.uninterpreted_option)\n  return &uninterpreted_option_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\nMessageOptions::uninterpreted_option() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.MessageOptions.uninterpreted_option)\n  return uninterpreted_option_;\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\nconst ::google::protobuf::EnumDescriptor* FieldOptions_CType_descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return FieldOptions_CType_descriptor_;\n}\nbool FieldOptions_CType_IsValid(int value) {\n  switch(value) {\n    case 0:\n    case 1:\n    case 2:\n      return true;\n    default:\n      return false;\n  }\n}\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst FieldOptions_CType FieldOptions::STRING;\nconst FieldOptions_CType FieldOptions::CORD;\nconst FieldOptions_CType FieldOptions::STRING_PIECE;\nconst FieldOptions_CType FieldOptions::CType_MIN;\nconst FieldOptions_CType FieldOptions::CType_MAX;\nconst int FieldOptions::CType_ARRAYSIZE;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\nconst ::google::protobuf::EnumDescriptor* FieldOptions_JSType_descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return FieldOptions_JSType_descriptor_;\n}\nbool FieldOptions_JSType_IsValid(int value) {\n  switch(value) {\n    case 0:\n    case 1:\n    case 2:\n      return true;\n    default:\n      return false;\n  }\n}\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst FieldOptions_JSType FieldOptions::JS_NORMAL;\nconst FieldOptions_JSType FieldOptions::JS_STRING;\nconst FieldOptions_JSType FieldOptions::JS_NUMBER;\nconst FieldOptions_JSType FieldOptions::JSType_MIN;\nconst FieldOptions_JSType FieldOptions::JSType_MAX;\nconst int FieldOptions::JSType_ARRAYSIZE;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int FieldOptions::kCtypeFieldNumber;\nconst int FieldOptions::kPackedFieldNumber;\nconst int FieldOptions::kJstypeFieldNumber;\nconst int FieldOptions::kLazyFieldNumber;\nconst int FieldOptions::kDeprecatedFieldNumber;\nconst int FieldOptions::kWeakFieldNumber;\nconst int FieldOptions::kUninterpretedOptionFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nFieldOptions::FieldOptions()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.FieldOptions)\n}\n\nvoid FieldOptions::InitAsDefaultInstance() {\n}\n\nFieldOptions::FieldOptions(const FieldOptions& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.FieldOptions)\n}\n\nvoid FieldOptions::SharedCtor() {\n  _cached_size_ = 0;\n  ctype_ = 0;\n  packed_ = false;\n  jstype_ = 0;\n  lazy_ = false;\n  deprecated_ = false;\n  weak_ = false;\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nFieldOptions::~FieldOptions() {\n  // @@protoc_insertion_point(destructor:google.protobuf.FieldOptions)\n  SharedDtor();\n}\n\nvoid FieldOptions::SharedDtor() {\n  if (this != default_instance_) {\n  }\n}\n\nvoid FieldOptions::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* FieldOptions::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return FieldOptions_descriptor_;\n}\n\nconst FieldOptions& FieldOptions::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nFieldOptions* FieldOptions::default_instance_ = NULL;\n\nFieldOptions* FieldOptions::New(::google::protobuf::Arena* arena) const {\n  FieldOptions* n = new FieldOptions;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid FieldOptions::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.FieldOptions)\n  _extensions_.Clear();\n#if defined(__clang__)\n#define ZR_HELPER_(f) \\\n  _Pragma(\"clang diagnostic push\") \\\n  _Pragma(\"clang diagnostic ignored \\\"-Winvalid-offsetof\\\"\") \\\n  __builtin_offsetof(FieldOptions, f) \\\n  _Pragma(\"clang diagnostic pop\")\n#else\n#define ZR_HELPER_(f) reinterpret_cast<char*>(\\\n  &reinterpret_cast<FieldOptions*>(16)->f)\n#endif\n\n#define ZR_(first, last) do {\\\n  ::memset(&first, 0,\\\n           ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\\\n} while (0)\n\n  if (_has_bits_[0 / 32] & 63u) {\n    ZR_(ctype_, jstype_);\n    ZR_(packed_, weak_);\n  }\n\n#undef ZR_HELPER_\n#undef ZR_\n\n  uninterpreted_option_.Clear();\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool FieldOptions::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.FieldOptions)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];\n      case 1: {\n        if (tag == 8) {\n          int value;\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n                 input, &value)));\n          if (::google::protobuf::FieldOptions_CType_IsValid(value)) {\n            set_ctype(static_cast< ::google::protobuf::FieldOptions_CType >(value));\n          } else {\n            mutable_unknown_fields()->AddVarint(1, value);\n          }\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(16)) goto parse_packed;\n        break;\n      }\n\n      // optional bool packed = 2;\n      case 2: {\n        if (tag == 16) {\n         parse_packed:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &packed_)));\n          set_has_packed();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(24)) goto parse_deprecated;\n        break;\n      }\n\n      // optional bool deprecated = 3 [default = false];\n      case 3: {\n        if (tag == 24) {\n         parse_deprecated:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &deprecated_)));\n          set_has_deprecated();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(40)) goto parse_lazy;\n        break;\n      }\n\n      // optional bool lazy = 5 [default = false];\n      case 5: {\n        if (tag == 40) {\n         parse_lazy:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &lazy_)));\n          set_has_lazy();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(48)) goto parse_jstype;\n        break;\n      }\n\n      // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];\n      case 6: {\n        if (tag == 48) {\n         parse_jstype:\n          int value;\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n                 input, &value)));\n          if (::google::protobuf::FieldOptions_JSType_IsValid(value)) {\n            set_jstype(static_cast< ::google::protobuf::FieldOptions_JSType >(value));\n          } else {\n            mutable_unknown_fields()->AddVarint(6, value);\n          }\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(80)) goto parse_weak;\n        break;\n      }\n\n      // optional bool weak = 10 [default = false];\n      case 10: {\n        if (tag == 80) {\n         parse_weak:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &weak_)));\n          set_has_weak();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(7994)) goto parse_uninterpreted_option;\n        break;\n      }\n\n      // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n      case 999: {\n        if (tag == 7994) {\n         parse_uninterpreted_option:\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_uninterpreted_option:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_uninterpreted_option()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        if ((8000u <= tag)) {\n          DO_(_extensions_.ParseField(tag, input, default_instance_,\n                                      mutable_unknown_fields()));\n          continue;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.FieldOptions)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.FieldOptions)\n  return false;\n#undef DO_\n}\n\nvoid FieldOptions::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.FieldOptions)\n  // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];\n  if (has_ctype()) {\n    ::google::protobuf::internal::WireFormatLite::WriteEnum(\n      1, this->ctype(), output);\n  }\n\n  // optional bool packed = 2;\n  if (has_packed()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->packed(), output);\n  }\n\n  // optional bool deprecated = 3 [default = false];\n  if (has_deprecated()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(3, this->deprecated(), output);\n  }\n\n  // optional bool lazy = 5 [default = false];\n  if (has_lazy()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(5, this->lazy(), output);\n  }\n\n  // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];\n  if (has_jstype()) {\n    ::google::protobuf::internal::WireFormatLite::WriteEnum(\n      6, this->jstype(), output);\n  }\n\n  // optional bool weak = 10 [default = false];\n  if (has_weak()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(10, this->weak(), output);\n  }\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      999, this->uninterpreted_option(i), output);\n  }\n\n  // Extension range [1000, 536870912)\n  _extensions_.SerializeWithCachedSizes(\n      1000, 536870912, output);\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.FieldOptions)\n}\n\n::google::protobuf::uint8* FieldOptions::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldOptions)\n  // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];\n  if (has_ctype()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(\n      1, this->ctype(), target);\n  }\n\n  // optional bool packed = 2;\n  if (has_packed()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->packed(), target);\n  }\n\n  // optional bool deprecated = 3 [default = false];\n  if (has_deprecated()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(3, this->deprecated(), target);\n  }\n\n  // optional bool lazy = 5 [default = false];\n  if (has_lazy()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(5, this->lazy(), target);\n  }\n\n  // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];\n  if (has_jstype()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(\n      6, this->jstype(), target);\n  }\n\n  // optional bool weak = 10 [default = false];\n  if (has_weak()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(10, this->weak(), target);\n  }\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        999, this->uninterpreted_option(i), false, target);\n  }\n\n  // Extension range [1000, 536870912)\n  target = _extensions_.InternalSerializeWithCachedSizesToArray(\n      1000, 536870912, false, target);\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FieldOptions)\n  return target;\n}\n\nint FieldOptions::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldOptions)\n  int total_size = 0;\n\n  if (_has_bits_[0 / 32] & 63u) {\n    // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];\n    if (has_ctype()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::EnumSize(this->ctype());\n    }\n\n    // optional bool packed = 2;\n    if (has_packed()) {\n      total_size += 1 + 1;\n    }\n\n    // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];\n    if (has_jstype()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::EnumSize(this->jstype());\n    }\n\n    // optional bool lazy = 5 [default = false];\n    if (has_lazy()) {\n      total_size += 1 + 1;\n    }\n\n    // optional bool deprecated = 3 [default = false];\n    if (has_deprecated()) {\n      total_size += 1 + 1;\n    }\n\n    // optional bool weak = 10 [default = false];\n    if (has_weak()) {\n      total_size += 1 + 1;\n    }\n\n  }\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  total_size += 2 * this->uninterpreted_option_size();\n  for (int i = 0; i < this->uninterpreted_option_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->uninterpreted_option(i));\n  }\n\n  total_size += _extensions_.ByteSize();\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid FieldOptions::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FieldOptions)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const FieldOptions* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const FieldOptions>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.FieldOptions)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FieldOptions)\n    MergeFrom(*source);\n  }\n}\n\nvoid FieldOptions::MergeFrom(const FieldOptions& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldOptions)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  uninterpreted_option_.MergeFrom(from.uninterpreted_option_);\n  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {\n    if (from.has_ctype()) {\n      set_ctype(from.ctype());\n    }\n    if (from.has_packed()) {\n      set_packed(from.packed());\n    }\n    if (from.has_jstype()) {\n      set_jstype(from.jstype());\n    }\n    if (from.has_lazy()) {\n      set_lazy(from.lazy());\n    }\n    if (from.has_deprecated()) {\n      set_deprecated(from.deprecated());\n    }\n    if (from.has_weak()) {\n      set_weak(from.weak());\n    }\n  }\n  _extensions_.MergeFrom(from._extensions_);\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid FieldOptions::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.FieldOptions)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid FieldOptions::CopyFrom(const FieldOptions& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FieldOptions)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool FieldOptions::IsInitialized() const {\n\n  if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;\n\n  if (!_extensions_.IsInitialized()) return false;  return true;\n}\n\nvoid FieldOptions::Swap(FieldOptions* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid FieldOptions::InternalSwap(FieldOptions* other) {\n  std::swap(ctype_, other->ctype_);\n  std::swap(packed_, other->packed_);\n  std::swap(jstype_, other->jstype_);\n  std::swap(lazy_, other->lazy_);\n  std::swap(deprecated_, other->deprecated_);\n  std::swap(weak_, other->weak_);\n  uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n  _extensions_.Swap(&other->_extensions_);\n}\n\n::google::protobuf::Metadata FieldOptions::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = FieldOptions_descriptor_;\n  metadata.reflection = FieldOptions_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// FieldOptions\n\n// optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];\nbool FieldOptions::has_ctype() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\nvoid FieldOptions::set_has_ctype() {\n  _has_bits_[0] |= 0x00000001u;\n}\nvoid FieldOptions::clear_has_ctype() {\n  _has_bits_[0] &= ~0x00000001u;\n}\nvoid FieldOptions::clear_ctype() {\n  ctype_ = 0;\n  clear_has_ctype();\n}\n ::google::protobuf::FieldOptions_CType FieldOptions::ctype() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.ctype)\n  return static_cast< ::google::protobuf::FieldOptions_CType >(ctype_);\n}\n void FieldOptions::set_ctype(::google::protobuf::FieldOptions_CType value) {\n  assert(::google::protobuf::FieldOptions_CType_IsValid(value));\n  set_has_ctype();\n  ctype_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.ctype)\n}\n\n// optional bool packed = 2;\nbool FieldOptions::has_packed() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\nvoid FieldOptions::set_has_packed() {\n  _has_bits_[0] |= 0x00000002u;\n}\nvoid FieldOptions::clear_has_packed() {\n  _has_bits_[0] &= ~0x00000002u;\n}\nvoid FieldOptions::clear_packed() {\n  packed_ = false;\n  clear_has_packed();\n}\n bool FieldOptions::packed() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.packed)\n  return packed_;\n}\n void FieldOptions::set_packed(bool value) {\n  set_has_packed();\n  packed_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.packed)\n}\n\n// optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];\nbool FieldOptions::has_jstype() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\nvoid FieldOptions::set_has_jstype() {\n  _has_bits_[0] |= 0x00000004u;\n}\nvoid FieldOptions::clear_has_jstype() {\n  _has_bits_[0] &= ~0x00000004u;\n}\nvoid FieldOptions::clear_jstype() {\n  jstype_ = 0;\n  clear_has_jstype();\n}\n ::google::protobuf::FieldOptions_JSType FieldOptions::jstype() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.jstype)\n  return static_cast< ::google::protobuf::FieldOptions_JSType >(jstype_);\n}\n void FieldOptions::set_jstype(::google::protobuf::FieldOptions_JSType value) {\n  assert(::google::protobuf::FieldOptions_JSType_IsValid(value));\n  set_has_jstype();\n  jstype_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.jstype)\n}\n\n// optional bool lazy = 5 [default = false];\nbool FieldOptions::has_lazy() const {\n  return (_has_bits_[0] & 0x00000008u) != 0;\n}\nvoid FieldOptions::set_has_lazy() {\n  _has_bits_[0] |= 0x00000008u;\n}\nvoid FieldOptions::clear_has_lazy() {\n  _has_bits_[0] &= ~0x00000008u;\n}\nvoid FieldOptions::clear_lazy() {\n  lazy_ = false;\n  clear_has_lazy();\n}\n bool FieldOptions::lazy() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.lazy)\n  return lazy_;\n}\n void FieldOptions::set_lazy(bool value) {\n  set_has_lazy();\n  lazy_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.lazy)\n}\n\n// optional bool deprecated = 3 [default = false];\nbool FieldOptions::has_deprecated() const {\n  return (_has_bits_[0] & 0x00000010u) != 0;\n}\nvoid FieldOptions::set_has_deprecated() {\n  _has_bits_[0] |= 0x00000010u;\n}\nvoid FieldOptions::clear_has_deprecated() {\n  _has_bits_[0] &= ~0x00000010u;\n}\nvoid FieldOptions::clear_deprecated() {\n  deprecated_ = false;\n  clear_has_deprecated();\n}\n bool FieldOptions::deprecated() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.deprecated)\n  return deprecated_;\n}\n void FieldOptions::set_deprecated(bool value) {\n  set_has_deprecated();\n  deprecated_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.deprecated)\n}\n\n// optional bool weak = 10 [default = false];\nbool FieldOptions::has_weak() const {\n  return (_has_bits_[0] & 0x00000020u) != 0;\n}\nvoid FieldOptions::set_has_weak() {\n  _has_bits_[0] |= 0x00000020u;\n}\nvoid FieldOptions::clear_has_weak() {\n  _has_bits_[0] &= ~0x00000020u;\n}\nvoid FieldOptions::clear_weak() {\n  weak_ = false;\n  clear_has_weak();\n}\n bool FieldOptions::weak() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.weak)\n  return weak_;\n}\n void FieldOptions::set_weak(bool value) {\n  set_has_weak();\n  weak_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.weak)\n}\n\n// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\nint FieldOptions::uninterpreted_option_size() const {\n  return uninterpreted_option_.size();\n}\nvoid FieldOptions::clear_uninterpreted_option() {\n  uninterpreted_option_.Clear();\n}\nconst ::google::protobuf::UninterpretedOption& FieldOptions::uninterpreted_option(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.uninterpreted_option)\n  return uninterpreted_option_.Get(index);\n}\n::google::protobuf::UninterpretedOption* FieldOptions::mutable_uninterpreted_option(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FieldOptions.uninterpreted_option)\n  return uninterpreted_option_.Mutable(index);\n}\n::google::protobuf::UninterpretedOption* FieldOptions::add_uninterpreted_option() {\n  // @@protoc_insertion_point(field_add:google.protobuf.FieldOptions.uninterpreted_option)\n  return uninterpreted_option_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\nFieldOptions::mutable_uninterpreted_option() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.FieldOptions.uninterpreted_option)\n  return &uninterpreted_option_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\nFieldOptions::uninterpreted_option() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.FieldOptions.uninterpreted_option)\n  return uninterpreted_option_;\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int OneofOptions::kUninterpretedOptionFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nOneofOptions::OneofOptions()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.OneofOptions)\n}\n\nvoid OneofOptions::InitAsDefaultInstance() {\n}\n\nOneofOptions::OneofOptions(const OneofOptions& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.OneofOptions)\n}\n\nvoid OneofOptions::SharedCtor() {\n  _cached_size_ = 0;\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nOneofOptions::~OneofOptions() {\n  // @@protoc_insertion_point(destructor:google.protobuf.OneofOptions)\n  SharedDtor();\n}\n\nvoid OneofOptions::SharedDtor() {\n  if (this != default_instance_) {\n  }\n}\n\nvoid OneofOptions::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* OneofOptions::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return OneofOptions_descriptor_;\n}\n\nconst OneofOptions& OneofOptions::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nOneofOptions* OneofOptions::default_instance_ = NULL;\n\nOneofOptions* OneofOptions::New(::google::protobuf::Arena* arena) const {\n  OneofOptions* n = new OneofOptions;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid OneofOptions::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.OneofOptions)\n  _extensions_.Clear();\n  uninterpreted_option_.Clear();\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool OneofOptions::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.OneofOptions)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n      case 999: {\n        if (tag == 7994) {\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_uninterpreted_option:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_uninterpreted_option()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        if ((8000u <= tag)) {\n          DO_(_extensions_.ParseField(tag, input, default_instance_,\n                                      mutable_unknown_fields()));\n          continue;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.OneofOptions)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.OneofOptions)\n  return false;\n#undef DO_\n}\n\nvoid OneofOptions::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.OneofOptions)\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      999, this->uninterpreted_option(i), output);\n  }\n\n  // Extension range [1000, 536870912)\n  _extensions_.SerializeWithCachedSizes(\n      1000, 536870912, output);\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.OneofOptions)\n}\n\n::google::protobuf::uint8* OneofOptions::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.OneofOptions)\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        999, this->uninterpreted_option(i), false, target);\n  }\n\n  // Extension range [1000, 536870912)\n  target = _extensions_.InternalSerializeWithCachedSizesToArray(\n      1000, 536870912, false, target);\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.OneofOptions)\n  return target;\n}\n\nint OneofOptions::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.OneofOptions)\n  int total_size = 0;\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  total_size += 2 * this->uninterpreted_option_size();\n  for (int i = 0; i < this->uninterpreted_option_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->uninterpreted_option(i));\n  }\n\n  total_size += _extensions_.ByteSize();\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid OneofOptions::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.OneofOptions)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const OneofOptions* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const OneofOptions>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.OneofOptions)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.OneofOptions)\n    MergeFrom(*source);\n  }\n}\n\nvoid OneofOptions::MergeFrom(const OneofOptions& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.OneofOptions)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  uninterpreted_option_.MergeFrom(from.uninterpreted_option_);\n  _extensions_.MergeFrom(from._extensions_);\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid OneofOptions::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.OneofOptions)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid OneofOptions::CopyFrom(const OneofOptions& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.OneofOptions)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool OneofOptions::IsInitialized() const {\n\n  if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;\n\n  if (!_extensions_.IsInitialized()) return false;  return true;\n}\n\nvoid OneofOptions::Swap(OneofOptions* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid OneofOptions::InternalSwap(OneofOptions* other) {\n  uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n  _extensions_.Swap(&other->_extensions_);\n}\n\n::google::protobuf::Metadata OneofOptions::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = OneofOptions_descriptor_;\n  metadata.reflection = OneofOptions_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// OneofOptions\n\n// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\nint OneofOptions::uninterpreted_option_size() const {\n  return uninterpreted_option_.size();\n}\nvoid OneofOptions::clear_uninterpreted_option() {\n  uninterpreted_option_.Clear();\n}\nconst ::google::protobuf::UninterpretedOption& OneofOptions::uninterpreted_option(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.OneofOptions.uninterpreted_option)\n  return uninterpreted_option_.Get(index);\n}\n::google::protobuf::UninterpretedOption* OneofOptions::mutable_uninterpreted_option(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.OneofOptions.uninterpreted_option)\n  return uninterpreted_option_.Mutable(index);\n}\n::google::protobuf::UninterpretedOption* OneofOptions::add_uninterpreted_option() {\n  // @@protoc_insertion_point(field_add:google.protobuf.OneofOptions.uninterpreted_option)\n  return uninterpreted_option_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\nOneofOptions::mutable_uninterpreted_option() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.OneofOptions.uninterpreted_option)\n  return &uninterpreted_option_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\nOneofOptions::uninterpreted_option() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.OneofOptions.uninterpreted_option)\n  return uninterpreted_option_;\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int EnumOptions::kAllowAliasFieldNumber;\nconst int EnumOptions::kDeprecatedFieldNumber;\nconst int EnumOptions::kUninterpretedOptionFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nEnumOptions::EnumOptions()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.EnumOptions)\n}\n\nvoid EnumOptions::InitAsDefaultInstance() {\n}\n\nEnumOptions::EnumOptions(const EnumOptions& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumOptions)\n}\n\nvoid EnumOptions::SharedCtor() {\n  _cached_size_ = 0;\n  allow_alias_ = false;\n  deprecated_ = false;\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nEnumOptions::~EnumOptions() {\n  // @@protoc_insertion_point(destructor:google.protobuf.EnumOptions)\n  SharedDtor();\n}\n\nvoid EnumOptions::SharedDtor() {\n  if (this != default_instance_) {\n  }\n}\n\nvoid EnumOptions::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* EnumOptions::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return EnumOptions_descriptor_;\n}\n\nconst EnumOptions& EnumOptions::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nEnumOptions* EnumOptions::default_instance_ = NULL;\n\nEnumOptions* EnumOptions::New(::google::protobuf::Arena* arena) const {\n  EnumOptions* n = new EnumOptions;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid EnumOptions::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumOptions)\n  _extensions_.Clear();\n#if defined(__clang__)\n#define ZR_HELPER_(f) \\\n  _Pragma(\"clang diagnostic push\") \\\n  _Pragma(\"clang diagnostic ignored \\\"-Winvalid-offsetof\\\"\") \\\n  __builtin_offsetof(EnumOptions, f) \\\n  _Pragma(\"clang diagnostic pop\")\n#else\n#define ZR_HELPER_(f) reinterpret_cast<char*>(\\\n  &reinterpret_cast<EnumOptions*>(16)->f)\n#endif\n\n#define ZR_(first, last) do {\\\n  ::memset(&first, 0,\\\n           ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\\\n} while (0)\n\n  ZR_(allow_alias_, deprecated_);\n\n#undef ZR_HELPER_\n#undef ZR_\n\n  uninterpreted_option_.Clear();\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool EnumOptions::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.EnumOptions)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional bool allow_alias = 2;\n      case 2: {\n        if (tag == 16) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &allow_alias_)));\n          set_has_allow_alias();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(24)) goto parse_deprecated;\n        break;\n      }\n\n      // optional bool deprecated = 3 [default = false];\n      case 3: {\n        if (tag == 24) {\n         parse_deprecated:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &deprecated_)));\n          set_has_deprecated();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(7994)) goto parse_uninterpreted_option;\n        break;\n      }\n\n      // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n      case 999: {\n        if (tag == 7994) {\n         parse_uninterpreted_option:\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_uninterpreted_option:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_uninterpreted_option()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        if ((8000u <= tag)) {\n          DO_(_extensions_.ParseField(tag, input, default_instance_,\n                                      mutable_unknown_fields()));\n          continue;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.EnumOptions)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.EnumOptions)\n  return false;\n#undef DO_\n}\n\nvoid EnumOptions::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.EnumOptions)\n  // optional bool allow_alias = 2;\n  if (has_allow_alias()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->allow_alias(), output);\n  }\n\n  // optional bool deprecated = 3 [default = false];\n  if (has_deprecated()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(3, this->deprecated(), output);\n  }\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      999, this->uninterpreted_option(i), output);\n  }\n\n  // Extension range [1000, 536870912)\n  _extensions_.SerializeWithCachedSizes(\n      1000, 536870912, output);\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.EnumOptions)\n}\n\n::google::protobuf::uint8* EnumOptions::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumOptions)\n  // optional bool allow_alias = 2;\n  if (has_allow_alias()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->allow_alias(), target);\n  }\n\n  // optional bool deprecated = 3 [default = false];\n  if (has_deprecated()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(3, this->deprecated(), target);\n  }\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        999, this->uninterpreted_option(i), false, target);\n  }\n\n  // Extension range [1000, 536870912)\n  target = _extensions_.InternalSerializeWithCachedSizesToArray(\n      1000, 536870912, false, target);\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumOptions)\n  return target;\n}\n\nint EnumOptions::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumOptions)\n  int total_size = 0;\n\n  if (_has_bits_[0 / 32] & 3u) {\n    // optional bool allow_alias = 2;\n    if (has_allow_alias()) {\n      total_size += 1 + 1;\n    }\n\n    // optional bool deprecated = 3 [default = false];\n    if (has_deprecated()) {\n      total_size += 1 + 1;\n    }\n\n  }\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  total_size += 2 * this->uninterpreted_option_size();\n  for (int i = 0; i < this->uninterpreted_option_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->uninterpreted_option(i));\n  }\n\n  total_size += _extensions_.ByteSize();\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid EnumOptions::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumOptions)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const EnumOptions* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const EnumOptions>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.EnumOptions)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumOptions)\n    MergeFrom(*source);\n  }\n}\n\nvoid EnumOptions::MergeFrom(const EnumOptions& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumOptions)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  uninterpreted_option_.MergeFrom(from.uninterpreted_option_);\n  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {\n    if (from.has_allow_alias()) {\n      set_allow_alias(from.allow_alias());\n    }\n    if (from.has_deprecated()) {\n      set_deprecated(from.deprecated());\n    }\n  }\n  _extensions_.MergeFrom(from._extensions_);\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid EnumOptions::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.EnumOptions)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid EnumOptions::CopyFrom(const EnumOptions& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumOptions)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool EnumOptions::IsInitialized() const {\n\n  if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;\n\n  if (!_extensions_.IsInitialized()) return false;  return true;\n}\n\nvoid EnumOptions::Swap(EnumOptions* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid EnumOptions::InternalSwap(EnumOptions* other) {\n  std::swap(allow_alias_, other->allow_alias_);\n  std::swap(deprecated_, other->deprecated_);\n  uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n  _extensions_.Swap(&other->_extensions_);\n}\n\n::google::protobuf::Metadata EnumOptions::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = EnumOptions_descriptor_;\n  metadata.reflection = EnumOptions_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// EnumOptions\n\n// optional bool allow_alias = 2;\nbool EnumOptions::has_allow_alias() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\nvoid EnumOptions::set_has_allow_alias() {\n  _has_bits_[0] |= 0x00000001u;\n}\nvoid EnumOptions::clear_has_allow_alias() {\n  _has_bits_[0] &= ~0x00000001u;\n}\nvoid EnumOptions::clear_allow_alias() {\n  allow_alias_ = false;\n  clear_has_allow_alias();\n}\n bool EnumOptions::allow_alias() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.allow_alias)\n  return allow_alias_;\n}\n void EnumOptions::set_allow_alias(bool value) {\n  set_has_allow_alias();\n  allow_alias_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.EnumOptions.allow_alias)\n}\n\n// optional bool deprecated = 3 [default = false];\nbool EnumOptions::has_deprecated() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\nvoid EnumOptions::set_has_deprecated() {\n  _has_bits_[0] |= 0x00000002u;\n}\nvoid EnumOptions::clear_has_deprecated() {\n  _has_bits_[0] &= ~0x00000002u;\n}\nvoid EnumOptions::clear_deprecated() {\n  deprecated_ = false;\n  clear_has_deprecated();\n}\n bool EnumOptions::deprecated() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.deprecated)\n  return deprecated_;\n}\n void EnumOptions::set_deprecated(bool value) {\n  set_has_deprecated();\n  deprecated_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.EnumOptions.deprecated)\n}\n\n// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\nint EnumOptions::uninterpreted_option_size() const {\n  return uninterpreted_option_.size();\n}\nvoid EnumOptions::clear_uninterpreted_option() {\n  uninterpreted_option_.Clear();\n}\nconst ::google::protobuf::UninterpretedOption& EnumOptions::uninterpreted_option(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.uninterpreted_option)\n  return uninterpreted_option_.Get(index);\n}\n::google::protobuf::UninterpretedOption* EnumOptions::mutable_uninterpreted_option(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.EnumOptions.uninterpreted_option)\n  return uninterpreted_option_.Mutable(index);\n}\n::google::protobuf::UninterpretedOption* EnumOptions::add_uninterpreted_option() {\n  // @@protoc_insertion_point(field_add:google.protobuf.EnumOptions.uninterpreted_option)\n  return uninterpreted_option_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\nEnumOptions::mutable_uninterpreted_option() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumOptions.uninterpreted_option)\n  return &uninterpreted_option_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\nEnumOptions::uninterpreted_option() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.EnumOptions.uninterpreted_option)\n  return uninterpreted_option_;\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int EnumValueOptions::kDeprecatedFieldNumber;\nconst int EnumValueOptions::kUninterpretedOptionFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nEnumValueOptions::EnumValueOptions()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.EnumValueOptions)\n}\n\nvoid EnumValueOptions::InitAsDefaultInstance() {\n}\n\nEnumValueOptions::EnumValueOptions(const EnumValueOptions& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValueOptions)\n}\n\nvoid EnumValueOptions::SharedCtor() {\n  _cached_size_ = 0;\n  deprecated_ = false;\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nEnumValueOptions::~EnumValueOptions() {\n  // @@protoc_insertion_point(destructor:google.protobuf.EnumValueOptions)\n  SharedDtor();\n}\n\nvoid EnumValueOptions::SharedDtor() {\n  if (this != default_instance_) {\n  }\n}\n\nvoid EnumValueOptions::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* EnumValueOptions::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return EnumValueOptions_descriptor_;\n}\n\nconst EnumValueOptions& EnumValueOptions::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nEnumValueOptions* EnumValueOptions::default_instance_ = NULL;\n\nEnumValueOptions* EnumValueOptions::New(::google::protobuf::Arena* arena) const {\n  EnumValueOptions* n = new EnumValueOptions;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid EnumValueOptions::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValueOptions)\n  _extensions_.Clear();\n  deprecated_ = false;\n  uninterpreted_option_.Clear();\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool EnumValueOptions::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.EnumValueOptions)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional bool deprecated = 1 [default = false];\n      case 1: {\n        if (tag == 8) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &deprecated_)));\n          set_has_deprecated();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(7994)) goto parse_uninterpreted_option;\n        break;\n      }\n\n      // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n      case 999: {\n        if (tag == 7994) {\n         parse_uninterpreted_option:\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_uninterpreted_option:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_uninterpreted_option()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        if ((8000u <= tag)) {\n          DO_(_extensions_.ParseField(tag, input, default_instance_,\n                                      mutable_unknown_fields()));\n          continue;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.EnumValueOptions)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.EnumValueOptions)\n  return false;\n#undef DO_\n}\n\nvoid EnumValueOptions::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.EnumValueOptions)\n  // optional bool deprecated = 1 [default = false];\n  if (has_deprecated()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->deprecated(), output);\n  }\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      999, this->uninterpreted_option(i), output);\n  }\n\n  // Extension range [1000, 536870912)\n  _extensions_.SerializeWithCachedSizes(\n      1000, 536870912, output);\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.EnumValueOptions)\n}\n\n::google::protobuf::uint8* EnumValueOptions::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumValueOptions)\n  // optional bool deprecated = 1 [default = false];\n  if (has_deprecated()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->deprecated(), target);\n  }\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        999, this->uninterpreted_option(i), false, target);\n  }\n\n  // Extension range [1000, 536870912)\n  target = _extensions_.InternalSerializeWithCachedSizesToArray(\n      1000, 536870912, false, target);\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumValueOptions)\n  return target;\n}\n\nint EnumValueOptions::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValueOptions)\n  int total_size = 0;\n\n  // optional bool deprecated = 1 [default = false];\n  if (has_deprecated()) {\n    total_size += 1 + 1;\n  }\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  total_size += 2 * this->uninterpreted_option_size();\n  for (int i = 0; i < this->uninterpreted_option_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->uninterpreted_option(i));\n  }\n\n  total_size += _extensions_.ByteSize();\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid EnumValueOptions::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumValueOptions)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const EnumValueOptions* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const EnumValueOptions>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.EnumValueOptions)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumValueOptions)\n    MergeFrom(*source);\n  }\n}\n\nvoid EnumValueOptions::MergeFrom(const EnumValueOptions& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValueOptions)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  uninterpreted_option_.MergeFrom(from.uninterpreted_option_);\n  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {\n    if (from.has_deprecated()) {\n      set_deprecated(from.deprecated());\n    }\n  }\n  _extensions_.MergeFrom(from._extensions_);\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid EnumValueOptions::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.EnumValueOptions)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid EnumValueOptions::CopyFrom(const EnumValueOptions& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumValueOptions)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool EnumValueOptions::IsInitialized() const {\n\n  if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;\n\n  if (!_extensions_.IsInitialized()) return false;  return true;\n}\n\nvoid EnumValueOptions::Swap(EnumValueOptions* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid EnumValueOptions::InternalSwap(EnumValueOptions* other) {\n  std::swap(deprecated_, other->deprecated_);\n  uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n  _extensions_.Swap(&other->_extensions_);\n}\n\n::google::protobuf::Metadata EnumValueOptions::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = EnumValueOptions_descriptor_;\n  metadata.reflection = EnumValueOptions_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// EnumValueOptions\n\n// optional bool deprecated = 1 [default = false];\nbool EnumValueOptions::has_deprecated() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\nvoid EnumValueOptions::set_has_deprecated() {\n  _has_bits_[0] |= 0x00000001u;\n}\nvoid EnumValueOptions::clear_has_deprecated() {\n  _has_bits_[0] &= ~0x00000001u;\n}\nvoid EnumValueOptions::clear_deprecated() {\n  deprecated_ = false;\n  clear_has_deprecated();\n}\n bool EnumValueOptions::deprecated() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumValueOptions.deprecated)\n  return deprecated_;\n}\n void EnumValueOptions::set_deprecated(bool value) {\n  set_has_deprecated();\n  deprecated_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.EnumValueOptions.deprecated)\n}\n\n// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\nint EnumValueOptions::uninterpreted_option_size() const {\n  return uninterpreted_option_.size();\n}\nvoid EnumValueOptions::clear_uninterpreted_option() {\n  uninterpreted_option_.Clear();\n}\nconst ::google::protobuf::UninterpretedOption& EnumValueOptions::uninterpreted_option(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumValueOptions.uninterpreted_option)\n  return uninterpreted_option_.Get(index);\n}\n::google::protobuf::UninterpretedOption* EnumValueOptions::mutable_uninterpreted_option(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueOptions.uninterpreted_option)\n  return uninterpreted_option_.Mutable(index);\n}\n::google::protobuf::UninterpretedOption* EnumValueOptions::add_uninterpreted_option() {\n  // @@protoc_insertion_point(field_add:google.protobuf.EnumValueOptions.uninterpreted_option)\n  return uninterpreted_option_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\nEnumValueOptions::mutable_uninterpreted_option() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumValueOptions.uninterpreted_option)\n  return &uninterpreted_option_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\nEnumValueOptions::uninterpreted_option() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.EnumValueOptions.uninterpreted_option)\n  return uninterpreted_option_;\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int ServiceOptions::kDeprecatedFieldNumber;\nconst int ServiceOptions::kUninterpretedOptionFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nServiceOptions::ServiceOptions()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.ServiceOptions)\n}\n\nvoid ServiceOptions::InitAsDefaultInstance() {\n}\n\nServiceOptions::ServiceOptions(const ServiceOptions& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.ServiceOptions)\n}\n\nvoid ServiceOptions::SharedCtor() {\n  _cached_size_ = 0;\n  deprecated_ = false;\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nServiceOptions::~ServiceOptions() {\n  // @@protoc_insertion_point(destructor:google.protobuf.ServiceOptions)\n  SharedDtor();\n}\n\nvoid ServiceOptions::SharedDtor() {\n  if (this != default_instance_) {\n  }\n}\n\nvoid ServiceOptions::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* ServiceOptions::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return ServiceOptions_descriptor_;\n}\n\nconst ServiceOptions& ServiceOptions::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nServiceOptions* ServiceOptions::default_instance_ = NULL;\n\nServiceOptions* ServiceOptions::New(::google::protobuf::Arena* arena) const {\n  ServiceOptions* n = new ServiceOptions;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid ServiceOptions::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.ServiceOptions)\n  _extensions_.Clear();\n  deprecated_ = false;\n  uninterpreted_option_.Clear();\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool ServiceOptions::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.ServiceOptions)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional bool deprecated = 33 [default = false];\n      case 33: {\n        if (tag == 264) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &deprecated_)));\n          set_has_deprecated();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(7994)) goto parse_uninterpreted_option;\n        break;\n      }\n\n      // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n      case 999: {\n        if (tag == 7994) {\n         parse_uninterpreted_option:\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_uninterpreted_option:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_uninterpreted_option()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        if ((8000u <= tag)) {\n          DO_(_extensions_.ParseField(tag, input, default_instance_,\n                                      mutable_unknown_fields()));\n          continue;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.ServiceOptions)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.ServiceOptions)\n  return false;\n#undef DO_\n}\n\nvoid ServiceOptions::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.ServiceOptions)\n  // optional bool deprecated = 33 [default = false];\n  if (has_deprecated()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(33, this->deprecated(), output);\n  }\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      999, this->uninterpreted_option(i), output);\n  }\n\n  // Extension range [1000, 536870912)\n  _extensions_.SerializeWithCachedSizes(\n      1000, 536870912, output);\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.ServiceOptions)\n}\n\n::google::protobuf::uint8* ServiceOptions::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ServiceOptions)\n  // optional bool deprecated = 33 [default = false];\n  if (has_deprecated()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(33, this->deprecated(), target);\n  }\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        999, this->uninterpreted_option(i), false, target);\n  }\n\n  // Extension range [1000, 536870912)\n  target = _extensions_.InternalSerializeWithCachedSizesToArray(\n      1000, 536870912, false, target);\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.ServiceOptions)\n  return target;\n}\n\nint ServiceOptions::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.ServiceOptions)\n  int total_size = 0;\n\n  // optional bool deprecated = 33 [default = false];\n  if (has_deprecated()) {\n    total_size += 2 + 1;\n  }\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  total_size += 2 * this->uninterpreted_option_size();\n  for (int i = 0; i < this->uninterpreted_option_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->uninterpreted_option(i));\n  }\n\n  total_size += _extensions_.ByteSize();\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid ServiceOptions::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.ServiceOptions)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const ServiceOptions* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const ServiceOptions>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.ServiceOptions)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.ServiceOptions)\n    MergeFrom(*source);\n  }\n}\n\nvoid ServiceOptions::MergeFrom(const ServiceOptions& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ServiceOptions)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  uninterpreted_option_.MergeFrom(from.uninterpreted_option_);\n  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {\n    if (from.has_deprecated()) {\n      set_deprecated(from.deprecated());\n    }\n  }\n  _extensions_.MergeFrom(from._extensions_);\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid ServiceOptions::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.ServiceOptions)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid ServiceOptions::CopyFrom(const ServiceOptions& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.ServiceOptions)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool ServiceOptions::IsInitialized() const {\n\n  if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;\n\n  if (!_extensions_.IsInitialized()) return false;  return true;\n}\n\nvoid ServiceOptions::Swap(ServiceOptions* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid ServiceOptions::InternalSwap(ServiceOptions* other) {\n  std::swap(deprecated_, other->deprecated_);\n  uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n  _extensions_.Swap(&other->_extensions_);\n}\n\n::google::protobuf::Metadata ServiceOptions::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = ServiceOptions_descriptor_;\n  metadata.reflection = ServiceOptions_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// ServiceOptions\n\n// optional bool deprecated = 33 [default = false];\nbool ServiceOptions::has_deprecated() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\nvoid ServiceOptions::set_has_deprecated() {\n  _has_bits_[0] |= 0x00000001u;\n}\nvoid ServiceOptions::clear_has_deprecated() {\n  _has_bits_[0] &= ~0x00000001u;\n}\nvoid ServiceOptions::clear_deprecated() {\n  deprecated_ = false;\n  clear_has_deprecated();\n}\n bool ServiceOptions::deprecated() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.ServiceOptions.deprecated)\n  return deprecated_;\n}\n void ServiceOptions::set_deprecated(bool value) {\n  set_has_deprecated();\n  deprecated_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.ServiceOptions.deprecated)\n}\n\n// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\nint ServiceOptions::uninterpreted_option_size() const {\n  return uninterpreted_option_.size();\n}\nvoid ServiceOptions::clear_uninterpreted_option() {\n  uninterpreted_option_.Clear();\n}\nconst ::google::protobuf::UninterpretedOption& ServiceOptions::uninterpreted_option(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.ServiceOptions.uninterpreted_option)\n  return uninterpreted_option_.Get(index);\n}\n::google::protobuf::UninterpretedOption* ServiceOptions::mutable_uninterpreted_option(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceOptions.uninterpreted_option)\n  return uninterpreted_option_.Mutable(index);\n}\n::google::protobuf::UninterpretedOption* ServiceOptions::add_uninterpreted_option() {\n  // @@protoc_insertion_point(field_add:google.protobuf.ServiceOptions.uninterpreted_option)\n  return uninterpreted_option_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\nServiceOptions::mutable_uninterpreted_option() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.ServiceOptions.uninterpreted_option)\n  return &uninterpreted_option_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\nServiceOptions::uninterpreted_option() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.ServiceOptions.uninterpreted_option)\n  return uninterpreted_option_;\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int MethodOptions::kDeprecatedFieldNumber;\nconst int MethodOptions::kUninterpretedOptionFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nMethodOptions::MethodOptions()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.MethodOptions)\n}\n\nvoid MethodOptions::InitAsDefaultInstance() {\n}\n\nMethodOptions::MethodOptions(const MethodOptions& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.MethodOptions)\n}\n\nvoid MethodOptions::SharedCtor() {\n  _cached_size_ = 0;\n  deprecated_ = false;\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nMethodOptions::~MethodOptions() {\n  // @@protoc_insertion_point(destructor:google.protobuf.MethodOptions)\n  SharedDtor();\n}\n\nvoid MethodOptions::SharedDtor() {\n  if (this != default_instance_) {\n  }\n}\n\nvoid MethodOptions::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* MethodOptions::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return MethodOptions_descriptor_;\n}\n\nconst MethodOptions& MethodOptions::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nMethodOptions* MethodOptions::default_instance_ = NULL;\n\nMethodOptions* MethodOptions::New(::google::protobuf::Arena* arena) const {\n  MethodOptions* n = new MethodOptions;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid MethodOptions::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.MethodOptions)\n  _extensions_.Clear();\n  deprecated_ = false;\n  uninterpreted_option_.Clear();\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool MethodOptions::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.MethodOptions)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(16383);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional bool deprecated = 33 [default = false];\n      case 33: {\n        if (tag == 264) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &deprecated_)));\n          set_has_deprecated();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(7994)) goto parse_uninterpreted_option;\n        break;\n      }\n\n      // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n      case 999: {\n        if (tag == 7994) {\n         parse_uninterpreted_option:\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_uninterpreted_option:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_uninterpreted_option()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(7994)) goto parse_loop_uninterpreted_option;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        if ((8000u <= tag)) {\n          DO_(_extensions_.ParseField(tag, input, default_instance_,\n                                      mutable_unknown_fields()));\n          continue;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.MethodOptions)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.MethodOptions)\n  return false;\n#undef DO_\n}\n\nvoid MethodOptions::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.MethodOptions)\n  // optional bool deprecated = 33 [default = false];\n  if (has_deprecated()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(33, this->deprecated(), output);\n  }\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      999, this->uninterpreted_option(i), output);\n  }\n\n  // Extension range [1000, 536870912)\n  _extensions_.SerializeWithCachedSizes(\n      1000, 536870912, output);\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.MethodOptions)\n}\n\n::google::protobuf::uint8* MethodOptions::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.MethodOptions)\n  // optional bool deprecated = 33 [default = false];\n  if (has_deprecated()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(33, this->deprecated(), target);\n  }\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  for (unsigned int i = 0, n = this->uninterpreted_option_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        999, this->uninterpreted_option(i), false, target);\n  }\n\n  // Extension range [1000, 536870912)\n  target = _extensions_.InternalSerializeWithCachedSizesToArray(\n      1000, 536870912, false, target);\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.MethodOptions)\n  return target;\n}\n\nint MethodOptions::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.MethodOptions)\n  int total_size = 0;\n\n  // optional bool deprecated = 33 [default = false];\n  if (has_deprecated()) {\n    total_size += 2 + 1;\n  }\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  total_size += 2 * this->uninterpreted_option_size();\n  for (int i = 0; i < this->uninterpreted_option_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->uninterpreted_option(i));\n  }\n\n  total_size += _extensions_.ByteSize();\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid MethodOptions::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.MethodOptions)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const MethodOptions* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const MethodOptions>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.MethodOptions)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.MethodOptions)\n    MergeFrom(*source);\n  }\n}\n\nvoid MethodOptions::MergeFrom(const MethodOptions& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.MethodOptions)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  uninterpreted_option_.MergeFrom(from.uninterpreted_option_);\n  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {\n    if (from.has_deprecated()) {\n      set_deprecated(from.deprecated());\n    }\n  }\n  _extensions_.MergeFrom(from._extensions_);\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid MethodOptions::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.MethodOptions)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid MethodOptions::CopyFrom(const MethodOptions& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.MethodOptions)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool MethodOptions::IsInitialized() const {\n\n  if (!::google::protobuf::internal::AllAreInitialized(this->uninterpreted_option())) return false;\n\n  if (!_extensions_.IsInitialized()) return false;  return true;\n}\n\nvoid MethodOptions::Swap(MethodOptions* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid MethodOptions::InternalSwap(MethodOptions* other) {\n  std::swap(deprecated_, other->deprecated_);\n  uninterpreted_option_.UnsafeArenaSwap(&other->uninterpreted_option_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n  _extensions_.Swap(&other->_extensions_);\n}\n\n::google::protobuf::Metadata MethodOptions::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = MethodOptions_descriptor_;\n  metadata.reflection = MethodOptions_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// MethodOptions\n\n// optional bool deprecated = 33 [default = false];\nbool MethodOptions::has_deprecated() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\nvoid MethodOptions::set_has_deprecated() {\n  _has_bits_[0] |= 0x00000001u;\n}\nvoid MethodOptions::clear_has_deprecated() {\n  _has_bits_[0] &= ~0x00000001u;\n}\nvoid MethodOptions::clear_deprecated() {\n  deprecated_ = false;\n  clear_has_deprecated();\n}\n bool MethodOptions::deprecated() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.deprecated)\n  return deprecated_;\n}\n void MethodOptions::set_deprecated(bool value) {\n  set_has_deprecated();\n  deprecated_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.deprecated)\n}\n\n// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\nint MethodOptions::uninterpreted_option_size() const {\n  return uninterpreted_option_.size();\n}\nvoid MethodOptions::clear_uninterpreted_option() {\n  uninterpreted_option_.Clear();\n}\nconst ::google::protobuf::UninterpretedOption& MethodOptions::uninterpreted_option(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.uninterpreted_option)\n  return uninterpreted_option_.Get(index);\n}\n::google::protobuf::UninterpretedOption* MethodOptions::mutable_uninterpreted_option(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.MethodOptions.uninterpreted_option)\n  return uninterpreted_option_.Mutable(index);\n}\n::google::protobuf::UninterpretedOption* MethodOptions::add_uninterpreted_option() {\n  // @@protoc_insertion_point(field_add:google.protobuf.MethodOptions.uninterpreted_option)\n  return uninterpreted_option_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\nMethodOptions::mutable_uninterpreted_option() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.MethodOptions.uninterpreted_option)\n  return &uninterpreted_option_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\nMethodOptions::uninterpreted_option() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.MethodOptions.uninterpreted_option)\n  return uninterpreted_option_;\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int UninterpretedOption_NamePart::kNamePartFieldNumber;\nconst int UninterpretedOption_NamePart::kIsExtensionFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nUninterpretedOption_NamePart::UninterpretedOption_NamePart()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.UninterpretedOption.NamePart)\n}\n\nvoid UninterpretedOption_NamePart::InitAsDefaultInstance() {\n}\n\nUninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOption_NamePart& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption.NamePart)\n}\n\nvoid UninterpretedOption_NamePart::SharedCtor() {\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  name_part_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  is_extension_ = false;\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nUninterpretedOption_NamePart::~UninterpretedOption_NamePart() {\n  // @@protoc_insertion_point(destructor:google.protobuf.UninterpretedOption.NamePart)\n  SharedDtor();\n}\n\nvoid UninterpretedOption_NamePart::SharedDtor() {\n  name_part_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n  }\n}\n\nvoid UninterpretedOption_NamePart::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* UninterpretedOption_NamePart::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return UninterpretedOption_NamePart_descriptor_;\n}\n\nconst UninterpretedOption_NamePart& UninterpretedOption_NamePart::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nUninterpretedOption_NamePart* UninterpretedOption_NamePart::default_instance_ = NULL;\n\nUninterpretedOption_NamePart* UninterpretedOption_NamePart::New(::google::protobuf::Arena* arena) const {\n  UninterpretedOption_NamePart* n = new UninterpretedOption_NamePart;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid UninterpretedOption_NamePart::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.UninterpretedOption.NamePart)\n  if (_has_bits_[0 / 32] & 3u) {\n    if (has_name_part()) {\n      name_part_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    is_extension_ = false;\n  }\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool UninterpretedOption_NamePart::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.UninterpretedOption.NamePart)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // required string name_part = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_name_part()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->name_part().data(), this->name_part().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.UninterpretedOption.NamePart.name_part\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(16)) goto parse_is_extension;\n        break;\n      }\n\n      // required bool is_extension = 2;\n      case 2: {\n        if (tag == 16) {\n         parse_is_extension:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &is_extension_)));\n          set_has_is_extension();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.UninterpretedOption.NamePart)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.UninterpretedOption.NamePart)\n  return false;\n#undef DO_\n}\n\nvoid UninterpretedOption_NamePart::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.UninterpretedOption.NamePart)\n  // required string name_part = 1;\n  if (has_name_part()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->name_part().data(), this->name_part().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.UninterpretedOption.NamePart.name_part\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      1, this->name_part(), output);\n  }\n\n  // required bool is_extension = 2;\n  if (has_is_extension()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(2, this->is_extension(), output);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.UninterpretedOption.NamePart)\n}\n\n::google::protobuf::uint8* UninterpretedOption_NamePart::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UninterpretedOption.NamePart)\n  // required string name_part = 1;\n  if (has_name_part()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->name_part().data(), this->name_part().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.UninterpretedOption.NamePart.name_part\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        1, this->name_part(), target);\n  }\n\n  // required bool is_extension = 2;\n  if (has_is_extension()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(2, this->is_extension(), target);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.UninterpretedOption.NamePart)\n  return target;\n}\n\nint UninterpretedOption_NamePart::RequiredFieldsByteSizeFallback() const {\n// @@protoc_insertion_point(required_fields_byte_size_fallback_start:google.protobuf.UninterpretedOption.NamePart)\n  int total_size = 0;\n\n  if (has_name_part()) {\n    // required string name_part = 1;\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::StringSize(\n        this->name_part());\n  }\n\n  if (has_is_extension()) {\n    // required bool is_extension = 2;\n    total_size += 1 + 1;\n  }\n\n  return total_size;\n}\nint UninterpretedOption_NamePart::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.UninterpretedOption.NamePart)\n  int total_size = 0;\n\n  if (((_has_bits_[0] & 0x00000003) ^ 0x00000003) == 0) {  // All required fields are present.\n    // required string name_part = 1;\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::StringSize(\n        this->name_part());\n\n    // required bool is_extension = 2;\n    total_size += 1 + 1;\n\n  } else {\n    total_size += RequiredFieldsByteSizeFallback();\n  }\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid UninterpretedOption_NamePart::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UninterpretedOption.NamePart)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const UninterpretedOption_NamePart* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const UninterpretedOption_NamePart>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.UninterpretedOption.NamePart)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.UninterpretedOption.NamePart)\n    MergeFrom(*source);\n  }\n}\n\nvoid UninterpretedOption_NamePart::MergeFrom(const UninterpretedOption_NamePart& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption.NamePart)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {\n    if (from.has_name_part()) {\n      set_has_name_part();\n      name_part_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_part_);\n    }\n    if (from.has_is_extension()) {\n      set_is_extension(from.is_extension());\n    }\n  }\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid UninterpretedOption_NamePart::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.UninterpretedOption.NamePart)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid UninterpretedOption_NamePart::CopyFrom(const UninterpretedOption_NamePart& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UninterpretedOption.NamePart)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool UninterpretedOption_NamePart::IsInitialized() const {\n  if ((_has_bits_[0] & 0x00000003) != 0x00000003) return false;\n\n  return true;\n}\n\nvoid UninterpretedOption_NamePart::Swap(UninterpretedOption_NamePart* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid UninterpretedOption_NamePart::InternalSwap(UninterpretedOption_NamePart* other) {\n  name_part_.Swap(&other->name_part_);\n  std::swap(is_extension_, other->is_extension_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata UninterpretedOption_NamePart::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = UninterpretedOption_NamePart_descriptor_;\n  metadata.reflection = UninterpretedOption_NamePart_reflection_;\n  return metadata;\n}\n\n\n// -------------------------------------------------------------------\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int UninterpretedOption::kNameFieldNumber;\nconst int UninterpretedOption::kIdentifierValueFieldNumber;\nconst int UninterpretedOption::kPositiveIntValueFieldNumber;\nconst int UninterpretedOption::kNegativeIntValueFieldNumber;\nconst int UninterpretedOption::kDoubleValueFieldNumber;\nconst int UninterpretedOption::kStringValueFieldNumber;\nconst int UninterpretedOption::kAggregateValueFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nUninterpretedOption::UninterpretedOption()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.UninterpretedOption)\n}\n\nvoid UninterpretedOption::InitAsDefaultInstance() {\n}\n\nUninterpretedOption::UninterpretedOption(const UninterpretedOption& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.UninterpretedOption)\n}\n\nvoid UninterpretedOption::SharedCtor() {\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  identifier_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  positive_int_value_ = GOOGLE_ULONGLONG(0);\n  negative_int_value_ = GOOGLE_LONGLONG(0);\n  double_value_ = 0;\n  string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  aggregate_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nUninterpretedOption::~UninterpretedOption() {\n  // @@protoc_insertion_point(destructor:google.protobuf.UninterpretedOption)\n  SharedDtor();\n}\n\nvoid UninterpretedOption::SharedDtor() {\n  identifier_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  string_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  aggregate_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n  }\n}\n\nvoid UninterpretedOption::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* UninterpretedOption::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return UninterpretedOption_descriptor_;\n}\n\nconst UninterpretedOption& UninterpretedOption::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nUninterpretedOption* UninterpretedOption::default_instance_ = NULL;\n\nUninterpretedOption* UninterpretedOption::New(::google::protobuf::Arena* arena) const {\n  UninterpretedOption* n = new UninterpretedOption;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid UninterpretedOption::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.UninterpretedOption)\n#if defined(__clang__)\n#define ZR_HELPER_(f) \\\n  _Pragma(\"clang diagnostic push\") \\\n  _Pragma(\"clang diagnostic ignored \\\"-Winvalid-offsetof\\\"\") \\\n  __builtin_offsetof(UninterpretedOption, f) \\\n  _Pragma(\"clang diagnostic pop\")\n#else\n#define ZR_HELPER_(f) reinterpret_cast<char*>(\\\n  &reinterpret_cast<UninterpretedOption*>(16)->f)\n#endif\n\n#define ZR_(first, last) do {\\\n  ::memset(&first, 0,\\\n           ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\\\n} while (0)\n\n  if (_has_bits_[0 / 32] & 126u) {\n    ZR_(positive_int_value_, double_value_);\n    if (has_identifier_value()) {\n      identifier_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    if (has_string_value()) {\n      string_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    if (has_aggregate_value()) {\n      aggregate_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n  }\n\n#undef ZR_HELPER_\n#undef ZR_\n\n  name_.Clear();\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool UninterpretedOption::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.UninterpretedOption)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // repeated .google.protobuf.UninterpretedOption.NamePart name = 2;\n      case 2: {\n        if (tag == 18) {\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_name:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_name()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_loop_name;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectTag(26)) goto parse_identifier_value;\n        break;\n      }\n\n      // optional string identifier_value = 3;\n      case 3: {\n        if (tag == 26) {\n         parse_identifier_value:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_identifier_value()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->identifier_value().data(), this->identifier_value().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.UninterpretedOption.identifier_value\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(32)) goto parse_positive_int_value;\n        break;\n      }\n\n      // optional uint64 positive_int_value = 4;\n      case 4: {\n        if (tag == 32) {\n         parse_positive_int_value:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>(\n                 input, &positive_int_value_)));\n          set_has_positive_int_value();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(40)) goto parse_negative_int_value;\n        break;\n      }\n\n      // optional int64 negative_int_value = 5;\n      case 5: {\n        if (tag == 40) {\n         parse_negative_int_value:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(\n                 input, &negative_int_value_)));\n          set_has_negative_int_value();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(49)) goto parse_double_value;\n        break;\n      }\n\n      // optional double double_value = 6;\n      case 6: {\n        if (tag == 49) {\n         parse_double_value:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>(\n                 input, &double_value_)));\n          set_has_double_value();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(58)) goto parse_string_value;\n        break;\n      }\n\n      // optional bytes string_value = 7;\n      case 7: {\n        if (tag == 58) {\n         parse_string_value:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(\n                input, this->mutable_string_value()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(66)) goto parse_aggregate_value;\n        break;\n      }\n\n      // optional string aggregate_value = 8;\n      case 8: {\n        if (tag == 66) {\n         parse_aggregate_value:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_aggregate_value()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->aggregate_value().data(), this->aggregate_value().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.UninterpretedOption.aggregate_value\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.UninterpretedOption)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.UninterpretedOption)\n  return false;\n#undef DO_\n}\n\nvoid UninterpretedOption::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.UninterpretedOption)\n  // repeated .google.protobuf.UninterpretedOption.NamePart name = 2;\n  for (unsigned int i = 0, n = this->name_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      2, this->name(i), output);\n  }\n\n  // optional string identifier_value = 3;\n  if (has_identifier_value()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->identifier_value().data(), this->identifier_value().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.UninterpretedOption.identifier_value\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      3, this->identifier_value(), output);\n  }\n\n  // optional uint64 positive_int_value = 4;\n  if (has_positive_int_value()) {\n    ::google::protobuf::internal::WireFormatLite::WriteUInt64(4, this->positive_int_value(), output);\n  }\n\n  // optional int64 negative_int_value = 5;\n  if (has_negative_int_value()) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt64(5, this->negative_int_value(), output);\n  }\n\n  // optional double double_value = 6;\n  if (has_double_value()) {\n    ::google::protobuf::internal::WireFormatLite::WriteDouble(6, this->double_value(), output);\n  }\n\n  // optional bytes string_value = 7;\n  if (has_string_value()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(\n      7, this->string_value(), output);\n  }\n\n  // optional string aggregate_value = 8;\n  if (has_aggregate_value()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->aggregate_value().data(), this->aggregate_value().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.UninterpretedOption.aggregate_value\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      8, this->aggregate_value(), output);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.UninterpretedOption)\n}\n\n::google::protobuf::uint8* UninterpretedOption::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UninterpretedOption)\n  // repeated .google.protobuf.UninterpretedOption.NamePart name = 2;\n  for (unsigned int i = 0, n = this->name_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        2, this->name(i), false, target);\n  }\n\n  // optional string identifier_value = 3;\n  if (has_identifier_value()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->identifier_value().data(), this->identifier_value().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.UninterpretedOption.identifier_value\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        3, this->identifier_value(), target);\n  }\n\n  // optional uint64 positive_int_value = 4;\n  if (has_positive_int_value()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(4, this->positive_int_value(), target);\n  }\n\n  // optional int64 negative_int_value = 5;\n  if (has_negative_int_value()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(5, this->negative_int_value(), target);\n  }\n\n  // optional double double_value = 6;\n  if (has_double_value()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(6, this->double_value(), target);\n  }\n\n  // optional bytes string_value = 7;\n  if (has_string_value()) {\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteBytesToArray(\n        7, this->string_value(), target);\n  }\n\n  // optional string aggregate_value = 8;\n  if (has_aggregate_value()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->aggregate_value().data(), this->aggregate_value().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.UninterpretedOption.aggregate_value\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        8, this->aggregate_value(), target);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.UninterpretedOption)\n  return target;\n}\n\nint UninterpretedOption::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.UninterpretedOption)\n  int total_size = 0;\n\n  if (_has_bits_[1 / 32] & 126u) {\n    // optional string identifier_value = 3;\n    if (has_identifier_value()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->identifier_value());\n    }\n\n    // optional uint64 positive_int_value = 4;\n    if (has_positive_int_value()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::UInt64Size(\n          this->positive_int_value());\n    }\n\n    // optional int64 negative_int_value = 5;\n    if (has_negative_int_value()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::Int64Size(\n          this->negative_int_value());\n    }\n\n    // optional double double_value = 6;\n    if (has_double_value()) {\n      total_size += 1 + 8;\n    }\n\n    // optional bytes string_value = 7;\n    if (has_string_value()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::BytesSize(\n          this->string_value());\n    }\n\n    // optional string aggregate_value = 8;\n    if (has_aggregate_value()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->aggregate_value());\n    }\n\n  }\n  // repeated .google.protobuf.UninterpretedOption.NamePart name = 2;\n  total_size += 1 * this->name_size();\n  for (int i = 0; i < this->name_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->name(i));\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid UninterpretedOption::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UninterpretedOption)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const UninterpretedOption* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const UninterpretedOption>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.UninterpretedOption)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.UninterpretedOption)\n    MergeFrom(*source);\n  }\n}\n\nvoid UninterpretedOption::MergeFrom(const UninterpretedOption& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UninterpretedOption)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  name_.MergeFrom(from.name_);\n  if (from._has_bits_[1 / 32] & (0xffu << (1 % 32))) {\n    if (from.has_identifier_value()) {\n      set_has_identifier_value();\n      identifier_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.identifier_value_);\n    }\n    if (from.has_positive_int_value()) {\n      set_positive_int_value(from.positive_int_value());\n    }\n    if (from.has_negative_int_value()) {\n      set_negative_int_value(from.negative_int_value());\n    }\n    if (from.has_double_value()) {\n      set_double_value(from.double_value());\n    }\n    if (from.has_string_value()) {\n      set_has_string_value();\n      string_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.string_value_);\n    }\n    if (from.has_aggregate_value()) {\n      set_has_aggregate_value();\n      aggregate_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.aggregate_value_);\n    }\n  }\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid UninterpretedOption::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.UninterpretedOption)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid UninterpretedOption::CopyFrom(const UninterpretedOption& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UninterpretedOption)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool UninterpretedOption::IsInitialized() const {\n\n  if (!::google::protobuf::internal::AllAreInitialized(this->name())) return false;\n  return true;\n}\n\nvoid UninterpretedOption::Swap(UninterpretedOption* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid UninterpretedOption::InternalSwap(UninterpretedOption* other) {\n  name_.UnsafeArenaSwap(&other->name_);\n  identifier_value_.Swap(&other->identifier_value_);\n  std::swap(positive_int_value_, other->positive_int_value_);\n  std::swap(negative_int_value_, other->negative_int_value_);\n  std::swap(double_value_, other->double_value_);\n  string_value_.Swap(&other->string_value_);\n  aggregate_value_.Swap(&other->aggregate_value_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata UninterpretedOption::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = UninterpretedOption_descriptor_;\n  metadata.reflection = UninterpretedOption_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// UninterpretedOption_NamePart\n\n// required string name_part = 1;\nbool UninterpretedOption_NamePart::has_name_part() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\nvoid UninterpretedOption_NamePart::set_has_name_part() {\n  _has_bits_[0] |= 0x00000001u;\n}\nvoid UninterpretedOption_NamePart::clear_has_name_part() {\n  _has_bits_[0] &= ~0x00000001u;\n}\nvoid UninterpretedOption_NamePart::clear_name_part() {\n  name_part_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_name_part();\n}\n const ::std::string& UninterpretedOption_NamePart::name_part() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.name_part)\n  return name_part_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void UninterpretedOption_NamePart::set_name_part(const ::std::string& value) {\n  set_has_name_part();\n  name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.name_part)\n}\n void UninterpretedOption_NamePart::set_name_part(const char* value) {\n  set_has_name_part();\n  name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.NamePart.name_part)\n}\n void UninterpretedOption_NamePart::set_name_part(const char* value, size_t size) {\n  set_has_name_part();\n  name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.NamePart.name_part)\n}\n ::std::string* UninterpretedOption_NamePart::mutable_name_part() {\n  set_has_name_part();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.NamePart.name_part)\n  return name_part_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* UninterpretedOption_NamePart::release_name_part() {\n  // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.NamePart.name_part)\n  clear_has_name_part();\n  return name_part_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void UninterpretedOption_NamePart::set_allocated_name_part(::std::string* name_part) {\n  if (name_part != NULL) {\n    set_has_name_part();\n  } else {\n    clear_has_name_part();\n  }\n  name_part_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name_part);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.NamePart.name_part)\n}\n\n// required bool is_extension = 2;\nbool UninterpretedOption_NamePart::has_is_extension() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\nvoid UninterpretedOption_NamePart::set_has_is_extension() {\n  _has_bits_[0] |= 0x00000002u;\n}\nvoid UninterpretedOption_NamePart::clear_has_is_extension() {\n  _has_bits_[0] &= ~0x00000002u;\n}\nvoid UninterpretedOption_NamePart::clear_is_extension() {\n  is_extension_ = false;\n  clear_has_is_extension();\n}\n bool UninterpretedOption_NamePart::is_extension() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.is_extension)\n  return is_extension_;\n}\n void UninterpretedOption_NamePart::set_is_extension(bool value) {\n  set_has_is_extension();\n  is_extension_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.is_extension)\n}\n\n// -------------------------------------------------------------------\n\n// UninterpretedOption\n\n// repeated .google.protobuf.UninterpretedOption.NamePart name = 2;\nint UninterpretedOption::name_size() const {\n  return name_.size();\n}\nvoid UninterpretedOption::clear_name() {\n  name_.Clear();\n}\nconst ::google::protobuf::UninterpretedOption_NamePart& UninterpretedOption::name(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.name)\n  return name_.Get(index);\n}\n::google::protobuf::UninterpretedOption_NamePart* UninterpretedOption::mutable_name(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.name)\n  return name_.Mutable(index);\n}\n::google::protobuf::UninterpretedOption_NamePart* UninterpretedOption::add_name() {\n  // @@protoc_insertion_point(field_add:google.protobuf.UninterpretedOption.name)\n  return name_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart >*\nUninterpretedOption::mutable_name() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.UninterpretedOption.name)\n  return &name_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart >&\nUninterpretedOption::name() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.UninterpretedOption.name)\n  return name_;\n}\n\n// optional string identifier_value = 3;\nbool UninterpretedOption::has_identifier_value() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\nvoid UninterpretedOption::set_has_identifier_value() {\n  _has_bits_[0] |= 0x00000002u;\n}\nvoid UninterpretedOption::clear_has_identifier_value() {\n  _has_bits_[0] &= ~0x00000002u;\n}\nvoid UninterpretedOption::clear_identifier_value() {\n  identifier_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_identifier_value();\n}\n const ::std::string& UninterpretedOption::identifier_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.identifier_value)\n  return identifier_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void UninterpretedOption::set_identifier_value(const ::std::string& value) {\n  set_has_identifier_value();\n  identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.identifier_value)\n}\n void UninterpretedOption::set_identifier_value(const char* value) {\n  set_has_identifier_value();\n  identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.identifier_value)\n}\n void UninterpretedOption::set_identifier_value(const char* value, size_t size) {\n  set_has_identifier_value();\n  identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.identifier_value)\n}\n ::std::string* UninterpretedOption::mutable_identifier_value() {\n  set_has_identifier_value();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.identifier_value)\n  return identifier_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* UninterpretedOption::release_identifier_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.identifier_value)\n  clear_has_identifier_value();\n  return identifier_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void UninterpretedOption::set_allocated_identifier_value(::std::string* identifier_value) {\n  if (identifier_value != NULL) {\n    set_has_identifier_value();\n  } else {\n    clear_has_identifier_value();\n  }\n  identifier_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), identifier_value);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.identifier_value)\n}\n\n// optional uint64 positive_int_value = 4;\nbool UninterpretedOption::has_positive_int_value() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\nvoid UninterpretedOption::set_has_positive_int_value() {\n  _has_bits_[0] |= 0x00000004u;\n}\nvoid UninterpretedOption::clear_has_positive_int_value() {\n  _has_bits_[0] &= ~0x00000004u;\n}\nvoid UninterpretedOption::clear_positive_int_value() {\n  positive_int_value_ = GOOGLE_ULONGLONG(0);\n  clear_has_positive_int_value();\n}\n ::google::protobuf::uint64 UninterpretedOption::positive_int_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.positive_int_value)\n  return positive_int_value_;\n}\n void UninterpretedOption::set_positive_int_value(::google::protobuf::uint64 value) {\n  set_has_positive_int_value();\n  positive_int_value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.positive_int_value)\n}\n\n// optional int64 negative_int_value = 5;\nbool UninterpretedOption::has_negative_int_value() const {\n  return (_has_bits_[0] & 0x00000008u) != 0;\n}\nvoid UninterpretedOption::set_has_negative_int_value() {\n  _has_bits_[0] |= 0x00000008u;\n}\nvoid UninterpretedOption::clear_has_negative_int_value() {\n  _has_bits_[0] &= ~0x00000008u;\n}\nvoid UninterpretedOption::clear_negative_int_value() {\n  negative_int_value_ = GOOGLE_LONGLONG(0);\n  clear_has_negative_int_value();\n}\n ::google::protobuf::int64 UninterpretedOption::negative_int_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.negative_int_value)\n  return negative_int_value_;\n}\n void UninterpretedOption::set_negative_int_value(::google::protobuf::int64 value) {\n  set_has_negative_int_value();\n  negative_int_value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.negative_int_value)\n}\n\n// optional double double_value = 6;\nbool UninterpretedOption::has_double_value() const {\n  return (_has_bits_[0] & 0x00000010u) != 0;\n}\nvoid UninterpretedOption::set_has_double_value() {\n  _has_bits_[0] |= 0x00000010u;\n}\nvoid UninterpretedOption::clear_has_double_value() {\n  _has_bits_[0] &= ~0x00000010u;\n}\nvoid UninterpretedOption::clear_double_value() {\n  double_value_ = 0;\n  clear_has_double_value();\n}\n double UninterpretedOption::double_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.double_value)\n  return double_value_;\n}\n void UninterpretedOption::set_double_value(double value) {\n  set_has_double_value();\n  double_value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.double_value)\n}\n\n// optional bytes string_value = 7;\nbool UninterpretedOption::has_string_value() const {\n  return (_has_bits_[0] & 0x00000020u) != 0;\n}\nvoid UninterpretedOption::set_has_string_value() {\n  _has_bits_[0] |= 0x00000020u;\n}\nvoid UninterpretedOption::clear_has_string_value() {\n  _has_bits_[0] &= ~0x00000020u;\n}\nvoid UninterpretedOption::clear_string_value() {\n  string_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_string_value();\n}\n const ::std::string& UninterpretedOption::string_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.string_value)\n  return string_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void UninterpretedOption::set_string_value(const ::std::string& value) {\n  set_has_string_value();\n  string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.string_value)\n}\n void UninterpretedOption::set_string_value(const char* value) {\n  set_has_string_value();\n  string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.string_value)\n}\n void UninterpretedOption::set_string_value(const void* value, size_t size) {\n  set_has_string_value();\n  string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.string_value)\n}\n ::std::string* UninterpretedOption::mutable_string_value() {\n  set_has_string_value();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.string_value)\n  return string_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* UninterpretedOption::release_string_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.string_value)\n  clear_has_string_value();\n  return string_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void UninterpretedOption::set_allocated_string_value(::std::string* string_value) {\n  if (string_value != NULL) {\n    set_has_string_value();\n  } else {\n    clear_has_string_value();\n  }\n  string_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), string_value);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.string_value)\n}\n\n// optional string aggregate_value = 8;\nbool UninterpretedOption::has_aggregate_value() const {\n  return (_has_bits_[0] & 0x00000040u) != 0;\n}\nvoid UninterpretedOption::set_has_aggregate_value() {\n  _has_bits_[0] |= 0x00000040u;\n}\nvoid UninterpretedOption::clear_has_aggregate_value() {\n  _has_bits_[0] &= ~0x00000040u;\n}\nvoid UninterpretedOption::clear_aggregate_value() {\n  aggregate_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_aggregate_value();\n}\n const ::std::string& UninterpretedOption::aggregate_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.aggregate_value)\n  return aggregate_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void UninterpretedOption::set_aggregate_value(const ::std::string& value) {\n  set_has_aggregate_value();\n  aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.aggregate_value)\n}\n void UninterpretedOption::set_aggregate_value(const char* value) {\n  set_has_aggregate_value();\n  aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.aggregate_value)\n}\n void UninterpretedOption::set_aggregate_value(const char* value, size_t size) {\n  set_has_aggregate_value();\n  aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.aggregate_value)\n}\n ::std::string* UninterpretedOption::mutable_aggregate_value() {\n  set_has_aggregate_value();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.aggregate_value)\n  return aggregate_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* UninterpretedOption::release_aggregate_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.aggregate_value)\n  clear_has_aggregate_value();\n  return aggregate_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void UninterpretedOption::set_allocated_aggregate_value(::std::string* aggregate_value) {\n  if (aggregate_value != NULL) {\n    set_has_aggregate_value();\n  } else {\n    clear_has_aggregate_value();\n  }\n  aggregate_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), aggregate_value);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.aggregate_value)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int SourceCodeInfo_Location::kPathFieldNumber;\nconst int SourceCodeInfo_Location::kSpanFieldNumber;\nconst int SourceCodeInfo_Location::kLeadingCommentsFieldNumber;\nconst int SourceCodeInfo_Location::kTrailingCommentsFieldNumber;\nconst int SourceCodeInfo_Location::kLeadingDetachedCommentsFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nSourceCodeInfo_Location::SourceCodeInfo_Location()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.SourceCodeInfo.Location)\n}\n\nvoid SourceCodeInfo_Location::InitAsDefaultInstance() {\n}\n\nSourceCodeInfo_Location::SourceCodeInfo_Location(const SourceCodeInfo_Location& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo.Location)\n}\n\nvoid SourceCodeInfo_Location::SharedCtor() {\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  leading_comments_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  trailing_comments_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nSourceCodeInfo_Location::~SourceCodeInfo_Location() {\n  // @@protoc_insertion_point(destructor:google.protobuf.SourceCodeInfo.Location)\n  SharedDtor();\n}\n\nvoid SourceCodeInfo_Location::SharedDtor() {\n  leading_comments_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  trailing_comments_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n  }\n}\n\nvoid SourceCodeInfo_Location::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* SourceCodeInfo_Location::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return SourceCodeInfo_Location_descriptor_;\n}\n\nconst SourceCodeInfo_Location& SourceCodeInfo_Location::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nSourceCodeInfo_Location* SourceCodeInfo_Location::default_instance_ = NULL;\n\nSourceCodeInfo_Location* SourceCodeInfo_Location::New(::google::protobuf::Arena* arena) const {\n  SourceCodeInfo_Location* n = new SourceCodeInfo_Location;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid SourceCodeInfo_Location::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo.Location)\n  if (_has_bits_[0 / 32] & 12u) {\n    if (has_leading_comments()) {\n      leading_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n    if (has_trailing_comments()) {\n      trailing_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n  }\n  path_.Clear();\n  span_.Clear();\n  leading_detached_comments_.Clear();\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool SourceCodeInfo_Location::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.SourceCodeInfo.Location)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // repeated int32 path = 1 [packed = true];\n      case 1: {\n        if (tag == 10) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 input, this->mutable_path())));\n        } else if (tag == 8) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 1, 10, input, this->mutable_path())));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_span;\n        break;\n      }\n\n      // repeated int32 span = 2 [packed = true];\n      case 2: {\n        if (tag == 18) {\n         parse_span:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 input, this->mutable_span())));\n        } else if (tag == 16) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 1, 18, input, this->mutable_span())));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(26)) goto parse_leading_comments;\n        break;\n      }\n\n      // optional string leading_comments = 3;\n      case 3: {\n        if (tag == 26) {\n         parse_leading_comments:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_leading_comments()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->leading_comments().data(), this->leading_comments().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.SourceCodeInfo.Location.leading_comments\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(34)) goto parse_trailing_comments;\n        break;\n      }\n\n      // optional string trailing_comments = 4;\n      case 4: {\n        if (tag == 34) {\n         parse_trailing_comments:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_trailing_comments()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->trailing_comments().data(), this->trailing_comments().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.SourceCodeInfo.Location.trailing_comments\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(50)) goto parse_leading_detached_comments;\n        break;\n      }\n\n      // repeated string leading_detached_comments = 6;\n      case 6: {\n        if (tag == 50) {\n         parse_leading_detached_comments:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->add_leading_detached_comments()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->leading_detached_comments(this->leading_detached_comments_size() - 1).data(),\n            this->leading_detached_comments(this->leading_detached_comments_size() - 1).length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.SourceCodeInfo.Location.leading_detached_comments\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(50)) goto parse_leading_detached_comments;\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.SourceCodeInfo.Location)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.SourceCodeInfo.Location)\n  return false;\n#undef DO_\n}\n\nvoid SourceCodeInfo_Location::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.SourceCodeInfo.Location)\n  // repeated int32 path = 1 [packed = true];\n  if (this->path_size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteTag(1, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);\n    output->WriteVarint32(_path_cached_byte_size_);\n  }\n  for (int i = 0; i < this->path_size(); i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt32NoTag(\n      this->path(i), output);\n  }\n\n  // repeated int32 span = 2 [packed = true];\n  if (this->span_size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteTag(2, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);\n    output->WriteVarint32(_span_cached_byte_size_);\n  }\n  for (int i = 0; i < this->span_size(); i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt32NoTag(\n      this->span(i), output);\n  }\n\n  // optional string leading_comments = 3;\n  if (has_leading_comments()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->leading_comments().data(), this->leading_comments().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.SourceCodeInfo.Location.leading_comments\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      3, this->leading_comments(), output);\n  }\n\n  // optional string trailing_comments = 4;\n  if (has_trailing_comments()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->trailing_comments().data(), this->trailing_comments().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.SourceCodeInfo.Location.trailing_comments\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      4, this->trailing_comments(), output);\n  }\n\n  // repeated string leading_detached_comments = 6;\n  for (int i = 0; i < this->leading_detached_comments_size(); i++) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->leading_detached_comments(i).data(), this->leading_detached_comments(i).length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.SourceCodeInfo.Location.leading_detached_comments\");\n    ::google::protobuf::internal::WireFormatLite::WriteString(\n      6, this->leading_detached_comments(i), output);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.SourceCodeInfo.Location)\n}\n\n::google::protobuf::uint8* SourceCodeInfo_Location::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceCodeInfo.Location)\n  // repeated int32 path = 1 [packed = true];\n  if (this->path_size() > 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray(\n      1,\n      ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n      target);\n    target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(\n      _path_cached_byte_size_, target);\n  }\n  for (int i = 0; i < this->path_size(); i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      WriteInt32NoTagToArray(this->path(i), target);\n  }\n\n  // repeated int32 span = 2 [packed = true];\n  if (this->span_size() > 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray(\n      2,\n      ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n      target);\n    target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(\n      _span_cached_byte_size_, target);\n  }\n  for (int i = 0; i < this->span_size(); i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      WriteInt32NoTagToArray(this->span(i), target);\n  }\n\n  // optional string leading_comments = 3;\n  if (has_leading_comments()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->leading_comments().data(), this->leading_comments().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.SourceCodeInfo.Location.leading_comments\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        3, this->leading_comments(), target);\n  }\n\n  // optional string trailing_comments = 4;\n  if (has_trailing_comments()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->trailing_comments().data(), this->trailing_comments().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.SourceCodeInfo.Location.trailing_comments\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        4, this->trailing_comments(), target);\n  }\n\n  // repeated string leading_detached_comments = 6;\n  for (int i = 0; i < this->leading_detached_comments_size(); i++) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->leading_detached_comments(i).data(), this->leading_detached_comments(i).length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.SourceCodeInfo.Location.leading_detached_comments\");\n    target = ::google::protobuf::internal::WireFormatLite::\n      WriteStringToArray(6, this->leading_detached_comments(i), target);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.SourceCodeInfo.Location)\n  return target;\n}\n\nint SourceCodeInfo_Location::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceCodeInfo.Location)\n  int total_size = 0;\n\n  if (_has_bits_[2 / 32] & 12u) {\n    // optional string leading_comments = 3;\n    if (has_leading_comments()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->leading_comments());\n    }\n\n    // optional string trailing_comments = 4;\n    if (has_trailing_comments()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->trailing_comments());\n    }\n\n  }\n  // repeated int32 path = 1 [packed = true];\n  {\n    int data_size = 0;\n    for (int i = 0; i < this->path_size(); i++) {\n      data_size += ::google::protobuf::internal::WireFormatLite::\n        Int32Size(this->path(i));\n    }\n    if (data_size > 0) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);\n    }\n    GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n    _path_cached_byte_size_ = data_size;\n    GOOGLE_SAFE_CONCURRENT_WRITES_END();\n    total_size += data_size;\n  }\n\n  // repeated int32 span = 2 [packed = true];\n  {\n    int data_size = 0;\n    for (int i = 0; i < this->span_size(); i++) {\n      data_size += ::google::protobuf::internal::WireFormatLite::\n        Int32Size(this->span(i));\n    }\n    if (data_size > 0) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);\n    }\n    GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n    _span_cached_byte_size_ = data_size;\n    GOOGLE_SAFE_CONCURRENT_WRITES_END();\n    total_size += data_size;\n  }\n\n  // repeated string leading_detached_comments = 6;\n  total_size += 1 * this->leading_detached_comments_size();\n  for (int i = 0; i < this->leading_detached_comments_size(); i++) {\n    total_size += ::google::protobuf::internal::WireFormatLite::StringSize(\n      this->leading_detached_comments(i));\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid SourceCodeInfo_Location::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.SourceCodeInfo.Location)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const SourceCodeInfo_Location* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const SourceCodeInfo_Location>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.SourceCodeInfo.Location)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceCodeInfo.Location)\n    MergeFrom(*source);\n  }\n}\n\nvoid SourceCodeInfo_Location::MergeFrom(const SourceCodeInfo_Location& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo.Location)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  path_.MergeFrom(from.path_);\n  span_.MergeFrom(from.span_);\n  leading_detached_comments_.MergeFrom(from.leading_detached_comments_);\n  if (from._has_bits_[2 / 32] & (0xffu << (2 % 32))) {\n    if (from.has_leading_comments()) {\n      set_has_leading_comments();\n      leading_comments_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.leading_comments_);\n    }\n    if (from.has_trailing_comments()) {\n      set_has_trailing_comments();\n      trailing_comments_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.trailing_comments_);\n    }\n  }\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid SourceCodeInfo_Location::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.SourceCodeInfo.Location)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid SourceCodeInfo_Location::CopyFrom(const SourceCodeInfo_Location& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceCodeInfo.Location)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool SourceCodeInfo_Location::IsInitialized() const {\n\n  return true;\n}\n\nvoid SourceCodeInfo_Location::Swap(SourceCodeInfo_Location* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid SourceCodeInfo_Location::InternalSwap(SourceCodeInfo_Location* other) {\n  path_.UnsafeArenaSwap(&other->path_);\n  span_.UnsafeArenaSwap(&other->span_);\n  leading_comments_.Swap(&other->leading_comments_);\n  trailing_comments_.Swap(&other->trailing_comments_);\n  leading_detached_comments_.UnsafeArenaSwap(&other->leading_detached_comments_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata SourceCodeInfo_Location::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = SourceCodeInfo_Location_descriptor_;\n  metadata.reflection = SourceCodeInfo_Location_reflection_;\n  return metadata;\n}\n\n\n// -------------------------------------------------------------------\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int SourceCodeInfo::kLocationFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nSourceCodeInfo::SourceCodeInfo()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.SourceCodeInfo)\n}\n\nvoid SourceCodeInfo::InitAsDefaultInstance() {\n}\n\nSourceCodeInfo::SourceCodeInfo(const SourceCodeInfo& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceCodeInfo)\n}\n\nvoid SourceCodeInfo::SharedCtor() {\n  _cached_size_ = 0;\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nSourceCodeInfo::~SourceCodeInfo() {\n  // @@protoc_insertion_point(destructor:google.protobuf.SourceCodeInfo)\n  SharedDtor();\n}\n\nvoid SourceCodeInfo::SharedDtor() {\n  if (this != default_instance_) {\n  }\n}\n\nvoid SourceCodeInfo::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* SourceCodeInfo::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return SourceCodeInfo_descriptor_;\n}\n\nconst SourceCodeInfo& SourceCodeInfo::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nSourceCodeInfo* SourceCodeInfo::default_instance_ = NULL;\n\nSourceCodeInfo* SourceCodeInfo::New(::google::protobuf::Arena* arena) const {\n  SourceCodeInfo* n = new SourceCodeInfo;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid SourceCodeInfo::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.SourceCodeInfo)\n  location_.Clear();\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool SourceCodeInfo::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.SourceCodeInfo)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // repeated .google.protobuf.SourceCodeInfo.Location location = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_location:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_location()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(10)) goto parse_loop_location;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.SourceCodeInfo)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.SourceCodeInfo)\n  return false;\n#undef DO_\n}\n\nvoid SourceCodeInfo::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.SourceCodeInfo)\n  // repeated .google.protobuf.SourceCodeInfo.Location location = 1;\n  for (unsigned int i = 0, n = this->location_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      1, this->location(i), output);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.SourceCodeInfo)\n}\n\n::google::protobuf::uint8* SourceCodeInfo::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceCodeInfo)\n  // repeated .google.protobuf.SourceCodeInfo.Location location = 1;\n  for (unsigned int i = 0, n = this->location_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        1, this->location(i), false, target);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.SourceCodeInfo)\n  return target;\n}\n\nint SourceCodeInfo::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceCodeInfo)\n  int total_size = 0;\n\n  // repeated .google.protobuf.SourceCodeInfo.Location location = 1;\n  total_size += 1 * this->location_size();\n  for (int i = 0; i < this->location_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->location(i));\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid SourceCodeInfo::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.SourceCodeInfo)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const SourceCodeInfo* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const SourceCodeInfo>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.SourceCodeInfo)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceCodeInfo)\n    MergeFrom(*source);\n  }\n}\n\nvoid SourceCodeInfo::MergeFrom(const SourceCodeInfo& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceCodeInfo)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  location_.MergeFrom(from.location_);\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid SourceCodeInfo::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.SourceCodeInfo)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid SourceCodeInfo::CopyFrom(const SourceCodeInfo& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceCodeInfo)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool SourceCodeInfo::IsInitialized() const {\n\n  return true;\n}\n\nvoid SourceCodeInfo::Swap(SourceCodeInfo* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid SourceCodeInfo::InternalSwap(SourceCodeInfo* other) {\n  location_.UnsafeArenaSwap(&other->location_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata SourceCodeInfo::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = SourceCodeInfo_descriptor_;\n  metadata.reflection = SourceCodeInfo_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// SourceCodeInfo_Location\n\n// repeated int32 path = 1 [packed = true];\nint SourceCodeInfo_Location::path_size() const {\n  return path_.size();\n}\nvoid SourceCodeInfo_Location::clear_path() {\n  path_.Clear();\n}\n ::google::protobuf::int32 SourceCodeInfo_Location::path(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.path)\n  return path_.Get(index);\n}\n void SourceCodeInfo_Location::set_path(int index, ::google::protobuf::int32 value) {\n  path_.Set(index, value);\n  // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.path)\n}\n void SourceCodeInfo_Location::add_path(::google::protobuf::int32 value) {\n  path_.Add(value);\n  // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.path)\n}\n const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&\nSourceCodeInfo_Location::path() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.Location.path)\n  return path_;\n}\n ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*\nSourceCodeInfo_Location::mutable_path() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.Location.path)\n  return &path_;\n}\n\n// repeated int32 span = 2 [packed = true];\nint SourceCodeInfo_Location::span_size() const {\n  return span_.size();\n}\nvoid SourceCodeInfo_Location::clear_span() {\n  span_.Clear();\n}\n ::google::protobuf::int32 SourceCodeInfo_Location::span(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.span)\n  return span_.Get(index);\n}\n void SourceCodeInfo_Location::set_span(int index, ::google::protobuf::int32 value) {\n  span_.Set(index, value);\n  // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.span)\n}\n void SourceCodeInfo_Location::add_span(::google::protobuf::int32 value) {\n  span_.Add(value);\n  // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.span)\n}\n const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&\nSourceCodeInfo_Location::span() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.Location.span)\n  return span_;\n}\n ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*\nSourceCodeInfo_Location::mutable_span() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.Location.span)\n  return &span_;\n}\n\n// optional string leading_comments = 3;\nbool SourceCodeInfo_Location::has_leading_comments() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\nvoid SourceCodeInfo_Location::set_has_leading_comments() {\n  _has_bits_[0] |= 0x00000004u;\n}\nvoid SourceCodeInfo_Location::clear_has_leading_comments() {\n  _has_bits_[0] &= ~0x00000004u;\n}\nvoid SourceCodeInfo_Location::clear_leading_comments() {\n  leading_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_leading_comments();\n}\n const ::std::string& SourceCodeInfo_Location::leading_comments() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.leading_comments)\n  return leading_comments_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void SourceCodeInfo_Location::set_leading_comments(const ::std::string& value) {\n  set_has_leading_comments();\n  leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_comments)\n}\n void SourceCodeInfo_Location::set_leading_comments(const char* value) {\n  set_has_leading_comments();\n  leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.leading_comments)\n}\n void SourceCodeInfo_Location::set_leading_comments(const char* value, size_t size) {\n  set_has_leading_comments();\n  leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.leading_comments)\n}\n ::std::string* SourceCodeInfo_Location::mutable_leading_comments() {\n  set_has_leading_comments();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.Location.leading_comments)\n  return leading_comments_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* SourceCodeInfo_Location::release_leading_comments() {\n  // @@protoc_insertion_point(field_release:google.protobuf.SourceCodeInfo.Location.leading_comments)\n  clear_has_leading_comments();\n  return leading_comments_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void SourceCodeInfo_Location::set_allocated_leading_comments(::std::string* leading_comments) {\n  if (leading_comments != NULL) {\n    set_has_leading_comments();\n  } else {\n    clear_has_leading_comments();\n  }\n  leading_comments_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), leading_comments);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceCodeInfo.Location.leading_comments)\n}\n\n// optional string trailing_comments = 4;\nbool SourceCodeInfo_Location::has_trailing_comments() const {\n  return (_has_bits_[0] & 0x00000008u) != 0;\n}\nvoid SourceCodeInfo_Location::set_has_trailing_comments() {\n  _has_bits_[0] |= 0x00000008u;\n}\nvoid SourceCodeInfo_Location::clear_has_trailing_comments() {\n  _has_bits_[0] &= ~0x00000008u;\n}\nvoid SourceCodeInfo_Location::clear_trailing_comments() {\n  trailing_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_trailing_comments();\n}\n const ::std::string& SourceCodeInfo_Location::trailing_comments() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.trailing_comments)\n  return trailing_comments_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void SourceCodeInfo_Location::set_trailing_comments(const ::std::string& value) {\n  set_has_trailing_comments();\n  trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.trailing_comments)\n}\n void SourceCodeInfo_Location::set_trailing_comments(const char* value) {\n  set_has_trailing_comments();\n  trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.trailing_comments)\n}\n void SourceCodeInfo_Location::set_trailing_comments(const char* value, size_t size) {\n  set_has_trailing_comments();\n  trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.trailing_comments)\n}\n ::std::string* SourceCodeInfo_Location::mutable_trailing_comments() {\n  set_has_trailing_comments();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.Location.trailing_comments)\n  return trailing_comments_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* SourceCodeInfo_Location::release_trailing_comments() {\n  // @@protoc_insertion_point(field_release:google.protobuf.SourceCodeInfo.Location.trailing_comments)\n  clear_has_trailing_comments();\n  return trailing_comments_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void SourceCodeInfo_Location::set_allocated_trailing_comments(::std::string* trailing_comments) {\n  if (trailing_comments != NULL) {\n    set_has_trailing_comments();\n  } else {\n    clear_has_trailing_comments();\n  }\n  trailing_comments_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), trailing_comments);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceCodeInfo.Location.trailing_comments)\n}\n\n// repeated string leading_detached_comments = 6;\nint SourceCodeInfo_Location::leading_detached_comments_size() const {\n  return leading_detached_comments_.size();\n}\nvoid SourceCodeInfo_Location::clear_leading_detached_comments() {\n  leading_detached_comments_.Clear();\n}\n const ::std::string& SourceCodeInfo_Location::leading_detached_comments(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)\n  return leading_detached_comments_.Get(index);\n}\n ::std::string* SourceCodeInfo_Location::mutable_leading_detached_comments(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)\n  return leading_detached_comments_.Mutable(index);\n}\n void SourceCodeInfo_Location::set_leading_detached_comments(int index, const ::std::string& value) {\n  // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)\n  leading_detached_comments_.Mutable(index)->assign(value);\n}\n void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value) {\n  leading_detached_comments_.Mutable(index)->assign(value);\n  // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)\n}\n void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value, size_t size) {\n  leading_detached_comments_.Mutable(index)->assign(\n    reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)\n}\n ::std::string* SourceCodeInfo_Location::add_leading_detached_comments() {\n  // @@protoc_insertion_point(field_add_mutable:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)\n  return leading_detached_comments_.Add();\n}\n void SourceCodeInfo_Location::add_leading_detached_comments(const ::std::string& value) {\n  leading_detached_comments_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)\n}\n void SourceCodeInfo_Location::add_leading_detached_comments(const char* value) {\n  leading_detached_comments_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)\n}\n void SourceCodeInfo_Location::add_leading_detached_comments(const char* value, size_t size) {\n  leading_detached_comments_.Add()->assign(reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_add_pointer:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)\n}\n const ::google::protobuf::RepeatedPtrField< ::std::string>&\nSourceCodeInfo_Location::leading_detached_comments() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)\n  return leading_detached_comments_;\n}\n ::google::protobuf::RepeatedPtrField< ::std::string>*\nSourceCodeInfo_Location::mutable_leading_detached_comments() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)\n  return &leading_detached_comments_;\n}\n\n// -------------------------------------------------------------------\n\n// SourceCodeInfo\n\n// repeated .google.protobuf.SourceCodeInfo.Location location = 1;\nint SourceCodeInfo::location_size() const {\n  return location_.size();\n}\nvoid SourceCodeInfo::clear_location() {\n  location_.Clear();\n}\nconst ::google::protobuf::SourceCodeInfo_Location& SourceCodeInfo::location(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.location)\n  return location_.Get(index);\n}\n::google::protobuf::SourceCodeInfo_Location* SourceCodeInfo::mutable_location(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.location)\n  return location_.Mutable(index);\n}\n::google::protobuf::SourceCodeInfo_Location* SourceCodeInfo::add_location() {\n  // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.location)\n  return location_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location >*\nSourceCodeInfo::mutable_location() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.location)\n  return &location_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location >&\nSourceCodeInfo::location() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.location)\n  return location_;\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int GeneratedCodeInfo_Annotation::kPathFieldNumber;\nconst int GeneratedCodeInfo_Annotation::kSourceFileFieldNumber;\nconst int GeneratedCodeInfo_Annotation::kBeginFieldNumber;\nconst int GeneratedCodeInfo_Annotation::kEndFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nGeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.GeneratedCodeInfo.Annotation)\n}\n\nvoid GeneratedCodeInfo_Annotation::InitAsDefaultInstance() {\n}\n\nGeneratedCodeInfo_Annotation::GeneratedCodeInfo_Annotation(const GeneratedCodeInfo_Annotation& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.GeneratedCodeInfo.Annotation)\n}\n\nvoid GeneratedCodeInfo_Annotation::SharedCtor() {\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  source_file_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  begin_ = 0;\n  end_ = 0;\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nGeneratedCodeInfo_Annotation::~GeneratedCodeInfo_Annotation() {\n  // @@protoc_insertion_point(destructor:google.protobuf.GeneratedCodeInfo.Annotation)\n  SharedDtor();\n}\n\nvoid GeneratedCodeInfo_Annotation::SharedDtor() {\n  source_file_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n  }\n}\n\nvoid GeneratedCodeInfo_Annotation::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* GeneratedCodeInfo_Annotation::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return GeneratedCodeInfo_Annotation_descriptor_;\n}\n\nconst GeneratedCodeInfo_Annotation& GeneratedCodeInfo_Annotation::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nGeneratedCodeInfo_Annotation* GeneratedCodeInfo_Annotation::default_instance_ = NULL;\n\nGeneratedCodeInfo_Annotation* GeneratedCodeInfo_Annotation::New(::google::protobuf::Arena* arena) const {\n  GeneratedCodeInfo_Annotation* n = new GeneratedCodeInfo_Annotation;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid GeneratedCodeInfo_Annotation::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo.Annotation)\n#if defined(__clang__)\n#define ZR_HELPER_(f) \\\n  _Pragma(\"clang diagnostic push\") \\\n  _Pragma(\"clang diagnostic ignored \\\"-Winvalid-offsetof\\\"\") \\\n  __builtin_offsetof(GeneratedCodeInfo_Annotation, f) \\\n  _Pragma(\"clang diagnostic pop\")\n#else\n#define ZR_HELPER_(f) reinterpret_cast<char*>(\\\n  &reinterpret_cast<GeneratedCodeInfo_Annotation*>(16)->f)\n#endif\n\n#define ZR_(first, last) do {\\\n  ::memset(&first, 0,\\\n           ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\\\n} while (0)\n\n  if (_has_bits_[0 / 32] & 14u) {\n    ZR_(begin_, end_);\n    if (has_source_file()) {\n      source_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    }\n  }\n\n#undef ZR_HELPER_\n#undef ZR_\n\n  path_.Clear();\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool GeneratedCodeInfo_Annotation::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.GeneratedCodeInfo.Annotation)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // repeated int32 path = 1 [packed = true];\n      case 1: {\n        if (tag == 10) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 input, this->mutable_path())));\n        } else if (tag == 8) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 1, 10, input, this->mutable_path())));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_source_file;\n        break;\n      }\n\n      // optional string source_file = 2;\n      case 2: {\n        if (tag == 18) {\n         parse_source_file:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_source_file()));\n          ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n            this->source_file().data(), this->source_file().length(),\n            ::google::protobuf::internal::WireFormat::PARSE,\n            \"google.protobuf.GeneratedCodeInfo.Annotation.source_file\");\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(24)) goto parse_begin;\n        break;\n      }\n\n      // optional int32 begin = 3;\n      case 3: {\n        if (tag == 24) {\n         parse_begin:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 input, &begin_)));\n          set_has_begin();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(32)) goto parse_end;\n        break;\n      }\n\n      // optional int32 end = 4;\n      case 4: {\n        if (tag == 32) {\n         parse_end:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 input, &end_)));\n          set_has_end();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.GeneratedCodeInfo.Annotation)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.GeneratedCodeInfo.Annotation)\n  return false;\n#undef DO_\n}\n\nvoid GeneratedCodeInfo_Annotation::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.GeneratedCodeInfo.Annotation)\n  // repeated int32 path = 1 [packed = true];\n  if (this->path_size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteTag(1, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);\n    output->WriteVarint32(_path_cached_byte_size_);\n  }\n  for (int i = 0; i < this->path_size(); i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt32NoTag(\n      this->path(i), output);\n  }\n\n  // optional string source_file = 2;\n  if (has_source_file()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->source_file().data(), this->source_file().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.GeneratedCodeInfo.Annotation.source_file\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      2, this->source_file(), output);\n  }\n\n  // optional int32 begin = 3;\n  if (has_begin()) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->begin(), output);\n  }\n\n  // optional int32 end = 4;\n  if (has_end()) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->end(), output);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.GeneratedCodeInfo.Annotation)\n}\n\n::google::protobuf::uint8* GeneratedCodeInfo_Annotation::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.GeneratedCodeInfo.Annotation)\n  // repeated int32 path = 1 [packed = true];\n  if (this->path_size() > 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray(\n      1,\n      ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n      target);\n    target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray(\n      _path_cached_byte_size_, target);\n  }\n  for (int i = 0; i < this->path_size(); i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      WriteInt32NoTagToArray(this->path(i), target);\n  }\n\n  // optional string source_file = 2;\n  if (has_source_file()) {\n    ::google::protobuf::internal::WireFormat::VerifyUTF8StringNamedField(\n      this->source_file().data(), this->source_file().length(),\n      ::google::protobuf::internal::WireFormat::SERIALIZE,\n      \"google.protobuf.GeneratedCodeInfo.Annotation.source_file\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        2, this->source_file(), target);\n  }\n\n  // optional int32 begin = 3;\n  if (has_begin()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->begin(), target);\n  }\n\n  // optional int32 end = 4;\n  if (has_end()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(4, this->end(), target);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.GeneratedCodeInfo.Annotation)\n  return target;\n}\n\nint GeneratedCodeInfo_Annotation::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.GeneratedCodeInfo.Annotation)\n  int total_size = 0;\n\n  if (_has_bits_[1 / 32] & 14u) {\n    // optional string source_file = 2;\n    if (has_source_file()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->source_file());\n    }\n\n    // optional int32 begin = 3;\n    if (has_begin()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::Int32Size(\n          this->begin());\n    }\n\n    // optional int32 end = 4;\n    if (has_end()) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::Int32Size(\n          this->end());\n    }\n\n  }\n  // repeated int32 path = 1 [packed = true];\n  {\n    int data_size = 0;\n    for (int i = 0; i < this->path_size(); i++) {\n      data_size += ::google::protobuf::internal::WireFormatLite::\n        Int32Size(this->path(i));\n    }\n    if (data_size > 0) {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::Int32Size(data_size);\n    }\n    GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n    _path_cached_byte_size_ = data_size;\n    GOOGLE_SAFE_CONCURRENT_WRITES_END();\n    total_size += data_size;\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid GeneratedCodeInfo_Annotation::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.GeneratedCodeInfo.Annotation)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const GeneratedCodeInfo_Annotation* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const GeneratedCodeInfo_Annotation>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.GeneratedCodeInfo.Annotation)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.GeneratedCodeInfo.Annotation)\n    MergeFrom(*source);\n  }\n}\n\nvoid GeneratedCodeInfo_Annotation::MergeFrom(const GeneratedCodeInfo_Annotation& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo.Annotation)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  path_.MergeFrom(from.path_);\n  if (from._has_bits_[1 / 32] & (0xffu << (1 % 32))) {\n    if (from.has_source_file()) {\n      set_has_source_file();\n      source_file_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.source_file_);\n    }\n    if (from.has_begin()) {\n      set_begin(from.begin());\n    }\n    if (from.has_end()) {\n      set_end(from.end());\n    }\n  }\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid GeneratedCodeInfo_Annotation::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.GeneratedCodeInfo.Annotation)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid GeneratedCodeInfo_Annotation::CopyFrom(const GeneratedCodeInfo_Annotation& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.GeneratedCodeInfo.Annotation)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool GeneratedCodeInfo_Annotation::IsInitialized() const {\n\n  return true;\n}\n\nvoid GeneratedCodeInfo_Annotation::Swap(GeneratedCodeInfo_Annotation* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid GeneratedCodeInfo_Annotation::InternalSwap(GeneratedCodeInfo_Annotation* other) {\n  path_.UnsafeArenaSwap(&other->path_);\n  source_file_.Swap(&other->source_file_);\n  std::swap(begin_, other->begin_);\n  std::swap(end_, other->end_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata GeneratedCodeInfo_Annotation::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = GeneratedCodeInfo_Annotation_descriptor_;\n  metadata.reflection = GeneratedCodeInfo_Annotation_reflection_;\n  return metadata;\n}\n\n\n// -------------------------------------------------------------------\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int GeneratedCodeInfo::kAnnotationFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nGeneratedCodeInfo::GeneratedCodeInfo()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.GeneratedCodeInfo)\n}\n\nvoid GeneratedCodeInfo::InitAsDefaultInstance() {\n}\n\nGeneratedCodeInfo::GeneratedCodeInfo(const GeneratedCodeInfo& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.GeneratedCodeInfo)\n}\n\nvoid GeneratedCodeInfo::SharedCtor() {\n  _cached_size_ = 0;\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n}\n\nGeneratedCodeInfo::~GeneratedCodeInfo() {\n  // @@protoc_insertion_point(destructor:google.protobuf.GeneratedCodeInfo)\n  SharedDtor();\n}\n\nvoid GeneratedCodeInfo::SharedDtor() {\n  if (this != default_instance_) {\n  }\n}\n\nvoid GeneratedCodeInfo::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* GeneratedCodeInfo::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return GeneratedCodeInfo_descriptor_;\n}\n\nconst GeneratedCodeInfo& GeneratedCodeInfo::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  return *default_instance_;\n}\n\nGeneratedCodeInfo* GeneratedCodeInfo::default_instance_ = NULL;\n\nGeneratedCodeInfo* GeneratedCodeInfo::New(::google::protobuf::Arena* arena) const {\n  GeneratedCodeInfo* n = new GeneratedCodeInfo;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid GeneratedCodeInfo::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.GeneratedCodeInfo)\n  annotation_.Clear();\n  ::memset(_has_bits_, 0, sizeof(_has_bits_));\n  if (_internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->Clear();\n  }\n}\n\nbool GeneratedCodeInfo::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.GeneratedCodeInfo)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_annotation:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_annotation()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(10)) goto parse_loop_annotation;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormat::SkipField(\n              input, tag, mutable_unknown_fields()));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.GeneratedCodeInfo)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.GeneratedCodeInfo)\n  return false;\n#undef DO_\n}\n\nvoid GeneratedCodeInfo::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.GeneratedCodeInfo)\n  // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;\n  for (unsigned int i = 0, n = this->annotation_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      1, this->annotation(i), output);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n        unknown_fields(), output);\n  }\n  // @@protoc_insertion_point(serialize_end:google.protobuf.GeneratedCodeInfo)\n}\n\n::google::protobuf::uint8* GeneratedCodeInfo::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.GeneratedCodeInfo)\n  // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;\n  for (unsigned int i = 0, n = this->annotation_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        1, this->annotation(i), false, target);\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(\n        unknown_fields(), target);\n  }\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.GeneratedCodeInfo)\n  return target;\n}\n\nint GeneratedCodeInfo::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.GeneratedCodeInfo)\n  int total_size = 0;\n\n  // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;\n  total_size += 1 * this->annotation_size();\n  for (int i = 0; i < this->annotation_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->annotation(i));\n  }\n\n  if (_internal_metadata_.have_unknown_fields()) {\n    total_size +=\n      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(\n        unknown_fields());\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid GeneratedCodeInfo::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.GeneratedCodeInfo)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const GeneratedCodeInfo* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const GeneratedCodeInfo>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.GeneratedCodeInfo)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.GeneratedCodeInfo)\n    MergeFrom(*source);\n  }\n}\n\nvoid GeneratedCodeInfo::MergeFrom(const GeneratedCodeInfo& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.GeneratedCodeInfo)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  annotation_.MergeFrom(from.annotation_);\n  if (from._internal_metadata_.have_unknown_fields()) {\n    mutable_unknown_fields()->MergeFrom(from.unknown_fields());\n  }\n}\n\nvoid GeneratedCodeInfo::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.GeneratedCodeInfo)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid GeneratedCodeInfo::CopyFrom(const GeneratedCodeInfo& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.GeneratedCodeInfo)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool GeneratedCodeInfo::IsInitialized() const {\n\n  return true;\n}\n\nvoid GeneratedCodeInfo::Swap(GeneratedCodeInfo* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid GeneratedCodeInfo::InternalSwap(GeneratedCodeInfo* other) {\n  annotation_.UnsafeArenaSwap(&other->annotation_);\n  std::swap(_has_bits_[0], other->_has_bits_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata GeneratedCodeInfo::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = GeneratedCodeInfo_descriptor_;\n  metadata.reflection = GeneratedCodeInfo_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// GeneratedCodeInfo_Annotation\n\n// repeated int32 path = 1 [packed = true];\nint GeneratedCodeInfo_Annotation::path_size() const {\n  return path_.size();\n}\nvoid GeneratedCodeInfo_Annotation::clear_path() {\n  path_.Clear();\n}\n ::google::protobuf::int32 GeneratedCodeInfo_Annotation::path(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.path)\n  return path_.Get(index);\n}\n void GeneratedCodeInfo_Annotation::set_path(int index, ::google::protobuf::int32 value) {\n  path_.Set(index, value);\n  // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.path)\n}\n void GeneratedCodeInfo_Annotation::add_path(::google::protobuf::int32 value) {\n  path_.Add(value);\n  // @@protoc_insertion_point(field_add:google.protobuf.GeneratedCodeInfo.Annotation.path)\n}\n const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&\nGeneratedCodeInfo_Annotation::path() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.GeneratedCodeInfo.Annotation.path)\n  return path_;\n}\n ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*\nGeneratedCodeInfo_Annotation::mutable_path() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.GeneratedCodeInfo.Annotation.path)\n  return &path_;\n}\n\n// optional string source_file = 2;\nbool GeneratedCodeInfo_Annotation::has_source_file() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\nvoid GeneratedCodeInfo_Annotation::set_has_source_file() {\n  _has_bits_[0] |= 0x00000002u;\n}\nvoid GeneratedCodeInfo_Annotation::clear_has_source_file() {\n  _has_bits_[0] &= ~0x00000002u;\n}\nvoid GeneratedCodeInfo_Annotation::clear_source_file() {\n  source_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_source_file();\n}\n const ::std::string& GeneratedCodeInfo_Annotation::source_file() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.source_file)\n  return source_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void GeneratedCodeInfo_Annotation::set_source_file(const ::std::string& value) {\n  set_has_source_file();\n  source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.source_file)\n}\n void GeneratedCodeInfo_Annotation::set_source_file(const char* value) {\n  set_has_source_file();\n  source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.GeneratedCodeInfo.Annotation.source_file)\n}\n void GeneratedCodeInfo_Annotation::set_source_file(const char* value, size_t size) {\n  set_has_source_file();\n  source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.GeneratedCodeInfo.Annotation.source_file)\n}\n ::std::string* GeneratedCodeInfo_Annotation::mutable_source_file() {\n  set_has_source_file();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.GeneratedCodeInfo.Annotation.source_file)\n  return source_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* GeneratedCodeInfo_Annotation::release_source_file() {\n  // @@protoc_insertion_point(field_release:google.protobuf.GeneratedCodeInfo.Annotation.source_file)\n  clear_has_source_file();\n  return source_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void GeneratedCodeInfo_Annotation::set_allocated_source_file(::std::string* source_file) {\n  if (source_file != NULL) {\n    set_has_source_file();\n  } else {\n    clear_has_source_file();\n  }\n  source_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source_file);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.GeneratedCodeInfo.Annotation.source_file)\n}\n\n// optional int32 begin = 3;\nbool GeneratedCodeInfo_Annotation::has_begin() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\nvoid GeneratedCodeInfo_Annotation::set_has_begin() {\n  _has_bits_[0] |= 0x00000004u;\n}\nvoid GeneratedCodeInfo_Annotation::clear_has_begin() {\n  _has_bits_[0] &= ~0x00000004u;\n}\nvoid GeneratedCodeInfo_Annotation::clear_begin() {\n  begin_ = 0;\n  clear_has_begin();\n}\n ::google::protobuf::int32 GeneratedCodeInfo_Annotation::begin() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.begin)\n  return begin_;\n}\n void GeneratedCodeInfo_Annotation::set_begin(::google::protobuf::int32 value) {\n  set_has_begin();\n  begin_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.begin)\n}\n\n// optional int32 end = 4;\nbool GeneratedCodeInfo_Annotation::has_end() const {\n  return (_has_bits_[0] & 0x00000008u) != 0;\n}\nvoid GeneratedCodeInfo_Annotation::set_has_end() {\n  _has_bits_[0] |= 0x00000008u;\n}\nvoid GeneratedCodeInfo_Annotation::clear_has_end() {\n  _has_bits_[0] &= ~0x00000008u;\n}\nvoid GeneratedCodeInfo_Annotation::clear_end() {\n  end_ = 0;\n  clear_has_end();\n}\n ::google::protobuf::int32 GeneratedCodeInfo_Annotation::end() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.end)\n  return end_;\n}\n void GeneratedCodeInfo_Annotation::set_end(::google::protobuf::int32 value) {\n  set_has_end();\n  end_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.end)\n}\n\n// -------------------------------------------------------------------\n\n// GeneratedCodeInfo\n\n// repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;\nint GeneratedCodeInfo::annotation_size() const {\n  return annotation_.size();\n}\nvoid GeneratedCodeInfo::clear_annotation() {\n  annotation_.Clear();\n}\nconst ::google::protobuf::GeneratedCodeInfo_Annotation& GeneratedCodeInfo::annotation(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.annotation)\n  return annotation_.Get(index);\n}\n::google::protobuf::GeneratedCodeInfo_Annotation* GeneratedCodeInfo::mutable_annotation(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.GeneratedCodeInfo.annotation)\n  return annotation_.Mutable(index);\n}\n::google::protobuf::GeneratedCodeInfo_Annotation* GeneratedCodeInfo::add_annotation() {\n  // @@protoc_insertion_point(field_add:google.protobuf.GeneratedCodeInfo.annotation)\n  return annotation_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation >*\nGeneratedCodeInfo::mutable_annotation() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.GeneratedCodeInfo.annotation)\n  return &annotation_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation >&\nGeneratedCodeInfo::annotation() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.GeneratedCodeInfo.annotation)\n  return annotation_;\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace protobuf\n}  // namespace google\n\n// @@protoc_insertion_point(global_scope)\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/descriptor.pb.h",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/descriptor.proto\n\n#ifndef PROTOBUF_google_2fprotobuf_2fdescriptor_2eproto__INCLUDED\n#define PROTOBUF_google_2fprotobuf_2fdescriptor_2eproto__INCLUDED\n\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n\n#if GOOGLE_PROTOBUF_VERSION < 3000000\n#error This file was generated by a newer version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please update\n#error your headers.\n#endif\n#if 3000000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION\n#error This file was generated by an older version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please\n#error regenerate this file with a newer version of protoc.\n#endif\n\n#include <google/protobuf/arena.h>\n#include <google/protobuf/arenastring.h>\n#include <google/protobuf/generated_message_util.h>\n#include <google/protobuf/metadata.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/extension_set.h>\n#include <google/protobuf/generated_enum_reflection.h>\n#include <google/protobuf/unknown_field_set.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\n\n// Internal implementation detail -- do not call these.\nvoid LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\nvoid protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\nvoid protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\nclass DescriptorProto;\nclass DescriptorProto_ExtensionRange;\nclass DescriptorProto_ReservedRange;\nclass EnumDescriptorProto;\nclass EnumOptions;\nclass EnumValueDescriptorProto;\nclass EnumValueOptions;\nclass FieldDescriptorProto;\nclass FieldOptions;\nclass FileDescriptorProto;\nclass FileDescriptorSet;\nclass FileOptions;\nclass GeneratedCodeInfo;\nclass GeneratedCodeInfo_Annotation;\nclass MessageOptions;\nclass MethodDescriptorProto;\nclass MethodOptions;\nclass OneofDescriptorProto;\nclass OneofOptions;\nclass ServiceDescriptorProto;\nclass ServiceOptions;\nclass SourceCodeInfo;\nclass SourceCodeInfo_Location;\nclass UninterpretedOption;\nclass UninterpretedOption_NamePart;\n\nenum FieldDescriptorProto_Type {\n  FieldDescriptorProto_Type_TYPE_DOUBLE = 1,\n  FieldDescriptorProto_Type_TYPE_FLOAT = 2,\n  FieldDescriptorProto_Type_TYPE_INT64 = 3,\n  FieldDescriptorProto_Type_TYPE_UINT64 = 4,\n  FieldDescriptorProto_Type_TYPE_INT32 = 5,\n  FieldDescriptorProto_Type_TYPE_FIXED64 = 6,\n  FieldDescriptorProto_Type_TYPE_FIXED32 = 7,\n  FieldDescriptorProto_Type_TYPE_BOOL = 8,\n  FieldDescriptorProto_Type_TYPE_STRING = 9,\n  FieldDescriptorProto_Type_TYPE_GROUP = 10,\n  FieldDescriptorProto_Type_TYPE_MESSAGE = 11,\n  FieldDescriptorProto_Type_TYPE_BYTES = 12,\n  FieldDescriptorProto_Type_TYPE_UINT32 = 13,\n  FieldDescriptorProto_Type_TYPE_ENUM = 14,\n  FieldDescriptorProto_Type_TYPE_SFIXED32 = 15,\n  FieldDescriptorProto_Type_TYPE_SFIXED64 = 16,\n  FieldDescriptorProto_Type_TYPE_SINT32 = 17,\n  FieldDescriptorProto_Type_TYPE_SINT64 = 18\n};\nLIBPROTOBUF_EXPORT bool FieldDescriptorProto_Type_IsValid(int value);\nconst FieldDescriptorProto_Type FieldDescriptorProto_Type_Type_MIN = FieldDescriptorProto_Type_TYPE_DOUBLE;\nconst FieldDescriptorProto_Type FieldDescriptorProto_Type_Type_MAX = FieldDescriptorProto_Type_TYPE_SINT64;\nconst int FieldDescriptorProto_Type_Type_ARRAYSIZE = FieldDescriptorProto_Type_Type_MAX + 1;\n\nLIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Type_descriptor();\ninline const ::std::string& FieldDescriptorProto_Type_Name(FieldDescriptorProto_Type value) {\n  return ::google::protobuf::internal::NameOfEnum(\n    FieldDescriptorProto_Type_descriptor(), value);\n}\ninline bool FieldDescriptorProto_Type_Parse(\n    const ::std::string& name, FieldDescriptorProto_Type* value) {\n  return ::google::protobuf::internal::ParseNamedEnum<FieldDescriptorProto_Type>(\n    FieldDescriptorProto_Type_descriptor(), name, value);\n}\nenum FieldDescriptorProto_Label {\n  FieldDescriptorProto_Label_LABEL_OPTIONAL = 1,\n  FieldDescriptorProto_Label_LABEL_REQUIRED = 2,\n  FieldDescriptorProto_Label_LABEL_REPEATED = 3\n};\nLIBPROTOBUF_EXPORT bool FieldDescriptorProto_Label_IsValid(int value);\nconst FieldDescriptorProto_Label FieldDescriptorProto_Label_Label_MIN = FieldDescriptorProto_Label_LABEL_OPTIONAL;\nconst FieldDescriptorProto_Label FieldDescriptorProto_Label_Label_MAX = FieldDescriptorProto_Label_LABEL_REPEATED;\nconst int FieldDescriptorProto_Label_Label_ARRAYSIZE = FieldDescriptorProto_Label_Label_MAX + 1;\n\nLIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* FieldDescriptorProto_Label_descriptor();\ninline const ::std::string& FieldDescriptorProto_Label_Name(FieldDescriptorProto_Label value) {\n  return ::google::protobuf::internal::NameOfEnum(\n    FieldDescriptorProto_Label_descriptor(), value);\n}\ninline bool FieldDescriptorProto_Label_Parse(\n    const ::std::string& name, FieldDescriptorProto_Label* value) {\n  return ::google::protobuf::internal::ParseNamedEnum<FieldDescriptorProto_Label>(\n    FieldDescriptorProto_Label_descriptor(), name, value);\n}\nenum FileOptions_OptimizeMode {\n  FileOptions_OptimizeMode_SPEED = 1,\n  FileOptions_OptimizeMode_CODE_SIZE = 2,\n  FileOptions_OptimizeMode_LITE_RUNTIME = 3\n};\nLIBPROTOBUF_EXPORT bool FileOptions_OptimizeMode_IsValid(int value);\nconst FileOptions_OptimizeMode FileOptions_OptimizeMode_OptimizeMode_MIN = FileOptions_OptimizeMode_SPEED;\nconst FileOptions_OptimizeMode FileOptions_OptimizeMode_OptimizeMode_MAX = FileOptions_OptimizeMode_LITE_RUNTIME;\nconst int FileOptions_OptimizeMode_OptimizeMode_ARRAYSIZE = FileOptions_OptimizeMode_OptimizeMode_MAX + 1;\n\nLIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* FileOptions_OptimizeMode_descriptor();\ninline const ::std::string& FileOptions_OptimizeMode_Name(FileOptions_OptimizeMode value) {\n  return ::google::protobuf::internal::NameOfEnum(\n    FileOptions_OptimizeMode_descriptor(), value);\n}\ninline bool FileOptions_OptimizeMode_Parse(\n    const ::std::string& name, FileOptions_OptimizeMode* value) {\n  return ::google::protobuf::internal::ParseNamedEnum<FileOptions_OptimizeMode>(\n    FileOptions_OptimizeMode_descriptor(), name, value);\n}\nenum FieldOptions_CType {\n  FieldOptions_CType_STRING = 0,\n  FieldOptions_CType_CORD = 1,\n  FieldOptions_CType_STRING_PIECE = 2\n};\nLIBPROTOBUF_EXPORT bool FieldOptions_CType_IsValid(int value);\nconst FieldOptions_CType FieldOptions_CType_CType_MIN = FieldOptions_CType_STRING;\nconst FieldOptions_CType FieldOptions_CType_CType_MAX = FieldOptions_CType_STRING_PIECE;\nconst int FieldOptions_CType_CType_ARRAYSIZE = FieldOptions_CType_CType_MAX + 1;\n\nLIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* FieldOptions_CType_descriptor();\ninline const ::std::string& FieldOptions_CType_Name(FieldOptions_CType value) {\n  return ::google::protobuf::internal::NameOfEnum(\n    FieldOptions_CType_descriptor(), value);\n}\ninline bool FieldOptions_CType_Parse(\n    const ::std::string& name, FieldOptions_CType* value) {\n  return ::google::protobuf::internal::ParseNamedEnum<FieldOptions_CType>(\n    FieldOptions_CType_descriptor(), name, value);\n}\nenum FieldOptions_JSType {\n  FieldOptions_JSType_JS_NORMAL = 0,\n  FieldOptions_JSType_JS_STRING = 1,\n  FieldOptions_JSType_JS_NUMBER = 2\n};\nLIBPROTOBUF_EXPORT bool FieldOptions_JSType_IsValid(int value);\nconst FieldOptions_JSType FieldOptions_JSType_JSType_MIN = FieldOptions_JSType_JS_NORMAL;\nconst FieldOptions_JSType FieldOptions_JSType_JSType_MAX = FieldOptions_JSType_JS_NUMBER;\nconst int FieldOptions_JSType_JSType_ARRAYSIZE = FieldOptions_JSType_JSType_MAX + 1;\n\nLIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* FieldOptions_JSType_descriptor();\ninline const ::std::string& FieldOptions_JSType_Name(FieldOptions_JSType value) {\n  return ::google::protobuf::internal::NameOfEnum(\n    FieldOptions_JSType_descriptor(), value);\n}\ninline bool FieldOptions_JSType_Parse(\n    const ::std::string& name, FieldOptions_JSType* value) {\n  return ::google::protobuf::internal::ParseNamedEnum<FieldOptions_JSType>(\n    FieldOptions_JSType_descriptor(), name, value);\n}\n// ===================================================================\n\nclass LIBPROTOBUF_EXPORT FileDescriptorSet : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorSet) */ {\n public:\n  FileDescriptorSet();\n  virtual ~FileDescriptorSet();\n\n  FileDescriptorSet(const FileDescriptorSet& from);\n\n  inline FileDescriptorSet& operator=(const FileDescriptorSet& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const FileDescriptorSet& default_instance();\n\n  void Swap(FileDescriptorSet* other);\n\n  // implements Message ----------------------------------------------\n\n  inline FileDescriptorSet* New() const { return New(NULL); }\n\n  FileDescriptorSet* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const FileDescriptorSet& from);\n  void MergeFrom(const FileDescriptorSet& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(FileDescriptorSet* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // repeated .google.protobuf.FileDescriptorProto file = 1;\n  int file_size() const;\n  void clear_file();\n  static const int kFileFieldNumber = 1;\n  const ::google::protobuf::FileDescriptorProto& file(int index) const;\n  ::google::protobuf::FileDescriptorProto* mutable_file(int index);\n  ::google::protobuf::FileDescriptorProto* add_file();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >*\n      mutable_file();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >&\n      file() const;\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.FileDescriptorSet)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto > file_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static FileDescriptorSet* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT FileDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileDescriptorProto) */ {\n public:\n  FileDescriptorProto();\n  virtual ~FileDescriptorProto();\n\n  FileDescriptorProto(const FileDescriptorProto& from);\n\n  inline FileDescriptorProto& operator=(const FileDescriptorProto& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const FileDescriptorProto& default_instance();\n\n  void Swap(FileDescriptorProto* other);\n\n  // implements Message ----------------------------------------------\n\n  inline FileDescriptorProto* New() const { return New(NULL); }\n\n  FileDescriptorProto* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const FileDescriptorProto& from);\n  void MergeFrom(const FileDescriptorProto& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(FileDescriptorProto* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional string name = 1;\n  bool has_name() const;\n  void clear_name();\n  static const int kNameFieldNumber = 1;\n  const ::std::string& name() const;\n  void set_name(const ::std::string& value);\n  void set_name(const char* value);\n  void set_name(const char* value, size_t size);\n  ::std::string* mutable_name();\n  ::std::string* release_name();\n  void set_allocated_name(::std::string* name);\n\n  // optional string package = 2;\n  bool has_package() const;\n  void clear_package();\n  static const int kPackageFieldNumber = 2;\n  const ::std::string& package() const;\n  void set_package(const ::std::string& value);\n  void set_package(const char* value);\n  void set_package(const char* value, size_t size);\n  ::std::string* mutable_package();\n  ::std::string* release_package();\n  void set_allocated_package(::std::string* package);\n\n  // repeated string dependency = 3;\n  int dependency_size() const;\n  void clear_dependency();\n  static const int kDependencyFieldNumber = 3;\n  const ::std::string& dependency(int index) const;\n  ::std::string* mutable_dependency(int index);\n  void set_dependency(int index, const ::std::string& value);\n  void set_dependency(int index, const char* value);\n  void set_dependency(int index, const char* value, size_t size);\n  ::std::string* add_dependency();\n  void add_dependency(const ::std::string& value);\n  void add_dependency(const char* value);\n  void add_dependency(const char* value, size_t size);\n  const ::google::protobuf::RepeatedPtrField< ::std::string>& dependency() const;\n  ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_dependency();\n\n  // repeated int32 public_dependency = 10;\n  int public_dependency_size() const;\n  void clear_public_dependency();\n  static const int kPublicDependencyFieldNumber = 10;\n  ::google::protobuf::int32 public_dependency(int index) const;\n  void set_public_dependency(int index, ::google::protobuf::int32 value);\n  void add_public_dependency(::google::protobuf::int32 value);\n  const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&\n      public_dependency() const;\n  ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*\n      mutable_public_dependency();\n\n  // repeated int32 weak_dependency = 11;\n  int weak_dependency_size() const;\n  void clear_weak_dependency();\n  static const int kWeakDependencyFieldNumber = 11;\n  ::google::protobuf::int32 weak_dependency(int index) const;\n  void set_weak_dependency(int index, ::google::protobuf::int32 value);\n  void add_weak_dependency(::google::protobuf::int32 value);\n  const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&\n      weak_dependency() const;\n  ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*\n      mutable_weak_dependency();\n\n  // repeated .google.protobuf.DescriptorProto message_type = 4;\n  int message_type_size() const;\n  void clear_message_type();\n  static const int kMessageTypeFieldNumber = 4;\n  const ::google::protobuf::DescriptorProto& message_type(int index) const;\n  ::google::protobuf::DescriptorProto* mutable_message_type(int index);\n  ::google::protobuf::DescriptorProto* add_message_type();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >*\n      mutable_message_type();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >&\n      message_type() const;\n\n  // repeated .google.protobuf.EnumDescriptorProto enum_type = 5;\n  int enum_type_size() const;\n  void clear_enum_type();\n  static const int kEnumTypeFieldNumber = 5;\n  const ::google::protobuf::EnumDescriptorProto& enum_type(int index) const;\n  ::google::protobuf::EnumDescriptorProto* mutable_enum_type(int index);\n  ::google::protobuf::EnumDescriptorProto* add_enum_type();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >*\n      mutable_enum_type();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >&\n      enum_type() const;\n\n  // repeated .google.protobuf.ServiceDescriptorProto service = 6;\n  int service_size() const;\n  void clear_service();\n  static const int kServiceFieldNumber = 6;\n  const ::google::protobuf::ServiceDescriptorProto& service(int index) const;\n  ::google::protobuf::ServiceDescriptorProto* mutable_service(int index);\n  ::google::protobuf::ServiceDescriptorProto* add_service();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto >*\n      mutable_service();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto >&\n      service() const;\n\n  // repeated .google.protobuf.FieldDescriptorProto extension = 7;\n  int extension_size() const;\n  void clear_extension();\n  static const int kExtensionFieldNumber = 7;\n  const ::google::protobuf::FieldDescriptorProto& extension(int index) const;\n  ::google::protobuf::FieldDescriptorProto* mutable_extension(int index);\n  ::google::protobuf::FieldDescriptorProto* add_extension();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >*\n      mutable_extension();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >&\n      extension() const;\n\n  // optional .google.protobuf.FileOptions options = 8;\n  bool has_options() const;\n  void clear_options();\n  static const int kOptionsFieldNumber = 8;\n  const ::google::protobuf::FileOptions& options() const;\n  ::google::protobuf::FileOptions* mutable_options();\n  ::google::protobuf::FileOptions* release_options();\n  void set_allocated_options(::google::protobuf::FileOptions* options);\n\n  // optional .google.protobuf.SourceCodeInfo source_code_info = 9;\n  bool has_source_code_info() const;\n  void clear_source_code_info();\n  static const int kSourceCodeInfoFieldNumber = 9;\n  const ::google::protobuf::SourceCodeInfo& source_code_info() const;\n  ::google::protobuf::SourceCodeInfo* mutable_source_code_info();\n  ::google::protobuf::SourceCodeInfo* release_source_code_info();\n  void set_allocated_source_code_info(::google::protobuf::SourceCodeInfo* source_code_info);\n\n  // optional string syntax = 12;\n  bool has_syntax() const;\n  void clear_syntax();\n  static const int kSyntaxFieldNumber = 12;\n  const ::std::string& syntax() const;\n  void set_syntax(const ::std::string& value);\n  void set_syntax(const char* value);\n  void set_syntax(const char* value, size_t size);\n  ::std::string* mutable_syntax();\n  ::std::string* release_syntax();\n  void set_allocated_syntax(::std::string* syntax);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.FileDescriptorProto)\n private:\n  inline void set_has_name();\n  inline void clear_has_name();\n  inline void set_has_package();\n  inline void clear_has_package();\n  inline void set_has_options();\n  inline void clear_has_options();\n  inline void set_has_source_code_info();\n  inline void clear_has_source_code_info();\n  inline void set_has_syntax();\n  inline void clear_has_syntax();\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::internal::ArenaStringPtr name_;\n  ::google::protobuf::internal::ArenaStringPtr package_;\n  ::google::protobuf::RepeatedPtrField< ::std::string> dependency_;\n  ::google::protobuf::RepeatedField< ::google::protobuf::int32 > public_dependency_;\n  ::google::protobuf::RepeatedField< ::google::protobuf::int32 > weak_dependency_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto > message_type_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto > enum_type_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto > service_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto > extension_;\n  ::google::protobuf::FileOptions* options_;\n  ::google::protobuf::SourceCodeInfo* source_code_info_;\n  ::google::protobuf::internal::ArenaStringPtr syntax_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static FileDescriptorProto* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT DescriptorProto_ExtensionRange : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ExtensionRange) */ {\n public:\n  DescriptorProto_ExtensionRange();\n  virtual ~DescriptorProto_ExtensionRange();\n\n  DescriptorProto_ExtensionRange(const DescriptorProto_ExtensionRange& from);\n\n  inline DescriptorProto_ExtensionRange& operator=(const DescriptorProto_ExtensionRange& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const DescriptorProto_ExtensionRange& default_instance();\n\n  void Swap(DescriptorProto_ExtensionRange* other);\n\n  // implements Message ----------------------------------------------\n\n  inline DescriptorProto_ExtensionRange* New() const { return New(NULL); }\n\n  DescriptorProto_ExtensionRange* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const DescriptorProto_ExtensionRange& from);\n  void MergeFrom(const DescriptorProto_ExtensionRange& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(DescriptorProto_ExtensionRange* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional int32 start = 1;\n  bool has_start() const;\n  void clear_start();\n  static const int kStartFieldNumber = 1;\n  ::google::protobuf::int32 start() const;\n  void set_start(::google::protobuf::int32 value);\n\n  // optional int32 end = 2;\n  bool has_end() const;\n  void clear_end();\n  static const int kEndFieldNumber = 2;\n  ::google::protobuf::int32 end() const;\n  void set_end(::google::protobuf::int32 value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto.ExtensionRange)\n private:\n  inline void set_has_start();\n  inline void clear_has_start();\n  inline void set_has_end();\n  inline void clear_has_end();\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::int32 start_;\n  ::google::protobuf::int32 end_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static DescriptorProto_ExtensionRange* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT DescriptorProto_ReservedRange : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto.ReservedRange) */ {\n public:\n  DescriptorProto_ReservedRange();\n  virtual ~DescriptorProto_ReservedRange();\n\n  DescriptorProto_ReservedRange(const DescriptorProto_ReservedRange& from);\n\n  inline DescriptorProto_ReservedRange& operator=(const DescriptorProto_ReservedRange& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const DescriptorProto_ReservedRange& default_instance();\n\n  void Swap(DescriptorProto_ReservedRange* other);\n\n  // implements Message ----------------------------------------------\n\n  inline DescriptorProto_ReservedRange* New() const { return New(NULL); }\n\n  DescriptorProto_ReservedRange* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const DescriptorProto_ReservedRange& from);\n  void MergeFrom(const DescriptorProto_ReservedRange& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(DescriptorProto_ReservedRange* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional int32 start = 1;\n  bool has_start() const;\n  void clear_start();\n  static const int kStartFieldNumber = 1;\n  ::google::protobuf::int32 start() const;\n  void set_start(::google::protobuf::int32 value);\n\n  // optional int32 end = 2;\n  bool has_end() const;\n  void clear_end();\n  static const int kEndFieldNumber = 2;\n  ::google::protobuf::int32 end() const;\n  void set_end(::google::protobuf::int32 value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto.ReservedRange)\n private:\n  inline void set_has_start();\n  inline void clear_has_start();\n  inline void set_has_end();\n  inline void clear_has_end();\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::int32 start_;\n  ::google::protobuf::int32 end_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static DescriptorProto_ReservedRange* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT DescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DescriptorProto) */ {\n public:\n  DescriptorProto();\n  virtual ~DescriptorProto();\n\n  DescriptorProto(const DescriptorProto& from);\n\n  inline DescriptorProto& operator=(const DescriptorProto& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const DescriptorProto& default_instance();\n\n  void Swap(DescriptorProto* other);\n\n  // implements Message ----------------------------------------------\n\n  inline DescriptorProto* New() const { return New(NULL); }\n\n  DescriptorProto* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const DescriptorProto& from);\n  void MergeFrom(const DescriptorProto& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(DescriptorProto* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  typedef DescriptorProto_ExtensionRange ExtensionRange;\n  typedef DescriptorProto_ReservedRange ReservedRange;\n\n  // accessors -------------------------------------------------------\n\n  // optional string name = 1;\n  bool has_name() const;\n  void clear_name();\n  static const int kNameFieldNumber = 1;\n  const ::std::string& name() const;\n  void set_name(const ::std::string& value);\n  void set_name(const char* value);\n  void set_name(const char* value, size_t size);\n  ::std::string* mutable_name();\n  ::std::string* release_name();\n  void set_allocated_name(::std::string* name);\n\n  // repeated .google.protobuf.FieldDescriptorProto field = 2;\n  int field_size() const;\n  void clear_field();\n  static const int kFieldFieldNumber = 2;\n  const ::google::protobuf::FieldDescriptorProto& field(int index) const;\n  ::google::protobuf::FieldDescriptorProto* mutable_field(int index);\n  ::google::protobuf::FieldDescriptorProto* add_field();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >*\n      mutable_field();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >&\n      field() const;\n\n  // repeated .google.protobuf.FieldDescriptorProto extension = 6;\n  int extension_size() const;\n  void clear_extension();\n  static const int kExtensionFieldNumber = 6;\n  const ::google::protobuf::FieldDescriptorProto& extension(int index) const;\n  ::google::protobuf::FieldDescriptorProto* mutable_extension(int index);\n  ::google::protobuf::FieldDescriptorProto* add_extension();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >*\n      mutable_extension();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >&\n      extension() const;\n\n  // repeated .google.protobuf.DescriptorProto nested_type = 3;\n  int nested_type_size() const;\n  void clear_nested_type();\n  static const int kNestedTypeFieldNumber = 3;\n  const ::google::protobuf::DescriptorProto& nested_type(int index) const;\n  ::google::protobuf::DescriptorProto* mutable_nested_type(int index);\n  ::google::protobuf::DescriptorProto* add_nested_type();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >*\n      mutable_nested_type();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >&\n      nested_type() const;\n\n  // repeated .google.protobuf.EnumDescriptorProto enum_type = 4;\n  int enum_type_size() const;\n  void clear_enum_type();\n  static const int kEnumTypeFieldNumber = 4;\n  const ::google::protobuf::EnumDescriptorProto& enum_type(int index) const;\n  ::google::protobuf::EnumDescriptorProto* mutable_enum_type(int index);\n  ::google::protobuf::EnumDescriptorProto* add_enum_type();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >*\n      mutable_enum_type();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >&\n      enum_type() const;\n\n  // repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;\n  int extension_range_size() const;\n  void clear_extension_range();\n  static const int kExtensionRangeFieldNumber = 5;\n  const ::google::protobuf::DescriptorProto_ExtensionRange& extension_range(int index) const;\n  ::google::protobuf::DescriptorProto_ExtensionRange* mutable_extension_range(int index);\n  ::google::protobuf::DescriptorProto_ExtensionRange* add_extension_range();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange >*\n      mutable_extension_range();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange >&\n      extension_range() const;\n\n  // repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;\n  int oneof_decl_size() const;\n  void clear_oneof_decl();\n  static const int kOneofDeclFieldNumber = 8;\n  const ::google::protobuf::OneofDescriptorProto& oneof_decl(int index) const;\n  ::google::protobuf::OneofDescriptorProto* mutable_oneof_decl(int index);\n  ::google::protobuf::OneofDescriptorProto* add_oneof_decl();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto >*\n      mutable_oneof_decl();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto >&\n      oneof_decl() const;\n\n  // optional .google.protobuf.MessageOptions options = 7;\n  bool has_options() const;\n  void clear_options();\n  static const int kOptionsFieldNumber = 7;\n  const ::google::protobuf::MessageOptions& options() const;\n  ::google::protobuf::MessageOptions* mutable_options();\n  ::google::protobuf::MessageOptions* release_options();\n  void set_allocated_options(::google::protobuf::MessageOptions* options);\n\n  // repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;\n  int reserved_range_size() const;\n  void clear_reserved_range();\n  static const int kReservedRangeFieldNumber = 9;\n  const ::google::protobuf::DescriptorProto_ReservedRange& reserved_range(int index) const;\n  ::google::protobuf::DescriptorProto_ReservedRange* mutable_reserved_range(int index);\n  ::google::protobuf::DescriptorProto_ReservedRange* add_reserved_range();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ReservedRange >*\n      mutable_reserved_range();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ReservedRange >&\n      reserved_range() const;\n\n  // repeated string reserved_name = 10;\n  int reserved_name_size() const;\n  void clear_reserved_name();\n  static const int kReservedNameFieldNumber = 10;\n  const ::std::string& reserved_name(int index) const;\n  ::std::string* mutable_reserved_name(int index);\n  void set_reserved_name(int index, const ::std::string& value);\n  void set_reserved_name(int index, const char* value);\n  void set_reserved_name(int index, const char* value, size_t size);\n  ::std::string* add_reserved_name();\n  void add_reserved_name(const ::std::string& value);\n  void add_reserved_name(const char* value);\n  void add_reserved_name(const char* value, size_t size);\n  const ::google::protobuf::RepeatedPtrField< ::std::string>& reserved_name() const;\n  ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_reserved_name();\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.DescriptorProto)\n private:\n  inline void set_has_name();\n  inline void clear_has_name();\n  inline void set_has_options();\n  inline void clear_has_options();\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::internal::ArenaStringPtr name_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto > field_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto > extension_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto > nested_type_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto > enum_type_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange > extension_range_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto > oneof_decl_;\n  ::google::protobuf::MessageOptions* options_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ReservedRange > reserved_range_;\n  ::google::protobuf::RepeatedPtrField< ::std::string> reserved_name_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static DescriptorProto* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT FieldDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldDescriptorProto) */ {\n public:\n  FieldDescriptorProto();\n  virtual ~FieldDescriptorProto();\n\n  FieldDescriptorProto(const FieldDescriptorProto& from);\n\n  inline FieldDescriptorProto& operator=(const FieldDescriptorProto& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const FieldDescriptorProto& default_instance();\n\n  void Swap(FieldDescriptorProto* other);\n\n  // implements Message ----------------------------------------------\n\n  inline FieldDescriptorProto* New() const { return New(NULL); }\n\n  FieldDescriptorProto* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const FieldDescriptorProto& from);\n  void MergeFrom(const FieldDescriptorProto& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(FieldDescriptorProto* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  typedef FieldDescriptorProto_Type Type;\n  static const Type TYPE_DOUBLE =\n    FieldDescriptorProto_Type_TYPE_DOUBLE;\n  static const Type TYPE_FLOAT =\n    FieldDescriptorProto_Type_TYPE_FLOAT;\n  static const Type TYPE_INT64 =\n    FieldDescriptorProto_Type_TYPE_INT64;\n  static const Type TYPE_UINT64 =\n    FieldDescriptorProto_Type_TYPE_UINT64;\n  static const Type TYPE_INT32 =\n    FieldDescriptorProto_Type_TYPE_INT32;\n  static const Type TYPE_FIXED64 =\n    FieldDescriptorProto_Type_TYPE_FIXED64;\n  static const Type TYPE_FIXED32 =\n    FieldDescriptorProto_Type_TYPE_FIXED32;\n  static const Type TYPE_BOOL =\n    FieldDescriptorProto_Type_TYPE_BOOL;\n  static const Type TYPE_STRING =\n    FieldDescriptorProto_Type_TYPE_STRING;\n  static const Type TYPE_GROUP =\n    FieldDescriptorProto_Type_TYPE_GROUP;\n  static const Type TYPE_MESSAGE =\n    FieldDescriptorProto_Type_TYPE_MESSAGE;\n  static const Type TYPE_BYTES =\n    FieldDescriptorProto_Type_TYPE_BYTES;\n  static const Type TYPE_UINT32 =\n    FieldDescriptorProto_Type_TYPE_UINT32;\n  static const Type TYPE_ENUM =\n    FieldDescriptorProto_Type_TYPE_ENUM;\n  static const Type TYPE_SFIXED32 =\n    FieldDescriptorProto_Type_TYPE_SFIXED32;\n  static const Type TYPE_SFIXED64 =\n    FieldDescriptorProto_Type_TYPE_SFIXED64;\n  static const Type TYPE_SINT32 =\n    FieldDescriptorProto_Type_TYPE_SINT32;\n  static const Type TYPE_SINT64 =\n    FieldDescriptorProto_Type_TYPE_SINT64;\n  static inline bool Type_IsValid(int value) {\n    return FieldDescriptorProto_Type_IsValid(value);\n  }\n  static const Type Type_MIN =\n    FieldDescriptorProto_Type_Type_MIN;\n  static const Type Type_MAX =\n    FieldDescriptorProto_Type_Type_MAX;\n  static const int Type_ARRAYSIZE =\n    FieldDescriptorProto_Type_Type_ARRAYSIZE;\n  static inline const ::google::protobuf::EnumDescriptor*\n  Type_descriptor() {\n    return FieldDescriptorProto_Type_descriptor();\n  }\n  static inline const ::std::string& Type_Name(Type value) {\n    return FieldDescriptorProto_Type_Name(value);\n  }\n  static inline bool Type_Parse(const ::std::string& name,\n      Type* value) {\n    return FieldDescriptorProto_Type_Parse(name, value);\n  }\n\n  typedef FieldDescriptorProto_Label Label;\n  static const Label LABEL_OPTIONAL =\n    FieldDescriptorProto_Label_LABEL_OPTIONAL;\n  static const Label LABEL_REQUIRED =\n    FieldDescriptorProto_Label_LABEL_REQUIRED;\n  static const Label LABEL_REPEATED =\n    FieldDescriptorProto_Label_LABEL_REPEATED;\n  static inline bool Label_IsValid(int value) {\n    return FieldDescriptorProto_Label_IsValid(value);\n  }\n  static const Label Label_MIN =\n    FieldDescriptorProto_Label_Label_MIN;\n  static const Label Label_MAX =\n    FieldDescriptorProto_Label_Label_MAX;\n  static const int Label_ARRAYSIZE =\n    FieldDescriptorProto_Label_Label_ARRAYSIZE;\n  static inline const ::google::protobuf::EnumDescriptor*\n  Label_descriptor() {\n    return FieldDescriptorProto_Label_descriptor();\n  }\n  static inline const ::std::string& Label_Name(Label value) {\n    return FieldDescriptorProto_Label_Name(value);\n  }\n  static inline bool Label_Parse(const ::std::string& name,\n      Label* value) {\n    return FieldDescriptorProto_Label_Parse(name, value);\n  }\n\n  // accessors -------------------------------------------------------\n\n  // optional string name = 1;\n  bool has_name() const;\n  void clear_name();\n  static const int kNameFieldNumber = 1;\n  const ::std::string& name() const;\n  void set_name(const ::std::string& value);\n  void set_name(const char* value);\n  void set_name(const char* value, size_t size);\n  ::std::string* mutable_name();\n  ::std::string* release_name();\n  void set_allocated_name(::std::string* name);\n\n  // optional int32 number = 3;\n  bool has_number() const;\n  void clear_number();\n  static const int kNumberFieldNumber = 3;\n  ::google::protobuf::int32 number() const;\n  void set_number(::google::protobuf::int32 value);\n\n  // optional .google.protobuf.FieldDescriptorProto.Label label = 4;\n  bool has_label() const;\n  void clear_label();\n  static const int kLabelFieldNumber = 4;\n  ::google::protobuf::FieldDescriptorProto_Label label() const;\n  void set_label(::google::protobuf::FieldDescriptorProto_Label value);\n\n  // optional .google.protobuf.FieldDescriptorProto.Type type = 5;\n  bool has_type() const;\n  void clear_type();\n  static const int kTypeFieldNumber = 5;\n  ::google::protobuf::FieldDescriptorProto_Type type() const;\n  void set_type(::google::protobuf::FieldDescriptorProto_Type value);\n\n  // optional string type_name = 6;\n  bool has_type_name() const;\n  void clear_type_name();\n  static const int kTypeNameFieldNumber = 6;\n  const ::std::string& type_name() const;\n  void set_type_name(const ::std::string& value);\n  void set_type_name(const char* value);\n  void set_type_name(const char* value, size_t size);\n  ::std::string* mutable_type_name();\n  ::std::string* release_type_name();\n  void set_allocated_type_name(::std::string* type_name);\n\n  // optional string extendee = 2;\n  bool has_extendee() const;\n  void clear_extendee();\n  static const int kExtendeeFieldNumber = 2;\n  const ::std::string& extendee() const;\n  void set_extendee(const ::std::string& value);\n  void set_extendee(const char* value);\n  void set_extendee(const char* value, size_t size);\n  ::std::string* mutable_extendee();\n  ::std::string* release_extendee();\n  void set_allocated_extendee(::std::string* extendee);\n\n  // optional string default_value = 7;\n  bool has_default_value() const;\n  void clear_default_value();\n  static const int kDefaultValueFieldNumber = 7;\n  const ::std::string& default_value() const;\n  void set_default_value(const ::std::string& value);\n  void set_default_value(const char* value);\n  void set_default_value(const char* value, size_t size);\n  ::std::string* mutable_default_value();\n  ::std::string* release_default_value();\n  void set_allocated_default_value(::std::string* default_value);\n\n  // optional int32 oneof_index = 9;\n  bool has_oneof_index() const;\n  void clear_oneof_index();\n  static const int kOneofIndexFieldNumber = 9;\n  ::google::protobuf::int32 oneof_index() const;\n  void set_oneof_index(::google::protobuf::int32 value);\n\n  // optional string json_name = 10;\n  bool has_json_name() const;\n  void clear_json_name();\n  static const int kJsonNameFieldNumber = 10;\n  const ::std::string& json_name() const;\n  void set_json_name(const ::std::string& value);\n  void set_json_name(const char* value);\n  void set_json_name(const char* value, size_t size);\n  ::std::string* mutable_json_name();\n  ::std::string* release_json_name();\n  void set_allocated_json_name(::std::string* json_name);\n\n  // optional .google.protobuf.FieldOptions options = 8;\n  bool has_options() const;\n  void clear_options();\n  static const int kOptionsFieldNumber = 8;\n  const ::google::protobuf::FieldOptions& options() const;\n  ::google::protobuf::FieldOptions* mutable_options();\n  ::google::protobuf::FieldOptions* release_options();\n  void set_allocated_options(::google::protobuf::FieldOptions* options);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.FieldDescriptorProto)\n private:\n  inline void set_has_name();\n  inline void clear_has_name();\n  inline void set_has_number();\n  inline void clear_has_number();\n  inline void set_has_label();\n  inline void clear_has_label();\n  inline void set_has_type();\n  inline void clear_has_type();\n  inline void set_has_type_name();\n  inline void clear_has_type_name();\n  inline void set_has_extendee();\n  inline void clear_has_extendee();\n  inline void set_has_default_value();\n  inline void clear_has_default_value();\n  inline void set_has_oneof_index();\n  inline void clear_has_oneof_index();\n  inline void set_has_json_name();\n  inline void clear_has_json_name();\n  inline void set_has_options();\n  inline void clear_has_options();\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::internal::ArenaStringPtr name_;\n  ::google::protobuf::int32 number_;\n  int label_;\n  ::google::protobuf::internal::ArenaStringPtr type_name_;\n  ::google::protobuf::internal::ArenaStringPtr extendee_;\n  int type_;\n  ::google::protobuf::int32 oneof_index_;\n  ::google::protobuf::internal::ArenaStringPtr default_value_;\n  ::google::protobuf::internal::ArenaStringPtr json_name_;\n  ::google::protobuf::FieldOptions* options_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static FieldDescriptorProto* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT OneofDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofDescriptorProto) */ {\n public:\n  OneofDescriptorProto();\n  virtual ~OneofDescriptorProto();\n\n  OneofDescriptorProto(const OneofDescriptorProto& from);\n\n  inline OneofDescriptorProto& operator=(const OneofDescriptorProto& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const OneofDescriptorProto& default_instance();\n\n  void Swap(OneofDescriptorProto* other);\n\n  // implements Message ----------------------------------------------\n\n  inline OneofDescriptorProto* New() const { return New(NULL); }\n\n  OneofDescriptorProto* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const OneofDescriptorProto& from);\n  void MergeFrom(const OneofDescriptorProto& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(OneofDescriptorProto* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional string name = 1;\n  bool has_name() const;\n  void clear_name();\n  static const int kNameFieldNumber = 1;\n  const ::std::string& name() const;\n  void set_name(const ::std::string& value);\n  void set_name(const char* value);\n  void set_name(const char* value, size_t size);\n  ::std::string* mutable_name();\n  ::std::string* release_name();\n  void set_allocated_name(::std::string* name);\n\n  // optional .google.protobuf.OneofOptions options = 2;\n  bool has_options() const;\n  void clear_options();\n  static const int kOptionsFieldNumber = 2;\n  const ::google::protobuf::OneofOptions& options() const;\n  ::google::protobuf::OneofOptions* mutable_options();\n  ::google::protobuf::OneofOptions* release_options();\n  void set_allocated_options(::google::protobuf::OneofOptions* options);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.OneofDescriptorProto)\n private:\n  inline void set_has_name();\n  inline void clear_has_name();\n  inline void set_has_options();\n  inline void clear_has_options();\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::internal::ArenaStringPtr name_;\n  ::google::protobuf::OneofOptions* options_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static OneofDescriptorProto* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT EnumDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumDescriptorProto) */ {\n public:\n  EnumDescriptorProto();\n  virtual ~EnumDescriptorProto();\n\n  EnumDescriptorProto(const EnumDescriptorProto& from);\n\n  inline EnumDescriptorProto& operator=(const EnumDescriptorProto& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const EnumDescriptorProto& default_instance();\n\n  void Swap(EnumDescriptorProto* other);\n\n  // implements Message ----------------------------------------------\n\n  inline EnumDescriptorProto* New() const { return New(NULL); }\n\n  EnumDescriptorProto* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const EnumDescriptorProto& from);\n  void MergeFrom(const EnumDescriptorProto& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(EnumDescriptorProto* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional string name = 1;\n  bool has_name() const;\n  void clear_name();\n  static const int kNameFieldNumber = 1;\n  const ::std::string& name() const;\n  void set_name(const ::std::string& value);\n  void set_name(const char* value);\n  void set_name(const char* value, size_t size);\n  ::std::string* mutable_name();\n  ::std::string* release_name();\n  void set_allocated_name(::std::string* name);\n\n  // repeated .google.protobuf.EnumValueDescriptorProto value = 2;\n  int value_size() const;\n  void clear_value();\n  static const int kValueFieldNumber = 2;\n  const ::google::protobuf::EnumValueDescriptorProto& value(int index) const;\n  ::google::protobuf::EnumValueDescriptorProto* mutable_value(int index);\n  ::google::protobuf::EnumValueDescriptorProto* add_value();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >*\n      mutable_value();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >&\n      value() const;\n\n  // optional .google.protobuf.EnumOptions options = 3;\n  bool has_options() const;\n  void clear_options();\n  static const int kOptionsFieldNumber = 3;\n  const ::google::protobuf::EnumOptions& options() const;\n  ::google::protobuf::EnumOptions* mutable_options();\n  ::google::protobuf::EnumOptions* release_options();\n  void set_allocated_options(::google::protobuf::EnumOptions* options);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.EnumDescriptorProto)\n private:\n  inline void set_has_name();\n  inline void clear_has_name();\n  inline void set_has_options();\n  inline void clear_has_options();\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::internal::ArenaStringPtr name_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto > value_;\n  ::google::protobuf::EnumOptions* options_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static EnumDescriptorProto* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT EnumValueDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueDescriptorProto) */ {\n public:\n  EnumValueDescriptorProto();\n  virtual ~EnumValueDescriptorProto();\n\n  EnumValueDescriptorProto(const EnumValueDescriptorProto& from);\n\n  inline EnumValueDescriptorProto& operator=(const EnumValueDescriptorProto& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const EnumValueDescriptorProto& default_instance();\n\n  void Swap(EnumValueDescriptorProto* other);\n\n  // implements Message ----------------------------------------------\n\n  inline EnumValueDescriptorProto* New() const { return New(NULL); }\n\n  EnumValueDescriptorProto* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const EnumValueDescriptorProto& from);\n  void MergeFrom(const EnumValueDescriptorProto& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(EnumValueDescriptorProto* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional string name = 1;\n  bool has_name() const;\n  void clear_name();\n  static const int kNameFieldNumber = 1;\n  const ::std::string& name() const;\n  void set_name(const ::std::string& value);\n  void set_name(const char* value);\n  void set_name(const char* value, size_t size);\n  ::std::string* mutable_name();\n  ::std::string* release_name();\n  void set_allocated_name(::std::string* name);\n\n  // optional int32 number = 2;\n  bool has_number() const;\n  void clear_number();\n  static const int kNumberFieldNumber = 2;\n  ::google::protobuf::int32 number() const;\n  void set_number(::google::protobuf::int32 value);\n\n  // optional .google.protobuf.EnumValueOptions options = 3;\n  bool has_options() const;\n  void clear_options();\n  static const int kOptionsFieldNumber = 3;\n  const ::google::protobuf::EnumValueOptions& options() const;\n  ::google::protobuf::EnumValueOptions* mutable_options();\n  ::google::protobuf::EnumValueOptions* release_options();\n  void set_allocated_options(::google::protobuf::EnumValueOptions* options);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.EnumValueDescriptorProto)\n private:\n  inline void set_has_name();\n  inline void clear_has_name();\n  inline void set_has_number();\n  inline void clear_has_number();\n  inline void set_has_options();\n  inline void clear_has_options();\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::internal::ArenaStringPtr name_;\n  ::google::protobuf::EnumValueOptions* options_;\n  ::google::protobuf::int32 number_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static EnumValueDescriptorProto* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT ServiceDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceDescriptorProto) */ {\n public:\n  ServiceDescriptorProto();\n  virtual ~ServiceDescriptorProto();\n\n  ServiceDescriptorProto(const ServiceDescriptorProto& from);\n\n  inline ServiceDescriptorProto& operator=(const ServiceDescriptorProto& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const ServiceDescriptorProto& default_instance();\n\n  void Swap(ServiceDescriptorProto* other);\n\n  // implements Message ----------------------------------------------\n\n  inline ServiceDescriptorProto* New() const { return New(NULL); }\n\n  ServiceDescriptorProto* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const ServiceDescriptorProto& from);\n  void MergeFrom(const ServiceDescriptorProto& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(ServiceDescriptorProto* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional string name = 1;\n  bool has_name() const;\n  void clear_name();\n  static const int kNameFieldNumber = 1;\n  const ::std::string& name() const;\n  void set_name(const ::std::string& value);\n  void set_name(const char* value);\n  void set_name(const char* value, size_t size);\n  ::std::string* mutable_name();\n  ::std::string* release_name();\n  void set_allocated_name(::std::string* name);\n\n  // repeated .google.protobuf.MethodDescriptorProto method = 2;\n  int method_size() const;\n  void clear_method();\n  static const int kMethodFieldNumber = 2;\n  const ::google::protobuf::MethodDescriptorProto& method(int index) const;\n  ::google::protobuf::MethodDescriptorProto* mutable_method(int index);\n  ::google::protobuf::MethodDescriptorProto* add_method();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >*\n      mutable_method();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >&\n      method() const;\n\n  // optional .google.protobuf.ServiceOptions options = 3;\n  bool has_options() const;\n  void clear_options();\n  static const int kOptionsFieldNumber = 3;\n  const ::google::protobuf::ServiceOptions& options() const;\n  ::google::protobuf::ServiceOptions* mutable_options();\n  ::google::protobuf::ServiceOptions* release_options();\n  void set_allocated_options(::google::protobuf::ServiceOptions* options);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.ServiceDescriptorProto)\n private:\n  inline void set_has_name();\n  inline void clear_has_name();\n  inline void set_has_options();\n  inline void clear_has_options();\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::internal::ArenaStringPtr name_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto > method_;\n  ::google::protobuf::ServiceOptions* options_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static ServiceDescriptorProto* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT MethodDescriptorProto : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodDescriptorProto) */ {\n public:\n  MethodDescriptorProto();\n  virtual ~MethodDescriptorProto();\n\n  MethodDescriptorProto(const MethodDescriptorProto& from);\n\n  inline MethodDescriptorProto& operator=(const MethodDescriptorProto& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const MethodDescriptorProto& default_instance();\n\n  void Swap(MethodDescriptorProto* other);\n\n  // implements Message ----------------------------------------------\n\n  inline MethodDescriptorProto* New() const { return New(NULL); }\n\n  MethodDescriptorProto* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const MethodDescriptorProto& from);\n  void MergeFrom(const MethodDescriptorProto& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(MethodDescriptorProto* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional string name = 1;\n  bool has_name() const;\n  void clear_name();\n  static const int kNameFieldNumber = 1;\n  const ::std::string& name() const;\n  void set_name(const ::std::string& value);\n  void set_name(const char* value);\n  void set_name(const char* value, size_t size);\n  ::std::string* mutable_name();\n  ::std::string* release_name();\n  void set_allocated_name(::std::string* name);\n\n  // optional string input_type = 2;\n  bool has_input_type() const;\n  void clear_input_type();\n  static const int kInputTypeFieldNumber = 2;\n  const ::std::string& input_type() const;\n  void set_input_type(const ::std::string& value);\n  void set_input_type(const char* value);\n  void set_input_type(const char* value, size_t size);\n  ::std::string* mutable_input_type();\n  ::std::string* release_input_type();\n  void set_allocated_input_type(::std::string* input_type);\n\n  // optional string output_type = 3;\n  bool has_output_type() const;\n  void clear_output_type();\n  static const int kOutputTypeFieldNumber = 3;\n  const ::std::string& output_type() const;\n  void set_output_type(const ::std::string& value);\n  void set_output_type(const char* value);\n  void set_output_type(const char* value, size_t size);\n  ::std::string* mutable_output_type();\n  ::std::string* release_output_type();\n  void set_allocated_output_type(::std::string* output_type);\n\n  // optional .google.protobuf.MethodOptions options = 4;\n  bool has_options() const;\n  void clear_options();\n  static const int kOptionsFieldNumber = 4;\n  const ::google::protobuf::MethodOptions& options() const;\n  ::google::protobuf::MethodOptions* mutable_options();\n  ::google::protobuf::MethodOptions* release_options();\n  void set_allocated_options(::google::protobuf::MethodOptions* options);\n\n  // optional bool client_streaming = 5 [default = false];\n  bool has_client_streaming() const;\n  void clear_client_streaming();\n  static const int kClientStreamingFieldNumber = 5;\n  bool client_streaming() const;\n  void set_client_streaming(bool value);\n\n  // optional bool server_streaming = 6 [default = false];\n  bool has_server_streaming() const;\n  void clear_server_streaming();\n  static const int kServerStreamingFieldNumber = 6;\n  bool server_streaming() const;\n  void set_server_streaming(bool value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.MethodDescriptorProto)\n private:\n  inline void set_has_name();\n  inline void clear_has_name();\n  inline void set_has_input_type();\n  inline void clear_has_input_type();\n  inline void set_has_output_type();\n  inline void clear_has_output_type();\n  inline void set_has_options();\n  inline void clear_has_options();\n  inline void set_has_client_streaming();\n  inline void clear_has_client_streaming();\n  inline void set_has_server_streaming();\n  inline void clear_has_server_streaming();\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::internal::ArenaStringPtr name_;\n  ::google::protobuf::internal::ArenaStringPtr input_type_;\n  ::google::protobuf::internal::ArenaStringPtr output_type_;\n  ::google::protobuf::MethodOptions* options_;\n  bool client_streaming_;\n  bool server_streaming_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static MethodDescriptorProto* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT FileOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FileOptions) */ {\n public:\n  FileOptions();\n  virtual ~FileOptions();\n\n  FileOptions(const FileOptions& from);\n\n  inline FileOptions& operator=(const FileOptions& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const FileOptions& default_instance();\n\n  void Swap(FileOptions* other);\n\n  // implements Message ----------------------------------------------\n\n  inline FileOptions* New() const { return New(NULL); }\n\n  FileOptions* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const FileOptions& from);\n  void MergeFrom(const FileOptions& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(FileOptions* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  typedef FileOptions_OptimizeMode OptimizeMode;\n  static const OptimizeMode SPEED =\n    FileOptions_OptimizeMode_SPEED;\n  static const OptimizeMode CODE_SIZE =\n    FileOptions_OptimizeMode_CODE_SIZE;\n  static const OptimizeMode LITE_RUNTIME =\n    FileOptions_OptimizeMode_LITE_RUNTIME;\n  static inline bool OptimizeMode_IsValid(int value) {\n    return FileOptions_OptimizeMode_IsValid(value);\n  }\n  static const OptimizeMode OptimizeMode_MIN =\n    FileOptions_OptimizeMode_OptimizeMode_MIN;\n  static const OptimizeMode OptimizeMode_MAX =\n    FileOptions_OptimizeMode_OptimizeMode_MAX;\n  static const int OptimizeMode_ARRAYSIZE =\n    FileOptions_OptimizeMode_OptimizeMode_ARRAYSIZE;\n  static inline const ::google::protobuf::EnumDescriptor*\n  OptimizeMode_descriptor() {\n    return FileOptions_OptimizeMode_descriptor();\n  }\n  static inline const ::std::string& OptimizeMode_Name(OptimizeMode value) {\n    return FileOptions_OptimizeMode_Name(value);\n  }\n  static inline bool OptimizeMode_Parse(const ::std::string& name,\n      OptimizeMode* value) {\n    return FileOptions_OptimizeMode_Parse(name, value);\n  }\n\n  // accessors -------------------------------------------------------\n\n  // optional string java_package = 1;\n  bool has_java_package() const;\n  void clear_java_package();\n  static const int kJavaPackageFieldNumber = 1;\n  const ::std::string& java_package() const;\n  void set_java_package(const ::std::string& value);\n  void set_java_package(const char* value);\n  void set_java_package(const char* value, size_t size);\n  ::std::string* mutable_java_package();\n  ::std::string* release_java_package();\n  void set_allocated_java_package(::std::string* java_package);\n\n  // optional string java_outer_classname = 8;\n  bool has_java_outer_classname() const;\n  void clear_java_outer_classname();\n  static const int kJavaOuterClassnameFieldNumber = 8;\n  const ::std::string& java_outer_classname() const;\n  void set_java_outer_classname(const ::std::string& value);\n  void set_java_outer_classname(const char* value);\n  void set_java_outer_classname(const char* value, size_t size);\n  ::std::string* mutable_java_outer_classname();\n  ::std::string* release_java_outer_classname();\n  void set_allocated_java_outer_classname(::std::string* java_outer_classname);\n\n  // optional bool java_multiple_files = 10 [default = false];\n  bool has_java_multiple_files() const;\n  void clear_java_multiple_files();\n  static const int kJavaMultipleFilesFieldNumber = 10;\n  bool java_multiple_files() const;\n  void set_java_multiple_files(bool value);\n\n  // optional bool java_generate_equals_and_hash = 20 [default = false];\n  bool has_java_generate_equals_and_hash() const;\n  void clear_java_generate_equals_and_hash();\n  static const int kJavaGenerateEqualsAndHashFieldNumber = 20;\n  bool java_generate_equals_and_hash() const;\n  void set_java_generate_equals_and_hash(bool value);\n\n  // optional bool java_string_check_utf8 = 27 [default = false];\n  bool has_java_string_check_utf8() const;\n  void clear_java_string_check_utf8();\n  static const int kJavaStringCheckUtf8FieldNumber = 27;\n  bool java_string_check_utf8() const;\n  void set_java_string_check_utf8(bool value);\n\n  // optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];\n  bool has_optimize_for() const;\n  void clear_optimize_for();\n  static const int kOptimizeForFieldNumber = 9;\n  ::google::protobuf::FileOptions_OptimizeMode optimize_for() const;\n  void set_optimize_for(::google::protobuf::FileOptions_OptimizeMode value);\n\n  // optional string go_package = 11;\n  bool has_go_package() const;\n  void clear_go_package();\n  static const int kGoPackageFieldNumber = 11;\n  const ::std::string& go_package() const;\n  void set_go_package(const ::std::string& value);\n  void set_go_package(const char* value);\n  void set_go_package(const char* value, size_t size);\n  ::std::string* mutable_go_package();\n  ::std::string* release_go_package();\n  void set_allocated_go_package(::std::string* go_package);\n\n  // optional bool cc_generic_services = 16 [default = false];\n  bool has_cc_generic_services() const;\n  void clear_cc_generic_services();\n  static const int kCcGenericServicesFieldNumber = 16;\n  bool cc_generic_services() const;\n  void set_cc_generic_services(bool value);\n\n  // optional bool java_generic_services = 17 [default = false];\n  bool has_java_generic_services() const;\n  void clear_java_generic_services();\n  static const int kJavaGenericServicesFieldNumber = 17;\n  bool java_generic_services() const;\n  void set_java_generic_services(bool value);\n\n  // optional bool py_generic_services = 18 [default = false];\n  bool has_py_generic_services() const;\n  void clear_py_generic_services();\n  static const int kPyGenericServicesFieldNumber = 18;\n  bool py_generic_services() const;\n  void set_py_generic_services(bool value);\n\n  // optional bool deprecated = 23 [default = false];\n  bool has_deprecated() const;\n  void clear_deprecated();\n  static const int kDeprecatedFieldNumber = 23;\n  bool deprecated() const;\n  void set_deprecated(bool value);\n\n  // optional bool cc_enable_arenas = 31 [default = false];\n  bool has_cc_enable_arenas() const;\n  void clear_cc_enable_arenas();\n  static const int kCcEnableArenasFieldNumber = 31;\n  bool cc_enable_arenas() const;\n  void set_cc_enable_arenas(bool value);\n\n  // optional string objc_class_prefix = 36;\n  bool has_objc_class_prefix() const;\n  void clear_objc_class_prefix();\n  static const int kObjcClassPrefixFieldNumber = 36;\n  const ::std::string& objc_class_prefix() const;\n  void set_objc_class_prefix(const ::std::string& value);\n  void set_objc_class_prefix(const char* value);\n  void set_objc_class_prefix(const char* value, size_t size);\n  ::std::string* mutable_objc_class_prefix();\n  ::std::string* release_objc_class_prefix();\n  void set_allocated_objc_class_prefix(::std::string* objc_class_prefix);\n\n  // optional string csharp_namespace = 37;\n  bool has_csharp_namespace() const;\n  void clear_csharp_namespace();\n  static const int kCsharpNamespaceFieldNumber = 37;\n  const ::std::string& csharp_namespace() const;\n  void set_csharp_namespace(const ::std::string& value);\n  void set_csharp_namespace(const char* value);\n  void set_csharp_namespace(const char* value, size_t size);\n  ::std::string* mutable_csharp_namespace();\n  ::std::string* release_csharp_namespace();\n  void set_allocated_csharp_namespace(::std::string* csharp_namespace);\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  int uninterpreted_option_size() const;\n  void clear_uninterpreted_option();\n  static const int kUninterpretedOptionFieldNumber = 999;\n  const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;\n  ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);\n  ::google::protobuf::UninterpretedOption* add_uninterpreted_option();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\n      mutable_uninterpreted_option();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\n      uninterpreted_option() const;\n\n  GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(FileOptions)\n  // @@protoc_insertion_point(class_scope:google.protobuf.FileOptions)\n private:\n  inline void set_has_java_package();\n  inline void clear_has_java_package();\n  inline void set_has_java_outer_classname();\n  inline void clear_has_java_outer_classname();\n  inline void set_has_java_multiple_files();\n  inline void clear_has_java_multiple_files();\n  inline void set_has_java_generate_equals_and_hash();\n  inline void clear_has_java_generate_equals_and_hash();\n  inline void set_has_java_string_check_utf8();\n  inline void clear_has_java_string_check_utf8();\n  inline void set_has_optimize_for();\n  inline void clear_has_optimize_for();\n  inline void set_has_go_package();\n  inline void clear_has_go_package();\n  inline void set_has_cc_generic_services();\n  inline void clear_has_cc_generic_services();\n  inline void set_has_java_generic_services();\n  inline void clear_has_java_generic_services();\n  inline void set_has_py_generic_services();\n  inline void clear_has_py_generic_services();\n  inline void set_has_deprecated();\n  inline void clear_has_deprecated();\n  inline void set_has_cc_enable_arenas();\n  inline void clear_has_cc_enable_arenas();\n  inline void set_has_objc_class_prefix();\n  inline void clear_has_objc_class_prefix();\n  inline void set_has_csharp_namespace();\n  inline void clear_has_csharp_namespace();\n\n  ::google::protobuf::internal::ExtensionSet _extensions_;\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::internal::ArenaStringPtr java_package_;\n  ::google::protobuf::internal::ArenaStringPtr java_outer_classname_;\n  bool java_multiple_files_;\n  bool java_generate_equals_and_hash_;\n  bool java_string_check_utf8_;\n  bool cc_generic_services_;\n  int optimize_for_;\n  ::google::protobuf::internal::ArenaStringPtr go_package_;\n  ::google::protobuf::internal::ArenaStringPtr objc_class_prefix_;\n  ::google::protobuf::internal::ArenaStringPtr csharp_namespace_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_;\n  bool java_generic_services_;\n  bool py_generic_services_;\n  bool deprecated_;\n  bool cc_enable_arenas_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static FileOptions* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT MessageOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MessageOptions) */ {\n public:\n  MessageOptions();\n  virtual ~MessageOptions();\n\n  MessageOptions(const MessageOptions& from);\n\n  inline MessageOptions& operator=(const MessageOptions& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const MessageOptions& default_instance();\n\n  void Swap(MessageOptions* other);\n\n  // implements Message ----------------------------------------------\n\n  inline MessageOptions* New() const { return New(NULL); }\n\n  MessageOptions* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const MessageOptions& from);\n  void MergeFrom(const MessageOptions& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(MessageOptions* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional bool message_set_wire_format = 1 [default = false];\n  bool has_message_set_wire_format() const;\n  void clear_message_set_wire_format();\n  static const int kMessageSetWireFormatFieldNumber = 1;\n  bool message_set_wire_format() const;\n  void set_message_set_wire_format(bool value);\n\n  // optional bool no_standard_descriptor_accessor = 2 [default = false];\n  bool has_no_standard_descriptor_accessor() const;\n  void clear_no_standard_descriptor_accessor();\n  static const int kNoStandardDescriptorAccessorFieldNumber = 2;\n  bool no_standard_descriptor_accessor() const;\n  void set_no_standard_descriptor_accessor(bool value);\n\n  // optional bool deprecated = 3 [default = false];\n  bool has_deprecated() const;\n  void clear_deprecated();\n  static const int kDeprecatedFieldNumber = 3;\n  bool deprecated() const;\n  void set_deprecated(bool value);\n\n  // optional bool map_entry = 7;\n  bool has_map_entry() const;\n  void clear_map_entry();\n  static const int kMapEntryFieldNumber = 7;\n  bool map_entry() const;\n  void set_map_entry(bool value);\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  int uninterpreted_option_size() const;\n  void clear_uninterpreted_option();\n  static const int kUninterpretedOptionFieldNumber = 999;\n  const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;\n  ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);\n  ::google::protobuf::UninterpretedOption* add_uninterpreted_option();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\n      mutable_uninterpreted_option();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\n      uninterpreted_option() const;\n\n  GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(MessageOptions)\n  // @@protoc_insertion_point(class_scope:google.protobuf.MessageOptions)\n private:\n  inline void set_has_message_set_wire_format();\n  inline void clear_has_message_set_wire_format();\n  inline void set_has_no_standard_descriptor_accessor();\n  inline void clear_has_no_standard_descriptor_accessor();\n  inline void set_has_deprecated();\n  inline void clear_has_deprecated();\n  inline void set_has_map_entry();\n  inline void clear_has_map_entry();\n\n  ::google::protobuf::internal::ExtensionSet _extensions_;\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_;\n  bool message_set_wire_format_;\n  bool no_standard_descriptor_accessor_;\n  bool deprecated_;\n  bool map_entry_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static MessageOptions* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT FieldOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldOptions) */ {\n public:\n  FieldOptions();\n  virtual ~FieldOptions();\n\n  FieldOptions(const FieldOptions& from);\n\n  inline FieldOptions& operator=(const FieldOptions& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const FieldOptions& default_instance();\n\n  void Swap(FieldOptions* other);\n\n  // implements Message ----------------------------------------------\n\n  inline FieldOptions* New() const { return New(NULL); }\n\n  FieldOptions* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const FieldOptions& from);\n  void MergeFrom(const FieldOptions& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(FieldOptions* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  typedef FieldOptions_CType CType;\n  static const CType STRING =\n    FieldOptions_CType_STRING;\n  static const CType CORD =\n    FieldOptions_CType_CORD;\n  static const CType STRING_PIECE =\n    FieldOptions_CType_STRING_PIECE;\n  static inline bool CType_IsValid(int value) {\n    return FieldOptions_CType_IsValid(value);\n  }\n  static const CType CType_MIN =\n    FieldOptions_CType_CType_MIN;\n  static const CType CType_MAX =\n    FieldOptions_CType_CType_MAX;\n  static const int CType_ARRAYSIZE =\n    FieldOptions_CType_CType_ARRAYSIZE;\n  static inline const ::google::protobuf::EnumDescriptor*\n  CType_descriptor() {\n    return FieldOptions_CType_descriptor();\n  }\n  static inline const ::std::string& CType_Name(CType value) {\n    return FieldOptions_CType_Name(value);\n  }\n  static inline bool CType_Parse(const ::std::string& name,\n      CType* value) {\n    return FieldOptions_CType_Parse(name, value);\n  }\n\n  typedef FieldOptions_JSType JSType;\n  static const JSType JS_NORMAL =\n    FieldOptions_JSType_JS_NORMAL;\n  static const JSType JS_STRING =\n    FieldOptions_JSType_JS_STRING;\n  static const JSType JS_NUMBER =\n    FieldOptions_JSType_JS_NUMBER;\n  static inline bool JSType_IsValid(int value) {\n    return FieldOptions_JSType_IsValid(value);\n  }\n  static const JSType JSType_MIN =\n    FieldOptions_JSType_JSType_MIN;\n  static const JSType JSType_MAX =\n    FieldOptions_JSType_JSType_MAX;\n  static const int JSType_ARRAYSIZE =\n    FieldOptions_JSType_JSType_ARRAYSIZE;\n  static inline const ::google::protobuf::EnumDescriptor*\n  JSType_descriptor() {\n    return FieldOptions_JSType_descriptor();\n  }\n  static inline const ::std::string& JSType_Name(JSType value) {\n    return FieldOptions_JSType_Name(value);\n  }\n  static inline bool JSType_Parse(const ::std::string& name,\n      JSType* value) {\n    return FieldOptions_JSType_Parse(name, value);\n  }\n\n  // accessors -------------------------------------------------------\n\n  // optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];\n  bool has_ctype() const;\n  void clear_ctype();\n  static const int kCtypeFieldNumber = 1;\n  ::google::protobuf::FieldOptions_CType ctype() const;\n  void set_ctype(::google::protobuf::FieldOptions_CType value);\n\n  // optional bool packed = 2;\n  bool has_packed() const;\n  void clear_packed();\n  static const int kPackedFieldNumber = 2;\n  bool packed() const;\n  void set_packed(bool value);\n\n  // optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];\n  bool has_jstype() const;\n  void clear_jstype();\n  static const int kJstypeFieldNumber = 6;\n  ::google::protobuf::FieldOptions_JSType jstype() const;\n  void set_jstype(::google::protobuf::FieldOptions_JSType value);\n\n  // optional bool lazy = 5 [default = false];\n  bool has_lazy() const;\n  void clear_lazy();\n  static const int kLazyFieldNumber = 5;\n  bool lazy() const;\n  void set_lazy(bool value);\n\n  // optional bool deprecated = 3 [default = false];\n  bool has_deprecated() const;\n  void clear_deprecated();\n  static const int kDeprecatedFieldNumber = 3;\n  bool deprecated() const;\n  void set_deprecated(bool value);\n\n  // optional bool weak = 10 [default = false];\n  bool has_weak() const;\n  void clear_weak();\n  static const int kWeakFieldNumber = 10;\n  bool weak() const;\n  void set_weak(bool value);\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  int uninterpreted_option_size() const;\n  void clear_uninterpreted_option();\n  static const int kUninterpretedOptionFieldNumber = 999;\n  const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;\n  ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);\n  ::google::protobuf::UninterpretedOption* add_uninterpreted_option();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\n      mutable_uninterpreted_option();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\n      uninterpreted_option() const;\n\n  GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(FieldOptions)\n  // @@protoc_insertion_point(class_scope:google.protobuf.FieldOptions)\n private:\n  inline void set_has_ctype();\n  inline void clear_has_ctype();\n  inline void set_has_packed();\n  inline void clear_has_packed();\n  inline void set_has_jstype();\n  inline void clear_has_jstype();\n  inline void set_has_lazy();\n  inline void clear_has_lazy();\n  inline void set_has_deprecated();\n  inline void clear_has_deprecated();\n  inline void set_has_weak();\n  inline void clear_has_weak();\n\n  ::google::protobuf::internal::ExtensionSet _extensions_;\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  int ctype_;\n  int jstype_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_;\n  bool packed_;\n  bool lazy_;\n  bool deprecated_;\n  bool weak_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static FieldOptions* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT OneofOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.OneofOptions) */ {\n public:\n  OneofOptions();\n  virtual ~OneofOptions();\n\n  OneofOptions(const OneofOptions& from);\n\n  inline OneofOptions& operator=(const OneofOptions& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const OneofOptions& default_instance();\n\n  void Swap(OneofOptions* other);\n\n  // implements Message ----------------------------------------------\n\n  inline OneofOptions* New() const { return New(NULL); }\n\n  OneofOptions* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const OneofOptions& from);\n  void MergeFrom(const OneofOptions& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(OneofOptions* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  int uninterpreted_option_size() const;\n  void clear_uninterpreted_option();\n  static const int kUninterpretedOptionFieldNumber = 999;\n  const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;\n  ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);\n  ::google::protobuf::UninterpretedOption* add_uninterpreted_option();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\n      mutable_uninterpreted_option();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\n      uninterpreted_option() const;\n\n  GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(OneofOptions)\n  // @@protoc_insertion_point(class_scope:google.protobuf.OneofOptions)\n private:\n\n  ::google::protobuf::internal::ExtensionSet _extensions_;\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static OneofOptions* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT EnumOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumOptions) */ {\n public:\n  EnumOptions();\n  virtual ~EnumOptions();\n\n  EnumOptions(const EnumOptions& from);\n\n  inline EnumOptions& operator=(const EnumOptions& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const EnumOptions& default_instance();\n\n  void Swap(EnumOptions* other);\n\n  // implements Message ----------------------------------------------\n\n  inline EnumOptions* New() const { return New(NULL); }\n\n  EnumOptions* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const EnumOptions& from);\n  void MergeFrom(const EnumOptions& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(EnumOptions* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional bool allow_alias = 2;\n  bool has_allow_alias() const;\n  void clear_allow_alias();\n  static const int kAllowAliasFieldNumber = 2;\n  bool allow_alias() const;\n  void set_allow_alias(bool value);\n\n  // optional bool deprecated = 3 [default = false];\n  bool has_deprecated() const;\n  void clear_deprecated();\n  static const int kDeprecatedFieldNumber = 3;\n  bool deprecated() const;\n  void set_deprecated(bool value);\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  int uninterpreted_option_size() const;\n  void clear_uninterpreted_option();\n  static const int kUninterpretedOptionFieldNumber = 999;\n  const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;\n  ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);\n  ::google::protobuf::UninterpretedOption* add_uninterpreted_option();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\n      mutable_uninterpreted_option();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\n      uninterpreted_option() const;\n\n  GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(EnumOptions)\n  // @@protoc_insertion_point(class_scope:google.protobuf.EnumOptions)\n private:\n  inline void set_has_allow_alias();\n  inline void clear_has_allow_alias();\n  inline void set_has_deprecated();\n  inline void clear_has_deprecated();\n\n  ::google::protobuf::internal::ExtensionSet _extensions_;\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_;\n  bool allow_alias_;\n  bool deprecated_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static EnumOptions* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT EnumValueOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValueOptions) */ {\n public:\n  EnumValueOptions();\n  virtual ~EnumValueOptions();\n\n  EnumValueOptions(const EnumValueOptions& from);\n\n  inline EnumValueOptions& operator=(const EnumValueOptions& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const EnumValueOptions& default_instance();\n\n  void Swap(EnumValueOptions* other);\n\n  // implements Message ----------------------------------------------\n\n  inline EnumValueOptions* New() const { return New(NULL); }\n\n  EnumValueOptions* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const EnumValueOptions& from);\n  void MergeFrom(const EnumValueOptions& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(EnumValueOptions* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional bool deprecated = 1 [default = false];\n  bool has_deprecated() const;\n  void clear_deprecated();\n  static const int kDeprecatedFieldNumber = 1;\n  bool deprecated() const;\n  void set_deprecated(bool value);\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  int uninterpreted_option_size() const;\n  void clear_uninterpreted_option();\n  static const int kUninterpretedOptionFieldNumber = 999;\n  const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;\n  ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);\n  ::google::protobuf::UninterpretedOption* add_uninterpreted_option();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\n      mutable_uninterpreted_option();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\n      uninterpreted_option() const;\n\n  GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(EnumValueOptions)\n  // @@protoc_insertion_point(class_scope:google.protobuf.EnumValueOptions)\n private:\n  inline void set_has_deprecated();\n  inline void clear_has_deprecated();\n\n  ::google::protobuf::internal::ExtensionSet _extensions_;\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_;\n  bool deprecated_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static EnumValueOptions* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT ServiceOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ServiceOptions) */ {\n public:\n  ServiceOptions();\n  virtual ~ServiceOptions();\n\n  ServiceOptions(const ServiceOptions& from);\n\n  inline ServiceOptions& operator=(const ServiceOptions& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const ServiceOptions& default_instance();\n\n  void Swap(ServiceOptions* other);\n\n  // implements Message ----------------------------------------------\n\n  inline ServiceOptions* New() const { return New(NULL); }\n\n  ServiceOptions* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const ServiceOptions& from);\n  void MergeFrom(const ServiceOptions& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(ServiceOptions* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional bool deprecated = 33 [default = false];\n  bool has_deprecated() const;\n  void clear_deprecated();\n  static const int kDeprecatedFieldNumber = 33;\n  bool deprecated() const;\n  void set_deprecated(bool value);\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  int uninterpreted_option_size() const;\n  void clear_uninterpreted_option();\n  static const int kUninterpretedOptionFieldNumber = 999;\n  const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;\n  ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);\n  ::google::protobuf::UninterpretedOption* add_uninterpreted_option();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\n      mutable_uninterpreted_option();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\n      uninterpreted_option() const;\n\n  GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(ServiceOptions)\n  // @@protoc_insertion_point(class_scope:google.protobuf.ServiceOptions)\n private:\n  inline void set_has_deprecated();\n  inline void clear_has_deprecated();\n\n  ::google::protobuf::internal::ExtensionSet _extensions_;\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_;\n  bool deprecated_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static ServiceOptions* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT MethodOptions : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.MethodOptions) */ {\n public:\n  MethodOptions();\n  virtual ~MethodOptions();\n\n  MethodOptions(const MethodOptions& from);\n\n  inline MethodOptions& operator=(const MethodOptions& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const MethodOptions& default_instance();\n\n  void Swap(MethodOptions* other);\n\n  // implements Message ----------------------------------------------\n\n  inline MethodOptions* New() const { return New(NULL); }\n\n  MethodOptions* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const MethodOptions& from);\n  void MergeFrom(const MethodOptions& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(MethodOptions* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional bool deprecated = 33 [default = false];\n  bool has_deprecated() const;\n  void clear_deprecated();\n  static const int kDeprecatedFieldNumber = 33;\n  bool deprecated() const;\n  void set_deprecated(bool value);\n\n  // repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\n  int uninterpreted_option_size() const;\n  void clear_uninterpreted_option();\n  static const int kUninterpretedOptionFieldNumber = 999;\n  const ::google::protobuf::UninterpretedOption& uninterpreted_option(int index) const;\n  ::google::protobuf::UninterpretedOption* mutable_uninterpreted_option(int index);\n  ::google::protobuf::UninterpretedOption* add_uninterpreted_option();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\n      mutable_uninterpreted_option();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\n      uninterpreted_option() const;\n\n  GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(MethodOptions)\n  // @@protoc_insertion_point(class_scope:google.protobuf.MethodOptions)\n private:\n  inline void set_has_deprecated();\n  inline void clear_has_deprecated();\n\n  ::google::protobuf::internal::ExtensionSet _extensions_;\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption > uninterpreted_option_;\n  bool deprecated_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static MethodOptions* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT UninterpretedOption_NamePart : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption.NamePart) */ {\n public:\n  UninterpretedOption_NamePart();\n  virtual ~UninterpretedOption_NamePart();\n\n  UninterpretedOption_NamePart(const UninterpretedOption_NamePart& from);\n\n  inline UninterpretedOption_NamePart& operator=(const UninterpretedOption_NamePart& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const UninterpretedOption_NamePart& default_instance();\n\n  void Swap(UninterpretedOption_NamePart* other);\n\n  // implements Message ----------------------------------------------\n\n  inline UninterpretedOption_NamePart* New() const { return New(NULL); }\n\n  UninterpretedOption_NamePart* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const UninterpretedOption_NamePart& from);\n  void MergeFrom(const UninterpretedOption_NamePart& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(UninterpretedOption_NamePart* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // required string name_part = 1;\n  bool has_name_part() const;\n  void clear_name_part();\n  static const int kNamePartFieldNumber = 1;\n  const ::std::string& name_part() const;\n  void set_name_part(const ::std::string& value);\n  void set_name_part(const char* value);\n  void set_name_part(const char* value, size_t size);\n  ::std::string* mutable_name_part();\n  ::std::string* release_name_part();\n  void set_allocated_name_part(::std::string* name_part);\n\n  // required bool is_extension = 2;\n  bool has_is_extension() const;\n  void clear_is_extension();\n  static const int kIsExtensionFieldNumber = 2;\n  bool is_extension() const;\n  void set_is_extension(bool value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.UninterpretedOption.NamePart)\n private:\n  inline void set_has_name_part();\n  inline void clear_has_name_part();\n  inline void set_has_is_extension();\n  inline void clear_has_is_extension();\n\n  // helper for ByteSize()\n  int RequiredFieldsByteSizeFallback() const;\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::internal::ArenaStringPtr name_part_;\n  bool is_extension_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static UninterpretedOption_NamePart* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT UninterpretedOption : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UninterpretedOption) */ {\n public:\n  UninterpretedOption();\n  virtual ~UninterpretedOption();\n\n  UninterpretedOption(const UninterpretedOption& from);\n\n  inline UninterpretedOption& operator=(const UninterpretedOption& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const UninterpretedOption& default_instance();\n\n  void Swap(UninterpretedOption* other);\n\n  // implements Message ----------------------------------------------\n\n  inline UninterpretedOption* New() const { return New(NULL); }\n\n  UninterpretedOption* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const UninterpretedOption& from);\n  void MergeFrom(const UninterpretedOption& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(UninterpretedOption* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  typedef UninterpretedOption_NamePart NamePart;\n\n  // accessors -------------------------------------------------------\n\n  // repeated .google.protobuf.UninterpretedOption.NamePart name = 2;\n  int name_size() const;\n  void clear_name();\n  static const int kNameFieldNumber = 2;\n  const ::google::protobuf::UninterpretedOption_NamePart& name(int index) const;\n  ::google::protobuf::UninterpretedOption_NamePart* mutable_name(int index);\n  ::google::protobuf::UninterpretedOption_NamePart* add_name();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart >*\n      mutable_name();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart >&\n      name() const;\n\n  // optional string identifier_value = 3;\n  bool has_identifier_value() const;\n  void clear_identifier_value();\n  static const int kIdentifierValueFieldNumber = 3;\n  const ::std::string& identifier_value() const;\n  void set_identifier_value(const ::std::string& value);\n  void set_identifier_value(const char* value);\n  void set_identifier_value(const char* value, size_t size);\n  ::std::string* mutable_identifier_value();\n  ::std::string* release_identifier_value();\n  void set_allocated_identifier_value(::std::string* identifier_value);\n\n  // optional uint64 positive_int_value = 4;\n  bool has_positive_int_value() const;\n  void clear_positive_int_value();\n  static const int kPositiveIntValueFieldNumber = 4;\n  ::google::protobuf::uint64 positive_int_value() const;\n  void set_positive_int_value(::google::protobuf::uint64 value);\n\n  // optional int64 negative_int_value = 5;\n  bool has_negative_int_value() const;\n  void clear_negative_int_value();\n  static const int kNegativeIntValueFieldNumber = 5;\n  ::google::protobuf::int64 negative_int_value() const;\n  void set_negative_int_value(::google::protobuf::int64 value);\n\n  // optional double double_value = 6;\n  bool has_double_value() const;\n  void clear_double_value();\n  static const int kDoubleValueFieldNumber = 6;\n  double double_value() const;\n  void set_double_value(double value);\n\n  // optional bytes string_value = 7;\n  bool has_string_value() const;\n  void clear_string_value();\n  static const int kStringValueFieldNumber = 7;\n  const ::std::string& string_value() const;\n  void set_string_value(const ::std::string& value);\n  void set_string_value(const char* value);\n  void set_string_value(const void* value, size_t size);\n  ::std::string* mutable_string_value();\n  ::std::string* release_string_value();\n  void set_allocated_string_value(::std::string* string_value);\n\n  // optional string aggregate_value = 8;\n  bool has_aggregate_value() const;\n  void clear_aggregate_value();\n  static const int kAggregateValueFieldNumber = 8;\n  const ::std::string& aggregate_value() const;\n  void set_aggregate_value(const ::std::string& value);\n  void set_aggregate_value(const char* value);\n  void set_aggregate_value(const char* value, size_t size);\n  ::std::string* mutable_aggregate_value();\n  ::std::string* release_aggregate_value();\n  void set_allocated_aggregate_value(::std::string* aggregate_value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.UninterpretedOption)\n private:\n  inline void set_has_identifier_value();\n  inline void clear_has_identifier_value();\n  inline void set_has_positive_int_value();\n  inline void clear_has_positive_int_value();\n  inline void set_has_negative_int_value();\n  inline void clear_has_negative_int_value();\n  inline void set_has_double_value();\n  inline void clear_has_double_value();\n  inline void set_has_string_value();\n  inline void clear_has_string_value();\n  inline void set_has_aggregate_value();\n  inline void clear_has_aggregate_value();\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart > name_;\n  ::google::protobuf::internal::ArenaStringPtr identifier_value_;\n  ::google::protobuf::uint64 positive_int_value_;\n  ::google::protobuf::int64 negative_int_value_;\n  double double_value_;\n  ::google::protobuf::internal::ArenaStringPtr string_value_;\n  ::google::protobuf::internal::ArenaStringPtr aggregate_value_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static UninterpretedOption* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT SourceCodeInfo_Location : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo.Location) */ {\n public:\n  SourceCodeInfo_Location();\n  virtual ~SourceCodeInfo_Location();\n\n  SourceCodeInfo_Location(const SourceCodeInfo_Location& from);\n\n  inline SourceCodeInfo_Location& operator=(const SourceCodeInfo_Location& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const SourceCodeInfo_Location& default_instance();\n\n  void Swap(SourceCodeInfo_Location* other);\n\n  // implements Message ----------------------------------------------\n\n  inline SourceCodeInfo_Location* New() const { return New(NULL); }\n\n  SourceCodeInfo_Location* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const SourceCodeInfo_Location& from);\n  void MergeFrom(const SourceCodeInfo_Location& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(SourceCodeInfo_Location* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // repeated int32 path = 1 [packed = true];\n  int path_size() const;\n  void clear_path();\n  static const int kPathFieldNumber = 1;\n  ::google::protobuf::int32 path(int index) const;\n  void set_path(int index, ::google::protobuf::int32 value);\n  void add_path(::google::protobuf::int32 value);\n  const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&\n      path() const;\n  ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*\n      mutable_path();\n\n  // repeated int32 span = 2 [packed = true];\n  int span_size() const;\n  void clear_span();\n  static const int kSpanFieldNumber = 2;\n  ::google::protobuf::int32 span(int index) const;\n  void set_span(int index, ::google::protobuf::int32 value);\n  void add_span(::google::protobuf::int32 value);\n  const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&\n      span() const;\n  ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*\n      mutable_span();\n\n  // optional string leading_comments = 3;\n  bool has_leading_comments() const;\n  void clear_leading_comments();\n  static const int kLeadingCommentsFieldNumber = 3;\n  const ::std::string& leading_comments() const;\n  void set_leading_comments(const ::std::string& value);\n  void set_leading_comments(const char* value);\n  void set_leading_comments(const char* value, size_t size);\n  ::std::string* mutable_leading_comments();\n  ::std::string* release_leading_comments();\n  void set_allocated_leading_comments(::std::string* leading_comments);\n\n  // optional string trailing_comments = 4;\n  bool has_trailing_comments() const;\n  void clear_trailing_comments();\n  static const int kTrailingCommentsFieldNumber = 4;\n  const ::std::string& trailing_comments() const;\n  void set_trailing_comments(const ::std::string& value);\n  void set_trailing_comments(const char* value);\n  void set_trailing_comments(const char* value, size_t size);\n  ::std::string* mutable_trailing_comments();\n  ::std::string* release_trailing_comments();\n  void set_allocated_trailing_comments(::std::string* trailing_comments);\n\n  // repeated string leading_detached_comments = 6;\n  int leading_detached_comments_size() const;\n  void clear_leading_detached_comments();\n  static const int kLeadingDetachedCommentsFieldNumber = 6;\n  const ::std::string& leading_detached_comments(int index) const;\n  ::std::string* mutable_leading_detached_comments(int index);\n  void set_leading_detached_comments(int index, const ::std::string& value);\n  void set_leading_detached_comments(int index, const char* value);\n  void set_leading_detached_comments(int index, const char* value, size_t size);\n  ::std::string* add_leading_detached_comments();\n  void add_leading_detached_comments(const ::std::string& value);\n  void add_leading_detached_comments(const char* value);\n  void add_leading_detached_comments(const char* value, size_t size);\n  const ::google::protobuf::RepeatedPtrField< ::std::string>& leading_detached_comments() const;\n  ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_leading_detached_comments();\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.SourceCodeInfo.Location)\n private:\n  inline void set_has_leading_comments();\n  inline void clear_has_leading_comments();\n  inline void set_has_trailing_comments();\n  inline void clear_has_trailing_comments();\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::RepeatedField< ::google::protobuf::int32 > path_;\n  mutable int _path_cached_byte_size_;\n  ::google::protobuf::RepeatedField< ::google::protobuf::int32 > span_;\n  mutable int _span_cached_byte_size_;\n  ::google::protobuf::internal::ArenaStringPtr leading_comments_;\n  ::google::protobuf::internal::ArenaStringPtr trailing_comments_;\n  ::google::protobuf::RepeatedPtrField< ::std::string> leading_detached_comments_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static SourceCodeInfo_Location* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT SourceCodeInfo : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceCodeInfo) */ {\n public:\n  SourceCodeInfo();\n  virtual ~SourceCodeInfo();\n\n  SourceCodeInfo(const SourceCodeInfo& from);\n\n  inline SourceCodeInfo& operator=(const SourceCodeInfo& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const SourceCodeInfo& default_instance();\n\n  void Swap(SourceCodeInfo* other);\n\n  // implements Message ----------------------------------------------\n\n  inline SourceCodeInfo* New() const { return New(NULL); }\n\n  SourceCodeInfo* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const SourceCodeInfo& from);\n  void MergeFrom(const SourceCodeInfo& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(SourceCodeInfo* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  typedef SourceCodeInfo_Location Location;\n\n  // accessors -------------------------------------------------------\n\n  // repeated .google.protobuf.SourceCodeInfo.Location location = 1;\n  int location_size() const;\n  void clear_location();\n  static const int kLocationFieldNumber = 1;\n  const ::google::protobuf::SourceCodeInfo_Location& location(int index) const;\n  ::google::protobuf::SourceCodeInfo_Location* mutable_location(int index);\n  ::google::protobuf::SourceCodeInfo_Location* add_location();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location >*\n      mutable_location();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location >&\n      location() const;\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.SourceCodeInfo)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location > location_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static SourceCodeInfo* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT GeneratedCodeInfo_Annotation : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo.Annotation) */ {\n public:\n  GeneratedCodeInfo_Annotation();\n  virtual ~GeneratedCodeInfo_Annotation();\n\n  GeneratedCodeInfo_Annotation(const GeneratedCodeInfo_Annotation& from);\n\n  inline GeneratedCodeInfo_Annotation& operator=(const GeneratedCodeInfo_Annotation& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const GeneratedCodeInfo_Annotation& default_instance();\n\n  void Swap(GeneratedCodeInfo_Annotation* other);\n\n  // implements Message ----------------------------------------------\n\n  inline GeneratedCodeInfo_Annotation* New() const { return New(NULL); }\n\n  GeneratedCodeInfo_Annotation* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const GeneratedCodeInfo_Annotation& from);\n  void MergeFrom(const GeneratedCodeInfo_Annotation& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(GeneratedCodeInfo_Annotation* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // repeated int32 path = 1 [packed = true];\n  int path_size() const;\n  void clear_path();\n  static const int kPathFieldNumber = 1;\n  ::google::protobuf::int32 path(int index) const;\n  void set_path(int index, ::google::protobuf::int32 value);\n  void add_path(::google::protobuf::int32 value);\n  const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&\n      path() const;\n  ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*\n      mutable_path();\n\n  // optional string source_file = 2;\n  bool has_source_file() const;\n  void clear_source_file();\n  static const int kSourceFileFieldNumber = 2;\n  const ::std::string& source_file() const;\n  void set_source_file(const ::std::string& value);\n  void set_source_file(const char* value);\n  void set_source_file(const char* value, size_t size);\n  ::std::string* mutable_source_file();\n  ::std::string* release_source_file();\n  void set_allocated_source_file(::std::string* source_file);\n\n  // optional int32 begin = 3;\n  bool has_begin() const;\n  void clear_begin();\n  static const int kBeginFieldNumber = 3;\n  ::google::protobuf::int32 begin() const;\n  void set_begin(::google::protobuf::int32 value);\n\n  // optional int32 end = 4;\n  bool has_end() const;\n  void clear_end();\n  static const int kEndFieldNumber = 4;\n  ::google::protobuf::int32 end() const;\n  void set_end(::google::protobuf::int32 value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.GeneratedCodeInfo.Annotation)\n private:\n  inline void set_has_source_file();\n  inline void clear_has_source_file();\n  inline void set_has_begin();\n  inline void clear_has_begin();\n  inline void set_has_end();\n  inline void clear_has_end();\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::RepeatedField< ::google::protobuf::int32 > path_;\n  mutable int _path_cached_byte_size_;\n  ::google::protobuf::internal::ArenaStringPtr source_file_;\n  ::google::protobuf::int32 begin_;\n  ::google::protobuf::int32 end_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static GeneratedCodeInfo_Annotation* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT GeneratedCodeInfo : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.GeneratedCodeInfo) */ {\n public:\n  GeneratedCodeInfo();\n  virtual ~GeneratedCodeInfo();\n\n  GeneratedCodeInfo(const GeneratedCodeInfo& from);\n\n  inline GeneratedCodeInfo& operator=(const GeneratedCodeInfo& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const {\n    return _internal_metadata_.unknown_fields();\n  }\n\n  inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() {\n    return _internal_metadata_.mutable_unknown_fields();\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const GeneratedCodeInfo& default_instance();\n\n  void Swap(GeneratedCodeInfo* other);\n\n  // implements Message ----------------------------------------------\n\n  inline GeneratedCodeInfo* New() const { return New(NULL); }\n\n  GeneratedCodeInfo* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const GeneratedCodeInfo& from);\n  void MergeFrom(const GeneratedCodeInfo& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(GeneratedCodeInfo* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  typedef GeneratedCodeInfo_Annotation Annotation;\n\n  // accessors -------------------------------------------------------\n\n  // repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;\n  int annotation_size() const;\n  void clear_annotation();\n  static const int kAnnotationFieldNumber = 1;\n  const ::google::protobuf::GeneratedCodeInfo_Annotation& annotation(int index) const;\n  ::google::protobuf::GeneratedCodeInfo_Annotation* mutable_annotation(int index);\n  ::google::protobuf::GeneratedCodeInfo_Annotation* add_annotation();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation >*\n      mutable_annotation();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation >&\n      annotation() const;\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.GeneratedCodeInfo)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  ::google::protobuf::uint32 _has_bits_[1];\n  mutable int _cached_size_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation > annotation_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fdescriptor_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fdescriptor_2eproto();\n\n  void InitAsDefaultInstance();\n  static GeneratedCodeInfo* default_instance_;\n};\n// ===================================================================\n\n\n// ===================================================================\n\n#if !PROTOBUF_INLINE_NOT_IN_HEADERS\n// FileDescriptorSet\n\n// repeated .google.protobuf.FileDescriptorProto file = 1;\ninline int FileDescriptorSet::file_size() const {\n  return file_.size();\n}\ninline void FileDescriptorSet::clear_file() {\n  file_.Clear();\n}\ninline const ::google::protobuf::FileDescriptorProto& FileDescriptorSet::file(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorSet.file)\n  return file_.Get(index);\n}\ninline ::google::protobuf::FileDescriptorProto* FileDescriptorSet::mutable_file(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorSet.file)\n  return file_.Mutable(index);\n}\ninline ::google::protobuf::FileDescriptorProto* FileDescriptorSet::add_file() {\n  // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorSet.file)\n  return file_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >*\nFileDescriptorSet::mutable_file() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorSet.file)\n  return &file_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FileDescriptorProto >&\nFileDescriptorSet::file() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorSet.file)\n  return file_;\n}\n\n// -------------------------------------------------------------------\n\n// FileDescriptorProto\n\n// optional string name = 1;\ninline bool FileDescriptorProto::has_name() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\ninline void FileDescriptorProto::set_has_name() {\n  _has_bits_[0] |= 0x00000001u;\n}\ninline void FileDescriptorProto::clear_has_name() {\n  _has_bits_[0] &= ~0x00000001u;\n}\ninline void FileDescriptorProto::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_name();\n}\ninline const ::std::string& FileDescriptorProto::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FileDescriptorProto::set_name(const ::std::string& value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.name)\n}\ninline void FileDescriptorProto::set_name(const char* value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.name)\n}\ninline void FileDescriptorProto::set_name(const char* value, size_t size) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.name)\n}\ninline ::std::string* FileDescriptorProto::mutable_name() {\n  set_has_name();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* FileDescriptorProto::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.name)\n  clear_has_name();\n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FileDescriptorProto::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    set_has_name();\n  } else {\n    clear_has_name();\n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.name)\n}\n\n// optional string package = 2;\ninline bool FileDescriptorProto::has_package() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\ninline void FileDescriptorProto::set_has_package() {\n  _has_bits_[0] |= 0x00000002u;\n}\ninline void FileDescriptorProto::clear_has_package() {\n  _has_bits_[0] &= ~0x00000002u;\n}\ninline void FileDescriptorProto::clear_package() {\n  package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_package();\n}\ninline const ::std::string& FileDescriptorProto::package() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.package)\n  return package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FileDescriptorProto::set_package(const ::std::string& value) {\n  set_has_package();\n  package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.package)\n}\ninline void FileDescriptorProto::set_package(const char* value) {\n  set_has_package();\n  package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.package)\n}\ninline void FileDescriptorProto::set_package(const char* value, size_t size) {\n  set_has_package();\n  package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.package)\n}\ninline ::std::string* FileDescriptorProto::mutable_package() {\n  set_has_package();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.package)\n  return package_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* FileDescriptorProto::release_package() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.package)\n  clear_has_package();\n  return package_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FileDescriptorProto::set_allocated_package(::std::string* package) {\n  if (package != NULL) {\n    set_has_package();\n  } else {\n    clear_has_package();\n  }\n  package_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), package);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.package)\n}\n\n// repeated string dependency = 3;\ninline int FileDescriptorProto::dependency_size() const {\n  return dependency_.size();\n}\ninline void FileDescriptorProto::clear_dependency() {\n  dependency_.Clear();\n}\ninline const ::std::string& FileDescriptorProto::dependency(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.dependency)\n  return dependency_.Get(index);\n}\ninline ::std::string* FileDescriptorProto::mutable_dependency(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.dependency)\n  return dependency_.Mutable(index);\n}\ninline void FileDescriptorProto::set_dependency(int index, const ::std::string& value) {\n  // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.dependency)\n  dependency_.Mutable(index)->assign(value);\n}\ninline void FileDescriptorProto::set_dependency(int index, const char* value) {\n  dependency_.Mutable(index)->assign(value);\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.dependency)\n}\ninline void FileDescriptorProto::set_dependency(int index, const char* value, size_t size) {\n  dependency_.Mutable(index)->assign(\n    reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.dependency)\n}\ninline ::std::string* FileDescriptorProto::add_dependency() {\n  // @@protoc_insertion_point(field_add_mutable:google.protobuf.FileDescriptorProto.dependency)\n  return dependency_.Add();\n}\ninline void FileDescriptorProto::add_dependency(const ::std::string& value) {\n  dependency_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.dependency)\n}\ninline void FileDescriptorProto::add_dependency(const char* value) {\n  dependency_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add_char:google.protobuf.FileDescriptorProto.dependency)\n}\ninline void FileDescriptorProto::add_dependency(const char* value, size_t size) {\n  dependency_.Add()->assign(reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_add_pointer:google.protobuf.FileDescriptorProto.dependency)\n}\ninline const ::google::protobuf::RepeatedPtrField< ::std::string>&\nFileDescriptorProto::dependency() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.dependency)\n  return dependency_;\n}\ninline ::google::protobuf::RepeatedPtrField< ::std::string>*\nFileDescriptorProto::mutable_dependency() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.dependency)\n  return &dependency_;\n}\n\n// repeated int32 public_dependency = 10;\ninline int FileDescriptorProto::public_dependency_size() const {\n  return public_dependency_.size();\n}\ninline void FileDescriptorProto::clear_public_dependency() {\n  public_dependency_.Clear();\n}\ninline ::google::protobuf::int32 FileDescriptorProto::public_dependency(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.public_dependency)\n  return public_dependency_.Get(index);\n}\ninline void FileDescriptorProto::set_public_dependency(int index, ::google::protobuf::int32 value) {\n  public_dependency_.Set(index, value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.public_dependency)\n}\ninline void FileDescriptorProto::add_public_dependency(::google::protobuf::int32 value) {\n  public_dependency_.Add(value);\n  // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.public_dependency)\n}\ninline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&\nFileDescriptorProto::public_dependency() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.public_dependency)\n  return public_dependency_;\n}\ninline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*\nFileDescriptorProto::mutable_public_dependency() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.public_dependency)\n  return &public_dependency_;\n}\n\n// repeated int32 weak_dependency = 11;\ninline int FileDescriptorProto::weak_dependency_size() const {\n  return weak_dependency_.size();\n}\ninline void FileDescriptorProto::clear_weak_dependency() {\n  weak_dependency_.Clear();\n}\ninline ::google::protobuf::int32 FileDescriptorProto::weak_dependency(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.weak_dependency)\n  return weak_dependency_.Get(index);\n}\ninline void FileDescriptorProto::set_weak_dependency(int index, ::google::protobuf::int32 value) {\n  weak_dependency_.Set(index, value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.weak_dependency)\n}\ninline void FileDescriptorProto::add_weak_dependency(::google::protobuf::int32 value) {\n  weak_dependency_.Add(value);\n  // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.weak_dependency)\n}\ninline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&\nFileDescriptorProto::weak_dependency() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.weak_dependency)\n  return weak_dependency_;\n}\ninline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*\nFileDescriptorProto::mutable_weak_dependency() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.weak_dependency)\n  return &weak_dependency_;\n}\n\n// repeated .google.protobuf.DescriptorProto message_type = 4;\ninline int FileDescriptorProto::message_type_size() const {\n  return message_type_.size();\n}\ninline void FileDescriptorProto::clear_message_type() {\n  message_type_.Clear();\n}\ninline const ::google::protobuf::DescriptorProto& FileDescriptorProto::message_type(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.message_type)\n  return message_type_.Get(index);\n}\ninline ::google::protobuf::DescriptorProto* FileDescriptorProto::mutable_message_type(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.message_type)\n  return message_type_.Mutable(index);\n}\ninline ::google::protobuf::DescriptorProto* FileDescriptorProto::add_message_type() {\n  // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.message_type)\n  return message_type_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >*\nFileDescriptorProto::mutable_message_type() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.message_type)\n  return &message_type_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >&\nFileDescriptorProto::message_type() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.message_type)\n  return message_type_;\n}\n\n// repeated .google.protobuf.EnumDescriptorProto enum_type = 5;\ninline int FileDescriptorProto::enum_type_size() const {\n  return enum_type_.size();\n}\ninline void FileDescriptorProto::clear_enum_type() {\n  enum_type_.Clear();\n}\ninline const ::google::protobuf::EnumDescriptorProto& FileDescriptorProto::enum_type(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.enum_type)\n  return enum_type_.Get(index);\n}\ninline ::google::protobuf::EnumDescriptorProto* FileDescriptorProto::mutable_enum_type(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.enum_type)\n  return enum_type_.Mutable(index);\n}\ninline ::google::protobuf::EnumDescriptorProto* FileDescriptorProto::add_enum_type() {\n  // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.enum_type)\n  return enum_type_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >*\nFileDescriptorProto::mutable_enum_type() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.enum_type)\n  return &enum_type_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >&\nFileDescriptorProto::enum_type() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.enum_type)\n  return enum_type_;\n}\n\n// repeated .google.protobuf.ServiceDescriptorProto service = 6;\ninline int FileDescriptorProto::service_size() const {\n  return service_.size();\n}\ninline void FileDescriptorProto::clear_service() {\n  service_.Clear();\n}\ninline const ::google::protobuf::ServiceDescriptorProto& FileDescriptorProto::service(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.service)\n  return service_.Get(index);\n}\ninline ::google::protobuf::ServiceDescriptorProto* FileDescriptorProto::mutable_service(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.service)\n  return service_.Mutable(index);\n}\ninline ::google::protobuf::ServiceDescriptorProto* FileDescriptorProto::add_service() {\n  // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.service)\n  return service_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto >*\nFileDescriptorProto::mutable_service() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.service)\n  return &service_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::ServiceDescriptorProto >&\nFileDescriptorProto::service() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.service)\n  return service_;\n}\n\n// repeated .google.protobuf.FieldDescriptorProto extension = 7;\ninline int FileDescriptorProto::extension_size() const {\n  return extension_.size();\n}\ninline void FileDescriptorProto::clear_extension() {\n  extension_.Clear();\n}\ninline const ::google::protobuf::FieldDescriptorProto& FileDescriptorProto::extension(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.extension)\n  return extension_.Get(index);\n}\ninline ::google::protobuf::FieldDescriptorProto* FileDescriptorProto::mutable_extension(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.extension)\n  return extension_.Mutable(index);\n}\ninline ::google::protobuf::FieldDescriptorProto* FileDescriptorProto::add_extension() {\n  // @@protoc_insertion_point(field_add:google.protobuf.FileDescriptorProto.extension)\n  return extension_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >*\nFileDescriptorProto::mutable_extension() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileDescriptorProto.extension)\n  return &extension_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >&\nFileDescriptorProto::extension() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.FileDescriptorProto.extension)\n  return extension_;\n}\n\n// optional .google.protobuf.FileOptions options = 8;\ninline bool FileDescriptorProto::has_options() const {\n  return (_has_bits_[0] & 0x00000200u) != 0;\n}\ninline void FileDescriptorProto::set_has_options() {\n  _has_bits_[0] |= 0x00000200u;\n}\ninline void FileDescriptorProto::clear_has_options() {\n  _has_bits_[0] &= ~0x00000200u;\n}\ninline void FileDescriptorProto::clear_options() {\n  if (options_ != NULL) options_->::google::protobuf::FileOptions::Clear();\n  clear_has_options();\n}\ninline const ::google::protobuf::FileOptions& FileDescriptorProto::options() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.options)\n  return options_ != NULL ? *options_ : *default_instance_->options_;\n}\ninline ::google::protobuf::FileOptions* FileDescriptorProto::mutable_options() {\n  set_has_options();\n  if (options_ == NULL) {\n    options_ = new ::google::protobuf::FileOptions;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.options)\n  return options_;\n}\ninline ::google::protobuf::FileOptions* FileDescriptorProto::release_options() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.options)\n  clear_has_options();\n  ::google::protobuf::FileOptions* temp = options_;\n  options_ = NULL;\n  return temp;\n}\ninline void FileDescriptorProto::set_allocated_options(::google::protobuf::FileOptions* options) {\n  delete options_;\n  options_ = options;\n  if (options) {\n    set_has_options();\n  } else {\n    clear_has_options();\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.options)\n}\n\n// optional .google.protobuf.SourceCodeInfo source_code_info = 9;\ninline bool FileDescriptorProto::has_source_code_info() const {\n  return (_has_bits_[0] & 0x00000400u) != 0;\n}\ninline void FileDescriptorProto::set_has_source_code_info() {\n  _has_bits_[0] |= 0x00000400u;\n}\ninline void FileDescriptorProto::clear_has_source_code_info() {\n  _has_bits_[0] &= ~0x00000400u;\n}\ninline void FileDescriptorProto::clear_source_code_info() {\n  if (source_code_info_ != NULL) source_code_info_->::google::protobuf::SourceCodeInfo::Clear();\n  clear_has_source_code_info();\n}\ninline const ::google::protobuf::SourceCodeInfo& FileDescriptorProto::source_code_info() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.source_code_info)\n  return source_code_info_ != NULL ? *source_code_info_ : *default_instance_->source_code_info_;\n}\ninline ::google::protobuf::SourceCodeInfo* FileDescriptorProto::mutable_source_code_info() {\n  set_has_source_code_info();\n  if (source_code_info_ == NULL) {\n    source_code_info_ = new ::google::protobuf::SourceCodeInfo;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.source_code_info)\n  return source_code_info_;\n}\ninline ::google::protobuf::SourceCodeInfo* FileDescriptorProto::release_source_code_info() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.source_code_info)\n  clear_has_source_code_info();\n  ::google::protobuf::SourceCodeInfo* temp = source_code_info_;\n  source_code_info_ = NULL;\n  return temp;\n}\ninline void FileDescriptorProto::set_allocated_source_code_info(::google::protobuf::SourceCodeInfo* source_code_info) {\n  delete source_code_info_;\n  source_code_info_ = source_code_info;\n  if (source_code_info) {\n    set_has_source_code_info();\n  } else {\n    clear_has_source_code_info();\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.source_code_info)\n}\n\n// optional string syntax = 12;\ninline bool FileDescriptorProto::has_syntax() const {\n  return (_has_bits_[0] & 0x00000800u) != 0;\n}\ninline void FileDescriptorProto::set_has_syntax() {\n  _has_bits_[0] |= 0x00000800u;\n}\ninline void FileDescriptorProto::clear_has_syntax() {\n  _has_bits_[0] &= ~0x00000800u;\n}\ninline void FileDescriptorProto::clear_syntax() {\n  syntax_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_syntax();\n}\ninline const ::std::string& FileDescriptorProto::syntax() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileDescriptorProto.syntax)\n  return syntax_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FileDescriptorProto::set_syntax(const ::std::string& value) {\n  set_has_syntax();\n  syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FileDescriptorProto.syntax)\n}\ninline void FileDescriptorProto::set_syntax(const char* value) {\n  set_has_syntax();\n  syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FileDescriptorProto.syntax)\n}\ninline void FileDescriptorProto::set_syntax(const char* value, size_t size) {\n  set_has_syntax();\n  syntax_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileDescriptorProto.syntax)\n}\ninline ::std::string* FileDescriptorProto::mutable_syntax() {\n  set_has_syntax();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileDescriptorProto.syntax)\n  return syntax_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* FileDescriptorProto::release_syntax() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FileDescriptorProto.syntax)\n  clear_has_syntax();\n  return syntax_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FileDescriptorProto::set_allocated_syntax(::std::string* syntax) {\n  if (syntax != NULL) {\n    set_has_syntax();\n  } else {\n    clear_has_syntax();\n  }\n  syntax_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), syntax);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileDescriptorProto.syntax)\n}\n\n// -------------------------------------------------------------------\n\n// DescriptorProto_ExtensionRange\n\n// optional int32 start = 1;\ninline bool DescriptorProto_ExtensionRange::has_start() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\ninline void DescriptorProto_ExtensionRange::set_has_start() {\n  _has_bits_[0] |= 0x00000001u;\n}\ninline void DescriptorProto_ExtensionRange::clear_has_start() {\n  _has_bits_[0] &= ~0x00000001u;\n}\ninline void DescriptorProto_ExtensionRange::clear_start() {\n  start_ = 0;\n  clear_has_start();\n}\ninline ::google::protobuf::int32 DescriptorProto_ExtensionRange::start() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.start)\n  return start_;\n}\ninline void DescriptorProto_ExtensionRange::set_start(::google::protobuf::int32 value) {\n  set_has_start();\n  start_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.start)\n}\n\n// optional int32 end = 2;\ninline bool DescriptorProto_ExtensionRange::has_end() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\ninline void DescriptorProto_ExtensionRange::set_has_end() {\n  _has_bits_[0] |= 0x00000002u;\n}\ninline void DescriptorProto_ExtensionRange::clear_has_end() {\n  _has_bits_[0] &= ~0x00000002u;\n}\ninline void DescriptorProto_ExtensionRange::clear_end() {\n  end_ = 0;\n  clear_has_end();\n}\ninline ::google::protobuf::int32 DescriptorProto_ExtensionRange::end() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ExtensionRange.end)\n  return end_;\n}\ninline void DescriptorProto_ExtensionRange::set_end(::google::protobuf::int32 value) {\n  set_has_end();\n  end_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ExtensionRange.end)\n}\n\n// -------------------------------------------------------------------\n\n// DescriptorProto_ReservedRange\n\n// optional int32 start = 1;\ninline bool DescriptorProto_ReservedRange::has_start() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\ninline void DescriptorProto_ReservedRange::set_has_start() {\n  _has_bits_[0] |= 0x00000001u;\n}\ninline void DescriptorProto_ReservedRange::clear_has_start() {\n  _has_bits_[0] &= ~0x00000001u;\n}\ninline void DescriptorProto_ReservedRange::clear_start() {\n  start_ = 0;\n  clear_has_start();\n}\ninline ::google::protobuf::int32 DescriptorProto_ReservedRange::start() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.start)\n  return start_;\n}\ninline void DescriptorProto_ReservedRange::set_start(::google::protobuf::int32 value) {\n  set_has_start();\n  start_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.start)\n}\n\n// optional int32 end = 2;\ninline bool DescriptorProto_ReservedRange::has_end() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\ninline void DescriptorProto_ReservedRange::set_has_end() {\n  _has_bits_[0] |= 0x00000002u;\n}\ninline void DescriptorProto_ReservedRange::clear_has_end() {\n  _has_bits_[0] &= ~0x00000002u;\n}\ninline void DescriptorProto_ReservedRange::clear_end() {\n  end_ = 0;\n  clear_has_end();\n}\ninline ::google::protobuf::int32 DescriptorProto_ReservedRange::end() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.ReservedRange.end)\n  return end_;\n}\ninline void DescriptorProto_ReservedRange::set_end(::google::protobuf::int32 value) {\n  set_has_end();\n  end_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.ReservedRange.end)\n}\n\n// -------------------------------------------------------------------\n\n// DescriptorProto\n\n// optional string name = 1;\ninline bool DescriptorProto::has_name() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\ninline void DescriptorProto::set_has_name() {\n  _has_bits_[0] |= 0x00000001u;\n}\ninline void DescriptorProto::clear_has_name() {\n  _has_bits_[0] &= ~0x00000001u;\n}\ninline void DescriptorProto::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_name();\n}\ninline const ::std::string& DescriptorProto::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void DescriptorProto::set_name(const ::std::string& value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.name)\n}\ninline void DescriptorProto::set_name(const char* value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.DescriptorProto.name)\n}\ninline void DescriptorProto::set_name(const char* value, size_t size) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.DescriptorProto.name)\n}\ninline ::std::string* DescriptorProto::mutable_name() {\n  set_has_name();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* DescriptorProto::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.name)\n  clear_has_name();\n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void DescriptorProto::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    set_has_name();\n  } else {\n    clear_has_name();\n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.DescriptorProto.name)\n}\n\n// repeated .google.protobuf.FieldDescriptorProto field = 2;\ninline int DescriptorProto::field_size() const {\n  return field_.size();\n}\ninline void DescriptorProto::clear_field() {\n  field_.Clear();\n}\ninline const ::google::protobuf::FieldDescriptorProto& DescriptorProto::field(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.field)\n  return field_.Get(index);\n}\ninline ::google::protobuf::FieldDescriptorProto* DescriptorProto::mutable_field(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.field)\n  return field_.Mutable(index);\n}\ninline ::google::protobuf::FieldDescriptorProto* DescriptorProto::add_field() {\n  // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.field)\n  return field_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >*\nDescriptorProto::mutable_field() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.field)\n  return &field_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >&\nDescriptorProto::field() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.field)\n  return field_;\n}\n\n// repeated .google.protobuf.FieldDescriptorProto extension = 6;\ninline int DescriptorProto::extension_size() const {\n  return extension_.size();\n}\ninline void DescriptorProto::clear_extension() {\n  extension_.Clear();\n}\ninline const ::google::protobuf::FieldDescriptorProto& DescriptorProto::extension(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.extension)\n  return extension_.Get(index);\n}\ninline ::google::protobuf::FieldDescriptorProto* DescriptorProto::mutable_extension(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.extension)\n  return extension_.Mutable(index);\n}\ninline ::google::protobuf::FieldDescriptorProto* DescriptorProto::add_extension() {\n  // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.extension)\n  return extension_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >*\nDescriptorProto::mutable_extension() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.extension)\n  return &extension_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldDescriptorProto >&\nDescriptorProto::extension() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.extension)\n  return extension_;\n}\n\n// repeated .google.protobuf.DescriptorProto nested_type = 3;\ninline int DescriptorProto::nested_type_size() const {\n  return nested_type_.size();\n}\ninline void DescriptorProto::clear_nested_type() {\n  nested_type_.Clear();\n}\ninline const ::google::protobuf::DescriptorProto& DescriptorProto::nested_type(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.nested_type)\n  return nested_type_.Get(index);\n}\ninline ::google::protobuf::DescriptorProto* DescriptorProto::mutable_nested_type(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.nested_type)\n  return nested_type_.Mutable(index);\n}\ninline ::google::protobuf::DescriptorProto* DescriptorProto::add_nested_type() {\n  // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.nested_type)\n  return nested_type_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >*\nDescriptorProto::mutable_nested_type() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.nested_type)\n  return &nested_type_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto >&\nDescriptorProto::nested_type() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.nested_type)\n  return nested_type_;\n}\n\n// repeated .google.protobuf.EnumDescriptorProto enum_type = 4;\ninline int DescriptorProto::enum_type_size() const {\n  return enum_type_.size();\n}\ninline void DescriptorProto::clear_enum_type() {\n  enum_type_.Clear();\n}\ninline const ::google::protobuf::EnumDescriptorProto& DescriptorProto::enum_type(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.enum_type)\n  return enum_type_.Get(index);\n}\ninline ::google::protobuf::EnumDescriptorProto* DescriptorProto::mutable_enum_type(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.enum_type)\n  return enum_type_.Mutable(index);\n}\ninline ::google::protobuf::EnumDescriptorProto* DescriptorProto::add_enum_type() {\n  // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.enum_type)\n  return enum_type_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >*\nDescriptorProto::mutable_enum_type() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.enum_type)\n  return &enum_type_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumDescriptorProto >&\nDescriptorProto::enum_type() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.enum_type)\n  return enum_type_;\n}\n\n// repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;\ninline int DescriptorProto::extension_range_size() const {\n  return extension_range_.size();\n}\ninline void DescriptorProto::clear_extension_range() {\n  extension_range_.Clear();\n}\ninline const ::google::protobuf::DescriptorProto_ExtensionRange& DescriptorProto::extension_range(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.extension_range)\n  return extension_range_.Get(index);\n}\ninline ::google::protobuf::DescriptorProto_ExtensionRange* DescriptorProto::mutable_extension_range(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.extension_range)\n  return extension_range_.Mutable(index);\n}\ninline ::google::protobuf::DescriptorProto_ExtensionRange* DescriptorProto::add_extension_range() {\n  // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.extension_range)\n  return extension_range_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange >*\nDescriptorProto::mutable_extension_range() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.extension_range)\n  return &extension_range_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ExtensionRange >&\nDescriptorProto::extension_range() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.extension_range)\n  return extension_range_;\n}\n\n// repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;\ninline int DescriptorProto::oneof_decl_size() const {\n  return oneof_decl_.size();\n}\ninline void DescriptorProto::clear_oneof_decl() {\n  oneof_decl_.Clear();\n}\ninline const ::google::protobuf::OneofDescriptorProto& DescriptorProto::oneof_decl(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.oneof_decl)\n  return oneof_decl_.Get(index);\n}\ninline ::google::protobuf::OneofDescriptorProto* DescriptorProto::mutable_oneof_decl(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.oneof_decl)\n  return oneof_decl_.Mutable(index);\n}\ninline ::google::protobuf::OneofDescriptorProto* DescriptorProto::add_oneof_decl() {\n  // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.oneof_decl)\n  return oneof_decl_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto >*\nDescriptorProto::mutable_oneof_decl() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.oneof_decl)\n  return &oneof_decl_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::OneofDescriptorProto >&\nDescriptorProto::oneof_decl() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.oneof_decl)\n  return oneof_decl_;\n}\n\n// optional .google.protobuf.MessageOptions options = 7;\ninline bool DescriptorProto::has_options() const {\n  return (_has_bits_[0] & 0x00000080u) != 0;\n}\ninline void DescriptorProto::set_has_options() {\n  _has_bits_[0] |= 0x00000080u;\n}\ninline void DescriptorProto::clear_has_options() {\n  _has_bits_[0] &= ~0x00000080u;\n}\ninline void DescriptorProto::clear_options() {\n  if (options_ != NULL) options_->::google::protobuf::MessageOptions::Clear();\n  clear_has_options();\n}\ninline const ::google::protobuf::MessageOptions& DescriptorProto::options() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.options)\n  return options_ != NULL ? *options_ : *default_instance_->options_;\n}\ninline ::google::protobuf::MessageOptions* DescriptorProto::mutable_options() {\n  set_has_options();\n  if (options_ == NULL) {\n    options_ = new ::google::protobuf::MessageOptions;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.options)\n  return options_;\n}\ninline ::google::protobuf::MessageOptions* DescriptorProto::release_options() {\n  // @@protoc_insertion_point(field_release:google.protobuf.DescriptorProto.options)\n  clear_has_options();\n  ::google::protobuf::MessageOptions* temp = options_;\n  options_ = NULL;\n  return temp;\n}\ninline void DescriptorProto::set_allocated_options(::google::protobuf::MessageOptions* options) {\n  delete options_;\n  options_ = options;\n  if (options) {\n    set_has_options();\n  } else {\n    clear_has_options();\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.DescriptorProto.options)\n}\n\n// repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;\ninline int DescriptorProto::reserved_range_size() const {\n  return reserved_range_.size();\n}\ninline void DescriptorProto::clear_reserved_range() {\n  reserved_range_.Clear();\n}\ninline const ::google::protobuf::DescriptorProto_ReservedRange& DescriptorProto::reserved_range(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.reserved_range)\n  return reserved_range_.Get(index);\n}\ninline ::google::protobuf::DescriptorProto_ReservedRange* DescriptorProto::mutable_reserved_range(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.reserved_range)\n  return reserved_range_.Mutable(index);\n}\ninline ::google::protobuf::DescriptorProto_ReservedRange* DescriptorProto::add_reserved_range() {\n  // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_range)\n  return reserved_range_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ReservedRange >*\nDescriptorProto::mutable_reserved_range() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.reserved_range)\n  return &reserved_range_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DescriptorProto_ReservedRange >&\nDescriptorProto::reserved_range() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.reserved_range)\n  return reserved_range_;\n}\n\n// repeated string reserved_name = 10;\ninline int DescriptorProto::reserved_name_size() const {\n  return reserved_name_.size();\n}\ninline void DescriptorProto::clear_reserved_name() {\n  reserved_name_.Clear();\n}\ninline const ::std::string& DescriptorProto::reserved_name(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DescriptorProto.reserved_name)\n  return reserved_name_.Get(index);\n}\ninline ::std::string* DescriptorProto::mutable_reserved_name(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.DescriptorProto.reserved_name)\n  return reserved_name_.Mutable(index);\n}\ninline void DescriptorProto::set_reserved_name(int index, const ::std::string& value) {\n  // @@protoc_insertion_point(field_set:google.protobuf.DescriptorProto.reserved_name)\n  reserved_name_.Mutable(index)->assign(value);\n}\ninline void DescriptorProto::set_reserved_name(int index, const char* value) {\n  reserved_name_.Mutable(index)->assign(value);\n  // @@protoc_insertion_point(field_set_char:google.protobuf.DescriptorProto.reserved_name)\n}\ninline void DescriptorProto::set_reserved_name(int index, const char* value, size_t size) {\n  reserved_name_.Mutable(index)->assign(\n    reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.DescriptorProto.reserved_name)\n}\ninline ::std::string* DescriptorProto::add_reserved_name() {\n  // @@protoc_insertion_point(field_add_mutable:google.protobuf.DescriptorProto.reserved_name)\n  return reserved_name_.Add();\n}\ninline void DescriptorProto::add_reserved_name(const ::std::string& value) {\n  reserved_name_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add:google.protobuf.DescriptorProto.reserved_name)\n}\ninline void DescriptorProto::add_reserved_name(const char* value) {\n  reserved_name_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add_char:google.protobuf.DescriptorProto.reserved_name)\n}\ninline void DescriptorProto::add_reserved_name(const char* value, size_t size) {\n  reserved_name_.Add()->assign(reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_add_pointer:google.protobuf.DescriptorProto.reserved_name)\n}\ninline const ::google::protobuf::RepeatedPtrField< ::std::string>&\nDescriptorProto::reserved_name() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.DescriptorProto.reserved_name)\n  return reserved_name_;\n}\ninline ::google::protobuf::RepeatedPtrField< ::std::string>*\nDescriptorProto::mutable_reserved_name() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.DescriptorProto.reserved_name)\n  return &reserved_name_;\n}\n\n// -------------------------------------------------------------------\n\n// FieldDescriptorProto\n\n// optional string name = 1;\ninline bool FieldDescriptorProto::has_name() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\ninline void FieldDescriptorProto::set_has_name() {\n  _has_bits_[0] |= 0x00000001u;\n}\ninline void FieldDescriptorProto::clear_has_name() {\n  _has_bits_[0] &= ~0x00000001u;\n}\ninline void FieldDescriptorProto::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_name();\n}\ninline const ::std::string& FieldDescriptorProto::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FieldDescriptorProto::set_name(const ::std::string& value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.name)\n}\ninline void FieldDescriptorProto::set_name(const char* value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.name)\n}\ninline void FieldDescriptorProto::set_name(const char* value, size_t size) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.name)\n}\ninline ::std::string* FieldDescriptorProto::mutable_name() {\n  set_has_name();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* FieldDescriptorProto::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.name)\n  clear_has_name();\n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FieldDescriptorProto::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    set_has_name();\n  } else {\n    clear_has_name();\n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.name)\n}\n\n// optional int32 number = 3;\ninline bool FieldDescriptorProto::has_number() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\ninline void FieldDescriptorProto::set_has_number() {\n  _has_bits_[0] |= 0x00000002u;\n}\ninline void FieldDescriptorProto::clear_has_number() {\n  _has_bits_[0] &= ~0x00000002u;\n}\ninline void FieldDescriptorProto::clear_number() {\n  number_ = 0;\n  clear_has_number();\n}\ninline ::google::protobuf::int32 FieldDescriptorProto::number() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.number)\n  return number_;\n}\ninline void FieldDescriptorProto::set_number(::google::protobuf::int32 value) {\n  set_has_number();\n  number_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.number)\n}\n\n// optional .google.protobuf.FieldDescriptorProto.Label label = 4;\ninline bool FieldDescriptorProto::has_label() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\ninline void FieldDescriptorProto::set_has_label() {\n  _has_bits_[0] |= 0x00000004u;\n}\ninline void FieldDescriptorProto::clear_has_label() {\n  _has_bits_[0] &= ~0x00000004u;\n}\ninline void FieldDescriptorProto::clear_label() {\n  label_ = 1;\n  clear_has_label();\n}\ninline ::google::protobuf::FieldDescriptorProto_Label FieldDescriptorProto::label() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.label)\n  return static_cast< ::google::protobuf::FieldDescriptorProto_Label >(label_);\n}\ninline void FieldDescriptorProto::set_label(::google::protobuf::FieldDescriptorProto_Label value) {\n  assert(::google::protobuf::FieldDescriptorProto_Label_IsValid(value));\n  set_has_label();\n  label_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.label)\n}\n\n// optional .google.protobuf.FieldDescriptorProto.Type type = 5;\ninline bool FieldDescriptorProto::has_type() const {\n  return (_has_bits_[0] & 0x00000008u) != 0;\n}\ninline void FieldDescriptorProto::set_has_type() {\n  _has_bits_[0] |= 0x00000008u;\n}\ninline void FieldDescriptorProto::clear_has_type() {\n  _has_bits_[0] &= ~0x00000008u;\n}\ninline void FieldDescriptorProto::clear_type() {\n  type_ = 1;\n  clear_has_type();\n}\ninline ::google::protobuf::FieldDescriptorProto_Type FieldDescriptorProto::type() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.type)\n  return static_cast< ::google::protobuf::FieldDescriptorProto_Type >(type_);\n}\ninline void FieldDescriptorProto::set_type(::google::protobuf::FieldDescriptorProto_Type value) {\n  assert(::google::protobuf::FieldDescriptorProto_Type_IsValid(value));\n  set_has_type();\n  type_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type)\n}\n\n// optional string type_name = 6;\ninline bool FieldDescriptorProto::has_type_name() const {\n  return (_has_bits_[0] & 0x00000010u) != 0;\n}\ninline void FieldDescriptorProto::set_has_type_name() {\n  _has_bits_[0] |= 0x00000010u;\n}\ninline void FieldDescriptorProto::clear_has_type_name() {\n  _has_bits_[0] &= ~0x00000010u;\n}\ninline void FieldDescriptorProto::clear_type_name() {\n  type_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_type_name();\n}\ninline const ::std::string& FieldDescriptorProto::type_name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.type_name)\n  return type_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FieldDescriptorProto::set_type_name(const ::std::string& value) {\n  set_has_type_name();\n  type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.type_name)\n}\ninline void FieldDescriptorProto::set_type_name(const char* value) {\n  set_has_type_name();\n  type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.type_name)\n}\ninline void FieldDescriptorProto::set_type_name(const char* value, size_t size) {\n  set_has_type_name();\n  type_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.type_name)\n}\ninline ::std::string* FieldDescriptorProto::mutable_type_name() {\n  set_has_type_name();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.type_name)\n  return type_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* FieldDescriptorProto::release_type_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.type_name)\n  clear_has_type_name();\n  return type_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FieldDescriptorProto::set_allocated_type_name(::std::string* type_name) {\n  if (type_name != NULL) {\n    set_has_type_name();\n  } else {\n    clear_has_type_name();\n  }\n  type_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type_name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.type_name)\n}\n\n// optional string extendee = 2;\ninline bool FieldDescriptorProto::has_extendee() const {\n  return (_has_bits_[0] & 0x00000020u) != 0;\n}\ninline void FieldDescriptorProto::set_has_extendee() {\n  _has_bits_[0] |= 0x00000020u;\n}\ninline void FieldDescriptorProto::clear_has_extendee() {\n  _has_bits_[0] &= ~0x00000020u;\n}\ninline void FieldDescriptorProto::clear_extendee() {\n  extendee_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_extendee();\n}\ninline const ::std::string& FieldDescriptorProto::extendee() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.extendee)\n  return extendee_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FieldDescriptorProto::set_extendee(const ::std::string& value) {\n  set_has_extendee();\n  extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.extendee)\n}\ninline void FieldDescriptorProto::set_extendee(const char* value) {\n  set_has_extendee();\n  extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.extendee)\n}\ninline void FieldDescriptorProto::set_extendee(const char* value, size_t size) {\n  set_has_extendee();\n  extendee_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.extendee)\n}\ninline ::std::string* FieldDescriptorProto::mutable_extendee() {\n  set_has_extendee();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.extendee)\n  return extendee_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* FieldDescriptorProto::release_extendee() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.extendee)\n  clear_has_extendee();\n  return extendee_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FieldDescriptorProto::set_allocated_extendee(::std::string* extendee) {\n  if (extendee != NULL) {\n    set_has_extendee();\n  } else {\n    clear_has_extendee();\n  }\n  extendee_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), extendee);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.extendee)\n}\n\n// optional string default_value = 7;\ninline bool FieldDescriptorProto::has_default_value() const {\n  return (_has_bits_[0] & 0x00000040u) != 0;\n}\ninline void FieldDescriptorProto::set_has_default_value() {\n  _has_bits_[0] |= 0x00000040u;\n}\ninline void FieldDescriptorProto::clear_has_default_value() {\n  _has_bits_[0] &= ~0x00000040u;\n}\ninline void FieldDescriptorProto::clear_default_value() {\n  default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_default_value();\n}\ninline const ::std::string& FieldDescriptorProto::default_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.default_value)\n  return default_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FieldDescriptorProto::set_default_value(const ::std::string& value) {\n  set_has_default_value();\n  default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.default_value)\n}\ninline void FieldDescriptorProto::set_default_value(const char* value) {\n  set_has_default_value();\n  default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.default_value)\n}\ninline void FieldDescriptorProto::set_default_value(const char* value, size_t size) {\n  set_has_default_value();\n  default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.default_value)\n}\ninline ::std::string* FieldDescriptorProto::mutable_default_value() {\n  set_has_default_value();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.default_value)\n  return default_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* FieldDescriptorProto::release_default_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.default_value)\n  clear_has_default_value();\n  return default_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FieldDescriptorProto::set_allocated_default_value(::std::string* default_value) {\n  if (default_value != NULL) {\n    set_has_default_value();\n  } else {\n    clear_has_default_value();\n  }\n  default_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), default_value);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.default_value)\n}\n\n// optional int32 oneof_index = 9;\ninline bool FieldDescriptorProto::has_oneof_index() const {\n  return (_has_bits_[0] & 0x00000080u) != 0;\n}\ninline void FieldDescriptorProto::set_has_oneof_index() {\n  _has_bits_[0] |= 0x00000080u;\n}\ninline void FieldDescriptorProto::clear_has_oneof_index() {\n  _has_bits_[0] &= ~0x00000080u;\n}\ninline void FieldDescriptorProto::clear_oneof_index() {\n  oneof_index_ = 0;\n  clear_has_oneof_index();\n}\ninline ::google::protobuf::int32 FieldDescriptorProto::oneof_index() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.oneof_index)\n  return oneof_index_;\n}\ninline void FieldDescriptorProto::set_oneof_index(::google::protobuf::int32 value) {\n  set_has_oneof_index();\n  oneof_index_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.oneof_index)\n}\n\n// optional string json_name = 10;\ninline bool FieldDescriptorProto::has_json_name() const {\n  return (_has_bits_[0] & 0x00000100u) != 0;\n}\ninline void FieldDescriptorProto::set_has_json_name() {\n  _has_bits_[0] |= 0x00000100u;\n}\ninline void FieldDescriptorProto::clear_has_json_name() {\n  _has_bits_[0] &= ~0x00000100u;\n}\ninline void FieldDescriptorProto::clear_json_name() {\n  json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_json_name();\n}\ninline const ::std::string& FieldDescriptorProto::json_name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.json_name)\n  return json_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FieldDescriptorProto::set_json_name(const ::std::string& value) {\n  set_has_json_name();\n  json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldDescriptorProto.json_name)\n}\ninline void FieldDescriptorProto::set_json_name(const char* value) {\n  set_has_json_name();\n  json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FieldDescriptorProto.json_name)\n}\ninline void FieldDescriptorProto::set_json_name(const char* value, size_t size) {\n  set_has_json_name();\n  json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldDescriptorProto.json_name)\n}\ninline ::std::string* FieldDescriptorProto::mutable_json_name() {\n  set_has_json_name();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.json_name)\n  return json_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* FieldDescriptorProto::release_json_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.json_name)\n  clear_has_json_name();\n  return json_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FieldDescriptorProto::set_allocated_json_name(::std::string* json_name) {\n  if (json_name != NULL) {\n    set_has_json_name();\n  } else {\n    clear_has_json_name();\n  }\n  json_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), json_name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.json_name)\n}\n\n// optional .google.protobuf.FieldOptions options = 8;\ninline bool FieldDescriptorProto::has_options() const {\n  return (_has_bits_[0] & 0x00000200u) != 0;\n}\ninline void FieldDescriptorProto::set_has_options() {\n  _has_bits_[0] |= 0x00000200u;\n}\ninline void FieldDescriptorProto::clear_has_options() {\n  _has_bits_[0] &= ~0x00000200u;\n}\ninline void FieldDescriptorProto::clear_options() {\n  if (options_ != NULL) options_->::google::protobuf::FieldOptions::Clear();\n  clear_has_options();\n}\ninline const ::google::protobuf::FieldOptions& FieldDescriptorProto::options() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldDescriptorProto.options)\n  return options_ != NULL ? *options_ : *default_instance_->options_;\n}\ninline ::google::protobuf::FieldOptions* FieldDescriptorProto::mutable_options() {\n  set_has_options();\n  if (options_ == NULL) {\n    options_ = new ::google::protobuf::FieldOptions;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FieldDescriptorProto.options)\n  return options_;\n}\ninline ::google::protobuf::FieldOptions* FieldDescriptorProto::release_options() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FieldDescriptorProto.options)\n  clear_has_options();\n  ::google::protobuf::FieldOptions* temp = options_;\n  options_ = NULL;\n  return temp;\n}\ninline void FieldDescriptorProto::set_allocated_options(::google::protobuf::FieldOptions* options) {\n  delete options_;\n  options_ = options;\n  if (options) {\n    set_has_options();\n  } else {\n    clear_has_options();\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FieldDescriptorProto.options)\n}\n\n// -------------------------------------------------------------------\n\n// OneofDescriptorProto\n\n// optional string name = 1;\ninline bool OneofDescriptorProto::has_name() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\ninline void OneofDescriptorProto::set_has_name() {\n  _has_bits_[0] |= 0x00000001u;\n}\ninline void OneofDescriptorProto::clear_has_name() {\n  _has_bits_[0] &= ~0x00000001u;\n}\ninline void OneofDescriptorProto::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_name();\n}\ninline const ::std::string& OneofDescriptorProto::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void OneofDescriptorProto::set_name(const ::std::string& value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.OneofDescriptorProto.name)\n}\ninline void OneofDescriptorProto::set_name(const char* value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.OneofDescriptorProto.name)\n}\ninline void OneofDescriptorProto::set_name(const char* value, size_t size) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.OneofDescriptorProto.name)\n}\ninline ::std::string* OneofDescriptorProto::mutable_name() {\n  set_has_name();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.OneofDescriptorProto.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* OneofDescriptorProto::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.OneofDescriptorProto.name)\n  clear_has_name();\n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void OneofDescriptorProto::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    set_has_name();\n  } else {\n    clear_has_name();\n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.OneofDescriptorProto.name)\n}\n\n// optional .google.protobuf.OneofOptions options = 2;\ninline bool OneofDescriptorProto::has_options() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\ninline void OneofDescriptorProto::set_has_options() {\n  _has_bits_[0] |= 0x00000002u;\n}\ninline void OneofDescriptorProto::clear_has_options() {\n  _has_bits_[0] &= ~0x00000002u;\n}\ninline void OneofDescriptorProto::clear_options() {\n  if (options_ != NULL) options_->::google::protobuf::OneofOptions::Clear();\n  clear_has_options();\n}\ninline const ::google::protobuf::OneofOptions& OneofDescriptorProto::options() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.OneofDescriptorProto.options)\n  return options_ != NULL ? *options_ : *default_instance_->options_;\n}\ninline ::google::protobuf::OneofOptions* OneofDescriptorProto::mutable_options() {\n  set_has_options();\n  if (options_ == NULL) {\n    options_ = new ::google::protobuf::OneofOptions;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.OneofDescriptorProto.options)\n  return options_;\n}\ninline ::google::protobuf::OneofOptions* OneofDescriptorProto::release_options() {\n  // @@protoc_insertion_point(field_release:google.protobuf.OneofDescriptorProto.options)\n  clear_has_options();\n  ::google::protobuf::OneofOptions* temp = options_;\n  options_ = NULL;\n  return temp;\n}\ninline void OneofDescriptorProto::set_allocated_options(::google::protobuf::OneofOptions* options) {\n  delete options_;\n  options_ = options;\n  if (options) {\n    set_has_options();\n  } else {\n    clear_has_options();\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.OneofDescriptorProto.options)\n}\n\n// -------------------------------------------------------------------\n\n// EnumDescriptorProto\n\n// optional string name = 1;\ninline bool EnumDescriptorProto::has_name() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\ninline void EnumDescriptorProto::set_has_name() {\n  _has_bits_[0] |= 0x00000001u;\n}\ninline void EnumDescriptorProto::clear_has_name() {\n  _has_bits_[0] &= ~0x00000001u;\n}\ninline void EnumDescriptorProto::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_name();\n}\ninline const ::std::string& EnumDescriptorProto::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void EnumDescriptorProto::set_name(const ::std::string& value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.EnumDescriptorProto.name)\n}\ninline void EnumDescriptorProto::set_name(const char* value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.EnumDescriptorProto.name)\n}\ninline void EnumDescriptorProto::set_name(const char* value, size_t size) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumDescriptorProto.name)\n}\ninline ::std::string* EnumDescriptorProto::mutable_name() {\n  set_has_name();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* EnumDescriptorProto::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.EnumDescriptorProto.name)\n  clear_has_name();\n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void EnumDescriptorProto::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    set_has_name();\n  } else {\n    clear_has_name();\n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumDescriptorProto.name)\n}\n\n// repeated .google.protobuf.EnumValueDescriptorProto value = 2;\ninline int EnumDescriptorProto::value_size() const {\n  return value_.size();\n}\ninline void EnumDescriptorProto::clear_value() {\n  value_.Clear();\n}\ninline const ::google::protobuf::EnumValueDescriptorProto& EnumDescriptorProto::value(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.value)\n  return value_.Get(index);\n}\ninline ::google::protobuf::EnumValueDescriptorProto* EnumDescriptorProto::mutable_value(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.value)\n  return value_.Mutable(index);\n}\ninline ::google::protobuf::EnumValueDescriptorProto* EnumDescriptorProto::add_value() {\n  // @@protoc_insertion_point(field_add:google.protobuf.EnumDescriptorProto.value)\n  return value_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >*\nEnumDescriptorProto::mutable_value() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumDescriptorProto.value)\n  return &value_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValueDescriptorProto >&\nEnumDescriptorProto::value() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.EnumDescriptorProto.value)\n  return value_;\n}\n\n// optional .google.protobuf.EnumOptions options = 3;\ninline bool EnumDescriptorProto::has_options() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\ninline void EnumDescriptorProto::set_has_options() {\n  _has_bits_[0] |= 0x00000004u;\n}\ninline void EnumDescriptorProto::clear_has_options() {\n  _has_bits_[0] &= ~0x00000004u;\n}\ninline void EnumDescriptorProto::clear_options() {\n  if (options_ != NULL) options_->::google::protobuf::EnumOptions::Clear();\n  clear_has_options();\n}\ninline const ::google::protobuf::EnumOptions& EnumDescriptorProto::options() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumDescriptorProto.options)\n  return options_ != NULL ? *options_ : *default_instance_->options_;\n}\ninline ::google::protobuf::EnumOptions* EnumDescriptorProto::mutable_options() {\n  set_has_options();\n  if (options_ == NULL) {\n    options_ = new ::google::protobuf::EnumOptions;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.EnumDescriptorProto.options)\n  return options_;\n}\ninline ::google::protobuf::EnumOptions* EnumDescriptorProto::release_options() {\n  // @@protoc_insertion_point(field_release:google.protobuf.EnumDescriptorProto.options)\n  clear_has_options();\n  ::google::protobuf::EnumOptions* temp = options_;\n  options_ = NULL;\n  return temp;\n}\ninline void EnumDescriptorProto::set_allocated_options(::google::protobuf::EnumOptions* options) {\n  delete options_;\n  options_ = options;\n  if (options) {\n    set_has_options();\n  } else {\n    clear_has_options();\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumDescriptorProto.options)\n}\n\n// -------------------------------------------------------------------\n\n// EnumValueDescriptorProto\n\n// optional string name = 1;\ninline bool EnumValueDescriptorProto::has_name() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\ninline void EnumValueDescriptorProto::set_has_name() {\n  _has_bits_[0] |= 0x00000001u;\n}\ninline void EnumValueDescriptorProto::clear_has_name() {\n  _has_bits_[0] &= ~0x00000001u;\n}\ninline void EnumValueDescriptorProto::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_name();\n}\ninline const ::std::string& EnumValueDescriptorProto::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void EnumValueDescriptorProto::set_name(const ::std::string& value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.name)\n}\ninline void EnumValueDescriptorProto::set_name(const char* value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.EnumValueDescriptorProto.name)\n}\ninline void EnumValueDescriptorProto::set_name(const char* value, size_t size) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumValueDescriptorProto.name)\n}\ninline ::std::string* EnumValueDescriptorProto::mutable_name() {\n  set_has_name();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueDescriptorProto.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* EnumValueDescriptorProto::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.EnumValueDescriptorProto.name)\n  clear_has_name();\n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void EnumValueDescriptorProto::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    set_has_name();\n  } else {\n    clear_has_name();\n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValueDescriptorProto.name)\n}\n\n// optional int32 number = 2;\ninline bool EnumValueDescriptorProto::has_number() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\ninline void EnumValueDescriptorProto::set_has_number() {\n  _has_bits_[0] |= 0x00000002u;\n}\ninline void EnumValueDescriptorProto::clear_has_number() {\n  _has_bits_[0] &= ~0x00000002u;\n}\ninline void EnumValueDescriptorProto::clear_number() {\n  number_ = 0;\n  clear_has_number();\n}\ninline ::google::protobuf::int32 EnumValueDescriptorProto::number() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.number)\n  return number_;\n}\ninline void EnumValueDescriptorProto::set_number(::google::protobuf::int32 value) {\n  set_has_number();\n  number_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.EnumValueDescriptorProto.number)\n}\n\n// optional .google.protobuf.EnumValueOptions options = 3;\ninline bool EnumValueDescriptorProto::has_options() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\ninline void EnumValueDescriptorProto::set_has_options() {\n  _has_bits_[0] |= 0x00000004u;\n}\ninline void EnumValueDescriptorProto::clear_has_options() {\n  _has_bits_[0] &= ~0x00000004u;\n}\ninline void EnumValueDescriptorProto::clear_options() {\n  if (options_ != NULL) options_->::google::protobuf::EnumValueOptions::Clear();\n  clear_has_options();\n}\ninline const ::google::protobuf::EnumValueOptions& EnumValueDescriptorProto::options() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumValueDescriptorProto.options)\n  return options_ != NULL ? *options_ : *default_instance_->options_;\n}\ninline ::google::protobuf::EnumValueOptions* EnumValueDescriptorProto::mutable_options() {\n  set_has_options();\n  if (options_ == NULL) {\n    options_ = new ::google::protobuf::EnumValueOptions;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueDescriptorProto.options)\n  return options_;\n}\ninline ::google::protobuf::EnumValueOptions* EnumValueDescriptorProto::release_options() {\n  // @@protoc_insertion_point(field_release:google.protobuf.EnumValueDescriptorProto.options)\n  clear_has_options();\n  ::google::protobuf::EnumValueOptions* temp = options_;\n  options_ = NULL;\n  return temp;\n}\ninline void EnumValueDescriptorProto::set_allocated_options(::google::protobuf::EnumValueOptions* options) {\n  delete options_;\n  options_ = options;\n  if (options) {\n    set_has_options();\n  } else {\n    clear_has_options();\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValueDescriptorProto.options)\n}\n\n// -------------------------------------------------------------------\n\n// ServiceDescriptorProto\n\n// optional string name = 1;\ninline bool ServiceDescriptorProto::has_name() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\ninline void ServiceDescriptorProto::set_has_name() {\n  _has_bits_[0] |= 0x00000001u;\n}\ninline void ServiceDescriptorProto::clear_has_name() {\n  _has_bits_[0] &= ~0x00000001u;\n}\ninline void ServiceDescriptorProto::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_name();\n}\ninline const ::std::string& ServiceDescriptorProto::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void ServiceDescriptorProto::set_name(const ::std::string& value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.ServiceDescriptorProto.name)\n}\ninline void ServiceDescriptorProto::set_name(const char* value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.ServiceDescriptorProto.name)\n}\ninline void ServiceDescriptorProto::set_name(const char* value, size_t size) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.ServiceDescriptorProto.name)\n}\ninline ::std::string* ServiceDescriptorProto::mutable_name() {\n  set_has_name();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* ServiceDescriptorProto::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.ServiceDescriptorProto.name)\n  clear_has_name();\n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void ServiceDescriptorProto::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    set_has_name();\n  } else {\n    clear_has_name();\n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.ServiceDescriptorProto.name)\n}\n\n// repeated .google.protobuf.MethodDescriptorProto method = 2;\ninline int ServiceDescriptorProto::method_size() const {\n  return method_.size();\n}\ninline void ServiceDescriptorProto::clear_method() {\n  method_.Clear();\n}\ninline const ::google::protobuf::MethodDescriptorProto& ServiceDescriptorProto::method(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.method)\n  return method_.Get(index);\n}\ninline ::google::protobuf::MethodDescriptorProto* ServiceDescriptorProto::mutable_method(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.method)\n  return method_.Mutable(index);\n}\ninline ::google::protobuf::MethodDescriptorProto* ServiceDescriptorProto::add_method() {\n  // @@protoc_insertion_point(field_add:google.protobuf.ServiceDescriptorProto.method)\n  return method_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >*\nServiceDescriptorProto::mutable_method() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.ServiceDescriptorProto.method)\n  return &method_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::MethodDescriptorProto >&\nServiceDescriptorProto::method() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.ServiceDescriptorProto.method)\n  return method_;\n}\n\n// optional .google.protobuf.ServiceOptions options = 3;\ninline bool ServiceDescriptorProto::has_options() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\ninline void ServiceDescriptorProto::set_has_options() {\n  _has_bits_[0] |= 0x00000004u;\n}\ninline void ServiceDescriptorProto::clear_has_options() {\n  _has_bits_[0] &= ~0x00000004u;\n}\ninline void ServiceDescriptorProto::clear_options() {\n  if (options_ != NULL) options_->::google::protobuf::ServiceOptions::Clear();\n  clear_has_options();\n}\ninline const ::google::protobuf::ServiceOptions& ServiceDescriptorProto::options() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.ServiceDescriptorProto.options)\n  return options_ != NULL ? *options_ : *default_instance_->options_;\n}\ninline ::google::protobuf::ServiceOptions* ServiceDescriptorProto::mutable_options() {\n  set_has_options();\n  if (options_ == NULL) {\n    options_ = new ::google::protobuf::ServiceOptions;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceDescriptorProto.options)\n  return options_;\n}\ninline ::google::protobuf::ServiceOptions* ServiceDescriptorProto::release_options() {\n  // @@protoc_insertion_point(field_release:google.protobuf.ServiceDescriptorProto.options)\n  clear_has_options();\n  ::google::protobuf::ServiceOptions* temp = options_;\n  options_ = NULL;\n  return temp;\n}\ninline void ServiceDescriptorProto::set_allocated_options(::google::protobuf::ServiceOptions* options) {\n  delete options_;\n  options_ = options;\n  if (options) {\n    set_has_options();\n  } else {\n    clear_has_options();\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.ServiceDescriptorProto.options)\n}\n\n// -------------------------------------------------------------------\n\n// MethodDescriptorProto\n\n// optional string name = 1;\ninline bool MethodDescriptorProto::has_name() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\ninline void MethodDescriptorProto::set_has_name() {\n  _has_bits_[0] |= 0x00000001u;\n}\ninline void MethodDescriptorProto::clear_has_name() {\n  _has_bits_[0] &= ~0x00000001u;\n}\ninline void MethodDescriptorProto::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_name();\n}\ninline const ::std::string& MethodDescriptorProto::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void MethodDescriptorProto::set_name(const ::std::string& value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.name)\n}\ninline void MethodDescriptorProto::set_name(const char* value) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.name)\n}\ninline void MethodDescriptorProto::set_name(const char* value, size_t size) {\n  set_has_name();\n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.name)\n}\ninline ::std::string* MethodDescriptorProto::mutable_name() {\n  set_has_name();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* MethodDescriptorProto::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.name)\n  clear_has_name();\n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void MethodDescriptorProto::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    set_has_name();\n  } else {\n    clear_has_name();\n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.name)\n}\n\n// optional string input_type = 2;\ninline bool MethodDescriptorProto::has_input_type() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\ninline void MethodDescriptorProto::set_has_input_type() {\n  _has_bits_[0] |= 0x00000002u;\n}\ninline void MethodDescriptorProto::clear_has_input_type() {\n  _has_bits_[0] &= ~0x00000002u;\n}\ninline void MethodDescriptorProto::clear_input_type() {\n  input_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_input_type();\n}\ninline const ::std::string& MethodDescriptorProto::input_type() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.input_type)\n  return input_type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void MethodDescriptorProto::set_input_type(const ::std::string& value) {\n  set_has_input_type();\n  input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.input_type)\n}\ninline void MethodDescriptorProto::set_input_type(const char* value) {\n  set_has_input_type();\n  input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.input_type)\n}\ninline void MethodDescriptorProto::set_input_type(const char* value, size_t size) {\n  set_has_input_type();\n  input_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.input_type)\n}\ninline ::std::string* MethodDescriptorProto::mutable_input_type() {\n  set_has_input_type();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.input_type)\n  return input_type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* MethodDescriptorProto::release_input_type() {\n  // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.input_type)\n  clear_has_input_type();\n  return input_type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void MethodDescriptorProto::set_allocated_input_type(::std::string* input_type) {\n  if (input_type != NULL) {\n    set_has_input_type();\n  } else {\n    clear_has_input_type();\n  }\n  input_type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), input_type);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.input_type)\n}\n\n// optional string output_type = 3;\ninline bool MethodDescriptorProto::has_output_type() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\ninline void MethodDescriptorProto::set_has_output_type() {\n  _has_bits_[0] |= 0x00000004u;\n}\ninline void MethodDescriptorProto::clear_has_output_type() {\n  _has_bits_[0] &= ~0x00000004u;\n}\ninline void MethodDescriptorProto::clear_output_type() {\n  output_type_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_output_type();\n}\ninline const ::std::string& MethodDescriptorProto::output_type() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.output_type)\n  return output_type_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void MethodDescriptorProto::set_output_type(const ::std::string& value) {\n  set_has_output_type();\n  output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.output_type)\n}\ninline void MethodDescriptorProto::set_output_type(const char* value) {\n  set_has_output_type();\n  output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.MethodDescriptorProto.output_type)\n}\ninline void MethodDescriptorProto::set_output_type(const char* value, size_t size) {\n  set_has_output_type();\n  output_type_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.MethodDescriptorProto.output_type)\n}\ninline ::std::string* MethodDescriptorProto::mutable_output_type() {\n  set_has_output_type();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.output_type)\n  return output_type_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* MethodDescriptorProto::release_output_type() {\n  // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.output_type)\n  clear_has_output_type();\n  return output_type_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void MethodDescriptorProto::set_allocated_output_type(::std::string* output_type) {\n  if (output_type != NULL) {\n    set_has_output_type();\n  } else {\n    clear_has_output_type();\n  }\n  output_type_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), output_type);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.output_type)\n}\n\n// optional .google.protobuf.MethodOptions options = 4;\ninline bool MethodDescriptorProto::has_options() const {\n  return (_has_bits_[0] & 0x00000008u) != 0;\n}\ninline void MethodDescriptorProto::set_has_options() {\n  _has_bits_[0] |= 0x00000008u;\n}\ninline void MethodDescriptorProto::clear_has_options() {\n  _has_bits_[0] &= ~0x00000008u;\n}\ninline void MethodDescriptorProto::clear_options() {\n  if (options_ != NULL) options_->::google::protobuf::MethodOptions::Clear();\n  clear_has_options();\n}\ninline const ::google::protobuf::MethodOptions& MethodDescriptorProto::options() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.options)\n  return options_ != NULL ? *options_ : *default_instance_->options_;\n}\ninline ::google::protobuf::MethodOptions* MethodDescriptorProto::mutable_options() {\n  set_has_options();\n  if (options_ == NULL) {\n    options_ = new ::google::protobuf::MethodOptions;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.MethodDescriptorProto.options)\n  return options_;\n}\ninline ::google::protobuf::MethodOptions* MethodDescriptorProto::release_options() {\n  // @@protoc_insertion_point(field_release:google.protobuf.MethodDescriptorProto.options)\n  clear_has_options();\n  ::google::protobuf::MethodOptions* temp = options_;\n  options_ = NULL;\n  return temp;\n}\ninline void MethodDescriptorProto::set_allocated_options(::google::protobuf::MethodOptions* options) {\n  delete options_;\n  options_ = options;\n  if (options) {\n    set_has_options();\n  } else {\n    clear_has_options();\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.MethodDescriptorProto.options)\n}\n\n// optional bool client_streaming = 5 [default = false];\ninline bool MethodDescriptorProto::has_client_streaming() const {\n  return (_has_bits_[0] & 0x00000010u) != 0;\n}\ninline void MethodDescriptorProto::set_has_client_streaming() {\n  _has_bits_[0] |= 0x00000010u;\n}\ninline void MethodDescriptorProto::clear_has_client_streaming() {\n  _has_bits_[0] &= ~0x00000010u;\n}\ninline void MethodDescriptorProto::clear_client_streaming() {\n  client_streaming_ = false;\n  clear_has_client_streaming();\n}\ninline bool MethodDescriptorProto::client_streaming() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.client_streaming)\n  return client_streaming_;\n}\ninline void MethodDescriptorProto::set_client_streaming(bool value) {\n  set_has_client_streaming();\n  client_streaming_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.client_streaming)\n}\n\n// optional bool server_streaming = 6 [default = false];\ninline bool MethodDescriptorProto::has_server_streaming() const {\n  return (_has_bits_[0] & 0x00000020u) != 0;\n}\ninline void MethodDescriptorProto::set_has_server_streaming() {\n  _has_bits_[0] |= 0x00000020u;\n}\ninline void MethodDescriptorProto::clear_has_server_streaming() {\n  _has_bits_[0] &= ~0x00000020u;\n}\ninline void MethodDescriptorProto::clear_server_streaming() {\n  server_streaming_ = false;\n  clear_has_server_streaming();\n}\ninline bool MethodDescriptorProto::server_streaming() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MethodDescriptorProto.server_streaming)\n  return server_streaming_;\n}\ninline void MethodDescriptorProto::set_server_streaming(bool value) {\n  set_has_server_streaming();\n  server_streaming_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.MethodDescriptorProto.server_streaming)\n}\n\n// -------------------------------------------------------------------\n\n// FileOptions\n\n// optional string java_package = 1;\ninline bool FileOptions::has_java_package() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\ninline void FileOptions::set_has_java_package() {\n  _has_bits_[0] |= 0x00000001u;\n}\ninline void FileOptions::clear_has_java_package() {\n  _has_bits_[0] &= ~0x00000001u;\n}\ninline void FileOptions::clear_java_package() {\n  java_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_java_package();\n}\ninline const ::std::string& FileOptions::java_package() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_package)\n  return java_package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FileOptions::set_java_package(const ::std::string& value) {\n  set_has_java_package();\n  java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_package)\n}\ninline void FileOptions::set_java_package(const char* value) {\n  set_has_java_package();\n  java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.java_package)\n}\ninline void FileOptions::set_java_package(const char* value, size_t size) {\n  set_has_java_package();\n  java_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.java_package)\n}\ninline ::std::string* FileOptions::mutable_java_package() {\n  set_has_java_package();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.java_package)\n  return java_package_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* FileOptions::release_java_package() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.java_package)\n  clear_has_java_package();\n  return java_package_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FileOptions::set_allocated_java_package(::std::string* java_package) {\n  if (java_package != NULL) {\n    set_has_java_package();\n  } else {\n    clear_has_java_package();\n  }\n  java_package_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), java_package);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.java_package)\n}\n\n// optional string java_outer_classname = 8;\ninline bool FileOptions::has_java_outer_classname() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\ninline void FileOptions::set_has_java_outer_classname() {\n  _has_bits_[0] |= 0x00000002u;\n}\ninline void FileOptions::clear_has_java_outer_classname() {\n  _has_bits_[0] &= ~0x00000002u;\n}\ninline void FileOptions::clear_java_outer_classname() {\n  java_outer_classname_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_java_outer_classname();\n}\ninline const ::std::string& FileOptions::java_outer_classname() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_outer_classname)\n  return java_outer_classname_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FileOptions::set_java_outer_classname(const ::std::string& value) {\n  set_has_java_outer_classname();\n  java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_outer_classname)\n}\ninline void FileOptions::set_java_outer_classname(const char* value) {\n  set_has_java_outer_classname();\n  java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.java_outer_classname)\n}\ninline void FileOptions::set_java_outer_classname(const char* value, size_t size) {\n  set_has_java_outer_classname();\n  java_outer_classname_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.java_outer_classname)\n}\ninline ::std::string* FileOptions::mutable_java_outer_classname() {\n  set_has_java_outer_classname();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.java_outer_classname)\n  return java_outer_classname_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* FileOptions::release_java_outer_classname() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.java_outer_classname)\n  clear_has_java_outer_classname();\n  return java_outer_classname_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FileOptions::set_allocated_java_outer_classname(::std::string* java_outer_classname) {\n  if (java_outer_classname != NULL) {\n    set_has_java_outer_classname();\n  } else {\n    clear_has_java_outer_classname();\n  }\n  java_outer_classname_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), java_outer_classname);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.java_outer_classname)\n}\n\n// optional bool java_multiple_files = 10 [default = false];\ninline bool FileOptions::has_java_multiple_files() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\ninline void FileOptions::set_has_java_multiple_files() {\n  _has_bits_[0] |= 0x00000004u;\n}\ninline void FileOptions::clear_has_java_multiple_files() {\n  _has_bits_[0] &= ~0x00000004u;\n}\ninline void FileOptions::clear_java_multiple_files() {\n  java_multiple_files_ = false;\n  clear_has_java_multiple_files();\n}\ninline bool FileOptions::java_multiple_files() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_multiple_files)\n  return java_multiple_files_;\n}\ninline void FileOptions::set_java_multiple_files(bool value) {\n  set_has_java_multiple_files();\n  java_multiple_files_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_multiple_files)\n}\n\n// optional bool java_generate_equals_and_hash = 20 [default = false];\ninline bool FileOptions::has_java_generate_equals_and_hash() const {\n  return (_has_bits_[0] & 0x00000008u) != 0;\n}\ninline void FileOptions::set_has_java_generate_equals_and_hash() {\n  _has_bits_[0] |= 0x00000008u;\n}\ninline void FileOptions::clear_has_java_generate_equals_and_hash() {\n  _has_bits_[0] &= ~0x00000008u;\n}\ninline void FileOptions::clear_java_generate_equals_and_hash() {\n  java_generate_equals_and_hash_ = false;\n  clear_has_java_generate_equals_and_hash();\n}\ninline bool FileOptions::java_generate_equals_and_hash() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_generate_equals_and_hash)\n  return java_generate_equals_and_hash_;\n}\ninline void FileOptions::set_java_generate_equals_and_hash(bool value) {\n  set_has_java_generate_equals_and_hash();\n  java_generate_equals_and_hash_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_generate_equals_and_hash)\n}\n\n// optional bool java_string_check_utf8 = 27 [default = false];\ninline bool FileOptions::has_java_string_check_utf8() const {\n  return (_has_bits_[0] & 0x00000010u) != 0;\n}\ninline void FileOptions::set_has_java_string_check_utf8() {\n  _has_bits_[0] |= 0x00000010u;\n}\ninline void FileOptions::clear_has_java_string_check_utf8() {\n  _has_bits_[0] &= ~0x00000010u;\n}\ninline void FileOptions::clear_java_string_check_utf8() {\n  java_string_check_utf8_ = false;\n  clear_has_java_string_check_utf8();\n}\ninline bool FileOptions::java_string_check_utf8() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_string_check_utf8)\n  return java_string_check_utf8_;\n}\ninline void FileOptions::set_java_string_check_utf8(bool value) {\n  set_has_java_string_check_utf8();\n  java_string_check_utf8_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_string_check_utf8)\n}\n\n// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];\ninline bool FileOptions::has_optimize_for() const {\n  return (_has_bits_[0] & 0x00000020u) != 0;\n}\ninline void FileOptions::set_has_optimize_for() {\n  _has_bits_[0] |= 0x00000020u;\n}\ninline void FileOptions::clear_has_optimize_for() {\n  _has_bits_[0] &= ~0x00000020u;\n}\ninline void FileOptions::clear_optimize_for() {\n  optimize_for_ = 1;\n  clear_has_optimize_for();\n}\ninline ::google::protobuf::FileOptions_OptimizeMode FileOptions::optimize_for() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.optimize_for)\n  return static_cast< ::google::protobuf::FileOptions_OptimizeMode >(optimize_for_);\n}\ninline void FileOptions::set_optimize_for(::google::protobuf::FileOptions_OptimizeMode value) {\n  assert(::google::protobuf::FileOptions_OptimizeMode_IsValid(value));\n  set_has_optimize_for();\n  optimize_for_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.optimize_for)\n}\n\n// optional string go_package = 11;\ninline bool FileOptions::has_go_package() const {\n  return (_has_bits_[0] & 0x00000040u) != 0;\n}\ninline void FileOptions::set_has_go_package() {\n  _has_bits_[0] |= 0x00000040u;\n}\ninline void FileOptions::clear_has_go_package() {\n  _has_bits_[0] &= ~0x00000040u;\n}\ninline void FileOptions::clear_go_package() {\n  go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_go_package();\n}\ninline const ::std::string& FileOptions::go_package() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.go_package)\n  return go_package_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FileOptions::set_go_package(const ::std::string& value) {\n  set_has_go_package();\n  go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.go_package)\n}\ninline void FileOptions::set_go_package(const char* value) {\n  set_has_go_package();\n  go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.go_package)\n}\ninline void FileOptions::set_go_package(const char* value, size_t size) {\n  set_has_go_package();\n  go_package_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.go_package)\n}\ninline ::std::string* FileOptions::mutable_go_package() {\n  set_has_go_package();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.go_package)\n  return go_package_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* FileOptions::release_go_package() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.go_package)\n  clear_has_go_package();\n  return go_package_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FileOptions::set_allocated_go_package(::std::string* go_package) {\n  if (go_package != NULL) {\n    set_has_go_package();\n  } else {\n    clear_has_go_package();\n  }\n  go_package_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), go_package);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.go_package)\n}\n\n// optional bool cc_generic_services = 16 [default = false];\ninline bool FileOptions::has_cc_generic_services() const {\n  return (_has_bits_[0] & 0x00000080u) != 0;\n}\ninline void FileOptions::set_has_cc_generic_services() {\n  _has_bits_[0] |= 0x00000080u;\n}\ninline void FileOptions::clear_has_cc_generic_services() {\n  _has_bits_[0] &= ~0x00000080u;\n}\ninline void FileOptions::clear_cc_generic_services() {\n  cc_generic_services_ = false;\n  clear_has_cc_generic_services();\n}\ninline bool FileOptions::cc_generic_services() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.cc_generic_services)\n  return cc_generic_services_;\n}\ninline void FileOptions::set_cc_generic_services(bool value) {\n  set_has_cc_generic_services();\n  cc_generic_services_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.cc_generic_services)\n}\n\n// optional bool java_generic_services = 17 [default = false];\ninline bool FileOptions::has_java_generic_services() const {\n  return (_has_bits_[0] & 0x00000100u) != 0;\n}\ninline void FileOptions::set_has_java_generic_services() {\n  _has_bits_[0] |= 0x00000100u;\n}\ninline void FileOptions::clear_has_java_generic_services() {\n  _has_bits_[0] &= ~0x00000100u;\n}\ninline void FileOptions::clear_java_generic_services() {\n  java_generic_services_ = false;\n  clear_has_java_generic_services();\n}\ninline bool FileOptions::java_generic_services() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.java_generic_services)\n  return java_generic_services_;\n}\ninline void FileOptions::set_java_generic_services(bool value) {\n  set_has_java_generic_services();\n  java_generic_services_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.java_generic_services)\n}\n\n// optional bool py_generic_services = 18 [default = false];\ninline bool FileOptions::has_py_generic_services() const {\n  return (_has_bits_[0] & 0x00000200u) != 0;\n}\ninline void FileOptions::set_has_py_generic_services() {\n  _has_bits_[0] |= 0x00000200u;\n}\ninline void FileOptions::clear_has_py_generic_services() {\n  _has_bits_[0] &= ~0x00000200u;\n}\ninline void FileOptions::clear_py_generic_services() {\n  py_generic_services_ = false;\n  clear_has_py_generic_services();\n}\ninline bool FileOptions::py_generic_services() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.py_generic_services)\n  return py_generic_services_;\n}\ninline void FileOptions::set_py_generic_services(bool value) {\n  set_has_py_generic_services();\n  py_generic_services_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.py_generic_services)\n}\n\n// optional bool deprecated = 23 [default = false];\ninline bool FileOptions::has_deprecated() const {\n  return (_has_bits_[0] & 0x00000400u) != 0;\n}\ninline void FileOptions::set_has_deprecated() {\n  _has_bits_[0] |= 0x00000400u;\n}\ninline void FileOptions::clear_has_deprecated() {\n  _has_bits_[0] &= ~0x00000400u;\n}\ninline void FileOptions::clear_deprecated() {\n  deprecated_ = false;\n  clear_has_deprecated();\n}\ninline bool FileOptions::deprecated() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.deprecated)\n  return deprecated_;\n}\ninline void FileOptions::set_deprecated(bool value) {\n  set_has_deprecated();\n  deprecated_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.deprecated)\n}\n\n// optional bool cc_enable_arenas = 31 [default = false];\ninline bool FileOptions::has_cc_enable_arenas() const {\n  return (_has_bits_[0] & 0x00000800u) != 0;\n}\ninline void FileOptions::set_has_cc_enable_arenas() {\n  _has_bits_[0] |= 0x00000800u;\n}\ninline void FileOptions::clear_has_cc_enable_arenas() {\n  _has_bits_[0] &= ~0x00000800u;\n}\ninline void FileOptions::clear_cc_enable_arenas() {\n  cc_enable_arenas_ = false;\n  clear_has_cc_enable_arenas();\n}\ninline bool FileOptions::cc_enable_arenas() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.cc_enable_arenas)\n  return cc_enable_arenas_;\n}\ninline void FileOptions::set_cc_enable_arenas(bool value) {\n  set_has_cc_enable_arenas();\n  cc_enable_arenas_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.cc_enable_arenas)\n}\n\n// optional string objc_class_prefix = 36;\ninline bool FileOptions::has_objc_class_prefix() const {\n  return (_has_bits_[0] & 0x00001000u) != 0;\n}\ninline void FileOptions::set_has_objc_class_prefix() {\n  _has_bits_[0] |= 0x00001000u;\n}\ninline void FileOptions::clear_has_objc_class_prefix() {\n  _has_bits_[0] &= ~0x00001000u;\n}\ninline void FileOptions::clear_objc_class_prefix() {\n  objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_objc_class_prefix();\n}\ninline const ::std::string& FileOptions::objc_class_prefix() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.objc_class_prefix)\n  return objc_class_prefix_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FileOptions::set_objc_class_prefix(const ::std::string& value) {\n  set_has_objc_class_prefix();\n  objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.objc_class_prefix)\n}\ninline void FileOptions::set_objc_class_prefix(const char* value) {\n  set_has_objc_class_prefix();\n  objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.objc_class_prefix)\n}\ninline void FileOptions::set_objc_class_prefix(const char* value, size_t size) {\n  set_has_objc_class_prefix();\n  objc_class_prefix_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.objc_class_prefix)\n}\ninline ::std::string* FileOptions::mutable_objc_class_prefix() {\n  set_has_objc_class_prefix();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.objc_class_prefix)\n  return objc_class_prefix_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* FileOptions::release_objc_class_prefix() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.objc_class_prefix)\n  clear_has_objc_class_prefix();\n  return objc_class_prefix_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FileOptions::set_allocated_objc_class_prefix(::std::string* objc_class_prefix) {\n  if (objc_class_prefix != NULL) {\n    set_has_objc_class_prefix();\n  } else {\n    clear_has_objc_class_prefix();\n  }\n  objc_class_prefix_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), objc_class_prefix);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.objc_class_prefix)\n}\n\n// optional string csharp_namespace = 37;\ninline bool FileOptions::has_csharp_namespace() const {\n  return (_has_bits_[0] & 0x00002000u) != 0;\n}\ninline void FileOptions::set_has_csharp_namespace() {\n  _has_bits_[0] |= 0x00002000u;\n}\ninline void FileOptions::clear_has_csharp_namespace() {\n  _has_bits_[0] &= ~0x00002000u;\n}\ninline void FileOptions::clear_csharp_namespace() {\n  csharp_namespace_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_csharp_namespace();\n}\ninline const ::std::string& FileOptions::csharp_namespace() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.csharp_namespace)\n  return csharp_namespace_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FileOptions::set_csharp_namespace(const ::std::string& value) {\n  set_has_csharp_namespace();\n  csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.FileOptions.csharp_namespace)\n}\ninline void FileOptions::set_csharp_namespace(const char* value) {\n  set_has_csharp_namespace();\n  csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FileOptions.csharp_namespace)\n}\ninline void FileOptions::set_csharp_namespace(const char* value, size_t size) {\n  set_has_csharp_namespace();\n  csharp_namespace_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FileOptions.csharp_namespace)\n}\ninline ::std::string* FileOptions::mutable_csharp_namespace() {\n  set_has_csharp_namespace();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.csharp_namespace)\n  return csharp_namespace_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* FileOptions::release_csharp_namespace() {\n  // @@protoc_insertion_point(field_release:google.protobuf.FileOptions.csharp_namespace)\n  clear_has_csharp_namespace();\n  return csharp_namespace_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void FileOptions::set_allocated_csharp_namespace(::std::string* csharp_namespace) {\n  if (csharp_namespace != NULL) {\n    set_has_csharp_namespace();\n  } else {\n    clear_has_csharp_namespace();\n  }\n  csharp_namespace_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), csharp_namespace);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.FileOptions.csharp_namespace)\n}\n\n// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\ninline int FileOptions::uninterpreted_option_size() const {\n  return uninterpreted_option_.size();\n}\ninline void FileOptions::clear_uninterpreted_option() {\n  uninterpreted_option_.Clear();\n}\ninline const ::google::protobuf::UninterpretedOption& FileOptions::uninterpreted_option(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FileOptions.uninterpreted_option)\n  return uninterpreted_option_.Get(index);\n}\ninline ::google::protobuf::UninterpretedOption* FileOptions::mutable_uninterpreted_option(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FileOptions.uninterpreted_option)\n  return uninterpreted_option_.Mutable(index);\n}\ninline ::google::protobuf::UninterpretedOption* FileOptions::add_uninterpreted_option() {\n  // @@protoc_insertion_point(field_add:google.protobuf.FileOptions.uninterpreted_option)\n  return uninterpreted_option_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\nFileOptions::mutable_uninterpreted_option() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.FileOptions.uninterpreted_option)\n  return &uninterpreted_option_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\nFileOptions::uninterpreted_option() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.FileOptions.uninterpreted_option)\n  return uninterpreted_option_;\n}\n\n// -------------------------------------------------------------------\n\n// MessageOptions\n\n// optional bool message_set_wire_format = 1 [default = false];\ninline bool MessageOptions::has_message_set_wire_format() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\ninline void MessageOptions::set_has_message_set_wire_format() {\n  _has_bits_[0] |= 0x00000001u;\n}\ninline void MessageOptions::clear_has_message_set_wire_format() {\n  _has_bits_[0] &= ~0x00000001u;\n}\ninline void MessageOptions::clear_message_set_wire_format() {\n  message_set_wire_format_ = false;\n  clear_has_message_set_wire_format();\n}\ninline bool MessageOptions::message_set_wire_format() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.message_set_wire_format)\n  return message_set_wire_format_;\n}\ninline void MessageOptions::set_message_set_wire_format(bool value) {\n  set_has_message_set_wire_format();\n  message_set_wire_format_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.message_set_wire_format)\n}\n\n// optional bool no_standard_descriptor_accessor = 2 [default = false];\ninline bool MessageOptions::has_no_standard_descriptor_accessor() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\ninline void MessageOptions::set_has_no_standard_descriptor_accessor() {\n  _has_bits_[0] |= 0x00000002u;\n}\ninline void MessageOptions::clear_has_no_standard_descriptor_accessor() {\n  _has_bits_[0] &= ~0x00000002u;\n}\ninline void MessageOptions::clear_no_standard_descriptor_accessor() {\n  no_standard_descriptor_accessor_ = false;\n  clear_has_no_standard_descriptor_accessor();\n}\ninline bool MessageOptions::no_standard_descriptor_accessor() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.no_standard_descriptor_accessor)\n  return no_standard_descriptor_accessor_;\n}\ninline void MessageOptions::set_no_standard_descriptor_accessor(bool value) {\n  set_has_no_standard_descriptor_accessor();\n  no_standard_descriptor_accessor_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.no_standard_descriptor_accessor)\n}\n\n// optional bool deprecated = 3 [default = false];\ninline bool MessageOptions::has_deprecated() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\ninline void MessageOptions::set_has_deprecated() {\n  _has_bits_[0] |= 0x00000004u;\n}\ninline void MessageOptions::clear_has_deprecated() {\n  _has_bits_[0] &= ~0x00000004u;\n}\ninline void MessageOptions::clear_deprecated() {\n  deprecated_ = false;\n  clear_has_deprecated();\n}\ninline bool MessageOptions::deprecated() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.deprecated)\n  return deprecated_;\n}\ninline void MessageOptions::set_deprecated(bool value) {\n  set_has_deprecated();\n  deprecated_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.deprecated)\n}\n\n// optional bool map_entry = 7;\ninline bool MessageOptions::has_map_entry() const {\n  return (_has_bits_[0] & 0x00000008u) != 0;\n}\ninline void MessageOptions::set_has_map_entry() {\n  _has_bits_[0] |= 0x00000008u;\n}\ninline void MessageOptions::clear_has_map_entry() {\n  _has_bits_[0] &= ~0x00000008u;\n}\ninline void MessageOptions::clear_map_entry() {\n  map_entry_ = false;\n  clear_has_map_entry();\n}\ninline bool MessageOptions::map_entry() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.map_entry)\n  return map_entry_;\n}\ninline void MessageOptions::set_map_entry(bool value) {\n  set_has_map_entry();\n  map_entry_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.MessageOptions.map_entry)\n}\n\n// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\ninline int MessageOptions::uninterpreted_option_size() const {\n  return uninterpreted_option_.size();\n}\ninline void MessageOptions::clear_uninterpreted_option() {\n  uninterpreted_option_.Clear();\n}\ninline const ::google::protobuf::UninterpretedOption& MessageOptions::uninterpreted_option(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MessageOptions.uninterpreted_option)\n  return uninterpreted_option_.Get(index);\n}\ninline ::google::protobuf::UninterpretedOption* MessageOptions::mutable_uninterpreted_option(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.MessageOptions.uninterpreted_option)\n  return uninterpreted_option_.Mutable(index);\n}\ninline ::google::protobuf::UninterpretedOption* MessageOptions::add_uninterpreted_option() {\n  // @@protoc_insertion_point(field_add:google.protobuf.MessageOptions.uninterpreted_option)\n  return uninterpreted_option_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\nMessageOptions::mutable_uninterpreted_option() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.MessageOptions.uninterpreted_option)\n  return &uninterpreted_option_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\nMessageOptions::uninterpreted_option() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.MessageOptions.uninterpreted_option)\n  return uninterpreted_option_;\n}\n\n// -------------------------------------------------------------------\n\n// FieldOptions\n\n// optional .google.protobuf.FieldOptions.CType ctype = 1 [default = STRING];\ninline bool FieldOptions::has_ctype() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\ninline void FieldOptions::set_has_ctype() {\n  _has_bits_[0] |= 0x00000001u;\n}\ninline void FieldOptions::clear_has_ctype() {\n  _has_bits_[0] &= ~0x00000001u;\n}\ninline void FieldOptions::clear_ctype() {\n  ctype_ = 0;\n  clear_has_ctype();\n}\ninline ::google::protobuf::FieldOptions_CType FieldOptions::ctype() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.ctype)\n  return static_cast< ::google::protobuf::FieldOptions_CType >(ctype_);\n}\ninline void FieldOptions::set_ctype(::google::protobuf::FieldOptions_CType value) {\n  assert(::google::protobuf::FieldOptions_CType_IsValid(value));\n  set_has_ctype();\n  ctype_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.ctype)\n}\n\n// optional bool packed = 2;\ninline bool FieldOptions::has_packed() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\ninline void FieldOptions::set_has_packed() {\n  _has_bits_[0] |= 0x00000002u;\n}\ninline void FieldOptions::clear_has_packed() {\n  _has_bits_[0] &= ~0x00000002u;\n}\ninline void FieldOptions::clear_packed() {\n  packed_ = false;\n  clear_has_packed();\n}\ninline bool FieldOptions::packed() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.packed)\n  return packed_;\n}\ninline void FieldOptions::set_packed(bool value) {\n  set_has_packed();\n  packed_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.packed)\n}\n\n// optional .google.protobuf.FieldOptions.JSType jstype = 6 [default = JS_NORMAL];\ninline bool FieldOptions::has_jstype() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\ninline void FieldOptions::set_has_jstype() {\n  _has_bits_[0] |= 0x00000004u;\n}\ninline void FieldOptions::clear_has_jstype() {\n  _has_bits_[0] &= ~0x00000004u;\n}\ninline void FieldOptions::clear_jstype() {\n  jstype_ = 0;\n  clear_has_jstype();\n}\ninline ::google::protobuf::FieldOptions_JSType FieldOptions::jstype() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.jstype)\n  return static_cast< ::google::protobuf::FieldOptions_JSType >(jstype_);\n}\ninline void FieldOptions::set_jstype(::google::protobuf::FieldOptions_JSType value) {\n  assert(::google::protobuf::FieldOptions_JSType_IsValid(value));\n  set_has_jstype();\n  jstype_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.jstype)\n}\n\n// optional bool lazy = 5 [default = false];\ninline bool FieldOptions::has_lazy() const {\n  return (_has_bits_[0] & 0x00000008u) != 0;\n}\ninline void FieldOptions::set_has_lazy() {\n  _has_bits_[0] |= 0x00000008u;\n}\ninline void FieldOptions::clear_has_lazy() {\n  _has_bits_[0] &= ~0x00000008u;\n}\ninline void FieldOptions::clear_lazy() {\n  lazy_ = false;\n  clear_has_lazy();\n}\ninline bool FieldOptions::lazy() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.lazy)\n  return lazy_;\n}\ninline void FieldOptions::set_lazy(bool value) {\n  set_has_lazy();\n  lazy_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.lazy)\n}\n\n// optional bool deprecated = 3 [default = false];\ninline bool FieldOptions::has_deprecated() const {\n  return (_has_bits_[0] & 0x00000010u) != 0;\n}\ninline void FieldOptions::set_has_deprecated() {\n  _has_bits_[0] |= 0x00000010u;\n}\ninline void FieldOptions::clear_has_deprecated() {\n  _has_bits_[0] &= ~0x00000010u;\n}\ninline void FieldOptions::clear_deprecated() {\n  deprecated_ = false;\n  clear_has_deprecated();\n}\ninline bool FieldOptions::deprecated() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.deprecated)\n  return deprecated_;\n}\ninline void FieldOptions::set_deprecated(bool value) {\n  set_has_deprecated();\n  deprecated_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.deprecated)\n}\n\n// optional bool weak = 10 [default = false];\ninline bool FieldOptions::has_weak() const {\n  return (_has_bits_[0] & 0x00000020u) != 0;\n}\ninline void FieldOptions::set_has_weak() {\n  _has_bits_[0] |= 0x00000020u;\n}\ninline void FieldOptions::clear_has_weak() {\n  _has_bits_[0] &= ~0x00000020u;\n}\ninline void FieldOptions::clear_weak() {\n  weak_ = false;\n  clear_has_weak();\n}\ninline bool FieldOptions::weak() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.weak)\n  return weak_;\n}\ninline void FieldOptions::set_weak(bool value) {\n  set_has_weak();\n  weak_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldOptions.weak)\n}\n\n// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\ninline int FieldOptions::uninterpreted_option_size() const {\n  return uninterpreted_option_.size();\n}\ninline void FieldOptions::clear_uninterpreted_option() {\n  uninterpreted_option_.Clear();\n}\ninline const ::google::protobuf::UninterpretedOption& FieldOptions::uninterpreted_option(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldOptions.uninterpreted_option)\n  return uninterpreted_option_.Get(index);\n}\ninline ::google::protobuf::UninterpretedOption* FieldOptions::mutable_uninterpreted_option(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FieldOptions.uninterpreted_option)\n  return uninterpreted_option_.Mutable(index);\n}\ninline ::google::protobuf::UninterpretedOption* FieldOptions::add_uninterpreted_option() {\n  // @@protoc_insertion_point(field_add:google.protobuf.FieldOptions.uninterpreted_option)\n  return uninterpreted_option_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\nFieldOptions::mutable_uninterpreted_option() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.FieldOptions.uninterpreted_option)\n  return &uninterpreted_option_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\nFieldOptions::uninterpreted_option() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.FieldOptions.uninterpreted_option)\n  return uninterpreted_option_;\n}\n\n// -------------------------------------------------------------------\n\n// OneofOptions\n\n// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\ninline int OneofOptions::uninterpreted_option_size() const {\n  return uninterpreted_option_.size();\n}\ninline void OneofOptions::clear_uninterpreted_option() {\n  uninterpreted_option_.Clear();\n}\ninline const ::google::protobuf::UninterpretedOption& OneofOptions::uninterpreted_option(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.OneofOptions.uninterpreted_option)\n  return uninterpreted_option_.Get(index);\n}\ninline ::google::protobuf::UninterpretedOption* OneofOptions::mutable_uninterpreted_option(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.OneofOptions.uninterpreted_option)\n  return uninterpreted_option_.Mutable(index);\n}\ninline ::google::protobuf::UninterpretedOption* OneofOptions::add_uninterpreted_option() {\n  // @@protoc_insertion_point(field_add:google.protobuf.OneofOptions.uninterpreted_option)\n  return uninterpreted_option_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\nOneofOptions::mutable_uninterpreted_option() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.OneofOptions.uninterpreted_option)\n  return &uninterpreted_option_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\nOneofOptions::uninterpreted_option() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.OneofOptions.uninterpreted_option)\n  return uninterpreted_option_;\n}\n\n// -------------------------------------------------------------------\n\n// EnumOptions\n\n// optional bool allow_alias = 2;\ninline bool EnumOptions::has_allow_alias() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\ninline void EnumOptions::set_has_allow_alias() {\n  _has_bits_[0] |= 0x00000001u;\n}\ninline void EnumOptions::clear_has_allow_alias() {\n  _has_bits_[0] &= ~0x00000001u;\n}\ninline void EnumOptions::clear_allow_alias() {\n  allow_alias_ = false;\n  clear_has_allow_alias();\n}\ninline bool EnumOptions::allow_alias() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.allow_alias)\n  return allow_alias_;\n}\ninline void EnumOptions::set_allow_alias(bool value) {\n  set_has_allow_alias();\n  allow_alias_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.EnumOptions.allow_alias)\n}\n\n// optional bool deprecated = 3 [default = false];\ninline bool EnumOptions::has_deprecated() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\ninline void EnumOptions::set_has_deprecated() {\n  _has_bits_[0] |= 0x00000002u;\n}\ninline void EnumOptions::clear_has_deprecated() {\n  _has_bits_[0] &= ~0x00000002u;\n}\ninline void EnumOptions::clear_deprecated() {\n  deprecated_ = false;\n  clear_has_deprecated();\n}\ninline bool EnumOptions::deprecated() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.deprecated)\n  return deprecated_;\n}\ninline void EnumOptions::set_deprecated(bool value) {\n  set_has_deprecated();\n  deprecated_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.EnumOptions.deprecated)\n}\n\n// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\ninline int EnumOptions::uninterpreted_option_size() const {\n  return uninterpreted_option_.size();\n}\ninline void EnumOptions::clear_uninterpreted_option() {\n  uninterpreted_option_.Clear();\n}\ninline const ::google::protobuf::UninterpretedOption& EnumOptions::uninterpreted_option(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumOptions.uninterpreted_option)\n  return uninterpreted_option_.Get(index);\n}\ninline ::google::protobuf::UninterpretedOption* EnumOptions::mutable_uninterpreted_option(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.EnumOptions.uninterpreted_option)\n  return uninterpreted_option_.Mutable(index);\n}\ninline ::google::protobuf::UninterpretedOption* EnumOptions::add_uninterpreted_option() {\n  // @@protoc_insertion_point(field_add:google.protobuf.EnumOptions.uninterpreted_option)\n  return uninterpreted_option_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\nEnumOptions::mutable_uninterpreted_option() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumOptions.uninterpreted_option)\n  return &uninterpreted_option_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\nEnumOptions::uninterpreted_option() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.EnumOptions.uninterpreted_option)\n  return uninterpreted_option_;\n}\n\n// -------------------------------------------------------------------\n\n// EnumValueOptions\n\n// optional bool deprecated = 1 [default = false];\ninline bool EnumValueOptions::has_deprecated() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\ninline void EnumValueOptions::set_has_deprecated() {\n  _has_bits_[0] |= 0x00000001u;\n}\ninline void EnumValueOptions::clear_has_deprecated() {\n  _has_bits_[0] &= ~0x00000001u;\n}\ninline void EnumValueOptions::clear_deprecated() {\n  deprecated_ = false;\n  clear_has_deprecated();\n}\ninline bool EnumValueOptions::deprecated() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumValueOptions.deprecated)\n  return deprecated_;\n}\ninline void EnumValueOptions::set_deprecated(bool value) {\n  set_has_deprecated();\n  deprecated_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.EnumValueOptions.deprecated)\n}\n\n// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\ninline int EnumValueOptions::uninterpreted_option_size() const {\n  return uninterpreted_option_.size();\n}\ninline void EnumValueOptions::clear_uninterpreted_option() {\n  uninterpreted_option_.Clear();\n}\ninline const ::google::protobuf::UninterpretedOption& EnumValueOptions::uninterpreted_option(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumValueOptions.uninterpreted_option)\n  return uninterpreted_option_.Get(index);\n}\ninline ::google::protobuf::UninterpretedOption* EnumValueOptions::mutable_uninterpreted_option(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValueOptions.uninterpreted_option)\n  return uninterpreted_option_.Mutable(index);\n}\ninline ::google::protobuf::UninterpretedOption* EnumValueOptions::add_uninterpreted_option() {\n  // @@protoc_insertion_point(field_add:google.protobuf.EnumValueOptions.uninterpreted_option)\n  return uninterpreted_option_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\nEnumValueOptions::mutable_uninterpreted_option() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumValueOptions.uninterpreted_option)\n  return &uninterpreted_option_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\nEnumValueOptions::uninterpreted_option() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.EnumValueOptions.uninterpreted_option)\n  return uninterpreted_option_;\n}\n\n// -------------------------------------------------------------------\n\n// ServiceOptions\n\n// optional bool deprecated = 33 [default = false];\ninline bool ServiceOptions::has_deprecated() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\ninline void ServiceOptions::set_has_deprecated() {\n  _has_bits_[0] |= 0x00000001u;\n}\ninline void ServiceOptions::clear_has_deprecated() {\n  _has_bits_[0] &= ~0x00000001u;\n}\ninline void ServiceOptions::clear_deprecated() {\n  deprecated_ = false;\n  clear_has_deprecated();\n}\ninline bool ServiceOptions::deprecated() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.ServiceOptions.deprecated)\n  return deprecated_;\n}\ninline void ServiceOptions::set_deprecated(bool value) {\n  set_has_deprecated();\n  deprecated_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.ServiceOptions.deprecated)\n}\n\n// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\ninline int ServiceOptions::uninterpreted_option_size() const {\n  return uninterpreted_option_.size();\n}\ninline void ServiceOptions::clear_uninterpreted_option() {\n  uninterpreted_option_.Clear();\n}\ninline const ::google::protobuf::UninterpretedOption& ServiceOptions::uninterpreted_option(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.ServiceOptions.uninterpreted_option)\n  return uninterpreted_option_.Get(index);\n}\ninline ::google::protobuf::UninterpretedOption* ServiceOptions::mutable_uninterpreted_option(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.ServiceOptions.uninterpreted_option)\n  return uninterpreted_option_.Mutable(index);\n}\ninline ::google::protobuf::UninterpretedOption* ServiceOptions::add_uninterpreted_option() {\n  // @@protoc_insertion_point(field_add:google.protobuf.ServiceOptions.uninterpreted_option)\n  return uninterpreted_option_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\nServiceOptions::mutable_uninterpreted_option() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.ServiceOptions.uninterpreted_option)\n  return &uninterpreted_option_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\nServiceOptions::uninterpreted_option() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.ServiceOptions.uninterpreted_option)\n  return uninterpreted_option_;\n}\n\n// -------------------------------------------------------------------\n\n// MethodOptions\n\n// optional bool deprecated = 33 [default = false];\ninline bool MethodOptions::has_deprecated() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\ninline void MethodOptions::set_has_deprecated() {\n  _has_bits_[0] |= 0x00000001u;\n}\ninline void MethodOptions::clear_has_deprecated() {\n  _has_bits_[0] &= ~0x00000001u;\n}\ninline void MethodOptions::clear_deprecated() {\n  deprecated_ = false;\n  clear_has_deprecated();\n}\ninline bool MethodOptions::deprecated() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.deprecated)\n  return deprecated_;\n}\ninline void MethodOptions::set_deprecated(bool value) {\n  set_has_deprecated();\n  deprecated_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.MethodOptions.deprecated)\n}\n\n// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;\ninline int MethodOptions::uninterpreted_option_size() const {\n  return uninterpreted_option_.size();\n}\ninline void MethodOptions::clear_uninterpreted_option() {\n  uninterpreted_option_.Clear();\n}\ninline const ::google::protobuf::UninterpretedOption& MethodOptions::uninterpreted_option(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.MethodOptions.uninterpreted_option)\n  return uninterpreted_option_.Get(index);\n}\ninline ::google::protobuf::UninterpretedOption* MethodOptions::mutable_uninterpreted_option(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.MethodOptions.uninterpreted_option)\n  return uninterpreted_option_.Mutable(index);\n}\ninline ::google::protobuf::UninterpretedOption* MethodOptions::add_uninterpreted_option() {\n  // @@protoc_insertion_point(field_add:google.protobuf.MethodOptions.uninterpreted_option)\n  return uninterpreted_option_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >*\nMethodOptions::mutable_uninterpreted_option() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.MethodOptions.uninterpreted_option)\n  return &uninterpreted_option_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption >&\nMethodOptions::uninterpreted_option() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.MethodOptions.uninterpreted_option)\n  return uninterpreted_option_;\n}\n\n// -------------------------------------------------------------------\n\n// UninterpretedOption_NamePart\n\n// required string name_part = 1;\ninline bool UninterpretedOption_NamePart::has_name_part() const {\n  return (_has_bits_[0] & 0x00000001u) != 0;\n}\ninline void UninterpretedOption_NamePart::set_has_name_part() {\n  _has_bits_[0] |= 0x00000001u;\n}\ninline void UninterpretedOption_NamePart::clear_has_name_part() {\n  _has_bits_[0] &= ~0x00000001u;\n}\ninline void UninterpretedOption_NamePart::clear_name_part() {\n  name_part_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_name_part();\n}\ninline const ::std::string& UninterpretedOption_NamePart::name_part() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.name_part)\n  return name_part_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void UninterpretedOption_NamePart::set_name_part(const ::std::string& value) {\n  set_has_name_part();\n  name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.name_part)\n}\ninline void UninterpretedOption_NamePart::set_name_part(const char* value) {\n  set_has_name_part();\n  name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.NamePart.name_part)\n}\ninline void UninterpretedOption_NamePart::set_name_part(const char* value, size_t size) {\n  set_has_name_part();\n  name_part_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.NamePart.name_part)\n}\ninline ::std::string* UninterpretedOption_NamePart::mutable_name_part() {\n  set_has_name_part();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.NamePart.name_part)\n  return name_part_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* UninterpretedOption_NamePart::release_name_part() {\n  // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.NamePart.name_part)\n  clear_has_name_part();\n  return name_part_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void UninterpretedOption_NamePart::set_allocated_name_part(::std::string* name_part) {\n  if (name_part != NULL) {\n    set_has_name_part();\n  } else {\n    clear_has_name_part();\n  }\n  name_part_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name_part);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.NamePart.name_part)\n}\n\n// required bool is_extension = 2;\ninline bool UninterpretedOption_NamePart::has_is_extension() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\ninline void UninterpretedOption_NamePart::set_has_is_extension() {\n  _has_bits_[0] |= 0x00000002u;\n}\ninline void UninterpretedOption_NamePart::clear_has_is_extension() {\n  _has_bits_[0] &= ~0x00000002u;\n}\ninline void UninterpretedOption_NamePart::clear_is_extension() {\n  is_extension_ = false;\n  clear_has_is_extension();\n}\ninline bool UninterpretedOption_NamePart::is_extension() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.NamePart.is_extension)\n  return is_extension_;\n}\ninline void UninterpretedOption_NamePart::set_is_extension(bool value) {\n  set_has_is_extension();\n  is_extension_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.NamePart.is_extension)\n}\n\n// -------------------------------------------------------------------\n\n// UninterpretedOption\n\n// repeated .google.protobuf.UninterpretedOption.NamePart name = 2;\ninline int UninterpretedOption::name_size() const {\n  return name_.size();\n}\ninline void UninterpretedOption::clear_name() {\n  name_.Clear();\n}\ninline const ::google::protobuf::UninterpretedOption_NamePart& UninterpretedOption::name(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.name)\n  return name_.Get(index);\n}\ninline ::google::protobuf::UninterpretedOption_NamePart* UninterpretedOption::mutable_name(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.name)\n  return name_.Mutable(index);\n}\ninline ::google::protobuf::UninterpretedOption_NamePart* UninterpretedOption::add_name() {\n  // @@protoc_insertion_point(field_add:google.protobuf.UninterpretedOption.name)\n  return name_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart >*\nUninterpretedOption::mutable_name() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.UninterpretedOption.name)\n  return &name_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UninterpretedOption_NamePart >&\nUninterpretedOption::name() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.UninterpretedOption.name)\n  return name_;\n}\n\n// optional string identifier_value = 3;\ninline bool UninterpretedOption::has_identifier_value() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\ninline void UninterpretedOption::set_has_identifier_value() {\n  _has_bits_[0] |= 0x00000002u;\n}\ninline void UninterpretedOption::clear_has_identifier_value() {\n  _has_bits_[0] &= ~0x00000002u;\n}\ninline void UninterpretedOption::clear_identifier_value() {\n  identifier_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_identifier_value();\n}\ninline const ::std::string& UninterpretedOption::identifier_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.identifier_value)\n  return identifier_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void UninterpretedOption::set_identifier_value(const ::std::string& value) {\n  set_has_identifier_value();\n  identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.identifier_value)\n}\ninline void UninterpretedOption::set_identifier_value(const char* value) {\n  set_has_identifier_value();\n  identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.identifier_value)\n}\ninline void UninterpretedOption::set_identifier_value(const char* value, size_t size) {\n  set_has_identifier_value();\n  identifier_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.identifier_value)\n}\ninline ::std::string* UninterpretedOption::mutable_identifier_value() {\n  set_has_identifier_value();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.identifier_value)\n  return identifier_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* UninterpretedOption::release_identifier_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.identifier_value)\n  clear_has_identifier_value();\n  return identifier_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void UninterpretedOption::set_allocated_identifier_value(::std::string* identifier_value) {\n  if (identifier_value != NULL) {\n    set_has_identifier_value();\n  } else {\n    clear_has_identifier_value();\n  }\n  identifier_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), identifier_value);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.identifier_value)\n}\n\n// optional uint64 positive_int_value = 4;\ninline bool UninterpretedOption::has_positive_int_value() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\ninline void UninterpretedOption::set_has_positive_int_value() {\n  _has_bits_[0] |= 0x00000004u;\n}\ninline void UninterpretedOption::clear_has_positive_int_value() {\n  _has_bits_[0] &= ~0x00000004u;\n}\ninline void UninterpretedOption::clear_positive_int_value() {\n  positive_int_value_ = GOOGLE_ULONGLONG(0);\n  clear_has_positive_int_value();\n}\ninline ::google::protobuf::uint64 UninterpretedOption::positive_int_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.positive_int_value)\n  return positive_int_value_;\n}\ninline void UninterpretedOption::set_positive_int_value(::google::protobuf::uint64 value) {\n  set_has_positive_int_value();\n  positive_int_value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.positive_int_value)\n}\n\n// optional int64 negative_int_value = 5;\ninline bool UninterpretedOption::has_negative_int_value() const {\n  return (_has_bits_[0] & 0x00000008u) != 0;\n}\ninline void UninterpretedOption::set_has_negative_int_value() {\n  _has_bits_[0] |= 0x00000008u;\n}\ninline void UninterpretedOption::clear_has_negative_int_value() {\n  _has_bits_[0] &= ~0x00000008u;\n}\ninline void UninterpretedOption::clear_negative_int_value() {\n  negative_int_value_ = GOOGLE_LONGLONG(0);\n  clear_has_negative_int_value();\n}\ninline ::google::protobuf::int64 UninterpretedOption::negative_int_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.negative_int_value)\n  return negative_int_value_;\n}\ninline void UninterpretedOption::set_negative_int_value(::google::protobuf::int64 value) {\n  set_has_negative_int_value();\n  negative_int_value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.negative_int_value)\n}\n\n// optional double double_value = 6;\ninline bool UninterpretedOption::has_double_value() const {\n  return (_has_bits_[0] & 0x00000010u) != 0;\n}\ninline void UninterpretedOption::set_has_double_value() {\n  _has_bits_[0] |= 0x00000010u;\n}\ninline void UninterpretedOption::clear_has_double_value() {\n  _has_bits_[0] &= ~0x00000010u;\n}\ninline void UninterpretedOption::clear_double_value() {\n  double_value_ = 0;\n  clear_has_double_value();\n}\ninline double UninterpretedOption::double_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.double_value)\n  return double_value_;\n}\ninline void UninterpretedOption::set_double_value(double value) {\n  set_has_double_value();\n  double_value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.double_value)\n}\n\n// optional bytes string_value = 7;\ninline bool UninterpretedOption::has_string_value() const {\n  return (_has_bits_[0] & 0x00000020u) != 0;\n}\ninline void UninterpretedOption::set_has_string_value() {\n  _has_bits_[0] |= 0x00000020u;\n}\ninline void UninterpretedOption::clear_has_string_value() {\n  _has_bits_[0] &= ~0x00000020u;\n}\ninline void UninterpretedOption::clear_string_value() {\n  string_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_string_value();\n}\ninline const ::std::string& UninterpretedOption::string_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.string_value)\n  return string_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void UninterpretedOption::set_string_value(const ::std::string& value) {\n  set_has_string_value();\n  string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.string_value)\n}\ninline void UninterpretedOption::set_string_value(const char* value) {\n  set_has_string_value();\n  string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.string_value)\n}\ninline void UninterpretedOption::set_string_value(const void* value, size_t size) {\n  set_has_string_value();\n  string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.string_value)\n}\ninline ::std::string* UninterpretedOption::mutable_string_value() {\n  set_has_string_value();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.string_value)\n  return string_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* UninterpretedOption::release_string_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.string_value)\n  clear_has_string_value();\n  return string_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void UninterpretedOption::set_allocated_string_value(::std::string* string_value) {\n  if (string_value != NULL) {\n    set_has_string_value();\n  } else {\n    clear_has_string_value();\n  }\n  string_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), string_value);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.string_value)\n}\n\n// optional string aggregate_value = 8;\ninline bool UninterpretedOption::has_aggregate_value() const {\n  return (_has_bits_[0] & 0x00000040u) != 0;\n}\ninline void UninterpretedOption::set_has_aggregate_value() {\n  _has_bits_[0] |= 0x00000040u;\n}\ninline void UninterpretedOption::clear_has_aggregate_value() {\n  _has_bits_[0] &= ~0x00000040u;\n}\ninline void UninterpretedOption::clear_aggregate_value() {\n  aggregate_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_aggregate_value();\n}\ninline const ::std::string& UninterpretedOption::aggregate_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.UninterpretedOption.aggregate_value)\n  return aggregate_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void UninterpretedOption::set_aggregate_value(const ::std::string& value) {\n  set_has_aggregate_value();\n  aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.UninterpretedOption.aggregate_value)\n}\ninline void UninterpretedOption::set_aggregate_value(const char* value) {\n  set_has_aggregate_value();\n  aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.UninterpretedOption.aggregate_value)\n}\ninline void UninterpretedOption::set_aggregate_value(const char* value, size_t size) {\n  set_has_aggregate_value();\n  aggregate_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.UninterpretedOption.aggregate_value)\n}\ninline ::std::string* UninterpretedOption::mutable_aggregate_value() {\n  set_has_aggregate_value();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.UninterpretedOption.aggregate_value)\n  return aggregate_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* UninterpretedOption::release_aggregate_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.UninterpretedOption.aggregate_value)\n  clear_has_aggregate_value();\n  return aggregate_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void UninterpretedOption::set_allocated_aggregate_value(::std::string* aggregate_value) {\n  if (aggregate_value != NULL) {\n    set_has_aggregate_value();\n  } else {\n    clear_has_aggregate_value();\n  }\n  aggregate_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), aggregate_value);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.UninterpretedOption.aggregate_value)\n}\n\n// -------------------------------------------------------------------\n\n// SourceCodeInfo_Location\n\n// repeated int32 path = 1 [packed = true];\ninline int SourceCodeInfo_Location::path_size() const {\n  return path_.size();\n}\ninline void SourceCodeInfo_Location::clear_path() {\n  path_.Clear();\n}\ninline ::google::protobuf::int32 SourceCodeInfo_Location::path(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.path)\n  return path_.Get(index);\n}\ninline void SourceCodeInfo_Location::set_path(int index, ::google::protobuf::int32 value) {\n  path_.Set(index, value);\n  // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.path)\n}\ninline void SourceCodeInfo_Location::add_path(::google::protobuf::int32 value) {\n  path_.Add(value);\n  // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.path)\n}\ninline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&\nSourceCodeInfo_Location::path() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.Location.path)\n  return path_;\n}\ninline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*\nSourceCodeInfo_Location::mutable_path() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.Location.path)\n  return &path_;\n}\n\n// repeated int32 span = 2 [packed = true];\ninline int SourceCodeInfo_Location::span_size() const {\n  return span_.size();\n}\ninline void SourceCodeInfo_Location::clear_span() {\n  span_.Clear();\n}\ninline ::google::protobuf::int32 SourceCodeInfo_Location::span(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.span)\n  return span_.Get(index);\n}\ninline void SourceCodeInfo_Location::set_span(int index, ::google::protobuf::int32 value) {\n  span_.Set(index, value);\n  // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.span)\n}\ninline void SourceCodeInfo_Location::add_span(::google::protobuf::int32 value) {\n  span_.Add(value);\n  // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.span)\n}\ninline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&\nSourceCodeInfo_Location::span() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.Location.span)\n  return span_;\n}\ninline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*\nSourceCodeInfo_Location::mutable_span() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.Location.span)\n  return &span_;\n}\n\n// optional string leading_comments = 3;\ninline bool SourceCodeInfo_Location::has_leading_comments() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\ninline void SourceCodeInfo_Location::set_has_leading_comments() {\n  _has_bits_[0] |= 0x00000004u;\n}\ninline void SourceCodeInfo_Location::clear_has_leading_comments() {\n  _has_bits_[0] &= ~0x00000004u;\n}\ninline void SourceCodeInfo_Location::clear_leading_comments() {\n  leading_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_leading_comments();\n}\ninline const ::std::string& SourceCodeInfo_Location::leading_comments() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.leading_comments)\n  return leading_comments_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void SourceCodeInfo_Location::set_leading_comments(const ::std::string& value) {\n  set_has_leading_comments();\n  leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_comments)\n}\ninline void SourceCodeInfo_Location::set_leading_comments(const char* value) {\n  set_has_leading_comments();\n  leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.leading_comments)\n}\ninline void SourceCodeInfo_Location::set_leading_comments(const char* value, size_t size) {\n  set_has_leading_comments();\n  leading_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.leading_comments)\n}\ninline ::std::string* SourceCodeInfo_Location::mutable_leading_comments() {\n  set_has_leading_comments();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.Location.leading_comments)\n  return leading_comments_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* SourceCodeInfo_Location::release_leading_comments() {\n  // @@protoc_insertion_point(field_release:google.protobuf.SourceCodeInfo.Location.leading_comments)\n  clear_has_leading_comments();\n  return leading_comments_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void SourceCodeInfo_Location::set_allocated_leading_comments(::std::string* leading_comments) {\n  if (leading_comments != NULL) {\n    set_has_leading_comments();\n  } else {\n    clear_has_leading_comments();\n  }\n  leading_comments_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), leading_comments);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceCodeInfo.Location.leading_comments)\n}\n\n// optional string trailing_comments = 4;\ninline bool SourceCodeInfo_Location::has_trailing_comments() const {\n  return (_has_bits_[0] & 0x00000008u) != 0;\n}\ninline void SourceCodeInfo_Location::set_has_trailing_comments() {\n  _has_bits_[0] |= 0x00000008u;\n}\ninline void SourceCodeInfo_Location::clear_has_trailing_comments() {\n  _has_bits_[0] &= ~0x00000008u;\n}\ninline void SourceCodeInfo_Location::clear_trailing_comments() {\n  trailing_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_trailing_comments();\n}\ninline const ::std::string& SourceCodeInfo_Location::trailing_comments() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.trailing_comments)\n  return trailing_comments_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void SourceCodeInfo_Location::set_trailing_comments(const ::std::string& value) {\n  set_has_trailing_comments();\n  trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.trailing_comments)\n}\ninline void SourceCodeInfo_Location::set_trailing_comments(const char* value) {\n  set_has_trailing_comments();\n  trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.trailing_comments)\n}\ninline void SourceCodeInfo_Location::set_trailing_comments(const char* value, size_t size) {\n  set_has_trailing_comments();\n  trailing_comments_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.trailing_comments)\n}\ninline ::std::string* SourceCodeInfo_Location::mutable_trailing_comments() {\n  set_has_trailing_comments();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.Location.trailing_comments)\n  return trailing_comments_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* SourceCodeInfo_Location::release_trailing_comments() {\n  // @@protoc_insertion_point(field_release:google.protobuf.SourceCodeInfo.Location.trailing_comments)\n  clear_has_trailing_comments();\n  return trailing_comments_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void SourceCodeInfo_Location::set_allocated_trailing_comments(::std::string* trailing_comments) {\n  if (trailing_comments != NULL) {\n    set_has_trailing_comments();\n  } else {\n    clear_has_trailing_comments();\n  }\n  trailing_comments_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), trailing_comments);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceCodeInfo.Location.trailing_comments)\n}\n\n// repeated string leading_detached_comments = 6;\ninline int SourceCodeInfo_Location::leading_detached_comments_size() const {\n  return leading_detached_comments_.size();\n}\ninline void SourceCodeInfo_Location::clear_leading_detached_comments() {\n  leading_detached_comments_.Clear();\n}\ninline const ::std::string& SourceCodeInfo_Location::leading_detached_comments(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)\n  return leading_detached_comments_.Get(index);\n}\ninline ::std::string* SourceCodeInfo_Location::mutable_leading_detached_comments(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)\n  return leading_detached_comments_.Mutable(index);\n}\ninline void SourceCodeInfo_Location::set_leading_detached_comments(int index, const ::std::string& value) {\n  // @@protoc_insertion_point(field_set:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)\n  leading_detached_comments_.Mutable(index)->assign(value);\n}\ninline void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value) {\n  leading_detached_comments_.Mutable(index)->assign(value);\n  // @@protoc_insertion_point(field_set_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)\n}\ninline void SourceCodeInfo_Location::set_leading_detached_comments(int index, const char* value, size_t size) {\n  leading_detached_comments_.Mutable(index)->assign(\n    reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)\n}\ninline ::std::string* SourceCodeInfo_Location::add_leading_detached_comments() {\n  // @@protoc_insertion_point(field_add_mutable:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)\n  return leading_detached_comments_.Add();\n}\ninline void SourceCodeInfo_Location::add_leading_detached_comments(const ::std::string& value) {\n  leading_detached_comments_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)\n}\ninline void SourceCodeInfo_Location::add_leading_detached_comments(const char* value) {\n  leading_detached_comments_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add_char:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)\n}\ninline void SourceCodeInfo_Location::add_leading_detached_comments(const char* value, size_t size) {\n  leading_detached_comments_.Add()->assign(reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_add_pointer:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)\n}\ninline const ::google::protobuf::RepeatedPtrField< ::std::string>&\nSourceCodeInfo_Location::leading_detached_comments() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)\n  return leading_detached_comments_;\n}\ninline ::google::protobuf::RepeatedPtrField< ::std::string>*\nSourceCodeInfo_Location::mutable_leading_detached_comments() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.Location.leading_detached_comments)\n  return &leading_detached_comments_;\n}\n\n// -------------------------------------------------------------------\n\n// SourceCodeInfo\n\n// repeated .google.protobuf.SourceCodeInfo.Location location = 1;\ninline int SourceCodeInfo::location_size() const {\n  return location_.size();\n}\ninline void SourceCodeInfo::clear_location() {\n  location_.Clear();\n}\ninline const ::google::protobuf::SourceCodeInfo_Location& SourceCodeInfo::location(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.SourceCodeInfo.location)\n  return location_.Get(index);\n}\ninline ::google::protobuf::SourceCodeInfo_Location* SourceCodeInfo::mutable_location(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.SourceCodeInfo.location)\n  return location_.Mutable(index);\n}\ninline ::google::protobuf::SourceCodeInfo_Location* SourceCodeInfo::add_location() {\n  // @@protoc_insertion_point(field_add:google.protobuf.SourceCodeInfo.location)\n  return location_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location >*\nSourceCodeInfo::mutable_location() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.SourceCodeInfo.location)\n  return &location_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceCodeInfo_Location >&\nSourceCodeInfo::location() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.SourceCodeInfo.location)\n  return location_;\n}\n\n// -------------------------------------------------------------------\n\n// GeneratedCodeInfo_Annotation\n\n// repeated int32 path = 1 [packed = true];\ninline int GeneratedCodeInfo_Annotation::path_size() const {\n  return path_.size();\n}\ninline void GeneratedCodeInfo_Annotation::clear_path() {\n  path_.Clear();\n}\ninline ::google::protobuf::int32 GeneratedCodeInfo_Annotation::path(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.path)\n  return path_.Get(index);\n}\ninline void GeneratedCodeInfo_Annotation::set_path(int index, ::google::protobuf::int32 value) {\n  path_.Set(index, value);\n  // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.path)\n}\ninline void GeneratedCodeInfo_Annotation::add_path(::google::protobuf::int32 value) {\n  path_.Add(value);\n  // @@protoc_insertion_point(field_add:google.protobuf.GeneratedCodeInfo.Annotation.path)\n}\ninline const ::google::protobuf::RepeatedField< ::google::protobuf::int32 >&\nGeneratedCodeInfo_Annotation::path() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.GeneratedCodeInfo.Annotation.path)\n  return path_;\n}\ninline ::google::protobuf::RepeatedField< ::google::protobuf::int32 >*\nGeneratedCodeInfo_Annotation::mutable_path() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.GeneratedCodeInfo.Annotation.path)\n  return &path_;\n}\n\n// optional string source_file = 2;\ninline bool GeneratedCodeInfo_Annotation::has_source_file() const {\n  return (_has_bits_[0] & 0x00000002u) != 0;\n}\ninline void GeneratedCodeInfo_Annotation::set_has_source_file() {\n  _has_bits_[0] |= 0x00000002u;\n}\ninline void GeneratedCodeInfo_Annotation::clear_has_source_file() {\n  _has_bits_[0] &= ~0x00000002u;\n}\ninline void GeneratedCodeInfo_Annotation::clear_source_file() {\n  source_file_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  clear_has_source_file();\n}\ninline const ::std::string& GeneratedCodeInfo_Annotation::source_file() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.source_file)\n  return source_file_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void GeneratedCodeInfo_Annotation::set_source_file(const ::std::string& value) {\n  set_has_source_file();\n  source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.source_file)\n}\ninline void GeneratedCodeInfo_Annotation::set_source_file(const char* value) {\n  set_has_source_file();\n  source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.GeneratedCodeInfo.Annotation.source_file)\n}\ninline void GeneratedCodeInfo_Annotation::set_source_file(const char* value, size_t size) {\n  set_has_source_file();\n  source_file_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.GeneratedCodeInfo.Annotation.source_file)\n}\ninline ::std::string* GeneratedCodeInfo_Annotation::mutable_source_file() {\n  set_has_source_file();\n  // @@protoc_insertion_point(field_mutable:google.protobuf.GeneratedCodeInfo.Annotation.source_file)\n  return source_file_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* GeneratedCodeInfo_Annotation::release_source_file() {\n  // @@protoc_insertion_point(field_release:google.protobuf.GeneratedCodeInfo.Annotation.source_file)\n  clear_has_source_file();\n  return source_file_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void GeneratedCodeInfo_Annotation::set_allocated_source_file(::std::string* source_file) {\n  if (source_file != NULL) {\n    set_has_source_file();\n  } else {\n    clear_has_source_file();\n  }\n  source_file_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), source_file);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.GeneratedCodeInfo.Annotation.source_file)\n}\n\n// optional int32 begin = 3;\ninline bool GeneratedCodeInfo_Annotation::has_begin() const {\n  return (_has_bits_[0] & 0x00000004u) != 0;\n}\ninline void GeneratedCodeInfo_Annotation::set_has_begin() {\n  _has_bits_[0] |= 0x00000004u;\n}\ninline void GeneratedCodeInfo_Annotation::clear_has_begin() {\n  _has_bits_[0] &= ~0x00000004u;\n}\ninline void GeneratedCodeInfo_Annotation::clear_begin() {\n  begin_ = 0;\n  clear_has_begin();\n}\ninline ::google::protobuf::int32 GeneratedCodeInfo_Annotation::begin() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.begin)\n  return begin_;\n}\ninline void GeneratedCodeInfo_Annotation::set_begin(::google::protobuf::int32 value) {\n  set_has_begin();\n  begin_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.begin)\n}\n\n// optional int32 end = 4;\ninline bool GeneratedCodeInfo_Annotation::has_end() const {\n  return (_has_bits_[0] & 0x00000008u) != 0;\n}\ninline void GeneratedCodeInfo_Annotation::set_has_end() {\n  _has_bits_[0] |= 0x00000008u;\n}\ninline void GeneratedCodeInfo_Annotation::clear_has_end() {\n  _has_bits_[0] &= ~0x00000008u;\n}\ninline void GeneratedCodeInfo_Annotation::clear_end() {\n  end_ = 0;\n  clear_has_end();\n}\ninline ::google::protobuf::int32 GeneratedCodeInfo_Annotation::end() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.Annotation.end)\n  return end_;\n}\ninline void GeneratedCodeInfo_Annotation::set_end(::google::protobuf::int32 value) {\n  set_has_end();\n  end_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.GeneratedCodeInfo.Annotation.end)\n}\n\n// -------------------------------------------------------------------\n\n// GeneratedCodeInfo\n\n// repeated .google.protobuf.GeneratedCodeInfo.Annotation annotation = 1;\ninline int GeneratedCodeInfo::annotation_size() const {\n  return annotation_.size();\n}\ninline void GeneratedCodeInfo::clear_annotation() {\n  annotation_.Clear();\n}\ninline const ::google::protobuf::GeneratedCodeInfo_Annotation& GeneratedCodeInfo::annotation(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.GeneratedCodeInfo.annotation)\n  return annotation_.Get(index);\n}\ninline ::google::protobuf::GeneratedCodeInfo_Annotation* GeneratedCodeInfo::mutable_annotation(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.GeneratedCodeInfo.annotation)\n  return annotation_.Mutable(index);\n}\ninline ::google::protobuf::GeneratedCodeInfo_Annotation* GeneratedCodeInfo::add_annotation() {\n  // @@protoc_insertion_point(field_add:google.protobuf.GeneratedCodeInfo.annotation)\n  return annotation_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation >*\nGeneratedCodeInfo::mutable_annotation() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.GeneratedCodeInfo.annotation)\n  return &annotation_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::GeneratedCodeInfo_Annotation >&\nGeneratedCodeInfo::annotation() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.GeneratedCodeInfo.annotation)\n  return annotation_;\n}\n\n#endif  // !PROTOBUF_INLINE_NOT_IN_HEADERS\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace protobuf\n}  // namespace google\n\n#ifndef SWIG\nnamespace google {\nnamespace protobuf {\n\ntemplate <> struct is_proto_enum< ::google::protobuf::FieldDescriptorProto_Type> : ::google::protobuf::internal::true_type {};\ntemplate <>\ninline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::FieldDescriptorProto_Type>() {\n  return ::google::protobuf::FieldDescriptorProto_Type_descriptor();\n}\ntemplate <> struct is_proto_enum< ::google::protobuf::FieldDescriptorProto_Label> : ::google::protobuf::internal::true_type {};\ntemplate <>\ninline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::FieldDescriptorProto_Label>() {\n  return ::google::protobuf::FieldDescriptorProto_Label_descriptor();\n}\ntemplate <> struct is_proto_enum< ::google::protobuf::FileOptions_OptimizeMode> : ::google::protobuf::internal::true_type {};\ntemplate <>\ninline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::FileOptions_OptimizeMode>() {\n  return ::google::protobuf::FileOptions_OptimizeMode_descriptor();\n}\ntemplate <> struct is_proto_enum< ::google::protobuf::FieldOptions_CType> : ::google::protobuf::internal::true_type {};\ntemplate <>\ninline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::FieldOptions_CType>() {\n  return ::google::protobuf::FieldOptions_CType_descriptor();\n}\ntemplate <> struct is_proto_enum< ::google::protobuf::FieldOptions_JSType> : ::google::protobuf::internal::true_type {};\ntemplate <>\ninline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::FieldOptions_JSType>() {\n  return ::google::protobuf::FieldOptions_JSType_descriptor();\n}\n\n}  // namespace protobuf\n}  // namespace google\n#endif  // SWIG\n\n// @@protoc_insertion_point(global_scope)\n\n#endif  // PROTOBUF_google_2fprotobuf_2fdescriptor_2eproto__INCLUDED\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/descriptor.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// The messages in this file describe the definitions found in .proto files.\n// A valid .proto file can be translated directly to a FileDescriptorProto\n// without any other information (e.g. without reading its imports).\n\n\nsyntax = \"proto2\";\n\npackage google.protobuf;\noption go_package = \"descriptor\";\noption java_package = \"com.google.protobuf\";\noption java_outer_classname = \"DescriptorProtos\";\noption csharp_namespace = \"Google.Protobuf.Reflection\";\noption objc_class_prefix = \"GPB\";\noption java_generate_equals_and_hash = true;\n\n// descriptor.proto must be optimized for speed because reflection-based\n// algorithms don't work during bootstrapping.\noption optimize_for = SPEED;\n\n// The protocol compiler can output a FileDescriptorSet containing the .proto\n// files it parses.\nmessage FileDescriptorSet {\n  repeated FileDescriptorProto file = 1;\n}\n\n// Describes a complete .proto file.\nmessage FileDescriptorProto {\n  optional string name = 1;       // file name, relative to root of source tree\n  optional string package = 2;    // e.g. \"foo\", \"foo.bar\", etc.\n\n  // Names of files imported by this file.\n  repeated string dependency = 3;\n  // Indexes of the public imported files in the dependency list above.\n  repeated int32 public_dependency = 10;\n  // Indexes of the weak imported files in the dependency list.\n  // For Google-internal migration only. Do not use.\n  repeated int32 weak_dependency = 11;\n\n  // All top-level definitions in this file.\n  repeated DescriptorProto message_type = 4;\n  repeated EnumDescriptorProto enum_type = 5;\n  repeated ServiceDescriptorProto service = 6;\n  repeated FieldDescriptorProto extension = 7;\n\n  optional FileOptions options = 8;\n\n  // This field contains optional information about the original source code.\n  // You may safely remove this entire field without harming runtime\n  // functionality of the descriptors -- the information is needed only by\n  // development tools.\n  optional SourceCodeInfo source_code_info = 9;\n\n  // The syntax of the proto file.\n  // The supported values are \"proto2\" and \"proto3\".\n  optional string syntax = 12;\n}\n\n// Describes a message type.\nmessage DescriptorProto {\n  optional string name = 1;\n\n  repeated FieldDescriptorProto field = 2;\n  repeated FieldDescriptorProto extension = 6;\n\n  repeated DescriptorProto nested_type = 3;\n  repeated EnumDescriptorProto enum_type = 4;\n\n  message ExtensionRange {\n    optional int32 start = 1;\n    optional int32 end = 2;\n  }\n  repeated ExtensionRange extension_range = 5;\n\n  repeated OneofDescriptorProto oneof_decl = 8;\n\n  optional MessageOptions options = 7;\n\n  // Range of reserved tag numbers. Reserved tag numbers may not be used by\n  // fields or extension ranges in the same message. Reserved ranges may\n  // not overlap.\n  message ReservedRange {\n    optional int32 start = 1; // Inclusive.\n    optional int32 end = 2;   // Exclusive.\n  }\n  repeated ReservedRange reserved_range = 9;\n  // Reserved field names, which may not be used by fields in the same message.\n  // A given name may only be reserved once.\n  repeated string reserved_name = 10;\n}\n\n// Describes a field within a message.\nmessage FieldDescriptorProto {\n  enum Type {\n    // 0 is reserved for errors.\n    // Order is weird for historical reasons.\n    TYPE_DOUBLE         = 1;\n    TYPE_FLOAT          = 2;\n    // Not ZigZag encoded.  Negative numbers take 10 bytes.  Use TYPE_SINT64 if\n    // negative values are likely.\n    TYPE_INT64          = 3;\n    TYPE_UINT64         = 4;\n    // Not ZigZag encoded.  Negative numbers take 10 bytes.  Use TYPE_SINT32 if\n    // negative values are likely.\n    TYPE_INT32          = 5;\n    TYPE_FIXED64        = 6;\n    TYPE_FIXED32        = 7;\n    TYPE_BOOL           = 8;\n    TYPE_STRING         = 9;\n    TYPE_GROUP          = 10;  // Tag-delimited aggregate.\n    TYPE_MESSAGE        = 11;  // Length-delimited aggregate.\n\n    // New in version 2.\n    TYPE_BYTES          = 12;\n    TYPE_UINT32         = 13;\n    TYPE_ENUM           = 14;\n    TYPE_SFIXED32       = 15;\n    TYPE_SFIXED64       = 16;\n    TYPE_SINT32         = 17;  // Uses ZigZag encoding.\n    TYPE_SINT64         = 18;  // Uses ZigZag encoding.\n  };\n\n  enum Label {\n    // 0 is reserved for errors\n    LABEL_OPTIONAL      = 1;\n    LABEL_REQUIRED      = 2;\n    LABEL_REPEATED      = 3;\n    // TODO(sanjay): Should we add LABEL_MAP?\n  };\n\n  optional string name = 1;\n  optional int32 number = 3;\n  optional Label label = 4;\n\n  // If type_name is set, this need not be set.  If both this and type_name\n  // are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP.\n  optional Type type = 5;\n\n  // For message and enum types, this is the name of the type.  If the name\n  // starts with a '.', it is fully-qualified.  Otherwise, C++-like scoping\n  // rules are used to find the type (i.e. first the nested types within this\n  // message are searched, then within the parent, on up to the root\n  // namespace).\n  optional string type_name = 6;\n\n  // For extensions, this is the name of the type being extended.  It is\n  // resolved in the same manner as type_name.\n  optional string extendee = 2;\n\n  // For numeric types, contains the original text representation of the value.\n  // For booleans, \"true\" or \"false\".\n  // For strings, contains the default text contents (not escaped in any way).\n  // For bytes, contains the C escaped value.  All bytes >= 128 are escaped.\n  // TODO(kenton):  Base-64 encode?\n  optional string default_value = 7;\n\n  // If set, gives the index of a oneof in the containing type's oneof_decl\n  // list.  This field is a member of that oneof.\n  optional int32 oneof_index = 9;\n\n  // JSON name of this field. The value is set by protocol compiler. If the\n  // user has set a \"json_name\" option on this field, that option's value\n  // will be used. Otherwise, it's deduced from the field's name by converting\n  // it to camelCase.\n  optional string json_name = 10;\n\n  optional FieldOptions options = 8;\n}\n\n// Describes a oneof.\nmessage OneofDescriptorProto {\n  optional string name = 1;\n  optional OneofOptions options = 2;\n}\n\n// Describes an enum type.\nmessage EnumDescriptorProto {\n  optional string name = 1;\n\n  repeated EnumValueDescriptorProto value = 2;\n\n  optional EnumOptions options = 3;\n}\n\n// Describes a value within an enum.\nmessage EnumValueDescriptorProto {\n  optional string name = 1;\n  optional int32 number = 2;\n\n  optional EnumValueOptions options = 3;\n}\n\n// Describes a service.\nmessage ServiceDescriptorProto {\n  optional string name = 1;\n  repeated MethodDescriptorProto method = 2;\n\n  optional ServiceOptions options = 3;\n}\n\n// Describes a method of a service.\nmessage MethodDescriptorProto {\n  optional string name = 1;\n\n  // Input and output type names.  These are resolved in the same way as\n  // FieldDescriptorProto.type_name, but must refer to a message type.\n  optional string input_type = 2;\n  optional string output_type = 3;\n\n  optional MethodOptions options = 4;\n\n  // Identifies if client streams multiple client messages\n  optional bool client_streaming = 5 [default=false];\n  // Identifies if server streams multiple server messages\n  optional bool server_streaming = 6 [default=false];\n}\n\n\n// ===================================================================\n// Options\n\n// Each of the definitions above may have \"options\" attached.  These are\n// just annotations which may cause code to be generated slightly differently\n// or may contain hints for code that manipulates protocol messages.\n//\n// Clients may define custom options as extensions of the *Options messages.\n// These extensions may not yet be known at parsing time, so the parser cannot\n// store the values in them.  Instead it stores them in a field in the *Options\n// message called uninterpreted_option. This field must have the same name\n// across all *Options messages. We then use this field to populate the\n// extensions when we build a descriptor, at which point all protos have been\n// parsed and so all extensions are known.\n//\n// Extension numbers for custom options may be chosen as follows:\n// * For options which will only be used within a single application or\n//   organization, or for experimental options, use field numbers 50000\n//   through 99999.  It is up to you to ensure that you do not use the\n//   same number for multiple options.\n// * For options which will be published and used publicly by multiple\n//   independent entities, e-mail protobuf-global-extension-registry@google.com\n//   to reserve extension numbers. Simply provide your project name (e.g.\n//   Objective-C plugin) and your project website (if available) -- there's no\n//   need to explain how you intend to use them. Usually you only need one\n//   extension number. You can declare multiple options with only one extension\n//   number by putting them in a sub-message. See the Custom Options section of\n//   the docs for examples:\n//   https://developers.google.com/protocol-buffers/docs/proto#options\n//   If this turns out to be popular, a web service will be set up\n//   to automatically assign option numbers.\n\n\nmessage FileOptions {\n\n  // Sets the Java package where classes generated from this .proto will be\n  // placed.  By default, the proto package is used, but this is often\n  // inappropriate because proto packages do not normally start with backwards\n  // domain names.\n  optional string java_package = 1;\n\n\n  // If set, all the classes from the .proto file are wrapped in a single\n  // outer class with the given name.  This applies to both Proto1\n  // (equivalent to the old \"--one_java_file\" option) and Proto2 (where\n  // a .proto always translates to a single class, but you may want to\n  // explicitly choose the class name).\n  optional string java_outer_classname = 8;\n\n  // If set true, then the Java code generator will generate a separate .java\n  // file for each top-level message, enum, and service defined in the .proto\n  // file.  Thus, these types will *not* be nested inside the outer class\n  // named by java_outer_classname.  However, the outer class will still be\n  // generated to contain the file's getDescriptor() method as well as any\n  // top-level extensions defined in the file.\n  optional bool java_multiple_files = 10 [default=false];\n\n  // If set true, then the Java code generator will generate equals() and\n  // hashCode() methods for all messages defined in the .proto file.\n  // This increases generated code size, potentially substantially for large\n  // protos, which may harm a memory-constrained application.\n  // - In the full runtime this is a speed optimization, as the\n  // AbstractMessage base class includes reflection-based implementations of\n  // these methods.\n  // - In the lite runtime, setting this option changes the semantics of\n  // equals() and hashCode() to more closely match those of the full runtime;\n  // the generated methods compute their results based on field values rather\n  // than object identity. (Implementations should not assume that hashcodes\n  // will be consistent across runtimes or versions of the protocol compiler.)\n  optional bool java_generate_equals_and_hash = 20 [default=false];\n\n  // If set true, then the Java2 code generator will generate code that\n  // throws an exception whenever an attempt is made to assign a non-UTF-8\n  // byte sequence to a string field.\n  // Message reflection will do the same.\n  // However, an extension field still accepts non-UTF-8 byte sequences.\n  // This option has no effect on when used with the lite runtime.\n  optional bool java_string_check_utf8 = 27 [default=false];\n\n\n  // Generated classes can be optimized for speed or code size.\n  enum OptimizeMode {\n    SPEED = 1;        // Generate complete code for parsing, serialization,\n                      // etc.\n    CODE_SIZE = 2;    // Use ReflectionOps to implement these methods.\n    LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime.\n  }\n  optional OptimizeMode optimize_for = 9 [default=SPEED];\n\n  // Sets the Go package where structs generated from this .proto will be\n  // placed. If omitted, the Go package will be derived from the following:\n  //   - The basename of the package import path, if provided.\n  //   - Otherwise, the package statement in the .proto file, if present.\n  //   - Otherwise, the basename of the .proto file, without extension.\n  optional string go_package = 11;\n\n\n\n  // Should generic services be generated in each language?  \"Generic\" services\n  // are not specific to any particular RPC system.  They are generated by the\n  // main code generators in each language (without additional plugins).\n  // Generic services were the only kind of service generation supported by\n  // early versions of google.protobuf.\n  //\n  // Generic services are now considered deprecated in favor of using plugins\n  // that generate code specific to your particular RPC system.  Therefore,\n  // these default to false.  Old code which depends on generic services should\n  // explicitly set them to true.\n  optional bool cc_generic_services = 16 [default=false];\n  optional bool java_generic_services = 17 [default=false];\n  optional bool py_generic_services = 18 [default=false];\n\n  // Is this file deprecated?\n  // Depending on the target platform, this can emit Deprecated annotations\n  // for everything in the file, or it will be completely ignored; in the very\n  // least, this is a formalization for deprecating files.\n  optional bool deprecated = 23 [default=false];\n\n  // Enables the use of arenas for the proto messages in this file. This applies\n  // only to generated classes for C++.\n  optional bool cc_enable_arenas = 31 [default=false];\n\n\n  // Sets the objective c class prefix which is prepended to all objective c\n  // generated classes from this .proto. There is no default.\n  optional string objc_class_prefix = 36;\n\n  // Namespace for generated classes; defaults to the package.\n  optional string csharp_namespace = 37;\n\n  // The parser stores options it doesn't recognize here. See above.\n  repeated UninterpretedOption uninterpreted_option = 999;\n\n  // Clients can define custom options in extensions of this message. See above.\n  extensions 1000 to max;\n\n  reserved 38;\n}\n\nmessage MessageOptions {\n  // Set true to use the old proto1 MessageSet wire format for extensions.\n  // This is provided for backwards-compatibility with the MessageSet wire\n  // format.  You should not use this for any other reason:  It's less\n  // efficient, has fewer features, and is more complicated.\n  //\n  // The message must be defined exactly as follows:\n  //   message Foo {\n  //     option message_set_wire_format = true;\n  //     extensions 4 to max;\n  //   }\n  // Note that the message cannot have any defined fields; MessageSets only\n  // have extensions.\n  //\n  // All extensions of your type must be singular messages; e.g. they cannot\n  // be int32s, enums, or repeated messages.\n  //\n  // Because this is an option, the above two restrictions are not enforced by\n  // the protocol compiler.\n  optional bool message_set_wire_format = 1 [default=false];\n\n  // Disables the generation of the standard \"descriptor()\" accessor, which can\n  // conflict with a field of the same name.  This is meant to make migration\n  // from proto1 easier; new code should avoid fields named \"descriptor\".\n  optional bool no_standard_descriptor_accessor = 2 [default=false];\n\n  // Is this message deprecated?\n  // Depending on the target platform, this can emit Deprecated annotations\n  // for the message, or it will be completely ignored; in the very least,\n  // this is a formalization for deprecating messages.\n  optional bool deprecated = 3 [default=false];\n\n  // Whether the message is an automatically generated map entry type for the\n  // maps field.\n  //\n  // For maps fields:\n  //     map<KeyType, ValueType> map_field = 1;\n  // The parsed descriptor looks like:\n  //     message MapFieldEntry {\n  //         option map_entry = true;\n  //         optional KeyType key = 1;\n  //         optional ValueType value = 2;\n  //     }\n  //     repeated MapFieldEntry map_field = 1;\n  //\n  // Implementations may choose not to generate the map_entry=true message, but\n  // use a native map in the target language to hold the keys and values.\n  // The reflection APIs in such implementions still need to work as\n  // if the field is a repeated message field.\n  //\n  // NOTE: Do not set the option in .proto files. Always use the maps syntax\n  // instead. The option should only be implicitly set by the proto compiler\n  // parser.\n  optional bool map_entry = 7;\n\n  // The parser stores options it doesn't recognize here. See above.\n  repeated UninterpretedOption uninterpreted_option = 999;\n\n  // Clients can define custom options in extensions of this message. See above.\n  extensions 1000 to max;\n}\n\nmessage FieldOptions {\n  // The ctype option instructs the C++ code generator to use a different\n  // representation of the field than it normally would.  See the specific\n  // options below.  This option is not yet implemented in the open source\n  // release -- sorry, we'll try to include it in a future version!\n  optional CType ctype = 1 [default = STRING];\n  enum CType {\n    // Default mode.\n    STRING = 0;\n\n    CORD = 1;\n\n    STRING_PIECE = 2;\n  }\n  // The packed option can be enabled for repeated primitive fields to enable\n  // a more efficient representation on the wire. Rather than repeatedly\n  // writing the tag and type for each element, the entire array is encoded as\n  // a single length-delimited blob. In proto3, only explicit setting it to\n  // false will avoid using packed encoding.\n  optional bool packed = 2;\n\n\n  // The jstype option determines the JavaScript type used for values of the\n  // field.  The option is permitted only for 64 bit integral and fixed types\n  // (int64, uint64, sint64, fixed64, sfixed64).  By default these types are\n  // represented as JavaScript strings.  This avoids loss of precision that can\n  // happen when a large value is converted to a floating point JavaScript\n  // numbers.  Specifying JS_NUMBER for the jstype causes the generated\n  // JavaScript code to use the JavaScript \"number\" type instead of strings.\n  // This option is an enum to permit additional types to be added,\n  // e.g. goog.math.Integer.\n  optional JSType jstype = 6 [default = JS_NORMAL];\n  enum JSType {\n    // Use the default type.\n    JS_NORMAL = 0;\n\n    // Use JavaScript strings.\n    JS_STRING = 1;\n\n    // Use JavaScript numbers.\n    JS_NUMBER = 2;\n  }\n\n  // Should this field be parsed lazily?  Lazy applies only to message-type\n  // fields.  It means that when the outer message is initially parsed, the\n  // inner message's contents will not be parsed but instead stored in encoded\n  // form.  The inner message will actually be parsed when it is first accessed.\n  //\n  // This is only a hint.  Implementations are free to choose whether to use\n  // eager or lazy parsing regardless of the value of this option.  However,\n  // setting this option true suggests that the protocol author believes that\n  // using lazy parsing on this field is worth the additional bookkeeping\n  // overhead typically needed to implement it.\n  //\n  // This option does not affect the public interface of any generated code;\n  // all method signatures remain the same.  Furthermore, thread-safety of the\n  // interface is not affected by this option; const methods remain safe to\n  // call from multiple threads concurrently, while non-const methods continue\n  // to require exclusive access.\n  //\n  //\n  // Note that implementations may choose not to check required fields within\n  // a lazy sub-message.  That is, calling IsInitialized() on the outher message\n  // may return true even if the inner message has missing required fields.\n  // This is necessary because otherwise the inner message would have to be\n  // parsed in order to perform the check, defeating the purpose of lazy\n  // parsing.  An implementation which chooses not to check required fields\n  // must be consistent about it.  That is, for any particular sub-message, the\n  // implementation must either *always* check its required fields, or *never*\n  // check its required fields, regardless of whether or not the message has\n  // been parsed.\n  optional bool lazy = 5 [default=false];\n\n  // Is this field deprecated?\n  // Depending on the target platform, this can emit Deprecated annotations\n  // for accessors, or it will be completely ignored; in the very least, this\n  // is a formalization for deprecating fields.\n  optional bool deprecated = 3 [default=false];\n\n  // For Google-internal migration only. Do not use.\n  optional bool weak = 10 [default=false];\n\n\n  // The parser stores options it doesn't recognize here. See above.\n  repeated UninterpretedOption uninterpreted_option = 999;\n\n  // Clients can define custom options in extensions of this message. See above.\n  extensions 1000 to max;\n}\n\nmessage OneofOptions {\n  // The parser stores options it doesn't recognize here. See above.\n  repeated UninterpretedOption uninterpreted_option = 999;\n\n  // Clients can define custom options in extensions of this message. See above.\n  extensions 1000 to max;\n}\n\nmessage EnumOptions {\n\n  // Set this option to true to allow mapping different tag names to the same\n  // value.\n  optional bool allow_alias = 2;\n\n  // Is this enum deprecated?\n  // Depending on the target platform, this can emit Deprecated annotations\n  // for the enum, or it will be completely ignored; in the very least, this\n  // is a formalization for deprecating enums.\n  optional bool deprecated = 3 [default=false];\n\n  // The parser stores options it doesn't recognize here. See above.\n  repeated UninterpretedOption uninterpreted_option = 999;\n\n  // Clients can define custom options in extensions of this message. See above.\n  extensions 1000 to max;\n}\n\nmessage EnumValueOptions {\n  // Is this enum value deprecated?\n  // Depending on the target platform, this can emit Deprecated annotations\n  // for the enum value, or it will be completely ignored; in the very least,\n  // this is a formalization for deprecating enum values.\n  optional bool deprecated = 1 [default=false];\n\n  // The parser stores options it doesn't recognize here. See above.\n  repeated UninterpretedOption uninterpreted_option = 999;\n\n  // Clients can define custom options in extensions of this message. See above.\n  extensions 1000 to max;\n}\n\nmessage ServiceOptions {\n\n  // Note:  Field numbers 1 through 32 are reserved for Google's internal RPC\n  //   framework.  We apologize for hoarding these numbers to ourselves, but\n  //   we were already using them long before we decided to release Protocol\n  //   Buffers.\n\n  // Is this service deprecated?\n  // Depending on the target platform, this can emit Deprecated annotations\n  // for the service, or it will be completely ignored; in the very least,\n  // this is a formalization for deprecating services.\n  optional bool deprecated = 33 [default=false];\n\n  // The parser stores options it doesn't recognize here. See above.\n  repeated UninterpretedOption uninterpreted_option = 999;\n\n  // Clients can define custom options in extensions of this message. See above.\n  extensions 1000 to max;\n}\n\nmessage MethodOptions {\n\n  // Note:  Field numbers 1 through 32 are reserved for Google's internal RPC\n  //   framework.  We apologize for hoarding these numbers to ourselves, but\n  //   we were already using them long before we decided to release Protocol\n  //   Buffers.\n\n  // Is this method deprecated?\n  // Depending on the target platform, this can emit Deprecated annotations\n  // for the method, or it will be completely ignored; in the very least,\n  // this is a formalization for deprecating methods.\n  optional bool deprecated = 33 [default=false];\n\n  // The parser stores options it doesn't recognize here. See above.\n  repeated UninterpretedOption uninterpreted_option = 999;\n\n  // Clients can define custom options in extensions of this message. See above.\n  extensions 1000 to max;\n}\n\n\n// A message representing a option the parser does not recognize. This only\n// appears in options protos created by the compiler::Parser class.\n// DescriptorPool resolves these when building Descriptor objects. Therefore,\n// options protos in descriptor objects (e.g. returned by Descriptor::options(),\n// or produced by Descriptor::CopyTo()) will never have UninterpretedOptions\n// in them.\nmessage UninterpretedOption {\n  // The name of the uninterpreted option.  Each string represents a segment in\n  // a dot-separated name.  is_extension is true iff a segment represents an\n  // extension (denoted with parentheses in options specs in .proto files).\n  // E.g.,{ [\"foo\", false], [\"bar.baz\", true], [\"qux\", false] } represents\n  // \"foo.(bar.baz).qux\".\n  message NamePart {\n    required string name_part = 1;\n    required bool is_extension = 2;\n  }\n  repeated NamePart name = 2;\n\n  // The value of the uninterpreted option, in whatever type the tokenizer\n  // identified it as during parsing. Exactly one of these should be set.\n  optional string identifier_value = 3;\n  optional uint64 positive_int_value = 4;\n  optional int64 negative_int_value = 5;\n  optional double double_value = 6;\n  optional bytes string_value = 7;\n  optional string aggregate_value = 8;\n}\n\n// ===================================================================\n// Optional source code info\n\n// Encapsulates information about the original source file from which a\n// FileDescriptorProto was generated.\nmessage SourceCodeInfo {\n  // A Location identifies a piece of source code in a .proto file which\n  // corresponds to a particular definition.  This information is intended\n  // to be useful to IDEs, code indexers, documentation generators, and similar\n  // tools.\n  //\n  // For example, say we have a file like:\n  //   message Foo {\n  //     optional string foo = 1;\n  //   }\n  // Let's look at just the field definition:\n  //   optional string foo = 1;\n  //   ^       ^^     ^^  ^  ^^^\n  //   a       bc     de  f  ghi\n  // We have the following locations:\n  //   span   path               represents\n  //   [a,i)  [ 4, 0, 2, 0 ]     The whole field definition.\n  //   [a,b)  [ 4, 0, 2, 0, 4 ]  The label (optional).\n  //   [c,d)  [ 4, 0, 2, 0, 5 ]  The type (string).\n  //   [e,f)  [ 4, 0, 2, 0, 1 ]  The name (foo).\n  //   [g,h)  [ 4, 0, 2, 0, 3 ]  The number (1).\n  //\n  // Notes:\n  // - A location may refer to a repeated field itself (i.e. not to any\n  //   particular index within it).  This is used whenever a set of elements are\n  //   logically enclosed in a single code segment.  For example, an entire\n  //   extend block (possibly containing multiple extension definitions) will\n  //   have an outer location whose path refers to the \"extensions\" repeated\n  //   field without an index.\n  // - Multiple locations may have the same path.  This happens when a single\n  //   logical declaration is spread out across multiple places.  The most\n  //   obvious example is the \"extend\" block again -- there may be multiple\n  //   extend blocks in the same scope, each of which will have the same path.\n  // - A location's span is not always a subset of its parent's span.  For\n  //   example, the \"extendee\" of an extension declaration appears at the\n  //   beginning of the \"extend\" block and is shared by all extensions within\n  //   the block.\n  // - Just because a location's span is a subset of some other location's span\n  //   does not mean that it is a descendent.  For example, a \"group\" defines\n  //   both a type and a field in a single declaration.  Thus, the locations\n  //   corresponding to the type and field and their components will overlap.\n  // - Code which tries to interpret locations should probably be designed to\n  //   ignore those that it doesn't understand, as more types of locations could\n  //   be recorded in the future.\n  repeated Location location = 1;\n  message Location {\n    // Identifies which part of the FileDescriptorProto was defined at this\n    // location.\n    //\n    // Each element is a field number or an index.  They form a path from\n    // the root FileDescriptorProto to the place where the definition.  For\n    // example, this path:\n    //   [ 4, 3, 2, 7, 1 ]\n    // refers to:\n    //   file.message_type(3)  // 4, 3\n    //       .field(7)         // 2, 7\n    //       .name()           // 1\n    // This is because FileDescriptorProto.message_type has field number 4:\n    //   repeated DescriptorProto message_type = 4;\n    // and DescriptorProto.field has field number 2:\n    //   repeated FieldDescriptorProto field = 2;\n    // and FieldDescriptorProto.name has field number 1:\n    //   optional string name = 1;\n    //\n    // Thus, the above path gives the location of a field name.  If we removed\n    // the last element:\n    //   [ 4, 3, 2, 7 ]\n    // this path refers to the whole field declaration (from the beginning\n    // of the label to the terminating semicolon).\n    repeated int32 path = 1 [packed=true];\n\n    // Always has exactly three or four elements: start line, start column,\n    // end line (optional, otherwise assumed same as start line), end column.\n    // These are packed into a single field for efficiency.  Note that line\n    // and column numbers are zero-based -- typically you will want to add\n    // 1 to each before displaying to a user.\n    repeated int32 span = 2 [packed=true];\n\n    // If this SourceCodeInfo represents a complete declaration, these are any\n    // comments appearing before and after the declaration which appear to be\n    // attached to the declaration.\n    //\n    // A series of line comments appearing on consecutive lines, with no other\n    // tokens appearing on those lines, will be treated as a single comment.\n    //\n    // leading_detached_comments will keep paragraphs of comments that appear\n    // before (but not connected to) the current element. Each paragraph,\n    // separated by empty lines, will be one comment element in the repeated\n    // field.\n    //\n    // Only the comment content is provided; comment markers (e.g. //) are\n    // stripped out.  For block comments, leading whitespace and an asterisk\n    // will be stripped from the beginning of each line other than the first.\n    // Newlines are included in the output.\n    //\n    // Examples:\n    //\n    //   optional int32 foo = 1;  // Comment attached to foo.\n    //   // Comment attached to bar.\n    //   optional int32 bar = 2;\n    //\n    //   optional string baz = 3;\n    //   // Comment attached to baz.\n    //   // Another line attached to baz.\n    //\n    //   // Comment attached to qux.\n    //   //\n    //   // Another line attached to qux.\n    //   optional double qux = 4;\n    //\n    //   // Detached comment for corge. This is not leading or trailing comments\n    //   // to qux or corge because there are blank lines separating it from\n    //   // both.\n    //\n    //   // Detached comment for corge paragraph 2.\n    //\n    //   optional string corge = 5;\n    //   /* Block comment attached\n    //    * to corge.  Leading asterisks\n    //    * will be removed. */\n    //   /* Block comment attached to\n    //    * grault. */\n    //   optional int32 grault = 6;\n    //\n    //   // ignored detached comments.\n    optional string leading_comments = 3;\n    optional string trailing_comments = 4;\n    repeated string leading_detached_comments = 6;\n  }\n}\n\n// Describes the relationship between generated code and its original source\n// file. A GeneratedCodeInfo message is associated with only one generated\n// source file, but may contain references to different source .proto files.\nmessage GeneratedCodeInfo {\n  // An Annotation connects some span of text in generated code to an element\n  // of its generating .proto file.\n  repeated Annotation annotation = 1;\n  message Annotation {\n    // Identifies the element in the original source .proto file. This field\n    // is formatted the same as SourceCodeInfo.Location.path.\n    repeated int32 path = 1 [packed=true];\n\n    // Identifies the filesystem path to the original source .proto.\n    optional string source_file = 2;\n\n    // Identifies the starting offset in bytes in the generated code\n    // that relates to the identified object.\n    optional int32 begin = 3;\n\n    // Identifies the ending offset in bytes in the generated code that\n    // relates to the identified offset. The end offset should be one past\n    // the last relevant byte (so the length of the text = end - begin).\n    optional int32 end = 4;\n  }\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/descriptor_database.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/descriptor_database.h>\n\n#include <set>\n\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/stl_util.h>\n#include <google/protobuf/stubs/map_util.h>\n\nnamespace google {\nnamespace protobuf {\n\nDescriptorDatabase::~DescriptorDatabase() {}\n\n// ===================================================================\n\ntemplate <typename Value>\nbool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddFile(\n    const FileDescriptorProto& file,\n    Value value) {\n  if (!InsertIfNotPresent(&by_name_, file.name(), value)) {\n    GOOGLE_LOG(ERROR) << \"File already exists in database: \" << file.name();\n    return false;\n  }\n\n  // We must be careful here -- calling file.package() if file.has_package() is\n  // false could access an uninitialized static-storage variable if we are being\n  // run at startup time.\n  string path = file.has_package() ? file.package() : string();\n  if (!path.empty()) path += '.';\n\n  for (int i = 0; i < file.message_type_size(); i++) {\n    if (!AddSymbol(path + file.message_type(i).name(), value)) return false;\n    if (!AddNestedExtensions(file.message_type(i), value)) return false;\n  }\n  for (int i = 0; i < file.enum_type_size(); i++) {\n    if (!AddSymbol(path + file.enum_type(i).name(), value)) return false;\n  }\n  for (int i = 0; i < file.extension_size(); i++) {\n    if (!AddSymbol(path + file.extension(i).name(), value)) return false;\n    if (!AddExtension(file.extension(i), value)) return false;\n  }\n  for (int i = 0; i < file.service_size(); i++) {\n    if (!AddSymbol(path + file.service(i).name(), value)) return false;\n  }\n\n  return true;\n}\n\ntemplate <typename Value>\nbool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddSymbol(\n    const string& name, Value value) {\n  // We need to make sure not to violate our map invariant.\n\n  // If the symbol name is invalid it could break our lookup algorithm (which\n  // relies on the fact that '.' sorts before all other characters that are\n  // valid in symbol names).\n  if (!ValidateSymbolName(name)) {\n    GOOGLE_LOG(ERROR) << \"Invalid symbol name: \" << name;\n    return false;\n  }\n\n  // Try to look up the symbol to make sure a super-symbol doesn't already\n  // exist.\n  typename map<string, Value>::iterator iter = FindLastLessOrEqual(name);\n\n  if (iter == by_symbol_.end()) {\n    // Apparently the map is currently empty.  Just insert and be done with it.\n    by_symbol_.insert(typename map<string, Value>::value_type(name, value));\n    return true;\n  }\n\n  if (IsSubSymbol(iter->first, name)) {\n    GOOGLE_LOG(ERROR) << \"Symbol name \\\"\" << name << \"\\\" conflicts with the existing \"\n                  \"symbol \\\"\" << iter->first << \"\\\".\";\n    return false;\n  }\n\n  // OK, that worked.  Now we have to make sure that no symbol in the map is\n  // a sub-symbol of the one we are inserting.  The only symbol which could\n  // be so is the first symbol that is greater than the new symbol.  Since\n  // |iter| points at the last symbol that is less than or equal, we just have\n  // to increment it.\n  ++iter;\n\n  if (iter != by_symbol_.end() && IsSubSymbol(name, iter->first)) {\n    GOOGLE_LOG(ERROR) << \"Symbol name \\\"\" << name << \"\\\" conflicts with the existing \"\n                  \"symbol \\\"\" << iter->first << \"\\\".\";\n    return false;\n  }\n\n  // OK, no conflicts.\n\n  // Insert the new symbol using the iterator as a hint, the new entry will\n  // appear immediately before the one the iterator is pointing at.\n  by_symbol_.insert(iter, typename map<string, Value>::value_type(name, value));\n\n  return true;\n}\n\ntemplate <typename Value>\nbool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddNestedExtensions(\n    const DescriptorProto& message_type,\n    Value value) {\n  for (int i = 0; i < message_type.nested_type_size(); i++) {\n    if (!AddNestedExtensions(message_type.nested_type(i), value)) return false;\n  }\n  for (int i = 0; i < message_type.extension_size(); i++) {\n    if (!AddExtension(message_type.extension(i), value)) return false;\n  }\n  return true;\n}\n\ntemplate <typename Value>\nbool SimpleDescriptorDatabase::DescriptorIndex<Value>::AddExtension(\n    const FieldDescriptorProto& field,\n    Value value) {\n  if (!field.extendee().empty() && field.extendee()[0] == '.') {\n    // The extension is fully-qualified.  We can use it as a lookup key in\n    // the by_symbol_ table.\n    if (!InsertIfNotPresent(\n            &by_extension_,\n            std::make_pair(field.extendee().substr(1), field.number()),\n            value)) {\n      GOOGLE_LOG(ERROR) << \"Extension conflicts with extension already in database: \"\n                    \"extend \" << field.extendee() << \" { \"\n                 << field.name() << \" = \" << field.number() << \" }\";\n      return false;\n    }\n  } else {\n    // Not fully-qualified.  We can't really do anything here, unfortunately.\n    // We don't consider this an error, though, because the descriptor is\n    // valid.\n  }\n  return true;\n}\n\ntemplate <typename Value>\nValue SimpleDescriptorDatabase::DescriptorIndex<Value>::FindFile(\n    const string& filename) {\n  return FindWithDefault(by_name_, filename, Value());\n}\n\ntemplate <typename Value>\nValue SimpleDescriptorDatabase::DescriptorIndex<Value>::FindSymbol(\n    const string& name) {\n  typename map<string, Value>::iterator iter = FindLastLessOrEqual(name);\n\n  return (iter != by_symbol_.end() && IsSubSymbol(iter->first, name)) ?\n         iter->second : Value();\n}\n\ntemplate <typename Value>\nValue SimpleDescriptorDatabase::DescriptorIndex<Value>::FindExtension(\n    const string& containing_type,\n    int field_number) {\n  return FindWithDefault(\n      by_extension_, std::make_pair(containing_type, field_number), Value());\n}\n\ntemplate <typename Value>\nbool SimpleDescriptorDatabase::DescriptorIndex<Value>::FindAllExtensionNumbers(\n    const string& containing_type,\n    vector<int>* output) {\n  typename map<pair<string, int>, Value>::const_iterator it =\n      by_extension_.lower_bound(std::make_pair(containing_type, 0));\n  bool success = false;\n\n  for (; it != by_extension_.end() && it->first.first == containing_type;\n       ++it) {\n    output->push_back(it->first.second);\n    success = true;\n  }\n\n  return success;\n}\n\ntemplate <typename Value>\ntypename map<string, Value>::iterator\nSimpleDescriptorDatabase::DescriptorIndex<Value>::FindLastLessOrEqual(\n    const string& name) {\n  // Find the last key in the map which sorts less than or equal to the\n  // symbol name.  Since upper_bound() returns the *first* key that sorts\n  // *greater* than the input, we want the element immediately before that.\n  typename map<string, Value>::iterator iter = by_symbol_.upper_bound(name);\n  if (iter != by_symbol_.begin()) --iter;\n  return iter;\n}\n\ntemplate <typename Value>\nbool SimpleDescriptorDatabase::DescriptorIndex<Value>::IsSubSymbol(\n    const string& sub_symbol, const string& super_symbol) {\n  return sub_symbol == super_symbol ||\n         (HasPrefixString(super_symbol, sub_symbol) &&\n             super_symbol[sub_symbol.size()] == '.');\n}\n\ntemplate <typename Value>\nbool SimpleDescriptorDatabase::DescriptorIndex<Value>::ValidateSymbolName(\n    const string& name) {\n  for (int i = 0; i < name.size(); i++) {\n    // I don't trust ctype.h due to locales.  :(\n    if (name[i] != '.' && name[i] != '_' &&\n        (name[i] < '0' || name[i] > '9') &&\n        (name[i] < 'A' || name[i] > 'Z') &&\n        (name[i] < 'a' || name[i] > 'z')) {\n      return false;\n    }\n  }\n  return true;\n}\n\n// -------------------------------------------------------------------\n\nSimpleDescriptorDatabase::SimpleDescriptorDatabase() {}\nSimpleDescriptorDatabase::~SimpleDescriptorDatabase() {\n  STLDeleteElements(&files_to_delete_);\n}\n\nbool SimpleDescriptorDatabase::Add(const FileDescriptorProto& file) {\n  FileDescriptorProto* new_file = new FileDescriptorProto;\n  new_file->CopyFrom(file);\n  return AddAndOwn(new_file);\n}\n\nbool SimpleDescriptorDatabase::AddAndOwn(const FileDescriptorProto* file) {\n  files_to_delete_.push_back(file);\n  return index_.AddFile(*file, file);\n}\n\nbool SimpleDescriptorDatabase::FindFileByName(\n    const string& filename,\n    FileDescriptorProto* output) {\n  return MaybeCopy(index_.FindFile(filename), output);\n}\n\nbool SimpleDescriptorDatabase::FindFileContainingSymbol(\n    const string& symbol_name,\n    FileDescriptorProto* output) {\n  return MaybeCopy(index_.FindSymbol(symbol_name), output);\n}\n\nbool SimpleDescriptorDatabase::FindFileContainingExtension(\n    const string& containing_type,\n    int field_number,\n    FileDescriptorProto* output) {\n  return MaybeCopy(index_.FindExtension(containing_type, field_number), output);\n}\n\nbool SimpleDescriptorDatabase::FindAllExtensionNumbers(\n    const string& extendee_type,\n    vector<int>* output) {\n  return index_.FindAllExtensionNumbers(extendee_type, output);\n}\n\n\nbool SimpleDescriptorDatabase::MaybeCopy(const FileDescriptorProto* file,\n                                         FileDescriptorProto* output) {\n  if (file == NULL) return false;\n  output->CopyFrom(*file);\n  return true;\n}\n\n// -------------------------------------------------------------------\n\nEncodedDescriptorDatabase::EncodedDescriptorDatabase() {}\nEncodedDescriptorDatabase::~EncodedDescriptorDatabase() {\n  for (int i = 0; i < files_to_delete_.size(); i++) {\n    operator delete(files_to_delete_[i]);\n  }\n}\n\nbool EncodedDescriptorDatabase::Add(\n    const void* encoded_file_descriptor, int size) {\n  FileDescriptorProto file;\n  if (file.ParseFromArray(encoded_file_descriptor, size)) {\n    return index_.AddFile(file, std::make_pair(encoded_file_descriptor, size));\n  } else {\n    GOOGLE_LOG(ERROR) << \"Invalid file descriptor data passed to \"\n                  \"EncodedDescriptorDatabase::Add().\";\n    return false;\n  }\n}\n\nbool EncodedDescriptorDatabase::AddCopy(\n    const void* encoded_file_descriptor, int size) {\n  void* copy = operator new(size);\n  memcpy(copy, encoded_file_descriptor, size);\n  files_to_delete_.push_back(copy);\n  return Add(copy, size);\n}\n\nbool EncodedDescriptorDatabase::FindFileByName(\n    const string& filename,\n    FileDescriptorProto* output) {\n  return MaybeParse(index_.FindFile(filename), output);\n}\n\nbool EncodedDescriptorDatabase::FindFileContainingSymbol(\n    const string& symbol_name,\n    FileDescriptorProto* output) {\n  return MaybeParse(index_.FindSymbol(symbol_name), output);\n}\n\nbool EncodedDescriptorDatabase::FindNameOfFileContainingSymbol(\n    const string& symbol_name,\n    string* output) {\n  pair<const void*, int> encoded_file = index_.FindSymbol(symbol_name);\n  if (encoded_file.first == NULL) return false;\n\n  // Optimization:  The name should be the first field in the encoded message.\n  //   Try to just read it directly.\n  io::CodedInputStream input(reinterpret_cast<const uint8*>(encoded_file.first),\n                             encoded_file.second);\n\n  const uint32 kNameTag = internal::WireFormatLite::MakeTag(\n      FileDescriptorProto::kNameFieldNumber,\n      internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED);\n\n  if (input.ReadTag() == kNameTag) {\n    // Success!\n    return internal::WireFormatLite::ReadString(&input, output);\n  } else {\n    // Slow path.  Parse whole message.\n    FileDescriptorProto file_proto;\n    if (!file_proto.ParseFromArray(encoded_file.first, encoded_file.second)) {\n      return false;\n    }\n    *output = file_proto.name();\n    return true;\n  }\n}\n\nbool EncodedDescriptorDatabase::FindFileContainingExtension(\n    const string& containing_type,\n    int field_number,\n    FileDescriptorProto* output) {\n  return MaybeParse(index_.FindExtension(containing_type, field_number),\n                    output);\n}\n\nbool EncodedDescriptorDatabase::FindAllExtensionNumbers(\n    const string& extendee_type,\n    vector<int>* output) {\n  return index_.FindAllExtensionNumbers(extendee_type, output);\n}\n\nbool EncodedDescriptorDatabase::MaybeParse(\n    pair<const void*, int> encoded_file,\n    FileDescriptorProto* output) {\n  if (encoded_file.first == NULL) return false;\n  return output->ParseFromArray(encoded_file.first, encoded_file.second);\n}\n\n// ===================================================================\n\nDescriptorPoolDatabase::DescriptorPoolDatabase(const DescriptorPool& pool)\n  : pool_(pool) {}\nDescriptorPoolDatabase::~DescriptorPoolDatabase() {}\n\nbool DescriptorPoolDatabase::FindFileByName(\n    const string& filename,\n    FileDescriptorProto* output) {\n  const FileDescriptor* file = pool_.FindFileByName(filename);\n  if (file == NULL) return false;\n  output->Clear();\n  file->CopyTo(output);\n  return true;\n}\n\nbool DescriptorPoolDatabase::FindFileContainingSymbol(\n    const string& symbol_name,\n    FileDescriptorProto* output) {\n  const FileDescriptor* file = pool_.FindFileContainingSymbol(symbol_name);\n  if (file == NULL) return false;\n  output->Clear();\n  file->CopyTo(output);\n  return true;\n}\n\nbool DescriptorPoolDatabase::FindFileContainingExtension(\n    const string& containing_type,\n    int field_number,\n    FileDescriptorProto* output) {\n  const Descriptor* extendee = pool_.FindMessageTypeByName(containing_type);\n  if (extendee == NULL) return false;\n\n  const FieldDescriptor* extension =\n    pool_.FindExtensionByNumber(extendee, field_number);\n  if (extension == NULL) return false;\n\n  output->Clear();\n  extension->file()->CopyTo(output);\n  return true;\n}\n\nbool DescriptorPoolDatabase::FindAllExtensionNumbers(\n    const string& extendee_type,\n    vector<int>* output) {\n  const Descriptor* extendee = pool_.FindMessageTypeByName(extendee_type);\n  if (extendee == NULL) return false;\n\n  vector<const FieldDescriptor*> extensions;\n  pool_.FindAllExtensions(extendee, &extensions);\n\n  for (int i = 0; i < extensions.size(); ++i) {\n    output->push_back(extensions[i]->number());\n  }\n\n  return true;\n}\n\n// ===================================================================\n\nMergedDescriptorDatabase::MergedDescriptorDatabase(\n    DescriptorDatabase* source1,\n    DescriptorDatabase* source2) {\n  sources_.push_back(source1);\n  sources_.push_back(source2);\n}\nMergedDescriptorDatabase::MergedDescriptorDatabase(\n    const vector<DescriptorDatabase*>& sources)\n  : sources_(sources) {}\nMergedDescriptorDatabase::~MergedDescriptorDatabase() {}\n\nbool MergedDescriptorDatabase::FindFileByName(\n    const string& filename,\n    FileDescriptorProto* output) {\n  for (int i = 0; i < sources_.size(); i++) {\n    if (sources_[i]->FindFileByName(filename, output)) {\n      return true;\n    }\n  }\n  return false;\n}\n\nbool MergedDescriptorDatabase::FindFileContainingSymbol(\n    const string& symbol_name,\n    FileDescriptorProto* output) {\n  for (int i = 0; i < sources_.size(); i++) {\n    if (sources_[i]->FindFileContainingSymbol(symbol_name, output)) {\n      // The symbol was found in source i.  However, if one of the previous\n      // sources defines a file with the same name (which presumably doesn't\n      // contain the symbol, since it wasn't found in that source), then we\n      // must hide it from the caller.\n      FileDescriptorProto temp;\n      for (int j = 0; j < i; j++) {\n        if (sources_[j]->FindFileByName(output->name(), &temp)) {\n          // Found conflicting file in a previous source.\n          return false;\n        }\n      }\n      return true;\n    }\n  }\n  return false;\n}\n\nbool MergedDescriptorDatabase::FindFileContainingExtension(\n    const string& containing_type,\n    int field_number,\n    FileDescriptorProto* output) {\n  for (int i = 0; i < sources_.size(); i++) {\n    if (sources_[i]->FindFileContainingExtension(\n          containing_type, field_number, output)) {\n      // The symbol was found in source i.  However, if one of the previous\n      // sources defines a file with the same name (which presumably doesn't\n      // contain the symbol, since it wasn't found in that source), then we\n      // must hide it from the caller.\n      FileDescriptorProto temp;\n      for (int j = 0; j < i; j++) {\n        if (sources_[j]->FindFileByName(output->name(), &temp)) {\n          // Found conflicting file in a previous source.\n          return false;\n        }\n      }\n      return true;\n    }\n  }\n  return false;\n}\n\nbool MergedDescriptorDatabase::FindAllExtensionNumbers(\n    const string& extendee_type,\n    vector<int>* output) {\n  set<int> merged_results;\n  vector<int> results;\n  bool success = false;\n\n  for (int i = 0; i < sources_.size(); i++) {\n    if (sources_[i]->FindAllExtensionNumbers(extendee_type, &results)) {\n      std::copy(\n          results.begin(), results.end(),\n          insert_iterator<set<int> >(merged_results, merged_results.begin()));\n      success = true;\n    }\n    results.clear();\n  }\n\n  std::copy(merged_results.begin(), merged_results.end(),\n            insert_iterator<vector<int> >(*output, output->end()));\n\n  return success;\n}\n\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/descriptor_database.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Interface for manipulating databases of descriptors.\n\n#ifndef GOOGLE_PROTOBUF_DESCRIPTOR_DATABASE_H__\n#define GOOGLE_PROTOBUF_DESCRIPTOR_DATABASE_H__\n\n#include <map>\n#include <string>\n#include <utility>\n#include <vector>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/descriptor.h>\n\nnamespace google {\nnamespace protobuf {\n\n// Defined in this file.\nclass DescriptorDatabase;\nclass SimpleDescriptorDatabase;\nclass EncodedDescriptorDatabase;\nclass DescriptorPoolDatabase;\nclass MergedDescriptorDatabase;\n\n// Abstract interface for a database of descriptors.\n//\n// This is useful if you want to create a DescriptorPool which loads\n// descriptors on-demand from some sort of large database.  If the database\n// is large, it may be inefficient to enumerate every .proto file inside it\n// calling DescriptorPool::BuildFile() for each one.  Instead, a DescriptorPool\n// can be created which wraps a DescriptorDatabase and only builds particular\n// descriptors when they are needed.\nclass LIBPROTOBUF_EXPORT DescriptorDatabase {\n public:\n  inline DescriptorDatabase() {}\n  virtual ~DescriptorDatabase();\n\n  // Find a file by file name.  Fills in in *output and returns true if found.\n  // Otherwise, returns false, leaving the contents of *output undefined.\n  virtual bool FindFileByName(const string& filename,\n                              FileDescriptorProto* output) = 0;\n\n  // Find the file that declares the given fully-qualified symbol name.\n  // If found, fills in *output and returns true, otherwise returns false\n  // and leaves *output undefined.\n  virtual bool FindFileContainingSymbol(const string& symbol_name,\n                                        FileDescriptorProto* output) = 0;\n\n  // Find the file which defines an extension extending the given message type\n  // with the given field number.  If found, fills in *output and returns true,\n  // otherwise returns false and leaves *output undefined.  containing_type\n  // must be a fully-qualified type name.\n  virtual bool FindFileContainingExtension(const string& containing_type,\n                                           int field_number,\n                                           FileDescriptorProto* output) = 0;\n\n  // Finds the tag numbers used by all known extensions of\n  // extendee_type, and appends them to output in an undefined\n  // order. This method is best-effort: it's not guaranteed that the\n  // database will find all extensions, and it's not guaranteed that\n  // FindFileContainingExtension will return true on all of the found\n  // numbers. Returns true if the search was successful, otherwise\n  // returns false and leaves output unchanged.\n  //\n  // This method has a default implementation that always returns\n  // false.\n  virtual bool FindAllExtensionNumbers(const string& /* extendee_type */,\n                                       vector<int>* /* output */) {\n    return false;\n  }\n\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DescriptorDatabase);\n};\n\n// A DescriptorDatabase into which you can insert files manually.\n//\n// FindFileContainingSymbol() is fully-implemented.  When you add a file, its\n// symbols will be indexed for this purpose.  Note that the implementation\n// may return false positives, but only if it isn't possible for the symbol\n// to be defined in any other file.  In particular, if a file defines a symbol\n// \"Foo\", then searching for \"Foo.[anything]\" will match that file.  This way,\n// the database does not need to aggressively index all children of a symbol.\n//\n// FindFileContainingExtension() is mostly-implemented.  It works if and only\n// if the original FieldDescriptorProto defining the extension has a\n// fully-qualified type name in its \"extendee\" field (i.e. starts with a '.').\n// If the extendee is a relative name, SimpleDescriptorDatabase will not\n// attempt to resolve the type, so it will not know what type the extension is\n// extending.  Therefore, calling FindFileContainingExtension() with the\n// extension's containing type will never actually find that extension.  Note\n// that this is an unlikely problem, as all FileDescriptorProtos created by the\n// protocol compiler (as well as ones created by calling\n// FileDescriptor::CopyTo()) will always use fully-qualified names for all\n// types.  You only need to worry if you are constructing FileDescriptorProtos\n// yourself, or are calling compiler::Parser directly.\nclass LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase {\n public:\n  SimpleDescriptorDatabase();\n  ~SimpleDescriptorDatabase();\n\n  // Adds the FileDescriptorProto to the database, making a copy.  The object\n  // can be deleted after Add() returns.  Returns false if the file conflicted\n  // with a file already in the database, in which case an error will have\n  // been written to GOOGLE_LOG(ERROR).\n  bool Add(const FileDescriptorProto& file);\n\n  // Adds the FileDescriptorProto to the database and takes ownership of it.\n  bool AddAndOwn(const FileDescriptorProto* file);\n\n  // implements DescriptorDatabase -----------------------------------\n  bool FindFileByName(const string& filename,\n                      FileDescriptorProto* output);\n  bool FindFileContainingSymbol(const string& symbol_name,\n                                FileDescriptorProto* output);\n  bool FindFileContainingExtension(const string& containing_type,\n                                   int field_number,\n                                   FileDescriptorProto* output);\n  bool FindAllExtensionNumbers(const string& extendee_type,\n                               vector<int>* output);\n\n private:\n  // So that it can use DescriptorIndex.\n  friend class EncodedDescriptorDatabase;\n\n  // An index mapping file names, symbol names, and extension numbers to\n  // some sort of values.\n  template <typename Value>\n  class DescriptorIndex {\n   public:\n    // Helpers to recursively add particular descriptors and all their contents\n    // to the index.\n    bool AddFile(const FileDescriptorProto& file,\n                 Value value);\n    bool AddSymbol(const string& name, Value value);\n    bool AddNestedExtensions(const DescriptorProto& message_type,\n                             Value value);\n    bool AddExtension(const FieldDescriptorProto& field,\n                      Value value);\n\n    Value FindFile(const string& filename);\n    Value FindSymbol(const string& name);\n    Value FindExtension(const string& containing_type, int field_number);\n    bool FindAllExtensionNumbers(const string& containing_type,\n                                 vector<int>* output);\n\n   private:\n    map<string, Value> by_name_;\n    map<string, Value> by_symbol_;\n    map<pair<string, int>, Value> by_extension_;\n\n    // Invariant:  The by_symbol_ map does not contain any symbols which are\n    // prefixes of other symbols in the map.  For example, \"foo.bar\" is a\n    // prefix of \"foo.bar.baz\" (but is not a prefix of \"foo.barbaz\").\n    //\n    // This invariant is important because it means that given a symbol name,\n    // we can find a key in the map which is a prefix of the symbol in O(lg n)\n    // time, and we know that there is at most one such key.\n    //\n    // The prefix lookup algorithm works like so:\n    // 1) Find the last key in the map which is less than or equal to the\n    //    search key.\n    // 2) If the found key is a prefix of the search key, then return it.\n    //    Otherwise, there is no match.\n    //\n    // I am sure this algorithm has been described elsewhere, but since I\n    // wasn't able to find it quickly I will instead prove that it works\n    // myself.  The key to the algorithm is that if a match exists, step (1)\n    // will find it.  Proof:\n    // 1) Define the \"search key\" to be the key we are looking for, the \"found\n    //    key\" to be the key found in step (1), and the \"match key\" to be the\n    //    key which actually matches the serach key (i.e. the key we're trying\n    //    to find).\n    // 2) The found key must be less than or equal to the search key by\n    //    definition.\n    // 3) The match key must also be less than or equal to the search key\n    //    (because it is a prefix).\n    // 4) The match key cannot be greater than the found key, because if it\n    //    were, then step (1) of the algorithm would have returned the match\n    //    key instead (since it finds the *greatest* key which is less than or\n    //    equal to the search key).\n    // 5) Therefore, the found key must be between the match key and the search\n    //    key, inclusive.\n    // 6) Since the search key must be a sub-symbol of the match key, if it is\n    //    not equal to the match key, then search_key[match_key.size()] must\n    //    be '.'.\n    // 7) Since '.' sorts before any other character that is valid in a symbol\n    //    name, then if the found key is not equal to the match key, then\n    //    found_key[match_key.size()] must also be '.', because any other value\n    //    would make it sort after the search key.\n    // 8) Therefore, if the found key is not equal to the match key, then the\n    //    found key must be a sub-symbol of the match key.  However, this would\n    //    contradict our map invariant which says that no symbol in the map is\n    //    a sub-symbol of any other.\n    // 9) Therefore, the found key must match the match key.\n    //\n    // The above proof assumes the match key exists.  In the case that the\n    // match key does not exist, then step (1) will return some other symbol.\n    // That symbol cannot be a super-symbol of the search key since if it were,\n    // then it would be a match, and we're assuming the match key doesn't exist.\n    // Therefore, step 2 will correctly return no match.\n\n    // Find the last entry in the by_symbol_ map whose key is less than or\n    // equal to the given name.\n    typename map<string, Value>::iterator FindLastLessOrEqual(\n        const string& name);\n\n    // True if either the arguments are equal or super_symbol identifies a\n    // parent symbol of sub_symbol (e.g. \"foo.bar\" is a parent of\n    // \"foo.bar.baz\", but not a parent of \"foo.barbaz\").\n    bool IsSubSymbol(const string& sub_symbol, const string& super_symbol);\n\n    // Returns true if and only if all characters in the name are alphanumerics,\n    // underscores, or periods.\n    bool ValidateSymbolName(const string& name);\n  };\n\n\n  DescriptorIndex<const FileDescriptorProto*> index_;\n  vector<const FileDescriptorProto*> files_to_delete_;\n\n  // If file is non-NULL, copy it into *output and return true, otherwise\n  // return false.\n  bool MaybeCopy(const FileDescriptorProto* file,\n                 FileDescriptorProto* output);\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SimpleDescriptorDatabase);\n};\n\n// Very similar to SimpleDescriptorDatabase, but stores all the descriptors\n// as raw bytes and generally tries to use as little memory as possible.\n//\n// The same caveats regarding FindFileContainingExtension() apply as with\n// SimpleDescriptorDatabase.\nclass LIBPROTOBUF_EXPORT EncodedDescriptorDatabase : public DescriptorDatabase {\n public:\n  EncodedDescriptorDatabase();\n  ~EncodedDescriptorDatabase();\n\n  // Adds the FileDescriptorProto to the database.  The descriptor is provided\n  // in encoded form.  The database does not make a copy of the bytes, nor\n  // does it take ownership; it's up to the caller to make sure the bytes\n  // remain valid for the life of the database.  Returns false and logs an error\n  // if the bytes are not a valid FileDescriptorProto or if the file conflicted\n  // with a file already in the database.\n  bool Add(const void* encoded_file_descriptor, int size);\n\n  // Like Add(), but makes a copy of the data, so that the caller does not\n  // need to keep it around.\n  bool AddCopy(const void* encoded_file_descriptor, int size);\n\n  // Like FindFileContainingSymbol but returns only the name of the file.\n  bool FindNameOfFileContainingSymbol(const string& symbol_name,\n                                      string* output);\n\n  // implements DescriptorDatabase -----------------------------------\n  bool FindFileByName(const string& filename,\n                      FileDescriptorProto* output);\n  bool FindFileContainingSymbol(const string& symbol_name,\n                                FileDescriptorProto* output);\n  bool FindFileContainingExtension(const string& containing_type,\n                                   int field_number,\n                                   FileDescriptorProto* output);\n  bool FindAllExtensionNumbers(const string& extendee_type,\n                               vector<int>* output);\n\n private:\n  SimpleDescriptorDatabase::DescriptorIndex<pair<const void*, int> > index_;\n  vector<void*> files_to_delete_;\n\n  // If encoded_file.first is non-NULL, parse the data into *output and return\n  // true, otherwise return false.\n  bool MaybeParse(pair<const void*, int> encoded_file,\n                  FileDescriptorProto* output);\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(EncodedDescriptorDatabase);\n};\n\n// A DescriptorDatabase that fetches files from a given pool.\nclass LIBPROTOBUF_EXPORT DescriptorPoolDatabase : public DescriptorDatabase {\n public:\n  explicit DescriptorPoolDatabase(const DescriptorPool& pool);\n  ~DescriptorPoolDatabase();\n\n  // implements DescriptorDatabase -----------------------------------\n  bool FindFileByName(const string& filename,\n                      FileDescriptorProto* output);\n  bool FindFileContainingSymbol(const string& symbol_name,\n                                FileDescriptorProto* output);\n  bool FindFileContainingExtension(const string& containing_type,\n                                   int field_number,\n                                   FileDescriptorProto* output);\n  bool FindAllExtensionNumbers(const string& extendee_type,\n                               vector<int>* output);\n\n private:\n  const DescriptorPool& pool_;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DescriptorPoolDatabase);\n};\n\n// A DescriptorDatabase that wraps two or more others.  It first searches the\n// first database and, if that fails, tries the second, and so on.\nclass LIBPROTOBUF_EXPORT MergedDescriptorDatabase : public DescriptorDatabase {\n public:\n  // Merge just two databases.  The sources remain property of the caller.\n  MergedDescriptorDatabase(DescriptorDatabase* source1,\n                           DescriptorDatabase* source2);\n  // Merge more than two databases.  The sources remain property of the caller.\n  // The vector may be deleted after the constructor returns but the\n  // DescriptorDatabases need to stick around.\n  explicit MergedDescriptorDatabase(const vector<DescriptorDatabase*>& sources);\n  ~MergedDescriptorDatabase();\n\n  // implements DescriptorDatabase -----------------------------------\n  bool FindFileByName(const string& filename,\n                      FileDescriptorProto* output);\n  bool FindFileContainingSymbol(const string& symbol_name,\n                                FileDescriptorProto* output);\n  bool FindFileContainingExtension(const string& containing_type,\n                                   int field_number,\n                                   FileDescriptorProto* output);\n  // Merges the results of calling all databases. Returns true iff any\n  // of the databases returned true.\n  bool FindAllExtensionNumbers(const string& extendee_type,\n                               vector<int>* output);\n\n\n private:\n  vector<DescriptorDatabase*> sources_;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MergedDescriptorDatabase);\n};\n\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_DESCRIPTOR_DATABASE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/descriptor_database_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This file makes extensive use of RFC 3092.  :)\n\n#include <algorithm>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#include <google/protobuf/descriptor_database.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/text_format.h>\n#include <google/protobuf/stubs/strutil.h>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace {\n\nstatic void AddToDatabase(SimpleDescriptorDatabase* database,\n                          const char* file_text) {\n  FileDescriptorProto file_proto;\n  EXPECT_TRUE(TextFormat::ParseFromString(file_text, &file_proto));\n  database->Add(file_proto);\n}\n\nstatic void ExpectContainsType(const FileDescriptorProto& proto,\n                               const string& type_name) {\n  for (int i = 0; i < proto.message_type_size(); i++) {\n    if (proto.message_type(i).name() == type_name) return;\n  }\n  ADD_FAILURE() << \"\\\"\" << proto.name()\n                << \"\\\" did not contain expected type \\\"\"\n                << type_name << \"\\\".\";\n}\n\n// ===================================================================\n\n#if GTEST_HAS_PARAM_TEST\n\n// SimpleDescriptorDatabase, EncodedDescriptorDatabase, and\n// DescriptorPoolDatabase call for very similar tests.  Instead of writing\n// three nearly-identical sets of tests, we use parameterized tests to apply\n// the same code to all three.\n\n// The parameterized test runs against a DescriptarDatabaseTestCase.  We have\n// implementations for each of the three classes we want to test.\nclass DescriptorDatabaseTestCase {\n public:\n  virtual ~DescriptorDatabaseTestCase() {}\n\n  virtual DescriptorDatabase* GetDatabase() = 0;\n  virtual bool AddToDatabase(const FileDescriptorProto& file) = 0;\n};\n\n// Factory function type.\ntypedef DescriptorDatabaseTestCase* DescriptorDatabaseTestCaseFactory();\n\n// Specialization for SimpleDescriptorDatabase.\nclass SimpleDescriptorDatabaseTestCase : public DescriptorDatabaseTestCase {\n public:\n  static DescriptorDatabaseTestCase* New() {\n    return new SimpleDescriptorDatabaseTestCase;\n  }\n\n  virtual ~SimpleDescriptorDatabaseTestCase() {}\n\n  virtual DescriptorDatabase* GetDatabase() {\n    return &database_;\n  }\n  virtual bool AddToDatabase(const FileDescriptorProto& file) {\n    return database_.Add(file);\n  }\n\n private:\n  SimpleDescriptorDatabase database_;\n};\n\n// Specialization for EncodedDescriptorDatabase.\nclass EncodedDescriptorDatabaseTestCase : public DescriptorDatabaseTestCase {\n public:\n  static DescriptorDatabaseTestCase* New() {\n    return new EncodedDescriptorDatabaseTestCase;\n  }\n\n  virtual ~EncodedDescriptorDatabaseTestCase() {}\n\n  virtual DescriptorDatabase* GetDatabase() {\n    return &database_;\n  }\n  virtual bool AddToDatabase(const FileDescriptorProto& file) {\n    string data;\n    file.SerializeToString(&data);\n    return database_.AddCopy(data.data(), data.size());\n  }\n\n private:\n  EncodedDescriptorDatabase database_;\n};\n\n// Specialization for DescriptorPoolDatabase.\nclass DescriptorPoolDatabaseTestCase : public DescriptorDatabaseTestCase {\n public:\n  static DescriptorDatabaseTestCase* New() {\n    return new EncodedDescriptorDatabaseTestCase;\n  }\n\n  DescriptorPoolDatabaseTestCase() : database_(pool_) {}\n  virtual ~DescriptorPoolDatabaseTestCase() {}\n\n  virtual DescriptorDatabase* GetDatabase() {\n    return &database_;\n  }\n  virtual bool AddToDatabase(const FileDescriptorProto& file) {\n    return pool_.BuildFile(file);\n  }\n\n private:\n  DescriptorPool pool_;\n  DescriptorPoolDatabase database_;\n};\n\n// -------------------------------------------------------------------\n\nclass DescriptorDatabaseTest\n    : public testing::TestWithParam<DescriptorDatabaseTestCaseFactory*> {\n protected:\n  virtual void SetUp() {\n    test_case_.reset(GetParam()());\n    database_ = test_case_->GetDatabase();\n  }\n\n  void AddToDatabase(const char* file_descriptor_text) {\n    FileDescriptorProto file_proto;\n    EXPECT_TRUE(TextFormat::ParseFromString(file_descriptor_text, &file_proto));\n    EXPECT_TRUE(test_case_->AddToDatabase(file_proto));\n  }\n\n  void AddToDatabaseWithError(const char* file_descriptor_text) {\n    FileDescriptorProto file_proto;\n    EXPECT_TRUE(TextFormat::ParseFromString(file_descriptor_text, &file_proto));\n    EXPECT_FALSE(test_case_->AddToDatabase(file_proto));\n  }\n\n  google::protobuf::scoped_ptr<DescriptorDatabaseTestCase> test_case_;\n  DescriptorDatabase* database_;\n};\n\nTEST_P(DescriptorDatabaseTest, FindFileByName) {\n  AddToDatabase(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { name:\\\"Foo\\\" }\");\n  AddToDatabase(\n    \"name: \\\"bar.proto\\\" \"\n    \"message_type { name:\\\"Bar\\\" }\");\n\n  {\n    FileDescriptorProto file;\n    EXPECT_TRUE(database_->FindFileByName(\"foo.proto\", &file));\n    EXPECT_EQ(\"foo.proto\", file.name());\n    ExpectContainsType(file, \"Foo\");\n  }\n\n  {\n    FileDescriptorProto file;\n    EXPECT_TRUE(database_->FindFileByName(\"bar.proto\", &file));\n    EXPECT_EQ(\"bar.proto\", file.name());\n    ExpectContainsType(file, \"Bar\");\n  }\n\n  {\n    // Fails to find undefined files.\n    FileDescriptorProto file;\n    EXPECT_FALSE(database_->FindFileByName(\"baz.proto\", &file));\n  }\n}\n\nTEST_P(DescriptorDatabaseTest, FindFileContainingSymbol) {\n  AddToDatabase(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { \"\n    \"  name: \\\"Foo\\\" \"\n    \"  field { name:\\\"qux\\\" }\"\n    \"  nested_type { name: \\\"Grault\\\" } \"\n    \"  enum_type { name: \\\"Garply\\\" } \"\n    \"} \"\n    \"enum_type { \"\n    \"  name: \\\"Waldo\\\" \"\n    \"  value { name:\\\"FRED\\\" } \"\n    \"} \"\n    \"extension { name: \\\"plugh\\\" } \"\n    \"service { \"\n    \"  name: \\\"Xyzzy\\\" \"\n    \"  method { name: \\\"Thud\\\" } \"\n    \"}\"\n    );\n  AddToDatabase(\n    \"name: \\\"bar.proto\\\" \"\n    \"package: \\\"corge\\\" \"\n    \"message_type { name: \\\"Bar\\\" }\");\n\n  {\n    FileDescriptorProto file;\n    EXPECT_TRUE(database_->FindFileContainingSymbol(\"Foo\", &file));\n    EXPECT_EQ(\"foo.proto\", file.name());\n  }\n\n  {\n    // Can find fields.\n    FileDescriptorProto file;\n    EXPECT_TRUE(database_->FindFileContainingSymbol(\"Foo.qux\", &file));\n    EXPECT_EQ(\"foo.proto\", file.name());\n  }\n\n  {\n    // Can find nested types.\n    FileDescriptorProto file;\n    EXPECT_TRUE(database_->FindFileContainingSymbol(\"Foo.Grault\", &file));\n    EXPECT_EQ(\"foo.proto\", file.name());\n  }\n\n  {\n    // Can find nested enums.\n    FileDescriptorProto file;\n    EXPECT_TRUE(database_->FindFileContainingSymbol(\"Foo.Garply\", &file));\n    EXPECT_EQ(\"foo.proto\", file.name());\n  }\n\n  {\n    // Can find enum types.\n    FileDescriptorProto file;\n    EXPECT_TRUE(database_->FindFileContainingSymbol(\"Waldo\", &file));\n    EXPECT_EQ(\"foo.proto\", file.name());\n  }\n\n  {\n    // Can find enum values.\n    FileDescriptorProto file;\n    EXPECT_TRUE(database_->FindFileContainingSymbol(\"Waldo.FRED\", &file));\n    EXPECT_EQ(\"foo.proto\", file.name());\n  }\n\n  {\n    // Can find extensions.\n    FileDescriptorProto file;\n    EXPECT_TRUE(database_->FindFileContainingSymbol(\"plugh\", &file));\n    EXPECT_EQ(\"foo.proto\", file.name());\n  }\n\n  {\n    // Can find services.\n    FileDescriptorProto file;\n    EXPECT_TRUE(database_->FindFileContainingSymbol(\"Xyzzy\", &file));\n    EXPECT_EQ(\"foo.proto\", file.name());\n  }\n\n  {\n    // Can find methods.\n    FileDescriptorProto file;\n    EXPECT_TRUE(database_->FindFileContainingSymbol(\"Xyzzy.Thud\", &file));\n    EXPECT_EQ(\"foo.proto\", file.name());\n  }\n\n  {\n    // Can find things in packages.\n    FileDescriptorProto file;\n    EXPECT_TRUE(database_->FindFileContainingSymbol(\"corge.Bar\", &file));\n    EXPECT_EQ(\"bar.proto\", file.name());\n  }\n\n  {\n    // Fails to find undefined symbols.\n    FileDescriptorProto file;\n    EXPECT_FALSE(database_->FindFileContainingSymbol(\"Baz\", &file));\n  }\n\n  {\n    // Names must be fully-qualified.\n    FileDescriptorProto file;\n    EXPECT_FALSE(database_->FindFileContainingSymbol(\"Bar\", &file));\n  }\n}\n\nTEST_P(DescriptorDatabaseTest, FindFileContainingExtension) {\n  AddToDatabase(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { \"\n    \"  name: \\\"Foo\\\" \"\n    \"  extension_range { start: 1 end: 1000 } \"\n    \"  extension { name:\\\"qux\\\" label:LABEL_OPTIONAL type:TYPE_INT32 number:5 \"\n    \"              extendee: \\\".Foo\\\" }\"\n    \"}\");\n  AddToDatabase(\n    \"name: \\\"bar.proto\\\" \"\n    \"package: \\\"corge\\\" \"\n    \"dependency: \\\"foo.proto\\\" \"\n    \"message_type { \"\n    \"  name: \\\"Bar\\\" \"\n    \"  extension_range { start: 1 end: 1000 } \"\n    \"} \"\n    \"extension { name:\\\"grault\\\" extendee: \\\".Foo\\\"       number:32 } \"\n    \"extension { name:\\\"garply\\\" extendee: \\\".corge.Bar\\\" number:70 } \"\n    \"extension { name:\\\"waldo\\\"  extendee: \\\"Bar\\\"        number:56 } \");\n\n  {\n    FileDescriptorProto file;\n    EXPECT_TRUE(database_->FindFileContainingExtension(\"Foo\", 5, &file));\n    EXPECT_EQ(\"foo.proto\", file.name());\n  }\n\n  {\n    FileDescriptorProto file;\n    EXPECT_TRUE(database_->FindFileContainingExtension(\"Foo\", 32, &file));\n    EXPECT_EQ(\"bar.proto\", file.name());\n  }\n\n  {\n    // Can find extensions for qualified type names.\n    FileDescriptorProto file;\n    EXPECT_TRUE(database_->FindFileContainingExtension(\"corge.Bar\", 70, &file));\n    EXPECT_EQ(\"bar.proto\", file.name());\n  }\n\n  {\n    // Can't find extensions whose extendee was not fully-qualified in the\n    // FileDescriptorProto.\n    FileDescriptorProto file;\n    EXPECT_FALSE(database_->FindFileContainingExtension(\"Bar\", 56, &file));\n    EXPECT_FALSE(\n        database_->FindFileContainingExtension(\"corge.Bar\", 56, &file));\n  }\n\n  {\n    // Can't find non-existent extension numbers.\n    FileDescriptorProto file;\n    EXPECT_FALSE(database_->FindFileContainingExtension(\"Foo\", 12, &file));\n  }\n\n  {\n    // Can't find extensions for non-existent types.\n    FileDescriptorProto file;\n    EXPECT_FALSE(\n        database_->FindFileContainingExtension(\"NoSuchType\", 5, &file));\n  }\n\n  {\n    // Can't find extensions for unqualified type names.\n    FileDescriptorProto file;\n    EXPECT_FALSE(database_->FindFileContainingExtension(\"Bar\", 70, &file));\n  }\n}\n\nTEST_P(DescriptorDatabaseTest, FindAllExtensionNumbers) {\n  AddToDatabase(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { \"\n    \"  name: \\\"Foo\\\" \"\n    \"  extension_range { start: 1 end: 1000 } \"\n    \"  extension { name:\\\"qux\\\" label:LABEL_OPTIONAL type:TYPE_INT32 number:5 \"\n    \"              extendee: \\\".Foo\\\" }\"\n    \"}\");\n  AddToDatabase(\n    \"name: \\\"bar.proto\\\" \"\n    \"package: \\\"corge\\\" \"\n    \"dependency: \\\"foo.proto\\\" \"\n    \"message_type { \"\n    \"  name: \\\"Bar\\\" \"\n    \"  extension_range { start: 1 end: 1000 } \"\n    \"} \"\n    \"extension { name:\\\"grault\\\" extendee: \\\".Foo\\\"       number:32 } \"\n    \"extension { name:\\\"garply\\\" extendee: \\\".corge.Bar\\\" number:70 } \"\n    \"extension { name:\\\"waldo\\\"  extendee: \\\"Bar\\\"        number:56 } \");\n\n  {\n    vector<int> numbers;\n    EXPECT_TRUE(database_->FindAllExtensionNumbers(\"Foo\", &numbers));\n    ASSERT_EQ(2, numbers.size());\n    std::sort(numbers.begin(), numbers.end());\n    EXPECT_EQ(5, numbers[0]);\n    EXPECT_EQ(32, numbers[1]);\n  }\n\n  {\n    vector<int> numbers;\n    EXPECT_TRUE(database_->FindAllExtensionNumbers(\"corge.Bar\", &numbers));\n    // Note: won't find extension 56 due to the name not being fully qualified.\n    ASSERT_EQ(1, numbers.size());\n    EXPECT_EQ(70, numbers[0]);\n  }\n\n  {\n    // Can't find extensions for non-existent types.\n    vector<int> numbers;\n    EXPECT_FALSE(database_->FindAllExtensionNumbers(\"NoSuchType\", &numbers));\n  }\n\n  {\n    // Can't find extensions for unqualified types.\n    vector<int> numbers;\n    EXPECT_FALSE(database_->FindAllExtensionNumbers(\"Bar\", &numbers));\n  }\n}\n\nTEST_P(DescriptorDatabaseTest, ConflictingFileError) {\n  AddToDatabase(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { \"\n    \"  name: \\\"Foo\\\" \"\n    \"}\");\n  AddToDatabaseWithError(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { \"\n    \"  name: \\\"Bar\\\" \"\n    \"}\");\n}\n\nTEST_P(DescriptorDatabaseTest, ConflictingTypeError) {\n  AddToDatabase(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { \"\n    \"  name: \\\"Foo\\\" \"\n    \"}\");\n  AddToDatabaseWithError(\n    \"name: \\\"bar.proto\\\" \"\n    \"message_type { \"\n    \"  name: \\\"Foo\\\" \"\n    \"}\");\n}\n\nTEST_P(DescriptorDatabaseTest, ConflictingExtensionError) {\n  AddToDatabase(\n    \"name: \\\"foo.proto\\\" \"\n    \"extension { name:\\\"foo\\\" label:LABEL_OPTIONAL type:TYPE_INT32 number:5 \"\n    \"            extendee: \\\".Foo\\\" }\");\n  AddToDatabaseWithError(\n    \"name: \\\"bar.proto\\\" \"\n    \"extension { name:\\\"bar\\\" label:LABEL_OPTIONAL type:TYPE_INT32 number:5 \"\n    \"            extendee: \\\".Foo\\\" }\");\n}\n\nINSTANTIATE_TEST_CASE_P(Simple, DescriptorDatabaseTest,\n    testing::Values(&SimpleDescriptorDatabaseTestCase::New));\nINSTANTIATE_TEST_CASE_P(MemoryConserving, DescriptorDatabaseTest,\n    testing::Values(&EncodedDescriptorDatabaseTestCase::New));\nINSTANTIATE_TEST_CASE_P(Pool, DescriptorDatabaseTest,\n    testing::Values(&DescriptorPoolDatabaseTestCase::New));\n\n#endif  // GTEST_HAS_PARAM_TEST\n\nTEST(EncodedDescriptorDatabaseExtraTest, FindNameOfFileContainingSymbol) {\n  // Create two files, one of which is in two parts.\n  FileDescriptorProto file1, file2a, file2b;\n  file1.set_name(\"foo.proto\");\n  file1.set_package(\"foo\");\n  file1.add_message_type()->set_name(\"Foo\");\n  file2a.set_name(\"bar.proto\");\n  file2b.set_package(\"bar\");\n  file2b.add_message_type()->set_name(\"Bar\");\n\n  // Normal serialization allows our optimization to kick in.\n  string data1 = file1.SerializeAsString();\n\n  // Force out-of-order serialization to test slow path.\n  string data2 = file2b.SerializeAsString() + file2a.SerializeAsString();\n\n  // Create EncodedDescriptorDatabase containing both files.\n  EncodedDescriptorDatabase db;\n  db.Add(data1.data(), data1.size());\n  db.Add(data2.data(), data2.size());\n\n  // Test!\n  string filename;\n  EXPECT_TRUE(db.FindNameOfFileContainingSymbol(\"foo.Foo\", &filename));\n  EXPECT_EQ(\"foo.proto\", filename);\n  EXPECT_TRUE(db.FindNameOfFileContainingSymbol(\"foo.Foo.Blah\", &filename));\n  EXPECT_EQ(\"foo.proto\", filename);\n  EXPECT_TRUE(db.FindNameOfFileContainingSymbol(\"bar.Bar\", &filename));\n  EXPECT_EQ(\"bar.proto\", filename);\n  EXPECT_FALSE(db.FindNameOfFileContainingSymbol(\"foo\", &filename));\n  EXPECT_FALSE(db.FindNameOfFileContainingSymbol(\"bar\", &filename));\n  EXPECT_FALSE(db.FindNameOfFileContainingSymbol(\"baz.Baz\", &filename));\n}\n\n// ===================================================================\n\nclass MergedDescriptorDatabaseTest : public testing::Test {\n protected:\n  MergedDescriptorDatabaseTest()\n    : forward_merged_(&database1_, &database2_),\n      reverse_merged_(&database2_, &database1_) {}\n\n  virtual void SetUp() {\n    AddToDatabase(&database1_,\n      \"name: \\\"foo.proto\\\" \"\n      \"message_type { name:\\\"Foo\\\" extension_range { start: 1 end: 100 } } \"\n      \"extension { name:\\\"foo_ext\\\" extendee: \\\".Foo\\\" number:3 \"\n      \"            label:LABEL_OPTIONAL type:TYPE_INT32 } \");\n    AddToDatabase(&database2_,\n      \"name: \\\"bar.proto\\\" \"\n      \"message_type { name:\\\"Bar\\\" extension_range { start: 1 end: 100 } } \"\n      \"extension { name:\\\"bar_ext\\\" extendee: \\\".Bar\\\" number:5 \"\n      \"            label:LABEL_OPTIONAL type:TYPE_INT32 } \");\n\n    // baz.proto exists in both pools, with different definitions.\n    AddToDatabase(&database1_,\n      \"name: \\\"baz.proto\\\" \"\n      \"message_type { name:\\\"Baz\\\" extension_range { start: 1 end: 100 } } \"\n      \"message_type { name:\\\"FromPool1\\\" } \"\n      \"extension { name:\\\"baz_ext\\\" extendee: \\\".Baz\\\" number:12 \"\n      \"            label:LABEL_OPTIONAL type:TYPE_INT32 } \"\n      \"extension { name:\\\"database1_only_ext\\\" extendee: \\\".Baz\\\" number:13 \"\n      \"            label:LABEL_OPTIONAL type:TYPE_INT32 } \");\n    AddToDatabase(&database2_,\n      \"name: \\\"baz.proto\\\" \"\n      \"message_type { name:\\\"Baz\\\" extension_range { start: 1 end: 100 } } \"\n      \"message_type { name:\\\"FromPool2\\\" } \"\n      \"extension { name:\\\"baz_ext\\\" extendee: \\\".Baz\\\" number:12 \"\n      \"            label:LABEL_OPTIONAL type:TYPE_INT32 } \");\n  }\n\n  SimpleDescriptorDatabase database1_;\n  SimpleDescriptorDatabase database2_;\n\n  MergedDescriptorDatabase forward_merged_;\n  MergedDescriptorDatabase reverse_merged_;\n};\n\nTEST_F(MergedDescriptorDatabaseTest, FindFileByName) {\n  {\n    // Can find file that is only in database1_.\n    FileDescriptorProto file;\n    EXPECT_TRUE(forward_merged_.FindFileByName(\"foo.proto\", &file));\n    EXPECT_EQ(\"foo.proto\", file.name());\n    ExpectContainsType(file, \"Foo\");\n  }\n\n  {\n    // Can find file that is only in database2_.\n    FileDescriptorProto file;\n    EXPECT_TRUE(forward_merged_.FindFileByName(\"bar.proto\", &file));\n    EXPECT_EQ(\"bar.proto\", file.name());\n    ExpectContainsType(file, \"Bar\");\n  }\n\n  {\n    // In forward_merged_, database1_'s baz.proto takes precedence.\n    FileDescriptorProto file;\n    EXPECT_TRUE(forward_merged_.FindFileByName(\"baz.proto\", &file));\n    EXPECT_EQ(\"baz.proto\", file.name());\n    ExpectContainsType(file, \"FromPool1\");\n  }\n\n  {\n    // In reverse_merged_, database2_'s baz.proto takes precedence.\n    FileDescriptorProto file;\n    EXPECT_TRUE(reverse_merged_.FindFileByName(\"baz.proto\", &file));\n    EXPECT_EQ(\"baz.proto\", file.name());\n    ExpectContainsType(file, \"FromPool2\");\n  }\n\n  {\n    // Can't find non-existent file.\n    FileDescriptorProto file;\n    EXPECT_FALSE(forward_merged_.FindFileByName(\"no_such.proto\", &file));\n  }\n}\n\nTEST_F(MergedDescriptorDatabaseTest, FindFileContainingSymbol) {\n  {\n    // Can find file that is only in database1_.\n    FileDescriptorProto file;\n    EXPECT_TRUE(forward_merged_.FindFileContainingSymbol(\"Foo\", &file));\n    EXPECT_EQ(\"foo.proto\", file.name());\n    ExpectContainsType(file, \"Foo\");\n  }\n\n  {\n    // Can find file that is only in database2_.\n    FileDescriptorProto file;\n    EXPECT_TRUE(forward_merged_.FindFileContainingSymbol(\"Bar\", &file));\n    EXPECT_EQ(\"bar.proto\", file.name());\n    ExpectContainsType(file, \"Bar\");\n  }\n\n  {\n    // In forward_merged_, database1_'s baz.proto takes precedence.\n    FileDescriptorProto file;\n    EXPECT_TRUE(forward_merged_.FindFileContainingSymbol(\"Baz\", &file));\n    EXPECT_EQ(\"baz.proto\", file.name());\n    ExpectContainsType(file, \"FromPool1\");\n  }\n\n  {\n    // In reverse_merged_, database2_'s baz.proto takes precedence.\n    FileDescriptorProto file;\n    EXPECT_TRUE(reverse_merged_.FindFileContainingSymbol(\"Baz\", &file));\n    EXPECT_EQ(\"baz.proto\", file.name());\n    ExpectContainsType(file, \"FromPool2\");\n  }\n\n  {\n    // FromPool1 only shows up in forward_merged_ because it is masked by\n    // database2_'s baz.proto in reverse_merged_.\n    FileDescriptorProto file;\n    EXPECT_TRUE(forward_merged_.FindFileContainingSymbol(\"FromPool1\", &file));\n    EXPECT_FALSE(reverse_merged_.FindFileContainingSymbol(\"FromPool1\", &file));\n  }\n\n  {\n    // Can't find non-existent symbol.\n    FileDescriptorProto file;\n    EXPECT_FALSE(\n      forward_merged_.FindFileContainingSymbol(\"NoSuchType\", &file));\n  }\n}\n\nTEST_F(MergedDescriptorDatabaseTest, FindFileContainingExtension) {\n  {\n    // Can find file that is only in database1_.\n    FileDescriptorProto file;\n    EXPECT_TRUE(\n      forward_merged_.FindFileContainingExtension(\"Foo\", 3, &file));\n    EXPECT_EQ(\"foo.proto\", file.name());\n    ExpectContainsType(file, \"Foo\");\n  }\n\n  {\n    // Can find file that is only in database2_.\n    FileDescriptorProto file;\n    EXPECT_TRUE(\n      forward_merged_.FindFileContainingExtension(\"Bar\", 5, &file));\n    EXPECT_EQ(\"bar.proto\", file.name());\n    ExpectContainsType(file, \"Bar\");\n  }\n\n  {\n    // In forward_merged_, database1_'s baz.proto takes precedence.\n    FileDescriptorProto file;\n    EXPECT_TRUE(\n      forward_merged_.FindFileContainingExtension(\"Baz\", 12, &file));\n    EXPECT_EQ(\"baz.proto\", file.name());\n    ExpectContainsType(file, \"FromPool1\");\n  }\n\n  {\n    // In reverse_merged_, database2_'s baz.proto takes precedence.\n    FileDescriptorProto file;\n    EXPECT_TRUE(\n      reverse_merged_.FindFileContainingExtension(\"Baz\", 12, &file));\n    EXPECT_EQ(\"baz.proto\", file.name());\n    ExpectContainsType(file, \"FromPool2\");\n  }\n\n  {\n    // Baz's extension 13 only shows up in forward_merged_ because it is\n    // masked by database2_'s baz.proto in reverse_merged_.\n    FileDescriptorProto file;\n    EXPECT_TRUE(forward_merged_.FindFileContainingExtension(\"Baz\", 13, &file));\n    EXPECT_FALSE(reverse_merged_.FindFileContainingExtension(\"Baz\", 13, &file));\n  }\n\n  {\n    // Can't find non-existent extension.\n    FileDescriptorProto file;\n    EXPECT_FALSE(\n      forward_merged_.FindFileContainingExtension(\"Foo\", 6, &file));\n  }\n}\n\nTEST_F(MergedDescriptorDatabaseTest, FindAllExtensionNumbers) {\n  {\n    // Message only has extension in database1_\n    vector<int> numbers;\n    EXPECT_TRUE(forward_merged_.FindAllExtensionNumbers(\"Foo\", &numbers));\n    ASSERT_EQ(1, numbers.size());\n    EXPECT_EQ(3, numbers[0]);\n  }\n\n  {\n    // Message only has extension in database2_\n    vector<int> numbers;\n    EXPECT_TRUE(forward_merged_.FindAllExtensionNumbers(\"Bar\", &numbers));\n    ASSERT_EQ(1, numbers.size());\n    EXPECT_EQ(5, numbers[0]);\n  }\n\n  {\n    // Merge results from the two databases.\n    vector<int> numbers;\n    EXPECT_TRUE(forward_merged_.FindAllExtensionNumbers(\"Baz\", &numbers));\n    ASSERT_EQ(2, numbers.size());\n    std::sort(numbers.begin(), numbers.end());\n    EXPECT_EQ(12, numbers[0]);\n    EXPECT_EQ(13, numbers[1]);\n  }\n\n  {\n    vector<int> numbers;\n    EXPECT_TRUE(reverse_merged_.FindAllExtensionNumbers(\"Baz\", &numbers));\n    ASSERT_EQ(2, numbers.size());\n    std::sort(numbers.begin(), numbers.end());\n    EXPECT_EQ(12, numbers[0]);\n    EXPECT_EQ(13, numbers[1]);\n  }\n\n  {\n    // Can't find extensions for a non-existent message.\n    vector<int> numbers;\n    EXPECT_FALSE(reverse_merged_.FindAllExtensionNumbers(\"Blah\", &numbers));\n  }\n}\n\n}  // anonymous namespace\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/descriptor_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This file makes extensive use of RFC 3092.  :)\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <vector>\n\n#include <google/protobuf/compiler/importer.h>\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/unittest_custom_options.pb.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor_database.h>\n#include <google/protobuf/dynamic_message.h>\n#include <google/protobuf/text_format.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\n\n// Can't use an anonymous namespace here due to brokenness of Tru64 compiler.\nnamespace descriptor_unittest {\n\n// Some helpers to make assembling descriptors faster.\nDescriptorProto* AddMessage(FileDescriptorProto* file, const string& name) {\n  DescriptorProto* result = file->add_message_type();\n  result->set_name(name);\n  return result;\n}\n\nDescriptorProto* AddNestedMessage(DescriptorProto* parent, const string& name) {\n  DescriptorProto* result = parent->add_nested_type();\n  result->set_name(name);\n  return result;\n}\n\nEnumDescriptorProto* AddEnum(FileDescriptorProto* file, const string& name) {\n  EnumDescriptorProto* result = file->add_enum_type();\n  result->set_name(name);\n  return result;\n}\n\nEnumDescriptorProto* AddNestedEnum(DescriptorProto* parent,\n                                   const string& name) {\n  EnumDescriptorProto* result = parent->add_enum_type();\n  result->set_name(name);\n  return result;\n}\n\nServiceDescriptorProto* AddService(FileDescriptorProto* file,\n                                   const string& name) {\n  ServiceDescriptorProto* result = file->add_service();\n  result->set_name(name);\n  return result;\n}\n\nFieldDescriptorProto* AddField(DescriptorProto* parent,\n                               const string& name, int number,\n                               FieldDescriptorProto::Label label,\n                               FieldDescriptorProto::Type type) {\n  FieldDescriptorProto* result = parent->add_field();\n  result->set_name(name);\n  result->set_number(number);\n  result->set_label(label);\n  result->set_type(type);\n  return result;\n}\n\nFieldDescriptorProto* AddExtension(FileDescriptorProto* file,\n                                   const string& extendee,\n                                   const string& name, int number,\n                                   FieldDescriptorProto::Label label,\n                                   FieldDescriptorProto::Type type) {\n  FieldDescriptorProto* result = file->add_extension();\n  result->set_name(name);\n  result->set_number(number);\n  result->set_label(label);\n  result->set_type(type);\n  result->set_extendee(extendee);\n  return result;\n}\n\nFieldDescriptorProto* AddNestedExtension(DescriptorProto* parent,\n                                         const string& extendee,\n                                         const string& name, int number,\n                                         FieldDescriptorProto::Label label,\n                                         FieldDescriptorProto::Type type) {\n  FieldDescriptorProto* result = parent->add_extension();\n  result->set_name(name);\n  result->set_number(number);\n  result->set_label(label);\n  result->set_type(type);\n  result->set_extendee(extendee);\n  return result;\n}\n\nDescriptorProto::ExtensionRange* AddExtensionRange(DescriptorProto* parent,\n                                                   int start, int end) {\n  DescriptorProto::ExtensionRange* result = parent->add_extension_range();\n  result->set_start(start);\n  result->set_end(end);\n  return result;\n}\n\nDescriptorProto::ReservedRange* AddReservedRange(DescriptorProto* parent,\n                                                 int start, int end) {\n  DescriptorProto::ReservedRange* result = parent->add_reserved_range();\n  result->set_start(start);\n  result->set_end(end);\n  return result;\n}\n\nEnumValueDescriptorProto* AddEnumValue(EnumDescriptorProto* enum_proto,\n                                       const string& name, int number) {\n  EnumValueDescriptorProto* result = enum_proto->add_value();\n  result->set_name(name);\n  result->set_number(number);\n  return result;\n}\n\nMethodDescriptorProto* AddMethod(ServiceDescriptorProto* service,\n                                 const string& name,\n                                 const string& input_type,\n                                 const string& output_type) {\n  MethodDescriptorProto* result = service->add_method();\n  result->set_name(name);\n  result->set_input_type(input_type);\n  result->set_output_type(output_type);\n  return result;\n}\n\n// Empty enums technically aren't allowed.  We need to insert a dummy value\n// into them.\nvoid AddEmptyEnum(FileDescriptorProto* file, const string& name) {\n  AddEnumValue(AddEnum(file, name), name + \"_DUMMY\", 1);\n}\n\nclass MockErrorCollector : public DescriptorPool::ErrorCollector {\n public:\n  MockErrorCollector() {}\n  ~MockErrorCollector() {}\n\n  string text_;\n  string warning_text_;\n\n  // implements ErrorCollector ---------------------------------------\n  void AddError(const string& filename,\n                const string& element_name, const Message* descriptor,\n                ErrorLocation location, const string& message) {\n    const char* location_name = NULL;\n    switch (location) {\n      case NAME         : location_name = \"NAME\"         ; break;\n      case NUMBER       : location_name = \"NUMBER\"       ; break;\n      case TYPE         : location_name = \"TYPE\"         ; break;\n      case EXTENDEE     : location_name = \"EXTENDEE\"     ; break;\n      case DEFAULT_VALUE: location_name = \"DEFAULT_VALUE\"; break;\n      case OPTION_NAME  : location_name = \"OPTION_NAME\"  ; break;\n      case OPTION_VALUE : location_name = \"OPTION_VALUE\" ; break;\n      case INPUT_TYPE   : location_name = \"INPUT_TYPE\"   ; break;\n      case OUTPUT_TYPE  : location_name = \"OUTPUT_TYPE\"  ; break;\n      case OTHER        : location_name = \"OTHER\"        ; break;\n    }\n\n    strings::SubstituteAndAppend(\n      &text_, \"$0: $1: $2: $3\\n\",\n      filename, element_name, location_name, message);\n  }\n\n  // implements ErrorCollector ---------------------------------------\n  void AddWarning(const string& filename, const string& element_name,\n                  const Message* descriptor, ErrorLocation location,\n                  const string& message) {\n    const char* location_name = NULL;\n    switch (location) {\n      case NAME         : location_name = \"NAME\"         ; break;\n      case NUMBER       : location_name = \"NUMBER\"       ; break;\n      case TYPE         : location_name = \"TYPE\"         ; break;\n      case EXTENDEE     : location_name = \"EXTENDEE\"     ; break;\n      case DEFAULT_VALUE: location_name = \"DEFAULT_VALUE\"; break;\n      case OPTION_NAME  : location_name = \"OPTION_NAME\"  ; break;\n      case OPTION_VALUE : location_name = \"OPTION_VALUE\" ; break;\n      case INPUT_TYPE   : location_name = \"INPUT_TYPE\"   ; break;\n      case OUTPUT_TYPE  : location_name = \"OUTPUT_TYPE\"  ; break;\n      case OTHER        : location_name = \"OTHER\"        ; break;\n    }\n\n    strings::SubstituteAndAppend(\n      &warning_text_, \"$0: $1: $2: $3\\n\",\n      filename, element_name, location_name, message);\n  }\n};\n\n// ===================================================================\n\n// Test simple files.\nclass FileDescriptorTest : public testing::Test {\n protected:\n  virtual void SetUp() {\n    // Build descriptors for the following definitions:\n    //\n    //   // in \"foo.proto\"\n    //   message FooMessage { extensions 1; }\n    //   enum FooEnum {FOO_ENUM_VALUE = 1;}\n    //   service FooService {}\n    //   extend FooMessage { optional int32 foo_extension = 1; }\n    //\n    //   // in \"bar.proto\"\n    //   package bar_package;\n    //   message BarMessage { extensions 1; }\n    //   enum BarEnum {BAR_ENUM_VALUE = 1;}\n    //   service BarService {}\n    //   extend BarMessage { optional int32 bar_extension = 1; }\n    //\n    // Also, we have an empty file \"baz.proto\".  This file's purpose is to\n    // make sure that even though it has the same package as foo.proto,\n    // searching it for members of foo.proto won't work.\n\n    FileDescriptorProto foo_file;\n    foo_file.set_name(\"foo.proto\");\n    AddExtensionRange(AddMessage(&foo_file, \"FooMessage\"), 1, 2);\n    AddEnumValue(AddEnum(&foo_file, \"FooEnum\"), \"FOO_ENUM_VALUE\", 1);\n    AddService(&foo_file, \"FooService\");\n    AddExtension(&foo_file, \"FooMessage\", \"foo_extension\", 1,\n                 FieldDescriptorProto::LABEL_OPTIONAL,\n                 FieldDescriptorProto::TYPE_INT32);\n\n    FileDescriptorProto bar_file;\n    bar_file.set_name(\"bar.proto\");\n    bar_file.set_package(\"bar_package\");\n    bar_file.add_dependency(\"foo.proto\");\n    AddExtensionRange(AddMessage(&bar_file, \"BarMessage\"), 1, 2);\n    AddEnumValue(AddEnum(&bar_file, \"BarEnum\"), \"BAR_ENUM_VALUE\", 1);\n    AddService(&bar_file, \"BarService\");\n    AddExtension(&bar_file, \"bar_package.BarMessage\", \"bar_extension\", 1,\n                 FieldDescriptorProto::LABEL_OPTIONAL,\n                 FieldDescriptorProto::TYPE_INT32);\n\n    FileDescriptorProto baz_file;\n    baz_file.set_name(\"baz.proto\");\n\n    // Build the descriptors and get the pointers.\n    foo_file_ = pool_.BuildFile(foo_file);\n    ASSERT_TRUE(foo_file_ != NULL);\n\n    bar_file_ = pool_.BuildFile(bar_file);\n    ASSERT_TRUE(bar_file_ != NULL);\n\n    baz_file_ = pool_.BuildFile(baz_file);\n    ASSERT_TRUE(baz_file_ != NULL);\n\n    ASSERT_EQ(1, foo_file_->message_type_count());\n    foo_message_ = foo_file_->message_type(0);\n    ASSERT_EQ(1, foo_file_->enum_type_count());\n    foo_enum_ = foo_file_->enum_type(0);\n    ASSERT_EQ(1, foo_enum_->value_count());\n    foo_enum_value_ = foo_enum_->value(0);\n    ASSERT_EQ(1, foo_file_->service_count());\n    foo_service_ = foo_file_->service(0);\n    ASSERT_EQ(1, foo_file_->extension_count());\n    foo_extension_ = foo_file_->extension(0);\n\n    ASSERT_EQ(1, bar_file_->message_type_count());\n    bar_message_ = bar_file_->message_type(0);\n    ASSERT_EQ(1, bar_file_->enum_type_count());\n    bar_enum_ = bar_file_->enum_type(0);\n    ASSERT_EQ(1, bar_enum_->value_count());\n    bar_enum_value_ = bar_enum_->value(0);\n    ASSERT_EQ(1, bar_file_->service_count());\n    bar_service_ = bar_file_->service(0);\n    ASSERT_EQ(1, bar_file_->extension_count());\n    bar_extension_ = bar_file_->extension(0);\n  }\n\n  DescriptorPool pool_;\n\n  const FileDescriptor* foo_file_;\n  const FileDescriptor* bar_file_;\n  const FileDescriptor* baz_file_;\n\n  const Descriptor*          foo_message_;\n  const EnumDescriptor*      foo_enum_;\n  const EnumValueDescriptor* foo_enum_value_;\n  const ServiceDescriptor*   foo_service_;\n  const FieldDescriptor*     foo_extension_;\n\n  const Descriptor*          bar_message_;\n  const EnumDescriptor*      bar_enum_;\n  const EnumValueDescriptor* bar_enum_value_;\n  const ServiceDescriptor*   bar_service_;\n  const FieldDescriptor*     bar_extension_;\n};\n\nTEST_F(FileDescriptorTest, Name) {\n  EXPECT_EQ(\"foo.proto\", foo_file_->name());\n  EXPECT_EQ(\"bar.proto\", bar_file_->name());\n  EXPECT_EQ(\"baz.proto\", baz_file_->name());\n}\n\nTEST_F(FileDescriptorTest, Package) {\n  EXPECT_EQ(\"\", foo_file_->package());\n  EXPECT_EQ(\"bar_package\", bar_file_->package());\n}\n\nTEST_F(FileDescriptorTest, Dependencies) {\n  EXPECT_EQ(0, foo_file_->dependency_count());\n  EXPECT_EQ(1, bar_file_->dependency_count());\n  EXPECT_EQ(foo_file_, bar_file_->dependency(0));\n}\n\nTEST_F(FileDescriptorTest, FindMessageTypeByName) {\n  EXPECT_EQ(foo_message_, foo_file_->FindMessageTypeByName(\"FooMessage\"));\n  EXPECT_EQ(bar_message_, bar_file_->FindMessageTypeByName(\"BarMessage\"));\n\n  EXPECT_TRUE(foo_file_->FindMessageTypeByName(\"BarMessage\") == NULL);\n  EXPECT_TRUE(bar_file_->FindMessageTypeByName(\"FooMessage\") == NULL);\n  EXPECT_TRUE(baz_file_->FindMessageTypeByName(\"FooMessage\") == NULL);\n\n  EXPECT_TRUE(foo_file_->FindMessageTypeByName(\"NoSuchMessage\") == NULL);\n  EXPECT_TRUE(foo_file_->FindMessageTypeByName(\"FooEnum\") == NULL);\n}\n\nTEST_F(FileDescriptorTest, FindEnumTypeByName) {\n  EXPECT_EQ(foo_enum_, foo_file_->FindEnumTypeByName(\"FooEnum\"));\n  EXPECT_EQ(bar_enum_, bar_file_->FindEnumTypeByName(\"BarEnum\"));\n\n  EXPECT_TRUE(foo_file_->FindEnumTypeByName(\"BarEnum\") == NULL);\n  EXPECT_TRUE(bar_file_->FindEnumTypeByName(\"FooEnum\") == NULL);\n  EXPECT_TRUE(baz_file_->FindEnumTypeByName(\"FooEnum\") == NULL);\n\n  EXPECT_TRUE(foo_file_->FindEnumTypeByName(\"NoSuchEnum\") == NULL);\n  EXPECT_TRUE(foo_file_->FindEnumTypeByName(\"FooMessage\") == NULL);\n}\n\nTEST_F(FileDescriptorTest, FindEnumValueByName) {\n  EXPECT_EQ(foo_enum_value_, foo_file_->FindEnumValueByName(\"FOO_ENUM_VALUE\"));\n  EXPECT_EQ(bar_enum_value_, bar_file_->FindEnumValueByName(\"BAR_ENUM_VALUE\"));\n\n  EXPECT_TRUE(foo_file_->FindEnumValueByName(\"BAR_ENUM_VALUE\") == NULL);\n  EXPECT_TRUE(bar_file_->FindEnumValueByName(\"FOO_ENUM_VALUE\") == NULL);\n  EXPECT_TRUE(baz_file_->FindEnumValueByName(\"FOO_ENUM_VALUE\") == NULL);\n\n  EXPECT_TRUE(foo_file_->FindEnumValueByName(\"NO_SUCH_VALUE\") == NULL);\n  EXPECT_TRUE(foo_file_->FindEnumValueByName(\"FooMessage\") == NULL);\n}\n\nTEST_F(FileDescriptorTest, FindServiceByName) {\n  EXPECT_EQ(foo_service_, foo_file_->FindServiceByName(\"FooService\"));\n  EXPECT_EQ(bar_service_, bar_file_->FindServiceByName(\"BarService\"));\n\n  EXPECT_TRUE(foo_file_->FindServiceByName(\"BarService\") == NULL);\n  EXPECT_TRUE(bar_file_->FindServiceByName(\"FooService\") == NULL);\n  EXPECT_TRUE(baz_file_->FindServiceByName(\"FooService\") == NULL);\n\n  EXPECT_TRUE(foo_file_->FindServiceByName(\"NoSuchService\") == NULL);\n  EXPECT_TRUE(foo_file_->FindServiceByName(\"FooMessage\") == NULL);\n}\n\nTEST_F(FileDescriptorTest, FindExtensionByName) {\n  EXPECT_EQ(foo_extension_, foo_file_->FindExtensionByName(\"foo_extension\"));\n  EXPECT_EQ(bar_extension_, bar_file_->FindExtensionByName(\"bar_extension\"));\n\n  EXPECT_TRUE(foo_file_->FindExtensionByName(\"bar_extension\") == NULL);\n  EXPECT_TRUE(bar_file_->FindExtensionByName(\"foo_extension\") == NULL);\n  EXPECT_TRUE(baz_file_->FindExtensionByName(\"foo_extension\") == NULL);\n\n  EXPECT_TRUE(foo_file_->FindExtensionByName(\"no_such_extension\") == NULL);\n  EXPECT_TRUE(foo_file_->FindExtensionByName(\"FooMessage\") == NULL);\n}\n\nTEST_F(FileDescriptorTest, FindExtensionByNumber) {\n  EXPECT_EQ(foo_extension_, pool_.FindExtensionByNumber(foo_message_, 1));\n  EXPECT_EQ(bar_extension_, pool_.FindExtensionByNumber(bar_message_, 1));\n\n  EXPECT_TRUE(pool_.FindExtensionByNumber(foo_message_, 2) == NULL);\n}\n\nTEST_F(FileDescriptorTest, BuildAgain) {\n  // Test that if te call BuildFile again on the same input we get the same\n  // FileDescriptor back.\n  FileDescriptorProto file;\n  foo_file_->CopyTo(&file);\n  EXPECT_EQ(foo_file_, pool_.BuildFile(file));\n\n  // But if we change the file then it won't work.\n  file.set_package(\"some.other.package\");\n  EXPECT_TRUE(pool_.BuildFile(file) == NULL);\n}\n\nTEST_F(FileDescriptorTest, BuildAgainWithSyntax) {\n  // Test that if te call BuildFile again on the same input we get the same\n  // FileDescriptor back even if syntax param is specified.\n  FileDescriptorProto proto_syntax2;\n  proto_syntax2.set_name(\"foo_syntax2\");\n  proto_syntax2.set_syntax(\"proto2\");\n\n  const FileDescriptor* proto2_descriptor = pool_.BuildFile(proto_syntax2);\n  EXPECT_TRUE(proto2_descriptor != NULL);\n  EXPECT_EQ(proto2_descriptor, pool_.BuildFile(proto_syntax2));\n\n  FileDescriptorProto implicit_proto2;\n  implicit_proto2.set_name(\"foo_implicit_syntax2\");\n\n  const FileDescriptor* implicit_proto2_descriptor =\n      pool_.BuildFile(implicit_proto2);\n  EXPECT_TRUE(implicit_proto2_descriptor != NULL);\n  // We get the same FileDescriptor back if syntax param is explicitly\n  // specified.\n  implicit_proto2.set_syntax(\"proto2\");\n  EXPECT_EQ(implicit_proto2_descriptor, pool_.BuildFile(implicit_proto2));\n\n  FileDescriptorProto proto_syntax3;\n  proto_syntax3.set_name(\"foo_syntax3\");\n  proto_syntax3.set_syntax(\"proto3\");\n\n  const FileDescriptor* proto3_descriptor = pool_.BuildFile(proto_syntax3);\n  EXPECT_TRUE(proto3_descriptor != NULL);\n  EXPECT_EQ(proto3_descriptor, pool_.BuildFile(proto_syntax3));\n}\n\nTEST_F(FileDescriptorTest, Syntax) {\n  FileDescriptorProto proto;\n  proto.set_name(\"foo\");\n  // Enable the test when we also populate the syntax for proto2.\n#if 0\n  {\n    proto.set_syntax(\"proto2\");\n    DescriptorPool pool;\n    const FileDescriptor* file = pool.BuildFile(proto);\n    EXPECT_TRUE(file != NULL);\n    EXPECT_EQ(FileDescriptor::SYNTAX_PROTO2, file->syntax());\n    FileDescriptorProto other;\n    file->CopyTo(&other);\n    EXPECT_EQ(\"proto2\", other.syntax());\n  }\n#endif\n  {\n    proto.set_syntax(\"proto3\");\n    DescriptorPool pool;\n    const FileDescriptor* file = pool.BuildFile(proto);\n    EXPECT_TRUE(file != NULL);\n    EXPECT_EQ(FileDescriptor::SYNTAX_PROTO3, file->syntax());\n    FileDescriptorProto other;\n    file->CopyTo(&other);\n    EXPECT_EQ(\"proto3\", other.syntax());\n  }\n}\n\n// ===================================================================\n\n// Test simple flat messages and fields.\nclass DescriptorTest : public testing::Test {\n protected:\n  virtual void SetUp() {\n    // Build descriptors for the following definitions:\n    //\n    //   // in \"foo.proto\"\n    //   message TestForeign {}\n    //   enum TestEnum {}\n    //\n    //   message TestMessage {\n    //     required string      foo = 1;\n    //     optional TestEnum    bar = 6;\n    //     repeated TestForeign baz = 500000000;\n    //     optional group       qux = 15 {}\n    //   }\n    //\n    //   // in \"bar.proto\"\n    //   package corge.grault;\n    //   message TestMessage2 {\n    //     required string foo = 1;\n    //     required string bar = 2;\n    //     required string quux = 6;\n    //   }\n    //\n    //   // in \"map.proto\"\n    //   message TestMessage3 {\n    //     map<int32, int32> map_int32_int32 = 1;\n    //   }\n    //\n    //   // in \"json.proto\"\n    //   message TestMessage4 {\n    //     optional int32 field_name1 = 1;\n    //     optional int32 fieldName2 = 2;\n    //     optional int32 FieldName3 = 3;\n    //     optional int32 _field_name4 = 4;\n    //     optional int32 FIELD_NAME5 = 5;\n    //     optional int32 field_name6 = 6 [json_name = \"@type\"];\n    //   }\n    //\n    // We cheat and use TestForeign as the type for qux rather than create\n    // an actual nested type.\n    //\n    // Since all primitive types (including string) use the same building\n    // code, there's no need to test each one individually.\n    //\n    // TestMessage2 is primarily here to test FindFieldByName and friends.\n    // All messages created from the same DescriptorPool share the same lookup\n    // table, so we need to insure that they don't interfere.\n\n    FileDescriptorProto foo_file;\n    foo_file.set_name(\"foo.proto\");\n    AddMessage(&foo_file, \"TestForeign\");\n    AddEmptyEnum(&foo_file, \"TestEnum\");\n\n    DescriptorProto* message = AddMessage(&foo_file, \"TestMessage\");\n    AddField(message, \"foo\", 1,\n             FieldDescriptorProto::LABEL_REQUIRED,\n             FieldDescriptorProto::TYPE_STRING);\n    AddField(message, \"bar\", 6,\n             FieldDescriptorProto::LABEL_OPTIONAL,\n             FieldDescriptorProto::TYPE_ENUM)\n      ->set_type_name(\"TestEnum\");\n    AddField(message, \"baz\", 500000000,\n             FieldDescriptorProto::LABEL_REPEATED,\n             FieldDescriptorProto::TYPE_MESSAGE)\n      ->set_type_name(\"TestForeign\");\n    AddField(message, \"qux\", 15,\n             FieldDescriptorProto::LABEL_OPTIONAL,\n             FieldDescriptorProto::TYPE_GROUP)\n      ->set_type_name(\"TestForeign\");\n\n    FileDescriptorProto bar_file;\n    bar_file.set_name(\"bar.proto\");\n    bar_file.set_package(\"corge.grault\");\n\n    DescriptorProto* message2 = AddMessage(&bar_file, \"TestMessage2\");\n    AddField(message2, \"foo\", 1,\n             FieldDescriptorProto::LABEL_REQUIRED,\n             FieldDescriptorProto::TYPE_STRING);\n    AddField(message2, \"bar\", 2,\n             FieldDescriptorProto::LABEL_REQUIRED,\n             FieldDescriptorProto::TYPE_STRING);\n    AddField(message2, \"quux\", 6,\n             FieldDescriptorProto::LABEL_REQUIRED,\n             FieldDescriptorProto::TYPE_STRING);\n\n    FileDescriptorProto map_file;\n    map_file.set_name(\"map.proto\");\n    DescriptorProto* message3 = AddMessage(&map_file, \"TestMessage3\");\n\n    DescriptorProto* entry = AddNestedMessage(message3, \"MapInt32Int32Entry\");\n    AddField(entry, \"key\", 1,\n             FieldDescriptorProto::LABEL_OPTIONAL,\n             FieldDescriptorProto::TYPE_INT32);\n    AddField(entry, \"value\", 2,\n             FieldDescriptorProto::LABEL_OPTIONAL,\n             FieldDescriptorProto::TYPE_INT32);\n    entry->mutable_options()->set_map_entry(true);\n\n    AddField(message3, \"map_int32_int32\", 1,\n             FieldDescriptorProto::LABEL_REPEATED,\n             FieldDescriptorProto::TYPE_MESSAGE)\n        ->set_type_name(\"MapInt32Int32Entry\");\n\n    FileDescriptorProto json_file;\n    json_file.set_name(\"json.proto\");\n    json_file.set_syntax(\"proto3\");\n    DescriptorProto* message4 = AddMessage(&json_file, \"TestMessage4\");\n    AddField(message4, \"field_name1\", 1,\n             FieldDescriptorProto::LABEL_OPTIONAL,\n             FieldDescriptorProto::TYPE_INT32);\n    AddField(message4, \"fieldName2\", 2,\n             FieldDescriptorProto::LABEL_OPTIONAL,\n             FieldDescriptorProto::TYPE_INT32);\n    AddField(message4, \"FieldName3\", 3,\n             FieldDescriptorProto::LABEL_OPTIONAL,\n             FieldDescriptorProto::TYPE_INT32);\n    AddField(message4, \"_field_name4\", 4,\n             FieldDescriptorProto::LABEL_OPTIONAL,\n             FieldDescriptorProto::TYPE_INT32);\n    AddField(message4, \"FIELD_NAME5\", 5,\n             FieldDescriptorProto::LABEL_OPTIONAL,\n             FieldDescriptorProto::TYPE_INT32);\n    AddField(message4, \"field_name6\", 6,\n             FieldDescriptorProto::LABEL_OPTIONAL,\n             FieldDescriptorProto::TYPE_INT32)\n        ->set_json_name(\"@type\");\n\n    // Build the descriptors and get the pointers.\n    foo_file_ = pool_.BuildFile(foo_file);\n    ASSERT_TRUE(foo_file_ != NULL);\n\n    bar_file_ = pool_.BuildFile(bar_file);\n    ASSERT_TRUE(bar_file_ != NULL);\n\n    map_file_ = pool_.BuildFile(map_file);\n    ASSERT_TRUE(map_file_ != NULL);\n\n    json_file_ = pool_.BuildFile(json_file);\n    ASSERT_TRUE(json_file_ != NULL);\n\n    ASSERT_EQ(1, foo_file_->enum_type_count());\n    enum_ = foo_file_->enum_type(0);\n\n    ASSERT_EQ(2, foo_file_->message_type_count());\n    foreign_ = foo_file_->message_type(0);\n    message_ = foo_file_->message_type(1);\n\n    ASSERT_EQ(4, message_->field_count());\n    foo_ = message_->field(0);\n    bar_ = message_->field(1);\n    baz_ = message_->field(2);\n    qux_ = message_->field(3);\n\n    ASSERT_EQ(1, bar_file_->message_type_count());\n    message2_ = bar_file_->message_type(0);\n\n    ASSERT_EQ(3, message2_->field_count());\n    foo2_  = message2_->field(0);\n    bar2_  = message2_->field(1);\n    quux2_ = message2_->field(2);\n\n    ASSERT_EQ(1, map_file_->message_type_count());\n    message3_ = map_file_->message_type(0);\n\n    ASSERT_EQ(1, message3_->field_count());\n    map_  = message3_->field(0);\n\n    ASSERT_EQ(1, json_file_->message_type_count());\n    message4_ = json_file_->message_type(0);\n  }\n\n  void CopyWithJsonName(const Descriptor* message, DescriptorProto* proto) {\n    message->CopyTo(proto);\n    message->CopyJsonNameTo(proto);\n  }\n\n  DescriptorPool pool_;\n\n  const FileDescriptor* foo_file_;\n  const FileDescriptor* bar_file_;\n  const FileDescriptor* map_file_;\n  const FileDescriptor* json_file_;\n\n  const Descriptor* message_;\n  const Descriptor* message2_;\n  const Descriptor* message3_;\n  const Descriptor* message4_;\n  const Descriptor* foreign_;\n  const EnumDescriptor* enum_;\n\n  const FieldDescriptor* foo_;\n  const FieldDescriptor* bar_;\n  const FieldDescriptor* baz_;\n  const FieldDescriptor* qux_;\n\n  const FieldDescriptor* foo2_;\n  const FieldDescriptor* bar2_;\n  const FieldDescriptor* quux2_;\n\n  const FieldDescriptor* map_;\n};\n\nTEST_F(DescriptorTest, Name) {\n  EXPECT_EQ(\"TestMessage\", message_->name());\n  EXPECT_EQ(\"TestMessage\", message_->full_name());\n  EXPECT_EQ(foo_file_, message_->file());\n\n  EXPECT_EQ(\"TestMessage2\", message2_->name());\n  EXPECT_EQ(\"corge.grault.TestMessage2\", message2_->full_name());\n  EXPECT_EQ(bar_file_, message2_->file());\n}\n\nTEST_F(DescriptorTest, ContainingType) {\n  EXPECT_TRUE(message_->containing_type() == NULL);\n  EXPECT_TRUE(message2_->containing_type() == NULL);\n}\n\nTEST_F(DescriptorTest, FieldsByIndex) {\n  ASSERT_EQ(4, message_->field_count());\n  EXPECT_EQ(foo_, message_->field(0));\n  EXPECT_EQ(bar_, message_->field(1));\n  EXPECT_EQ(baz_, message_->field(2));\n  EXPECT_EQ(qux_, message_->field(3));\n}\n\nTEST_F(DescriptorTest, FindFieldByName) {\n  // All messages in the same DescriptorPool share a single lookup table for\n  // fields.  So, in addition to testing that FindFieldByName finds the fields\n  // of the message, we need to test that it does *not* find the fields of\n  // *other* messages.\n\n  EXPECT_EQ(foo_, message_->FindFieldByName(\"foo\"));\n  EXPECT_EQ(bar_, message_->FindFieldByName(\"bar\"));\n  EXPECT_EQ(baz_, message_->FindFieldByName(\"baz\"));\n  EXPECT_EQ(qux_, message_->FindFieldByName(\"qux\"));\n  EXPECT_TRUE(message_->FindFieldByName(\"no_such_field\") == NULL);\n  EXPECT_TRUE(message_->FindFieldByName(\"quux\") == NULL);\n\n  EXPECT_EQ(foo2_ , message2_->FindFieldByName(\"foo\" ));\n  EXPECT_EQ(bar2_ , message2_->FindFieldByName(\"bar\" ));\n  EXPECT_EQ(quux2_, message2_->FindFieldByName(\"quux\"));\n  EXPECT_TRUE(message2_->FindFieldByName(\"baz\") == NULL);\n  EXPECT_TRUE(message2_->FindFieldByName(\"qux\") == NULL);\n}\n\nTEST_F(DescriptorTest, FindFieldByNumber) {\n  EXPECT_EQ(foo_, message_->FindFieldByNumber(1));\n  EXPECT_EQ(bar_, message_->FindFieldByNumber(6));\n  EXPECT_EQ(baz_, message_->FindFieldByNumber(500000000));\n  EXPECT_EQ(qux_, message_->FindFieldByNumber(15));\n  EXPECT_TRUE(message_->FindFieldByNumber(837592) == NULL);\n  EXPECT_TRUE(message_->FindFieldByNumber(2) == NULL);\n\n  EXPECT_EQ(foo2_ , message2_->FindFieldByNumber(1));\n  EXPECT_EQ(bar2_ , message2_->FindFieldByNumber(2));\n  EXPECT_EQ(quux2_, message2_->FindFieldByNumber(6));\n  EXPECT_TRUE(message2_->FindFieldByNumber(15) == NULL);\n  EXPECT_TRUE(message2_->FindFieldByNumber(500000000) == NULL);\n}\n\nTEST_F(DescriptorTest, FieldName) {\n  EXPECT_EQ(\"foo\", foo_->name());\n  EXPECT_EQ(\"bar\", bar_->name());\n  EXPECT_EQ(\"baz\", baz_->name());\n  EXPECT_EQ(\"qux\", qux_->name());\n}\n\nTEST_F(DescriptorTest, FieldFullName) {\n  EXPECT_EQ(\"TestMessage.foo\", foo_->full_name());\n  EXPECT_EQ(\"TestMessage.bar\", bar_->full_name());\n  EXPECT_EQ(\"TestMessage.baz\", baz_->full_name());\n  EXPECT_EQ(\"TestMessage.qux\", qux_->full_name());\n\n  EXPECT_EQ(\"corge.grault.TestMessage2.foo\", foo2_->full_name());\n  EXPECT_EQ(\"corge.grault.TestMessage2.bar\", bar2_->full_name());\n  EXPECT_EQ(\"corge.grault.TestMessage2.quux\", quux2_->full_name());\n}\n\nTEST_F(DescriptorTest, FieldJsonName) {\n  EXPECT_EQ(\"fieldName1\", message4_->field(0)->json_name());\n  EXPECT_EQ(\"fieldName2\", message4_->field(1)->json_name());\n  EXPECT_EQ(\"fieldName3\", message4_->field(2)->json_name());\n  EXPECT_EQ(\"fieldName4\", message4_->field(3)->json_name());\n  EXPECT_EQ(\"fIELDNAME5\", message4_->field(4)->json_name());\n  EXPECT_EQ(\"@type\", message4_->field(5)->json_name());\n\n  DescriptorProto proto;\n  message4_->CopyTo(&proto);\n  ASSERT_EQ(6, proto.field_size());\n  EXPECT_FALSE(proto.field(0).has_json_name());\n  EXPECT_FALSE(proto.field(1).has_json_name());\n  EXPECT_FALSE(proto.field(2).has_json_name());\n  EXPECT_FALSE(proto.field(3).has_json_name());\n  EXPECT_FALSE(proto.field(4).has_json_name());\n  EXPECT_EQ(\"@type\", proto.field(5).json_name());\n\n  proto.Clear();\n  CopyWithJsonName(message4_, &proto);\n  ASSERT_EQ(6, proto.field_size());\n  EXPECT_EQ(\"fieldName1\", proto.field(0).json_name());\n  EXPECT_EQ(\"fieldName2\", proto.field(1).json_name());\n  EXPECT_EQ(\"fieldName3\", proto.field(2).json_name());\n  EXPECT_EQ(\"fieldName4\", proto.field(3).json_name());\n  EXPECT_EQ(\"fIELDNAME5\", proto.field(4).json_name());\n  EXPECT_EQ(\"@type\", proto.field(5).json_name());\n}\n\nTEST_F(DescriptorTest, FieldFile) {\n  EXPECT_EQ(foo_file_, foo_->file());\n  EXPECT_EQ(foo_file_, bar_->file());\n  EXPECT_EQ(foo_file_, baz_->file());\n  EXPECT_EQ(foo_file_, qux_->file());\n\n  EXPECT_EQ(bar_file_, foo2_->file());\n  EXPECT_EQ(bar_file_, bar2_->file());\n  EXPECT_EQ(bar_file_, quux2_->file());\n}\n\nTEST_F(DescriptorTest, FieldIndex) {\n  EXPECT_EQ(0, foo_->index());\n  EXPECT_EQ(1, bar_->index());\n  EXPECT_EQ(2, baz_->index());\n  EXPECT_EQ(3, qux_->index());\n}\n\nTEST_F(DescriptorTest, FieldNumber) {\n  EXPECT_EQ(        1, foo_->number());\n  EXPECT_EQ(        6, bar_->number());\n  EXPECT_EQ(500000000, baz_->number());\n  EXPECT_EQ(       15, qux_->number());\n}\n\nTEST_F(DescriptorTest, FieldType) {\n  EXPECT_EQ(FieldDescriptor::TYPE_STRING , foo_->type());\n  EXPECT_EQ(FieldDescriptor::TYPE_ENUM   , bar_->type());\n  EXPECT_EQ(FieldDescriptor::TYPE_MESSAGE, baz_->type());\n  EXPECT_EQ(FieldDescriptor::TYPE_GROUP  , qux_->type());\n}\n\nTEST_F(DescriptorTest, FieldLabel) {\n  EXPECT_EQ(FieldDescriptor::LABEL_REQUIRED, foo_->label());\n  EXPECT_EQ(FieldDescriptor::LABEL_OPTIONAL, bar_->label());\n  EXPECT_EQ(FieldDescriptor::LABEL_REPEATED, baz_->label());\n  EXPECT_EQ(FieldDescriptor::LABEL_OPTIONAL, qux_->label());\n\n  EXPECT_TRUE (foo_->is_required());\n  EXPECT_FALSE(foo_->is_optional());\n  EXPECT_FALSE(foo_->is_repeated());\n\n  EXPECT_FALSE(bar_->is_required());\n  EXPECT_TRUE (bar_->is_optional());\n  EXPECT_FALSE(bar_->is_repeated());\n\n  EXPECT_FALSE(baz_->is_required());\n  EXPECT_FALSE(baz_->is_optional());\n  EXPECT_TRUE (baz_->is_repeated());\n}\n\nTEST_F(DescriptorTest, IsMap) {\n  EXPECT_TRUE(map_->is_map());\n  EXPECT_FALSE(baz_->is_map());\n  EXPECT_TRUE(map_->message_type()->options().map_entry());\n}\n\nTEST_F(DescriptorTest, FieldHasDefault) {\n  EXPECT_FALSE(foo_->has_default_value());\n  EXPECT_FALSE(bar_->has_default_value());\n  EXPECT_FALSE(baz_->has_default_value());\n  EXPECT_FALSE(qux_->has_default_value());\n}\n\nTEST_F(DescriptorTest, FieldContainingType) {\n  EXPECT_EQ(message_, foo_->containing_type());\n  EXPECT_EQ(message_, bar_->containing_type());\n  EXPECT_EQ(message_, baz_->containing_type());\n  EXPECT_EQ(message_, qux_->containing_type());\n\n  EXPECT_EQ(message2_, foo2_ ->containing_type());\n  EXPECT_EQ(message2_, bar2_ ->containing_type());\n  EXPECT_EQ(message2_, quux2_->containing_type());\n}\n\nTEST_F(DescriptorTest, FieldMessageType) {\n  EXPECT_TRUE(foo_->message_type() == NULL);\n  EXPECT_TRUE(bar_->message_type() == NULL);\n\n  EXPECT_EQ(foreign_, baz_->message_type());\n  EXPECT_EQ(foreign_, qux_->message_type());\n}\n\nTEST_F(DescriptorTest, FieldEnumType) {\n  EXPECT_TRUE(foo_->enum_type() == NULL);\n  EXPECT_TRUE(baz_->enum_type() == NULL);\n  EXPECT_TRUE(qux_->enum_type() == NULL);\n\n  EXPECT_EQ(enum_, bar_->enum_type());\n}\n\n// ===================================================================\n\n// Test simple flat messages and fields.\nclass OneofDescriptorTest : public testing::Test {\n protected:\n  virtual void SetUp() {\n    // Build descriptors for the following definitions:\n    //\n    //   package garply;\n    //   message TestOneof {\n    //     optional int32 a = 1;\n    //     oneof foo {\n    //       string b = 2;\n    //       TestOneof c = 3;\n    //     }\n    //     oneof bar {\n    //       float d = 4;\n    //     }\n    //   }\n\n    FileDescriptorProto baz_file;\n    baz_file.set_name(\"baz.proto\");\n    baz_file.set_package(\"garply\");\n\n    DescriptorProto* oneof_message = AddMessage(&baz_file, \"TestOneof\");\n    oneof_message->add_oneof_decl()->set_name(\"foo\");\n    oneof_message->add_oneof_decl()->set_name(\"bar\");\n\n    AddField(oneof_message, \"a\", 1,\n             FieldDescriptorProto::LABEL_OPTIONAL,\n             FieldDescriptorProto::TYPE_INT32);\n    AddField(oneof_message, \"b\", 2,\n             FieldDescriptorProto::LABEL_OPTIONAL,\n             FieldDescriptorProto::TYPE_STRING);\n    oneof_message->mutable_field(1)->set_oneof_index(0);\n    AddField(oneof_message, \"c\", 3,\n             FieldDescriptorProto::LABEL_OPTIONAL,\n             FieldDescriptorProto::TYPE_MESSAGE);\n    oneof_message->mutable_field(2)->set_oneof_index(0);\n    oneof_message->mutable_field(2)->set_type_name(\"TestOneof\");\n\n    AddField(oneof_message, \"d\", 4,\n             FieldDescriptorProto::LABEL_OPTIONAL,\n             FieldDescriptorProto::TYPE_FLOAT);\n    oneof_message->mutable_field(3)->set_oneof_index(1);\n\n    // Build the descriptors and get the pointers.\n    baz_file_ = pool_.BuildFile(baz_file);\n    ASSERT_TRUE(baz_file_ != NULL);\n\n    ASSERT_EQ(1, baz_file_->message_type_count());\n    oneof_message_ = baz_file_->message_type(0);\n\n    ASSERT_EQ(2, oneof_message_->oneof_decl_count());\n    oneof_ = oneof_message_->oneof_decl(0);\n    oneof2_ = oneof_message_->oneof_decl(1);\n\n    ASSERT_EQ(4, oneof_message_->field_count());\n    a_ = oneof_message_->field(0);\n    b_ = oneof_message_->field(1);\n    c_ = oneof_message_->field(2);\n    d_ = oneof_message_->field(3);\n  }\n\n  DescriptorPool pool_;\n\n  const FileDescriptor* baz_file_;\n\n  const Descriptor* oneof_message_;\n\n  const OneofDescriptor* oneof_;\n  const OneofDescriptor* oneof2_;\n  const FieldDescriptor* a_;\n  const FieldDescriptor* b_;\n  const FieldDescriptor* c_;\n  const FieldDescriptor* d_;\n  const FieldDescriptor* e_;\n  const FieldDescriptor* f_;\n};\n\nTEST_F(OneofDescriptorTest, Normal) {\n  EXPECT_EQ(\"foo\", oneof_->name());\n  EXPECT_EQ(\"garply.TestOneof.foo\", oneof_->full_name());\n  EXPECT_EQ(0, oneof_->index());\n  ASSERT_EQ(2, oneof_->field_count());\n  EXPECT_EQ(b_, oneof_->field(0));\n  EXPECT_EQ(c_, oneof_->field(1));\n  EXPECT_TRUE(a_->containing_oneof() == NULL);\n  EXPECT_EQ(oneof_, b_->containing_oneof());\n  EXPECT_EQ(oneof_, c_->containing_oneof());\n}\n\nTEST_F(OneofDescriptorTest, FindByName) {\n  EXPECT_EQ(oneof_, oneof_message_->FindOneofByName(\"foo\"));\n  EXPECT_EQ(oneof2_, oneof_message_->FindOneofByName(\"bar\"));\n  EXPECT_TRUE(oneof_message_->FindOneofByName(\"no_such_oneof\") == NULL);\n}\n\n// ===================================================================\n\nclass StylizedFieldNamesTest : public testing::Test {\n protected:\n  void SetUp() {\n    FileDescriptorProto file;\n    file.set_name(\"foo.proto\");\n\n    AddExtensionRange(AddMessage(&file, \"ExtendableMessage\"), 1, 1000);\n\n    DescriptorProto* message = AddMessage(&file, \"TestMessage\");\n    AddField(message, \"foo_foo\", 1,\n             FieldDescriptorProto::LABEL_OPTIONAL,\n             FieldDescriptorProto::TYPE_INT32);\n    AddField(message, \"FooBar\", 2,\n             FieldDescriptorProto::LABEL_OPTIONAL,\n             FieldDescriptorProto::TYPE_INT32);\n    AddField(message, \"fooBaz\", 3,\n             FieldDescriptorProto::LABEL_OPTIONAL,\n             FieldDescriptorProto::TYPE_INT32);\n    AddField(message, \"fooFoo\", 4,  // Camel-case conflict with foo_foo.\n             FieldDescriptorProto::LABEL_OPTIONAL,\n             FieldDescriptorProto::TYPE_INT32);\n    AddField(message, \"foobar\", 5,  // Lower-case conflict with FooBar.\n             FieldDescriptorProto::LABEL_OPTIONAL,\n             FieldDescriptorProto::TYPE_INT32);\n\n    AddNestedExtension(message, \"ExtendableMessage\", \"bar_foo\", 1,\n                       FieldDescriptorProto::LABEL_OPTIONAL,\n                       FieldDescriptorProto::TYPE_INT32);\n    AddNestedExtension(message, \"ExtendableMessage\", \"BarBar\", 2,\n                       FieldDescriptorProto::LABEL_OPTIONAL,\n                       FieldDescriptorProto::TYPE_INT32);\n    AddNestedExtension(message, \"ExtendableMessage\", \"BarBaz\", 3,\n                       FieldDescriptorProto::LABEL_OPTIONAL,\n                       FieldDescriptorProto::TYPE_INT32);\n    AddNestedExtension(message, \"ExtendableMessage\", \"barFoo\", 4,  // Conflict\n                       FieldDescriptorProto::LABEL_OPTIONAL,\n                       FieldDescriptorProto::TYPE_INT32);\n    AddNestedExtension(message, \"ExtendableMessage\", \"barbar\", 5,  // Conflict\n                       FieldDescriptorProto::LABEL_OPTIONAL,\n                       FieldDescriptorProto::TYPE_INT32);\n\n    AddExtension(&file, \"ExtendableMessage\", \"baz_foo\", 11,\n                 FieldDescriptorProto::LABEL_OPTIONAL,\n                 FieldDescriptorProto::TYPE_INT32);\n    AddExtension(&file, \"ExtendableMessage\", \"BazBar\", 12,\n                 FieldDescriptorProto::LABEL_OPTIONAL,\n                 FieldDescriptorProto::TYPE_INT32);\n    AddExtension(&file, \"ExtendableMessage\", \"BazBaz\", 13,\n                 FieldDescriptorProto::LABEL_OPTIONAL,\n                 FieldDescriptorProto::TYPE_INT32);\n    AddExtension(&file, \"ExtendableMessage\", \"bazFoo\", 14,  // Conflict\n                 FieldDescriptorProto::LABEL_OPTIONAL,\n                 FieldDescriptorProto::TYPE_INT32);\n    AddExtension(&file, \"ExtendableMessage\", \"bazbar\", 15,  // Conflict\n                 FieldDescriptorProto::LABEL_OPTIONAL,\n                 FieldDescriptorProto::TYPE_INT32);\n\n    file_ = pool_.BuildFile(file);\n    ASSERT_TRUE(file_ != NULL);\n    ASSERT_EQ(2, file_->message_type_count());\n    message_ = file_->message_type(1);\n    ASSERT_EQ(\"TestMessage\", message_->name());\n    ASSERT_EQ(5, message_->field_count());\n    ASSERT_EQ(5, message_->extension_count());\n    ASSERT_EQ(5, file_->extension_count());\n  }\n\n  DescriptorPool pool_;\n  const FileDescriptor* file_;\n  const Descriptor* message_;\n};\n\nTEST_F(StylizedFieldNamesTest, LowercaseName) {\n  EXPECT_EQ(\"foo_foo\", message_->field(0)->lowercase_name());\n  EXPECT_EQ(\"foobar\" , message_->field(1)->lowercase_name());\n  EXPECT_EQ(\"foobaz\" , message_->field(2)->lowercase_name());\n  EXPECT_EQ(\"foofoo\" , message_->field(3)->lowercase_name());\n  EXPECT_EQ(\"foobar\" , message_->field(4)->lowercase_name());\n\n  EXPECT_EQ(\"bar_foo\", message_->extension(0)->lowercase_name());\n  EXPECT_EQ(\"barbar\" , message_->extension(1)->lowercase_name());\n  EXPECT_EQ(\"barbaz\" , message_->extension(2)->lowercase_name());\n  EXPECT_EQ(\"barfoo\" , message_->extension(3)->lowercase_name());\n  EXPECT_EQ(\"barbar\" , message_->extension(4)->lowercase_name());\n\n  EXPECT_EQ(\"baz_foo\", file_->extension(0)->lowercase_name());\n  EXPECT_EQ(\"bazbar\" , file_->extension(1)->lowercase_name());\n  EXPECT_EQ(\"bazbaz\" , file_->extension(2)->lowercase_name());\n  EXPECT_EQ(\"bazfoo\" , file_->extension(3)->lowercase_name());\n  EXPECT_EQ(\"bazbar\" , file_->extension(4)->lowercase_name());\n}\n\nTEST_F(StylizedFieldNamesTest, CamelcaseName) {\n  EXPECT_EQ(\"fooFoo\", message_->field(0)->camelcase_name());\n  EXPECT_EQ(\"fooBar\", message_->field(1)->camelcase_name());\n  EXPECT_EQ(\"fooBaz\", message_->field(2)->camelcase_name());\n  EXPECT_EQ(\"fooFoo\", message_->field(3)->camelcase_name());\n  EXPECT_EQ(\"foobar\", message_->field(4)->camelcase_name());\n\n  EXPECT_EQ(\"barFoo\", message_->extension(0)->camelcase_name());\n  EXPECT_EQ(\"barBar\", message_->extension(1)->camelcase_name());\n  EXPECT_EQ(\"barBaz\", message_->extension(2)->camelcase_name());\n  EXPECT_EQ(\"barFoo\", message_->extension(3)->camelcase_name());\n  EXPECT_EQ(\"barbar\", message_->extension(4)->camelcase_name());\n\n  EXPECT_EQ(\"bazFoo\", file_->extension(0)->camelcase_name());\n  EXPECT_EQ(\"bazBar\", file_->extension(1)->camelcase_name());\n  EXPECT_EQ(\"bazBaz\", file_->extension(2)->camelcase_name());\n  EXPECT_EQ(\"bazFoo\", file_->extension(3)->camelcase_name());\n  EXPECT_EQ(\"bazbar\", file_->extension(4)->camelcase_name());\n}\n\nTEST_F(StylizedFieldNamesTest, FindByLowercaseName) {\n  EXPECT_EQ(message_->field(0),\n            message_->FindFieldByLowercaseName(\"foo_foo\"));\n  EXPECT_EQ(message_->field(1),\n            message_->FindFieldByLowercaseName(\"foobar\"));\n  EXPECT_EQ(message_->field(2),\n            message_->FindFieldByLowercaseName(\"foobaz\"));\n  EXPECT_TRUE(message_->FindFieldByLowercaseName(\"FooBar\") == NULL);\n  EXPECT_TRUE(message_->FindFieldByLowercaseName(\"fooBaz\") == NULL);\n  EXPECT_TRUE(message_->FindFieldByLowercaseName(\"bar_foo\") == NULL);\n  EXPECT_TRUE(message_->FindFieldByLowercaseName(\"nosuchfield\") == NULL);\n\n  EXPECT_EQ(message_->extension(0),\n            message_->FindExtensionByLowercaseName(\"bar_foo\"));\n  EXPECT_EQ(message_->extension(1),\n            message_->FindExtensionByLowercaseName(\"barbar\"));\n  EXPECT_EQ(message_->extension(2),\n            message_->FindExtensionByLowercaseName(\"barbaz\"));\n  EXPECT_TRUE(message_->FindExtensionByLowercaseName(\"BarBar\") == NULL);\n  EXPECT_TRUE(message_->FindExtensionByLowercaseName(\"barBaz\") == NULL);\n  EXPECT_TRUE(message_->FindExtensionByLowercaseName(\"foo_foo\") == NULL);\n  EXPECT_TRUE(message_->FindExtensionByLowercaseName(\"nosuchfield\") == NULL);\n\n  EXPECT_EQ(file_->extension(0),\n            file_->FindExtensionByLowercaseName(\"baz_foo\"));\n  EXPECT_EQ(file_->extension(1),\n            file_->FindExtensionByLowercaseName(\"bazbar\"));\n  EXPECT_EQ(file_->extension(2),\n            file_->FindExtensionByLowercaseName(\"bazbaz\"));\n  EXPECT_TRUE(file_->FindExtensionByLowercaseName(\"BazBar\") == NULL);\n  EXPECT_TRUE(file_->FindExtensionByLowercaseName(\"bazBaz\") == NULL);\n  EXPECT_TRUE(file_->FindExtensionByLowercaseName(\"nosuchfield\") == NULL);\n}\n\nTEST_F(StylizedFieldNamesTest, FindByCamelcaseName) {\n  EXPECT_EQ(message_->field(0),\n            message_->FindFieldByCamelcaseName(\"fooFoo\"));\n  EXPECT_EQ(message_->field(1),\n            message_->FindFieldByCamelcaseName(\"fooBar\"));\n  EXPECT_EQ(message_->field(2),\n            message_->FindFieldByCamelcaseName(\"fooBaz\"));\n  EXPECT_TRUE(message_->FindFieldByCamelcaseName(\"foo_foo\") == NULL);\n  EXPECT_TRUE(message_->FindFieldByCamelcaseName(\"FooBar\") == NULL);\n  EXPECT_TRUE(message_->FindFieldByCamelcaseName(\"barFoo\") == NULL);\n  EXPECT_TRUE(message_->FindFieldByCamelcaseName(\"nosuchfield\") == NULL);\n\n  EXPECT_EQ(message_->extension(0),\n            message_->FindExtensionByCamelcaseName(\"barFoo\"));\n  EXPECT_EQ(message_->extension(1),\n            message_->FindExtensionByCamelcaseName(\"barBar\"));\n  EXPECT_EQ(message_->extension(2),\n            message_->FindExtensionByCamelcaseName(\"barBaz\"));\n  EXPECT_TRUE(message_->FindExtensionByCamelcaseName(\"bar_foo\") == NULL);\n  EXPECT_TRUE(message_->FindExtensionByCamelcaseName(\"BarBar\") == NULL);\n  EXPECT_TRUE(message_->FindExtensionByCamelcaseName(\"fooFoo\") == NULL);\n  EXPECT_TRUE(message_->FindExtensionByCamelcaseName(\"nosuchfield\") == NULL);\n\n  EXPECT_EQ(file_->extension(0),\n            file_->FindExtensionByCamelcaseName(\"bazFoo\"));\n  EXPECT_EQ(file_->extension(1),\n            file_->FindExtensionByCamelcaseName(\"bazBar\"));\n  EXPECT_EQ(file_->extension(2),\n            file_->FindExtensionByCamelcaseName(\"bazBaz\"));\n  EXPECT_TRUE(file_->FindExtensionByCamelcaseName(\"baz_foo\") == NULL);\n  EXPECT_TRUE(file_->FindExtensionByCamelcaseName(\"BazBar\") == NULL);\n  EXPECT_TRUE(file_->FindExtensionByCamelcaseName(\"nosuchfield\") == NULL);\n}\n\n// ===================================================================\n\n// Test enum descriptors.\nclass EnumDescriptorTest : public testing::Test {\n protected:\n  virtual void SetUp() {\n    // Build descriptors for the following definitions:\n    //\n    //   // in \"foo.proto\"\n    //   enum TestEnum {\n    //     FOO = 1;\n    //     BAR = 2;\n    //   }\n    //\n    //   // in \"bar.proto\"\n    //   package corge.grault;\n    //   enum TestEnum2 {\n    //     FOO = 1;\n    //     BAZ = 3;\n    //   }\n    //\n    // TestEnum2 is primarily here to test FindValueByName and friends.\n    // All enums created from the same DescriptorPool share the same lookup\n    // table, so we need to insure that they don't interfere.\n\n    // TestEnum\n    FileDescriptorProto foo_file;\n    foo_file.set_name(\"foo.proto\");\n\n    EnumDescriptorProto* enum_proto = AddEnum(&foo_file, \"TestEnum\");\n    AddEnumValue(enum_proto, \"FOO\", 1);\n    AddEnumValue(enum_proto, \"BAR\", 2);\n\n    // TestEnum2\n    FileDescriptorProto bar_file;\n    bar_file.set_name(\"bar.proto\");\n    bar_file.set_package(\"corge.grault\");\n\n    EnumDescriptorProto* enum2_proto = AddEnum(&bar_file, \"TestEnum2\");\n    AddEnumValue(enum2_proto, \"FOO\", 1);\n    AddEnumValue(enum2_proto, \"BAZ\", 3);\n\n    // Build the descriptors and get the pointers.\n    foo_file_ = pool_.BuildFile(foo_file);\n    ASSERT_TRUE(foo_file_ != NULL);\n\n    bar_file_ = pool_.BuildFile(bar_file);\n    ASSERT_TRUE(bar_file_ != NULL);\n\n    ASSERT_EQ(1, foo_file_->enum_type_count());\n    enum_ = foo_file_->enum_type(0);\n\n    ASSERT_EQ(2, enum_->value_count());\n    foo_ = enum_->value(0);\n    bar_ = enum_->value(1);\n\n    ASSERT_EQ(1, bar_file_->enum_type_count());\n    enum2_ = bar_file_->enum_type(0);\n\n    ASSERT_EQ(2, enum2_->value_count());\n    foo2_ = enum2_->value(0);\n    baz2_ = enum2_->value(1);\n  }\n\n  DescriptorPool pool_;\n\n  const FileDescriptor* foo_file_;\n  const FileDescriptor* bar_file_;\n\n  const EnumDescriptor* enum_;\n  const EnumDescriptor* enum2_;\n\n  const EnumValueDescriptor* foo_;\n  const EnumValueDescriptor* bar_;\n\n  const EnumValueDescriptor* foo2_;\n  const EnumValueDescriptor* baz2_;\n};\n\nTEST_F(EnumDescriptorTest, Name) {\n  EXPECT_EQ(\"TestEnum\", enum_->name());\n  EXPECT_EQ(\"TestEnum\", enum_->full_name());\n  EXPECT_EQ(foo_file_, enum_->file());\n\n  EXPECT_EQ(\"TestEnum2\", enum2_->name());\n  EXPECT_EQ(\"corge.grault.TestEnum2\", enum2_->full_name());\n  EXPECT_EQ(bar_file_, enum2_->file());\n}\n\nTEST_F(EnumDescriptorTest, ContainingType) {\n  EXPECT_TRUE(enum_->containing_type() == NULL);\n  EXPECT_TRUE(enum2_->containing_type() == NULL);\n}\n\nTEST_F(EnumDescriptorTest, ValuesByIndex) {\n  ASSERT_EQ(2, enum_->value_count());\n  EXPECT_EQ(foo_, enum_->value(0));\n  EXPECT_EQ(bar_, enum_->value(1));\n}\n\nTEST_F(EnumDescriptorTest, FindValueByName) {\n  EXPECT_EQ(foo_ , enum_ ->FindValueByName(\"FOO\"));\n  EXPECT_EQ(bar_ , enum_ ->FindValueByName(\"BAR\"));\n  EXPECT_EQ(foo2_, enum2_->FindValueByName(\"FOO\"));\n  EXPECT_EQ(baz2_, enum2_->FindValueByName(\"BAZ\"));\n\n  EXPECT_TRUE(enum_ ->FindValueByName(\"NO_SUCH_VALUE\") == NULL);\n  EXPECT_TRUE(enum_ ->FindValueByName(\"BAZ\"          ) == NULL);\n  EXPECT_TRUE(enum2_->FindValueByName(\"BAR\"          ) == NULL);\n}\n\nTEST_F(EnumDescriptorTest, FindValueByNumber) {\n  EXPECT_EQ(foo_ , enum_ ->FindValueByNumber(1));\n  EXPECT_EQ(bar_ , enum_ ->FindValueByNumber(2));\n  EXPECT_EQ(foo2_, enum2_->FindValueByNumber(1));\n  EXPECT_EQ(baz2_, enum2_->FindValueByNumber(3));\n\n  EXPECT_TRUE(enum_ ->FindValueByNumber(416) == NULL);\n  EXPECT_TRUE(enum_ ->FindValueByNumber(3) == NULL);\n  EXPECT_TRUE(enum2_->FindValueByNumber(2) == NULL);\n}\n\nTEST_F(EnumDescriptorTest, ValueName) {\n  EXPECT_EQ(\"FOO\", foo_->name());\n  EXPECT_EQ(\"BAR\", bar_->name());\n}\n\nTEST_F(EnumDescriptorTest, ValueFullName) {\n  EXPECT_EQ(\"FOO\", foo_->full_name());\n  EXPECT_EQ(\"BAR\", bar_->full_name());\n  EXPECT_EQ(\"corge.grault.FOO\", foo2_->full_name());\n  EXPECT_EQ(\"corge.grault.BAZ\", baz2_->full_name());\n}\n\nTEST_F(EnumDescriptorTest, ValueIndex) {\n  EXPECT_EQ(0, foo_->index());\n  EXPECT_EQ(1, bar_->index());\n}\n\nTEST_F(EnumDescriptorTest, ValueNumber) {\n  EXPECT_EQ(1, foo_->number());\n  EXPECT_EQ(2, bar_->number());\n}\n\nTEST_F(EnumDescriptorTest, ValueType) {\n  EXPECT_EQ(enum_ , foo_ ->type());\n  EXPECT_EQ(enum_ , bar_ ->type());\n  EXPECT_EQ(enum2_, foo2_->type());\n  EXPECT_EQ(enum2_, baz2_->type());\n}\n\n// ===================================================================\n\n// Test service descriptors.\nclass ServiceDescriptorTest : public testing::Test {\n protected:\n  virtual void SetUp() {\n    // Build descriptors for the following messages and service:\n    //    // in \"foo.proto\"\n    //    message FooRequest  {}\n    //    message FooResponse {}\n    //    message BarRequest  {}\n    //    message BarResponse {}\n    //    message BazRequest  {}\n    //    message BazResponse {}\n    //\n    //    service TestService {\n    //      rpc Foo(FooRequest) returns (FooResponse);\n    //      rpc Bar(BarRequest) returns (BarResponse);\n    //    }\n    //\n    //    // in \"bar.proto\"\n    //    package corge.grault\n    //    service TestService2 {\n    //      rpc Foo(FooRequest) returns (FooResponse);\n    //      rpc Baz(BazRequest) returns (BazResponse);\n    //    }\n\n    FileDescriptorProto foo_file;\n    foo_file.set_name(\"foo.proto\");\n\n    AddMessage(&foo_file, \"FooRequest\");\n    AddMessage(&foo_file, \"FooResponse\");\n    AddMessage(&foo_file, \"BarRequest\");\n    AddMessage(&foo_file, \"BarResponse\");\n    AddMessage(&foo_file, \"BazRequest\");\n    AddMessage(&foo_file, \"BazResponse\");\n\n    ServiceDescriptorProto* service = AddService(&foo_file, \"TestService\");\n    AddMethod(service, \"Foo\", \"FooRequest\", \"FooResponse\");\n    AddMethod(service, \"Bar\", \"BarRequest\", \"BarResponse\");\n\n    FileDescriptorProto bar_file;\n    bar_file.set_name(\"bar.proto\");\n    bar_file.set_package(\"corge.grault\");\n    bar_file.add_dependency(\"foo.proto\");\n\n    ServiceDescriptorProto* service2 = AddService(&bar_file, \"TestService2\");\n    AddMethod(service2, \"Foo\", \"FooRequest\", \"FooResponse\");\n    AddMethod(service2, \"Baz\", \"BazRequest\", \"BazResponse\");\n\n    // Build the descriptors and get the pointers.\n    foo_file_ = pool_.BuildFile(foo_file);\n    ASSERT_TRUE(foo_file_ != NULL);\n\n    bar_file_ = pool_.BuildFile(bar_file);\n    ASSERT_TRUE(bar_file_ != NULL);\n\n    ASSERT_EQ(6, foo_file_->message_type_count());\n    foo_request_  = foo_file_->message_type(0);\n    foo_response_ = foo_file_->message_type(1);\n    bar_request_  = foo_file_->message_type(2);\n    bar_response_ = foo_file_->message_type(3);\n    baz_request_  = foo_file_->message_type(4);\n    baz_response_ = foo_file_->message_type(5);\n\n    ASSERT_EQ(1, foo_file_->service_count());\n    service_ = foo_file_->service(0);\n\n    ASSERT_EQ(2, service_->method_count());\n    foo_ = service_->method(0);\n    bar_ = service_->method(1);\n\n    ASSERT_EQ(1, bar_file_->service_count());\n    service2_ = bar_file_->service(0);\n\n    ASSERT_EQ(2, service2_->method_count());\n    foo2_ = service2_->method(0);\n    baz2_ = service2_->method(1);\n  }\n\n  DescriptorPool pool_;\n\n  const FileDescriptor* foo_file_;\n  const FileDescriptor* bar_file_;\n\n  const Descriptor* foo_request_;\n  const Descriptor* foo_response_;\n  const Descriptor* bar_request_;\n  const Descriptor* bar_response_;\n  const Descriptor* baz_request_;\n  const Descriptor* baz_response_;\n\n  const ServiceDescriptor* service_;\n  const ServiceDescriptor* service2_;\n\n  const MethodDescriptor* foo_;\n  const MethodDescriptor* bar_;\n\n  const MethodDescriptor* foo2_;\n  const MethodDescriptor* baz2_;\n};\n\nTEST_F(ServiceDescriptorTest, Name) {\n  EXPECT_EQ(\"TestService\", service_->name());\n  EXPECT_EQ(\"TestService\", service_->full_name());\n  EXPECT_EQ(foo_file_, service_->file());\n\n  EXPECT_EQ(\"TestService2\", service2_->name());\n  EXPECT_EQ(\"corge.grault.TestService2\", service2_->full_name());\n  EXPECT_EQ(bar_file_, service2_->file());\n}\n\nTEST_F(ServiceDescriptorTest, MethodsByIndex) {\n  ASSERT_EQ(2, service_->method_count());\n  EXPECT_EQ(foo_, service_->method(0));\n  EXPECT_EQ(bar_, service_->method(1));\n}\n\nTEST_F(ServiceDescriptorTest, FindMethodByName) {\n  EXPECT_EQ(foo_ , service_ ->FindMethodByName(\"Foo\"));\n  EXPECT_EQ(bar_ , service_ ->FindMethodByName(\"Bar\"));\n  EXPECT_EQ(foo2_, service2_->FindMethodByName(\"Foo\"));\n  EXPECT_EQ(baz2_, service2_->FindMethodByName(\"Baz\"));\n\n  EXPECT_TRUE(service_ ->FindMethodByName(\"NoSuchMethod\") == NULL);\n  EXPECT_TRUE(service_ ->FindMethodByName(\"Baz\"         ) == NULL);\n  EXPECT_TRUE(service2_->FindMethodByName(\"Bar\"         ) == NULL);\n}\n\nTEST_F(ServiceDescriptorTest, MethodName) {\n  EXPECT_EQ(\"Foo\", foo_->name());\n  EXPECT_EQ(\"Bar\", bar_->name());\n}\n\nTEST_F(ServiceDescriptorTest, MethodFullName) {\n  EXPECT_EQ(\"TestService.Foo\", foo_->full_name());\n  EXPECT_EQ(\"TestService.Bar\", bar_->full_name());\n  EXPECT_EQ(\"corge.grault.TestService2.Foo\", foo2_->full_name());\n  EXPECT_EQ(\"corge.grault.TestService2.Baz\", baz2_->full_name());\n}\n\nTEST_F(ServiceDescriptorTest, MethodIndex) {\n  EXPECT_EQ(0, foo_->index());\n  EXPECT_EQ(1, bar_->index());\n}\n\nTEST_F(ServiceDescriptorTest, MethodParent) {\n  EXPECT_EQ(service_, foo_->service());\n  EXPECT_EQ(service_, bar_->service());\n}\n\nTEST_F(ServiceDescriptorTest, MethodInputType) {\n  EXPECT_EQ(foo_request_, foo_->input_type());\n  EXPECT_EQ(bar_request_, bar_->input_type());\n}\n\nTEST_F(ServiceDescriptorTest, MethodOutputType) {\n  EXPECT_EQ(foo_response_, foo_->output_type());\n  EXPECT_EQ(bar_response_, bar_->output_type());\n}\n\n// ===================================================================\n\n// Test nested types.\nclass NestedDescriptorTest : public testing::Test {\n protected:\n  virtual void SetUp() {\n    // Build descriptors for the following definitions:\n    //\n    //   // in \"foo.proto\"\n    //   message TestMessage {\n    //     message Foo {}\n    //     message Bar {}\n    //     enum Baz { A = 1; }\n    //     enum Qux { B = 1; }\n    //   }\n    //\n    //   // in \"bar.proto\"\n    //   package corge.grault;\n    //   message TestMessage2 {\n    //     message Foo {}\n    //     message Baz {}\n    //     enum Qux  { A = 1; }\n    //     enum Quux { C = 1; }\n    //   }\n    //\n    // TestMessage2 is primarily here to test FindNestedTypeByName and friends.\n    // All messages created from the same DescriptorPool share the same lookup\n    // table, so we need to insure that they don't interfere.\n    //\n    // We add enum values to the enums in order to test searching for enum\n    // values across a message's scope.\n\n    FileDescriptorProto foo_file;\n    foo_file.set_name(\"foo.proto\");\n\n    DescriptorProto* message = AddMessage(&foo_file, \"TestMessage\");\n    AddNestedMessage(message, \"Foo\");\n    AddNestedMessage(message, \"Bar\");\n    EnumDescriptorProto* baz = AddNestedEnum(message, \"Baz\");\n    AddEnumValue(baz, \"A\", 1);\n    EnumDescriptorProto* qux = AddNestedEnum(message, \"Qux\");\n    AddEnumValue(qux, \"B\", 1);\n\n    FileDescriptorProto bar_file;\n    bar_file.set_name(\"bar.proto\");\n    bar_file.set_package(\"corge.grault\");\n\n    DescriptorProto* message2 = AddMessage(&bar_file, \"TestMessage2\");\n    AddNestedMessage(message2, \"Foo\");\n    AddNestedMessage(message2, \"Baz\");\n    EnumDescriptorProto* qux2 = AddNestedEnum(message2, \"Qux\");\n    AddEnumValue(qux2, \"A\", 1);\n    EnumDescriptorProto* quux2 = AddNestedEnum(message2, \"Quux\");\n    AddEnumValue(quux2, \"C\", 1);\n\n    // Build the descriptors and get the pointers.\n    foo_file_ = pool_.BuildFile(foo_file);\n    ASSERT_TRUE(foo_file_ != NULL);\n\n    bar_file_ = pool_.BuildFile(bar_file);\n    ASSERT_TRUE(bar_file_ != NULL);\n\n    ASSERT_EQ(1, foo_file_->message_type_count());\n    message_ = foo_file_->message_type(0);\n\n    ASSERT_EQ(2, message_->nested_type_count());\n    foo_ = message_->nested_type(0);\n    bar_ = message_->nested_type(1);\n\n    ASSERT_EQ(2, message_->enum_type_count());\n    baz_ = message_->enum_type(0);\n    qux_ = message_->enum_type(1);\n\n    ASSERT_EQ(1, baz_->value_count());\n    a_ = baz_->value(0);\n    ASSERT_EQ(1, qux_->value_count());\n    b_ = qux_->value(0);\n\n    ASSERT_EQ(1, bar_file_->message_type_count());\n    message2_ = bar_file_->message_type(0);\n\n    ASSERT_EQ(2, message2_->nested_type_count());\n    foo2_ = message2_->nested_type(0);\n    baz2_ = message2_->nested_type(1);\n\n    ASSERT_EQ(2, message2_->enum_type_count());\n    qux2_ = message2_->enum_type(0);\n    quux2_ = message2_->enum_type(1);\n\n    ASSERT_EQ(1, qux2_->value_count());\n    a2_ = qux2_->value(0);\n    ASSERT_EQ(1, quux2_->value_count());\n    c2_ = quux2_->value(0);\n  }\n\n  DescriptorPool pool_;\n\n  const FileDescriptor* foo_file_;\n  const FileDescriptor* bar_file_;\n\n  const Descriptor* message_;\n  const Descriptor* message2_;\n\n  const Descriptor* foo_;\n  const Descriptor* bar_;\n  const EnumDescriptor* baz_;\n  const EnumDescriptor* qux_;\n  const EnumValueDescriptor* a_;\n  const EnumValueDescriptor* b_;\n\n  const Descriptor* foo2_;\n  const Descriptor* baz2_;\n  const EnumDescriptor* qux2_;\n  const EnumDescriptor* quux2_;\n  const EnumValueDescriptor* a2_;\n  const EnumValueDescriptor* c2_;\n};\n\nTEST_F(NestedDescriptorTest, MessageName) {\n  EXPECT_EQ(\"Foo\", foo_ ->name());\n  EXPECT_EQ(\"Bar\", bar_ ->name());\n  EXPECT_EQ(\"Foo\", foo2_->name());\n  EXPECT_EQ(\"Baz\", baz2_->name());\n\n  EXPECT_EQ(\"TestMessage.Foo\", foo_->full_name());\n  EXPECT_EQ(\"TestMessage.Bar\", bar_->full_name());\n  EXPECT_EQ(\"corge.grault.TestMessage2.Foo\", foo2_->full_name());\n  EXPECT_EQ(\"corge.grault.TestMessage2.Baz\", baz2_->full_name());\n}\n\nTEST_F(NestedDescriptorTest, MessageContainingType) {\n  EXPECT_EQ(message_ , foo_ ->containing_type());\n  EXPECT_EQ(message_ , bar_ ->containing_type());\n  EXPECT_EQ(message2_, foo2_->containing_type());\n  EXPECT_EQ(message2_, baz2_->containing_type());\n}\n\nTEST_F(NestedDescriptorTest, NestedMessagesByIndex) {\n  ASSERT_EQ(2, message_->nested_type_count());\n  EXPECT_EQ(foo_, message_->nested_type(0));\n  EXPECT_EQ(bar_, message_->nested_type(1));\n}\n\nTEST_F(NestedDescriptorTest, FindFieldByNameDoesntFindNestedTypes) {\n  EXPECT_TRUE(message_->FindFieldByName(\"Foo\") == NULL);\n  EXPECT_TRUE(message_->FindFieldByName(\"Qux\") == NULL);\n  EXPECT_TRUE(message_->FindExtensionByName(\"Foo\") == NULL);\n  EXPECT_TRUE(message_->FindExtensionByName(\"Qux\") == NULL);\n}\n\nTEST_F(NestedDescriptorTest, FindNestedTypeByName) {\n  EXPECT_EQ(foo_ , message_ ->FindNestedTypeByName(\"Foo\"));\n  EXPECT_EQ(bar_ , message_ ->FindNestedTypeByName(\"Bar\"));\n  EXPECT_EQ(foo2_, message2_->FindNestedTypeByName(\"Foo\"));\n  EXPECT_EQ(baz2_, message2_->FindNestedTypeByName(\"Baz\"));\n\n  EXPECT_TRUE(message_ ->FindNestedTypeByName(\"NoSuchType\") == NULL);\n  EXPECT_TRUE(message_ ->FindNestedTypeByName(\"Baz\"       ) == NULL);\n  EXPECT_TRUE(message2_->FindNestedTypeByName(\"Bar\"       ) == NULL);\n\n  EXPECT_TRUE(message_->FindNestedTypeByName(\"Qux\") == NULL);\n}\n\nTEST_F(NestedDescriptorTest, EnumName) {\n  EXPECT_EQ(\"Baz\" , baz_ ->name());\n  EXPECT_EQ(\"Qux\" , qux_ ->name());\n  EXPECT_EQ(\"Qux\" , qux2_->name());\n  EXPECT_EQ(\"Quux\", quux2_->name());\n\n  EXPECT_EQ(\"TestMessage.Baz\", baz_->full_name());\n  EXPECT_EQ(\"TestMessage.Qux\", qux_->full_name());\n  EXPECT_EQ(\"corge.grault.TestMessage2.Qux\" , qux2_ ->full_name());\n  EXPECT_EQ(\"corge.grault.TestMessage2.Quux\", quux2_->full_name());\n}\n\nTEST_F(NestedDescriptorTest, EnumContainingType) {\n  EXPECT_EQ(message_ , baz_  ->containing_type());\n  EXPECT_EQ(message_ , qux_  ->containing_type());\n  EXPECT_EQ(message2_, qux2_ ->containing_type());\n  EXPECT_EQ(message2_, quux2_->containing_type());\n}\n\nTEST_F(NestedDescriptorTest, NestedEnumsByIndex) {\n  ASSERT_EQ(2, message_->nested_type_count());\n  EXPECT_EQ(foo_, message_->nested_type(0));\n  EXPECT_EQ(bar_, message_->nested_type(1));\n}\n\nTEST_F(NestedDescriptorTest, FindEnumTypeByName) {\n  EXPECT_EQ(baz_  , message_ ->FindEnumTypeByName(\"Baz\" ));\n  EXPECT_EQ(qux_  , message_ ->FindEnumTypeByName(\"Qux\" ));\n  EXPECT_EQ(qux2_ , message2_->FindEnumTypeByName(\"Qux\" ));\n  EXPECT_EQ(quux2_, message2_->FindEnumTypeByName(\"Quux\"));\n\n  EXPECT_TRUE(message_ ->FindEnumTypeByName(\"NoSuchType\") == NULL);\n  EXPECT_TRUE(message_ ->FindEnumTypeByName(\"Quux\"      ) == NULL);\n  EXPECT_TRUE(message2_->FindEnumTypeByName(\"Baz\"       ) == NULL);\n\n  EXPECT_TRUE(message_->FindEnumTypeByName(\"Foo\") == NULL);\n}\n\nTEST_F(NestedDescriptorTest, FindEnumValueByName) {\n  EXPECT_EQ(a_ , message_ ->FindEnumValueByName(\"A\"));\n  EXPECT_EQ(b_ , message_ ->FindEnumValueByName(\"B\"));\n  EXPECT_EQ(a2_, message2_->FindEnumValueByName(\"A\"));\n  EXPECT_EQ(c2_, message2_->FindEnumValueByName(\"C\"));\n\n  EXPECT_TRUE(message_ ->FindEnumValueByName(\"NO_SUCH_VALUE\") == NULL);\n  EXPECT_TRUE(message_ ->FindEnumValueByName(\"C\"            ) == NULL);\n  EXPECT_TRUE(message2_->FindEnumValueByName(\"B\"            ) == NULL);\n\n  EXPECT_TRUE(message_->FindEnumValueByName(\"Foo\") == NULL);\n}\n\n// ===================================================================\n\n// Test extensions.\nclass ExtensionDescriptorTest : public testing::Test {\n protected:\n  virtual void SetUp() {\n    // Build descriptors for the following definitions:\n    //\n    //   enum Baz {}\n    //   message Qux {}\n    //\n    //   message Foo {\n    //     extensions 10 to 19;\n    //     extensions 30 to 39;\n    //   }\n    //   extends Foo with optional int32 foo_int32 = 10;\n    //   extends Foo with repeated TestEnum foo_enum = 19;\n    //   message Bar {\n    //     extends Foo with optional Qux foo_message = 30;\n    //     // (using Qux as the group type)\n    //     extends Foo with repeated group foo_group = 39;\n    //   }\n\n    FileDescriptorProto foo_file;\n    foo_file.set_name(\"foo.proto\");\n\n    AddEmptyEnum(&foo_file, \"Baz\");\n    AddMessage(&foo_file, \"Qux\");\n\n    DescriptorProto* foo = AddMessage(&foo_file, \"Foo\");\n    AddExtensionRange(foo, 10, 20);\n    AddExtensionRange(foo, 30, 40);\n\n    AddExtension(&foo_file, \"Foo\", \"foo_int32\", 10,\n                 FieldDescriptorProto::LABEL_OPTIONAL,\n                 FieldDescriptorProto::TYPE_INT32);\n    AddExtension(&foo_file, \"Foo\", \"foo_enum\", 19,\n                 FieldDescriptorProto::LABEL_REPEATED,\n                 FieldDescriptorProto::TYPE_ENUM)\n      ->set_type_name(\"Baz\");\n\n    DescriptorProto* bar = AddMessage(&foo_file, \"Bar\");\n    AddNestedExtension(bar, \"Foo\", \"foo_message\", 30,\n                       FieldDescriptorProto::LABEL_OPTIONAL,\n                       FieldDescriptorProto::TYPE_MESSAGE)\n      ->set_type_name(\"Qux\");\n    AddNestedExtension(bar, \"Foo\", \"foo_group\", 39,\n                       FieldDescriptorProto::LABEL_REPEATED,\n                       FieldDescriptorProto::TYPE_GROUP)\n      ->set_type_name(\"Qux\");\n\n    // Build the descriptors and get the pointers.\n    foo_file_ = pool_.BuildFile(foo_file);\n    ASSERT_TRUE(foo_file_ != NULL);\n\n    ASSERT_EQ(1, foo_file_->enum_type_count());\n    baz_ = foo_file_->enum_type(0);\n\n    ASSERT_EQ(3, foo_file_->message_type_count());\n    qux_ = foo_file_->message_type(0);\n    foo_ = foo_file_->message_type(1);\n    bar_ = foo_file_->message_type(2);\n  }\n\n  DescriptorPool pool_;\n\n  const FileDescriptor* foo_file_;\n\n  const Descriptor* foo_;\n  const Descriptor* bar_;\n  const EnumDescriptor* baz_;\n  const Descriptor* qux_;\n};\n\nTEST_F(ExtensionDescriptorTest, ExtensionRanges) {\n  EXPECT_EQ(0, bar_->extension_range_count());\n  ASSERT_EQ(2, foo_->extension_range_count());\n\n  EXPECT_EQ(10, foo_->extension_range(0)->start);\n  EXPECT_EQ(30, foo_->extension_range(1)->start);\n\n  EXPECT_EQ(20, foo_->extension_range(0)->end);\n  EXPECT_EQ(40, foo_->extension_range(1)->end);\n};\n\nTEST_F(ExtensionDescriptorTest, Extensions) {\n  EXPECT_EQ(0, foo_->extension_count());\n  ASSERT_EQ(2, foo_file_->extension_count());\n  ASSERT_EQ(2, bar_->extension_count());\n\n  EXPECT_TRUE(foo_file_->extension(0)->is_extension());\n  EXPECT_TRUE(foo_file_->extension(1)->is_extension());\n  EXPECT_TRUE(bar_->extension(0)->is_extension());\n  EXPECT_TRUE(bar_->extension(1)->is_extension());\n\n  EXPECT_EQ(\"foo_int32\"  , foo_file_->extension(0)->name());\n  EXPECT_EQ(\"foo_enum\"   , foo_file_->extension(1)->name());\n  EXPECT_EQ(\"foo_message\", bar_->extension(0)->name());\n  EXPECT_EQ(\"foo_group\"  , bar_->extension(1)->name());\n\n  EXPECT_EQ(10, foo_file_->extension(0)->number());\n  EXPECT_EQ(19, foo_file_->extension(1)->number());\n  EXPECT_EQ(30, bar_->extension(0)->number());\n  EXPECT_EQ(39, bar_->extension(1)->number());\n\n  EXPECT_EQ(FieldDescriptor::TYPE_INT32  , foo_file_->extension(0)->type());\n  EXPECT_EQ(FieldDescriptor::TYPE_ENUM   , foo_file_->extension(1)->type());\n  EXPECT_EQ(FieldDescriptor::TYPE_MESSAGE, bar_->extension(0)->type());\n  EXPECT_EQ(FieldDescriptor::TYPE_GROUP  , bar_->extension(1)->type());\n\n  EXPECT_EQ(baz_, foo_file_->extension(1)->enum_type());\n  EXPECT_EQ(qux_, bar_->extension(0)->message_type());\n  EXPECT_EQ(qux_, bar_->extension(1)->message_type());\n\n  EXPECT_EQ(FieldDescriptor::LABEL_OPTIONAL, foo_file_->extension(0)->label());\n  EXPECT_EQ(FieldDescriptor::LABEL_REPEATED, foo_file_->extension(1)->label());\n  EXPECT_EQ(FieldDescriptor::LABEL_OPTIONAL, bar_->extension(0)->label());\n  EXPECT_EQ(FieldDescriptor::LABEL_REPEATED, bar_->extension(1)->label());\n\n  EXPECT_EQ(foo_, foo_file_->extension(0)->containing_type());\n  EXPECT_EQ(foo_, foo_file_->extension(1)->containing_type());\n  EXPECT_EQ(foo_, bar_->extension(0)->containing_type());\n  EXPECT_EQ(foo_, bar_->extension(1)->containing_type());\n\n  EXPECT_TRUE(foo_file_->extension(0)->extension_scope() == NULL);\n  EXPECT_TRUE(foo_file_->extension(1)->extension_scope() == NULL);\n  EXPECT_EQ(bar_, bar_->extension(0)->extension_scope());\n  EXPECT_EQ(bar_, bar_->extension(1)->extension_scope());\n};\n\nTEST_F(ExtensionDescriptorTest, IsExtensionNumber) {\n  EXPECT_FALSE(foo_->IsExtensionNumber( 9));\n  EXPECT_TRUE (foo_->IsExtensionNumber(10));\n  EXPECT_TRUE (foo_->IsExtensionNumber(19));\n  EXPECT_FALSE(foo_->IsExtensionNumber(20));\n  EXPECT_FALSE(foo_->IsExtensionNumber(29));\n  EXPECT_TRUE (foo_->IsExtensionNumber(30));\n  EXPECT_TRUE (foo_->IsExtensionNumber(39));\n  EXPECT_FALSE(foo_->IsExtensionNumber(40));\n}\n\nTEST_F(ExtensionDescriptorTest, FindExtensionByName) {\n  // Note that FileDescriptor::FindExtensionByName() is tested by\n  // FileDescriptorTest.\n  ASSERT_EQ(2, bar_->extension_count());\n\n  EXPECT_EQ(bar_->extension(0), bar_->FindExtensionByName(\"foo_message\"));\n  EXPECT_EQ(bar_->extension(1), bar_->FindExtensionByName(\"foo_group\"  ));\n\n  EXPECT_TRUE(bar_->FindExtensionByName(\"no_such_extension\") == NULL);\n  EXPECT_TRUE(foo_->FindExtensionByName(\"foo_int32\") == NULL);\n  EXPECT_TRUE(foo_->FindExtensionByName(\"foo_message\") == NULL);\n}\n\nTEST_F(ExtensionDescriptorTest, FindAllExtensions) {\n  vector<const FieldDescriptor*> extensions;\n  pool_.FindAllExtensions(foo_, &extensions);\n  ASSERT_EQ(4, extensions.size());\n  EXPECT_EQ(10, extensions[0]->number());\n  EXPECT_EQ(19, extensions[1]->number());\n  EXPECT_EQ(30, extensions[2]->number());\n  EXPECT_EQ(39, extensions[3]->number());\n}\n\nTEST_F(ExtensionDescriptorTest, DuplicateFieldNumber) {\n  DescriptorPool pool;\n  FileDescriptorProto file_proto;\n  // Add \"google/protobuf/descriptor.proto\".\n  FileDescriptorProto::descriptor()->file()->CopyTo(&file_proto);\n  ASSERT_TRUE(pool.BuildFile(file_proto) != NULL);\n  // Add \"foo.proto\":\n  //   import \"google/protobuf/descriptor.proto\";\n  //   extend google.protobuf.FieldOptions {\n  //     optional int32 option1 = 1000;\n  //   }\n  file_proto.Clear();\n  file_proto.set_name(\"foo.proto\");\n  file_proto.add_dependency(\"google/protobuf/descriptor.proto\");\n  AddExtension(&file_proto, \"google.protobuf.FieldOptions\", \"option1\", 1000,\n               FieldDescriptorProto::LABEL_OPTIONAL,\n               FieldDescriptorProto::TYPE_INT32);\n  ASSERT_TRUE(pool.BuildFile(file_proto) != NULL);\n  // Add \"bar.proto\":\n  //   import \"google/protobuf/descriptor.proto\";\n  //   extend google.protobuf.FieldOptions {\n  //     optional int32 option2 = 1000;\n  //   }\n  file_proto.Clear();\n  file_proto.set_name(\"bar.proto\");\n  file_proto.add_dependency(\"google/protobuf/descriptor.proto\");\n  AddExtension(&file_proto, \"google.protobuf.FieldOptions\", \"option2\", 1000,\n               FieldDescriptorProto::LABEL_OPTIONAL,\n               FieldDescriptorProto::TYPE_INT32);\n  // Currently we only generate a warning for conflicting extension numbers.\n  // TODO(xiaofeng): Change it to an error.\n  ASSERT_TRUE(pool.BuildFile(file_proto) != NULL);\n}\n\n// ===================================================================\n\n// Test reserved fields.\nclass ReservedDescriptorTest : public testing::Test {\n protected:\n  virtual void SetUp() {\n    // Build descriptors for the following definitions:\n    //\n    //   message Foo {\n    //     reserved 2, 9 to 11, 15;\n    //     reserved \"foo\", \"bar\";\n    //   }\n\n    FileDescriptorProto foo_file;\n    foo_file.set_name(\"foo.proto\");\n\n    DescriptorProto* foo = AddMessage(&foo_file, \"Foo\");\n    AddReservedRange(foo, 2, 3);\n    AddReservedRange(foo, 9, 12);\n    AddReservedRange(foo, 15, 16);\n\n    foo->add_reserved_name(\"foo\");\n    foo->add_reserved_name(\"bar\");\n\n    // Build the descriptors and get the pointers.\n    foo_file_ = pool_.BuildFile(foo_file);\n    ASSERT_TRUE(foo_file_ != NULL);\n\n    ASSERT_EQ(1, foo_file_->message_type_count());\n    foo_ = foo_file_->message_type(0);\n  }\n\n  DescriptorPool pool_;\n  const FileDescriptor* foo_file_;\n  const Descriptor* foo_;\n};\n\nTEST_F(ReservedDescriptorTest, ReservedRanges) {\n  ASSERT_EQ(3, foo_->reserved_range_count());\n\n  EXPECT_EQ(2, foo_->reserved_range(0)->start);\n  EXPECT_EQ(3, foo_->reserved_range(0)->end);\n\n  EXPECT_EQ(9, foo_->reserved_range(1)->start);\n  EXPECT_EQ(12, foo_->reserved_range(1)->end);\n\n  EXPECT_EQ(15, foo_->reserved_range(2)->start);\n  EXPECT_EQ(16, foo_->reserved_range(2)->end);\n};\n\nTEST_F(ReservedDescriptorTest, IsReservedNumber) {\n  EXPECT_FALSE(foo_->IsReservedNumber(1));\n  EXPECT_TRUE (foo_->IsReservedNumber(2));\n  EXPECT_FALSE(foo_->IsReservedNumber(3));\n  EXPECT_FALSE(foo_->IsReservedNumber(8));\n  EXPECT_TRUE (foo_->IsReservedNumber(9));\n  EXPECT_TRUE (foo_->IsReservedNumber(10));\n  EXPECT_TRUE (foo_->IsReservedNumber(11));\n  EXPECT_FALSE(foo_->IsReservedNumber(12));\n  EXPECT_FALSE(foo_->IsReservedNumber(13));\n  EXPECT_FALSE(foo_->IsReservedNumber(14));\n  EXPECT_TRUE (foo_->IsReservedNumber(15));\n  EXPECT_FALSE(foo_->IsReservedNumber(16));\n};\n\nTEST_F(ReservedDescriptorTest, ReservedNames) {\n  ASSERT_EQ(2, foo_->reserved_name_count());\n\n  EXPECT_EQ(\"foo\", foo_->reserved_name(0));\n  EXPECT_EQ(\"bar\", foo_->reserved_name(1));\n};\n\nTEST_F(ReservedDescriptorTest, IsReservedName) {\n  EXPECT_TRUE (foo_->IsReservedName(\"foo\"));\n  EXPECT_TRUE (foo_->IsReservedName(\"bar\"));\n  EXPECT_FALSE(foo_->IsReservedName(\"baz\"));\n};\n\n// ===================================================================\n\nclass MiscTest : public testing::Test {\n protected:\n  // Function which makes a field descriptor of the given type.\n  const FieldDescriptor* GetFieldDescriptorOfType(FieldDescriptor::Type type) {\n    FileDescriptorProto file_proto;\n    file_proto.set_name(\"foo.proto\");\n    AddEmptyEnum(&file_proto, \"DummyEnum\");\n\n    DescriptorProto* message = AddMessage(&file_proto, \"TestMessage\");\n    FieldDescriptorProto* field =\n      AddField(message, \"foo\", 1, FieldDescriptorProto::LABEL_OPTIONAL,\n               static_cast<FieldDescriptorProto::Type>(static_cast<int>(type)));\n\n    if (type == FieldDescriptor::TYPE_MESSAGE ||\n        type == FieldDescriptor::TYPE_GROUP) {\n      field->set_type_name(\"TestMessage\");\n    } else if (type == FieldDescriptor::TYPE_ENUM) {\n      field->set_type_name(\"DummyEnum\");\n    }\n\n    // Build the descriptors and get the pointers.\n    pool_.reset(new DescriptorPool());\n    const FileDescriptor* file = pool_->BuildFile(file_proto);\n\n    if (file != NULL &&\n        file->message_type_count() == 1 &&\n        file->message_type(0)->field_count() == 1) {\n      return file->message_type(0)->field(0);\n    } else {\n      return NULL;\n    }\n  }\n\n  const char* GetTypeNameForFieldType(FieldDescriptor::Type type) {\n    const FieldDescriptor* field = GetFieldDescriptorOfType(type);\n    return field != NULL ? field->type_name() : \"\";\n  }\n\n  FieldDescriptor::CppType GetCppTypeForFieldType(FieldDescriptor::Type type) {\n    const FieldDescriptor* field = GetFieldDescriptorOfType(type);\n    return field != NULL ? field->cpp_type() :\n        static_cast<FieldDescriptor::CppType>(0);\n  }\n\n  const char* GetCppTypeNameForFieldType(FieldDescriptor::Type type) {\n    const FieldDescriptor* field = GetFieldDescriptorOfType(type);\n    return field != NULL ? field->cpp_type_name() : \"\";\n  }\n\n  const Descriptor* GetMessageDescriptorForFieldType(\n      FieldDescriptor::Type type) {\n    const FieldDescriptor* field = GetFieldDescriptorOfType(type);\n    return field != NULL ? field->message_type() : NULL;\n  }\n\n  const EnumDescriptor* GetEnumDescriptorForFieldType(\n    FieldDescriptor::Type type) {\n    const FieldDescriptor* field = GetFieldDescriptorOfType(type);\n    return field != NULL ? field->enum_type() : NULL;\n  }\n\n  google::protobuf::scoped_ptr<DescriptorPool> pool_;\n};\n\nTEST_F(MiscTest, TypeNames) {\n  // Test that correct type names are returned.\n\n  typedef FieldDescriptor FD;  // avoid ugly line wrapping\n\n  EXPECT_STREQ(\"double\"  , GetTypeNameForFieldType(FD::TYPE_DOUBLE  ));\n  EXPECT_STREQ(\"float\"   , GetTypeNameForFieldType(FD::TYPE_FLOAT   ));\n  EXPECT_STREQ(\"int64\"   , GetTypeNameForFieldType(FD::TYPE_INT64   ));\n  EXPECT_STREQ(\"uint64\"  , GetTypeNameForFieldType(FD::TYPE_UINT64  ));\n  EXPECT_STREQ(\"int32\"   , GetTypeNameForFieldType(FD::TYPE_INT32   ));\n  EXPECT_STREQ(\"fixed64\" , GetTypeNameForFieldType(FD::TYPE_FIXED64 ));\n  EXPECT_STREQ(\"fixed32\" , GetTypeNameForFieldType(FD::TYPE_FIXED32 ));\n  EXPECT_STREQ(\"bool\"    , GetTypeNameForFieldType(FD::TYPE_BOOL    ));\n  EXPECT_STREQ(\"string\"  , GetTypeNameForFieldType(FD::TYPE_STRING  ));\n  EXPECT_STREQ(\"group\"   , GetTypeNameForFieldType(FD::TYPE_GROUP   ));\n  EXPECT_STREQ(\"message\" , GetTypeNameForFieldType(FD::TYPE_MESSAGE ));\n  EXPECT_STREQ(\"bytes\"   , GetTypeNameForFieldType(FD::TYPE_BYTES   ));\n  EXPECT_STREQ(\"uint32\"  , GetTypeNameForFieldType(FD::TYPE_UINT32  ));\n  EXPECT_STREQ(\"enum\"    , GetTypeNameForFieldType(FD::TYPE_ENUM    ));\n  EXPECT_STREQ(\"sfixed32\", GetTypeNameForFieldType(FD::TYPE_SFIXED32));\n  EXPECT_STREQ(\"sfixed64\", GetTypeNameForFieldType(FD::TYPE_SFIXED64));\n  EXPECT_STREQ(\"sint32\"  , GetTypeNameForFieldType(FD::TYPE_SINT32  ));\n  EXPECT_STREQ(\"sint64\"  , GetTypeNameForFieldType(FD::TYPE_SINT64  ));\n}\n\nTEST_F(MiscTest, StaticTypeNames) {\n  // Test that correct type names are returned.\n\n  typedef FieldDescriptor FD;  // avoid ugly line wrapping\n\n  EXPECT_STREQ(\"double\"  , FD::TypeName(FD::TYPE_DOUBLE  ));\n  EXPECT_STREQ(\"float\"   , FD::TypeName(FD::TYPE_FLOAT   ));\n  EXPECT_STREQ(\"int64\"   , FD::TypeName(FD::TYPE_INT64   ));\n  EXPECT_STREQ(\"uint64\"  , FD::TypeName(FD::TYPE_UINT64  ));\n  EXPECT_STREQ(\"int32\"   , FD::TypeName(FD::TYPE_INT32   ));\n  EXPECT_STREQ(\"fixed64\" , FD::TypeName(FD::TYPE_FIXED64 ));\n  EXPECT_STREQ(\"fixed32\" , FD::TypeName(FD::TYPE_FIXED32 ));\n  EXPECT_STREQ(\"bool\"    , FD::TypeName(FD::TYPE_BOOL    ));\n  EXPECT_STREQ(\"string\"  , FD::TypeName(FD::TYPE_STRING  ));\n  EXPECT_STREQ(\"group\"   , FD::TypeName(FD::TYPE_GROUP   ));\n  EXPECT_STREQ(\"message\" , FD::TypeName(FD::TYPE_MESSAGE ));\n  EXPECT_STREQ(\"bytes\"   , FD::TypeName(FD::TYPE_BYTES   ));\n  EXPECT_STREQ(\"uint32\"  , FD::TypeName(FD::TYPE_UINT32  ));\n  EXPECT_STREQ(\"enum\"    , FD::TypeName(FD::TYPE_ENUM    ));\n  EXPECT_STREQ(\"sfixed32\", FD::TypeName(FD::TYPE_SFIXED32));\n  EXPECT_STREQ(\"sfixed64\", FD::TypeName(FD::TYPE_SFIXED64));\n  EXPECT_STREQ(\"sint32\"  , FD::TypeName(FD::TYPE_SINT32  ));\n  EXPECT_STREQ(\"sint64\"  , FD::TypeName(FD::TYPE_SINT64  ));\n}\n\nTEST_F(MiscTest, CppTypes) {\n  // Test that CPP types are assigned correctly.\n\n  typedef FieldDescriptor FD;  // avoid ugly line wrapping\n\n  EXPECT_EQ(FD::CPPTYPE_DOUBLE , GetCppTypeForFieldType(FD::TYPE_DOUBLE  ));\n  EXPECT_EQ(FD::CPPTYPE_FLOAT  , GetCppTypeForFieldType(FD::TYPE_FLOAT   ));\n  EXPECT_EQ(FD::CPPTYPE_INT64  , GetCppTypeForFieldType(FD::TYPE_INT64   ));\n  EXPECT_EQ(FD::CPPTYPE_UINT64 , GetCppTypeForFieldType(FD::TYPE_UINT64  ));\n  EXPECT_EQ(FD::CPPTYPE_INT32  , GetCppTypeForFieldType(FD::TYPE_INT32   ));\n  EXPECT_EQ(FD::CPPTYPE_UINT64 , GetCppTypeForFieldType(FD::TYPE_FIXED64 ));\n  EXPECT_EQ(FD::CPPTYPE_UINT32 , GetCppTypeForFieldType(FD::TYPE_FIXED32 ));\n  EXPECT_EQ(FD::CPPTYPE_BOOL   , GetCppTypeForFieldType(FD::TYPE_BOOL    ));\n  EXPECT_EQ(FD::CPPTYPE_STRING , GetCppTypeForFieldType(FD::TYPE_STRING  ));\n  EXPECT_EQ(FD::CPPTYPE_MESSAGE, GetCppTypeForFieldType(FD::TYPE_GROUP   ));\n  EXPECT_EQ(FD::CPPTYPE_MESSAGE, GetCppTypeForFieldType(FD::TYPE_MESSAGE ));\n  EXPECT_EQ(FD::CPPTYPE_STRING , GetCppTypeForFieldType(FD::TYPE_BYTES   ));\n  EXPECT_EQ(FD::CPPTYPE_UINT32 , GetCppTypeForFieldType(FD::TYPE_UINT32  ));\n  EXPECT_EQ(FD::CPPTYPE_ENUM   , GetCppTypeForFieldType(FD::TYPE_ENUM    ));\n  EXPECT_EQ(FD::CPPTYPE_INT32  , GetCppTypeForFieldType(FD::TYPE_SFIXED32));\n  EXPECT_EQ(FD::CPPTYPE_INT64  , GetCppTypeForFieldType(FD::TYPE_SFIXED64));\n  EXPECT_EQ(FD::CPPTYPE_INT32  , GetCppTypeForFieldType(FD::TYPE_SINT32  ));\n  EXPECT_EQ(FD::CPPTYPE_INT64  , GetCppTypeForFieldType(FD::TYPE_SINT64  ));\n}\n\nTEST_F(MiscTest, CppTypeNames) {\n  // Test that correct CPP type names are returned.\n\n  typedef FieldDescriptor FD;  // avoid ugly line wrapping\n\n  EXPECT_STREQ(\"double\" , GetCppTypeNameForFieldType(FD::TYPE_DOUBLE  ));\n  EXPECT_STREQ(\"float\"  , GetCppTypeNameForFieldType(FD::TYPE_FLOAT   ));\n  EXPECT_STREQ(\"int64\"  , GetCppTypeNameForFieldType(FD::TYPE_INT64   ));\n  EXPECT_STREQ(\"uint64\" , GetCppTypeNameForFieldType(FD::TYPE_UINT64  ));\n  EXPECT_STREQ(\"int32\"  , GetCppTypeNameForFieldType(FD::TYPE_INT32   ));\n  EXPECT_STREQ(\"uint64\" , GetCppTypeNameForFieldType(FD::TYPE_FIXED64 ));\n  EXPECT_STREQ(\"uint32\" , GetCppTypeNameForFieldType(FD::TYPE_FIXED32 ));\n  EXPECT_STREQ(\"bool\"   , GetCppTypeNameForFieldType(FD::TYPE_BOOL    ));\n  EXPECT_STREQ(\"string\" , GetCppTypeNameForFieldType(FD::TYPE_STRING  ));\n  EXPECT_STREQ(\"message\", GetCppTypeNameForFieldType(FD::TYPE_GROUP   ));\n  EXPECT_STREQ(\"message\", GetCppTypeNameForFieldType(FD::TYPE_MESSAGE ));\n  EXPECT_STREQ(\"string\" , GetCppTypeNameForFieldType(FD::TYPE_BYTES   ));\n  EXPECT_STREQ(\"uint32\" , GetCppTypeNameForFieldType(FD::TYPE_UINT32  ));\n  EXPECT_STREQ(\"enum\"   , GetCppTypeNameForFieldType(FD::TYPE_ENUM    ));\n  EXPECT_STREQ(\"int32\"  , GetCppTypeNameForFieldType(FD::TYPE_SFIXED32));\n  EXPECT_STREQ(\"int64\"  , GetCppTypeNameForFieldType(FD::TYPE_SFIXED64));\n  EXPECT_STREQ(\"int32\"  , GetCppTypeNameForFieldType(FD::TYPE_SINT32  ));\n  EXPECT_STREQ(\"int64\"  , GetCppTypeNameForFieldType(FD::TYPE_SINT64  ));\n}\n\nTEST_F(MiscTest, StaticCppTypeNames) {\n  // Test that correct CPP type names are returned.\n\n  typedef FieldDescriptor FD;  // avoid ugly line wrapping\n\n  EXPECT_STREQ(\"int32\"  , FD::CppTypeName(FD::CPPTYPE_INT32  ));\n  EXPECT_STREQ(\"int64\"  , FD::CppTypeName(FD::CPPTYPE_INT64  ));\n  EXPECT_STREQ(\"uint32\" , FD::CppTypeName(FD::CPPTYPE_UINT32 ));\n  EXPECT_STREQ(\"uint64\" , FD::CppTypeName(FD::CPPTYPE_UINT64 ));\n  EXPECT_STREQ(\"double\" , FD::CppTypeName(FD::CPPTYPE_DOUBLE ));\n  EXPECT_STREQ(\"float\"  , FD::CppTypeName(FD::CPPTYPE_FLOAT  ));\n  EXPECT_STREQ(\"bool\"   , FD::CppTypeName(FD::CPPTYPE_BOOL   ));\n  EXPECT_STREQ(\"enum\"   , FD::CppTypeName(FD::CPPTYPE_ENUM   ));\n  EXPECT_STREQ(\"string\" , FD::CppTypeName(FD::CPPTYPE_STRING ));\n  EXPECT_STREQ(\"message\", FD::CppTypeName(FD::CPPTYPE_MESSAGE));\n}\n\nTEST_F(MiscTest, MessageType) {\n  // Test that message_type() is NULL for non-aggregate fields\n\n  typedef FieldDescriptor FD;  // avoid ugly line wrapping\n\n  EXPECT_TRUE(NULL == GetMessageDescriptorForFieldType(FD::TYPE_DOUBLE  ));\n  EXPECT_TRUE(NULL == GetMessageDescriptorForFieldType(FD::TYPE_FLOAT   ));\n  EXPECT_TRUE(NULL == GetMessageDescriptorForFieldType(FD::TYPE_INT64   ));\n  EXPECT_TRUE(NULL == GetMessageDescriptorForFieldType(FD::TYPE_UINT64  ));\n  EXPECT_TRUE(NULL == GetMessageDescriptorForFieldType(FD::TYPE_INT32   ));\n  EXPECT_TRUE(NULL == GetMessageDescriptorForFieldType(FD::TYPE_FIXED64 ));\n  EXPECT_TRUE(NULL == GetMessageDescriptorForFieldType(FD::TYPE_FIXED32 ));\n  EXPECT_TRUE(NULL == GetMessageDescriptorForFieldType(FD::TYPE_BOOL    ));\n  EXPECT_TRUE(NULL == GetMessageDescriptorForFieldType(FD::TYPE_STRING  ));\n  EXPECT_TRUE(NULL != GetMessageDescriptorForFieldType(FD::TYPE_GROUP   ));\n  EXPECT_TRUE(NULL != GetMessageDescriptorForFieldType(FD::TYPE_MESSAGE ));\n  EXPECT_TRUE(NULL == GetMessageDescriptorForFieldType(FD::TYPE_BYTES   ));\n  EXPECT_TRUE(NULL == GetMessageDescriptorForFieldType(FD::TYPE_UINT32  ));\n  EXPECT_TRUE(NULL == GetMessageDescriptorForFieldType(FD::TYPE_ENUM    ));\n  EXPECT_TRUE(NULL == GetMessageDescriptorForFieldType(FD::TYPE_SFIXED32));\n  EXPECT_TRUE(NULL == GetMessageDescriptorForFieldType(FD::TYPE_SFIXED64));\n  EXPECT_TRUE(NULL == GetMessageDescriptorForFieldType(FD::TYPE_SINT32  ));\n  EXPECT_TRUE(NULL == GetMessageDescriptorForFieldType(FD::TYPE_SINT64  ));\n}\n\nTEST_F(MiscTest, EnumType) {\n  // Test that enum_type() is NULL for non-enum fields\n\n  typedef FieldDescriptor FD;  // avoid ugly line wrapping\n\n  EXPECT_TRUE(NULL == GetEnumDescriptorForFieldType(FD::TYPE_DOUBLE  ));\n  EXPECT_TRUE(NULL == GetEnumDescriptorForFieldType(FD::TYPE_FLOAT   ));\n  EXPECT_TRUE(NULL == GetEnumDescriptorForFieldType(FD::TYPE_INT64   ));\n  EXPECT_TRUE(NULL == GetEnumDescriptorForFieldType(FD::TYPE_UINT64  ));\n  EXPECT_TRUE(NULL == GetEnumDescriptorForFieldType(FD::TYPE_INT32   ));\n  EXPECT_TRUE(NULL == GetEnumDescriptorForFieldType(FD::TYPE_FIXED64 ));\n  EXPECT_TRUE(NULL == GetEnumDescriptorForFieldType(FD::TYPE_FIXED32 ));\n  EXPECT_TRUE(NULL == GetEnumDescriptorForFieldType(FD::TYPE_BOOL    ));\n  EXPECT_TRUE(NULL == GetEnumDescriptorForFieldType(FD::TYPE_STRING  ));\n  EXPECT_TRUE(NULL == GetEnumDescriptorForFieldType(FD::TYPE_GROUP   ));\n  EXPECT_TRUE(NULL == GetEnumDescriptorForFieldType(FD::TYPE_MESSAGE ));\n  EXPECT_TRUE(NULL == GetEnumDescriptorForFieldType(FD::TYPE_BYTES   ));\n  EXPECT_TRUE(NULL == GetEnumDescriptorForFieldType(FD::TYPE_UINT32  ));\n  EXPECT_TRUE(NULL != GetEnumDescriptorForFieldType(FD::TYPE_ENUM    ));\n  EXPECT_TRUE(NULL == GetEnumDescriptorForFieldType(FD::TYPE_SFIXED32));\n  EXPECT_TRUE(NULL == GetEnumDescriptorForFieldType(FD::TYPE_SFIXED64));\n  EXPECT_TRUE(NULL == GetEnumDescriptorForFieldType(FD::TYPE_SINT32  ));\n  EXPECT_TRUE(NULL == GetEnumDescriptorForFieldType(FD::TYPE_SINT64  ));\n}\n\n\nTEST_F(MiscTest, DefaultValues) {\n  // Test that setting default values works.\n  FileDescriptorProto file_proto;\n  file_proto.set_name(\"foo.proto\");\n\n  EnumDescriptorProto* enum_type_proto = AddEnum(&file_proto, \"DummyEnum\");\n  AddEnumValue(enum_type_proto, \"A\", 1);\n  AddEnumValue(enum_type_proto, \"B\", 2);\n\n  DescriptorProto* message_proto = AddMessage(&file_proto, \"TestMessage\");\n\n  typedef FieldDescriptorProto FD;  // avoid ugly line wrapping\n  const FD::Label label = FD::LABEL_OPTIONAL;\n\n  // Create fields of every CPP type with default values.\n  AddField(message_proto, \"int32\" , 1, label, FD::TYPE_INT32 )\n    ->set_default_value(\"-1\");\n  AddField(message_proto, \"int64\" , 2, label, FD::TYPE_INT64 )\n    ->set_default_value(\"-1000000000000\");\n  AddField(message_proto, \"uint32\", 3, label, FD::TYPE_UINT32)\n    ->set_default_value(\"42\");\n  AddField(message_proto, \"uint64\", 4, label, FD::TYPE_UINT64)\n    ->set_default_value(\"2000000000000\");\n  AddField(message_proto, \"float\" , 5, label, FD::TYPE_FLOAT )\n    ->set_default_value(\"4.5\");\n  AddField(message_proto, \"double\", 6, label, FD::TYPE_DOUBLE)\n    ->set_default_value(\"10e100\");\n  AddField(message_proto, \"bool\"  , 7, label, FD::TYPE_BOOL  )\n    ->set_default_value(\"true\");\n  AddField(message_proto, \"string\", 8, label, FD::TYPE_STRING)\n    ->set_default_value(\"hello\");\n  AddField(message_proto, \"data\"  , 9, label, FD::TYPE_BYTES )\n    ->set_default_value(\"\\\\001\\\\002\\\\003\");\n\n  FieldDescriptorProto* enum_field =\n    AddField(message_proto, \"enum\", 10, label, FD::TYPE_ENUM);\n  enum_field->set_type_name(\"DummyEnum\");\n  enum_field->set_default_value(\"B\");\n\n  // Strings are allowed to have empty defaults.  (At one point, due to\n  // a bug, empty defaults for strings were rejected.  Oops.)\n  AddField(message_proto, \"empty_string\", 11, label, FD::TYPE_STRING)\n    ->set_default_value(\"\");\n\n  // Add a second set of fields with implicit defalut values.\n  AddField(message_proto, \"implicit_int32\" , 21, label, FD::TYPE_INT32 );\n  AddField(message_proto, \"implicit_int64\" , 22, label, FD::TYPE_INT64 );\n  AddField(message_proto, \"implicit_uint32\", 23, label, FD::TYPE_UINT32);\n  AddField(message_proto, \"implicit_uint64\", 24, label, FD::TYPE_UINT64);\n  AddField(message_proto, \"implicit_float\" , 25, label, FD::TYPE_FLOAT );\n  AddField(message_proto, \"implicit_double\", 26, label, FD::TYPE_DOUBLE);\n  AddField(message_proto, \"implicit_bool\"  , 27, label, FD::TYPE_BOOL  );\n  AddField(message_proto, \"implicit_string\", 28, label, FD::TYPE_STRING);\n  AddField(message_proto, \"implicit_data\"  , 29, label, FD::TYPE_BYTES );\n  AddField(message_proto, \"implicit_enum\"  , 30, label, FD::TYPE_ENUM)\n    ->set_type_name(\"DummyEnum\");\n\n  // Build it.\n  DescriptorPool pool;\n  const FileDescriptor* file = pool.BuildFile(file_proto);\n  ASSERT_TRUE(file != NULL);\n\n  ASSERT_EQ(1, file->enum_type_count());\n  const EnumDescriptor* enum_type = file->enum_type(0);\n  ASSERT_EQ(2, enum_type->value_count());\n  const EnumValueDescriptor* enum_value_a = enum_type->value(0);\n  const EnumValueDescriptor* enum_value_b = enum_type->value(1);\n\n  ASSERT_EQ(1, file->message_type_count());\n  const Descriptor* message = file->message_type(0);\n\n  ASSERT_EQ(21, message->field_count());\n\n  // Check the default values.\n  ASSERT_TRUE(message->field(0)->has_default_value());\n  ASSERT_TRUE(message->field(1)->has_default_value());\n  ASSERT_TRUE(message->field(2)->has_default_value());\n  ASSERT_TRUE(message->field(3)->has_default_value());\n  ASSERT_TRUE(message->field(4)->has_default_value());\n  ASSERT_TRUE(message->field(5)->has_default_value());\n  ASSERT_TRUE(message->field(6)->has_default_value());\n  ASSERT_TRUE(message->field(7)->has_default_value());\n  ASSERT_TRUE(message->field(8)->has_default_value());\n  ASSERT_TRUE(message->field(9)->has_default_value());\n  ASSERT_TRUE(message->field(10)->has_default_value());\n\n  EXPECT_EQ(-1              , message->field(0)->default_value_int32 ());\n  EXPECT_EQ(-GOOGLE_ULONGLONG(1000000000000),\n            message->field(1)->default_value_int64 ());\n  EXPECT_EQ(42              , message->field(2)->default_value_uint32());\n  EXPECT_EQ(GOOGLE_ULONGLONG(2000000000000),\n            message->field(3)->default_value_uint64());\n  EXPECT_EQ(4.5             , message->field(4)->default_value_float ());\n  EXPECT_EQ(10e100          , message->field(5)->default_value_double());\n  EXPECT_TRUE(                message->field(6)->default_value_bool  ());\n  EXPECT_EQ(\"hello\"         , message->field(7)->default_value_string());\n  EXPECT_EQ(\"\\001\\002\\003\"  , message->field(8)->default_value_string());\n  EXPECT_EQ(enum_value_b    , message->field(9)->default_value_enum  ());\n  EXPECT_EQ(\"\"              , message->field(10)->default_value_string());\n\n  ASSERT_FALSE(message->field(11)->has_default_value());\n  ASSERT_FALSE(message->field(12)->has_default_value());\n  ASSERT_FALSE(message->field(13)->has_default_value());\n  ASSERT_FALSE(message->field(14)->has_default_value());\n  ASSERT_FALSE(message->field(15)->has_default_value());\n  ASSERT_FALSE(message->field(16)->has_default_value());\n  ASSERT_FALSE(message->field(17)->has_default_value());\n  ASSERT_FALSE(message->field(18)->has_default_value());\n  ASSERT_FALSE(message->field(19)->has_default_value());\n  ASSERT_FALSE(message->field(20)->has_default_value());\n\n  EXPECT_EQ(0    , message->field(11)->default_value_int32 ());\n  EXPECT_EQ(0    , message->field(12)->default_value_int64 ());\n  EXPECT_EQ(0    , message->field(13)->default_value_uint32());\n  EXPECT_EQ(0    , message->field(14)->default_value_uint64());\n  EXPECT_EQ(0.0f , message->field(15)->default_value_float ());\n  EXPECT_EQ(0.0  , message->field(16)->default_value_double());\n  EXPECT_FALSE(    message->field(17)->default_value_bool  ());\n  EXPECT_EQ(\"\"   , message->field(18)->default_value_string());\n  EXPECT_EQ(\"\"   , message->field(19)->default_value_string());\n  EXPECT_EQ(enum_value_a, message->field(20)->default_value_enum());\n}\n\nTEST_F(MiscTest, FieldOptions) {\n  // Try setting field options.\n\n  FileDescriptorProto file_proto;\n  file_proto.set_name(\"foo.proto\");\n\n  DescriptorProto* message_proto = AddMessage(&file_proto, \"TestMessage\");\n  AddField(message_proto, \"foo\", 1,\n           FieldDescriptorProto::LABEL_OPTIONAL,\n           FieldDescriptorProto::TYPE_INT32);\n  FieldDescriptorProto* bar_proto =\n    AddField(message_proto, \"bar\", 2,\n             FieldDescriptorProto::LABEL_OPTIONAL,\n             FieldDescriptorProto::TYPE_INT32);\n\n  FieldOptions* options = bar_proto->mutable_options();\n  options->set_ctype(FieldOptions::CORD);\n\n  // Build the descriptors and get the pointers.\n  DescriptorPool pool;\n  const FileDescriptor* file = pool.BuildFile(file_proto);\n  ASSERT_TRUE(file != NULL);\n\n  ASSERT_EQ(1, file->message_type_count());\n  const Descriptor* message = file->message_type(0);\n\n  ASSERT_EQ(2, message->field_count());\n  const FieldDescriptor* foo = message->field(0);\n  const FieldDescriptor* bar = message->field(1);\n\n  // \"foo\" had no options set, so it should return the default options.\n  EXPECT_EQ(&FieldOptions::default_instance(), &foo->options());\n\n  // \"bar\" had options set.\n  EXPECT_NE(&FieldOptions::default_instance(), options);\n  EXPECT_TRUE(bar->options().has_ctype());\n  EXPECT_EQ(FieldOptions::CORD, bar->options().ctype());\n}\n\n// ===================================================================\nenum DescriptorPoolMode {\n  NO_DATABASE,\n  FALLBACK_DATABASE\n};\n\nclass AllowUnknownDependenciesTest\n    : public testing::TestWithParam<DescriptorPoolMode> {\n protected:\n  DescriptorPoolMode mode() {\n    return GetParam();\n   }\n\n  virtual void SetUp() {\n    FileDescriptorProto foo_proto, bar_proto;\n\n    switch (mode()) {\n      case NO_DATABASE:\n        pool_.reset(new DescriptorPool);\n        break;\n      case FALLBACK_DATABASE:\n        pool_.reset(new DescriptorPool(&db_));\n        break;\n    }\n\n    pool_->AllowUnknownDependencies();\n\n    ASSERT_TRUE(TextFormat::ParseFromString(\n      \"name: 'foo.proto'\"\n      \"dependency: 'bar.proto'\"\n      \"dependency: 'baz.proto'\"\n      \"message_type {\"\n      \"  name: 'Foo'\"\n      \"  field { name:'bar' number:1 label:LABEL_OPTIONAL type_name:'Bar' }\"\n      \"  field { name:'baz' number:2 label:LABEL_OPTIONAL type_name:'Baz' }\"\n      \"  field { name:'qux' number:3 label:LABEL_OPTIONAL\"\n      \"    type_name: '.corge.Qux'\"\n      \"    type: TYPE_ENUM\"\n      \"    options {\"\n      \"      uninterpreted_option {\"\n      \"        name {\"\n      \"          name_part: 'grault'\"\n      \"          is_extension: true\"\n      \"        }\"\n      \"        positive_int_value: 1234\"\n      \"      }\"\n      \"    }\"\n      \"  }\"\n      \"}\",\n      &foo_proto));\n    ASSERT_TRUE(TextFormat::ParseFromString(\n      \"name: 'bar.proto'\"\n      \"message_type { name: 'Bar' }\",\n      &bar_proto));\n\n    // Collect pointers to stuff.\n    bar_file_ = BuildFile(bar_proto);\n    ASSERT_TRUE(bar_file_ != NULL);\n\n    ASSERT_EQ(1, bar_file_->message_type_count());\n    bar_type_ = bar_file_->message_type(0);\n\n    foo_file_ = BuildFile(foo_proto);\n    ASSERT_TRUE(foo_file_ != NULL);\n\n    ASSERT_EQ(1, foo_file_->message_type_count());\n    foo_type_ = foo_file_->message_type(0);\n\n    ASSERT_EQ(3, foo_type_->field_count());\n    bar_field_ = foo_type_->field(0);\n    baz_field_ = foo_type_->field(1);\n    qux_field_ = foo_type_->field(2);\n  }\n\n  const FileDescriptor* BuildFile(const FileDescriptorProto& proto) {\n    switch (mode()) {\n      case NO_DATABASE:\n        return pool_->BuildFile(proto);\n        break;\n      case FALLBACK_DATABASE: {\n        EXPECT_TRUE(db_.Add(proto));\n        return pool_->FindFileByName(proto.name());\n      }\n    }\n    GOOGLE_LOG(FATAL) << \"Can't get here.\";\n    return NULL;\n  }\n\n  const FileDescriptor* bar_file_;\n  const Descriptor* bar_type_;\n  const FileDescriptor* foo_file_;\n  const Descriptor* foo_type_;\n  const FieldDescriptor* bar_field_;\n  const FieldDescriptor* baz_field_;\n  const FieldDescriptor* qux_field_;\n\n  SimpleDescriptorDatabase db_;        // used if in FALLBACK_DATABASE mode.\n  google::protobuf::scoped_ptr<DescriptorPool> pool_;\n};\n\nTEST_P(AllowUnknownDependenciesTest, PlaceholderFile) {\n  ASSERT_EQ(2, foo_file_->dependency_count());\n  EXPECT_EQ(bar_file_, foo_file_->dependency(0));\n  EXPECT_FALSE(bar_file_->is_placeholder());\n\n  const FileDescriptor* baz_file = foo_file_->dependency(1);\n  EXPECT_EQ(\"baz.proto\", baz_file->name());\n  EXPECT_EQ(0, baz_file->message_type_count());\n  EXPECT_TRUE(baz_file->is_placeholder());\n\n  // Placeholder files should not be findable.\n  EXPECT_EQ(bar_file_, pool_->FindFileByName(bar_file_->name()));\n  EXPECT_TRUE(pool_->FindFileByName(baz_file->name()) == NULL);\n\n  // Copy*To should not crash for placeholder files.\n  FileDescriptorProto baz_file_proto;\n  baz_file->CopyTo(&baz_file_proto);\n  baz_file->CopySourceCodeInfoTo(&baz_file_proto);\n  EXPECT_FALSE(baz_file_proto.has_source_code_info());\n}\n\nTEST_P(AllowUnknownDependenciesTest, PlaceholderTypes) {\n  ASSERT_EQ(FieldDescriptor::TYPE_MESSAGE, bar_field_->type());\n  EXPECT_EQ(bar_type_, bar_field_->message_type());\n  EXPECT_FALSE(bar_type_->is_placeholder());\n\n  ASSERT_EQ(FieldDescriptor::TYPE_MESSAGE, baz_field_->type());\n  const Descriptor* baz_type = baz_field_->message_type();\n  EXPECT_EQ(\"Baz\", baz_type->name());\n  EXPECT_EQ(\"Baz\", baz_type->full_name());\n  EXPECT_EQ(0, baz_type->extension_range_count());\n  EXPECT_TRUE(baz_type->is_placeholder());\n\n  ASSERT_EQ(FieldDescriptor::TYPE_ENUM, qux_field_->type());\n  const EnumDescriptor* qux_type = qux_field_->enum_type();\n  EXPECT_EQ(\"Qux\", qux_type->name());\n  EXPECT_EQ(\"corge.Qux\", qux_type->full_name());\n  EXPECT_TRUE(qux_type->is_placeholder());\n\n  // Placeholder types should not be findable.\n  EXPECT_EQ(bar_type_, pool_->FindMessageTypeByName(bar_type_->full_name()));\n  EXPECT_TRUE(pool_->FindMessageTypeByName(baz_type->full_name()) == NULL);\n  EXPECT_TRUE(pool_->FindEnumTypeByName(qux_type->full_name()) == NULL);\n}\n\nTEST_P(AllowUnknownDependenciesTest, CopyTo) {\n  // FieldDescriptor::CopyTo() should write non-fully-qualified type names\n  // for placeholder types which were not originally fully-qualified.\n  FieldDescriptorProto proto;\n\n  // Bar is not a placeholder, so it is fully-qualified.\n  bar_field_->CopyTo(&proto);\n  EXPECT_EQ(\".Bar\", proto.type_name());\n  EXPECT_EQ(FieldDescriptorProto::TYPE_MESSAGE, proto.type());\n\n  // Baz is an unqualified placeholder.\n  proto.Clear();\n  baz_field_->CopyTo(&proto);\n  EXPECT_EQ(\"Baz\", proto.type_name());\n  EXPECT_FALSE(proto.has_type());\n\n  // Qux is a fully-qualified placeholder.\n  proto.Clear();\n  qux_field_->CopyTo(&proto);\n  EXPECT_EQ(\".corge.Qux\", proto.type_name());\n  EXPECT_EQ(FieldDescriptorProto::TYPE_ENUM, proto.type());\n}\n\nTEST_P(AllowUnknownDependenciesTest, CustomOptions) {\n  // Qux should still have the uninterpreted option attached.\n  ASSERT_EQ(1, qux_field_->options().uninterpreted_option_size());\n  const UninterpretedOption& option =\n    qux_field_->options().uninterpreted_option(0);\n  ASSERT_EQ(1, option.name_size());\n  EXPECT_EQ(\"grault\", option.name(0).name_part());\n}\n\nTEST_P(AllowUnknownDependenciesTest, UnknownExtendee) {\n  // Test that we can extend an unknown type.  This is slightly tricky because\n  // it means that the placeholder type must have an extension range.\n\n  FileDescriptorProto extension_proto;\n\n  ASSERT_TRUE(TextFormat::ParseFromString(\n    \"name: 'extension.proto'\"\n    \"extension { extendee: 'UnknownType' name:'some_extension' number:123\"\n    \"            label:LABEL_OPTIONAL type:TYPE_INT32 }\",\n    &extension_proto));\n  const FileDescriptor* file = BuildFile(extension_proto);\n\n  ASSERT_TRUE(file != NULL);\n\n  ASSERT_EQ(1, file->extension_count());\n  const Descriptor* extendee = file->extension(0)->containing_type();\n  EXPECT_EQ(\"UnknownType\", extendee->name());\n  EXPECT_TRUE(extendee->is_placeholder());\n  ASSERT_EQ(1, extendee->extension_range_count());\n  EXPECT_EQ(1, extendee->extension_range(0)->start);\n  EXPECT_EQ(FieldDescriptor::kMaxNumber + 1, extendee->extension_range(0)->end);\n}\n\nTEST_P(AllowUnknownDependenciesTest, CustomOption) {\n  // Test that we can use a custom option without having parsed\n  // descriptor.proto.\n\n  FileDescriptorProto option_proto;\n\n  ASSERT_TRUE(TextFormat::ParseFromString(\n    \"name: \\\"unknown_custom_options.proto\\\" \"\n    \"dependency: \\\"google/protobuf/descriptor.proto\\\" \"\n    \"extension { \"\n    \"  extendee: \\\"google.protobuf.FileOptions\\\" \"\n    \"  name: \\\"some_option\\\" \"\n    \"  number: 123456 \"\n    \"  label: LABEL_OPTIONAL \"\n    \"  type: TYPE_INT32 \"\n    \"} \"\n    \"options { \"\n    \"  uninterpreted_option { \"\n    \"    name { \"\n    \"      name_part: \\\"some_option\\\" \"\n    \"      is_extension: true \"\n    \"    } \"\n    \"    positive_int_value: 1234 \"\n    \"  } \"\n    \"  uninterpreted_option { \"\n    \"    name { \"\n    \"      name_part: \\\"unknown_option\\\" \"\n    \"      is_extension: true \"\n    \"    } \"\n    \"    positive_int_value: 1234 \"\n    \"  } \"\n    \"  uninterpreted_option { \"\n    \"    name { \"\n    \"      name_part: \\\"optimize_for\\\" \"\n    \"      is_extension: false \"\n    \"    } \"\n    \"    identifier_value: \\\"SPEED\\\" \"\n    \"  } \"\n    \"}\",\n    &option_proto));\n\n  const FileDescriptor* file = BuildFile(option_proto);\n  ASSERT_TRUE(file != NULL);\n\n  // Verify that no extension options were set, but they were left as\n  // uninterpreted_options.\n  vector<const FieldDescriptor*> fields;\n  file->options().GetReflection()->ListFields(file->options(), &fields);\n  ASSERT_EQ(2, fields.size());\n  EXPECT_TRUE(file->options().has_optimize_for());\n  EXPECT_EQ(2, file->options().uninterpreted_option_size());\n}\n\nTEST_P(AllowUnknownDependenciesTest,\n       UndeclaredDependencyTriggersBuildOfDependency) {\n  // Crazy case: suppose foo.proto refers to a symbol without declaring the\n  // dependency that finds it. In the event that the pool is backed by a\n  // DescriptorDatabase, the pool will attempt to find the symbol in the\n  // database. If successful, it will build the undeclared dependency to verify\n  // that the file does indeed contain the symbol. If that file fails to build,\n  // then its descriptors must be rolled back. However, we still want foo.proto\n  // to build successfully, since we are allowing unknown dependencies.\n\n  FileDescriptorProto undeclared_dep_proto;\n  // We make this file fail to build by giving it two fields with tag 1.\n  ASSERT_TRUE(TextFormat::ParseFromString(\n    \"name: \\\"invalid_file_as_undeclared_dep.proto\\\" \"\n    \"package: \\\"undeclared\\\" \"\n    \"message_type: {  \"\n    \"  name: \\\"Quux\\\"  \"\n    \"  field { \"\n    \"    name:'qux' number:1 label:LABEL_OPTIONAL type: TYPE_INT32 \"\n    \"  }\"\n    \"  field { \"\n    \"    name:'quux' number:1 label:LABEL_OPTIONAL type: TYPE_INT64 \"\n    \"  }\"\n    \"}\",\n    &undeclared_dep_proto));\n  // We can't use the BuildFile() helper because we don't actually want to build\n  // it into the descriptor pool in the fallback database case: it just needs to\n  // be sitting in the database so that it gets built during the building of\n  // test.proto below.\n  switch (mode()) {\n    case NO_DATABASE: {\n      ASSERT_TRUE(pool_->BuildFile(undeclared_dep_proto) == NULL);\n      break;\n    }\n    case FALLBACK_DATABASE: {\n      ASSERT_TRUE(db_.Add(undeclared_dep_proto));\n    }\n  }\n\n  FileDescriptorProto test_proto;\n  ASSERT_TRUE(TextFormat::ParseFromString(\n    \"name: \\\"test.proto\\\" \"\n    \"message_type: { \"\n    \"  name: \\\"Corge\\\" \"\n    \"  field { \"\n    \"    name:'quux' number:1 label: LABEL_OPTIONAL \"\n    \"    type_name:'undeclared.Quux' type: TYPE_MESSAGE \"\n    \"  }\"\n    \"}\",\n    &test_proto));\n\n  const FileDescriptor* file = BuildFile(test_proto);\n  ASSERT_TRUE(file != NULL);\n  GOOGLE_LOG(INFO) << file->DebugString();\n\n  EXPECT_EQ(0, file->dependency_count());\n  ASSERT_EQ(1, file->message_type_count());\n  const Descriptor* corge_desc = file->message_type(0);\n  ASSERT_EQ(\"Corge\", corge_desc->name());\n  ASSERT_EQ(1, corge_desc->field_count());\n  EXPECT_FALSE(corge_desc->is_placeholder());\n\n  const FieldDescriptor* quux_field = corge_desc->field(0);\n  ASSERT_EQ(FieldDescriptor::TYPE_MESSAGE, quux_field->type());\n  ASSERT_EQ(\"Quux\", quux_field->message_type()->name());\n  ASSERT_EQ(\"undeclared.Quux\", quux_field->message_type()->full_name());\n  EXPECT_TRUE(quux_field->message_type()->is_placeholder());\n  // The place holder type should not be findable.\n  ASSERT_TRUE(pool_->FindMessageTypeByName(\"undeclared.Quux\") == NULL);\n}\n\nINSTANTIATE_TEST_CASE_P(DatabaseSource,\n                        AllowUnknownDependenciesTest,\n                        testing::Values(NO_DATABASE, FALLBACK_DATABASE));\n\n// ===================================================================\n\nTEST(CustomOptions, OptionLocations) {\n  const Descriptor* message =\n      protobuf_unittest::TestMessageWithCustomOptions::descriptor();\n  const FileDescriptor* file = message->file();\n  const FieldDescriptor* field = message->FindFieldByName(\"field1\");\n  const OneofDescriptor* oneof = message->FindOneofByName(\"AnOneof\");\n  const EnumDescriptor* enm = message->FindEnumTypeByName(\"AnEnum\");\n  // TODO(benjy): Support EnumValue options, once the compiler does.\n  const ServiceDescriptor* service =\n      file->FindServiceByName(\"TestServiceWithCustomOptions\");\n  const MethodDescriptor* method = service->FindMethodByName(\"Foo\");\n\n  EXPECT_EQ(GOOGLE_LONGLONG(9876543210),\n            file->options().GetExtension(protobuf_unittest::file_opt1));\n  EXPECT_EQ(-56,\n            message->options().GetExtension(protobuf_unittest::message_opt1));\n  EXPECT_EQ(GOOGLE_LONGLONG(8765432109),\n            field->options().GetExtension(protobuf_unittest::field_opt1));\n  EXPECT_EQ(42,  // Check that we get the default for an option we don't set.\n            field->options().GetExtension(protobuf_unittest::field_opt2));\n  EXPECT_EQ(-99,\n            oneof->options().GetExtension(protobuf_unittest::oneof_opt1));\n  EXPECT_EQ(-789,\n            enm->options().GetExtension(protobuf_unittest::enum_opt1));\n  EXPECT_EQ(123,\n            enm->value(1)->options().GetExtension(\n              protobuf_unittest::enum_value_opt1));\n  EXPECT_EQ(GOOGLE_LONGLONG(-9876543210),\n            service->options().GetExtension(protobuf_unittest::service_opt1));\n  EXPECT_EQ(protobuf_unittest::METHODOPT1_VAL2,\n            method->options().GetExtension(protobuf_unittest::method_opt1));\n\n  // See that the regular options went through unscathed.\n  EXPECT_TRUE(message->options().has_message_set_wire_format());\n  EXPECT_EQ(FieldOptions::CORD, field->options().ctype());\n}\n\nTEST(CustomOptions, OptionTypes) {\n  const MessageOptions* options = NULL;\n\n  options =\n      &protobuf_unittest::CustomOptionMinIntegerValues::descriptor()->options();\n  EXPECT_EQ(false    , options->GetExtension(protobuf_unittest::bool_opt));\n  EXPECT_EQ(kint32min, options->GetExtension(protobuf_unittest::int32_opt));\n  EXPECT_EQ(kint64min, options->GetExtension(protobuf_unittest::int64_opt));\n  EXPECT_EQ(0        , options->GetExtension(protobuf_unittest::uint32_opt));\n  EXPECT_EQ(0        , options->GetExtension(protobuf_unittest::uint64_opt));\n  EXPECT_EQ(kint32min, options->GetExtension(protobuf_unittest::sint32_opt));\n  EXPECT_EQ(kint64min, options->GetExtension(protobuf_unittest::sint64_opt));\n  EXPECT_EQ(0        , options->GetExtension(protobuf_unittest::fixed32_opt));\n  EXPECT_EQ(0        , options->GetExtension(protobuf_unittest::fixed64_opt));\n  EXPECT_EQ(kint32min, options->GetExtension(protobuf_unittest::sfixed32_opt));\n  EXPECT_EQ(kint64min, options->GetExtension(protobuf_unittest::sfixed64_opt));\n\n  options =\n      &protobuf_unittest::CustomOptionMaxIntegerValues::descriptor()->options();\n  EXPECT_EQ(true      , options->GetExtension(protobuf_unittest::bool_opt));\n  EXPECT_EQ(kint32max , options->GetExtension(protobuf_unittest::int32_opt));\n  EXPECT_EQ(kint64max , options->GetExtension(protobuf_unittest::int64_opt));\n  EXPECT_EQ(kuint32max, options->GetExtension(protobuf_unittest::uint32_opt));\n  EXPECT_EQ(kuint64max, options->GetExtension(protobuf_unittest::uint64_opt));\n  EXPECT_EQ(kint32max , options->GetExtension(protobuf_unittest::sint32_opt));\n  EXPECT_EQ(kint64max , options->GetExtension(protobuf_unittest::sint64_opt));\n  EXPECT_EQ(kuint32max, options->GetExtension(protobuf_unittest::fixed32_opt));\n  EXPECT_EQ(kuint64max, options->GetExtension(protobuf_unittest::fixed64_opt));\n  EXPECT_EQ(kint32max , options->GetExtension(protobuf_unittest::sfixed32_opt));\n  EXPECT_EQ(kint64max , options->GetExtension(protobuf_unittest::sfixed64_opt));\n\n  options =\n      &protobuf_unittest::CustomOptionOtherValues::descriptor()->options();\n  EXPECT_EQ(-100, options->GetExtension(protobuf_unittest::int32_opt));\n  EXPECT_FLOAT_EQ(12.3456789,\n                  options->GetExtension(protobuf_unittest::float_opt));\n  EXPECT_DOUBLE_EQ(1.234567890123456789,\n                   options->GetExtension(protobuf_unittest::double_opt));\n  EXPECT_EQ(\"Hello, \\\"World\\\"\",\n            options->GetExtension(protobuf_unittest::string_opt));\n\n  EXPECT_EQ(string(\"Hello\\0World\", 11),\n            options->GetExtension(protobuf_unittest::bytes_opt));\n\n  EXPECT_EQ(protobuf_unittest::DummyMessageContainingEnum::TEST_OPTION_ENUM_TYPE2,\n            options->GetExtension(protobuf_unittest::enum_opt));\n\n  options =\n      &protobuf_unittest::SettingRealsFromPositiveInts::descriptor()->options();\n  EXPECT_FLOAT_EQ(12, options->GetExtension(protobuf_unittest::float_opt));\n  EXPECT_DOUBLE_EQ(154, options->GetExtension(protobuf_unittest::double_opt));\n\n  options =\n      &protobuf_unittest::SettingRealsFromNegativeInts::descriptor()->options();\n  EXPECT_FLOAT_EQ(-12, options->GetExtension(protobuf_unittest::float_opt));\n  EXPECT_DOUBLE_EQ(-154, options->GetExtension(protobuf_unittest::double_opt));\n}\n\nTEST(CustomOptions, ComplexExtensionOptions) {\n  const MessageOptions* options =\n      &protobuf_unittest::VariousComplexOptions::descriptor()->options();\n  EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt1).foo(), 42);\n  EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt1).\n            GetExtension(protobuf_unittest::quux), 324);\n  EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt1).\n            GetExtension(protobuf_unittest::corge).qux(), 876);\n  EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2).baz(), 987);\n  EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2).\n            GetExtension(protobuf_unittest::grault), 654);\n  EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2).bar().foo(),\n            743);\n  EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2).bar().\n            GetExtension(protobuf_unittest::quux), 1999);\n  EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2).bar().\n            GetExtension(protobuf_unittest::corge).qux(), 2008);\n  EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2).\n            GetExtension(protobuf_unittest::garply).foo(), 741);\n  EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2).\n            GetExtension(protobuf_unittest::garply).\n            GetExtension(protobuf_unittest::quux), 1998);\n  EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2).\n            GetExtension(protobuf_unittest::garply).\n            GetExtension(protobuf_unittest::corge).qux(), 2121);\n  EXPECT_EQ(options->GetExtension(\n      protobuf_unittest::ComplexOptionType2::ComplexOptionType4::complex_opt4).\n            waldo(), 1971);\n  EXPECT_EQ(options->GetExtension(protobuf_unittest::complex_opt2).\n            fred().waldo(), 321);\n  EXPECT_EQ(9, options->GetExtension(protobuf_unittest::complex_opt3).qux());\n  EXPECT_EQ(22, options->GetExtension(protobuf_unittest::complex_opt3).\n                complexoptiontype5().plugh());\n  EXPECT_EQ(24, options->GetExtension(protobuf_unittest::complexopt6).xyzzy());\n}\n\nTEST(CustomOptions, OptionsFromOtherFile) {\n  // Test that to use a custom option, we only need to import the file\n  // defining the option; we do not also have to import descriptor.proto.\n  DescriptorPool pool;\n\n  FileDescriptorProto file_proto;\n  FileDescriptorProto::descriptor()->file()->CopyTo(&file_proto);\n  ASSERT_TRUE(pool.BuildFile(file_proto) != NULL);\n\n  protobuf_unittest::TestMessageWithCustomOptions::descriptor()\n    ->file()->CopyTo(&file_proto);\n  ASSERT_TRUE(pool.BuildFile(file_proto) != NULL);\n\n  ASSERT_TRUE(TextFormat::ParseFromString(\n    \"name: \\\"custom_options_import.proto\\\" \"\n    \"package: \\\"protobuf_unittest\\\" \"\n    \"dependency: \\\"google/protobuf/unittest_custom_options.proto\\\" \"\n    \"options { \"\n    \"  uninterpreted_option { \"\n    \"    name { \"\n    \"      name_part: \\\"file_opt1\\\" \"\n    \"      is_extension: true \"\n    \"    } \"\n    \"    positive_int_value: 1234 \"\n    \"  } \"\n    // Test a non-extension option too.  (At one point this failed due to a\n    // bug.)\n    \"  uninterpreted_option { \"\n    \"    name { \"\n    \"      name_part: \\\"java_package\\\" \"\n    \"      is_extension: false \"\n    \"    } \"\n    \"    string_value: \\\"foo\\\" \"\n    \"  } \"\n    // Test that enum-typed options still work too.  (At one point this also\n    // failed due to a bug.)\n    \"  uninterpreted_option { \"\n    \"    name { \"\n    \"      name_part: \\\"optimize_for\\\" \"\n    \"      is_extension: false \"\n    \"    } \"\n    \"    identifier_value: \\\"SPEED\\\" \"\n    \"  } \"\n    \"}\"\n    ,\n    &file_proto));\n\n  const FileDescriptor* file = pool.BuildFile(file_proto);\n  ASSERT_TRUE(file != NULL);\n  EXPECT_EQ(1234, file->options().GetExtension(protobuf_unittest::file_opt1));\n  EXPECT_TRUE(file->options().has_java_package());\n  EXPECT_EQ(\"foo\", file->options().java_package());\n  EXPECT_TRUE(file->options().has_optimize_for());\n  EXPECT_EQ(FileOptions::SPEED, file->options().optimize_for());\n}\n\nTEST(CustomOptions, MessageOptionThreeFieldsSet) {\n  // This tests a bug which previously existed in custom options parsing.  The\n  // bug occurred when you defined a custom option with message type and then\n  // set three fields of that option on a single definition (see the example\n  // below).  The bug is a bit hard to explain, so check the change history if\n  // you want to know more.\n  DescriptorPool pool;\n\n  FileDescriptorProto file_proto;\n  FileDescriptorProto::descriptor()->file()->CopyTo(&file_proto);\n  ASSERT_TRUE(pool.BuildFile(file_proto) != NULL);\n\n  protobuf_unittest::TestMessageWithCustomOptions::descriptor()\n    ->file()->CopyTo(&file_proto);\n  ASSERT_TRUE(pool.BuildFile(file_proto) != NULL);\n\n  // The following represents the definition:\n  //\n  //   import \"google/protobuf/unittest_custom_options.proto\"\n  //   package protobuf_unittest;\n  //   message Foo {\n  //     option (complex_opt1).foo  = 1234;\n  //     option (complex_opt1).foo2 = 1234;\n  //     option (complex_opt1).foo3 = 1234;\n  //   }\n  ASSERT_TRUE(TextFormat::ParseFromString(\n    \"name: \\\"custom_options_import.proto\\\" \"\n    \"package: \\\"protobuf_unittest\\\" \"\n    \"dependency: \\\"google/protobuf/unittest_custom_options.proto\\\" \"\n    \"message_type { \"\n    \"  name: \\\"Foo\\\" \"\n    \"  options { \"\n    \"    uninterpreted_option { \"\n    \"      name { \"\n    \"        name_part: \\\"complex_opt1\\\" \"\n    \"        is_extension: true \"\n    \"      } \"\n    \"      name { \"\n    \"        name_part: \\\"foo\\\" \"\n    \"        is_extension: false \"\n    \"      } \"\n    \"      positive_int_value: 1234 \"\n    \"    } \"\n    \"    uninterpreted_option { \"\n    \"      name { \"\n    \"        name_part: \\\"complex_opt1\\\" \"\n    \"        is_extension: true \"\n    \"      } \"\n    \"      name { \"\n    \"        name_part: \\\"foo2\\\" \"\n    \"        is_extension: false \"\n    \"      } \"\n    \"      positive_int_value: 1234 \"\n    \"    } \"\n    \"    uninterpreted_option { \"\n    \"      name { \"\n    \"        name_part: \\\"complex_opt1\\\" \"\n    \"        is_extension: true \"\n    \"      } \"\n    \"      name { \"\n    \"        name_part: \\\"foo3\\\" \"\n    \"        is_extension: false \"\n    \"      } \"\n    \"      positive_int_value: 1234 \"\n    \"    } \"\n    \"  } \"\n    \"}\",\n    &file_proto));\n\n  const FileDescriptor* file = pool.BuildFile(file_proto);\n  ASSERT_TRUE(file != NULL);\n  ASSERT_EQ(1, file->message_type_count());\n\n  const MessageOptions& options = file->message_type(0)->options();\n  EXPECT_EQ(1234, options.GetExtension(protobuf_unittest::complex_opt1).foo());\n}\n\nTEST(CustomOptions, MessageOptionRepeatedLeafFieldSet) {\n  // This test verifies that repeated fields in custom options can be\n  // given multiple values by repeating the option with a different value.\n  // This test checks repeated leaf values. Each repeated custom value\n  // appears in a different uninterpreted_option, which will be concatenated\n  // when they are merged into the final option value.\n  DescriptorPool pool;\n\n  FileDescriptorProto file_proto;\n  FileDescriptorProto::descriptor()->file()->CopyTo(&file_proto);\n  ASSERT_TRUE(pool.BuildFile(file_proto) != NULL);\n\n  protobuf_unittest::TestMessageWithCustomOptions::descriptor()\n    ->file()->CopyTo(&file_proto);\n  ASSERT_TRUE(pool.BuildFile(file_proto) != NULL);\n\n  // The following represents the definition:\n  //\n  //   import \"google/protobuf/unittest_custom_options.proto\"\n  //   package protobuf_unittest;\n  //   message Foo {\n  //     option (complex_opt1).foo4 = 12;\n  //     option (complex_opt1).foo4 = 34;\n  //     option (complex_opt1).foo4 = 56;\n  //   }\n  ASSERT_TRUE(TextFormat::ParseFromString(\n    \"name: \\\"custom_options_import.proto\\\" \"\n    \"package: \\\"protobuf_unittest\\\" \"\n    \"dependency: \\\"google/protobuf/unittest_custom_options.proto\\\" \"\n    \"message_type { \"\n    \"  name: \\\"Foo\\\" \"\n    \"  options { \"\n    \"    uninterpreted_option { \"\n    \"      name { \"\n    \"        name_part: \\\"complex_opt1\\\" \"\n    \"        is_extension: true \"\n    \"      } \"\n    \"      name { \"\n    \"        name_part: \\\"foo4\\\" \"\n    \"        is_extension: false \"\n    \"      } \"\n    \"      positive_int_value: 12 \"\n    \"    } \"\n    \"    uninterpreted_option { \"\n    \"      name { \"\n    \"        name_part: \\\"complex_opt1\\\" \"\n    \"        is_extension: true \"\n    \"      } \"\n    \"      name { \"\n    \"        name_part: \\\"foo4\\\" \"\n    \"        is_extension: false \"\n    \"      } \"\n    \"      positive_int_value: 34 \"\n    \"    } \"\n    \"    uninterpreted_option { \"\n    \"      name { \"\n    \"        name_part: \\\"complex_opt1\\\" \"\n    \"        is_extension: true \"\n    \"      } \"\n    \"      name { \"\n    \"        name_part: \\\"foo4\\\" \"\n    \"        is_extension: false \"\n    \"      } \"\n    \"      positive_int_value: 56 \"\n    \"    } \"\n    \"  } \"\n    \"}\",\n    &file_proto));\n\n  const FileDescriptor* file = pool.BuildFile(file_proto);\n  ASSERT_TRUE(file != NULL);\n  ASSERT_EQ(1, file->message_type_count());\n\n  const MessageOptions& options = file->message_type(0)->options();\n  EXPECT_EQ(3, options.GetExtension(protobuf_unittest::complex_opt1).foo4_size());\n  EXPECT_EQ(12, options.GetExtension(protobuf_unittest::complex_opt1).foo4(0));\n  EXPECT_EQ(34, options.GetExtension(protobuf_unittest::complex_opt1).foo4(1));\n  EXPECT_EQ(56, options.GetExtension(protobuf_unittest::complex_opt1).foo4(2));\n}\n\nTEST(CustomOptions, MessageOptionRepeatedMsgFieldSet) {\n  // This test verifies that repeated fields in custom options can be\n  // given multiple values by repeating the option with a different value.\n  // This test checks repeated message values. Each repeated custom value\n  // appears in a different uninterpreted_option, which will be concatenated\n  // when they are merged into the final option value.\n  DescriptorPool pool;\n\n  FileDescriptorProto file_proto;\n  FileDescriptorProto::descriptor()->file()->CopyTo(&file_proto);\n  ASSERT_TRUE(pool.BuildFile(file_proto) != NULL);\n\n  protobuf_unittest::TestMessageWithCustomOptions::descriptor()\n    ->file()->CopyTo(&file_proto);\n  ASSERT_TRUE(pool.BuildFile(file_proto) != NULL);\n\n  // The following represents the definition:\n  //\n  //   import \"google/protobuf/unittest_custom_options.proto\"\n  //   package protobuf_unittest;\n  //   message Foo {\n  //     option (complex_opt2).barney = {waldo: 1};\n  //     option (complex_opt2).barney = {waldo: 10};\n  //     option (complex_opt2).barney = {waldo: 100};\n  //   }\n  ASSERT_TRUE(TextFormat::ParseFromString(\n    \"name: \\\"custom_options_import.proto\\\" \"\n    \"package: \\\"protobuf_unittest\\\" \"\n    \"dependency: \\\"google/protobuf/unittest_custom_options.proto\\\" \"\n    \"message_type { \"\n    \"  name: \\\"Foo\\\" \"\n    \"  options { \"\n    \"    uninterpreted_option { \"\n    \"      name { \"\n    \"        name_part: \\\"complex_opt2\\\" \"\n    \"        is_extension: true \"\n    \"      } \"\n    \"      name { \"\n    \"        name_part: \\\"barney\\\" \"\n    \"        is_extension: false \"\n    \"      } \"\n    \"      aggregate_value: \\\"waldo: 1\\\" \"\n    \"    } \"\n    \"    uninterpreted_option { \"\n    \"      name { \"\n    \"        name_part: \\\"complex_opt2\\\" \"\n    \"        is_extension: true \"\n    \"      } \"\n    \"      name { \"\n    \"        name_part: \\\"barney\\\" \"\n    \"        is_extension: false \"\n    \"      } \"\n    \"      aggregate_value: \\\"waldo: 10\\\" \"\n    \"    } \"\n    \"    uninterpreted_option { \"\n    \"      name { \"\n    \"        name_part: \\\"complex_opt2\\\" \"\n    \"        is_extension: true \"\n    \"      } \"\n    \"      name { \"\n    \"        name_part: \\\"barney\\\" \"\n    \"        is_extension: false \"\n    \"      } \"\n    \"      aggregate_value: \\\"waldo: 100\\\" \"\n    \"    } \"\n    \"  } \"\n    \"}\",\n    &file_proto));\n\n  const FileDescriptor* file = pool.BuildFile(file_proto);\n  ASSERT_TRUE(file != NULL);\n  ASSERT_EQ(1, file->message_type_count());\n\n  const MessageOptions& options = file->message_type(0)->options();\n  EXPECT_EQ(3, options.GetExtension(\n      protobuf_unittest::complex_opt2).barney_size());\n  EXPECT_EQ(1,options.GetExtension(\n      protobuf_unittest::complex_opt2).barney(0).waldo());\n  EXPECT_EQ(10, options.GetExtension(\n      protobuf_unittest::complex_opt2).barney(1).waldo());\n  EXPECT_EQ(100, options.GetExtension(\n      protobuf_unittest::complex_opt2).barney(2).waldo());\n}\n\n// Check that aggregate options were parsed and saved correctly in\n// the appropriate descriptors.\nTEST(CustomOptions, AggregateOptions) {\n  const Descriptor* msg = protobuf_unittest::AggregateMessage::descriptor();\n  const FileDescriptor* file = msg->file();\n  const FieldDescriptor* field = msg->FindFieldByName(\"fieldname\");\n  const EnumDescriptor* enumd = file->FindEnumTypeByName(\"AggregateEnum\");\n  const EnumValueDescriptor* enumv = enumd->FindValueByName(\"VALUE\");\n  const ServiceDescriptor* service = file->FindServiceByName(\n      \"AggregateService\");\n  const MethodDescriptor* method = service->FindMethodByName(\"Method\");\n\n  // Tests for the different types of data embedded in fileopt\n  const protobuf_unittest::Aggregate& file_options =\n      file->options().GetExtension(protobuf_unittest::fileopt);\n  EXPECT_EQ(100, file_options.i());\n  EXPECT_EQ(\"FileAnnotation\", file_options.s());\n  EXPECT_EQ(\"NestedFileAnnotation\", file_options.sub().s());\n  EXPECT_EQ(\"FileExtensionAnnotation\",\n            file_options.file().GetExtension(protobuf_unittest::fileopt).s());\n  EXPECT_EQ(\"EmbeddedMessageSetElement\",\n            file_options.mset().GetExtension(\n                protobuf_unittest::AggregateMessageSetElement\n                ::message_set_extension).s());\n\n  // Simple tests for all the other types of annotations\n  EXPECT_EQ(\"MessageAnnotation\",\n            msg->options().GetExtension(protobuf_unittest::msgopt).s());\n  EXPECT_EQ(\"FieldAnnotation\",\n            field->options().GetExtension(protobuf_unittest::fieldopt).s());\n  EXPECT_EQ(\"EnumAnnotation\",\n            enumd->options().GetExtension(protobuf_unittest::enumopt).s());\n  EXPECT_EQ(\"EnumValueAnnotation\",\n            enumv->options().GetExtension(protobuf_unittest::enumvalopt).s());\n  EXPECT_EQ(\"ServiceAnnotation\",\n            service->options().GetExtension(protobuf_unittest::serviceopt).s());\n  EXPECT_EQ(\"MethodAnnotation\",\n            method->options().GetExtension(protobuf_unittest::methodopt).s());\n}\n\nTEST(CustomOptions, UnusedImportWarning) {\n  DescriptorPool pool;\n\n  FileDescriptorProto file_proto;\n  FileDescriptorProto::descriptor()->file()->CopyTo(&file_proto);\n  ASSERT_TRUE(pool.BuildFile(file_proto) != NULL);\n\n  protobuf_unittest::TestMessageWithCustomOptions::descriptor()\n      ->file()->CopyTo(&file_proto);\n  ASSERT_TRUE(pool.BuildFile(file_proto) != NULL);\n\n  pool.AddUnusedImportTrackFile(\"custom_options_import.proto\");\n  ASSERT_TRUE(TextFormat::ParseFromString(\n    \"name: \\\"custom_options_import.proto\\\" \"\n    \"package: \\\"protobuf_unittest\\\" \"\n    \"dependency: \\\"google/protobuf/unittest_custom_options.proto\\\" \",\n    &file_proto));\n\n  MockErrorCollector error_collector;\n  EXPECT_TRUE(pool.BuildFileCollectingErrors(file_proto, &error_collector));\n  EXPECT_EQ(\"\", error_collector.warning_text_);\n}\n\n// Verifies that proto files can correctly be parsed, even if the\n// custom options defined in the file are incompatible with those\n// compiled in the binary. See http://b/19276250.\nTEST(CustomOptions, OptionsWithRequiredEnums) {\n  DescriptorPool pool;\n\n  FileDescriptorProto file_proto;\n  MessageOptions::descriptor()->file()->CopyTo(&file_proto);\n  ASSERT_TRUE(pool.BuildFile(file_proto) != NULL);\n\n  // Create a new file descriptor proto containing a subset of the\n  // messages defined in google/protobuf/unittest_custom_options.proto.\n  file_proto.Clear();\n  file_proto.set_name(\"unittest_custom_options.proto\");\n  file_proto.set_package(\"protobuf_unittest\");\n  file_proto.add_dependency(\"google/protobuf/descriptor.proto\");\n\n  // Add the \"required_enum_opt\" extension.\n  FieldDescriptorProto* extension = file_proto.add_extension();\n  protobuf_unittest::OldOptionType::descriptor()->file()\n      ->FindExtensionByName(\"required_enum_opt\")->CopyTo(extension);\n\n  // Add a test message that uses the \"required_enum_opt\" option.\n  DescriptorProto* test_message_type = file_proto.add_message_type();\n  protobuf_unittest::TestMessageWithRequiredEnumOption::descriptor()\n      ->CopyTo(test_message_type);\n\n  // Instruct the extension to use NewOptionType instead of\n  // OldOptionType, and add the descriptor of NewOptionType.\n  extension->set_type_name(\".protobuf_unittest.NewOptionType\");\n  DescriptorProto* new_option_type = file_proto.add_message_type();\n  protobuf_unittest::NewOptionType::descriptor()\n      ->CopyTo(new_option_type);\n\n  // Replace the value of the \"required_enum_opt\" option used in the\n  // test message with an enum value that only exists in NewOptionType.\n  ASSERT_TRUE(TextFormat::ParseFromString(\n      \"uninterpreted_option { \"\n      \"  name { \"\n      \"    name_part: 'required_enum_opt' \"\n      \"    is_extension: true \"\n      \"  } \"\n      \"  aggregate_value: 'value: NEW_VALUE' \"\n      \"}\",\n      test_message_type->mutable_options()));\n\n  // Add the file descriptor to the pool.\n  ASSERT_TRUE(pool.BuildFile(file_proto) != NULL);\n\n  // Find the test message.\n  const Descriptor* test_message = pool.FindMessageTypeByName(\n      \"protobuf_unittest.TestMessageWithRequiredEnumOption\");\n  ASSERT_TRUE(test_message != NULL);\n\n  const MessageOptions& options = test_message->options();\n  // Extract the \"required_enum_opt\" option. Since the binary does not\n  // know that the extension was updated, this will still return an\n  // OldOptionType message.\n  ASSERT_TRUE(\n      options.HasExtension(protobuf_unittest::required_enum_opt));\n  const protobuf_unittest::OldOptionType& old_enum_opt =\n      options.GetExtension(protobuf_unittest::required_enum_opt);\n\n  // Confirm that the required enum field is missing.\n  EXPECT_FALSE(old_enum_opt.IsInitialized());\n  EXPECT_FALSE(old_enum_opt.has_value());\n\n  string buf;\n  // Verify that the required enum field does show up when the option\n  // is re-parsed as a NewOptionType message;\n  protobuf_unittest::NewOptionType new_enum_opt;\n  EXPECT_TRUE(old_enum_opt.AppendPartialToString(&buf));\n  EXPECT_TRUE(new_enum_opt.ParseFromString(buf));\n  EXPECT_EQ(protobuf_unittest::NewOptionType::NEW_VALUE, new_enum_opt.value());\n}\n\n// ===================================================================\n\nclass ValidationErrorTest : public testing::Test {\n protected:\n  // Parse file_text as a FileDescriptorProto in text format and add it\n  // to the DescriptorPool.  Expect no errors.\n  const FileDescriptor* BuildFile(const string& file_text) {\n    FileDescriptorProto file_proto;\n    EXPECT_TRUE(TextFormat::ParseFromString(file_text, &file_proto));\n    return GOOGLE_CHECK_NOTNULL(pool_.BuildFile(file_proto));\n  }\n\n  // Parse file_text as a FileDescriptorProto in text format and add it\n  // to the DescriptorPool.  Expect errors to be produced which match the\n  // given error text.\n  void BuildFileWithErrors(const string& file_text,\n                           const string& expected_errors) {\n    FileDescriptorProto file_proto;\n    ASSERT_TRUE(TextFormat::ParseFromString(file_text, &file_proto));\n\n    MockErrorCollector error_collector;\n    EXPECT_TRUE(\n      pool_.BuildFileCollectingErrors(file_proto, &error_collector) == NULL);\n    EXPECT_EQ(expected_errors, error_collector.text_);\n  }\n\n  // Parse file_text as a FileDescriptorProto in text format and add it\n  // to the DescriptorPool.  Expect errors to be produced which match the\n  // given warning text.\n  void BuildFileWithWarnings(const string& file_text,\n                             const string& expected_warnings) {\n    FileDescriptorProto file_proto;\n    ASSERT_TRUE(TextFormat::ParseFromString(file_text, &file_proto));\n\n    MockErrorCollector error_collector;\n    EXPECT_TRUE(pool_.BuildFileCollectingErrors(file_proto, &error_collector));\n    EXPECT_EQ(expected_warnings, error_collector.warning_text_);\n  }\n\n  // Builds some already-parsed file in our test pool.\n  void BuildFileInTestPool(const FileDescriptor* file) {\n    FileDescriptorProto file_proto;\n    file->CopyTo(&file_proto);\n    ASSERT_TRUE(pool_.BuildFile(file_proto) != NULL);\n  }\n\n  // Build descriptor.proto in our test pool. This allows us to extend it in\n  // the test pool, so we can test custom options.\n  void BuildDescriptorMessagesInTestPool() {\n    BuildFileInTestPool(DescriptorProto::descriptor()->file());\n  }\n\n  DescriptorPool pool_;\n};\n\nTEST_F(ValidationErrorTest, AlreadyDefined) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { name: \\\"Foo\\\" }\"\n    \"message_type { name: \\\"Foo\\\" }\",\n\n    \"foo.proto: Foo: NAME: \\\"Foo\\\" is already defined.\\n\");\n}\n\nTEST_F(ValidationErrorTest, AlreadyDefinedInPackage) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"package: \\\"foo.bar\\\" \"\n    \"message_type { name: \\\"Foo\\\" }\"\n    \"message_type { name: \\\"Foo\\\" }\",\n\n    \"foo.proto: foo.bar.Foo: NAME: \\\"Foo\\\" is already defined in \"\n      \"\\\"foo.bar\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, AlreadyDefinedInOtherFile) {\n  BuildFile(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { name: \\\"Foo\\\" }\");\n\n  BuildFileWithErrors(\n    \"name: \\\"bar.proto\\\" \"\n    \"message_type { name: \\\"Foo\\\" }\",\n\n    \"bar.proto: Foo: NAME: \\\"Foo\\\" is already defined in file \"\n      \"\\\"foo.proto\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, PackageAlreadyDefined) {\n  BuildFile(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { name: \\\"foo\\\" }\");\n  BuildFileWithErrors(\n    \"name: \\\"bar.proto\\\" \"\n    \"package: \\\"foo.bar\\\"\",\n\n    \"bar.proto: foo: NAME: \\\"foo\\\" is already defined (as something other \"\n      \"than a package) in file \\\"foo.proto\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, EnumValueAlreadyDefinedInParent) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"enum_type { name: \\\"Foo\\\" value { name: \\\"FOO\\\" number: 1 } } \"\n    \"enum_type { name: \\\"Bar\\\" value { name: \\\"FOO\\\" number: 1 } } \",\n\n    \"foo.proto: FOO: NAME: \\\"FOO\\\" is already defined.\\n\"\n    \"foo.proto: FOO: NAME: Note that enum values use C++ scoping rules, \"\n      \"meaning that enum values are siblings of their type, not children of \"\n      \"it.  Therefore, \\\"FOO\\\" must be unique within the global scope, not \"\n      \"just within \\\"Bar\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, EnumValueAlreadyDefinedInParentNonGlobal) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"package: \\\"pkg\\\" \"\n    \"enum_type { name: \\\"Foo\\\" value { name: \\\"FOO\\\" number: 1 } } \"\n    \"enum_type { name: \\\"Bar\\\" value { name: \\\"FOO\\\" number: 1 } } \",\n\n    \"foo.proto: pkg.FOO: NAME: \\\"FOO\\\" is already defined in \\\"pkg\\\".\\n\"\n    \"foo.proto: pkg.FOO: NAME: Note that enum values use C++ scoping rules, \"\n      \"meaning that enum values are siblings of their type, not children of \"\n      \"it.  Therefore, \\\"FOO\\\" must be unique within \\\"pkg\\\", not just within \"\n      \"\\\"Bar\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, MissingName) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { }\",\n\n    \"foo.proto: : NAME: Missing name.\\n\");\n}\n\nTEST_F(ValidationErrorTest, InvalidName) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { name: \\\"$\\\" }\",\n\n    \"foo.proto: $: NAME: \\\"$\\\" is not a valid identifier.\\n\");\n}\n\nTEST_F(ValidationErrorTest, InvalidPackageName) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"package: \\\"foo.$\\\"\",\n\n    \"foo.proto: foo.$: NAME: \\\"$\\\" is not a valid identifier.\\n\");\n}\n\nTEST_F(ValidationErrorTest, MissingFileName) {\n  BuildFileWithErrors(\n    \"\",\n\n    \": : OTHER: Missing field: FileDescriptorProto.name.\\n\");\n}\n\nTEST_F(ValidationErrorTest, DupeDependency) {\n  BuildFile(\"name: \\\"foo.proto\\\"\");\n  BuildFileWithErrors(\n    \"name: \\\"bar.proto\\\" \"\n    \"dependency: \\\"foo.proto\\\" \"\n    \"dependency: \\\"foo.proto\\\" \",\n\n    \"bar.proto: bar.proto: OTHER: Import \\\"foo.proto\\\" was listed twice.\\n\");\n}\n\nTEST_F(ValidationErrorTest, UnknownDependency) {\n  BuildFileWithErrors(\n    \"name: \\\"bar.proto\\\" \"\n    \"dependency: \\\"foo.proto\\\" \",\n\n    \"bar.proto: bar.proto: OTHER: Import \\\"foo.proto\\\" has not been loaded.\\n\");\n}\n\nTEST_F(ValidationErrorTest, InvalidPublicDependencyIndex) {\n  BuildFile(\"name: \\\"foo.proto\\\"\");\n  BuildFileWithErrors(\n    \"name: \\\"bar.proto\\\" \"\n    \"dependency: \\\"foo.proto\\\" \"\n    \"public_dependency: 1\",\n    \"bar.proto: bar.proto: OTHER: Invalid public dependency index.\\n\");\n}\n\nTEST_F(ValidationErrorTest, ForeignUnimportedPackageNoCrash) {\n  // Used to crash:  If we depend on a non-existent file and then refer to a\n  // package defined in a file that we didn't import, and that package is\n  // nested within a parent package which this file is also in, and we don't\n  // include that parent package in the name (i.e. we do a relative lookup)...\n  // Yes, really.\n  BuildFile(\n    \"name: 'foo.proto' \"\n    \"package: 'outer.foo' \");\n  BuildFileWithErrors(\n    \"name: 'bar.proto' \"\n    \"dependency: 'baz.proto' \"\n    \"package: 'outer.bar' \"\n    \"message_type { \"\n    \"  name: 'Bar' \"\n    \"  field { name:'bar' number:1 label:LABEL_OPTIONAL type_name:'foo.Foo' }\"\n    \"}\",\n\n    \"bar.proto: bar.proto: OTHER: Import \\\"baz.proto\\\" has not been loaded.\\n\"\n    \"bar.proto: outer.bar.Bar.bar: TYPE: \\\"outer.foo\\\" seems to be defined in \"\n      \"\\\"foo.proto\\\", which is not imported by \\\"bar.proto\\\".  To use it here, \"\n      \"please add the necessary import.\\n\");\n}\n\nTEST_F(ValidationErrorTest, DupeFile) {\n  BuildFile(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { name: \\\"Foo\\\" }\");\n  // Note:  We should *not* get redundant errors about \"Foo\" already being\n  //   defined.\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { name: \\\"Foo\\\" } \"\n    // Add another type so that the files aren't identical (in which case there\n    // would be no error).\n    \"enum_type { name: \\\"Bar\\\" }\",\n\n    \"foo.proto: foo.proto: OTHER: A file with this name is already in the \"\n      \"pool.\\n\");\n}\n\nTEST_F(ValidationErrorTest, FieldInExtensionRange) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name: \\\"foo\\\" number:  9 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n    \"  field { name: \\\"bar\\\" number: 10 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n    \"  field { name: \\\"baz\\\" number: 19 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n    \"  field { name: \\\"qux\\\" number: 20 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n    \"  extension_range { start: 10 end: 20 }\"\n    \"}\",\n\n    \"foo.proto: Foo.bar: NUMBER: Extension range 10 to 19 includes field \"\n      \"\\\"bar\\\" (10).\\n\"\n    \"foo.proto: Foo.baz: NUMBER: Extension range 10 to 19 includes field \"\n      \"\\\"baz\\\" (19).\\n\");\n}\n\nTEST_F(ValidationErrorTest, OverlappingExtensionRanges) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  extension_range { start: 10 end: 20 }\"\n    \"  extension_range { start: 20 end: 30 }\"\n    \"  extension_range { start: 19 end: 21 }\"\n    \"}\",\n\n    \"foo.proto: Foo: NUMBER: Extension range 19 to 20 overlaps with \"\n      \"already-defined range 10 to 19.\\n\"\n    \"foo.proto: Foo: NUMBER: Extension range 19 to 20 overlaps with \"\n      \"already-defined range 20 to 29.\\n\");\n}\n\nTEST_F(ValidationErrorTest, ReservedFieldError) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name: \\\"foo\\\" number: 15 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n    \"  reserved_range { start: 10 end: 20 }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: NUMBER: Field \\\"foo\\\" uses reserved number 15.\\n\");\n}\n\nTEST_F(ValidationErrorTest, ReservedExtensionRangeError) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  extension_range { start: 10 end: 20 }\"\n    \"  reserved_range { start: 5 end: 15 }\"\n    \"}\",\n\n    \"foo.proto: Foo: NUMBER: Extension range 10 to 19\"\n    \" overlaps with reserved range 5 to 14.\\n\");\n}\n\nTEST_F(ValidationErrorTest, ReservedExtensionRangeAdjacent) {\n  BuildFile(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  extension_range { start: 10 end: 20 }\"\n    \"  reserved_range { start: 5 end: 10 }\"\n    \"}\");\n}\n\nTEST_F(ValidationErrorTest, ReservedRangeOverlap) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  reserved_range { start: 10 end: 20 }\"\n    \"  reserved_range { start: 5 end: 15 }\"\n    \"}\",\n\n    \"foo.proto: Foo: NUMBER: Reserved range 5 to 14\"\n    \" overlaps with already-defined range 10 to 19.\\n\");\n}\n\nTEST_F(ValidationErrorTest, ReservedNameError) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name: \\\"foo\\\" number: 15 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n    \"  field { name: \\\"bar\\\" number: 16 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n    \"  field { name: \\\"baz\\\" number: 17 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n    \"  reserved_name: \\\"foo\\\"\"\n    \"  reserved_name: \\\"bar\\\"\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: NAME: Field name \\\"foo\\\" is reserved.\\n\"\n    \"foo.proto: Foo.bar: NAME: Field name \\\"bar\\\" is reserved.\\n\");\n}\n\nTEST_F(ValidationErrorTest, ReservedNameRedundant) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  reserved_name: \\\"foo\\\"\"\n    \"  reserved_name: \\\"foo\\\"\"\n    \"}\",\n\n    \"foo.proto: foo: NAME: Field name \\\"foo\\\" is reserved multiple times.\\n\");\n}\n\nTEST_F(ValidationErrorTest, ReservedFieldsDebugString) {\n  const FileDescriptor* file = BuildFile(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  reserved_name: \\\"foo\\\"\"\n    \"  reserved_name: \\\"bar\\\"\"\n    \"  reserved_range { start: 5 end: 6 }\"\n    \"  reserved_range { start: 10 end: 20 }\"\n    \"}\");\n\n  ASSERT_EQ(\n    \"syntax = \\\"proto2\\\";\\n\\n\"\n    \"message Foo {\\n\"\n    \"  reserved 5, 10 to 19;\\n\"\n    \"  reserved \\\"foo\\\", \\\"bar\\\";\\n\"\n    \"}\\n\\n\",\n    file->DebugString());\n}\n\nTEST_F(ValidationErrorTest, InvalidDefaults) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n\n    // Invalid number.\n    \"  field { name: \\\"foo\\\" number: 1 label: LABEL_OPTIONAL type: TYPE_INT32\"\n    \"          default_value: \\\"abc\\\" }\"\n\n    // Empty default value.\n    \"  field { name: \\\"bar\\\" number: 2 label: LABEL_OPTIONAL type: TYPE_INT32\"\n    \"          default_value: \\\"\\\" }\"\n\n    // Invalid boolean.\n    \"  field { name: \\\"baz\\\" number: 3 label: LABEL_OPTIONAL type: TYPE_BOOL\"\n    \"          default_value: \\\"abc\\\" }\"\n\n    // Messages can't have defaults.\n    \"  field { name: \\\"qux\\\" number: 4 label: LABEL_OPTIONAL type: TYPE_MESSAGE\"\n    \"          default_value: \\\"abc\\\" type_name: \\\"Foo\\\" }\"\n\n    // Same thing, but we don't know that this field has message type until\n    // we look up the type name.\n    \"  field { name: \\\"quux\\\" number: 5 label: LABEL_OPTIONAL\"\n    \"          default_value: \\\"abc\\\" type_name: \\\"Foo\\\" }\"\n\n    // Repeateds can't have defaults.\n    \"  field { name: \\\"corge\\\" number: 6 label: LABEL_REPEATED type: TYPE_INT32\"\n    \"          default_value: \\\"1\\\" }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: DEFAULT_VALUE: Couldn't parse default value \\\"abc\\\".\\n\"\n    \"foo.proto: Foo.bar: DEFAULT_VALUE: Couldn't parse default value \\\"\\\".\\n\"\n    \"foo.proto: Foo.baz: DEFAULT_VALUE: Boolean default must be true or \"\n      \"false.\\n\"\n    \"foo.proto: Foo.qux: DEFAULT_VALUE: Messages can't have default values.\\n\"\n    \"foo.proto: Foo.corge: DEFAULT_VALUE: Repeated fields can't have default \"\n      \"values.\\n\"\n    // This ends up being reported later because the error is detected at\n    // cross-linking time.\n    \"foo.proto: Foo.quux: DEFAULT_VALUE: Messages can't have default \"\n      \"values.\\n\");\n}\n\nTEST_F(ValidationErrorTest, NegativeFieldNumber) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name: \\\"foo\\\" number: -1 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: NUMBER: Field numbers must be positive integers.\\n\");\n}\n\nTEST_F(ValidationErrorTest, HugeFieldNumber) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name: \\\"foo\\\" number: 0x70000000 \"\n    \"          label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: NUMBER: Field numbers cannot be greater than \"\n      \"536870911.\\n\");\n}\n\nTEST_F(ValidationErrorTest, ReservedFieldNumber) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field {name:\\\"foo\\\" number: 18999 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n    \"  field {name:\\\"bar\\\" number: 19000 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n    \"  field {name:\\\"baz\\\" number: 19999 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n    \"  field {name:\\\"qux\\\" number: 20000 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n    \"}\",\n\n    \"foo.proto: Foo.bar: NUMBER: Field numbers 19000 through 19999 are \"\n      \"reserved for the protocol buffer library implementation.\\n\"\n    \"foo.proto: Foo.baz: NUMBER: Field numbers 19000 through 19999 are \"\n      \"reserved for the protocol buffer library implementation.\\n\");\n}\n\nTEST_F(ValidationErrorTest, ExtensionMissingExtendee) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  extension { name: \\\"foo\\\" number: 1 label: LABEL_OPTIONAL\"\n    \"              type_name: \\\"Foo\\\" }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: EXTENDEE: FieldDescriptorProto.extendee not set for \"\n      \"extension field.\\n\");\n}\n\nTEST_F(ValidationErrorTest, NonExtensionWithExtendee) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Bar\\\"\"\n    \"  extension_range { start: 1 end: 2 }\"\n    \"}\"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name: \\\"foo\\\" number: 1 label: LABEL_OPTIONAL\"\n    \"          type_name: \\\"Foo\\\" extendee: \\\"Bar\\\" }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: EXTENDEE: FieldDescriptorProto.extendee set for \"\n      \"non-extension field.\\n\");\n}\n\nTEST_F(ValidationErrorTest, FieldOneofIndexTooLarge) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL type:TYPE_INT32 \"\n    \"          oneof_index: 1 }\"\n    \"  field { name:\\\"dummy\\\" number:2 label:LABEL_OPTIONAL type:TYPE_INT32 \"\n    \"          oneof_index: 0 }\"\n    \"  oneof_decl { name:\\\"bar\\\" }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: OTHER: FieldDescriptorProto.oneof_index 1 is out of \"\n      \"range for type \\\"Foo\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, FieldOneofIndexNegative) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL type:TYPE_INT32 \"\n    \"          oneof_index: -1 }\"\n    \"  field { name:\\\"dummy\\\" number:2 label:LABEL_OPTIONAL type:TYPE_INT32 \"\n    \"          oneof_index: 0 }\"\n    \"  oneof_decl { name:\\\"bar\\\" }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: OTHER: FieldDescriptorProto.oneof_index -1 is out of \"\n      \"range for type \\\"Foo\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, OneofFieldsConsecutiveDefinition) {\n  // Fields belonging to the same oneof must be defined consecutively.\n  BuildFileWithErrors(\n      \"name: \\\"foo.proto\\\" \"\n      \"message_type {\"\n      \"  name: \\\"Foo\\\"\"\n      \"  field { name:\\\"foo1\\\" number: 1 label:LABEL_OPTIONAL type:TYPE_INT32 \"\n      \"          oneof_index: 0 }\"\n      \"  field { name:\\\"bar\\\" number: 2 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n      \"  field { name:\\\"foo2\\\" number: 3 label:LABEL_OPTIONAL type:TYPE_INT32 \"\n      \"          oneof_index: 0 }\"\n      \"  oneof_decl { name:\\\"foos\\\" }\"\n      \"}\",\n\n      \"foo.proto: Foo.bar: OTHER: Fields in the same oneof must be defined \"\n      \"consecutively. \\\"bar\\\" cannot be defined before the completion of the \"\n      \"\\\"foos\\\" oneof definition.\\n\");\n\n  // Prevent interleaved fields, which belong to different oneofs.\n  BuildFileWithErrors(\n      \"name: \\\"foo2.proto\\\" \"\n      \"message_type {\"\n      \"  name: \\\"Foo2\\\"\"\n      \"  field { name:\\\"foo1\\\" number: 1 label:LABEL_OPTIONAL type:TYPE_INT32 \"\n      \"          oneof_index: 0 }\"\n      \"  field { name:\\\"bar1\\\" number: 2 label:LABEL_OPTIONAL type:TYPE_INT32 \"\n      \"          oneof_index: 1 }\"\n      \"  field { name:\\\"foo2\\\" number: 3 label:LABEL_OPTIONAL type:TYPE_INT32 \"\n      \"          oneof_index: 0 }\"\n      \"  field { name:\\\"bar2\\\" number: 4 label:LABEL_OPTIONAL type:TYPE_INT32 \"\n      \"          oneof_index: 1 }\"\n      \"  oneof_decl { name:\\\"foos\\\" }\"\n      \"  oneof_decl { name:\\\"bars\\\" }\"\n      \"}\",\n      \"foo2.proto: Foo2.bar1: OTHER: Fields in the same oneof must be defined \"\n      \"consecutively. \\\"bar1\\\" cannot be defined before the completion of the \"\n      \"\\\"foos\\\" oneof definition.\\n\"\n      \"foo2.proto: Foo2.foo2: OTHER: Fields in the same oneof must be defined \"\n      \"consecutively. \\\"foo2\\\" cannot be defined before the completion of the \"\n      \"\\\"bars\\\" oneof definition.\\n\");\n\n  // Another case for normal fields and different oneof fields interleave.\n  BuildFileWithErrors(\n      \"name: \\\"foo3.proto\\\" \"\n      \"message_type {\"\n      \"  name: \\\"Foo3\\\"\"\n      \"  field { name:\\\"foo1\\\" number: 1 label:LABEL_OPTIONAL type:TYPE_INT32 \"\n      \"          oneof_index: 0 }\"\n      \"  field { name:\\\"bar1\\\" number: 2 label:LABEL_OPTIONAL type:TYPE_INT32 \"\n      \"          oneof_index: 1 }\"\n      \"  field { name:\\\"baz\\\" number: 3 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n      \"  field { name:\\\"foo2\\\" number: 4 label:LABEL_OPTIONAL type:TYPE_INT32 \"\n      \"          oneof_index: 0 }\"\n      \"  oneof_decl { name:\\\"foos\\\" }\"\n      \"  oneof_decl { name:\\\"bars\\\" }\"\n      \"}\",\n      \"foo3.proto: Foo3.baz: OTHER: Fields in the same oneof must be defined \"\n      \"consecutively. \\\"baz\\\" cannot be defined before the completion of the \"\n      \"\\\"foos\\\" oneof definition.\\n\");\n}\n\nTEST_F(ValidationErrorTest, FieldNumberConflict) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name: \\\"foo\\\" number: 1 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n    \"  field { name: \\\"bar\\\" number: 1 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n    \"}\",\n\n    \"foo.proto: Foo.bar: NUMBER: Field number 1 has already been used in \"\n      \"\\\"Foo\\\" by field \\\"foo\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, BadMessageSetExtensionType) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"MessageSet\\\"\"\n    \"  options { message_set_wire_format: true }\"\n    \"  extension_range { start: 4 end: 5 }\"\n    \"}\"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  extension { name:\\\"foo\\\" number:4 label:LABEL_OPTIONAL type:TYPE_INT32\"\n    \"              extendee: \\\"MessageSet\\\" }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: TYPE: Extensions of MessageSets must be optional \"\n      \"messages.\\n\");\n}\n\nTEST_F(ValidationErrorTest, BadMessageSetExtensionLabel) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"MessageSet\\\"\"\n    \"  options { message_set_wire_format: true }\"\n    \"  extension_range { start: 4 end: 5 }\"\n    \"}\"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  extension { name:\\\"foo\\\" number:4 label:LABEL_REPEATED type:TYPE_MESSAGE\"\n    \"              type_name: \\\"Foo\\\" extendee: \\\"MessageSet\\\" }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: TYPE: Extensions of MessageSets must be optional \"\n      \"messages.\\n\");\n}\n\nTEST_F(ValidationErrorTest, FieldInMessageSet) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  options { message_set_wire_format: true }\"\n    \"  field { name: \\\"foo\\\" number: 1 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: NAME: MessageSets cannot have fields, only \"\n      \"extensions.\\n\");\n}\n\nTEST_F(ValidationErrorTest, NegativeExtensionRangeNumber) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  extension_range { start: -10 end: -1 }\"\n    \"}\",\n\n    \"foo.proto: Foo: NUMBER: Extension numbers must be positive integers.\\n\");\n}\n\nTEST_F(ValidationErrorTest, HugeExtensionRangeNumber) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  extension_range { start: 1 end: 0x70000000 }\"\n    \"}\",\n\n    \"foo.proto: Foo: NUMBER: Extension numbers cannot be greater than \"\n      \"536870911.\\n\");\n}\n\nTEST_F(ValidationErrorTest, ExtensionRangeEndBeforeStart) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  extension_range { start: 10 end: 10 }\"\n    \"  extension_range { start: 10 end: 5 }\"\n    \"}\",\n\n    \"foo.proto: Foo: NUMBER: Extension range end number must be greater than \"\n      \"start number.\\n\"\n    \"foo.proto: Foo: NUMBER: Extension range end number must be greater than \"\n      \"start number.\\n\");\n}\n\nTEST_F(ValidationErrorTest, EmptyEnum) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"enum_type { name: \\\"Foo\\\" }\"\n    // Also use the empty enum in a message to make sure there are no crashes\n    // during validation (possible if the code attempts to derive a default\n    // value for the field).\n    \"message_type {\"\n    \"  name: \\\"Bar\\\"\"\n    \"  field { name: \\\"foo\\\" number: 1 label:LABEL_OPTIONAL type_name:\\\"Foo\\\" }\"\n    \"  field { name: \\\"bar\\\" number: 2 label:LABEL_OPTIONAL type_name:\\\"Foo\\\" \"\n    \"          default_value: \\\"NO_SUCH_VALUE\\\" }\"\n    \"}\",\n\n    \"foo.proto: Foo: NAME: Enums must contain at least one value.\\n\"\n    \"foo.proto: Bar.bar: DEFAULT_VALUE: Enum type \\\"Foo\\\" has no value named \"\n      \"\\\"NO_SUCH_VALUE\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, UndefinedExtendee) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  extension { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL type:TYPE_INT32\"\n    \"              extendee: \\\"Bar\\\" }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: EXTENDEE: \\\"Bar\\\" is not defined.\\n\");\n}\n\nTEST_F(ValidationErrorTest, NonMessageExtendee) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"enum_type { name: \\\"Bar\\\" value { name:\\\"DUMMY\\\" number:0 } }\"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  extension { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL type:TYPE_INT32\"\n    \"              extendee: \\\"Bar\\\" }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: EXTENDEE: \\\"Bar\\\" is not a message type.\\n\");\n}\n\nTEST_F(ValidationErrorTest, NotAnExtensionNumber) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Bar\\\"\"\n    \"}\"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  extension { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL type:TYPE_INT32\"\n    \"              extendee: \\\"Bar\\\" }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: NUMBER: \\\"Bar\\\" does not declare 1 as an extension \"\n      \"number.\\n\");\n}\n\nTEST_F(ValidationErrorTest, RequiredExtension) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Bar\\\"\"\n    \"  extension_range { start: 1000 end: 10000 }\"\n    \"}\"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  extension {\"\n    \"    name:\\\"foo\\\"\"\n    \"    number:1000\"\n    \"    label:LABEL_REQUIRED\"\n    \"    type:TYPE_INT32\"\n    \"    extendee: \\\"Bar\\\"\"\n    \"  }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: TYPE: Message extensions cannot have required \"\n    \"fields.\\n\");\n}\n\nTEST_F(ValidationErrorTest, UndefinedFieldType) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL type_name:\\\"Bar\\\" }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: TYPE: \\\"Bar\\\" is not defined.\\n\");\n}\n\nTEST_F(ValidationErrorTest, UndefinedFieldTypeWithDefault) {\n  // See b/12533582. Previously this failed because the default value was not\n  // accepted by the parser, which assumed an enum type, leading to an unclear\n  // error message. We want this input to yield a validation error instead,\n  // since the unknown type is the primary problem.\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL type_name:\\\"int\\\" \"\n    \"          default_value:\\\"1\\\" }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: TYPE: \\\"int\\\" is not defined.\\n\");\n}\n\nTEST_F(ValidationErrorTest, UndefinedNestedFieldType) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  nested_type { name:\\\"Baz\\\" }\"\n    \"  field { name:\\\"foo\\\" number:1\"\n    \"          label:LABEL_OPTIONAL\"\n    \"          type_name:\\\"Foo.Baz.Bar\\\" }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: TYPE: \\\"Foo.Baz.Bar\\\" is not defined.\\n\");\n}\n\nTEST_F(ValidationErrorTest, FieldTypeDefinedInUndeclaredDependency) {\n  BuildFile(\n    \"name: \\\"bar.proto\\\" \"\n    \"message_type { name: \\\"Bar\\\" } \");\n\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL type_name:\\\"Bar\\\" }\"\n    \"}\",\n    \"foo.proto: Foo.foo: TYPE: \\\"Bar\\\" seems to be defined in \\\"bar.proto\\\", \"\n      \"which is not imported by \\\"foo.proto\\\".  To use it here, please add the \"\n      \"necessary import.\\n\");\n}\n\nTEST_F(ValidationErrorTest, FieldTypeDefinedInIndirectDependency) {\n  // Test for hidden dependencies.\n  //\n  // // bar.proto\n  // message Bar{}\n  //\n  // // forward.proto\n  // import \"bar.proto\"\n  //\n  // // foo.proto\n  // import \"forward.proto\"\n  // message Foo {\n  //   optional Bar foo = 1;  // Error, needs to import bar.proto explicitly.\n  // }\n  //\n  BuildFile(\n    \"name: \\\"bar.proto\\\" \"\n    \"message_type { name: \\\"Bar\\\" }\");\n\n  BuildFile(\n    \"name: \\\"forward.proto\\\"\"\n    \"dependency: \\\"bar.proto\\\"\");\n\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"forward.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL type_name:\\\"Bar\\\" }\"\n    \"}\",\n    \"foo.proto: Foo.foo: TYPE: \\\"Bar\\\" seems to be defined in \\\"bar.proto\\\", \"\n      \"which is not imported by \\\"foo.proto\\\".  To use it here, please add the \"\n      \"necessary import.\\n\");\n}\n\nTEST_F(ValidationErrorTest, FieldTypeDefinedInPublicDependency) {\n  // Test for public dependencies.\n  //\n  // // bar.proto\n  // message Bar{}\n  //\n  // // forward.proto\n  // import public \"bar.proto\"\n  //\n  // // foo.proto\n  // import \"forward.proto\"\n  // message Foo {\n  //   optional Bar foo = 1;  // Correct. \"bar.proto\" is public imported into\n  //                          // forward.proto, so when \"foo.proto\" imports\n  //                          // \"forward.proto\", it imports \"bar.proto\" too.\n  // }\n  //\n  BuildFile(\n    \"name: \\\"bar.proto\\\" \"\n    \"message_type { name: \\\"Bar\\\" }\");\n\n  BuildFile(\n    \"name: \\\"forward.proto\\\"\"\n    \"dependency: \\\"bar.proto\\\" \"\n    \"public_dependency: 0\");\n\n  BuildFile(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"forward.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL type_name:\\\"Bar\\\" }\"\n    \"}\");\n}\n\nTEST_F(ValidationErrorTest, FieldTypeDefinedInTransitivePublicDependency) {\n  // Test for public dependencies.\n  //\n  // // bar.proto\n  // message Bar{}\n  //\n  // // forward.proto\n  // import public \"bar.proto\"\n  //\n  // // forward2.proto\n  // import public \"forward.proto\"\n  //\n  // // foo.proto\n  // import \"forward2.proto\"\n  // message Foo {\n  //   optional Bar foo = 1;  // Correct, public imports are transitive.\n  // }\n  //\n  BuildFile(\n    \"name: \\\"bar.proto\\\" \"\n    \"message_type { name: \\\"Bar\\\" }\");\n\n  BuildFile(\n    \"name: \\\"forward.proto\\\"\"\n    \"dependency: \\\"bar.proto\\\" \"\n    \"public_dependency: 0\");\n\n  BuildFile(\n    \"name: \\\"forward2.proto\\\"\"\n    \"dependency: \\\"forward.proto\\\" \"\n    \"public_dependency: 0\");\n\n  BuildFile(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"forward2.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL type_name:\\\"Bar\\\" }\"\n    \"}\");\n}\n\nTEST_F(ValidationErrorTest,\n       FieldTypeDefinedInPrivateDependencyOfPublicDependency) {\n  // Test for public dependencies.\n  //\n  // // bar.proto\n  // message Bar{}\n  //\n  // // forward.proto\n  // import \"bar.proto\"\n  //\n  // // forward2.proto\n  // import public \"forward.proto\"\n  //\n  // // foo.proto\n  // import \"forward2.proto\"\n  // message Foo {\n  //   optional Bar foo = 1;  // Error, the \"bar.proto\" is not public imported\n  //                          // into \"forward.proto\", so will not be imported\n  //                          // into either \"forward2.proto\" or \"foo.proto\".\n  // }\n  //\n  BuildFile(\n    \"name: \\\"bar.proto\\\" \"\n    \"message_type { name: \\\"Bar\\\" }\");\n\n  BuildFile(\n    \"name: \\\"forward.proto\\\"\"\n    \"dependency: \\\"bar.proto\\\"\");\n\n  BuildFile(\n    \"name: \\\"forward2.proto\\\"\"\n    \"dependency: \\\"forward.proto\\\" \"\n    \"public_dependency: 0\");\n\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"forward2.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL type_name:\\\"Bar\\\" }\"\n    \"}\",\n    \"foo.proto: Foo.foo: TYPE: \\\"Bar\\\" seems to be defined in \\\"bar.proto\\\", \"\n      \"which is not imported by \\\"foo.proto\\\".  To use it here, please add the \"\n      \"necessary import.\\n\");\n}\n\n\nTEST_F(ValidationErrorTest, SearchMostLocalFirst) {\n  // The following should produce an error that Bar.Baz is resolved but\n  // not defined:\n  //   message Bar { message Baz {} }\n  //   message Foo {\n  //     message Bar {\n  //       // Placing \"message Baz{}\" here, or removing Foo.Bar altogether,\n  //       // would fix the error.\n  //     }\n  //     optional Bar.Baz baz = 1;\n  //   }\n  // An one point the lookup code incorrectly did not produce an error in this\n  // case, because when looking for Bar.Baz, it would try \"Foo.Bar.Baz\" first,\n  // fail, and ten try \"Bar.Baz\" and succeed, even though \"Bar\" should actually\n  // refer to the inner Bar, not the outer one.\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Bar\\\"\"\n    \"  nested_type { name: \\\"Baz\\\" }\"\n    \"}\"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  nested_type { name: \\\"Bar\\\" }\"\n    \"  field { name:\\\"baz\\\" number:1 label:LABEL_OPTIONAL\"\n    \"          type_name:\\\"Bar.Baz\\\" }\"\n    \"}\",\n\n    \"foo.proto: Foo.baz: TYPE: \\\"Bar.Baz\\\" is resolved to \\\"Foo.Bar.Baz\\\",\"\n    \" which is not defined. The innermost scope is searched first in name \"\n    \"resolution. Consider using a leading '.'(i.e., \\\".Bar.Baz\\\") to start \"\n    \"from the outermost scope.\\n\");\n}\n\nTEST_F(ValidationErrorTest, SearchMostLocalFirst2) {\n  // This test would find the most local \"Bar\" first, and does, but\n  // proceeds to find the outer one because the inner one's not an\n  // aggregate.\n  BuildFile(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Bar\\\"\"\n    \"  nested_type { name: \\\"Baz\\\" }\"\n    \"}\"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name: \\\"Bar\\\" number:1 type:TYPE_BYTES } \"\n    \"  field { name:\\\"baz\\\" number:2 label:LABEL_OPTIONAL\"\n    \"          type_name:\\\"Bar.Baz\\\" }\"\n    \"}\");\n}\n\nTEST_F(ValidationErrorTest, PackageOriginallyDeclaredInTransitiveDependent) {\n  // Imagine we have the following:\n  //\n  // foo.proto:\n  //   package foo.bar;\n  // bar.proto:\n  //   package foo.bar;\n  //   import \"foo.proto\";\n  //   message Bar {}\n  // baz.proto:\n  //   package foo;\n  //   import \"bar.proto\"\n  //   message Baz { optional bar.Bar qux = 1; }\n  //\n  // When validating baz.proto, we will look up \"bar.Bar\".  As part of this\n  // lookup, we first lookup \"bar\" then try to find \"Bar\" within it.  \"bar\"\n  // should resolve to \"foo.bar\".  Note, though, that \"foo.bar\" was originally\n  // defined in foo.proto, which is not a direct dependency of baz.proto.  The\n  // implementation of FindSymbol() normally only returns symbols in direct\n  // dependencies, not indirect ones.  This test insures that this does not\n  // prevent it from finding \"foo.bar\".\n\n  BuildFile(\n    \"name: \\\"foo.proto\\\" \"\n    \"package: \\\"foo.bar\\\" \");\n  BuildFile(\n    \"name: \\\"bar.proto\\\" \"\n    \"package: \\\"foo.bar\\\" \"\n    \"dependency: \\\"foo.proto\\\" \"\n    \"message_type { name: \\\"Bar\\\" }\");\n  BuildFile(\n    \"name: \\\"baz.proto\\\" \"\n    \"package: \\\"foo\\\" \"\n    \"dependency: \\\"bar.proto\\\" \"\n    \"message_type { \"\n    \"  name: \\\"Baz\\\" \"\n    \"  field { name:\\\"qux\\\" number:1 label:LABEL_OPTIONAL \"\n    \"          type_name:\\\"bar.Bar\\\" }\"\n    \"}\");\n}\n\nTEST_F(ValidationErrorTest, FieldTypeNotAType) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL \"\n    \"          type_name:\\\".Foo.bar\\\" }\"\n    \"  field { name:\\\"bar\\\" number:2 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: TYPE: \\\".Foo.bar\\\" is not a type.\\n\");\n}\n\nTEST_F(ValidationErrorTest, RelativeFieldTypeNotAType) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  nested_type {\"\n    \"    name: \\\"Bar\\\"\"\n    \"    field { name:\\\"Baz\\\" number:2 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n    \"  }\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL \"\n    \"          type_name:\\\"Bar.Baz\\\" }\"\n    \"}\",\n    \"foo.proto: Foo.foo: TYPE: \\\"Bar.Baz\\\" is not a type.\\n\");\n}\n\nTEST_F(ValidationErrorTest, FieldTypeMayBeItsName) {\n  BuildFile(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Bar\\\"\"\n    \"}\"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name:\\\"Bar\\\" number:1 label:LABEL_OPTIONAL type_name:\\\"Bar\\\" }\"\n    \"}\");\n}\n\nTEST_F(ValidationErrorTest, EnumFieldTypeIsMessage) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { name: \\\"Bar\\\" } \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL type:TYPE_ENUM\"\n    \"          type_name:\\\"Bar\\\" }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: TYPE: \\\"Bar\\\" is not an enum type.\\n\");\n}\n\nTEST_F(ValidationErrorTest, MessageFieldTypeIsEnum) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"enum_type { name: \\\"Bar\\\" value { name:\\\"DUMMY\\\" number:0 } } \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL type:TYPE_MESSAGE\"\n    \"          type_name:\\\"Bar\\\" }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: TYPE: \\\"Bar\\\" is not a message type.\\n\");\n}\n\nTEST_F(ValidationErrorTest, BadEnumDefaultValue) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"enum_type { name: \\\"Bar\\\" value { name:\\\"DUMMY\\\" number:0 } } \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL type_name:\\\"Bar\\\"\"\n    \"          default_value:\\\"NO_SUCH_VALUE\\\" }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: DEFAULT_VALUE: Enum type \\\"Bar\\\" has no value named \"\n      \"\\\"NO_SUCH_VALUE\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, EnumDefaultValueIsInteger) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"enum_type { name: \\\"Bar\\\" value { name:\\\"DUMMY\\\" number:0 } } \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL type_name:\\\"Bar\\\"\"\n    \"          default_value:\\\"0\\\" }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: DEFAULT_VALUE: Default value for an enum field must \"\n    \"be an identifier.\\n\");\n}\n\nTEST_F(ValidationErrorTest, PrimitiveWithTypeName) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL type:TYPE_INT32\"\n    \"          type_name:\\\"Foo\\\" }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: TYPE: Field with primitive type has type_name.\\n\");\n}\n\nTEST_F(ValidationErrorTest, NonPrimitiveWithoutTypeName) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL type:TYPE_MESSAGE }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: TYPE: Field with message or enum type missing \"\n      \"type_name.\\n\");\n}\n\nTEST_F(ValidationErrorTest, OneofWithNoFields) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  oneof_decl { name:\\\"bar\\\" }\"\n    \"}\",\n\n    \"foo.proto: Foo.bar: NAME: Oneof must have at least one field.\\n\");\n}\n\nTEST_F(ValidationErrorTest, OneofLabelMismatch) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name:\\\"foo\\\" number:1 label:LABEL_REPEATED type:TYPE_INT32 \"\n    \"          oneof_index:0 }\"\n    \"  oneof_decl { name:\\\"bar\\\" }\"\n    \"}\",\n\n    \"foo.proto: Foo.foo: NAME: Fields of oneofs must themselves have label \"\n      \"LABEL_OPTIONAL.\\n\");\n}\n\nTEST_F(ValidationErrorTest, InputTypeNotDefined) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { name: \\\"Foo\\\" } \"\n    \"service {\"\n    \"  name: \\\"TestService\\\"\"\n    \"  method { name: \\\"A\\\" input_type: \\\"Bar\\\" output_type: \\\"Foo\\\" }\"\n    \"}\",\n\n    \"foo.proto: TestService.A: INPUT_TYPE: \\\"Bar\\\" is not defined.\\n\"\n    );\n}\n\nTEST_F(ValidationErrorTest, InputTypeNotAMessage) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { name: \\\"Foo\\\" } \"\n    \"enum_type { name: \\\"Bar\\\" value { name:\\\"DUMMY\\\" number:0 } } \"\n    \"service {\"\n    \"  name: \\\"TestService\\\"\"\n    \"  method { name: \\\"A\\\" input_type: \\\"Bar\\\" output_type: \\\"Foo\\\" }\"\n    \"}\",\n\n    \"foo.proto: TestService.A: INPUT_TYPE: \\\"Bar\\\" is not a message type.\\n\"\n    );\n}\n\nTEST_F(ValidationErrorTest, OutputTypeNotDefined) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { name: \\\"Foo\\\" } \"\n    \"service {\"\n    \"  name: \\\"TestService\\\"\"\n    \"  method { name: \\\"A\\\" input_type: \\\"Foo\\\" output_type: \\\"Bar\\\" }\"\n    \"}\",\n\n    \"foo.proto: TestService.A: OUTPUT_TYPE: \\\"Bar\\\" is not defined.\\n\"\n    );\n}\n\nTEST_F(ValidationErrorTest, OutputTypeNotAMessage) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { name: \\\"Foo\\\" } \"\n    \"enum_type { name: \\\"Bar\\\" value { name:\\\"DUMMY\\\" number:0 } } \"\n    \"service {\"\n    \"  name: \\\"TestService\\\"\"\n    \"  method { name: \\\"A\\\" input_type: \\\"Foo\\\" output_type: \\\"Bar\\\" }\"\n    \"}\",\n\n    \"foo.proto: TestService.A: OUTPUT_TYPE: \\\"Bar\\\" is not a message type.\\n\"\n    );\n}\n\n\nTEST_F(ValidationErrorTest, IllegalPackedField) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\\n\"\n    \"  name: \\\"Foo\\\"\"\n    \"  field { name:\\\"packed_string\\\" number:1 label:LABEL_REPEATED \"\n    \"          type:TYPE_STRING \"\n    \"          options { uninterpreted_option {\"\n    \"            name { name_part: \\\"packed\\\" is_extension: false }\"\n    \"            identifier_value: \\\"true\\\" }}}\\n\"\n    \"  field { name:\\\"packed_message\\\" number:3 label:LABEL_REPEATED \"\n    \"          type_name: \\\"Foo\\\"\"\n    \"          options { uninterpreted_option {\"\n    \"            name { name_part: \\\"packed\\\" is_extension: false }\"\n    \"            identifier_value: \\\"true\\\" }}}\\n\"\n    \"  field { name:\\\"optional_int32\\\" number: 4 label: LABEL_OPTIONAL \"\n    \"          type:TYPE_INT32 \"\n    \"          options { uninterpreted_option {\"\n    \"            name { name_part: \\\"packed\\\" is_extension: false }\"\n    \"            identifier_value: \\\"true\\\" }}}\\n\"\n    \"}\",\n\n    \"foo.proto: Foo.packed_string: TYPE: [packed = true] can only be \"\n        \"specified for repeated primitive fields.\\n\"\n    \"foo.proto: Foo.packed_message: TYPE: [packed = true] can only be \"\n        \"specified for repeated primitive fields.\\n\"\n    \"foo.proto: Foo.optional_int32: TYPE: [packed = true] can only be \"\n        \"specified for repeated primitive fields.\\n\"\n        );\n}\n\nTEST_F(ValidationErrorTest, OptionWrongType) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { \"\n    \"  name: \\\"TestMessage\\\" \"\n    \"  field { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL type:TYPE_STRING \"\n    \"          options { uninterpreted_option { name { name_part: \\\"ctype\\\" \"\n    \"                                                  is_extension: false }\"\n    \"                                           positive_int_value: 1 }\"\n    \"          }\"\n    \"  }\"\n    \"}\\n\",\n\n    \"foo.proto: TestMessage.foo: OPTION_VALUE: Value must be identifier for \"\n    \"enum-valued option \\\"google.protobuf.FieldOptions.ctype\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, OptionExtendsAtomicType) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { \"\n    \"  name: \\\"TestMessage\\\" \"\n    \"  field { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL type:TYPE_STRING \"\n    \"          options { uninterpreted_option { name { name_part: \\\"ctype\\\" \"\n    \"                                                  is_extension: false }\"\n    \"                                           name { name_part: \\\"foo\\\" \"\n    \"                                                  is_extension: true }\"\n    \"                                           positive_int_value: 1 }\"\n    \"          }\"\n    \"  }\"\n    \"}\\n\",\n\n    \"foo.proto: TestMessage.foo: OPTION_NAME: Option \\\"ctype\\\" is an \"\n    \"atomic type, not a message.\\n\");\n}\n\nTEST_F(ValidationErrorTest, DupOption) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { \"\n    \"  name: \\\"TestMessage\\\" \"\n    \"  field { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL type:TYPE_UINT32 \"\n    \"          options { uninterpreted_option { name { name_part: \\\"ctype\\\" \"\n    \"                                                  is_extension: false }\"\n    \"                                           identifier_value: \\\"CORD\\\" }\"\n    \"                    uninterpreted_option { name { name_part: \\\"ctype\\\" \"\n    \"                                                  is_extension: false }\"\n    \"                                           identifier_value: \\\"CORD\\\" }\"\n    \"          }\"\n    \"  }\"\n    \"}\\n\",\n\n    \"foo.proto: TestMessage.foo: OPTION_NAME: Option \\\"ctype\\\" was \"\n    \"already set.\\n\");\n}\n\nTEST_F(ValidationErrorTest, InvalidOptionName) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { \"\n    \"  name: \\\"TestMessage\\\" \"\n    \"  field { name:\\\"foo\\\" number:1 label:LABEL_OPTIONAL type:TYPE_BOOL \"\n    \"          options { uninterpreted_option { \"\n    \"                      name { name_part: \\\"uninterpreted_option\\\" \"\n    \"                             is_extension: false }\"\n    \"                      positive_int_value: 1 \"\n    \"                    }\"\n    \"          }\"\n    \"  }\"\n    \"}\\n\",\n\n    \"foo.proto: TestMessage.foo: OPTION_NAME: Option must not use \"\n    \"reserved name \\\"uninterpreted_option\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, RepeatedMessageOption) {\n  BuildDescriptorMessagesInTestPool();\n\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"google/protobuf/descriptor.proto\\\" \"\n    \"message_type: { name: \\\"Bar\\\" field: { \"\n    \"  name: \\\"foo\\\" number: 1 label: LABEL_OPTIONAL type: TYPE_INT32 } \"\n    \"} \"\n    \"extension { name: \\\"bar\\\" number: 7672757 label: LABEL_REPEATED \"\n    \"            type: TYPE_MESSAGE type_name: \\\"Bar\\\" \"\n    \"            extendee: \\\"google.protobuf.FileOptions\\\" }\"\n    \"options { uninterpreted_option { name { name_part: \\\"bar\\\" \"\n    \"                                        is_extension: true } \"\n    \"                                 name { name_part: \\\"foo\\\" \"\n    \"                                        is_extension: false } \"\n    \"                                 positive_int_value: 1 } }\",\n\n    \"foo.proto: foo.proto: OPTION_NAME: Option field \\\"(bar)\\\" is a \"\n    \"repeated message. Repeated message options must be initialized \"\n    \"using an aggregate value.\\n\");\n}\n\nTEST_F(ValidationErrorTest, ResolveUndefinedOption) {\n  // The following should produce an eror that baz.bar is resolved but not\n  // defined.\n  // foo.proto:\n  //   package baz\n  //   import google/protobuf/descriptor.proto\n  //   message Bar { optional int32 foo = 1; }\n  //   extend FileOptions { optional Bar bar = 7672757; }\n  //\n  // qux.proto:\n  //   package qux.baz\n  //   option (baz.bar).foo = 1;\n  //\n  // Although \"baz.bar\" is already defined, the lookup code will try\n  // \"qux.baz.bar\", since it's the match from the innermost scope, which will\n  // cause a symbol not defined error.\n  BuildDescriptorMessagesInTestPool();\n\n  BuildFile(\n    \"name: \\\"foo.proto\\\" \"\n    \"package: \\\"baz\\\" \"\n    \"dependency: \\\"google/protobuf/descriptor.proto\\\" \"\n    \"message_type: { name: \\\"Bar\\\" field: { \"\n    \"  name: \\\"foo\\\" number: 1 label: LABEL_OPTIONAL type: TYPE_INT32 } \"\n    \"} \"\n    \"extension { name: \\\"bar\\\" number: 7672757 label: LABEL_OPTIONAL \"\n    \"            type: TYPE_MESSAGE type_name: \\\"Bar\\\" \"\n    \"            extendee: \\\"google.protobuf.FileOptions\\\" }\");\n\n  BuildFileWithErrors(\n    \"name: \\\"qux.proto\\\" \"\n    \"package: \\\"qux.baz\\\" \"\n    \"options { uninterpreted_option { name { name_part: \\\"baz.bar\\\" \"\n    \"                                        is_extension: true } \"\n    \"                                 name { name_part: \\\"foo\\\" \"\n    \"                                        is_extension: false } \"\n    \"                                 positive_int_value: 1 } }\",\n\n    \"qux.proto: qux.proto: OPTION_NAME: Option \\\"(baz.bar)\\\" is resolved to \"\n    \"\\\"(qux.baz.bar)\\\",\"\n    \" which is not defined. The innermost scope is searched first in name \"\n    \"resolution. Consider using a leading '.'(i.e., \\\"(.baz.bar)\\\") to start \"\n    \"from the outermost scope.\\n\");\n}\n\nTEST_F(ValidationErrorTest, UnknownOption) {\n  BuildFileWithErrors(\n    \"name: \\\"qux.proto\\\" \"\n    \"package: \\\"qux.baz\\\" \"\n    \"options { uninterpreted_option { name { name_part: \\\"baaz.bar\\\" \"\n    \"                                        is_extension: true } \"\n    \"                                 name { name_part: \\\"foo\\\" \"\n    \"                                        is_extension: false } \"\n    \"                                 positive_int_value: 1 } }\",\n\n    \"qux.proto: qux.proto: OPTION_NAME: Option \\\"(baaz.bar)\\\" unknown.\\n\");\n}\n\nTEST_F(ValidationErrorTest, CustomOptionConflictingFieldNumber) {\n  BuildDescriptorMessagesInTestPool();\n\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"google/protobuf/descriptor.proto\\\" \"\n    \"extension { name: \\\"foo1\\\" number: 7672757 label: LABEL_OPTIONAL \"\n    \"            type: TYPE_INT32 extendee: \\\"google.protobuf.FieldOptions\\\" }\"\n    \"extension { name: \\\"foo2\\\" number: 7672757 label: LABEL_OPTIONAL \"\n    \"            type: TYPE_INT32 extendee: \\\"google.protobuf.FieldOptions\\\" }\",\n\n    \"foo.proto: foo2: NUMBER: Extension number 7672757 has already been used \"\n    \"in \\\"google.protobuf.FieldOptions\\\" by extension \\\"foo1\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, Int32OptionValueOutOfPositiveRange) {\n  BuildDescriptorMessagesInTestPool();\n\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"google/protobuf/descriptor.proto\\\" \"\n    \"extension { name: \\\"foo\\\" number: 7672757 label: LABEL_OPTIONAL \"\n    \"            type: TYPE_INT32 extendee: \\\"google.protobuf.FileOptions\\\" }\"\n    \"options { uninterpreted_option { name { name_part: \\\"foo\\\" \"\n    \"                                        is_extension: true } \"\n    \"                                 positive_int_value: 0x80000000 } \"\n    \"}\",\n\n    \"foo.proto: foo.proto: OPTION_VALUE: Value out of range \"\n    \"for int32 option \\\"foo\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, Int32OptionValueOutOfNegativeRange) {\n  BuildDescriptorMessagesInTestPool();\n\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"google/protobuf/descriptor.proto\\\" \"\n    \"extension { name: \\\"foo\\\" number: 7672757 label: LABEL_OPTIONAL \"\n    \"            type: TYPE_INT32 extendee: \\\"google.protobuf.FileOptions\\\" }\"\n    \"options { uninterpreted_option { name { name_part: \\\"foo\\\" \"\n    \"                                        is_extension: true } \"\n    \"                                 negative_int_value: -0x80000001 } \"\n    \"}\",\n\n    \"foo.proto: foo.proto: OPTION_VALUE: Value out of range \"\n    \"for int32 option \\\"foo\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, Int32OptionValueIsNotPositiveInt) {\n  BuildDescriptorMessagesInTestPool();\n\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"google/protobuf/descriptor.proto\\\" \"\n    \"extension { name: \\\"foo\\\" number: 7672757 label: LABEL_OPTIONAL \"\n    \"            type: TYPE_INT32 extendee: \\\"google.protobuf.FileOptions\\\" }\"\n    \"options { uninterpreted_option { name { name_part: \\\"foo\\\" \"\n    \"                                        is_extension: true } \"\n    \"                                 string_value: \\\"5\\\" } }\",\n\n    \"foo.proto: foo.proto: OPTION_VALUE: Value must be integer \"\n    \"for int32 option \\\"foo\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, Int64OptionValueOutOfRange) {\n  BuildDescriptorMessagesInTestPool();\n\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"google/protobuf/descriptor.proto\\\" \"\n    \"extension { name: \\\"foo\\\" number: 7672757 label: LABEL_OPTIONAL \"\n    \"            type: TYPE_INT64 extendee: \\\"google.protobuf.FileOptions\\\" }\"\n    \"options { uninterpreted_option { name { name_part: \\\"foo\\\" \"\n    \"                                        is_extension: true } \"\n    \"                                 positive_int_value: 0x8000000000000000 } \"\n    \"}\",\n\n    \"foo.proto: foo.proto: OPTION_VALUE: Value out of range \"\n    \"for int64 option \\\"foo\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, Int64OptionValueIsNotPositiveInt) {\n  BuildDescriptorMessagesInTestPool();\n\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"google/protobuf/descriptor.proto\\\" \"\n    \"extension { name: \\\"foo\\\" number: 7672757 label: LABEL_OPTIONAL \"\n    \"            type: TYPE_INT64 extendee: \\\"google.protobuf.FileOptions\\\" }\"\n    \"options { uninterpreted_option { name { name_part: \\\"foo\\\" \"\n    \"                                        is_extension: true } \"\n    \"                                 identifier_value: \\\"5\\\" } }\",\n\n    \"foo.proto: foo.proto: OPTION_VALUE: Value must be integer \"\n    \"for int64 option \\\"foo\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, UInt32OptionValueOutOfRange) {\n  BuildDescriptorMessagesInTestPool();\n\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"google/protobuf/descriptor.proto\\\" \"\n    \"extension { name: \\\"foo\\\" number: 7672757 label: LABEL_OPTIONAL \"\n    \"            type: TYPE_UINT32 extendee: \\\"google.protobuf.FileOptions\\\" }\"\n    \"options { uninterpreted_option { name { name_part: \\\"foo\\\" \"\n    \"                                        is_extension: true } \"\n    \"                                 positive_int_value: 0x100000000 } }\",\n\n    \"foo.proto: foo.proto: OPTION_VALUE: Value out of range \"\n    \"for uint32 option \\\"foo\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, UInt32OptionValueIsNotPositiveInt) {\n  BuildDescriptorMessagesInTestPool();\n\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"google/protobuf/descriptor.proto\\\" \"\n    \"extension { name: \\\"foo\\\" number: 7672757 label: LABEL_OPTIONAL \"\n    \"            type: TYPE_UINT32 extendee: \\\"google.protobuf.FileOptions\\\" }\"\n    \"options { uninterpreted_option { name { name_part: \\\"foo\\\" \"\n    \"                                        is_extension: true } \"\n    \"                                 double_value: -5.6 } }\",\n\n    \"foo.proto: foo.proto: OPTION_VALUE: Value must be non-negative integer \"\n    \"for uint32 option \\\"foo\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, UInt64OptionValueIsNotPositiveInt) {\n  BuildDescriptorMessagesInTestPool();\n\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"google/protobuf/descriptor.proto\\\" \"\n    \"extension { name: \\\"foo\\\" number: 7672757 label: LABEL_OPTIONAL \"\n    \"            type: TYPE_UINT64 extendee: \\\"google.protobuf.FileOptions\\\" }\"\n    \"options { uninterpreted_option { name { name_part: \\\"foo\\\" \"\n    \"                                        is_extension: true } \"\n    \"                                 negative_int_value: -5 } }\",\n\n    \"foo.proto: foo.proto: OPTION_VALUE: Value must be non-negative integer \"\n    \"for uint64 option \\\"foo\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, FloatOptionValueIsNotNumber) {\n  BuildDescriptorMessagesInTestPool();\n\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"google/protobuf/descriptor.proto\\\" \"\n    \"extension { name: \\\"foo\\\" number: 7672757 label: LABEL_OPTIONAL \"\n    \"            type: TYPE_FLOAT extendee: \\\"google.protobuf.FileOptions\\\" }\"\n    \"options { uninterpreted_option { name { name_part: \\\"foo\\\" \"\n    \"                                        is_extension: true } \"\n    \"                                 string_value: \\\"bar\\\" } }\",\n\n    \"foo.proto: foo.proto: OPTION_VALUE: Value must be number \"\n    \"for float option \\\"foo\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, DoubleOptionValueIsNotNumber) {\n  BuildDescriptorMessagesInTestPool();\n\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"google/protobuf/descriptor.proto\\\" \"\n    \"extension { name: \\\"foo\\\" number: 7672757 label: LABEL_OPTIONAL \"\n    \"            type: TYPE_DOUBLE extendee: \\\"google.protobuf.FileOptions\\\" }\"\n    \"options { uninterpreted_option { name { name_part: \\\"foo\\\" \"\n    \"                                        is_extension: true } \"\n    \"                                 string_value: \\\"bar\\\" } }\",\n\n    \"foo.proto: foo.proto: OPTION_VALUE: Value must be number \"\n    \"for double option \\\"foo\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, BoolOptionValueIsNotTrueOrFalse) {\n  BuildDescriptorMessagesInTestPool();\n\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"google/protobuf/descriptor.proto\\\" \"\n    \"extension { name: \\\"foo\\\" number: 7672757 label: LABEL_OPTIONAL \"\n    \"            type: TYPE_BOOL extendee: \\\"google.protobuf.FileOptions\\\" }\"\n    \"options { uninterpreted_option { name { name_part: \\\"foo\\\" \"\n    \"                                        is_extension: true } \"\n    \"                                 identifier_value: \\\"bar\\\" } }\",\n\n    \"foo.proto: foo.proto: OPTION_VALUE: Value must be \\\"true\\\" or \\\"false\\\" \"\n    \"for boolean option \\\"foo\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, EnumOptionValueIsNotIdentifier) {\n  BuildDescriptorMessagesInTestPool();\n\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"google/protobuf/descriptor.proto\\\" \"\n    \"enum_type { name: \\\"FooEnum\\\" value { name: \\\"BAR\\\" number: 1 } \"\n    \"                              value { name: \\\"BAZ\\\" number: 2 } }\"\n    \"extension { name: \\\"foo\\\" number: 7672757 label: LABEL_OPTIONAL \"\n    \"            type: TYPE_ENUM type_name: \\\"FooEnum\\\" \"\n    \"            extendee: \\\"google.protobuf.FileOptions\\\" }\"\n    \"options { uninterpreted_option { name { name_part: \\\"foo\\\" \"\n    \"                                        is_extension: true } \"\n    \"                                 string_value: \\\"QUUX\\\" } }\",\n\n    \"foo.proto: foo.proto: OPTION_VALUE: Value must be identifier for \"\n    \"enum-valued option \\\"foo\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, EnumOptionValueIsNotEnumValueName) {\n  BuildDescriptorMessagesInTestPool();\n\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"google/protobuf/descriptor.proto\\\" \"\n    \"enum_type { name: \\\"FooEnum\\\" value { name: \\\"BAR\\\" number: 1 } \"\n    \"                              value { name: \\\"BAZ\\\" number: 2 } }\"\n    \"extension { name: \\\"foo\\\" number: 7672757 label: LABEL_OPTIONAL \"\n    \"            type: TYPE_ENUM type_name: \\\"FooEnum\\\" \"\n    \"            extendee: \\\"google.protobuf.FileOptions\\\" }\"\n    \"options { uninterpreted_option { name { name_part: \\\"foo\\\" \"\n    \"                                        is_extension: true } \"\n    \"                                 identifier_value: \\\"QUUX\\\" } }\",\n\n    \"foo.proto: foo.proto: OPTION_VALUE: Enum type \\\"FooEnum\\\" has no value \"\n    \"named \\\"QUUX\\\" for option \\\"foo\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, EnumOptionValueIsSiblingEnumValueName) {\n  BuildDescriptorMessagesInTestPool();\n\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"google/protobuf/descriptor.proto\\\" \"\n    \"enum_type { name: \\\"FooEnum1\\\" value { name: \\\"BAR\\\" number: 1 } \"\n    \"                               value { name: \\\"BAZ\\\" number: 2 } }\"\n    \"enum_type { name: \\\"FooEnum2\\\" value { name: \\\"QUX\\\" number: 1 } \"\n    \"                               value { name: \\\"QUUX\\\" number: 2 } }\"\n    \"extension { name: \\\"foo\\\" number: 7672757 label: LABEL_OPTIONAL \"\n    \"            type: TYPE_ENUM type_name: \\\"FooEnum1\\\" \"\n    \"            extendee: \\\"google.protobuf.FileOptions\\\" }\"\n    \"options { uninterpreted_option { name { name_part: \\\"foo\\\" \"\n    \"                                        is_extension: true } \"\n    \"                                 identifier_value: \\\"QUUX\\\" } }\",\n\n    \"foo.proto: foo.proto: OPTION_VALUE: Enum type \\\"FooEnum1\\\" has no value \"\n    \"named \\\"QUUX\\\" for option \\\"foo\\\". This appears to be a value from a \"\n    \"sibling type.\\n\");\n}\n\nTEST_F(ValidationErrorTest, StringOptionValueIsNotString) {\n  BuildDescriptorMessagesInTestPool();\n\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"google/protobuf/descriptor.proto\\\" \"\n    \"extension { name: \\\"foo\\\" number: 7672757 label: LABEL_OPTIONAL \"\n    \"            type: TYPE_STRING extendee: \\\"google.protobuf.FileOptions\\\" }\"\n    \"options { uninterpreted_option { name { name_part: \\\"foo\\\" \"\n    \"                                        is_extension: true } \"\n    \"                                 identifier_value: \\\"QUUX\\\" } }\",\n\n    \"foo.proto: foo.proto: OPTION_VALUE: Value must be quoted string for \"\n    \"string option \\\"foo\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, DuplicateExtensionFieldNumber) {\n  BuildDescriptorMessagesInTestPool();\n\n  BuildFile(\n      \"name: \\\"foo.proto\\\" \"\n      \"dependency: \\\"google/protobuf/descriptor.proto\\\" \"\n      \"extension { name: \\\"option1\\\" number: 1000 label: LABEL_OPTIONAL \"\n      \"            type: TYPE_INT32 extendee: \\\"google.protobuf.FileOptions\\\" }\");\n\n  BuildFileWithWarnings(\n      \"name: \\\"bar.proto\\\" \"\n      \"dependency: \\\"google/protobuf/descriptor.proto\\\" \"\n      \"extension { name: \\\"option2\\\" number: 1000 label: LABEL_OPTIONAL \"\n      \"            type: TYPE_INT32 extendee: \\\"google.protobuf.FileOptions\\\" }\",\n      \"bar.proto: option2: NUMBER: Extension number 1000 has already been used \"\n      \"in \\\"google.protobuf.FileOptions\\\" by extension \\\"option1\\\" defined in \"\n      \"foo.proto.\\n\");\n}\n\n// Helper function for tests that check for aggregate value parsing\n// errors.  The \"value\" argument is embedded inside the\n// \"uninterpreted_option\" portion of the result.\nstatic string EmbedAggregateValue(const char* value) {\n  return strings::Substitute(\n      \"name: \\\"foo.proto\\\" \"\n      \"dependency: \\\"google/protobuf/descriptor.proto\\\" \"\n      \"message_type { name: \\\"Foo\\\" } \"\n      \"extension { name: \\\"foo\\\" number: 7672757 label: LABEL_OPTIONAL \"\n      \"            type: TYPE_MESSAGE type_name: \\\"Foo\\\" \"\n      \"            extendee: \\\"google.protobuf.FileOptions\\\" }\"\n      \"options { uninterpreted_option { name { name_part: \\\"foo\\\" \"\n      \"                                        is_extension: true } \"\n      \"                                 $0 } }\",\n      value);\n}\n\nTEST_F(ValidationErrorTest, AggregateValueNotFound) {\n  BuildDescriptorMessagesInTestPool();\n\n  BuildFileWithErrors(\n      EmbedAggregateValue(\"string_value: \\\"\\\"\"),\n      \"foo.proto: foo.proto: OPTION_VALUE: Option \\\"foo\\\" is a message. \"\n      \"To set the entire message, use syntax like \"\n      \"\\\"foo = { <proto text format> }\\\". To set fields within it, use \"\n      \"syntax like \\\"foo.foo = value\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, AggregateValueParseError) {\n  BuildDescriptorMessagesInTestPool();\n\n  BuildFileWithErrors(\n      EmbedAggregateValue(\"aggregate_value: \\\"1+2\\\"\"),\n      \"foo.proto: foo.proto: OPTION_VALUE: Error while parsing option \"\n      \"value for \\\"foo\\\": Expected identifier, got: 1\\n\");\n}\n\nTEST_F(ValidationErrorTest, AggregateValueUnknownFields) {\n  BuildDescriptorMessagesInTestPool();\n\n  BuildFileWithErrors(\n      EmbedAggregateValue(\"aggregate_value: \\\"x:100\\\"\"),\n      \"foo.proto: foo.proto: OPTION_VALUE: Error while parsing option \"\n      \"value for \\\"foo\\\": Message type \\\"Foo\\\" has no field named \\\"x\\\".\\n\");\n}\n\nTEST_F(ValidationErrorTest, NotLiteImportsLite) {\n  BuildFile(\n    \"name: \\\"bar.proto\\\" \"\n    \"options { optimize_for: LITE_RUNTIME } \");\n\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"bar.proto\\\" \",\n\n    \"foo.proto: foo.proto: OTHER: Files that do not use optimize_for = \"\n      \"LITE_RUNTIME cannot import files which do use this option.  This file \"\n      \"is not lite, but it imports \\\"bar.proto\\\" which is.\\n\");\n}\n\nTEST_F(ValidationErrorTest, LiteExtendsNotLite) {\n  BuildFile(\n    \"name: \\\"bar.proto\\\" \"\n    \"message_type: {\"\n    \"  name: \\\"Bar\\\"\"\n    \"  extension_range { start: 1 end: 1000 }\"\n    \"}\");\n\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"dependency: \\\"bar.proto\\\" \"\n    \"options { optimize_for: LITE_RUNTIME } \"\n    \"extension { name: \\\"ext\\\" number: 123 label: LABEL_OPTIONAL \"\n    \"            type: TYPE_INT32 extendee: \\\"Bar\\\" }\",\n\n    \"foo.proto: ext: EXTENDEE: Extensions to non-lite types can only be \"\n      \"declared in non-lite files.  Note that you cannot extend a non-lite \"\n      \"type to contain a lite type, but the reverse is allowed.\\n\");\n}\n\nTEST_F(ValidationErrorTest, NoLiteServices) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"options {\"\n    \"  optimize_for: LITE_RUNTIME\"\n    \"  cc_generic_services: true\"\n    \"  java_generic_services: true\"\n    \"} \"\n    \"service { name: \\\"Foo\\\" }\",\n\n    \"foo.proto: Foo: NAME: Files with optimize_for = LITE_RUNTIME cannot \"\n    \"define services unless you set both options cc_generic_services and \"\n    \"java_generic_sevices to false.\\n\");\n\n  BuildFile(\n    \"name: \\\"bar.proto\\\" \"\n    \"options {\"\n    \"  optimize_for: LITE_RUNTIME\"\n    \"  cc_generic_services: false\"\n    \"  java_generic_services: false\"\n    \"} \"\n    \"service { name: \\\"Bar\\\" }\");\n}\n\nTEST_F(ValidationErrorTest, RollbackAfterError) {\n  // Build a file which contains every kind of construct but references an\n  // undefined type.  All these constructs will be added to the symbol table\n  // before the undefined type error is noticed.  The DescriptorPool will then\n  // have to roll everything back.\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  field { name:\\\"foo\\\" label:LABEL_OPTIONAL type:TYPE_INT32 number:1 }\"\n    \"} \"\n    \"enum_type {\"\n    \"  name: \\\"TestEnum\\\"\"\n    \"  value { name:\\\"BAR\\\" number:1 }\"\n    \"} \"\n    \"service {\"\n    \"  name: \\\"TestService\\\"\"\n    \"  method {\"\n    \"    name: \\\"Baz\\\"\"\n    \"    input_type: \\\"NoSuchType\\\"\"    // error\n    \"    output_type: \\\"TestMessage\\\"\"\n    \"  }\"\n    \"}\",\n\n    \"foo.proto: TestService.Baz: INPUT_TYPE: \\\"NoSuchType\\\" is not defined.\\n\"\n    );\n\n  // Make sure that if we build the same file again with the error fixed,\n  // it works.  If the above rollback was incomplete, then some symbols will\n  // be left defined, and this second attempt will fail since it tries to\n  // re-define the same symbols.\n  BuildFile(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type {\"\n    \"  name: \\\"TestMessage\\\"\"\n    \"  field { name:\\\"foo\\\" label:LABEL_OPTIONAL type:TYPE_INT32 number:1 }\"\n    \"} \"\n    \"enum_type {\"\n    \"  name: \\\"TestEnum\\\"\"\n    \"  value { name:\\\"BAR\\\" number:1 }\"\n    \"} \"\n    \"service {\"\n    \"  name: \\\"TestService\\\"\"\n    \"  method { name:\\\"Baz\\\"\"\n    \"           input_type:\\\"TestMessage\\\"\"\n    \"           output_type:\\\"TestMessage\\\" }\"\n    \"}\");\n}\n\nTEST_F(ValidationErrorTest, ErrorsReportedToLogError) {\n  // Test that errors are reported to GOOGLE_LOG(ERROR) if no error collector is\n  // provided.\n\n  FileDescriptorProto file_proto;\n  ASSERT_TRUE(TextFormat::ParseFromString(\n    \"name: \\\"foo.proto\\\" \"\n    \"message_type { name: \\\"Foo\\\" } \"\n    \"message_type { name: \\\"Foo\\\" } \",\n    &file_proto));\n\n  vector<string> errors;\n\n  {\n    ScopedMemoryLog log;\n    EXPECT_TRUE(pool_.BuildFile(file_proto) == NULL);\n    errors = log.GetMessages(ERROR);\n  }\n\n  ASSERT_EQ(2, errors.size());\n\n  EXPECT_EQ(\"Invalid proto descriptor for file \\\"foo.proto\\\":\", errors[0]);\n  EXPECT_EQ(\"  Foo: \\\"Foo\\\" is already defined.\", errors[1]);\n}\n\nTEST_F(ValidationErrorTest, DisallowEnumAlias) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"enum_type {\"\n    \"  name: \\\"Bar\\\"\"\n    \"  value { name:\\\"ENUM_A\\\" number:0 }\"\n    \"  value { name:\\\"ENUM_B\\\" number:0 }\"\n    \"}\",\n    \"foo.proto: Bar: NUMBER: \"\n    \"\\\"ENUM_B\\\" uses the same enum value as \\\"ENUM_A\\\". \"\n    \"If this is intended, set 'option allow_alias = true;' to the enum \"\n    \"definition.\\n\");\n}\n\nTEST_F(ValidationErrorTest, AllowEnumAlias) {\n  BuildFile(\n    \"name: \\\"foo.proto\\\" \"\n    \"enum_type {\"\n    \"  name: \\\"Bar\\\"\"\n    \"  value { name:\\\"ENUM_A\\\" number:0 }\"\n    \"  value { name:\\\"ENUM_B\\\" number:0 }\"\n    \"  options { allow_alias: true }\"\n    \"}\");\n}\n\nTEST_F(ValidationErrorTest, UnusedImportWarning) {\n  pool_.AddUnusedImportTrackFile(\"bar.proto\");\n  BuildFile(\n    \"name: \\\"bar.proto\\\" \"\n    \"message_type { name: \\\"Bar\\\" }\");\n\n  pool_.AddUnusedImportTrackFile(\"base.proto\");\n  BuildFile(\n    \"name: \\\"base.proto\\\" \"\n    \"message_type { name: \\\"Base\\\" }\");\n\n  pool_.AddUnusedImportTrackFile(\"baz.proto\");\n  BuildFile(\n    \"name: \\\"baz.proto\\\" \"\n    \"message_type { name: \\\"Baz\\\" }\");\n\n  pool_.AddUnusedImportTrackFile(\"public.proto\");\n  BuildFile(\n    \"name: \\\"public.proto\\\" \"\n    \"dependency: \\\"bar.proto\\\"\"\n    \"public_dependency: 0\");\n\n  // // forward.proto\n  // import \"base.proto\"       // No warning: Base message is used.\n  // import \"bar.proto\"        // Will log a warning.\n  // import public \"baz.proto\" // No warning: Do not track import public.\n  // import \"public.proto\"     // No warning: public.proto has import public.\n  // message Forward {\n  //   optional Base base = 1;\n  // }\n  //\n  pool_.AddUnusedImportTrackFile(\"forward.proto\");\n  BuildFileWithWarnings(\n    \"name: \\\"forward.proto\\\"\"\n    \"dependency: \\\"base.proto\\\"\"\n    \"dependency: \\\"bar.proto\\\"\"\n    \"dependency: \\\"baz.proto\\\"\"\n    \"dependency: \\\"public.proto\\\"\"\n    \"public_dependency: 2 \"\n    \"message_type {\"\n    \"  name: \\\"Forward\\\"\"\n    \"  field { name:\\\"base\\\" number:1 label:LABEL_OPTIONAL type_name:\\\"Base\\\" }\"\n    \"}\",\n    \"forward.proto: bar.proto: OTHER: Import bar.proto but not used.\\n\");\n}\n\nnamespace {\nvoid FillValidMapEntry(FileDescriptorProto* file_proto) {\n  ASSERT_TRUE(TextFormat::ParseFromString(\n      \"name: 'foo.proto' \"\n      \"message_type { \"\n      \"  name: 'Foo' \"\n      \"  field { \"\n      \"    name: 'foo_map' number: 1 label:LABEL_REPEATED \"\n      \"    type_name: 'FooMapEntry' \"\n      \"  } \"\n      \"  nested_type { \"\n      \"    name: 'FooMapEntry' \"\n      \"    options {  map_entry: true } \"\n      \"    field { \"\n      \"      name: 'key' number: 1 type:TYPE_INT32 label:LABEL_OPTIONAL \"\n      \"    } \"\n      \"    field { \"\n      \"      name: 'value' number: 2 type:TYPE_INT32 label:LABEL_OPTIONAL \"\n      \"    } \"\n      \"  } \"\n      \"} \"\n      \"message_type { \"\n      \"  name: 'Bar' \"\n      \"  extension_range { start: 1 end: 10 }\"\n      \"} \",\n      file_proto));\n}\nstatic const char* kMapEntryErrorMessage =\n    \"foo.proto: Foo.foo_map: OTHER: map_entry should not be set explicitly. \"\n    \"Use map<KeyType, ValueType> instead.\\n\";\nstatic const char* kMapEntryKeyTypeErrorMessage =\n    \"foo.proto: Foo.foo_map: TYPE: Key in map fields cannot be float/double, \"\n    \"bytes or message types.\\n\";\n\n}  // namespace\n\nTEST_F(ValidationErrorTest, MapEntryBase) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  BuildFile(file_proto.DebugString());\n}\n\nTEST_F(ValidationErrorTest, MapEntryExtensionRange) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  TextFormat::MergeFromString(\n      \"extension_range { \"\n      \"  start: 10 end: 20 \"\n      \"} \",\n      file_proto.mutable_message_type(0)->mutable_nested_type(0));\n  BuildFileWithErrors(file_proto.DebugString(), kMapEntryErrorMessage);\n}\n\nTEST_F(ValidationErrorTest, MapEntryExtension) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  TextFormat::MergeFromString(\n      \"extension { \"\n      \"  name: 'foo_ext' extendee: '.Bar' number: 5\"\n      \"} \",\n      file_proto.mutable_message_type(0)->mutable_nested_type(0));\n  BuildFileWithErrors(file_proto.DebugString(), kMapEntryErrorMessage);\n}\n\nTEST_F(ValidationErrorTest, MapEntryNestedType) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  TextFormat::MergeFromString(\n      \"nested_type { \"\n      \"  name: 'Bar' \"\n      \"} \",\n      file_proto.mutable_message_type(0)->mutable_nested_type(0));\n  BuildFileWithErrors(file_proto.DebugString(), kMapEntryErrorMessage);\n}\n\nTEST_F(ValidationErrorTest, MapEntryEnumTypes) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  TextFormat::MergeFromString(\n      \"enum_type { \"\n      \"  name: 'BarEnum' \"\n      \"  value { name: 'BAR_BAR' number:0 } \"\n      \"} \",\n      file_proto.mutable_message_type(0)->mutable_nested_type(0));\n  BuildFileWithErrors(file_proto.DebugString(), kMapEntryErrorMessage);\n}\n\nTEST_F(ValidationErrorTest, MapEntryExtraField) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  TextFormat::MergeFromString(\n      \"field { \"\n      \"  name: 'other_field' \"\n      \"  label: LABEL_OPTIONAL \"\n      \"  type: TYPE_INT32 \"\n      \"  number: 3 \"\n      \"} \",\n      file_proto.mutable_message_type(0)->mutable_nested_type(0));\n  BuildFileWithErrors(file_proto.DebugString(), kMapEntryErrorMessage);\n}\n\nTEST_F(ValidationErrorTest, MapEntryMessageName) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  file_proto.mutable_message_type(0)->mutable_nested_type(0)->set_name(\n      \"OtherMapEntry\");\n  file_proto.mutable_message_type(0)->mutable_field(0)->set_type_name(\n      \"OtherMapEntry\");\n  BuildFileWithErrors(file_proto.DebugString(), kMapEntryErrorMessage);\n}\n\nTEST_F(ValidationErrorTest, MapEntryNoneRepeatedMapEntry) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  file_proto.mutable_message_type(0)->mutable_field(0)->set_label(\n      FieldDescriptorProto::LABEL_OPTIONAL);\n  BuildFileWithErrors(file_proto.DebugString(), kMapEntryErrorMessage);\n}\n\nTEST_F(ValidationErrorTest, MapEntryDifferentContainingType) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  // Move the nested MapEntry message into the top level, which should not pass\n  // the validation.\n  file_proto.mutable_message_type()->AddAllocated(\n      file_proto.mutable_message_type(0)->mutable_nested_type()->ReleaseLast());\n  BuildFileWithErrors(file_proto.DebugString(), kMapEntryErrorMessage);\n}\n\nTEST_F(ValidationErrorTest, MapEntryKeyName) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  FieldDescriptorProto* key = file_proto.mutable_message_type(0)\n      ->mutable_nested_type(0)\n      ->mutable_field(0);\n  key->set_name(\"Key\");\n  BuildFileWithErrors(file_proto.DebugString(), kMapEntryErrorMessage);\n}\n\nTEST_F(ValidationErrorTest, MapEntryKeyLabel) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  FieldDescriptorProto* key = file_proto.mutable_message_type(0)\n      ->mutable_nested_type(0)\n      ->mutable_field(0);\n  key->set_label(FieldDescriptorProto::LABEL_REQUIRED);\n  BuildFileWithErrors(file_proto.DebugString(), kMapEntryErrorMessage);\n}\n\nTEST_F(ValidationErrorTest, MapEntryKeyNumber) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  FieldDescriptorProto* key = file_proto.mutable_message_type(0)\n      ->mutable_nested_type(0)\n      ->mutable_field(0);\n  key->set_number(3);\n  BuildFileWithErrors(file_proto.DebugString(), kMapEntryErrorMessage);\n}\n\nTEST_F(ValidationErrorTest, MapEntryValueName) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  FieldDescriptorProto* value = file_proto.mutable_message_type(0)\n      ->mutable_nested_type(0)\n      ->mutable_field(1);\n  value->set_name(\"Value\");\n  BuildFileWithErrors(file_proto.DebugString(), kMapEntryErrorMessage);\n}\n\nTEST_F(ValidationErrorTest, MapEntryValueLabel) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  FieldDescriptorProto* value = file_proto.mutable_message_type(0)\n      ->mutable_nested_type(0)\n      ->mutable_field(1);\n  value->set_label(FieldDescriptorProto::LABEL_REQUIRED);\n  BuildFileWithErrors(file_proto.DebugString(), kMapEntryErrorMessage);\n}\n\nTEST_F(ValidationErrorTest, MapEntryValueNumber) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  FieldDescriptorProto* value = file_proto.mutable_message_type(0)\n      ->mutable_nested_type(0)\n      ->mutable_field(1);\n  value->set_number(3);\n  BuildFileWithErrors(file_proto.DebugString(), kMapEntryErrorMessage);\n}\n\nTEST_F(ValidationErrorTest, MapEntryKeyTypeFloat) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  FieldDescriptorProto* key = file_proto.mutable_message_type(0)\n      ->mutable_nested_type(0)\n      ->mutable_field(0);\n  key->set_type(FieldDescriptorProto::TYPE_FLOAT);\n  BuildFileWithErrors(file_proto.DebugString(), kMapEntryKeyTypeErrorMessage);\n}\n\nTEST_F(ValidationErrorTest, MapEntryKeyTypeDouble) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  FieldDescriptorProto* key = file_proto.mutable_message_type(0)\n      ->mutable_nested_type(0)\n      ->mutable_field(0);\n  key->set_type(FieldDescriptorProto::TYPE_DOUBLE);\n  BuildFileWithErrors(file_proto.DebugString(), kMapEntryKeyTypeErrorMessage);\n}\n\nTEST_F(ValidationErrorTest, MapEntryKeyTypeBytes) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  FieldDescriptorProto* key = file_proto.mutable_message_type(0)\n      ->mutable_nested_type(0)\n      ->mutable_field(0);\n  key->set_type(FieldDescriptorProto::TYPE_BYTES);\n  BuildFileWithErrors(file_proto.DebugString(), kMapEntryKeyTypeErrorMessage);\n}\n\nTEST_F(ValidationErrorTest, MapEntryKeyTypeEnum) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  FieldDescriptorProto* key = file_proto.mutable_message_type(0)\n      ->mutable_nested_type(0)\n      ->mutable_field(0);\n  key->clear_type();\n  key->set_type_name(\"BarEnum\");\n  EnumDescriptorProto* enum_proto = file_proto.add_enum_type();\n  enum_proto->set_name(\"BarEnum\");\n  EnumValueDescriptorProto* enum_value_proto = enum_proto->add_value();\n  enum_value_proto->set_name(\"BAR_VALUE0\");\n  enum_value_proto->set_number(0);\n  BuildFileWithErrors(file_proto.DebugString(),\n                      \"foo.proto: Foo.foo_map: TYPE: Key in map fields cannot \"\n                      \"be enum types.\\n\");\n  // Enum keys are not allowed in proto3 as well.\n  // Get rid of extensions for proto3 to make it proto3 compatible.\n  file_proto.mutable_message_type()->RemoveLast();\n  file_proto.set_syntax(\"proto3\");\n  BuildFileWithErrors(file_proto.DebugString(),\n                      \"foo.proto: Foo.foo_map: TYPE: Key in map fields cannot \"\n                      \"be enum types.\\n\");\n}\n\n\nTEST_F(ValidationErrorTest, MapEntryKeyTypeMessage) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  FieldDescriptorProto* key = file_proto.mutable_message_type(0)\n      ->mutable_nested_type(0)\n      ->mutable_field(0);\n  key->clear_type();\n  key->set_type_name(\".Bar\");\n  BuildFileWithErrors(file_proto.DebugString(), kMapEntryKeyTypeErrorMessage);\n}\n\nTEST_F(ValidationErrorTest, MapEntryConflictsWithField) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  TextFormat::MergeFromString(\n      \"field { \"\n      \"  name: 'FooMapEntry' \"\n      \"  type: TYPE_INT32 \"\n      \"  label: LABEL_OPTIONAL \"\n      \"  number: 100 \"\n      \"}\",\n      file_proto.mutable_message_type(0));\n  BuildFileWithErrors(\n      file_proto.DebugString(),\n      \"foo.proto: Foo.FooMapEntry: NAME: \\\"FooMapEntry\\\" is already defined in \"\n      \"\\\"Foo\\\".\\n\"\n      \"foo.proto: Foo.foo_map: TYPE: \\\"FooMapEntry\\\" is not defined.\\n\"\n      \"foo.proto: Foo: NAME: Expanded map entry type FooMapEntry conflicts \"\n      \"with an existing field.\\n\");\n}\n\nTEST_F(ValidationErrorTest, MapEntryConflictsWithMessage) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  TextFormat::MergeFromString(\n      \"nested_type { \"\n      \"  name: 'FooMapEntry' \"\n      \"}\",\n      file_proto.mutable_message_type(0));\n  BuildFileWithErrors(\n      file_proto.DebugString(),\n      \"foo.proto: Foo.FooMapEntry: NAME: \\\"FooMapEntry\\\" is already defined in \"\n      \"\\\"Foo\\\".\\n\"\n      \"foo.proto: Foo: NAME: Expanded map entry type FooMapEntry conflicts \"\n      \"with an existing nested message type.\\n\");\n}\n\nTEST_F(ValidationErrorTest, MapEntryConflictsWithEnum) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  TextFormat::MergeFromString(\n      \"enum_type { \"\n      \"  name: 'FooMapEntry' \"\n      \"  value { name: 'ENTRY_FOO' number: 0 }\"\n      \"}\",\n      file_proto.mutable_message_type(0));\n  BuildFileWithErrors(\n      file_proto.DebugString(),\n      \"foo.proto: Foo.FooMapEntry: NAME: \\\"FooMapEntry\\\" is already defined in \"\n      \"\\\"Foo\\\".\\n\"\n      \"foo.proto: Foo: NAME: Expanded map entry type FooMapEntry conflicts \"\n      \"with an existing enum type.\\n\");\n}\n\nTEST_F(ValidationErrorTest, MapEntryConflictsWithOneof) {\n  FileDescriptorProto file_proto;\n  FillValidMapEntry(&file_proto);\n  TextFormat::MergeFromString(\n      \"oneof_decl { \"\n      \"  name: 'FooMapEntry' \"\n      \"}\"\n      \"field { \"\n      \"  name: 'int_field' \"\n      \"  type: TYPE_INT32 \"\n      \"  label: LABEL_OPTIONAL \"\n      \"  oneof_index: 0 \"\n      \"  number: 100 \"\n      \"} \",\n      file_proto.mutable_message_type(0));\n  BuildFileWithErrors(\n      file_proto.DebugString(),\n      \"foo.proto: Foo.FooMapEntry: NAME: \\\"FooMapEntry\\\" is already defined in \"\n      \"\\\"Foo\\\".\\n\"\n      \"foo.proto: Foo.foo_map: TYPE: \\\"FooMapEntry\\\" is not defined.\\n\"\n      \"foo.proto: Foo: NAME: Expanded map entry type FooMapEntry conflicts \"\n      \"with an existing oneof type.\\n\");\n}\n\nTEST_F(ValidationErrorTest, MapEntryUsesNoneZeroEnumDefaultValue) {\n  BuildFileWithErrors(\n    \"name: \\\"foo.proto\\\" \"\n    \"enum_type {\"\n    \"  name: \\\"Bar\\\"\"\n    \"  value { name:\\\"ENUM_A\\\" number:1 }\"\n    \"  value { name:\\\"ENUM_B\\\" number:2 }\"\n    \"}\"\n    \"message_type {\"\n    \"  name: 'Foo' \"\n    \"  field { \"\n    \"    name: 'foo_map' number: 1 label:LABEL_REPEATED \"\n    \"    type_name: 'FooMapEntry' \"\n    \"  } \"\n    \"  nested_type { \"\n    \"    name: 'FooMapEntry' \"\n    \"    options {  map_entry: true } \"\n    \"    field { \"\n    \"      name: 'key' number: 1 type:TYPE_INT32 label:LABEL_OPTIONAL \"\n    \"    } \"\n    \"    field { \"\n    \"      name: 'value' number: 2 type_name:\\\"Bar\\\" label:LABEL_OPTIONAL \"\n    \"    } \"\n    \"  } \"\n    \"}\",\n    \"foo.proto: Foo.foo_map: \"\n    \"TYPE: Enum value in map must define 0 as the first value.\\n\");\n}\n\nTEST_F(ValidationErrorTest, Proto3RequiredFields) {\n  BuildFileWithErrors(\n      \"name: 'foo.proto' \"\n      \"syntax: 'proto3' \"\n      \"message_type { \"\n      \"  name: 'Foo' \"\n      \"  field { name:'foo' number:1 label:LABEL_REQUIRED type:TYPE_INT32 } \"\n      \"}\",\n      \"foo.proto: Foo.foo: OTHER: Required fields are not allowed in \"\n      \"proto3.\\n\");\n\n  // applied to nested types as well.\n  BuildFileWithErrors(\n      \"name: 'foo.proto' \"\n      \"syntax: 'proto3' \"\n      \"message_type { \"\n      \"  name: 'Foo' \"\n      \"  nested_type { \"\n      \"    name : 'Bar' \"\n      \"    field { name:'bar' number:1 label:LABEL_REQUIRED type:TYPE_INT32 } \"\n      \"  } \"\n      \"}\",\n      \"foo.proto: Foo.Bar.bar: OTHER: Required fields are not allowed in \"\n      \"proto3.\\n\");\n\n  // optional and repeated fields are OK.\n  BuildFile(\n      \"name: 'foo.proto' \"\n      \"syntax: 'proto3' \"\n      \"message_type { \"\n      \"  name: 'Foo' \"\n      \"  field { name:'foo' number:1 label:LABEL_OPTIONAL type:TYPE_INT32 } \"\n      \"  field { name:'bar' number:2 label:LABEL_REPEATED type:TYPE_INT32 } \"\n      \"}\");\n}\n\nTEST_F(ValidationErrorTest, ValidateProto3DefaultValue) {\n  BuildFileWithErrors(\n      \"name: 'foo.proto' \"\n      \"syntax: 'proto3' \"\n      \"message_type { \"\n      \"  name: 'Foo' \"\n      \"  field { name:'foo' number:1 label:LABEL_OPTIONAL type:TYPE_INT32 \"\n      \"          default_value: '1' }\"\n      \"}\",\n      \"foo.proto: Foo.foo: OTHER: Explicit default values are not allowed in \"\n      \"proto3.\\n\");\n\n  BuildFileWithErrors(\n      \"name: 'foo.proto' \"\n      \"syntax: 'proto3' \"\n      \"message_type { \"\n      \"  name: 'Foo' \"\n      \"  nested_type { \"\n      \"    name : 'Bar' \"\n      \"    field { name:'bar' number:1 label:LABEL_OPTIONAL type:TYPE_INT32 \"\n      \"            default_value: '1' }\"\n      \"  } \"\n      \"}\",\n      \"foo.proto: Foo.Bar.bar: OTHER: Explicit default values are not allowed \"\n      \"in proto3.\\n\");\n}\n\nTEST_F(ValidationErrorTest, ValidateProto3ExtensionRange) {\n  BuildFileWithErrors(\n      \"name: 'foo.proto' \"\n      \"syntax: 'proto3' \"\n      \"message_type { \"\n      \"  name: 'Foo' \"\n      \"  field { name:'foo' number:1 label:LABEL_OPTIONAL type:TYPE_INT32 } \"\n      \"  extension_range { start:10 end:100 } \"\n      \"}\",\n      \"foo.proto: Foo: OTHER: Extension ranges are not allowed in \"\n      \"proto3.\\n\");\n\n  BuildFileWithErrors(\n      \"name: 'foo.proto' \"\n      \"syntax: 'proto3' \"\n      \"message_type { \"\n      \"  name: 'Foo' \"\n      \"  nested_type { \"\n      \"    name : 'Bar' \"\n      \"    field { name:'bar' number:1 label:LABEL_OPTIONAL type:TYPE_INT32 } \"\n      \"    extension_range { start:10 end:100 } \"\n      \"  } \"\n      \"}\",\n      \"foo.proto: Foo.Bar: OTHER: Extension ranges are not allowed in \"\n      \"proto3.\\n\");\n}\n\nTEST_F(ValidationErrorTest, ValidateProto3MessageSetWireFormat) {\n  BuildFileWithErrors(\n      \"name: 'foo.proto' \"\n      \"syntax: 'proto3' \"\n      \"message_type { \"\n      \"  name: 'Foo' \"\n      \"  options { message_set_wire_format: true } \"\n      \"}\",\n      \"foo.proto: Foo: OTHER: MessageSet is not supported \"\n      \"in proto3.\\n\");\n}\n\nTEST_F(ValidationErrorTest, ValidateProto3Enum) {\n  BuildFileWithErrors(\n      \"name: 'foo.proto' \"\n      \"syntax: 'proto3' \"\n      \"enum_type { \"\n      \"  name: 'FooEnum' \"\n      \"  value { name: 'FOO_FOO' number:1 } \"\n      \"}\",\n      \"foo.proto: FooEnum: OTHER: The first enum value must be \"\n      \"zero in proto3.\\n\");\n\n  BuildFileWithErrors(\n      \"name: 'foo.proto' \"\n      \"syntax: 'proto3' \"\n      \"message_type { \"\n      \"  name: 'Foo' \"\n      \"  enum_type { \"\n      \"    name: 'FooEnum' \"\n      \"    value { name: 'FOO_FOO' number:1 } \"\n      \"  } \"\n      \"}\",\n      \"foo.proto: Foo.FooEnum: OTHER: The first enum value must be \"\n      \"zero in proto3.\\n\");\n\n  // valid case.\n  BuildFile(\n      \"name: 'foo.proto' \"\n      \"syntax: 'proto3' \"\n      \"enum_type { \"\n      \"  name: 'FooEnum' \"\n      \"  value { name: 'FOO_FOO' number:0 } \"\n      \"}\");\n}\n\nTEST_F(ValidationErrorTest, ValidateProto3Group) {\n  BuildFileWithErrors(\n      \"name: 'foo.proto' \"\n      \"syntax: 'proto3' \"\n      \"message_type { \"\n      \"  name: 'Foo' \"\n      \"  nested_type { \"\n      \"    name: 'FooGroup' \"\n      \"  } \"\n      \"  field { name:'foo_group' number: 1 label:LABEL_OPTIONAL \"\n      \"          type: TYPE_GROUP type_name:'FooGroup' } \"\n      \"}\",\n      \"foo.proto: Foo.foo_group: TYPE: Groups are not supported in proto3 \"\n      \"syntax.\\n\");\n}\n\n\nTEST_F(ValidationErrorTest, ValidateProto3EnumFromProto2) {\n  // Define an enum in a proto2 file.\n  BuildFile(\n      \"name: 'foo.proto' \"\n      \"package: 'foo' \"\n      \"syntax: 'proto2' \"\n      \"enum_type { \"\n      \"  name: 'FooEnum' \"\n      \"  value { name: 'DEFAULT_OPTION' number:0 } \"\n      \"}\");\n\n  // Now try to refer to it. (All tests in the fixture use the same pool, so we\n  // can refer to the enum above in this definition.)\n  BuildFileWithErrors(\n      \"name: 'bar.proto' \"\n      \"dependency: 'foo.proto' \"\n      \"syntax: 'proto3' \"\n      \"message_type { \"\n      \"  name: 'Foo' \"\n      \"    field { name:'bar' number:1 label:LABEL_OPTIONAL type:TYPE_ENUM \"\n      \"            type_name: 'foo.FooEnum' }\"\n      \"}\",\n      \"bar.proto: Foo.bar: TYPE: Enum type \\\"foo.FooEnum\\\" is not a proto3 \"\n      \"enum, but is used in \\\"Foo\\\" which is a proto3 message type.\\n\");\n}\n\nTEST_F(ValidationErrorTest, ValidateProto3Extension) {\n  // Valid for options.\n  DescriptorPool pool;\n  FileDescriptorProto file_proto;\n  // Add \"google/protobuf/descriptor.proto\".\n  FileDescriptorProto::descriptor()->file()->CopyTo(&file_proto);\n  ASSERT_TRUE(pool.BuildFile(file_proto) != NULL);\n  // Add \"foo.proto\":\n  //   import \"google/protobuf/descriptor.proto\";\n  //   extend google.protobuf.FieldOptions {\n  //     optional int32 option1 = 1000;\n  //   }\n  file_proto.Clear();\n  file_proto.set_name(\"foo.proto\");\n  file_proto.set_syntax(\"proto3\");\n  file_proto.add_dependency(\"google/protobuf/descriptor.proto\");\n  AddExtension(&file_proto, \"google.protobuf.FieldOptions\", \"option1\", 1000,\n               FieldDescriptorProto::LABEL_OPTIONAL,\n               FieldDescriptorProto::TYPE_INT32);\n  ASSERT_TRUE(pool.BuildFile(file_proto) != NULL);\n\n  // Copy and change the package of the descriptor.proto\n  BuildFile(\n      \"name: 'google.protobuf.proto' \"\n      \"syntax: 'proto2' \"\n      \"message_type { \"\n      \"  name: 'Container' extension_range { start: 1 end: 1000 } \"\n      \"}\");\n  BuildFileWithErrors(\n      \"name: 'bar.proto' \"\n      \"syntax: 'proto3' \"\n      \"dependency: 'google.protobuf.proto' \"\n      \"extension { \"\n      \"  name: 'bar' number: 1 label: LABEL_OPTIONAL type: TYPE_INT32 \"\n      \"  extendee: 'Container' \"\n      \"}\",\n      \"bar.proto: bar: OTHER: Extensions in proto3 are only allowed for \"\n      \"defining options.\\n\");\n}\n\n// Test that field names that may conflict in JSON is not allowed by protoc.\nTEST_F(ValidationErrorTest, ValidateProto3JsonName) {\n  // The comparison is case-insensitive.\n  BuildFileWithErrors(\n      \"name: 'foo.proto' \"\n      \"syntax: 'proto3' \"\n      \"message_type {\"\n      \"  name: 'Foo'\"\n      \"  field { name:'name' number:1 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n      \"  field { name:'Name' number:2 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n      \"}\",\n      \"foo.proto: Foo: OTHER: The JSON camel-case name of field \\\"Name\\\" \"\n      \"conflicts with field \\\"name\\\". This is not allowed in proto3.\\n\");\n  // Underscores are ignored.\n  BuildFileWithErrors(\n      \"name: 'foo.proto' \"\n      \"syntax: 'proto3' \"\n      \"message_type {\"\n      \"  name: 'Foo'\"\n      \"  field { name:'ab' number:1 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n      \"  field { name:'_a__b_' number:2 label:LABEL_OPTIONAL type:TYPE_INT32 }\"\n      \"}\",\n      \"foo.proto: Foo: OTHER: The JSON camel-case name of field \\\"_a__b_\\\" \"\n      \"conflicts with field \\\"ab\\\". This is not allowed in proto3.\\n\");\n}\n\n// ===================================================================\n// DescriptorDatabase\n\nstatic void AddToDatabase(SimpleDescriptorDatabase* database,\n                          const char* file_text) {\n  FileDescriptorProto file_proto;\n  EXPECT_TRUE(TextFormat::ParseFromString(file_text, &file_proto));\n  database->Add(file_proto);\n}\n\nclass DatabaseBackedPoolTest : public testing::Test {\n protected:\n  DatabaseBackedPoolTest() {}\n\n  SimpleDescriptorDatabase database_;\n\n  virtual void SetUp() {\n    AddToDatabase(&database_,\n      \"name: 'foo.proto' \"\n      \"message_type { name:'Foo' extension_range { start: 1 end: 100 } } \"\n      \"enum_type { name:'TestEnum' value { name:'DUMMY' number:0 } } \"\n      \"service { name:'TestService' } \");\n    AddToDatabase(&database_,\n      \"name: 'bar.proto' \"\n      \"dependency: 'foo.proto' \"\n      \"message_type { name:'Bar' } \"\n      \"extension { name:'foo_ext' extendee: '.Foo' number:5 \"\n      \"            label:LABEL_OPTIONAL type:TYPE_INT32 } \");\n    // Baz has an undeclared dependency on Foo.\n    AddToDatabase(&database_,\n      \"name: 'baz.proto' \"\n      \"message_type { \"\n      \"  name:'Baz' \"\n      \"  field { name:'foo' number:1 label:LABEL_OPTIONAL type_name:'Foo' } \"\n      \"}\");\n  }\n\n  // We can't inject a file containing errors into a DescriptorPool, so we\n  // need an actual mock DescriptorDatabase to test errors.\n  class ErrorDescriptorDatabase : public DescriptorDatabase {\n   public:\n    ErrorDescriptorDatabase() {}\n    ~ErrorDescriptorDatabase() {}\n\n    // implements DescriptorDatabase ---------------------------------\n    bool FindFileByName(const string& filename,\n                        FileDescriptorProto* output) {\n      // error.proto and error2.proto cyclically import each other.\n      if (filename == \"error.proto\") {\n        output->Clear();\n        output->set_name(\"error.proto\");\n        output->add_dependency(\"error2.proto\");\n        return true;\n      } else if (filename == \"error2.proto\") {\n        output->Clear();\n        output->set_name(\"error2.proto\");\n        output->add_dependency(\"error.proto\");\n        return true;\n      } else {\n        return false;\n      }\n    }\n    bool FindFileContainingSymbol(const string& symbol_name,\n                                  FileDescriptorProto* output) {\n      return false;\n    }\n    bool FindFileContainingExtension(const string& containing_type,\n                                     int field_number,\n                                     FileDescriptorProto* output) {\n      return false;\n    }\n  };\n\n  // A DescriptorDatabase that counts how many times each method has been\n  // called and forwards to some other DescriptorDatabase.\n  class CallCountingDatabase : public DescriptorDatabase {\n   public:\n    CallCountingDatabase(DescriptorDatabase* wrapped_db)\n      : wrapped_db_(wrapped_db) {\n      Clear();\n    }\n    ~CallCountingDatabase() {}\n\n    DescriptorDatabase* wrapped_db_;\n\n    int call_count_;\n\n    void Clear() {\n      call_count_ = 0;\n    }\n\n    // implements DescriptorDatabase ---------------------------------\n    bool FindFileByName(const string& filename,\n                        FileDescriptorProto* output) {\n      ++call_count_;\n      return wrapped_db_->FindFileByName(filename, output);\n    }\n    bool FindFileContainingSymbol(const string& symbol_name,\n                                  FileDescriptorProto* output) {\n      ++call_count_;\n      return wrapped_db_->FindFileContainingSymbol(symbol_name, output);\n    }\n    bool FindFileContainingExtension(const string& containing_type,\n                                     int field_number,\n                                     FileDescriptorProto* output) {\n      ++call_count_;\n      return wrapped_db_->FindFileContainingExtension(\n        containing_type, field_number, output);\n    }\n  };\n\n  // A DescriptorDatabase which falsely always returns foo.proto when searching\n  // for any symbol or extension number.  This shouldn't cause the\n  // DescriptorPool to reload foo.proto if it is already loaded.\n  class FalsePositiveDatabase : public DescriptorDatabase {\n   public:\n    FalsePositiveDatabase(DescriptorDatabase* wrapped_db)\n      : wrapped_db_(wrapped_db) {}\n    ~FalsePositiveDatabase() {}\n\n    DescriptorDatabase* wrapped_db_;\n\n    // implements DescriptorDatabase ---------------------------------\n    bool FindFileByName(const string& filename,\n                        FileDescriptorProto* output) {\n      return wrapped_db_->FindFileByName(filename, output);\n    }\n    bool FindFileContainingSymbol(const string& symbol_name,\n                                  FileDescriptorProto* output) {\n      return FindFileByName(\"foo.proto\", output);\n    }\n    bool FindFileContainingExtension(const string& containing_type,\n                                     int field_number,\n                                     FileDescriptorProto* output) {\n      return FindFileByName(\"foo.proto\", output);\n    }\n  };\n};\n\nTEST_F(DatabaseBackedPoolTest, FindFileByName) {\n  DescriptorPool pool(&database_);\n\n  const FileDescriptor* foo = pool.FindFileByName(\"foo.proto\");\n  ASSERT_TRUE(foo != NULL);\n  EXPECT_EQ(\"foo.proto\", foo->name());\n  ASSERT_EQ(1, foo->message_type_count());\n  EXPECT_EQ(\"Foo\", foo->message_type(0)->name());\n\n  EXPECT_EQ(foo, pool.FindFileByName(\"foo.proto\"));\n\n  EXPECT_TRUE(pool.FindFileByName(\"no_such_file.proto\") == NULL);\n}\n\nTEST_F(DatabaseBackedPoolTest, FindDependencyBeforeDependent) {\n  DescriptorPool pool(&database_);\n\n  const FileDescriptor* foo = pool.FindFileByName(\"foo.proto\");\n  ASSERT_TRUE(foo != NULL);\n  EXPECT_EQ(\"foo.proto\", foo->name());\n  ASSERT_EQ(1, foo->message_type_count());\n  EXPECT_EQ(\"Foo\", foo->message_type(0)->name());\n\n  const FileDescriptor* bar = pool.FindFileByName(\"bar.proto\");\n  ASSERT_TRUE(bar != NULL);\n  EXPECT_EQ(\"bar.proto\", bar->name());\n  ASSERT_EQ(1, bar->message_type_count());\n  EXPECT_EQ(\"Bar\", bar->message_type(0)->name());\n\n  ASSERT_EQ(1, bar->dependency_count());\n  EXPECT_EQ(foo, bar->dependency(0));\n}\n\nTEST_F(DatabaseBackedPoolTest, FindDependentBeforeDependency) {\n  DescriptorPool pool(&database_);\n\n  const FileDescriptor* bar = pool.FindFileByName(\"bar.proto\");\n  ASSERT_TRUE(bar != NULL);\n  EXPECT_EQ(\"bar.proto\", bar->name());\n  ASSERT_EQ(1, bar->message_type_count());\n  ASSERT_EQ(\"Bar\", bar->message_type(0)->name());\n\n  const FileDescriptor* foo = pool.FindFileByName(\"foo.proto\");\n  ASSERT_TRUE(foo != NULL);\n  EXPECT_EQ(\"foo.proto\", foo->name());\n  ASSERT_EQ(1, foo->message_type_count());\n  ASSERT_EQ(\"Foo\", foo->message_type(0)->name());\n\n  ASSERT_EQ(1, bar->dependency_count());\n  EXPECT_EQ(foo, bar->dependency(0));\n}\n\nTEST_F(DatabaseBackedPoolTest, FindFileContainingSymbol) {\n  DescriptorPool pool(&database_);\n\n  const FileDescriptor* file = pool.FindFileContainingSymbol(\"Foo\");\n  ASSERT_TRUE(file != NULL);\n  EXPECT_EQ(\"foo.proto\", file->name());\n  EXPECT_EQ(file, pool.FindFileByName(\"foo.proto\"));\n\n  EXPECT_TRUE(pool.FindFileContainingSymbol(\"NoSuchSymbol\") == NULL);\n}\n\nTEST_F(DatabaseBackedPoolTest, FindMessageTypeByName) {\n  DescriptorPool pool(&database_);\n\n  const Descriptor* type = pool.FindMessageTypeByName(\"Foo\");\n  ASSERT_TRUE(type != NULL);\n  EXPECT_EQ(\"Foo\", type->name());\n  EXPECT_EQ(type->file(), pool.FindFileByName(\"foo.proto\"));\n\n  EXPECT_TRUE(pool.FindMessageTypeByName(\"NoSuchType\") == NULL);\n}\n\nTEST_F(DatabaseBackedPoolTest, FindExtensionByNumber) {\n  DescriptorPool pool(&database_);\n\n  const Descriptor* foo = pool.FindMessageTypeByName(\"Foo\");\n  ASSERT_TRUE(foo != NULL);\n\n  const FieldDescriptor* extension = pool.FindExtensionByNumber(foo, 5);\n  ASSERT_TRUE(extension != NULL);\n  EXPECT_EQ(\"foo_ext\", extension->name());\n  EXPECT_EQ(extension->file(), pool.FindFileByName(\"bar.proto\"));\n\n  EXPECT_TRUE(pool.FindExtensionByNumber(foo, 12) == NULL);\n}\n\nTEST_F(DatabaseBackedPoolTest, FindAllExtensions) {\n  DescriptorPool pool(&database_);\n\n  const Descriptor* foo = pool.FindMessageTypeByName(\"Foo\");\n\n  for (int i = 0; i < 2; ++i) {\n    // Repeat the lookup twice, to check that we get consistent\n    // results despite the fallback database lookup mutating the pool.\n    vector<const FieldDescriptor*> extensions;\n    pool.FindAllExtensions(foo, &extensions);\n    ASSERT_EQ(1, extensions.size());\n    EXPECT_EQ(5, extensions[0]->number());\n  }\n}\n\nTEST_F(DatabaseBackedPoolTest, ErrorWithoutErrorCollector) {\n  ErrorDescriptorDatabase error_database;\n  DescriptorPool pool(&error_database);\n\n  vector<string> errors;\n\n  {\n    ScopedMemoryLog log;\n    EXPECT_TRUE(pool.FindFileByName(\"error.proto\") == NULL);\n    errors = log.GetMessages(ERROR);\n  }\n\n  EXPECT_FALSE(errors.empty());\n}\n\nTEST_F(DatabaseBackedPoolTest, ErrorWithErrorCollector) {\n  ErrorDescriptorDatabase error_database;\n  MockErrorCollector error_collector;\n  DescriptorPool pool(&error_database, &error_collector);\n\n  EXPECT_TRUE(pool.FindFileByName(\"error.proto\") == NULL);\n  EXPECT_EQ(\n    \"error.proto: error.proto: OTHER: File recursively imports itself: \"\n      \"error.proto -> error2.proto -> error.proto\\n\"\n    \"error2.proto: error2.proto: OTHER: Import \\\"error.proto\\\" was not \"\n      \"found or had errors.\\n\"\n    \"error.proto: error.proto: OTHER: Import \\\"error2.proto\\\" was not \"\n      \"found or had errors.\\n\",\n    error_collector.text_);\n}\n\nTEST_F(DatabaseBackedPoolTest, UndeclaredDependencyOnUnbuiltType) {\n  // Check that we find and report undeclared dependencies on types that exist\n  // in the descriptor database but that have not not been built yet.\n  MockErrorCollector error_collector;\n  DescriptorPool pool(&database_, &error_collector);\n  EXPECT_TRUE(pool.FindMessageTypeByName(\"Baz\") == NULL);\n  EXPECT_EQ(\n    \"baz.proto: Baz.foo: TYPE: \\\"Foo\\\" seems to be defined in \\\"foo.proto\\\", \"\n    \"which is not imported by \\\"baz.proto\\\".  To use it here, please add \"\n    \"the necessary import.\\n\",\n    error_collector.text_);\n}\n\nTEST_F(DatabaseBackedPoolTest, RollbackAfterError) {\n  // Make sure that all traces of bad types are removed from the pool. This used\n  // to be b/4529436, due to the fact that a symbol resolution failure could\n  // potentially cause another file to be recursively built, which would trigger\n  // a checkpoint _past_ possibly invalid symbols.\n  // Baz is defined in the database, but the file is invalid because it is\n  // missing a necessary import.\n  DescriptorPool pool(&database_);\n  EXPECT_TRUE(pool.FindMessageTypeByName(\"Baz\") == NULL);\n  // Make sure that searching again for the file or the type fails.\n  EXPECT_TRUE(pool.FindFileByName(\"baz.proto\") == NULL);\n  EXPECT_TRUE(pool.FindMessageTypeByName(\"Baz\") == NULL);\n}\n\nTEST_F(DatabaseBackedPoolTest, UnittestProto) {\n  // Try to load all of unittest.proto from a DescriptorDatabase.  This should\n  // thoroughly test all paths through DescriptorBuilder to insure that there\n  // are no deadlocking problems when pool_->mutex_ is non-NULL.\n  const FileDescriptor* original_file =\n    protobuf_unittest::TestAllTypes::descriptor()->file();\n\n  DescriptorPoolDatabase database(*DescriptorPool::generated_pool());\n  DescriptorPool pool(&database);\n  const FileDescriptor* file_from_database =\n    pool.FindFileByName(original_file->name());\n\n  ASSERT_TRUE(file_from_database != NULL);\n\n  FileDescriptorProto original_file_proto;\n  original_file->CopyTo(&original_file_proto);\n\n  FileDescriptorProto file_from_database_proto;\n  file_from_database->CopyTo(&file_from_database_proto);\n\n  EXPECT_EQ(original_file_proto.DebugString(),\n            file_from_database_proto.DebugString());\n\n  // Also verify that CopyTo() did not omit any information.\n  EXPECT_EQ(original_file->DebugString(),\n            file_from_database->DebugString());\n}\n\nTEST_F(DatabaseBackedPoolTest, DoesntRetryDbUnnecessarily) {\n  // Searching for a child of an existing descriptor should never fall back\n  // to the DescriptorDatabase even if it isn't found, because we know all\n  // children are already loaded.\n  CallCountingDatabase call_counter(&database_);\n  DescriptorPool pool(&call_counter);\n\n  const FileDescriptor* file = pool.FindFileByName(\"foo.proto\");\n  ASSERT_TRUE(file != NULL);\n  const Descriptor* foo = pool.FindMessageTypeByName(\"Foo\");\n  ASSERT_TRUE(foo != NULL);\n  const EnumDescriptor* test_enum = pool.FindEnumTypeByName(\"TestEnum\");\n  ASSERT_TRUE(test_enum != NULL);\n  const ServiceDescriptor* test_service = pool.FindServiceByName(\"TestService\");\n  ASSERT_TRUE(test_service != NULL);\n\n  EXPECT_NE(0, call_counter.call_count_);\n  call_counter.Clear();\n\n  EXPECT_TRUE(foo->FindFieldByName(\"no_such_field\") == NULL);\n  EXPECT_TRUE(foo->FindExtensionByName(\"no_such_extension\") == NULL);\n  EXPECT_TRUE(foo->FindNestedTypeByName(\"NoSuchMessageType\") == NULL);\n  EXPECT_TRUE(foo->FindEnumTypeByName(\"NoSuchEnumType\") == NULL);\n  EXPECT_TRUE(foo->FindEnumValueByName(\"NO_SUCH_VALUE\") == NULL);\n  EXPECT_TRUE(test_enum->FindValueByName(\"NO_SUCH_VALUE\") == NULL);\n  EXPECT_TRUE(test_service->FindMethodByName(\"NoSuchMethod\") == NULL);\n\n  EXPECT_TRUE(file->FindMessageTypeByName(\"NoSuchMessageType\") == NULL);\n  EXPECT_TRUE(file->FindEnumTypeByName(\"NoSuchEnumType\") == NULL);\n  EXPECT_TRUE(file->FindEnumValueByName(\"NO_SUCH_VALUE\") == NULL);\n  EXPECT_TRUE(file->FindServiceByName(\"NO_SUCH_VALUE\") == NULL);\n  EXPECT_TRUE(file->FindExtensionByName(\"no_such_extension\") == NULL);\n\n  EXPECT_TRUE(pool.FindFileContainingSymbol(\"Foo.no.such.field\") == NULL);\n  EXPECT_TRUE(pool.FindFileContainingSymbol(\"Foo.no_such_field\") == NULL);\n  EXPECT_TRUE(pool.FindMessageTypeByName(\"Foo.NoSuchMessageType\") == NULL);\n  EXPECT_TRUE(pool.FindFieldByName(\"Foo.no_such_field\") == NULL);\n  EXPECT_TRUE(pool.FindExtensionByName(\"Foo.no_such_extension\") == NULL);\n  EXPECT_TRUE(pool.FindEnumTypeByName(\"Foo.NoSuchEnumType\") == NULL);\n  EXPECT_TRUE(pool.FindEnumValueByName(\"Foo.NO_SUCH_VALUE\") == NULL);\n  EXPECT_TRUE(pool.FindMethodByName(\"TestService.NoSuchMethod\") == NULL);\n\n  EXPECT_EQ(0, call_counter.call_count_);\n}\n\nTEST_F(DatabaseBackedPoolTest, DoesntReloadFilesUncesessarily) {\n  // If FindFileContainingSymbol() or FindFileContainingExtension() return a\n  // file that is already in the DescriptorPool, it should not attempt to\n  // reload the file.\n  FalsePositiveDatabase false_positive_database(&database_);\n  MockErrorCollector error_collector;\n  DescriptorPool pool(&false_positive_database, &error_collector);\n\n  // First make sure foo.proto is loaded.\n  const Descriptor* foo = pool.FindMessageTypeByName(\"Foo\");\n  ASSERT_TRUE(foo != NULL);\n\n  // Try inducing false positives.\n  EXPECT_TRUE(pool.FindMessageTypeByName(\"NoSuchSymbol\") == NULL);\n  EXPECT_TRUE(pool.FindExtensionByNumber(foo, 22) == NULL);\n\n  // No errors should have been reported.  (If foo.proto was incorrectly\n  // loaded multiple times, errors would have been reported.)\n  EXPECT_EQ(\"\", error_collector.text_);\n}\n\n// DescriptorDatabase that attempts to induce exponentially-bad performance\n// in DescriptorPool. For every positive N, the database contains a file\n// fileN.proto, which defines a message MessageN, which contains fields of\n// type MessageK for all K in [0,N). Message0 is not defined anywhere\n// (file0.proto exists, but is empty), so every other file and message type\n// will fail to build.\n//\n// If the DescriptorPool is not careful to memoize errors, an attempt to\n// build a descriptor for MessageN can require O(2^N) time.\nclass ExponentialErrorDatabase : public DescriptorDatabase {\n public:\n  ExponentialErrorDatabase() {}\n  ~ExponentialErrorDatabase() {}\n\n  // implements DescriptorDatabase ---------------------------------\n  bool FindFileByName(const string& filename,\n                      FileDescriptorProto* output) {\n    int file_num = -1;\n    FullMatch(filename, \"file\", \".proto\", &file_num);\n    if (file_num > -1) {\n      return PopulateFile(file_num, output);\n    } else {\n      return false;\n    }\n  }\n  bool FindFileContainingSymbol(const string& symbol_name,\n                                FileDescriptorProto* output) {\n    int file_num = -1;\n    FullMatch(symbol_name, \"Message\", \"\", &file_num);\n    if (file_num > 0) {\n      return PopulateFile(file_num, output);\n    } else {\n      return false;\n    }\n  }\n  bool FindFileContainingExtension(const string& containing_type,\n                                   int field_number,\n                                   FileDescriptorProto* output) {\n    return false;\n  }\n\n private:\n  void FullMatch(const string& name,\n                 const string& begin_with,\n                 const string& end_with,\n                 int* file_num) {\n    int begin_size = begin_with.size();\n    int end_size = end_with.size();\n    if (name.substr(0, begin_size) != begin_with ||\n        name.substr(name.size()- end_size, end_size) != end_with) {\n      return;\n    }\n    safe_strto32(name.substr(begin_size, name.size() - end_size - begin_size),\n                 file_num);\n  }\n\n  bool PopulateFile(int file_num, FileDescriptorProto* output) {\n    using strings::Substitute;\n    GOOGLE_CHECK_GE(file_num, 0);\n    output->Clear();\n    output->set_name(Substitute(\"file$0.proto\", file_num));\n    // file0.proto doesn't define Message0\n    if (file_num > 0) {\n      DescriptorProto* message = output->add_message_type();\n      message->set_name(Substitute(\"Message$0\", file_num));\n      for (int i = 0; i < file_num; ++i) {\n        output->add_dependency(Substitute(\"file$0.proto\", i));\n        FieldDescriptorProto* field = message->add_field();\n        field->set_name(Substitute(\"field$0\", i));\n        field->set_number(i);\n        field->set_label(FieldDescriptorProto::LABEL_OPTIONAL);\n        field->set_type(FieldDescriptorProto::TYPE_MESSAGE);\n        field->set_type_name(Substitute(\"Message$0\", i));\n      }\n    }\n    return true;\n  }\n};\n\nTEST_F(DatabaseBackedPoolTest, DoesntReloadKnownBadFiles) {\n  ExponentialErrorDatabase error_database;\n  DescriptorPool pool(&error_database);\n\n  GOOGLE_LOG(INFO) << \"A timeout in this test probably indicates a real bug.\";\n\n  EXPECT_TRUE(pool.FindFileByName(\"file40.proto\") == NULL);\n  EXPECT_TRUE(pool.FindMessageTypeByName(\"Message40\") == NULL);\n}\n\nTEST_F(DatabaseBackedPoolTest, DoesntFallbackOnWrongType) {\n  // If a lookup finds a symbol of the wrong type (e.g. we pass a type name\n  // to FindFieldByName()), we should fail fast, without checking the fallback\n  // database.\n  CallCountingDatabase call_counter(&database_);\n  DescriptorPool pool(&call_counter);\n\n  const FileDescriptor* file = pool.FindFileByName(\"foo.proto\");\n  ASSERT_TRUE(file != NULL);\n  const Descriptor* foo = pool.FindMessageTypeByName(\"Foo\");\n  ASSERT_TRUE(foo != NULL);\n  const EnumDescriptor* test_enum = pool.FindEnumTypeByName(\"TestEnum\");\n  ASSERT_TRUE(test_enum != NULL);\n\n  EXPECT_NE(0, call_counter.call_count_);\n  call_counter.Clear();\n\n  EXPECT_TRUE(pool.FindMessageTypeByName(\"TestEnum\") == NULL);\n  EXPECT_TRUE(pool.FindFieldByName(\"Foo\") == NULL);\n  EXPECT_TRUE(pool.FindExtensionByName(\"Foo\") == NULL);\n  EXPECT_TRUE(pool.FindEnumTypeByName(\"Foo\") == NULL);\n  EXPECT_TRUE(pool.FindEnumValueByName(\"Foo\") == NULL);\n  EXPECT_TRUE(pool.FindServiceByName(\"Foo\") == NULL);\n  EXPECT_TRUE(pool.FindMethodByName(\"Foo\") == NULL);\n\n  EXPECT_EQ(0, call_counter.call_count_);\n}\n\n// ===================================================================\n\nclass AbortingErrorCollector : public DescriptorPool::ErrorCollector {\n public:\n  AbortingErrorCollector() {}\n\n  virtual void AddError(\n      const string &filename,\n      const string &element_name,\n      const Message *message,\n      ErrorLocation location,\n      const string &error_message) {\n    GOOGLE_LOG(FATAL) << \"AddError() called unexpectedly: \" << filename << \" [\"\n               << element_name << \"]: \" << error_message;\n  }\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(AbortingErrorCollector);\n};\n\n// A source tree containing only one file.\nclass SingletonSourceTree : public compiler::SourceTree {\n public:\n  SingletonSourceTree(const string& filename, const string& contents)\n      : filename_(filename), contents_(contents) {}\n\n  virtual io::ZeroCopyInputStream* Open(const string& filename) {\n    return filename == filename_ ?\n        new io::ArrayInputStream(contents_.data(), contents_.size()) : NULL;\n  }\n\n private:\n  const string filename_;\n  const string contents_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(SingletonSourceTree);\n};\n\nconst char *const kSourceLocationTestInput =\n  \"syntax = \\\"proto2\\\";\\n\"\n  \"message A {\\n\"\n  \"  optional int32 a = 1;\\n\"\n  \"  message B {\\n\"\n  \"    required double b = 1;\\n\"\n  \"  }\\n\"\n  \"}\\n\"\n  \"enum Indecision {\\n\"\n  \"  YES   = 1;\\n\"\n  \"  NO    = 2;\\n\"\n  \"  MAYBE = 3;\\n\"\n  \"}\\n\"\n  \"service S {\\n\"\n  \"  rpc Method(A) returns (A.B);\\n\"\n  // Put an empty line here to make the source location range match.\n  \"\\n\"\n  \"}\\n\"\n  \"message MessageWithExtensions {\\n\"\n  \"  extensions 1000 to max;\\n\"\n  \"}\\n\"\n  \"extend MessageWithExtensions {\\n\"\n  \"  optional int32 int32_extension = 1001;\\n\"\n  \"}\\n\"\n  \"message C {\\n\"\n  \"  extend MessageWithExtensions {\\n\"\n  \"    optional C message_extension = 1002;\\n\"\n  \"  }\\n\"\n  \"}\\n\";\n\nclass SourceLocationTest : public testing::Test {\n public:\n  SourceLocationTest()\n      : source_tree_(\"/test/test.proto\", kSourceLocationTestInput),\n        db_(&source_tree_),\n        pool_(&db_, &collector_) {}\n\n  static string PrintSourceLocation(const SourceLocation &loc) {\n    return strings::Substitute(\"$0:$1-$2:$3\",\n                               1 + loc.start_line,\n                               1 + loc.start_column,\n                               1 + loc.end_line,\n                               1 + loc.end_column);\n  }\n\n private:\n  AbortingErrorCollector collector_;\n  SingletonSourceTree source_tree_;\n  compiler::SourceTreeDescriptorDatabase db_;\n\n protected:\n  DescriptorPool pool_;\n};\n\n// TODO(adonovan): implement support for option fields and for\n// subparts of declarations.\n\nTEST_F(SourceLocationTest, GetSourceLocation) {\n  SourceLocation loc;\n\n  const FileDescriptor *file_desc =\n      GOOGLE_CHECK_NOTNULL(pool_.FindFileByName(\"/test/test.proto\"));\n\n  const Descriptor *a_desc = file_desc->FindMessageTypeByName(\"A\");\n  EXPECT_TRUE(a_desc->GetSourceLocation(&loc));\n  EXPECT_EQ(\"2:1-7:2\", PrintSourceLocation(loc));\n\n  const Descriptor *a_b_desc = a_desc->FindNestedTypeByName(\"B\");\n  EXPECT_TRUE(a_b_desc->GetSourceLocation(&loc));\n  EXPECT_EQ(\"4:3-6:4\", PrintSourceLocation(loc));\n\n  const EnumDescriptor *e_desc = file_desc->FindEnumTypeByName(\"Indecision\");\n  EXPECT_TRUE(e_desc->GetSourceLocation(&loc));\n  EXPECT_EQ(\"8:1-12:2\", PrintSourceLocation(loc));\n\n  const EnumValueDescriptor *yes_desc = e_desc->FindValueByName(\"YES\");\n  EXPECT_TRUE(yes_desc->GetSourceLocation(&loc));\n  EXPECT_EQ(\"9:3-9:13\", PrintSourceLocation(loc));\n\n  const ServiceDescriptor *s_desc = file_desc->FindServiceByName(\"S\");\n  EXPECT_TRUE(s_desc->GetSourceLocation(&loc));\n  EXPECT_EQ(\"13:1-16:2\", PrintSourceLocation(loc));\n\n  const MethodDescriptor *m_desc = s_desc->FindMethodByName(\"Method\");\n  EXPECT_TRUE(m_desc->GetSourceLocation(&loc));\n  EXPECT_EQ(\"14:3-14:31\", PrintSourceLocation(loc));\n\n}\n\nTEST_F(SourceLocationTest, ExtensionSourceLocation) {\n  SourceLocation loc;\n\n  const FileDescriptor *file_desc =\n      GOOGLE_CHECK_NOTNULL(pool_.FindFileByName(\"/test/test.proto\"));\n\n  const FieldDescriptor *int32_extension_desc =\n      file_desc->FindExtensionByName(\"int32_extension\");\n  EXPECT_TRUE(int32_extension_desc->GetSourceLocation(&loc));\n  EXPECT_EQ(\"21:3-21:41\", PrintSourceLocation(loc));\n\n  const Descriptor *c_desc = file_desc->FindMessageTypeByName(\"C\");\n  EXPECT_TRUE(c_desc->GetSourceLocation(&loc));\n  EXPECT_EQ(\"23:1-27:2\", PrintSourceLocation(loc));\n\n  const FieldDescriptor *message_extension_desc =\n      c_desc->FindExtensionByName(\"message_extension\");\n  EXPECT_TRUE(message_extension_desc->GetSourceLocation(&loc));\n  EXPECT_EQ(\"25:5-25:41\", PrintSourceLocation(loc));\n}\n\n// Missing SourceCodeInfo doesn't cause crash:\nTEST_F(SourceLocationTest, GetSourceLocation_MissingSourceCodeInfo) {\n  SourceLocation loc;\n\n  const FileDescriptor *file_desc =\n      GOOGLE_CHECK_NOTNULL(pool_.FindFileByName(\"/test/test.proto\"));\n\n  FileDescriptorProto proto;\n  file_desc->CopyTo(&proto);  // Note, this discards the SourceCodeInfo.\n  EXPECT_FALSE(proto.has_source_code_info());\n\n  DescriptorPool bad1_pool(&pool_);\n  const FileDescriptor* bad1_file_desc =\n      GOOGLE_CHECK_NOTNULL(bad1_pool.BuildFile(proto));\n  const Descriptor *bad1_a_desc = bad1_file_desc->FindMessageTypeByName(\"A\");\n  EXPECT_FALSE(bad1_a_desc->GetSourceLocation(&loc));\n}\n\n// Corrupt SourceCodeInfo doesn't cause crash:\nTEST_F(SourceLocationTest, GetSourceLocation_BogusSourceCodeInfo) {\n  SourceLocation loc;\n\n  const FileDescriptor *file_desc =\n      GOOGLE_CHECK_NOTNULL(pool_.FindFileByName(\"/test/test.proto\"));\n\n  FileDescriptorProto proto;\n  file_desc->CopyTo(&proto);  // Note, this discards the SourceCodeInfo.\n  EXPECT_FALSE(proto.has_source_code_info());\n  SourceCodeInfo_Location *loc_msg =\n      proto.mutable_source_code_info()->add_location();\n  loc_msg->add_path(1);\n  loc_msg->add_path(2);\n  loc_msg->add_path(3);\n  loc_msg->add_span(4);\n  loc_msg->add_span(5);\n  loc_msg->add_span(6);\n\n  DescriptorPool bad2_pool(&pool_);\n  const FileDescriptor* bad2_file_desc =\n      GOOGLE_CHECK_NOTNULL(bad2_pool.BuildFile(proto));\n  const Descriptor *bad2_a_desc = bad2_file_desc->FindMessageTypeByName(\"A\");\n  EXPECT_FALSE(bad2_a_desc->GetSourceLocation(&loc));\n}\n\n// ===================================================================\n\nconst char* const kCopySourceCodeInfoToTestInput =\n  \"syntax = \\\"proto2\\\";\\n\"\n  \"message Foo {}\\n\";\n\n// Required since source code information is not preserved by\n// FileDescriptorTest.\nclass CopySourceCodeInfoToTest : public testing::Test {\n public:\n  CopySourceCodeInfoToTest()\n      : source_tree_(\"/test/test.proto\", kCopySourceCodeInfoToTestInput),\n        db_(&source_tree_),\n        pool_(&db_, &collector_) {}\n\n private:\n  AbortingErrorCollector collector_;\n  SingletonSourceTree source_tree_;\n  compiler::SourceTreeDescriptorDatabase db_;\n\n protected:\n  DescriptorPool pool_;\n};\n\nTEST_F(CopySourceCodeInfoToTest, CopyTo_DoesNotCopySourceCodeInfo) {\n  const FileDescriptor* file_desc =\n      GOOGLE_CHECK_NOTNULL(pool_.FindFileByName(\"/test/test.proto\"));\n  FileDescriptorProto file_desc_proto;\n  ASSERT_FALSE(file_desc_proto.has_source_code_info());\n\n  file_desc->CopyTo(&file_desc_proto);\n  EXPECT_FALSE(file_desc_proto.has_source_code_info());\n}\n\nTEST_F(CopySourceCodeInfoToTest, CopySourceCodeInfoTo) {\n  const FileDescriptor* file_desc =\n      GOOGLE_CHECK_NOTNULL(pool_.FindFileByName(\"/test/test.proto\"));\n  FileDescriptorProto file_desc_proto;\n  ASSERT_FALSE(file_desc_proto.has_source_code_info());\n\n  file_desc->CopySourceCodeInfoTo(&file_desc_proto);\n  const SourceCodeInfo& info = file_desc_proto.source_code_info();\n  ASSERT_EQ(4, info.location_size());\n  // Get the Foo message location\n  const SourceCodeInfo_Location& foo_location = info.location(2);\n  ASSERT_EQ(2, foo_location.path_size());\n  EXPECT_EQ(FileDescriptorProto::kMessageTypeFieldNumber, foo_location.path(0));\n  EXPECT_EQ(0, foo_location.path(1));      // Foo is the first message defined\n  ASSERT_EQ(3, foo_location.span_size());  // Foo spans one line\n  EXPECT_EQ(1, foo_location.span(0));      // Foo is declared on line 1\n  EXPECT_EQ(0, foo_location.span(1));      // Foo starts at column 0\n  EXPECT_EQ(14, foo_location.span(2));     // Foo ends on column 14\n}\n\n// ===================================================================\n\n\n}  // namespace descriptor_unittest\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/drop_unknown_fields_test.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#include <google/protobuf/unittest_drop_unknown_fields.pb.h>\n#include <google/protobuf/dynamic_message.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nusing unittest_drop_unknown_fields::Foo;\nusing unittest_drop_unknown_fields::FooWithExtraFields;\n\nnamespace protobuf {\n\nTEST(DropUnknownFieldsTest, GeneratedMessage) {\n  FooWithExtraFields foo_with_extra_fields;\n  foo_with_extra_fields.set_int32_value(1);\n  foo_with_extra_fields.set_enum_value(FooWithExtraFields::QUX);\n  foo_with_extra_fields.set_extra_int32_value(2);\n\n  Foo foo;\n  ASSERT_TRUE(foo.ParseFromString(foo_with_extra_fields.SerializeAsString()));\n  EXPECT_EQ(1, foo.int32_value());\n  EXPECT_EQ(static_cast<int>(FooWithExtraFields::QUX),\n            static_cast<int>(foo.enum_value()));\n  // We don't generate unknown field accessors but the UnknownFieldSet is\n  // still exposed through reflection API.\n  EXPECT_TRUE(foo.GetReflection()->GetUnknownFields(foo).empty());\n\n  ASSERT_TRUE(foo_with_extra_fields.ParseFromString(foo.SerializeAsString()));\n  EXPECT_EQ(1, foo_with_extra_fields.int32_value());\n  EXPECT_EQ(FooWithExtraFields::QUX, foo_with_extra_fields.enum_value());\n  // The \"extra_int32_value\" field should be lost.\n  EXPECT_EQ(0, foo_with_extra_fields.extra_int32_value());\n}\n\nTEST(DropUnknownFieldsTest, DynamicMessage) {\n  FooWithExtraFields foo_with_extra_fields;\n  foo_with_extra_fields.set_int32_value(1);\n  foo_with_extra_fields.set_enum_value(FooWithExtraFields::QUX);\n  foo_with_extra_fields.set_extra_int32_value(2);\n\n  google::protobuf::DynamicMessageFactory factory;\n  google::protobuf::scoped_ptr<google::protobuf::Message> foo(\n      factory.GetPrototype(Foo::descriptor())->New());\n  ASSERT_TRUE(foo->ParseFromString(foo_with_extra_fields.SerializeAsString()));\n  EXPECT_TRUE(foo->GetReflection()->GetUnknownFields(*foo).empty());\n\n  ASSERT_TRUE(foo_with_extra_fields.ParseFromString(foo->SerializeAsString()));\n  EXPECT_EQ(1, foo_with_extra_fields.int32_value());\n  EXPECT_EQ(FooWithExtraFields::QUX, foo_with_extra_fields.enum_value());\n  // The \"extra_int32_value\" field should be lost.\n  EXPECT_EQ(0, foo_with_extra_fields.extra_int32_value());\n}\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/duration.pb.cc",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/duration.proto\n\n#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION\n#include <google/protobuf/duration.pb.h>\n\n#include <algorithm>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/port.h>\n#include <google/protobuf/stubs/once.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/generated_message_reflection.h>\n#include <google/protobuf/reflection_ops.h>\n#include <google/protobuf/wire_format.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\n\nnamespace {\n\nconst ::google::protobuf::Descriptor* Duration_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  Duration_reflection_ = NULL;\n\n}  // namespace\n\n\nvoid protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto() {\n  protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto();\n  const ::google::protobuf::FileDescriptor* file =\n    ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(\n      \"google/protobuf/duration.proto\");\n  GOOGLE_CHECK(file != NULL);\n  Duration_descriptor_ = file->message_type(0);\n  static const int Duration_offsets_[2] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, seconds_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, nanos_),\n  };\n  Duration_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      Duration_descriptor_,\n      Duration::default_instance_,\n      Duration_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(Duration),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Duration, _is_default_instance_));\n}\n\nnamespace {\n\nGOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);\ninline void protobuf_AssignDescriptorsOnce() {\n  ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,\n                 &protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto);\n}\n\nvoid protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_RegisterTypes(const ::std::string&) {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      Duration_descriptor_, &Duration::default_instance());\n}\n\n}  // namespace\n\nvoid protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto() {\n  delete Duration::default_instance_;\n  delete Duration_reflection_;\n}\n\nvoid protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto() {\n  static bool already_here = false;\n  if (already_here) return;\n  already_here = true;\n  GOOGLE_PROTOBUF_VERIFY_VERSION;\n\n  ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(\n    \"\\n\\036google/protobuf/duration.proto\\022\\017google\"\n    \".protobuf\\\"*\\n\\010Duration\\022\\017\\n\\007seconds\\030\\001 \\001(\\003\\022\\r\"\n    \"\\n\\005nanos\\030\\002 \\001(\\005B|\\n\\023com.google.protobufB\\rDu\"\n    \"rationProtoP\\001Z*github.com/golang/protobu\"\n    \"f/ptypes/duration\\240\\001\\001\\242\\002\\003GPB\\252\\002\\036Google.Prot\"\n    \"obuf.WellKnownTypesb\\006proto3\", 227);\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(\n    \"google/protobuf/duration.proto\", &protobuf_RegisterTypes);\n  Duration::default_instance_ = new Duration();\n  Duration::default_instance_->InitAsDefaultInstance();\n  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto);\n}\n\n// Force AddDescriptors() to be called at static initialization time.\nstruct StaticDescriptorInitializer_google_2fprotobuf_2fduration_2eproto {\n  StaticDescriptorInitializer_google_2fprotobuf_2fduration_2eproto() {\n    protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto();\n  }\n} static_descriptor_initializer_google_2fprotobuf_2fduration_2eproto_;\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int Duration::kSecondsFieldNumber;\nconst int Duration::kNanosFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nDuration::Duration()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.Duration)\n}\n\nvoid Duration::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n}\n\nDuration::Duration(const Duration& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.Duration)\n}\n\nvoid Duration::SharedCtor() {\n    _is_default_instance_ = false;\n  _cached_size_ = 0;\n  seconds_ = GOOGLE_LONGLONG(0);\n  nanos_ = 0;\n}\n\nDuration::~Duration() {\n  // @@protoc_insertion_point(destructor:google.protobuf.Duration)\n  SharedDtor();\n}\n\nvoid Duration::SharedDtor() {\n  if (this != default_instance_) {\n  }\n}\n\nvoid Duration::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* Duration::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return Duration_descriptor_;\n}\n\nconst Duration& Duration::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto();\n  return *default_instance_;\n}\n\nDuration* Duration::default_instance_ = NULL;\n\nDuration* Duration::New(::google::protobuf::Arena* arena) const {\n  Duration* n = new Duration;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid Duration::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.Duration)\n#if defined(__clang__)\n#define ZR_HELPER_(f) \\\n  _Pragma(\"clang diagnostic push\") \\\n  _Pragma(\"clang diagnostic ignored \\\"-Winvalid-offsetof\\\"\") \\\n  __builtin_offsetof(Duration, f) \\\n  _Pragma(\"clang diagnostic pop\")\n#else\n#define ZR_HELPER_(f) reinterpret_cast<char*>(\\\n  &reinterpret_cast<Duration*>(16)->f)\n#endif\n\n#define ZR_(first, last) do {\\\n  ::memset(&first, 0,\\\n           ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\\\n} while (0)\n\n  ZR_(seconds_, nanos_);\n\n#undef ZR_HELPER_\n#undef ZR_\n\n}\n\nbool Duration::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.Duration)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional int64 seconds = 1;\n      case 1: {\n        if (tag == 8) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(\n                 input, &seconds_)));\n\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(16)) goto parse_nanos;\n        break;\n      }\n\n      // optional int32 nanos = 2;\n      case 2: {\n        if (tag == 16) {\n         parse_nanos:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 input, &nanos_)));\n\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.Duration)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.Duration)\n  return false;\n#undef DO_\n}\n\nvoid Duration::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.Duration)\n  // optional int64 seconds = 1;\n  if (this->seconds() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt64(1, this->seconds(), output);\n  }\n\n  // optional int32 nanos = 2;\n  if (this->nanos() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->nanos(), output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.Duration)\n}\n\n::google::protobuf::uint8* Duration::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Duration)\n  // optional int64 seconds = 1;\n  if (this->seconds() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(1, this->seconds(), target);\n  }\n\n  // optional int32 nanos = 2;\n  if (this->nanos() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->nanos(), target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Duration)\n  return target;\n}\n\nint Duration::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Duration)\n  int total_size = 0;\n\n  // optional int64 seconds = 1;\n  if (this->seconds() != 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::Int64Size(\n        this->seconds());\n  }\n\n  // optional int32 nanos = 2;\n  if (this->nanos() != 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::Int32Size(\n        this->nanos());\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid Duration::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Duration)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const Duration* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const Duration>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.Duration)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Duration)\n    MergeFrom(*source);\n  }\n}\n\nvoid Duration::MergeFrom(const Duration& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Duration)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from.seconds() != 0) {\n    set_seconds(from.seconds());\n  }\n  if (from.nanos() != 0) {\n    set_nanos(from.nanos());\n  }\n}\n\nvoid Duration::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.Duration)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid Duration::CopyFrom(const Duration& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Duration)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool Duration::IsInitialized() const {\n\n  return true;\n}\n\nvoid Duration::Swap(Duration* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid Duration::InternalSwap(Duration* other) {\n  std::swap(seconds_, other->seconds_);\n  std::swap(nanos_, other->nanos_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata Duration::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = Duration_descriptor_;\n  metadata.reflection = Duration_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// Duration\n\n// optional int64 seconds = 1;\nvoid Duration::clear_seconds() {\n  seconds_ = GOOGLE_LONGLONG(0);\n}\n ::google::protobuf::int64 Duration::seconds() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Duration.seconds)\n  return seconds_;\n}\n void Duration::set_seconds(::google::protobuf::int64 value) {\n  \n  seconds_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Duration.seconds)\n}\n\n// optional int32 nanos = 2;\nvoid Duration::clear_nanos() {\n  nanos_ = 0;\n}\n ::google::protobuf::int32 Duration::nanos() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Duration.nanos)\n  return nanos_;\n}\n void Duration::set_nanos(::google::protobuf::int32 value) {\n  \n  nanos_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Duration.nanos)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace protobuf\n}  // namespace google\n\n// @@protoc_insertion_point(global_scope)\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/duration.pb.h",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/duration.proto\n\n#ifndef PROTOBUF_google_2fprotobuf_2fduration_2eproto__INCLUDED\n#define PROTOBUF_google_2fprotobuf_2fduration_2eproto__INCLUDED\n\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n\n#if GOOGLE_PROTOBUF_VERSION < 3000000\n#error This file was generated by a newer version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please update\n#error your headers.\n#endif\n#if 3000000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION\n#error This file was generated by an older version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please\n#error regenerate this file with a newer version of protoc.\n#endif\n\n#include <google/protobuf/arena.h>\n#include <google/protobuf/arenastring.h>\n#include <google/protobuf/generated_message_util.h>\n#include <google/protobuf/metadata.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/extension_set.h>\n#include <google/protobuf/unknown_field_set.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\n\n// Internal implementation detail -- do not call these.\nvoid LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto();\nvoid protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto();\nvoid protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto();\n\nclass Duration;\n\n// ===================================================================\n\nclass LIBPROTOBUF_EXPORT Duration : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Duration) */ {\n public:\n  Duration();\n  virtual ~Duration();\n\n  Duration(const Duration& from);\n\n  inline Duration& operator=(const Duration& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const Duration& default_instance();\n\n  void Swap(Duration* other);\n\n  // implements Message ----------------------------------------------\n\n  inline Duration* New() const { return New(NULL); }\n\n  Duration* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const Duration& from);\n  void MergeFrom(const Duration& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(Duration* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional int64 seconds = 1;\n  void clear_seconds();\n  static const int kSecondsFieldNumber = 1;\n  ::google::protobuf::int64 seconds() const;\n  void set_seconds(::google::protobuf::int64 value);\n\n  // optional int32 nanos = 2;\n  void clear_nanos();\n  static const int kNanosFieldNumber = 2;\n  ::google::protobuf::int32 nanos() const;\n  void set_nanos(::google::protobuf::int32 value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.Duration)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  bool _is_default_instance_;\n  ::google::protobuf::int64 seconds_;\n  ::google::protobuf::int32 nanos_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fduration_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fduration_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fduration_2eproto();\n\n  void InitAsDefaultInstance();\n  static Duration* default_instance_;\n};\n// ===================================================================\n\n\n// ===================================================================\n\n#if !PROTOBUF_INLINE_NOT_IN_HEADERS\n// Duration\n\n// optional int64 seconds = 1;\ninline void Duration::clear_seconds() {\n  seconds_ = GOOGLE_LONGLONG(0);\n}\ninline ::google::protobuf::int64 Duration::seconds() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Duration.seconds)\n  return seconds_;\n}\ninline void Duration::set_seconds(::google::protobuf::int64 value) {\n  \n  seconds_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Duration.seconds)\n}\n\n// optional int32 nanos = 2;\ninline void Duration::clear_nanos() {\n  nanos_ = 0;\n}\ninline ::google::protobuf::int32 Duration::nanos() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Duration.nanos)\n  return nanos_;\n}\ninline void Duration::set_nanos(::google::protobuf::int32 value) {\n  \n  nanos_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Duration.nanos)\n}\n\n#endif  // !PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace protobuf\n}  // namespace google\n\n// @@protoc_insertion_point(global_scope)\n\n#endif  // PROTOBUF_google_2fprotobuf_2fduration_2eproto__INCLUDED\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/duration.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto3\";\n\npackage google.protobuf;\n\noption csharp_namespace = \"Google.Protobuf.WellKnownTypes\";\noption go_package = \"github.com/golang/protobuf/ptypes/duration\";\noption java_package = \"com.google.protobuf\";\noption java_outer_classname = \"DurationProto\";\noption java_multiple_files = true;\noption java_generate_equals_and_hash = true;\noption objc_class_prefix = \"GPB\";\n\n// A Duration represents a signed, fixed-length span of time represented\n// as a count of seconds and fractions of seconds at nanosecond\n// resolution. It is independent of any calendar and concepts like \"day\"\n// or \"month\". It is related to Timestamp in that the difference between\n// two Timestamp values is a Duration and it can be added or subtracted\n// from a Timestamp. Range is approximately +-10,000 years.\n//\n// Example 1: Compute Duration from two Timestamps in pseudo code.\n//\n//     Timestamp start = ...;\n//     Timestamp end = ...;\n//     Duration duration = ...;\n//\n//     duration.seconds = end.seconds - start.seconds;\n//     duration.nanos = end.nanos - start.nanos;\n//\n//     if (duration.seconds < 0 && duration.nanos > 0) {\n//       duration.seconds += 1;\n//       duration.nanos -= 1000000000;\n//     } else if (durations.seconds > 0 && duration.nanos < 0) {\n//       duration.seconds -= 1;\n//       duration.nanos += 1000000000;\n//     }\n//\n// Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.\n//\n//     Timestamp start = ...;\n//     Duration duration = ...;\n//     Timestamp end = ...;\n//\n//     end.seconds = start.seconds + duration.seconds;\n//     end.nanos = start.nanos + duration.nanos;\n//\n//     if (end.nanos < 0) {\n//       end.seconds -= 1;\n//       end.nanos += 1000000000;\n//     } else if (end.nanos >= 1000000000) {\n//       end.seconds += 1;\n//       end.nanos -= 1000000000;\n//     }\n//\n//\nmessage Duration {\n\n  // Signed seconds of the span of time. Must be from -315,576,000,000\n  // to +315,576,000,000 inclusive.\n  int64 seconds = 1;\n\n  // Signed fractions of a second at nanosecond resolution of the span\n  // of time. Durations less than one second are represented with a 0\n  // `seconds` field and a positive or negative `nanos` field. For durations\n  // of one second or more, a non-zero value for the `nanos` field must be\n  // of the same sign as the `seconds` field. Must be from -999,999,999\n  // to +999,999,999 inclusive.\n  int32 nanos = 2;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/dynamic_message.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// DynamicMessage is implemented by constructing a data structure which\n// has roughly the same memory layout as a generated message would have.\n// Then, we use GeneratedMessageReflection to implement our reflection\n// interface.  All the other operations we need to implement (e.g.\n// parsing, copying, etc.) are already implemented in terms of\n// Reflection, so the rest is easy.\n//\n// The up side of this strategy is that it's very efficient.  We don't\n// need to use hash_maps or generic representations of fields.  The\n// down side is that this is a low-level memory management hack which\n// can be tricky to get right.\n//\n// As mentioned in the header, we only expose a DynamicMessageFactory\n// publicly, not the DynamicMessage class itself.  This is because\n// GenericMessageReflection wants to have a pointer to a \"default\"\n// copy of the class, with all fields initialized to their default\n// values.  We only want to construct one of these per message type,\n// so DynamicMessageFactory stores a cache of default messages for\n// each type it sees (each unique Descriptor pointer).  The code\n// refers to the \"default\" copy of the class as the \"prototype\".\n//\n// Note on memory allocation:  This module often calls \"operator new()\"\n// to allocate untyped memory, rather than calling something like\n// \"new uint8[]\".  This is because \"operator new()\" means \"Give me some\n// space which I can use as I please.\" while \"new uint8[]\" means \"Give\n// me an array of 8-bit integers.\".  In practice, the later may return\n// a pointer that is not aligned correctly for general use.  I believe\n// Item 8 of \"More Effective C++\" discusses this in more detail, though\n// I don't have the book on me right now so I'm not sure.\n\n#include <algorithm>\n#include <google/protobuf/stubs/hash.h>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#include <google/protobuf/stubs/common.h>\n\n#include <google/protobuf/dynamic_message.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/generated_message_util.h>\n#include <google/protobuf/generated_message_reflection.h>\n#include <google/protobuf/arenastring.h>\n#include <google/protobuf/map_field_inl.h>\n#include <google/protobuf/reflection_ops.h>\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/map_type_handler.h>\n#include <google/protobuf/extension_set.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/map_field.h>\n\nnamespace google {\nnamespace protobuf {\n\nusing internal::WireFormat;\nusing internal::ExtensionSet;\nusing internal::GeneratedMessageReflection;\nusing internal::MapField;\nusing internal::DynamicMapField;\n\n\nusing internal::ArenaStringPtr;\n\n// ===================================================================\n// Some helper tables and functions...\n\nnamespace {\n\nbool IsMapFieldInApi(const FieldDescriptor* field) {\n  return field->is_map();\n}\n\n// Compute the byte size of the in-memory representation of the field.\nint FieldSpaceUsed(const FieldDescriptor* field) {\n  typedef FieldDescriptor FD;  // avoid line wrapping\n  if (field->label() == FD::LABEL_REPEATED) {\n    switch (field->cpp_type()) {\n      case FD::CPPTYPE_INT32  : return sizeof(RepeatedField<int32   >);\n      case FD::CPPTYPE_INT64  : return sizeof(RepeatedField<int64   >);\n      case FD::CPPTYPE_UINT32 : return sizeof(RepeatedField<uint32  >);\n      case FD::CPPTYPE_UINT64 : return sizeof(RepeatedField<uint64  >);\n      case FD::CPPTYPE_DOUBLE : return sizeof(RepeatedField<double  >);\n      case FD::CPPTYPE_FLOAT  : return sizeof(RepeatedField<float   >);\n      case FD::CPPTYPE_BOOL   : return sizeof(RepeatedField<bool    >);\n      case FD::CPPTYPE_ENUM   : return sizeof(RepeatedField<int     >);\n      case FD::CPPTYPE_MESSAGE:\n        if (IsMapFieldInApi(field)) {\n          return sizeof(DynamicMapField);\n        } else {\n          return sizeof(RepeatedPtrField<Message>);\n        }\n\n      case FD::CPPTYPE_STRING:\n        switch (field->options().ctype()) {\n          default:  // TODO(kenton):  Support other string reps.\n          case FieldOptions::STRING:\n            return sizeof(RepeatedPtrField<string>);\n        }\n        break;\n    }\n  } else {\n    switch (field->cpp_type()) {\n      case FD::CPPTYPE_INT32  : return sizeof(int32   );\n      case FD::CPPTYPE_INT64  : return sizeof(int64   );\n      case FD::CPPTYPE_UINT32 : return sizeof(uint32  );\n      case FD::CPPTYPE_UINT64 : return sizeof(uint64  );\n      case FD::CPPTYPE_DOUBLE : return sizeof(double  );\n      case FD::CPPTYPE_FLOAT  : return sizeof(float   );\n      case FD::CPPTYPE_BOOL   : return sizeof(bool    );\n      case FD::CPPTYPE_ENUM   : return sizeof(int     );\n\n      case FD::CPPTYPE_MESSAGE:\n        return sizeof(Message*);\n\n      case FD::CPPTYPE_STRING:\n        switch (field->options().ctype()) {\n          default:  // TODO(kenton):  Support other string reps.\n          case FieldOptions::STRING:\n            return sizeof(ArenaStringPtr);\n        }\n        break;\n    }\n  }\n\n  GOOGLE_LOG(DFATAL) << \"Can't get here.\";\n  return 0;\n}\n\n// Compute the byte size of in-memory representation of the oneof fields\n// in default oneof instance.\nint OneofFieldSpaceUsed(const FieldDescriptor* field) {\n  typedef FieldDescriptor FD;  // avoid line wrapping\n  switch (field->cpp_type()) {\n    case FD::CPPTYPE_INT32  : return sizeof(int32   );\n    case FD::CPPTYPE_INT64  : return sizeof(int64   );\n    case FD::CPPTYPE_UINT32 : return sizeof(uint32  );\n    case FD::CPPTYPE_UINT64 : return sizeof(uint64  );\n    case FD::CPPTYPE_DOUBLE : return sizeof(double  );\n    case FD::CPPTYPE_FLOAT  : return sizeof(float   );\n    case FD::CPPTYPE_BOOL   : return sizeof(bool    );\n    case FD::CPPTYPE_ENUM   : return sizeof(int     );\n\n    case FD::CPPTYPE_MESSAGE:\n      return sizeof(Message*);\n\n    case FD::CPPTYPE_STRING:\n      switch (field->options().ctype()) {\n        default:\n        case FieldOptions::STRING:\n          return sizeof(ArenaStringPtr);\n      }\n      break;\n  }\n\n  GOOGLE_LOG(DFATAL) << \"Can't get here.\";\n  return 0;\n}\n\ninline int DivideRoundingUp(int i, int j) {\n  return (i + (j - 1)) / j;\n}\n\nstatic const int kSafeAlignment = sizeof(uint64);\nstatic const int kMaxOneofUnionSize = sizeof(uint64);\n\ninline int AlignTo(int offset, int alignment) {\n  return DivideRoundingUp(offset, alignment) * alignment;\n}\n\n// Rounds the given byte offset up to the next offset aligned such that any\n// type may be stored at it.\ninline int AlignOffset(int offset) {\n  return AlignTo(offset, kSafeAlignment);\n}\n\n#define bitsizeof(T) (sizeof(T) * 8)\n\n}  // namespace\n\n// ===================================================================\n\nclass DynamicMessage : public Message {\n public:\n  struct TypeInfo {\n    int size;\n    int has_bits_offset;\n    int oneof_case_offset;\n    int unknown_fields_offset;\n    int extensions_offset;\n    int is_default_instance_offset;\n\n    // Not owned by the TypeInfo.\n    DynamicMessageFactory* factory;  // The factory that created this object.\n    const DescriptorPool* pool;      // The factory's DescriptorPool.\n    const Descriptor* type;          // Type of this DynamicMessage.\n\n    // Warning:  The order in which the following pointers are defined is\n    //   important (the prototype must be deleted *before* the offsets).\n    google::protobuf::scoped_array<int> offsets;\n    google::protobuf::scoped_ptr<const GeneratedMessageReflection> reflection;\n    // Don't use a scoped_ptr to hold the prototype: the destructor for\n    // DynamicMessage needs to know whether it is the prototype, and does so by\n    // looking back at this field. This would assume details about the\n    // implementation of scoped_ptr.\n    const DynamicMessage* prototype;\n    void* default_oneof_instance;\n\n    TypeInfo() : prototype(NULL), default_oneof_instance(NULL) {}\n\n    ~TypeInfo() {\n      delete prototype;\n      operator delete(default_oneof_instance);\n    }\n  };\n\n  DynamicMessage(const TypeInfo* type_info);\n  ~DynamicMessage();\n\n  // Called on the prototype after construction to initialize message fields.\n  void CrossLinkPrototypes();\n\n  // implements Message ----------------------------------------------\n\n  Message* New() const;\n  Message* New(::google::protobuf::Arena* arena) const;\n  ::google::protobuf::Arena* GetArena() const { return NULL; };\n\n  int GetCachedSize() const;\n  void SetCachedSize(int size) const;\n\n  Metadata GetMetadata() const;\n\n  // We actually allocate more memory than sizeof(*this) when this\n  // class's memory is allocated via the global operator new. Thus, we need to\n  // manually call the global operator delete. Calling the destructor is taken\n  // care of for us. This makes DynamicMessage compatible with -fsized-delete.\n  // It doesn't work for MSVC though.\n#ifndef _MSC_VER\n  static void operator delete(void* ptr) {\n    ::operator delete(ptr);\n  }\n#endif  // !_MSC_VER\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessage);\n  DynamicMessage(const TypeInfo* type_info, ::google::protobuf::Arena* arena);\n  void SharedCtor();\n\n  inline bool is_prototype() const {\n    return type_info_->prototype == this ||\n           // If type_info_->prototype is NULL, then we must be constructing\n           // the prototype now, which means we must be the prototype.\n           type_info_->prototype == NULL;\n  }\n\n  inline void* OffsetToPointer(int offset) {\n    return reinterpret_cast<uint8*>(this) + offset;\n  }\n  inline const void* OffsetToPointer(int offset) const {\n    return reinterpret_cast<const uint8*>(this) + offset;\n  }\n\n  const TypeInfo* type_info_;\n  // TODO(kenton):  Make this an atomic<int> when C++ supports it.\n  mutable int cached_byte_size_;\n};\n\nDynamicMessage::DynamicMessage(const TypeInfo* type_info)\n  : type_info_(type_info),\n    cached_byte_size_(0) {\n  SharedCtor();\n}\n\nDynamicMessage::DynamicMessage(const TypeInfo* type_info,\n                               ::google::protobuf::Arena* arena)\n  : type_info_(type_info),\n    cached_byte_size_(0) {\n  SharedCtor();\n}\n\nvoid DynamicMessage::SharedCtor() {\n  // We need to call constructors for various fields manually and set\n  // default values where appropriate.  We use placement new to call\n  // constructors.  If you haven't heard of placement new, I suggest Googling\n  // it now.  We use placement new even for primitive types that don't have\n  // constructors for consistency.  (In theory, placement new should be used\n  // any time you are trying to convert untyped memory to typed memory, though\n  // in practice that's not strictly necessary for types that don't have a\n  // constructor.)\n\n  const Descriptor* descriptor = type_info_->type;\n\n  // Initialize oneof cases.\n  for (int i = 0 ; i < descriptor->oneof_decl_count(); ++i) {\n    new(OffsetToPointer(type_info_->oneof_case_offset + sizeof(uint32) * i))\n        uint32(0);\n  }\n\n  if (type_info_->is_default_instance_offset != -1) {\n    *reinterpret_cast<bool*>(\n        OffsetToPointer(type_info_->is_default_instance_offset)) = false;\n  }\n\n  new(OffsetToPointer(type_info_->unknown_fields_offset)) UnknownFieldSet;\n\n  if (type_info_->extensions_offset != -1) {\n    new(OffsetToPointer(type_info_->extensions_offset)) ExtensionSet;\n  }\n\n  for (int i = 0; i < descriptor->field_count(); i++) {\n    const FieldDescriptor* field = descriptor->field(i);\n    void* field_ptr = OffsetToPointer(type_info_->offsets[i]);\n    if (field->containing_oneof()) {\n      continue;\n    }\n    switch (field->cpp_type()) {\n#define HANDLE_TYPE(CPPTYPE, TYPE)                                           \\\n      case FieldDescriptor::CPPTYPE_##CPPTYPE:                               \\\n        if (!field->is_repeated()) {                                         \\\n          new(field_ptr) TYPE(field->default_value_##TYPE());                \\\n        } else {                                                             \\\n          new(field_ptr) RepeatedField<TYPE>();                              \\\n        }                                                                    \\\n        break;\n\n      HANDLE_TYPE(INT32 , int32 );\n      HANDLE_TYPE(INT64 , int64 );\n      HANDLE_TYPE(UINT32, uint32);\n      HANDLE_TYPE(UINT64, uint64);\n      HANDLE_TYPE(DOUBLE, double);\n      HANDLE_TYPE(FLOAT , float );\n      HANDLE_TYPE(BOOL  , bool  );\n#undef HANDLE_TYPE\n\n      case FieldDescriptor::CPPTYPE_ENUM:\n        if (!field->is_repeated()) {\n          new(field_ptr) int(field->default_value_enum()->number());\n        } else {\n          new(field_ptr) RepeatedField<int>();\n        }\n        break;\n\n      case FieldDescriptor::CPPTYPE_STRING:\n        switch (field->options().ctype()) {\n          default:  // TODO(kenton):  Support other string reps.\n          case FieldOptions::STRING:\n            if (!field->is_repeated()) {\n              const string* default_value;\n              if (is_prototype()) {\n                default_value = &field->default_value_string();\n              } else {\n                default_value =\n                  &(reinterpret_cast<const ArenaStringPtr*>(\n                    type_info_->prototype->OffsetToPointer(\n                      type_info_->offsets[i]))->Get(NULL));\n              }\n              ArenaStringPtr* asp = new(field_ptr) ArenaStringPtr();\n              asp->UnsafeSetDefault(default_value);\n            } else {\n              new(field_ptr) RepeatedPtrField<string>();\n            }\n            break;\n        }\n        break;\n\n      case FieldDescriptor::CPPTYPE_MESSAGE: {\n        if (!field->is_repeated()) {\n          new(field_ptr) Message*(NULL);\n        } else {\n          if (IsMapFieldInApi(field)) {\n            new (field_ptr) DynamicMapField(\n                type_info_->factory->GetPrototypeNoLock(field->message_type()));\n          } else {\n            new (field_ptr) RepeatedPtrField<Message>();\n          }\n        }\n        break;\n      }\n    }\n  }\n}\n\nDynamicMessage::~DynamicMessage() {\n  const Descriptor* descriptor = type_info_->type;\n\n  reinterpret_cast<UnknownFieldSet*>(\n    OffsetToPointer(type_info_->unknown_fields_offset))->~UnknownFieldSet();\n\n  if (type_info_->extensions_offset != -1) {\n    reinterpret_cast<ExtensionSet*>(\n      OffsetToPointer(type_info_->extensions_offset))->~ExtensionSet();\n  }\n\n  // We need to manually run the destructors for repeated fields and strings,\n  // just as we ran their constructors in the DynamicMessage constructor.\n  // We also need to manually delete oneof fields if it is set and is string\n  // or message.\n  // Additionally, if any singular embedded messages have been allocated, we\n  // need to delete them, UNLESS we are the prototype message of this type,\n  // in which case any embedded messages are other prototypes and shouldn't\n  // be touched.\n  for (int i = 0; i < descriptor->field_count(); i++) {\n    const FieldDescriptor* field = descriptor->field(i);\n    if (field->containing_oneof()) {\n      void* field_ptr = OffsetToPointer(\n          type_info_->oneof_case_offset\n          + sizeof(uint32) * field->containing_oneof()->index());\n      if (*(reinterpret_cast<const uint32*>(field_ptr)) ==\n          field->number()) {\n        field_ptr = OffsetToPointer(type_info_->offsets[\n            descriptor->field_count() + field->containing_oneof()->index()]);\n        if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {\n          switch (field->options().ctype()) {\n            default:\n            case FieldOptions::STRING: {\n              const ::std::string* default_value =\n                  &(reinterpret_cast<const ArenaStringPtr*>(\n                      reinterpret_cast<uint8*>(\n                          type_info_->default_oneof_instance)\n                      + type_info_->offsets[i])\n                    ->Get(NULL));\n              reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy(\n                  default_value, NULL);\n              break;\n            }\n          }\n        } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n            delete *reinterpret_cast<Message**>(field_ptr);\n        }\n      }\n      continue;\n    }\n    void* field_ptr = OffsetToPointer(type_info_->offsets[i]);\n\n    if (field->is_repeated()) {\n      switch (field->cpp_type()) {\n#define HANDLE_TYPE(UPPERCASE, LOWERCASE)                                     \\\n        case FieldDescriptor::CPPTYPE_##UPPERCASE :                           \\\n          reinterpret_cast<RepeatedField<LOWERCASE>*>(field_ptr)              \\\n              ->~RepeatedField<LOWERCASE>();                                  \\\n          break\n\n        HANDLE_TYPE( INT32,  int32);\n        HANDLE_TYPE( INT64,  int64);\n        HANDLE_TYPE(UINT32, uint32);\n        HANDLE_TYPE(UINT64, uint64);\n        HANDLE_TYPE(DOUBLE, double);\n        HANDLE_TYPE( FLOAT,  float);\n        HANDLE_TYPE(  BOOL,   bool);\n        HANDLE_TYPE(  ENUM,    int);\n#undef HANDLE_TYPE\n\n        case FieldDescriptor::CPPTYPE_STRING:\n          switch (field->options().ctype()) {\n            default:  // TODO(kenton):  Support other string reps.\n            case FieldOptions::STRING:\n              reinterpret_cast<RepeatedPtrField<string>*>(field_ptr)\n                  ->~RepeatedPtrField<string>();\n              break;\n          }\n          break;\n\n        case FieldDescriptor::CPPTYPE_MESSAGE:\n          if (IsMapFieldInApi(field)) {\n            reinterpret_cast<DynamicMapField*>(field_ptr)->~DynamicMapField();\n          } else {\n            reinterpret_cast<RepeatedPtrField<Message>*>(field_ptr)\n                ->~RepeatedPtrField<Message>();\n          }\n          break;\n      }\n\n    } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {\n      switch (field->options().ctype()) {\n        default:  // TODO(kenton):  Support other string reps.\n        case FieldOptions::STRING: {\n          const ::std::string* default_value =\n              &(reinterpret_cast<const ArenaStringPtr*>(\n                  type_info_->prototype->OffsetToPointer(\n                      type_info_->offsets[i]))->Get(NULL));\n          reinterpret_cast<ArenaStringPtr*>(field_ptr)->Destroy(\n              default_value, NULL);\n          break;\n        }\n      }\n    } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n      if (!is_prototype()) {\n        Message* message = *reinterpret_cast<Message**>(field_ptr);\n        if (message != NULL) {\n          delete message;\n        }\n      }\n    }\n  }\n}\n\nvoid DynamicMessage::CrossLinkPrototypes() {\n  // This should only be called on the prototype message.\n  GOOGLE_CHECK(is_prototype());\n\n  DynamicMessageFactory* factory = type_info_->factory;\n  const Descriptor* descriptor = type_info_->type;\n\n  // Cross-link default messages.\n  for (int i = 0; i < descriptor->field_count(); i++) {\n    const FieldDescriptor* field = descriptor->field(i);\n    void* field_ptr = OffsetToPointer(type_info_->offsets[i]);\n    if (field->containing_oneof()) {\n      field_ptr = reinterpret_cast<uint8*>(\n          type_info_->default_oneof_instance) + type_info_->offsets[i];\n    }\n\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&\n        !field->is_repeated()) {\n      // For fields with message types, we need to cross-link with the\n      // prototype for the field's type.\n      // For singular fields, the field is just a pointer which should\n      // point to the prototype.\n      *reinterpret_cast<const Message**>(field_ptr) =\n        factory->GetPrototypeNoLock(field->message_type());\n    }\n  }\n\n  // Set as the default instance -- this affects field-presence semantics for\n  // proto3.\n  if (type_info_->is_default_instance_offset != -1) {\n    void* is_default_instance_ptr =\n        OffsetToPointer(type_info_->is_default_instance_offset);\n    *reinterpret_cast<bool*>(is_default_instance_ptr) = true;\n  }\n}\n\nMessage* DynamicMessage::New() const {\n  void* new_base = operator new(type_info_->size);\n  memset(new_base, 0, type_info_->size);\n  return new(new_base) DynamicMessage(type_info_);\n}\n\nMessage* DynamicMessage::New(::google::protobuf::Arena* arena) const {\n  if (arena != NULL) {\n    Message* message = New();\n    arena->Own(message);\n    return message;\n  } else {\n    return New();\n  }\n}\n\nint DynamicMessage::GetCachedSize() const {\n  return cached_byte_size_;\n}\n\nvoid DynamicMessage::SetCachedSize(int size) const {\n  // This is theoretically not thread-compatible, but in practice it works\n  // because if multiple threads write this simultaneously, they will be\n  // writing the exact same value.\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  cached_byte_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\n\nMetadata DynamicMessage::GetMetadata() const {\n  Metadata metadata;\n  metadata.descriptor = type_info_->type;\n  metadata.reflection = type_info_->reflection.get();\n  return metadata;\n}\n\n// ===================================================================\n\nstruct DynamicMessageFactory::PrototypeMap {\n  typedef hash_map<const Descriptor*, const DynamicMessage::TypeInfo*> Map;\n  Map map_;\n};\n\nDynamicMessageFactory::DynamicMessageFactory()\n  : pool_(NULL), delegate_to_generated_factory_(false),\n    prototypes_(new PrototypeMap) {\n}\n\nDynamicMessageFactory::DynamicMessageFactory(const DescriptorPool* pool)\n  : pool_(pool), delegate_to_generated_factory_(false),\n    prototypes_(new PrototypeMap) {\n}\n\nDynamicMessageFactory::~DynamicMessageFactory() {\n  for (PrototypeMap::Map::iterator iter = prototypes_->map_.begin();\n       iter != prototypes_->map_.end(); ++iter) {\n    DeleteDefaultOneofInstance(iter->second->type,\n                               iter->second->offsets.get(),\n                               iter->second->default_oneof_instance);\n    delete iter->second;\n  }\n}\n\nconst Message* DynamicMessageFactory::GetPrototype(const Descriptor* type) {\n  MutexLock lock(&prototypes_mutex_);\n  return GetPrototypeNoLock(type);\n}\n\nconst Message* DynamicMessageFactory::GetPrototypeNoLock(\n    const Descriptor* type) {\n  if (delegate_to_generated_factory_ &&\n      type->file()->pool() == DescriptorPool::generated_pool()) {\n    return MessageFactory::generated_factory()->GetPrototype(type);\n  }\n\n  const DynamicMessage::TypeInfo** target = &prototypes_->map_[type];\n  if (*target != NULL) {\n    // Already exists.\n    return (*target)->prototype;\n  }\n\n  DynamicMessage::TypeInfo* type_info = new DynamicMessage::TypeInfo;\n  *target = type_info;\n\n  type_info->type = type;\n  type_info->pool = (pool_ == NULL) ? type->file()->pool() : pool_;\n  type_info->factory = this;\n\n  // We need to construct all the structures passed to\n  // GeneratedMessageReflection's constructor.  This includes:\n  // - A block of memory that contains space for all the message's fields.\n  // - An array of integers indicating the byte offset of each field within\n  //   this block.\n  // - A big bitfield containing a bit for each field indicating whether\n  //   or not that field is set.\n\n  // Compute size and offsets.\n  int* offsets = new int[type->field_count() + type->oneof_decl_count()];\n  type_info->offsets.reset(offsets);\n\n  // Decide all field offsets by packing in order.\n  // We place the DynamicMessage object itself at the beginning of the allocated\n  // space.\n  int size = sizeof(DynamicMessage);\n  size = AlignOffset(size);\n\n  // Next the has_bits, which is an array of uint32s.\n  if (type->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) {\n    type_info->has_bits_offset = -1;\n  } else {\n    type_info->has_bits_offset = size;\n    int has_bits_array_size =\n      DivideRoundingUp(type->field_count(), bitsizeof(uint32));\n    size += has_bits_array_size * sizeof(uint32);\n    size = AlignOffset(size);\n  }\n\n  // The is_default_instance member, if any.\n  if (type->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) {\n    type_info->is_default_instance_offset = size;\n    size += sizeof(bool);\n    size = AlignOffset(size);\n  } else {\n    type_info->is_default_instance_offset = -1;\n  }\n\n  // The oneof_case, if any. It is an array of uint32s.\n  if (type->oneof_decl_count() > 0) {\n    type_info->oneof_case_offset = size;\n    size += type->oneof_decl_count() * sizeof(uint32);\n    size = AlignOffset(size);\n  }\n\n  // The ExtensionSet, if any.\n  if (type->extension_range_count() > 0) {\n    type_info->extensions_offset = size;\n    size += sizeof(ExtensionSet);\n    size = AlignOffset(size);\n  } else {\n    // No extensions.\n    type_info->extensions_offset = -1;\n  }\n\n  // All the fields.\n  for (int i = 0; i < type->field_count(); i++) {\n    // Make sure field is aligned to avoid bus errors.\n    // Oneof fields do not use any space.\n    if (!type->field(i)->containing_oneof()) {\n      int field_size = FieldSpaceUsed(type->field(i));\n      size = AlignTo(size, std::min(kSafeAlignment, field_size));\n      offsets[i] = size;\n      size += field_size;\n    }\n  }\n\n  // The oneofs.\n  for (int i = 0; i < type->oneof_decl_count(); i++) {\n    size = AlignTo(size, kSafeAlignment);\n    offsets[type->field_count() + i] = size;\n    size += kMaxOneofUnionSize;\n  }\n\n  // Add the UnknownFieldSet to the end.\n  size = AlignOffset(size);\n  type_info->unknown_fields_offset = size;\n  size += sizeof(UnknownFieldSet);\n\n  // Align the final size to make sure no clever allocators think that\n  // alignment is not necessary.\n  size = AlignOffset(size);\n  type_info->size = size;\n\n  // Allocate the prototype.\n  void* base = operator new(size);\n  memset(base, 0, size);\n  // The prototype in type_info has to be set before creating the prototype\n  // instance on memory. e.g., message Foo { map<int32, Foo> a = 1; }. When\n  // creating prototype for Foo, prototype of the map entry will also be\n  // created, which needs the address of the prototype of Foo (the value in\n  // map). To break the cyclic dependency, we have to assgin the address of\n  // prototype into type_info first.\n  type_info->prototype = static_cast<DynamicMessage*>(base);\n  DynamicMessage* prototype = new(base) DynamicMessage(type_info);\n\n  // Construct the reflection object.\n  if (type->oneof_decl_count() > 0) {\n    // Compute the size of default oneof instance and offsets of default\n    // oneof fields.\n    int oneof_size = 0;\n    for (int i = 0; i < type->oneof_decl_count(); i++) {\n      for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) {\n        const FieldDescriptor* field = type->oneof_decl(i)->field(j);\n        int field_size = OneofFieldSpaceUsed(field);\n        oneof_size = AlignTo(oneof_size, std::min(kSafeAlignment, field_size));\n        offsets[field->index()] = oneof_size;\n        oneof_size += field_size;\n      }\n    }\n    // Construct default oneof instance.\n    type_info->default_oneof_instance = ::operator new(oneof_size);\n    ConstructDefaultOneofInstance(type_info->type,\n                                  type_info->offsets.get(),\n                                  type_info->default_oneof_instance);\n    type_info->reflection.reset(\n        new GeneratedMessageReflection(\n            type_info->type,\n            type_info->prototype,\n            type_info->offsets.get(),\n            type_info->has_bits_offset,\n            type_info->unknown_fields_offset,\n            type_info->extensions_offset,\n            type_info->default_oneof_instance,\n            type_info->oneof_case_offset,\n            type_info->pool,\n            this,\n            type_info->size,\n            -1 /* arena_offset */,\n            type_info->is_default_instance_offset));\n  } else {\n    type_info->reflection.reset(\n        new GeneratedMessageReflection(\n            type_info->type,\n            type_info->prototype,\n            type_info->offsets.get(),\n            type_info->has_bits_offset,\n            type_info->unknown_fields_offset,\n            type_info->extensions_offset,\n            type_info->pool,\n            this,\n            type_info->size,\n            -1 /* arena_offset */,\n            type_info->is_default_instance_offset));\n  }\n  // Cross link prototypes.\n  prototype->CrossLinkPrototypes();\n\n  return prototype;\n}\n\nvoid DynamicMessageFactory::ConstructDefaultOneofInstance(\n    const Descriptor* type,\n    const int offsets[],\n    void* default_oneof_instance) {\n  for (int i = 0; i < type->oneof_decl_count(); i++) {\n    for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) {\n      const FieldDescriptor* field = type->oneof_decl(i)->field(j);\n      void* field_ptr = reinterpret_cast<uint8*>(\n          default_oneof_instance) + offsets[field->index()];\n      switch (field->cpp_type()) {\n#define HANDLE_TYPE(CPPTYPE, TYPE)                                      \\\n        case FieldDescriptor::CPPTYPE_##CPPTYPE:                        \\\n          new(field_ptr) TYPE(field->default_value_##TYPE());           \\\n          break;\n\n        HANDLE_TYPE(INT32 , int32 );\n        HANDLE_TYPE(INT64 , int64 );\n        HANDLE_TYPE(UINT32, uint32);\n        HANDLE_TYPE(UINT64, uint64);\n        HANDLE_TYPE(DOUBLE, double);\n        HANDLE_TYPE(FLOAT , float );\n        HANDLE_TYPE(BOOL  , bool  );\n#undef HANDLE_TYPE\n\n        case FieldDescriptor::CPPTYPE_ENUM:\n          new(field_ptr) int(field->default_value_enum()->number());\n          break;\n        case FieldDescriptor::CPPTYPE_STRING:\n          switch (field->options().ctype()) {\n            default:\n            case FieldOptions::STRING:\n              ArenaStringPtr* asp = new (field_ptr) ArenaStringPtr();\n              asp->UnsafeSetDefault(&field->default_value_string());\n              break;\n          }\n          break;\n\n        case FieldDescriptor::CPPTYPE_MESSAGE: {\n          new(field_ptr) Message*(NULL);\n          break;\n        }\n      }\n    }\n  }\n}\n\nvoid DynamicMessageFactory::DeleteDefaultOneofInstance(\n    const Descriptor* type,\n    const int offsets[],\n    void* default_oneof_instance) {\n  for (int i = 0; i < type->oneof_decl_count(); i++) {\n    for (int j = 0; j < type->oneof_decl(i)->field_count(); j++) {\n      const FieldDescriptor* field = type->oneof_decl(i)->field(j);\n      if (field->cpp_type() == FieldDescriptor::CPPTYPE_STRING) {\n        switch (field->options().ctype()) {\n          default:\n          case FieldOptions::STRING:\n            break;\n        }\n      }\n    }\n  }\n}\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/dynamic_message.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Defines an implementation of Message which can emulate types which are not\n// known at compile-time.\n\n#ifndef GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__\n#define GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#include <google/protobuf/message.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/mutex.h>\n\nnamespace google {\nnamespace protobuf {\n\n// Defined in other files.\nclass Descriptor;        // descriptor.h\nclass DescriptorPool;    // descriptor.h\n\n// Constructs implementations of Message which can emulate types which are not\n// known at compile-time.\n//\n// Sometimes you want to be able to manipulate protocol types that you don't\n// know about at compile time.  It would be nice to be able to construct\n// a Message object which implements the message type given by any arbitrary\n// Descriptor.  DynamicMessage provides this.\n//\n// As it turns out, a DynamicMessage needs to construct extra\n// information about its type in order to operate.  Most of this information\n// can be shared between all DynamicMessages of the same type.  But, caching\n// this information in some sort of global map would be a bad idea, since\n// the cached information for a particular descriptor could outlive the\n// descriptor itself.  To avoid this problem, DynamicMessageFactory\n// encapsulates this \"cache\".  All DynamicMessages of the same type created\n// from the same factory will share the same support data.  Any Descriptors\n// used with a particular factory must outlive the factory.\nclass LIBPROTOBUF_EXPORT DynamicMessageFactory : public MessageFactory {\n public:\n  // Construct a DynamicMessageFactory that will search for extensions in\n  // the DescriptorPool in which the extendee is defined.\n  DynamicMessageFactory();\n\n  // Construct a DynamicMessageFactory that will search for extensions in\n  // the given DescriptorPool.\n  //\n  // DEPRECATED:  Use CodedInputStream::SetExtensionRegistry() to tell the\n  //   parser to look for extensions in an alternate pool.  However, note that\n  //   this is almost never what you want to do.  Almost all users should use\n  //   the zero-arg constructor.\n  DynamicMessageFactory(const DescriptorPool* pool);\n\n  ~DynamicMessageFactory();\n\n  // Call this to tell the DynamicMessageFactory that if it is given a\n  // Descriptor d for which:\n  //   d->file()->pool() == DescriptorPool::generated_pool(),\n  // then it should delegate to MessageFactory::generated_factory() instead\n  // of constructing a dynamic implementation of the message.  In theory there\n  // is no down side to doing this, so it may become the default in the future.\n  void SetDelegateToGeneratedFactory(bool enable) {\n    delegate_to_generated_factory_ = enable;\n  }\n\n  // implements MessageFactory ---------------------------------------\n\n  // Given a Descriptor, constructs the default (prototype) Message of that\n  // type.  You can then call that message's New() method to construct a\n  // mutable message of that type.\n  //\n  // Calling this method twice with the same Descriptor returns the same\n  // object.  The returned object remains property of the factory and will\n  // be destroyed when the factory is destroyed.  Also, any objects created\n  // by calling the prototype's New() method share some data with the\n  // prototype, so these must be destroyed before the DynamicMessageFactory\n  // is destroyed.\n  //\n  // The given descriptor must outlive the returned message, and hence must\n  // outlive the DynamicMessageFactory.\n  //\n  // The method is thread-safe.\n  const Message* GetPrototype(const Descriptor* type);\n\n private:\n  const DescriptorPool* pool_;\n  bool delegate_to_generated_factory_;\n\n  // This struct just contains a hash_map.  We can't #include <google/protobuf/stubs/hash.h> from\n  // this header due to hacks needed for hash_map portability in the open source\n  // release.  Namely, stubs/hash.h, which defines hash_map portably, is not a\n  // public header (for good reason), but dynamic_message.h is, and public\n  // headers may only #include other public headers.\n  struct PrototypeMap;\n  google::protobuf::scoped_ptr<PrototypeMap> prototypes_;\n  mutable Mutex prototypes_mutex_;\n\n  friend class DynamicMessage;\n  const Message* GetPrototypeNoLock(const Descriptor* type);\n\n  // Construct default oneof instance for reflection usage if oneof\n  // is defined.\n  static void ConstructDefaultOneofInstance(const Descriptor* type,\n                                            const int offsets[],\n                                            void* default_oneof_instance);\n  // Delete default oneof instance. Called by ~DynamicMessageFactory.\n  static void DeleteDefaultOneofInstance(const Descriptor* type,\n                                         const int offsets[],\n                                         void* default_oneof_instance);\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DynamicMessageFactory);\n};\n\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_DYNAMIC_MESSAGE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/dynamic_message_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Since the reflection interface for DynamicMessage is implemented by\n// GenericMessageReflection, the only thing we really have to test is\n// that DynamicMessage correctly sets up the information that\n// GenericMessageReflection needs to use.  So, we focus on that in this\n// test.  Other tests, such as generic_message_reflection_unittest and\n// reflection_ops_unittest, cover the rest of the functionality used by\n// DynamicMessage.\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#include <google/protobuf/dynamic_message.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/test_util.h>\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/unittest_no_field_presence.pb.h>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\n\nclass DynamicMessageTest : public testing::Test {\n protected:\n  DescriptorPool pool_;\n  DynamicMessageFactory factory_;\n  const Descriptor* descriptor_;\n  const Message* prototype_;\n  const Descriptor* extensions_descriptor_;\n  const Message* extensions_prototype_;\n  const Descriptor* packed_descriptor_;\n  const Message* packed_prototype_;\n  const Descriptor* oneof_descriptor_;\n  const Message* oneof_prototype_;\n  const Descriptor* proto3_descriptor_;\n  const Message* proto3_prototype_;\n\n  DynamicMessageTest(): factory_(&pool_) {}\n\n  virtual void SetUp() {\n    // We want to make sure that DynamicMessage works (particularly with\n    // extensions) even if we use descriptors that are *not* from compiled-in\n    // types, so we make copies of the descriptors for unittest.proto and\n    // unittest_import.proto.\n    FileDescriptorProto unittest_file;\n    FileDescriptorProto unittest_import_file;\n    FileDescriptorProto unittest_import_public_file;\n    FileDescriptorProto unittest_no_field_presence_file;\n\n    unittest::TestAllTypes::descriptor()->file()->CopyTo(&unittest_file);\n    unittest_import::ImportMessage::descriptor()->file()->CopyTo(\n      &unittest_import_file);\n    unittest_import::PublicImportMessage::descriptor()->file()->CopyTo(\n      &unittest_import_public_file);\n    proto2_nofieldpresence_unittest::TestAllTypes::descriptor()->\n        file()->CopyTo(&unittest_no_field_presence_file);\n\n    ASSERT_TRUE(pool_.BuildFile(unittest_import_public_file) != NULL);\n    ASSERT_TRUE(pool_.BuildFile(unittest_import_file) != NULL);\n    ASSERT_TRUE(pool_.BuildFile(unittest_file) != NULL);\n    ASSERT_TRUE(pool_.BuildFile(unittest_no_field_presence_file) != NULL);\n\n    descriptor_ = pool_.FindMessageTypeByName(\"protobuf_unittest.TestAllTypes\");\n    ASSERT_TRUE(descriptor_ != NULL);\n    prototype_ = factory_.GetPrototype(descriptor_);\n\n    extensions_descriptor_ =\n      pool_.FindMessageTypeByName(\"protobuf_unittest.TestAllExtensions\");\n    ASSERT_TRUE(extensions_descriptor_ != NULL);\n    extensions_prototype_ = factory_.GetPrototype(extensions_descriptor_);\n\n    packed_descriptor_ =\n      pool_.FindMessageTypeByName(\"protobuf_unittest.TestPackedTypes\");\n    ASSERT_TRUE(packed_descriptor_ != NULL);\n    packed_prototype_ = factory_.GetPrototype(packed_descriptor_);\n\n    oneof_descriptor_ =\n      pool_.FindMessageTypeByName(\"protobuf_unittest.TestOneof2\");\n    ASSERT_TRUE(oneof_descriptor_ != NULL);\n    oneof_prototype_ = factory_.GetPrototype(oneof_descriptor_);\n\n    proto3_descriptor_ =\n      pool_.FindMessageTypeByName(\n          \"proto2_nofieldpresence_unittest.TestAllTypes\");\n    ASSERT_TRUE(proto3_descriptor_ != NULL);\n    proto3_prototype_ = factory_.GetPrototype(proto3_descriptor_);\n  }\n};\n\nTEST_F(DynamicMessageTest, Descriptor) {\n  // Check that the descriptor on the DynamicMessage matches the descriptor\n  // passed to GetPrototype().\n  EXPECT_EQ(prototype_->GetDescriptor(), descriptor_);\n}\n\nTEST_F(DynamicMessageTest, OnePrototype) {\n  // Check that requesting the same prototype twice produces the same object.\n  EXPECT_EQ(prototype_, factory_.GetPrototype(descriptor_));\n}\n\nTEST_F(DynamicMessageTest, Defaults) {\n  // Check that all default values are set correctly in the initial message.\n  TestUtil::ReflectionTester reflection_tester(descriptor_);\n  reflection_tester.ExpectClearViaReflection(*prototype_);\n}\n\nTEST_F(DynamicMessageTest, IndependentOffsets) {\n  // Check that all fields have independent offsets by setting each\n  // one to a unique value then checking that they all still have those\n  // unique values (i.e. they don't stomp each other).\n  google::protobuf::scoped_ptr<Message> message(prototype_->New());\n  TestUtil::ReflectionTester reflection_tester(descriptor_);\n\n  reflection_tester.SetAllFieldsViaReflection(message.get());\n  reflection_tester.ExpectAllFieldsSetViaReflection(*message);\n}\n\nTEST_F(DynamicMessageTest, Extensions) {\n  // Check that extensions work.\n  google::protobuf::scoped_ptr<Message> message(extensions_prototype_->New());\n  TestUtil::ReflectionTester reflection_tester(extensions_descriptor_);\n\n  reflection_tester.SetAllFieldsViaReflection(message.get());\n  reflection_tester.ExpectAllFieldsSetViaReflection(*message);\n}\n\nTEST_F(DynamicMessageTest, PackedFields) {\n  // Check that packed fields work properly.\n  google::protobuf::scoped_ptr<Message> message(packed_prototype_->New());\n  TestUtil::ReflectionTester reflection_tester(packed_descriptor_);\n\n  reflection_tester.SetPackedFieldsViaReflection(message.get());\n  reflection_tester.ExpectPackedFieldsSetViaReflection(*message);\n}\n\nTEST_F(DynamicMessageTest, Oneof) {\n  // Check that oneof fields work properly.\n  google::protobuf::scoped_ptr<Message> message(oneof_prototype_->New());\n\n  // Check default values.\n  const Descriptor* descriptor = message->GetDescriptor();\n  const Reflection* reflection = message->GetReflection();\n  EXPECT_EQ(0, reflection->GetInt32(\n      *message, descriptor->FindFieldByName(\"foo_int\")));\n  EXPECT_EQ(\"\", reflection->GetString(\n      *message, descriptor->FindFieldByName(\"foo_string\")));\n  EXPECT_EQ(\"\", reflection->GetString(\n      *message, descriptor->FindFieldByName(\"foo_cord\")));\n  EXPECT_EQ(\"\", reflection->GetString(\n      *message, descriptor->FindFieldByName(\"foo_string_piece\")));\n  EXPECT_EQ(\"\", reflection->GetString(\n      *message, descriptor->FindFieldByName(\"foo_bytes\")));\n  EXPECT_EQ(unittest::TestOneof2::FOO, reflection->GetEnum(\n      *message, descriptor->FindFieldByName(\"foo_enum\"))->number());\n  const Descriptor* nested_descriptor;\n  const Message* nested_prototype;\n  nested_descriptor =\n      pool_.FindMessageTypeByName(\"protobuf_unittest.TestOneof2.NestedMessage\");\n  nested_prototype = factory_.GetPrototype(nested_descriptor);\n  EXPECT_EQ(nested_prototype,\n            &reflection->GetMessage(\n                *message, descriptor->FindFieldByName(\"foo_message\")));\n  const Descriptor* foogroup_descriptor;\n  const Message* foogroup_prototype;\n  foogroup_descriptor =\n      pool_.FindMessageTypeByName(\"protobuf_unittest.TestOneof2.FooGroup\");\n  foogroup_prototype = factory_.GetPrototype(foogroup_descriptor);\n  EXPECT_EQ(foogroup_prototype,\n            &reflection->GetMessage(\n                *message, descriptor->FindFieldByName(\"foogroup\")));\n  EXPECT_NE(foogroup_prototype,\n            &reflection->GetMessage(\n                *message, descriptor->FindFieldByName(\"foo_lazy_message\")));\n  EXPECT_EQ(5, reflection->GetInt32(\n      *message, descriptor->FindFieldByName(\"bar_int\")));\n  EXPECT_EQ(\"STRING\", reflection->GetString(\n      *message, descriptor->FindFieldByName(\"bar_string\")));\n  EXPECT_EQ(\"CORD\", reflection->GetString(\n      *message, descriptor->FindFieldByName(\"bar_cord\")));\n  EXPECT_EQ(\"SPIECE\", reflection->GetString(\n      *message, descriptor->FindFieldByName(\"bar_string_piece\")));\n  EXPECT_EQ(\"BYTES\", reflection->GetString(\n      *message, descriptor->FindFieldByName(\"bar_bytes\")));\n  EXPECT_EQ(unittest::TestOneof2::BAR, reflection->GetEnum(\n      *message, descriptor->FindFieldByName(\"bar_enum\"))->number());\n\n  // Check set functions.\n  TestUtil::ReflectionTester reflection_tester(oneof_descriptor_);\n  reflection_tester.SetOneofViaReflection(message.get());\n  reflection_tester.ExpectOneofSetViaReflection(*message);\n}\n\nTEST_F(DynamicMessageTest, SpaceUsed) {\n  // Test that SpaceUsed() works properly\n\n  // Since we share the implementation with generated messages, we don't need\n  // to test very much here.  Just make sure it appears to be working.\n\n  google::protobuf::scoped_ptr<Message> message(prototype_->New());\n  TestUtil::ReflectionTester reflection_tester(descriptor_);\n\n  int initial_space_used = message->SpaceUsed();\n\n  reflection_tester.SetAllFieldsViaReflection(message.get());\n  EXPECT_LT(initial_space_used, message->SpaceUsed());\n}\n\nTEST_F(DynamicMessageTest, Arena) {\n  Arena arena;\n  Message* message = prototype_->New(&arena);\n  (void)message;  // avoid unused-variable error.\n  // Return without freeing: should not leak.\n}\n\nTEST_F(DynamicMessageTest, Proto3) {\n  Message* message = proto3_prototype_->New();\n  const Reflection* refl = message->GetReflection();\n  const Descriptor* desc = message->GetDescriptor();\n\n  // Just test a single primtive and single message field here to make sure we\n  // are getting the no-field-presence semantics elsewhere. DynamicMessage uses\n  // GeneratedMessageReflection under the hood, so the rest should be fine as\n  // long as GMR recognizes that we're using a proto3 message.\n  const FieldDescriptor* optional_int32 =\n      desc->FindFieldByName(\"optional_int32\");\n  const FieldDescriptor* optional_msg =\n      desc->FindFieldByName(\"optional_nested_message\");\n  EXPECT_TRUE(optional_int32 != NULL);\n  EXPECT_TRUE(optional_msg != NULL);\n\n  EXPECT_EQ(false, refl->HasField(*message, optional_int32));\n  refl->SetInt32(message, optional_int32, 42);\n  EXPECT_EQ(true, refl->HasField(*message, optional_int32));\n  refl->SetInt32(message, optional_int32, 0);\n  EXPECT_EQ(false, refl->HasField(*message, optional_int32));\n\n  EXPECT_EQ(false, refl->HasField(*message, optional_msg));\n  refl->MutableMessage(message, optional_msg);\n  EXPECT_EQ(true, refl->HasField(*message, optional_msg));\n  delete refl->ReleaseMessage(message, optional_msg);\n  EXPECT_EQ(false, refl->HasField(*message, optional_msg));\n\n  // Also ensure that the default instance handles field presence properly.\n  EXPECT_EQ(false, refl->HasField(*proto3_prototype_, optional_msg));\n\n  delete message;\n}\n\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/empty.pb.cc",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/empty.proto\n\n#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION\n#include <google/protobuf/empty.pb.h>\n\n#include <algorithm>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/port.h>\n#include <google/protobuf/stubs/once.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/generated_message_reflection.h>\n#include <google/protobuf/reflection_ops.h>\n#include <google/protobuf/wire_format.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\n\nnamespace {\n\nconst ::google::protobuf::Descriptor* Empty_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  Empty_reflection_ = NULL;\n\n}  // namespace\n\n\nvoid protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto() {\n  protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto();\n  const ::google::protobuf::FileDescriptor* file =\n    ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(\n      \"google/protobuf/empty.proto\");\n  GOOGLE_CHECK(file != NULL);\n  Empty_descriptor_ = file->message_type(0);\n  static const int Empty_offsets_[1] = {\n  };\n  Empty_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      Empty_descriptor_,\n      Empty::default_instance_,\n      Empty_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(Empty),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Empty, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Empty, _is_default_instance_));\n}\n\nnamespace {\n\nGOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);\ninline void protobuf_AssignDescriptorsOnce() {\n  ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,\n                 &protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto);\n}\n\nvoid protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_RegisterTypes(const ::std::string&) {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      Empty_descriptor_, &Empty::default_instance());\n}\n\n}  // namespace\n\nvoid protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto() {\n  delete Empty::default_instance_;\n  delete Empty_reflection_;\n}\n\nvoid protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto() {\n  static bool already_here = false;\n  if (already_here) return;\n  already_here = true;\n  GOOGLE_PROTOBUF_VERIFY_VERSION;\n\n  ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(\n    \"\\n\\033google/protobuf/empty.proto\\022\\017google.pr\"\n    \"otobuf\\\"\\007\\n\\005EmptyBy\\n\\023com.google.protobufB\\n\"\n    \"EmptyProtoP\\001Z\\'github.com/golang/protobuf\"\n    \"/ptypes/empty\\240\\001\\001\\370\\001\\001\\242\\002\\003GPB\\252\\002\\036Google.Proto\"\n    \"buf.WellKnownTypesb\\006proto3\", 186);\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(\n    \"google/protobuf/empty.proto\", &protobuf_RegisterTypes);\n  Empty::default_instance_ = new Empty();\n  Empty::default_instance_->InitAsDefaultInstance();\n  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto);\n}\n\n// Force AddDescriptors() to be called at static initialization time.\nstruct StaticDescriptorInitializer_google_2fprotobuf_2fempty_2eproto {\n  StaticDescriptorInitializer_google_2fprotobuf_2fempty_2eproto() {\n    protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto();\n  }\n} static_descriptor_initializer_google_2fprotobuf_2fempty_2eproto_;\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nEmpty::Empty()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.Empty)\n}\n\nEmpty::Empty(::google::protobuf::Arena* arena)\n  : ::google::protobuf::Message(),\n  _internal_metadata_(arena) {\n  SharedCtor();\n  RegisterArenaDtor(arena);\n  // @@protoc_insertion_point(arena_constructor:google.protobuf.Empty)\n}\n\nvoid Empty::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n}\n\nEmpty::Empty(const Empty& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.Empty)\n}\n\nvoid Empty::SharedCtor() {\n    _is_default_instance_ = false;\n  _cached_size_ = 0;\n}\n\nEmpty::~Empty() {\n  // @@protoc_insertion_point(destructor:google.protobuf.Empty)\n  SharedDtor();\n}\n\nvoid Empty::SharedDtor() {\n  if (GetArenaNoVirtual() != NULL) {\n    return;\n  }\n\n  if (this != default_instance_) {\n  }\n}\n\nvoid Empty::ArenaDtor(void* object) {\n  Empty* _this = reinterpret_cast< Empty* >(object);\n  (void)_this;\n}\nvoid Empty::RegisterArenaDtor(::google::protobuf::Arena* arena) {\n}\nvoid Empty::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* Empty::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return Empty_descriptor_;\n}\n\nconst Empty& Empty::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto();\n  return *default_instance_;\n}\n\nEmpty* Empty::default_instance_ = NULL;\n\nEmpty* Empty::New(::google::protobuf::Arena* arena) const {\n  return ::google::protobuf::Arena::CreateMessage<Empty>(arena);\n}\n\nvoid Empty::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.Empty)\n}\n\nbool Empty::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.Empty)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n  handle_unusual:\n    if (tag == 0 ||\n        ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n        ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n      goto success;\n    }\n    DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.Empty)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.Empty)\n  return false;\n#undef DO_\n}\n\nvoid Empty::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.Empty)\n  // @@protoc_insertion_point(serialize_end:google.protobuf.Empty)\n}\n\n::google::protobuf::uint8* Empty::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Empty)\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Empty)\n  return target;\n}\n\nint Empty::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Empty)\n  int total_size = 0;\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid Empty::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Empty)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const Empty* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const Empty>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.Empty)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Empty)\n    MergeFrom(*source);\n  }\n}\n\nvoid Empty::MergeFrom(const Empty& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Empty)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n}\n\nvoid Empty::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.Empty)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid Empty::CopyFrom(const Empty& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Empty)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool Empty::IsInitialized() const {\n\n  return true;\n}\n\nvoid Empty::Swap(Empty* other) {\n  if (other == this) return;\n  if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {\n    InternalSwap(other);\n  } else {\n    Empty temp;\n    temp.MergeFrom(*this);\n    CopyFrom(*other);\n    other->CopyFrom(temp);\n  }\n}\nvoid Empty::UnsafeArenaSwap(Empty* other) {\n  if (other == this) return;\n  GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());\n  InternalSwap(other);\n}\nvoid Empty::InternalSwap(Empty* other) {\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata Empty::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = Empty_descriptor_;\n  metadata.reflection = Empty_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// Empty\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace protobuf\n}  // namespace google\n\n// @@protoc_insertion_point(global_scope)\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/empty.pb.h",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/empty.proto\n\n#ifndef PROTOBUF_google_2fprotobuf_2fempty_2eproto__INCLUDED\n#define PROTOBUF_google_2fprotobuf_2fempty_2eproto__INCLUDED\n\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n\n#if GOOGLE_PROTOBUF_VERSION < 3000000\n#error This file was generated by a newer version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please update\n#error your headers.\n#endif\n#if 3000000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION\n#error This file was generated by an older version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please\n#error regenerate this file with a newer version of protoc.\n#endif\n\n#include <google/protobuf/arena.h>\n#include <google/protobuf/arenastring.h>\n#include <google/protobuf/generated_message_util.h>\n#include <google/protobuf/metadata.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/extension_set.h>\n#include <google/protobuf/unknown_field_set.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\n\n// Internal implementation detail -- do not call these.\nvoid LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto();\nvoid protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto();\nvoid protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto();\n\nclass Empty;\n\n// ===================================================================\n\nclass LIBPROTOBUF_EXPORT Empty : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Empty) */ {\n public:\n  Empty();\n  virtual ~Empty();\n\n  Empty(const Empty& from);\n\n  inline Empty& operator=(const Empty& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }\n  inline void* GetMaybeArenaPointer() const {\n    return MaybeArenaPtr();\n  }\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const Empty& default_instance();\n\n  void UnsafeArenaSwap(Empty* other);\n  void Swap(Empty* other);\n\n  // implements Message ----------------------------------------------\n\n  inline Empty* New() const { return New(NULL); }\n\n  Empty* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const Empty& from);\n  void MergeFrom(const Empty& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(Empty* other);\n  protected:\n  explicit Empty(::google::protobuf::Arena* arena);\n  private:\n  static void ArenaDtor(void* object);\n  inline void RegisterArenaDtor(::google::protobuf::Arena* arena);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.Empty)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  friend class ::google::protobuf::Arena;\n  typedef void InternalArenaConstructable_;\n  typedef void DestructorSkippable_;\n  bool _is_default_instance_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fempty_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fempty_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fempty_2eproto();\n\n  void InitAsDefaultInstance();\n  static Empty* default_instance_;\n};\n// ===================================================================\n\n\n// ===================================================================\n\n#if !PROTOBUF_INLINE_NOT_IN_HEADERS\n// Empty\n\n#endif  // !PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace protobuf\n}  // namespace google\n\n// @@protoc_insertion_point(global_scope)\n\n#endif  // PROTOBUF_google_2fprotobuf_2fempty_2eproto__INCLUDED\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/empty.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto3\";\n\npackage google.protobuf;\n\noption csharp_namespace = \"Google.Protobuf.WellKnownTypes\";\noption go_package = \"github.com/golang/protobuf/ptypes/empty\";\noption java_package = \"com.google.protobuf\";\noption java_outer_classname = \"EmptyProto\";\noption java_multiple_files = true;\noption java_generate_equals_and_hash = true;\noption objc_class_prefix = \"GPB\";\noption cc_enable_arenas = true;\n\n// A generic empty message that you can re-use to avoid defining duplicated\n// empty messages in your APIs. A typical example is to use it as the request\n// or the response type of an API method. For instance:\n//\n//     service Foo {\n//       rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);\n//     }\n//\n// The JSON representation for `Empty` is empty JSON object `{}`.\nmessage Empty {}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/extension_set.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/stubs/hash.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/once.h>\n#include <google/protobuf/extension_set.h>\n#include <google/protobuf/message_lite.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/stubs/map_util.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\nnamespace {\n\ninline WireFormatLite::FieldType real_type(FieldType type) {\n  GOOGLE_DCHECK(type > 0 && type <= WireFormatLite::MAX_FIELD_TYPE);\n  return static_cast<WireFormatLite::FieldType>(type);\n}\n\ninline WireFormatLite::CppType cpp_type(FieldType type) {\n  return WireFormatLite::FieldTypeToCppType(real_type(type));\n}\n\ninline bool is_packable(WireFormatLite::WireType type) {\n  switch (type) {\n    case WireFormatLite::WIRETYPE_VARINT:\n    case WireFormatLite::WIRETYPE_FIXED64:\n    case WireFormatLite::WIRETYPE_FIXED32:\n      return true;\n    case WireFormatLite::WIRETYPE_LENGTH_DELIMITED:\n    case WireFormatLite::WIRETYPE_START_GROUP:\n    case WireFormatLite::WIRETYPE_END_GROUP:\n      return false;\n\n    // Do not add a default statement. Let the compiler complain when someone\n    // adds a new wire type.\n  }\n  GOOGLE_LOG(FATAL) << \"can't reach here.\";\n  return false;\n}\n\n// Registry stuff.\ntypedef hash_map<pair<const MessageLite*, int>,\n                 ExtensionInfo> ExtensionRegistry;\nExtensionRegistry* registry_ = NULL;\nGOOGLE_PROTOBUF_DECLARE_ONCE(registry_init_);\n\nvoid DeleteRegistry() {\n  delete registry_;\n  registry_ = NULL;\n}\n\nvoid InitRegistry() {\n  registry_ = new ExtensionRegistry;\n  OnShutdown(&DeleteRegistry);\n}\n\n// This function is only called at startup, so there is no need for thread-\n// safety.\nvoid Register(const MessageLite* containing_type,\n              int number, ExtensionInfo info) {\n  ::google::protobuf::GoogleOnceInit(&registry_init_, &InitRegistry);\n\n  if (!InsertIfNotPresent(registry_, std::make_pair(containing_type, number),\n                          info)) {\n    GOOGLE_LOG(FATAL) << \"Multiple extension registrations for type \\\"\"\n               << containing_type->GetTypeName()\n               << \"\\\", field number \" << number << \".\";\n  }\n}\n\nconst ExtensionInfo* FindRegisteredExtension(\n    const MessageLite* containing_type, int number) {\n  return (registry_ == NULL)\n             ? NULL\n             : FindOrNull(*registry_, std::make_pair(containing_type, number));\n}\n\n}  // namespace\n\nExtensionFinder::~ExtensionFinder() {}\n\nbool GeneratedExtensionFinder::Find(int number, ExtensionInfo* output) {\n  const ExtensionInfo* extension =\n      FindRegisteredExtension(containing_type_, number);\n  if (extension == NULL) {\n    return false;\n  } else {\n    *output = *extension;\n    return true;\n  }\n}\n\nvoid ExtensionSet::RegisterExtension(const MessageLite* containing_type,\n                                     int number, FieldType type,\n                                     bool is_repeated, bool is_packed) {\n  GOOGLE_CHECK_NE(type, WireFormatLite::TYPE_ENUM);\n  GOOGLE_CHECK_NE(type, WireFormatLite::TYPE_MESSAGE);\n  GOOGLE_CHECK_NE(type, WireFormatLite::TYPE_GROUP);\n  ExtensionInfo info(type, is_repeated, is_packed);\n  Register(containing_type, number, info);\n}\n\nstatic bool CallNoArgValidityFunc(const void* arg, int number) {\n  // Note:  Must use C-style cast here rather than reinterpret_cast because\n  //   the C++ standard at one point did not allow casts between function and\n  //   data pointers and some compilers enforce this for C++-style casts.  No\n  //   compiler enforces it for C-style casts since lots of C-style code has\n  //   relied on these kinds of casts for a long time, despite being\n  //   technically undefined.  See:\n  //     http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#195\n  // Also note:  Some compilers do not allow function pointers to be \"const\".\n  //   Which makes sense, I suppose, because it's meaningless.\n  return ((EnumValidityFunc*)arg)(number);\n}\n\nvoid ExtensionSet::RegisterEnumExtension(const MessageLite* containing_type,\n                                         int number, FieldType type,\n                                         bool is_repeated, bool is_packed,\n                                         EnumValidityFunc* is_valid) {\n  GOOGLE_CHECK_EQ(type, WireFormatLite::TYPE_ENUM);\n  ExtensionInfo info(type, is_repeated, is_packed);\n  info.enum_validity_check.func = CallNoArgValidityFunc;\n  // See comment in CallNoArgValidityFunc() about why we use a c-style cast.\n  info.enum_validity_check.arg = (void*)is_valid;\n  Register(containing_type, number, info);\n}\n\nvoid ExtensionSet::RegisterMessageExtension(const MessageLite* containing_type,\n                                            int number, FieldType type,\n                                            bool is_repeated, bool is_packed,\n                                            const MessageLite* prototype) {\n  GOOGLE_CHECK(type == WireFormatLite::TYPE_MESSAGE ||\n        type == WireFormatLite::TYPE_GROUP);\n  ExtensionInfo info(type, is_repeated, is_packed);\n  info.message_prototype = prototype;\n  Register(containing_type, number, info);\n}\n\n\n// ===================================================================\n// Constructors and basic methods.\n\nExtensionSet::ExtensionSet(::google::protobuf::Arena* arena)\n    : arena_(arena) {\n  if (arena_ != NULL) {\n    arena_->OwnDestructor(&extensions_);\n  }\n}\n\nExtensionSet::ExtensionSet() : arena_(NULL) {}\n\nExtensionSet::~ExtensionSet() {\n  // Deletes all allocated extensions.\n  if (arena_ == NULL) {\n    for (ExtensionMap::iterator iter = extensions_.begin();\n         iter != extensions_.end(); ++iter) {\n      iter->second.Free();\n    }\n  }\n}\n\n// Defined in extension_set_heavy.cc.\n// void ExtensionSet::AppendToList(const Descriptor* containing_type,\n//                                 const DescriptorPool* pool,\n//                                 vector<const FieldDescriptor*>* output) const\n\nbool ExtensionSet::Has(int number) const {\n  ExtensionMap::const_iterator iter = extensions_.find(number);\n  if (iter == extensions_.end()) return false;\n  GOOGLE_DCHECK(!iter->second.is_repeated);\n  return !iter->second.is_cleared;\n}\n\nint ExtensionSet::NumExtensions() const {\n  int result = 0;\n  for (ExtensionMap::const_iterator iter = extensions_.begin();\n       iter != extensions_.end(); ++iter) {\n    if (!iter->second.is_cleared) {\n      ++result;\n    }\n  }\n  return result;\n}\n\nint ExtensionSet::ExtensionSize(int number) const {\n  ExtensionMap::const_iterator iter = extensions_.find(number);\n  if (iter == extensions_.end()) return false;\n  return iter->second.GetSize();\n}\n\nFieldType ExtensionSet::ExtensionType(int number) const {\n  ExtensionMap::const_iterator iter = extensions_.find(number);\n  if (iter == extensions_.end()) {\n    GOOGLE_LOG(DFATAL) << \"Don't lookup extension types if they aren't present (1). \";\n    return 0;\n  }\n  if (iter->second.is_cleared) {\n    GOOGLE_LOG(DFATAL) << \"Don't lookup extension types if they aren't present (2). \";\n  }\n  return iter->second.type;\n}\n\nvoid ExtensionSet::ClearExtension(int number) {\n  ExtensionMap::iterator iter = extensions_.find(number);\n  if (iter == extensions_.end()) return;\n  iter->second.Clear();\n}\n\n// ===================================================================\n// Field accessors\n\nnamespace {\n\nenum Cardinality {\n  REPEATED,\n  OPTIONAL\n};\n\n}  // namespace\n\n#define GOOGLE_DCHECK_TYPE(EXTENSION, LABEL, CPPTYPE)                             \\\n  GOOGLE_DCHECK_EQ((EXTENSION).is_repeated ? REPEATED : OPTIONAL, LABEL);         \\\n  GOOGLE_DCHECK_EQ(cpp_type((EXTENSION).type), WireFormatLite::CPPTYPE_##CPPTYPE)\n\n// -------------------------------------------------------------------\n// Primitives\n\n#define PRIMITIVE_ACCESSORS(UPPERCASE, LOWERCASE, CAMELCASE)                   \\\n                                                                               \\\nLOWERCASE ExtensionSet::Get##CAMELCASE(int number,                             \\\n                                       LOWERCASE default_value) const {        \\\n  ExtensionMap::const_iterator iter = extensions_.find(number);                \\\n  if (iter == extensions_.end() || iter->second.is_cleared) {                  \\\n    return default_value;                                                      \\\n  } else {                                                                     \\\n    GOOGLE_DCHECK_TYPE(iter->second, OPTIONAL, UPPERCASE);                            \\\n    return iter->second.LOWERCASE##_value;                                     \\\n  }                                                                            \\\n}                                                                              \\\n                                                                               \\\nvoid ExtensionSet::Set##CAMELCASE(int number, FieldType type,                  \\\n                                  LOWERCASE value,                             \\\n                                  const FieldDescriptor* descriptor) {         \\\n  Extension* extension;                                                        \\\n  if (MaybeNewExtension(number, descriptor, &extension)) {                     \\\n    extension->type = type;                                                    \\\n    GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_##UPPERCASE); \\\n    extension->is_repeated = false;                                            \\\n  } else {                                                                     \\\n    GOOGLE_DCHECK_TYPE(*extension, OPTIONAL, UPPERCASE);                              \\\n  }                                                                            \\\n  extension->is_cleared = false;                                               \\\n  extension->LOWERCASE##_value = value;                                        \\\n}                                                                              \\\n                                                                               \\\nLOWERCASE ExtensionSet::GetRepeated##CAMELCASE(int number, int index) const {  \\\n  ExtensionMap::const_iterator iter = extensions_.find(number);                \\\n  GOOGLE_CHECK(iter != extensions_.end()) << \"Index out-of-bounds (field is empty).\"; \\\n  GOOGLE_DCHECK_TYPE(iter->second, REPEATED, UPPERCASE);                              \\\n  return iter->second.repeated_##LOWERCASE##_value->Get(index);                \\\n}                                                                              \\\n                                                                               \\\nvoid ExtensionSet::SetRepeated##CAMELCASE(                                     \\\n    int number, int index, LOWERCASE value) {                                  \\\n  ExtensionMap::iterator iter = extensions_.find(number);                      \\\n  GOOGLE_CHECK(iter != extensions_.end()) << \"Index out-of-bounds (field is empty).\"; \\\n  GOOGLE_DCHECK_TYPE(iter->second, REPEATED, UPPERCASE);                              \\\n  iter->second.repeated_##LOWERCASE##_value->Set(index, value);                \\\n}                                                                              \\\n                                                                               \\\nvoid ExtensionSet::Add##CAMELCASE(int number, FieldType type,                  \\\n                                  bool packed, LOWERCASE value,                \\\n                                  const FieldDescriptor* descriptor) {         \\\n  Extension* extension;                                                        \\\n  if (MaybeNewExtension(number, descriptor, &extension)) {                     \\\n    extension->type = type;                                                    \\\n    GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_##UPPERCASE); \\\n    extension->is_repeated = true;                                             \\\n    extension->is_packed = packed;                                             \\\n    extension->repeated_##LOWERCASE##_value =                                  \\\n      Arena::CreateMessage<RepeatedField<LOWERCASE> >(arena_);                 \\\n  } else {                                                                     \\\n    GOOGLE_DCHECK_TYPE(*extension, REPEATED, UPPERCASE);                              \\\n    GOOGLE_DCHECK_EQ(extension->is_packed, packed);                                   \\\n  }                                                                            \\\n  extension->repeated_##LOWERCASE##_value->Add(value);                         \\\n}\n\nPRIMITIVE_ACCESSORS( INT32,  int32,  Int32)\nPRIMITIVE_ACCESSORS( INT64,  int64,  Int64)\nPRIMITIVE_ACCESSORS(UINT32, uint32, UInt32)\nPRIMITIVE_ACCESSORS(UINT64, uint64, UInt64)\nPRIMITIVE_ACCESSORS( FLOAT,  float,  Float)\nPRIMITIVE_ACCESSORS(DOUBLE, double, Double)\nPRIMITIVE_ACCESSORS(  BOOL,   bool,   Bool)\n\n#undef PRIMITIVE_ACCESSORS\n\nconst void* ExtensionSet::GetRawRepeatedField(int number,\n                                              const void* default_value) const {\n  ExtensionMap::const_iterator iter = extensions_.find(number);\n  if (iter == extensions_.end()) {\n    return default_value;\n  }\n  // We assume that all the RepeatedField<>* pointers have the same\n  // size and alignment within the anonymous union in Extension.\n  return iter->second.repeated_int32_value;\n}\n\nvoid* ExtensionSet::MutableRawRepeatedField(int number, FieldType field_type,\n                                            bool packed,\n                                            const FieldDescriptor* desc) {\n  Extension* extension;\n\n  // We instantiate an empty Repeated{,Ptr}Field if one doesn't exist for this\n  // extension.\n  if (MaybeNewExtension(number, desc, &extension)) {\n    extension->is_repeated = true;\n    extension->type = field_type;\n    extension->is_packed = packed;\n\n    switch (WireFormatLite::FieldTypeToCppType(\n        static_cast<WireFormatLite::FieldType>(field_type))) {\n      case WireFormatLite::CPPTYPE_INT32:\n        extension->repeated_int32_value =\n            Arena::CreateMessage<RepeatedField<int32> >(arena_);\n        break;\n      case WireFormatLite::CPPTYPE_INT64:\n        extension->repeated_int64_value =\n            Arena::CreateMessage<RepeatedField<int64> >(arena_);\n        break;\n      case WireFormatLite::CPPTYPE_UINT32:\n        extension->repeated_uint32_value =\n            Arena::CreateMessage<RepeatedField<uint32> >(arena_);\n        break;\n      case WireFormatLite::CPPTYPE_UINT64:\n        extension->repeated_uint64_value =\n            Arena::CreateMessage<RepeatedField<uint64> >(arena_);\n        break;\n      case WireFormatLite::CPPTYPE_DOUBLE:\n        extension->repeated_double_value =\n            Arena::CreateMessage<RepeatedField<double> >(arena_);\n        break;\n      case WireFormatLite::CPPTYPE_FLOAT:\n        extension->repeated_float_value =\n            Arena::CreateMessage<RepeatedField<float> >(arena_);\n        break;\n      case WireFormatLite::CPPTYPE_BOOL:\n        extension->repeated_bool_value =\n            Arena::CreateMessage<RepeatedField<bool> >(arena_);\n        break;\n      case WireFormatLite::CPPTYPE_ENUM:\n        extension->repeated_enum_value =\n            Arena::CreateMessage<RepeatedField<int> >(arena_);\n        break;\n      case WireFormatLite::CPPTYPE_STRING:\n        extension->repeated_string_value =\n            Arena::CreateMessage<RepeatedPtrField< ::std::string> >(arena_);\n        break;\n      case WireFormatLite::CPPTYPE_MESSAGE:\n        extension->repeated_message_value =\n            Arena::CreateMessage<RepeatedPtrField<MessageLite> >(arena_);\n        break;\n    }\n  }\n\n  // We assume that all the RepeatedField<>* pointers have the same\n  // size and alignment within the anonymous union in Extension.\n  return extension->repeated_int32_value;\n}\n\n// Compatible version using old call signature. Does not create extensions when\n// the don't already exist; instead, just GOOGLE_CHECK-fails.\nvoid* ExtensionSet::MutableRawRepeatedField(int number) {\n  ExtensionMap::iterator iter = extensions_.find(number);\n  GOOGLE_CHECK(iter == extensions_.end()) << \"Extension not found.\";\n  // We assume that all the RepeatedField<>* pointers have the same\n  // size and alignment within the anonymous union in Extension.\n  return iter->second.repeated_int32_value;\n}\n\n\n// -------------------------------------------------------------------\n// Enums\n\nint ExtensionSet::GetEnum(int number, int default_value) const {\n  ExtensionMap::const_iterator iter = extensions_.find(number);\n  if (iter == extensions_.end() || iter->second.is_cleared) {\n    // Not present.  Return the default value.\n    return default_value;\n  } else {\n    GOOGLE_DCHECK_TYPE(iter->second, OPTIONAL, ENUM);\n    return iter->second.enum_value;\n  }\n}\n\nvoid ExtensionSet::SetEnum(int number, FieldType type, int value,\n                           const FieldDescriptor* descriptor) {\n  Extension* extension;\n  if (MaybeNewExtension(number, descriptor, &extension)) {\n    extension->type = type;\n    GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_ENUM);\n    extension->is_repeated = false;\n  } else {\n    GOOGLE_DCHECK_TYPE(*extension, OPTIONAL, ENUM);\n  }\n  extension->is_cleared = false;\n  extension->enum_value = value;\n}\n\nint ExtensionSet::GetRepeatedEnum(int number, int index) const {\n  ExtensionMap::const_iterator iter = extensions_.find(number);\n  GOOGLE_CHECK(iter != extensions_.end()) << \"Index out-of-bounds (field is empty).\";\n  GOOGLE_DCHECK_TYPE(iter->second, REPEATED, ENUM);\n  return iter->second.repeated_enum_value->Get(index);\n}\n\nvoid ExtensionSet::SetRepeatedEnum(int number, int index, int value) {\n  ExtensionMap::iterator iter = extensions_.find(number);\n  GOOGLE_CHECK(iter != extensions_.end()) << \"Index out-of-bounds (field is empty).\";\n  GOOGLE_DCHECK_TYPE(iter->second, REPEATED, ENUM);\n  iter->second.repeated_enum_value->Set(index, value);\n}\n\nvoid ExtensionSet::AddEnum(int number, FieldType type,\n                           bool packed, int value,\n                           const FieldDescriptor* descriptor) {\n  Extension* extension;\n  if (MaybeNewExtension(number, descriptor, &extension)) {\n    extension->type = type;\n    GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_ENUM);\n    extension->is_repeated = true;\n    extension->is_packed = packed;\n    extension->repeated_enum_value =\n        Arena::CreateMessage<RepeatedField<int> >(arena_);\n  } else {\n    GOOGLE_DCHECK_TYPE(*extension, REPEATED, ENUM);\n    GOOGLE_DCHECK_EQ(extension->is_packed, packed);\n  }\n  extension->repeated_enum_value->Add(value);\n}\n\n// -------------------------------------------------------------------\n// Strings\n\nconst string& ExtensionSet::GetString(int number,\n                                      const string& default_value) const {\n  ExtensionMap::const_iterator iter = extensions_.find(number);\n  if (iter == extensions_.end() || iter->second.is_cleared) {\n    // Not present.  Return the default value.\n    return default_value;\n  } else {\n    GOOGLE_DCHECK_TYPE(iter->second, OPTIONAL, STRING);\n    return *iter->second.string_value;\n  }\n}\n\nstring* ExtensionSet::MutableString(int number, FieldType type,\n                                    const FieldDescriptor* descriptor) {\n  Extension* extension;\n  if (MaybeNewExtension(number, descriptor, &extension)) {\n    extension->type = type;\n    GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_STRING);\n    extension->is_repeated = false;\n    extension->string_value = Arena::Create<string>(arena_);\n  } else {\n    GOOGLE_DCHECK_TYPE(*extension, OPTIONAL, STRING);\n  }\n  extension->is_cleared = false;\n  return extension->string_value;\n}\n\nconst string& ExtensionSet::GetRepeatedString(int number, int index) const {\n  ExtensionMap::const_iterator iter = extensions_.find(number);\n  GOOGLE_CHECK(iter != extensions_.end()) << \"Index out-of-bounds (field is empty).\";\n  GOOGLE_DCHECK_TYPE(iter->second, REPEATED, STRING);\n  return iter->second.repeated_string_value->Get(index);\n}\n\nstring* ExtensionSet::MutableRepeatedString(int number, int index) {\n  ExtensionMap::iterator iter = extensions_.find(number);\n  GOOGLE_CHECK(iter != extensions_.end()) << \"Index out-of-bounds (field is empty).\";\n  GOOGLE_DCHECK_TYPE(iter->second, REPEATED, STRING);\n  return iter->second.repeated_string_value->Mutable(index);\n}\n\nstring* ExtensionSet::AddString(int number, FieldType type,\n                                const FieldDescriptor* descriptor) {\n  Extension* extension;\n  if (MaybeNewExtension(number, descriptor, &extension)) {\n    extension->type = type;\n    GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_STRING);\n    extension->is_repeated = true;\n    extension->is_packed = false;\n    extension->repeated_string_value =\n        Arena::CreateMessage<RepeatedPtrField<string> >(arena_);\n  } else {\n    GOOGLE_DCHECK_TYPE(*extension, REPEATED, STRING);\n  }\n  return extension->repeated_string_value->Add();\n}\n\n// -------------------------------------------------------------------\n// Messages\n\nconst MessageLite& ExtensionSet::GetMessage(\n    int number, const MessageLite& default_value) const {\n  ExtensionMap::const_iterator iter = extensions_.find(number);\n  if (iter == extensions_.end()) {\n    // Not present.  Return the default value.\n    return default_value;\n  } else {\n    GOOGLE_DCHECK_TYPE(iter->second, OPTIONAL, MESSAGE);\n    if (iter->second.is_lazy) {\n      return iter->second.lazymessage_value->GetMessage(default_value);\n    } else {\n      return *iter->second.message_value;\n    }\n  }\n}\n\n// Defined in extension_set_heavy.cc.\n// const MessageLite& ExtensionSet::GetMessage(int number,\n//                                             const Descriptor* message_type,\n//                                             MessageFactory* factory) const\n\nMessageLite* ExtensionSet::MutableMessage(int number, FieldType type,\n                                          const MessageLite& prototype,\n                                          const FieldDescriptor* descriptor) {\n  Extension* extension;\n  if (MaybeNewExtension(number, descriptor, &extension)) {\n    extension->type = type;\n    GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE);\n    extension->is_repeated = false;\n    extension->is_lazy = false;\n    extension->message_value = prototype.New(arena_);\n    extension->is_cleared = false;\n    return extension->message_value;\n  } else {\n    GOOGLE_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE);\n    extension->is_cleared = false;\n    if (extension->is_lazy) {\n      return extension->lazymessage_value->MutableMessage(prototype);\n    } else {\n      return extension->message_value;\n    }\n  }\n}\n\n// Defined in extension_set_heavy.cc.\n// MessageLite* ExtensionSet::MutableMessage(int number, FieldType type,\n//                                           const Descriptor* message_type,\n//                                           MessageFactory* factory)\n\nvoid ExtensionSet::SetAllocatedMessage(int number, FieldType type,\n                                       const FieldDescriptor* descriptor,\n                                       MessageLite* message) {\n  if (message == NULL) {\n    ClearExtension(number);\n    return;\n  }\n  ::google::protobuf::Arena* message_arena = message->GetArena();\n  Extension* extension;\n  if (MaybeNewExtension(number, descriptor, &extension)) {\n    extension->type = type;\n    GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE);\n    extension->is_repeated = false;\n    extension->is_lazy = false;\n    if (message_arena == arena_) {\n      extension->message_value = message;\n    } else if (message_arena == NULL) {\n      extension->message_value = message;\n      arena_->Own(message);  // not NULL because not equal to message_arena\n    } else {\n      extension->message_value = message->New(arena_);\n      extension->message_value->CheckTypeAndMergeFrom(*message);\n    }\n  } else {\n    GOOGLE_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE);\n    if (extension->is_lazy) {\n      extension->lazymessage_value->SetAllocatedMessage(message);\n    } else {\n      if (arena_ == NULL) {\n        delete extension->message_value;\n      }\n      if (message_arena == arena_) {\n        extension->message_value = message;\n      } else if (message_arena == NULL) {\n        extension->message_value = message;\n        arena_->Own(message);  // not NULL because not equal to message_arena\n      } else {\n        extension->message_value = message->New(arena_);\n        extension->message_value->CheckTypeAndMergeFrom(*message);\n      }\n    }\n  }\n  extension->is_cleared = false;\n}\n\nvoid ExtensionSet::UnsafeArenaSetAllocatedMessage(\n    int number, FieldType type, const FieldDescriptor* descriptor,\n    MessageLite* message) {\n  if (message == NULL) {\n    ClearExtension(number);\n    return;\n  }\n  Extension* extension;\n  if (MaybeNewExtension(number, descriptor, &extension)) {\n    extension->type = type;\n    GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE);\n    extension->is_repeated = false;\n    extension->is_lazy = false;\n    extension->message_value = message;\n  } else {\n    GOOGLE_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE);\n    if (extension->is_lazy) {\n      extension->lazymessage_value->UnsafeArenaSetAllocatedMessage(message);\n    } else {\n      if (arena_ == NULL) {\n        delete extension->message_value;\n      }\n      extension->message_value = message;\n    }\n  }\n  extension->is_cleared = false;\n}\n\n\nMessageLite* ExtensionSet::ReleaseMessage(int number,\n                                          const MessageLite& prototype) {\n  ExtensionMap::iterator iter = extensions_.find(number);\n  if (iter == extensions_.end()) {\n    // Not present.  Return NULL.\n    return NULL;\n  } else {\n    GOOGLE_DCHECK_TYPE(iter->second, OPTIONAL, MESSAGE);\n    MessageLite* ret = NULL;\n    if (iter->second.is_lazy) {\n      ret = iter->second.lazymessage_value->ReleaseMessage(prototype);\n      if (arena_ == NULL) {\n        delete iter->second.lazymessage_value;\n      }\n    } else {\n      if (arena_ == NULL) {\n        ret = iter->second.message_value;\n      } else {\n        // ReleaseMessage() always returns a heap-allocated message, and we are\n        // on an arena, so we need to make a copy of this message to return.\n        ret = (iter->second.message_value)->New();\n        ret->CheckTypeAndMergeFrom(*iter->second.message_value);\n      }\n    }\n    extensions_.erase(number);\n    return ret;\n  }\n}\n\nMessageLite* ExtensionSet::UnsafeArenaReleaseMessage(\n    int number, const MessageLite& prototype) {\n  ExtensionMap::iterator iter = extensions_.find(number);\n  if (iter == extensions_.end()) {\n    // Not present.  Return NULL.\n    return NULL;\n  } else {\n    GOOGLE_DCHECK_TYPE(iter->second, OPTIONAL, MESSAGE);\n    MessageLite* ret = NULL;\n    if (iter->second.is_lazy) {\n      ret =\n        iter->second.lazymessage_value->UnsafeArenaReleaseMessage(prototype);\n      if (arena_ == NULL) {\n        delete iter->second.lazymessage_value;\n      }\n    } else {\n      ret = iter->second.message_value;\n    }\n    extensions_.erase(number);\n    return ret;\n  }\n}\n\n// Defined in extension_set_heavy.cc.\n// MessageLite* ExtensionSet::ReleaseMessage(const FieldDescriptor* descriptor,\n//                                           MessageFactory* factory);\n\nconst MessageLite& ExtensionSet::GetRepeatedMessage(\n    int number, int index) const {\n  ExtensionMap::const_iterator iter = extensions_.find(number);\n  GOOGLE_CHECK(iter != extensions_.end()) << \"Index out-of-bounds (field is empty).\";\n  GOOGLE_DCHECK_TYPE(iter->second, REPEATED, MESSAGE);\n  return iter->second.repeated_message_value->Get(index);\n}\n\nMessageLite* ExtensionSet::MutableRepeatedMessage(int number, int index) {\n  ExtensionMap::iterator iter = extensions_.find(number);\n  GOOGLE_CHECK(iter != extensions_.end()) << \"Index out-of-bounds (field is empty).\";\n  GOOGLE_DCHECK_TYPE(iter->second, REPEATED, MESSAGE);\n  return iter->second.repeated_message_value->Mutable(index);\n}\n\nMessageLite* ExtensionSet::AddMessage(int number, FieldType type,\n                                      const MessageLite& prototype,\n                                      const FieldDescriptor* descriptor) {\n  Extension* extension;\n  if (MaybeNewExtension(number, descriptor, &extension)) {\n    extension->type = type;\n    GOOGLE_DCHECK_EQ(cpp_type(extension->type), WireFormatLite::CPPTYPE_MESSAGE);\n    extension->is_repeated = true;\n    extension->repeated_message_value =\n        Arena::CreateMessage<RepeatedPtrField<MessageLite> >(arena_);\n  } else {\n    GOOGLE_DCHECK_TYPE(*extension, REPEATED, MESSAGE);\n  }\n\n  // RepeatedPtrField<MessageLite> does not know how to Add() since it cannot\n  // allocate an abstract object, so we have to be tricky.\n  MessageLite* result = extension->repeated_message_value\n      ->AddFromCleared<GenericTypeHandler<MessageLite> >();\n  if (result == NULL) {\n    result = prototype.New(arena_);\n    extension->repeated_message_value->AddAllocated(result);\n  }\n  return result;\n}\n\n// Defined in extension_set_heavy.cc.\n// MessageLite* ExtensionSet::AddMessage(int number, FieldType type,\n//                                       const Descriptor* message_type,\n//                                       MessageFactory* factory)\n\n#undef GOOGLE_DCHECK_TYPE\n\nvoid ExtensionSet::RemoveLast(int number) {\n  ExtensionMap::iterator iter = extensions_.find(number);\n  GOOGLE_CHECK(iter != extensions_.end()) << \"Index out-of-bounds (field is empty).\";\n\n  Extension* extension = &iter->second;\n  GOOGLE_DCHECK(extension->is_repeated);\n\n  switch(cpp_type(extension->type)) {\n    case WireFormatLite::CPPTYPE_INT32:\n      extension->repeated_int32_value->RemoveLast();\n      break;\n    case WireFormatLite::CPPTYPE_INT64:\n      extension->repeated_int64_value->RemoveLast();\n      break;\n    case WireFormatLite::CPPTYPE_UINT32:\n      extension->repeated_uint32_value->RemoveLast();\n      break;\n    case WireFormatLite::CPPTYPE_UINT64:\n      extension->repeated_uint64_value->RemoveLast();\n      break;\n    case WireFormatLite::CPPTYPE_FLOAT:\n      extension->repeated_float_value->RemoveLast();\n      break;\n    case WireFormatLite::CPPTYPE_DOUBLE:\n      extension->repeated_double_value->RemoveLast();\n      break;\n    case WireFormatLite::CPPTYPE_BOOL:\n      extension->repeated_bool_value->RemoveLast();\n      break;\n    case WireFormatLite::CPPTYPE_ENUM:\n      extension->repeated_enum_value->RemoveLast();\n      break;\n    case WireFormatLite::CPPTYPE_STRING:\n      extension->repeated_string_value->RemoveLast();\n      break;\n    case WireFormatLite::CPPTYPE_MESSAGE:\n      extension->repeated_message_value->RemoveLast();\n      break;\n  }\n}\n\nMessageLite* ExtensionSet::ReleaseLast(int number) {\n  ExtensionMap::iterator iter = extensions_.find(number);\n  GOOGLE_CHECK(iter != extensions_.end()) << \"Index out-of-bounds (field is empty).\";\n\n  Extension* extension = &iter->second;\n  GOOGLE_DCHECK(extension->is_repeated);\n  GOOGLE_DCHECK(cpp_type(extension->type) == WireFormatLite::CPPTYPE_MESSAGE);\n  return extension->repeated_message_value->ReleaseLast();\n}\n\nvoid ExtensionSet::SwapElements(int number, int index1, int index2) {\n  ExtensionMap::iterator iter = extensions_.find(number);\n  GOOGLE_CHECK(iter != extensions_.end()) << \"Index out-of-bounds (field is empty).\";\n\n  Extension* extension = &iter->second;\n  GOOGLE_DCHECK(extension->is_repeated);\n\n  switch(cpp_type(extension->type)) {\n    case WireFormatLite::CPPTYPE_INT32:\n      extension->repeated_int32_value->SwapElements(index1, index2);\n      break;\n    case WireFormatLite::CPPTYPE_INT64:\n      extension->repeated_int64_value->SwapElements(index1, index2);\n      break;\n    case WireFormatLite::CPPTYPE_UINT32:\n      extension->repeated_uint32_value->SwapElements(index1, index2);\n      break;\n    case WireFormatLite::CPPTYPE_UINT64:\n      extension->repeated_uint64_value->SwapElements(index1, index2);\n      break;\n    case WireFormatLite::CPPTYPE_FLOAT:\n      extension->repeated_float_value->SwapElements(index1, index2);\n      break;\n    case WireFormatLite::CPPTYPE_DOUBLE:\n      extension->repeated_double_value->SwapElements(index1, index2);\n      break;\n    case WireFormatLite::CPPTYPE_BOOL:\n      extension->repeated_bool_value->SwapElements(index1, index2);\n      break;\n    case WireFormatLite::CPPTYPE_ENUM:\n      extension->repeated_enum_value->SwapElements(index1, index2);\n      break;\n    case WireFormatLite::CPPTYPE_STRING:\n      extension->repeated_string_value->SwapElements(index1, index2);\n      break;\n    case WireFormatLite::CPPTYPE_MESSAGE:\n      extension->repeated_message_value->SwapElements(index1, index2);\n      break;\n  }\n}\n\n// ===================================================================\n\nvoid ExtensionSet::Clear() {\n  for (ExtensionMap::iterator iter = extensions_.begin();\n       iter != extensions_.end(); ++iter) {\n    iter->second.Clear();\n  }\n}\n\nvoid ExtensionSet::MergeFrom(const ExtensionSet& other) {\n  for (ExtensionMap::const_iterator iter = other.extensions_.begin();\n       iter != other.extensions_.end(); ++iter) {\n    const Extension& other_extension = iter->second;\n    InternalExtensionMergeFrom(iter->first, other_extension);\n  }\n}\n\nvoid ExtensionSet::InternalExtensionMergeFrom(\n  int number, const Extension& other_extension) {\n  if (other_extension.is_repeated) {\n    Extension* extension;\n    bool is_new = MaybeNewExtension(number, other_extension.descriptor,\n                                    &extension);\n    if (is_new) {\n      // Extension did not already exist in set.\n      extension->type = other_extension.type;\n      extension->is_packed = other_extension.is_packed;\n      extension->is_repeated = true;\n    } else {\n      GOOGLE_DCHECK_EQ(extension->type, other_extension.type);\n      GOOGLE_DCHECK_EQ(extension->is_packed, other_extension.is_packed);\n      GOOGLE_DCHECK(extension->is_repeated);\n    }\n\n    switch (cpp_type(other_extension.type)) {\n#define HANDLE_TYPE(UPPERCASE, LOWERCASE, REPEATED_TYPE)                    \\\n      case WireFormatLite::CPPTYPE_##UPPERCASE:                             \\\n        if (is_new) {                                                       \\\n          extension->repeated_##LOWERCASE##_value =                         \\\n            Arena::CreateMessage<REPEATED_TYPE >(arena_);                   \\\n        }                                                                   \\\n        extension->repeated_##LOWERCASE##_value->MergeFrom(                 \\\n          *other_extension.repeated_##LOWERCASE##_value);                   \\\n        break;\n\n      HANDLE_TYPE(  INT32,   int32, RepeatedField   <  int32>);\n      HANDLE_TYPE(  INT64,   int64, RepeatedField   <  int64>);\n      HANDLE_TYPE( UINT32,  uint32, RepeatedField   < uint32>);\n      HANDLE_TYPE( UINT64,  uint64, RepeatedField   < uint64>);\n      HANDLE_TYPE(  FLOAT,   float, RepeatedField   <  float>);\n      HANDLE_TYPE( DOUBLE,  double, RepeatedField   < double>);\n      HANDLE_TYPE(   BOOL,    bool, RepeatedField   <   bool>);\n      HANDLE_TYPE(   ENUM,    enum, RepeatedField   <    int>);\n      HANDLE_TYPE( STRING,  string, RepeatedPtrField< string>);\n#undef HANDLE_TYPE\n\n      case WireFormatLite::CPPTYPE_MESSAGE:\n        if (is_new) {\n          extension->repeated_message_value =\n              Arena::CreateMessage<RepeatedPtrField<MessageLite> >(arena_);\n        }\n        // We can't call RepeatedPtrField<MessageLite>::MergeFrom() because\n        // it would attempt to allocate new objects.\n        RepeatedPtrField<MessageLite>* other_repeated_message =\n            other_extension.repeated_message_value;\n        for (int i = 0; i < other_repeated_message->size(); i++) {\n          const MessageLite& other_message = other_repeated_message->Get(i);\n          MessageLite* target = extension->repeated_message_value\n                   ->AddFromCleared<GenericTypeHandler<MessageLite> >();\n          if (target == NULL) {\n            target = other_message.New(arena_);\n            extension->repeated_message_value->AddAllocated(target);\n          }\n          target->CheckTypeAndMergeFrom(other_message);\n        }\n        break;\n    }\n  } else {\n    if (!other_extension.is_cleared) {\n      switch (cpp_type(other_extension.type)) {\n#define HANDLE_TYPE(UPPERCASE, LOWERCASE, CAMELCASE)                       \\\n        case WireFormatLite::CPPTYPE_##UPPERCASE:                          \\\n          Set##CAMELCASE(number, other_extension.type,                     \\\n                         other_extension.LOWERCASE##_value,                \\\n                         other_extension.descriptor);                      \\\n          break;\n\n        HANDLE_TYPE( INT32,  int32,  Int32);\n        HANDLE_TYPE( INT64,  int64,  Int64);\n        HANDLE_TYPE(UINT32, uint32, UInt32);\n        HANDLE_TYPE(UINT64, uint64, UInt64);\n        HANDLE_TYPE( FLOAT,  float,  Float);\n        HANDLE_TYPE(DOUBLE, double, Double);\n        HANDLE_TYPE(  BOOL,   bool,   Bool);\n        HANDLE_TYPE(  ENUM,   enum,   Enum);\n#undef HANDLE_TYPE\n        case WireFormatLite::CPPTYPE_STRING:\n          SetString(number, other_extension.type,\n                    *other_extension.string_value,\n                    other_extension.descriptor);\n          break;\n        case WireFormatLite::CPPTYPE_MESSAGE: {\n          Extension* extension;\n          bool is_new = MaybeNewExtension(number,\n                                          other_extension.descriptor,\n                                          &extension);\n          if (is_new) {\n            extension->type = other_extension.type;\n            extension->is_packed = other_extension.is_packed;\n            extension->is_repeated = false;\n            if (other_extension.is_lazy) {\n              extension->is_lazy = true;\n              extension->lazymessage_value =\n                  other_extension.lazymessage_value->New(arena_);\n              extension->lazymessage_value->MergeFrom(\n                  *other_extension.lazymessage_value);\n            } else {\n              extension->is_lazy = false;\n              extension->message_value =\n                  other_extension.message_value->New(arena_);\n              extension->message_value->CheckTypeAndMergeFrom(\n                  *other_extension.message_value);\n            }\n          } else {\n            GOOGLE_DCHECK_EQ(extension->type, other_extension.type);\n            GOOGLE_DCHECK_EQ(extension->is_packed,other_extension.is_packed);\n            GOOGLE_DCHECK(!extension->is_repeated);\n            if (other_extension.is_lazy) {\n              if (extension->is_lazy) {\n                extension->lazymessage_value->MergeFrom(\n                    *other_extension.lazymessage_value);\n              } else {\n                extension->message_value->CheckTypeAndMergeFrom(\n                    other_extension.lazymessage_value->GetMessage(\n                        *extension->message_value));\n              }\n            } else {\n              if (extension->is_lazy) {\n                extension->lazymessage_value->MutableMessage(\n                    *other_extension.message_value)->CheckTypeAndMergeFrom(\n                        *other_extension.message_value);\n              } else {\n                extension->message_value->CheckTypeAndMergeFrom(\n                    *other_extension.message_value);\n              }\n            }\n          }\n          extension->is_cleared = false;\n          break;\n        }\n      }\n    }\n  }\n}\n\nvoid ExtensionSet::Swap(ExtensionSet* x) {\n  if (GetArenaNoVirtual() == x->GetArenaNoVirtual()) {\n    extensions_.swap(x->extensions_);\n  } else {\n    // TODO(cfallin, rohananil): We maybe able to optimize a case where we are\n    // swapping from heap to arena-allocated extension set, by just Own()'ing\n    // the extensions.\n    ExtensionSet extension_set;\n    extension_set.MergeFrom(*x);\n    x->Clear();\n    x->MergeFrom(*this);\n    Clear();\n    MergeFrom(extension_set);\n  }\n}\n\nvoid ExtensionSet::SwapExtension(ExtensionSet* other,\n                                 int number) {\n  if (this == other) return;\n  ExtensionMap::iterator this_iter = extensions_.find(number);\n  ExtensionMap::iterator other_iter = other->extensions_.find(number);\n\n  if (this_iter == extensions_.end() &&\n      other_iter == other->extensions_.end()) {\n    return;\n  }\n\n  if (this_iter != extensions_.end() &&\n      other_iter != other->extensions_.end()) {\n    if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {\n      using std::swap;\n      swap(this_iter->second, other_iter->second);\n    } else {\n      // TODO(cfallin, rohananil): We could further optimize these cases,\n      // especially avoid creation of ExtensionSet, and move MergeFrom logic\n      // into Extensions itself (which takes arena as an argument).\n      // We do it this way to reuse the copy-across-arenas logic already\n      // implemented in ExtensionSet's MergeFrom.\n      ExtensionSet temp;\n      temp.InternalExtensionMergeFrom(number, other_iter->second);\n      ExtensionMap::iterator temp_iter = temp.extensions_.find(number);\n      other_iter->second.Clear();\n      other->InternalExtensionMergeFrom(number, this_iter->second);\n      this_iter->second.Clear();\n      InternalExtensionMergeFrom(number, temp_iter->second);\n    }\n    return;\n  }\n\n  if (this_iter == extensions_.end()) {\n    if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {\n      extensions_.insert(std::make_pair(number, other_iter->second));\n    } else {\n      InternalExtensionMergeFrom(number, other_iter->second);\n    }\n    other->extensions_.erase(number);\n    return;\n  }\n\n  if (other_iter == other->extensions_.end()) {\n    if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {\n      other->extensions_.insert(std::make_pair(number, this_iter->second));\n    } else {\n      other->InternalExtensionMergeFrom(number, this_iter->second);\n    }\n    extensions_.erase(number);\n    return;\n  }\n}\n\nbool ExtensionSet::IsInitialized() const {\n  // Extensions are never required.  However, we need to check that all\n  // embedded messages are initialized.\n  for (ExtensionMap::const_iterator iter = extensions_.begin();\n       iter != extensions_.end(); ++iter) {\n    const Extension& extension = iter->second;\n    if (cpp_type(extension.type) == WireFormatLite::CPPTYPE_MESSAGE) {\n      if (extension.is_repeated) {\n        for (int i = 0; i < extension.repeated_message_value->size(); i++) {\n          if (!extension.repeated_message_value->Get(i).IsInitialized()) {\n            return false;\n          }\n        }\n      } else {\n        if (!extension.is_cleared) {\n          if (extension.is_lazy) {\n            if (!extension.lazymessage_value->IsInitialized()) return false;\n          } else {\n            if (!extension.message_value->IsInitialized()) return false;\n          }\n        }\n      }\n    }\n  }\n\n  return true;\n}\n\nbool ExtensionSet::FindExtensionInfoFromTag(\n    uint32 tag, ExtensionFinder* extension_finder, int* field_number,\n    ExtensionInfo* extension, bool* was_packed_on_wire) {\n  *field_number = WireFormatLite::GetTagFieldNumber(tag);\n  WireFormatLite::WireType wire_type = WireFormatLite::GetTagWireType(tag);\n  return FindExtensionInfoFromFieldNumber(wire_type, *field_number,\n                                          extension_finder, extension,\n                                          was_packed_on_wire);\n}\n\nbool ExtensionSet::FindExtensionInfoFromFieldNumber(\n    int wire_type, int field_number, ExtensionFinder* extension_finder,\n    ExtensionInfo* extension, bool* was_packed_on_wire) {\n  if (!extension_finder->Find(field_number, extension)) {\n    return false;\n  }\n\n  WireFormatLite::WireType expected_wire_type =\n      WireFormatLite::WireTypeForFieldType(real_type(extension->type));\n\n  // Check if this is a packed field.\n  *was_packed_on_wire = false;\n  if (extension->is_repeated &&\n      wire_type == WireFormatLite::WIRETYPE_LENGTH_DELIMITED &&\n      is_packable(expected_wire_type)) {\n    *was_packed_on_wire = true;\n    return true;\n  }\n  // Otherwise the wire type must match.\n  return expected_wire_type == wire_type;\n}\n\nbool ExtensionSet::ParseField(uint32 tag, io::CodedInputStream* input,\n                              ExtensionFinder* extension_finder,\n                              FieldSkipper* field_skipper) {\n  int number;\n  bool was_packed_on_wire;\n  ExtensionInfo extension;\n  if (!FindExtensionInfoFromTag(\n      tag, extension_finder, &number, &extension, &was_packed_on_wire)) {\n    return field_skipper->SkipField(input, tag);\n  } else {\n    return ParseFieldWithExtensionInfo(\n        number, was_packed_on_wire, extension, input, field_skipper);\n  }\n}\n\nbool ExtensionSet::ParseFieldWithExtensionInfo(\n    int number, bool was_packed_on_wire, const ExtensionInfo& extension,\n    io::CodedInputStream* input,\n    FieldSkipper* field_skipper) {\n  // Explicitly not read extension.is_packed, instead check whether the field\n  // was encoded in packed form on the wire.\n  if (was_packed_on_wire) {\n    uint32 size;\n    if (!input->ReadVarint32(&size)) return false;\n    io::CodedInputStream::Limit limit = input->PushLimit(size);\n\n    switch (extension.type) {\n#define HANDLE_TYPE(UPPERCASE, CPP_CAMELCASE, CPP_LOWERCASE)        \\\n      case WireFormatLite::TYPE_##UPPERCASE:                                   \\\n        while (input->BytesUntilLimit() > 0) {                                 \\\n          CPP_LOWERCASE value;                                                 \\\n          if (!WireFormatLite::ReadPrimitive<                                  \\\n                  CPP_LOWERCASE, WireFormatLite::TYPE_##UPPERCASE>(            \\\n                input, &value)) return false;                                  \\\n          Add##CPP_CAMELCASE(number, WireFormatLite::TYPE_##UPPERCASE,         \\\n                             extension.is_packed, value,                       \\\n                             extension.descriptor);                            \\\n        }                                                                      \\\n        break\n\n      HANDLE_TYPE(   INT32,  Int32,   int32);\n      HANDLE_TYPE(   INT64,  Int64,   int64);\n      HANDLE_TYPE(  UINT32, UInt32,  uint32);\n      HANDLE_TYPE(  UINT64, UInt64,  uint64);\n      HANDLE_TYPE(  SINT32,  Int32,   int32);\n      HANDLE_TYPE(  SINT64,  Int64,   int64);\n      HANDLE_TYPE( FIXED32, UInt32,  uint32);\n      HANDLE_TYPE( FIXED64, UInt64,  uint64);\n      HANDLE_TYPE(SFIXED32,  Int32,   int32);\n      HANDLE_TYPE(SFIXED64,  Int64,   int64);\n      HANDLE_TYPE(   FLOAT,  Float,   float);\n      HANDLE_TYPE(  DOUBLE, Double,  double);\n      HANDLE_TYPE(    BOOL,   Bool,    bool);\n#undef HANDLE_TYPE\n\n      case WireFormatLite::TYPE_ENUM:\n        while (input->BytesUntilLimit() > 0) {\n          int value;\n          if (!WireFormatLite::ReadPrimitive<int, WireFormatLite::TYPE_ENUM>(\n                  input, &value)) return false;\n          if (extension.enum_validity_check.func(\n                  extension.enum_validity_check.arg, value)) {\n            AddEnum(number, WireFormatLite::TYPE_ENUM, extension.is_packed,\n                    value, extension.descriptor);\n          } else {\n            // Invalid value.  Treat as unknown.\n            field_skipper->SkipUnknownEnum(number, value);\n          }\n        }\n        break;\n\n      case WireFormatLite::TYPE_STRING:\n      case WireFormatLite::TYPE_BYTES:\n      case WireFormatLite::TYPE_GROUP:\n      case WireFormatLite::TYPE_MESSAGE:\n        GOOGLE_LOG(FATAL) << \"Non-primitive types can't be packed.\";\n        break;\n    }\n\n    input->PopLimit(limit);\n  } else {\n    switch (extension.type) {\n#define HANDLE_TYPE(UPPERCASE, CPP_CAMELCASE, CPP_LOWERCASE)                   \\\n      case WireFormatLite::TYPE_##UPPERCASE: {                                 \\\n        CPP_LOWERCASE value;                                                   \\\n        if (!WireFormatLite::ReadPrimitive<                                    \\\n                CPP_LOWERCASE, WireFormatLite::TYPE_##UPPERCASE>(              \\\n               input, &value)) return false;                                   \\\n        if (extension.is_repeated) {                                           \\\n          Add##CPP_CAMELCASE(number, WireFormatLite::TYPE_##UPPERCASE,         \\\n                             extension.is_packed, value,                       \\\n                             extension.descriptor);                            \\\n        } else {                                                               \\\n          Set##CPP_CAMELCASE(number, WireFormatLite::TYPE_##UPPERCASE, value,  \\\n                             extension.descriptor);                            \\\n        }                                                                      \\\n      } break\n\n      HANDLE_TYPE(   INT32,  Int32,   int32);\n      HANDLE_TYPE(   INT64,  Int64,   int64);\n      HANDLE_TYPE(  UINT32, UInt32,  uint32);\n      HANDLE_TYPE(  UINT64, UInt64,  uint64);\n      HANDLE_TYPE(  SINT32,  Int32,   int32);\n      HANDLE_TYPE(  SINT64,  Int64,   int64);\n      HANDLE_TYPE( FIXED32, UInt32,  uint32);\n      HANDLE_TYPE( FIXED64, UInt64,  uint64);\n      HANDLE_TYPE(SFIXED32,  Int32,   int32);\n      HANDLE_TYPE(SFIXED64,  Int64,   int64);\n      HANDLE_TYPE(   FLOAT,  Float,   float);\n      HANDLE_TYPE(  DOUBLE, Double,  double);\n      HANDLE_TYPE(    BOOL,   Bool,    bool);\n#undef HANDLE_TYPE\n\n      case WireFormatLite::TYPE_ENUM: {\n        int value;\n        if (!WireFormatLite::ReadPrimitive<int, WireFormatLite::TYPE_ENUM>(\n                input, &value)) return false;\n\n        if (!extension.enum_validity_check.func(\n                extension.enum_validity_check.arg, value)) {\n          // Invalid value.  Treat as unknown.\n          field_skipper->SkipUnknownEnum(number, value);\n        } else if (extension.is_repeated) {\n          AddEnum(number, WireFormatLite::TYPE_ENUM, extension.is_packed, value,\n                  extension.descriptor);\n        } else {\n          SetEnum(number, WireFormatLite::TYPE_ENUM, value,\n                  extension.descriptor);\n        }\n        break;\n      }\n\n      case WireFormatLite::TYPE_STRING:  {\n        string* value = extension.is_repeated ?\n          AddString(number, WireFormatLite::TYPE_STRING, extension.descriptor) :\n          MutableString(number, WireFormatLite::TYPE_STRING,\n                        extension.descriptor);\n        if (!WireFormatLite::ReadString(input, value)) return false;\n        break;\n      }\n\n      case WireFormatLite::TYPE_BYTES:  {\n        string* value = extension.is_repeated ?\n          AddString(number, WireFormatLite::TYPE_BYTES, extension.descriptor) :\n          MutableString(number, WireFormatLite::TYPE_BYTES,\n                        extension.descriptor);\n        if (!WireFormatLite::ReadBytes(input, value)) return false;\n        break;\n      }\n\n      case WireFormatLite::TYPE_GROUP: {\n        MessageLite* value = extension.is_repeated ?\n            AddMessage(number, WireFormatLite::TYPE_GROUP,\n                       *extension.message_prototype, extension.descriptor) :\n            MutableMessage(number, WireFormatLite::TYPE_GROUP,\n                           *extension.message_prototype, extension.descriptor);\n        if (!WireFormatLite::ReadGroup(number, input, value)) return false;\n        break;\n      }\n\n      case WireFormatLite::TYPE_MESSAGE: {\n        MessageLite* value = extension.is_repeated ?\n            AddMessage(number, WireFormatLite::TYPE_MESSAGE,\n                       *extension.message_prototype, extension.descriptor) :\n            MutableMessage(number, WireFormatLite::TYPE_MESSAGE,\n                           *extension.message_prototype, extension.descriptor);\n        if (!WireFormatLite::ReadMessage(input, value)) return false;\n        break;\n      }\n    }\n  }\n\n  return true;\n}\n\nbool ExtensionSet::ParseField(uint32 tag, io::CodedInputStream* input,\n                              const MessageLite* containing_type) {\n  FieldSkipper skipper;\n  GeneratedExtensionFinder finder(containing_type);\n  return ParseField(tag, input, &finder, &skipper);\n}\n\nbool ExtensionSet::ParseField(uint32 tag, io::CodedInputStream* input,\n                              const MessageLite* containing_type,\n                              io::CodedOutputStream* unknown_fields) {\n  CodedOutputStreamFieldSkipper skipper(unknown_fields);\n  GeneratedExtensionFinder finder(containing_type);\n  return ParseField(tag, input, &finder, &skipper);\n}\n\n// Defined in extension_set_heavy.cc.\n// bool ExtensionSet::ParseField(uint32 tag, io::CodedInputStream* input,\n//                               const MessageLite* containing_type,\n//                               UnknownFieldSet* unknown_fields)\n\n// Defined in extension_set_heavy.cc.\n// bool ExtensionSet::ParseMessageSet(io::CodedInputStream* input,\n//                                    const MessageLite* containing_type,\n//                                    UnknownFieldSet* unknown_fields);\n\nvoid ExtensionSet::SerializeWithCachedSizes(\n    int start_field_number, int end_field_number,\n    io::CodedOutputStream* output) const {\n  ExtensionMap::const_iterator iter;\n  for (iter = extensions_.lower_bound(start_field_number);\n       iter != extensions_.end() && iter->first < end_field_number;\n       ++iter) {\n    iter->second.SerializeFieldWithCachedSizes(iter->first, output);\n  }\n}\n\nint ExtensionSet::ByteSize() const {\n  int total_size = 0;\n\n  for (ExtensionMap::const_iterator iter = extensions_.begin();\n       iter != extensions_.end(); ++iter) {\n    total_size += iter->second.ByteSize(iter->first);\n  }\n\n  return total_size;\n}\n\n// Defined in extension_set_heavy.cc.\n// int ExtensionSet::SpaceUsedExcludingSelf() const\n\nbool ExtensionSet::MaybeNewExtension(int number,\n                                     const FieldDescriptor* descriptor,\n                                     Extension** result) {\n  pair<ExtensionMap::iterator, bool> insert_result =\n      extensions_.insert(std::make_pair(number, Extension()));\n  *result = &insert_result.first->second;\n  (*result)->descriptor = descriptor;\n  return insert_result.second;\n}\n\n// ===================================================================\n// Methods of ExtensionSet::Extension\n\nvoid ExtensionSet::Extension::Clear() {\n  if (is_repeated) {\n    switch (cpp_type(type)) {\n#define HANDLE_TYPE(UPPERCASE, LOWERCASE)                          \\\n      case WireFormatLite::CPPTYPE_##UPPERCASE:                    \\\n        repeated_##LOWERCASE##_value->Clear();                     \\\n        break\n\n      HANDLE_TYPE(  INT32,   int32);\n      HANDLE_TYPE(  INT64,   int64);\n      HANDLE_TYPE( UINT32,  uint32);\n      HANDLE_TYPE( UINT64,  uint64);\n      HANDLE_TYPE(  FLOAT,   float);\n      HANDLE_TYPE( DOUBLE,  double);\n      HANDLE_TYPE(   BOOL,    bool);\n      HANDLE_TYPE(   ENUM,    enum);\n      HANDLE_TYPE( STRING,  string);\n      HANDLE_TYPE(MESSAGE, message);\n#undef HANDLE_TYPE\n    }\n  } else {\n    if (!is_cleared) {\n      switch (cpp_type(type)) {\n        case WireFormatLite::CPPTYPE_STRING:\n          string_value->clear();\n          break;\n        case WireFormatLite::CPPTYPE_MESSAGE:\n          if (is_lazy) {\n            lazymessage_value->Clear();\n          } else {\n            message_value->Clear();\n          }\n          break;\n        default:\n          // No need to do anything.  Get*() will return the default value\n          // as long as is_cleared is true and Set*() will overwrite the\n          // previous value.\n          break;\n      }\n\n      is_cleared = true;\n    }\n  }\n}\n\nvoid ExtensionSet::Extension::SerializeFieldWithCachedSizes(\n    int number,\n    io::CodedOutputStream* output) const {\n  if (is_repeated) {\n    if (is_packed) {\n      if (cached_size == 0) return;\n\n      WireFormatLite::WriteTag(number,\n          WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);\n      output->WriteVarint32(cached_size);\n\n      switch (real_type(type)) {\n#define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE)                        \\\n        case WireFormatLite::TYPE_##UPPERCASE:                              \\\n          for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) {  \\\n            WireFormatLite::Write##CAMELCASE##NoTag(                        \\\n              repeated_##LOWERCASE##_value->Get(i), output);                \\\n          }                                                                 \\\n          break\n\n        HANDLE_TYPE(   INT32,    Int32,   int32);\n        HANDLE_TYPE(   INT64,    Int64,   int64);\n        HANDLE_TYPE(  UINT32,   UInt32,  uint32);\n        HANDLE_TYPE(  UINT64,   UInt64,  uint64);\n        HANDLE_TYPE(  SINT32,   SInt32,   int32);\n        HANDLE_TYPE(  SINT64,   SInt64,   int64);\n        HANDLE_TYPE( FIXED32,  Fixed32,  uint32);\n        HANDLE_TYPE( FIXED64,  Fixed64,  uint64);\n        HANDLE_TYPE(SFIXED32, SFixed32,   int32);\n        HANDLE_TYPE(SFIXED64, SFixed64,   int64);\n        HANDLE_TYPE(   FLOAT,    Float,   float);\n        HANDLE_TYPE(  DOUBLE,   Double,  double);\n        HANDLE_TYPE(    BOOL,     Bool,    bool);\n        HANDLE_TYPE(    ENUM,     Enum,    enum);\n#undef HANDLE_TYPE\n\n        case WireFormatLite::TYPE_STRING:\n        case WireFormatLite::TYPE_BYTES:\n        case WireFormatLite::TYPE_GROUP:\n        case WireFormatLite::TYPE_MESSAGE:\n          GOOGLE_LOG(FATAL) << \"Non-primitive types can't be packed.\";\n          break;\n      }\n    } else {\n      switch (real_type(type)) {\n#define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE)                        \\\n        case WireFormatLite::TYPE_##UPPERCASE:                              \\\n          for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) {  \\\n            WireFormatLite::Write##CAMELCASE(number,                        \\\n              repeated_##LOWERCASE##_value->Get(i), output);                \\\n          }                                                                 \\\n          break\n\n        HANDLE_TYPE(   INT32,    Int32,   int32);\n        HANDLE_TYPE(   INT64,    Int64,   int64);\n        HANDLE_TYPE(  UINT32,   UInt32,  uint32);\n        HANDLE_TYPE(  UINT64,   UInt64,  uint64);\n        HANDLE_TYPE(  SINT32,   SInt32,   int32);\n        HANDLE_TYPE(  SINT64,   SInt64,   int64);\n        HANDLE_TYPE( FIXED32,  Fixed32,  uint32);\n        HANDLE_TYPE( FIXED64,  Fixed64,  uint64);\n        HANDLE_TYPE(SFIXED32, SFixed32,   int32);\n        HANDLE_TYPE(SFIXED64, SFixed64,   int64);\n        HANDLE_TYPE(   FLOAT,    Float,   float);\n        HANDLE_TYPE(  DOUBLE,   Double,  double);\n        HANDLE_TYPE(    BOOL,     Bool,    bool);\n        HANDLE_TYPE(  STRING,   String,  string);\n        HANDLE_TYPE(   BYTES,    Bytes,  string);\n        HANDLE_TYPE(    ENUM,     Enum,    enum);\n        HANDLE_TYPE(   GROUP,    Group, message);\n        HANDLE_TYPE( MESSAGE,  Message, message);\n#undef HANDLE_TYPE\n      }\n    }\n  } else if (!is_cleared) {\n    switch (real_type(type)) {\n#define HANDLE_TYPE(UPPERCASE, CAMELCASE, VALUE)                 \\\n      case WireFormatLite::TYPE_##UPPERCASE:                     \\\n        WireFormatLite::Write##CAMELCASE(number, VALUE, output); \\\n        break\n\n      HANDLE_TYPE(   INT32,    Int32,    int32_value);\n      HANDLE_TYPE(   INT64,    Int64,    int64_value);\n      HANDLE_TYPE(  UINT32,   UInt32,   uint32_value);\n      HANDLE_TYPE(  UINT64,   UInt64,   uint64_value);\n      HANDLE_TYPE(  SINT32,   SInt32,    int32_value);\n      HANDLE_TYPE(  SINT64,   SInt64,    int64_value);\n      HANDLE_TYPE( FIXED32,  Fixed32,   uint32_value);\n      HANDLE_TYPE( FIXED64,  Fixed64,   uint64_value);\n      HANDLE_TYPE(SFIXED32, SFixed32,    int32_value);\n      HANDLE_TYPE(SFIXED64, SFixed64,    int64_value);\n      HANDLE_TYPE(   FLOAT,    Float,    float_value);\n      HANDLE_TYPE(  DOUBLE,   Double,   double_value);\n      HANDLE_TYPE(    BOOL,     Bool,     bool_value);\n      HANDLE_TYPE(  STRING,   String,  *string_value);\n      HANDLE_TYPE(   BYTES,    Bytes,  *string_value);\n      HANDLE_TYPE(    ENUM,     Enum,     enum_value);\n      HANDLE_TYPE(   GROUP,    Group, *message_value);\n#undef HANDLE_TYPE\n      case WireFormatLite::TYPE_MESSAGE:\n        if (is_lazy) {\n          lazymessage_value->WriteMessage(number, output);\n        } else {\n          WireFormatLite::WriteMessage(number, *message_value, output);\n        }\n        break;\n    }\n  }\n}\n\nint ExtensionSet::Extension::ByteSize(int number) const {\n  int result = 0;\n\n  if (is_repeated) {\n    if (is_packed) {\n      switch (real_type(type)) {\n#define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE)                        \\\n        case WireFormatLite::TYPE_##UPPERCASE:                              \\\n          for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) {  \\\n            result += WireFormatLite::CAMELCASE##Size(                      \\\n              repeated_##LOWERCASE##_value->Get(i));                        \\\n          }                                                                 \\\n          break\n\n        HANDLE_TYPE(   INT32,    Int32,   int32);\n        HANDLE_TYPE(   INT64,    Int64,   int64);\n        HANDLE_TYPE(  UINT32,   UInt32,  uint32);\n        HANDLE_TYPE(  UINT64,   UInt64,  uint64);\n        HANDLE_TYPE(  SINT32,   SInt32,   int32);\n        HANDLE_TYPE(  SINT64,   SInt64,   int64);\n        HANDLE_TYPE(    ENUM,     Enum,    enum);\n#undef HANDLE_TYPE\n\n        // Stuff with fixed size.\n#define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE)                        \\\n        case WireFormatLite::TYPE_##UPPERCASE:                              \\\n          result += WireFormatLite::k##CAMELCASE##Size *                    \\\n                    repeated_##LOWERCASE##_value->size();                   \\\n          break\n        HANDLE_TYPE( FIXED32,  Fixed32, uint32);\n        HANDLE_TYPE( FIXED64,  Fixed64, uint64);\n        HANDLE_TYPE(SFIXED32, SFixed32,  int32);\n        HANDLE_TYPE(SFIXED64, SFixed64,  int64);\n        HANDLE_TYPE(   FLOAT,    Float,  float);\n        HANDLE_TYPE(  DOUBLE,   Double, double);\n        HANDLE_TYPE(    BOOL,     Bool,   bool);\n#undef HANDLE_TYPE\n\n        case WireFormatLite::TYPE_STRING:\n        case WireFormatLite::TYPE_BYTES:\n        case WireFormatLite::TYPE_GROUP:\n        case WireFormatLite::TYPE_MESSAGE:\n          GOOGLE_LOG(FATAL) << \"Non-primitive types can't be packed.\";\n          break;\n      }\n\n      cached_size = result;\n      if (result > 0) {\n        result += io::CodedOutputStream::VarintSize32(result);\n        result += io::CodedOutputStream::VarintSize32(\n            WireFormatLite::MakeTag(number,\n                WireFormatLite::WIRETYPE_LENGTH_DELIMITED));\n      }\n    } else {\n      int tag_size = WireFormatLite::TagSize(number, real_type(type));\n\n      switch (real_type(type)) {\n#define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE)                        \\\n        case WireFormatLite::TYPE_##UPPERCASE:                              \\\n          result += tag_size * repeated_##LOWERCASE##_value->size();        \\\n          for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) {  \\\n            result += WireFormatLite::CAMELCASE##Size(                      \\\n              repeated_##LOWERCASE##_value->Get(i));                        \\\n          }                                                                 \\\n          break\n\n        HANDLE_TYPE(   INT32,    Int32,   int32);\n        HANDLE_TYPE(   INT64,    Int64,   int64);\n        HANDLE_TYPE(  UINT32,   UInt32,  uint32);\n        HANDLE_TYPE(  UINT64,   UInt64,  uint64);\n        HANDLE_TYPE(  SINT32,   SInt32,   int32);\n        HANDLE_TYPE(  SINT64,   SInt64,   int64);\n        HANDLE_TYPE(  STRING,   String,  string);\n        HANDLE_TYPE(   BYTES,    Bytes,  string);\n        HANDLE_TYPE(    ENUM,     Enum,    enum);\n        HANDLE_TYPE(   GROUP,    Group, message);\n        HANDLE_TYPE( MESSAGE,  Message, message);\n#undef HANDLE_TYPE\n\n        // Stuff with fixed size.\n#define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE)                        \\\n        case WireFormatLite::TYPE_##UPPERCASE:                              \\\n          result += (tag_size + WireFormatLite::k##CAMELCASE##Size) *       \\\n                    repeated_##LOWERCASE##_value->size();                   \\\n          break\n        HANDLE_TYPE( FIXED32,  Fixed32, uint32);\n        HANDLE_TYPE( FIXED64,  Fixed64, uint64);\n        HANDLE_TYPE(SFIXED32, SFixed32,  int32);\n        HANDLE_TYPE(SFIXED64, SFixed64,  int64);\n        HANDLE_TYPE(   FLOAT,    Float,  float);\n        HANDLE_TYPE(  DOUBLE,   Double, double);\n        HANDLE_TYPE(    BOOL,     Bool,   bool);\n#undef HANDLE_TYPE\n      }\n    }\n  } else if (!is_cleared) {\n    result += WireFormatLite::TagSize(number, real_type(type));\n    switch (real_type(type)) {\n#define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE)                      \\\n      case WireFormatLite::TYPE_##UPPERCASE:                              \\\n        result += WireFormatLite::CAMELCASE##Size(LOWERCASE);             \\\n        break\n\n      HANDLE_TYPE(   INT32,    Int32,    int32_value);\n      HANDLE_TYPE(   INT64,    Int64,    int64_value);\n      HANDLE_TYPE(  UINT32,   UInt32,   uint32_value);\n      HANDLE_TYPE(  UINT64,   UInt64,   uint64_value);\n      HANDLE_TYPE(  SINT32,   SInt32,    int32_value);\n      HANDLE_TYPE(  SINT64,   SInt64,    int64_value);\n      HANDLE_TYPE(  STRING,   String,  *string_value);\n      HANDLE_TYPE(   BYTES,    Bytes,  *string_value);\n      HANDLE_TYPE(    ENUM,     Enum,     enum_value);\n      HANDLE_TYPE(   GROUP,    Group, *message_value);\n#undef HANDLE_TYPE\n      case WireFormatLite::TYPE_MESSAGE: {\n        if (is_lazy) {\n          int size = lazymessage_value->ByteSize();\n          result += io::CodedOutputStream::VarintSize32(size) + size;\n        } else {\n          result += WireFormatLite::MessageSize(*message_value);\n        }\n        break;\n      }\n\n      // Stuff with fixed size.\n#define HANDLE_TYPE(UPPERCASE, CAMELCASE)                                 \\\n      case WireFormatLite::TYPE_##UPPERCASE:                              \\\n        result += WireFormatLite::k##CAMELCASE##Size;                     \\\n        break\n      HANDLE_TYPE( FIXED32,  Fixed32);\n      HANDLE_TYPE( FIXED64,  Fixed64);\n      HANDLE_TYPE(SFIXED32, SFixed32);\n      HANDLE_TYPE(SFIXED64, SFixed64);\n      HANDLE_TYPE(   FLOAT,    Float);\n      HANDLE_TYPE(  DOUBLE,   Double);\n      HANDLE_TYPE(    BOOL,     Bool);\n#undef HANDLE_TYPE\n    }\n  }\n\n  return result;\n}\n\nint ExtensionSet::Extension::GetSize() const {\n  GOOGLE_DCHECK(is_repeated);\n  switch (cpp_type(type)) {\n#define HANDLE_TYPE(UPPERCASE, LOWERCASE)                        \\\n    case WireFormatLite::CPPTYPE_##UPPERCASE:                    \\\n      return repeated_##LOWERCASE##_value->size()\n\n    HANDLE_TYPE(  INT32,   int32);\n    HANDLE_TYPE(  INT64,   int64);\n    HANDLE_TYPE( UINT32,  uint32);\n    HANDLE_TYPE( UINT64,  uint64);\n    HANDLE_TYPE(  FLOAT,   float);\n    HANDLE_TYPE( DOUBLE,  double);\n    HANDLE_TYPE(   BOOL,    bool);\n    HANDLE_TYPE(   ENUM,    enum);\n    HANDLE_TYPE( STRING,  string);\n    HANDLE_TYPE(MESSAGE, message);\n#undef HANDLE_TYPE\n  }\n\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n  return 0;\n}\n\n// This function deletes all allocated objects. This function should be only\n// called if the Extension was created with an arena.\nvoid ExtensionSet::Extension::Free() {\n  if (is_repeated) {\n    switch (cpp_type(type)) {\n#define HANDLE_TYPE(UPPERCASE, LOWERCASE)                          \\\n      case WireFormatLite::CPPTYPE_##UPPERCASE:                    \\\n        delete repeated_##LOWERCASE##_value;                       \\\n        break\n\n      HANDLE_TYPE(  INT32,   int32);\n      HANDLE_TYPE(  INT64,   int64);\n      HANDLE_TYPE( UINT32,  uint32);\n      HANDLE_TYPE( UINT64,  uint64);\n      HANDLE_TYPE(  FLOAT,   float);\n      HANDLE_TYPE( DOUBLE,  double);\n      HANDLE_TYPE(   BOOL,    bool);\n      HANDLE_TYPE(   ENUM,    enum);\n      HANDLE_TYPE( STRING,  string);\n      HANDLE_TYPE(MESSAGE, message);\n#undef HANDLE_TYPE\n    }\n  } else {\n    switch (cpp_type(type)) {\n      case WireFormatLite::CPPTYPE_STRING:\n        delete string_value;\n        break;\n      case WireFormatLite::CPPTYPE_MESSAGE:\n        if (is_lazy) {\n          delete lazymessage_value;\n        } else {\n          delete message_value;\n        }\n        break;\n      default:\n        break;\n    }\n  }\n}\n\n// Defined in extension_set_heavy.cc.\n// int ExtensionSet::Extension::SpaceUsedExcludingSelf() const\n\n// ==================================================================\n// Default repeated field instances for iterator-compatible accessors\n\nGOOGLE_PROTOBUF_DECLARE_ONCE(repeated_primitive_generic_type_traits_once_init_);\nGOOGLE_PROTOBUF_DECLARE_ONCE(repeated_string_type_traits_once_init_);\nGOOGLE_PROTOBUF_DECLARE_ONCE(repeated_message_generic_type_traits_once_init_);\n\nvoid RepeatedPrimitiveGenericTypeTraits::InitializeDefaultRepeatedFields() {\n  default_repeated_field_int32_ = new RepeatedField<int32>;\n  default_repeated_field_int64_ = new RepeatedField<int64>;\n  default_repeated_field_uint32_ = new RepeatedField<uint32>;\n  default_repeated_field_uint64_ = new RepeatedField<uint64>;\n  default_repeated_field_double_ = new RepeatedField<double>;\n  default_repeated_field_float_ = new RepeatedField<float>;\n  default_repeated_field_bool_ = new RepeatedField<bool>;\n  OnShutdown(&DestroyDefaultRepeatedFields);\n}\n\nvoid RepeatedPrimitiveGenericTypeTraits::DestroyDefaultRepeatedFields() {\n  delete default_repeated_field_int32_;\n  delete default_repeated_field_int64_;\n  delete default_repeated_field_uint32_;\n  delete default_repeated_field_uint64_;\n  delete default_repeated_field_double_;\n  delete default_repeated_field_float_;\n  delete default_repeated_field_bool_;\n}\n\nvoid RepeatedStringTypeTraits::InitializeDefaultRepeatedFields() {\n  default_repeated_field_ = new RepeatedFieldType;\n  OnShutdown(&DestroyDefaultRepeatedFields);\n}\n\nvoid RepeatedStringTypeTraits::DestroyDefaultRepeatedFields() {\n  delete default_repeated_field_;\n}\n\nvoid RepeatedMessageGenericTypeTraits::InitializeDefaultRepeatedFields() {\n  default_repeated_field_ = new RepeatedFieldType;\n  OnShutdown(&DestroyDefaultRepeatedFields);\n}\n\nvoid RepeatedMessageGenericTypeTraits::DestroyDefaultRepeatedFields() {\n  delete default_repeated_field_;\n}\n\nconst RepeatedField<int32>*\nRepeatedPrimitiveGenericTypeTraits::default_repeated_field_int32_ = NULL;\nconst RepeatedField<int64>*\nRepeatedPrimitiveGenericTypeTraits::default_repeated_field_int64_ = NULL;\nconst RepeatedField<uint32>*\nRepeatedPrimitiveGenericTypeTraits::default_repeated_field_uint32_ = NULL;\nconst RepeatedField<uint64>*\nRepeatedPrimitiveGenericTypeTraits::default_repeated_field_uint64_ = NULL;\nconst RepeatedField<double>*\nRepeatedPrimitiveGenericTypeTraits::default_repeated_field_double_ = NULL;\nconst RepeatedField<float>*\nRepeatedPrimitiveGenericTypeTraits::default_repeated_field_float_ = NULL;\nconst RepeatedField<bool>*\nRepeatedPrimitiveGenericTypeTraits::default_repeated_field_bool_ = NULL;\nconst RepeatedStringTypeTraits::RepeatedFieldType*\nRepeatedStringTypeTraits::default_repeated_field_ = NULL;\nconst RepeatedMessageGenericTypeTraits::RepeatedFieldType*\nRepeatedMessageGenericTypeTraits::default_repeated_field_ = NULL;\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/extension_set.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This header is logically internal, but is made public because it is used\n// from protocol-compiler-generated code, which may reside in other components.\n\n#ifndef GOOGLE_PROTOBUF_EXTENSION_SET_H__\n#define GOOGLE_PROTOBUF_EXTENSION_SET_H__\n\n#include <vector>\n#include <map>\n#include <utility>\n#include <string>\n\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/once.h>\n\n#include <google/protobuf/repeated_field.h>\n\nnamespace google {\n\nnamespace protobuf {\n  class Arena;\n  class Descriptor;                                    // descriptor.h\n  class FieldDescriptor;                               // descriptor.h\n  class DescriptorPool;                                // descriptor.h\n  class MessageLite;                                   // message_lite.h\n  class Message;                                       // message.h\n  class MessageFactory;                                // message.h\n  class UnknownFieldSet;                               // unknown_field_set.h\n  namespace io {\n    class CodedInputStream;                              // coded_stream.h\n    class CodedOutputStream;                             // coded_stream.h\n  }\n  namespace internal {\n    class FieldSkipper;                                  // wire_format_lite.h\n  }\n}\n\nnamespace protobuf {\nnamespace internal {\n\n// Used to store values of type WireFormatLite::FieldType without having to\n// #include wire_format_lite.h.  Also, ensures that we use only one byte to\n// store these values, which is important to keep the layout of\n// ExtensionSet::Extension small.\ntypedef uint8 FieldType;\n\n// A function which, given an integer value, returns true if the number\n// matches one of the defined values for the corresponding enum type.  This\n// is used with RegisterEnumExtension, below.\ntypedef bool EnumValidityFunc(int number);\n\n// Version of the above which takes an argument.  This is needed to deal with\n// extensions that are not compiled in.\ntypedef bool EnumValidityFuncWithArg(const void* arg, int number);\n\n// Information about a registered extension.\nstruct ExtensionInfo {\n  inline ExtensionInfo() {}\n  inline ExtensionInfo(FieldType type_param, bool isrepeated, bool ispacked)\n      : type(type_param), is_repeated(isrepeated), is_packed(ispacked),\n        descriptor(NULL) {}\n\n  FieldType type;\n  bool is_repeated;\n  bool is_packed;\n\n  struct EnumValidityCheck {\n    EnumValidityFuncWithArg* func;\n    const void* arg;\n  };\n\n  union {\n    EnumValidityCheck enum_validity_check;\n    const MessageLite* message_prototype;\n  };\n\n  // The descriptor for this extension, if one exists and is known.  May be\n  // NULL.  Must not be NULL if the descriptor for the extension does not\n  // live in the same pool as the descriptor for the containing type.\n  const FieldDescriptor* descriptor;\n};\n\n// Abstract interface for an object which looks up extension definitions.  Used\n// when parsing.\nclass LIBPROTOBUF_EXPORT ExtensionFinder {\n public:\n  virtual ~ExtensionFinder();\n\n  // Find the extension with the given containing type and number.\n  virtual bool Find(int number, ExtensionInfo* output) = 0;\n};\n\n// Implementation of ExtensionFinder which finds extensions defined in .proto\n// files which have been compiled into the binary.\nclass LIBPROTOBUF_EXPORT GeneratedExtensionFinder : public ExtensionFinder {\n public:\n  GeneratedExtensionFinder(const MessageLite* containing_type)\n      : containing_type_(containing_type) {}\n  virtual ~GeneratedExtensionFinder() {}\n\n  // Returns true and fills in *output if found, otherwise returns false.\n  virtual bool Find(int number, ExtensionInfo* output);\n\n private:\n  const MessageLite* containing_type_;\n};\n\n// A FieldSkipper used for parsing MessageSet.\nclass MessageSetFieldSkipper;\n\n// Note:  extension_set_heavy.cc defines DescriptorPoolExtensionFinder for\n// finding extensions from a DescriptorPool.\n\n// This is an internal helper class intended for use within the protocol buffer\n// library and generated classes.  Clients should not use it directly.  Instead,\n// use the generated accessors such as GetExtension() of the class being\n// extended.\n//\n// This class manages extensions for a protocol message object.  The\n// message's HasExtension(), GetExtension(), MutableExtension(), and\n// ClearExtension() methods are just thin wrappers around the embedded\n// ExtensionSet.  When parsing, if a tag number is encountered which is\n// inside one of the message type's extension ranges, the tag is passed\n// off to the ExtensionSet for parsing.  Etc.\nclass LIBPROTOBUF_EXPORT ExtensionSet {\n public:\n  ExtensionSet();\n  explicit ExtensionSet(::google::protobuf::Arena* arena);\n  ~ExtensionSet();\n\n  // These are called at startup by protocol-compiler-generated code to\n  // register known extensions.  The registrations are used by ParseField()\n  // to look up extensions for parsed field numbers.  Note that dynamic parsing\n  // does not use ParseField(); only protocol-compiler-generated parsing\n  // methods do.\n  static void RegisterExtension(const MessageLite* containing_type,\n                                int number, FieldType type,\n                                bool is_repeated, bool is_packed);\n  static void RegisterEnumExtension(const MessageLite* containing_type,\n                                    int number, FieldType type,\n                                    bool is_repeated, bool is_packed,\n                                    EnumValidityFunc* is_valid);\n  static void RegisterMessageExtension(const MessageLite* containing_type,\n                                       int number, FieldType type,\n                                       bool is_repeated, bool is_packed,\n                                       const MessageLite* prototype);\n\n  // =================================================================\n\n  // Add all fields which are currently present to the given vector.  This\n  // is useful to implement Reflection::ListFields().\n  void AppendToList(const Descriptor* containing_type,\n                    const DescriptorPool* pool,\n                    std::vector<const FieldDescriptor*>* output) const;\n\n  // =================================================================\n  // Accessors\n  //\n  // Generated message classes include type-safe templated wrappers around\n  // these methods.  Generally you should use those rather than call these\n  // directly, unless you are doing low-level memory management.\n  //\n  // When calling any of these accessors, the extension number requested\n  // MUST exist in the DescriptorPool provided to the constructor.  Otherwise,\n  // the method will fail an assert.  Normally, though, you would not call\n  // these directly; you would either call the generated accessors of your\n  // message class (e.g. GetExtension()) or you would call the accessors\n  // of the reflection interface.  In both cases, it is impossible to\n  // trigger this assert failure:  the generated accessors only accept\n  // linked-in extension types as parameters, while the Reflection interface\n  // requires you to provide the FieldDescriptor describing the extension.\n  //\n  // When calling any of these accessors, a protocol-compiler-generated\n  // implementation of the extension corresponding to the number MUST\n  // be linked in, and the FieldDescriptor used to refer to it MUST be\n  // the one generated by that linked-in code.  Otherwise, the method will\n  // die on an assert failure.  The message objects returned by the message\n  // accessors are guaranteed to be of the correct linked-in type.\n  //\n  // These methods pretty much match Reflection except that:\n  // - They're not virtual.\n  // - They identify fields by number rather than FieldDescriptors.\n  // - They identify enum values using integers rather than descriptors.\n  // - Strings provide Mutable() in addition to Set() accessors.\n\n  bool Has(int number) const;\n  int ExtensionSize(int number) const;   // Size of a repeated extension.\n  int NumExtensions() const;  // The number of extensions\n  FieldType ExtensionType(int number) const;\n  void ClearExtension(int number);\n\n  // singular fields -------------------------------------------------\n\n  int32  GetInt32 (int number, int32  default_value) const;\n  int64  GetInt64 (int number, int64  default_value) const;\n  uint32 GetUInt32(int number, uint32 default_value) const;\n  uint64 GetUInt64(int number, uint64 default_value) const;\n  float  GetFloat (int number, float  default_value) const;\n  double GetDouble(int number, double default_value) const;\n  bool   GetBool  (int number, bool   default_value) const;\n  int    GetEnum  (int number, int    default_value) const;\n  const string & GetString (int number, const string&  default_value) const;\n  const MessageLite& GetMessage(int number,\n                                const MessageLite& default_value) const;\n  const MessageLite& GetMessage(int number, const Descriptor* message_type,\n                                MessageFactory* factory) const;\n\n  // |descriptor| may be NULL so long as it is known that the descriptor for\n  // the extension lives in the same pool as the descriptor for the containing\n  // type.\n#define desc const FieldDescriptor* descriptor  // avoid line wrapping\n  void SetInt32 (int number, FieldType type, int32  value, desc);\n  void SetInt64 (int number, FieldType type, int64  value, desc);\n  void SetUInt32(int number, FieldType type, uint32 value, desc);\n  void SetUInt64(int number, FieldType type, uint64 value, desc);\n  void SetFloat (int number, FieldType type, float  value, desc);\n  void SetDouble(int number, FieldType type, double value, desc);\n  void SetBool  (int number, FieldType type, bool   value, desc);\n  void SetEnum  (int number, FieldType type, int    value, desc);\n  void SetString(int number, FieldType type, const string& value, desc);\n  string * MutableString (int number, FieldType type, desc);\n  MessageLite* MutableMessage(int number, FieldType type,\n                              const MessageLite& prototype, desc);\n  MessageLite* MutableMessage(const FieldDescriptor* decsriptor,\n                              MessageFactory* factory);\n  // Adds the given message to the ExtensionSet, taking ownership of the\n  // message object. Existing message with the same number will be deleted.\n  // If \"message\" is NULL, this is equivalent to \"ClearExtension(number)\".\n  void SetAllocatedMessage(int number, FieldType type,\n                           const FieldDescriptor* descriptor,\n                           MessageLite* message);\n  void UnsafeArenaSetAllocatedMessage(int number, FieldType type,\n                                      const FieldDescriptor* descriptor,\n                                      MessageLite* message);\n  MessageLite* ReleaseMessage(int number, const MessageLite& prototype);\n  MessageLite* UnsafeArenaReleaseMessage(\n      int number, const MessageLite& prototype);\n\n  MessageLite* ReleaseMessage(const FieldDescriptor* descriptor,\n                              MessageFactory* factory);\n  MessageLite* UnsafeArenaReleaseMessage(const FieldDescriptor* descriptor,\n                                         MessageFactory* factory);\n#undef desc\n  ::google::protobuf::Arena* GetArenaNoVirtual() const { return arena_; }\n\n  // repeated fields -------------------------------------------------\n\n  // Fetches a RepeatedField extension by number; returns |default_value|\n  // if no such extension exists. User should not touch this directly; it is\n  // used by the GetRepeatedExtension() method.\n  const void* GetRawRepeatedField(int number, const void* default_value) const;\n  // Fetches a mutable version of a RepeatedField extension by number,\n  // instantiating one if none exists. Similar to above, user should not use\n  // this directly; it underlies MutableRepeatedExtension().\n  void* MutableRawRepeatedField(int number, FieldType field_type,\n                                bool packed, const FieldDescriptor* desc);\n\n  // This is an overload of MutableRawRepeatedField to maintain compatibility\n  // with old code using a previous API. This version of\n  // MutableRawRepeatedField() will GOOGLE_CHECK-fail on a missing extension.\n  // (E.g.: borg/clients/internal/proto1/proto2_reflection.cc.)\n  void* MutableRawRepeatedField(int number);\n\n  int32  GetRepeatedInt32 (int number, int index) const;\n  int64  GetRepeatedInt64 (int number, int index) const;\n  uint32 GetRepeatedUInt32(int number, int index) const;\n  uint64 GetRepeatedUInt64(int number, int index) const;\n  float  GetRepeatedFloat (int number, int index) const;\n  double GetRepeatedDouble(int number, int index) const;\n  bool   GetRepeatedBool  (int number, int index) const;\n  int    GetRepeatedEnum  (int number, int index) const;\n  const string & GetRepeatedString (int number, int index) const;\n  const MessageLite& GetRepeatedMessage(int number, int index) const;\n\n  void SetRepeatedInt32 (int number, int index, int32  value);\n  void SetRepeatedInt64 (int number, int index, int64  value);\n  void SetRepeatedUInt32(int number, int index, uint32 value);\n  void SetRepeatedUInt64(int number, int index, uint64 value);\n  void SetRepeatedFloat (int number, int index, float  value);\n  void SetRepeatedDouble(int number, int index, double value);\n  void SetRepeatedBool  (int number, int index, bool   value);\n  void SetRepeatedEnum  (int number, int index, int    value);\n  void SetRepeatedString(int number, int index, const string& value);\n  string * MutableRepeatedString (int number, int index);\n  MessageLite* MutableRepeatedMessage(int number, int index);\n\n#define desc const FieldDescriptor* descriptor  // avoid line wrapping\n  void AddInt32 (int number, FieldType type, bool packed, int32  value, desc);\n  void AddInt64 (int number, FieldType type, bool packed, int64  value, desc);\n  void AddUInt32(int number, FieldType type, bool packed, uint32 value, desc);\n  void AddUInt64(int number, FieldType type, bool packed, uint64 value, desc);\n  void AddFloat (int number, FieldType type, bool packed, float  value, desc);\n  void AddDouble(int number, FieldType type, bool packed, double value, desc);\n  void AddBool  (int number, FieldType type, bool packed, bool   value, desc);\n  void AddEnum  (int number, FieldType type, bool packed, int    value, desc);\n  void AddString(int number, FieldType type, const string& value, desc);\n  string * AddString (int number, FieldType type, desc);\n  MessageLite* AddMessage(int number, FieldType type,\n                          const MessageLite& prototype, desc);\n  MessageLite* AddMessage(const FieldDescriptor* descriptor,\n                          MessageFactory* factory);\n  void AddAllocatedMessage(const FieldDescriptor* descriptor,\n                           MessageLite* new_entry);\n#undef desc\n\n  void RemoveLast(int number);\n  MessageLite* ReleaseLast(int number);\n  void SwapElements(int number, int index1, int index2);\n\n  // -----------------------------------------------------------------\n  // TODO(kenton):  Hardcore memory management accessors\n\n  // =================================================================\n  // convenience methods for implementing methods of Message\n  //\n  // These could all be implemented in terms of the other methods of this\n  // class, but providing them here helps keep the generated code size down.\n\n  void Clear();\n  void MergeFrom(const ExtensionSet& other);\n  void Swap(ExtensionSet* other);\n  void SwapExtension(ExtensionSet* other, int number);\n  bool IsInitialized() const;\n\n  // Parses a single extension from the input. The input should start out\n  // positioned immediately after the tag.\n  bool ParseField(uint32 tag, io::CodedInputStream* input,\n                  ExtensionFinder* extension_finder,\n                  FieldSkipper* field_skipper);\n\n  // Specific versions for lite or full messages (constructs the appropriate\n  // FieldSkipper automatically).  |containing_type| is the default\n  // instance for the containing message; it is used only to look up the\n  // extension by number.  See RegisterExtension(), above.  Unlike the other\n  // methods of ExtensionSet, this only works for generated message types --\n  // it looks up extensions registered using RegisterExtension().\n  bool ParseField(uint32 tag, io::CodedInputStream* input,\n                  const MessageLite* containing_type);\n  bool ParseField(uint32 tag, io::CodedInputStream* input,\n                  const Message* containing_type,\n                  UnknownFieldSet* unknown_fields);\n  bool ParseField(uint32 tag, io::CodedInputStream* input,\n                  const MessageLite* containing_type,\n                  io::CodedOutputStream* unknown_fields);\n\n  // Parse an entire message in MessageSet format.  Such messages have no\n  // fields, only extensions.\n  bool ParseMessageSet(io::CodedInputStream* input,\n                       ExtensionFinder* extension_finder,\n                       MessageSetFieldSkipper* field_skipper);\n\n  // Specific versions for lite or full messages (constructs the appropriate\n  // FieldSkipper automatically).\n  bool ParseMessageSet(io::CodedInputStream* input,\n                       const MessageLite* containing_type);\n  bool ParseMessageSet(io::CodedInputStream* input,\n                       const Message* containing_type,\n                       UnknownFieldSet* unknown_fields);\n\n  // Write all extension fields with field numbers in the range\n  //   [start_field_number, end_field_number)\n  // to the output stream, using the cached sizes computed when ByteSize() was\n  // last called.  Note that the range bounds are inclusive-exclusive.\n  void SerializeWithCachedSizes(int start_field_number,\n                                int end_field_number,\n                                io::CodedOutputStream* output) const;\n\n  // Same as SerializeWithCachedSizes, but without any bounds checking.\n  // The caller must ensure that target has sufficient capacity for the\n  // serialized extensions.\n  //\n  // Returns a pointer past the last written byte.\n  uint8* InternalSerializeWithCachedSizesToArray(int start_field_number,\n                                                 int end_field_number,\n                                                 bool deterministic,\n                                                 uint8* target) const;\n\n  // Like above but serializes in MessageSet format.\n  void SerializeMessageSetWithCachedSizes(io::CodedOutputStream* output) const;\n  uint8* InternalSerializeMessageSetWithCachedSizesToArray(bool deterministic,\n                                                           uint8* target) const;\n\n  // For backward-compatibility, versions of two of the above methods that\n  // are never forced to serialize deterministically.\n  uint8* SerializeWithCachedSizesToArray(int start_field_number,\n                                         int end_field_number,\n                                         uint8* target) const;\n  uint8* SerializeMessageSetWithCachedSizesToArray(uint8* target) const;\n\n  // Returns the total serialized size of all the extensions.\n  int ByteSize() const;\n\n  // Like ByteSize() but uses MessageSet format.\n  int MessageSetByteSize() const;\n\n  // Returns (an estimate of) the total number of bytes used for storing the\n  // extensions in memory, excluding sizeof(*this).  If the ExtensionSet is\n  // for a lite message (and thus possibly contains lite messages), the results\n  // are undefined (might work, might crash, might corrupt data, might not even\n  // be linked in).  It's up to the protocol compiler to avoid calling this on\n  // such ExtensionSets (easy enough since lite messages don't implement\n  // SpaceUsed()).\n  int SpaceUsedExcludingSelf() const;\n\n private:\n\n  // Interface of a lazily parsed singular message extension.\n  class LIBPROTOBUF_EXPORT LazyMessageExtension {\n   public:\n    LazyMessageExtension() {}\n    virtual ~LazyMessageExtension() {}\n\n    virtual LazyMessageExtension* New(::google::protobuf::Arena* arena) const = 0;\n    virtual const MessageLite& GetMessage(\n        const MessageLite& prototype) const = 0;\n    virtual MessageLite* MutableMessage(const MessageLite& prototype) = 0;\n    virtual void SetAllocatedMessage(MessageLite *message) = 0;\n    virtual void UnsafeArenaSetAllocatedMessage(MessageLite *message) = 0;\n    virtual MessageLite* ReleaseMessage(const MessageLite& prototype) = 0;\n    virtual MessageLite* UnsafeArenaReleaseMessage(\n        const MessageLite& prototype) = 0;\n\n    virtual bool IsInitialized() const = 0;\n    virtual int ByteSize() const = 0;\n    virtual int SpaceUsed() const = 0;\n\n    virtual void MergeFrom(const LazyMessageExtension& other) = 0;\n    virtual void Clear() = 0;\n\n    virtual bool ReadMessage(const MessageLite& prototype,\n                             io::CodedInputStream* input) = 0;\n    virtual void WriteMessage(int number,\n                              io::CodedOutputStream* output) const = 0;\n    virtual uint8* WriteMessageToArray(int number, uint8* target) const = 0;\n    virtual uint8* InternalWriteMessageToArray(int number, bool,\n                                               uint8* target) const {\n      // TODO(gpike): make this pure virtual. This is a placeholder because we\n      // need to update third_party/upb, for example.\n      return WriteMessageToArray(number, target);\n    }\n\n   private:\n    GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(LazyMessageExtension);\n  };\n  struct Extension {\n    // The order of these fields packs Extension into 24 bytes when using 8\n    // byte alignment. Consider this when adding or removing fields here.\n    union {\n      int32                 int32_value;\n      int64                 int64_value;\n      uint32                uint32_value;\n      uint64                uint64_value;\n      float                 float_value;\n      double                double_value;\n      bool                  bool_value;\n      int                   enum_value;\n      string*               string_value;\n      MessageLite*          message_value;\n      LazyMessageExtension* lazymessage_value;\n\n      RepeatedField   <int32      >* repeated_int32_value;\n      RepeatedField   <int64      >* repeated_int64_value;\n      RepeatedField   <uint32     >* repeated_uint32_value;\n      RepeatedField   <uint64     >* repeated_uint64_value;\n      RepeatedField   <float      >* repeated_float_value;\n      RepeatedField   <double     >* repeated_double_value;\n      RepeatedField   <bool       >* repeated_bool_value;\n      RepeatedField   <int        >* repeated_enum_value;\n      RepeatedPtrField<string     >* repeated_string_value;\n      RepeatedPtrField<MessageLite>* repeated_message_value;\n    };\n\n    FieldType type;\n    bool is_repeated;\n\n    // For singular types, indicates if the extension is \"cleared\".  This\n    // happens when an extension is set and then later cleared by the caller.\n    // We want to keep the Extension object around for reuse, so instead of\n    // removing it from the map, we just set is_cleared = true.  This has no\n    // meaning for repeated types; for those, the size of the RepeatedField\n    // simply becomes zero when cleared.\n    bool is_cleared : 4;\n\n    // For singular message types, indicates whether lazy parsing is enabled\n    // for this extension. This field is only valid when type == TYPE_MESSAGE\n    // and !is_repeated because we only support lazy parsing for singular\n    // message types currently. If is_lazy = true, the extension is stored in\n    // lazymessage_value. Otherwise, the extension will be message_value.\n    bool is_lazy : 4;\n\n    // For repeated types, this indicates if the [packed=true] option is set.\n    bool is_packed;\n\n    // For packed fields, the size of the packed data is recorded here when\n    // ByteSize() is called then used during serialization.\n    // TODO(kenton):  Use atomic<int> when C++ supports it.\n    mutable int cached_size;\n\n    // The descriptor for this extension, if one exists and is known.  May be\n    // NULL.  Must not be NULL if the descriptor for the extension does not\n    // live in the same pool as the descriptor for the containing type.\n    const FieldDescriptor* descriptor;\n\n    // Some helper methods for operations on a single Extension.\n    void SerializeFieldWithCachedSizes(\n        int number,\n        io::CodedOutputStream* output) const;\n    uint8* InternalSerializeFieldWithCachedSizesToArray(\n        int number,\n        bool deterministic,\n        uint8* target) const;\n    void SerializeMessageSetItemWithCachedSizes(\n        int number,\n        io::CodedOutputStream* output) const;\n    uint8* InternalSerializeMessageSetItemWithCachedSizesToArray(\n        int number,\n        bool deterministic,\n        uint8* target) const;\n    int ByteSize(int number) const;\n    int MessageSetItemByteSize(int number) const;\n    void Clear();\n    int GetSize() const;\n    void Free();\n    int SpaceUsedExcludingSelf() const;\n  };\n  typedef std::map<int, Extension> ExtensionMap;\n\n\n  // Merges existing Extension from other_extension\n  void InternalExtensionMergeFrom(int number, const Extension& other_extension);\n\n  // Returns true and fills field_number and extension if extension is found.\n  // Note to support packed repeated field compatibility, it also fills whether\n  // the tag on wire is packed, which can be different from\n  // extension->is_packed (whether packed=true is specified).\n  bool FindExtensionInfoFromTag(uint32 tag, ExtensionFinder* extension_finder,\n                                int* field_number, ExtensionInfo* extension,\n                                bool* was_packed_on_wire);\n\n  // Returns true and fills extension if extension is found.\n  // Note to support packed repeated field compatibility, it also fills whether\n  // the tag on wire is packed, which can be different from\n  // extension->is_packed (whether packed=true is specified).\n  bool FindExtensionInfoFromFieldNumber(int wire_type, int field_number,\n                                        ExtensionFinder* extension_finder,\n                                        ExtensionInfo* extension,\n                                        bool* was_packed_on_wire);\n\n  // Parses a single extension from the input. The input should start out\n  // positioned immediately after the wire tag. This method is called in\n  // ParseField() after field number and was_packed_on_wire is extracted from\n  // the wire tag and ExtensionInfo is found by the field number.\n  bool ParseFieldWithExtensionInfo(int field_number,\n                                   bool was_packed_on_wire,\n                                   const ExtensionInfo& extension,\n                                   io::CodedInputStream* input,\n                                   FieldSkipper* field_skipper);\n\n  // Like ParseField(), but this method may parse singular message extensions\n  // lazily depending on the value of FLAGS_eagerly_parse_message_sets.\n  bool ParseFieldMaybeLazily(int wire_type, int field_number,\n                             io::CodedInputStream* input,\n                             ExtensionFinder* extension_finder,\n                             MessageSetFieldSkipper* field_skipper);\n\n  // Gets the extension with the given number, creating it if it does not\n  // already exist.  Returns true if the extension did not already exist.\n  bool MaybeNewExtension(int number, const FieldDescriptor* descriptor,\n                         Extension** result);\n\n  // Gets the repeated extension for the given descriptor, creating it if\n  // it does not exist.\n  Extension* MaybeNewRepeatedExtension(const FieldDescriptor* descriptor);\n\n  // Parse a single MessageSet item -- called just after the item group start\n  // tag has been read.\n  bool ParseMessageSetItem(io::CodedInputStream* input,\n                           ExtensionFinder* extension_finder,\n                           MessageSetFieldSkipper* field_skipper);\n\n  // Hack:  RepeatedPtrFieldBase declares ExtensionSet as a friend.  This\n  //   friendship should automatically extend to ExtensionSet::Extension, but\n  //   unfortunately some older compilers (e.g. GCC 3.4.4) do not implement this\n  //   correctly.  So, we must provide helpers for calling methods of that\n  //   class.\n\n  // Defined in extension_set_heavy.cc.\n  static inline int RepeatedMessage_SpaceUsedExcludingSelf(\n      RepeatedPtrFieldBase* field);\n\n  // The Extension struct is small enough to be passed by value, so we use it\n  // directly as the value type in the map rather than use pointers.  We use\n  // a map rather than hash_map here because we expect most ExtensionSets will\n  // only contain a small number of extensions whereas hash_map is optimized\n  // for 100 elements or more.  Also, we want AppendToList() to order fields\n  // by field number.\n  ExtensionMap extensions_;\n  ::google::protobuf::Arena* arena_;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ExtensionSet);\n};\n\n// These are just for convenience...\ninline void ExtensionSet::SetString(int number, FieldType type,\n                                    const string& value,\n                                    const FieldDescriptor* descriptor) {\n  MutableString(number, type, descriptor)->assign(value);\n}\ninline void ExtensionSet::SetRepeatedString(int number, int index,\n                                            const string& value) {\n  MutableRepeatedString(number, index)->assign(value);\n}\ninline void ExtensionSet::AddString(int number, FieldType type,\n                                    const string& value,\n                                    const FieldDescriptor* descriptor) {\n  AddString(number, type, descriptor)->assign(value);\n}\n\n// ===================================================================\n// Glue for generated extension accessors\n\n// -------------------------------------------------------------------\n// Template magic\n\n// First we have a set of classes representing \"type traits\" for different\n// field types.  A type traits class knows how to implement basic accessors\n// for extensions of a particular type given an ExtensionSet.  The signature\n// for a type traits class looks like this:\n//\n//   class TypeTraits {\n//    public:\n//     typedef ? ConstType;\n//     typedef ? MutableType;\n//     // TypeTraits for singular fields and repeated fields will define the\n//     // symbol \"Singular\" or \"Repeated\" respectively. These two symbols will\n//     // be used in extension accessors to distinguish between singular\n//     // extensions and repeated extensions. If the TypeTraits for the passed\n//     // in extension doesn't have the expected symbol defined, it means the\n//     // user is passing a repeated extension to a singular accessor, or the\n//     // opposite. In that case the C++ compiler will generate an error\n//     // message \"no matching member function\" to inform the user.\n//     typedef ? Singular\n//     typedef ? Repeated\n//\n//     static inline ConstType Get(int number, const ExtensionSet& set);\n//     static inline void Set(int number, ConstType value, ExtensionSet* set);\n//     static inline MutableType Mutable(int number, ExtensionSet* set);\n//\n//     // Variants for repeated fields.\n//     static inline ConstType Get(int number, const ExtensionSet& set,\n//                                 int index);\n//     static inline void Set(int number, int index,\n//                            ConstType value, ExtensionSet* set);\n//     static inline MutableType Mutable(int number, int index,\n//                                       ExtensionSet* set);\n//     static inline void Add(int number, ConstType value, ExtensionSet* set);\n//     static inline MutableType Add(int number, ExtensionSet* set);\n//   };\n//\n// Not all of these methods make sense for all field types.  For example, the\n// \"Mutable\" methods only make sense for strings and messages, and the\n// repeated methods only make sense for repeated types.  So, each type\n// traits class implements only the set of methods from this signature that it\n// actually supports.  This will cause a compiler error if the user tries to\n// access an extension using a method that doesn't make sense for its type.\n// For example, if \"foo\" is an extension of type \"optional int32\", then if you\n// try to write code like:\n//   my_message.MutableExtension(foo)\n// you will get a compile error because PrimitiveTypeTraits<int32> does not\n// have a \"Mutable()\" method.\n\n// -------------------------------------------------------------------\n// PrimitiveTypeTraits\n\n// Since the ExtensionSet has different methods for each primitive type,\n// we must explicitly define the methods of the type traits class for each\n// known type.\ntemplate <typename Type>\nclass PrimitiveTypeTraits {\n public:\n  typedef Type ConstType;\n  typedef Type MutableType;\n  typedef PrimitiveTypeTraits<Type> Singular;\n\n  static inline ConstType Get(int number, const ExtensionSet& set,\n                              ConstType default_value);\n  static inline void Set(int number, FieldType field_type,\n                         ConstType value, ExtensionSet* set);\n};\n\ntemplate <typename Type>\nclass RepeatedPrimitiveTypeTraits {\n public:\n  typedef Type ConstType;\n  typedef Type MutableType;\n  typedef RepeatedPrimitiveTypeTraits<Type> Repeated;\n\n  typedef RepeatedField<Type> RepeatedFieldType;\n\n  static inline Type Get(int number, const ExtensionSet& set, int index);\n  static inline void Set(int number, int index, Type value, ExtensionSet* set);\n  static inline void Add(int number, FieldType field_type,\n                         bool is_packed, Type value, ExtensionSet* set);\n\n  static inline const RepeatedField<ConstType>&\n      GetRepeated(int number, const ExtensionSet& set);\n  static inline RepeatedField<Type>*\n      MutableRepeated(int number, FieldType field_type,\n                      bool is_packed, ExtensionSet* set);\n\n  static const RepeatedFieldType* GetDefaultRepeatedField();\n};\n\nLIBPROTOBUF_EXPORT extern ProtobufOnceType repeated_primitive_generic_type_traits_once_init_;\n\nclass LIBPROTOBUF_EXPORT RepeatedPrimitiveGenericTypeTraits {\n private:\n  template<typename Type> friend class RepeatedPrimitiveTypeTraits;\n  static void InitializeDefaultRepeatedFields();\n  static void DestroyDefaultRepeatedFields();\n  static const RepeatedField<int32>* default_repeated_field_int32_;\n  static const RepeatedField<int64>* default_repeated_field_int64_;\n  static const RepeatedField<uint32>* default_repeated_field_uint32_;\n  static const RepeatedField<uint64>* default_repeated_field_uint64_;\n  static const RepeatedField<double>* default_repeated_field_double_;\n  static const RepeatedField<float>* default_repeated_field_float_;\n  static const RepeatedField<bool>* default_repeated_field_bool_;\n};\n\n#define PROTOBUF_DEFINE_PRIMITIVE_TYPE(TYPE, METHOD)                       \\\ntemplate<> inline TYPE PrimitiveTypeTraits<TYPE>::Get(                     \\\n    int number, const ExtensionSet& set, TYPE default_value) {             \\\n  return set.Get##METHOD(number, default_value);                           \\\n}                                                                          \\\ntemplate<> inline void PrimitiveTypeTraits<TYPE>::Set(                     \\\n    int number, FieldType field_type, TYPE value, ExtensionSet* set) {     \\\n  set->Set##METHOD(number, field_type, value, NULL);                       \\\n}                                                                          \\\n                                                                           \\\ntemplate<> inline TYPE RepeatedPrimitiveTypeTraits<TYPE>::Get(             \\\n    int number, const ExtensionSet& set, int index) {                      \\\n  return set.GetRepeated##METHOD(number, index);                           \\\n}                                                                          \\\ntemplate<> inline void RepeatedPrimitiveTypeTraits<TYPE>::Set(             \\\n    int number, int index, TYPE value, ExtensionSet* set) {                \\\n  set->SetRepeated##METHOD(number, index, value);                          \\\n}                                                                          \\\ntemplate<> inline void RepeatedPrimitiveTypeTraits<TYPE>::Add(             \\\n    int number, FieldType field_type, bool is_packed,                      \\\n    TYPE value, ExtensionSet* set) {                                       \\\n  set->Add##METHOD(number, field_type, is_packed, value, NULL);            \\\n}                                                                          \\\ntemplate<> inline const RepeatedField<TYPE>*                               \\\n    RepeatedPrimitiveTypeTraits<TYPE>::GetDefaultRepeatedField() {         \\\n  ::google::protobuf::GoogleOnceInit(                                                          \\\n      &repeated_primitive_generic_type_traits_once_init_,                  \\\n      &RepeatedPrimitiveGenericTypeTraits::InitializeDefaultRepeatedFields); \\\n  return RepeatedPrimitiveGenericTypeTraits::                              \\\n      default_repeated_field_##TYPE##_;                                    \\\n}                                                                          \\\ntemplate<> inline const RepeatedField<TYPE>&                               \\\n    RepeatedPrimitiveTypeTraits<TYPE>::GetRepeated(int number,             \\\n                                               const ExtensionSet& set) {  \\\n  return *reinterpret_cast<const RepeatedField<TYPE>*>(                    \\\n                            set.GetRawRepeatedField(                       \\\n                                number, GetDefaultRepeatedField()));       \\\n}                                                                          \\\ntemplate<> inline RepeatedField<TYPE>*                                     \\\n    RepeatedPrimitiveTypeTraits<TYPE>::MutableRepeated(int number,         \\\n                                                   FieldType field_type,   \\\n                                                   bool is_packed,         \\\n                                                   ExtensionSet* set) {    \\\n  return reinterpret_cast<RepeatedField<TYPE>*>(                           \\\n      set->MutableRawRepeatedField(number, field_type, is_packed, NULL));  \\\n}\n\nPROTOBUF_DEFINE_PRIMITIVE_TYPE( int32,  Int32)\nPROTOBUF_DEFINE_PRIMITIVE_TYPE( int64,  Int64)\nPROTOBUF_DEFINE_PRIMITIVE_TYPE(uint32, UInt32)\nPROTOBUF_DEFINE_PRIMITIVE_TYPE(uint64, UInt64)\nPROTOBUF_DEFINE_PRIMITIVE_TYPE( float,  Float)\nPROTOBUF_DEFINE_PRIMITIVE_TYPE(double, Double)\nPROTOBUF_DEFINE_PRIMITIVE_TYPE(  bool,   Bool)\n\n#undef PROTOBUF_DEFINE_PRIMITIVE_TYPE\n\n// -------------------------------------------------------------------\n// StringTypeTraits\n\n// Strings support both Set() and Mutable().\nclass LIBPROTOBUF_EXPORT StringTypeTraits {\n public:\n  typedef const string& ConstType;\n  typedef string* MutableType;\n  typedef StringTypeTraits Singular;\n\n  static inline const string& Get(int number, const ExtensionSet& set,\n                                  ConstType default_value) {\n    return set.GetString(number, default_value);\n  }\n  static inline void Set(int number, FieldType field_type,\n                         const string& value, ExtensionSet* set) {\n    set->SetString(number, field_type, value, NULL);\n  }\n  static inline string* Mutable(int number, FieldType field_type,\n                                ExtensionSet* set) {\n    return set->MutableString(number, field_type, NULL);\n  }\n};\n\nLIBPROTOBUF_EXPORT extern ProtobufOnceType repeated_string_type_traits_once_init_;\n\nclass LIBPROTOBUF_EXPORT RepeatedStringTypeTraits {\n public:\n  typedef const string& ConstType;\n  typedef string* MutableType;\n  typedef RepeatedStringTypeTraits Repeated;\n\n  typedef RepeatedPtrField<string> RepeatedFieldType;\n\n  static inline const string& Get(int number, const ExtensionSet& set,\n                                  int index) {\n    return set.GetRepeatedString(number, index);\n  }\n  static inline void Set(int number, int index,\n                         const string& value, ExtensionSet* set) {\n    set->SetRepeatedString(number, index, value);\n  }\n  static inline string* Mutable(int number, int index, ExtensionSet* set) {\n    return set->MutableRepeatedString(number, index);\n  }\n  static inline void Add(int number, FieldType field_type,\n                         bool /*is_packed*/, const string& value,\n                         ExtensionSet* set) {\n    set->AddString(number, field_type, value, NULL);\n  }\n  static inline string* Add(int number, FieldType field_type,\n                            ExtensionSet* set) {\n    return set->AddString(number, field_type, NULL);\n  }\n  static inline const RepeatedPtrField<string>&\n      GetRepeated(int number, const ExtensionSet& set) {\n    return *reinterpret_cast<const RepeatedPtrField<string>*>(\n        set.GetRawRepeatedField(number, GetDefaultRepeatedField()));\n  }\n\n  static inline RepeatedPtrField<string>*\n      MutableRepeated(int number, FieldType field_type,\n                      bool is_packed, ExtensionSet* set) {\n    return reinterpret_cast<RepeatedPtrField<string>*>(\n        set->MutableRawRepeatedField(number, field_type,\n                                     is_packed, NULL));\n  }\n\n  static const RepeatedFieldType* GetDefaultRepeatedField() {\n    ::google::protobuf::GoogleOnceInit(&repeated_string_type_traits_once_init_,\n                   &InitializeDefaultRepeatedFields);\n    return default_repeated_field_;\n  }\n\n private:\n  static void InitializeDefaultRepeatedFields();\n  static void DestroyDefaultRepeatedFields();\n  static const RepeatedFieldType *default_repeated_field_;\n};\n\n// -------------------------------------------------------------------\n// EnumTypeTraits\n\n// ExtensionSet represents enums using integers internally, so we have to\n// static_cast around.\ntemplate <typename Type, bool IsValid(int)>\nclass EnumTypeTraits {\n public:\n  typedef Type ConstType;\n  typedef Type MutableType;\n  typedef EnumTypeTraits<Type, IsValid> Singular;\n\n  static inline ConstType Get(int number, const ExtensionSet& set,\n                              ConstType default_value) {\n    return static_cast<Type>(set.GetEnum(number, default_value));\n  }\n  static inline void Set(int number, FieldType field_type,\n                         ConstType value, ExtensionSet* set) {\n    GOOGLE_DCHECK(IsValid(value));\n    set->SetEnum(number, field_type, value, NULL);\n  }\n};\n\ntemplate <typename Type, bool IsValid(int)>\nclass RepeatedEnumTypeTraits {\n public:\n  typedef Type ConstType;\n  typedef Type MutableType;\n  typedef RepeatedEnumTypeTraits<Type, IsValid> Repeated;\n\n  typedef RepeatedField<Type> RepeatedFieldType;\n\n  static inline ConstType Get(int number, const ExtensionSet& set, int index) {\n    return static_cast<Type>(set.GetRepeatedEnum(number, index));\n  }\n  static inline void Set(int number, int index,\n                         ConstType value, ExtensionSet* set) {\n    GOOGLE_DCHECK(IsValid(value));\n    set->SetRepeatedEnum(number, index, value);\n  }\n  static inline void Add(int number, FieldType field_type,\n                         bool is_packed, ConstType value, ExtensionSet* set) {\n    GOOGLE_DCHECK(IsValid(value));\n    set->AddEnum(number, field_type, is_packed, value, NULL);\n  }\n  static inline const RepeatedField<Type>& GetRepeated(int number,\n                                                       const ExtensionSet&\n                                                       set) {\n    // Hack: the `Extension` struct stores a RepeatedField<int> for enums.\n    // RepeatedField<int> cannot implicitly convert to RepeatedField<EnumType>\n    // so we need to do some casting magic. See message.h for similar\n    // contortions for non-extension fields.\n    return *reinterpret_cast<const RepeatedField<Type>*>(\n        set.GetRawRepeatedField(number, GetDefaultRepeatedField()));\n  }\n\n  static inline RepeatedField<Type>* MutableRepeated(int number,\n                                                     FieldType field_type,\n                                                     bool is_packed,\n                                                     ExtensionSet* set) {\n    return reinterpret_cast<RepeatedField<Type>*>(\n        set->MutableRawRepeatedField(number, field_type, is_packed, NULL));\n  }\n\n  static const RepeatedFieldType* GetDefaultRepeatedField() {\n    // Hack: as noted above, repeated enum fields are internally stored as a\n    // RepeatedField<int>. We need to be able to instantiate global static\n    // objects to return as default (empty) repeated fields on non-existent\n    // extensions. We would not be able to know a-priori all of the enum types\n    // (values of |Type|) to instantiate all of these, so we just re-use int32's\n    // default repeated field object.\n    return reinterpret_cast<const RepeatedField<Type>*>(\n        RepeatedPrimitiveTypeTraits<int32>::GetDefaultRepeatedField());\n  }\n};\n\n// -------------------------------------------------------------------\n// MessageTypeTraits\n\n// ExtensionSet guarantees that when manipulating extensions with message\n// types, the implementation used will be the compiled-in class representing\n// that type.  So, we can static_cast down to the exact type we expect.\ntemplate <typename Type>\nclass MessageTypeTraits {\n public:\n  typedef const Type& ConstType;\n  typedef Type* MutableType;\n  typedef MessageTypeTraits<Type> Singular;\n\n  static inline ConstType Get(int number, const ExtensionSet& set,\n                              ConstType default_value) {\n    return static_cast<const Type&>(\n        set.GetMessage(number, default_value));\n  }\n  static inline MutableType Mutable(int number, FieldType field_type,\n                                    ExtensionSet* set) {\n    return static_cast<Type*>(\n      set->MutableMessage(number, field_type, Type::default_instance(), NULL));\n  }\n  static inline void SetAllocated(int number, FieldType field_type,\n                                  MutableType message, ExtensionSet* set) {\n    set->SetAllocatedMessage(number, field_type, NULL, message);\n  }\n  static inline void UnsafeArenaSetAllocated(int number, FieldType field_type,\n                                             MutableType message,\n                                             ExtensionSet* set) {\n    set->UnsafeArenaSetAllocatedMessage(number, field_type, NULL, message);\n  }\n  static inline MutableType Release(int number, FieldType /* field_type */,\n                                    ExtensionSet* set) {\n    return static_cast<Type*>(set->ReleaseMessage(\n        number, Type::default_instance()));\n  }\n  static inline MutableType UnsafeArenaRelease(int number,\n                                               FieldType /* field_type */,\n                                               ExtensionSet* set) {\n    return static_cast<Type*>(set->UnsafeArenaReleaseMessage(\n        number, Type::default_instance()));\n  }\n};\n\n// forward declaration\nclass RepeatedMessageGenericTypeTraits;\n\ntemplate <typename Type>\nclass RepeatedMessageTypeTraits {\n public:\n  typedef const Type& ConstType;\n  typedef Type* MutableType;\n  typedef RepeatedMessageTypeTraits<Type> Repeated;\n\n  typedef RepeatedPtrField<Type> RepeatedFieldType;\n\n  static inline ConstType Get(int number, const ExtensionSet& set, int index) {\n    return static_cast<const Type&>(set.GetRepeatedMessage(number, index));\n  }\n  static inline MutableType Mutable(int number, int index, ExtensionSet* set) {\n    return static_cast<Type*>(set->MutableRepeatedMessage(number, index));\n  }\n  static inline MutableType Add(int number, FieldType field_type,\n                                ExtensionSet* set) {\n    return static_cast<Type*>(\n        set->AddMessage(number, field_type, Type::default_instance(), NULL));\n  }\n  static inline const RepeatedPtrField<Type>& GetRepeated(int number,\n                                                          const ExtensionSet&\n                                                          set) {\n    // See notes above in RepeatedEnumTypeTraits::GetRepeated(): same\n    // casting hack applies here, because a RepeatedPtrField<MessageLite>\n    // cannot naturally become a RepeatedPtrType<Type> even though Type is\n    // presumably a message. google::protobuf::Message goes through similar contortions\n    // with a reinterpret_cast<>.\n    return *reinterpret_cast<const RepeatedPtrField<Type>*>(\n        set.GetRawRepeatedField(number, GetDefaultRepeatedField()));\n  }\n  static inline RepeatedPtrField<Type>* MutableRepeated(int number,\n                                                        FieldType field_type,\n                                                        bool is_packed,\n                                                        ExtensionSet* set) {\n    return reinterpret_cast<RepeatedPtrField<Type>*>(\n        set->MutableRawRepeatedField(number, field_type, is_packed, NULL));\n  }\n\n  static const RepeatedFieldType* GetDefaultRepeatedField();\n};\n\nLIBPROTOBUF_EXPORT extern ProtobufOnceType repeated_message_generic_type_traits_once_init_;\n\n// This class exists only to hold a generic default empty repeated field for all\n// message-type repeated field extensions.\nclass LIBPROTOBUF_EXPORT RepeatedMessageGenericTypeTraits {\n public:\n  typedef RepeatedPtrField< ::google::protobuf::MessageLite*> RepeatedFieldType;\n private:\n  template<typename Type> friend class RepeatedMessageTypeTraits;\n  static void InitializeDefaultRepeatedFields();\n  static void DestroyDefaultRepeatedFields();\n  static const RepeatedFieldType* default_repeated_field_;\n};\n\ntemplate<typename Type> inline\n    const typename RepeatedMessageTypeTraits<Type>::RepeatedFieldType*\n    RepeatedMessageTypeTraits<Type>::GetDefaultRepeatedField() {\n  ::google::protobuf::GoogleOnceInit(\n      &repeated_message_generic_type_traits_once_init_,\n      &RepeatedMessageGenericTypeTraits::InitializeDefaultRepeatedFields);\n  return reinterpret_cast<const RepeatedFieldType*>(\n      RepeatedMessageGenericTypeTraits::default_repeated_field_);\n}\n\n// -------------------------------------------------------------------\n// ExtensionIdentifier\n\n// This is the type of actual extension objects.  E.g. if you have:\n//   extends Foo with optional int32 bar = 1234;\n// then \"bar\" will be defined in C++ as:\n//   ExtensionIdentifier<Foo, PrimitiveTypeTraits<int32>, 1, false> bar(1234);\n//\n// Note that we could, in theory, supply the field number as a template\n// parameter, and thus make an instance of ExtensionIdentifier have no\n// actual contents.  However, if we did that, then using at extension\n// identifier would not necessarily cause the compiler to output any sort\n// of reference to any simple defined in the extension's .pb.o file.  Some\n// linkers will actually drop object files that are not explicitly referenced,\n// but that would be bad because it would cause this extension to not be\n// registered at static initialization, and therefore using it would crash.\n\ntemplate <typename ExtendeeType, typename TypeTraitsType,\n          FieldType field_type, bool is_packed>\nclass ExtensionIdentifier {\n public:\n  typedef TypeTraitsType TypeTraits;\n  typedef ExtendeeType Extendee;\n\n  ExtensionIdentifier(int number, typename TypeTraits::ConstType default_value)\n      : number_(number), default_value_(default_value) {}\n  inline int number() const { return number_; }\n  typename TypeTraits::ConstType default_value() const {\n    return default_value_;\n  }\n\n private:\n  const int number_;\n  typename TypeTraits::ConstType default_value_;\n};\n\n// -------------------------------------------------------------------\n// Generated accessors\n\n// This macro should be expanded in the context of a generated type which\n// has extensions.\n//\n// We use \"_proto_TypeTraits\" as a type name below because \"TypeTraits\"\n// causes problems if the class has a nested message or enum type with that\n// name and \"_TypeTraits\" is technically reserved for the C++ library since\n// it starts with an underscore followed by a capital letter.\n//\n// For similar reason, we use \"_field_type\" and \"_is_packed\" as parameter names\n// below, so that \"field_type\" and \"is_packed\" can be used as field names.\n#define GOOGLE_PROTOBUF_EXTENSION_ACCESSORS(CLASSNAME)                        \\\n  /* Has, Size, Clear */                                                      \\\n  template <typename _proto_TypeTraits,                                       \\\n            ::google::protobuf::internal::FieldType _field_type,                        \\\n            bool _is_packed>                                                  \\\n  inline bool HasExtension(                                                   \\\n      const ::google::protobuf::internal::ExtensionIdentifier<                          \\\n        CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) const {   \\\n    return _extensions_.Has(id.number());                                     \\\n  }                                                                           \\\n                                                                              \\\n  template <typename _proto_TypeTraits,                                       \\\n            ::google::protobuf::internal::FieldType _field_type,                        \\\n            bool _is_packed>                                                  \\\n  inline void ClearExtension(                                                 \\\n      const ::google::protobuf::internal::ExtensionIdentifier<                          \\\n        CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) {         \\\n    _extensions_.ClearExtension(id.number());                                 \\\n  }                                                                           \\\n                                                                              \\\n  template <typename _proto_TypeTraits,                                       \\\n            ::google::protobuf::internal::FieldType _field_type,                        \\\n            bool _is_packed>                                                  \\\n  inline int ExtensionSize(                                                   \\\n      const ::google::protobuf::internal::ExtensionIdentifier<                          \\\n        CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) const {   \\\n    return _extensions_.ExtensionSize(id.number());                           \\\n  }                                                                           \\\n                                                                              \\\n  /* Singular accessors */                                                    \\\n  template <typename _proto_TypeTraits,                                       \\\n            ::google::protobuf::internal::FieldType _field_type,                        \\\n            bool _is_packed>                                                  \\\n  inline typename _proto_TypeTraits::Singular::ConstType GetExtension(        \\\n      const ::google::protobuf::internal::ExtensionIdentifier<                          \\\n        CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) const {   \\\n    return _proto_TypeTraits::Get(id.number(), _extensions_,                  \\\n                                  id.default_value());                        \\\n  }                                                                           \\\n                                                                              \\\n  template <typename _proto_TypeTraits,                                       \\\n            ::google::protobuf::internal::FieldType _field_type,                        \\\n            bool _is_packed>                                                  \\\n  inline typename _proto_TypeTraits::Singular::MutableType MutableExtension(  \\\n      const ::google::protobuf::internal::ExtensionIdentifier<                          \\\n        CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) {         \\\n    return _proto_TypeTraits::Mutable(id.number(), _field_type,               \\\n                                      &_extensions_);                         \\\n  }                                                                           \\\n                                                                              \\\n  template <typename _proto_TypeTraits,                                       \\\n            ::google::protobuf::internal::FieldType _field_type,                        \\\n            bool _is_packed>                                                  \\\n  inline void SetExtension(                                                   \\\n      const ::google::protobuf::internal::ExtensionIdentifier<                          \\\n        CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id,           \\\n      typename _proto_TypeTraits::Singular::ConstType value) {                \\\n    _proto_TypeTraits::Set(id.number(), _field_type, value, &_extensions_);   \\\n  }                                                                           \\\n                                                                              \\\n  template <typename _proto_TypeTraits,                                       \\\n            ::google::protobuf::internal::FieldType _field_type,                        \\\n            bool _is_packed>                                                  \\\n  inline void SetAllocatedExtension(                                          \\\n      const ::google::protobuf::internal::ExtensionIdentifier<                          \\\n        CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id,           \\\n      typename _proto_TypeTraits::Singular::MutableType value) {              \\\n    _proto_TypeTraits::SetAllocated(id.number(), _field_type,                 \\\n                                    value, &_extensions_);                    \\\n  }                                                                           \\\n  template <typename _proto_TypeTraits,                                       \\\n            ::google::protobuf::internal::FieldType _field_type,                        \\\n            bool _is_packed>                                                  \\\n  inline void UnsafeArenaSetAllocatedExtension(                               \\\n      const ::google::protobuf::internal::ExtensionIdentifier<                          \\\n        CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id,           \\\n      typename _proto_TypeTraits::Singular::MutableType value) {              \\\n    _proto_TypeTraits::UnsafeArenaSetAllocated(id.number(), _field_type,      \\\n                                               value, &_extensions_);         \\\n  }                                                                           \\\n  template <typename _proto_TypeTraits,                                       \\\n            ::google::protobuf::internal::FieldType _field_type,                        \\\n            bool _is_packed>                                                  \\\n  inline typename _proto_TypeTraits::Singular::MutableType ReleaseExtension(  \\\n      const ::google::protobuf::internal::ExtensionIdentifier<                          \\\n        CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) {         \\\n    return _proto_TypeTraits::Release(id.number(), _field_type,               \\\n                                      &_extensions_);                         \\\n  }                                                                           \\\n  template <typename _proto_TypeTraits,                                       \\\n            ::google::protobuf::internal::FieldType _field_type,                        \\\n            bool _is_packed>                                                  \\\n  inline typename _proto_TypeTraits::Singular::MutableType                    \\\n      UnsafeArenaReleaseExtension(                                            \\\n          const ::google::protobuf::internal::ExtensionIdentifier<                      \\\n            CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) {     \\\n    return _proto_TypeTraits::UnsafeArenaRelease(id.number(), _field_type,    \\\n                                                 &_extensions_);              \\\n  }                                                                           \\\n                                                                              \\\n  /* Repeated accessors */                                                    \\\n  template <typename _proto_TypeTraits,                                       \\\n            ::google::protobuf::internal::FieldType _field_type,                        \\\n            bool _is_packed>                                                  \\\n  inline typename _proto_TypeTraits::Repeated::ConstType GetExtension(        \\\n      const ::google::protobuf::internal::ExtensionIdentifier<                          \\\n        CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id,           \\\n      int index) const {                                                      \\\n    return _proto_TypeTraits::Get(id.number(), _extensions_, index);          \\\n  }                                                                           \\\n                                                                              \\\n  template <typename _proto_TypeTraits,                                       \\\n            ::google::protobuf::internal::FieldType _field_type,                        \\\n            bool _is_packed>                                                  \\\n  inline typename _proto_TypeTraits::Repeated::MutableType MutableExtension(  \\\n      const ::google::protobuf::internal::ExtensionIdentifier<                          \\\n        CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id,           \\\n      int index) {                                                            \\\n    return _proto_TypeTraits::Mutable(id.number(), index, &_extensions_);     \\\n  }                                                                           \\\n                                                                              \\\n  template <typename _proto_TypeTraits,                                       \\\n            ::google::protobuf::internal::FieldType _field_type,                        \\\n            bool _is_packed>                                                  \\\n  inline void SetExtension(                                                   \\\n      const ::google::protobuf::internal::ExtensionIdentifier<                          \\\n        CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id,           \\\n      int index, typename _proto_TypeTraits::Repeated::ConstType value) {     \\\n    _proto_TypeTraits::Set(id.number(), index, value, &_extensions_);         \\\n  }                                                                           \\\n                                                                              \\\n  template <typename _proto_TypeTraits,                                       \\\n            ::google::protobuf::internal::FieldType _field_type,                        \\\n            bool _is_packed>                                                  \\\n  inline typename _proto_TypeTraits::Repeated::MutableType AddExtension(      \\\n      const ::google::protobuf::internal::ExtensionIdentifier<                          \\\n        CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id) {         \\\n    return _proto_TypeTraits::Add(id.number(), _field_type, &_extensions_);   \\\n  }                                                                           \\\n                                                                              \\\n  template <typename _proto_TypeTraits,                                       \\\n            ::google::protobuf::internal::FieldType _field_type,                        \\\n            bool _is_packed>                                                  \\\n  inline void AddExtension(                                                   \\\n      const ::google::protobuf::internal::ExtensionIdentifier<                          \\\n        CLASSNAME, _proto_TypeTraits, _field_type, _is_packed>& id,           \\\n      typename _proto_TypeTraits::Repeated::ConstType value) {                \\\n    _proto_TypeTraits::Add(id.number(), _field_type, _is_packed,              \\\n                           value, &_extensions_);                             \\\n  }                                                                           \\\n                                                                              \\\n  template <typename _proto_TypeTraits,                                       \\\n            ::google::protobuf::internal::FieldType _field_type,                        \\\n            bool _is_packed>                                                  \\\n  inline const typename _proto_TypeTraits::Repeated::RepeatedFieldType&       \\\n      GetRepeatedExtension(                                                   \\\n          const ::google::protobuf::internal::ExtensionIdentifier<                      \\\n            CLASSNAME, _proto_TypeTraits, _field_type,                        \\\n            _is_packed>& id) const {                                          \\\n    return _proto_TypeTraits::GetRepeated(id.number(), _extensions_);         \\\n  }                                                                           \\\n                                                                              \\\n  template <typename _proto_TypeTraits,                                       \\\n            ::google::protobuf::internal::FieldType _field_type,                        \\\n            bool _is_packed>                                                  \\\n  inline typename _proto_TypeTraits::Repeated::RepeatedFieldType*             \\\n      MutableRepeatedExtension(                                               \\\n          const ::google::protobuf::internal::ExtensionIdentifier<                      \\\n              CLASSNAME, _proto_TypeTraits, _field_type,                      \\\n              _is_packed>& id) {                                              \\\n    return _proto_TypeTraits::MutableRepeated(id.number(), _field_type,       \\\n                                              _is_packed, &_extensions_);     \\\n  }\n\n}  // namespace internal\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_EXTENSION_SET_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/extension_set_heavy.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Contains methods defined in extension_set.h which cannot be part of the\n// lite library because they use descriptors or reflection.\n\n#include <google/protobuf/io/zero_copy_stream_impl_lite.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/extension_set.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n\nnamespace google {\n\nnamespace protobuf {\nnamespace internal {\n\n// A FieldSkipper used to store unknown MessageSet fields into UnknownFieldSet.\nclass MessageSetFieldSkipper\n    : public UnknownFieldSetFieldSkipper {\n public:\n  explicit MessageSetFieldSkipper(UnknownFieldSet* unknown_fields)\n      : UnknownFieldSetFieldSkipper(unknown_fields) {}\n  virtual ~MessageSetFieldSkipper() {}\n\n  virtual bool SkipMessageSetField(io::CodedInputStream* input,\n                                   int field_number);\n};\nbool MessageSetFieldSkipper::SkipMessageSetField(\n    io::CodedInputStream* input, int field_number) {\n  uint32 length;\n  if (!input->ReadVarint32(&length)) return false;\n  if (unknown_fields_ == NULL) {\n    return input->Skip(length);\n  } else {\n    return input->ReadString(\n        unknown_fields_->AddLengthDelimited(field_number), length);\n  }\n}\n\n\n// Implementation of ExtensionFinder which finds extensions in a given\n// DescriptorPool, using the given MessageFactory to construct sub-objects.\n// This class is implemented in extension_set_heavy.cc.\nclass DescriptorPoolExtensionFinder : public ExtensionFinder {\n public:\n  DescriptorPoolExtensionFinder(const DescriptorPool* pool,\n                                MessageFactory* factory,\n                                const Descriptor* containing_type)\n      : pool_(pool), factory_(factory), containing_type_(containing_type) {}\n  virtual ~DescriptorPoolExtensionFinder() {}\n\n  virtual bool Find(int number, ExtensionInfo* output);\n\n private:\n  const DescriptorPool* pool_;\n  MessageFactory* factory_;\n  const Descriptor* containing_type_;\n};\n\nvoid ExtensionSet::AppendToList(\n    const Descriptor* containing_type,\n    const DescriptorPool* pool,\n    std::vector<const FieldDescriptor*>* output) const {\n  for (ExtensionMap::const_iterator iter = extensions_.begin();\n       iter != extensions_.end(); ++iter) {\n    bool has = false;\n    if (iter->second.is_repeated) {\n      has = iter->second.GetSize() > 0;\n    } else {\n      has = !iter->second.is_cleared;\n    }\n\n    if (has) {\n      // TODO(kenton): Looking up each field by number is somewhat unfortunate.\n      //   Is there a better way?  The problem is that descriptors are lazily-\n      //   initialized, so they might not even be constructed until\n      //   AppendToList() is called.\n\n      if (iter->second.descriptor == NULL) {\n        output->push_back(pool->FindExtensionByNumber(\n            containing_type, iter->first));\n      } else {\n        output->push_back(iter->second.descriptor);\n      }\n    }\n  }\n}\n\ninline FieldDescriptor::Type real_type(FieldType type) {\n  GOOGLE_DCHECK(type > 0 && type <= FieldDescriptor::MAX_TYPE);\n  return static_cast<FieldDescriptor::Type>(type);\n}\n\ninline FieldDescriptor::CppType cpp_type(FieldType type) {\n  return FieldDescriptor::TypeToCppType(\n      static_cast<FieldDescriptor::Type>(type));\n}\n\ninline WireFormatLite::FieldType field_type(FieldType type) {\n  GOOGLE_DCHECK(type > 0 && type <= WireFormatLite::MAX_FIELD_TYPE);\n  return static_cast<WireFormatLite::FieldType>(type);\n}\n\n#define GOOGLE_DCHECK_TYPE(EXTENSION, LABEL, CPPTYPE)                            \\\n  GOOGLE_DCHECK_EQ((EXTENSION).is_repeated ? FieldDescriptor::LABEL_REPEATED     \\\n                                  : FieldDescriptor::LABEL_OPTIONAL,      \\\n            FieldDescriptor::LABEL_##LABEL);                              \\\n  GOOGLE_DCHECK_EQ(cpp_type((EXTENSION).type), FieldDescriptor::CPPTYPE_##CPPTYPE)\n\nconst MessageLite& ExtensionSet::GetMessage(int number,\n                                            const Descriptor* message_type,\n                                            MessageFactory* factory) const {\n  ExtensionMap::const_iterator iter = extensions_.find(number);\n  if (iter == extensions_.end() || iter->second.is_cleared) {\n    // Not present.  Return the default value.\n    return *factory->GetPrototype(message_type);\n  } else {\n    GOOGLE_DCHECK_TYPE(iter->second, OPTIONAL, MESSAGE);\n    if (iter->second.is_lazy) {\n      return iter->second.lazymessage_value->GetMessage(\n          *factory->GetPrototype(message_type));\n    } else {\n      return *iter->second.message_value;\n    }\n  }\n}\n\nMessageLite* ExtensionSet::MutableMessage(const FieldDescriptor* descriptor,\n                                          MessageFactory* factory) {\n  Extension* extension;\n  if (MaybeNewExtension(descriptor->number(), descriptor, &extension)) {\n    extension->type = descriptor->type();\n    GOOGLE_DCHECK_EQ(cpp_type(extension->type), FieldDescriptor::CPPTYPE_MESSAGE);\n    extension->is_repeated = false;\n    extension->is_packed = false;\n    const MessageLite* prototype =\n        factory->GetPrototype(descriptor->message_type());\n    extension->is_lazy = false;\n    extension->message_value = prototype->New(arena_);\n    extension->is_cleared = false;\n    return extension->message_value;\n  } else {\n    GOOGLE_DCHECK_TYPE(*extension, OPTIONAL, MESSAGE);\n    extension->is_cleared = false;\n    if (extension->is_lazy) {\n      return extension->lazymessage_value->MutableMessage(\n          *factory->GetPrototype(descriptor->message_type()));\n    } else {\n      return extension->message_value;\n    }\n  }\n}\n\nMessageLite* ExtensionSet::ReleaseMessage(const FieldDescriptor* descriptor,\n                                          MessageFactory* factory) {\n  ExtensionMap::iterator iter = extensions_.find(descriptor->number());\n  if (iter == extensions_.end()) {\n    // Not present.  Return NULL.\n    return NULL;\n  } else {\n    GOOGLE_DCHECK_TYPE(iter->second, OPTIONAL, MESSAGE);\n    MessageLite* ret = NULL;\n    if (iter->second.is_lazy) {\n      ret = iter->second.lazymessage_value->ReleaseMessage(\n          *factory->GetPrototype(descriptor->message_type()));\n      if (arena_ == NULL) {\n        delete iter->second.lazymessage_value;\n      }\n    } else {\n      if (arena_ != NULL) {\n        ret = (iter->second.message_value)->New();\n        ret->CheckTypeAndMergeFrom(*(iter->second.message_value));\n      } else {\n        ret = iter->second.message_value;\n      }\n    }\n    extensions_.erase(descriptor->number());\n    return ret;\n  }\n}\n\nMessageLite* ExtensionSet::UnsafeArenaReleaseMessage(\n    const FieldDescriptor* descriptor, MessageFactory* factory) {\n  ExtensionMap::iterator iter = extensions_.find(descriptor->number());\n  if (iter == extensions_.end()) {\n    // Not present.  Return NULL.\n    return NULL;\n  } else {\n    GOOGLE_DCHECK_TYPE(iter->second, OPTIONAL, MESSAGE);\n    MessageLite* ret = NULL;\n    if (iter->second.is_lazy) {\n      ret = iter->second.lazymessage_value->UnsafeArenaReleaseMessage(\n          *factory->GetPrototype(descriptor->message_type()));\n      if (arena_ == NULL) {\n        delete iter->second.lazymessage_value;\n      }\n    } else {\n      ret = iter->second.message_value;\n    }\n    extensions_.erase(descriptor->number());\n    return ret;\n  }\n}\n\nExtensionSet::Extension* ExtensionSet::MaybeNewRepeatedExtension(const FieldDescriptor* descriptor) {\n  Extension* extension;\n  if (MaybeNewExtension(descriptor->number(), descriptor, &extension)) {\n    extension->type = descriptor->type();\n    GOOGLE_DCHECK_EQ(cpp_type(extension->type), FieldDescriptor::CPPTYPE_MESSAGE);\n    extension->is_repeated = true;\n    extension->repeated_message_value =\n        ::google::protobuf::Arena::CreateMessage<RepeatedPtrField<MessageLite> >(arena_);\n  } else {\n    GOOGLE_DCHECK_TYPE(*extension, REPEATED, MESSAGE);\n  }\n  return extension;\n}\n\nMessageLite* ExtensionSet::AddMessage(const FieldDescriptor* descriptor,\n                                      MessageFactory* factory) {\n  Extension* extension = MaybeNewRepeatedExtension(descriptor);\n\n  // RepeatedPtrField<Message> does not know how to Add() since it cannot\n  // allocate an abstract object, so we have to be tricky.\n  MessageLite* result = extension->repeated_message_value\n      ->AddFromCleared<GenericTypeHandler<MessageLite> >();\n  if (result == NULL) {\n    const MessageLite* prototype;\n    if (extension->repeated_message_value->size() == 0) {\n      prototype = factory->GetPrototype(descriptor->message_type());\n      GOOGLE_CHECK(prototype != NULL);\n    } else {\n      prototype = &extension->repeated_message_value->Get(0);\n    }\n    result = prototype->New(arena_);\n    extension->repeated_message_value->AddAllocated(result);\n  }\n  return result;\n}\n\nvoid ExtensionSet::AddAllocatedMessage(const FieldDescriptor* descriptor,\n                                       MessageLite* new_entry) {\n  Extension* extension = MaybeNewRepeatedExtension(descriptor);\n\n  extension->repeated_message_value->AddAllocated(new_entry);\n}\n\nstatic bool ValidateEnumUsingDescriptor(const void* arg, int number) {\n  return reinterpret_cast<const EnumDescriptor*>(arg)\n      ->FindValueByNumber(number) != NULL;\n}\n\nbool DescriptorPoolExtensionFinder::Find(int number, ExtensionInfo* output) {\n  const FieldDescriptor* extension =\n      pool_->FindExtensionByNumber(containing_type_, number);\n  if (extension == NULL) {\n    return false;\n  } else {\n    output->type = extension->type();\n    output->is_repeated = extension->is_repeated();\n    output->is_packed = extension->options().packed();\n    output->descriptor = extension;\n    if (extension->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n      output->message_prototype =\n          factory_->GetPrototype(extension->message_type());\n      GOOGLE_CHECK(output->message_prototype != NULL)\n          << \"Extension factory's GetPrototype() returned NULL for extension: \"\n          << extension->full_name();\n    } else if (extension->cpp_type() == FieldDescriptor::CPPTYPE_ENUM) {\n      output->enum_validity_check.func = ValidateEnumUsingDescriptor;\n      output->enum_validity_check.arg = extension->enum_type();\n    }\n\n    return true;\n  }\n}\n\nbool ExtensionSet::ParseField(uint32 tag, io::CodedInputStream* input,\n                              const Message* containing_type,\n                              UnknownFieldSet* unknown_fields) {\n  UnknownFieldSetFieldSkipper skipper(unknown_fields);\n  if (input->GetExtensionPool() == NULL) {\n    GeneratedExtensionFinder finder(containing_type);\n    return ParseField(tag, input, &finder, &skipper);\n  } else {\n    DescriptorPoolExtensionFinder finder(input->GetExtensionPool(),\n                                         input->GetExtensionFactory(),\n                                         containing_type->GetDescriptor());\n    return ParseField(tag, input, &finder, &skipper);\n  }\n}\n\nbool ExtensionSet::ParseMessageSet(io::CodedInputStream* input,\n                                   const Message* containing_type,\n                                   UnknownFieldSet* unknown_fields) {\n  MessageSetFieldSkipper skipper(unknown_fields);\n  if (input->GetExtensionPool() == NULL) {\n    GeneratedExtensionFinder finder(containing_type);\n    return ParseMessageSet(input, &finder, &skipper);\n  } else {\n    DescriptorPoolExtensionFinder finder(input->GetExtensionPool(),\n                                         input->GetExtensionFactory(),\n                                         containing_type->GetDescriptor());\n    return ParseMessageSet(input, &finder, &skipper);\n  }\n}\n\nint ExtensionSet::SpaceUsedExcludingSelf() const {\n  int total_size =\n      extensions_.size() * sizeof(ExtensionMap::value_type);\n  for (ExtensionMap::const_iterator iter = extensions_.begin(),\n       end = extensions_.end();\n       iter != end;\n       ++iter) {\n    total_size += iter->second.SpaceUsedExcludingSelf();\n  }\n  return total_size;\n}\n\ninline int ExtensionSet::RepeatedMessage_SpaceUsedExcludingSelf(\n    RepeatedPtrFieldBase* field) {\n  return field->SpaceUsedExcludingSelf<GenericTypeHandler<Message> >();\n}\n\nint ExtensionSet::Extension::SpaceUsedExcludingSelf() const {\n  int total_size = 0;\n  if (is_repeated) {\n    switch (cpp_type(type)) {\n#define HANDLE_TYPE(UPPERCASE, LOWERCASE)                          \\\n      case FieldDescriptor::CPPTYPE_##UPPERCASE:                   \\\n        total_size += sizeof(*repeated_##LOWERCASE##_value) +      \\\n            repeated_##LOWERCASE##_value->SpaceUsedExcludingSelf();\\\n        break\n\n      HANDLE_TYPE(  INT32,   int32);\n      HANDLE_TYPE(  INT64,   int64);\n      HANDLE_TYPE( UINT32,  uint32);\n      HANDLE_TYPE( UINT64,  uint64);\n      HANDLE_TYPE(  FLOAT,   float);\n      HANDLE_TYPE( DOUBLE,  double);\n      HANDLE_TYPE(   BOOL,    bool);\n      HANDLE_TYPE(   ENUM,    enum);\n      HANDLE_TYPE( STRING,  string);\n#undef HANDLE_TYPE\n\n      case FieldDescriptor::CPPTYPE_MESSAGE:\n        // repeated_message_value is actually a RepeatedPtrField<MessageLite>,\n        // but MessageLite has no SpaceUsed(), so we must directly call\n        // RepeatedPtrFieldBase::SpaceUsedExcludingSelf() with a different type\n        // handler.\n        total_size += sizeof(*repeated_message_value) +\n            RepeatedMessage_SpaceUsedExcludingSelf(repeated_message_value);\n        break;\n    }\n  } else {\n    switch (cpp_type(type)) {\n      case FieldDescriptor::CPPTYPE_STRING:\n        total_size += sizeof(*string_value) +\n                      StringSpaceUsedExcludingSelf(*string_value);\n        break;\n      case FieldDescriptor::CPPTYPE_MESSAGE:\n        if (is_lazy) {\n          total_size += lazymessage_value->SpaceUsed();\n        } else {\n          total_size += down_cast<Message*>(message_value)->SpaceUsed();\n        }\n        break;\n      default:\n        // No extra storage costs for primitive types.\n        break;\n    }\n  }\n  return total_size;\n}\n\n// The Serialize*ToArray methods are only needed in the heavy library, as\n// the lite library only generates SerializeWithCachedSizes.\nuint8* ExtensionSet::SerializeWithCachedSizesToArray(int start_field_number,\n                                                     int end_field_number,\n                                                     uint8* target) const {\n  return InternalSerializeWithCachedSizesToArray(\n      start_field_number, end_field_number, false, target);\n}\n\nuint8* ExtensionSet::SerializeMessageSetWithCachedSizesToArray(\n    uint8* target) const {\n  return InternalSerializeMessageSetWithCachedSizesToArray(false, target);\n}\n\nuint8* ExtensionSet::InternalSerializeWithCachedSizesToArray(\n    int start_field_number, int end_field_number,\n    bool deterministic, uint8* target) const {\n  ExtensionMap::const_iterator iter;\n  for (iter = extensions_.lower_bound(start_field_number);\n       iter != extensions_.end() && iter->first < end_field_number;\n       ++iter) {\n    target = iter->second.InternalSerializeFieldWithCachedSizesToArray(\n        iter->first, deterministic, target);\n  }\n  return target;\n}\n\nuint8* ExtensionSet::InternalSerializeMessageSetWithCachedSizesToArray(\n    bool deterministic, uint8* target) const {\n  ExtensionMap::const_iterator iter;\n  for (iter = extensions_.begin(); iter != extensions_.end(); ++iter) {\n    target = iter->second.InternalSerializeMessageSetItemWithCachedSizesToArray(\n        iter->first, deterministic, target);\n  }\n  return target;\n}\n\nuint8* ExtensionSet::Extension::InternalSerializeFieldWithCachedSizesToArray(\n    int number, bool deterministic, uint8* target) const {\n  if (is_repeated) {\n    if (is_packed) {\n      if (cached_size == 0) return target;\n\n      target = WireFormatLite::WriteTagToArray(number,\n          WireFormatLite::WIRETYPE_LENGTH_DELIMITED, target);\n      target = WireFormatLite::WriteInt32NoTagToArray(cached_size, target);\n\n      switch (real_type(type)) {\n#define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE)                        \\\n        case FieldDescriptor::TYPE_##UPPERCASE:                             \\\n          for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) {  \\\n            target = WireFormatLite::Write##CAMELCASE##NoTagToArray(        \\\n              repeated_##LOWERCASE##_value->Get(i), target);                \\\n          }                                                                 \\\n          break\n\n        HANDLE_TYPE(   INT32,    Int32,   int32);\n        HANDLE_TYPE(   INT64,    Int64,   int64);\n        HANDLE_TYPE(  UINT32,   UInt32,  uint32);\n        HANDLE_TYPE(  UINT64,   UInt64,  uint64);\n        HANDLE_TYPE(  SINT32,   SInt32,   int32);\n        HANDLE_TYPE(  SINT64,   SInt64,   int64);\n        HANDLE_TYPE( FIXED32,  Fixed32,  uint32);\n        HANDLE_TYPE( FIXED64,  Fixed64,  uint64);\n        HANDLE_TYPE(SFIXED32, SFixed32,   int32);\n        HANDLE_TYPE(SFIXED64, SFixed64,   int64);\n        HANDLE_TYPE(   FLOAT,    Float,   float);\n        HANDLE_TYPE(  DOUBLE,   Double,  double);\n        HANDLE_TYPE(    BOOL,     Bool,    bool);\n        HANDLE_TYPE(    ENUM,     Enum,    enum);\n#undef HANDLE_TYPE\n\n        case WireFormatLite::TYPE_STRING:\n        case WireFormatLite::TYPE_BYTES:\n        case WireFormatLite::TYPE_GROUP:\n        case WireFormatLite::TYPE_MESSAGE:\n          GOOGLE_LOG(FATAL) << \"Non-primitive types can't be packed.\";\n          break;\n      }\n    } else {\n      switch (real_type(type)) {\n#define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE)                        \\\n        case FieldDescriptor::TYPE_##UPPERCASE:                             \\\n          for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) {  \\\n            target = WireFormatLite::Write##CAMELCASE##ToArray(number,      \\\n              repeated_##LOWERCASE##_value->Get(i), target);                \\\n          }                                                                 \\\n          break\n\n        HANDLE_TYPE(   INT32,    Int32,   int32);\n        HANDLE_TYPE(   INT64,    Int64,   int64);\n        HANDLE_TYPE(  UINT32,   UInt32,  uint32);\n        HANDLE_TYPE(  UINT64,   UInt64,  uint64);\n        HANDLE_TYPE(  SINT32,   SInt32,   int32);\n        HANDLE_TYPE(  SINT64,   SInt64,   int64);\n        HANDLE_TYPE( FIXED32,  Fixed32,  uint32);\n        HANDLE_TYPE( FIXED64,  Fixed64,  uint64);\n        HANDLE_TYPE(SFIXED32, SFixed32,   int32);\n        HANDLE_TYPE(SFIXED64, SFixed64,   int64);\n        HANDLE_TYPE(   FLOAT,    Float,   float);\n        HANDLE_TYPE(  DOUBLE,   Double,  double);\n        HANDLE_TYPE(    BOOL,     Bool,    bool);\n        HANDLE_TYPE(  STRING,   String,  string);\n        HANDLE_TYPE(   BYTES,    Bytes,  string);\n        HANDLE_TYPE(    ENUM,     Enum,    enum);\n#undef HANDLE_TYPE\n#define HANDLE_TYPE(UPPERCASE, CAMELCASE, LOWERCASE)                        \\\n        case FieldDescriptor::TYPE_##UPPERCASE:                             \\\n          for (int i = 0; i < repeated_##LOWERCASE##_value->size(); i++) {  \\\n            target = WireFormatLite::InternalWrite##CAMELCASE##ToArray(     \\\n                      number, repeated_##LOWERCASE##_value->Get(i),         \\\n                      deterministic, target);                               \\\n          }                                                                 \\\n          break\n\n        HANDLE_TYPE(   GROUP,    Group, message);\n        HANDLE_TYPE( MESSAGE,  Message, message);\n#undef HANDLE_TYPE\n      }\n    }\n  } else if (!is_cleared) {\n    switch (real_type(type)) {\n#define HANDLE_TYPE(UPPERCASE, CAMELCASE, VALUE)                 \\\n      case FieldDescriptor::TYPE_##UPPERCASE:                    \\\n        target = WireFormatLite::Write##CAMELCASE##ToArray(      \\\n            number, VALUE, target); \\\n        break\n\n      HANDLE_TYPE(   INT32,    Int32,    int32_value);\n      HANDLE_TYPE(   INT64,    Int64,    int64_value);\n      HANDLE_TYPE(  UINT32,   UInt32,   uint32_value);\n      HANDLE_TYPE(  UINT64,   UInt64,   uint64_value);\n      HANDLE_TYPE(  SINT32,   SInt32,    int32_value);\n      HANDLE_TYPE(  SINT64,   SInt64,    int64_value);\n      HANDLE_TYPE( FIXED32,  Fixed32,   uint32_value);\n      HANDLE_TYPE( FIXED64,  Fixed64,   uint64_value);\n      HANDLE_TYPE(SFIXED32, SFixed32,    int32_value);\n      HANDLE_TYPE(SFIXED64, SFixed64,    int64_value);\n      HANDLE_TYPE(   FLOAT,    Float,    float_value);\n      HANDLE_TYPE(  DOUBLE,   Double,   double_value);\n      HANDLE_TYPE(    BOOL,     Bool,     bool_value);\n      HANDLE_TYPE(  STRING,   String,  *string_value);\n      HANDLE_TYPE(   BYTES,    Bytes,  *string_value);\n      HANDLE_TYPE(    ENUM,     Enum,     enum_value);\n      HANDLE_TYPE(   GROUP,    Group, *message_value);\n#undef HANDLE_TYPE\n      case FieldDescriptor::TYPE_MESSAGE:\n        if (is_lazy) {\n          target = lazymessage_value->InternalWriteMessageToArray(\n              number, deterministic, target);\n        } else {\n          target = WireFormatLite::InternalWriteMessageToArray(\n              number, *message_value, deterministic, target);\n        }\n        break;\n    }\n  }\n  return target;\n}\n\nuint8*\nExtensionSet::Extension::InternalSerializeMessageSetItemWithCachedSizesToArray(\n    int number, bool deterministic, uint8* target) const {\n  if (type != WireFormatLite::TYPE_MESSAGE || is_repeated) {\n    // Not a valid MessageSet extension, but serialize it the normal way.\n    GOOGLE_LOG(WARNING) << \"Invalid message set extension.\";\n    return InternalSerializeFieldWithCachedSizesToArray(number, deterministic,\n                                                        target);\n  }\n\n  if (is_cleared) return target;\n\n  // Start group.\n  target = io::CodedOutputStream::WriteTagToArray(\n      WireFormatLite::kMessageSetItemStartTag, target);\n  // Write type ID.\n  target = WireFormatLite::WriteUInt32ToArray(\n      WireFormatLite::kMessageSetTypeIdNumber, number, target);\n  // Write message.\n  if (is_lazy) {\n    target = lazymessage_value->WriteMessageToArray(\n        WireFormatLite::kMessageSetMessageNumber, target);\n  } else {\n    target = WireFormatLite::WriteMessageToArray(\n        WireFormatLite::kMessageSetMessageNumber, *message_value, target);\n  }\n  // End group.\n  target = io::CodedOutputStream::WriteTagToArray(\n      WireFormatLite::kMessageSetItemEndTag, target);\n  return target;\n}\n\n\nbool ExtensionSet::ParseFieldMaybeLazily(\n    int wire_type, int field_number, io::CodedInputStream* input,\n    ExtensionFinder* extension_finder,\n    MessageSetFieldSkipper* field_skipper) {\n  return ParseField(WireFormatLite::MakeTag(\n      field_number, static_cast<WireFormatLite::WireType>(wire_type)),\n                    input, extension_finder, field_skipper);\n}\n\nbool ExtensionSet::ParseMessageSet(io::CodedInputStream* input,\n                                   ExtensionFinder* extension_finder,\n                                   MessageSetFieldSkipper* field_skipper) {\n  while (true) {\n    const uint32 tag = input->ReadTag();\n    switch (tag) {\n      case 0:\n        return true;\n      case WireFormatLite::kMessageSetItemStartTag:\n        if (!ParseMessageSetItem(input, extension_finder, field_skipper)) {\n          return false;\n        }\n        break;\n      default:\n        if (!ParseField(tag, input, extension_finder, field_skipper)) {\n          return false;\n        }\n        break;\n    }\n  }\n}\n\nbool ExtensionSet::ParseMessageSet(io::CodedInputStream* input,\n                                   const MessageLite* containing_type) {\n  MessageSetFieldSkipper skipper(NULL);\n  GeneratedExtensionFinder finder(containing_type);\n  return ParseMessageSet(input, &finder, &skipper);\n}\n\nbool ExtensionSet::ParseMessageSetItem(io::CodedInputStream* input,\n                                       ExtensionFinder* extension_finder,\n                                       MessageSetFieldSkipper* field_skipper) {\n  // TODO(kenton):  It would be nice to share code between this and\n  // WireFormatLite::ParseAndMergeMessageSetItem(), but I think the\n  // differences would be hard to factor out.\n\n  // This method parses a group which should contain two fields:\n  //   required int32 type_id = 2;\n  //   required data message = 3;\n\n  uint32 last_type_id = 0;\n\n  // If we see message data before the type_id, we'll append it to this so\n  // we can parse it later.\n  string message_data;\n\n  while (true) {\n    const uint32 tag = input->ReadTag();\n    if (tag == 0) return false;\n\n    switch (tag) {\n      case WireFormatLite::kMessageSetTypeIdTag: {\n        uint32 type_id;\n        if (!input->ReadVarint32(&type_id)) return false;\n        last_type_id = type_id;\n\n        if (!message_data.empty()) {\n          // We saw some message data before the type_id.  Have to parse it\n          // now.\n          io::CodedInputStream sub_input(\n              reinterpret_cast<const uint8*>(message_data.data()),\n              message_data.size());\n          if (!ParseFieldMaybeLazily(WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n                                     last_type_id, &sub_input,\n                                     extension_finder, field_skipper)) {\n            return false;\n          }\n          message_data.clear();\n        }\n\n        break;\n      }\n\n      case WireFormatLite::kMessageSetMessageTag: {\n        if (last_type_id == 0) {\n          // We haven't seen a type_id yet.  Append this data to message_data.\n          string temp;\n          uint32 length;\n          if (!input->ReadVarint32(&length)) return false;\n          if (!input->ReadString(&temp, length)) return false;\n          io::StringOutputStream output_stream(&message_data);\n          io::CodedOutputStream coded_output(&output_stream);\n          coded_output.WriteVarint32(length);\n          coded_output.WriteString(temp);\n        } else {\n          // Already saw type_id, so we can parse this directly.\n          if (!ParseFieldMaybeLazily(WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n                                     last_type_id, input,\n                                     extension_finder, field_skipper)) {\n            return false;\n          }\n        }\n\n        break;\n      }\n\n      case WireFormatLite::kMessageSetItemEndTag: {\n        return true;\n      }\n\n      default: {\n        if (!field_skipper->SkipField(input, tag)) return false;\n      }\n    }\n  }\n}\n\nvoid ExtensionSet::Extension::SerializeMessageSetItemWithCachedSizes(\n    int number,\n    io::CodedOutputStream* output) const {\n  if (type != WireFormatLite::TYPE_MESSAGE || is_repeated) {\n    // Not a valid MessageSet extension, but serialize it the normal way.\n    SerializeFieldWithCachedSizes(number, output);\n    return;\n  }\n\n  if (is_cleared) return;\n\n  // Start group.\n  output->WriteTag(WireFormatLite::kMessageSetItemStartTag);\n\n  // Write type ID.\n  WireFormatLite::WriteUInt32(WireFormatLite::kMessageSetTypeIdNumber,\n                              number,\n                              output);\n  // Write message.\n  if (is_lazy) {\n    lazymessage_value->WriteMessage(\n        WireFormatLite::kMessageSetMessageNumber, output);\n  } else {\n    WireFormatLite::WriteMessageMaybeToArray(\n        WireFormatLite::kMessageSetMessageNumber,\n        *message_value,\n        output);\n  }\n\n  // End group.\n  output->WriteTag(WireFormatLite::kMessageSetItemEndTag);\n}\n\nint ExtensionSet::Extension::MessageSetItemByteSize(int number) const {\n  if (type != WireFormatLite::TYPE_MESSAGE || is_repeated) {\n    // Not a valid MessageSet extension, but compute the byte size for it the\n    // normal way.\n    return ByteSize(number);\n  }\n\n  if (is_cleared) return 0;\n\n  int our_size = WireFormatLite::kMessageSetItemTagsSize;\n\n  // type_id\n  our_size += io::CodedOutputStream::VarintSize32(number);\n\n  // message\n  int message_size = 0;\n  if (is_lazy) {\n    message_size = lazymessage_value->ByteSize();\n  } else {\n    message_size = message_value->ByteSize();\n  }\n\n  our_size += io::CodedOutputStream::VarintSize32(message_size);\n  our_size += message_size;\n\n  return our_size;\n}\n\nvoid ExtensionSet::SerializeMessageSetWithCachedSizes(\n    io::CodedOutputStream* output) const {\n  for (ExtensionMap::const_iterator iter = extensions_.begin();\n       iter != extensions_.end(); ++iter) {\n    iter->second.SerializeMessageSetItemWithCachedSizes(iter->first, output);\n  }\n}\n\nint ExtensionSet::MessageSetByteSize() const {\n  int total_size = 0;\n\n  for (ExtensionMap::const_iterator iter = extensions_.begin();\n       iter != extensions_.end(); ++iter) {\n    total_size += iter->second.MessageSetItemByteSize(iter->first);\n  }\n\n  return total_size;\n}\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/extension_set_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/extension_set.h>\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/unittest_mset.pb.h>\n#include <google/protobuf/test_util.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/arena.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/dynamic_message.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n#include <google/protobuf/stubs/stl_util.h>\n\nnamespace google {\n\nnamespace protobuf {\nnamespace internal {\nnamespace {\n\n// This test closely mirrors google/protobuf/compiler/cpp/unittest.cc\n// except that it uses extensions rather than regular fields.\n\nTEST(ExtensionSetTest, Defaults) {\n  // Check that all default values are set correctly in the initial message.\n  unittest::TestAllExtensions message;\n\n  TestUtil::ExpectExtensionsClear(message);\n\n  // Messages should return pointers to default instances until first use.\n  // (This is not checked by ExpectClear() since it is not actually true after\n  // the fields have been set and then cleared.)\n  EXPECT_EQ(&unittest::OptionalGroup_extension::default_instance(),\n            &message.GetExtension(unittest::optionalgroup_extension));\n  EXPECT_EQ(&unittest::TestAllTypes::NestedMessage::default_instance(),\n            &message.GetExtension(unittest::optional_nested_message_extension));\n  EXPECT_EQ(&unittest::ForeignMessage::default_instance(),\n            &message.GetExtension(\n              unittest::optional_foreign_message_extension));\n  EXPECT_EQ(&unittest_import::ImportMessage::default_instance(),\n            &message.GetExtension(unittest::optional_import_message_extension));\n}\n\nTEST(ExtensionSetTest, Accessors) {\n  // Set every field to a unique value then go back and check all those\n  // values.\n  unittest::TestAllExtensions message;\n\n  TestUtil::SetAllExtensions(&message);\n  TestUtil::ExpectAllExtensionsSet(message);\n\n  TestUtil::ModifyRepeatedExtensions(&message);\n  TestUtil::ExpectRepeatedExtensionsModified(message);\n}\n\nTEST(ExtensionSetTest, Clear) {\n  // Set every field to a unique value, clear the message, then check that\n  // it is cleared.\n  unittest::TestAllExtensions message;\n\n  TestUtil::SetAllExtensions(&message);\n  message.Clear();\n  TestUtil::ExpectExtensionsClear(message);\n\n  // Unlike with the defaults test, we do NOT expect that requesting embedded\n  // messages will return a pointer to the default instance.  Instead, they\n  // should return the objects that were created when mutable_blah() was\n  // called.\n  EXPECT_NE(&unittest::OptionalGroup_extension::default_instance(),\n            &message.GetExtension(unittest::optionalgroup_extension));\n  EXPECT_NE(&unittest::TestAllTypes::NestedMessage::default_instance(),\n            &message.GetExtension(unittest::optional_nested_message_extension));\n  EXPECT_NE(&unittest::ForeignMessage::default_instance(),\n            &message.GetExtension(\n              unittest::optional_foreign_message_extension));\n  EXPECT_NE(&unittest_import::ImportMessage::default_instance(),\n            &message.GetExtension(unittest::optional_import_message_extension));\n\n  // Make sure setting stuff again after clearing works.  (This takes slightly\n  // different code paths since the objects are reused.)\n  TestUtil::SetAllExtensions(&message);\n  TestUtil::ExpectAllExtensionsSet(message);\n}\n\nTEST(ExtensionSetTest, ClearOneField) {\n  // Set every field to a unique value, then clear one value and insure that\n  // only that one value is cleared.\n  unittest::TestAllExtensions message;\n\n  TestUtil::SetAllExtensions(&message);\n  int64 original_value =\n    message.GetExtension(unittest::optional_int64_extension);\n\n  // Clear the field and make sure it shows up as cleared.\n  message.ClearExtension(unittest::optional_int64_extension);\n  EXPECT_FALSE(message.HasExtension(unittest::optional_int64_extension));\n  EXPECT_EQ(0, message.GetExtension(unittest::optional_int64_extension));\n\n  // Other adjacent fields should not be cleared.\n  EXPECT_TRUE(message.HasExtension(unittest::optional_int32_extension));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_uint32_extension));\n\n  // Make sure if we set it again, then all fields are set.\n  message.SetExtension(unittest::optional_int64_extension, original_value);\n  TestUtil::ExpectAllExtensionsSet(message);\n}\n\nTEST(ExtensionSetTest, SetAllocatedExtension) {\n  unittest::TestAllExtensions message;\n  EXPECT_FALSE(message.HasExtension(\n      unittest::optional_foreign_message_extension));\n  // Add a extension using SetAllocatedExtension\n  unittest::ForeignMessage* foreign_message = new unittest::ForeignMessage();\n  message.SetAllocatedExtension(unittest::optional_foreign_message_extension,\n                                foreign_message);\n  EXPECT_TRUE(message.HasExtension(\n      unittest::optional_foreign_message_extension));\n  EXPECT_EQ(foreign_message,\n            message.MutableExtension(\n                unittest::optional_foreign_message_extension));\n  EXPECT_EQ(foreign_message,\n            &message.GetExtension(\n                unittest::optional_foreign_message_extension));\n\n  // SetAllocatedExtension should delete the previously existing extension.\n  // (We reply on unittest to check memory leaks for this case)\n  message.SetAllocatedExtension(unittest::optional_foreign_message_extension,\n                                new unittest::ForeignMessage());\n\n  // SetAllocatedExtension with a NULL parameter is equivalent to ClearExtenion.\n  message.SetAllocatedExtension(unittest::optional_foreign_message_extension,\n                                NULL);\n  EXPECT_FALSE(message.HasExtension(\n      unittest::optional_foreign_message_extension));\n}\n\nTEST(ExtensionSetTest, ReleaseExtension) {\n  proto2_wireformat_unittest::TestMessageSet message;\n  EXPECT_FALSE(message.HasExtension(\n      unittest::TestMessageSetExtension1::message_set_extension));\n  // Add a extension using SetAllocatedExtension\n  unittest::TestMessageSetExtension1* extension =\n      new unittest::TestMessageSetExtension1();\n  message.SetAllocatedExtension(\n      unittest::TestMessageSetExtension1::message_set_extension,\n      extension);\n  EXPECT_TRUE(message.HasExtension(\n      unittest::TestMessageSetExtension1::message_set_extension));\n  // Release the extension using ReleaseExtension\n  unittest::TestMessageSetExtension1* released_extension =\n      message.ReleaseExtension(\n          unittest::TestMessageSetExtension1::message_set_extension);\n  EXPECT_EQ(extension, released_extension);\n  EXPECT_FALSE(message.HasExtension(\n      unittest::TestMessageSetExtension1::message_set_extension));\n  // ReleaseExtension will return the underlying object even after\n  // ClearExtension is called.\n  message.SetAllocatedExtension(\n      unittest::TestMessageSetExtension1::message_set_extension,\n      extension);\n  message.ClearExtension(\n      unittest::TestMessageSetExtension1::message_set_extension);\n  released_extension = message.ReleaseExtension(\n      unittest::TestMessageSetExtension1::message_set_extension);\n  EXPECT_TRUE(released_extension != NULL);\n  delete released_extension;\n}\n\nTEST(ExtensionSetTest, ArenaUnsafeArenaSetAllocatedAndRelease) {\n  ::google::protobuf::Arena arena;\n  unittest::TestAllExtensions* message =\n      ::google::protobuf::Arena::CreateMessage<unittest::TestAllExtensions>(&arena);\n  unittest::ForeignMessage extension;\n  message->UnsafeArenaSetAllocatedExtension(\n      unittest::optional_foreign_message_extension,\n      &extension);\n  // No copy when set.\n  unittest::ForeignMessage* mutable_extension =\n      message->MutableExtension(unittest::optional_foreign_message_extension);\n  EXPECT_EQ(&extension, mutable_extension);\n  // No copy when unsafe released.\n  unittest::ForeignMessage* released_extension =\n      message->UnsafeArenaReleaseExtension(\n          unittest::optional_foreign_message_extension);\n  EXPECT_EQ(&extension, released_extension);\n  EXPECT_FALSE(message->HasExtension(\n      unittest::optional_foreign_message_extension));\n  // Set the ownership back and let the destructors run.  It should not take\n  // ownership, so this should not crash.\n  message->UnsafeArenaSetAllocatedExtension(\n      unittest::optional_foreign_message_extension,\n      &extension);\n}\n\nTEST(ExtensionSetTest, UnsafeArenaSetAllocatedAndRelease) {\n  unittest::TestAllExtensions message;\n  unittest::ForeignMessage* extension = new unittest::ForeignMessage();\n  message.UnsafeArenaSetAllocatedExtension(\n      unittest::optional_foreign_message_extension,\n      extension);\n  // No copy when set.\n  unittest::ForeignMessage* mutable_extension =\n      message.MutableExtension(unittest::optional_foreign_message_extension);\n  EXPECT_EQ(extension, mutable_extension);\n  // No copy when unsafe released.\n  unittest::ForeignMessage* released_extension =\n      message.UnsafeArenaReleaseExtension(\n          unittest::optional_foreign_message_extension);\n  EXPECT_EQ(extension, released_extension);\n  EXPECT_FALSE(message.HasExtension(\n      unittest::optional_foreign_message_extension));\n  // Set the ownership back and let the destructors run.  It should take\n  // ownership, so this should not leak.\n  message.UnsafeArenaSetAllocatedExtension(\n      unittest::optional_foreign_message_extension,\n      extension);\n}\n\nTEST(ExtensionSetTest, ArenaUnsafeArenaReleaseOfHeapAlloc) {\n  ::google::protobuf::Arena arena;\n  unittest::TestAllExtensions* message =\n      ::google::protobuf::Arena::CreateMessage<unittest::TestAllExtensions>(&arena);\n  unittest::ForeignMessage* extension = new unittest::ForeignMessage;\n  message->SetAllocatedExtension(\n      unittest::optional_foreign_message_extension,\n      extension);\n  // The arena should maintain ownership of the heap allocated proto because we\n  // used UnsafeArenaReleaseExtension.  The leak checker will ensure this.\n  unittest::ForeignMessage* released_extension =\n      message->UnsafeArenaReleaseExtension(\n          unittest::optional_foreign_message_extension);\n  EXPECT_EQ(extension, released_extension);\n  EXPECT_FALSE(message->HasExtension(\n      unittest::optional_foreign_message_extension));\n}\n\n\nTEST(ExtensionSetTest, CopyFrom) {\n  unittest::TestAllExtensions message1, message2;\n\n  TestUtil::SetAllExtensions(&message1);\n  message2.CopyFrom(message1);\n  TestUtil::ExpectAllExtensionsSet(message2);\n  message2.CopyFrom(message1);  // exercise copy when fields already exist\n  TestUtil::ExpectAllExtensionsSet(message2);\n}\n\nTEST(ExtensioSetTest, CopyFromPacked) {\n  unittest::TestPackedExtensions message1, message2;\n\n  TestUtil::SetPackedExtensions(&message1);\n  message2.CopyFrom(message1);\n  TestUtil::ExpectPackedExtensionsSet(message2);\n  message2.CopyFrom(message1);  // exercise copy when fields already exist\n  TestUtil::ExpectPackedExtensionsSet(message2);\n}\n\nTEST(ExtensionSetTest, CopyFromUpcasted) {\n  unittest::TestAllExtensions message1, message2;\n  const Message& upcasted_message = message1;\n\n  TestUtil::SetAllExtensions(&message1);\n  message2.CopyFrom(upcasted_message);\n  TestUtil::ExpectAllExtensionsSet(message2);\n  // exercise copy when fields already exist\n  message2.CopyFrom(upcasted_message);\n  TestUtil::ExpectAllExtensionsSet(message2);\n}\n\nTEST(ExtensionSetTest, SwapWithEmpty) {\n  unittest::TestAllExtensions message1, message2;\n  TestUtil::SetAllExtensions(&message1);\n\n  TestUtil::ExpectAllExtensionsSet(message1);\n  TestUtil::ExpectExtensionsClear(message2);\n  message1.Swap(&message2);\n  TestUtil::ExpectAllExtensionsSet(message2);\n  TestUtil::ExpectExtensionsClear(message1);\n}\n\nTEST(ExtensionSetTest, SwapWithSelf) {\n  unittest::TestAllExtensions message;\n  TestUtil::SetAllExtensions(&message);\n\n  TestUtil::ExpectAllExtensionsSet(message);\n  message.Swap(&message);\n  TestUtil::ExpectAllExtensionsSet(message);\n}\n\nTEST(ExtensionSetTest, SwapExtension) {\n  unittest::TestAllExtensions message1;\n  unittest::TestAllExtensions message2;\n\n  TestUtil::SetAllExtensions(&message1);\n  vector<const FieldDescriptor*> fields;\n\n  // Swap empty fields.\n  const Reflection* reflection = message1.GetReflection();\n  reflection->SwapFields(&message1, &message2, fields);\n  TestUtil::ExpectAllExtensionsSet(message1);\n  TestUtil::ExpectExtensionsClear(message2);\n\n  // Swap two extensions.\n  fields.push_back(\n      reflection->FindKnownExtensionByNumber(12));\n  fields.push_back(\n      reflection->FindKnownExtensionByNumber(25));\n  reflection->SwapFields(&message1, &message2, fields);\n\n  EXPECT_TRUE(message1.HasExtension(unittest::optional_int32_extension));\n  EXPECT_FALSE(message1.HasExtension(unittest::optional_double_extension));\n  EXPECT_FALSE(message1.HasExtension(unittest::optional_cord_extension));\n\n  EXPECT_FALSE(message2.HasExtension(unittest::optional_int32_extension));\n  EXPECT_TRUE(message2.HasExtension(unittest::optional_double_extension));\n  EXPECT_TRUE(message2.HasExtension(unittest::optional_cord_extension));\n}\n\nTEST(ExtensionSetTest, SwapExtensionWithEmpty) {\n  unittest::TestAllExtensions message1;\n  unittest::TestAllExtensions message2;\n  unittest::TestAllExtensions message3;\n\n  TestUtil::SetAllExtensions(&message3);\n\n  const Reflection* reflection = message3.GetReflection();\n  vector<const FieldDescriptor*> fields;\n  reflection->ListFields(message3, &fields);\n\n  reflection->SwapFields(&message1, &message2, fields);\n\n  TestUtil::ExpectExtensionsClear(message1);\n  TestUtil::ExpectExtensionsClear(message2);\n}\n\nTEST(ExtensionSetTest, SwapExtensionBothFull) {\n  unittest::TestAllExtensions message1;\n  unittest::TestAllExtensions message2;\n\n  TestUtil::SetAllExtensions(&message1);\n  TestUtil::SetAllExtensions(&message2);\n\n  const Reflection* reflection = message1.GetReflection();\n  vector<const FieldDescriptor*> fields;\n  reflection->ListFields(message1, &fields);\n\n  reflection->SwapFields(&message1, &message2, fields);\n\n  TestUtil::ExpectAllExtensionsSet(message1);\n  TestUtil::ExpectAllExtensionsSet(message2);\n}\n\nTEST(ExtensionSetTest, ArenaSetAllExtension) {\n  ::google::protobuf::Arena arena1;\n  unittest::TestAllExtensions* message1 =\n      ::google::protobuf::Arena::CreateMessage<unittest::TestAllExtensions>(&arena1);\n  TestUtil::SetAllExtensions(message1);\n  TestUtil::ExpectAllExtensionsSet(*message1);\n}\n\nTEST(ExtensionSetTest, ArenaCopyConstructor) {\n  ::google::protobuf::Arena arena1;\n  unittest::TestAllExtensions* message1 =\n      ::google::protobuf::Arena::CreateMessage<unittest::TestAllExtensions>(&arena1);\n  TestUtil::SetAllExtensions(message1);\n  unittest::TestAllExtensions message2(*message1);\n  arena1.Reset();\n  TestUtil::ExpectAllExtensionsSet(message2);\n}\n\nTEST(ExtensionSetTest, ArenaMergeFrom) {\n  ::google::protobuf::Arena arena1;\n  unittest::TestAllExtensions* message1 =\n      ::google::protobuf::Arena::CreateMessage<unittest::TestAllExtensions>(&arena1);\n  TestUtil::SetAllExtensions(message1);\n  unittest::TestAllExtensions message2;\n  message2.MergeFrom(*message1);\n  arena1.Reset();\n  TestUtil::ExpectAllExtensionsSet(message2);\n}\n\nTEST(ExtensionSetTest, ArenaSetAllocatedMessageAndRelease) {\n  ::google::protobuf::Arena arena;\n  unittest::TestAllExtensions* message =\n      ::google::protobuf::Arena::CreateMessage<unittest::TestAllExtensions>(&arena);\n  EXPECT_FALSE(message->HasExtension(\n      unittest::optional_foreign_message_extension));\n  // Add a extension using SetAllocatedExtension\n  unittest::ForeignMessage* foreign_message = new unittest::ForeignMessage();\n  message->SetAllocatedExtension(unittest::optional_foreign_message_extension,\n                                 foreign_message);\n  // foreign_message is now owned by the arena.\n  EXPECT_EQ(foreign_message,\n            message->MutableExtension(\n                unittest::optional_foreign_message_extension));\n\n  // Underlying message is copied, and returned.\n  unittest::ForeignMessage* released_message = message->ReleaseExtension(\n      unittest::optional_foreign_message_extension);\n  delete released_message;\n  EXPECT_FALSE(message->HasExtension(\n      unittest::optional_foreign_message_extension));\n}\n\nTEST(ExtensionSetTest, SwapExtensionBothFullWithArena) {\n  ::google::protobuf::Arena arena1;\n  google::protobuf::scoped_ptr<google::protobuf::Arena> arena2(new ::google::protobuf::Arena());\n\n  unittest::TestAllExtensions* message1 =\n      Arena::CreateMessage<unittest::TestAllExtensions>(&arena1);\n  unittest::TestAllExtensions* message2 =\n      Arena::CreateMessage<unittest::TestAllExtensions>(arena2.get());\n\n  TestUtil::SetAllExtensions(message1);\n  TestUtil::SetAllExtensions(message2);\n  message1->SetExtension(unittest::optional_int32_extension, 1);\n  message2->SetExtension(unittest::optional_int32_extension, 2);\n  message1->Swap(message2);\n  EXPECT_EQ(2, message1->GetExtension(unittest::optional_int32_extension));\n  EXPECT_EQ(1, message2->GetExtension(unittest::optional_int32_extension));\n  // Re-set the original values so ExpectAllExtensionsSet is happy.\n  message1->SetExtension(unittest::optional_int32_extension, 101);\n  message2->SetExtension(unittest::optional_int32_extension, 101);\n  TestUtil::ExpectAllExtensionsSet(*message1);\n  TestUtil::ExpectAllExtensionsSet(*message2);\n  arena2.reset(NULL);\n  TestUtil::ExpectAllExtensionsSet(*message1);\n  // Test corner cases, when one is empty and other is not.\n  ::google::protobuf::Arena arena3, arena4;\n\n  unittest::TestAllExtensions* message3 =\n      Arena::CreateMessage<unittest::TestAllExtensions>(&arena3);\n  unittest::TestAllExtensions* message4 =\n      Arena::CreateMessage<unittest::TestAllExtensions>(&arena4);\n  TestUtil::SetAllExtensions(message3);\n  message3->Swap(message4);\n  arena3.Reset();\n  TestUtil::ExpectAllExtensionsSet(*message4);\n}\n\nTEST(ExtensionSetTest, SwapFieldsOfExtensionBothFullWithArena) {\n  google::protobuf::Arena arena1;\n  google::protobuf::Arena* arena2 = new ::google::protobuf::Arena();\n\n  unittest::TestAllExtensions* message1 =\n      Arena::CreateMessage<unittest::TestAllExtensions>(&arena1);\n  unittest::TestAllExtensions* message2 =\n      Arena::CreateMessage<unittest::TestAllExtensions>(arena2);\n\n  TestUtil::SetAllExtensions(message1);\n  TestUtil::SetAllExtensions(message2);\n\n  const Reflection* reflection = message1->GetReflection();\n  vector<const FieldDescriptor*> fields;\n  reflection->ListFields(*message1, &fields);\n  reflection->SwapFields(message1, message2, fields);\n  TestUtil::ExpectAllExtensionsSet(*message1);\n  TestUtil::ExpectAllExtensionsSet(*message2);\n  delete arena2;\n  TestUtil::ExpectAllExtensionsSet(*message1);\n}\n\nTEST(ExtensionSetTest, SwapExtensionWithSelf) {\n  unittest::TestAllExtensions message1;\n\n  TestUtil::SetAllExtensions(&message1);\n\n  vector<const FieldDescriptor*> fields;\n  const Reflection* reflection = message1.GetReflection();\n  reflection->ListFields(message1, &fields);\n  reflection->SwapFields(&message1, &message1, fields);\n\n  TestUtil::ExpectAllExtensionsSet(message1);\n}\n\nTEST(ExtensionSetTest, SerializationToArray) {\n  // Serialize as TestAllExtensions and parse as TestAllTypes to insure wire\n  // compatibility of extensions.\n  //\n  // This checks serialization to a flat array by explicitly reserving space in\n  // the string and calling the generated message's\n  // SerializeWithCachedSizesToArray.\n  unittest::TestAllExtensions source;\n  unittest::TestAllTypes destination;\n  TestUtil::SetAllExtensions(&source);\n  int size = source.ByteSize();\n  string data;\n  data.resize(size);\n  uint8* target = reinterpret_cast<uint8*>(string_as_array(&data));\n  uint8* end = source.SerializeWithCachedSizesToArray(target);\n  EXPECT_EQ(size, end - target);\n  EXPECT_TRUE(destination.ParseFromString(data));\n  TestUtil::ExpectAllFieldsSet(destination);\n}\n\nTEST(ExtensionSetTest, SerializationToStream) {\n  // Serialize as TestAllExtensions and parse as TestAllTypes to insure wire\n  // compatibility of extensions.\n  //\n  // This checks serialization to an output stream by creating an array output\n  // stream that can only buffer 1 byte at a time - this prevents the message\n  // from ever jumping to the fast path, ensuring that serialization happens via\n  // the CodedOutputStream.\n  unittest::TestAllExtensions source;\n  unittest::TestAllTypes destination;\n  TestUtil::SetAllExtensions(&source);\n  int size = source.ByteSize();\n  string data;\n  data.resize(size);\n  {\n    io::ArrayOutputStream array_stream(string_as_array(&data), size, 1);\n    io::CodedOutputStream output_stream(&array_stream);\n    source.SerializeWithCachedSizes(&output_stream);\n    ASSERT_FALSE(output_stream.HadError());\n  }\n  EXPECT_TRUE(destination.ParseFromString(data));\n  TestUtil::ExpectAllFieldsSet(destination);\n}\n\nTEST(ExtensionSetTest, PackedSerializationToArray) {\n  // Serialize as TestPackedExtensions and parse as TestPackedTypes to insure\n  // wire compatibility of extensions.\n  //\n  // This checks serialization to a flat array by explicitly reserving space in\n  // the string and calling the generated message's\n  // SerializeWithCachedSizesToArray.\n  unittest::TestPackedExtensions source;\n  unittest::TestPackedTypes destination;\n  TestUtil::SetPackedExtensions(&source);\n  int size = source.ByteSize();\n  string data;\n  data.resize(size);\n  uint8* target = reinterpret_cast<uint8*>(string_as_array(&data));\n  uint8* end = source.SerializeWithCachedSizesToArray(target);\n  EXPECT_EQ(size, end - target);\n  EXPECT_TRUE(destination.ParseFromString(data));\n  TestUtil::ExpectPackedFieldsSet(destination);\n}\n\nTEST(ExtensionSetTest, PackedSerializationToStream) {\n  // Serialize as TestPackedExtensions and parse as TestPackedTypes to insure\n  // wire compatibility of extensions.\n  //\n  // This checks serialization to an output stream by creating an array output\n  // stream that can only buffer 1 byte at a time - this prevents the message\n  // from ever jumping to the fast path, ensuring that serialization happens via\n  // the CodedOutputStream.\n  unittest::TestPackedExtensions source;\n  unittest::TestPackedTypes destination;\n  TestUtil::SetPackedExtensions(&source);\n  int size = source.ByteSize();\n  string data;\n  data.resize(size);\n  {\n    io::ArrayOutputStream array_stream(string_as_array(&data), size, 1);\n    io::CodedOutputStream output_stream(&array_stream);\n    source.SerializeWithCachedSizes(&output_stream);\n    ASSERT_FALSE(output_stream.HadError());\n  }\n  EXPECT_TRUE(destination.ParseFromString(data));\n  TestUtil::ExpectPackedFieldsSet(destination);\n}\n\nTEST(ExtensionSetTest, Parsing) {\n  // Serialize as TestAllTypes and parse as TestAllExtensions.\n  unittest::TestAllTypes source;\n  unittest::TestAllExtensions destination;\n  string data;\n\n  TestUtil::SetAllFields(&source);\n  source.SerializeToString(&data);\n  EXPECT_TRUE(destination.ParseFromString(data));\n  TestUtil::SetOneofFields(&destination);\n  TestUtil::ExpectAllExtensionsSet(destination);\n}\n\nTEST(ExtensionSetTest, PackedParsing) {\n  // Serialize as TestPackedTypes and parse as TestPackedExtensions.\n  unittest::TestPackedTypes source;\n  unittest::TestPackedExtensions destination;\n  string data;\n\n  TestUtil::SetPackedFields(&source);\n  source.SerializeToString(&data);\n  EXPECT_TRUE(destination.ParseFromString(data));\n  TestUtil::ExpectPackedExtensionsSet(destination);\n}\n\nTEST(ExtensionSetTest, PackedToUnpackedParsing) {\n  unittest::TestPackedTypes source;\n  unittest::TestUnpackedExtensions destination;\n  string data;\n\n  TestUtil::SetPackedFields(&source);\n  source.SerializeToString(&data);\n  EXPECT_TRUE(destination.ParseFromString(data));\n  TestUtil::ExpectUnpackedExtensionsSet(destination);\n\n  // Reserialize\n  unittest::TestUnpackedTypes unpacked;\n  TestUtil::SetUnpackedFields(&unpacked);\n  EXPECT_TRUE(unpacked.SerializeAsString() == destination.SerializeAsString());\n\n  // Make sure we can add extensions.\n  destination.AddExtension(unittest::unpacked_int32_extension, 1);\n  destination.AddExtension(unittest::unpacked_enum_extension,\n                           protobuf_unittest::FOREIGN_BAR);\n}\n\nTEST(ExtensionSetTest, UnpackedToPackedParsing) {\n  unittest::TestUnpackedTypes source;\n  unittest::TestPackedExtensions destination;\n  string data;\n\n  TestUtil::SetUnpackedFields(&source);\n  source.SerializeToString(&data);\n  EXPECT_TRUE(destination.ParseFromString(data));\n  TestUtil::ExpectPackedExtensionsSet(destination);\n\n  // Reserialize\n  unittest::TestPackedTypes packed;\n  TestUtil::SetPackedFields(&packed);\n  EXPECT_TRUE(packed.SerializeAsString() == destination.SerializeAsString());\n\n  // Make sure we can add extensions.\n  destination.AddExtension(unittest::packed_int32_extension, 1);\n  destination.AddExtension(unittest::packed_enum_extension,\n                           protobuf_unittest::FOREIGN_BAR);\n}\n\nTEST(ExtensionSetTest, IsInitialized) {\n  // Test that IsInitialized() returns false if required fields in nested\n  // extensions are missing.\n  unittest::TestAllExtensions message;\n\n  EXPECT_TRUE(message.IsInitialized());\n\n  message.MutableExtension(unittest::TestRequired::single);\n  EXPECT_FALSE(message.IsInitialized());\n\n  message.MutableExtension(unittest::TestRequired::single)->set_a(1);\n  EXPECT_FALSE(message.IsInitialized());\n  message.MutableExtension(unittest::TestRequired::single)->set_b(2);\n  EXPECT_FALSE(message.IsInitialized());\n  message.MutableExtension(unittest::TestRequired::single)->set_c(3);\n  EXPECT_TRUE(message.IsInitialized());\n\n  message.AddExtension(unittest::TestRequired::multi);\n  EXPECT_FALSE(message.IsInitialized());\n\n  message.MutableExtension(unittest::TestRequired::multi, 0)->set_a(1);\n  EXPECT_FALSE(message.IsInitialized());\n  message.MutableExtension(unittest::TestRequired::multi, 0)->set_b(2);\n  EXPECT_FALSE(message.IsInitialized());\n  message.MutableExtension(unittest::TestRequired::multi, 0)->set_c(3);\n  EXPECT_TRUE(message.IsInitialized());\n}\n\nTEST(ExtensionSetTest, MutableString) {\n  // Test the mutable string accessors.\n  unittest::TestAllExtensions message;\n\n  message.MutableExtension(unittest::optional_string_extension)->assign(\"foo\");\n  EXPECT_TRUE(message.HasExtension(unittest::optional_string_extension));\n  EXPECT_EQ(\"foo\", message.GetExtension(unittest::optional_string_extension));\n\n  message.AddExtension(unittest::repeated_string_extension)->assign(\"bar\");\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_string_extension));\n  EXPECT_EQ(\"bar\",\n            message.GetExtension(unittest::repeated_string_extension, 0));\n}\n\nTEST(ExtensionSetTest, SpaceUsedExcludingSelf) {\n  // Scalar primitive extensions should increase the extension set size by a\n  // minimum of the size of the primitive type.\n#define TEST_SCALAR_EXTENSIONS_SPACE_USED(type, value)                        \\\n  do {                                                                        \\\n    unittest::TestAllExtensions message;                                      \\\n    const int base_size = message.SpaceUsed();                                \\\n    message.SetExtension(unittest::optional_##type##_extension, value);       \\\n    int min_expected_size = base_size +                                       \\\n        sizeof(message.GetExtension(unittest::optional_##type##_extension));  \\\n    EXPECT_LE(min_expected_size, message.SpaceUsed());                        \\\n  } while (0)\n\n  TEST_SCALAR_EXTENSIONS_SPACE_USED(int32   , 101);\n  TEST_SCALAR_EXTENSIONS_SPACE_USED(int64   , 102);\n  TEST_SCALAR_EXTENSIONS_SPACE_USED(uint32  , 103);\n  TEST_SCALAR_EXTENSIONS_SPACE_USED(uint64  , 104);\n  TEST_SCALAR_EXTENSIONS_SPACE_USED(sint32  , 105);\n  TEST_SCALAR_EXTENSIONS_SPACE_USED(sint64  , 106);\n  TEST_SCALAR_EXTENSIONS_SPACE_USED(fixed32 , 107);\n  TEST_SCALAR_EXTENSIONS_SPACE_USED(fixed64 , 108);\n  TEST_SCALAR_EXTENSIONS_SPACE_USED(sfixed32, 109);\n  TEST_SCALAR_EXTENSIONS_SPACE_USED(sfixed64, 110);\n  TEST_SCALAR_EXTENSIONS_SPACE_USED(float   , 111);\n  TEST_SCALAR_EXTENSIONS_SPACE_USED(double  , 112);\n  TEST_SCALAR_EXTENSIONS_SPACE_USED(bool    , true);\n#undef TEST_SCALAR_EXTENSIONS_SPACE_USED\n  {\n    unittest::TestAllExtensions message;\n    const int base_size = message.SpaceUsed();\n    message.SetExtension(unittest::optional_nested_enum_extension,\n                         unittest::TestAllTypes::FOO);\n    int min_expected_size = base_size +\n        sizeof(message.GetExtension(unittest::optional_nested_enum_extension));\n    EXPECT_LE(min_expected_size, message.SpaceUsed());\n  }\n  {\n    // Strings may cause extra allocations depending on their length; ensure\n    // that gets included as well.\n    unittest::TestAllExtensions message;\n    const int base_size = message.SpaceUsed();\n    const string s(\"this is a fairly large string that will cause some \"\n                   \"allocation in order to store it in the extension\");\n    message.SetExtension(unittest::optional_string_extension, s);\n    int min_expected_size = base_size + s.length();\n    EXPECT_LE(min_expected_size, message.SpaceUsed());\n  }\n  {\n    // Messages also have additional allocation that need to be counted.\n    unittest::TestAllExtensions message;\n    const int base_size = message.SpaceUsed();\n    unittest::ForeignMessage foreign;\n    foreign.set_c(42);\n    message.MutableExtension(unittest::optional_foreign_message_extension)->\n        CopyFrom(foreign);\n    int min_expected_size = base_size + foreign.SpaceUsed();\n    EXPECT_LE(min_expected_size, message.SpaceUsed());\n  }\n\n  // Repeated primitive extensions will increase space used by at least a\n  // RepeatedField<T>, and will cause additional allocations when the array\n  // gets too big for the initial space.\n  // This macro:\n  //   - Adds a value to the repeated extension, then clears it, establishing\n  //     the base size.\n  //   - Adds a small number of values, testing that it doesn't increase the\n  //     SpaceUsed()\n  //   - Adds a large number of values (requiring allocation in the repeated\n  //     field), and ensures that that allocation is included in SpaceUsed()\n#define TEST_REPEATED_EXTENSIONS_SPACE_USED(type, cpptype, value)              \\\n  do {                                                                         \\\n    unittest::TestAllExtensions message;                                       \\\n    const int base_size = message.SpaceUsed();                                 \\\n    int min_expected_size = sizeof(RepeatedField<cpptype>) + base_size;        \\\n    message.AddExtension(unittest::repeated_##type##_extension, value);        \\\n    message.ClearExtension(unittest::repeated_##type##_extension);             \\\n    const int empty_repeated_field_size = message.SpaceUsed();                 \\\n    EXPECT_LE(min_expected_size, empty_repeated_field_size) << #type;          \\\n    message.AddExtension(unittest::repeated_##type##_extension, value);        \\\n    message.AddExtension(unittest::repeated_##type##_extension, value);        \\\n    EXPECT_EQ(empty_repeated_field_size, message.SpaceUsed()) << #type;        \\\n    message.ClearExtension(unittest::repeated_##type##_extension);             \\\n    for (int i = 0; i < 16; ++i) {                                             \\\n      message.AddExtension(unittest::repeated_##type##_extension, value);      \\\n    }                                                                          \\\n    int expected_size = sizeof(cpptype) * (16 -                                \\\n        kMinRepeatedFieldAllocationSize) + empty_repeated_field_size;          \\\n    EXPECT_EQ(expected_size, message.SpaceUsed()) << #type;                    \\\n  } while (0)\n\n  TEST_REPEATED_EXTENSIONS_SPACE_USED(int32   , int32 , 101);\n  TEST_REPEATED_EXTENSIONS_SPACE_USED(int64   , int64 , 102);\n  TEST_REPEATED_EXTENSIONS_SPACE_USED(uint32  , uint32, 103);\n  TEST_REPEATED_EXTENSIONS_SPACE_USED(uint64  , uint64, 104);\n  TEST_REPEATED_EXTENSIONS_SPACE_USED(sint32  , int32 , 105);\n  TEST_REPEATED_EXTENSIONS_SPACE_USED(sint64  , int64 , 106);\n  TEST_REPEATED_EXTENSIONS_SPACE_USED(fixed32 , uint32, 107);\n  TEST_REPEATED_EXTENSIONS_SPACE_USED(fixed64 , uint64, 108);\n  TEST_REPEATED_EXTENSIONS_SPACE_USED(sfixed32, int32 , 109);\n  TEST_REPEATED_EXTENSIONS_SPACE_USED(sfixed64, int64 , 110);\n  TEST_REPEATED_EXTENSIONS_SPACE_USED(float   , float , 111);\n  TEST_REPEATED_EXTENSIONS_SPACE_USED(double  , double, 112);\n  TEST_REPEATED_EXTENSIONS_SPACE_USED(bool    , bool  , true);\n  TEST_REPEATED_EXTENSIONS_SPACE_USED(nested_enum, int,\n                                      unittest::TestAllTypes::FOO);\n#undef TEST_REPEATED_EXTENSIONS_SPACE_USED\n  // Repeated strings\n  {\n    unittest::TestAllExtensions message;\n    const int base_size = message.SpaceUsed();\n    int min_expected_size = sizeof(RepeatedPtrField<string>) + base_size;\n    const string value(256, 'x');\n    // Once items are allocated, they may stick around even when cleared so\n    // without the hardcore memory management accessors there isn't a notion of\n    // the empty repeated field memory usage as there is with primitive types.\n    for (int i = 0; i < 16; ++i) {\n      message.AddExtension(unittest::repeated_string_extension, value);\n    }\n    min_expected_size += (sizeof(value) + value.size()) *\n        (16 - kMinRepeatedFieldAllocationSize);\n    EXPECT_LE(min_expected_size, message.SpaceUsed());\n  }\n  // Repeated messages\n  {\n    unittest::TestAllExtensions message;\n    const int base_size = message.SpaceUsed();\n    int min_expected_size = sizeof(RepeatedPtrField<unittest::ForeignMessage>) +\n        base_size;\n    unittest::ForeignMessage prototype;\n    prototype.set_c(2);\n    for (int i = 0; i < 16; ++i) {\n      message.AddExtension(unittest::repeated_foreign_message_extension)->\n          CopyFrom(prototype);\n    }\n    min_expected_size +=\n        (16 - kMinRepeatedFieldAllocationSize) * prototype.SpaceUsed();\n    EXPECT_LE(min_expected_size, message.SpaceUsed());\n  }\n}\n\n// N.B.: We do not test range-based for here because we remain C++03 compatible.\ntemplate<typename T, typename M, typename ID>\ninline T SumAllExtensions(const M& message, ID extension, T zero) {\n  T sum = zero;\n  typename RepeatedField<T>::const_iterator iter =\n      message.GetRepeatedExtension(extension).begin();\n  typename RepeatedField<T>::const_iterator end =\n      message.GetRepeatedExtension(extension).end();\n  for (; iter != end; ++iter) {\n    sum += *iter;\n  }\n  return sum;\n}\n\ntemplate<typename T, typename M, typename ID>\ninline void IncAllExtensions(M* message, ID extension,\n                          T val) {\n  typename RepeatedField<T>::iterator iter =\n      message->MutableRepeatedExtension(extension)->begin();\n  typename RepeatedField<T>::iterator end  =\n      message->MutableRepeatedExtension(extension)->end();\n  for (; iter != end; ++iter) {\n    *iter += val;\n  }\n}\n\nTEST(ExtensionSetTest, RepeatedFields) {\n  unittest::TestAllExtensions message;\n\n  // Test empty repeated-field case (b/12926163)\n  ASSERT_EQ(0, message.GetRepeatedExtension(\n      unittest::repeated_int32_extension).size());\n  ASSERT_EQ(0, message.GetRepeatedExtension(\n      unittest::repeated_nested_enum_extension).size());\n  ASSERT_EQ(0, message.GetRepeatedExtension(\n      unittest::repeated_string_extension).size());\n  ASSERT_EQ(0, message.GetRepeatedExtension(\n      unittest::repeated_nested_message_extension).size());\n\n  unittest::TestAllTypes::NestedMessage nested_message;\n  nested_message.set_bb(42);\n  unittest::TestAllTypes::NestedEnum nested_enum =\n      unittest::TestAllTypes::NestedEnum_MIN;\n\n  for (int i = 0; i < 10; ++i) {\n    message.AddExtension(unittest::repeated_int32_extension, 1);\n    message.AddExtension(unittest::repeated_int64_extension, 2);\n    message.AddExtension(unittest::repeated_uint32_extension, 3);\n    message.AddExtension(unittest::repeated_uint64_extension, 4);\n    message.AddExtension(unittest::repeated_sint32_extension, 5);\n    message.AddExtension(unittest::repeated_sint64_extension, 6);\n    message.AddExtension(unittest::repeated_fixed32_extension, 7);\n    message.AddExtension(unittest::repeated_fixed64_extension, 8);\n    message.AddExtension(unittest::repeated_sfixed32_extension, 7);\n    message.AddExtension(unittest::repeated_sfixed64_extension, 8);\n    message.AddExtension(unittest::repeated_float_extension, 9.0);\n    message.AddExtension(unittest::repeated_double_extension, 10.0);\n    message.AddExtension(unittest::repeated_bool_extension, true);\n    message.AddExtension(unittest::repeated_nested_enum_extension, nested_enum);\n    message.AddExtension(unittest::repeated_string_extension,\n                         ::std::string(\"test\"));\n    message.AddExtension(unittest::repeated_bytes_extension,\n                         ::std::string(\"test\\xFF\"));\n    message.AddExtension(\n        unittest::repeated_nested_message_extension)->CopyFrom(nested_message);\n    message.AddExtension(unittest::repeated_nested_enum_extension,\n                         nested_enum);\n  }\n\n  ASSERT_EQ(10, SumAllExtensions<int32>(\n      message, unittest::repeated_int32_extension, 0));\n  IncAllExtensions<int32>(\n      &message, unittest::repeated_int32_extension, 1);\n  ASSERT_EQ(20, SumAllExtensions<int32>(\n      message, unittest::repeated_int32_extension, 0));\n\n  ASSERT_EQ(20, SumAllExtensions<int64>(\n      message, unittest::repeated_int64_extension, 0));\n  IncAllExtensions<int64>(\n      &message, unittest::repeated_int64_extension, 1);\n  ASSERT_EQ(30, SumAllExtensions<int64>(\n      message, unittest::repeated_int64_extension, 0));\n\n  ASSERT_EQ(30, SumAllExtensions<uint32>(\n      message, unittest::repeated_uint32_extension, 0));\n  IncAllExtensions<uint32>(\n      &message, unittest::repeated_uint32_extension, 1);\n  ASSERT_EQ(40, SumAllExtensions<uint32>(\n      message, unittest::repeated_uint32_extension, 0));\n\n  ASSERT_EQ(40, SumAllExtensions<uint64>(\n      message, unittest::repeated_uint64_extension, 0));\n  IncAllExtensions<uint64>(\n      &message, unittest::repeated_uint64_extension, 1);\n  ASSERT_EQ(50, SumAllExtensions<uint64>(\n      message, unittest::repeated_uint64_extension, 0));\n\n  ASSERT_EQ(50, SumAllExtensions<int32>(\n      message, unittest::repeated_sint32_extension, 0));\n  IncAllExtensions<int32>(\n      &message, unittest::repeated_sint32_extension, 1);\n  ASSERT_EQ(60, SumAllExtensions<int32>(\n      message, unittest::repeated_sint32_extension, 0));\n\n  ASSERT_EQ(60, SumAllExtensions<int64>(\n      message, unittest::repeated_sint64_extension, 0));\n  IncAllExtensions<int64>(\n      &message, unittest::repeated_sint64_extension, 1);\n  ASSERT_EQ(70, SumAllExtensions<int64>(\n      message, unittest::repeated_sint64_extension, 0));\n\n  ASSERT_EQ(70, SumAllExtensions<uint32>(\n      message, unittest::repeated_fixed32_extension, 0));\n  IncAllExtensions<uint32>(\n      &message, unittest::repeated_fixed32_extension, 1);\n  ASSERT_EQ(80, SumAllExtensions<uint32>(\n      message, unittest::repeated_fixed32_extension, 0));\n\n  ASSERT_EQ(80, SumAllExtensions<uint64>(\n      message, unittest::repeated_fixed64_extension, 0));\n  IncAllExtensions<uint64>(\n      &message, unittest::repeated_fixed64_extension, 1);\n  ASSERT_EQ(90, SumAllExtensions<uint64>(\n      message, unittest::repeated_fixed64_extension, 0));\n\n  // Usually, floating-point arithmetic cannot be trusted to be exact, so it is\n  // a Bad Idea to assert equality in a test like this. However, we're dealing\n  // with integers with a small number of significant mantissa bits, so we\n  // should actually have exact precision here.\n  ASSERT_EQ(90, SumAllExtensions<float>(\n      message, unittest::repeated_float_extension, 0));\n  IncAllExtensions<float>(\n      &message, unittest::repeated_float_extension, 1);\n  ASSERT_EQ(100, SumAllExtensions<float>(\n      message, unittest::repeated_float_extension, 0));\n\n  ASSERT_EQ(100, SumAllExtensions<double>(\n      message, unittest::repeated_double_extension, 0));\n  IncAllExtensions<double>(\n      &message, unittest::repeated_double_extension, 1);\n  ASSERT_EQ(110, SumAllExtensions<double>(\n      message, unittest::repeated_double_extension, 0));\n\n  RepeatedPtrField< ::std::string>::iterator string_iter;\n  RepeatedPtrField< ::std::string>::iterator string_end;\n  for (string_iter = message.MutableRepeatedExtension(\n          unittest::repeated_string_extension)->begin(),\n       string_end  = message.MutableRepeatedExtension(\n           unittest::repeated_string_extension)->end();\n       string_iter != string_end; ++string_iter) {\n    *string_iter += \"test\";\n  }\n  RepeatedPtrField< ::std::string>::const_iterator string_const_iter;\n  RepeatedPtrField< ::std::string>::const_iterator string_const_end;\n  for (string_const_iter = message.GetRepeatedExtension(\n           unittest::repeated_string_extension).begin(),\n       string_const_end  = message.GetRepeatedExtension(\n           unittest::repeated_string_extension).end();\n       string_iter != string_end; ++string_iter) {\n    ASSERT_TRUE(*string_iter == \"testtest\");\n  }\n\n  RepeatedField<unittest::TestAllTypes_NestedEnum>::iterator enum_iter;\n  RepeatedField<unittest::TestAllTypes_NestedEnum>::iterator enum_end;\n  for (enum_iter = message.MutableRepeatedExtension(\n           unittest::repeated_nested_enum_extension)->begin(),\n       enum_end  = message.MutableRepeatedExtension(\n           unittest::repeated_nested_enum_extension)->end();\n       enum_iter != enum_end; ++enum_iter) {\n    *enum_iter = unittest::TestAllTypes::NestedEnum_MAX;\n  }\n  RepeatedField<unittest::TestAllTypes_NestedEnum>::const_iterator\n      enum_const_iter;\n  RepeatedField<unittest::TestAllTypes_NestedEnum>::const_iterator\n      enum_const_end;\n  for (enum_const_iter = message.GetRepeatedExtension(\n           unittest::repeated_nested_enum_extension).begin(),\n       enum_const_end  = message.GetRepeatedExtension(\n           unittest::repeated_nested_enum_extension).end();\n       enum_iter != enum_end; ++enum_iter) {\n    ASSERT_EQ(*enum_const_iter, unittest::TestAllTypes::NestedEnum_MAX);\n  }\n\n  RepeatedPtrField<unittest::TestAllTypes_NestedMessage>::iterator\n      msg_iter;\n  RepeatedPtrField<unittest::TestAllTypes_NestedMessage>::iterator\n      msg_end;\n  for (msg_iter = message.MutableRepeatedExtension(\n           unittest::repeated_nested_message_extension)->begin(),\n       msg_end  = message.MutableRepeatedExtension(\n           unittest::repeated_nested_message_extension)->end();\n       msg_iter != msg_end; ++msg_iter) {\n    msg_iter->set_bb(1234);\n  }\n  RepeatedPtrField<unittest::TestAllTypes_NestedMessage>::\n      const_iterator msg_const_iter;\n  RepeatedPtrField<unittest::TestAllTypes_NestedMessage>::\n      const_iterator msg_const_end;\n  for (msg_const_iter = message.GetRepeatedExtension(\n           unittest::repeated_nested_message_extension).begin(),\n       msg_const_end  = message.GetRepeatedExtension(\n           unittest::repeated_nested_message_extension).end();\n       msg_const_iter != msg_const_end; ++msg_const_iter) {\n    ASSERT_EQ(msg_const_iter->bb(), 1234);\n  }\n\n  // Test range-based for as well, but only if compiled as C++11.\n#if __cplusplus >= 201103L\n  // Test one primitive field.\n  for (auto& x : *message.MutableRepeatedExtension(\n          unittest::repeated_int32_extension)) {\n    x = 4321;\n  }\n  for (const auto& x : message.GetRepeatedExtension(\n          unittest::repeated_int32_extension)) {\n    ASSERT_EQ(x, 4321);\n  }\n  // Test one string field.\n  for (auto& x : *message.MutableRepeatedExtension(\n          unittest::repeated_string_extension)) {\n    x = \"test_range_based_for\";\n  }\n  for (const auto& x : message.GetRepeatedExtension(\n          unittest::repeated_string_extension)) {\n    ASSERT_TRUE(x == \"test_range_based_for\");\n  }\n  // Test one message field.\n  for (auto& x : *message.MutableRepeatedExtension(\n          unittest::repeated_nested_message_extension)) {\n    x.set_bb(4321);\n  }\n  for (const auto& x : *message.MutableRepeatedExtension(\n          unittest::repeated_nested_message_extension)) {\n    ASSERT_EQ(x.bb(), 4321);\n  }\n#endif\n}\n\n// From b/12926163\nTEST(ExtensionSetTest, AbsentExtension) {\n  unittest::TestAllExtensions message;\n  message.MutableRepeatedExtension(unittest::repeated_nested_message_extension)\n      ->Add()->set_bb(123);\n  ASSERT_EQ(1, message.ExtensionSize(\n      unittest::repeated_nested_message_extension));\n  EXPECT_EQ(\n      123, message.GetExtension(\n          unittest::repeated_nested_message_extension, 0).bb());\n}\n\n#ifdef PROTOBUF_HAS_DEATH_TEST\n\nTEST(ExtensionSetTest, InvalidEnumDeath) {\n  unittest::TestAllExtensions message;\n  EXPECT_DEBUG_DEATH(\n    message.SetExtension(unittest::optional_foreign_enum_extension,\n                         static_cast<unittest::ForeignEnum>(53)),\n    \"IsValid\");\n}\n\n#endif  // PROTOBUF_HAS_DEATH_TEST\n\nTEST(ExtensionSetTest, DynamicExtensions) {\n  // Test adding a dynamic extension to a compiled-in message object.\n\n  FileDescriptorProto dynamic_proto;\n  dynamic_proto.set_name(\"dynamic_extensions_test.proto\");\n  dynamic_proto.add_dependency(\n      unittest::TestAllExtensions::descriptor()->file()->name());\n  dynamic_proto.set_package(\"dynamic_extensions\");\n\n  // Copy the fields and nested types from TestDynamicExtensions into our new\n  // proto, converting the fields into extensions.\n  const Descriptor* template_descriptor =\n      unittest::TestDynamicExtensions::descriptor();\n  DescriptorProto template_descriptor_proto;\n  template_descriptor->CopyTo(&template_descriptor_proto);\n  dynamic_proto.mutable_message_type()->MergeFrom(\n      template_descriptor_proto.nested_type());\n  dynamic_proto.mutable_enum_type()->MergeFrom(\n      template_descriptor_proto.enum_type());\n  dynamic_proto.mutable_extension()->MergeFrom(\n      template_descriptor_proto.field());\n\n  // For each extension that we added...\n  for (int i = 0; i < dynamic_proto.extension_size(); i++) {\n    // Set its extendee to TestAllExtensions.\n    FieldDescriptorProto* extension = dynamic_proto.mutable_extension(i);\n    extension->set_extendee(\n        unittest::TestAllExtensions::descriptor()->full_name());\n\n    // If the field refers to one of the types nested in TestDynamicExtensions,\n    // make it refer to the type in our dynamic proto instead.\n    string prefix = \".\" + template_descriptor->full_name() + \".\";\n    if (extension->has_type_name()) {\n      string* type_name = extension->mutable_type_name();\n      if (HasPrefixString(*type_name, prefix)) {\n        type_name->replace(0, prefix.size(), \".dynamic_extensions.\");\n      }\n    }\n  }\n\n  // Now build the file, using the generated pool as an underlay.\n  DescriptorPool dynamic_pool(DescriptorPool::generated_pool());\n  const FileDescriptor* file = dynamic_pool.BuildFile(dynamic_proto);\n  ASSERT_TRUE(file != NULL);\n  DynamicMessageFactory dynamic_factory(&dynamic_pool);\n  dynamic_factory.SetDelegateToGeneratedFactory(true);\n\n  // Construct a message that we can parse with the extensions we defined.\n  // Since the extensions were based off of the fields of TestDynamicExtensions,\n  // we can use that message to create this test message.\n  string data;\n  {\n    unittest::TestDynamicExtensions message;\n    message.set_scalar_extension(123);\n    message.set_enum_extension(unittest::FOREIGN_BAR);\n    message.set_dynamic_enum_extension(\n        unittest::TestDynamicExtensions::DYNAMIC_BAZ);\n    message.mutable_message_extension()->set_c(456);\n    message.mutable_dynamic_message_extension()->set_dynamic_field(789);\n    message.add_repeated_extension(\"foo\");\n    message.add_repeated_extension(\"bar\");\n    message.add_packed_extension(12);\n    message.add_packed_extension(-34);\n    message.add_packed_extension(56);\n    message.add_packed_extension(-78);\n\n    // Also add some unknown fields.\n\n    // An unknown enum value (for a known field).\n    message.mutable_unknown_fields()->AddVarint(\n      unittest::TestDynamicExtensions::kDynamicEnumExtensionFieldNumber,\n      12345);\n    // A regular unknown field.\n    message.mutable_unknown_fields()->AddLengthDelimited(54321, \"unknown\");\n\n    message.SerializeToString(&data);\n  }\n\n  // Now we can parse this using our dynamic extension definitions...\n  unittest::TestAllExtensions message;\n  {\n    io::ArrayInputStream raw_input(data.data(), data.size());\n    io::CodedInputStream input(&raw_input);\n    input.SetExtensionRegistry(&dynamic_pool, &dynamic_factory);\n    ASSERT_TRUE(message.ParseFromCodedStream(&input));\n    ASSERT_TRUE(input.ConsumedEntireMessage());\n  }\n\n  // Can we print it?\n  EXPECT_EQ(\n    \"[dynamic_extensions.scalar_extension]: 123\\n\"\n    \"[dynamic_extensions.enum_extension]: FOREIGN_BAR\\n\"\n    \"[dynamic_extensions.dynamic_enum_extension]: DYNAMIC_BAZ\\n\"\n    \"[dynamic_extensions.message_extension] {\\n\"\n    \"  c: 456\\n\"\n    \"}\\n\"\n    \"[dynamic_extensions.dynamic_message_extension] {\\n\"\n    \"  dynamic_field: 789\\n\"\n    \"}\\n\"\n    \"[dynamic_extensions.repeated_extension]: \\\"foo\\\"\\n\"\n    \"[dynamic_extensions.repeated_extension]: \\\"bar\\\"\\n\"\n    \"[dynamic_extensions.packed_extension]: 12\\n\"\n    \"[dynamic_extensions.packed_extension]: -34\\n\"\n    \"[dynamic_extensions.packed_extension]: 56\\n\"\n    \"[dynamic_extensions.packed_extension]: -78\\n\"\n    \"2002: 12345\\n\"\n    \"54321: \\\"unknown\\\"\\n\",\n    message.DebugString());\n\n  // Can we serialize it?\n  // (Don't use EXPECT_EQ because we don't want to dump raw binary data to the\n  // terminal on failure.)\n  EXPECT_TRUE(message.SerializeAsString() == data);\n\n  // What if we parse using the reflection-based parser?\n  {\n    unittest::TestAllExtensions message2;\n    io::ArrayInputStream raw_input(data.data(), data.size());\n    io::CodedInputStream input(&raw_input);\n    input.SetExtensionRegistry(&dynamic_pool, &dynamic_factory);\n    ASSERT_TRUE(WireFormat::ParseAndMergePartial(&input, &message2));\n    ASSERT_TRUE(input.ConsumedEntireMessage());\n    EXPECT_EQ(message.DebugString(), message2.DebugString());\n  }\n\n  // Are the embedded generated types actually using the generated objects?\n  {\n    const FieldDescriptor* message_extension =\n        file->FindExtensionByName(\"message_extension\");\n    ASSERT_TRUE(message_extension != NULL);\n    const Message& sub_message =\n        message.GetReflection()->GetMessage(message, message_extension);\n    const unittest::ForeignMessage* typed_sub_message =\n#ifdef GOOGLE_PROTOBUF_NO_RTTI\n        static_cast<const unittest::ForeignMessage*>(&sub_message);\n#else\n        dynamic_cast<const unittest::ForeignMessage*>(&sub_message);\n#endif\n    ASSERT_TRUE(typed_sub_message != NULL);\n    EXPECT_EQ(456, typed_sub_message->c());\n  }\n\n  // What does GetMessage() return for the embedded dynamic type if it isn't\n  // present?\n  {\n    const FieldDescriptor* dynamic_message_extension =\n        file->FindExtensionByName(\"dynamic_message_extension\");\n    ASSERT_TRUE(dynamic_message_extension != NULL);\n    const Message& parent = unittest::TestAllExtensions::default_instance();\n    const Message& sub_message =\n        parent.GetReflection()->GetMessage(parent, dynamic_message_extension,\n                                           &dynamic_factory);\n    const Message* prototype =\n        dynamic_factory.GetPrototype(dynamic_message_extension->message_type());\n    EXPECT_EQ(prototype, &sub_message);\n  }\n}\n\n}  // namespace\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/field_mask.pb.cc",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/field_mask.proto\n\n#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION\n#include <google/protobuf/field_mask.pb.h>\n\n#include <algorithm>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/port.h>\n#include <google/protobuf/stubs/once.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/generated_message_reflection.h>\n#include <google/protobuf/reflection_ops.h>\n#include <google/protobuf/wire_format.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\n\nnamespace {\n\nconst ::google::protobuf::Descriptor* FieldMask_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  FieldMask_reflection_ = NULL;\n\n}  // namespace\n\n\nvoid protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto() {\n  protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto();\n  const ::google::protobuf::FileDescriptor* file =\n    ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(\n      \"google/protobuf/field_mask.proto\");\n  GOOGLE_CHECK(file != NULL);\n  FieldMask_descriptor_ = file->message_type(0);\n  static const int FieldMask_offsets_[1] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, paths_),\n  };\n  FieldMask_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      FieldMask_descriptor_,\n      FieldMask::default_instance_,\n      FieldMask_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(FieldMask),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FieldMask, _is_default_instance_));\n}\n\nnamespace {\n\nGOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);\ninline void protobuf_AssignDescriptorsOnce() {\n  ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,\n                 &protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto);\n}\n\nvoid protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_RegisterTypes(const ::std::string&) {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      FieldMask_descriptor_, &FieldMask::default_instance());\n}\n\n}  // namespace\n\nvoid protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto() {\n  delete FieldMask::default_instance_;\n  delete FieldMask_reflection_;\n}\n\nvoid protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto() {\n  static bool already_here = false;\n  if (already_here) return;\n  already_here = true;\n  GOOGLE_PROTOBUF_VERIFY_VERSION;\n\n  ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(\n    \"\\n google/protobuf/field_mask.proto\\022\\017goog\"\n    \"le.protobuf\\\"\\032\\n\\tFieldMask\\022\\r\\n\\005paths\\030\\001 \\003(\\tB\"\n    \"Q\\n\\023com.google.protobufB\\016FieldMaskProtoP\\001\"\n    \"\\240\\001\\001\\242\\002\\003GPB\\252\\002\\036Google.Protobuf.WellKnownTyp\"\n    \"esb\\006proto3\", 170);\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(\n    \"google/protobuf/field_mask.proto\", &protobuf_RegisterTypes);\n  FieldMask::default_instance_ = new FieldMask();\n  FieldMask::default_instance_->InitAsDefaultInstance();\n  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto);\n}\n\n// Force AddDescriptors() to be called at static initialization time.\nstruct StaticDescriptorInitializer_google_2fprotobuf_2ffield_5fmask_2eproto {\n  StaticDescriptorInitializer_google_2fprotobuf_2ffield_5fmask_2eproto() {\n    protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto();\n  }\n} static_descriptor_initializer_google_2fprotobuf_2ffield_5fmask_2eproto_;\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int FieldMask::kPathsFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nFieldMask::FieldMask()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.FieldMask)\n}\n\nvoid FieldMask::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n}\n\nFieldMask::FieldMask(const FieldMask& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.FieldMask)\n}\n\nvoid FieldMask::SharedCtor() {\n    _is_default_instance_ = false;\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n}\n\nFieldMask::~FieldMask() {\n  // @@protoc_insertion_point(destructor:google.protobuf.FieldMask)\n  SharedDtor();\n}\n\nvoid FieldMask::SharedDtor() {\n  if (this != default_instance_) {\n  }\n}\n\nvoid FieldMask::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* FieldMask::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return FieldMask_descriptor_;\n}\n\nconst FieldMask& FieldMask::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto();\n  return *default_instance_;\n}\n\nFieldMask* FieldMask::default_instance_ = NULL;\n\nFieldMask* FieldMask::New(::google::protobuf::Arena* arena) const {\n  FieldMask* n = new FieldMask;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid FieldMask::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.FieldMask)\n  paths_.Clear();\n}\n\nbool FieldMask::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.FieldMask)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // repeated string paths = 1;\n      case 1: {\n        if (tag == 10) {\n         parse_paths:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->add_paths()));\n          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n            this->paths(this->paths_size() - 1).data(),\n            this->paths(this->paths_size() - 1).length(),\n            ::google::protobuf::internal::WireFormatLite::PARSE,\n            \"google.protobuf.FieldMask.paths\"));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(10)) goto parse_paths;\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.FieldMask)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.FieldMask)\n  return false;\n#undef DO_\n}\n\nvoid FieldMask::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.FieldMask)\n  // repeated string paths = 1;\n  for (int i = 0; i < this->paths_size(); i++) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->paths(i).data(), this->paths(i).length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.FieldMask.paths\");\n    ::google::protobuf::internal::WireFormatLite::WriteString(\n      1, this->paths(i), output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.FieldMask)\n}\n\n::google::protobuf::uint8* FieldMask::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FieldMask)\n  // repeated string paths = 1;\n  for (int i = 0; i < this->paths_size(); i++) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->paths(i).data(), this->paths(i).length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.FieldMask.paths\");\n    target = ::google::protobuf::internal::WireFormatLite::\n      WriteStringToArray(1, this->paths(i), target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FieldMask)\n  return target;\n}\n\nint FieldMask::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FieldMask)\n  int total_size = 0;\n\n  // repeated string paths = 1;\n  total_size += 1 * this->paths_size();\n  for (int i = 0; i < this->paths_size(); i++) {\n    total_size += ::google::protobuf::internal::WireFormatLite::StringSize(\n      this->paths(i));\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid FieldMask::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FieldMask)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const FieldMask* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const FieldMask>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.FieldMask)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FieldMask)\n    MergeFrom(*source);\n  }\n}\n\nvoid FieldMask::MergeFrom(const FieldMask& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FieldMask)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  paths_.MergeFrom(from.paths_);\n}\n\nvoid FieldMask::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.FieldMask)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid FieldMask::CopyFrom(const FieldMask& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FieldMask)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool FieldMask::IsInitialized() const {\n\n  return true;\n}\n\nvoid FieldMask::Swap(FieldMask* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid FieldMask::InternalSwap(FieldMask* other) {\n  paths_.UnsafeArenaSwap(&other->paths_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata FieldMask::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = FieldMask_descriptor_;\n  metadata.reflection = FieldMask_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// FieldMask\n\n// repeated string paths = 1;\nint FieldMask::paths_size() const {\n  return paths_.size();\n}\nvoid FieldMask::clear_paths() {\n  paths_.Clear();\n}\n const ::std::string& FieldMask::paths(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldMask.paths)\n  return paths_.Get(index);\n}\n ::std::string* FieldMask::mutable_paths(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FieldMask.paths)\n  return paths_.Mutable(index);\n}\n void FieldMask::set_paths(int index, const ::std::string& value) {\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths)\n  paths_.Mutable(index)->assign(value);\n}\n void FieldMask::set_paths(int index, const char* value) {\n  paths_.Mutable(index)->assign(value);\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FieldMask.paths)\n}\n void FieldMask::set_paths(int index, const char* value, size_t size) {\n  paths_.Mutable(index)->assign(\n    reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldMask.paths)\n}\n ::std::string* FieldMask::add_paths() {\n  // @@protoc_insertion_point(field_add_mutable:google.protobuf.FieldMask.paths)\n  return paths_.Add();\n}\n void FieldMask::add_paths(const ::std::string& value) {\n  paths_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths)\n}\n void FieldMask::add_paths(const char* value) {\n  paths_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add_char:google.protobuf.FieldMask.paths)\n}\n void FieldMask::add_paths(const char* value, size_t size) {\n  paths_.Add()->assign(reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_add_pointer:google.protobuf.FieldMask.paths)\n}\n const ::google::protobuf::RepeatedPtrField< ::std::string>&\nFieldMask::paths() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.FieldMask.paths)\n  return paths_;\n}\n ::google::protobuf::RepeatedPtrField< ::std::string>*\nFieldMask::mutable_paths() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.FieldMask.paths)\n  return &paths_;\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace protobuf\n}  // namespace google\n\n// @@protoc_insertion_point(global_scope)\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/field_mask.pb.h",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/field_mask.proto\n\n#ifndef PROTOBUF_google_2fprotobuf_2ffield_5fmask_2eproto__INCLUDED\n#define PROTOBUF_google_2fprotobuf_2ffield_5fmask_2eproto__INCLUDED\n\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n\n#if GOOGLE_PROTOBUF_VERSION < 3000000\n#error This file was generated by a newer version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please update\n#error your headers.\n#endif\n#if 3000000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION\n#error This file was generated by an older version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please\n#error regenerate this file with a newer version of protoc.\n#endif\n\n#include <google/protobuf/arena.h>\n#include <google/protobuf/arenastring.h>\n#include <google/protobuf/generated_message_util.h>\n#include <google/protobuf/metadata.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/extension_set.h>\n#include <google/protobuf/unknown_field_set.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\n\n// Internal implementation detail -- do not call these.\nvoid LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto();\nvoid protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto();\nvoid protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto();\n\nclass FieldMask;\n\n// ===================================================================\n\nclass LIBPROTOBUF_EXPORT FieldMask : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FieldMask) */ {\n public:\n  FieldMask();\n  virtual ~FieldMask();\n\n  FieldMask(const FieldMask& from);\n\n  inline FieldMask& operator=(const FieldMask& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const FieldMask& default_instance();\n\n  void Swap(FieldMask* other);\n\n  // implements Message ----------------------------------------------\n\n  inline FieldMask* New() const { return New(NULL); }\n\n  FieldMask* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const FieldMask& from);\n  void MergeFrom(const FieldMask& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(FieldMask* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // repeated string paths = 1;\n  int paths_size() const;\n  void clear_paths();\n  static const int kPathsFieldNumber = 1;\n  const ::std::string& paths(int index) const;\n  ::std::string* mutable_paths(int index);\n  void set_paths(int index, const ::std::string& value);\n  void set_paths(int index, const char* value);\n  void set_paths(int index, const char* value, size_t size);\n  ::std::string* add_paths();\n  void add_paths(const ::std::string& value);\n  void add_paths(const char* value);\n  void add_paths(const char* value, size_t size);\n  const ::google::protobuf::RepeatedPtrField< ::std::string>& paths() const;\n  ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_paths();\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.FieldMask)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  bool _is_default_instance_;\n  ::google::protobuf::RepeatedPtrField< ::std::string> paths_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ffield_5fmask_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2ffield_5fmask_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2ffield_5fmask_2eproto();\n\n  void InitAsDefaultInstance();\n  static FieldMask* default_instance_;\n};\n// ===================================================================\n\n\n// ===================================================================\n\n#if !PROTOBUF_INLINE_NOT_IN_HEADERS\n// FieldMask\n\n// repeated string paths = 1;\ninline int FieldMask::paths_size() const {\n  return paths_.size();\n}\ninline void FieldMask::clear_paths() {\n  paths_.Clear();\n}\ninline const ::std::string& FieldMask::paths(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FieldMask.paths)\n  return paths_.Get(index);\n}\ninline ::std::string* FieldMask::mutable_paths(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.FieldMask.paths)\n  return paths_.Mutable(index);\n}\ninline void FieldMask::set_paths(int index, const ::std::string& value) {\n  // @@protoc_insertion_point(field_set:google.protobuf.FieldMask.paths)\n  paths_.Mutable(index)->assign(value);\n}\ninline void FieldMask::set_paths(int index, const char* value) {\n  paths_.Mutable(index)->assign(value);\n  // @@protoc_insertion_point(field_set_char:google.protobuf.FieldMask.paths)\n}\ninline void FieldMask::set_paths(int index, const char* value, size_t size) {\n  paths_.Mutable(index)->assign(\n    reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.FieldMask.paths)\n}\ninline ::std::string* FieldMask::add_paths() {\n  // @@protoc_insertion_point(field_add_mutable:google.protobuf.FieldMask.paths)\n  return paths_.Add();\n}\ninline void FieldMask::add_paths(const ::std::string& value) {\n  paths_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add:google.protobuf.FieldMask.paths)\n}\ninline void FieldMask::add_paths(const char* value) {\n  paths_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add_char:google.protobuf.FieldMask.paths)\n}\ninline void FieldMask::add_paths(const char* value, size_t size) {\n  paths_.Add()->assign(reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_add_pointer:google.protobuf.FieldMask.paths)\n}\ninline const ::google::protobuf::RepeatedPtrField< ::std::string>&\nFieldMask::paths() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.FieldMask.paths)\n  return paths_;\n}\ninline ::google::protobuf::RepeatedPtrField< ::std::string>*\nFieldMask::mutable_paths() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.FieldMask.paths)\n  return &paths_;\n}\n\n#endif  // !PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace protobuf\n}  // namespace google\n\n// @@protoc_insertion_point(global_scope)\n\n#endif  // PROTOBUF_google_2fprotobuf_2ffield_5fmask_2eproto__INCLUDED\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/field_mask.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto3\";\n\npackage google.protobuf;\n\noption csharp_namespace = \"Google.Protobuf.WellKnownTypes\";\noption java_package = \"com.google.protobuf\";\noption java_outer_classname = \"FieldMaskProto\";\noption java_multiple_files = true;\noption objc_class_prefix = \"GPB\";\noption java_generate_equals_and_hash = true;\n\n// `FieldMask` represents a set of symbolic field paths, for example:\n//\n//     paths: \"f.a\"\n//     paths: \"f.b.d\"\n//\n// Here `f` represents a field in some root message, `a` and `b`\n// fields in the message found in `f`, and `d` a field found in the\n// message in `f.b`.\n//\n// Field masks are used to specify a subset of fields that should be\n// returned by a get operation or modified by an update operation.\n// Field masks also have a custom JSON encoding (see below).\n//\n// # Field Masks in Projections\n//\n// When used in the context of a projection, a response message or\n// sub-message is filtered by the API to only contain those fields as\n// specified in the mask. For example, if the mask in the previous\n// example is applied to a response message as follows:\n//\n//     f {\n//       a : 22\n//       b {\n//         d : 1\n//         x : 2\n//       }\n//       y : 13\n//     }\n//     z: 8\n//\n// The result will not contain specific values for fields x,y and z\n// (their value will be set to the default, and omitted in proto text\n// output):\n//\n//\n//     f {\n//       a : 22\n//       b {\n//         d : 1\n//       }\n//     }\n//\n// A repeated field is not allowed except at the last position of a\n// field mask.\n//\n// If a FieldMask object is not present in a get operation, the\n// operation applies to all fields (as if a FieldMask of all fields\n// had been specified).\n//\n// Note that a field mask does not necessarily apply to the\n// top-level response message. In case of a REST get operation, the\n// field mask applies directly to the response, but in case of a REST\n// list operation, the mask instead applies to each individual message\n// in the returned resource list. In case of a REST custom method,\n// other definitions may be used. Where the mask applies will be\n// clearly documented together with its declaration in the API.  In\n// any case, the effect on the returned resource/resources is required\n// behavior for APIs.\n//\n// # Field Masks in Update Operations\n//\n// A field mask in update operations specifies which fields of the\n// targeted resource are going to be updated. The API is required\n// to only change the values of the fields as specified in the mask\n// and leave the others untouched. If a resource is passed in to\n// describe the updated values, the API ignores the values of all\n// fields not covered by the mask.\n//\n// If a repeated field is specified for an update operation, the existing\n// repeated values in the target resource will be overwritten by the new values.\n// Note that a repeated field is only allowed in the last position of a field\n// mask.\n//\n// If a sub-message is specified in the last position of the field mask for an\n// update operation, then the existing sub-message in the target resource is\n// overwritten. Given the target message:\n//\n//     f {\n//       b {\n//         d : 1\n//         x : 2\n//       }\n//       c : 1\n//     }\n//\n// And an update message:\n//\n//     f {\n//       b {\n//         d : 10\n//       }\n//     }\n//\n// then if the field mask is:\n//\n//  paths: \"f.b\"\n//\n// then the result will be:\n//\n//     f {\n//       b {\n//         d : 10\n//       }\n//       c : 1\n//     }\n//\n// However, if the update mask was:\n//\n//  paths: \"f.b.d\"\n//\n// then the result would be:\n//\n//     f {\n//       b {\n//         d : 10\n//         x : 2\n//       }\n//       c : 1\n//     }\n//\n// In order to reset a field's value to the default, the field must\n// be in the mask and set to the default value in the provided resource.\n// Hence, in order to reset all fields of a resource, provide a default\n// instance of the resource and set all fields in the mask, or do\n// not provide a mask as described below.\n//\n// If a field mask is not present on update, the operation applies to\n// all fields (as if a field mask of all fields has been specified).\n// Note that in the presence of schema evolution, this may mean that\n// fields the client does not know and has therefore not filled into\n// the request will be reset to their default. If this is unwanted\n// behavior, a specific service may require a client to always specify\n// a field mask, producing an error if not.\n//\n// As with get operations, the location of the resource which\n// describes the updated values in the request message depends on the\n// operation kind. In any case, the effect of the field mask is\n// required to be honored by the API.\n//\n// ## Considerations for HTTP REST\n//\n// The HTTP kind of an update operation which uses a field mask must\n// be set to PATCH instead of PUT in order to satisfy HTTP semantics\n// (PUT must only be used for full updates).\n//\n// # JSON Encoding of Field Masks\n//\n// In JSON, a field mask is encoded as a single string where paths are\n// separated by a comma. Fields name in each path are converted\n// to/from lower-camel naming conventions.\n//\n// As an example, consider the following message declarations:\n//\n//     message Profile {\n//       User user = 1;\n//       Photo photo = 2;\n//     }\n//     message User {\n//       string display_name = 1;\n//       string address = 2;\n//     }\n//\n// In proto a field mask for `Profile` may look as such:\n//\n//     mask {\n//       paths: \"user.display_name\"\n//       paths: \"photo\"\n//     }\n//\n// In JSON, the same mask is represented as below:\n//\n//     {\n//       mask: \"user.displayName,photo\"\n//     }\n//\n// # Field Masks and Oneof Fields\n//\n// Field masks treat fields in oneofs just as regular fields. Consider the\n// following message:\n//\n//     message SampleMessage {\n//       oneof test_oneof {\n//         string name = 4;\n//         SubMessage sub_message = 9;\n//       }\n//     }\n//\n// The field mask can be:\n//\n//     mask {\n//       paths: \"name\"\n//     }\n//\n// Or:\n//\n//     mask {\n//       paths: \"sub_message\"\n//     }\n//\n// Note that oneof type names (\"test_oneof\" in this case) cannot be used in\n// paths.\nmessage FieldMask {\n  // The set of field mask paths.\n  repeated string paths = 1;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/generated_enum_reflection.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: jasonh@google.com (Jason Hsueh)\n//\n// This header is logically internal, but is made public because it is used\n// from protocol-compiler-generated code, which may reside in other components.\n// It provides reflection support for generated enums, and is included in\n// generated .pb.h files and should have minimal dependencies. The methods are\n// implemented in generated_message_reflection.cc.\n\n#ifndef GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__\n#define GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__\n\n#include <string>\n\n#include <google/protobuf/stubs/template_util.h>\n#include <google/protobuf/generated_enum_util.h>\n\nnamespace google {\nnamespace protobuf {\n  class EnumDescriptor;\n}  // namespace protobuf\n\nnamespace protobuf {\n\n// Returns the EnumDescriptor for enum type E, which must be a\n// proto-declared enum type.  Code generated by the protocol compiler\n// will include specializations of this template for each enum type declared.\ntemplate <typename E>\nconst EnumDescriptor* GetEnumDescriptor();\n\nnamespace internal {\n\n// Helper for EnumType_Parse functions: try to parse the string 'name' as an\n// enum name of the given type, returning true and filling in value on success,\n// or returning false and leaving value unchanged on failure.\nLIBPROTOBUF_EXPORT bool ParseNamedEnum(const EnumDescriptor* descriptor,\n                    const string& name,\n                    int* value);\n\ntemplate<typename EnumType>\nbool ParseNamedEnum(const EnumDescriptor* descriptor,\n                    const string& name,\n                    EnumType* value) {\n  int tmp;\n  if (!ParseNamedEnum(descriptor, name, &tmp)) return false;\n  *value = static_cast<EnumType>(tmp);\n  return true;\n}\n\n// Just a wrapper around printing the name of a value. The main point of this\n// function is not to be inlined, so that you can do this without including\n// descriptor.h.\nLIBPROTOBUF_EXPORT const string& NameOfEnum(const EnumDescriptor* descriptor, int value);\n\n}  // namespace internal\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_GENERATED_ENUM_REFLECTION_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/generated_enum_util.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_GENERATED_ENUM_UTIL_H__\n#define GOOGLE_PROTOBUF_GENERATED_ENUM_UTIL_H__\n\n#include <google/protobuf/stubs/template_util.h>\n\nnamespace google {\nnamespace protobuf {\n\n// This type trait can be used to cause templates to only match proto2 enum\n// types.\ntemplate <typename T> struct is_proto_enum : ::google::protobuf::internal::false_type {};\n\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_GENERATED_ENUM_UTIL_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/generated_message_reflection.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <algorithm>\n#include <set>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/extension_set.h>\n#include <google/protobuf/generated_message_reflection.h>\n#include <google/protobuf/generated_message_util.h>\n#include <google/protobuf/map_field.h>\n#include <google/protobuf/repeated_field.h>\n\n\n#define GOOGLE_PROTOBUF_HAS_ONEOF\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\nnamespace {\nbool IsMapFieldInApi(const FieldDescriptor* field) {\n  return field->is_map();\n}\n}  // anonymous namespace\n\nbool ParseNamedEnum(const EnumDescriptor* descriptor,\n                    const string& name,\n                    int* value) {\n  const EnumValueDescriptor* d = descriptor->FindValueByName(name);\n  if (d == NULL) return false;\n  *value = d->number();\n  return true;\n}\n\nconst string& NameOfEnum(const EnumDescriptor* descriptor, int value) {\n  const EnumValueDescriptor* d = descriptor->FindValueByNumber(value);\n  return (d == NULL ? GetEmptyString() : d->name());\n}\n\nnamespace {\ninline bool SupportsArenas(const Descriptor* descriptor) {\n  return descriptor->file()->options().cc_enable_arenas();\n}\n}  // anonymous namespace\n\n// ===================================================================\n// Helpers for reporting usage errors (e.g. trying to use GetInt32() on\n// a string field).\n\nnamespace {\n\nvoid ReportReflectionUsageError(\n    const Descriptor* descriptor, const FieldDescriptor* field,\n    const char* method, const char* description) {\n  GOOGLE_LOG(FATAL)\n    << \"Protocol Buffer reflection usage error:\\n\"\n       \"  Method      : google::protobuf::Reflection::\" << method << \"\\n\"\n       \"  Message type: \" << descriptor->full_name() << \"\\n\"\n       \"  Field       : \" << field->full_name() << \"\\n\"\n       \"  Problem     : \" << description;\n}\n\nconst char* cpptype_names_[FieldDescriptor::MAX_CPPTYPE + 1] = {\n  \"INVALID_CPPTYPE\",\n  \"CPPTYPE_INT32\",\n  \"CPPTYPE_INT64\",\n  \"CPPTYPE_UINT32\",\n  \"CPPTYPE_UINT64\",\n  \"CPPTYPE_DOUBLE\",\n  \"CPPTYPE_FLOAT\",\n  \"CPPTYPE_BOOL\",\n  \"CPPTYPE_ENUM\",\n  \"CPPTYPE_STRING\",\n  \"CPPTYPE_MESSAGE\"\n};\n\nstatic void ReportReflectionUsageTypeError(\n    const Descriptor* descriptor, const FieldDescriptor* field,\n    const char* method,\n    FieldDescriptor::CppType expected_type) {\n  GOOGLE_LOG(FATAL)\n    << \"Protocol Buffer reflection usage error:\\n\"\n       \"  Method      : google::protobuf::Reflection::\" << method << \"\\n\"\n       \"  Message type: \" << descriptor->full_name() << \"\\n\"\n       \"  Field       : \" << field->full_name() << \"\\n\"\n       \"  Problem     : Field is not the right type for this message:\\n\"\n       \"    Expected  : \" << cpptype_names_[expected_type] << \"\\n\"\n       \"    Field type: \" << cpptype_names_[field->cpp_type()];\n}\n\nstatic void ReportReflectionUsageEnumTypeError(\n    const Descriptor* descriptor, const FieldDescriptor* field,\n    const char* method, const EnumValueDescriptor* value) {\n  GOOGLE_LOG(FATAL)\n    << \"Protocol Buffer reflection usage error:\\n\"\n       \"  Method      : google::protobuf::Reflection::\" << method << \"\\n\"\n       \"  Message type: \" << descriptor->full_name() << \"\\n\"\n       \"  Field       : \" << field->full_name() << \"\\n\"\n       \"  Problem     : Enum value did not match field type:\\n\"\n       \"    Expected  : \" << field->enum_type()->full_name() << \"\\n\"\n       \"    Actual    : \" << value->full_name();\n}\n\n#define USAGE_CHECK(CONDITION, METHOD, ERROR_DESCRIPTION)                      \\\n  if (!(CONDITION))                                                            \\\n    ReportReflectionUsageError(descriptor_, field, #METHOD, ERROR_DESCRIPTION)\n#define USAGE_CHECK_EQ(A, B, METHOD, ERROR_DESCRIPTION)                        \\\n  USAGE_CHECK((A) == (B), METHOD, ERROR_DESCRIPTION)\n#define USAGE_CHECK_NE(A, B, METHOD, ERROR_DESCRIPTION)                        \\\n  USAGE_CHECK((A) != (B), METHOD, ERROR_DESCRIPTION)\n\n#define USAGE_CHECK_TYPE(METHOD, CPPTYPE)                                      \\\n  if (field->cpp_type() != FieldDescriptor::CPPTYPE_##CPPTYPE)                 \\\n    ReportReflectionUsageTypeError(descriptor_, field, #METHOD,                \\\n                                   FieldDescriptor::CPPTYPE_##CPPTYPE)\n\n#define USAGE_CHECK_ENUM_VALUE(METHOD)                                         \\\n  if (value->type() != field->enum_type())                                     \\\n    ReportReflectionUsageEnumTypeError(descriptor_, field, #METHOD, value)\n\n#define USAGE_CHECK_MESSAGE_TYPE(METHOD)                                       \\\n  USAGE_CHECK_EQ(field->containing_type(), descriptor_,                        \\\n                 METHOD, \"Field does not match message type.\");\n#define USAGE_CHECK_SINGULAR(METHOD)                                           \\\n  USAGE_CHECK_NE(field->label(), FieldDescriptor::LABEL_REPEATED, METHOD,      \\\n                 \"Field is repeated; the method requires a singular field.\")\n#define USAGE_CHECK_REPEATED(METHOD)                                           \\\n  USAGE_CHECK_EQ(field->label(), FieldDescriptor::LABEL_REPEATED, METHOD,      \\\n                 \"Field is singular; the method requires a repeated field.\")\n\n#define USAGE_CHECK_ALL(METHOD, LABEL, CPPTYPE)                       \\\n    USAGE_CHECK_MESSAGE_TYPE(METHOD);                                 \\\n    USAGE_CHECK_##LABEL(METHOD);                                      \\\n    USAGE_CHECK_TYPE(METHOD, CPPTYPE)\n\n}  // namespace\n\n// ===================================================================\n\nGeneratedMessageReflection::GeneratedMessageReflection(\n    const Descriptor* descriptor,\n    const Message* default_instance,\n    const int offsets[],\n    int has_bits_offset,\n    int unknown_fields_offset,\n    int extensions_offset,\n    const DescriptorPool* descriptor_pool,\n    MessageFactory* factory,\n    int object_size,\n    int arena_offset,\n    int is_default_instance_offset)\n  : descriptor_       (descriptor),\n    default_instance_ (default_instance),\n    offsets_          (offsets),\n    has_bits_offset_  (has_bits_offset),\n    unknown_fields_offset_(unknown_fields_offset),\n    extensions_offset_(extensions_offset),\n    arena_offset_     (arena_offset),\n    is_default_instance_offset_(is_default_instance_offset),\n    object_size_      (object_size),\n    descriptor_pool_  ((descriptor_pool == NULL) ?\n                         DescriptorPool::generated_pool() :\n                         descriptor_pool),\n    message_factory_  (factory) {\n}\n\nGeneratedMessageReflection::GeneratedMessageReflection(\n    const Descriptor* descriptor,\n    const Message* default_instance,\n    const int offsets[],\n    int has_bits_offset,\n    int unknown_fields_offset,\n    int extensions_offset,\n    const void* default_oneof_instance,\n    int oneof_case_offset,\n    const DescriptorPool* descriptor_pool,\n    MessageFactory* factory,\n    int object_size,\n    int arena_offset,\n    int is_default_instance_offset)\n  : descriptor_       (descriptor),\n    default_instance_ (default_instance),\n    default_oneof_instance_ (default_oneof_instance),\n    offsets_          (offsets),\n    has_bits_offset_  (has_bits_offset),\n    oneof_case_offset_(oneof_case_offset),\n    unknown_fields_offset_(unknown_fields_offset),\n    extensions_offset_(extensions_offset),\n    arena_offset_     (arena_offset),\n    is_default_instance_offset_(is_default_instance_offset),\n    object_size_      (object_size),\n    descriptor_pool_  ((descriptor_pool == NULL) ?\n                         DescriptorPool::generated_pool() :\n                         descriptor_pool),\n    message_factory_  (factory) {\n}\n\nGeneratedMessageReflection::~GeneratedMessageReflection() {}\n\nnamespace {\nUnknownFieldSet* empty_unknown_field_set_ = NULL;\nGOOGLE_PROTOBUF_DECLARE_ONCE(empty_unknown_field_set_once_);\n\nvoid DeleteEmptyUnknownFieldSet() {\n  delete empty_unknown_field_set_;\n  empty_unknown_field_set_ = NULL;\n}\n\nvoid InitEmptyUnknownFieldSet() {\n  empty_unknown_field_set_ = new UnknownFieldSet;\n  internal::OnShutdown(&DeleteEmptyUnknownFieldSet);\n}\n\nconst UnknownFieldSet& GetEmptyUnknownFieldSet() {\n  ::google::protobuf::GoogleOnceInit(&empty_unknown_field_set_once_, &InitEmptyUnknownFieldSet);\n  return *empty_unknown_field_set_;\n}\n}  // namespace\n\nconst UnknownFieldSet& GeneratedMessageReflection::GetUnknownFields(\n    const Message& message) const {\n  if (descriptor_->file()->syntax() == FileDescriptor::SYNTAX_PROTO3) {\n    return GetEmptyUnknownFieldSet();\n  }\n  if (unknown_fields_offset_ == kUnknownFieldSetInMetadata) {\n    return GetInternalMetadataWithArena(message).unknown_fields();\n  }\n  const void* ptr = reinterpret_cast<const uint8*>(&message) +\n                    unknown_fields_offset_;\n  return *reinterpret_cast<const UnknownFieldSet*>(ptr);\n}\n\nUnknownFieldSet* GeneratedMessageReflection::MutableUnknownFields(\n    Message* message) const {\n  if (unknown_fields_offset_ == kUnknownFieldSetInMetadata) {\n    return MutableInternalMetadataWithArena(message)->\n        mutable_unknown_fields();\n  }\n  void* ptr = reinterpret_cast<uint8*>(message) + unknown_fields_offset_;\n  return reinterpret_cast<UnknownFieldSet*>(ptr);\n}\n\nint GeneratedMessageReflection::SpaceUsed(const Message& message) const {\n  // object_size_ already includes the in-memory representation of each field\n  // in the message, so we only need to account for additional memory used by\n  // the fields.\n  int total_size = object_size_;\n\n  total_size += GetUnknownFields(message).SpaceUsedExcludingSelf();\n\n  if (extensions_offset_ != -1) {\n    total_size += GetExtensionSet(message).SpaceUsedExcludingSelf();\n  }\n\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n\n    if (field->is_repeated()) {\n      switch (field->cpp_type()) {\n#define HANDLE_TYPE(UPPERCASE, LOWERCASE)                                     \\\n        case FieldDescriptor::CPPTYPE_##UPPERCASE :                           \\\n          total_size += GetRaw<RepeatedField<LOWERCASE> >(message, field)     \\\n                          .SpaceUsedExcludingSelf();                          \\\n          break\n\n        HANDLE_TYPE( INT32,  int32);\n        HANDLE_TYPE( INT64,  int64);\n        HANDLE_TYPE(UINT32, uint32);\n        HANDLE_TYPE(UINT64, uint64);\n        HANDLE_TYPE(DOUBLE, double);\n        HANDLE_TYPE( FLOAT,  float);\n        HANDLE_TYPE(  BOOL,   bool);\n        HANDLE_TYPE(  ENUM,    int);\n#undef HANDLE_TYPE\n\n        case FieldDescriptor::CPPTYPE_STRING:\n          switch (field->options().ctype()) {\n            default:  // TODO(kenton):  Support other string reps.\n            case FieldOptions::STRING:\n              total_size += GetRaw<RepeatedPtrField<string> >(message, field)\n                              .SpaceUsedExcludingSelf();\n              break;\n          }\n          break;\n\n        case FieldDescriptor::CPPTYPE_MESSAGE:\n          if (IsMapFieldInApi(field)) {\n            total_size +=\n                GetRaw<MapFieldBase>(message, field).SpaceUsedExcludingSelf();\n          } else {\n            // We don't know which subclass of RepeatedPtrFieldBase the type is,\n            // so we use RepeatedPtrFieldBase directly.\n            total_size +=\n                GetRaw<RepeatedPtrFieldBase>(message, field)\n                  .SpaceUsedExcludingSelf<GenericTypeHandler<Message> >();\n          }\n\n          break;\n      }\n    } else {\n      if (field->containing_oneof() && !HasOneofField(message, field)) {\n        continue;\n      }\n      switch (field->cpp_type()) {\n        case FieldDescriptor::CPPTYPE_INT32 :\n        case FieldDescriptor::CPPTYPE_INT64 :\n        case FieldDescriptor::CPPTYPE_UINT32:\n        case FieldDescriptor::CPPTYPE_UINT64:\n        case FieldDescriptor::CPPTYPE_DOUBLE:\n        case FieldDescriptor::CPPTYPE_FLOAT :\n        case FieldDescriptor::CPPTYPE_BOOL  :\n        case FieldDescriptor::CPPTYPE_ENUM  :\n          // Field is inline, so we've already counted it.\n          break;\n\n        case FieldDescriptor::CPPTYPE_STRING: {\n          switch (field->options().ctype()) {\n            default:  // TODO(kenton):  Support other string reps.\n            case FieldOptions::STRING: {\n              // Initially, the string points to the default value stored in\n              // the prototype. Only count the string if it has been changed\n              // from the default value.\n              const string* default_ptr =\n                  &DefaultRaw<ArenaStringPtr>(field).Get(NULL);\n              const string* ptr =\n                  &GetField<ArenaStringPtr>(message, field).Get(default_ptr);\n\n              if (ptr != default_ptr) {\n                // string fields are represented by just a pointer, so also\n                // include sizeof(string) as well.\n                total_size += sizeof(*ptr) + StringSpaceUsedExcludingSelf(*ptr);\n              }\n              break;\n            }\n          }\n          break;\n        }\n\n        case FieldDescriptor::CPPTYPE_MESSAGE:\n          if (&message == default_instance_) {\n            // For singular fields, the prototype just stores a pointer to the\n            // external type's prototype, so there is no extra memory usage.\n          } else {\n            const Message* sub_message = GetRaw<const Message*>(message, field);\n            if (sub_message != NULL) {\n              total_size += sub_message->SpaceUsed();\n            }\n          }\n          break;\n      }\n    }\n  }\n\n  return total_size;\n}\n\nvoid GeneratedMessageReflection::SwapField(\n    Message* message1,\n    Message* message2,\n    const FieldDescriptor* field) const {\n  if (field->is_repeated()) {\n    switch (field->cpp_type()) {\n#define SWAP_ARRAYS(CPPTYPE, TYPE)                                      \\\n      case FieldDescriptor::CPPTYPE_##CPPTYPE:                          \\\n        MutableRaw<RepeatedField<TYPE> >(message1, field)->Swap(        \\\n            MutableRaw<RepeatedField<TYPE> >(message2, field));         \\\n        break;\n\n      SWAP_ARRAYS(INT32 , int32 );\n      SWAP_ARRAYS(INT64 , int64 );\n      SWAP_ARRAYS(UINT32, uint32);\n      SWAP_ARRAYS(UINT64, uint64);\n      SWAP_ARRAYS(FLOAT , float );\n      SWAP_ARRAYS(DOUBLE, double);\n      SWAP_ARRAYS(BOOL  , bool  );\n      SWAP_ARRAYS(ENUM  , int   );\n#undef SWAP_ARRAYS\n\n      case FieldDescriptor::CPPTYPE_STRING:\n        switch (field->options().ctype()) {\n          default:  // TODO(kenton):  Support other string reps.\n          case FieldOptions::STRING:\n            MutableRaw<RepeatedPtrFieldBase>(message1, field)->\n                Swap<GenericTypeHandler<string> >(\n                    MutableRaw<RepeatedPtrFieldBase>(message2, field));\n            break;\n        }\n        break;\n      case FieldDescriptor::CPPTYPE_MESSAGE:\n        if (IsMapFieldInApi(field)) {\n          MutableRaw<MapFieldBase>(message1, field)->\n            MutableRepeatedField()->\n              Swap<GenericTypeHandler<google::protobuf::Message> >(\n                MutableRaw<MapFieldBase>(message2, field)->\n                  MutableRepeatedField());\n        } else {\n          MutableRaw<RepeatedPtrFieldBase>(message1, field)->\n            Swap<GenericTypeHandler<google::protobuf::Message> >(\n              MutableRaw<RepeatedPtrFieldBase>(message2, field));\n        }\n        break;\n\n      default:\n        GOOGLE_LOG(FATAL) << \"Unimplemented type: \" << field->cpp_type();\n    }\n  } else {\n    switch (field->cpp_type()) {\n#define SWAP_VALUES(CPPTYPE, TYPE)                                      \\\n      case FieldDescriptor::CPPTYPE_##CPPTYPE:                          \\\n        std::swap(*MutableRaw<TYPE>(message1, field),                   \\\n                  *MutableRaw<TYPE>(message2, field));                  \\\n        break;\n\n      SWAP_VALUES(INT32 , int32 );\n      SWAP_VALUES(INT64 , int64 );\n      SWAP_VALUES(UINT32, uint32);\n      SWAP_VALUES(UINT64, uint64);\n      SWAP_VALUES(FLOAT , float );\n      SWAP_VALUES(DOUBLE, double);\n      SWAP_VALUES(BOOL  , bool  );\n      SWAP_VALUES(ENUM  , int   );\n#undef SWAP_VALUES\n      case FieldDescriptor::CPPTYPE_MESSAGE:\n        if (GetArena(message1) == GetArena(message2)) {\n          std::swap(*MutableRaw<Message*>(message1, field),\n                    *MutableRaw<Message*>(message2, field));\n        } else {\n          Message** sub_msg1 = MutableRaw<Message*>(message1, field);\n          Message** sub_msg2 = MutableRaw<Message*>(message2, field);\n          if (*sub_msg1 == NULL && *sub_msg2 == NULL) break;\n          if (*sub_msg1 && *sub_msg2) {\n            (*sub_msg1)->GetReflection()->Swap(*sub_msg1, *sub_msg2);\n            break;\n          }\n          if (*sub_msg1 == NULL) {\n            *sub_msg1 = (*sub_msg2)->New(message1->GetArena());\n            (*sub_msg1)->CopyFrom(**sub_msg2);\n            ClearField(message2, field);\n          } else {\n            *sub_msg2 = (*sub_msg1)->New(message2->GetArena());\n            (*sub_msg2)->CopyFrom(**sub_msg1);\n            ClearField(message1, field);\n          }\n        }\n        break;\n\n      case FieldDescriptor::CPPTYPE_STRING:\n        switch (field->options().ctype()) {\n          default:  // TODO(kenton):  Support other string reps.\n          case FieldOptions::STRING:\n            {\n              Arena* arena1 = GetArena(message1);\n              Arena* arena2 = GetArena(message2);\n              ArenaStringPtr* string1 =\n                  MutableRaw<ArenaStringPtr>(message1, field);\n              ArenaStringPtr* string2 =\n                  MutableRaw<ArenaStringPtr>(message2, field);\n              if (arena1 == arena2) {\n                string1->Swap(string2);\n              } else {\n                const string* default_ptr =\n                    &DefaultRaw<ArenaStringPtr>(field).Get(NULL);\n                const string temp = string1->Get(default_ptr);\n                string1->Set(default_ptr, string2->Get(default_ptr), arena1);\n                string2->Set(default_ptr, temp, arena2);\n              }\n            }\n            break;\n        }\n        break;\n\n      default:\n        GOOGLE_LOG(FATAL) << \"Unimplemented type: \" << field->cpp_type();\n    }\n  }\n}\n\nvoid GeneratedMessageReflection::SwapOneofField(\n    Message* message1,\n    Message* message2,\n    const OneofDescriptor* oneof_descriptor) const {\n  uint32 oneof_case1 = GetOneofCase(*message1, oneof_descriptor);\n  uint32 oneof_case2 = GetOneofCase(*message2, oneof_descriptor);\n\n  int32 temp_int32;\n  int64 temp_int64;\n  uint32 temp_uint32;\n  uint64 temp_uint64;\n  float temp_float;\n  double temp_double;\n  bool temp_bool;\n  int temp_int;\n  Message* temp_message = NULL;\n  string temp_string;\n\n  // Stores message1's oneof field to a temp variable.\n  const FieldDescriptor* field1 = NULL;\n  if (oneof_case1 > 0) {\n    field1 = descriptor_->FindFieldByNumber(oneof_case1);\n    //oneof_descriptor->field(oneof_case1);\n    switch (field1->cpp_type()) {\n#define GET_TEMP_VALUE(CPPTYPE, TYPE)                                   \\\n      case FieldDescriptor::CPPTYPE_##CPPTYPE:                          \\\n        temp_##TYPE = GetField<TYPE>(*message1, field1);                \\\n        break;\n\n      GET_TEMP_VALUE(INT32 , int32 );\n      GET_TEMP_VALUE(INT64 , int64 );\n      GET_TEMP_VALUE(UINT32, uint32);\n      GET_TEMP_VALUE(UINT64, uint64);\n      GET_TEMP_VALUE(FLOAT , float );\n      GET_TEMP_VALUE(DOUBLE, double);\n      GET_TEMP_VALUE(BOOL  , bool  );\n      GET_TEMP_VALUE(ENUM  , int   );\n#undef GET_TEMP_VALUE\n      case FieldDescriptor::CPPTYPE_MESSAGE:\n        temp_message = ReleaseMessage(message1, field1);\n        break;\n\n      case FieldDescriptor::CPPTYPE_STRING:\n        temp_string = GetString(*message1, field1);\n        break;\n\n      default:\n        GOOGLE_LOG(FATAL) << \"Unimplemented type: \" << field1->cpp_type();\n    }\n  }\n\n  // Sets message1's oneof field from the message2's oneof field.\n  if (oneof_case2 > 0) {\n    const FieldDescriptor* field2 =\n        descriptor_->FindFieldByNumber(oneof_case2);\n    switch (field2->cpp_type()) {\n#define SET_ONEOF_VALUE1(CPPTYPE, TYPE)                                 \\\n      case FieldDescriptor::CPPTYPE_##CPPTYPE:                          \\\n        SetField<TYPE>(message1, field2, GetField<TYPE>(*message2, field2)); \\\n        break;\n\n      SET_ONEOF_VALUE1(INT32 , int32 );\n      SET_ONEOF_VALUE1(INT64 , int64 );\n      SET_ONEOF_VALUE1(UINT32, uint32);\n      SET_ONEOF_VALUE1(UINT64, uint64);\n      SET_ONEOF_VALUE1(FLOAT , float );\n      SET_ONEOF_VALUE1(DOUBLE, double);\n      SET_ONEOF_VALUE1(BOOL  , bool  );\n      SET_ONEOF_VALUE1(ENUM  , int   );\n#undef SET_ONEOF_VALUE1\n      case FieldDescriptor::CPPTYPE_MESSAGE:\n        SetAllocatedMessage(message1,\n                            ReleaseMessage(message2, field2),\n                            field2);\n        break;\n\n      case FieldDescriptor::CPPTYPE_STRING:\n        SetString(message1, field2, GetString(*message2, field2));\n        break;\n\n      default:\n        GOOGLE_LOG(FATAL) << \"Unimplemented type: \" << field2->cpp_type();\n    }\n  } else {\n    ClearOneof(message1, oneof_descriptor);\n  }\n\n  // Sets message2's oneof field from the temp variable.\n  if (oneof_case1 > 0) {\n    switch (field1->cpp_type()) {\n#define SET_ONEOF_VALUE2(CPPTYPE, TYPE)                                 \\\n      case FieldDescriptor::CPPTYPE_##CPPTYPE:                          \\\n        SetField<TYPE>(message2, field1, temp_##TYPE);                  \\\n        break;\n\n      SET_ONEOF_VALUE2(INT32 , int32 );\n      SET_ONEOF_VALUE2(INT64 , int64 );\n      SET_ONEOF_VALUE2(UINT32, uint32);\n      SET_ONEOF_VALUE2(UINT64, uint64);\n      SET_ONEOF_VALUE2(FLOAT , float );\n      SET_ONEOF_VALUE2(DOUBLE, double);\n      SET_ONEOF_VALUE2(BOOL  , bool  );\n      SET_ONEOF_VALUE2(ENUM  , int   );\n#undef SET_ONEOF_VALUE2\n      case FieldDescriptor::CPPTYPE_MESSAGE:\n        SetAllocatedMessage(message2, temp_message, field1);\n        break;\n\n      case FieldDescriptor::CPPTYPE_STRING:\n        SetString(message2, field1, temp_string);\n        break;\n\n      default:\n        GOOGLE_LOG(FATAL) << \"Unimplemented type: \" << field1->cpp_type();\n    }\n  } else {\n    ClearOneof(message2, oneof_descriptor);\n  }\n}\n\nvoid GeneratedMessageReflection::Swap(\n    Message* message1,\n    Message* message2) const {\n  if (message1 == message2) return;\n\n  // TODO(kenton):  Other Reflection methods should probably check this too.\n  GOOGLE_CHECK_EQ(message1->GetReflection(), this)\n    << \"First argument to Swap() (of type \\\"\"\n    << message1->GetDescriptor()->full_name()\n    << \"\\\") is not compatible with this reflection object (which is for type \\\"\"\n    << descriptor_->full_name()\n    << \"\\\").  Note that the exact same class is required; not just the same \"\n       \"descriptor.\";\n  GOOGLE_CHECK_EQ(message2->GetReflection(), this)\n    << \"Second argument to Swap() (of type \\\"\"\n    << message2->GetDescriptor()->full_name()\n    << \"\\\") is not compatible with this reflection object (which is for type \\\"\"\n    << descriptor_->full_name()\n    << \"\\\").  Note that the exact same class is required; not just the same \"\n       \"descriptor.\";\n\n  // Check that both messages are in the same arena (or both on the heap). We\n  // need to copy all data if not, due to ownership semantics.\n  if (GetArena(message1) != GetArena(message2)) {\n    // Slow copy path.\n    // Use our arena as temp space, if available.\n    Message* temp = message1->New(GetArena(message1));\n    temp->MergeFrom(*message1);\n    message1->CopyFrom(*message2);\n    message2->CopyFrom(*temp);\n    if (GetArena(message1) == NULL) {\n      delete temp;\n    }\n    return;\n  }\n\n  if (has_bits_offset_ != -1) {\n    uint32* has_bits1 = MutableHasBits(message1);\n    uint32* has_bits2 = MutableHasBits(message2);\n    int has_bits_size = (descriptor_->field_count() + 31) / 32;\n\n    for (int i = 0; i < has_bits_size; i++) {\n      std::swap(has_bits1[i], has_bits2[i]);\n    }\n  }\n\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n    if (!field->containing_oneof()) {\n      SwapField(message1, message2, field);\n    }\n  }\n\n  for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {\n    SwapOneofField(message1, message2, descriptor_->oneof_decl(i));\n  }\n\n  if (extensions_offset_ != -1) {\n    MutableExtensionSet(message1)->Swap(MutableExtensionSet(message2));\n  }\n\n  MutableUnknownFields(message1)->Swap(MutableUnknownFields(message2));\n}\n\nvoid GeneratedMessageReflection::SwapFields(\n    Message* message1,\n    Message* message2,\n    const vector<const FieldDescriptor*>& fields) const {\n  if (message1 == message2) return;\n\n  // TODO(kenton):  Other Reflection methods should probably check this too.\n  GOOGLE_CHECK_EQ(message1->GetReflection(), this)\n    << \"First argument to SwapFields() (of type \\\"\"\n    << message1->GetDescriptor()->full_name()\n    << \"\\\") is not compatible with this reflection object (which is for type \\\"\"\n    << descriptor_->full_name()\n    << \"\\\").  Note that the exact same class is required; not just the same \"\n       \"descriptor.\";\n  GOOGLE_CHECK_EQ(message2->GetReflection(), this)\n    << \"Second argument to SwapFields() (of type \\\"\"\n    << message2->GetDescriptor()->full_name()\n    << \"\\\") is not compatible with this reflection object (which is for type \\\"\"\n    << descriptor_->full_name()\n    << \"\\\").  Note that the exact same class is required; not just the same \"\n       \"descriptor.\";\n\n  std::set<int> swapped_oneof;\n\n  for (int i = 0; i < fields.size(); i++) {\n    const FieldDescriptor* field = fields[i];\n    if (field->is_extension()) {\n      MutableExtensionSet(message1)->SwapExtension(\n          MutableExtensionSet(message2),\n          field->number());\n    } else {\n      if (field->containing_oneof()) {\n        int oneof_index = field->containing_oneof()->index();\n        // Only swap the oneof field once.\n        if (swapped_oneof.find(oneof_index) != swapped_oneof.end()) {\n          continue;\n        }\n        swapped_oneof.insert(oneof_index);\n        SwapOneofField(message1, message2, field->containing_oneof());\n      } else {\n        // Swap has bit.\n        SwapBit(message1, message2, field);\n        // Swap field.\n        SwapField(message1, message2, field);\n      }\n    }\n  }\n}\n\n// -------------------------------------------------------------------\n\nbool GeneratedMessageReflection::HasField(const Message& message,\n                                          const FieldDescriptor* field) const {\n  USAGE_CHECK_MESSAGE_TYPE(HasField);\n  USAGE_CHECK_SINGULAR(HasField);\n\n  if (field->is_extension()) {\n    return GetExtensionSet(message).Has(field->number());\n  } else {\n    if (field->containing_oneof()) {\n      return HasOneofField(message, field);\n    } else {\n      return HasBit(message, field);\n    }\n  }\n}\n\nint GeneratedMessageReflection::FieldSize(const Message& message,\n                                          const FieldDescriptor* field) const {\n  USAGE_CHECK_MESSAGE_TYPE(FieldSize);\n  USAGE_CHECK_REPEATED(FieldSize);\n\n  if (field->is_extension()) {\n    return GetExtensionSet(message).ExtensionSize(field->number());\n  } else {\n    switch (field->cpp_type()) {\n#define HANDLE_TYPE(UPPERCASE, LOWERCASE)                                     \\\n      case FieldDescriptor::CPPTYPE_##UPPERCASE :                             \\\n        return GetRaw<RepeatedField<LOWERCASE> >(message, field).size()\n\n      HANDLE_TYPE( INT32,  int32);\n      HANDLE_TYPE( INT64,  int64);\n      HANDLE_TYPE(UINT32, uint32);\n      HANDLE_TYPE(UINT64, uint64);\n      HANDLE_TYPE(DOUBLE, double);\n      HANDLE_TYPE( FLOAT,  float);\n      HANDLE_TYPE(  BOOL,   bool);\n      HANDLE_TYPE(  ENUM,    int);\n#undef HANDLE_TYPE\n\n      case FieldDescriptor::CPPTYPE_STRING:\n      case FieldDescriptor::CPPTYPE_MESSAGE:\n        if (IsMapFieldInApi(field)) {\n          return GetRaw<MapFieldBase>(message, field).GetRepeatedField().size();\n        } else {\n          return GetRaw<RepeatedPtrFieldBase>(message, field).size();\n        }\n    }\n\n    GOOGLE_LOG(FATAL) << \"Can't get here.\";\n    return 0;\n  }\n}\n\nvoid GeneratedMessageReflection::ClearField(\n    Message* message, const FieldDescriptor* field) const {\n  USAGE_CHECK_MESSAGE_TYPE(ClearField);\n\n  if (field->is_extension()) {\n    MutableExtensionSet(message)->ClearExtension(field->number());\n  } else if (!field->is_repeated()) {\n    if (field->containing_oneof()) {\n      ClearOneofField(message, field);\n      return;\n    }\n\n    if (HasBit(*message, field)) {\n      ClearBit(message, field);\n\n      // We need to set the field back to its default value.\n      switch (field->cpp_type()) {\n#define CLEAR_TYPE(CPPTYPE, TYPE)                                            \\\n        case FieldDescriptor::CPPTYPE_##CPPTYPE:                             \\\n          *MutableRaw<TYPE>(message, field) =                                \\\n            field->default_value_##TYPE();                                   \\\n          break;\n\n        CLEAR_TYPE(INT32 , int32 );\n        CLEAR_TYPE(INT64 , int64 );\n        CLEAR_TYPE(UINT32, uint32);\n        CLEAR_TYPE(UINT64, uint64);\n        CLEAR_TYPE(FLOAT , float );\n        CLEAR_TYPE(DOUBLE, double);\n        CLEAR_TYPE(BOOL  , bool  );\n#undef CLEAR_TYPE\n\n        case FieldDescriptor::CPPTYPE_ENUM:\n          *MutableRaw<int>(message, field) =\n            field->default_value_enum()->number();\n          break;\n\n        case FieldDescriptor::CPPTYPE_STRING: {\n          switch (field->options().ctype()) {\n            default:  // TODO(kenton):  Support other string reps.\n            case FieldOptions::STRING: {\n              const string* default_ptr =\n                  &DefaultRaw<ArenaStringPtr>(field).Get(NULL);\n              MutableRaw<ArenaStringPtr>(message, field)->Destroy(default_ptr,\n                  GetArena(message));\n              break;\n            }\n          }\n          break;\n        }\n\n        case FieldDescriptor::CPPTYPE_MESSAGE:\n          if (has_bits_offset_ == -1) {\n            // Proto3 does not have has-bits and we need to set a message field\n            // to NULL in order to indicate its un-presence.\n            if (GetArena(message) == NULL) {\n              delete *MutableRaw<Message*>(message, field);\n            }\n            *MutableRaw<Message*>(message, field) = NULL;\n          } else {\n            (*MutableRaw<Message*>(message, field))->Clear();\n          }\n          break;\n      }\n    }\n  } else {\n    switch (field->cpp_type()) {\n#define HANDLE_TYPE(UPPERCASE, LOWERCASE)                                     \\\n      case FieldDescriptor::CPPTYPE_##UPPERCASE :                             \\\n        MutableRaw<RepeatedField<LOWERCASE> >(message, field)->Clear();       \\\n        break\n\n      HANDLE_TYPE( INT32,  int32);\n      HANDLE_TYPE( INT64,  int64);\n      HANDLE_TYPE(UINT32, uint32);\n      HANDLE_TYPE(UINT64, uint64);\n      HANDLE_TYPE(DOUBLE, double);\n      HANDLE_TYPE( FLOAT,  float);\n      HANDLE_TYPE(  BOOL,   bool);\n      HANDLE_TYPE(  ENUM,    int);\n#undef HANDLE_TYPE\n\n      case FieldDescriptor::CPPTYPE_STRING: {\n        switch (field->options().ctype()) {\n          default:  // TODO(kenton):  Support other string reps.\n          case FieldOptions::STRING:\n            MutableRaw<RepeatedPtrField<string> >(message, field)->Clear();\n            break;\n        }\n        break;\n      }\n\n      case FieldDescriptor::CPPTYPE_MESSAGE: {\n        if (IsMapFieldInApi(field)) {\n          MutableRaw<MapFieldBase>(message, field)\n              ->MutableRepeatedField()\n              ->Clear<GenericTypeHandler<Message> >();\n        } else {\n          // We don't know which subclass of RepeatedPtrFieldBase the type is,\n          // so we use RepeatedPtrFieldBase directly.\n          MutableRaw<RepeatedPtrFieldBase>(message, field)\n              ->Clear<GenericTypeHandler<Message> >();\n        }\n        break;\n      }\n    }\n  }\n}\n\nvoid GeneratedMessageReflection::RemoveLast(\n    Message* message,\n    const FieldDescriptor* field) const {\n  USAGE_CHECK_MESSAGE_TYPE(RemoveLast);\n  USAGE_CHECK_REPEATED(RemoveLast);\n\n  if (field->is_extension()) {\n    MutableExtensionSet(message)->RemoveLast(field->number());\n  } else {\n    switch (field->cpp_type()) {\n#define HANDLE_TYPE(UPPERCASE, LOWERCASE)                                     \\\n      case FieldDescriptor::CPPTYPE_##UPPERCASE :                             \\\n        MutableRaw<RepeatedField<LOWERCASE> >(message, field)->RemoveLast();  \\\n        break\n\n      HANDLE_TYPE( INT32,  int32);\n      HANDLE_TYPE( INT64,  int64);\n      HANDLE_TYPE(UINT32, uint32);\n      HANDLE_TYPE(UINT64, uint64);\n      HANDLE_TYPE(DOUBLE, double);\n      HANDLE_TYPE( FLOAT,  float);\n      HANDLE_TYPE(  BOOL,   bool);\n      HANDLE_TYPE(  ENUM,    int);\n#undef HANDLE_TYPE\n\n      case FieldDescriptor::CPPTYPE_STRING:\n        switch (field->options().ctype()) {\n          default:  // TODO(kenton):  Support other string reps.\n          case FieldOptions::STRING:\n            MutableRaw<RepeatedPtrField<string> >(message, field)->RemoveLast();\n            break;\n        }\n        break;\n\n      case FieldDescriptor::CPPTYPE_MESSAGE:\n        if (IsMapFieldInApi(field)) {\n          MutableRaw<MapFieldBase>(message, field)\n              ->MutableRepeatedField()\n              ->RemoveLast<GenericTypeHandler<Message> >();\n        } else {\n          MutableRaw<RepeatedPtrFieldBase>(message, field)\n            ->RemoveLast<GenericTypeHandler<Message> >();\n        }\n        break;\n    }\n  }\n}\n\nMessage* GeneratedMessageReflection::ReleaseLast(\n    Message* message,\n    const FieldDescriptor* field) const {\n  USAGE_CHECK_ALL(ReleaseLast, REPEATED, MESSAGE);\n\n  if (field->is_extension()) {\n    return static_cast<Message*>(\n        MutableExtensionSet(message)->ReleaseLast(field->number()));\n  } else {\n    if (IsMapFieldInApi(field)) {\n      return MutableRaw<MapFieldBase>(message, field)\n          ->MutableRepeatedField()\n          ->ReleaseLast<GenericTypeHandler<Message> >();\n    } else {\n      return MutableRaw<RepeatedPtrFieldBase>(message, field)\n        ->ReleaseLast<GenericTypeHandler<Message> >();\n    }\n  }\n}\n\nvoid GeneratedMessageReflection::SwapElements(\n    Message* message,\n    const FieldDescriptor* field,\n    int index1,\n    int index2) const {\n  USAGE_CHECK_MESSAGE_TYPE(Swap);\n  USAGE_CHECK_REPEATED(Swap);\n\n  if (field->is_extension()) {\n    MutableExtensionSet(message)->SwapElements(field->number(), index1, index2);\n  } else {\n    switch (field->cpp_type()) {\n#define HANDLE_TYPE(UPPERCASE, LOWERCASE)                                     \\\n      case FieldDescriptor::CPPTYPE_##UPPERCASE :                             \\\n        MutableRaw<RepeatedField<LOWERCASE> >(message, field)                 \\\n            ->SwapElements(index1, index2);                                   \\\n        break\n\n      HANDLE_TYPE( INT32,  int32);\n      HANDLE_TYPE( INT64,  int64);\n      HANDLE_TYPE(UINT32, uint32);\n      HANDLE_TYPE(UINT64, uint64);\n      HANDLE_TYPE(DOUBLE, double);\n      HANDLE_TYPE( FLOAT,  float);\n      HANDLE_TYPE(  BOOL,   bool);\n      HANDLE_TYPE(  ENUM,    int);\n#undef HANDLE_TYPE\n\n      case FieldDescriptor::CPPTYPE_STRING:\n      case FieldDescriptor::CPPTYPE_MESSAGE:\n        if (IsMapFieldInApi(field)) {\n          MutableRaw<MapFieldBase>(message, field)\n              ->MutableRepeatedField()\n              ->SwapElements(index1, index2);\n        } else {\n          MutableRaw<RepeatedPtrFieldBase>(message, field)\n            ->SwapElements(index1, index2);\n        }\n        break;\n    }\n  }\n}\n\nnamespace {\n// Comparison functor for sorting FieldDescriptors by field number.\nstruct FieldNumberSorter {\n  bool operator()(const FieldDescriptor* left,\n                  const FieldDescriptor* right) const {\n    return left->number() < right->number();\n  }\n};\n}  // namespace\n\nvoid GeneratedMessageReflection::ListFields(\n    const Message& message,\n    vector<const FieldDescriptor*>* output) const {\n  output->clear();\n\n  // Optimization:  The default instance never has any fields set.\n  if (&message == default_instance_) return;\n\n  output->reserve(descriptor_->field_count());\n  for (int i = 0; i < descriptor_->field_count(); i++) {\n    const FieldDescriptor* field = descriptor_->field(i);\n    if (field->is_repeated()) {\n      if (FieldSize(message, field) > 0) {\n        output->push_back(field);\n      }\n    } else {\n      if (field->containing_oneof()) {\n        if (HasOneofField(message, field)) {\n          output->push_back(field);\n        }\n      } else if (HasBit(message, field)) {\n        output->push_back(field);\n      }\n    }\n  }\n\n  if (extensions_offset_ != -1) {\n    GetExtensionSet(message).AppendToList(descriptor_, descriptor_pool_,\n                                          output);\n  }\n\n  // ListFields() must sort output by field number.\n  std::sort(output->begin(), output->end(), FieldNumberSorter());\n}\n\n// -------------------------------------------------------------------\n\n#undef DEFINE_PRIMITIVE_ACCESSORS\n#define DEFINE_PRIMITIVE_ACCESSORS(TYPENAME, TYPE, PASSTYPE, CPPTYPE)        \\\n  PASSTYPE GeneratedMessageReflection::Get##TYPENAME(                        \\\n      const Message& message, const FieldDescriptor* field) const {          \\\n    USAGE_CHECK_ALL(Get##TYPENAME, SINGULAR, CPPTYPE);                       \\\n    if (field->is_extension()) {                                             \\\n      return GetExtensionSet(message).Get##TYPENAME(                         \\\n        field->number(), field->default_value_##PASSTYPE());                 \\\n    } else {                                                                 \\\n      return GetField<TYPE>(message, field);                                 \\\n    }                                                                        \\\n  }                                                                          \\\n                                                                             \\\n  void GeneratedMessageReflection::Set##TYPENAME(                            \\\n      Message* message, const FieldDescriptor* field,                        \\\n      PASSTYPE value) const {                                                \\\n    USAGE_CHECK_ALL(Set##TYPENAME, SINGULAR, CPPTYPE);                       \\\n    if (field->is_extension()) {                                             \\\n      return MutableExtensionSet(message)->Set##TYPENAME(                    \\\n        field->number(), field->type(), value, field);                       \\\n    } else {                                                                 \\\n      SetField<TYPE>(message, field, value);                                 \\\n    }                                                                        \\\n  }                                                                          \\\n                                                                             \\\n  PASSTYPE GeneratedMessageReflection::GetRepeated##TYPENAME(                \\\n      const Message& message,                                                \\\n      const FieldDescriptor* field, int index) const {                       \\\n    USAGE_CHECK_ALL(GetRepeated##TYPENAME, REPEATED, CPPTYPE);               \\\n    if (field->is_extension()) {                                             \\\n      return GetExtensionSet(message).GetRepeated##TYPENAME(                 \\\n        field->number(), index);                                             \\\n    } else {                                                                 \\\n      return GetRepeatedField<TYPE>(message, field, index);                  \\\n    }                                                                        \\\n  }                                                                          \\\n                                                                             \\\n  void GeneratedMessageReflection::SetRepeated##TYPENAME(                    \\\n      Message* message, const FieldDescriptor* field,                        \\\n      int index, PASSTYPE value) const {                                     \\\n    USAGE_CHECK_ALL(SetRepeated##TYPENAME, REPEATED, CPPTYPE);               \\\n    if (field->is_extension()) {                                             \\\n      MutableExtensionSet(message)->SetRepeated##TYPENAME(                   \\\n        field->number(), index, value);                                      \\\n    } else {                                                                 \\\n      SetRepeatedField<TYPE>(message, field, index, value);                  \\\n    }                                                                        \\\n  }                                                                          \\\n                                                                             \\\n  void GeneratedMessageReflection::Add##TYPENAME(                            \\\n      Message* message, const FieldDescriptor* field,                        \\\n      PASSTYPE value) const {                                                \\\n    USAGE_CHECK_ALL(Add##TYPENAME, REPEATED, CPPTYPE);                       \\\n    if (field->is_extension()) {                                             \\\n      MutableExtensionSet(message)->Add##TYPENAME(                           \\\n        field->number(), field->type(), field->options().packed(), value,    \\\n        field);                                                              \\\n    } else {                                                                 \\\n      AddField<TYPE>(message, field, value);                                 \\\n    }                                                                        \\\n  }\n\nDEFINE_PRIMITIVE_ACCESSORS(Int32 , int32 , int32 , INT32 )\nDEFINE_PRIMITIVE_ACCESSORS(Int64 , int64 , int64 , INT64 )\nDEFINE_PRIMITIVE_ACCESSORS(UInt32, uint32, uint32, UINT32)\nDEFINE_PRIMITIVE_ACCESSORS(UInt64, uint64, uint64, UINT64)\nDEFINE_PRIMITIVE_ACCESSORS(Float , float , float , FLOAT )\nDEFINE_PRIMITIVE_ACCESSORS(Double, double, double, DOUBLE)\nDEFINE_PRIMITIVE_ACCESSORS(Bool  , bool  , bool  , BOOL  )\n#undef DEFINE_PRIMITIVE_ACCESSORS\n\n// -------------------------------------------------------------------\n\nstring GeneratedMessageReflection::GetString(\n    const Message& message, const FieldDescriptor* field) const {\n  USAGE_CHECK_ALL(GetString, SINGULAR, STRING);\n  if (field->is_extension()) {\n    return GetExtensionSet(message).GetString(field->number(),\n                                              field->default_value_string());\n  } else {\n    switch (field->options().ctype()) {\n      default:  // TODO(kenton):  Support other string reps.\n      case FieldOptions::STRING: {\n        const string* default_ptr =\n            &DefaultRaw<ArenaStringPtr>(field).Get(NULL);\n        return GetField<ArenaStringPtr>(message, field).Get(default_ptr);\n      }\n    }\n\n    GOOGLE_LOG(FATAL) << \"Can't get here.\";\n    return GetEmptyString();  // Make compiler happy.\n  }\n}\n\nconst string& GeneratedMessageReflection::GetStringReference(\n    const Message& message,\n    const FieldDescriptor* field, string* scratch) const {\n  USAGE_CHECK_ALL(GetStringReference, SINGULAR, STRING);\n  if (field->is_extension()) {\n    return GetExtensionSet(message).GetString(field->number(),\n                                              field->default_value_string());\n  } else {\n    switch (field->options().ctype()) {\n      default:  // TODO(kenton):  Support other string reps.\n      case FieldOptions::STRING: {\n        const string* default_ptr =\n            &DefaultRaw<ArenaStringPtr>(field).Get(NULL);\n        return GetField<ArenaStringPtr>(message, field).Get(default_ptr);\n      }\n    }\n\n    GOOGLE_LOG(FATAL) << \"Can't get here.\";\n    return GetEmptyString();  // Make compiler happy.\n  }\n}\n\n\nvoid GeneratedMessageReflection::SetString(\n    Message* message, const FieldDescriptor* field,\n    const string& value) const {\n  USAGE_CHECK_ALL(SetString, SINGULAR, STRING);\n  if (field->is_extension()) {\n    return MutableExtensionSet(message)->SetString(field->number(),\n                                                   field->type(), value, field);\n  } else {\n    switch (field->options().ctype()) {\n      default:  // TODO(kenton):  Support other string reps.\n      case FieldOptions::STRING: {\n        const string* default_ptr =\n            &DefaultRaw<ArenaStringPtr>(field).Get(NULL);\n        if (field->containing_oneof() && !HasOneofField(*message, field)) {\n          ClearOneof(message, field->containing_oneof());\n          MutableField<ArenaStringPtr>(message, field)->UnsafeSetDefault(\n              default_ptr);\n        }\n        MutableField<ArenaStringPtr>(message, field)->Set(default_ptr,\n            value, GetArena(message));\n        break;\n      }\n    }\n  }\n}\n\n\nstring GeneratedMessageReflection::GetRepeatedString(\n    const Message& message, const FieldDescriptor* field, int index) const {\n  USAGE_CHECK_ALL(GetRepeatedString, REPEATED, STRING);\n  if (field->is_extension()) {\n    return GetExtensionSet(message).GetRepeatedString(field->number(), index);\n  } else {\n    switch (field->options().ctype()) {\n      default:  // TODO(kenton):  Support other string reps.\n      case FieldOptions::STRING:\n        return GetRepeatedPtrField<string>(message, field, index);\n    }\n\n    GOOGLE_LOG(FATAL) << \"Can't get here.\";\n    return GetEmptyString();  // Make compiler happy.\n  }\n}\n\nconst string& GeneratedMessageReflection::GetRepeatedStringReference(\n    const Message& message, const FieldDescriptor* field,\n    int index, string* scratch) const {\n  USAGE_CHECK_ALL(GetRepeatedStringReference, REPEATED, STRING);\n  if (field->is_extension()) {\n    return GetExtensionSet(message).GetRepeatedString(field->number(), index);\n  } else {\n    switch (field->options().ctype()) {\n      default:  // TODO(kenton):  Support other string reps.\n      case FieldOptions::STRING:\n        return GetRepeatedPtrField<string>(message, field, index);\n    }\n\n    GOOGLE_LOG(FATAL) << \"Can't get here.\";\n    return GetEmptyString();  // Make compiler happy.\n  }\n}\n\n\nvoid GeneratedMessageReflection::SetRepeatedString(\n    Message* message, const FieldDescriptor* field,\n    int index, const string& value) const {\n  USAGE_CHECK_ALL(SetRepeatedString, REPEATED, STRING);\n  if (field->is_extension()) {\n    MutableExtensionSet(message)->SetRepeatedString(\n      field->number(), index, value);\n  } else {\n    switch (field->options().ctype()) {\n      default:  // TODO(kenton):  Support other string reps.\n      case FieldOptions::STRING:\n        *MutableRepeatedField<string>(message, field, index) = value;\n        break;\n    }\n  }\n}\n\n\nvoid GeneratedMessageReflection::AddString(\n    Message* message, const FieldDescriptor* field,\n    const string& value) const {\n  USAGE_CHECK_ALL(AddString, REPEATED, STRING);\n  if (field->is_extension()) {\n    MutableExtensionSet(message)->AddString(field->number(),\n                                            field->type(), value, field);\n  } else {\n    switch (field->options().ctype()) {\n      default:  // TODO(kenton):  Support other string reps.\n      case FieldOptions::STRING:\n        *AddField<string>(message, field) = value;\n        break;\n    }\n  }\n}\n\n\n// -------------------------------------------------------------------\n\ninline bool CreateUnknownEnumValues(const FileDescriptor* file) {\n  return file->syntax() == FileDescriptor::SYNTAX_PROTO3;\n}\n\nconst EnumValueDescriptor* GeneratedMessageReflection::GetEnum(\n    const Message& message, const FieldDescriptor* field) const {\n  // Usage checked by GetEnumValue.\n  int value = GetEnumValue(message, field);\n  return field->enum_type()->FindValueByNumberCreatingIfUnknown(value);\n}\n\nint GeneratedMessageReflection::GetEnumValue(\n    const Message& message, const FieldDescriptor* field) const {\n  USAGE_CHECK_ALL(GetEnumValue, SINGULAR, ENUM);\n\n  int32 value;\n  if (field->is_extension()) {\n    value = GetExtensionSet(message).GetEnum(\n      field->number(), field->default_value_enum()->number());\n  } else {\n    value = GetField<int>(message, field);\n  }\n  return value;\n}\n\nvoid GeneratedMessageReflection::SetEnum(\n    Message* message, const FieldDescriptor* field,\n    const EnumValueDescriptor* value) const {\n  // Usage checked by SetEnumValue.\n  USAGE_CHECK_ENUM_VALUE(SetEnum);\n  SetEnumValueInternal(message, field, value->number());\n}\n\nvoid GeneratedMessageReflection::SetEnumValue(\n    Message* message, const FieldDescriptor* field,\n    int value) const {\n  USAGE_CHECK_ALL(SetEnumValue, SINGULAR, ENUM);\n  if (!CreateUnknownEnumValues(descriptor_->file())) {\n    // Check that the value is valid if we don't support direct storage of\n    // unknown enum values.\n    const EnumValueDescriptor* value_desc =\n        field->enum_type()->FindValueByNumber(value);\n    if (value_desc == NULL) {\n      GOOGLE_LOG(DFATAL) << \"SetEnumValue accepts only valid integer values: value \"\n                  << value << \" unexpected for field \" << field->full_name();\n      // In production builds, DFATAL will not terminate the program, so we have\n      // to do something reasonable: just set the default value.\n      value = field->default_value_enum()->number();\n    }\n  }\n  SetEnumValueInternal(message, field, value);\n}\n\nvoid GeneratedMessageReflection::SetEnumValueInternal(\n    Message* message, const FieldDescriptor* field,\n    int value) const {\n  if (field->is_extension()) {\n    MutableExtensionSet(message)->SetEnum(field->number(), field->type(),\n                                          value, field);\n  } else {\n    SetField<int>(message, field, value);\n  }\n}\n\nconst EnumValueDescriptor* GeneratedMessageReflection::GetRepeatedEnum(\n    const Message& message, const FieldDescriptor* field, int index) const {\n  // Usage checked by GetRepeatedEnumValue.\n  int value = GetRepeatedEnumValue(message, field, index);\n  return field->enum_type()->FindValueByNumberCreatingIfUnknown(value);\n}\n\nint GeneratedMessageReflection::GetRepeatedEnumValue(\n    const Message& message, const FieldDescriptor* field, int index) const {\n  USAGE_CHECK_ALL(GetRepeatedEnumValue, REPEATED, ENUM);\n\n  int value;\n  if (field->is_extension()) {\n    value = GetExtensionSet(message).GetRepeatedEnum(field->number(), index);\n  } else {\n    value = GetRepeatedField<int>(message, field, index);\n  }\n  return value;\n}\n\nvoid GeneratedMessageReflection::SetRepeatedEnum(\n    Message* message,\n    const FieldDescriptor* field, int index,\n    const EnumValueDescriptor* value) const {\n  // Usage checked by SetRepeatedEnumValue.\n  USAGE_CHECK_ENUM_VALUE(SetRepeatedEnum);\n  SetRepeatedEnumValueInternal(message, field, index, value->number());\n}\n\nvoid GeneratedMessageReflection::SetRepeatedEnumValue(\n    Message* message,\n    const FieldDescriptor* field, int index,\n    int value) const {\n  USAGE_CHECK_ALL(SetRepeatedEnum, REPEATED, ENUM);\n  if (!CreateUnknownEnumValues(descriptor_->file())) {\n    // Check that the value is valid if we don't support direct storage of\n    // unknown enum values.\n    const EnumValueDescriptor* value_desc =\n        field->enum_type()->FindValueByNumber(value);\n    if (value_desc == NULL) {\n      GOOGLE_LOG(DFATAL) << \"SetRepeatedEnumValue accepts only valid integer values: \"\n                  << \"value \" << value << \" unexpected for field \"\n                  << field->full_name();\n      // In production builds, DFATAL will not terminate the program, so we have\n      // to do something reasonable: just set the default value.\n      value = field->default_value_enum()->number();\n    }\n  }\n  SetRepeatedEnumValueInternal(message, field, index, value);\n}\n\nvoid GeneratedMessageReflection::SetRepeatedEnumValueInternal(\n    Message* message,\n    const FieldDescriptor* field, int index,\n    int value) const {\n  if (field->is_extension()) {\n    MutableExtensionSet(message)->SetRepeatedEnum(\n      field->number(), index, value);\n  } else {\n    SetRepeatedField<int>(message, field, index, value);\n  }\n}\n\nvoid GeneratedMessageReflection::AddEnum(\n    Message* message, const FieldDescriptor* field,\n    const EnumValueDescriptor* value) const {\n  // Usage checked by AddEnumValue.\n  USAGE_CHECK_ENUM_VALUE(AddEnum);\n  AddEnumValueInternal(message, field, value->number());\n}\n\nvoid GeneratedMessageReflection::AddEnumValue(\n    Message* message, const FieldDescriptor* field,\n    int value) const {\n  USAGE_CHECK_ALL(AddEnum, REPEATED, ENUM);\n  if (!CreateUnknownEnumValues(descriptor_->file())) {\n    // Check that the value is valid if we don't support direct storage of\n    // unknown enum values.\n    const EnumValueDescriptor* value_desc =\n        field->enum_type()->FindValueByNumber(value);\n    if (value_desc == NULL) {\n      GOOGLE_LOG(DFATAL) << \"AddEnumValue accepts only valid integer values: value \"\n                  << value << \" unexpected for field \" << field->full_name();\n      // In production builds, DFATAL will not terminate the program, so we have\n      // to do something reasonable: just set the default value.\n      value = field->default_value_enum()->number();\n    }\n  }\n  AddEnumValueInternal(message, field, value);\n}\n\nvoid GeneratedMessageReflection::AddEnumValueInternal(\n    Message* message, const FieldDescriptor* field,\n    int value) const {\n  if (field->is_extension()) {\n    MutableExtensionSet(message)->AddEnum(field->number(), field->type(),\n                                          field->options().packed(),\n                                          value, field);\n  } else {\n    AddField<int>(message, field, value);\n  }\n}\n\n// -------------------------------------------------------------------\n\nconst Message& GeneratedMessageReflection::GetMessage(\n    const Message& message, const FieldDescriptor* field,\n    MessageFactory* factory) const {\n  USAGE_CHECK_ALL(GetMessage, SINGULAR, MESSAGE);\n\n  if (factory == NULL) factory = message_factory_;\n\n  if (field->is_extension()) {\n    return static_cast<const Message&>(\n        GetExtensionSet(message).GetMessage(\n          field->number(), field->message_type(), factory));\n  } else {\n    const Message* result;\n    result = GetRaw<const Message*>(message, field);\n    if (result == NULL) {\n      result = DefaultRaw<const Message*>(field);\n    }\n    return *result;\n  }\n}\n\nMessage* GeneratedMessageReflection::MutableMessage(\n    Message* message, const FieldDescriptor* field,\n    MessageFactory* factory) const {\n  USAGE_CHECK_ALL(MutableMessage, SINGULAR, MESSAGE);\n\n  if (factory == NULL) factory = message_factory_;\n\n  if (field->is_extension()) {\n    return static_cast<Message*>(\n        MutableExtensionSet(message)->MutableMessage(field, factory));\n  } else {\n    Message* result;\n    Message** result_holder = MutableRaw<Message*>(message, field);\n\n    if (field->containing_oneof()) {\n      if (!HasOneofField(*message, field)) {\n        ClearOneof(message, field->containing_oneof());\n        result_holder = MutableField<Message*>(message, field);\n        const Message* default_message = DefaultRaw<const Message*>(field);\n        *result_holder = default_message->New(message->GetArena());\n      }\n    } else {\n      SetBit(message, field);\n    }\n\n    if (*result_holder == NULL) {\n      const Message* default_message = DefaultRaw<const Message*>(field);\n      *result_holder = default_message->New(message->GetArena());\n    }\n    result = *result_holder;\n    return result;\n  }\n}\n\nvoid GeneratedMessageReflection::UnsafeArenaSetAllocatedMessage(\n    Message* message,\n    Message* sub_message,\n    const FieldDescriptor* field) const {\n  USAGE_CHECK_ALL(SetAllocatedMessage, SINGULAR, MESSAGE);\n\n  if (field->is_extension()) {\n    MutableExtensionSet(message)->SetAllocatedMessage(\n        field->number(), field->type(), field, sub_message);\n  } else {\n    if (field->containing_oneof()) {\n      if (sub_message == NULL) {\n        ClearOneof(message, field->containing_oneof());\n        return;\n      }\n        ClearOneof(message, field->containing_oneof());\n        *MutableRaw<Message*>(message, field) = sub_message;\n      SetOneofCase(message, field);\n      return;\n    }\n\n    if (sub_message == NULL) {\n      ClearBit(message, field);\n    } else {\n      SetBit(message, field);\n    }\n    Message** sub_message_holder = MutableRaw<Message*>(message, field);\n    if (GetArena(message) == NULL) {\n      delete *sub_message_holder;\n    }\n    *sub_message_holder = sub_message;\n  }\n}\n\nvoid GeneratedMessageReflection::SetAllocatedMessage(\n    Message* message,\n    Message* sub_message,\n    const FieldDescriptor* field) const {\n  // If message and sub-message are in different memory ownership domains\n  // (different arenas, or one is on heap and one is not), then we may need to\n  // do a copy.\n  if (sub_message != NULL &&\n      sub_message->GetArena() != message->GetArena()) {\n    if (sub_message->GetArena() == NULL && message->GetArena() != NULL) {\n      // Case 1: parent is on an arena and child is heap-allocated. We can add\n      // the child to the arena's Own() list to free on arena destruction, then\n      // set our pointer.\n      message->GetArena()->Own(sub_message);\n      UnsafeArenaSetAllocatedMessage(message, sub_message, field);\n    } else {\n      // Case 2: all other cases. We need to make a copy. MutableMessage() will\n      // either get the existing message object, or instantiate a new one as\n      // appropriate w.r.t. our arena.\n      Message* sub_message_copy = MutableMessage(message, field);\n      sub_message_copy->CopyFrom(*sub_message);\n    }\n  } else {\n    // Same memory ownership domains.\n    UnsafeArenaSetAllocatedMessage(message, sub_message, field);\n  }\n}\n\nMessage* GeneratedMessageReflection::UnsafeArenaReleaseMessage(\n    Message* message,\n    const FieldDescriptor* field,\n    MessageFactory* factory) const {\n  USAGE_CHECK_ALL(ReleaseMessage, SINGULAR, MESSAGE);\n\n  if (factory == NULL) factory = message_factory_;\n\n  if (field->is_extension()) {\n    return static_cast<Message*>(\n        MutableExtensionSet(message)->UnsafeArenaReleaseMessage(field,\n                                                                factory));\n  } else {\n    ClearBit(message, field);\n    if (field->containing_oneof()) {\n      if (HasOneofField(*message, field)) {\n        *MutableOneofCase(message, field->containing_oneof()) = 0;\n      } else {\n        return NULL;\n      }\n    }\n    Message** result = MutableRaw<Message*>(message, field);\n    Message* ret = *result;\n    *result = NULL;\n    return ret;\n  }\n}\n\nMessage* GeneratedMessageReflection::ReleaseMessage(\n    Message* message,\n    const FieldDescriptor* field,\n    MessageFactory* factory) const {\n  Message* released = UnsafeArenaReleaseMessage(message, field, factory);\n  if (GetArena(message) != NULL && released != NULL) {\n    Message* copy_from_arena = released->New();\n    copy_from_arena->CopyFrom(*released);\n    released = copy_from_arena;\n  }\n  return released;\n}\n\nconst Message& GeneratedMessageReflection::GetRepeatedMessage(\n    const Message& message, const FieldDescriptor* field, int index) const {\n  USAGE_CHECK_ALL(GetRepeatedMessage, REPEATED, MESSAGE);\n\n  if (field->is_extension()) {\n    return static_cast<const Message&>(\n        GetExtensionSet(message).GetRepeatedMessage(field->number(), index));\n  } else {\n    if (IsMapFieldInApi(field)) {\n      return GetRaw<MapFieldBase>(message, field)\n          .GetRepeatedField()\n          .Get<GenericTypeHandler<Message> >(index);\n    } else {\n      return GetRaw<RepeatedPtrFieldBase>(message, field)\n          .Get<GenericTypeHandler<Message> >(index);\n    }\n  }\n}\n\nMessage* GeneratedMessageReflection::MutableRepeatedMessage(\n    Message* message, const FieldDescriptor* field, int index) const {\n  USAGE_CHECK_ALL(MutableRepeatedMessage, REPEATED, MESSAGE);\n\n  if (field->is_extension()) {\n    return static_cast<Message*>(\n        MutableExtensionSet(message)->MutableRepeatedMessage(\n          field->number(), index));\n  } else {\n    if (IsMapFieldInApi(field)) {\n      return MutableRaw<MapFieldBase>(message, field)\n          ->MutableRepeatedField()\n          ->Mutable<GenericTypeHandler<Message> >(index);\n    } else {\n      return MutableRaw<RepeatedPtrFieldBase>(message, field)\n        ->Mutable<GenericTypeHandler<Message> >(index);\n    }\n  }\n}\n\nMessage* GeneratedMessageReflection::AddMessage(\n    Message* message, const FieldDescriptor* field,\n    MessageFactory* factory) const {\n  USAGE_CHECK_ALL(AddMessage, REPEATED, MESSAGE);\n\n  if (factory == NULL) factory = message_factory_;\n\n  if (field->is_extension()) {\n    return static_cast<Message*>(\n        MutableExtensionSet(message)->AddMessage(field, factory));\n  } else {\n    Message* result = NULL;\n\n    // We can't use AddField<Message>() because RepeatedPtrFieldBase doesn't\n    // know how to allocate one.\n    RepeatedPtrFieldBase* repeated = NULL;\n    if (IsMapFieldInApi(field)) {\n      repeated =\n          MutableRaw<MapFieldBase>(message, field)->MutableRepeatedField();\n    } else {\n      repeated = MutableRaw<RepeatedPtrFieldBase>(message, field);\n    }\n    result = repeated->AddFromCleared<GenericTypeHandler<Message> >();\n    if (result == NULL) {\n      // We must allocate a new object.\n      const Message* prototype;\n      if (repeated->size() == 0) {\n        prototype = factory->GetPrototype(field->message_type());\n      } else {\n        prototype = &repeated->Get<GenericTypeHandler<Message> >(0);\n      }\n      result = prototype->New(message->GetArena());\n      // We can guarantee here that repeated and result are either both heap\n      // allocated or arena owned. So it is safe to call the unsafe version\n      // of AddAllocated.\n      repeated->UnsafeArenaAddAllocated<GenericTypeHandler<Message> >(result);\n    }\n\n    return result;\n  }\n}\n\nvoid GeneratedMessageReflection::AddAllocatedMessage(\n    Message* message, const FieldDescriptor* field,\n    Message* new_entry) const {\n  USAGE_CHECK_ALL(AddAllocatedMessage, REPEATED, MESSAGE);\n\n  if (field->is_extension()) {\n    MutableExtensionSet(message)->AddAllocatedMessage(field, new_entry);\n  } else {\n    RepeatedPtrFieldBase* repeated = NULL;\n    if (IsMapFieldInApi(field)) {\n      repeated =\n          MutableRaw<MapFieldBase>(message, field)->MutableRepeatedField();\n    } else {\n      repeated = MutableRaw<RepeatedPtrFieldBase>(message, field);\n    }\n    repeated->AddAllocated<GenericTypeHandler<Message> >(new_entry);\n  }\n}\n\nvoid* GeneratedMessageReflection::MutableRawRepeatedField(\n    Message* message, const FieldDescriptor* field,\n    FieldDescriptor::CppType cpptype,\n    int ctype, const Descriptor* desc) const {\n  USAGE_CHECK_REPEATED(\"MutableRawRepeatedField\");\n  if (field->cpp_type() != cpptype)\n    ReportReflectionUsageTypeError(descriptor_,\n        field, \"MutableRawRepeatedField\", cpptype);\n  if (ctype >= 0)\n    GOOGLE_CHECK_EQ(field->options().ctype(), ctype) << \"subtype mismatch\";\n  if (desc != NULL)\n    GOOGLE_CHECK_EQ(field->message_type(), desc) << \"wrong submessage type\";\n  if (field->is_extension()) {\n    return MutableExtensionSet(message)->MutableRawRepeatedField(\n        field->number(), field->type(), field->is_packed(), field);\n  } else {\n    // Trigger transform for MapField\n    if (IsMapFieldInApi(field)) {\n      return reinterpret_cast<MapFieldBase*>(reinterpret_cast<uint8*>(message) +\n                                             offsets_[field->index()])\n          ->MutableRepeatedField();\n    }\n    return reinterpret_cast<uint8*>(message) + offsets_[field->index()];\n  }\n}\n\nconst void* GeneratedMessageReflection::GetRawRepeatedField(\n    const Message& message, const FieldDescriptor* field,\n    FieldDescriptor::CppType cpptype,\n    int ctype, const Descriptor* desc) const {\n  USAGE_CHECK_REPEATED(\"GetRawRepeatedField\");\n  if (field->cpp_type() != cpptype)\n    ReportReflectionUsageTypeError(descriptor_,\n        field, \"GetRawRepeatedField\", cpptype);\n  if (ctype >= 0)\n    GOOGLE_CHECK_EQ(field->options().ctype(), ctype) << \"subtype mismatch\";\n  if (desc != NULL)\n    GOOGLE_CHECK_EQ(field->message_type(), desc) << \"wrong submessage type\";\n  if (field->is_extension()) {\n    // Should use extension_set::GetRawRepeatedField. However, the required\n    // parameter \"default repeated value\" is not very easy to get here.\n    // Map is not supported in extensions, it is acceptable to use\n    // extension_set::MutableRawRepeatedField which does not change the message.\n    return MutableExtensionSet(const_cast<Message*>(&message))\n        ->MutableRawRepeatedField(\n        field->number(), field->type(), field->is_packed(), field);\n  } else {\n    // Trigger transform for MapField\n    if (IsMapFieldInApi(field)) {\n      return &(reinterpret_cast<const MapFieldBase*>(\n          reinterpret_cast<const uint8*>(&message) +\n          offsets_[field->index()])->GetRepeatedField());\n    }\n    return reinterpret_cast<const uint8*>(&message) + offsets_[field->index()];\n  }\n}\n\nconst FieldDescriptor* GeneratedMessageReflection::GetOneofFieldDescriptor(\n    const Message& message,\n    const OneofDescriptor* oneof_descriptor) const {\n  uint32 field_number = GetOneofCase(message, oneof_descriptor);\n  if (field_number == 0) {\n    return NULL;\n  }\n  return descriptor_->FindFieldByNumber(field_number);\n}\n\nbool GeneratedMessageReflection::ContainsMapKey(\n    const Message& message,\n    const FieldDescriptor* field,\n    const MapKey& key) const {\n  USAGE_CHECK(IsMapFieldInApi(field),\n              \"LookupMapValue\",\n              \"Field is not a map field.\");\n  return GetRaw<MapFieldBase>(message, field).ContainsMapKey(key);\n}\n\nbool GeneratedMessageReflection::InsertOrLookupMapValue(\n    Message* message,\n    const FieldDescriptor* field,\n    const MapKey& key,\n    MapValueRef* val) const {\n  USAGE_CHECK(IsMapFieldInApi(field),\n              \"InsertOrLookupMapValue\",\n              \"Field is not a map field.\");\n  val->SetType(field->message_type()->FindFieldByName(\"value\")->cpp_type());\n  return MutableRaw<MapFieldBase>(message, field)->InsertOrLookupMapValue(\n      key, val);\n}\n\nbool GeneratedMessageReflection::DeleteMapValue(\n    Message* message,\n    const FieldDescriptor* field,\n    const MapKey& key) const {\n  USAGE_CHECK(IsMapFieldInApi(field),\n              \"DeleteMapValue\",\n              \"Field is not a map field.\");\n  return MutableRaw<MapFieldBase>(message, field)->DeleteMapValue(key);\n}\n\nMapIterator GeneratedMessageReflection::MapBegin(\n    Message* message,\n    const FieldDescriptor* field) const {\n  USAGE_CHECK(IsMapFieldInApi(field),\n              \"MapBegin\",\n              \"Field is not a map field.\");\n  MapIterator iter(message, field);\n  GetRaw<MapFieldBase>(*message, field).MapBegin(&iter);\n  return iter;\n}\n\nMapIterator GeneratedMessageReflection::MapEnd(\n    Message* message,\n    const FieldDescriptor* field) const {\n  USAGE_CHECK(IsMapFieldInApi(field),\n              \"MapEnd\",\n              \"Field is not a map field.\");\n  MapIterator iter(message, field);\n  GetRaw<MapFieldBase>(*message, field).MapEnd(&iter);\n  return iter;\n}\n\nint GeneratedMessageReflection::MapSize(\n    const Message& message,\n    const FieldDescriptor* field) const {\n  USAGE_CHECK(IsMapFieldInApi(field),\n              \"MapSize\",\n              \"Field is not a map field.\");\n  return GetRaw<MapFieldBase>(message, field).size();\n}\n\n// -----------------------------------------------------------------------------\n\nconst FieldDescriptor* GeneratedMessageReflection::FindKnownExtensionByName(\n    const string& name) const {\n  if (extensions_offset_ == -1) return NULL;\n\n  const FieldDescriptor* result = descriptor_pool_->FindExtensionByName(name);\n  if (result != NULL && result->containing_type() == descriptor_) {\n    return result;\n  }\n\n  if (descriptor_->options().message_set_wire_format()) {\n    // MessageSet extensions may be identified by type name.\n    const Descriptor* type = descriptor_pool_->FindMessageTypeByName(name);\n    if (type != NULL) {\n      // Look for a matching extension in the foreign type's scope.\n      for (int i = 0; i < type->extension_count(); i++) {\n        const FieldDescriptor* extension = type->extension(i);\n        if (extension->containing_type() == descriptor_ &&\n            extension->type() == FieldDescriptor::TYPE_MESSAGE &&\n            extension->is_optional() &&\n            extension->message_type() == type) {\n          // Found it.\n          return extension;\n        }\n      }\n    }\n  }\n\n  return NULL;\n}\n\nconst FieldDescriptor* GeneratedMessageReflection::FindKnownExtensionByNumber(\n    int number) const {\n  if (extensions_offset_ == -1) return NULL;\n  return descriptor_pool_->FindExtensionByNumber(descriptor_, number);\n}\n\nbool GeneratedMessageReflection::SupportsUnknownEnumValues() const {\n  return CreateUnknownEnumValues(descriptor_->file());\n}\n\n// ===================================================================\n// Some private helpers.\n\n// These simple template accessors obtain pointers (or references) to\n// the given field.\ntemplate <typename Type>\ninline const Type& GeneratedMessageReflection::GetRaw(\n    const Message& message, const FieldDescriptor* field) const {\n  if (field->containing_oneof() && !HasOneofField(message, field)) {\n    return DefaultRaw<Type>(field);\n  }\n  int index = field->containing_oneof() ?\n      descriptor_->field_count() + field->containing_oneof()->index() :\n      field->index();\n  const void* ptr = reinterpret_cast<const uint8*>(&message) +\n      offsets_[index];\n  return *reinterpret_cast<const Type*>(ptr);\n}\n\ntemplate <typename Type>\ninline Type* GeneratedMessageReflection::MutableRaw(\n    Message* message, const FieldDescriptor* field) const {\n  int index = field->containing_oneof() ?\n      descriptor_->field_count() + field->containing_oneof()->index() :\n      field->index();\n  void* ptr = reinterpret_cast<uint8*>(message) + offsets_[index];\n  return reinterpret_cast<Type*>(ptr);\n}\n\ntemplate <typename Type>\ninline const Type& GeneratedMessageReflection::DefaultRaw(\n    const FieldDescriptor* field) const {\n  const void* ptr = field->containing_oneof() ?\n      reinterpret_cast<const uint8*>(default_oneof_instance_) +\n      offsets_[field->index()] :\n      reinterpret_cast<const uint8*>(default_instance_) +\n      offsets_[field->index()];\n  return *reinterpret_cast<const Type*>(ptr);\n}\n\ninline const uint32* GeneratedMessageReflection::GetHasBits(\n    const Message& message) const {\n  if (has_bits_offset_ == -1) {  // proto3 with no has-bits.\n    return NULL;\n  }\n  const void* ptr = reinterpret_cast<const uint8*>(&message) + has_bits_offset_;\n  return reinterpret_cast<const uint32*>(ptr);\n}\ninline uint32* GeneratedMessageReflection::MutableHasBits(\n    Message* message) const {\n  if (has_bits_offset_ == -1) {\n    return NULL;\n  }\n  void* ptr = reinterpret_cast<uint8*>(message) + has_bits_offset_;\n  return reinterpret_cast<uint32*>(ptr);\n}\n\ninline uint32 GeneratedMessageReflection::GetOneofCase(\n    const Message& message,\n    const OneofDescriptor* oneof_descriptor) const {\n  const void* ptr = reinterpret_cast<const uint8*>(&message)\n      + oneof_case_offset_;\n  return reinterpret_cast<const uint32*>(ptr)[oneof_descriptor->index()];\n}\n\ninline uint32* GeneratedMessageReflection::MutableOneofCase(\n    Message* message,\n    const OneofDescriptor* oneof_descriptor) const {\n  void* ptr = reinterpret_cast<uint8*>(message) + oneof_case_offset_;\n  return &(reinterpret_cast<uint32*>(ptr)[oneof_descriptor->index()]);\n}\n\ninline const ExtensionSet& GeneratedMessageReflection::GetExtensionSet(\n    const Message& message) const {\n  GOOGLE_DCHECK_NE(extensions_offset_, -1);\n  const void* ptr = reinterpret_cast<const uint8*>(&message) +\n                    extensions_offset_;\n  return *reinterpret_cast<const ExtensionSet*>(ptr);\n}\ninline ExtensionSet* GeneratedMessageReflection::MutableExtensionSet(\n    Message* message) const {\n  GOOGLE_DCHECK_NE(extensions_offset_, -1);\n  void* ptr = reinterpret_cast<uint8*>(message) + extensions_offset_;\n  return reinterpret_cast<ExtensionSet*>(ptr);\n}\n\ninline Arena* GeneratedMessageReflection::GetArena(Message* message) const {\n  if (arena_offset_ == kNoArenaPointer) {\n    return NULL;\n  }\n\n  if (unknown_fields_offset_ == kUnknownFieldSetInMetadata) {\n    // zero-overhead arena pointer overloading UnknownFields\n    return GetInternalMetadataWithArena(*message).arena();\n  }\n\n  // Baseline case: message class has a dedicated arena pointer.\n  void* ptr = reinterpret_cast<uint8*>(message) + arena_offset_;\n  return *reinterpret_cast<Arena**>(ptr);\n}\n\ninline const InternalMetadataWithArena&\nGeneratedMessageReflection::GetInternalMetadataWithArena(\n    const Message& message) const {\n  const void* ptr = reinterpret_cast<const uint8*>(&message) + arena_offset_;\n  return *reinterpret_cast<const InternalMetadataWithArena*>(ptr);\n}\n\ninline InternalMetadataWithArena*\nGeneratedMessageReflection::MutableInternalMetadataWithArena(\n    Message* message) const {\n  void* ptr = reinterpret_cast<uint8*>(message) + arena_offset_;\n  return reinterpret_cast<InternalMetadataWithArena*>(ptr);\n}\n\ninline bool\nGeneratedMessageReflection::GetIsDefaultInstance(\n    const Message& message) const {\n  if (is_default_instance_offset_ == kHasNoDefaultInstanceField) {\n    return false;\n  }\n  const void* ptr = reinterpret_cast<const uint8*>(&message) +\n      is_default_instance_offset_;\n  return *reinterpret_cast<const bool*>(ptr);\n}\n\n// Simple accessors for manipulating has_bits_.\ninline bool GeneratedMessageReflection::HasBit(\n    const Message& message, const FieldDescriptor* field) const {\n  if (has_bits_offset_ == -1) {\n    // proto3: no has-bits. All fields present except messages, which are\n    // present only if their message-field pointer is non-NULL.\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n      return !GetIsDefaultInstance(message) &&\n          GetRaw<const Message*>(message, field) != NULL;\n    } else {\n      // Non-message field (and non-oneof, since that was handled in HasField()\n      // before calling us), and singular (again, checked in HasField). So, this\n      // field must be a scalar.\n\n      // Scalar primitive (numeric or string/bytes) fields are present if\n      // their value is non-zero (numeric) or non-empty (string/bytes).  N.B.:\n      // we must use this definition here, rather than the \"scalar fields\n      // always present\" in the proto3 docs, because MergeFrom() semantics\n      // require presence as \"present on wire\", and reflection-based merge\n      // (which uses HasField()) needs to be consistent with this.\n      switch (field->cpp_type()) {\n        case FieldDescriptor::CPPTYPE_STRING:\n          switch (field->options().ctype()) {\n            default: {\n              const string* default_ptr =\n                  &DefaultRaw<ArenaStringPtr>(field).Get(NULL);\n              return GetField<ArenaStringPtr>(message, field).Get(\n                  default_ptr).size() > 0;\n            }\n          }\n          return false;\n        case FieldDescriptor::CPPTYPE_BOOL:\n          return GetRaw<bool>(message, field) != false;\n        case FieldDescriptor::CPPTYPE_INT32:\n          return GetRaw<int32>(message, field) != 0;\n        case FieldDescriptor::CPPTYPE_INT64:\n          return GetRaw<int64>(message, field) != 0;\n        case FieldDescriptor::CPPTYPE_UINT32:\n          return GetRaw<uint32>(message, field) != 0;\n        case FieldDescriptor::CPPTYPE_UINT64:\n          return GetRaw<uint64>(message, field) != 0;\n        case FieldDescriptor::CPPTYPE_FLOAT:\n          return GetRaw<float>(message, field) != 0.0;\n        case FieldDescriptor::CPPTYPE_DOUBLE:\n          return GetRaw<double>(message, field) != 0.0;\n        case FieldDescriptor::CPPTYPE_ENUM:\n          return GetRaw<int>(message, field) != 0;\n        case FieldDescriptor::CPPTYPE_MESSAGE:\n          // handled above; avoid warning\n          GOOGLE_LOG(FATAL) << \"Reached impossible case in HasBit().\";\n          break;\n      }\n    }\n  }\n  return GetHasBits(message)[field->index() / 32] &\n    (1 << (field->index() % 32));\n}\n\ninline void GeneratedMessageReflection::SetBit(\n    Message* message, const FieldDescriptor* field) const {\n  if (has_bits_offset_ == -1) {\n    return;\n  }\n  MutableHasBits(message)[field->index() / 32] |= (1 << (field->index() % 32));\n}\n\ninline void GeneratedMessageReflection::ClearBit(\n    Message* message, const FieldDescriptor* field) const {\n  if (has_bits_offset_ == -1) {\n    return;\n  }\n  MutableHasBits(message)[field->index() / 32] &= ~(1 << (field->index() % 32));\n}\n\ninline void GeneratedMessageReflection::SwapBit(\n    Message* message1, Message* message2, const FieldDescriptor* field) const {\n  if (has_bits_offset_ == -1) {\n    return;\n  }\n  bool temp_has_bit = HasBit(*message1, field);\n  if (HasBit(*message2, field)) {\n    SetBit(message1, field);\n  } else {\n    ClearBit(message1, field);\n  }\n  if (temp_has_bit) {\n    SetBit(message2, field);\n  } else {\n    ClearBit(message2, field);\n  }\n}\n\ninline bool GeneratedMessageReflection::HasOneof(\n    const Message& message, const OneofDescriptor* oneof_descriptor) const {\n  return (GetOneofCase(message, oneof_descriptor) > 0);\n}\n\ninline bool GeneratedMessageReflection::HasOneofField(\n    const Message& message, const FieldDescriptor* field) const {\n  return (GetOneofCase(message, field->containing_oneof()) == field->number());\n}\n\ninline void GeneratedMessageReflection::SetOneofCase(\n    Message* message, const FieldDescriptor* field) const {\n  *MutableOneofCase(message, field->containing_oneof()) = field->number();\n}\n\ninline void GeneratedMessageReflection::ClearOneofField(\n    Message* message, const FieldDescriptor* field) const {\n  if (HasOneofField(*message, field)) {\n    ClearOneof(message, field->containing_oneof());\n  }\n}\n\ninline void GeneratedMessageReflection::ClearOneof(\n    Message* message, const OneofDescriptor* oneof_descriptor) const {\n  // TODO(jieluo): Consider to cache the unused object instead of deleting\n  // it. It will be much faster if an application switches a lot from\n  // a few oneof fields.  Time/space tradeoff\n  uint32 oneof_case = GetOneofCase(*message, oneof_descriptor);\n  if (oneof_case > 0) {\n    const FieldDescriptor* field = descriptor_->FindFieldByNumber(oneof_case);\n    if (GetArena(message) == NULL) {\n      switch (field->cpp_type()) {\n        case FieldDescriptor::CPPTYPE_STRING: {\n          switch (field->options().ctype()) {\n            default:  // TODO(kenton):  Support other string reps.\n            case FieldOptions::STRING: {\n              const string* default_ptr =\n                  &DefaultRaw<ArenaStringPtr>(field).Get(NULL);\n              MutableField<ArenaStringPtr>(message, field)->\n                  Destroy(default_ptr, GetArena(message));\n              break;\n            }\n          }\n          break;\n        }\n\n        case FieldDescriptor::CPPTYPE_MESSAGE:\n          delete *MutableRaw<Message*>(message, field);\n          break;\n        default:\n          break;\n      }\n    }\n\n    *MutableOneofCase(message, oneof_descriptor) = 0;\n  }\n}\n\n// Template implementations of basic accessors.  Inline because each\n// template instance is only called from one location.  These are\n// used for all types except messages.\ntemplate <typename Type>\ninline const Type& GeneratedMessageReflection::GetField(\n    const Message& message, const FieldDescriptor* field) const {\n  return GetRaw<Type>(message, field);\n}\n\ntemplate <typename Type>\ninline void GeneratedMessageReflection::SetField(\n    Message* message, const FieldDescriptor* field, const Type& value) const {\n  if (field->containing_oneof() && !HasOneofField(*message, field)) {\n    ClearOneof(message, field->containing_oneof());\n  }\n  *MutableRaw<Type>(message, field) = value;\n  field->containing_oneof() ?\n      SetOneofCase(message, field) : SetBit(message, field);\n}\n\ntemplate <typename Type>\ninline Type* GeneratedMessageReflection::MutableField(\n    Message* message, const FieldDescriptor* field) const {\n  field->containing_oneof() ?\n      SetOneofCase(message, field) : SetBit(message, field);\n  return MutableRaw<Type>(message, field);\n}\n\ntemplate <typename Type>\ninline const Type& GeneratedMessageReflection::GetRepeatedField(\n    const Message& message, const FieldDescriptor* field, int index) const {\n  return GetRaw<RepeatedField<Type> >(message, field).Get(index);\n}\n\ntemplate <typename Type>\ninline const Type& GeneratedMessageReflection::GetRepeatedPtrField(\n    const Message& message, const FieldDescriptor* field, int index) const {\n  return GetRaw<RepeatedPtrField<Type> >(message, field).Get(index);\n}\n\ntemplate <typename Type>\ninline void GeneratedMessageReflection::SetRepeatedField(\n    Message* message, const FieldDescriptor* field,\n    int index, Type value) const {\n  MutableRaw<RepeatedField<Type> >(message, field)->Set(index, value);\n}\n\ntemplate <typename Type>\ninline Type* GeneratedMessageReflection::MutableRepeatedField(\n    Message* message, const FieldDescriptor* field, int index) const {\n  RepeatedPtrField<Type>* repeated =\n    MutableRaw<RepeatedPtrField<Type> >(message, field);\n  return repeated->Mutable(index);\n}\n\ntemplate <typename Type>\ninline void GeneratedMessageReflection::AddField(\n    Message* message, const FieldDescriptor* field, const Type& value) const {\n  MutableRaw<RepeatedField<Type> >(message, field)->Add(value);\n}\n\ntemplate <typename Type>\ninline Type* GeneratedMessageReflection::AddField(\n    Message* message, const FieldDescriptor* field) const {\n  RepeatedPtrField<Type>* repeated =\n    MutableRaw<RepeatedPtrField<Type> >(message, field);\n  return repeated->Add();\n}\n\nMessageFactory* GeneratedMessageReflection::GetMessageFactory() const {\n  return message_factory_;\n}\n\nvoid* GeneratedMessageReflection::RepeatedFieldData(\n    Message* message, const FieldDescriptor* field,\n    FieldDescriptor::CppType cpp_type,\n    const Descriptor* message_type) const {\n  GOOGLE_CHECK(field->is_repeated());\n  GOOGLE_CHECK(field->cpp_type() == cpp_type ||\n        (field->cpp_type() == FieldDescriptor::CPPTYPE_ENUM &&\n         cpp_type == FieldDescriptor::CPPTYPE_INT32))\n      << \"The type parameter T in RepeatedFieldRef<T> API doesn't match \"\n      << \"the actual field type (for enums T should be the generated enum \"\n      << \"type or int32).\";\n  if (message_type != NULL) {\n    GOOGLE_CHECK_EQ(message_type, field->message_type());\n  }\n  if (field->is_extension()) {\n    return MutableExtensionSet(message)->MutableRawRepeatedField(\n        field->number(), field->type(), field->is_packed(), field);\n  } else {\n    return reinterpret_cast<uint8*>(message) + offsets_[field->index()];\n  }\n}\n\nMapFieldBase* GeneratedMessageReflection::MapData(\n    Message* message, const FieldDescriptor* field) const {\n  USAGE_CHECK(IsMapFieldInApi(field),\n              \"GetMapData\",\n              \"Field is not a map field.\");\n  return MutableRaw<MapFieldBase>(message, field);\n}\n\nGeneratedMessageReflection*\nGeneratedMessageReflection::NewGeneratedMessageReflection(\n    const Descriptor* descriptor,\n    const Message* default_instance,\n    const int offsets[],\n    int has_bits_offset,\n    int unknown_fields_offset,\n    int extensions_offset,\n    const void* default_oneof_instance,\n    int oneof_case_offset,\n    int object_size,\n    int arena_offset,\n    int is_default_instance_offset) {\n  return new GeneratedMessageReflection(descriptor,\n                                        default_instance,\n                                        offsets,\n                                        has_bits_offset,\n                                        unknown_fields_offset,\n                                        extensions_offset,\n                                        default_oneof_instance,\n                                        oneof_case_offset,\n                                        DescriptorPool::generated_pool(),\n                                        MessageFactory::generated_factory(),\n                                        object_size,\n                                        arena_offset,\n                                        is_default_instance_offset);\n}\n\nGeneratedMessageReflection*\nGeneratedMessageReflection::NewGeneratedMessageReflection(\n    const Descriptor* descriptor,\n    const Message* default_instance,\n    const int offsets[],\n    int has_bits_offset,\n    int unknown_fields_offset,\n    int extensions_offset,\n    int object_size,\n    int arena_offset,\n    int is_default_instance_offset) {\n  return new GeneratedMessageReflection(descriptor,\n                                        default_instance,\n                                        offsets,\n                                        has_bits_offset,\n                                        unknown_fields_offset,\n                                        extensions_offset,\n                                        DescriptorPool::generated_pool(),\n                                        MessageFactory::generated_factory(),\n                                        object_size,\n                                        arena_offset,\n                                        is_default_instance_offset);\n}\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/generated_message_reflection.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This header is logically internal, but is made public because it is used\n// from protocol-compiler-generated code, which may reside in other components.\n\n#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_REFLECTION_H__\n#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_REFLECTION_H__\n\n#include <string>\n#include <vector>\n#include <google/protobuf/stubs/casts.h>\n#include <google/protobuf/stubs/common.h>\n// TODO(jasonh): Remove this once the compiler change to directly include this\n// is released to components.\n#include <google/protobuf/generated_enum_reflection.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/metadata.h>\n#include <google/protobuf/unknown_field_set.h>\n\n\nnamespace google {\nnamespace upb {\nnamespace google_opensource {\nclass GMR_Handlers;\n}  // namespace google_opensource\n}  // namespace upb\n\nnamespace protobuf {\nclass DescriptorPool;\nclass MapKey;\nclass MapValueRef;\n}\n\nnamespace protobuf {\nnamespace internal {\nclass DefaultEmptyOneof;\n\n// Defined in this file.\nclass GeneratedMessageReflection;\n\n// Defined in other files.\nclass ExtensionSet;             // extension_set.h\n\n// THIS CLASS IS NOT INTENDED FOR DIRECT USE.  It is intended for use\n// by generated code.  This class is just a big hack that reduces code\n// size.\n//\n// A GeneratedMessageReflection is an implementation of Reflection\n// which expects all fields to be backed by simple variables located in\n// memory.  The locations are given using a base pointer and a set of\n// offsets.\n//\n// It is required that the user represents fields of each type in a standard\n// way, so that GeneratedMessageReflection can cast the void* pointer to\n// the appropriate type.  For primitive fields and string fields, each field\n// should be represented using the obvious C++ primitive type.  Enums and\n// Messages are different:\n//  - Singular Message fields are stored as a pointer to a Message.  These\n//    should start out NULL, except for in the default instance where they\n//    should start out pointing to other default instances.\n//  - Enum fields are stored as an int.  This int must always contain\n//    a valid value, such that EnumDescriptor::FindValueByNumber() would\n//    not return NULL.\n//  - Repeated fields are stored as RepeatedFields or RepeatedPtrFields\n//    of whatever type the individual field would be.  Strings and\n//    Messages use RepeatedPtrFields while everything else uses\n//    RepeatedFields.\nclass LIBPROTOBUF_EXPORT GeneratedMessageReflection : public Reflection {\n public:\n  // Constructs a GeneratedMessageReflection.\n  // Parameters:\n  //   descriptor:    The descriptor for the message type being implemented.\n  //   default_instance:  The default instance of the message.  This is only\n  //                  used to obtain pointers to default instances of embedded\n  //                  messages, which GetMessage() will return if the particular\n  //                  sub-message has not been initialized yet.  (Thus, all\n  //                  embedded message fields *must* have non-NULL pointers\n  //                  in the default instance.)\n  //   offsets:       An array of ints giving the byte offsets, relative to\n  //                  the start of the message object, of each field.  These can\n  //                  be computed at compile time using the\n  //                  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET() macro, defined\n  //                  below.\n  //   has_bits_offset:  Offset in the message of an array of uint32s of size\n  //                  descriptor->field_count()/32, rounded up.  This is a\n  //                  bitfield where each bit indicates whether or not the\n  //                  corresponding field of the message has been initialized.\n  //                  The bit for field index i is obtained by the expression:\n  //                    has_bits[i / 32] & (1 << (i % 32))\n  //   unknown_fields_offset:  Offset in the message of the UnknownFieldSet for\n  //                  the message.\n  //   extensions_offset:  Offset in the message of the ExtensionSet for the\n  //                  message, or -1 if the message type has no extension\n  //                  ranges.\n  //   pool:          DescriptorPool to search for extension definitions.  Only\n  //                  used by FindKnownExtensionByName() and\n  //                  FindKnownExtensionByNumber().\n  //   factory:       MessageFactory to use to construct extension messages.\n  //   object_size:   The size of a message object of this type, as measured\n  //                  by sizeof().\n  GeneratedMessageReflection(const Descriptor* descriptor,\n                             const Message* default_instance,\n                             const int offsets[],\n                             int has_bits_offset,\n                             int unknown_fields_offset,\n                             int extensions_offset,\n                             const DescriptorPool* pool,\n                             MessageFactory* factory,\n                             int object_size,\n                             int arena_offset,\n                             int is_default_instance_offset = -1);\n\n  // Similar with the construction above. Call this construction if the\n  // message has oneof definition.\n  // Parameters:\n  //   offsets:       An array of ints giving the byte offsets.\n  //                  For each oneof field, the offset is relative to the\n  //                  default_oneof_instance. These can be computed at compile\n  //                  time using the\n  //                  PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET() macro.\n  //                  For each none oneof field, the offset is related to\n  //                  the start of the message object.  These can be computed\n  //                  at compile time using the\n  //                  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET() macro.\n  //                  Besides offsets for all fields, this array also contains\n  //                  offsets for oneof unions. The offset of the i-th oneof\n  //                  union is offsets[descriptor->field_count() + i].\n  //   default_oneof_instance: The default instance of the oneofs. It is a\n  //                  struct holding the default value of all oneof fields\n  //                  for this message. It is only used to obtain pointers\n  //                  to default instances of oneof fields, which Get\n  //                  methods will return if the field is not set.\n  //   oneof_case_offset:  Offset in the message of an array of uint32s of\n  //                  size descriptor->oneof_decl_count().  Each uint32\n  //                  indicates what field is set for each oneof.\n  //   other parameters are the same with the construction above.\n  GeneratedMessageReflection(const Descriptor* descriptor,\n                             const Message* default_instance,\n                             const int offsets[],\n                             int has_bits_offset,\n                             int unknown_fields_offset,\n                             int extensions_offset,\n                             const void* default_oneof_instance,\n                             int oneof_case_offset,\n                             const DescriptorPool* pool,\n                             MessageFactory* factory,\n                             int object_size,\n                             int arena_offset,\n                             int is_default_instance_offset = -1);\n  ~GeneratedMessageReflection();\n\n  // Shorter-to-call helpers for the above two constructions that work if the\n  // pool and factory are the usual, namely, DescriptorPool::generated_pool()\n  // and MessageFactory::generated_factory().\n\n  static GeneratedMessageReflection* NewGeneratedMessageReflection(\n      const Descriptor* descriptor,\n      const Message* default_instance,\n      const int offsets[],\n      int has_bits_offset,\n      int unknown_fields_offset,\n      int extensions_offset,\n      const void* default_oneof_instance,\n      int oneof_case_offset,\n      int object_size,\n      int arena_offset,\n      int is_default_instance_offset = -1);\n\n  static GeneratedMessageReflection* NewGeneratedMessageReflection(\n      const Descriptor* descriptor,\n      const Message* default_instance,\n      const int offsets[],\n      int has_bits_offset,\n      int unknown_fields_offset,\n      int extensions_offset,\n      int object_size,\n      int arena_offset,\n      int is_default_instance_offset = -1);\n\n  // implements Reflection -------------------------------------------\n\n  const UnknownFieldSet& GetUnknownFields(const Message& message) const;\n  UnknownFieldSet* MutableUnknownFields(Message* message) const;\n\n  int SpaceUsed(const Message& message) const;\n\n  bool HasField(const Message& message, const FieldDescriptor* field) const;\n  int FieldSize(const Message& message, const FieldDescriptor* field) const;\n  void ClearField(Message* message, const FieldDescriptor* field) const;\n  bool HasOneof(const Message& message,\n                const OneofDescriptor* oneof_descriptor) const;\n  void ClearOneof(Message* message, const OneofDescriptor* field) const;\n  void RemoveLast(Message* message, const FieldDescriptor* field) const;\n  Message* ReleaseLast(Message* message, const FieldDescriptor* field) const;\n  void Swap(Message* message1, Message* message2) const;\n  void SwapFields(Message* message1, Message* message2,\n                  const vector<const FieldDescriptor*>& fields) const;\n  void SwapElements(Message* message, const FieldDescriptor* field,\n                    int index1, int index2) const;\n  void ListFields(const Message& message,\n                  vector<const FieldDescriptor*>* output) const;\n\n  int32  GetInt32 (const Message& message,\n                   const FieldDescriptor* field) const;\n  int64  GetInt64 (const Message& message,\n                   const FieldDescriptor* field) const;\n  uint32 GetUInt32(const Message& message,\n                   const FieldDescriptor* field) const;\n  uint64 GetUInt64(const Message& message,\n                   const FieldDescriptor* field) const;\n  float  GetFloat (const Message& message,\n                   const FieldDescriptor* field) const;\n  double GetDouble(const Message& message,\n                   const FieldDescriptor* field) const;\n  bool   GetBool  (const Message& message,\n                   const FieldDescriptor* field) const;\n  string GetString(const Message& message,\n                   const FieldDescriptor* field) const;\n  const string& GetStringReference(const Message& message,\n                                   const FieldDescriptor* field,\n                                   string* scratch) const;\n  const EnumValueDescriptor* GetEnum(const Message& message,\n                                     const FieldDescriptor* field) const;\n  int GetEnumValue(const Message& message,\n                   const FieldDescriptor* field) const;\n  const Message& GetMessage(const Message& message,\n                            const FieldDescriptor* field,\n                            MessageFactory* factory = NULL) const;\n\n  const FieldDescriptor* GetOneofFieldDescriptor(\n      const Message& message,\n      const OneofDescriptor* oneof_descriptor) const;\n\n private:\n  bool ContainsMapKey(const Message& message,\n                      const FieldDescriptor* field,\n                      const MapKey& key) const;\n  bool InsertOrLookupMapValue(Message* message,\n                              const FieldDescriptor* field,\n                              const MapKey& key,\n                              MapValueRef* val) const;\n  bool DeleteMapValue(Message* message,\n                      const FieldDescriptor* field,\n                      const MapKey& key) const;\n  MapIterator MapBegin(\n      Message* message,\n      const FieldDescriptor* field) const;\n  MapIterator MapEnd(\n      Message* message,\n      const FieldDescriptor* field) const;\n  int MapSize(const Message& message, const FieldDescriptor* field) const;\n\n public:\n  void SetInt32 (Message* message,\n                 const FieldDescriptor* field, int32  value) const;\n  void SetInt64 (Message* message,\n                 const FieldDescriptor* field, int64  value) const;\n  void SetUInt32(Message* message,\n                 const FieldDescriptor* field, uint32 value) const;\n  void SetUInt64(Message* message,\n                 const FieldDescriptor* field, uint64 value) const;\n  void SetFloat (Message* message,\n                 const FieldDescriptor* field, float  value) const;\n  void SetDouble(Message* message,\n                 const FieldDescriptor* field, double value) const;\n  void SetBool  (Message* message,\n                 const FieldDescriptor* field, bool   value) const;\n  void SetString(Message* message,\n                 const FieldDescriptor* field,\n                 const string& value) const;\n  void SetEnum  (Message* message, const FieldDescriptor* field,\n                 const EnumValueDescriptor* value) const;\n  void SetEnumValue(Message* message, const FieldDescriptor* field,\n                    int value) const;\n  Message* MutableMessage(Message* message, const FieldDescriptor* field,\n                          MessageFactory* factory = NULL) const;\n  void SetAllocatedMessage(Message* message,\n                           Message* sub_message,\n                           const FieldDescriptor* field) const;\n  Message* ReleaseMessage(Message* message, const FieldDescriptor* field,\n                          MessageFactory* factory = NULL) const;\n\n  int32  GetRepeatedInt32 (const Message& message,\n                           const FieldDescriptor* field, int index) const;\n  int64  GetRepeatedInt64 (const Message& message,\n                           const FieldDescriptor* field, int index) const;\n  uint32 GetRepeatedUInt32(const Message& message,\n                           const FieldDescriptor* field, int index) const;\n  uint64 GetRepeatedUInt64(const Message& message,\n                           const FieldDescriptor* field, int index) const;\n  float  GetRepeatedFloat (const Message& message,\n                           const FieldDescriptor* field, int index) const;\n  double GetRepeatedDouble(const Message& message,\n                           const FieldDescriptor* field, int index) const;\n  bool   GetRepeatedBool  (const Message& message,\n                           const FieldDescriptor* field, int index) const;\n  string GetRepeatedString(const Message& message,\n                           const FieldDescriptor* field, int index) const;\n  const string& GetRepeatedStringReference(const Message& message,\n                                           const FieldDescriptor* field,\n                                           int index, string* scratch) const;\n  const EnumValueDescriptor* GetRepeatedEnum(const Message& message,\n                                             const FieldDescriptor* field,\n                                             int index) const;\n  int GetRepeatedEnumValue(const Message& message,\n                           const FieldDescriptor* field,\n                           int index) const;\n  const Message& GetRepeatedMessage(const Message& message,\n                                    const FieldDescriptor* field,\n                                    int index) const;\n\n  // Set the value of a field.\n  void SetRepeatedInt32 (Message* message,\n                         const FieldDescriptor* field, int index, int32  value) const;\n  void SetRepeatedInt64 (Message* message,\n                         const FieldDescriptor* field, int index, int64  value) const;\n  void SetRepeatedUInt32(Message* message,\n                         const FieldDescriptor* field, int index, uint32 value) const;\n  void SetRepeatedUInt64(Message* message,\n                         const FieldDescriptor* field, int index, uint64 value) const;\n  void SetRepeatedFloat (Message* message,\n                         const FieldDescriptor* field, int index, float  value) const;\n  void SetRepeatedDouble(Message* message,\n                         const FieldDescriptor* field, int index, double value) const;\n  void SetRepeatedBool  (Message* message,\n                         const FieldDescriptor* field, int index, bool   value) const;\n  void SetRepeatedString(Message* message,\n                         const FieldDescriptor* field, int index,\n                         const string& value) const;\n  void SetRepeatedEnum(Message* message, const FieldDescriptor* field,\n                       int index, const EnumValueDescriptor* value) const;\n  void SetRepeatedEnumValue(Message* message, const FieldDescriptor* field,\n                            int index, int value) const;\n  // Get a mutable pointer to a field with a message type.\n  Message* MutableRepeatedMessage(Message* message,\n                                  const FieldDescriptor* field,\n                                  int index) const;\n\n  void AddInt32 (Message* message,\n                 const FieldDescriptor* field, int32  value) const;\n  void AddInt64 (Message* message,\n                 const FieldDescriptor* field, int64  value) const;\n  void AddUInt32(Message* message,\n                 const FieldDescriptor* field, uint32 value) const;\n  void AddUInt64(Message* message,\n                 const FieldDescriptor* field, uint64 value) const;\n  void AddFloat (Message* message,\n                 const FieldDescriptor* field, float  value) const;\n  void AddDouble(Message* message,\n                 const FieldDescriptor* field, double value) const;\n  void AddBool  (Message* message,\n                 const FieldDescriptor* field, bool   value) const;\n  void AddString(Message* message,\n                 const FieldDescriptor* field, const string& value) const;\n  void AddEnum(Message* message,\n               const FieldDescriptor* field,\n               const EnumValueDescriptor* value) const;\n  void AddEnumValue(Message* message,\n                    const FieldDescriptor* field,\n                    int value) const;\n  Message* AddMessage(Message* message, const FieldDescriptor* field,\n                      MessageFactory* factory = NULL) const;\n  void AddAllocatedMessage(\n      Message* message, const FieldDescriptor* field,\n      Message* new_entry) const;\n\n  const FieldDescriptor* FindKnownExtensionByName(const string& name) const;\n  const FieldDescriptor* FindKnownExtensionByNumber(int number) const;\n\n  bool SupportsUnknownEnumValues() const;\n\n  // This value for arena_offset_ indicates that there is no arena pointer in\n  // this message (e.g., old generated code).\n  static const int kNoArenaPointer = -1;\n\n  // This value for unknown_field_offset_ indicates that there is no\n  // UnknownFieldSet in this message, and that instead, we are using the\n  // Zero-Overhead Arena Pointer trick. When this is the case, arena_offset_\n  // actually indexes to an InternalMetadataWithArena instance, which can return\n  // either an arena pointer or an UnknownFieldSet or both. It is never the case\n  // that unknown_field_offset_ == kUnknownFieldSetInMetadata && arena_offset_\n  // == kNoArenaPointer.\n  static const int kUnknownFieldSetInMetadata = -1;\n\n protected:\n  void* MutableRawRepeatedField(\n      Message* message, const FieldDescriptor* field, FieldDescriptor::CppType,\n      int ctype, const Descriptor* desc) const;\n\n  const void* GetRawRepeatedField(\n      const Message& message, const FieldDescriptor* field,\n      FieldDescriptor::CppType, int ctype,\n      const Descriptor* desc) const;\n\n  virtual MessageFactory* GetMessageFactory() const;\n\n  virtual void* RepeatedFieldData(\n      Message* message, const FieldDescriptor* field,\n      FieldDescriptor::CppType cpp_type,\n      const Descriptor* message_type) const;\n\n private:\n  friend class GeneratedMessage;\n\n  // To parse directly into a proto2 generated class, the class GMR_Handlers\n  // needs access to member offsets and hasbits.\n  friend class upb::google_opensource::GMR_Handlers;\n\n  const Descriptor* descriptor_;\n  const Message* default_instance_;\n  const void* default_oneof_instance_;\n  const int* offsets_;\n\n  int has_bits_offset_;\n  int oneof_case_offset_;\n  int unknown_fields_offset_;\n  int extensions_offset_;\n  int arena_offset_;\n  int is_default_instance_offset_;\n  int object_size_;\n\n  static const int kHasNoDefaultInstanceField = -1;\n\n  const DescriptorPool* descriptor_pool_;\n  MessageFactory* message_factory_;\n\n  template <typename Type>\n  inline const Type& GetRaw(const Message& message,\n                            const FieldDescriptor* field) const;\n  template <typename Type>\n  inline Type* MutableRaw(Message* message,\n                          const FieldDescriptor* field) const;\n  template <typename Type>\n  inline const Type& DefaultRaw(const FieldDescriptor* field) const;\n  template <typename Type>\n  inline const Type& DefaultOneofRaw(const FieldDescriptor* field) const;\n\n  inline const uint32* GetHasBits(const Message& message) const;\n  inline uint32* MutableHasBits(Message* message) const;\n  inline uint32 GetOneofCase(\n      const Message& message,\n      const OneofDescriptor* oneof_descriptor) const;\n  inline uint32* MutableOneofCase(\n      Message* message,\n      const OneofDescriptor* oneof_descriptor) const;\n  inline const ExtensionSet& GetExtensionSet(const Message& message) const;\n  inline ExtensionSet* MutableExtensionSet(Message* message) const;\n  inline Arena* GetArena(Message* message) const;\n  inline const internal::InternalMetadataWithArena&\n      GetInternalMetadataWithArena(const Message& message) const;\n  inline internal::InternalMetadataWithArena*\n      MutableInternalMetadataWithArena(Message* message) const;\n\n  inline bool GetIsDefaultInstance(const Message& message) const;\n\n  inline bool HasBit(const Message& message,\n                     const FieldDescriptor* field) const;\n  inline void SetBit(Message* message,\n                     const FieldDescriptor* field) const;\n  inline void ClearBit(Message* message,\n                       const FieldDescriptor* field) const;\n  inline void SwapBit(Message* message1,\n                      Message* message2,\n                      const FieldDescriptor* field) const;\n\n  // This function only swaps the field. Should swap corresponding has_bit\n  // before or after using this function.\n  void SwapField(Message* message1,\n                 Message* message2,\n                 const FieldDescriptor* field) const;\n\n  void SwapOneofField(Message* message1,\n                      Message* message2,\n                      const OneofDescriptor* oneof_descriptor) const;\n\n  inline bool HasOneofField(const Message& message,\n                            const FieldDescriptor* field) const;\n  inline void SetOneofCase(Message* message,\n                           const FieldDescriptor* field) const;\n  inline void ClearOneofField(Message* message,\n                              const FieldDescriptor* field) const;\n\n  template <typename Type>\n  inline const Type& GetField(const Message& message,\n                              const FieldDescriptor* field) const;\n  template <typename Type>\n  inline void SetField(Message* message,\n                       const FieldDescriptor* field, const Type& value) const;\n  template <typename Type>\n  inline Type* MutableField(Message* message,\n                            const FieldDescriptor* field) const;\n  template <typename Type>\n  inline const Type& GetRepeatedField(const Message& message,\n                                      const FieldDescriptor* field,\n                                      int index) const;\n  template <typename Type>\n  inline const Type& GetRepeatedPtrField(const Message& message,\n                                         const FieldDescriptor* field,\n                                         int index) const;\n  template <typename Type>\n  inline void SetRepeatedField(Message* message,\n                               const FieldDescriptor* field, int index,\n                               Type value) const;\n  template <typename Type>\n  inline Type* MutableRepeatedField(Message* message,\n                                    const FieldDescriptor* field,\n                                    int index) const;\n  template <typename Type>\n  inline void AddField(Message* message,\n                       const FieldDescriptor* field, const Type& value) const;\n  template <typename Type>\n  inline Type* AddField(Message* message,\n                        const FieldDescriptor* field) const;\n\n  int GetExtensionNumberOrDie(const Descriptor* type) const;\n\n  // Internal versions of EnumValue API perform no checking. Called after checks\n  // by public methods.\n  void SetEnumValueInternal(Message* message,\n                            const FieldDescriptor* field,\n                            int value) const;\n  void SetRepeatedEnumValueInternal(Message* message,\n                                    const FieldDescriptor* field,\n                                    int index,\n                                    int value) const;\n  void AddEnumValueInternal(Message* message,\n                            const FieldDescriptor* field,\n                            int value) const;\n\n\n  Message* UnsafeArenaReleaseMessage(Message* message,\n                                     const FieldDescriptor* field,\n                                     MessageFactory* factory = NULL) const;\n\n  void UnsafeArenaSetAllocatedMessage(Message* message,\n                                      Message* sub_message,\n                                      const FieldDescriptor* field) const;\n\n  internal::MapFieldBase* MapData(\n      Message* message, const FieldDescriptor* field) const;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GeneratedMessageReflection);\n};\n\n// Returns the offset of the given field within the given aggregate type.\n// This is equivalent to the ANSI C offsetof() macro.  However, according\n// to the C++ standard, offsetof() only works on POD types, and GCC\n// enforces this requirement with a warning.  In practice, this rule is\n// unnecessarily strict; there is probably no compiler or platform on\n// which the offsets of the direct fields of a class are non-constant.\n// Fields inherited from superclasses *can* have non-constant offsets,\n// but that's not what this macro will be used for.\n#if defined(__clang__)\n// For Clang we use __builtin_offsetof() and suppress the warning,\n// to avoid Control Flow Integrity and UBSan vptr sanitizers from\n// crashing while trying to validate the invalid reinterpet_casts.\n#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TYPE, FIELD)    \\\n  _Pragma(\"clang diagnostic push\")                            \\\n  _Pragma(\"clang diagnostic ignored \\\"-Winvalid-offsetof\\\"\")  \\\n  __builtin_offsetof(TYPE, FIELD)                             \\\n  _Pragma(\"clang diagnostic pop\")\n#else\n// Note that we calculate relative to the pointer value 16 here since if we\n// just use zero, GCC complains about dereferencing a NULL pointer.  We\n// choose 16 rather than some other number just in case the compiler would\n// be confused by an unaligned pointer.\n#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(TYPE, FIELD)    \\\n  static_cast<int>(                                           \\\n      reinterpret_cast<const char*>(                          \\\n          &reinterpret_cast<const TYPE*>(16)->FIELD) -        \\\n      reinterpret_cast<const char*>(16))\n#endif\n\n#define PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(ONEOF, FIELD)     \\\n  static_cast<int>(                                                   \\\n      reinterpret_cast<const char*>(&(ONEOF->FIELD))                  \\\n      - reinterpret_cast<const char*>(ONEOF))\n\n// There are some places in proto2 where dynamic_cast would be useful as an\n// optimization.  For example, take Message::MergeFrom(const Message& other).\n// For a given generated message FooMessage, we generate these two methods:\n//   void MergeFrom(const FooMessage& other);\n//   void MergeFrom(const Message& other);\n// The former method can be implemented directly in terms of FooMessage's\n// inline accessors, but the latter method must work with the reflection\n// interface.  However, if the parameter to the latter method is actually of\n// type FooMessage, then we'd like to be able to just call the other method\n// as an optimization.  So, we use dynamic_cast to check this.\n//\n// That said, dynamic_cast requires RTTI, which many people like to disable\n// for performance and code size reasons.  When RTTI is not available, we\n// still need to produce correct results.  So, in this case we have to fall\n// back to using reflection, which is what we would have done anyway if the\n// objects were not of the exact same class.\n//\n// dynamic_cast_if_available() implements this logic.  If RTTI is\n// enabled, it does a dynamic_cast.  If RTTI is disabled, it just returns\n// NULL.\n//\n// If you need to compile without RTTI, simply #define GOOGLE_PROTOBUF_NO_RTTI.\n// On MSVC, this should be detected automatically.\ntemplate<typename To, typename From>\ninline To dynamic_cast_if_available(From from) {\n#if defined(GOOGLE_PROTOBUF_NO_RTTI) || (defined(_MSC_VER)&&!defined(_CPPRTTI))\n  return NULL;\n#else\n  return dynamic_cast<To>(from);\n#endif\n}\n\n// Tries to downcast this message to a generated message type.\n// Returns NULL if this class is not an instance of T.\n//\n// This is like dynamic_cast_if_available, except it works even when\n// dynamic_cast is not available by using Reflection.  However it only works\n// with Message objects.\n//\n// TODO(haberman): can we remove dynamic_cast_if_available in favor of this?\ntemplate <typename T>\nT* DynamicCastToGenerated(const Message* from) {\n  // Compile-time assert that T is a generated type that has a\n  // default_instance() accessor, but avoid actually calling it.\n  const T&(*get_default_instance)() = &T::default_instance;\n  (void)get_default_instance;\n\n  // Compile-time assert that T is a subclass of google::protobuf::Message.\n  const Message* unused = static_cast<T*>(NULL);\n  (void)unused;\n\n#if defined(GOOGLE_PROTOBUF_NO_RTTI) || \\\n  (defined(_MSC_VER) && !defined(_CPPRTTI))\n  bool ok = &T::default_instance() ==\n            from->GetReflection()->GetMessageFactory()->GetPrototype(\n                from->GetDescriptor());\n  return ok ? down_cast<T*>(from) : NULL;\n#else\n  return dynamic_cast<T*>(from);\n#endif\n}\n\ntemplate <typename T>\nT* DynamicCastToGenerated(Message* from) {\n  const Message* message_const = from;\n  return const_cast<T*>(DynamicCastToGenerated<const T>(message_const));\n}\n\n}  // namespace internal\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_GENERATED_MESSAGE_REFLECTION_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/generated_message_reflection_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// To test GeneratedMessageReflection, we actually let the protocol compiler\n// generate a full protocol message implementation and then test its\n// reflection interface.  This is much easier and more maintainable than\n// trying to create our own Message class for GeneratedMessageReflection\n// to wrap.\n//\n// The tests here closely mirror some of the tests in\n// compiler/cpp/unittest, except using the reflection interface\n// rather than generated accessors.\n\n#include <google/protobuf/generated_message_reflection.h>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/test_util.h>\n#include <google/protobuf/unittest.pb.h>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\n\nnamespace {\n\n// Shorthand to get a FieldDescriptor for a field of unittest::TestAllTypes.\nconst FieldDescriptor* F(const string& name) {\n  const FieldDescriptor* result =\n    unittest::TestAllTypes::descriptor()->FindFieldByName(name);\n  GOOGLE_CHECK(result != NULL);\n  return result;\n}\n\nTEST(GeneratedMessageReflectionTest, Defaults) {\n  // Check that all default values are set correctly in the initial message.\n  unittest::TestAllTypes message;\n  TestUtil::ReflectionTester reflection_tester(\n    unittest::TestAllTypes::descriptor());\n\n  reflection_tester.ExpectClearViaReflection(message);\n\n  const Reflection* reflection = message.GetReflection();\n\n  // Messages should return pointers to default instances until first use.\n  // (This is not checked by ExpectClear() since it is not actually true after\n  // the fields have been set and then cleared.)\n  EXPECT_EQ(&unittest::TestAllTypes::OptionalGroup::default_instance(),\n            &reflection->GetMessage(message, F(\"optionalgroup\")));\n  EXPECT_EQ(&unittest::TestAllTypes::NestedMessage::default_instance(),\n            &reflection->GetMessage(message, F(\"optional_nested_message\")));\n  EXPECT_EQ(&unittest::ForeignMessage::default_instance(),\n            &reflection->GetMessage(message, F(\"optional_foreign_message\")));\n  EXPECT_EQ(&unittest_import::ImportMessage::default_instance(),\n            &reflection->GetMessage(message, F(\"optional_import_message\")));\n}\n\nTEST(GeneratedMessageReflectionTest, Accessors) {\n  // Set every field to a unique value then go back and check all those\n  // values.\n  unittest::TestAllTypes message;\n  TestUtil::ReflectionTester reflection_tester(\n    unittest::TestAllTypes::descriptor());\n\n  reflection_tester.SetAllFieldsViaReflection(&message);\n  TestUtil::ExpectAllFieldsSet(message);\n  reflection_tester.ExpectAllFieldsSetViaReflection(message);\n\n  reflection_tester.ModifyRepeatedFieldsViaReflection(&message);\n  TestUtil::ExpectRepeatedFieldsModified(message);\n}\n\nTEST(GeneratedMessageReflectionTest, GetStringReference) {\n  // Test that GetStringReference() returns the underlying string when it is\n  // a normal string field.\n  unittest::TestAllTypes message;\n  message.set_optional_string(\"foo\");\n  message.add_repeated_string(\"foo\");\n\n  const Reflection* reflection = message.GetReflection();\n  string scratch;\n\n  EXPECT_EQ(&message.optional_string(),\n      &reflection->GetStringReference(message, F(\"optional_string\"), &scratch))\n    << \"For simple string fields, GetStringReference() should return a \"\n       \"reference to the underlying string.\";\n  EXPECT_EQ(&message.repeated_string(0),\n      &reflection->GetRepeatedStringReference(message, F(\"repeated_string\"),\n                                              0, &scratch))\n    << \"For simple string fields, GetRepeatedStringReference() should return \"\n       \"a reference to the underlying string.\";\n}\n\n\nTEST(GeneratedMessageReflectionTest, DefaultsAfterClear) {\n  // Check that after setting all fields and then clearing, getting an\n  // embedded message does NOT return the default instance.\n  unittest::TestAllTypes message;\n  TestUtil::ReflectionTester reflection_tester(\n    unittest::TestAllTypes::descriptor());\n\n  TestUtil::SetAllFields(&message);\n  message.Clear();\n\n  const Reflection* reflection = message.GetReflection();\n\n  EXPECT_NE(&unittest::TestAllTypes::OptionalGroup::default_instance(),\n            &reflection->GetMessage(message, F(\"optionalgroup\")));\n  EXPECT_NE(&unittest::TestAllTypes::NestedMessage::default_instance(),\n            &reflection->GetMessage(message, F(\"optional_nested_message\")));\n  EXPECT_NE(&unittest::ForeignMessage::default_instance(),\n            &reflection->GetMessage(message, F(\"optional_foreign_message\")));\n  EXPECT_NE(&unittest_import::ImportMessage::default_instance(),\n            &reflection->GetMessage(message, F(\"optional_import_message\")));\n}\n\n\nTEST(GeneratedMessageReflectionTest, Swap) {\n  unittest::TestAllTypes message1;\n  unittest::TestAllTypes message2;\n\n  TestUtil::SetAllFields(&message1);\n\n  const Reflection* reflection = message1.GetReflection();\n  reflection->Swap(&message1, &message2);\n\n  TestUtil::ExpectClear(message1);\n  TestUtil::ExpectAllFieldsSet(message2);\n}\n\nTEST(GeneratedMessageReflectionTest, SwapWithBothSet) {\n  unittest::TestAllTypes message1;\n  unittest::TestAllTypes message2;\n\n  TestUtil::SetAllFields(&message1);\n  TestUtil::SetAllFields(&message2);\n  TestUtil::ModifyRepeatedFields(&message2);\n\n  const Reflection* reflection = message1.GetReflection();\n  reflection->Swap(&message1, &message2);\n\n  TestUtil::ExpectRepeatedFieldsModified(message1);\n  TestUtil::ExpectAllFieldsSet(message2);\n\n  message1.set_optional_int32(532819);\n\n  reflection->Swap(&message1, &message2);\n\n  EXPECT_EQ(532819, message2.optional_int32());\n}\n\nTEST(GeneratedMessageReflectionTest, SwapExtensions) {\n  unittest::TestAllExtensions message1;\n  unittest::TestAllExtensions message2;\n\n  TestUtil::SetAllExtensions(&message1);\n\n  const Reflection* reflection = message1.GetReflection();\n  reflection->Swap(&message1, &message2);\n\n  TestUtil::ExpectExtensionsClear(message1);\n  TestUtil::ExpectAllExtensionsSet(message2);\n}\n\nTEST(GeneratedMessageReflectionTest, SwapUnknown) {\n  unittest::TestEmptyMessage message1, message2;\n\n  message1.mutable_unknown_fields()->AddVarint(1234, 1);\n\n  EXPECT_EQ(1, message1.unknown_fields().field_count());\n  EXPECT_EQ(0, message2.unknown_fields().field_count());\n  const Reflection* reflection = message1.GetReflection();\n  reflection->Swap(&message1, &message2);\n  EXPECT_EQ(0, message1.unknown_fields().field_count());\n  EXPECT_EQ(1, message2.unknown_fields().field_count());\n}\n\nTEST(GeneratedMessageReflectionTest, SwapFields) {\n  unittest::TestAllTypes message1, message2;\n  message1.set_optional_double(12.3);\n  message1.mutable_repeated_int32()->Add(10);\n  message1.mutable_repeated_int32()->Add(20);\n\n  message2.set_optional_string(\"hello\");\n  message2.mutable_repeated_int64()->Add(30);\n\n  vector<const FieldDescriptor*> fields;\n  const Descriptor* descriptor = message1.GetDescriptor();\n  fields.push_back(descriptor->FindFieldByName(\"optional_double\"));\n  fields.push_back(descriptor->FindFieldByName(\"repeated_int32\"));\n  fields.push_back(descriptor->FindFieldByName(\"optional_string\"));\n  fields.push_back(descriptor->FindFieldByName(\"optional_uint64\"));\n\n  const Reflection* reflection = message1.GetReflection();\n  reflection->SwapFields(&message1, &message2, fields);\n\n  EXPECT_FALSE(message1.has_optional_double());\n  EXPECT_EQ(0, message1.repeated_int32_size());\n  EXPECT_TRUE(message1.has_optional_string());\n  EXPECT_EQ(\"hello\", message1.optional_string());\n  EXPECT_EQ(0, message1.repeated_int64_size());\n  EXPECT_FALSE(message1.has_optional_uint64());\n\n  EXPECT_TRUE(message2.has_optional_double());\n  EXPECT_EQ(12.3, message2.optional_double());\n  EXPECT_EQ(2, message2.repeated_int32_size());\n  EXPECT_EQ(10, message2.repeated_int32(0));\n  EXPECT_EQ(20, message2.repeated_int32(1));\n  EXPECT_FALSE(message2.has_optional_string());\n  EXPECT_EQ(1, message2.repeated_int64_size());\n  EXPECT_FALSE(message2.has_optional_uint64());\n}\n\nTEST(GeneratedMessageReflectionTest, SwapFieldsAll) {\n  unittest::TestAllTypes message1;\n  unittest::TestAllTypes message2;\n\n  TestUtil::SetAllFields(&message2);\n\n  vector<const FieldDescriptor*> fields;\n  const Reflection* reflection = message1.GetReflection();\n  reflection->ListFields(message2, &fields);\n  reflection->SwapFields(&message1, &message2, fields);\n\n  TestUtil::ExpectAllFieldsSet(message1);\n  TestUtil::ExpectClear(message2);\n}\n\nTEST(GeneratedMessageReflectionTest, SwapFieldsAllExtension) {\n  unittest::TestAllExtensions message1;\n  unittest::TestAllExtensions message2;\n\n  TestUtil::SetAllExtensions(&message1);\n\n  vector<const FieldDescriptor*> fields;\n  const Reflection* reflection = message1.GetReflection();\n  reflection->ListFields(message1, &fields);\n  reflection->SwapFields(&message1, &message2, fields);\n\n  TestUtil::ExpectExtensionsClear(message1);\n  TestUtil::ExpectAllExtensionsSet(message2);\n}\n\nTEST(GeneratedMessageReflectionTest, SwapOneof) {\n  unittest::TestOneof2 message1, message2;\n  TestUtil::SetOneof1(&message1);\n\n  const Reflection* reflection = message1.GetReflection();\n  reflection->Swap(&message1, &message2);\n\n  TestUtil::ExpectOneofClear(message1);\n  TestUtil::ExpectOneofSet1(message2);\n}\n\nTEST(GeneratedMessageReflectionTest, SwapOneofBothSet) {\n  unittest::TestOneof2 message1, message2;\n  TestUtil::SetOneof1(&message1);\n  TestUtil::SetOneof2(&message2);\n\n  const Reflection* reflection = message1.GetReflection();\n  reflection->Swap(&message1, &message2);\n\n  TestUtil::ExpectOneofSet2(message1);\n  TestUtil::ExpectOneofSet1(message2);\n}\n\nTEST(GeneratedMessageReflectionTest, SwapFieldsOneof) {\n  unittest::TestOneof2 message1, message2;\n  TestUtil::SetOneof1(&message1);\n\n  vector<const FieldDescriptor*> fields;\n  const Descriptor* descriptor = message1.GetDescriptor();\n  for (int i = 0; i < descriptor->field_count(); i++) {\n    fields.push_back(descriptor->field(i));\n  }\n  const Reflection* reflection = message1.GetReflection();\n  reflection->SwapFields(&message1, &message2, fields);\n\n  TestUtil::ExpectOneofClear(message1);\n  TestUtil::ExpectOneofSet1(message2);\n}\n\nTEST(GeneratedMessageReflectionTest, RemoveLast) {\n  unittest::TestAllTypes message;\n  TestUtil::ReflectionTester reflection_tester(\n    unittest::TestAllTypes::descriptor());\n\n  TestUtil::SetAllFields(&message);\n\n  reflection_tester.RemoveLastRepeatedsViaReflection(&message);\n\n  TestUtil::ExpectLastRepeatedsRemoved(message);\n}\n\nTEST(GeneratedMessageReflectionTest, RemoveLastExtensions) {\n  unittest::TestAllExtensions message;\n  TestUtil::ReflectionTester reflection_tester(\n    unittest::TestAllExtensions::descriptor());\n\n  TestUtil::SetAllExtensions(&message);\n\n  reflection_tester.RemoveLastRepeatedsViaReflection(&message);\n\n  TestUtil::ExpectLastRepeatedExtensionsRemoved(message);\n}\n\nTEST(GeneratedMessageReflectionTest, ReleaseLast) {\n  unittest::TestAllTypes message;\n  const Descriptor* descriptor = message.GetDescriptor();\n  TestUtil::ReflectionTester reflection_tester(descriptor);\n\n  TestUtil::SetAllFields(&message);\n\n  reflection_tester.ReleaseLastRepeatedsViaReflection(&message, false);\n\n  TestUtil::ExpectLastRepeatedsReleased(message);\n\n  // Now test that we actually release the right message.\n  message.Clear();\n  TestUtil::SetAllFields(&message);\n  ASSERT_EQ(2, message.repeated_foreign_message_size());\n  const protobuf_unittest::ForeignMessage* expected =\n      message.mutable_repeated_foreign_message(1);\n  google::protobuf::scoped_ptr<Message> released(message.GetReflection()->ReleaseLast(\n      &message, descriptor->FindFieldByName(\"repeated_foreign_message\")));\n  EXPECT_EQ(expected, released.get());\n}\n\nTEST(GeneratedMessageReflectionTest, ReleaseLastExtensions) {\n  unittest::TestAllExtensions message;\n  const Descriptor* descriptor = message.GetDescriptor();\n  TestUtil::ReflectionTester reflection_tester(descriptor);\n\n  TestUtil::SetAllExtensions(&message);\n\n  reflection_tester.ReleaseLastRepeatedsViaReflection(&message, true);\n\n  TestUtil::ExpectLastRepeatedExtensionsReleased(message);\n\n  // Now test that we actually release the right message.\n  message.Clear();\n  TestUtil::SetAllExtensions(&message);\n  ASSERT_EQ(2, message.ExtensionSize(\n      unittest::repeated_foreign_message_extension));\n  const protobuf_unittest::ForeignMessage* expected = message.MutableExtension(\n      unittest::repeated_foreign_message_extension, 1);\n  google::protobuf::scoped_ptr<Message> released(message.GetReflection()->ReleaseLast(\n      &message, descriptor->file()->FindExtensionByName(\n                    \"repeated_foreign_message_extension\")));\n  EXPECT_EQ(expected, released.get());\n\n}\n\nTEST(GeneratedMessageReflectionTest, SwapRepeatedElements) {\n  unittest::TestAllTypes message;\n  TestUtil::ReflectionTester reflection_tester(\n    unittest::TestAllTypes::descriptor());\n\n  TestUtil::SetAllFields(&message);\n\n  // Swap and test that fields are all swapped.\n  reflection_tester.SwapRepeatedsViaReflection(&message);\n  TestUtil::ExpectRepeatedsSwapped(message);\n\n  // Swap back and test that fields are all back to original values.\n  reflection_tester.SwapRepeatedsViaReflection(&message);\n  TestUtil::ExpectAllFieldsSet(message);\n}\n\nTEST(GeneratedMessageReflectionTest, SwapRepeatedElementsExtension) {\n  unittest::TestAllExtensions message;\n  TestUtil::ReflectionTester reflection_tester(\n    unittest::TestAllExtensions::descriptor());\n\n  TestUtil::SetAllExtensions(&message);\n\n  // Swap and test that fields are all swapped.\n  reflection_tester.SwapRepeatedsViaReflection(&message);\n  TestUtil::ExpectRepeatedExtensionsSwapped(message);\n\n  // Swap back and test that fields are all back to original values.\n  reflection_tester.SwapRepeatedsViaReflection(&message);\n  TestUtil::ExpectAllExtensionsSet(message);\n}\n\nTEST(GeneratedMessageReflectionTest, Extensions) {\n  // Set every extension to a unique value then go back and check all those\n  // values.\n  unittest::TestAllExtensions message;\n  TestUtil::ReflectionTester reflection_tester(\n    unittest::TestAllExtensions::descriptor());\n\n  reflection_tester.SetAllFieldsViaReflection(&message);\n  TestUtil::ExpectAllExtensionsSet(message);\n  reflection_tester.ExpectAllFieldsSetViaReflection(message);\n\n  reflection_tester.ModifyRepeatedFieldsViaReflection(&message);\n  TestUtil::ExpectRepeatedExtensionsModified(message);\n}\n\nTEST(GeneratedMessageReflectionTest, FindExtensionTypeByNumber) {\n  const Reflection* reflection =\n    unittest::TestAllExtensions::default_instance().GetReflection();\n\n  const FieldDescriptor* extension1 =\n    unittest::TestAllExtensions::descriptor()->file()->FindExtensionByName(\n      \"optional_int32_extension\");\n  const FieldDescriptor* extension2 =\n    unittest::TestAllExtensions::descriptor()->file()->FindExtensionByName(\n      \"repeated_string_extension\");\n\n  EXPECT_EQ(extension1,\n            reflection->FindKnownExtensionByNumber(extension1->number()));\n  EXPECT_EQ(extension2,\n            reflection->FindKnownExtensionByNumber(extension2->number()));\n\n  // Non-existent extension.\n  EXPECT_TRUE(reflection->FindKnownExtensionByNumber(62341) == NULL);\n\n  // Extensions of TestAllExtensions should not show up as extensions of\n  // other types.\n  EXPECT_TRUE(unittest::TestAllTypes::default_instance().GetReflection()->\n              FindKnownExtensionByNumber(extension1->number()) == NULL);\n}\n\nTEST(GeneratedMessageReflectionTest, FindKnownExtensionByName) {\n  const Reflection* reflection =\n    unittest::TestAllExtensions::default_instance().GetReflection();\n\n  const FieldDescriptor* extension1 =\n    unittest::TestAllExtensions::descriptor()->file()->FindExtensionByName(\n      \"optional_int32_extension\");\n  const FieldDescriptor* extension2 =\n    unittest::TestAllExtensions::descriptor()->file()->FindExtensionByName(\n      \"repeated_string_extension\");\n\n  EXPECT_EQ(extension1,\n            reflection->FindKnownExtensionByName(extension1->full_name()));\n  EXPECT_EQ(extension2,\n            reflection->FindKnownExtensionByName(extension2->full_name()));\n\n  // Non-existent extension.\n  EXPECT_TRUE(reflection->FindKnownExtensionByName(\"no_such_ext\") == NULL);\n\n  // Extensions of TestAllExtensions should not show up as extensions of\n  // other types.\n  EXPECT_TRUE(unittest::TestAllTypes::default_instance().GetReflection()->\n              FindKnownExtensionByName(extension1->full_name()) == NULL);\n}\n\nTEST(GeneratedMessageReflectionTest, SetAllocatedMessageTest) {\n  unittest::TestAllTypes from_message1;\n  unittest::TestAllTypes from_message2;\n  unittest::TestAllTypes to_message;\n  TestUtil::ReflectionTester reflection_tester(\n    unittest::TestAllTypes::descriptor());\n  reflection_tester.SetAllFieldsViaReflection(&from_message1);\n  reflection_tester.SetAllFieldsViaReflection(&from_message2);\n\n  // Before moving fields, we expect the nested messages to be NULL.\n  reflection_tester.ExpectMessagesReleasedViaReflection(\n      &to_message, TestUtil::ReflectionTester::IS_NULL);\n\n  // After fields are moved we should get non-NULL releases.\n  reflection_tester.SetAllocatedOptionalMessageFieldsToMessageViaReflection(\n      &from_message1, &to_message);\n  reflection_tester.ExpectMessagesReleasedViaReflection(\n      &to_message, TestUtil::ReflectionTester::NOT_NULL);\n\n  // Another move to make sure that we can SetAllocated several times.\n  reflection_tester.SetAllocatedOptionalMessageFieldsToMessageViaReflection(\n      &from_message2, &to_message);\n  reflection_tester.ExpectMessagesReleasedViaReflection(\n      &to_message, TestUtil::ReflectionTester::NOT_NULL);\n\n  // After SetAllocatedOptionalMessageFieldsToNullViaReflection() we expect the\n  // releases to be NULL again.\n  reflection_tester.SetAllocatedOptionalMessageFieldsToNullViaReflection(\n      &to_message);\n  reflection_tester.ExpectMessagesReleasedViaReflection(\n      &to_message, TestUtil::ReflectionTester::IS_NULL);\n}\n\nTEST(GeneratedMessageReflectionTest, SetAllocatedExtensionMessageTest) {\n  unittest::TestAllExtensions from_message1;\n  unittest::TestAllExtensions from_message2;\n  unittest::TestAllExtensions to_message;\n  TestUtil::ReflectionTester reflection_tester(\n    unittest::TestAllExtensions::descriptor());\n  reflection_tester.SetAllFieldsViaReflection(&from_message1);\n  reflection_tester.SetAllFieldsViaReflection(&from_message2);\n\n  // Before moving fields, we expect the nested messages to be NULL.\n  reflection_tester.ExpectMessagesReleasedViaReflection(\n      &to_message, TestUtil::ReflectionTester::IS_NULL);\n\n  // After fields are moved we should get non-NULL releases.\n  reflection_tester.SetAllocatedOptionalMessageFieldsToMessageViaReflection(\n      &from_message1, &to_message);\n  reflection_tester.ExpectMessagesReleasedViaReflection(\n      &to_message, TestUtil::ReflectionTester::NOT_NULL);\n\n  // Another move to make sure that we can SetAllocated several times.\n  reflection_tester.SetAllocatedOptionalMessageFieldsToMessageViaReflection(\n      &from_message2, &to_message);\n  reflection_tester.ExpectMessagesReleasedViaReflection(\n      &to_message, TestUtil::ReflectionTester::NOT_NULL);\n\n  // After SetAllocatedOptionalMessageFieldsToNullViaReflection() we expect the\n  // releases to be NULL again.\n  reflection_tester.SetAllocatedOptionalMessageFieldsToNullViaReflection(\n      &to_message);\n  reflection_tester.ExpectMessagesReleasedViaReflection(\n      &to_message, TestUtil::ReflectionTester::IS_NULL);\n}\n\nTEST(GeneratedMessageReflectionTest, AddRepeatedMessage) {\n  unittest::TestAllTypes message;\n\n  const Reflection* reflection = message.GetReflection();\n  const Reflection* nested_reflection =\n      unittest::TestAllTypes::NestedMessage::default_instance().GetReflection();\n\n  const FieldDescriptor* nested_bb =\n      unittest::TestAllTypes::NestedMessage::descriptor()->FindFieldByName(\n          \"bb\");\n\n  Message* nested = reflection->AddMessage(\n      &message, F(\"repeated_nested_message\"));\n  nested_reflection->SetInt32(nested, nested_bb, 11);\n\n  EXPECT_EQ(11, message.repeated_nested_message(0).bb());\n}\n\nTEST(GeneratedMessageReflectionTest, MutableRepeatedMessage) {\n  unittest::TestAllTypes message;\n\n  const Reflection* reflection = message.GetReflection();\n  const Reflection* nested_reflection =\n      unittest::TestAllTypes::NestedMessage::default_instance().GetReflection();\n\n  const FieldDescriptor* nested_bb =\n      unittest::TestAllTypes::NestedMessage::descriptor()->FindFieldByName(\n          \"bb\");\n\n  message.add_repeated_nested_message()->set_bb(12);\n\n  Message* nested = reflection->MutableRepeatedMessage(\n      &message, F(\"repeated_nested_message\"), 0);\n  EXPECT_EQ(12, nested_reflection->GetInt32(*nested, nested_bb));\n  nested_reflection->SetInt32(nested, nested_bb, 13);\n  EXPECT_EQ(13, message.repeated_nested_message(0).bb());\n}\n\nTEST(GeneratedMessageReflectionTest, AddAllocatedMessage) {\n  unittest::TestAllTypes message;\n\n  const Reflection* reflection = message.GetReflection();\n\n  unittest::TestAllTypes::NestedMessage* nested =\n      new unittest::TestAllTypes::NestedMessage();\n  nested->set_bb(11);\n  reflection->AddAllocatedMessage(&message, F(\"repeated_nested_message\"), nested);\n  EXPECT_EQ(1, message.repeated_nested_message_size());\n  EXPECT_EQ(11, message.repeated_nested_message(0).bb());\n}\n\nTEST(GeneratedMessageReflectionTest, ListFieldsOneOf) {\n  unittest::TestOneof2 message;\n  TestUtil::SetOneof1(&message);\n\n  const Reflection* reflection = message.GetReflection();\n  vector<const FieldDescriptor*> fields;\n  reflection->ListFields(message, &fields);\n  EXPECT_EQ(4, fields.size());\n}\n\nTEST(GeneratedMessageReflectionTest, Oneof) {\n  unittest::TestOneof2 message;\n  const Descriptor* descriptor = message.GetDescriptor();\n  const Reflection* reflection = message.GetReflection();\n\n  // Check default values.\n  EXPECT_EQ(0, reflection->GetInt32(\n      message, descriptor->FindFieldByName(\"foo_int\")));\n  EXPECT_EQ(\"\", reflection->GetString(\n      message, descriptor->FindFieldByName(\"foo_string\")));\n  EXPECT_EQ(\"\", reflection->GetString(\n      message, descriptor->FindFieldByName(\"foo_cord\")));\n  EXPECT_EQ(\"\", reflection->GetString(\n      message, descriptor->FindFieldByName(\"foo_string_piece\")));\n  EXPECT_EQ(\"\", reflection->GetString(\n      message, descriptor->FindFieldByName(\"foo_bytes\")));\n  EXPECT_EQ(unittest::TestOneof2::FOO, reflection->GetEnum(\n      message, descriptor->FindFieldByName(\"foo_enum\"))->number());\n  EXPECT_EQ(&unittest::TestOneof2::NestedMessage::default_instance(),\n            &reflection->GetMessage(\n                message, descriptor->FindFieldByName(\"foo_message\")));\n  EXPECT_EQ(&unittest::TestOneof2::FooGroup::default_instance(),\n            &reflection->GetMessage(\n                message, descriptor->FindFieldByName(\"foogroup\")));\n  EXPECT_NE(&unittest::TestOneof2::FooGroup::default_instance(),\n            &reflection->GetMessage(\n                message, descriptor->FindFieldByName(\"foo_lazy_message\")));\n  EXPECT_EQ(5, reflection->GetInt32(\n      message, descriptor->FindFieldByName(\"bar_int\")));\n  EXPECT_EQ(\"STRING\", reflection->GetString(\n      message, descriptor->FindFieldByName(\"bar_string\")));\n  EXPECT_EQ(\"CORD\", reflection->GetString(\n      message, descriptor->FindFieldByName(\"bar_cord\")));\n  EXPECT_EQ(\"SPIECE\", reflection->GetString(\n      message, descriptor->FindFieldByName(\"bar_string_piece\")));\n  EXPECT_EQ(\"BYTES\", reflection->GetString(\n      message, descriptor->FindFieldByName(\"bar_bytes\")));\n  EXPECT_EQ(unittest::TestOneof2::BAR, reflection->GetEnum(\n      message, descriptor->FindFieldByName(\"bar_enum\"))->number());\n\n  // Check Set functions.\n  reflection->SetInt32(\n      &message, descriptor->FindFieldByName(\"foo_int\"), 123);\n  EXPECT_EQ(123, reflection->GetInt32(\n      message, descriptor->FindFieldByName(\"foo_int\")));\n  reflection->SetString(\n      &message, descriptor->FindFieldByName(\"foo_string\"), \"abc\");\n  EXPECT_EQ(\"abc\", reflection->GetString(\n      message, descriptor->FindFieldByName(\"foo_string\")));\n  reflection->SetString(\n      &message, descriptor->FindFieldByName(\"foo_bytes\"), \"bytes\");\n  EXPECT_EQ(\"bytes\", reflection->GetString(\n      message, descriptor->FindFieldByName(\"foo_bytes\")));\n  reflection->SetString(\n      &message, descriptor->FindFieldByName(\"bar_cord\"), \"change_cord\");\n  EXPECT_EQ(\"change_cord\", reflection->GetString(\n      message, descriptor->FindFieldByName(\"bar_cord\")));\n  reflection->SetString(\n      &message, descriptor->FindFieldByName(\"bar_string_piece\"),\n      \"change_spiece\");\n  EXPECT_EQ(\"change_spiece\", reflection->GetString(\n      message, descriptor->FindFieldByName(\"bar_string_piece\")));\n}\n\nTEST(GeneratedMessageReflectionTest, SetAllocatedOneofMessageTest) {\n  unittest::TestOneof2 from_message1;\n  unittest::TestOneof2 from_message2;\n  unittest::TestOneof2 to_message;\n  const Descriptor* descriptor = unittest::TestOneof2::descriptor();\n  const Reflection* reflection = to_message.GetReflection();\n\n  Message* released = reflection->ReleaseMessage(\n      &to_message, descriptor->FindFieldByName(\"foo_lazy_message\"));\n  EXPECT_TRUE(released == NULL);\n  released = reflection->ReleaseMessage(\n      &to_message, descriptor->FindFieldByName(\"foo_message\"));\n  EXPECT_TRUE(released == NULL);\n\n  TestUtil::ReflectionTester::SetOneofViaReflection(&from_message1);\n  TestUtil::ReflectionTester::ExpectOneofSetViaReflection(from_message1);\n\n  TestUtil::ReflectionTester::\n      SetAllocatedOptionalMessageFieldsToMessageViaReflection(\n          &from_message1, &to_message);\n  const Message& sub_message = reflection->GetMessage(\n      to_message, descriptor->FindFieldByName(\"foo_lazy_message\"));\n  released = reflection->ReleaseMessage(\n      &to_message, descriptor->FindFieldByName(\"foo_lazy_message\"));\n  EXPECT_TRUE(released != NULL);\n  EXPECT_EQ(&sub_message, released);\n  delete released;\n\n  TestUtil::ReflectionTester::SetOneofViaReflection(&from_message2);\n\n  reflection->MutableMessage(\n      &from_message2, descriptor->FindFieldByName(\"foo_message\"));\n\n  TestUtil::ReflectionTester::\n      SetAllocatedOptionalMessageFieldsToMessageViaReflection(\n          &from_message2, &to_message);\n\n  const Message& sub_message2 = reflection->GetMessage(\n      to_message, descriptor->FindFieldByName(\"foo_message\"));\n  released = reflection->ReleaseMessage(\n      &to_message, descriptor->FindFieldByName(\"foo_message\"));\n  EXPECT_TRUE(released != NULL);\n  EXPECT_EQ(&sub_message2, released);\n  delete released;\n}\n\nTEST(GeneratedMessageReflectionTest, ReleaseMessageTest) {\n  unittest::TestAllTypes message;\n  TestUtil::ReflectionTester reflection_tester(\n    unittest::TestAllTypes::descriptor());\n\n  // When nothing is set, we expect all released messages to be NULL.\n  reflection_tester.ExpectMessagesReleasedViaReflection(\n      &message, TestUtil::ReflectionTester::IS_NULL);\n\n  // After fields are set we should get non-NULL releases.\n  reflection_tester.SetAllFieldsViaReflection(&message);\n  reflection_tester.ExpectMessagesReleasedViaReflection(\n      &message, TestUtil::ReflectionTester::NOT_NULL);\n\n  // After Clear() we may or may not get a message from ReleaseMessage().\n  // This is implementation specific.\n  reflection_tester.SetAllFieldsViaReflection(&message);\n  message.Clear();\n  reflection_tester.ExpectMessagesReleasedViaReflection(\n      &message, TestUtil::ReflectionTester::CAN_BE_NULL);\n\n  // Test a different code path for setting after releasing.\n  TestUtil::SetAllFields(&message);\n  TestUtil::ExpectAllFieldsSet(message);\n}\n\nTEST(GeneratedMessageReflectionTest, ReleaseExtensionMessageTest) {\n  unittest::TestAllExtensions message;\n  TestUtil::ReflectionTester reflection_tester(\n    unittest::TestAllExtensions::descriptor());\n\n  // When nothing is set, we expect all released messages to be NULL.\n  reflection_tester.ExpectMessagesReleasedViaReflection(\n      &message, TestUtil::ReflectionTester::IS_NULL);\n\n  // After fields are set we should get non-NULL releases.\n  reflection_tester.SetAllFieldsViaReflection(&message);\n  reflection_tester.ExpectMessagesReleasedViaReflection(\n      &message, TestUtil::ReflectionTester::NOT_NULL);\n\n  // After Clear() we may or may not get a message from ReleaseMessage().\n  // This is implementation specific.\n  reflection_tester.SetAllFieldsViaReflection(&message);\n  message.Clear();\n  reflection_tester.ExpectMessagesReleasedViaReflection(\n      &message, TestUtil::ReflectionTester::CAN_BE_NULL);\n\n  // Test a different code path for setting after releasing.\n  TestUtil::SetAllExtensions(&message);\n  TestUtil::ExpectAllExtensionsSet(message);\n}\n\nTEST(GeneratedMessageReflectionTest, ReleaseOneofMessageTest) {\n  unittest::TestOneof2 message;\n  TestUtil::ReflectionTester::SetOneofViaReflection(&message);\n\n  const Descriptor* descriptor = unittest::TestOneof2::descriptor();\n  const Reflection* reflection = message.GetReflection();\n  const Message& sub_message = reflection->GetMessage(\n      message, descriptor->FindFieldByName(\"foo_lazy_message\"));\n  Message* released = reflection->ReleaseMessage(\n      &message, descriptor->FindFieldByName(\"foo_lazy_message\"));\n\n  EXPECT_TRUE(released != NULL);\n  EXPECT_EQ(&sub_message, released);\n  delete released;\n\n  released = reflection->ReleaseMessage(\n      &message, descriptor->FindFieldByName(\"foo_lazy_message\"));\n  EXPECT_TRUE(released == NULL);\n}\n\nTEST(GeneratedMessageReflectionTest, ArenaReleaseMessageTest) {\n  ::google::protobuf::Arena arena;\n  unittest::TestAllTypes* message =\n      ::google::protobuf::Arena::CreateMessage<unittest::TestAllTypes>(&arena);\n  TestUtil::ReflectionTester reflection_tester(\n      unittest::TestAllTypes::descriptor());\n\n  // When nothing is set, we expect all released messages to be NULL.\n  reflection_tester.ExpectMessagesReleasedViaReflection(\n      message, TestUtil::ReflectionTester::IS_NULL);\n\n  // After fields are set we should get non-NULL releases.\n  reflection_tester.SetAllFieldsViaReflection(message);\n  reflection_tester.ExpectMessagesReleasedViaReflection(\n      message, TestUtil::ReflectionTester::NOT_NULL);\n\n  // After Clear() we may or may not get a message from ReleaseMessage().\n  // This is implementation specific.\n  reflection_tester.SetAllFieldsViaReflection(message);\n  message->Clear();\n  reflection_tester.ExpectMessagesReleasedViaReflection(\n      message, TestUtil::ReflectionTester::CAN_BE_NULL);\n}\n\nTEST(GeneratedMessageReflectionTest, ArenaReleaseExtensionMessageTest) {\n  ::google::protobuf::Arena arena;\n  unittest::TestAllExtensions* message =\n      ::google::protobuf::Arena::CreateMessage<unittest::TestAllExtensions>(&arena);\n  TestUtil::ReflectionTester reflection_tester(\n      unittest::TestAllExtensions::descriptor());\n\n  // When nothing is set, we expect all released messages to be NULL.\n  reflection_tester.ExpectMessagesReleasedViaReflection(\n      message, TestUtil::ReflectionTester::IS_NULL);\n\n  // After fields are set we should get non-NULL releases.\n  reflection_tester.SetAllFieldsViaReflection(message);\n  reflection_tester.ExpectMessagesReleasedViaReflection(\n      message, TestUtil::ReflectionTester::NOT_NULL);\n\n  // After Clear() we may or may not get a message from ReleaseMessage().\n  // This is implementation specific.\n  reflection_tester.SetAllFieldsViaReflection(message);\n  message->Clear();\n  reflection_tester.ExpectMessagesReleasedViaReflection(\n      message, TestUtil::ReflectionTester::CAN_BE_NULL);\n}\n\nTEST(GeneratedMessageReflectionTest, ArenaReleaseOneofMessageTest) {\n  ::google::protobuf::Arena arena;\n  unittest::TestOneof2* message =\n      ::google::protobuf::Arena::CreateMessage<unittest::TestOneof2>(&arena);\n  TestUtil::ReflectionTester::SetOneofViaReflection(message);\n\n  const Descriptor* descriptor = unittest::TestOneof2::descriptor();\n  const Reflection* reflection = message->GetReflection();\n  Message* released = reflection->ReleaseMessage(\n      message, descriptor->FindFieldByName(\"foo_lazy_message\"));\n\n  EXPECT_TRUE(released != NULL);\n  delete released;\n\n  released = reflection->ReleaseMessage(\n      message, descriptor->FindFieldByName(\"foo_lazy_message\"));\n  EXPECT_TRUE(released == NULL);\n}\n\n#ifdef PROTOBUF_HAS_DEATH_TEST\n\nTEST(GeneratedMessageReflectionTest, UsageErrors) {\n  unittest::TestAllTypes message;\n  const Reflection* reflection = message.GetReflection();\n  const Descriptor* descriptor = message.GetDescriptor();\n\n#define f(NAME) descriptor->FindFieldByName(NAME)\n\n  // Testing every single failure mode would be too much work.  Let's just\n  // check a few.\n  EXPECT_DEATH(\n    reflection->GetInt32(\n      message, descriptor->FindFieldByName(\"optional_int64\")),\n    \"Protocol Buffer reflection usage error:\\n\"\n    \"  Method      : google::protobuf::Reflection::GetInt32\\n\"\n    \"  Message type: protobuf_unittest\\\\.TestAllTypes\\n\"\n    \"  Field       : protobuf_unittest\\\\.TestAllTypes\\\\.optional_int64\\n\"\n    \"  Problem     : Field is not the right type for this message:\\n\"\n    \"    Expected  : CPPTYPE_INT32\\n\"\n    \"    Field type: CPPTYPE_INT64\");\n  EXPECT_DEATH(\n    reflection->GetInt32(\n      message, descriptor->FindFieldByName(\"repeated_int32\")),\n    \"Protocol Buffer reflection usage error:\\n\"\n    \"  Method      : google::protobuf::Reflection::GetInt32\\n\"\n    \"  Message type: protobuf_unittest.TestAllTypes\\n\"\n    \"  Field       : protobuf_unittest.TestAllTypes.repeated_int32\\n\"\n    \"  Problem     : Field is repeated; the method requires a singular field.\");\n  EXPECT_DEATH(\n    reflection->GetInt32(\n      message, unittest::ForeignMessage::descriptor()->FindFieldByName(\"c\")),\n    \"Protocol Buffer reflection usage error:\\n\"\n    \"  Method      : google::protobuf::Reflection::GetInt32\\n\"\n    \"  Message type: protobuf_unittest.TestAllTypes\\n\"\n    \"  Field       : protobuf_unittest.ForeignMessage.c\\n\"\n    \"  Problem     : Field does not match message type.\");\n  EXPECT_DEATH(\n    reflection->HasField(\n      message, unittest::ForeignMessage::descriptor()->FindFieldByName(\"c\")),\n    \"Protocol Buffer reflection usage error:\\n\"\n    \"  Method      : google::protobuf::Reflection::HasField\\n\"\n    \"  Message type: protobuf_unittest.TestAllTypes\\n\"\n    \"  Field       : protobuf_unittest.ForeignMessage.c\\n\"\n    \"  Problem     : Field does not match message type.\");\n\n#undef f\n}\n\n#endif  // PROTOBUF_HAS_DEATH_TEST\n\n\n}  // namespace\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/generated_message_util.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/generated_message_util.h>\n\n#include <limits>\n\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\ndouble Infinity() {\n  return std::numeric_limits<double>::infinity();\n}\ndouble NaN() {\n  return std::numeric_limits<double>::quiet_NaN();\n}\n\nconst ::std::string* empty_string_;\nGOOGLE_PROTOBUF_DECLARE_ONCE(empty_string_once_init_);\n\nvoid DeleteEmptyString() {\n  delete empty_string_;\n}\n\nvoid InitEmptyString() {\n  empty_string_ = new string;\n  OnShutdown(&DeleteEmptyString);\n}\n\nint StringSpaceUsedExcludingSelf(const string& str) {\n  const void* start = &str;\n  const void* end = &str + 1;\n  if (start <= str.data() && str.data() < end) {\n    // The string's data is stored inside the string object itself.\n    return 0;\n  } else {\n    return str.capacity();\n  }\n}\n\n\n\nvoid MergeFromFail(const char* file, int line) {\n  GOOGLE_CHECK(false) << file << \":\" << line;\n  // Open-source GOOGLE_CHECK(false) is not NORETURN.\n  exit(1);\n}\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/generated_message_util.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This file contains miscellaneous helper code used by generated code --\n// including lite types -- but which should not be used directly by users.\n\n#ifndef GOOGLE_PROTOBUF_GENERATED_MESSAGE_UTIL_H__\n#define GOOGLE_PROTOBUF_GENERATED_MESSAGE_UTIL_H__\n\n#include <assert.h>\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/once.h>\n\nnamespace google {\n\nnamespace protobuf {\n\nclass Arena;\nnamespace io { class CodedInputStream; }\n\nnamespace internal {\n\n\n// Annotation for the compiler to emit a deprecation message if a field marked\n// with option 'deprecated=true' is used in the code, or for other things in\n// generated code which are deprecated.\n//\n// For internal use in the pb.cc files, deprecation warnings are suppressed\n// there.\n#undef DEPRECATED_PROTOBUF_FIELD\n#define PROTOBUF_DEPRECATED\n\n#define GOOGLE_PROTOBUF_DEPRECATED_ATTR\n\n\n// Constants for special floating point values.\nLIBPROTOBUF_EXPORT double Infinity();\nLIBPROTOBUF_EXPORT double NaN();\n\n// TODO(jieluo): Change to template. We have tried to use template,\n// but it causes net/rpc/python:rpcutil_test fail (the empty string will\n// init twice). It may related to swig. Change to template after we\n// found the solution.\n\n// Default empty string object. Don't use the pointer directly. Instead, call\n// GetEmptyString() to get the reference.\nLIBPROTOBUF_EXPORT extern const ::std::string* empty_string_;\nLIBPROTOBUF_EXPORT extern ProtobufOnceType empty_string_once_init_;\nLIBPROTOBUF_EXPORT void InitEmptyString();\n\n\nLIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyStringAlreadyInited() {\n  assert(empty_string_ != NULL);\n  return *empty_string_;\n}\nLIBPROTOBUF_EXPORT inline const ::std::string& GetEmptyString() {\n  ::google::protobuf::GoogleOnceInit(&empty_string_once_init_, &InitEmptyString);\n  return GetEmptyStringAlreadyInited();\n}\n\nLIBPROTOBUF_EXPORT int StringSpaceUsedExcludingSelf(const string& str);\n\n\n// True if IsInitialized() is true for all elements of t.  Type is expected\n// to be a RepeatedPtrField<some message type>.  It's useful to have this\n// helper here to keep the protobuf compiler from ever having to emit loops in\n// IsInitialized() methods.  We want the C++ compiler to inline this or not\n// as it sees fit.\ntemplate <class Type> bool AllAreInitialized(const Type& t) {\n  for (int i = t.size(); --i >= 0; ) {\n    if (!t.Get(i).IsInitialized()) return false;\n  }\n  return true;\n}\n\nclass ArenaString;\n\n// Read a length (varint32), followed by a string, from *input.  Return a\n// pointer to a copy of the string that resides in *arena.  Requires both\n// args to be non-NULL.  If something goes wrong while reading the data\n// then NULL is returned (e.g., input does not start with a valid varint).\nLIBPROTOBUF_EXPORT ArenaString* ReadArenaString(\n    ::google::protobuf::io::CodedInputStream* input,\n    ::google::protobuf::Arena* arena);\n\n// Helper function to crash on merge failure.\n// Moved out of generated code to reduce binary size.\nLIBPROTOBUF_EXPORT void MergeFromFail(const char* file, int line) GOOGLE_ATTRIBUTE_NORETURN;\n\n}  // namespace internal\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_GENERATED_MESSAGE_UTIL_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/coded_stream.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This implementation is heavily optimized to make reads and writes\n// of small values (especially varints) as fast as possible.  In\n// particular, we optimize for the common case that a read or a write\n// will not cross the end of the buffer, since we can avoid a lot\n// of branching in this case.\n\n#include <google/protobuf/io/coded_stream_inl.h>\n#include <algorithm>\n#include <utility>\n#include <limits.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/arena.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/stl_util.h>\n\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\n\nnamespace {\n\nstatic const int kMaxVarintBytes = 10;\nstatic const int kMaxVarint32Bytes = 5;\n\n\ninline bool NextNonEmpty(ZeroCopyInputStream* input,\n                         const void** data, int* size) {\n  bool success;\n  do {\n    success = input->Next(data, size);\n  } while (success && *size == 0);\n  return success;\n}\n\n}  // namespace\n\n// CodedInputStream ==================================================\n\nCodedInputStream::~CodedInputStream() {\n  if (input_ != NULL) {\n    BackUpInputToCurrentPosition();\n  }\n\n  if (total_bytes_warning_threshold_ == -2) {\n    GOOGLE_LOG(WARNING) << \"The total number of bytes read was \" << total_bytes_read_;\n  }\n}\n\n// Static.\nint CodedInputStream::default_recursion_limit_ = 100;\n\n\nvoid CodedOutputStream::EnableAliasing(bool enabled) {\n  aliasing_enabled_ = enabled && output_->AllowsAliasing();\n}\n\nvoid CodedInputStream::BackUpInputToCurrentPosition() {\n  int backup_bytes = BufferSize() + buffer_size_after_limit_ + overflow_bytes_;\n  if (backup_bytes > 0) {\n    input_->BackUp(backup_bytes);\n\n    // total_bytes_read_ doesn't include overflow_bytes_.\n    total_bytes_read_ -= BufferSize() + buffer_size_after_limit_;\n    buffer_end_ = buffer_;\n    buffer_size_after_limit_ = 0;\n    overflow_bytes_ = 0;\n  }\n}\n\ninline void CodedInputStream::RecomputeBufferLimits() {\n  buffer_end_ += buffer_size_after_limit_;\n  int closest_limit = std::min(current_limit_, total_bytes_limit_);\n  if (closest_limit < total_bytes_read_) {\n    // The limit position is in the current buffer.  We must adjust\n    // the buffer size accordingly.\n    buffer_size_after_limit_ = total_bytes_read_ - closest_limit;\n    buffer_end_ -= buffer_size_after_limit_;\n  } else {\n    buffer_size_after_limit_ = 0;\n  }\n}\n\nCodedInputStream::Limit CodedInputStream::PushLimit(int byte_limit) {\n  // Current position relative to the beginning of the stream.\n  int current_position = CurrentPosition();\n\n  Limit old_limit = current_limit_;\n\n  // security: byte_limit is possibly evil, so check for negative values\n  // and overflow.\n  if (byte_limit >= 0 &&\n      byte_limit <= INT_MAX - current_position) {\n    current_limit_ = current_position + byte_limit;\n  } else {\n    // Negative or overflow.\n    current_limit_ = INT_MAX;\n  }\n\n  // We need to enforce all limits, not just the new one, so if the previous\n  // limit was before the new requested limit, we continue to enforce the\n  // previous limit.\n  current_limit_ = std::min(current_limit_, old_limit);\n\n  RecomputeBufferLimits();\n  return old_limit;\n}\n\nvoid CodedInputStream::PopLimit(Limit limit) {\n  // The limit passed in is actually the *old* limit, which we returned from\n  // PushLimit().\n  current_limit_ = limit;\n  RecomputeBufferLimits();\n\n  // We may no longer be at a legitimate message end.  ReadTag() needs to be\n  // called again to find out.\n  legitimate_message_end_ = false;\n}\n\nstd::pair<CodedInputStream::Limit, int>\nCodedInputStream::IncrementRecursionDepthAndPushLimit(int byte_limit) {\n  return std::make_pair(PushLimit(byte_limit), --recursion_budget_);\n}\n\nCodedInputStream::Limit CodedInputStream::ReadLengthAndPushLimit() {\n  uint32 length;\n  return PushLimit(ReadVarint32(&length) ? length : 0);\n}\n\nbool CodedInputStream::DecrementRecursionDepthAndPopLimit(Limit limit) {\n  bool result = ConsumedEntireMessage();\n  PopLimit(limit);\n  GOOGLE_DCHECK_LT(recursion_budget_, recursion_limit_);\n  ++recursion_budget_;\n  return result;\n}\n\nbool CodedInputStream::CheckEntireMessageConsumedAndPopLimit(Limit limit) {\n  bool result = ConsumedEntireMessage();\n  PopLimit(limit);\n  return result;\n}\n\nint CodedInputStream::BytesUntilLimit() const {\n  if (current_limit_ == INT_MAX) return -1;\n  int current_position = CurrentPosition();\n\n  return current_limit_ - current_position;\n}\n\nvoid CodedInputStream::SetTotalBytesLimit(\n    int total_bytes_limit, int warning_threshold) {\n  // Make sure the limit isn't already past, since this could confuse other\n  // code.\n  int current_position = CurrentPosition();\n  total_bytes_limit_ = std::max(current_position, total_bytes_limit);\n  if (warning_threshold >= 0) {\n    total_bytes_warning_threshold_ = warning_threshold;\n  } else {\n    // warning_threshold is negative\n    total_bytes_warning_threshold_ = -1;\n  }\n  RecomputeBufferLimits();\n}\n\nint CodedInputStream::BytesUntilTotalBytesLimit() const {\n  if (total_bytes_limit_ == INT_MAX) return -1;\n  return total_bytes_limit_ - CurrentPosition();\n}\n\nvoid CodedInputStream::PrintTotalBytesLimitError() {\n  GOOGLE_LOG(ERROR) << \"A protocol message was rejected because it was too \"\n                \"big (more than \" << total_bytes_limit_\n             << \" bytes).  To increase the limit (or to disable these \"\n                \"warnings), see CodedInputStream::SetTotalBytesLimit() \"\n                \"in google/protobuf/io/coded_stream.h.\";\n}\n\nbool CodedInputStream::Skip(int count) {\n  if (count < 0) return false;  // security: count is often user-supplied\n\n  const int original_buffer_size = BufferSize();\n\n  if (count <= original_buffer_size) {\n    // Just skipping within the current buffer.  Easy.\n    Advance(count);\n    return true;\n  }\n\n  if (buffer_size_after_limit_ > 0) {\n    // We hit a limit inside this buffer.  Advance to the limit and fail.\n    Advance(original_buffer_size);\n    return false;\n  }\n\n  count -= original_buffer_size;\n  buffer_ = NULL;\n  buffer_end_ = buffer_;\n\n  // Make sure this skip doesn't try to skip past the current limit.\n  int closest_limit = std::min(current_limit_, total_bytes_limit_);\n  int bytes_until_limit = closest_limit - total_bytes_read_;\n  if (bytes_until_limit < count) {\n    // We hit the limit.  Skip up to it then fail.\n    if (bytes_until_limit > 0) {\n      total_bytes_read_ = closest_limit;\n      input_->Skip(bytes_until_limit);\n    }\n    return false;\n  }\n\n  total_bytes_read_ += count;\n  return input_->Skip(count);\n}\n\nbool CodedInputStream::GetDirectBufferPointer(const void** data, int* size) {\n  if (BufferSize() == 0 && !Refresh()) return false;\n\n  *data = buffer_;\n  *size = BufferSize();\n  return true;\n}\n\nbool CodedInputStream::ReadRaw(void* buffer, int size) {\n  return InternalReadRawInline(buffer, size);\n}\n\nbool CodedInputStream::ReadString(string* buffer, int size) {\n  if (size < 0) return false;  // security: size is often user-supplied\n  return InternalReadStringInline(buffer, size);\n}\n\nbool CodedInputStream::ReadStringFallback(string* buffer, int size) {\n  if (!buffer->empty()) {\n    buffer->clear();\n  }\n\n  int closest_limit = std::min(current_limit_, total_bytes_limit_);\n  if (closest_limit != INT_MAX) {\n    int bytes_to_limit = closest_limit - CurrentPosition();\n    if (bytes_to_limit > 0 && size > 0 && size <= bytes_to_limit) {\n      buffer->reserve(size);\n    }\n  }\n\n  int current_buffer_size;\n  while ((current_buffer_size = BufferSize()) < size) {\n    // Some STL implementations \"helpfully\" crash on buffer->append(NULL, 0).\n    if (current_buffer_size != 0) {\n      // Note:  string1.append(string2) is O(string2.size()) (as opposed to\n      //   O(string1.size() + string2.size()), which would be bad).\n      buffer->append(reinterpret_cast<const char*>(buffer_),\n                     current_buffer_size);\n    }\n    size -= current_buffer_size;\n    Advance(current_buffer_size);\n    if (!Refresh()) return false;\n  }\n\n  buffer->append(reinterpret_cast<const char*>(buffer_), size);\n  Advance(size);\n\n  return true;\n}\n\n\nbool CodedInputStream::ReadLittleEndian32Fallback(uint32* value) {\n  uint8 bytes[sizeof(*value)];\n\n  const uint8* ptr;\n  if (BufferSize() >= sizeof(*value)) {\n    // Fast path:  Enough bytes in the buffer to read directly.\n    ptr = buffer_;\n    Advance(sizeof(*value));\n  } else {\n    // Slow path:  Had to read past the end of the buffer.\n    if (!ReadRaw(bytes, sizeof(*value))) return false;\n    ptr = bytes;\n  }\n  ReadLittleEndian32FromArray(ptr, value);\n  return true;\n}\n\nbool CodedInputStream::ReadLittleEndian64Fallback(uint64* value) {\n  uint8 bytes[sizeof(*value)];\n\n  const uint8* ptr;\n  if (BufferSize() >= sizeof(*value)) {\n    // Fast path:  Enough bytes in the buffer to read directly.\n    ptr = buffer_;\n    Advance(sizeof(*value));\n  } else {\n    // Slow path:  Had to read past the end of the buffer.\n    if (!ReadRaw(bytes, sizeof(*value))) return false;\n    ptr = bytes;\n  }\n  ReadLittleEndian64FromArray(ptr, value);\n  return true;\n}\n\nnamespace {\n\n// Read a varint from the given buffer, write it to *value, and return a pair.\n// The first part of the pair is true iff the read was successful.  The second\n// part is buffer + (number of bytes read).  This function is always inlined,\n// so returning a pair is costless.\nGOOGLE_ATTRIBUTE_ALWAYS_INLINE ::std::pair<bool, const uint8*> ReadVarint32FromArray(\n    uint32 first_byte, const uint8* buffer,\n    uint32* value);\ninline ::std::pair<bool, const uint8*> ReadVarint32FromArray(\n    uint32 first_byte, const uint8* buffer, uint32* value) {\n  // Fast path:  We have enough bytes left in the buffer to guarantee that\n  // this read won't cross the end, so we can skip the checks.\n  GOOGLE_DCHECK_EQ(*buffer, first_byte);\n  GOOGLE_DCHECK_EQ(first_byte & 0x80, 0x80) << first_byte;\n  const uint8* ptr = buffer;\n  uint32 b;\n  uint32 result = first_byte - 0x80;\n  ++ptr;  // We just processed the first byte.  Move on to the second.\n  b = *(ptr++); result += b <<  7; if (!(b & 0x80)) goto done;\n  result -= 0x80 << 7;\n  b = *(ptr++); result += b << 14; if (!(b & 0x80)) goto done;\n  result -= 0x80 << 14;\n  b = *(ptr++); result += b << 21; if (!(b & 0x80)) goto done;\n  result -= 0x80 << 21;\n  b = *(ptr++); result += b << 28; if (!(b & 0x80)) goto done;\n  // \"result -= 0x80 << 28\" is irrevelant.\n\n  // If the input is larger than 32 bits, we still need to read it all\n  // and discard the high-order bits.\n  for (int i = 0; i < kMaxVarintBytes - kMaxVarint32Bytes; i++) {\n    b = *(ptr++); if (!(b & 0x80)) goto done;\n  }\n\n  // We have overrun the maximum size of a varint (10 bytes).  Assume\n  // the data is corrupt.\n  return std::make_pair(false, ptr);\n\n done:\n  *value = result;\n  return std::make_pair(true, ptr);\n}\n\nGOOGLE_ATTRIBUTE_ALWAYS_INLINE::std::pair<bool, const uint8*> ReadVarint64FromArray(\n    const uint8* buffer, uint64* value);\ninline ::std::pair<bool, const uint8*> ReadVarint64FromArray(\n    const uint8* buffer, uint64* value) {\n  const uint8* ptr = buffer;\n  uint32 b;\n\n  // Splitting into 32-bit pieces gives better performance on 32-bit\n  // processors.\n  uint32 part0 = 0, part1 = 0, part2 = 0;\n\n  b = *(ptr++); part0  = b      ; if (!(b & 0x80)) goto done;\n  part0 -= 0x80;\n  b = *(ptr++); part0 += b <<  7; if (!(b & 0x80)) goto done;\n  part0 -= 0x80 << 7;\n  b = *(ptr++); part0 += b << 14; if (!(b & 0x80)) goto done;\n  part0 -= 0x80 << 14;\n  b = *(ptr++); part0 += b << 21; if (!(b & 0x80)) goto done;\n  part0 -= 0x80 << 21;\n  b = *(ptr++); part1  = b      ; if (!(b & 0x80)) goto done;\n  part1 -= 0x80;\n  b = *(ptr++); part1 += b <<  7; if (!(b & 0x80)) goto done;\n  part1 -= 0x80 << 7;\n  b = *(ptr++); part1 += b << 14; if (!(b & 0x80)) goto done;\n  part1 -= 0x80 << 14;\n  b = *(ptr++); part1 += b << 21; if (!(b & 0x80)) goto done;\n  part1 -= 0x80 << 21;\n  b = *(ptr++); part2  = b      ; if (!(b & 0x80)) goto done;\n  part2 -= 0x80;\n  b = *(ptr++); part2 += b <<  7; if (!(b & 0x80)) goto done;\n  // \"part2 -= 0x80 << 7\" is irrelevant because (0x80 << 7) << 56 is 0.\n\n  // We have overrun the maximum size of a varint (10 bytes).  Assume\n  // the data is corrupt.\n  return std::make_pair(false, ptr);\n\n done:\n  *value = (static_cast<uint64>(part0)) |\n           (static_cast<uint64>(part1) << 28) |\n           (static_cast<uint64>(part2) << 56);\n  return std::make_pair(true, ptr);\n}\n\n}  // namespace\n\nbool CodedInputStream::ReadVarint32Slow(uint32* value) {\n  // Directly invoke ReadVarint64Fallback, since we already tried to optimize\n  // for one-byte varints.\n  std::pair<uint64, bool> p = ReadVarint64Fallback();\n  *value = static_cast<uint32>(p.first);\n  return p.second;\n}\n\nint64 CodedInputStream::ReadVarint32Fallback(uint32 first_byte_or_zero) {\n  if (BufferSize() >= kMaxVarintBytes ||\n      // Optimization:  We're also safe if the buffer is non-empty and it ends\n      // with a byte that would terminate a varint.\n      (buffer_end_ > buffer_ && !(buffer_end_[-1] & 0x80))) {\n    GOOGLE_DCHECK_NE(first_byte_or_zero, 0)\n        << \"Caller should provide us with *buffer_ when buffer is non-empty\";\n    uint32 temp;\n    ::std::pair<bool, const uint8*> p =\n          ReadVarint32FromArray(first_byte_or_zero, buffer_, &temp);\n    if (!p.first) return -1;\n    buffer_ = p.second;\n    return temp;\n  } else {\n    // Really slow case: we will incur the cost of an extra function call here,\n    // but moving this out of line reduces the size of this function, which\n    // improves the common case. In micro benchmarks, this is worth about 10-15%\n    uint32 temp;\n    return ReadVarint32Slow(&temp) ? static_cast<int64>(temp) : -1;\n  }\n}\n\nint CodedInputStream::ReadVarintSizeAsIntSlow() {\n  // Directly invoke ReadVarint64Fallback, since we already tried to optimize\n  // for one-byte varints.\n  std::pair<uint64, bool> p = ReadVarint64Fallback();\n  if (!p.second || p.first > static_cast<uint64>(INT_MAX)) return -1;\n  return p.first;\n}\n\nint CodedInputStream::ReadVarintSizeAsIntFallback() {\n  if (BufferSize() >= kMaxVarintBytes ||\n      // Optimization:  We're also safe if the buffer is non-empty and it ends\n      // with a byte that would terminate a varint.\n      (buffer_end_ > buffer_ && !(buffer_end_[-1] & 0x80))) {\n    uint64 temp;\n    ::std::pair<bool, const uint8*> p = ReadVarint64FromArray(buffer_, &temp);\n    if (!p.first || temp > static_cast<uint64>(INT_MAX)) return -1;\n    buffer_ = p.second;\n    return temp;\n  } else {\n    // Really slow case: we will incur the cost of an extra function call here,\n    // but moving this out of line reduces the size of this function, which\n    // improves the common case. In micro benchmarks, this is worth about 10-15%\n    return ReadVarintSizeAsIntSlow();\n  }\n}\n\nuint32 CodedInputStream::ReadTagSlow() {\n  if (buffer_ == buffer_end_) {\n    // Call refresh.\n    if (!Refresh()) {\n      // Refresh failed.  Make sure that it failed due to EOF, not because\n      // we hit total_bytes_limit_, which, unlike normal limits, is not a\n      // valid place to end a message.\n      int current_position = total_bytes_read_ - buffer_size_after_limit_;\n      if (current_position >= total_bytes_limit_) {\n        // Hit total_bytes_limit_.  But if we also hit the normal limit,\n        // we're still OK.\n        legitimate_message_end_ = current_limit_ == total_bytes_limit_;\n      } else {\n        legitimate_message_end_ = true;\n      }\n      return 0;\n    }\n  }\n\n  // For the slow path, just do a 64-bit read. Try to optimize for one-byte tags\n  // again, since we have now refreshed the buffer.\n  uint64 result = 0;\n  if (!ReadVarint64(&result)) return 0;\n  return static_cast<uint32>(result);\n}\n\nuint32 CodedInputStream::ReadTagFallback(uint32 first_byte_or_zero) {\n  const int buf_size = BufferSize();\n  if (buf_size >= kMaxVarintBytes ||\n      // Optimization:  We're also safe if the buffer is non-empty and it ends\n      // with a byte that would terminate a varint.\n      (buf_size > 0 && !(buffer_end_[-1] & 0x80))) {\n    GOOGLE_DCHECK_EQ(first_byte_or_zero, buffer_[0]);\n    if (first_byte_or_zero == 0) {\n      ++buffer_;\n      return 0;\n    }\n    uint32 tag;\n    ::std::pair<bool, const uint8*> p =\n        ReadVarint32FromArray(first_byte_or_zero, buffer_, &tag);\n    if (!p.first) {\n      return 0;\n    }\n    buffer_ = p.second;\n    return tag;\n  } else {\n    // We are commonly at a limit when attempting to read tags. Try to quickly\n    // detect this case without making another function call.\n    if ((buf_size == 0) &&\n        ((buffer_size_after_limit_ > 0) ||\n         (total_bytes_read_ == current_limit_)) &&\n        // Make sure that the limit we hit is not total_bytes_limit_, since\n        // in that case we still need to call Refresh() so that it prints an\n        // error.\n        total_bytes_read_ - buffer_size_after_limit_ < total_bytes_limit_) {\n      // We hit a byte limit.\n      legitimate_message_end_ = true;\n      return 0;\n    }\n    return ReadTagSlow();\n  }\n}\n\nbool CodedInputStream::ReadVarint64Slow(uint64* value) {\n  // Slow path:  This read might cross the end of the buffer, so we\n  // need to check and refresh the buffer if and when it does.\n\n  uint64 result = 0;\n  int count = 0;\n  uint32 b;\n\n  do {\n    if (count == kMaxVarintBytes) return false;\n    while (buffer_ == buffer_end_) {\n      if (!Refresh()) return false;\n    }\n    b = *buffer_;\n    result |= static_cast<uint64>(b & 0x7F) << (7 * count);\n    Advance(1);\n    ++count;\n  } while (b & 0x80);\n\n  *value = result;\n  return true;\n}\n\nstd::pair<uint64, bool> CodedInputStream::ReadVarint64Fallback() {\n  if (BufferSize() >= kMaxVarintBytes ||\n      // Optimization:  We're also safe if the buffer is non-empty and it ends\n      // with a byte that would terminate a varint.\n      (buffer_end_ > buffer_ && !(buffer_end_[-1] & 0x80))) {\n    uint64 temp;\n    ::std::pair<bool, const uint8*> p = ReadVarint64FromArray(buffer_, &temp);\n    if (!p.first) {\n      return std::make_pair(0, false);\n    }\n    buffer_ = p.second;\n    return std::make_pair(temp, true);\n  } else {\n    uint64 temp;\n    bool success = ReadVarint64Slow(&temp);\n    return std::make_pair(temp, success);\n  }\n}\n\nbool CodedInputStream::Refresh() {\n  GOOGLE_DCHECK_EQ(0, BufferSize());\n\n  if (buffer_size_after_limit_ > 0 || overflow_bytes_ > 0 ||\n      total_bytes_read_ == current_limit_) {\n    // We've hit a limit.  Stop.\n    int current_position = total_bytes_read_ - buffer_size_after_limit_;\n\n    if (current_position >= total_bytes_limit_ &&\n        total_bytes_limit_ != current_limit_) {\n      // Hit total_bytes_limit_.\n      PrintTotalBytesLimitError();\n    }\n\n    return false;\n  }\n\n  if (total_bytes_warning_threshold_ >= 0 &&\n      total_bytes_read_ >= total_bytes_warning_threshold_) {\n      GOOGLE_LOG(WARNING) << \"Reading dangerously large protocol message.  If the \"\n                      \"message turns out to be larger than \"\n                   << total_bytes_limit_ << \" bytes, parsing will be halted \"\n                      \"for security reasons.  To increase the limit (or to \"\n                      \"disable these warnings), see \"\n                      \"CodedInputStream::SetTotalBytesLimit() in \"\n                      \"google/protobuf/io/coded_stream.h.\";\n\n    // Don't warn again for this stream, and print total size at the end.\n    total_bytes_warning_threshold_ = -2;\n  }\n\n  const void* void_buffer;\n  int buffer_size;\n  if (NextNonEmpty(input_, &void_buffer, &buffer_size)) {\n    buffer_ = reinterpret_cast<const uint8*>(void_buffer);\n    buffer_end_ = buffer_ + buffer_size;\n    GOOGLE_CHECK_GE(buffer_size, 0);\n\n    if (total_bytes_read_ <= INT_MAX - buffer_size) {\n      total_bytes_read_ += buffer_size;\n    } else {\n      // Overflow.  Reset buffer_end_ to not include the bytes beyond INT_MAX.\n      // We can't get that far anyway, because total_bytes_limit_ is guaranteed\n      // to be less than it.  We need to keep track of the number of bytes\n      // we discarded, though, so that we can call input_->BackUp() to back\n      // up over them on destruction.\n\n      // The following line is equivalent to:\n      //   overflow_bytes_ = total_bytes_read_ + buffer_size - INT_MAX;\n      // except that it avoids overflows.  Signed integer overflow has\n      // undefined results according to the C standard.\n      overflow_bytes_ = total_bytes_read_ - (INT_MAX - buffer_size);\n      buffer_end_ -= overflow_bytes_;\n      total_bytes_read_ = INT_MAX;\n    }\n\n    RecomputeBufferLimits();\n    return true;\n  } else {\n    buffer_ = NULL;\n    buffer_end_ = NULL;\n    return false;\n  }\n}\n\n// CodedOutputStream =================================================\n\nbool CodedOutputStream::default_serialization_deterministic_ = false;\n\nCodedOutputStream::CodedOutputStream(ZeroCopyOutputStream* output)\n  : output_(output),\n    buffer_(NULL),\n    buffer_size_(0),\n    total_bytes_(0),\n    had_error_(false),\n    aliasing_enabled_(false),\n    serialization_deterministic_is_overridden_(false) {\n  // Eagerly Refresh() so buffer space is immediately available.\n  Refresh();\n  // The Refresh() may have failed. If the client doesn't write any data,\n  // though, don't consider this an error. If the client does write data, then\n  // another Refresh() will be attempted and it will set the error once again.\n  had_error_ = false;\n}\n\nCodedOutputStream::CodedOutputStream(ZeroCopyOutputStream* output,\n                                     bool do_eager_refresh)\n  : output_(output),\n    buffer_(NULL),\n    buffer_size_(0),\n    total_bytes_(0),\n    had_error_(false),\n    aliasing_enabled_(false),\n    serialization_deterministic_is_overridden_(false) {\n  if (do_eager_refresh) {\n    // Eagerly Refresh() so buffer space is immediately available.\n    Refresh();\n    // The Refresh() may have failed. If the client doesn't write any data,\n    // though, don't consider this an error. If the client does write data, then\n    // another Refresh() will be attempted and it will set the error once again.\n    had_error_ = false;\n  }\n}\n\nCodedOutputStream::~CodedOutputStream() {\n  Trim();\n}\n\nvoid CodedOutputStream::Trim() {\n  if (buffer_size_ > 0) {\n    output_->BackUp(buffer_size_);\n    total_bytes_ -= buffer_size_;\n    buffer_size_ = 0;\n    buffer_ = NULL;\n  }\n}\n\nbool CodedOutputStream::Skip(int count) {\n  if (count < 0) return false;\n\n  while (count > buffer_size_) {\n    count -= buffer_size_;\n    if (!Refresh()) return false;\n  }\n\n  Advance(count);\n  return true;\n}\n\nbool CodedOutputStream::GetDirectBufferPointer(void** data, int* size) {\n  if (buffer_size_ == 0 && !Refresh()) return false;\n\n  *data = buffer_;\n  *size = buffer_size_;\n  return true;\n}\n\nvoid CodedOutputStream::WriteRaw(const void* data, int size) {\n  while (buffer_size_ < size) {\n    memcpy(buffer_, data, buffer_size_);\n    size -= buffer_size_;\n    data = reinterpret_cast<const uint8*>(data) + buffer_size_;\n    if (!Refresh()) return;\n  }\n\n  memcpy(buffer_, data, size);\n  Advance(size);\n}\n\nuint8* CodedOutputStream::WriteRawToArray(\n    const void* data, int size, uint8* target) {\n  memcpy(target, data, size);\n  return target + size;\n}\n\n\nvoid CodedOutputStream::WriteAliasedRaw(const void* data, int size) {\n  if (size < buffer_size_\n      ) {\n    WriteRaw(data, size);\n  } else {\n    Trim();\n\n    total_bytes_ += size;\n    had_error_ |= !output_->WriteAliasedRaw(data, size);\n  }\n}\n\nvoid CodedOutputStream::WriteLittleEndian32(uint32 value) {\n  uint8 bytes[sizeof(value)];\n\n  bool use_fast = buffer_size_ >= sizeof(value);\n  uint8* ptr = use_fast ? buffer_ : bytes;\n\n  WriteLittleEndian32ToArray(value, ptr);\n\n  if (use_fast) {\n    Advance(sizeof(value));\n  } else {\n    WriteRaw(bytes, sizeof(value));\n  }\n}\n\nvoid CodedOutputStream::WriteLittleEndian64(uint64 value) {\n  uint8 bytes[sizeof(value)];\n\n  bool use_fast = buffer_size_ >= sizeof(value);\n  uint8* ptr = use_fast ? buffer_ : bytes;\n\n  WriteLittleEndian64ToArray(value, ptr);\n\n  if (use_fast) {\n    Advance(sizeof(value));\n  } else {\n    WriteRaw(bytes, sizeof(value));\n  }\n}\n\nvoid CodedOutputStream::WriteVarint32SlowPath(uint32 value) {\n  uint8 bytes[kMaxVarint32Bytes];\n  uint8* target = &bytes[0];\n  uint8* end = WriteVarint32ToArray(value, target);\n  int size = end - target;\n  WriteRaw(bytes, size);\n}\n\ninline uint8* CodedOutputStream::WriteVarint64ToArrayInline(\n    uint64 value, uint8* target) {\n  // Splitting into 32-bit pieces gives better performance on 32-bit\n  // processors.\n  uint32 part0 = static_cast<uint32>(value      );\n  uint32 part1 = static_cast<uint32>(value >> 28);\n  uint32 part2 = static_cast<uint32>(value >> 56);\n\n  int size;\n\n  // Here we can't really optimize for small numbers, since the value is\n  // split into three parts.  Cheking for numbers < 128, for instance,\n  // would require three comparisons, since you'd have to make sure part1\n  // and part2 are zero.  However, if the caller is using 64-bit integers,\n  // it is likely that they expect the numbers to often be very large, so\n  // we probably don't want to optimize for small numbers anyway.  Thus,\n  // we end up with a hardcoded binary search tree...\n  if (part2 == 0) {\n    if (part1 == 0) {\n      if (part0 < (1 << 14)) {\n        if (part0 < (1 << 7)) {\n          size = 1; goto size1;\n        } else {\n          size = 2; goto size2;\n        }\n      } else {\n        if (part0 < (1 << 21)) {\n          size = 3; goto size3;\n        } else {\n          size = 4; goto size4;\n        }\n      }\n    } else {\n      if (part1 < (1 << 14)) {\n        if (part1 < (1 << 7)) {\n          size = 5; goto size5;\n        } else {\n          size = 6; goto size6;\n        }\n      } else {\n        if (part1 < (1 << 21)) {\n          size = 7; goto size7;\n        } else {\n          size = 8; goto size8;\n        }\n      }\n    }\n  } else {\n    if (part2 < (1 << 7)) {\n      size = 9; goto size9;\n    } else {\n      size = 10; goto size10;\n    }\n  }\n\n  GOOGLE_LOG(FATAL) << \"Can't get here.\";\n\n  size10: target[9] = static_cast<uint8>((part2 >>  7) | 0x80);\n  size9 : target[8] = static_cast<uint8>((part2      ) | 0x80);\n  size8 : target[7] = static_cast<uint8>((part1 >> 21) | 0x80);\n  size7 : target[6] = static_cast<uint8>((part1 >> 14) | 0x80);\n  size6 : target[5] = static_cast<uint8>((part1 >>  7) | 0x80);\n  size5 : target[4] = static_cast<uint8>((part1      ) | 0x80);\n  size4 : target[3] = static_cast<uint8>((part0 >> 21) | 0x80);\n  size3 : target[2] = static_cast<uint8>((part0 >> 14) | 0x80);\n  size2 : target[1] = static_cast<uint8>((part0 >>  7) | 0x80);\n  size1 : target[0] = static_cast<uint8>((part0      ) | 0x80);\n\n  target[size-1] &= 0x7F;\n  return target + size;\n}\n\nvoid CodedOutputStream::WriteVarint64(uint64 value) {\n  if (buffer_size_ >= kMaxVarintBytes) {\n    // Fast path:  We have enough bytes left in the buffer to guarantee that\n    // this write won't cross the end, so we can skip the checks.\n    uint8* target = buffer_;\n\n    uint8* end = WriteVarint64ToArrayInline(value, target);\n    int size = end - target;\n    Advance(size);\n  } else {\n    // Slow path:  This write might cross the end of the buffer, so we\n    // compose the bytes first then use WriteRaw().\n    uint8 bytes[kMaxVarintBytes];\n    int size = 0;\n    while (value > 0x7F) {\n      bytes[size++] = (static_cast<uint8>(value) & 0x7F) | 0x80;\n      value >>= 7;\n    }\n    bytes[size++] = static_cast<uint8>(value) & 0x7F;\n    WriteRaw(bytes, size);\n  }\n}\n\nuint8* CodedOutputStream::WriteVarint64ToArray(\n    uint64 value, uint8* target) {\n  return WriteVarint64ToArrayInline(value, target);\n}\n\nbool CodedOutputStream::Refresh() {\n  void* void_buffer;\n  if (output_->Next(&void_buffer, &buffer_size_)) {\n    buffer_ = reinterpret_cast<uint8*>(void_buffer);\n    total_bytes_ += buffer_size_;\n    return true;\n  } else {\n    buffer_ = NULL;\n    buffer_size_ = 0;\n    had_error_ = true;\n    return false;\n  }\n}\n\nint CodedOutputStream::VarintSize32Fallback(uint32 value) {\n  if (value < (1 << 7)) {\n    return 1;\n  } else if (value < (1 << 14)) {\n    return 2;\n  } else if (value < (1 << 21)) {\n    return 3;\n  } else if (value < (1 << 28)) {\n    return 4;\n  } else {\n    return 5;\n  }\n}\n\nint CodedOutputStream::VarintSize64(uint64 value) {\n  if (value < (1ull << 35)) {\n    if (value < (1ull << 7)) {\n      return 1;\n    } else if (value < (1ull << 14)) {\n      return 2;\n    } else if (value < (1ull << 21)) {\n      return 3;\n    } else if (value < (1ull << 28)) {\n      return 4;\n    } else {\n      return 5;\n    }\n  } else {\n    if (value < (1ull << 42)) {\n      return 6;\n    } else if (value < (1ull << 49)) {\n      return 7;\n    } else if (value < (1ull << 56)) {\n      return 8;\n    } else if (value < (1ull << 63)) {\n      return 9;\n    } else {\n      return 10;\n    }\n  }\n}\n\nuint8* CodedOutputStream::WriteStringWithSizeToArray(const string& str,\n                                                     uint8* target) {\n  GOOGLE_DCHECK_LE(str.size(), kuint32max);\n  target = WriteVarint32ToArray(str.size(), target);\n  return WriteStringToArray(str, target);\n}\n\n}  // namespace io\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/coded_stream.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This file contains the CodedInputStream and CodedOutputStream classes,\n// which wrap a ZeroCopyInputStream or ZeroCopyOutputStream, respectively,\n// and allow you to read or write individual pieces of data in various\n// formats.  In particular, these implement the varint encoding for\n// integers, a simple variable-length encoding in which smaller numbers\n// take fewer bytes.\n//\n// Typically these classes will only be used internally by the protocol\n// buffer library in order to encode and decode protocol buffers.  Clients\n// of the library only need to know about this class if they wish to write\n// custom message parsing or serialization procedures.\n//\n// CodedOutputStream example:\n//   // Write some data to \"myfile\".  First we write a 4-byte \"magic number\"\n//   // to identify the file type, then write a length-delimited string.  The\n//   // string is composed of a varint giving the length followed by the raw\n//   // bytes.\n//   int fd = open(\"myfile\", O_CREAT | O_WRONLY);\n//   ZeroCopyOutputStream* raw_output = new FileOutputStream(fd);\n//   CodedOutputStream* coded_output = new CodedOutputStream(raw_output);\n//\n//   int magic_number = 1234;\n//   char text[] = \"Hello world!\";\n//   coded_output->WriteLittleEndian32(magic_number);\n//   coded_output->WriteVarint32(strlen(text));\n//   coded_output->WriteRaw(text, strlen(text));\n//\n//   delete coded_output;\n//   delete raw_output;\n//   close(fd);\n//\n// CodedInputStream example:\n//   // Read a file created by the above code.\n//   int fd = open(\"myfile\", O_RDONLY);\n//   ZeroCopyInputStream* raw_input = new FileInputStream(fd);\n//   CodedInputStream coded_input = new CodedInputStream(raw_input);\n//\n//   coded_input->ReadLittleEndian32(&magic_number);\n//   if (magic_number != 1234) {\n//     cerr << \"File not in expected format.\" << endl;\n//     return;\n//   }\n//\n//   uint32 size;\n//   coded_input->ReadVarint32(&size);\n//\n//   char* text = new char[size + 1];\n//   coded_input->ReadRaw(buffer, size);\n//   text[size] = '\\0';\n//\n//   delete coded_input;\n//   delete raw_input;\n//   close(fd);\n//\n//   cout << \"Text is: \" << text << endl;\n//   delete [] text;\n//\n// For those who are interested, varint encoding is defined as follows:\n//\n// The encoding operates on unsigned integers of up to 64 bits in length.\n// Each byte of the encoded value has the format:\n// * bits 0-6: Seven bits of the number being encoded.\n// * bit 7: Zero if this is the last byte in the encoding (in which\n//   case all remaining bits of the number are zero) or 1 if\n//   more bytes follow.\n// The first byte contains the least-significant 7 bits of the number, the\n// second byte (if present) contains the next-least-significant 7 bits,\n// and so on.  So, the binary number 1011000101011 would be encoded in two\n// bytes as \"10101011 00101100\".\n//\n// In theory, varint could be used to encode integers of any length.\n// However, for practicality we set a limit at 64 bits.  The maximum encoded\n// length of a number is thus 10 bytes.\n\n#ifndef GOOGLE_PROTOBUF_IO_CODED_STREAM_H__\n#define GOOGLE_PROTOBUF_IO_CODED_STREAM_H__\n\n#include <assert.h>\n#include <string>\n#include <utility>\n#ifdef _MSC_VER\n  // Assuming windows is always little-endian.\n  #if !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)\n    #define PROTOBUF_LITTLE_ENDIAN 1\n  #endif\n  #if _MSC_VER >= 1300 && !defined(__INTEL_COMPILER)\n    // If MSVC has \"/RTCc\" set, it will complain about truncating casts at\n    // runtime.  This file contains some intentional truncating casts.\n    #pragma runtime_checks(\"c\", off)\n  #endif\n#else\n  #include <sys/param.h>   // __BYTE_ORDER\n  #if ((defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \\\n         (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN)) && \\\n      !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)\n    #define PROTOBUF_LITTLE_ENDIAN 1\n  #endif\n#endif\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\n\nnamespace protobuf {\n\nclass DescriptorPool;\nclass MessageFactory;\n\nnamespace io {\n\n// Defined in this file.\nclass CodedInputStream;\nclass CodedOutputStream;\n\n// Defined in other files.\nclass ZeroCopyInputStream;           // zero_copy_stream.h\nclass ZeroCopyOutputStream;          // zero_copy_stream.h\n\n// Class which reads and decodes binary data which is composed of varint-\n// encoded integers and fixed-width pieces.  Wraps a ZeroCopyInputStream.\n// Most users will not need to deal with CodedInputStream.\n//\n// Most methods of CodedInputStream that return a bool return false if an\n// underlying I/O error occurs or if the data is malformed.  Once such a\n// failure occurs, the CodedInputStream is broken and is no longer useful.\nclass LIBPROTOBUF_EXPORT CodedInputStream {\n public:\n  // Create a CodedInputStream that reads from the given ZeroCopyInputStream.\n  explicit CodedInputStream(ZeroCopyInputStream* input);\n\n  // Create a CodedInputStream that reads from the given flat array.  This is\n  // faster than using an ArrayInputStream.  PushLimit(size) is implied by\n  // this constructor.\n  explicit CodedInputStream(const uint8* buffer, int size);\n\n  // Destroy the CodedInputStream and position the underlying\n  // ZeroCopyInputStream at the first unread byte.  If an error occurred while\n  // reading (causing a method to return false), then the exact position of\n  // the input stream may be anywhere between the last value that was read\n  // successfully and the stream's byte limit.\n  ~CodedInputStream();\n\n  // Return true if this CodedInputStream reads from a flat array instead of\n  // a ZeroCopyInputStream.\n  inline bool IsFlat() const;\n\n  // Skips a number of bytes.  Returns false if an underlying read error\n  // occurs.\n  bool Skip(int count);\n\n  // Sets *data to point directly at the unread part of the CodedInputStream's\n  // underlying buffer, and *size to the size of that buffer, but does not\n  // advance the stream's current position.  This will always either produce\n  // a non-empty buffer or return false.  If the caller consumes any of\n  // this data, it should then call Skip() to skip over the consumed bytes.\n  // This may be useful for implementing external fast parsing routines for\n  // types of data not covered by the CodedInputStream interface.\n  bool GetDirectBufferPointer(const void** data, int* size);\n\n  // Like GetDirectBufferPointer, but this method is inlined, and does not\n  // attempt to Refresh() if the buffer is currently empty.\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE void GetDirectBufferPointerInline(const void** data,\n                                                            int* size);\n\n  // Read raw bytes, copying them into the given buffer.\n  bool ReadRaw(void* buffer, int size);\n\n  // Like the above, with inlined optimizations. This should only be used\n  // by the protobuf implementation.\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE bool InternalReadRawInline(void* buffer, int size);\n\n  // Like ReadRaw, but reads into a string.\n  //\n  // Implementation Note:  ReadString() grows the string gradually as it\n  // reads in the data, rather than allocating the entire requested size\n  // upfront.  This prevents denial-of-service attacks in which a client\n  // could claim that a string is going to be MAX_INT bytes long in order to\n  // crash the server because it can't allocate this much space at once.\n  bool ReadString(string* buffer, int size);\n  // Like the above, with inlined optimizations. This should only be used\n  // by the protobuf implementation.\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE bool InternalReadStringInline(string* buffer,\n                                                        int size);\n\n\n  // Read a 32-bit little-endian integer.\n  bool ReadLittleEndian32(uint32* value);\n  // Read a 64-bit little-endian integer.\n  bool ReadLittleEndian64(uint64* value);\n\n  // These methods read from an externally provided buffer. The caller is\n  // responsible for ensuring that the buffer has sufficient space.\n  // Read a 32-bit little-endian integer.\n  static const uint8* ReadLittleEndian32FromArray(const uint8* buffer,\n                                                   uint32* value);\n  // Read a 64-bit little-endian integer.\n  static const uint8* ReadLittleEndian64FromArray(const uint8* buffer,\n                                                   uint64* value);\n\n  // Read an unsigned integer with Varint encoding, truncating to 32 bits.\n  // Reading a 32-bit value is equivalent to reading a 64-bit one and casting\n  // it to uint32, but may be more efficient.\n  bool ReadVarint32(uint32* value);\n  // Read an unsigned integer with Varint encoding.\n  bool ReadVarint64(uint64* value);\n\n  // Reads a varint off the wire into an \"int\". This should be used for reading\n  // sizes off the wire (sizes of strings, submessages, bytes fields, etc).\n  //\n  // The value from the wire is interpreted as unsigned.  If its value exceeds\n  // the representable value of an integer on this platform, instead of\n  // truncating we return false. Truncating (as performed by ReadVarint32()\n  // above) is an acceptable approach for fields representing an integer, but\n  // when we are parsing a size from the wire, truncating the value would result\n  // in us misparsing the payload.\n  bool ReadVarintSizeAsInt(int* value);\n\n  // Read a tag.  This calls ReadVarint32() and returns the result, or returns\n  // zero (which is not a valid tag) if ReadVarint32() fails.  Also, it updates\n  // the last tag value, which can be checked with LastTagWas().\n  // Always inline because this is only called in one place per parse loop\n  // but it is called for every iteration of said loop, so it should be fast.\n  // GCC doesn't want to inline this by default.\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE uint32 ReadTag();\n\n  // This usually a faster alternative to ReadTag() when cutoff is a manifest\n  // constant.  It does particularly well for cutoff >= 127.  The first part\n  // of the return value is the tag that was read, though it can also be 0 in\n  // the cases where ReadTag() would return 0.  If the second part is true\n  // then the tag is known to be in [0, cutoff].  If not, the tag either is\n  // above cutoff or is 0.  (There's intentional wiggle room when tag is 0,\n  // because that can arise in several ways, and for best performance we want\n  // to avoid an extra \"is tag == 0?\" check here.)\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE std::pair<uint32, bool> ReadTagWithCutoff(\n      uint32 cutoff);\n\n  // Usually returns true if calling ReadVarint32() now would produce the given\n  // value.  Will always return false if ReadVarint32() would not return the\n  // given value.  If ExpectTag() returns true, it also advances past\n  // the varint.  For best performance, use a compile-time constant as the\n  // parameter.\n  // Always inline because this collapses to a small number of instructions\n  // when given a constant parameter, but GCC doesn't want to inline by default.\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE bool ExpectTag(uint32 expected);\n\n  // Like above, except this reads from the specified buffer. The caller is\n  // responsible for ensuring that the buffer is large enough to read a varint\n  // of the expected size. For best performance, use a compile-time constant as\n  // the expected tag parameter.\n  //\n  // Returns a pointer beyond the expected tag if it was found, or NULL if it\n  // was not.\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE static const uint8* ExpectTagFromArray(\n      const uint8* buffer,\n      uint32 expected);\n\n  // Usually returns true if no more bytes can be read.  Always returns false\n  // if more bytes can be read.  If ExpectAtEnd() returns true, a subsequent\n  // call to LastTagWas() will act as if ReadTag() had been called and returned\n  // zero, and ConsumedEntireMessage() will return true.\n  bool ExpectAtEnd();\n\n  // If the last call to ReadTag() or ReadTagWithCutoff() returned the\n  // given value, returns true.  Otherwise, returns false;\n  //\n  // This is needed because parsers for some types of embedded messages\n  // (with field type TYPE_GROUP) don't actually know that they've reached the\n  // end of a message until they see an ENDGROUP tag, which was actually part\n  // of the enclosing message.  The enclosing message would like to check that\n  // tag to make sure it had the right number, so it calls LastTagWas() on\n  // return from the embedded parser to check.\n  bool LastTagWas(uint32 expected);\n\n  // When parsing message (but NOT a group), this method must be called\n  // immediately after MergeFromCodedStream() returns (if it returns true)\n  // to further verify that the message ended in a legitimate way.  For\n  // example, this verifies that parsing did not end on an end-group tag.\n  // It also checks for some cases where, due to optimizations,\n  // MergeFromCodedStream() can incorrectly return true.\n  bool ConsumedEntireMessage();\n\n  // Limits ----------------------------------------------------------\n  // Limits are used when parsing length-delimited embedded messages.\n  // After the message's length is read, PushLimit() is used to prevent\n  // the CodedInputStream from reading beyond that length.  Once the\n  // embedded message has been parsed, PopLimit() is called to undo the\n  // limit.\n\n  // Opaque type used with PushLimit() and PopLimit().  Do not modify\n  // values of this type yourself.  The only reason that this isn't a\n  // struct with private internals is for efficiency.\n  typedef int Limit;\n\n  // Places a limit on the number of bytes that the stream may read,\n  // starting from the current position.  Once the stream hits this limit,\n  // it will act like the end of the input has been reached until PopLimit()\n  // is called.\n  //\n  // As the names imply, the stream conceptually has a stack of limits.  The\n  // shortest limit on the stack is always enforced, even if it is not the\n  // top limit.\n  //\n  // The value returned by PushLimit() is opaque to the caller, and must\n  // be passed unchanged to the corresponding call to PopLimit().\n  Limit PushLimit(int byte_limit);\n\n  // Pops the last limit pushed by PushLimit().  The input must be the value\n  // returned by that call to PushLimit().\n  void PopLimit(Limit limit);\n\n  // Returns the number of bytes left until the nearest limit on the\n  // stack is hit, or -1 if no limits are in place.\n  int BytesUntilLimit() const;\n\n  // Returns current position relative to the beginning of the input stream.\n  int CurrentPosition() const;\n\n  // Total Bytes Limit -----------------------------------------------\n  // To prevent malicious users from sending excessively large messages\n  // and causing integer overflows or memory exhaustion, CodedInputStream\n  // imposes a hard limit on the total number of bytes it will read.\n\n  // Sets the maximum number of bytes that this CodedInputStream will read\n  // before refusing to continue.  To prevent integer overflows in the\n  // protocol buffers implementation, as well as to prevent servers from\n  // allocating enormous amounts of memory to hold parsed messages, the\n  // maximum message length should be limited to the shortest length that\n  // will not harm usability.  The theoretical shortest message that could\n  // cause integer overflows is 512MB.  The default limit is 64MB.  Apps\n  // should set shorter limits if possible.  If warning_threshold is not -1,\n  // a warning will be printed to stderr after warning_threshold bytes are\n  // read.  For backwards compatibility all negative values get squashed to -1,\n  // as other negative values might have special internal meanings.\n  // An error will always be printed to stderr if the limit is reached.\n  //\n  // This is unrelated to PushLimit()/PopLimit().\n  //\n  // Hint:  If you are reading this because your program is printing a\n  //   warning about dangerously large protocol messages, you may be\n  //   confused about what to do next.  The best option is to change your\n  //   design such that excessively large messages are not necessary.\n  //   For example, try to design file formats to consist of many small\n  //   messages rather than a single large one.  If this is infeasible,\n  //   you will need to increase the limit.  Chances are, though, that\n  //   your code never constructs a CodedInputStream on which the limit\n  //   can be set.  You probably parse messages by calling things like\n  //   Message::ParseFromString().  In this case, you will need to change\n  //   your code to instead construct some sort of ZeroCopyInputStream\n  //   (e.g. an ArrayInputStream), construct a CodedInputStream around\n  //   that, then call Message::ParseFromCodedStream() instead.  Then\n  //   you can adjust the limit.  Yes, it's more work, but you're doing\n  //   something unusual.\n  void SetTotalBytesLimit(int total_bytes_limit, int warning_threshold);\n\n  // The Total Bytes Limit minus the Current Position, or -1 if there\n  // is no Total Bytes Limit.\n  int BytesUntilTotalBytesLimit() const;\n\n  // Recursion Limit -------------------------------------------------\n  // To prevent corrupt or malicious messages from causing stack overflows,\n  // we must keep track of the depth of recursion when parsing embedded\n  // messages and groups.  CodedInputStream keeps track of this because it\n  // is the only object that is passed down the stack during parsing.\n\n  // Sets the maximum recursion depth.  The default is 100.\n  void SetRecursionLimit(int limit);\n\n\n  // Increments the current recursion depth.  Returns true if the depth is\n  // under the limit, false if it has gone over.\n  bool IncrementRecursionDepth();\n\n  // Decrements the recursion depth if possible.\n  void DecrementRecursionDepth();\n\n  // Decrements the recursion depth blindly.  This is faster than\n  // DecrementRecursionDepth().  It should be used only if all previous\n  // increments to recursion depth were successful.\n  void UnsafeDecrementRecursionDepth();\n\n  // Shorthand for make_pair(PushLimit(byte_limit), --recursion_budget_).\n  // Using this can reduce code size and complexity in some cases.  The caller\n  // is expected to check that the second part of the result is non-negative (to\n  // bail out if the depth of recursion is too high) and, if all is well, to\n  // later pass the first part of the result to PopLimit() or similar.\n  std::pair<CodedInputStream::Limit, int> IncrementRecursionDepthAndPushLimit(\n      int byte_limit);\n\n  // Shorthand for PushLimit(ReadVarint32(&length) ? length : 0).\n  Limit ReadLengthAndPushLimit();\n\n  // Helper that is equivalent to: {\n  //  bool result = ConsumedEntireMessage();\n  //  PopLimit(limit);\n  //  UnsafeDecrementRecursionDepth();\n  //  return result; }\n  // Using this can reduce code size and complexity in some cases.\n  // Do not use unless the current recursion depth is greater than zero.\n  bool DecrementRecursionDepthAndPopLimit(Limit limit);\n\n  // Helper that is equivalent to: {\n  //  bool result = ConsumedEntireMessage();\n  //  PopLimit(limit);\n  //  return result; }\n  // Using this can reduce code size and complexity in some cases.\n  bool CheckEntireMessageConsumedAndPopLimit(Limit limit);\n\n  // Extension Registry ----------------------------------------------\n  // ADVANCED USAGE:  99.9% of people can ignore this section.\n  //\n  // By default, when parsing extensions, the parser looks for extension\n  // definitions in the pool which owns the outer message's Descriptor.\n  // However, you may call SetExtensionRegistry() to provide an alternative\n  // pool instead.  This makes it possible, for example, to parse a message\n  // using a generated class, but represent some extensions using\n  // DynamicMessage.\n\n  // Set the pool used to look up extensions.  Most users do not need to call\n  // this as the correct pool will be chosen automatically.\n  //\n  // WARNING:  It is very easy to misuse this.  Carefully read the requirements\n  //   below.  Do not use this unless you are sure you need it.  Almost no one\n  //   does.\n  //\n  // Let's say you are parsing a message into message object m, and you want\n  // to take advantage of SetExtensionRegistry().  You must follow these\n  // requirements:\n  //\n  // The given DescriptorPool must contain m->GetDescriptor().  It is not\n  // sufficient for it to simply contain a descriptor that has the same name\n  // and content -- it must be the *exact object*.  In other words:\n  //   assert(pool->FindMessageTypeByName(m->GetDescriptor()->full_name()) ==\n  //          m->GetDescriptor());\n  // There are two ways to satisfy this requirement:\n  // 1) Use m->GetDescriptor()->pool() as the pool.  This is generally useless\n  //    because this is the pool that would be used anyway if you didn't call\n  //    SetExtensionRegistry() at all.\n  // 2) Use a DescriptorPool which has m->GetDescriptor()->pool() as an\n  //    \"underlay\".  Read the documentation for DescriptorPool for more\n  //    information about underlays.\n  //\n  // You must also provide a MessageFactory.  This factory will be used to\n  // construct Message objects representing extensions.  The factory's\n  // GetPrototype() MUST return non-NULL for any Descriptor which can be found\n  // through the provided pool.\n  //\n  // If the provided factory might return instances of protocol-compiler-\n  // generated (i.e. compiled-in) types, or if the outer message object m is\n  // a generated type, then the given factory MUST have this property:  If\n  // GetPrototype() is given a Descriptor which resides in\n  // DescriptorPool::generated_pool(), the factory MUST return the same\n  // prototype which MessageFactory::generated_factory() would return.  That\n  // is, given a descriptor for a generated type, the factory must return an\n  // instance of the generated class (NOT DynamicMessage).  However, when\n  // given a descriptor for a type that is NOT in generated_pool, the factory\n  // is free to return any implementation.\n  //\n  // The reason for this requirement is that generated sub-objects may be\n  // accessed via the standard (non-reflection) extension accessor methods,\n  // and these methods will down-cast the object to the generated class type.\n  // If the object is not actually of that type, the results would be undefined.\n  // On the other hand, if an extension is not compiled in, then there is no\n  // way the code could end up accessing it via the standard accessors -- the\n  // only way to access the extension is via reflection.  When using reflection,\n  // DynamicMessage and generated messages are indistinguishable, so it's fine\n  // if these objects are represented using DynamicMessage.\n  //\n  // Using DynamicMessageFactory on which you have called\n  // SetDelegateToGeneratedFactory(true) should be sufficient to satisfy the\n  // above requirement.\n  //\n  // If either pool or factory is NULL, both must be NULL.\n  //\n  // Note that this feature is ignored when parsing \"lite\" messages as they do\n  // not have descriptors.\n  void SetExtensionRegistry(const DescriptorPool* pool,\n                            MessageFactory* factory);\n\n  // Get the DescriptorPool set via SetExtensionRegistry(), or NULL if no pool\n  // has been provided.\n  const DescriptorPool* GetExtensionPool();\n\n  // Get the MessageFactory set via SetExtensionRegistry(), or NULL if no\n  // factory has been provided.\n  MessageFactory* GetExtensionFactory();\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CodedInputStream);\n\n  const uint8* buffer_;\n  const uint8* buffer_end_;     // pointer to the end of the buffer.\n  ZeroCopyInputStream* input_;\n  int total_bytes_read_;  // total bytes read from input_, including\n                          // the current buffer\n\n  // If total_bytes_read_ surpasses INT_MAX, we record the extra bytes here\n  // so that we can BackUp() on destruction.\n  int overflow_bytes_;\n\n  // LastTagWas() stuff.\n  uint32 last_tag_;         // result of last ReadTag() or ReadTagWithCutoff().\n\n  // This is set true by ReadTag{Fallback/Slow}() if it is called when exactly\n  // at EOF, or by ExpectAtEnd() when it returns true.  This happens when we\n  // reach the end of a message and attempt to read another tag.\n  bool legitimate_message_end_;\n\n  // See EnableAliasing().\n  bool aliasing_enabled_;\n\n  // Limits\n  Limit current_limit_;   // if position = -1, no limit is applied\n\n  // For simplicity, if the current buffer crosses a limit (either a normal\n  // limit created by PushLimit() or the total bytes limit), buffer_size_\n  // only tracks the number of bytes before that limit.  This field\n  // contains the number of bytes after it.  Note that this implies that if\n  // buffer_size_ == 0 and buffer_size_after_limit_ > 0, we know we've\n  // hit a limit.  However, if both are zero, it doesn't necessarily mean\n  // we aren't at a limit -- the buffer may have ended exactly at the limit.\n  int buffer_size_after_limit_;\n\n  // Maximum number of bytes to read, period.  This is unrelated to\n  // current_limit_.  Set using SetTotalBytesLimit().\n  int total_bytes_limit_;\n\n  // If positive/0: Limit for bytes read after which a warning due to size\n  // should be logged.\n  // If -1: Printing of warning disabled. Can be set by client.\n  // If -2: Internal: Limit has been reached, print full size when destructing.\n  int total_bytes_warning_threshold_;\n\n  // Current recursion budget, controlled by IncrementRecursionDepth() and\n  // similar.  Starts at recursion_limit_ and goes down: if this reaches\n  // -1 we are over budget.\n  int recursion_budget_;\n  // Recursion depth limit, set by SetRecursionLimit().\n  int recursion_limit_;\n\n  // See SetExtensionRegistry().\n  const DescriptorPool* extension_pool_;\n  MessageFactory* extension_factory_;\n\n  // Private member functions.\n\n  // Advance the buffer by a given number of bytes.\n  void Advance(int amount);\n\n  // Back up input_ to the current buffer position.\n  void BackUpInputToCurrentPosition();\n\n  // Recomputes the value of buffer_size_after_limit_.  Must be called after\n  // current_limit_ or total_bytes_limit_ changes.\n  void RecomputeBufferLimits();\n\n  // Writes an error message saying that we hit total_bytes_limit_.\n  void PrintTotalBytesLimitError();\n\n  // Called when the buffer runs out to request more data.  Implies an\n  // Advance(BufferSize()).\n  bool Refresh();\n\n  // When parsing varints, we optimize for the common case of small values, and\n  // then optimize for the case when the varint fits within the current buffer\n  // piece. The Fallback method is used when we can't use the one-byte\n  // optimization. The Slow method is yet another fallback when the buffer is\n  // not large enough. Making the slow path out-of-line speeds up the common\n  // case by 10-15%. The slow path is fairly uncommon: it only triggers when a\n  // message crosses multiple buffers.  Note: ReadVarint32Fallback() and\n  // ReadVarint64Fallback() are called frequently and generally not inlined, so\n  // they have been optimized to avoid \"out\" parameters.  The former returns -1\n  // if it fails and the uint32 it read otherwise.  The latter has a bool\n  // indicating success or failure as part of its return type.\n  int64 ReadVarint32Fallback(uint32 first_byte_or_zero);\n  int ReadVarintSizeAsIntFallback();\n  std::pair<uint64, bool> ReadVarint64Fallback();\n  bool ReadVarint32Slow(uint32* value);\n  bool ReadVarint64Slow(uint64* value);\n  int ReadVarintSizeAsIntSlow();\n  bool ReadLittleEndian32Fallback(uint32* value);\n  bool ReadLittleEndian64Fallback(uint64* value);\n  // Fallback/slow methods for reading tags. These do not update last_tag_,\n  // but will set legitimate_message_end_ if we are at the end of the input\n  // stream.\n  uint32 ReadTagFallback(uint32 first_byte_or_zero);\n  uint32 ReadTagSlow();\n  bool ReadStringFallback(string* buffer, int size);\n\n  // Return the size of the buffer.\n  int BufferSize() const;\n\n  static const int kDefaultTotalBytesLimit = 64 << 20;  // 64MB\n\n  static const int kDefaultTotalBytesWarningThreshold = 32 << 20;  // 32MB\n\n  static int default_recursion_limit_;  // 100 by default.\n};\n\n// Class which encodes and writes binary data which is composed of varint-\n// encoded integers and fixed-width pieces.  Wraps a ZeroCopyOutputStream.\n// Most users will not need to deal with CodedOutputStream.\n//\n// Most methods of CodedOutputStream which return a bool return false if an\n// underlying I/O error occurs.  Once such a failure occurs, the\n// CodedOutputStream is broken and is no longer useful. The Write* methods do\n// not return the stream status, but will invalidate the stream if an error\n// occurs. The client can probe HadError() to determine the status.\n//\n// Note that every method of CodedOutputStream which writes some data has\n// a corresponding static \"ToArray\" version. These versions write directly\n// to the provided buffer, returning a pointer past the last written byte.\n// They require that the buffer has sufficient capacity for the encoded data.\n// This allows an optimization where we check if an output stream has enough\n// space for an entire message before we start writing and, if there is, we\n// call only the ToArray methods to avoid doing bound checks for each\n// individual value.\n// i.e., in the example above:\n//\n//   CodedOutputStream coded_output = new CodedOutputStream(raw_output);\n//   int magic_number = 1234;\n//   char text[] = \"Hello world!\";\n//\n//   int coded_size = sizeof(magic_number) +\n//                    CodedOutputStream::VarintSize32(strlen(text)) +\n//                    strlen(text);\n//\n//   uint8* buffer =\n//       coded_output->GetDirectBufferForNBytesAndAdvance(coded_size);\n//   if (buffer != NULL) {\n//     // The output stream has enough space in the buffer: write directly to\n//     // the array.\n//     buffer = CodedOutputStream::WriteLittleEndian32ToArray(magic_number,\n//                                                            buffer);\n//     buffer = CodedOutputStream::WriteVarint32ToArray(strlen(text), buffer);\n//     buffer = CodedOutputStream::WriteRawToArray(text, strlen(text), buffer);\n//   } else {\n//     // Make bound-checked writes, which will ask the underlying stream for\n//     // more space as needed.\n//     coded_output->WriteLittleEndian32(magic_number);\n//     coded_output->WriteVarint32(strlen(text));\n//     coded_output->WriteRaw(text, strlen(text));\n//   }\n//\n//   delete coded_output;\nclass LIBPROTOBUF_EXPORT CodedOutputStream {\n public:\n  // Create an CodedOutputStream that writes to the given ZeroCopyOutputStream.\n  explicit CodedOutputStream(ZeroCopyOutputStream* output);\n  CodedOutputStream(ZeroCopyOutputStream* output, bool do_eager_refresh);\n\n  // Destroy the CodedOutputStream and position the underlying\n  // ZeroCopyOutputStream immediately after the last byte written.\n  ~CodedOutputStream();\n\n  // Trims any unused space in the underlying buffer so that its size matches\n  // the number of bytes written by this stream. The underlying buffer will\n  // automatically be trimmed when this stream is destroyed; this call is only\n  // necessary if the underlying buffer is accessed *before* the stream is\n  // destroyed.\n  void Trim();\n\n  // Skips a number of bytes, leaving the bytes unmodified in the underlying\n  // buffer.  Returns false if an underlying write error occurs.  This is\n  // mainly useful with GetDirectBufferPointer().\n  bool Skip(int count);\n\n  // Sets *data to point directly at the unwritten part of the\n  // CodedOutputStream's underlying buffer, and *size to the size of that\n  // buffer, but does not advance the stream's current position.  This will\n  // always either produce a non-empty buffer or return false.  If the caller\n  // writes any data to this buffer, it should then call Skip() to skip over\n  // the consumed bytes.  This may be useful for implementing external fast\n  // serialization routines for types of data not covered by the\n  // CodedOutputStream interface.\n  bool GetDirectBufferPointer(void** data, int* size);\n\n  // If there are at least \"size\" bytes available in the current buffer,\n  // returns a pointer directly into the buffer and advances over these bytes.\n  // The caller may then write directly into this buffer (e.g. using the\n  // *ToArray static methods) rather than go through CodedOutputStream.  If\n  // there are not enough bytes available, returns NULL.  The return pointer is\n  // invalidated as soon as any other non-const method of CodedOutputStream\n  // is called.\n  inline uint8* GetDirectBufferForNBytesAndAdvance(int size);\n\n  // Write raw bytes, copying them from the given buffer.\n  void WriteRaw(const void* buffer, int size);\n  // Like WriteRaw()  but will try to write aliased data if aliasing is\n  // turned on.\n  void WriteRawMaybeAliased(const void* data, int size);\n  // Like WriteRaw()  but writing directly to the target array.\n  // This is _not_ inlined, as the compiler often optimizes memcpy into inline\n  // copy loops. Since this gets called by every field with string or bytes\n  // type, inlining may lead to a significant amount of code bloat, with only a\n  // minor performance gain.\n  static uint8* WriteRawToArray(const void* buffer, int size, uint8* target);\n\n  // Equivalent to WriteRaw(str.data(), str.size()).\n  void WriteString(const string& str);\n  // Like WriteString()  but writing directly to the target array.\n  static uint8* WriteStringToArray(const string& str, uint8* target);\n  // Write the varint-encoded size of str followed by str.\n  static uint8* WriteStringWithSizeToArray(const string& str, uint8* target);\n\n\n  // Instructs the CodedOutputStream to allow the underlying\n  // ZeroCopyOutputStream to hold pointers to the original structure instead of\n  // copying, if it supports it (i.e. output->AllowsAliasing() is true).  If the\n  // underlying stream does not support aliasing, then enabling it has no\n  // affect.  For now, this only affects the behavior of\n  // WriteRawMaybeAliased().\n  //\n  // NOTE: It is caller's responsibility to ensure that the chunk of memory\n  // remains live until all of the data has been consumed from the stream.\n  void EnableAliasing(bool enabled);\n\n  // Write a 32-bit little-endian integer.\n  void WriteLittleEndian32(uint32 value);\n  // Like WriteLittleEndian32()  but writing directly to the target array.\n  static uint8* WriteLittleEndian32ToArray(uint32 value, uint8* target);\n  // Write a 64-bit little-endian integer.\n  void WriteLittleEndian64(uint64 value);\n  // Like WriteLittleEndian64()  but writing directly to the target array.\n  static uint8* WriteLittleEndian64ToArray(uint64 value, uint8* target);\n\n  // Write an unsigned integer with Varint encoding.  Writing a 32-bit value\n  // is equivalent to casting it to uint64 and writing it as a 64-bit value,\n  // but may be more efficient.\n  void WriteVarint32(uint32 value);\n  // Like WriteVarint32()  but writing directly to the target array.\n  static uint8* WriteVarint32ToArray(uint32 value, uint8* target);\n  // Write an unsigned integer with Varint encoding.\n  void WriteVarint64(uint64 value);\n  // Like WriteVarint64()  but writing directly to the target array.\n  static uint8* WriteVarint64ToArray(uint64 value, uint8* target);\n\n  // Equivalent to WriteVarint32() except when the value is negative,\n  // in which case it must be sign-extended to a full 10 bytes.\n  void WriteVarint32SignExtended(int32 value);\n  // Like WriteVarint32SignExtended()  but writing directly to the target array.\n  static uint8* WriteVarint32SignExtendedToArray(int32 value, uint8* target);\n\n  // This is identical to WriteVarint32(), but optimized for writing tags.\n  // In particular, if the input is a compile-time constant, this method\n  // compiles down to a couple instructions.\n  // Always inline because otherwise the aformentioned optimization can't work,\n  // but GCC by default doesn't want to inline this.\n  void WriteTag(uint32 value);\n  // Like WriteTag()  but writing directly to the target array.\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE static uint8* WriteTagToArray(uint32 value,\n                                                        uint8* target);\n\n  // Returns the number of bytes needed to encode the given value as a varint.\n  static int VarintSize32(uint32 value);\n  // Returns the number of bytes needed to encode the given value as a varint.\n  static int VarintSize64(uint64 value);\n\n  // If negative, 10 bytes.  Otheriwse, same as VarintSize32().\n  static int VarintSize32SignExtended(int32 value);\n\n  // Compile-time equivalent of VarintSize32().\n  template <uint32 Value>\n  struct StaticVarintSize32 {\n    static const int value =\n        (Value < (1 << 7))\n            ? 1\n            : (Value < (1 << 14))\n                ? 2\n                : (Value < (1 << 21))\n                    ? 3\n                    : (Value < (1 << 28))\n                        ? 4\n                        : 5;\n  };\n\n  // Returns the total number of bytes written since this object was created.\n  inline int ByteCount() const;\n\n  // Returns true if there was an underlying I/O error since this object was\n  // created.\n  bool HadError() const { return had_error_; }\n\n  // Deterministic serialization, if requested, guarantees that for a given\n  // binary, equal messages will always be serialized to the same bytes. This\n  // implies:\n  //   . repeated serialization of a message will return the same bytes\n  //   . different processes of the same binary (which may be executing on\n  //     different machines) will serialize equal messages to the same bytes.\n  //\n  // Note the deterministic serialization is NOT canonical across languages; it\n  // is also unstable across different builds with schema changes due to unknown\n  // fields. Users who need canonical serialization, e.g., persistent storage in\n  // a canonical form, fingerprinting, etc., should define their own\n  // canonicalization specification and implement the serializer using\n  // reflection APIs rather than relying on this API.\n  //\n  // If determinisitc serialization is requested, the serializer will\n  // sort map entries by keys in lexicographical order or numerical order.\n  // (This is an implementation detail and may subject to change.)\n  //\n  // There are two ways to determine whether serialization should be\n  // deterministic for this CodedOutputStream.  If SetSerializationDeterministic\n  // has not yet been called, then the default comes from the global default,\n  // which is false, until SetDefaultSerializationDeterministic has been called.\n  // Otherwise, SetSerializationDeterministic has been called, and the last\n  // value passed to it is all that matters.\n  void SetSerializationDeterministic(bool value) {\n    serialization_deterministic_is_overridden_ = true;\n    serialization_deterministic_override_ = value;\n  }\n  // See above.  Also, note that users of this CodedOutputStream may need to\n  // call IsSerializationDeterminstic() to serialize in the intended way.  This\n  // CodedOutputStream cannot enforce a desire for deterministic serialization\n  // by itself.\n  bool IsSerializationDeterminstic() const {\n    return serialization_deterministic_is_overridden_ ?\n        serialization_deterministic_override_ :\n        default_serialization_deterministic_;\n  }\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CodedOutputStream);\n\n  ZeroCopyOutputStream* output_;\n  uint8* buffer_;\n  int buffer_size_;\n  int total_bytes_;  // Sum of sizes of all buffers seen so far.\n  bool had_error_;   // Whether an error occurred during output.\n  bool aliasing_enabled_;  // See EnableAliasing().\n  // See SetSerializationDeterministic() regarding these three fields.\n  bool serialization_deterministic_is_overridden_;\n  bool serialization_deterministic_override_;\n  static bool default_serialization_deterministic_;\n\n  // Advance the buffer by a given number of bytes.\n  void Advance(int amount);\n\n  // Called when the buffer runs out to request more data.  Implies an\n  // Advance(buffer_size_).\n  bool Refresh();\n\n  // Like WriteRaw() but may avoid copying if the underlying\n  // ZeroCopyOutputStream supports it.\n  void WriteAliasedRaw(const void* buffer, int size);\n\n  // If this write might cross the end of the buffer, we compose the bytes first\n  // then use WriteRaw().\n  void WriteVarint32SlowPath(uint32 value);\n\n  // Always-inlined versions of WriteVarint* functions so that code can be\n  // reused, while still controlling size. For instance, WriteVarint32ToArray()\n  // should not directly call this: since it is inlined itself, doing so\n  // would greatly increase the size of generated code. Instead, it should call\n  // WriteVarint32FallbackToArray.  Meanwhile, WriteVarint32() is already\n  // out-of-line, so it should just invoke this directly to avoid any extra\n  // function call overhead.\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE static uint8* WriteVarint64ToArrayInline(\n      uint64 value, uint8* target);\n\n  static int VarintSize32Fallback(uint32 value);\n\n  // See above.  Other projects may use \"friend\" to allow them to call this.\n  static void SetDefaultSerializationDeterministic() {\n    default_serialization_deterministic_ = true;\n  }\n};\n\n// inline methods ====================================================\n// The vast majority of varints are only one byte.  These inline\n// methods optimize for that case.\n\ninline bool CodedInputStream::ReadVarint32(uint32* value) {\n  uint32 v = 0;\n  if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_)) {\n    v = *buffer_;\n    if (v < 0x80) {\n      *value = v;\n      Advance(1);\n      return true;\n    }\n  }\n  int64 result = ReadVarint32Fallback(v);\n  *value = static_cast<uint32>(result);\n  return result >= 0;\n}\n\ninline bool CodedInputStream::ReadVarint64(uint64* value) {\n  if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_) && *buffer_ < 0x80) {\n    *value = *buffer_;\n    Advance(1);\n    return true;\n  }\n  std::pair<uint64, bool> p = ReadVarint64Fallback();\n  *value = p.first;\n  return p.second;\n}\n\ninline bool CodedInputStream::ReadVarintSizeAsInt(int* value) {\n  if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_)) {\n    int v = *buffer_;\n    if (v < 0x80) {\n      *value = v;\n      Advance(1);\n      return true;\n    }\n  }\n  *value = ReadVarintSizeAsIntFallback();\n  return *value >= 0;\n}\n\n// static\ninline const uint8* CodedInputStream::ReadLittleEndian32FromArray(\n    const uint8* buffer,\n    uint32* value) {\n#if defined(PROTOBUF_LITTLE_ENDIAN)\n  memcpy(value, buffer, sizeof(*value));\n  return buffer + sizeof(*value);\n#else\n  *value = (static_cast<uint32>(buffer[0])      ) |\n           (static_cast<uint32>(buffer[1]) <<  8) |\n           (static_cast<uint32>(buffer[2]) << 16) |\n           (static_cast<uint32>(buffer[3]) << 24);\n  return buffer + sizeof(*value);\n#endif\n}\n// static\ninline const uint8* CodedInputStream::ReadLittleEndian64FromArray(\n    const uint8* buffer,\n    uint64* value) {\n#if defined(PROTOBUF_LITTLE_ENDIAN)\n  memcpy(value, buffer, sizeof(*value));\n  return buffer + sizeof(*value);\n#else\n  uint32 part0 = (static_cast<uint32>(buffer[0])      ) |\n                 (static_cast<uint32>(buffer[1]) <<  8) |\n                 (static_cast<uint32>(buffer[2]) << 16) |\n                 (static_cast<uint32>(buffer[3]) << 24);\n  uint32 part1 = (static_cast<uint32>(buffer[4])      ) |\n                 (static_cast<uint32>(buffer[5]) <<  8) |\n                 (static_cast<uint32>(buffer[6]) << 16) |\n                 (static_cast<uint32>(buffer[7]) << 24);\n  *value = static_cast<uint64>(part0) |\n          (static_cast<uint64>(part1) << 32);\n  return buffer + sizeof(*value);\n#endif\n}\n\ninline bool CodedInputStream::ReadLittleEndian32(uint32* value) {\n#if defined(PROTOBUF_LITTLE_ENDIAN)\n  if (GOOGLE_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {\n    memcpy(value, buffer_, sizeof(*value));\n    Advance(sizeof(*value));\n    return true;\n  } else {\n    return ReadLittleEndian32Fallback(value);\n  }\n#else\n  return ReadLittleEndian32Fallback(value);\n#endif\n}\n\ninline bool CodedInputStream::ReadLittleEndian64(uint64* value) {\n#if defined(PROTOBUF_LITTLE_ENDIAN)\n  if (GOOGLE_PREDICT_TRUE(BufferSize() >= static_cast<int>(sizeof(*value)))) {\n    memcpy(value, buffer_, sizeof(*value));\n    Advance(sizeof(*value));\n    return true;\n  } else {\n    return ReadLittleEndian64Fallback(value);\n  }\n#else\n  return ReadLittleEndian64Fallback(value);\n#endif\n}\n\ninline uint32 CodedInputStream::ReadTag() {\n  uint32 v = 0;\n  if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_)) {\n    v = *buffer_;\n    if (v < 0x80) {\n      last_tag_ = v;\n      Advance(1);\n      return v;\n    }\n  }\n  last_tag_ = ReadTagFallback(v);\n  return last_tag_;\n}\n\ninline std::pair<uint32, bool> CodedInputStream::ReadTagWithCutoff(\n    uint32 cutoff) {\n  // In performance-sensitive code we can expect cutoff to be a compile-time\n  // constant, and things like \"cutoff >= kMax1ByteVarint\" to be evaluated at\n  // compile time.\n  uint32 first_byte_or_zero = 0;\n  if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_)) {\n    // Hot case: buffer_ non_empty, buffer_[0] in [1, 128).\n    // TODO(gpike): Is it worth rearranging this? E.g., if the number of fields\n    // is large enough then is it better to check for the two-byte case first?\n    first_byte_or_zero = buffer_[0];\n    if (static_cast<int8>(buffer_[0]) > 0) {\n      const uint32 kMax1ByteVarint = 0x7f;\n      uint32 tag = last_tag_ = buffer_[0];\n      Advance(1);\n      return std::make_pair(tag, cutoff >= kMax1ByteVarint || tag <= cutoff);\n    }\n    // Other hot case: cutoff >= 0x80, buffer_ has at least two bytes available,\n    // and tag is two bytes.  The latter is tested by bitwise-and-not of the\n    // first byte and the second byte.\n    if (cutoff >= 0x80 &&\n        GOOGLE_PREDICT_TRUE(buffer_ + 1 < buffer_end_) &&\n        GOOGLE_PREDICT_TRUE((buffer_[0] & ~buffer_[1]) >= 0x80)) {\n      const uint32 kMax2ByteVarint = (0x7f << 7) + 0x7f;\n      uint32 tag = last_tag_ = (1u << 7) * buffer_[1] + (buffer_[0] - 0x80);\n      Advance(2);\n      // It might make sense to test for tag == 0 now, but it is so rare that\n      // that we don't bother.  A varint-encoded 0 should be one byte unless\n      // the encoder lost its mind.  The second part of the return value of\n      // this function is allowed to be either true or false if the tag is 0,\n      // so we don't have to check for tag == 0.  We may need to check whether\n      // it exceeds cutoff.\n      bool at_or_below_cutoff = cutoff >= kMax2ByteVarint || tag <= cutoff;\n      return std::make_pair(tag, at_or_below_cutoff);\n    }\n  }\n  // Slow path\n  last_tag_ = ReadTagFallback(first_byte_or_zero);\n  return std::make_pair(last_tag_, static_cast<uint32>(last_tag_ - 1) < cutoff);\n}\n\ninline bool CodedInputStream::LastTagWas(uint32 expected) {\n  return last_tag_ == expected;\n}\n\ninline bool CodedInputStream::ConsumedEntireMessage() {\n  return legitimate_message_end_;\n}\n\ninline bool CodedInputStream::ExpectTag(uint32 expected) {\n  if (expected < (1 << 7)) {\n    if (GOOGLE_PREDICT_TRUE(buffer_ < buffer_end_) && buffer_[0] == expected) {\n      Advance(1);\n      return true;\n    } else {\n      return false;\n    }\n  } else if (expected < (1 << 14)) {\n    if (GOOGLE_PREDICT_TRUE(BufferSize() >= 2) &&\n        buffer_[0] == static_cast<uint8>(expected | 0x80) &&\n        buffer_[1] == static_cast<uint8>(expected >> 7)) {\n      Advance(2);\n      return true;\n    } else {\n      return false;\n    }\n  } else {\n    // Don't bother optimizing for larger values.\n    return false;\n  }\n}\n\ninline const uint8* CodedInputStream::ExpectTagFromArray(\n    const uint8* buffer, uint32 expected) {\n  if (expected < (1 << 7)) {\n    if (buffer[0] == expected) {\n      return buffer + 1;\n    }\n  } else if (expected < (1 << 14)) {\n    if (buffer[0] == static_cast<uint8>(expected | 0x80) &&\n        buffer[1] == static_cast<uint8>(expected >> 7)) {\n      return buffer + 2;\n    }\n  }\n  return NULL;\n}\n\ninline void CodedInputStream::GetDirectBufferPointerInline(const void** data,\n                                                           int* size) {\n  *data = buffer_;\n  *size = static_cast<int>(buffer_end_ - buffer_);\n}\n\ninline bool CodedInputStream::ExpectAtEnd() {\n  // If we are at a limit we know no more bytes can be read.  Otherwise, it's\n  // hard to say without calling Refresh(), and we'd rather not do that.\n\n  if (buffer_ == buffer_end_ &&\n      ((buffer_size_after_limit_ != 0) ||\n       (total_bytes_read_ == current_limit_))) {\n    last_tag_ = 0;                   // Pretend we called ReadTag()...\n    legitimate_message_end_ = true;  // ... and it hit EOF.\n    return true;\n  } else {\n    return false;\n  }\n}\n\ninline int CodedInputStream::CurrentPosition() const {\n  return total_bytes_read_ - (BufferSize() + buffer_size_after_limit_);\n}\n\ninline uint8* CodedOutputStream::GetDirectBufferForNBytesAndAdvance(int size) {\n  if (buffer_size_ < size) {\n    return NULL;\n  } else {\n    uint8* result = buffer_;\n    Advance(size);\n    return result;\n  }\n}\n\ninline uint8* CodedOutputStream::WriteVarint32ToArray(uint32 value,\n                                                      uint8* target) {\n  while (value >= 0x80) {\n    *target = static_cast<uint8>(value | 0x80);\n    value >>= 7;\n    ++target;\n  }\n  *target = static_cast<uint8>(value);\n  return target + 1;\n}\n\ninline void CodedOutputStream::WriteVarint32SignExtended(int32 value) {\n  if (value < 0) {\n    WriteVarint64(static_cast<uint64>(value));\n  } else {\n    WriteVarint32(static_cast<uint32>(value));\n  }\n}\n\ninline uint8* CodedOutputStream::WriteVarint32SignExtendedToArray(\n    int32 value, uint8* target) {\n  if (value < 0) {\n    return WriteVarint64ToArray(static_cast<uint64>(value), target);\n  } else {\n    return WriteVarint32ToArray(static_cast<uint32>(value), target);\n  }\n}\n\ninline uint8* CodedOutputStream::WriteLittleEndian32ToArray(uint32 value,\n                                                            uint8* target) {\n#if defined(PROTOBUF_LITTLE_ENDIAN)\n  memcpy(target, &value, sizeof(value));\n#else\n  target[0] = static_cast<uint8>(value);\n  target[1] = static_cast<uint8>(value >>  8);\n  target[2] = static_cast<uint8>(value >> 16);\n  target[3] = static_cast<uint8>(value >> 24);\n#endif\n  return target + sizeof(value);\n}\n\ninline uint8* CodedOutputStream::WriteLittleEndian64ToArray(uint64 value,\n                                                            uint8* target) {\n#if defined(PROTOBUF_LITTLE_ENDIAN)\n  memcpy(target, &value, sizeof(value));\n#else\n  uint32 part0 = static_cast<uint32>(value);\n  uint32 part1 = static_cast<uint32>(value >> 32);\n\n  target[0] = static_cast<uint8>(part0);\n  target[1] = static_cast<uint8>(part0 >>  8);\n  target[2] = static_cast<uint8>(part0 >> 16);\n  target[3] = static_cast<uint8>(part0 >> 24);\n  target[4] = static_cast<uint8>(part1);\n  target[5] = static_cast<uint8>(part1 >>  8);\n  target[6] = static_cast<uint8>(part1 >> 16);\n  target[7] = static_cast<uint8>(part1 >> 24);\n#endif\n  return target + sizeof(value);\n}\n\ninline void CodedOutputStream::WriteVarint32(uint32 value) {\n  if (buffer_size_ >= 5) {\n    // Fast path:  We have enough bytes left in the buffer to guarantee that\n    // this write won't cross the end, so we can skip the checks.\n    uint8* target = buffer_;\n    uint8* end = WriteVarint32ToArray(value, target);\n    int size = static_cast<int>(end - target);\n    Advance(size);\n  } else {\n    WriteVarint32SlowPath(value);\n  }\n}\n\ninline void CodedOutputStream::WriteTag(uint32 value) {\n  WriteVarint32(value);\n}\n\ninline uint8* CodedOutputStream::WriteTagToArray(\n    uint32 value, uint8* target) {\n  return WriteVarint32ToArray(value, target);\n}\n\ninline int CodedOutputStream::VarintSize32(uint32 value) {\n  if (value < (1 << 7)) {\n    return 1;\n  } else  {\n    return VarintSize32Fallback(value);\n  }\n}\n\ninline int CodedOutputStream::VarintSize32SignExtended(int32 value) {\n  if (value < 0) {\n    return 10;     // TODO(kenton):  Make this a symbolic constant.\n  } else {\n    return VarintSize32(static_cast<uint32>(value));\n  }\n}\n\ninline void CodedOutputStream::WriteString(const string& str) {\n  WriteRaw(str.data(), static_cast<int>(str.size()));\n}\n\ninline void CodedOutputStream::WriteRawMaybeAliased(\n    const void* data, int size) {\n  if (aliasing_enabled_) {\n    WriteAliasedRaw(data, size);\n  } else {\n    WriteRaw(data, size);\n  }\n}\n\ninline uint8* CodedOutputStream::WriteStringToArray(\n    const string& str, uint8* target) {\n  return WriteRawToArray(str.data(), static_cast<int>(str.size()), target);\n}\n\ninline int CodedOutputStream::ByteCount() const {\n  return total_bytes_ - buffer_size_;\n}\n\ninline void CodedInputStream::Advance(int amount) {\n  buffer_ += amount;\n}\n\ninline void CodedOutputStream::Advance(int amount) {\n  buffer_ += amount;\n  buffer_size_ -= amount;\n}\n\ninline void CodedInputStream::SetRecursionLimit(int limit) {\n  recursion_budget_ += limit - recursion_limit_;\n  recursion_limit_ = limit;\n}\n\ninline bool CodedInputStream::IncrementRecursionDepth() {\n  --recursion_budget_;\n  return recursion_budget_ >= 0;\n}\n\ninline void CodedInputStream::DecrementRecursionDepth() {\n  if (recursion_budget_ < recursion_limit_) ++recursion_budget_;\n}\n\ninline void CodedInputStream::UnsafeDecrementRecursionDepth() {\n  assert(recursion_budget_ < recursion_limit_);\n  ++recursion_budget_;\n}\n\ninline void CodedInputStream::SetExtensionRegistry(const DescriptorPool* pool,\n                                                   MessageFactory* factory) {\n  extension_pool_ = pool;\n  extension_factory_ = factory;\n}\n\ninline const DescriptorPool* CodedInputStream::GetExtensionPool() {\n  return extension_pool_;\n}\n\ninline MessageFactory* CodedInputStream::GetExtensionFactory() {\n  return extension_factory_;\n}\n\ninline int CodedInputStream::BufferSize() const {\n  return static_cast<int>(buffer_end_ - buffer_);\n}\n\ninline CodedInputStream::CodedInputStream(ZeroCopyInputStream* input)\n  : buffer_(NULL),\n    buffer_end_(NULL),\n    input_(input),\n    total_bytes_read_(0),\n    overflow_bytes_(0),\n    last_tag_(0),\n    legitimate_message_end_(false),\n    aliasing_enabled_(false),\n    current_limit_(kint32max),\n    buffer_size_after_limit_(0),\n    total_bytes_limit_(kDefaultTotalBytesLimit),\n    total_bytes_warning_threshold_(kDefaultTotalBytesWarningThreshold),\n    recursion_budget_(default_recursion_limit_),\n    recursion_limit_(default_recursion_limit_),\n    extension_pool_(NULL),\n    extension_factory_(NULL) {\n  // Eagerly Refresh() so buffer space is immediately available.\n  Refresh();\n}\n\ninline CodedInputStream::CodedInputStream(const uint8* buffer, int size)\n  : buffer_(buffer),\n    buffer_end_(buffer + size),\n    input_(NULL),\n    total_bytes_read_(size),\n    overflow_bytes_(0),\n    last_tag_(0),\n    legitimate_message_end_(false),\n    aliasing_enabled_(false),\n    current_limit_(size),\n    buffer_size_after_limit_(0),\n    total_bytes_limit_(kDefaultTotalBytesLimit),\n    total_bytes_warning_threshold_(kDefaultTotalBytesWarningThreshold),\n    recursion_budget_(default_recursion_limit_),\n    recursion_limit_(default_recursion_limit_),\n    extension_pool_(NULL),\n    extension_factory_(NULL) {\n  // Note that setting current_limit_ == size is important to prevent some\n  // code paths from trying to access input_ and segfaulting.\n}\n\ninline bool CodedInputStream::IsFlat() const {\n  return input_ == NULL;\n}\n\n}  // namespace io\n}  // namespace protobuf\n\n\n#if _MSC_VER >= 1300 && !defined(__INTEL_COMPILER)\n  #pragma runtime_checks(\"c\", restore)\n#endif  // _MSC_VER && !defined(__INTEL_COMPILER)\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_IO_CODED_STREAM_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/coded_stream_inl.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: jasonh@google.com (Jason Hsueh)\n//\n// Implements methods of coded_stream.h that need to be inlined for performance\n// reasons, but should not be defined in a public header.\n\n#ifndef GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__\n#define GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl_lite.h>\n#include <string>\n#include <google/protobuf/stubs/stl_util.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\n\ninline bool CodedInputStream::InternalReadStringInline(string* buffer,\n                                                       int size) {\n  if (size < 0) return false;  // security: size is often user-supplied\n\n  if (BufferSize() >= size) {\n    STLStringResizeUninitialized(buffer, size);\n    std::pair<char*, bool> z = as_string_data(buffer);\n    if (z.second) {\n      // Oddly enough, memcpy() requires its first two args to be non-NULL even\n      // if we copy 0 bytes.  So, we have ensured that z.first is non-NULL here.\n      GOOGLE_DCHECK(z.first != NULL);\n      memcpy(z.first, buffer_, size);\n      Advance(size);\n    }\n    return true;\n  }\n\n  return ReadStringFallback(buffer, size);\n}\n\ninline bool CodedInputStream::InternalReadRawInline(void* buffer, int size) {\n  int current_buffer_size;\n  while ((current_buffer_size = BufferSize()) < size) {\n    // Reading past end of buffer.  Copy what we have, then refresh.\n    memcpy(buffer, buffer_, current_buffer_size);\n    buffer = reinterpret_cast<uint8*>(buffer) + current_buffer_size;\n    size -= current_buffer_size;\n    Advance(current_buffer_size);\n    if (!Refresh()) return false;\n  }\n\n  memcpy(buffer, buffer_, size);\n  Advance(size);\n\n  return true;\n}\n\n}  // namespace io\n}  // namespace protobuf\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/coded_stream_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This file contains tests and benchmarks.\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <vector>\n\n#include <google/protobuf/io/coded_stream.h>\n\n#include <limits.h>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n\n\n// This declares an unsigned long long integer literal in a portable way.\n// (The original macro is way too big and ruins my formatting.)\n#undef ULL\n#define ULL(x) GOOGLE_ULONGLONG(x)\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\nnamespace {\n\n// ===================================================================\n// Data-Driven Test Infrastructure\n\n// TEST_1D and TEST_2D are macros I'd eventually like to see added to\n// gTest.  These macros can be used to declare tests which should be\n// run multiple times, once for each item in some input array.  TEST_1D\n// tests all cases in a single input array.  TEST_2D tests all\n// combinations of cases from two arrays.  The arrays must be statically\n// defined such that the GOOGLE_ARRAYSIZE() macro works on them.  Example:\n//\n// int kCases[] = {1, 2, 3, 4}\n// TEST_1D(MyFixture, MyTest, kCases) {\n//   EXPECT_GT(kCases_case, 0);\n// }\n//\n// This test iterates through the numbers 1, 2, 3, and 4 and tests that\n// they are all grater than zero.  In case of failure, the exact case\n// which failed will be printed.  The case type must be printable using\n// ostream::operator<<.\n\n// TODO(kenton):  gTest now supports \"parameterized tests\" which would be\n//   a better way to accomplish this.  Rewrite when time permits.\n\n#define TEST_1D(FIXTURE, NAME, CASES)                                      \\\n  class FIXTURE##_##NAME##_DD : public FIXTURE {                           \\\n   protected:                                                              \\\n    template <typename CaseType>                                           \\\n    void DoSingleCase(const CaseType& CASES##_case);                       \\\n  };                                                                       \\\n                                                                           \\\n  TEST_F(FIXTURE##_##NAME##_DD, NAME) {                                    \\\n    for (int i = 0; i < GOOGLE_ARRAYSIZE(CASES); i++) {                           \\\n      SCOPED_TRACE(testing::Message()                                      \\\n        << #CASES \" case #\" << i << \": \" << CASES[i]);                     \\\n      DoSingleCase(CASES[i]);                                              \\\n    }                                                                      \\\n  }                                                                        \\\n                                                                           \\\n  template <typename CaseType>                                             \\\n  void FIXTURE##_##NAME##_DD::DoSingleCase(const CaseType& CASES##_case)\n\n#define TEST_2D(FIXTURE, NAME, CASES1, CASES2)                             \\\n  class FIXTURE##_##NAME##_DD : public FIXTURE {                           \\\n   protected:                                                              \\\n    template <typename CaseType1, typename CaseType2>                      \\\n    void DoSingleCase(const CaseType1& CASES1##_case,                      \\\n                      const CaseType2& CASES2##_case);                     \\\n  };                                                                       \\\n                                                                           \\\n  TEST_F(FIXTURE##_##NAME##_DD, NAME) {                                    \\\n    for (int i = 0; i < GOOGLE_ARRAYSIZE(CASES1); i++) {                          \\\n      for (int j = 0; j < GOOGLE_ARRAYSIZE(CASES2); j++) {                        \\\n        SCOPED_TRACE(testing::Message()                                    \\\n          << #CASES1 \" case #\" << i << \": \" << CASES1[i] << \", \"           \\\n          << #CASES2 \" case #\" << j << \": \" << CASES2[j]);                 \\\n        DoSingleCase(CASES1[i], CASES2[j]);                                \\\n      }                                                                    \\\n    }                                                                      \\\n  }                                                                        \\\n                                                                           \\\n  template <typename CaseType1, typename CaseType2>                        \\\n  void FIXTURE##_##NAME##_DD::DoSingleCase(const CaseType1& CASES1##_case, \\\n                                           const CaseType2& CASES2##_case)\n\n// ===================================================================\n\nclass CodedStreamTest : public testing::Test {\n protected:\n  // Helper method used by tests for bytes warning. See implementation comment\n  // for further information.\n  static void SetupTotalBytesLimitWarningTest(\n      int total_bytes_limit, int warning_threshold,\n      vector<string>* out_errors, vector<string>* out_warnings);\n\n  // Buffer used during most of the tests. This assumes tests run sequentially.\n  static const int kBufferSize = 1024 * 64;\n  static uint8 buffer_[kBufferSize];\n};\n\nuint8 CodedStreamTest::buffer_[CodedStreamTest::kBufferSize];\n\n// We test each operation over a variety of block sizes to insure that\n// we test cases where reads or writes cross buffer boundaries, cases\n// where they don't, and cases where there is so much buffer left that\n// we can use special optimized paths that don't worry about bounds\n// checks.\nconst int kBlockSizes[] = {1, 2, 3, 5, 7, 13, 32, 1024};\n\n\n// -------------------------------------------------------------------\n// Varint tests.\n\nstruct VarintCase {\n  uint8 bytes[10];          // Encoded bytes.\n  int size;                 // Encoded size, in bytes.\n  uint64 value;             // Parsed value.\n};\n\ninline std::ostream& operator<<(std::ostream& os, const VarintCase& c) {\n  return os << c.value;\n}\n\nVarintCase kVarintCases[] = {\n  // 32-bit values\n  {{0x00}      , 1, 0},\n  {{0x01}      , 1, 1},\n  {{0x7f}      , 1, 127},\n  {{0xa2, 0x74}, 2, (0x22 << 0) | (0x74 << 7)},          // 14882\n  {{0xbe, 0xf7, 0x92, 0x84, 0x0b}, 5,                    // 2961488830\n    (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) |\n    (ULL(0x0b) << 28)},\n\n  // 64-bit\n  {{0xbe, 0xf7, 0x92, 0x84, 0x1b}, 5,                    // 7256456126\n    (0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) |\n    (ULL(0x1b) << 28)},\n  {{0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49}, 8,  // 41256202580718336\n    (0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) |\n    (ULL(0x43) << 28) | (ULL(0x49) << 35) | (ULL(0x24) << 42) |\n    (ULL(0x49) << 49)},\n  // 11964378330978735131\n  {{0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01}, 10,\n    (0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) |\n    (ULL(0x3b) << 28) | (ULL(0x56) << 35) | (ULL(0x00) << 42) |\n    (ULL(0x05) << 49) | (ULL(0x26) << 56) | (ULL(0x01) << 63)},\n};\n\nTEST_2D(CodedStreamTest, ReadVarint32, kVarintCases, kBlockSizes) {\n  memcpy(buffer_, kVarintCases_case.bytes, kVarintCases_case.size);\n  ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case);\n\n  {\n    CodedInputStream coded_input(&input);\n\n    uint32 value;\n    EXPECT_TRUE(coded_input.ReadVarint32(&value));\n    EXPECT_EQ(static_cast<uint32>(kVarintCases_case.value), value);\n  }\n\n  EXPECT_EQ(kVarintCases_case.size, input.ByteCount());\n}\n\nTEST_2D(CodedStreamTest, ReadTag, kVarintCases, kBlockSizes) {\n  memcpy(buffer_, kVarintCases_case.bytes, kVarintCases_case.size);\n  ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case);\n\n  {\n    CodedInputStream coded_input(&input);\n\n    uint32 expected_value = static_cast<uint32>(kVarintCases_case.value);\n    EXPECT_EQ(expected_value, coded_input.ReadTag());\n\n    EXPECT_TRUE(coded_input.LastTagWas(expected_value));\n    EXPECT_FALSE(coded_input.LastTagWas(expected_value + 1));\n  }\n\n  EXPECT_EQ(kVarintCases_case.size, input.ByteCount());\n}\n\n// This is the regression test that verifies that there is no issues\n// with the empty input buffers handling.\nTEST_F(CodedStreamTest, EmptyInputBeforeEos) {\n  class In : public ZeroCopyInputStream {\n   public:\n    In() : count_(0) {}\n   private:\n    virtual bool Next(const void** data, int* size) {\n      *data = NULL;\n      *size = 0;\n      return count_++ < 2;\n    }\n    virtual void BackUp(int count)  {\n      GOOGLE_LOG(FATAL) << \"Tests never call this.\";\n    }\n    virtual bool Skip(int count) {\n      GOOGLE_LOG(FATAL) << \"Tests never call this.\";\n      return false;\n    }\n    virtual int64 ByteCount() const { return 0; }\n    int count_;\n  } in;\n  CodedInputStream input(&in);\n  input.ReadTag();\n  EXPECT_TRUE(input.ConsumedEntireMessage());\n}\n\nTEST_1D(CodedStreamTest, ExpectTag, kVarintCases) {\n  // Leave one byte at the beginning of the buffer so we can read it\n  // to force the first buffer to be loaded.\n  buffer_[0] = '\\0';\n  memcpy(buffer_ + 1, kVarintCases_case.bytes, kVarintCases_case.size);\n  ArrayInputStream input(buffer_, sizeof(buffer_));\n\n  {\n    CodedInputStream coded_input(&input);\n\n    // Read one byte to force coded_input.Refill() to be called.  Otherwise,\n    // ExpectTag() will return a false negative.\n    uint8 dummy;\n    coded_input.ReadRaw(&dummy, 1);\n    EXPECT_EQ((uint)'\\0', (uint)dummy);\n\n    uint32 expected_value = static_cast<uint32>(kVarintCases_case.value);\n\n    // ExpectTag() produces false negatives for large values.\n    if (kVarintCases_case.size <= 2) {\n      EXPECT_FALSE(coded_input.ExpectTag(expected_value + 1));\n      EXPECT_TRUE(coded_input.ExpectTag(expected_value));\n    } else {\n      EXPECT_FALSE(coded_input.ExpectTag(expected_value));\n    }\n  }\n\n  if (kVarintCases_case.size <= 2) {\n    EXPECT_EQ(kVarintCases_case.size + 1, input.ByteCount());\n  } else {\n    EXPECT_EQ(1, input.ByteCount());\n  }\n}\n\nTEST_1D(CodedStreamTest, ExpectTagFromArray, kVarintCases) {\n  memcpy(buffer_, kVarintCases_case.bytes, kVarintCases_case.size);\n\n  const uint32 expected_value = static_cast<uint32>(kVarintCases_case.value);\n\n  // If the expectation succeeds, it should return a pointer past the tag.\n  if (kVarintCases_case.size <= 2) {\n    EXPECT_TRUE(NULL ==\n                CodedInputStream::ExpectTagFromArray(buffer_,\n                                                     expected_value + 1));\n    EXPECT_TRUE(buffer_ + kVarintCases_case.size ==\n                CodedInputStream::ExpectTagFromArray(buffer_, expected_value));\n  } else {\n    EXPECT_TRUE(NULL ==\n                CodedInputStream::ExpectTagFromArray(buffer_, expected_value));\n  }\n}\n\nTEST_2D(CodedStreamTest, ReadVarint64, kVarintCases, kBlockSizes) {\n  memcpy(buffer_, kVarintCases_case.bytes, kVarintCases_case.size);\n  ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case);\n\n  {\n    CodedInputStream coded_input(&input);\n\n    uint64 value;\n    EXPECT_TRUE(coded_input.ReadVarint64(&value));\n    EXPECT_EQ(kVarintCases_case.value, value);\n  }\n\n  EXPECT_EQ(kVarintCases_case.size, input.ByteCount());\n}\n\nTEST_2D(CodedStreamTest, WriteVarint32, kVarintCases, kBlockSizes) {\n  if (kVarintCases_case.value > ULL(0x00000000FFFFFFFF)) {\n    // Skip this test for the 64-bit values.\n    return;\n  }\n\n  ArrayOutputStream output(buffer_, sizeof(buffer_), kBlockSizes_case);\n\n  {\n    CodedOutputStream coded_output(&output);\n\n    coded_output.WriteVarint32(static_cast<uint32>(kVarintCases_case.value));\n    EXPECT_FALSE(coded_output.HadError());\n\n    EXPECT_EQ(kVarintCases_case.size, coded_output.ByteCount());\n  }\n\n  EXPECT_EQ(kVarintCases_case.size, output.ByteCount());\n  EXPECT_EQ(0,\n    memcmp(buffer_, kVarintCases_case.bytes, kVarintCases_case.size));\n}\n\nTEST_2D(CodedStreamTest, WriteVarint64, kVarintCases, kBlockSizes) {\n  ArrayOutputStream output(buffer_, sizeof(buffer_), kBlockSizes_case);\n\n  {\n    CodedOutputStream coded_output(&output);\n\n    coded_output.WriteVarint64(kVarintCases_case.value);\n    EXPECT_FALSE(coded_output.HadError());\n\n    EXPECT_EQ(kVarintCases_case.size, coded_output.ByteCount());\n  }\n\n  EXPECT_EQ(kVarintCases_case.size, output.ByteCount());\n  EXPECT_EQ(0,\n    memcmp(buffer_, kVarintCases_case.bytes, kVarintCases_case.size));\n}\n\n// This test causes gcc 3.3.5 (and earlier?) to give the cryptic error:\n//   \"sorry, unimplemented: `method_call_expr' not supported by dump_expr\"\n#if !defined(__GNUC__) || __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)\n\nint32 kSignExtendedVarintCases[] = {\n  0, 1, -1, 1237894, -37895138\n};\n\nTEST_2D(CodedStreamTest, WriteVarint32SignExtended,\n        kSignExtendedVarintCases, kBlockSizes) {\n  ArrayOutputStream output(buffer_, sizeof(buffer_), kBlockSizes_case);\n\n  {\n    CodedOutputStream coded_output(&output);\n\n    coded_output.WriteVarint32SignExtended(kSignExtendedVarintCases_case);\n    EXPECT_FALSE(coded_output.HadError());\n\n    if (kSignExtendedVarintCases_case < 0) {\n      EXPECT_EQ(10, coded_output.ByteCount());\n    } else {\n      EXPECT_LE(coded_output.ByteCount(), 5);\n    }\n  }\n\n  if (kSignExtendedVarintCases_case < 0) {\n    EXPECT_EQ(10, output.ByteCount());\n  } else {\n    EXPECT_LE(output.ByteCount(), 5);\n  }\n\n  // Read value back in as a varint64 and insure it matches.\n  ArrayInputStream input(buffer_, sizeof(buffer_));\n\n  {\n    CodedInputStream coded_input(&input);\n\n    uint64 value;\n    EXPECT_TRUE(coded_input.ReadVarint64(&value));\n\n    EXPECT_EQ(kSignExtendedVarintCases_case, static_cast<int64>(value));\n  }\n\n  EXPECT_EQ(output.ByteCount(), input.ByteCount());\n}\n\n#endif\n\n\n// -------------------------------------------------------------------\n// Varint failure test.\n\nstruct VarintErrorCase {\n  uint8 bytes[12];\n  int size;\n  bool can_parse;\n};\n\ninline std::ostream& operator<<(std::ostream& os, const VarintErrorCase& c) {\n  return os << \"size \" << c.size;\n}\n\nconst VarintErrorCase kVarintErrorCases[] = {\n  // Control case.  (Insures that there isn't something else wrong that\n  // makes parsing always fail.)\n  {{0x00}, 1, true},\n\n  // No input data.\n  {{}, 0, false},\n\n  // Input ends unexpectedly.\n  {{0xf0, 0xab}, 2, false},\n\n  // Input ends unexpectedly after 32 bits.\n  {{0xf0, 0xab, 0xc9, 0x9a, 0xf8, 0xb2}, 6, false},\n\n  // Longer than 10 bytes.\n  {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01},\n   11, false},\n};\n\nTEST_2D(CodedStreamTest, ReadVarint32Error, kVarintErrorCases, kBlockSizes) {\n  memcpy(buffer_, kVarintErrorCases_case.bytes, kVarintErrorCases_case.size);\n  ArrayInputStream input(buffer_, kVarintErrorCases_case.size,\n                         kBlockSizes_case);\n  CodedInputStream coded_input(&input);\n\n  uint32 value;\n  EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint32(&value));\n}\n\nTEST_2D(CodedStreamTest, ReadVarint64Error, kVarintErrorCases, kBlockSizes) {\n  memcpy(buffer_, kVarintErrorCases_case.bytes, kVarintErrorCases_case.size);\n  ArrayInputStream input(buffer_, kVarintErrorCases_case.size,\n                         kBlockSizes_case);\n  CodedInputStream coded_input(&input);\n\n  uint64 value;\n  EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint64(&value));\n}\n\n// -------------------------------------------------------------------\n// VarintSize\n\nstruct VarintSizeCase {\n  uint64 value;\n  int size;\n};\n\ninline std::ostream& operator<<(std::ostream& os, const VarintSizeCase& c) {\n  return os << c.value;\n}\n\nVarintSizeCase kVarintSizeCases[] = {\n  {0u, 1},\n  {1u, 1},\n  {127u, 1},\n  {128u, 2},\n  {758923u, 3},\n  {4000000000u, 5},\n  {ULL(41256202580718336), 8},\n  {ULL(11964378330978735131), 10},\n};\n\nTEST_1D(CodedStreamTest, VarintSize32, kVarintSizeCases) {\n  if (kVarintSizeCases_case.value > 0xffffffffu) {\n    // Skip 64-bit values.\n    return;\n  }\n\n  EXPECT_EQ(kVarintSizeCases_case.size,\n    CodedOutputStream::VarintSize32(\n      static_cast<uint32>(kVarintSizeCases_case.value)));\n}\n\nTEST_1D(CodedStreamTest, VarintSize64, kVarintSizeCases) {\n  EXPECT_EQ(kVarintSizeCases_case.size,\n    CodedOutputStream::VarintSize64(kVarintSizeCases_case.value));\n}\n\n// -------------------------------------------------------------------\n// Fixed-size int tests\n\nstruct Fixed32Case {\n  uint8 bytes[sizeof(uint32)];          // Encoded bytes.\n  uint32 value;                         // Parsed value.\n};\n\nstruct Fixed64Case {\n  uint8 bytes[sizeof(uint64)];          // Encoded bytes.\n  uint64 value;                         // Parsed value.\n};\n\ninline std::ostream& operator<<(std::ostream& os, const Fixed32Case& c) {\n  return os << \"0x\" << std::hex << c.value << std::dec;\n}\n\ninline std::ostream& operator<<(std::ostream& os, const Fixed64Case& c) {\n  return os << \"0x\" << std::hex << c.value << std::dec;\n}\n\nFixed32Case kFixed32Cases[] = {\n  {{0xef, 0xcd, 0xab, 0x90}, 0x90abcdefu},\n  {{0x12, 0x34, 0x56, 0x78}, 0x78563412u},\n};\n\nFixed64Case kFixed64Cases[] = {\n  {{0xef, 0xcd, 0xab, 0x90, 0x12, 0x34, 0x56, 0x78}, ULL(0x7856341290abcdef)},\n  {{0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}, ULL(0x8877665544332211)},\n};\n\nTEST_2D(CodedStreamTest, ReadLittleEndian32, kFixed32Cases, kBlockSizes) {\n  memcpy(buffer_, kFixed32Cases_case.bytes, sizeof(kFixed32Cases_case.bytes));\n  ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case);\n\n  {\n    CodedInputStream coded_input(&input);\n\n    uint32 value;\n    EXPECT_TRUE(coded_input.ReadLittleEndian32(&value));\n    EXPECT_EQ(kFixed32Cases_case.value, value);\n  }\n\n  EXPECT_EQ(sizeof(uint32), input.ByteCount());\n}\n\nTEST_2D(CodedStreamTest, ReadLittleEndian64, kFixed64Cases, kBlockSizes) {\n  memcpy(buffer_, kFixed64Cases_case.bytes, sizeof(kFixed64Cases_case.bytes));\n  ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case);\n\n  {\n    CodedInputStream coded_input(&input);\n\n    uint64 value;\n    EXPECT_TRUE(coded_input.ReadLittleEndian64(&value));\n    EXPECT_EQ(kFixed64Cases_case.value, value);\n  }\n\n  EXPECT_EQ(sizeof(uint64), input.ByteCount());\n}\n\nTEST_2D(CodedStreamTest, WriteLittleEndian32, kFixed32Cases, kBlockSizes) {\n  ArrayOutputStream output(buffer_, sizeof(buffer_), kBlockSizes_case);\n\n  {\n    CodedOutputStream coded_output(&output);\n\n    coded_output.WriteLittleEndian32(kFixed32Cases_case.value);\n    EXPECT_FALSE(coded_output.HadError());\n\n    EXPECT_EQ(sizeof(uint32), coded_output.ByteCount());\n  }\n\n  EXPECT_EQ(sizeof(uint32), output.ByteCount());\n  EXPECT_EQ(0, memcmp(buffer_, kFixed32Cases_case.bytes, sizeof(uint32)));\n}\n\nTEST_2D(CodedStreamTest, WriteLittleEndian64, kFixed64Cases, kBlockSizes) {\n  ArrayOutputStream output(buffer_, sizeof(buffer_), kBlockSizes_case);\n\n  {\n    CodedOutputStream coded_output(&output);\n\n    coded_output.WriteLittleEndian64(kFixed64Cases_case.value);\n    EXPECT_FALSE(coded_output.HadError());\n\n    EXPECT_EQ(sizeof(uint64), coded_output.ByteCount());\n  }\n\n  EXPECT_EQ(sizeof(uint64), output.ByteCount());\n  EXPECT_EQ(0, memcmp(buffer_, kFixed64Cases_case.bytes, sizeof(uint64)));\n}\n\n// Tests using the static methods to read fixed-size values from raw arrays.\n\nTEST_1D(CodedStreamTest, ReadLittleEndian32FromArray, kFixed32Cases) {\n  memcpy(buffer_, kFixed32Cases_case.bytes, sizeof(kFixed32Cases_case.bytes));\n\n  uint32 value;\n  const uint8* end = CodedInputStream::ReadLittleEndian32FromArray(\n      buffer_, &value);\n  EXPECT_EQ(kFixed32Cases_case.value, value);\n  EXPECT_TRUE(end == buffer_ + sizeof(value));\n}\n\nTEST_1D(CodedStreamTest, ReadLittleEndian64FromArray, kFixed64Cases) {\n  memcpy(buffer_, kFixed64Cases_case.bytes, sizeof(kFixed64Cases_case.bytes));\n\n  uint64 value;\n  const uint8* end = CodedInputStream::ReadLittleEndian64FromArray(\n      buffer_, &value);\n  EXPECT_EQ(kFixed64Cases_case.value, value);\n  EXPECT_TRUE(end == buffer_ + sizeof(value));\n}\n\n// -------------------------------------------------------------------\n// Raw reads and writes\n\nconst char kRawBytes[] = \"Some bytes which will be written and read raw.\";\n\nTEST_1D(CodedStreamTest, ReadRaw, kBlockSizes) {\n  memcpy(buffer_, kRawBytes, sizeof(kRawBytes));\n  ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case);\n  char read_buffer[sizeof(kRawBytes)];\n\n  {\n    CodedInputStream coded_input(&input);\n\n    EXPECT_TRUE(coded_input.ReadRaw(read_buffer, sizeof(kRawBytes)));\n    EXPECT_EQ(0, memcmp(kRawBytes, read_buffer, sizeof(kRawBytes)));\n  }\n\n  EXPECT_EQ(sizeof(kRawBytes), input.ByteCount());\n}\n\nTEST_1D(CodedStreamTest, WriteRaw, kBlockSizes) {\n  ArrayOutputStream output(buffer_, sizeof(buffer_), kBlockSizes_case);\n\n  {\n    CodedOutputStream coded_output(&output);\n\n    coded_output.WriteRaw(kRawBytes, sizeof(kRawBytes));\n    EXPECT_FALSE(coded_output.HadError());\n\n    EXPECT_EQ(sizeof(kRawBytes), coded_output.ByteCount());\n  }\n\n  EXPECT_EQ(sizeof(kRawBytes), output.ByteCount());\n  EXPECT_EQ(0, memcmp(buffer_, kRawBytes, sizeof(kRawBytes)));\n}\n\nTEST_1D(CodedStreamTest, ReadString, kBlockSizes) {\n  memcpy(buffer_, kRawBytes, sizeof(kRawBytes));\n  ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case);\n\n  {\n    CodedInputStream coded_input(&input);\n\n    string str;\n    EXPECT_TRUE(coded_input.ReadString(&str, strlen(kRawBytes)));\n    EXPECT_EQ(kRawBytes, str);\n  }\n\n  EXPECT_EQ(strlen(kRawBytes), input.ByteCount());\n}\n\n// Check to make sure ReadString doesn't crash on impossibly large strings.\nTEST_1D(CodedStreamTest, ReadStringImpossiblyLarge, kBlockSizes) {\n  ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case);\n\n  {\n    CodedInputStream coded_input(&input);\n\n    string str;\n    // Try to read a gigabyte.\n    EXPECT_FALSE(coded_input.ReadString(&str, 1 << 30));\n  }\n}\n\nTEST_F(CodedStreamTest, ReadStringImpossiblyLargeFromStringOnStack) {\n  // Same test as above, except directly use a buffer. This used to cause\n  // crashes while the above did not.\n  uint8 buffer[8];\n  CodedInputStream coded_input(buffer, 8);\n  string str;\n  EXPECT_FALSE(coded_input.ReadString(&str, 1 << 30));\n}\n\nTEST_F(CodedStreamTest, ReadStringImpossiblyLargeFromStringOnHeap) {\n  google::protobuf::scoped_array<uint8> buffer(new uint8[8]);\n  CodedInputStream coded_input(buffer.get(), 8);\n  string str;\n  EXPECT_FALSE(coded_input.ReadString(&str, 1 << 30));\n}\n\nTEST_1D(CodedStreamTest, ReadStringReservesMemoryOnTotalLimit, kBlockSizes) {\n  memcpy(buffer_, kRawBytes, sizeof(kRawBytes));\n  ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case);\n\n  {\n    CodedInputStream coded_input(&input);\n    coded_input.SetTotalBytesLimit(sizeof(kRawBytes), sizeof(kRawBytes));\n    EXPECT_EQ(sizeof(kRawBytes), coded_input.BytesUntilTotalBytesLimit());\n\n    string str;\n    EXPECT_TRUE(coded_input.ReadString(&str, strlen(kRawBytes)));\n    EXPECT_EQ(sizeof(kRawBytes) - strlen(kRawBytes),\n              coded_input.BytesUntilTotalBytesLimit());\n    EXPECT_EQ(kRawBytes, str);\n    // TODO(liujisi): Replace with a more meaningful test (see cl/60966023).\n    EXPECT_GE(str.capacity(), strlen(kRawBytes));\n  }\n\n  EXPECT_EQ(strlen(kRawBytes), input.ByteCount());\n}\n\nTEST_1D(CodedStreamTest, ReadStringReservesMemoryOnPushedLimit, kBlockSizes) {\n  memcpy(buffer_, kRawBytes, sizeof(kRawBytes));\n  ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case);\n\n  {\n    CodedInputStream coded_input(&input);\n    coded_input.PushLimit(sizeof(buffer_));\n\n    string str;\n    EXPECT_TRUE(coded_input.ReadString(&str, strlen(kRawBytes)));\n    EXPECT_EQ(kRawBytes, str);\n    // TODO(liujisi): Replace with a more meaningful test (see cl/60966023).\n    EXPECT_GE(str.capacity(), strlen(kRawBytes));\n  }\n\n  EXPECT_EQ(strlen(kRawBytes), input.ByteCount());\n}\n\nTEST_F(CodedStreamTest, ReadStringNoReservationIfLimitsNotSet) {\n  memcpy(buffer_, kRawBytes, sizeof(kRawBytes));\n  // Buffer size in the input must be smaller than sizeof(kRawBytes),\n  // otherwise check against capacity will fail as ReadStringInline()\n  // will handle the reading and will reserve the memory as needed.\n  ArrayInputStream input(buffer_, sizeof(buffer_), 32);\n\n  {\n    CodedInputStream coded_input(&input);\n\n    string str;\n    EXPECT_TRUE(coded_input.ReadString(&str, strlen(kRawBytes)));\n    EXPECT_EQ(kRawBytes, str);\n    // Note: this check depends on string class implementation. It\n    // expects that string will allocate more than strlen(kRawBytes)\n    // if the content of kRawBytes is appended to string in small\n    // chunks.\n    // TODO(liujisi): Replace with a more meaningful test (see cl/60966023).\n    EXPECT_GE(str.capacity(), strlen(kRawBytes));\n  }\n\n  EXPECT_EQ(strlen(kRawBytes), input.ByteCount());\n}\n\nTEST_F(CodedStreamTest, ReadStringNoReservationSizeIsNegative) {\n  memcpy(buffer_, kRawBytes, sizeof(kRawBytes));\n  // Buffer size in the input must be smaller than sizeof(kRawBytes),\n  // otherwise check against capacity will fail as ReadStringInline()\n  // will handle the reading and will reserve the memory as needed.\n  ArrayInputStream input(buffer_, sizeof(buffer_), 32);\n\n  {\n    CodedInputStream coded_input(&input);\n    coded_input.PushLimit(sizeof(buffer_));\n\n    string str;\n    EXPECT_FALSE(coded_input.ReadString(&str, -1));\n    // Note: this check depends on string class implementation. It\n    // expects that string will always allocate the same amount of\n    // memory for an empty string.\n    EXPECT_EQ(string().capacity(), str.capacity());\n  }\n}\n\nTEST_F(CodedStreamTest, ReadStringNoReservationSizeIsLarge) {\n  memcpy(buffer_, kRawBytes, sizeof(kRawBytes));\n  // Buffer size in the input must be smaller than sizeof(kRawBytes),\n  // otherwise check against capacity will fail as ReadStringInline()\n  // will handle the reading and will reserve the memory as needed.\n  ArrayInputStream input(buffer_, sizeof(buffer_), 32);\n\n  {\n    CodedInputStream coded_input(&input);\n    coded_input.PushLimit(sizeof(buffer_));\n\n    string str;\n    EXPECT_FALSE(coded_input.ReadString(&str, 1 << 30));\n    EXPECT_GT(1 << 30, str.capacity());\n  }\n}\n\nTEST_F(CodedStreamTest, ReadStringNoReservationSizeIsOverTheLimit) {\n  memcpy(buffer_, kRawBytes, sizeof(kRawBytes));\n  // Buffer size in the input must be smaller than sizeof(kRawBytes),\n  // otherwise check against capacity will fail as ReadStringInline()\n  // will handle the reading and will reserve the memory as needed.\n  ArrayInputStream input(buffer_, sizeof(buffer_), 32);\n\n  {\n    CodedInputStream coded_input(&input);\n    coded_input.PushLimit(16);\n\n    string str;\n    EXPECT_FALSE(coded_input.ReadString(&str, strlen(kRawBytes)));\n    // Note: this check depends on string class implementation. It\n    // expects that string will allocate less than strlen(kRawBytes)\n    // for an empty string.\n    EXPECT_GT(strlen(kRawBytes), str.capacity());\n  }\n}\n\nTEST_F(CodedStreamTest, ReadStringNoReservationSizeIsOverTheTotalBytesLimit) {\n  memcpy(buffer_, kRawBytes, sizeof(kRawBytes));\n  // Buffer size in the input must be smaller than sizeof(kRawBytes),\n  // otherwise check against capacity will fail as ReadStringInline()\n  // will handle the reading and will reserve the memory as needed.\n  ArrayInputStream input(buffer_, sizeof(buffer_), 32);\n\n  {\n    CodedInputStream coded_input(&input);\n    coded_input.SetTotalBytesLimit(16, 16);\n\n    string str;\n    EXPECT_FALSE(coded_input.ReadString(&str, strlen(kRawBytes)));\n    // Note: this check depends on string class implementation. It\n    // expects that string will allocate less than strlen(kRawBytes)\n    // for an empty string.\n    EXPECT_GT(strlen(kRawBytes), str.capacity());\n  }\n}\n\nTEST_F(CodedStreamTest,\n       ReadStringNoReservationSizeIsOverTheClosestLimit_GlobalLimitIsCloser) {\n  memcpy(buffer_, kRawBytes, sizeof(kRawBytes));\n  // Buffer size in the input must be smaller than sizeof(kRawBytes),\n  // otherwise check against capacity will fail as ReadStringInline()\n  // will handle the reading and will reserve the memory as needed.\n  ArrayInputStream input(buffer_, sizeof(buffer_), 32);\n\n  {\n    CodedInputStream coded_input(&input);\n    coded_input.PushLimit(sizeof(buffer_));\n    coded_input.SetTotalBytesLimit(16, 16);\n\n    string str;\n    EXPECT_FALSE(coded_input.ReadString(&str, strlen(kRawBytes)));\n    // Note: this check depends on string class implementation. It\n    // expects that string will allocate less than strlen(kRawBytes)\n    // for an empty string.\n    EXPECT_GT(strlen(kRawBytes), str.capacity());\n  }\n}\n\nTEST_F(CodedStreamTest,\n       ReadStringNoReservationSizeIsOverTheClosestLimit_LocalLimitIsCloser) {\n  memcpy(buffer_, kRawBytes, sizeof(kRawBytes));\n  // Buffer size in the input must be smaller than sizeof(kRawBytes),\n  // otherwise check against capacity will fail as ReadStringInline()\n  // will handle the reading and will reserve the memory as needed.\n  ArrayInputStream input(buffer_, sizeof(buffer_), 32);\n\n  {\n    CodedInputStream coded_input(&input);\n    coded_input.PushLimit(16);\n    coded_input.SetTotalBytesLimit(sizeof(buffer_), sizeof(buffer_));\n    EXPECT_EQ(sizeof(buffer_), coded_input.BytesUntilTotalBytesLimit());\n\n    string str;\n    EXPECT_FALSE(coded_input.ReadString(&str, strlen(kRawBytes)));\n    // Note: this check depends on string class implementation. It\n    // expects that string will allocate less than strlen(kRawBytes)\n    // for an empty string.\n    EXPECT_GT(strlen(kRawBytes), str.capacity());\n  }\n}\n\n\n// -------------------------------------------------------------------\n// Skip\n\nconst char kSkipTestBytes[] =\n  \"<Before skipping><To be skipped><After skipping>\";\n\nTEST_1D(CodedStreamTest, SkipInput, kBlockSizes) {\n  memcpy(buffer_, kSkipTestBytes, sizeof(kSkipTestBytes));\n  ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case);\n\n  {\n    CodedInputStream coded_input(&input);\n\n    string str;\n    EXPECT_TRUE(coded_input.ReadString(&str, strlen(\"<Before skipping>\")));\n    EXPECT_EQ(\"<Before skipping>\", str);\n    EXPECT_TRUE(coded_input.Skip(strlen(\"<To be skipped>\")));\n    EXPECT_TRUE(coded_input.ReadString(&str, strlen(\"<After skipping>\")));\n    EXPECT_EQ(\"<After skipping>\", str);\n  }\n\n  EXPECT_EQ(strlen(kSkipTestBytes), input.ByteCount());\n}\n\n// -------------------------------------------------------------------\n// GetDirectBufferPointer\n\nTEST_F(CodedStreamTest, GetDirectBufferPointerInput) {\n  ArrayInputStream input(buffer_, sizeof(buffer_), 8);\n  CodedInputStream coded_input(&input);\n\n  const void* ptr;\n  int size;\n\n  EXPECT_TRUE(coded_input.GetDirectBufferPointer(&ptr, &size));\n  EXPECT_EQ(buffer_, ptr);\n  EXPECT_EQ(8, size);\n\n  // Peeking again should return the same pointer.\n  EXPECT_TRUE(coded_input.GetDirectBufferPointer(&ptr, &size));\n  EXPECT_EQ(buffer_, ptr);\n  EXPECT_EQ(8, size);\n\n  // Skip forward in the same buffer then peek again.\n  EXPECT_TRUE(coded_input.Skip(3));\n  EXPECT_TRUE(coded_input.GetDirectBufferPointer(&ptr, &size));\n  EXPECT_EQ(buffer_ + 3, ptr);\n  EXPECT_EQ(5, size);\n\n  // Skip to end of buffer and peek -- should get next buffer.\n  EXPECT_TRUE(coded_input.Skip(5));\n  EXPECT_TRUE(coded_input.GetDirectBufferPointer(&ptr, &size));\n  EXPECT_EQ(buffer_ + 8, ptr);\n  EXPECT_EQ(8, size);\n}\n\nTEST_F(CodedStreamTest, GetDirectBufferPointerInlineInput) {\n  ArrayInputStream input(buffer_, sizeof(buffer_), 8);\n  CodedInputStream coded_input(&input);\n\n  const void* ptr;\n  int size;\n\n  coded_input.GetDirectBufferPointerInline(&ptr, &size);\n  EXPECT_EQ(buffer_, ptr);\n  EXPECT_EQ(8, size);\n\n  // Peeking again should return the same pointer.\n  coded_input.GetDirectBufferPointerInline(&ptr, &size);\n  EXPECT_EQ(buffer_, ptr);\n  EXPECT_EQ(8, size);\n\n  // Skip forward in the same buffer then peek again.\n  EXPECT_TRUE(coded_input.Skip(3));\n  coded_input.GetDirectBufferPointerInline(&ptr, &size);\n  EXPECT_EQ(buffer_ + 3, ptr);\n  EXPECT_EQ(5, size);\n\n  // Skip to end of buffer and peek -- should return false and provide an empty\n  // buffer. It does not try to Refresh().\n  EXPECT_TRUE(coded_input.Skip(5));\n  coded_input.GetDirectBufferPointerInline(&ptr, &size);\n  EXPECT_EQ(buffer_ + 8, ptr);\n  EXPECT_EQ(0, size);\n}\n\nTEST_F(CodedStreamTest, GetDirectBufferPointerOutput) {\n  ArrayOutputStream output(buffer_, sizeof(buffer_), 8);\n  CodedOutputStream coded_output(&output);\n\n  void* ptr;\n  int size;\n\n  EXPECT_TRUE(coded_output.GetDirectBufferPointer(&ptr, &size));\n  EXPECT_EQ(buffer_, ptr);\n  EXPECT_EQ(8, size);\n\n  // Peeking again should return the same pointer.\n  EXPECT_TRUE(coded_output.GetDirectBufferPointer(&ptr, &size));\n  EXPECT_EQ(buffer_, ptr);\n  EXPECT_EQ(8, size);\n\n  // Skip forward in the same buffer then peek again.\n  EXPECT_TRUE(coded_output.Skip(3));\n  EXPECT_TRUE(coded_output.GetDirectBufferPointer(&ptr, &size));\n  EXPECT_EQ(buffer_ + 3, ptr);\n  EXPECT_EQ(5, size);\n\n  // Skip to end of buffer and peek -- should get next buffer.\n  EXPECT_TRUE(coded_output.Skip(5));\n  EXPECT_TRUE(coded_output.GetDirectBufferPointer(&ptr, &size));\n  EXPECT_EQ(buffer_ + 8, ptr);\n  EXPECT_EQ(8, size);\n\n  // Skip over multiple buffers.\n  EXPECT_TRUE(coded_output.Skip(22));\n  EXPECT_TRUE(coded_output.GetDirectBufferPointer(&ptr, &size));\n  EXPECT_EQ(buffer_ + 30, ptr);\n  EXPECT_EQ(2, size);\n}\n\n// -------------------------------------------------------------------\n// Limits\n\nTEST_1D(CodedStreamTest, BasicLimit, kBlockSizes) {\n  ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case);\n\n  {\n    CodedInputStream coded_input(&input);\n\n    EXPECT_EQ(-1, coded_input.BytesUntilLimit());\n    CodedInputStream::Limit limit = coded_input.PushLimit(8);\n\n    // Read until we hit the limit.\n    uint32 value;\n    EXPECT_EQ(8, coded_input.BytesUntilLimit());\n    EXPECT_TRUE(coded_input.ReadLittleEndian32(&value));\n    EXPECT_EQ(4, coded_input.BytesUntilLimit());\n    EXPECT_TRUE(coded_input.ReadLittleEndian32(&value));\n    EXPECT_EQ(0, coded_input.BytesUntilLimit());\n    EXPECT_FALSE(coded_input.ReadLittleEndian32(&value));\n    EXPECT_EQ(0, coded_input.BytesUntilLimit());\n\n    coded_input.PopLimit(limit);\n\n    EXPECT_EQ(-1, coded_input.BytesUntilLimit());\n    EXPECT_TRUE(coded_input.ReadLittleEndian32(&value));\n  }\n\n  EXPECT_EQ(12, input.ByteCount());\n}\n\n// Test what happens when we push two limits where the second (top) one is\n// shorter.\nTEST_1D(CodedStreamTest, SmallLimitOnTopOfBigLimit, kBlockSizes) {\n  ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case);\n\n  {\n    CodedInputStream coded_input(&input);\n\n    EXPECT_EQ(-1, coded_input.BytesUntilLimit());\n    CodedInputStream::Limit limit1 = coded_input.PushLimit(8);\n    EXPECT_EQ(8, coded_input.BytesUntilLimit());\n    CodedInputStream::Limit limit2 = coded_input.PushLimit(4);\n\n    uint32 value;\n\n    // Read until we hit limit2, the top and shortest limit.\n    EXPECT_EQ(4, coded_input.BytesUntilLimit());\n    EXPECT_TRUE(coded_input.ReadLittleEndian32(&value));\n    EXPECT_EQ(0, coded_input.BytesUntilLimit());\n    EXPECT_FALSE(coded_input.ReadLittleEndian32(&value));\n    EXPECT_EQ(0, coded_input.BytesUntilLimit());\n\n    coded_input.PopLimit(limit2);\n\n    // Read until we hit limit1.\n    EXPECT_EQ(4, coded_input.BytesUntilLimit());\n    EXPECT_TRUE(coded_input.ReadLittleEndian32(&value));\n    EXPECT_EQ(0, coded_input.BytesUntilLimit());\n    EXPECT_FALSE(coded_input.ReadLittleEndian32(&value));\n    EXPECT_EQ(0, coded_input.BytesUntilLimit());\n\n    coded_input.PopLimit(limit1);\n\n    // No more limits.\n    EXPECT_EQ(-1, coded_input.BytesUntilLimit());\n    EXPECT_TRUE(coded_input.ReadLittleEndian32(&value));\n  }\n\n  EXPECT_EQ(12, input.ByteCount());\n}\n\n// Test what happens when we push two limits where the second (top) one is\n// longer.  In this case, the top limit is shortened to match the previous\n// limit.\nTEST_1D(CodedStreamTest, BigLimitOnTopOfSmallLimit, kBlockSizes) {\n  ArrayInputStream input(buffer_, sizeof(buffer_), kBlockSizes_case);\n\n  {\n    CodedInputStream coded_input(&input);\n\n    EXPECT_EQ(-1, coded_input.BytesUntilLimit());\n    CodedInputStream::Limit limit1 = coded_input.PushLimit(4);\n    EXPECT_EQ(4, coded_input.BytesUntilLimit());\n    CodedInputStream::Limit limit2 = coded_input.PushLimit(8);\n\n    uint32 value;\n\n    // Read until we hit limit2.  Except, wait!  limit1 is shorter, so\n    // we end up hitting that first, despite having 4 bytes to go on\n    // limit2.\n    EXPECT_EQ(4, coded_input.BytesUntilLimit());\n    EXPECT_TRUE(coded_input.ReadLittleEndian32(&value));\n    EXPECT_EQ(0, coded_input.BytesUntilLimit());\n    EXPECT_FALSE(coded_input.ReadLittleEndian32(&value));\n    EXPECT_EQ(0, coded_input.BytesUntilLimit());\n\n    coded_input.PopLimit(limit2);\n\n    // OK, popped limit2, now limit1 is on top, which we've already hit.\n    EXPECT_EQ(0, coded_input.BytesUntilLimit());\n    EXPECT_FALSE(coded_input.ReadLittleEndian32(&value));\n    EXPECT_EQ(0, coded_input.BytesUntilLimit());\n\n    coded_input.PopLimit(limit1);\n\n    // No more limits.\n    EXPECT_EQ(-1, coded_input.BytesUntilLimit());\n    EXPECT_TRUE(coded_input.ReadLittleEndian32(&value));\n  }\n\n  EXPECT_EQ(8, input.ByteCount());\n}\n\nTEST_F(CodedStreamTest, ExpectAtEnd) {\n  // Test ExpectAtEnd(), which is based on limits.\n  ArrayInputStream input(buffer_, sizeof(buffer_));\n  CodedInputStream coded_input(&input);\n\n  EXPECT_FALSE(coded_input.ExpectAtEnd());\n\n  CodedInputStream::Limit limit = coded_input.PushLimit(4);\n\n  uint32 value;\n  EXPECT_TRUE(coded_input.ReadLittleEndian32(&value));\n  EXPECT_TRUE(coded_input.ExpectAtEnd());\n\n  coded_input.PopLimit(limit);\n  EXPECT_FALSE(coded_input.ExpectAtEnd());\n}\n\nTEST_F(CodedStreamTest, NegativeLimit) {\n  // Check what happens when we push a negative limit.\n  ArrayInputStream input(buffer_, sizeof(buffer_));\n  CodedInputStream coded_input(&input);\n\n  CodedInputStream::Limit limit = coded_input.PushLimit(-1234);\n  // BytesUntilLimit() returns -1 to mean \"no limit\", which actually means\n  // \"the limit is INT_MAX relative to the beginning of the stream\".\n  EXPECT_EQ(-1, coded_input.BytesUntilLimit());\n  coded_input.PopLimit(limit);\n}\n\nTEST_F(CodedStreamTest, NegativeLimitAfterReading) {\n  // Check what happens when we push a negative limit.\n  ArrayInputStream input(buffer_, sizeof(buffer_));\n  CodedInputStream coded_input(&input);\n  ASSERT_TRUE(coded_input.Skip(128));\n\n  CodedInputStream::Limit limit = coded_input.PushLimit(-64);\n  // BytesUntilLimit() returns -1 to mean \"no limit\", which actually means\n  // \"the limit is INT_MAX relative to the beginning of the stream\".\n  EXPECT_EQ(-1, coded_input.BytesUntilLimit());\n  coded_input.PopLimit(limit);\n}\n\nTEST_F(CodedStreamTest, OverflowLimit) {\n  // Check what happens when we push a limit large enough that its absolute\n  // position is more than 2GB into the stream.\n  ArrayInputStream input(buffer_, sizeof(buffer_));\n  CodedInputStream coded_input(&input);\n  ASSERT_TRUE(coded_input.Skip(128));\n\n  CodedInputStream::Limit limit = coded_input.PushLimit(INT_MAX);\n  // BytesUntilLimit() returns -1 to mean \"no limit\", which actually means\n  // \"the limit is INT_MAX relative to the beginning of the stream\".\n  EXPECT_EQ(-1, coded_input.BytesUntilLimit());\n  coded_input.PopLimit(limit);\n}\n\nTEST_F(CodedStreamTest, TotalBytesLimit) {\n  ArrayInputStream input(buffer_, sizeof(buffer_));\n  CodedInputStream coded_input(&input);\n  coded_input.SetTotalBytesLimit(16, -1);\n  EXPECT_EQ(16, coded_input.BytesUntilTotalBytesLimit());\n\n  string str;\n  EXPECT_TRUE(coded_input.ReadString(&str, 16));\n  EXPECT_EQ(0, coded_input.BytesUntilTotalBytesLimit());\n\n  vector<string> errors;\n\n  {\n    ScopedMemoryLog error_log;\n    EXPECT_FALSE(coded_input.ReadString(&str, 1));\n    errors = error_log.GetMessages(ERROR);\n  }\n\n  ASSERT_EQ(1, errors.size());\n  EXPECT_PRED_FORMAT2(testing::IsSubstring,\n    \"A protocol message was rejected because it was too big\", errors[0]);\n\n  coded_input.SetTotalBytesLimit(32, -1);\n  EXPECT_EQ(16, coded_input.BytesUntilTotalBytesLimit());\n  EXPECT_TRUE(coded_input.ReadString(&str, 16));\n  EXPECT_EQ(0, coded_input.BytesUntilTotalBytesLimit());\n}\n\nTEST_F(CodedStreamTest, TotalBytesLimitNotValidMessageEnd) {\n  // total_bytes_limit_ is not a valid place for a message to end.\n\n  ArrayInputStream input(buffer_, sizeof(buffer_));\n  CodedInputStream coded_input(&input);\n\n  // Set both total_bytes_limit and a regular limit at 16 bytes.\n  coded_input.SetTotalBytesLimit(16, -1);\n  CodedInputStream::Limit limit = coded_input.PushLimit(16);\n\n  // Read 16 bytes.\n  string str;\n  EXPECT_TRUE(coded_input.ReadString(&str, 16));\n\n  // Read a tag.  Should fail, but report being a valid endpoint since it's\n  // a regular limit.\n  EXPECT_EQ(0, coded_input.ReadTag());\n  EXPECT_TRUE(coded_input.ConsumedEntireMessage());\n\n  // Pop the limit.\n  coded_input.PopLimit(limit);\n\n  // Read a tag.  Should fail, and report *not* being a valid endpoint, since\n  // this time we're hitting the total bytes limit.\n  EXPECT_EQ(0, coded_input.ReadTag());\n  EXPECT_FALSE(coded_input.ConsumedEntireMessage());\n}\n\n// This method is used by the tests below.\n// It constructs a CodedInputStream with the given limits and tries to read 2KiB\n// of data from it. Then it returns the logged errors and warnings in the given\n// vectors.\nvoid CodedStreamTest::SetupTotalBytesLimitWarningTest(\n    int total_bytes_limit, int warning_threshold,\n    vector<string>* out_errors, vector<string>* out_warnings) {\n  ArrayInputStream raw_input(buffer_, sizeof(buffer_), 128);\n\n  ScopedMemoryLog scoped_log;\n  {\n    CodedInputStream input(&raw_input);\n    input.SetTotalBytesLimit(total_bytes_limit, warning_threshold);\n    string str;\n    EXPECT_TRUE(input.ReadString(&str, 2048));\n  }\n\n  *out_errors = scoped_log.GetMessages(ERROR);\n  *out_warnings = scoped_log.GetMessages(WARNING);\n}\n\nTEST_F(CodedStreamTest, TotalBytesLimitWarning) {\n  vector<string> errors;\n  vector<string> warnings;\n  SetupTotalBytesLimitWarningTest(10240, 1024, &errors, &warnings);\n\n  EXPECT_EQ(0, errors.size());\n\n  ASSERT_EQ(2, warnings.size());\n  EXPECT_PRED_FORMAT2(testing::IsSubstring,\n    \"Reading dangerously large protocol message.  If the message turns out to \"\n    \"be larger than 10240 bytes, parsing will be halted for security reasons.\",\n    warnings[0]);\n  EXPECT_PRED_FORMAT2(testing::IsSubstring,\n    \"The total number of bytes read was 2048\",\n    warnings[1]);\n}\n\nTEST_F(CodedStreamTest, TotalBytesLimitWarningDisabled) {\n  vector<string> errors;\n  vector<string> warnings;\n\n  // Test with -1\n  SetupTotalBytesLimitWarningTest(10240, -1, &errors, &warnings);\n  EXPECT_EQ(0, errors.size());\n  EXPECT_EQ(0, warnings.size());\n\n  // Test again with -2, expecting the same result\n  SetupTotalBytesLimitWarningTest(10240, -2, &errors, &warnings);\n  EXPECT_EQ(0, errors.size());\n  EXPECT_EQ(0, warnings.size());\n}\n\n\nTEST_F(CodedStreamTest, RecursionLimit) {\n  ArrayInputStream input(buffer_, sizeof(buffer_));\n  CodedInputStream coded_input(&input);\n  coded_input.SetRecursionLimit(4);\n\n  // This is way too much testing for a counter.\n  EXPECT_TRUE(coded_input.IncrementRecursionDepth());      // 1\n  EXPECT_TRUE(coded_input.IncrementRecursionDepth());      // 2\n  EXPECT_TRUE(coded_input.IncrementRecursionDepth());      // 3\n  EXPECT_TRUE(coded_input.IncrementRecursionDepth());      // 4\n  EXPECT_FALSE(coded_input.IncrementRecursionDepth());     // 5\n  EXPECT_FALSE(coded_input.IncrementRecursionDepth());     // 6\n  coded_input.DecrementRecursionDepth();                   // 5\n  EXPECT_FALSE(coded_input.IncrementRecursionDepth());     // 6\n  coded_input.DecrementRecursionDepth();                   // 5\n  coded_input.DecrementRecursionDepth();                   // 4\n  coded_input.DecrementRecursionDepth();                   // 3\n  EXPECT_TRUE(coded_input.IncrementRecursionDepth());      // 4\n  EXPECT_FALSE(coded_input.IncrementRecursionDepth());     // 5\n  coded_input.DecrementRecursionDepth();                   // 4\n  coded_input.DecrementRecursionDepth();                   // 3\n  coded_input.DecrementRecursionDepth();                   // 2\n  coded_input.DecrementRecursionDepth();                   // 1\n  coded_input.DecrementRecursionDepth();                   // 0\n  coded_input.DecrementRecursionDepth();                   // 0\n  coded_input.DecrementRecursionDepth();                   // 0\n  EXPECT_TRUE(coded_input.IncrementRecursionDepth());      // 1\n  EXPECT_TRUE(coded_input.IncrementRecursionDepth());      // 2\n  EXPECT_TRUE(coded_input.IncrementRecursionDepth());      // 3\n  EXPECT_TRUE(coded_input.IncrementRecursionDepth());      // 4\n  EXPECT_FALSE(coded_input.IncrementRecursionDepth());     // 5\n\n  coded_input.SetRecursionLimit(6);\n  EXPECT_TRUE(coded_input.IncrementRecursionDepth());      // 6\n  EXPECT_FALSE(coded_input.IncrementRecursionDepth());     // 7\n}\n\n\nclass ReallyBigInputStream : public ZeroCopyInputStream {\n public:\n  ReallyBigInputStream() : backup_amount_(0), buffer_count_(0) {}\n  ~ReallyBigInputStream() {}\n\n  // implements ZeroCopyInputStream ----------------------------------\n  bool Next(const void** data, int* size) {\n    // We only expect BackUp() to be called at the end.\n    EXPECT_EQ(0, backup_amount_);\n\n    switch (buffer_count_++) {\n      case 0:\n        *data = buffer_;\n        *size = sizeof(buffer_);\n        return true;\n      case 1:\n        // Return an enormously large buffer that, when combined with the 1k\n        // returned already, should overflow the total_bytes_read_ counter in\n        // CodedInputStream.  Note that we'll only read the first 1024 bytes\n        // of this buffer so it's OK that we have it point at buffer_.\n        *data = buffer_;\n        *size = INT_MAX;\n        return true;\n      default:\n        return false;\n    }\n  }\n\n  void BackUp(int count) {\n    backup_amount_ = count;\n  }\n\n  bool Skip(int count)    { GOOGLE_LOG(FATAL) << \"Not implemented.\"; return false; }\n  int64 ByteCount() const { GOOGLE_LOG(FATAL) << \"Not implemented.\"; return 0; }\n\n  int backup_amount_;\n\n private:\n  char buffer_[1024];\n  int64 buffer_count_;\n};\n\nTEST_F(CodedStreamTest, InputOver2G) {\n  // CodedInputStream should gracefully handle input over 2G and call\n  // input.BackUp() with the correct number of bytes on destruction.\n  ReallyBigInputStream input;\n\n  vector<string> errors;\n\n  {\n    ScopedMemoryLog error_log;\n    CodedInputStream coded_input(&input);\n    string str;\n    EXPECT_TRUE(coded_input.ReadString(&str, 512));\n    EXPECT_TRUE(coded_input.ReadString(&str, 1024));\n    errors = error_log.GetMessages(ERROR);\n  }\n\n  EXPECT_EQ(INT_MAX - 512, input.backup_amount_);\n  EXPECT_EQ(0, errors.size());\n}\n\n// ===================================================================\n\n\n}  // namespace\n}  // namespace io\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/gzip_stream.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: brianolson@google.com (Brian Olson)\n//\n// This file contains the implementation of classes GzipInputStream and\n// GzipOutputStream.\n\n\n#if HAVE_ZLIB\n#include <google/protobuf/io/gzip_stream.h>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\n\nstatic const int kDefaultBufferSize = 65536;\n\nGzipInputStream::GzipInputStream(\n    ZeroCopyInputStream* sub_stream, Format format, int buffer_size)\n    : format_(format), sub_stream_(sub_stream), zerror_(Z_OK), byte_count_(0) {\n  zcontext_.state = Z_NULL;\n  zcontext_.zalloc = Z_NULL;\n  zcontext_.zfree = Z_NULL;\n  zcontext_.opaque = Z_NULL;\n  zcontext_.total_out = 0;\n  zcontext_.next_in = NULL;\n  zcontext_.avail_in = 0;\n  zcontext_.total_in = 0;\n  zcontext_.msg = NULL;\n  if (buffer_size == -1) {\n    output_buffer_length_ = kDefaultBufferSize;\n  } else {\n    output_buffer_length_ = buffer_size;\n  }\n  output_buffer_ = operator new(output_buffer_length_);\n  GOOGLE_CHECK(output_buffer_ != NULL);\n  zcontext_.next_out = static_cast<Bytef*>(output_buffer_);\n  zcontext_.avail_out = output_buffer_length_;\n  output_position_ = output_buffer_;\n}\nGzipInputStream::~GzipInputStream() {\n  operator delete(output_buffer_);\n  zerror_ = inflateEnd(&zcontext_);\n}\n\nstatic inline int internalInflateInit2(\n    z_stream* zcontext, GzipInputStream::Format format) {\n  int windowBitsFormat = 0;\n  switch (format) {\n    case GzipInputStream::GZIP: windowBitsFormat = 16; break;\n    case GzipInputStream::AUTO: windowBitsFormat = 32; break;\n    case GzipInputStream::ZLIB: windowBitsFormat = 0; break;\n  }\n  return inflateInit2(zcontext, /* windowBits */15 | windowBitsFormat);\n}\n\nint GzipInputStream::Inflate(int flush) {\n  if ((zerror_ == Z_OK) && (zcontext_.avail_out == 0)) {\n    // previous inflate filled output buffer. don't change input params yet.\n  } else if (zcontext_.avail_in == 0) {\n    const void* in;\n    int in_size;\n    bool first = zcontext_.next_in == NULL;\n    bool ok = sub_stream_->Next(&in, &in_size);\n    if (!ok) {\n      zcontext_.next_out = NULL;\n      zcontext_.avail_out = 0;\n      return Z_STREAM_END;\n    }\n    zcontext_.next_in = static_cast<Bytef*>(const_cast<void*>(in));\n    zcontext_.avail_in = in_size;\n    if (first) {\n      int error = internalInflateInit2(&zcontext_, format_);\n      if (error != Z_OK) {\n        return error;\n      }\n    }\n  }\n  zcontext_.next_out = static_cast<Bytef*>(output_buffer_);\n  zcontext_.avail_out = output_buffer_length_;\n  output_position_ = output_buffer_;\n  int error = inflate(&zcontext_, flush);\n  return error;\n}\n\nvoid GzipInputStream::DoNextOutput(const void** data, int* size) {\n  *data = output_position_;\n  *size = ((uintptr_t)zcontext_.next_out) - ((uintptr_t)output_position_);\n  output_position_ = zcontext_.next_out;\n}\n\n// implements ZeroCopyInputStream ----------------------------------\nbool GzipInputStream::Next(const void** data, int* size) {\n  bool ok = (zerror_ == Z_OK) || (zerror_ == Z_STREAM_END)\n      || (zerror_ == Z_BUF_ERROR);\n  if ((!ok) || (zcontext_.next_out == NULL)) {\n    return false;\n  }\n  if (zcontext_.next_out != output_position_) {\n    DoNextOutput(data, size);\n    return true;\n  }\n  if (zerror_ == Z_STREAM_END) {\n    if (zcontext_.next_out != NULL) {\n      // sub_stream_ may have concatenated streams to follow\n      zerror_ = inflateEnd(&zcontext_);\n      byte_count_ += zcontext_.total_out;\n      if (zerror_ != Z_OK) {\n        return false;\n      }\n      zerror_ = internalInflateInit2(&zcontext_, format_);\n      if (zerror_ != Z_OK) {\n        return false;\n      }\n    } else {\n      *data = NULL;\n      *size = 0;\n      return false;\n    }\n  }\n  zerror_ = Inflate(Z_NO_FLUSH);\n  if ((zerror_ == Z_STREAM_END) && (zcontext_.next_out == NULL)) {\n    // The underlying stream's Next returned false inside Inflate.\n    return false;\n  }\n  ok = (zerror_ == Z_OK) || (zerror_ == Z_STREAM_END)\n      || (zerror_ == Z_BUF_ERROR);\n  if (!ok) {\n    return false;\n  }\n  DoNextOutput(data, size);\n  return true;\n}\nvoid GzipInputStream::BackUp(int count) {\n  output_position_ = reinterpret_cast<void*>(\n      reinterpret_cast<uintptr_t>(output_position_) - count);\n}\nbool GzipInputStream::Skip(int count) {\n  const void* data;\n  int size;\n  bool ok = Next(&data, &size);\n  while (ok && (size < count)) {\n    count -= size;\n    ok = Next(&data, &size);\n  }\n  if (size > count) {\n    BackUp(size - count);\n  }\n  return ok;\n}\nint64 GzipInputStream::ByteCount() const {\n  int64 ret = byte_count_ + zcontext_.total_out;\n  if (zcontext_.next_out != NULL && output_position_ != NULL) {\n    ret += reinterpret_cast<uintptr_t>(zcontext_.next_out) -\n           reinterpret_cast<uintptr_t>(output_position_);\n  }\n  return ret;\n}\n\n// =========================================================================\n\nGzipOutputStream::Options::Options()\n    : format(GZIP),\n      buffer_size(kDefaultBufferSize),\n      compression_level(Z_DEFAULT_COMPRESSION),\n      compression_strategy(Z_DEFAULT_STRATEGY) {}\n\nGzipOutputStream::GzipOutputStream(ZeroCopyOutputStream* sub_stream) {\n  Init(sub_stream, Options());\n}\n\nGzipOutputStream::GzipOutputStream(ZeroCopyOutputStream* sub_stream,\n                                   const Options& options) {\n  Init(sub_stream, options);\n}\n\nvoid GzipOutputStream::Init(ZeroCopyOutputStream* sub_stream,\n                            const Options& options) {\n  sub_stream_ = sub_stream;\n  sub_data_ = NULL;\n  sub_data_size_ = 0;\n\n  input_buffer_length_ = options.buffer_size;\n  input_buffer_ = operator new(input_buffer_length_);\n  GOOGLE_CHECK(input_buffer_ != NULL);\n\n  zcontext_.zalloc = Z_NULL;\n  zcontext_.zfree = Z_NULL;\n  zcontext_.opaque = Z_NULL;\n  zcontext_.next_out = NULL;\n  zcontext_.avail_out = 0;\n  zcontext_.total_out = 0;\n  zcontext_.next_in = NULL;\n  zcontext_.avail_in = 0;\n  zcontext_.total_in = 0;\n  zcontext_.msg = NULL;\n  // default to GZIP format\n  int windowBitsFormat = 16;\n  if (options.format == ZLIB) {\n    windowBitsFormat = 0;\n  }\n  zerror_ = deflateInit2(\n      &zcontext_,\n      options.compression_level,\n      Z_DEFLATED,\n      /* windowBits */15 | windowBitsFormat,\n      /* memLevel (default) */8,\n      options.compression_strategy);\n}\n\nGzipOutputStream::~GzipOutputStream() {\n  Close();\n  operator delete(input_buffer_);\n}\n\n// private\nint GzipOutputStream::Deflate(int flush) {\n  int error = Z_OK;\n  do {\n    if ((sub_data_ == NULL) || (zcontext_.avail_out == 0)) {\n      bool ok = sub_stream_->Next(&sub_data_, &sub_data_size_);\n      if (!ok) {\n        sub_data_ = NULL;\n        sub_data_size_ = 0;\n        return Z_BUF_ERROR;\n      }\n      GOOGLE_CHECK_GT(sub_data_size_, 0);\n      zcontext_.next_out = static_cast<Bytef*>(sub_data_);\n      zcontext_.avail_out = sub_data_size_;\n    }\n    error = deflate(&zcontext_, flush);\n  } while (error == Z_OK && zcontext_.avail_out == 0);\n  if ((flush == Z_FULL_FLUSH) || (flush == Z_FINISH)) {\n    // Notify lower layer of data.\n    sub_stream_->BackUp(zcontext_.avail_out);\n    // We don't own the buffer anymore.\n    sub_data_ = NULL;\n    sub_data_size_ = 0;\n  }\n  return error;\n}\n\n// implements ZeroCopyOutputStream ---------------------------------\nbool GzipOutputStream::Next(void** data, int* size) {\n  if ((zerror_ != Z_OK) && (zerror_ != Z_BUF_ERROR)) {\n    return false;\n  }\n  if (zcontext_.avail_in != 0) {\n    zerror_ = Deflate(Z_NO_FLUSH);\n    if (zerror_ != Z_OK) {\n      return false;\n    }\n  }\n  if (zcontext_.avail_in == 0) {\n    // all input was consumed. reset the buffer.\n    zcontext_.next_in = static_cast<Bytef*>(input_buffer_);\n    zcontext_.avail_in = input_buffer_length_;\n    *data = input_buffer_;\n    *size = input_buffer_length_;\n  } else {\n    // The loop in Deflate should consume all avail_in\n    GOOGLE_LOG(DFATAL) << \"Deflate left bytes unconsumed\";\n  }\n  return true;\n}\nvoid GzipOutputStream::BackUp(int count) {\n  GOOGLE_CHECK_GE(zcontext_.avail_in, count);\n  zcontext_.avail_in -= count;\n}\nint64 GzipOutputStream::ByteCount() const {\n  return zcontext_.total_in + zcontext_.avail_in;\n}\n\nbool GzipOutputStream::Flush() {\n  zerror_ = Deflate(Z_FULL_FLUSH);\n  // Return true if the flush succeeded or if it was a no-op.\n  return  (zerror_ == Z_OK) ||\n      (zerror_ == Z_BUF_ERROR && zcontext_.avail_in == 0 &&\n       zcontext_.avail_out != 0);\n}\n\nbool GzipOutputStream::Close() {\n  if ((zerror_ != Z_OK) && (zerror_ != Z_BUF_ERROR)) {\n    return false;\n  }\n  do {\n    zerror_ = Deflate(Z_FINISH);\n  } while (zerror_ == Z_OK);\n  zerror_ = deflateEnd(&zcontext_);\n  bool ok = zerror_ == Z_OK;\n  zerror_ = Z_STREAM_END;\n  return ok;\n}\n\n}  // namespace io\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // HAVE_ZLIB\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/gzip_stream.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: brianolson@google.com (Brian Olson)\n//\n// This file contains the definition for classes GzipInputStream and\n// GzipOutputStream.\n//\n// GzipInputStream decompresses data from an underlying\n// ZeroCopyInputStream and provides the decompressed data as a\n// ZeroCopyInputStream.\n//\n// GzipOutputStream is an ZeroCopyOutputStream that compresses data to\n// an underlying ZeroCopyOutputStream.\n\n#ifndef GOOGLE_PROTOBUF_IO_GZIP_STREAM_H__\n#define GOOGLE_PROTOBUF_IO_GZIP_STREAM_H__\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <zlib.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\n\n// A ZeroCopyInputStream that reads compressed data through zlib\nclass LIBPROTOBUF_EXPORT GzipInputStream : public ZeroCopyInputStream {\n public:\n  // Format key for constructor\n  enum Format {\n    // zlib will autodetect gzip header or deflate stream\n    AUTO = 0,\n\n    // GZIP streams have some extra header data for file attributes.\n    GZIP = 1,\n\n    // Simpler zlib stream format.\n    ZLIB = 2,\n  };\n\n  // buffer_size and format may be -1 for default of 64kB and GZIP format\n  explicit GzipInputStream(\n      ZeroCopyInputStream* sub_stream,\n      Format format = AUTO,\n      int buffer_size = -1);\n  virtual ~GzipInputStream();\n\n  // Return last error message or NULL if no error.\n  inline const char* ZlibErrorMessage() const {\n    return zcontext_.msg;\n  }\n  inline int ZlibErrorCode() const {\n    return zerror_;\n  }\n\n  // implements ZeroCopyInputStream ----------------------------------\n  bool Next(const void** data, int* size);\n  void BackUp(int count);\n  bool Skip(int count);\n  int64 ByteCount() const;\n\n private:\n  Format format_;\n\n  ZeroCopyInputStream* sub_stream_;\n\n  z_stream zcontext_;\n  int zerror_;\n\n  void* output_buffer_;\n  void* output_position_;\n  size_t output_buffer_length_;\n  int64 byte_count_;\n\n  int Inflate(int flush);\n  void DoNextOutput(const void** data, int* size);\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GzipInputStream);\n};\n\n\nclass LIBPROTOBUF_EXPORT GzipOutputStream : public ZeroCopyOutputStream {\n public:\n  // Format key for constructor\n  enum Format {\n    // GZIP streams have some extra header data for file attributes.\n    GZIP = 1,\n\n    // Simpler zlib stream format.\n    ZLIB = 2,\n  };\n\n  struct Options {\n    // Defaults to GZIP.\n    Format format;\n\n    // What size buffer to use internally.  Defaults to 64kB.\n    int buffer_size;\n\n    // A number between 0 and 9, where 0 is no compression and 9 is best\n    // compression.  Defaults to Z_DEFAULT_COMPRESSION (see zlib.h).\n    int compression_level;\n\n    // Defaults to Z_DEFAULT_STRATEGY.  Can also be set to Z_FILTERED,\n    // Z_HUFFMAN_ONLY, or Z_RLE.  See the documentation for deflateInit2 in\n    // zlib.h for definitions of these constants.\n    int compression_strategy;\n\n    Options();  // Initializes with default values.\n  };\n\n  // Create a GzipOutputStream with default options.\n  explicit GzipOutputStream(ZeroCopyOutputStream* sub_stream);\n\n  // Create a GzipOutputStream with the given options.\n  GzipOutputStream(\n      ZeroCopyOutputStream* sub_stream,\n      const Options& options);\n\n  virtual ~GzipOutputStream();\n\n  // Return last error message or NULL if no error.\n  inline const char* ZlibErrorMessage() const {\n    return zcontext_.msg;\n  }\n  inline int ZlibErrorCode() const {\n    return zerror_;\n  }\n\n  // Flushes data written so far to zipped data in the underlying stream.\n  // It is the caller's responsibility to flush the underlying stream if\n  // necessary.\n  // Compression may be less efficient stopping and starting around flushes.\n  // Returns true if no error.\n  //\n  // Please ensure that block size is > 6. Here is an excerpt from the zlib\n  // doc that explains why:\n  //\n  // In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that avail_out\n  // is greater than six to avoid repeated flush markers due to\n  // avail_out == 0 on return.\n  bool Flush();\n\n  // Writes out all data and closes the gzip stream.\n  // It is the caller's responsibility to close the underlying stream if\n  // necessary.\n  // Returns true if no error.\n  bool Close();\n\n  // implements ZeroCopyOutputStream ---------------------------------\n  bool Next(void** data, int* size);\n  void BackUp(int count);\n  int64 ByteCount() const;\n\n private:\n  ZeroCopyOutputStream* sub_stream_;\n  // Result from calling Next() on sub_stream_\n  void* sub_data_;\n  int sub_data_size_;\n\n  z_stream zcontext_;\n  int zerror_;\n  void* input_buffer_;\n  size_t input_buffer_length_;\n\n  // Shared constructor code.\n  void Init(ZeroCopyOutputStream* sub_stream, const Options& options);\n\n  // Do some compression.\n  // Takes zlib flush mode.\n  // Returns zlib error code.\n  int Deflate(int flush);\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GzipOutputStream);\n};\n\n}  // namespace io\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_IO_GZIP_STREAM_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/gzip_stream_unittest.sh",
    "content": "#!/bin/sh -x\n#\n# Protocol Buffers - Google's data interchange format\n# Copyright 2009 Google Inc.  All rights reserved.\n# https://developers.google.com/protocol-buffers/\n#\n# Redistribution and use in source and binary forms, with or without\n# modification, are permitted provided that the following conditions are\n# met:\n#\n#     * Redistributions of source code must retain the above copyright\n# notice, this list of conditions and the following disclaimer.\n#     * Redistributions in binary form must reproduce the above\n# copyright notice, this list of conditions and the following disclaimer\n# in the documentation and/or other materials provided with the\n# distribution.\n#     * Neither the name of Google Inc. nor the names of its\n# contributors may be used to endorse or promote products derived from\n# this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n# \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n#\n# Author: brianolson@google.com (Brian Olson)\n#\n# Test compatibility between command line gzip/gunzip binaries and\n# ZeroCopyStream versions.\n\nTESTFILE=Makefile\n\n(./zcgzip < ${TESTFILE} | gunzip | cmp - ${TESTFILE}) && \\\n(gzip < ${TESTFILE} | ./zcgunzip | cmp - ${TESTFILE})\n\n# Result of \"(cmd) && (cmd)\" implicitly becomes result of this script\n# and thus the test.\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/package_info.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This file exists solely to document the google::protobuf::io namespace.\n// It is not compiled into anything, but it may be read by an automated\n// documentation generator.\n\nnamespace google {\n\nnamespace protobuf {\n\n// Auxiliary classes used for I/O.\n//\n// The Protocol Buffer library uses the classes in this package to deal with\n// I/O and encoding/decoding raw bytes.  Most users will not need to\n// deal with this package.  However, users who want to adapt the system to\n// work with their own I/O abstractions -- e.g., to allow Protocol Buffers\n// to be read from a different kind of input stream without the need for a\n// temporary buffer -- should take a closer look.\nnamespace io {}\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/printer.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\n\nPrinter::Printer(ZeroCopyOutputStream* output, char variable_delimiter)\n    : variable_delimiter_(variable_delimiter),\n      output_(output),\n      buffer_(NULL),\n      buffer_size_(0),\n      offset_(0),\n      at_start_of_line_(true),\n      failed_(false),\n      annotation_collector_(NULL) {}\n\nPrinter::Printer(ZeroCopyOutputStream* output, char variable_delimiter,\n                 AnnotationCollector* annotation_collector)\n    : variable_delimiter_(variable_delimiter),\n      output_(output),\n      buffer_(NULL),\n      buffer_size_(0),\n      offset_(0),\n      at_start_of_line_(true),\n      failed_(false),\n      annotation_collector_(annotation_collector) {}\n\nPrinter::~Printer() {\n  // Only BackUp() if we have called Next() at least once and never failed.\n  if (buffer_size_ > 0 && !failed_) {\n    output_->BackUp(buffer_size_);\n  }\n}\n\nbool Printer::GetSubstitutionRange(const char* varname,\n                                   pair<size_t, size_t>* range) {\n  map<string, pair<size_t, size_t> >::const_iterator iter =\n      substitutions_.find(varname);\n  if (iter == substitutions_.end()) {\n    GOOGLE_LOG(DFATAL) << \" Undefined variable in annotation: \" << varname;\n    return false;\n  }\n  if (iter->second.first > iter->second.second) {\n    GOOGLE_LOG(DFATAL) << \" Variable used for annotation used multiple times: \"\n                << varname;\n    return false;\n  }\n  *range = iter->second;\n  return true;\n}\n\nvoid Printer::Annotate(const char* begin_varname, const char* end_varname,\n                       const string& file_path, const vector<int>& path) {\n  if (annotation_collector_ == NULL) {\n    // Can't generate signatures with this Printer.\n    return;\n  }\n  pair<size_t, size_t> begin, end;\n  if (!GetSubstitutionRange(begin_varname, &begin) ||\n      !GetSubstitutionRange(end_varname, &end)) {\n    return;\n  }\n  if (begin.first > end.second) {\n    GOOGLE_LOG(DFATAL) << \"  Annotation has negative length from \" << begin_varname\n                << \" to \" << end_varname;\n  } else {\n    annotation_collector_->AddAnnotation(begin.first, end.second, file_path,\n                                         path);\n  }\n}\n\nvoid Printer::Print(const map<string, string>& variables, const char* text) {\n  int size = strlen(text);\n  int pos = 0;  // The number of bytes we've written so far.\n  substitutions_.clear();\n\n  for (int i = 0; i < size; i++) {\n    if (text[i] == '\\n') {\n      // Saw newline.  If there is more text, we may need to insert an indent\n      // here.  So, write what we have so far, including the '\\n'.\n      WriteRaw(text + pos, i - pos + 1);\n      pos = i + 1;\n\n      // Setting this true will cause the next WriteRaw() to insert an indent\n      // first.\n      at_start_of_line_ = true;\n\n    } else if (text[i] == variable_delimiter_) {\n      // Saw the start of a variable name.\n\n      // Write what we have so far.\n      WriteRaw(text + pos, i - pos);\n      pos = i + 1;\n\n      // Find closing delimiter.\n      const char* end = strchr(text + pos, variable_delimiter_);\n      if (end == NULL) {\n        GOOGLE_LOG(DFATAL) << \" Unclosed variable name.\";\n        end = text + pos;\n      }\n      int endpos = end - text;\n\n      string varname(text + pos, endpos - pos);\n      if (varname.empty()) {\n        // Two delimiters in a row reduce to a literal delimiter character.\n        WriteRaw(&variable_delimiter_, 1);\n      } else {\n        // Replace with the variable's value.\n        map<string, string>::const_iterator iter = variables.find(varname);\n        if (iter == variables.end()) {\n          GOOGLE_LOG(DFATAL) << \" Undefined variable: \" << varname;\n        } else {\n          size_t begin = offset_;\n          WriteRaw(iter->second.data(), iter->second.size());\n          pair<map<string, pair<size_t, size_t> >::iterator, bool> inserted =\n              substitutions_.insert(\n                  std::make_pair(varname, std::make_pair(begin, offset_)));\n          if (!inserted.second) {\n            // This variable was used multiple times.  Make its span have\n            // negative length so we can detect it if it gets used in an\n            // annotation.\n            inserted.first->second = std::make_pair(1, 0);\n          }\n        }\n      }\n\n      // Advance past this variable.\n      i = endpos;\n      pos = endpos + 1;\n    }\n  }\n\n  // Write the rest.\n  WriteRaw(text + pos, size - pos);\n}\n\nvoid Printer::Print(const char* text) {\n  static map<string, string> empty;\n  Print(empty, text);\n}\n\nvoid Printer::Print(const char* text,\n                    const char* variable, const string& value) {\n  map<string, string> vars;\n  vars[variable] = value;\n  Print(vars, text);\n}\n\nvoid Printer::Print(const char* text,\n                    const char* variable1, const string& value1,\n                    const char* variable2, const string& value2) {\n  map<string, string> vars;\n  vars[variable1] = value1;\n  vars[variable2] = value2;\n  Print(vars, text);\n}\n\nvoid Printer::Print(const char* text,\n                    const char* variable1, const string& value1,\n                    const char* variable2, const string& value2,\n                    const char* variable3, const string& value3) {\n  map<string, string> vars;\n  vars[variable1] = value1;\n  vars[variable2] = value2;\n  vars[variable3] = value3;\n  Print(vars, text);\n}\n\nvoid Printer::Print(const char* text,\n                    const char* variable1, const string& value1,\n                    const char* variable2, const string& value2,\n                    const char* variable3, const string& value3,\n                    const char* variable4, const string& value4) {\n  map<string, string> vars;\n  vars[variable1] = value1;\n  vars[variable2] = value2;\n  vars[variable3] = value3;\n  vars[variable4] = value4;\n  Print(vars, text);\n}\n\nvoid Printer::Print(const char* text,\n                    const char* variable1, const string& value1,\n                    const char* variable2, const string& value2,\n                    const char* variable3, const string& value3,\n                    const char* variable4, const string& value4,\n                    const char* variable5, const string& value5) {\n  map<string, string> vars;\n  vars[variable1] = value1;\n  vars[variable2] = value2;\n  vars[variable3] = value3;\n  vars[variable4] = value4;\n  vars[variable5] = value5;\n  Print(vars, text);\n}\n\nvoid Printer::Print(const char* text,\n                    const char* variable1, const string& value1,\n                    const char* variable2, const string& value2,\n                    const char* variable3, const string& value3,\n                    const char* variable4, const string& value4,\n                    const char* variable5, const string& value5,\n                    const char* variable6, const string& value6) {\n  map<string, string> vars;\n  vars[variable1] = value1;\n  vars[variable2] = value2;\n  vars[variable3] = value3;\n  vars[variable4] = value4;\n  vars[variable5] = value5;\n  vars[variable6] = value6;\n  Print(vars, text);\n}\n\nvoid Printer::Print(const char* text,\n                    const char* variable1, const string& value1,\n                    const char* variable2, const string& value2,\n                    const char* variable3, const string& value3,\n                    const char* variable4, const string& value4,\n                    const char* variable5, const string& value5,\n                    const char* variable6, const string& value6,\n                    const char* variable7, const string& value7) {\n  map<string, string> vars;\n  vars[variable1] = value1;\n  vars[variable2] = value2;\n  vars[variable3] = value3;\n  vars[variable4] = value4;\n  vars[variable5] = value5;\n  vars[variable6] = value6;\n  vars[variable7] = value7;\n  Print(vars, text);\n}\n\nvoid Printer::Print(const char* text,\n                    const char* variable1, const string& value1,\n                    const char* variable2, const string& value2,\n                    const char* variable3, const string& value3,\n                    const char* variable4, const string& value4,\n                    const char* variable5, const string& value5,\n                    const char* variable6, const string& value6,\n                    const char* variable7, const string& value7,\n                    const char* variable8, const string& value8) {\n  map<string, string> vars;\n  vars[variable1] = value1;\n  vars[variable2] = value2;\n  vars[variable3] = value3;\n  vars[variable4] = value4;\n  vars[variable5] = value5;\n  vars[variable6] = value6;\n  vars[variable7] = value7;\n  vars[variable8] = value8;\n  Print(vars, text);\n}\n\nvoid Printer::Indent() {\n  indent_ += \"  \";\n}\n\nvoid Printer::Outdent() {\n  if (indent_.empty()) {\n    GOOGLE_LOG(DFATAL) << \" Outdent() without matching Indent().\";\n    return;\n  }\n\n  indent_.resize(indent_.size() - 2);\n}\n\nvoid Printer::PrintRaw(const string& data) {\n  WriteRaw(data.data(), data.size());\n}\n\nvoid Printer::PrintRaw(const char* data) {\n  if (failed_) return;\n  WriteRaw(data, strlen(data));\n}\n\nvoid Printer::WriteRaw(const char* data, int size) {\n  if (failed_) return;\n  if (size == 0) return;\n\n  if (at_start_of_line_ && (size > 0) && (data[0] != '\\n')) {\n    // Insert an indent.\n    at_start_of_line_ = false;\n    WriteRaw(indent_.data(), indent_.size());\n    if (failed_) return;\n  }\n\n  while (size > buffer_size_) {\n    // Data exceeds space in the buffer.  Copy what we can and request a\n    // new buffer.\n    memcpy(buffer_, data, buffer_size_);\n    offset_ += buffer_size_;\n    data += buffer_size_;\n    size -= buffer_size_;\n    void* void_buffer;\n    failed_ = !output_->Next(&void_buffer, &buffer_size_);\n    if (failed_) return;\n    buffer_ = reinterpret_cast<char*>(void_buffer);\n  }\n\n  // Buffer is big enough to receive the data; copy it.\n  memcpy(buffer_, data, size);\n  buffer_ += size;\n  buffer_size_ -= size;\n  offset_ += size;\n}\n\n}  // namespace io\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/printer.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Utility class for writing text to a ZeroCopyOutputStream.\n\n#ifndef GOOGLE_PROTOBUF_IO_PRINTER_H__\n#define GOOGLE_PROTOBUF_IO_PRINTER_H__\n\n#include <string>\n#include <map>\n#include <vector>\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\n\nclass ZeroCopyOutputStream;     // zero_copy_stream.h\n\n// Records annotations about a Printer's output.\nclass LIBPROTOBUF_EXPORT AnnotationCollector {\n public:\n  // Records that the bytes in file_path beginning with begin_offset and ending\n  // before end_offset are associated with the SourceCodeInfo-style path.\n  virtual void AddAnnotation(size_t begin_offset, size_t end_offset,\n                             const string& file_path,\n                             const vector<int>& path) = 0;\n\n  virtual ~AnnotationCollector() {}\n};\n\n// Records annotations about a Printer's output to the given protocol buffer,\n// assuming that the buffer has an ::Annotation message exposing path,\n// source_file, begin and end fields.\ntemplate <typename AnnotationProto>\nclass AnnotationProtoCollector : public AnnotationCollector {\n public:\n  // annotation_proto is the protocol buffer to which new Annotations should be\n  // added. It is not owned by the AnnotationProtoCollector.\n  explicit AnnotationProtoCollector(AnnotationProto* annotation_proto)\n      : annotation_proto_(annotation_proto) {}\n\n  // Override for AnnotationCollector::AddAnnotation.\n  virtual void AddAnnotation(size_t begin_offset, size_t end_offset,\n                             const string& file_path, const vector<int>& path) {\n    typename AnnotationProto::Annotation* annotation =\n        annotation_proto_->add_annotation();\n    for (int i = 0; i < path.size(); ++i) {\n      annotation->add_path(path[i]);\n    }\n    annotation->set_source_file(file_path);\n    annotation->set_begin(begin_offset);\n    annotation->set_end(end_offset);\n  }\n\n private:\n  // The protocol buffer to which new annotations should be added.\n  AnnotationProto* const annotation_proto_;\n};\n\n// This simple utility class assists in code generation.  It basically\n// allows the caller to define a set of variables and then output some\n// text with variable substitutions.  Example usage:\n//\n//   Printer printer(output, '$');\n//   map<string, string> vars;\n//   vars[\"name\"] = \"Bob\";\n//   printer.Print(vars, \"My name is $name$.\");\n//\n// The above writes \"My name is Bob.\" to the output stream.\n//\n// Printer aggressively enforces correct usage, crashing (with assert failures)\n// in the case of undefined variables in debug builds. This helps greatly in\n// debugging code which uses it.\n//\n// If a Printer is constructed with an AnnotationCollector, it will provide it\n// with annotations that connect the Printer's output to paths that can identify\n// various descriptors.  In the above example, if person_ is a descriptor that\n// identifies Bob, we can associate the output string \"My name is Bob.\" with\n// a source path pointing to that descriptor with:\n//\n//   printer.Annotate(\"name\", person_);\n//\n// The AnnotationCollector will be sent an annotation linking the output range\n// covering \"Bob\" to the logical path provided by person_.  Tools may use\n// this association to (for example) link \"Bob\" in the output back to the\n// source file that defined the person_ descriptor identifying Bob.\n//\n// Annotate can only examine variables substituted during the last call to\n// Print.  It is invalid to refer to a variable that was used multiple times\n// in a single Print call.\n//\n// In full generality, one may specify a range of output text using a beginning\n// substitution variable and an ending variable.  The resulting annotation will\n// span from the first character of the substituted value for the beginning\n// variable to the last character of the substituted value for the ending\n// variable.  For example, the Annotate call above is equivalent to this one:\n//\n//   printer.Annotate(\"name\", \"name\", person_);\n//\n// This is useful if multiple variables combine to form a single span of output\n// that should be annotated with the same source path.  For example:\n//\n//   Printer printer(output, '$');\n//   map<string, string> vars;\n//   vars[\"first\"] = \"Alice\";\n//   vars[\"last\"] = \"Smith\";\n//   printer.Print(vars, \"My name is $first$ $last$.\");\n//   printer.Annotate(\"first\", \"last\", person_);\n//\n// This code would associate the span covering \"Alice Smith\" in the output with\n// the person_ descriptor.\n//\n// Note that the beginning variable must come before (or overlap with, in the\n// case of zero-sized substitution values) the ending variable.\n//\n// It is also sometimes useful to use variables with zero-sized values as\n// markers.  This avoids issues with multiple references to the same variable\n// and also allows annotation ranges to span literal text from the Print\n// templates:\n//\n//   Printer printer(output, '$');\n//   map<string, string> vars;\n//   vars[\"foo\"] = \"bar\";\n//   vars[\"function\"] = \"call\";\n//   vars[\"mark\"] = \"\";\n//   printer.Print(vars, \"$function$($foo$,$foo$)$mark$\");\n//   printer.Annotate(\"function\", \"rmark\", call_);\n//\n// This code associates the span covering \"call(bar,bar)\" in the output with the\n// call_ descriptor.\n\nclass LIBPROTOBUF_EXPORT Printer {\n public:\n  // Create a printer that writes text to the given output stream.  Use the\n  // given character as the delimiter for variables.\n  Printer(ZeroCopyOutputStream* output, char variable_delimiter);\n\n  // Create a printer that writes text to the given output stream.  Use the\n  // given character as the delimiter for variables.  If annotation_collector\n  // is not null, Printer will provide it with annotations about code written\n  // to the stream.  annotation_collector is not owned by Printer.\n  Printer(ZeroCopyOutputStream* output, char variable_delimiter,\n          AnnotationCollector* annotation_collector);\n\n  ~Printer();\n\n  // Link a subsitution variable emitted by the last call to Print to the object\n  // described by descriptor.\n  template <typename SomeDescriptor>\n  void Annotate(const char* varname, const SomeDescriptor* descriptor) {\n    Annotate(varname, varname, descriptor);\n  }\n\n  // Link the output range defined by the substitution variables as emitted by\n  // the last call to Print to the object described by descriptor. The range\n  // begins at begin_varname's value and ends after the last character of the\n  // value substituted for end_varname.\n  template <typename SomeDescriptor>\n  void Annotate(const char* begin_varname, const char* end_varname,\n                const SomeDescriptor* descriptor) {\n    if (annotation_collector_ == NULL) {\n      // Annotations aren't turned on for this Printer, so don't pay the cost\n      // of building the location path.\n      return;\n    }\n    vector<int> path;\n    descriptor->GetLocationPath(&path);\n    Annotate(begin_varname, end_varname, descriptor->file()->name(), path);\n  }\n\n  // Link a subsitution variable emitted by the last call to Print to the file\n  // with path file_name.\n  void Annotate(const char* varname, const string& file_name) {\n    Annotate(varname, varname, file_name);\n  }\n\n  // Link the output range defined by the substitution variables as emitted by\n  // the last call to Print to the file with path file_name. The range begins\n  // at begin_varname's value and ends after the last character of the value\n  // substituted for end_varname.\n  void Annotate(const char* begin_varname, const char* end_varname,\n                const string& file_name) {\n    if (annotation_collector_ == NULL) {\n      // Annotations aren't turned on for this Printer.\n      return;\n    }\n    vector<int> empty_path;\n    Annotate(begin_varname, end_varname, file_name, empty_path);\n  }\n\n  // Print some text after applying variable substitutions.  If a particular\n  // variable in the text is not defined, this will crash.  Variables to be\n  // substituted are identified by their names surrounded by delimiter\n  // characters (as given to the constructor).  The variable bindings are\n  // defined by the given map.\n  void Print(const map<string, string>& variables, const char* text);\n\n  // Like the first Print(), except the substitutions are given as parameters.\n  void Print(const char* text);\n  // Like the first Print(), except the substitutions are given as parameters.\n  void Print(const char* text, const char* variable, const string& value);\n  // Like the first Print(), except the substitutions are given as parameters.\n  void Print(const char* text, const char* variable1, const string& value1,\n                               const char* variable2, const string& value2);\n  // Like the first Print(), except the substitutions are given as parameters.\n  void Print(const char* text, const char* variable1, const string& value1,\n                               const char* variable2, const string& value2,\n                               const char* variable3, const string& value3);\n  // Like the first Print(), except the substitutions are given as parameters.\n  void Print(const char* text, const char* variable1, const string& value1,\n                               const char* variable2, const string& value2,\n                               const char* variable3, const string& value3,\n                               const char* variable4, const string& value4);\n  // Like the first Print(), except the substitutions are given as parameters.\n  void Print(const char* text, const char* variable1, const string& value1,\n                               const char* variable2, const string& value2,\n                               const char* variable3, const string& value3,\n                               const char* variable4, const string& value4,\n                               const char* variable5, const string& value5);\n  // Like the first Print(), except the substitutions are given as parameters.\n  void Print(const char* text, const char* variable1, const string& value1,\n                               const char* variable2, const string& value2,\n                               const char* variable3, const string& value3,\n                               const char* variable4, const string& value4,\n                               const char* variable5, const string& value5,\n                               const char* variable6, const string& value6);\n  // Like the first Print(), except the substitutions are given as parameters.\n  void Print(const char* text, const char* variable1, const string& value1,\n                               const char* variable2, const string& value2,\n                               const char* variable3, const string& value3,\n                               const char* variable4, const string& value4,\n                               const char* variable5, const string& value5,\n                               const char* variable6, const string& value6,\n                               const char* variable7, const string& value7);\n  // Like the first Print(), except the substitutions are given as parameters.\n  void Print(const char* text, const char* variable1, const string& value1,\n                               const char* variable2, const string& value2,\n                               const char* variable3, const string& value3,\n                               const char* variable4, const string& value4,\n                               const char* variable5, const string& value5,\n                               const char* variable6, const string& value6,\n                               const char* variable7, const string& value7,\n                               const char* variable8, const string& value8);\n\n  // Indent text by two spaces.  After calling Indent(), two spaces will be\n  // inserted at the beginning of each line of text.  Indent() may be called\n  // multiple times to produce deeper indents.\n  void Indent();\n\n  // Reduces the current indent level by two spaces, or crashes if the indent\n  // level is zero.\n  void Outdent();\n\n  // Write a string to the output buffer.\n  // This method does not look for newlines to add indentation.\n  void PrintRaw(const string& data);\n\n  // Write a zero-delimited string to output buffer.\n  // This method does not look for newlines to add indentation.\n  void PrintRaw(const char* data);\n\n  // Write some bytes to the output buffer.\n  // This method does not look for newlines to add indentation.\n  void WriteRaw(const char* data, int size);\n\n  // True if any write to the underlying stream failed.  (We don't just\n  // crash in this case because this is an I/O failure, not a programming\n  // error.)\n  bool failed() const { return failed_; }\n\n private:\n  // Link the output range defined by the substitution variables as emitted by\n  // the last call to Print to the object found at the SourceCodeInfo-style path\n  // in a file with path file_path. The range begins at the start of\n  // begin_varname's value and ends after the last character of the value\n  // substituted for end_varname. Note that begin_varname and end_varname\n  // may refer to the same variable.\n  void Annotate(const char* begin_varname, const char* end_varname,\n                const string& file_path, const vector<int>& path);\n\n  const char variable_delimiter_;\n\n  ZeroCopyOutputStream* const output_;\n  char* buffer_;\n  int buffer_size_;\n  // The current position, in bytes, in the output stream.  This is equivalent\n  // to the total number of bytes that have been written so far.  This value is\n  // used to calculate annotation ranges in the substitutions_ map below.\n  size_t offset_;\n\n  string indent_;\n  bool at_start_of_line_;\n  bool failed_;\n\n  // A map from variable name to [start, end) offsets in the output buffer.\n  // These refer to the offsets used for a variable after the last call to\n  // Print.  If a variable was used more than once, the entry used in\n  // this map is set to a negative-length span.  For singly-used variables, the\n  // start offset is the beginning of the substitution; the end offset is the\n  // last byte of the substitution plus one (such that (end - start) is the\n  // length of the substituted string).\n  map<string, pair<size_t, size_t> > substitutions_;\n\n  // Returns true and sets range to the substitution range in the output for\n  // varname if varname was used once in the last call to Print. If varname\n  // was not used, or if it was used multiple times, returns false (and\n  // fails a debug assertion).\n  bool GetSubstitutionRange(const char* varname, pair<size_t, size_t>* range);\n\n  // If non-null, annotation_collector_ is used to store annotations about\n  // generated code.\n  AnnotationCollector* const annotation_collector_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Printer);\n};\n\n}  // namespace io\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_IO_PRINTER_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/printer_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <vector>\n\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/descriptor.pb.h>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\nnamespace {\n\n// Each test repeats over several block sizes in order to test both cases\n// where particular writes cross a buffer boundary and cases where they do\n// not.\n\nTEST(Printer, EmptyPrinter) {\n  char buffer[8192];\n  const int block_size = 100;\n  ArrayOutputStream output(buffer, GOOGLE_ARRAYSIZE(buffer), block_size);\n  Printer printer(&output, '\\0');\n  EXPECT_TRUE(!printer.failed());\n}\n\nTEST(Printer, BasicPrinting) {\n  char buffer[8192];\n\n  for (int block_size = 1; block_size < 512; block_size *= 2) {\n    ArrayOutputStream output(buffer, sizeof(buffer), block_size);\n\n    {\n      Printer printer(&output, '\\0');\n\n      printer.Print(\"Hello World!\");\n      printer.Print(\"  This is the same line.\\n\");\n      printer.Print(\"But this is a new one.\\nAnd this is another one.\");\n\n      EXPECT_FALSE(printer.failed());\n    }\n\n    buffer[output.ByteCount()] = '\\0';\n\n    EXPECT_STREQ(\"Hello World!  This is the same line.\\n\"\n                 \"But this is a new one.\\n\"\n                 \"And this is another one.\",\n                 buffer);\n  }\n}\n\nTEST(Printer, WriteRaw) {\n  char buffer[8192];\n\n  for (int block_size = 1; block_size < 512; block_size *= 2) {\n    ArrayOutputStream output(buffer, sizeof(buffer), block_size);\n\n    {\n      string string_obj = \"From an object\\n\";\n      Printer printer(&output, '$');\n      printer.WriteRaw(\"Hello World!\", 12);\n      printer.PrintRaw(\"  This is the same line.\\n\");\n      printer.PrintRaw(\"But this is a new one.\\nAnd this is another one.\");\n      printer.WriteRaw(\"\\n\", 1);\n      printer.PrintRaw(string_obj);\n      EXPECT_FALSE(printer.failed());\n    }\n\n    buffer[output.ByteCount()] = '\\0';\n\n    EXPECT_STREQ(\"Hello World!  This is the same line.\\n\"\n                 \"But this is a new one.\\n\"\n                 \"And this is another one.\"\n                 \"\\n\"\n                 \"From an object\\n\",\n                 buffer);\n  }\n}\n\nTEST(Printer, VariableSubstitution) {\n  char buffer[8192];\n\n  for (int block_size = 1; block_size < 512; block_size *= 2) {\n    ArrayOutputStream output(buffer, sizeof(buffer), block_size);\n\n    {\n      Printer printer(&output, '$');\n      map<string, string> vars;\n\n      vars[\"foo\"] = \"World\";\n      vars[\"bar\"] = \"$foo$\";\n      vars[\"abcdefg\"] = \"1234\";\n\n      printer.Print(vars, \"Hello $foo$!\\nbar = $bar$\\n\");\n      printer.PrintRaw(\"RawBit\\n\");\n      printer.Print(vars, \"$abcdefg$\\nA literal dollar sign:  $$\");\n\n      vars[\"foo\"] = \"blah\";\n      printer.Print(vars, \"\\nNow foo = $foo$.\");\n\n      EXPECT_FALSE(printer.failed());\n    }\n\n    buffer[output.ByteCount()] = '\\0';\n\n    EXPECT_STREQ(\"Hello World!\\n\"\n                 \"bar = $foo$\\n\"\n                 \"RawBit\\n\"\n                 \"1234\\n\"\n                 \"A literal dollar sign:  $\\n\"\n                 \"Now foo = blah.\",\n                 buffer);\n  }\n}\n\nTEST(Printer, InlineVariableSubstitution) {\n  char buffer[8192];\n\n  ArrayOutputStream output(buffer, sizeof(buffer));\n\n  {\n    Printer printer(&output, '$');\n    printer.Print(\"Hello $foo$!\\n\", \"foo\", \"World\");\n    printer.PrintRaw(\"RawBit\\n\");\n    printer.Print(\"$foo$ $bar$\\n\", \"foo\", \"one\", \"bar\", \"two\");\n    EXPECT_FALSE(printer.failed());\n  }\n\n  buffer[output.ByteCount()] = '\\0';\n\n  EXPECT_STREQ(\"Hello World!\\n\"\n               \"RawBit\\n\"\n               \"one two\\n\",\n               buffer);\n}\n\n// MockDescriptorFile defines only those members that Printer uses to write out\n// annotations.\nclass MockDescriptorFile {\n public:\n  explicit MockDescriptorFile(const string& file) : file_(file) {}\n\n  // The mock filename for this file.\n  const string& name() const { return file_; }\n\n private:\n  string file_;\n};\n\n// MockDescriptor defines only those members that Printer uses to write out\n// annotations.\nclass MockDescriptor {\n public:\n  MockDescriptor(const string& file, const vector<int>& path)\n      : file_(file), path_(path) {}\n\n  // The mock file in which this descriptor was defined.\n  const MockDescriptorFile* file() const { return &file_; }\n\n private:\n  // Allows access to GetLocationPath.\n  friend class ::google::protobuf::io::Printer;\n\n  // Copies the pre-stored path to output.\n  void GetLocationPath(std::vector<int>* output) const { *output = path_; }\n\n  MockDescriptorFile file_;\n  vector<int> path_;\n};\n\nTEST(Printer, AnnotateMap) {\n  char buffer[8192];\n  ArrayOutputStream output(buffer, sizeof(buffer));\n  GeneratedCodeInfo info;\n  AnnotationProtoCollector<GeneratedCodeInfo> info_collector(&info);\n  {\n    Printer printer(&output, '$', &info_collector);\n    map<string, string> vars;\n    vars[\"foo\"] = \"3\";\n    vars[\"bar\"] = \"5\";\n    printer.Print(vars, \"012$foo$4$bar$\\n\");\n    vector<int> path_1;\n    path_1.push_back(33);\n    vector<int> path_2;\n    path_2.push_back(11);\n    path_2.push_back(22);\n    MockDescriptor descriptor_1(\"path_1\", path_1);\n    MockDescriptor descriptor_2(\"path_2\", path_2);\n    printer.Annotate(\"foo\", \"foo\", &descriptor_1);\n    printer.Annotate(\"bar\", \"bar\", &descriptor_2);\n  }\n  buffer[output.ByteCount()] = '\\0';\n  EXPECT_STREQ(\"012345\\n\", buffer);\n  ASSERT_EQ(2, info.annotation_size());\n  const GeneratedCodeInfo::Annotation* foo = info.annotation(0).path_size() == 1\n                                                 ? &info.annotation(0)\n                                                 : &info.annotation(1);\n  const GeneratedCodeInfo::Annotation* bar = info.annotation(0).path_size() == 1\n                                                 ? &info.annotation(1)\n                                                 : &info.annotation(0);\n  ASSERT_EQ(1, foo->path_size());\n  ASSERT_EQ(2, bar->path_size());\n  EXPECT_EQ(33, foo->path(0));\n  EXPECT_EQ(11, bar->path(0));\n  EXPECT_EQ(22, bar->path(1));\n  EXPECT_EQ(\"path_1\", foo->source_file());\n  EXPECT_EQ(\"path_2\", bar->source_file());\n  EXPECT_EQ(3, foo->begin());\n  EXPECT_EQ(4, foo->end());\n  EXPECT_EQ(5, bar->begin());\n  EXPECT_EQ(6, bar->end());\n}\n\nTEST(Printer, AnnotateInline) {\n  char buffer[8192];\n  ArrayOutputStream output(buffer, sizeof(buffer));\n  GeneratedCodeInfo info;\n  AnnotationProtoCollector<GeneratedCodeInfo> info_collector(&info);\n  {\n    Printer printer(&output, '$', &info_collector);\n    printer.Print(\"012$foo$4$bar$\\n\", \"foo\", \"3\", \"bar\", \"5\");\n    vector<int> path_1;\n    path_1.push_back(33);\n    vector<int> path_2;\n    path_2.push_back(11);\n    path_2.push_back(22);\n    MockDescriptor descriptor_1(\"path_1\", path_1);\n    MockDescriptor descriptor_2(\"path_2\", path_2);\n    printer.Annotate(\"foo\", \"foo\", &descriptor_1);\n    printer.Annotate(\"bar\", \"bar\", &descriptor_2);\n  }\n  buffer[output.ByteCount()] = '\\0';\n  EXPECT_STREQ(\"012345\\n\", buffer);\n  ASSERT_EQ(2, info.annotation_size());\n  const GeneratedCodeInfo::Annotation* foo = info.annotation(0).path_size() == 1\n                                                 ? &info.annotation(0)\n                                                 : &info.annotation(1);\n  const GeneratedCodeInfo::Annotation* bar = info.annotation(0).path_size() == 1\n                                                 ? &info.annotation(1)\n                                                 : &info.annotation(0);\n  ASSERT_EQ(1, foo->path_size());\n  ASSERT_EQ(2, bar->path_size());\n  EXPECT_EQ(33, foo->path(0));\n  EXPECT_EQ(11, bar->path(0));\n  EXPECT_EQ(22, bar->path(1));\n  EXPECT_EQ(\"path_1\", foo->source_file());\n  EXPECT_EQ(\"path_2\", bar->source_file());\n  EXPECT_EQ(3, foo->begin());\n  EXPECT_EQ(4, foo->end());\n  EXPECT_EQ(5, bar->begin());\n  EXPECT_EQ(6, bar->end());\n}\n\nTEST(Printer, AnnotateRange) {\n  char buffer[8192];\n  ArrayOutputStream output(buffer, sizeof(buffer));\n  GeneratedCodeInfo info;\n  AnnotationProtoCollector<GeneratedCodeInfo> info_collector(&info);\n  {\n    Printer printer(&output, '$', &info_collector);\n    printer.Print(\"012$foo$4$bar$\\n\", \"foo\", \"3\", \"bar\", \"5\");\n    vector<int> path;\n    path.push_back(33);\n    MockDescriptor descriptor(\"path\", path);\n    printer.Annotate(\"foo\", \"bar\", &descriptor);\n  }\n  buffer[output.ByteCount()] = '\\0';\n  EXPECT_STREQ(\"012345\\n\", buffer);\n  ASSERT_EQ(1, info.annotation_size());\n  const GeneratedCodeInfo::Annotation* foobar = &info.annotation(0);\n  ASSERT_EQ(1, foobar->path_size());\n  EXPECT_EQ(33, foobar->path(0));\n  EXPECT_EQ(\"path\", foobar->source_file());\n  EXPECT_EQ(3, foobar->begin());\n  EXPECT_EQ(6, foobar->end());\n}\n\nTEST(Printer, AnnotateEmptyRange) {\n  char buffer[8192];\n  ArrayOutputStream output(buffer, sizeof(buffer));\n  GeneratedCodeInfo info;\n  AnnotationProtoCollector<GeneratedCodeInfo> info_collector(&info);\n  {\n    Printer printer(&output, '$', &info_collector);\n    printer.Print(\"012$foo$4$baz$$bam$$bar$\\n\", \"foo\", \"3\", \"bar\", \"5\", \"baz\",\n                  \"\", \"bam\", \"\");\n    vector<int> path;\n    path.push_back(33);\n    MockDescriptor descriptor(\"path\", path);\n    printer.Annotate(\"baz\", \"bam\", &descriptor);\n  }\n  buffer[output.ByteCount()] = '\\0';\n  EXPECT_STREQ(\"012345\\n\", buffer);\n  ASSERT_EQ(1, info.annotation_size());\n  const GeneratedCodeInfo::Annotation* bazbam = &info.annotation(0);\n  ASSERT_EQ(1, bazbam->path_size());\n  EXPECT_EQ(33, bazbam->path(0));\n  EXPECT_EQ(\"path\", bazbam->source_file());\n  EXPECT_EQ(5, bazbam->begin());\n  EXPECT_EQ(5, bazbam->end());\n}\n\nTEST(Printer, AnnotateDespiteUnrelatedMultipleUses) {\n  char buffer[8192];\n  ArrayOutputStream output(buffer, sizeof(buffer));\n  GeneratedCodeInfo info;\n  AnnotationProtoCollector<GeneratedCodeInfo> info_collector(&info);\n  {\n    Printer printer(&output, '$', &info_collector);\n    printer.Print(\"012$foo$4$foo$$bar$\\n\", \"foo\", \"3\", \"bar\", \"5\");\n    vector<int> path;\n    path.push_back(33);\n    MockDescriptor descriptor(\"path\", path);\n    printer.Annotate(\"bar\", \"bar\", &descriptor);\n  }\n  buffer[output.ByteCount()] = '\\0';\n  EXPECT_STREQ(\"0123435\\n\", buffer);\n  ASSERT_EQ(1, info.annotation_size());\n  const GeneratedCodeInfo::Annotation* bar = &info.annotation(0);\n  ASSERT_EQ(1, bar->path_size());\n  EXPECT_EQ(33, bar->path(0));\n  EXPECT_EQ(\"path\", bar->source_file());\n  EXPECT_EQ(6, bar->begin());\n  EXPECT_EQ(7, bar->end());\n}\n\nTEST(Printer, Indenting) {\n  char buffer[8192];\n\n  for (int block_size = 1; block_size < 512; block_size *= 2) {\n    ArrayOutputStream output(buffer, sizeof(buffer), block_size);\n\n    {\n      Printer printer(&output, '$');\n      map<string, string> vars;\n\n      vars[\"newline\"] = \"\\n\";\n\n      printer.Print(\"This is not indented.\\n\");\n      printer.Indent();\n      printer.Print(\"This is indented\\nAnd so is this\\n\");\n      printer.Outdent();\n      printer.Print(\"But this is not.\");\n      printer.Indent();\n      printer.Print(\"  And this is still the same line.\\n\"\n                    \"But this is indented.\\n\");\n      printer.PrintRaw(\"RawBit has indent at start\\n\");\n      printer.PrintRaw(\"but not after a raw newline\\n\");\n      printer.Print(vars, \"Note that a newline in a variable will break \"\n                    \"indenting, as we see$newline$here.\\n\");\n      printer.Indent();\n      printer.Print(\"And this\");\n      printer.Outdent();\n      printer.Outdent();\n      printer.Print(\" is double-indented\\nBack to normal.\");\n\n      EXPECT_FALSE(printer.failed());\n    }\n\n    buffer[output.ByteCount()] = '\\0';\n\n    EXPECT_STREQ(\n      \"This is not indented.\\n\"\n      \"  This is indented\\n\"\n      \"  And so is this\\n\"\n      \"But this is not.  And this is still the same line.\\n\"\n      \"  But this is indented.\\n\"\n      \"  RawBit has indent at start\\n\"\n      \"but not after a raw newline\\n\"\n      \"Note that a newline in a variable will break indenting, as we see\\n\"\n      \"here.\\n\"\n      \"    And this is double-indented\\n\"\n      \"Back to normal.\",\n      buffer);\n  }\n}\n\n// Death tests do not work on Windows as of yet.\n#ifdef PROTOBUF_HAS_DEATH_TEST\nTEST(Printer, Death) {\n  char buffer[8192];\n\n  ArrayOutputStream output(buffer, sizeof(buffer));\n  Printer printer(&output, '$');\n\n  EXPECT_DEBUG_DEATH(printer.Print(\"$nosuchvar$\"), \"Undefined variable\");\n  EXPECT_DEBUG_DEATH(printer.Print(\"$unclosed\"), \"Unclosed variable name\");\n  EXPECT_DEBUG_DEATH(printer.Outdent(), \"without matching Indent\");\n}\n\nTEST(Printer, AnnotateMultipleUsesDeath) {\n  char buffer[8192];\n  ArrayOutputStream output(buffer, sizeof(buffer));\n  GeneratedCodeInfo info;\n  AnnotationProtoCollector<GeneratedCodeInfo> info_collector(&info);\n  {\n    Printer printer(&output, '$', &info_collector);\n    printer.Print(\"012$foo$4$foo$\\n\", \"foo\", \"3\");\n    vector<int> path;\n    path.push_back(33);\n    MockDescriptor descriptor(\"path\", path);\n    EXPECT_DEBUG_DEATH(printer.Annotate(\"foo\", \"foo\", &descriptor), \"multiple\");\n  }\n}\n\nTEST(Printer, AnnotateNegativeLengthDeath) {\n  char buffer[8192];\n  ArrayOutputStream output(buffer, sizeof(buffer));\n  GeneratedCodeInfo info;\n  AnnotationProtoCollector<GeneratedCodeInfo> info_collector(&info);\n  {\n    Printer printer(&output, '$', &info_collector);\n    printer.Print(\"012$foo$4$bar$\\n\", \"foo\", \"3\", \"bar\", \"5\");\n    vector<int> path;\n    path.push_back(33);\n    MockDescriptor descriptor(\"path\", path);\n    EXPECT_DEBUG_DEATH(printer.Annotate(\"bar\", \"foo\", &descriptor), \"negative\");\n  }\n}\n\nTEST(Printer, AnnotateUndefinedDeath) {\n  char buffer[8192];\n  ArrayOutputStream output(buffer, sizeof(buffer));\n  GeneratedCodeInfo info;\n  AnnotationProtoCollector<GeneratedCodeInfo> info_collector(&info);\n  {\n    Printer printer(&output, '$', &info_collector);\n    printer.Print(\"012$foo$4$foo$\\n\", \"foo\", \"3\");\n    vector<int> path;\n    path.push_back(33);\n    MockDescriptor descriptor(\"path\", path);\n    EXPECT_DEBUG_DEATH(printer.Annotate(\"bar\", \"bar\", &descriptor),\n                       \"Undefined\");\n  }\n}\n#endif  // PROTOBUF_HAS_DEATH_TEST\n\nTEST(Printer, WriteFailurePartial) {\n  char buffer[17];\n\n  ArrayOutputStream output(buffer, sizeof(buffer));\n  Printer printer(&output, '$');\n\n  // Print 16 bytes to almost fill the buffer (should not fail).\n  printer.Print(\"0123456789abcdef\");\n  EXPECT_FALSE(printer.failed());\n\n  // Try to print 2 chars. Only one fits.\n  printer.Print(\"<>\");\n  EXPECT_TRUE(printer.failed());\n\n  // Anything else should fail too.\n  printer.Print(\" \");\n  EXPECT_TRUE(printer.failed());\n  printer.Print(\"blah\");\n  EXPECT_TRUE(printer.failed());\n\n  // Buffer should contain the first 17 bytes written.\n  EXPECT_EQ(\"0123456789abcdef<\", string(buffer, sizeof(buffer)));\n}\n\nTEST(Printer, WriteFailureExact) {\n  char buffer[16];\n\n  ArrayOutputStream output(buffer, sizeof(buffer));\n  Printer printer(&output, '$');\n\n  // Print 16 bytes to fill the buffer exactly (should not fail).\n  printer.Print(\"0123456789abcdef\");\n  EXPECT_FALSE(printer.failed());\n\n  // Try to print one more byte (should fail).\n  printer.Print(\" \");\n  EXPECT_TRUE(printer.failed());\n\n  // Should not crash\n  printer.Print(\"blah\");\n  EXPECT_TRUE(printer.failed());\n\n  // Buffer should contain the first 16 bytes written.\n  EXPECT_EQ(\"0123456789abcdef\", string(buffer, sizeof(buffer)));\n}\n\n}  // namespace\n}  // namespace io\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/strtod.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/io/strtod.h>\n\n#include <cstdio>\n#include <cstring>\n#include <limits>\n#include <string>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\n\n// ----------------------------------------------------------------------\n// NoLocaleStrtod()\n//   This code will make you cry.\n// ----------------------------------------------------------------------\n\nnamespace {\n\n// Returns a string identical to *input except that the character pointed to\n// by radix_pos (which should be '.') is replaced with the locale-specific\n// radix character.\nstring LocalizeRadix(const char* input, const char* radix_pos) {\n  // Determine the locale-specific radix character by calling sprintf() to\n  // print the number 1.5, then stripping off the digits.  As far as I can\n  // tell, this is the only portable, thread-safe way to get the C library\n  // to divuldge the locale's radix character.  No, localeconv() is NOT\n  // thread-safe.\n  char temp[16];\n  int size = sprintf(temp, \"%.1f\", 1.5);\n  GOOGLE_CHECK_EQ(temp[0], '1');\n  GOOGLE_CHECK_EQ(temp[size-1], '5');\n  GOOGLE_CHECK_LE(size, 6);\n\n  // Now replace the '.' in the input with it.\n  string result;\n  result.reserve(strlen(input) + size - 3);\n  result.append(input, radix_pos);\n  result.append(temp + 1, size - 2);\n  result.append(radix_pos + 1);\n  return result;\n}\n\n}  // namespace\n\ndouble NoLocaleStrtod(const char* text, char** original_endptr) {\n  // We cannot simply set the locale to \"C\" temporarily with setlocale()\n  // as this is not thread-safe.  Instead, we try to parse in the current\n  // locale first.  If parsing stops at a '.' character, then this is a\n  // pretty good hint that we're actually in some other locale in which\n  // '.' is not the radix character.\n\n  char* temp_endptr;\n  double result = strtod(text, &temp_endptr);\n  if (original_endptr != NULL) *original_endptr = temp_endptr;\n  if (*temp_endptr != '.') return result;\n\n  // Parsing halted on a '.'.  Perhaps we're in a different locale?  Let's\n  // try to replace the '.' with a locale-specific radix character and\n  // try again.\n  string localized = LocalizeRadix(text, temp_endptr);\n  const char* localized_cstr = localized.c_str();\n  char* localized_endptr;\n  result = strtod(localized_cstr, &localized_endptr);\n  if ((localized_endptr - localized_cstr) >\n      (temp_endptr - text)) {\n    // This attempt got further, so replacing the decimal must have helped.\n    // Update original_endptr to point at the right location.\n    if (original_endptr != NULL) {\n      // size_diff is non-zero if the localized radix has multiple bytes.\n      int size_diff = localized.size() - strlen(text);\n      // const_cast is necessary to match the strtod() interface.\n      *original_endptr = const_cast<char*>(\n        text + (localized_endptr - localized_cstr - size_diff));\n    }\n  }\n\n  return result;\n}\n\nfloat SafeDoubleToFloat(double value) {\n  if (value > std::numeric_limits<float>::max()) {\n    return std::numeric_limits<float>::infinity();\n  } else if (value < -std::numeric_limits<float>::max()) {\n    return -std::numeric_limits<float>::infinity();\n  } else {\n    return static_cast<float>(value);\n  }\n}\n\n}  // namespace io\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/strtod.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A locale-independent version of strtod(), used to parse floating\n// point default values in .proto files, where the decimal separator\n// is always a dot.\n\n#ifndef GOOGLE_PROTOBUF_IO_STRTOD_H__\n#define GOOGLE_PROTOBUF_IO_STRTOD_H__\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\n\n// A locale-independent version of the standard strtod(), which always\n// uses a dot as the decimal separator.\ndouble NoLocaleStrtod(const char* str, char** endptr);\n\n// Casts a double value to a float value. If the value is outside of the\n// representable range of float, it will be converted to positive or negative\n// infinity.\nfloat SafeDoubleToFloat(double value);\n\n}  // namespace io\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_IO_STRTOD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/tokenizer.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Here we have a hand-written lexer.  At first you might ask yourself,\n// \"Hand-written text processing?  Is Kenton crazy?!\"  Well, first of all,\n// yes I am crazy, but that's beside the point.  There are actually reasons\n// why I ended up writing this this way.\n//\n// The traditional approach to lexing is to use lex to generate a lexer for\n// you.  Unfortunately, lex's output is ridiculously ugly and difficult to\n// integrate cleanly with C++ code, especially abstract code or code meant\n// as a library.  Better parser-generators exist but would add dependencies\n// which most users won't already have, which we'd like to avoid.  (GNU flex\n// has a C++ output option, but it's still ridiculously ugly, non-abstract,\n// and not library-friendly.)\n//\n// The next approach that any good software engineer should look at is to\n// use regular expressions.  And, indeed, I did.  I have code which\n// implements this same class using regular expressions.  It's about 200\n// lines shorter.  However:\n// - Rather than error messages telling you \"This string has an invalid\n//   escape sequence at line 5, column 45\", you get error messages like\n//   \"Parse error on line 5\".  Giving more precise errors requires adding\n//   a lot of code that ends up basically as complex as the hand-coded\n//   version anyway.\n// - The regular expression to match a string literal looks like this:\n//     kString  = new RE(\"(\\\"([^\\\"\\\\\\\\]|\"              // non-escaped\n//                       \"\\\\\\\\[abfnrtv?\\\"'\\\\\\\\0-7]|\"   // normal escape\n//                       \"\\\\\\\\x[0-9a-fA-F])*\\\"|\"       // hex escape\n//                       \"\\'([^\\'\\\\\\\\]|\"        // Also support single-quotes.\n//                       \"\\\\\\\\[abfnrtv?\\\"'\\\\\\\\0-7]|\"\n//                       \"\\\\\\\\x[0-9a-fA-F])*\\')\");\n//   Verifying the correctness of this line noise is actually harder than\n//   verifying the correctness of ConsumeString(), defined below.  I'm not\n//   even confident that the above is correct, after staring at it for some\n//   time.\n// - PCRE is fast, but there's still more overhead involved than the code\n//   below.\n// - Sadly, regular expressions are not part of the C standard library, so\n//   using them would require depending on some other library.  For the\n//   open source release, this could be really annoying.  Nobody likes\n//   downloading one piece of software just to find that they need to\n//   download something else to make it work, and in all likelihood\n//   people downloading Protocol Buffers will already be doing so just\n//   to make something else work.  We could include a copy of PCRE with\n//   our code, but that obligates us to keep it up-to-date and just seems\n//   like a big waste just to save 200 lines of code.\n//\n// On a similar but unrelated note, I'm even scared to use ctype.h.\n// Apparently functions like isalpha() are locale-dependent.  So, if we used\n// that, then if this code is being called from some program that doesn't\n// have its locale set to \"C\", it would behave strangely.  We can't just set\n// the locale to \"C\" ourselves since we might break the calling program that\n// way, particularly if it is multi-threaded.  WTF?  Someone please let me\n// (Kenton) know if I'm missing something here...\n//\n// I'd love to hear about other alternatives, though, as this code isn't\n// exactly pretty.\n\n#include <google/protobuf/io/tokenizer.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/stringprintf.h>\n#include <google/protobuf/io/strtod.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/stl_util.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\nnamespace {\n\n// As mentioned above, I don't trust ctype.h due to the presence of \"locales\".\n// So, I have written replacement functions here.  Someone please smack me if\n// this is a bad idea or if there is some way around this.\n//\n// These \"character classes\" are designed to be used in template methods.\n// For instance, Tokenizer::ConsumeZeroOrMore<Whitespace>() will eat\n// whitespace.\n\n// Note:  No class is allowed to contain '\\0', since this is used to mark end-\n//   of-input and is handled specially.\n\n#define CHARACTER_CLASS(NAME, EXPRESSION)      \\\n  class NAME {                                 \\\n   public:                                     \\\n    static inline bool InClass(char c) {       \\\n      return EXPRESSION;                       \\\n    }                                          \\\n  }\n\nCHARACTER_CLASS(Whitespace, c == ' ' || c == '\\n' || c == '\\t' ||\n                            c == '\\r' || c == '\\v' || c == '\\f');\nCHARACTER_CLASS(WhitespaceNoNewline, c == ' ' || c == '\\t' ||\n                                     c == '\\r' || c == '\\v' || c == '\\f');\n\nCHARACTER_CLASS(Unprintable, c < ' ' && c > '\\0');\n\nCHARACTER_CLASS(Digit, '0' <= c && c <= '9');\nCHARACTER_CLASS(OctalDigit, '0' <= c && c <= '7');\nCHARACTER_CLASS(HexDigit, ('0' <= c && c <= '9') ||\n                          ('a' <= c && c <= 'f') ||\n                          ('A' <= c && c <= 'F'));\n\nCHARACTER_CLASS(Letter, ('a' <= c && c <= 'z') ||\n                        ('A' <= c && c <= 'Z') ||\n                        (c == '_'));\n\nCHARACTER_CLASS(Alphanumeric, ('a' <= c && c <= 'z') ||\n                              ('A' <= c && c <= 'Z') ||\n                              ('0' <= c && c <= '9') ||\n                              (c == '_'));\n\nCHARACTER_CLASS(Escape, c == 'a' || c == 'b' || c == 'f' || c == 'n' ||\n                        c == 'r' || c == 't' || c == 'v' || c == '\\\\' ||\n                        c == '?' || c == '\\'' || c == '\\\"');\n\n#undef CHARACTER_CLASS\n\n// Given a char, interpret it as a numeric digit and return its value.\n// This supports any number base up to 36.\ninline int DigitValue(char digit) {\n  if ('0' <= digit && digit <= '9') return digit - '0';\n  if ('a' <= digit && digit <= 'z') return digit - 'a' + 10;\n  if ('A' <= digit && digit <= 'Z') return digit - 'A' + 10;\n  return -1;\n}\n\n// Inline because it's only used in one place.\ninline char TranslateEscape(char c) {\n  switch (c) {\n    case 'a':  return '\\a';\n    case 'b':  return '\\b';\n    case 'f':  return '\\f';\n    case 'n':  return '\\n';\n    case 'r':  return '\\r';\n    case 't':  return '\\t';\n    case 'v':  return '\\v';\n    case '\\\\': return '\\\\';\n    case '?':  return '\\?';    // Trigraphs = :(\n    case '\\'': return '\\'';\n    case '\"':  return '\\\"';\n\n    // We expect escape sequences to have been validated separately.\n    default:   return '?';\n  }\n}\n\n}  // anonymous namespace\n\nErrorCollector::~ErrorCollector() {}\n\n// ===================================================================\n\nTokenizer::Tokenizer(ZeroCopyInputStream* input,\n                     ErrorCollector* error_collector)\n  : input_(input),\n    error_collector_(error_collector),\n    buffer_(NULL),\n    buffer_size_(0),\n    buffer_pos_(0),\n    read_error_(false),\n    line_(0),\n    column_(0),\n    record_target_(NULL),\n    record_start_(-1),\n    allow_f_after_float_(false),\n    comment_style_(CPP_COMMENT_STYLE),\n    require_space_after_number_(true),\n    allow_multiline_strings_(false) {\n\n  current_.line = 0;\n  current_.column = 0;\n  current_.end_column = 0;\n  current_.type = TYPE_START;\n\n  Refresh();\n}\n\nTokenizer::~Tokenizer() {\n  // If we had any buffer left unread, return it to the underlying stream\n  // so that someone else can read it.\n  if (buffer_size_ > buffer_pos_) {\n    input_->BackUp(buffer_size_ - buffer_pos_);\n  }\n}\n\n// -------------------------------------------------------------------\n// Internal helpers.\n\nvoid Tokenizer::NextChar() {\n  // Update our line and column counters based on the character being\n  // consumed.\n  if (current_char_ == '\\n') {\n    ++line_;\n    column_ = 0;\n  } else if (current_char_ == '\\t') {\n    column_ += kTabWidth - column_ % kTabWidth;\n  } else {\n    ++column_;\n  }\n\n  // Advance to the next character.\n  ++buffer_pos_;\n  if (buffer_pos_ < buffer_size_) {\n    current_char_ = buffer_[buffer_pos_];\n  } else {\n    Refresh();\n  }\n}\n\nvoid Tokenizer::Refresh() {\n  if (read_error_) {\n    current_char_ = '\\0';\n    return;\n  }\n\n  // If we're in a token, append the rest of the buffer to it.\n  if (record_target_ != NULL && record_start_ < buffer_size_) {\n    record_target_->append(buffer_ + record_start_, buffer_size_ - record_start_);\n    record_start_ = 0;\n  }\n\n  const void* data = NULL;\n  buffer_ = NULL;\n  buffer_pos_ = 0;\n  do {\n    if (!input_->Next(&data, &buffer_size_)) {\n      // end of stream (or read error)\n      buffer_size_ = 0;\n      read_error_ = true;\n      current_char_ = '\\0';\n      return;\n    }\n  } while (buffer_size_ == 0);\n\n  buffer_ = static_cast<const char*>(data);\n\n  current_char_ = buffer_[0];\n}\n\ninline void Tokenizer::RecordTo(string* target) {\n  record_target_ = target;\n  record_start_ = buffer_pos_;\n}\n\ninline void Tokenizer::StopRecording() {\n  // Note:  The if() is necessary because some STL implementations crash when\n  //   you call string::append(NULL, 0), presumably because they are trying to\n  //   be helpful by detecting the NULL pointer, even though there's nothing\n  //   wrong with reading zero bytes from NULL.\n  if (buffer_pos_ != record_start_) {\n    record_target_->append(buffer_ + record_start_, buffer_pos_ - record_start_);\n  }\n  record_target_ = NULL;\n  record_start_ = -1;\n}\n\ninline void Tokenizer::StartToken() {\n  current_.type = TYPE_START;    // Just for the sake of initializing it.\n  current_.text.clear();\n  current_.line = line_;\n  current_.column = column_;\n  RecordTo(&current_.text);\n}\n\ninline void Tokenizer::EndToken() {\n  StopRecording();\n  current_.end_column = column_;\n}\n\n// -------------------------------------------------------------------\n// Helper methods that consume characters.\n\ntemplate<typename CharacterClass>\ninline bool Tokenizer::LookingAt() {\n  return CharacterClass::InClass(current_char_);\n}\n\ntemplate<typename CharacterClass>\ninline bool Tokenizer::TryConsumeOne() {\n  if (CharacterClass::InClass(current_char_)) {\n    NextChar();\n    return true;\n  } else {\n    return false;\n  }\n}\n\ninline bool Tokenizer::TryConsume(char c) {\n  if (current_char_ == c) {\n    NextChar();\n    return true;\n  } else {\n    return false;\n  }\n}\n\ntemplate<typename CharacterClass>\ninline void Tokenizer::ConsumeZeroOrMore() {\n  while (CharacterClass::InClass(current_char_)) {\n    NextChar();\n  }\n}\n\ntemplate<typename CharacterClass>\ninline void Tokenizer::ConsumeOneOrMore(const char* error) {\n  if (!CharacterClass::InClass(current_char_)) {\n    AddError(error);\n  } else {\n    do {\n      NextChar();\n    } while (CharacterClass::InClass(current_char_));\n  }\n}\n\n// -------------------------------------------------------------------\n// Methods that read whole patterns matching certain kinds of tokens\n// or comments.\n\nvoid Tokenizer::ConsumeString(char delimiter) {\n  while (true) {\n    switch (current_char_) {\n      case '\\0':\n        AddError(\"Unexpected end of string.\");\n        return;\n\n      case '\\n': {\n        if (!allow_multiline_strings_) {\n          AddError(\"String literals cannot cross line boundaries.\");\n          return;\n        }\n        NextChar();\n        break;\n      }\n\n      case '\\\\': {\n        // An escape sequence.\n        NextChar();\n        if (TryConsumeOne<Escape>()) {\n          // Valid escape sequence.\n        } else if (TryConsumeOne<OctalDigit>()) {\n          // Possibly followed by two more octal digits, but these will\n          // just be consumed by the main loop anyway so we don't need\n          // to do so explicitly here.\n        } else if (TryConsume('x')) {\n          if (!TryConsumeOne<HexDigit>()) {\n            AddError(\"Expected hex digits for escape sequence.\");\n          }\n          // Possibly followed by another hex digit, but again we don't care.\n        } else if (TryConsume('u')) {\n          if (!TryConsumeOne<HexDigit>() ||\n              !TryConsumeOne<HexDigit>() ||\n              !TryConsumeOne<HexDigit>() ||\n              !TryConsumeOne<HexDigit>()) {\n            AddError(\"Expected four hex digits for \\\\u escape sequence.\");\n          }\n        } else if (TryConsume('U')) {\n          // We expect 8 hex digits; but only the range up to 0x10ffff is\n          // legal.\n          if (!TryConsume('0') ||\n              !TryConsume('0') ||\n              !(TryConsume('0') || TryConsume('1')) ||\n              !TryConsumeOne<HexDigit>() ||\n              !TryConsumeOne<HexDigit>() ||\n              !TryConsumeOne<HexDigit>() ||\n              !TryConsumeOne<HexDigit>() ||\n              !TryConsumeOne<HexDigit>()) {\n            AddError(\"Expected eight hex digits up to 10ffff for \\\\U escape \"\n                     \"sequence\");\n          }\n        } else {\n          AddError(\"Invalid escape sequence in string literal.\");\n        }\n        break;\n      }\n\n      default: {\n        if (current_char_ == delimiter) {\n          NextChar();\n          return;\n        }\n        NextChar();\n        break;\n      }\n    }\n  }\n}\n\nTokenizer::TokenType Tokenizer::ConsumeNumber(bool started_with_zero,\n                                              bool started_with_dot) {\n  bool is_float = false;\n\n  if (started_with_zero && (TryConsume('x') || TryConsume('X'))) {\n    // A hex number (started with \"0x\").\n    ConsumeOneOrMore<HexDigit>(\"\\\"0x\\\" must be followed by hex digits.\");\n\n  } else if (started_with_zero && LookingAt<Digit>()) {\n    // An octal number (had a leading zero).\n    ConsumeZeroOrMore<OctalDigit>();\n    if (LookingAt<Digit>()) {\n      AddError(\"Numbers starting with leading zero must be in octal.\");\n      ConsumeZeroOrMore<Digit>();\n    }\n\n  } else {\n    // A decimal number.\n    if (started_with_dot) {\n      is_float = true;\n      ConsumeZeroOrMore<Digit>();\n    } else {\n      ConsumeZeroOrMore<Digit>();\n\n      if (TryConsume('.')) {\n        is_float = true;\n        ConsumeZeroOrMore<Digit>();\n      }\n    }\n\n    if (TryConsume('e') || TryConsume('E')) {\n      is_float = true;\n      TryConsume('-') || TryConsume('+');\n      ConsumeOneOrMore<Digit>(\"\\\"e\\\" must be followed by exponent.\");\n    }\n\n    if (allow_f_after_float_ && (TryConsume('f') || TryConsume('F'))) {\n      is_float = true;\n    }\n  }\n\n  if (LookingAt<Letter>() && require_space_after_number_) {\n    AddError(\"Need space between number and identifier.\");\n  } else if (current_char_ == '.') {\n    if (is_float) {\n      AddError(\n        \"Already saw decimal point or exponent; can't have another one.\");\n    } else {\n      AddError(\"Hex and octal numbers must be integers.\");\n    }\n  }\n\n  return is_float ? TYPE_FLOAT : TYPE_INTEGER;\n}\n\nvoid Tokenizer::ConsumeLineComment(string* content) {\n  if (content != NULL) RecordTo(content);\n\n  while (current_char_ != '\\0' && current_char_ != '\\n') {\n    NextChar();\n  }\n  TryConsume('\\n');\n\n  if (content != NULL) StopRecording();\n}\n\nvoid Tokenizer::ConsumeBlockComment(string* content) {\n  int start_line = line_;\n  int start_column = column_ - 2;\n\n  if (content != NULL) RecordTo(content);\n\n  while (true) {\n    while (current_char_ != '\\0' &&\n           current_char_ != '*' &&\n           current_char_ != '/' &&\n           current_char_ != '\\n') {\n      NextChar();\n    }\n\n    if (TryConsume('\\n')) {\n      if (content != NULL) StopRecording();\n\n      // Consume leading whitespace and asterisk;\n      ConsumeZeroOrMore<WhitespaceNoNewline>();\n      if (TryConsume('*')) {\n        if (TryConsume('/')) {\n          // End of comment.\n          break;\n        }\n      }\n\n      if (content != NULL) RecordTo(content);\n    } else if (TryConsume('*') && TryConsume('/')) {\n      // End of comment.\n      if (content != NULL) {\n        StopRecording();\n        // Strip trailing \"*/\".\n        content->erase(content->size() - 2);\n      }\n      break;\n    } else if (TryConsume('/') && current_char_ == '*') {\n      // Note:  We didn't consume the '*' because if there is a '/' after it\n      //   we want to interpret that as the end of the comment.\n      AddError(\n        \"\\\"/*\\\" inside block comment.  Block comments cannot be nested.\");\n    } else if (current_char_ == '\\0') {\n      AddError(\"End-of-file inside block comment.\");\n      error_collector_->AddError(\n        start_line, start_column, \"  Comment started here.\");\n      if (content != NULL) StopRecording();\n      break;\n    }\n  }\n}\n\nTokenizer::NextCommentStatus Tokenizer::TryConsumeCommentStart() {\n  if (comment_style_ == CPP_COMMENT_STYLE && TryConsume('/')) {\n    if (TryConsume('/')) {\n      return LINE_COMMENT;\n    } else if (TryConsume('*')) {\n      return BLOCK_COMMENT;\n    } else {\n      // Oops, it was just a slash.  Return it.\n      current_.type = TYPE_SYMBOL;\n      current_.text = \"/\";\n      current_.line = line_;\n      current_.column = column_ - 1;\n      current_.end_column = column_;\n      return SLASH_NOT_COMMENT;\n    }\n  } else if (comment_style_ == SH_COMMENT_STYLE && TryConsume('#')) {\n    return LINE_COMMENT;\n  } else {\n    return NO_COMMENT;\n  }\n}\n\n// -------------------------------------------------------------------\n\nbool Tokenizer::Next() {\n  previous_ = current_;\n\n  while (!read_error_) {\n    ConsumeZeroOrMore<Whitespace>();\n\n    switch (TryConsumeCommentStart()) {\n      case LINE_COMMENT:\n        ConsumeLineComment(NULL);\n        continue;\n      case BLOCK_COMMENT:\n        ConsumeBlockComment(NULL);\n        continue;\n      case SLASH_NOT_COMMENT:\n        return true;\n      case NO_COMMENT:\n        break;\n    }\n\n    // Check for EOF before continuing.\n    if (read_error_) break;\n\n    if (LookingAt<Unprintable>() || current_char_ == '\\0') {\n      AddError(\"Invalid control characters encountered in text.\");\n      NextChar();\n      // Skip more unprintable characters, too.  But, remember that '\\0' is\n      // also what current_char_ is set to after EOF / read error.  We have\n      // to be careful not to go into an infinite loop of trying to consume\n      // it, so make sure to check read_error_ explicitly before consuming\n      // '\\0'.\n      while (TryConsumeOne<Unprintable>() ||\n             (!read_error_ && TryConsume('\\0'))) {\n        // Ignore.\n      }\n\n    } else {\n      // Reading some sort of token.\n      StartToken();\n\n      if (TryConsumeOne<Letter>()) {\n        ConsumeZeroOrMore<Alphanumeric>();\n        current_.type = TYPE_IDENTIFIER;\n      } else if (TryConsume('0')) {\n        current_.type = ConsumeNumber(true, false);\n      } else if (TryConsume('.')) {\n        // This could be the beginning of a floating-point number, or it could\n        // just be a '.' symbol.\n\n        if (TryConsumeOne<Digit>()) {\n          // It's a floating-point number.\n          if (previous_.type == TYPE_IDENTIFIER &&\n              current_.line == previous_.line &&\n              current_.column == previous_.end_column) {\n            // We don't accept syntax like \"blah.123\".\n            error_collector_->AddError(line_, column_ - 2,\n              \"Need space between identifier and decimal point.\");\n          }\n          current_.type = ConsumeNumber(false, true);\n        } else {\n          current_.type = TYPE_SYMBOL;\n        }\n      } else if (TryConsumeOne<Digit>()) {\n        current_.type = ConsumeNumber(false, false);\n      } else if (TryConsume('\\\"')) {\n        ConsumeString('\\\"');\n        current_.type = TYPE_STRING;\n      } else if (TryConsume('\\'')) {\n        ConsumeString('\\'');\n        current_.type = TYPE_STRING;\n      } else {\n        // Check if the high order bit is set.\n        if (current_char_ & 0x80) {\n          error_collector_->AddError(line_, column_,\n              StringPrintf(\"Interpreting non ascii codepoint %d.\",\n                           static_cast<unsigned char>(current_char_)));\n        }\n        NextChar();\n        current_.type = TYPE_SYMBOL;\n      }\n\n      EndToken();\n      return true;\n    }\n  }\n\n  // EOF\n  current_.type = TYPE_END;\n  current_.text.clear();\n  current_.line = line_;\n  current_.column = column_;\n  current_.end_column = column_;\n  return false;\n}\n\nnamespace {\n\n// Helper class for collecting comments and putting them in the right places.\n//\n// This basically just buffers the most recent comment until it can be decided\n// exactly where that comment should be placed.  When Flush() is called, the\n// current comment goes into either prev_trailing_comments or detached_comments.\n// When the CommentCollector is destroyed, the last buffered comment goes into\n// next_leading_comments.\nclass CommentCollector {\n public:\n  CommentCollector(string* prev_trailing_comments,\n                   vector<string>* detached_comments,\n                   string* next_leading_comments)\n      : prev_trailing_comments_(prev_trailing_comments),\n        detached_comments_(detached_comments),\n        next_leading_comments_(next_leading_comments),\n        has_comment_(false),\n        is_line_comment_(false),\n        can_attach_to_prev_(true) {\n    if (prev_trailing_comments != NULL) prev_trailing_comments->clear();\n    if (detached_comments != NULL) detached_comments->clear();\n    if (next_leading_comments != NULL) next_leading_comments->clear();\n  }\n\n  ~CommentCollector() {\n    // Whatever is in the buffer is a leading comment.\n    if (next_leading_comments_ != NULL && has_comment_) {\n      comment_buffer_.swap(*next_leading_comments_);\n    }\n  }\n\n  // About to read a line comment.  Get the comment buffer pointer in order to\n  // read into it.\n  string* GetBufferForLineComment() {\n    // We want to combine with previous line comments, but not block comments.\n    if (has_comment_ && !is_line_comment_) {\n      Flush();\n    }\n    has_comment_ = true;\n    is_line_comment_ = true;\n    return &comment_buffer_;\n  }\n\n  // About to read a block comment.  Get the comment buffer pointer in order to\n  // read into it.\n  string* GetBufferForBlockComment() {\n    if (has_comment_) {\n      Flush();\n    }\n    has_comment_ = true;\n    is_line_comment_ = false;\n    return &comment_buffer_;\n  }\n\n  void ClearBuffer() {\n    comment_buffer_.clear();\n    has_comment_ = false;\n  }\n\n  // Called once we know that the comment buffer is complete and is *not*\n  // connected to the next token.\n  void Flush() {\n    if (has_comment_) {\n      if (can_attach_to_prev_) {\n        if (prev_trailing_comments_ != NULL) {\n          prev_trailing_comments_->append(comment_buffer_);\n        }\n        can_attach_to_prev_ = false;\n      } else {\n        if (detached_comments_ != NULL) {\n          detached_comments_->push_back(comment_buffer_);\n        }\n      }\n      ClearBuffer();\n    }\n  }\n\n  void DetachFromPrev() {\n    can_attach_to_prev_ = false;\n  }\n\n private:\n  string* prev_trailing_comments_;\n  vector<string>* detached_comments_;\n  string* next_leading_comments_;\n\n  string comment_buffer_;\n\n  // True if any comments were read into comment_buffer_.  This can be true even\n  // if comment_buffer_ is empty, namely if the comment was \"/**/\".\n  bool has_comment_;\n\n  // Is the comment in the comment buffer a line comment?\n  bool is_line_comment_;\n\n  // Is it still possible that we could be reading a comment attached to the\n  // previous token?\n  bool can_attach_to_prev_;\n};\n\n} // namespace\n\nbool Tokenizer::NextWithComments(string* prev_trailing_comments,\n                                 vector<string>* detached_comments,\n                                 string* next_leading_comments) {\n  CommentCollector collector(prev_trailing_comments, detached_comments,\n                             next_leading_comments);\n\n  if (current_.type == TYPE_START) {\n    // Ignore unicode byte order mark(BOM) if it appears at the file\n    // beginning. Only UTF-8 BOM (0xEF 0xBB 0xBF) is accepted.\n    if (TryConsume((char)0xEF)) {\n      if (!TryConsume((char)0xBB) || !TryConsume((char)0xBF)) {\n        AddError(\"Proto file starts with 0xEF but not UTF-8 BOM. \"\n                 \"Only UTF-8 is accepted for proto file.\");\n        return false;\n      }\n    }\n    collector.DetachFromPrev();\n  } else {\n    // A comment appearing on the same line must be attached to the previous\n    // declaration.\n    ConsumeZeroOrMore<WhitespaceNoNewline>();\n    switch (TryConsumeCommentStart()) {\n      case LINE_COMMENT:\n        ConsumeLineComment(collector.GetBufferForLineComment());\n\n        // Don't allow comments on subsequent lines to be attached to a trailing\n        // comment.\n        collector.Flush();\n        break;\n      case BLOCK_COMMENT:\n        ConsumeBlockComment(collector.GetBufferForBlockComment());\n\n        ConsumeZeroOrMore<WhitespaceNoNewline>();\n        if (!TryConsume('\\n')) {\n          // Oops, the next token is on the same line.  If we recorded a comment\n          // we really have no idea which token it should be attached to.\n          collector.ClearBuffer();\n          return Next();\n        }\n\n        // Don't allow comments on subsequent lines to be attached to a trailing\n        // comment.\n        collector.Flush();\n        break;\n      case SLASH_NOT_COMMENT:\n        return true;\n      case NO_COMMENT:\n        if (!TryConsume('\\n')) {\n          // The next token is on the same line.  There are no comments.\n          return Next();\n        }\n        break;\n    }\n  }\n\n  // OK, we are now on the line *after* the previous token.\n  while (true) {\n    ConsumeZeroOrMore<WhitespaceNoNewline>();\n\n    switch (TryConsumeCommentStart()) {\n      case LINE_COMMENT:\n        ConsumeLineComment(collector.GetBufferForLineComment());\n        break;\n      case BLOCK_COMMENT:\n        ConsumeBlockComment(collector.GetBufferForBlockComment());\n\n        // Consume the rest of the line so that we don't interpret it as a\n        // blank line the next time around the loop.\n        ConsumeZeroOrMore<WhitespaceNoNewline>();\n        TryConsume('\\n');\n        break;\n      case SLASH_NOT_COMMENT:\n        return true;\n      case NO_COMMENT:\n        if (TryConsume('\\n')) {\n          // Completely blank line.\n          collector.Flush();\n          collector.DetachFromPrev();\n        } else {\n          bool result = Next();\n          if (!result ||\n              current_.text == \"}\" ||\n              current_.text == \"]\" ||\n              current_.text == \")\") {\n            // It looks like we're at the end of a scope.  In this case it\n            // makes no sense to attach a comment to the following token.\n            collector.Flush();\n          }\n          return result;\n        }\n        break;\n    }\n  }\n}\n\n// -------------------------------------------------------------------\n// Token-parsing helpers.  Remember that these don't need to report\n// errors since any errors should already have been reported while\n// tokenizing.  Also, these can assume that whatever text they\n// are given is text that the tokenizer actually parsed as a token\n// of the given type.\n\nbool Tokenizer::ParseInteger(const string& text, uint64 max_value,\n                             uint64* output) {\n  // Sadly, we can't just use strtoul() since it is only 32-bit and strtoull()\n  // is non-standard.  I hate the C standard library.  :(\n\n//  return strtoull(text.c_str(), NULL, 0);\n\n  const char* ptr = text.c_str();\n  int base = 10;\n  if (ptr[0] == '0') {\n    if (ptr[1] == 'x' || ptr[1] == 'X') {\n      // This is hex.\n      base = 16;\n      ptr += 2;\n    } else {\n      // This is octal.\n      base = 8;\n    }\n  }\n\n  uint64 result = 0;\n  for (; *ptr != '\\0'; ptr++) {\n    int digit = DigitValue(*ptr);\n    if (digit < 0 || digit >= base) {\n      // The token provided by Tokenizer is invalid. i.e., 099 is an invalid\n      // token, but Tokenizer still think it's integer.\n      return false;\n    }\n    if (digit > max_value || result > (max_value - digit) / base) {\n      // Overflow.\n      return false;\n    }\n    result = result * base + digit;\n  }\n\n  *output = result;\n  return true;\n}\n\ndouble Tokenizer::ParseFloat(const string& text) {\n  const char* start = text.c_str();\n  char* end;\n  double result = NoLocaleStrtod(start, &end);\n\n  // \"1e\" is not a valid float, but if the tokenizer reads it, it will\n  // report an error but still return it as a valid token.  We need to\n  // accept anything the tokenizer could possibly return, error or not.\n  if (*end == 'e' || *end == 'E') {\n    ++end;\n    if (*end == '-' || *end == '+') ++end;\n  }\n\n  // If the Tokenizer had allow_f_after_float_ enabled, the float may be\n  // suffixed with the letter 'f'.\n  if (*end == 'f' || *end == 'F') {\n    ++end;\n  }\n\n  GOOGLE_LOG_IF(DFATAL, end - start != text.size() || *start == '-')\n    << \" Tokenizer::ParseFloat() passed text that could not have been\"\n       \" tokenized as a float: \" << CEscape(text);\n  return result;\n}\n\n// Helper to append a Unicode code point to a string as UTF8, without bringing\n// in any external dependencies.\nstatic void AppendUTF8(uint32 code_point, string* output) {\n  uint32 tmp = 0;\n  int len = 0;\n  if (code_point <= 0x7f) {\n    tmp = code_point;\n    len = 1;\n  } else if (code_point <= 0x07ff) {\n    tmp = 0x0000c080 |\n        ((code_point & 0x07c0) << 2) |\n        (code_point & 0x003f);\n    len = 2;\n  } else if (code_point <= 0xffff) {\n    tmp = 0x00e08080 |\n        ((code_point & 0xf000) << 4) |\n        ((code_point & 0x0fc0) << 2) |\n        (code_point & 0x003f);\n    len = 3;\n  } else if (code_point <= 0x1fffff) {\n    tmp = 0xf0808080 |\n        ((code_point & 0x1c0000) << 6) |\n        ((code_point & 0x03f000) << 4) |\n        ((code_point & 0x000fc0) << 2) |\n        (code_point & 0x003f);\n    len = 4;\n  } else {\n    // UTF-16 is only defined for code points up to 0x10FFFF, and UTF-8 is\n    // normally only defined up to there as well.\n    StringAppendF(output, \"\\\\U%08x\", code_point);\n    return;\n  }\n  tmp = ghtonl(tmp);\n  output->append(reinterpret_cast<const char*>(&tmp) + sizeof(tmp) - len, len);\n}\n\n// Try to read <len> hex digits from ptr, and stuff the numeric result into\n// *result. Returns true if that many digits were successfully consumed.\nstatic bool ReadHexDigits(const char* ptr, int len, uint32* result) {\n  *result = 0;\n  if (len == 0) return false;\n  for (const char* end = ptr + len; ptr < end; ++ptr) {\n    if (*ptr == '\\0') return false;\n    *result = (*result << 4) + DigitValue(*ptr);\n  }\n  return true;\n}\n\n// Handling UTF-16 surrogate pairs. UTF-16 encodes code points in the range\n// 0x10000...0x10ffff as a pair of numbers, a head surrogate followed by a trail\n// surrogate. These numbers are in a reserved range of Unicode code points, so\n// if we encounter such a pair we know how to parse it and convert it into a\n// single code point.\nstatic const uint32 kMinHeadSurrogate = 0xd800;\nstatic const uint32 kMaxHeadSurrogate = 0xdc00;\nstatic const uint32 kMinTrailSurrogate = 0xdc00;\nstatic const uint32 kMaxTrailSurrogate = 0xe000;\n\nstatic inline bool IsHeadSurrogate(uint32 code_point) {\n  return (code_point >= kMinHeadSurrogate) && (code_point < kMaxHeadSurrogate);\n}\n\nstatic inline bool IsTrailSurrogate(uint32 code_point) {\n  return (code_point >= kMinTrailSurrogate) &&\n      (code_point < kMaxTrailSurrogate);\n}\n\n// Combine a head and trail surrogate into a single Unicode code point.\nstatic uint32 AssembleUTF16(uint32 head_surrogate, uint32 trail_surrogate) {\n  GOOGLE_DCHECK(IsHeadSurrogate(head_surrogate));\n  GOOGLE_DCHECK(IsTrailSurrogate(trail_surrogate));\n  return 0x10000 + (((head_surrogate - kMinHeadSurrogate) << 10) |\n      (trail_surrogate - kMinTrailSurrogate));\n}\n\n// Convert the escape sequence parameter to a number of expected hex digits.\nstatic inline int UnicodeLength(char key) {\n  if (key == 'u') return 4;\n  if (key == 'U') return 8;\n  return 0;\n}\n\n// Given a pointer to the 'u' or 'U' starting a Unicode escape sequence, attempt\n// to parse that sequence. On success, returns a pointer to the first char\n// beyond that sequence, and fills in *code_point. On failure, returns ptr\n// itself.\nstatic const char* FetchUnicodePoint(const char* ptr, uint32* code_point) {\n  const char* p = ptr;\n  // Fetch the code point.\n  const int len = UnicodeLength(*p++);\n  if (!ReadHexDigits(p, len, code_point))\n    return ptr;\n  p += len;\n\n  // Check if the code point we read is a \"head surrogate.\" If so, then we\n  // expect it to be immediately followed by another code point which is a valid\n  // \"trail surrogate,\" and together they form a UTF-16 pair which decodes into\n  // a single Unicode point. Trail surrogates may only use \\u, not \\U.\n  if (IsHeadSurrogate(*code_point) && *p == '\\\\' && *(p + 1) == 'u') {\n    uint32 trail_surrogate;\n    if (ReadHexDigits(p + 2, 4, &trail_surrogate) &&\n        IsTrailSurrogate(trail_surrogate)) {\n      *code_point = AssembleUTF16(*code_point, trail_surrogate);\n      p += 6;\n    }\n    // If this failed, then we just emit the head surrogate as a code point.\n    // It's bogus, but so is the string.\n  }\n\n  return p;\n}\n\n// The text string must begin and end with single or double quote\n// characters.\nvoid Tokenizer::ParseStringAppend(const string& text, string* output) {\n  // Reminder: text[0] is always a quote character.  (If text is\n  // empty, it's invalid, so we'll just return).\n  const size_t text_size = text.size();\n  if (text_size == 0) {\n    GOOGLE_LOG(DFATAL)\n      << \" Tokenizer::ParseStringAppend() passed text that could not\"\n         \" have been tokenized as a string: \" << CEscape(text);\n    return;\n  }\n\n  // Reserve room for new string. The branch is necessary because if\n  // there is already space available the reserve() call might\n  // downsize the output.\n  const size_t new_len = text_size + output->size();\n  if (new_len > output->capacity()) {\n    output->reserve(new_len);\n  }\n\n  // Loop through the string copying characters to \"output\" and\n  // interpreting escape sequences.  Note that any invalid escape\n  // sequences or other errors were already reported while tokenizing.\n  // In this case we do not need to produce valid results.\n  for (const char* ptr = text.c_str() + 1; *ptr != '\\0'; ptr++) {\n    if (*ptr == '\\\\' && ptr[1] != '\\0') {\n      // An escape sequence.\n      ++ptr;\n\n      if (OctalDigit::InClass(*ptr)) {\n        // An octal escape.  May one, two, or three digits.\n        int code = DigitValue(*ptr);\n        if (OctalDigit::InClass(ptr[1])) {\n          ++ptr;\n          code = code * 8 + DigitValue(*ptr);\n        }\n        if (OctalDigit::InClass(ptr[1])) {\n          ++ptr;\n          code = code * 8 + DigitValue(*ptr);\n        }\n        output->push_back(static_cast<char>(code));\n\n      } else if (*ptr == 'x') {\n        // A hex escape.  May zero, one, or two digits.  (The zero case\n        // will have been caught as an error earlier.)\n        int code = 0;\n        if (HexDigit::InClass(ptr[1])) {\n          ++ptr;\n          code = DigitValue(*ptr);\n        }\n        if (HexDigit::InClass(ptr[1])) {\n          ++ptr;\n          code = code * 16 + DigitValue(*ptr);\n        }\n        output->push_back(static_cast<char>(code));\n\n      } else if (*ptr == 'u' || *ptr == 'U') {\n        uint32 unicode;\n        const char* end = FetchUnicodePoint(ptr, &unicode);\n        if (end == ptr) {\n          // Failure: Just dump out what we saw, don't try to parse it.\n          output->push_back(*ptr);\n        } else {\n          AppendUTF8(unicode, output);\n          ptr = end - 1;  // Because we're about to ++ptr.\n        }\n      } else {\n        // Some other escape code.\n        output->push_back(TranslateEscape(*ptr));\n      }\n\n    } else if (*ptr == text[0] && ptr[1] == '\\0') {\n      // Ignore final quote matching the starting quote.\n    } else {\n      output->push_back(*ptr);\n    }\n  }\n}\n\ntemplate<typename CharacterClass>\nstatic bool AllInClass(const string& s) {\n  for (int i = 0; i < s.size(); ++i) {\n    if (!CharacterClass::InClass(s[i]))\n      return false;\n  }\n  return true;\n}\n\nbool Tokenizer::IsIdentifier(const string& text) {\n  // Mirrors IDENTIFIER definition in Tokenizer::Next() above.\n  if (text.size() == 0)\n    return false;\n  if (!Letter::InClass(text.at(0)))\n    return false;\n  if (!AllInClass<Alphanumeric>(text.substr(1)))\n    return false;\n  return true;\n}\n\n}  // namespace io\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/tokenizer.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Class for parsing tokenized text from a ZeroCopyInputStream.\n\n#ifndef GOOGLE_PROTOBUF_IO_TOKENIZER_H__\n#define GOOGLE_PROTOBUF_IO_TOKENIZER_H__\n\n#include <string>\n#include <vector>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\n\nclass ZeroCopyInputStream;     // zero_copy_stream.h\n\n// Defined in this file.\nclass ErrorCollector;\nclass Tokenizer;\n\n// By \"column number\", the proto compiler refers to a count of the number\n// of bytes before a given byte, except that a tab character advances to\n// the next multiple of 8 bytes.  Note in particular that column numbers\n// are zero-based, while many user interfaces use one-based column numbers.\ntypedef int ColumnNumber;\n\n// Abstract interface for an object which collects the errors that occur\n// during parsing.  A typical implementation might simply print the errors\n// to stdout.\nclass LIBPROTOBUF_EXPORT ErrorCollector {\n public:\n  inline ErrorCollector() {}\n  virtual ~ErrorCollector();\n\n  // Indicates that there was an error in the input at the given line and\n  // column numbers.  The numbers are zero-based, so you may want to add\n  // 1 to each before printing them.\n  virtual void AddError(int line, ColumnNumber column,\n                        const string& message) = 0;\n\n  // Indicates that there was a warning in the input at the given line and\n  // column numbers.  The numbers are zero-based, so you may want to add\n  // 1 to each before printing them.\n  virtual void AddWarning(int line, ColumnNumber column,\n                          const string& message) { }\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ErrorCollector);\n};\n\n// This class converts a stream of raw text into a stream of tokens for\n// the protocol definition parser to parse.  The tokens recognized are\n// similar to those that make up the C language; see the TokenType enum for\n// precise descriptions.  Whitespace and comments are skipped.  By default,\n// C- and C++-style comments are recognized, but other styles can be used by\n// calling set_comment_style().\nclass LIBPROTOBUF_EXPORT Tokenizer {\n public:\n  // Construct a Tokenizer that reads and tokenizes text from the given\n  // input stream and writes errors to the given error_collector.\n  // The caller keeps ownership of input and error_collector.\n  Tokenizer(ZeroCopyInputStream* input, ErrorCollector* error_collector);\n  ~Tokenizer();\n\n  enum TokenType {\n    TYPE_START,       // Next() has not yet been called.\n    TYPE_END,         // End of input reached.  \"text\" is empty.\n\n    TYPE_IDENTIFIER,  // A sequence of letters, digits, and underscores, not\n                      // starting with a digit.  It is an error for a number\n                      // to be followed by an identifier with no space in\n                      // between.\n    TYPE_INTEGER,     // A sequence of digits representing an integer.  Normally\n                      // the digits are decimal, but a prefix of \"0x\" indicates\n                      // a hex number and a leading zero indicates octal, just\n                      // like with C numeric literals.  A leading negative sign\n                      // is NOT included in the token; it's up to the parser to\n                      // interpret the unary minus operator on its own.\n    TYPE_FLOAT,       // A floating point literal, with a fractional part and/or\n                      // an exponent.  Always in decimal.  Again, never\n                      // negative.\n    TYPE_STRING,      // A quoted sequence of escaped characters.  Either single\n                      // or double quotes can be used, but they must match.\n                      // A string literal cannot cross a line break.\n    TYPE_SYMBOL,      // Any other printable character, like '!' or '+'.\n                      // Symbols are always a single character, so \"!+$%\" is\n                      // four tokens.\n  };\n\n  // Structure representing a token read from the token stream.\n  struct Token {\n    TokenType type;\n    string text;       // The exact text of the token as it appeared in\n                       // the input.  e.g. tokens of TYPE_STRING will still\n                       // be escaped and in quotes.\n\n    // \"line\" and \"column\" specify the position of the first character of\n    // the token within the input stream.  They are zero-based.\n    int line;\n    ColumnNumber column;\n    ColumnNumber end_column;\n  };\n\n  // Get the current token.  This is updated when Next() is called.  Before\n  // the first call to Next(), current() has type TYPE_START and no contents.\n  const Token& current();\n\n  // Return the previous token -- i.e. what current() returned before the\n  // previous call to Next().\n  const Token& previous();\n\n  // Advance to the next token.  Returns false if the end of the input is\n  // reached.\n  bool Next();\n\n  // Like Next(), but also collects comments which appear between the previous\n  // and next tokens.\n  //\n  // Comments which appear to be attached to the previous token are stored\n  // in *prev_tailing_comments.  Comments which appear to be attached to the\n  // next token are stored in *next_leading_comments.  Comments appearing in\n  // between which do not appear to be attached to either will be added to\n  // detached_comments.  Any of these parameters can be NULL to simply discard\n  // the comments.\n  //\n  // A series of line comments appearing on consecutive lines, with no other\n  // tokens appearing on those lines, will be treated as a single comment.\n  //\n  // Only the comment content is returned; comment markers (e.g. //) are\n  // stripped out.  For block comments, leading whitespace and an asterisk will\n  // be stripped from the beginning of each line other than the first.  Newlines\n  // are included in the output.\n  //\n  // Examples:\n  //\n  //   optional int32 foo = 1;  // Comment attached to foo.\n  //   // Comment attached to bar.\n  //   optional int32 bar = 2;\n  //\n  //   optional string baz = 3;\n  //   // Comment attached to baz.\n  //   // Another line attached to baz.\n  //\n  //   // Comment attached to qux.\n  //   //\n  //   // Another line attached to qux.\n  //   optional double qux = 4;\n  //\n  //   // Detached comment.  This is not attached to qux or corge\n  //   // because there are blank lines separating it from both.\n  //\n  //   optional string corge = 5;\n  //   /* Block comment attached\n  //    * to corge.  Leading asterisks\n  //    * will be removed. */\n  //   /* Block comment attached to\n  //    * grault. */\n  //   optional int32 grault = 6;\n  bool NextWithComments(string* prev_trailing_comments,\n                        vector<string>* detached_comments,\n                        string* next_leading_comments);\n\n  // Parse helpers ---------------------------------------------------\n\n  // Parses a TYPE_FLOAT token.  This never fails, so long as the text actually\n  // comes from a TYPE_FLOAT token parsed by Tokenizer.  If it doesn't, the\n  // result is undefined (possibly an assert failure).\n  static double ParseFloat(const string& text);\n\n  // Parses a TYPE_STRING token.  This never fails, so long as the text actually\n  // comes from a TYPE_STRING token parsed by Tokenizer.  If it doesn't, the\n  // result is undefined (possibly an assert failure).\n  static void ParseString(const string& text, string* output);\n\n  // Identical to ParseString, but appends to output.\n  static void ParseStringAppend(const string& text, string* output);\n\n  // Parses a TYPE_INTEGER token.  Returns false if the result would be\n  // greater than max_value.  Otherwise, returns true and sets *output to the\n  // result.  If the text is not from a Token of type TYPE_INTEGER originally\n  // parsed by a Tokenizer, the result is undefined (possibly an assert\n  // failure).\n  static bool ParseInteger(const string& text, uint64 max_value,\n                           uint64* output);\n\n  // Options ---------------------------------------------------------\n\n  // Set true to allow floats to be suffixed with the letter 'f'.  Tokens\n  // which would otherwise be integers but which have the 'f' suffix will be\n  // forced to be interpreted as floats.  For all other purposes, the 'f' is\n  // ignored.\n  void set_allow_f_after_float(bool value) { allow_f_after_float_ = value; }\n\n  // Valid values for set_comment_style().\n  enum CommentStyle {\n    // Line comments begin with \"//\", block comments are delimited by \"/*\" and\n    // \"*/\".\n    CPP_COMMENT_STYLE,\n    // Line comments begin with \"#\".  No way to write block comments.\n    SH_COMMENT_STYLE\n  };\n\n  // Sets the comment style.\n  void set_comment_style(CommentStyle style) { comment_style_ = style; }\n\n  // Whether to require whitespace between a number and a field name.\n  // Default is true. Do not use this; for Google-internal cleanup only.\n  void set_require_space_after_number(bool require) {\n    require_space_after_number_ = require;\n  }\n\n  // Whether to allow string literals to span multiple lines. Default is false.\n  // Do not use this; for Google-internal cleanup only.\n  void set_allow_multiline_strings(bool allow) {\n    allow_multiline_strings_ = allow;\n  }\n\n  // External helper: validate an identifier.\n  static bool IsIdentifier(const string& text);\n\n  // -----------------------------------------------------------------\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Tokenizer);\n\n  Token current_;           // Returned by current().\n  Token previous_;          // Returned by previous().\n\n  ZeroCopyInputStream* input_;\n  ErrorCollector* error_collector_;\n\n  char current_char_;       // == buffer_[buffer_pos_], updated by NextChar().\n  const char* buffer_;      // Current buffer returned from input_.\n  int buffer_size_;         // Size of buffer_.\n  int buffer_pos_;          // Current position within the buffer.\n  bool read_error_;         // Did we previously encounter a read error?\n\n  // Line and column number of current_char_ within the whole input stream.\n  int line_;\n  ColumnNumber column_;\n\n  // String to which text should be appended as we advance through it.\n  // Call RecordTo(&str) to start recording and StopRecording() to stop.\n  // E.g. StartToken() calls RecordTo(&current_.text).  record_start_ is the\n  // position within the current buffer where recording started.\n  string* record_target_;\n  int record_start_;\n\n  // Options.\n  bool allow_f_after_float_;\n  CommentStyle comment_style_;\n  bool require_space_after_number_;\n  bool allow_multiline_strings_;\n\n  // Since we count columns we need to interpret tabs somehow.  We'll take\n  // the standard 8-character definition for lack of any way to do better.\n  // This must match the documentation of ColumnNumber.\n  static const int kTabWidth = 8;\n\n  // -----------------------------------------------------------------\n  // Helper methods.\n\n  // Consume this character and advance to the next one.\n  void NextChar();\n\n  // Read a new buffer from the input.\n  void Refresh();\n\n  inline void RecordTo(string* target);\n  inline void StopRecording();\n\n  // Called when the current character is the first character of a new\n  // token (not including whitespace or comments).\n  inline void StartToken();\n  // Called when the current character is the first character after the\n  // end of the last token.  After this returns, current_.text will\n  // contain all text consumed since StartToken() was called.\n  inline void EndToken();\n\n  // Convenience method to add an error at the current line and column.\n  void AddError(const string& message) {\n    error_collector_->AddError(line_, column_, message);\n  }\n\n  // -----------------------------------------------------------------\n  // The following four methods are used to consume tokens of specific\n  // types.  They are actually used to consume all characters *after*\n  // the first, since the calling function consumes the first character\n  // in order to decide what kind of token is being read.\n\n  // Read and consume a string, ending when the given delimiter is\n  // consumed.\n  void ConsumeString(char delimiter);\n\n  // Read and consume a number, returning TYPE_FLOAT or TYPE_INTEGER\n  // depending on what was read.  This needs to know if the first\n  // character was a zero in order to correctly recognize hex and octal\n  // numbers.\n  // It also needs to know if the first character was a . to parse floating\n  // point correctly.\n  TokenType ConsumeNumber(bool started_with_zero, bool started_with_dot);\n\n  // Consume the rest of a line.\n  void ConsumeLineComment(string* content);\n  // Consume until \"*/\".\n  void ConsumeBlockComment(string* content);\n\n  enum NextCommentStatus {\n    // Started a line comment.\n    LINE_COMMENT,\n\n    // Started a block comment.\n    BLOCK_COMMENT,\n\n    // Consumed a slash, then realized it wasn't a comment.  current_ has\n    // been filled in with a slash token.  The caller should return it.\n    SLASH_NOT_COMMENT,\n\n    // We do not appear to be starting a comment here.\n    NO_COMMENT\n  };\n\n  // If we're at the start of a new comment, consume it and return what kind\n  // of comment it is.\n  NextCommentStatus TryConsumeCommentStart();\n\n  // -----------------------------------------------------------------\n  // These helper methods make the parsing code more readable.  The\n  // \"character classes\" referred to are defined at the top of the .cc file.\n  // Basically it is a C++ class with one method:\n  //   static bool InClass(char c);\n  // The method returns true if c is a member of this \"class\", like \"Letter\"\n  // or \"Digit\".\n\n  // Returns true if the current character is of the given character\n  // class, but does not consume anything.\n  template<typename CharacterClass>\n  inline bool LookingAt();\n\n  // If the current character is in the given class, consume it and return\n  // true.  Otherwise return false.\n  // e.g. TryConsumeOne<Letter>()\n  template<typename CharacterClass>\n  inline bool TryConsumeOne();\n\n  // Like above, but try to consume the specific character indicated.\n  inline bool TryConsume(char c);\n\n  // Consume zero or more of the given character class.\n  template<typename CharacterClass>\n  inline void ConsumeZeroOrMore();\n\n  // Consume one or more of the given character class or log the given\n  // error message.\n  // e.g. ConsumeOneOrMore<Digit>(\"Expected digits.\");\n  template<typename CharacterClass>\n  inline void ConsumeOneOrMore(const char* error);\n};\n\n// inline methods ====================================================\ninline const Tokenizer::Token& Tokenizer::current() {\n  return current_;\n}\n\ninline const Tokenizer::Token& Tokenizer::previous() {\n  return previous_;\n}\n\ninline void Tokenizer::ParseString(const string& text, string* output) {\n  output->clear();\n  ParseStringAppend(text, output);\n}\n\n}  // namespace io\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_IO_TOKENIZER_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/tokenizer_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <limits.h>\n#include <math.h>\n\n#include <vector>\n\n#include <google/protobuf/io/tokenizer.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\nnamespace {\n\n// ===================================================================\n// Data-Driven Test Infrastructure\n\n// TODO(kenton):  This is copied from coded_stream_unittest.  This is\n//   temporary until these fetaures are integrated into gTest itself.\n\n// TEST_1D and TEST_2D are macros I'd eventually like to see added to\n// gTest.  These macros can be used to declare tests which should be\n// run multiple times, once for each item in some input array.  TEST_1D\n// tests all cases in a single input array.  TEST_2D tests all\n// combinations of cases from two arrays.  The arrays must be statically\n// defined such that the GOOGLE_ARRAYSIZE() macro works on them.  Example:\n//\n// int kCases[] = {1, 2, 3, 4}\n// TEST_1D(MyFixture, MyTest, kCases) {\n//   EXPECT_GT(kCases_case, 0);\n// }\n//\n// This test iterates through the numbers 1, 2, 3, and 4 and tests that\n// they are all grater than zero.  In case of failure, the exact case\n// which failed will be printed.  The case type must be printable using\n// ostream::operator<<.\n\n#define TEST_1D(FIXTURE, NAME, CASES)                                      \\\n  class FIXTURE##_##NAME##_DD : public FIXTURE {                           \\\n   protected:                                                              \\\n    template <typename CaseType>                                           \\\n    void DoSingleCase(const CaseType& CASES##_case);                       \\\n  };                                                                       \\\n                                                                           \\\n  TEST_F(FIXTURE##_##NAME##_DD, NAME) {                                    \\\n    for (int i = 0; i < GOOGLE_ARRAYSIZE(CASES); i++) {                           \\\n      SCOPED_TRACE(testing::Message()                                      \\\n        << #CASES \" case #\" << i << \": \" << CASES[i]);                     \\\n      DoSingleCase(CASES[i]);                                              \\\n    }                                                                      \\\n  }                                                                        \\\n                                                                           \\\n  template <typename CaseType>                                             \\\n  void FIXTURE##_##NAME##_DD::DoSingleCase(const CaseType& CASES##_case)\n\n#define TEST_2D(FIXTURE, NAME, CASES1, CASES2)                             \\\n  class FIXTURE##_##NAME##_DD : public FIXTURE {                           \\\n   protected:                                                              \\\n    template <typename CaseType1, typename CaseType2>                      \\\n    void DoSingleCase(const CaseType1& CASES1##_case,                      \\\n                      const CaseType2& CASES2##_case);                     \\\n  };                                                                       \\\n                                                                           \\\n  TEST_F(FIXTURE##_##NAME##_DD, NAME) {                                    \\\n    for (int i = 0; i < GOOGLE_ARRAYSIZE(CASES1); i++) {                          \\\n      for (int j = 0; j < GOOGLE_ARRAYSIZE(CASES2); j++) {                        \\\n        SCOPED_TRACE(testing::Message()                                    \\\n          << #CASES1 \" case #\" << i << \": \" << CASES1[i] << \", \"           \\\n          << #CASES2 \" case #\" << j << \": \" << CASES2[j]);                 \\\n        DoSingleCase(CASES1[i], CASES2[j]);                                \\\n      }                                                                    \\\n    }                                                                      \\\n  }                                                                        \\\n                                                                           \\\n  template <typename CaseType1, typename CaseType2>                        \\\n  void FIXTURE##_##NAME##_DD::DoSingleCase(const CaseType1& CASES1##_case, \\\n                                           const CaseType2& CASES2##_case)\n\n// -------------------------------------------------------------------\n\n// An input stream that is basically like an ArrayInputStream but sometimes\n// returns empty buffers, just to throw us off.\nclass TestInputStream : public ZeroCopyInputStream {\n public:\n  TestInputStream(const void* data, int size, int block_size)\n    : array_stream_(data, size, block_size), counter_(0) {}\n  ~TestInputStream() {}\n\n  // implements ZeroCopyInputStream ----------------------------------\n  bool Next(const void** data, int* size) {\n    // We'll return empty buffers starting with the first buffer, and every\n    // 3 and 5 buffers after that.\n    if (counter_ % 3 == 0 || counter_ % 5 == 0) {\n      *data = NULL;\n      *size = 0;\n      ++counter_;\n      return true;\n    } else {\n      ++counter_;\n      return array_stream_.Next(data, size);\n    }\n  }\n\n  void BackUp(int count)  { return array_stream_.BackUp(count); }\n  bool Skip(int count)    { return array_stream_.Skip(count);   }\n  int64 ByteCount() const { return array_stream_.ByteCount();   }\n\n private:\n  ArrayInputStream array_stream_;\n  int counter_;\n};\n\n// -------------------------------------------------------------------\n\n// An error collector which simply concatenates all its errors into a big\n// block of text which can be checked.\nclass TestErrorCollector : public ErrorCollector {\n public:\n  TestErrorCollector() {}\n  ~TestErrorCollector() {}\n\n  string text_;\n\n  // implements ErrorCollector ---------------------------------------\n  void AddError(int line, int column, const string& message) {\n    strings::SubstituteAndAppend(&text_, \"$0:$1: $2\\n\",\n                                 line, column, message);\n  }\n};\n\n// -------------------------------------------------------------------\n\n// We test each operation over a variety of block sizes to insure that\n// we test cases where reads cross buffer boundaries as well as cases\n// where they don't.  This is sort of a brute-force approach to this,\n// but it's easy to write and easy to understand.\nconst int kBlockSizes[] = {1, 2, 3, 5, 7, 13, 32, 1024};\n\nclass TokenizerTest : public testing::Test {\n protected:\n  // For easy testing.\n  uint64 ParseInteger(const string& text) {\n    uint64 result;\n    EXPECT_TRUE(Tokenizer::ParseInteger(text, kuint64max, &result));\n    return result;\n  }\n};\n\n// ===================================================================\n\n// These tests causes gcc 3.3.5 (and earlier?) to give the cryptic error:\n//   \"sorry, unimplemented: `method_call_expr' not supported by dump_expr\"\n#if !defined(__GNUC__) || __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)\n\n// In each test case, the entire input text should parse as a single token\n// of the given type.\nstruct SimpleTokenCase {\n  string input;\n  Tokenizer::TokenType type;\n};\n\ninline ostream& operator<<(ostream& out,\n                           const SimpleTokenCase& test_case) {\n  return out << CEscape(test_case.input);\n}\n\nSimpleTokenCase kSimpleTokenCases[] = {\n  // Test identifiers.\n  { \"hello\",       Tokenizer::TYPE_IDENTIFIER },\n\n  // Test integers.\n  { \"123\",         Tokenizer::TYPE_INTEGER },\n  { \"0xab6\",       Tokenizer::TYPE_INTEGER },\n  { \"0XAB6\",       Tokenizer::TYPE_INTEGER },\n  { \"0X1234567\",   Tokenizer::TYPE_INTEGER },\n  { \"0x89abcdef\",  Tokenizer::TYPE_INTEGER },\n  { \"0x89ABCDEF\",  Tokenizer::TYPE_INTEGER },\n  { \"01234567\",    Tokenizer::TYPE_INTEGER },\n\n  // Test floats.\n  { \"123.45\",      Tokenizer::TYPE_FLOAT },\n  { \"1.\",          Tokenizer::TYPE_FLOAT },\n  { \"1e3\",         Tokenizer::TYPE_FLOAT },\n  { \"1E3\",         Tokenizer::TYPE_FLOAT },\n  { \"1e-3\",        Tokenizer::TYPE_FLOAT },\n  { \"1e+3\",        Tokenizer::TYPE_FLOAT },\n  { \"1.e3\",        Tokenizer::TYPE_FLOAT },\n  { \"1.2e3\",       Tokenizer::TYPE_FLOAT },\n  { \".1\",          Tokenizer::TYPE_FLOAT },\n  { \".1e3\",        Tokenizer::TYPE_FLOAT },\n  { \".1e-3\",       Tokenizer::TYPE_FLOAT },\n  { \".1e+3\",       Tokenizer::TYPE_FLOAT },\n\n  // Test strings.\n  { \"'hello'\",     Tokenizer::TYPE_STRING },\n  { \"\\\"foo\\\"\",     Tokenizer::TYPE_STRING },\n  { \"'a\\\"b'\",      Tokenizer::TYPE_STRING },\n  { \"\\\"a'b\\\"\",     Tokenizer::TYPE_STRING },\n  { \"'a\\\\'b'\",     Tokenizer::TYPE_STRING },\n  { \"\\\"a\\\\\\\"b\\\"\",  Tokenizer::TYPE_STRING },\n  { \"'\\\\xf'\",      Tokenizer::TYPE_STRING },\n  { \"'\\\\0'\",       Tokenizer::TYPE_STRING },\n\n  // Test symbols.\n  { \"+\",           Tokenizer::TYPE_SYMBOL },\n  { \".\",           Tokenizer::TYPE_SYMBOL },\n};\n\nTEST_2D(TokenizerTest, SimpleTokens, kSimpleTokenCases, kBlockSizes) {\n  // Set up the tokenizer.\n  TestInputStream input(kSimpleTokenCases_case.input.data(),\n                        kSimpleTokenCases_case.input.size(),\n                        kBlockSizes_case);\n  TestErrorCollector error_collector;\n  Tokenizer tokenizer(&input, &error_collector);\n\n  // Before Next() is called, the initial token should always be TYPE_START.\n  EXPECT_EQ(Tokenizer::TYPE_START, tokenizer.current().type);\n  EXPECT_EQ(\"\", tokenizer.current().text);\n  EXPECT_EQ(0, tokenizer.current().line);\n  EXPECT_EQ(0, tokenizer.current().column);\n  EXPECT_EQ(0, tokenizer.current().end_column);\n\n  // Parse the token.\n  ASSERT_TRUE(tokenizer.Next());\n\n  // Check that it has the right type.\n  EXPECT_EQ(kSimpleTokenCases_case.type, tokenizer.current().type);\n  // Check that it contains the complete input text.\n  EXPECT_EQ(kSimpleTokenCases_case.input, tokenizer.current().text);\n  // Check that it is located at the beginning of the input\n  EXPECT_EQ(0, tokenizer.current().line);\n  EXPECT_EQ(0, tokenizer.current().column);\n  EXPECT_EQ(kSimpleTokenCases_case.input.size(),\n            tokenizer.current().end_column);\n\n  // There should be no more input.\n  EXPECT_FALSE(tokenizer.Next());\n\n  // After Next() returns false, the token should have type TYPE_END.\n  EXPECT_EQ(Tokenizer::TYPE_END, tokenizer.current().type);\n  EXPECT_EQ(\"\", tokenizer.current().text);\n  EXPECT_EQ(0, tokenizer.current().line);\n  EXPECT_EQ(kSimpleTokenCases_case.input.size(), tokenizer.current().column);\n  EXPECT_EQ(kSimpleTokenCases_case.input.size(),\n            tokenizer.current().end_column);\n\n  // There should be no errors.\n  EXPECT_TRUE(error_collector.text_.empty());\n}\n\nTEST_1D(TokenizerTest, FloatSuffix, kBlockSizes) {\n  // Test the \"allow_f_after_float\" option.\n\n  // Set up the tokenizer.\n  const char* text = \"1f 2.5f 6e3f 7F\";\n  TestInputStream input(text, strlen(text), kBlockSizes_case);\n  TestErrorCollector error_collector;\n  Tokenizer tokenizer(&input, &error_collector);\n  tokenizer.set_allow_f_after_float(true);\n\n  // Advance through tokens and check that they are parsed as expected.\n  ASSERT_TRUE(tokenizer.Next());\n  EXPECT_EQ(tokenizer.current().text, \"1f\");\n  EXPECT_EQ(tokenizer.current().type, Tokenizer::TYPE_FLOAT);\n  ASSERT_TRUE(tokenizer.Next());\n  EXPECT_EQ(tokenizer.current().text, \"2.5f\");\n  EXPECT_EQ(tokenizer.current().type, Tokenizer::TYPE_FLOAT);\n  ASSERT_TRUE(tokenizer.Next());\n  EXPECT_EQ(tokenizer.current().text, \"6e3f\");\n  EXPECT_EQ(tokenizer.current().type, Tokenizer::TYPE_FLOAT);\n  ASSERT_TRUE(tokenizer.Next());\n  EXPECT_EQ(tokenizer.current().text, \"7F\");\n  EXPECT_EQ(tokenizer.current().type, Tokenizer::TYPE_FLOAT);\n\n  // There should be no more input.\n  EXPECT_FALSE(tokenizer.Next());\n  // There should be no errors.\n  EXPECT_TRUE(error_collector.text_.empty());\n}\n\n#endif\n\n// -------------------------------------------------------------------\n\n// In each case, the input is parsed to produce a list of tokens.  The\n// last token in \"output\" must have type TYPE_END.\nstruct MultiTokenCase {\n  string input;\n  Tokenizer::Token output[10];  // The compiler wants a constant array\n                                // size for initialization to work.  There\n                                // is no reason this can't be increased if\n                                // needed.\n};\n\ninline ostream& operator<<(ostream& out,\n                           const MultiTokenCase& test_case) {\n  return out << CEscape(test_case.input);\n}\n\nMultiTokenCase kMultiTokenCases[] = {\n  // Test empty input.\n  { \"\", {\n    { Tokenizer::TYPE_END       , \"\"     , 0,  0 },\n  }},\n\n  // Test all token types at the same time.\n  { \"foo 1 1.2 + 'bar'\", {\n    { Tokenizer::TYPE_IDENTIFIER, \"foo\"  , 0,  0,  3 },\n    { Tokenizer::TYPE_INTEGER   , \"1\"    , 0,  4,  5 },\n    { Tokenizer::TYPE_FLOAT     , \"1.2\"  , 0,  6,  9 },\n    { Tokenizer::TYPE_SYMBOL    , \"+\"    , 0, 10, 11 },\n    { Tokenizer::TYPE_STRING    , \"'bar'\", 0, 12, 17 },\n    { Tokenizer::TYPE_END       , \"\"     , 0, 17, 17 },\n  }},\n\n  // Test that consecutive symbols are parsed as separate tokens.\n  { \"!@+%\", {\n    { Tokenizer::TYPE_SYMBOL    , \"!\"    , 0, 0, 1 },\n    { Tokenizer::TYPE_SYMBOL    , \"@\"    , 0, 1, 2 },\n    { Tokenizer::TYPE_SYMBOL    , \"+\"    , 0, 2, 3 },\n    { Tokenizer::TYPE_SYMBOL    , \"%\"    , 0, 3, 4 },\n    { Tokenizer::TYPE_END       , \"\"     , 0, 4, 4 },\n  }},\n\n  // Test that newlines affect line numbers correctly.\n  { \"foo bar\\nrab oof\", {\n    { Tokenizer::TYPE_IDENTIFIER, \"foo\", 0,  0, 3 },\n    { Tokenizer::TYPE_IDENTIFIER, \"bar\", 0,  4, 7 },\n    { Tokenizer::TYPE_IDENTIFIER, \"rab\", 1,  0, 3 },\n    { Tokenizer::TYPE_IDENTIFIER, \"oof\", 1,  4, 7 },\n    { Tokenizer::TYPE_END       , \"\"   , 1,  7, 7 },\n  }},\n\n  // Test that tabs affect column numbers correctly.\n  { \"foo\\tbar  \\tbaz\", {\n    { Tokenizer::TYPE_IDENTIFIER, \"foo\", 0,  0,  3 },\n    { Tokenizer::TYPE_IDENTIFIER, \"bar\", 0,  8, 11 },\n    { Tokenizer::TYPE_IDENTIFIER, \"baz\", 0, 16, 19 },\n    { Tokenizer::TYPE_END       , \"\"   , 0, 19, 19 },\n  }},\n\n  // Test that tabs in string literals affect column numbers correctly.\n  { \"\\\"foo\\tbar\\\" baz\", {\n    { Tokenizer::TYPE_STRING    , \"\\\"foo\\tbar\\\"\", 0,  0, 12 },\n    { Tokenizer::TYPE_IDENTIFIER, \"baz\"         , 0, 13, 16 },\n    { Tokenizer::TYPE_END       , \"\"            , 0, 16, 16 },\n  }},\n\n  // Test that line comments are ignored.\n  { \"foo // This is a comment\\n\"\n    \"bar // This is another comment\", {\n    { Tokenizer::TYPE_IDENTIFIER, \"foo\", 0,  0,  3 },\n    { Tokenizer::TYPE_IDENTIFIER, \"bar\", 1,  0,  3 },\n    { Tokenizer::TYPE_END       , \"\"   , 1, 30, 30 },\n  }},\n\n  // Test that block comments are ignored.\n  { \"foo /* This is a block comment */ bar\", {\n    { Tokenizer::TYPE_IDENTIFIER, \"foo\", 0,  0,  3 },\n    { Tokenizer::TYPE_IDENTIFIER, \"bar\", 0, 34, 37 },\n    { Tokenizer::TYPE_END       , \"\"   , 0, 37, 37 },\n  }},\n\n  // Test that sh-style comments are not ignored by default.\n  { \"foo # bar\\n\"\n    \"baz\", {\n    { Tokenizer::TYPE_IDENTIFIER, \"foo\", 0, 0, 3 },\n    { Tokenizer::TYPE_SYMBOL    , \"#\"  , 0, 4, 5 },\n    { Tokenizer::TYPE_IDENTIFIER, \"bar\", 0, 6, 9 },\n    { Tokenizer::TYPE_IDENTIFIER, \"baz\", 1, 0, 3 },\n    { Tokenizer::TYPE_END       , \"\"   , 1, 3, 3 },\n  }},\n\n  // Test all whitespace chars\n  { \"foo\\n\\t\\r\\v\\fbar\", {\n    { Tokenizer::TYPE_IDENTIFIER, \"foo\", 0,  0,  3 },\n    { Tokenizer::TYPE_IDENTIFIER, \"bar\", 1, 11, 14 },\n    { Tokenizer::TYPE_END       , \"\"   , 1, 14, 14 },\n  }},\n};\n\nTEST_2D(TokenizerTest, MultipleTokens, kMultiTokenCases, kBlockSizes) {\n  // Set up the tokenizer.\n  TestInputStream input(kMultiTokenCases_case.input.data(),\n                        kMultiTokenCases_case.input.size(),\n                        kBlockSizes_case);\n  TestErrorCollector error_collector;\n  Tokenizer tokenizer(&input, &error_collector);\n\n  // Before Next() is called, the initial token should always be TYPE_START.\n  EXPECT_EQ(Tokenizer::TYPE_START, tokenizer.current().type);\n  EXPECT_EQ(\"\", tokenizer.current().text);\n  EXPECT_EQ(0, tokenizer.current().line);\n  EXPECT_EQ(0, tokenizer.current().column);\n  EXPECT_EQ(0, tokenizer.current().end_column);\n\n  // Loop through all expected tokens.\n  int i = 0;\n  Tokenizer::Token token;\n  do {\n    token = kMultiTokenCases_case.output[i++];\n\n    SCOPED_TRACE(testing::Message() << \"Token #\" << i << \": \" << token.text);\n\n    Tokenizer::Token previous = tokenizer.current();\n\n    // Next() should only return false when it hits the end token.\n    if (token.type != Tokenizer::TYPE_END) {\n      ASSERT_TRUE(tokenizer.Next());\n    } else {\n      ASSERT_FALSE(tokenizer.Next());\n    }\n\n    // Check that the previous token is set correctly.\n    EXPECT_EQ(previous.type, tokenizer.previous().type);\n    EXPECT_EQ(previous.text, tokenizer.previous().text);\n    EXPECT_EQ(previous.line, tokenizer.previous().line);\n    EXPECT_EQ(previous.column, tokenizer.previous().column);\n    EXPECT_EQ(previous.end_column, tokenizer.previous().end_column);\n\n    // Check that the token matches the expected one.\n    EXPECT_EQ(token.type, tokenizer.current().type);\n    EXPECT_EQ(token.text, tokenizer.current().text);\n    EXPECT_EQ(token.line, tokenizer.current().line);\n    EXPECT_EQ(token.column, tokenizer.current().column);\n    EXPECT_EQ(token.end_column, tokenizer.current().end_column);\n\n  } while (token.type != Tokenizer::TYPE_END);\n\n  // There should be no errors.\n  EXPECT_TRUE(error_collector.text_.empty());\n}\n\n// This test causes gcc 3.3.5 (and earlier?) to give the cryptic error:\n//   \"sorry, unimplemented: `method_call_expr' not supported by dump_expr\"\n#if !defined(__GNUC__) || __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)\n\nTEST_1D(TokenizerTest, ShCommentStyle, kBlockSizes) {\n  // Test the \"comment_style\" option.\n\n  const char* text = \"foo # bar\\n\"\n                     \"baz // qux\\n\"\n                     \"corge /* grault */\\n\"\n                     \"garply\";\n  const char* const kTokens[] = {\"foo\",  // \"# bar\" is ignored\n                                 \"baz\", \"/\", \"/\", \"qux\",\n                                 \"corge\", \"/\", \"*\", \"grault\", \"*\", \"/\",\n                                 \"garply\"};\n\n  // Set up the tokenizer.\n  TestInputStream input(text, strlen(text), kBlockSizes_case);\n  TestErrorCollector error_collector;\n  Tokenizer tokenizer(&input, &error_collector);\n  tokenizer.set_comment_style(Tokenizer::SH_COMMENT_STYLE);\n\n  // Advance through tokens and check that they are parsed as expected.\n  for (int i = 0; i < GOOGLE_ARRAYSIZE(kTokens); i++) {\n    EXPECT_TRUE(tokenizer.Next());\n    EXPECT_EQ(tokenizer.current().text, kTokens[i]);\n  }\n\n  // There should be no more input.\n  EXPECT_FALSE(tokenizer.Next());\n  // There should be no errors.\n  EXPECT_TRUE(error_collector.text_.empty());\n}\n\n#endif\n\n// -------------------------------------------------------------------\n\n// In each case, the input is expected to have two tokens named \"prev\" and\n// \"next\" with comments in between.\nstruct DocCommentCase {\n  string input;\n\n  const char* prev_trailing_comments;\n  const char* detached_comments[10];\n  const char* next_leading_comments;\n};\n\ninline ostream& operator<<(ostream& out,\n                           const DocCommentCase& test_case) {\n  return out << CEscape(test_case.input);\n}\n\nDocCommentCase kDocCommentCases[] = {\n  {\n    \"prev next\",\n\n    \"\",\n    {},\n    \"\"\n      },\n\n        {\n      \"prev /* ignored */ next\",\n\n      \"\",\n      {},\n      \"\"\n        },\n\n          {\n        \"prev // trailing comment\\n\"\n            \"next\",\n\n            \" trailing comment\\n\",\n            {},\n            \"\"\n          },\n\n            {\n          \"prev\\n\"\n              \"// leading comment\\n\"\n              \"// line 2\\n\"\n              \"next\",\n\n              \"\",\n              {},\n              \" leading comment\\n\"\n              \" line 2\\n\"\n            },\n\n              {\n            \"prev\\n\"\n                \"// trailing comment\\n\"\n                \"// line 2\\n\"\n                \"\\n\"\n                \"next\",\n\n                \" trailing comment\\n\"\n                \" line 2\\n\",\n                {},\n                \"\"\n              },\n\n                {\n              \"prev // trailing comment\\n\"\n                  \"// leading comment\\n\"\n                  \"// line 2\\n\"\n                  \"next\",\n\n                  \" trailing comment\\n\",\n                  {},\n                  \" leading comment\\n\"\n                  \" line 2\\n\"\n                },\n\n                  {\n                \"prev /* trailing block comment */\\n\"\n                    \"/* leading block comment\\n\"\n                    \" * line 2\\n\"\n                    \" * line 3 */\"\n                    \"next\",\n\n                    \" trailing block comment \",\n                    {},\n                    \" leading block comment\\n\"\n                    \" line 2\\n\"\n                    \" line 3 \"\n                  },\n\n                    {\n                  \"prev\\n\"\n                      \"/* trailing block comment\\n\"\n                      \" * line 2\\n\"\n                      \" * line 3\\n\"\n                      \" */\\n\"\n                      \"/* leading block comment\\n\"\n                      \" * line 2\\n\"\n                      \" * line 3 */\"\n                      \"next\",\n\n                      \" trailing block comment\\n\"\n                      \" line 2\\n\"\n                      \" line 3\\n\",\n                      {},\n                      \" leading block comment\\n\"\n                      \" line 2\\n\"\n                      \" line 3 \"\n                    },\n\n                      {\n                    \"prev\\n\"\n                        \"// trailing comment\\n\"\n                        \"\\n\"\n                        \"// detached comment\\n\"\n                        \"// line 2\\n\"\n                        \"\\n\"\n                        \"// second detached comment\\n\"\n                        \"/* third detached comment\\n\"\n                        \" * line 2 */\\n\"\n                        \"// leading comment\\n\"\n                        \"next\",\n\n                        \" trailing comment\\n\",\n                        {\n                      \" detached comment\\n\"\n                          \" line 2\\n\",\n                          \" second detached comment\\n\",\n                          \" third detached comment\\n\"\n                          \" line 2 \"\n                        },\n                          \" leading comment\\n\"\n                        },\n\n                          {\n                        \"prev /**/\\n\"\n                            \"\\n\"\n                            \"// detached comment\\n\"\n                            \"\\n\"\n                            \"// leading comment\\n\"\n                            \"next\",\n\n                            \"\",\n                            {\n                          \" detached comment\\n\"\n                            },\n                              \" leading comment\\n\"\n                            },\n\n                              {\n                            \"prev /**/\\n\"\n                                \"// leading comment\\n\"\n                                \"next\",\n\n                                \"\",\n                                {},\n                                \" leading comment\\n\"\n                              },\n                              };\n\nTEST_2D(TokenizerTest, DocComments, kDocCommentCases, kBlockSizes) {\n  // Set up the tokenizer.\n  TestInputStream input(kDocCommentCases_case.input.data(),\n                        kDocCommentCases_case.input.size(),\n                        kBlockSizes_case);\n  TestErrorCollector error_collector;\n  Tokenizer tokenizer(&input, &error_collector);\n\n  // Set up a second tokenizer where we'll pass all NULLs to NextWithComments().\n  TestInputStream input2(kDocCommentCases_case.input.data(),\n                        kDocCommentCases_case.input.size(),\n                        kBlockSizes_case);\n  Tokenizer tokenizer2(&input2, &error_collector);\n\n  tokenizer.Next();\n  tokenizer2.Next();\n\n  EXPECT_EQ(\"prev\", tokenizer.current().text);\n  EXPECT_EQ(\"prev\", tokenizer2.current().text);\n\n  string prev_trailing_comments;\n  vector<string> detached_comments;\n  string next_leading_comments;\n  tokenizer.NextWithComments(&prev_trailing_comments, &detached_comments,\n                             &next_leading_comments);\n  tokenizer2.NextWithComments(NULL, NULL, NULL);\n  EXPECT_EQ(\"next\", tokenizer.current().text);\n  EXPECT_EQ(\"next\", tokenizer2.current().text);\n\n  EXPECT_EQ(kDocCommentCases_case.prev_trailing_comments,\n            prev_trailing_comments);\n\n  for (int i = 0; i < detached_comments.size(); i++) {\n    ASSERT_LT(i, GOOGLE_ARRAYSIZE(kDocCommentCases));\n    ASSERT_TRUE(kDocCommentCases_case.detached_comments[i] != NULL);\n    EXPECT_EQ(kDocCommentCases_case.detached_comments[i],\n              detached_comments[i]);\n  }\n\n  // Verify that we matched all the detached comments.\n  EXPECT_EQ(NULL,\n      kDocCommentCases_case.detached_comments[detached_comments.size()]);\n\n  EXPECT_EQ(kDocCommentCases_case.next_leading_comments,\n            next_leading_comments);\n}\n\n// -------------------------------------------------------------------\n\n// Test parse helpers.  It's not really worth setting up a full data-driven\n// test here.\nTEST_F(TokenizerTest, ParseInteger) {\n  EXPECT_EQ(0, ParseInteger(\"0\"));\n  EXPECT_EQ(123, ParseInteger(\"123\"));\n  EXPECT_EQ(0xabcdef12u, ParseInteger(\"0xabcdef12\"));\n  EXPECT_EQ(0xabcdef12u, ParseInteger(\"0xABCDEF12\"));\n  EXPECT_EQ(kuint64max, ParseInteger(\"0xFFFFFFFFFFFFFFFF\"));\n  EXPECT_EQ(01234567, ParseInteger(\"01234567\"));\n  EXPECT_EQ(0X123, ParseInteger(\"0X123\"));\n\n  // Test invalid integers that may still be tokenized as integers.\n  EXPECT_EQ(0, ParseInteger(\"0x\"));\n\n  uint64 i;\n\n  // Test invalid integers that will never be tokenized as integers.\n  EXPECT_FALSE(Tokenizer::ParseInteger(\"zxy\", kuint64max, &i));\n  EXPECT_FALSE(Tokenizer::ParseInteger(\"1.2\", kuint64max, &i));\n  EXPECT_FALSE(Tokenizer::ParseInteger(\"08\", kuint64max, &i));\n  EXPECT_FALSE(Tokenizer::ParseInteger(\"0xg\", kuint64max, &i));\n  EXPECT_FALSE(Tokenizer::ParseInteger(\"-1\", kuint64max, &i));\n\n  // Test overflows.\n  EXPECT_TRUE (Tokenizer::ParseInteger(\"0\", 0, &i));\n  EXPECT_FALSE(Tokenizer::ParseInteger(\"1\", 0, &i));\n  EXPECT_TRUE (Tokenizer::ParseInteger(\"1\", 1, &i));\n  EXPECT_TRUE (Tokenizer::ParseInteger(\"12345\", 12345, &i));\n  EXPECT_FALSE(Tokenizer::ParseInteger(\"12346\", 12345, &i));\n  EXPECT_TRUE (Tokenizer::ParseInteger(\"0xFFFFFFFFFFFFFFFF\" , kuint64max, &i));\n  EXPECT_FALSE(Tokenizer::ParseInteger(\"0x10000000000000000\", kuint64max, &i));\n}\n\nTEST_F(TokenizerTest, ParseFloat) {\n  EXPECT_DOUBLE_EQ(1    , Tokenizer::ParseFloat(\"1.\"));\n  EXPECT_DOUBLE_EQ(1e3  , Tokenizer::ParseFloat(\"1e3\"));\n  EXPECT_DOUBLE_EQ(1e3  , Tokenizer::ParseFloat(\"1E3\"));\n  EXPECT_DOUBLE_EQ(1.5e3, Tokenizer::ParseFloat(\"1.5e3\"));\n  EXPECT_DOUBLE_EQ(.1   , Tokenizer::ParseFloat(\".1\"));\n  EXPECT_DOUBLE_EQ(.25  , Tokenizer::ParseFloat(\".25\"));\n  EXPECT_DOUBLE_EQ(.1e3 , Tokenizer::ParseFloat(\".1e3\"));\n  EXPECT_DOUBLE_EQ(.25e3, Tokenizer::ParseFloat(\".25e3\"));\n  EXPECT_DOUBLE_EQ(.1e+3, Tokenizer::ParseFloat(\".1e+3\"));\n  EXPECT_DOUBLE_EQ(.1e-3, Tokenizer::ParseFloat(\".1e-3\"));\n  EXPECT_DOUBLE_EQ(5    , Tokenizer::ParseFloat(\"5\"));\n  EXPECT_DOUBLE_EQ(6e-12, Tokenizer::ParseFloat(\"6e-12\"));\n  EXPECT_DOUBLE_EQ(1.2  , Tokenizer::ParseFloat(\"1.2\"));\n  EXPECT_DOUBLE_EQ(1.e2 , Tokenizer::ParseFloat(\"1.e2\"));\n\n  // Test invalid integers that may still be tokenized as integers.\n  EXPECT_DOUBLE_EQ(1, Tokenizer::ParseFloat(\"1e\"));\n  EXPECT_DOUBLE_EQ(1, Tokenizer::ParseFloat(\"1e-\"));\n  EXPECT_DOUBLE_EQ(1, Tokenizer::ParseFloat(\"1.e\"));\n\n  // Test 'f' suffix.\n  EXPECT_DOUBLE_EQ(1, Tokenizer::ParseFloat(\"1f\"));\n  EXPECT_DOUBLE_EQ(1, Tokenizer::ParseFloat(\"1.0f\"));\n  EXPECT_DOUBLE_EQ(1, Tokenizer::ParseFloat(\"1F\"));\n\n  // These should parse successfully even though they are out of range.\n  // Overflows become infinity and underflows become zero.\n  EXPECT_EQ(     0.0, Tokenizer::ParseFloat(\"1e-9999999999999999999999999999\"));\n  EXPECT_EQ(HUGE_VAL, Tokenizer::ParseFloat(\"1e+9999999999999999999999999999\"));\n\n#ifdef PROTOBUF_HAS_DEATH_TEST  // death tests do not work on Windows yet\n  // Test invalid integers that will never be tokenized as integers.\n  EXPECT_DEBUG_DEATH(Tokenizer::ParseFloat(\"zxy\"),\n    \"passed text that could not have been tokenized as a float\");\n  EXPECT_DEBUG_DEATH(Tokenizer::ParseFloat(\"1-e0\"),\n    \"passed text that could not have been tokenized as a float\");\n  EXPECT_DEBUG_DEATH(Tokenizer::ParseFloat(\"-1.0\"),\n    \"passed text that could not have been tokenized as a float\");\n#endif  // PROTOBUF_HAS_DEATH_TEST\n}\n\nTEST_F(TokenizerTest, ParseString) {\n  string output;\n  Tokenizer::ParseString(\"'hello'\", &output);\n  EXPECT_EQ(\"hello\", output);\n  Tokenizer::ParseString(\"\\\"blah\\\\nblah2\\\"\", &output);\n  EXPECT_EQ(\"blah\\nblah2\", output);\n  Tokenizer::ParseString(\"'\\\\1x\\\\1\\\\123\\\\739\\\\52\\\\334n\\\\3'\", &output);\n  EXPECT_EQ(\"\\1x\\1\\123\\739\\52\\334n\\3\", output);\n  Tokenizer::ParseString(\"'\\\\x20\\\\x4'\", &output);\n  EXPECT_EQ(\"\\x20\\x4\", output);\n\n  // Test invalid strings that may still be tokenized as strings.\n  Tokenizer::ParseString(\"\\\"\\\\a\\\\l\\\\v\\\\t\", &output);  // \\l is invalid\n  EXPECT_EQ(\"\\a?\\v\\t\", output);\n  Tokenizer::ParseString(\"'\", &output);\n  EXPECT_EQ(\"\", output);\n  Tokenizer::ParseString(\"'\\\\\", &output);\n  EXPECT_EQ(\"\\\\\", output);\n\n  // Experiment with Unicode escapes. Here are one-, two- and three-byte Unicode\n  // characters.\n  Tokenizer::ParseString(\"'\\\\u0024\\\\u00a2\\\\u20ac\\\\U00024b62XX'\", &output);\n  EXPECT_EQ(\"$¢€𤭢XX\", output);\n  // Same thing encoded using UTF16.\n  Tokenizer::ParseString(\"'\\\\u0024\\\\u00a2\\\\u20ac\\\\ud852\\\\udf62XX'\", &output);\n  EXPECT_EQ(\"$¢€𤭢XX\", output);\n  // Here's some broken UTF16; there's a head surrogate with no tail surrogate.\n  // We just output this as if it were UTF8; it's not a defined code point, but\n  // it has a defined encoding.\n  Tokenizer::ParseString(\"'\\\\ud852XX'\", &output);\n  EXPECT_EQ(\"\\xed\\xa1\\x92XX\", output);\n  // Malformed escape: Demons may fly out of the nose.\n  Tokenizer::ParseString(\"\\\\u0\", &output);\n  EXPECT_EQ(\"u0\", output);\n\n  // Test invalid strings that will never be tokenized as strings.\n#ifdef PROTOBUF_HAS_DEATH_TEST  // death tests do not work on Windows yet\n  EXPECT_DEBUG_DEATH(Tokenizer::ParseString(\"\", &output),\n    \"passed text that could not have been tokenized as a string\");\n#endif  // PROTOBUF_HAS_DEATH_TEST\n}\n\nTEST_F(TokenizerTest, ParseStringAppend) {\n  // Check that ParseString and ParseStringAppend differ.\n  string output(\"stuff+\");\n  Tokenizer::ParseStringAppend(\"'hello'\", &output);\n  EXPECT_EQ(\"stuff+hello\", output);\n  Tokenizer::ParseString(\"'hello'\", &output);\n  EXPECT_EQ(\"hello\", output);\n}\n\n// -------------------------------------------------------------------\n\n// Each case parses some input text, ignoring the tokens produced, and\n// checks that the error output matches what is expected.\nstruct ErrorCase {\n  string input;\n  bool recoverable;  // True if the tokenizer should be able to recover and\n                     // parse more tokens after seeing this error.  Cases\n                     // for which this is true must end with \"foo\" as\n                     // the last token, which the test will check for.\n  const char* errors;\n};\n\ninline ostream& operator<<(ostream& out,\n                           const ErrorCase& test_case) {\n  return out << CEscape(test_case.input);\n}\n\nErrorCase kErrorCases[] = {\n  // String errors.\n  { \"'\\\\l' foo\", true,\n    \"0:2: Invalid escape sequence in string literal.\\n\" },\n  { \"'\\\\X' foo\", true,\n    \"0:2: Invalid escape sequence in string literal.\\n\" },\n  { \"'\\\\x' foo\", true,\n    \"0:3: Expected hex digits for escape sequence.\\n\" },\n  { \"'foo\", false,\n    \"0:4: Unexpected end of string.\\n\" },\n  { \"'bar\\nfoo\", true,\n    \"0:4: String literals cannot cross line boundaries.\\n\" },\n  { \"'\\\\u01' foo\", true,\n    \"0:5: Expected four hex digits for \\\\u escape sequence.\\n\" },\n  { \"'\\\\u01' foo\", true,\n    \"0:5: Expected four hex digits for \\\\u escape sequence.\\n\" },\n  { \"'\\\\uXYZ' foo\", true,\n    \"0:3: Expected four hex digits for \\\\u escape sequence.\\n\" },\n\n  // Integer errors.\n  { \"123foo\", true,\n    \"0:3: Need space between number and identifier.\\n\" },\n\n  // Hex/octal errors.\n  { \"0x foo\", true,\n    \"0:2: \\\"0x\\\" must be followed by hex digits.\\n\" },\n  { \"0541823 foo\", true,\n    \"0:4: Numbers starting with leading zero must be in octal.\\n\" },\n  { \"0x123z foo\", true,\n    \"0:5: Need space between number and identifier.\\n\" },\n  { \"0x123.4 foo\", true,\n    \"0:5: Hex and octal numbers must be integers.\\n\" },\n  { \"0123.4 foo\", true,\n    \"0:4: Hex and octal numbers must be integers.\\n\" },\n\n  // Float errors.\n  { \"1e foo\", true,\n    \"0:2: \\\"e\\\" must be followed by exponent.\\n\" },\n  { \"1e- foo\", true,\n    \"0:3: \\\"e\\\" must be followed by exponent.\\n\" },\n  { \"1.2.3 foo\", true,\n    \"0:3: Already saw decimal point or exponent; can't have another one.\\n\" },\n  { \"1e2.3 foo\", true,\n    \"0:3: Already saw decimal point or exponent; can't have another one.\\n\" },\n  { \"a.1 foo\", true,\n    \"0:1: Need space between identifier and decimal point.\\n\" },\n  // allow_f_after_float not enabled, so this should be an error.\n  { \"1.0f foo\", true,\n    \"0:3: Need space between number and identifier.\\n\" },\n\n  // Block comment errors.\n  { \"/*\", false,\n    \"0:2: End-of-file inside block comment.\\n\"\n    \"0:0:   Comment started here.\\n\"},\n  { \"/*/*/ foo\", true,\n    \"0:3: \\\"/*\\\" inside block comment.  Block comments cannot be nested.\\n\"},\n\n  // Control characters.  Multiple consecutive control characters should only\n  // produce one error.\n  { \"\\b foo\", true,\n    \"0:0: Invalid control characters encountered in text.\\n\" },\n  { \"\\b\\b foo\", true,\n    \"0:0: Invalid control characters encountered in text.\\n\" },\n\n  // Check that control characters at end of input don't result in an\n  // infinite loop.\n  { \"\\b\", false,\n    \"0:0: Invalid control characters encountered in text.\\n\" },\n\n  // Check recovery from '\\0'.  We have to explicitly specify the length of\n  // these strings because otherwise the string constructor will just call\n  // strlen() which will see the first '\\0' and think that is the end of the\n  // string.\n  { string(\"\\0foo\", 4), true,\n    \"0:0: Invalid control characters encountered in text.\\n\" },\n  { string(\"\\0\\0foo\", 5), true,\n    \"0:0: Invalid control characters encountered in text.\\n\" },\n\n  // Check error from high order bits set\n  { \"\\300foo\", true,\n    \"0:0: Interpreting non ascii codepoint 192.\\n\" },\n};\n\nTEST_2D(TokenizerTest, Errors, kErrorCases, kBlockSizes) {\n  // Set up the tokenizer.\n  TestInputStream input(kErrorCases_case.input.data(),\n                        kErrorCases_case.input.size(),\n                        kBlockSizes_case);\n  TestErrorCollector error_collector;\n  Tokenizer tokenizer(&input, &error_collector);\n\n  // Ignore all input, except remember if the last token was \"foo\".\n  bool last_was_foo = false;\n  while (tokenizer.Next()) {\n    last_was_foo = tokenizer.current().text == \"foo\";\n  }\n\n  // Check that the errors match what was expected.\n  EXPECT_EQ(kErrorCases_case.errors, error_collector.text_);\n\n  // If the error was recoverable, make sure we saw \"foo\" after it.\n  if (kErrorCases_case.recoverable) {\n    EXPECT_TRUE(last_was_foo);\n  }\n}\n\n// -------------------------------------------------------------------\n\nTEST_1D(TokenizerTest, BackUpOnDestruction, kBlockSizes) {\n  string text = \"foo bar\";\n  TestInputStream input(text.data(), text.size(), kBlockSizes_case);\n\n  // Create a tokenizer, read one token, then destroy it.\n  {\n    TestErrorCollector error_collector;\n    Tokenizer tokenizer(&input, &error_collector);\n\n    tokenizer.Next();\n  }\n\n  // Only \"foo\" should have been read.\n  EXPECT_EQ(strlen(\"foo\"), input.ByteCount());\n}\n\n\n}  // namespace\n}  // namespace io\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/zero_copy_stream.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/io/zero_copy_stream.h>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\n\nZeroCopyInputStream::~ZeroCopyInputStream() {}\nZeroCopyOutputStream::~ZeroCopyOutputStream() {}\n\n\nbool ZeroCopyOutputStream::WriteAliasedRaw(const void* /* data */,\n                                           int /* size */) {\n  GOOGLE_LOG(FATAL) << \"This ZeroCopyOutputStream doesn't support aliasing. \"\n                \"Reaching here usually means a ZeroCopyOutputStream \"\n                \"implementation bug.\";\n  return false;\n}\n\n}  // namespace io\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/zero_copy_stream.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This file contains the ZeroCopyInputStream and ZeroCopyOutputStream\n// interfaces, which represent abstract I/O streams to and from which\n// protocol buffers can be read and written.  For a few simple\n// implementations of these interfaces, see zero_copy_stream_impl.h.\n//\n// These interfaces are different from classic I/O streams in that they\n// try to minimize the amount of data copying that needs to be done.\n// To accomplish this, responsibility for allocating buffers is moved to\n// the stream object, rather than being the responsibility of the caller.\n// So, the stream can return a buffer which actually points directly into\n// the final data structure where the bytes are to be stored, and the caller\n// can interact directly with that buffer, eliminating an intermediate copy\n// operation.\n//\n// As an example, consider the common case in which you are reading bytes\n// from an array that is already in memory (or perhaps an mmap()ed file).\n// With classic I/O streams, you would do something like:\n//   char buffer[BUFFER_SIZE];\n//   input->Read(buffer, BUFFER_SIZE);\n//   DoSomething(buffer, BUFFER_SIZE);\n// Then, the stream basically just calls memcpy() to copy the data from\n// the array into your buffer.  With a ZeroCopyInputStream, you would do\n// this instead:\n//   const void* buffer;\n//   int size;\n//   input->Next(&buffer, &size);\n//   DoSomething(buffer, size);\n// Here, no copy is performed.  The input stream returns a pointer directly\n// into the backing array, and the caller ends up reading directly from it.\n//\n// If you want to be able to read the old-fashion way, you can create\n// a CodedInputStream or CodedOutputStream wrapping these objects and use\n// their ReadRaw()/WriteRaw() methods.  These will, of course, add a copy\n// step, but Coded*Stream will handle buffering so at least it will be\n// reasonably efficient.\n//\n// ZeroCopyInputStream example:\n//   // Read in a file and print its contents to stdout.\n//   int fd = open(\"myfile\", O_RDONLY);\n//   ZeroCopyInputStream* input = new FileInputStream(fd);\n//\n//   const void* buffer;\n//   int size;\n//   while (input->Next(&buffer, &size)) {\n//     cout.write(buffer, size);\n//   }\n//\n//   delete input;\n//   close(fd);\n//\n// ZeroCopyOutputStream example:\n//   // Copy the contents of \"infile\" to \"outfile\", using plain read() for\n//   // \"infile\" but a ZeroCopyOutputStream for \"outfile\".\n//   int infd = open(\"infile\", O_RDONLY);\n//   int outfd = open(\"outfile\", O_WRONLY);\n//   ZeroCopyOutputStream* output = new FileOutputStream(outfd);\n//\n//   void* buffer;\n//   int size;\n//   while (output->Next(&buffer, &size)) {\n//     int bytes = read(infd, buffer, size);\n//     if (bytes < size) {\n//       // Reached EOF.\n//       output->BackUp(size - bytes);\n//       break;\n//     }\n//   }\n//\n//   delete output;\n//   close(infd);\n//   close(outfd);\n\n#ifndef GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_H__\n#define GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_H__\n\n#include <string>\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\n\nnamespace protobuf {\nnamespace io {\n\n// Defined in this file.\nclass ZeroCopyInputStream;\nclass ZeroCopyOutputStream;\n\n// Abstract interface similar to an input stream but designed to minimize\n// copying.\nclass LIBPROTOBUF_EXPORT ZeroCopyInputStream {\n public:\n  inline ZeroCopyInputStream() {}\n  virtual ~ZeroCopyInputStream();\n\n  // Obtains a chunk of data from the stream.\n  //\n  // Preconditions:\n  // * \"size\" and \"data\" are not NULL.\n  //\n  // Postconditions:\n  // * If the returned value is false, there is no more data to return or\n  //   an error occurred.  All errors are permanent.\n  // * Otherwise, \"size\" points to the actual number of bytes read and \"data\"\n  //   points to a pointer to a buffer containing these bytes.\n  // * Ownership of this buffer remains with the stream, and the buffer\n  //   remains valid only until some other method of the stream is called\n  //   or the stream is destroyed.\n  // * It is legal for the returned buffer to have zero size, as long\n  //   as repeatedly calling Next() eventually yields a buffer with non-zero\n  //   size.\n  virtual bool Next(const void** data, int* size) = 0;\n\n  // Backs up a number of bytes, so that the next call to Next() returns\n  // data again that was already returned by the last call to Next().  This\n  // is useful when writing procedures that are only supposed to read up\n  // to a certain point in the input, then return.  If Next() returns a\n  // buffer that goes beyond what you wanted to read, you can use BackUp()\n  // to return to the point where you intended to finish.\n  //\n  // Preconditions:\n  // * The last method called must have been Next().\n  // * count must be less than or equal to the size of the last buffer\n  //   returned by Next().\n  //\n  // Postconditions:\n  // * The last \"count\" bytes of the last buffer returned by Next() will be\n  //   pushed back into the stream.  Subsequent calls to Next() will return\n  //   the same data again before producing new data.\n  virtual void BackUp(int count) = 0;\n\n  // Skips a number of bytes.  Returns false if the end of the stream is\n  // reached or some input error occurred.  In the end-of-stream case, the\n  // stream is advanced to the end of the stream (so ByteCount() will return\n  // the total size of the stream).\n  virtual bool Skip(int count) = 0;\n\n  // Returns the total number of bytes read since this object was created.\n  virtual int64 ByteCount() const = 0;\n\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ZeroCopyInputStream);\n};\n\n// Abstract interface similar to an output stream but designed to minimize\n// copying.\nclass LIBPROTOBUF_EXPORT ZeroCopyOutputStream {\n public:\n  inline ZeroCopyOutputStream() {}\n  virtual ~ZeroCopyOutputStream();\n\n  // Obtains a buffer into which data can be written.  Any data written\n  // into this buffer will eventually (maybe instantly, maybe later on)\n  // be written to the output.\n  //\n  // Preconditions:\n  // * \"size\" and \"data\" are not NULL.\n  //\n  // Postconditions:\n  // * If the returned value is false, an error occurred.  All errors are\n  //   permanent.\n  // * Otherwise, \"size\" points to the actual number of bytes in the buffer\n  //   and \"data\" points to the buffer.\n  // * Ownership of this buffer remains with the stream, and the buffer\n  //   remains valid only until some other method of the stream is called\n  //   or the stream is destroyed.\n  // * Any data which the caller stores in this buffer will eventually be\n  //   written to the output (unless BackUp() is called).\n  // * It is legal for the returned buffer to have zero size, as long\n  //   as repeatedly calling Next() eventually yields a buffer with non-zero\n  //   size.\n  virtual bool Next(void** data, int* size) = 0;\n\n  // Backs up a number of bytes, so that the end of the last buffer returned\n  // by Next() is not actually written.  This is needed when you finish\n  // writing all the data you want to write, but the last buffer was bigger\n  // than you needed.  You don't want to write a bunch of garbage after the\n  // end of your data, so you use BackUp() to back up.\n  //\n  // Preconditions:\n  // * The last method called must have been Next().\n  // * count must be less than or equal to the size of the last buffer\n  //   returned by Next().\n  // * The caller must not have written anything to the last \"count\" bytes\n  //   of that buffer.\n  //\n  // Postconditions:\n  // * The last \"count\" bytes of the last buffer returned by Next() will be\n  //   ignored.\n  virtual void BackUp(int count) = 0;\n\n  // Returns the total number of bytes written since this object was created.\n  virtual int64 ByteCount() const = 0;\n\n  // Write a given chunk of data to the output.  Some output streams may\n  // implement this in a way that avoids copying. Check AllowsAliasing() before\n  // calling WriteAliasedRaw(). It will GOOGLE_CHECK fail if WriteAliasedRaw() is\n  // called on a stream that does not allow aliasing.\n  //\n  // NOTE: It is caller's responsibility to ensure that the chunk of memory\n  // remains live until all of the data has been consumed from the stream.\n  virtual bool WriteAliasedRaw(const void* data, int size);\n  virtual bool AllowsAliasing() const { return false; }\n\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ZeroCopyOutputStream);\n};\n\n}  // namespace io\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/zero_copy_stream_impl.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifdef _MSC_VER\n#include <io.h>\n#else\n#include <unistd.h>\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n#endif\n#include <errno.h>\n#include <iostream>\n#include <algorithm>\n\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/stl_util.h>\n\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\n\n#ifdef _WIN32\n// Win32 lseek is broken:  If invoked on a non-seekable file descriptor, its\n// return value is undefined.  We re-define it to always produce an error.\n#define lseek(fd, offset, origin) ((off_t)-1)\n#endif\n\nnamespace {\n\n// EINTR sucks.\nint close_no_eintr(int fd) {\n  int result;\n  do {\n    result = close(fd);\n  } while (result < 0 && errno == EINTR);\n  return result;\n}\n\n}  // namespace\n\n\n// ===================================================================\n\nFileInputStream::FileInputStream(int file_descriptor, int block_size)\n  : copying_input_(file_descriptor),\n    impl_(&copying_input_, block_size) {\n}\n\nFileInputStream::~FileInputStream() {}\n\nbool FileInputStream::Close() {\n  return copying_input_.Close();\n}\n\nbool FileInputStream::Next(const void** data, int* size) {\n  return impl_.Next(data, size);\n}\n\nvoid FileInputStream::BackUp(int count) {\n  impl_.BackUp(count);\n}\n\nbool FileInputStream::Skip(int count) {\n  return impl_.Skip(count);\n}\n\nint64 FileInputStream::ByteCount() const {\n  return impl_.ByteCount();\n}\n\nFileInputStream::CopyingFileInputStream::CopyingFileInputStream(\n    int file_descriptor)\n  : file_(file_descriptor),\n    close_on_delete_(false),\n    is_closed_(false),\n    errno_(0),\n    previous_seek_failed_(false) {\n}\n\nFileInputStream::CopyingFileInputStream::~CopyingFileInputStream() {\n  if (close_on_delete_) {\n    if (!Close()) {\n      GOOGLE_LOG(ERROR) << \"close() failed: \" << strerror(errno_);\n    }\n  }\n}\n\nbool FileInputStream::CopyingFileInputStream::Close() {\n  GOOGLE_CHECK(!is_closed_);\n\n  is_closed_ = true;\n  if (close_no_eintr(file_) != 0) {\n    // The docs on close() do not specify whether a file descriptor is still\n    // open after close() fails with EIO.  However, the glibc source code\n    // seems to indicate that it is not.\n    errno_ = errno;\n    return false;\n  }\n\n  return true;\n}\n\nint FileInputStream::CopyingFileInputStream::Read(void* buffer, int size) {\n  GOOGLE_CHECK(!is_closed_);\n\n  int result;\n  do {\n    result = read(file_, buffer, size);\n  } while (result < 0 && errno == EINTR);\n\n  if (result < 0) {\n    // Read error (not EOF).\n    errno_ = errno;\n  }\n\n  return result;\n}\n\nint FileInputStream::CopyingFileInputStream::Skip(int count) {\n  GOOGLE_CHECK(!is_closed_);\n\n  if (!previous_seek_failed_ &&\n      lseek(file_, count, SEEK_CUR) != (off_t)-1) {\n    // Seek succeeded.\n    return count;\n  } else {\n    // Failed to seek.\n\n    // Note to self:  Don't seek again.  This file descriptor doesn't\n    // support it.\n    previous_seek_failed_ = true;\n\n    // Use the default implementation.\n    return CopyingInputStream::Skip(count);\n  }\n}\n\n// ===================================================================\n\nFileOutputStream::FileOutputStream(int file_descriptor, int block_size)\n  : copying_output_(file_descriptor),\n    impl_(&copying_output_, block_size) {\n}\n\nFileOutputStream::~FileOutputStream() {\n  impl_.Flush();\n}\n\nbool FileOutputStream::Close() {\n  bool flush_succeeded = impl_.Flush();\n  return copying_output_.Close() && flush_succeeded;\n}\n\nbool FileOutputStream::Flush() {\n  return impl_.Flush();\n}\n\nbool FileOutputStream::Next(void** data, int* size) {\n  return impl_.Next(data, size);\n}\n\nvoid FileOutputStream::BackUp(int count) {\n  impl_.BackUp(count);\n}\n\nint64 FileOutputStream::ByteCount() const {\n  return impl_.ByteCount();\n}\n\nFileOutputStream::CopyingFileOutputStream::CopyingFileOutputStream(\n    int file_descriptor)\n  : file_(file_descriptor),\n    close_on_delete_(false),\n    is_closed_(false),\n    errno_(0) {\n}\n\nFileOutputStream::CopyingFileOutputStream::~CopyingFileOutputStream() {\n  if (close_on_delete_) {\n    if (!Close()) {\n      GOOGLE_LOG(ERROR) << \"close() failed: \" << strerror(errno_);\n    }\n  }\n}\n\nbool FileOutputStream::CopyingFileOutputStream::Close() {\n  GOOGLE_CHECK(!is_closed_);\n\n  is_closed_ = true;\n  if (close_no_eintr(file_) != 0) {\n    // The docs on close() do not specify whether a file descriptor is still\n    // open after close() fails with EIO.  However, the glibc source code\n    // seems to indicate that it is not.\n    errno_ = errno;\n    return false;\n  }\n\n  return true;\n}\n\nbool FileOutputStream::CopyingFileOutputStream::Write(\n    const void* buffer, int size) {\n  GOOGLE_CHECK(!is_closed_);\n  int total_written = 0;\n\n  const uint8* buffer_base = reinterpret_cast<const uint8*>(buffer);\n\n  while (total_written < size) {\n    int bytes;\n    do {\n      bytes = write(file_, buffer_base + total_written, size - total_written);\n    } while (bytes < 0 && errno == EINTR);\n\n    if (bytes <= 0) {\n      // Write error.\n\n      // FIXME(kenton):  According to the man page, if write() returns zero,\n      //   there was no error; write() simply did not write anything.  It's\n      //   unclear under what circumstances this might happen, but presumably\n      //   errno won't be set in this case.  I am confused as to how such an\n      //   event should be handled.  For now I'm treating it as an error, since\n      //   retrying seems like it could lead to an infinite loop.  I suspect\n      //   this never actually happens anyway.\n\n      if (bytes < 0) {\n        errno_ = errno;\n      }\n      return false;\n    }\n    total_written += bytes;\n  }\n\n  return true;\n}\n\n// ===================================================================\n\nIstreamInputStream::IstreamInputStream(istream* input, int block_size)\n  : copying_input_(input),\n    impl_(&copying_input_, block_size) {\n}\n\nIstreamInputStream::~IstreamInputStream() {}\n\nbool IstreamInputStream::Next(const void** data, int* size) {\n  return impl_.Next(data, size);\n}\n\nvoid IstreamInputStream::BackUp(int count) {\n  impl_.BackUp(count);\n}\n\nbool IstreamInputStream::Skip(int count) {\n  return impl_.Skip(count);\n}\n\nint64 IstreamInputStream::ByteCount() const {\n  return impl_.ByteCount();\n}\n\nIstreamInputStream::CopyingIstreamInputStream::CopyingIstreamInputStream(\n    istream* input)\n  : input_(input) {\n}\n\nIstreamInputStream::CopyingIstreamInputStream::~CopyingIstreamInputStream() {}\n\nint IstreamInputStream::CopyingIstreamInputStream::Read(\n    void* buffer, int size) {\n  input_->read(reinterpret_cast<char*>(buffer), size);\n  int result = input_->gcount();\n  if (result == 0 && input_->fail() && !input_->eof()) {\n    return -1;\n  }\n  return result;\n}\n\n// ===================================================================\n\nOstreamOutputStream::OstreamOutputStream(ostream* output, int block_size)\n  : copying_output_(output),\n    impl_(&copying_output_, block_size) {\n}\n\nOstreamOutputStream::~OstreamOutputStream() {\n  impl_.Flush();\n}\n\nbool OstreamOutputStream::Next(void** data, int* size) {\n  return impl_.Next(data, size);\n}\n\nvoid OstreamOutputStream::BackUp(int count) {\n  impl_.BackUp(count);\n}\n\nint64 OstreamOutputStream::ByteCount() const {\n  return impl_.ByteCount();\n}\n\nOstreamOutputStream::CopyingOstreamOutputStream::CopyingOstreamOutputStream(\n    ostream* output)\n  : output_(output) {\n}\n\nOstreamOutputStream::CopyingOstreamOutputStream::~CopyingOstreamOutputStream() {\n}\n\nbool OstreamOutputStream::CopyingOstreamOutputStream::Write(\n    const void* buffer, int size) {\n  output_->write(reinterpret_cast<const char*>(buffer), size);\n  return output_->good();\n}\n\n// ===================================================================\n\nConcatenatingInputStream::ConcatenatingInputStream(\n    ZeroCopyInputStream* const streams[], int count)\n  : streams_(streams), stream_count_(count), bytes_retired_(0) {\n}\n\nConcatenatingInputStream::~ConcatenatingInputStream() {\n}\n\nbool ConcatenatingInputStream::Next(const void** data, int* size) {\n  while (stream_count_ > 0) {\n    if (streams_[0]->Next(data, size)) return true;\n\n    // That stream is done.  Advance to the next one.\n    bytes_retired_ += streams_[0]->ByteCount();\n    ++streams_;\n    --stream_count_;\n  }\n\n  // No more streams.\n  return false;\n}\n\nvoid ConcatenatingInputStream::BackUp(int count) {\n  if (stream_count_ > 0) {\n    streams_[0]->BackUp(count);\n  } else {\n    GOOGLE_LOG(DFATAL) << \"Can't BackUp() after failed Next().\";\n  }\n}\n\nbool ConcatenatingInputStream::Skip(int count) {\n  while (stream_count_ > 0) {\n    // Assume that ByteCount() can be used to find out how much we actually\n    // skipped when Skip() fails.\n    int64 target_byte_count = streams_[0]->ByteCount() + count;\n    if (streams_[0]->Skip(count)) return true;\n\n    // Hit the end of the stream.  Figure out how many more bytes we still have\n    // to skip.\n    int64 final_byte_count = streams_[0]->ByteCount();\n    GOOGLE_DCHECK_LT(final_byte_count, target_byte_count);\n    count = target_byte_count - final_byte_count;\n\n    // That stream is done.  Advance to the next one.\n    bytes_retired_ += final_byte_count;\n    ++streams_;\n    --stream_count_;\n  }\n\n  return false;\n}\n\nint64 ConcatenatingInputStream::ByteCount() const {\n  if (stream_count_ == 0) {\n    return bytes_retired_;\n  } else {\n    return bytes_retired_ + streams_[0]->ByteCount();\n  }\n}\n\n\n// ===================================================================\n\nLimitingInputStream::LimitingInputStream(ZeroCopyInputStream* input,\n                                         int64 limit)\n  : input_(input), limit_(limit) {\n  prior_bytes_read_ = input_->ByteCount();\n}\n\nLimitingInputStream::~LimitingInputStream() {\n  // If we overshot the limit, back up.\n  if (limit_ < 0) input_->BackUp(-limit_);\n}\n\nbool LimitingInputStream::Next(const void** data, int* size) {\n  if (limit_ <= 0) return false;\n  if (!input_->Next(data, size)) return false;\n\n  limit_ -= *size;\n  if (limit_ < 0) {\n    // We overshot the limit.  Reduce *size to hide the rest of the buffer.\n    *size += limit_;\n  }\n  return true;\n}\n\nvoid LimitingInputStream::BackUp(int count) {\n  if (limit_ < 0) {\n    input_->BackUp(count - limit_);\n    limit_ = count;\n  } else {\n    input_->BackUp(count);\n    limit_ += count;\n  }\n}\n\nbool LimitingInputStream::Skip(int count) {\n  if (count > limit_) {\n    if (limit_ < 0) return false;\n    input_->Skip(limit_);\n    limit_ = 0;\n    return false;\n  } else {\n    if (!input_->Skip(count)) return false;\n    limit_ -= count;\n    return true;\n  }\n}\n\nint64 LimitingInputStream::ByteCount() const {\n  if (limit_ < 0) {\n    return input_->ByteCount() + limit_ - prior_bytes_read_;\n  } else {\n    return input_->ByteCount() - prior_bytes_read_;\n  }\n}\n\n\n// ===================================================================\n\n}  // namespace io\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/zero_copy_stream_impl.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This file contains common implementations of the interfaces defined in\n// zero_copy_stream.h which are only included in the full (non-lite)\n// protobuf library.  These implementations include Unix file descriptors\n// and C++ iostreams.  See also:  zero_copy_stream_impl_lite.h\n\n#ifndef GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_H__\n#define GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_H__\n\n#include <string>\n#include <iosfwd>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl_lite.h>\n#include <google/protobuf/stubs/common.h>\n\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\n\n\n// ===================================================================\n\n// A ZeroCopyInputStream which reads from a file descriptor.\n//\n// FileInputStream is preferred over using an ifstream with IstreamInputStream.\n// The latter will introduce an extra layer of buffering, harming performance.\n// Also, it's conceivable that FileInputStream could someday be enhanced\n// to use zero-copy file descriptors on OSs which support them.\nclass LIBPROTOBUF_EXPORT FileInputStream : public ZeroCopyInputStream {\n public:\n  // Creates a stream that reads from the given Unix file descriptor.\n  // If a block_size is given, it specifies the number of bytes that\n  // should be read and returned with each call to Next().  Otherwise,\n  // a reasonable default is used.\n  explicit FileInputStream(int file_descriptor, int block_size = -1);\n  ~FileInputStream();\n\n  // Flushes any buffers and closes the underlying file.  Returns false if\n  // an error occurs during the process; use GetErrno() to examine the error.\n  // Even if an error occurs, the file descriptor is closed when this returns.\n  bool Close();\n\n  // By default, the file descriptor is not closed when the stream is\n  // destroyed.  Call SetCloseOnDelete(true) to change that.  WARNING:\n  // This leaves no way for the caller to detect if close() fails.  If\n  // detecting close() errors is important to you, you should arrange\n  // to close the descriptor yourself.\n  void SetCloseOnDelete(bool value) { copying_input_.SetCloseOnDelete(value); }\n\n  // If an I/O error has occurred on this file descriptor, this is the\n  // errno from that error.  Otherwise, this is zero.  Once an error\n  // occurs, the stream is broken and all subsequent operations will\n  // fail.\n  int GetErrno() { return copying_input_.GetErrno(); }\n\n  // implements ZeroCopyInputStream ----------------------------------\n  bool Next(const void** data, int* size);\n  void BackUp(int count);\n  bool Skip(int count);\n  int64 ByteCount() const;\n\n private:\n  class LIBPROTOBUF_EXPORT CopyingFileInputStream : public CopyingInputStream {\n   public:\n    CopyingFileInputStream(int file_descriptor);\n    ~CopyingFileInputStream();\n\n    bool Close();\n    void SetCloseOnDelete(bool value) { close_on_delete_ = value; }\n    int GetErrno() { return errno_; }\n\n    // implements CopyingInputStream ---------------------------------\n    int Read(void* buffer, int size);\n    int Skip(int count);\n\n   private:\n    // The file descriptor.\n    const int file_;\n    bool close_on_delete_;\n    bool is_closed_;\n\n    // The errno of the I/O error, if one has occurred.  Otherwise, zero.\n    int errno_;\n\n    // Did we try to seek once and fail?  If so, we assume this file descriptor\n    // doesn't support seeking and won't try again.\n    bool previous_seek_failed_;\n\n    GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingFileInputStream);\n  };\n\n  CopyingFileInputStream copying_input_;\n  CopyingInputStreamAdaptor impl_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileInputStream);\n};\n\n// ===================================================================\n\n// A ZeroCopyOutputStream which writes to a file descriptor.\n//\n// FileOutputStream is preferred over using an ofstream with\n// OstreamOutputStream.  The latter will introduce an extra layer of buffering,\n// harming performance.  Also, it's conceivable that FileOutputStream could\n// someday be enhanced to use zero-copy file descriptors on OSs which\n// support them.\nclass LIBPROTOBUF_EXPORT FileOutputStream : public ZeroCopyOutputStream {\n public:\n  // Creates a stream that writes to the given Unix file descriptor.\n  // If a block_size is given, it specifies the size of the buffers\n  // that should be returned by Next().  Otherwise, a reasonable default\n  // is used.\n  explicit FileOutputStream(int file_descriptor, int block_size = -1);\n  ~FileOutputStream();\n\n  // Flushes any buffers and closes the underlying file.  Returns false if\n  // an error occurs during the process; use GetErrno() to examine the error.\n  // Even if an error occurs, the file descriptor is closed when this returns.\n  bool Close();\n\n  // Flushes FileOutputStream's buffers but does not close the\n  // underlying file. No special measures are taken to ensure that\n  // underlying operating system file object is synchronized to disk.\n  bool Flush();\n\n  // By default, the file descriptor is not closed when the stream is\n  // destroyed.  Call SetCloseOnDelete(true) to change that.  WARNING:\n  // This leaves no way for the caller to detect if close() fails.  If\n  // detecting close() errors is important to you, you should arrange\n  // to close the descriptor yourself.\n  void SetCloseOnDelete(bool value) { copying_output_.SetCloseOnDelete(value); }\n\n  // If an I/O error has occurred on this file descriptor, this is the\n  // errno from that error.  Otherwise, this is zero.  Once an error\n  // occurs, the stream is broken and all subsequent operations will\n  // fail.\n  int GetErrno() { return copying_output_.GetErrno(); }\n\n  // implements ZeroCopyOutputStream ---------------------------------\n  bool Next(void** data, int* size);\n  void BackUp(int count);\n  int64 ByteCount() const;\n\n private:\n  class LIBPROTOBUF_EXPORT CopyingFileOutputStream : public CopyingOutputStream {\n   public:\n    CopyingFileOutputStream(int file_descriptor);\n    ~CopyingFileOutputStream();\n\n    bool Close();\n    void SetCloseOnDelete(bool value) { close_on_delete_ = value; }\n    int GetErrno() { return errno_; }\n\n    // implements CopyingOutputStream --------------------------------\n    bool Write(const void* buffer, int size);\n\n   private:\n    // The file descriptor.\n    const int file_;\n    bool close_on_delete_;\n    bool is_closed_;\n\n    // The errno of the I/O error, if one has occurred.  Otherwise, zero.\n    int errno_;\n\n    GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingFileOutputStream);\n  };\n\n  CopyingFileOutputStream copying_output_;\n  CopyingOutputStreamAdaptor impl_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FileOutputStream);\n};\n\n// ===================================================================\n\n// A ZeroCopyInputStream which reads from a C++ istream.\n//\n// Note that for reading files (or anything represented by a file descriptor),\n// FileInputStream is more efficient.\nclass LIBPROTOBUF_EXPORT IstreamInputStream : public ZeroCopyInputStream {\n public:\n  // Creates a stream that reads from the given C++ istream.\n  // If a block_size is given, it specifies the number of bytes that\n  // should be read and returned with each call to Next().  Otherwise,\n  // a reasonable default is used.\n  explicit IstreamInputStream(istream* stream, int block_size = -1);\n  ~IstreamInputStream();\n\n  // implements ZeroCopyInputStream ----------------------------------\n  bool Next(const void** data, int* size);\n  void BackUp(int count);\n  bool Skip(int count);\n  int64 ByteCount() const;\n\n private:\n  class LIBPROTOBUF_EXPORT CopyingIstreamInputStream : public CopyingInputStream {\n   public:\n    CopyingIstreamInputStream(istream* input);\n    ~CopyingIstreamInputStream();\n\n    // implements CopyingInputStream ---------------------------------\n    int Read(void* buffer, int size);\n    // (We use the default implementation of Skip().)\n\n   private:\n    // The stream.\n    istream* input_;\n\n    GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingIstreamInputStream);\n  };\n\n  CopyingIstreamInputStream copying_input_;\n  CopyingInputStreamAdaptor impl_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(IstreamInputStream);\n};\n\n// ===================================================================\n\n// A ZeroCopyOutputStream which writes to a C++ ostream.\n//\n// Note that for writing files (or anything represented by a file descriptor),\n// FileOutputStream is more efficient.\nclass LIBPROTOBUF_EXPORT OstreamOutputStream : public ZeroCopyOutputStream {\n public:\n  // Creates a stream that writes to the given C++ ostream.\n  // If a block_size is given, it specifies the size of the buffers\n  // that should be returned by Next().  Otherwise, a reasonable default\n  // is used.\n  explicit OstreamOutputStream(ostream* stream, int block_size = -1);\n  ~OstreamOutputStream();\n\n  // implements ZeroCopyOutputStream ---------------------------------\n  bool Next(void** data, int* size);\n  void BackUp(int count);\n  int64 ByteCount() const;\n\n private:\n  class LIBPROTOBUF_EXPORT CopyingOstreamOutputStream : public CopyingOutputStream {\n   public:\n    CopyingOstreamOutputStream(ostream* output);\n    ~CopyingOstreamOutputStream();\n\n    // implements CopyingOutputStream --------------------------------\n    bool Write(const void* buffer, int size);\n\n   private:\n    // The stream.\n    ostream* output_;\n\n    GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingOstreamOutputStream);\n  };\n\n  CopyingOstreamOutputStream copying_output_;\n  CopyingOutputStreamAdaptor impl_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(OstreamOutputStream);\n};\n\n// ===================================================================\n\n// A ZeroCopyInputStream which reads from several other streams in sequence.\n// ConcatenatingInputStream is unable to distinguish between end-of-stream\n// and read errors in the underlying streams, so it assumes any errors mean\n// end-of-stream.  So, if the underlying streams fail for any other reason,\n// ConcatenatingInputStream may do odd things.  It is suggested that you do\n// not use ConcatenatingInputStream on streams that might produce read errors\n// other than end-of-stream.\nclass LIBPROTOBUF_EXPORT ConcatenatingInputStream : public ZeroCopyInputStream {\n public:\n  // All streams passed in as well as the array itself must remain valid\n  // until the ConcatenatingInputStream is destroyed.\n  ConcatenatingInputStream(ZeroCopyInputStream* const streams[], int count);\n  ~ConcatenatingInputStream();\n\n  // implements ZeroCopyInputStream ----------------------------------\n  bool Next(const void** data, int* size);\n  void BackUp(int count);\n  bool Skip(int count);\n  int64 ByteCount() const;\n\n\n private:\n  // As streams are retired, streams_ is incremented and count_ is\n  // decremented.\n  ZeroCopyInputStream* const* streams_;\n  int stream_count_;\n  int64 bytes_retired_;  // Bytes read from previous streams.\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ConcatenatingInputStream);\n};\n\n// ===================================================================\n\n// A ZeroCopyInputStream which wraps some other stream and limits it to\n// a particular byte count.\nclass LIBPROTOBUF_EXPORT LimitingInputStream : public ZeroCopyInputStream {\n public:\n  LimitingInputStream(ZeroCopyInputStream* input, int64 limit);\n  ~LimitingInputStream();\n\n  // implements ZeroCopyInputStream ----------------------------------\n  bool Next(const void** data, int* size);\n  void BackUp(int count);\n  bool Skip(int count);\n  int64 ByteCount() const;\n\n\n private:\n  ZeroCopyInputStream* input_;\n  int64 limit_;  // Decreases as we go, becomes negative if we overshoot.\n  int64 prior_bytes_read_;  // Bytes read on underlying stream at construction\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(LimitingInputStream);\n};\n\n// ===================================================================\n\n}  // namespace io\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/io/zero_copy_stream_impl_lite.h>\n\n#include <algorithm>\n#include <limits>\n\n#include <google/protobuf/stubs/casts.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/stl_util.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\n\nnamespace {\n\n// Default block size for Copying{In,Out}putStreamAdaptor.\nstatic const int kDefaultBlockSize = 8192;\n\n}  // namespace\n\n// ===================================================================\n\nArrayInputStream::ArrayInputStream(const void* data, int size,\n                                   int block_size)\n  : data_(reinterpret_cast<const uint8*>(data)),\n    size_(size),\n    block_size_(block_size > 0 ? block_size : size),\n    position_(0),\n    last_returned_size_(0) {\n}\n\nArrayInputStream::~ArrayInputStream() {\n}\n\nbool ArrayInputStream::Next(const void** data, int* size) {\n  if (position_ < size_) {\n    last_returned_size_ = std::min(block_size_, size_ - position_);\n    *data = data_ + position_;\n    *size = last_returned_size_;\n    position_ += last_returned_size_;\n    return true;\n  } else {\n    // We're at the end of the array.\n    last_returned_size_ = 0;   // Don't let caller back up.\n    return false;\n  }\n}\n\nvoid ArrayInputStream::BackUp(int count) {\n  GOOGLE_CHECK_GT(last_returned_size_, 0)\n      << \"BackUp() can only be called after a successful Next().\";\n  GOOGLE_CHECK_LE(count, last_returned_size_);\n  GOOGLE_CHECK_GE(count, 0);\n  position_ -= count;\n  last_returned_size_ = 0;  // Don't let caller back up further.\n}\n\nbool ArrayInputStream::Skip(int count) {\n  GOOGLE_CHECK_GE(count, 0);\n  last_returned_size_ = 0;   // Don't let caller back up.\n  if (count > size_ - position_) {\n    position_ = size_;\n    return false;\n  } else {\n    position_ += count;\n    return true;\n  }\n}\n\nint64 ArrayInputStream::ByteCount() const {\n  return position_;\n}\n\n\n// ===================================================================\n\nArrayOutputStream::ArrayOutputStream(void* data, int size, int block_size)\n  : data_(reinterpret_cast<uint8*>(data)),\n    size_(size),\n    block_size_(block_size > 0 ? block_size : size),\n    position_(0),\n    last_returned_size_(0) {\n}\n\nArrayOutputStream::~ArrayOutputStream() {\n}\n\nbool ArrayOutputStream::Next(void** data, int* size) {\n  if (position_ < size_) {\n    last_returned_size_ = std::min(block_size_, size_ - position_);\n    *data = data_ + position_;\n    *size = last_returned_size_;\n    position_ += last_returned_size_;\n    return true;\n  } else {\n    // We're at the end of the array.\n    last_returned_size_ = 0;   // Don't let caller back up.\n    return false;\n  }\n}\n\nvoid ArrayOutputStream::BackUp(int count) {\n  GOOGLE_CHECK_GT(last_returned_size_, 0)\n      << \"BackUp() can only be called after a successful Next().\";\n  GOOGLE_CHECK_LE(count, last_returned_size_);\n  GOOGLE_CHECK_GE(count, 0);\n  position_ -= count;\n  last_returned_size_ = 0;  // Don't let caller back up further.\n}\n\nint64 ArrayOutputStream::ByteCount() const {\n  return position_;\n}\n\n// ===================================================================\n\nStringOutputStream::StringOutputStream(string* target)\n  : target_(target) {\n}\n\nStringOutputStream::~StringOutputStream() {\n}\n\nbool StringOutputStream::Next(void** data, int* size) {\n  GOOGLE_CHECK(target_ != NULL);\n  int old_size = target_->size();\n\n  // Grow the string.\n  if (old_size < target_->capacity()) {\n    // Resize the string to match its capacity, since we can get away\n    // without a memory allocation this way.\n    STLStringResizeUninitialized(target_, target_->capacity());\n  } else {\n    // Size has reached capacity, try to double the size.\n    if (old_size > std::numeric_limits<int>::max() / 2) {\n      // Can not double the size otherwise it is going to cause integer\n      // overflow in the expression below: old_size * 2 \";\n      GOOGLE_LOG(ERROR) << \"Cannot allocate buffer larger than kint32max for \"\n                 << \"StringOutputStream.\";\n      return false;\n    }\n    // Double the size, also make sure that the new size is at least\n    // kMinimumSize.\n    STLStringResizeUninitialized(\n        target_,\n        std::max(old_size * 2,\n                 kMinimumSize + 0));  // \"+ 0\" works around GCC4 weirdness.\n  }\n\n  *data = mutable_string_data(target_) + old_size;\n  *size = target_->size() - old_size;\n  return true;\n}\n\nvoid StringOutputStream::BackUp(int count) {\n  GOOGLE_CHECK_GE(count, 0);\n  GOOGLE_CHECK(target_ != NULL);\n  GOOGLE_CHECK_LE(count, target_->size());\n  target_->resize(target_->size() - count);\n}\n\nint64 StringOutputStream::ByteCount() const {\n  GOOGLE_CHECK(target_ != NULL);\n  return target_->size();\n}\n\nvoid StringOutputStream::SetString(string* target) {\n  target_ = target;\n}\n\n// ===================================================================\n\nLazyStringOutputStream::LazyStringOutputStream(\n    ResultCallback<string*>* callback)\n    : StringOutputStream(NULL),\n      callback_(GOOGLE_CHECK_NOTNULL(callback)),\n      string_is_set_(false) {\n}\n\nLazyStringOutputStream::~LazyStringOutputStream() {\n}\n\nbool LazyStringOutputStream::Next(void** data, int* size) {\n  if (!string_is_set_) {\n    SetString(callback_->Run());\n    string_is_set_ = true;\n  }\n  return StringOutputStream::Next(data, size);\n}\n\nint64 LazyStringOutputStream::ByteCount() const {\n  return string_is_set_ ? StringOutputStream::ByteCount() : 0;\n}\n\n// ===================================================================\n\nCopyingInputStream::~CopyingInputStream() {}\n\nint CopyingInputStream::Skip(int count) {\n  char junk[4096];\n  int skipped = 0;\n  while (skipped < count) {\n    int bytes =\n        Read(junk, std::min(count - skipped, implicit_cast<int>(sizeof(junk))));\n    if (bytes <= 0) {\n      // EOF or read error.\n      return skipped;\n    }\n    skipped += bytes;\n  }\n  return skipped;\n}\n\nCopyingInputStreamAdaptor::CopyingInputStreamAdaptor(\n    CopyingInputStream* copying_stream, int block_size)\n  : copying_stream_(copying_stream),\n    owns_copying_stream_(false),\n    failed_(false),\n    position_(0),\n    buffer_size_(block_size > 0 ? block_size : kDefaultBlockSize),\n    buffer_used_(0),\n    backup_bytes_(0) {\n}\n\nCopyingInputStreamAdaptor::~CopyingInputStreamAdaptor() {\n  if (owns_copying_stream_) {\n    delete copying_stream_;\n  }\n}\n\nbool CopyingInputStreamAdaptor::Next(const void** data, int* size) {\n  if (failed_) {\n    // Already failed on a previous read.\n    return false;\n  }\n\n  AllocateBufferIfNeeded();\n\n  if (backup_bytes_ > 0) {\n    // We have data left over from a previous BackUp(), so just return that.\n    *data = buffer_.get() + buffer_used_ - backup_bytes_;\n    *size = backup_bytes_;\n    backup_bytes_ = 0;\n    return true;\n  }\n\n  // Read new data into the buffer.\n  buffer_used_ = copying_stream_->Read(buffer_.get(), buffer_size_);\n  if (buffer_used_ <= 0) {\n    // EOF or read error.  We don't need the buffer anymore.\n    if (buffer_used_ < 0) {\n      // Read error (not EOF).\n      failed_ = true;\n    }\n    FreeBuffer();\n    return false;\n  }\n  position_ += buffer_used_;\n\n  *size = buffer_used_;\n  *data = buffer_.get();\n  return true;\n}\n\nvoid CopyingInputStreamAdaptor::BackUp(int count) {\n  GOOGLE_CHECK(backup_bytes_ == 0 && buffer_.get() != NULL)\n    << \" BackUp() can only be called after Next().\";\n  GOOGLE_CHECK_LE(count, buffer_used_)\n    << \" Can't back up over more bytes than were returned by the last call\"\n       \" to Next().\";\n  GOOGLE_CHECK_GE(count, 0)\n    << \" Parameter to BackUp() can't be negative.\";\n\n  backup_bytes_ = count;\n}\n\nbool CopyingInputStreamAdaptor::Skip(int count) {\n  GOOGLE_CHECK_GE(count, 0);\n\n  if (failed_) {\n    // Already failed on a previous read.\n    return false;\n  }\n\n  // First skip any bytes left over from a previous BackUp().\n  if (backup_bytes_ >= count) {\n    // We have more data left over than we're trying to skip.  Just chop it.\n    backup_bytes_ -= count;\n    return true;\n  }\n\n  count -= backup_bytes_;\n  backup_bytes_ = 0;\n\n  int skipped = copying_stream_->Skip(count);\n  position_ += skipped;\n  return skipped == count;\n}\n\nint64 CopyingInputStreamAdaptor::ByteCount() const {\n  return position_ - backup_bytes_;\n}\n\nvoid CopyingInputStreamAdaptor::AllocateBufferIfNeeded() {\n  if (buffer_.get() == NULL) {\n    buffer_.reset(new uint8[buffer_size_]);\n  }\n}\n\nvoid CopyingInputStreamAdaptor::FreeBuffer() {\n  GOOGLE_CHECK_EQ(backup_bytes_, 0);\n  buffer_used_ = 0;\n  buffer_.reset();\n}\n\n// ===================================================================\n\nCopyingOutputStream::~CopyingOutputStream() {}\n\nCopyingOutputStreamAdaptor::CopyingOutputStreamAdaptor(\n    CopyingOutputStream* copying_stream, int block_size)\n  : copying_stream_(copying_stream),\n    owns_copying_stream_(false),\n    failed_(false),\n    position_(0),\n    buffer_size_(block_size > 0 ? block_size : kDefaultBlockSize),\n    buffer_used_(0) {\n}\n\nCopyingOutputStreamAdaptor::~CopyingOutputStreamAdaptor() {\n  WriteBuffer();\n  if (owns_copying_stream_) {\n    delete copying_stream_;\n  }\n}\n\nbool CopyingOutputStreamAdaptor::Flush() {\n  return WriteBuffer();\n}\n\nbool CopyingOutputStreamAdaptor::Next(void** data, int* size) {\n  if (buffer_used_ == buffer_size_) {\n    if (!WriteBuffer()) return false;\n  }\n\n  AllocateBufferIfNeeded();\n\n  *data = buffer_.get() + buffer_used_;\n  *size = buffer_size_ - buffer_used_;\n  buffer_used_ = buffer_size_;\n  return true;\n}\n\nvoid CopyingOutputStreamAdaptor::BackUp(int count) {\n  GOOGLE_CHECK_GE(count, 0);\n  GOOGLE_CHECK_EQ(buffer_used_, buffer_size_)\n    << \" BackUp() can only be called after Next().\";\n  GOOGLE_CHECK_LE(count, buffer_used_)\n    << \" Can't back up over more bytes than were returned by the last call\"\n       \" to Next().\";\n\n  buffer_used_ -= count;\n}\n\nint64 CopyingOutputStreamAdaptor::ByteCount() const {\n  return position_ + buffer_used_;\n}\n\nbool CopyingOutputStreamAdaptor::WriteBuffer() {\n  if (failed_) {\n    // Already failed on a previous write.\n    return false;\n  }\n\n  if (buffer_used_ == 0) return true;\n\n  if (copying_stream_->Write(buffer_.get(), buffer_used_)) {\n    position_ += buffer_used_;\n    buffer_used_ = 0;\n    return true;\n  } else {\n    failed_ = true;\n    FreeBuffer();\n    return false;\n  }\n}\n\nvoid CopyingOutputStreamAdaptor::AllocateBufferIfNeeded() {\n  if (buffer_ == NULL) {\n    buffer_.reset(new uint8[buffer_size_]);\n  }\n}\n\nvoid CopyingOutputStreamAdaptor::FreeBuffer() {\n  buffer_used_ = 0;\n  buffer_.reset();\n}\n\n// ===================================================================\n\n}  // namespace io\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/zero_copy_stream_impl_lite.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This file contains common implementations of the interfaces defined in\n// zero_copy_stream.h which are included in the \"lite\" protobuf library.\n// These implementations cover I/O on raw arrays and strings, as well as\n// adaptors which make it easy to implement streams based on traditional\n// streams.  Of course, many users will probably want to write their own\n// implementations of these interfaces specific to the particular I/O\n// abstractions they prefer to use, but these should cover the most common\n// cases.\n\n#ifndef GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__\n#define GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <string>\n#include <iosfwd>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/stubs/callback.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/stl_util.h>\n\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\n\n// ===================================================================\n\n// A ZeroCopyInputStream backed by an in-memory array of bytes.\nclass LIBPROTOBUF_EXPORT ArrayInputStream : public ZeroCopyInputStream {\n public:\n  // Create an InputStream that returns the bytes pointed to by \"data\".\n  // \"data\" remains the property of the caller but must remain valid until\n  // the stream is destroyed.  If a block_size is given, calls to Next()\n  // will return data blocks no larger than the given size.  Otherwise, the\n  // first call to Next() returns the entire array.  block_size is mainly\n  // useful for testing; in production you would probably never want to set\n  // it.\n  ArrayInputStream(const void* data, int size, int block_size = -1);\n  ~ArrayInputStream();\n\n  // implements ZeroCopyInputStream ----------------------------------\n  bool Next(const void** data, int* size);\n  void BackUp(int count);\n  bool Skip(int count);\n  int64 ByteCount() const;\n\n\n private:\n  const uint8* const data_;  // The byte array.\n  const int size_;           // Total size of the array.\n  const int block_size_;     // How many bytes to return at a time.\n\n  int position_;\n  int last_returned_size_;   // How many bytes we returned last time Next()\n                             // was called (used for error checking only).\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ArrayInputStream);\n};\n\n// ===================================================================\n\n// A ZeroCopyOutputStream backed by an in-memory array of bytes.\nclass LIBPROTOBUF_EXPORT ArrayOutputStream : public ZeroCopyOutputStream {\n public:\n  // Create an OutputStream that writes to the bytes pointed to by \"data\".\n  // \"data\" remains the property of the caller but must remain valid until\n  // the stream is destroyed.  If a block_size is given, calls to Next()\n  // will return data blocks no larger than the given size.  Otherwise, the\n  // first call to Next() returns the entire array.  block_size is mainly\n  // useful for testing; in production you would probably never want to set\n  // it.\n  ArrayOutputStream(void* data, int size, int block_size = -1);\n  ~ArrayOutputStream();\n\n  // implements ZeroCopyOutputStream ---------------------------------\n  bool Next(void** data, int* size);\n  void BackUp(int count);\n  int64 ByteCount() const;\n\n private:\n  uint8* const data_;        // The byte array.\n  const int size_;           // Total size of the array.\n  const int block_size_;     // How many bytes to return at a time.\n\n  int position_;\n  int last_returned_size_;   // How many bytes we returned last time Next()\n                             // was called (used for error checking only).\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ArrayOutputStream);\n};\n\n// ===================================================================\n\n// A ZeroCopyOutputStream which appends bytes to a string.\nclass LIBPROTOBUF_EXPORT StringOutputStream : public ZeroCopyOutputStream {\n public:\n  // Create a StringOutputStream which appends bytes to the given string.\n  // The string remains property of the caller, but it is mutated in arbitrary\n  // ways and MUST NOT be accessed in any way until you're done with the\n  // stream. Either be sure there's no further usage, or (safest) destroy the\n  // stream before using the contents.\n  //\n  // Hint:  If you call target->reserve(n) before creating the stream,\n  //   the first call to Next() will return at least n bytes of buffer\n  //   space.\n  explicit StringOutputStream(string* target);\n  ~StringOutputStream();\n\n  // implements ZeroCopyOutputStream ---------------------------------\n  bool Next(void** data, int* size);\n  void BackUp(int count);\n  int64 ByteCount() const;\n\n protected:\n  void SetString(string* target);\n\n private:\n  static const int kMinimumSize = 16;\n\n  string* target_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringOutputStream);\n};\n\n// LazyStringOutputStream is a StringOutputStream with lazy acquisition of\n// the output string from a callback. The string is owned externally, and not\n// deleted in the stream destructor.\nclass LIBPROTOBUF_EXPORT LazyStringOutputStream : public StringOutputStream {\n public:\n  // Callback should be permanent (non-self-deleting). Ownership is transferred\n  // to the LazyStringOutputStream.\n  explicit LazyStringOutputStream(ResultCallback<string*>* callback);\n  ~LazyStringOutputStream();\n\n  // implements ZeroCopyOutputStream, overriding StringOutputStream -----------\n  bool Next(void** data, int* size);\n  int64 ByteCount() const;\n\n private:\n  const google::protobuf::scoped_ptr<ResultCallback<string*> > callback_;\n  bool string_is_set_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(LazyStringOutputStream);\n};\n\n// Note:  There is no StringInputStream.  Instead, just create an\n// ArrayInputStream as follows:\n//   ArrayInputStream input(str.data(), str.size());\n\n// ===================================================================\n\n// A generic traditional input stream interface.\n//\n// Lots of traditional input streams (e.g. file descriptors, C stdio\n// streams, and C++ iostreams) expose an interface where every read\n// involves copying bytes into a buffer.  If you want to take such an\n// interface and make a ZeroCopyInputStream based on it, simply implement\n// CopyingInputStream and then use CopyingInputStreamAdaptor.\n//\n// CopyingInputStream implementations should avoid buffering if possible.\n// CopyingInputStreamAdaptor does its own buffering and will read data\n// in large blocks.\nclass LIBPROTOBUF_EXPORT CopyingInputStream {\n public:\n  virtual ~CopyingInputStream();\n\n  // Reads up to \"size\" bytes into the given buffer.  Returns the number of\n  // bytes read.  Read() waits until at least one byte is available, or\n  // returns zero if no bytes will ever become available (EOF), or -1 if a\n  // permanent read error occurred.\n  virtual int Read(void* buffer, int size) = 0;\n\n  // Skips the next \"count\" bytes of input.  Returns the number of bytes\n  // actually skipped.  This will always be exactly equal to \"count\" unless\n  // EOF was reached or a permanent read error occurred.\n  //\n  // The default implementation just repeatedly calls Read() into a scratch\n  // buffer.\n  virtual int Skip(int count);\n};\n\n// A ZeroCopyInputStream which reads from a CopyingInputStream.  This is\n// useful for implementing ZeroCopyInputStreams that read from traditional\n// streams.  Note that this class is not really zero-copy.\n//\n// If you want to read from file descriptors or C++ istreams, this is\n// already implemented for you:  use FileInputStream or IstreamInputStream\n// respectively.\nclass LIBPROTOBUF_EXPORT CopyingInputStreamAdaptor : public ZeroCopyInputStream {\n public:\n  // Creates a stream that reads from the given CopyingInputStream.\n  // If a block_size is given, it specifies the number of bytes that\n  // should be read and returned with each call to Next().  Otherwise,\n  // a reasonable default is used.  The caller retains ownership of\n  // copying_stream unless SetOwnsCopyingStream(true) is called.\n  explicit CopyingInputStreamAdaptor(CopyingInputStream* copying_stream,\n                                     int block_size = -1);\n  ~CopyingInputStreamAdaptor();\n\n  // Call SetOwnsCopyingStream(true) to tell the CopyingInputStreamAdaptor to\n  // delete the underlying CopyingInputStream when it is destroyed.\n  void SetOwnsCopyingStream(bool value) { owns_copying_stream_ = value; }\n\n  // implements ZeroCopyInputStream ----------------------------------\n  bool Next(const void** data, int* size);\n  void BackUp(int count);\n  bool Skip(int count);\n  int64 ByteCount() const;\n\n private:\n  // Insures that buffer_ is not NULL.\n  void AllocateBufferIfNeeded();\n  // Frees the buffer and resets buffer_used_.\n  void FreeBuffer();\n\n  // The underlying copying stream.\n  CopyingInputStream* copying_stream_;\n  bool owns_copying_stream_;\n\n  // True if we have seen a permenant error from the underlying stream.\n  bool failed_;\n\n  // The current position of copying_stream_, relative to the point where\n  // we started reading.\n  int64 position_;\n\n  // Data is read into this buffer.  It may be NULL if no buffer is currently\n  // in use.  Otherwise, it points to an array of size buffer_size_.\n  google::protobuf::scoped_array<uint8> buffer_;\n  const int buffer_size_;\n\n  // Number of valid bytes currently in the buffer (i.e. the size last\n  // returned by Next()).  0 <= buffer_used_ <= buffer_size_.\n  int buffer_used_;\n\n  // Number of bytes in the buffer which were backed up over by a call to\n  // BackUp().  These need to be returned again.\n  // 0 <= backup_bytes_ <= buffer_used_\n  int backup_bytes_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingInputStreamAdaptor);\n};\n\n// ===================================================================\n\n// A generic traditional output stream interface.\n//\n// Lots of traditional output streams (e.g. file descriptors, C stdio\n// streams, and C++ iostreams) expose an interface where every write\n// involves copying bytes from a buffer.  If you want to take such an\n// interface and make a ZeroCopyOutputStream based on it, simply implement\n// CopyingOutputStream and then use CopyingOutputStreamAdaptor.\n//\n// CopyingOutputStream implementations should avoid buffering if possible.\n// CopyingOutputStreamAdaptor does its own buffering and will write data\n// in large blocks.\nclass LIBPROTOBUF_EXPORT CopyingOutputStream {\n public:\n  virtual ~CopyingOutputStream();\n\n  // Writes \"size\" bytes from the given buffer to the output.  Returns true\n  // if successful, false on a write error.\n  virtual bool Write(const void* buffer, int size) = 0;\n};\n\n// A ZeroCopyOutputStream which writes to a CopyingOutputStream.  This is\n// useful for implementing ZeroCopyOutputStreams that write to traditional\n// streams.  Note that this class is not really zero-copy.\n//\n// If you want to write to file descriptors or C++ ostreams, this is\n// already implemented for you:  use FileOutputStream or OstreamOutputStream\n// respectively.\nclass LIBPROTOBUF_EXPORT CopyingOutputStreamAdaptor : public ZeroCopyOutputStream {\n public:\n  // Creates a stream that writes to the given Unix file descriptor.\n  // If a block_size is given, it specifies the size of the buffers\n  // that should be returned by Next().  Otherwise, a reasonable default\n  // is used.\n  explicit CopyingOutputStreamAdaptor(CopyingOutputStream* copying_stream,\n                                      int block_size = -1);\n  ~CopyingOutputStreamAdaptor();\n\n  // Writes all pending data to the underlying stream.  Returns false if a\n  // write error occurred on the underlying stream.  (The underlying\n  // stream itself is not necessarily flushed.)\n  bool Flush();\n\n  // Call SetOwnsCopyingStream(true) to tell the CopyingOutputStreamAdaptor to\n  // delete the underlying CopyingOutputStream when it is destroyed.\n  void SetOwnsCopyingStream(bool value) { owns_copying_stream_ = value; }\n\n  // implements ZeroCopyOutputStream ---------------------------------\n  bool Next(void** data, int* size);\n  void BackUp(int count);\n  int64 ByteCount() const;\n\n private:\n  // Write the current buffer, if it is present.\n  bool WriteBuffer();\n  // Insures that buffer_ is not NULL.\n  void AllocateBufferIfNeeded();\n  // Frees the buffer.\n  void FreeBuffer();\n\n  // The underlying copying stream.\n  CopyingOutputStream* copying_stream_;\n  bool owns_copying_stream_;\n\n  // True if we have seen a permenant error from the underlying stream.\n  bool failed_;\n\n  // The current position of copying_stream_, relative to the point where\n  // we started writing.\n  int64 position_;\n\n  // Data is written from this buffer.  It may be NULL if no buffer is\n  // currently in use.  Otherwise, it points to an array of size buffer_size_.\n  google::protobuf::scoped_array<uint8> buffer_;\n  const int buffer_size_;\n\n  // Number of valid bytes currently in the buffer (i.e. the size last\n  // returned by Next()).  When BackUp() is called, we just reduce this.\n  // 0 <= buffer_used_ <= buffer_size_.\n  int buffer_used_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CopyingOutputStreamAdaptor);\n};\n\n// ===================================================================\n\n// mutable_string_data() and as_string_data() are workarounds to improve\n// the performance of writing new data to an existing string.  Unfortunately\n// the methods provided by the string class are suboptimal, and using memcpy()\n// is mildly annoying because it requires its pointer args to be non-NULL even\n// if we ask it to copy 0 bytes.  Furthermore, string_as_array() has the\n// property that it always returns NULL if its arg is the empty string, exactly\n// what we want to avoid if we're using it in conjunction with memcpy()!\n// With C++11, the desired memcpy() boils down to memcpy(..., &(*s)[0], size),\n// where s is a string*.  Without C++11, &(*s)[0] is not guaranteed to be safe,\n// so we use string_as_array(), and live with the extra logic that tests whether\n// *s is empty.\n\n// Return a pointer to mutable characters underlying the given string.  The\n// return value is valid until the next time the string is resized.  We\n// trust the caller to treat the return value as an array of length s->size().\ninline char* mutable_string_data(string* s) {\n#ifdef LANG_CXX11\n  // This should be simpler & faster than string_as_array() because the latter\n  // is guaranteed to return NULL when *s is empty, so it has to check for that.\n  return &(*s)[0];\n#else\n  return string_as_array(s);\n#endif\n}\n\n// as_string_data(s) is equivalent to\n//  ({ char* p = mutable_string_data(s); make_pair(p, p != NULL); })\n// Sometimes it's faster: in some scenarios p cannot be NULL, and then the\n// code can avoid that check.\ninline std::pair<char*, bool> as_string_data(string* s) {\n  char *p = mutable_string_data(s);\n#ifdef LANG_CXX11\n  return std::make_pair(p, true);\n#else\n  return make_pair(p, p != NULL);\n#endif\n}\n\n}  // namespace io\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_IO_ZERO_COPY_STREAM_IMPL_LITE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/io/zero_copy_stream_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Testing strategy:  For each type of I/O (array, string, file, etc.) we\n// create an output stream and write some data to it, then create a\n// corresponding input stream to read the same data back and expect it to\n// match.  When the data is written, it is written in several small chunks\n// of varying sizes, with a BackUp() after each chunk.  It is read back\n// similarly, but with chunks separated at different points.  The whole\n// process is run with a variety of block sizes for both the input and\n// the output.\n//\n// TODO(kenton):  Rewrite this test to bring it up to the standards of all\n//   the other proto2 tests.  May want to wait for gTest to implement\n//   \"parametized tests\" so that one set of tests can be used on all the\n//   implementations.\n\n\n#ifdef _MSC_VER\n#include <io.h>\n#else\n#include <unistd.h>\n#endif\n#include <stdlib.h>\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n#include <errno.h>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <sstream>\n\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n\n#if HAVE_ZLIB\n#include <google/protobuf/io/gzip_stream.h>\n#endif\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/testing/googletest.h>\n#include <google/protobuf/testing/file.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\nnamespace {\n\n#ifdef _WIN32\n#define pipe(fds) _pipe(fds, 4096, O_BINARY)\n#endif\n\n#ifndef O_BINARY\n#ifdef _O_BINARY\n#define O_BINARY _O_BINARY\n#else\n#define O_BINARY 0     // If this isn't defined, the platform doesn't need it.\n#endif\n#endif\n\nclass IoTest : public testing::Test {\n protected:\n  // Test helpers.\n\n  // Helper to write an array of data to an output stream.\n  bool WriteToOutput(ZeroCopyOutputStream* output, const void* data, int size);\n  // Helper to read a fixed-length array of data from an input stream.\n  int ReadFromInput(ZeroCopyInputStream* input, void* data, int size);\n  // Write a string to the output stream.\n  void WriteString(ZeroCopyOutputStream* output, const string& str);\n  // Read a number of bytes equal to the size of the given string and checks\n  // that it matches the string.\n  void ReadString(ZeroCopyInputStream* input, const string& str);\n  // Writes some text to the output stream in a particular order.  Returns\n  // the number of bytes written, incase the caller needs that to set up an\n  // input stream.\n  int WriteStuff(ZeroCopyOutputStream* output);\n  // Reads text from an input stream and expects it to match what\n  // WriteStuff() writes.\n  void ReadStuff(ZeroCopyInputStream* input);\n\n  // Similar to WriteStuff, but performs more sophisticated testing.\n  int WriteStuffLarge(ZeroCopyOutputStream* output);\n  // Reads and tests a stream that should have been written to\n  // via WriteStuffLarge().\n  void ReadStuffLarge(ZeroCopyInputStream* input);\n\n#if HAVE_ZLIB\n  string Compress(const string& data, const GzipOutputStream::Options& options);\n  string Uncompress(const string& data);\n#endif\n\n  static const int kBlockSizes[];\n  static const int kBlockSizeCount;\n};\n\nconst int IoTest::kBlockSizes[] = {-1, 1, 2, 5, 7, 10, 23, 64};\nconst int IoTest::kBlockSizeCount = GOOGLE_ARRAYSIZE(IoTest::kBlockSizes);\n\nbool IoTest::WriteToOutput(ZeroCopyOutputStream* output,\n                           const void* data, int size) {\n  const uint8* in = reinterpret_cast<const uint8*>(data);\n  int in_size = size;\n\n  void* out;\n  int out_size;\n\n  while (true) {\n    if (!output->Next(&out, &out_size)) {\n      return false;\n    }\n    EXPECT_GT(out_size, 0);\n\n    if (in_size <= out_size) {\n      memcpy(out, in, in_size);\n      output->BackUp(out_size - in_size);\n      return true;\n    }\n\n    memcpy(out, in, out_size);\n    in += out_size;\n    in_size -= out_size;\n  }\n}\n\n#define MAX_REPEATED_ZEROS 100\n\nint IoTest::ReadFromInput(ZeroCopyInputStream* input, void* data, int size) {\n  uint8* out = reinterpret_cast<uint8*>(data);\n  int out_size = size;\n\n  const void* in;\n  int in_size = 0;\n\n  int repeated_zeros = 0;\n\n  while (true) {\n    if (!input->Next(&in, &in_size)) {\n      return size - out_size;\n    }\n    EXPECT_GT(in_size, -1);\n    if (in_size == 0) {\n      repeated_zeros++;\n    } else {\n      repeated_zeros = 0;\n    }\n    EXPECT_LT(repeated_zeros, MAX_REPEATED_ZEROS);\n\n    if (out_size <= in_size) {\n      memcpy(out, in, out_size);\n      if (in_size > out_size) {\n        input->BackUp(in_size - out_size);\n      }\n      return size;  // Copied all of it.\n    }\n\n    memcpy(out, in, in_size);\n    out += in_size;\n    out_size -= in_size;\n  }\n}\n\nvoid IoTest::WriteString(ZeroCopyOutputStream* output, const string& str) {\n  EXPECT_TRUE(WriteToOutput(output, str.c_str(), str.size()));\n}\n\nvoid IoTest::ReadString(ZeroCopyInputStream* input, const string& str) {\n  google::protobuf::scoped_array<char> buffer(new char[str.size() + 1]);\n  buffer[str.size()] = '\\0';\n  EXPECT_EQ(ReadFromInput(input, buffer.get(), str.size()), str.size());\n  EXPECT_STREQ(str.c_str(), buffer.get());\n}\n\nint IoTest::WriteStuff(ZeroCopyOutputStream* output) {\n  WriteString(output, \"Hello world!\\n\");\n  WriteString(output, \"Some te\");\n  WriteString(output, \"xt.  Blah blah.\");\n  WriteString(output, \"abcdefg\");\n  WriteString(output, \"01234567890123456789\");\n  WriteString(output, \"foobar\");\n\n  EXPECT_EQ(output->ByteCount(), 68);\n\n  int result = output->ByteCount();\n  return result;\n}\n\n// Reads text from an input stream and expects it to match what WriteStuff()\n// writes.\nvoid IoTest::ReadStuff(ZeroCopyInputStream* input) {\n  ReadString(input, \"Hello world!\\n\");\n  ReadString(input, \"Some text.  \");\n  ReadString(input, \"Blah \");\n  ReadString(input, \"blah.\");\n  ReadString(input, \"abcdefg\");\n  EXPECT_TRUE(input->Skip(20));\n  ReadString(input, \"foo\");\n  ReadString(input, \"bar\");\n\n  EXPECT_EQ(input->ByteCount(), 68);\n\n  uint8 byte;\n  EXPECT_EQ(ReadFromInput(input, &byte, 1), 0);\n}\n\nint IoTest::WriteStuffLarge(ZeroCopyOutputStream* output) {\n  WriteString(output, \"Hello world!\\n\");\n  WriteString(output, \"Some te\");\n  WriteString(output, \"xt.  Blah blah.\");\n  WriteString(output, string(100000, 'x'));  // A very long string\n  WriteString(output, string(100000, 'y'));  // A very long string\n  WriteString(output, \"01234567890123456789\");\n\n  EXPECT_EQ(output->ByteCount(), 200055);\n\n  int result = output->ByteCount();\n  return result;\n}\n\n// Reads text from an input stream and expects it to match what WriteStuff()\n// writes.\nvoid IoTest::ReadStuffLarge(ZeroCopyInputStream* input) {\n  ReadString(input, \"Hello world!\\nSome text.  \");\n  EXPECT_TRUE(input->Skip(5));\n  ReadString(input, \"blah.\");\n  EXPECT_TRUE(input->Skip(100000 - 10));\n  ReadString(input, string(10, 'x') + string(100000 - 20000, 'y'));\n  EXPECT_TRUE(input->Skip(20000 - 10));\n  ReadString(input, \"yyyyyyyyyy01234567890123456789\");\n\n  EXPECT_EQ(input->ByteCount(), 200055);\n\n  uint8 byte;\n  EXPECT_EQ(ReadFromInput(input, &byte, 1), 0);\n}\n\n// ===================================================================\n\nTEST_F(IoTest, ArrayIo) {\n  const int kBufferSize = 256;\n  uint8 buffer[kBufferSize];\n\n  for (int i = 0; i < kBlockSizeCount; i++) {\n    for (int j = 0; j < kBlockSizeCount; j++) {\n      int size;\n      {\n        ArrayOutputStream output(buffer, kBufferSize, kBlockSizes[i]);\n        size = WriteStuff(&output);\n      }\n      {\n        ArrayInputStream input(buffer, size, kBlockSizes[j]);\n        ReadStuff(&input);\n      }\n    }\n  }\n}\n\nTEST_F(IoTest, TwoSessionWrite) {\n  // Test that two concatenated write sessions read correctly\n\n  static const char* strA = \"0123456789\";\n  static const char* strB = \"WhirledPeas\";\n  const int kBufferSize = 2*1024;\n  uint8* buffer = new uint8[kBufferSize];\n  char* temp_buffer = new char[40];\n\n  for (int i = 0; i < kBlockSizeCount; i++) {\n    for (int j = 0; j < kBlockSizeCount; j++) {\n      ArrayOutputStream* output =\n          new ArrayOutputStream(buffer, kBufferSize, kBlockSizes[i]);\n      CodedOutputStream* coded_output = new CodedOutputStream(output);\n      coded_output->WriteVarint32(strlen(strA));\n      coded_output->WriteRaw(strA, strlen(strA));\n      delete coded_output;  // flush\n      int64 pos = output->ByteCount();\n      delete output;\n      output = new ArrayOutputStream(\n          buffer + pos, kBufferSize - pos, kBlockSizes[i]);\n      coded_output = new CodedOutputStream(output);\n      coded_output->WriteVarint32(strlen(strB));\n      coded_output->WriteRaw(strB, strlen(strB));\n      delete coded_output;  // flush\n      int64 size = pos + output->ByteCount();\n      delete output;\n\n      ArrayInputStream* input =\n          new ArrayInputStream(buffer, size, kBlockSizes[j]);\n      CodedInputStream* coded_input = new CodedInputStream(input);\n      uint32 insize;\n      EXPECT_TRUE(coded_input->ReadVarint32(&insize));\n      EXPECT_EQ(strlen(strA), insize);\n      EXPECT_TRUE(coded_input->ReadRaw(temp_buffer, insize));\n      EXPECT_EQ(0, memcmp(temp_buffer, strA, insize));\n\n      EXPECT_TRUE(coded_input->ReadVarint32(&insize));\n      EXPECT_EQ(strlen(strB), insize);\n      EXPECT_TRUE(coded_input->ReadRaw(temp_buffer, insize));\n      EXPECT_EQ(0, memcmp(temp_buffer, strB, insize));\n\n      delete coded_input;\n      delete input;\n    }\n  }\n\n  delete [] temp_buffer;\n  delete [] buffer;\n}\n\n#if HAVE_ZLIB\nTEST_F(IoTest, GzipIo) {\n  const int kBufferSize = 2*1024;\n  uint8* buffer = new uint8[kBufferSize];\n  for (int i = 0; i < kBlockSizeCount; i++) {\n    for (int j = 0; j < kBlockSizeCount; j++) {\n      for (int z = 0; z < kBlockSizeCount; z++) {\n        int gzip_buffer_size = kBlockSizes[z];\n        int size;\n        {\n          ArrayOutputStream output(buffer, kBufferSize, kBlockSizes[i]);\n          GzipOutputStream::Options options;\n          options.format = GzipOutputStream::GZIP;\n          if (gzip_buffer_size != -1) {\n            options.buffer_size = gzip_buffer_size;\n          }\n          GzipOutputStream gzout(&output, options);\n          WriteStuff(&gzout);\n          gzout.Close();\n          size = output.ByteCount();\n        }\n        {\n          ArrayInputStream input(buffer, size, kBlockSizes[j]);\n          GzipInputStream gzin(\n              &input, GzipInputStream::GZIP, gzip_buffer_size);\n          ReadStuff(&gzin);\n        }\n      }\n    }\n  }\n  delete [] buffer;\n}\n\nTEST_F(IoTest, GzipIoWithFlush) {\n  const int kBufferSize = 2*1024;\n  uint8* buffer = new uint8[kBufferSize];\n  // We start with i = 4 as we want a block size > 6. With block size <= 6\n  // Flush() fills up the entire 2K buffer with flush markers and the test\n  // fails. See documentation for Flush() for more detail.\n  for (int i = 4; i < kBlockSizeCount; i++) {\n    for (int j = 0; j < kBlockSizeCount; j++) {\n      for (int z = 0; z < kBlockSizeCount; z++) {\n        int gzip_buffer_size = kBlockSizes[z];\n        int size;\n        {\n          ArrayOutputStream output(buffer, kBufferSize, kBlockSizes[i]);\n          GzipOutputStream::Options options;\n          options.format = GzipOutputStream::GZIP;\n          if (gzip_buffer_size != -1) {\n            options.buffer_size = gzip_buffer_size;\n          }\n          GzipOutputStream gzout(&output, options);\n          WriteStuff(&gzout);\n          EXPECT_TRUE(gzout.Flush());\n          gzout.Close();\n          size = output.ByteCount();\n        }\n        {\n          ArrayInputStream input(buffer, size, kBlockSizes[j]);\n          GzipInputStream gzin(\n              &input, GzipInputStream::GZIP, gzip_buffer_size);\n          ReadStuff(&gzin);\n        }\n      }\n    }\n  }\n  delete [] buffer;\n}\n\nTEST_F(IoTest, GzipIoContiguousFlushes) {\n  const int kBufferSize = 2*1024;\n  uint8* buffer = new uint8[kBufferSize];\n\n  int block_size = kBlockSizes[4];\n  int gzip_buffer_size = block_size;\n  int size;\n\n  ArrayOutputStream output(buffer, kBufferSize, block_size);\n  GzipOutputStream::Options options;\n  options.format = GzipOutputStream::GZIP;\n  if (gzip_buffer_size != -1) {\n    options.buffer_size = gzip_buffer_size;\n  }\n  GzipOutputStream gzout(&output, options);\n  WriteStuff(&gzout);\n  EXPECT_TRUE(gzout.Flush());\n  EXPECT_TRUE(gzout.Flush());\n  gzout.Close();\n  size = output.ByteCount();\n\n  ArrayInputStream input(buffer, size, block_size);\n  GzipInputStream gzin(\n      &input, GzipInputStream::GZIP, gzip_buffer_size);\n  ReadStuff(&gzin);\n\n  delete [] buffer;\n}\n\nTEST_F(IoTest, GzipIoReadAfterFlush) {\n  const int kBufferSize = 2*1024;\n  uint8* buffer = new uint8[kBufferSize];\n\n  int block_size = kBlockSizes[4];\n  int gzip_buffer_size = block_size;\n  int size;\n  ArrayOutputStream output(buffer, kBufferSize, block_size);\n  GzipOutputStream::Options options;\n  options.format = GzipOutputStream::GZIP;\n  if (gzip_buffer_size != -1) {\n    options.buffer_size = gzip_buffer_size;\n  }\n\n  GzipOutputStream gzout(&output, options);\n  WriteStuff(&gzout);\n  EXPECT_TRUE(gzout.Flush());\n  size = output.ByteCount();\n\n  ArrayInputStream input(buffer, size, block_size);\n  GzipInputStream gzin(\n      &input, GzipInputStream::GZIP, gzip_buffer_size);\n  ReadStuff(&gzin);\n\n  gzout.Close();\n\n  delete [] buffer;\n}\n\nTEST_F(IoTest, ZlibIo) {\n  const int kBufferSize = 2*1024;\n  uint8* buffer = new uint8[kBufferSize];\n  for (int i = 0; i < kBlockSizeCount; i++) {\n    for (int j = 0; j < kBlockSizeCount; j++) {\n      for (int z = 0; z < kBlockSizeCount; z++) {\n        int gzip_buffer_size = kBlockSizes[z];\n        int size;\n        {\n          ArrayOutputStream output(buffer, kBufferSize, kBlockSizes[i]);\n          GzipOutputStream::Options options;\n          options.format = GzipOutputStream::ZLIB;\n          if (gzip_buffer_size != -1) {\n            options.buffer_size = gzip_buffer_size;\n          }\n          GzipOutputStream gzout(&output, options);\n          WriteStuff(&gzout);\n          gzout.Close();\n          size = output.ByteCount();\n        }\n        {\n          ArrayInputStream input(buffer, size, kBlockSizes[j]);\n          GzipInputStream gzin(\n              &input, GzipInputStream::ZLIB, gzip_buffer_size);\n          ReadStuff(&gzin);\n        }\n      }\n    }\n  }\n  delete [] buffer;\n}\n\nTEST_F(IoTest, ZlibIoInputAutodetect) {\n  const int kBufferSize = 2*1024;\n  uint8* buffer = new uint8[kBufferSize];\n  int size;\n  {\n    ArrayOutputStream output(buffer, kBufferSize);\n    GzipOutputStream::Options options;\n    options.format = GzipOutputStream::ZLIB;\n    GzipOutputStream gzout(&output, options);\n    WriteStuff(&gzout);\n    gzout.Close();\n    size = output.ByteCount();\n  }\n  {\n    ArrayInputStream input(buffer, size);\n    GzipInputStream gzin(&input, GzipInputStream::AUTO);\n    ReadStuff(&gzin);\n  }\n  {\n    ArrayOutputStream output(buffer, kBufferSize);\n    GzipOutputStream::Options options;\n    options.format = GzipOutputStream::GZIP;\n    GzipOutputStream gzout(&output, options);\n    WriteStuff(&gzout);\n    gzout.Close();\n    size = output.ByteCount();\n  }\n  {\n    ArrayInputStream input(buffer, size);\n    GzipInputStream gzin(&input, GzipInputStream::AUTO);\n    ReadStuff(&gzin);\n  }\n  delete [] buffer;\n}\n\nstring IoTest::Compress(const string& data,\n                        const GzipOutputStream::Options& options) {\n  string result;\n  {\n    StringOutputStream output(&result);\n    GzipOutputStream gzout(&output, options);\n    WriteToOutput(&gzout, data.data(), data.size());\n  }\n  return result;\n}\n\nstring IoTest::Uncompress(const string& data) {\n  string result;\n  {\n    ArrayInputStream input(data.data(), data.size());\n    GzipInputStream gzin(&input);\n    const void* buffer;\n    int size;\n    while (gzin.Next(&buffer, &size)) {\n      result.append(reinterpret_cast<const char*>(buffer), size);\n    }\n  }\n  return result;\n}\n\nTEST_F(IoTest, CompressionOptions) {\n  // Some ad-hoc testing of compression options.\n\n  string golden;\n  GOOGLE_CHECK_OK(File::GetContents(\n      TestSourceDir() +\n          \"/google/protobuf/testdata/golden_message\",\n      &golden, true));\n\n  GzipOutputStream::Options options;\n  string gzip_compressed = Compress(golden, options);\n\n  options.compression_level = 0;\n  string not_compressed = Compress(golden, options);\n\n  // Try zlib compression for fun.\n  options = GzipOutputStream::Options();\n  options.format = GzipOutputStream::ZLIB;\n  string zlib_compressed = Compress(golden, options);\n\n  // Uncompressed should be bigger than the original since it should have some\n  // sort of header.\n  EXPECT_GT(not_compressed.size(), golden.size());\n\n  // Higher compression levels should result in smaller sizes.\n  EXPECT_LT(zlib_compressed.size(), not_compressed.size());\n\n  // ZLIB format should differ from GZIP format.\n  EXPECT_TRUE(zlib_compressed != gzip_compressed);\n\n  // Everything should decompress correctly.\n  EXPECT_TRUE(Uncompress(not_compressed) == golden);\n  EXPECT_TRUE(Uncompress(gzip_compressed) == golden);\n  EXPECT_TRUE(Uncompress(zlib_compressed) == golden);\n}\n\nTEST_F(IoTest, TwoSessionWriteGzip) {\n  // Test that two concatenated gzip streams can be read correctly\n\n  static const char* strA = \"0123456789\";\n  static const char* strB = \"QuickBrownFox\";\n  const int kBufferSize = 2*1024;\n  uint8* buffer = new uint8[kBufferSize];\n  char* temp_buffer = new char[40];\n\n  for (int i = 0; i < kBlockSizeCount; i++) {\n    for (int j = 0; j < kBlockSizeCount; j++) {\n      ArrayOutputStream* output =\n          new ArrayOutputStream(buffer, kBufferSize, kBlockSizes[i]);\n      GzipOutputStream* gzout = new GzipOutputStream(output);\n      CodedOutputStream* coded_output = new CodedOutputStream(gzout);\n      int32 outlen = strlen(strA) + 1;\n      coded_output->WriteVarint32(outlen);\n      coded_output->WriteRaw(strA, outlen);\n      delete coded_output;  // flush\n      delete gzout;  // flush\n      int64 pos = output->ByteCount();\n      delete output;\n      output = new ArrayOutputStream(\n          buffer + pos, kBufferSize - pos, kBlockSizes[i]);\n      gzout = new GzipOutputStream(output);\n      coded_output = new CodedOutputStream(gzout);\n      outlen = strlen(strB) + 1;\n      coded_output->WriteVarint32(outlen);\n      coded_output->WriteRaw(strB, outlen);\n      delete coded_output;  // flush\n      delete gzout;  // flush\n      int64 size = pos + output->ByteCount();\n      delete output;\n\n      ArrayInputStream* input =\n          new ArrayInputStream(buffer, size, kBlockSizes[j]);\n      GzipInputStream* gzin = new GzipInputStream(input);\n      CodedInputStream* coded_input = new CodedInputStream(gzin);\n      uint32 insize;\n      EXPECT_TRUE(coded_input->ReadVarint32(&insize));\n      EXPECT_EQ(strlen(strA) + 1, insize);\n      EXPECT_TRUE(coded_input->ReadRaw(temp_buffer, insize));\n      EXPECT_EQ(0, memcmp(temp_buffer, strA, insize))\n          << \"strA=\" << strA << \" in=\" << temp_buffer;\n\n      EXPECT_TRUE(coded_input->ReadVarint32(&insize));\n      EXPECT_EQ(strlen(strB) + 1, insize);\n      EXPECT_TRUE(coded_input->ReadRaw(temp_buffer, insize));\n      EXPECT_EQ(0, memcmp(temp_buffer, strB, insize))\n          << \" out_block_size=\" << kBlockSizes[i]\n          << \" in_block_size=\" << kBlockSizes[j]\n          << \" pos=\" << pos\n          << \" size=\" << size\n          << \" strB=\" << strB << \" in=\" << temp_buffer;\n\n      delete coded_input;\n      delete gzin;\n      delete input;\n    }\n  }\n\n  delete [] temp_buffer;\n  delete [] buffer;\n}\n\nTEST_F(IoTest, GzipInputByteCountAfterClosed) {\n  string golden = \"abcdefghijklmnopqrstuvwxyz\";\n  string compressed = Compress(golden, GzipOutputStream::Options());\n\n  for (int i = 0; i < kBlockSizeCount; i++) {\n    ArrayInputStream arr_input(compressed.data(), compressed.size(),\n                               kBlockSizes[i]);\n    GzipInputStream gz_input(&arr_input);\n    const void* buffer;\n    int size;\n    while (gz_input.Next(&buffer, &size)) {\n      EXPECT_LE(gz_input.ByteCount(), golden.size());\n    }\n    EXPECT_EQ(golden.size(), gz_input.ByteCount());\n  }\n}\n\nTEST_F(IoTest, GzipInputByteCountAfterClosedConcatenatedStreams) {\n  string golden1 = \"abcdefghijklmnopqrstuvwxyz\";\n  string golden2 = \"the quick brown fox jumps over the lazy dog\";\n  const size_t total_size = golden1.size() + golden2.size();\n  string compressed = Compress(golden1, GzipOutputStream::Options()) +\n                      Compress(golden2, GzipOutputStream::Options());\n\n  for (int i = 0; i < kBlockSizeCount; i++) {\n    ArrayInputStream arr_input(compressed.data(), compressed.size(),\n                               kBlockSizes[i]);\n    GzipInputStream gz_input(&arr_input);\n    const void* buffer;\n    int size;\n    while (gz_input.Next(&buffer, &size)) {\n      EXPECT_LE(gz_input.ByteCount(), total_size);\n    }\n    EXPECT_EQ(total_size, gz_input.ByteCount());\n  }\n}\n#endif\n\n// There is no string input, only string output.  Also, it doesn't support\n// explicit block sizes.  So, we'll only run one test and we'll use\n// ArrayInput to read back the results.\nTEST_F(IoTest, StringIo) {\n  string str;\n  {\n    StringOutputStream output(&str);\n    WriteStuff(&output);\n  }\n  {\n    ArrayInputStream input(str.data(), str.size());\n    ReadStuff(&input);\n  }\n}\n\n\n// To test files, we create a temporary file, write, read, truncate, repeat.\nTEST_F(IoTest, FileIo) {\n  string filename = TestTempDir() + \"/zero_copy_stream_test_file\";\n\n  for (int i = 0; i < kBlockSizeCount; i++) {\n    for (int j = 0; j < kBlockSizeCount; j++) {\n      // Make a temporary file.\n      int file =\n        open(filename.c_str(), O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0777);\n      ASSERT_GE(file, 0);\n\n      {\n        FileOutputStream output(file, kBlockSizes[i]);\n        WriteStuff(&output);\n        EXPECT_EQ(0, output.GetErrno());\n      }\n\n      // Rewind.\n      ASSERT_NE(lseek(file, 0, SEEK_SET), (off_t)-1);\n\n      {\n        FileInputStream input(file, kBlockSizes[j]);\n        ReadStuff(&input);\n        EXPECT_EQ(0, input.GetErrno());\n      }\n\n      close(file);\n    }\n  }\n}\n\n#if HAVE_ZLIB\nTEST_F(IoTest, GzipFileIo) {\n  string filename = TestTempDir() + \"/zero_copy_stream_test_file\";\n\n  for (int i = 0; i < kBlockSizeCount; i++) {\n    for (int j = 0; j < kBlockSizeCount; j++) {\n      // Make a temporary file.\n      int file =\n        open(filename.c_str(), O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0777);\n      ASSERT_GE(file, 0);\n      {\n        FileOutputStream output(file, kBlockSizes[i]);\n        GzipOutputStream gzout(&output);\n        WriteStuffLarge(&gzout);\n        gzout.Close();\n        output.Flush();\n        EXPECT_EQ(0, output.GetErrno());\n      }\n\n      // Rewind.\n      ASSERT_NE(lseek(file, 0, SEEK_SET), (off_t)-1);\n\n      {\n        FileInputStream input(file, kBlockSizes[j]);\n        GzipInputStream gzin(&input);\n        ReadStuffLarge(&gzin);\n        EXPECT_EQ(0, input.GetErrno());\n      }\n\n      close(file);\n    }\n  }\n}\n#endif\n\n// MSVC raises various debugging exceptions if we try to use a file\n// descriptor of -1, defeating our tests below.  This class will disable\n// these debug assertions while in scope.\nclass MsvcDebugDisabler {\n public:\n#if defined(_MSC_VER) && _MSC_VER >= 1400\n  MsvcDebugDisabler() {\n    old_handler_ = _set_invalid_parameter_handler(MyHandler);\n    old_mode_ = _CrtSetReportMode(_CRT_ASSERT, 0);\n  }\n  ~MsvcDebugDisabler() {\n    old_handler_ = _set_invalid_parameter_handler(old_handler_);\n    old_mode_ = _CrtSetReportMode(_CRT_ASSERT, old_mode_);\n  }\n\n  static void MyHandler(const wchar_t *expr,\n                        const wchar_t *func,\n                        const wchar_t *file,\n                        unsigned int line,\n                        uintptr_t pReserved) {\n    // do nothing\n  }\n\n  _invalid_parameter_handler old_handler_;\n  int old_mode_;\n#else\n  // Dummy constructor and destructor to ensure that GCC doesn't complain\n  // that debug_disabler is an unused variable.\n  MsvcDebugDisabler() {}\n  ~MsvcDebugDisabler() {}\n#endif\n};\n\n// Test that FileInputStreams report errors correctly.\nTEST_F(IoTest, FileReadError) {\n  MsvcDebugDisabler debug_disabler;\n\n  // -1 = invalid file descriptor.\n  FileInputStream input(-1);\n\n  const void* buffer;\n  int size;\n  EXPECT_FALSE(input.Next(&buffer, &size));\n  EXPECT_EQ(EBADF, input.GetErrno());\n}\n\n// Test that FileOutputStreams report errors correctly.\nTEST_F(IoTest, FileWriteError) {\n  MsvcDebugDisabler debug_disabler;\n\n  // -1 = invalid file descriptor.\n  FileOutputStream input(-1);\n\n  void* buffer;\n  int size;\n\n  // The first call to Next() succeeds because it doesn't have anything to\n  // write yet.\n  EXPECT_TRUE(input.Next(&buffer, &size));\n\n  // Second call fails.\n  EXPECT_FALSE(input.Next(&buffer, &size));\n\n  EXPECT_EQ(EBADF, input.GetErrno());\n}\n\n// Pipes are not seekable, so File{Input,Output}Stream ends up doing some\n// different things to handle them.  We'll test by writing to a pipe and\n// reading back from it.\nTEST_F(IoTest, PipeIo) {\n  int files[2];\n\n  for (int i = 0; i < kBlockSizeCount; i++) {\n    for (int j = 0; j < kBlockSizeCount; j++) {\n      // Need to create a new pipe each time because ReadStuff() expects\n      // to see EOF at the end.\n      ASSERT_EQ(pipe(files), 0);\n\n      {\n        FileOutputStream output(files[1], kBlockSizes[i]);\n        WriteStuff(&output);\n        EXPECT_EQ(0, output.GetErrno());\n      }\n      close(files[1]);  // Send EOF.\n\n      {\n        FileInputStream input(files[0], kBlockSizes[j]);\n        ReadStuff(&input);\n        EXPECT_EQ(0, input.GetErrno());\n      }\n      close(files[0]);\n    }\n  }\n}\n\n// Test using C++ iostreams.\nTEST_F(IoTest, IostreamIo) {\n  for (int i = 0; i < kBlockSizeCount; i++) {\n    for (int j = 0; j < kBlockSizeCount; j++) {\n      {\n        stringstream stream;\n\n        {\n          OstreamOutputStream output(&stream, kBlockSizes[i]);\n          WriteStuff(&output);\n          EXPECT_FALSE(stream.fail());\n        }\n\n        {\n          IstreamInputStream input(&stream, kBlockSizes[j]);\n          ReadStuff(&input);\n          EXPECT_TRUE(stream.eof());\n        }\n      }\n\n      {\n        stringstream stream;\n\n        {\n          OstreamOutputStream output(&stream, kBlockSizes[i]);\n          WriteStuffLarge(&output);\n          EXPECT_FALSE(stream.fail());\n        }\n\n        {\n          IstreamInputStream input(&stream, kBlockSizes[j]);\n          ReadStuffLarge(&input);\n          EXPECT_TRUE(stream.eof());\n        }\n      }\n    }\n  }\n}\n\n// To test ConcatenatingInputStream, we create several ArrayInputStreams\n// covering a buffer and then concatenate them.\nTEST_F(IoTest, ConcatenatingInputStream) {\n  const int kBufferSize = 256;\n  uint8 buffer[kBufferSize];\n\n  // Fill the buffer.\n  ArrayOutputStream output(buffer, kBufferSize);\n  WriteStuff(&output);\n\n  // Now split it up into multiple streams of varying sizes.\n  ASSERT_EQ(68, output.ByteCount());  // Test depends on this.\n  ArrayInputStream input1(buffer     , 12);\n  ArrayInputStream input2(buffer + 12,  7);\n  ArrayInputStream input3(buffer + 19,  6);\n  ArrayInputStream input4(buffer + 25, 15);\n  ArrayInputStream input5(buffer + 40,  0);\n  // Note:  We want to make sure we have a stream boundary somewhere between\n  // bytes 42 and 62, which is the range that it Skip()ed by ReadStuff().  This\n  // tests that a bug that existed in the original code for Skip() is fixed.\n  ArrayInputStream input6(buffer + 40, 10);\n  ArrayInputStream input7(buffer + 50, 18);  // Total = 68 bytes.\n\n  ZeroCopyInputStream* streams[] =\n    {&input1, &input2, &input3, &input4, &input5, &input6, &input7};\n\n  // Create the concatenating stream and read.\n  ConcatenatingInputStream input(streams, GOOGLE_ARRAYSIZE(streams));\n  ReadStuff(&input);\n}\n\n// To test LimitingInputStream, we write our golden text to a buffer, then\n// create an ArrayInputStream that contains the whole buffer (not just the\n// bytes written), then use a LimitingInputStream to limit it just to the\n// bytes written.\nTEST_F(IoTest, LimitingInputStream) {\n  const int kBufferSize = 256;\n  uint8 buffer[kBufferSize];\n\n  // Fill the buffer.\n  ArrayOutputStream output(buffer, kBufferSize);\n  WriteStuff(&output);\n\n  // Set up input.\n  ArrayInputStream array_input(buffer, kBufferSize);\n  LimitingInputStream input(&array_input, output.ByteCount());\n\n  ReadStuff(&input);\n}\n\n// Checks that ByteCount works correctly for LimitingInputStreams where the\n// underlying stream has already been read.\nTEST_F(IoTest, LimitingInputStreamByteCount) {\n  const int kHalfBufferSize = 128;\n  const int kBufferSize = kHalfBufferSize * 2;\n  uint8 buffer[kBufferSize];\n\n  // Set up input. Only allow half to be read at once.\n  ArrayInputStream array_input(buffer, kBufferSize, kHalfBufferSize);\n  const void* data;\n  int size;\n  EXPECT_TRUE(array_input.Next(&data, &size));\n  EXPECT_EQ(kHalfBufferSize, array_input.ByteCount());\n  // kHalfBufferSize - 1 to test limiting logic as well.\n  LimitingInputStream input(&array_input, kHalfBufferSize - 1);\n  EXPECT_EQ(0, input.ByteCount());\n  EXPECT_TRUE(input.Next(&data, &size));\n  EXPECT_EQ(kHalfBufferSize - 1 , input.ByteCount());\n}\n\n// Check that a zero-size array doesn't confuse the code.\nTEST(ZeroSizeArray, Input) {\n  ArrayInputStream input(NULL, 0);\n  const void* data;\n  int size;\n  EXPECT_FALSE(input.Next(&data, &size));\n}\n\nTEST(ZeroSizeArray, Output) {\n  ArrayOutputStream output(NULL, 0);\n  void* data;\n  int size;\n  EXPECT_FALSE(output.Next(&data, &size));\n}\n\n}  // namespace\n}  // namespace io\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/lite_arena_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/arena_test_util.h>\n#include <google/protobuf/map_lite_test_util.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace {\n\nTEST(LiteArenaTest, MapNoHeapAllocation) {\n  // Allocate a large initial block to avoid mallocs during hooked test.\n  std::vector<char> arena_block(128 * 1024);\n  google::protobuf::ArenaOptions options;\n  options.initial_block = &arena_block[0];\n  options.initial_block_size = arena_block.size();\n  google::protobuf::Arena arena(options);\n  string data;\n  data.reserve(128 * 1024);\n\n  {\n    // TODO(teboring): Enable no heap check when ArenaStringPtr is used in\n    // Map.\n    // google::protobuf::internal::NoHeapChecker no_heap;\n\n    protobuf_unittest::TestArenaMapLite* from =\n        google::protobuf::Arena::CreateMessage<protobuf_unittest::TestArenaMapLite>(&arena);\n    google::protobuf::MapLiteTestUtil::SetArenaMapFields(from);\n    from->SerializeToString(&data);\n\n    protobuf_unittest::TestArenaMapLite* to =\n        google::protobuf::Arena::CreateMessage<protobuf_unittest::TestArenaMapLite>(&arena);\n    to->ParseFromString(data);\n    google::protobuf::MapLiteTestUtil::ExpectArenaMapFieldsSet(*to);\n  }\n}\n\nTEST(LiteArenaTest, UnknownFieldMemLeak) {\n  google::protobuf::Arena arena;\n  protobuf_unittest::ForeignMessageArenaLite* message =\n      google::protobuf::Arena::CreateMessage<protobuf_unittest::ForeignMessageArenaLite>(\n          &arena);\n  string data = \"\\012\\000\";\n  int original_capacity = data.capacity();\n  while (data.capacity() <= original_capacity) {\n    data.append(\"a\");\n  }\n  data[1] = data.size() - 2;\n  message->ParseFromString(data);\n}\n\n}  // namespace\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/lite_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n\n#include <string>\n#include <iostream>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/arena_test_util.h>\n#include <google/protobuf/map_lite_unittest.pb.h>\n#include <google/protobuf/map_lite_test_util.h>\n#include <google/protobuf/test_util_lite.h>\n#include <google/protobuf/unittest_lite.pb.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl_lite.h>\n#include <google/protobuf/wire_format_lite.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n#include <google/protobuf/stubs/strutil.h>\n\nusing namespace std;\n\nnamespace {\n// Helper methods to test parsing merge behavior.\nvoid ExpectMessageMerged(const google::protobuf::unittest::TestAllTypesLite& message) {\n  GOOGLE_CHECK(message.optional_int32() == 3);\n  GOOGLE_CHECK(message.optional_int64() == 2);\n  GOOGLE_CHECK(message.optional_string() == \"hello\");\n}\n\nvoid AssignParsingMergeMessages(\n    google::protobuf::unittest::TestAllTypesLite* msg1,\n    google::protobuf::unittest::TestAllTypesLite* msg2,\n    google::protobuf::unittest::TestAllTypesLite* msg3) {\n  msg1->set_optional_int32(1);\n  msg2->set_optional_int64(2);\n  msg3->set_optional_int32(3);\n  msg3->set_optional_string(\"hello\");\n}\n\nvoid SetAllTypesInEmptyMessageUnknownFields(\n    google::protobuf::unittest::TestEmptyMessageLite* empty_message) {\n  protobuf_unittest::TestAllTypesLite message;\n  google::protobuf::TestUtilLite::ExpectClear(message);\n  google::protobuf::TestUtilLite::SetAllFields(&message);\n  string data = message.SerializeAsString();\n  empty_message->ParseFromString(data);\n}\n\nvoid SetSomeTypesInEmptyMessageUnknownFields(\n    google::protobuf::unittest::TestEmptyMessageLite* empty_message) {\n  protobuf_unittest::TestAllTypesLite message;\n  google::protobuf::TestUtilLite::ExpectClear(message);\n  message.set_optional_int32(101);\n  message.set_optional_int64(102);\n  message.set_optional_uint32(103);\n  message.set_optional_uint64(104);\n  string data = message.SerializeAsString();\n  empty_message->ParseFromString(data);\n}\n\n}  // namespace\n\n#define EXPECT_TRUE GOOGLE_CHECK\n#define ASSERT_TRUE GOOGLE_CHECK\n#define EXPECT_FALSE(COND) GOOGLE_CHECK(!(COND))\n#define EXPECT_EQ GOOGLE_CHECK_EQ\n#define ASSERT_EQ GOOGLE_CHECK_EQ\n\nint main(int argc, char* argv[]) {\n  string data, data2, packed_data;\n\n  {\n    protobuf_unittest::TestAllTypesLite message, message2, message3;\n    google::protobuf::TestUtilLite::ExpectClear(message);\n    google::protobuf::TestUtilLite::SetAllFields(&message);\n    message2.CopyFrom(message);\n    data = message.SerializeAsString();\n    message3.ParseFromString(data);\n    google::protobuf::TestUtilLite::ExpectAllFieldsSet(message);\n    google::protobuf::TestUtilLite::ExpectAllFieldsSet(message2);\n    google::protobuf::TestUtilLite::ExpectAllFieldsSet(message3);\n    google::protobuf::TestUtilLite::ModifyRepeatedFields(&message);\n    google::protobuf::TestUtilLite::ExpectRepeatedFieldsModified(message);\n    message.Clear();\n    google::protobuf::TestUtilLite::ExpectClear(message);\n  }\n\n  {\n    protobuf_unittest::TestAllExtensionsLite message, message2, message3;\n    google::protobuf::TestUtilLite::ExpectExtensionsClear(message);\n    google::protobuf::TestUtilLite::SetAllExtensions(&message);\n    message2.CopyFrom(message);\n    string extensions_data = message.SerializeAsString();\n    message3.ParseFromString(extensions_data);\n    google::protobuf::TestUtilLite::ExpectAllExtensionsSet(message);\n    google::protobuf::TestUtilLite::ExpectAllExtensionsSet(message2);\n    google::protobuf::TestUtilLite::ExpectAllExtensionsSet(message3);\n    google::protobuf::TestUtilLite::ModifyRepeatedExtensions(&message);\n    google::protobuf::TestUtilLite::ExpectRepeatedExtensionsModified(message);\n    message.Clear();\n    google::protobuf::TestUtilLite::ExpectExtensionsClear(message);\n  }\n\n  {\n    protobuf_unittest::TestPackedTypesLite message, message2, message3;\n    google::protobuf::TestUtilLite::ExpectPackedClear(message);\n    google::protobuf::TestUtilLite::SetPackedFields(&message);\n    message2.CopyFrom(message);\n    packed_data = message.SerializeAsString();\n    message3.ParseFromString(packed_data);\n    google::protobuf::TestUtilLite::ExpectPackedFieldsSet(message);\n    google::protobuf::TestUtilLite::ExpectPackedFieldsSet(message2);\n    google::protobuf::TestUtilLite::ExpectPackedFieldsSet(message3);\n    google::protobuf::TestUtilLite::ModifyPackedFields(&message);\n    google::protobuf::TestUtilLite::ExpectPackedFieldsModified(message);\n    message.Clear();\n    google::protobuf::TestUtilLite::ExpectPackedClear(message);\n  }\n\n  {\n    protobuf_unittest::TestPackedExtensionsLite message, message2, message3;\n    google::protobuf::TestUtilLite::ExpectPackedExtensionsClear(message);\n    google::protobuf::TestUtilLite::SetPackedExtensions(&message);\n    message2.CopyFrom(message);\n    string packed_extensions_data = message.SerializeAsString();\n    GOOGLE_CHECK(packed_extensions_data == packed_data);\n    message3.ParseFromString(packed_extensions_data);\n    google::protobuf::TestUtilLite::ExpectPackedExtensionsSet(message);\n    google::protobuf::TestUtilLite::ExpectPackedExtensionsSet(message2);\n    google::protobuf::TestUtilLite::ExpectPackedExtensionsSet(message3);\n    google::protobuf::TestUtilLite::ModifyPackedExtensions(&message);\n    google::protobuf::TestUtilLite::ExpectPackedExtensionsModified(message);\n    message.Clear();\n    google::protobuf::TestUtilLite::ExpectPackedExtensionsClear(message);\n  }\n\n  {\n    // Test that if an optional or required message/group field appears multiple\n    // times in the input, they need to be merged.\n    google::protobuf::unittest::TestParsingMergeLite::RepeatedFieldsGenerator generator;\n    google::protobuf::unittest::TestAllTypesLite* msg1;\n    google::protobuf::unittest::TestAllTypesLite* msg2;\n    google::protobuf::unittest::TestAllTypesLite* msg3;\n\n#define ASSIGN_REPEATED_FIELD(FIELD)                \\\n  msg1 = generator.add_##FIELD();                   \\\n  msg2 = generator.add_##FIELD();                   \\\n  msg3 = generator.add_##FIELD();                   \\\n  AssignParsingMergeMessages(msg1, msg2, msg3)\n\n    ASSIGN_REPEATED_FIELD(field1);\n    ASSIGN_REPEATED_FIELD(field2);\n    ASSIGN_REPEATED_FIELD(field3);\n    ASSIGN_REPEATED_FIELD(ext1);\n    ASSIGN_REPEATED_FIELD(ext2);\n\n#undef ASSIGN_REPEATED_FIELD\n#define ASSIGN_REPEATED_GROUP(FIELD)                \\\n  msg1 = generator.add_##FIELD()->mutable_field1(); \\\n  msg2 = generator.add_##FIELD()->mutable_field1(); \\\n  msg3 = generator.add_##FIELD()->mutable_field1(); \\\n  AssignParsingMergeMessages(msg1, msg2, msg3)\n\n    ASSIGN_REPEATED_GROUP(group1);\n    ASSIGN_REPEATED_GROUP(group2);\n\n#undef ASSIGN_REPEATED_GROUP\n\n    string buffer;\n    generator.SerializeToString(&buffer);\n    google::protobuf::unittest::TestParsingMergeLite parsing_merge;\n    parsing_merge.ParseFromString(buffer);\n\n    // Required and optional fields should be merged.\n    ExpectMessageMerged(parsing_merge.required_all_types());\n    ExpectMessageMerged(parsing_merge.optional_all_types());\n    ExpectMessageMerged(\n        parsing_merge.optionalgroup().optional_group_all_types());\n    ExpectMessageMerged(parsing_merge.GetExtension(\n        google::protobuf::unittest::TestParsingMergeLite::optional_ext));\n\n    // Repeated fields should not be merged.\n    GOOGLE_CHECK(parsing_merge.repeated_all_types_size() == 3);\n    GOOGLE_CHECK(parsing_merge.repeatedgroup_size() == 3);\n    GOOGLE_CHECK(parsing_merge.ExtensionSize(\n        google::protobuf::unittest::TestParsingMergeLite::repeated_ext) == 3);\n  }\n\n  // Test unknown fields support for lite messages.\n  {\n    protobuf_unittest::TestAllTypesLite message, message2;\n    protobuf_unittest::TestEmptyMessageLite empty_message;\n    google::protobuf::TestUtilLite::ExpectClear(message);\n    google::protobuf::TestUtilLite::SetAllFields(&message);\n    data = message.SerializeAsString();\n    empty_message.ParseFromString(data);\n    data.clear();\n    data = empty_message.SerializeAsString();\n    message2.ParseFromString(data);\n    data = message2.SerializeAsString();\n    google::protobuf::TestUtilLite::ExpectAllFieldsSet(message2);\n    message.Clear();\n    google::protobuf::TestUtilLite::ExpectClear(message);\n  }\n\n  {\n    protobuf_unittest::TestAllExtensionsLite message, message2;\n    protobuf_unittest::TestEmptyMessageLite empty_message;\n    google::protobuf::TestUtilLite::ExpectExtensionsClear(message);\n    google::protobuf::TestUtilLite::SetAllExtensions(&message);\n    data = message.SerializeAsString();\n    empty_message.ParseFromString(data);\n    data.clear();\n    data = empty_message.SerializeAsString();\n    message2.ParseFromString(data);\n    data = message2.SerializeAsString();\n    google::protobuf::TestUtilLite::ExpectAllExtensionsSet(message2);\n    message.Clear();\n    google::protobuf::TestUtilLite::ExpectExtensionsClear(message);\n  }\n\n  {\n    protobuf_unittest::TestPackedTypesLite message, message2;\n    protobuf_unittest::TestEmptyMessageLite empty_message;\n    google::protobuf::TestUtilLite::ExpectPackedClear(message);\n    google::protobuf::TestUtilLite::SetPackedFields(&message);\n    data = message.SerializeAsString();\n    empty_message.ParseFromString(data);\n    data.clear();\n    data = empty_message.SerializeAsString();\n    message2.ParseFromString(data);\n    data = message2.SerializeAsString();\n    google::protobuf::TestUtilLite::ExpectPackedFieldsSet(message2);\n    message.Clear();\n    google::protobuf::TestUtilLite::ExpectPackedClear(message);\n  }\n\n  {\n    protobuf_unittest::TestPackedExtensionsLite message, message2;\n    protobuf_unittest::TestEmptyMessageLite empty_message;\n    google::protobuf::TestUtilLite::ExpectPackedExtensionsClear(message);\n    google::protobuf::TestUtilLite::SetPackedExtensions(&message);\n    data = message.SerializeAsString();\n    empty_message.ParseFromString(data);\n    data.clear();\n    data = empty_message.SerializeAsString();\n    message2.ParseFromString(data);\n    data = message2.SerializeAsString();\n    google::protobuf::TestUtilLite::ExpectPackedExtensionsSet(message2);\n    message.Clear();\n    google::protobuf::TestUtilLite::ExpectPackedExtensionsClear(message);\n  }\n\n  {\n    // Test Unknown fields swap\n    protobuf_unittest::TestEmptyMessageLite empty_message, empty_message2;\n    SetAllTypesInEmptyMessageUnknownFields(&empty_message);\n    SetSomeTypesInEmptyMessageUnknownFields(&empty_message2);\n    data = empty_message.SerializeAsString();\n    data2 = empty_message2.SerializeAsString();\n    empty_message.Swap(&empty_message2);\n    GOOGLE_CHECK_EQ(data, empty_message2.SerializeAsString());\n    GOOGLE_CHECK_EQ(data2, empty_message.SerializeAsString());\n  }\n\n  {\n    // Test unknown fields swap with self\n    protobuf_unittest::TestEmptyMessageLite empty_message;\n    SetAllTypesInEmptyMessageUnknownFields(&empty_message);\n    data = empty_message.SerializeAsString();\n    empty_message.Swap(&empty_message);\n    GOOGLE_CHECK_EQ(data, empty_message.SerializeAsString());\n  }\n\n  {\n    // Test MergeFrom with unknown fields\n    protobuf_unittest::TestAllTypesLite message, message2;\n    protobuf_unittest::TestEmptyMessageLite empty_message, empty_message2;\n    message.set_optional_int32(101);\n    message.add_repeated_int32(201);\n    message.set_optional_nested_enum(google::protobuf::unittest::TestAllTypesLite::BAZ);\n    message2.set_optional_int64(102);\n    message2.add_repeated_int64(202);\n    message2.set_optional_foreign_enum(google::protobuf::unittest::FOREIGN_LITE_BAZ);\n\n    data = message.SerializeAsString();\n    empty_message.ParseFromString(data);\n    data = message2.SerializeAsString();\n    empty_message2.ParseFromString(data);\n    message.MergeFrom(message2);\n    empty_message.MergeFrom(empty_message2);\n\n    data = empty_message.SerializeAsString();\n    message2.ParseFromString(data);\n    // We do not compare the serialized output of a normal message and a lite\n    // message because the order of fields do not match. We convert lite message\n    // back into normal message, then compare.\n    GOOGLE_CHECK_EQ(message.SerializeAsString(), message2.SerializeAsString());\n  }\n\n  {\n    // Test unknown enum value\n    protobuf_unittest::TestAllTypesLite message;\n    string buffer;\n    {\n      google::protobuf::io::StringOutputStream output_stream(&buffer);\n      google::protobuf::io::CodedOutputStream coded_output(&output_stream);\n      google::protobuf::internal::WireFormatLite::WriteTag(\n          protobuf_unittest::TestAllTypesLite::kOptionalNestedEnumFieldNumber,\n          google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT, &coded_output);\n      coded_output.WriteVarint32(10);\n      google::protobuf::internal::WireFormatLite::WriteTag(\n          protobuf_unittest::TestAllTypesLite::kRepeatedNestedEnumFieldNumber,\n          google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT, &coded_output);\n      coded_output.WriteVarint32(20);\n    }\n    message.ParseFromString(buffer);\n    data = message.SerializeAsString();\n    GOOGLE_CHECK_EQ(data, buffer);\n  }\n\n  {\n    // Test Clear with unknown fields\n    protobuf_unittest::TestEmptyMessageLite empty_message;\n    SetAllTypesInEmptyMessageUnknownFields(&empty_message);\n    empty_message.Clear();\n    GOOGLE_CHECK_EQ(0, empty_message.unknown_fields().size());\n  }\n\n  // Tests for map lite =============================================\n\n  {\n    // Accessors\n    protobuf_unittest::TestMapLite message;\n\n    google::protobuf::MapLiteTestUtil::SetMapFields(&message);\n    google::protobuf::MapLiteTestUtil::ExpectMapFieldsSet(message);\n\n    google::protobuf::MapLiteTestUtil::ModifyMapFields(&message);\n    google::protobuf::MapLiteTestUtil::ExpectMapFieldsModified(message);\n  }\n\n  {\n    // SetMapFieldsInitialized\n    protobuf_unittest::TestMapLite message;\n\n    google::protobuf::MapLiteTestUtil::SetMapFieldsInitialized(&message);\n    google::protobuf::MapLiteTestUtil::ExpectMapFieldsSetInitialized(message);\n  }\n\n  {\n    // Clear\n    protobuf_unittest::TestMapLite message;\n\n    google::protobuf::MapLiteTestUtil::SetMapFields(&message);\n    message.Clear();\n    google::protobuf::MapLiteTestUtil::ExpectClear(message);\n  }\n\n  {\n    // ClearMessageMap\n    protobuf_unittest::TestMessageMapLite message;\n\n    // Creates a TestAllTypes with default value\n    google::protobuf::TestUtilLite::ExpectClear(\n        (*message.mutable_map_int32_message())[0]);\n  }\n\n  {\n    // CopyFrom\n    protobuf_unittest::TestMapLite message1, message2;\n\n    google::protobuf::MapLiteTestUtil::SetMapFields(&message1);\n    message2.CopyFrom(message1);\n    google::protobuf::MapLiteTestUtil::ExpectMapFieldsSet(message2);\n\n    // Copying from self should be a no-op.\n    message2.CopyFrom(message2);\n    google::protobuf::MapLiteTestUtil::ExpectMapFieldsSet(message2);\n  }\n\n  {\n    // CopyFromMessageMap\n    protobuf_unittest::TestMessageMapLite message1, message2;\n\n    (*message1.mutable_map_int32_message())[0].add_repeated_int32(100);\n    (*message2.mutable_map_int32_message())[0].add_repeated_int32(101);\n\n    message1.CopyFrom(message2);\n\n    // Checks repeated field is overwritten.\n    EXPECT_EQ(1, message1.map_int32_message().at(0).repeated_int32_size());\n    EXPECT_EQ(101, message1.map_int32_message().at(0).repeated_int32(0));\n  }\n\n  {\n    // SwapWithEmpty\n    protobuf_unittest::TestMapLite message1, message2;\n\n    google::protobuf::MapLiteTestUtil::SetMapFields(&message1);\n    google::protobuf::MapLiteTestUtil::ExpectMapFieldsSet(message1);\n    google::protobuf::MapLiteTestUtil::ExpectClear(message2);\n\n    message1.Swap(&message2);\n    google::protobuf::MapLiteTestUtil::ExpectMapFieldsSet(message2);\n    google::protobuf::MapLiteTestUtil::ExpectClear(message1);\n  }\n\n  {\n    // SwapWithSelf\n    protobuf_unittest::TestMapLite message;\n\n    google::protobuf::MapLiteTestUtil::SetMapFields(&message);\n    google::protobuf::MapLiteTestUtil::ExpectMapFieldsSet(message);\n\n    message.Swap(&message);\n    google::protobuf::MapLiteTestUtil::ExpectMapFieldsSet(message);\n  }\n\n  {\n    // SwapWithOther\n    protobuf_unittest::TestMapLite message1, message2;\n\n    google::protobuf::MapLiteTestUtil::SetMapFields(&message1);\n    google::protobuf::MapLiteTestUtil::SetMapFields(&message2);\n    google::protobuf::MapLiteTestUtil::ModifyMapFields(&message2);\n\n    message1.Swap(&message2);\n    google::protobuf::MapLiteTestUtil::ExpectMapFieldsModified(message1);\n    google::protobuf::MapLiteTestUtil::ExpectMapFieldsSet(message2);\n  }\n\n  {\n    // CopyConstructor\n    protobuf_unittest::TestMapLite message1;\n    google::protobuf::MapLiteTestUtil::SetMapFields(&message1);\n\n    protobuf_unittest::TestMapLite message2(message1);\n    google::protobuf::MapLiteTestUtil::ExpectMapFieldsSet(message2);\n  }\n\n  {\n    // CopyAssignmentOperator\n    protobuf_unittest::TestMapLite message1;\n    google::protobuf::MapLiteTestUtil::SetMapFields(&message1);\n\n    protobuf_unittest::TestMapLite message2;\n    message2 = message1;\n    google::protobuf::MapLiteTestUtil::ExpectMapFieldsSet(message2);\n\n    // Make sure that self-assignment does something sane.\n    message2.operator=(message2);\n    google::protobuf::MapLiteTestUtil::ExpectMapFieldsSet(message2);\n  }\n\n  {\n    // NonEmptyMergeFrom\n    protobuf_unittest::TestMapLite message1, message2;\n\n    google::protobuf::MapLiteTestUtil::SetMapFields(&message1);\n\n    // This field will test merging into an empty spot.\n    (*message2.mutable_map_int32_int32())[1] = 1;\n    message1.mutable_map_int32_int32()->erase(1);\n\n    // This tests overwriting.\n    (*message2.mutable_map_int32_double())[1] = 1;\n    (*message1.mutable_map_int32_double())[1] = 2;\n\n    message1.MergeFrom(message2);\n    google::protobuf::MapLiteTestUtil::ExpectMapFieldsSet(message1);\n  }\n\n  {\n    // MergeFromMessageMap\n    protobuf_unittest::TestMessageMapLite message1, message2;\n\n    (*message1.mutable_map_int32_message())[0].add_repeated_int32(100);\n    (*message2.mutable_map_int32_message())[0].add_repeated_int32(101);\n\n    message1.MergeFrom(message2);\n\n    // Checks repeated field is overwritten.\n    EXPECT_EQ(1, message1.map_int32_message().at(0).repeated_int32_size());\n    EXPECT_EQ(101, message1.map_int32_message().at(0).repeated_int32(0));\n  }\n\n  {\n    // Test the generated SerializeWithCachedSizesToArray()\n    protobuf_unittest::TestMapLite message1, message2;\n    string data;\n    google::protobuf::MapLiteTestUtil::SetMapFields(&message1);\n    int size = message1.ByteSize();\n    data.resize(size);\n    ::google::protobuf::uint8* start = reinterpret_cast< ::google::protobuf::uint8*>(::google::protobuf::string_as_array(&data));\n    ::google::protobuf::uint8* end = message1.SerializeWithCachedSizesToArray(start);\n    EXPECT_EQ(size, end - start);\n    EXPECT_TRUE(message2.ParseFromString(data));\n    google::protobuf::MapLiteTestUtil::ExpectMapFieldsSet(message2);\n  }\n\n  {\n    // Test the generated SerializeWithCachedSizes()\n    protobuf_unittest::TestMapLite message1, message2;\n    google::protobuf::MapLiteTestUtil::SetMapFields(&message1);\n    int size = message1.ByteSize();\n    string data;\n    data.resize(size);\n    {\n      // Allow the output stream to buffer only one byte at a time.\n      google::protobuf::io::ArrayOutputStream array_stream(\n          ::google::protobuf::string_as_array(&data), size, 1);\n      google::protobuf::io::CodedOutputStream output_stream(&array_stream);\n      message1.SerializeWithCachedSizes(&output_stream);\n      EXPECT_FALSE(output_stream.HadError());\n      EXPECT_EQ(size, output_stream.ByteCount());\n    }\n    EXPECT_TRUE(message2.ParseFromString(data));\n    google::protobuf::MapLiteTestUtil::ExpectMapFieldsSet(message2);\n  }\n\n\n  {\n    // Proto2UnknownEnum\n    protobuf_unittest::TestEnumMapPlusExtraLite from;\n    (*from.mutable_known_map_field())[0] =\n        protobuf_unittest::E_PROTO2_MAP_ENUM_FOO_LITE;\n    (*from.mutable_unknown_map_field())[0] =\n        protobuf_unittest::E_PROTO2_MAP_ENUM_EXTRA_LITE;\n    string data;\n    from.SerializeToString(&data);\n\n    protobuf_unittest::TestEnumMapLite to;\n    EXPECT_TRUE(to.ParseFromString(data));\n    EXPECT_EQ(0, to.unknown_map_field().size());\n    EXPECT_FALSE(to.mutable_unknown_fields()->empty());\n    EXPECT_EQ(1, to.known_map_field().size());\n    EXPECT_EQ(protobuf_unittest::PROTO2_MAP_ENUM_FOO_LITE,\n              to.known_map_field().at(0));\n\n    data.clear();\n    from.Clear();\n    to.SerializeToString(&data);\n    EXPECT_TRUE(from.ParseFromString(data));\n    EXPECT_EQ(1, from.known_map_field().size());\n    EXPECT_EQ(protobuf_unittest::E_PROTO2_MAP_ENUM_FOO_LITE,\n              from.known_map_field().at(0));\n    EXPECT_EQ(1, from.unknown_map_field().size());\n    EXPECT_EQ(protobuf_unittest::E_PROTO2_MAP_ENUM_EXTRA_LITE,\n              from.unknown_map_field().at(0));\n  }\n\n  {\n    // StandardWireFormat\n    protobuf_unittest::TestMapLite message;\n    string data = \"\\x0A\\x04\\x08\\x01\\x10\\x01\";\n\n    EXPECT_TRUE(message.ParseFromString(data));\n    EXPECT_EQ(1, message.map_int32_int32().size());\n    EXPECT_EQ(1, message.map_int32_int32().at(1));\n  }\n\n  {\n    // UnorderedWireFormat\n    protobuf_unittest::TestMapLite message;\n\n    // put value before key in wire format\n    string data = \"\\x0A\\x04\\x10\\x01\\x08\\x02\";\n\n    EXPECT_TRUE(message.ParseFromString(data));\n    EXPECT_EQ(1, message.map_int32_int32().size());\n    EXPECT_EQ(1, message.map_int32_int32().at(2));\n  }\n\n  {\n    // DuplicatedKeyWireFormat\n    protobuf_unittest::TestMapLite message;\n\n    // Two key fields in wire format\n    string data = \"\\x0A\\x06\\x08\\x01\\x08\\x02\\x10\\x01\";\n\n    EXPECT_TRUE(message.ParseFromString(data));\n    EXPECT_EQ(1, message.map_int32_int32().size());\n    EXPECT_EQ(1, message.map_int32_int32().at(2));\n  }\n\n  {\n    // DuplicatedValueWireFormat\n    protobuf_unittest::TestMapLite message;\n\n    // Two value fields in wire format\n    string data = \"\\x0A\\x06\\x08\\x01\\x10\\x01\\x10\\x02\";\n\n    EXPECT_TRUE(message.ParseFromString(data));\n    EXPECT_EQ(1, message.map_int32_int32().size());\n    EXPECT_EQ(2, message.map_int32_int32().at(1));\n  }\n\n  {\n    // MissedKeyWireFormat\n    protobuf_unittest::TestMapLite message;\n\n    // No key field in wire format\n    string data = \"\\x0A\\x02\\x10\\x01\";\n\n    EXPECT_TRUE(message.ParseFromString(data));\n    EXPECT_EQ(1, message.map_int32_int32().size());\n    EXPECT_EQ(1, message.map_int32_int32().at(0));\n  }\n\n  {\n    // MissedValueWireFormat\n    protobuf_unittest::TestMapLite message;\n\n    // No value field in wire format\n    string data = \"\\x0A\\x02\\x08\\x01\";\n\n    EXPECT_TRUE(message.ParseFromString(data));\n    EXPECT_EQ(1, message.map_int32_int32().size());\n    EXPECT_EQ(0, message.map_int32_int32().at(1));\n  }\n\n  {\n    // UnknownFieldWireFormat\n    protobuf_unittest::TestMapLite message;\n\n    // Unknown field in wire format\n    string data = \"\\x0A\\x06\\x08\\x02\\x10\\x03\\x18\\x01\";\n\n    EXPECT_TRUE(message.ParseFromString(data));\n    EXPECT_EQ(1, message.map_int32_int32().size());\n    EXPECT_EQ(3, message.map_int32_int32().at(2));\n  }\n\n  {\n    // CorruptedWireFormat\n    protobuf_unittest::TestMapLite message;\n\n    // corrupted data in wire format\n    string data = \"\\x0A\\x06\\x08\\x02\\x11\\x03\";\n\n    EXPECT_FALSE(message.ParseFromString(data));\n  }\n\n  {\n    // IsInitialized\n    protobuf_unittest::TestRequiredMessageMapLite map_message;\n\n    // Add an uninitialized message.\n    (*map_message.mutable_map_field())[0];\n    EXPECT_FALSE(map_message.IsInitialized());\n\n    // Initialize uninitialized message\n    (*map_message.mutable_map_field())[0].set_a(0);\n    (*map_message.mutable_map_field())[0].set_b(0);\n    (*map_message.mutable_map_field())[0].set_c(0);\n    EXPECT_TRUE(map_message.IsInitialized());\n  }\n\n  {\n      // Check that adding more values to enum does not corrupt message\n      // when passed through an old client.\n      protobuf_unittest::V2MessageLite v2_message;\n      v2_message.set_int_field(800);\n      // Set enum field to the value not understood by the old client.\n      v2_message.set_enum_field(protobuf_unittest::V2_SECOND);\n      string v2_bytes = v2_message.SerializeAsString();\n\n      protobuf_unittest::V1MessageLite v1_message;\n      v1_message.ParseFromString(v2_bytes);\n      EXPECT_TRUE(v1_message.IsInitialized());\n      EXPECT_EQ(v1_message.int_field(), v2_message.int_field());\n      // V1 client does not understand V2_SECOND value, so it discards it and\n      // uses default value instead.\n      EXPECT_EQ(v1_message.enum_field(), protobuf_unittest::V1_FIRST);\n\n      // However, when re-serialized, it should preserve enum value.\n      string v1_bytes = v1_message.SerializeAsString();\n\n      protobuf_unittest::V2MessageLite same_v2_message;\n      same_v2_message.ParseFromString(v1_bytes);\n\n      EXPECT_EQ(v2_message.int_field(), same_v2_message.int_field());\n      EXPECT_EQ(v2_message.enum_field(), same_v2_message.enum_field());\n  }\n\n  std::cout << \"PASS\" << std::endl;\n  return 0;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/map.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_MAP_H__\n#define GOOGLE_PROTOBUF_MAP_H__\n\n#include <google/protobuf/stubs/hash.h>\n#include <iterator>\n#include <limits>  // To support Visual Studio 2008\n#include <set>\n#include <utility>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/arena.h>\n#include <google/protobuf/generated_enum_util.h>\n#include <google/protobuf/map_type_handler.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/descriptor.h>\n#if __cpp_exceptions && LANG_CXX11\n#include <random>\n#endif\n\nnamespace google {\nnamespace protobuf {\n\n// The Map and MapIterator types are provided by this header file.\n// Please avoid using other types defined here, unless they are public\n// types within Map or MapIterator, such as Map::value_type.\ntemplate <typename Key, typename T>\nclass Map;\n\nclass MapIterator;\n\ntemplate <typename Enum> struct is_proto_enum;\n\nnamespace internal {\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType key_wire_type,\n          WireFormatLite::FieldType value_wire_type,\n          int default_enum_value>\nclass MapFieldLite;\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType key_wire_type,\n          WireFormatLite::FieldType value_wire_type,\n          int default_enum_value>\nclass MapField;\n\ntemplate <typename Key, typename T>\nclass TypeDefinedMapFieldBase;\n\nclass DynamicMapField;\n\nclass GeneratedMessageReflection;\n}  // namespace internal\n\n#define TYPE_CHECK(EXPECTEDTYPE, METHOD)                        \\\n  if (type() != EXPECTEDTYPE) {                                 \\\n    GOOGLE_LOG(FATAL)                                                  \\\n        << \"Protocol Buffer map usage error:\\n\"                 \\\n        << METHOD << \" type does not match\\n\"                   \\\n        << \"  Expected : \"                                      \\\n        << FieldDescriptor::CppTypeName(EXPECTEDTYPE) << \"\\n\"   \\\n        << \"  Actual   : \"                                      \\\n        << FieldDescriptor::CppTypeName(type());                \\\n  }\n\n// MapKey is an union type for representing any possible\n// map key.\nclass LIBPROTOBUF_EXPORT MapKey {\n public:\n  MapKey() : type_(0) {\n  }\n  MapKey(const MapKey& other) : type_(0) {\n    CopyFrom(other);\n  }\n\n  ~MapKey() {\n    if (type_ == FieldDescriptor::CPPTYPE_STRING) {\n      delete val_.string_value_;\n    }\n  }\n\n  FieldDescriptor::CppType type() const {\n    if (type_ == 0) {\n      GOOGLE_LOG(FATAL)\n          << \"Protocol Buffer map usage error:\\n\"\n          << \"MapKey::type MapKey is not initialized. \"\n          << \"Call set methods to initialize MapKey.\";\n    }\n    return (FieldDescriptor::CppType)type_;\n  }\n\n  void SetInt64Value(int64 value) {\n    SetType(FieldDescriptor::CPPTYPE_INT64);\n    val_.int64_value_ = value;\n  }\n  void SetUInt64Value(uint64 value) {\n    SetType(FieldDescriptor::CPPTYPE_UINT64);\n    val_.uint64_value_ = value;\n  }\n  void SetInt32Value(int32 value) {\n    SetType(FieldDescriptor::CPPTYPE_INT32);\n    val_.int32_value_ = value;\n  }\n  void SetUInt32Value(uint32 value) {\n    SetType(FieldDescriptor::CPPTYPE_UINT32);\n    val_.uint32_value_ = value;\n  }\n  void SetBoolValue(bool value) {\n    SetType(FieldDescriptor::CPPTYPE_BOOL);\n    val_.bool_value_ = value;\n  }\n  void SetStringValue(const string& val) {\n    SetType(FieldDescriptor::CPPTYPE_STRING);\n    *val_.string_value_ = val;\n  }\n\n  int64 GetInt64Value() const {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_INT64,\n               \"MapKey::GetInt64Value\");\n    return val_.int64_value_;\n  }\n  uint64 GetUInt64Value() const {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_UINT64,\n               \"MapKey::GetUInt64Value\");\n    return val_.uint64_value_;\n  }\n  int32 GetInt32Value() const {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_INT32,\n               \"MapKey::GetInt32Value\");\n    return val_.int32_value_;\n  }\n  uint32 GetUInt32Value() const {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_UINT32,\n               \"MapKey::GetUInt32Value\");\n    return val_.uint32_value_;\n  }\n  bool GetBoolValue() const {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_BOOL,\n               \"MapKey::GetBoolValue\");\n    return val_.bool_value_;\n  }\n  const string& GetStringValue() const {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_STRING,\n               \"MapKey::GetStringValue\");\n    return *val_.string_value_;\n  }\n\n  bool operator<(const MapKey& other) const {\n    if (type_ != other.type_) {\n      // We could define a total order that handles this case, but\n      // there currently no need.  So, for now, fail.\n      GOOGLE_LOG(FATAL) << \"Unsupported: type mismatch\";\n    }\n    switch (type()) {\n      case FieldDescriptor::CPPTYPE_DOUBLE:\n      case FieldDescriptor::CPPTYPE_FLOAT:\n      case FieldDescriptor::CPPTYPE_ENUM:\n      case FieldDescriptor::CPPTYPE_MESSAGE:\n        GOOGLE_LOG(FATAL) << \"Unsupported\";\n        return false;\n      case FieldDescriptor::CPPTYPE_STRING:\n        return *val_.string_value_ < *other.val_.string_value_;\n      case FieldDescriptor::CPPTYPE_INT64:\n        return val_.int64_value_ < other.val_.int64_value_;\n      case FieldDescriptor::CPPTYPE_INT32:\n        return val_.int32_value_ < other.val_.int32_value_;\n      case FieldDescriptor::CPPTYPE_UINT64:\n        return val_.uint64_value_ < other.val_.uint64_value_;\n      case FieldDescriptor::CPPTYPE_UINT32:\n        return val_.uint32_value_ < other.val_.uint32_value_;\n      case FieldDescriptor::CPPTYPE_BOOL:\n        return val_.bool_value_ < other.val_.bool_value_;\n    }\n    return false;\n  }\n\n  bool operator==(const MapKey& other) const {\n    if (type_ != other.type_) {\n      // To be consistent with operator<, we don't allow this either.\n      GOOGLE_LOG(FATAL) << \"Unsupported: type mismatch\";\n    }\n    switch (type()) {\n      case FieldDescriptor::CPPTYPE_DOUBLE:\n      case FieldDescriptor::CPPTYPE_FLOAT:\n      case FieldDescriptor::CPPTYPE_ENUM:\n      case FieldDescriptor::CPPTYPE_MESSAGE:\n        GOOGLE_LOG(FATAL) << \"Unsupported\";\n        break;\n      case FieldDescriptor::CPPTYPE_STRING:\n        return *val_.string_value_ == *other.val_.string_value_;\n      case FieldDescriptor::CPPTYPE_INT64:\n        return val_.int64_value_ == other.val_.int64_value_;\n      case FieldDescriptor::CPPTYPE_INT32:\n        return val_.int32_value_ == other.val_.int32_value_;\n      case FieldDescriptor::CPPTYPE_UINT64:\n        return val_.uint64_value_ == other.val_.uint64_value_;\n      case FieldDescriptor::CPPTYPE_UINT32:\n        return val_.uint32_value_ == other.val_.uint32_value_;\n      case FieldDescriptor::CPPTYPE_BOOL:\n        return val_.bool_value_ == other.val_.bool_value_;\n    }\n    GOOGLE_LOG(FATAL) << \"Can't get here.\";\n    return false;\n  }\n\n  void CopyFrom(const MapKey& other) {\n    SetType(other.type());\n    switch (type_) {\n      case FieldDescriptor::CPPTYPE_DOUBLE:\n      case FieldDescriptor::CPPTYPE_FLOAT:\n      case FieldDescriptor::CPPTYPE_ENUM:\n      case FieldDescriptor::CPPTYPE_MESSAGE:\n        GOOGLE_LOG(FATAL) << \"Unsupported\";\n        break;\n      case FieldDescriptor::CPPTYPE_STRING:\n        *val_.string_value_ = *other.val_.string_value_;\n        break;\n      case FieldDescriptor::CPPTYPE_INT64:\n        val_.int64_value_ = other.val_.int64_value_;\n        break;\n      case FieldDescriptor::CPPTYPE_INT32:\n        val_.int32_value_ = other.val_.int32_value_;\n        break;\n      case FieldDescriptor::CPPTYPE_UINT64:\n        val_.uint64_value_ = other.val_.uint64_value_;\n        break;\n      case FieldDescriptor::CPPTYPE_UINT32:\n        val_.uint32_value_ = other.val_.uint32_value_;\n        break;\n      case FieldDescriptor::CPPTYPE_BOOL:\n        val_.bool_value_ = other.val_.bool_value_;\n        break;\n    }\n  }\n\n private:\n  template <typename K, typename V>\n  friend class internal::TypeDefinedMapFieldBase;\n  friend class MapIterator;\n  friend class internal::DynamicMapField;\n\n  union KeyValue {\n    KeyValue() {}\n    string* string_value_;\n    int64 int64_value_;\n    int32 int32_value_;\n    uint64 uint64_value_;\n    uint32 uint32_value_;\n    bool bool_value_;\n  } val_;\n\n  void SetType(FieldDescriptor::CppType type) {\n    if (type_ == type) return;\n    if (type_ == FieldDescriptor::CPPTYPE_STRING) {\n      delete val_.string_value_;\n    }\n    type_ = type;\n    if (type_ == FieldDescriptor::CPPTYPE_STRING) {\n      val_.string_value_ = new string;\n    }\n  }\n\n  // type_ is 0 or a valid FieldDescriptor::CppType.\n  int type_;\n};\n\n// MapValueRef points to a map value.\nclass LIBPROTOBUF_EXPORT MapValueRef {\n public:\n  MapValueRef() : data_(NULL), type_(0) {}\n\n  void SetInt64Value(int64 value) {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_INT64,\n               \"MapValueRef::SetInt64Value\");\n    *reinterpret_cast<int64*>(data_) = value;\n  }\n  void SetUInt64Value(uint64 value) {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_UINT64,\n               \"MapValueRef::SetUInt64Value\");\n    *reinterpret_cast<uint64*>(data_) = value;\n  }\n  void SetInt32Value(int32 value) {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_INT32,\n               \"MapValueRef::SetInt32Value\");\n    *reinterpret_cast<int32*>(data_) = value;\n  }\n  void SetUInt32Value(uint32 value) {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_UINT32,\n               \"MapValueRef::SetUInt32Value\");\n    *reinterpret_cast<uint32*>(data_) = value;\n  }\n  void SetBoolValue(bool value) {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_BOOL,\n               \"MapValueRef::SetBoolValue\");\n    *reinterpret_cast<bool*>(data_) = value;\n  }\n  // TODO(jieluo) - Checks that enum is member.\n  void SetEnumValue(int value) {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_ENUM,\n               \"MapValueRef::SetEnumValue\");\n    *reinterpret_cast<int*>(data_) = value;\n  }\n  void SetStringValue(const string& value) {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_STRING,\n               \"MapValueRef::SetStringValue\");\n    *reinterpret_cast<string*>(data_) = value;\n  }\n  void SetFloatValue(float value) {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_FLOAT,\n               \"MapValueRef::SetFloatValue\");\n    *reinterpret_cast<float*>(data_) = value;\n  }\n  void SetDoubleValue(double value) {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_DOUBLE,\n               \"MapValueRef::SetDoubleValue\");\n    *reinterpret_cast<double*>(data_) = value;\n  }\n\n  int64 GetInt64Value() const {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_INT64,\n               \"MapValueRef::GetInt64Value\");\n    return *reinterpret_cast<int64*>(data_);\n  }\n  uint64 GetUInt64Value() const {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_UINT64,\n               \"MapValueRef::GetUInt64Value\");\n    return *reinterpret_cast<uint64*>(data_);\n  }\n  int32 GetInt32Value() const {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_INT32,\n               \"MapValueRef::GetInt32Value\");\n    return *reinterpret_cast<int32*>(data_);\n  }\n  uint32 GetUInt32Value() const {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_UINT32,\n               \"MapValueRef::GetUInt32Value\");\n    return *reinterpret_cast<uint32*>(data_);\n  }\n  bool GetBoolValue() const {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_BOOL,\n               \"MapValueRef::GetBoolValue\");\n    return *reinterpret_cast<bool*>(data_);\n  }\n  int GetEnumValue() const {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_ENUM,\n               \"MapValueRef::GetEnumValue\");\n    return *reinterpret_cast<int*>(data_);\n  }\n  const string& GetStringValue() const {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_STRING,\n               \"MapValueRef::GetStringValue\");\n    return *reinterpret_cast<string*>(data_);\n  }\n  float GetFloatValue() const {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_FLOAT,\n               \"MapValueRef::GetFloatValue\");\n    return *reinterpret_cast<float*>(data_);\n  }\n  double GetDoubleValue() const {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_DOUBLE,\n               \"MapValueRef::GetDoubleValue\");\n    return *reinterpret_cast<double*>(data_);\n  }\n\n  const Message& GetMessageValue() const {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_MESSAGE,\n               \"MapValueRef::GetMessageValue\");\n    return *reinterpret_cast<Message*>(data_);\n  }\n\n  Message* MutableMessageValue() {\n    TYPE_CHECK(FieldDescriptor::CPPTYPE_MESSAGE,\n               \"MapValueRef::MutableMessageValue\");\n    return reinterpret_cast<Message*>(data_);\n  }\n\n private:\n  template <typename K, typename V,\n            internal::WireFormatLite::FieldType key_wire_type,\n            internal::WireFormatLite::FieldType value_wire_type,\n            int default_enum_value>\n  friend class internal::MapField;\n  template <typename K, typename V>\n  friend class internal::TypeDefinedMapFieldBase;\n  friend class MapIterator;\n  friend class internal::GeneratedMessageReflection;\n  friend class internal::DynamicMapField;\n\n  void SetType(FieldDescriptor::CppType type) {\n    type_ = type;\n  }\n\n  FieldDescriptor::CppType type() const {\n    if (type_ == 0 || data_ == NULL) {\n      GOOGLE_LOG(FATAL)\n          << \"Protocol Buffer map usage error:\\n\"\n          << \"MapValueRef::type MapValueRef is not initialized.\";\n    }\n    return (FieldDescriptor::CppType)type_;\n  }\n  void SetValue(const void* val) {\n    data_ = const_cast<void*>(val);\n  }\n  void CopyFrom(const MapValueRef& other) {\n    type_ = other.type_;\n    data_ = other.data_;\n  }\n  // Only used in DynamicMapField\n  void DeleteData() {\n    switch (type_) {\n#define HANDLE_TYPE(CPPTYPE, TYPE)                              \\\n      case google::protobuf::FieldDescriptor::CPPTYPE_##CPPTYPE: {        \\\n        delete reinterpret_cast<TYPE*>(data_);                  \\\n        break;                                                  \\\n      }\n      HANDLE_TYPE(INT32, int32);\n      HANDLE_TYPE(INT64, int64);\n      HANDLE_TYPE(UINT32, uint32);\n      HANDLE_TYPE(UINT64, uint64);\n      HANDLE_TYPE(DOUBLE, double);\n      HANDLE_TYPE(FLOAT, float);\n      HANDLE_TYPE(BOOL, bool);\n      HANDLE_TYPE(STRING, string);\n      HANDLE_TYPE(ENUM, int32);\n      HANDLE_TYPE(MESSAGE, Message);\n#undef HANDLE_TYPE\n    }\n  }\n  // data_ point to a map value. MapValueRef does not\n  // own this value.\n  void* data_;\n  // type_ is 0 or a valid FieldDescriptor::CppType.\n  int type_;\n};\n\n#undef TYPE_CHECK\n\n// This is the class for google::protobuf::Map's internal value_type. Instead of using\n// std::pair as value_type, we use this class which provides us more control of\n// its process of construction and destruction.\ntemplate <typename Key, typename T>\nclass MapPair {\n public:\n  typedef const Key first_type;\n  typedef T second_type;\n\n  MapPair(const Key& other_first, const T& other_second)\n      : first(other_first), second(other_second) {}\n  explicit MapPair(const Key& other_first) : first(other_first), second() {}\n  MapPair(const MapPair& other)\n      : first(other.first), second(other.second) {}\n\n  ~MapPair() {}\n\n  // Implicitly convertible to std::pair of compatible types.\n  template <typename T1, typename T2>\n  operator std::pair<T1, T2>() const {\n    return std::pair<T1, T2>(first, second);\n  }\n\n  const Key first;\n  T second;\n\n private:\n  friend class ::google::protobuf::Arena;\n  friend class Map<Key, T>;\n};\n\n// google::protobuf::Map is an associative container type used to store protobuf map\n// fields.  Each Map instance may or may not use a different hash function, a\n// different iteration order, and so on.  E.g., please don't examine\n// implementation details to decide if the following would work:\n//  Map<int, int> m0, m1;\n//  m0[0] = m1[0] = m0[1] = m1[1] = 0;\n//  assert(m0.begin()->first == m1.begin()->first);  // Bug!\n//\n// Map's interface is similar to std::unordered_map, except that Map is not\n// designed to play well with exceptions.\ntemplate <typename Key, typename T>\nclass Map {\n public:\n  typedef Key key_type;\n  typedef T mapped_type;\n  typedef MapPair<Key, T> value_type;\n\n  typedef value_type* pointer;\n  typedef const value_type* const_pointer;\n  typedef value_type& reference;\n  typedef const value_type& const_reference;\n\n  typedef size_t size_type;\n  typedef hash<Key> hasher;\n\n  explicit Map(bool old_style = true)\n      : arena_(NULL),\n        default_enum_value_(0),\n        old_style_(old_style) {\n    Init();\n  }\n  explicit Map(Arena* arena, bool old_style = true)\n      : arena_(arena),\n        default_enum_value_(0),\n        old_style_(old_style) {\n    Init();\n  }\n  Map(const Map& other)\n      : arena_(NULL),\n        default_enum_value_(other.default_enum_value_),\n        old_style_(other.old_style_) {\n    Init();\n    insert(other.begin(), other.end());\n  }\n  template <class InputIt>\n  Map(const InputIt& first, const InputIt& last, bool old_style = true)\n      : arena_(NULL),\n        default_enum_value_(0),\n        old_style_(old_style) {\n    Init();\n    insert(first, last);\n  }\n\n  ~Map() {\n    clear();\n    if (arena_ == NULL) {\n      if (old_style_)\n        delete deprecated_elements_;\n      else\n        delete elements_;\n    }\n  }\n\n private:\n  void Init() {\n    if (old_style_)\n      deprecated_elements_ = Arena::Create<DeprecatedInnerMap>(\n          arena_, 0, hasher(), equal_to<Key>(),\n          MapAllocator<std::pair<const Key, MapPair<Key, T>*> >(arena_));\n    else\n      elements_ =\n          Arena::Create<InnerMap>(arena_, 0, hasher(), Allocator(arena_));\n  }\n\n  // re-implement std::allocator to use arena allocator for memory allocation.\n  // Used for google::protobuf::Map implementation. Users should not use this class\n  // directly.\n  template <typename U>\n  class MapAllocator {\n   public:\n    typedef U value_type;\n    typedef value_type* pointer;\n    typedef const value_type* const_pointer;\n    typedef value_type& reference;\n    typedef const value_type& const_reference;\n    typedef size_t size_type;\n    typedef ptrdiff_t difference_type;\n\n    MapAllocator() : arena_(NULL) {}\n    explicit MapAllocator(Arena* arena) : arena_(arena) {}\n    template <typename X>\n    MapAllocator(const MapAllocator<X>& allocator)\n        : arena_(allocator.arena()) {}\n\n    pointer allocate(size_type n, const_pointer hint = 0) {\n      // If arena is not given, malloc needs to be called which doesn't\n      // construct element object.\n      if (arena_ == NULL) {\n        return reinterpret_cast<pointer>(malloc(n * sizeof(value_type)));\n      } else {\n        return reinterpret_cast<pointer>(\n            Arena::CreateArray<uint8>(arena_, n * sizeof(value_type)));\n      }\n    }\n\n    void deallocate(pointer p, size_type n) {\n      if (arena_ == NULL) {\n        free(p);\n      }\n    }\n\n#if __cplusplus >= 201103L && !defined(GOOGLE_PROTOBUF_OS_APPLE) && \\\n    !defined(GOOGLE_PROTOBUF_OS_NACL) &&                            \\\n    !defined(GOOGLE_PROTOBUF_OS_ANDROID) &&                         \\\n    !defined(GOOGLE_PROTOBUF_OS_EMSCRIPTEN)\n    template<class NodeType, class... Args>\n    void construct(NodeType* p, Args&&... args) {\n      // Clang 3.6 doesn't compile static casting to void* directly. (Issue\n      // #1266) According C++ standard 5.2.9/1: \"The static_cast operator shall\n      // not cast away constness\". So first the maybe const pointer is casted to\n      // const void* and after the const void* is const casted.\n      new (const_cast<void*>(static_cast<const void*>(p)))\n          NodeType(std::forward<Args>(args)...);\n    }\n\n    template<class NodeType>\n    void destroy(NodeType* p) {\n      p->~NodeType();\n    }\n#else\n    void construct(pointer p, const_reference t) { new (p) value_type(t); }\n\n    void destroy(pointer p) { p->~value_type(); }\n#endif\n\n    template <typename X>\n    struct rebind {\n      typedef MapAllocator<X> other;\n    };\n\n    template <typename X>\n    bool operator==(const MapAllocator<X>& other) const {\n      return arena_ == other.arena_;\n    }\n\n    template <typename X>\n    bool operator!=(const MapAllocator<X>& other) const {\n      return arena_ != other.arena_;\n    }\n\n    // To support Visual Studio 2008\n    size_type max_size() const {\n      return std::numeric_limits<size_type>::max();\n    }\n\n    // To support gcc-4.4, which does not properly\n    // support templated friend classes\n    Arena* arena() const {\n      return arena_;\n    }\n\n   private:\n    typedef void DestructorSkippable_;\n    Arena* const arena_;\n  };\n\n  // InnerMap's key type is Key and its value type is value_type*.  We use a\n  // custom class here and for Node, below, to ensure that k_ is at offset 0,\n  // allowing safe conversion from pointer to Node to pointer to Key, and vice\n  // versa when appropriate.\n  class KeyValuePair {\n   public:\n    KeyValuePair(const Key& k, value_type* v) : k_(k), v_(v) {}\n\n    const Key& key() const { return k_; }\n    Key& key() { return k_; }\n    value_type* const value() const { return v_; }\n    value_type*& value() { return v_; }\n\n   private:\n    Key k_;\n    value_type* v_;\n  };\n\n  typedef MapAllocator<KeyValuePair> Allocator;\n\n  // InnerMap is a generic hash-based map.  It doesn't contain any\n  // protocol-buffer-specific logic.  It is a chaining hash map with the\n  // additional feature that some buckets can be converted to use an ordered\n  // container.  This ensures O(lg n) bounds on find, insert, and erase, while\n  // avoiding the overheads of ordered containers most of the time.\n  //\n  // The implementation doesn't need the full generality of unordered_map,\n  // and it doesn't have it.  More bells and whistles can be added as needed.\n  // Some implementation details:\n  // 1. The hash function has type hasher and the equality function\n  //    equal_to<Key>.  We inherit from hasher to save space\n  //    (empty-base-class optimization).\n  // 2. The number of buckets is a power of two.\n  // 3. Buckets are converted to trees in pairs: if we convert bucket b then\n  //    buckets b and b^1 will share a tree.  Invariant: buckets b and b^1 have\n  //    the same non-NULL value iff they are sharing a tree.  (An alternative\n  //    implementation strategy would be to have a tag bit per bucket.)\n  // 4. As is typical for hash_map and such, the Keys and Values are always\n  //    stored in linked list nodes.  Pointers to elements are never invalidated\n  //    until the element is deleted.\n  // 5. The trees' payload type is pointer to linked-list node.  Tree-converting\n  //    a bucket doesn't copy Key-Value pairs.\n  // 6. Once we've tree-converted a bucket, it is never converted back. However,\n  //    the items a tree contains may wind up assigned to trees or lists upon a\n  //    rehash.\n  // 7. The code requires no C++ features from C++11 or later.\n  // 8. Mutations to a map do not invalidate the map's iterators, pointers to\n  //    elements, or references to elements.\n  // 9. Except for erase(iterator), any non-const method can reorder iterators.\n  class InnerMap : private hasher {\n   public:\n    typedef value_type* Value;\n\n    InnerMap(size_type n, hasher h, Allocator alloc)\n        : hasher(h),\n          num_elements_(0),\n          seed_(Seed()),\n          table_(NULL),\n          alloc_(alloc) {\n      n = TableSize(n);\n      table_ = CreateEmptyTable(n);\n      num_buckets_ = index_of_first_non_null_ = n;\n    }\n\n    ~InnerMap() {\n      if (table_ != NULL) {\n        clear();\n        Dealloc<void*>(table_, num_buckets_);\n      }\n    }\n\n   private:\n    enum { kMinTableSize = 8 };\n\n    // Linked-list nodes, as one would expect for a chaining hash table.\n    struct Node {\n      KeyValuePair kv;\n      Node* next;\n    };\n\n    // This is safe only if the given pointer is known to point to a Key that is\n    // part of a Node.\n    static Node* NodePtrFromKeyPtr(Key* k) {\n      return reinterpret_cast<Node*>(k);\n    }\n\n    static Key* KeyPtrFromNodePtr(Node* node) { return &node->kv.key(); }\n\n    // Trees.  The payload type is pointer to Key, so that we can query the tree\n    // with Keys that are not in any particular data structure.  When we insert,\n    // though, the pointer is always pointing to a Key that is inside a Node.\n    struct KeyCompare {\n      bool operator()(const Key* n0, const Key* n1) const { return *n0 < *n1; }\n    };\n    typedef typename Allocator::template rebind<Key*>::other KeyPtrAllocator;\n    typedef std::set<Key*, KeyCompare, KeyPtrAllocator> Tree;\n\n    // iterator and const_iterator are instantiations of iterator_base.\n    template <typename KeyValueType>\n    class iterator_base {\n     public:\n      typedef KeyValueType& reference;\n      typedef KeyValueType* pointer;\n      typedef typename Tree::iterator TreeIterator;\n\n      // Invariants:\n      // node_ is always correct. This is handy because the most common\n      // operations are operator* and operator-> and they only use node_.\n      // When node_ is set to a non-NULL value, all the other non-const fields\n      // are updated to be correct also, but those fields can become stale\n      // if the underlying map is modified.  When those fields are needed they\n      // are rechecked, and updated if necessary.\n      iterator_base() : node_(NULL) {}\n\n      explicit iterator_base(const InnerMap* m) : m_(m) {\n        SearchFrom(m->index_of_first_non_null_);\n      }\n\n      // Any iterator_base can convert to any other.  This is overkill, and we\n      // rely on the enclosing class to use it wisely.  The standard \"iterator\n      // can convert to const_iterator\" is OK but the reverse direction is not.\n      template <typename U>\n      explicit iterator_base(const iterator_base<U>& it)\n          : node_(it.node_),\n            m_(it.m_),\n            bucket_index_(it.bucket_index_),\n            tree_it_(it.tree_it_) {}\n\n      iterator_base(Node* n, const InnerMap* m, size_type index)\n          : node_(n),\n            m_(m),\n            bucket_index_(index) {}\n\n      iterator_base(TreeIterator tree_it, const InnerMap* m, size_type index)\n          : node_(NodePtrFromKeyPtr(*tree_it)),\n            m_(m),\n            bucket_index_(index),\n            tree_it_(tree_it) {\n        // Invariant: iterators that use tree_it_ have an even bucket_index_.\n        GOOGLE_DCHECK_EQ(bucket_index_ % 2, 0);\n      }\n\n      // Advance through buckets, looking for the first that isn't empty.\n      // If nothing non-empty is found then leave node_ == NULL.\n      void SearchFrom(size_type start_bucket) {\n        GOOGLE_DCHECK(m_->index_of_first_non_null_ == m_->num_buckets_ ||\n               m_->table_[m_->index_of_first_non_null_] != NULL);\n        node_ = NULL;\n        for (bucket_index_ = start_bucket; bucket_index_ < m_->num_buckets_;\n             bucket_index_++) {\n          if (m_->TableEntryIsNonEmptyList(bucket_index_)) {\n            node_ = static_cast<Node*>(m_->table_[bucket_index_]);\n            break;\n          } else if (m_->TableEntryIsTree(bucket_index_)) {\n            Tree* tree = static_cast<Tree*>(m_->table_[bucket_index_]);\n            GOOGLE_DCHECK(!tree->empty());\n            tree_it_ = tree->begin();\n            node_ = NodePtrFromKeyPtr(*tree_it_);\n            break;\n          }\n        }\n      }\n\n      reference operator*() const { return node_->kv; }\n      pointer operator->() const { return &(operator*()); }\n\n      friend bool operator==(const iterator_base& a, const iterator_base& b) {\n        return a.node_ == b.node_;\n      }\n      friend bool operator!=(const iterator_base& a, const iterator_base& b) {\n        return a.node_ != b.node_;\n      }\n\n      iterator_base& operator++() {\n        if (node_->next == NULL) {\n          const bool is_list = revalidate_if_necessary();\n          if (is_list) {\n            SearchFrom(bucket_index_ + 1);\n          } else {\n            GOOGLE_DCHECK_EQ(bucket_index_ & 1, 0);\n            Tree* tree = static_cast<Tree*>(m_->table_[bucket_index_]);\n            if (++tree_it_ == tree->end()) {\n              SearchFrom(bucket_index_ + 2);\n            } else {\n              node_ = NodePtrFromKeyPtr(*tree_it_);\n            }\n          }\n        } else {\n          node_ = node_->next;\n        }\n        return *this;\n      }\n\n      iterator_base operator++(int /* unused */) {\n        iterator_base tmp = *this;\n        ++*this;\n        return tmp;\n      }\n\n      // Assumes node_ and m_ are correct and non-NULL, but other fields may be\n      // stale.  Fix them as needed.  Then return true iff node_ points to a\n      // Node in a list.\n      bool revalidate_if_necessary() {\n        GOOGLE_DCHECK(node_ != NULL && m_ != NULL);\n        // Force bucket_index_ to be in range.\n        bucket_index_ &= (m_->num_buckets_ - 1);\n        // Common case: the bucket we think is relevant points to node_.\n        if (m_->table_[bucket_index_] == static_cast<void*>(node_))\n          return true;\n        // Less common: the bucket is a linked list with node_ somewhere in it,\n        // but not at the head.\n        if (m_->TableEntryIsNonEmptyList(bucket_index_)) {\n          Node* l = static_cast<Node*>(m_->table_[bucket_index_]);\n          while ((l = l->next) != NULL) {\n            if (l == node_) {\n              return true;\n            }\n          }\n        }\n        // Well, bucket_index_ still might be correct, but probably\n        // not.  Revalidate just to be sure.  This case is rare enough that we\n        // don't worry about potential optimizations, such as having a custom\n        // find-like method that compares Node* instead of const Key&.\n        iterator_base i(m_->find(*KeyPtrFromNodePtr(node_)));\n        bucket_index_ = i.bucket_index_;\n        tree_it_ = i.tree_it_;\n        return m_->TableEntryIsList(bucket_index_);\n      }\n\n      Node* node_;\n      const InnerMap* m_;\n      size_type bucket_index_;\n      TreeIterator tree_it_;\n    };\n\n   public:\n    typedef iterator_base<KeyValuePair> iterator;\n    typedef iterator_base<const KeyValuePair> const_iterator;\n\n    iterator begin() { return iterator(this); }\n    iterator end() { return iterator(); }\n    const_iterator begin() const { return const_iterator(this); }\n    const_iterator end() const { return const_iterator(); }\n\n    void clear() {\n      for (size_type b = 0; b < num_buckets_; b++) {\n        if (TableEntryIsNonEmptyList(b)) {\n          Node* node = static_cast<Node*>(table_[b]);\n          table_[b] = NULL;\n          do {\n            Node* next = node->next;\n            DestroyNode(node);\n            node = next;\n          } while (node != NULL);\n        } else if (TableEntryIsTree(b)) {\n          Tree* tree = static_cast<Tree*>(table_[b]);\n          GOOGLE_DCHECK(table_[b] == table_[b + 1] && (b & 1) == 0);\n          table_[b] = table_[b + 1] = NULL;\n          typename Tree::iterator tree_it = tree->begin();\n          do {\n            Node* node = NodePtrFromKeyPtr(*tree_it);\n            typename Tree::iterator next = tree_it;\n            ++next;\n            tree->erase(tree_it);\n            DestroyNode(node);\n            tree_it = next;\n          } while (tree_it != tree->end());\n          DestroyTree(tree);\n          b++;\n        }\n      }\n      num_elements_ = 0;\n      index_of_first_non_null_ = num_buckets_;\n    }\n\n    const hasher& hash_function() const { return *this; }\n\n    static size_type max_size() {\n      return static_cast<size_type>(1) << (sizeof(void**) >= 8 ? 60 : 28);\n    }\n    size_type size() const { return num_elements_; }\n    bool empty() const { return size() == 0; }\n\n    iterator find(const Key& k) { return iterator(FindHelper(k).first); }\n    const_iterator find(const Key& k) const { return FindHelper(k).first; }\n\n    // In traditional C++ style, this performs \"insert if not present.\"\n    std::pair<iterator, bool> insert(const KeyValuePair& kv) {\n      std::pair<const_iterator, size_type> p = FindHelper(kv.key());\n      // Case 1: key was already present.\n      if (p.first.node_ != NULL)\n        return std::make_pair(iterator(p.first), false);\n      // Case 2: insert.\n      if (ResizeIfLoadIsOutOfRange(num_elements_ + 1)) {\n        p = FindHelper(kv.key());\n      }\n      const size_type b = p.second;  // bucket number\n      Node* node = Alloc<Node>(1);\n      alloc_.construct(&node->kv, kv);\n      iterator result = InsertUnique(b, node);\n      ++num_elements_;\n      return std::make_pair(result, true);\n    }\n\n    // The same, but if an insertion is necessary then the value portion of the\n    // inserted key-value pair is left uninitialized.\n    std::pair<iterator, bool> insert(const Key& k) {\n      std::pair<const_iterator, size_type> p = FindHelper(k);\n      // Case 1: key was already present.\n      if (p.first.node_ != NULL)\n        return std::make_pair(iterator(p.first), false);\n      // Case 2: insert.\n      if (ResizeIfLoadIsOutOfRange(num_elements_ + 1)) {\n        p = FindHelper(k);\n      }\n      const size_type b = p.second;  // bucket number\n      Node* node = Alloc<Node>(1);\n      typedef typename Allocator::template rebind<Key>::other KeyAllocator;\n      KeyAllocator(alloc_).construct(&node->kv.key(), k);\n      iterator result = InsertUnique(b, node);\n      ++num_elements_;\n      return std::make_pair(result, true);\n    }\n\n    Value& operator[](const Key& k) {\n      KeyValuePair kv(k, Value());\n      return insert(kv).first->value();\n    }\n\n    void erase(iterator it) {\n      GOOGLE_DCHECK_EQ(it.m_, this);\n      const bool is_list = it.revalidate_if_necessary();\n      size_type b = it.bucket_index_;\n      Node* const item = it.node_;\n      if (is_list) {\n        GOOGLE_DCHECK(TableEntryIsNonEmptyList(b));\n        Node* head = static_cast<Node*>(table_[b]);\n        head = EraseFromLinkedList(item, head);\n        table_[b] = static_cast<void*>(head);\n      } else {\n        GOOGLE_DCHECK(TableEntryIsTree(b));\n        Tree* tree = static_cast<Tree*>(table_[b]);\n        tree->erase(it.tree_it_);\n        if (tree->empty()) {\n          // Force b to be the minimum of b and b ^ 1.  This is important\n          // only because we want index_of_first_non_null_ to be correct.\n          b &= ~static_cast<size_type>(1);\n          DestroyTree(tree);\n          table_[b] = table_[b + 1] = NULL;\n        }\n      }\n      DestroyNode(item);\n      --num_elements_;\n      if (GOOGLE_PREDICT_FALSE(b == index_of_first_non_null_)) {\n        while (index_of_first_non_null_ < num_buckets_ &&\n               table_[index_of_first_non_null_] == NULL) {\n          ++index_of_first_non_null_;\n        }\n      }\n    }\n\n   private:\n    std::pair<const_iterator, size_type> FindHelper(const Key& k) const {\n      size_type b = BucketNumber(k);\n      if (TableEntryIsNonEmptyList(b)) {\n        Node* node = static_cast<Node*>(table_[b]);\n        do {\n          if (IsMatch(*KeyPtrFromNodePtr(node), k)) {\n            return std::make_pair(const_iterator(node, this, b), b);\n          } else {\n            node = node->next;\n          }\n        } while (node != NULL);\n      } else if (TableEntryIsTree(b)) {\n        GOOGLE_DCHECK_EQ(table_[b], table_[b ^ 1]);\n        b &= ~static_cast<size_t>(1);\n        Tree* tree = static_cast<Tree*>(table_[b]);\n        Key* key = const_cast<Key*>(&k);\n        typename Tree::iterator tree_it = tree->find(key);\n        if (tree_it != tree->end()) {\n          return std::make_pair(const_iterator(tree_it, this, b), b);\n        }\n      }\n      return std::make_pair(end(), b);\n    }\n\n    // Insert the given Node in bucket b.  If that would make bucket b too big,\n    // and bucket b is not a tree, create a tree for buckets b and b^1 to share.\n    // Requires count(*KeyPtrFromNodePtr(node)) == 0 and that b is the correct\n    // bucket.  num_elements_ is not modified.\n    iterator InsertUnique(size_type b, Node* node) {\n      GOOGLE_DCHECK(index_of_first_non_null_ == num_buckets_ ||\n             table_[index_of_first_non_null_] != NULL);\n      // In practice, the code that led to this point may have already\n      // determined whether we are inserting into an empty list, a short list,\n      // or whatever.  But it's probably cheap enough to recompute that here;\n      // it's likely that we're inserting into an empty or short list.\n      iterator result;\n      GOOGLE_DCHECK(find(*KeyPtrFromNodePtr(node)) == end());\n      if (TableEntryIsEmpty(b)) {\n        result = InsertUniqueInList(b, node);\n      } else if (TableEntryIsNonEmptyList(b)) {\n        if (GOOGLE_PREDICT_FALSE(TableEntryIsTooLong(b))) {\n          TreeConvert(b);\n          result = InsertUniqueInTree(b, node);\n          GOOGLE_DCHECK_EQ(result.bucket_index_, b & ~static_cast<size_type>(1));\n        } else {\n          // Insert into a pre-existing list.  This case cannot modify\n          // index_of_first_non_null_, so we skip the code to update it.\n          return InsertUniqueInList(b, node);\n        }\n      } else {\n        // Insert into a pre-existing tree.  This case cannot modify\n        // index_of_first_non_null_, so we skip the code to update it.\n        return InsertUniqueInTree(b, node);\n      }\n      index_of_first_non_null_ =\n          std::min(index_of_first_non_null_, result.bucket_index_);\n      return result;\n    }\n\n    // Helper for InsertUnique.  Handles the case where bucket b is a\n    // not-too-long linked list.\n    iterator InsertUniqueInList(size_type b, Node* node) {\n      node->next = static_cast<Node*>(table_[b]);\n      table_[b] = static_cast<void*>(node);\n      return iterator(node, this, b);\n    }\n\n    // Helper for InsertUnique.  Handles the case where bucket b points to a\n    // Tree.\n    iterator InsertUniqueInTree(size_type b, Node* node) {\n      GOOGLE_DCHECK_EQ(table_[b], table_[b ^ 1]);\n      // Maintain the invariant that node->next is NULL for all Nodes in Trees.\n      node->next = NULL;\n      return iterator(static_cast<Tree*>(table_[b])\n                      ->insert(KeyPtrFromNodePtr(node))\n                      .first,\n                      this, b & ~static_cast<size_t>(1));\n    }\n\n    // Returns whether it did resize.  Currently this is only used when\n    // num_elements_ increases, though it could be used in other situations.\n    // It checks for load too low as well as load too high: because any number\n    // of erases can occur between inserts, the load could be as low as 0 here.\n    // Resizing to a lower size is not always helpful, but failing to do so can\n    // destroy the expected big-O bounds for some operations. By having the\n    // policy that sometimes we resize down as well as up, clients can easily\n    // keep O(size()) = O(number of buckets) if they want that.\n    bool ResizeIfLoadIsOutOfRange(size_type new_size) {\n      const size_type kMaxMapLoadTimes16 = 12;  // controls RAM vs CPU tradeoff\n      const size_type hi_cutoff = num_buckets_ * kMaxMapLoadTimes16 / 16;\n      const size_type lo_cutoff = hi_cutoff / 4;\n      // We don't care how many elements are in trees.  If a lot are,\n      // we may resize even though there are many empty buckets.  In\n      // practice, this seems fine.\n      if (GOOGLE_PREDICT_FALSE(new_size >= hi_cutoff)) {\n        if (num_buckets_ <= max_size() / 2) {\n          Resize(num_buckets_ * 2);\n          return true;\n        }\n      } else if (GOOGLE_PREDICT_FALSE(new_size <= lo_cutoff &&\n                               num_buckets_ > kMinTableSize)) {\n        size_type lg2_of_size_reduction_factor = 1;\n        // It's possible we want to shrink a lot here... size() could even be 0.\n        // So, estimate how much to shrink by making sure we don't shrink so\n        // much that we would need to grow the table after a few inserts.\n        const size_type hypothetical_size = new_size * 5 / 4 + 1;\n        while ((hypothetical_size << lg2_of_size_reduction_factor) <\n               hi_cutoff) {\n          ++lg2_of_size_reduction_factor;\n        }\n        size_type new_num_buckets = std::max<size_type>(\n            kMinTableSize, num_buckets_ >> lg2_of_size_reduction_factor);\n        if (new_num_buckets != num_buckets_) {\n          Resize(new_num_buckets);\n          return true;\n        }\n      }\n      return false;\n    }\n\n    // Resize to the given number of buckets.\n    void Resize(size_t new_num_buckets) {\n      GOOGLE_DCHECK_GE(new_num_buckets, kMinTableSize);\n      void** const old_table = table_;\n      const size_type old_table_size = num_buckets_;\n      num_buckets_ = new_num_buckets;\n      table_ = CreateEmptyTable(num_buckets_);\n      const size_type start = index_of_first_non_null_;\n      index_of_first_non_null_ = num_buckets_;\n      for (size_type i = start; i < old_table_size; i++) {\n        if (TableEntryIsNonEmptyList(old_table, i)) {\n          TransferList(old_table, i);\n        } else if (TableEntryIsTree(old_table, i)) {\n          TransferTree(old_table, i++);\n        }\n      }\n      Dealloc<void*>(old_table, old_table_size);\n    }\n\n    void TransferList(void* const* table, size_type index) {\n      Node* node = static_cast<Node*>(table[index]);\n      do {\n        Node* next = node->next;\n        InsertUnique(BucketNumber(*KeyPtrFromNodePtr(node)), node);\n        node = next;\n      } while (node != NULL);\n    }\n\n    void TransferTree(void* const* table, size_type index) {\n      Tree* tree = static_cast<Tree*>(table[index]);\n      typename Tree::iterator tree_it = tree->begin();\n      do {\n        Node* node = NodePtrFromKeyPtr(*tree_it);\n        InsertUnique(BucketNumber(**tree_it), node);\n      } while (++tree_it != tree->end());\n      DestroyTree(tree);\n    }\n\n    Node* EraseFromLinkedList(Node* item, Node* head) {\n      if (head == item) {\n        return head->next;\n      } else {\n        head->next = EraseFromLinkedList(item, head->next);\n        return head;\n      }\n    }\n\n    bool TableEntryIsEmpty(size_type b) const {\n      return TableEntryIsEmpty(table_, b);\n    }\n    bool TableEntryIsNonEmptyList(size_type b) const {\n      return TableEntryIsNonEmptyList(table_, b);\n    }\n    bool TableEntryIsTree(size_type b) const {\n      return TableEntryIsTree(table_, b);\n    }\n    bool TableEntryIsList(size_type b) const {\n      return TableEntryIsList(table_, b);\n    }\n    static bool TableEntryIsEmpty(void* const* table, size_type b) {\n      return table[b] == NULL;\n    }\n    static bool TableEntryIsNonEmptyList(void* const* table, size_type b) {\n      return table[b] != NULL && table[b] != table[b ^ 1];\n    }\n    static bool TableEntryIsTree(void* const* table, size_type b) {\n      return !TableEntryIsEmpty(table, b) &&\n          !TableEntryIsNonEmptyList(table, b);\n    }\n    static bool TableEntryIsList(void* const* table, size_type b) {\n      return !TableEntryIsTree(table, b);\n    }\n\n    void TreeConvert(size_type b) {\n      GOOGLE_DCHECK(!TableEntryIsTree(b) && !TableEntryIsTree(b ^ 1));\n      typename Allocator::template rebind<Tree>::other tree_allocator(alloc_);\n      Tree* tree = tree_allocator.allocate(1);\n      // We want to use the three-arg form of construct, if it exists, but we\n      // create a temporary and use the two-arg construct that's known to exist.\n      // It's clunky, but the compiler should be able to generate more-or-less\n      // the same code.\n      tree_allocator.construct(tree,\n                               Tree(KeyCompare(), KeyPtrAllocator(alloc_)));\n      // Now the tree is ready to use.\n      size_type count = CopyListToTree(b, tree) + CopyListToTree(b ^ 1, tree);\n      GOOGLE_DCHECK_EQ(count, tree->size());\n      table_[b] = table_[b ^ 1] = static_cast<void*>(tree);\n    }\n\n    // Copy a linked list in the given bucket to a tree.\n    // Returns the number of things it copied.\n    size_type CopyListToTree(size_type b, Tree* tree) {\n      size_type count = 0;\n      Node* node = static_cast<Node*>(table_[b]);\n      while (node != NULL) {\n        tree->insert(KeyPtrFromNodePtr(node));\n        ++count;\n        Node* next = node->next;\n        node->next = NULL;\n        node = next;\n      }\n      return count;\n    }\n\n    // Return whether table_[b] is a linked list that seems awfully long.\n    // Requires table_[b] to point to a non-empty linked list.\n    bool TableEntryIsTooLong(size_type b) {\n      const size_type kMaxLength = 8;\n      size_type count = 0;\n      Node* node = static_cast<Node*>(table_[b]);\n      do {\n        ++count;\n        node = node->next;\n      } while (node != NULL);\n      // Invariant: no linked list ever is more than kMaxLength in length.\n      GOOGLE_DCHECK_LE(count, kMaxLength);\n      return count >= kMaxLength;\n    }\n\n    size_type BucketNumber(const Key& k) const {\n      // We inherit from hasher, so one-arg operator() provides a hash function.\n      size_type h = (*const_cast<InnerMap*>(this))(k);\n      // To help prevent people from making assumptions about the hash function,\n      // we use the seed differently depending on NDEBUG.  The default hash\n      // function, the seeding, etc., are all likely to change in the future.\n#ifndef NDEBUG\n      return (h * (seed_ | 1)) & (num_buckets_ - 1);\n#else\n      return (h + seed_) & (num_buckets_ - 1);\n#endif\n    }\n\n    bool IsMatch(const Key& k0, const Key& k1) const {\n      return std::equal_to<Key>()(k0, k1);\n    }\n\n    // Return a power of two no less than max(kMinTableSize, n).\n    // Assumes either n < kMinTableSize or n is a power of two.\n    size_type TableSize(size_type n) {\n      return n < kMinTableSize ? kMinTableSize : n;\n    }\n\n    // Use alloc_ to allocate an array of n objects of type U.\n    template <typename U>\n    U* Alloc(size_type n) {\n      typedef typename Allocator::template rebind<U>::other alloc_type;\n      return alloc_type(alloc_).allocate(n);\n    }\n\n    // Use alloc_ to deallocate an array of n objects of type U.\n    template <typename U>\n    void Dealloc(U* t, size_type n) {\n      typedef typename Allocator::template rebind<U>::other alloc_type;\n      alloc_type(alloc_).deallocate(t, n);\n    }\n\n    void DestroyNode(Node* node) {\n      alloc_.destroy(&node->kv);\n      Dealloc<Node>(node, 1);\n    }\n\n    void DestroyTree(Tree* tree) {\n      typename Allocator::template rebind<Tree>::other tree_allocator(alloc_);\n      tree_allocator.destroy(tree);\n      tree_allocator.deallocate(tree, 1);\n    }\n\n    void** CreateEmptyTable(size_type n) {\n      GOOGLE_DCHECK(n >= kMinTableSize);\n      GOOGLE_DCHECK_EQ(n & (n - 1), 0);\n      void** result = Alloc<void*>(n);\n      memset(result, 0, n * sizeof(result[0]));\n      return result;\n    }\n\n    // Return a randomish value.\n    size_type Seed() const {\n      // random_device can throw, so avoid it unless we are compiling with\n      // exceptions enabled.\n#if __cpp_exceptions && LANG_CXX11\n      try {\n        std::random_device rd;\n        std::knuth_b knuth(rd());\n        std::uniform_int_distribution<size_type> u;\n        return u(knuth);\n      } catch (...) { }\n#endif\n      size_type s = static_cast<size_type>(reinterpret_cast<uintptr_t>(this));\n#if defined(__x86_64__) && defined(__GNUC__)\n      uint32 hi, lo;\n      asm(\"rdtsc\" : \"=a\" (lo), \"=d\" (hi));\n      s += ((static_cast<uint64>(hi) << 32) | lo);\n#endif\n      return s;\n    }\n\n    size_type num_elements_;\n    size_type num_buckets_;\n    size_type seed_;\n    size_type index_of_first_non_null_;\n    void** table_;  // an array with num_buckets_ entries\n    Allocator alloc_;\n    GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(InnerMap);\n  };  // end of class InnerMap\n\n  typedef hash_map<Key, value_type*, hash<Key>, equal_to<Key>,\n                   MapAllocator<std::pair<const Key, MapPair<Key, T>*> > >\n      DeprecatedInnerMap;\n\n public:\n  // Iterators\n  class iterator_base {\n   public:\n    // We support \"old style\" and \"new style\" iterators for now. This is\n    // temporary.  Also, for \"iterator()\" we have an unknown category.\n    // TODO(gpike): get rid of this.\n    enum IteratorStyle { kUnknown, kOld, kNew };\n    explicit iterator_base(IteratorStyle style) : iterator_style_(style) {}\n\n    bool OldStyle() const {\n      GOOGLE_DCHECK_NE(iterator_style_, kUnknown);\n      return iterator_style_ == kOld;\n    }\n    bool UnknownStyle() const {\n      return iterator_style_ == kUnknown;\n    }\n    bool SameStyle(const iterator_base& other) const {\n      return iterator_style_ == other.iterator_style_;\n    }\n\n   private:\n    IteratorStyle iterator_style_;\n  };\n\n  class const_iterator\n      : private iterator_base,\n        public std::iterator<std::forward_iterator_tag, value_type, ptrdiff_t,\n                             const value_type*, const value_type&> {\n    typedef typename InnerMap::const_iterator InnerIt;\n    typedef typename DeprecatedInnerMap::const_iterator DeprecatedInnerIt;\n\n   public:\n    const_iterator() : iterator_base(iterator_base::kUnknown) {}\n    explicit const_iterator(const DeprecatedInnerIt& dit)\n        : iterator_base(iterator_base::kOld), dit_(dit) {}\n    explicit const_iterator(const InnerIt& it)\n        : iterator_base(iterator_base::kNew), it_(it) {}\n\n    const_iterator(const const_iterator& other)\n        : iterator_base(other), it_(other.it_), dit_(other.dit_) {}\n\n    const_reference operator*() const {\n      return this->OldStyle() ? *dit_->second : *it_->value();\n    }\n    const_pointer operator->() const { return &(operator*()); }\n\n    const_iterator& operator++() {\n      if (this->OldStyle())\n        ++dit_;\n      else\n        ++it_;\n      return *this;\n    }\n    const_iterator operator++(int) {\n      return this->OldStyle() ? const_iterator(dit_++) : const_iterator(it_++);\n    }\n\n    friend bool operator==(const const_iterator& a, const const_iterator& b) {\n      if (!a.SameStyle(b)) return false;\n      if (a.UnknownStyle()) return true;\n      return a.OldStyle() ? (a.dit_ == b.dit_) : (a.it_ == b.it_);\n    }\n    friend bool operator!=(const const_iterator& a, const const_iterator& b) {\n      return !(a == b);\n    }\n\n   private:\n    InnerIt it_;\n    DeprecatedInnerIt dit_;\n  };\n\n  class iterator : private iterator_base,\n                   public std::iterator<std::forward_iterator_tag, value_type> {\n    typedef typename InnerMap::iterator InnerIt;\n    typedef typename DeprecatedInnerMap::iterator DeprecatedInnerIt;\n\n   public:\n    iterator() : iterator_base(iterator_base::kUnknown) {}\n    explicit iterator(const DeprecatedInnerIt& dit)\n        : iterator_base(iterator_base::kOld), dit_(dit) {}\n    explicit iterator(const InnerIt& it)\n        : iterator_base(iterator_base::kNew), it_(it) {}\n\n    reference operator*() const {\n      return this->OldStyle() ? *dit_->second : *it_->value();\n    }\n    pointer operator->() const { return &(operator*()); }\n\n    iterator& operator++() {\n      if (this->OldStyle())\n        ++dit_;\n      else\n        ++it_;\n      return *this;\n    }\n    iterator operator++(int) {\n      return this->OldStyle() ? iterator(dit_++) : iterator(it_++);\n    }\n\n    // Allow implicit conversion to const_iterator.\n    operator const_iterator() const {\n      return this->OldStyle() ?\n          const_iterator(typename DeprecatedInnerMap::const_iterator(dit_)) :\n          const_iterator(typename InnerMap::const_iterator(it_));\n    }\n\n    friend bool operator==(const iterator& a, const iterator& b) {\n      if (!a.SameStyle(b)) return false;\n      if (a.UnknownStyle()) return true;\n      return a.OldStyle() ? a.dit_ == b.dit_ : a.it_ == b.it_;\n    }\n    friend bool operator!=(const iterator& a, const iterator& b) {\n      return !(a == b);\n    }\n\n   private:\n    friend class Map;\n\n    InnerIt it_;\n    DeprecatedInnerIt dit_;\n  };\n\n  iterator begin() {\n    return old_style_ ? iterator(deprecated_elements_->begin())\n                      : iterator(elements_->begin());\n  }\n  iterator end() {\n    return old_style_ ? iterator(deprecated_elements_->end())\n                      : iterator(elements_->end());\n  }\n  const_iterator begin() const {\n    return old_style_ ? const_iterator(deprecated_elements_->begin())\n                      : const_iterator(iterator(elements_->begin()));\n  }\n  const_iterator end() const {\n    return old_style_ ? const_iterator(deprecated_elements_->end())\n                      : const_iterator(iterator(elements_->end()));\n  }\n  const_iterator cbegin() const { return begin(); }\n  const_iterator cend() const { return end(); }\n\n  // Capacity\n  size_type size() const {\n    return old_style_ ? deprecated_elements_->size() : elements_->size();\n  }\n  bool empty() const { return size() == 0; }\n\n  // Element access\n  T& operator[](const key_type& key) {\n    value_type** value =\n        old_style_ ? &(*deprecated_elements_)[key] : &(*elements_)[key];\n    if (*value == NULL) {\n      *value = CreateValueTypeInternal(key);\n      internal::MapValueInitializer<google::protobuf::is_proto_enum<T>::value,\n                                    T>::Initialize((*value)->second,\n                                                   default_enum_value_);\n    }\n    return (*value)->second;\n  }\n  const T& at(const key_type& key) const {\n    const_iterator it = find(key);\n    GOOGLE_CHECK(it != end());\n    return it->second;\n  }\n  T& at(const key_type& key) {\n    iterator it = find(key);\n    GOOGLE_CHECK(it != end());\n    return it->second;\n  }\n\n  // Lookup\n  size_type count(const key_type& key) const {\n    if (find(key) != end()) assert(key == find(key)->first);\n    return find(key) == end() ? 0 : 1;\n  }\n  const_iterator find(const key_type& key) const {\n    return old_style_ ? const_iterator(deprecated_elements_->find(key))\n        : const_iterator(iterator(elements_->find(key)));\n  }\n  iterator find(const key_type& key) {\n    return old_style_ ? iterator(deprecated_elements_->find(key))\n                      : iterator(elements_->find(key));\n  }\n  std::pair<const_iterator, const_iterator> equal_range(\n      const key_type& key) const {\n    const_iterator it = find(key);\n    if (it == end()) {\n      return std::pair<const_iterator, const_iterator>(it, it);\n    } else {\n      const_iterator begin = it++;\n      return std::pair<const_iterator, const_iterator>(begin, it);\n    }\n  }\n  std::pair<iterator, iterator> equal_range(const key_type& key) {\n    iterator it = find(key);\n    if (it == end()) {\n      return std::pair<iterator, iterator>(it, it);\n    } else {\n      iterator begin = it++;\n      return std::pair<iterator, iterator>(begin, it);\n    }\n  }\n\n  // insert\n  std::pair<iterator, bool> insert(const value_type& value) {\n    if (old_style_) {\n      iterator it = find(value.first);\n      if (it != end()) {\n        return std::pair<iterator, bool>(it, false);\n      } else {\n        return std::pair<iterator, bool>(\n            iterator(deprecated_elements_->insert(std::pair<Key, value_type*>(\n                value.first, CreateValueTypeInternal(value))).first), true);\n      }\n    } else {\n      std::pair<typename InnerMap::iterator, bool> p =\n          elements_->insert(value.first);\n      if (p.second) {\n        p.first->value() = CreateValueTypeInternal(value);\n      }\n      return std::pair<iterator, bool>(iterator(p.first), p.second);\n    }\n  }\n  template <class InputIt>\n  void insert(InputIt first, InputIt last) {\n    for (InputIt it = first; it != last; ++it) {\n      iterator exist_it = find(it->first);\n      if (exist_it == end()) {\n        operator[](it->first) = it->second;\n      }\n    }\n  }\n\n  // Erase and clear\n  size_type erase(const key_type& key) {\n    iterator it = find(key);\n    if (it == end()) {\n      return 0;\n    } else {\n      erase(it);\n      return 1;\n    }\n  }\n  iterator erase(iterator pos) {\n    if (arena_ == NULL) delete pos.operator->();\n    iterator i = pos++;\n    if (old_style_)\n      deprecated_elements_->erase(i.dit_);\n    else\n      elements_->erase(i.it_);\n    return pos;\n  }\n  void erase(iterator first, iterator last) {\n    while (first != last) {\n      first = erase(first);\n    }\n  }\n  void clear() { erase(begin(), end()); }\n\n  // Assign\n  Map& operator=(const Map& other) {\n    if (this != &other) {\n      clear();\n      insert(other.begin(), other.end());\n    }\n    return *this;\n  }\n\n  void swap(Map& other) {\n    if (arena_ == other.arena_ && old_style_ == other.old_style_) {\n      std::swap(default_enum_value_, other.default_enum_value_);\n      if (old_style_) {\n        std::swap(deprecated_elements_, other.deprecated_elements_);\n      } else {\n        std::swap(elements_, other.elements_);\n      }\n    } else {\n      // TODO(zuguang): optimize this. The temporary copy can be allocated\n      // in the same arena as the other message, and the \"other = copy\" can\n      // be replaced with the fast-path swap above.\n      Map copy = *this;\n      *this = other;\n      other = copy;\n    }\n  }\n\n  // Access to hasher.  Currently this returns a copy, but it may\n  // be modified to return a const reference in the future.\n  hasher hash_function() const {\n    return old_style_ ? deprecated_elements_->hash_function()\n                      : elements_->hash_function();\n  }\n\n private:\n  // Set default enum value only for proto2 map field whose value is enum type.\n  void SetDefaultEnumValue(int default_enum_value) {\n    default_enum_value_ = default_enum_value;\n  }\n\n  value_type* CreateValueTypeInternal(const Key& key) {\n    if (arena_ == NULL) {\n      return new value_type(key);\n    } else {\n      value_type* value = reinterpret_cast<value_type*>(\n          Arena::CreateArray<uint8>(arena_, sizeof(value_type)));\n      Arena::CreateInArenaStorage(const_cast<Key*>(&value->first), arena_);\n      Arena::CreateInArenaStorage(&value->second, arena_);\n      const_cast<Key&>(value->first) = key;\n      return value;\n    }\n  }\n\n  value_type* CreateValueTypeInternal(const value_type& value) {\n    if (arena_ == NULL) {\n      return new value_type(value);\n    } else {\n      value_type* p = reinterpret_cast<value_type*>(\n          Arena::CreateArray<uint8>(arena_, sizeof(value_type)));\n      Arena::CreateInArenaStorage(const_cast<Key*>(&p->first), arena_);\n      Arena::CreateInArenaStorage(&p->second, arena_);\n      const_cast<Key&>(p->first) = value.first;\n      p->second = value.second;\n      return p;\n    }\n  }\n\n  Arena* arena_;\n  int default_enum_value_;\n  // The following is a tagged union because we support two map styles\n  // for now.\n  // TODO(gpike): get rid of the old style.\n  const bool old_style_;\n  union {\n    InnerMap* elements_;\n    DeprecatedInnerMap* deprecated_elements_;\n  };\n\n  friend class ::google::protobuf::Arena;\n  typedef void InternalArenaConstructable_;\n  typedef void DestructorSkippable_;\n  template <typename K, typename V,\n            internal::WireFormatLite::FieldType key_wire_type,\n            internal::WireFormatLite::FieldType value_wire_type,\n            int default_enum_value>\n  friend class internal::MapFieldLite;\n};\n\n}  // namespace protobuf\n}  // namespace google\n\nGOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_START\ntemplate<>\nstruct hash<google::protobuf::MapKey> {\n  size_t\n  operator()(const google::protobuf::MapKey& map_key) const {\n    switch (map_key.type()) {\n      case google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE:\n      case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT:\n      case google::protobuf::FieldDescriptor::CPPTYPE_ENUM:\n      case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE:\n        GOOGLE_LOG(FATAL) << \"Unsupported\";\n        break;\n      case google::protobuf::FieldDescriptor::CPPTYPE_STRING:\n        return hash<string>()(map_key.GetStringValue());\n      case google::protobuf::FieldDescriptor::CPPTYPE_INT64:\n        return hash< ::google::protobuf::int64>()(map_key.GetInt64Value());\n      case google::protobuf::FieldDescriptor::CPPTYPE_INT32:\n        return hash< ::google::protobuf::int32>()(map_key.GetInt32Value());\n      case google::protobuf::FieldDescriptor::CPPTYPE_UINT64:\n        return hash< ::google::protobuf::uint64>()(map_key.GetUInt64Value());\n      case google::protobuf::FieldDescriptor::CPPTYPE_UINT32:\n        return hash< ::google::protobuf::uint32>()(map_key.GetUInt32Value());\n      case google::protobuf::FieldDescriptor::CPPTYPE_BOOL:\n        return hash<bool>()(map_key.GetBoolValue());\n    }\n    GOOGLE_LOG(FATAL) << \"Can't get here.\";\n    return 0;\n  }\n  bool\n  operator()(const google::protobuf::MapKey& map_key1,\n             const google::protobuf::MapKey& map_key2) const {\n    return map_key1 < map_key2;\n  }\n};\nGOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_END\n\n#endif  // GOOGLE_PROTOBUF_MAP_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/map_entry.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_MAP_ENTRY_H__\n#define GOOGLE_PROTOBUF_MAP_ENTRY_H__\n\n#include <google/protobuf/generated_message_reflection.h>\n#include <google/protobuf/map_entry_lite.h>\n#include <google/protobuf/map_type_handler.h>\n#include <google/protobuf/metadata.h>\n#include <google/protobuf/reflection_ops.h>\n#include <google/protobuf/unknown_field_set.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n\nnamespace google {\nnamespace protobuf {\nclass Arena;\nnamespace internal {\ntemplate <typename Key, typename Value,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nclass MapField;\n}\n}\n\nnamespace protobuf {\nnamespace internal {\n\n// Register all MapEntry default instances so we can delete them in\n// ShutdownProtobufLibrary().\nvoid LIBPROTOBUF_EXPORT RegisterMapEntryDefaultInstance(\n    MessageLite* default_instance);\n\n// This is the common base class for MapEntry. It is used by MapFieldBase in\n// reflection api, in which the static type of key and value is unknown.\nclass LIBPROTOBUF_EXPORT MapEntryBase : public Message {\n public:\n  ::google::protobuf::Metadata GetMetadata() const {\n    ::google::protobuf::Metadata metadata;\n    metadata.descriptor = descriptor_;\n    metadata.reflection = reflection_;\n    return metadata;\n  }\n\n protected:\n  MapEntryBase() : descriptor_(NULL), reflection_(NULL) {  }\n  virtual ~MapEntryBase() {}\n\n  const Descriptor* descriptor_;\n  const Reflection* reflection_;\n};\n\n// MapEntry is the returned google::protobuf::Message when calling AddMessage of\n// google::protobuf::Reflection. In order to let it work with generated message\n// reflection, its in-memory type is the same as generated message with the same\n// fields. However, in order to decide the in-memory type of key/value, we need\n// to know both their cpp type in generated api and proto type. In\n// implementation, all in-memory types have related wire format functions to\n// support except ArenaStringPtr. Therefore, we need to define another type with\n// supporting wire format functions. Since this type is only used as return type\n// of MapEntry accessors, it's named MapEntry accessor type.\n//\n// cpp type:               the type visible to users in public API.\n// proto type:             WireFormatLite::FieldType of the field.\n// in-memory type:         type of the data member used to stored this field.\n// MapEntry accessor type: type used in MapEntry getters/mutators to access the\n//                         field.\n//\n// cpp type | proto type  | in-memory type | MapEntry accessor type\n// int32      TYPE_INT32    int32            int32\n// int32      TYPE_FIXED32  int32            int32\n// string     TYPE_STRING   ArenaStringPtr   string\n// FooEnum    TYPE_ENUM     int              int\n// FooMessage TYPE_MESSAGE  FooMessage*      FooMessage\n//\n// The in-memory types of primitive types can be inferred from its proto type,\n// while we need to explicitly specify the cpp type if proto type is\n// TYPE_MESSAGE to infer the in-memory type.  Moreover, default_enum_value is\n// used to initialize enum field in proto2.\ntemplate <typename Key, typename Value,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nclass MapEntry : public MapEntryBase {\n  // Provide utilities to parse/serialize key/value.  Provide utilities to\n  // manipulate internal stored type.\n  typedef MapTypeHandler<kKeyFieldType, Key> KeyTypeHandler;\n  typedef MapTypeHandler<kValueFieldType, Value> ValueTypeHandler;\n\n  // Enum type cannot be used for MapTypeHandler::Read. Define a type\n  // which will replace Enum with int.\n  typedef typename KeyTypeHandler::MapEntryAccessorType KeyMapEntryAccessorType;\n  typedef typename ValueTypeHandler::MapEntryAccessorType\n      ValueMapEntryAccessorType;\n\n  // Abbreviation for MapEntry\n  typedef typename google::protobuf::internal::MapEntry<\n      Key, Value, kKeyFieldType, kValueFieldType, default_enum_value> EntryType;\n\n  // Abbreviation for MapEntryLite\n  typedef typename google::protobuf::internal::MapEntryLite<\n      Key, Value, kKeyFieldType, kValueFieldType, default_enum_value>\n      EntryLiteType;\n\n public:\n  ~MapEntry() {\n    if (this == default_instance_) {\n      delete reflection_;\n    }\n  }\n\n  // accessors ======================================================\n\n  virtual inline const KeyMapEntryAccessorType& key() const {\n    return entry_lite_.key();\n  }\n  inline KeyMapEntryAccessorType* mutable_key() {\n    return entry_lite_.mutable_key();\n  }\n  virtual inline const ValueMapEntryAccessorType& value() const {\n    return entry_lite_.value();\n  }\n  inline ValueMapEntryAccessorType* mutable_value() {\n    return entry_lite_.mutable_value();\n  }\n\n  // implements Message =============================================\n\n  bool MergePartialFromCodedStream(::google::protobuf::io::CodedInputStream* input) {\n    return entry_lite_.MergePartialFromCodedStream(input);\n  }\n\n  int ByteSize() const {\n    return entry_lite_.ByteSize();\n  }\n\n  void SerializeWithCachedSizes(::google::protobuf::io::CodedOutputStream* output) const {\n    entry_lite_.SerializeWithCachedSizes(output);\n  }\n\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(bool deterministic,\n                                                   ::google::protobuf::uint8* output) const {\n    return entry_lite_.InternalSerializeWithCachedSizesToArray(deterministic,\n                                                               output);\n  }\n\n  int GetCachedSize() const {\n    return entry_lite_.GetCachedSize();\n  }\n\n  bool IsInitialized() const {\n    return entry_lite_.IsInitialized();\n  }\n\n  Message* New() const {\n    MapEntry* entry = new MapEntry;\n    entry->descriptor_ = descriptor_;\n    entry->reflection_ = reflection_;\n    entry->set_default_instance(default_instance_);\n    return entry;\n  }\n\n  Message* New(Arena* arena) const {\n    MapEntry* entry = Arena::CreateMessage<MapEntry>(arena);\n    entry->descriptor_ = descriptor_;\n    entry->reflection_ = reflection_;\n    entry->set_default_instance(default_instance_);\n    return entry;\n  }\n\n  int SpaceUsed() const {\n    int size = sizeof(MapEntry);\n    size += entry_lite_.SpaceUsed();\n    return size;\n  }\n\n  void CopyFrom(const ::google::protobuf::Message& from) {\n    Clear();\n    MergeFrom(from);\n  }\n\n  void MergeFrom(const ::google::protobuf::Message& from) {\n    GOOGLE_CHECK_NE(&from, this);\n    const MapEntry* source = dynamic_cast_if_available<const MapEntry*>(&from);\n    if (source == NULL) {\n      ReflectionOps::Merge(from, this);\n    } else {\n      MergeFrom(*source);\n    }\n  }\n\n  void CopyFrom(const MapEntry& from) {\n    Clear();\n    MergeFrom(from);\n  }\n\n  void MergeFrom(const MapEntry& from) {\n    entry_lite_.MergeFrom(from.entry_lite_);\n  }\n\n  void Clear() {\n    entry_lite_.Clear();\n  }\n\n  void InitAsDefaultInstance() {\n    entry_lite_.InitAsDefaultInstance();\n  }\n\n  Arena* GetArena() const {\n    return entry_lite_.GetArena();\n  }\n\n  // Create default MapEntry instance for given descriptor. Descriptor has to be\n  // given when creating default MapEntry instance because different map field\n  // may have the same type and MapEntry class. The given descriptor is needed\n  // to distinguish instances of the same MapEntry class.\n  static MapEntry* CreateDefaultInstance(const Descriptor* descriptor) {\n    MapEntry* entry = new MapEntry;\n    const Reflection* reflection = new GeneratedMessageReflection(\n        descriptor, entry, offsets_,\n        GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, entry_lite_._has_bits_),\n        GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, _unknown_fields_), -1,\n        DescriptorPool::generated_pool(),\n        ::google::protobuf::MessageFactory::generated_factory(),\n        sizeof(MapEntry),\n        GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, _internal_metadata_));\n    entry->descriptor_ = descriptor;\n    entry->reflection_ = reflection;\n    entry->set_default_instance(entry);\n    entry->InitAsDefaultInstance();\n    RegisterMapEntryDefaultInstance(entry);\n    return entry;\n  }\n\n private:\n  MapEntry()\n      : _internal_metadata_(NULL), default_instance_(NULL), entry_lite_() {}\n\n  explicit MapEntry(Arena* arena)\n      : _internal_metadata_(arena),\n        default_instance_(NULL),\n        entry_lite_(arena) {}\n\n  inline Arena* GetArenaNoVirtual() const {\n    return entry_lite_.GetArenaNoVirtual();\n  }\n\n  void set_default_instance(MapEntry* default_instance) {\n    default_instance_ = default_instance;\n    entry_lite_.set_default_instance(&default_instance->entry_lite_);\n  }\n\n  static int offsets_[2];\n  UnknownFieldSet _unknown_fields_;\n  InternalMetadataWithArena _internal_metadata_;\n  MapEntry* default_instance_;\n  EntryLiteType entry_lite_;\n\n  friend class ::google::protobuf::Arena;\n  typedef void InternalArenaConstructable_;\n  typedef void DestructorSkippable_;\n  template <typename K, typename V, WireFormatLite::FieldType k_wire_type,\n            WireFormatLite::FieldType, int default_enum>\n  friend class internal::MapField;\n  friend class internal::GeneratedMessageReflection;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntry);\n};\n\ntemplate <typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType, int default_enum_value>\nint MapEntry<Key, Value, kKeyFieldType, kValueFieldType,\n             default_enum_value>::offsets_[2] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, entry_lite_.key_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapEntry, entry_lite_.value_),\n};\n\n}  // namespace internal\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_MAP_ENTRY_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/map_entry_lite.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_MAP_ENTRY_LITE_H__\n#define GOOGLE_PROTOBUF_MAP_ENTRY_LITE_H__\n\n#include <assert.h>\n#include <google/protobuf/map_type_handler.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n\nnamespace google {\nnamespace protobuf {\nclass Arena;\nnamespace internal {\ntemplate <typename Key, typename Value,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nclass MapEntry;\ntemplate <typename Key, typename Value,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nclass MapFieldLite;\n}  // namespace internal\n}  // namespace protobuf\n\nnamespace protobuf {\nnamespace internal {\n\n// MoveHelper::Move is used to set *dest.  It copies *src, or moves it (in\n// the C++11 sense), or swaps it. *src is left in a sane state for\n// subsequent destruction, but shouldn't be used for anything.\ntemplate <bool is_enum, bool is_message, bool is_stringlike, typename T>\nstruct MoveHelper {  // primitives\n  static void Move(T* src, T* dest) { *dest = *src; }\n};\n\ntemplate <bool is_message, bool is_stringlike, typename T>\nstruct MoveHelper<true, is_message, is_stringlike, T> {  // enums\n  static void Move(T* src, T* dest) { *dest = *src; }\n  // T is an enum here, so allow conversions to and from int.\n  static void Move(T* src, int* dest) { *dest = static_cast<int>(*src); }\n  static void Move(int* src, T* dest) { *dest = static_cast<T>(*src); }\n};\n\ntemplate <bool is_stringlike, typename T>\nstruct MoveHelper<false, true, is_stringlike, T> {  // messages\n  static void Move(T* src, T* dest) { dest->Swap(src); }\n};\n\ntemplate <typename T>\nstruct MoveHelper<false, false, true, T> {  // strings and similar\n  static void Move(T* src, T* dest) {\n#if __cplusplus >= 201103L\n    *dest = std::move(*src);\n#else\n    dest->swap(*src);\n#endif\n  }\n};\n\n// MapEntryLite is used to implement parsing and serialization of map for lite\n// runtime.\ntemplate <typename Key, typename Value,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nclass MapEntryLite : public MessageLite {\n  // Provide utilities to parse/serialize key/value.  Provide utilities to\n  // manipulate internal stored type.\n  typedef MapTypeHandler<kKeyFieldType, Key> KeyTypeHandler;\n  typedef MapTypeHandler<kValueFieldType, Value> ValueTypeHandler;\n\n  // Define internal memory layout. Strings and messages are stored as\n  // pointers, while other types are stored as values.\n  typedef typename KeyTypeHandler::TypeOnMemory KeyOnMemory;\n  typedef typename ValueTypeHandler::TypeOnMemory ValueOnMemory;\n\n  // Enum type cannot be used for MapTypeHandler::Read. Define a type\n  // which will replace Enum with int.\n  typedef typename KeyTypeHandler::MapEntryAccessorType KeyMapEntryAccessorType;\n  typedef typename ValueTypeHandler::MapEntryAccessorType\n      ValueMapEntryAccessorType;\n\n  // Constants for field number.\n  static const int kKeyFieldNumber = 1;\n  static const int kValueFieldNumber = 2;\n\n  // Constants for field tag.\n  static const uint8 kKeyTag = GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(\n      kKeyFieldNumber, KeyTypeHandler::kWireType);\n  static const uint8 kValueTag = GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(\n      kValueFieldNumber, ValueTypeHandler::kWireType);\n  static const int kTagSize = 1;\n\n public:\n  ~MapEntryLite() {\n    if (this != default_instance_) {\n      if (GetArenaNoVirtual() != NULL) return;\n      KeyTypeHandler::DeleteNoArena(key_);\n      ValueTypeHandler::DeleteNoArena(value_);\n    }\n  }\n\n  // accessors ======================================================\n\n  virtual inline const KeyMapEntryAccessorType& key() const {\n    return KeyTypeHandler::GetExternalReference(key_);\n  }\n  virtual inline const ValueMapEntryAccessorType& value() const {\n    GOOGLE_CHECK(default_instance_ != NULL);\n    return ValueTypeHandler::DefaultIfNotInitialized(value_,\n                                                    default_instance_->value_);\n  }\n  inline KeyMapEntryAccessorType* mutable_key() {\n    set_has_key();\n    return KeyTypeHandler::EnsureMutable(&key_, GetArenaNoVirtual());\n  }\n  inline ValueMapEntryAccessorType* mutable_value() {\n    set_has_value();\n    return ValueTypeHandler::EnsureMutable(&value_, GetArenaNoVirtual());\n  }\n\n  // implements MessageLite =========================================\n\n  // MapEntryLite is for implementation only and this function isn't called\n  // anywhere. Just provide a fake implementation here for MessageLite.\n  string GetTypeName() const { return \"\"; }\n\n  void CheckTypeAndMergeFrom(const MessageLite& other) {\n    MergeFrom(*::google::protobuf::down_cast<const MapEntryLite*>(&other));\n  }\n\n  bool MergePartialFromCodedStream(::google::protobuf::io::CodedInputStream* input) {\n    uint32 tag;\n\n    for (;;) {\n      // 1) corrupted data: return false;\n      // 2) unknown field: skip without putting into unknown field set;\n      // 3) unknown enum value: keep it in parsing. In proto2, caller should\n      // check the value and put this entry into containing message's unknown\n      // field set if the value is an unknown enum. In proto3, caller doesn't\n      // need to care whether the value is unknown enum;\n      // 4) missing key/value: missed key/value will have default value. caller\n      // should take this entry as if key/value is set to default value.\n      tag = input->ReadTag();\n      switch (tag) {\n        case kKeyTag:\n          if (!KeyTypeHandler::Read(input, mutable_key())) {\n            return false;\n          }\n          set_has_key();\n          if (!input->ExpectTag(kValueTag)) break;\n          GOOGLE_FALLTHROUGH_INTENDED;\n\n        case kValueTag:\n          if (!ValueTypeHandler::Read(input, mutable_value())) {\n            return false;\n          }\n          set_has_value();\n          if (input->ExpectAtEnd()) return true;\n          break;\n\n        default:\n          if (tag == 0 ||\n              WireFormatLite::GetTagWireType(tag) ==\n              WireFormatLite::WIRETYPE_END_GROUP) {\n            return true;\n          }\n          if (!WireFormatLite::SkipField(input, tag)) return false;\n          break;\n      }\n    }\n  }\n\n  int ByteSize() const {\n    int size = 0;\n    size += has_key() ? kTagSize + KeyTypeHandler::ByteSize(key()) : 0;\n    size += has_value() ? kTagSize + ValueTypeHandler::ByteSize(value()) : 0;\n    return size;\n  }\n\n  void SerializeWithCachedSizes(::google::protobuf::io::CodedOutputStream* output) const {\n    KeyTypeHandler::Write(kKeyFieldNumber, key(), output);\n    ValueTypeHandler::Write(kValueFieldNumber, value(), output);\n  }\n\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(bool deterministic,\n                                                   ::google::protobuf::uint8* output) const {\n    output = KeyTypeHandler::InternalWriteToArray(kKeyFieldNumber, key(),\n                                                  deterministic, output);\n    output = ValueTypeHandler::InternalWriteToArray(kValueFieldNumber, value(),\n                                                    deterministic, output);\n    return output;\n  }\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n\n  int GetCachedSize() const {\n    int size = 0;\n    size += has_key()\n        ? kTagSize + KeyTypeHandler::GetCachedSize(key())\n        : 0;\n    size += has_value()\n        ? kTagSize + ValueTypeHandler::GetCachedSize(\n            value())\n        : 0;\n    return size;\n  }\n\n  bool IsInitialized() const { return ValueTypeHandler::IsInitialized(value_); }\n\n  MessageLite* New() const {\n    MapEntryLite* entry = new MapEntryLite;\n    entry->default_instance_ = default_instance_;\n    return entry;\n  }\n\n  MessageLite* New(Arena* arena) const {\n    MapEntryLite* entry = Arena::CreateMessage<MapEntryLite>(arena);\n    entry->default_instance_ = default_instance_;\n    return entry;\n  }\n\n  int SpaceUsed() const {\n    int size = sizeof(MapEntryLite);\n    size += KeyTypeHandler::SpaceUsedInMapEntry(key_);\n    size += ValueTypeHandler::SpaceUsedInMapEntry(value_);\n    return size;\n  }\n\n  void MergeFrom(const MapEntryLite& from) {\n    if (from._has_bits_[0]) {\n      if (from.has_key()) {\n        KeyTypeHandler::EnsureMutable(&key_, GetArenaNoVirtual());\n        KeyTypeHandler::Merge(from.key(), &key_, GetArenaNoVirtual());\n        set_has_key();\n      }\n      if (from.has_value()) {\n        ValueTypeHandler::EnsureMutable(&value_, GetArenaNoVirtual());\n        ValueTypeHandler::Merge(from.value(), &value_, GetArenaNoVirtual());\n        set_has_value();\n      }\n    }\n  }\n\n  void Clear() {\n    KeyTypeHandler::Clear(&key_, GetArenaNoVirtual());\n    ValueTypeHandler::ClearMaybeByDefaultEnum(\n        &value_, GetArenaNoVirtual(), default_enum_value);\n    clear_has_key();\n    clear_has_value();\n  }\n\n  void InitAsDefaultInstance() {\n    KeyTypeHandler::AssignDefaultValue(&key_);\n    ValueTypeHandler::AssignDefaultValue(&value_);\n  }\n\n  Arena* GetArena() const {\n    return GetArenaNoVirtual();\n  }\n\n  // Create a MapEntryLite for given key and value from google::protobuf::Map in\n  // serialization. This function is only called when value is enum. Enum is\n  // treated differently because its type in MapEntry is int and its type in\n  // google::protobuf::Map is enum. We cannot create a reference to int from an enum.\n  static MapEntryLite* EnumWrap(const Key& key, const Value value,\n                                Arena* arena) {\n    return Arena::CreateMessage<MapEnumEntryWrapper<\n        Key, Value, kKeyFieldType, kValueFieldType, default_enum_value> >(\n        arena, key, value);\n  }\n\n  // Like above, but for all the other types. This avoids value copy to create\n  // MapEntryLite from google::protobuf::Map in serialization.\n  static MapEntryLite* Wrap(const Key& key, const Value& value, Arena* arena) {\n    return Arena::CreateMessage<MapEntryWrapper<Key, Value, kKeyFieldType,\n                                                kValueFieldType,\n                                                default_enum_value> >(\n        arena, key, value);\n  }\n\n  // Parsing using MergePartialFromCodedStream, above, is not as\n  // efficient as it could be.  This helper class provides a speedier way.\n  template <typename MapField, typename Map>\n  class Parser {\n   public:\n    explicit Parser(MapField* mf) : mf_(mf), map_(mf->MutableMap()) {}\n\n    // This does what the typical MergePartialFromCodedStream() is expected to\n    // do, with the additional side-effect that if successful (i.e., if true is\n    // going to be its return value) it inserts the key-value pair into map_.\n    bool MergePartialFromCodedStream(::google::protobuf::io::CodedInputStream* input) {\n      // Look for the expected thing: a key and then a value.  If it fails,\n      // invoke the enclosing class's MergePartialFromCodedStream, or return\n      // false if that would be pointless.\n      if (input->ExpectTag(kKeyTag)) {\n        if (!KeyTypeHandler::Read(input, &key_)) {\n          return false;\n        }\n        // Peek at the next byte to see if it is kValueTag.  If not, bail out.\n        const void* data;\n        int size;\n        input->GetDirectBufferPointerInline(&data, &size);\n        // We could use memcmp here, but we don't bother. The tag is one byte.\n        assert(kTagSize == 1);\n        if (size > 0 && *reinterpret_cast<const char*>(data) == kValueTag) {\n          typename Map::size_type size = map_->size();\n          value_ptr_ = &(*map_)[key_];\n          if (GOOGLE_PREDICT_TRUE(size != map_->size())) {\n            // We created a new key-value pair.  Fill in the value.\n            typedef\n                typename MapIf<ValueTypeHandler::kIsEnum, int*, Value*>::type T;\n            input->Skip(kTagSize);  // Skip kValueTag.\n            if (!ValueTypeHandler::Read(input,\n                                        reinterpret_cast<T>(value_ptr_))) {\n              map_->erase(key_);  // Failure! Undo insertion.\n              return false;\n            }\n            if (input->ExpectAtEnd()) return true;\n            return ReadBeyondKeyValuePair(input);\n          }\n        }\n      } else {\n        key_ = Key();\n      }\n\n      entry_.reset(mf_->NewEntry());\n      *entry_->mutable_key() = key_;\n      if (!entry_->MergePartialFromCodedStream(input)) return false;\n      return UseKeyAndValueFromEntry();\n    }\n\n    const Key& key() const { return key_; }\n    const Value& value() const { return *value_ptr_; }\n\n   private:\n    bool UseKeyAndValueFromEntry() GOOGLE_ATTRIBUTE_COLD {\n      // Update key_ in case we need it later (because key() is called).\n      // This is potentially inefficient, especially if the key is\n      // expensive to copy (e.g., a long string), but this is a cold\n      // path, so it's not a big deal.\n      key_ = entry_->key();\n      value_ptr_ = &(*map_)[key_];\n      MoveHelper<ValueTypeHandler::kIsEnum,\n                 ValueTypeHandler::kIsMessage,\n                 ValueTypeHandler::kWireType ==\n                 WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n                 Value>::Move(entry_->mutable_value(), value_ptr_);\n      if (entry_->GetArena() != NULL) entry_.release();\n      return true;\n    }\n\n    // After reading a key and value successfully, and inserting that data\n    // into map_, we are not at the end of the input.  This is unusual, but\n    // allowed by the spec.\n    bool ReadBeyondKeyValuePair(::google::protobuf::io::CodedInputStream* input)\n        GOOGLE_ATTRIBUTE_COLD {\n      typedef MoveHelper<KeyTypeHandler::kIsEnum,\n                         KeyTypeHandler::kIsMessage,\n                         KeyTypeHandler::kWireType ==\n                         WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n                         Key> KeyMover;\n      typedef MoveHelper<ValueTypeHandler::kIsEnum,\n                         ValueTypeHandler::kIsMessage,\n                         ValueTypeHandler::kWireType ==\n                         WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n                         Value> ValueMover;\n      entry_.reset(mf_->NewEntry());\n      ValueMover::Move(value_ptr_, entry_->mutable_value());\n      map_->erase(key_);\n      KeyMover::Move(&key_, entry_->mutable_key());\n      if (!entry_->MergePartialFromCodedStream(input)) return false;\n      return UseKeyAndValueFromEntry();\n    }\n\n    MapField* const mf_;\n    Map* const map_;\n    Key key_;\n    Value* value_ptr_;\n    // On the fast path entry_ is not used.\n    google::protobuf::scoped_ptr<MapEntryLite> entry_;\n  };\n\n protected:\n  void set_has_key() { _has_bits_[0] |= 0x00000001u; }\n  bool has_key() const { return (_has_bits_[0] & 0x00000001u) != 0; }\n  void clear_has_key() { _has_bits_[0] &= ~0x00000001u; }\n  void set_has_value() { _has_bits_[0] |= 0x00000002u; }\n  bool has_value() const { return (_has_bits_[0] & 0x00000002u) != 0; }\n  void clear_has_value() { _has_bits_[0] &= ~0x00000002u; }\n\n private:\n  // Serializing a generated message containing map field involves serializing\n  // key-value pairs from google::protobuf::Map. The wire format of each key-value pair\n  // after serialization should be the same as that of a MapEntry message\n  // containing the same key and value inside it.  However, google::protobuf::Map doesn't\n  // store key and value as MapEntry message, which disables us to use existing\n  // code to serialize message. In order to use existing code to serialize\n  // message, we need to construct a MapEntry from key-value pair. But it\n  // involves copy of key and value to construct a MapEntry. In order to avoid\n  // this copy in constructing a MapEntry, we need the following class which\n  // only takes references of given key and value.\n  template <typename K, typename V, WireFormatLite::FieldType k_wire_type,\n            WireFormatLite::FieldType v_wire_type, int default_enum>\n  class MapEntryWrapper\n      : public MapEntryLite<K, V, k_wire_type, v_wire_type, default_enum> {\n    typedef MapEntryLite<K, V, k_wire_type, v_wire_type, default_enum> Base;\n    typedef typename Base::KeyMapEntryAccessorType KeyMapEntryAccessorType;\n    typedef typename Base::ValueMapEntryAccessorType ValueMapEntryAccessorType;\n\n   public:\n    MapEntryWrapper(Arena* arena, const K& key, const V& value)\n        : MapEntryLite<K, V, k_wire_type, v_wire_type, default_enum>(arena),\n          key_(key),\n          value_(value) {\n      Base::set_has_key();\n      Base::set_has_value();\n    }\n    inline const KeyMapEntryAccessorType& key() const { return key_; }\n    inline const ValueMapEntryAccessorType& value() const { return value_; }\n\n   private:\n    const Key& key_;\n    const Value& value_;\n\n    friend class ::google::protobuf::Arena;\n    typedef void InternalArenaConstructable_;\n    typedef void DestructorSkippable_;\n  };\n\n  // Like above, but for enum value only, which stores value instead of\n  // reference of value field inside. This is needed because the type of value\n  // field in constructor is an enum, while we need to store it as an int. If we\n  // initialize a reference to int with a reference to enum, compiler will\n  // generate a temporary int from enum and initialize the reference to int with\n  // the temporary.\n  template <typename K, typename V, WireFormatLite::FieldType k_wire_type,\n            WireFormatLite::FieldType v_wire_type, int default_enum>\n  class MapEnumEntryWrapper\n      : public MapEntryLite<K, V, k_wire_type, v_wire_type, default_enum> {\n    typedef MapEntryLite<K, V, k_wire_type, v_wire_type, default_enum> Base;\n    typedef typename Base::KeyMapEntryAccessorType KeyMapEntryAccessorType;\n    typedef typename Base::ValueMapEntryAccessorType ValueMapEntryAccessorType;\n\n   public:\n    MapEnumEntryWrapper(Arena* arena, const K& key, const V& value)\n        : MapEntryLite<K, V, k_wire_type, v_wire_type, default_enum>(arena),\n          key_(key),\n          value_(value) {\n      Base::set_has_key();\n      Base::set_has_value();\n    }\n    inline const KeyMapEntryAccessorType& key() const { return key_; }\n    inline const ValueMapEntryAccessorType& value() const { return value_; }\n\n   private:\n    const KeyMapEntryAccessorType& key_;\n    const ValueMapEntryAccessorType value_;\n\n    friend class google::protobuf::Arena;\n    typedef void DestructorSkippable_;\n  };\n\n  MapEntryLite() : default_instance_(NULL), arena_(NULL) {\n    KeyTypeHandler::Initialize(&key_, NULL);\n    ValueTypeHandler::InitializeMaybeByDefaultEnum(\n        &value_, default_enum_value, NULL);\n    _has_bits_[0] = 0;\n  }\n\n  explicit MapEntryLite(Arena* arena)\n      : default_instance_(NULL), arena_(arena) {\n    KeyTypeHandler::Initialize(&key_, arena);\n    ValueTypeHandler::InitializeMaybeByDefaultEnum(\n        &value_, default_enum_value, arena);\n    _has_bits_[0] = 0;\n  }\n\n  inline Arena* GetArenaNoVirtual() const {\n    return arena_;\n  }\n\n  void set_default_instance(MapEntryLite* default_instance) {\n    default_instance_ = default_instance;\n  }\n\n  MapEntryLite* default_instance_;\n\n  KeyOnMemory key_;\n  ValueOnMemory value_;\n  Arena* arena_;\n  uint32 _has_bits_[1];\n\n  friend class ::google::protobuf::Arena;\n  typedef void InternalArenaConstructable_;\n  typedef void DestructorSkippable_;\n  template <typename K, typename V, WireFormatLite::FieldType,\n            WireFormatLite::FieldType, int>\n  friend class internal::MapEntry;\n  template <typename K, typename V, WireFormatLite::FieldType,\n            WireFormatLite::FieldType, int>\n  friend class internal::MapFieldLite;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapEntryLite);\n};\n\n// Helpers for deterministic serialization =============================\n\n// This struct can be used with any generic sorting algorithm.  If the Key\n// type is relatively small and easy to copy then copying Keys into an\n// array of SortItems can be beneficial.  Then all the data the sorting\n// algorithm needs to touch is in that one array.\ntemplate <typename Key, typename PtrToKeyValuePair> struct SortItem {\n  SortItem() {}\n  explicit SortItem(PtrToKeyValuePair p) : first(p->first), second(p) {}\n\n  Key first;\n  PtrToKeyValuePair second;\n};\n\ntemplate <typename T> struct CompareByFirstField {\n  bool operator()(const T& a, const T& b) const {\n    return a.first < b.first;\n  }\n};\n\ntemplate <typename T> struct CompareByDerefFirst {\n  bool operator()(const T& a, const T& b) const {\n    return a->first < b->first;\n  }\n};\n\n}  // namespace internal\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_MAP_ENTRY_LITE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/map_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/map_field.h>\n#include <google/protobuf/map_field_inl.h>\n\n#include <vector>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\nProtobufOnceType map_entry_default_instances_once_;\nMutex* map_entry_default_instances_mutex_;\nvector<MessageLite*>* map_entry_default_instances_;\n\nvoid DeleteMapEntryDefaultInstances() {\n  for (int i = 0; i < map_entry_default_instances_->size(); ++i) {\n    delete map_entry_default_instances_->at(i);\n  }\n  delete map_entry_default_instances_mutex_;\n  delete map_entry_default_instances_;\n}\n\nvoid InitMapEntryDefaultInstances() {\n  map_entry_default_instances_mutex_ = new Mutex();\n  map_entry_default_instances_ = new vector<MessageLite*>();\n  OnShutdown(&DeleteMapEntryDefaultInstances);\n}\n\nvoid RegisterMapEntryDefaultInstance(MessageLite* default_instance) {\n  ::google::protobuf::GoogleOnceInit(&map_entry_default_instances_once_,\n                 &InitMapEntryDefaultInstances);\n  MutexLock lock(map_entry_default_instances_mutex_);\n  map_entry_default_instances_->push_back(default_instance);\n}\n\nMapFieldBase::~MapFieldBase() {\n  if (repeated_field_ != NULL && arena_ == NULL) delete repeated_field_;\n}\n\nconst RepeatedPtrFieldBase& MapFieldBase::GetRepeatedField() const {\n  SyncRepeatedFieldWithMap();\n  return *repeated_field_;\n}\n\nRepeatedPtrFieldBase* MapFieldBase::MutableRepeatedField() {\n  SyncRepeatedFieldWithMap();\n  SetRepeatedDirty();\n  return repeated_field_;\n}\n\nint MapFieldBase::SpaceUsedExcludingSelf() const {\n  mutex_.Lock();\n  int size = SpaceUsedExcludingSelfNoLock();\n  mutex_.Unlock();\n  return size;\n}\n\nint MapFieldBase::SpaceUsedExcludingSelfNoLock() const {\n  if (repeated_field_ != NULL) {\n    return repeated_field_->SpaceUsedExcludingSelf();\n  } else {\n    return 0;\n  }\n}\n\nvoid MapFieldBase::InitMetadataOnce() const {\n  GOOGLE_CHECK(entry_descriptor_ != NULL);\n  GOOGLE_CHECK(assign_descriptor_callback_ != NULL);\n  (*assign_descriptor_callback_)();\n}\n\nvoid MapFieldBase::SetMapDirty() { state_ = STATE_MODIFIED_MAP; }\n\nvoid MapFieldBase::SetRepeatedDirty() { state_ = STATE_MODIFIED_REPEATED; }\n\nvoid* MapFieldBase::MutableRepeatedPtrField() const { return repeated_field_; }\n\nvoid MapFieldBase::SyncRepeatedFieldWithMap() const {\n  // \"Acquire\" insures the operation after SyncRepeatedFieldWithMap won't get\n  // executed before state_ is checked.\n  Atomic32 state = google::protobuf::internal::Acquire_Load(&state_);\n  if (state == STATE_MODIFIED_MAP) {\n    mutex_.Lock();\n    // Double check state, because another thread may have seen the same state\n    // and done the synchronization before the current thread.\n    if (state_ == STATE_MODIFIED_MAP) {\n      SyncRepeatedFieldWithMapNoLock();\n      // \"Release\" insures state_ can only be changed \"after\"\n      // SyncRepeatedFieldWithMapNoLock is finished.\n      google::protobuf::internal::Release_Store(&state_, CLEAN);\n    }\n    mutex_.Unlock();\n  }\n}\n\nvoid MapFieldBase::SyncRepeatedFieldWithMapNoLock() const {\n  if (repeated_field_ == NULL) {\n    repeated_field_ = Arena::CreateMessage<RepeatedPtrField<Message> >(arena_);\n  }\n}\n\nvoid MapFieldBase::SyncMapWithRepeatedField() const {\n  // \"Acquire\" insures the operation after SyncMapWithRepeatedField won't get\n  // executed before state_ is checked.\n  Atomic32 state = google::protobuf::internal::Acquire_Load(&state_);\n  if (state == STATE_MODIFIED_REPEATED) {\n    mutex_.Lock();\n    // Double check state, because another thread may have seen the same state\n    // and done the synchronization before the current thread.\n    if (state_ == STATE_MODIFIED_REPEATED) {\n      SyncMapWithRepeatedFieldNoLock();\n      // \"Release\" insures state_ can only be changed \"after\"\n      // SyncRepeatedFieldWithMapNoLock is finished.\n      google::protobuf::internal::Release_Store(&state_, CLEAN);\n    }\n    mutex_.Unlock();\n  }\n}\n\n// ------------------DynamicMapField------------------\nDynamicMapField::DynamicMapField(const Message* default_entry)\n    : default_entry_(default_entry) {\n}\n\nDynamicMapField::DynamicMapField(const Message* default_entry,\n                                 Arena* arena)\n    : TypeDefinedMapFieldBase<MapKey, MapValueRef>(arena),\n      default_entry_(default_entry) {\n}\n\nDynamicMapField::~DynamicMapField() {\n  // DynamicMapField owns map values. Need to delete them before clearing\n  // the map.\n  for (Map<MapKey, MapValueRef>::iterator iter = map_.begin();\n       iter != map_.end(); ++iter) {\n    iter->second.DeleteData();\n  }\n  map_.clear();\n}\n\nint DynamicMapField::size() const {\n  return GetMap().size();\n}\n\nbool DynamicMapField::ContainsMapKey(\n    const MapKey& map_key) const {\n  const Map<MapKey, MapValueRef>& map = GetMap();\n  Map<MapKey, MapValueRef>::const_iterator iter = map.find(map_key);\n  return iter != map.end();\n}\n\nbool DynamicMapField::InsertOrLookupMapValue(\n    const MapKey& map_key, MapValueRef* val) {\n  // Always use mutable map because users may change the map value by\n  // MapValueRef.\n  Map<MapKey, MapValueRef>* map = MutableMap();\n  Map<MapKey, MapValueRef>::iterator iter = map->find(map_key);\n  if (iter == map->end()) {\n    // Insert\n    MapValueRef& map_val = (*map)[map_key];\n    const FieldDescriptor* val_des =\n        default_entry_->GetDescriptor()->FindFieldByName(\"value\");\n    map_val.SetType(val_des->cpp_type());\n    // Allocate memory for the inserted MapValueRef, and initialize to\n    // default value.\n    switch (val_des->cpp_type()) {\n#define HANDLE_TYPE(CPPTYPE, TYPE)                              \\\n      case google::protobuf::FieldDescriptor::CPPTYPE_##CPPTYPE: {        \\\n        TYPE * value = new TYPE();                              \\\n        map_val.SetValue(value);                                \\\n        break;                                                  \\\n      }\n      HANDLE_TYPE(INT32, int32);\n      HANDLE_TYPE(INT64, int64);\n      HANDLE_TYPE(UINT32, uint32);\n      HANDLE_TYPE(UINT64, uint64);\n      HANDLE_TYPE(DOUBLE, double);\n      HANDLE_TYPE(FLOAT, float);\n      HANDLE_TYPE(BOOL, bool);\n      HANDLE_TYPE(STRING, string);\n      HANDLE_TYPE(ENUM, int32);\n#undef HANDLE_TYPE\n      case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE: {\n        const Message& message = default_entry_->GetReflection()->GetMessage(\n            *default_entry_, val_des);\n        Message* value = message.New();\n        map_val.SetValue(value);\n        break;\n      }\n    }\n    val->CopyFrom(map_val);\n    return true;\n  }\n  // map_key is already in the map. Make sure (*map)[map_key] is not called.\n  // [] may reorder the map and iterators.\n  val->CopyFrom(iter->second);\n  return false;\n}\n\nbool DynamicMapField::DeleteMapValue(const MapKey& map_key) {\n  MapFieldBase::SyncMapWithRepeatedField();\n  Map<MapKey, MapValueRef>::iterator iter = map_.find(map_key);\n  if (iter == map_.end()) {\n    return false;\n  }\n  // Set map dirty only if the delete is successful.\n  MapFieldBase::SetMapDirty();\n  iter->second.DeleteData();\n  map_.erase(iter);\n  return true;\n}\n\nconst Map<MapKey, MapValueRef>& DynamicMapField::GetMap() const {\n  MapFieldBase::SyncMapWithRepeatedField();\n  return map_;\n}\n\nMap<MapKey, MapValueRef>* DynamicMapField::MutableMap() {\n  MapFieldBase::SyncMapWithRepeatedField();\n  MapFieldBase::SetMapDirty();\n  return &map_;\n}\n\nvoid DynamicMapField::SetMapIteratorValue(MapIterator* map_iter) const {\n  Map<MapKey, MapValueRef>::const_iterator iter =\n      TypeDefinedMapFieldBase<MapKey, MapValueRef>::InternalGetIterator(\n          map_iter);\n  if (iter == map_.end()) return;\n  map_iter->key_.CopyFrom(iter->first);\n  map_iter->value_.CopyFrom(iter->second);\n}\n\nvoid DynamicMapField::SyncRepeatedFieldWithMapNoLock() const {\n  const Reflection* reflection = default_entry_->GetReflection();\n  const FieldDescriptor* key_des =\n      default_entry_->GetDescriptor()->FindFieldByName(\"key\");\n  const FieldDescriptor* val_des =\n      default_entry_->GetDescriptor()->FindFieldByName(\"value\");\n  if (MapFieldBase::repeated_field_ == NULL) {\n    if (MapFieldBase::arena_ == NULL) {\n      MapFieldBase::repeated_field_ = new RepeatedPtrField<Message>();\n    } else {\n      MapFieldBase::repeated_field_ =\n          Arena::CreateMessage<RepeatedPtrField<Message> >(\n              MapFieldBase::arena_);\n    }\n  }\n\n  MapFieldBase::repeated_field_->Clear();\n\n  for (Map<MapKey, MapValueRef>::const_iterator it = map_.begin();\n       it != map_.end(); ++it) {\n    Message* new_entry = default_entry_->New();\n    MapFieldBase::repeated_field_->AddAllocated(new_entry);\n    const MapKey& map_key = it->first;\n    switch (key_des->cpp_type()) {\n      case google::protobuf::FieldDescriptor::CPPTYPE_STRING:\n        reflection->SetString(new_entry, key_des, map_key.GetStringValue());\n        break;\n      case google::protobuf::FieldDescriptor::CPPTYPE_INT64:\n        reflection->SetInt64(new_entry, key_des, map_key.GetInt64Value());\n        break;\n      case google::protobuf::FieldDescriptor::CPPTYPE_INT32:\n        reflection->SetInt32(new_entry, key_des, map_key.GetInt32Value());\n        break;\n      case google::protobuf::FieldDescriptor::CPPTYPE_UINT64:\n        reflection->SetUInt64(new_entry, key_des, map_key.GetUInt64Value());\n        break;\n      case google::protobuf::FieldDescriptor::CPPTYPE_UINT32:\n        reflection->SetUInt32(new_entry, key_des, map_key.GetUInt32Value());\n        break;\n      case google::protobuf::FieldDescriptor::CPPTYPE_BOOL:\n        reflection->SetBool(new_entry, key_des, map_key.GetBoolValue());\n        break;\n      case google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE:\n      case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT:\n      case google::protobuf::FieldDescriptor::CPPTYPE_ENUM:\n      case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE:\n        GOOGLE_LOG(FATAL) << \"Can't get here.\";\n        break;\n    }\n    const MapValueRef& map_val = it->second;\n    switch (val_des->cpp_type()) {\n      case google::protobuf::FieldDescriptor::CPPTYPE_STRING:\n        reflection->SetString(new_entry, val_des, map_val.GetStringValue());\n        break;\n      case google::protobuf::FieldDescriptor::CPPTYPE_INT64:\n        reflection->SetInt64(new_entry, val_des, map_val.GetInt64Value());\n        break;\n      case google::protobuf::FieldDescriptor::CPPTYPE_INT32:\n        reflection->SetInt32(new_entry, val_des, map_val.GetInt32Value());\n        break;\n      case google::protobuf::FieldDescriptor::CPPTYPE_UINT64:\n        reflection->SetUInt64(new_entry, val_des, map_val.GetUInt64Value());\n        break;\n      case google::protobuf::FieldDescriptor::CPPTYPE_UINT32:\n        reflection->SetUInt32(new_entry, val_des, map_val.GetUInt32Value());\n        break;\n      case google::protobuf::FieldDescriptor::CPPTYPE_BOOL:\n        reflection->SetBool(new_entry, val_des, map_val.GetBoolValue());\n        break;\n      case google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE:\n        reflection->SetDouble(new_entry, val_des, map_val.GetDoubleValue());\n        break;\n      case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT:\n        reflection->SetFloat(new_entry, val_des, map_val.GetFloatValue());\n        break;\n      case google::protobuf::FieldDescriptor::CPPTYPE_ENUM:\n        reflection->SetEnumValue(new_entry, val_des, map_val.GetEnumValue());\n        break;\n      case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE: {\n        const Message& message = map_val.GetMessageValue();\n        reflection->MutableMessage(new_entry, val_des)->CopyFrom(message);\n        break;\n      }\n    }\n  }\n}\n\nvoid DynamicMapField::SyncMapWithRepeatedFieldNoLock() const {\n  Map<MapKey, MapValueRef>* map = &const_cast<DynamicMapField*>(this)->map_;\n  const Reflection* reflection = default_entry_->GetReflection();\n  const FieldDescriptor* key_des =\n      default_entry_->GetDescriptor()->FindFieldByName(\"key\");\n  const FieldDescriptor* val_des =\n      default_entry_->GetDescriptor()->FindFieldByName(\"value\");\n  // DynamicMapField owns map values. Need to delete them before clearing\n  // the map.\n  for (Map<MapKey, MapValueRef>::iterator iter = map->begin();\n       iter != map->end(); ++iter) {\n    iter->second.DeleteData();\n  }\n  map->clear();\n  for (RepeatedPtrField<Message>::iterator it =\n           MapFieldBase::repeated_field_->begin();\n       it != MapFieldBase::repeated_field_->end(); ++it) {\n    MapKey map_key;\n    switch (key_des->cpp_type()) {\n      case google::protobuf::FieldDescriptor::CPPTYPE_STRING:\n        map_key.SetStringValue(reflection->GetString(*it, key_des));\n        break;\n      case google::protobuf::FieldDescriptor::CPPTYPE_INT64:\n        map_key.SetInt64Value(reflection->GetInt64(*it, key_des));\n        break;\n      case google::protobuf::FieldDescriptor::CPPTYPE_INT32:\n        map_key.SetInt32Value(reflection->GetInt32(*it, key_des));\n        break;\n      case google::protobuf::FieldDescriptor::CPPTYPE_UINT64:\n        map_key.SetUInt64Value(reflection->GetUInt64(*it, key_des));\n        break;\n      case google::protobuf::FieldDescriptor::CPPTYPE_UINT32:\n        map_key.SetUInt32Value(reflection->GetUInt32(*it, key_des));\n        break;\n      case google::protobuf::FieldDescriptor::CPPTYPE_BOOL:\n        map_key.SetBoolValue(reflection->GetBool(*it, key_des));\n        break;\n      case google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE:\n      case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT:\n      case google::protobuf::FieldDescriptor::CPPTYPE_ENUM:\n      case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE:\n        GOOGLE_LOG(FATAL) << \"Can't get here.\";\n        break;\n    }\n    MapValueRef& map_val = (*map)[map_key];\n    map_val.SetType(val_des->cpp_type());\n    switch (val_des->cpp_type()) {\n#define HANDLE_TYPE(CPPTYPE, TYPE, METHOD)                      \\\n      case google::protobuf::FieldDescriptor::CPPTYPE_##CPPTYPE: {        \\\n        TYPE * value = new TYPE;                                \\\n        *value = reflection->Get##METHOD(*it, val_des);         \\\n            map_val.SetValue(value);                            \\\n            break;                                              \\\n      }\n      HANDLE_TYPE(INT32, int32, Int32);\n      HANDLE_TYPE(INT64, int64, Int64);\n      HANDLE_TYPE(UINT32, uint32, UInt32);\n      HANDLE_TYPE(UINT64, uint64, UInt64);\n      HANDLE_TYPE(DOUBLE, double, Double);\n      HANDLE_TYPE(FLOAT, float, Float);\n      HANDLE_TYPE(BOOL, bool, Bool);\n      HANDLE_TYPE(STRING, string, String);\n      HANDLE_TYPE(ENUM, int32, EnumValue);\n#undef HANDLE_TYPE\n      case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE: {\n        const Message& message = reflection->GetMessage(*it, val_des);\n        Message* value = message.New();\n        value->CopyFrom(message);\n        map_val.SetValue(value);\n        break;\n      }\n    }\n  }\n}\n\nint DynamicMapField::SpaceUsedExcludingSelfNoLock() const {\n  int size = 0;\n  if (MapFieldBase::repeated_field_ != NULL) {\n    size += MapFieldBase::repeated_field_->SpaceUsedExcludingSelf();\n  }\n  size += sizeof(map_);\n  int map_size = map_.size();\n  if (map_size) {\n    Map<MapKey, MapValueRef>::const_iterator it = map_.begin();\n    size += sizeof(it->first) * map_size;\n    size += sizeof(it->second) * map_size;\n    // If key is string, add the allocated space.\n    if (it->first.type() == google::protobuf::FieldDescriptor::CPPTYPE_STRING) {\n      size += sizeof(string) * map_size;\n    }\n    // Add the allocated space in MapValueRef.\n    switch (it->second.type()) {\n#define HANDLE_TYPE(CPPTYPE, TYPE)                              \\\n      case google::protobuf::FieldDescriptor::CPPTYPE_##CPPTYPE: {        \\\n        size += sizeof(TYPE) * map_size;                        \\\n        break;                                                  \\\n      }\n      HANDLE_TYPE(INT32, int32);\n      HANDLE_TYPE(INT64, int64);\n      HANDLE_TYPE(UINT32, uint32);\n      HANDLE_TYPE(UINT64, uint64);\n      HANDLE_TYPE(DOUBLE, double);\n      HANDLE_TYPE(FLOAT, float);\n      HANDLE_TYPE(BOOL, bool);\n      HANDLE_TYPE(STRING, string);\n      HANDLE_TYPE(ENUM, int32);\n#undef HANDLE_TYPE\n      case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE: {\n        while (it != map_.end()) {\n          const Message& message = it->second.GetMessageValue();\n          size += message.GetReflection()->SpaceUsed(message);\n          ++it;\n        }\n        break;\n      }\n    }\n  }\n  return size;\n}\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/map_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_MAP_FIELD_H__\n#define GOOGLE_PROTOBUF_MAP_FIELD_H__\n\n#include <google/protobuf/stubs/atomicops.h>\n#include <google/protobuf/stubs/mutex.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/generated_message_reflection.h>\n#include <google/protobuf/arena.h>\n#include <google/protobuf/map_entry.h>\n#include <google/protobuf/map_field_lite.h>\n#include <google/protobuf/map_type_handler.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/unknown_field_set.h>\n\n\nnamespace google {\nnamespace protobuf {\nclass DynamicMessage;\nclass MapKey;\nnamespace internal {\n\nclass ContendedMapCleanTest;\nclass GeneratedMessageReflection;\nclass MapFieldAccessor;\n\n// This class provides access to map field using reflection, which is the same\n// as those provided for RepeatedPtrField<Message>. It is used for internal\n// reflection implentation only. Users should never use this directly.\nclass LIBPROTOBUF_EXPORT MapFieldBase {\n public:\n  MapFieldBase()\n      : arena_(NULL),\n        repeated_field_(NULL),\n        entry_descriptor_(NULL),\n        assign_descriptor_callback_(NULL),\n        state_(STATE_MODIFIED_MAP) {}\n  explicit MapFieldBase(Arena* arena)\n      : arena_(arena),\n        repeated_field_(NULL),\n        entry_descriptor_(NULL),\n        assign_descriptor_callback_(NULL),\n        state_(STATE_MODIFIED_MAP) {\n    // Mutex's destructor needs to be called explicitly to release resources\n    // acquired in its constructor.\n    arena->OwnDestructor(&mutex_);\n  }\n  virtual ~MapFieldBase();\n\n  // Returns reference to internal repeated field. Data written using\n  // google::protobuf::Map's api prior to calling this function is guarantted to be\n  // included in repeated field.\n  const RepeatedPtrFieldBase& GetRepeatedField() const;\n\n  // Like above. Returns mutable pointer to the internal repeated field.\n  RepeatedPtrFieldBase* MutableRepeatedField();\n\n  // Pure virtual map APIs for Map Reflection.\n  virtual bool ContainsMapKey(const MapKey& map_key) const = 0;\n  virtual bool InsertOrLookupMapValue(\n      const MapKey& map_key, MapValueRef* val) = 0;\n  virtual bool DeleteMapValue(const MapKey& map_key) = 0;\n  virtual bool EqualIterator(const MapIterator& a,\n                             const MapIterator& b) const = 0;\n  virtual void MapBegin(MapIterator* map_iter) const = 0;\n  virtual void MapEnd(MapIterator* map_iter) const = 0;\n  // Sync Map with repeated field and returns the size of map.\n  virtual int size() const = 0;\n\n  // Returns the number of bytes used by the repeated field, excluding\n  // sizeof(*this)\n  int SpaceUsedExcludingSelf() const;\n\n protected:\n  // Gets the size of space used by map field.\n  virtual int SpaceUsedExcludingSelfNoLock() const;\n\n  // Synchronizes the content in Map to RepeatedPtrField if there is any change\n  // to Map after last synchronization.\n  void SyncRepeatedFieldWithMap() const;\n  virtual void SyncRepeatedFieldWithMapNoLock() const;\n\n  // Synchronizes the content in RepeatedPtrField to Map if there is any change\n  // to RepeatedPtrField after last synchronization.\n  void SyncMapWithRepeatedField() const;\n  virtual void SyncMapWithRepeatedFieldNoLock() const {}\n\n  // Tells MapFieldBase that there is new change to Map.\n  void SetMapDirty();\n\n  // Tells MapFieldBase that there is new change to RepeatedPTrField.\n  void SetRepeatedDirty();\n\n  // Provides derived class the access to repeated field.\n  void* MutableRepeatedPtrField() const;\n\n  // Creates descriptor for only one time.\n  void InitMetadataOnce() const;\n\n  enum State {\n    STATE_MODIFIED_MAP = 0,       // map has newly added data that has not been\n                                  // synchronized to repeated field\n    STATE_MODIFIED_REPEATED = 1,  // repeated field has newly added data that\n                                  // has not been synchronized to map\n    CLEAN = 2,  // data in map and repeated field are same\n  };\n\n  Arena* arena_;\n  mutable RepeatedPtrField<Message>* repeated_field_;\n  // MapEntry can only be created from MapField. To create MapEntry, MapField\n  // needs to know its descriptor, because MapEntry is not generated class which\n  // cannot initialize its own descriptor by calling generated\n  // descriptor-assign-function. Thus, we need to register a callback to\n  // initialize MapEntry's descriptor.\n  const Descriptor** entry_descriptor_;\n  void (*assign_descriptor_callback_)();\n\n  mutable Mutex mutex_;  // The thread to synchronize map and repeated field\n                         // needs to get lock first;\n  mutable volatile Atomic32 state_;  // 0: STATE_MODIFIED_MAP\n                                     // 1: STATE_MODIFIED_REPEATED\n                                     // 2: CLEAN\n\n private:\n  friend class ContendedMapCleanTest;\n  friend class GeneratedMessageReflection;\n  friend class MapFieldAccessor;\n  friend class ::google::protobuf::DynamicMessage;\n\n  // Virtual helper methods for MapIterator. MapIterator doesn't have the\n  // type helper for key and value. Call these help methods to deal with\n  // different types. Real helper methods are implemented in\n  // TypeDefinedMapFieldBase.\n  friend class ::google::protobuf::MapIterator;\n  // Allocate map<...>::iterator for MapIterator.\n  virtual void InitializeIterator(MapIterator* map_iter) const = 0;\n\n  // DeleteIterator() is called by the destructor of MapIterator only.\n  // It deletes map<...>::iterator for MapIterator.\n  virtual void DeleteIterator(MapIterator* map_iter) const = 0;\n\n  // Copy the map<...>::iterator from other_iterator to\n  // this_iterator.\n  virtual void CopyIterator(MapIterator* this_iterator,\n                            const MapIterator& other_iterator) const = 0;\n\n  // IncreaseIterator() is called by operator++() of MapIterator only.\n  // It implements the ++ operator of MapIterator.\n  virtual void IncreaseIterator(MapIterator* map_iter) const = 0;\n};\n\n// This class provides common Map Reflection implementations for generated\n// message and dynamic message.\ntemplate<typename Key, typename T>\nclass TypeDefinedMapFieldBase : public MapFieldBase {\n public:\n  TypeDefinedMapFieldBase() {}\n  explicit TypeDefinedMapFieldBase(Arena* arena) : MapFieldBase(arena) {}\n  ~TypeDefinedMapFieldBase() {}\n  void MapBegin(MapIterator* map_iter) const;\n  void MapEnd(MapIterator* map_iter) const;\n  bool EqualIterator(const MapIterator& a, const MapIterator& b) const;\n\n  virtual const Map<Key, T>& GetMap() const = 0;\n  virtual Map<Key, T>* MutableMap() = 0;\n\n protected:\n  typename Map<Key, T>::const_iterator& InternalGetIterator(\n      const MapIterator* map_iter) const;\n\n private:\n  void InitializeIterator(MapIterator* map_iter) const;\n  void DeleteIterator(MapIterator* map_iter) const;\n  void CopyIterator(MapIterator* this_iteratorm,\n                    const MapIterator& that_iterator) const;\n  void IncreaseIterator(MapIterator* map_iter) const;\n\n  virtual void SetMapIteratorValue(MapIterator* map_iter) const = 0;\n};\n\n// This class provides access to map field using generated api. It is used for\n// internal generated message implentation only. Users should never use this\n// directly.\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value = 0>\nclass MapField : public TypeDefinedMapFieldBase<Key, T>,\n                 public MapFieldLite<Key, T, kKeyFieldType, kValueFieldType,\n                                     default_enum_value> {\n  // Provide utilities to parse/serialize key/value.  Provide utilities to\n  // manipulate internal stored type.\n  typedef MapTypeHandler<kKeyFieldType, Key> KeyTypeHandler;\n  typedef MapTypeHandler<kValueFieldType, T> ValueTypeHandler;\n\n  // Define message type for internal repeated field.\n  typedef MapEntry<Key, T, kKeyFieldType, kValueFieldType, default_enum_value>\n      EntryType;\n  typedef MapEntryLite<Key, T, kKeyFieldType, kValueFieldType,\n                       default_enum_value> EntryLiteType;\n\n  // Define abbreviation for parent MapFieldLite\n  typedef MapFieldLite<Key, T, kKeyFieldType, kValueFieldType,\n                       default_enum_value> MapFieldLiteType;\n\n  // Enum needs to be handled differently from other types because it has\n  // different exposed type in google::protobuf::Map's api and repeated field's api. For\n  // details see the comment in the implementation of\n  // SyncMapWithRepeatedFieldNoLock.\n  static const bool kIsValueEnum = ValueTypeHandler::kIsEnum;\n  typedef typename MapIf<kIsValueEnum, T, const T&>::type CastValueType;\n\n public:\n  MapField();\n  explicit MapField(Arena* arena);\n  // MapField doesn't own the default_entry, which means default_entry must\n  // outlive the lifetime of MapField.\n  MapField(const Message* default_entry);\n  // For tests only.\n  MapField(Arena* arena, const Message* default_entry);\n  ~MapField();\n\n  // Implement MapFieldBase\n  bool ContainsMapKey(const MapKey& map_key) const;\n  bool InsertOrLookupMapValue(const MapKey& map_key, MapValueRef* val);\n  bool DeleteMapValue(const MapKey& map_key);\n\n  // Accessors\n  const Map<Key, T>& GetMap() const;\n  Map<Key, T>* MutableMap();\n\n  // Convenient methods for generated message implementation.\n  int size() const;\n  void Clear();\n  void MergeFrom(const MapFieldLiteType& other);\n  void Swap(MapFieldLiteType* other);\n\n  // Allocates metadata only if this MapField is part of a generated message.\n  void SetEntryDescriptor(const Descriptor** descriptor);\n  void SetAssignDescriptorCallback(void (*callback)());\n\n private:\n  typedef void InternalArenaConstructable_;\n  typedef void DestructorSkippable_;\n\n  // MapField needs MapEntry's default instance to create new MapEntry.\n  void InitDefaultEntryOnce() const;\n\n  // Manually set default entry instance. For test only.\n  void SetDefaultEntryOnce(const EntryType* default_entry) const;\n\n  // Convenient methods to get internal google::protobuf::Map\n  const Map<Key, T>& GetInternalMap() const;\n  Map<Key, T>* MutableInternalMap();\n\n  // Implements MapFieldBase\n  void SyncRepeatedFieldWithMapNoLock() const;\n  void SyncMapWithRepeatedFieldNoLock() const;\n  int SpaceUsedExcludingSelfNoLock() const;\n\n  void SetMapIteratorValue(MapIterator* map_iter) const;\n\n  mutable const EntryType* default_entry_;\n\n  friend class ::google::protobuf::Arena;\n};\n\nclass LIBPROTOBUF_EXPORT DynamicMapField: public TypeDefinedMapFieldBase<MapKey, MapValueRef> {\n public:\n  explicit DynamicMapField(const Message* default_entry);\n  DynamicMapField(const Message* default_entry, Arena* arena);\n  ~DynamicMapField();\n\n  // Implement MapFieldBase\n  bool ContainsMapKey(const MapKey& map_key) const;\n  bool InsertOrLookupMapValue(const MapKey& map_key, MapValueRef* val);\n  bool DeleteMapValue(const MapKey& map_key);\n\n  const Map<MapKey, MapValueRef>& GetMap() const;\n  Map<MapKey, MapValueRef>* MutableMap();\n\n  int size() const;\n\n private:\n  Map<MapKey, MapValueRef> map_;\n  const Message* default_entry_;\n\n  // Implements MapFieldBase\n  void SyncRepeatedFieldWithMapNoLock() const;\n  void SyncMapWithRepeatedFieldNoLock() const;\n  int SpaceUsedExcludingSelfNoLock() const;\n  void SetMapIteratorValue(MapIterator* map_iter) const;\n};\n\n}  // namespace internal\n\nclass LIBPROTOBUF_EXPORT MapIterator {\n public:\n  MapIterator(Message* message, const FieldDescriptor* field) {\n    const Reflection* reflection = message->GetReflection();\n    map_ = reflection->MapData(message, field);\n    key_.SetType(field->message_type()->FindFieldByName(\"key\")->cpp_type());\n    value_.SetType(field->message_type()->FindFieldByName(\"value\")->cpp_type());\n    map_->InitializeIterator(this);\n  }\n  MapIterator(const MapIterator& other) {\n    map_ = other.map_;\n    map_->InitializeIterator(this);\n    map_->CopyIterator(this, other);\n  }\n  ~MapIterator() {\n    map_->DeleteIterator(this);\n  }\n  friend bool operator==(const MapIterator& a, const MapIterator& b) {\n    return a.map_->EqualIterator(a, b);\n  }\n  friend bool operator!=(const MapIterator& a, const MapIterator& b) {\n    return !a.map_->EqualIterator(a, b);\n  }\n  MapIterator& operator++() {\n    map_->IncreaseIterator(this);\n    return *this;\n  }\n  MapIterator operator++(int) {\n    // iter_ is copied from Map<...>::iterator, no need to\n    // copy from its self again. Use the same implementation\n    // with operator++()\n    map_->IncreaseIterator(this);\n    return *this;\n  }\n  const MapKey& GetKey() {\n    return key_;\n  }\n  const MapValueRef& GetValueRef() {\n    return value_;\n  }\n  MapValueRef* MutableValueRef() {\n    map_->SetMapDirty();\n    return &value_;\n  }\n\n private:\n  template <typename Key, typename T>\n  friend class internal::TypeDefinedMapFieldBase;\n  friend class internal::DynamicMapField;\n  template <typename Key, typename T,\n            internal::WireFormatLite::FieldType kKeyFieldType,\n            internal::WireFormatLite::FieldType kValueFieldType,\n            int default_enum_value>\n  friend class internal::MapField;\n\n  // reinterpret_cast from heap-allocated Map<...>::iterator*. MapIterator owns\n  // the iterator. It is allocated by MapField<...>::InitializeIterator() called\n  // in constructor and deleted by MapField<...>::DeleteIterator() called in\n  // destructor.\n  void* iter_;\n  // Point to a MapField to call helper methods implemented in MapField.\n  // MapIterator does not own this object.\n  internal::MapFieldBase* map_;\n  MapKey key_;\n  MapValueRef value_;\n};\n\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_MAP_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/map_field_inl.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_MAP_FIELD_INL_H__\n#define GOOGLE_PROTOBUF_MAP_FIELD_INL_H__\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#include <google/protobuf/map.h>\n#include <google/protobuf/map_field.h>\n#include <google/protobuf/map_type_handler.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n// UnwrapMapKey template\ntemplate<typename T>\nT UnwrapMapKey(const MapKey& map_key);\ntemplate<>\ninline int32 UnwrapMapKey<int32>(const MapKey& map_key) {\n  return map_key.GetInt32Value();\n}\ntemplate<>\ninline uint32 UnwrapMapKey<uint32>(const MapKey& map_key) {\n  return map_key.GetUInt32Value();\n}\ntemplate<>\ninline int64 UnwrapMapKey<int64>(const MapKey& map_key) {\n  return map_key.GetInt64Value();\n}\ntemplate<>\ninline uint64 UnwrapMapKey<uint64>(const MapKey& map_key) {\n  return map_key.GetUInt64Value();\n}\ntemplate<>\ninline bool UnwrapMapKey<bool>(const MapKey& map_key) {\n  return map_key.GetBoolValue();\n}\ntemplate<>\ninline string UnwrapMapKey<string>(const MapKey& map_key) {\n  return map_key.GetStringValue();\n}\n\n// SetMapKey template\ntemplate<typename T>\ninline void SetMapKey(MapKey* map_key, const T& value);\ntemplate<>\ninline void SetMapKey<int32>(MapKey* map_key, const int32& value) {\n  map_key->SetInt32Value(value);\n}\ntemplate<>\ninline void SetMapKey<uint32>(MapKey* map_key, const uint32& value) {\n  map_key->SetUInt32Value(value);\n}\ntemplate<>\ninline void SetMapKey<int64>(MapKey* map_key, const int64& value) {\n  map_key->SetInt64Value(value);\n}\ntemplate<>\ninline void SetMapKey<uint64>(MapKey* map_key, const uint64& value) {\n  map_key->SetUInt64Value(value);\n}\ntemplate<>\ninline void SetMapKey<bool>(MapKey* map_key, const bool& value) {\n  map_key->SetBoolValue(value);\n}\ntemplate<>\ninline void SetMapKey<string>(MapKey* map_key, const string& value) {\n  map_key->SetStringValue(value);\n}\n\n// ------------------------TypeDefinedMapFieldBase---------------\ntemplate <typename Key, typename T>\ntypename Map<Key, T>::const_iterator&\nTypeDefinedMapFieldBase<Key, T>::InternalGetIterator(\n    const MapIterator* map_iter) const {\n  return *reinterpret_cast<typename Map<Key, T>::const_iterator *>(\n      map_iter->iter_);\n}\n\ntemplate <typename Key, typename T>\nvoid TypeDefinedMapFieldBase<Key, T>::MapBegin(MapIterator* map_iter) const {\n  InternalGetIterator(map_iter) = GetMap().begin();\n  SetMapIteratorValue(map_iter);\n}\n\ntemplate <typename Key, typename T>\nvoid TypeDefinedMapFieldBase<Key, T>::MapEnd(MapIterator* map_iter) const {\n  InternalGetIterator(map_iter) = GetMap().end();\n}\n\ntemplate <typename Key, typename T>\nbool TypeDefinedMapFieldBase<Key, T>::EqualIterator(const MapIterator& a,\n                                                    const MapIterator& b)\n    const {\n  return InternalGetIterator(&a) == InternalGetIterator(&b);\n}\n\ntemplate <typename Key, typename T>\nvoid TypeDefinedMapFieldBase<Key, T>::IncreaseIterator(MapIterator* map_iter)\n    const {\n  ++InternalGetIterator(map_iter);\n  SetMapIteratorValue(map_iter);\n}\n\ntemplate <typename Key, typename T>\nvoid TypeDefinedMapFieldBase<Key, T>::InitializeIterator(\n    MapIterator* map_iter) const {\n  map_iter->iter_ = new typename Map<Key, T>::const_iterator;\n  GOOGLE_CHECK(map_iter->iter_ != NULL);\n}\n\ntemplate <typename Key, typename T>\nvoid TypeDefinedMapFieldBase<Key, T>::DeleteIterator(MapIterator* map_iter)\n    const {\n  delete reinterpret_cast<typename Map<Key, T>::const_iterator *>(\n      map_iter->iter_);\n}\n\ntemplate <typename Key, typename T>\nvoid TypeDefinedMapFieldBase<Key, T>::CopyIterator(\n    MapIterator* this_iter,\n    const MapIterator& that_iter) const {\n  InternalGetIterator(this_iter) = InternalGetIterator(&that_iter);\n  this_iter->key_.SetType(that_iter.key_.type());\n  // MapValueRef::type() fails when containing data is null. However, if\n  // this_iter points to MapEnd, data can be null.\n  this_iter->value_.SetType(\n      static_cast<FieldDescriptor::CppType>(that_iter.value_.type_));\n  SetMapIteratorValue(this_iter);\n}\n\n// ----------------------------------------------------------------------\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nMapField<Key, T, kKeyFieldType, kValueFieldType, default_enum_value>::MapField()\n    : default_entry_(NULL) {}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nMapField<Key, T, kKeyFieldType, kValueFieldType, default_enum_value>::MapField(\n    Arena* arena)\n    : TypeDefinedMapFieldBase<Key, T>(arena),\n      MapFieldLite<Key, T, kKeyFieldType, kValueFieldType, default_enum_value>(\n          arena),\n      default_entry_(NULL) {}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nMapField<Key, T, kKeyFieldType, kValueFieldType, default_enum_value>::MapField(\n    const Message* default_entry)\n    : default_entry_(down_cast<const EntryType*>(default_entry)) {}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nMapField<Key, T, kKeyFieldType, kValueFieldType, default_enum_value>::MapField(\n    Arena* arena, const Message* default_entry)\n    : TypeDefinedMapFieldBase<Key, T>(arena),\n      MapFieldLite<Key, T, kKeyFieldType, kValueFieldType, default_enum_value>(\n          arena),\n      default_entry_(down_cast<const EntryType*>(default_entry)) {}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nMapField<Key, T, kKeyFieldType, kValueFieldType,\n         default_enum_value>::~MapField() {}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nint\nMapField<Key, T, kKeyFieldType, kValueFieldType,\n         default_enum_value>::size() const {\n  MapFieldBase::SyncMapWithRepeatedField();\n  return MapFieldLiteType::GetInternalMap().size();\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nvoid\nMapField<Key, T, kKeyFieldType, kValueFieldType,\n         default_enum_value>::Clear() {\n  MapFieldBase::SyncMapWithRepeatedField();\n  MapFieldLiteType::MutableInternalMap()->clear();\n  MapFieldBase::SetMapDirty();\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nvoid MapField<Key, T, kKeyFieldType, kValueFieldType,\n              default_enum_value>::SetMapIteratorValue(\n                  MapIterator* map_iter) const {\n  const Map<Key, T>& map = GetMap();\n  typename Map<Key, T>::const_iterator iter =\n      TypeDefinedMapFieldBase<Key, T>::InternalGetIterator(map_iter);\n  if (iter == map.end()) return;\n  SetMapKey(&map_iter->key_, iter->first);\n  map_iter->value_.SetValue(&iter->second);\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nbool MapField<Key, T, kKeyFieldType, kValueFieldType,\n              default_enum_value>::ContainsMapKey(\n                  const MapKey& map_key) const {\n  const Map<Key, T>& map = GetMap();\n  const Key& key = UnwrapMapKey<Key>(map_key);\n  typename Map<Key, T>::const_iterator iter = map.find(key);\n  return iter != map.end();\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nbool MapField<Key, T, kKeyFieldType, kValueFieldType,\n              default_enum_value>::InsertOrLookupMapValue(\n                  const MapKey& map_key,\n                  MapValueRef* val) {\n  // Always use mutable map because users may change the map value by\n  // MapValueRef.\n  Map<Key, T>* map = MutableMap();\n  const Key& key = UnwrapMapKey<Key>(map_key);\n  typename Map<Key, T>::iterator iter = map->find(key);\n  if (map->end() == iter) {\n    val->SetValue(&((*map)[key]));\n    return true;\n  }\n  // Key is already in the map. Make sure (*map)[key] is not called.\n  // [] may reorder the map and iterators.\n  val->SetValue(&(iter->second));\n  return false;\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nbool MapField<Key, T, kKeyFieldType, kValueFieldType,\n              default_enum_value>::DeleteMapValue(\n                  const MapKey& map_key) {\n  const Key& key = UnwrapMapKey<Key>(map_key);\n  return MutableMap()->erase(key);\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nconst Map<Key, T>&\nMapField<Key, T, kKeyFieldType, kValueFieldType,\n         default_enum_value>::GetMap() const {\n  MapFieldBase::SyncMapWithRepeatedField();\n  return MapFieldLiteType::GetInternalMap();\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nMap<Key, T>*\nMapField<Key, T, kKeyFieldType, kValueFieldType,\n         default_enum_value>::MutableMap() {\n  MapFieldBase::SyncMapWithRepeatedField();\n  Map<Key, T>* result = MapFieldLiteType::MutableInternalMap();\n  MapFieldBase::SetMapDirty();\n  return result;\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nvoid\nMapField<Key, T, kKeyFieldType, kValueFieldType,\n         default_enum_value>::MergeFrom(\n    const MapFieldLiteType& other) {\n  const MapField& down_other = down_cast<const MapField&>(other);\n  MapFieldBase::SyncMapWithRepeatedField();\n  down_other.SyncMapWithRepeatedField();\n  MapFieldLiteType::MergeFrom(other);\n  MapFieldBase::SetMapDirty();\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nvoid\nMapField<Key, T, kKeyFieldType, kValueFieldType,\n         default_enum_value>::Swap(\n    MapFieldLiteType* other) {\n  MapField* down_other = down_cast<MapField*>(other);\n  std::swap(MapFieldBase::repeated_field_, down_other->repeated_field_);\n  MapFieldLiteType::Swap(other);\n  std::swap(MapFieldBase::state_, down_other->state_);\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nvoid\nMapField<Key, T, kKeyFieldType, kValueFieldType,\n         default_enum_value>::SetEntryDescriptor(\n    const Descriptor** descriptor) {\n  MapFieldBase::entry_descriptor_ = descriptor;\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nvoid\nMapField<Key, T, kKeyFieldType, kValueFieldType,\n         default_enum_value>::SetAssignDescriptorCallback(void (*callback)()) {\n  MapFieldBase::assign_descriptor_callback_ = callback;\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nconst Map<Key, T>&\nMapField<Key, T, kKeyFieldType, kValueFieldType,\n         default_enum_value>::GetInternalMap() const {\n  return MapFieldLiteType::GetInternalMap();\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nMap<Key, T>*\nMapField<Key, T, kKeyFieldType, kValueFieldType,\n         default_enum_value>::MutableInternalMap() {\n  return MapFieldLiteType::MutableInternalMap();\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nvoid\nMapField<Key, T, kKeyFieldType, kValueFieldType,\n         default_enum_value>::SyncRepeatedFieldWithMapNoLock() const {\n  if (MapFieldBase::repeated_field_ == NULL) {\n    if (MapFieldBase::arena_ == NULL) {\n      MapFieldBase::repeated_field_ = new RepeatedPtrField<Message>();\n    } else {\n      MapFieldBase::repeated_field_ =\n          Arena::CreateMessage<RepeatedPtrField<Message> >(\n              MapFieldBase::arena_);\n    }\n  }\n  const Map<Key, T>& map = GetInternalMap();\n  RepeatedPtrField<EntryType>* repeated_field =\n      reinterpret_cast<RepeatedPtrField<EntryType>*>(\n          MapFieldBase::repeated_field_);\n\n  repeated_field->Clear();\n\n  for (typename Map<Key, T>::const_iterator it = map.begin();\n       it != map.end(); ++it) {\n    InitDefaultEntryOnce();\n    GOOGLE_CHECK(default_entry_ != NULL);\n    EntryType* new_entry =\n        down_cast<EntryType*>(default_entry_->New(MapFieldBase::arena_));\n    repeated_field->AddAllocated(new_entry);\n    (*new_entry->mutable_key()) = it->first;\n    (*new_entry->mutable_value()) = it->second;\n  }\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nvoid\nMapField<Key, T, kKeyFieldType, kValueFieldType,\n         default_enum_value>::SyncMapWithRepeatedFieldNoLock() const {\n  Map<Key, T>* map = const_cast<MapField*>(this)->MutableInternalMap();\n  RepeatedPtrField<EntryType>* repeated_field =\n      reinterpret_cast<RepeatedPtrField<EntryType>*>(\n          MapFieldBase::repeated_field_);\n  GOOGLE_CHECK(MapFieldBase::repeated_field_ != NULL);\n  map->clear();\n  for (typename RepeatedPtrField<EntryType>::iterator it =\n           repeated_field->begin(); it != repeated_field->end(); ++it) {\n    // Cast is needed because Map's api and internal storage is different when\n    // value is enum. For enum, we cannot cast an int to enum. Thus, we have to\n    // copy value. For other types, they have same exposed api type and internal\n    // stored type. We should not introduce value copy for them. We achieve this\n    // by casting to value for enum while casting to reference for other types.\n    (*map)[it->key()] = static_cast<CastValueType>(it->value());\n  }\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nint\nMapField<Key, T, kKeyFieldType, kValueFieldType,\n         default_enum_value>::SpaceUsedExcludingSelfNoLock() const {\n  int size = 0;\n  if (MapFieldBase::repeated_field_ != NULL) {\n    size += MapFieldBase::repeated_field_->SpaceUsedExcludingSelf();\n  }\n  Map<Key, T>* map = const_cast<MapField*>(this)->MutableInternalMap();\n  size += sizeof(*map);\n  for (typename Map<Key, T>::iterator it = map->begin();\n       it != map->end(); ++it) {\n    size += KeyTypeHandler::SpaceUsedInMap(it->first);\n    size += ValueTypeHandler::SpaceUsedInMap(it->second);\n  }\n  return size;\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType kKeyFieldType,\n          WireFormatLite::FieldType kValueFieldType,\n          int default_enum_value>\nvoid\nMapField<Key, T, kKeyFieldType, kValueFieldType,\n         default_enum_value>::InitDefaultEntryOnce()\n    const {\n  if (default_entry_ == NULL) {\n    MapFieldBase::InitMetadataOnce();\n    GOOGLE_CHECK(*MapFieldBase::entry_descriptor_ != NULL);\n    default_entry_ = down_cast<const EntryType*>(\n        MessageFactory::generated_factory()->GetPrototype(\n            *MapFieldBase::entry_descriptor_));\n  }\n}\n\n}  // namespace internal\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_MAP_FIELD_INL_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/map_field_lite.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_MAP_FIELD_LITE_H__\n#define GOOGLE_PROTOBUF_MAP_FIELD_LITE_H__\n\n#include <google/protobuf/map.h>\n#include <google/protobuf/map_entry_lite.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\n// This class provides access to map field using generated api. It is used for\n// internal generated message implentation only. Users should never use this\n// directly.\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType key_wire_type,\n          WireFormatLite::FieldType value_wire_type,\n          int default_enum_value = 0>\nclass MapFieldLite {\n  // Define message type for internal repeated field.\n  typedef MapEntryLite<Key, T, key_wire_type, value_wire_type,\n                       default_enum_value> EntryType;\n\n public:\n  MapFieldLite();\n  explicit MapFieldLite(Arena* arena);\n  virtual ~MapFieldLite();\n\n  // Accessors\n  virtual const Map<Key, T>& GetMap() const;\n  virtual Map<Key, T>* MutableMap();\n\n  // Convenient methods for generated message implementation.\n  virtual int size() const;\n  virtual void Clear();\n  virtual void MergeFrom(const MapFieldLite& other);\n  virtual void Swap(MapFieldLite* other);\n\n  // Set default enum value only for proto2 map field whose value is enum type.\n  void SetDefaultEnumValue();\n\n  // Used in the implementation of parsing. Caller should take the ownership.\n  EntryType* NewEntry() const;\n  // Used in the implementation of serializing enum value type. Caller should\n  // take the ownership.\n  EntryType* NewEnumEntryWrapper(const Key& key, const T t) const;\n  // Used in the implementation of serializing other value types. Caller should\n  // take the ownership.\n  EntryType* NewEntryWrapper(const Key& key, const T& t) const;\n\n protected:\n  // Convenient methods to get internal google::protobuf::Map\n  virtual const Map<Key, T>& GetInternalMap() const;\n  virtual Map<Key, T>* MutableInternalMap();\n\n private:\n  typedef void DestructorSkippable_;\n\n  Arena* arena_;\n  Map<Key, T>* map_;\n\n  friend class ::google::protobuf::Arena;\n};\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType key_wire_type,\n          WireFormatLite::FieldType value_wire_type,\n          int default_enum_value>\nMapFieldLite<Key, T, key_wire_type, value_wire_type,\n             default_enum_value>::MapFieldLite()\n    : arena_(NULL) {\n  map_ = new Map<Key, T>;\n  SetDefaultEnumValue();\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType key_wire_type,\n          WireFormatLite::FieldType value_wire_type,\n          int default_enum_value>\nMapFieldLite<Key, T, key_wire_type, value_wire_type,\n             default_enum_value>::MapFieldLite(Arena* arena)\n  : arena_(arena) {\n  map_ = Arena::CreateMessage<Map<Key, T> >(arena);\n  SetDefaultEnumValue();\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType key_wire_type,\n          WireFormatLite::FieldType value_wire_type,\n          int default_enum_value>\nMapFieldLite<Key, T, key_wire_type, value_wire_type,\n             default_enum_value>::~MapFieldLite() {\n  delete map_;\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType key_wire_type,\n          WireFormatLite::FieldType value_wire_type,\n          int default_enum_value>\nconst Map<Key, T>&\nMapFieldLite<Key, T, key_wire_type, value_wire_type,\n             default_enum_value>::GetMap() const {\n  return *map_;\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType key_wire_type,\n          WireFormatLite::FieldType value_wire_type,\n          int default_enum_value>\nMap<Key, T>*\nMapFieldLite<Key, T, key_wire_type, value_wire_type,\n             default_enum_value>::MutableMap() {\n  return map_;\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType key_wire_type,\n          WireFormatLite::FieldType value_wire_type,\n          int default_enum_value>\nint\nMapFieldLite<Key, T, key_wire_type, value_wire_type,\n             default_enum_value>::size() const {\n  return map_->size();\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType key_wire_type,\n          WireFormatLite::FieldType value_wire_type,\n          int default_enum_value>\nvoid\nMapFieldLite<Key, T, key_wire_type, value_wire_type,\n             default_enum_value>::Clear() {\n  map_->clear();\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType key_wire_type,\n          WireFormatLite::FieldType value_wire_type,\n          int default_enum_value>\nvoid\nMapFieldLite<Key, T, key_wire_type, value_wire_type,\n             default_enum_value>::MergeFrom(\n    const MapFieldLite& other) {\n  for (typename Map<Key, T>::const_iterator it = other.map_->begin();\n       it != other.map_->end(); ++it) {\n    (*map_)[it->first] = it->second;\n  }\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType key_wire_type,\n          WireFormatLite::FieldType value_wire_type,\n          int default_enum_value>\nvoid\nMapFieldLite<Key, T, key_wire_type, value_wire_type,\n             default_enum_value>::Swap(\n    MapFieldLite* other) {\n  std::swap(map_, other->map_);\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType key_wire_type,\n          WireFormatLite::FieldType value_wire_type,\n          int default_enum_value>\nvoid\nMapFieldLite<Key, T, key_wire_type, value_wire_type,\n             default_enum_value>::SetDefaultEnumValue() {\n  MutableInternalMap()->SetDefaultEnumValue(default_enum_value);\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType key_wire_type,\n          WireFormatLite::FieldType value_wire_type,\n          int default_enum_value>\nconst Map<Key, T>&\nMapFieldLite<Key, T, key_wire_type, value_wire_type,\n             default_enum_value>::GetInternalMap() const {\n  return *map_;\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType key_wire_type,\n          WireFormatLite::FieldType value_wire_type,\n          int default_enum_value>\nMap<Key, T>*\nMapFieldLite<Key, T, key_wire_type, value_wire_type,\n             default_enum_value>::MutableInternalMap() {\n  return map_;\n}\n\n#define EntryType \\\n  MapEntryLite<Key, T, key_wire_type, value_wire_type, default_enum_value>\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType key_wire_type,\n          WireFormatLite::FieldType value_wire_type,\n          int default_enum_value>\nEntryType*\nMapFieldLite<Key, T, key_wire_type, value_wire_type,\n             default_enum_value>::NewEntry() const {\n  if (arena_ == NULL) {\n    return new EntryType();\n  } else {\n    return Arena::CreateMessage<EntryType>(arena_);\n  }\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType key_wire_type,\n          WireFormatLite::FieldType value_wire_type,\n          int default_enum_value>\nEntryType*\nMapFieldLite<Key, T, key_wire_type, value_wire_type,\n             default_enum_value>::NewEnumEntryWrapper(const Key& key,\n                                                      const T t) const {\n  return EntryType::EnumWrap(key, t, arena_);\n}\n\ntemplate <typename Key, typename T,\n          WireFormatLite::FieldType key_wire_type,\n          WireFormatLite::FieldType value_wire_type,\n          int default_enum_value>\nEntryType*\nMapFieldLite<Key, T, key_wire_type, value_wire_type,\n             default_enum_value>::NewEntryWrapper(const Key& key,\n                                                  const T& t) const {\n  return EntryType::Wrap(key, t, arena_);\n}\n\n#undef EntryType\n\n// True if IsInitialized() is true for value field in all elements of t. T is\n// expected to be message.  It's useful to have this helper here to keep the\n// protobuf compiler from ever having to emit loops in IsInitialized() methods.\n// We want the C++ compiler to inline this or not as it sees fit.\ntemplate <typename Key, typename T>\nbool AllAreInitialized(const Map<Key, T>& t) {\n  for (typename Map<Key, T>::const_iterator it = t.begin(); it != t.end();\n       ++it) {\n    if (!it->second.IsInitialized()) return false;\n  }\n  return true;\n}\n\n}  // namespace internal\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_MAP_FIELD_LITE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/map_field_test.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <map>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/arena.h>\n#include <google/protobuf/map.h>\n#include <google/protobuf/arena_test_util.h>\n#include <google/protobuf/map_unittest.pb.h>\n#include <google/protobuf/map_test_util.h>\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/map_field_inl.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n#include <gtest/gtest.h>\nnamespace google {\n\nnamespace protobuf {\n\nnamespace internal {\n\nusing unittest::TestAllTypes;\n\nclass MapFieldBaseStub : public MapFieldBase {\n public:\n  typedef void InternalArenaConstructable_;\n  typedef void DestructorSkippable_;\n  MapFieldBaseStub() {}\n  explicit MapFieldBaseStub(Arena* arena) : MapFieldBase(arena) {}\n  void SyncRepeatedFieldWithMap() const {\n    MapFieldBase::SyncRepeatedFieldWithMap();\n  }\n  void SyncMapWithRepeatedField() const {\n    MapFieldBase::SyncMapWithRepeatedField();\n  }\n  // Get underlined repeated field without synchronizing map.\n  RepeatedPtrField<Message>* InternalRepeatedField() {\n    return repeated_field_;\n  }\n  bool IsMapClean() { return state_ != 0; }\n  bool IsRepeatedClean() { return state_ != 1; }\n  void SetMapDirty() { state_ = 0; }\n  void SetRepeatedDirty() { state_ = 1; }\n  bool ContainsMapKey(const MapKey& map_key) const {\n    return false;\n  }\n  bool InsertOrLookupMapValue(const MapKey& map_key, MapValueRef* val) {\n    return false;\n  }\n  bool DeleteMapValue(const MapKey& map_key) {\n    return false;\n  }\n  bool EqualIterator(const MapIterator& a, const MapIterator& b) const {\n    return false;\n  }\n  int size() const { return 0; }\n  void MapBegin(MapIterator* map_iter) const {}\n  void MapEnd(MapIterator* map_iter) const {}\n  void InitializeIterator(MapIterator* map_iter) const {}\n  void DeleteIterator(MapIterator* map_iter) const {}\n  void CopyIterator(MapIterator* this_iterator,\n                    const MapIterator& other_iterator) const {}\n  void IncreaseIterator(MapIterator* map_iter) const {}\n  void SetDefaultMessageEntry(const Message* message) const {}\n  const Message* GetDefaultMessageEntry() const { return NULL; }\n};\n\nclass MapFieldBasePrimitiveTest : public ::testing::Test {\n protected:\n  typedef MapField<int32, int32, WireFormatLite::TYPE_INT32,\n                   WireFormatLite::TYPE_INT32, false> MapFieldType;\n\n  MapFieldBasePrimitiveTest() {\n    // Get descriptors\n    map_descriptor_ = unittest::TestMap::descriptor()\n                          ->FindFieldByName(\"map_int32_int32\")\n                          ->message_type();\n    key_descriptor_ = map_descriptor_->FindFieldByName(\"key\");\n    value_descriptor_ = map_descriptor_->FindFieldByName(\"value\");\n\n    // Build map field\n    default_entry_ =\n        MessageFactory::generated_factory()->GetPrototype(map_descriptor_);\n    map_field_.reset(new MapFieldType(default_entry_));\n    map_field_base_ = map_field_.get();\n    map_ = map_field_->MutableMap();\n    initial_value_map_[0] = 100;\n    initial_value_map_[1] = 101;\n    map_->insert(initial_value_map_.begin(), initial_value_map_.end());\n    EXPECT_EQ(2, map_->size());\n  }\n\n  google::protobuf::scoped_ptr<MapFieldType> map_field_;\n  MapFieldBase* map_field_base_;\n  Map<int32, int32>* map_;\n  const Descriptor* map_descriptor_;\n  const FieldDescriptor* key_descriptor_;\n  const FieldDescriptor* value_descriptor_;\n  const Message* default_entry_;\n  std::map<int32, int32> initial_value_map_;  // copy of initial values inserted\n};\n\nTEST_F(MapFieldBasePrimitiveTest, SpaceUsedExcludingSelf) {\n  EXPECT_LT(0, map_field_base_->SpaceUsedExcludingSelf());\n}\n\nTEST_F(MapFieldBasePrimitiveTest, GetRepeatedField) {\n  const RepeatedPtrField<Message>& repeated =\n      reinterpret_cast<const RepeatedPtrField<Message>&>(\n          map_field_base_->GetRepeatedField());\n  EXPECT_EQ(2, repeated.size());\n  for (int i = 0; i < repeated.size(); i++) {\n    const Message& message = repeated.Get(i);\n    int key = message.GetReflection()->GetInt32(message, key_descriptor_);\n    int value = message.GetReflection()->GetInt32(message, value_descriptor_);\n    EXPECT_EQ(value, initial_value_map_[key]);\n  }\n}\n\nTEST_F(MapFieldBasePrimitiveTest, MutableRepeatedField) {\n  RepeatedPtrField<Message>* repeated =\n      reinterpret_cast<RepeatedPtrField<Message>*>(\n          map_field_base_->MutableRepeatedField());\n  EXPECT_EQ(2, repeated->size());\n  for (int i = 0; i < repeated->size(); i++) {\n    const Message& message = repeated->Get(i);\n    int key = message.GetReflection()->GetInt32(message, key_descriptor_);\n    int value = message.GetReflection()->GetInt32(message, value_descriptor_);\n    EXPECT_EQ(value, initial_value_map_[key]);\n  }\n}\n\nTEST_F(MapFieldBasePrimitiveTest, Arena) {\n  // Allocate a large initial block to avoid mallocs during hooked test.\n  std::vector<char> arena_block(128 * 1024);\n  ArenaOptions options;\n  options.initial_block = &arena_block[0];\n  options.initial_block_size = arena_block.size();\n  Arena arena(options);\n\n  {\n    // TODO(liujisi): Re-write the test to ensure the memory for the map and\n    // repeated fields are allocated from arenas.\n    // NoHeapChecker no_heap;\n\n    MapFieldType* map_field =\n        Arena::CreateMessage<MapFieldType>(&arena, default_entry_);\n\n    // Set content in map\n    (*map_field->MutableMap())[100] = 101;\n\n    // Trigger conversion to repeated field.\n    map_field->GetRepeatedField();\n  }\n\n  {\n    // TODO(liujisi): Re-write the test to ensure the memory for the map and\n    // repeated fields are allocated from arenas.\n    // NoHeapChecker no_heap;\n\n    MapFieldBaseStub* map_field =\n        Arena::CreateMessage<MapFieldBaseStub>(&arena);\n\n    // Trigger conversion to repeated field.\n    EXPECT_TRUE(map_field->MutableRepeatedField() != NULL);\n  }\n}\n\nnamespace {\nenum State { CLEAN, MAP_DIRTY, REPEATED_DIRTY };\n}  // anonymous namespace\n\nclass MapFieldStateTest\n    : public testing::TestWithParam<State> {\n public:\n protected:\n  typedef MapField<int32, int32, WireFormatLite::TYPE_INT32,\n                   WireFormatLite::TYPE_INT32, false> MapFieldType;\n  typedef MapFieldLite<int32, int32, WireFormatLite::TYPE_INT32,\n                       WireFormatLite::TYPE_INT32, false> MapFieldLiteType;\n  MapFieldStateTest() : state_(GetParam()) {\n    // Build map field\n    const Descriptor* map_descriptor =\n        unittest::TestMap::descriptor()\n            ->FindFieldByName(\"map_int32_int32\")\n            ->message_type();\n    default_entry_ =\n        MessageFactory::generated_factory()->GetPrototype(map_descriptor);\n    map_field_.reset(new MapFieldType(default_entry_));\n    map_field_base_ = map_field_.get();\n\n    Expect(map_field_.get(), MAP_DIRTY, 0, 0, true);\n    switch (state_) {\n      case CLEAN:\n        AddOneStillClean(map_field_.get());\n        break;\n      case MAP_DIRTY:\n        MakeMapDirty(map_field_.get());\n        break;\n      case REPEATED_DIRTY:\n        MakeRepeatedDirty(map_field_.get());\n        break;\n      default:\n        break;\n    }\n  }\n\n  void AddOneStillClean(MapFieldType* map_field) {\n    MapFieldBase* map_field_base = map_field;\n    Map<int32, int32>* map = map_field->MutableMap();\n    (*map)[0] = 0;\n    map_field_base->GetRepeatedField();\n    Expect(map_field, CLEAN, 1, 1, false);\n  }\n\n  void MakeMapDirty(MapFieldType* map_field) {\n    Map<int32, int32>* map = map_field->MutableMap();\n    (*map)[0] = 0;\n    Expect(map_field, MAP_DIRTY, 1, 0, true);\n  }\n\n  void MakeRepeatedDirty(MapFieldType* map_field) {\n    MakeMapDirty(map_field);\n    MapFieldBase* map_field_base = map_field;\n    map_field_base->MutableRepeatedField();\n    Map<int32, int32>* map = implicit_cast<MapFieldLiteType*>(map_field)\n                                 ->MapFieldLiteType::MutableMap();\n    map->clear();\n\n    Expect(map_field, REPEATED_DIRTY, 0, 1, false);\n  }\n\n  void Expect(MapFieldType* map_field, State state, int map_size,\n              int repeated_size, bool is_repeated_null) {\n    MapFieldBase* map_field_base = map_field;\n    MapFieldBaseStub* stub =\n        reinterpret_cast<MapFieldBaseStub*>(map_field_base);\n\n    Map<int32, int32>* map = implicit_cast<MapFieldLiteType*>(map_field)\n                                 ->MapFieldLiteType::MutableMap();\n    RepeatedPtrField<Message>* repeated_field = stub->InternalRepeatedField();\n\n    switch (state) {\n      case MAP_DIRTY:\n        EXPECT_FALSE(stub->IsMapClean());\n        EXPECT_TRUE(stub->IsRepeatedClean());\n        break;\n      case REPEATED_DIRTY:\n        EXPECT_TRUE(stub->IsMapClean());\n        EXPECT_FALSE(stub->IsRepeatedClean());\n        break;\n      case CLEAN:\n        EXPECT_TRUE(stub->IsMapClean());\n        EXPECT_TRUE(stub->IsRepeatedClean());\n        break;\n      default:\n        FAIL();\n    }\n\n    EXPECT_EQ(map_size, map->size());\n    if (is_repeated_null) {\n      EXPECT_TRUE(repeated_field == NULL);\n    } else {\n      EXPECT_EQ(repeated_size, repeated_field->size());\n    }\n  }\n\n  google::protobuf::scoped_ptr<MapFieldType> map_field_;\n  MapFieldBase* map_field_base_;\n  State state_;\n  const Message* default_entry_;\n};\n\nINSTANTIATE_TEST_CASE_P(MapFieldStateTestInstance, MapFieldStateTest,\n                        ::testing::Values(CLEAN, MAP_DIRTY, REPEATED_DIRTY));\n\nTEST_P(MapFieldStateTest, GetMap) {\n  map_field_->GetMap();\n  if (state_ != MAP_DIRTY) {\n    Expect(map_field_.get(), CLEAN, 1, 1, false);\n  } else {\n    Expect(map_field_.get(), MAP_DIRTY, 1, 0, true);\n  }\n}\n\nTEST_P(MapFieldStateTest, MutableMap) {\n  map_field_->MutableMap();\n  if (state_ != MAP_DIRTY) {\n    Expect(map_field_.get(), MAP_DIRTY, 1, 1, false);\n  } else {\n    Expect(map_field_.get(), MAP_DIRTY, 1, 0, true);\n  }\n}\n\nTEST_P(MapFieldStateTest, MergeFromClean) {\n  MapFieldType other(default_entry_);\n  AddOneStillClean(&other);\n\n  map_field_->MergeFrom(other);\n\n  if (state_ != MAP_DIRTY) {\n    Expect(map_field_.get(), MAP_DIRTY, 1, 1, false);\n  } else {\n    Expect(map_field_.get(), MAP_DIRTY, 1, 0, true);\n  }\n\n  Expect(&other, CLEAN, 1, 1, false);\n}\n\nTEST_P(MapFieldStateTest, MergeFromMapDirty) {\n  MapFieldType other(default_entry_);\n  MakeMapDirty(&other);\n\n  map_field_->MergeFrom(other);\n\n  if (state_ != MAP_DIRTY) {\n    Expect(map_field_.get(), MAP_DIRTY, 1, 1, false);\n  } else {\n    Expect(map_field_.get(), MAP_DIRTY, 1, 0, true);\n  }\n\n  Expect(&other, MAP_DIRTY, 1, 0, true);\n}\n\nTEST_P(MapFieldStateTest, MergeFromRepeatedDirty) {\n  MapFieldType other(default_entry_);\n  MakeRepeatedDirty(&other);\n\n  map_field_->MergeFrom(other);\n\n  if (state_ != MAP_DIRTY) {\n    Expect(map_field_.get(), MAP_DIRTY, 1, 1, false);\n  } else {\n    Expect(map_field_.get(), MAP_DIRTY, 1, 0, true);\n  }\n\n  Expect(&other, CLEAN, 1, 1, false);\n}\n\nTEST_P(MapFieldStateTest, SwapClean) {\n  MapFieldType other(default_entry_);\n  AddOneStillClean(&other);\n\n  map_field_->Swap(&other);\n\n  Expect(map_field_.get(), CLEAN, 1, 1, false);\n\n  switch (state_) {\n    case CLEAN:\n      Expect(&other, CLEAN, 1, 1, false);\n      break;\n    case MAP_DIRTY:\n      Expect(&other, MAP_DIRTY, 1, 0, true);\n      break;\n    case REPEATED_DIRTY:\n      Expect(&other, REPEATED_DIRTY, 0, 1, false);\n      break;\n    default:\n      break;\n  }\n}\n\nTEST_P(MapFieldStateTest, SwapMapDirty) {\n  MapFieldType other(default_entry_);\n  MakeMapDirty(&other);\n\n  map_field_->Swap(&other);\n\n  Expect(map_field_.get(), MAP_DIRTY, 1, 0, true);\n\n  switch (state_) {\n    case CLEAN:\n      Expect(&other, CLEAN, 1, 1, false);\n      break;\n    case MAP_DIRTY:\n      Expect(&other, MAP_DIRTY, 1, 0, true);\n      break;\n    case REPEATED_DIRTY:\n      Expect(&other, REPEATED_DIRTY, 0, 1, false);\n      break;\n    default:\n      break;\n  }\n}\n\nTEST_P(MapFieldStateTest, SwapRepeatedDirty) {\n  MapFieldType other(default_entry_);\n  MakeRepeatedDirty(&other);\n\n  map_field_->Swap(&other);\n\n  Expect(map_field_.get(), REPEATED_DIRTY, 0, 1, false);\n\n  switch (state_) {\n    case CLEAN:\n      Expect(&other, CLEAN, 1, 1, false);\n      break;\n    case MAP_DIRTY:\n      Expect(&other, MAP_DIRTY, 1, 0, true);\n      break;\n    case REPEATED_DIRTY:\n      Expect(&other, REPEATED_DIRTY, 0, 1, false);\n      break;\n    default:\n      break;\n  }\n}\n\nTEST_P(MapFieldStateTest, Clear) {\n  map_field_->Clear();\n\n  if (state_ != MAP_DIRTY) {\n    Expect(map_field_.get(), MAP_DIRTY, 0, 1, false);\n  } else {\n    Expect(map_field_.get(), MAP_DIRTY, 0, 0, true);\n  }\n}\n\nTEST_P(MapFieldStateTest, SpaceUsedExcludingSelf) {\n  map_field_base_->SpaceUsedExcludingSelf();\n\n  switch (state_) {\n    case CLEAN:\n      Expect(map_field_.get(), CLEAN, 1, 1, false);\n      break;\n    case MAP_DIRTY:\n      Expect(map_field_.get(), MAP_DIRTY, 1, 0, true);\n      break;\n    case REPEATED_DIRTY:\n      Expect(map_field_.get(), REPEATED_DIRTY, 0, 1, false);\n      break;\n    default:\n      break;\n  }\n}\n\nTEST_P(MapFieldStateTest, GetMapField) {\n  map_field_base_->GetRepeatedField();\n\n  if (state_ != REPEATED_DIRTY) {\n    Expect(map_field_.get(), CLEAN, 1, 1, false);\n  } else {\n    Expect(map_field_.get(), REPEATED_DIRTY, 0, 1, false);\n  }\n}\n\nTEST_P(MapFieldStateTest, MutableMapField) {\n  map_field_base_->MutableRepeatedField();\n\n  if (state_ != REPEATED_DIRTY) {\n    Expect(map_field_.get(), REPEATED_DIRTY, 1, 1, false);\n  } else {\n    Expect(map_field_.get(), REPEATED_DIRTY, 0, 1, false);\n  }\n}\n\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/map_lite_test_util.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/map_lite_test_util.h>\n#include <google/protobuf/map_lite_unittest.pb.h>\n#include <google/protobuf/map_test_util_impl.h>\n\nnamespace google {\nnamespace protobuf {\n\nvoid MapLiteTestUtil::SetMapFields(unittest::TestMapLite* message) {\n  MapTestUtilImpl::SetMapFields<unittest::MapEnumLite,\n                                unittest::MAP_ENUM_BAR_LITE,\n                                unittest::MAP_ENUM_BAZ_LITE>(message);\n}\n\nvoid MapLiteTestUtil::SetArenaMapFields(unittest::TestArenaMapLite* message) {\n  MapTestUtilImpl::SetArenaMapFields<unittest::MapEnumLite,\n                                     unittest::MAP_ENUM_BAR_LITE,\n                                     unittest::MAP_ENUM_BAZ_LITE>(message);\n}\n\nvoid MapLiteTestUtil::SetMapFieldsInitialized(unittest::TestMapLite* message) {\n  MapTestUtilImpl::SetMapFieldsInitialized(message);\n}\n\nvoid MapLiteTestUtil::ModifyMapFields(unittest::TestMapLite* message) {\n  MapTestUtilImpl::ModifyMapFields<unittest::MapEnumLite,\n                                   unittest::MAP_ENUM_FOO_LITE>(message);\n}\n\nvoid MapLiteTestUtil::ExpectClear(const unittest::TestMapLite& message) {\n  MapTestUtilImpl::ExpectClear(message);\n}\n\nvoid MapLiteTestUtil::ExpectMapFieldsSet(const unittest::TestMapLite& message) {\n  MapTestUtilImpl::ExpectMapFieldsSet<unittest::MapEnumLite,\n                                      unittest::MAP_ENUM_BAR_LITE,\n                                      unittest::MAP_ENUM_BAZ_LITE>(message);\n}\n\nvoid MapLiteTestUtil::ExpectArenaMapFieldsSet(\n    const unittest::TestArenaMapLite& message) {\n  MapTestUtilImpl::ExpectArenaMapFieldsSet<unittest::MapEnumLite,\n                                           unittest::MAP_ENUM_BAR_LITE,\n                                           unittest::MAP_ENUM_BAZ_LITE>(\n      message);\n}\n\nvoid MapLiteTestUtil::ExpectMapFieldsSetInitialized(\n    const unittest::TestMapLite& message) {\n  MapTestUtilImpl::ExpectMapFieldsSetInitialized<unittest::MapEnumLite,\n                                                 unittest::MAP_ENUM_FOO_LITE>(\n      message);\n}\n\nvoid MapLiteTestUtil::ExpectMapFieldsModified(\n    const unittest::TestMapLite& message) {\n  MapTestUtilImpl::ExpectMapFieldsModified<unittest::MapEnumLite,\n                                           unittest::MAP_ENUM_BAR_LITE,\n                                           unittest::MAP_ENUM_FOO_LITE>(\n      message);\n}\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/map_lite_test_util.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_MAP_LITE_TEST_UTIL_H__\n#define GOOGLE_PROTOBUF_MAP_LITE_TEST_UTIL_H__\n\n#include <google/protobuf/map_lite_unittest.pb.h>\n\nnamespace google {\nnamespace protobuf {\n\nclass MapLiteTestUtil {\n public:\n  // Set every field in the TestMapLite message to a unique value.\n  static void SetMapFields(protobuf_unittest::TestMapLite* message);\n\n  // Set every field in the TestArenaMapLite message to a unique value.\n  static void SetArenaMapFields(protobuf_unittest::TestArenaMapLite* message);\n\n  // Set every field in the message to a default value.\n  static void SetMapFieldsInitialized(protobuf_unittest::TestMapLite* message);\n\n  // Modify all the map fields of the message (which should already have been\n  // initialized with SetMapFields()).\n  static void ModifyMapFields(protobuf_unittest::TestMapLite* message);\n\n  // Check that all fields have the values that they should have after\n  // SetMapFields() is called.\n  static void ExpectMapFieldsSet(const protobuf_unittest::TestMapLite& message);\n\n  // Check that all fields have the values that they should have after\n  // SetMapFields() is called for TestArenaMapLite.\n  static void ExpectArenaMapFieldsSet(\n      const protobuf_unittest::TestArenaMapLite& message);\n\n  // Check that all fields have the values that they should have after\n  // SetMapFieldsInitialized() is called.\n  static void ExpectMapFieldsSetInitialized(\n      const protobuf_unittest::TestMapLite& message);\n\n  // Expect that the message is modified as would be expected from\n  // ModifyMapFields().\n  static void ExpectMapFieldsModified(\n      const protobuf_unittest::TestMapLite& message);\n\n  // Check that all fields are empty.\n  static void ExpectClear(const protobuf_unittest::TestMapLite& message);\n};\n\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_MAP_LITE_TEST_UTIL_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/map_lite_unittest.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto2\";\n\noption cc_enable_arenas = true;\noption optimize_for = LITE_RUNTIME;\n\nimport \"google/protobuf/unittest_lite.proto\";\nimport \"google/protobuf/unittest_no_arena_lite.proto\";\n\npackage protobuf_unittest;\n\nmessage TestMapLite {\n  map<int32   , int32   > map_int32_int32       = 1;\n  map<int64   , int64   > map_int64_int64       = 2;\n  map<uint32  , uint32  > map_uint32_uint32     = 3;\n  map<uint64  , uint64  > map_uint64_uint64     = 4;\n  map<sint32  , sint32  > map_sint32_sint32     = 5;\n  map<sint64  , sint64  > map_sint64_sint64     = 6;\n  map<fixed32 , fixed32 > map_fixed32_fixed32   = 7;\n  map<fixed64 , fixed64 > map_fixed64_fixed64   = 8;\n  map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;\n  map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;\n  map<int32   , float   > map_int32_float       = 11;\n  map<int32   , double  > map_int32_double      = 12;\n  map<bool    , bool    > map_bool_bool         = 13;\n  map<string  , string  > map_string_string     = 14;\n  map<int32   , bytes   > map_int32_bytes       = 15;\n  map<int32   , MapEnumLite> map_int32_enum     = 16;\n  map<int32   , ForeignMessageLite> map_int32_foreign_message = 17;\n  map<int32, int32> teboring = 18;\n}\n\nmessage TestArenaMapLite {\n  map<int32   , int32   > map_int32_int32       = 1;\n  map<int64   , int64   > map_int64_int64       = 2;\n  map<uint32  , uint32  > map_uint32_uint32     = 3;\n  map<uint64  , uint64  > map_uint64_uint64     = 4;\n  map<sint32  , sint32  > map_sint32_sint32     = 5;\n  map<sint64  , sint64  > map_sint64_sint64     = 6;\n  map<fixed32 , fixed32 > map_fixed32_fixed32   = 7;\n  map<fixed64 , fixed64 > map_fixed64_fixed64   = 8;\n  map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;\n  map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;\n  map<int32   , float   > map_int32_float       = 11;\n  map<int32   , double  > map_int32_double      = 12;\n  map<bool    , bool    > map_bool_bool         = 13;\n  map<string  , string  > map_string_string     = 14;\n  map<int32   , bytes   > map_int32_bytes       = 15;\n  map<int32   , MapEnumLite> map_int32_enum     = 16;\n  map<int32   , ForeignMessageArenaLite> map_int32_foreign_message = 17;\n  map<int32, .protobuf_unittest_no_arena.ForeignMessageLite>\n      map_int32_foreign_message_no_arena = 18;\n}\n\n// Test embedded message with required fields\nmessage TestRequiredMessageMapLite {\n  map<int32, TestRequiredLite> map_field = 1;\n}\n\nmessage TestEnumMapLite {\n  map<int32, Proto2MapEnumLite> known_map_field = 101;\n  map<int32, Proto2MapEnumLite> unknown_map_field = 102;\n}\n\nmessage TestEnumMapPlusExtraLite {\n  map<int32, Proto2MapEnumPlusExtraLite> known_map_field = 101;\n  map<int32, Proto2MapEnumPlusExtraLite> unknown_map_field = 102;\n}\n\nmessage TestMessageMapLite {\n  map<int32, TestAllTypesLite> map_int32_message = 1;\n}\n\nenum Proto2MapEnumLite {\n  PROTO2_MAP_ENUM_FOO_LITE = 0;\n  PROTO2_MAP_ENUM_BAR_LITE = 1;\n  PROTO2_MAP_ENUM_BAZ_LITE = 2;\n}\n\nenum Proto2MapEnumPlusExtraLite {\n  E_PROTO2_MAP_ENUM_FOO_LITE   = 0;\n  E_PROTO2_MAP_ENUM_BAR_LITE   = 1;\n  E_PROTO2_MAP_ENUM_BAZ_LITE   = 2;\n  E_PROTO2_MAP_ENUM_EXTRA_LITE = 3;\n}\n\nenum MapEnumLite {\n  MAP_ENUM_FOO_LITE = 0;\n  MAP_ENUM_BAR_LITE = 1;\n  MAP_ENUM_BAZ_LITE = 2;\n}\n\nmessage TestRequiredLite {\n  required int32 a = 1;\n  required int32 b = 2;\n  required int32 c = 3;\n}\n\nmessage ForeignMessageArenaLite {\n  optional int32 c = 1;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/map_proto2_unittest.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto2\";\n\n\nimport \"google/protobuf/unittest_import.proto\";\n\n// We don't put this in a package within proto2 because we need to make sure\n// that the generated code doesn't depend on being in the proto2 namespace.\n// In map_test_util.h we do \"using namespace unittest = protobuf_unittest\".\npackage protobuf_unittest;\n\nenum Proto2MapEnum {\n  PROTO2_MAP_ENUM_FOO   = 0;\n  PROTO2_MAP_ENUM_BAR   = 1;\n  PROTO2_MAP_ENUM_BAZ   = 2;\n}\n\nenum Proto2MapEnumPlusExtra {\n  E_PROTO2_MAP_ENUM_FOO   = 0;\n  E_PROTO2_MAP_ENUM_BAR   = 1;\n  E_PROTO2_MAP_ENUM_BAZ   = 2;\n  E_PROTO2_MAP_ENUM_EXTRA = 3;\n}\n\nmessage TestEnumMap {\n  map<int32, Proto2MapEnum> known_map_field = 101;\n  map<int32, Proto2MapEnum> unknown_map_field = 102;\n}\n\nmessage TestEnumMapPlusExtra {\n  map<int32, Proto2MapEnumPlusExtra> known_map_field = 101;\n  map<int32, Proto2MapEnumPlusExtra> unknown_map_field = 102;\n}\n\nmessage TestImportEnumMap {\n  map<int32, protobuf_unittest_import.ImportEnumForMap> import_enum_amp = 1;\n}\n\nmessage TestIntIntMap {\n  map<int32, int32> m = 1;\n}\n\n// Test all key types: string, plus the non-floating-point scalars.\nmessage TestMaps {\n  map<int32, TestIntIntMap> m_int32 = 1;\n  map<int64, TestIntIntMap> m_int64 = 2;\n  map<uint32, TestIntIntMap> m_uint32 = 3;\n  map<uint64, TestIntIntMap> m_uint64 = 4;\n  map<sint32, TestIntIntMap> m_sint32 = 5;\n  map<sint64, TestIntIntMap> m_sint64 = 6;\n  map<fixed32, TestIntIntMap> m_fixed32 = 7;\n  map<fixed64, TestIntIntMap> m_fixed64 = 8;\n  map<sfixed32, TestIntIntMap> m_sfixed32 = 9;\n  map<sfixed64, TestIntIntMap> m_sfixed64 = 10;\n  map<bool, TestIntIntMap> m_bool = 11;\n  map<string, TestIntIntMap> m_string = 12;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/map_test.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A hack to include windows.h first, which ensures the GetMessage macro can\n// be undefined when we include <google/protobuf/stubs/common.h>\n#if defined(_WIN32)\n#define _WINSOCKAPI_  // to avoid re-definition in WinSock2.h\n#define NOMINMAX      // to avoid defining min/max macros\n#include <windows.h>\n#endif  // _WIN32\n\n#include <algorithm>\n#include <google/protobuf/stubs/hash.h>\n#include <map>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <set>\n#include <sstream>\n#include <vector>\n\n#include <google/protobuf/stubs/casts.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/stringprintf.h>\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/arena_test_util.h>\n#include <google/protobuf/map_proto2_unittest.pb.h>\n#include <google/protobuf/map_unittest.pb.h>\n#include <google/protobuf/map_test_util.h>\n#include <google/protobuf/test_util.h>\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor_database.h>\n#include <google/protobuf/dynamic_message.h>\n#include <google/protobuf/map.h>\n#include <google/protobuf/map_field_inl.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/reflection.h>\n#include <google/protobuf/reflection_ops.h>\n#include <google/protobuf/text_format.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/tokenizer.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/util/time_util.h>\n#include <google/protobuf/util/message_differencer.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n#include <gmock/gmock.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\n\nusing google::protobuf::unittest::ForeignMessage;\nusing google::protobuf::unittest::TestAllTypes;\nusing google::protobuf::unittest::TestMap;\nusing google::protobuf::unittest::TestRecursiveMapMessage;\n\nnamespace protobuf {\nnamespace internal {\n\n// Map API Test =====================================================\n\n// Parameterized tests on whether to use old style maps.\nclass MapImplTest : public testing::TestWithParam<bool> {\n protected:\n  MapImplTest()\n      : map_ptr_(new Map<int32, int32>(GetParam())),\n        map_(*map_ptr_),\n        const_map_(*map_ptr_) {\n    EXPECT_TRUE(map_.empty());\n    EXPECT_EQ(0, map_.size());\n  }\n  ~MapImplTest() {}\n\n  void ExpectSingleElement(int32 key, int32 value) {\n    EXPECT_FALSE(map_.empty());\n    EXPECT_EQ(1, map_.size());\n    ExpectElement(key, value);\n  }\n\n  void ExpectElements(const std::map<int32, int32>& map) {\n    EXPECT_FALSE(map_.empty());\n    EXPECT_EQ(map.size(), map_.size());\n    for (std::map<int32, int32>::const_iterator it = map.begin();\n         it != map.end(); ++it) {\n      ExpectElement(it->first, it->second);\n    }\n  }\n\n  void ExpectElement(int32 key, int32 value) {\n    // Test map size is correct.\n    EXPECT_EQ(value, map_[key]);\n    EXPECT_EQ(1, map_.count(key));\n\n    // Check mutable at and find work correctly.\n    EXPECT_EQ(value, map_.at(key));\n    Map<int32, int32>::iterator it = map_.find(key);\n\n    // interator dereferenceable\n    EXPECT_EQ(key,   (*it).first);\n    EXPECT_EQ(value, (*it).second);\n    EXPECT_EQ(key,   it->first);\n    EXPECT_EQ(value, it->second);\n\n    // iterator mutable\n    ((*it).second) = value + 1;\n    EXPECT_EQ(value + 1, map_[key]);\n    ((*it).second) = value;\n    EXPECT_EQ(value, map_[key]);\n\n    it->second = value + 1;\n    EXPECT_EQ(value + 1, map_[key]);\n    it->second = value;\n    EXPECT_EQ(value, map_[key]);\n\n    // copy constructor\n    Map<int32, int32>::iterator it_copy = it;\n    EXPECT_EQ(key, it_copy->first);\n    EXPECT_EQ(value, it_copy->second);\n\n    // Immutable API ================================================\n\n    // Check immutable at and find work correctly.\n    EXPECT_EQ(value, const_map_.at(key));\n    Map<int32, int32>::const_iterator const_it = const_map_.find(key);\n\n    // interator dereferenceable\n    EXPECT_EQ(key, (*const_it).first);\n    EXPECT_EQ(value, (*const_it).second);\n    EXPECT_EQ(key, const_it->first);\n    EXPECT_EQ(value, const_it->second);\n\n    // copy constructor\n    Map<int32, int32>::const_iterator const_it_copy = const_it;\n    EXPECT_EQ(key, const_it_copy->first);\n    EXPECT_EQ(value, const_it_copy->second);\n  }\n\n  google::protobuf::scoped_ptr<Map<int32, int32> > map_ptr_;\n  Map<int32, int32>& map_;\n  const Map<int32, int32>& const_map_;\n};\n\nTEST_P(MapImplTest, OperatorBracket) {\n  int32 key = 0;\n  int32 value1 = 100;\n  int32 value2 = 101;\n\n  EXPECT_EQ(0, map_[key]);\n\n  map_[key] = value1;\n  ExpectSingleElement(key, value1);\n\n  map_[key] = value2;\n  ExpectSingleElement(key, value2);\n}\n\nTEST_P(MapImplTest, OperatorBracketNonExist) {\n  int32 key = 0;\n  int32 default_value = 0;\n\n  EXPECT_EQ(default_value, map_[key]);\n  ExpectSingleElement(key, default_value);\n}\n\nTEST_P(MapImplTest, MutableAt) {\n  int32 key = 0;\n  int32 value1 = 100;\n  int32 value2 = 101;\n\n  map_[key] = value1;\n  ExpectSingleElement(key, value1);\n\n  map_.at(key) = value2;\n  ExpectSingleElement(key, value2);\n}\n\n#ifdef PROTOBUF_HAS_DEATH_TEST\n\nTEST_P(MapImplTest, MutableAtNonExistDeathTest) {\n  EXPECT_DEATH(map_.at(0), \"\");\n}\n\nTEST_P(MapImplTest, ImmutableAtNonExistDeathTest) {\n  EXPECT_DEATH(const_map_.at(0), \"\");\n}\n\nTEST_P(MapImplTest, UsageErrors) {\n  MapKey key;\n  key.SetInt64Value(1);\n  EXPECT_DEATH(key.GetUInt64Value(),\n               \"Protocol Buffer map usage error:\\n\"\n               \"MapKey::GetUInt64Value type does not match\\n\"\n               \"  Expected : uint64\\n\"\n               \"  Actual   : int64\");\n\n  MapValueRef value;\n  EXPECT_DEATH(value.SetFloatValue(0.1),\n               \"Protocol Buffer map usage error:\\n\"\n               \"MapValueRef::type MapValueRef is not initialized.\");\n}\n\n#endif  // PROTOBUF_HAS_DEATH_TEST\n\nTEST_P(MapImplTest, CountNonExist) {\n  EXPECT_EQ(0, map_.count(0));\n}\n\nTEST_P(MapImplTest, MutableFindNonExist) {\n  EXPECT_TRUE(map_.end() == map_.find(0));\n}\n\nTEST_P(MapImplTest, ImmutableFindNonExist) {\n  EXPECT_TRUE(const_map_.end() == const_map_.find(0));\n}\n\nTEST_P(MapImplTest, ConstEnd) {\n  EXPECT_TRUE(const_map_.end() == const_map_.cend());\n}\n\nTEST_P(MapImplTest, GetReferenceFromIterator) {\n  for (int i = 0; i < 10; i++) {\n    map_[i] = i;\n  }\n\n  for (Map<int32, int32>::const_iterator it = map_.cbegin();\n       it != map_.cend();) {\n    Map<int32, int32>::const_reference entry = *it++;\n    EXPECT_EQ(entry.first, entry.second);\n  }\n\n  for (Map<int32, int32>::const_iterator it = const_map_.begin();\n       it != const_map_.end();) {\n    Map<int32, int32>::const_reference entry = *it++;\n    EXPECT_EQ(entry.first, entry.second);\n  }\n\n  for (Map<int32, int32>::iterator it = map_.begin(); it != map_.end();) {\n    Map<int32, int32>::reference entry = *it++;\n    EXPECT_EQ(entry.first + 1, ++entry.second);\n  }\n}\n\nTEST_P(MapImplTest, IteratorBasic) {\n  map_[0] = 0;\n\n  // Default constructible (per forward iterator requirements).\n  Map<int, int>::const_iterator cit;\n  Map<int, int>::iterator it;\n\n  it = map_.begin();\n  cit = it;  // Converts to const_iterator\n\n  // Can compare between them.\n  EXPECT_TRUE(it == cit);\n  EXPECT_FALSE(cit != it);\n\n  // Pre increment.\n  EXPECT_FALSE(it == ++cit);\n\n  // Post increment.\n  EXPECT_FALSE(it++ == cit);\n  EXPECT_TRUE(it == cit);\n}\n\ntemplate <typename Iterator>\nstatic int64 median(Iterator i0, Iterator i1) {\n  vector<int64> v(i0, i1);\n  std::nth_element(v.begin(), v.begin() + v.size() / 2, v.end());\n  return v[v.size() / 2];\n}\n\nstatic int64 Now() {\n  return google::protobuf::util::TimeUtil::TimestampToNanoseconds(\n      google::protobuf::util::TimeUtil::GetCurrentTime());\n}\n\n// Arbitrary odd integers for creating test data.\nstatic int k0 = 812398771;\nstatic int k1 = 1312938717;\nstatic int k2 = 1321555333;\n\n// A naive begin() implementation will cause begin() to get slower and slower\n// if one erases elements at the \"front\" of the hash map, and we'd like to\n// avoid that, as std::unordered_map does.\nTEST_P(MapImplTest, BeginIsFast) {\n  // Disable this test for both new and old implementations.\n  if (/*GetParam()*/true) return;\n  Map<int32, int32> map(false);  // This test uses new-style maps only.\n  const int kTestSize = 250000;\n  // Create a random-looking map of size n.  Use non-negative integer keys.\n  uint32 frog = 123983;\n  int last_key = 0;\n  int counter = 0;\n  while (map.size() < kTestSize) {\n    frog *= static_cast<uint32>(k0);\n    frog ^= frog >> 17;\n    frog += counter++;\n    last_key =\n        static_cast<int>(frog) >= 0 ? static_cast<int>(frog) : last_key ^ 1;\n    GOOGLE_DCHECK_GE(last_key, 0);\n    map[last_key] = last_key ^ 1;\n  }\n  vector<int64> times;\n  // We're going to do map.erase(map.begin()) over and over again.  But,\n  // just in case one iteration is fast compared to the granularity of\n  // our time keeping, we measure kChunkSize iterations per outer-loop iter.\n  const int kChunkSize = 1000;\n  GOOGLE_CHECK_EQ(kTestSize % kChunkSize, 0);\n  do {\n    const int64 start = Now();\n    for (int i = 0; i < kChunkSize; i++) {\n      map.erase(map.begin());\n    }\n    const int64 end = Now();\n    if (end > start) {\n      times.push_back(end - start);\n    }\n  } while (!map.empty());\n  if (times.size() < .99 * kTestSize / kChunkSize) {\n    GOOGLE_LOG(WARNING) << \"Now() isn't helping us measure time\";\n    return;\n  }\n  int64 x0 = median(times.begin(), times.begin() + 9);\n  int64 x1 = median(times.begin() + times.size() - 9, times.end());\n  GOOGLE_LOG(INFO) << \"x0=\" << x0 << \", x1=\" << x1;\n  // x1 will greatly exceed x0 if the code we just executed took O(n^2) time.\n  // And we'll probably time out and never get here.  So, this test is\n  // intentionally loose: we check that x0 and x1 are within a factor of 8.\n  EXPECT_GE(x1, x0 / 8);\n  EXPECT_GE(x0, x1 / 8);\n}\n\n// Try to create kTestSize keys that will land in just a few buckets, and\n// time the insertions, to get a rough estimate of whether an O(n^2) worst case\n// was triggered.  This test is a hacky, but probably better than nothing.\nTEST_P(MapImplTest, HashFlood) {\n  const int kTestSize = 1024;  // must be a power of 2\n  std::set<int> s;\n  for (int i = 0; s.size() < kTestSize; i++) {\n    if ((map_.hash_function()(i) & (kTestSize - 1)) < 3) {\n      s.insert(i);\n    }\n  }\n  // Create hash table with kTestSize entries that hash flood a table with\n  // 1024 (or 512 or 2048 or ...) entries.  This assumes that map_ uses powers\n  // of 2 for table sizes, and that it's sufficient to \"flood\" with respect to\n  // the low bits of the output of map_.hash_function().\n  vector<int64> times;\n  std::set<int>::iterator it = s.begin();\n  int count = 0;\n  do {\n    const int64 start = Now();\n    map_[*it] = 0;\n    const int64 end = Now();\n    if (end > start) {\n      times.push_back(end - start);\n    }\n    ++count;\n    ++it;\n  } while (it != s.end());\n  if (times.size() < .99 * count) return;\n  int64 x0 = median(times.begin(), times.begin() + 9);\n  int64 x1 = median(times.begin() + times.size() - 9, times.end());\n  // x1 will greatly exceed x0 if the code we just executed took O(n^2) time.\n  // But we want to allow O(n log n).  A factor of 20 should be generous enough.\n  EXPECT_LE(x1, x0 * 20);\n}\n\ntemplate <typename T, typename U>\nstatic void TestValidityForAllKeysExcept(int key_to_avoid,\n                                         const T& check_map,\n                                         const U& map) {\n  typedef typename U::value_type value_type;  // a key-value pair\n  for (typename U::const_iterator it = map.begin(); it != map.end(); ++it) {\n    const int key = it->first;\n    if (key == key_to_avoid) continue;\n    // All iterators relevant to this key, whether old (from check_map) or new,\n    // must point to the same memory.  So, test pointer equality here.\n    const value_type* check_val = &*check_map.find(key)->second;\n    EXPECT_EQ(check_val, &*it);\n    EXPECT_EQ(check_val, &*map.find(key));\n  }\n}\n\n// EXPECT i0 and i1 to be the same.  Advancing them should have the same effect,\n// too.\ntemplate <typename Iter>\nstatic void TestEqualIterators(Iter i0, Iter i1, Iter end) {\n  const int kMaxAdvance = 10;\n  for (int i = 0; i < kMaxAdvance; i++) {\n    EXPECT_EQ(i0 == end, i1 == end);\n    if (i0 == end) return;\n    EXPECT_EQ(&*i0, &*i1) << \"iter \" << i;\n    ++i0;\n    ++i1;\n  }\n}\n\ntemplate <typename IteratorType>\nstatic void TestOldVersusNewIterator(int skip, Map<int, int>* m) {\n  const int initial_size = m->size();\n  IteratorType it = m->begin();\n  for (int i = 0; i < skip && it != m->end(); it++, i++) {}\n  if (it == m->end()) return;\n  const IteratorType old = it;\n  GOOGLE_LOG(INFO) << \"skip=\" << skip << \", old->first=\" << old->first;\n  const int target_size =\n      initial_size < 100 ? initial_size * 5 : initial_size * 5 / 4;\n  for (int i = 0; m->size() <= target_size; i++) {\n    (*m)[i] = 0;\n  }\n  // Iterator 'old' should still work just fine despite the growth of *m.\n  const IteratorType after_growth = m->find(old->first);\n  TestEqualIterators<IteratorType>(old, after_growth, m->end());\n\n  // Now shrink the number of elements.  Do this with a mix of erases and\n  // inserts to increase the chance that the hashtable will resize to a lower\n  // number of buckets.  (But, in any case, the test is still useful.)\n  for (int i = 0; i < 2 * (target_size - initial_size); i++) {\n    if (i != old->first) {\n      m->erase(i);\n    }\n    if (((i ^ m->begin()->first) & 15) == 0) {\n      (*m)[i * 342] = i;\n    }\n  }\n  // Now, the table has grown and shrunk; test again.\n  TestEqualIterators<IteratorType>(old, m->find(old->first), m->end());\n  TestEqualIterators<IteratorType>(old, after_growth, m->end());\n}\n\n// Create and test an n-element Map, with emphasis on iterator correctness.\nstatic void StressTestIterators(int n, bool test_old_style_proto2_maps) {\n  GOOGLE_LOG(INFO) << \"StressTestIterators \" << n;\n  GOOGLE_CHECK_GT(n, 0);\n  // Create a random-looking map of size n.  Use non-negative integer keys.\n  Map<int, int> m(test_old_style_proto2_maps);\n  uint32 frog = 123987 + n;\n  int last_key = 0;\n  int counter = 0;\n  while (m.size() < n) {\n    frog *= static_cast<uint32>(k0);\n    frog ^= frog >> 17;\n    frog += counter++;\n    last_key =\n        static_cast<int>(frog) >= 0 ? static_cast<int>(frog) : last_key ^ 1;\n    GOOGLE_DCHECK_GE(last_key, 0);\n    m[last_key] = last_key ^ 1;\n  }\n  // Test it.\n  ASSERT_EQ(n, m.size());\n  // Create maps of pointers and iterators.\n  // These should remain valid even if we modify m.\n  hash_map<int, Map<int, int>::value_type*> mp(n);\n  hash_map<int, Map<int, int>::iterator> mi(n);\n  for (Map<int, int>::iterator it = m.begin(); it != m.end(); ++it) {\n    mp[it->first] = &*it;\n    mi[it->first] = it;\n  }\n  ASSERT_EQ(m.size(), mi.size());\n  ASSERT_EQ(m.size(), mp.size());\n  m.erase(last_key);\n  ASSERT_EQ(n - 1, m.size());\n  TestValidityForAllKeysExcept(last_key, mp, m);\n  TestValidityForAllKeysExcept(last_key, mi, m);\n\n  m[last_key] = 0;\n  ASSERT_EQ(n, m.size());\n  // Test old iterator vs new iterator, with table modification in between.\n  TestOldVersusNewIterator<Map<int, int>::const_iterator>(n % 3, &m);\n  TestOldVersusNewIterator<Map<int, int>::iterator>(n % (1 + (n / 40)), &m);\n  // Finally, ensure erase(iterator) doesn't reorder anything, because that is\n  // what its documentation says.\n  m[last_key] = m[last_key ^ 999] = 0;\n  vector<Map<int, int>::iterator> v;\n  v.reserve(m.size());\n  int position_of_last_key = 0;\n  for (Map<int, int>::iterator it = m.begin(); it != m.end(); ++it) {\n    if (it->first == last_key) {\n      position_of_last_key = v.size();\n    }\n    v.push_back(it);\n  }\n  ASSERT_EQ(m.size(), v.size());\n  const Map<int, int>::iterator erase_result = m.erase(m.find(last_key));\n  int index = 0;\n  for (Map<int, int>::iterator it = m.begin(); it != m.end(); ++it, ++index) {\n    if (index == position_of_last_key) {\n      EXPECT_EQ(&*erase_result, &*v[++index]);\n    }\n    ASSERT_EQ(&*it, &*v[index]);\n  }\n}\n\nTEST_P(MapImplTest, IteratorInvalidation) {\n  // As multiple underlying hash_map implementations do not follow the\n  // validation requirement, the test is disabled for old-style maps.\n  if (GetParam()) return;\n  // Create a set of pseudo-random sizes to test.\n#ifndef NDEBUG\n  const int kMaxSizeToTest = 100 * 1000;\n#else\n  const int kMaxSizeToTest = 1000 * 1000;\n#endif\n  std::set<int> s;\n  int n = kMaxSizeToTest;\n  int frog = k1 + n;\n  while (n > 1 && s.size() < 25) {\n    s.insert(n);\n    n = static_cast<int>(n * 100 / (101.0 + (frog & 63)));\n    frog *= k2;\n    frog ^= frog >> 17;\n  }\n  // Ensure we test a few small sizes.\n  s.insert(1);\n  s.insert(2);\n  s.insert(3);\n  // Now, the real work.\n  for (std::set<int>::iterator i = s.begin(); i != s.end(); ++i) {\n    StressTestIterators(*i, GetParam());\n  }\n}\n\n// Test that erase() revalidates iterators.\nTEST_P(MapImplTest, EraseRevalidates) {\n  // As multiple underlying hash_map implementations do not follow the\n  // validation requirement, the test is disabled for old-style maps.\n  if (GetParam()) return;\n  map_[3] = map_[13] = map_[20] = 0;\n  const int initial_size = map_.size();\n  EXPECT_EQ(3, initial_size);\n  vector<Map<int, int>::iterator> v;\n  for (Map<int, int>::iterator it = map_.begin(); it != map_.end(); ++it) {\n    v.push_back(it);\n  }\n  EXPECT_EQ(initial_size, v.size());\n  for (int i = 0; map_.size() <= initial_size * 20; i++) {\n    map_[i] = 0;\n  }\n  const int larger_size = map_.size();\n  // We've greatly increased the size of the map, so it is highly likely that\n  // the following will corrupt m if erase() doesn't properly revalidate\n  // iterators passed to it.  Finishing this routine without crashing indicates\n  // success.\n  for (int i = 0; i < v.size(); i++) {\n    map_.erase(v[i]);\n  }\n  EXPECT_EQ(larger_size - v.size(), map_.size());\n}\n\ntemplate <typename T>\nbool IsConstHelper(T& /*t*/) {  // NOLINT. We want to catch non-const refs here.\n  return false;\n}\ntemplate <typename T>\nbool IsConstHelper(const T& /*t*/) {\n  return true;\n}\n\nTEST_P(MapImplTest, IteratorConstness) {\n  map_[0] = 0;\n  EXPECT_TRUE(IsConstHelper(*map_.cbegin()));\n  EXPECT_TRUE(IsConstHelper(*const_map_.begin()));\n  EXPECT_FALSE(IsConstHelper(*map_.begin()));\n}\n\nbool IsForwardIteratorHelper(std::forward_iterator_tag /*tag*/) { return true; }\ntemplate <typename T>\nbool IsForwardIteratorHelper(T /*t*/) {\n  return false;\n}\n\nTEST_P(MapImplTest, IteratorCategory) {\n  EXPECT_TRUE(IsForwardIteratorHelper(\n      std::iterator_traits<Map<int, int>::iterator>::iterator_category()));\n  EXPECT_TRUE(IsForwardIteratorHelper(std::iterator_traits<\n      Map<int, int>::const_iterator>::iterator_category()));\n}\n\nTEST_P(MapImplTest, InsertSingle) {\n  int32 key = 0;\n  int32 value1 = 100;\n  int32 value2 = 101;\n\n  // Insert a non-existed key.\n  std::pair<Map<int32, int32>::iterator, bool> result1 =\n      map_.insert(Map<int32, int32>::value_type(key, value1));\n  ExpectSingleElement(key, value1);\n\n  Map<int32, int32>::iterator it1 = result1.first;\n  EXPECT_EQ(key, it1->first);\n  EXPECT_EQ(value1, it1->second);\n  EXPECT_TRUE(result1.second);\n\n  // Insert an existed key.\n  std::pair<Map<int32, int32>::iterator, bool> result2 =\n      map_.insert(Map<int32, int32>::value_type(key, value2));\n  ExpectSingleElement(key, value1);\n\n  Map<int32, int32>::iterator it2 = result2.first;\n  EXPECT_TRUE(it1 == it2);\n  EXPECT_FALSE(result2.second);\n}\n\nTEST_P(MapImplTest, InsertByIterator) {\n  int32 key1 = 0;\n  int32 key2 = 1;\n  int32 value1a = 100;\n  int32 value1b = 101;\n  int32 value2a = 200;\n  int32 value2b = 201;\n\n  std::map<int32, int32> map1;\n  map1[key1] = value1a;\n  map1[key2] = value2a;\n\n  map_.insert(map1.begin(), map1.end());\n  ExpectElements(map1);\n\n  std::map<int32, int32> map2;\n  map2[key1] = value1b;\n  map2[key2] = value2b;\n\n  map_.insert(map2.begin(), map2.end());\n  ExpectElements(map1);\n}\n\nTEST_P(MapImplTest, EraseSingleByKey) {\n  int32 key = 0;\n  int32 value = 100;\n\n  map_[key] = value;\n  ExpectSingleElement(key, value);\n\n  // Erase an existing key.\n  EXPECT_EQ(1, map_.erase(key));\n  EXPECT_TRUE(map_.empty());\n  EXPECT_EQ(0, map_.size());\n  EXPECT_TRUE(map_.end() == map_.find(key));\n  EXPECT_TRUE(map_.begin() == map_.end());\n\n  // Erase a non-existing key.\n  EXPECT_EQ(0, map_.erase(key));\n}\n\nTEST_P(MapImplTest, EraseMutipleByKey) {\n  // erase in one specific order to trigger corner cases\n  for (int i = 0; i < 5; i++) {\n    map_[i] = i;\n  }\n\n  map_.erase(0);\n  EXPECT_EQ(4, map_.size());\n  EXPECT_TRUE(map_.end() == map_.find(0));\n\n  map_.erase(1);\n  EXPECT_EQ(3, map_.size());\n  EXPECT_TRUE(map_.end() == map_.find(1));\n\n  map_.erase(3);\n  EXPECT_EQ(2, map_.size());\n  EXPECT_TRUE(map_.end() == map_.find(3));\n\n  map_.erase(4);\n  EXPECT_EQ(1, map_.size());\n  EXPECT_TRUE(map_.end() == map_.find(4));\n\n  map_.erase(2);\n  EXPECT_EQ(0, map_.size());\n  EXPECT_TRUE(map_.end() == map_.find(2));\n}\n\nTEST_P(MapImplTest, EraseSingleByIterator) {\n  int32 key = 0;\n  int32 value = 100;\n\n  map_[key] = value;\n  ExpectSingleElement(key, value);\n\n  Map<int32, int32>::iterator it = map_.find(key);\n  map_.erase(it);\n  EXPECT_TRUE(map_.empty());\n  EXPECT_EQ(0, map_.size());\n  EXPECT_TRUE(map_.end() == map_.find(key));\n  EXPECT_TRUE(map_.begin() == map_.end());\n}\n\nTEST_P(MapImplTest, ValidIteratorAfterErase) {\n  for (int i = 0; i < 10; i++) {\n    map_[i] = i;\n  }\n\n  int count = 0;\n\n  for (Map<int32, int32>::iterator it = map_.begin(); it != map_.end();) {\n    count++;\n    if (it->first % 2 == 1) {\n      map_.erase(it++);\n    } else {\n      ++it;\n    }\n  }\n\n  EXPECT_EQ(10, count);\n  EXPECT_EQ(5, map_.size());\n}\n\nTEST_P(MapImplTest, EraseByIterator) {\n  int32 key1 = 0;\n  int32 key2 = 1;\n  int32 value1 = 100;\n  int32 value2 = 101;\n\n  std::map<int32, int32> map;\n  map[key1] = value1;\n  map[key2] = value2;\n\n  map_.insert(map.begin(), map.end());\n  ExpectElements(map);\n\n  map_.erase(map_.begin(), map_.end());\n  EXPECT_TRUE(map_.empty());\n  EXPECT_EQ(0, map_.size());\n  EXPECT_TRUE(map_.end() == map_.find(key1));\n  EXPECT_TRUE(map_.end() == map_.find(key2));\n  EXPECT_TRUE(map_.begin() == map_.end());\n}\n\nTEST_P(MapImplTest, Clear) {\n  int32 key = 0;\n  int32 value = 100;\n\n  map_[key] = value;\n  ExpectSingleElement(key, value);\n\n  map_.clear();\n\n  EXPECT_TRUE(map_.empty());\n  EXPECT_EQ(0, map_.size());\n  EXPECT_TRUE(map_.end() == map_.find(key));\n  EXPECT_TRUE(map_.begin() == map_.end());\n}\n\nstatic void CopyConstructorHelper(Arena* arena, Map<int32, int32>* m) {\n  int32 key1 = 0;\n  int32 key2 = 1;\n  int32 value1 = 100;\n  int32 value2 = 101;\n\n  std::map<int32, int32> map;\n  map[key1] = value1;\n  map[key2] = value2;\n\n  m->insert(map.begin(), map.end());\n\n  Map<int32, int32> other(*m);\n\n  EXPECT_EQ(2, other.size());\n  EXPECT_EQ(value1, other.at(key1));\n  EXPECT_EQ(value2, other.at(key2));\n}\n\nTEST_P(MapImplTest, CopyConstructorWithArena) {\n  Arena a;\n  CopyConstructorHelper(&a, &map_);\n}\n\nTEST_P(MapImplTest, CopyConstructorWithoutArena) {\n  CopyConstructorHelper(NULL, &map_);\n}\n\nTEST_P(MapImplTest, IterConstructor) {\n  int32 key1 = 0;\n  int32 key2 = 1;\n  int32 value1 = 100;\n  int32 value2 = 101;\n\n  std::map<int32, int32> map;\n  map[key1] = value1;\n  map[key2] = value2;\n\n  Map<int32, int32> new_map(map.begin(), map.end(),\n                            GetParam());\n\n  EXPECT_EQ(2, new_map.size());\n  EXPECT_EQ(value1, new_map.at(key1));\n  EXPECT_EQ(value2, new_map.at(key2));\n}\n\nTEST_P(MapImplTest, Assigner) {\n  int32 key1 = 0;\n  int32 key2 = 1;\n  int32 value1 = 100;\n  int32 value2 = 101;\n\n  std::map<int32, int32> map;\n  map[key1] = value1;\n  map[key2] = value2;\n\n  map_.insert(map.begin(), map.end());\n\n  Map<int32, int32> other(GetParam());\n  int32 key_other = 123;\n  int32 value_other = 321;\n  other[key_other] = value_other;\n  EXPECT_EQ(1, other.size());\n\n  other = map_;\n\n  EXPECT_EQ(2, other.size());\n  EXPECT_EQ(value1, other.at(key1));\n  EXPECT_EQ(value2, other.at(key2));\n  EXPECT_TRUE(other.find(key_other) == other.end());\n\n  // Self assign\n  other = other;\n  EXPECT_EQ(2, other.size());\n  EXPECT_EQ(value1, other.at(key1));\n  EXPECT_EQ(value2, other.at(key2));\n\n  // Try assignment to a map with a different choice of \"style.\"\n  Map<int32, int32> m(!GetParam());\n  m = other;\n  EXPECT_EQ(2, m.size());\n  EXPECT_EQ(value1, m.at(key1));\n  EXPECT_EQ(value2, m.at(key2));\n}\n\nTEST_P(MapImplTest, Rehash) {\n  const int test_size = 50;\n  std::map<int32, int32> reference_map;\n  for (int i = 0; i < test_size; i++) {\n    reference_map[i] = i;\n  }\n  for (int i = 0; i < test_size; i++) {\n    map_[i] = reference_map[i];\n    EXPECT_EQ(reference_map[i], map_[i]);\n  }\n  for (int i = 0; i < test_size; i++) {\n    map_.erase(i);\n    EXPECT_TRUE(map_.end() == map_.find(i));\n  }\n  EXPECT_TRUE(map_.empty());\n}\n\nTEST_P(MapImplTest, EqualRange) {\n  int key = 100, key_missing = 101;\n  map_[key] = 100;\n\n  std::pair<google::protobuf::Map<int32, int32>::iterator,\n            google::protobuf::Map<int32, int32>::iterator> range = map_.equal_range(key);\n  EXPECT_TRUE(map_.find(key) == range.first);\n  EXPECT_TRUE(++map_.find(key) == range.second);\n\n  range = map_.equal_range(key_missing);\n  EXPECT_TRUE(map_.end() == range.first);\n  EXPECT_TRUE(map_.end() == range.second);\n\n  std::pair<google::protobuf::Map<int32, int32>::const_iterator,\n            google::protobuf::Map<int32, int32>::const_iterator> const_range =\n      const_map_.equal_range(key);\n  EXPECT_TRUE(const_map_.find(key) == const_range.first);\n  EXPECT_TRUE(++const_map_.find(key) == const_range.second);\n\n  const_range = const_map_.equal_range(key_missing);\n  EXPECT_TRUE(const_map_.end() == const_range.first);\n  EXPECT_TRUE(const_map_.end() == const_range.second);\n}\n\nTEST_P(MapImplTest, ConvertToStdMap) {\n  map_[100] = 101;\n  std::map<int32, int32> std_map(map_.begin(), map_.end());\n  EXPECT_EQ(1, std_map.size());\n  EXPECT_EQ(101, std_map[100]);\n}\n\nTEST_P(MapImplTest, ConvertToStdVectorOfPairs) {\n  map_[100] = 101;\n  std::vector<std::pair<int32, int32> > std_vec(map_.begin(), map_.end());\n  EXPECT_EQ(1, std_vec.size());\n  EXPECT_EQ(100, std_vec[0].first);\n  EXPECT_EQ(101, std_vec[0].second);\n}\n\nTEST_P(MapImplTest, SwapSameStyle) {\n  Map<int32, int32> another(GetParam());  // same old_style_ value\n  map_[9398] = 41999;\n  another[9398] = 41999;\n  another[8070] = 42056;\n  another.swap(map_);\n  EXPECT_THAT(another, testing::UnorderedElementsAre(\n      testing::Pair(9398, 41999)));\n  EXPECT_THAT(map_, testing::UnorderedElementsAre(\n      testing::Pair(8070, 42056),\n      testing::Pair(9398, 41999)));\n}\n\nTEST_P(MapImplTest, SwapDifferentStyle) {\n  Map<int32, int32> another(!GetParam());  // different old_style_ value\n  map_[9398] = 41999;\n  another[9398] = 41999;\n  another[8070] = 42056;\n  another.swap(map_);\n  EXPECT_THAT(another, testing::UnorderedElementsAre(\n      testing::Pair(9398, 41999)));\n  EXPECT_THAT(map_, testing::UnorderedElementsAre(\n      testing::Pair(8070, 42056),\n      testing::Pair(9398, 41999)));\n}\n\nTEST_P(MapImplTest, SwapArena) {\n  Arena arena1, arena2;\n  Map<int32, int32> m1(&arena1, false);\n  Map<int32, int32> m2(&arena2, false);\n  map_[9398] = 41999;\n  m1[9398] = 41999;\n  m1[8070] = 42056;\n  m2[10244] = 10247;\n  m2[8070] = 42056;\n  m1.swap(map_);\n  EXPECT_THAT(m1, testing::UnorderedElementsAre(\n      testing::Pair(9398, 41999)));\n  EXPECT_THAT(map_, testing::UnorderedElementsAre(\n      testing::Pair(8070, 42056),\n      testing::Pair(9398, 41999)));\n  m2.swap(m1);\n  EXPECT_THAT(m1, testing::UnorderedElementsAre(\n      testing::Pair(8070, 42056),\n      testing::Pair(10244, 10247)));\n  EXPECT_THAT(m2, testing::UnorderedElementsAre(\n      testing::Pair(9398, 41999)));\n}\n\nINSTANTIATE_TEST_CASE_P(BoolSequence, MapImplTest, testing::Bool());\n\n// Map Field Reflection Test ========================================\n\nstatic int Func(int i, int j) {\n  return i * j;\n}\n\nstatic string StrFunc(int i, int j) {\n  string str;\n  SStringPrintf(&str, \"%d\", Func(i, j));\n  return str;\n}\n\nstatic int Int(const string& value) {\n  int result = 0;\n  std::istringstream(value) >> result;\n  return result;\n}\n\nclass MapFieldReflectionTest : public testing::Test {\n protected:\n  typedef FieldDescriptor FD;\n};\n\nTEST_F(MapFieldReflectionTest, RegularFields) {\n  TestMap message;\n  const Reflection* refl = message.GetReflection();\n  const Descriptor* desc = message.GetDescriptor();\n\n  Map<int32, int32>* map_int32_int32 = message.mutable_map_int32_int32();\n  Map<int32, double>* map_int32_double = message.mutable_map_int32_double();\n  Map<string, string>* map_string_string = message.mutable_map_string_string();\n  Map<int32, ForeignMessage>* map_int32_foreign_message =\n      message.mutable_map_int32_foreign_message();\n\n  for (int i = 0; i < 10; ++i) {\n    (*map_int32_int32)[i] = Func(i, 1);\n    (*map_int32_double)[i] = Func(i, 2);\n    (*map_string_string)[StrFunc(i, 1)] = StrFunc(i, 5);\n    (*map_int32_foreign_message)[i].set_c(Func(i, 6));\n  }\n\n  // Get FieldDescriptors for all the fields of interest.\n  const FieldDescriptor* fd_map_int32_int32 =\n      desc->FindFieldByName(\"map_int32_int32\");\n  const FieldDescriptor* fd_map_int32_double =\n      desc->FindFieldByName(\"map_int32_double\");\n  const FieldDescriptor* fd_map_string_string =\n      desc->FindFieldByName(\"map_string_string\");\n  const FieldDescriptor* fd_map_int32_foreign_message =\n      desc->FindFieldByName(\"map_int32_foreign_message\");\n\n  const FieldDescriptor* fd_map_int32_in32_key =\n      fd_map_int32_int32->message_type()->FindFieldByName(\"key\");\n  const FieldDescriptor* fd_map_int32_in32_value =\n      fd_map_int32_int32->message_type()->FindFieldByName(\"value\");\n  const FieldDescriptor* fd_map_int32_double_key =\n      fd_map_int32_double->message_type()->FindFieldByName(\"key\");\n  const FieldDescriptor* fd_map_int32_double_value =\n      fd_map_int32_double->message_type()->FindFieldByName(\"value\");\n  const FieldDescriptor* fd_map_string_string_key =\n      fd_map_string_string->message_type()->FindFieldByName(\"key\");\n  const FieldDescriptor* fd_map_string_string_value =\n      fd_map_string_string->message_type()->FindFieldByName(\"value\");\n  const FieldDescriptor* fd_map_int32_foreign_message_key =\n      fd_map_int32_foreign_message->message_type()->FindFieldByName(\"key\");\n  const FieldDescriptor* fd_map_int32_foreign_message_value =\n      fd_map_int32_foreign_message->message_type()->FindFieldByName(\"value\");\n\n  // Get RepeatedPtrField objects for all fields of interest.\n  const RepeatedPtrField<Message>& mf_int32_int32 =\n      refl->GetRepeatedPtrField<Message>(message, fd_map_int32_int32);\n  const RepeatedPtrField<Message>& mf_int32_double =\n      refl->GetRepeatedPtrField<Message>(message, fd_map_int32_double);\n  const RepeatedPtrField<Message>& mf_string_string =\n      refl->GetRepeatedPtrField<Message>(message, fd_map_string_string);\n  const RepeatedPtrField<Message>&\n      mf_int32_foreign_message =\n          refl->GetRepeatedPtrField<Message>(\n              message, fd_map_int32_foreign_message);\n\n  // Get mutable RepeatedPtrField objects for all fields of interest.\n  RepeatedPtrField<Message>* mmf_int32_int32 =\n      refl->MutableRepeatedPtrField<Message>(&message, fd_map_int32_int32);\n  RepeatedPtrField<Message>* mmf_int32_double =\n      refl->MutableRepeatedPtrField<Message>(&message, fd_map_int32_double);\n  RepeatedPtrField<Message>* mmf_string_string =\n      refl->MutableRepeatedPtrField<Message>(&message, fd_map_string_string);\n  RepeatedPtrField<Message>* mmf_int32_foreign_message =\n      refl->MutableRepeatedPtrField<Message>(\n          &message, fd_map_int32_foreign_message);\n\n  // Make sure we can do gets through the RepeatedPtrField objects.\n  for (int i = 0; i < 10; ++i) {\n    {\n      // Check gets through const objects.\n      const Message& message_int32_int32 = mf_int32_int32.Get(i);\n      int32 key_int32_int32 = message_int32_int32.GetReflection()->GetInt32(\n          message_int32_int32, fd_map_int32_in32_key);\n      int32 value_int32_int32 = message_int32_int32.GetReflection()->GetInt32(\n          message_int32_int32, fd_map_int32_in32_value);\n      EXPECT_EQ(value_int32_int32, Func(key_int32_int32, 1));\n\n      const Message& message_int32_double = mf_int32_double.Get(i);\n      int32 key_int32_double = message_int32_double.GetReflection()->GetInt32(\n          message_int32_double, fd_map_int32_double_key);\n      double value_int32_double =\n          message_int32_double.GetReflection()->GetDouble(\n              message_int32_double, fd_map_int32_double_value);\n      EXPECT_EQ(value_int32_double, Func(key_int32_double, 2));\n\n      const Message& message_string_string = mf_string_string.Get(i);\n      string key_string_string =\n          message_string_string.GetReflection()->GetString(\n              message_string_string, fd_map_string_string_key);\n      string value_string_string =\n          message_string_string.GetReflection()->GetString(\n              message_string_string, fd_map_string_string_value);\n      EXPECT_EQ(value_string_string, StrFunc(Int(key_string_string), 5));\n\n      const Message& message_int32_message = mf_int32_foreign_message.Get(i);\n      int32 key_int32_message = message_int32_message.GetReflection()->GetInt32(\n          message_int32_message, fd_map_int32_foreign_message_key);\n      const ForeignMessage& value_int32_message =\n          down_cast<const ForeignMessage&>(\n              message_int32_message.GetReflection()\n                  ->GetMessage(message_int32_message,\n                               fd_map_int32_foreign_message_value));\n      EXPECT_EQ(value_int32_message.c(), Func(key_int32_message, 6));\n    }\n\n    {\n      // Check gets through mutable objects.\n      const Message& message_int32_int32 = mmf_int32_int32->Get(i);\n      int32 key_int32_int32 = message_int32_int32.GetReflection()->GetInt32(\n          message_int32_int32, fd_map_int32_in32_key);\n      int32 value_int32_int32 = message_int32_int32.GetReflection()->GetInt32(\n          message_int32_int32, fd_map_int32_in32_value);\n      EXPECT_EQ(value_int32_int32, Func(key_int32_int32, 1));\n\n      const Message& message_int32_double = mmf_int32_double->Get(i);\n      int32 key_int32_double = message_int32_double.GetReflection()->GetInt32(\n          message_int32_double, fd_map_int32_double_key);\n      double value_int32_double =\n          message_int32_double.GetReflection()->GetDouble(\n              message_int32_double, fd_map_int32_double_value);\n      EXPECT_EQ(value_int32_double, Func(key_int32_double, 2));\n\n      const Message& message_string_string = mmf_string_string->Get(i);\n      string key_string_string =\n          message_string_string.GetReflection()->GetString(\n              message_string_string, fd_map_string_string_key);\n      string value_string_string =\n          message_string_string.GetReflection()->GetString(\n              message_string_string, fd_map_string_string_value);\n      EXPECT_EQ(value_string_string, StrFunc(Int(key_string_string), 5));\n\n      const Message& message_int32_message = mmf_int32_foreign_message->Get(i);\n      int32 key_int32_message = message_int32_message.GetReflection()->GetInt32(\n          message_int32_message, fd_map_int32_foreign_message_key);\n      const ForeignMessage& value_int32_message =\n          down_cast<const ForeignMessage&>(\n              message_int32_message.GetReflection()\n                  ->GetMessage(message_int32_message,\n                               fd_map_int32_foreign_message_value));\n      EXPECT_EQ(value_int32_message.c(), Func(key_int32_message, 6));\n    }\n  }\n\n  // Do sets through the RepeatedPtrField objects.\n  for (int i = 0; i < 10; i++) {\n    {\n      Message* message_int32_int32 = mmf_int32_int32->Mutable(i);\n      int32 key_int32_int32 = message_int32_int32->GetReflection()->GetInt32(\n          *message_int32_int32, fd_map_int32_in32_key);\n      message_int32_int32->GetReflection()->SetInt32(message_int32_int32,\n                                                     fd_map_int32_in32_value,\n                                                     Func(key_int32_int32, -1));\n\n      Message* message_int32_double = mmf_int32_double->Mutable(i);\n      int32 key_int32_double = message_int32_double->GetReflection()->GetInt32(\n          *message_int32_double, fd_map_int32_double_key);\n      message_int32_double->GetReflection()->SetDouble(\n          message_int32_double, fd_map_int32_double_value,\n          Func(key_int32_double, -2));\n\n      Message* message_string_string = mmf_string_string->Mutable(i);\n      string key_string_string =\n          message_string_string->GetReflection()->GetString(\n              *message_string_string, fd_map_string_string_key);\n      message_string_string->GetReflection()->SetString(\n          message_string_string, fd_map_string_string_value,\n          StrFunc(Int(key_string_string), -5));\n\n      Message* message_int32_message = mmf_int32_foreign_message->Mutable(i);\n      int32 key_int32_message =\n          message_int32_message->GetReflection()->GetInt32(\n              *message_int32_message, fd_map_int32_foreign_message_key);\n      ForeignMessage* value_int32_message = down_cast<ForeignMessage*>(\n          message_int32_message->GetReflection()\n              ->MutableMessage(message_int32_message,\n                               fd_map_int32_foreign_message_value));\n      value_int32_message->set_c(Func(key_int32_message, -6));\n    }\n  }\n\n  // Check gets through mutable objects.\n  for (int i = 0; i < 10; i++) {\n    EXPECT_EQ(Func(i, -1), message.map_int32_int32().at(i));\n    EXPECT_EQ(Func(i, -2), message.map_int32_double().at(i));\n    EXPECT_EQ(StrFunc(i, -5), message.map_string_string().at(StrFunc(i, 1)));\n    EXPECT_EQ(Func(i, -6), message.map_int32_foreign_message().at(i).c());\n  }\n}\n\nTEST_F(MapFieldReflectionTest, RepeatedFieldRefForRegularFields) {\n  TestMap message;\n  const Reflection* refl = message.GetReflection();\n  const Descriptor* desc = message.GetDescriptor();\n\n  Map<int32, int32>* map_int32_int32 = message.mutable_map_int32_int32();\n  Map<int32, double>* map_int32_double = message.mutable_map_int32_double();\n  Map<string, string>* map_string_string = message.mutable_map_string_string();\n  Map<int32, ForeignMessage>* map_int32_foreign_message =\n      message.mutable_map_int32_foreign_message();\n\n  for (int i = 0; i < 10; ++i) {\n    (*map_int32_int32)[i] = Func(i, 1);\n    (*map_int32_double)[i] = Func(i, 2);\n    (*map_string_string)[StrFunc(i, 1)] = StrFunc(i, 5);\n    (*map_int32_foreign_message)[i].set_c(Func(i, 6));\n  }\n\n  // Get FieldDescriptors for all the fields of interest.\n  const FieldDescriptor* fd_map_int32_int32 =\n      desc->FindFieldByName(\"map_int32_int32\");\n  const FieldDescriptor* fd_map_int32_double =\n      desc->FindFieldByName(\"map_int32_double\");\n  const FieldDescriptor* fd_map_string_string =\n      desc->FindFieldByName(\"map_string_string\");\n  const FieldDescriptor* fd_map_int32_foreign_message =\n      desc->FindFieldByName(\"map_int32_foreign_message\");\n\n  const FieldDescriptor* fd_map_int32_in32_key =\n      fd_map_int32_int32->message_type()->FindFieldByName(\"key\");\n  const FieldDescriptor* fd_map_int32_in32_value =\n      fd_map_int32_int32->message_type()->FindFieldByName(\"value\");\n  const FieldDescriptor* fd_map_int32_double_key =\n      fd_map_int32_double->message_type()->FindFieldByName(\"key\");\n  const FieldDescriptor* fd_map_int32_double_value =\n      fd_map_int32_double->message_type()->FindFieldByName(\"value\");\n  const FieldDescriptor* fd_map_string_string_key =\n      fd_map_string_string->message_type()->FindFieldByName(\"key\");\n  const FieldDescriptor* fd_map_string_string_value =\n      fd_map_string_string->message_type()->FindFieldByName(\"value\");\n  const FieldDescriptor* fd_map_int32_foreign_message_key =\n      fd_map_int32_foreign_message->message_type()->FindFieldByName(\"key\");\n  const FieldDescriptor* fd_map_int32_foreign_message_value =\n      fd_map_int32_foreign_message->message_type()->FindFieldByName(\"value\");\n\n  // Get RepeatedFieldRef objects for all fields of interest.\n  const RepeatedFieldRef<Message> mf_int32_int32 =\n      refl->GetRepeatedFieldRef<Message>(message, fd_map_int32_int32);\n  const RepeatedFieldRef<Message> mf_int32_double =\n      refl->GetRepeatedFieldRef<Message>(message, fd_map_int32_double);\n  const RepeatedFieldRef<Message> mf_string_string =\n      refl->GetRepeatedFieldRef<Message>(message, fd_map_string_string);\n  const RepeatedFieldRef<Message> mf_int32_foreign_message =\n      refl->GetRepeatedFieldRef<Message>(message, fd_map_int32_foreign_message);\n\n  // Get mutable RepeatedFieldRef objects for all fields of interest.\n  const MutableRepeatedFieldRef<Message> mmf_int32_int32 =\n      refl->GetMutableRepeatedFieldRef<Message>(&message, fd_map_int32_int32);\n  const MutableRepeatedFieldRef<Message> mmf_int32_double =\n      refl->GetMutableRepeatedFieldRef<Message>(&message, fd_map_int32_double);\n  const MutableRepeatedFieldRef<Message> mmf_string_string =\n      refl->GetMutableRepeatedFieldRef<Message>(&message, fd_map_string_string);\n  const MutableRepeatedFieldRef<Message>\n      mmf_int32_foreign_message =\n          refl->GetMutableRepeatedFieldRef<Message>(\n              &message, fd_map_int32_foreign_message);\n\n  // Get entry default instances\n  google::protobuf::scoped_ptr<Message> entry_int32_int32(\n      MessageFactory::generated_factory()\n          ->GetPrototype(fd_map_int32_int32->message_type())\n          ->New());\n  google::protobuf::scoped_ptr<Message> entry_int32_double(\n      MessageFactory::generated_factory()\n          ->GetPrototype(fd_map_int32_double->message_type())\n          ->New());\n  google::protobuf::scoped_ptr<Message> entry_string_string(\n      MessageFactory::generated_factory()\n          ->GetPrototype(fd_map_string_string->message_type())\n          ->New());\n  google::protobuf::scoped_ptr<Message> entry_int32_foreign_message(\n      MessageFactory::generated_factory()\n          ->GetPrototype(fd_map_int32_foreign_message->message_type())\n          ->New());\n\n  EXPECT_EQ(10, mf_int32_int32.size());\n  EXPECT_EQ(10, mmf_int32_int32.size());\n  EXPECT_EQ(10, mf_int32_double.size());\n  EXPECT_EQ(10, mmf_int32_double.size());\n  EXPECT_EQ(10, mf_string_string.size());\n  EXPECT_EQ(10, mmf_string_string.size());\n  EXPECT_EQ(10, mf_int32_foreign_message.size());\n  EXPECT_EQ(10, mmf_int32_foreign_message.size());\n\n  EXPECT_FALSE(mf_int32_int32.empty());\n  EXPECT_FALSE(mmf_int32_int32.empty());\n  EXPECT_FALSE(mf_int32_double.empty());\n  EXPECT_FALSE(mmf_int32_double.empty());\n  EXPECT_FALSE(mf_string_string.empty());\n  EXPECT_FALSE(mmf_string_string.empty());\n  EXPECT_FALSE(mf_int32_foreign_message.empty());\n  EXPECT_FALSE(mmf_int32_foreign_message.empty());\n\n  // Make sure we can do gets through the RepeatedFieldRef objects.\n  for (int i = 0; i < 10; ++i) {\n    {\n      // Check gets through const objects.\n      const Message& message_int32_int32 =\n          mf_int32_int32.Get(i, entry_int32_int32.get());\n      int32 key_int32_int32 = message_int32_int32.GetReflection()->GetInt32(\n          message_int32_int32, fd_map_int32_in32_key);\n      int32 value_int32_int32 = message_int32_int32.GetReflection()->GetInt32(\n          message_int32_int32, fd_map_int32_in32_value);\n      EXPECT_EQ(value_int32_int32, Func(key_int32_int32, 1));\n\n      const Message& message_int32_double =\n          mf_int32_double.Get(i, entry_int32_double.get());\n      int32 key_int32_double = message_int32_double.GetReflection()->GetInt32(\n          message_int32_double, fd_map_int32_double_key);\n      double value_int32_double =\n          message_int32_double.GetReflection()->GetDouble(\n              message_int32_double, fd_map_int32_double_value);\n      EXPECT_EQ(value_int32_double, Func(key_int32_double, 2));\n\n      const Message& message_string_string =\n          mf_string_string.Get(i, entry_string_string.get());\n      string key_string_string =\n          message_string_string.GetReflection()->GetString(\n              message_string_string, fd_map_string_string_key);\n      string value_string_string =\n          message_string_string.GetReflection()->GetString(\n              message_string_string, fd_map_string_string_value);\n      EXPECT_EQ(value_string_string, StrFunc(Int(key_string_string), 5));\n\n      const Message& message_int32_message =\n          mf_int32_foreign_message.Get(i, entry_int32_foreign_message.get());\n      int32 key_int32_message = message_int32_message.GetReflection()->GetInt32(\n          message_int32_message, fd_map_int32_foreign_message_key);\n      const ForeignMessage& value_int32_message =\n          down_cast<const ForeignMessage&>(\n              message_int32_message.GetReflection()\n                  ->GetMessage(message_int32_message,\n                               fd_map_int32_foreign_message_value));\n      EXPECT_EQ(value_int32_message.c(), Func(key_int32_message, 6));\n    }\n\n    {\n      // Check gets through mutable objects.\n      const Message& message_int32_int32 =\n          mmf_int32_int32.Get(i, entry_int32_int32.get());\n      int32 key_int32_int32 = message_int32_int32.GetReflection()->GetInt32(\n          message_int32_int32, fd_map_int32_in32_key);\n      int32 value_int32_int32 = message_int32_int32.GetReflection()->GetInt32(\n          message_int32_int32, fd_map_int32_in32_value);\n      EXPECT_EQ(value_int32_int32, Func(key_int32_int32, 1));\n\n      const Message& message_int32_double =\n          mmf_int32_double.Get(i, entry_int32_double.get());\n      int32 key_int32_double = message_int32_double.GetReflection()->GetInt32(\n          message_int32_double, fd_map_int32_double_key);\n      double value_int32_double =\n          message_int32_double.GetReflection()->GetDouble(\n              message_int32_double, fd_map_int32_double_value);\n      EXPECT_EQ(value_int32_double, Func(key_int32_double, 2));\n\n      const Message& message_string_string =\n          mmf_string_string.Get(i, entry_string_string.get());\n      string key_string_string =\n          message_string_string.GetReflection()->GetString(\n              message_string_string, fd_map_string_string_key);\n      string value_string_string =\n          message_string_string.GetReflection()->GetString(\n              message_string_string, fd_map_string_string_value);\n      EXPECT_EQ(value_string_string, StrFunc(Int(key_string_string), 5));\n\n      const Message& message_int32_message =\n          mmf_int32_foreign_message.Get(i, entry_int32_foreign_message.get());\n      int32 key_int32_message = message_int32_message.GetReflection()->GetInt32(\n          message_int32_message, fd_map_int32_foreign_message_key);\n      const ForeignMessage& value_int32_message =\n          down_cast<const ForeignMessage&>(\n              message_int32_message.GetReflection()\n                  ->GetMessage(message_int32_message,\n                               fd_map_int32_foreign_message_value));\n      EXPECT_EQ(value_int32_message.c(), Func(key_int32_message, 6));\n    }\n  }\n\n  // Make sure we can do sets through the RepeatedFieldRef objects.\n  for (int i = 0; i < 10; i++) {\n    const Message& message_int32_int32 =\n        mmf_int32_int32.Get(i, entry_int32_int32.get());\n    int key = message_int32_int32.GetReflection()->GetInt32(\n        message_int32_int32, fd_map_int32_in32_key);\n\n    entry_int32_int32->GetReflection()->SetInt32(\n        entry_int32_int32.get(), fd_map_int32_int32->message_type()->field(0),\n        key);\n    entry_int32_int32->GetReflection()->SetInt32(\n        entry_int32_int32.get(), fd_map_int32_int32->message_type()->field(1),\n        Func(key, -1));\n    entry_int32_double->GetReflection()->SetInt32(\n        entry_int32_double.get(), fd_map_int32_double->message_type()->field(0),\n        key);\n    entry_int32_double->GetReflection()->SetDouble(\n        entry_int32_double.get(), fd_map_int32_double->message_type()->field(1),\n        Func(key, -2));\n    entry_string_string->GetReflection()->SetString(\n        entry_string_string.get(),\n        fd_map_string_string->message_type()->field(0), StrFunc(key, 1));\n    entry_string_string->GetReflection()->SetString(\n        entry_string_string.get(),\n        fd_map_string_string->message_type()->field(1), StrFunc(key, -5));\n    entry_int32_foreign_message->GetReflection()->SetInt32(\n        entry_int32_foreign_message.get(),\n        fd_map_int32_foreign_message->message_type()->field(0), key);\n    Message* value_message =\n        entry_int32_foreign_message->GetReflection()->MutableMessage(\n            entry_int32_foreign_message.get(),\n            fd_map_int32_foreign_message->message_type()->field(1));\n    value_message->GetReflection()->SetInt32(\n        value_message, value_message->GetDescriptor()->FindFieldByName(\"c\"),\n        Func(key, -6));\n\n    mmf_int32_int32.Set(i, *entry_int32_int32);\n    mmf_int32_double.Set(i, *entry_int32_double);\n    mmf_string_string.Set(i, *entry_string_string);\n    mmf_int32_foreign_message.Set(i, *entry_int32_foreign_message);\n  }\n\n  for (int i = 0; i < 10; i++) {\n    EXPECT_EQ(Func(i, -1), message.map_int32_int32().at(i));\n    EXPECT_EQ(Func(i, -2), message.map_int32_double().at(i));\n    EXPECT_EQ(StrFunc(i, -5), message.map_string_string().at(StrFunc(i, 1)));\n    EXPECT_EQ(Func(i, -6), message.map_int32_foreign_message().at(i).c());\n  }\n\n  // Test iterators.\n  {\n    int index = 0;\n    hash_map<int32, int32> result;\n    for (RepeatedFieldRef<Message>::iterator it = mf_int32_int32.begin();\n         it != mf_int32_int32.end(); ++it) {\n      const Message& message = *it;\n      int32 key =\n          message.GetReflection()->GetInt32(message, fd_map_int32_in32_key);\n      int32 value =\n          message.GetReflection()->GetInt32(message, fd_map_int32_in32_value);\n      result[key] = value;\n      ++index;\n    }\n    EXPECT_EQ(10, index);\n    for (hash_map<int32, int32>::const_iterator it = result.begin();\n         it != result.end(); ++it) {\n      EXPECT_EQ(message.map_int32_int32().at(it->first), it->second);\n    }\n  }\n\n  {\n    int index = 0;\n    hash_map<int32, double> result;\n    for (RepeatedFieldRef<Message>::iterator it = mf_int32_double.begin();\n         it != mf_int32_double.end(); ++it) {\n      const Message& message = *it;\n      int32 key =\n          message.GetReflection()->GetInt32(message, fd_map_int32_double_key);\n      double value = message.GetReflection()->GetDouble(\n          message, fd_map_int32_double_value);\n      result[key] = value;\n      ++index;\n    }\n    EXPECT_EQ(10, index);\n    for (hash_map<int32, double>::const_iterator it = result.begin();\n         it != result.end(); ++it) {\n      EXPECT_EQ(message.map_int32_double().at(it->first), it->second);\n    }\n  }\n\n  {\n    int index = 0;\n    hash_map<string, string> result;\n    for (RepeatedFieldRef<Message>::iterator it = mf_string_string.begin();\n         it != mf_string_string.end(); ++it) {\n      const Message& message = *it;\n      string key =\n          message.GetReflection()->GetString(message, fd_map_string_string_key);\n      string value = message.GetReflection()->GetString(\n          message, fd_map_string_string_value);\n      result[key] = value;\n      ++index;\n    }\n    EXPECT_EQ(10, index);\n    for (hash_map<string, string>::const_iterator it = result.begin();\n         it != result.end(); ++it) {\n      EXPECT_EQ(message.map_string_string().at(it->first), it->second);\n    }\n  }\n\n  {\n    int index = 0;\n    std::map<int32, ForeignMessage> result;\n    for (RepeatedFieldRef<Message>::iterator it =\n             mf_int32_foreign_message.begin();\n         it != mf_int32_foreign_message.end(); ++it) {\n      const Message& message = *it;\n      int32 key = message.GetReflection()->GetInt32(\n          message, fd_map_int32_foreign_message_key);\n      const ForeignMessage& sub_message = down_cast<const ForeignMessage&>(\n          message.GetReflection()\n              ->GetMessage(message, fd_map_int32_foreign_message_value));\n      result[key].MergeFrom(sub_message);\n      ++index;\n    }\n    EXPECT_EQ(10, index);\n    for (std::map<int32, ForeignMessage>::const_iterator it = result.begin();\n         it != result.end(); ++it) {\n      EXPECT_EQ(message.map_int32_foreign_message().at(it->first).c(),\n                it->second.c());\n    }\n  }\n\n  // Test MutableRepeatedFieldRef::Add()\n  entry_int32_int32->GetReflection()->SetInt32(\n      entry_int32_int32.get(), fd_map_int32_int32->message_type()->field(0),\n      4321);\n  entry_int32_int32->GetReflection()->SetInt32(\n      entry_int32_int32.get(), fd_map_int32_int32->message_type()->field(1),\n      1234);\n  mmf_int32_int32.Add(*entry_int32_int32);\n  EXPECT_EQ(1234, message.map_int32_int32().at(4321));\n\n  entry_int32_double->GetReflection()->SetInt32(\n      entry_int32_double.get(), fd_map_int32_double->message_type()->field(0),\n      4321);\n  entry_int32_double->GetReflection()->SetDouble(\n      entry_int32_double.get(), fd_map_int32_double->message_type()->field(1),\n      1234.0);\n  mmf_int32_double.Add(*entry_int32_double);\n  EXPECT_EQ(1234.0, message.map_int32_double().at(4321));\n\n  entry_string_string->GetReflection()->SetString(\n      entry_string_string.get(),\n      fd_map_string_string->message_type()->field(0), \"4321\");\n  entry_string_string->GetReflection()->SetString(\n      entry_string_string.get(), fd_map_string_string->message_type()->field(1),\n      \"1234\");\n  mmf_string_string.Add(*entry_string_string);\n  EXPECT_EQ(\"1234\", message.map_string_string().at(\"4321\"));\n\n  entry_int32_foreign_message->GetReflection()->SetInt32(\n      entry_int32_foreign_message.get(),\n      fd_map_int32_foreign_message->message_type()->field(0), 4321);\n  Message* value_message =\n      entry_int32_foreign_message->GetReflection()->MutableMessage(\n          entry_int32_foreign_message.get(),\n          fd_map_int32_foreign_message->message_type()->field(1));\n  ForeignMessage foreign_message;\n  foreign_message.set_c(1234);\n  value_message->CopyFrom(foreign_message);\n\n  mmf_int32_foreign_message.Add(*entry_int32_foreign_message);\n  EXPECT_EQ(1234, message.map_int32_foreign_message().at(4321).c());\n\n  // Test Reflection::AddAllocatedMessage\n  Message* free_entry_string_string = MessageFactory::generated_factory()\n      ->GetPrototype(fd_map_string_string->message_type())\n      ->New();\n  entry_string_string->GetReflection()->SetString(\n      free_entry_string_string,\n      fd_map_string_string->message_type()->field(0), \"4321\");\n  entry_string_string->GetReflection()->SetString(\n      free_entry_string_string, fd_map_string_string->message_type()->field(1),\n      \"1234\");\n  refl->AddAllocatedMessage(&message, fd_map_string_string,\n                            free_entry_string_string);\n\n  // Test MutableRepeatedFieldRef::RemoveLast()\n  mmf_int32_int32.RemoveLast();\n  mmf_int32_double.RemoveLast();\n  mmf_string_string.RemoveLast();\n  mmf_int32_foreign_message.RemoveLast();\n  EXPECT_EQ(10, message.map_int32_int32().size());\n  EXPECT_EQ(10, message.map_int32_double().size());\n  EXPECT_EQ(11, message.map_string_string().size());\n  EXPECT_EQ(10, message.map_int32_foreign_message().size());\n\n  // Test MutableRepeatedFieldRef::SwapElements()\n  {\n    const Message& message0a = mmf_int32_int32.Get(0, entry_int32_int32.get());\n    int32 int32_value0a =\n        message0a.GetReflection()->GetInt32(message0a, fd_map_int32_in32_value);\n    const Message& message9a = mmf_int32_int32.Get(9, entry_int32_int32.get());\n    int32 int32_value9a =\n        message9a.GetReflection()->GetInt32(message9a, fd_map_int32_in32_value);\n\n    mmf_int32_int32.SwapElements(0, 9);\n\n    const Message& message0b = mmf_int32_int32.Get(0, entry_int32_int32.get());\n    int32 int32_value0b =\n        message0b.GetReflection()->GetInt32(message0b, fd_map_int32_in32_value);\n    const Message& message9b = mmf_int32_int32.Get(9, entry_int32_int32.get());\n    int32 int32_value9b =\n        message9b.GetReflection()->GetInt32(message9b, fd_map_int32_in32_value);\n\n    EXPECT_EQ(int32_value9a, int32_value0b);\n    EXPECT_EQ(int32_value0a, int32_value9b);\n  }\n\n  {\n    const Message& message0a =\n        mmf_int32_double.Get(0, entry_int32_double.get());\n    double double_value0a = message0a.GetReflection()->GetDouble(\n        message0a, fd_map_int32_double_value);\n    const Message& message9a =\n        mmf_int32_double.Get(9, entry_int32_double.get());\n    double double_value9a = message9a.GetReflection()->GetDouble(\n        message9a, fd_map_int32_double_value);\n\n    mmf_int32_double.SwapElements(0, 9);\n\n    const Message& message0b =\n        mmf_int32_double.Get(0, entry_int32_double.get());\n    double double_value0b = message0b.GetReflection()->GetDouble(\n        message0b, fd_map_int32_double_value);\n    const Message& message9b =\n        mmf_int32_double.Get(9, entry_int32_double.get());\n    double double_value9b = message9b.GetReflection()->GetDouble(\n        message9b, fd_map_int32_double_value);\n\n    EXPECT_EQ(double_value9a, double_value0b);\n    EXPECT_EQ(double_value0a, double_value9b);\n  }\n\n  {\n    const Message& message0a =\n        mmf_string_string.Get(0, entry_string_string.get());\n    string string_value0a = message0a.GetReflection()->GetString(\n        message0a, fd_map_string_string_value);\n    const Message& message9a =\n        mmf_string_string.Get(9, entry_string_string.get());\n    string string_value9a = message9a.GetReflection()->GetString(\n        message9a, fd_map_string_string_value);\n\n    mmf_string_string.SwapElements(0, 9);\n\n    const Message& message0b =\n        mmf_string_string.Get(0, entry_string_string.get());\n    string string_value0b = message0b.GetReflection()->GetString(\n        message0b, fd_map_string_string_value);\n    const Message& message9b =\n        mmf_string_string.Get(9, entry_string_string.get());\n    string string_value9b = message9b.GetReflection()->GetString(\n        message9b, fd_map_string_string_value);\n\n    EXPECT_EQ(string_value9a, string_value0b);\n    EXPECT_EQ(string_value0a, string_value9b);\n  }\n\n  {\n    const Message& message0a =\n        mmf_int32_foreign_message.Get(0, entry_int32_foreign_message.get());\n    const ForeignMessage& sub_message0a = down_cast<const ForeignMessage&>(\n        message0a.GetReflection()\n            ->GetMessage(message0a, fd_map_int32_foreign_message_value));\n    int32 int32_value0a = sub_message0a.c();\n    const Message& message9a =\n        mmf_int32_foreign_message.Get(9, entry_int32_foreign_message.get());\n    const ForeignMessage& sub_message9a = down_cast<const ForeignMessage&>(\n        message9a.GetReflection()\n            ->GetMessage(message9a, fd_map_int32_foreign_message_value));\n    int32 int32_value9a = sub_message9a.c();\n\n    mmf_int32_foreign_message.SwapElements(0, 9);\n\n    const Message& message0b =\n        mmf_int32_foreign_message.Get(0, entry_int32_foreign_message.get());\n    const ForeignMessage& sub_message0b = down_cast<const ForeignMessage&>(\n        message0b.GetReflection()\n            ->GetMessage(message0b, fd_map_int32_foreign_message_value));\n    int32 int32_value0b = sub_message0b.c();\n    const Message& message9b =\n        mmf_int32_foreign_message.Get(9, entry_int32_foreign_message.get());\n    const ForeignMessage& sub_message9b = down_cast<const ForeignMessage&>(\n        message9b.GetReflection()\n            ->GetMessage(message9b, fd_map_int32_foreign_message_value));\n    int32 int32_value9b = sub_message9b.c();\n\n    EXPECT_EQ(int32_value9a, int32_value0b);\n    EXPECT_EQ(int32_value0a, int32_value9b);\n  }\n}\n\nTEST_F(MapFieldReflectionTest, RepeatedFieldRefMergeFromAndSwap) {\n  // Set-up message content.\n  TestMap m0, m1, m2;\n  for (int i = 0; i < 10; ++i) {\n    (*m0.mutable_map_int32_int32())[i] = Func(i, 1);\n    (*m0.mutable_map_int32_double())[i] = Func(i, 2);\n    (*m0.mutable_map_string_string())[StrFunc(i, 1)] = StrFunc(i, 5);\n    (*m0.mutable_map_int32_foreign_message())[i].set_c(Func(i, 6));\n    (*m1.mutable_map_int32_int32())[i + 10] = Func(i, 11);\n    (*m1.mutable_map_int32_double())[i + 10] = Func(i, 12);\n    (*m1.mutable_map_string_string())[StrFunc(i + 10, 1)] = StrFunc(i, 15);\n    (*m1.mutable_map_int32_foreign_message())[i + 10].set_c(Func(i, 16));\n    (*m2.mutable_map_int32_int32())[i + 20] = Func(i, 21);\n    (*m2.mutable_map_int32_double())[i + 20] = Func(i, 22);\n    (*m2.mutable_map_string_string())[StrFunc(i + 20, 1)] = StrFunc(i, 25);\n    (*m2.mutable_map_int32_foreign_message())[i + 20].set_c(Func(i, 26));\n  }\n\n  const Reflection* refl = m0.GetReflection();\n  const Descriptor* desc = m0.GetDescriptor();\n\n  // Get FieldDescriptors for all the fields of interest.\n  const FieldDescriptor* fd_map_int32_int32 =\n      desc->FindFieldByName(\"map_int32_int32\");\n  const FieldDescriptor* fd_map_int32_double =\n      desc->FindFieldByName(\"map_int32_double\");\n  const FieldDescriptor* fd_map_string_string =\n      desc->FindFieldByName(\"map_string_string\");\n  const FieldDescriptor* fd_map_int32_foreign_message =\n      desc->FindFieldByName(\"map_int32_foreign_message\");\n\n    // Get MutableRepeatedFieldRef objects for all fields of interest.\n  const MutableRepeatedFieldRef<Message> mmf_int32_int32 =\n      refl->GetMutableRepeatedFieldRef<Message>(\n          &m0, fd_map_int32_int32);\n  const MutableRepeatedFieldRef<Message> mmf_int32_double =\n      refl->GetMutableRepeatedFieldRef<Message>(\n          &m0, fd_map_int32_double);\n  const MutableRepeatedFieldRef<Message> mmf_string_string =\n      refl->GetMutableRepeatedFieldRef<Message>(\n          &m0, fd_map_string_string);\n  const MutableRepeatedFieldRef<Message>\n      mmf_int32_foreign_message =\n          refl->GetMutableRepeatedFieldRef<Message>(\n              &m0, fd_map_int32_foreign_message);\n\n  // Test MutableRepeatedRef::CopyFrom\n  mmf_int32_int32.CopyFrom(\n      refl->GetRepeatedFieldRef<Message>(\n          m1, fd_map_int32_int32));\n  mmf_int32_double.CopyFrom(\n      refl->GetRepeatedFieldRef<Message>(\n          m1, fd_map_int32_double));\n  mmf_string_string.CopyFrom(\n      refl->GetRepeatedFieldRef<Message>(\n          m1, fd_map_string_string));\n  mmf_int32_foreign_message.CopyFrom(\n      refl->GetRepeatedFieldRef<Message>(\n          m1, fd_map_int32_foreign_message));\n\n  for (int i = 0; i < 10; ++i) {\n    EXPECT_EQ(Func(i, 11), m0.map_int32_int32().at(i + 10));\n    EXPECT_EQ(Func(i, 12), m0.map_int32_double().at(i + 10));\n    EXPECT_EQ(StrFunc(i, 15), m0.map_string_string().at(StrFunc(i + 10, 1)));\n    EXPECT_EQ(Func(i, 16), m0.map_int32_foreign_message().at(i + 10).c());\n  }\n\n  // Test MutableRepeatedRef::MergeFrom\n  mmf_int32_int32.MergeFrom(\n      refl->GetRepeatedFieldRef<Message>(\n          m2, fd_map_int32_int32));\n  mmf_int32_double.MergeFrom(\n      refl->GetRepeatedFieldRef<Message>(\n          m2, fd_map_int32_double));\n  mmf_string_string.MergeFrom(\n      refl->GetRepeatedFieldRef<Message>(\n          m2, fd_map_string_string));\n  mmf_int32_foreign_message.MergeFrom(\n      refl->GetRepeatedFieldRef<Message>(\n          m2, fd_map_int32_foreign_message));\n  for (int i = 0; i < 10; ++i) {\n    EXPECT_EQ(Func(i, 21), m0.map_int32_int32().at(i + 20));\n    EXPECT_EQ(Func(i, 22), m0.map_int32_double().at(i + 20));\n    EXPECT_EQ(StrFunc(i, 25), m0.map_string_string().at(StrFunc(i + 20, 1)));\n    EXPECT_EQ(Func(i, 26), m0.map_int32_foreign_message().at(i + 20).c());\n  }\n\n  // Test MutableRepeatedRef::Swap\n  // Swap between m0 and m2.\n  mmf_int32_int32.Swap(\n      refl->GetMutableRepeatedFieldRef<Message>(\n          &m2, fd_map_int32_int32));\n  mmf_int32_double.Swap(\n      refl->GetMutableRepeatedFieldRef<Message>(\n          &m2, fd_map_int32_double));\n  mmf_string_string.Swap(\n      refl->GetMutableRepeatedFieldRef<Message>(\n          &m2, fd_map_string_string));\n  mmf_int32_foreign_message.Swap(\n      refl->GetMutableRepeatedFieldRef<Message>(\n          &m2, fd_map_int32_foreign_message));\n  for (int i = 0; i < 10; ++i) {\n    // Check the content of m0.\n    EXPECT_EQ(Func(i, 21), m0.map_int32_int32().at(i + 20));\n    EXPECT_EQ(Func(i, 22), m0.map_int32_double().at(i + 20));\n    EXPECT_EQ(StrFunc(i, 25), m0.map_string_string().at(StrFunc(i + 20, 1)));\n    EXPECT_EQ(Func(i, 26), m0.map_int32_foreign_message().at(i + 20).c());\n\n    // Check the content of m2.\n    EXPECT_EQ(Func(i, 11), m2.map_int32_int32().at(i + 10));\n    EXPECT_EQ(Func(i, 12), m2.map_int32_double().at(i + 10));\n    EXPECT_EQ(StrFunc(i, 15), m2.map_string_string().at(StrFunc(i + 10, 1)));\n    EXPECT_EQ(Func(i, 16), m2.map_int32_foreign_message().at(i + 10).c());\n    EXPECT_EQ(Func(i, 21), m2.map_int32_int32().at(i + 20));\n    EXPECT_EQ(Func(i, 22), m2.map_int32_double().at(i + 20));\n    EXPECT_EQ(StrFunc(i, 25), m2.map_string_string().at(StrFunc(i + 20, 1)));\n    EXPECT_EQ(Func(i, 26), m2.map_int32_foreign_message().at(i + 20).c());\n  }\n\n  // TODO(teboring): add test for duplicated key\n}\n\n// Generated Message Test ===========================================\n\nTEST(GeneratedMapFieldTest, Accessors) {\n  unittest::TestMap message;\n\n  MapTestUtil::SetMapFields(&message);\n  MapTestUtil::ExpectMapFieldsSet(message);\n\n  MapTestUtil::ModifyMapFields(&message);\n  MapTestUtil::ExpectMapFieldsModified(message);\n}\n\nTEST(GeneratedMapFieldTest, SetMapFieldsInitialized) {\n  unittest::TestMap message;\n\n  MapTestUtil::SetMapFieldsInitialized(&message);\n  MapTestUtil::ExpectMapFieldsSetInitialized(message);\n}\n\nTEST(GeneratedMapFieldTest, Proto2SetMapFieldsInitialized) {\n  unittest::TestEnumMap message;\n  EXPECT_EQ(unittest::PROTO2_MAP_ENUM_FOO,\n            (*message.mutable_known_map_field())[0]);\n}\n\nTEST(GeneratedMapFieldTest, Clear) {\n  unittest::TestMap message;\n\n  MapTestUtil::SetMapFields(&message);\n  message.Clear();\n  MapTestUtil::ExpectClear(message);\n}\n\nTEST(GeneratedMapFieldTest, ClearMessageMap) {\n  unittest::TestMessageMap message;\n\n  // Creates a TestAllTypes with default value\n  TestUtil::ExpectClear((*message.mutable_map_int32_message())[0]);\n}\n\nTEST(GeneratedMapFieldTest, CopyFrom) {\n  unittest::TestMap message1, message2;\n\n  MapTestUtil::SetMapFields(&message1);\n  message2.CopyFrom(message1);\n  MapTestUtil::ExpectMapFieldsSet(message2);\n\n  // Copying from self should be a no-op.\n  message2.CopyFrom(message2);\n  MapTestUtil::ExpectMapFieldsSet(message2);\n}\n\nTEST(GeneratedMapFieldTest, CopyFromMessageMap) {\n  unittest::TestMessageMap message1, message2;\n\n  (*message1.mutable_map_int32_message())[0].add_repeated_int32(100);\n  (*message2.mutable_map_int32_message())[0].add_repeated_int32(101);\n\n  message1.CopyFrom(message2);\n\n  // Checks repeated field is overwritten.\n  EXPECT_EQ(1, message1.map_int32_message().at(0).repeated_int32_size());\n  EXPECT_EQ(101, message1.map_int32_message().at(0).repeated_int32(0));\n}\n\nTEST(GeneratedMapFieldTest, SwapWithEmpty) {\n  unittest::TestMap message1, message2;\n\n  MapTestUtil::SetMapFields(&message1);\n  MapTestUtil::ExpectMapFieldsSet(message1);\n  MapTestUtil::ExpectClear(message2);\n\n  message1.Swap(&message2);\n  MapTestUtil::ExpectMapFieldsSet(message2);\n  MapTestUtil::ExpectClear(message1);\n}\n\nTEST(GeneratedMapFieldTest, SwapWithSelf) {\n  unittest::TestMap message;\n\n  MapTestUtil::SetMapFields(&message);\n  MapTestUtil::ExpectMapFieldsSet(message);\n\n  message.Swap(&message);\n  MapTestUtil::ExpectMapFieldsSet(message);\n}\n\nTEST(GeneratedMapFieldTest, SwapWithOther) {\n  unittest::TestMap message1, message2;\n\n  MapTestUtil::SetMapFields(&message1);\n  MapTestUtil::SetMapFields(&message2);\n  MapTestUtil::ModifyMapFields(&message2);\n\n  message1.Swap(&message2);\n  MapTestUtil::ExpectMapFieldsModified(message1);\n  MapTestUtil::ExpectMapFieldsSet(message2);\n}\n\nTEST(GeneratedMapFieldTest, CopyConstructor) {\n  unittest::TestMap message1;\n  MapTestUtil::SetMapFields(&message1);\n\n  unittest::TestMap message2(message1);\n  MapTestUtil::ExpectMapFieldsSet(message2);\n}\n\nTEST(GeneratedMapFieldTest, CopyAssignmentOperator) {\n  unittest::TestMap message1;\n  MapTestUtil::SetMapFields(&message1);\n\n  unittest::TestMap message2;\n  message2 = message1;\n  MapTestUtil::ExpectMapFieldsSet(message2);\n\n  // Make sure that self-assignment does something sane.\n  message2.operator=(message2);\n  MapTestUtil::ExpectMapFieldsSet(message2);\n}\n\n#if !defined(PROTOBUF_TEST_NO_DESCRIPTORS) || \\\n        !defined(GOOGLE_PROTOBUF_NO_RTTI)\nTEST(GeneratedMapFieldTest, UpcastCopyFrom) {\n  // Test the CopyFrom method that takes in the generic const Message&\n  // parameter.\n  unittest::TestMap message1, message2;\n\n  MapTestUtil::SetMapFields(&message1);\n\n  const Message* source = implicit_cast<const Message*>(&message1);\n  message2.CopyFrom(*source);\n\n  MapTestUtil::ExpectMapFieldsSet(message2);\n}\n#endif\n\n#ifndef PROTOBUF_TEST_NO_DESCRIPTORS\n\nTEST(GeneratedMapFieldTest, CopyFromDynamicMessage) {\n  // Test copying from a DynamicMessage, which must fall back to using\n  // reflection.\n  unittest::TestMap message2;\n\n  // Construct a new version of the dynamic message via the factory.\n  DynamicMessageFactory factory;\n  google::protobuf::scoped_ptr<Message> message1;\n  message1.reset(\n      factory.GetPrototype(unittest::TestMap::descriptor())->New());\n  MapReflectionTester reflection_tester(\n      unittest::TestMap::descriptor());\n  reflection_tester.SetMapFieldsViaReflection(message1.get());\n  reflection_tester.ExpectMapFieldsSetViaReflection(*message1);\n  reflection_tester.ExpectMapFieldsSetViaReflectionIterator(message1.get());\n  message2.CopyFrom(*message1);\n  MapTestUtil::ExpectMapFieldsSet(message2);\n}\n\nTEST(GeneratedMapFieldTest, CopyFromDynamicMessageMapReflection) {\n  unittest::TestMap message2;\n\n  // Construct a new version of the dynamic message via the factory.\n  DynamicMessageFactory factory;\n  google::protobuf::scoped_ptr<Message> message1;\n  message1.reset(\n      factory.GetPrototype(unittest::TestMap::descriptor())->New());\n  MapReflectionTester reflection_tester(\n      unittest::TestMap::descriptor());\n  reflection_tester.SetMapFieldsViaMapReflection(message1.get());\n  reflection_tester.ExpectMapFieldsSetViaReflection(*message1);\n  reflection_tester.ExpectMapFieldsSetViaReflectionIterator(message1.get());\n  message2.CopyFrom(*message1);\n  MapTestUtil::ExpectMapFieldsSet(message2);\n}\n\nTEST(GeneratedMapFieldTest, DynamicMessageCopyFrom) {\n  // Test copying to a DynamicMessage, which must fall back to using reflection.\n  unittest::TestMap message2;\n  MapTestUtil::SetMapFields(&message2);\n\n  // Construct a new version of the dynamic message via the factory.\n  DynamicMessageFactory factory;\n  google::protobuf::scoped_ptr<Message> message1;\n  message1.reset(\n      factory.GetPrototype(unittest::TestMap::descriptor())->New());\n\n  MapReflectionTester reflection_tester(\n      unittest::TestMap::descriptor());\n  message1->MergeFrom(message2);\n  reflection_tester.ExpectMapFieldsSetViaReflection(*message1);\n  reflection_tester.ExpectMapFieldsSetViaReflectionIterator(message1.get());\n}\n\nTEST(GeneratedMapFieldTest, DynamicMessageCopyFromMapReflection) {\n  MapReflectionTester reflection_tester(\n      unittest::TestMap::descriptor());\n  unittest::TestMap message2;\n  reflection_tester.SetMapFieldsViaMapReflection(&message2);\n\n  // Construct a dynamic message via the factory.\n  DynamicMessageFactory factory;\n  google::protobuf::scoped_ptr<Message> message1;\n  message1.reset(\n      factory.GetPrototype(unittest::TestMap::descriptor())->New());\n\n  message1->MergeFrom(message2);\n  reflection_tester.ExpectMapFieldsSetViaReflectionIterator(message1.get());\n  reflection_tester.ExpectMapFieldsSetViaReflection(*message1);\n}\n\nTEST(GeneratedMapFieldTest, SyncDynamicMapWithRepeatedField) {\n  // Construct a dynamic message via the factory.\n  MapReflectionTester reflection_tester(\n      unittest::TestMap::descriptor());\n  DynamicMessageFactory factory;\n  google::protobuf::scoped_ptr<Message> message;\n  message.reset(\n      factory.GetPrototype(unittest::TestMap::descriptor())->New());\n  reflection_tester.SetMapFieldsViaReflection(message.get());\n  reflection_tester.ExpectMapFieldsSetViaReflectionIterator(message.get());\n  reflection_tester.ExpectMapFieldsSetViaReflection(*message);\n}\n\n#endif  // !PROTOBUF_TEST_NO_DESCRIPTORS\n\nTEST(GeneratedMapFieldTest, NonEmptyMergeFrom) {\n  unittest::TestMap message1, message2;\n\n  MapTestUtil::SetMapFields(&message1);\n\n  // This field will test merging into an empty spot.\n  (*message2.mutable_map_int32_int32())[1] = 1;\n  message1.mutable_map_int32_int32()->erase(1);\n\n  // This tests overwriting.\n  (*message2.mutable_map_int32_double())[1] = 1;\n  (*message1.mutable_map_int32_double())[1] = 2;\n\n  message1.MergeFrom(message2);\n  MapTestUtil::ExpectMapFieldsSet(message1);\n}\n\nTEST(GeneratedMapFieldTest, MergeFromMessageMap) {\n  unittest::TestMessageMap message1, message2;\n\n  (*message1.mutable_map_int32_message())[0].add_repeated_int32(100);\n  (*message2.mutable_map_int32_message())[0].add_repeated_int32(101);\n\n  message1.MergeFrom(message2);\n\n  // Checks repeated field is overwritten.\n  EXPECT_EQ(1, message1.map_int32_message().at(0).repeated_int32_size());\n  EXPECT_EQ(101, message1.map_int32_message().at(0).repeated_int32(0));\n}\n\n// Test the generated SerializeWithCachedSizesToArray()\nTEST(GeneratedMapFieldTest, SerializationToArray) {\n  unittest::TestMap message1, message2;\n  string data;\n  MapTestUtil::SetMapFields(&message1);\n  int size = message1.ByteSize();\n  data.resize(size);\n  uint8* start = reinterpret_cast<uint8*>(string_as_array(&data));\n  uint8* end = message1.SerializeWithCachedSizesToArray(start);\n  EXPECT_EQ(size, end - start);\n  EXPECT_TRUE(message2.ParseFromString(data));\n  MapTestUtil::ExpectMapFieldsSet(message2);\n}\n\n// Test the generated SerializeWithCachedSizes()\nTEST(GeneratedMapFieldTest, SerializationToStream) {\n  unittest::TestMap message1, message2;\n  MapTestUtil::SetMapFields(&message1);\n  int size = message1.ByteSize();\n  string data;\n  data.resize(size);\n  {\n    // Allow the output stream to buffer only one byte at a time.\n    io::ArrayOutputStream array_stream(string_as_array(&data), size, 1);\n    io::CodedOutputStream output_stream(&array_stream);\n    message1.SerializeWithCachedSizes(&output_stream);\n    EXPECT_FALSE(output_stream.HadError());\n    EXPECT_EQ(size, output_stream.ByteCount());\n  }\n  EXPECT_TRUE(message2.ParseFromString(data));\n  MapTestUtil::ExpectMapFieldsSet(message2);\n}\n\n\nTEST(GeneratedMapFieldTest, SameTypeMaps) {\n  const Descriptor* map1 = unittest::TestSameTypeMap::descriptor()\n                               ->FindFieldByName(\"map1\")\n                               ->message_type();\n  const Descriptor* map2 = unittest::TestSameTypeMap::descriptor()\n                               ->FindFieldByName(\"map2\")\n                               ->message_type();\n\n  const Message* map1_entry =\n      MessageFactory::generated_factory()->GetPrototype(map1);\n  const Message* map2_entry =\n      MessageFactory::generated_factory()->GetPrototype(map2);\n\n  EXPECT_EQ(map1, map1_entry->GetDescriptor());\n  EXPECT_EQ(map2, map2_entry->GetDescriptor());\n}\n\nTEST(GeneratedMapFieldTest, Proto2UnknownEnum) {\n  unittest::TestEnumMapPlusExtra from;\n  (*from.mutable_known_map_field())[0] = unittest::E_PROTO2_MAP_ENUM_FOO;\n  (*from.mutable_unknown_map_field())[0] = unittest::E_PROTO2_MAP_ENUM_EXTRA;\n  string data;\n  from.SerializeToString(&data);\n\n  unittest::TestEnumMap to;\n  EXPECT_TRUE(to.ParseFromString(data));\n  EXPECT_EQ(0, to.unknown_map_field().size());\n  const UnknownFieldSet& unknown_field_set =\n      to.GetReflection()->GetUnknownFields(to);\n  EXPECT_EQ(1, unknown_field_set.field_count());\n  EXPECT_EQ(1, to.known_map_field().size());\n  EXPECT_EQ(unittest::PROTO2_MAP_ENUM_FOO, to.known_map_field().at(0));\n\n  data.clear();\n  from.Clear();\n  to.SerializeToString(&data);\n  EXPECT_TRUE(from.ParseFromString(data));\n  EXPECT_EQ(0, from.GetReflection()->GetUnknownFields(from).field_count());\n  EXPECT_EQ(1, from.known_map_field().size());\n  EXPECT_EQ(unittest::E_PROTO2_MAP_ENUM_FOO, from.known_map_field().at(0));\n  EXPECT_EQ(1, from.unknown_map_field().size());\n  EXPECT_EQ(unittest::E_PROTO2_MAP_ENUM_EXTRA, from.unknown_map_field().at(0));\n}\n\nTEST(GeneratedMapFieldTest, StandardWireFormat) {\n  unittest::TestMap message;\n  string data = \"\\x0A\\x04\\x08\\x01\\x10\\x01\";\n\n  EXPECT_TRUE(message.ParseFromString(data));\n  EXPECT_EQ(1, message.map_int32_int32().size());\n  EXPECT_EQ(1, message.map_int32_int32().at(1));\n}\n\nTEST(GeneratedMapFieldTest, UnorderedWireFormat) {\n  unittest::TestMap message;\n\n  // put value before key in wire format\n  string data = \"\\x0A\\x04\\x10\\x01\\x08\\x02\";\n\n  EXPECT_TRUE(message.ParseFromString(data));\n  EXPECT_EQ(1, message.map_int32_int32().size());\n  EXPECT_EQ(1, message.map_int32_int32().at(2));\n}\n\nTEST(GeneratedMapFieldTest, DuplicatedKeyWireFormat) {\n  unittest::TestMap message;\n\n  // Two key fields in wire format\n  string data = \"\\x0A\\x06\\x08\\x01\\x08\\x02\\x10\\x01\";\n\n  EXPECT_TRUE(message.ParseFromString(data));\n  EXPECT_EQ(1, message.map_int32_int32().size());\n  EXPECT_EQ(1, message.map_int32_int32().at(2));\n\n  // A similar test, but with a map from int to a message type.\n  // Again, we want to be sure that the \"second one wins\" when\n  // there are two separate entries with the same key.\n  const int key = 99;\n  unittest::TestRequiredMessageMap map_message;\n  unittest::TestRequired with_dummy4;\n  with_dummy4.set_a(0);\n  with_dummy4.set_b(0);\n  with_dummy4.set_c(0);\n  with_dummy4.set_dummy4(11);\n  (*map_message.mutable_map_field())[key] = with_dummy4;\n  string s = map_message.SerializeAsString();\n  unittest::TestRequired with_dummy5;\n  with_dummy5.set_a(0);\n  with_dummy5.set_b(0);\n  with_dummy5.set_c(0);\n  with_dummy5.set_dummy5(12);\n  (*map_message.mutable_map_field())[key] = with_dummy5;\n  string both = s + map_message.SerializeAsString();\n  // We don't expect a merge now.  The \"second one wins.\"\n  ASSERT_TRUE(map_message.ParseFromString(both));\n  ASSERT_EQ(1, map_message.map_field().size());\n  ASSERT_EQ(1, map_message.map_field().count(key));\n  EXPECT_EQ(0, map_message.map_field().find(key)->second.a());\n  EXPECT_EQ(0, map_message.map_field().find(key)->second.b());\n  EXPECT_EQ(0, map_message.map_field().find(key)->second.c());\n  EXPECT_FALSE(map_message.map_field().find(key)->second.has_dummy4());\n  ASSERT_TRUE(map_message.map_field().find(key)->second.has_dummy5());\n  EXPECT_EQ(12, map_message.map_field().find(key)->second.dummy5());\n}\n\n// Exhaustive combinations of keys, values, and junk in any order.\n// This re-tests some of the things tested above, but if it fails\n// it's more work to determine what went wrong, so it isn't necessarily\n// bad that we have the simpler tests too.\nTEST(GeneratedMapFieldTest, KeysValuesUnknownsWireFormat) {\n  unittest::TestMap message;\n  const int kMaxNumKeysAndValuesAndJunk = 4;\n  const char kKeyTag = 0x08;\n  const char kValueTag = 0x10;\n  const char kJunkTag = 0x20;\n  for (int items = 0; items <= kMaxNumKeysAndValuesAndJunk; items++) {\n    string data = \"\\x0A\";\n    // Encode length of what will follow.\n    data.push_back(items * 2);\n    static const int kBitsOfIPerItem = 4;\n    static const int mask = (1 << kBitsOfIPerItem) - 1;\n    // Each iteration of the following is a test.  It uses i as bit vector\n    // encoding the keys and values to put in the wire format.\n    for (int i = 0; i < (1 << (items * kBitsOfIPerItem)); i++) {\n      string wire_format = data;\n      int expected_key = 0;\n      int expected_value = 0;\n      for (int k = i, j = 0; j < items; j++, k >>= kBitsOfIPerItem) {\n        bool is_key = k & 0x1;\n        bool is_value = !is_key && (k & 0x2);\n        wire_format.push_back(is_key ? kKeyTag :\n                              is_value ? kValueTag : kJunkTag);\n        char c = static_cast<char>(k & mask) >> 2;  // One char after the tag.\n        wire_format.push_back(c);\n        if (is_key) expected_key = static_cast<int>(c);\n        if (is_value) expected_value = static_cast<int>(c);\n        ASSERT_TRUE(message.ParseFromString(wire_format));\n        ASSERT_EQ(1, message.map_int32_int32().size());\n        ASSERT_EQ(expected_key, message.map_int32_int32().begin()->first);\n        ASSERT_EQ(expected_value, message.map_int32_int32().begin()->second);\n      }\n    }\n  }\n}\n\nTEST(GeneratedMapFieldTest, DuplicatedValueWireFormat) {\n  unittest::TestMap message;\n\n  // Two value fields in wire format\n  string data = \"\\x0A\\x06\\x08\\x01\\x10\\x01\\x10\\x02\";\n\n  EXPECT_TRUE(message.ParseFromString(data));\n  EXPECT_EQ(1, message.map_int32_int32().size());\n  EXPECT_EQ(2, message.map_int32_int32().at(1));\n}\n\nTEST(GeneratedMapFieldTest, MissedKeyWireFormat) {\n  unittest::TestMap message;\n\n  // No key field in wire format\n  string data = \"\\x0A\\x02\\x10\\x01\";\n\n  EXPECT_TRUE(message.ParseFromString(data));\n  EXPECT_EQ(1, message.map_int32_int32().size());\n  EXPECT_EQ(1, message.map_int32_int32().at(0));\n}\n\nTEST(GeneratedMapFieldTest, MissedValueWireFormat) {\n  unittest::TestMap message;\n\n  // No value field in wire format\n  string data = \"\\x0A\\x02\\x08\\x01\";\n\n  EXPECT_TRUE(message.ParseFromString(data));\n  EXPECT_EQ(1, message.map_int32_int32().size());\n  EXPECT_EQ(0, message.map_int32_int32().at(1));\n}\n\nTEST(GeneratedMapFieldTest, MissedValueTextFormat) {\n  unittest::TestMap message;\n\n  // No value field in text format\n  string text =\n      \"map_int32_foreign_message {\\n\"\n      \"  key: 1234567890\\n\"\n      \"}\";\n\n  EXPECT_TRUE(google::protobuf::TextFormat::ParseFromString(text, &message));\n  EXPECT_EQ(1, message.map_int32_foreign_message().size());\n  EXPECT_EQ(11, message.ByteSize());\n}\n\nTEST(GeneratedMapFieldTest, UnknownFieldWireFormat) {\n  unittest::TestMap message;\n\n  // Unknown field in wire format\n  string data = \"\\x0A\\x06\\x08\\x02\\x10\\x03\\x18\\x01\";\n\n  EXPECT_TRUE(message.ParseFromString(data));\n  EXPECT_EQ(1, message.map_int32_int32().size());\n  EXPECT_EQ(3, message.map_int32_int32().at(2));\n}\n\nTEST(GeneratedMapFieldTest, CorruptedWireFormat) {\n  unittest::TestMap message;\n\n  // corrupted data in wire format\n  string data = \"\\x0A\\x06\\x08\\x02\\x11\\x03\";\n\n  EXPECT_FALSE(message.ParseFromString(data));\n}\n\nTEST(GeneratedMapFieldTest, IsInitialized) {\n  unittest::TestRequiredMessageMap map_message;\n\n  // Add an uninitialized message.\n  (*map_message.mutable_map_field())[0];\n  EXPECT_FALSE(map_message.IsInitialized());\n\n  // Initialize uninitialized message\n  (*map_message.mutable_map_field())[0].set_a(0);\n  (*map_message.mutable_map_field())[0].set_b(0);\n  (*map_message.mutable_map_field())[0].set_c(0);\n  EXPECT_TRUE(map_message.IsInitialized());\n}\n\nTEST(GeneratedMapFieldTest, MessagesMustMerge) {\n  unittest::TestRequiredMessageMap map_message;\n  unittest::TestRequired with_dummy4;\n  with_dummy4.set_a(97);\n  with_dummy4.set_b(0);\n  with_dummy4.set_c(0);\n  with_dummy4.set_dummy4(98);\n\n  EXPECT_TRUE(with_dummy4.IsInitialized());\n  (*map_message.mutable_map_field())[0] = with_dummy4;\n  EXPECT_TRUE(map_message.IsInitialized());\n  string s = map_message.SerializeAsString();\n\n  // Modify s so that there are two values in the entry for key 0.\n  // The first will have no value for c.  The second will have no value for a.\n  // Those are required fields.  Also, make some other little changes, to\n  // ensure we are merging the two values (because they're messages).\n  ASSERT_EQ(s.size() - 2, s[1]);  // encoding of the length of what follows\n  string encoded_val(s.data() + 4, s.data() + s.size());\n  // In s, change the encoding of c to an encoding of dummy32.\n  s[s.size() - 3] -= 8;\n  // Make encoded_val slightly different from what's in s.\n  encoded_val[encoded_val.size() - 1] += 33;  // Encode c = 33.\n  for (int i = 0; i < encoded_val.size(); i++) {\n    if (encoded_val[i] == 97) {\n      // Encode b = 91 instead of a = 97.  But this won't matter, because\n      // we also encode b = 0 right after this.  The point is to leave out\n      // a required field, and make sure the parser doesn't complain, because\n      // every required field is set after the merge of the two values.\n      encoded_val[i - 1] += 16;\n      encoded_val[i] = 91;\n    } else if (encoded_val[i] == 98) {\n      // Encode dummy5 = 99 instead of dummy4 = 98.\n      encoded_val[i - 1] += 8;  // The tag for dummy5 is 8 more.\n      encoded_val[i]++;\n      break;\n    }\n  }\n\n  s += encoded_val;            // Add the second message.\n  s[1] += encoded_val.size();  // Adjust encoded size.\n\n  // Test key then value then value.\n  int key = 0;\n  ASSERT_TRUE(map_message.ParseFromString(s));\n  ASSERT_EQ(1, map_message.map_field().size());\n  ASSERT_EQ(1, map_message.map_field().count(key));\n  EXPECT_EQ(97, map_message.map_field().find(key)->second.a());\n  EXPECT_EQ(0, map_message.map_field().find(key)->second.b());\n  EXPECT_EQ(33, map_message.map_field().find(key)->second.c());\n  EXPECT_EQ(98, map_message.map_field().find(key)->second.dummy4());\n  EXPECT_EQ(99, map_message.map_field().find(key)->second.dummy5());\n\n  // Test key then value then value then key.\n  s.push_back(s[2]);       // Copy the key's tag.\n  key = 19;\n  s.push_back(key);        // Second key is 19 instead of 0.\n  s[1] += 2;               // Adjust encoded size.\n  ASSERT_TRUE(map_message.ParseFromString(s));\n  ASSERT_EQ(1, map_message.map_field().size());\n  ASSERT_EQ(1, map_message.map_field().count(key));\n  EXPECT_EQ(97, map_message.map_field().find(key)->second.a());\n  EXPECT_EQ(0, map_message.map_field().find(key)->second.b());\n  EXPECT_EQ(33, map_message.map_field().find(key)->second.c());\n  EXPECT_EQ(98, map_message.map_field().find(key)->second.dummy4());\n  EXPECT_EQ(99, map_message.map_field().find(key)->second.dummy5());\n}\n\n// Generated Message Reflection Test ================================\n\nTEST(GeneratedMapFieldReflectionTest, SpaceUsed) {\n  unittest::TestMap message;\n  MapReflectionTester reflection_tester(\n    unittest::TestMap::descriptor());\n  reflection_tester.SetMapFieldsViaReflection(&message);\n\n  EXPECT_LT(0, message.GetReflection()->SpaceUsed(message));\n}\n\nTEST(GeneratedMapFieldReflectionTest, Accessors) {\n  // Set every field to a unique value then go back and check all those\n  // values.\n  unittest::TestMap message;\n  MapReflectionTester reflection_tester(\n    unittest::TestMap::descriptor());\n  reflection_tester.SetMapFieldsViaReflection(&message);\n  MapTestUtil::ExpectMapFieldsSet(message);\n  reflection_tester.ExpectMapFieldsSetViaReflection(message);\n  reflection_tester.ExpectMapFieldsSetViaReflectionIterator(&message);\n\n  reflection_tester.ModifyMapFieldsViaReflection(&message);\n  MapTestUtil::ExpectMapFieldsModified(message);\n}\n\nTEST(GeneratedMapFieldReflectionTest, Swap) {\n  unittest::TestMap message1;\n  unittest::TestMap message2;\n\n  MapTestUtil::SetMapFields(&message1);\n\n  const Reflection* reflection = message1.GetReflection();\n  reflection->Swap(&message1, &message2);\n\n  MapTestUtil::ExpectClear(message1);\n  MapTestUtil::ExpectMapFieldsSet(message2);\n}\n\nTEST(GeneratedMapFieldReflectionTest, SwapWithBothSet) {\n  unittest::TestMap message1;\n  unittest::TestMap message2;\n\n  MapTestUtil::SetMapFields(&message1);\n  MapTestUtil::SetMapFields(&message2);\n  MapTestUtil::ModifyMapFields(&message2);\n\n  const Reflection* reflection = message1.GetReflection();\n  reflection->Swap(&message1, &message2);\n\n  MapTestUtil::ExpectMapFieldsModified(message1);\n  MapTestUtil::ExpectMapFieldsSet(message2);\n}\n\nTEST(GeneratedMapFieldReflectionTest, SwapFields) {\n  unittest::TestMap message1;\n  unittest::TestMap message2;\n\n  MapTestUtil::SetMapFields(&message2);\n\n  vector<const FieldDescriptor*> fields;\n  const Reflection* reflection = message1.GetReflection();\n  reflection->ListFields(message2, &fields);\n  reflection->SwapFields(&message1, &message2, fields);\n\n  MapTestUtil::ExpectMapFieldsSet(message1);\n  MapTestUtil::ExpectClear(message2);\n}\n\nTEST(GeneratedMapFieldReflectionTest, ClearField) {\n  unittest::TestMap message;\n  MapTestUtil::SetMapFields(&message);\n  MapTestUtil::ExpectMapFieldsSet(message);\n\n  MapReflectionTester reflection_tester(\n      unittest::TestMap::descriptor());\n  reflection_tester.ClearMapFieldsViaReflection(&message);\n  reflection_tester.ExpectClearViaReflection(message);\n  reflection_tester.ExpectClearViaReflectionIterator(&message);\n}\n\nTEST(GeneratedMapFieldReflectionTest, RemoveLast) {\n  unittest::TestMap message;\n  MapReflectionTester reflection_tester(\n      unittest::TestMap::descriptor());\n\n  MapTestUtil::SetMapFields(&message);\n  MapTestUtil::ExpectMapsSize(message, 2);\n  std::vector<const Message*> expected_entries =\n      MapTestUtil::GetMapEntries(message, 0);\n\n  reflection_tester.RemoveLastMapsViaReflection(&message);\n\n  MapTestUtil::ExpectMapsSize(message, 1);\n  std::vector<const Message*> remained_entries =\n      MapTestUtil::GetMapEntries(message, 0);\n  EXPECT_TRUE(expected_entries == remained_entries);\n}\n\nTEST(GeneratedMapFieldReflectionTest, ReleaseLast) {\n  unittest::TestMap message;\n  const Descriptor* descriptor = message.GetDescriptor();\n  MapReflectionTester reflection_tester(descriptor);\n\n  MapTestUtil::SetMapFields(&message);\n\n  MapTestUtil::ExpectMapsSize(message, 2);\n\n  reflection_tester.ReleaseLastMapsViaReflection(&message);\n\n  MapTestUtil::ExpectMapsSize(message, 1);\n\n  // Now test that we actually release the right message.\n  message.Clear();\n  MapTestUtil::SetMapFields(&message);\n\n  MapTestUtil::ExpectMapsSize(message, 2);\n  std::vector<const Message*> expect_last =\n      MapTestUtil::GetMapEntries(message, 1);\n  std::vector<const Message*> release_last =\n      MapTestUtil::GetMapEntriesFromRelease(&message);\n  MapTestUtil::ExpectMapsSize(message, 1);\n  EXPECT_TRUE(expect_last == release_last);\n  for (std::vector<const Message*>::iterator it = release_last.begin();\n       it != release_last.end(); ++it) {\n    delete *it;\n  }\n}\n\nTEST(GeneratedMapFieldReflectionTest, SwapElements) {\n  unittest::TestMap message;\n  MapReflectionTester reflection_tester(\n    unittest::TestMap::descriptor());\n\n  MapTestUtil::SetMapFields(&message);\n\n  // Get pointers of map entries at their original position\n  std::vector<const Message*> entries0 = MapTestUtil::GetMapEntries(message, 0);\n  std::vector<const Message*> entries1 = MapTestUtil::GetMapEntries(message, 1);\n\n  // Swap the first time.\n  reflection_tester.SwapMapsViaReflection(&message);\n\n  // Get pointer of map entry after swap once.\n  std::vector<const Message*> entries0_once =\n      MapTestUtil::GetMapEntries(message, 0);\n  std::vector<const Message*> entries1_once =\n      MapTestUtil::GetMapEntries(message, 1);\n\n  // Test map entries are swapped.\n  MapTestUtil::ExpectMapsSize(message, 2);\n  EXPECT_TRUE(entries0 == entries1_once);\n  EXPECT_TRUE(entries1 == entries0_once);\n\n  // Swap the second time.\n  reflection_tester.SwapMapsViaReflection(&message);\n\n  // Get pointer of map entry after swap once.\n  std::vector<const Message*> entries0_twice =\n      MapTestUtil::GetMapEntries(message, 0);\n  std::vector<const Message*> entries1_twice =\n      MapTestUtil::GetMapEntries(message, 1);\n\n  // Test map entries are swapped back.\n  MapTestUtil::ExpectMapsSize(message, 2);\n  EXPECT_TRUE(entries0 == entries0_twice);\n  EXPECT_TRUE(entries1 == entries1_twice);\n}\n\nTEST(GeneratedMapFieldReflectionTest, MutableUnknownFields) {\n  unittest::TestMap message;\n  MapReflectionTester reflection_tester(\n    unittest::TestMap::descriptor());\n  reflection_tester.MutableUnknownFieldsOfMapFieldsViaReflection(&message);\n}\n\nTEST(GeneratedMapFieldReflectionTest, EmbedProto2Message) {\n  unittest::TestMessageMap message;\n\n  const FieldDescriptor* map_field =\n      unittest::TestMessageMap::descriptor()->FindFieldByName(\n          \"map_int32_message\");\n  const FieldDescriptor* value =\n      map_field->message_type()->FindFieldByName(\"value\");\n\n  Message* entry_message =\n      message.GetReflection()->AddMessage(&message, map_field);\n  EXPECT_EQ(\n      &entry_message->GetReflection()->GetMessage(*entry_message, value),\n      reinterpret_cast<const Message*>(&TestAllTypes::default_instance()));\n\n  Message* proto2_message =\n      entry_message->GetReflection()->MutableMessage(entry_message, value);\n  EXPECT_EQ(unittest::TestAllTypes::descriptor(),\n            proto2_message->GetDescriptor());\n  ASSERT_EQ(1, message.map_int32_message().size());\n}\n\nTEST(GeneratedMapFieldReflectionTest, MergeFromClearMapEntry) {\n  unittest::TestMap message;\n  const FieldDescriptor* map_field =\n      unittest::TestMap::descriptor()->FindFieldByName(\"map_int32_int32\");\n  const FieldDescriptor* key =\n      map_field->message_type()->FindFieldByName(\"key\");\n  const FieldDescriptor* value =\n      map_field->message_type()->FindFieldByName(\"value\");\n\n  Message* entry_message1 =\n      message.GetReflection()->AddMessage(&message, map_field);\n  EXPECT_FALSE(entry_message1->GetReflection()->HasField(*entry_message1, key));\n  EXPECT_FALSE(\n      entry_message1->GetReflection()->HasField(*entry_message1, value));\n\n  Message* entry_message2 =\n      message.GetReflection()->AddMessage(&message, map_field);\n  EXPECT_FALSE(entry_message2->GetReflection()->HasField(*entry_message2, key));\n  EXPECT_FALSE(\n      entry_message2->GetReflection()->HasField(*entry_message2, value));\n\n  entry_message1->MergeFrom(*entry_message2);\n  EXPECT_FALSE(entry_message1->GetReflection()->HasField(*entry_message1, key));\n  EXPECT_FALSE(\n      entry_message1->GetReflection()->HasField(*entry_message1, value));\n}\n\nTEST(GeneratedMapFieldReflectionTest, MapEntryClear) {\n  unittest::TestMap message;\n  MapReflectionTester reflection_tester(\n    unittest::TestMap::descriptor());\n  reflection_tester.MutableUnknownFieldsOfMapFieldsViaReflection(&message);\n}\n\nTEST(GeneratedMapFieldReflectionTest, Proto2MapEntryClear) {\n  unittest::TestEnumMap message;\n  const Descriptor* descriptor = message.GetDescriptor();\n  const FieldDescriptor* field_descriptor =\n      descriptor->FindFieldByName(\"known_map_field\");\n  const FieldDescriptor* value_descriptor =\n      field_descriptor->message_type()->FindFieldByName(\"value\");\n  Message* sub_message =\n      message.GetReflection()->AddMessage(&message, field_descriptor);\n  EXPECT_EQ(0, sub_message->GetReflection()->GetEnumValue(*sub_message,\n                                                          value_descriptor));\n}\n\n// Map Reflection API Test =========================================\n\nTEST(GeneratedMapFieldReflectionTest, SetViaMapReflection) {\n  unittest::TestMap message;\n  MapReflectionTester reflection_tester(\n      unittest::TestMap::descriptor());\n  reflection_tester.SetMapFieldsViaMapReflection(&message);\n  reflection_tester.ExpectMapFieldsSetViaReflection(message);\n  reflection_tester.ExpectMapFieldsSetViaReflectionIterator(&message);\n}\n\n// Dynamic Message Test =============================================\n\nclass MapFieldInDynamicMessageTest : public testing::Test {\n protected:\n  const DescriptorPool* pool_;\n  DynamicMessageFactory factory_;\n  const Descriptor* map_descriptor_;\n  const Descriptor* recursive_map_descriptor_;\n  const Message* map_prototype_;\n\n  MapFieldInDynamicMessageTest()\n      : pool_(DescriptorPool::generated_pool()), factory_(pool_) {}\n\n  virtual void SetUp() {\n    map_descriptor_ =\n      pool_->FindMessageTypeByName(\"protobuf_unittest.TestMap\");\n    recursive_map_descriptor_ =\n        pool_->FindMessageTypeByName(\"protobuf_unittest.TestRecursiveMapMessage\");\n    ASSERT_TRUE(map_descriptor_ != NULL);\n    ASSERT_TRUE(recursive_map_descriptor_ != NULL);\n    map_prototype_ = factory_.GetPrototype(map_descriptor_);\n  }\n};\n\nTEST_F(MapFieldInDynamicMessageTest, MapIndependentOffsets) {\n  // Check that all fields have independent offsets by setting each\n  // one to a unique value then checking that they all still have those\n  // unique values (i.e. they don't stomp each other).\n  google::protobuf::scoped_ptr<Message> message(map_prototype_->New());\n  MapReflectionTester reflection_tester(map_descriptor_);\n\n  reflection_tester.SetMapFieldsViaReflection(message.get());\n  reflection_tester.ExpectMapFieldsSetViaReflection(*message);\n}\n\nTEST_F(MapFieldInDynamicMessageTest, DynamicMapReflection) {\n  // Check that map fields work properly.\n  google::protobuf::scoped_ptr<Message> message(map_prototype_->New());\n\n  // Check set functions.\n  MapReflectionTester reflection_tester(map_descriptor_);\n  reflection_tester.SetMapFieldsViaMapReflection(message.get());\n  reflection_tester.ExpectMapFieldsSetViaReflection(*message);\n}\n\nTEST_F(MapFieldInDynamicMessageTest, MapSpaceUsed) {\n  // Test that SpaceUsed() works properly\n\n  // Since we share the implementation with generated messages, we don't need\n  // to test very much here.  Just make sure it appears to be working.\n\n  google::protobuf::scoped_ptr<Message> message(map_prototype_->New());\n  MapReflectionTester reflection_tester(map_descriptor_);\n\n  int initial_space_used = message->SpaceUsed();\n\n  reflection_tester.SetMapFieldsViaReflection(message.get());\n  EXPECT_LT(initial_space_used, message->SpaceUsed());\n}\n\nTEST_F(MapFieldInDynamicMessageTest, RecursiveMap) {\n  TestRecursiveMapMessage from;\n  (*from.mutable_a())[\"\"];\n  string data = from.SerializeAsString();\n  google::protobuf::scoped_ptr<Message> to(\n      factory_.GetPrototype(recursive_map_descriptor_)->New());\n  ASSERT_TRUE(to->ParseFromString(data));\n}\n\n// ReflectionOps Test ===============================================\n\nTEST(ReflectionOpsForMapFieldTest, MapSanityCheck) {\n  unittest::TestMap message;\n\n  MapTestUtil::SetMapFields(&message);\n  MapTestUtil::ExpectMapFieldsSet(message);\n}\n\nTEST(ReflectionOpsForMapFieldTest, MapCopy) {\n  unittest::TestMap message, message2;\n\n  MapTestUtil::SetMapFields(&message);\n\n  ReflectionOps::Copy(message, &message2);\n\n  MapTestUtil::ExpectMapFieldsSet(message2);\n\n  // Copying from self should be a no-op.\n  ReflectionOps::Copy(message2, &message2);\n  MapTestUtil::ExpectMapFieldsSet(message2);\n}\n\nTEST(ReflectionOpsForMapFieldTest, MergeMap) {\n  // Note:  Copy is implemented in terms of Merge() so technically the Copy\n  //   test already tested most of this.\n\n  unittest::TestMap message, message2;\n\n  MapTestUtil::SetMapFields(&message);\n\n  ReflectionOps::Merge(message2, &message);\n\n  MapTestUtil::ExpectMapFieldsSet(message);\n}\n\nTEST(ReflectionOpsForMapFieldTest, ClearMap) {\n  unittest::TestMap message;\n\n  MapTestUtil::SetMapFields(&message);\n\n  ReflectionOps::Clear(&message);\n\n  MapTestUtil::ExpectClear(message);\n}\n\nTEST(ReflectionOpsForMapFieldTest, MapDiscardUnknownFields) {\n  unittest::TestMap message;\n  MapTestUtil::SetMapFields(&message);\n\n  // Set some unknown fields in message.\n  message.GetReflection()->MutableUnknownFields(&message)->\n      AddVarint(123456, 654321);\n\n  // Discard them.\n  ReflectionOps::DiscardUnknownFields(&message);\n  MapTestUtil::ExpectMapFieldsSet(message);\n\n  EXPECT_EQ(0, message.GetReflection()->\n      GetUnknownFields(message).field_count());\n}\n\n// Wire Format Test =================================================\n\nTEST(WireFormatForMapFieldTest, ParseMap) {\n  unittest::TestMap source, dest;\n  string data;\n\n  // Serialize using the generated code.\n  MapTestUtil::SetMapFields(&source);\n  source.SerializeToString(&data);\n\n  // Parse using WireFormat.\n  io::ArrayInputStream raw_input(data.data(), data.size());\n  io::CodedInputStream input(&raw_input);\n  WireFormat::ParseAndMergePartial(&input, &dest);\n\n  // Check.\n  MapTestUtil::ExpectMapFieldsSet(dest);\n}\n\nTEST(WireFormatForMapFieldTest, MapByteSize) {\n  unittest::TestMap message;\n  MapTestUtil::SetMapFields(&message);\n\n  EXPECT_EQ(message.ByteSize(), WireFormat::ByteSize(message));\n  message.Clear();\n  EXPECT_EQ(0, message.ByteSize());\n  EXPECT_EQ(0, WireFormat::ByteSize(message));\n}\n\nTEST(WireFormatForMapFieldTest, SerializeMap) {\n  unittest::TestMap message;\n  string generated_data;\n  string dynamic_data;\n\n  MapTestUtil::SetMapFields(&message);\n\n  // Serialize using the generated code.\n  {\n    message.ByteSize();\n    io::StringOutputStream raw_output(&generated_data);\n    io::CodedOutputStream output(&raw_output);\n    message.SerializeWithCachedSizes(&output);\n    ASSERT_FALSE(output.HadError());\n  }\n\n  // Serialize using WireFormat.\n  {\n    io::StringOutputStream raw_output(&dynamic_data);\n    io::CodedOutputStream output(&raw_output);\n    int size = WireFormat::ByteSize(message);\n    WireFormat::SerializeWithCachedSizes(message, size, &output);\n    ASSERT_FALSE(output.HadError());\n  }\n\n  // Should be the same.\n  // Don't use EXPECT_EQ here because we're comparing raw binary data and\n  // we really don't want it dumped to stdout on failure.\n  EXPECT_TRUE(dynamic_data == generated_data);\n}\n\nTEST(WireFormatForMapFieldTest, MapParseHelpers) {\n  string data;\n\n  {\n    // Set up.\n    protobuf_unittest::TestMap message;\n    MapTestUtil::SetMapFields(&message);\n    message.SerializeToString(&data);\n  }\n\n  {\n    // Test ParseFromString.\n    protobuf_unittest::TestMap message;\n    EXPECT_TRUE(message.ParseFromString(data));\n    MapTestUtil::ExpectMapFieldsSet(message);\n  }\n\n  {\n    // Test ParseFromIstream.\n    protobuf_unittest::TestMap message;\n    stringstream stream(data);\n    EXPECT_TRUE(message.ParseFromIstream(&stream));\n    EXPECT_TRUE(stream.eof());\n    MapTestUtil::ExpectMapFieldsSet(message);\n  }\n\n  {\n    // Test ParseFromBoundedZeroCopyStream.\n    string data_with_junk(data);\n    data_with_junk.append(\"some junk on the end\");\n    io::ArrayInputStream stream(data_with_junk.data(), data_with_junk.size());\n    protobuf_unittest::TestMap message;\n    EXPECT_TRUE(message.ParseFromBoundedZeroCopyStream(&stream, data.size()));\n    MapTestUtil::ExpectMapFieldsSet(message);\n  }\n\n  {\n    // Test that ParseFromBoundedZeroCopyStream fails (but doesn't crash) if\n    // EOF is reached before the expected number of bytes.\n    io::ArrayInputStream stream(data.data(), data.size());\n    protobuf_unittest::TestAllTypes message;\n    EXPECT_FALSE(\n      message.ParseFromBoundedZeroCopyStream(&stream, data.size() + 1));\n  }\n}\n\n// Deterministic Serialization Test ==========================================\n\ntemplate <typename T>\nstatic string DeterministicSerialization(const T& t) {\n  const int size = t.ByteSize();\n  string result(size, '\\0');\n  io::ArrayOutputStream array_stream(string_as_array(&result), size);\n  io::CodedOutputStream output_stream(&array_stream);\n  output_stream.SetSerializationDeterministic(true);\n  t.SerializeWithCachedSizes(&output_stream);\n  EXPECT_FALSE(output_stream.HadError());\n  EXPECT_EQ(size, output_stream.ByteCount());\n  return result;\n}\n\n// Helper to test the serialization of the first arg against a golden file.\nstatic void TestDeterministicSerialization(const protobuf_unittest::TestMaps& t,\n                                           const string& filename) {\n  string expected;\n  GOOGLE_CHECK_OK(File::GetContents(\n      TestSourceDir() + \"/google/protobuf/testdata/\" + filename,\n      &expected, true));\n  const string actual = DeterministicSerialization(t);\n  EXPECT_EQ(expected, actual);\n  protobuf_unittest::TestMaps u;\n  EXPECT_TRUE(u.ParseFromString(actual));\n  EXPECT_TRUE(google::protobuf::util::MessageDifferencer::Equals(u, t));\n}\n\n// Helper for MapSerializationTest.  Return a 7-bit ASCII string.\nstatic string ConstructKey(uint64 n) {\n  string s(n % static_cast<uint64>(9), '\\0');\n  if (s.empty()) {\n    return StrCat(n);\n  } else {\n    while (n != 0) {\n      s[n % s.size()] = (n >> 10) & 0x7f;\n      n /= 888;\n    }\n    return s;\n  }\n}\n\nTEST(MapSerializationTest, Deterministic) {\n  const int kIters = 25;\n  protobuf_unittest::TestMaps t;\n  protobuf_unittest::TestIntIntMap inner;\n  (*inner.mutable_m())[0] = (*inner.mutable_m())[10] =\n      (*inner.mutable_m())[-200] = 0;\n  uint64 frog = 9;\n  const uint64 multiplier = 0xa29cd16f;\n  for (int i = 0; i < kIters; i++) {\n    const int32 i32 = static_cast<int32>(frog & 0xffffffff);\n    const uint32 u32 = static_cast<uint32>(i32) * 91919;\n    const int64 i64 = static_cast<int64>(frog);\n    const uint64 u64 = frog * static_cast<uint64>(187321);\n    const bool b = i32 > 0;\n    const string s = ConstructKey(frog);\n    (*inner.mutable_m())[i] = i32;\n    (*t.mutable_m_int32())[i32] = (*t.mutable_m_sint32())[i32] =\n        (*t.mutable_m_sfixed32())[i32] = inner;\n    (*t.mutable_m_uint32())[u32] = (*t.mutable_m_fixed32())[u32] = inner;\n    (*t.mutable_m_int64())[i64] = (*t.mutable_m_sint64())[i64] =\n        (*t.mutable_m_sfixed64())[i64] = inner;\n    (*t.mutable_m_uint64())[u64] = (*t.mutable_m_fixed64())[u64] = inner;\n    (*t.mutable_m_bool())[b] = inner;\n    (*t.mutable_m_string())[s] = inner;\n    (*t.mutable_m_string())[s + string(1 << (u32 % static_cast<uint32>(9)),\n                                       b)] = inner;\n    inner.mutable_m()->erase(i);\n    frog = frog * multiplier + i;\n    frog ^= (frog >> 41);\n  }\n  TestDeterministicSerialization(t, \"golden_message_maps\");\n}\n\n// Text Format Test =================================================\n\nTEST(TextFormatMapTest, SerializeAndParse) {\n  unittest::TestMap source;\n  unittest::TestMap dest;\n  MapTestUtil::SetMapFields(&source);\n  string output;\n\n  // Test compact ASCII\n  TextFormat::Printer printer;\n  printer.PrintToString(source, &output);\n  TextFormat::Parser parser;\n  EXPECT_TRUE(parser.ParseFromString(output, &dest));\n  MapTestUtil::ExpectMapFieldsSet(dest);\n}\n\nTEST(TextFormatMapTest, Sorted) {\n  unittest::TestMap message;\n  MapReflectionTester tester(message.GetDescriptor());\n  tester.SetMapFieldsViaReflection(&message);\n\n  string expected_text;\n  GOOGLE_CHECK_OK(File::GetContents(\n      TestSourceDir() +\n          \"/google/protobuf/\"\n          \"testdata/map_test_data.txt\",\n      &expected_text, true));\n\n  EXPECT_EQ(message.DebugString(), expected_text);\n\n  // Test again on the reverse order.\n  unittest::TestMap message2;\n  tester.SetMapFieldsViaReflection(&message2);\n  tester.SwapMapsViaReflection(&message2);\n  EXPECT_EQ(message2.DebugString(), expected_text);\n}\n\n\n// arena support =================================================\nTEST(ArenaTest, ParsingAndSerializingNoHeapAllocation) {\n  // Allocate a large initial block to avoid mallocs during hooked test.\n  std::vector<char> arena_block(128 * 1024);\n  ArenaOptions options;\n  options.initial_block = &arena_block[0];\n  options.initial_block_size = arena_block.size();\n  Arena arena(options);\n  string data;\n  data.reserve(128 * 1024);\n\n  {\n    // TODO(teboring): Enable no heap check when ArenaStringPtr is used in map.\n    // NoHeapChecker no_heap;\n\n    unittest::TestArenaMap* from =\n        Arena::CreateMessage<unittest::TestArenaMap>(&arena);\n    MapTestUtil::SetArenaMapFields(from);\n    from->SerializeToString(&data);\n\n    unittest::TestArenaMap* to =\n        Arena::CreateMessage<unittest::TestArenaMap>(&arena);\n    to->ParseFromString(data);\n    MapTestUtil::ExpectArenaMapFieldsSet(*to);\n  }\n}\n\n// Use text format parsing and serializing to test reflection api.\nTEST(ArenaTest, RelfectionInTextFormat) {\n  Arena arena;\n  string data;\n\n  TextFormat::Printer printer;\n  TextFormat::Parser parser;\n\n  unittest::TestArenaMap* from =\n      Arena::CreateMessage<unittest::TestArenaMap>(&arena);\n  unittest::TestArenaMap* to =\n      Arena::CreateMessage<unittest::TestArenaMap>(&arena);\n\n  MapTestUtil::SetArenaMapFields(from);\n  printer.PrintToString(*from, &data);\n\n  EXPECT_TRUE(parser.ParseFromString(data, to));\n  MapTestUtil::ExpectArenaMapFieldsSet(*to);\n}\n\n// Make sure the memory allocated for string in map is deallocated.\nTEST(ArenaTest, StringMapNoLeak) {\n  Arena arena;\n  unittest::TestArenaMap* message =\n      Arena::CreateMessage<unittest::TestArenaMap>(&arena);\n  string data;\n  // String with length less than 16 will not be allocated from heap.\n  int original_capacity = data.capacity();\n  while (data.capacity() <= original_capacity) {\n    data.append(\"a\");\n  }\n  (*message->mutable_map_string_string())[data] = data;\n  // We rely on heap checkers to detect memory leak for us.\n  ASSERT_FALSE(message == NULL);\n}\n\nTEST(ArenaTest, IsInitialized) {\n  // Allocate a large initial polluted block.\n  std::vector<char> arena_block(128 * 1024);\n  std::fill(arena_block.begin(), arena_block.end(), '\\xff');\n\n  ArenaOptions options;\n  options.initial_block = &arena_block[0];\n  options.initial_block_size = arena_block.size();\n  Arena arena(options);\n\n  unittest::TestArenaMap* message =\n      Arena::CreateMessage<unittest::TestArenaMap>(&arena);\n  EXPECT_EQ(0, (*message->mutable_map_int32_int32())[0]);\n}\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/map_test_util.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/map_test_util.h>\n#include <google/protobuf/map_test_util_impl.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/message.h>\n\nnamespace google {\nnamespace protobuf {\n\nvoid MapTestUtil::SetMapFields(unittest::TestMap* message) {\n  MapTestUtilImpl::SetMapFields<unittest::MapEnum, unittest::MAP_ENUM_BAR,\n                                unittest::MAP_ENUM_BAZ>(message);\n}\n\nvoid MapTestUtil::SetArenaMapFields(unittest::TestArenaMap* message) {\n  MapTestUtilImpl::SetArenaMapFields<unittest::MapEnum, unittest::MAP_ENUM_BAR,\n                                     unittest::MAP_ENUM_BAZ>(message);\n}\n\nvoid MapTestUtil::SetMapFieldsInitialized(unittest::TestMap* message) {\n  MapTestUtilImpl::SetMapFieldsInitialized(message);\n}\n\nvoid MapTestUtil::ModifyMapFields(unittest::TestMap* message) {\n  MapTestUtilImpl::ModifyMapFields<unittest::MapEnum, unittest::MAP_ENUM_FOO>(\n      message);\n}\n\nvoid MapTestUtil::ExpectClear(const unittest::TestMap& message) {\n  MapTestUtilImpl::ExpectClear(message);\n}\n\nvoid MapTestUtil::ExpectMapFieldsSet(const unittest::TestMap& message) {\n  MapTestUtilImpl::ExpectMapFieldsSet<unittest::MapEnum, unittest::MAP_ENUM_BAR,\n                                      unittest::MAP_ENUM_BAZ>(message);\n}\n\nvoid MapTestUtil::ExpectArenaMapFieldsSet(\n    const unittest::TestArenaMap& message) {\n  MapTestUtilImpl::ExpectArenaMapFieldsSet<\n      unittest::MapEnum, unittest::MAP_ENUM_BAR, unittest::MAP_ENUM_BAZ>(\n      message);\n}\n\nvoid MapTestUtil::ExpectMapFieldsSetInitialized(\n    const unittest::TestMap& message) {\n  MapTestUtilImpl::ExpectMapFieldsSetInitialized<unittest::MapEnum,\n                                                 unittest::MAP_ENUM_FOO>(\n      message);\n}\n\nvoid MapTestUtil::ExpectMapFieldsModified(\n    const unittest::TestMap& message) {\n  MapTestUtilImpl::ExpectMapFieldsModified<\n      unittest::MapEnum, unittest::MAP_ENUM_BAR, unittest::MAP_ENUM_FOO>(\n      message);\n}\n\nvoid MapTestUtil::ExpectMapsSize(\n    const unittest::TestMap& message, int size) {\n  const Descriptor* descriptor = message.GetDescriptor();\n\n  EXPECT_EQ(size, message.GetReflection()->FieldSize(\n    message, descriptor->FindFieldByName(\"map_int32_int32\")));\n  EXPECT_EQ(size, message.GetReflection()->FieldSize(\n    message, descriptor->FindFieldByName(\"map_int64_int64\")));\n  EXPECT_EQ(size, message.GetReflection()->FieldSize(\n    message, descriptor->FindFieldByName(\"map_uint32_uint32\")));\n  EXPECT_EQ(size, message.GetReflection()->FieldSize(\n    message, descriptor->FindFieldByName(\"map_uint64_uint64\")));\n  EXPECT_EQ(size, message.GetReflection()->FieldSize(\n    message, descriptor->FindFieldByName(\"map_sint32_sint32\")));\n  EXPECT_EQ(size, message.GetReflection()->FieldSize(\n    message, descriptor->FindFieldByName(\"map_sint64_sint64\")));\n  EXPECT_EQ(size, message.GetReflection()->FieldSize(\n    message, descriptor->FindFieldByName(\"map_fixed32_fixed32\")));\n  EXPECT_EQ(size, message.GetReflection()->FieldSize(\n    message, descriptor->FindFieldByName(\"map_fixed64_fixed64\")));\n  EXPECT_EQ(size, message.GetReflection()->FieldSize(\n    message, descriptor->FindFieldByName(\"map_sfixed32_sfixed32\")));\n  EXPECT_EQ(size, message.GetReflection()->FieldSize(\n    message, descriptor->FindFieldByName(\"map_sfixed64_sfixed64\")));\n  EXPECT_EQ(size, message.GetReflection()->FieldSize(\n    message, descriptor->FindFieldByName(\"map_int32_float\")));\n  EXPECT_EQ(size, message.GetReflection()->FieldSize(\n    message, descriptor->FindFieldByName(\"map_int32_double\")));\n  EXPECT_EQ(size, message.GetReflection()->FieldSize(\n    message, descriptor->FindFieldByName(\"map_bool_bool\")));\n  EXPECT_EQ(size, message.GetReflection()->FieldSize(\n    message, descriptor->FindFieldByName(\"map_string_string\")));\n  EXPECT_EQ(size, message.GetReflection()->FieldSize(\n    message, descriptor->FindFieldByName(\"map_int32_bytes\")));\n  EXPECT_EQ(size, message.GetReflection()->FieldSize(\n    message, descriptor->FindFieldByName(\"map_int32_foreign_message\")));\n}\n\nstd::vector<const Message*> MapTestUtil::GetMapEntries(\n    const unittest::TestMap& message, int index) {\n  const Descriptor* descriptor = message.GetDescriptor();\n  std::vector<const Message*> result;\n\n  result.push_back(&message.GetReflection()->GetRepeatedMessage(\n    message, descriptor->FindFieldByName(\"map_int32_int32\"), index));\n  result.push_back(&message.GetReflection()->GetRepeatedMessage(\n    message, descriptor->FindFieldByName(\"map_int64_int64\"), index));\n  result.push_back(&message.GetReflection()->GetRepeatedMessage(\n    message, descriptor->FindFieldByName(\"map_uint32_uint32\"), index));\n  result.push_back(&message.GetReflection()->GetRepeatedMessage(\n    message, descriptor->FindFieldByName(\"map_uint64_uint64\"), index));\n  result.push_back(&message.GetReflection()->GetRepeatedMessage(\n    message, descriptor->FindFieldByName(\"map_sint32_sint32\"), index));\n  result.push_back(&message.GetReflection()->GetRepeatedMessage(\n    message, descriptor->FindFieldByName(\"map_sint64_sint64\"), index));\n  result.push_back(&message.GetReflection()->GetRepeatedMessage(\n    message, descriptor->FindFieldByName(\"map_fixed32_fixed32\"), index));\n  result.push_back(&message.GetReflection()->GetRepeatedMessage(\n    message, descriptor->FindFieldByName(\"map_fixed64_fixed64\"), index));\n  result.push_back(&message.GetReflection()->GetRepeatedMessage(\n    message, descriptor->FindFieldByName(\"map_sfixed32_sfixed32\"), index));\n  result.push_back(&message.GetReflection()->GetRepeatedMessage(\n    message, descriptor->FindFieldByName(\"map_sfixed64_sfixed64\"), index));\n  result.push_back(&message.GetReflection()->GetRepeatedMessage(\n    message, descriptor->FindFieldByName(\"map_int32_float\"), index));\n  result.push_back(&message.GetReflection()->GetRepeatedMessage(\n    message, descriptor->FindFieldByName(\"map_int32_double\"), index));\n  result.push_back(&message.GetReflection()->GetRepeatedMessage(\n    message, descriptor->FindFieldByName(\"map_bool_bool\"), index));\n  result.push_back(&message.GetReflection()->GetRepeatedMessage(\n    message, descriptor->FindFieldByName(\"map_string_string\"), index));\n  result.push_back(&message.GetReflection()->GetRepeatedMessage(\n    message, descriptor->FindFieldByName(\"map_int32_bytes\"), index));\n  result.push_back(&message.GetReflection()->GetRepeatedMessage(\n    message, descriptor->FindFieldByName(\"map_int32_enum\"), index));\n  result.push_back(&message.GetReflection()->GetRepeatedMessage(\n    message, descriptor->FindFieldByName(\"map_int32_foreign_message\"), index));\n\n  return result;\n}\n\nstd::vector<const Message*> MapTestUtil::GetMapEntriesFromRelease(\n    unittest::TestMap* message) {\n  const Descriptor* descriptor = message->GetDescriptor();\n  std::vector<const Message*> result;\n\n  result.push_back(message->GetReflection()->ReleaseLast(\n    message, descriptor->FindFieldByName(\"map_int32_int32\")));\n  result.push_back(message->GetReflection()->ReleaseLast(\n    message, descriptor->FindFieldByName(\"map_int64_int64\")));\n  result.push_back(message->GetReflection()->ReleaseLast(\n    message, descriptor->FindFieldByName(\"map_uint32_uint32\")));\n  result.push_back(message->GetReflection()->ReleaseLast(\n    message, descriptor->FindFieldByName(\"map_uint64_uint64\")));\n  result.push_back(message->GetReflection()->ReleaseLast(\n    message, descriptor->FindFieldByName(\"map_sint32_sint32\")));\n  result.push_back(message->GetReflection()->ReleaseLast(\n    message, descriptor->FindFieldByName(\"map_sint64_sint64\")));\n  result.push_back(message->GetReflection()->ReleaseLast(\n    message, descriptor->FindFieldByName(\"map_fixed32_fixed32\")));\n  result.push_back(message->GetReflection()->ReleaseLast(\n    message, descriptor->FindFieldByName(\"map_fixed64_fixed64\")));\n  result.push_back(message->GetReflection()->ReleaseLast(\n    message, descriptor->FindFieldByName(\"map_sfixed32_sfixed32\")));\n  result.push_back(message->GetReflection()->ReleaseLast(\n    message, descriptor->FindFieldByName(\"map_sfixed64_sfixed64\")));\n  result.push_back(message->GetReflection()->ReleaseLast(\n    message, descriptor->FindFieldByName(\"map_int32_float\")));\n  result.push_back(message->GetReflection()->ReleaseLast(\n    message, descriptor->FindFieldByName(\"map_int32_double\")));\n  result.push_back(message->GetReflection()->ReleaseLast(\n    message, descriptor->FindFieldByName(\"map_bool_bool\")));\n  result.push_back(message->GetReflection()->ReleaseLast(\n    message, descriptor->FindFieldByName(\"map_string_string\")));\n  result.push_back(message->GetReflection()->ReleaseLast(\n    message, descriptor->FindFieldByName(\"map_int32_bytes\")));\n  result.push_back(message->GetReflection()->ReleaseLast(\n    message, descriptor->FindFieldByName(\"map_int32_enum\")));\n  result.push_back(message->GetReflection()->ReleaseLast(\n    message, descriptor->FindFieldByName(\"map_int32_foreign_message\")));\n\n  return result;\n}\n\nMapReflectionTester::MapReflectionTester(\n    const Descriptor* base_descriptor)\n  : base_descriptor_(base_descriptor) {\n  const DescriptorPool* pool = base_descriptor->file()->pool();\n\n  map_enum_foo_ = pool->FindEnumValueByName(\"protobuf_unittest.MAP_ENUM_FOO\");\n  map_enum_bar_ = pool->FindEnumValueByName(\"protobuf_unittest.MAP_ENUM_BAR\");\n  map_enum_baz_ = pool->FindEnumValueByName(\"protobuf_unittest.MAP_ENUM_BAZ\");\n\n  foreign_c_ = pool->FindFieldByName(\n      \"protobuf_unittest.ForeignMessage.c\");\n  map_int32_int32_key_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapInt32Int32Entry.key\");\n  map_int32_int32_val_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapInt32Int32Entry.value\");\n  map_int64_int64_key_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapInt64Int64Entry.key\");\n  map_int64_int64_val_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapInt64Int64Entry.value\");\n  map_uint32_uint32_key_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapUint32Uint32Entry.key\");\n  map_uint32_uint32_val_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapUint32Uint32Entry.value\");\n  map_uint64_uint64_key_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapUint64Uint64Entry.key\");\n  map_uint64_uint64_val_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapUint64Uint64Entry.value\");\n  map_sint32_sint32_key_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapSint32Sint32Entry.key\");\n  map_sint32_sint32_val_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapSint32Sint32Entry.value\");\n  map_sint64_sint64_key_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapSint64Sint64Entry.key\");\n  map_sint64_sint64_val_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapSint64Sint64Entry.value\");\n  map_fixed32_fixed32_key_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapFixed32Fixed32Entry.key\");\n  map_fixed32_fixed32_val_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapFixed32Fixed32Entry.value\");\n  map_fixed64_fixed64_key_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapFixed64Fixed64Entry.key\");\n  map_fixed64_fixed64_val_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapFixed64Fixed64Entry.value\");\n  map_sfixed32_sfixed32_key_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapSfixed32Sfixed32Entry.key\");\n  map_sfixed32_sfixed32_val_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapSfixed32Sfixed32Entry.value\");\n  map_sfixed64_sfixed64_key_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapSfixed64Sfixed64Entry.key\");\n  map_sfixed64_sfixed64_val_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapSfixed64Sfixed64Entry.value\");\n  map_int32_float_key_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapInt32FloatEntry.key\");\n  map_int32_float_val_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapInt32FloatEntry.value\");\n  map_int32_double_key_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapInt32DoubleEntry.key\");\n  map_int32_double_val_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapInt32DoubleEntry.value\");\n  map_bool_bool_key_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapBoolBoolEntry.key\");\n  map_bool_bool_val_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapBoolBoolEntry.value\");\n  map_string_string_key_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapStringStringEntry.key\");\n  map_string_string_val_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapStringStringEntry.value\");\n  map_int32_bytes_key_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapInt32BytesEntry.key\");\n  map_int32_bytes_val_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapInt32BytesEntry.value\");\n  map_int32_enum_key_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapInt32EnumEntry.key\");\n  map_int32_enum_val_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapInt32EnumEntry.value\");\n  map_int32_foreign_message_key_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapInt32ForeignMessageEntry.key\");\n  map_int32_foreign_message_val_ = pool->FindFieldByName(\n      \"protobuf_unittest.TestMap.MapInt32ForeignMessageEntry.value\");\n\n  EXPECT_FALSE(map_enum_foo_ == NULL);\n  EXPECT_FALSE(map_enum_bar_ == NULL);\n  EXPECT_FALSE(map_enum_baz_ == NULL);\n  EXPECT_FALSE(map_int32_int32_key_ == NULL);\n  EXPECT_FALSE(map_int32_int32_val_ == NULL);\n  EXPECT_FALSE(map_int64_int64_key_ == NULL);\n  EXPECT_FALSE(map_int64_int64_val_ == NULL);\n  EXPECT_FALSE(map_uint32_uint32_key_ == NULL);\n  EXPECT_FALSE(map_uint32_uint32_val_ == NULL);\n  EXPECT_FALSE(map_uint64_uint64_key_ == NULL);\n  EXPECT_FALSE(map_uint64_uint64_val_ == NULL);\n  EXPECT_FALSE(map_sint32_sint32_key_ == NULL);\n  EXPECT_FALSE(map_sint32_sint32_val_ == NULL);\n  EXPECT_FALSE(map_sint64_sint64_key_ == NULL);\n  EXPECT_FALSE(map_sint64_sint64_val_ == NULL);\n  EXPECT_FALSE(map_fixed32_fixed32_key_ == NULL);\n  EXPECT_FALSE(map_fixed32_fixed32_val_ == NULL);\n  EXPECT_FALSE(map_fixed64_fixed64_key_ == NULL);\n  EXPECT_FALSE(map_fixed64_fixed64_val_ == NULL);\n  EXPECT_FALSE(map_sfixed32_sfixed32_key_ == NULL);\n  EXPECT_FALSE(map_sfixed32_sfixed32_val_ == NULL);\n  EXPECT_FALSE(map_sfixed64_sfixed64_key_ == NULL);\n  EXPECT_FALSE(map_sfixed64_sfixed64_val_ == NULL);\n  EXPECT_FALSE(map_int32_float_key_ == NULL);\n  EXPECT_FALSE(map_int32_float_val_ == NULL);\n  EXPECT_FALSE(map_int32_double_key_ == NULL);\n  EXPECT_FALSE(map_int32_double_val_ == NULL);\n  EXPECT_FALSE(map_bool_bool_key_ == NULL);\n  EXPECT_FALSE(map_bool_bool_val_ == NULL);\n  EXPECT_FALSE(map_string_string_key_ == NULL);\n  EXPECT_FALSE(map_string_string_val_ == NULL);\n  EXPECT_FALSE(map_int32_bytes_key_ == NULL);\n  EXPECT_FALSE(map_int32_bytes_val_ == NULL);\n  EXPECT_FALSE(map_int32_enum_key_ == NULL);\n  EXPECT_FALSE(map_int32_enum_val_ == NULL);\n  EXPECT_FALSE(map_int32_foreign_message_key_ == NULL);\n  EXPECT_FALSE(map_int32_foreign_message_val_ == NULL);\n}\n\n// Shorthand to get a FieldDescriptor for a field of unittest::TestMap.\nconst FieldDescriptor* MapReflectionTester::F(const string& name) {\n  const FieldDescriptor* result = NULL;\n  result = base_descriptor_->FindFieldByName(name);\n  GOOGLE_CHECK(result != NULL);\n  return result;\n}\n\nvoid MapReflectionTester::SetMapFieldsViaReflection(\n    Message* message) {\n  const Reflection* reflection = message->GetReflection();\n  Message* sub_message = NULL;\n  Message* sub_foreign_message = NULL;\n\n  // Add first element.\n  sub_message = reflection->AddMessage(message, F(\"map_int32_int32\"));\n  sub_message->GetReflection()\n      ->SetInt32(sub_message, map_int32_int32_key_, 0);\n  sub_message->GetReflection()\n      ->SetInt32(sub_message, map_int32_int32_val_, 0);\n\n  sub_message = reflection->AddMessage(message, F(\"map_int64_int64\"));\n  sub_message->GetReflection()\n      ->SetInt64(sub_message, map_int64_int64_key_, 0);\n  sub_message->GetReflection()\n      ->SetInt64(sub_message, map_int64_int64_val_, 0);\n\n  sub_message = reflection->AddMessage(message, F(\"map_uint32_uint32\"));\n  sub_message->GetReflection()\n      ->SetUInt32(sub_message, map_uint32_uint32_key_, 0);\n  sub_message->GetReflection()\n      ->SetUInt32(sub_message, map_uint32_uint32_val_, 0);\n\n  sub_message = reflection->AddMessage(message, F(\"map_uint64_uint64\"));\n  sub_message->GetReflection()\n      ->SetUInt64(sub_message, map_uint64_uint64_key_, 0);\n  sub_message->GetReflection()\n      ->SetUInt64(sub_message, map_uint64_uint64_val_, 0);\n\n  sub_message = reflection->AddMessage(message, F(\"map_sint32_sint32\"));\n  sub_message->GetReflection()\n      ->SetInt32(sub_message, map_sint32_sint32_key_, 0);\n  sub_message->GetReflection()\n      ->SetInt32(sub_message, map_sint32_sint32_val_, 0);\n\n  sub_message = reflection->AddMessage(message, F(\"map_sint64_sint64\"));\n  sub_message->GetReflection()\n      ->SetInt64(sub_message, map_sint64_sint64_key_, 0);\n  sub_message->GetReflection()\n      ->SetInt64(sub_message, map_sint64_sint64_val_, 0);\n\n  sub_message = reflection->AddMessage(message, F(\"map_fixed32_fixed32\"));\n  sub_message->GetReflection()\n      ->SetUInt32(sub_message, map_fixed32_fixed32_key_, 0);\n  sub_message->GetReflection()\n      ->SetUInt32(sub_message, map_fixed32_fixed32_val_, 0);\n\n  sub_message = reflection->AddMessage(message, F(\"map_fixed64_fixed64\"));\n  sub_message->GetReflection()\n      ->SetUInt64(sub_message, map_fixed64_fixed64_key_, 0);\n  sub_message->GetReflection()\n      ->SetUInt64(sub_message, map_fixed64_fixed64_val_, 0);\n\n  sub_message = reflection->AddMessage(message, F(\"map_sfixed32_sfixed32\"));\n  sub_message->GetReflection()\n      ->SetInt32(sub_message, map_sfixed32_sfixed32_key_, 0);\n  sub_message->GetReflection()\n      ->SetInt32(sub_message, map_sfixed32_sfixed32_val_, 0);\n\n  sub_message = reflection->AddMessage(message, F(\"map_sfixed64_sfixed64\"));\n  sub_message->GetReflection()\n      ->SetInt64(sub_message, map_sfixed64_sfixed64_key_, 0);\n  sub_message->GetReflection()\n      ->SetInt64(sub_message, map_sfixed64_sfixed64_val_, 0);\n\n  sub_message = reflection->AddMessage(message, F(\"map_int32_float\"));\n  sub_message->GetReflection()\n      ->SetInt32(sub_message, map_int32_float_key_, 0);\n  sub_message->GetReflection()\n      ->SetFloat(sub_message, map_int32_float_val_, 0.0);\n\n  sub_message = reflection->AddMessage(message, F(\"map_int32_double\"));\n  sub_message->GetReflection()\n      ->SetInt32(sub_message, map_int32_double_key_, 0);\n  sub_message->GetReflection()\n      ->SetDouble(sub_message, map_int32_double_val_, 0.0);\n\n  sub_message = reflection->AddMessage(message, F(\"map_bool_bool\"));\n  sub_message->GetReflection()\n      ->SetBool(sub_message, map_bool_bool_key_, false);\n  sub_message->GetReflection()\n      ->SetBool(sub_message, map_bool_bool_val_, false);\n\n  sub_message = reflection->AddMessage(message, F(\"map_string_string\"));\n  sub_message->GetReflection()\n      ->SetString(sub_message, map_string_string_key_, \"0\");\n  sub_message->GetReflection()\n      ->SetString(sub_message, map_string_string_val_, \"0\");\n\n  sub_message = reflection->AddMessage(message, F(\"map_int32_bytes\"));\n  sub_message->GetReflection()\n      ->SetInt32(sub_message, map_int32_bytes_key_, 0);\n  sub_message->GetReflection()\n      ->SetString(sub_message, map_int32_bytes_val_, \"0\");\n\n  sub_message = reflection->AddMessage(message, F(\"map_int32_enum\"));\n  sub_message->GetReflection()\n      ->SetInt32(sub_message, map_int32_enum_key_, 0);\n  sub_message->GetReflection()\n      ->SetEnum(sub_message, map_int32_enum_val_, map_enum_bar_);\n\n  sub_message = reflection\n      ->AddMessage(message, F(\"map_int32_foreign_message\"));\n  sub_message->GetReflection()\n      ->SetInt32(sub_message, map_int32_foreign_message_key_, 0);\n  sub_foreign_message = sub_message->GetReflection()->\n      MutableMessage(sub_message, map_int32_foreign_message_val_, NULL);\n  sub_foreign_message->GetReflection()->\n      SetInt32(sub_foreign_message, foreign_c_, 0);\n\n  // Add second element\n  sub_message = reflection->AddMessage(message, F(\"map_int32_int32\"));\n  sub_message->GetReflection()\n      ->SetInt32(sub_message, map_int32_int32_key_, 1);\n  sub_message->GetReflection()\n      ->SetInt32(sub_message, map_int32_int32_val_, 1);\n\n  sub_message = reflection->AddMessage(message, F(\"map_int64_int64\"));\n  sub_message->GetReflection()\n      ->SetInt64(sub_message, map_int64_int64_key_, 1);\n  sub_message->GetReflection()\n      ->SetInt64(sub_message, map_int64_int64_val_, 1);\n\n  sub_message = reflection->AddMessage(message, F(\"map_uint32_uint32\"));\n  sub_message->GetReflection()\n      ->SetUInt32(sub_message, map_uint32_uint32_key_, 1);\n  sub_message->GetReflection()\n      ->SetUInt32(sub_message, map_uint32_uint32_val_, 1);\n\n  sub_message = reflection->AddMessage(message, F(\"map_uint64_uint64\"));\n  sub_message->GetReflection()\n      ->SetUInt64(sub_message, map_uint64_uint64_key_, 1);\n  sub_message->GetReflection()\n      ->SetUInt64(sub_message, map_uint64_uint64_val_, 1);\n\n  sub_message = reflection->AddMessage(message, F(\"map_sint32_sint32\"));\n  sub_message->GetReflection()\n      ->SetInt32(sub_message, map_sint32_sint32_key_, 1);\n  sub_message->GetReflection()\n      ->SetInt32(sub_message, map_sint32_sint32_val_, 1);\n\n  sub_message = reflection->AddMessage(message, F(\"map_sint64_sint64\"));\n  sub_message->GetReflection()\n      ->SetInt64(sub_message, map_sint64_sint64_key_, 1);\n  sub_message->GetReflection()\n      ->SetInt64(sub_message, map_sint64_sint64_val_, 1);\n\n  sub_message = reflection->AddMessage(message, F(\"map_fixed32_fixed32\"));\n  sub_message->GetReflection()\n      ->SetUInt32(sub_message, map_fixed32_fixed32_key_, 1);\n  sub_message->GetReflection()\n      ->SetUInt32(sub_message, map_fixed32_fixed32_val_, 1);\n\n  sub_message = reflection->AddMessage(message, F(\"map_fixed64_fixed64\"));\n  sub_message->GetReflection()\n      ->SetUInt64(sub_message, map_fixed64_fixed64_key_, 1);\n  sub_message->GetReflection()\n      ->SetUInt64(sub_message, map_fixed64_fixed64_val_, 1);\n\n  sub_message = reflection->AddMessage(message, F(\"map_sfixed32_sfixed32\"));\n  sub_message->GetReflection()\n      ->SetInt32(sub_message, map_sfixed32_sfixed32_key_, 1);\n  sub_message->GetReflection()\n      ->SetInt32(sub_message, map_sfixed32_sfixed32_val_, 1);\n\n  sub_message = reflection->AddMessage(message, F(\"map_sfixed64_sfixed64\"));\n  sub_message->GetReflection()\n      ->SetInt64(sub_message, map_sfixed64_sfixed64_key_, 1);\n  sub_message->GetReflection()\n      ->SetInt64(sub_message, map_sfixed64_sfixed64_val_, 1);\n\n  sub_message = reflection->AddMessage(message, F(\"map_int32_float\"));\n  sub_message->GetReflection()\n      ->SetInt32(sub_message, map_int32_float_key_, 1);\n  sub_message->GetReflection()\n      ->SetFloat(sub_message, map_int32_float_val_, 1.0);\n\n  sub_message = reflection->AddMessage(message, F(\"map_int32_double\"));\n  sub_message->GetReflection()\n      ->SetInt32(sub_message, map_int32_double_key_, 1);\n  sub_message->GetReflection()\n      ->SetDouble(sub_message, map_int32_double_val_, 1.0);\n\n  sub_message = reflection->AddMessage(message, F(\"map_bool_bool\"));\n  sub_message->GetReflection()\n      ->SetBool(sub_message, map_bool_bool_key_, true);\n  sub_message->GetReflection()\n      ->SetBool(sub_message, map_bool_bool_val_, true);\n\n  sub_message = reflection->AddMessage(message, F(\"map_string_string\"));\n  sub_message->GetReflection()\n      ->SetString(sub_message, map_string_string_key_, \"1\");\n  sub_message->GetReflection()\n      ->SetString(sub_message, map_string_string_val_, \"1\");\n\n  sub_message = reflection->AddMessage(message, F(\"map_int32_bytes\"));\n  sub_message->GetReflection()\n      ->SetInt32(sub_message, map_int32_bytes_key_, 1);\n  sub_message->GetReflection()\n      ->SetString(sub_message, map_int32_bytes_val_, \"1\");\n\n  sub_message = reflection->AddMessage(message, F(\"map_int32_enum\"));\n  sub_message->GetReflection()\n      ->SetInt32(sub_message, map_int32_enum_key_, 1);\n  sub_message->GetReflection()\n      ->SetEnum(sub_message, map_int32_enum_val_, map_enum_baz_);\n\n  sub_message = reflection\n      ->AddMessage(message, F(\"map_int32_foreign_message\"));\n  sub_message->GetReflection()\n      ->SetInt32(sub_message, map_int32_foreign_message_key_, 1);\n  sub_foreign_message = sub_message->GetReflection()->\n      MutableMessage(sub_message, map_int32_foreign_message_val_, NULL);\n  sub_foreign_message->GetReflection()->\n      SetInt32(sub_foreign_message, foreign_c_, 1);\n}\n\nvoid MapReflectionTester::SetMapFieldsViaMapReflection(\n    Message* message) {\n  const Reflection* reflection = message->GetReflection();\n\n  Message* sub_foreign_message = NULL;\n  MapValueRef map_val;\n\n  // Add first element.\n  MapKey map_key;\n  map_key.SetInt32Value(0);\n  EXPECT_TRUE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_int32_int32\"), map_key, &map_val));\n  map_val.SetInt32Value(0);\n\n  map_key.SetInt64Value(0);\n  EXPECT_TRUE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_int64_int64\"), map_key, &map_val));\n  map_val.SetInt64Value(0);\n\n  map_key.SetUInt32Value(0);\n  EXPECT_TRUE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_uint32_uint32\"), map_key, &map_val));\n  map_val.SetUInt32Value(0);\n\n  map_key.SetUInt64Value(0);\n  EXPECT_TRUE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_uint64_uint64\"), map_key, &map_val));\n  map_val.SetUInt64Value(0);\n\n  map_key.SetInt32Value(0);\n  EXPECT_TRUE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_sint32_sint32\"), map_key, &map_val));\n  map_val.SetInt32Value(0);\n\n  map_key.SetInt64Value(0);\n  EXPECT_TRUE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_sint64_sint64\"), map_key, &map_val));\n  map_val.SetInt64Value(0);\n\n  map_key.SetUInt32Value(0);\n  EXPECT_TRUE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_fixed32_fixed32\"), map_key, &map_val));\n  map_val.SetUInt32Value(0);\n\n  map_key.SetUInt64Value(0);\n  EXPECT_TRUE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_fixed64_fixed64\"), map_key, &map_val));\n  map_val.SetUInt64Value(0);\n\n  map_key.SetInt32Value(0);\n  EXPECT_TRUE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_sfixed32_sfixed32\"), map_key, &map_val));\n  map_val.SetInt32Value(0);\n\n  map_key.SetInt64Value(0);\n  EXPECT_TRUE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_sfixed64_sfixed64\"), map_key, &map_val));\n  map_val.SetInt64Value(0);\n\n  map_key.SetInt32Value(0);\n  EXPECT_TRUE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_int32_float\"), map_key, &map_val));\n  map_val.SetFloatValue(0.0);\n\n  map_key.SetInt32Value(0);\n  EXPECT_TRUE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_int32_double\"), map_key, &map_val));\n  map_val.SetDoubleValue(0.0);\n\n  map_key.SetBoolValue(false);\n  EXPECT_TRUE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_bool_bool\"), map_key, &map_val));\n  map_val.SetBoolValue(false);\n\n  map_key.SetStringValue(\"0\");\n  EXPECT_TRUE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_string_string\"), map_key, &map_val));\n  map_val.SetStringValue(\"0\");\n\n  map_key.SetInt32Value(0);\n  EXPECT_TRUE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_int32_bytes\"), map_key, &map_val));\n  map_val.SetStringValue(\"0\");\n\n  map_key.SetInt32Value(0);\n  EXPECT_TRUE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_int32_enum\"), map_key, &map_val));\n  map_val.SetEnumValue(map_enum_bar_->number());\n\n  map_key.SetInt32Value(0);\n  EXPECT_TRUE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_int32_foreign_message\"), map_key, &map_val));\n  sub_foreign_message = map_val.MutableMessageValue();\n  sub_foreign_message->GetReflection()->SetInt32(\n      sub_foreign_message, foreign_c_, 0);\n\n  // Add second element\n  map_key.SetInt32Value(1);\n  EXPECT_TRUE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_int32_int32\"), map_key, &map_val));\n  map_val.SetInt32Value(1);\n  EXPECT_FALSE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_int32_int32\"), map_key, &map_val));\n\n  map_key.SetInt64Value(1);\n  EXPECT_TRUE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_int64_int64\"), map_key, &map_val));\n  map_val.SetInt64Value(1);\n  EXPECT_FALSE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_int64_int64\"), map_key, &map_val));\n\n  map_key.SetUInt32Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_uint32_uint32\"), map_key, &map_val);\n  map_val.SetUInt32Value(1);\n\n  map_key.SetUInt64Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_uint64_uint64\"), map_key, &map_val);\n  map_val.SetUInt64Value(1);\n\n  map_key.SetInt32Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_sint32_sint32\"), map_key, &map_val);\n  map_val.SetInt32Value(1);\n\n  map_key.SetInt64Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_sint64_sint64\"), map_key, &map_val);\n  map_val.SetInt64Value(1);\n\n  map_key.SetUInt32Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_fixed32_fixed32\"), map_key, &map_val);\n  map_val.SetUInt32Value(1);\n\n  map_key.SetUInt64Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_fixed64_fixed64\"), map_key, &map_val);\n  map_val.SetUInt64Value(1);\n\n  map_key.SetInt32Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_sfixed32_sfixed32\"), map_key, &map_val);\n  map_val.SetInt32Value(1);\n\n  map_key.SetInt64Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_sfixed64_sfixed64\"), map_key, &map_val);\n  map_val.SetInt64Value(1);\n\n  map_key.SetInt32Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_int32_float\"), map_key, &map_val);\n  map_val.SetFloatValue(1.0);\n\n  map_key.SetInt32Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_int32_double\"), map_key, &map_val);\n  map_val.SetDoubleValue(1.0);\n\n  map_key.SetBoolValue(true);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_bool_bool\"), map_key, &map_val);\n  map_val.SetBoolValue(true);\n\n  map_key.SetStringValue(\"1\");\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_string_string\"), map_key, &map_val);\n  map_val.SetStringValue(\"1\");\n\n  map_key.SetInt32Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_int32_bytes\"), map_key, &map_val);\n  map_val.SetStringValue(\"1\");\n\n  map_key.SetInt32Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_int32_enum\"), map_key, &map_val);\n  map_val.SetEnumValue(map_enum_baz_->number());\n\n  map_key.SetInt32Value(1);\n  EXPECT_TRUE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_int32_foreign_message\"), map_key, &map_val));\n  sub_foreign_message = map_val.MutableMessageValue();\n  sub_foreign_message->GetReflection()->SetInt32(\n      sub_foreign_message, foreign_c_, 1);\n}\n\nvoid MapReflectionTester::ClearMapFieldsViaReflection(\n    Message* message) {\n  const Reflection* reflection = message->GetReflection();\n\n  reflection->ClearField(message, F(\"map_int32_int32\"));\n  reflection->ClearField(message, F(\"map_int64_int64\"));\n  reflection->ClearField(message, F(\"map_uint32_uint32\"));\n  reflection->ClearField(message, F(\"map_uint64_uint64\"));\n  reflection->ClearField(message, F(\"map_sint32_sint32\"));\n  reflection->ClearField(message, F(\"map_sint64_sint64\"));\n  reflection->ClearField(message, F(\"map_fixed32_fixed32\"));\n  reflection->ClearField(message, F(\"map_fixed64_fixed64\"));\n  reflection->ClearField(message, F(\"map_sfixed32_sfixed32\"));\n  reflection->ClearField(message, F(\"map_sfixed64_sfixed64\"));\n  reflection->ClearField(message, F(\"map_int32_float\"));\n  reflection->ClearField(message, F(\"map_int32_double\"));\n  reflection->ClearField(message, F(\"map_bool_bool\"));\n  reflection->ClearField(message, F(\"map_string_string\"));\n  reflection->ClearField(message, F(\"map_int32_bytes\"));\n  reflection->ClearField(message, F(\"map_int32_enum\"));\n  reflection->ClearField(message, F(\"map_int32_foreign_message\"));\n}\n\nvoid MapReflectionTester::ModifyMapFieldsViaReflection(\n    Message* message) {\n  const Reflection* reflection = message->GetReflection();\n  MapValueRef map_val;\n  Message* sub_foreign_message;\n\n  // Modify the second element\n  MapKey map_key;\n  map_key.SetInt32Value(1);\n  EXPECT_FALSE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_int32_int32\"), map_key, &map_val));\n  map_val.SetInt32Value(2);\n\n  map_key.SetInt64Value(1);\n  EXPECT_FALSE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_int64_int64\"), map_key, &map_val));\n  map_val.SetInt64Value(2);\n\n  map_key.SetUInt32Value(1);\n  EXPECT_FALSE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_uint32_uint32\"), map_key, &map_val));\n  map_val.SetUInt32Value(2);\n\n  map_key.SetUInt64Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_uint64_uint64\"), map_key, &map_val);\n  map_val.SetUInt64Value(2);\n\n  map_key.SetInt32Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_sint32_sint32\"), map_key, &map_val);\n  map_val.SetInt32Value(2);\n\n  map_key.SetInt64Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_sint64_sint64\"), map_key, &map_val);\n  map_val.SetInt64Value(2);\n\n  map_key.SetUInt32Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_fixed32_fixed32\"), map_key, &map_val);\n  map_val.SetUInt32Value(2);\n\n  map_key.SetUInt64Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_fixed64_fixed64\"), map_key, &map_val);\n  map_val.SetUInt64Value(2);\n\n  map_key.SetInt32Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_sfixed32_sfixed32\"), map_key, &map_val);\n  map_val.SetInt32Value(2);\n\n  map_key.SetInt64Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_sfixed64_sfixed64\"), map_key, &map_val);\n  map_val.SetInt64Value(2);\n\n  map_key.SetInt32Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_int32_float\"), map_key, &map_val);\n  map_val.SetFloatValue(2.0);\n\n  map_key.SetInt32Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_int32_double\"), map_key, &map_val);\n  map_val.SetDoubleValue(2.0);\n\n  map_key.SetBoolValue(true);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_bool_bool\"), map_key, &map_val);\n  map_val.SetBoolValue(false);\n\n  map_key.SetStringValue(\"1\");\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_string_string\"), map_key, &map_val);\n  map_val.SetStringValue(\"2\");\n\n  map_key.SetInt32Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_int32_bytes\"), map_key, &map_val);\n  map_val.SetStringValue(\"2\");\n\n  map_key.SetInt32Value(1);\n  reflection->InsertOrLookupMapValue(\n      message, F(\"map_int32_enum\"), map_key, &map_val);\n  map_val.SetEnumValue(map_enum_foo_->number());\n\n  map_key.SetInt32Value(1);\n  EXPECT_FALSE(reflection->InsertOrLookupMapValue(\n      message, F(\"map_int32_foreign_message\"), map_key, &map_val));\n  sub_foreign_message = map_val.MutableMessageValue();\n  sub_foreign_message->GetReflection()->SetInt32(\n      sub_foreign_message, foreign_c_, 2);\n}\n\nvoid MapReflectionTester::RemoveLastMapsViaReflection(\n    Message* message) {\n  const Reflection* reflection = message->GetReflection();\n\n  vector<const FieldDescriptor*> output;\n  reflection->ListFields(*message, &output);\n  for (int i = 0; i < output.size(); ++i) {\n    const FieldDescriptor* field = output[i];\n    if (!field->is_repeated()) continue;\n    reflection->RemoveLast(message, field);\n  }\n}\n\nvoid MapReflectionTester::ReleaseLastMapsViaReflection(\n    Message* message) {\n  const Reflection* reflection = message->GetReflection();\n\n  vector<const FieldDescriptor*> output;\n  reflection->ListFields(*message, &output);\n  for (int i = 0; i < output.size(); ++i) {\n    const FieldDescriptor* field = output[i];\n    if (!field->is_repeated()) continue;\n    if (field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) continue;\n\n    Message* released = reflection->ReleaseLast(message, field);\n    ASSERT_TRUE(released != NULL) << \"ReleaseLast returned NULL for: \"\n                                  << field->name();\n    delete released;\n  }\n}\n\nvoid MapReflectionTester::SwapMapsViaReflection(Message* message) {\n  const Reflection* reflection = message->GetReflection();\n  vector<const FieldDescriptor*> output;\n  reflection->ListFields(*message, &output);\n  for (int i = 0; i < output.size(); ++i) {\n    const FieldDescriptor* field = output[i];\n    if (!field->is_repeated()) continue;\n    reflection->SwapElements(message, field, 0, 1);\n  }\n}\n\nvoid MapReflectionTester::\n    MutableUnknownFieldsOfMapFieldsViaReflection(Message* message) {\n  const Reflection* reflection = message->GetReflection();\n  Message* sub_message = NULL;\n\n  sub_message = reflection->AddMessage(message, F(\"map_int32_int32\"));\n  EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=\n              NULL);\n  sub_message = reflection->AddMessage(message, F(\"map_int64_int64\"));\n  EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=\n              NULL);\n  sub_message = reflection->AddMessage(message, F(\"map_uint32_uint32\"));\n  EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=\n              NULL);\n  sub_message = reflection->AddMessage(message, F(\"map_uint64_uint64\"));\n  EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=\n              NULL);\n  sub_message = reflection->AddMessage(message, F(\"map_sint32_sint32\"));\n  EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=\n              NULL);\n  sub_message = reflection->AddMessage(message, F(\"map_sint64_sint64\"));\n  EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=\n              NULL);\n  sub_message = reflection->AddMessage(message, F(\"map_fixed32_fixed32\"));\n  EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=\n              NULL);\n  sub_message = reflection->AddMessage(message, F(\"map_fixed64_fixed64\"));\n  EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=\n              NULL);\n  sub_message = reflection->AddMessage(message, F(\"map_sfixed32_sfixed32\"));\n  EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=\n              NULL);\n  sub_message = reflection->AddMessage(message, F(\"map_sfixed64_sfixed64\"));\n  EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=\n              NULL);\n  sub_message = reflection->AddMessage(message, F(\"map_int32_float\"));\n  EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=\n              NULL);\n  sub_message = reflection->AddMessage(message, F(\"map_int32_double\"));\n  EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=\n              NULL);\n  sub_message = reflection->AddMessage(message, F(\"map_bool_bool\"));\n  EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=\n              NULL);\n  sub_message = reflection->AddMessage(message, F(\"map_string_string\"));\n  EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=\n              NULL);\n  sub_message = reflection->AddMessage(message, F(\"map_int32_bytes\"));\n  EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=\n              NULL);\n  sub_message = reflection->AddMessage(message, F(\"map_int32_enum\"));\n  EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=\n              NULL);\n  sub_message = reflection->AddMessage(message, F(\"map_int32_foreign_message\"));\n  EXPECT_TRUE(sub_message->GetReflection()->MutableUnknownFields(sub_message) !=\n              NULL);\n}\n\nvoid MapReflectionTester::ExpectMapFieldsSetViaReflection(\n    const Message& message) {\n  string scratch;\n  const Reflection* reflection = message.GetReflection();\n  const Message* sub_message;\n  MapKey map_key;\n\n  // -----------------------------------------------------------------\n\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"map_int32_int32\")));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"map_int64_int64\")));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"map_uint32_uint32\")));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"map_uint64_uint64\")));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"map_sint32_sint32\")));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"map_sint64_sint64\")));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"map_fixed32_fixed32\")));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"map_fixed64_fixed64\")));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"map_sfixed32_sfixed32\")));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"map_sfixed64_sfixed64\")));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"map_int32_float\")));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"map_int32_double\")));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"map_bool_bool\")));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"map_string_string\")));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"map_int32_bytes\")));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"map_int32_enum\")));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"map_int32_foreign_message\")));\n\n  {\n    std::map<int32, int32> map;\n    map[0] = 0;\n    map[1] = 1;\n    for (int i = 0; i < 2; i++) {\n      // Check with RepeatedField Reflection\n      sub_message =\n          &reflection->GetRepeatedMessage(message, F(\"map_int32_int32\"), i);\n      int32 key = sub_message->GetReflection()->GetInt32(\n          *sub_message, map_int32_int32_key_);\n      int32 val = sub_message->GetReflection()->GetInt32(\n          *sub_message, map_int32_int32_val_);\n      EXPECT_EQ(map[key], val);\n      // Check with Map Reflection\n      map_key.SetInt32Value(key);\n      EXPECT_TRUE(reflection->ContainsMapKey(\n          message, F(\"map_int32_int32\"), map_key));\n    }\n  }\n  {\n    std::map<int64, int64> map;\n    map[0] = 0;\n    map[1] = 1;\n    for (int i = 0; i < 2; i++) {\n      // Check with RepeatedField Reflection\n      sub_message =\n          &reflection->GetRepeatedMessage(message, F(\"map_int64_int64\"), i);\n      int64 key = sub_message->GetReflection()->GetInt64(\n          *sub_message, map_int64_int64_key_);\n      int64 val = sub_message->GetReflection()->GetInt64(\n          *sub_message, map_int64_int64_val_);\n      EXPECT_EQ(map[key], val);\n      // Check with Map Reflection\n      map_key.SetInt64Value(key);\n      EXPECT_TRUE(reflection->ContainsMapKey(\n          message, F(\"map_int64_int64\"), map_key));\n    }\n  }\n  {\n    std::map<uint32, uint32> map;\n    map[0] = 0;\n    map[1] = 1;\n    for (int i = 0; i < 2; i++) {\n      // Check with RepeatedField Reflection\n      sub_message =\n          &reflection->GetRepeatedMessage(message, F(\"map_uint32_uint32\"), i);\n      uint32 key = sub_message->GetReflection()->GetUInt32(\n          *sub_message, map_uint32_uint32_key_);\n      uint32 val = sub_message->GetReflection()->GetUInt32(\n          *sub_message, map_uint32_uint32_val_);\n      EXPECT_EQ(map[key], val);\n      // Check with Map Reflection\n      map_key.SetUInt32Value(key);\n      EXPECT_TRUE(reflection->ContainsMapKey(\n          message, F(\"map_uint32_uint32\"), map_key));\n    }\n  }\n  {\n    std::map<uint64, uint64> map;\n    map[0] = 0;\n    map[1] = 1;\n    for (int i = 0; i < 2; i++) {\n      sub_message =\n          &reflection->GetRepeatedMessage(message, F(\"map_uint64_uint64\"), i);\n      uint64 key = sub_message->GetReflection()->GetUInt64(\n          *sub_message, map_uint64_uint64_key_);\n      uint64 val = sub_message->GetReflection()->GetUInt64(\n          *sub_message, map_uint64_uint64_val_);\n      EXPECT_EQ(map[key], val);\n      // Check with Map Reflection\n      map_key.SetUInt64Value(key);\n      EXPECT_TRUE(reflection->ContainsMapKey(\n          message, F(\"map_uint64_uint64\"), map_key));\n    }\n  }\n  {\n    std::map<int32, int32> map;\n    map[0] = 0;\n    map[1] = 1;\n    for (int i = 0; i < 2; i++) {\n      sub_message =\n          &reflection->GetRepeatedMessage(message, F(\"map_sint32_sint32\"), i);\n      int32 key = sub_message->GetReflection()->GetInt32(\n          *sub_message, map_sint32_sint32_key_);\n      int32 val = sub_message->GetReflection()->GetInt32(\n          *sub_message, map_sint32_sint32_val_);\n      EXPECT_EQ(map[key], val);\n      // Check with Map Reflection\n      map_key.SetInt32Value(key);\n      EXPECT_EQ(true, reflection->ContainsMapKey(\n          message, F(\"map_sint32_sint32\"), map_key));\n    }\n  }\n  {\n    std::map<int64, int64> map;\n    map[0] = 0;\n    map[1] = 1;\n    for (int i = 0; i < 2; i++) {\n      sub_message =\n          &reflection->GetRepeatedMessage(message, F(\"map_sint64_sint64\"), i);\n      int64 key = sub_message->GetReflection()->GetInt64(\n          *sub_message, map_sint64_sint64_key_);\n      int64 val = sub_message->GetReflection()->GetInt64(\n          *sub_message, map_sint64_sint64_val_);\n      EXPECT_EQ(map[key], val);\n      // Check with Map Reflection\n      map_key.SetInt64Value(key);\n      EXPECT_EQ(true, reflection->ContainsMapKey(\n          message, F(\"map_sint64_sint64\"), map_key));\n    }\n  }\n  {\n    std::map<uint32, uint32> map;\n    map[0] = 0;\n    map[1] = 1;\n    for (int i = 0; i < 2; i++) {\n      sub_message =\n          &reflection->GetRepeatedMessage(message, F(\"map_fixed32_fixed32\"), i);\n      uint32 key = sub_message->GetReflection()->GetUInt32(\n          *sub_message, map_fixed32_fixed32_key_);\n      uint32 val = sub_message->GetReflection()->GetUInt32(\n          *sub_message, map_fixed32_fixed32_val_);\n      EXPECT_EQ(map[key], val);\n      // Check with Map Reflection\n      map_key.SetUInt32Value(key);\n      EXPECT_EQ(true, reflection->ContainsMapKey(\n          message, F(\"map_fixed32_fixed32\"), map_key));\n    }\n  }\n  {\n    std::map<uint64, uint64> map;\n    map[0] = 0;\n    map[1] = 1;\n    for (int i = 0; i < 2; i++) {\n      sub_message =\n          &reflection->GetRepeatedMessage(message, F(\"map_fixed64_fixed64\"), i);\n      uint64 key = sub_message->GetReflection()->GetUInt64(\n          *sub_message, map_fixed64_fixed64_key_);\n      uint64 val = sub_message->GetReflection()->GetUInt64(\n          *sub_message, map_fixed64_fixed64_val_);\n      EXPECT_EQ(map[key], val);\n      // Check with Map Reflection\n      map_key.SetUInt64Value(key);\n      EXPECT_EQ(true, reflection->ContainsMapKey(\n          message, F(\"map_fixed64_fixed64\"), map_key));\n    }\n  }\n  {\n    std::map<int32, int32> map;\n    map[0] = 0;\n    map[1] = 1;\n    for (int i = 0; i < 2; i++) {\n      sub_message = &reflection->GetRepeatedMessage(\n          message, F(\"map_sfixed32_sfixed32\"), i);\n      int32 key = sub_message->GetReflection()->GetInt32(\n          *sub_message, map_sfixed32_sfixed32_key_);\n      int32 val = sub_message->GetReflection()->GetInt32(\n          *sub_message, map_sfixed32_sfixed32_val_);\n      EXPECT_EQ(map[key], val);\n      // Check with Map Reflection\n      map_key.SetInt32Value(key);\n      EXPECT_EQ(true, reflection->ContainsMapKey(\n          message, F(\"map_sfixed32_sfixed32\"), map_key));\n    }\n  }\n  {\n    std::map<int64, int64> map;\n    map[0] = 0;\n    map[1] = 1;\n    for (int i = 0; i < 2; i++) {\n      sub_message = &reflection->GetRepeatedMessage(\n          message, F(\"map_sfixed64_sfixed64\"), i);\n      int64 key = sub_message->GetReflection()->GetInt64(\n          *sub_message, map_sfixed64_sfixed64_key_);\n      int64 val = sub_message->GetReflection()->GetInt64(\n          *sub_message, map_sfixed64_sfixed64_val_);\n      EXPECT_EQ(map[key], val);\n      // Check with Map Reflection\n      map_key.SetInt64Value(key);\n      EXPECT_EQ(true, reflection->ContainsMapKey(\n          message, F(\"map_sfixed64_sfixed64\"), map_key));\n    }\n  }\n  {\n    std::map<int32, float> map;\n    map[0] = 0.0;\n    map[1] = 1.0;\n    for (int i = 0; i < 2; i++) {\n      sub_message =\n          &reflection->GetRepeatedMessage(message, F(\"map_int32_float\"), i);\n      int32  key = sub_message->GetReflection()->GetInt32(\n          *sub_message, map_int32_float_key_);\n      float val = sub_message->GetReflection()->GetFloat(\n          *sub_message, map_int32_float_val_);\n      EXPECT_EQ(map[key], val);\n      // Check with Map Reflection\n      map_key.SetInt32Value(key);\n      EXPECT_EQ(true, reflection->ContainsMapKey(\n          message, F(\"map_int32_float\"), map_key));\n    }\n  }\n  {\n    std::map<int32, double> map;\n    map[0] = 0.0;\n    map[1] = 1.0;\n    for (int i = 0; i < 2; i++) {\n      sub_message =\n          &reflection->GetRepeatedMessage(message, F(\"map_int32_double\"), i);\n      int32  key = sub_message->GetReflection()->GetInt32(\n          *sub_message, map_int32_double_key_);\n      double val = sub_message->GetReflection()->GetDouble(\n          *sub_message, map_int32_double_val_);\n      EXPECT_EQ(map[key], val);\n      // Check with Map Reflection\n      map_key.SetInt32Value(key);\n      EXPECT_EQ(true, reflection->ContainsMapKey(\n          message, F(\"map_int32_double\"), map_key));\n    }\n  }\n  {\n    std::map<bool, bool> map;\n    map[false] = false;\n    map[true] = true;\n    for (int i = 0; i < 2; i++) {\n      sub_message =\n          &reflection->GetRepeatedMessage(message, F(\"map_bool_bool\"), i);\n      bool key = sub_message->GetReflection()->GetBool(\n          *sub_message, map_bool_bool_key_);\n      bool val = sub_message->GetReflection()->GetBool(\n          *sub_message, map_bool_bool_val_);\n      EXPECT_EQ(map[key], val);\n      // Check with Map Reflection\n      map_key.SetBoolValue(key);\n      EXPECT_EQ(true, reflection->ContainsMapKey(\n          message, F(\"map_bool_bool\"), map_key));\n    }\n  }\n  {\n    std::map<string, string> map;\n    map[\"0\"] = \"0\";\n    map[\"1\"] = \"1\";\n    for (int i = 0; i < 2; i++) {\n      sub_message =\n          &reflection->GetRepeatedMessage(message, F(\"map_string_string\"), i);\n      string  key = sub_message->GetReflection()->GetString(\n          *sub_message, map_string_string_key_);\n      string val = sub_message->GetReflection()->GetString(\n          *sub_message, map_string_string_val_);\n      EXPECT_EQ(map[key], val);\n      // Check with Map Reflection\n      map_key.SetStringValue(key);\n      EXPECT_EQ(true, reflection->ContainsMapKey(\n          message, F(\"map_string_string\"), map_key));\n    }\n  }\n  {\n    std::map<int32, string> map;\n    map[0] = \"0\";\n    map[1] = \"1\";\n    for (int i = 0; i < 2; i++) {\n      sub_message =\n          &reflection->GetRepeatedMessage(message, F(\"map_int32_bytes\"), i);\n      int32  key = sub_message->GetReflection()->GetInt32(\n          *sub_message, map_int32_bytes_key_);\n      string val = sub_message->GetReflection()->GetString(\n          *sub_message, map_int32_bytes_val_);\n      EXPECT_EQ(map[key], val);\n      // Check with Map Reflection\n      map_key.SetInt32Value(key);\n      EXPECT_EQ(true, reflection->ContainsMapKey(\n          message, F(\"map_int32_bytes\"), map_key));\n    }\n  }\n  {\n    std::map<int32, const EnumValueDescriptor*> map;\n    map[0] = map_enum_bar_;\n    map[1] = map_enum_baz_;\n    for (int i = 0; i < 2; i++) {\n      sub_message = &reflection->GetRepeatedMessage(\n          message, F(\"map_int32_enum\"), i);\n      int32 key = sub_message->GetReflection()->GetInt32(\n          *sub_message, map_int32_enum_key_);\n      const EnumValueDescriptor* val = sub_message->GetReflection()->GetEnum(\n          *sub_message, map_int32_enum_val_);\n      EXPECT_EQ(map[key], val);\n      // Check with Map Reflection\n      map_key.SetInt32Value(key);\n      EXPECT_EQ(true, reflection->ContainsMapKey(\n          message, F(\"map_int32_enum\"), map_key));\n    }\n  }\n  {\n    std::map<int32, int32> map;\n    map[0] = 0;\n    map[1] = 1;\n    for (int i = 0; i < 2; i++) {\n      sub_message = &reflection->GetRepeatedMessage(\n          message, F(\"map_int32_foreign_message\"), i);\n      int32  key = sub_message->GetReflection()->GetInt32(\n          *sub_message, map_int32_foreign_message_key_);\n      const Message& foreign_message = sub_message->GetReflection()->GetMessage(\n          *sub_message, map_int32_foreign_message_val_);\n      int32 val = foreign_message.GetReflection()->GetInt32(\n          foreign_message, foreign_c_);\n      EXPECT_EQ(map[key], val);\n      // Check with Map Reflection\n      map_key.SetInt32Value(key);\n      EXPECT_EQ(true, reflection->ContainsMapKey(\n          message, F(\"map_int32_foreign_message\"), map_key));\n    }\n  }\n}\n\nvoid MapReflectionTester::ExpectMapFieldsSetViaReflectionIterator(\n    Message* message) {\n  string scratch;\n  string serialized;\n  const Reflection* reflection = message->GetReflection();\n\n  ASSERT_EQ(2, reflection->FieldSize(*message, F(\"map_int32_int32\")));\n  ASSERT_EQ(2, reflection->FieldSize(*message, F(\"map_int64_int64\")));\n  ASSERT_EQ(2, reflection->FieldSize(*message, F(\"map_uint32_uint32\")));\n  ASSERT_EQ(2, reflection->FieldSize(*message, F(\"map_uint64_uint64\")));\n  ASSERT_EQ(2, reflection->FieldSize(*message, F(\"map_sint32_sint32\")));\n  ASSERT_EQ(2, reflection->FieldSize(*message, F(\"map_sint64_sint64\")));\n  ASSERT_EQ(2, reflection->FieldSize(*message, F(\"map_fixed32_fixed32\")));\n  ASSERT_EQ(2, reflection->FieldSize(*message, F(\"map_fixed64_fixed64\")));\n  ASSERT_EQ(2, reflection->FieldSize(*message, F(\"map_sfixed32_sfixed32\")));\n  ASSERT_EQ(2, reflection->FieldSize(*message, F(\"map_sfixed64_sfixed64\")));\n  ASSERT_EQ(2, reflection->FieldSize(*message, F(\"map_int32_float\")));\n  ASSERT_EQ(2, reflection->FieldSize(*message, F(\"map_int32_double\")));\n  ASSERT_EQ(2, reflection->FieldSize(*message, F(\"map_bool_bool\")));\n  ASSERT_EQ(2, reflection->FieldSize(*message, F(\"map_string_string\")));\n  ASSERT_EQ(2, reflection->FieldSize(*message, F(\"map_int32_bytes\")));\n  ASSERT_EQ(2, reflection->FieldSize(*message, F(\"map_int32_enum\")));\n  ASSERT_EQ(2, reflection->FieldSize(*message, F(\"map_int32_foreign_message\")));\n\n  {\n    std::map<int32, int32> map;\n    map[0] = 0;\n    map[1] = 1;\n    int size = 0;\n    for (MapIterator iter = reflection->MapBegin(message, F(\"map_int32_int32\"));\n         iter != reflection->MapEnd(message, F(\"map_int32_int32\"));\n         ++iter, ++size) {\n      // Check const methods do not invalidate map.\n      message->DebugString();\n      message->ShortDebugString();\n      message->SerializeToString(&serialized);\n      message->SpaceUsed();\n      message->ByteSize();\n      EXPECT_EQ(map[iter.GetKey().GetInt32Value()],\n                iter.GetValueRef().GetInt32Value());\n    }\n    EXPECT_EQ(size, 2);\n  }\n  {\n    std::map<int64, int64> map;\n    map[0] = 0;\n    map[1] = 1;\n    for (MapIterator iter = reflection->MapBegin(message, F(\"map_int64_int64\"));\n         iter != reflection->MapEnd(message, F(\"map_int64_int64\")); ++iter) {\n      EXPECT_EQ(map[iter.GetKey().GetInt64Value()],\n                iter.GetValueRef().GetInt64Value());\n    }\n  }\n  {\n    std::map<uint32, uint32> map;\n    map[0] = 0;\n    map[1] = 1;\n    for (MapIterator iter = reflection->MapBegin(\n             message, F(\"map_uint32_uint32\"));\n         iter != reflection->MapEnd(message, F(\"map_uint32_uint32\"));\n         ++iter) {\n      EXPECT_EQ(map[iter.GetKey().GetUInt32Value()],\n                iter.GetValueRef().GetUInt32Value());\n    }\n  }\n  {\n    std::map<uint64, uint64> map;\n    map[0] = 0;\n    map[1] = 1;\n    for (MapIterator iter = reflection->MapBegin(\n             message, F(\"map_uint64_uint64\"));\n         iter != reflection->MapEnd(message, F(\"map_uint64_uint64\"));\n         ++iter) {\n      EXPECT_EQ(map[iter.GetKey().GetUInt64Value()],\n                iter.GetValueRef().GetUInt64Value());\n    }\n  }\n  {\n    std::map<int32, int32> map;\n    map[0] = 0;\n    map[1] = 1;\n    for (MapIterator iter = reflection->MapBegin(\n             message, F(\"map_sint32_sint32\"));\n         iter != reflection->MapEnd(message, F(\"map_sint32_sint32\"));\n         ++iter) {\n      EXPECT_EQ(map[iter.GetKey().GetInt32Value()],\n                iter.GetValueRef().GetInt32Value());\n    }\n  }\n  {\n    std::map<int64, int64> map;\n    map[0] = 0;\n    map[1] = 1;\n    for (MapIterator iter = reflection->MapBegin(\n             message, F(\"map_sint64_sint64\"));\n         iter != reflection->MapEnd(message, F(\"map_sint64_sint64\")); ++iter) {\n      EXPECT_EQ(map[iter.GetKey().GetInt64Value()],\n                iter.GetValueRef().GetInt64Value());\n    }\n  }\n  {\n    std::map<uint32, uint32> map;\n    map[0] = 0;\n    map[1] = 1;\n    for (MapIterator iter = reflection->MapBegin(\n             message, F(\"map_fixed32_fixed32\"));\n         iter != reflection->MapEnd(message, F(\"map_fixed32_fixed32\"));\n         ++iter) {\n      EXPECT_EQ(map[iter.GetKey().GetUInt32Value()],\n                iter.GetValueRef().GetUInt32Value());\n    }\n  }\n  {\n    std::map<uint64, uint64> map;\n    map[0] = 0;\n    map[1] = 1;\n    for (MapIterator iter = reflection->MapBegin(\n             message, F(\"map_fixed64_fixed64\"));\n         iter != reflection->MapEnd(message, F(\"map_fixed64_fixed64\"));\n         ++iter) {\n      EXPECT_EQ(map[iter.GetKey().GetUInt64Value()],\n                iter.GetValueRef().GetUInt64Value());\n    }\n  }\n  {\n    std::map<int32, int32> map;\n    map[0] = 0;\n    map[1] = 1;\n    for (MapIterator iter = reflection->MapBegin(\n             message, F(\"map_sfixed32_sfixed32\"));\n         iter != reflection->MapEnd(message, F(\"map_sfixed32_sfixed32\"));\n         ++iter) {\n      EXPECT_EQ(map[iter.GetKey().GetInt32Value()],\n                iter.GetValueRef().GetInt32Value());\n    }\n  }\n  {\n    std::map<int32, float> map;\n    map[0] = 0.0;\n    map[1] = 1.0;\n    for (MapIterator iter = reflection->MapBegin(message, F(\"map_int32_float\"));\n         iter != reflection->MapEnd(message, F(\"map_int32_float\")); ++iter) {\n      EXPECT_EQ(map[iter.GetKey().GetInt32Value()],\n                iter.GetValueRef().GetFloatValue());\n    }\n  }\n  {\n    std::map<int32, double> map;\n    map[0] = 0.0;\n    map[1] = 1.0;\n    for (MapIterator iter = reflection->MapBegin(\n             message, F(\"map_int32_double\"));\n         iter != reflection->MapEnd(message, F(\"map_int32_double\")); ++iter) {\n      EXPECT_EQ(map[iter.GetKey().GetInt32Value()],\n                iter.GetValueRef().GetDoubleValue());\n    }\n  }\n  {\n    std::map<bool, bool> map;\n    map[false] = false;\n    map[true] = true;\n    for (MapIterator iter = reflection->MapBegin(message, F(\"map_bool_bool\"));\n         iter != reflection->MapEnd(message, F(\"map_bool_bool\")); ++iter) {\n      EXPECT_EQ(map[iter.GetKey().GetBoolValue()],\n                iter.GetValueRef().GetBoolValue());\n    }\n  }\n  {\n    std::map<string, string> map;\n    map[\"0\"] = \"0\";\n    map[\"1\"] = \"1\";\n    int size = 0;\n    for (MapIterator iter = reflection->MapBegin(\n             message, F(\"map_string_string\"));\n         iter != reflection->MapEnd(message, F(\"map_string_string\"));\n         ++iter, ++size) {\n      // Check const methods do not invalidate map.\n      message->DebugString();\n      message->ShortDebugString();\n      message->SerializeToString(&serialized);\n      message->SpaceUsed();\n      message->ByteSize();\n      EXPECT_EQ(map[iter.GetKey().GetStringValue()],\n                iter.GetValueRef().GetStringValue());\n    }\n    EXPECT_EQ(size, 2);\n  }\n  {\n    std::map<int32, string> map;\n    map[0] = \"0\";\n    map[1] = \"1\";\n    for (MapIterator iter = reflection->MapBegin(message, F(\"map_int32_bytes\"));\n         iter != reflection->MapEnd(message, F(\"map_int32_bytes\")); ++iter) {\n      EXPECT_EQ(map[iter.GetKey().GetInt32Value()],\n                iter.GetValueRef().GetStringValue());\n    }\n  }\n  {\n    std::map<int32, const EnumValueDescriptor*> map;\n    map[0] = map_enum_bar_;\n    map[1] = map_enum_baz_;\n    for (MapIterator iter = reflection->MapBegin(message, F(\"map_int32_enum\"));\n         iter != reflection->MapEnd(message, F(\"map_int32_enum\")); ++iter) {\n      EXPECT_EQ(map[iter.GetKey().GetInt32Value()]->number(),\n                iter.GetValueRef().GetEnumValue());\n    }\n  }\n  {\n    std::map<int32, int32> map;\n    map[0] = 0;\n    map[1] = 1;\n    int size = 0;\n    for (MapIterator iter = reflection->MapBegin(\n             message, F(\"map_int32_foreign_message\"));\n         iter != reflection->MapEnd(message, F(\"map_int32_foreign_message\"));\n         ++iter, ++size) {\n      // Check const methods do not invalidate map.\n      message->DebugString();\n      message->ShortDebugString();\n      message->SerializeToString(&serialized);\n      message->SpaceUsed();\n      message->ByteSize();\n      const Message& sub_message = iter.GetValueRef().GetMessageValue();\n      EXPECT_EQ(map[iter.GetKey().GetInt32Value()],\n                sub_message.GetReflection()->GetInt32(sub_message, foreign_c_));\n    }\n    EXPECT_EQ(size, 2);\n  }\n}\n\nvoid MapReflectionTester::ExpectClearViaReflection(\n    const Message& message) {\n  const Reflection* reflection = message.GetReflection();\n  // Map fields are empty.\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"map_int32_int32\")));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"map_int64_int64\")));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"map_uint32_uint32\")));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"map_uint64_uint64\")));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"map_sint32_sint32\")));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"map_sint64_sint64\")));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"map_fixed32_fixed32\")));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"map_fixed64_fixed64\")));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"map_sfixed32_sfixed32\")));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"map_sfixed64_sfixed64\")));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"map_int32_float\")));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"map_int32_double\")));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"map_bool_bool\")));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"map_string_string\")));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"map_int32_bytes\")));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"map_int32_enum\")));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"map_int32_foreign_message\")));\n}\n\nvoid MapReflectionTester::ExpectClearViaReflectionIterator(\n    Message* message) {\n  const Reflection* reflection = message->GetReflection();\n  EXPECT_TRUE(reflection->MapBegin(message, F(\"map_int32_int32\")) ==\n              reflection->MapEnd(message, F(\"map_int32_int32\")));\n  EXPECT_TRUE(reflection->MapBegin(message, F(\"map_int64_int64\")) ==\n              reflection->MapEnd(message, F(\"map_int64_int64\")));\n  EXPECT_TRUE(reflection->MapBegin(message, F(\"map_uint32_uint32\")) ==\n              reflection->MapEnd(message, F(\"map_uint32_uint32\")));\n  EXPECT_TRUE(reflection->MapBegin(message, F(\"map_uint64_uint64\")) ==\n              reflection->MapEnd(message, F(\"map_uint64_uint64\")));\n  EXPECT_TRUE(reflection->MapBegin(message, F(\"map_sint32_sint32\")) ==\n              reflection->MapEnd(message, F(\"map_sint32_sint32\")));\n  EXPECT_TRUE(reflection->MapBegin(message, F(\"map_sint64_sint64\")) ==\n              reflection->MapEnd(message, F(\"map_sint64_sint64\")));\n  EXPECT_TRUE(reflection->MapBegin(message, F(\"map_fixed32_fixed32\")) ==\n              reflection->MapEnd(message, F(\"map_fixed32_fixed32\")));\n  EXPECT_TRUE(reflection->MapBegin(message, F(\"map_fixed64_fixed64\")) ==\n              reflection->MapEnd(message, F(\"map_fixed64_fixed64\")));\n  EXPECT_TRUE(reflection->MapBegin(message, F(\"map_sfixed32_sfixed32\")) ==\n              reflection->MapEnd(message, F(\"map_sfixed32_sfixed32\")));\n  EXPECT_TRUE(reflection->MapBegin(message, F(\"map_sfixed64_sfixed64\")) ==\n              reflection->MapEnd(message, F(\"map_sfixed64_sfixed64\")));\n  EXPECT_TRUE(reflection->MapBegin(message, F(\"map_int32_float\")) ==\n              reflection->MapEnd(message, F(\"map_int32_float\")));\n  EXPECT_TRUE(reflection->MapBegin(message, F(\"map_int32_double\")) ==\n              reflection->MapEnd(message, F(\"map_int32_double\")));\n  EXPECT_TRUE(reflection->MapBegin(message, F(\"map_bool_bool\")) ==\n              reflection->MapEnd(message, F(\"map_bool_bool\")));\n  EXPECT_TRUE(reflection->MapBegin(message, F(\"map_string_string\")) ==\n              reflection->MapEnd(message, F(\"map_string_string\")));\n  EXPECT_TRUE(reflection->MapBegin(message, F(\"map_int32_bytes\")) ==\n              reflection->MapEnd(message, F(\"map_int32_bytes\")));\n  EXPECT_TRUE(reflection->MapBegin(message, F(\"map_int32_enum\")) ==\n              reflection->MapEnd(message, F(\"map_int32_enum\")));\n  EXPECT_TRUE(reflection->MapBegin(message, F(\"map_int32_foreign_message\")) ==\n              reflection->MapEnd(message, F(\"map_int32_foreign_message\")));\n}\n\nvoid MapReflectionTester::ExpectMapEntryClearViaReflection(\n    Message* message) {\n  const Reflection* reflection = message->GetReflection();\n  const Message* sub_message;\n\n  {\n    const FieldDescriptor* descriptor = F(\"map_int32_int32\");\n    const FieldDescriptor* key_descriptor =\n        descriptor->message_type()->FindFieldByName(\"key\");\n    const FieldDescriptor* value_descriptor =\n        descriptor->message_type()->FindFieldByName(\"value\");\n    sub_message = reflection->AddMessage(message, F(\"map_int32_int32\"));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message,\n                                                        key_descriptor));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message,\n                                                        value_descriptor));\n  }\n  {\n    const FieldDescriptor* descriptor = F(\"map_int64_int64\");\n    const FieldDescriptor* key_descriptor =\n        descriptor->message_type()->FindFieldByName(\"key\");\n    const FieldDescriptor* value_descriptor =\n        descriptor->message_type()->FindFieldByName(\"value\");\n    sub_message = reflection->AddMessage(message, F(\"map_int64_int64\"));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetInt64(*sub_message,\n                                                        key_descriptor));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetInt64(*sub_message,\n                                                        value_descriptor));\n  }\n  {\n    const FieldDescriptor* descriptor = F(\"map_uint32_uint32\");\n    const FieldDescriptor* key_descriptor =\n        descriptor->message_type()->FindFieldByName(\"key\");\n    const FieldDescriptor* value_descriptor =\n        descriptor->message_type()->FindFieldByName(\"value\");\n    sub_message = reflection->AddMessage(message, F(\"map_uint32_uint32\"));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetUInt32(*sub_message,\n                                                         key_descriptor));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetUInt32(*sub_message,\n                                                         value_descriptor));\n  }\n  {\n    const FieldDescriptor* descriptor = F(\"map_uint64_uint64\");\n    const FieldDescriptor* key_descriptor =\n        descriptor->message_type()->FindFieldByName(\"key\");\n    const FieldDescriptor* value_descriptor =\n        descriptor->message_type()->FindFieldByName(\"value\");\n    sub_message = reflection->AddMessage(message, F(\"map_uint64_uint64\"));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetUInt64(*sub_message,\n                                                         key_descriptor));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetUInt64(*sub_message,\n                                                         value_descriptor));\n  }\n  {\n    const FieldDescriptor* descriptor = F(\"map_sint32_sint32\");\n    const FieldDescriptor* key_descriptor =\n        descriptor->message_type()->FindFieldByName(\"key\");\n    const FieldDescriptor* value_descriptor =\n        descriptor->message_type()->FindFieldByName(\"value\");\n    sub_message = reflection->AddMessage(message, F(\"map_sint32_sint32\"));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message,\n                                                        key_descriptor));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message,\n                                                        value_descriptor));\n  }\n  {\n    const FieldDescriptor* descriptor = F(\"map_sint64_sint64\");\n    const FieldDescriptor* key_descriptor =\n        descriptor->message_type()->FindFieldByName(\"key\");\n    const FieldDescriptor* value_descriptor =\n        descriptor->message_type()->FindFieldByName(\"value\");\n    sub_message = reflection->AddMessage(message, F(\"map_sint64_sint64\"));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetInt64(*sub_message,\n                                                        key_descriptor));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetInt64(*sub_message,\n                                                        value_descriptor));\n  }\n  {\n    const FieldDescriptor* descriptor = F(\"map_fixed32_fixed32\");\n    const FieldDescriptor* key_descriptor =\n        descriptor->message_type()->FindFieldByName(\"key\");\n    const FieldDescriptor* value_descriptor =\n        descriptor->message_type()->FindFieldByName(\"value\");\n    sub_message = reflection->AddMessage(message, F(\"map_fixed32_fixed32\"));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetUInt32(*sub_message,\n                                                         key_descriptor));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetUInt32(*sub_message,\n                                                         value_descriptor));\n  }\n  {\n    const FieldDescriptor* descriptor = F(\"map_fixed64_fixed64\");\n    const FieldDescriptor* key_descriptor =\n        descriptor->message_type()->FindFieldByName(\"key\");\n    const FieldDescriptor* value_descriptor =\n        descriptor->message_type()->FindFieldByName(\"value\");\n    sub_message = reflection->AddMessage(message, F(\"map_fixed64_fixed64\"));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetUInt64(*sub_message,\n                                                         key_descriptor));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetUInt64(*sub_message,\n                                                         value_descriptor));\n  }\n  {\n    const FieldDescriptor* descriptor = F(\"map_sfixed32_sfixed32\");\n    const FieldDescriptor* key_descriptor =\n        descriptor->message_type()->FindFieldByName(\"key\");\n    const FieldDescriptor* value_descriptor =\n        descriptor->message_type()->FindFieldByName(\"value\");\n    sub_message = reflection->AddMessage(message, F(\"map_sfixed32_sfixed32\"));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message,\n                                                        key_descriptor));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message,\n                                                        value_descriptor));\n  }\n  {\n    const FieldDescriptor* descriptor = F(\"map_sfixed64_sfixed64\");\n    const FieldDescriptor* key_descriptor =\n        descriptor->message_type()->FindFieldByName(\"key\");\n    const FieldDescriptor* value_descriptor =\n        descriptor->message_type()->FindFieldByName(\"value\");\n    sub_message = reflection->AddMessage(message, F(\"map_sfixed64_sfixed64\"));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetInt64(*sub_message,\n                                                        key_descriptor));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetInt64(*sub_message,\n                                                        value_descriptor));\n  }\n  {\n    const FieldDescriptor* descriptor = F(\"map_int32_float\");\n    const FieldDescriptor* key_descriptor =\n        descriptor->message_type()->FindFieldByName(\"key\");\n    const FieldDescriptor* value_descriptor =\n        descriptor->message_type()->FindFieldByName(\"value\");\n    sub_message = reflection->AddMessage(message, F(\"map_int32_float\"));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message,\n                                                        key_descriptor));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetFloat(*sub_message,\n                                                        value_descriptor));\n  }\n  {\n    const FieldDescriptor* descriptor = F(\"map_int32_double\");\n    const FieldDescriptor* key_descriptor =\n        descriptor->message_type()->FindFieldByName(\"key\");\n    const FieldDescriptor* value_descriptor =\n        descriptor->message_type()->FindFieldByName(\"value\");\n    sub_message = reflection->AddMessage(message, F(\"map_int32_double\"));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message,\n                                                        key_descriptor));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetDouble(*sub_message,\n                                                         value_descriptor));\n  }\n  {\n    const FieldDescriptor* descriptor = F(\"map_bool_bool\");\n    const FieldDescriptor* key_descriptor =\n        descriptor->message_type()->FindFieldByName(\"key\");\n    const FieldDescriptor* value_descriptor =\n        descriptor->message_type()->FindFieldByName(\"value\");\n    sub_message = reflection->AddMessage(message, F(\"map_bool_bool\"));\n    EXPECT_EQ(false, sub_message->GetReflection()->GetBool(*sub_message,\n                                                           key_descriptor));\n    EXPECT_EQ(false, sub_message->GetReflection()->GetBool(*sub_message,\n                                                           value_descriptor));\n  }\n  {\n    const FieldDescriptor* descriptor = F(\"map_string_string\");\n    const FieldDescriptor* key_descriptor =\n        descriptor->message_type()->FindFieldByName(\"key\");\n    const FieldDescriptor* value_descriptor =\n        descriptor->message_type()->FindFieldByName(\"value\");\n    sub_message = reflection->AddMessage(message, F(\"map_string_string\"));\n    EXPECT_EQ(\"\", sub_message->GetReflection()->GetString(*sub_message,\n                                                          key_descriptor));\n    EXPECT_EQ(\"\", sub_message->GetReflection()->GetString(*sub_message,\n                                                          value_descriptor));\n  }\n  {\n    const FieldDescriptor* descriptor = F(\"map_int32_bytes\");\n    const FieldDescriptor* key_descriptor =\n        descriptor->message_type()->FindFieldByName(\"key\");\n    const FieldDescriptor* value_descriptor =\n        descriptor->message_type()->FindFieldByName(\"value\");\n    sub_message = reflection->AddMessage(message, F(\"map_int32_bytes\"));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message,\n                                                        key_descriptor));\n    EXPECT_EQ(\"\", sub_message->GetReflection()->GetString(*sub_message,\n                                                        value_descriptor));\n  }\n  {\n    const FieldDescriptor* descriptor = F(\"map_int32_enum\");\n    const FieldDescriptor* key_descriptor =\n        descriptor->message_type()->FindFieldByName(\"key\");\n    const FieldDescriptor* value_descriptor =\n        descriptor->message_type()->FindFieldByName(\"value\");\n    sub_message = reflection->AddMessage(message, F(\"map_int32_enum\"));\n    EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message,\n                                                        key_descriptor));\n    EXPECT_EQ(0, sub_message->GetReflection()\n                     ->GetEnum(*sub_message, value_descriptor)\n                     ->number());\n  }\n  // Map using message as value has been tested in other place. Thus, we don't\n  // test it here.\n}\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/map_test_util.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_MAP_TEST_UTIL_H__\n#define GOOGLE_PROTOBUF_MAP_TEST_UTIL_H__\n\n#include <google/protobuf/map_unittest.pb.h>\n\nnamespace google {\nnamespace protobuf {\n\nnamespace unittest = ::protobuf_unittest;\n\nclass MapTestUtil {\n public:\n  // Set every field in the TestMap message to a unique value.\n  static void SetMapFields(unittest::TestMap* message);\n\n  // Set every field in the TestArenaMap message to a unique value.\n  static void SetArenaMapFields(unittest::TestArenaMap* message);\n\n  // Set every field in the message to a default value.\n  static void SetMapFieldsInitialized(unittest::TestMap* message);\n\n  // Modify all the map fields of the message (which should already have been\n  // initialized with SetMapFields()).\n  static void ModifyMapFields(unittest::TestMap* message);\n\n  // Check that all fields have the values that they should have after\n  // SetMapFields() is called.\n  static void ExpectMapFieldsSet(const unittest::TestMap& message);\n\n  // Check that all fields have the values that they should have after\n  // SetMapFields() is called for TestArenaMap.\n  static void ExpectArenaMapFieldsSet(const unittest::TestArenaMap& message);\n\n  // Check that all fields have the values that they should have after\n  // SetMapFieldsInitialized() is called.\n  static void ExpectMapFieldsSetInitialized(\n      const unittest::TestMap& message);\n\n  // Expect that the message is modified as would be expected from\n  // ModifyMapFields().\n  static void ExpectMapFieldsModified(const unittest::TestMap& message);\n\n  // Check that all fields are empty.\n  static void ExpectClear(const unittest::TestMap& message);\n\n  // Check that all map fields have the given size.\n  static void ExpectMapsSize(const unittest::TestMap& message, int size);\n\n  // Get pointers of map entries at given index.\n  static std::vector<const Message*> GetMapEntries(\n      const unittest::TestMap& message, int index);\n\n  // Get pointers of map entries from release.\n  static std::vector<const Message*> GetMapEntriesFromRelease(\n      unittest::TestMap* message);\n};\n\n// Like above, but use the reflection interface.\nclass MapReflectionTester {\n public:\n  // base_descriptor must be a descriptor for TestMap, which is used for\n  // MapReflectionTester to fetch the FieldDescriptors needed to use the\n  // reflection interface.\n  explicit MapReflectionTester(const Descriptor* base_descriptor);\n\n  void SetMapFieldsViaReflection(Message* message);\n  void SetMapFieldsViaMapReflection(Message* message);\n  void ClearMapFieldsViaReflection(Message* message);\n  void ModifyMapFieldsViaReflection(Message* message);\n  void RemoveLastMapsViaReflection(Message* message);\n  void ReleaseLastMapsViaReflection(Message* message);\n  void SwapMapsViaReflection(Message* message);\n  void MutableUnknownFieldsOfMapFieldsViaReflection(Message* message);\n  void ExpectMapFieldsSetViaReflection(const Message& message);\n  void ExpectMapFieldsSetViaReflectionIterator(Message* message);\n  void ExpectClearViaReflection(const Message& message);\n  void ExpectClearViaReflectionIterator(Message* message);\n  void ExpectMapEntryClearViaReflection(Message* message);\n\n private:\n  const FieldDescriptor* F(const string& name);\n\n  const Descriptor* base_descriptor_;\n\n  const EnumValueDescriptor* map_enum_bar_;\n  const EnumValueDescriptor* map_enum_baz_;\n  const EnumValueDescriptor* map_enum_foo_;\n\n  const FieldDescriptor* foreign_c_;\n  const FieldDescriptor* map_int32_int32_key_;\n  const FieldDescriptor* map_int32_int32_val_;\n  const FieldDescriptor* map_int64_int64_key_;\n  const FieldDescriptor* map_int64_int64_val_;\n  const FieldDescriptor* map_uint32_uint32_key_;\n  const FieldDescriptor* map_uint32_uint32_val_;\n  const FieldDescriptor* map_uint64_uint64_key_;\n  const FieldDescriptor* map_uint64_uint64_val_;\n  const FieldDescriptor* map_sint32_sint32_key_;\n  const FieldDescriptor* map_sint32_sint32_val_;\n  const FieldDescriptor* map_sint64_sint64_key_;\n  const FieldDescriptor* map_sint64_sint64_val_;\n  const FieldDescriptor* map_fixed32_fixed32_key_;\n  const FieldDescriptor* map_fixed32_fixed32_val_;\n  const FieldDescriptor* map_fixed64_fixed64_key_;\n  const FieldDescriptor* map_fixed64_fixed64_val_;\n  const FieldDescriptor* map_sfixed32_sfixed32_key_;\n  const FieldDescriptor* map_sfixed32_sfixed32_val_;\n  const FieldDescriptor* map_sfixed64_sfixed64_key_;\n  const FieldDescriptor* map_sfixed64_sfixed64_val_;\n  const FieldDescriptor* map_int32_float_key_;\n  const FieldDescriptor* map_int32_float_val_;\n  const FieldDescriptor* map_int32_double_key_;\n  const FieldDescriptor* map_int32_double_val_;\n  const FieldDescriptor* map_bool_bool_key_;\n  const FieldDescriptor* map_bool_bool_val_;\n  const FieldDescriptor* map_string_string_key_;\n  const FieldDescriptor* map_string_string_val_;\n  const FieldDescriptor* map_int32_bytes_key_;\n  const FieldDescriptor* map_int32_bytes_val_;\n  const FieldDescriptor* map_int32_enum_key_;\n  const FieldDescriptor* map_int32_enum_val_;\n  const FieldDescriptor* map_int32_foreign_message_key_;\n  const FieldDescriptor* map_int32_foreign_message_val_;\n};\n\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_MAP_TEST_UTIL_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/map_test_util_impl.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_MAP_TEST_UTIL_IMPL_H__\n#define GOOGLE_PROTOBUF_MAP_TEST_UTIL_IMPL_H__\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n\n\n#define EXPECT_TRUE GOOGLE_CHECK\n#define ASSERT_TRUE GOOGLE_CHECK\n#define EXPECT_FALSE(COND) GOOGLE_CHECK(!(COND))\n#define EXPECT_EQ GOOGLE_CHECK_EQ\n#define ASSERT_EQ GOOGLE_CHECK_EQ\n\nnamespace google {\nnamespace protobuf_unittest {}  // forward declaration\n\nnamespace protobuf {\n\nnamespace unittest = ::protobuf_unittest;\n\nclass MapTestUtilImpl {\n public:\n  // Set every field in the TestMap message to a unique value.\n  template <typename EnumType, EnumType enum_value0,\n            EnumType enum_value1, typename MapMessage>\n  static void SetMapFields(MapMessage* message);\n\n  // Set every field in the TestArenaMap message to a unique value.\n  template <typename EnumType, EnumType enum_value0,\n            EnumType enum_value1, typename MapMessage>\n  static void SetArenaMapFields(MapMessage* message);\n\n  // Set every field in the message to a default value.\n  template <typename MapMessage>\n  static void SetMapFieldsInitialized(MapMessage* message);\n\n  // Modify all the map fields of the message (which should already have been\n  // initialized with SetMapFields()).\n  template <typename EnumType, EnumType enum_value, typename MapMessage>\n  static void ModifyMapFields(MapMessage* message);\n\n  // Check that all fields have the values that they should have after\n  // SetMapFields() is called.\n  template <typename EnumType, EnumType enum_value0,\n            EnumType enum_value1, typename MapMessage>\n  static void ExpectMapFieldsSet(const MapMessage& message);\n\n  // Check that all fields have the values that they should have after\n  // SetMapFields() is called for TestArenaMap.\n  template <typename EnumType, EnumType enum_value0,\n            EnumType enum_value1, typename MapMessage>\n  static void ExpectArenaMapFieldsSet(const MapMessage& message);\n\n  // Check that all fields have the values that they should have after\n  // SetMapFieldsInitialized() is called.\n  template <typename EnumType, EnumType enum_value, typename MapMessage>\n  static void ExpectMapFieldsSetInitialized(const MapMessage& message);\n\n  // Expect that the message is modified as would be expected from\n  // ModifyMapFields().\n  template <typename EnumType, EnumType enum_value0,\n            EnumType enum_value1, typename MapMessage>\n  static void ExpectMapFieldsModified(const MapMessage& message);\n\n  // Check that all fields are empty.\n  template <typename MapMessage>\n  static void ExpectClear(const MapMessage& message);\n\n  // // Check that all map fields have the given size.\n  // template <typename MapMessage>\n  // static void ExpectMapsSize(const MapMessage& message, int size);\n\n  // // Get pointers of map entries at given index.\n  // static std::vector<const Message*> GetMapEntries(\n  //     const MapMessage& message, int index);\n\n  // // Get pointers of map entries from release.\n  // static std::vector<const Message*> GetMapEntriesFromRelease(\n  //     MapMessage* message);\n};\n\ntemplate <typename EnumType, EnumType enum_value0,\n          EnumType enum_value1, typename MapMessage>\nvoid MapTestUtilImpl::SetMapFields(MapMessage* message) {\n  // Add first element.\n  (*message->mutable_map_int32_int32())[0] = 0;\n  (*message->mutable_map_int64_int64())[0] = 0;\n  (*message->mutable_map_uint32_uint32())[0] = 0;\n  (*message->mutable_map_uint64_uint64())[0] = 0;\n  (*message->mutable_map_sint32_sint32())[0] = 0;\n  (*message->mutable_map_sint64_sint64())[0] = 0;\n  (*message->mutable_map_fixed32_fixed32())[0] = 0;\n  (*message->mutable_map_fixed64_fixed64())[0] = 0;\n  (*message->mutable_map_sfixed32_sfixed32())[0] = 0;\n  (*message->mutable_map_sfixed64_sfixed64())[0] = 0;\n  (*message->mutable_map_int32_float())[0] = 0.0;\n  (*message->mutable_map_int32_double())[0] = 0.0;\n  (*message->mutable_map_bool_bool())[0] = false;\n  (*message->mutable_map_string_string())[\"0\"] = \"0\";\n  (*message->mutable_map_int32_bytes())[0] = \"0\";\n  (*message->mutable_map_int32_enum())[0] = enum_value0;\n  (*message->mutable_map_int32_foreign_message())[0].set_c(0);\n\n  // Add second element\n  (*message->mutable_map_int32_int32())[1] = 1;\n  (*message->mutable_map_int64_int64())[1] = 1;\n  (*message->mutable_map_uint32_uint32())[1] = 1;\n  (*message->mutable_map_uint64_uint64())[1] = 1;\n  (*message->mutable_map_sint32_sint32())[1] = 1;\n  (*message->mutable_map_sint64_sint64())[1] = 1;\n  (*message->mutable_map_fixed32_fixed32())[1] = 1;\n  (*message->mutable_map_fixed64_fixed64())[1] = 1;\n  (*message->mutable_map_sfixed32_sfixed32())[1] = 1;\n  (*message->mutable_map_sfixed64_sfixed64())[1] = 1;\n  (*message->mutable_map_int32_float())[1] = 1.0;\n  (*message->mutable_map_int32_double())[1] = 1.0;\n  (*message->mutable_map_bool_bool())[1] = true;\n  (*message->mutable_map_string_string())[\"1\"] = \"1\";\n  (*message->mutable_map_int32_bytes())[1] = \"1\";\n  (*message->mutable_map_int32_enum())[1] = enum_value1;\n  (*message->mutable_map_int32_foreign_message())[1].set_c(1);\n}\n\ntemplate <typename EnumType, EnumType enum_value0,\n          EnumType enum_value1, typename MapMessage>\nvoid MapTestUtilImpl::SetArenaMapFields(MapMessage* message) {\n  // Add first element.\n  (*message->mutable_map_int32_int32())[0] = 0;\n  (*message->mutable_map_int64_int64())[0] = 0;\n  (*message->mutable_map_uint32_uint32())[0] = 0;\n  (*message->mutable_map_uint64_uint64())[0] = 0;\n  (*message->mutable_map_sint32_sint32())[0] = 0;\n  (*message->mutable_map_sint64_sint64())[0] = 0;\n  (*message->mutable_map_fixed32_fixed32())[0] = 0;\n  (*message->mutable_map_fixed64_fixed64())[0] = 0;\n  (*message->mutable_map_sfixed32_sfixed32())[0] = 0;\n  (*message->mutable_map_sfixed64_sfixed64())[0] = 0;\n  (*message->mutable_map_int32_float())[0] = 0.0;\n  (*message->mutable_map_int32_double())[0] = 0.0;\n  (*message->mutable_map_bool_bool())[0] = false;\n  (*message->mutable_map_string_string())[\"0\"] = \"0\";\n  (*message->mutable_map_int32_bytes())[0] = \"0\";\n  (*message->mutable_map_int32_enum())[0] = enum_value0;\n  (*message->mutable_map_int32_foreign_message())[0].set_c(0);\n  (*message->mutable_map_int32_foreign_message_no_arena())[0].set_c(0);\n\n  // Add second element\n  (*message->mutable_map_int32_int32())[1] = 1;\n  (*message->mutable_map_int64_int64())[1] = 1;\n  (*message->mutable_map_uint32_uint32())[1] = 1;\n  (*message->mutable_map_uint64_uint64())[1] = 1;\n  (*message->mutable_map_sint32_sint32())[1] = 1;\n  (*message->mutable_map_sint64_sint64())[1] = 1;\n  (*message->mutable_map_fixed32_fixed32())[1] = 1;\n  (*message->mutable_map_fixed64_fixed64())[1] = 1;\n  (*message->mutable_map_sfixed32_sfixed32())[1] = 1;\n  (*message->mutable_map_sfixed64_sfixed64())[1] = 1;\n  (*message->mutable_map_int32_float())[1] = 1.0;\n  (*message->mutable_map_int32_double())[1] = 1.0;\n  (*message->mutable_map_bool_bool())[1] = true;\n  (*message->mutable_map_string_string())[\"1\"] = \"1\";\n  (*message->mutable_map_int32_bytes())[1] = \"1\";\n  (*message->mutable_map_int32_enum())[1] = enum_value1;\n  (*message->mutable_map_int32_foreign_message())[1].set_c(1);\n  (*message->mutable_map_int32_foreign_message_no_arena())[1].set_c(1);\n}\n\ntemplate <typename MapMessage>\nvoid MapTestUtilImpl::SetMapFieldsInitialized(MapMessage* message) {\n  // Add first element using bracket operator, which should assign default\n  // value automatically.\n  (*message->mutable_map_int32_int32())[0];\n  (*message->mutable_map_int64_int64())[0];\n  (*message->mutable_map_uint32_uint32())[0];\n  (*message->mutable_map_uint64_uint64())[0];\n  (*message->mutable_map_sint32_sint32())[0];\n  (*message->mutable_map_sint64_sint64())[0];\n  (*message->mutable_map_fixed32_fixed32())[0];\n  (*message->mutable_map_fixed64_fixed64())[0];\n  (*message->mutable_map_sfixed32_sfixed32())[0];\n  (*message->mutable_map_sfixed64_sfixed64())[0];\n  (*message->mutable_map_int32_float())[0];\n  (*message->mutable_map_int32_double())[0];\n  (*message->mutable_map_bool_bool())[0];\n  (*message->mutable_map_string_string())[\"0\"];\n  (*message->mutable_map_int32_bytes())[0];\n  (*message->mutable_map_int32_enum())[0];\n  (*message->mutable_map_int32_foreign_message())[0];\n}\n\ntemplate <typename EnumType, EnumType enum_value, typename MapMessage>\nvoid MapTestUtilImpl::ModifyMapFields(MapMessage* message) {\n  (*message->mutable_map_int32_int32())[1] = 2;\n  (*message->mutable_map_int64_int64())[1] = 2;\n  (*message->mutable_map_uint32_uint32())[1] = 2;\n  (*message->mutable_map_uint64_uint64())[1] = 2;\n  (*message->mutable_map_sint32_sint32())[1] = 2;\n  (*message->mutable_map_sint64_sint64())[1] = 2;\n  (*message->mutable_map_fixed32_fixed32())[1] = 2;\n  (*message->mutable_map_fixed64_fixed64())[1] = 2;\n  (*message->mutable_map_sfixed32_sfixed32())[1] = 2;\n  (*message->mutable_map_sfixed64_sfixed64())[1] = 2;\n  (*message->mutable_map_int32_float())[1] = 2.0;\n  (*message->mutable_map_int32_double())[1] = 2.0;\n  (*message->mutable_map_bool_bool())[1] = false;\n  (*message->mutable_map_string_string())[\"1\"] = \"2\";\n  (*message->mutable_map_int32_bytes())[1] = \"2\";\n  (*message->mutable_map_int32_enum())[1] = enum_value;\n  (*message->mutable_map_int32_foreign_message())[1].set_c(2);\n}\n\ntemplate <typename MapMessage>\nvoid MapTestUtilImpl::ExpectClear(const MapMessage& message) {\n  EXPECT_EQ(0, message.map_int32_int32().size());\n  EXPECT_EQ(0, message.map_int64_int64().size());\n  EXPECT_EQ(0, message.map_uint32_uint32().size());\n  EXPECT_EQ(0, message.map_uint64_uint64().size());\n  EXPECT_EQ(0, message.map_sint32_sint32().size());\n  EXPECT_EQ(0, message.map_sint64_sint64().size());\n  EXPECT_EQ(0, message.map_fixed32_fixed32().size());\n  EXPECT_EQ(0, message.map_fixed64_fixed64().size());\n  EXPECT_EQ(0, message.map_sfixed32_sfixed32().size());\n  EXPECT_EQ(0, message.map_sfixed64_sfixed64().size());\n  EXPECT_EQ(0, message.map_int32_float().size());\n  EXPECT_EQ(0, message.map_int32_double().size());\n  EXPECT_EQ(0, message.map_bool_bool().size());\n  EXPECT_EQ(0, message.map_string_string().size());\n  EXPECT_EQ(0, message.map_int32_bytes().size());\n  EXPECT_EQ(0, message.map_int32_enum().size());\n  EXPECT_EQ(0, message.map_int32_foreign_message().size());\n}\n\n\n\ntemplate <typename EnumType, EnumType enum_value0,\n          EnumType enum_value1, typename MapMessage>\nvoid MapTestUtilImpl::ExpectMapFieldsSet(const MapMessage& message) {\n  EXPECT_EQ(2, message.map_int32_int32().size());\n  EXPECT_EQ(2, message.map_int64_int64().size());\n  EXPECT_EQ(2, message.map_uint32_uint32().size());\n  EXPECT_EQ(2, message.map_uint64_uint64().size());\n  EXPECT_EQ(2, message.map_sint32_sint32().size());\n  EXPECT_EQ(2, message.map_sint64_sint64().size());\n  EXPECT_EQ(2, message.map_fixed32_fixed32().size());\n  EXPECT_EQ(2, message.map_fixed64_fixed64().size());\n  EXPECT_EQ(2, message.map_sfixed32_sfixed32().size());\n  EXPECT_EQ(2, message.map_sfixed64_sfixed64().size());\n  EXPECT_EQ(2, message.map_int32_float().size());\n  EXPECT_EQ(2, message.map_int32_double().size());\n  EXPECT_EQ(2, message.map_bool_bool().size());\n  EXPECT_EQ(2, message.map_string_string().size());\n  EXPECT_EQ(2, message.map_int32_bytes().size());\n  EXPECT_EQ(2, message.map_int32_enum().size());\n  EXPECT_EQ(2, message.map_int32_foreign_message().size());\n\n  EXPECT_EQ(0, message.map_int32_int32().at(0));\n  EXPECT_EQ(0, message.map_int64_int64().at(0));\n  EXPECT_EQ(0, message.map_uint32_uint32().at(0));\n  EXPECT_EQ(0, message.map_uint64_uint64().at(0));\n  EXPECT_EQ(0, message.map_sint32_sint32().at(0));\n  EXPECT_EQ(0, message.map_sint64_sint64().at(0));\n  EXPECT_EQ(0, message.map_fixed32_fixed32().at(0));\n  EXPECT_EQ(0, message.map_fixed64_fixed64().at(0));\n  EXPECT_EQ(0, message.map_sfixed32_sfixed32().at(0));\n  EXPECT_EQ(0, message.map_sfixed64_sfixed64().at(0));\n  EXPECT_EQ(0, message.map_int32_float().at(0));\n  EXPECT_EQ(0, message.map_int32_double().at(0));\n  EXPECT_EQ(false, message.map_bool_bool().at(0));\n  EXPECT_EQ(\"0\", message.map_string_string().at(\"0\"));\n  EXPECT_EQ(\"0\", message.map_int32_bytes().at(0));\n  EXPECT_EQ(enum_value0, message.map_int32_enum().at(0));\n  EXPECT_EQ(0, message.map_int32_foreign_message().at(0).c());\n\n  EXPECT_EQ(1, message.map_int32_int32().at(1));\n  EXPECT_EQ(1, message.map_int64_int64().at(1));\n  EXPECT_EQ(1, message.map_uint32_uint32().at(1));\n  EXPECT_EQ(1, message.map_uint64_uint64().at(1));\n  EXPECT_EQ(1, message.map_sint32_sint32().at(1));\n  EXPECT_EQ(1, message.map_sint64_sint64().at(1));\n  EXPECT_EQ(1, message.map_fixed32_fixed32().at(1));\n  EXPECT_EQ(1, message.map_fixed64_fixed64().at(1));\n  EXPECT_EQ(1, message.map_sfixed32_sfixed32().at(1));\n  EXPECT_EQ(1, message.map_sfixed64_sfixed64().at(1));\n  EXPECT_EQ(1, message.map_int32_float().at(1));\n  EXPECT_EQ(1, message.map_int32_double().at(1));\n  EXPECT_EQ(true, message.map_bool_bool().at(1));\n  EXPECT_EQ(\"1\", message.map_string_string().at(\"1\"));\n  EXPECT_EQ(\"1\", message.map_int32_bytes().at(1));\n  EXPECT_EQ(enum_value1, message.map_int32_enum().at(1));\n  EXPECT_EQ(1, message.map_int32_foreign_message().at(1).c());\n}\n\ntemplate <typename EnumType, EnumType enum_value0,\n          EnumType enum_value1, typename MapMessage>\nvoid MapTestUtilImpl::ExpectArenaMapFieldsSet(const MapMessage& message) {\n  EXPECT_EQ(2, message.map_int32_int32().size());\n  EXPECT_EQ(2, message.map_int64_int64().size());\n  EXPECT_EQ(2, message.map_uint32_uint32().size());\n  EXPECT_EQ(2, message.map_uint64_uint64().size());\n  EXPECT_EQ(2, message.map_sint32_sint32().size());\n  EXPECT_EQ(2, message.map_sint64_sint64().size());\n  EXPECT_EQ(2, message.map_fixed32_fixed32().size());\n  EXPECT_EQ(2, message.map_fixed64_fixed64().size());\n  EXPECT_EQ(2, message.map_sfixed32_sfixed32().size());\n  EXPECT_EQ(2, message.map_sfixed64_sfixed64().size());\n  EXPECT_EQ(2, message.map_int32_float().size());\n  EXPECT_EQ(2, message.map_int32_double().size());\n  EXPECT_EQ(2, message.map_bool_bool().size());\n  EXPECT_EQ(2, message.map_string_string().size());\n  EXPECT_EQ(2, message.map_int32_bytes().size());\n  EXPECT_EQ(2, message.map_int32_enum().size());\n  EXPECT_EQ(2, message.map_int32_foreign_message().size());\n  EXPECT_EQ(2, message.map_int32_foreign_message_no_arena().size());\n\n  EXPECT_EQ(0, message.map_int32_int32().at(0));\n  EXPECT_EQ(0, message.map_int64_int64().at(0));\n  EXPECT_EQ(0, message.map_uint32_uint32().at(0));\n  EXPECT_EQ(0, message.map_uint64_uint64().at(0));\n  EXPECT_EQ(0, message.map_sint32_sint32().at(0));\n  EXPECT_EQ(0, message.map_sint64_sint64().at(0));\n  EXPECT_EQ(0, message.map_fixed32_fixed32().at(0));\n  EXPECT_EQ(0, message.map_fixed64_fixed64().at(0));\n  EXPECT_EQ(0, message.map_sfixed32_sfixed32().at(0));\n  EXPECT_EQ(0, message.map_sfixed64_sfixed64().at(0));\n  EXPECT_EQ(0, message.map_int32_float().at(0));\n  EXPECT_EQ(0, message.map_int32_double().at(0));\n  EXPECT_EQ(false, message.map_bool_bool().at(0));\n  EXPECT_EQ(\"0\", message.map_string_string().at(\"0\"));\n  EXPECT_EQ(\"0\", message.map_int32_bytes().at(0));\n  EXPECT_EQ(enum_value0, message.map_int32_enum().at(0));\n  EXPECT_EQ(0, message.map_int32_foreign_message().at(0).c());\n  EXPECT_EQ(0, message.map_int32_foreign_message_no_arena().at(0).c());\n\n  EXPECT_EQ(1, message.map_int32_int32().at(1));\n  EXPECT_EQ(1, message.map_int64_int64().at(1));\n  EXPECT_EQ(1, message.map_uint32_uint32().at(1));\n  EXPECT_EQ(1, message.map_uint64_uint64().at(1));\n  EXPECT_EQ(1, message.map_sint32_sint32().at(1));\n  EXPECT_EQ(1, message.map_sint64_sint64().at(1));\n  EXPECT_EQ(1, message.map_fixed32_fixed32().at(1));\n  EXPECT_EQ(1, message.map_fixed64_fixed64().at(1));\n  EXPECT_EQ(1, message.map_sfixed32_sfixed32().at(1));\n  EXPECT_EQ(1, message.map_sfixed64_sfixed64().at(1));\n  EXPECT_EQ(1, message.map_int32_float().at(1));\n  EXPECT_EQ(1, message.map_int32_double().at(1));\n  EXPECT_EQ(true, message.map_bool_bool().at(1));\n  EXPECT_EQ(\"1\", message.map_string_string().at(\"1\"));\n  EXPECT_EQ(\"1\", message.map_int32_bytes().at(1));\n  EXPECT_EQ(enum_value1, message.map_int32_enum().at(1));\n  EXPECT_EQ(1, message.map_int32_foreign_message().at(1).c());\n  EXPECT_EQ(1, message.map_int32_foreign_message_no_arena().at(1).c());\n}\n\ntemplate <typename EnumType, EnumType enum_value, typename MapMessage>\nvoid MapTestUtilImpl::ExpectMapFieldsSetInitialized(\n    const MapMessage& message) {\n  EXPECT_EQ(1, message.map_int32_int32().size());\n  EXPECT_EQ(1, message.map_int64_int64().size());\n  EXPECT_EQ(1, message.map_uint32_uint32().size());\n  EXPECT_EQ(1, message.map_uint64_uint64().size());\n  EXPECT_EQ(1, message.map_sint32_sint32().size());\n  EXPECT_EQ(1, message.map_sint64_sint64().size());\n  EXPECT_EQ(1, message.map_fixed32_fixed32().size());\n  EXPECT_EQ(1, message.map_fixed64_fixed64().size());\n  EXPECT_EQ(1, message.map_sfixed32_sfixed32().size());\n  EXPECT_EQ(1, message.map_sfixed64_sfixed64().size());\n  EXPECT_EQ(1, message.map_int32_float().size());\n  EXPECT_EQ(1, message.map_int32_double().size());\n  EXPECT_EQ(1, message.map_bool_bool().size());\n  EXPECT_EQ(1, message.map_string_string().size());\n  EXPECT_EQ(1, message.map_int32_bytes().size());\n  EXPECT_EQ(1, message.map_int32_enum().size());\n  EXPECT_EQ(1, message.map_int32_foreign_message().size());\n\n  EXPECT_EQ(0, message.map_int32_int32().at(0));\n  EXPECT_EQ(0, message.map_int64_int64().at(0));\n  EXPECT_EQ(0, message.map_uint32_uint32().at(0));\n  EXPECT_EQ(0, message.map_uint64_uint64().at(0));\n  EXPECT_EQ(0, message.map_sint32_sint32().at(0));\n  EXPECT_EQ(0, message.map_sint64_sint64().at(0));\n  EXPECT_EQ(0, message.map_fixed32_fixed32().at(0));\n  EXPECT_EQ(0, message.map_fixed64_fixed64().at(0));\n  EXPECT_EQ(0, message.map_sfixed32_sfixed32().at(0));\n  EXPECT_EQ(0, message.map_sfixed64_sfixed64().at(0));\n  EXPECT_EQ(0, message.map_int32_float().at(0));\n  EXPECT_EQ(0, message.map_int32_double().at(0));\n  EXPECT_EQ(false, message.map_bool_bool().at(0));\n  EXPECT_EQ(\"\", message.map_string_string().at(\"0\"));\n  EXPECT_EQ(\"\", message.map_int32_bytes().at(0));\n  EXPECT_EQ(enum_value, message.map_int32_enum().at(0));\n  EXPECT_EQ(0, message.map_int32_foreign_message().at(0).ByteSize());\n}\n\ntemplate <typename EnumType, EnumType enum_value0,\n            EnumType enum_value1, typename MapMessage>\nvoid MapTestUtilImpl::ExpectMapFieldsModified(\n    const MapMessage& message) {\n  // ModifyMapFields only sets the second element of each field.  In addition to\n  // verifying this, we also verify that the first element and size were *not*\n  // modified.\n  EXPECT_EQ(2, message.map_int32_int32().size());\n  EXPECT_EQ(2, message.map_int64_int64().size());\n  EXPECT_EQ(2, message.map_uint32_uint32().size());\n  EXPECT_EQ(2, message.map_uint64_uint64().size());\n  EXPECT_EQ(2, message.map_sint32_sint32().size());\n  EXPECT_EQ(2, message.map_sint64_sint64().size());\n  EXPECT_EQ(2, message.map_fixed32_fixed32().size());\n  EXPECT_EQ(2, message.map_fixed64_fixed64().size());\n  EXPECT_EQ(2, message.map_sfixed32_sfixed32().size());\n  EXPECT_EQ(2, message.map_sfixed64_sfixed64().size());\n  EXPECT_EQ(2, message.map_int32_float().size());\n  EXPECT_EQ(2, message.map_int32_double().size());\n  EXPECT_EQ(2, message.map_bool_bool().size());\n  EXPECT_EQ(2, message.map_string_string().size());\n  EXPECT_EQ(2, message.map_int32_bytes().size());\n  EXPECT_EQ(2, message.map_int32_enum().size());\n  EXPECT_EQ(2, message.map_int32_foreign_message().size());\n\n  EXPECT_EQ(0, message.map_int32_int32().at(0));\n  EXPECT_EQ(0, message.map_int64_int64().at(0));\n  EXPECT_EQ(0, message.map_uint32_uint32().at(0));\n  EXPECT_EQ(0, message.map_uint64_uint64().at(0));\n  EXPECT_EQ(0, message.map_sint32_sint32().at(0));\n  EXPECT_EQ(0, message.map_sint64_sint64().at(0));\n  EXPECT_EQ(0, message.map_fixed32_fixed32().at(0));\n  EXPECT_EQ(0, message.map_fixed64_fixed64().at(0));\n  EXPECT_EQ(0, message.map_sfixed32_sfixed32().at(0));\n  EXPECT_EQ(0, message.map_sfixed64_sfixed64().at(0));\n  EXPECT_EQ(0, message.map_int32_float().at(0));\n  EXPECT_EQ(0, message.map_int32_double().at(0));\n  EXPECT_EQ(false, message.map_bool_bool().at(0));\n  EXPECT_EQ(\"0\", message.map_string_string().at(\"0\"));\n  EXPECT_EQ(\"0\", message.map_int32_bytes().at(0));\n  EXPECT_EQ(enum_value0, message.map_int32_enum().at(0));\n  EXPECT_EQ(0, message.map_int32_foreign_message().at(0).c());\n\n  // Actually verify the second (modified) elements now.\n  EXPECT_EQ(2, message.map_int32_int32().at(1));\n  EXPECT_EQ(2, message.map_int64_int64().at(1));\n  EXPECT_EQ(2, message.map_uint32_uint32().at(1));\n  EXPECT_EQ(2, message.map_uint64_uint64().at(1));\n  EXPECT_EQ(2, message.map_sint32_sint32().at(1));\n  EXPECT_EQ(2, message.map_sint64_sint64().at(1));\n  EXPECT_EQ(2, message.map_fixed32_fixed32().at(1));\n  EXPECT_EQ(2, message.map_fixed64_fixed64().at(1));\n  EXPECT_EQ(2, message.map_sfixed32_sfixed32().at(1));\n  EXPECT_EQ(2, message.map_sfixed64_sfixed64().at(1));\n  EXPECT_EQ(2, message.map_int32_float().at(1));\n  EXPECT_EQ(2, message.map_int32_double().at(1));\n  EXPECT_EQ(false, message.map_bool_bool().at(1));\n  EXPECT_EQ(\"2\", message.map_string_string().at(\"1\"));\n  EXPECT_EQ(\"2\", message.map_int32_bytes().at(1));\n  EXPECT_EQ(enum_value1, message.map_int32_enum().at(1));\n  EXPECT_EQ(2, message.map_int32_foreign_message().at(1).c());\n}\n\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_MAP_TEST_UTIL_IMPL_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/map_type_handler.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_TYPE_HANDLER_H__\n#define GOOGLE_PROTOBUF_TYPE_HANDLER_H__\n\n#include <google/protobuf/arena.h>\n#include <google/protobuf/generated_message_util.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\n// Used for compile time type selection. MapIf::type will be TrueType if Flag is\n// true and FalseType otherwise.\ntemplate<bool Flag, typename TrueType, typename FalseType>\nstruct MapIf;\n\ntemplate<typename TrueType, typename FalseType>\nstruct MapIf<true, TrueType, FalseType> {\n  typedef TrueType type;\n};\n\ntemplate<typename TrueType, typename FalseType>\nstruct MapIf<false, TrueType, FalseType> {\n  typedef FalseType type;\n};\n\n// In proto2 Map, enum needs to be initialized to given default value, while\n// other types' default value can be inferred from the type.\ntemplate <bool IsEnum, typename Type>\nclass MapValueInitializer {\n public:\n  static inline void Initialize(Type& type, int default_enum_value);\n};\n\ntemplate <typename Type>\nclass MapValueInitializer<true, Type> {\n public:\n  static inline void Initialize(Type& value, int default_enum_value) {\n    value = static_cast<Type>(default_enum_value);\n  }\n};\n\ntemplate <typename Type>\nclass MapValueInitializer<false, Type> {\n public:\n  static inline void Initialize(Type& value, int default_enum_value) {}\n};\n\ntemplate <typename Type, bool is_arena_constructable>\nclass MapArenaMessageCreator {\n public:\n  // Use arena to create message if Type is arena constructable. Otherwise,\n  // create the message on heap.\n  static inline Type* CreateMessage(Arena* arena);\n};\ntemplate <typename Type>\nclass MapArenaMessageCreator<Type, true> {\n public:\n  static inline Type* CreateMessage(Arena* arena) {\n    return Arena::CreateMessage<Type>(arena);\n  }\n};\ntemplate <typename Type>\nclass MapArenaMessageCreator<Type, false> {\n public:\n  static inline Type* CreateMessage(Arena* arena) {\n    return Arena::Create<Type>(arena);\n  }\n};\n\n// Define constants for given wire field type\ntemplate <WireFormatLite::FieldType field_type, typename Type>\nclass MapWireFieldTypeTraits {};\n\n#define TYPE_TRAITS(FieldType, CType, WireFormatType, IsMessage, IsEnum)   \\\n  template <typename Type>                                                 \\\n  class MapWireFieldTypeTraits<WireFormatLite::TYPE_##FieldType, Type> {   \\\n   public:                                                                 \\\n    static const bool kIsMessage = IsMessage;                              \\\n    static const bool kIsEnum = IsEnum;                                    \\\n    typedef typename MapIf<kIsMessage, Type*, CType>::type TypeOnMemory;   \\\n    typedef typename MapIf<kIsEnum, int, Type>::type MapEntryAccessorType; \\\n    static const WireFormatLite::WireType kWireType =                      \\\n        WireFormatLite::WIRETYPE_##WireFormatType;                         \\\n  };\n\nTYPE_TRAITS(MESSAGE , Type, LENGTH_DELIMITED, true, false)\nTYPE_TRAITS(STRING  , ArenaStringPtr, LENGTH_DELIMITED, false, false)\nTYPE_TRAITS(BYTES   , ArenaStringPtr ,  LENGTH_DELIMITED, false, false)\nTYPE_TRAITS(INT64   , int64  ,  VARINT , false, false)\nTYPE_TRAITS(UINT64  , uint64 ,  VARINT , false, false)\nTYPE_TRAITS(INT32   , int32  ,  VARINT , false, false)\nTYPE_TRAITS(UINT32  , uint32 ,  VARINT , false, false)\nTYPE_TRAITS(SINT64  , int64  ,  VARINT , false, false)\nTYPE_TRAITS(SINT32  , int32  ,  VARINT , false, false)\nTYPE_TRAITS(ENUM    , int    ,  VARINT , false, true )\nTYPE_TRAITS(DOUBLE  , double ,  FIXED64, false, false)\nTYPE_TRAITS(FLOAT   , float  ,  FIXED32, false, false)\nTYPE_TRAITS(FIXED64 , uint64 ,  FIXED64, false, false)\nTYPE_TRAITS(FIXED32 , uint32 ,  FIXED32, false, false)\nTYPE_TRAITS(SFIXED64, int64  ,  FIXED64, false, false)\nTYPE_TRAITS(SFIXED32, int32  ,  FIXED32, false, false)\nTYPE_TRAITS(BOOL    , bool   ,  VARINT , false, false)\n\n#undef TYPE_TRAITS\n\ntemplate <WireFormatLite::FieldType field_type, typename Type>\nclass MapTypeHandler {};\n\ntemplate <typename Type>\nclass MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type> {\n public:\n  // Enum type cannot be used for MapTypeHandler::Read. Define a type which will\n  // replace Enum with int.\n  typedef typename MapWireFieldTypeTraits<WireFormatLite::TYPE_MESSAGE,\n      Type>::MapEntryAccessorType MapEntryAccessorType;\n  // Internal stored type in MapEntryLite for given wire field type.\n  typedef typename MapWireFieldTypeTraits<WireFormatLite::TYPE_MESSAGE,\n                                          Type>::TypeOnMemory TypeOnMemory;\n  // Corresponding wire type for field type.\n  static const WireFormatLite::WireType kWireType =\n      MapWireFieldTypeTraits<WireFormatLite::TYPE_MESSAGE, Type>::kWireType;\n  // Whether wire type is for message.\n  static const bool kIsMessage =\n      MapWireFieldTypeTraits<WireFormatLite::TYPE_MESSAGE, Type>::kIsMessage;\n  // Whether wire type is for enum.\n  static const bool kIsEnum =\n      MapWireFieldTypeTraits<WireFormatLite::TYPE_MESSAGE, Type>::kIsEnum;\n\n  // Functions used in parsing and serialization. ===================\n  static inline int ByteSize(const MapEntryAccessorType& value);\n  static inline int GetCachedSize(const MapEntryAccessorType& value);\n  static inline bool Read(io::CodedInputStream* input,\n                          MapEntryAccessorType* value);\n  static inline void Write(int field, const MapEntryAccessorType& value,\n                           io::CodedOutputStream* output);\n  static inline uint8* InternalWriteToArray(int field,\n                                            const MapEntryAccessorType& value,\n                                            bool deterministic, uint8* target);\n  static inline uint8* WriteToArray(int field,\n                                    const MapEntryAccessorType& value,\n                                    uint8* target);\n\n  // Functions to manipulate data on memory. ========================\n  static inline const Type& GetExternalReference(const Type* value);\n  static inline void DeleteNoArena(const Type* x);\n  static inline void Merge(const Type& from, Type** to, Arena* arena);\n  static inline void Clear(Type** value, Arena* arena);\n  static inline void ClearMaybeByDefaultEnum(Type** value, Arena* arena,\n                                             int default_enum_value);\n  static inline void Initialize(Type** x, Arena* arena);\n\n  static inline void InitializeMaybeByDefaultEnum(Type** x,\n                                                  int default_enum_value,\n                                                  Arena* arena);\n  static inline Type* EnsureMutable(Type** value, Arena* arena);\n  // SpaceUsedInMapEntry: Return bytes used by value in MapEntry, excluding\n  // those already calculate in sizeof(MapField).\n  static inline int SpaceUsedInMapEntry(const Type* value);\n  // Return bytes used by value in Map.\n  static inline int SpaceUsedInMap(const Type& value);\n  // Assign default value to given instance.\n  static inline void AssignDefaultValue(Type** value);\n  // Return default instance if value is not initialized when calling const\n  // reference accessor.\n  static inline const Type& DefaultIfNotInitialized(\n      const Type* value, const Type* default_value);\n  // Check if all required fields have values set.\n  static inline bool IsInitialized(Type* value);\n};\n\n#define MAP_HANDLER(FieldType)                                                \\\n  template <typename Type>                                                    \\\n  class MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type> {              \\\n   public:                                                                    \\\n    typedef typename MapWireFieldTypeTraits<WireFormatLite::TYPE_##FieldType, \\\n                                            Type>::MapEntryAccessorType       \\\n        MapEntryAccessorType;                                                 \\\n    typedef typename MapWireFieldTypeTraits<WireFormatLite::TYPE_##FieldType, \\\n                                            Type>::TypeOnMemory TypeOnMemory; \\\n    static const WireFormatLite::WireType kWireType =                         \\\n        MapWireFieldTypeTraits<WireFormatLite::TYPE_##FieldType,              \\\n                               Type>::kWireType;                              \\\n    static const bool kIsMessage =                                            \\\n        MapWireFieldTypeTraits<WireFormatLite::TYPE_##FieldType,              \\\n                               Type>::kIsMessage;                             \\\n    static const bool kIsEnum =                                               \\\n        MapWireFieldTypeTraits<WireFormatLite::TYPE_##FieldType,              \\\n                               Type>::kIsEnum;                                \\\n    static inline int ByteSize(const MapEntryAccessorType& value);            \\\n    static inline int GetCachedSize(const MapEntryAccessorType& value);       \\\n    static inline bool Read(io::CodedInputStream* input,                      \\\n                            MapEntryAccessorType* value);                     \\\n    static inline void Write(int field, const MapEntryAccessorType& value,    \\\n                             io::CodedOutputStream* output);                  \\\n    static inline uint8* InternalWriteToArray(                                \\\n        int field,                                                            \\\n        const MapEntryAccessorType& value,                                    \\\n        bool deterministic,                                                   \\\n        uint8* target);                                                       \\\n    static inline uint8* WriteToArray(int field,                              \\\n                                      const MapEntryAccessorType& value,      \\\n                                      uint8* target) {                        \\\n      return InternalWriteToArray(field, value, false, target);               \\\n    }                                                                         \\\n    static inline const MapEntryAccessorType& GetExternalReference(           \\\n        const TypeOnMemory& value);                                           \\\n    static inline void DeleteNoArena(const TypeOnMemory& x);                  \\\n    static inline void Merge(const MapEntryAccessorType& from,                \\\n                             TypeOnMemory* to, Arena* arena);                 \\\n    static inline void Clear(TypeOnMemory* value, Arena* arena);              \\\n    static inline void ClearMaybeByDefaultEnum(TypeOnMemory* value,           \\\n                                               Arena* arena,                  \\\n                                               int default_enum);             \\\n    static inline int SpaceUsedInMapEntry(const TypeOnMemory& value);         \\\n    static inline int SpaceUsedInMap(const TypeOnMemory& value);              \\\n    static inline int SpaceUsedInMap(const string& value);                    \\\n    static inline void AssignDefaultValue(TypeOnMemory* value);               \\\n    static inline const MapEntryAccessorType& DefaultIfNotInitialized(        \\\n        const TypeOnMemory& value, const TypeOnMemory& default_value);        \\\n    static inline bool IsInitialized(const TypeOnMemory& value);              \\\n    static void DeleteNoArena(TypeOnMemory& value);                           \\\n    static inline void Initialize(TypeOnMemory* value, Arena* arena);         \\\n    static inline void InitializeMaybeByDefaultEnum(TypeOnMemory* value,      \\\n                                                    int default_enum_value,   \\\n                                                    Arena* arena);            \\\n    static inline MapEntryAccessorType* EnsureMutable(TypeOnMemory* value,    \\\n                                                      Arena* arena);          \\\n  };\nMAP_HANDLER(STRING)\nMAP_HANDLER(BYTES)\nMAP_HANDLER(INT64)\nMAP_HANDLER(UINT64)\nMAP_HANDLER(INT32)\nMAP_HANDLER(UINT32)\nMAP_HANDLER(SINT64)\nMAP_HANDLER(SINT32)\nMAP_HANDLER(ENUM)\nMAP_HANDLER(DOUBLE)\nMAP_HANDLER(FLOAT)\nMAP_HANDLER(FIXED64)\nMAP_HANDLER(FIXED32)\nMAP_HANDLER(SFIXED64)\nMAP_HANDLER(SFIXED32)\nMAP_HANDLER(BOOL)\n#undef MAP_HANDLER\n\ntemplate <typename Type>\ninline int\nMapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::ByteSize(\n    const MapEntryAccessorType& value) {\n  return WireFormatLite::MessageSizeNoVirtual(value);\n}\n\n#define GOOGLE_PROTOBUF_BYTE_SIZE(FieldType, DeclaredType)                     \\\n  template <typename Type>                                                     \\\n  inline int MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::ByteSize( \\\n      const MapEntryAccessorType& value) {                                     \\\n    return WireFormatLite::DeclaredType##Size(value);                          \\\n  }\n\nGOOGLE_PROTOBUF_BYTE_SIZE(STRING, String)\nGOOGLE_PROTOBUF_BYTE_SIZE(BYTES , Bytes)\nGOOGLE_PROTOBUF_BYTE_SIZE(INT64 , Int64)\nGOOGLE_PROTOBUF_BYTE_SIZE(UINT64, UInt64)\nGOOGLE_PROTOBUF_BYTE_SIZE(INT32 , Int32)\nGOOGLE_PROTOBUF_BYTE_SIZE(UINT32, UInt32)\nGOOGLE_PROTOBUF_BYTE_SIZE(SINT64, SInt64)\nGOOGLE_PROTOBUF_BYTE_SIZE(SINT32, SInt32)\nGOOGLE_PROTOBUF_BYTE_SIZE(ENUM  , Enum)\n\n#undef GOOGLE_PROTOBUF_BYTE_SIZE\n\n#define FIXED_BYTE_SIZE(FieldType, DeclaredType)                               \\\n  template <typename Type>                                                     \\\n  inline int MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::ByteSize( \\\n      const MapEntryAccessorType& value) {                                     \\\n    return WireFormatLite::k##DeclaredType##Size;                              \\\n  }\n\nFIXED_BYTE_SIZE(DOUBLE  , Double)\nFIXED_BYTE_SIZE(FLOAT   , Float)\nFIXED_BYTE_SIZE(FIXED64 , Fixed64)\nFIXED_BYTE_SIZE(FIXED32 , Fixed32)\nFIXED_BYTE_SIZE(SFIXED64, SFixed64)\nFIXED_BYTE_SIZE(SFIXED32, SFixed32)\nFIXED_BYTE_SIZE(BOOL    , Bool)\n\n#undef FIXED_BYTE_SIZE\n\ntemplate <typename Type>\ninline int\nMapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::GetCachedSize(\n    const MapEntryAccessorType& value) {\n  return WireFormatLite::LengthDelimitedSize(value.GetCachedSize());\n}\n\n#define GET_CACHED_SIZE(FieldType, DeclaredType)                         \\\n  template <typename Type>                                               \\\n  inline int                                                             \\\n  MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::GetCachedSize( \\\n      const MapEntryAccessorType& value) {                               \\\n    return WireFormatLite::DeclaredType##Size(value);                    \\\n  }\n\nGET_CACHED_SIZE(STRING, String)\nGET_CACHED_SIZE(BYTES , Bytes)\nGET_CACHED_SIZE(INT64 , Int64)\nGET_CACHED_SIZE(UINT64, UInt64)\nGET_CACHED_SIZE(INT32 , Int32)\nGET_CACHED_SIZE(UINT32, UInt32)\nGET_CACHED_SIZE(SINT64, SInt64)\nGET_CACHED_SIZE(SINT32, SInt32)\nGET_CACHED_SIZE(ENUM  , Enum)\n\n#undef GET_CACHED_SIZE\n\n#define GET_FIXED_CACHED_SIZE(FieldType, DeclaredType)                   \\\n  template <typename Type>                                               \\\n  inline int                                                             \\\n  MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::GetCachedSize( \\\n      const MapEntryAccessorType& value) {                               \\\n    return WireFormatLite::k##DeclaredType##Size;                        \\\n  }\n\nGET_FIXED_CACHED_SIZE(DOUBLE  , Double)\nGET_FIXED_CACHED_SIZE(FLOAT   , Float)\nGET_FIXED_CACHED_SIZE(FIXED64 , Fixed64)\nGET_FIXED_CACHED_SIZE(FIXED32 , Fixed32)\nGET_FIXED_CACHED_SIZE(SFIXED64, SFixed64)\nGET_FIXED_CACHED_SIZE(SFIXED32, SFixed32)\nGET_FIXED_CACHED_SIZE(BOOL    , Bool)\n\n#undef GET_FIXED_CACHED_SIZE\n\ntemplate <typename Type>\ninline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::Write(\n    int field, const MapEntryAccessorType& value,\n    io::CodedOutputStream* output) {\n  WireFormatLite::WriteMessageMaybeToArray(field, value, output);\n}\n\ntemplate <typename Type>\ninline uint8*\nMapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::InternalWriteToArray(\n    int field, const MapEntryAccessorType& value, bool deterministic,\n    uint8* target) {\n  return WireFormatLite::InternalWriteMessageToArray(field, value,\n                                                     deterministic, target);\n}\n\n#define WRITE_METHOD(FieldType, DeclaredType)                                  \\\n  template <typename Type>                                                     \\\n  inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Write(   \\\n      int field, const MapEntryAccessorType& value,                            \\\n      io::CodedOutputStream* output) {                                         \\\n    return WireFormatLite::Write##DeclaredType(field, value, output);          \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  inline uint8*                                                                \\\n  MapTypeHandler<WireFormatLite::TYPE_##FieldType,                             \\\n                 Type>::InternalWriteToArray(                                  \\\n      int field, const MapEntryAccessorType& value, bool, uint8* target) {     \\\n    return WireFormatLite::Write##DeclaredType##ToArray(field, value, target); \\\n  }\n\nWRITE_METHOD(STRING  , String)\nWRITE_METHOD(BYTES   , Bytes)\nWRITE_METHOD(INT64   , Int64)\nWRITE_METHOD(UINT64  , UInt64)\nWRITE_METHOD(INT32   , Int32)\nWRITE_METHOD(UINT32  , UInt32)\nWRITE_METHOD(SINT64  , SInt64)\nWRITE_METHOD(SINT32  , SInt32)\nWRITE_METHOD(ENUM    , Enum)\nWRITE_METHOD(DOUBLE  , Double)\nWRITE_METHOD(FLOAT   , Float)\nWRITE_METHOD(FIXED64 , Fixed64)\nWRITE_METHOD(FIXED32 , Fixed32)\nWRITE_METHOD(SFIXED64, SFixed64)\nWRITE_METHOD(SFIXED32, SFixed32)\nWRITE_METHOD(BOOL    , Bool)\n\n#undef WRITE_METHOD\n\ntemplate <typename Type>\ninline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::Read(\n    io::CodedInputStream* input, MapEntryAccessorType* value) {\n  return WireFormatLite::ReadMessageNoVirtual(input, value);\n}\n\ntemplate <typename Type>\ninline bool MapTypeHandler<WireFormatLite::TYPE_STRING, Type>::Read(\n    io::CodedInputStream* input, MapEntryAccessorType* value) {\n  return WireFormatLite::ReadString(input, value);\n}\n\ntemplate <typename Type>\ninline bool MapTypeHandler<WireFormatLite::TYPE_BYTES, Type>::Read(\n    io::CodedInputStream* input, MapEntryAccessorType* value) {\n  return WireFormatLite::ReadBytes(input, value);\n}\n\n#define READ_METHOD(FieldType)                                              \\\n  template <typename Type>                                                  \\\n  inline bool MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Read( \\\n      io::CodedInputStream* input, MapEntryAccessorType* value) {           \\\n    return WireFormatLite::ReadPrimitive<TypeOnMemory,                      \\\n                                         WireFormatLite::TYPE_##FieldType>( \\\n        input, value);                                                      \\\n  }\n\nREAD_METHOD(INT64)\nREAD_METHOD(UINT64)\nREAD_METHOD(INT32)\nREAD_METHOD(UINT32)\nREAD_METHOD(SINT64)\nREAD_METHOD(SINT32)\nREAD_METHOD(ENUM)\nREAD_METHOD(DOUBLE)\nREAD_METHOD(FLOAT)\nREAD_METHOD(FIXED64)\nREAD_METHOD(FIXED32)\nREAD_METHOD(SFIXED64)\nREAD_METHOD(SFIXED32)\nREAD_METHOD(BOOL)\n\n#undef READ_METHOD\n\n// Definition for message handler\n\ntemplate <typename Type>\ninline const Type&\nMapTypeHandler<WireFormatLite::TYPE_MESSAGE,\n                        Type>::GetExternalReference(const Type* value) {\n  return *value;\n}\n\ntemplate <typename Type>\ninline int\nMapTypeHandler<WireFormatLite::TYPE_MESSAGE,\n                        Type>::SpaceUsedInMapEntry(const Type* value) {\n  return value->SpaceUsed();\n}\n\ntemplate <typename Type>\nint MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::SpaceUsedInMap(\n    const Type& value) {\n  return value.SpaceUsed();\n}\n\ntemplate <typename Type>\ninline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::Clear(\n    Type** value, Arena* arena) {\n  if (*value != NULL) (*value)->Clear();\n}\ntemplate <typename Type>\ninline void\nMapTypeHandler<WireFormatLite::TYPE_MESSAGE,\n                        Type>::ClearMaybeByDefaultEnum(Type** value,\n                                                       Arena* arena,\n                                                       int default_enum_value) {\n  if (*value != NULL) (*value)->Clear();\n}\ntemplate <typename Type>\ninline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::Merge(\n    const Type& from, Type** to, Arena* arena) {\n  (*to)->MergeFrom(from);\n}\n\ntemplate <typename Type>\nvoid MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::DeleteNoArena(\n    const Type* ptr) {\n  delete ptr;\n}\n\ntemplate <typename Type>\ninline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE,\n                                    Type>::AssignDefaultValue(Type** value) {\n  *value = const_cast<Type*>(&Type::default_instance());\n}\n\ntemplate <typename Type>\ninline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE,\n                                    Type>::Initialize(Type** x,\n                                                      Arena* arena) {\n  *x = NULL;\n}\n\ntemplate <typename Type>\ninline void MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::\n    InitializeMaybeByDefaultEnum(Type** x, int default_enum_value,\n                                 Arena* arena) {\n  *x = NULL;\n}\n\ntemplate <typename Type>\ninline Type* MapTypeHandler<WireFormatLite::TYPE_MESSAGE,\n                                     Type>::EnsureMutable(Type** value,\n                                                          Arena* arena) {\n  if (*value == NULL) {\n    *value =\n        MapArenaMessageCreator<Type, Arena::is_arena_constructable<Type>::\n                                         type::value>::CreateMessage(arena);\n  }\n  return *value;\n}\n\ntemplate <typename Type>\ninline const Type& MapTypeHandler<WireFormatLite::TYPE_MESSAGE, Type>::\n    DefaultIfNotInitialized(const Type* value, const Type* default_value) {\n  return value != NULL ? *value : *default_value;\n}\n\ntemplate <typename Type>\ninline bool MapTypeHandler<WireFormatLite::TYPE_MESSAGE,\n                                    Type>::IsInitialized(Type* value) {\n  return value->IsInitialized();\n}\n\n// Definition for string/bytes handler\n\n#define STRING_OR_BYTES_HANDLER_FUNCTIONS(FieldType)                           \\\n  template <typename Type>                                                     \\\n  inline const typename MapTypeHandler<WireFormatLite::TYPE_##FieldType,       \\\n                                       Type>::MapEntryAccessorType&            \\\n  MapTypeHandler<WireFormatLite::TYPE_##FieldType,                             \\\n                 Type>::GetExternalReference(const TypeOnMemory& value) {      \\\n    return value.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());      \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  inline int                                                                   \\\n  MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::SpaceUsedInMapEntry( \\\n      const TypeOnMemory& value) {                                             \\\n    return sizeof(value);                                                      \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  inline int MapTypeHandler<WireFormatLite::TYPE_##FieldType,                  \\\n                            Type>::SpaceUsedInMap(const TypeOnMemory& value) { \\\n    return sizeof(value);                                                      \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  inline int MapTypeHandler<WireFormatLite::TYPE_##FieldType,                  \\\n                            Type>::SpaceUsedInMap(const string& value) {       \\\n    return sizeof(value);                                                      \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Clear(   \\\n      TypeOnMemory* value, Arena* arena) {                                     \\\n    value->ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),    \\\n                        arena);                                                \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  inline void                                                                  \\\n  MapTypeHandler<WireFormatLite::TYPE_##FieldType,                             \\\n                 Type>::ClearMaybeByDefaultEnum(TypeOnMemory* value,           \\\n                                                Arena* arena,                  \\\n                                                int default_enum) {            \\\n    Clear(value, arena);                                                       \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Merge(   \\\n      const MapEntryAccessorType& from, TypeOnMemory* to, Arena* arena) {      \\\n    to->Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from, arena);  \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::DeleteNoArena(  \\\n      TypeOnMemory& value) {                                                   \\\n    value.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());  \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType,                 \\\n                             Type>::AssignDefaultValue(TypeOnMemory* value) {} \\\n  template <typename Type>                                                     \\\n  inline void                                                                  \\\n  MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Initialize(          \\\n      TypeOnMemory* value, Arena* arena) {                                     \\\n    value->UnsafeSetDefault(                                                   \\\n        &::google::protobuf::internal::GetEmptyStringAlreadyInited());                   \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  inline void                                                                  \\\n  MapTypeHandler<WireFormatLite::TYPE_##FieldType,                             \\\n                 Type>::InitializeMaybeByDefaultEnum(TypeOnMemory* value,      \\\n                                                     int default_enum_value,   \\\n                                                     Arena* arena) {           \\\n    Initialize(value, arena);                                                  \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  inline typename MapTypeHandler<WireFormatLite::TYPE_##FieldType,             \\\n                                 Type>::MapEntryAccessorType*                  \\\n  MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::EnsureMutable(       \\\n      TypeOnMemory* value, Arena* arena) {                                     \\\n    return value->Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),  \\\n                          arena);                                              \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  inline const typename MapTypeHandler<WireFormatLite::TYPE_##FieldType,       \\\n                                       Type>::MapEntryAccessorType&            \\\n  MapTypeHandler<WireFormatLite::TYPE_##FieldType,                             \\\n                 Type>::DefaultIfNotInitialized(const TypeOnMemory& value,     \\\n                                                const TypeOnMemory&            \\\n                                                    default_value) {           \\\n    return value.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());      \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  inline bool MapTypeHandler<WireFormatLite::TYPE_##FieldType,                 \\\n                             Type>::IsInitialized(const TypeOnMemory& value) { \\\n    return true;                                                               \\\n  }\nSTRING_OR_BYTES_HANDLER_FUNCTIONS(STRING)\nSTRING_OR_BYTES_HANDLER_FUNCTIONS(BYTES)\n#undef STRING_OR_BYTES_HANDLER_FUNCTIONS\n\n#define PRIMITIVE_HANDLER_FUNCTIONS(FieldType)                                 \\\n  template <typename Type>                                                     \\\n  inline const typename MapTypeHandler<WireFormatLite::TYPE_##FieldType,       \\\n                                       Type>::MapEntryAccessorType&            \\\n  MapTypeHandler<WireFormatLite::TYPE_##FieldType,                             \\\n                 Type>::GetExternalReference(const TypeOnMemory& value) {      \\\n    return value;                                                              \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  inline int                                                                   \\\n  MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::SpaceUsedInMapEntry( \\\n      const TypeOnMemory& value) {                                             \\\n    return 0;                                                                  \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  inline int MapTypeHandler<WireFormatLite::TYPE_##FieldType,                  \\\n                            Type>::SpaceUsedInMap(const TypeOnMemory& value) { \\\n    return sizeof(Type);                                                       \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Clear(   \\\n      TypeOnMemory* value, Arena* arena) {                                     \\\n    *value = 0;                                                                \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  inline void                                                                  \\\n  MapTypeHandler<WireFormatLite::TYPE_##FieldType,                             \\\n                 Type>::ClearMaybeByDefaultEnum(TypeOnMemory* value,           \\\n                                                Arena* arena,                  \\\n                                                int default_enum_value) {      \\\n    *value = static_cast<TypeOnMemory>(default_enum_value);                    \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Merge(   \\\n      const MapEntryAccessorType& from, TypeOnMemory* to, Arena* arena) {      \\\n    *to = from;                                                                \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType,                 \\\n                             Type>::DeleteNoArena(TypeOnMemory& x) {}          \\\n  template <typename Type>                                                     \\\n  inline void MapTypeHandler<WireFormatLite::TYPE_##FieldType,                 \\\n                             Type>::AssignDefaultValue(TypeOnMemory* value) {} \\\n  template <typename Type>                                                     \\\n  inline void                                                                  \\\n  MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::Initialize(          \\\n      TypeOnMemory* value, Arena* arena) {                                     \\\n    *value = 0;                                                                \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  inline void                                                                  \\\n  MapTypeHandler<WireFormatLite::TYPE_##FieldType,                             \\\n                 Type>::InitializeMaybeByDefaultEnum(TypeOnMemory* value,      \\\n                                                     int default_enum_value,   \\\n                                                     Arena* arena) {           \\\n    *value = static_cast<TypeOnMemory>(default_enum_value);                    \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  inline typename MapTypeHandler<WireFormatLite::TYPE_##FieldType,             \\\n                                 Type>::MapEntryAccessorType*                  \\\n  MapTypeHandler<WireFormatLite::TYPE_##FieldType, Type>::EnsureMutable(       \\\n      TypeOnMemory* value, Arena* arena) {                                     \\\n    return value;                                                              \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  inline const typename MapTypeHandler<WireFormatLite::TYPE_##FieldType,       \\\n                                       Type>::MapEntryAccessorType&            \\\n  MapTypeHandler<WireFormatLite::TYPE_##FieldType,                             \\\n                 Type>::DefaultIfNotInitialized(const TypeOnMemory& value,     \\\n                                                const TypeOnMemory&            \\\n                                                    default_value) {           \\\n    return value;                                                              \\\n  }                                                                            \\\n  template <typename Type>                                                     \\\n  inline bool MapTypeHandler<WireFormatLite::TYPE_##FieldType,                 \\\n                             Type>::IsInitialized(const TypeOnMemory& value) { \\\n    return true;                                                               \\\n  }\nPRIMITIVE_HANDLER_FUNCTIONS(INT64)\nPRIMITIVE_HANDLER_FUNCTIONS(UINT64)\nPRIMITIVE_HANDLER_FUNCTIONS(INT32)\nPRIMITIVE_HANDLER_FUNCTIONS(UINT32)\nPRIMITIVE_HANDLER_FUNCTIONS(SINT64)\nPRIMITIVE_HANDLER_FUNCTIONS(SINT32)\nPRIMITIVE_HANDLER_FUNCTIONS(ENUM)\nPRIMITIVE_HANDLER_FUNCTIONS(DOUBLE)\nPRIMITIVE_HANDLER_FUNCTIONS(FLOAT)\nPRIMITIVE_HANDLER_FUNCTIONS(FIXED64)\nPRIMITIVE_HANDLER_FUNCTIONS(FIXED32)\nPRIMITIVE_HANDLER_FUNCTIONS(SFIXED64)\nPRIMITIVE_HANDLER_FUNCTIONS(SFIXED32)\nPRIMITIVE_HANDLER_FUNCTIONS(BOOL)\n#undef PRIMITIVE_HANDLER_FUNCTIONS\n\n}  // namespace internal\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_TYPE_HANDLER_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/map_unittest.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto3\";\n\noption cc_enable_arenas = true;\n\nimport \"google/protobuf/unittest.proto\";\nimport \"google/protobuf/unittest_no_arena.proto\";\n\n// We don't put this in a package within proto2 because we need to make sure\n// that the generated code doesn't depend on being in the proto2 namespace.\n// In map_test_util.h we do \"using namespace unittest = protobuf_unittest\".\npackage protobuf_unittest;\n\n// Tests maps.\nmessage TestMap {\n  map<int32   , int32   > map_int32_int32       = 1;\n  map<int64   , int64   > map_int64_int64       = 2;\n  map<uint32  , uint32  > map_uint32_uint32     = 3;\n  map<uint64  , uint64  > map_uint64_uint64     = 4;\n  map<sint32  , sint32  > map_sint32_sint32     = 5;\n  map<sint64  , sint64  > map_sint64_sint64     = 6;\n  map<fixed32 , fixed32 > map_fixed32_fixed32   = 7;\n  map<fixed64 , fixed64 > map_fixed64_fixed64   = 8;\n  map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;\n  map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;\n  map<int32   , float   > map_int32_float       = 11;\n  map<int32   , double  > map_int32_double      = 12;\n  map<bool    , bool    > map_bool_bool         = 13;\n  map<string  , string  > map_string_string     = 14;\n  map<int32   , bytes   > map_int32_bytes       = 15;\n  map<int32   , MapEnum > map_int32_enum        = 16;\n  map<int32   , ForeignMessage> map_int32_foreign_message = 17;\n  map<string  , ForeignMessage> map_string_foreign_message = 18;\n}\n\nmessage TestMapSubmessage {\n  TestMap test_map = 1;\n}\n\nmessage TestMessageMap {\n  map<int32, TestAllTypes> map_int32_message = 1;\n}\n\n// Two map fields share the same entry default instance.\nmessage TestSameTypeMap {\n  map<int32, int32> map1 = 1;\n  map<int32, int32> map2 = 2;\n}\n\n\nenum MapEnum {\n  MAP_ENUM_FOO = 0;\n  MAP_ENUM_BAR = 1;\n  MAP_ENUM_BAZ = 2;\n}\n\n// Test embedded message with required fields\nmessage TestRequiredMessageMap {\n  map<int32, TestRequired> map_field = 1;\n}\n\nmessage TestArenaMap {\n  map<int32   , int32   > map_int32_int32       = 1;\n  map<int64   , int64   > map_int64_int64       = 2;\n  map<uint32  , uint32  > map_uint32_uint32     = 3;\n  map<uint64  , uint64  > map_uint64_uint64     = 4;\n  map<sint32  , sint32  > map_sint32_sint32     = 5;\n  map<sint64  , sint64  > map_sint64_sint64     = 6;\n  map<fixed32 , fixed32 > map_fixed32_fixed32   = 7;\n  map<fixed64 , fixed64 > map_fixed64_fixed64   = 8;\n  map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;\n  map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;\n  map<int32   , float   > map_int32_float       = 11;\n  map<int32   , double  > map_int32_double      = 12;\n  map<bool    , bool    > map_bool_bool         = 13;\n  map<string  , string  > map_string_string     = 14;\n  map<int32   , bytes   > map_int32_bytes       = 15;\n  map<int32   , MapEnum > map_int32_enum        = 16;\n  map<int32   , ForeignMessage> map_int32_foreign_message = 17;\n  map<int32, .protobuf_unittest_no_arena.ForeignMessage>\n      map_int32_foreign_message_no_arena = 18;\n}\n\n// Previously, message containing enum called Type cannot be used as value of\n// map field.\nmessage MessageContainingEnumCalledType {\n  enum Type {\n    TYPE_FOO = 0;\n  }\n  map<string, MessageContainingEnumCalledType> type = 1;\n}\n\n// Previously, message cannot contain map field called \"entry\".\nmessage MessageContainingMapCalledEntry {\n  map<int32, int32> entry = 1;\n}\n\nmessage TestRecursiveMapMessage {\n  map<string, TestRecursiveMapMessage> a = 1;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/message.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <iostream>\n#include <stack>\n#include <google/protobuf/stubs/hash.h>\n\n#include <google/protobuf/message.h>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/mutex.h>\n#include <google/protobuf/stubs/once.h>\n#include <google/protobuf/reflection_internal.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/map_field.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/generated_message_util.h>\n#include <google/protobuf/reflection_ops.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/map_util.h>\n#include <google/protobuf/stubs/singleton.h>\n#include <google/protobuf/stubs/stl_util.h>\n\nnamespace google {\nnamespace protobuf {\n\nusing internal::WireFormat;\nusing internal::ReflectionOps;\n\nvoid Message::MergeFrom(const Message& from) {\n  const Descriptor* descriptor = GetDescriptor();\n  GOOGLE_CHECK_EQ(from.GetDescriptor(), descriptor)\n    << \": Tried to merge from a message with a different type.  \"\n       \"to: \" << descriptor->full_name() << \", \"\n       \"from: \" << from.GetDescriptor()->full_name();\n  ReflectionOps::Merge(from, this);\n}\n\nvoid Message::CheckTypeAndMergeFrom(const MessageLite& other) {\n  MergeFrom(*down_cast<const Message*>(&other));\n}\n\nvoid Message::CopyFrom(const Message& from) {\n  const Descriptor* descriptor = GetDescriptor();\n  GOOGLE_CHECK_EQ(from.GetDescriptor(), descriptor)\n    << \": Tried to copy from a message with a different type. \"\n       \"to: \" << descriptor->full_name() << \", \"\n       \"from: \" << from.GetDescriptor()->full_name();\n  ReflectionOps::Copy(from, this);\n}\n\nstring Message::GetTypeName() const {\n  return GetDescriptor()->full_name();\n}\n\nvoid Message::Clear() {\n  ReflectionOps::Clear(this);\n}\n\nbool Message::IsInitialized() const {\n  return ReflectionOps::IsInitialized(*this);\n}\n\nvoid Message::FindInitializationErrors(vector<string>* errors) const {\n  return ReflectionOps::FindInitializationErrors(*this, \"\", errors);\n}\n\nstring Message::InitializationErrorString() const {\n  vector<string> errors;\n  FindInitializationErrors(&errors);\n  return Join(errors, \", \");\n}\n\nvoid Message::CheckInitialized() const {\n  GOOGLE_CHECK(IsInitialized())\n    << \"Message of type \\\"\" << GetDescriptor()->full_name()\n    << \"\\\" is missing required fields: \" << InitializationErrorString();\n}\n\nvoid Message::DiscardUnknownFields() {\n  return ReflectionOps::DiscardUnknownFields(this);\n}\n\nbool Message::MergePartialFromCodedStream(io::CodedInputStream* input) {\n  return WireFormat::ParseAndMergePartial(input, this);\n}\n\nbool Message::ParseFromFileDescriptor(int file_descriptor) {\n  io::FileInputStream input(file_descriptor);\n  return ParseFromZeroCopyStream(&input) && input.GetErrno() == 0;\n}\n\nbool Message::ParsePartialFromFileDescriptor(int file_descriptor) {\n  io::FileInputStream input(file_descriptor);\n  return ParsePartialFromZeroCopyStream(&input) && input.GetErrno() == 0;\n}\n\nbool Message::ParseFromIstream(istream* input) {\n  io::IstreamInputStream zero_copy_input(input);\n  return ParseFromZeroCopyStream(&zero_copy_input) && input->eof();\n}\n\nbool Message::ParsePartialFromIstream(istream* input) {\n  io::IstreamInputStream zero_copy_input(input);\n  return ParsePartialFromZeroCopyStream(&zero_copy_input) && input->eof();\n}\n\n\nvoid Message::SerializeWithCachedSizes(\n    io::CodedOutputStream* output) const {\n  WireFormat::SerializeWithCachedSizes(*this, GetCachedSize(), output);\n}\n\nint Message::ByteSize() const {\n  int size = WireFormat::ByteSize(*this);\n  SetCachedSize(size);\n  return size;\n}\n\nvoid Message::SetCachedSize(int /* size */) const {\n  GOOGLE_LOG(FATAL) << \"Message class \\\"\" << GetDescriptor()->full_name()\n             << \"\\\" implements neither SetCachedSize() nor ByteSize().  \"\n                \"Must implement one or the other.\";\n}\n\nint Message::SpaceUsed() const {\n  return GetReflection()->SpaceUsed(*this);\n}\n\nbool Message::SerializeToFileDescriptor(int file_descriptor) const {\n  io::FileOutputStream output(file_descriptor);\n  return SerializeToZeroCopyStream(&output);\n}\n\nbool Message::SerializePartialToFileDescriptor(int file_descriptor) const {\n  io::FileOutputStream output(file_descriptor);\n  return SerializePartialToZeroCopyStream(&output);\n}\n\nbool Message::SerializeToOstream(ostream* output) const {\n  {\n    io::OstreamOutputStream zero_copy_output(output);\n    if (!SerializeToZeroCopyStream(&zero_copy_output)) return false;\n  }\n  return output->good();\n}\n\nbool Message::SerializePartialToOstream(ostream* output) const {\n  io::OstreamOutputStream zero_copy_output(output);\n  return SerializePartialToZeroCopyStream(&zero_copy_output);\n}\n\n\n// =============================================================================\n// Reflection and associated Template Specializations\n\nReflection::~Reflection() {}\n\n#define HANDLE_TYPE(TYPE, CPPTYPE, CTYPE)                             \\\ntemplate<>                                                            \\\nconst RepeatedField<TYPE>& Reflection::GetRepeatedField<TYPE>(        \\\n    const Message& message, const FieldDescriptor* field) const {     \\\n  return *static_cast<RepeatedField<TYPE>* >(                         \\\n      MutableRawRepeatedField(const_cast<Message*>(&message),         \\\n                          field, CPPTYPE, CTYPE, NULL));              \\\n}                                                                     \\\n                                                                      \\\ntemplate<>                                                            \\\nRepeatedField<TYPE>* Reflection::MutableRepeatedField<TYPE>(          \\\n    Message* message, const FieldDescriptor* field) const {           \\\n  return static_cast<RepeatedField<TYPE>* >(                          \\\n      MutableRawRepeatedField(message, field, CPPTYPE, CTYPE, NULL)); \\\n}\n\nHANDLE_TYPE(int32,  FieldDescriptor::CPPTYPE_INT32,  -1);\nHANDLE_TYPE(int64,  FieldDescriptor::CPPTYPE_INT64,  -1);\nHANDLE_TYPE(uint32, FieldDescriptor::CPPTYPE_UINT32, -1);\nHANDLE_TYPE(uint64, FieldDescriptor::CPPTYPE_UINT64, -1);\nHANDLE_TYPE(float,  FieldDescriptor::CPPTYPE_FLOAT,  -1);\nHANDLE_TYPE(double, FieldDescriptor::CPPTYPE_DOUBLE, -1);\nHANDLE_TYPE(bool,   FieldDescriptor::CPPTYPE_BOOL,   -1);\n\n\n#undef HANDLE_TYPE\n\nvoid* Reflection::MutableRawRepeatedString(\n    Message* message, const FieldDescriptor* field, bool is_string) const {\n  return MutableRawRepeatedField(message, field,\n      FieldDescriptor::CPPTYPE_STRING, FieldOptions::STRING, NULL);\n}\n\n\n// Default EnumValue API implementations. Real reflection implementations should\n// override these. However, there are several legacy implementations that do\n// not, and cannot easily be changed at the same time as the Reflection API, so\n// we provide these for now.\n// TODO: Remove these once all Reflection implementations are updated.\nint Reflection::GetEnumValue(const Message& message,\n                             const FieldDescriptor* field) const {\n  GOOGLE_LOG(FATAL) << \"Unimplemented EnumValue API.\";\n  return 0;\n}\nvoid Reflection::SetEnumValue(Message* message,\n                  const FieldDescriptor* field,\n                  int value) const {\n  GOOGLE_LOG(FATAL) << \"Unimplemented EnumValue API.\";\n}\nint Reflection::GetRepeatedEnumValue(\n    const Message& message,\n    const FieldDescriptor* field, int index) const {\n  GOOGLE_LOG(FATAL) << \"Unimplemented EnumValue API.\";\n  return 0;\n}\nvoid Reflection::SetRepeatedEnumValue(Message* message,\n                                  const FieldDescriptor* field, int index,\n                                  int value) const {\n  GOOGLE_LOG(FATAL) << \"Unimplemented EnumValue API.\";\n}\nvoid Reflection::AddEnumValue(Message* message,\n                  const FieldDescriptor* field,\n                  int value) const {\n  GOOGLE_LOG(FATAL) << \"Unimplemented EnumValue API.\";\n}\n\nMapIterator Reflection::MapBegin(\n    Message* message,\n    const FieldDescriptor* field) const {\n  GOOGLE_LOG(FATAL) << \"Unimplemented Map Reflection API.\";\n  MapIterator iter(message, field);\n  return iter;\n}\n\nMapIterator Reflection::MapEnd(\n    Message* message,\n    const FieldDescriptor* field) const {\n  GOOGLE_LOG(FATAL) << \"Unimplemented Map Reflection API.\";\n  MapIterator iter(message, field);\n  return iter;\n}\n\n// =============================================================================\n// MessageFactory\n\nMessageFactory::~MessageFactory() {}\n\nnamespace {\n\nclass GeneratedMessageFactory : public MessageFactory {\n public:\n  GeneratedMessageFactory();\n  ~GeneratedMessageFactory();\n\n  static GeneratedMessageFactory* singleton();\n\n  typedef void RegistrationFunc(const string&);\n  void RegisterFile(const char* file, RegistrationFunc* registration_func);\n  void RegisterType(const Descriptor* descriptor, const Message* prototype);\n\n  // implements MessageFactory ---------------------------------------\n  const Message* GetPrototype(const Descriptor* type);\n\n private:\n  // Only written at static init time, so does not require locking.\n  hash_map<const char*, RegistrationFunc*,\n           hash<const char*>, streq> file_map_;\n\n  // Initialized lazily, so requires locking.\n  Mutex mutex_;\n  hash_map<const Descriptor*, const Message*> type_map_;\n};\n\nGeneratedMessageFactory* generated_message_factory_ = NULL;\nGOOGLE_PROTOBUF_DECLARE_ONCE(generated_message_factory_once_init_);\n\nvoid ShutdownGeneratedMessageFactory() {\n  delete generated_message_factory_;\n}\n\nvoid InitGeneratedMessageFactory() {\n  generated_message_factory_ = new GeneratedMessageFactory;\n  internal::OnShutdown(&ShutdownGeneratedMessageFactory);\n}\n\nGeneratedMessageFactory::GeneratedMessageFactory() {}\nGeneratedMessageFactory::~GeneratedMessageFactory() {}\n\nGeneratedMessageFactory* GeneratedMessageFactory::singleton() {\n  ::google::protobuf::GoogleOnceInit(&generated_message_factory_once_init_,\n                 &InitGeneratedMessageFactory);\n  return generated_message_factory_;\n}\n\nvoid GeneratedMessageFactory::RegisterFile(\n    const char* file, RegistrationFunc* registration_func) {\n  if (!InsertIfNotPresent(&file_map_, file, registration_func)) {\n    GOOGLE_LOG(FATAL) << \"File is already registered: \" << file;\n  }\n}\n\nvoid GeneratedMessageFactory::RegisterType(const Descriptor* descriptor,\n                                           const Message* prototype) {\n  GOOGLE_DCHECK_EQ(descriptor->file()->pool(), DescriptorPool::generated_pool())\n    << \"Tried to register a non-generated type with the generated \"\n       \"type registry.\";\n\n  // This should only be called as a result of calling a file registration\n  // function during GetPrototype(), in which case we already have locked\n  // the mutex.\n  mutex_.AssertHeld();\n  if (!InsertIfNotPresent(&type_map_, descriptor, prototype)) {\n    GOOGLE_LOG(DFATAL) << \"Type is already registered: \" << descriptor->full_name();\n  }\n}\n\n\nconst Message* GeneratedMessageFactory::GetPrototype(const Descriptor* type) {\n  {\n    ReaderMutexLock lock(&mutex_);\n    const Message* result = FindPtrOrNull(type_map_, type);\n    if (result != NULL) return result;\n  }\n\n  // If the type is not in the generated pool, then we can't possibly handle\n  // it.\n  if (type->file()->pool() != DescriptorPool::generated_pool()) return NULL;\n\n  // Apparently the file hasn't been registered yet.  Let's do that now.\n  RegistrationFunc* registration_func =\n      FindPtrOrNull(file_map_, type->file()->name().c_str());\n  if (registration_func == NULL) {\n    GOOGLE_LOG(DFATAL) << \"File appears to be in generated pool but wasn't \"\n                   \"registered: \" << type->file()->name();\n    return NULL;\n  }\n\n  WriterMutexLock lock(&mutex_);\n\n  // Check if another thread preempted us.\n  const Message* result = FindPtrOrNull(type_map_, type);\n  if (result == NULL) {\n    // Nope.  OK, register everything.\n    registration_func(type->file()->name());\n    // Should be here now.\n    result = FindPtrOrNull(type_map_, type);\n  }\n\n  if (result == NULL) {\n    GOOGLE_LOG(DFATAL) << \"Type appears to be in generated pool but wasn't \"\n                << \"registered: \" << type->full_name();\n  }\n\n  return result;\n}\n\n}  // namespace\n\nMessageFactory* MessageFactory::generated_factory() {\n  return GeneratedMessageFactory::singleton();\n}\n\nvoid MessageFactory::InternalRegisterGeneratedFile(\n    const char* filename, void (*register_messages)(const string&)) {\n  GeneratedMessageFactory::singleton()->RegisterFile(filename,\n                                                     register_messages);\n}\n\nvoid MessageFactory::InternalRegisterGeneratedMessage(\n    const Descriptor* descriptor, const Message* prototype) {\n  GeneratedMessageFactory::singleton()->RegisterType(descriptor, prototype);\n}\n\n\nMessageFactory* Reflection::GetMessageFactory() const {\n  GOOGLE_LOG(FATAL) << \"Not implemented.\";\n  return NULL;\n}\n\nvoid* Reflection::RepeatedFieldData(\n    Message* message, const FieldDescriptor* field,\n    FieldDescriptor::CppType cpp_type,\n    const Descriptor* message_type) const {\n  GOOGLE_LOG(FATAL) << \"Not implemented.\";\n  return NULL;\n}\n\nnamespace internal {\nRepeatedFieldAccessor::~RepeatedFieldAccessor() {\n}\n}  // namespace internal\n\nconst internal::RepeatedFieldAccessor* Reflection::RepeatedFieldAccessor(\n    const FieldDescriptor* field) const {\n  GOOGLE_CHECK(field->is_repeated());\n  switch (field->cpp_type()) {\n#define HANDLE_PRIMITIVE_TYPE(TYPE, type) \\\n    case FieldDescriptor::CPPTYPE_ ## TYPE: \\\n      return internal::Singleton<internal::RepeatedFieldPrimitiveAccessor<type> >::get();\n    HANDLE_PRIMITIVE_TYPE(INT32, int32)\n    HANDLE_PRIMITIVE_TYPE(UINT32, uint32)\n    HANDLE_PRIMITIVE_TYPE(INT64, int64)\n    HANDLE_PRIMITIVE_TYPE(UINT64, uint64)\n    HANDLE_PRIMITIVE_TYPE(FLOAT, float)\n    HANDLE_PRIMITIVE_TYPE(DOUBLE, double)\n    HANDLE_PRIMITIVE_TYPE(BOOL, bool)\n    HANDLE_PRIMITIVE_TYPE(ENUM, int32)\n#undef HANDLE_PRIMITIVE_TYPE\n    case FieldDescriptor::CPPTYPE_STRING:\n      switch (field->options().ctype()) {\n        default:\n        case FieldOptions::STRING:\n          return internal::Singleton<internal::RepeatedPtrFieldStringAccessor>::get();\n      }\n      break;\n    case FieldDescriptor::CPPTYPE_MESSAGE:\n      if (field->is_map()) {\n        return internal::Singleton<internal::MapFieldAccessor>::get();\n      } else {\n        return internal::Singleton<internal::RepeatedPtrFieldMessageAccessor>::get();\n      }\n  }\n  GOOGLE_LOG(FATAL) << \"Should not reach here.\";\n  return NULL;\n}\n\nnamespace internal {\nnamespace {\nvoid ShutdownRepeatedFieldAccessor() {\n  internal::Singleton<internal::RepeatedFieldPrimitiveAccessor<int32> >::ShutDown();\n  internal::Singleton<internal::RepeatedFieldPrimitiveAccessor<uint32> >::ShutDown();\n  internal::Singleton<internal::RepeatedFieldPrimitiveAccessor<int64> >::ShutDown();\n  internal::Singleton<internal::RepeatedFieldPrimitiveAccessor<uint64> >::ShutDown();\n  internal::Singleton<internal::RepeatedFieldPrimitiveAccessor<float> >::ShutDown();\n  internal::Singleton<internal::RepeatedFieldPrimitiveAccessor<double> >::ShutDown();\n  internal::Singleton<internal::RepeatedFieldPrimitiveAccessor<bool> >::ShutDown();\n  internal::Singleton<internal::RepeatedPtrFieldStringAccessor>::ShutDown();\n  internal::Singleton<internal::RepeatedPtrFieldMessageAccessor>::ShutDown();\n  internal::Singleton<internal::MapFieldAccessor>::ShutDown();\n}\n\nstruct ShutdownRepeatedFieldRegister {\n  ShutdownRepeatedFieldRegister() {\n    OnShutdown(&ShutdownRepeatedFieldAccessor);\n  }\n} shutdown_;\n\n}  // namespace\n}  // namespace internal\n\nnamespace internal {\ntemplate<>\n#if defined(_MSC_VER) && (_MSC_VER >= 1900)\n// Note: force noinline to workaround MSVC 2015 compiler bug, issue #240\nGOOGLE_ATTRIBUTE_NOINLINE\n#endif\nMessage* GenericTypeHandler<Message>::NewFromPrototype(\n    const Message* prototype, google::protobuf::Arena* arena) {\n  return prototype->New(arena);\n}\ntemplate<>\n#if defined(_MSC_VER) && (_MSC_VER >= 1900)\n// Note: force noinline to workaround MSVC 2015 compiler bug, issue #240\nGOOGLE_ATTRIBUTE_NOINLINE\n#endif\ngoogle::protobuf::Arena* GenericTypeHandler<Message>::GetArena(\n    Message* value) {\n  return value->GetArena();\n}\ntemplate<>\n#if defined(_MSC_VER) && (_MSC_VER >= 1900)\n// Note: force noinline to workaround MSVC 2015 compiler bug, issue #240\nGOOGLE_ATTRIBUTE_NOINLINE\n#endif\nvoid* GenericTypeHandler<Message>::GetMaybeArenaPointer(\n    Message* value) {\n  return value->GetMaybeArenaPointer();\n}\n}  // namespace internal\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/message.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Defines Message, the abstract interface implemented by non-lite\n// protocol message objects.  Although it's possible to implement this\n// interface manually, most users will use the protocol compiler to\n// generate implementations.\n//\n// Example usage:\n//\n// Say you have a message defined as:\n//\n//   message Foo {\n//     optional string text = 1;\n//     repeated int32 numbers = 2;\n//   }\n//\n// Then, if you used the protocol compiler to generate a class from the above\n// definition, you could use it like so:\n//\n//   string data;  // Will store a serialized version of the message.\n//\n//   {\n//     // Create a message and serialize it.\n//     Foo foo;\n//     foo.set_text(\"Hello World!\");\n//     foo.add_numbers(1);\n//     foo.add_numbers(5);\n//     foo.add_numbers(42);\n//\n//     foo.SerializeToString(&data);\n//   }\n//\n//   {\n//     // Parse the serialized message and check that it contains the\n//     // correct data.\n//     Foo foo;\n//     foo.ParseFromString(data);\n//\n//     assert(foo.text() == \"Hello World!\");\n//     assert(foo.numbers_size() == 3);\n//     assert(foo.numbers(0) == 1);\n//     assert(foo.numbers(1) == 5);\n//     assert(foo.numbers(2) == 42);\n//   }\n//\n//   {\n//     // Same as the last block, but do it dynamically via the Message\n//     // reflection interface.\n//     Message* foo = new Foo;\n//     const Descriptor* descriptor = foo->GetDescriptor();\n//\n//     // Get the descriptors for the fields we're interested in and verify\n//     // their types.\n//     const FieldDescriptor* text_field = descriptor->FindFieldByName(\"text\");\n//     assert(text_field != NULL);\n//     assert(text_field->type() == FieldDescriptor::TYPE_STRING);\n//     assert(text_field->label() == FieldDescriptor::LABEL_OPTIONAL);\n//     const FieldDescriptor* numbers_field = descriptor->\n//                                            FindFieldByName(\"numbers\");\n//     assert(numbers_field != NULL);\n//     assert(numbers_field->type() == FieldDescriptor::TYPE_INT32);\n//     assert(numbers_field->label() == FieldDescriptor::LABEL_REPEATED);\n//\n//     // Parse the message.\n//     foo->ParseFromString(data);\n//\n//     // Use the reflection interface to examine the contents.\n//     const Reflection* reflection = foo->GetReflection();\n//     assert(reflection->GetString(*foo, text_field) == \"Hello World!\");\n//     assert(reflection->FieldSize(*foo, numbers_field) == 3);\n//     assert(reflection->GetRepeatedInt32(*foo, numbers_field, 0) == 1);\n//     assert(reflection->GetRepeatedInt32(*foo, numbers_field, 1) == 5);\n//     assert(reflection->GetRepeatedInt32(*foo, numbers_field, 2) == 42);\n//\n//     delete foo;\n//   }\n\n#ifndef GOOGLE_PROTOBUF_MESSAGE_H__\n#define GOOGLE_PROTOBUF_MESSAGE_H__\n\n#include <iosfwd>\n#include <string>\n#include <google/protobuf/stubs/type_traits.h>\n#include <vector>\n\n#include <google/protobuf/arena.h>\n#include <google/protobuf/message_lite.h>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/descriptor.h>\n\n\n#define GOOGLE_PROTOBUF_HAS_ONEOF\n#define GOOGLE_PROTOBUF_HAS_ARENAS\n\nnamespace google {\nnamespace protobuf {\n\n// Defined in this file.\nclass Message;\nclass Reflection;\nclass MessageFactory;\n\n// Defined in other files.\nclass MapKey;\nclass MapValueRef;\nclass MapIterator;\nclass MapReflectionTester;\n\nnamespace internal {\nclass MapFieldBase;\n}\nclass UnknownFieldSet;         // unknown_field_set.h\nnamespace io {\nclass ZeroCopyInputStream;     // zero_copy_stream.h\nclass ZeroCopyOutputStream;    // zero_copy_stream.h\nclass CodedInputStream;        // coded_stream.h\nclass CodedOutputStream;       // coded_stream.h\n}\nnamespace python {\nclass MapReflectionFriend;     // scalar_map_container.h\n}\n\n\ntemplate<typename T>\nclass RepeatedField;     // repeated_field.h\n\ntemplate<typename T>\nclass RepeatedPtrField;  // repeated_field.h\n\n// A container to hold message metadata.\nstruct Metadata {\n  const Descriptor* descriptor;\n  const Reflection* reflection;\n};\n\n// Abstract interface for protocol messages.\n//\n// See also MessageLite, which contains most every-day operations.  Message\n// adds descriptors and reflection on top of that.\n//\n// The methods of this class that are virtual but not pure-virtual have\n// default implementations based on reflection.  Message classes which are\n// optimized for speed will want to override these with faster implementations,\n// but classes optimized for code size may be happy with keeping them.  See\n// the optimize_for option in descriptor.proto.\nclass LIBPROTOBUF_EXPORT Message : public MessageLite {\n public:\n  inline Message() {}\n  virtual ~Message() {}\n\n  // Basic Operations ------------------------------------------------\n\n  // Construct a new instance of the same type.  Ownership is passed to the\n  // caller.  (This is also defined in MessageLite, but is defined again here\n  // for return-type covariance.)\n  virtual Message* New() const = 0;\n\n  // Construct a new instance on the arena. Ownership is passed to the caller\n  // if arena is a NULL. Default implementation allows for API compatibility\n  // during the Arena transition.\n  virtual Message* New(::google::protobuf::Arena* arena) const {\n    Message* message = New();\n    if (arena != NULL) {\n      arena->Own(message);\n    }\n    return message;\n  }\n\n  // Make this message into a copy of the given message.  The given message\n  // must have the same descriptor, but need not necessarily be the same class.\n  // By default this is just implemented as \"Clear(); MergeFrom(from);\".\n  virtual void CopyFrom(const Message& from);\n\n  // Merge the fields from the given message into this message.  Singular\n  // fields will be overwritten, if specified in from, except for embedded\n  // messages which will be merged.  Repeated fields will be concatenated.\n  // The given message must be of the same type as this message (i.e. the\n  // exact same class).\n  virtual void MergeFrom(const Message& from);\n\n  // Verifies that IsInitialized() returns true.  GOOGLE_CHECK-fails otherwise, with\n  // a nice error message.\n  void CheckInitialized() const;\n\n  // Slowly build a list of all required fields that are not set.\n  // This is much, much slower than IsInitialized() as it is implemented\n  // purely via reflection.  Generally, you should not call this unless you\n  // have already determined that an error exists by calling IsInitialized().\n  void FindInitializationErrors(std::vector<string>* errors) const;\n\n  // Like FindInitializationErrors, but joins all the strings, delimited by\n  // commas, and returns them.\n  string InitializationErrorString() const;\n\n  // Clears all unknown fields from this message and all embedded messages.\n  // Normally, if unknown tag numbers are encountered when parsing a message,\n  // the tag and value are stored in the message's UnknownFieldSet and\n  // then written back out when the message is serialized.  This allows servers\n  // which simply route messages to other servers to pass through messages\n  // that have new field definitions which they don't yet know about.  However,\n  // this behavior can have security implications.  To avoid it, call this\n  // method after parsing.\n  //\n  // See Reflection::GetUnknownFields() for more on unknown fields.\n  virtual void DiscardUnknownFields();\n\n  // Computes (an estimate of) the total number of bytes currently used for\n  // storing the message in memory.  The default implementation calls the\n  // Reflection object's SpaceUsed() method.\n  //\n  // SpaceUsed() is noticeably slower than ByteSize(), as it is implemented\n  // using reflection (rather than the generated code implementation for\n  // ByteSize()). Like ByteSize(), its CPU time is linear in the number of\n  // fields defined for the proto.\n  virtual int SpaceUsed() const;\n\n  // Debugging & Testing----------------------------------------------\n\n  // Generates a human readable form of this message, useful for debugging\n  // and other purposes.\n  string DebugString() const;\n  // Like DebugString(), but with less whitespace.\n  string ShortDebugString() const;\n  // Like DebugString(), but do not escape UTF-8 byte sequences.\n  string Utf8DebugString() const;\n  // Convenience function useful in GDB.  Prints DebugString() to stdout.\n  void PrintDebugString() const;\n\n  // Heavy I/O -------------------------------------------------------\n  // Additional parsing and serialization methods not implemented by\n  // MessageLite because they are not supported by the lite library.\n\n  // Parse a protocol buffer from a file descriptor.  If successful, the entire\n  // input will be consumed.\n  bool ParseFromFileDescriptor(int file_descriptor);\n  // Like ParseFromFileDescriptor(), but accepts messages that are missing\n  // required fields.\n  bool ParsePartialFromFileDescriptor(int file_descriptor);\n  // Parse a protocol buffer from a C++ istream.  If successful, the entire\n  // input will be consumed.\n  bool ParseFromIstream(istream* input);\n  // Like ParseFromIstream(), but accepts messages that are missing\n  // required fields.\n  bool ParsePartialFromIstream(istream* input);\n\n  // Serialize the message and write it to the given file descriptor.  All\n  // required fields must be set.\n  bool SerializeToFileDescriptor(int file_descriptor) const;\n  // Like SerializeToFileDescriptor(), but allows missing required fields.\n  bool SerializePartialToFileDescriptor(int file_descriptor) const;\n  // Serialize the message and write it to the given C++ ostream.  All\n  // required fields must be set.\n  bool SerializeToOstream(ostream* output) const;\n  // Like SerializeToOstream(), but allows missing required fields.\n  bool SerializePartialToOstream(ostream* output) const;\n\n\n  // Reflection-based methods ----------------------------------------\n  // These methods are pure-virtual in MessageLite, but Message provides\n  // reflection-based default implementations.\n\n  virtual string GetTypeName() const;\n  virtual void Clear();\n  virtual bool IsInitialized() const;\n  virtual void CheckTypeAndMergeFrom(const MessageLite& other);\n  virtual bool MergePartialFromCodedStream(io::CodedInputStream* input);\n  virtual int ByteSize() const;\n  virtual void SerializeWithCachedSizes(io::CodedOutputStream* output) const;\n\n private:\n  // This is called only by the default implementation of ByteSize(), to\n  // update the cached size.  If you override ByteSize(), you do not need\n  // to override this.  If you do not override ByteSize(), you MUST override\n  // this; the default implementation will crash.\n  //\n  // The method is private because subclasses should never call it; only\n  // override it.  Yes, C++ lets you do that.  Crazy, huh?\n  virtual void SetCachedSize(int size) const;\n\n public:\n\n  // Introspection ---------------------------------------------------\n\n  // Typedef for backwards-compatibility.\n  typedef google::protobuf::Reflection Reflection;\n\n  // Get a Descriptor for this message's type.  This describes what\n  // fields the message contains, the types of those fields, etc.\n  const Descriptor* GetDescriptor() const { return GetMetadata().descriptor; }\n\n  // Get the Reflection interface for this Message, which can be used to\n  // read and modify the fields of the Message dynamically (in other words,\n  // without knowing the message type at compile time).  This object remains\n  // property of the Message.\n  //\n  // This method remains virtual in case a subclass does not implement\n  // reflection and wants to override the default behavior.\n  virtual const Reflection* GetReflection() const {\n    return GetMetadata().reflection;\n  }\n\n protected:\n  // Get a struct containing the metadata for the Message. Most subclasses only\n  // need to implement this method, rather than the GetDescriptor() and\n  // GetReflection() wrappers.\n  virtual Metadata GetMetadata() const  = 0;\n\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Message);\n};\n\nnamespace internal {\n// Forward-declare interfaces used to implement RepeatedFieldRef.\n// These are protobuf internals that users shouldn't care about.\nclass RepeatedFieldAccessor;\n}  // namespace internal\n\n// Forward-declare RepeatedFieldRef templates. The second type parameter is\n// used for SFINAE tricks. Users should ignore it.\ntemplate<typename T, typename Enable = void>\nclass RepeatedFieldRef;\n\ntemplate<typename T, typename Enable = void>\nclass MutableRepeatedFieldRef;\n\n// This interface contains methods that can be used to dynamically access\n// and modify the fields of a protocol message.  Their semantics are\n// similar to the accessors the protocol compiler generates.\n//\n// To get the Reflection for a given Message, call Message::GetReflection().\n//\n// This interface is separate from Message only for efficiency reasons;\n// the vast majority of implementations of Message will share the same\n// implementation of Reflection (GeneratedMessageReflection,\n// defined in generated_message.h), and all Messages of a particular class\n// should share the same Reflection object (though you should not rely on\n// the latter fact).\n//\n// There are several ways that these methods can be used incorrectly.  For\n// example, any of the following conditions will lead to undefined\n// results (probably assertion failures):\n// - The FieldDescriptor is not a field of this message type.\n// - The method called is not appropriate for the field's type.  For\n//   each field type in FieldDescriptor::TYPE_*, there is only one\n//   Get*() method, one Set*() method, and one Add*() method that is\n//   valid for that type.  It should be obvious which (except maybe\n//   for TYPE_BYTES, which are represented using strings in C++).\n// - A Get*() or Set*() method for singular fields is called on a repeated\n//   field.\n// - GetRepeated*(), SetRepeated*(), or Add*() is called on a non-repeated\n//   field.\n// - The Message object passed to any method is not of the right type for\n//   this Reflection object (i.e. message.GetReflection() != reflection).\n//\n// You might wonder why there is not any abstract representation for a field\n// of arbitrary type.  E.g., why isn't there just a \"GetField()\" method that\n// returns \"const Field&\", where \"Field\" is some class with accessors like\n// \"GetInt32Value()\".  The problem is that someone would have to deal with\n// allocating these Field objects.  For generated message classes, having to\n// allocate space for an additional object to wrap every field would at least\n// double the message's memory footprint, probably worse.  Allocating the\n// objects on-demand, on the other hand, would be expensive and prone to\n// memory leaks.  So, instead we ended up with this flat interface.\n//\n// TODO(kenton):  Create a utility class which callers can use to read and\n//   write fields from a Reflection without paying attention to the type.\nclass LIBPROTOBUF_EXPORT Reflection {\n public:\n  inline Reflection() {}\n  virtual ~Reflection();\n\n  // Get the UnknownFieldSet for the message.  This contains fields which\n  // were seen when the Message was parsed but were not recognized according\n  // to the Message's definition. For proto3 protos, this method will always\n  // return an empty UnknownFieldSet.\n  virtual const UnknownFieldSet& GetUnknownFields(\n      const Message& message) const = 0;\n  // Get a mutable pointer to the UnknownFieldSet for the message.  This\n  // contains fields which were seen when the Message was parsed but were not\n  // recognized according to the Message's definition. For proto3 protos, this\n  // method will return a valid mutable UnknownFieldSet pointer but modifying\n  // it won't affect the serialized bytes of the message.\n  virtual UnknownFieldSet* MutableUnknownFields(Message* message) const = 0;\n\n  // Estimate the amount of memory used by the message object.\n  virtual int SpaceUsed(const Message& message) const = 0;\n\n  // Check if the given non-repeated field is set.\n  virtual bool HasField(const Message& message,\n                        const FieldDescriptor* field) const = 0;\n\n  // Get the number of elements of a repeated field.\n  virtual int FieldSize(const Message& message,\n                        const FieldDescriptor* field) const = 0;\n\n  // Clear the value of a field, so that HasField() returns false or\n  // FieldSize() returns zero.\n  virtual void ClearField(Message* message,\n                          const FieldDescriptor* field) const = 0;\n\n  // Check if the oneof is set. Returns true if any field in oneof\n  // is set, false otherwise.\n  // TODO(jieluo) - make it pure virtual after updating all\n  // the subclasses.\n  virtual bool HasOneof(const Message& /*message*/,\n                        const OneofDescriptor* /*oneof_descriptor*/) const {\n    return false;\n  }\n\n  virtual void ClearOneof(Message* /*message*/,\n                          const OneofDescriptor* /*oneof_descriptor*/) const {}\n\n  // Returns the field descriptor if the oneof is set. NULL otherwise.\n  // TODO(jieluo) - make it pure virtual.\n  virtual const FieldDescriptor* GetOneofFieldDescriptor(\n      const Message& /*message*/,\n      const OneofDescriptor* /*oneof_descriptor*/) const {\n    return NULL;\n  }\n\n  // Removes the last element of a repeated field.\n  // We don't provide a way to remove any element other than the last\n  // because it invites inefficient use, such as O(n^2) filtering loops\n  // that should have been O(n).  If you want to remove an element other\n  // than the last, the best way to do it is to re-arrange the elements\n  // (using Swap()) so that the one you want removed is at the end, then\n  // call RemoveLast().\n  virtual void RemoveLast(Message* message,\n                          const FieldDescriptor* field) const = 0;\n  // Removes the last element of a repeated message field, and returns the\n  // pointer to the caller.  Caller takes ownership of the returned pointer.\n  virtual Message* ReleaseLast(Message* message,\n                               const FieldDescriptor* field) const = 0;\n\n  // Swap the complete contents of two messages.\n  virtual void Swap(Message* message1, Message* message2) const = 0;\n\n  // Swap fields listed in fields vector of two messages.\n  virtual void SwapFields(Message* message1,\n                          Message* message2,\n                          const std::vector<const FieldDescriptor*>& fields)\n      const = 0;\n\n  // Swap two elements of a repeated field.\n  virtual void SwapElements(Message* message,\n                            const FieldDescriptor* field,\n                            int index1,\n                            int index2) const = 0;\n\n  // List all fields of the message which are currently set.  This includes\n  // extensions.  Singular fields will only be listed if HasField(field) would\n  // return true and repeated fields will only be listed if FieldSize(field)\n  // would return non-zero.  Fields (both normal fields and extension fields)\n  // will be listed ordered by field number.\n  virtual void ListFields(\n      const Message& message,\n      std::vector<const FieldDescriptor*>* output) const = 0;\n\n  // Singular field getters ------------------------------------------\n  // These get the value of a non-repeated field.  They return the default\n  // value for fields that aren't set.\n\n  virtual int32  GetInt32 (const Message& message,\n                           const FieldDescriptor* field) const = 0;\n  virtual int64  GetInt64 (const Message& message,\n                           const FieldDescriptor* field) const = 0;\n  virtual uint32 GetUInt32(const Message& message,\n                           const FieldDescriptor* field) const = 0;\n  virtual uint64 GetUInt64(const Message& message,\n                           const FieldDescriptor* field) const = 0;\n  virtual float  GetFloat (const Message& message,\n                           const FieldDescriptor* field) const = 0;\n  virtual double GetDouble(const Message& message,\n                           const FieldDescriptor* field) const = 0;\n  virtual bool   GetBool  (const Message& message,\n                           const FieldDescriptor* field) const = 0;\n  virtual string GetString(const Message& message,\n                           const FieldDescriptor* field) const = 0;\n  virtual const EnumValueDescriptor* GetEnum(\n      const Message& message, const FieldDescriptor* field) const = 0;\n\n  // GetEnumValue() returns an enum field's value as an integer rather than\n  // an EnumValueDescriptor*. If the integer value does not correspond to a\n  // known value descriptor, a new value descriptor is created. (Such a value\n  // will only be present when the new unknown-enum-value semantics are enabled\n  // for a message.)\n  virtual int GetEnumValue(\n      const Message& message, const FieldDescriptor* field) const;\n\n  // See MutableMessage() for the meaning of the \"factory\" parameter.\n  virtual const Message& GetMessage(const Message& message,\n                                    const FieldDescriptor* field,\n                                    MessageFactory* factory = NULL) const = 0;\n\n  // Get a string value without copying, if possible.\n  //\n  // GetString() necessarily returns a copy of the string.  This can be\n  // inefficient when the string is already stored in a string object in the\n  // underlying message.  GetStringReference() will return a reference to the\n  // underlying string in this case.  Otherwise, it will copy the string into\n  // *scratch and return that.\n  //\n  // Note:  It is perfectly reasonable and useful to write code like:\n  //     str = reflection->GetStringReference(field, &str);\n  //   This line would ensure that only one copy of the string is made\n  //   regardless of the field's underlying representation.  When initializing\n  //   a newly-constructed string, though, it's just as fast and more readable\n  //   to use code like:\n  //     string str = reflection->GetString(message, field);\n  virtual const string& GetStringReference(const Message& message,\n                                           const FieldDescriptor* field,\n                                           string* scratch) const = 0;\n\n\n  // Singular field mutators -----------------------------------------\n  // These mutate the value of a non-repeated field.\n\n  virtual void SetInt32 (Message* message,\n                         const FieldDescriptor* field, int32  value) const = 0;\n  virtual void SetInt64 (Message* message,\n                         const FieldDescriptor* field, int64  value) const = 0;\n  virtual void SetUInt32(Message* message,\n                         const FieldDescriptor* field, uint32 value) const = 0;\n  virtual void SetUInt64(Message* message,\n                         const FieldDescriptor* field, uint64 value) const = 0;\n  virtual void SetFloat (Message* message,\n                         const FieldDescriptor* field, float  value) const = 0;\n  virtual void SetDouble(Message* message,\n                         const FieldDescriptor* field, double value) const = 0;\n  virtual void SetBool  (Message* message,\n                         const FieldDescriptor* field, bool   value) const = 0;\n  virtual void SetString(Message* message,\n                         const FieldDescriptor* field,\n                         const string& value) const = 0;\n  virtual void SetEnum  (Message* message,\n                         const FieldDescriptor* field,\n                         const EnumValueDescriptor* value) const = 0;\n  // Set an enum field's value with an integer rather than EnumValueDescriptor.\n  // If the value does not correspond to a known enum value, either behavior is\n  // undefined (for proto2 messages), or the value is accepted silently for\n  // messages with new unknown-enum-value semantics.\n  virtual void SetEnumValue(Message* message,\n                            const FieldDescriptor* field,\n                            int value) const;\n\n  // Get a mutable pointer to a field with a message type.  If a MessageFactory\n  // is provided, it will be used to construct instances of the sub-message;\n  // otherwise, the default factory is used.  If the field is an extension that\n  // does not live in the same pool as the containing message's descriptor (e.g.\n  // it lives in an overlay pool), then a MessageFactory must be provided.\n  // If you have no idea what that meant, then you probably don't need to worry\n  // about it (don't provide a MessageFactory).  WARNING:  If the\n  // FieldDescriptor is for a compiled-in extension, then\n  // factory->GetPrototype(field->message_type()) MUST return an instance of\n  // the compiled-in class for this type, NOT DynamicMessage.\n  virtual Message* MutableMessage(Message* message,\n                                  const FieldDescriptor* field,\n                                  MessageFactory* factory = NULL) const = 0;\n  // Replaces the message specified by 'field' with the already-allocated object\n  // sub_message, passing ownership to the message.  If the field contained a\n  // message, that message is deleted.  If sub_message is NULL, the field is\n  // cleared.\n  virtual void SetAllocatedMessage(Message* message,\n                                   Message* sub_message,\n                                   const FieldDescriptor* field) const = 0;\n  // Releases the message specified by 'field' and returns the pointer,\n  // ReleaseMessage() will return the message the message object if it exists.\n  // Otherwise, it may or may not return NULL.  In any case, if the return value\n  // is non-NULL, the caller takes ownership of the pointer.\n  // If the field existed (HasField() is true), then the returned pointer will\n  // be the same as the pointer returned by MutableMessage().\n  // This function has the same effect as ClearField().\n  virtual Message* ReleaseMessage(Message* message,\n                                  const FieldDescriptor* field,\n                                  MessageFactory* factory = NULL) const = 0;\n\n\n  // Repeated field getters ------------------------------------------\n  // These get the value of one element of a repeated field.\n\n  virtual int32  GetRepeatedInt32 (const Message& message,\n                                   const FieldDescriptor* field,\n                                   int index) const = 0;\n  virtual int64  GetRepeatedInt64 (const Message& message,\n                                   const FieldDescriptor* field,\n                                   int index) const = 0;\n  virtual uint32 GetRepeatedUInt32(const Message& message,\n                                   const FieldDescriptor* field,\n                                   int index) const = 0;\n  virtual uint64 GetRepeatedUInt64(const Message& message,\n                                   const FieldDescriptor* field,\n                                   int index) const = 0;\n  virtual float  GetRepeatedFloat (const Message& message,\n                                   const FieldDescriptor* field,\n                                   int index) const = 0;\n  virtual double GetRepeatedDouble(const Message& message,\n                                   const FieldDescriptor* field,\n                                   int index) const = 0;\n  virtual bool   GetRepeatedBool  (const Message& message,\n                                   const FieldDescriptor* field,\n                                   int index) const = 0;\n  virtual string GetRepeatedString(const Message& message,\n                                   const FieldDescriptor* field,\n                                   int index) const = 0;\n  virtual const EnumValueDescriptor* GetRepeatedEnum(\n      const Message& message,\n      const FieldDescriptor* field, int index) const = 0;\n  // GetRepeatedEnumValue() returns an enum field's value as an integer rather\n  // than an EnumValueDescriptor*. If the integer value does not correspond to a\n  // known value descriptor, a new value descriptor is created. (Such a value\n  // will only be present when the new unknown-enum-value semantics are enabled\n  // for a message.)\n  virtual int GetRepeatedEnumValue(\n      const Message& message,\n      const FieldDescriptor* field, int index) const;\n  virtual const Message& GetRepeatedMessage(\n      const Message& message,\n      const FieldDescriptor* field, int index) const = 0;\n\n  // See GetStringReference(), above.\n  virtual const string& GetRepeatedStringReference(\n      const Message& message, const FieldDescriptor* field,\n      int index, string* scratch) const = 0;\n\n\n  // Repeated field mutators -----------------------------------------\n  // These mutate the value of one element of a repeated field.\n\n  virtual void SetRepeatedInt32 (Message* message,\n                                 const FieldDescriptor* field,\n                                 int index, int32  value) const = 0;\n  virtual void SetRepeatedInt64 (Message* message,\n                                 const FieldDescriptor* field,\n                                 int index, int64  value) const = 0;\n  virtual void SetRepeatedUInt32(Message* message,\n                                 const FieldDescriptor* field,\n                                 int index, uint32 value) const = 0;\n  virtual void SetRepeatedUInt64(Message* message,\n                                 const FieldDescriptor* field,\n                                 int index, uint64 value) const = 0;\n  virtual void SetRepeatedFloat (Message* message,\n                                 const FieldDescriptor* field,\n                                 int index, float  value) const = 0;\n  virtual void SetRepeatedDouble(Message* message,\n                                 const FieldDescriptor* field,\n                                 int index, double value) const = 0;\n  virtual void SetRepeatedBool  (Message* message,\n                                 const FieldDescriptor* field,\n                                 int index, bool   value) const = 0;\n  virtual void SetRepeatedString(Message* message,\n                                 const FieldDescriptor* field,\n                                 int index, const string& value) const = 0;\n  virtual void SetRepeatedEnum(Message* message,\n                               const FieldDescriptor* field, int index,\n                               const EnumValueDescriptor* value) const = 0;\n  // Set an enum field's value with an integer rather than EnumValueDescriptor.\n  // If the value does not correspond to a known enum value, either behavior is\n  // undefined (for proto2 messages), or the value is accepted silently for\n  // messages with new unknown-enum-value semantics.\n  virtual void SetRepeatedEnumValue(Message* message,\n                                    const FieldDescriptor* field, int index,\n                                    int value) const;\n  // Get a mutable pointer to an element of a repeated field with a message\n  // type.\n  virtual Message* MutableRepeatedMessage(\n      Message* message, const FieldDescriptor* field, int index) const = 0;\n\n\n  // Repeated field adders -------------------------------------------\n  // These add an element to a repeated field.\n\n  virtual void AddInt32 (Message* message,\n                         const FieldDescriptor* field, int32  value) const = 0;\n  virtual void AddInt64 (Message* message,\n                         const FieldDescriptor* field, int64  value) const = 0;\n  virtual void AddUInt32(Message* message,\n                         const FieldDescriptor* field, uint32 value) const = 0;\n  virtual void AddUInt64(Message* message,\n                         const FieldDescriptor* field, uint64 value) const = 0;\n  virtual void AddFloat (Message* message,\n                         const FieldDescriptor* field, float  value) const = 0;\n  virtual void AddDouble(Message* message,\n                         const FieldDescriptor* field, double value) const = 0;\n  virtual void AddBool  (Message* message,\n                         const FieldDescriptor* field, bool   value) const = 0;\n  virtual void AddString(Message* message,\n                         const FieldDescriptor* field,\n                         const string& value) const = 0;\n  virtual void AddEnum  (Message* message,\n                         const FieldDescriptor* field,\n                         const EnumValueDescriptor* value) const = 0;\n  // Set an enum field's value with an integer rather than EnumValueDescriptor.\n  // If the value does not correspond to a known enum value, either behavior is\n  // undefined (for proto2 messages), or the value is accepted silently for\n  // messages with new unknown-enum-value semantics.\n  virtual void AddEnumValue(Message* message,\n                            const FieldDescriptor* field,\n                            int value) const;\n  // See MutableMessage() for comments on the \"factory\" parameter.\n  virtual Message* AddMessage(Message* message,\n                              const FieldDescriptor* field,\n                              MessageFactory* factory = NULL) const = 0;\n\n  // Appends an already-allocated object 'new_entry' to the repeated field\n  // specifyed by 'field' passing ownership to the message.\n  // TODO(tmarek): Make virtual after all subclasses have been\n  // updated.\n  virtual void AddAllocatedMessage(Message* /* message */,\n                                   const FieldDescriptor* /*field */,\n                                   Message* /* new_entry */) const {}\n\n\n  // Get a RepeatedFieldRef object that can be used to read the underlying\n  // repeated field. The type parameter T must be set according to the\n  // field's cpp type. The following table shows the mapping from cpp type\n  // to acceptable T.\n  //\n  //   field->cpp_type()      T\n  //   CPPTYPE_INT32        int32\n  //   CPPTYPE_UINT32       uint32\n  //   CPPTYPE_INT64        int64\n  //   CPPTYPE_UINT64       uint64\n  //   CPPTYPE_DOUBLE       double\n  //   CPPTYPE_FLOAT        float\n  //   CPPTYPE_BOOL         bool\n  //   CPPTYPE_ENUM         generated enum type or int32\n  //   CPPTYPE_STRING       string\n  //   CPPTYPE_MESSAGE      generated message type or google::protobuf::Message\n  //\n  // A RepeatedFieldRef object can be copied and the resulted object will point\n  // to the same repeated field in the same message. The object can be used as\n  // long as the message is not destroyed.\n  //\n  // Note that to use this method users need to include the header file\n  // \"google/protobuf/reflection.h\" (which defines the RepeatedFieldRef\n  // class templates).\n  template<typename T>\n  RepeatedFieldRef<T> GetRepeatedFieldRef(\n      const Message& message, const FieldDescriptor* field) const;\n\n  // Like GetRepeatedFieldRef() but return an object that can also be used\n  // manipulate the underlying repeated field.\n  template<typename T>\n  MutableRepeatedFieldRef<T> GetMutableRepeatedFieldRef(\n      Message* message, const FieldDescriptor* field) const;\n\n  // DEPRECATED. Please use Get(Mutable)RepeatedFieldRef() for repeated field\n  // access. The following repeated field accesors will be removed in the\n  // future.\n  //\n  // Repeated field accessors  -------------------------------------------------\n  // The methods above, e.g. GetRepeatedInt32(msg, fd, index), provide singular\n  // access to the data in a RepeatedField.  The methods below provide aggregate\n  // access by exposing the RepeatedField object itself with the Message.\n  // Applying these templates to inappropriate types will lead to an undefined\n  // reference at link time (e.g. GetRepeatedField<***double>), or possibly a\n  // template matching error at compile time (e.g. GetRepeatedPtrField<File>).\n  //\n  // Usage example: my_doubs = refl->GetRepeatedField<double>(msg, fd);\n\n  // DEPRECATED. Please use GetRepeatedFieldRef().\n  //\n  // for T = Cord and all protobuf scalar types except enums.\n  template<typename T>\n  const RepeatedField<T>& GetRepeatedField(\n      const Message&, const FieldDescriptor*) const;\n\n  // DEPRECATED. Please use GetMutableRepeatedFieldRef().\n  //\n  // for T = Cord and all protobuf scalar types except enums.\n  template<typename T>\n  RepeatedField<T>* MutableRepeatedField(\n      Message*, const FieldDescriptor*) const;\n\n  // DEPRECATED. Please use GetRepeatedFieldRef().\n  //\n  // for T = string, google::protobuf::internal::StringPieceField\n  //         google::protobuf::Message & descendants.\n  template<typename T>\n  const RepeatedPtrField<T>& GetRepeatedPtrField(\n      const Message&, const FieldDescriptor*) const;\n\n  // DEPRECATED. Please use GetMutableRepeatedFieldRef().\n  //\n  // for T = string, google::protobuf::internal::StringPieceField\n  //         google::protobuf::Message & descendants.\n  template<typename T>\n  RepeatedPtrField<T>* MutableRepeatedPtrField(\n      Message*, const FieldDescriptor*) const;\n\n  // Extensions ----------------------------------------------------------------\n\n  // Try to find an extension of this message type by fully-qualified field\n  // name.  Returns NULL if no extension is known for this name or number.\n  virtual const FieldDescriptor* FindKnownExtensionByName(\n      const string& name) const = 0;\n\n  // Try to find an extension of this message type by field number.\n  // Returns NULL if no extension is known for this name or number.\n  virtual const FieldDescriptor* FindKnownExtensionByNumber(\n      int number) const = 0;\n\n  // Feature Flags -------------------------------------------------------------\n\n  // Does this message support storing arbitrary integer values in enum fields?\n  // If |true|, GetEnumValue/SetEnumValue and associated repeated-field versions\n  // take arbitrary integer values, and the legacy GetEnum() getter will\n  // dynamically create an EnumValueDescriptor for any integer value without\n  // one. If |false|, setting an unknown enum value via the integer-based\n  // setters results in undefined behavior (in practice, GOOGLE_DCHECK-fails).\n  //\n  // Generic code that uses reflection to handle messages with enum fields\n  // should check this flag before using the integer-based setter, and either\n  // downgrade to a compatible value or use the UnknownFieldSet if not. For\n  // example:\n  //\n  // int new_value = GetValueFromApplicationLogic();\n  // if (reflection->SupportsUnknownEnumValues()) {\n  //     reflection->SetEnumValue(message, field, new_value);\n  // } else {\n  //     if (field_descriptor->enum_type()->\n  //             FindValueByNumver(new_value) != NULL) {\n  //         reflection->SetEnumValue(message, field, new_value);\n  //     } else if (emit_unknown_enum_values) {\n  //         reflection->MutableUnknownFields(message)->AddVarint(\n  //             field->number(),\n  //             new_value);\n  //     } else {\n  //         // convert value to a compatible/default value.\n  //         new_value = CompatibleDowngrade(new_value);\n  //         reflection->SetEnumValue(message, field, new_value);\n  //     }\n  // }\n  virtual bool SupportsUnknownEnumValues() const { return false; }\n\n  // Returns the MessageFactory associated with this message.  This can be\n  // useful for determining if a message is a generated message or not, for\n  // example:\n  //\n  // if (message->GetReflection()->GetMessageFactory() ==\n  //     google::protobuf::MessageFactory::generated_factory()) {\n  //   // This is a generated message.\n  // }\n  //\n  // It can also be used to create more messages of this type, though\n  // Message::New() is an easier way to accomplish this.\n  virtual MessageFactory* GetMessageFactory() const;\n\n  // ---------------------------------------------------------------------------\n\n protected:\n  // Obtain a pointer to a Repeated Field Structure and do some type checking:\n  //   on field->cpp_type(),\n  //   on field->field_option().ctype() (if ctype >= 0)\n  //   of field->message_type() (if message_type != NULL).\n  // We use 2 routine rather than 4 (const vs mutable) x (scalar vs pointer).\n  virtual void* MutableRawRepeatedField(\n      Message* message, const FieldDescriptor* field, FieldDescriptor::CppType,\n      int ctype, const Descriptor* message_type) const = 0;\n\n  // TODO(jieluo) - make it pure virtual after updating all the subclasses.\n  virtual const void* GetRawRepeatedField(\n      const Message& message, const FieldDescriptor* field,\n      FieldDescriptor::CppType cpptype, int ctype,\n      const Descriptor* message_type) const {\n    return MutableRawRepeatedField(\n        const_cast<Message*>(&message), field, cpptype, ctype, message_type);\n  }\n\n  // The following methods are used to implement (Mutable)RepeatedFieldRef.\n  // A Ref object will store a raw pointer to the repeated field data (obtained\n  // from RepeatedFieldData()) and a pointer to a Accessor (obtained from\n  // RepeatedFieldAccessor) which will be used to access the raw data.\n  //\n  // TODO(xiaofeng): Make these methods pure-virtual.\n\n  // Returns a raw pointer to the repeated field\n  //\n  // \"cpp_type\" and \"message_type\" are decuded from the type parameter T passed\n  // to Get(Mutable)RepeatedFieldRef. If T is a generated message type,\n  // \"message_type\" should be set to its descriptor. Otherwise \"message_type\"\n  // should be set to NULL. Implementations of this method should check whether\n  // \"cpp_type\"/\"message_type\" is consistent with the actual type of the field.\n  // We use 1 routine rather than 2 (const vs mutable) because it is protected\n  // and it doesn't change the message.\n  virtual void* RepeatedFieldData(\n      Message* message, const FieldDescriptor* field,\n      FieldDescriptor::CppType cpp_type,\n      const Descriptor* message_type) const;\n\n  // The returned pointer should point to a singleton instance which implements\n  // the RepeatedFieldAccessor interface.\n  virtual const internal::RepeatedFieldAccessor* RepeatedFieldAccessor(\n      const FieldDescriptor* field) const;\n\n private:\n  template<typename T, typename Enable>\n  friend class RepeatedFieldRef;\n  template<typename T, typename Enable>\n  friend class MutableRepeatedFieldRef;\n  friend class ::google::protobuf::python::MapReflectionFriend;\n\n  // Special version for specialized implementations of string.  We can't call\n  // MutableRawRepeatedField directly here because we don't have access to\n  // FieldOptions::* which are defined in descriptor.pb.h.  Including that\n  // file here is not possible because it would cause a circular include cycle.\n  // We use 1 routine rather than 2 (const vs mutable) because it is private\n  // and mutable a repeated string field doesn't change the message.\n  void* MutableRawRepeatedString(\n      Message* message, const FieldDescriptor* field, bool is_string) const;\n\n  friend class MapReflectionTester;\n  // TODO(jieluo) - make the map APIs pure virtual after updating\n  // all the subclasses.\n  // Returns true if key is in map. Returns false if key is not in map field.\n  virtual bool ContainsMapKey(const Message& /* message*/,\n                              const FieldDescriptor* /* field */,\n                              const MapKey& /* key */) const {\n    return false;\n  }\n\n  // If key is in map field: Saves the value pointer to val and returns\n  // false. If key in not in map field: Insert the key into map, saves\n  // value pointer to val and retuns true.\n  virtual bool InsertOrLookupMapValue(Message* /* message */,\n                                      const FieldDescriptor* /* field */,\n                                      const MapKey& /* key */,\n                                      MapValueRef* /* val */) const {\n    return false;\n  }\n\n  // Delete and returns true if key is in the map field. Returns false\n  // otherwise.\n  virtual bool DeleteMapValue(Message* /* mesage */,\n                              const FieldDescriptor* /* field */,\n                              const MapKey& /* key */) const {\n    return false;\n  }\n\n  // Returns a MapIterator referring to the first element in the map field.\n  // If the map field is empty, this function returns the same as\n  // reflection::MapEnd. Mutation to the field may invalidate the iterator.\n  virtual MapIterator MapBegin(\n      Message* message,\n      const FieldDescriptor* field) const;\n\n  // Returns a MapIterator referring to the theoretical element that would\n  // follow the last element in the map field. It does not point to any\n  // real element. Mutation to the field may invalidate the iterator.\n  virtual MapIterator MapEnd(\n      Message* message,\n      const FieldDescriptor* field) const;\n\n  // Get the number of <key, value> pair of a map field. The result may be\n  // different from FieldSize which can have duplicate keys.\n  virtual int MapSize(const Message& /* message */,\n                      const FieldDescriptor* /* field */) const {\n    return 0;\n  }\n\n  // Help method for MapIterator.\n  friend class MapIterator;\n  virtual internal::MapFieldBase* MapData(\n      Message* /* message */, const FieldDescriptor* /* field */) const {\n    return NULL;\n  }\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Reflection);\n};\n\n// Abstract interface for a factory for message objects.\nclass LIBPROTOBUF_EXPORT MessageFactory {\n public:\n  inline MessageFactory() {}\n  virtual ~MessageFactory();\n\n  // Given a Descriptor, gets or constructs the default (prototype) Message\n  // of that type.  You can then call that message's New() method to construct\n  // a mutable message of that type.\n  //\n  // Calling this method twice with the same Descriptor returns the same\n  // object.  The returned object remains property of the factory.  Also, any\n  // objects created by calling the prototype's New() method share some data\n  // with the prototype, so these must be destroyed before the MessageFactory\n  // is destroyed.\n  //\n  // The given descriptor must outlive the returned message, and hence must\n  // outlive the MessageFactory.\n  //\n  // Some implementations do not support all types.  GetPrototype() will\n  // return NULL if the descriptor passed in is not supported.\n  //\n  // This method may or may not be thread-safe depending on the implementation.\n  // Each implementation should document its own degree thread-safety.\n  virtual const Message* GetPrototype(const Descriptor* type) = 0;\n\n  // Gets a MessageFactory which supports all generated, compiled-in messages.\n  // In other words, for any compiled-in type FooMessage, the following is true:\n  //   MessageFactory::generated_factory()->GetPrototype(\n  //     FooMessage::descriptor()) == FooMessage::default_instance()\n  // This factory supports all types which are found in\n  // DescriptorPool::generated_pool().  If given a descriptor from any other\n  // pool, GetPrototype() will return NULL.  (You can also check if a\n  // descriptor is for a generated message by checking if\n  // descriptor->file()->pool() == DescriptorPool::generated_pool().)\n  //\n  // This factory is 100% thread-safe; calling GetPrototype() does not modify\n  // any shared data.\n  //\n  // This factory is a singleton.  The caller must not delete the object.\n  static MessageFactory* generated_factory();\n\n  // For internal use only:  Registers a .proto file at static initialization\n  // time, to be placed in generated_factory.  The first time GetPrototype()\n  // is called with a descriptor from this file, |register_messages| will be\n  // called, with the file name as the parameter.  It must call\n  // InternalRegisterGeneratedMessage() (below) to register each message type\n  // in the file.  This strange mechanism is necessary because descriptors are\n  // built lazily, so we can't register types by their descriptor until we\n  // know that the descriptor exists.  |filename| must be a permanent string.\n  static void InternalRegisterGeneratedFile(\n      const char* filename, void (*register_messages)(const string&));\n\n  // For internal use only:  Registers a message type.  Called only by the\n  // functions which are registered with InternalRegisterGeneratedFile(),\n  // above.\n  static void InternalRegisterGeneratedMessage(const Descriptor* descriptor,\n                                               const Message* prototype);\n\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageFactory);\n};\n\n#define DECLARE_GET_REPEATED_FIELD(TYPE)                         \\\ntemplate<>                                                       \\\nLIBPROTOBUF_EXPORT                                               \\\nconst RepeatedField<TYPE>& Reflection::GetRepeatedField<TYPE>(   \\\n    const Message& message, const FieldDescriptor* field) const; \\\n                                                                 \\\ntemplate<>                                                       \\\nLIBPROTOBUF_EXPORT                                               \\\nRepeatedField<TYPE>* Reflection::MutableRepeatedField<TYPE>(     \\\n    Message* message, const FieldDescriptor* field) const;\n\nDECLARE_GET_REPEATED_FIELD(int32)\nDECLARE_GET_REPEATED_FIELD(int64)\nDECLARE_GET_REPEATED_FIELD(uint32)\nDECLARE_GET_REPEATED_FIELD(uint64)\nDECLARE_GET_REPEATED_FIELD(float)\nDECLARE_GET_REPEATED_FIELD(double)\nDECLARE_GET_REPEATED_FIELD(bool)\n\n#undef DECLARE_GET_REPEATED_FIELD\n\n// =============================================================================\n// Implementation details for {Get,Mutable}RawRepeatedPtrField.  We provide\n// specializations for <string>, <StringPieceField> and <Message> and handle\n// everything else with the default template which will match any type having\n// a method with signature \"static const google::protobuf::Descriptor* descriptor()\".\n// Such a type presumably is a descendant of google::protobuf::Message.\n\ntemplate<>\ninline const RepeatedPtrField<string>& Reflection::GetRepeatedPtrField<string>(\n    const Message& message, const FieldDescriptor* field) const {\n  return *static_cast<RepeatedPtrField<string>* >(\n      MutableRawRepeatedString(const_cast<Message*>(&message), field, true));\n}\n\ntemplate<>\ninline RepeatedPtrField<string>* Reflection::MutableRepeatedPtrField<string>(\n    Message* message, const FieldDescriptor* field) const {\n  return static_cast<RepeatedPtrField<string>* >(\n      MutableRawRepeatedString(message, field, true));\n}\n\n\n// -----\n\ntemplate<>\ninline const RepeatedPtrField<Message>& Reflection::GetRepeatedPtrField(\n    const Message& message, const FieldDescriptor* field) const {\n  return *static_cast<const RepeatedPtrField<Message>* >(\n      GetRawRepeatedField(message, field, FieldDescriptor::CPPTYPE_MESSAGE,\n                          -1, NULL));\n}\n\ntemplate<>\ninline RepeatedPtrField<Message>* Reflection::MutableRepeatedPtrField(\n    Message* message, const FieldDescriptor* field) const {\n  return static_cast<RepeatedPtrField<Message>* >(\n      MutableRawRepeatedField(message, field,\n          FieldDescriptor::CPPTYPE_MESSAGE, -1,\n          NULL));\n}\n\ntemplate<typename PB>\ninline const RepeatedPtrField<PB>& Reflection::GetRepeatedPtrField(\n    const Message& message, const FieldDescriptor* field) const {\n  return *static_cast<const RepeatedPtrField<PB>* >(\n      GetRawRepeatedField(message, field, FieldDescriptor::CPPTYPE_MESSAGE,\n                          -1, PB::default_instance().GetDescriptor()));\n}\n\ntemplate<typename PB>\ninline RepeatedPtrField<PB>* Reflection::MutableRepeatedPtrField(\n    Message* message, const FieldDescriptor* field) const {\n  return static_cast<RepeatedPtrField<PB>* >(\n      MutableRawRepeatedField(message, field,\n          FieldDescriptor::CPPTYPE_MESSAGE, -1,\n          PB::default_instance().GetDescriptor()));\n}\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_MESSAGE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/message_lite.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Authors: wink@google.com (Wink Saville),\n//          kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/message_lite.h>\n#include <google/protobuf/arena.h>\n#include <google/protobuf/repeated_field.h>\n#include <string>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl_lite.h>\n#include <google/protobuf/stubs/stl_util.h>\n\nnamespace google {\nnamespace protobuf {\n\nstring MessageLite::InitializationErrorString() const {\n  return \"(cannot determine missing fields for lite message)\";\n}\n\nnamespace {\n\n// When serializing, we first compute the byte size, then serialize the message.\n// If serialization produces a different number of bytes than expected, we\n// call this function, which crashes.  The problem could be due to a bug in the\n// protobuf implementation but is more likely caused by concurrent modification\n// of the message.  This function attempts to distinguish between the two and\n// provide a useful error message.\nvoid ByteSizeConsistencyError(int byte_size_before_serialization,\n                              int byte_size_after_serialization,\n                              int bytes_produced_by_serialization,\n                              const MessageLite& message) {\n  GOOGLE_CHECK_EQ(byte_size_before_serialization, byte_size_after_serialization)\n      << message.GetTypeName()\n      << \" was modified concurrently during serialization.\";\n  GOOGLE_CHECK_EQ(bytes_produced_by_serialization, byte_size_before_serialization)\n      << \"Byte size calculation and serialization were inconsistent.  This \"\n         \"may indicate a bug in protocol buffers or it may be caused by \"\n         \"concurrent modification of \" << message.GetTypeName() << \".\";\n  GOOGLE_LOG(FATAL) << \"This shouldn't be called if all the sizes are equal.\";\n}\n\nstring InitializationErrorMessage(const char* action,\n                                  const MessageLite& message) {\n  // Note:  We want to avoid depending on strutil in the lite library, otherwise\n  //   we'd use:\n  //\n  // return strings::Substitute(\n  //   \"Can't $0 message of type \\\"$1\\\" because it is missing required \"\n  //   \"fields: $2\",\n  //   action, message.GetTypeName(),\n  //   message.InitializationErrorString());\n\n  string result;\n  result += \"Can't \";\n  result += action;\n  result += \" message of type \\\"\";\n  result += message.GetTypeName();\n  result += \"\\\" because it is missing required fields: \";\n  result += message.InitializationErrorString();\n  return result;\n}\n\n// Several of the Parse methods below just do one thing and then call another\n// method.  In a naive implementation, we might have ParseFromString() call\n// ParseFromArray() which would call ParseFromZeroCopyStream() which would call\n// ParseFromCodedStream() which would call MergeFromCodedStream() which would\n// call MergePartialFromCodedStream().  However, when parsing very small\n// messages, every function call introduces significant overhead.  To avoid\n// this without reproducing code, we use these forced-inline helpers.\nGOOGLE_ATTRIBUTE_ALWAYS_INLINE bool InlineMergeFromCodedStream(\n    io::CodedInputStream* input, MessageLite* message);\nGOOGLE_ATTRIBUTE_ALWAYS_INLINE bool InlineParseFromCodedStream(\n    io::CodedInputStream* input, MessageLite* message);\nGOOGLE_ATTRIBUTE_ALWAYS_INLINE bool InlineParsePartialFromCodedStream(\n    io::CodedInputStream* input, MessageLite* message);\nGOOGLE_ATTRIBUTE_ALWAYS_INLINE bool InlineParseFromArray(\n    const void* data, int size, MessageLite* message);\nGOOGLE_ATTRIBUTE_ALWAYS_INLINE bool InlineParsePartialFromArray(\n    const void* data, int size, MessageLite* message);\n\ninline bool InlineMergeFromCodedStream(io::CodedInputStream* input,\n                                       MessageLite* message) {\n  if (!message->MergePartialFromCodedStream(input)) return false;\n  if (!message->IsInitialized()) {\n    GOOGLE_LOG(ERROR) << InitializationErrorMessage(\"parse\", *message);\n    return false;\n  }\n  return true;\n}\n\ninline bool InlineParseFromCodedStream(io::CodedInputStream* input,\n                                       MessageLite* message) {\n  message->Clear();\n  return InlineMergeFromCodedStream(input, message);\n}\n\ninline bool InlineParsePartialFromCodedStream(io::CodedInputStream* input,\n                                              MessageLite* message) {\n  message->Clear();\n  return message->MergePartialFromCodedStream(input);\n}\n\ninline bool InlineParseFromArray(\n    const void* data, int size, MessageLite* message) {\n  io::CodedInputStream input(reinterpret_cast<const uint8*>(data), size);\n  return InlineParseFromCodedStream(&input, message) &&\n         input.ConsumedEntireMessage();\n}\n\ninline bool InlineParsePartialFromArray(\n    const void* data, int size, MessageLite* message) {\n  io::CodedInputStream input(reinterpret_cast<const uint8*>(data), size);\n  return InlineParsePartialFromCodedStream(&input, message) &&\n         input.ConsumedEntireMessage();\n}\n\n}  // namespace\n\n\nMessageLite* MessageLite::New(::google::protobuf::Arena* arena) const {\n  MessageLite* message = New();\n  if (arena != NULL) {\n    arena->Own(message);\n  }\n  return message;\n}\n\nbool MessageLite::MergeFromCodedStream(io::CodedInputStream* input) {\n  return InlineMergeFromCodedStream(input, this);\n}\n\nbool MessageLite::ParseFromCodedStream(io::CodedInputStream* input) {\n  return InlineParseFromCodedStream(input, this);\n}\n\nbool MessageLite::ParsePartialFromCodedStream(io::CodedInputStream* input) {\n  return InlineParsePartialFromCodedStream(input, this);\n}\n\nbool MessageLite::ParseFromZeroCopyStream(io::ZeroCopyInputStream* input) {\n  io::CodedInputStream decoder(input);\n  return ParseFromCodedStream(&decoder) && decoder.ConsumedEntireMessage();\n}\n\nbool MessageLite::ParsePartialFromZeroCopyStream(\n    io::ZeroCopyInputStream* input) {\n  io::CodedInputStream decoder(input);\n  return ParsePartialFromCodedStream(&decoder) &&\n         decoder.ConsumedEntireMessage();\n}\n\nbool MessageLite::ParseFromBoundedZeroCopyStream(\n    io::ZeroCopyInputStream* input, int size) {\n  io::CodedInputStream decoder(input);\n  decoder.PushLimit(size);\n  return ParseFromCodedStream(&decoder) &&\n         decoder.ConsumedEntireMessage() &&\n         decoder.BytesUntilLimit() == 0;\n}\n\nbool MessageLite::ParsePartialFromBoundedZeroCopyStream(\n    io::ZeroCopyInputStream* input, int size) {\n  io::CodedInputStream decoder(input);\n  decoder.PushLimit(size);\n  return ParsePartialFromCodedStream(&decoder) &&\n         decoder.ConsumedEntireMessage() &&\n         decoder.BytesUntilLimit() == 0;\n}\n\nbool MessageLite::ParseFromString(const string& data) {\n  return InlineParseFromArray(data.data(), data.size(), this);\n}\n\nbool MessageLite::ParsePartialFromString(const string& data) {\n  return InlineParsePartialFromArray(data.data(), data.size(), this);\n}\n\nbool MessageLite::ParseFromArray(const void* data, int size) {\n  return InlineParseFromArray(data, size, this);\n}\n\nbool MessageLite::ParsePartialFromArray(const void* data, int size) {\n  return InlineParsePartialFromArray(data, size, this);\n}\n\n\n// ===================================================================\n\nuint8* MessageLite::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, uint8* target) const {\n  // We only optimize this when using optimize_for = SPEED.  In other cases\n  // we just use the CodedOutputStream path.\n  int size = GetCachedSize();\n  io::ArrayOutputStream out(target, size);\n  io::CodedOutputStream coded_out(&out);\n  SerializeWithCachedSizes(&coded_out);\n  GOOGLE_CHECK(!coded_out.HadError());\n  return target + size;\n}\n\nbool MessageLite::SerializeToCodedStream(io::CodedOutputStream* output) const {\n  GOOGLE_DCHECK(IsInitialized()) << InitializationErrorMessage(\"serialize\", *this);\n  return SerializePartialToCodedStream(output);\n}\n\nbool MessageLite::SerializePartialToCodedStream(\n    io::CodedOutputStream* output) const {\n  const int size = ByteSize();  // Force size to be cached.\n  if (size < 0) {\n    // Messages >2G cannot be serialized due to overflow computing ByteSize.\n    GOOGLE_LOG(ERROR) << \"Error computing ByteSize (possible overflow?).\";\n    return false;\n  }\n\n  uint8* buffer = output->GetDirectBufferForNBytesAndAdvance(size);\n  if (buffer != NULL) {\n    uint8* end = SerializeWithCachedSizesToArray(buffer);\n    if (end - buffer != size) {\n      ByteSizeConsistencyError(size, ByteSize(), end - buffer, *this);\n    }\n    return true;\n  } else {\n    int original_byte_count = output->ByteCount();\n    SerializeWithCachedSizes(output);\n    if (output->HadError()) {\n      return false;\n    }\n    int final_byte_count = output->ByteCount();\n\n    if (final_byte_count - original_byte_count != size) {\n      ByteSizeConsistencyError(size, ByteSize(),\n                               final_byte_count - original_byte_count, *this);\n    }\n\n    return true;\n  }\n}\n\nbool MessageLite::SerializeToZeroCopyStream(\n    io::ZeroCopyOutputStream* output) const {\n  io::CodedOutputStream encoder(output);\n  return SerializeToCodedStream(&encoder);\n}\n\nbool MessageLite::SerializePartialToZeroCopyStream(\n    io::ZeroCopyOutputStream* output) const {\n  io::CodedOutputStream encoder(output);\n  return SerializePartialToCodedStream(&encoder);\n}\n\nbool MessageLite::AppendToString(string* output) const {\n  GOOGLE_DCHECK(IsInitialized()) << InitializationErrorMessage(\"serialize\", *this);\n  return AppendPartialToString(output);\n}\n\nbool MessageLite::AppendPartialToString(string* output) const {\n  int old_size = output->size();\n  int byte_size = ByteSize();\n  if (byte_size < 0) {\n    // Messages >2G cannot be serialized due to overflow computing ByteSize.\n    GOOGLE_LOG(ERROR) << \"Error computing ByteSize (possible overflow?).\";\n    return false;\n  }\n\n  STLStringResizeUninitialized(output, old_size + byte_size);\n  uint8* start =\n      reinterpret_cast<uint8*>(io::mutable_string_data(output) + old_size);\n  uint8* end = SerializeWithCachedSizesToArray(start);\n  if (end - start != byte_size) {\n    ByteSizeConsistencyError(byte_size, ByteSize(), end - start, *this);\n  }\n  return true;\n}\n\nbool MessageLite::SerializeToString(string* output) const {\n  output->clear();\n  return AppendToString(output);\n}\n\nbool MessageLite::SerializePartialToString(string* output) const {\n  output->clear();\n  return AppendPartialToString(output);\n}\n\nbool MessageLite::SerializeToArray(void* data, int size) const {\n  GOOGLE_DCHECK(IsInitialized()) << InitializationErrorMessage(\"serialize\", *this);\n  return SerializePartialToArray(data, size);\n}\n\nbool MessageLite::SerializePartialToArray(void* data, int size) const {\n  int byte_size = ByteSize();\n  if (size < byte_size) return false;\n  uint8* start = reinterpret_cast<uint8*>(data);\n  uint8* end = SerializeWithCachedSizesToArray(start);\n  if (end - start != byte_size) {\n    ByteSizeConsistencyError(byte_size, ByteSize(), end - start, *this);\n  }\n  return true;\n}\n\nstring MessageLite::SerializeAsString() const {\n  // If the compiler implements the (Named) Return Value Optimization,\n  // the local variable 'output' will not actually reside on the stack\n  // of this function, but will be overlaid with the object that the\n  // caller supplied for the return value to be constructed in.\n  string output;\n  if (!AppendToString(&output))\n    output.clear();\n  return output;\n}\n\nstring MessageLite::SerializePartialAsString() const {\n  string output;\n  if (!AppendPartialToString(&output))\n    output.clear();\n  return output;\n}\n\nnamespace internal {\ntemplate<>\nMessageLite* GenericTypeHandler<MessageLite>::NewFromPrototype(\n    const MessageLite* prototype, google::protobuf::Arena* arena) {\n  return prototype->New(arena);\n}\ntemplate <>\nvoid GenericTypeHandler<MessageLite>::Merge(const MessageLite& from,\n                                            MessageLite* to) {\n  to->CheckTypeAndMergeFrom(from);\n}\ntemplate<>\nvoid GenericTypeHandler<string>::Merge(const string& from,\n                                              string* to) {\n  *to = from;\n}\n}  // namespace internal\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/message_lite.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Authors: wink@google.com (Wink Saville),\n//          kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Defines MessageLite, the abstract interface implemented by all (lite\n// and non-lite) protocol message objects.\n\n#ifndef GOOGLE_PROTOBUF_MESSAGE_LITE_H__\n#define GOOGLE_PROTOBUF_MESSAGE_LITE_H__\n\n#include <google/protobuf/stubs/common.h>\n\n\nnamespace google {\nnamespace protobuf {\n  class Arena;\nnamespace io {\n  class CodedInputStream;\n  class CodedOutputStream;\n  class ZeroCopyInputStream;\n  class ZeroCopyOutputStream;\n}\nnamespace internal {\n  class WireFormatLite;\n}\n\n// Interface to light weight protocol messages.\n//\n// This interface is implemented by all protocol message objects.  Non-lite\n// messages additionally implement the Message interface, which is a\n// subclass of MessageLite.  Use MessageLite instead when you only need\n// the subset of features which it supports -- namely, nothing that uses\n// descriptors or reflection.  You can instruct the protocol compiler\n// to generate classes which implement only MessageLite, not the full\n// Message interface, by adding the following line to the .proto file:\n//\n//   option optimize_for = LITE_RUNTIME;\n//\n// This is particularly useful on resource-constrained systems where\n// the full protocol buffers runtime library is too big.\n//\n// Note that on non-constrained systems (e.g. servers) when you need\n// to link in lots of protocol definitions, a better way to reduce\n// total code footprint is to use optimize_for = CODE_SIZE.  This\n// will make the generated code smaller while still supporting all the\n// same features (at the expense of speed).  optimize_for = LITE_RUNTIME\n// is best when you only have a small number of message types linked\n// into your binary, in which case the size of the protocol buffers\n// runtime itself is the biggest problem.\nclass LIBPROTOBUF_EXPORT MessageLite {\n public:\n  inline MessageLite() {}\n  virtual ~MessageLite() {}\n\n  // Basic Operations ------------------------------------------------\n\n  // Get the name of this message type, e.g. \"foo.bar.BazProto\".\n  virtual string GetTypeName() const = 0;\n\n  // Construct a new instance of the same type.  Ownership is passed to the\n  // caller.\n  virtual MessageLite* New() const = 0;\n\n  // Construct a new instance on the arena. Ownership is passed to the caller\n  // if arena is a NULL. Default implementation for backwards compatibility.\n  virtual MessageLite* New(::google::protobuf::Arena* arena) const;\n\n  // Get the arena, if any, associated with this message. Virtual method\n  // required for generic operations but most arena-related operations should\n  // use the GetArenaNoVirtual() generated-code method. Default implementation\n  // to reduce code size by avoiding the need for per-type implementations when\n  // types do not implement arena support.\n  virtual ::google::protobuf::Arena* GetArena() const { return NULL; }\n\n  // Get a pointer that may be equal to this message's arena, or may not be. If\n  // the value returned by this method is equal to some arena pointer, then this\n  // message is on that arena; however, if this message is on some arena, this\n  // method may or may not return that arena's pointer. As a tradeoff, this\n  // method may be more efficient than GetArena(). The intent is to allow\n  // underlying representations that use e.g. tagged pointers to sometimes store\n  // the arena pointer directly, and sometimes in a more indirect way, and allow\n  // a fastpath comparison against the arena pointer when it's easy to obtain.\n  virtual void* GetMaybeArenaPointer() const { return GetArena(); }\n\n  // Clear all fields of the message and set them to their default values.\n  // Clear() avoids freeing memory, assuming that any memory allocated\n  // to hold parts of the message will be needed again to hold the next\n  // message.  If you actually want to free the memory used by a Message,\n  // you must delete it.\n  virtual void Clear() = 0;\n\n  // Quickly check if all required fields have values set.\n  virtual bool IsInitialized() const = 0;\n\n  // This is not implemented for Lite messages -- it just returns \"(cannot\n  // determine missing fields for lite message)\".  However, it is implemented\n  // for full messages.  See message.h.\n  virtual string InitializationErrorString() const;\n\n  // If |other| is the exact same class as this, calls MergeFrom().  Otherwise,\n  // results are undefined (probably crash).\n  virtual void CheckTypeAndMergeFrom(const MessageLite& other) = 0;\n\n  // Parsing ---------------------------------------------------------\n  // Methods for parsing in protocol buffer format.  Most of these are\n  // just simple wrappers around MergeFromCodedStream().  Clear() will be called\n  // before merging the input.\n\n  // Fill the message with a protocol buffer parsed from the given input stream.\n  // Returns false on a read error or if the input is in the wrong format.  A\n  // successful return does not indicate the entire input is consumed, ensure\n  // you call ConsumedEntireMessage() to check that if applicable.\n  bool ParseFromCodedStream(io::CodedInputStream* input);\n  // Like ParseFromCodedStream(), but accepts messages that are missing\n  // required fields.\n  bool ParsePartialFromCodedStream(io::CodedInputStream* input);\n  // Read a protocol buffer from the given zero-copy input stream.  If\n  // successful, the entire input will be consumed.\n  bool ParseFromZeroCopyStream(io::ZeroCopyInputStream* input);\n  // Like ParseFromZeroCopyStream(), but accepts messages that are missing\n  // required fields.\n  bool ParsePartialFromZeroCopyStream(io::ZeroCopyInputStream* input);\n  // Read a protocol buffer from the given zero-copy input stream, expecting\n  // the message to be exactly \"size\" bytes long.  If successful, exactly\n  // this many bytes will have been consumed from the input.\n  bool ParseFromBoundedZeroCopyStream(io::ZeroCopyInputStream* input, int size);\n  // Like ParseFromBoundedZeroCopyStream(), but accepts messages that are\n  // missing required fields.\n  bool ParsePartialFromBoundedZeroCopyStream(io::ZeroCopyInputStream* input,\n                                             int size);\n  // Parses a protocol buffer contained in a string. Returns true on success.\n  // This function takes a string in the (non-human-readable) binary wire\n  // format, matching the encoding output by MessageLite::SerializeToString().\n  // If you'd like to convert a human-readable string into a protocol buffer\n  // object, see google::protobuf::TextFormat::ParseFromString().\n  bool ParseFromString(const string& data);\n  // Like ParseFromString(), but accepts messages that are missing\n  // required fields.\n  bool ParsePartialFromString(const string& data);\n  // Parse a protocol buffer contained in an array of bytes.\n  bool ParseFromArray(const void* data, int size);\n  // Like ParseFromArray(), but accepts messages that are missing\n  // required fields.\n  bool ParsePartialFromArray(const void* data, int size);\n\n\n  // Reads a protocol buffer from the stream and merges it into this\n  // Message.  Singular fields read from the input overwrite what is\n  // already in the Message and repeated fields are appended to those\n  // already present.\n  //\n  // It is the responsibility of the caller to call input->LastTagWas()\n  // (for groups) or input->ConsumedEntireMessage() (for non-groups) after\n  // this returns to verify that the message's end was delimited correctly.\n  //\n  // ParsefromCodedStream() is implemented as Clear() followed by\n  // MergeFromCodedStream().\n  bool MergeFromCodedStream(io::CodedInputStream* input);\n\n  // Like MergeFromCodedStream(), but succeeds even if required fields are\n  // missing in the input.\n  //\n  // MergeFromCodedStream() is just implemented as MergePartialFromCodedStream()\n  // followed by IsInitialized().\n  virtual bool MergePartialFromCodedStream(io::CodedInputStream* input) = 0;\n\n\n  // Serialization ---------------------------------------------------\n  // Methods for serializing in protocol buffer format.  Most of these\n  // are just simple wrappers around ByteSize() and SerializeWithCachedSizes().\n\n  // Write a protocol buffer of this message to the given output.  Returns\n  // false on a write error.  If the message is missing required fields,\n  // this may GOOGLE_CHECK-fail.\n  bool SerializeToCodedStream(io::CodedOutputStream* output) const;\n  // Like SerializeToCodedStream(), but allows missing required fields.\n  bool SerializePartialToCodedStream(io::CodedOutputStream* output) const;\n  // Write the message to the given zero-copy output stream.  All required\n  // fields must be set.\n  bool SerializeToZeroCopyStream(io::ZeroCopyOutputStream* output) const;\n  // Like SerializeToZeroCopyStream(), but allows missing required fields.\n  bool SerializePartialToZeroCopyStream(io::ZeroCopyOutputStream* output) const;\n  // Serialize the message and store it in the given string.  All required\n  // fields must be set.\n  bool SerializeToString(string* output) const;\n  // Like SerializeToString(), but allows missing required fields.\n  bool SerializePartialToString(string* output) const;\n  // Serialize the message and store it in the given byte array.  All required\n  // fields must be set.\n  bool SerializeToArray(void* data, int size) const;\n  // Like SerializeToArray(), but allows missing required fields.\n  bool SerializePartialToArray(void* data, int size) const;\n\n  // Make a string encoding the message. Is equivalent to calling\n  // SerializeToString() on a string and using that.  Returns the empty\n  // string if SerializeToString() would have returned an error.\n  // Note: If you intend to generate many such strings, you may\n  // reduce heap fragmentation by instead re-using the same string\n  // object with calls to SerializeToString().\n  string SerializeAsString() const;\n  // Like SerializeAsString(), but allows missing required fields.\n  string SerializePartialAsString() const;\n\n  // Like SerializeToString(), but appends to the data to the string's existing\n  // contents.  All required fields must be set.\n  bool AppendToString(string* output) const;\n  // Like AppendToString(), but allows missing required fields.\n  bool AppendPartialToString(string* output) const;\n\n  // Computes the serialized size of the message.  This recursively calls\n  // ByteSize() on all embedded messages.  If a subclass does not override\n  // this, it MUST override SetCachedSize().\n  //\n  // ByteSize() is generally linear in the number of fields defined for the\n  // proto.\n  virtual int ByteSize() const = 0;\n\n  // Serializes the message without recomputing the size.  The message must\n  // not have changed since the last call to ByteSize(); if it has, the results\n  // are undefined.\n  virtual void SerializeWithCachedSizes(\n      io::CodedOutputStream* output) const = 0;\n\n  // A version of SerializeWithCachedSizesToArray, below, that does\n  // not guarantee deterministic serialization.\n  virtual uint8* SerializeWithCachedSizesToArray(uint8* target) const {\n    return InternalSerializeWithCachedSizesToArray(false, target);\n  }\n\n  // Returns the result of the last call to ByteSize().  An embedded message's\n  // size is needed both to serialize it (because embedded messages are\n  // length-delimited) and to compute the outer message's size.  Caching\n  // the size avoids computing it multiple times.\n  //\n  // ByteSize() does not automatically use the cached size when available\n  // because this would require invalidating it every time the message was\n  // modified, which would be too hard and expensive.  (E.g. if a deeply-nested\n  // sub-message is changed, all of its parents' cached sizes would need to be\n  // invalidated, which is too much work for an otherwise inlined setter\n  // method.)\n  virtual int GetCachedSize() const = 0;\n\n  // Functions below here are not part of the public interface.  It isn't\n  // enforced, but they should be treated as private, and will be private\n  // at some future time.  Unfortunately the implementation of the \"friend\"\n  // keyword in GCC is broken at the moment, but we expect it will be fixed.\n\n  // Like SerializeWithCachedSizes, but writes directly to *target, returning\n  // a pointer to the byte immediately after the last byte written.  \"target\"\n  // must point at a byte array of at least ByteSize() bytes.  If deterministic\n  // is true then we use deterministic serialization, e.g., map keys are sorted.\n  // FOR INTERNAL USE ONLY!\n  virtual uint8* InternalSerializeWithCachedSizesToArray(bool deterministic,\n                                                         uint8* target) const;\n\n private:\n  friend class internal::WireFormatLite;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageLite);\n};\n\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_MESSAGE_LITE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/message_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/message.h>\n\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n#ifdef _MSC_VER\n#include <io.h>\n#else\n#include <unistd.h>\n#endif\n#include <sstream>\n#include <fstream>\n\n#include <google/protobuf/test_util.h>\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/generated_message_reflection.h>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\n\n#ifndef O_BINARY\n#ifdef _O_BINARY\n#define O_BINARY _O_BINARY\n#else\n#define O_BINARY 0     // If this isn't defined, the platform doesn't need it.\n#endif\n#endif\n\nTEST(MessageTest, SerializeHelpers) {\n  // TODO(kenton):  Test more helpers?  They're all two-liners so it seems\n  //   like a waste of time.\n\n  protobuf_unittest::TestAllTypes message;\n  TestUtil::SetAllFields(&message);\n  stringstream stream;\n\n  string str1(\"foo\");\n  string str2(\"bar\");\n\n  EXPECT_TRUE(message.SerializeToString(&str1));\n  EXPECT_TRUE(message.AppendToString(&str2));\n  EXPECT_TRUE(message.SerializeToOstream(&stream));\n\n  EXPECT_EQ(str1.size() + 3, str2.size());\n  EXPECT_EQ(\"bar\", str2.substr(0, 3));\n  // Don't use EXPECT_EQ because we don't want to dump raw binary data to\n  // stdout.\n  EXPECT_TRUE(str2.substr(3) == str1);\n\n  // GCC gives some sort of error if we try to just do stream.str() == str1.\n  string temp = stream.str();\n  EXPECT_TRUE(temp == str1);\n\n  EXPECT_TRUE(message.SerializeAsString() == str1);\n\n}\n\nTEST(MessageTest, SerializeToBrokenOstream) {\n  ofstream out;\n  protobuf_unittest::TestAllTypes message;\n  message.set_optional_int32(123);\n\n  EXPECT_FALSE(message.SerializeToOstream(&out));\n}\n\nTEST(MessageTest, ParseFromFileDescriptor) {\n  string filename = TestSourceDir() +\n                    \"/google/protobuf/testdata/golden_message\";\n  int file = open(filename.c_str(), O_RDONLY | O_BINARY);\n\n  unittest::TestAllTypes message;\n  EXPECT_TRUE(message.ParseFromFileDescriptor(file));\n  TestUtil::ExpectAllFieldsSet(message);\n\n  EXPECT_GE(close(file), 0);\n}\n\nTEST(MessageTest, ParsePackedFromFileDescriptor) {\n  string filename =\n      TestSourceDir() +\n      \"/google/protobuf/testdata/golden_packed_fields_message\";\n  int file = open(filename.c_str(), O_RDONLY | O_BINARY);\n\n  unittest::TestPackedTypes message;\n  EXPECT_TRUE(message.ParseFromFileDescriptor(file));\n  TestUtil::ExpectPackedFieldsSet(message);\n\n  EXPECT_GE(close(file), 0);\n}\n\nTEST(MessageTest, ParseHelpers) {\n  // TODO(kenton):  Test more helpers?  They're all two-liners so it seems\n  //   like a waste of time.\n  string data;\n\n  {\n    // Set up.\n    protobuf_unittest::TestAllTypes message;\n    TestUtil::SetAllFields(&message);\n    message.SerializeToString(&data);\n  }\n\n  {\n    // Test ParseFromString.\n    protobuf_unittest::TestAllTypes message;\n    EXPECT_TRUE(message.ParseFromString(data));\n    TestUtil::ExpectAllFieldsSet(message);\n  }\n\n  {\n    // Test ParseFromIstream.\n    protobuf_unittest::TestAllTypes message;\n    stringstream stream(data);\n    EXPECT_TRUE(message.ParseFromIstream(&stream));\n    EXPECT_TRUE(stream.eof());\n    TestUtil::ExpectAllFieldsSet(message);\n  }\n\n  {\n    // Test ParseFromBoundedZeroCopyStream.\n    string data_with_junk(data);\n    data_with_junk.append(\"some junk on the end\");\n    io::ArrayInputStream stream(data_with_junk.data(), data_with_junk.size());\n    protobuf_unittest::TestAllTypes message;\n    EXPECT_TRUE(message.ParseFromBoundedZeroCopyStream(&stream, data.size()));\n    TestUtil::ExpectAllFieldsSet(message);\n  }\n\n  {\n    // Test that ParseFromBoundedZeroCopyStream fails (but doesn't crash) if\n    // EOF is reached before the expected number of bytes.\n    io::ArrayInputStream stream(data.data(), data.size());\n    protobuf_unittest::TestAllTypes message;\n    EXPECT_FALSE(\n      message.ParseFromBoundedZeroCopyStream(&stream, data.size() + 1));\n  }\n}\n\nTEST(MessageTest, ParseFailsIfNotInitialized) {\n  unittest::TestRequired message;\n  vector<string> errors;\n\n  {\n    ScopedMemoryLog log;\n    EXPECT_FALSE(message.ParseFromString(\"\"));\n    errors = log.GetMessages(ERROR);\n  }\n\n  ASSERT_EQ(1, errors.size());\n  EXPECT_EQ(\"Can't parse message of type \\\"protobuf_unittest.TestRequired\\\" \"\n            \"because it is missing required fields: a, b, c\",\n            errors[0]);\n}\n\nTEST(MessageTest, BypassInitializationCheckOnParse) {\n  unittest::TestRequired message;\n  io::ArrayInputStream raw_input(NULL, 0);\n  io::CodedInputStream input(&raw_input);\n  EXPECT_TRUE(message.MergePartialFromCodedStream(&input));\n}\n\nTEST(MessageTest, InitializationErrorString) {\n  unittest::TestRequired message;\n  EXPECT_EQ(\"a, b, c\", message.InitializationErrorString());\n}\n\nTEST(MessageTest, DynamicCastToGenerated) {\n  unittest::TestAllTypes test_all_types;\n\n  google::protobuf::Message* test_all_types_pointer = &test_all_types;\n  EXPECT_EQ(&test_all_types,\n            google::protobuf::internal::DynamicCastToGenerated<unittest::TestAllTypes>(\n                test_all_types_pointer));\n  EXPECT_EQ(NULL,\n            google::protobuf::internal::DynamicCastToGenerated<unittest::TestRequired>(\n                test_all_types_pointer));\n\n  const google::protobuf::Message* test_all_types_pointer_const = &test_all_types;\n  EXPECT_EQ(\n      &test_all_types,\n      google::protobuf::internal::DynamicCastToGenerated<const unittest::TestAllTypes>(\n          test_all_types_pointer_const));\n  EXPECT_EQ(\n      NULL,\n      google::protobuf::internal::DynamicCastToGenerated<const unittest::TestRequired>(\n          test_all_types_pointer_const));\n}\n\n#ifdef PROTOBUF_HAS_DEATH_TEST  // death tests do not work on Windows yet.\n\nTEST(MessageTest, SerializeFailsIfNotInitialized) {\n  unittest::TestRequired message;\n  string data;\n  EXPECT_DEBUG_DEATH(EXPECT_TRUE(message.SerializeToString(&data)),\n    \"Can't serialize message of type \\\"protobuf_unittest.TestRequired\\\" because \"\n    \"it is missing required fields: a, b, c\");\n}\n\nTEST(MessageTest, CheckInitialized) {\n  unittest::TestRequired message;\n  EXPECT_DEATH(message.CheckInitialized(),\n    \"Message of type \\\"protobuf_unittest.TestRequired\\\" is missing required \"\n    \"fields: a, b, c\");\n}\n\nTEST(MessageTest, CheckOverflow) {\n  unittest::TestAllTypes message;\n  // Create a message with size just over 2GB. This triggers integer overflow\n  // when computing message size.\n  const string data(1024, 'x');\n  Cord one_megabyte;\n  for (int i = 0; i < 1024; i++) {\n    one_megabyte.Append(data);\n  }\n\n  for (int i = 0; i < 2 * 1024 + 1; ++i) {\n    message.add_repeated_cord()->CopyFrom(one_megabyte);\n  }\n\n  Cord serialized;\n  EXPECT_FALSE(message.AppendToCord(&serialized));\n}\n\n#endif  // PROTOBUF_HAS_DEATH_TEST\n\nnamespace {\n\nclass NegativeByteSize : public unittest::TestRequired {\n public:\n  virtual int ByteSize() const { return -1; }\n};\n\n}  // namespace\n\nTEST(MessageTest, SerializationFailsOnNegativeByteSize) {\n  NegativeByteSize message;\n  string string_output;\n  EXPECT_FALSE(message.AppendPartialToString(&string_output));\n\n  io::ArrayOutputStream coded_raw_output(NULL, 100);\n  io::CodedOutputStream coded_output(&coded_raw_output);\n  EXPECT_FALSE(message.SerializePartialToCodedStream(&coded_output));\n}\n\nTEST(MessageTest, BypassInitializationCheckOnSerialize) {\n  unittest::TestRequired message;\n  io::ArrayOutputStream raw_output(NULL, 0);\n  io::CodedOutputStream output(&raw_output);\n  EXPECT_TRUE(message.SerializePartialToCodedStream(&output));\n}\n\nTEST(MessageTest, FindInitializationErrors) {\n  unittest::TestRequired message;\n  vector<string> errors;\n  message.FindInitializationErrors(&errors);\n  ASSERT_EQ(3, errors.size());\n  EXPECT_EQ(\"a\", errors[0]);\n  EXPECT_EQ(\"b\", errors[1]);\n  EXPECT_EQ(\"c\", errors[2]);\n}\n\nTEST(MessageTest, ParseFailsOnInvalidMessageEnd) {\n  unittest::TestAllTypes message;\n\n  // Control case.\n  EXPECT_TRUE(message.ParseFromArray(\"\", 0));\n\n  // The byte is a valid varint, but not a valid tag (zero).\n  EXPECT_FALSE(message.ParseFromArray(\"\\0\", 1));\n\n  // The byte is a malformed varint.\n  EXPECT_FALSE(message.ParseFromArray(\"\\200\", 1));\n\n  // The byte is an endgroup tag, but we aren't parsing a group.\n  EXPECT_FALSE(message.ParseFromArray(\"\\014\", 1));\n}\n\nnamespace {\n\nvoid ExpectMessageMerged(const unittest::TestAllTypes& message) {\n  EXPECT_EQ(3, message.optional_int32());\n  EXPECT_EQ(2, message.optional_int64());\n  EXPECT_EQ(\"hello\", message.optional_string());\n}\n\nvoid AssignParsingMergeMessages(\n    unittest::TestAllTypes* msg1,\n    unittest::TestAllTypes* msg2,\n    unittest::TestAllTypes* msg3) {\n  msg1->set_optional_int32(1);\n  msg2->set_optional_int64(2);\n  msg3->set_optional_int32(3);\n  msg3->set_optional_string(\"hello\");\n}\n\n}  // namespace\n\n// Test that if an optional or required message/group field appears multiple\n// times in the input, they need to be merged.\nTEST(MessageTest, ParsingMerge) {\n  unittest::TestParsingMerge::RepeatedFieldsGenerator generator;\n  unittest::TestAllTypes* msg1;\n  unittest::TestAllTypes* msg2;\n  unittest::TestAllTypes* msg3;\n\n#define ASSIGN_REPEATED_FIELD(FIELD)                \\\n  msg1 = generator.add_##FIELD();                   \\\n  msg2 = generator.add_##FIELD();                   \\\n  msg3 = generator.add_##FIELD();                   \\\n  AssignParsingMergeMessages(msg1, msg2, msg3)\n\n  ASSIGN_REPEATED_FIELD(field1);\n  ASSIGN_REPEATED_FIELD(field2);\n  ASSIGN_REPEATED_FIELD(field3);\n  ASSIGN_REPEATED_FIELD(ext1);\n  ASSIGN_REPEATED_FIELD(ext2);\n\n#undef ASSIGN_REPEATED_FIELD\n#define ASSIGN_REPEATED_GROUP(FIELD)                \\\n  msg1 = generator.add_##FIELD()->mutable_field1(); \\\n  msg2 = generator.add_##FIELD()->mutable_field1(); \\\n  msg3 = generator.add_##FIELD()->mutable_field1(); \\\n  AssignParsingMergeMessages(msg1, msg2, msg3)\n\n  ASSIGN_REPEATED_GROUP(group1);\n  ASSIGN_REPEATED_GROUP(group2);\n\n#undef ASSIGN_REPEATED_GROUP\n\n  string buffer;\n  generator.SerializeToString(&buffer);\n  unittest::TestParsingMerge parsing_merge;\n  parsing_merge.ParseFromString(buffer);\n\n  // Required and optional fields should be merged.\n  ExpectMessageMerged(parsing_merge.required_all_types());\n  ExpectMessageMerged(parsing_merge.optional_all_types());\n  ExpectMessageMerged(\n      parsing_merge.optionalgroup().optional_group_all_types());\n  ExpectMessageMerged(\n      parsing_merge.GetExtension(unittest::TestParsingMerge::optional_ext));\n\n  // Repeated fields should not be merged.\n  EXPECT_EQ(3, parsing_merge.repeated_all_types_size());\n  EXPECT_EQ(3, parsing_merge.repeatedgroup_size());\n  EXPECT_EQ(3, parsing_merge.ExtensionSize(\n      unittest::TestParsingMerge::repeated_ext));\n}\n\nTEST(MessageTest, MergeFrom) {\n  unittest::TestAllTypes source;\n  unittest::TestAllTypes dest;\n\n  // Optional fields\n  source.set_optional_int32(1);  // only source\n  source.set_optional_int64(2);  // both source and dest\n  dest.set_optional_int64(3);\n  dest.set_optional_uint32(4);   // only dest\n\n  // Optional fields with defaults\n  source.set_default_int32(13);  // only source\n  source.set_default_int64(14);  // both source and dest\n  dest.set_default_int64(15);\n  dest.set_default_uint32(16);   // only dest\n\n  // Repeated fields\n  source.add_repeated_int32(5);  // only source\n  source.add_repeated_int32(6);\n  source.add_repeated_int64(7);  // both source and dest\n  source.add_repeated_int64(8);\n  dest.add_repeated_int64(9);\n  dest.add_repeated_int64(10);\n  dest.add_repeated_uint32(11);  // only dest\n  dest.add_repeated_uint32(12);\n\n  dest.MergeFrom(source);\n\n  // Optional fields: source overwrites dest if source is specified\n  EXPECT_EQ(1, dest.optional_int32());  // only source: use source\n  EXPECT_EQ(2, dest.optional_int64());  // source and dest: use source\n  EXPECT_EQ(4, dest.optional_uint32());  // only dest: use dest\n  EXPECT_EQ(0, dest.optional_uint64());  // neither: use default\n\n  // Optional fields with defaults\n  EXPECT_EQ(13, dest.default_int32());  // only source: use source\n  EXPECT_EQ(14, dest.default_int64());  // source and dest: use source\n  EXPECT_EQ(16, dest.default_uint32());  // only dest: use dest\n  EXPECT_EQ(44, dest.default_uint64());  // neither: use default\n\n  // Repeated fields: concatenate source onto the end of dest\n  ASSERT_EQ(2, dest.repeated_int32_size());\n  EXPECT_EQ(5, dest.repeated_int32(0));\n  EXPECT_EQ(6, dest.repeated_int32(1));\n  ASSERT_EQ(4, dest.repeated_int64_size());\n  EXPECT_EQ(9,  dest.repeated_int64(0));\n  EXPECT_EQ(10, dest.repeated_int64(1));\n  EXPECT_EQ(7,  dest.repeated_int64(2));\n  EXPECT_EQ(8,  dest.repeated_int64(3));\n  ASSERT_EQ(2, dest.repeated_uint32_size());\n  EXPECT_EQ(11, dest.repeated_uint32(0));\n  EXPECT_EQ(12, dest.repeated_uint32(1));\n  ASSERT_EQ(0, dest.repeated_uint64_size());\n}\n\nTEST(MessageFactoryTest, GeneratedFactoryLookup) {\n  EXPECT_EQ(\n    MessageFactory::generated_factory()->GetPrototype(\n      protobuf_unittest::TestAllTypes::descriptor()),\n    &protobuf_unittest::TestAllTypes::default_instance());\n}\n\nTEST(MessageFactoryTest, GeneratedFactoryUnknownType) {\n  // Construct a new descriptor.\n  DescriptorPool pool;\n  FileDescriptorProto file;\n  file.set_name(\"foo.proto\");\n  file.add_message_type()->set_name(\"Foo\");\n  const Descriptor* descriptor = pool.BuildFile(file)->message_type(0);\n\n  // Trying to construct it should return NULL.\n  EXPECT_TRUE(\n    MessageFactory::generated_factory()->GetPrototype(descriptor) == NULL);\n}\n\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/metadata.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This header file defines an internal class that encapsulates internal message\n// metadata (Unknown-field set, Arena pointer, ...) and allows its\n// representation to be made more space-efficient via various optimizations.\n//\n// Note that this is distinct from google::protobuf::Metadata, which encapsulates\n// Descriptor and Reflection pointers.\n\n#ifndef GOOGLE_PROTOBUF_METADATA_H__\n#define GOOGLE_PROTOBUF_METADATA_H__\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/arena.h>\n#include <google/protobuf/unknown_field_set.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\n// This is the representation for messages that support arena allocation. It\n// uses a tagged pointer to either store the Arena pointer, if there are no\n// unknown fields, or a pointer to a block of memory with both the Arena pointer\n// and the UnknownFieldSet, if there are unknown fields. This optimization\n// allows for \"zero-overhead\" storage of the Arena pointer, relative to the\n// above baseline implementation.\n//\n// The tagged pointer uses the LSB to disambiguate cases, and uses bit 0 == 0 to\n// indicate an arena pointer and bit 0 == 1 to indicate a UFS+Arena-container\n// pointer.\nclass LIBPROTOBUF_EXPORT InternalMetadataWithArena {\n public:\n  InternalMetadataWithArena() : ptr_(NULL) {}\n  explicit InternalMetadataWithArena(Arena* arena)\n      : ptr_ (arena) {}\n\n  ~InternalMetadataWithArena() {\n    if (have_unknown_fields() && arena() == NULL) {\n      delete PtrValue<Container>();\n    }\n    ptr_ = NULL;\n  }\n\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE const UnknownFieldSet& unknown_fields() const {\n    if (GOOGLE_PREDICT_FALSE(have_unknown_fields())) {\n      return PtrValue<Container>()->unknown_fields_;\n    } else {\n      return *UnknownFieldSet::default_instance();\n    }\n  }\n\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE UnknownFieldSet* mutable_unknown_fields() {\n    if (GOOGLE_PREDICT_TRUE(have_unknown_fields())) {\n      return &PtrValue<Container>()->unknown_fields_;\n    } else {\n      return mutable_unknown_fields_slow();\n    }\n  }\n\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE Arena* arena() const {\n    if (GOOGLE_PREDICT_FALSE(have_unknown_fields())) {\n      return PtrValue<Container>()->arena_;\n    } else {\n      return PtrValue<Arena>();\n    }\n  }\n\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE bool have_unknown_fields() const {\n    return PtrTag() == kTagContainer;\n  }\n\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE void Swap(InternalMetadataWithArena* other) {\n    // Semantics here are that we swap only the unknown fields, not the arena\n    // pointer. We cannot simply swap ptr_ with other->ptr_ because we need to\n    // maintain our own arena ptr. Also, our ptr_ and other's ptr_ may be in\n    // different states (direct arena pointer vs. container with UFS) so we\n    // cannot simply swap ptr_ and then restore the arena pointers. We reuse\n    // UFS's swap implementation instead.\n    if (have_unknown_fields() || other->have_unknown_fields()) {\n      mutable_unknown_fields()->Swap(other->mutable_unknown_fields());\n    }\n  }\n\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE void* raw_arena_ptr() const {\n    return ptr_;\n  }\n\n private:\n  void* ptr_;\n\n  // Tagged pointer implementation.\n  enum {\n    // ptr_ is an Arena*.\n    kTagArena = 0,\n    // ptr_ is a Container*.\n    kTagContainer = 1,\n  };\n  static const intptr_t kPtrTagMask = 1;\n  static const intptr_t kPtrValueMask = ~kPtrTagMask;\n\n  // Accessors for pointer tag and pointer value.\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE int PtrTag() const {\n    return reinterpret_cast<intptr_t>(ptr_) & kPtrTagMask;\n  }\n\n  template<typename T> T* PtrValue() const {\n    return reinterpret_cast<T*>(\n        reinterpret_cast<intptr_t>(ptr_) & kPtrValueMask);\n  }\n\n  // If ptr_'s tag is kTagContainer, it points to an instance of this struct.\n  struct Container {\n    UnknownFieldSet unknown_fields_;\n    Arena* arena_;\n  };\n\n  GOOGLE_ATTRIBUTE_NOINLINE UnknownFieldSet* mutable_unknown_fields_slow() {\n    Arena* my_arena = arena();\n    Container* container = Arena::Create<Container>(my_arena);\n    ptr_ = reinterpret_cast<void*>(\n        reinterpret_cast<intptr_t>(container) | kTagContainer);\n    container->arena_ = my_arena;\n    return &(container->unknown_fields_);\n  }\n};\n\n// Temporary compatibility typedef. Remove once this is released in components\n// and upb CL is submitted.\ntypedef InternalMetadataWithArena InternalMetadata;\n\n}  // namespace internal\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_METADATA_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/no_field_presence_test.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <string>\n\n#include <google/protobuf/unittest_no_field_presence.pb.h>\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/descriptor.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace {\n\n// Helper: checks that all fields have default (zero/empty) values.\nvoid CheckDefaultValues(\n    const proto2_nofieldpresence_unittest::TestAllTypes& m) {\n  EXPECT_EQ(0, m.optional_int32());\n  EXPECT_EQ(0, m.optional_int64());\n  EXPECT_EQ(0, m.optional_uint32());\n  EXPECT_EQ(0, m.optional_uint64());\n  EXPECT_EQ(0, m.optional_sint32());\n  EXPECT_EQ(0, m.optional_sint64());\n  EXPECT_EQ(0, m.optional_fixed32());\n  EXPECT_EQ(0, m.optional_fixed64());\n  EXPECT_EQ(0, m.optional_sfixed32());\n  EXPECT_EQ(0, m.optional_sfixed64());\n  EXPECT_EQ(0, m.optional_float());\n  EXPECT_EQ(0, m.optional_double());\n  EXPECT_EQ(false, m.optional_bool());\n  EXPECT_EQ(0, m.optional_string().size());\n  EXPECT_EQ(0, m.optional_bytes().size());\n\n  EXPECT_EQ(false, m.has_optional_nested_message());\n  // accessor for message fields returns default instance when not present\n  EXPECT_EQ(0, m.optional_nested_message().bb());\n  EXPECT_EQ(false, m.has_optional_proto2_message());\n  // Embedded proto2 messages still have proto2 semantics, e.g. non-zero default\n  // values. Here the submessage is not present but its accessor returns the\n  // default instance.\n  EXPECT_EQ(41, m.optional_proto2_message().default_int32());\n  EXPECT_EQ(false, m.has_optional_foreign_message());\n  EXPECT_EQ(proto2_nofieldpresence_unittest::TestAllTypes_NestedEnum_FOO,\n            m.optional_nested_enum());\n  EXPECT_EQ(proto2_nofieldpresence_unittest::FOREIGN_FOO,\n            m.optional_foreign_enum());\n\n\n  EXPECT_EQ(0, m.repeated_int32_size());\n  EXPECT_EQ(0, m.repeated_int64_size());\n  EXPECT_EQ(0, m.repeated_uint32_size());\n  EXPECT_EQ(0, m.repeated_uint64_size());\n  EXPECT_EQ(0, m.repeated_sint32_size());\n  EXPECT_EQ(0, m.repeated_sint64_size());\n  EXPECT_EQ(0, m.repeated_fixed32_size());\n  EXPECT_EQ(0, m.repeated_fixed64_size());\n  EXPECT_EQ(0, m.repeated_sfixed32_size());\n  EXPECT_EQ(0, m.repeated_sfixed64_size());\n  EXPECT_EQ(0, m.repeated_float_size());\n  EXPECT_EQ(0, m.repeated_double_size());\n  EXPECT_EQ(0, m.repeated_bool_size());\n  EXPECT_EQ(0, m.repeated_string_size());\n  EXPECT_EQ(0, m.repeated_bytes_size());\n  EXPECT_EQ(0, m.repeated_nested_message_size());\n  EXPECT_EQ(0, m.repeated_foreign_message_size());\n  EXPECT_EQ(0, m.repeated_proto2_message_size());\n  EXPECT_EQ(0, m.repeated_nested_enum_size());\n  EXPECT_EQ(0, m.repeated_foreign_enum_size());\n  EXPECT_EQ(0, m.repeated_lazy_message_size());\n  EXPECT_EQ(proto2_nofieldpresence_unittest::TestAllTypes::ONEOF_FIELD_NOT_SET,\n            m.oneof_field_case());\n}\n\nvoid FillValues(proto2_nofieldpresence_unittest::TestAllTypes* m) {\n  m->set_optional_int32(100);\n  m->set_optional_int64(101);\n  m->set_optional_uint32(102);\n  m->set_optional_uint64(103);\n  m->set_optional_sint32(104);\n  m->set_optional_sint64(105);\n  m->set_optional_fixed32(106);\n  m->set_optional_fixed64(107);\n  m->set_optional_sfixed32(108);\n  m->set_optional_sfixed64(109);\n  m->set_optional_float(110.0);\n  m->set_optional_double(111.0);\n  m->set_optional_bool(true);\n  m->set_optional_string(\"asdf\");\n  m->set_optional_bytes(\"jkl;\");\n  m->mutable_optional_nested_message()->set_bb(42);\n  m->mutable_optional_foreign_message()->set_c(43);\n  m->mutable_optional_proto2_message()->set_optional_int32(44);\n  m->set_optional_nested_enum(\n      proto2_nofieldpresence_unittest::TestAllTypes_NestedEnum_BAZ);\n  m->set_optional_foreign_enum(\n      proto2_nofieldpresence_unittest::FOREIGN_BAZ);\n  m->mutable_optional_lazy_message()->set_bb(45);\n  m->add_repeated_int32(100);\n  m->add_repeated_int64(101);\n  m->add_repeated_uint32(102);\n  m->add_repeated_uint64(103);\n  m->add_repeated_sint32(104);\n  m->add_repeated_sint64(105);\n  m->add_repeated_fixed32(106);\n  m->add_repeated_fixed64(107);\n  m->add_repeated_sfixed32(108);\n  m->add_repeated_sfixed64(109);\n  m->add_repeated_float(110.0);\n  m->add_repeated_double(111.0);\n  m->add_repeated_bool(true);\n  m->add_repeated_string(\"asdf\");\n  m->add_repeated_bytes(\"jkl;\");\n  m->add_repeated_nested_message()->set_bb(46);\n  m->add_repeated_foreign_message()->set_c(47);\n  m->add_repeated_proto2_message()->set_optional_int32(48);\n  m->add_repeated_nested_enum(\n      proto2_nofieldpresence_unittest::TestAllTypes_NestedEnum_BAZ);\n  m->add_repeated_foreign_enum(\n      proto2_nofieldpresence_unittest::FOREIGN_BAZ);\n  m->add_repeated_lazy_message()->set_bb(49);\n\n  m->set_oneof_uint32(1);\n  m->mutable_oneof_nested_message()->set_bb(50);\n  m->set_oneof_string(\"test\");  // only this one remains set\n}\n\nvoid CheckNonDefaultValues(\nconst proto2_nofieldpresence_unittest::TestAllTypes& m) {\n  EXPECT_EQ(100, m.optional_int32());\n  EXPECT_EQ(101, m.optional_int64());\n  EXPECT_EQ(102, m.optional_uint32());\n  EXPECT_EQ(103, m.optional_uint64());\n  EXPECT_EQ(104, m.optional_sint32());\n  EXPECT_EQ(105, m.optional_sint64());\n  EXPECT_EQ(106, m.optional_fixed32());\n  EXPECT_EQ(107, m.optional_fixed64());\n  EXPECT_EQ(108, m.optional_sfixed32());\n  EXPECT_EQ(109, m.optional_sfixed64());\n  EXPECT_EQ(110.0, m.optional_float());\n  EXPECT_EQ(111.0, m.optional_double());\n  EXPECT_EQ(true, m.optional_bool());\n  EXPECT_EQ(\"asdf\", m.optional_string());\n  EXPECT_EQ(\"jkl;\", m.optional_bytes());\n  EXPECT_EQ(true, m.has_optional_nested_message());\n  EXPECT_EQ(42, m.optional_nested_message().bb());\n  EXPECT_EQ(true, m.has_optional_foreign_message());\n  EXPECT_EQ(43, m.optional_foreign_message().c());\n  EXPECT_EQ(true, m.has_optional_proto2_message());\n  EXPECT_EQ(44, m.optional_proto2_message().optional_int32());\n  EXPECT_EQ(proto2_nofieldpresence_unittest::TestAllTypes_NestedEnum_BAZ,\n            m.optional_nested_enum());\n  EXPECT_EQ(proto2_nofieldpresence_unittest::FOREIGN_BAZ,\n            m.optional_foreign_enum());\n  EXPECT_EQ(true, m.has_optional_lazy_message());\n  EXPECT_EQ(45, m.optional_lazy_message().bb());\n\n  EXPECT_EQ(1, m.repeated_int32_size());\n  EXPECT_EQ(100, m.repeated_int32(0));\n  EXPECT_EQ(1, m.repeated_int64_size());\n  EXPECT_EQ(101, m.repeated_int64(0));\n  EXPECT_EQ(1, m.repeated_uint32_size());\n  EXPECT_EQ(102, m.repeated_uint32(0));\n  EXPECT_EQ(1, m.repeated_uint64_size());\n  EXPECT_EQ(103, m.repeated_uint64(0));\n  EXPECT_EQ(1, m.repeated_sint32_size());\n  EXPECT_EQ(104, m.repeated_sint32(0));\n  EXPECT_EQ(1, m.repeated_sint64_size());\n  EXPECT_EQ(105, m.repeated_sint64(0));\n  EXPECT_EQ(1, m.repeated_fixed32_size());\n  EXPECT_EQ(106, m.repeated_fixed32(0));\n  EXPECT_EQ(1, m.repeated_fixed64_size());\n  EXPECT_EQ(107, m.repeated_fixed64(0));\n  EXPECT_EQ(1, m.repeated_sfixed32_size());\n  EXPECT_EQ(108, m.repeated_sfixed32(0));\n  EXPECT_EQ(1, m.repeated_sfixed64_size());\n  EXPECT_EQ(109, m.repeated_sfixed64(0));\n  EXPECT_EQ(1, m.repeated_float_size());\n  EXPECT_EQ(110.0, m.repeated_float(0));\n  EXPECT_EQ(1, m.repeated_double_size());\n  EXPECT_EQ(111.0, m.repeated_double(0));\n  EXPECT_EQ(1, m.repeated_bool_size());\n  EXPECT_EQ(true, m.repeated_bool(0));\n  EXPECT_EQ(1, m.repeated_string_size());\n  EXPECT_EQ(\"asdf\", m.repeated_string(0));\n  EXPECT_EQ(1, m.repeated_bytes_size());\n  EXPECT_EQ(\"jkl;\", m.repeated_bytes(0));\n  EXPECT_EQ(1, m.repeated_nested_message_size());\n  EXPECT_EQ(46, m.repeated_nested_message(0).bb());\n  EXPECT_EQ(1, m.repeated_foreign_message_size());\n  EXPECT_EQ(47, m.repeated_foreign_message(0).c());\n  EXPECT_EQ(1, m.repeated_proto2_message_size());\n  EXPECT_EQ(48, m.repeated_proto2_message(0).optional_int32());\n  EXPECT_EQ(1, m.repeated_nested_enum_size());\n  EXPECT_EQ(proto2_nofieldpresence_unittest::TestAllTypes_NestedEnum_BAZ,\n            m.repeated_nested_enum(0));\n  EXPECT_EQ(1, m.repeated_foreign_enum_size());\n  EXPECT_EQ(proto2_nofieldpresence_unittest::FOREIGN_BAZ,\n            m.repeated_foreign_enum(0));\n  EXPECT_EQ(1, m.repeated_lazy_message_size());\n  EXPECT_EQ(49, m.repeated_lazy_message(0).bb());\n\n  EXPECT_EQ(proto2_nofieldpresence_unittest::TestAllTypes::kOneofString,\n            m.oneof_field_case());\n  EXPECT_EQ(\"test\", m.oneof_string());\n}\n\nTEST(NoFieldPresenceTest, BasicMessageTest) {\n  proto2_nofieldpresence_unittest::TestAllTypes message;\n  // Check default values, fill all fields, check values. We just want to\n  // exercise the basic getters/setter paths here to make sure no\n  // field-presence-related changes broke these.\n  CheckDefaultValues(message);\n  FillValues(&message);\n  CheckNonDefaultValues(message);\n\n  // Clear() should be equivalent to getting a freshly-constructed message.\n  message.Clear();\n  CheckDefaultValues(message);\n}\n\nTEST(NoFieldPresenceTest, MessageFieldPresenceTest) {\n  // check that presence still works properly for message fields.\n  proto2_nofieldpresence_unittest::TestAllTypes message;\n  EXPECT_EQ(false, message.has_optional_nested_message());\n  // Getter should fetch default instance, and not cause the field to become\n  // present.\n  EXPECT_EQ(0, message.optional_nested_message().bb());\n  EXPECT_EQ(false, message.has_optional_nested_message());\n  message.mutable_optional_nested_message()->set_bb(42);\n  EXPECT_EQ(true, message.has_optional_nested_message());\n  message.clear_optional_nested_message();\n  EXPECT_EQ(false, message.has_optional_nested_message());\n\n  // Likewise for a lazy message field.\n  EXPECT_EQ(false, message.has_optional_lazy_message());\n  // Getter should fetch default instance, and not cause the field to become\n  // present.\n  EXPECT_EQ(0, message.optional_lazy_message().bb());\n  EXPECT_EQ(false, message.has_optional_lazy_message());\n  message.mutable_optional_lazy_message()->set_bb(42);\n  EXPECT_EQ(true, message.has_optional_lazy_message());\n  message.clear_optional_lazy_message();\n  EXPECT_EQ(false, message.has_optional_lazy_message());\n\n  // Test field presence of a message field on the default instance.\n  EXPECT_EQ(false, proto2_nofieldpresence_unittest::TestAllTypes::\n            default_instance().has_optional_nested_message());\n}\n\nTEST(NoFieldPresenceTest, ReflectionHasFieldTest) {\n  // check that HasField reports true on all scalar fields. Check that it\n  // behaves properly for message fields.\n\n  proto2_nofieldpresence_unittest::TestAllTypes message;\n  const google::protobuf::Reflection* r = message.GetReflection();\n  const google::protobuf::Descriptor* desc = message.GetDescriptor();\n\n  // Check initial state: scalars not present (due to need to be consistent with\n  // MergeFrom()), message fields not present, oneofs not present.\n  for (int i = 0; i < desc->field_count(); i++) {\n    const google::protobuf::FieldDescriptor* field = desc->field(i);\n    if (field->is_repeated()) continue;\n    EXPECT_EQ(false, r->HasField(message, field));\n  }\n\n  // Test field presence of a message field on the default instance.\n  const google::protobuf::FieldDescriptor* msg_field =\n      desc->FindFieldByName(\"optional_nested_message\");\n  EXPECT_EQ(false, r->HasField(\n      proto2_nofieldpresence_unittest::TestAllTypes::\n      default_instance(), msg_field));\n\n  // Fill all fields, expect everything to report true (check oneofs below).\n  FillValues(&message);\n  for (int i = 0; i < desc->field_count(); i++) {\n    const google::protobuf::FieldDescriptor* field = desc->field(i);\n    if (field->is_repeated() || field->containing_oneof()) {\n      continue;\n    }\n    if (field->options().ctype() != google::protobuf::FieldOptions::STRING) {\n      continue;\n    }\n    EXPECT_EQ(true, r->HasField(message, field));\n  }\n\n  message.Clear();\n\n  // Check zero/empty-means-not-present semantics.\n  const google::protobuf::FieldDescriptor* field_int32 = desc->FindFieldByName(\n      \"optional_int32\");\n  const google::protobuf::FieldDescriptor* field_double = desc->FindFieldByName(\n      \"optional_double\");\n  const google::protobuf::FieldDescriptor* field_string = desc->FindFieldByName(\n      \"optional_string\");\n\n  EXPECT_EQ(false, r->HasField(message, field_int32));\n  EXPECT_EQ(false, r->HasField(message, field_double));\n  EXPECT_EQ(false, r->HasField(message, field_string));\n\n  message.set_optional_int32(42);\n  EXPECT_EQ(true, r->HasField(message, field_int32));\n  message.set_optional_int32(0);\n  EXPECT_EQ(false, r->HasField(message, field_int32));\n\n  message.set_optional_double(42.0);\n  EXPECT_EQ(true, r->HasField(message, field_double));\n  message.set_optional_double(0.0);\n  EXPECT_EQ(false, r->HasField(message, field_double));\n\n  message.set_optional_string(\"test\");\n  EXPECT_EQ(true, r->HasField(message, field_string));\n  message.set_optional_string(\"\");\n  EXPECT_EQ(false, r->HasField(message, field_string));\n}\n\nTEST(NoFieldPresenceTest, ReflectionClearFieldTest) {\n  proto2_nofieldpresence_unittest::TestAllTypes message;\n\n  const google::protobuf::Reflection* r = message.GetReflection();\n  const google::protobuf::Descriptor* desc = message.GetDescriptor();\n\n  const google::protobuf::FieldDescriptor* field_int32 = desc->FindFieldByName(\n      \"optional_int32\");\n  const google::protobuf::FieldDescriptor* field_double = desc->FindFieldByName(\n      \"optional_double\");\n  const google::protobuf::FieldDescriptor* field_string = desc->FindFieldByName(\n      \"optional_string\");\n  const google::protobuf::FieldDescriptor* field_message = desc->FindFieldByName(\n      \"optional_nested_message\");\n  const google::protobuf::FieldDescriptor* field_lazy = desc->FindFieldByName(\n      \"optional_lazy_message\");\n\n  message.set_optional_int32(42);\n  r->ClearField(&message, field_int32);\n  EXPECT_EQ(0, message.optional_int32());\n\n  message.set_optional_double(42.0);\n  r->ClearField(&message, field_double);\n  EXPECT_EQ(0.0, message.optional_double());\n\n  message.set_optional_string(\"test\");\n  r->ClearField(&message, field_string);\n  EXPECT_EQ(\"\", message.optional_string());\n\n  message.mutable_optional_nested_message()->set_bb(1234);\n  r->ClearField(&message, field_message);\n  EXPECT_FALSE(message.has_optional_nested_message());\n  EXPECT_EQ(0, message.optional_nested_message().bb());\n\n  message.mutable_optional_lazy_message()->set_bb(42);\n  r->ClearField(&message, field_lazy);\n  EXPECT_FALSE(message.has_optional_lazy_message());\n  EXPECT_EQ(0, message.optional_lazy_message().bb());\n}\n\nTEST(NoFieldPresenceTest, HasFieldOneofsTest) {\n  // check that HasField behaves properly for oneofs.\n  proto2_nofieldpresence_unittest::TestAllTypes message;\n\n  const google::protobuf::Reflection* r = message.GetReflection();\n  const google::protobuf::Descriptor* desc = message.GetDescriptor();\n  const google::protobuf::FieldDescriptor* desc_oneof_uint32 =\n      desc->FindFieldByName(\"oneof_uint32\");\n  const google::protobuf::FieldDescriptor* desc_oneof_nested_message =\n      desc->FindFieldByName(\"oneof_nested_message\");\n  const google::protobuf::FieldDescriptor* desc_oneof_string =\n      desc->FindFieldByName(\"oneof_string\");\n  GOOGLE_CHECK_NOTNULL(desc_oneof_uint32);\n  GOOGLE_CHECK_NOTNULL(desc_oneof_nested_message);\n  GOOGLE_CHECK_NOTNULL(desc_oneof_string);\n\n  EXPECT_EQ(false, r->HasField(message, desc_oneof_uint32));\n  EXPECT_EQ(false, r->HasField(message, desc_oneof_nested_message));\n  EXPECT_EQ(false, r->HasField(message, desc_oneof_string));\n\n  message.set_oneof_string(\"test\");\n  EXPECT_EQ(false, r->HasField(message, desc_oneof_uint32));\n  EXPECT_EQ(false, r->HasField(message, desc_oneof_nested_message));\n  EXPECT_EQ(true, r->HasField(message, desc_oneof_string));\n  message.mutable_oneof_nested_message()->set_bb(42);\n  EXPECT_EQ(false, r->HasField(message, desc_oneof_uint32));\n  EXPECT_EQ(true, r->HasField(message, desc_oneof_nested_message));\n  EXPECT_EQ(false, r->HasField(message, desc_oneof_string));\n\n  message.Clear();\n  EXPECT_EQ(false, r->HasField(message, desc_oneof_uint32));\n  EXPECT_EQ(false, r->HasField(message, desc_oneof_nested_message));\n  EXPECT_EQ(false, r->HasField(message, desc_oneof_string));\n}\n\nTEST(NoFieldPresenceTest, DontSerializeDefaultValuesTest) {\n  // check that serialized data contains only non-zero numeric fields/non-empty\n  // string/byte fields.\n  proto2_nofieldpresence_unittest::TestAllTypes message;\n  string output;\n\n  // All default values -> no output.\n  message.SerializeToString(&output);\n  EXPECT_EQ(0, output.size());\n\n  // Zero values -> still no output.\n  message.set_optional_int32(0);\n  message.set_optional_int64(0);\n  message.set_optional_uint32(0);\n  message.set_optional_uint64(0);\n  message.set_optional_sint32(0);\n  message.set_optional_sint64(0);\n  message.set_optional_fixed32(0);\n  message.set_optional_fixed64(0);\n  message.set_optional_sfixed32(0);\n  message.set_optional_sfixed64(0);\n  message.set_optional_float(0);\n  message.set_optional_double(0);\n  message.set_optional_bool(0);\n  message.set_optional_string(\"\");\n  message.set_optional_bytes(\"\");\n  message.set_optional_nested_enum(\n      proto2_nofieldpresence_unittest::TestAllTypes_NestedEnum_FOO);  // first enum entry\n  message.set_optional_foreign_enum(\n      proto2_nofieldpresence_unittest::FOREIGN_FOO);  // first enum entry\n\n  message.SerializeToString(&output);\n  EXPECT_EQ(0, output.size());\n\n  message.set_optional_int32(1);\n  message.SerializeToString(&output);\n  EXPECT_EQ(2, output.size());\n  EXPECT_EQ(\"\\x08\\x01\", output);\n\n  message.set_optional_int32(0);\n  message.SerializeToString(&output);\n  EXPECT_EQ(0, output.size());\n}\n\nTEST(NoFieldPresenceTest, MergeFromIfNonzeroTest) {\n  // check that MergeFrom copies if nonzero/nondefault only.\n  proto2_nofieldpresence_unittest::TestAllTypes source;\n  proto2_nofieldpresence_unittest::TestAllTypes dest;\n\n  dest.set_optional_int32(42);\n  dest.set_optional_string(\"test\");\n  source.set_optional_int32(0);\n  source.set_optional_string(\"\");\n  // MergeFrom() copies only if present in serialization, i.e., non-zero.\n  dest.MergeFrom(source);\n  EXPECT_EQ(42, dest.optional_int32());\n  EXPECT_EQ(\"test\", dest.optional_string());\n\n  source.set_optional_int32(84);\n  source.set_optional_string(\"test2\");\n  dest.MergeFrom(source);\n  EXPECT_EQ(84, dest.optional_int32());\n  EXPECT_EQ(\"test2\", dest.optional_string());\n}\n\nTEST(NoFieldPresenceTest, IsInitializedTest) {\n  // Check that IsInitialized works properly.\n  proto2_nofieldpresence_unittest::TestProto2Required message;\n\n  EXPECT_EQ(true, message.IsInitialized());\n  message.mutable_proto2()->set_a(1);\n  EXPECT_EQ(false, message.IsInitialized());\n  message.mutable_proto2()->set_b(1);\n  EXPECT_EQ(false, message.IsInitialized());\n  message.mutable_proto2()->set_c(1);\n  EXPECT_EQ(true, message.IsInitialized());\n}\n\nTEST(NoFieldPresenceTest, LazyMessageFieldHasBit) {\n  // Check that has-bit interaction with lazy message works (has-bit before and\n  // after lazy decode).\n  proto2_nofieldpresence_unittest::TestAllTypes message;\n  const google::protobuf::Reflection* r = message.GetReflection();\n  const google::protobuf::Descriptor* desc = message.GetDescriptor();\n  const google::protobuf::FieldDescriptor* field = desc->FindFieldByName(\n      \"optional_lazy_message\");\n  GOOGLE_CHECK_NOTNULL(field);\n\n  EXPECT_EQ(false, message.has_optional_lazy_message());\n  EXPECT_EQ(false, r->HasField(message, field));\n\n  message.mutable_optional_lazy_message()->set_bb(42);\n  EXPECT_EQ(true, message.has_optional_lazy_message());\n  EXPECT_EQ(true, r->HasField(message, field));\n\n  // Serialize and parse with a new message object so that lazy field on new\n  // object is in unparsed state.\n  string output;\n  message.SerializeToString(&output);\n  proto2_nofieldpresence_unittest::TestAllTypes message2;\n  message2.ParseFromString(output);\n\n  EXPECT_EQ(true, message2.has_optional_lazy_message());\n  EXPECT_EQ(true, r->HasField(message2, field));\n\n  // Access field to force lazy parse.\n  EXPECT_EQ(42, message.optional_lazy_message().bb());\n  EXPECT_EQ(true, message2.has_optional_lazy_message());\n  EXPECT_EQ(true, r->HasField(message2, field));\n}\n\nTEST(NoFieldPresenceTest, OneofPresence) {\n  proto2_nofieldpresence_unittest::TestAllTypes message;\n  // oneof fields still have field presence -- ensure that this goes on the wire\n  // even though its value is the empty string.\n  message.set_oneof_string(\"\");\n  string serialized;\n  message.SerializeToString(&serialized);\n  // Tag: 113 --> tag is (113 << 3) | 2 (length delimited) = 906\n  // varint: 0x8a 0x07\n  // Length: 0x00\n  EXPECT_EQ(3, serialized.size());\n  EXPECT_EQ(static_cast<char>(0x8a), serialized.at(0));\n  EXPECT_EQ(static_cast<char>(0x07), serialized.at(1));\n  EXPECT_EQ(static_cast<char>(0x00), serialized.at(2));\n\n  message.Clear();\n  EXPECT_TRUE(message.ParseFromString(serialized));\n  EXPECT_EQ(proto2_nofieldpresence_unittest::TestAllTypes::kOneofString,\n            message.oneof_field_case());\n\n  // Also test int32 and enum fields.\n  message.Clear();\n  message.set_oneof_uint32(0);  // would not go on wire if ordinary field.\n  message.SerializeToString(&serialized);\n  EXPECT_EQ(3, serialized.size());\n  EXPECT_TRUE(message.ParseFromString(serialized));\n  EXPECT_EQ(proto2_nofieldpresence_unittest::TestAllTypes::kOneofUint32,\n            message.oneof_field_case());\n\n  message.Clear();\n  message.set_oneof_enum(proto2_nofieldpresence_unittest::\n                         TestAllTypes_NestedEnum_FOO);  // default value.\n  message.SerializeToString(&serialized);\n  EXPECT_EQ(3, serialized.size());\n  EXPECT_TRUE(message.ParseFromString(serialized));\n  EXPECT_EQ(proto2_nofieldpresence_unittest::TestAllTypes::kOneofEnum,\n            message.oneof_field_case());\n\n  message.Clear();\n  message.set_oneof_string(\"test\");\n  message.clear_oneof_string();\n  EXPECT_EQ(0, message.ByteSize());\n}\n\n}  // namespace\n}  // namespace protobuf\n\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/package_info.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This file exists solely to document the google::protobuf namespace.\n// It is not compiled into anything, but it may be read by an automated\n// documentation generator.\n\nnamespace google {\n\n// Core components of the Protocol Buffers runtime library.\n//\n// The files in this package represent the core of the Protocol Buffer\n// system.  All of them are part of the libprotobuf library.\n//\n// A note on thread-safety:\n//\n// Thread-safety in the Protocol Buffer library follows a simple rule:\n// unless explicitly noted otherwise, it is always safe to use an object\n// from multiple threads simultaneously as long as the object is declared\n// const in all threads (or, it is only used in ways that would be allowed\n// if it were declared const).  However, if an object is accessed in one\n// thread in a way that would not be allowed if it were const, then it is\n// not safe to access that object in any other thread simultaneously.\n//\n// Put simply, read-only access to an object can happen in multiple threads\n// simultaneously, but write access can only happen in a single thread at\n// a time.\n//\n// The implementation does contain some \"const\" methods which actually modify\n// the object behind the scenes -- e.g., to cache results -- but in these cases\n// mutex locking is used to make the access thread-safe.\nnamespace protobuf {}\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/preserve_unknown_enum_test.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/unittest_preserve_unknown_enum.pb.h>\n#include <google/protobuf/unittest_preserve_unknown_enum2.pb.h>\n#include <google/protobuf/dynamic_message.h>\n#include <google/protobuf/descriptor.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace {\n\nvoid FillMessage(\n    proto3_preserve_unknown_enum_unittest::MyMessagePlusExtra* message) {\n  message->set_e(\n      proto3_preserve_unknown_enum_unittest::E_EXTRA);\n  message->add_repeated_e(\n      proto3_preserve_unknown_enum_unittest::E_EXTRA);\n  message->add_repeated_packed_e(\n      proto3_preserve_unknown_enum_unittest::E_EXTRA);\n  message->add_repeated_packed_unexpected_e(\n      proto3_preserve_unknown_enum_unittest::E_EXTRA);\n  message->set_oneof_e_1(\n      proto3_preserve_unknown_enum_unittest::E_EXTRA);\n}\n\nvoid CheckMessage(\n    const proto3_preserve_unknown_enum_unittest::MyMessagePlusExtra& message) {\n  EXPECT_EQ(proto3_preserve_unknown_enum_unittest::E_EXTRA,\n            message.e());\n  EXPECT_EQ(1, message.repeated_e_size());\n  EXPECT_EQ(proto3_preserve_unknown_enum_unittest::E_EXTRA,\n            message.repeated_e(0));\n  EXPECT_EQ(1, message.repeated_packed_e_size());\n  EXPECT_EQ(proto3_preserve_unknown_enum_unittest::E_EXTRA,\n            message.repeated_packed_e(0));\n  EXPECT_EQ(1, message.repeated_packed_unexpected_e_size());\n  EXPECT_EQ(proto3_preserve_unknown_enum_unittest::E_EXTRA,\n            message.repeated_packed_unexpected_e(0));\n  EXPECT_EQ(proto3_preserve_unknown_enum_unittest::E_EXTRA,\n            message.oneof_e_1());\n}\n\nvoid CheckMessage(\n    const proto3_preserve_unknown_enum_unittest::MyMessage& message) {\n  EXPECT_EQ(static_cast<int>(\n              proto3_preserve_unknown_enum_unittest::E_EXTRA),\n            static_cast<int>(message.e()));\n  EXPECT_EQ(1, message.repeated_e_size());\n  EXPECT_EQ(static_cast<int>(\n              proto3_preserve_unknown_enum_unittest::E_EXTRA),\n            static_cast<int>(message.repeated_e(0)));\n  EXPECT_EQ(1, message.repeated_packed_e_size());\n  EXPECT_EQ(static_cast<int>(\n              proto3_preserve_unknown_enum_unittest::E_EXTRA),\n            static_cast<int>(message.repeated_packed_e(0)));\n  EXPECT_EQ(1, message.repeated_packed_unexpected_e_size());\n  EXPECT_EQ(static_cast<int>(\n              proto3_preserve_unknown_enum_unittest::E_EXTRA),\n            static_cast<int>(message.repeated_packed_unexpected_e(0)));\n  EXPECT_EQ(static_cast<int>(\n              proto3_preserve_unknown_enum_unittest::E_EXTRA),\n            static_cast<int>(message.oneof_e_1()));\n}\n\n}  // anonymous namespace\n\n// Test that parsing preserves an unknown value in the enum field and does not\n// punt it to the UnknownFieldSet.\nTEST(PreserveUnknownEnumTest, PreserveParseAndSerialize) {\n  proto3_preserve_unknown_enum_unittest::MyMessagePlusExtra orig_message;\n  FillMessage(&orig_message);\n  string serialized;\n  orig_message.SerializeToString(&serialized);\n\n  proto3_preserve_unknown_enum_unittest::MyMessage message;\n  EXPECT_EQ(true, message.ParseFromString(serialized));\n  CheckMessage(message);\n\n  serialized.clear();\n  message.SerializeToString(&serialized);\n  EXPECT_EQ(true, orig_message.ParseFromString(serialized));\n  CheckMessage(orig_message);\n}\n\n// Test that reflection based implementation also keeps unknown enum values and\n// doesn't put them into UnknownFieldSet.\nTEST(PreserveUnknownEnumTest, PreserveParseAndSerializeDynamicMessage) {\n  proto3_preserve_unknown_enum_unittest::MyMessagePlusExtra orig_message;\n  FillMessage(&orig_message);\n  string serialized = orig_message.SerializeAsString();\n\n  google::protobuf::DynamicMessageFactory factory;\n  google::protobuf::scoped_ptr<google::protobuf::Message> message(factory.GetPrototype(\n      proto3_preserve_unknown_enum_unittest::MyMessage::descriptor())->New());\n  EXPECT_EQ(true, message->ParseFromString(serialized));\n  message->DiscardUnknownFields();\n\n  serialized = message->SerializeAsString();\n  EXPECT_EQ(true, orig_message.ParseFromString(serialized));\n  CheckMessage(orig_message);\n}\n\n// Test that for proto2 messages, unknown values are in unknown fields.\nTEST(PreserveUnknownEnumTest, Proto2HidesUnknownValues) {\n  proto3_preserve_unknown_enum_unittest::MyMessagePlusExtra orig_message;\n  FillMessage(&orig_message);\n\n  string serialized;\n  orig_message.SerializeToString(&serialized);\n\n  proto2_preserve_unknown_enum_unittest::MyMessage message;\n  EXPECT_EQ(true, message.ParseFromString(serialized));\n  // The intermediate message has everything in its \"unknown fields\".\n  proto2_preserve_unknown_enum_unittest::MyMessage message2 = message;\n  message2.DiscardUnknownFields();\n  EXPECT_EQ(0, message2.ByteSize());\n\n  // But when we pass it to the correct structure, all values are there.\n  serialized.clear();\n  message.SerializeToString(&serialized);\n  EXPECT_EQ(true, orig_message.ParseFromString(serialized));\n  CheckMessage(orig_message);\n}\n\n// Same as before, for a dynamic message.\nTEST(PreserveUnknownEnumTest, DynamicProto2HidesUnknownValues) {\n  proto3_preserve_unknown_enum_unittest::MyMessagePlusExtra orig_message;\n  FillMessage(&orig_message);\n\n  string serialized;\n  orig_message.SerializeToString(&serialized);\n\n  google::protobuf::DynamicMessageFactory factory;\n  google::protobuf::scoped_ptr<google::protobuf::Message> message(factory.GetPrototype(\n      proto2_preserve_unknown_enum_unittest::MyMessage::descriptor())->New());\n  EXPECT_EQ(true, message->ParseFromString(serialized));\n  // The intermediate message has everything in its \"unknown fields\".\n  proto2_preserve_unknown_enum_unittest::MyMessage message2;\n  message2.CopyFrom(*message);\n  message2.DiscardUnknownFields();\n  EXPECT_EQ(0, message2.ByteSize());\n\n  // But when we pass it to the correct structure, all values are there.\n  serialized.clear();\n  message->SerializeToString(&serialized);\n  EXPECT_EQ(true, orig_message.ParseFromString(serialized));\n  CheckMessage(orig_message);\n}\n\n// Test that reflection provides EnumValueDescriptors for unknown values.\nTEST(PreserveUnknownEnumTest, DynamicEnumValueDescriptors) {\n  proto3_preserve_unknown_enum_unittest::MyMessagePlusExtra orig_message;\n  FillMessage(&orig_message);\n  string serialized;\n  orig_message.SerializeToString(&serialized);\n\n  proto3_preserve_unknown_enum_unittest::MyMessage message;\n  EXPECT_EQ(true, message.ParseFromString(serialized));\n  CheckMessage(message);\n\n  const google::protobuf::Reflection* r = message.GetReflection();\n  const google::protobuf::Descriptor* d = message.GetDescriptor();\n  const google::protobuf::FieldDescriptor* field = d->FindFieldByName(\"e\");\n\n  // This should dynamically create an EnumValueDescriptor.\n  const google::protobuf::EnumValueDescriptor* enum_value = r->GetEnum(message, field);\n  EXPECT_EQ(enum_value->number(),\n            static_cast<int>(proto3_preserve_unknown_enum_unittest::E_EXTRA));\n\n  // Fetching value for a second time should return the same pointer.\n  const google::protobuf::EnumValueDescriptor* enum_value_second =\n      r->GetEnum(message, field);\n  EXPECT_EQ(enum_value, enum_value_second);\n\n  // Check the repeated case too.\n  const google::protobuf::FieldDescriptor* repeated_field =\n      d->FindFieldByName(\"repeated_e\");\n  enum_value = r->GetRepeatedEnum(message, repeated_field, 0);\n  EXPECT_EQ(enum_value->number(),\n            static_cast<int>(proto3_preserve_unknown_enum_unittest::E_EXTRA));\n  // Should reuse the same EnumValueDescriptor, even for a different field.\n  EXPECT_EQ(enum_value, enum_value_second);\n\n  // We should be able to use the returned value descriptor to set a value on\n  // another message.\n  google::protobuf::Message* m = message.New();\n  r->SetEnum(m, field, enum_value);\n  EXPECT_EQ(enum_value, r->GetEnum(*m, field));\n  delete m;\n}\n\n// Test that the new integer-based enum reflection API works.\nTEST(PreserveUnknownEnumTest, IntegerEnumReflectionAPI) {\n  proto3_preserve_unknown_enum_unittest::MyMessage message;\n  const google::protobuf::Reflection* r = message.GetReflection();\n  const google::protobuf::Descriptor* d = message.GetDescriptor();\n\n  const google::protobuf::FieldDescriptor* singular_field = d->FindFieldByName(\"e\");\n  const google::protobuf::FieldDescriptor* repeated_field =\n      d->FindFieldByName(\"repeated_e\");\n\n  r->SetEnumValue(&message, singular_field, 42);\n  EXPECT_EQ(42, r->GetEnumValue(message, singular_field));\n  r->AddEnumValue(&message, repeated_field, 42);\n  r->AddEnumValue(&message, repeated_field, 42);\n  EXPECT_EQ(42, r->GetRepeatedEnumValue(message, repeated_field, 0));\n  r->SetRepeatedEnumValue(&message, repeated_field, 1, 84);\n  EXPECT_EQ(84, r->GetRepeatedEnumValue(message, repeated_field, 1));\n  const google::protobuf::EnumValueDescriptor* enum_value = r->GetEnum(message,\n                                                             singular_field);\n  EXPECT_EQ(42, enum_value->number());\n}\n\n// Test that the EnumValue API works properly for proto2 messages as well.\nTEST(PreserveUnknownEnumTest, Proto2CatchesUnknownValues) {\n  protobuf_unittest::TestAllTypes message;  // proto2 message\n  const google::protobuf::Reflection* r = message.GetReflection();\n  const google::protobuf::Descriptor* d = message.GetDescriptor();\n  const google::protobuf::FieldDescriptor* repeated_field =\n      d->FindFieldByName(\"repeated_nested_enum\");\n  // Add one element to the repeated field so that we can test\n  // SetRepeatedEnumValue.\n  const google::protobuf::EnumValueDescriptor* enum_value =\n      repeated_field->enum_type()->FindValueByName(\"BAR\");\n  EXPECT_TRUE(enum_value != NULL);\n  r->AddEnum(&message, repeated_field, enum_value);\n\n#ifdef PROTOBUF_HAS_DEATH_TEST\n  const google::protobuf::FieldDescriptor* singular_field =\n      d->FindFieldByName(\"optional_nested_enum\");\n  // Enum-field integer-based setters GOOGLE_DCHECK-fail on invalid values, in order to\n  // remain consistent with proto2 generated code.\n  EXPECT_DEBUG_DEATH({\n    r->SetEnumValue(&message, singular_field, 4242);\n    r->GetEnum(message, singular_field)->number();\n  }, \"SetEnumValue accepts only valid integer values\");\n  EXPECT_DEBUG_DEATH({\n    r->SetRepeatedEnumValue(&message, repeated_field, 0, 4242);\n    r->GetRepeatedEnum(message, repeated_field, 0);\n  }, \"SetRepeatedEnumValue accepts only valid integer values\");\n  EXPECT_DEBUG_DEATH({\n    r->AddEnumValue(&message, repeated_field, 4242);\n    r->GetRepeatedEnum(message, repeated_field, 1);\n  }, \"AddEnumValue accepts only valid integer values\");\n#endif  // PROTOBUF_HAS_DEATH_TEST\n}\n\nTEST(PreserveUnknownEnumTest, SupportsUnknownEnumValuesAPI) {\n  protobuf_unittest::TestAllTypes proto2_message;\n  proto3_preserve_unknown_enum_unittest::MyMessage new_message;\n\n  const google::protobuf::Reflection* proto2_reflection = proto2_message.GetReflection();\n  const google::protobuf::Reflection* new_reflection = new_message.GetReflection();\n\n  EXPECT_FALSE(proto2_reflection->SupportsUnknownEnumValues());\n  EXPECT_TRUE(new_reflection->SupportsUnknownEnumValues());\n}\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/proto3_arena_lite_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <string>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <vector>\n\n#include <google/protobuf/test_util.h>\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/unittest_proto3_arena_lite.pb.h>\n#include <google/protobuf/arena.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nusing proto3_arena_lite_unittest::TestAllTypes;\n\nnamespace protobuf {\nnamespace {\n// We selectively set/check a few representative fields rather than all fields\n// as this test is only expected to cover the basics of arena support.\nvoid SetAllFields(TestAllTypes* m) {\n  m->set_optional_int32(100);\n  m->set_optional_string(\"asdf\");\n  m->set_optional_bytes(\"jkl;\");\n  m->mutable_optional_nested_message()->set_bb(42);\n  m->mutable_optional_foreign_message()->set_c(43);\n  m->set_optional_nested_enum(\n      proto3_arena_lite_unittest::TestAllTypes_NestedEnum_BAZ);\n  m->set_optional_foreign_enum(\n      proto3_arena_lite_unittest::FOREIGN_BAZ);\n  m->mutable_optional_lazy_message()->set_bb(45);\n  m->add_repeated_int32(100);\n  m->add_repeated_string(\"asdf\");\n  m->add_repeated_bytes(\"jkl;\");\n  m->add_repeated_nested_message()->set_bb(46);\n  m->add_repeated_foreign_message()->set_c(47);\n  m->add_repeated_nested_enum(\n      proto3_arena_lite_unittest::TestAllTypes_NestedEnum_BAZ);\n  m->add_repeated_foreign_enum(\n      proto3_arena_lite_unittest::FOREIGN_BAZ);\n  m->add_repeated_lazy_message()->set_bb(49);\n\n  m->set_oneof_uint32(1);\n  m->mutable_oneof_nested_message()->set_bb(50);\n  m->set_oneof_string(\"test\");  // only this one remains set\n}\n\nvoid ExpectAllFieldsSet(const TestAllTypes& m) {\n  EXPECT_EQ(100, m.optional_int32());\n  EXPECT_EQ(\"asdf\", m.optional_string());\n  EXPECT_EQ(\"jkl;\", m.optional_bytes());\n  EXPECT_EQ(true, m.has_optional_nested_message());\n  EXPECT_EQ(42, m.optional_nested_message().bb());\n  EXPECT_EQ(true, m.has_optional_foreign_message());\n  EXPECT_EQ(43, m.optional_foreign_message().c());\n  EXPECT_EQ(proto3_arena_lite_unittest::TestAllTypes_NestedEnum_BAZ,\n            m.optional_nested_enum());\n  EXPECT_EQ(proto3_arena_lite_unittest::FOREIGN_BAZ,\n            m.optional_foreign_enum());\n  EXPECT_EQ(true, m.has_optional_lazy_message());\n  EXPECT_EQ(45, m.optional_lazy_message().bb());\n\n  EXPECT_EQ(1, m.repeated_int32_size());\n  EXPECT_EQ(100, m.repeated_int32(0));\n  EXPECT_EQ(1, m.repeated_string_size());\n  EXPECT_EQ(\"asdf\", m.repeated_string(0));\n  EXPECT_EQ(1, m.repeated_bytes_size());\n  EXPECT_EQ(\"jkl;\", m.repeated_bytes(0));\n  EXPECT_EQ(1, m.repeated_nested_message_size());\n  EXPECT_EQ(46, m.repeated_nested_message(0).bb());\n  EXPECT_EQ(1, m.repeated_foreign_message_size());\n  EXPECT_EQ(47, m.repeated_foreign_message(0).c());\n  EXPECT_EQ(1, m.repeated_nested_enum_size());\n  EXPECT_EQ(proto3_arena_lite_unittest::TestAllTypes_NestedEnum_BAZ,\n            m.repeated_nested_enum(0));\n  EXPECT_EQ(1, m.repeated_foreign_enum_size());\n  EXPECT_EQ(proto3_arena_lite_unittest::FOREIGN_BAZ,\n            m.repeated_foreign_enum(0));\n  EXPECT_EQ(1, m.repeated_lazy_message_size());\n  EXPECT_EQ(49, m.repeated_lazy_message(0).bb());\n\n  EXPECT_EQ(proto3_arena_lite_unittest::TestAllTypes::kOneofString,\n            m.oneof_field_case());\n  EXPECT_EQ(\"test\", m.oneof_string());\n}\n\n// In this file we only test some basic functionalities of arena support in\n// proto3 and expect the arena support to be fully tested in proto2 unittests\n// because proto3 shares most code with proto2.\n\nTEST(Proto3ArenaLiteTest, Parsing) {\n  TestAllTypes original;\n  SetAllFields(&original);\n\n  Arena arena;\n  TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena);\n  arena_message->ParseFromString(original.SerializeAsString());\n  ExpectAllFieldsSet(*arena_message);\n}\n\nTEST(Proto3ArenaLiteTest, Swap) {\n  Arena arena1;\n  Arena arena2;\n\n  // Test Swap().\n  TestAllTypes* arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1);\n  TestAllTypes* arena2_message = Arena::CreateMessage<TestAllTypes>(&arena2);\n  arena1_message->Swap(arena2_message);\n  EXPECT_EQ(&arena1, arena1_message->GetArena());\n  EXPECT_EQ(&arena2, arena2_message->GetArena());\n}\n\nTEST(Proto3ArenaLiteTest, SetAllocatedMessage) {\n  Arena arena;\n  TestAllTypes *arena_message = Arena::CreateMessage<TestAllTypes>(&arena);\n  TestAllTypes::NestedMessage* nested = new TestAllTypes::NestedMessage;\n  nested->set_bb(118);\n  arena_message->set_allocated_optional_nested_message(nested);\n  EXPECT_EQ(118, arena_message->optional_nested_message().bb());\n}\n\nTEST(Proto3ArenaLiteTest, ReleaseMessage) {\n  Arena arena;\n  TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena);\n  arena_message->mutable_optional_nested_message()->set_bb(118);\n  google::protobuf::scoped_ptr<TestAllTypes::NestedMessage> nested(\n      arena_message->release_optional_nested_message());\n  EXPECT_EQ(118, nested->bb());\n}\n\n}  // namespace\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/proto3_arena_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <string>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <vector>\n\n#include <google/protobuf/test_util.h>\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/unittest_proto3_arena.pb.h>\n#include <google/protobuf/arena.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nusing proto3_arena_unittest::TestAllTypes;\n\nnamespace protobuf {\nnamespace {\n// We selectively set/check a few representative fields rather than all fields\n// as this test is only expected to cover the basics of arena support.\nvoid SetAllFields(TestAllTypes* m) {\n  m->set_optional_int32(100);\n  m->set_optional_string(\"asdf\");\n  m->set_optional_bytes(\"jkl;\");\n  m->mutable_optional_nested_message()->set_bb(42);\n  m->mutable_optional_foreign_message()->set_c(43);\n  m->set_optional_nested_enum(\n      proto3_arena_unittest::TestAllTypes_NestedEnum_BAZ);\n  m->set_optional_foreign_enum(\n      proto3_arena_unittest::FOREIGN_BAZ);\n  m->mutable_optional_lazy_message()->set_bb(45);\n  m->add_repeated_int32(100);\n  m->add_repeated_string(\"asdf\");\n  m->add_repeated_bytes(\"jkl;\");\n  m->add_repeated_nested_message()->set_bb(46);\n  m->add_repeated_foreign_message()->set_c(47);\n  m->add_repeated_nested_enum(\n      proto3_arena_unittest::TestAllTypes_NestedEnum_BAZ);\n  m->add_repeated_foreign_enum(\n      proto3_arena_unittest::FOREIGN_BAZ);\n  m->add_repeated_lazy_message()->set_bb(49);\n\n  m->set_oneof_uint32(1);\n  m->mutable_oneof_nested_message()->set_bb(50);\n  m->set_oneof_string(\"test\");  // only this one remains set\n}\n\nvoid ExpectAllFieldsSet(const TestAllTypes& m) {\n  EXPECT_EQ(100, m.optional_int32());\n  EXPECT_EQ(\"asdf\", m.optional_string());\n  EXPECT_EQ(\"jkl;\", m.optional_bytes());\n  EXPECT_EQ(true, m.has_optional_nested_message());\n  EXPECT_EQ(42, m.optional_nested_message().bb());\n  EXPECT_EQ(true, m.has_optional_foreign_message());\n  EXPECT_EQ(43, m.optional_foreign_message().c());\n  EXPECT_EQ(proto3_arena_unittest::TestAllTypes_NestedEnum_BAZ,\n            m.optional_nested_enum());\n  EXPECT_EQ(proto3_arena_unittest::FOREIGN_BAZ,\n            m.optional_foreign_enum());\n  EXPECT_EQ(true, m.has_optional_lazy_message());\n  EXPECT_EQ(45, m.optional_lazy_message().bb());\n\n  EXPECT_EQ(1, m.repeated_int32_size());\n  EXPECT_EQ(100, m.repeated_int32(0));\n  EXPECT_EQ(1, m.repeated_string_size());\n  EXPECT_EQ(\"asdf\", m.repeated_string(0));\n  EXPECT_EQ(1, m.repeated_bytes_size());\n  EXPECT_EQ(\"jkl;\", m.repeated_bytes(0));\n  EXPECT_EQ(1, m.repeated_nested_message_size());\n  EXPECT_EQ(46, m.repeated_nested_message(0).bb());\n  EXPECT_EQ(1, m.repeated_foreign_message_size());\n  EXPECT_EQ(47, m.repeated_foreign_message(0).c());\n  EXPECT_EQ(1, m.repeated_nested_enum_size());\n  EXPECT_EQ(proto3_arena_unittest::TestAllTypes_NestedEnum_BAZ,\n            m.repeated_nested_enum(0));\n  EXPECT_EQ(1, m.repeated_foreign_enum_size());\n  EXPECT_EQ(proto3_arena_unittest::FOREIGN_BAZ,\n            m.repeated_foreign_enum(0));\n  EXPECT_EQ(1, m.repeated_lazy_message_size());\n  EXPECT_EQ(49, m.repeated_lazy_message(0).bb());\n\n  EXPECT_EQ(proto3_arena_unittest::TestAllTypes::kOneofString,\n            m.oneof_field_case());\n  EXPECT_EQ(\"test\", m.oneof_string());\n}\n\n// In this file we only test some basic functionalities of arena support in\n// proto3 and expect the arena support to be fully tested in proto2 unittests\n// because proto3 shares most code with proto2.\n\nTEST(Proto3ArenaTest, Parsing) {\n  TestAllTypes original;\n  SetAllFields(&original);\n\n  Arena arena;\n  TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena);\n  arena_message->ParseFromString(original.SerializeAsString());\n  ExpectAllFieldsSet(*arena_message);\n}\n\nTEST(Proto3ArenaTest, UnknownFields) {\n  TestAllTypes original;\n  SetAllFields(&original);\n\n  Arena arena;\n  TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena);\n  arena_message->ParseFromString(original.SerializeAsString());\n  ExpectAllFieldsSet(*arena_message);\n\n  // In proto3 we can still get a pointer to the UnknownFieldSet through\n  // reflection API.\n  UnknownFieldSet* unknown_fields =\n      arena_message->GetReflection()->MutableUnknownFields(arena_message);\n  // We can modify this UnknownFieldSet.\n  unknown_fields->AddVarint(1, 2);\n  // But the change will never will serialized back.\n  ASSERT_EQ(original.ByteSize(), arena_message->ByteSize());\n  ASSERT_TRUE(\n      arena_message->GetReflection()->GetUnknownFields(*arena_message).empty());\n}\n\nTEST(Proto3ArenaTest, Swap) {\n  Arena arena1;\n  Arena arena2;\n\n  // Test Swap().\n  TestAllTypes* arena1_message = Arena::CreateMessage<TestAllTypes>(&arena1);\n  TestAllTypes* arena2_message = Arena::CreateMessage<TestAllTypes>(&arena2);\n  arena1_message->Swap(arena2_message);\n  EXPECT_EQ(&arena1, arena1_message->GetArena());\n  EXPECT_EQ(&arena2, arena2_message->GetArena());\n}\n\nTEST(Proto3ArenaTest, SetAllocatedMessage) {\n  Arena arena;\n  TestAllTypes *arena_message = Arena::CreateMessage<TestAllTypes>(&arena);\n  TestAllTypes::NestedMessage* nested = new TestAllTypes::NestedMessage;\n  nested->set_bb(118);\n  arena_message->set_allocated_optional_nested_message(nested);\n  EXPECT_EQ(118, arena_message->optional_nested_message().bb());\n}\n\nTEST(Proto3ArenaTest, ReleaseMessage) {\n  Arena arena;\n  TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena);\n  arena_message->mutable_optional_nested_message()->set_bb(118);\n  google::protobuf::scoped_ptr<TestAllTypes::NestedMessage> nested(\n      arena_message->release_optional_nested_message());\n  EXPECT_EQ(118, nested->bb());\n}\n\nTEST(Proto3ArenaTest, MessageFieldClear) {\n  // GitHub issue #310: https://github.com/google/protobuf/issues/310\n  Arena arena;\n  TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena);\n  arena_message->mutable_optional_nested_message()->set_bb(118);\n  // This should not crash, but prior to the bugfix, it tried to use `operator\n  // delete` the nested message (which is on the arena):\n  arena_message->Clear();\n}\n\nTEST(Proto3ArenaTest, MessageFieldClearViaReflection) {\n  Arena arena;\n  TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena);\n  const Reflection* r = message->GetReflection();\n  const Descriptor* d = message->GetDescriptor();\n  const FieldDescriptor* msg_field = d->FindFieldByName(\n      \"optional_nested_message\");\n\n  message->mutable_optional_nested_message()->set_bb(1);\n  r->ClearField(message, msg_field);\n  EXPECT_FALSE(message->has_optional_nested_message());\n  EXPECT_EQ(0, message->optional_nested_message().bb());\n}\n\n}  // namespace\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/proto3_lite_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <string>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <vector>\n\n#include <google/protobuf/test_util.h>\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/unittest_proto3_lite.pb.h>\n#include <google/protobuf/arena.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nusing proto3_lite_unittest::TestAllTypes;\n\nnamespace protobuf {\nnamespace {\n// We selectively set/check a few representative fields rather than all fields\n// as this test is only expected to cover the basics of lite support.\nvoid SetAllFields(TestAllTypes* m) {\n  m->set_optional_int32(100);\n  m->set_optional_string(\"asdf\");\n  m->set_optional_bytes(\"jkl;\");\n  m->mutable_optional_nested_message()->set_bb(42);\n  m->mutable_optional_foreign_message()->set_c(43);\n  m->set_optional_nested_enum(\n      proto3_lite_unittest::TestAllTypes_NestedEnum_BAZ);\n  m->set_optional_foreign_enum(\n      proto3_lite_unittest::FOREIGN_BAZ);\n  m->mutable_optional_lazy_message()->set_bb(45);\n  m->add_repeated_int32(100);\n  m->add_repeated_string(\"asdf\");\n  m->add_repeated_bytes(\"jkl;\");\n  m->add_repeated_nested_message()->set_bb(46);\n  m->add_repeated_foreign_message()->set_c(47);\n  m->add_repeated_nested_enum(\n      proto3_lite_unittest::TestAllTypes_NestedEnum_BAZ);\n  m->add_repeated_foreign_enum(\n      proto3_lite_unittest::FOREIGN_BAZ);\n  m->add_repeated_lazy_message()->set_bb(49);\n\n  m->set_oneof_uint32(1);\n  m->mutable_oneof_nested_message()->set_bb(50);\n  m->set_oneof_string(\"test\");  // only this one remains set\n}\n\nvoid ExpectAllFieldsSet(const TestAllTypes& m) {\n  EXPECT_EQ(100, m.optional_int32());\n  EXPECT_EQ(\"asdf\", m.optional_string());\n  EXPECT_EQ(\"jkl;\", m.optional_bytes());\n  EXPECT_EQ(true, m.has_optional_nested_message());\n  EXPECT_EQ(42, m.optional_nested_message().bb());\n  EXPECT_EQ(true, m.has_optional_foreign_message());\n  EXPECT_EQ(43, m.optional_foreign_message().c());\n  EXPECT_EQ(proto3_lite_unittest::TestAllTypes_NestedEnum_BAZ,\n            m.optional_nested_enum());\n  EXPECT_EQ(proto3_lite_unittest::FOREIGN_BAZ,\n            m.optional_foreign_enum());\n  EXPECT_EQ(true, m.has_optional_lazy_message());\n  EXPECT_EQ(45, m.optional_lazy_message().bb());\n\n  EXPECT_EQ(1, m.repeated_int32_size());\n  EXPECT_EQ(100, m.repeated_int32(0));\n  EXPECT_EQ(1, m.repeated_string_size());\n  EXPECT_EQ(\"asdf\", m.repeated_string(0));\n  EXPECT_EQ(1, m.repeated_bytes_size());\n  EXPECT_EQ(\"jkl;\", m.repeated_bytes(0));\n  EXPECT_EQ(1, m.repeated_nested_message_size());\n  EXPECT_EQ(46, m.repeated_nested_message(0).bb());\n  EXPECT_EQ(1, m.repeated_foreign_message_size());\n  EXPECT_EQ(47, m.repeated_foreign_message(0).c());\n  EXPECT_EQ(1, m.repeated_nested_enum_size());\n  EXPECT_EQ(proto3_lite_unittest::TestAllTypes_NestedEnum_BAZ,\n            m.repeated_nested_enum(0));\n  EXPECT_EQ(1, m.repeated_foreign_enum_size());\n  EXPECT_EQ(proto3_lite_unittest::FOREIGN_BAZ,\n            m.repeated_foreign_enum(0));\n  EXPECT_EQ(1, m.repeated_lazy_message_size());\n  EXPECT_EQ(49, m.repeated_lazy_message(0).bb());\n\n  EXPECT_EQ(proto3_lite_unittest::TestAllTypes::kOneofString,\n            m.oneof_field_case());\n  EXPECT_EQ(\"test\", m.oneof_string());\n}\n\n// In this file we only test some basic functionalities of in proto3 and expect\n// the rest is fully tested in proto2 unittests because proto3 shares most code\n// with proto2.\n\nTEST(Proto3LiteTest, Parsing) {\n  TestAllTypes original;\n  SetAllFields(&original);\n\n  TestAllTypes msg;\n  msg.ParseFromString(original.SerializeAsString());\n  ExpectAllFieldsSet(msg);\n}\n\nTEST(Proto3LiteTest, Swap) {\n  // Test Swap().\n  TestAllTypes msg1;\n  TestAllTypes msg2;\n  msg1.set_optional_string(\"123\");\n  msg2.set_optional_string(\"3456\");\n  msg1.Swap(&msg2);\n  EXPECT_EQ(\"3456\", msg1.optional_string());\n  EXPECT_EQ(\"123\", msg2.optional_string());\n  EXPECT_EQ(msg1.ByteSize(), msg2.ByteSize() + 1);\n}\n\n}  // namespace\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/reflection.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This header defines the RepeatedFieldRef class template used to access\n// repeated fields with protobuf reflection API.\n#ifndef GOOGLE_PROTOBUF_REFLECTION_H__\n#define GOOGLE_PROTOBUF_REFLECTION_H__\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#include <google/protobuf/message.h>\n#include <google/protobuf/generated_enum_util.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\ntemplate<typename T, typename Enable = void>\nstruct RefTypeTraits;\n}  // namespace internal\n\ntemplate<typename T>\nRepeatedFieldRef<T> Reflection::GetRepeatedFieldRef(\n    const Message& message, const FieldDescriptor* field) const {\n  return RepeatedFieldRef<T>(message, field);\n}\n\ntemplate<typename T>\nMutableRepeatedFieldRef<T> Reflection::GetMutableRepeatedFieldRef(\n    Message* message, const FieldDescriptor* field) const {\n  return MutableRepeatedFieldRef<T>(message, field);\n}\n\n// RepeatedFieldRef definition for non-message types.\ntemplate<typename T>\nclass RepeatedFieldRef<\n    T, typename internal::enable_if<!internal::is_base_of<Message, T>::value>::type> {\n  typedef typename internal::RefTypeTraits<T>::iterator IteratorType;\n  typedef typename internal::RefTypeTraits<T>::AccessorType AccessorType;\n\n public:\n  bool empty() const {\n    return accessor_->IsEmpty(data_);\n  }\n  int size() const {\n    return accessor_->Size(data_);\n  }\n  T Get(int index) const {\n    return accessor_->template Get<T>(data_, index);\n  }\n\n  typedef IteratorType iterator;\n  typedef IteratorType const_iterator;\n  iterator begin() const {\n    return iterator(data_, accessor_, true);\n  }\n  iterator end() const {\n    return iterator(data_, accessor_, false);\n  }\n\n private:\n  friend class Reflection;\n  RepeatedFieldRef(\n      const Message& message,\n      const FieldDescriptor* field) {\n    const Reflection* reflection = message.GetReflection();\n    data_ = reflection->RepeatedFieldData(\n        const_cast<Message*>(&message), field,\n        internal::RefTypeTraits<T>::cpp_type, NULL);\n    accessor_ = reflection->RepeatedFieldAccessor(field);\n  }\n\n  const void* data_;\n  const AccessorType* accessor_;\n};\n\n// MutableRepeatedFieldRef definition for non-message types.\ntemplate<typename T>\nclass MutableRepeatedFieldRef<\n    T, typename internal::enable_if<!internal::is_base_of<Message, T>::value>::type> {\n  typedef typename internal::RefTypeTraits<T>::AccessorType AccessorType;\n\n public:\n  bool empty() const {\n    return accessor_->IsEmpty(data_);\n  }\n  int size() const {\n    return accessor_->Size(data_);\n  }\n  T Get(int index) const {\n    return accessor_->template Get<T>(data_, index);\n  }\n\n  void Set(int index, const T& value) const {\n    accessor_->template Set<T>(data_, index, value);\n  }\n  void Add(const T& value) const {\n    accessor_->template Add<T>(data_, value);\n  }\n  void RemoveLast() const {\n    accessor_->RemoveLast(data_);\n  }\n  void SwapElements(int index1, int index2) const {\n    accessor_->SwapElements(data_, index1, index2);\n  }\n  void Clear() const {\n    accessor_->Clear(data_);\n  }\n\n  void Swap(const MutableRepeatedFieldRef& other) const {\n    accessor_->Swap(data_, other.accessor_, other.data_);\n  }\n\n  template<typename Container>\n  void MergeFrom(const Container& container) const {\n    typedef typename Container::const_iterator Iterator;\n    for (Iterator it = container.begin(); it != container.end(); ++it) {\n      Add(*it);\n    }\n  }\n  template<typename Container>\n  void CopyFrom(const Container& container) const {\n    Clear();\n    MergeFrom(container);\n  }\n\n private:\n  friend class Reflection;\n  MutableRepeatedFieldRef(\n      Message* message,\n      const FieldDescriptor* field) {\n    const Reflection* reflection = message->GetReflection();\n    data_ = reflection->RepeatedFieldData(\n        message, field, internal::RefTypeTraits<T>::cpp_type, NULL);\n    accessor_ = reflection->RepeatedFieldAccessor(field);\n  }\n\n  void* data_;\n  const AccessorType* accessor_;\n};\n\n// RepeatedFieldRef definition for message types.\ntemplate<typename T>\nclass RepeatedFieldRef<\n    T, typename internal::enable_if<internal::is_base_of<Message, T>::value>::type> {\n  typedef typename internal::RefTypeTraits<T>::iterator IteratorType;\n  typedef typename internal::RefTypeTraits<T>::AccessorType AccessorType;\n\n public:\n  bool empty() const {\n    return accessor_->IsEmpty(data_);\n  }\n  int size() const {\n    return accessor_->Size(data_);\n  }\n  // This method returns a reference to the underlying message object if it\n  // exists. If a message object doesn't exist (e.g., data stored in serialized\n  // form), scratch_space will be filled with the data and a reference to it\n  // will be returned.\n  //\n  // Example:\n  //   RepeatedFieldRef<Message> h = ...\n  //   unique_ptr<Message> scratch_space(h.NewMessage());\n  //   const Message& item = h.Get(index, scratch_space.get());\n  const T& Get(int index, T* scratch_space) const {\n    return *static_cast<const T*>(accessor_->Get(data_, index, scratch_space));\n  }\n  // Create a new message of the same type as the messages stored in this\n  // repeated field. Caller takes ownership of the returned object.\n  T* NewMessage() const {\n    return static_cast<T*>(default_instance_->New());\n  }\n\n  typedef IteratorType iterator;\n  typedef IteratorType const_iterator;\n  iterator begin() const {\n    return iterator(data_, accessor_, true, NewMessage());\n  }\n  iterator end() const {\n    return iterator(data_, accessor_, false, NewMessage());\n  }\n\n private:\n  friend class Reflection;\n  RepeatedFieldRef(\n      const Message& message,\n      const FieldDescriptor* field) {\n    const Reflection* reflection = message.GetReflection();\n    data_ = reflection->RepeatedFieldData(\n        const_cast<Message*>(&message), field,\n        internal::RefTypeTraits<T>::cpp_type,\n        internal::RefTypeTraits<T>::GetMessageFieldDescriptor());\n    accessor_ = reflection->RepeatedFieldAccessor(field);\n    default_instance_ =\n        reflection->GetMessageFactory()->GetPrototype(field->message_type());\n  }\n\n  const void* data_;\n  const AccessorType* accessor_;\n  const Message* default_instance_;\n};\n\n// MutableRepeatedFieldRef definition for message types.\ntemplate<typename T>\nclass MutableRepeatedFieldRef<\n    T, typename internal::enable_if<internal::is_base_of<Message, T>::value>::type> {\n  typedef typename internal::RefTypeTraits<T>::AccessorType AccessorType;\n\n public:\n  bool empty() const {\n    return accessor_->IsEmpty(data_);\n  }\n  int size() const {\n    return accessor_->Size(data_);\n  }\n  // See comments for RepeatedFieldRef<Message>::Get()\n  const T& Get(int index, T* scratch_space) const {\n    return *static_cast<const T*>(accessor_->Get(data_, index, scratch_space));\n  }\n  // Create a new message of the same type as the messages stored in this\n  // repeated field. Caller takes ownership of the returned object.\n  T* NewMessage() const {\n    return static_cast<T*>(default_instance_->New());\n  }\n\n  void Set(int index, const T& value) const {\n    accessor_->Set(data_, index, &value);\n  }\n  void Add(const T& value) const {\n    accessor_->Add(data_, &value);\n  }\n  void RemoveLast() const {\n    accessor_->RemoveLast(data_);\n  }\n  void SwapElements(int index1, int index2) const {\n    accessor_->SwapElements(data_, index1, index2);\n  }\n  void Clear() const {\n    accessor_->Clear(data_);\n  }\n\n  void Swap(const MutableRepeatedFieldRef& other) const {\n    accessor_->Swap(data_, other.accessor_, other.data_);\n  }\n\n  template<typename Container>\n  void MergeFrom(const Container& container) const {\n    typedef typename Container::const_iterator Iterator;\n    for (Iterator it = container.begin(); it != container.end(); ++it) {\n      Add(*it);\n    }\n  }\n  template<typename Container>\n  void CopyFrom(const Container& container) const {\n    Clear();\n    MergeFrom(container);\n  }\n\n private:\n  friend class Reflection;\n  MutableRepeatedFieldRef(\n      Message* message,\n      const FieldDescriptor* field) {\n    const Reflection* reflection = message->GetReflection();\n    data_ = reflection->RepeatedFieldData(\n        message, field, internal::RefTypeTraits<T>::cpp_type,\n        internal::RefTypeTraits<T>::GetMessageFieldDescriptor());\n    accessor_ = reflection->RepeatedFieldAccessor(field);\n    default_instance_ =\n        reflection->GetMessageFactory()->GetPrototype(field->message_type());\n  }\n\n  void* data_;\n  const AccessorType* accessor_;\n  const Message* default_instance_;\n};\n\nnamespace internal {\n// Interfaces used to implement reflection RepeatedFieldRef API.\n// Reflection::GetRepeatedAccessor() should return a pointer to an singleton\n// object that implements the below interface.\n//\n// This interface passes/returns values using void pointers. The actual type\n// of the value depends on the field's cpp_type. Following is a mapping from\n// cpp_type to the type that should be used in this interface:\n//\n//   field->cpp_type()      T                Actual type of void*\n//   CPPTYPE_INT32        int32                   int32\n//   CPPTYPE_UINT32       uint32                  uint32\n//   CPPTYPE_INT64        int64                   int64\n//   CPPTYPE_UINT64       uint64                  uint64\n//   CPPTYPE_DOUBLE       double                  double\n//   CPPTYPE_FLOAT        float                   float\n//   CPPTYPE_BOOL         bool                    bool\n//   CPPTYPE_ENUM         generated enum type     int32\n//   CPPTYPE_STRING       string                  string\n//   CPPTYPE_MESSAGE      generated message type  google::protobuf::Message\n//                        or google::protobuf::Message\n//\n// Note that for enums we use int32 in the interface.\n//\n// You can map from T to the actual type using RefTypeTraits:\n//   typedef RefTypeTraits<T>::AccessorValueType ActualType;\nclass LIBPROTOBUF_EXPORT RepeatedFieldAccessor {\n public:\n  // Typedefs for clarity.\n  typedef void Field;\n  typedef void Value;\n  typedef void Iterator;\n\n  virtual ~RepeatedFieldAccessor();\n  virtual bool IsEmpty(const Field* data) const = 0;\n  virtual int Size(const Field* data) const = 0;\n  // Depends on the underlying representation of the repeated field, this\n  // method can return a pointer to the underlying object if such an object\n  // exists, or fill the data into scratch_space and return scratch_space.\n  // Callers of this method must ensure scratch_space is a valid pointer\n  // to a mutable object of the correct type.\n  virtual const Value* Get(\n      const Field* data, int index, Value* scratch_space) const = 0;\n\n  virtual void Clear(Field* data) const = 0;\n  virtual void Set(Field* data, int index, const Value* value) const = 0;\n  virtual void Add(Field* data, const Value* value) const = 0;\n  virtual void RemoveLast(Field* data) const = 0;\n  virtual void SwapElements(Field* data, int index1, int index2) const = 0;\n  virtual void Swap(Field* data, const RepeatedFieldAccessor* other_mutator,\n                    Field* other_data) const = 0;\n\n  // Create an iterator that points at the beginning of the repeated field.\n  virtual Iterator* BeginIterator(const Field* data) const = 0;\n  // Create an iterator that points at the end of the repeated field.\n  virtual Iterator* EndIterator(const Field* data) const = 0;\n  // Make a copy of an iterator and return the new copy.\n  virtual Iterator* CopyIterator(const Field* data,\n                                 const Iterator* iterator) const = 0;\n  // Move an iterator to point to the next element.\n  virtual Iterator* AdvanceIterator(const Field* data,\n                                    Iterator* iterator) const = 0;\n  // Compare whether two iterators point to the same element.\n  virtual bool EqualsIterator(const Field* data, const Iterator* a,\n                              const Iterator* b) const = 0;\n  // Delete an iterator created by BeginIterator(), EndIterator() and\n  // CopyIterator().\n  virtual void DeleteIterator(const Field* data, Iterator* iterator) const = 0;\n  // Like Get() but for iterators.\n  virtual const Value* GetIteratorValue(const Field* data,\n                                        const Iterator* iterator,\n                                        Value* scratch_space) const = 0;\n\n  // Templated methods that make using this interface easier for non-message\n  // types.\n  template<typename T>\n  T Get(const Field* data, int index) const {\n    typedef typename RefTypeTraits<T>::AccessorValueType ActualType;\n    ActualType scratch_space;\n    return static_cast<T>(\n        *reinterpret_cast<const ActualType*>(\n            Get(data, index, static_cast<Value*>(&scratch_space))));\n  }\n\n  template<typename T, typename ValueType>\n  void Set(Field* data, int index, const ValueType& value) const {\n    typedef typename RefTypeTraits<T>::AccessorValueType ActualType;\n    // In this RepeatedFieldAccessor interface we pass/return data using\n    // raw pointers. Type of the data these raw pointers point to should\n    // be ActualType. Here we have a ValueType object and want a ActualType\n    // pointer. We can't cast a ValueType pointer to an ActualType pointer\n    // directly because their type might be different (for enums ValueType\n    // may be a generated enum type while ActualType is int32). To be safe\n    // we make a copy to get a temporary ActualType object and use it.\n    ActualType tmp = static_cast<ActualType>(value);\n    Set(data, index, static_cast<const Value*>(&tmp));\n  }\n\n  template<typename T, typename ValueType>\n  void Add(Field* data, const ValueType& value) const {\n    typedef typename RefTypeTraits<T>::AccessorValueType ActualType;\n    // In this RepeatedFieldAccessor interface we pass/return data using\n    // raw pointers. Type of the data these raw pointers point to should\n    // be ActualType. Here we have a ValueType object and want a ActualType\n    // pointer. We can't cast a ValueType pointer to an ActualType pointer\n    // directly because their type might be different (for enums ValueType\n    // may be a generated enum type while ActualType is int32). To be safe\n    // we make a copy to get a temporary ActualType object and use it.\n    ActualType tmp = static_cast<ActualType>(value);\n    Add(data, static_cast<const Value*>(&tmp));\n  }\n};\n\n// Implement (Mutable)RepeatedFieldRef::iterator\ntemplate<typename T>\nclass RepeatedFieldRefIterator\n    : public std::iterator<std::forward_iterator_tag, T> {\n  typedef typename RefTypeTraits<T>::AccessorValueType AccessorValueType;\n  typedef typename RefTypeTraits<T>::IteratorValueType IteratorValueType;\n  typedef typename RefTypeTraits<T>::IteratorPointerType IteratorPointerType;\n\n public:\n  // Constructor for non-message fields.\n  RepeatedFieldRefIterator(const void* data,\n                           const RepeatedFieldAccessor* accessor,\n                           bool begin)\n      : data_(data), accessor_(accessor),\n        iterator_(begin ? accessor->BeginIterator(data) :\n                          accessor->EndIterator(data)),\n        scratch_space_(new AccessorValueType) {\n  }\n  // Constructor for message fields.\n  RepeatedFieldRefIterator(const void* data,\n                           const RepeatedFieldAccessor* accessor,\n                           bool begin,\n                           AccessorValueType* scratch_space)\n      : data_(data), accessor_(accessor),\n        iterator_(begin ? accessor->BeginIterator(data) :\n                          accessor->EndIterator(data)),\n        scratch_space_(scratch_space) {\n  }\n  ~RepeatedFieldRefIterator() {\n    accessor_->DeleteIterator(data_, iterator_);\n  }\n  RepeatedFieldRefIterator operator++(int) {\n    RepeatedFieldRefIterator tmp(*this);\n    iterator_ = accessor_->AdvanceIterator(data_, iterator_);\n    return tmp;\n  }\n  RepeatedFieldRefIterator& operator++() {\n    iterator_ = accessor_->AdvanceIterator(data_, iterator_);\n    return *this;\n  }\n  IteratorValueType operator*() const {\n    return static_cast<IteratorValueType>(\n        *static_cast<const AccessorValueType*>(\n            accessor_->GetIteratorValue(\n                data_, iterator_, scratch_space_.get())));\n  }\n  IteratorPointerType operator->() const {\n    return static_cast<IteratorPointerType>(\n        accessor_->GetIteratorValue(\n            data_, iterator_, scratch_space_.get()));\n  }\n  bool operator!=(const RepeatedFieldRefIterator& other) const {\n    assert(data_ == other.data_);\n    assert(accessor_ == other.accessor_);\n    return !accessor_->EqualsIterator(data_, iterator_, other.iterator_);\n  }\n  bool operator==(const RepeatedFieldRefIterator& other) const {\n    return !this->operator!=(other);\n  }\n\n  RepeatedFieldRefIterator(const RepeatedFieldRefIterator& other)\n      : data_(other.data_), accessor_(other.accessor_),\n        iterator_(accessor_->CopyIterator(data_, other.iterator_)) {\n  }\n  RepeatedFieldRefIterator& operator=(const RepeatedFieldRefIterator& other) {\n    if (this != &other) {\n      accessor_->DeleteIterator(data_, iterator_);\n      data_ = other.data_;\n      accessor_ = other.accessor_;\n      iterator_ = accessor_->CopyIterator(data_, other.iterator_);\n    }\n    return *this;\n  }\n\n protected:\n  const void* data_;\n  const RepeatedFieldAccessor* accessor_;\n  void* iterator_;\n  google::protobuf::scoped_ptr<AccessorValueType> scratch_space_;\n};\n\n// TypeTraits that maps the type parameter T of RepeatedFieldRef or\n// MutableRepeatedFieldRef to corresponding iterator type,\n// RepeatedFieldAccessor type, etc.\ntemplate<typename T>\nstruct PrimitiveTraits {\n  static const bool is_primitive = false;\n};\n#define DEFINE_PRIMITIVE(TYPE, type) \\\n    template<> struct PrimitiveTraits<type> { \\\n      static const bool is_primitive = true; \\\n      static const FieldDescriptor::CppType cpp_type = \\\n          FieldDescriptor::CPPTYPE_ ## TYPE; \\\n    };\nDEFINE_PRIMITIVE(INT32, int32)\nDEFINE_PRIMITIVE(UINT32, uint32)\nDEFINE_PRIMITIVE(INT64, int64)\nDEFINE_PRIMITIVE(UINT64, uint64)\nDEFINE_PRIMITIVE(FLOAT, float)\nDEFINE_PRIMITIVE(DOUBLE, double)\nDEFINE_PRIMITIVE(BOOL, bool)\n#undef DEFINE_PRIMITIVE\n\ntemplate<typename T>\nstruct RefTypeTraits<\n    T, typename internal::enable_if<PrimitiveTraits<T>::is_primitive>::type> {\n  typedef RepeatedFieldRefIterator<T> iterator;\n  typedef RepeatedFieldAccessor AccessorType;\n  typedef T AccessorValueType;\n  typedef T IteratorValueType;\n  typedef T* IteratorPointerType;\n  static const FieldDescriptor::CppType cpp_type =\n      PrimitiveTraits<T>::cpp_type;\n  static const Descriptor* GetMessageFieldDescriptor() {\n    return NULL;\n  }\n};\n\ntemplate<typename T>\nstruct RefTypeTraits<\n    T, typename internal::enable_if<is_proto_enum<T>::value>::type> {\n  typedef RepeatedFieldRefIterator<T> iterator;\n  typedef RepeatedFieldAccessor AccessorType;\n  // We use int32 for repeated enums in RepeatedFieldAccessor.\n  typedef int32 AccessorValueType;\n  typedef T IteratorValueType;\n  typedef int32* IteratorPointerType;\n  static const FieldDescriptor::CppType cpp_type =\n      FieldDescriptor::CPPTYPE_ENUM;\n  static const Descriptor* GetMessageFieldDescriptor() {\n    return NULL;\n  }\n};\n\ntemplate<typename T>\nstruct RefTypeTraits<\n    T, typename internal::enable_if< ::google::protobuf::internal::is_same<string, T>::value>::type> {\n  typedef RepeatedFieldRefIterator<T> iterator;\n  typedef RepeatedFieldAccessor AccessorType;\n  typedef string AccessorValueType;\n  typedef string IteratorValueType;\n  typedef string* IteratorPointerType;\n  static const FieldDescriptor::CppType cpp_type =\n      FieldDescriptor::CPPTYPE_STRING;\n  static const Descriptor* GetMessageFieldDescriptor() {\n    return NULL;\n  }\n};\n\ntemplate<typename T>\nstruct MessageDescriptorGetter {\n  static const Descriptor* get() {\n    return T::default_instance().GetDescriptor();\n  }\n};\ntemplate<>\nstruct MessageDescriptorGetter<Message> {\n  static const Descriptor* get() {\n    return NULL;\n  }\n};\n\ntemplate<typename T>\nstruct RefTypeTraits<\n    T, typename internal::enable_if<internal::is_base_of<Message, T>::value>::type> {\n  typedef RepeatedFieldRefIterator<T> iterator;\n  typedef RepeatedFieldAccessor AccessorType;\n  typedef Message AccessorValueType;\n  typedef const T& IteratorValueType;\n  typedef const T* IteratorPointerType;\n  static const FieldDescriptor::CppType cpp_type =\n      FieldDescriptor::CPPTYPE_MESSAGE;\n  static const Descriptor* GetMessageFieldDescriptor() {\n    return MessageDescriptorGetter<T>::get();\n  }\n};\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_REFLECTION_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/reflection_internal.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_REFLECTION_INTERNAL_H__\n#define GOOGLE_PROTOBUF_REFLECTION_INTERNAL_H__\n\n#include <google/protobuf/map_field.h>\n#include <google/protobuf/reflection.h>\n#include <google/protobuf/repeated_field.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n// A base class for RepeatedFieldAccessor implementations that can support\n// random-access efficiently. All iterator methods delegates the work to\n// corresponding random-access methods.\nclass RandomAccessRepeatedFieldAccessor : public RepeatedFieldAccessor {\n public:\n  virtual ~RandomAccessRepeatedFieldAccessor() {}\n\n  virtual Iterator* BeginIterator(const Field* data) const {\n    return PositionToIterator(0);\n  }\n  virtual Iterator* EndIterator(const Field* data) const {\n    return PositionToIterator(this->Size(data));\n  }\n  virtual Iterator* CopyIterator(const Field* data,\n                                 const Iterator* iterator) const {\n    return const_cast<Iterator*>(iterator);\n  }\n  virtual Iterator* AdvanceIterator(const Field* data,\n                                    Iterator* iterator) const {\n    return PositionToIterator(IteratorToPosition(iterator) + 1);\n  }\n  virtual bool EqualsIterator(const Field* data,\n                              const Iterator* a,\n                              const Iterator* b) const {\n    return a == b;\n  }\n  virtual void DeleteIterator(const Field* data, Iterator* iterator) const {\n  }\n  virtual const Value* GetIteratorValue(const Field* data,\n                                        const Iterator* iterator,\n                                        Value* scratch_space) const {\n    return Get(data, static_cast<int>(IteratorToPosition(iterator)),\n               scratch_space);\n  }\n\n private:\n  static intptr_t IteratorToPosition(const Iterator* iterator) {\n    return reinterpret_cast<intptr_t>(iterator);\n  }\n  static Iterator* PositionToIterator(intptr_t position) {\n    return reinterpret_cast<Iterator*>(position);\n  }\n};\n\n// Base class for RepeatedFieldAccessor implementations that manipulates\n// RepeatedField<T>.\ntemplate<typename T>\nclass RepeatedFieldWrapper : public RandomAccessRepeatedFieldAccessor {\n public:\n  RepeatedFieldWrapper() {}\n  virtual ~RepeatedFieldWrapper() {}\n  virtual bool IsEmpty(const Field* data) const {\n    return GetRepeatedField(data)->empty();\n  }\n  virtual int Size(const Field* data) const {\n    return GetRepeatedField(data)->size();\n  }\n  virtual const Value* Get(const Field* data, int index,\n                          Value* scratch_space) const {\n    return ConvertFromT(GetRepeatedField(data)->Get(index), scratch_space);\n  }\n  virtual void Clear(Field* data) const {\n    MutableRepeatedField(data)->Clear();\n  }\n  virtual void Set(Field* data, int index, const Value* value) const {\n    MutableRepeatedField(data)->Set(index, ConvertToT(value));\n  }\n  virtual void Add(Field* data, const Value* value) const {\n    MutableRepeatedField(data)->Add(ConvertToT(value));\n  }\n  virtual void RemoveLast(Field* data) const {\n    MutableRepeatedField(data)->RemoveLast();\n  }\n  virtual void SwapElements(Field* data, int index1, int index2) const {\n    MutableRepeatedField(data)->SwapElements(index1, index2);\n  }\n\n protected:\n  typedef RepeatedField<T> RepeatedFieldType;\n  static const RepeatedFieldType* GetRepeatedField(const Field* data) {\n    return reinterpret_cast<const RepeatedFieldType*>(data);\n  }\n  static RepeatedFieldType* MutableRepeatedField(Field* data) {\n    return reinterpret_cast<RepeatedFieldType*>(data);\n  }\n\n  // Convert an object recevied by this accessor to an object to be stored in\n  // the underlying RepeatedField.\n  virtual T ConvertToT(const Value* value) const = 0;\n\n  // Convert an object stored in RepeatedPtrField to an object that will be\n  // returned by this accessor. If the two objects have the same type (true\n  // for string fields with ctype=STRING), a pointer to the source object can\n  // be returned directly. Otherwise, data should be copied from value to\n  // scratch_space and scratch_space should be returned.\n  virtual const Value* ConvertFromT(const T& value,\n                                    Value* scratch_space) const = 0;\n};\n\n// Base class for RepeatedFieldAccessor implementations that manipulates\n// RepeatedPtrField<T>.\ntemplate<typename T>\nclass RepeatedPtrFieldWrapper : public RandomAccessRepeatedFieldAccessor {\n public:\n  RepeatedPtrFieldWrapper() {}\n  virtual ~RepeatedPtrFieldWrapper() {}\n  virtual bool IsEmpty(const Field* data) const {\n    return GetRepeatedField(data)->empty();\n  }\n  virtual int Size(const Field* data) const {\n    return GetRepeatedField(data)->size();\n  }\n  virtual const Value* Get(const Field* data, int index,\n                           Value* scratch_space) const {\n    return ConvertFromT(GetRepeatedField(data)->Get(index), scratch_space);\n  }\n  virtual void Clear(Field* data) const {\n    MutableRepeatedField(data)->Clear();\n  }\n  virtual void Set(Field* data, int index, const Value* value) const {\n    ConvertToT(value, MutableRepeatedField(data)->Mutable(index));\n  }\n  virtual void Add(Field* data, const Value* value) const {\n    T* allocated = New(value);\n    ConvertToT(value, allocated);\n    MutableRepeatedField(data)->AddAllocated(allocated);\n  }\n  virtual void RemoveLast(Field* data) const {\n    MutableRepeatedField(data)->RemoveLast();\n  }\n  virtual void SwapElements(Field* data, int index1, int index2) const {\n    MutableRepeatedField(data)->SwapElements(index1, index2);\n  }\n\n protected:\n  typedef RepeatedPtrField<T> RepeatedFieldType;\n  static const RepeatedFieldType* GetRepeatedField(const Field* data) {\n    return reinterpret_cast<const RepeatedFieldType*>(data);\n  }\n  static RepeatedFieldType* MutableRepeatedField(Field* data) {\n    return reinterpret_cast<RepeatedFieldType*>(data);\n  }\n\n  // Create a new T instance. For repeated message fields, T can be specified\n  // as google::protobuf::Message so we can't use \"new T()\" directly. In that case, value\n  // should be a message of the same type (it's ensured by the caller) and a\n  // new message object will be created using it.\n  virtual T* New(const Value* value) const = 0;\n\n  // Convert an object received by this accessor to an object that will be\n  // stored in the underlying RepeatedPtrField.\n  virtual void ConvertToT(const Value* value, T* result) const = 0;\n\n  // Convert an object stored in RepeatedPtrField to an object that will be\n  // returned by this accessor. If the two objects have the same type (true\n  // for string fields with ctype=STRING), a pointer to the source object can\n  // be returned directly. Otherwise, data should be copied from value to\n  // scratch_space and scratch_space should be returned.\n  virtual const Value* ConvertFromT(const T& value,\n                                    Value* scratch_space) const = 0;\n};\n\n// An implementation of RandomAccessRepeatedFieldAccessor that manipulates\n// MapFieldBase.\nclass MapFieldAccessor : public RandomAccessRepeatedFieldAccessor {\n public:\n  MapFieldAccessor() {}\n  virtual ~MapFieldAccessor() {}\n  virtual bool IsEmpty(const Field* data) const {\n    return GetRepeatedField(data)->empty();\n  }\n  virtual int Size(const Field* data) const {\n    return GetRepeatedField(data)->size();\n  }\n  virtual const Value* Get(const Field* data, int index,\n                           Value* scratch_space) const {\n    return ConvertFromEntry(GetRepeatedField(data)->Get(index), scratch_space);\n  }\n  virtual void Clear(Field* data) const {\n    MutableRepeatedField(data)->Clear();\n  }\n  virtual void Set(Field* data, int index, const Value* value) const {\n    ConvertToEntry(value, MutableRepeatedField(data)->Mutable(index));\n  }\n  virtual void Add(Field* data, const Value* value) const {\n    Message* allocated = New(value);\n    ConvertToEntry(value, allocated);\n    MutableRepeatedField(data)->AddAllocated(allocated);\n  }\n  virtual void RemoveLast(Field* data) const {\n    MutableRepeatedField(data)->RemoveLast();\n  }\n  virtual void SwapElements(Field* data, int index1, int index2) const {\n    MutableRepeatedField(data)->SwapElements(index1, index2);\n  }\n  virtual void Swap(\n      Field* data,\n      const internal::RepeatedFieldAccessor* other_mutator,\n      Field* other_data) const {\n    GOOGLE_CHECK(this == other_mutator);\n    MutableRepeatedField(data)->Swap(MutableRepeatedField(other_data));\n  }\n\n protected:\n  typedef RepeatedPtrField<Message> RepeatedFieldType;\n  static const RepeatedFieldType* GetRepeatedField(const Field* data) {\n    return reinterpret_cast<const RepeatedFieldType*>(\n        (&reinterpret_cast<const MapFieldBase*>(data)->GetRepeatedField()));\n  }\n  static RepeatedFieldType* MutableRepeatedField(Field* data) {\n    return reinterpret_cast<RepeatedFieldType*>(\n        reinterpret_cast<MapFieldBase*>(data)->MutableRepeatedField());\n  }\n  virtual Message* New(const Value* value) const {\n    return static_cast<const Message*>(value)->New();\n  }\n  // Convert an object received by this accessor to an MapEntry message to be\n  // stored in the underlying MapFieldBase.\n  virtual void ConvertToEntry(const Value* value, Message* result) const {\n    result->CopyFrom(*static_cast<const Message*>(value));\n  }\n  // Convert a MapEntry message stored in the underlying MapFieldBase to an\n  // object that will be returned by this accessor.\n  virtual const Value* ConvertFromEntry(const Message& value,\n                                        Value* scratch_space) const {\n    return static_cast<const Value*>(&value);\n  }\n};\n\n// Default implementations of RepeatedFieldAccessor for primitive types.\ntemplate<typename T>\nclass RepeatedFieldPrimitiveAccessor : public RepeatedFieldWrapper<T> {\n  typedef void Field;\n  typedef void Value;\n  using RepeatedFieldWrapper<T>::MutableRepeatedField;\n\n public:\n  RepeatedFieldPrimitiveAccessor() {}\n  virtual ~RepeatedFieldPrimitiveAccessor() {}\n  virtual void Swap(\n      Field* data,\n      const internal::RepeatedFieldAccessor* other_mutator,\n      Field* other_data) const {\n    // Currently RepeatedFieldPrimitiveAccessor is the only implementation of\n    // RepeatedFieldAccessor for primitive types. As we are using singletons\n    // for these accessors, here \"other_mutator\" must be \"this\".\n    GOOGLE_CHECK(this == other_mutator);\n    MutableRepeatedField(data)->Swap(MutableRepeatedField(other_data));\n  }\n\n protected:\n  virtual T ConvertToT(const Value* value) const {\n    return *static_cast<const T*>(value);\n  }\n  virtual const Value* ConvertFromT(const T& value,\n                                    Value* scratch_space) const {\n    return static_cast<const Value*>(&value);\n  }\n};\n\n// Default implementation of RepeatedFieldAccessor for string fields with\n// ctype=STRING.\nclass RepeatedPtrFieldStringAccessor : public RepeatedPtrFieldWrapper<string> {\n  typedef void Field;\n  typedef void Value;\n  using RepeatedFieldAccessor::Add;\n\n public:\n  RepeatedPtrFieldStringAccessor() {}\n  virtual ~RepeatedPtrFieldStringAccessor() {}\n  virtual void Swap(\n      Field* data,\n      const internal::RepeatedFieldAccessor* other_mutator,\n      Field* other_data) const {\n    if (this == other_mutator) {\n      MutableRepeatedField(data)->Swap(MutableRepeatedField(other_data));\n    } else {\n      RepeatedPtrField<string> tmp;\n      tmp.Swap(MutableRepeatedField(data));\n      int other_size = other_mutator->Size(other_data);\n      for (int i = 0; i < other_size; ++i) {\n        Add<string>(data, other_mutator->Get<string>(other_data, i));\n      }\n      int size = Size(data);\n      other_mutator->Clear(other_data);\n      for (int i = 0; i < size; ++i) {\n        other_mutator->Add<string>(other_data, tmp.Get(i));\n      }\n    }\n  }\n\n protected:\n  virtual string* New(const Value*) const {\n    return new string();\n  }\n  virtual void ConvertToT(const Value* value, string* result) const {\n    *result = *static_cast<const string*>(value);\n  }\n  virtual const Value* ConvertFromT(const string& value,\n                                    Value* scratch_space) const {\n    return static_cast<const Value*>(&value);\n  }\n};\n\n\nclass RepeatedPtrFieldMessageAccessor\n    : public RepeatedPtrFieldWrapper<Message> {\n  typedef void Field;\n  typedef void Value;\n\n public:\n  RepeatedPtrFieldMessageAccessor() {}\n  virtual ~RepeatedPtrFieldMessageAccessor() {}\n  virtual void Swap(\n      Field* data,\n      const internal::RepeatedFieldAccessor* other_mutator,\n      Field* other_data) const {\n    GOOGLE_CHECK(this == other_mutator);\n    MutableRepeatedField(data)->Swap(MutableRepeatedField(other_data));\n  }\n\n protected:\n  virtual Message* New(const Value* value) const {\n    return static_cast<const Message*>(value)->New();\n  }\n  virtual void ConvertToT(const Value* value, Message* result) const {\n    result->CopyFrom(*static_cast<const Message*>(value));\n  }\n  virtual const Value* ConvertFromT(const Message& value,\n                                    Value* scratch_space) const {\n    return static_cast<const Value*>(&value);\n  }\n};\n}  // namespace internal\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_REFLECTION_INTERNAL_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/reflection_ops.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <string>\n#include <vector>\n\n#include <google/protobuf/reflection_ops.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/unknown_field_set.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\nvoid ReflectionOps::Copy(const Message& from, Message* to) {\n  if (&from == to) return;\n  Clear(to);\n  Merge(from, to);\n}\n\nvoid ReflectionOps::Merge(const Message& from, Message* to) {\n  GOOGLE_CHECK_NE(&from, to);\n\n  const Descriptor* descriptor = from.GetDescriptor();\n  GOOGLE_CHECK_EQ(to->GetDescriptor(), descriptor)\n    << \"Tried to merge messages of different types \"\n    << \"(merge \" << descriptor->full_name()\n    << \" to \" << to->GetDescriptor()->full_name() << \")\";\n\n  const Reflection* from_reflection = from.GetReflection();\n  const Reflection* to_reflection = to->GetReflection();\n\n  vector<const FieldDescriptor*> fields;\n  from_reflection->ListFields(from, &fields);\n  for (int i = 0; i < fields.size(); i++) {\n    const FieldDescriptor* field = fields[i];\n\n    if (field->is_repeated()) {\n      int count = from_reflection->FieldSize(from, field);\n      for (int j = 0; j < count; j++) {\n        switch (field->cpp_type()) {\n#define HANDLE_TYPE(CPPTYPE, METHOD)                                     \\\n          case FieldDescriptor::CPPTYPE_##CPPTYPE:                       \\\n            to_reflection->Add##METHOD(to, field,                        \\\n              from_reflection->GetRepeated##METHOD(from, field, j));     \\\n            break;\n\n          HANDLE_TYPE(INT32 , Int32 );\n          HANDLE_TYPE(INT64 , Int64 );\n          HANDLE_TYPE(UINT32, UInt32);\n          HANDLE_TYPE(UINT64, UInt64);\n          HANDLE_TYPE(FLOAT , Float );\n          HANDLE_TYPE(DOUBLE, Double);\n          HANDLE_TYPE(BOOL  , Bool  );\n          HANDLE_TYPE(STRING, String);\n          HANDLE_TYPE(ENUM  , Enum  );\n#undef HANDLE_TYPE\n\n          case FieldDescriptor::CPPTYPE_MESSAGE:\n            to_reflection->AddMessage(to, field)->MergeFrom(\n              from_reflection->GetRepeatedMessage(from, field, j));\n            break;\n        }\n      }\n    } else {\n      switch (field->cpp_type()) {\n#define HANDLE_TYPE(CPPTYPE, METHOD)                                        \\\n        case FieldDescriptor::CPPTYPE_##CPPTYPE:                            \\\n          to_reflection->Set##METHOD(to, field,                             \\\n            from_reflection->Get##METHOD(from, field));                     \\\n          break;\n\n        HANDLE_TYPE(INT32 , Int32 );\n        HANDLE_TYPE(INT64 , Int64 );\n        HANDLE_TYPE(UINT32, UInt32);\n        HANDLE_TYPE(UINT64, UInt64);\n        HANDLE_TYPE(FLOAT , Float );\n        HANDLE_TYPE(DOUBLE, Double);\n        HANDLE_TYPE(BOOL  , Bool  );\n        HANDLE_TYPE(STRING, String);\n        HANDLE_TYPE(ENUM  , Enum  );\n#undef HANDLE_TYPE\n\n        case FieldDescriptor::CPPTYPE_MESSAGE:\n          to_reflection->MutableMessage(to, field)->MergeFrom(\n            from_reflection->GetMessage(from, field));\n          break;\n      }\n    }\n  }\n\n  to_reflection->MutableUnknownFields(to)->MergeFrom(\n    from_reflection->GetUnknownFields(from));\n}\n\nvoid ReflectionOps::Clear(Message* message) {\n  const Reflection* reflection = message->GetReflection();\n\n  vector<const FieldDescriptor*> fields;\n  reflection->ListFields(*message, &fields);\n  for (int i = 0; i < fields.size(); i++) {\n    reflection->ClearField(message, fields[i]);\n  }\n\n  reflection->MutableUnknownFields(message)->Clear();\n}\n\nbool ReflectionOps::IsInitialized(const Message& message) {\n  const Descriptor* descriptor = message.GetDescriptor();\n  const Reflection* reflection = message.GetReflection();\n\n  // Check required fields of this message.\n  for (int i = 0; i < descriptor->field_count(); i++) {\n    if (descriptor->field(i)->is_required()) {\n      if (!reflection->HasField(message, descriptor->field(i))) {\n        return false;\n      }\n    }\n  }\n\n  // Check that sub-messages are initialized.\n  vector<const FieldDescriptor*> fields;\n  reflection->ListFields(message, &fields);\n  for (int i = 0; i < fields.size(); i++) {\n    const FieldDescriptor* field = fields[i];\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n\n      if (field->is_repeated()) {\n        int size = reflection->FieldSize(message, field);\n\n        for (int j = 0; j < size; j++) {\n          if (!reflection->GetRepeatedMessage(message, field, j)\n                          .IsInitialized()) {\n            return false;\n          }\n        }\n      } else {\n        if (!reflection->GetMessage(message, field).IsInitialized()) {\n          return false;\n        }\n      }\n    }\n  }\n\n  return true;\n}\n\nvoid ReflectionOps::DiscardUnknownFields(Message* message) {\n  const Reflection* reflection = message->GetReflection();\n\n  reflection->MutableUnknownFields(message)->Clear();\n\n  vector<const FieldDescriptor*> fields;\n  reflection->ListFields(*message, &fields);\n  for (int i = 0; i < fields.size(); i++) {\n    const FieldDescriptor* field = fields[i];\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n      if (field->is_repeated()) {\n        int size = reflection->FieldSize(*message, field);\n        for (int j = 0; j < size; j++) {\n          reflection->MutableRepeatedMessage(message, field, j)\n                    ->DiscardUnknownFields();\n        }\n      } else {\n        reflection->MutableMessage(message, field)->DiscardUnknownFields();\n      }\n    }\n  }\n}\n\nstatic string SubMessagePrefix(const string& prefix,\n                               const FieldDescriptor* field,\n                               int index) {\n  string result(prefix);\n  if (field->is_extension()) {\n    result.append(\"(\");\n    result.append(field->full_name());\n    result.append(\")\");\n  } else {\n    result.append(field->name());\n  }\n  if (index != -1) {\n    result.append(\"[\");\n    result.append(SimpleItoa(index));\n    result.append(\"]\");\n  }\n  result.append(\".\");\n  return result;\n}\n\nvoid ReflectionOps::FindInitializationErrors(\n    const Message& message,\n    const string& prefix,\n    vector<string>* errors) {\n  const Descriptor* descriptor = message.GetDescriptor();\n  const Reflection* reflection = message.GetReflection();\n\n  // Check required fields of this message.\n  for (int i = 0; i < descriptor->field_count(); i++) {\n    if (descriptor->field(i)->is_required()) {\n      if (!reflection->HasField(message, descriptor->field(i))) {\n        errors->push_back(prefix + descriptor->field(i)->name());\n      }\n    }\n  }\n\n  // Check sub-messages.\n  vector<const FieldDescriptor*> fields;\n  reflection->ListFields(message, &fields);\n  for (int i = 0; i < fields.size(); i++) {\n    const FieldDescriptor* field = fields[i];\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n\n      if (field->is_repeated()) {\n        int size = reflection->FieldSize(message, field);\n\n        for (int j = 0; j < size; j++) {\n          const Message& sub_message =\n            reflection->GetRepeatedMessage(message, field, j);\n          FindInitializationErrors(sub_message,\n                                   SubMessagePrefix(prefix, field, j),\n                                   errors);\n        }\n      } else {\n        const Message& sub_message = reflection->GetMessage(message, field);\n        FindInitializationErrors(sub_message,\n                                 SubMessagePrefix(prefix, field, -1),\n                                 errors);\n      }\n    }\n  }\n}\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/reflection_ops.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This header is logically internal, but is made public because it is used\n// from protocol-compiler-generated code, which may reside in other components.\n\n#ifndef GOOGLE_PROTOBUF_REFLECTION_OPS_H__\n#define GOOGLE_PROTOBUF_REFLECTION_OPS_H__\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/message.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\n// Basic operations that can be performed using reflection.\n// These can be used as a cheap way to implement the corresponding\n// methods of the Message interface, though they are likely to be\n// slower than implementations tailored for the specific message type.\n//\n// This class should stay limited to operations needed to implement\n// the Message interface.\n//\n// This class is really a namespace that contains only static methods.\nclass LIBPROTOBUF_EXPORT ReflectionOps {\n public:\n  static void Copy(const Message& from, Message* to);\n  static void Merge(const Message& from, Message* to);\n  static void Clear(Message* message);\n  static bool IsInitialized(const Message& message);\n  static void DiscardUnknownFields(Message* message);\n\n  // Finds all unset required fields in the message and adds their full\n  // paths (e.g. \"foo.bar[5].baz\") to *names.  \"prefix\" will be attached to\n  // the front of each name.\n  static void FindInitializationErrors(const Message& message,\n                                       const string& prefix,\n                                       vector<string>* errors);\n\n private:\n  // All methods are static.  No need to construct.\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ReflectionOps);\n};\n\n}  // namespace internal\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_REFLECTION_OPS_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/reflection_ops_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/reflection_ops.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/test_util.h>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\nnamespace {\n\nTEST(ReflectionOpsTest, SanityCheck) {\n  unittest::TestAllTypes message;\n\n  TestUtil::SetAllFields(&message);\n  TestUtil::ExpectAllFieldsSet(message);\n}\n\nTEST(ReflectionOpsTest, Copy) {\n  unittest::TestAllTypes message, message2;\n\n  TestUtil::SetAllFields(&message);\n\n  ReflectionOps::Copy(message, &message2);\n\n  TestUtil::ExpectAllFieldsSet(message2);\n\n  // Copying from self should be a no-op.\n  ReflectionOps::Copy(message2, &message2);\n  TestUtil::ExpectAllFieldsSet(message2);\n}\n\nTEST(ReflectionOpsTest, CopyExtensions) {\n  unittest::TestAllExtensions message, message2;\n\n  TestUtil::SetAllExtensions(&message);\n\n  ReflectionOps::Copy(message, &message2);\n\n  TestUtil::ExpectAllExtensionsSet(message2);\n}\n\nTEST(ReflectionOpsTest, CopyOneof) {\n  unittest::TestOneof2 message, message2;\n  TestUtil::SetOneof1(&message);\n  ReflectionOps::Copy(message, &message2);\n  TestUtil::ExpectOneofSet1(message2);\n\n  TestUtil::SetOneof2(&message);\n  TestUtil::ExpectOneofSet2(message);\n  ReflectionOps::Copy(message, &message2);\n  TestUtil::ExpectOneofSet2(message2);\n}\n\nTEST(ReflectionOpsTest, Merge) {\n  // Note:  Copy is implemented in terms of Merge() so technically the Copy\n  //   test already tested most of this.\n\n  unittest::TestAllTypes message, message2;\n\n  TestUtil::SetAllFields(&message);\n\n  // This field will test merging into an empty spot.\n  message2.set_optional_int32(message.optional_int32());\n  message.clear_optional_int32();\n\n  // This tests overwriting.\n  message2.set_optional_string(message.optional_string());\n  message.set_optional_string(\"something else\");\n\n  // This tests concatenating.\n  message2.add_repeated_int32(message.repeated_int32(1));\n  int32 i = message.repeated_int32(0);\n  message.clear_repeated_int32();\n  message.add_repeated_int32(i);\n\n  ReflectionOps::Merge(message2, &message);\n\n  TestUtil::ExpectAllFieldsSet(message);\n}\n\nTEST(ReflectionOpsTest, MergeExtensions) {\n  // Note:  Copy is implemented in terms of Merge() so technically the Copy\n  //   test already tested most of this.\n\n  unittest::TestAllExtensions message, message2;\n\n  TestUtil::SetAllExtensions(&message);\n\n  // This field will test merging into an empty spot.\n  message2.SetExtension(unittest::optional_int32_extension,\n    message.GetExtension(unittest::optional_int32_extension));\n  message.ClearExtension(unittest::optional_int32_extension);\n\n  // This tests overwriting.\n  message2.SetExtension(unittest::optional_string_extension,\n    message.GetExtension(unittest::optional_string_extension));\n  message.SetExtension(unittest::optional_string_extension, \"something else\");\n\n  // This tests concatenating.\n  message2.AddExtension(unittest::repeated_int32_extension,\n    message.GetExtension(unittest::repeated_int32_extension, 1));\n  int32 i = message.GetExtension(unittest::repeated_int32_extension, 0);\n  message.ClearExtension(unittest::repeated_int32_extension);\n  message.AddExtension(unittest::repeated_int32_extension, i);\n\n  ReflectionOps::Merge(message2, &message);\n\n  TestUtil::ExpectAllExtensionsSet(message);\n}\n\nTEST(ReflectionOpsTest, MergeUnknown) {\n  // Test that the messages' UnknownFieldSets are correctly merged.\n  unittest::TestEmptyMessage message1, message2;\n  message1.mutable_unknown_fields()->AddVarint(1234, 1);\n  message2.mutable_unknown_fields()->AddVarint(1234, 2);\n\n  ReflectionOps::Merge(message2, &message1);\n\n  ASSERT_EQ(2, message1.unknown_fields().field_count());\n  ASSERT_EQ(UnknownField::TYPE_VARINT,\n            message1.unknown_fields().field(0).type());\n  EXPECT_EQ(1, message1.unknown_fields().field(0).varint());\n  ASSERT_EQ(UnknownField::TYPE_VARINT,\n            message1.unknown_fields().field(1).type());\n  EXPECT_EQ(2, message1.unknown_fields().field(1).varint());\n}\n\nTEST(ReflectionOpsTest, MergeOneof) {\n  unittest::TestOneof2 message1, message2;\n  TestUtil::SetOneof1(&message1);\n\n  // Merge to empty message\n  ReflectionOps::Merge(message1, &message2);\n  TestUtil::ExpectOneofSet1(message2);\n\n  // Merge with the same oneof fields\n  ReflectionOps::Merge(message1, &message2);\n  TestUtil::ExpectOneofSet1(message2);\n\n  // Merge with different oneof fields\n  TestUtil::SetOneof2(&message1);\n  ReflectionOps::Merge(message1, &message2);\n  TestUtil::ExpectOneofSet2(message2);\n}\n\n#ifdef PROTOBUF_HAS_DEATH_TEST\n\nTEST(ReflectionOpsTest, MergeFromSelf) {\n  // Note:  Copy is implemented in terms of Merge() so technically the Copy\n  //   test already tested most of this.\n\n  unittest::TestAllTypes message;\n\n  EXPECT_DEATH(\n    ReflectionOps::Merge(message, &message),\n    \"&from\");\n}\n\n#endif  // PROTOBUF_HAS_DEATH_TEST\n\nTEST(ReflectionOpsTest, Clear) {\n  unittest::TestAllTypes message;\n\n  TestUtil::SetAllFields(&message);\n\n  ReflectionOps::Clear(&message);\n\n  TestUtil::ExpectClear(message);\n\n  // Check that getting embedded messages returns the objects created during\n  // SetAllFields() rather than default instances.\n  EXPECT_NE(&unittest::TestAllTypes::OptionalGroup::default_instance(),\n            &message.optionalgroup());\n  EXPECT_NE(&unittest::TestAllTypes::NestedMessage::default_instance(),\n            &message.optional_nested_message());\n  EXPECT_NE(&unittest::ForeignMessage::default_instance(),\n            &message.optional_foreign_message());\n  EXPECT_NE(&unittest_import::ImportMessage::default_instance(),\n            &message.optional_import_message());\n}\n\nTEST(ReflectionOpsTest, ClearExtensions) {\n  unittest::TestAllExtensions message;\n\n  TestUtil::SetAllExtensions(&message);\n\n  ReflectionOps::Clear(&message);\n\n  TestUtil::ExpectExtensionsClear(message);\n\n  // Check that getting embedded messages returns the objects created during\n  // SetAllExtensions() rather than default instances.\n  EXPECT_NE(&unittest::OptionalGroup_extension::default_instance(),\n            &message.GetExtension(unittest::optionalgroup_extension));\n  EXPECT_NE(&unittest::TestAllTypes::NestedMessage::default_instance(),\n            &message.GetExtension(unittest::optional_nested_message_extension));\n  EXPECT_NE(&unittest::ForeignMessage::default_instance(),\n            &message.GetExtension(\n              unittest::optional_foreign_message_extension));\n  EXPECT_NE(&unittest_import::ImportMessage::default_instance(),\n            &message.GetExtension(unittest::optional_import_message_extension));\n}\n\nTEST(ReflectionOpsTest, ClearUnknown) {\n  // Test that the message's UnknownFieldSet is correctly cleared.\n  unittest::TestEmptyMessage message;\n  message.mutable_unknown_fields()->AddVarint(1234, 1);\n\n  ReflectionOps::Clear(&message);\n\n  EXPECT_EQ(0, message.unknown_fields().field_count());\n}\n\nTEST(ReflectionOpsTest, ClearOneof) {\n  unittest::TestOneof2 message;\n\n  TestUtil::ExpectOneofClear(message);\n  TestUtil::SetOneof1(&message);\n  TestUtil::ExpectOneofSet1(message);\n  ReflectionOps::Clear(&message);\n  TestUtil::ExpectOneofClear(message);\n\n  TestUtil::SetOneof1(&message);\n  TestUtil::ExpectOneofSet1(message);\n  TestUtil::SetOneof2(&message);\n  TestUtil::ExpectOneofSet2(message);\n  ReflectionOps::Clear(&message);\n  TestUtil::ExpectOneofClear(message);\n}\n\nTEST(ReflectionOpsTest, DiscardUnknownFields) {\n  unittest::TestAllTypes message;\n  TestUtil::SetAllFields(&message);\n\n  // Set some unknown fields in message.\n  message.mutable_unknown_fields()\n        ->AddVarint(123456, 654321);\n  message.mutable_optional_nested_message()\n        ->mutable_unknown_fields()\n        ->AddVarint(123456, 654321);\n  message.mutable_repeated_nested_message(0)\n        ->mutable_unknown_fields()\n        ->AddVarint(123456, 654321);\n\n  EXPECT_EQ(1, message.unknown_fields().field_count());\n  EXPECT_EQ(1, message.optional_nested_message()\n                      .unknown_fields().field_count());\n  EXPECT_EQ(1, message.repeated_nested_message(0)\n                      .unknown_fields().field_count());\n\n  // Discard them.\n  ReflectionOps::DiscardUnknownFields(&message);\n  TestUtil::ExpectAllFieldsSet(message);\n\n  EXPECT_EQ(0, message.unknown_fields().field_count());\n  EXPECT_EQ(0, message.optional_nested_message()\n                      .unknown_fields().field_count());\n  EXPECT_EQ(0, message.repeated_nested_message(0)\n                      .unknown_fields().field_count());\n}\n\nTEST(ReflectionOpsTest, DiscardUnknownExtensions) {\n  unittest::TestAllExtensions message;\n  TestUtil::SetAllExtensions(&message);\n\n  // Set some unknown fields.\n  message.mutable_unknown_fields()\n        ->AddVarint(123456, 654321);\n  message.MutableExtension(unittest::optional_nested_message_extension)\n        ->mutable_unknown_fields()\n        ->AddVarint(123456, 654321);\n  message.MutableExtension(unittest::repeated_nested_message_extension, 0)\n        ->mutable_unknown_fields()\n        ->AddVarint(123456, 654321);\n\n  EXPECT_EQ(1, message.unknown_fields().field_count());\n  EXPECT_EQ(1,\n    message.GetExtension(unittest::optional_nested_message_extension)\n           .unknown_fields().field_count());\n  EXPECT_EQ(1,\n    message.GetExtension(unittest::repeated_nested_message_extension, 0)\n           .unknown_fields().field_count());\n\n  // Discard them.\n  ReflectionOps::DiscardUnknownFields(&message);\n  TestUtil::ExpectAllExtensionsSet(message);\n\n  EXPECT_EQ(0, message.unknown_fields().field_count());\n  EXPECT_EQ(0,\n    message.GetExtension(unittest::optional_nested_message_extension)\n           .unknown_fields().field_count());\n  EXPECT_EQ(0,\n    message.GetExtension(unittest::repeated_nested_message_extension, 0)\n           .unknown_fields().field_count());\n}\n\nTEST(ReflectionOpsTest, IsInitialized) {\n  unittest::TestRequired message;\n\n  EXPECT_FALSE(ReflectionOps::IsInitialized(message));\n  message.set_a(1);\n  EXPECT_FALSE(ReflectionOps::IsInitialized(message));\n  message.set_b(2);\n  EXPECT_FALSE(ReflectionOps::IsInitialized(message));\n  message.set_c(3);\n  EXPECT_TRUE(ReflectionOps::IsInitialized(message));\n}\n\nTEST(ReflectionOpsTest, ForeignIsInitialized) {\n  unittest::TestRequiredForeign message;\n\n  // Starts out initialized because the foreign message is itself an optional\n  // field.\n  EXPECT_TRUE(ReflectionOps::IsInitialized(message));\n\n  // Once we create that field, the message is no longer initialized.\n  message.mutable_optional_message();\n  EXPECT_FALSE(ReflectionOps::IsInitialized(message));\n\n  // Initialize it.  Now we're initialized.\n  message.mutable_optional_message()->set_a(1);\n  message.mutable_optional_message()->set_b(2);\n  message.mutable_optional_message()->set_c(3);\n  EXPECT_TRUE(ReflectionOps::IsInitialized(message));\n\n  // Add a repeated version of the message.  No longer initialized.\n  unittest::TestRequired* sub_message = message.add_repeated_message();\n  EXPECT_FALSE(ReflectionOps::IsInitialized(message));\n\n  // Initialize that repeated version.\n  sub_message->set_a(1);\n  sub_message->set_b(2);\n  sub_message->set_c(3);\n  EXPECT_TRUE(ReflectionOps::IsInitialized(message));\n}\n\nTEST(ReflectionOpsTest, ExtensionIsInitialized) {\n  unittest::TestAllExtensions message;\n\n  // Starts out initialized because the foreign message is itself an optional\n  // field.\n  EXPECT_TRUE(ReflectionOps::IsInitialized(message));\n\n  // Once we create that field, the message is no longer initialized.\n  message.MutableExtension(unittest::TestRequired::single);\n  EXPECT_FALSE(ReflectionOps::IsInitialized(message));\n\n  // Initialize it.  Now we're initialized.\n  message.MutableExtension(unittest::TestRequired::single)->set_a(1);\n  message.MutableExtension(unittest::TestRequired::single)->set_b(2);\n  message.MutableExtension(unittest::TestRequired::single)->set_c(3);\n  EXPECT_TRUE(ReflectionOps::IsInitialized(message));\n\n  // Add a repeated version of the message.  No longer initialized.\n  message.AddExtension(unittest::TestRequired::multi);\n  EXPECT_FALSE(ReflectionOps::IsInitialized(message));\n\n  // Initialize that repeated version.\n  message.MutableExtension(unittest::TestRequired::multi, 0)->set_a(1);\n  message.MutableExtension(unittest::TestRequired::multi, 0)->set_b(2);\n  message.MutableExtension(unittest::TestRequired::multi, 0)->set_c(3);\n  EXPECT_TRUE(ReflectionOps::IsInitialized(message));\n}\n\nTEST(ReflectionOpsTest, OneofIsInitialized) {\n  unittest::TestRequiredOneof message;\n  EXPECT_TRUE(ReflectionOps::IsInitialized(message));\n\n  message.mutable_foo_message();\n  EXPECT_FALSE(ReflectionOps::IsInitialized(message));\n\n  message.set_foo_int(1);\n  EXPECT_TRUE(ReflectionOps::IsInitialized(message));\n\n  message.mutable_foo_message();\n  EXPECT_FALSE(ReflectionOps::IsInitialized(message));\n  message.mutable_foo_message()->set_required_double(0.1);\n  EXPECT_TRUE(ReflectionOps::IsInitialized(message));\n}\n\nstatic string FindInitializationErrors(const Message& message) {\n  vector<string> errors;\n  ReflectionOps::FindInitializationErrors(message, \"\", &errors);\n  return Join(errors, \",\");\n}\n\nTEST(ReflectionOpsTest, FindInitializationErrors) {\n  unittest::TestRequired message;\n  EXPECT_EQ(\"a,b,c\", FindInitializationErrors(message));\n}\n\nTEST(ReflectionOpsTest, FindForeignInitializationErrors) {\n  unittest::TestRequiredForeign message;\n  message.mutable_optional_message();\n  message.add_repeated_message();\n  message.add_repeated_message();\n  EXPECT_EQ(\"optional_message.a,\"\n            \"optional_message.b,\"\n            \"optional_message.c,\"\n            \"repeated_message[0].a,\"\n            \"repeated_message[0].b,\"\n            \"repeated_message[0].c,\"\n            \"repeated_message[1].a,\"\n            \"repeated_message[1].b,\"\n            \"repeated_message[1].c\",\n            FindInitializationErrors(message));\n}\n\nTEST(ReflectionOpsTest, FindExtensionInitializationErrors) {\n  unittest::TestAllExtensions message;\n  message.MutableExtension(unittest::TestRequired::single);\n  message.AddExtension(unittest::TestRequired::multi);\n  message.AddExtension(unittest::TestRequired::multi);\n  EXPECT_EQ(\"(protobuf_unittest.TestRequired.single).a,\"\n            \"(protobuf_unittest.TestRequired.single).b,\"\n            \"(protobuf_unittest.TestRequired.single).c,\"\n            \"(protobuf_unittest.TestRequired.multi)[0].a,\"\n            \"(protobuf_unittest.TestRequired.multi)[0].b,\"\n            \"(protobuf_unittest.TestRequired.multi)[0].c,\"\n            \"(protobuf_unittest.TestRequired.multi)[1].a,\"\n            \"(protobuf_unittest.TestRequired.multi)[1].b,\"\n            \"(protobuf_unittest.TestRequired.multi)[1].c\",\n            FindInitializationErrors(message));\n}\n\nTEST(ReflectionOpsTest, FindOneofInitializationErrors) {\n  unittest::TestRequiredOneof message;\n  message.mutable_foo_message();\n  EXPECT_EQ(\"foo_message.required_double\",\n            FindInitializationErrors(message));\n}\n\n}  // namespace\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/repeated_field.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <algorithm>\n\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\n\nnamespace internal {\n\nvoid** RepeatedPtrFieldBase::InternalExtend(int extend_amount) {\n  int new_size = current_size_ + extend_amount;\n  if (total_size_ >= new_size) {\n    // N.B.: rep_ is non-NULL because extend_amount is always > 0, hence\n    // total_size must be non-zero since it is lower-bounded by new_size.\n    return &rep_->elements[current_size_];\n  }\n  Rep* old_rep = rep_;\n  Arena* arena = GetArenaNoVirtual();\n  new_size = std::max(kMinRepeatedFieldAllocationSize,\n                      std::max(total_size_ * 2, new_size));\n  GOOGLE_CHECK_LE(new_size,\n           (std::numeric_limits<size_t>::max() - kRepHeaderSize) /\n           sizeof(old_rep->elements[0]))\n      << \"Requested size is too large to fit into size_t.\";\n  if (arena == NULL) {\n    rep_ = reinterpret_cast<Rep*>(\n        new char[kRepHeaderSize + sizeof(old_rep->elements[0]) * new_size]);\n  } else {\n    rep_ = reinterpret_cast<Rep*>(\n        ::google::protobuf::Arena::CreateArray<char>(arena,\n            kRepHeaderSize + sizeof(old_rep->elements[0]) * new_size));\n  }\n  total_size_ = new_size;\n  if (old_rep && old_rep->allocated_size > 0) {\n    memcpy(rep_->elements, old_rep->elements,\n           old_rep->allocated_size * sizeof(rep_->elements[0]));\n    rep_->allocated_size = old_rep->allocated_size;\n  } else {\n    rep_->allocated_size = 0;\n  }\n  if (arena == NULL) {\n    delete [] reinterpret_cast<char*>(old_rep);\n  }\n  return &rep_->elements[current_size_];\n}\n\nvoid RepeatedPtrFieldBase::Reserve(int new_size) {\n  if (new_size > current_size_) {\n    InternalExtend(new_size - current_size_);\n  }\n}\n\nvoid RepeatedPtrFieldBase::CloseGap(int start, int num) {\n  if (rep_ == NULL) return;\n  // Close up a gap of \"num\" elements starting at offset \"start\".\n  for (int i = start + num; i < rep_->allocated_size; ++i)\n    rep_->elements[i - num] = rep_->elements[i];\n  current_size_ -= num;\n  rep_->allocated_size -= num;\n}\n\n}  // namespace internal\n\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/repeated_field.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// RepeatedField and RepeatedPtrField are used by generated protocol message\n// classes to manipulate repeated fields.  These classes are very similar to\n// STL's vector, but include a number of optimizations found to be useful\n// specifically in the case of Protocol Buffers.  RepeatedPtrField is\n// particularly different from STL vector as it manages ownership of the\n// pointers that it contains.\n//\n// Typically, clients should not need to access RepeatedField objects directly,\n// but should instead use the accessor functions generated automatically by the\n// protocol compiler.\n\n#ifndef GOOGLE_PROTOBUF_REPEATED_FIELD_H__\n#define GOOGLE_PROTOBUF_REPEATED_FIELD_H__\n\n#ifdef _MSC_VER\n// This is required for min/max on VS2013 only.\n#include <algorithm>\n#endif\n\n#include <string>\n#include <iterator>\n#include <google/protobuf/stubs/casts.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/type_traits.h>\n#include <google/protobuf/arena.h>\n#include <google/protobuf/generated_message_util.h>\n#include <google/protobuf/message_lite.h>\n\nnamespace google {\n\nnamespace upb {\nnamespace google_opensource {\nclass GMR_Handlers;\n}  // namespace google_opensource\n}  // namespace upb\n\nnamespace protobuf {\n\nclass Message;\n\nnamespace internal {\n\nstatic const int kMinRepeatedFieldAllocationSize = 4;\n\n// A utility function for logging that doesn't need any template types.\nvoid LogIndexOutOfBounds(int index, int size);\n\ntemplate <typename Iter>\ninline int CalculateReserve(Iter begin, Iter end, std::forward_iterator_tag) {\n  return std::distance(begin, end);\n}\n\ntemplate <typename Iter>\ninline int CalculateReserve(Iter /*begin*/, Iter /*end*/,\n                            std::input_iterator_tag /*unused*/) {\n  return -1;\n}\n\ntemplate <typename Iter>\ninline int CalculateReserve(Iter begin, Iter end) {\n  typedef typename std::iterator_traits<Iter>::iterator_category Category;\n  return CalculateReserve(begin, end, Category());\n}\n}  // namespace internal\n\n\n// RepeatedField is used to represent repeated fields of a primitive type (in\n// other words, everything except strings and nested Messages).  Most users will\n// not ever use a RepeatedField directly; they will use the get-by-index,\n// set-by-index, and add accessors that are generated for all repeated fields.\ntemplate <typename Element>\nclass RepeatedField {\n public:\n  RepeatedField();\n  explicit RepeatedField(Arena* arena);\n  RepeatedField(const RepeatedField& other);\n  template <typename Iter>\n  RepeatedField(Iter begin, const Iter& end);\n  ~RepeatedField();\n\n  RepeatedField& operator=(const RepeatedField& other);\n\n  bool empty() const;\n  int size() const;\n\n  const Element& Get(int index) const;\n  Element* Mutable(int index);\n  void Set(int index, const Element& value);\n  void Add(const Element& value);\n  Element* Add();\n  // Remove the last element in the array.\n  void RemoveLast();\n\n  // Extract elements with indices in \"[start .. start+num-1]\".\n  // Copy them into \"elements[0 .. num-1]\" if \"elements\" is not NULL.\n  // Caution: implementation also moves elements with indices [start+num ..].\n  // Calling this routine inside a loop can cause quadratic behavior.\n  void ExtractSubrange(int start, int num, Element* elements);\n\n  void Clear();\n  void MergeFrom(const RepeatedField& other);\n  void CopyFrom(const RepeatedField& other);\n\n  // Reserve space to expand the field to at least the given size.  If the\n  // array is grown, it will always be at least doubled in size.\n  void Reserve(int new_size);\n\n  // Resize the RepeatedField to a new, smaller size.  This is O(1).\n  void Truncate(int new_size);\n\n  void AddAlreadyReserved(const Element& value);\n  Element* AddAlreadyReserved();\n  int Capacity() const;\n\n  // Like STL resize.  Uses value to fill appended elements.\n  // Like Truncate() if new_size <= size(), otherwise this is\n  // O(new_size - size()).\n  void Resize(int new_size, const Element& value);\n\n  // Gets the underlying array.  This pointer is possibly invalidated by\n  // any add or remove operation.\n  Element* mutable_data();\n  const Element* data() const;\n\n  // Swap entire contents with \"other\". If they are separate arenas then, copies\n  // data between each other.\n  void Swap(RepeatedField* other);\n\n  // Swap entire contents with \"other\". Should be called only if the caller can\n  // guarantee that both repeated fields are on the same arena or are on the\n  // heap. Swapping between different arenas is disallowed and caught by a\n  // GOOGLE_DCHECK (see API docs for details).\n  void UnsafeArenaSwap(RepeatedField* other);\n\n  // Swap two elements.\n  void SwapElements(int index1, int index2);\n\n  // STL-like iterator support\n  typedef Element* iterator;\n  typedef const Element* const_iterator;\n  typedef Element value_type;\n  typedef value_type& reference;\n  typedef const value_type& const_reference;\n  typedef value_type* pointer;\n  typedef const value_type* const_pointer;\n  typedef int size_type;\n  typedef ptrdiff_t difference_type;\n\n  iterator begin();\n  const_iterator begin() const;\n  const_iterator cbegin() const;\n  iterator end();\n  const_iterator end() const;\n  const_iterator cend() const;\n\n  // Reverse iterator support\n  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;\n  typedef std::reverse_iterator<iterator> reverse_iterator;\n  reverse_iterator rbegin() {\n    return reverse_iterator(end());\n  }\n  const_reverse_iterator rbegin() const {\n    return const_reverse_iterator(end());\n  }\n  reverse_iterator rend() {\n    return reverse_iterator(begin());\n  }\n  const_reverse_iterator rend() const {\n    return const_reverse_iterator(begin());\n  }\n\n  // Returns the number of bytes used by the repeated field, excluding\n  // sizeof(*this)\n  int SpaceUsedExcludingSelf() const;\n\n  // Removes the element referenced by position.\n  //\n  // Returns an iterator to the element immediately following the removed\n  // element.\n  //\n  // Invalidates all iterators at or after the removed element, including end().\n  iterator erase(const_iterator position);\n\n  // Removes the elements in the range [first, last).\n  //\n  // Returns an iterator to the element immediately following the removed range.\n  //\n  // Invalidates all iterators at or after the removed range, including end().\n  iterator erase(const_iterator first, const_iterator last);\n\n  // Get the Arena on which this RepeatedField stores its elements.\n  ::google::protobuf::Arena* GetArena() const {\n    return GetArenaNoVirtual();\n  }\n\n private:\n  static const int kInitialSize = 0;\n  // A note on the representation here (see also comment below for\n  // RepeatedPtrFieldBase's struct Rep):\n  //\n  // We maintain the same sizeof(RepeatedField) as before we added arena support\n  // so that we do not degrade performance by bloating memory usage. Directly\n  // adding an arena_ element to RepeatedField is quite costly. By using\n  // indirection in this way, we keep the same size when the RepeatedField is\n  // empty (common case), and add only an 8-byte header to the elements array\n  // when non-empty. We make sure to place the size fields directly in the\n  // RepeatedField class to avoid costly cache misses due to the indirection.\n  int current_size_;\n  int total_size_;\n  struct Rep {\n    Arena* arena;\n    Element elements[1];\n  };\n  // We can not use sizeof(Rep) - sizeof(Element) due to the trailing padding on\n  // the struct. We can not use sizeof(Arena*) as well because there might be\n  // a \"gap\" after the field arena and before the field elements (e.g., when\n  // Element is double and pointer is 32bit).\n  static const size_t kRepHeaderSize;\n  // Contains arena ptr and the elements array. We also keep the invariant that\n  // if rep_ is NULL, then arena is NULL.\n  Rep* rep_;\n\n  friend class Arena;\n  typedef void InternalArenaConstructable_;\n\n  // Move the contents of |from| into |to|, possibly clobbering |from| in the\n  // process.  For primitive types this is just a memcpy(), but it could be\n  // specialized for non-primitive types to, say, swap each element instead.\n  void MoveArray(Element* to, Element* from, int size);\n\n  // Copy the elements of |from| into |to|.\n  void CopyArray(Element* to, const Element* from, int size);\n\n  inline void InternalSwap(RepeatedField* other);\n\n  // Internal helper expected by Arena methods.\n  inline Arena* GetArenaNoVirtual() const {\n    return (rep_ == NULL) ? NULL : rep_->arena;\n  }\n\n  // Internal helper to delete all elements and deallocate the storage.\n  // If Element has a trivial destructor (for example, if it's a fundamental\n  // type, like int32), the loop will be removed by the optimizer.\n  void InternalDeallocate(Rep* rep, int size) {\n    if (rep != NULL) {\n      Element* e = &rep->elements[0];\n      Element* limit = &rep->elements[size];\n      for (; e < limit; e++) {\n        e->Element::~Element();\n      }\n      if (rep->arena == NULL) {\n        delete[] reinterpret_cast<char*>(rep);\n      }\n    }\n  }\n};\n\ntemplate<typename Element>\nconst size_t RepeatedField<Element>::kRepHeaderSize =\n    reinterpret_cast<size_t>(&reinterpret_cast<Rep*>(16)->elements[0]) - 16;\n\nnamespace internal {\ntemplate <typename It> class RepeatedPtrIterator;\ntemplate <typename It, typename VoidPtr> class RepeatedPtrOverPtrsIterator;\n}  // namespace internal\n\nnamespace internal {\n\n// This is a helper template to copy an array of elements effeciently when they\n// have a trivial copy constructor, and correctly otherwise. This really\n// shouldn't be necessary, but our compiler doesn't optimize std::copy very\n// effectively.\ntemplate <typename Element,\n          bool HasTrivialCopy = has_trivial_copy<Element>::value>\nstruct ElementCopier {\n  void operator()(Element* to, const Element* from, int array_size);\n};\n\n}  // namespace internal\n\nnamespace internal {\n\n// type-traits helper for RepeatedPtrFieldBase: we only want to invoke\n// arena-related \"copy if on different arena\" behavior if the necessary methods\n// exist on the contained type. In particular, we rely on MergeFrom() existing\n// as a general proxy for the fact that a copy will work, and we also provide a\n// specific override for string*.\ntemplate<typename T>\nstruct TypeImplementsMergeBehavior {\n  typedef char HasMerge;\n  typedef long HasNoMerge;\n\n  // We accept either of:\n  // - void MergeFrom(const T& other)\n  // - bool MergeFrom(const T& other)\n  //\n  // We mangle these names a bit to avoid compatibility issues in 'unclean'\n  // include environments that may have, e.g., \"#define test ...\" (yes, this\n  // exists).\n  template<typename U, typename RetType, RetType (U::*)(const U& arg)>\n      struct CheckType;\n  template<typename U> static HasMerge Check(\n      CheckType<U, void, &U::MergeFrom>*);\n  template<typename U> static HasMerge Check(\n      CheckType<U, bool, &U::MergeFrom>*);\n  template<typename U> static HasNoMerge Check(...);\n\n  // Resovles to either google::protobuf::internal::true_type or google::protobuf::internal::false_type.\n  typedef google::protobuf::internal::integral_constant<bool,\n               (sizeof(Check<T>(0)) == sizeof(HasMerge))> type;\n};\n\ntemplate<>\nstruct TypeImplementsMergeBehavior< ::std::string > {\n  typedef google::protobuf::internal::true_type type;\n};\n\n// This is the common base class for RepeatedPtrFields.  It deals only in void*\n// pointers.  Users should not use this interface directly.\n//\n// The methods of this interface correspond to the methods of RepeatedPtrField,\n// but may have a template argument called TypeHandler.  Its signature is:\n//   class TypeHandler {\n//    public:\n//     typedef MyType Type;\n//     static Type* New();\n//     static void Delete(Type*);\n//     static void Clear(Type*);\n//     static void Merge(const Type& from, Type* to);\n//\n//     // Only needs to be implemented if SpaceUsedExcludingSelf() is called.\n//     static int SpaceUsed(const Type&);\n//   };\nclass LIBPROTOBUF_EXPORT RepeatedPtrFieldBase {\n protected:\n  // The reflection implementation needs to call protected methods directly,\n  // reinterpreting pointers as being to Message instead of a specific Message\n  // subclass.\n  friend class GeneratedMessageReflection;\n\n  // ExtensionSet stores repeated message extensions as\n  // RepeatedPtrField<MessageLite>, but non-lite ExtensionSets need to\n  // implement SpaceUsed(), and thus need to call SpaceUsedExcludingSelf()\n  // reinterpreting MessageLite as Message.  ExtensionSet also needs to make\n  // use of AddFromCleared(), which is not part of the public interface.\n  friend class ExtensionSet;\n\n  // The MapFieldBase implementation needs to call protected methods directly,\n  // reinterpreting pointers as being to Message instead of a specific Message\n  // subclass.\n  friend class MapFieldBase;\n\n  // To parse directly into a proto2 generated class, the upb class GMR_Handlers\n  // needs to be able to modify a RepeatedPtrFieldBase directly.\n  friend class upb::google_opensource::GMR_Handlers;\n\n  RepeatedPtrFieldBase();\n  explicit RepeatedPtrFieldBase(::google::protobuf::Arena* arena);\n  ~RepeatedPtrFieldBase() {}\n\n  // Must be called from destructor.\n  template <typename TypeHandler>\n  void Destroy();\n\n  bool empty() const;\n  int size() const;\n\n  template <typename TypeHandler>\n  const typename TypeHandler::Type& Get(int index) const;\n  template <typename TypeHandler>\n  typename TypeHandler::Type* Mutable(int index);\n  template <typename TypeHandler>\n  void Delete(int index);\n  template <typename TypeHandler>\n  typename TypeHandler::Type* Add(typename TypeHandler::Type* prototype = NULL);\n\n  template <typename TypeHandler>\n  void RemoveLast();\n  template <typename TypeHandler>\n  void Clear();\n  template <typename TypeHandler>\n  void MergeFrom(const RepeatedPtrFieldBase& other);\n  template <typename TypeHandler>\n  void CopyFrom(const RepeatedPtrFieldBase& other);\n\n  void CloseGap(int start, int num);\n\n  void Reserve(int new_size);\n\n  int Capacity() const;\n\n  // Used for constructing iterators.\n  void* const* raw_data() const;\n  void** raw_mutable_data() const;\n\n  template <typename TypeHandler>\n  typename TypeHandler::Type** mutable_data();\n  template <typename TypeHandler>\n  const typename TypeHandler::Type* const* data() const;\n\n  template <typename TypeHandler>\n  GOOGLE_ATTRIBUTE_ALWAYS_INLINE void Swap(RepeatedPtrFieldBase* other);\n\n  void SwapElements(int index1, int index2);\n\n  template <typename TypeHandler>\n  int SpaceUsedExcludingSelf() const;\n\n\n  // Advanced memory management --------------------------------------\n\n  // Like Add(), but if there are no cleared objects to use, returns NULL.\n  template <typename TypeHandler>\n  typename TypeHandler::Type* AddFromCleared();\n\n  template<typename TypeHandler>\n  void AddAllocated(typename TypeHandler::Type* value) {\n    typename TypeImplementsMergeBehavior<typename TypeHandler::Type>::type t;\n    AddAllocatedInternal<TypeHandler>(value, t);\n  }\n\n  template <typename TypeHandler>\n  void UnsafeArenaAddAllocated(typename TypeHandler::Type* value);\n\n  template <typename TypeHandler>\n  typename TypeHandler::Type* ReleaseLast() {\n    typename TypeImplementsMergeBehavior<typename TypeHandler::Type>::type t;\n    return ReleaseLastInternal<TypeHandler>(t);\n  }\n\n  // Releases last element and returns it, but does not do out-of-arena copy.\n  // And just returns the raw pointer to the contained element in the arena.\n  template <typename TypeHandler>\n  typename TypeHandler::Type* UnsafeArenaReleaseLast();\n\n  int ClearedCount() const;\n  template <typename TypeHandler>\n  void AddCleared(typename TypeHandler::Type* value);\n  template <typename TypeHandler>\n  typename TypeHandler::Type* ReleaseCleared();\n\n protected:\n  inline void InternalSwap(RepeatedPtrFieldBase* other);\n\n  template <typename TypeHandler>\n  void AddAllocatedInternal(typename TypeHandler::Type* value,\n                            google::protobuf::internal::true_type);\n  template <typename TypeHandler>\n  void AddAllocatedInternal(typename TypeHandler::Type* value,\n                            google::protobuf::internal::false_type);\n\n  template <typename TypeHandler> GOOGLE_ATTRIBUTE_NOINLINE\n  void AddAllocatedSlowWithCopy(typename TypeHandler::Type* value,\n                                Arena* value_arena,\n                                Arena* my_arena);\n  template <typename TypeHandler> GOOGLE_ATTRIBUTE_NOINLINE\n  void AddAllocatedSlowWithoutCopy(typename TypeHandler::Type* value);\n\n  template <typename TypeHandler>\n  typename TypeHandler::Type* ReleaseLastInternal(google::protobuf::internal::true_type);\n  template <typename TypeHandler>\n  typename TypeHandler::Type* ReleaseLastInternal(google::protobuf::internal::false_type);\n\n  template<typename TypeHandler> GOOGLE_ATTRIBUTE_NOINLINE\n  void SwapFallback(RepeatedPtrFieldBase* other);\n\n  inline Arena* GetArenaNoVirtual() const {\n    return arena_;\n  }\n\n private:\n  static const int kInitialSize = 0;\n  // A few notes on internal representation:\n  //\n  // We use an indirected approach, with struct Rep, to keep\n  // sizeof(RepeatedPtrFieldBase) equivalent to what it was before arena support\n  // was added, namely, 3 8-byte machine words on x86-64. An instance of Rep is\n  // allocated only when the repeated field is non-empty, and it is a\n  // dynamically-sized struct (the header is directly followed by elements[]).\n  // We place arena_ and current_size_ directly in the object to avoid cache\n  // misses due to the indirection, because these fields are checked frequently.\n  // Placing all fields directly in the RepeatedPtrFieldBase instance costs\n  // significant performance for memory-sensitive workloads.\n  Arena* arena_;\n  int    current_size_;\n  int    total_size_;\n  struct Rep {\n    int    allocated_size;\n    void*  elements[1];\n  };\n  static const size_t kRepHeaderSize = sizeof(Rep) - sizeof(void*);\n  // Contains arena ptr and the elements array. We also keep the invariant that\n  // if rep_ is NULL, then arena is NULL.\n  Rep* rep_;\n\n  template <typename TypeHandler>\n  static inline typename TypeHandler::Type* cast(void* element) {\n    return reinterpret_cast<typename TypeHandler::Type*>(element);\n  }\n  template <typename TypeHandler>\n  static inline const typename TypeHandler::Type* cast(const void* element) {\n    return reinterpret_cast<const typename TypeHandler::Type*>(element);\n  }\n\n  // Non-templated inner function to avoid code duplication. Takes a function\n  // pointer to the type-specific (templated) inner allocate/merge loop.\n  void MergeFromInternal(\n      const RepeatedPtrFieldBase& other,\n      void (RepeatedPtrFieldBase::*inner_loop)(void**, void**, int, int));\n\n  template<typename TypeHandler>\n  void MergeFromInnerLoop(\n      void** our_elems, void** other_elems, int length, int already_allocated);\n\n  // Internal helper: extend array space if necessary to contain |extend_amount|\n  // more elements, and return a pointer to the element immediately following\n  // the old list of elements.  This interface factors out common behavior from\n  // Reserve() and MergeFrom() to reduce code size. |extend_amount| must be > 0.\n  void** InternalExtend(int extend_amount);\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RepeatedPtrFieldBase);\n};\n\ntemplate <typename GenericType>\nclass GenericTypeHandler {\n public:\n  typedef GenericType Type;\n  static inline GenericType* New(Arena* arena) {\n    return ::google::protobuf::Arena::CreateMaybeMessage<Type>(\n        arena, static_cast<GenericType*>(0));\n  }\n  // We force NewFromPrototype() to be non-inline to reduce code size:\n  // else, several other methods get inlined copies of message types'\n  // constructors.\n  GOOGLE_ATTRIBUTE_NOINLINE static GenericType* NewFromPrototype(\n      const GenericType* prototype, ::google::protobuf::Arena* arena = NULL);\n  static inline void Delete(GenericType* value, Arena* arena) {\n    if (arena == NULL) {\n      delete value;\n    }\n  }\n  static inline ::google::protobuf::Arena* GetArena(GenericType* value) {\n    return ::google::protobuf::Arena::GetArena<Type>(value);\n  }\n  static inline void* GetMaybeArenaPointer(GenericType* value) {\n    return ::google::protobuf::Arena::GetArena<Type>(value);\n  }\n\n  static inline void Clear(GenericType* value) { value->Clear(); }\n  GOOGLE_ATTRIBUTE_NOINLINE static void Merge(const GenericType& from,\n                                       GenericType* to);\n  static inline int SpaceUsed(const GenericType& value) {\n    return value.SpaceUsed();\n  }\n  static inline const Type& default_instance() {\n    return Type::default_instance();\n  }\n};\n\ntemplate <typename GenericType>\nGenericType* GenericTypeHandler<GenericType>::NewFromPrototype(\n    const GenericType* /* prototype */, ::google::protobuf::Arena* arena) {\n  return New(arena);\n}\ntemplate <typename GenericType>\nvoid GenericTypeHandler<GenericType>::Merge(const GenericType& from,\n                                            GenericType* to) {\n  to->MergeFrom(from);\n}\n\n// NewFromPrototype() and Merge() cannot be defined here; if they're declared\n// inline the compiler will complain about not matching GOOGLE_ATTRIBUTE_NOINLINE\n// above, and if not, compilation will result in multiple definitions.  These\n// are therefore declared as specializations here and defined in\n// message_lite.cc.\ntemplate<>\nMessageLite* GenericTypeHandler<MessageLite>::NewFromPrototype(\n    const MessageLite* prototype, google::protobuf::Arena* arena);\ntemplate<>\ninline google::protobuf::Arena* GenericTypeHandler<MessageLite>::GetArena(\n    MessageLite* value) {\n  return value->GetArena();\n}\ntemplate<>\ninline void* GenericTypeHandler<MessageLite>::GetMaybeArenaPointer(\n    MessageLite* value) {\n  return value->GetMaybeArenaPointer();\n}\ntemplate <>\nvoid GenericTypeHandler<MessageLite>::Merge(const MessageLite& from,\n                                            MessageLite* to);\ntemplate<>\ninline void GenericTypeHandler<string>::Clear(string* value) {\n  value->clear();\n}\ntemplate<>\nvoid GenericTypeHandler<string>::Merge(const string& from,\n                                       string* to);\n\n// Declarations of the specialization as we cannot define them here, as the\n// header that defines ProtocolMessage depends on types defined in this header.\n#define DECLARE_SPECIALIZATIONS_FOR_BASE_PROTO_TYPES(TypeName)                 \\\n    template<>                                                                 \\\n    TypeName* GenericTypeHandler<TypeName>::NewFromPrototype(                  \\\n        const TypeName* prototype, google::protobuf::Arena* arena);                      \\\n    template<>                                                                 \\\n    google::protobuf::Arena* GenericTypeHandler<TypeName>::GetArena(                     \\\n        TypeName* value);                                                      \\\n    template<>                                                                 \\\n    void* GenericTypeHandler<TypeName>::GetMaybeArenaPointer(                  \\\n        TypeName* value);\n\n// Message specialization bodies defined in message.cc. This split is necessary\n// to allow proto2-lite (which includes this header) to be independent of\n// Message.\nDECLARE_SPECIALIZATIONS_FOR_BASE_PROTO_TYPES(Message)\n\n\n#undef DECLARE_SPECIALIZATIONS_FOR_BASE_PROTO_TYPES\n\ntemplate <>\ninline const MessageLite& GenericTypeHandler<MessageLite>::default_instance() {\n  // Yes, the behavior of the code is undefined, but this function is only\n  // called when we're already deep into the world of undefined, because the\n  // caller called Get(index) out of bounds.\n  MessageLite* null = NULL;\n  return *null;\n}\n\ntemplate <>\ninline const Message& GenericTypeHandler<Message>::default_instance() {\n  // Yes, the behavior of the code is undefined, but this function is only\n  // called when we're already deep into the world of undefined, because the\n  // caller called Get(index) out of bounds.\n  Message* null = NULL;\n  return *null;\n}\n\n\n// HACK:  If a class is declared as DLL-exported in MSVC, it insists on\n//   generating copies of all its methods -- even inline ones -- to include\n//   in the DLL.  But SpaceUsed() calls StringSpaceUsedExcludingSelf() which\n//   isn't in the lite library, therefore the lite library cannot link if\n//   StringTypeHandler is exported.  So, we factor out StringTypeHandlerBase,\n//   export that, then make StringTypeHandler be a subclass which is NOT\n//   exported.\n// TODO(kenton):  Now that StringSpaceUsedExcludingSelf() is in the lite\n//   library, this can be cleaned up.\nclass LIBPROTOBUF_EXPORT StringTypeHandlerBase {\n public:\n  typedef string Type;\n\n  static inline string* New(Arena* arena) {\n    return Arena::Create<string>(arena);\n  }\n  static inline string* NewFromPrototype(const string*,\n                                         ::google::protobuf::Arena* arena) {\n    return New(arena);\n  }\n  static inline ::google::protobuf::Arena* GetArena(string*) {\n    return NULL;\n  }\n  static inline void* GetMaybeArenaPointer(string* /* value */) {\n    return NULL;\n  }\n  static inline void Delete(string* value, Arena* arena) {\n    if (arena == NULL) {\n      delete value;\n    }\n  }\n  static inline void Clear(string* value) { value->clear(); }\n  static inline void Merge(const string& from, string* to) { *to = from; }\n  static inline const Type& default_instance() {\n    return ::google::protobuf::internal::GetEmptyString();\n  }\n};\n\nclass StringTypeHandler : public StringTypeHandlerBase {\n public:\n  static int SpaceUsed(const string& value)  {\n    return static_cast<int>(sizeof(value)) + StringSpaceUsedExcludingSelf(value);\n  }\n};\n\n\n}  // namespace internal\n\n// RepeatedPtrField is like RepeatedField, but used for repeated strings or\n// Messages.\ntemplate <typename Element>\nclass RepeatedPtrField : public internal::RepeatedPtrFieldBase {\n public:\n  RepeatedPtrField();\n  explicit RepeatedPtrField(::google::protobuf::Arena* arena);\n\n  RepeatedPtrField(const RepeatedPtrField& other);\n  template <typename Iter>\n  RepeatedPtrField(Iter begin, const Iter& end);\n  ~RepeatedPtrField();\n\n  RepeatedPtrField& operator=(const RepeatedPtrField& other);\n\n  bool empty() const;\n  int size() const;\n\n  const Element& Get(int index) const;\n  Element* Mutable(int index);\n  Element* Add();\n\n  // Remove the last element in the array.\n  // Ownership of the element is retained by the array.\n  void RemoveLast();\n\n  // Delete elements with indices in the range [start .. start+num-1].\n  // Caution: implementation moves all elements with indices [start+num .. ].\n  // Calling this routine inside a loop can cause quadratic behavior.\n  void DeleteSubrange(int start, int num);\n\n  void Clear();\n  void MergeFrom(const RepeatedPtrField& other);\n  void CopyFrom(const RepeatedPtrField& other);\n\n  // Reserve space to expand the field to at least the given size.  This only\n  // resizes the pointer array; it doesn't allocate any objects.  If the\n  // array is grown, it will always be at least doubled in size.\n  void Reserve(int new_size);\n\n  int Capacity() const;\n\n  // Gets the underlying array.  This pointer is possibly invalidated by\n  // any add or remove operation.\n  Element** mutable_data();\n  const Element* const* data() const;\n\n  // Swap entire contents with \"other\". If they are on separate arenas, then\n  // copies data.\n  void Swap(RepeatedPtrField* other);\n\n  // Swap entire contents with \"other\". Caller should guarantee that either both\n  // fields are on the same arena or both are on the heap. Swapping between\n  // different arenas with this function is disallowed and is caught via\n  // GOOGLE_DCHECK.\n  void UnsafeArenaSwap(RepeatedPtrField* other);\n\n  // Swap two elements.\n  void SwapElements(int index1, int index2);\n\n  // STL-like iterator support\n  typedef internal::RepeatedPtrIterator<Element> iterator;\n  typedef internal::RepeatedPtrIterator<const Element> const_iterator;\n  typedef Element value_type;\n  typedef value_type& reference;\n  typedef const value_type& const_reference;\n  typedef value_type* pointer;\n  typedef const value_type* const_pointer;\n  typedef int size_type;\n  typedef ptrdiff_t difference_type;\n\n  iterator begin();\n  const_iterator begin() const;\n  const_iterator cbegin() const;\n  iterator end();\n  const_iterator end() const;\n  const_iterator cend() const;\n\n  // Reverse iterator support\n  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;\n  typedef std::reverse_iterator<iterator> reverse_iterator;\n  reverse_iterator rbegin() {\n    return reverse_iterator(end());\n  }\n  const_reverse_iterator rbegin() const {\n    return const_reverse_iterator(end());\n  }\n  reverse_iterator rend() {\n    return reverse_iterator(begin());\n  }\n  const_reverse_iterator rend() const {\n    return const_reverse_iterator(begin());\n  }\n\n  // Custom STL-like iterator that iterates over and returns the underlying\n  // pointers to Element rather than Element itself.\n  typedef internal::RepeatedPtrOverPtrsIterator<Element, void*>\n  pointer_iterator;\n  typedef internal::RepeatedPtrOverPtrsIterator<const Element, const void*>\n  const_pointer_iterator;\n  pointer_iterator pointer_begin();\n  const_pointer_iterator pointer_begin() const;\n  pointer_iterator pointer_end();\n  const_pointer_iterator pointer_end() const;\n\n  // Returns (an estimate of) the number of bytes used by the repeated field,\n  // excluding sizeof(*this).\n  int SpaceUsedExcludingSelf() const;\n\n  // Advanced memory management --------------------------------------\n  // When hardcore memory management becomes necessary -- as it sometimes\n  // does here at Google -- the following methods may be useful.\n\n  // Add an already-allocated object, passing ownership to the\n  // RepeatedPtrField.\n  //\n  // Note that some special behavior occurs with respect to arenas:\n  //\n  //   (i) if this field holds submessages, the new submessage will be copied if\n  //   the original is in an arena and this RepeatedPtrField is either in a\n  //   different arena, or on the heap.\n  //   (ii) if this field holds strings, the passed-in string *must* be\n  //   heap-allocated, not arena-allocated. There is no way to dynamically check\n  //   this at runtime, so User Beware.\n  void AddAllocated(Element* value);\n\n  // Remove the last element and return it, passing ownership to the caller.\n  // Requires:  size() > 0\n  //\n  // If this RepeatedPtrField is on an arena, an object copy is required to pass\n  // ownership back to the user (for compatible semantics). Use\n  // UnsafeArenaReleaseLast() if this behavior is undesired.\n  Element* ReleaseLast();\n\n  // Add an already-allocated object, skipping arena-ownership checks. The user\n  // must guarantee that the given object is in the same arena as this\n  // RepeatedPtrField.\n  // It is also useful in legacy code that uses temporary ownership to avoid\n  // copies. Example:\n  // RepeatedPtrField<T> temp_field;\n  // temp_field.AddAllocated(new T);\n  // ... // Do something with temp_field\n  // temp_field.ExtractSubrange(0, temp_field.size(), NULL);\n  // If you put temp_field on the arena this fails, because the ownership\n  // transfers to the arena at the \"AddAllocated\" call and is not released\n  // anymore causing a double delete. UnsafeArenaAddAllocated prevents this.\n  void UnsafeArenaAddAllocated(Element* value);\n\n  // Remove the last element and return it.  Works only when operating on an\n  // arena. The returned pointer is to the original object in the arena, hence\n  // has the arena's lifetime.\n  // Requires:  current_size_ > 0\n  Element* UnsafeArenaReleaseLast();\n\n  // Extract elements with indices in the range \"[start .. start+num-1]\".\n  // The caller assumes ownership of the extracted elements and is responsible\n  // for deleting them when they are no longer needed.\n  // If \"elements\" is non-NULL, then pointers to the extracted elements\n  // are stored in \"elements[0 .. num-1]\" for the convenience of the caller.\n  // If \"elements\" is NULL, then the caller must use some other mechanism\n  // to perform any further operations (like deletion) on these elements.\n  // Caution: implementation also moves elements with indices [start+num ..].\n  // Calling this routine inside a loop can cause quadratic behavior.\n  //\n  // Memory copying behavior is identical to ReleaseLast(), described above: if\n  // this RepeatedPtrField is on an arena, an object copy is performed for each\n  // returned element, so that all returned element pointers are to\n  // heap-allocated copies. If this copy is not desired, the user should call\n  // UnsafeArenaExtractSubrange().\n  void ExtractSubrange(int start, int num, Element** elements);\n\n  // Identical to ExtractSubrange() described above, except that when this\n  // repeated field is on an arena, no object copies are performed. Instead, the\n  // raw object pointers are returned. Thus, if on an arena, the returned\n  // objects must not be freed, because they will not be heap-allocated objects.\n  void UnsafeArenaExtractSubrange(int start, int num, Element** elements);\n\n  // When elements are removed by calls to RemoveLast() or Clear(), they\n  // are not actually freed.  Instead, they are cleared and kept so that\n  // they can be reused later.  This can save lots of CPU time when\n  // repeatedly reusing a protocol message for similar purposes.\n  //\n  // Hardcore programs may choose to manipulate these cleared objects\n  // to better optimize memory management using the following routines.\n\n  // Get the number of cleared objects that are currently being kept\n  // around for reuse.\n  int ClearedCount() const;\n  // Add an element to the pool of cleared objects, passing ownership to\n  // the RepeatedPtrField.  The element must be cleared prior to calling\n  // this method.\n  //\n  // This method cannot be called when the repeated field is on an arena or when\n  // |value| is; both cases will trigger a GOOGLE_DCHECK-failure.\n  void AddCleared(Element* value);\n  // Remove a single element from the cleared pool and return it, passing\n  // ownership to the caller.  The element is guaranteed to be cleared.\n  // Requires:  ClearedCount() > 0\n  //\n  //\n  // This method cannot be called when the repeated field is on an arena; doing\n  // so will trigger a GOOGLE_DCHECK-failure.\n  Element* ReleaseCleared();\n\n  // Removes the element referenced by position.\n  //\n  // Returns an iterator to the element immediately following the removed\n  // element.\n  //\n  // Invalidates all iterators at or after the removed element, including end().\n  iterator erase(const_iterator position);\n\n  // Removes the elements in the range [first, last).\n  //\n  // Returns an iterator to the element immediately following the removed range.\n  //\n  // Invalidates all iterators at or after the removed range, including end().\n  iterator erase(const_iterator first, const_iterator last);\n\n  // Gets the arena on which this RepeatedPtrField stores its elements.\n  ::google::protobuf::Arena* GetArena() const {\n    return GetArenaNoVirtual();\n  }\n\n protected:\n  // Note:  RepeatedPtrField SHOULD NOT be subclassed by users.  We only\n  //   subclass it in one place as a hack for compatibility with proto1.  The\n  //   subclass needs to know about TypeHandler in order to call protected\n  //   methods on RepeatedPtrFieldBase.\n  class TypeHandler;\n\n  // Internal arena accessor expected by helpers in Arena.\n  inline Arena* GetArenaNoVirtual() const;\n\n private:\n  // Implementations for ExtractSubrange(). The copying behavior must be\n  // included only if the type supports the necessary operations (e.g.,\n  // MergeFrom()), so we must resolve this at compile time. ExtractSubrange()\n  // uses SFINAE to choose one of the below implementations.\n  void ExtractSubrangeInternal(int start, int num, Element** elements,\n                               google::protobuf::internal::true_type);\n  void ExtractSubrangeInternal(int start, int num, Element** elements,\n                               google::protobuf::internal::false_type);\n\n  friend class Arena;\n  typedef void InternalArenaConstructable_;\n\n};\n\n// implementation ====================================================\n\ntemplate <typename Element>\ninline RepeatedField<Element>::RepeatedField()\n  : current_size_(0),\n    total_size_(0),\n    rep_(NULL) {\n}\n\ntemplate <typename Element>\ninline RepeatedField<Element>::RepeatedField(Arena* arena)\n  : current_size_(0),\n    total_size_(0),\n    rep_(NULL) {\n // In case arena is NULL, then we do not create rep_, as code has an invariant\n // `rep_ == NULL then arena == NULL`.\n if (arena != NULL) {\n  rep_ = reinterpret_cast<Rep*>(\n      ::google::protobuf::Arena::CreateArray<char>(arena, kRepHeaderSize));\n  rep_->arena = arena;\n }\n}\n\ntemplate <typename Element>\ninline RepeatedField<Element>::RepeatedField(const RepeatedField& other)\n  : current_size_(0),\n    total_size_(0),\n    rep_(NULL) {\n  CopyFrom(other);\n}\n\ntemplate <typename Element>\ntemplate <typename Iter>\nRepeatedField<Element>::RepeatedField(Iter begin, const Iter& end)\n  : current_size_(0),\n    total_size_(0),\n    rep_(NULL) {\n  int reserve = internal::CalculateReserve(begin, end);\n  if (reserve != -1) {\n    Reserve(reserve);\n    for (; begin != end; ++begin) {\n      AddAlreadyReserved(*begin);\n    }\n  } else {\n    for (; begin != end; ++begin) {\n      Add(*begin);\n    }\n  }\n}\n\ntemplate <typename Element>\nRepeatedField<Element>::~RepeatedField() {\n  // See explanation in Reserve(): we need to invoke destructors here for the\n  // case that Element has a non-trivial destructor.\n  InternalDeallocate(rep_, total_size_);\n}\n\ntemplate <typename Element>\ninline RepeatedField<Element>&\nRepeatedField<Element>::operator=(const RepeatedField& other) {\n  if (this != &other)\n    CopyFrom(other);\n  return *this;\n}\n\ntemplate <typename Element>\ninline bool RepeatedField<Element>::empty() const {\n  return current_size_ == 0;\n}\n\ntemplate <typename Element>\ninline int RepeatedField<Element>::size() const {\n  return current_size_;\n}\n\ntemplate <typename Element>\ninline int RepeatedField<Element>::Capacity() const {\n  return total_size_;\n}\n\ntemplate<typename Element>\ninline void RepeatedField<Element>::AddAlreadyReserved(const Element& value) {\n  GOOGLE_DCHECK_LT(current_size_, total_size_);\n  rep_->elements[current_size_++] = value;\n}\n\ntemplate<typename Element>\ninline Element* RepeatedField<Element>::AddAlreadyReserved() {\n  GOOGLE_DCHECK_LT(current_size_, total_size_);\n  return &rep_->elements[current_size_++];\n}\n\ntemplate<typename Element>\ninline void RepeatedField<Element>::Resize(int new_size, const Element& value) {\n  GOOGLE_DCHECK_GE(new_size, 0);\n  if (new_size > current_size_) {\n    Reserve(new_size);\n    std::fill(&rep_->elements[current_size_],\n              &rep_->elements[new_size], value);\n  }\n  current_size_ = new_size;\n}\n\ntemplate <typename Element>\ninline const Element& RepeatedField<Element>::Get(int index) const {\n  GOOGLE_DCHECK_GE(index, 0);\n  GOOGLE_DCHECK_LT(index, current_size_);\n  return rep_->elements[index];\n}\n\ntemplate <typename Element>\ninline Element* RepeatedField<Element>::Mutable(int index) {\n  GOOGLE_DCHECK_GE(index, 0);\n  GOOGLE_DCHECK_LT(index, current_size_);\n  return &rep_->elements[index];\n}\n\ntemplate <typename Element>\ninline void RepeatedField<Element>::Set(int index, const Element& value) {\n  GOOGLE_DCHECK_GE(index, 0);\n  GOOGLE_DCHECK_LT(index, current_size_);\n  rep_->elements[index] = value;\n}\n\ntemplate <typename Element>\ninline void RepeatedField<Element>::Add(const Element& value) {\n  if (current_size_ == total_size_) Reserve(total_size_ + 1);\n  rep_->elements[current_size_++] = value;\n}\n\ntemplate <typename Element>\ninline Element* RepeatedField<Element>::Add() {\n  if (current_size_ == total_size_) Reserve(total_size_ + 1);\n  return &rep_->elements[current_size_++];\n}\n\ntemplate <typename Element>\ninline void RepeatedField<Element>::RemoveLast() {\n  GOOGLE_DCHECK_GT(current_size_, 0);\n  current_size_--;\n}\n\ntemplate <typename Element>\nvoid RepeatedField<Element>::ExtractSubrange(\n    int start, int num, Element* elements) {\n  GOOGLE_DCHECK_GE(start, 0);\n  GOOGLE_DCHECK_GE(num, 0);\n  GOOGLE_DCHECK_LE(start + num, this->current_size_);\n\n  // Save the values of the removed elements if requested.\n  if (elements != NULL) {\n    for (int i = 0; i < num; ++i)\n      elements[i] = this->Get(i + start);\n  }\n\n  // Slide remaining elements down to fill the gap.\n  if (num > 0) {\n    for (int i = start + num; i < this->current_size_; ++i)\n      this->Set(i - num, this->Get(i));\n    this->Truncate(this->current_size_ - num);\n  }\n}\n\ntemplate <typename Element>\ninline void RepeatedField<Element>::Clear() {\n  current_size_ = 0;\n}\n\ntemplate <typename Element>\ninline void RepeatedField<Element>::MergeFrom(const RepeatedField& other) {\n  GOOGLE_CHECK_NE(&other, this);\n  if (other.current_size_ != 0) {\n    Reserve(current_size_ + other.current_size_);\n    CopyArray(rep_->elements + current_size_,\n              other.rep_->elements, other.current_size_);\n    current_size_ += other.current_size_;\n  }\n}\n\ntemplate <typename Element>\ninline void RepeatedField<Element>::CopyFrom(const RepeatedField& other) {\n  if (&other == this) return;\n  Clear();\n  MergeFrom(other);\n}\n\ntemplate <typename Element>\ninline typename RepeatedField<Element>::iterator RepeatedField<Element>::erase(\n    const_iterator position) {\n  return erase(position, position + 1);\n}\n\ntemplate <typename Element>\ninline typename RepeatedField<Element>::iterator RepeatedField<Element>::erase(\n    const_iterator first, const_iterator last) {\n  size_type first_offset = first - cbegin();\n  if (first != last) {\n    Truncate(std::copy(last, cend(), begin() + first_offset) - cbegin());\n  }\n  return begin() + first_offset;\n}\n\ntemplate <typename Element>\ninline Element* RepeatedField<Element>::mutable_data() {\n  return rep_ ? rep_->elements : NULL;\n}\n\ntemplate <typename Element>\ninline const Element* RepeatedField<Element>::data() const {\n  return rep_ ? rep_->elements : NULL;\n}\n\n\ntemplate <typename Element>\ninline void RepeatedField<Element>::InternalSwap(RepeatedField* other) {\n  std::swap(rep_, other->rep_);\n  std::swap(current_size_, other->current_size_);\n  std::swap(total_size_, other->total_size_);\n}\n\ntemplate <typename Element>\nvoid RepeatedField<Element>::Swap(RepeatedField* other) {\n  if (this == other) return;\n  if (GetArenaNoVirtual() ==  other->GetArenaNoVirtual()) {\n    InternalSwap(other);\n  } else {\n    RepeatedField<Element> temp(other->GetArenaNoVirtual());\n    temp.MergeFrom(*this);\n    CopyFrom(*other);\n    other->UnsafeArenaSwap(&temp);\n  }\n}\n\ntemplate <typename Element>\nvoid RepeatedField<Element>::UnsafeArenaSwap(RepeatedField* other) {\n  if (this == other) return;\n  GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());\n  InternalSwap(other);\n}\n\ntemplate <typename Element>\nvoid RepeatedField<Element>::SwapElements(int index1, int index2) {\n  using std::swap;  // enable ADL with fallback\n  swap(rep_->elements[index1], rep_->elements[index2]);\n}\n\ntemplate <typename Element>\ninline typename RepeatedField<Element>::iterator\nRepeatedField<Element>::begin() {\n  return rep_ ? rep_->elements : NULL;\n}\ntemplate <typename Element>\ninline typename RepeatedField<Element>::const_iterator\nRepeatedField<Element>::begin() const {\n  return rep_ ? rep_->elements : NULL;\n}\ntemplate <typename Element>\ninline typename RepeatedField<Element>::const_iterator\nRepeatedField<Element>::cbegin() const {\n  return rep_ ? rep_->elements : NULL;\n}\ntemplate <typename Element>\ninline typename RepeatedField<Element>::iterator\nRepeatedField<Element>::end() {\n  return rep_ ? rep_->elements + current_size_ : NULL;\n}\ntemplate <typename Element>\ninline typename RepeatedField<Element>::const_iterator\nRepeatedField<Element>::end() const {\n  return rep_ ? rep_->elements + current_size_ : NULL;\n}\ntemplate <typename Element>\ninline typename RepeatedField<Element>::const_iterator\nRepeatedField<Element>::cend() const {\n  return rep_ ? rep_->elements + current_size_ : NULL;\n}\n\ntemplate <typename Element>\ninline int RepeatedField<Element>::SpaceUsedExcludingSelf() const {\n  return rep_ ?\n      (total_size_ * sizeof(Element) + kRepHeaderSize) : 0;\n}\n\n// Avoid inlining of Reserve(): new, copy, and delete[] lead to a significant\n// amount of code bloat.\ntemplate <typename Element>\nvoid RepeatedField<Element>::Reserve(int new_size) {\n  if (total_size_ >= new_size) return;\n  Rep* old_rep = rep_;\n  Arena* arena = GetArenaNoVirtual();\n  new_size = std::max(google::protobuf::internal::kMinRepeatedFieldAllocationSize,\n                      std::max(total_size_ * 2, new_size));\n  GOOGLE_CHECK_LE(static_cast<size_t>(new_size),\n           (std::numeric_limits<size_t>::max() - kRepHeaderSize) /\n           sizeof(Element))\n      << \"Requested size is too large to fit into size_t.\";\n  if (arena == NULL) {\n    rep_ = reinterpret_cast<Rep*>(\n        new char[kRepHeaderSize + sizeof(Element) * new_size]);\n  } else {\n    rep_ = reinterpret_cast<Rep*>(\n            ::google::protobuf::Arena::CreateArray<char>(arena,\n                kRepHeaderSize + sizeof(Element) * new_size));\n  }\n  rep_->arena = arena;\n  int old_total_size = total_size_;\n  total_size_ = new_size;\n  // Invoke placement-new on newly allocated elements. We shouldn't have to do\n  // this, since Element is supposed to be POD, but a previous version of this\n  // code allocated storage with \"new Element[size]\" and some code uses\n  // RepeatedField with non-POD types, relying on constructor invocation. If\n  // Element has a trivial constructor (e.g., int32), gcc (tested with -O2)\n  // completely removes this loop because the loop body is empty, so this has no\n  // effect unless its side-effects are required for correctness.\n  // Note that we do this before MoveArray() below because Element's copy\n  // assignment implementation will want an initialized instance first.\n  Element* e = &rep_->elements[0];\n  Element* limit = &rep_->elements[total_size_];\n  for (; e < limit; e++) {\n    new (e) Element();\n  }\n  if (current_size_ > 0) {\n    MoveArray(rep_->elements, old_rep->elements, current_size_);\n  }\n\n  // Likewise, we need to invoke destructors on the old array.\n  InternalDeallocate(old_rep, old_total_size);\n\n}\n\ntemplate <typename Element>\ninline void RepeatedField<Element>::Truncate(int new_size) {\n  GOOGLE_DCHECK_LE(new_size, current_size_);\n  if (current_size_ > 0) {\n    current_size_ = new_size;\n  }\n}\n\ntemplate <typename Element>\ninline void RepeatedField<Element>::MoveArray(\n  Element* to, Element* from, int array_size) {\n  CopyArray(to, from, array_size);\n}\n\ntemplate <typename Element>\ninline void RepeatedField<Element>::CopyArray(\n  Element* to, const Element* from, int array_size) {\n  internal::ElementCopier<Element>()(to, from, array_size);\n}\n\nnamespace internal {\n\ntemplate <typename Element, bool HasTrivialCopy>\nvoid ElementCopier<Element, HasTrivialCopy>::operator()(\n  Element* to, const Element* from, int array_size) {\n  std::copy(from, from + array_size, to);\n}\n\ntemplate <typename Element>\nstruct ElementCopier<Element, true> {\n  void operator()(Element* to, const Element* from, int array_size) {\n    memcpy(to, from, array_size * sizeof(Element));\n  }\n};\n\n}  // namespace internal\n\n\n// -------------------------------------------------------------------\n\nnamespace internal {\n\ninline RepeatedPtrFieldBase::RepeatedPtrFieldBase()\n  : arena_(NULL),\n    current_size_(0),\n    total_size_(0),\n    rep_(NULL) {\n}\n\ninline RepeatedPtrFieldBase::RepeatedPtrFieldBase(::google::protobuf::Arena* arena)\n  : arena_(arena),\n    current_size_(0),\n    total_size_(0),\n    rep_(NULL) {\n}\n\ntemplate <typename TypeHandler>\nvoid RepeatedPtrFieldBase::Destroy() {\n  if (rep_ != NULL && arena_ == NULL) {\n    int n = rep_->allocated_size;\n    void* const* elements = rep_->elements;\n    for (int i = 0; i < n; i++) {\n      TypeHandler::Delete(cast<TypeHandler>(elements[i]), NULL);\n    }\n    delete[] reinterpret_cast<char*>(rep_);\n  }\n  rep_ = NULL;\n}\n\ntemplate <typename TypeHandler>\ninline void RepeatedPtrFieldBase::Swap(RepeatedPtrFieldBase* other) {\n  if (other->GetArenaNoVirtual() == GetArenaNoVirtual()) {\n    InternalSwap(other);\n  } else {\n    SwapFallback<TypeHandler>(other);\n  }\n}\n\ntemplate <typename TypeHandler>\nvoid RepeatedPtrFieldBase::SwapFallback(RepeatedPtrFieldBase* other) {\n  GOOGLE_DCHECK(other->GetArenaNoVirtual() != GetArenaNoVirtual());\n\n  // Copy semantics in this case. We try to improve efficiency by placing the\n  // temporary on |other|'s arena so that messages are copied cross-arena only\n  // once, not twice.\n  RepeatedPtrFieldBase temp(other->GetArenaNoVirtual());\n  temp.MergeFrom<TypeHandler>(*this);\n  this->Clear<TypeHandler>();\n  this->MergeFrom<TypeHandler>(*other);\n  other->Clear<TypeHandler>();\n  other->InternalSwap(&temp);\n  temp.Destroy<TypeHandler>();  // Frees rep_ if `other` had no arena.\n}\n\ninline bool RepeatedPtrFieldBase::empty() const {\n  return current_size_ == 0;\n}\n\ninline int RepeatedPtrFieldBase::size() const {\n  return current_size_;\n}\n\ntemplate <typename TypeHandler>\ninline const typename TypeHandler::Type&\nRepeatedPtrFieldBase::Get(int index) const {\n  GOOGLE_DCHECK_GE(index, 0);\n  GOOGLE_DCHECK_LT(index, current_size_);\n  return *cast<TypeHandler>(rep_->elements[index]);\n}\n\n\ntemplate <typename TypeHandler>\ninline typename TypeHandler::Type*\nRepeatedPtrFieldBase::Mutable(int index) {\n  GOOGLE_DCHECK_GE(index, 0);\n  GOOGLE_DCHECK_LT(index, current_size_);\n  return cast<TypeHandler>(rep_->elements[index]);\n}\n\ntemplate <typename TypeHandler>\ninline void RepeatedPtrFieldBase::Delete(int index) {\n  GOOGLE_DCHECK_GE(index, 0);\n  GOOGLE_DCHECK_LT(index, current_size_);\n  TypeHandler::Delete(cast<TypeHandler>(rep_->elements[index]), arena_);\n}\n\ntemplate <typename TypeHandler>\ninline typename TypeHandler::Type* RepeatedPtrFieldBase::Add(\n    typename TypeHandler::Type* prototype) {\n  if (rep_ != NULL && current_size_ < rep_->allocated_size) {\n    return cast<TypeHandler>(rep_->elements[current_size_++]);\n  }\n  if (!rep_ || rep_->allocated_size == total_size_) {\n    Reserve(total_size_ + 1);\n  }\n  ++rep_->allocated_size;\n  typename TypeHandler::Type* result =\n      TypeHandler::NewFromPrototype(prototype, arena_);\n  rep_->elements[current_size_++] = result;\n  return result;\n}\n\ntemplate <typename TypeHandler>\ninline void RepeatedPtrFieldBase::RemoveLast() {\n  GOOGLE_DCHECK_GT(current_size_, 0);\n  TypeHandler::Clear(cast<TypeHandler>(rep_->elements[--current_size_]));\n}\n\ntemplate <typename TypeHandler>\nvoid RepeatedPtrFieldBase::Clear() {\n  const int n = current_size_;\n  GOOGLE_DCHECK_GE(n, 0);\n  if (n > 0) {\n    void* const* elements = rep_->elements;\n    int i = 0;\n    do {\n      TypeHandler::Clear(cast<TypeHandler>(elements[i++]));\n    } while (i < n);\n    current_size_ = 0;\n  }\n}\n\n// To avoid unnecessary code duplication and reduce binary size, we use a\n// layered approach to implementing MergeFrom(). The toplevel method is\n// templated, so we get a small thunk per concrete message type in the binary.\n// This calls a shared implementation with most of the logic, passing a function\n// pointer to another type-specific piece of code that calls the object-allocate\n// and merge handlers.\ntemplate <typename TypeHandler>\ninline void RepeatedPtrFieldBase::MergeFrom(const RepeatedPtrFieldBase& other) {\n  GOOGLE_DCHECK_NE(&other, this);\n  if (other.current_size_ == 0) return;\n  MergeFromInternal(\n      other, &RepeatedPtrFieldBase::MergeFromInnerLoop<TypeHandler>);\n}\n\ninline void RepeatedPtrFieldBase::MergeFromInternal(\n    const RepeatedPtrFieldBase& other,\n    void (RepeatedPtrFieldBase::*inner_loop)(void**, void**, int, int)) {\n  // Note: wrapper has already guaranteed that other.rep_ != NULL here.\n  int other_size = other.current_size_;\n  void** other_elements = other.rep_->elements;\n  void** new_elements = InternalExtend(other_size);\n  int allocated_elems = rep_->allocated_size - current_size_;\n  (this->*inner_loop)(new_elements, other_elements,\n                      other_size, allocated_elems);\n  current_size_ += other_size;\n  if (rep_->allocated_size < current_size_) {\n    rep_->allocated_size = current_size_;\n  }\n}\n\n// Merges other_elems to our_elems.\ntemplate<typename TypeHandler>\nvoid RepeatedPtrFieldBase::MergeFromInnerLoop(\n    void** our_elems, void** other_elems, int length, int already_allocated) {\n  // Split into two loops, over ranges [0, allocated) and [allocated, length),\n  // to avoid a branch within the loop.\n  for (int i = 0; i < already_allocated && i < length; i++) {\n    // Already allocated: use existing element.\n    typename TypeHandler::Type* other_elem =\n        reinterpret_cast<typename TypeHandler::Type*>(other_elems[i]);\n    typename TypeHandler::Type* new_elem =\n        reinterpret_cast<typename TypeHandler::Type*>(our_elems[i]);\n    TypeHandler::Merge(*other_elem, new_elem);\n  }\n  Arena* arena = GetArenaNoVirtual();\n  for (int i = already_allocated; i < length; i++) {\n    // Not allocated: alloc a new element first, then merge it.\n    typename TypeHandler::Type* other_elem =\n        reinterpret_cast<typename TypeHandler::Type*>(other_elems[i]);\n    typename TypeHandler::Type* new_elem =\n        TypeHandler::NewFromPrototype(other_elem, arena);\n    TypeHandler::Merge(*other_elem, new_elem);\n    our_elems[i] = new_elem;\n  }\n}\n\ntemplate <typename TypeHandler>\ninline void RepeatedPtrFieldBase::CopyFrom(const RepeatedPtrFieldBase& other) {\n  if (&other == this) return;\n  RepeatedPtrFieldBase::Clear<TypeHandler>();\n  RepeatedPtrFieldBase::MergeFrom<TypeHandler>(other);\n}\n\ninline int RepeatedPtrFieldBase::Capacity() const {\n  return total_size_;\n}\n\ninline void* const* RepeatedPtrFieldBase::raw_data() const {\n  return rep_ ? rep_->elements : NULL;\n}\n\ninline void** RepeatedPtrFieldBase::raw_mutable_data() const {\n  return rep_ ? const_cast<void**>(rep_->elements) : NULL;\n}\n\ntemplate <typename TypeHandler>\ninline typename TypeHandler::Type** RepeatedPtrFieldBase::mutable_data() {\n  // TODO(kenton):  Breaks C++ aliasing rules.  We should probably remove this\n  //   method entirely.\n  return reinterpret_cast<typename TypeHandler::Type**>(raw_mutable_data());\n}\n\ntemplate <typename TypeHandler>\ninline const typename TypeHandler::Type* const*\nRepeatedPtrFieldBase::data() const {\n  // TODO(kenton):  Breaks C++ aliasing rules.  We should probably remove this\n  //   method entirely.\n  return reinterpret_cast<const typename TypeHandler::Type* const*>(raw_data());\n}\n\ninline void RepeatedPtrFieldBase::SwapElements(int index1, int index2) {\n  using std::swap;  // enable ADL with fallback\n  swap(rep_->elements[index1], rep_->elements[index2]);\n}\n\ntemplate <typename TypeHandler>\ninline int RepeatedPtrFieldBase::SpaceUsedExcludingSelf() const {\n  int allocated_bytes = total_size_ * sizeof(void*);\n  if (rep_ != NULL) {\n    for (int i = 0; i < rep_->allocated_size; ++i) {\n      allocated_bytes += TypeHandler::SpaceUsed(\n          *cast<TypeHandler>(rep_->elements[i]));\n    }\n    allocated_bytes += kRepHeaderSize;\n  }\n  return allocated_bytes;\n}\n\ntemplate <typename TypeHandler>\ninline typename TypeHandler::Type* RepeatedPtrFieldBase::AddFromCleared() {\n  if (rep_ != NULL && current_size_ < rep_->allocated_size) {\n    return cast<TypeHandler>(rep_->elements[current_size_++]);\n  } else {\n    return NULL;\n  }\n}\n\n// AddAllocated version that implements arena-safe copying behavior.\ntemplate <typename TypeHandler>\nvoid RepeatedPtrFieldBase::AddAllocatedInternal(\n    typename TypeHandler::Type* value,\n    google::protobuf::internal::true_type) {\n  Arena* element_arena = reinterpret_cast<Arena*>(\n      TypeHandler::GetMaybeArenaPointer(value));\n  Arena* arena = GetArenaNoVirtual();\n  if (arena == element_arena && rep_ &&\n      rep_->allocated_size < total_size_) {\n    // Fast path: underlying arena representation (tagged pointer) is equal to\n    // our arena pointer, and we can add to array without resizing it (at least\n    // one slot that is not allocated).\n    void** elems = rep_->elements;\n    if (current_size_ < rep_->allocated_size) {\n      // Make space at [current] by moving first allocated element to end of\n      // allocated list.\n      elems[rep_->allocated_size] = elems[current_size_];\n    }\n    elems[current_size_] = value;\n    current_size_ = current_size_ + 1;\n    rep_->allocated_size = rep_->allocated_size + 1;\n    return;\n  } else {\n    AddAllocatedSlowWithCopy<TypeHandler>(\n        value, TypeHandler::GetArena(value), arena);\n  }\n}\n\n// Slowpath handles all cases, copying if necessary.\ntemplate<typename TypeHandler>\nvoid RepeatedPtrFieldBase::AddAllocatedSlowWithCopy(\n    // Pass value_arena and my_arena to avoid duplicate virtual call (value) or\n    // load (mine).\n    typename TypeHandler::Type* value, Arena* value_arena, Arena* my_arena) {\n  // Ensure that either the value is in the same arena, or if not, we do the\n  // appropriate thing: Own() it (if it's on heap and we're in an arena) or copy\n  // it to our arena/heap (otherwise).\n  if (my_arena != NULL && value_arena == NULL) {\n    my_arena->Own(value);\n  } else if (my_arena != value_arena) {\n    typename TypeHandler::Type* new_value =\n        TypeHandler::NewFromPrototype(value, my_arena);\n    TypeHandler::Merge(*value, new_value);\n    TypeHandler::Delete(value, value_arena);\n    value = new_value;\n  }\n\n  UnsafeArenaAddAllocated<TypeHandler>(value);\n}\n\n// AddAllocated version that does not implement arena-safe copying behavior.\ntemplate <typename TypeHandler>\nvoid RepeatedPtrFieldBase::AddAllocatedInternal(\n    typename TypeHandler::Type* value,\n    google::protobuf::internal::false_type) {\n  if (rep_ &&  rep_->allocated_size < total_size_) {\n    // Fast path: underlying arena representation (tagged pointer) is equal to\n    // our arena pointer, and we can add to array without resizing it (at least\n    // one slot that is not allocated).\n    void** elems = rep_->elements;\n    if (current_size_ < rep_->allocated_size) {\n      // Make space at [current] by moving first allocated element to end of\n      // allocated list.\n      elems[rep_->allocated_size] = elems[current_size_];\n    }\n    elems[current_size_] = value;\n    current_size_ = current_size_ + 1;\n    ++rep_->allocated_size;\n    return;\n  } else {\n    UnsafeArenaAddAllocated<TypeHandler>(value);\n  }\n}\n\ntemplate <typename TypeHandler>\nvoid RepeatedPtrFieldBase::UnsafeArenaAddAllocated(\n    typename TypeHandler::Type* value) {\n  // Make room for the new pointer.\n  if (!rep_ || current_size_ == total_size_) {\n    // The array is completely full with no cleared objects, so grow it.\n    Reserve(total_size_ + 1);\n    ++rep_->allocated_size;\n  } else if (rep_->allocated_size == total_size_) {\n    // There is no more space in the pointer array because it contains some\n    // cleared objects awaiting reuse.  We don't want to grow the array in this\n    // case because otherwise a loop calling AddAllocated() followed by Clear()\n    // would leak memory.\n    TypeHandler::Delete(\n        cast<TypeHandler>(rep_->elements[current_size_]), arena_);\n  } else if (current_size_ < rep_->allocated_size) {\n    // We have some cleared objects.  We don't care about their order, so we\n    // can just move the first one to the end to make space.\n    rep_->elements[rep_->allocated_size] = rep_->elements[current_size_];\n    ++rep_->allocated_size;\n  } else {\n    // There are no cleared objects.\n    ++rep_->allocated_size;\n  }\n\n  rep_->elements[current_size_++] = value;\n}\n\n// ReleaseLast() for types that implement merge/copy behavior.\ntemplate <typename TypeHandler>\ninline typename TypeHandler::Type*\nRepeatedPtrFieldBase::ReleaseLastInternal(google::protobuf::internal::true_type) {\n  // First, release an element.\n  typename TypeHandler::Type* result = UnsafeArenaReleaseLast<TypeHandler>();\n  // Now perform a copy if we're on an arena.\n  Arena* arena = GetArenaNoVirtual();\n  if (arena == NULL) {\n    return result;\n  } else {\n    typename TypeHandler::Type* new_result =\n        TypeHandler::NewFromPrototype(result, NULL);\n    TypeHandler::Merge(*result, new_result);\n    return new_result;\n  }\n}\n\n// ReleaseLast() for types that *do not* implement merge/copy behavior -- this\n// is the same as UnsafeArenaReleaseLast(). Note that we GOOGLE_DCHECK-fail if we're on\n// an arena, since the user really should implement the copy operation in this\n// case.\ntemplate <typename TypeHandler>\ninline typename TypeHandler::Type*\nRepeatedPtrFieldBase::ReleaseLastInternal(google::protobuf::internal::false_type) {\n  GOOGLE_DCHECK(GetArenaNoVirtual() == NULL)\n      << \"ReleaseLast() called on a RepeatedPtrField that is on an arena, \"\n      << \"with a type that does not implement MergeFrom. This is unsafe; \"\n      << \"please implement MergeFrom for your type.\";\n  return UnsafeArenaReleaseLast<TypeHandler>();\n}\n\ntemplate <typename TypeHandler>\ninline typename TypeHandler::Type*\n  RepeatedPtrFieldBase::UnsafeArenaReleaseLast() {\n  GOOGLE_DCHECK_GT(current_size_, 0);\n  typename TypeHandler::Type* result =\n      cast<TypeHandler>(rep_->elements[--current_size_]);\n  --rep_->allocated_size;\n  if (current_size_ < rep_->allocated_size) {\n    // There are cleared elements on the end; replace the removed element\n    // with the last allocated element.\n    rep_->elements[current_size_] = rep_->elements[rep_->allocated_size];\n  }\n  return result;\n}\n\ninline int RepeatedPtrFieldBase::ClearedCount() const {\n  return rep_ ? (rep_->allocated_size - current_size_) : 0;\n}\n\ntemplate <typename TypeHandler>\ninline void RepeatedPtrFieldBase::AddCleared(\n    typename TypeHandler::Type* value) {\n  GOOGLE_DCHECK(GetArenaNoVirtual() == NULL)\n      << \"AddCleared() can only be used on a RepeatedPtrField not on an arena.\";\n  GOOGLE_DCHECK(TypeHandler::GetArena(value) == NULL)\n      << \"AddCleared() can only accept values not on an arena.\";\n  if (!rep_ || rep_->allocated_size == total_size_) {\n    Reserve(total_size_ + 1);\n  }\n  rep_->elements[rep_->allocated_size++] = value;\n}\n\ntemplate <typename TypeHandler>\ninline typename TypeHandler::Type* RepeatedPtrFieldBase::ReleaseCleared() {\n  GOOGLE_DCHECK(GetArenaNoVirtual() == NULL)\n      << \"ReleaseCleared() can only be used on a RepeatedPtrField not on \"\n      << \"an arena.\";\n  GOOGLE_DCHECK(GetArenaNoVirtual() == NULL);\n  GOOGLE_DCHECK(rep_ != NULL);\n  GOOGLE_DCHECK_GT(rep_->allocated_size, current_size_);\n  return cast<TypeHandler>(rep_->elements[--rep_->allocated_size]);\n}\n\n}  // namespace internal\n\n// -------------------------------------------------------------------\n\ntemplate <typename Element>\nclass RepeatedPtrField<Element>::TypeHandler\n    : public internal::GenericTypeHandler<Element> {\n};\n\ntemplate <>\nclass RepeatedPtrField<string>::TypeHandler\n    : public internal::StringTypeHandler {\n};\n\n\ntemplate <typename Element>\ninline RepeatedPtrField<Element>::RepeatedPtrField()\n  : RepeatedPtrFieldBase() {}\n\ntemplate <typename Element>\ninline RepeatedPtrField<Element>::RepeatedPtrField(::google::protobuf::Arena* arena) :\n  RepeatedPtrFieldBase(arena) {}\n\ntemplate <typename Element>\ninline RepeatedPtrField<Element>::RepeatedPtrField(\n    const RepeatedPtrField& other)\n  : RepeatedPtrFieldBase() {\n  CopyFrom(other);\n}\n\ntemplate <typename Element>\ntemplate <typename Iter>\ninline RepeatedPtrField<Element>::RepeatedPtrField(\n    Iter begin, const Iter& end) {\n  int reserve = internal::CalculateReserve(begin, end);\n  if (reserve != -1) {\n    Reserve(reserve);\n  }\n  for (; begin != end; ++begin) {\n    *Add() = *begin;\n  }\n}\n\ntemplate <typename Element>\nRepeatedPtrField<Element>::~RepeatedPtrField() {\n  Destroy<TypeHandler>();\n}\n\ntemplate <typename Element>\ninline RepeatedPtrField<Element>& RepeatedPtrField<Element>::operator=(\n    const RepeatedPtrField& other) {\n  if (this != &other)\n    CopyFrom(other);\n  return *this;\n}\n\ntemplate <typename Element>\ninline bool RepeatedPtrField<Element>::empty() const {\n  return RepeatedPtrFieldBase::empty();\n}\n\ntemplate <typename Element>\ninline int RepeatedPtrField<Element>::size() const {\n  return RepeatedPtrFieldBase::size();\n}\n\ntemplate <typename Element>\ninline const Element& RepeatedPtrField<Element>::Get(int index) const {\n  return RepeatedPtrFieldBase::Get<TypeHandler>(index);\n}\n\n\ntemplate <typename Element>\ninline Element* RepeatedPtrField<Element>::Mutable(int index) {\n  return RepeatedPtrFieldBase::Mutable<TypeHandler>(index);\n}\n\ntemplate <typename Element>\ninline Element* RepeatedPtrField<Element>::Add() {\n  return RepeatedPtrFieldBase::Add<TypeHandler>();\n}\n\ntemplate <typename Element>\ninline void RepeatedPtrField<Element>::RemoveLast() {\n  RepeatedPtrFieldBase::RemoveLast<TypeHandler>();\n}\n\ntemplate <typename Element>\ninline void RepeatedPtrField<Element>::DeleteSubrange(int start, int num) {\n  GOOGLE_DCHECK_GE(start, 0);\n  GOOGLE_DCHECK_GE(num, 0);\n  GOOGLE_DCHECK_LE(start + num, size());\n  for (int i = 0; i < num; ++i) {\n    RepeatedPtrFieldBase::Delete<TypeHandler>(start + i);\n  }\n  ExtractSubrange(start, num, NULL);\n}\n\ntemplate <typename Element>\ninline void RepeatedPtrField<Element>::ExtractSubrange(\n    int start, int num, Element** elements) {\n  typename internal::TypeImplementsMergeBehavior<\n      typename TypeHandler::Type>::type t;\n  ExtractSubrangeInternal(start, num, elements, t);\n}\n\n// ExtractSubrange() implementation for types that implement merge/copy\n// behavior.\ntemplate <typename Element>\ninline void RepeatedPtrField<Element>::ExtractSubrangeInternal(\n    int start, int num, Element** elements, google::protobuf::internal::true_type) {\n  GOOGLE_DCHECK_GE(start, 0);\n  GOOGLE_DCHECK_GE(num, 0);\n  GOOGLE_DCHECK_LE(start + num, size());\n\n  if (num > 0) {\n    // Save the values of the removed elements if requested.\n    if (elements != NULL) {\n      if (GetArenaNoVirtual() != NULL) {\n        // If we're on an arena, we perform a copy for each element so that the\n        // returned elements are heap-allocated.\n        for (int i = 0; i < num; ++i) {\n          Element* element = RepeatedPtrFieldBase::\n              Mutable<TypeHandler>(i + start);\n          typename TypeHandler::Type* new_value =\n              TypeHandler::NewFromPrototype(element, NULL);\n          TypeHandler::Merge(*element, new_value);\n          elements[i] = new_value;\n        }\n      } else {\n        for (int i = 0; i < num; ++i) {\n          elements[i] = RepeatedPtrFieldBase::Mutable<TypeHandler>(i + start);\n        }\n      }\n    }\n    CloseGap(start, num);\n  }\n}\n\n// ExtractSubrange() implementation for types that do not implement merge/copy\n// behavior.\ntemplate<typename Element>\ninline void RepeatedPtrField<Element>::ExtractSubrangeInternal(\n    int start, int num, Element** elements, google::protobuf::internal::false_type) {\n  // This case is identical to UnsafeArenaExtractSubrange(). However, since\n  // ExtractSubrange() must return heap-allocated objects by contract, and we\n  // cannot fulfill this contract if we are an on arena, we must GOOGLE_DCHECK() that\n  // we are not on an arena.\n  GOOGLE_DCHECK(GetArenaNoVirtual() == NULL)\n      << \"ExtractSubrange() when arena is non-NULL is only supported when \"\n      << \"the Element type supplies a MergeFrom() operation to make copies.\";\n  UnsafeArenaExtractSubrange(start, num, elements);\n}\n\ntemplate <typename Element>\ninline void RepeatedPtrField<Element>::UnsafeArenaExtractSubrange(\n    int start, int num, Element** elements) {\n  GOOGLE_DCHECK_GE(start, 0);\n  GOOGLE_DCHECK_GE(num, 0);\n  GOOGLE_DCHECK_LE(start + num, size());\n\n  if (num > 0) {\n    // Save the values of the removed elements if requested.\n    if (elements != NULL) {\n      for (int i = 0; i < num; ++i) {\n        elements[i] = RepeatedPtrFieldBase::Mutable<TypeHandler>(i + start);\n      }\n    }\n    CloseGap(start, num);\n  }\n}\n\ntemplate <typename Element>\ninline void RepeatedPtrField<Element>::Clear() {\n  RepeatedPtrFieldBase::Clear<TypeHandler>();\n}\n\ntemplate <typename Element>\ninline void RepeatedPtrField<Element>::MergeFrom(\n    const RepeatedPtrField& other) {\n  RepeatedPtrFieldBase::MergeFrom<TypeHandler>(other);\n}\n\ntemplate <typename Element>\ninline void RepeatedPtrField<Element>::CopyFrom(\n    const RepeatedPtrField& other) {\n  RepeatedPtrFieldBase::CopyFrom<TypeHandler>(other);\n}\n\ntemplate <typename Element>\ninline typename RepeatedPtrField<Element>::iterator\nRepeatedPtrField<Element>::erase(const_iterator position) {\n  return erase(position, position + 1);\n}\n\ntemplate <typename Element>\ninline typename RepeatedPtrField<Element>::iterator\nRepeatedPtrField<Element>::erase(const_iterator first, const_iterator last) {\n  size_type pos_offset = std::distance(cbegin(), first);\n  size_type last_offset = std::distance(cbegin(), last);\n  DeleteSubrange(pos_offset, last_offset - pos_offset);\n  return begin() + pos_offset;\n}\n\ntemplate <typename Element>\ninline Element** RepeatedPtrField<Element>::mutable_data() {\n  return RepeatedPtrFieldBase::mutable_data<TypeHandler>();\n}\n\ntemplate <typename Element>\ninline const Element* const* RepeatedPtrField<Element>::data() const {\n  return RepeatedPtrFieldBase::data<TypeHandler>();\n}\n\ntemplate <typename Element>\ninline void RepeatedPtrField<Element>::Swap(RepeatedPtrField* other) {\n  if (this == other)\n    return;\n  RepeatedPtrFieldBase::Swap<TypeHandler>(other);\n}\n\ntemplate <typename Element>\ninline void RepeatedPtrField<Element>::UnsafeArenaSwap(\n    RepeatedPtrField* other) {\n  GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());\n  if (this == other)\n      return;\n  RepeatedPtrFieldBase::InternalSwap(other);\n}\n\ntemplate <typename Element>\ninline void RepeatedPtrField<Element>::SwapElements(int index1, int index2) {\n  RepeatedPtrFieldBase::SwapElements(index1, index2);\n}\n\ntemplate <typename Element>\ninline Arena* RepeatedPtrField<Element>::GetArenaNoVirtual() const {\n  return RepeatedPtrFieldBase::GetArenaNoVirtual();\n}\n\ntemplate <typename Element>\ninline int RepeatedPtrField<Element>::SpaceUsedExcludingSelf() const {\n  return RepeatedPtrFieldBase::SpaceUsedExcludingSelf<TypeHandler>();\n}\n\ntemplate <typename Element>\ninline void RepeatedPtrField<Element>::AddAllocated(Element* value) {\n  RepeatedPtrFieldBase::AddAllocated<TypeHandler>(value);\n}\n\ntemplate <typename Element>\ninline void RepeatedPtrField<Element>::UnsafeArenaAddAllocated(Element* value) {\n  RepeatedPtrFieldBase::UnsafeArenaAddAllocated<TypeHandler>(value);\n}\n\ntemplate <typename Element>\ninline Element* RepeatedPtrField<Element>::ReleaseLast() {\n  return RepeatedPtrFieldBase::ReleaseLast<TypeHandler>();\n}\n\ntemplate <typename Element>\ninline Element* RepeatedPtrField<Element>::UnsafeArenaReleaseLast() {\n  return RepeatedPtrFieldBase::UnsafeArenaReleaseLast<TypeHandler>();\n}\n\ntemplate <typename Element>\ninline int RepeatedPtrField<Element>::ClearedCount() const {\n  return RepeatedPtrFieldBase::ClearedCount();\n}\n\ntemplate <typename Element>\ninline void RepeatedPtrField<Element>::AddCleared(Element* value) {\n  return RepeatedPtrFieldBase::AddCleared<TypeHandler>(value);\n}\n\ntemplate <typename Element>\ninline Element* RepeatedPtrField<Element>::ReleaseCleared() {\n  return RepeatedPtrFieldBase::ReleaseCleared<TypeHandler>();\n}\n\ntemplate <typename Element>\ninline void RepeatedPtrField<Element>::Reserve(int new_size) {\n  return RepeatedPtrFieldBase::Reserve(new_size);\n}\n\ntemplate <typename Element>\ninline int RepeatedPtrField<Element>::Capacity() const {\n  return RepeatedPtrFieldBase::Capacity();\n}\n\n// -------------------------------------------------------------------\n\nnamespace internal {\n\n// STL-like iterator implementation for RepeatedPtrField.  You should not\n// refer to this class directly; use RepeatedPtrField<T>::iterator instead.\n//\n// The iterator for RepeatedPtrField<T>, RepeatedPtrIterator<T>, is\n// very similar to iterator_ptr<T**> in util/gtl/iterator_adaptors.h,\n// but adds random-access operators and is modified to wrap a void** base\n// iterator (since RepeatedPtrField stores its array as a void* array and\n// casting void** to T** would violate C++ aliasing rules).\n//\n// This code based on net/proto/proto-array-internal.h by Jeffrey Yasskin\n// (jyasskin@google.com).\ntemplate<typename Element>\nclass RepeatedPtrIterator\n    : public std::iterator<\n          std::random_access_iterator_tag, Element> {\n public:\n  typedef RepeatedPtrIterator<Element> iterator;\n  typedef std::iterator<\n          std::random_access_iterator_tag, Element> superclass;\n\n  // Shadow the value_type in std::iterator<> because const_iterator::value_type\n  // needs to be T, not const T.\n  typedef typename remove_const<Element>::type value_type;\n\n  // Let the compiler know that these are type names, so we don't have to\n  // write \"typename\" in front of them everywhere.\n  typedef typename superclass::reference reference;\n  typedef typename superclass::pointer pointer;\n  typedef typename superclass::difference_type difference_type;\n\n  RepeatedPtrIterator() : it_(NULL) {}\n  explicit RepeatedPtrIterator(void* const* it) : it_(it) {}\n\n  // Allow \"upcasting\" from RepeatedPtrIterator<T**> to\n  // RepeatedPtrIterator<const T*const*>.\n  template<typename OtherElement>\n  RepeatedPtrIterator(const RepeatedPtrIterator<OtherElement>& other)\n      : it_(other.it_) {\n    // Force a compiler error if the other type is not convertible to ours.\n    if (false) {\n      implicit_cast<Element*, OtherElement*>(0);\n    }\n  }\n\n  // dereferenceable\n  reference operator*() const { return *reinterpret_cast<Element*>(*it_); }\n  pointer   operator->() const { return &(operator*()); }\n\n  // {inc,dec}rementable\n  iterator& operator++() { ++it_; return *this; }\n  iterator  operator++(int) { return iterator(it_++); }\n  iterator& operator--() { --it_; return *this; }\n  iterator  operator--(int) { return iterator(it_--); }\n\n  // equality_comparable\n  bool operator==(const iterator& x) const { return it_ == x.it_; }\n  bool operator!=(const iterator& x) const { return it_ != x.it_; }\n\n  // less_than_comparable\n  bool operator<(const iterator& x) const { return it_ < x.it_; }\n  bool operator<=(const iterator& x) const { return it_ <= x.it_; }\n  bool operator>(const iterator& x) const { return it_ > x.it_; }\n  bool operator>=(const iterator& x) const { return it_ >= x.it_; }\n\n  // addable, subtractable\n  iterator& operator+=(difference_type d) {\n    it_ += d;\n    return *this;\n  }\n  friend iterator operator+(iterator it, const difference_type d) {\n    it += d;\n    return it;\n  }\n  friend iterator operator+(const difference_type d, iterator it) {\n    it += d;\n    return it;\n  }\n  iterator& operator-=(difference_type d) {\n    it_ -= d;\n    return *this;\n  }\n  friend iterator operator-(iterator it, difference_type d) {\n    it -= d;\n    return it;\n  }\n\n  // indexable\n  reference operator[](difference_type d) const { return *(*this + d); }\n\n  // random access iterator\n  difference_type operator-(const iterator& x) const { return it_ - x.it_; }\n\n private:\n  template<typename OtherElement>\n  friend class RepeatedPtrIterator;\n\n  // The internal iterator.\n  void* const* it_;\n};\n\n// Provide an iterator that operates on pointers to the underlying objects\n// rather than the objects themselves as RepeatedPtrIterator does.\n// Consider using this when working with stl algorithms that change\n// the array.\n// The VoidPtr template parameter holds the type-agnostic pointer value\n// referenced by the iterator.  It should either be \"void *\" for a mutable\n// iterator, or \"const void *\" for a constant iterator.\ntemplate<typename Element, typename VoidPtr>\nclass RepeatedPtrOverPtrsIterator\n    : public std::iterator<std::random_access_iterator_tag, Element*> {\n public:\n  typedef RepeatedPtrOverPtrsIterator<Element, VoidPtr> iterator;\n  typedef std::iterator<\n          std::random_access_iterator_tag, Element*> superclass;\n\n  // Shadow the value_type in std::iterator<> because const_iterator::value_type\n  // needs to be T, not const T.\n  typedef typename remove_const<Element*>::type value_type;\n\n  // Let the compiler know that these are type names, so we don't have to\n  // write \"typename\" in front of them everywhere.\n  typedef typename superclass::reference reference;\n  typedef typename superclass::pointer pointer;\n  typedef typename superclass::difference_type difference_type;\n\n  RepeatedPtrOverPtrsIterator() : it_(NULL) {}\n  explicit RepeatedPtrOverPtrsIterator(VoidPtr* it) : it_(it) {}\n\n  // dereferenceable\n  reference operator*() const { return *reinterpret_cast<Element**>(it_); }\n  pointer   operator->() const { return &(operator*()); }\n\n  // {inc,dec}rementable\n  iterator& operator++() { ++it_; return *this; }\n  iterator  operator++(int) { return iterator(it_++); }\n  iterator& operator--() { --it_; return *this; }\n  iterator  operator--(int) { return iterator(it_--); }\n\n  // equality_comparable\n  bool operator==(const iterator& x) const { return it_ == x.it_; }\n  bool operator!=(const iterator& x) const { return it_ != x.it_; }\n\n  // less_than_comparable\n  bool operator<(const iterator& x) const { return it_ < x.it_; }\n  bool operator<=(const iterator& x) const { return it_ <= x.it_; }\n  bool operator>(const iterator& x) const { return it_ > x.it_; }\n  bool operator>=(const iterator& x) const { return it_ >= x.it_; }\n\n  // addable, subtractable\n  iterator& operator+=(difference_type d) {\n    it_ += d;\n    return *this;\n  }\n  friend iterator operator+(iterator it, difference_type d) {\n    it += d;\n    return it;\n  }\n  friend iterator operator+(difference_type d, iterator it) {\n    it += d;\n    return it;\n  }\n  iterator& operator-=(difference_type d) {\n    it_ -= d;\n    return *this;\n  }\n  friend iterator operator-(iterator it, difference_type d) {\n    it -= d;\n    return it;\n  }\n\n  // indexable\n  reference operator[](difference_type d) const { return *(*this + d); }\n\n  // random access iterator\n  difference_type operator-(const iterator& x) const { return it_ - x.it_; }\n\n private:\n  template<typename OtherElement>\n  friend class RepeatedPtrIterator;\n\n  // The internal iterator.\n  VoidPtr* it_;\n};\n\nvoid RepeatedPtrFieldBase::InternalSwap(RepeatedPtrFieldBase* other) {\n  std::swap(rep_, other->rep_);\n  std::swap(current_size_, other->current_size_);\n  std::swap(total_size_, other->total_size_);\n}\n\n}  // namespace internal\n\ntemplate <typename Element>\ninline typename RepeatedPtrField<Element>::iterator\nRepeatedPtrField<Element>::begin() {\n  return iterator(raw_data());\n}\ntemplate <typename Element>\ninline typename RepeatedPtrField<Element>::const_iterator\nRepeatedPtrField<Element>::begin() const {\n  return iterator(raw_data());\n}\ntemplate <typename Element>\ninline typename RepeatedPtrField<Element>::const_iterator\nRepeatedPtrField<Element>::cbegin() const {\n  return begin();\n}\ntemplate <typename Element>\ninline typename RepeatedPtrField<Element>::iterator\nRepeatedPtrField<Element>::end() {\n  return iterator(raw_data() + size());\n}\ntemplate <typename Element>\ninline typename RepeatedPtrField<Element>::const_iterator\nRepeatedPtrField<Element>::end() const {\n  return iterator(raw_data() + size());\n}\ntemplate <typename Element>\ninline typename RepeatedPtrField<Element>::const_iterator\nRepeatedPtrField<Element>::cend() const {\n  return end();\n}\n\ntemplate <typename Element>\ninline typename RepeatedPtrField<Element>::pointer_iterator\nRepeatedPtrField<Element>::pointer_begin() {\n  return pointer_iterator(raw_mutable_data());\n}\ntemplate <typename Element>\ninline typename RepeatedPtrField<Element>::const_pointer_iterator\nRepeatedPtrField<Element>::pointer_begin() const {\n  return const_pointer_iterator(const_cast<const void**>(raw_mutable_data()));\n}\ntemplate <typename Element>\ninline typename RepeatedPtrField<Element>::pointer_iterator\nRepeatedPtrField<Element>::pointer_end() {\n  return pointer_iterator(raw_mutable_data() + size());\n}\ntemplate <typename Element>\ninline typename RepeatedPtrField<Element>::const_pointer_iterator\nRepeatedPtrField<Element>::pointer_end() const {\n  return const_pointer_iterator(\n      const_cast<const void**>(raw_mutable_data() + size()));\n}\n\n\n// Iterators and helper functions that follow the spirit of the STL\n// std::back_insert_iterator and std::back_inserter but are tailor-made\n// for RepeatedField and RepeatedPtrField. Typical usage would be:\n//\n//   std::copy(some_sequence.begin(), some_sequence.end(),\n//             google::protobuf::RepeatedFieldBackInserter(proto.mutable_sequence()));\n//\n// Ported by johannes from util/gtl/proto-array-iterators.h\n\nnamespace internal {\n// A back inserter for RepeatedField objects.\ntemplate<typename T> class RepeatedFieldBackInsertIterator\n    : public std::iterator<std::output_iterator_tag, T> {\n public:\n  explicit RepeatedFieldBackInsertIterator(\n      RepeatedField<T>* const mutable_field)\n      : field_(mutable_field) {\n  }\n  RepeatedFieldBackInsertIterator<T>& operator=(const T& value) {\n    field_->Add(value);\n    return *this;\n  }\n  RepeatedFieldBackInsertIterator<T>& operator*() {\n    return *this;\n  }\n  RepeatedFieldBackInsertIterator<T>& operator++() {\n    return *this;\n  }\n  RepeatedFieldBackInsertIterator<T>& operator++(int /* unused */) {\n    return *this;\n  }\n\n private:\n  RepeatedField<T>* field_;\n};\n\n// A back inserter for RepeatedPtrField objects.\ntemplate<typename T> class RepeatedPtrFieldBackInsertIterator\n    : public std::iterator<std::output_iterator_tag, T> {\n public:\n  RepeatedPtrFieldBackInsertIterator(\n      RepeatedPtrField<T>* const mutable_field)\n      : field_(mutable_field) {\n  }\n  RepeatedPtrFieldBackInsertIterator<T>& operator=(const T& value) {\n    *field_->Add() = value;\n    return *this;\n  }\n  RepeatedPtrFieldBackInsertIterator<T>& operator=(\n      const T* const ptr_to_value) {\n    *field_->Add() = *ptr_to_value;\n    return *this;\n  }\n  RepeatedPtrFieldBackInsertIterator<T>& operator*() {\n    return *this;\n  }\n  RepeatedPtrFieldBackInsertIterator<T>& operator++() {\n    return *this;\n  }\n  RepeatedPtrFieldBackInsertIterator<T>& operator++(int /* unused */) {\n    return *this;\n  }\n\n private:\n  RepeatedPtrField<T>* field_;\n};\n\n// A back inserter for RepeatedPtrFields that inserts by transferring ownership\n// of a pointer.\ntemplate<typename T> class AllocatedRepeatedPtrFieldBackInsertIterator\n    : public std::iterator<std::output_iterator_tag, T> {\n public:\n  explicit AllocatedRepeatedPtrFieldBackInsertIterator(\n      RepeatedPtrField<T>* const mutable_field)\n      : field_(mutable_field) {\n  }\n  AllocatedRepeatedPtrFieldBackInsertIterator<T>& operator=(\n      T* const ptr_to_value) {\n    field_->AddAllocated(ptr_to_value);\n    return *this;\n  }\n  AllocatedRepeatedPtrFieldBackInsertIterator<T>& operator*() {\n    return *this;\n  }\n  AllocatedRepeatedPtrFieldBackInsertIterator<T>& operator++() {\n    return *this;\n  }\n  AllocatedRepeatedPtrFieldBackInsertIterator<T>& operator++(\n      int /* unused */) {\n    return *this;\n  }\n\n private:\n  RepeatedPtrField<T>* field_;\n};\n\n// Almost identical to AllocatedRepeatedPtrFieldBackInsertIterator. This one\n// uses the UnsafeArenaAddAllocated instead.\ntemplate<typename T>\nclass UnsafeArenaAllocatedRepeatedPtrFieldBackInsertIterator\n    : public std::iterator<std::output_iterator_tag, T> {\n public:\n  explicit UnsafeArenaAllocatedRepeatedPtrFieldBackInsertIterator(\n    ::google::protobuf::RepeatedPtrField<T>* const mutable_field)\n  : field_(mutable_field) {\n  }\n  UnsafeArenaAllocatedRepeatedPtrFieldBackInsertIterator<T>& operator=(\n    T const* const ptr_to_value) {\n    field_->UnsafeArenaAddAllocated(const_cast<T*>(ptr_to_value));\n    return *this;\n  }\n  UnsafeArenaAllocatedRepeatedPtrFieldBackInsertIterator<T>& operator*() {\n    return *this;\n  }\n  UnsafeArenaAllocatedRepeatedPtrFieldBackInsertIterator<T>& operator++() {\n    return *this;\n  }\n  UnsafeArenaAllocatedRepeatedPtrFieldBackInsertIterator<T>& operator++(\n      int /* unused */) {\n    return *this;\n  }\n\n private:\n  ::google::protobuf::RepeatedPtrField<T>* field_;\n};\n\n}  // namespace internal\n\n// Provides a back insert iterator for RepeatedField instances,\n// similar to std::back_inserter().\ntemplate<typename T> internal::RepeatedFieldBackInsertIterator<T>\nRepeatedFieldBackInserter(RepeatedField<T>* const mutable_field) {\n  return internal::RepeatedFieldBackInsertIterator<T>(mutable_field);\n}\n\n// Provides a back insert iterator for RepeatedPtrField instances,\n// similar to std::back_inserter().\ntemplate<typename T> internal::RepeatedPtrFieldBackInsertIterator<T>\nRepeatedPtrFieldBackInserter(RepeatedPtrField<T>* const mutable_field) {\n  return internal::RepeatedPtrFieldBackInsertIterator<T>(mutable_field);\n}\n\n// Special back insert iterator for RepeatedPtrField instances, just in\n// case someone wants to write generic template code that can access both\n// RepeatedFields and RepeatedPtrFields using a common name.\ntemplate<typename T> internal::RepeatedPtrFieldBackInsertIterator<T>\nRepeatedFieldBackInserter(RepeatedPtrField<T>* const mutable_field) {\n  return internal::RepeatedPtrFieldBackInsertIterator<T>(mutable_field);\n}\n\n// Provides a back insert iterator for RepeatedPtrField instances\n// similar to std::back_inserter() which transfers the ownership while\n// copying elements.\ntemplate<typename T> internal::AllocatedRepeatedPtrFieldBackInsertIterator<T>\nAllocatedRepeatedPtrFieldBackInserter(\n    RepeatedPtrField<T>* const mutable_field) {\n  return internal::AllocatedRepeatedPtrFieldBackInsertIterator<T>(\n      mutable_field);\n}\n\n// Similar to AllocatedRepeatedPtrFieldBackInserter, using\n// UnsafeArenaAddAllocated instead of AddAllocated.\n// This is slightly faster if that matters. It is also useful in legacy code\n// that uses temporary ownership to avoid copies. Example:\n// RepeatedPtrField<T> temp_field;\n// temp_field.AddAllocated(new T);\n// ... // Do something with temp_field\n// temp_field.ExtractSubrange(0, temp_field.size(), NULL);\n// If you put temp_field on the arena this fails, because the ownership\n// transfers to the arena at the \"AddAllocated\" call and is not released anymore\n// causing a double delete. Using UnsafeArenaAddAllocated prevents this.\ntemplate<typename T>\ninternal::UnsafeArenaAllocatedRepeatedPtrFieldBackInsertIterator<T>\nUnsafeArenaAllocatedRepeatedPtrFieldBackInserter(\n    ::google::protobuf::RepeatedPtrField<T>* const mutable_field) {\n  return internal::UnsafeArenaAllocatedRepeatedPtrFieldBackInsertIterator<T>(\n      mutable_field);\n}\n\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_REPEATED_FIELD_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/repeated_field_reflection_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: tgs@google.com (Tom Szymanski)\n//\n// Test reflection methods for aggregate access to Repeated[Ptr]Fields.\n// This test proto2 methods on a proto2 layout.\n\n#include <google/protobuf/stubs/casts.h>\n#include <google/protobuf/stubs/stringprintf.h>\n#include <google/protobuf/dynamic_message.h>\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/test_util.h>\n#include <google/protobuf/reflection.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\n\nusing unittest::ForeignMessage;\nusing unittest::TestAllTypes;\nusing unittest::TestAllExtensions;\n\nnamespace {\n\nstatic int Func(int i, int j) {\n  return i * j;\n}\n\nstatic string StrFunc(int i, int j) {\n  string str;\n  SStringPrintf(&str, \"%d\", Func(i, 4));\n  return str;\n}\n\nTEST(RepeatedFieldReflectionTest, RegularFields) {\n  TestAllTypes message;\n  const Reflection* refl = message.GetReflection();\n  const Descriptor* desc = message.GetDescriptor();\n\n  for (int i = 0; i < 10; ++i) {\n    message.add_repeated_int32(Func(i, 1));\n    message.add_repeated_double(Func(i, 2));\n    message.add_repeated_string(StrFunc(i, 5));\n    message.add_repeated_foreign_message()->set_c(Func(i, 6));\n  }\n\n  // Get FieldDescriptors for all the fields of interest.\n  const FieldDescriptor* fd_repeated_int32 =\n      desc->FindFieldByName(\"repeated_int32\");\n  const FieldDescriptor* fd_repeated_double =\n      desc->FindFieldByName(\"repeated_double\");\n  const FieldDescriptor* fd_repeated_string =\n      desc->FindFieldByName(\"repeated_string\");\n  const FieldDescriptor* fd_repeated_foreign_message =\n      desc->FindFieldByName(\"repeated_foreign_message\");\n\n  // Get RepeatedField objects for all fields of interest.\n  const RepeatedField<int32>& rf_int32 =\n      refl->GetRepeatedField<int32>(message, fd_repeated_int32);\n  const RepeatedField<double>& rf_double =\n      refl->GetRepeatedField<double>(message, fd_repeated_double);\n\n  // Get mutable RepeatedField objects for all fields of interest.\n  RepeatedField<int32>* mrf_int32 =\n      refl->MutableRepeatedField<int32>(&message, fd_repeated_int32);\n  RepeatedField<double>* mrf_double =\n      refl->MutableRepeatedField<double>(&message, fd_repeated_double);\n\n  // Get RepeatedPtrField objects for all fields of interest.\n  const RepeatedPtrField<string>& rpf_string =\n      refl->GetRepeatedPtrField<string>(message, fd_repeated_string);\n  const RepeatedPtrField<ForeignMessage>& rpf_foreign_message =\n      refl->GetRepeatedPtrField<ForeignMessage>(\n          message, fd_repeated_foreign_message);\n  const RepeatedPtrField<Message>& rpf_message =\n      refl->GetRepeatedPtrField<Message>(\n          message, fd_repeated_foreign_message);\n\n  // Get mutable RepeatedPtrField objects for all fields of interest.\n  RepeatedPtrField<string>* mrpf_string =\n      refl->MutableRepeatedPtrField<string>(&message, fd_repeated_string);\n  RepeatedPtrField<ForeignMessage>* mrpf_foreign_message =\n      refl->MutableRepeatedPtrField<ForeignMessage>(\n          &message, fd_repeated_foreign_message);\n  RepeatedPtrField<Message>* mrpf_message =\n      refl->MutableRepeatedPtrField<Message>(\n          &message, fd_repeated_foreign_message);\n\n  // Make sure we can do gets and sets through the Repeated[Ptr]Field objects.\n  for (int i = 0; i < 10; ++i) {\n    // Check gets through const objects.\n    EXPECT_EQ(rf_int32.Get(i), Func(i, 1));\n    EXPECT_EQ(rf_double.Get(i), Func(i, 2));\n    EXPECT_EQ(rpf_string.Get(i), StrFunc(i, 5));\n    EXPECT_EQ(rpf_foreign_message.Get(i).c(), Func(i, 6));\n    EXPECT_EQ(down_cast<const ForeignMessage*>(&rpf_message.Get(i))->c(),\n              Func(i, 6));\n\n    // Check gets through mutable objects.\n    EXPECT_EQ(mrf_int32->Get(i), Func(i, 1));\n    EXPECT_EQ(mrf_double->Get(i), Func(i, 2));\n    EXPECT_EQ(mrpf_string->Get(i), StrFunc(i, 5));\n    EXPECT_EQ(mrpf_foreign_message->Get(i).c(), Func(i, 6));\n    EXPECT_EQ(down_cast<const ForeignMessage*>(&mrpf_message->Get(i))->c(),\n              Func(i, 6));\n\n    // Check sets through mutable objects.\n    mrf_int32->Set(i, Func(i, -1));\n    mrf_double->Set(i, Func(i, -2));\n    mrpf_string->Mutable(i)->assign(StrFunc(i, -5));\n    mrpf_foreign_message->Mutable(i)->set_c(Func(i, -6));\n    EXPECT_EQ(message.repeated_int32(i), Func(i, -1));\n    EXPECT_EQ(message.repeated_double(i), Func(i, -2));\n    EXPECT_EQ(message.repeated_string(i), StrFunc(i, -5));\n    EXPECT_EQ(message.repeated_foreign_message(i).c(), Func(i, -6));\n    down_cast<ForeignMessage*>(mrpf_message->Mutable(i))->set_c(Func(i, 7));\n    EXPECT_EQ(message.repeated_foreign_message(i).c(), Func(i, 7));\n  }\n\n#ifdef PROTOBUF_HAS_DEATH_TEST\n  // Make sure types are checked correctly at runtime.\n  const FieldDescriptor* fd_optional_int32 =\n      desc->FindFieldByName(\"optional_int32\");\n  EXPECT_DEATH(refl->GetRepeatedField<int32>(\n      message, fd_optional_int32), \"requires a repeated field\");\n  EXPECT_DEATH(refl->GetRepeatedField<double>(\n      message, fd_repeated_int32), \"not the right type\");\n  EXPECT_DEATH(refl->GetRepeatedPtrField<TestAllTypes>(\n      message, fd_repeated_foreign_message), \"wrong submessage type\");\n#endif  // PROTOBUF_HAS_DEATH_TEST\n}\n\n\nTEST(RepeatedFieldReflectionTest, ExtensionFields) {\n  TestAllExtensions extended_message;\n  const Reflection* refl = extended_message.GetReflection();\n  const Descriptor* desc = extended_message.GetDescriptor();\n\n  for (int i = 0; i < 10; ++i) {\n    extended_message.AddExtension(\n        unittest::repeated_int64_extension, Func(i, 1));\n  }\n\n  const FieldDescriptor* fd_repeated_int64_extension =\n      desc->file()->FindExtensionByName(\"repeated_int64_extension\");\n  GOOGLE_CHECK(fd_repeated_int64_extension != NULL);\n\n  const RepeatedField<int64>& rf_int64_extension =\n      refl->GetRepeatedField<int64>(extended_message,\n                                    fd_repeated_int64_extension);\n\n  RepeatedField<int64>* mrf_int64_extension =\n      refl->MutableRepeatedField<int64>(&extended_message,\n                                        fd_repeated_int64_extension);\n\n  for (int i = 0; i < 10; ++i) {\n    EXPECT_EQ(Func(i, 1), rf_int64_extension.Get(i));\n    mrf_int64_extension->Set(i, Func(i, -1));\n    EXPECT_EQ(Func(i, -1),\n        extended_message.GetExtension(unittest::repeated_int64_extension, i));\n  }\n}\n\ntemplate<typename Ref, typename MessageType, typename ValueType>\nvoid TestRepeatedFieldRefIterator(\n    const Ref& handle, const MessageType& message,\n    ValueType (MessageType::*GetFunc)(int) const) {\n  int index = 0;\n  for (typename Ref::const_iterator it = handle.begin();\n       it != handle.end(); ++it) {\n    EXPECT_EQ((message.*GetFunc)(index), *it);\n    ++index;\n  }\n  EXPECT_EQ(handle.size(), index);\n}\n\nTEST(RepeatedFieldReflectionTest, RepeatedFieldRefForRegularFields) {\n  TestAllTypes message;\n  const Reflection* refl = message.GetReflection();\n  const Descriptor* desc = message.GetDescriptor();\n\n  for (int i = 0; i < 10; ++i) {\n    message.add_repeated_int32(Func(i, 1));\n    message.add_repeated_double(Func(i, 2));\n    message.add_repeated_string(StrFunc(i, 5));\n    message.add_repeated_foreign_message()->set_c(Func(i, 6));\n  }\n\n  // Get FieldDescriptors for all the fields of interest.\n  const FieldDescriptor* fd_repeated_int32 =\n      desc->FindFieldByName(\"repeated_int32\");\n  const FieldDescriptor* fd_repeated_double =\n      desc->FindFieldByName(\"repeated_double\");\n  const FieldDescriptor* fd_repeated_string =\n      desc->FindFieldByName(\"repeated_string\");\n  const FieldDescriptor* fd_repeated_foreign_message =\n      desc->FindFieldByName(\"repeated_foreign_message\");\n\n  // Get RepeatedFieldRef objects for all fields of interest.\n  const RepeatedFieldRef<int32> rf_int32 =\n      refl->GetRepeatedFieldRef<int32>(message, fd_repeated_int32);\n  const RepeatedFieldRef<double> rf_double =\n      refl->GetRepeatedFieldRef<double>(message, fd_repeated_double);\n  const RepeatedFieldRef<string> rf_string =\n      refl->GetRepeatedFieldRef<string>(message, fd_repeated_string);\n  const RepeatedFieldRef<ForeignMessage> rf_foreign_message =\n      refl->GetRepeatedFieldRef<ForeignMessage>(\n          message, fd_repeated_foreign_message);\n  const RepeatedFieldRef<Message> rf_message =\n      refl->GetRepeatedFieldRef<Message>(\n          message, fd_repeated_foreign_message);\n\n  // Get MutableRepeatedFieldRef objects for all fields of interest.\n  const MutableRepeatedFieldRef<int32> mrf_int32 =\n      refl->GetMutableRepeatedFieldRef<int32>(&message, fd_repeated_int32);\n  const MutableRepeatedFieldRef<double> mrf_double =\n      refl->GetMutableRepeatedFieldRef<double>(&message, fd_repeated_double);\n  const MutableRepeatedFieldRef<string> mrf_string =\n      refl->GetMutableRepeatedFieldRef<string>(&message, fd_repeated_string);\n  const MutableRepeatedFieldRef<ForeignMessage> mrf_foreign_message =\n      refl->GetMutableRepeatedFieldRef<ForeignMessage>(\n          &message, fd_repeated_foreign_message);\n  const MutableRepeatedFieldRef<Message> mrf_message =\n      refl->GetMutableRepeatedFieldRef<Message>(\n          &message, fd_repeated_foreign_message);\n\n  EXPECT_EQ(message.repeated_int32_size(), rf_int32.size());\n  EXPECT_EQ(message.repeated_int32_size(), mrf_int32.size());\n  EXPECT_EQ(message.repeated_double_size(), rf_double.size());\n  EXPECT_EQ(message.repeated_double_size(), mrf_double.size());\n  EXPECT_EQ(message.repeated_string_size(), rf_string.size());\n  EXPECT_EQ(message.repeated_string_size(), mrf_string.size());\n  EXPECT_EQ(message.repeated_foreign_message_size(),\n            rf_foreign_message.size());\n  EXPECT_EQ(message.repeated_foreign_message_size(),\n            mrf_foreign_message.size());\n  EXPECT_EQ(message.repeated_foreign_message_size(), rf_message.size());\n  EXPECT_EQ(message.repeated_foreign_message_size(), mrf_message.size());\n\n  EXPECT_FALSE(rf_int32.empty());\n  EXPECT_FALSE(mrf_int32.empty());\n  EXPECT_FALSE(rf_double.empty());\n  EXPECT_FALSE(mrf_double.empty());\n  EXPECT_FALSE(rf_string.empty());\n  EXPECT_FALSE(mrf_string.empty());\n  EXPECT_FALSE(rf_foreign_message.empty());\n  EXPECT_FALSE(mrf_foreign_message.empty());\n  EXPECT_FALSE(rf_message.empty());\n  EXPECT_FALSE(mrf_message.empty());\n\n  // Make sure we can do gets and sets through the RepeatedFieldRef objects.\n  for (int i = 0; i < 10; ++i) {\n    // Check gets through const objects.\n    EXPECT_EQ(rf_int32.Get(i), Func(i, 1));\n    EXPECT_EQ(rf_double.Get(i), Func(i, 2));\n    EXPECT_EQ(rf_string.Get(i), StrFunc(i, 5));\n    ForeignMessage scratch_space;\n    EXPECT_EQ(rf_foreign_message.Get(i, &scratch_space).c(), Func(i, 6));\n    EXPECT_EQ(down_cast<const ForeignMessage&>(\n        rf_message.Get(i, &scratch_space)).c(), Func(i, 6));\n\n    // Check gets through mutable objects.\n    EXPECT_EQ(mrf_int32.Get(i), Func(i, 1));\n    EXPECT_EQ(mrf_double.Get(i), Func(i, 2));\n    EXPECT_EQ(mrf_string.Get(i), StrFunc(i, 5));\n    EXPECT_EQ(mrf_foreign_message.Get(i, &scratch_space).c(), Func(i, 6));\n    EXPECT_EQ(down_cast<const ForeignMessage&>(\n        mrf_message.Get(i, &scratch_space)).c(), Func(i, 6));\n\n    // Check sets through mutable objects.\n    mrf_int32.Set(i, Func(i, -1));\n    mrf_double.Set(i, Func(i, -2));\n    mrf_string.Set(i, StrFunc(i, -5));\n    ForeignMessage foreign_message;\n    foreign_message.set_c(Func(i, -6));\n    mrf_foreign_message.Set(i, foreign_message);\n    EXPECT_EQ(message.repeated_int32(i), Func(i, -1));\n    EXPECT_EQ(message.repeated_double(i), Func(i, -2));\n    EXPECT_EQ(message.repeated_string(i), StrFunc(i, -5));\n    EXPECT_EQ(message.repeated_foreign_message(i).c(), Func(i, -6));\n    foreign_message.set_c(Func(i, 7));\n    mrf_message.Set(i, foreign_message);\n    EXPECT_EQ(message.repeated_foreign_message(i).c(), Func(i, 7));\n  }\n\n  // Test iterators.\n  TestRepeatedFieldRefIterator(rf_int32, message,\n                               &TestAllTypes::repeated_int32);\n  TestRepeatedFieldRefIterator(rf_double, message,\n                               &TestAllTypes::repeated_double);\n  TestRepeatedFieldRefIterator(rf_string, message,\n                               &TestAllTypes::repeated_string);\n\n  // Test iterators for message fields.\n  typedef RepeatedFieldRef<ForeignMessage>::iterator MessageIterator;\n  int index = 0;\n  for (MessageIterator it = rf_foreign_message.begin();\n       it != rf_foreign_message.end(); ++it) {\n    EXPECT_EQ(message.repeated_foreign_message(index).c(), it->c());\n    ++index;\n  }\n  EXPECT_EQ(10, index);\n\n  // Test iterator operators that are not ususally used in regular for-loops.\n  // Including: post increment, assign, ==.\n  MessageIterator old_it = rf_foreign_message.begin();\n  MessageIterator new_it = old_it++;\n  EXPECT_FALSE(old_it == new_it);\n  // Check that old_it++ increments old_it once.\n  for (index = 1; old_it != rf_foreign_message.end(); ++old_it, ++index) {\n    EXPECT_EQ(message.repeated_foreign_message(index).c(), old_it->c());\n  }\n  EXPECT_EQ(10, index);\n  // Test assign operator.\n  old_it = new_it;\n  for (index = 0; old_it != rf_foreign_message.end(); ++old_it, ++index) {\n    EXPECT_EQ(message.repeated_foreign_message(index).c(), old_it->c());\n  }\n  EXPECT_EQ(10, index);\n  // Check that the returned value of old_it++ is the one before increment.\n  for (index = 0; new_it != rf_foreign_message.end(); ++new_it, ++index) {\n    EXPECT_EQ(message.repeated_foreign_message(index).c(), new_it->c());\n  }\n  EXPECT_EQ(10, index);\n\n  // Test MutableRepeatedFieldRef::Add()\n  mrf_int32.Add(1234);\n  mrf_double.Add(1234.0);\n  mrf_string.Add(\"1234\");\n  ForeignMessage foreign_message;\n  foreign_message.set_c(1234);\n  mrf_foreign_message.Add(foreign_message);\n  EXPECT_EQ(1234, message.repeated_int32(10));\n  EXPECT_EQ(1234.0, message.repeated_double(10));\n  EXPECT_EQ(\"1234\", message.repeated_string(10));\n  EXPECT_EQ(1234, message.repeated_foreign_message(10).c());\n\n  // Test MutableRepeatedFieldRef::RemoveLast()\n  mrf_int32.RemoveLast();\n  mrf_double.RemoveLast();\n  mrf_string.RemoveLast();\n  mrf_foreign_message.RemoveLast();\n  EXPECT_EQ(10, message.repeated_int32_size());\n  EXPECT_EQ(10, message.repeated_double_size());\n  EXPECT_EQ(10, message.repeated_string_size());\n  EXPECT_EQ(10, message.repeated_foreign_message_size());\n\n  // Test MutableRepeatedFieldRef::SwapElements()\n  mrf_int32.SwapElements(0, 9);\n  mrf_double.SwapElements(0, 9);\n  mrf_string.SwapElements(0, 9);\n  mrf_foreign_message.SwapElements(0, 9);\n  EXPECT_EQ(Func(9, -1), message.repeated_int32(0));\n  EXPECT_EQ(Func(0, -1), message.repeated_int32(9));\n  EXPECT_EQ(Func(9, -2), message.repeated_double(0));\n  EXPECT_EQ(Func(0, -2), message.repeated_double(9));\n  EXPECT_EQ(StrFunc(9, -5), message.repeated_string(0));\n  EXPECT_EQ(StrFunc(0, -5), message.repeated_string(9));\n  EXPECT_EQ(Func(9, 7), message.repeated_foreign_message(0).c());\n  EXPECT_EQ(Func(0, 7), message.repeated_foreign_message(9).c());\n\n  // Test MutableRepeatedFieldRef::Clear()\n  mrf_int32.Clear();\n  mrf_double.Clear();\n  mrf_string.Clear();\n  mrf_foreign_message.Clear();\n  EXPECT_EQ(0, message.repeated_int32_size());\n  EXPECT_EQ(0, message.repeated_double_size());\n  EXPECT_EQ(0, message.repeated_string_size());\n  EXPECT_EQ(0, message.repeated_foreign_message_size());\n\n  // Test (Mutable)RepeatedFieldRef::empty()\n  EXPECT_TRUE(rf_int32.empty());\n  EXPECT_TRUE(mrf_int32.empty());\n  EXPECT_TRUE(rf_double.empty());\n  EXPECT_TRUE(mrf_double.empty());\n  EXPECT_TRUE(rf_string.empty());\n  EXPECT_TRUE(mrf_string.empty());\n  EXPECT_TRUE(rf_foreign_message.empty());\n  EXPECT_TRUE(mrf_foreign_message.empty());\n  EXPECT_TRUE(rf_message.empty());\n  EXPECT_TRUE(mrf_message.empty());\n\n#ifdef PROTOBUF_HAS_DEATH_TEST\n\n  // Make sure types are checked correctly at runtime.\n  const FieldDescriptor* fd_optional_int32 =\n      desc->FindFieldByName(\"optional_int32\");\n  EXPECT_DEATH(refl->GetRepeatedFieldRef<int32>(\n      message, fd_optional_int32), \"\");\n  EXPECT_DEATH(refl->GetRepeatedFieldRef<double>(\n      message, fd_repeated_int32), \"\");\n  EXPECT_DEATH(refl->GetRepeatedFieldRef<TestAllTypes>(\n      message, fd_repeated_foreign_message), \"\");\n\n#endif  // PROTOBUF_HAS_DEATH_TEST\n}\n\nTEST(RepeatedFieldReflectionTest, RepeatedFieldRefForEnums) {\n  TestAllTypes message;\n  const Reflection* refl = message.GetReflection();\n  const Descriptor* desc = message.GetDescriptor();\n\n  for (int i = 0; i < 10; ++i) {\n    message.add_repeated_nested_enum(TestAllTypes::BAR);\n  }\n\n  const FieldDescriptor* fd_repeated_nested_enum =\n      desc->FindFieldByName(\"repeated_nested_enum\");\n  const RepeatedFieldRef<TestAllTypes::NestedEnum> enum_ref =\n      refl->GetRepeatedFieldRef<TestAllTypes::NestedEnum>(\n          message, fd_repeated_nested_enum);\n  const MutableRepeatedFieldRef<TestAllTypes::NestedEnum>\n  mutable_enum_ref =\n      refl->GetMutableRepeatedFieldRef<TestAllTypes::NestedEnum>(\n          &message, fd_repeated_nested_enum);\n  const RepeatedFieldRef<int32> int32_ref =\n      refl->GetRepeatedFieldRef<int32>(\n          message, fd_repeated_nested_enum);\n  const MutableRepeatedFieldRef<int32> mutable_int32_ref =\n      refl->GetMutableRepeatedFieldRef<int32>(\n          &message, fd_repeated_nested_enum);\n\n  EXPECT_EQ(message.repeated_nested_enum_size(), enum_ref.size());\n  EXPECT_EQ(message.repeated_nested_enum_size(), mutable_enum_ref.size());\n  EXPECT_EQ(message.repeated_nested_enum_size(), int32_ref.size());\n  EXPECT_EQ(message.repeated_nested_enum_size(), mutable_int32_ref.size());\n\n  EXPECT_FALSE(enum_ref.empty());\n  EXPECT_FALSE(mutable_enum_ref.empty());\n  EXPECT_FALSE(int32_ref.empty());\n  EXPECT_FALSE(mutable_int32_ref.empty());\n\n  for (int i = 0; i < 10; ++i) {\n    EXPECT_EQ(TestAllTypes::BAR, enum_ref.Get(i));\n    EXPECT_EQ(TestAllTypes::BAR, mutable_enum_ref.Get(i));\n    mutable_enum_ref.Set(i, TestAllTypes::BAZ);\n    EXPECT_EQ(TestAllTypes::BAZ, enum_ref.Get(i));\n    EXPECT_EQ(TestAllTypes::BAZ, message.repeated_nested_enum(i));\n\n    message.set_repeated_nested_enum(i, TestAllTypes::BAR);\n    EXPECT_EQ(TestAllTypes::BAR, int32_ref.Get(i));\n    EXPECT_EQ(TestAllTypes::BAR, mutable_int32_ref.Get(i));\n    mutable_int32_ref.Set(i, TestAllTypes::BAZ);\n    EXPECT_EQ(TestAllTypes::BAZ, int32_ref.Get(i));\n    EXPECT_EQ(TestAllTypes::BAZ, message.repeated_nested_enum(i));\n  }\n\n  TestRepeatedFieldRefIterator(enum_ref, message,\n                               &TestAllTypes::repeated_nested_enum);\n  TestRepeatedFieldRefIterator(int32_ref, message,\n                               &TestAllTypes::repeated_nested_enum);\n\n  // Test Add()\n  mutable_enum_ref.Add(TestAllTypes::FOO);\n  EXPECT_EQ(TestAllTypes::FOO, message.repeated_nested_enum(10));\n  mutable_int32_ref.Add(TestAllTypes::BAR);\n  EXPECT_EQ(TestAllTypes::BAR, message.repeated_nested_enum(11));\n\n  // Test RemoveLast()\n  mutable_enum_ref.RemoveLast();\n  EXPECT_EQ(11, message.repeated_nested_enum_size());\n  mutable_int32_ref.RemoveLast();\n  EXPECT_EQ(10, message.repeated_nested_enum_size());\n\n  // Test SwapElements()\n  mutable_enum_ref.Set(0, TestAllTypes::BAR);\n  mutable_enum_ref.Set(9, TestAllTypes::BAZ);\n  mutable_enum_ref.SwapElements(0, 9);\n  EXPECT_EQ(TestAllTypes::BAZ, enum_ref.Get(0));\n  EXPECT_EQ(TestAllTypes::BAR, enum_ref.Get(9));\n  mutable_int32_ref.SwapElements(0, 9);\n  EXPECT_EQ(TestAllTypes::BAR, enum_ref.Get(0));\n  EXPECT_EQ(TestAllTypes::BAZ, enum_ref.Get(9));\n\n  // Test Clear()\n  mutable_enum_ref.Clear();\n  EXPECT_EQ(0, message.repeated_nested_enum_size());\n  mutable_enum_ref.Add(TestAllTypes::FOO);\n  EXPECT_EQ(1, message.repeated_nested_enum_size());\n  mutable_int32_ref.Clear();\n  EXPECT_EQ(0, message.repeated_nested_enum_size());\n\n  // Test empty()\n  EXPECT_TRUE(enum_ref.empty());\n  EXPECT_TRUE(mutable_enum_ref.empty());\n  EXPECT_TRUE(int32_ref.empty());\n  EXPECT_TRUE(mutable_int32_ref.empty());\n}\n\nTEST(RepeatedFieldReflectionTest, RepeatedFieldRefForExtensionFields) {\n  TestAllExtensions extended_message;\n  const Reflection* refl = extended_message.GetReflection();\n  const Descriptor* desc = extended_message.GetDescriptor();\n\n  for (int i = 0; i < 10; ++i) {\n    extended_message.AddExtension(\n        unittest::repeated_int64_extension, Func(i, 1));\n  }\n\n  const FieldDescriptor* fd_repeated_int64_extension =\n      desc->file()->FindExtensionByName(\"repeated_int64_extension\");\n  GOOGLE_CHECK(fd_repeated_int64_extension != NULL);\n\n  const RepeatedFieldRef<int64> rf_int64_extension =\n      refl->GetRepeatedFieldRef<int64>(extended_message,\n                                          fd_repeated_int64_extension);\n\n  const MutableRepeatedFieldRef<int64> mrf_int64_extension =\n      refl->GetMutableRepeatedFieldRef<int64>(&extended_message,\n                                                 fd_repeated_int64_extension);\n\n  for (int i = 0; i < 10; ++i) {\n    EXPECT_EQ(Func(i, 1), rf_int64_extension.Get(i));\n    mrf_int64_extension.Set(i, Func(i, -1));\n    EXPECT_EQ(Func(i, -1),\n        extended_message.GetExtension(unittest::repeated_int64_extension, i));\n  }\n}\n\n\nTEST(RepeatedFieldReflectionTest, RepeatedFieldRefMergeFromAndSwap) {\n  // Set-up message content.\n  TestAllTypes m0, m1, m2;\n  for (int i = 0; i < 10; ++i) {\n    m0.add_repeated_int32(Func(i, 1));\n    m0.add_repeated_double(Func(i, 2));\n    m0.add_repeated_string(StrFunc(i, 5));\n    m0.add_repeated_foreign_message()->set_c(Func(i, 6));\n    m0.add_repeated_nested_enum(TestAllTypes::FOO);\n    m1.add_repeated_int32(Func(i, 11));\n    m1.add_repeated_double(Func(i, 12));\n    m1.add_repeated_string(StrFunc(i, 15));\n    m1.add_repeated_foreign_message()->set_c(Func(i, 16));\n    m1.add_repeated_nested_enum(TestAllTypes::BAR);\n    m2.add_repeated_int32(Func(i, 21));\n    m2.add_repeated_double(Func(i, 22));\n    m2.add_repeated_string(StrFunc(i, 25));\n    m2.add_repeated_foreign_message()->set_c(Func(i, 26));\n    m2.add_repeated_nested_enum(TestAllTypes::BAZ);\n  }\n\n  const Reflection* refl = m0.GetReflection();\n  const Descriptor* desc = m0.GetDescriptor();\n\n  // Get FieldDescriptors for all the fields of interest.\n  const FieldDescriptor* fd_repeated_int32 =\n      desc->FindFieldByName(\"repeated_int32\");\n  const FieldDescriptor* fd_repeated_double =\n      desc->FindFieldByName(\"repeated_double\");\n  const FieldDescriptor* fd_repeated_string =\n      desc->FindFieldByName(\"repeated_string\");\n  const FieldDescriptor* fd_repeated_foreign_message =\n      desc->FindFieldByName(\"repeated_foreign_message\");\n  const FieldDescriptor* fd_repeated_nested_enum =\n      desc->FindFieldByName(\"repeated_nested_enum\");\n\n  // Get MutableRepeatedFieldRef objects for all fields of interest.\n  const MutableRepeatedFieldRef<int32> mrf_int32 =\n      refl->GetMutableRepeatedFieldRef<int32>(&m0, fd_repeated_int32);\n  const MutableRepeatedFieldRef<double> mrf_double =\n      refl->GetMutableRepeatedFieldRef<double>(&m0, fd_repeated_double);\n  const MutableRepeatedFieldRef<string> mrf_string =\n      refl->GetMutableRepeatedFieldRef<string>(&m0, fd_repeated_string);\n  const MutableRepeatedFieldRef<ForeignMessage> mrf_foreign_message =\n      refl->GetMutableRepeatedFieldRef<ForeignMessage>(\n          &m0, fd_repeated_foreign_message);\n  const MutableRepeatedFieldRef<TestAllTypes::NestedEnum>\n  mrf_nested_enum =\n      refl->GetMutableRepeatedFieldRef<TestAllTypes::NestedEnum>(\n          &m0, fd_repeated_nested_enum);\n\n  // Test MutableRepeatedRef::CopyFrom\n  mrf_int32.CopyFrom(\n      refl->GetRepeatedFieldRef<int32>(m1, fd_repeated_int32));\n  mrf_double.CopyFrom(\n      refl->GetRepeatedFieldRef<double>(m1, fd_repeated_double));\n  mrf_string.CopyFrom(\n      refl->GetRepeatedFieldRef<string>(m1, fd_repeated_string));\n  mrf_foreign_message.CopyFrom(\n      refl->GetRepeatedFieldRef<ForeignMessage>(\n          m1, fd_repeated_foreign_message));\n  mrf_nested_enum.CopyFrom(\n      refl->GetRepeatedFieldRef<TestAllTypes::NestedEnum>(\n          m1, fd_repeated_nested_enum));\n  for (int i = 0; i < 10; ++i) {\n    EXPECT_EQ(Func(i, 11), m0.repeated_int32(i));\n    EXPECT_EQ(Func(i, 12), m0.repeated_double(i));\n    EXPECT_EQ(StrFunc(i, 15), m0.repeated_string(i));\n    EXPECT_EQ(Func(i, 16), m0.repeated_foreign_message(i).c());\n    EXPECT_EQ(TestAllTypes::BAR, m0.repeated_nested_enum(i));\n  }\n\n  // Test MutableRepeatedRef::MergeFrom\n  mrf_int32.MergeFrom(\n      refl->GetRepeatedFieldRef<int32>(m2, fd_repeated_int32));\n  mrf_double.MergeFrom(\n      refl->GetRepeatedFieldRef<double>(m2, fd_repeated_double));\n  mrf_string.MergeFrom(\n      refl->GetRepeatedFieldRef<string>(m2, fd_repeated_string));\n  mrf_foreign_message.MergeFrom(\n      refl->GetRepeatedFieldRef<ForeignMessage>(\n          m2, fd_repeated_foreign_message));\n  mrf_nested_enum.MergeFrom(\n      refl->GetRepeatedFieldRef<TestAllTypes::NestedEnum>(\n          m2, fd_repeated_nested_enum));\n  for (int i = 0; i < 10; ++i) {\n    EXPECT_EQ(Func(i, 21), m0.repeated_int32(i + 10));\n    EXPECT_EQ(Func(i, 22), m0.repeated_double(i + 10));\n    EXPECT_EQ(StrFunc(i, 25), m0.repeated_string(i + 10));\n    EXPECT_EQ(Func(i, 26), m0.repeated_foreign_message(i + 10).c());\n    EXPECT_EQ(TestAllTypes::BAZ, m0.repeated_nested_enum(i + 10));\n  }\n\n  // Test MutableRepeatedRef::Swap\n  // Swap between m0 and m2.\n  mrf_int32.Swap(\n      refl->GetMutableRepeatedFieldRef<int32>(&m2, fd_repeated_int32));\n  mrf_double.Swap(\n      refl->GetMutableRepeatedFieldRef<double>(&m2, fd_repeated_double));\n  mrf_string.Swap(\n      refl->GetMutableRepeatedFieldRef<string>(&m2, fd_repeated_string));\n  mrf_foreign_message.Swap(\n      refl->GetMutableRepeatedFieldRef<ForeignMessage>(\n          &m2, fd_repeated_foreign_message));\n  mrf_nested_enum.Swap(\n      refl->GetMutableRepeatedFieldRef<TestAllTypes::NestedEnum>(\n          &m2, fd_repeated_nested_enum));\n  for (int i = 0; i < 10; ++i) {\n    // Check the content of m0.\n    EXPECT_EQ(Func(i, 21), m0.repeated_int32(i));\n    EXPECT_EQ(Func(i, 22), m0.repeated_double(i));\n    EXPECT_EQ(StrFunc(i, 25), m0.repeated_string(i));\n    EXPECT_EQ(Func(i, 26), m0.repeated_foreign_message(i).c());\n    EXPECT_EQ(TestAllTypes::BAZ, m0.repeated_nested_enum(i));\n\n    // Check the content of m2.\n    EXPECT_EQ(Func(i, 11), m2.repeated_int32(i));\n    EXPECT_EQ(Func(i, 12), m2.repeated_double(i));\n    EXPECT_EQ(StrFunc(i, 15), m2.repeated_string(i));\n    EXPECT_EQ(Func(i, 16), m2.repeated_foreign_message(i).c());\n    EXPECT_EQ(TestAllTypes::BAR, m2.repeated_nested_enum(i));\n    EXPECT_EQ(Func(i, 21), m2.repeated_int32(i + 10));\n    EXPECT_EQ(Func(i, 22), m2.repeated_double(i + 10));\n    EXPECT_EQ(StrFunc(i, 25), m2.repeated_string(i + 10));\n    EXPECT_EQ(Func(i, 26), m2.repeated_foreign_message(i + 10).c());\n    EXPECT_EQ(TestAllTypes::BAZ, m2.repeated_nested_enum(i + 10));\n  }\n}\n\n// Test that GetRepeatedFieldRef/MutableRepeatedFieldRef works with\n// DynamicMessage.\nTEST(RepeatedFieldReflectionTest, RepeatedFieldRefDynamicMessage) {\n  // DynamicMessage shares the same memory layout as generated message\n  // and use the same GeneratedMessageReflection code for reflection.\n  // All code paths should already be covered by the other tests for\n  // generated messages. Here we just test one field.\n\n  const Descriptor* desc = TestAllTypes::descriptor();\n  const FieldDescriptor* fd_repeated_int32 =\n      desc->FindFieldByName(\"repeated_int32\");\n\n  DynamicMessageFactory factory;\n  google::protobuf::scoped_ptr<Message> dynamic_message(factory.GetPrototype(desc)->New());\n  const Reflection* refl = dynamic_message->GetReflection();\n\n  MutableRepeatedFieldRef<int32> rf_int32 =\n      refl->GetMutableRepeatedFieldRef<int32>(\n          dynamic_message.get(), fd_repeated_int32);\n  rf_int32.Add(1234);\n  EXPECT_EQ(1, refl->FieldSize(*dynamic_message, fd_repeated_int32));\n  EXPECT_EQ(1234, refl->GetRepeatedInt32(*dynamic_message,\n                                         fd_repeated_int32, 0));\n}\n\n}  // namespace\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/repeated_field_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// TODO(kenton):  Improve this unittest to bring it up to the standards of\n//   other proto2 unittests.\n\n#include <algorithm>\n#include <limits>\n#include <list>\n#include <vector>\n\n#include <google/protobuf/repeated_field.h>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n#include <google/protobuf/stubs/stl_util.h>\n\nnamespace google {\nusing protobuf_unittest::TestAllTypes;\n\nnamespace protobuf {\nnamespace {\n\n// Test operations on a small RepeatedField.\nTEST(RepeatedField, Small) {\n  RepeatedField<int> field;\n\n  EXPECT_TRUE(field.empty());\n  EXPECT_EQ(field.size(), 0);\n\n  field.Add(5);\n\n  EXPECT_FALSE(field.empty());\n  EXPECT_EQ(field.size(), 1);\n  EXPECT_EQ(field.Get(0), 5);\n\n  field.Add(42);\n\n  EXPECT_FALSE(field.empty());\n  EXPECT_EQ(field.size(), 2);\n  EXPECT_EQ(field.Get(0), 5);\n  EXPECT_EQ(field.Get(1), 42);\n\n  field.Set(1, 23);\n\n  EXPECT_FALSE(field.empty());\n  EXPECT_EQ(field.size(), 2);\n  EXPECT_EQ(field.Get(0), 5);\n  EXPECT_EQ(field.Get(1), 23);\n\n  field.RemoveLast();\n\n  EXPECT_FALSE(field.empty());\n  EXPECT_EQ(field.size(), 1);\n  EXPECT_EQ(field.Get(0), 5);\n\n  field.Clear();\n\n  EXPECT_TRUE(field.empty());\n  EXPECT_EQ(field.size(), 0);\n  // Additional bytes are for 'struct Rep' header.\n  int expected_usage = 4 * sizeof(int) + sizeof(Arena*);\n  EXPECT_EQ(field.SpaceUsedExcludingSelf(), expected_usage);\n}\n\n\n// Test operations on a RepeatedField which is large enough to allocate a\n// separate array.\nTEST(RepeatedField, Large) {\n  RepeatedField<int> field;\n\n  for (int i = 0; i < 16; i++) {\n    field.Add(i * i);\n  }\n\n  EXPECT_FALSE(field.empty());\n  EXPECT_EQ(field.size(), 16);\n\n  for (int i = 0; i < 16; i++) {\n    EXPECT_EQ(field.Get(i), i * i);\n  }\n\n  int expected_usage = 16 * sizeof(int);\n  EXPECT_GE(field.SpaceUsedExcludingSelf(), expected_usage);\n}\n\n// Test swapping between various types of RepeatedFields.\nTEST(RepeatedField, SwapSmallSmall) {\n  RepeatedField<int> field1;\n  RepeatedField<int> field2;\n\n  field1.Add(5);\n  field1.Add(42);\n\n  EXPECT_FALSE(field1.empty());\n  EXPECT_EQ(field1.size(), 2);\n  EXPECT_EQ(field1.Get(0), 5);\n  EXPECT_EQ(field1.Get(1), 42);\n\n  EXPECT_TRUE(field2.empty());\n  EXPECT_EQ(field2.size(), 0);\n\n  field1.Swap(&field2);\n\n  EXPECT_TRUE(field1.empty());\n  EXPECT_EQ(field1.size(), 0);\n\n  EXPECT_FALSE(field2.empty());\n  EXPECT_EQ(field2.size(), 2);\n  EXPECT_EQ(field2.Get(0), 5);\n  EXPECT_EQ(field2.Get(1), 42);\n}\n\nTEST(RepeatedField, SwapLargeSmall) {\n  RepeatedField<int> field1;\n  RepeatedField<int> field2;\n\n  for (int i = 0; i < 16; i++) {\n    field1.Add(i * i);\n  }\n  field2.Add(5);\n  field2.Add(42);\n  field1.Swap(&field2);\n\n  EXPECT_EQ(field1.size(), 2);\n  EXPECT_EQ(field1.Get(0), 5);\n  EXPECT_EQ(field1.Get(1), 42);\n  EXPECT_EQ(field2.size(), 16);\n  for (int i = 0; i < 16; i++) {\n    EXPECT_EQ(field2.Get(i), i * i);\n  }\n}\n\nTEST(RepeatedField, SwapLargeLarge) {\n  RepeatedField<int> field1;\n  RepeatedField<int> field2;\n\n  field1.Add(5);\n  field1.Add(42);\n  for (int i = 0; i < 16; i++) {\n    field1.Add(i);\n    field2.Add(i * i);\n  }\n  field2.Swap(&field1);\n\n  EXPECT_EQ(field1.size(), 16);\n  for (int i = 0; i < 16; i++) {\n    EXPECT_EQ(field1.Get(i), i * i);\n  }\n  EXPECT_EQ(field2.size(), 18);\n  EXPECT_EQ(field2.Get(0), 5);\n  EXPECT_EQ(field2.Get(1), 42);\n  for (int i = 2; i < 18; i++) {\n    EXPECT_EQ(field2.Get(i), i - 2);\n  }\n}\n\n// Determines how much space was reserved by the given field by adding elements\n// to it until it re-allocates its space.\nstatic int ReservedSpace(RepeatedField<int>* field) {\n  const int* ptr = field->data();\n  do {\n    field->Add(0);\n  } while (field->data() == ptr);\n\n  return field->size() - 1;\n}\n\nTEST(RepeatedField, ReserveMoreThanDouble) {\n  // Reserve more than double the previous space in the field and expect the\n  // field to reserve exactly the amount specified.\n  RepeatedField<int> field;\n  field.Reserve(20);\n\n  EXPECT_EQ(20, ReservedSpace(&field));\n}\n\nTEST(RepeatedField, ReserveLessThanDouble) {\n  // Reserve less than double the previous space in the field and expect the\n  // field to grow by double instead.\n  RepeatedField<int> field;\n  field.Reserve(20);\n  field.Reserve(30);\n\n  EXPECT_EQ(40, ReservedSpace(&field));\n}\n\nTEST(RepeatedField, ReserveLessThanExisting) {\n  // Reserve less than the previous space in the field and expect the\n  // field to not re-allocate at all.\n  RepeatedField<int> field;\n  field.Reserve(20);\n  const int* previous_ptr = field.data();\n  field.Reserve(10);\n\n  EXPECT_EQ(previous_ptr, field.data());\n  EXPECT_EQ(20, ReservedSpace(&field));\n}\n\nTEST(RepeatedField, Resize) {\n  RepeatedField<int> field;\n  field.Resize(2, 1);\n  EXPECT_EQ(2, field.size());\n  field.Resize(5, 2);\n  EXPECT_EQ(5, field.size());\n  field.Resize(4, 3);\n  ASSERT_EQ(4, field.size());\n  EXPECT_EQ(1, field.Get(0));\n  EXPECT_EQ(1, field.Get(1));\n  EXPECT_EQ(2, field.Get(2));\n  EXPECT_EQ(2, field.Get(3));\n  field.Resize(0, 4);\n  EXPECT_TRUE(field.empty());\n}\n\nTEST(RepeatedField, MergeFrom) {\n  RepeatedField<int> source, destination;\n  source.Add(4);\n  source.Add(5);\n  destination.Add(1);\n  destination.Add(2);\n  destination.Add(3);\n\n  destination.MergeFrom(source);\n\n  ASSERT_EQ(5, destination.size());\n  EXPECT_EQ(1, destination.Get(0));\n  EXPECT_EQ(2, destination.Get(1));\n  EXPECT_EQ(3, destination.Get(2));\n  EXPECT_EQ(4, destination.Get(3));\n  EXPECT_EQ(5, destination.Get(4));\n}\n\n#ifdef PROTOBUF_HAS_DEATH_TEST\nTEST(RepeatedField, MergeFromSelf) {\n  RepeatedField<int> me;\n  me.Add(3);\n  EXPECT_DEATH(me.MergeFrom(me), \"\");\n}\n#endif  // PROTOBUF_HAS_DEATH_TEST\n\nTEST(RepeatedField, CopyFrom) {\n  RepeatedField<int> source, destination;\n  source.Add(4);\n  source.Add(5);\n  destination.Add(1);\n  destination.Add(2);\n  destination.Add(3);\n\n  destination.CopyFrom(source);\n\n  ASSERT_EQ(2, destination.size());\n  EXPECT_EQ(4, destination.Get(0));\n  EXPECT_EQ(5, destination.Get(1));\n}\n\nTEST(RepeatedField, CopyFromSelf) {\n  RepeatedField<int> me;\n  me.Add(3);\n  me.CopyFrom(me);\n  ASSERT_EQ(1, me.size());\n  EXPECT_EQ(3, me.Get(0));\n}\n\nTEST(RepeatedField, Erase) {\n  RepeatedField<int> me;\n  RepeatedField<int>::iterator it = me.erase(me.begin(), me.end());\n  EXPECT_TRUE(me.begin() == it);\n  EXPECT_EQ(0, me.size());\n\n  me.Add(1);\n  me.Add(2);\n  me.Add(3);\n  it = me.erase(me.begin(), me.end());\n  EXPECT_TRUE(me.begin() == it);\n  EXPECT_EQ(0, me.size());\n\n  me.Add(4);\n  me.Add(5);\n  me.Add(6);\n  it = me.erase(me.begin() + 2, me.end());\n  EXPECT_TRUE(me.begin() + 2 == it);\n  EXPECT_EQ(2, me.size());\n  EXPECT_EQ(4, me.Get(0));\n  EXPECT_EQ(5, me.Get(1));\n\n  me.Add(6);\n  me.Add(7);\n  me.Add(8);\n  it = me.erase(me.begin() + 1, me.begin() + 3);\n  EXPECT_TRUE(me.begin() + 1 == it);\n  EXPECT_EQ(3, me.size());\n  EXPECT_EQ(4, me.Get(0));\n  EXPECT_EQ(7, me.Get(1));\n  EXPECT_EQ(8, me.Get(2));\n}\n\nTEST(RepeatedField, CopyConstruct) {\n  RepeatedField<int> source;\n  source.Add(1);\n  source.Add(2);\n\n  RepeatedField<int> destination(source);\n\n  ASSERT_EQ(2, destination.size());\n  EXPECT_EQ(1, destination.Get(0));\n  EXPECT_EQ(2, destination.Get(1));\n}\n\nTEST(RepeatedField, IteratorConstruct) {\n  vector<int> values;\n  values.push_back(1);\n  values.push_back(2);\n\n  RepeatedField<int> field(values.begin(), values.end());\n  ASSERT_EQ(values.size(), field.size());\n  EXPECT_EQ(values[0], field.Get(0));\n  EXPECT_EQ(values[1], field.Get(1));\n\n  RepeatedField<int> other(field.begin(), field.end());\n  ASSERT_EQ(values.size(), other.size());\n  EXPECT_EQ(values[0], other.Get(0));\n  EXPECT_EQ(values[1], other.Get(1));\n}\n\nTEST(RepeatedField, CopyAssign) {\n  RepeatedField<int> source, destination;\n  source.Add(4);\n  source.Add(5);\n  destination.Add(1);\n  destination.Add(2);\n  destination.Add(3);\n\n  destination = source;\n\n  ASSERT_EQ(2, destination.size());\n  EXPECT_EQ(4, destination.Get(0));\n  EXPECT_EQ(5, destination.Get(1));\n}\n\nTEST(RepeatedField, SelfAssign) {\n  // Verify that assignment to self does not destroy data.\n  RepeatedField<int> source, *p;\n  p = &source;\n  source.Add(7);\n  source.Add(8);\n\n  *p = source;\n\n  ASSERT_EQ(2, source.size());\n  EXPECT_EQ(7, source.Get(0));\n  EXPECT_EQ(8, source.Get(1));\n}\n\nTEST(RepeatedField, MutableDataIsMutable) {\n  RepeatedField<int> field;\n  field.Add(1);\n  EXPECT_EQ(1, field.Get(0));\n  // The fact that this line compiles would be enough, but we'll check the\n  // value anyway.\n  *field.mutable_data() = 2;\n  EXPECT_EQ(2, field.Get(0));\n}\n\nTEST(RepeatedField, Truncate) {\n  RepeatedField<int> field;\n\n  field.Add(12);\n  field.Add(34);\n  field.Add(56);\n  field.Add(78);\n  EXPECT_EQ(4, field.size());\n\n  field.Truncate(3);\n  EXPECT_EQ(3, field.size());\n\n  field.Add(90);\n  EXPECT_EQ(4, field.size());\n  EXPECT_EQ(90, field.Get(3));\n\n  // Truncations that don't change the size are allowed, but growing is not\n  // allowed.\n  field.Truncate(field.size());\n#ifdef PROTOBUF_HAS_DEATH_TEST\n  EXPECT_DEBUG_DEATH(field.Truncate(field.size() + 1), \"new_size\");\n#endif\n}\n\n\nTEST(RepeatedField, ExtractSubrange) {\n  // Exhaustively test every subrange in arrays of all sizes from 0 through 9.\n  for (int sz = 0; sz < 10; ++sz) {\n    for (int num = 0; num <= sz; ++num) {\n      for (int start = 0; start < sz - num; ++start) {\n        // Create RepeatedField with sz elements having values 0 through sz-1.\n        RepeatedField<int32> field;\n        for (int i = 0; i < sz; ++i)\n          field.Add(i);\n        EXPECT_EQ(field.size(), sz);\n\n        // Create a catcher array and call ExtractSubrange.\n        int32 catcher[10];\n        for (int i = 0; i < 10; ++i)\n          catcher[i] = -1;\n        field.ExtractSubrange(start, num, catcher);\n\n        // Does the resulting array have the right size?\n        EXPECT_EQ(field.size(), sz - num);\n\n        // Were the removed elements extracted into the catcher array?\n        for (int i = 0; i < num; ++i)\n          EXPECT_EQ(catcher[i], start + i);\n        EXPECT_EQ(catcher[num], -1);\n\n        // Does the resulting array contain the right values?\n        for (int i = 0; i < start; ++i)\n          EXPECT_EQ(field.Get(i), i);\n        for (int i = start; i < field.size(); ++i)\n          EXPECT_EQ(field.Get(i), i + num);\n      }\n    }\n  }\n}\n\nTEST(RepeatedField, ClearThenReserveMore) {\n  // Test that Reserve properly destroys the old internal array when it's forced\n  // to allocate a new one, even when cleared-but-not-deleted objects are\n  // present. Use a 'string' and > 16 bytes length so that the elements are\n  // non-POD and allocate -- the leak checker will catch any skipped destructor\n  // calls here.\n  RepeatedField<string> field;\n  for (int i = 0; i < 32; i++) {\n    field.Add(string(\"abcdefghijklmnopqrstuvwxyz0123456789\"));\n  }\n  EXPECT_EQ(32, field.size());\n  field.Clear();\n  EXPECT_EQ(0, field.size());\n  EXPECT_EQ(32, field.Capacity());\n\n  field.Reserve(1024);\n  EXPECT_EQ(0, field.size());\n  EXPECT_EQ(1024, field.Capacity());\n  // Finish test -- |field| should destroy the cleared-but-not-yet-destroyed\n  // strings.\n}\n\n// ===================================================================\n// RepeatedPtrField tests.  These pretty much just mirror the RepeatedField\n// tests above.\n\nTEST(RepeatedPtrField, Small) {\n  RepeatedPtrField<string> field;\n\n  EXPECT_TRUE(field.empty());\n  EXPECT_EQ(field.size(), 0);\n\n  field.Add()->assign(\"foo\");\n\n  EXPECT_FALSE(field.empty());\n  EXPECT_EQ(field.size(), 1);\n  EXPECT_EQ(field.Get(0), \"foo\");\n\n  field.Add()->assign(\"bar\");\n\n  EXPECT_FALSE(field.empty());\n  EXPECT_EQ(field.size(), 2);\n  EXPECT_EQ(field.Get(0), \"foo\");\n  EXPECT_EQ(field.Get(1), \"bar\");\n\n  field.Mutable(1)->assign(\"baz\");\n\n  EXPECT_FALSE(field.empty());\n  EXPECT_EQ(field.size(), 2);\n  EXPECT_EQ(field.Get(0), \"foo\");\n  EXPECT_EQ(field.Get(1), \"baz\");\n\n  field.RemoveLast();\n\n  EXPECT_FALSE(field.empty());\n  EXPECT_EQ(field.size(), 1);\n  EXPECT_EQ(field.Get(0), \"foo\");\n\n  field.Clear();\n\n  EXPECT_TRUE(field.empty());\n  EXPECT_EQ(field.size(), 0);\n}\n\nTEST(RepeatedPtrField, Large) {\n  RepeatedPtrField<string> field;\n\n  for (int i = 0; i < 16; i++) {\n    *field.Add() += 'a' + i;\n  }\n\n  EXPECT_EQ(field.size(), 16);\n\n  for (int i = 0; i < 16; i++) {\n    EXPECT_EQ(field.Get(i).size(), 1);\n    EXPECT_EQ(field.Get(i)[0], 'a' + i);\n  }\n\n  int min_expected_usage = 16 * sizeof(string);\n  EXPECT_GE(field.SpaceUsedExcludingSelf(), min_expected_usage);\n}\n\nTEST(RepeatedPtrField, SwapSmallSmall) {\n  RepeatedPtrField<string> field1;\n  RepeatedPtrField<string> field2;\n\n  EXPECT_TRUE(field1.empty());\n  EXPECT_EQ(field1.size(), 0);\n  EXPECT_TRUE(field2.empty());\n  EXPECT_EQ(field2.size(), 0);\n\n  field1.Add()->assign(\"foo\");\n  field1.Add()->assign(\"bar\");\n\n  EXPECT_FALSE(field1.empty());\n  EXPECT_EQ(field1.size(), 2);\n  EXPECT_EQ(field1.Get(0), \"foo\");\n  EXPECT_EQ(field1.Get(1), \"bar\");\n\n  EXPECT_TRUE(field2.empty());\n  EXPECT_EQ(field2.size(), 0);\n\n  field1.Swap(&field2);\n\n  EXPECT_TRUE(field1.empty());\n  EXPECT_EQ(field1.size(), 0);\n\n  EXPECT_EQ(field2.size(), 2);\n  EXPECT_EQ(field2.Get(0), \"foo\");\n  EXPECT_EQ(field2.Get(1), \"bar\");\n}\n\nTEST(RepeatedPtrField, SwapLargeSmall) {\n  RepeatedPtrField<string> field1;\n  RepeatedPtrField<string> field2;\n\n  field2.Add()->assign(\"foo\");\n  field2.Add()->assign(\"bar\");\n  for (int i = 0; i < 16; i++) {\n    *field1.Add() += 'a' + i;\n  }\n  field1.Swap(&field2);\n\n  EXPECT_EQ(field1.size(), 2);\n  EXPECT_EQ(field1.Get(0), \"foo\");\n  EXPECT_EQ(field1.Get(1), \"bar\");\n  EXPECT_EQ(field2.size(), 16);\n  for (int i = 0; i < 16; i++) {\n    EXPECT_EQ(field2.Get(i).size(), 1);\n    EXPECT_EQ(field2.Get(i)[0], 'a' + i);\n  }\n}\n\nTEST(RepeatedPtrField, SwapLargeLarge) {\n  RepeatedPtrField<string> field1;\n  RepeatedPtrField<string> field2;\n\n  field1.Add()->assign(\"foo\");\n  field1.Add()->assign(\"bar\");\n  for (int i = 0; i < 16; i++) {\n    *field1.Add() += 'A' + i;\n    *field2.Add() += 'a' + i;\n  }\n  field2.Swap(&field1);\n\n  EXPECT_EQ(field1.size(), 16);\n  for (int i = 0; i < 16; i++) {\n    EXPECT_EQ(field1.Get(i).size(), 1);\n    EXPECT_EQ(field1.Get(i)[0], 'a' + i);\n  }\n  EXPECT_EQ(field2.size(), 18);\n  EXPECT_EQ(field2.Get(0), \"foo\");\n  EXPECT_EQ(field2.Get(1), \"bar\");\n  for (int i = 2; i < 18; i++) {\n    EXPECT_EQ(field2.Get(i).size(), 1);\n    EXPECT_EQ(field2.Get(i)[0], 'A' + i - 2);\n  }\n}\n\nstatic int ReservedSpace(RepeatedPtrField<string>* field) {\n  const string* const* ptr = field->data();\n  do {\n    field->Add();\n  } while (field->data() == ptr);\n\n  return field->size() - 1;\n}\n\nTEST(RepeatedPtrField, ReserveMoreThanDouble) {\n  RepeatedPtrField<string> field;\n  field.Reserve(20);\n\n  EXPECT_EQ(20, ReservedSpace(&field));\n}\n\nTEST(RepeatedPtrField, ReserveLessThanDouble) {\n  RepeatedPtrField<string> field;\n  field.Reserve(20);\n  field.Reserve(30);\n\n  EXPECT_EQ(40, ReservedSpace(&field));\n}\n\nTEST(RepeatedPtrField, ReserveLessThanExisting) {\n  RepeatedPtrField<string> field;\n  field.Reserve(20);\n  const string* const* previous_ptr = field.data();\n  field.Reserve(10);\n\n  EXPECT_EQ(previous_ptr, field.data());\n  EXPECT_EQ(20, ReservedSpace(&field));\n}\n\nTEST(RepeatedPtrField, ReserveDoesntLoseAllocated) {\n  // Check that a bug is fixed:  An earlier implementation of Reserve()\n  // failed to copy pointers to allocated-but-cleared objects, possibly\n  // leading to segfaults.\n  RepeatedPtrField<string> field;\n  string* first = field.Add();\n  field.RemoveLast();\n\n  field.Reserve(20);\n  EXPECT_EQ(first, field.Add());\n}\n\n// Clearing elements is tricky with RepeatedPtrFields since the memory for\n// the elements is retained and reused.\nTEST(RepeatedPtrField, ClearedElements) {\n  RepeatedPtrField<string> field;\n\n  string* original = field.Add();\n  *original = \"foo\";\n\n  EXPECT_EQ(field.ClearedCount(), 0);\n\n  field.RemoveLast();\n  EXPECT_TRUE(original->empty());\n  EXPECT_EQ(field.ClearedCount(), 1);\n\n  EXPECT_EQ(field.Add(), original);  // Should return same string for reuse.\n\n  EXPECT_EQ(field.ReleaseLast(), original);  // We take ownership.\n  EXPECT_EQ(field.ClearedCount(), 0);\n\n  EXPECT_NE(field.Add(), original);  // Should NOT return the same string.\n  EXPECT_EQ(field.ClearedCount(), 0);\n\n  field.AddAllocated(original);  // Give ownership back.\n  EXPECT_EQ(field.ClearedCount(), 0);\n  EXPECT_EQ(field.Mutable(1), original);\n\n  field.Clear();\n  EXPECT_EQ(field.ClearedCount(), 2);\n  EXPECT_EQ(field.ReleaseCleared(), original);  // Take ownership again.\n  EXPECT_EQ(field.ClearedCount(), 1);\n  EXPECT_NE(field.Add(), original);\n  EXPECT_EQ(field.ClearedCount(), 0);\n  EXPECT_NE(field.Add(), original);\n  EXPECT_EQ(field.ClearedCount(), 0);\n\n  field.AddCleared(original);  // Give ownership back, but as a cleared object.\n  EXPECT_EQ(field.ClearedCount(), 1);\n  EXPECT_EQ(field.Add(), original);\n  EXPECT_EQ(field.ClearedCount(), 0);\n}\n\n// Test all code paths in AddAllocated().\nTEST(RepeatedPtrField, AddAlocated) {\n  RepeatedPtrField<string> field;\n  while (field.size() < field.Capacity()) {\n    field.Add()->assign(\"filler\");\n  }\n\n  int index = field.size();\n\n  // First branch:  Field is at capacity with no cleared objects.\n  string* foo = new string(\"foo\");\n  field.AddAllocated(foo);\n  EXPECT_EQ(index + 1, field.size());\n  EXPECT_EQ(0, field.ClearedCount());\n  EXPECT_EQ(foo, &field.Get(index));\n\n  // Last branch:  Field is not at capacity and there are no cleared objects.\n  string* bar = new string(\"bar\");\n  field.AddAllocated(bar);\n  ++index;\n  EXPECT_EQ(index + 1, field.size());\n  EXPECT_EQ(0, field.ClearedCount());\n  EXPECT_EQ(bar, &field.Get(index));\n\n  // Third branch:  Field is not at capacity and there are no cleared objects.\n  field.RemoveLast();\n  string* baz = new string(\"baz\");\n  field.AddAllocated(baz);\n  EXPECT_EQ(index + 1, field.size());\n  EXPECT_EQ(1, field.ClearedCount());\n  EXPECT_EQ(baz, &field.Get(index));\n\n  // Second branch:  Field is at capacity but has some cleared objects.\n  while (field.size() < field.Capacity()) {\n    field.Add()->assign(\"filler2\");\n  }\n  field.RemoveLast();\n  index = field.size();\n  string* qux = new string(\"qux\");\n  field.AddAllocated(qux);\n  EXPECT_EQ(index + 1, field.size());\n  // We should have discarded the cleared object.\n  EXPECT_EQ(0, field.ClearedCount());\n  EXPECT_EQ(qux, &field.Get(index));\n}\n\nTEST(RepeatedPtrField, MergeFrom) {\n  RepeatedPtrField<string> source, destination;\n  source.Add()->assign(\"4\");\n  source.Add()->assign(\"5\");\n  destination.Add()->assign(\"1\");\n  destination.Add()->assign(\"2\");\n  destination.Add()->assign(\"3\");\n\n  destination.MergeFrom(source);\n\n  ASSERT_EQ(5, destination.size());\n  EXPECT_EQ(\"1\", destination.Get(0));\n  EXPECT_EQ(\"2\", destination.Get(1));\n  EXPECT_EQ(\"3\", destination.Get(2));\n  EXPECT_EQ(\"4\", destination.Get(3));\n  EXPECT_EQ(\"5\", destination.Get(4));\n}\n\n#ifdef PROTOBUF_HAS_DEATH_TEST\nTEST(RepeatedPtrField, MergeFromSelf) {\n  RepeatedPtrField<string> me;\n  me.Add()->assign(\"1\");\n  EXPECT_DEATH(me.MergeFrom(me), \"\");\n}\n#endif  // PROTOBUF_HAS_DEATH_TEST\n\nTEST(RepeatedPtrField, CopyFrom) {\n  RepeatedPtrField<string> source, destination;\n  source.Add()->assign(\"4\");\n  source.Add()->assign(\"5\");\n  destination.Add()->assign(\"1\");\n  destination.Add()->assign(\"2\");\n  destination.Add()->assign(\"3\");\n\n  destination.CopyFrom(source);\n\n  ASSERT_EQ(2, destination.size());\n  EXPECT_EQ(\"4\", destination.Get(0));\n  EXPECT_EQ(\"5\", destination.Get(1));\n}\n\nTEST(RepeatedPtrField, CopyFromSelf) {\n  RepeatedPtrField<string> me;\n  me.Add()->assign(\"1\");\n  me.CopyFrom(me);\n  ASSERT_EQ(1, me.size());\n  EXPECT_EQ(\"1\", me.Get(0));\n}\n\nTEST(RepeatedPtrField, Erase) {\n  RepeatedPtrField<string> me;\n  RepeatedPtrField<string>::iterator it = me.erase(me.begin(), me.end());\n  EXPECT_TRUE(me.begin() == it);\n  EXPECT_EQ(0, me.size());\n\n  *me.Add() = \"1\";\n  *me.Add() = \"2\";\n  *me.Add() = \"3\";\n  it = me.erase(me.begin(), me.end());\n  EXPECT_TRUE(me.begin() == it);\n  EXPECT_EQ(0, me.size());\n\n  *me.Add() = \"4\";\n  *me.Add() = \"5\";\n  *me.Add() = \"6\";\n  it = me.erase(me.begin() + 2, me.end());\n  EXPECT_TRUE(me.begin() + 2 == it);\n  EXPECT_EQ(2, me.size());\n  EXPECT_EQ(\"4\", me.Get(0));\n  EXPECT_EQ(\"5\", me.Get(1));\n\n  *me.Add() = \"6\";\n  *me.Add() = \"7\";\n  *me.Add() = \"8\";\n  it = me.erase(me.begin() + 1, me.begin() + 3);\n  EXPECT_TRUE(me.begin() + 1 == it);\n  EXPECT_EQ(3, me.size());\n  EXPECT_EQ(\"4\", me.Get(0));\n  EXPECT_EQ(\"7\", me.Get(1));\n  EXPECT_EQ(\"8\", me.Get(2));\n}\n\nTEST(RepeatedPtrField, CopyConstruct) {\n  RepeatedPtrField<string> source;\n  source.Add()->assign(\"1\");\n  source.Add()->assign(\"2\");\n\n  RepeatedPtrField<string> destination(source);\n\n  ASSERT_EQ(2, destination.size());\n  EXPECT_EQ(\"1\", destination.Get(0));\n  EXPECT_EQ(\"2\", destination.Get(1));\n}\n\nTEST(RepeatedPtrField, IteratorConstruct_String) {\n  vector<string> values;\n  values.push_back(\"1\");\n  values.push_back(\"2\");\n\n  RepeatedPtrField<string> field(values.begin(), values.end());\n  ASSERT_EQ(values.size(), field.size());\n  EXPECT_EQ(values[0], field.Get(0));\n  EXPECT_EQ(values[1], field.Get(1));\n\n  RepeatedPtrField<string> other(field.begin(), field.end());\n  ASSERT_EQ(values.size(), other.size());\n  EXPECT_EQ(values[0], other.Get(0));\n  EXPECT_EQ(values[1], other.Get(1));\n}\n\nTEST(RepeatedPtrField, IteratorConstruct_Proto) {\n  typedef TestAllTypes::NestedMessage Nested;\n  vector<Nested> values;\n  values.push_back(Nested());\n  values.back().set_bb(1);\n  values.push_back(Nested());\n  values.back().set_bb(2);\n\n  RepeatedPtrField<Nested> field(values.begin(), values.end());\n  ASSERT_EQ(values.size(), field.size());\n  EXPECT_EQ(values[0].bb(), field.Get(0).bb());\n  EXPECT_EQ(values[1].bb(), field.Get(1).bb());\n\n  RepeatedPtrField<Nested> other(field.begin(), field.end());\n  ASSERT_EQ(values.size(), other.size());\n  EXPECT_EQ(values[0].bb(), other.Get(0).bb());\n  EXPECT_EQ(values[1].bb(), other.Get(1).bb());\n}\n\nTEST(RepeatedPtrField, CopyAssign) {\n  RepeatedPtrField<string> source, destination;\n  source.Add()->assign(\"4\");\n  source.Add()->assign(\"5\");\n  destination.Add()->assign(\"1\");\n  destination.Add()->assign(\"2\");\n  destination.Add()->assign(\"3\");\n\n  destination = source;\n\n  ASSERT_EQ(2, destination.size());\n  EXPECT_EQ(\"4\", destination.Get(0));\n  EXPECT_EQ(\"5\", destination.Get(1));\n}\n\nTEST(RepeatedPtrField, SelfAssign) {\n  // Verify that assignment to self does not destroy data.\n  RepeatedPtrField<string> source, *p;\n  p = &source;\n  source.Add()->assign(\"7\");\n  source.Add()->assign(\"8\");\n\n  *p = source;\n\n  ASSERT_EQ(2, source.size());\n  EXPECT_EQ(\"7\", source.Get(0));\n  EXPECT_EQ(\"8\", source.Get(1));\n}\n\nTEST(RepeatedPtrField, MutableDataIsMutable) {\n  RepeatedPtrField<string> field;\n  *field.Add() = \"1\";\n  EXPECT_EQ(\"1\", field.Get(0));\n  // The fact that this line compiles would be enough, but we'll check the\n  // value anyway.\n  string** data = field.mutable_data();\n  **data = \"2\";\n  EXPECT_EQ(\"2\", field.Get(0));\n}\n\nTEST(RepeatedPtrField, ExtractSubrange) {\n  // Exhaustively test every subrange in arrays of all sizes from 0 through 9\n  // with 0 through 3 cleared elements at the end.\n  for (int sz = 0; sz < 10; ++sz) {\n    for (int num = 0; num <= sz; ++num) {\n      for (int start = 0; start < sz - num; ++start) {\n        for (int extra = 0; extra < 4; ++extra) {\n          vector<string*> subject;\n\n          // Create an array with \"sz\" elements and \"extra\" cleared elements.\n          RepeatedPtrField<string> field;\n          for (int i = 0; i < sz + extra; ++i) {\n            subject.push_back(new string());\n            field.AddAllocated(subject[i]);\n          }\n          EXPECT_EQ(field.size(), sz + extra);\n          for (int i = 0; i < extra; ++i)\n            field.RemoveLast();\n          EXPECT_EQ(field.size(), sz);\n          EXPECT_EQ(field.ClearedCount(), extra);\n\n          // Create a catcher array and call ExtractSubrange.\n          string* catcher[10];\n          for (int i = 0; i < 10; ++i)\n            catcher[i] = NULL;\n          field.ExtractSubrange(start, num, catcher);\n\n          // Does the resulting array have the right size?\n          EXPECT_EQ(field.size(), sz - num);\n\n          // Were the removed elements extracted into the catcher array?\n          for (int i = 0; i < num; ++i)\n            EXPECT_EQ(catcher[i], subject[start + i]);\n          EXPECT_EQ(NULL, catcher[num]);\n\n          // Does the resulting array contain the right values?\n          for (int i = 0; i < start; ++i)\n            EXPECT_EQ(field.Mutable(i), subject[i]);\n          for (int i = start; i < field.size(); ++i)\n            EXPECT_EQ(field.Mutable(i), subject[i + num]);\n\n          // Reinstate the cleared elements.\n          EXPECT_EQ(field.ClearedCount(), extra);\n          for (int i = 0; i < extra; ++i)\n            field.Add();\n          EXPECT_EQ(field.ClearedCount(), 0);\n          EXPECT_EQ(field.size(), sz - num + extra);\n\n          // Make sure the extra elements are all there (in some order).\n          for (int i = sz; i < sz + extra; ++i) {\n            int count = 0;\n            for (int j = sz; j < sz + extra; ++j) {\n              if (field.Mutable(j - num) == subject[i])\n                count += 1;\n            }\n            EXPECT_EQ(count, 1);\n          }\n\n          // Release the caught elements.\n          for (int i = 0; i < num; ++i)\n            delete catcher[i];\n        }\n      }\n    }\n  }\n}\n\nTEST(RepeatedPtrField, DeleteSubrange) {\n  // DeleteSubrange is a trivial extension of ExtendSubrange.\n}\n\n// ===================================================================\n\n// Iterator tests stolen from net/proto/proto-array_unittest.\nclass RepeatedFieldIteratorTest : public testing::Test {\n protected:\n  virtual void SetUp() {\n    for (int i = 0; i < 3; ++i) {\n      proto_array_.Add(i);\n    }\n  }\n\n  RepeatedField<int> proto_array_;\n};\n\nTEST_F(RepeatedFieldIteratorTest, Convertible) {\n  RepeatedField<int>::iterator iter = proto_array_.begin();\n  RepeatedField<int>::const_iterator c_iter = iter;\n  RepeatedField<int>::value_type value = *c_iter;\n  EXPECT_EQ(0, value);\n}\n\nTEST_F(RepeatedFieldIteratorTest, MutableIteration) {\n  RepeatedField<int>::iterator iter = proto_array_.begin();\n  EXPECT_EQ(0, *iter);\n  ++iter;\n  EXPECT_EQ(1, *iter++);\n  EXPECT_EQ(2, *iter);\n  ++iter;\n  EXPECT_TRUE(proto_array_.end() == iter);\n\n  EXPECT_EQ(2, *(proto_array_.end() - 1));\n}\n\nTEST_F(RepeatedFieldIteratorTest, ConstIteration) {\n  const RepeatedField<int>& const_proto_array = proto_array_;\n  RepeatedField<int>::const_iterator iter = const_proto_array.begin();\n  EXPECT_EQ(0, *iter);\n  ++iter;\n  EXPECT_EQ(1, *iter++);\n  EXPECT_EQ(2, *iter);\n  ++iter;\n  EXPECT_TRUE(proto_array_.end() == iter);\n  EXPECT_EQ(2, *(proto_array_.end() - 1));\n}\n\nTEST_F(RepeatedFieldIteratorTest, Mutation) {\n  RepeatedField<int>::iterator iter = proto_array_.begin();\n  *iter = 7;\n  EXPECT_EQ(7, proto_array_.Get(0));\n}\n\n// -------------------------------------------------------------------\n\nclass RepeatedPtrFieldIteratorTest : public testing::Test {\n protected:\n  virtual void SetUp() {\n    proto_array_.Add()->assign(\"foo\");\n    proto_array_.Add()->assign(\"bar\");\n    proto_array_.Add()->assign(\"baz\");\n  }\n\n  RepeatedPtrField<string> proto_array_;\n};\n\nTEST_F(RepeatedPtrFieldIteratorTest, Convertible) {\n  RepeatedPtrField<string>::iterator iter = proto_array_.begin();\n  RepeatedPtrField<string>::const_iterator c_iter = iter;\n  RepeatedPtrField<string>::value_type value = *c_iter;\n  EXPECT_EQ(\"foo\", value);\n}\n\nTEST_F(RepeatedPtrFieldIteratorTest, MutableIteration) {\n  RepeatedPtrField<string>::iterator iter = proto_array_.begin();\n  EXPECT_EQ(\"foo\", *iter);\n  ++iter;\n  EXPECT_EQ(\"bar\", *(iter++));\n  EXPECT_EQ(\"baz\", *iter);\n  ++iter;\n  EXPECT_TRUE(proto_array_.end() == iter);\n  EXPECT_EQ(\"baz\", *(--proto_array_.end()));\n}\n\nTEST_F(RepeatedPtrFieldIteratorTest, ConstIteration) {\n  const RepeatedPtrField<string>& const_proto_array = proto_array_;\n  RepeatedPtrField<string>::const_iterator iter = const_proto_array.begin();\n  EXPECT_EQ(\"foo\", *iter);\n  ++iter;\n  EXPECT_EQ(\"bar\", *(iter++));\n  EXPECT_EQ(\"baz\", *iter);\n  ++iter;\n  EXPECT_TRUE(const_proto_array.end() == iter);\n  EXPECT_EQ(\"baz\", *(--const_proto_array.end()));\n}\n\nTEST_F(RepeatedPtrFieldIteratorTest, MutableReverseIteration) {\n  RepeatedPtrField<string>::reverse_iterator iter = proto_array_.rbegin();\n  EXPECT_EQ(\"baz\", *iter);\n  ++iter;\n  EXPECT_EQ(\"bar\", *(iter++));\n  EXPECT_EQ(\"foo\", *iter);\n  ++iter;\n  EXPECT_TRUE(proto_array_.rend() == iter);\n  EXPECT_EQ(\"foo\", *(--proto_array_.rend()));\n}\n\nTEST_F(RepeatedPtrFieldIteratorTest, ConstReverseIteration) {\n  const RepeatedPtrField<string>& const_proto_array = proto_array_;\n  RepeatedPtrField<string>::const_reverse_iterator iter\n      = const_proto_array.rbegin();\n  EXPECT_EQ(\"baz\", *iter);\n  ++iter;\n  EXPECT_EQ(\"bar\", *(iter++));\n  EXPECT_EQ(\"foo\", *iter);\n  ++iter;\n  EXPECT_TRUE(const_proto_array.rend() == iter);\n  EXPECT_EQ(\"foo\", *(--const_proto_array.rend()));\n}\n\nTEST_F(RepeatedPtrFieldIteratorTest, RandomAccess) {\n  RepeatedPtrField<string>::iterator iter = proto_array_.begin();\n  RepeatedPtrField<string>::iterator iter2 = iter;\n  ++iter2;\n  ++iter2;\n  EXPECT_TRUE(iter + 2 == iter2);\n  EXPECT_TRUE(iter == iter2 - 2);\n  EXPECT_EQ(\"baz\", iter[2]);\n  EXPECT_EQ(\"baz\", *(iter + 2));\n  EXPECT_EQ(3, proto_array_.end() - proto_array_.begin());\n}\n\nTEST_F(RepeatedPtrFieldIteratorTest, Comparable) {\n  RepeatedPtrField<string>::const_iterator iter = proto_array_.begin();\n  RepeatedPtrField<string>::const_iterator iter2 = iter + 1;\n  EXPECT_TRUE(iter == iter);\n  EXPECT_TRUE(iter != iter2);\n  EXPECT_TRUE(iter < iter2);\n  EXPECT_TRUE(iter <= iter2);\n  EXPECT_TRUE(iter <= iter);\n  EXPECT_TRUE(iter2 > iter);\n  EXPECT_TRUE(iter2 >= iter);\n  EXPECT_TRUE(iter >= iter);\n}\n\n// Uninitialized iterator does not point to any of the RepeatedPtrField.\nTEST_F(RepeatedPtrFieldIteratorTest, UninitializedIterator) {\n  RepeatedPtrField<string>::iterator iter;\n  EXPECT_TRUE(iter != proto_array_.begin());\n  EXPECT_TRUE(iter != proto_array_.begin() + 1);\n  EXPECT_TRUE(iter != proto_array_.begin() + 2);\n  EXPECT_TRUE(iter != proto_array_.begin() + 3);\n  EXPECT_TRUE(iter != proto_array_.end());\n}\n\nTEST_F(RepeatedPtrFieldIteratorTest, STLAlgorithms_lower_bound) {\n  proto_array_.Clear();\n  proto_array_.Add()->assign(\"a\");\n  proto_array_.Add()->assign(\"c\");\n  proto_array_.Add()->assign(\"d\");\n  proto_array_.Add()->assign(\"n\");\n  proto_array_.Add()->assign(\"p\");\n  proto_array_.Add()->assign(\"x\");\n  proto_array_.Add()->assign(\"y\");\n\n  string v = \"f\";\n  RepeatedPtrField<string>::const_iterator it =\n      std::lower_bound(proto_array_.begin(), proto_array_.end(), v);\n\n  EXPECT_EQ(*it, \"n\");\n  EXPECT_TRUE(it == proto_array_.begin() + 3);\n}\n\nTEST_F(RepeatedPtrFieldIteratorTest, Mutation) {\n  RepeatedPtrField<string>::iterator iter = proto_array_.begin();\n  *iter = \"qux\";\n  EXPECT_EQ(\"qux\", proto_array_.Get(0));\n}\n\n// -------------------------------------------------------------------\n\nclass RepeatedPtrFieldPtrsIteratorTest : public testing::Test {\n protected:\n  virtual void SetUp() {\n    proto_array_.Add()->assign(\"foo\");\n    proto_array_.Add()->assign(\"bar\");\n    proto_array_.Add()->assign(\"baz\");\n    const_proto_array_ = &proto_array_;\n  }\n\n  RepeatedPtrField<string> proto_array_;\n  const RepeatedPtrField<string>* const_proto_array_;\n};\n\nTEST_F(RepeatedPtrFieldPtrsIteratorTest, ConvertiblePtr) {\n  RepeatedPtrField<string>::pointer_iterator iter =\n      proto_array_.pointer_begin();\n  static_cast<void>(iter);\n}\n\nTEST_F(RepeatedPtrFieldPtrsIteratorTest, ConvertibleConstPtr) {\n  RepeatedPtrField<string>::const_pointer_iterator iter =\n      const_proto_array_->pointer_begin();\n  static_cast<void>(iter);\n}\n\nTEST_F(RepeatedPtrFieldPtrsIteratorTest, MutablePtrIteration) {\n  RepeatedPtrField<string>::pointer_iterator iter =\n      proto_array_.pointer_begin();\n  EXPECT_EQ(\"foo\", **iter);\n  ++iter;\n  EXPECT_EQ(\"bar\", **(iter++));\n  EXPECT_EQ(\"baz\", **iter);\n  ++iter;\n  EXPECT_TRUE(proto_array_.pointer_end() == iter);\n  EXPECT_EQ(\"baz\", **(--proto_array_.pointer_end()));\n}\n\nTEST_F(RepeatedPtrFieldPtrsIteratorTest, MutableConstPtrIteration) {\n  RepeatedPtrField<string>::const_pointer_iterator iter =\n      const_proto_array_->pointer_begin();\n  EXPECT_EQ(\"foo\", **iter);\n  ++iter;\n  EXPECT_EQ(\"bar\", **(iter++));\n  EXPECT_EQ(\"baz\", **iter);\n  ++iter;\n  EXPECT_TRUE(const_proto_array_->pointer_end() == iter);\n  EXPECT_EQ(\"baz\", **(--const_proto_array_->pointer_end()));\n}\n\nTEST_F(RepeatedPtrFieldPtrsIteratorTest, RandomPtrAccess) {\n  RepeatedPtrField<string>::pointer_iterator iter =\n      proto_array_.pointer_begin();\n  RepeatedPtrField<string>::pointer_iterator iter2 = iter;\n  ++iter2;\n  ++iter2;\n  EXPECT_TRUE(iter + 2 == iter2);\n  EXPECT_TRUE(iter == iter2 - 2);\n  EXPECT_EQ(\"baz\", *iter[2]);\n  EXPECT_EQ(\"baz\", **(iter + 2));\n  EXPECT_EQ(3, proto_array_.end() - proto_array_.begin());\n}\n\nTEST_F(RepeatedPtrFieldPtrsIteratorTest, RandomConstPtrAccess) {\n  RepeatedPtrField<string>::const_pointer_iterator iter =\n      const_proto_array_->pointer_begin();\n  RepeatedPtrField<string>::const_pointer_iterator iter2 = iter;\n  ++iter2;\n  ++iter2;\n  EXPECT_TRUE(iter + 2 == iter2);\n  EXPECT_TRUE(iter == iter2 - 2);\n  EXPECT_EQ(\"baz\", *iter[2]);\n  EXPECT_EQ(\"baz\", **(iter + 2));\n  EXPECT_EQ(3, const_proto_array_->end() - const_proto_array_->begin());\n}\n\nTEST_F(RepeatedPtrFieldPtrsIteratorTest, ComparablePtr) {\n  RepeatedPtrField<string>::pointer_iterator iter =\n      proto_array_.pointer_begin();\n  RepeatedPtrField<string>::pointer_iterator iter2 = iter + 1;\n  EXPECT_TRUE(iter == iter);\n  EXPECT_TRUE(iter != iter2);\n  EXPECT_TRUE(iter < iter2);\n  EXPECT_TRUE(iter <= iter2);\n  EXPECT_TRUE(iter <= iter);\n  EXPECT_TRUE(iter2 > iter);\n  EXPECT_TRUE(iter2 >= iter);\n  EXPECT_TRUE(iter >= iter);\n}\n\nTEST_F(RepeatedPtrFieldPtrsIteratorTest, ComparableConstPtr) {\n  RepeatedPtrField<string>::const_pointer_iterator iter =\n      const_proto_array_->pointer_begin();\n  RepeatedPtrField<string>::const_pointer_iterator iter2 = iter + 1;\n  EXPECT_TRUE(iter == iter);\n  EXPECT_TRUE(iter != iter2);\n  EXPECT_TRUE(iter < iter2);\n  EXPECT_TRUE(iter <= iter2);\n  EXPECT_TRUE(iter <= iter);\n  EXPECT_TRUE(iter2 > iter);\n  EXPECT_TRUE(iter2 >= iter);\n  EXPECT_TRUE(iter >= iter);\n}\n\n// Uninitialized iterator does not point to any of the RepeatedPtrOverPtrs.\n// Dereferencing an uninitialized iterator crashes the process.\nTEST_F(RepeatedPtrFieldPtrsIteratorTest, UninitializedPtrIterator) {\n  RepeatedPtrField<string>::pointer_iterator iter;\n  EXPECT_TRUE(iter != proto_array_.pointer_begin());\n  EXPECT_TRUE(iter != proto_array_.pointer_begin() + 1);\n  EXPECT_TRUE(iter != proto_array_.pointer_begin() + 2);\n  EXPECT_TRUE(iter != proto_array_.pointer_begin() + 3);\n  EXPECT_TRUE(iter != proto_array_.pointer_end());\n}\n\nTEST_F(RepeatedPtrFieldPtrsIteratorTest, UninitializedConstPtrIterator) {\n  RepeatedPtrField<string>::const_pointer_iterator iter;\n  EXPECT_TRUE(iter != const_proto_array_->pointer_begin());\n  EXPECT_TRUE(iter != const_proto_array_->pointer_begin() + 1);\n  EXPECT_TRUE(iter != const_proto_array_->pointer_begin() + 2);\n  EXPECT_TRUE(iter != const_proto_array_->pointer_begin() + 3);\n  EXPECT_TRUE(iter != const_proto_array_->pointer_end());\n}\n\n// This comparison functor is required by the tests for RepeatedPtrOverPtrs.\n// They operate on strings and need to compare strings as strings in\n// any stl algorithm, even though the iterator returns a pointer to a string\n// - i.e. *iter has type string*.\nstruct StringLessThan {\n  bool operator()(const string* z, const string& y) {\n    return *z < y;\n  }\n  bool operator()(const string* z, const string* y) const { return *z < *y; }\n};\n\nTEST_F(RepeatedPtrFieldPtrsIteratorTest, PtrSTLAlgorithms_lower_bound) {\n  proto_array_.Clear();\n  proto_array_.Add()->assign(\"a\");\n  proto_array_.Add()->assign(\"c\");\n  proto_array_.Add()->assign(\"d\");\n  proto_array_.Add()->assign(\"n\");\n  proto_array_.Add()->assign(\"p\");\n  proto_array_.Add()->assign(\"x\");\n  proto_array_.Add()->assign(\"y\");\n\n  {\n    string v = \"f\";\n    RepeatedPtrField<string>::pointer_iterator it =\n        std::lower_bound(proto_array_.pointer_begin(),\n                         proto_array_.pointer_end(), &v, StringLessThan());\n\n    GOOGLE_CHECK(*it != NULL);\n\n    EXPECT_EQ(**it, \"n\");\n    EXPECT_TRUE(it == proto_array_.pointer_begin() + 3);\n  }\n  {\n    string v = \"f\";\n    RepeatedPtrField<string>::const_pointer_iterator it = std::lower_bound(\n        const_proto_array_->pointer_begin(), const_proto_array_->pointer_end(),\n        &v, StringLessThan());\n\n    GOOGLE_CHECK(*it != NULL);\n\n    EXPECT_EQ(**it, \"n\");\n    EXPECT_TRUE(it == const_proto_array_->pointer_begin() + 3);\n  }\n}\n\nTEST_F(RepeatedPtrFieldPtrsIteratorTest, PtrMutation) {\n  RepeatedPtrField<string>::pointer_iterator iter =\n      proto_array_.pointer_begin();\n  **iter = \"qux\";\n  EXPECT_EQ(\"qux\", proto_array_.Get(0));\n\n  EXPECT_EQ(\"bar\", proto_array_.Get(1));\n  EXPECT_EQ(\"baz\", proto_array_.Get(2));\n  ++iter;\n  delete *iter;\n  *iter = new string(\"a\");\n  ++iter;\n  delete *iter;\n  *iter = new string(\"b\");\n  EXPECT_EQ(\"a\", proto_array_.Get(1));\n  EXPECT_EQ(\"b\", proto_array_.Get(2));\n}\n\nTEST_F(RepeatedPtrFieldPtrsIteratorTest, Sort) {\n  proto_array_.Add()->assign(\"c\");\n  proto_array_.Add()->assign(\"d\");\n  proto_array_.Add()->assign(\"n\");\n  proto_array_.Add()->assign(\"p\");\n  proto_array_.Add()->assign(\"a\");\n  proto_array_.Add()->assign(\"y\");\n  proto_array_.Add()->assign(\"x\");\n  EXPECT_EQ(\"foo\", proto_array_.Get(0));\n  EXPECT_EQ(\"n\", proto_array_.Get(5));\n  EXPECT_EQ(\"x\", proto_array_.Get(9));\n  std::sort(proto_array_.pointer_begin(), proto_array_.pointer_end(),\n            StringLessThan());\n  EXPECT_EQ(\"a\", proto_array_.Get(0));\n  EXPECT_EQ(\"baz\", proto_array_.Get(2));\n  EXPECT_EQ(\"y\", proto_array_.Get(9));\n}\n\n\n// -----------------------------------------------------------------------------\n// Unit-tests for the insert iterators\n// google::protobuf::RepeatedFieldBackInserter,\n// google::protobuf::AllocatedRepeatedPtrFieldBackInserter\n// Ported from util/gtl/proto-array-iterators_unittest.\n\nclass RepeatedFieldInsertionIteratorsTest : public testing::Test {\n protected:\n  std::list<double> halves;\n  std::list<int> fibonacci;\n  std::vector<string> words;\n  typedef TestAllTypes::NestedMessage Nested;\n  Nested nesteds[2];\n  std::vector<Nested*> nested_ptrs;\n  TestAllTypes protobuffer;\n\n  virtual void SetUp() {\n    fibonacci.push_back(1);\n    fibonacci.push_back(1);\n    fibonacci.push_back(2);\n    fibonacci.push_back(3);\n    fibonacci.push_back(5);\n    fibonacci.push_back(8);\n    std::copy(fibonacci.begin(), fibonacci.end(),\n              RepeatedFieldBackInserter(protobuffer.mutable_repeated_int32()));\n\n    halves.push_back(1.0);\n    halves.push_back(0.5);\n    halves.push_back(0.25);\n    halves.push_back(0.125);\n    halves.push_back(0.0625);\n    std::copy(halves.begin(), halves.end(),\n              RepeatedFieldBackInserter(protobuffer.mutable_repeated_double()));\n\n    words.push_back(\"Able\");\n    words.push_back(\"was\");\n    words.push_back(\"I\");\n    words.push_back(\"ere\");\n    words.push_back(\"I\");\n    words.push_back(\"saw\");\n    words.push_back(\"Elba\");\n    std::copy(words.begin(), words.end(),\n              RepeatedFieldBackInserter(protobuffer.mutable_repeated_string()));\n\n    nesteds[0].set_bb(17);\n    nesteds[1].set_bb(4711);\n    std::copy(&nesteds[0], &nesteds[2],\n              RepeatedFieldBackInserter(\n                  protobuffer.mutable_repeated_nested_message()));\n\n    nested_ptrs.push_back(new Nested);\n    nested_ptrs.back()->set_bb(170);\n    nested_ptrs.push_back(new Nested);\n    nested_ptrs.back()->set_bb(47110);\n    std::copy(nested_ptrs.begin(), nested_ptrs.end(),\n              RepeatedFieldBackInserter(\n                  protobuffer.mutable_repeated_nested_message()));\n  }\n\n  virtual void TearDown() {\n    STLDeleteContainerPointers(nested_ptrs.begin(), nested_ptrs.end());\n  }\n};\n\nTEST_F(RepeatedFieldInsertionIteratorsTest, Fibonacci) {\n  EXPECT_TRUE(std::equal(fibonacci.begin(),\n                         fibonacci.end(),\n                         protobuffer.repeated_int32().begin()));\n  EXPECT_TRUE(std::equal(protobuffer.repeated_int32().begin(),\n                         protobuffer.repeated_int32().end(),\n                         fibonacci.begin()));\n}\n\nTEST_F(RepeatedFieldInsertionIteratorsTest, Halves) {\n  EXPECT_TRUE(std::equal(halves.begin(),\n                         halves.end(),\n                         protobuffer.repeated_double().begin()));\n  EXPECT_TRUE(std::equal(protobuffer.repeated_double().begin(),\n                         protobuffer.repeated_double().end(),\n                         halves.begin()));\n}\n\nTEST_F(RepeatedFieldInsertionIteratorsTest, Words) {\n  ASSERT_EQ(words.size(), protobuffer.repeated_string_size());\n  for (int i = 0; i < words.size(); ++i)\n    EXPECT_EQ(words.at(i), protobuffer.repeated_string(i));\n}\n\nTEST_F(RepeatedFieldInsertionIteratorsTest, Words2) {\n  words.clear();\n  words.push_back(\"sing\");\n  words.push_back(\"a\");\n  words.push_back(\"song\");\n  words.push_back(\"of\");\n  words.push_back(\"six\");\n  words.push_back(\"pence\");\n  protobuffer.mutable_repeated_string()->Clear();\n  std::copy(words.begin(), words.end(), RepeatedPtrFieldBackInserter(\n      protobuffer.mutable_repeated_string()));\n  ASSERT_EQ(words.size(), protobuffer.repeated_string_size());\n  for (int i = 0; i < words.size(); ++i)\n    EXPECT_EQ(words.at(i), protobuffer.repeated_string(i));\n}\n\nTEST_F(RepeatedFieldInsertionIteratorsTest, Nesteds) {\n  ASSERT_EQ(protobuffer.repeated_nested_message_size(), 4);\n  EXPECT_EQ(protobuffer.repeated_nested_message(0).bb(), 17);\n  EXPECT_EQ(protobuffer.repeated_nested_message(1).bb(), 4711);\n  EXPECT_EQ(protobuffer.repeated_nested_message(2).bb(), 170);\n  EXPECT_EQ(protobuffer.repeated_nested_message(3).bb(), 47110);\n}\n\nTEST_F(RepeatedFieldInsertionIteratorsTest,\n       AllocatedRepeatedPtrFieldWithStringIntData) {\n  vector<Nested*> data;\n  TestAllTypes goldenproto;\n  for (int i = 0; i < 10; ++i) {\n    Nested* new_data = new Nested;\n    new_data->set_bb(i);\n    data.push_back(new_data);\n\n    new_data = goldenproto.add_repeated_nested_message();\n    new_data->set_bb(i);\n  }\n  TestAllTypes testproto;\n  std::copy(data.begin(), data.end(),\n            AllocatedRepeatedPtrFieldBackInserter(\n                testproto.mutable_repeated_nested_message()));\n  EXPECT_EQ(testproto.DebugString(), goldenproto.DebugString());\n}\n\nTEST_F(RepeatedFieldInsertionIteratorsTest,\n       AllocatedRepeatedPtrFieldWithString) {\n  vector<string*> data;\n  TestAllTypes goldenproto;\n  for (int i = 0; i < 10; ++i) {\n    string* new_data = new string;\n    *new_data = \"name-\" + SimpleItoa(i);\n    data.push_back(new_data);\n\n    new_data = goldenproto.add_repeated_string();\n    *new_data = \"name-\" + SimpleItoa(i);\n  }\n  TestAllTypes testproto;\n  std::copy(data.begin(), data.end(), AllocatedRepeatedPtrFieldBackInserter(\n                                          testproto.mutable_repeated_string()));\n  EXPECT_EQ(testproto.DebugString(), goldenproto.DebugString());\n}\n\nTEST_F(RepeatedFieldInsertionIteratorsTest,\n       UnsafeArenaAllocatedRepeatedPtrFieldWithStringIntData) {\n  vector<Nested*> data;\n  TestAllTypes goldenproto;\n  for (int i = 0; i < 10; ++i) {\n    Nested* new_data = new Nested;\n    new_data->set_bb(i);\n    data.push_back(new_data);\n\n    new_data = goldenproto.add_repeated_nested_message();\n    new_data->set_bb(i);\n  }\n  TestAllTypes testproto;\n  std::copy(data.begin(), data.end(),\n            UnsafeArenaAllocatedRepeatedPtrFieldBackInserter(\n                testproto.mutable_repeated_nested_message()));\n  EXPECT_EQ(testproto.DebugString(), goldenproto.DebugString());\n}\n\nTEST_F(RepeatedFieldInsertionIteratorsTest,\n       UnsafeArenaAllocatedRepeatedPtrFieldWithString) {\n  vector<string*> data;\n  TestAllTypes goldenproto;\n  for (int i = 0; i < 10; ++i) {\n    string* new_data = new string;\n    *new_data = \"name-\" + SimpleItoa(i);\n    data.push_back(new_data);\n\n    new_data = goldenproto.add_repeated_string();\n    *new_data = \"name-\" + SimpleItoa(i);\n  }\n  TestAllTypes testproto;\n  std::copy(data.begin(), data.end(),\n            UnsafeArenaAllocatedRepeatedPtrFieldBackInserter(\n                testproto.mutable_repeated_string()));\n  EXPECT_EQ(testproto.DebugString(), goldenproto.DebugString());\n}\n\n}  // namespace\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/service.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/service.h>\n\nnamespace google {\nnamespace protobuf {\n\nService::~Service() {}\nRpcChannel::~RpcChannel() {}\nRpcController::~RpcController() {}\n\n}  // namespace protobuf\n\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/service.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// DEPRECATED:  This module declares the abstract interfaces underlying proto2\n// RPC services.  These are intented to be independent of any particular RPC\n// implementation, so that proto2 services can be used on top of a variety\n// of implementations.  Starting with version 2.3.0, RPC implementations should\n// not try to build on these, but should instead provide code generator plugins\n// which generate code specific to the particular RPC implementation.  This way\n// the generated code can be more appropriate for the implementation in use\n// and can avoid unnecessary layers of indirection.\n//\n//\n// When you use the protocol compiler to compile a service definition, it\n// generates two classes:  An abstract interface for the service (with\n// methods matching the service definition) and a \"stub\" implementation.\n// A stub is just a type-safe wrapper around an RpcChannel which emulates a\n// local implementation of the service.\n//\n// For example, the service definition:\n//   service MyService {\n//     rpc Foo(MyRequest) returns(MyResponse);\n//   }\n// will generate abstract interface \"MyService\" and class \"MyService::Stub\".\n// You could implement a MyService as follows:\n//   class MyServiceImpl : public MyService {\n//    public:\n//     MyServiceImpl() {}\n//     ~MyServiceImpl() {}\n//\n//     // implements MyService ---------------------------------------\n//\n//     void Foo(google::protobuf::RpcController* controller,\n//              const MyRequest* request,\n//              MyResponse* response,\n//              Closure* done) {\n//       // ... read request and fill in response ...\n//       done->Run();\n//     }\n//   };\n// You would then register an instance of MyServiceImpl with your RPC server\n// implementation.  (How to do that depends on the implementation.)\n//\n// To call a remote MyServiceImpl, first you need an RpcChannel connected to it.\n// How to construct a channel depends, again, on your RPC implementation.\n// Here we use a hypothetical \"MyRpcChannel\" as an example:\n//   MyRpcChannel channel(\"rpc:hostname:1234/myservice\");\n//   MyRpcController controller;\n//   MyServiceImpl::Stub stub(&channel);\n//   FooRequest request;\n//   FooResponse response;\n//\n//   // ... fill in request ...\n//\n//   stub.Foo(&controller, request, &response, NewCallback(HandleResponse));\n//\n// On Thread-Safety:\n//\n// Different RPC implementations may make different guarantees about what\n// threads they may run callbacks on, and what threads the application is\n// allowed to use to call the RPC system.  Portable software should be ready\n// for callbacks to be called on any thread, but should not try to call the\n// RPC system from any thread except for the ones on which it received the\n// callbacks.  Realistically, though, simple software will probably want to\n// use a single-threaded RPC system while high-end software will want to\n// use multiple threads.  RPC implementations should provide multiple\n// choices.\n\n#ifndef GOOGLE_PROTOBUF_SERVICE_H__\n#define GOOGLE_PROTOBUF_SERVICE_H__\n\n#include <string>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/callback.h>\n\nnamespace google {\nnamespace protobuf {\n\n// Defined in this file.\nclass Service;\nclass RpcController;\nclass RpcChannel;\n\n// Defined in other files.\nclass Descriptor;            // descriptor.h\nclass ServiceDescriptor;     // descriptor.h\nclass MethodDescriptor;      // descriptor.h\nclass Message;               // message.h\n\n// Abstract base interface for protocol-buffer-based RPC services.  Services\n// themselves are abstract interfaces (implemented either by servers or as\n// stubs), but they subclass this base interface.  The methods of this\n// interface can be used to call the methods of the Service without knowing\n// its exact type at compile time (analogous to Reflection).\nclass LIBPROTOBUF_EXPORT Service {\n public:\n  inline Service() {}\n  virtual ~Service();\n\n  // When constructing a stub, you may pass STUB_OWNS_CHANNEL as the second\n  // parameter to the constructor to tell it to delete its RpcChannel when\n  // destroyed.\n  enum ChannelOwnership {\n    STUB_OWNS_CHANNEL,\n    STUB_DOESNT_OWN_CHANNEL\n  };\n\n  // Get the ServiceDescriptor describing this service and its methods.\n  virtual const ServiceDescriptor* GetDescriptor() = 0;\n\n  // Call a method of the service specified by MethodDescriptor.  This is\n  // normally implemented as a simple switch() that calls the standard\n  // definitions of the service's methods.\n  //\n  // Preconditions:\n  // * method->service() == GetDescriptor()\n  // * request and response are of the exact same classes as the objects\n  //   returned by GetRequestPrototype(method) and\n  //   GetResponsePrototype(method).\n  // * After the call has started, the request must not be modified and the\n  //   response must not be accessed at all until \"done\" is called.\n  // * \"controller\" is of the correct type for the RPC implementation being\n  //   used by this Service.  For stubs, the \"correct type\" depends on the\n  //   RpcChannel which the stub is using.  Server-side Service\n  //   implementations are expected to accept whatever type of RpcController\n  //   the server-side RPC implementation uses.\n  //\n  // Postconditions:\n  // * \"done\" will be called when the method is complete.  This may be\n  //   before CallMethod() returns or it may be at some point in the future.\n  // * If the RPC succeeded, \"response\" contains the response returned by\n  //   the server.\n  // * If the RPC failed, \"response\"'s contents are undefined.  The\n  //   RpcController can be queried to determine if an error occurred and\n  //   possibly to get more information about the error.\n  virtual void CallMethod(const MethodDescriptor* method,\n                          RpcController* controller,\n                          const Message* request,\n                          Message* response,\n                          Closure* done) = 0;\n\n  // CallMethod() requires that the request and response passed in are of a\n  // particular subclass of Message.  GetRequestPrototype() and\n  // GetResponsePrototype() get the default instances of these required types.\n  // You can then call Message::New() on these instances to construct mutable\n  // objects which you can then pass to CallMethod().\n  //\n  // Example:\n  //   const MethodDescriptor* method =\n  //     service->GetDescriptor()->FindMethodByName(\"Foo\");\n  //   Message* request  = stub->GetRequestPrototype (method)->New();\n  //   Message* response = stub->GetResponsePrototype(method)->New();\n  //   request->ParseFromString(input);\n  //   service->CallMethod(method, *request, response, callback);\n  virtual const Message& GetRequestPrototype(\n    const MethodDescriptor* method) const = 0;\n  virtual const Message& GetResponsePrototype(\n    const MethodDescriptor* method) const = 0;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Service);\n};\n\n// An RpcController mediates a single method call.  The primary purpose of\n// the controller is to provide a way to manipulate settings specific to the\n// RPC implementation and to find out about RPC-level errors.\n//\n// The methods provided by the RpcController interface are intended to be a\n// \"least common denominator\" set of features which we expect all\n// implementations to support.  Specific implementations may provide more\n// advanced features (e.g. deadline propagation).\nclass LIBPROTOBUF_EXPORT RpcController {\n public:\n  inline RpcController() {}\n  virtual ~RpcController();\n\n  // Client-side methods ---------------------------------------------\n  // These calls may be made from the client side only.  Their results\n  // are undefined on the server side (may crash).\n\n  // Resets the RpcController to its initial state so that it may be reused in\n  // a new call.  Must not be called while an RPC is in progress.\n  virtual void Reset() = 0;\n\n  // After a call has finished, returns true if the call failed.  The possible\n  // reasons for failure depend on the RPC implementation.  Failed() must not\n  // be called before a call has finished.  If Failed() returns true, the\n  // contents of the response message are undefined.\n  virtual bool Failed() const = 0;\n\n  // If Failed() is true, returns a human-readable description of the error.\n  virtual string ErrorText() const = 0;\n\n  // Advises the RPC system that the caller desires that the RPC call be\n  // canceled.  The RPC system may cancel it immediately, may wait awhile and\n  // then cancel it, or may not even cancel the call at all.  If the call is\n  // canceled, the \"done\" callback will still be called and the RpcController\n  // will indicate that the call failed at that time.\n  virtual void StartCancel() = 0;\n\n  // Server-side methods ---------------------------------------------\n  // These calls may be made from the server side only.  Their results\n  // are undefined on the client side (may crash).\n\n  // Causes Failed() to return true on the client side.  \"reason\" will be\n  // incorporated into the message returned by ErrorText().  If you find\n  // you need to return machine-readable information about failures, you\n  // should incorporate it into your response protocol buffer and should\n  // NOT call SetFailed().\n  virtual void SetFailed(const string& reason) = 0;\n\n  // If true, indicates that the client canceled the RPC, so the server may\n  // as well give up on replying to it.  The server should still call the\n  // final \"done\" callback.\n  virtual bool IsCanceled() const = 0;\n\n  // Asks that the given callback be called when the RPC is canceled.  The\n  // callback will always be called exactly once.  If the RPC completes without\n  // being canceled, the callback will be called after completion.  If the RPC\n  // has already been canceled when NotifyOnCancel() is called, the callback\n  // will be called immediately.\n  //\n  // NotifyOnCancel() must be called no more than once per request.\n  virtual void NotifyOnCancel(Closure* callback) = 0;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RpcController);\n};\n\n// Abstract interface for an RPC channel.  An RpcChannel represents a\n// communication line to a Service which can be used to call that Service's\n// methods.  The Service may be running on another machine.  Normally, you\n// should not call an RpcChannel directly, but instead construct a stub Service\n// wrapping it.  Example:\n//   RpcChannel* channel = new MyRpcChannel(\"remotehost.example.com:1234\");\n//   MyService* service = new MyService::Stub(channel);\n//   service->MyMethod(request, &response, callback);\nclass LIBPROTOBUF_EXPORT RpcChannel {\n public:\n  inline RpcChannel() {}\n  virtual ~RpcChannel();\n\n  // Call the given method of the remote service.  The signature of this\n  // procedure looks the same as Service::CallMethod(), but the requirements\n  // are less strict in one important way:  the request and response objects\n  // need not be of any specific class as long as their descriptors are\n  // method->input_type() and method->output_type().\n  virtual void CallMethod(const MethodDescriptor* method,\n                          RpcController* controller,\n                          const Message* request,\n                          Message* response,\n                          Closure* done) = 0;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(RpcChannel);\n};\n\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_SERVICE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/source_context.pb.cc",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/source_context.proto\n\n#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION\n#include <google/protobuf/source_context.pb.h>\n\n#include <algorithm>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/port.h>\n#include <google/protobuf/stubs/once.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/generated_message_reflection.h>\n#include <google/protobuf/reflection_ops.h>\n#include <google/protobuf/wire_format.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\n\nnamespace {\n\nconst ::google::protobuf::Descriptor* SourceContext_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  SourceContext_reflection_ = NULL;\n\n}  // namespace\n\n\nvoid protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() {\n  protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();\n  const ::google::protobuf::FileDescriptor* file =\n    ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(\n      \"google/protobuf/source_context.proto\");\n  GOOGLE_CHECK(file != NULL);\n  SourceContext_descriptor_ = file->message_type(0);\n  static const int SourceContext_offsets_[1] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, file_name_),\n  };\n  SourceContext_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      SourceContext_descriptor_,\n      SourceContext::default_instance_,\n      SourceContext_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(SourceContext),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(SourceContext, _is_default_instance_));\n}\n\nnamespace {\n\nGOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);\ninline void protobuf_AssignDescriptorsOnce() {\n  ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,\n                 &protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto);\n}\n\nvoid protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_RegisterTypes(const ::std::string&) {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      SourceContext_descriptor_, &SourceContext::default_instance());\n}\n\n}  // namespace\n\nvoid protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto() {\n  delete SourceContext::default_instance_;\n  delete SourceContext_reflection_;\n}\n\nvoid protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto() {\n  static bool already_here = false;\n  if (already_here) return;\n  already_here = true;\n  GOOGLE_PROTOBUF_VERIFY_VERSION;\n\n  ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(\n    \"\\n$google/protobuf/source_context.proto\\022\\017\"\n    \"google.protobuf\\\"\\\"\\n\\rSourceContext\\022\\021\\n\\tfile\"\n    \"_name\\030\\001 \\001(\\tBU\\n\\023com.google.protobufB\\022Sour\"\n    \"ceContextProtoP\\001\\240\\001\\001\\242\\002\\003GPB\\252\\002\\036Google.Proto\"\n    \"buf.WellKnownTypesb\\006proto3\", 186);\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(\n    \"google/protobuf/source_context.proto\", &protobuf_RegisterTypes);\n  SourceContext::default_instance_ = new SourceContext();\n  SourceContext::default_instance_->InitAsDefaultInstance();\n  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto);\n}\n\n// Force AddDescriptors() to be called at static initialization time.\nstruct StaticDescriptorInitializer_google_2fprotobuf_2fsource_5fcontext_2eproto {\n  StaticDescriptorInitializer_google_2fprotobuf_2fsource_5fcontext_2eproto() {\n    protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();\n  }\n} static_descriptor_initializer_google_2fprotobuf_2fsource_5fcontext_2eproto_;\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int SourceContext::kFileNameFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nSourceContext::SourceContext()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.SourceContext)\n}\n\nvoid SourceContext::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n}\n\nSourceContext::SourceContext(const SourceContext& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.SourceContext)\n}\n\nvoid SourceContext::SharedCtor() {\n    _is_default_instance_ = false;\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  file_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n\nSourceContext::~SourceContext() {\n  // @@protoc_insertion_point(destructor:google.protobuf.SourceContext)\n  SharedDtor();\n}\n\nvoid SourceContext::SharedDtor() {\n  file_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n  }\n}\n\nvoid SourceContext::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* SourceContext::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return SourceContext_descriptor_;\n}\n\nconst SourceContext& SourceContext::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();\n  return *default_instance_;\n}\n\nSourceContext* SourceContext::default_instance_ = NULL;\n\nSourceContext* SourceContext::New(::google::protobuf::Arena* arena) const {\n  SourceContext* n = new SourceContext;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid SourceContext::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.SourceContext)\n  file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n\nbool SourceContext::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.SourceContext)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional string file_name = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_file_name()));\n          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n            this->file_name().data(), this->file_name().length(),\n            ::google::protobuf::internal::WireFormatLite::PARSE,\n            \"google.protobuf.SourceContext.file_name\"));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.SourceContext)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.SourceContext)\n  return false;\n#undef DO_\n}\n\nvoid SourceContext::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.SourceContext)\n  // optional string file_name = 1;\n  if (this->file_name().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->file_name().data(), this->file_name().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.SourceContext.file_name\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      1, this->file_name(), output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.SourceContext)\n}\n\n::google::protobuf::uint8* SourceContext::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.SourceContext)\n  // optional string file_name = 1;\n  if (this->file_name().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->file_name().data(), this->file_name().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.SourceContext.file_name\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        1, this->file_name(), target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.SourceContext)\n  return target;\n}\n\nint SourceContext::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.SourceContext)\n  int total_size = 0;\n\n  // optional string file_name = 1;\n  if (this->file_name().size() > 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::StringSize(\n        this->file_name());\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid SourceContext::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.SourceContext)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const SourceContext* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const SourceContext>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.SourceContext)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.SourceContext)\n    MergeFrom(*source);\n  }\n}\n\nvoid SourceContext::MergeFrom(const SourceContext& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.SourceContext)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from.file_name().size() > 0) {\n\n    file_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.file_name_);\n  }\n}\n\nvoid SourceContext::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.SourceContext)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid SourceContext::CopyFrom(const SourceContext& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.SourceContext)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool SourceContext::IsInitialized() const {\n\n  return true;\n}\n\nvoid SourceContext::Swap(SourceContext* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid SourceContext::InternalSwap(SourceContext* other) {\n  file_name_.Swap(&other->file_name_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata SourceContext::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = SourceContext_descriptor_;\n  metadata.reflection = SourceContext_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// SourceContext\n\n// optional string file_name = 1;\nvoid SourceContext::clear_file_name() {\n  file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n const ::std::string& SourceContext::file_name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.SourceContext.file_name)\n  return file_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void SourceContext::set_file_name(const ::std::string& value) {\n  \n  file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name)\n}\n void SourceContext::set_file_name(const char* value) {\n  \n  file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.SourceContext.file_name)\n}\n void SourceContext::set_file_name(const char* value, size_t size) {\n  \n  file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceContext.file_name)\n}\n ::std::string* SourceContext::mutable_file_name() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.SourceContext.file_name)\n  return file_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* SourceContext::release_file_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.SourceContext.file_name)\n  \n  return file_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void SourceContext::set_allocated_file_name(::std::string* file_name) {\n  if (file_name != NULL) {\n    \n  } else {\n    \n  }\n  file_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), file_name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace protobuf\n}  // namespace google\n\n// @@protoc_insertion_point(global_scope)\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/source_context.pb.h",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/source_context.proto\n\n#ifndef PROTOBUF_google_2fprotobuf_2fsource_5fcontext_2eproto__INCLUDED\n#define PROTOBUF_google_2fprotobuf_2fsource_5fcontext_2eproto__INCLUDED\n\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n\n#if GOOGLE_PROTOBUF_VERSION < 3000000\n#error This file was generated by a newer version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please update\n#error your headers.\n#endif\n#if 3000000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION\n#error This file was generated by an older version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please\n#error regenerate this file with a newer version of protoc.\n#endif\n\n#include <google/protobuf/arena.h>\n#include <google/protobuf/arenastring.h>\n#include <google/protobuf/generated_message_util.h>\n#include <google/protobuf/metadata.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/extension_set.h>\n#include <google/protobuf/unknown_field_set.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\n\n// Internal implementation detail -- do not call these.\nvoid LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();\nvoid protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();\nvoid protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto();\n\nclass SourceContext;\n\n// ===================================================================\n\nclass LIBPROTOBUF_EXPORT SourceContext : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.SourceContext) */ {\n public:\n  SourceContext();\n  virtual ~SourceContext();\n\n  SourceContext(const SourceContext& from);\n\n  inline SourceContext& operator=(const SourceContext& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const SourceContext& default_instance();\n\n  void Swap(SourceContext* other);\n\n  // implements Message ----------------------------------------------\n\n  inline SourceContext* New() const { return New(NULL); }\n\n  SourceContext* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const SourceContext& from);\n  void MergeFrom(const SourceContext& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(SourceContext* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional string file_name = 1;\n  void clear_file_name();\n  static const int kFileNameFieldNumber = 1;\n  const ::std::string& file_name() const;\n  void set_file_name(const ::std::string& value);\n  void set_file_name(const char* value);\n  void set_file_name(const char* value, size_t size);\n  ::std::string* mutable_file_name();\n  ::std::string* release_file_name();\n  void set_allocated_file_name(::std::string* file_name);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.SourceContext)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  bool _is_default_instance_;\n  ::google::protobuf::internal::ArenaStringPtr file_name_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fsource_5fcontext_2eproto();\n\n  void InitAsDefaultInstance();\n  static SourceContext* default_instance_;\n};\n// ===================================================================\n\n\n// ===================================================================\n\n#if !PROTOBUF_INLINE_NOT_IN_HEADERS\n// SourceContext\n\n// optional string file_name = 1;\ninline void SourceContext::clear_file_name() {\n  file_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline const ::std::string& SourceContext::file_name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.SourceContext.file_name)\n  return file_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void SourceContext::set_file_name(const ::std::string& value) {\n  \n  file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.SourceContext.file_name)\n}\ninline void SourceContext::set_file_name(const char* value) {\n  \n  file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.SourceContext.file_name)\n}\ninline void SourceContext::set_file_name(const char* value, size_t size) {\n  \n  file_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.SourceContext.file_name)\n}\ninline ::std::string* SourceContext::mutable_file_name() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.SourceContext.file_name)\n  return file_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* SourceContext::release_file_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.SourceContext.file_name)\n  \n  return file_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void SourceContext::set_allocated_file_name(::std::string* file_name) {\n  if (file_name != NULL) {\n    \n  } else {\n    \n  }\n  file_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), file_name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.SourceContext.file_name)\n}\n\n#endif  // !PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace protobuf\n}  // namespace google\n\n// @@protoc_insertion_point(global_scope)\n\n#endif  // PROTOBUF_google_2fprotobuf_2fsource_5fcontext_2eproto__INCLUDED\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/source_context.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto3\";\n\npackage google.protobuf;\n\noption csharp_namespace = \"Google.Protobuf.WellKnownTypes\";\noption java_package = \"com.google.protobuf\";\noption java_outer_classname = \"SourceContextProto\";\noption java_multiple_files = true;\noption java_generate_equals_and_hash = true;\noption objc_class_prefix = \"GPB\";\n\n// `SourceContext` represents information about the source of a\n// protobuf element, like the file in which it is defined.\nmessage SourceContext {\n  // The path-qualified name of the .proto file that contained the associated\n  // protobuf element.  For example: `\"google/protobuf/source_context.proto\"`.\n  string file_name = 1;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/struct.pb.cc",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/struct.proto\n\n#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION\n#include <google/protobuf/struct.pb.h>\n\n#include <algorithm>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/port.h>\n#include <google/protobuf/stubs/once.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/generated_message_reflection.h>\n#include <google/protobuf/reflection_ops.h>\n#include <google/protobuf/wire_format.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\n\nnamespace {\n\nconst ::google::protobuf::Descriptor* Struct_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  Struct_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* Struct_FieldsEntry_descriptor_ = NULL;\nconst ::google::protobuf::Descriptor* Value_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  Value_reflection_ = NULL;\nstruct ValueOneofInstance {\n  int null_value_;\n  double number_value_;\n  ::google::protobuf::internal::ArenaStringPtr string_value_;\n  bool bool_value_;\n  const ::google::protobuf::Struct* struct_value_;\n  const ::google::protobuf::ListValue* list_value_;\n}* Value_default_oneof_instance_ = NULL;\nconst ::google::protobuf::Descriptor* ListValue_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  ListValue_reflection_ = NULL;\nconst ::google::protobuf::EnumDescriptor* NullValue_descriptor_ = NULL;\n\n}  // namespace\n\n\nvoid protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto() {\n  protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto();\n  const ::google::protobuf::FileDescriptor* file =\n    ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(\n      \"google/protobuf/struct.proto\");\n  GOOGLE_CHECK(file != NULL);\n  Struct_descriptor_ = file->message_type(0);\n  static const int Struct_offsets_[1] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, fields_),\n  };\n  Struct_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      Struct_descriptor_,\n      Struct::default_instance_,\n      Struct_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(Struct),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Struct, _is_default_instance_));\n  Struct_FieldsEntry_descriptor_ = Struct_descriptor_->nested_type(0);\n  Value_descriptor_ = file->message_type(1);\n  static const int Value_offsets_[7] = {\n    PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, null_value_),\n    PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, number_value_),\n    PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, string_value_),\n    PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, bool_value_),\n    PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, struct_value_),\n    PROTO2_GENERATED_DEFAULT_ONEOF_FIELD_OFFSET(Value_default_oneof_instance_, list_value_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, kind_),\n  };\n  Value_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      Value_descriptor_,\n      Value::default_instance_,\n      Value_offsets_,\n      -1,\n      -1,\n      -1,\n      Value_default_oneof_instance_,\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _oneof_case_[0]),\n      sizeof(Value),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Value, _is_default_instance_));\n  ListValue_descriptor_ = file->message_type(2);\n  static const int ListValue_offsets_[1] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, values_),\n  };\n  ListValue_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      ListValue_descriptor_,\n      ListValue::default_instance_,\n      ListValue_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(ListValue),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(ListValue, _is_default_instance_));\n  NullValue_descriptor_ = file->enum_type(0);\n}\n\nnamespace {\n\nGOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);\ninline void protobuf_AssignDescriptorsOnce() {\n  ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,\n                 &protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto);\n}\n\nvoid protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_RegisterTypes(const ::std::string&) {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      Struct_descriptor_, &Struct::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n        Struct_FieldsEntry_descriptor_,\n        ::google::protobuf::internal::MapEntry<\n            ::std::string,\n            ::google::protobuf::Value,\n            ::google::protobuf::internal::WireFormatLite::TYPE_STRING,\n            ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE,\n            0>::CreateDefaultInstance(\n                Struct_FieldsEntry_descriptor_));\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      Value_descriptor_, &Value::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      ListValue_descriptor_, &ListValue::default_instance());\n}\n\n}  // namespace\n\nvoid protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto() {\n  delete Struct::default_instance_;\n  delete Struct_reflection_;\n  delete Value::default_instance_;\n  delete Value_default_oneof_instance_;\n  delete Value_reflection_;\n  delete ListValue::default_instance_;\n  delete ListValue_reflection_;\n}\n\nvoid protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto() {\n  static bool already_here = false;\n  if (already_here) return;\n  already_here = true;\n  GOOGLE_PROTOBUF_VERIFY_VERSION;\n\n  ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(\n    \"\\n\\034google/protobuf/struct.proto\\022\\017google.p\"\n    \"rotobuf\\\"\\204\\001\\n\\006Struct\\0223\\n\\006fields\\030\\001 \\003(\\0132#.goo\"\n    \"gle.protobuf.Struct.FieldsEntry\\032E\\n\\013Field\"\n    \"sEntry\\022\\013\\n\\003key\\030\\001 \\001(\\t\\022%\\n\\005value\\030\\002 \\001(\\0132\\026.goo\"\n    \"gle.protobuf.Value:\\0028\\001\\\"\\352\\001\\n\\005Value\\0220\\n\\nnull\"\n    \"_value\\030\\001 \\001(\\0162\\032.google.protobuf.NullValue\"\n    \"H\\000\\022\\026\\n\\014number_value\\030\\002 \\001(\\001H\\000\\022\\026\\n\\014string_val\"\n    \"ue\\030\\003 \\001(\\tH\\000\\022\\024\\n\\nbool_value\\030\\004 \\001(\\010H\\000\\022/\\n\\014stru\"\n    \"ct_value\\030\\005 \\001(\\0132\\027.google.protobuf.StructH\"\n    \"\\000\\0220\\n\\nlist_value\\030\\006 \\001(\\0132\\032.google.protobuf.\"\n    \"ListValueH\\000B\\006\\n\\004kind\\\"3\\n\\tListValue\\022&\\n\\006valu\"\n    \"es\\030\\001 \\003(\\0132\\026.google.protobuf.Value*\\033\\n\\tNull\"\n    \"Value\\022\\016\\n\\nNULL_VALUE\\020\\000B\\201\\001\\n\\023com.google.pro\"\n    \"tobufB\\013StructProtoP\\001Z1github.com/golang/\"\n    \"protobuf/ptypes/struct;structpb\\240\\001\\001\\242\\002\\003GPB\"\n    \"\\252\\002\\036Google.Protobuf.WellKnownTypesb\\006proto\"\n    \"3\", 641);\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(\n    \"google/protobuf/struct.proto\", &protobuf_RegisterTypes);\n  Struct::default_instance_ = new Struct();\n  Value::default_instance_ = new Value();\n  Value_default_oneof_instance_ = new ValueOneofInstance();\n  ListValue::default_instance_ = new ListValue();\n  Struct::default_instance_->InitAsDefaultInstance();\n  Value::default_instance_->InitAsDefaultInstance();\n  ListValue::default_instance_->InitAsDefaultInstance();\n  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto);\n}\n\n// Force AddDescriptors() to be called at static initialization time.\nstruct StaticDescriptorInitializer_google_2fprotobuf_2fstruct_2eproto {\n  StaticDescriptorInitializer_google_2fprotobuf_2fstruct_2eproto() {\n    protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto();\n  }\n} static_descriptor_initializer_google_2fprotobuf_2fstruct_2eproto_;\nconst ::google::protobuf::EnumDescriptor* NullValue_descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return NullValue_descriptor_;\n}\nbool NullValue_IsValid(int value) {\n  switch(value) {\n    case 0:\n      return true;\n    default:\n      return false;\n  }\n}\n\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int Struct::kFieldsFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nStruct::Struct()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.Struct)\n}\n\nvoid Struct::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n}\n\nStruct::Struct(const Struct& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.Struct)\n}\n\nvoid Struct::SharedCtor() {\n    _is_default_instance_ = false;\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  fields_.SetAssignDescriptorCallback(\n      protobuf_AssignDescriptorsOnce);\n  fields_.SetEntryDescriptor(\n      &::google::protobuf::Struct_FieldsEntry_descriptor_);\n}\n\nStruct::~Struct() {\n  // @@protoc_insertion_point(destructor:google.protobuf.Struct)\n  SharedDtor();\n}\n\nvoid Struct::SharedDtor() {\n  if (this != default_instance_) {\n  }\n}\n\nvoid Struct::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* Struct::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return Struct_descriptor_;\n}\n\nconst Struct& Struct::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto();\n  return *default_instance_;\n}\n\nStruct* Struct::default_instance_ = NULL;\n\nStruct* Struct::New(::google::protobuf::Arena* arena) const {\n  Struct* n = new Struct;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid Struct::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.Struct)\n  fields_.Clear();\n}\n\nbool Struct::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.Struct)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // map<string, .google.protobuf.Value> fields = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_fields:\n          Struct_FieldsEntry::Parser< ::google::protobuf::internal::MapField<\n              ::std::string, ::google::protobuf::Value,\n              ::google::protobuf::internal::WireFormatLite::TYPE_STRING,\n              ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE,\n              0 >,\n            ::google::protobuf::Map< ::std::string, ::google::protobuf::Value > > parser(&fields_);\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\n              input, &parser));\n          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n            parser.key().data(), parser.key().length(),\n            ::google::protobuf::internal::WireFormatLite::PARSE,\n            \"google.protobuf.Struct.FieldsEntry.key\"));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(10)) goto parse_loop_fields;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.Struct)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.Struct)\n  return false;\n#undef DO_\n}\n\nvoid Struct::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.Struct)\n  // map<string, .google.protobuf.Value> fields = 1;\n  if (!this->fields().empty()) {\n    typedef ::google::protobuf::Map< ::std::string, ::google::protobuf::Value >::const_pointer\n        ConstPtr;\n    typedef ConstPtr SortItem;\n    typedef ::google::protobuf::internal::CompareByDerefFirst<SortItem> Less;\n    struct Utf8Check {\n      static void Check(ConstPtr p) {\n        ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n          p->first.data(), p->first.length(),\n          ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n          \"google.protobuf.Struct.FieldsEntry.key\");\n      }\n    };\n\n    if (output->IsSerializationDeterminstic() &&\n        this->fields().size() > 1) {\n      ::google::protobuf::scoped_array<SortItem> items(\n          new SortItem[this->fields().size()]);\n      typedef ::google::protobuf::Map< ::std::string, ::google::protobuf::Value >::size_type size_type;\n      size_type n = 0;\n      for (::google::protobuf::Map< ::std::string, ::google::protobuf::Value >::const_iterator\n          it = this->fields().begin();\n          it != this->fields().end(); ++it, ++n) {\n        items[n] = SortItem(&*it);\n      }\n      ::std::sort(&items[0], &items[n], Less());\n      ::google::protobuf::scoped_ptr<Struct_FieldsEntry> entry;\n      for (size_type i = 0; i < n; i++) {\n        entry.reset(fields_.NewEntryWrapper(\n            items[i]->first, items[i]->second));\n        ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n            1, *entry, output);\n        Utf8Check::Check(items[i]);\n      }\n    } else {\n      ::google::protobuf::scoped_ptr<Struct_FieldsEntry> entry;\n      for (::google::protobuf::Map< ::std::string, ::google::protobuf::Value >::const_iterator\n          it = this->fields().begin();\n          it != this->fields().end(); ++it) {\n        entry.reset(fields_.NewEntryWrapper(\n            it->first, it->second));\n        ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n            1, *entry, output);\n        Utf8Check::Check(&*it);\n      }\n    }\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.Struct)\n}\n\n::google::protobuf::uint8* Struct::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Struct)\n  // map<string, .google.protobuf.Value> fields = 1;\n  if (!this->fields().empty()) {\n    typedef ::google::protobuf::Map< ::std::string, ::google::protobuf::Value >::const_pointer\n        ConstPtr;\n    typedef ConstPtr SortItem;\n    typedef ::google::protobuf::internal::CompareByDerefFirst<SortItem> Less;\n    struct Utf8Check {\n      static void Check(ConstPtr p) {\n        ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n          p->first.data(), p->first.length(),\n          ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n          \"google.protobuf.Struct.FieldsEntry.key\");\n      }\n    };\n\n    if (deterministic &&\n        this->fields().size() > 1) {\n      ::google::protobuf::scoped_array<SortItem> items(\n          new SortItem[this->fields().size()]);\n      typedef ::google::protobuf::Map< ::std::string, ::google::protobuf::Value >::size_type size_type;\n      size_type n = 0;\n      for (::google::protobuf::Map< ::std::string, ::google::protobuf::Value >::const_iterator\n          it = this->fields().begin();\n          it != this->fields().end(); ++it, ++n) {\n        items[n] = SortItem(&*it);\n      }\n      ::std::sort(&items[0], &items[n], Less());\n      ::google::protobuf::scoped_ptr<Struct_FieldsEntry> entry;\n      for (size_type i = 0; i < n; i++) {\n        entry.reset(fields_.NewEntryWrapper(\n            items[i]->first, items[i]->second));\n        target = ::google::protobuf::internal::WireFormatLite::\n                   InternalWriteMessageNoVirtualToArray(\n                       1, *entry, deterministic, target);\n;\n        Utf8Check::Check(items[i]);\n      }\n    } else {\n      ::google::protobuf::scoped_ptr<Struct_FieldsEntry> entry;\n      for (::google::protobuf::Map< ::std::string, ::google::protobuf::Value >::const_iterator\n          it = this->fields().begin();\n          it != this->fields().end(); ++it) {\n        entry.reset(fields_.NewEntryWrapper(\n            it->first, it->second));\n        target = ::google::protobuf::internal::WireFormatLite::\n                   InternalWriteMessageNoVirtualToArray(\n                       1, *entry, deterministic, target);\n;\n        Utf8Check::Check(&*it);\n      }\n    }\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Struct)\n  return target;\n}\n\nint Struct::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Struct)\n  int total_size = 0;\n\n  // map<string, .google.protobuf.Value> fields = 1;\n  total_size += 1 * this->fields_size();\n  {\n    ::google::protobuf::scoped_ptr<Struct_FieldsEntry> entry;\n    for (::google::protobuf::Map< ::std::string, ::google::protobuf::Value >::const_iterator\n        it = this->fields().begin();\n        it != this->fields().end(); ++it) {\n      entry.reset(fields_.NewEntryWrapper(it->first, it->second));\n      total_size += ::google::protobuf::internal::WireFormatLite::\n          MessageSizeNoVirtual(*entry);\n    }\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid Struct::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Struct)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const Struct* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const Struct>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.Struct)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Struct)\n    MergeFrom(*source);\n  }\n}\n\nvoid Struct::MergeFrom(const Struct& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Struct)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  fields_.MergeFrom(from.fields_);\n}\n\nvoid Struct::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.Struct)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid Struct::CopyFrom(const Struct& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Struct)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool Struct::IsInitialized() const {\n\n  return true;\n}\n\nvoid Struct::Swap(Struct* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid Struct::InternalSwap(Struct* other) {\n  fields_.Swap(&other->fields_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata Struct::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = Struct_descriptor_;\n  metadata.reflection = Struct_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// Struct\n\n// map<string, .google.protobuf.Value> fields = 1;\nint Struct::fields_size() const {\n  return fields_.size();\n}\nvoid Struct::clear_fields() {\n  fields_.Clear();\n}\n const ::google::protobuf::Map< ::std::string, ::google::protobuf::Value >&\nStruct::fields() const {\n  // @@protoc_insertion_point(field_map:google.protobuf.Struct.fields)\n  return fields_.GetMap();\n}\n ::google::protobuf::Map< ::std::string, ::google::protobuf::Value >*\nStruct::mutable_fields() {\n  // @@protoc_insertion_point(field_mutable_map:google.protobuf.Struct.fields)\n  return fields_.MutableMap();\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int Value::kNullValueFieldNumber;\nconst int Value::kNumberValueFieldNumber;\nconst int Value::kStringValueFieldNumber;\nconst int Value::kBoolValueFieldNumber;\nconst int Value::kStructValueFieldNumber;\nconst int Value::kListValueFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nValue::Value()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.Value)\n}\n\nvoid Value::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n  Value_default_oneof_instance_->null_value_ = 0;\n  Value_default_oneof_instance_->number_value_ = 0;\n  Value_default_oneof_instance_->string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  Value_default_oneof_instance_->bool_value_ = false;\n  Value_default_oneof_instance_->struct_value_ = const_cast< ::google::protobuf::Struct*>(&::google::protobuf::Struct::default_instance());\n  Value_default_oneof_instance_->list_value_ = const_cast< ::google::protobuf::ListValue*>(&::google::protobuf::ListValue::default_instance());\n}\n\nValue::Value(const Value& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.Value)\n}\n\nvoid Value::SharedCtor() {\n    _is_default_instance_ = false;\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  clear_has_kind();\n}\n\nValue::~Value() {\n  // @@protoc_insertion_point(destructor:google.protobuf.Value)\n  SharedDtor();\n}\n\nvoid Value::SharedDtor() {\n  if (has_kind()) {\n    clear_kind();\n  }\n  if (this != default_instance_) {\n  }\n}\n\nvoid Value::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* Value::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return Value_descriptor_;\n}\n\nconst Value& Value::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto();\n  return *default_instance_;\n}\n\nValue* Value::default_instance_ = NULL;\n\nValue* Value::New(::google::protobuf::Arena* arena) const {\n  Value* n = new Value;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid Value::clear_kind() {\n// @@protoc_insertion_point(one_of_clear_start:google.protobuf.Value)\n  switch(kind_case()) {\n    case kNullValue: {\n      // No need to clear\n      break;\n    }\n    case kNumberValue: {\n      // No need to clear\n      break;\n    }\n    case kStringValue: {\n      kind_.string_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n      break;\n    }\n    case kBoolValue: {\n      // No need to clear\n      break;\n    }\n    case kStructValue: {\n      delete kind_.struct_value_;\n      break;\n    }\n    case kListValue: {\n      delete kind_.list_value_;\n      break;\n    }\n    case KIND_NOT_SET: {\n      break;\n    }\n  }\n  _oneof_case_[0] = KIND_NOT_SET;\n}\n\n\nvoid Value::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.Value)\n  clear_kind();\n}\n\nbool Value::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.Value)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional .google.protobuf.NullValue null_value = 1;\n      case 1: {\n        if (tag == 8) {\n          int value;\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n                 input, &value)));\n          set_null_value(static_cast< ::google::protobuf::NullValue >(value));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(17)) goto parse_number_value;\n        break;\n      }\n\n      // optional double number_value = 2;\n      case 2: {\n        if (tag == 17) {\n         parse_number_value:\n          clear_kind();\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>(\n                 input, &kind_.number_value_)));\n          set_has_number_value();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(26)) goto parse_string_value;\n        break;\n      }\n\n      // optional string string_value = 3;\n      case 3: {\n        if (tag == 26) {\n         parse_string_value:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_string_value()));\n          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n            this->string_value().data(), this->string_value().length(),\n            ::google::protobuf::internal::WireFormatLite::PARSE,\n            \"google.protobuf.Value.string_value\"));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(32)) goto parse_bool_value;\n        break;\n      }\n\n      // optional bool bool_value = 4;\n      case 4: {\n        if (tag == 32) {\n         parse_bool_value:\n          clear_kind();\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &kind_.bool_value_)));\n          set_has_bool_value();\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(42)) goto parse_struct_value;\n        break;\n      }\n\n      // optional .google.protobuf.Struct struct_value = 5;\n      case 5: {\n        if (tag == 42) {\n         parse_struct_value:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\n               input, mutable_struct_value()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(50)) goto parse_list_value;\n        break;\n      }\n\n      // optional .google.protobuf.ListValue list_value = 6;\n      case 6: {\n        if (tag == 50) {\n         parse_list_value:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\n               input, mutable_list_value()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.Value)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.Value)\n  return false;\n#undef DO_\n}\n\nvoid Value::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.Value)\n  // optional .google.protobuf.NullValue null_value = 1;\n  if (has_null_value()) {\n    ::google::protobuf::internal::WireFormatLite::WriteEnum(\n      1, this->null_value(), output);\n  }\n\n  // optional double number_value = 2;\n  if (has_number_value()) {\n    ::google::protobuf::internal::WireFormatLite::WriteDouble(2, this->number_value(), output);\n  }\n\n  // optional string string_value = 3;\n  if (has_string_value()) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->string_value().data(), this->string_value().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Value.string_value\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      3, this->string_value(), output);\n  }\n\n  // optional bool bool_value = 4;\n  if (has_bool_value()) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(4, this->bool_value(), output);\n  }\n\n  // optional .google.protobuf.Struct struct_value = 5;\n  if (has_struct_value()) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      5, *kind_.struct_value_, output);\n  }\n\n  // optional .google.protobuf.ListValue list_value = 6;\n  if (has_list_value()) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      6, *kind_.list_value_, output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.Value)\n}\n\n::google::protobuf::uint8* Value::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Value)\n  // optional .google.protobuf.NullValue null_value = 1;\n  if (has_null_value()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(\n      1, this->null_value(), target);\n  }\n\n  // optional double number_value = 2;\n  if (has_number_value()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(2, this->number_value(), target);\n  }\n\n  // optional string string_value = 3;\n  if (has_string_value()) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->string_value().data(), this->string_value().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Value.string_value\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        3, this->string_value(), target);\n  }\n\n  // optional bool bool_value = 4;\n  if (has_bool_value()) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(4, this->bool_value(), target);\n  }\n\n  // optional .google.protobuf.Struct struct_value = 5;\n  if (has_struct_value()) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        5, *kind_.struct_value_, false, target);\n  }\n\n  // optional .google.protobuf.ListValue list_value = 6;\n  if (has_list_value()) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        6, *kind_.list_value_, false, target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Value)\n  return target;\n}\n\nint Value::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Value)\n  int total_size = 0;\n\n  switch (kind_case()) {\n    // optional .google.protobuf.NullValue null_value = 1;\n    case kNullValue: {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::EnumSize(this->null_value());\n      break;\n    }\n    // optional double number_value = 2;\n    case kNumberValue: {\n      total_size += 1 + 8;\n      break;\n    }\n    // optional string string_value = 3;\n    case kStringValue: {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::StringSize(\n          this->string_value());\n      break;\n    }\n    // optional bool bool_value = 4;\n    case kBoolValue: {\n      total_size += 1 + 1;\n      break;\n    }\n    // optional .google.protobuf.Struct struct_value = 5;\n    case kStructValue: {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n          *kind_.struct_value_);\n      break;\n    }\n    // optional .google.protobuf.ListValue list_value = 6;\n    case kListValue: {\n      total_size += 1 +\n        ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n          *kind_.list_value_);\n      break;\n    }\n    case KIND_NOT_SET: {\n      break;\n    }\n  }\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid Value::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Value)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const Value* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const Value>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.Value)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Value)\n    MergeFrom(*source);\n  }\n}\n\nvoid Value::MergeFrom(const Value& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Value)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  switch (from.kind_case()) {\n    case kNullValue: {\n      set_null_value(from.null_value());\n      break;\n    }\n    case kNumberValue: {\n      set_number_value(from.number_value());\n      break;\n    }\n    case kStringValue: {\n      set_string_value(from.string_value());\n      break;\n    }\n    case kBoolValue: {\n      set_bool_value(from.bool_value());\n      break;\n    }\n    case kStructValue: {\n      mutable_struct_value()->::google::protobuf::Struct::MergeFrom(from.struct_value());\n      break;\n    }\n    case kListValue: {\n      mutable_list_value()->::google::protobuf::ListValue::MergeFrom(from.list_value());\n      break;\n    }\n    case KIND_NOT_SET: {\n      break;\n    }\n  }\n}\n\nvoid Value::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.Value)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid Value::CopyFrom(const Value& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Value)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool Value::IsInitialized() const {\n\n  return true;\n}\n\nvoid Value::Swap(Value* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid Value::InternalSwap(Value* other) {\n  std::swap(kind_, other->kind_);\n  std::swap(_oneof_case_[0], other->_oneof_case_[0]);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata Value::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = Value_descriptor_;\n  metadata.reflection = Value_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// Value\n\n// optional .google.protobuf.NullValue null_value = 1;\nbool Value::has_null_value() const {\n  return kind_case() == kNullValue;\n}\nvoid Value::set_has_null_value() {\n  _oneof_case_[0] = kNullValue;\n}\nvoid Value::clear_null_value() {\n  if (has_null_value()) {\n    kind_.null_value_ = 0;\n    clear_has_kind();\n  }\n}\n ::google::protobuf::NullValue Value::null_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Value.null_value)\n  if (has_null_value()) {\n    return static_cast< ::google::protobuf::NullValue >(kind_.null_value_);\n  }\n  return static_cast< ::google::protobuf::NullValue >(0);\n}\n void Value::set_null_value(::google::protobuf::NullValue value) {\n  if (!has_null_value()) {\n    clear_kind();\n    set_has_null_value();\n  }\n  kind_.null_value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Value.null_value)\n}\n\n// optional double number_value = 2;\nbool Value::has_number_value() const {\n  return kind_case() == kNumberValue;\n}\nvoid Value::set_has_number_value() {\n  _oneof_case_[0] = kNumberValue;\n}\nvoid Value::clear_number_value() {\n  if (has_number_value()) {\n    kind_.number_value_ = 0;\n    clear_has_kind();\n  }\n}\n double Value::number_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Value.number_value)\n  if (has_number_value()) {\n    return kind_.number_value_;\n  }\n  return 0;\n}\n void Value::set_number_value(double value) {\n  if (!has_number_value()) {\n    clear_kind();\n    set_has_number_value();\n  }\n  kind_.number_value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Value.number_value)\n}\n\n// optional string string_value = 3;\nbool Value::has_string_value() const {\n  return kind_case() == kStringValue;\n}\nvoid Value::set_has_string_value() {\n  _oneof_case_[0] = kStringValue;\n}\nvoid Value::clear_string_value() {\n  if (has_string_value()) {\n    kind_.string_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    clear_has_kind();\n  }\n}\n const ::std::string& Value::string_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Value.string_value)\n  if (has_string_value()) {\n    return kind_.string_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  }\n  return *&::google::protobuf::internal::GetEmptyStringAlreadyInited();\n}\n void Value::set_string_value(const ::std::string& value) {\n  // @@protoc_insertion_point(field_set:google.protobuf.Value.string_value)\n  if (!has_string_value()) {\n    clear_kind();\n    set_has_string_value();\n    kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  }\n  kind_.string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Value.string_value)\n}\n void Value::set_string_value(const char* value) {\n  if (!has_string_value()) {\n    clear_kind();\n    set_has_string_value();\n    kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  }\n  kind_.string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Value.string_value)\n}\n void Value::set_string_value(const char* value, size_t size) {\n  if (!has_string_value()) {\n    clear_kind();\n    set_has_string_value();\n    kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  }\n  kind_.string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(\n      reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Value.string_value)\n}\n ::std::string* Value::mutable_string_value() {\n  if (!has_string_value()) {\n    clear_kind();\n    set_has_string_value();\n    kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Value.string_value)\n  return kind_.string_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* Value::release_string_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Value.string_value)\n  if (has_string_value()) {\n    clear_has_kind();\n    return kind_.string_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  } else {\n    return NULL;\n  }\n}\n void Value::set_allocated_string_value(::std::string* string_value) {\n  if (!has_string_value()) {\n    kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  }\n  clear_kind();\n  if (string_value != NULL) {\n    set_has_string_value();\n    kind_.string_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n        string_value);\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.string_value)\n}\n\n// optional bool bool_value = 4;\nbool Value::has_bool_value() const {\n  return kind_case() == kBoolValue;\n}\nvoid Value::set_has_bool_value() {\n  _oneof_case_[0] = kBoolValue;\n}\nvoid Value::clear_bool_value() {\n  if (has_bool_value()) {\n    kind_.bool_value_ = false;\n    clear_has_kind();\n  }\n}\n bool Value::bool_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Value.bool_value)\n  if (has_bool_value()) {\n    return kind_.bool_value_;\n  }\n  return false;\n}\n void Value::set_bool_value(bool value) {\n  if (!has_bool_value()) {\n    clear_kind();\n    set_has_bool_value();\n  }\n  kind_.bool_value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Value.bool_value)\n}\n\n// optional .google.protobuf.Struct struct_value = 5;\nbool Value::has_struct_value() const {\n  return kind_case() == kStructValue;\n}\nvoid Value::set_has_struct_value() {\n  _oneof_case_[0] = kStructValue;\n}\nvoid Value::clear_struct_value() {\n  if (has_struct_value()) {\n    delete kind_.struct_value_;\n    clear_has_kind();\n  }\n}\n const ::google::protobuf::Struct& Value::struct_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Value.struct_value)\n  return has_struct_value()\n      ? *kind_.struct_value_\n      : ::google::protobuf::Struct::default_instance();\n}\n::google::protobuf::Struct* Value::mutable_struct_value() {\n  if (!has_struct_value()) {\n    clear_kind();\n    set_has_struct_value();\n    kind_.struct_value_ = new ::google::protobuf::Struct;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Value.struct_value)\n  return kind_.struct_value_;\n}\n::google::protobuf::Struct* Value::release_struct_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Value.struct_value)\n  if (has_struct_value()) {\n    clear_has_kind();\n    ::google::protobuf::Struct* temp = kind_.struct_value_;\n    kind_.struct_value_ = NULL;\n    return temp;\n  } else {\n    return NULL;\n  }\n}\nvoid Value::set_allocated_struct_value(::google::protobuf::Struct* struct_value) {\n  clear_kind();\n  if (struct_value) {\n    set_has_struct_value();\n    kind_.struct_value_ = struct_value;\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.struct_value)\n}\n\n// optional .google.protobuf.ListValue list_value = 6;\nbool Value::has_list_value() const {\n  return kind_case() == kListValue;\n}\nvoid Value::set_has_list_value() {\n  _oneof_case_[0] = kListValue;\n}\nvoid Value::clear_list_value() {\n  if (has_list_value()) {\n    delete kind_.list_value_;\n    clear_has_kind();\n  }\n}\n const ::google::protobuf::ListValue& Value::list_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Value.list_value)\n  return has_list_value()\n      ? *kind_.list_value_\n      : ::google::protobuf::ListValue::default_instance();\n}\n::google::protobuf::ListValue* Value::mutable_list_value() {\n  if (!has_list_value()) {\n    clear_kind();\n    set_has_list_value();\n    kind_.list_value_ = new ::google::protobuf::ListValue;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Value.list_value)\n  return kind_.list_value_;\n}\n::google::protobuf::ListValue* Value::release_list_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Value.list_value)\n  if (has_list_value()) {\n    clear_has_kind();\n    ::google::protobuf::ListValue* temp = kind_.list_value_;\n    kind_.list_value_ = NULL;\n    return temp;\n  } else {\n    return NULL;\n  }\n}\nvoid Value::set_allocated_list_value(::google::protobuf::ListValue* list_value) {\n  clear_kind();\n  if (list_value) {\n    set_has_list_value();\n    kind_.list_value_ = list_value;\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.list_value)\n}\n\nbool Value::has_kind() const {\n  return kind_case() != KIND_NOT_SET;\n}\nvoid Value::clear_has_kind() {\n  _oneof_case_[0] = KIND_NOT_SET;\n}\nValue::KindCase Value::kind_case() const {\n  return Value::KindCase(_oneof_case_[0]);\n}\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int ListValue::kValuesFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nListValue::ListValue()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.ListValue)\n}\n\nvoid ListValue::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n}\n\nListValue::ListValue(const ListValue& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.ListValue)\n}\n\nvoid ListValue::SharedCtor() {\n    _is_default_instance_ = false;\n  _cached_size_ = 0;\n}\n\nListValue::~ListValue() {\n  // @@protoc_insertion_point(destructor:google.protobuf.ListValue)\n  SharedDtor();\n}\n\nvoid ListValue::SharedDtor() {\n  if (this != default_instance_) {\n  }\n}\n\nvoid ListValue::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* ListValue::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return ListValue_descriptor_;\n}\n\nconst ListValue& ListValue::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto();\n  return *default_instance_;\n}\n\nListValue* ListValue::default_instance_ = NULL;\n\nListValue* ListValue::New(::google::protobuf::Arena* arena) const {\n  ListValue* n = new ListValue;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid ListValue::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.ListValue)\n  values_.Clear();\n}\n\nbool ListValue::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.ListValue)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // repeated .google.protobuf.Value values = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_values:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_values()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(10)) goto parse_loop_values;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.ListValue)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.ListValue)\n  return false;\n#undef DO_\n}\n\nvoid ListValue::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.ListValue)\n  // repeated .google.protobuf.Value values = 1;\n  for (unsigned int i = 0, n = this->values_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      1, this->values(i), output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.ListValue)\n}\n\n::google::protobuf::uint8* ListValue::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.ListValue)\n  // repeated .google.protobuf.Value values = 1;\n  for (unsigned int i = 0, n = this->values_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        1, this->values(i), false, target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.ListValue)\n  return target;\n}\n\nint ListValue::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.ListValue)\n  int total_size = 0;\n\n  // repeated .google.protobuf.Value values = 1;\n  total_size += 1 * this->values_size();\n  for (int i = 0; i < this->values_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->values(i));\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid ListValue::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.ListValue)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const ListValue* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const ListValue>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.ListValue)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.ListValue)\n    MergeFrom(*source);\n  }\n}\n\nvoid ListValue::MergeFrom(const ListValue& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.ListValue)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  values_.MergeFrom(from.values_);\n}\n\nvoid ListValue::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.ListValue)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid ListValue::CopyFrom(const ListValue& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.ListValue)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool ListValue::IsInitialized() const {\n\n  return true;\n}\n\nvoid ListValue::Swap(ListValue* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid ListValue::InternalSwap(ListValue* other) {\n  values_.UnsafeArenaSwap(&other->values_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata ListValue::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = ListValue_descriptor_;\n  metadata.reflection = ListValue_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// ListValue\n\n// repeated .google.protobuf.Value values = 1;\nint ListValue::values_size() const {\n  return values_.size();\n}\nvoid ListValue::clear_values() {\n  values_.Clear();\n}\nconst ::google::protobuf::Value& ListValue::values(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.ListValue.values)\n  return values_.Get(index);\n}\n::google::protobuf::Value* ListValue::mutable_values(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.ListValue.values)\n  return values_.Mutable(index);\n}\n::google::protobuf::Value* ListValue::add_values() {\n  // @@protoc_insertion_point(field_add:google.protobuf.ListValue.values)\n  return values_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::Value >*\nListValue::mutable_values() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.ListValue.values)\n  return &values_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::Value >&\nListValue::values() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.ListValue.values)\n  return values_;\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace protobuf\n}  // namespace google\n\n// @@protoc_insertion_point(global_scope)\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/struct.pb.h",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/struct.proto\n\n#ifndef PROTOBUF_google_2fprotobuf_2fstruct_2eproto__INCLUDED\n#define PROTOBUF_google_2fprotobuf_2fstruct_2eproto__INCLUDED\n\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n\n#if GOOGLE_PROTOBUF_VERSION < 3000000\n#error This file was generated by a newer version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please update\n#error your headers.\n#endif\n#if 3000000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION\n#error This file was generated by an older version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please\n#error regenerate this file with a newer version of protoc.\n#endif\n\n#include <google/protobuf/arena.h>\n#include <google/protobuf/arenastring.h>\n#include <google/protobuf/generated_message_util.h>\n#include <google/protobuf/metadata.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/extension_set.h>\n#include <google/protobuf/map.h>\n#include <google/protobuf/map_field_inl.h>\n#include <google/protobuf/generated_enum_reflection.h>\n#include <google/protobuf/unknown_field_set.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\n\n// Internal implementation detail -- do not call these.\nvoid LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto();\nvoid protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto();\nvoid protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto();\n\nclass ListValue;\nclass Struct;\nclass Value;\n\nenum NullValue {\n  NULL_VALUE = 0,\n  NullValue_INT_MIN_SENTINEL_DO_NOT_USE_ = ::google::protobuf::kint32min,\n  NullValue_INT_MAX_SENTINEL_DO_NOT_USE_ = ::google::protobuf::kint32max\n};\nLIBPROTOBUF_EXPORT bool NullValue_IsValid(int value);\nconst NullValue NullValue_MIN = NULL_VALUE;\nconst NullValue NullValue_MAX = NULL_VALUE;\nconst int NullValue_ARRAYSIZE = NullValue_MAX + 1;\n\nLIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* NullValue_descriptor();\ninline const ::std::string& NullValue_Name(NullValue value) {\n  return ::google::protobuf::internal::NameOfEnum(\n    NullValue_descriptor(), value);\n}\ninline bool NullValue_Parse(\n    const ::std::string& name, NullValue* value) {\n  return ::google::protobuf::internal::ParseNamedEnum<NullValue>(\n    NullValue_descriptor(), name, value);\n}\n// ===================================================================\n\nclass LIBPROTOBUF_EXPORT Struct : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Struct) */ {\n public:\n  Struct();\n  virtual ~Struct();\n\n  Struct(const Struct& from);\n\n  inline Struct& operator=(const Struct& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const Struct& default_instance();\n\n  void Swap(Struct* other);\n\n  // implements Message ----------------------------------------------\n\n  inline Struct* New() const { return New(NULL); }\n\n  Struct* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const Struct& from);\n  void MergeFrom(const Struct& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(Struct* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n\n  // accessors -------------------------------------------------------\n\n  // map<string, .google.protobuf.Value> fields = 1;\n  int fields_size() const;\n  void clear_fields();\n  static const int kFieldsFieldNumber = 1;\n  const ::google::protobuf::Map< ::std::string, ::google::protobuf::Value >&\n      fields() const;\n  ::google::protobuf::Map< ::std::string, ::google::protobuf::Value >*\n      mutable_fields();\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.Struct)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  bool _is_default_instance_;\n  typedef ::google::protobuf::internal::MapEntryLite<\n      ::std::string, ::google::protobuf::Value,\n      ::google::protobuf::internal::WireFormatLite::TYPE_STRING,\n      ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE,\n      0 >\n      Struct_FieldsEntry;\n  ::google::protobuf::internal::MapField<\n      ::std::string, ::google::protobuf::Value,\n      ::google::protobuf::internal::WireFormatLite::TYPE_STRING,\n      ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE,\n      0 > fields_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto();\n\n  void InitAsDefaultInstance();\n  static Struct* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Value) */ {\n public:\n  Value();\n  virtual ~Value();\n\n  Value(const Value& from);\n\n  inline Value& operator=(const Value& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const Value& default_instance();\n\n  enum KindCase {\n    kNullValue = 1,\n    kNumberValue = 2,\n    kStringValue = 3,\n    kBoolValue = 4,\n    kStructValue = 5,\n    kListValue = 6,\n    KIND_NOT_SET = 0,\n  };\n\n  void Swap(Value* other);\n\n  // implements Message ----------------------------------------------\n\n  inline Value* New() const { return New(NULL); }\n\n  Value* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const Value& from);\n  void MergeFrom(const Value& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(Value* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional .google.protobuf.NullValue null_value = 1;\n  private:\n  bool has_null_value() const;\n  public:\n  void clear_null_value();\n  static const int kNullValueFieldNumber = 1;\n  ::google::protobuf::NullValue null_value() const;\n  void set_null_value(::google::protobuf::NullValue value);\n\n  // optional double number_value = 2;\n  private:\n  bool has_number_value() const;\n  public:\n  void clear_number_value();\n  static const int kNumberValueFieldNumber = 2;\n  double number_value() const;\n  void set_number_value(double value);\n\n  // optional string string_value = 3;\n  private:\n  bool has_string_value() const;\n  public:\n  void clear_string_value();\n  static const int kStringValueFieldNumber = 3;\n  const ::std::string& string_value() const;\n  void set_string_value(const ::std::string& value);\n  void set_string_value(const char* value);\n  void set_string_value(const char* value, size_t size);\n  ::std::string* mutable_string_value();\n  ::std::string* release_string_value();\n  void set_allocated_string_value(::std::string* string_value);\n\n  // optional bool bool_value = 4;\n  private:\n  bool has_bool_value() const;\n  public:\n  void clear_bool_value();\n  static const int kBoolValueFieldNumber = 4;\n  bool bool_value() const;\n  void set_bool_value(bool value);\n\n  // optional .google.protobuf.Struct struct_value = 5;\n  bool has_struct_value() const;\n  void clear_struct_value();\n  static const int kStructValueFieldNumber = 5;\n  const ::google::protobuf::Struct& struct_value() const;\n  ::google::protobuf::Struct* mutable_struct_value();\n  ::google::protobuf::Struct* release_struct_value();\n  void set_allocated_struct_value(::google::protobuf::Struct* struct_value);\n\n  // optional .google.protobuf.ListValue list_value = 6;\n  bool has_list_value() const;\n  void clear_list_value();\n  static const int kListValueFieldNumber = 6;\n  const ::google::protobuf::ListValue& list_value() const;\n  ::google::protobuf::ListValue* mutable_list_value();\n  ::google::protobuf::ListValue* release_list_value();\n  void set_allocated_list_value(::google::protobuf::ListValue* list_value);\n\n  KindCase kind_case() const;\n  // @@protoc_insertion_point(class_scope:google.protobuf.Value)\n private:\n  inline void set_has_null_value();\n  inline void set_has_number_value();\n  inline void set_has_string_value();\n  inline void set_has_bool_value();\n  inline void set_has_struct_value();\n  inline void set_has_list_value();\n\n  inline bool has_kind() const;\n  void clear_kind();\n  inline void clear_has_kind();\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  bool _is_default_instance_;\n  union KindUnion {\n    KindUnion() {}\n    int null_value_;\n    double number_value_;\n    ::google::protobuf::internal::ArenaStringPtr string_value_;\n    bool bool_value_;\n    ::google::protobuf::Struct* struct_value_;\n    ::google::protobuf::ListValue* list_value_;\n  } kind_;\n  mutable int _cached_size_;\n  ::google::protobuf::uint32 _oneof_case_[1];\n\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto();\n\n  void InitAsDefaultInstance();\n  static Value* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT ListValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.ListValue) */ {\n public:\n  ListValue();\n  virtual ~ListValue();\n\n  ListValue(const ListValue& from);\n\n  inline ListValue& operator=(const ListValue& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const ListValue& default_instance();\n\n  void Swap(ListValue* other);\n\n  // implements Message ----------------------------------------------\n\n  inline ListValue* New() const { return New(NULL); }\n\n  ListValue* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const ListValue& from);\n  void MergeFrom(const ListValue& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(ListValue* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // repeated .google.protobuf.Value values = 1;\n  int values_size() const;\n  void clear_values();\n  static const int kValuesFieldNumber = 1;\n  const ::google::protobuf::Value& values(int index) const;\n  ::google::protobuf::Value* mutable_values(int index);\n  ::google::protobuf::Value* add_values();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Value >*\n      mutable_values();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Value >&\n      values() const;\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.ListValue)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  bool _is_default_instance_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Value > values_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fstruct_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fstruct_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fstruct_2eproto();\n\n  void InitAsDefaultInstance();\n  static ListValue* default_instance_;\n};\n// ===================================================================\n\n\n// ===================================================================\n\n#if !PROTOBUF_INLINE_NOT_IN_HEADERS\n// Struct\n\n// map<string, .google.protobuf.Value> fields = 1;\ninline int Struct::fields_size() const {\n  return fields_.size();\n}\ninline void Struct::clear_fields() {\n  fields_.Clear();\n}\ninline const ::google::protobuf::Map< ::std::string, ::google::protobuf::Value >&\nStruct::fields() const {\n  // @@protoc_insertion_point(field_map:google.protobuf.Struct.fields)\n  return fields_.GetMap();\n}\ninline ::google::protobuf::Map< ::std::string, ::google::protobuf::Value >*\nStruct::mutable_fields() {\n  // @@protoc_insertion_point(field_mutable_map:google.protobuf.Struct.fields)\n  return fields_.MutableMap();\n}\n\n// -------------------------------------------------------------------\n\n// Value\n\n// optional .google.protobuf.NullValue null_value = 1;\ninline bool Value::has_null_value() const {\n  return kind_case() == kNullValue;\n}\ninline void Value::set_has_null_value() {\n  _oneof_case_[0] = kNullValue;\n}\ninline void Value::clear_null_value() {\n  if (has_null_value()) {\n    kind_.null_value_ = 0;\n    clear_has_kind();\n  }\n}\ninline ::google::protobuf::NullValue Value::null_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Value.null_value)\n  if (has_null_value()) {\n    return static_cast< ::google::protobuf::NullValue >(kind_.null_value_);\n  }\n  return static_cast< ::google::protobuf::NullValue >(0);\n}\ninline void Value::set_null_value(::google::protobuf::NullValue value) {\n  if (!has_null_value()) {\n    clear_kind();\n    set_has_null_value();\n  }\n  kind_.null_value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Value.null_value)\n}\n\n// optional double number_value = 2;\ninline bool Value::has_number_value() const {\n  return kind_case() == kNumberValue;\n}\ninline void Value::set_has_number_value() {\n  _oneof_case_[0] = kNumberValue;\n}\ninline void Value::clear_number_value() {\n  if (has_number_value()) {\n    kind_.number_value_ = 0;\n    clear_has_kind();\n  }\n}\ninline double Value::number_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Value.number_value)\n  if (has_number_value()) {\n    return kind_.number_value_;\n  }\n  return 0;\n}\ninline void Value::set_number_value(double value) {\n  if (!has_number_value()) {\n    clear_kind();\n    set_has_number_value();\n  }\n  kind_.number_value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Value.number_value)\n}\n\n// optional string string_value = 3;\ninline bool Value::has_string_value() const {\n  return kind_case() == kStringValue;\n}\ninline void Value::set_has_string_value() {\n  _oneof_case_[0] = kStringValue;\n}\ninline void Value::clear_string_value() {\n  if (has_string_value()) {\n    kind_.string_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n    clear_has_kind();\n  }\n}\ninline const ::std::string& Value::string_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Value.string_value)\n  if (has_string_value()) {\n    return kind_.string_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  }\n  return *&::google::protobuf::internal::GetEmptyStringAlreadyInited();\n}\ninline void Value::set_string_value(const ::std::string& value) {\n  // @@protoc_insertion_point(field_set:google.protobuf.Value.string_value)\n  if (!has_string_value()) {\n    clear_kind();\n    set_has_string_value();\n    kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  }\n  kind_.string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Value.string_value)\n}\ninline void Value::set_string_value(const char* value) {\n  if (!has_string_value()) {\n    clear_kind();\n    set_has_string_value();\n    kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  }\n  kind_.string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Value.string_value)\n}\ninline void Value::set_string_value(const char* value, size_t size) {\n  if (!has_string_value()) {\n    clear_kind();\n    set_has_string_value();\n    kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  }\n  kind_.string_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(\n      reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Value.string_value)\n}\ninline ::std::string* Value::mutable_string_value() {\n  if (!has_string_value()) {\n    clear_kind();\n    set_has_string_value();\n    kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Value.string_value)\n  return kind_.string_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* Value::release_string_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Value.string_value)\n  if (has_string_value()) {\n    clear_has_kind();\n    return kind_.string_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  } else {\n    return NULL;\n  }\n}\ninline void Value::set_allocated_string_value(::std::string* string_value) {\n  if (!has_string_value()) {\n    kind_.string_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  }\n  clear_kind();\n  if (string_value != NULL) {\n    set_has_string_value();\n    kind_.string_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n        string_value);\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.string_value)\n}\n\n// optional bool bool_value = 4;\ninline bool Value::has_bool_value() const {\n  return kind_case() == kBoolValue;\n}\ninline void Value::set_has_bool_value() {\n  _oneof_case_[0] = kBoolValue;\n}\ninline void Value::clear_bool_value() {\n  if (has_bool_value()) {\n    kind_.bool_value_ = false;\n    clear_has_kind();\n  }\n}\ninline bool Value::bool_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Value.bool_value)\n  if (has_bool_value()) {\n    return kind_.bool_value_;\n  }\n  return false;\n}\ninline void Value::set_bool_value(bool value) {\n  if (!has_bool_value()) {\n    clear_kind();\n    set_has_bool_value();\n  }\n  kind_.bool_value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Value.bool_value)\n}\n\n// optional .google.protobuf.Struct struct_value = 5;\ninline bool Value::has_struct_value() const {\n  return kind_case() == kStructValue;\n}\ninline void Value::set_has_struct_value() {\n  _oneof_case_[0] = kStructValue;\n}\ninline void Value::clear_struct_value() {\n  if (has_struct_value()) {\n    delete kind_.struct_value_;\n    clear_has_kind();\n  }\n}\ninline  const ::google::protobuf::Struct& Value::struct_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Value.struct_value)\n  return has_struct_value()\n      ? *kind_.struct_value_\n      : ::google::protobuf::Struct::default_instance();\n}\ninline ::google::protobuf::Struct* Value::mutable_struct_value() {\n  if (!has_struct_value()) {\n    clear_kind();\n    set_has_struct_value();\n    kind_.struct_value_ = new ::google::protobuf::Struct;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Value.struct_value)\n  return kind_.struct_value_;\n}\ninline ::google::protobuf::Struct* Value::release_struct_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Value.struct_value)\n  if (has_struct_value()) {\n    clear_has_kind();\n    ::google::protobuf::Struct* temp = kind_.struct_value_;\n    kind_.struct_value_ = NULL;\n    return temp;\n  } else {\n    return NULL;\n  }\n}\ninline void Value::set_allocated_struct_value(::google::protobuf::Struct* struct_value) {\n  clear_kind();\n  if (struct_value) {\n    set_has_struct_value();\n    kind_.struct_value_ = struct_value;\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.struct_value)\n}\n\n// optional .google.protobuf.ListValue list_value = 6;\ninline bool Value::has_list_value() const {\n  return kind_case() == kListValue;\n}\ninline void Value::set_has_list_value() {\n  _oneof_case_[0] = kListValue;\n}\ninline void Value::clear_list_value() {\n  if (has_list_value()) {\n    delete kind_.list_value_;\n    clear_has_kind();\n  }\n}\ninline  const ::google::protobuf::ListValue& Value::list_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Value.list_value)\n  return has_list_value()\n      ? *kind_.list_value_\n      : ::google::protobuf::ListValue::default_instance();\n}\ninline ::google::protobuf::ListValue* Value::mutable_list_value() {\n  if (!has_list_value()) {\n    clear_kind();\n    set_has_list_value();\n    kind_.list_value_ = new ::google::protobuf::ListValue;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Value.list_value)\n  return kind_.list_value_;\n}\ninline ::google::protobuf::ListValue* Value::release_list_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Value.list_value)\n  if (has_list_value()) {\n    clear_has_kind();\n    ::google::protobuf::ListValue* temp = kind_.list_value_;\n    kind_.list_value_ = NULL;\n    return temp;\n  } else {\n    return NULL;\n  }\n}\ninline void Value::set_allocated_list_value(::google::protobuf::ListValue* list_value) {\n  clear_kind();\n  if (list_value) {\n    set_has_list_value();\n    kind_.list_value_ = list_value;\n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Value.list_value)\n}\n\ninline bool Value::has_kind() const {\n  return kind_case() != KIND_NOT_SET;\n}\ninline void Value::clear_has_kind() {\n  _oneof_case_[0] = KIND_NOT_SET;\n}\ninline Value::KindCase Value::kind_case() const {\n  return Value::KindCase(_oneof_case_[0]);\n}\n// -------------------------------------------------------------------\n\n// ListValue\n\n// repeated .google.protobuf.Value values = 1;\ninline int ListValue::values_size() const {\n  return values_.size();\n}\ninline void ListValue::clear_values() {\n  values_.Clear();\n}\ninline const ::google::protobuf::Value& ListValue::values(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.ListValue.values)\n  return values_.Get(index);\n}\ninline ::google::protobuf::Value* ListValue::mutable_values(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.ListValue.values)\n  return values_.Mutable(index);\n}\ninline ::google::protobuf::Value* ListValue::add_values() {\n  // @@protoc_insertion_point(field_add:google.protobuf.ListValue.values)\n  return values_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Value >*\nListValue::mutable_values() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.ListValue.values)\n  return &values_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Value >&\nListValue::values() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.ListValue.values)\n  return values_;\n}\n\n#endif  // !PROTOBUF_INLINE_NOT_IN_HEADERS\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace protobuf\n}  // namespace google\n\n#ifndef SWIG\nnamespace google {\nnamespace protobuf {\n\ntemplate <> struct is_proto_enum< ::google::protobuf::NullValue> : ::google::protobuf::internal::true_type {};\ntemplate <>\ninline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::NullValue>() {\n  return ::google::protobuf::NullValue_descriptor();\n}\n\n}  // namespace protobuf\n}  // namespace google\n#endif  // SWIG\n\n// @@protoc_insertion_point(global_scope)\n\n#endif  // PROTOBUF_google_2fprotobuf_2fstruct_2eproto__INCLUDED\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/struct.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto3\";\n\npackage google.protobuf;\n\noption csharp_namespace = \"Google.Protobuf.WellKnownTypes\";\noption go_package = \"github.com/golang/protobuf/ptypes/struct;structpb\";\noption java_package = \"com.google.protobuf\";\noption java_outer_classname = \"StructProto\";\noption java_multiple_files = true;\noption java_generate_equals_and_hash = true;\noption objc_class_prefix = \"GPB\";\n\n\n// `Struct` represents a structured data value, consisting of fields\n// which map to dynamically typed values. In some languages, `Struct`\n// might be supported by a native representation. For example, in\n// scripting languages like JS a struct is represented as an\n// object. The details of that representation are described together\n// with the proto support for the language.\n//\n// The JSON representation for `Struct` is JSON object.\nmessage Struct {\n  // Unordered map of dynamically typed values.\n  map<string, Value> fields = 1;\n}\n\n// `Value` represents a dynamically typed value which can be either\n// null, a number, a string, a boolean, a recursive struct value, or a\n// list of values. A producer of value is expected to set one of that\n// variants, absence of any variant indicates an error.\n//\n// The JSON representation for `Value` is JSON value.\nmessage Value {\n  // The kind of value.\n  oneof kind {\n    // Represents a null value.\n    NullValue null_value = 1;\n    // Represents a double value.\n    double number_value = 2;\n    // Represents a string value.\n    string string_value = 3;\n    // Represents a boolean value.\n    bool bool_value = 4;\n    // Represents a structured value.\n    Struct struct_value = 5;\n    // Represents a repeated `Value`.\n    ListValue list_value = 6;\n  }\n}\n\n// `NullValue` is a singleton enumeration to represent the null value for the\n// `Value` type union.\n//\n//  The JSON representation for `NullValue` is JSON `null`.\nenum NullValue {\n  // Null value.\n  NULL_VALUE = 0;\n}\n\n// `ListValue` is a wrapper around a repeated field of values.\n//\n// The JSON representation for `ListValue` is JSON array.\nmessage ListValue {\n  // Repeated field of dynamically typed values.\n  repeated Value values = 1;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/atomic_sequence_num.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2014 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n#ifndef GOOGLE_PROTOBUF_ATOMIC_SEQUENCE_NUM_H_\n#define GOOGLE_PROTOBUF_ATOMIC_SEQUENCE_NUM_H_\n\n#include <google/protobuf/stubs/atomicops.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\nclass SequenceNumber {\n public:\n  SequenceNumber() : word_(0) {}\n\n  AtomicWord GetNext() {\n    return NoBarrier_AtomicIncrement(&word_, 1) - 1;\n  }\n private:\n  AtomicWord word_;\n};\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_ATOMIC_SEQUENCE_NUM_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/atomicops.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2012 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// The routines exported by this module are subtle.  If you use them, even if\n// you get the code right, it will depend on careful reasoning about atomicity\n// and memory ordering; it will be less readable, and harder to maintain.  If\n// you plan to use these routines, you should have a good reason, such as solid\n// evidence that performance would otherwise suffer, or there being no\n// alternative.  You should assume only properties explicitly guaranteed by the\n// specifications in this file.  You are almost certainly _not_ writing code\n// just for the x86; if you assume x86 semantics, x86 hardware bugs and\n// implementations on other archtectures will cause your code to break.  If you\n// do not know what you are doing, avoid these routines, and use a Mutex.\n//\n// It is incorrect to make direct assignments to/from an atomic variable.\n// You should use one of the Load or Store routines.  The NoBarrier\n// versions are provided when no barriers are needed:\n//   NoBarrier_Store()\n//   NoBarrier_Load()\n// Although there are currently no compiler enforcement, you are encouraged\n// to use these.\n\n// This header and the implementations for each platform (located in\n// atomicops_internals_*) must be kept in sync with the upstream code (V8).\n\n#ifndef GOOGLE_PROTOBUF_ATOMICOPS_H_\n#define GOOGLE_PROTOBUF_ATOMICOPS_H_\n\n// Don't include this file for people not concerned about thread safety.\n#ifndef GOOGLE_PROTOBUF_NO_THREAD_SAFETY\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/platform_macros.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\n#if defined(GOOGLE_PROTOBUF_ARCH_POWER)\n#if defined(_LP64) || defined(__LP64__)\ntypedef int32 Atomic32;\ntypedef intptr_t Atomic64;\n#else\ntypedef intptr_t Atomic32;\ntypedef int64 Atomic64;\n#endif\n#else\ntypedef int32 Atomic32;\n#ifdef GOOGLE_PROTOBUF_ARCH_64_BIT\n// We need to be able to go between Atomic64 and AtomicWord implicitly.  This\n// means Atomic64 and AtomicWord should be the same type on 64-bit.\n#if defined(__ILP32__) || defined(GOOGLE_PROTOBUF_OS_NACL)\n// NaCl's intptr_t is not actually 64-bits on 64-bit!\n// http://code.google.com/p/nativeclient/issues/detail?id=1162\n// sparcv9's pointer type is 32bits\ntypedef int64 Atomic64;\n#else\ntypedef intptr_t Atomic64;\n#endif\n#endif\n#endif\n\n// Use AtomicWord for a machine-sized pointer.  It will use the Atomic32 or\n// Atomic64 routines below, depending on your architecture.\ntypedef intptr_t AtomicWord;\n\n// Atomically execute:\n//      result = *ptr;\n//      if (*ptr == old_value)\n//        *ptr = new_value;\n//      return result;\n//\n// I.e., replace \"*ptr\" with \"new_value\" if \"*ptr\" used to be \"old_value\".\n// Always return the old value of \"*ptr\"\n//\n// This routine implies no memory barriers.\nAtomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,\n                                  Atomic32 old_value,\n                                  Atomic32 new_value);\n\n// Atomically store new_value into *ptr, returning the previous value held in\n// *ptr.  This routine implies no memory barriers.\nAtomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr, Atomic32 new_value);\n\n// Atomically increment *ptr by \"increment\".  Returns the new value of\n// *ptr with the increment applied.  This routine implies no memory barriers.\nAtomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr, Atomic32 increment);\n\nAtomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,\n                                 Atomic32 increment);\n\n// These following lower-level operations are typically useful only to people\n// implementing higher-level synchronization operations like spinlocks,\n// mutexes, and condition-variables.  They combine CompareAndSwap(), a load, or\n// a store with appropriate memory-ordering instructions.  \"Acquire\" operations\n// ensure that no later memory access can be reordered ahead of the operation.\n// \"Release\" operations ensure that no previous memory access can be reordered\n// after the operation.  \"Barrier\" operations have both \"Acquire\" and \"Release\"\n// semantics.   A MemoryBarrier() has \"Barrier\" semantics, but does no memory\n// access.\nAtomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,\n                                Atomic32 old_value,\n                                Atomic32 new_value);\nAtomic32 Release_CompareAndSwap(volatile Atomic32* ptr,\n                                Atomic32 old_value,\n                                Atomic32 new_value);\n\n#if defined(__MINGW32__) && defined(MemoryBarrier)\n#undef MemoryBarrier\n#endif\nvoid MemoryBarrier();\nvoid NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value);\nvoid Acquire_Store(volatile Atomic32* ptr, Atomic32 value);\nvoid Release_Store(volatile Atomic32* ptr, Atomic32 value);\n\nAtomic32 NoBarrier_Load(volatile const Atomic32* ptr);\nAtomic32 Acquire_Load(volatile const Atomic32* ptr);\nAtomic32 Release_Load(volatile const Atomic32* ptr);\n\n// 64-bit atomic operations (only available on 64-bit processors).\n#ifdef GOOGLE_PROTOBUF_ARCH_64_BIT\nAtomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,\n                                  Atomic64 old_value,\n                                  Atomic64 new_value);\nAtomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr, Atomic64 new_value);\nAtomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment);\nAtomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment);\n\nAtomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,\n                                Atomic64 old_value,\n                                Atomic64 new_value);\nAtomic64 Release_CompareAndSwap(volatile Atomic64* ptr,\n                                Atomic64 old_value,\n                                Atomic64 new_value);\nvoid NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value);\nvoid Acquire_Store(volatile Atomic64* ptr, Atomic64 value);\nvoid Release_Store(volatile Atomic64* ptr, Atomic64 value);\nAtomic64 NoBarrier_Load(volatile const Atomic64* ptr);\nAtomic64 Acquire_Load(volatile const Atomic64* ptr);\nAtomic64 Release_Load(volatile const Atomic64* ptr);\n#endif  // GOOGLE_PROTOBUF_ARCH_64_BIT\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n// Include our platform specific implementation.\n#define GOOGLE_PROTOBUF_ATOMICOPS_ERROR \\\n\"Atomic operations are not supported on your platform\"\n\n// ThreadSanitizer, http://clang.llvm.org/docs/ThreadSanitizer.html.\n#if defined(THREAD_SANITIZER)\n#include <google/protobuf/stubs/atomicops_internals_tsan.h>\n// MSVC.\n#elif defined(_MSC_VER)\n#if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64)\n#include <google/protobuf/stubs/atomicops_internals_x86_msvc.h>\n#else\n#error GOOGLE_PROTOBUF_ATOMICOPS_ERROR\n#endif\n\n// Solaris\n#elif defined(GOOGLE_PROTOBUF_OS_SOLARIS)\n#include <google/protobuf/stubs/atomicops_internals_solaris.h>\n\n// AIX\n#elif defined(GOOGLE_PROTOBUF_OS_AIX)\n#include <google/protobuf/stubs/atomicops_internals_power.h>\n\n// Apple.\n#elif defined(GOOGLE_PROTOBUF_OS_APPLE)\n#include <google/protobuf/stubs/atomicops_internals_macosx.h>\n\n// GCC.\n#elif defined(__GNUC__)\n#if defined(GOOGLE_PROTOBUF_ARCH_IA32) || defined(GOOGLE_PROTOBUF_ARCH_X64)\n#include <google/protobuf/stubs/atomicops_internals_x86_gcc.h>\n#elif defined(GOOGLE_PROTOBUF_ARCH_ARM) && defined(__linux__)\n#include <google/protobuf/stubs/atomicops_internals_arm_gcc.h>\n#elif defined(GOOGLE_PROTOBUF_ARCH_AARCH64)\n#include <google/protobuf/stubs/atomicops_internals_arm64_gcc.h>\n#elif defined(GOOGLE_PROTOBUF_ARCH_ARM_QNX)\n#include <google/protobuf/stubs/atomicops_internals_arm_qnx.h>\n#elif defined(GOOGLE_PROTOBUF_ARCH_MIPS) || defined(GOOGLE_PROTOBUF_ARCH_MIPS64)\n#include <google/protobuf/stubs/atomicops_internals_mips_gcc.h>\n#elif defined(GOOGLE_PROTOBUF_ARCH_POWER)\n#include <google/protobuf/stubs/atomicops_internals_power.h>\n#elif defined(__native_client__)\n#include <google/protobuf/stubs/atomicops_internals_pnacl.h>\n#elif defined(GOOGLE_PROTOBUF_ARCH_PPC)\n#include <google/protobuf/stubs/atomicops_internals_ppc_gcc.h>\n#elif (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4))\n#include <google/protobuf/stubs/atomicops_internals_generic_gcc.h>\n#elif defined(__clang__)\n#if __has_extension(c_atomic)\n#include <google/protobuf/stubs/atomicops_internals_generic_gcc.h>\n#else\n#error GOOGLE_PROTOBUF_ATOMICOPS_ERROR\n#endif\n#else\n#error GOOGLE_PROTOBUF_ATOMICOPS_ERROR\n#endif\n\n// Unknown.\n#else\n#error GOOGLE_PROTOBUF_ATOMICOPS_ERROR\n#endif\n\n// On some platforms we need additional declarations to make AtomicWord\n// compatible with our other Atomic* types.\n#if defined(GOOGLE_PROTOBUF_OS_APPLE)\n#include <google/protobuf/stubs/atomicops_internals_atomicword_compat.h>\n#endif\n\n#undef GOOGLE_PROTOBUF_ATOMICOPS_ERROR\n\n#endif  // GOOGLE_PROTOBUF_NO_THREAD_SAFETY\n\n#endif  // GOOGLE_PROTOBUF_ATOMICOPS_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2012 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file is an internal atomic implementation, use atomicops.h instead.\n\n#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ARM64_GCC_H_\n#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ARM64_GCC_H_\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\ninline void MemoryBarrier() {\n  __asm__ __volatile__ (\"dmb ish\" ::: \"memory\");  // NOLINT\n}\n\n// NoBarrier versions of the operation include \"memory\" in the clobber list.\n// This is not required for direct usage of the NoBarrier versions of the\n// operations. However this is required for correctness when they are used as\n// part of the Acquire or Release versions, to ensure that nothing from outside\n// the call is reordered between the operation and the memory barrier. This does\n// not change the code generated, so has no or minimal impact on the\n// NoBarrier operations.\n\ninline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,\n                                         Atomic32 old_value,\n                                         Atomic32 new_value) {\n  Atomic32 prev;\n  int32_t temp;\n\n  __asm__ __volatile__ (  // NOLINT\n    \"0:                                    \\n\\t\"\n    \"ldxr %w[prev], %[ptr]                 \\n\\t\"  // Load the previous value.\n    \"cmp %w[prev], %w[old_value]           \\n\\t\"\n    \"bne 1f                                \\n\\t\"\n    \"stxr %w[temp], %w[new_value], %[ptr]  \\n\\t\"  // Try to store the new value.\n    \"cbnz %w[temp], 0b                     \\n\\t\"  // Retry if it did not work.\n    \"1:                                    \\n\\t\"\n    : [prev]\"=&r\" (prev),\n      [temp]\"=&r\" (temp),\n      [ptr]\"+Q\" (*ptr)\n    : [old_value]\"IJr\" (old_value),\n      [new_value]\"r\" (new_value)\n    : \"cc\", \"memory\"\n  );  // NOLINT\n\n  return prev;\n}\n\ninline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,\n                                         Atomic32 new_value) {\n  Atomic32 result;\n  int32_t temp;\n\n  __asm__ __volatile__ (  // NOLINT\n    \"0:                                    \\n\\t\"\n    \"ldxr %w[result], %[ptr]               \\n\\t\"  // Load the previous value.\n    \"stxr %w[temp], %w[new_value], %[ptr]  \\n\\t\"  // Try to store the new value.\n    \"cbnz %w[temp], 0b                     \\n\\t\"  // Retry if it did not work.\n    : [result]\"=&r\" (result),\n      [temp]\"=&r\" (temp),\n      [ptr]\"+Q\" (*ptr)\n    : [new_value]\"r\" (new_value)\n    : \"memory\"\n  );  // NOLINT\n\n  return result;\n}\n\ninline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,\n                                          Atomic32 increment) {\n  Atomic32 result;\n  int32_t temp;\n\n  __asm__ __volatile__ (  // NOLINT\n    \"0:                                       \\n\\t\"\n    \"ldxr %w[result], %[ptr]                  \\n\\t\"  // Load the previous value.\n    \"add %w[result], %w[result], %w[increment]\\n\\t\"\n    \"stxr %w[temp], %w[result], %[ptr]        \\n\\t\"  // Try to store the result.\n    \"cbnz %w[temp], 0b                        \\n\\t\"  // Retry on failure.\n    : [result]\"=&r\" (result),\n      [temp]\"=&r\" (temp),\n      [ptr]\"+Q\" (*ptr)\n    : [increment]\"IJr\" (increment)\n    : \"memory\"\n  );  // NOLINT\n\n  return result;\n}\n\ninline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,\n                                        Atomic32 increment) {\n  MemoryBarrier();\n  Atomic32 result = NoBarrier_AtomicIncrement(ptr, increment);\n  MemoryBarrier();\n\n  return result;\n}\n\ninline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  Atomic32 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n  MemoryBarrier();\n\n  return prev;\n}\n\ninline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  MemoryBarrier();\n  Atomic32 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n\n  return prev;\n}\n\ninline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {\n  *ptr = value;\n}\n\ninline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {\n  *ptr = value;\n  MemoryBarrier();\n}\n\ninline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {\n  __asm__ __volatile__ (  // NOLINT\n    \"stlr %w[value], %[ptr]  \\n\\t\"\n    : [ptr]\"=Q\" (*ptr)\n    : [value]\"r\" (value)\n    : \"memory\"\n  );  // NOLINT\n}\n\ninline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {\n  return *ptr;\n}\n\ninline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {\n  Atomic32 value;\n\n  __asm__ __volatile__ (  // NOLINT\n    \"ldar %w[value], %[ptr]  \\n\\t\"\n    : [value]\"=r\" (value)\n    : [ptr]\"Q\" (*ptr)\n    : \"memory\"\n  );  // NOLINT\n\n  return value;\n}\n\ninline Atomic32 Release_Load(volatile const Atomic32* ptr) {\n  MemoryBarrier();\n  return *ptr;\n}\n\n// 64-bit versions of the operations.\n// See the 32-bit versions for comments.\n\ninline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,\n                                         Atomic64 old_value,\n                                         Atomic64 new_value) {\n  Atomic64 prev;\n  int32_t temp;\n\n  __asm__ __volatile__ (  // NOLINT\n    \"0:                                    \\n\\t\"\n    \"ldxr %[prev], %[ptr]                  \\n\\t\"\n    \"cmp %[prev], %[old_value]             \\n\\t\"\n    \"bne 1f                                \\n\\t\"\n    \"stxr %w[temp], %[new_value], %[ptr]   \\n\\t\"\n    \"cbnz %w[temp], 0b                     \\n\\t\"\n    \"1:                                    \\n\\t\"\n    : [prev]\"=&r\" (prev),\n      [temp]\"=&r\" (temp),\n      [ptr]\"+Q\" (*ptr)\n    : [old_value]\"IJr\" (old_value),\n      [new_value]\"r\" (new_value)\n    : \"cc\", \"memory\"\n  );  // NOLINT\n\n  return prev;\n}\n\ninline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,\n                                         Atomic64 new_value) {\n  Atomic64 result;\n  int32_t temp;\n\n  __asm__ __volatile__ (  // NOLINT\n    \"0:                                    \\n\\t\"\n    \"ldxr %[result], %[ptr]                \\n\\t\"\n    \"stxr %w[temp], %[new_value], %[ptr]   \\n\\t\"\n    \"cbnz %w[temp], 0b                     \\n\\t\"\n    : [result]\"=&r\" (result),\n      [temp]\"=&r\" (temp),\n      [ptr]\"+Q\" (*ptr)\n    : [new_value]\"r\" (new_value)\n    : \"memory\"\n  );  // NOLINT\n\n  return result;\n}\n\ninline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,\n                                          Atomic64 increment) {\n  Atomic64 result;\n  int32_t temp;\n\n  __asm__ __volatile__ (  // NOLINT\n    \"0:                                     \\n\\t\"\n    \"ldxr %[result], %[ptr]                 \\n\\t\"\n    \"add %[result], %[result], %[increment] \\n\\t\"\n    \"stxr %w[temp], %[result], %[ptr]       \\n\\t\"\n    \"cbnz %w[temp], 0b                      \\n\\t\"\n    : [result]\"=&r\" (result),\n      [temp]\"=&r\" (temp),\n      [ptr]\"+Q\" (*ptr)\n    : [increment]\"IJr\" (increment)\n    : \"memory\"\n  );  // NOLINT\n\n  return result;\n}\n\ninline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,\n                                        Atomic64 increment) {\n  MemoryBarrier();\n  Atomic64 result = NoBarrier_AtomicIncrement(ptr, increment);\n  MemoryBarrier();\n\n  return result;\n}\n\ninline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,\n                                       Atomic64 old_value,\n                                       Atomic64 new_value) {\n  Atomic64 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n  MemoryBarrier();\n\n  return prev;\n}\n\ninline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,\n                                       Atomic64 old_value,\n                                       Atomic64 new_value) {\n  MemoryBarrier();\n  Atomic64 prev = NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n\n  return prev;\n}\n\ninline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {\n  *ptr = value;\n}\n\ninline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {\n  *ptr = value;\n  MemoryBarrier();\n}\n\ninline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {\n  __asm__ __volatile__ (  // NOLINT\n    \"stlr %x[value], %[ptr]  \\n\\t\"\n    : [ptr]\"=Q\" (*ptr)\n    : [value]\"r\" (value)\n    : \"memory\"\n  );  // NOLINT\n}\n\ninline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {\n  return *ptr;\n}\n\ninline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {\n  Atomic64 value;\n\n  __asm__ __volatile__ (  // NOLINT\n    \"ldar %x[value], %[ptr]  \\n\\t\"\n    : [value]\"=r\" (value)\n    : [ptr]\"Q\" (*ptr)\n    : \"memory\"\n  );  // NOLINT\n\n  return value;\n}\n\ninline Atomic64 Release_Load(volatile const Atomic64* ptr) {\n  MemoryBarrier();\n  return *ptr;\n}\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ARM64_GCC_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/atomicops_internals_arm_gcc.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2012 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file is an internal atomic implementation, use atomicops.h instead.\n//\n// LinuxKernelCmpxchg and Barrier_AtomicIncrement are from Google Gears.\n\n#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ARM_GCC_H_\n#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ARM_GCC_H_\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\n// 0xffff0fc0 is the hard coded address of a function provided by\n// the kernel which implements an atomic compare-exchange. On older\n// ARM architecture revisions (pre-v6) this may be implemented using\n// a syscall. This address is stable, and in active use (hard coded)\n// by at least glibc-2.7 and the Android C library.\ntypedef Atomic32 (*LinuxKernelCmpxchgFunc)(Atomic32 old_value,\n                                           Atomic32 new_value,\n                                           volatile Atomic32* ptr);\nLinuxKernelCmpxchgFunc pLinuxKernelCmpxchg __attribute__((weak)) =\n    (LinuxKernelCmpxchgFunc) 0xffff0fc0;\n\ntypedef void (*LinuxKernelMemoryBarrierFunc)(void);\nLinuxKernelMemoryBarrierFunc pLinuxKernelMemoryBarrier __attribute__((weak)) =\n    (LinuxKernelMemoryBarrierFunc) 0xffff0fa0;\n\n\ninline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,\n                                         Atomic32 old_value,\n                                         Atomic32 new_value) {\n  Atomic32 prev_value = *ptr;\n  do {\n    if (!pLinuxKernelCmpxchg(old_value, new_value,\n                             const_cast<Atomic32*>(ptr))) {\n      return old_value;\n    }\n    prev_value = *ptr;\n  } while (prev_value == old_value);\n  return prev_value;\n}\n\ninline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,\n                                         Atomic32 new_value) {\n  Atomic32 old_value;\n  do {\n    old_value = *ptr;\n  } while (pLinuxKernelCmpxchg(old_value, new_value,\n                               const_cast<Atomic32*>(ptr)));\n  return old_value;\n}\n\ninline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,\n                                          Atomic32 increment) {\n  return Barrier_AtomicIncrement(ptr, increment);\n}\n\ninline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,\n                                        Atomic32 increment) {\n  for (;;) {\n    // Atomic exchange the old value with an incremented one.\n    Atomic32 old_value = *ptr;\n    Atomic32 new_value = old_value + increment;\n    if (pLinuxKernelCmpxchg(old_value, new_value,\n                            const_cast<Atomic32*>(ptr)) == 0) {\n      // The exchange took place as expected.\n      return new_value;\n    }\n    // Otherwise, *ptr changed mid-loop and we need to retry.\n  }\n}\n\ninline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  return NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n}\n\ninline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  return NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n}\n\ninline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {\n  *ptr = value;\n}\n\ninline void MemoryBarrier() {\n  pLinuxKernelMemoryBarrier();\n}\n\ninline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {\n  *ptr = value;\n  MemoryBarrier();\n}\n\ninline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {\n  MemoryBarrier();\n  *ptr = value;\n}\n\ninline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {\n  return *ptr;\n}\n\ninline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {\n  Atomic32 value = *ptr;\n  MemoryBarrier();\n  return value;\n}\n\ninline Atomic32 Release_Load(volatile const Atomic32* ptr) {\n  MemoryBarrier();\n  return *ptr;\n}\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ARM_GCC_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/atomicops_internals_arm_qnx.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2012 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file is an internal atomic implementation, use atomicops.h instead.\n\n#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ARM_QNX_H_\n#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ARM_QNX_H_\n\n// For _smp_cmpxchg()\n#include <pthread.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\ninline Atomic32 QNXCmpxchg(Atomic32 old_value,\n                           Atomic32 new_value,\n                           volatile Atomic32* ptr) {\n  return static_cast<Atomic32>(\n      _smp_cmpxchg((volatile unsigned *)ptr,\n                   (unsigned)old_value,\n                   (unsigned)new_value));\n}\n\n\ninline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,\n                                         Atomic32 old_value,\n                                         Atomic32 new_value) {\n  Atomic32 prev_value = *ptr;\n  do {\n    if (!QNXCmpxchg(old_value, new_value,\n                    const_cast<Atomic32*>(ptr))) {\n      return old_value;\n    }\n    prev_value = *ptr;\n  } while (prev_value == old_value);\n  return prev_value;\n}\n\ninline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,\n                                         Atomic32 new_value) {\n  Atomic32 old_value;\n  do {\n    old_value = *ptr;\n  } while (QNXCmpxchg(old_value, new_value,\n                      const_cast<Atomic32*>(ptr)));\n  return old_value;\n}\n\ninline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,\n                                          Atomic32 increment) {\n  return Barrier_AtomicIncrement(ptr, increment);\n}\n\ninline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,\n                                        Atomic32 increment) {\n  for (;;) {\n    // Atomic exchange the old value with an incremented one.\n    Atomic32 old_value = *ptr;\n    Atomic32 new_value = old_value + increment;\n    if (QNXCmpxchg(old_value, new_value,\n                   const_cast<Atomic32*>(ptr)) == 0) {\n      // The exchange took place as expected.\n      return new_value;\n    }\n    // Otherwise, *ptr changed mid-loop and we need to retry.\n  }\n}\n\ninline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  return NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n}\n\ninline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  return NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n}\n\ninline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {\n  *ptr = value;\n}\n\ninline void MemoryBarrier() {\n  __sync_synchronize();\n}\n\ninline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {\n  *ptr = value;\n  MemoryBarrier();\n}\n\ninline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {\n  MemoryBarrier();\n  *ptr = value;\n}\n\ninline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {\n  return *ptr;\n}\n\ninline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {\n  Atomic32 value = *ptr;\n  MemoryBarrier();\n  return value;\n}\n\ninline Atomic32 Release_Load(volatile const Atomic32* ptr) {\n  MemoryBarrier();\n  return *ptr;\n}\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ARM_QNX_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/atomicops_internals_atomicword_compat.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2012 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file is an internal atomic implementation, use atomicops.h instead.\n\n#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_\n#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_\n\n// AtomicWord is a synonym for intptr_t, and Atomic32 is a synonym for int32,\n// which in turn means int. On some LP32 platforms, intptr_t is an int, but\n// on others, it's a long. When AtomicWord and Atomic32 are based on different\n// fundamental types, their pointers are incompatible.\n//\n// This file defines function overloads to allow both AtomicWord and Atomic32\n// data to be used with this interface.\n//\n// On LP64 platforms, AtomicWord and Atomic64 are both always long,\n// so this problem doesn't occur.\n\n#if !defined(GOOGLE_PROTOBUF_ARCH_64_BIT)\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\ninline AtomicWord NoBarrier_CompareAndSwap(volatile AtomicWord* ptr,\n                                           AtomicWord old_value,\n                                           AtomicWord new_value) {\n  return NoBarrier_CompareAndSwap(\n      reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);\n}\n\ninline AtomicWord NoBarrier_AtomicExchange(volatile AtomicWord* ptr,\n                                           AtomicWord new_value) {\n  return NoBarrier_AtomicExchange(\n      reinterpret_cast<volatile Atomic32*>(ptr), new_value);\n}\n\ninline AtomicWord NoBarrier_AtomicIncrement(volatile AtomicWord* ptr,\n                                            AtomicWord increment) {\n  return NoBarrier_AtomicIncrement(\n      reinterpret_cast<volatile Atomic32*>(ptr), increment);\n}\n\ninline AtomicWord Barrier_AtomicIncrement(volatile AtomicWord* ptr,\n                                          AtomicWord increment) {\n  return Barrier_AtomicIncrement(\n      reinterpret_cast<volatile Atomic32*>(ptr), increment);\n}\n\ninline AtomicWord Acquire_CompareAndSwap(volatile AtomicWord* ptr,\n                                         AtomicWord old_value,\n                                         AtomicWord new_value) {\n  return Acquire_CompareAndSwap(\n      reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);\n}\n\ninline AtomicWord Release_CompareAndSwap(volatile AtomicWord* ptr,\n                                         AtomicWord old_value,\n                                         AtomicWord new_value) {\n  return Release_CompareAndSwap(\n      reinterpret_cast<volatile Atomic32*>(ptr), old_value, new_value);\n}\n\ninline void NoBarrier_Store(volatile AtomicWord *ptr, AtomicWord value) {\n  NoBarrier_Store(reinterpret_cast<volatile Atomic32*>(ptr), value);\n}\n\ninline void Acquire_Store(volatile AtomicWord* ptr, AtomicWord value) {\n  return Acquire_Store(reinterpret_cast<volatile Atomic32*>(ptr), value);\n}\n\ninline void Release_Store(volatile AtomicWord* ptr, AtomicWord value) {\n  return Release_Store(reinterpret_cast<volatile Atomic32*>(ptr), value);\n}\n\ninline AtomicWord NoBarrier_Load(volatile const AtomicWord *ptr) {\n  return NoBarrier_Load(reinterpret_cast<volatile const Atomic32*>(ptr));\n}\n\ninline AtomicWord Acquire_Load(volatile const AtomicWord* ptr) {\n  return Acquire_Load(reinterpret_cast<volatile const Atomic32*>(ptr));\n}\n\ninline AtomicWord Release_Load(volatile const AtomicWord* ptr) {\n  return Release_Load(reinterpret_cast<volatile const Atomic32*>(ptr));\n}\n\n}   // namespace internal\n}   // namespace protobuf\n}   // namespace google\n\n#endif  // !defined(GOOGLE_PROTOBUF_ARCH_64_BIT)\n\n#endif  // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_ATOMICWORD_COMPAT_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h",
    "content": "// Copyright 2013 Red Hat Inc.  All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Red Hat Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file is an internal atomic implementation, use atomicops.h instead.\n\n#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_GENERIC_GCC_H_\n#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_GENERIC_GCC_H_\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\ninline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,\n                                         Atomic32 old_value,\n                                         Atomic32 new_value) {\n  __atomic_compare_exchange_n(ptr, &old_value, new_value, true,\n                              __ATOMIC_RELAXED, __ATOMIC_RELAXED);\n  return old_value;\n}\n\ninline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,\n                                         Atomic32 new_value) {\n  return __atomic_exchange_n(ptr, new_value, __ATOMIC_RELAXED);\n}\n\ninline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,\n                                          Atomic32 increment) {\n  return __atomic_add_fetch(ptr, increment, __ATOMIC_RELAXED);\n}\n\ninline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,\n                                        Atomic32 increment) {\n  return __atomic_add_fetch(ptr, increment, __ATOMIC_SEQ_CST);\n}\n\ninline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  __atomic_compare_exchange_n(ptr, &old_value, new_value, true,\n                              __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);\n  return old_value;\n}\n\ninline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  __atomic_compare_exchange_n(ptr, &old_value, new_value, true,\n                              __ATOMIC_RELEASE, __ATOMIC_ACQUIRE);\n  return old_value;\n}\n\ninline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {\n  __atomic_store_n(ptr, value, __ATOMIC_RELAXED);\n}\n\ninline void MemoryBarrier() {\n  __sync_synchronize();\n}\n\ninline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {\n  __atomic_store_n(ptr, value, __ATOMIC_SEQ_CST);\n}\n\ninline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {\n  __atomic_store_n(ptr, value, __ATOMIC_RELEASE);\n}\n\ninline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {\n  return __atomic_load_n(ptr, __ATOMIC_RELAXED);\n}\n\ninline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {\n  return __atomic_load_n(ptr, __ATOMIC_ACQUIRE);\n}\n\ninline Atomic32 Release_Load(volatile const Atomic32* ptr) {\n  return __atomic_load_n(ptr, __ATOMIC_SEQ_CST);\n}\n\n#ifdef __LP64__\n\ninline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {\n  __atomic_store_n(ptr, value, __ATOMIC_RELEASE);\n}\n\ninline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {\n  return __atomic_load_n(ptr, __ATOMIC_ACQUIRE);\n}\n\ninline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,\n                                       Atomic64 old_value,\n                                       Atomic64 new_value) {\n  __atomic_compare_exchange_n(ptr, &old_value, new_value, true,\n                              __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);\n  return old_value;\n}\n\ninline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,\n                                         Atomic64 old_value,\n                                         Atomic64 new_value) {\n  __atomic_compare_exchange_n(ptr, &old_value, new_value, true,\n                              __ATOMIC_RELAXED, __ATOMIC_RELAXED);\n  return old_value;\n}\n\ninline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,\n                                          Atomic64 increment) {\n  return __atomic_add_fetch(ptr, increment, __ATOMIC_RELAXED);\n}\n\ninline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {\n  __atomic_store_n(ptr, value, __ATOMIC_RELAXED);\n}\n\ninline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,\n                                         Atomic64 new_value) {\n  return __atomic_exchange_n(ptr, new_value, __ATOMIC_RELAXED);\n}\n\ninline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {\n  return __atomic_load_n(ptr, __ATOMIC_RELAXED);\n}\n\n#endif // defined(__LP64__)\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_GENERIC_GCC_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/atomicops_internals_macosx.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2012 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file is an internal atomic implementation, use atomicops.h instead.\n\n#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MACOSX_H_\n#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MACOSX_H_\n\n#include <libkern/OSAtomic.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\ninline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,\n                                         Atomic32 old_value,\n                                         Atomic32 new_value) {\n  Atomic32 prev_value;\n  do {\n    if (OSAtomicCompareAndSwap32(old_value, new_value,\n                                 const_cast<Atomic32*>(ptr))) {\n      return old_value;\n    }\n    prev_value = *ptr;\n  } while (prev_value == old_value);\n  return prev_value;\n}\n\ninline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,\n                                         Atomic32 new_value) {\n  Atomic32 old_value;\n  do {\n    old_value = *ptr;\n  } while (!OSAtomicCompareAndSwap32(old_value, new_value,\n                                     const_cast<Atomic32*>(ptr)));\n  return old_value;\n}\n\ninline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,\n                                          Atomic32 increment) {\n  return OSAtomicAdd32(increment, const_cast<Atomic32*>(ptr));\n}\n\ninline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,\n                                          Atomic32 increment) {\n  return OSAtomicAdd32Barrier(increment, const_cast<Atomic32*>(ptr));\n}\n\ninline void MemoryBarrier() {\n  OSMemoryBarrier();\n}\n\ninline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  Atomic32 prev_value;\n  do {\n    if (OSAtomicCompareAndSwap32Barrier(old_value, new_value,\n                                        const_cast<Atomic32*>(ptr))) {\n      return old_value;\n    }\n    prev_value = *ptr;\n  } while (prev_value == old_value);\n  return prev_value;\n}\n\ninline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  return Acquire_CompareAndSwap(ptr, old_value, new_value);\n}\n\ninline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {\n  *ptr = value;\n}\n\ninline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {\n  *ptr = value;\n  MemoryBarrier();\n}\n\ninline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {\n  MemoryBarrier();\n  *ptr = value;\n}\n\ninline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {\n  return *ptr;\n}\n\ninline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {\n  Atomic32 value = *ptr;\n  MemoryBarrier();\n  return value;\n}\n\ninline Atomic32 Release_Load(volatile const Atomic32* ptr) {\n  MemoryBarrier();\n  return *ptr;\n}\n\n#ifdef __LP64__\n\n// 64-bit implementation on 64-bit platform\n\ninline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,\n                                         Atomic64 old_value,\n                                         Atomic64 new_value) {\n  Atomic64 prev_value;\n  do {\n    if (OSAtomicCompareAndSwap64(old_value, new_value,\n                                 reinterpret_cast<volatile int64_t*>(ptr))) {\n      return old_value;\n    }\n    prev_value = *ptr;\n  } while (prev_value == old_value);\n  return prev_value;\n}\n\ninline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,\n                                         Atomic64 new_value) {\n  Atomic64 old_value;\n  do {\n    old_value = *ptr;\n  } while (!OSAtomicCompareAndSwap64(old_value, new_value,\n                                     reinterpret_cast<volatile int64_t*>(ptr)));\n  return old_value;\n}\n\ninline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,\n                                          Atomic64 increment) {\n  return OSAtomicAdd64(increment, reinterpret_cast<volatile int64_t*>(ptr));\n}\n\ninline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,\n                                        Atomic64 increment) {\n  return OSAtomicAdd64Barrier(increment,\n                              reinterpret_cast<volatile int64_t*>(ptr));\n}\n\ninline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,\n                                       Atomic64 old_value,\n                                       Atomic64 new_value) {\n  Atomic64 prev_value;\n  do {\n    if (OSAtomicCompareAndSwap64Barrier(\n        old_value, new_value, reinterpret_cast<volatile int64_t*>(ptr))) {\n      return old_value;\n    }\n    prev_value = *ptr;\n  } while (prev_value == old_value);\n  return prev_value;\n}\n\ninline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,\n                                       Atomic64 old_value,\n                                       Atomic64 new_value) {\n  // The lib kern interface does not distinguish between\n  // Acquire and Release memory barriers; they are equivalent.\n  return Acquire_CompareAndSwap(ptr, old_value, new_value);\n}\n\ninline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {\n  *ptr = value;\n}\n\ninline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {\n  *ptr = value;\n  MemoryBarrier();\n}\n\ninline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {\n  MemoryBarrier();\n  *ptr = value;\n}\n\ninline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {\n  return *ptr;\n}\n\ninline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {\n  Atomic64 value = *ptr;\n  MemoryBarrier();\n  return value;\n}\n\ninline Atomic64 Release_Load(volatile const Atomic64* ptr) {\n  MemoryBarrier();\n  return *ptr;\n}\n\n#endif  // defined(__LP64__)\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MACOSX_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/atomicops_internals_mips_gcc.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2012 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file is an internal atomic implementation, use atomicops.h instead.\n\n#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MIPS_GCC_H_\n#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MIPS_GCC_H_\n\n#define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__(\"\" : : : \"memory\")\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\n// Atomically execute:\n//      result = *ptr;\n//      if (*ptr == old_value)\n//        *ptr = new_value;\n//      return result;\n//\n// I.e., replace \"*ptr\" with \"new_value\" if \"*ptr\" used to be \"old_value\".\n// Always return the old value of \"*ptr\"\n//\n// This routine implies no memory barriers.\ninline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,\n                                         Atomic32 old_value,\n                                         Atomic32 new_value) {\n  Atomic32 prev, tmp;\n  __asm__ __volatile__(\".set push\\n\"\n                       \".set noreorder\\n\"\n                       \"1:\\n\"\n                       \"ll %0, %5\\n\"  // prev = *ptr\n                       \"bne %0, %3, 2f\\n\"  // if (prev != old_value) goto 2\n                       \"move %2, %4\\n\"  // tmp = new_value\n                       \"sc %2, %1\\n\"  // *ptr = tmp (with atomic check)\n                       \"beqz %2, 1b\\n\"  // start again on atomic error\n                       \"nop\\n\"  // delay slot nop\n                       \"2:\\n\"\n                       \".set pop\\n\"\n                       : \"=&r\" (prev), \"=m\" (*ptr), \"=&r\" (tmp)\n                       : \"r\" (old_value), \"r\" (new_value), \"m\" (*ptr)\n                       : \"memory\");\n  return prev;\n}\n\n// Atomically store new_value into *ptr, returning the previous value held in\n// *ptr.  This routine implies no memory barriers.\ninline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,\n                                         Atomic32 new_value) {\n  Atomic32 temp, old;\n  __asm__ __volatile__(\".set push\\n\"\n                       \".set noreorder\\n\"\n                       \"1:\\n\"\n                       \"ll %1, %4\\n\"  // old = *ptr\n                       \"move %0, %3\\n\"  // temp = new_value\n                       \"sc %0, %2\\n\"  // *ptr = temp (with atomic check)\n                       \"beqz %0, 1b\\n\"  // start again on atomic error\n                       \"nop\\n\"  // delay slot nop\n                       \".set pop\\n\"\n                       : \"=&r\" (temp), \"=&r\" (old), \"=m\" (*ptr)\n                       : \"r\" (new_value), \"m\" (*ptr)\n                       : \"memory\");\n\n  return old;\n}\n\n// Atomically increment *ptr by \"increment\".  Returns the new value of\n// *ptr with the increment applied.  This routine implies no memory barriers.\ninline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,\n                                          Atomic32 increment) {\n  Atomic32 temp, temp2;\n\n  __asm__ __volatile__(\".set push\\n\"\n                       \".set noreorder\\n\"\n                       \"1:\\n\"\n                       \"ll %0, %4\\n\"  // temp = *ptr\n                       \"addu %1, %0, %3\\n\"  // temp2 = temp + increment\n                       \"sc %1, %2\\n\"  // *ptr = temp2 (with atomic check)\n                       \"beqz %1, 1b\\n\"  // start again on atomic error\n                       \"addu %1, %0, %3\\n\"  // temp2 = temp + increment\n                       \".set pop\\n\"\n                       : \"=&r\" (temp), \"=&r\" (temp2), \"=m\" (*ptr)\n                       : \"Ir\" (increment), \"m\" (*ptr)\n                       : \"memory\");\n  // temp2 now holds the final value.\n  return temp2;\n}\n\ninline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,\n                                        Atomic32 increment) {\n  ATOMICOPS_COMPILER_BARRIER();\n  Atomic32 res = NoBarrier_AtomicIncrement(ptr, increment);\n  ATOMICOPS_COMPILER_BARRIER();\n  return res;\n}\n\n// \"Acquire\" operations\n// ensure that no later memory access can be reordered ahead of the operation.\n// \"Release\" operations ensure that no previous memory access can be reordered\n// after the operation.  \"Barrier\" operations have both \"Acquire\" and \"Release\"\n// semantics.   A MemoryBarrier() has \"Barrier\" semantics, but does no memory\n// access.\ninline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  ATOMICOPS_COMPILER_BARRIER();\n  Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n  ATOMICOPS_COMPILER_BARRIER();\n  return res;\n}\n\ninline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  ATOMICOPS_COMPILER_BARRIER();\n  Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n  ATOMICOPS_COMPILER_BARRIER();\n  return res;\n}\n\ninline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {\n  *ptr = value;\n}\n\ninline void MemoryBarrier() {\n  __asm__ __volatile__(\"sync\" : : : \"memory\");\n}\n\ninline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {\n  *ptr = value;\n  MemoryBarrier();\n}\n\ninline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {\n  MemoryBarrier();\n  *ptr = value;\n}\n\ninline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {\n  return *ptr;\n}\n\ninline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {\n  Atomic32 value = *ptr;\n  MemoryBarrier();\n  return value;\n}\n\ninline Atomic32 Release_Load(volatile const Atomic32* ptr) {\n  MemoryBarrier();\n  return *ptr;\n}\n\n#if defined(__LP64__)\n// 64-bit versions of the atomic ops.\n\ninline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,\n                                         Atomic64 old_value,\n                                         Atomic64 new_value) {\n  Atomic64 prev, tmp;\n  __asm__ __volatile__(\".set push\\n\"\n                       \".set noreorder\\n\"\n                       \"1:\\n\"\n                       \"lld %0, %5\\n\"  // prev = *ptr\n                       \"bne %0, %3, 2f\\n\"  // if (prev != old_value) goto 2\n                       \"move %2, %4\\n\"  // tmp = new_value\n                       \"scd %2, %1\\n\"  // *ptr = tmp (with atomic check)\n                       \"beqz %2, 1b\\n\"  // start again on atomic error\n                       \"nop\\n\"  // delay slot nop\n                       \"2:\\n\"\n                       \".set pop\\n\"\n                       : \"=&r\" (prev), \"=m\" (*ptr), \"=&r\" (tmp)\n                       : \"r\" (old_value), \"r\" (new_value), \"m\" (*ptr)\n                       : \"memory\");\n  return prev;\n}\n\n// Atomically store new_value into *ptr, returning the previous value held in\n// *ptr.  This routine implies no memory barriers.\ninline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,\n                                         Atomic64 new_value) {\n  Atomic64 temp, old;\n  __asm__ __volatile__(\".set push\\n\"\n                       \".set noreorder\\n\"\n                       \"1:\\n\"\n                       \"lld %1, %4\\n\"  // old = *ptr\n                       \"move %0, %3\\n\"  // temp = new_value\n                       \"scd %0, %2\\n\"  // *ptr = temp (with atomic check)\n                       \"beqz %0, 1b\\n\"  // start again on atomic error\n                       \"nop\\n\"  // delay slot nop\n                       \".set pop\\n\"\n                       : \"=&r\" (temp), \"=&r\" (old), \"=m\" (*ptr)\n                       : \"r\" (new_value), \"m\" (*ptr)\n                       : \"memory\");\n\n  return old;\n}\n\n// Atomically increment *ptr by \"increment\".  Returns the new value of\n// *ptr with the increment applied.  This routine implies no memory barriers.\ninline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,\n                                          Atomic64 increment) {\n  Atomic64 temp, temp2;\n\n  __asm__ __volatile__(\".set push\\n\"\n                       \".set noreorder\\n\"\n                       \"1:\\n\"\n                       \"lld %0, %4\\n\"  // temp = *ptr\n                       \"daddu %1, %0, %3\\n\"  // temp2 = temp + increment\n                       \"scd %1, %2\\n\"  // *ptr = temp2 (with atomic check)\n                       \"beqz %1, 1b\\n\"  // start again on atomic error\n                       \"daddu %1, %0, %3\\n\"  // temp2 = temp + increment\n                       \".set pop\\n\"\n                       : \"=&r\" (temp), \"=&r\" (temp2), \"=m\" (*ptr)\n                       : \"Ir\" (increment), \"m\" (*ptr)\n                       : \"memory\");\n  // temp2 now holds the final value.\n  return temp2;\n}\n\ninline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,\n                                        Atomic64 increment) {\n  MemoryBarrier();\n  Atomic64 res = NoBarrier_AtomicIncrement(ptr, increment);\n  MemoryBarrier();\n  return res;\n}\n\n// \"Acquire\" operations\n// ensure that no later memory access can be reordered ahead of the operation.\n// \"Release\" operations ensure that no previous memory access can be reordered\n// after the operation.  \"Barrier\" operations have both \"Acquire\" and \"Release\"\n// semantics.   A MemoryBarrier() has \"Barrier\" semantics, but does no memory\n// access.\ninline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,\n                                       Atomic64 old_value,\n                                       Atomic64 new_value) {\n  Atomic64 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n  MemoryBarrier();\n  return res;\n}\n\ninline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,\n                                       Atomic64 old_value,\n                                       Atomic64 new_value) {\n  MemoryBarrier();\n  return NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n}\n\ninline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {\n  *ptr = value;\n}\n\ninline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {\n  *ptr = value;\n  MemoryBarrier();\n}\n\ninline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {\n  MemoryBarrier();\n  *ptr = value;\n}\n\ninline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {\n  return *ptr;\n}\n\ninline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {\n  Atomic64 value = *ptr;\n  MemoryBarrier();\n  return value;\n}\n\ninline Atomic64 Release_Load(volatile const Atomic64* ptr) {\n  MemoryBarrier();\n  return *ptr;\n}\n#endif\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n#undef ATOMICOPS_COMPILER_BARRIER\n\n#endif  // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_MIPS_GCC_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/atomicops_internals_pnacl.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2012 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file is an internal atomic implementation, use atomicops.h instead.\n\n#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PNACL_H_\n#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PNACL_H_\n\n#include <atomic>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\n// This implementation is transitional and maintains the original API for\n// atomicops.h. This requires casting memory locations to the atomic types, and\n// assumes that the API and the C++11 implementation are layout-compatible,\n// which isn't true for all implementations or hardware platforms. The static\n// assertion should detect this issue, were it to fire then this header\n// shouldn't be used.\n//\n// TODO(jfb) If this header manages to stay committed then the API should be\n//           modified, and all call sites updated.\ntypedef volatile std::atomic<Atomic32>* AtomicLocation32;\nstatic_assert(sizeof(*(AtomicLocation32) nullptr) == sizeof(Atomic32),\n              \"incompatible 32-bit atomic layout\");\n\ninline void MemoryBarrier() {\n#if defined(__GLIBCXX__)\n  // Work around libstdc++ bug 51038 where atomic_thread_fence was declared but\n  // not defined, leading to the linker complaining about undefined references.\n  __atomic_thread_fence(std::memory_order_seq_cst);\n#else\n  std::atomic_thread_fence(std::memory_order_seq_cst);\n#endif\n}\n\ninline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,\n                                         Atomic32 old_value,\n                                         Atomic32 new_value) {\n  ((AtomicLocation32)ptr)\n      ->compare_exchange_strong(old_value,\n                                new_value,\n                                std::memory_order_relaxed,\n                                std::memory_order_relaxed);\n  return old_value;\n}\n\ninline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,\n                                         Atomic32 new_value) {\n  return ((AtomicLocation32)ptr)\n      ->exchange(new_value, std::memory_order_relaxed);\n}\n\ninline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,\n                                          Atomic32 increment) {\n  return increment +\n         ((AtomicLocation32)ptr)\n             ->fetch_add(increment, std::memory_order_relaxed);\n}\n\ninline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,\n                                        Atomic32 increment) {\n  return increment + ((AtomicLocation32)ptr)->fetch_add(increment);\n}\n\ninline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  ((AtomicLocation32)ptr)\n      ->compare_exchange_strong(old_value,\n                                new_value,\n                                std::memory_order_acquire,\n                                std::memory_order_acquire);\n  return old_value;\n}\n\ninline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  ((AtomicLocation32)ptr)\n      ->compare_exchange_strong(old_value,\n                                new_value,\n                                std::memory_order_release,\n                                std::memory_order_relaxed);\n  return old_value;\n}\n\ninline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {\n  ((AtomicLocation32)ptr)->store(value, std::memory_order_relaxed);\n}\n\ninline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {\n  ((AtomicLocation32)ptr)->store(value, std::memory_order_relaxed);\n  MemoryBarrier();\n}\n\ninline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {\n  ((AtomicLocation32)ptr)->store(value, std::memory_order_release);\n}\n\ninline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {\n  return ((AtomicLocation32)ptr)->load(std::memory_order_relaxed);\n}\n\ninline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {\n  return ((AtomicLocation32)ptr)->load(std::memory_order_acquire);\n}\n\ninline Atomic32 Release_Load(volatile const Atomic32* ptr) {\n  MemoryBarrier();\n  return ((AtomicLocation32)ptr)->load(std::memory_order_relaxed);\n}\n\n#if defined(GOOGLE_PROTOBUF_ARCH_64_BIT)\n\ntypedef volatile std::atomic<Atomic64>* AtomicLocation64;\nstatic_assert(sizeof(*(AtomicLocation64) nullptr) == sizeof(Atomic64),\n              \"incompatible 64-bit atomic layout\");\n\ninline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,\n                                         Atomic64 old_value,\n                                         Atomic64 new_value) {\n  ((AtomicLocation64)ptr)\n      ->compare_exchange_strong(old_value,\n                                new_value,\n                                std::memory_order_relaxed,\n                                std::memory_order_relaxed);\n  return old_value;\n}\n\ninline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,\n                                         Atomic64 new_value) {\n  return ((AtomicLocation64)ptr)\n      ->exchange(new_value, std::memory_order_relaxed);\n}\n\ninline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,\n                                          Atomic64 increment) {\n  return increment +\n         ((AtomicLocation64)ptr)\n             ->fetch_add(increment, std::memory_order_relaxed);\n}\n\ninline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,\n                                        Atomic64 increment) {\n  return increment + ((AtomicLocation64)ptr)->fetch_add(increment);\n}\n\ninline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,\n                                       Atomic64 old_value,\n                                       Atomic64 new_value) {\n  ((AtomicLocation64)ptr)\n      ->compare_exchange_strong(old_value,\n                                new_value,\n                                std::memory_order_acquire,\n                                std::memory_order_acquire);\n  return old_value;\n}\n\ninline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,\n                                       Atomic64 old_value,\n                                       Atomic64 new_value) {\n  ((AtomicLocation64)ptr)\n      ->compare_exchange_strong(old_value,\n                                new_value,\n                                std::memory_order_release,\n                                std::memory_order_relaxed);\n  return old_value;\n}\n\ninline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {\n  ((AtomicLocation64)ptr)->store(value, std::memory_order_relaxed);\n}\n\ninline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {\n  ((AtomicLocation64)ptr)->store(value, std::memory_order_relaxed);\n  MemoryBarrier();\n}\n\ninline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {\n  ((AtomicLocation64)ptr)->store(value, std::memory_order_release);\n}\n\ninline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {\n  return ((AtomicLocation64)ptr)->load(std::memory_order_relaxed);\n}\n\ninline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {\n  return ((AtomicLocation64)ptr)->load(std::memory_order_acquire);\n}\n\ninline Atomic64 Release_Load(volatile const Atomic64* ptr) {\n  MemoryBarrier();\n  return ((AtomicLocation64)ptr)->load(std::memory_order_relaxed);\n}\n\n#endif  // defined(GOOGLE_PROTOBUF_ARCH_64_BIT)\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PNACL_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/atomicops_internals_power.h",
    "content": "// Copyright 2014 Bloomberg Finance LP. All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Bloomberg Finance LP. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file is an internal atomic implementation, use atomicops.h instead.\n\n#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_AIX_H_\n#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_AIX_H_\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\ninline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,\n                                         Atomic32 old_value,\n                                         Atomic32 new_value) {\n  Atomic32 result;\n\n  asm volatile (\n      \"1:     lwarx %[res], %[zero], %[obj]   \\n\\t\"  // load and reserve\n      \"       cmpw %[cmp], %[res]             \\n\\t\"  // compare values\n      \"       bne- 2f                         \\n\\t\"\n      \"       stwcx. %[val], %[zero], %[obj]  \\n\\t\"  // store new value\n      \"       bne- 1b                         \\n\\t\"\n      \"2:                                     \\n\\t\"\n              : [res]  \"=&b\" (result)\n              : [obj]  \"b\"   (ptr),\n                [cmp]  \"b\"   (old_value),\n                [val]  \"b\"   (new_value),\n                [zero] \"i\"   (0)\n              : \"cr0\", \"ctr\");\n\n  return result;\n}\n\ninline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,\n                                         Atomic32 new_value) {\n  Atomic32 result;\n\n  asm volatile (\n      \"1:     lwarx %[res], %[zero], %[obj]       \\n\\t\"\n      \"       stwcx. %[val], %[zero], %[obj]      \\n\\t\"\n      \"       bne- 1b                             \\n\\t\"\n              : [res]  \"=&b\" (result)\n              : [obj]  \"b\"   (ptr),\n                [val]  \"b\"   (new_value),\n                [zero] \"i\"   (0)\n              : \"cr0\", \"ctr\");\n\n  return result;\n}\n\ninline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,\n                                          Atomic32 increment) {\n  Atomic32 result;\n\n  asm volatile (\n      \"1:     lwarx %[res], %[zero], %[obj]   \\n\\t\"  // load and reserve\n      \"       add %[res], %[val], %[res]      \\n\\t\"  // add the operand\n      \"       stwcx. %[res], %[zero], %[obj]  \\n\\t\"  // store old value\n                                                     // if still reserved\n      \"       bne- 1b                         \\n\\t\"\n              : [res]  \"=&b\" (result)\n              : [obj]  \"b\"   (ptr),\n                [val]  \"b\"   (increment),\n                [zero] \"i\"   (0)\n              : \"cr0\", \"ctr\");\n\n  return result;\n}\n\ninline void MemoryBarrier(void) {\n  asm volatile (\n      \"       lwsync                          \\n\\t\"\n      \"       isync                           \\n\\t\"\n              :\n              :\n              : \"memory\");\n}\n\ninline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,\n                                        Atomic32 increment) {\n  Atomic32 result;\n\n  asm volatile (\n      \"       lwsync                          \\n\\t\"\n\n      \"1:     lwarx %[res], %[zero], %[obj]   \\n\\t\"  // load and reserve\n      \"       add %[res], %[val], %[res]      \\n\\t\"  // add the operand\n      \"       stwcx. %[res], %[zero], %[obj]  \\n\\t\"  // store old value\n                                                     // if still reserved\n      \"       bne- 1b                         \\n\\t\"\n      \"       isync                           \\n\\t\"\n              : [res]  \"=&b\" (result)\n              : [obj]  \"b\"   (ptr),\n                [val]  \"b\"   (increment),\n                [zero] \"i\"   (0)\n              : \"cr0\", \"ctr\");\n\n  return result;\n}\n\ninline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  Atomic32 result;\n\n  asm volatile (\n      \"1:     lwarx %[res], %[zero], %[obj]   \\n\\t\"  // load and reserve\n      \"       cmpw %[cmp], %[res]             \\n\\t\"  // compare values\n      \"       bne- 2f                         \\n\\t\"\n      \"       stwcx. %[val], %[zero], %[obj]  \\n\\t\"  // store new value\n      \"       bne- 1b                         \\n\\t\"\n\n      \"       isync                           \\n\\t\"\n      \"2:                                     \\n\\t\"\n              : [res]  \"=&b\" (result)\n              : [obj]  \"b\"   (ptr),\n                [cmp]  \"b\"   (old_value),\n                [val]  \"b\"   (new_value),\n                [zero] \"i\"   (0)\n              : \"cr0\", \"ctr\");\n\n  return result;\n}\n\ninline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  Atomic32 result;\n\n  asm volatile (\n      \"       lwsync                          \\n\\t\"\n\n      \"1:     lwarx %[res], %[zero], %[obj]   \\n\\t\"  // load and reserve\n      \"       cmpw %[cmp], %[res]             \\n\\t\"  // compare values\n      \"       bne- 2f                         \\n\\t\"\n      \"       stwcx. %[val], %[zero], %[obj]  \\n\\t\"  // store new value\n      \"       bne- 1b                         \\n\\t\"\n\n      \"2:                                     \\n\\t\"\n              : [res]  \"=&b\" (result)\n              : [obj]  \"b\"   (ptr),\n                [cmp]  \"b\"   (old_value),\n                [val]  \"b\"   (new_value),\n                [zero] \"i\"   (0)\n              : \"cr0\", \"ctr\");\n\n  return result;\n}\n\ninline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {\n  *ptr = value;\n}\n\ninline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {\n  asm volatile (\n      \"       stw %[val], %[obj]      \\n\\t\"\n      \"       isync                   \\n\\t\"\n              : [obj] \"=m\" (*ptr)\n              : [val]  \"b\"  (value));\n}\n\ninline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {\n  asm volatile (\n      \"       lwsync                  \\n\\t\"\n      \"       stw %[val], %[obj]      \\n\\t\"\n              : [obj] \"=m\" (*ptr)\n              : [val]  \"b\"  (value));\n}\n\ninline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {\n  return *ptr;\n}\n\ninline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {\n  Atomic32 result;\n\n  asm volatile (\n      \"1:     lwz %[res], %[obj]              \\n\\t\"\n      \"       cmpw %[res], %[res]             \\n\\t\" // create data\n                                                    // dependency for\n                                                    // load/load ordering\n      \"       bne- 1b                         \\n\\t\" // never taken\n\n      \"       isync                           \\n\\t\"\n              : [res]  \"=b\" (result)\n              : [obj]  \"m\"  (*ptr),\n                [zero] \"i\"  (0)\n              : \"cr0\", \"ctr\");\n\n  return result;\n}\n\ninline Atomic32 Release_Load(volatile const Atomic32* ptr) {\n  Atomic32 result;\n\n  asm volatile (\n      \"       lwsync                          \\n\\t\"\n\n      \"1:     lwz %[res], %[obj]              \\n\\t\"\n      \"       cmpw %[res], %[res]             \\n\\t\" // create data\n                                                    // dependency for\n                                                    // load/load ordering\n      \"       bne- 1b                         \\n\\t\" // never taken\n              : [res]  \"=b\" (result)\n              : [obj]  \"m\"  (*ptr),\n                [zero] \"i\"  (0)\n              : \"cr0\", \"ctr\");\n\n  return result;\n}\n\n#ifdef GOOGLE_PROTOBUF_ARCH_64_BIT\ninline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,\n                                         Atomic64 old_value,\n                                         Atomic64 new_value) {\n  Atomic64 result;\n\n  asm volatile (\n      \"1:     ldarx %[res], %[zero], %[obj]   \\n\\t\"  // load and reserve\n      \"       cmpd %[cmp], %[res]             \\n\\t\"  // compare values\n      \"       bne- 2f                         \\n\\t\"\n\n      \"       stdcx. %[val], %[zero], %[obj]  \\n\\t\"  // store the new value\n      \"       bne- 1b                         \\n\\t\"\n      \"2:                                     \\n\\t\"\n              : [res]  \"=&b\" (result)\n              : [obj]  \"b\"   (ptr),\n                [cmp]  \"b\"   (old_value),\n                [val]  \"b\"   (new_value),\n                [zero] \"i\"   (0)\n              : \"cr0\", \"ctr\");\n\n  return result;\n}\n\ninline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,\n                                         Atomic64 new_value) {\n  Atomic64 result;\n\n  asm volatile (\n      \"1:     ldarx %[res], %[zero], %[obj]       \\n\\t\"\n      \"       stdcx. %[val], %[zero], %[obj]      \\n\\t\"\n      \"       bne- 1b                             \\n\\t\"\n              : [res]  \"=&b\" (result)\n              : [obj]  \"b\"   (ptr),\n                [val]  \"b\"   (new_value),\n                [zero] \"i\"   (0)\n              : \"cr0\", \"ctr\");\n\n  return result;\n}\n\ninline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,\n                                          Atomic64 increment) {\n  Atomic64 result;\n\n  asm volatile (\n      \"1:     ldarx %[res], %[zero], %[obj]   \\n\\t\" // load and reserve\n      \"       add %[res], %[res], %[val]      \\n\\t\" // add the operand\n      \"       stdcx. %[res], %[zero], %[obj]  \\n\\t\" // store old value if\n                                                    // still reserved\n\n      \"       bne- 1b                         \\n\\t\"\n              : [res]  \"=&b\" (result)\n              : [obj]  \"b\"   (ptr),\n                [val]  \"b\"   (increment),\n                [zero] \"i\"   (0)\n              : \"cr0\", \"ctr\");\n\n  return result;\n}\n\ninline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,\n                                        Atomic64 increment) {\n\n  Atomic64 result;\n\n  asm volatile (\n      \"       lwsync                          \\n\\t\"\n\n      \"1:     ldarx %[res], %[zero], %[obj]   \\n\\t\" // load and reserve\n      \"       add %[res], %[res], %[val]      \\n\\t\" // add the operand\n      \"       stdcx. %[res], %[zero], %[obj]  \\n\\t\" // store old value if\n                                                    // still reserved\n\n      \"       bne- 1b                         \\n\\t\"\n\n      \"       isync                           \\n\\t\"\n              : [res]  \"=&b\" (result)\n              : [obj]  \"b\"   (ptr),\n                [val]  \"b\"   (increment),\n                [zero] \"i\"   (0)\n              : \"cr0\", \"ctr\");\n\n  return result;\n}\n\ninline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,\n                                       Atomic64 old_value,\n                                       Atomic64 new_value) {\n  Atomic64 result;\n\n  asm volatile (\n      \"1:     ldarx %[res], %[zero], %[obj]   \\n\\t\"  // load and reserve\n      \"       cmpd %[cmp], %[res]             \\n\\t\"  // compare values\n      \"       bne- 2f                         \\n\\t\"\n\n      \"       stdcx. %[val], %[zero], %[obj]  \\n\\t\"  // store the new value\n      \"       bne- 1b                         \\n\\t\"\n      \"       isync                           \\n\\t\"\n      \"2:                                     \\n\\t\"\n              : [res]  \"=&b\" (result)\n              : [obj]  \"b\"   (ptr),\n                [cmp]  \"b\"   (old_value),\n                [val]  \"b\"   (new_value),\n                [zero] \"i\"   (0)\n              : \"cr0\", \"ctr\");\n\n  return result;\n}\n\ninline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,\n                                       Atomic64 old_value,\n                                       Atomic64 new_value) {\n  Atomic64 result;\n\n  asm volatile (\n      \"       lwsync                          \\n\\t\"\n\n      \"1:     ldarx %[res], %[zero], %[obj]   \\n\\t\"  // load and reserve\n      \"       cmpd %[cmp], %[res]             \\n\\t\"  // compare values\n      \"       bne- 2f                         \\n\\t\"\n\n      \"       stdcx. %[val], %[zero], %[obj]  \\n\\t\"  // store the new value\n      \"       bne- 1b                         \\n\\t\"\n      \"2:                                     \\n\\t\"\n              : [res]  \"=&b\" (result)\n              : [obj]  \"b\"   (ptr),\n                [cmp]  \"b\"   (old_value),\n                [val]  \"b\"   (new_value),\n                [zero] \"i\"   (0)\n              : \"cr0\", \"ctr\");\n\n  return result;\n}\n\ninline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {\n  *ptr = value;\n}\n\ninline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {\n  asm volatile (\n      \"       std %[val], %[obj]          \\n\\t\"\n      \"       isync                       \\n\\t\"\n              : [obj] \"=m\" (*ptr)\n              : [val] \"b\"  (value));\n}\n\ninline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {\n  asm volatile (\n      \"       lwsync                      \\n\\t\"\n      \"       std %[val], %[obj]          \\n\\t\"\n              : [obj] \"=m\" (*ptr)\n              : [val] \"b\"  (value));\n}\n\ninline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {\n  return *ptr;\n}\n\ninline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {\n  Atomic64 result;\n\n  asm volatile (\n      \"1:     ld %[res], %[obj]                   \\n\\t\"\n      \"       cmpd %[res], %[res]                 \\n\\t\" // create data\n                                                        // dependency for\n                                                        // load/load ordering\n      \"       bne- 1b                             \\n\\t\" // never taken\n\n      \"       isync                               \\n\\t\"\n              : [res]  \"=b\" (result)\n              : [obj]  \"m\"  (*ptr),\n                [zero] \"i\"  (0)\n              : \"cr0\", \"ctr\");\n\n  return result;\n}\n\ninline Atomic64 Release_Load(volatile const Atomic64* ptr) {\n  Atomic64 result;\n\n  asm volatile (\n      \"       lwsync                              \\n\\t\"\n\n      \"1:     ld %[res], %[obj]                   \\n\\t\"\n      \"       cmpd %[res], %[res]                 \\n\\t\" // create data\n                                                        // dependency for\n                                                        // load/load ordering\n      \"       bne- 1b                             \\n\\t\" // never taken\n              : [res]  \"=b\" (result)\n              : [obj]  \"m\"  (*ptr),\n                [zero] \"i\"  (0)\n              : \"cr0\", \"ctr\");\n\n  return result;\n}\n#endif\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_SPARC_GCC_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/atomicops_internals_ppc_gcc.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2015 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: ogabbay@advaoptical.com (Oded Gabbay)\n// Cleaned up by: bsilver16384@gmail.com (Brian Silverman)\n//\n// This file is an internal atomic implementation, use atomicops.h instead.\n\n#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PPC_GCC_H_\n#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PPC_GCC_H_\n\n#define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__(\"\" : : : \"memory\")\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\ninline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32 *ptr,\n                                         Atomic32 old_value,\n                                         Atomic32 new_value) {\n  Atomic32 prev;\n\n  __asm__ __volatile__(\n      \"0:                                  \\n\\t\"\n      \"lwarx %[prev],0,%[ptr]              \\n\\t\"\n      \"cmpw 0,%[prev],%[old_value]         \\n\\t\"\n      \"bne- 1f                             \\n\\t\"\n      \"stwcx. %[new_value],0,%[ptr]        \\n\\t\"\n      \"bne- 0b                             \\n\\t\"\n      \"1:                                  \\n\\t\"\n      : [prev] \"=&r\"(prev), \"+m\"(*ptr)\n      : [ptr] \"r\"(ptr), [old_value] \"r\"(old_value), [new_value] \"r\"(new_value)\n      : \"cc\", \"memory\");\n\n  return prev;\n}\n\ninline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32 *ptr,\n                                         Atomic32 new_value) {\n  Atomic32 old;\n\n  __asm__ __volatile__(\n      \"0:                                  \\n\\t\"\n      \"lwarx %[old],0,%[ptr]               \\n\\t\"\n      \"stwcx. %[new_value],0,%[ptr]        \\n\\t\"\n      \"bne- 0b                             \\n\\t\"\n      : [old] \"=&r\"(old), \"+m\"(*ptr)\n      : [ptr] \"r\"(ptr), [new_value] \"r\"(new_value)\n      : \"cc\", \"memory\");\n\n  return old;\n}\n\ninline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32 *ptr,\n                                          Atomic32 increment) {\n  Atomic32 temp;\n\n  __asm__ __volatile__(\n      \"0:                                  \\n\\t\"\n      \"lwarx %[temp],0,%[ptr]              \\n\\t\"\n      \"add %[temp],%[increment],%[temp]    \\n\\t\"\n      \"stwcx. %[temp],0,%[ptr]             \\n\\t\"\n      \"bne- 0b                             \\n\\t\"\n      : [temp] \"=&r\"(temp)\n      : [increment] \"r\"(increment), [ptr] \"r\"(ptr)\n      : \"cc\", \"memory\");\n\n  return temp;\n}\n\ninline Atomic32 Barrier_AtomicIncrement(volatile Atomic32 *ptr,\n                                        Atomic32 increment) {\n  MemoryBarrier();\n  Atomic32 res = NoBarrier_AtomicIncrement(ptr, increment);\n  MemoryBarrier();\n  return res;\n}\n\ninline Atomic32 Acquire_CompareAndSwap(volatile Atomic32 *ptr,\n                                       Atomic32 old_value, Atomic32 new_value) {\n  Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n  MemoryBarrier();\n  return res;\n}\n\ninline Atomic32 Release_CompareAndSwap(volatile Atomic32 *ptr,\n                                       Atomic32 old_value, Atomic32 new_value) {\n  MemoryBarrier();\n  Atomic32 res = NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n  return res;\n}\n\ninline void NoBarrier_Store(volatile Atomic32 *ptr, Atomic32 value) {\n  *ptr = value;\n}\n\ninline void MemoryBarrier() { __asm__ __volatile__(\"sync\" : : : \"memory\"); }\n\ninline void Acquire_Store(volatile Atomic32 *ptr, Atomic32 value) {\n  *ptr = value;\n  MemoryBarrier();\n}\n\ninline void Release_Store(volatile Atomic32 *ptr, Atomic32 value) {\n  MemoryBarrier();\n  *ptr = value;\n}\n\ninline Atomic32 NoBarrier_Load(volatile const Atomic32 *ptr) { return *ptr; }\n\ninline Atomic32 Acquire_Load(volatile const Atomic32 *ptr) {\n  Atomic32 value = *ptr;\n  MemoryBarrier();\n  return value;\n}\n\ninline Atomic32 Release_Load(volatile const Atomic32 *ptr) {\n  MemoryBarrier();\n  return *ptr;\n}\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n#undef ATOMICOPS_COMPILER_BARRIER\n\n#endif  // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_PPC_GCC_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/atomicops_internals_solaris.h",
    "content": "// Copyright 2014 Google Inc. All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file is an internal atomic implementation, use atomicops.h instead.\n\n#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_SPARC_GCC_H_\n#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_SPARC_GCC_H_\n\n#include <atomic.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\ninline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,\n                                         Atomic32 old_value,\n                                         Atomic32 new_value) {\n  return (Atomic32)atomic_cas_32((volatile uint32_t*)ptr, (uint32_t)old_value, (uint32_t)new_value);\n}\n\ninline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,\n                                         Atomic32 new_value) {\n  return (Atomic32)atomic_swap_32((volatile uint32_t*)ptr, (uint32_t)new_value);\n}\n\ninline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,\n                                          Atomic32 increment) {\n  return (Atomic32)atomic_add_32_nv((volatile uint32_t*)ptr, (uint32_t)increment);\n}\n\ninline void MemoryBarrier(void) {\n\tmembar_producer();\n\tmembar_consumer();\n}\n\ninline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,\n                                        Atomic32 increment) {\n  MemoryBarrier();\n  Atomic32 ret = NoBarrier_AtomicIncrement(ptr, increment);\n  MemoryBarrier();\n\n  return ret;\n}\n\ninline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  Atomic32 ret = NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n  MemoryBarrier();\n\n  return ret;\n}\n\ninline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  MemoryBarrier();\n  return NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n}\n\ninline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {\n  *ptr = value;\n}\n\ninline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {\n  *ptr = value;\n  membar_producer();\n}\n\ninline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {\n  membar_consumer();\n  *ptr = value;\n}\n\ninline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {\n  return *ptr;\n}\n\ninline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {\n  Atomic32 val = *ptr;\n  membar_consumer();\n  return val;\n}\n\ninline Atomic32 Release_Load(volatile const Atomic32* ptr) {\n  membar_producer();\n  return *ptr;\n}\n\n#ifdef GOOGLE_PROTOBUF_ARCH_64_BIT\ninline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,\n                                         Atomic64 old_value,\n                                         Atomic64 new_value) {\n  return atomic_cas_64((volatile uint64_t*)ptr, (uint64_t)old_value, (uint64_t)new_value);\n}\n\ninline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr, Atomic64 new_value) {\n  return atomic_swap_64((volatile uint64_t*)ptr, (uint64_t)new_value);\n}\n\ninline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment) {\n  return atomic_add_64_nv((volatile uint64_t*)ptr, increment);\n}\n\ninline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr, Atomic64 increment) {\n  MemoryBarrier();\n  Atomic64 ret = atomic_add_64_nv((volatile uint64_t*)ptr, increment);\n  MemoryBarrier();\n  return ret;\n}\n\ninline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,\n                                       Atomic64 old_value,\n                                       Atomic64 new_value) {\n  Atomic64 ret = NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n  MemoryBarrier();\n  return ret;\n}\n\ninline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,\n                                       Atomic64 old_value,\n                                       Atomic64 new_value) {\n  MemoryBarrier();\n  return NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n}\n\ninline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {\n  *ptr = value;\n}\n\ninline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {\n  *ptr = value;\n  membar_producer();\n}\n\ninline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {\n  membar_consumer();\n  *ptr = value;\n}\n\ninline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {\n  return *ptr;\n}\n\ninline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {\n  Atomic64 ret = *ptr;\n  membar_consumer();\n  return ret;\n}\n\ninline Atomic64 Release_Load(volatile const Atomic64* ptr) {\n  membar_producer();\n  return *ptr;\n}\n#endif\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_SPARC_GCC_H_\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/atomicops_internals_tsan.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2013 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file is an internal atomic implementation for compiler-based\n// ThreadSanitizer (http://clang.llvm.org/docs/ThreadSanitizer.html).\n// Use atomicops.h instead.\n\n#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_TSAN_H_\n#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_TSAN_H_\n\n#define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__(\"\" : : : \"memory\")\n\n#include <sanitizer/tsan_interface_atomic.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\ninline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32 *ptr,\n                                         Atomic32 old_value,\n                                         Atomic32 new_value) {\n  Atomic32 cmp = old_value;\n  __tsan_atomic32_compare_exchange_strong(ptr, &cmp, new_value,\n      __tsan_memory_order_relaxed, __tsan_memory_order_relaxed);\n  return cmp;\n}\n\ninline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32 *ptr,\n                                         Atomic32 new_value) {\n  return __tsan_atomic32_exchange(ptr, new_value,\n      __tsan_memory_order_relaxed);\n}\n\ninline Atomic32 Acquire_AtomicExchange(volatile Atomic32 *ptr,\n                                       Atomic32 new_value) {\n  return __tsan_atomic32_exchange(ptr, new_value,\n      __tsan_memory_order_acquire);\n}\n\ninline Atomic32 Release_AtomicExchange(volatile Atomic32 *ptr,\n                                       Atomic32 new_value) {\n  return __tsan_atomic32_exchange(ptr, new_value,\n      __tsan_memory_order_release);\n}\n\ninline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32 *ptr,\n                                          Atomic32 increment) {\n  return increment + __tsan_atomic32_fetch_add(ptr, increment,\n      __tsan_memory_order_relaxed);\n}\n\ninline Atomic32 Barrier_AtomicIncrement(volatile Atomic32 *ptr,\n                                        Atomic32 increment) {\n  return increment + __tsan_atomic32_fetch_add(ptr, increment,\n      __tsan_memory_order_acq_rel);\n}\n\ninline Atomic32 Acquire_CompareAndSwap(volatile Atomic32 *ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  Atomic32 cmp = old_value;\n  __tsan_atomic32_compare_exchange_strong(ptr, &cmp, new_value,\n      __tsan_memory_order_acquire, __tsan_memory_order_acquire);\n  return cmp;\n}\n\ninline Atomic32 Release_CompareAndSwap(volatile Atomic32 *ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  Atomic32 cmp = old_value;\n  __tsan_atomic32_compare_exchange_strong(ptr, &cmp, new_value,\n      __tsan_memory_order_release, __tsan_memory_order_relaxed);\n  return cmp;\n}\n\ninline void NoBarrier_Store(volatile Atomic32 *ptr, Atomic32 value) {\n  __tsan_atomic32_store(ptr, value, __tsan_memory_order_relaxed);\n}\n\ninline void Acquire_Store(volatile Atomic32 *ptr, Atomic32 value) {\n  __tsan_atomic32_store(ptr, value, __tsan_memory_order_relaxed);\n  __tsan_atomic_thread_fence(__tsan_memory_order_seq_cst);\n}\n\ninline void Release_Store(volatile Atomic32 *ptr, Atomic32 value) {\n  __tsan_atomic32_store(ptr, value, __tsan_memory_order_release);\n}\n\ninline Atomic32 NoBarrier_Load(volatile const Atomic32 *ptr) {\n  return __tsan_atomic32_load(ptr, __tsan_memory_order_relaxed);\n}\n\ninline Atomic32 Acquire_Load(volatile const Atomic32 *ptr) {\n  return __tsan_atomic32_load(ptr, __tsan_memory_order_acquire);\n}\n\ninline Atomic32 Release_Load(volatile const Atomic32 *ptr) {\n  __tsan_atomic_thread_fence(__tsan_memory_order_seq_cst);\n  return __tsan_atomic32_load(ptr, __tsan_memory_order_relaxed);\n}\n\ninline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64 *ptr,\n                                         Atomic64 old_value,\n                                         Atomic64 new_value) {\n  Atomic64 cmp = old_value;\n  __tsan_atomic64_compare_exchange_strong(ptr, &cmp, new_value,\n      __tsan_memory_order_relaxed, __tsan_memory_order_relaxed);\n  return cmp;\n}\n\ninline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64 *ptr,\n                                         Atomic64 new_value) {\n  return __tsan_atomic64_exchange(ptr, new_value, __tsan_memory_order_relaxed);\n}\n\ninline Atomic64 Acquire_AtomicExchange(volatile Atomic64 *ptr,\n                                       Atomic64 new_value) {\n  return __tsan_atomic64_exchange(ptr, new_value, __tsan_memory_order_acquire);\n}\n\ninline Atomic64 Release_AtomicExchange(volatile Atomic64 *ptr,\n                                       Atomic64 new_value) {\n  return __tsan_atomic64_exchange(ptr, new_value, __tsan_memory_order_release);\n}\n\ninline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64 *ptr,\n                                          Atomic64 increment) {\n  return increment + __tsan_atomic64_fetch_add(ptr, increment,\n      __tsan_memory_order_relaxed);\n}\n\ninline Atomic64 Barrier_AtomicIncrement(volatile Atomic64 *ptr,\n                                        Atomic64 increment) {\n  return increment + __tsan_atomic64_fetch_add(ptr, increment,\n      __tsan_memory_order_acq_rel);\n}\n\ninline void NoBarrier_Store(volatile Atomic64 *ptr, Atomic64 value) {\n  __tsan_atomic64_store(ptr, value, __tsan_memory_order_relaxed);\n}\n\ninline void Acquire_Store(volatile Atomic64 *ptr, Atomic64 value) {\n  __tsan_atomic64_store(ptr, value, __tsan_memory_order_relaxed);\n  __tsan_atomic_thread_fence(__tsan_memory_order_seq_cst);\n}\n\ninline void Release_Store(volatile Atomic64 *ptr, Atomic64 value) {\n  __tsan_atomic64_store(ptr, value, __tsan_memory_order_release);\n}\n\ninline Atomic64 NoBarrier_Load(volatile const Atomic64 *ptr) {\n  return __tsan_atomic64_load(ptr, __tsan_memory_order_relaxed);\n}\n\ninline Atomic64 Acquire_Load(volatile const Atomic64 *ptr) {\n  return __tsan_atomic64_load(ptr, __tsan_memory_order_acquire);\n}\n\ninline Atomic64 Release_Load(volatile const Atomic64 *ptr) {\n  __tsan_atomic_thread_fence(__tsan_memory_order_seq_cst);\n  return __tsan_atomic64_load(ptr, __tsan_memory_order_relaxed);\n}\n\ninline Atomic64 Acquire_CompareAndSwap(volatile Atomic64 *ptr,\n                                       Atomic64 old_value,\n                                       Atomic64 new_value) {\n  Atomic64 cmp = old_value;\n  __tsan_atomic64_compare_exchange_strong(ptr, &cmp, new_value,\n      __tsan_memory_order_acquire, __tsan_memory_order_acquire);\n  return cmp;\n}\n\ninline Atomic64 Release_CompareAndSwap(volatile Atomic64 *ptr,\n                                       Atomic64 old_value,\n                                       Atomic64 new_value) {\n  Atomic64 cmp = old_value;\n  __tsan_atomic64_compare_exchange_strong(ptr, &cmp, new_value,\n      __tsan_memory_order_release, __tsan_memory_order_relaxed);\n  return cmp;\n}\n\ninline void MemoryBarrier() {\n  __tsan_atomic_thread_fence(__tsan_memory_order_seq_cst);\n}\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n#undef ATOMICOPS_COMPILER_BARRIER\n\n#endif  // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_TSAN_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2012 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This module gets enough CPU information to optimize the\n// atomicops module on x86.\n\n#include <cstring>\n\n#include <google/protobuf/stubs/atomicops.h>\n\n// This file only makes sense with atomicops_internals_x86_gcc.h -- it\n// depends on structs that are defined in that file.  If atomicops.h\n// doesn't sub-include that file, then we aren't needed, and shouldn't\n// try to do anything.\n#ifdef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_GCC_H_\n\n// Inline cpuid instruction.  In PIC compilations, %ebx contains the address\n// of the global offset table.  To avoid breaking such executables, this code\n// must preserve that register's value across cpuid instructions.\n#if defined(__i386__)\n#define cpuid(a, b, c, d, inp) \\\n  asm(\"mov %%ebx, %%edi\\n\"     \\\n      \"cpuid\\n\"                \\\n      \"xchg %%edi, %%ebx\\n\"    \\\n      : \"=a\" (a), \"=D\" (b), \"=c\" (c), \"=d\" (d) : \"a\" (inp))\n#elif defined(__x86_64__)\n#define cpuid(a, b, c, d, inp) \\\n  asm(\"mov %%rbx, %%rdi\\n\"     \\\n      \"cpuid\\n\"                \\\n      \"xchg %%rdi, %%rbx\\n\"    \\\n      : \"=a\" (a), \"=D\" (b), \"=c\" (c), \"=d\" (d) : \"a\" (inp))\n#endif\n\n#if defined(cpuid)        // initialize the struct only on x86\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\n// Set the flags so that code will run correctly and conservatively, so even\n// if we haven't been initialized yet, we're probably single threaded, and our\n// default values should hopefully be pretty safe.\nstruct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures = {\n  false,          // bug can't exist before process spawns multiple threads\n  false,          // no SSE2\n};\n\nnamespace {\n\n// Initialize the AtomicOps_Internalx86CPUFeatures struct.\nvoid AtomicOps_Internalx86CPUFeaturesInit() {\n  uint32_t eax;\n  uint32_t ebx;\n  uint32_t ecx;\n  uint32_t edx;\n\n  // Get vendor string (issue CPUID with eax = 0)\n  cpuid(eax, ebx, ecx, edx, 0);\n  char vendor[13];\n  memcpy(vendor, &ebx, 4);\n  memcpy(vendor + 4, &edx, 4);\n  memcpy(vendor + 8, &ecx, 4);\n  vendor[12] = 0;\n\n  // get feature flags in ecx/edx, and family/model in eax\n  cpuid(eax, ebx, ecx, edx, 1);\n\n  int family = (eax >> 8) & 0xf;        // family and model fields\n  int model = (eax >> 4) & 0xf;\n  if (family == 0xf) {                  // use extended family and model fields\n    family += (eax >> 20) & 0xff;\n    model += ((eax >> 16) & 0xf) << 4;\n  }\n\n  // Opteron Rev E has a bug in which on very rare occasions a locked\n  // instruction doesn't act as a read-acquire barrier if followed by a\n  // non-locked read-modify-write instruction.  Rev F has this bug in\n  // pre-release versions, but not in versions released to customers,\n  // so we test only for Rev E, which is family 15, model 32..63 inclusive.\n  if (strcmp(vendor, \"AuthenticAMD\") == 0 &&       // AMD\n      family == 15 &&\n      32 <= model && model <= 63) {\n    AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug = true;\n  } else {\n    AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug = false;\n  }\n\n  // edx bit 26 is SSE2 which we use to tell use whether we can use mfence\n  AtomicOps_Internalx86CPUFeatures.has_sse2 = ((edx >> 26) & 1);\n}\n\nclass AtomicOpsx86Initializer {\n public:\n  AtomicOpsx86Initializer() {\n    AtomicOps_Internalx86CPUFeaturesInit();\n  }\n};\n\n// A global to get use initialized on startup via static initialization :/\nAtomicOpsx86Initializer g_initer;\n\n}  // namespace\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // __i386__\n\n#endif  // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_GCC_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2012 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file is an internal atomic implementation, use atomicops.h instead.\n\n#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_GCC_H_\n#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_GCC_H_\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\n// This struct is not part of the public API of this module; clients may not\n// use it.\n// Features of this x86.  Values may not be correct before main() is run,\n// but are set conservatively.\nstruct AtomicOps_x86CPUFeatureStruct {\n  bool has_amd_lock_mb_bug;  // Processor has AMD memory-barrier bug; do lfence\n                             // after acquire compare-and-swap.\n  bool has_sse2;             // Processor has SSE2.\n};\nextern struct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures;\n\n#define ATOMICOPS_COMPILER_BARRIER() __asm__ __volatile__(\"\" : : : \"memory\")\n\n// 32-bit low-level operations on any platform.\n\ninline Atomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,\n                                         Atomic32 old_value,\n                                         Atomic32 new_value) {\n  Atomic32 prev;\n  __asm__ __volatile__(\"lock; cmpxchgl %1,%2\"\n                       : \"=a\" (prev)\n                       : \"q\" (new_value), \"m\" (*ptr), \"0\" (old_value)\n                       : \"memory\");\n  return prev;\n}\n\ninline Atomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,\n                                         Atomic32 new_value) {\n  __asm__ __volatile__(\"xchgl %1,%0\"  // The lock prefix is implicit for xchg.\n                       : \"=r\" (new_value)\n                       : \"m\" (*ptr), \"0\" (new_value)\n                       : \"memory\");\n  return new_value;  // Now it's the previous value.\n}\n\ninline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,\n                                          Atomic32 increment) {\n  Atomic32 temp = increment;\n  __asm__ __volatile__(\"lock; xaddl %0,%1\"\n                       : \"+r\" (temp), \"+m\" (*ptr)\n                       : : \"memory\");\n  // temp now holds the old value of *ptr\n  return temp + increment;\n}\n\ninline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,\n                                        Atomic32 increment) {\n  Atomic32 temp = increment;\n  __asm__ __volatile__(\"lock; xaddl %0,%1\"\n                       : \"+r\" (temp), \"+m\" (*ptr)\n                       : : \"memory\");\n  // temp now holds the old value of *ptr\n  if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) {\n    __asm__ __volatile__(\"lfence\" : : : \"memory\");\n  }\n  return temp + increment;\n}\n\ninline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  Atomic32 x = NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n  if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) {\n    __asm__ __volatile__(\"lfence\" : : : \"memory\");\n  }\n  return x;\n}\n\ninline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  return NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n}\n\ninline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {\n  *ptr = value;\n}\n\n#if defined(__x86_64__)\n\n// 64-bit implementations of memory barrier can be simpler, because it\n// \"mfence\" is guaranteed to exist.\ninline void MemoryBarrier() {\n  __asm__ __volatile__(\"mfence\" : : : \"memory\");\n}\n\ninline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {\n  *ptr = value;\n  MemoryBarrier();\n}\n\n#else\n\ninline void MemoryBarrier() {\n  if (AtomicOps_Internalx86CPUFeatures.has_sse2) {\n    __asm__ __volatile__(\"mfence\" : : : \"memory\");\n  } else {  // mfence is faster but not present on PIII\n    Atomic32 x = 0;\n    NoBarrier_AtomicExchange(&x, 0);  // acts as a barrier on PIII\n  }\n}\n\ninline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {\n  if (AtomicOps_Internalx86CPUFeatures.has_sse2) {\n    *ptr = value;\n    __asm__ __volatile__(\"mfence\" : : : \"memory\");\n  } else {\n    NoBarrier_AtomicExchange(ptr, value);\n                          // acts as a barrier on PIII\n  }\n}\n#endif\n\ninline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {\n  ATOMICOPS_COMPILER_BARRIER();\n  *ptr = value;  // An x86 store acts as a release barrier.\n  // See comments in Atomic64 version of Release_Store(), below.\n}\n\ninline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {\n  return *ptr;\n}\n\ninline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {\n  Atomic32 value = *ptr;  // An x86 load acts as a acquire barrier.\n  // See comments in Atomic64 version of Release_Store(), below.\n  ATOMICOPS_COMPILER_BARRIER();\n  return value;\n}\n\ninline Atomic32 Release_Load(volatile const Atomic32* ptr) {\n  MemoryBarrier();\n  return *ptr;\n}\n\n#if defined(__x86_64__)\n\n// 64-bit low-level operations on 64-bit platform.\n\ninline Atomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,\n                                         Atomic64 old_value,\n                                         Atomic64 new_value) {\n  Atomic64 prev;\n  __asm__ __volatile__(\"lock; cmpxchgq %1,%2\"\n                       : \"=a\" (prev)\n                       : \"q\" (new_value), \"m\" (*ptr), \"0\" (old_value)\n                       : \"memory\");\n  return prev;\n}\n\ninline Atomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,\n                                         Atomic64 new_value) {\n  __asm__ __volatile__(\"xchgq %1,%0\"  // The lock prefix is implicit for xchg.\n                       : \"=r\" (new_value)\n                       : \"m\" (*ptr), \"0\" (new_value)\n                       : \"memory\");\n  return new_value;  // Now it's the previous value.\n}\n\ninline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,\n                                          Atomic64 increment) {\n  Atomic64 temp = increment;\n  __asm__ __volatile__(\"lock; xaddq %0,%1\"\n                       : \"+r\" (temp), \"+m\" (*ptr)\n                       : : \"memory\");\n  // temp now contains the previous value of *ptr\n  return temp + increment;\n}\n\ninline Atomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,\n                                        Atomic64 increment) {\n  Atomic64 temp = increment;\n  __asm__ __volatile__(\"lock; xaddq %0,%1\"\n                       : \"+r\" (temp), \"+m\" (*ptr)\n                       : : \"memory\");\n  // temp now contains the previous value of *ptr\n  if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) {\n    __asm__ __volatile__(\"lfence\" : : : \"memory\");\n  }\n  return temp + increment;\n}\n\ninline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {\n  *ptr = value;\n}\n\ninline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {\n  *ptr = value;\n  MemoryBarrier();\n}\n\ninline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {\n  ATOMICOPS_COMPILER_BARRIER();\n\n  *ptr = value;  // An x86 store acts as a release barrier\n                 // for current AMD/Intel chips as of Jan 2008.\n                 // See also Acquire_Load(), below.\n\n  // When new chips come out, check:\n  //  IA-32 Intel Architecture Software Developer's Manual, Volume 3:\n  //  System Programming Guide, Chatper 7: Multiple-processor management,\n  //  Section 7.2, Memory Ordering.\n  // Last seen at:\n  //   http://developer.intel.com/design/pentium4/manuals/index_new.htm\n  //\n  // x86 stores/loads fail to act as barriers for a few instructions (clflush\n  // maskmovdqu maskmovq movntdq movnti movntpd movntps movntq) but these are\n  // not generated by the compiler, and are rare.  Users of these instructions\n  // need to know about cache behaviour in any case since all of these involve\n  // either flushing cache lines or non-temporal cache hints.\n}\n\ninline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {\n  return *ptr;\n}\n\ninline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {\n  Atomic64 value = *ptr;  // An x86 load acts as a acquire barrier,\n                          // for current AMD/Intel chips as of Jan 2008.\n                          // See also Release_Store(), above.\n  ATOMICOPS_COMPILER_BARRIER();\n  return value;\n}\n\ninline Atomic64 Release_Load(volatile const Atomic64* ptr) {\n  MemoryBarrier();\n  return *ptr;\n}\n\ninline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,\n                                       Atomic64 old_value,\n                                       Atomic64 new_value) {\n  Atomic64 x = NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n  if (AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug) {\n    __asm__ __volatile__(\"lfence\" : : : \"memory\");\n  }\n  return x;\n}\n\ninline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,\n                                       Atomic64 old_value,\n                                       Atomic64 new_value) {\n  return NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n}\n\n#endif  // defined(__x86_64__)\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n#undef ATOMICOPS_COMPILER_BARRIER\n\n#endif  // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_GCC_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2012 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// The compilation of extension_set.cc fails when windows.h is included.\n// Therefore we move the code depending on windows.h to this separate cc file.\n\n// Don't compile this file for people not concerned about thread safety.\n#ifndef GOOGLE_PROTOBUF_NO_THREAD_SAFETY\n\n#include <google/protobuf/stubs/atomicops.h>\n\n#ifdef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_MSVC_H_\n\n#include <windows.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\ninline void MemoryBarrier() {\n  // We use MemoryBarrier from WinNT.h\n  ::MemoryBarrier();\n}\n\nAtomic32 NoBarrier_CompareAndSwap(volatile Atomic32* ptr,\n                                  Atomic32 old_value,\n                                  Atomic32 new_value) {\n  LONG result = InterlockedCompareExchange(\n      reinterpret_cast<volatile LONG*>(ptr),\n      static_cast<LONG>(new_value),\n      static_cast<LONG>(old_value));\n  return static_cast<Atomic32>(result);\n}\n\nAtomic32 NoBarrier_AtomicExchange(volatile Atomic32* ptr,\n                                  Atomic32 new_value) {\n  LONG result = InterlockedExchange(\n      reinterpret_cast<volatile LONG*>(ptr),\n      static_cast<LONG>(new_value));\n  return static_cast<Atomic32>(result);\n}\n\nAtomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,\n                                 Atomic32 increment) {\n  return InterlockedExchangeAdd(\n      reinterpret_cast<volatile LONG*>(ptr),\n      static_cast<LONG>(increment)) + increment;\n}\n\n#if defined(_WIN64)\n\n// 64-bit low-level operations on 64-bit platform.\n\nAtomic64 NoBarrier_CompareAndSwap(volatile Atomic64* ptr,\n                                  Atomic64 old_value,\n                                  Atomic64 new_value) {\n  PVOID result = InterlockedCompareExchangePointer(\n    reinterpret_cast<volatile PVOID*>(ptr),\n    reinterpret_cast<PVOID>(new_value), reinterpret_cast<PVOID>(old_value));\n  return reinterpret_cast<Atomic64>(result);\n}\n\nAtomic64 NoBarrier_AtomicExchange(volatile Atomic64* ptr,\n                                  Atomic64 new_value) {\n  PVOID result = InterlockedExchangePointer(\n    reinterpret_cast<volatile PVOID*>(ptr),\n    reinterpret_cast<PVOID>(new_value));\n  return reinterpret_cast<Atomic64>(result);\n}\n\nAtomic64 Barrier_AtomicIncrement(volatile Atomic64* ptr,\n                                 Atomic64 increment) {\n  return InterlockedExchangeAdd64(\n      reinterpret_cast<volatile LONGLONG*>(ptr),\n      static_cast<LONGLONG>(increment)) + increment;\n}\n\n#endif  // defined(_WIN64)\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_MSVC_H_\n#endif  // GOOGLE_PROTOBUF_NO_THREAD_SAFETY\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2012 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file is an internal atomic implementation, use atomicops.h instead.\n\n#ifndef GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_MSVC_H_\n#define GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_MSVC_H_\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\ninline Atomic32 NoBarrier_AtomicIncrement(volatile Atomic32* ptr,\n                                          Atomic32 increment) {\n  return Barrier_AtomicIncrement(ptr, increment);\n}\n\n#if !(defined(_MSC_VER) && _MSC_VER >= 1400)\n#error \"We require at least vs2005 for MemoryBarrier\"\n#endif\n\ninline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  return NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n}\n\ninline Atomic32 Release_CompareAndSwap(volatile Atomic32* ptr,\n                                       Atomic32 old_value,\n                                       Atomic32 new_value) {\n  return NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n}\n\ninline void NoBarrier_Store(volatile Atomic32* ptr, Atomic32 value) {\n  *ptr = value;\n}\n\ninline void Acquire_Store(volatile Atomic32* ptr, Atomic32 value) {\n  NoBarrier_AtomicExchange(ptr, value);\n              // acts as a barrier in this implementation\n}\n\ninline void Release_Store(volatile Atomic32* ptr, Atomic32 value) {\n  *ptr = value;  // works w/o barrier for current Intel chips as of June 2005\n  // See comments in Atomic64 version of Release_Store() below.\n}\n\ninline Atomic32 NoBarrier_Load(volatile const Atomic32* ptr) {\n  return *ptr;\n}\n\ninline Atomic32 Acquire_Load(volatile const Atomic32* ptr) {\n  Atomic32 value = *ptr;\n  return value;\n}\n\ninline Atomic32 Release_Load(volatile const Atomic32* ptr) {\n  MemoryBarrier();\n  return *ptr;\n}\n\n#if defined(_WIN64)\n\n// 64-bit low-level operations on 64-bit platform.\n\ninline Atomic64 NoBarrier_AtomicIncrement(volatile Atomic64* ptr,\n                                          Atomic64 increment) {\n  return Barrier_AtomicIncrement(ptr, increment);\n}\n\ninline void NoBarrier_Store(volatile Atomic64* ptr, Atomic64 value) {\n  *ptr = value;\n}\n\ninline void Acquire_Store(volatile Atomic64* ptr, Atomic64 value) {\n  NoBarrier_AtomicExchange(ptr, value);\n              // acts as a barrier in this implementation\n}\n\ninline void Release_Store(volatile Atomic64* ptr, Atomic64 value) {\n  *ptr = value;  // works w/o barrier for current Intel chips as of June 2005\n\n  // When new chips come out, check:\n  //  IA-32 Intel Architecture Software Developer's Manual, Volume 3:\n  //  System Programming Guide, Chatper 7: Multiple-processor management,\n  //  Section 7.2, Memory Ordering.\n  // Last seen at:\n  //   http://developer.intel.com/design/pentium4/manuals/index_new.htm\n}\n\ninline Atomic64 NoBarrier_Load(volatile const Atomic64* ptr) {\n  return *ptr;\n}\n\ninline Atomic64 Acquire_Load(volatile const Atomic64* ptr) {\n  Atomic64 value = *ptr;\n  return value;\n}\n\ninline Atomic64 Release_Load(volatile const Atomic64* ptr) {\n  MemoryBarrier();\n  return *ptr;\n}\n\ninline Atomic64 Acquire_CompareAndSwap(volatile Atomic64* ptr,\n                                       Atomic64 old_value,\n                                       Atomic64 new_value) {\n  return NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n}\n\ninline Atomic64 Release_CompareAndSwap(volatile Atomic64* ptr,\n                                       Atomic64 old_value,\n                                       Atomic64 new_value) {\n  return NoBarrier_CompareAndSwap(ptr, old_value, new_value);\n}\n\n#endif  // defined(_WIN64)\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_ATOMICOPS_INTERNALS_X86_MSVC_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/bytestream.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/stubs/bytestream.h>\n\n#include <string.h>\n#include <algorithm>\n\nnamespace google {\nnamespace protobuf {\nnamespace strings {\n\nvoid ByteSource::CopyTo(ByteSink* sink, size_t n) {\n  while (n > 0) {\n    StringPiece fragment = Peek();\n    if (fragment.empty()) {\n      GOOGLE_LOG(DFATAL) << \"ByteSource::CopyTo() overran input.\";\n      break;\n    }\n    std::size_t fragment_size = std::min<std::size_t>(n, fragment.size());\n    sink->Append(fragment.data(), fragment_size);\n    Skip(fragment_size);\n    n -= fragment_size;\n  }\n}\n\nvoid ByteSink::Flush() {}\n\nvoid UncheckedArrayByteSink::Append(const char* data, size_t n) {\n  if (data != dest_) {\n    // Catch cases where the pointer returned by GetAppendBuffer() was modified.\n    GOOGLE_DCHECK(!(dest_ <= data && data < (dest_ + n)))\n        << \"Append() data[] overlaps with dest_[]\";\n    memcpy(dest_, data, n);\n  }\n  dest_ += n;\n}\n\nCheckedArrayByteSink::CheckedArrayByteSink(char* outbuf, size_t capacity)\n    : outbuf_(outbuf), capacity_(capacity), size_(0), overflowed_(false) {\n}\n\nvoid CheckedArrayByteSink::Append(const char* bytes, size_t n) {\n  size_t available = capacity_ - size_;\n  if (n > available) {\n    n = available;\n    overflowed_ = true;\n  }\n  if (n > 0 && bytes != (outbuf_ + size_)) {\n    // Catch cases where the pointer returned by GetAppendBuffer() was modified.\n    GOOGLE_DCHECK(!(outbuf_ <= bytes && bytes < (outbuf_ + capacity_)))\n        << \"Append() bytes[] overlaps with outbuf_[]\";\n    memcpy(outbuf_ + size_, bytes, n);\n  }\n  size_ += n;\n}\n\nGrowingArrayByteSink::GrowingArrayByteSink(size_t estimated_size)\n    : capacity_(estimated_size),\n      buf_(new char[estimated_size]),\n      size_(0) {\n}\n\nGrowingArrayByteSink::~GrowingArrayByteSink() {\n  delete[] buf_;  // Just in case the user didn't call GetBuffer.\n}\n\nvoid GrowingArrayByteSink::Append(const char* bytes, size_t n) {\n  size_t available = capacity_ - size_;\n  if (bytes != (buf_ + size_)) {\n    // Catch cases where the pointer returned by GetAppendBuffer() was modified.\n    // We need to test for this before calling Expand() which may reallocate.\n    GOOGLE_DCHECK(!(buf_ <= bytes && bytes < (buf_ + capacity_)))\n        << \"Append() bytes[] overlaps with buf_[]\";\n  }\n  if (n > available) {\n    Expand(n - available);\n  }\n  if (n > 0 && bytes != (buf_ + size_)) {\n    memcpy(buf_ + size_, bytes, n);\n  }\n  size_ += n;\n}\n\nchar* GrowingArrayByteSink::GetBuffer(size_t* nbytes) {\n  ShrinkToFit();\n  char* b = buf_;\n  *nbytes = size_;\n  buf_ = NULL;\n  size_ = capacity_ = 0;\n  return b;\n}\n\nvoid GrowingArrayByteSink::Expand(size_t amount) {  // Expand by at least 50%.\n  size_t new_capacity = std::max(capacity_ + amount, (3 * capacity_) / 2);\n  char* bigger = new char[new_capacity];\n  memcpy(bigger, buf_, size_);\n  delete[] buf_;\n  buf_ = bigger;\n  capacity_ = new_capacity;\n}\n\nvoid GrowingArrayByteSink::ShrinkToFit() {\n  // Shrink only if the buffer is large and size_ is less than 3/4\n  // of capacity_.\n  if (capacity_ > 256 && size_ < (3 * capacity_) / 4) {\n    char* just_enough = new char[size_];\n    memcpy(just_enough, buf_, size_);\n    delete[] buf_;\n    buf_ = just_enough;\n    capacity_ = size_;\n  }\n}\n\nvoid StringByteSink::Append(const char* data, size_t n) {\n  dest_->append(data, n);\n}\n\nsize_t ArrayByteSource::Available() const {\n  return input_.size();\n}\n\nStringPiece ArrayByteSource::Peek() {\n  return input_;\n}\n\nvoid ArrayByteSource::Skip(size_t n) {\n  GOOGLE_DCHECK_LE(n, input_.size());\n  input_.remove_prefix(n);\n}\n\nLimitByteSource::LimitByteSource(ByteSource *source, size_t limit)\n  : source_(source),\n    limit_(limit) {\n}\n\nsize_t LimitByteSource::Available() const {\n  size_t available = source_->Available();\n  if (available > limit_) {\n    available = limit_;\n  }\n\n  return available;\n}\n\nStringPiece LimitByteSource::Peek() {\n  StringPiece piece(source_->Peek());\n  if (piece.size() > limit_) {\n    piece.set(piece.data(), limit_);\n  }\n\n  return piece;\n}\n\nvoid LimitByteSource::Skip(size_t n) {\n  GOOGLE_DCHECK_LE(n, limit_);\n  source_->Skip(n);\n  limit_ -= n;\n}\n\nvoid LimitByteSource::CopyTo(ByteSink *sink, size_t n) {\n  GOOGLE_DCHECK_LE(n, limit_);\n  source_->CopyTo(sink, n);\n  limit_ -= n;\n}\n\n}  // namespace strings\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/bytestream.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// This file declares the ByteSink and ByteSource abstract interfaces. These\n// interfaces represent objects that consume (ByteSink) or produce (ByteSource)\n// a sequence of bytes. Using these abstract interfaces in your APIs can help\n// make your code work with a variety of input and output types.\n//\n// This file also declares the following commonly used implementations of these\n// interfaces.\n//\n//   ByteSink:\n//      UncheckedArrayByteSink  Writes to an array, without bounds checking\n//      CheckedArrayByteSink    Writes to an array, with bounds checking\n//      GrowingArrayByteSink    Allocates and writes to a growable buffer\n//      StringByteSink          Writes to an STL string\n//      NullByteSink            Consumes a never-ending stream of bytes\n//\n//   ByteSource:\n//      ArrayByteSource         Reads from an array or string/StringPiece\n//      LimitedByteSource       Limits the number of bytes read from an\n\n#ifndef GOOGLE_PROTOBUF_STUBS_BYTESTREAM_H_\n#define GOOGLE_PROTOBUF_STUBS_BYTESTREAM_H_\n\n#include <stddef.h>\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/stringpiece.h>\n\nclass CordByteSink;\nclass MemBlock;\n\nnamespace google {\nnamespace protobuf {\nnamespace strings {\n\n// An abstract interface for an object that consumes a sequence of bytes. This\n// interface offers 3 different ways to append data, and a Flush() function.\n//\n// Example:\n//\n//   string my_data;\n//   ...\n//   ByteSink* sink = ...\n//   sink->Append(my_data.data(), my_data.size());\n//   sink->Flush();\n//\nclass LIBPROTOBUF_EXPORT ByteSink {\n public:\n  ByteSink() {}\n  virtual ~ByteSink() {}\n\n  // Appends the \"n\" bytes starting at \"bytes\".\n  virtual void Append(const char* bytes, size_t n) = 0;\n\n  // Flushes internal buffers. The default implemenation does nothing. ByteSink\n  // subclasses may use internal buffers that require calling Flush() at the end\n  // of the stream.\n  virtual void Flush();\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ByteSink);\n};\n\n// An abstract interface for an object that produces a fixed-size sequence of\n// bytes.\n//\n// Example:\n//\n//   ByteSource* source = ...\n//   while (source->Available() > 0) {\n//     StringPiece data = source->Peek();\n//     ... do something with \"data\" ...\n//     source->Skip(data.length());\n//   }\n//\nclass LIBPROTOBUF_EXPORT ByteSource {\n public:\n  ByteSource() {}\n  virtual ~ByteSource() {}\n\n  // Returns the number of bytes left to read from the source. Available()\n  // should decrease by N each time Skip(N) is called. Available() may not\n  // increase. Available() returning 0 indicates that the ByteSource is\n  // exhausted.\n  //\n  // Note: Size() may have been a more appropriate name as it's more\n  //       indicative of the fixed-size nature of a ByteSource.\n  virtual size_t Available() const = 0;\n\n  // Returns a StringPiece of the next contiguous region of the source. Does not\n  // reposition the source. The returned region is empty iff Available() == 0.\n  //\n  // The returned region is valid until the next call to Skip() or until this\n  // object is destroyed, whichever occurs first.\n  //\n  // The length of the returned StringPiece will be <= Available().\n  virtual StringPiece Peek() = 0;\n\n  // Skips the next n bytes. Invalidates any StringPiece returned by a previous\n  // call to Peek().\n  //\n  // REQUIRES: Available() >= n\n  virtual void Skip(size_t n) = 0;\n\n  // Writes the next n bytes in this ByteSource to the given ByteSink, and\n  // advances this ByteSource past the copied bytes. The default implementation\n  // of this method just copies the bytes normally, but subclasses might\n  // override CopyTo to optimize certain cases.\n  //\n  // REQUIRES: Available() >= n\n  virtual void CopyTo(ByteSink* sink, size_t n);\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ByteSource);\n};\n\n//\n// Some commonly used implementations of ByteSink\n//\n\n// Implementation of ByteSink that writes to an unsized byte array. No\n// bounds-checking is performed--it is the caller's responsibility to ensure\n// that the destination array is large enough.\n//\n// Example:\n//\n//   char buf[10];\n//   UncheckedArrayByteSink sink(buf);\n//   sink.Append(\"hi\", 2);    // OK\n//   sink.Append(data, 100);  // WOOPS! Overflows buf[10].\n//\nclass LIBPROTOBUF_EXPORT UncheckedArrayByteSink : public ByteSink {\n public:\n  explicit UncheckedArrayByteSink(char* dest) : dest_(dest) {}\n  virtual void Append(const char* data, size_t n);\n\n  // Returns the current output pointer so that a caller can see how many bytes\n  // were produced.\n  //\n  // Note: this method is not part of the ByteSink interface.\n  char* CurrentDestination() const { return dest_; }\n\n private:\n  char* dest_;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(UncheckedArrayByteSink);\n};\n\n// Implementation of ByteSink that writes to a sized byte array. This sink will\n// not write more than \"capacity\" bytes to outbuf. Once \"capacity\" bytes are\n// appended, subsequent bytes will be ignored and Overflowed() will return true.\n// Overflowed() does not cause a runtime error (i.e., it does not CHECK fail).\n//\n// Example:\n//\n//   char buf[10];\n//   CheckedArrayByteSink sink(buf, 10);\n//   sink.Append(\"hi\", 2);    // OK\n//   sink.Append(data, 100);  // Will only write 8 more bytes\n//\nclass LIBPROTOBUF_EXPORT CheckedArrayByteSink : public ByteSink {\n public:\n  CheckedArrayByteSink(char* outbuf, size_t capacity);\n  virtual void Append(const char* bytes, size_t n);\n\n  // Returns the number of bytes actually written to the sink.\n  size_t NumberOfBytesWritten() const { return size_; }\n\n  // Returns true if any bytes were discarded, i.e., if there was an\n  // attempt to write more than 'capacity' bytes.\n  bool Overflowed() const { return overflowed_; }\n\n private:\n  char* outbuf_;\n  const size_t capacity_;\n  size_t size_;\n  bool overflowed_;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(CheckedArrayByteSink);\n};\n\n// Implementation of ByteSink that allocates an internal buffer (a char array)\n// and expands it as needed to accommodate appended data (similar to a string),\n// and allows the caller to take ownership of the internal buffer via the\n// GetBuffer() method. The buffer returned from GetBuffer() must be deleted by\n// the caller with delete[]. GetBuffer() also sets the internal buffer to be\n// empty, and subsequent appends to the sink will create a new buffer. The\n// destructor will free the internal buffer if GetBuffer() was not called.\n//\n// Example:\n//\n//   GrowingArrayByteSink sink(10);\n//   sink.Append(\"hi\", 2);\n//   sink.Append(data, n);\n//   const char* buf = sink.GetBuffer();  // Ownership transferred\n//   delete[] buf;\n//\nclass LIBPROTOBUF_EXPORT GrowingArrayByteSink : public strings::ByteSink {\n public:\n  explicit GrowingArrayByteSink(size_t estimated_size);\n  virtual ~GrowingArrayByteSink();\n  virtual void Append(const char* bytes, size_t n);\n\n  // Returns the allocated buffer, and sets nbytes to its size. The caller takes\n  // ownership of the buffer and must delete it with delete[].\n  char* GetBuffer(size_t* nbytes);\n\n private:\n  void Expand(size_t amount);\n  void ShrinkToFit();\n\n  size_t capacity_;\n  char* buf_;\n  size_t size_;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(GrowingArrayByteSink);\n};\n\n// Implementation of ByteSink that appends to the given string.\n// Existing contents of \"dest\" are not modified; new data is appended.\n//\n// Example:\n//\n//   string dest = \"Hello \";\n//   StringByteSink sink(&dest);\n//   sink.Append(\"World\", 5);\n//   assert(dest == \"Hello World\");\n//\nclass LIBPROTOBUF_EXPORT StringByteSink : public ByteSink {\n public:\n  explicit StringByteSink(string* dest) : dest_(dest) {}\n  virtual void Append(const char* data, size_t n);\n\n private:\n  string* dest_;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StringByteSink);\n};\n\n// Implementation of ByteSink that discards all data.\n//\n// Example:\n//\n//   NullByteSink sink;\n//   sink.Append(data, data.size());  // All data ignored.\n//\nclass LIBPROTOBUF_EXPORT NullByteSink : public ByteSink {\n public:\n  NullByteSink() {}\n  virtual void Append(const char *data, size_t n) {}\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(NullByteSink);\n};\n\n//\n// Some commonly used implementations of ByteSource\n//\n\n// Implementation of ByteSource that reads from a StringPiece.\n//\n// Example:\n//\n//   string data = \"Hello\";\n//   ArrayByteSource source(data);\n//   assert(source.Available() == 5);\n//   assert(source.Peek() == \"Hello\");\n//\nclass LIBPROTOBUF_EXPORT ArrayByteSource : public ByteSource {\n public:\n  explicit ArrayByteSource(StringPiece s) : input_(s) {}\n\n  virtual size_t Available() const;\n  virtual StringPiece Peek();\n  virtual void Skip(size_t n);\n\n private:\n  StringPiece   input_;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ArrayByteSource);\n};\n\n// Implementation of ByteSource that wraps another ByteSource, limiting the\n// number of bytes returned.\n//\n// The caller maintains ownership of the underlying source, and may not use the\n// underlying source while using the LimitByteSource object.  The underlying\n// source's pointer is advanced by n bytes every time this LimitByteSource\n// object is advanced by n.\n//\n// Example:\n//\n//   string data = \"Hello World\";\n//   ArrayByteSource abs(data);\n//   assert(abs.Available() == data.size());\n//\n//   LimitByteSource limit(abs, 5);\n//   assert(limit.Available() == 5);\n//   assert(limit.Peek() == \"Hello\");\n//\nclass LIBPROTOBUF_EXPORT LimitByteSource : public ByteSource {\n public:\n  // Returns at most \"limit\" bytes from \"source\".\n  LimitByteSource(ByteSource* source, size_t limit);\n\n  virtual size_t Available() const;\n  virtual StringPiece Peek();\n  virtual void Skip(size_t n);\n\n  // We override CopyTo so that we can forward to the underlying source, in\n  // case it has an efficient implementation of CopyTo.\n  virtual void CopyTo(ByteSink* sink, size_t n);\n\n private:\n  ByteSource* source_;\n  size_t limit_;\n};\n\n}  // namespace strings\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_STUBS_BYTESTREAM_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/bytestream_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/stubs/bytestream.h>\n\n#include <stdio.h>\n#include <string.h>\n#include <algorithm>\n\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace strings {\nnamespace {\n\n// We use this class instead of ArrayByteSource to simulate a ByteSource that\n// contains multiple fragments.  ArrayByteSource returns the entire array in\n// one fragment.\nclass MockByteSource : public ByteSource {\n public:\n  MockByteSource(StringPiece data, int block_size)\n    : data_(data), block_size_(block_size) {}\n\n  size_t Available() const { return data_.size(); }\n  StringPiece Peek() {\n    return data_.substr(0, block_size_);\n  }\n  void Skip(size_t n) { data_.remove_prefix(n); }\n\n private:\n  StringPiece data_;\n  int block_size_;\n};\n\nTEST(ByteSourceTest, CopyTo) {\n  StringPiece data(\"Hello world!\");\n  MockByteSource source(data, 3);\n  string str;\n  StringByteSink sink(&str);\n\n  source.CopyTo(&sink, data.size());\n  EXPECT_EQ(data, str);\n}\n\nTEST(ByteSourceTest, CopySubstringTo) {\n  StringPiece data(\"Hello world!\");\n  MockByteSource source(data, 3);\n  source.Skip(1);\n  string str;\n  StringByteSink sink(&str);\n\n  source.CopyTo(&sink, data.size() - 2);\n  EXPECT_EQ(data.substr(1, data.size() - 2), str);\n  EXPECT_EQ(\"!\", source.Peek());\n}\n\nTEST(ByteSourceTest, LimitByteSource) {\n  StringPiece data(\"Hello world!\");\n  MockByteSource source(data, 3);\n  LimitByteSource limit_source(&source, 6);\n  EXPECT_EQ(6, limit_source.Available());\n  limit_source.Skip(1);\n  EXPECT_EQ(5, limit_source.Available());\n\n  {\n    string str;\n    StringByteSink sink(&str);\n    limit_source.CopyTo(&sink, limit_source.Available());\n    EXPECT_EQ(\"ello \", str);\n    EXPECT_EQ(0, limit_source.Available());\n    EXPECT_EQ(6, source.Available());\n  }\n\n  {\n    string str;\n    StringByteSink sink(&str);\n    source.CopyTo(&sink, source.Available());\n    EXPECT_EQ(\"world!\", str);\n    EXPECT_EQ(0, source.Available());\n  }\n}\n\nTEST(ByteSourceTest, CopyToStringByteSink) {\n  StringPiece data(\"Hello world!\");\n  MockByteSource source(data, 3);\n  string str;\n  StringByteSink sink(&str);\n  source.CopyTo(&sink, data.size());\n  EXPECT_EQ(data, str);\n}\n\n// Verify that ByteSink is subclassable and Flush() overridable.\nclass FlushingByteSink : public StringByteSink {\n public:\n  explicit FlushingByteSink(string* dest) : StringByteSink(dest) {}\n  virtual void Flush() { Append(\"z\", 1); }\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FlushingByteSink);\n};\n\n// Write and Flush via the ByteSink superclass interface.\nvoid WriteAndFlush(ByteSink* s) {\n  s->Append(\"abc\", 3);\n  s->Flush();\n}\n\nTEST(ByteSinkTest, Flush) {\n  string str;\n  FlushingByteSink f_sink(&str);\n  WriteAndFlush(&f_sink);\n  EXPECT_STREQ(\"abcz\", str.c_str());\n}\n\n}  // namespace\n}  // namespace strings\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/callback.h",
    "content": "#ifndef GOOGLE_PROTOBUF_STUBS_CALLBACK_H_\n#define GOOGLE_PROTOBUF_STUBS_CALLBACK_H_\n\n#include <google/protobuf/stubs/macros.h>\n#include <google/protobuf/stubs/type_traits.h>\n\n// ===================================================================\n// emulates google3/base/callback.h\n\nnamespace google {\nnamespace protobuf {\n\n// Abstract interface for a callback.  When calling an RPC, you must provide\n// a Closure to call when the procedure completes.  See the Service interface\n// in service.h.\n//\n// To automatically construct a Closure which calls a particular function or\n// method with a particular set of parameters, use the NewCallback() function.\n// Example:\n//   void FooDone(const FooResponse* response) {\n//     ...\n//   }\n//\n//   void CallFoo() {\n//     ...\n//     // When done, call FooDone() and pass it a pointer to the response.\n//     Closure* callback = NewCallback(&FooDone, response);\n//     // Make the call.\n//     service->Foo(controller, request, response, callback);\n//   }\n//\n// Example that calls a method:\n//   class Handler {\n//    public:\n//     ...\n//\n//     void FooDone(const FooResponse* response) {\n//       ...\n//     }\n//\n//     void CallFoo() {\n//       ...\n//       // When done, call FooDone() and pass it a pointer to the response.\n//       Closure* callback = NewCallback(this, &Handler::FooDone, response);\n//       // Make the call.\n//       service->Foo(controller, request, response, callback);\n//     }\n//   };\n//\n// Currently NewCallback() supports binding zero, one, or two arguments.\n//\n// Callbacks created with NewCallback() automatically delete themselves when\n// executed.  They should be used when a callback is to be called exactly\n// once (usually the case with RPC callbacks).  If a callback may be called\n// a different number of times (including zero), create it with\n// NewPermanentCallback() instead.  You are then responsible for deleting the\n// callback (using the \"delete\" keyword as normal).\n//\n// Note that NewCallback() is a bit touchy regarding argument types.  Generally,\n// the values you provide for the parameter bindings must exactly match the\n// types accepted by the callback function.  For example:\n//   void Foo(string s);\n//   NewCallback(&Foo, \"foo\");          // WON'T WORK:  const char* != string\n//   NewCallback(&Foo, string(\"foo\"));  // WORKS\n// Also note that the arguments cannot be references:\n//   void Foo(const string& s);\n//   string my_str;\n//   NewCallback(&Foo, my_str);  // WON'T WORK:  Can't use referecnes.\n// However, correctly-typed pointers will work just fine.\nclass LIBPROTOBUF_EXPORT Closure {\n public:\n  Closure() {}\n  virtual ~Closure();\n\n  virtual void Run() = 0;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Closure);\n};\n\ntemplate<typename R>\nclass ResultCallback {\n public:\n  ResultCallback() {}\n  virtual ~ResultCallback() {}\n\n  virtual R Run() = 0;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ResultCallback);\n};\n\ntemplate<typename R, typename A1>\nclass LIBPROTOBUF_EXPORT ResultCallback1 {\n public:\n  ResultCallback1() {}\n  virtual ~ResultCallback1() {}\n\n  virtual R Run(A1) = 0;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ResultCallback1);\n};\n\ntemplate<typename R, typename A1, typename A2>\nclass LIBPROTOBUF_EXPORT ResultCallback2 {\n public:\n  ResultCallback2() {}\n  virtual ~ResultCallback2() {}\n\n  virtual R Run(A1,A2) = 0;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ResultCallback2);\n};\n\nnamespace internal {\n\nclass LIBPROTOBUF_EXPORT FunctionClosure0 : public Closure {\n public:\n  typedef void (*FunctionType)();\n\n  FunctionClosure0(FunctionType function, bool self_deleting)\n    : function_(function), self_deleting_(self_deleting) {}\n  ~FunctionClosure0();\n\n  void Run() {\n    bool needs_delete = self_deleting_;  // read in case callback deletes\n    function_();\n    if (needs_delete) delete this;\n  }\n\n private:\n  FunctionType function_;\n  bool self_deleting_;\n};\n\ntemplate <typename Class>\nclass MethodClosure0 : public Closure {\n public:\n  typedef void (Class::*MethodType)();\n\n  MethodClosure0(Class* object, MethodType method, bool self_deleting)\n    : object_(object), method_(method), self_deleting_(self_deleting) {}\n  ~MethodClosure0() {}\n\n  void Run() {\n    bool needs_delete = self_deleting_;  // read in case callback deletes\n    (object_->*method_)();\n    if (needs_delete) delete this;\n  }\n\n private:\n  Class* object_;\n  MethodType method_;\n  bool self_deleting_;\n};\n\ntemplate <typename Arg1>\nclass FunctionClosure1 : public Closure {\n public:\n  typedef void (*FunctionType)(Arg1 arg1);\n\n  FunctionClosure1(FunctionType function, bool self_deleting,\n                   Arg1 arg1)\n    : function_(function), self_deleting_(self_deleting),\n      arg1_(arg1) {}\n  ~FunctionClosure1() {}\n\n  void Run() {\n    bool needs_delete = self_deleting_;  // read in case callback deletes\n    function_(arg1_);\n    if (needs_delete) delete this;\n  }\n\n private:\n  FunctionType function_;\n  bool self_deleting_;\n  Arg1 arg1_;\n};\n\ntemplate <typename Class, typename Arg1>\nclass MethodClosure1 : public Closure {\n public:\n  typedef void (Class::*MethodType)(Arg1 arg1);\n\n  MethodClosure1(Class* object, MethodType method, bool self_deleting,\n                 Arg1 arg1)\n    : object_(object), method_(method), self_deleting_(self_deleting),\n      arg1_(arg1) {}\n  ~MethodClosure1() {}\n\n  void Run() {\n    bool needs_delete = self_deleting_;  // read in case callback deletes\n    (object_->*method_)(arg1_);\n    if (needs_delete) delete this;\n  }\n\n private:\n  Class* object_;\n  MethodType method_;\n  bool self_deleting_;\n  Arg1 arg1_;\n};\n\ntemplate <typename Arg1, typename Arg2>\nclass FunctionClosure2 : public Closure {\n public:\n  typedef void (*FunctionType)(Arg1 arg1, Arg2 arg2);\n\n  FunctionClosure2(FunctionType function, bool self_deleting,\n                   Arg1 arg1, Arg2 arg2)\n    : function_(function), self_deleting_(self_deleting),\n      arg1_(arg1), arg2_(arg2) {}\n  ~FunctionClosure2() {}\n\n  void Run() {\n    bool needs_delete = self_deleting_;  // read in case callback deletes\n    function_(arg1_, arg2_);\n    if (needs_delete) delete this;\n  }\n\n private:\n  FunctionType function_;\n  bool self_deleting_;\n  Arg1 arg1_;\n  Arg2 arg2_;\n};\n\ntemplate <typename Class, typename Arg1, typename Arg2>\nclass MethodClosure2 : public Closure {\n public:\n  typedef void (Class::*MethodType)(Arg1 arg1, Arg2 arg2);\n\n  MethodClosure2(Class* object, MethodType method, bool self_deleting,\n                 Arg1 arg1, Arg2 arg2)\n    : object_(object), method_(method), self_deleting_(self_deleting),\n      arg1_(arg1), arg2_(arg2) {}\n  ~MethodClosure2() {}\n\n  void Run() {\n    bool needs_delete = self_deleting_;  // read in case callback deletes\n    (object_->*method_)(arg1_, arg2_);\n    if (needs_delete) delete this;\n  }\n\n private:\n  Class* object_;\n  MethodType method_;\n  bool self_deleting_;\n  Arg1 arg1_;\n  Arg2 arg2_;\n};\n\ntemplate<typename R>\nclass FunctionResultCallback_0_0 : public ResultCallback<R> {\n public:\n  typedef R (*FunctionType)();\n\n  FunctionResultCallback_0_0(FunctionType function, bool self_deleting)\n      : function_(function), self_deleting_(self_deleting) {}\n  ~FunctionResultCallback_0_0() {}\n\n  R Run() {\n    bool needs_delete = self_deleting_;  // read in case callback deletes\n    R result = function_();\n    if (needs_delete) delete this;\n    return result;\n  }\n\n private:\n  FunctionType function_;\n  bool self_deleting_;\n};\n\ntemplate<typename R, typename P1>\nclass FunctionResultCallback_1_0 : public ResultCallback<R> {\n public:\n  typedef R (*FunctionType)(P1);\n\n  FunctionResultCallback_1_0(FunctionType function, bool self_deleting,\n                             P1 p1)\n      : function_(function), self_deleting_(self_deleting), p1_(p1) {}\n  ~FunctionResultCallback_1_0() {}\n\n  R Run() {\n    bool needs_delete = self_deleting_;  // read in case callback deletes\n    R result = function_(p1_);\n    if (needs_delete) delete this;\n    return result;\n  }\n\n private:\n  FunctionType function_;\n  bool self_deleting_;\n  P1 p1_;\n};\n\ntemplate<typename R, typename Arg1>\nclass FunctionResultCallback_0_1 : public ResultCallback1<R, Arg1> {\n public:\n  typedef R (*FunctionType)(Arg1 arg1);\n\n  FunctionResultCallback_0_1(FunctionType function, bool self_deleting)\n      : function_(function), self_deleting_(self_deleting) {}\n  ~FunctionResultCallback_0_1() {}\n\n  R Run(Arg1 a1) {\n    bool needs_delete = self_deleting_;  // read in case callback deletes\n    R result = function_(a1);\n    if (needs_delete) delete this;\n    return result;\n  }\n\n private:\n  FunctionType function_;\n  bool self_deleting_;\n};\n\ntemplate<typename R, typename P1, typename A1>\nclass FunctionResultCallback_1_1 : public ResultCallback1<R, A1> {\n public:\n  typedef R (*FunctionType)(P1, A1);\n\n  FunctionResultCallback_1_1(FunctionType function, bool self_deleting,\n                             P1 p1)\n      : function_(function), self_deleting_(self_deleting), p1_(p1) {}\n  ~FunctionResultCallback_1_1() {}\n\n  R Run(A1 a1) {\n    bool needs_delete = self_deleting_;  // read in case callback deletes\n    R result = function_(p1_, a1);\n    if (needs_delete) delete this;\n    return result;\n  }\n\n private:\n  FunctionType function_;\n  bool self_deleting_;\n  P1 p1_;\n};\n\ntemplate <typename T>\nstruct InternalConstRef {\n  typedef typename remove_reference<T>::type base_type;\n  typedef const base_type& type;\n};\n\ntemplate <typename R, typename T, typename P1, typename P2, typename P3,\n          typename P4, typename P5, typename A1, typename A2>\nclass MethodResultCallback_5_2 : public ResultCallback2<R, A1, A2> {\n public:\n  typedef R (T::*MethodType)(P1, P2, P3, P4, P5, A1, A2);\n  MethodResultCallback_5_2(T* object, MethodType method, bool self_deleting,\n                           P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)\n      : object_(object),\n        method_(method),\n        self_deleting_(self_deleting),\n        p1_(p1),\n        p2_(p2),\n        p3_(p3),\n        p4_(p4),\n        p5_(p5) {}\n  ~MethodResultCallback_5_2() {}\n\n  R Run(A1 a1, A2 a2) {\n    bool needs_delete = self_deleting_;\n    R result = (object_->*method_)(p1_, p2_, p3_, p4_, p5_, a1, a2);\n    if (needs_delete) delete this;\n    return result;\n  }\n\n private:\n  T* object_;\n  MethodType method_;\n  bool self_deleting_;\n  typename remove_reference<P1>::type p1_;\n  typename remove_reference<P2>::type p2_;\n  typename remove_reference<P3>::type p3_;\n  typename remove_reference<P4>::type p4_;\n  typename remove_reference<P5>::type p5_;\n};\n\n// See Closure.\ninline Closure* NewCallback(void (*function)()) {\n  return new internal::FunctionClosure0(function, true);\n}\n\n// See Closure.\ninline Closure* NewPermanentCallback(void (*function)()) {\n  return new internal::FunctionClosure0(function, false);\n}\n\n// See Closure.\ntemplate <typename Class>\ninline Closure* NewCallback(Class* object, void (Class::*method)()) {\n  return new internal::MethodClosure0<Class>(object, method, true);\n}\n\n// See Closure.\ntemplate <typename Class>\ninline Closure* NewPermanentCallback(Class* object, void (Class::*method)()) {\n  return new internal::MethodClosure0<Class>(object, method, false);\n}\n\n// See Closure.\ntemplate <typename Arg1>\ninline Closure* NewCallback(void (*function)(Arg1),\n                            Arg1 arg1) {\n  return new internal::FunctionClosure1<Arg1>(function, true, arg1);\n}\n\n// See Closure.\ntemplate <typename Arg1>\ninline Closure* NewPermanentCallback(void (*function)(Arg1),\n                                     Arg1 arg1) {\n  return new internal::FunctionClosure1<Arg1>(function, false, arg1);\n}\n\n// See Closure.\ntemplate <typename Class, typename Arg1>\ninline Closure* NewCallback(Class* object, void (Class::*method)(Arg1),\n                            Arg1 arg1) {\n  return new internal::MethodClosure1<Class, Arg1>(object, method, true, arg1);\n}\n\n// See Closure.\ntemplate <typename Class, typename Arg1>\ninline Closure* NewPermanentCallback(Class* object, void (Class::*method)(Arg1),\n                                     Arg1 arg1) {\n  return new internal::MethodClosure1<Class, Arg1>(object, method, false, arg1);\n}\n\n// See Closure.\ntemplate <typename Arg1, typename Arg2>\ninline Closure* NewCallback(void (*function)(Arg1, Arg2),\n                            Arg1 arg1, Arg2 arg2) {\n  return new internal::FunctionClosure2<Arg1, Arg2>(\n    function, true, arg1, arg2);\n}\n\n// See Closure.\ntemplate <typename Arg1, typename Arg2>\ninline Closure* NewPermanentCallback(void (*function)(Arg1, Arg2),\n                                     Arg1 arg1, Arg2 arg2) {\n  return new internal::FunctionClosure2<Arg1, Arg2>(\n    function, false, arg1, arg2);\n}\n\n// See Closure.\ntemplate <typename Class, typename Arg1, typename Arg2>\ninline Closure* NewCallback(Class* object, void (Class::*method)(Arg1, Arg2),\n                            Arg1 arg1, Arg2 arg2) {\n  return new internal::MethodClosure2<Class, Arg1, Arg2>(\n    object, method, true, arg1, arg2);\n}\n\n// See Closure.\ntemplate <typename Class, typename Arg1, typename Arg2>\ninline Closure* NewPermanentCallback(\n    Class* object, void (Class::*method)(Arg1, Arg2),\n    Arg1 arg1, Arg2 arg2) {\n  return new internal::MethodClosure2<Class, Arg1, Arg2>(\n    object, method, false, arg1, arg2);\n}\n\n// See ResultCallback\ntemplate<typename R>\ninline ResultCallback<R>* NewCallback(R (*function)()) {\n  return new internal::FunctionResultCallback_0_0<R>(function, true);\n}\n\n// See ResultCallback\ntemplate<typename R>\ninline ResultCallback<R>* NewPermanentCallback(R (*function)()) {\n  return new internal::FunctionResultCallback_0_0<R>(function, false);\n}\n\n// See ResultCallback\ntemplate<typename R, typename P1>\ninline ResultCallback<R>* NewCallback(R (*function)(P1), P1 p1) {\n  return new internal::FunctionResultCallback_1_0<R, P1>(\n      function, true, p1);\n}\n\n// See ResultCallback\ntemplate<typename R, typename P1>\ninline ResultCallback<R>* NewPermanentCallback(\n    R (*function)(P1), P1 p1) {\n  return new internal::FunctionResultCallback_1_0<R, P1>(\n      function, false, p1);\n}\n\n// See ResultCallback1\ntemplate<typename R, typename A1>\ninline ResultCallback1<R, A1>* NewCallback(R (*function)(A1)) {\n  return new internal::FunctionResultCallback_0_1<R, A1>(function, true);\n}\n\n// See ResultCallback1\ntemplate<typename R, typename A1>\ninline ResultCallback1<R, A1>* NewPermanentCallback(R (*function)(A1)) {\n  return new internal::FunctionResultCallback_0_1<R, A1>(function, false);\n}\n\n// See ResultCallback1\ntemplate<typename R, typename P1, typename A1>\ninline ResultCallback1<R, A1>* NewCallback(R (*function)(P1, A1), P1 p1) {\n  return new internal::FunctionResultCallback_1_1<R, P1, A1>(\n      function, true, p1);\n}\n\n// See ResultCallback1\ntemplate<typename R, typename P1, typename A1>\ninline ResultCallback1<R, A1>* NewPermanentCallback(\n    R (*function)(P1, A1), P1 p1) {\n  return new internal::FunctionResultCallback_1_1<R, P1, A1>(\n      function, false, p1);\n}\n\n// See MethodResultCallback_5_2\ntemplate <typename R, typename T, typename P1, typename P2, typename P3,\n          typename P4, typename P5, typename A1, typename A2>\ninline ResultCallback2<R, A1, A2>* NewPermanentCallback(\n    T* object, R (T::*function)(P1, P2, P3, P4, P5, A1, A2),\n    typename internal::InternalConstRef<P1>::type p1,\n    typename internal::InternalConstRef<P2>::type p2,\n    typename internal::InternalConstRef<P3>::type p3,\n    typename internal::InternalConstRef<P4>::type p4,\n    typename internal::InternalConstRef<P5>::type p5) {\n  return new internal::MethodResultCallback_5_2<R, T, P1, P2, P3, P4, P5, A1,\n                                                A2>(object, function, false, p1,\n                                                    p2, p3, p4, p5);\n}\n\n}  // namespace internal\n\n// A function which does nothing.  Useful for creating no-op callbacks, e.g.:\n//   Closure* nothing = NewCallback(&DoNothing);\nvoid LIBPROTOBUF_EXPORT DoNothing();\n\n\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_STUBS_CALLBACK_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/casts.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2014 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_CASTS_H__\n#define GOOGLE_PROTOBUF_CASTS_H__\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/type_traits.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n// Use implicit_cast as a safe version of static_cast or const_cast\n// for upcasting in the type hierarchy (i.e. casting a pointer to Foo\n// to a pointer to SuperclassOfFoo or casting a pointer to Foo to\n// a const pointer to Foo).\n// When you use implicit_cast, the compiler checks that the cast is safe.\n// Such explicit implicit_casts are necessary in surprisingly many\n// situations where C++ demands an exact type match instead of an\n// argument type convertable to a target type.\n//\n// The From type can be inferred, so the preferred syntax for using\n// implicit_cast is the same as for static_cast etc.:\n//\n//   implicit_cast<ToType>(expr)\n//\n// implicit_cast would have been part of the C++ standard library,\n// but the proposal was submitted too late.  It will probably make\n// its way into the language in the future.\ntemplate<typename To, typename From>\ninline To implicit_cast(From const &f) {\n  return f;\n}\n\n// When you upcast (that is, cast a pointer from type Foo to type\n// SuperclassOfFoo), it's fine to use implicit_cast<>, since upcasts\n// always succeed.  When you downcast (that is, cast a pointer from\n// type Foo to type SubclassOfFoo), static_cast<> isn't safe, because\n// how do you know the pointer is really of type SubclassOfFoo?  It\n// could be a bare Foo, or of type DifferentSubclassOfFoo.  Thus,\n// when you downcast, you should use this macro.  In debug mode, we\n// use dynamic_cast<> to double-check the downcast is legal (we die\n// if it's not).  In normal mode, we do the efficient static_cast<>\n// instead.  Thus, it's important to test in debug mode to make sure\n// the cast is legal!\n//    This is the only place in the code we should use dynamic_cast<>.\n// In particular, you SHOULDN'T be using dynamic_cast<> in order to\n// do RTTI (eg code like this:\n//    if (dynamic_cast<Subclass1>(foo)) HandleASubclass1Object(foo);\n//    if (dynamic_cast<Subclass2>(foo)) HandleASubclass2Object(foo);\n// You should design the code some other way not to need this.\n\ntemplate<typename To, typename From>     // use like this: down_cast<T*>(foo);\ninline To down_cast(From* f) {                   // so we only accept pointers\n  // Ensures that To is a sub-type of From *.  This test is here only\n  // for compile-time type checking, and has no overhead in an\n  // optimized build at run-time, as it will be optimized away\n  // completely.\n  if (false) {\n    implicit_cast<From*, To>(0);\n  }\n\n#if !defined(NDEBUG) && !defined(GOOGLE_PROTOBUF_NO_RTTI)\n  assert(f == NULL || dynamic_cast<To>(f) != NULL);  // RTTI: debug mode only!\n#endif\n  return static_cast<To>(f);\n}\n\ntemplate<typename To, typename From>    // use like this: down_cast<T&>(foo);\ninline To down_cast(From& f) {\n  typedef typename remove_reference<To>::type* ToAsPointer;\n  // Ensures that To is a sub-type of From *.  This test is here only\n  // for compile-time type checking, and has no overhead in an\n  // optimized build at run-time, as it will be optimized away\n  // completely.\n  if (false) {\n    implicit_cast<From*, ToAsPointer>(0);\n  }\n\n#if !defined(NDEBUG) && !defined(GOOGLE_PROTOBUF_NO_RTTI)\n  // RTTI: debug mode only!\n  assert(dynamic_cast<ToAsPointer>(&f) != NULL);\n#endif\n  return *static_cast<ToAsPointer>(&f);\n}\n\ntemplate<typename To, typename From>\ninline To bit_cast(const From& from) {\n  GOOGLE_COMPILE_ASSERT(sizeof(From) == sizeof(To),\n                        bit_cast_with_different_sizes);\n  To dest;\n  memcpy(&dest, &from, sizeof(dest));\n  return dest;\n}\n\n}  // namespace internal\n\n// We made these internal so that they would show up as such in the docs,\n// but we don't want to stick \"internal::\" in front of them everywhere.\nusing internal::implicit_cast;\nusing internal::down_cast;\nusing internal::bit_cast;\n\n}  // namespace protobuf\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_CASTS_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/common.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/once.h>\n#include <google/protobuf/stubs/status.h>\n#include <google/protobuf/stubs/stringpiece.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/int128.h>\n#include <errno.h>\n#include <sstream>\n#include <stdio.h>\n#include <vector>\n\n#ifdef _WIN32\n#define WIN32_LEAN_AND_MEAN  // We only need minimal includes\n#include <windows.h>\n#define snprintf _snprintf    // see comment in strutil.cc\n#elif defined(HAVE_PTHREAD)\n#include <pthread.h>\n#else\n#error \"No suitable threading library available.\"\n#endif\n#if defined(__ANDROID__)\n#include <android/log.h>\n#endif\n\nnamespace google {\nnamespace protobuf {\n\nnamespace internal {\n\nvoid VerifyVersion(int headerVersion,\n                   int minLibraryVersion,\n                   const char* filename) {\n  if (GOOGLE_PROTOBUF_VERSION < minLibraryVersion) {\n    // Library is too old for headers.\n    GOOGLE_LOG(FATAL)\n      << \"This program requires version \" << VersionString(minLibraryVersion)\n      << \" of the Protocol Buffer runtime library, but the installed version \"\n         \"is \" << VersionString(GOOGLE_PROTOBUF_VERSION) << \".  Please update \"\n         \"your library.  If you compiled the program yourself, make sure that \"\n         \"your headers are from the same version of Protocol Buffers as your \"\n         \"link-time library.  (Version verification failed in \\\"\"\n      << filename << \"\\\".)\";\n  }\n  if (headerVersion < kMinHeaderVersionForLibrary) {\n    // Headers are too old for library.\n    GOOGLE_LOG(FATAL)\n      << \"This program was compiled against version \"\n      << VersionString(headerVersion) << \" of the Protocol Buffer runtime \"\n         \"library, which is not compatible with the installed version (\"\n      << VersionString(GOOGLE_PROTOBUF_VERSION) <<  \").  Contact the program \"\n         \"author for an update.  If you compiled the program yourself, make \"\n         \"sure that your headers are from the same version of Protocol Buffers \"\n         \"as your link-time library.  (Version verification failed in \\\"\"\n      << filename << \"\\\".)\";\n  }\n}\n\nstring VersionString(int version) {\n  int major = version / 1000000;\n  int minor = (version / 1000) % 1000;\n  int micro = version % 1000;\n\n  // 128 bytes should always be enough, but we use snprintf() anyway to be\n  // safe.\n  char buffer[128];\n  snprintf(buffer, sizeof(buffer), \"%d.%d.%d\", major, minor, micro);\n\n  // Guard against broken MSVC snprintf().\n  buffer[sizeof(buffer)-1] = '\\0';\n\n  return buffer;\n}\n\n}  // namespace internal\n\n// ===================================================================\n// emulates google3/base/logging.cc\n\nnamespace internal {\n#if defined(__ANDROID__)\ninline void DefaultLogHandler(LogLevel level, const char* filename, int line,\n                              const string& message) {\n#ifdef GOOGLE_PROTOBUF_MIN_LOG_LEVEL\n  if (level < GOOGLE_PROTOBUF_MIN_LOG_LEVEL) {\n    return;\n  }\n  static const char* level_names[] = {\"INFO\", \"WARNING\", \"ERROR\", \"FATAL\"};\n\n  static const int android_log_levels[] = {\n      ANDROID_LOG_INFO,   // LOG(INFO),\n      ANDROID_LOG_WARN,   // LOG(WARNING)\n      ANDROID_LOG_ERROR,  // LOG(ERROR)\n      ANDROID_LOG_FATAL,  // LOG(FATAL)\n  };\n\n  // Bound the logging level.\n  const int android_log_level = android_log_levels[level];\n  ::std::ostringstream ostr;\n  ostr << \"[libprotobuf \" << level_names[level] << \" \" << filename << \":\"\n       << line << \"] \" << message.c_str();\n\n  // Output the log string the Android log at the appropriate level.\n  __android_log_write(android_log_level, \"libprotobuf-native\",\n                      ostr.str().c_str());\n  // Also output to std::cerr.\n  fprintf(stderr, \"%s\", ostr.str().c_str());\n  fflush(stderr);\n\n  // Indicate termination if needed.\n  if (android_log_level == ANDROID_LOG_FATAL) {\n    __android_log_write(ANDROID_LOG_FATAL, \"libprotobuf-native\",\n                        \"terminating.\\n\");\n  }\n#endif\n}\n#else\nvoid DefaultLogHandler(LogLevel level, const char* filename, int line,\n                       const string& message) {\n  static const char* level_names[] = { \"INFO\", \"WARNING\", \"ERROR\", \"FATAL\" };\n\n  // We use fprintf() instead of cerr because we want this to work at static\n  // initialization time.\n  fprintf(stderr, \"[libprotobuf %s %s:%d] %s\\n\",\n          level_names[level], filename, line, message.c_str());\n  fflush(stderr);  // Needed on MSVC.\n}\n#endif\n\nvoid NullLogHandler(LogLevel /* level */, const char* /* filename */,\n                    int /* line */, const string& /* message */) {\n  // Nothing.\n}\n\nstatic LogHandler* log_handler_ = &DefaultLogHandler;\nstatic int log_silencer_count_ = 0;\n\nstatic Mutex* log_silencer_count_mutex_ = NULL;\nGOOGLE_PROTOBUF_DECLARE_ONCE(log_silencer_count_init_);\n\nvoid DeleteLogSilencerCount() {\n  delete log_silencer_count_mutex_;\n  log_silencer_count_mutex_ = NULL;\n}\nvoid InitLogSilencerCount() {\n  log_silencer_count_mutex_ = new Mutex;\n  OnShutdown(&DeleteLogSilencerCount);\n}\nvoid InitLogSilencerCountOnce() {\n  GoogleOnceInit(&log_silencer_count_init_, &InitLogSilencerCount);\n}\n\nLogMessage& LogMessage::operator<<(const string& value) {\n  message_ += value;\n  return *this;\n}\n\nLogMessage& LogMessage::operator<<(const char* value) {\n  message_ += value;\n  return *this;\n}\n\nLogMessage& LogMessage::operator<<(const StringPiece& value) {\n  message_ += value.ToString();\n  return *this;\n}\n\nLogMessage& LogMessage::operator<<(\n    const ::google::protobuf::util::Status& status) {\n  message_ += status.ToString();\n  return *this;\n}\n\nLogMessage& LogMessage::operator<<(const uint128& value) {\n  std::ostringstream str;\n  str << value;\n  message_ += str.str();\n  return *this;\n}\n\n// Since this is just for logging, we don't care if the current locale changes\n// the results -- in fact, we probably prefer that.  So we use snprintf()\n// instead of Simple*toa().\n#undef DECLARE_STREAM_OPERATOR\n#define DECLARE_STREAM_OPERATOR(TYPE, FORMAT)                       \\\n  LogMessage& LogMessage::operator<<(TYPE value) {                  \\\n    /* 128 bytes should be big enough for any of the primitive */   \\\n    /* values which we print with this, but well use snprintf() */  \\\n    /* anyway to be extra safe. */                                  \\\n    char buffer[128];                                               \\\n    snprintf(buffer, sizeof(buffer), FORMAT, value);                \\\n    /* Guard against broken MSVC snprintf(). */                     \\\n    buffer[sizeof(buffer)-1] = '\\0';                                \\\n    message_ += buffer;                                             \\\n    return *this;                                                   \\\n  }\n\nDECLARE_STREAM_OPERATOR(char         , \"%c\" )\nDECLARE_STREAM_OPERATOR(int          , \"%d\" )\nDECLARE_STREAM_OPERATOR(unsigned int , \"%u\" )\nDECLARE_STREAM_OPERATOR(long         , \"%ld\")\nDECLARE_STREAM_OPERATOR(unsigned long, \"%lu\")\nDECLARE_STREAM_OPERATOR(double       , \"%g\" )\nDECLARE_STREAM_OPERATOR(void*        , \"%p\" )\nDECLARE_STREAM_OPERATOR(long long         , \"%\" GOOGLE_LL_FORMAT \"d\")\nDECLARE_STREAM_OPERATOR(unsigned long long, \"%\" GOOGLE_LL_FORMAT \"u\")\n#undef DECLARE_STREAM_OPERATOR\n\nLogMessage::LogMessage(LogLevel level, const char* filename, int line)\n  : level_(level), filename_(filename), line_(line) {}\nLogMessage::~LogMessage() {}\n\nvoid LogMessage::Finish() {\n  bool suppress = false;\n\n  if (level_ != LOGLEVEL_FATAL) {\n    InitLogSilencerCountOnce();\n    MutexLock lock(log_silencer_count_mutex_);\n    suppress = log_silencer_count_ > 0;\n  }\n\n  if (!suppress) {\n    log_handler_(level_, filename_, line_, message_);\n  }\n\n  if (level_ == LOGLEVEL_FATAL) {\n#if PROTOBUF_USE_EXCEPTIONS\n    throw FatalException(filename_, line_, message_);\n#else\n    abort();\n#endif\n  }\n}\n\nvoid LogFinisher::operator=(LogMessage& other) {\n  other.Finish();\n}\n\n}  // namespace internal\n\nLogHandler* SetLogHandler(LogHandler* new_func) {\n  LogHandler* old = internal::log_handler_;\n  if (old == &internal::NullLogHandler) {\n    old = NULL;\n  }\n  if (new_func == NULL) {\n    internal::log_handler_ = &internal::NullLogHandler;\n  } else {\n    internal::log_handler_ = new_func;\n  }\n  return old;\n}\n\nLogSilencer::LogSilencer() {\n  internal::InitLogSilencerCountOnce();\n  MutexLock lock(internal::log_silencer_count_mutex_);\n  ++internal::log_silencer_count_;\n};\n\nLogSilencer::~LogSilencer() {\n  internal::InitLogSilencerCountOnce();\n  MutexLock lock(internal::log_silencer_count_mutex_);\n  --internal::log_silencer_count_;\n};\n\n// ===================================================================\n// emulates google3/base/callback.cc\n\nClosure::~Closure() {}\n\nnamespace internal { FunctionClosure0::~FunctionClosure0() {} }\n\nvoid DoNothing() {}\n\n// ===================================================================\n// emulates google3/base/mutex.cc\n\n#ifdef _WIN32\n\nstruct Mutex::Internal {\n  CRITICAL_SECTION mutex;\n#ifndef NDEBUG\n  // Used only to implement AssertHeld().\n  DWORD thread_id;\n#endif\n};\n\nMutex::Mutex()\n  : mInternal(new Internal) {\n  InitializeCriticalSection(&mInternal->mutex);\n}\n\nMutex::~Mutex() {\n  DeleteCriticalSection(&mInternal->mutex);\n  delete mInternal;\n}\n\nvoid Mutex::Lock() {\n  EnterCriticalSection(&mInternal->mutex);\n#ifndef NDEBUG\n  mInternal->thread_id = GetCurrentThreadId();\n#endif\n}\n\nvoid Mutex::Unlock() {\n#ifndef NDEBUG\n  mInternal->thread_id = 0;\n#endif\n  LeaveCriticalSection(&mInternal->mutex);\n}\n\nvoid Mutex::AssertHeld() {\n#ifndef NDEBUG\n  GOOGLE_DCHECK_EQ(mInternal->thread_id, GetCurrentThreadId());\n#endif\n}\n\n#elif defined(HAVE_PTHREAD)\n\nstruct Mutex::Internal {\n  pthread_mutex_t mutex;\n};\n\nMutex::Mutex()\n  : mInternal(new Internal) {\n  pthread_mutex_init(&mInternal->mutex, NULL);\n}\n\nMutex::~Mutex() {\n  pthread_mutex_destroy(&mInternal->mutex);\n  delete mInternal;\n}\n\nvoid Mutex::Lock() {\n  int result = pthread_mutex_lock(&mInternal->mutex);\n  if (result != 0) {\n    GOOGLE_LOG(FATAL) << \"pthread_mutex_lock: \" << strerror(result);\n  }\n}\n\nvoid Mutex::Unlock() {\n  int result = pthread_mutex_unlock(&mInternal->mutex);\n  if (result != 0) {\n    GOOGLE_LOG(FATAL) << \"pthread_mutex_unlock: \" << strerror(result);\n  }\n}\n\nvoid Mutex::AssertHeld() {\n  // pthreads dosn't provide a way to check which thread holds the mutex.\n  // TODO(kenton):  Maybe keep track of locking thread ID like with WIN32?\n}\n\n#endif\n\n// ===================================================================\n// emulates google3/util/endian/endian.h\n//\n// TODO(xiaofeng): PROTOBUF_LITTLE_ENDIAN is unfortunately defined in\n// google/protobuf/io/coded_stream.h and therefore can not be used here.\n// Maybe move that macro definition here in the furture.\nuint32 ghtonl(uint32 x) {\n  union {\n    uint32 result;\n    uint8 result_array[4];\n  };\n  result_array[0] = static_cast<uint8>(x >> 24);\n  result_array[1] = static_cast<uint8>((x >> 16) & 0xFF);\n  result_array[2] = static_cast<uint8>((x >> 8) & 0xFF);\n  result_array[3] = static_cast<uint8>(x & 0xFF);\n  return result;\n}\n\n// ===================================================================\n// Shutdown support.\n\nnamespace internal {\n\ntypedef void OnShutdownFunc();\nvector<void (*)()>* shutdown_functions = NULL;\nMutex* shutdown_functions_mutex = NULL;\nGOOGLE_PROTOBUF_DECLARE_ONCE(shutdown_functions_init);\n\nvoid InitShutdownFunctions() {\n  shutdown_functions = new vector<void (*)()>;\n  shutdown_functions_mutex = new Mutex;\n}\n\ninline void InitShutdownFunctionsOnce() {\n  GoogleOnceInit(&shutdown_functions_init, &InitShutdownFunctions);\n}\n\nvoid OnShutdown(void (*func)()) {\n  InitShutdownFunctionsOnce();\n  MutexLock lock(shutdown_functions_mutex);\n  shutdown_functions->push_back(func);\n}\n\n}  // namespace internal\n\nvoid ShutdownProtobufLibrary() {\n  internal::InitShutdownFunctionsOnce();\n\n  // We don't need to lock shutdown_functions_mutex because it's up to the\n  // caller to make sure that no one is using the library before this is\n  // called.\n\n  // Make it safe to call this multiple times.\n  if (internal::shutdown_functions == NULL) return;\n\n  for (int i = 0; i < internal::shutdown_functions->size(); i++) {\n    internal::shutdown_functions->at(i)();\n  }\n  delete internal::shutdown_functions;\n  internal::shutdown_functions = NULL;\n  delete internal::shutdown_functions_mutex;\n  internal::shutdown_functions_mutex = NULL;\n}\n\n#if PROTOBUF_USE_EXCEPTIONS\nFatalException::~FatalException() throw() {}\n\nconst char* FatalException::what() const throw() {\n  return message_.c_str();\n}\n#endif\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/common.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda) and others\n//\n// Contains basic types and utilities used by the rest of the library.\n\n#ifndef GOOGLE_PROTOBUF_COMMON_H__\n#define GOOGLE_PROTOBUF_COMMON_H__\n\n#include <string>\n\n#include <google/protobuf/stubs/port.h>\n#include <google/protobuf/stubs/macros.h>\n#include <google/protobuf/stubs/platform_macros.h>\n\n// TODO(liujisi): Remove the following includes after the include clean-up.\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/scoped_ptr.h>\n#include <google/protobuf/stubs/mutex.h>\n#include <google/protobuf/stubs/callback.h>\n\n#ifndef PROTOBUF_USE_EXCEPTIONS\n#if defined(_MSC_VER) && defined(_CPPUNWIND)\n  #define PROTOBUF_USE_EXCEPTIONS 1\n#elif defined(__EXCEPTIONS)\n  #define PROTOBUF_USE_EXCEPTIONS 1\n#else\n  #define PROTOBUF_USE_EXCEPTIONS 0\n#endif\n#endif\n\n#if PROTOBUF_USE_EXCEPTIONS\n#include <exception>\n#endif\n#if defined(__APPLE__)\n#include <TargetConditionals.h>  // for TARGET_OS_IPHONE\n#endif\n\n#if defined(__ANDROID__) || defined(GOOGLE_PROTOBUF_OS_ANDROID) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) || defined(GOOGLE_PROTOBUF_OS_IPHONE)\n#include <pthread.h>\n#endif\n\n#if defined(_WIN32) && defined(GetMessage)\n// Allow GetMessage to be used as a valid method name in protobuf classes.\n// windows.h defines GetMessage() as a macro.  Let's re-define it as an inline\n// function.  The inline function should be equivalent for C++ users.\ninline BOOL GetMessage_Win32(\n    LPMSG lpMsg, HWND hWnd,\n    UINT wMsgFilterMin, UINT wMsgFilterMax) {\n  return GetMessage(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);\n}\n#undef GetMessage\ninline BOOL GetMessage(\n    LPMSG lpMsg, HWND hWnd,\n    UINT wMsgFilterMin, UINT wMsgFilterMax) {\n  return GetMessage_Win32(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax);\n}\n#endif\n\nnamespace std {}\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\n// Some of these constants are macros rather than const ints so that they can\n// be used in #if directives.\n\n// The current version, represented as a single integer to make comparison\n// easier:  major * 10^6 + minor * 10^3 + micro\n#define GOOGLE_PROTOBUF_VERSION 3000000\n\n// The minimum library version which works with the current version of the\n// headers.\n#define GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION 3000000\n\n// The minimum header version which works with the current version of\n// the library.  This constant should only be used by protoc's C++ code\n// generator.\nstatic const int kMinHeaderVersionForLibrary = 3000000;\n\n// The minimum protoc version which works with the current version of the\n// headers.\n#define GOOGLE_PROTOBUF_MIN_PROTOC_VERSION 3000000\n\n// The minimum header version which works with the current version of\n// protoc.  This constant should only be used in VerifyVersion().\nstatic const int kMinHeaderVersionForProtoc = 3000000;\n\n// Verifies that the headers and libraries are compatible.  Use the macro\n// below to call this.\nvoid LIBPROTOBUF_EXPORT VerifyVersion(int headerVersion, int minLibraryVersion,\n                                      const char* filename);\n\n// Converts a numeric version number to a string.\nstd::string LIBPROTOBUF_EXPORT VersionString(int version);\n\n}  // namespace internal\n\n// Place this macro in your main() function (or somewhere before you attempt\n// to use the protobuf library) to verify that the version you link against\n// matches the headers you compiled against.  If a version mismatch is\n// detected, the process will abort.\n#define GOOGLE_PROTOBUF_VERIFY_VERSION                                    \\\n  ::google::protobuf::internal::VerifyVersion(                            \\\n    GOOGLE_PROTOBUF_VERSION, GOOGLE_PROTOBUF_MIN_LIBRARY_VERSION,         \\\n    __FILE__)\n\n\n// ===================================================================\n// from google3/util/utf8/public/unilib.h\n\nclass StringPiece;\nnamespace internal {\n\n// Checks if the buffer contains structurally-valid UTF-8.  Implemented in\n// structurally_valid.cc.\nLIBPROTOBUF_EXPORT bool IsStructurallyValidUTF8(const char* buf, int len);\n\ninline bool IsStructurallyValidUTF8(const std::string& str) {\n  return IsStructurallyValidUTF8(str.data(), static_cast<int>(str.length()));\n}\n\n// Returns initial number of bytes of structually valid UTF-8.\nLIBPROTOBUF_EXPORT int UTF8SpnStructurallyValid(const StringPiece& str);\n\n// Coerce UTF-8 byte string in src_str to be\n// a structurally-valid equal-length string by selectively\n// overwriting illegal bytes with replace_char (typically ' ' or '?').\n// replace_char must be legal printable 7-bit Ascii 0x20..0x7e.\n// src_str is read-only.\n//\n// Returns pointer to output buffer, src_str.data() if no changes were made,\n//  or idst if some bytes were changed. idst is allocated by the caller\n//  and must be at least as big as src_str\n//\n// Optimized for: all structurally valid and no byte copying is done.\n//\nLIBPROTOBUF_EXPORT char* UTF8CoerceToStructurallyValid(\n    const StringPiece& str, char* dst, char replace_char);\n\n}  // namespace internal\n\n\n// ===================================================================\n// Shutdown support.\n\n// Shut down the entire protocol buffers library, deleting all static-duration\n// objects allocated by the library or by generated .pb.cc files.\n//\n// There are two reasons you might want to call this:\n// * You use a draconian definition of \"memory leak\" in which you expect\n//   every single malloc() to have a corresponding free(), even for objects\n//   which live until program exit.\n// * You are writing a dynamically-loaded library which needs to clean up\n//   after itself when the library is unloaded.\n//\n// It is safe to call this multiple times.  However, it is not safe to use\n// any other part of the protocol buffers library after\n// ShutdownProtobufLibrary() has been called.\nLIBPROTOBUF_EXPORT void ShutdownProtobufLibrary();\n\nnamespace internal {\n\n// Register a function to be called when ShutdownProtocolBuffers() is called.\nLIBPROTOBUF_EXPORT void OnShutdown(void (*func)());\n\n}  // namespace internal\n\n#if PROTOBUF_USE_EXCEPTIONS\nclass FatalException : public std::exception {\n public:\n  FatalException(const char* filename, int line, const std::string& message)\n      : filename_(filename), line_(line), message_(message) {}\n  virtual ~FatalException() throw();\n\n  virtual const char* what() const throw();\n\n  const char* filename() const { return filename_; }\n  int line() const { return line_; }\n  const std::string& message() const { return message_; }\n\n private:\n  const char* filename_;\n  const int line_;\n  const std::string message_;\n};\n#endif\n\n// This is at the end of the file instead of the beginning to work around a bug\n// in some versions of MSVC.\nusing namespace std;  // Don't do this at home, kids.\n\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_COMMON_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/common_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n\n#include <vector>\n#include <google/protobuf/stubs/casts.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nusing internal::NewCallback;\nusing internal::NewPermanentCallback;\nnamespace {\n\n// TODO(kenton):  More tests.\n\n#ifdef PACKAGE_VERSION  // only defined when using automake, not MSVC\n\nTEST(VersionTest, VersionMatchesConfig) {\n  // Verify that the version string specified in config.h matches the one\n  // in common.h.  The config.h version is a string which may have a suffix\n  // like \"beta\" or \"rc1\", so we remove that.\n  string version = PACKAGE_VERSION;\n  int pos = 0;\n  while (pos < version.size() &&\n         (ascii_isdigit(version[pos]) || version[pos] == '.')) {\n    ++pos;\n  }\n  version.erase(pos);\n\n  EXPECT_EQ(version, internal::VersionString(GOOGLE_PROTOBUF_VERSION));\n}\n\n#endif  // PACKAGE_VERSION\n\nTEST(CommonTest, IntMinMaxConstants) {\n  // kint32min was declared incorrectly in the first release of protobufs.\n  // Ugh.\n  EXPECT_LT(kint32min, kint32max);\n  EXPECT_EQ(static_cast<uint32>(kint32min), static_cast<uint32>(kint32max) + 1);\n  EXPECT_LT(kint64min, kint64max);\n  EXPECT_EQ(static_cast<uint64>(kint64min), static_cast<uint64>(kint64max) + 1);\n  EXPECT_EQ(0, kuint32max + 1);\n  EXPECT_EQ(0, kuint64max + 1);\n}\n\nvector<string> captured_messages_;\n\nvoid CaptureLog(LogLevel level, const char* filename, int line,\n                const string& message) {\n  captured_messages_.push_back(\n    strings::Substitute(\"$0 $1:$2: $3\",\n      implicit_cast<int>(level), filename, line, message));\n}\n\nTEST(LoggingTest, DefaultLogging) {\n  CaptureTestStderr();\n  int line = __LINE__;\n  GOOGLE_LOG(INFO   ) << \"A message.\";\n  GOOGLE_LOG(WARNING) << \"A warning.\";\n  GOOGLE_LOG(ERROR  ) << \"An error.\";\n\n  string text = GetCapturedTestStderr();\n  EXPECT_EQ(\n    \"[libprotobuf INFO \" __FILE__ \":\" + SimpleItoa(line + 1) + \"] A message.\\n\"\n    \"[libprotobuf WARNING \" __FILE__ \":\" + SimpleItoa(line + 2) + \"] A warning.\\n\"\n    \"[libprotobuf ERROR \" __FILE__ \":\" + SimpleItoa(line + 3) + \"] An error.\\n\",\n    text);\n}\n\nTEST(LoggingTest, NullLogging) {\n  LogHandler* old_handler = SetLogHandler(NULL);\n\n  CaptureTestStderr();\n  GOOGLE_LOG(INFO   ) << \"A message.\";\n  GOOGLE_LOG(WARNING) << \"A warning.\";\n  GOOGLE_LOG(ERROR  ) << \"An error.\";\n\n  EXPECT_TRUE(SetLogHandler(old_handler) == NULL);\n\n  string text = GetCapturedTestStderr();\n  EXPECT_EQ(\"\", text);\n}\n\nTEST(LoggingTest, CaptureLogging) {\n  captured_messages_.clear();\n\n  LogHandler* old_handler = SetLogHandler(&CaptureLog);\n\n  int start_line = __LINE__;\n  GOOGLE_LOG(ERROR) << \"An error.\";\n  GOOGLE_LOG(WARNING) << \"A warning.\";\n\n  EXPECT_TRUE(SetLogHandler(old_handler) == &CaptureLog);\n\n  ASSERT_EQ(2, captured_messages_.size());\n  EXPECT_EQ(\n    \"2 \" __FILE__ \":\" + SimpleItoa(start_line + 1) + \": An error.\",\n    captured_messages_[0]);\n  EXPECT_EQ(\n    \"1 \" __FILE__ \":\" + SimpleItoa(start_line + 2) + \": A warning.\",\n    captured_messages_[1]);\n}\n\nTEST(LoggingTest, SilenceLogging) {\n  captured_messages_.clear();\n\n  LogHandler* old_handler = SetLogHandler(&CaptureLog);\n\n  int line1 = __LINE__; GOOGLE_LOG(INFO) << \"Visible1\";\n  LogSilencer* silencer1 = new LogSilencer;\n  GOOGLE_LOG(INFO) << \"Not visible.\";\n  LogSilencer* silencer2 = new LogSilencer;\n  GOOGLE_LOG(INFO) << \"Not visible.\";\n  delete silencer1;\n  GOOGLE_LOG(INFO) << \"Not visible.\";\n  delete silencer2;\n  int line2 = __LINE__; GOOGLE_LOG(INFO) << \"Visible2\";\n\n  EXPECT_TRUE(SetLogHandler(old_handler) == &CaptureLog);\n\n  ASSERT_EQ(2, captured_messages_.size());\n  EXPECT_EQ(\n    \"0 \" __FILE__ \":\" + SimpleItoa(line1) + \": Visible1\",\n    captured_messages_[0]);\n  EXPECT_EQ(\n    \"0 \" __FILE__ \":\" + SimpleItoa(line2) + \": Visible2\",\n    captured_messages_[1]);\n}\n\nclass ClosureTest : public testing::Test {\n public:\n  void SetA123Method()   { a_ = 123; }\n  static void SetA123Function() { current_instance_->a_ = 123; }\n\n  void SetAMethod(int a)         { a_ = a; }\n  void SetCMethod(string c)      { c_ = c; }\n\n  static void SetAFunction(int a)         { current_instance_->a_ = a; }\n  static void SetCFunction(string c)      { current_instance_->c_ = c; }\n\n  void SetABMethod(int a, const char* b)  { a_ = a; b_ = b; }\n  static void SetABFunction(int a, const char* b) {\n    current_instance_->a_ = a;\n    current_instance_->b_ = b;\n  }\n\n  virtual void SetUp() {\n    current_instance_ = this;\n    a_ = 0;\n    b_ = NULL;\n    c_.clear();\n    permanent_closure_ = NULL;\n  }\n\n  void DeleteClosureInCallback() {\n    delete permanent_closure_;\n  }\n\n  int a_;\n  const char* b_;\n  string c_;\n  Closure* permanent_closure_;\n\n  static ClosureTest* current_instance_;\n};\n\nClosureTest* ClosureTest::current_instance_ = NULL;\n\nTEST_F(ClosureTest, TestClosureFunction0) {\n  Closure* closure = NewCallback(&SetA123Function);\n  EXPECT_NE(123, a_);\n  closure->Run();\n  EXPECT_EQ(123, a_);\n}\n\nTEST_F(ClosureTest, TestClosureMethod0) {\n  Closure* closure = NewCallback(current_instance_,\n                                 &ClosureTest::SetA123Method);\n  EXPECT_NE(123, a_);\n  closure->Run();\n  EXPECT_EQ(123, a_);\n}\n\nTEST_F(ClosureTest, TestClosureFunction1) {\n  Closure* closure = NewCallback(&SetAFunction, 456);\n  EXPECT_NE(456, a_);\n  closure->Run();\n  EXPECT_EQ(456, a_);\n}\n\nTEST_F(ClosureTest, TestClosureMethod1) {\n  Closure* closure = NewCallback(current_instance_,\n                                 &ClosureTest::SetAMethod, 456);\n  EXPECT_NE(456, a_);\n  closure->Run();\n  EXPECT_EQ(456, a_);\n}\n\nTEST_F(ClosureTest, TestClosureFunction1String) {\n  Closure* closure = NewCallback(&SetCFunction, string(\"test\"));\n  EXPECT_NE(\"test\", c_);\n  closure->Run();\n  EXPECT_EQ(\"test\", c_);\n}\n\nTEST_F(ClosureTest, TestClosureMethod1String) {\n  Closure* closure = NewCallback(current_instance_,\n                                 &ClosureTest::SetCMethod, string(\"test\"));\n  EXPECT_NE(\"test\", c_);\n  closure->Run();\n  EXPECT_EQ(\"test\", c_);\n}\n\nTEST_F(ClosureTest, TestClosureFunction2) {\n  const char* cstr = \"hello\";\n  Closure* closure = NewCallback(&SetABFunction, 789, cstr);\n  EXPECT_NE(789, a_);\n  EXPECT_NE(cstr, b_);\n  closure->Run();\n  EXPECT_EQ(789, a_);\n  EXPECT_EQ(cstr, b_);\n}\n\nTEST_F(ClosureTest, TestClosureMethod2) {\n  const char* cstr = \"hello\";\n  Closure* closure = NewCallback(current_instance_,\n                                 &ClosureTest::SetABMethod, 789, cstr);\n  EXPECT_NE(789, a_);\n  EXPECT_NE(cstr, b_);\n  closure->Run();\n  EXPECT_EQ(789, a_);\n  EXPECT_EQ(cstr, b_);\n}\n\n// Repeat all of the above with NewPermanentCallback()\n\nTEST_F(ClosureTest, TestPermanentClosureFunction0) {\n  Closure* closure = NewPermanentCallback(&SetA123Function);\n  EXPECT_NE(123, a_);\n  closure->Run();\n  EXPECT_EQ(123, a_);\n  a_ = 0;\n  closure->Run();\n  EXPECT_EQ(123, a_);\n  delete closure;\n}\n\nTEST_F(ClosureTest, TestPermanentClosureMethod0) {\n  Closure* closure = NewPermanentCallback(current_instance_,\n                                          &ClosureTest::SetA123Method);\n  EXPECT_NE(123, a_);\n  closure->Run();\n  EXPECT_EQ(123, a_);\n  a_ = 0;\n  closure->Run();\n  EXPECT_EQ(123, a_);\n  delete closure;\n}\n\nTEST_F(ClosureTest, TestPermanentClosureFunction1) {\n  Closure* closure = NewPermanentCallback(&SetAFunction, 456);\n  EXPECT_NE(456, a_);\n  closure->Run();\n  EXPECT_EQ(456, a_);\n  a_ = 0;\n  closure->Run();\n  EXPECT_EQ(456, a_);\n  delete closure;\n}\n\nTEST_F(ClosureTest, TestPermanentClosureMethod1) {\n  Closure* closure = NewPermanentCallback(current_instance_,\n                                          &ClosureTest::SetAMethod, 456);\n  EXPECT_NE(456, a_);\n  closure->Run();\n  EXPECT_EQ(456, a_);\n  a_ = 0;\n  closure->Run();\n  EXPECT_EQ(456, a_);\n  delete closure;\n}\n\nTEST_F(ClosureTest, TestPermanentClosureFunction2) {\n  const char* cstr = \"hello\";\n  Closure* closure = NewPermanentCallback(&SetABFunction, 789, cstr);\n  EXPECT_NE(789, a_);\n  EXPECT_NE(cstr, b_);\n  closure->Run();\n  EXPECT_EQ(789, a_);\n  EXPECT_EQ(cstr, b_);\n  a_ = 0;\n  b_ = NULL;\n  closure->Run();\n  EXPECT_EQ(789, a_);\n  EXPECT_EQ(cstr, b_);\n  delete closure;\n}\n\nTEST_F(ClosureTest, TestPermanentClosureMethod2) {\n  const char* cstr = \"hello\";\n  Closure* closure = NewPermanentCallback(current_instance_,\n                                          &ClosureTest::SetABMethod, 789, cstr);\n  EXPECT_NE(789, a_);\n  EXPECT_NE(cstr, b_);\n  closure->Run();\n  EXPECT_EQ(789, a_);\n  EXPECT_EQ(cstr, b_);\n  a_ = 0;\n  b_ = NULL;\n  closure->Run();\n  EXPECT_EQ(789, a_);\n  EXPECT_EQ(cstr, b_);\n  delete closure;\n}\n\nTEST_F(ClosureTest, TestPermanentClosureDeleteInCallback) {\n  permanent_closure_ = NewPermanentCallback((ClosureTest*) this,\n      &ClosureTest::DeleteClosureInCallback);\n  permanent_closure_->Run();\n}\n\n}  // anonymous namespace\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/fastmem.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2014 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Fast memory copying and comparison routines.\n//   strings::fastmemcmp_inlined() replaces memcmp()\n//   strings::memcpy_inlined() replaces memcpy()\n//   strings::memeq(a, b, n) replaces memcmp(a, b, n) == 0\n//\n// strings::*_inlined() routines are inline versions of the\n// routines exported by this module.  Sometimes using the inlined\n// versions is faster.  Measure before using the inlined versions.\n//\n// Performance measurement:\n//   strings::fastmemcmp_inlined\n//     Analysis: memcmp, fastmemcmp_inlined, fastmemcmp\n//     2012-01-30\n\n#ifndef GOOGLE_PROTOBUF_STUBS_FASTMEM_H_\n#define GOOGLE_PROTOBUF_STUBS_FASTMEM_H_\n\n#include <stddef.h>\n#include <stdio.h>\n#include <string.h>\n\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\n// Return true if the n bytes at a equal the n bytes at b.\n// The regions are allowed to overlap.\n//\n// The performance is similar to the performance memcmp(), but faster for\n// moderately-sized inputs, or inputs that share a common prefix and differ\n// somewhere in their last 8 bytes. Further optimizations can be added later\n// if it makes sense to do so.:w\ninline bool memeq(const char* a, const char* b, size_t n) {\n  size_t n_rounded_down = n & ~static_cast<size_t>(7);\n  if (GOOGLE_PREDICT_FALSE(n_rounded_down == 0)) {  // n <= 7\n    return memcmp(a, b, n) == 0;\n  }\n  // n >= 8\n  uint64 u = GOOGLE_UNALIGNED_LOAD64(a) ^ GOOGLE_UNALIGNED_LOAD64(b);\n  uint64 v = GOOGLE_UNALIGNED_LOAD64(a + n - 8) ^ GOOGLE_UNALIGNED_LOAD64(b + n - 8);\n  if ((u | v) != 0) {  // The first or last 8 bytes differ.\n    return false;\n  }\n  a += 8;\n  b += 8;\n  n = n_rounded_down - 8;\n  if (n > 128) {\n    // As of 2012, memcmp on x86-64 uses a big unrolled loop with SSE2\n    // instructions, and while we could try to do something faster, it\n    // doesn't seem worth pursuing.\n    return memcmp(a, b, n) == 0;\n  }\n  for (; n >= 16; n -= 16) {\n    uint64 x = GOOGLE_UNALIGNED_LOAD64(a) ^ GOOGLE_UNALIGNED_LOAD64(b);\n    uint64 y = GOOGLE_UNALIGNED_LOAD64(a + 8) ^ GOOGLE_UNALIGNED_LOAD64(b + 8);\n    if ((x | y) != 0) {\n      return false;\n    }\n    a += 16;\n    b += 16;\n  }\n  // n must be 0 or 8 now because it was a multiple of 8 at the top of the loop.\n  return n == 0 || GOOGLE_UNALIGNED_LOAD64(a) == GOOGLE_UNALIGNED_LOAD64(b);\n}\n\ninline int fastmemcmp_inlined(const char *a, const char *b, size_t n) {\n  if (n >= 64) {\n    return memcmp(a, b, n);\n  }\n  const char* a_limit = a + n;\n  while (a + sizeof(uint64) <= a_limit &&\n         GOOGLE_UNALIGNED_LOAD64(a) == GOOGLE_UNALIGNED_LOAD64(b)) {\n    a += sizeof(uint64);\n    b += sizeof(uint64);\n  }\n  if (a + sizeof(uint32) <= a_limit &&\n      GOOGLE_UNALIGNED_LOAD32(a) == GOOGLE_UNALIGNED_LOAD32(b)) {\n    a += sizeof(uint32);\n    b += sizeof(uint32);\n  }\n  while (a < a_limit) {\n    int d = static_cast<uint32>(*a++) - static_cast<uint32>(*b++);\n    if (d) return d;\n  }\n  return 0;\n}\n\n// The standard memcpy operation is slow for variable small sizes.\n// This implementation inlines the optimal realization for sizes 1 to 16.\n// To avoid code bloat don't use it in case of not performance-critical spots,\n// nor when you don't expect very frequent values of size <= 16.\ninline void memcpy_inlined(char *dst, const char *src, size_t size) {\n  // Compiler inlines code with minimal amount of data movement when third\n  // parameter of memcpy is a constant.\n  switch (size) {\n    case  1: memcpy(dst, src, 1); break;\n    case  2: memcpy(dst, src, 2); break;\n    case  3: memcpy(dst, src, 3); break;\n    case  4: memcpy(dst, src, 4); break;\n    case  5: memcpy(dst, src, 5); break;\n    case  6: memcpy(dst, src, 6); break;\n    case  7: memcpy(dst, src, 7); break;\n    case  8: memcpy(dst, src, 8); break;\n    case  9: memcpy(dst, src, 9); break;\n    case 10: memcpy(dst, src, 10); break;\n    case 11: memcpy(dst, src, 11); break;\n    case 12: memcpy(dst, src, 12); break;\n    case 13: memcpy(dst, src, 13); break;\n    case 14: memcpy(dst, src, 14); break;\n    case 15: memcpy(dst, src, 15); break;\n    case 16: memcpy(dst, src, 16); break;\n    default: memcpy(dst, src, size); break;\n  }\n}\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_STUBS_FASTMEM_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/hash.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//\n// Deals with the fact that hash_map is not defined everywhere.\n\n#ifndef GOOGLE_PROTOBUF_STUBS_HASH_H__\n#define GOOGLE_PROTOBUF_STUBS_HASH_H__\n\n#include <string.h>\n#include <google/protobuf/stubs/common.h>\n\n#define GOOGLE_PROTOBUF_HAVE_HASH_MAP 1\n#define GOOGLE_PROTOBUF_HAVE_HASH_SET 1\n\n// Android\n#if defined(__ANDROID__)\n# undef GOOGLE_PROTOBUF_HAVE_HASH_MAP\n# undef GOOGLE_PROTOBUF_HAVE_HASH_MAP\n\n// Use C++11 unordered_{map|set} if available.\n#elif ((_LIBCPP_STD_VER >= 11) || \\\n      (((__cplusplus >= 201103L) || defined(__GXX_EXPERIMENTAL_CXX0X)) && \\\n      (__GLIBCXX__ > 20090421)))\n# define GOOGLE_PROTOBUF_HAS_CXX11_HASH\n\n// For XCode >= 4.6:  the compiler is clang with libc++.\n// For earlier XCode version: the compiler is gcc-4.2.1 with libstdc++.\n// libc++ provides <unordered_map> and friends even in non C++11 mode,\n// and it does not provide the tr1 library. Therefore the following macro\n// checks against this special case.\n// Note that we should not test the __APPLE_CC__ version number or the\n// __clang__ macro, since the new compiler can still use -stdlib=libstdc++, in\n// which case <unordered_map> is not compilable without -std=c++11\n#elif defined(__APPLE_CC__)\n# if __GNUC__ >= 4\n#  define GOOGLE_PROTOBUF_HAS_TR1\n# else\n// Not tested for gcc < 4... These setting can compile under 4.2.1 though.\n#  define GOOGLE_PROTOBUF_HASH_NAMESPACE __gnu_cxx\n#  include <ext/hash_map>\n#  define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map\n#  include <ext/hash_set>\n#  define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set\n# endif\n\n// Version checks for gcc.\n#elif defined(__GNUC__)\n// For GCC 4.x+, use tr1::unordered_map/set; otherwise, follow the\n// instructions from:\n// https://gcc.gnu.org/onlinedocs/libstdc++/manual/backwards.html\n# if __GNUC__ >= 4\n#  define GOOGLE_PROTOBUF_HAS_TR1\n# elif __GNUC__ >= 3\n#  include <backward/hash_map>\n#  define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map\n#  include <backward/hash_set>\n#  define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set\n#  if __GNUC__ == 3 && __GNUC_MINOR__ == 0\n#   define GOOGLE_PROTOBUF_HASH_NAMESPACE std       // GCC 3.0\n#  else\n#   define GOOGLE_PROTOBUF_HASH_NAMESPACE __gnu_cxx // GCC 3.1 and later\n#  endif\n# else\n#  define GOOGLE_PROTOBUF_HASH_NAMESPACE\n#  include <hash_map>\n#  define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map\n#  include <hash_set>\n#  define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set\n# endif\n\n// Version checks for MSC.\n// Apparently Microsoft decided to move hash_map *back* to the std namespace in\n// MSVC 2010:\n// http://blogs.msdn.com/vcblog/archive/2009/05/25/stl-breaking-changes-in-visual-studio-2010-beta-1.aspx\n// And.. they are moved back to stdext in MSVC 2013 (haven't checked 2012). That\n// said, use unordered_map for MSVC 2010 and beyond is our safest bet.\n#elif defined(_MSC_VER)\n# if _MSC_VER >= 1600  // Since Visual Studio 2010\n#  define GOOGLE_PROTOBUF_HAS_CXX11_HASH\n#  define GOOGLE_PROTOBUF_HASH_COMPARE std::hash_compare\n# elif _MSC_VER >= 1500  // Since Visual Studio 2008\n#  define GOOGLE_PROTOBUF_HASH_NAMESPACE stdext\n#  include <hash_map>\n#  define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map\n#  include <hash_set>\n#  define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set\n#  define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare\n#  define GOOGLE_PROTOBUF_CONTAINERS_NEED_HASH_COMPARE\n# elif _MSC_VER >= 1310\n#  define GOOGLE_PROTOBUF_HASH_NAMESPACE stdext\n#  include <hash_map>\n#  define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map\n#  include <hash_set>\n#  define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set\n#  define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare\n# else\n#  define GOOGLE_PROTOBUF_HASH_NAMESPACE std\n#  include <hash_map>\n#  define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map\n#  include <hash_set>\n#  define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set\n#  define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare\n# endif\n\n// **ADD NEW COMPILERS SUPPORT HERE.**\n// For other compilers, undefine the macro and fallback to use std::map, in\n// google/protobuf/stubs/hash.h\n#else\n# undef GOOGLE_PROTOBUF_HAVE_HASH_MAP\n# undef GOOGLE_PROTOBUF_HAVE_HASH_SET\n#endif\n\n#if defined(GOOGLE_PROTOBUF_HAS_CXX11_HASH)\n# define GOOGLE_PROTOBUF_HASH_NAMESPACE std\n# include <unordered_map>\n# define GOOGLE_PROTOBUF_HASH_MAP_CLASS unordered_map\n# include <unordered_set>\n# define GOOGLE_PROTOBUF_HASH_SET_CLASS unordered_set\n#elif defined(GOOGLE_PROTOBUF_HAS_TR1)\n# define GOOGLE_PROTOBUF_HASH_NAMESPACE std::tr1\n# include <tr1/unordered_map>\n# define GOOGLE_PROTOBUF_HASH_MAP_CLASS unordered_map\n# include <tr1/unordered_set>\n# define GOOGLE_PROTOBUF_HASH_SET_CLASS unordered_set\n#endif\n\n# define GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_START \\\n  namespace google {                                      \\\n  namespace protobuf {\n# define GOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_END }}\n\n#undef GOOGLE_PROTOBUF_HAS_CXX11_HASH\n#undef GOOGLE_PROTOBUF_HAS_TR1\n\n#if defined(GOOGLE_PROTOBUF_HAVE_HASH_MAP) && \\\n    defined(GOOGLE_PROTOBUF_HAVE_HASH_SET)\n#else\n#define GOOGLE_PROTOBUF_MISSING_HASH\n#include <map>\n#include <set>\n#endif\n\nnamespace google {\nnamespace protobuf {\n\n#ifdef GOOGLE_PROTOBUF_MISSING_HASH\n#undef GOOGLE_PROTOBUF_MISSING_HASH\n\n// This system doesn't have hash_map or hash_set.  Emulate them using map and\n// set.\n\n// Make hash<T> be the same as less<T>.  Note that everywhere where custom\n// hash functions are defined in the protobuf code, they are also defined such\n// that they can be used as \"less\" functions, which is required by MSVC anyway.\ntemplate <typename Key>\nstruct hash {\n  // Dummy, just to make derivative hash functions compile.\n  int operator()(const Key& key) {\n    GOOGLE_LOG(FATAL) << \"Should never be called.\";\n    return 0;\n  }\n\n  inline bool operator()(const Key& a, const Key& b) const {\n    return a < b;\n  }\n};\n\n// Make sure char* is compared by value.\ntemplate <>\nstruct hash<const char*> {\n  // Dummy, just to make derivative hash functions compile.\n  int operator()(const char* key) {\n    GOOGLE_LOG(FATAL) << \"Should never be called.\";\n    return 0;\n  }\n\n  inline bool operator()(const char* a, const char* b) const {\n    return strcmp(a, b) < 0;\n  }\n};\n\ntemplate <typename Key, typename Data,\n          typename HashFcn = hash<Key>,\n          typename EqualKey = std::equal_to<Key>,\n          typename Alloc = std::allocator< std::pair<const Key, Data> > >\nclass hash_map : public std::map<Key, Data, HashFcn, Alloc> {\n  typedef std::map<Key, Data, HashFcn, Alloc> BaseClass;\n\n public:\n  hash_map(int a = 0, const HashFcn& b = HashFcn(),\n           const EqualKey& c = EqualKey(),\n           const Alloc& d = Alloc()) : BaseClass(b, d) {}\n\n  HashFcn hash_function() const { return HashFcn(); }\n};\n\ntemplate <typename Key,\n          typename HashFcn = hash<Key>,\n          typename EqualKey = std::equal_to<Key> >\nclass hash_set : public std::set<Key, HashFcn> {\n public:\n  hash_set(int = 0) {}\n\n  HashFcn hash_function() const { return HashFcn(); }\n};\n\n#elif defined(_MSC_VER) && !defined(_STLPORT_VERSION)\n\ntemplate <typename Key>\nstruct hash : public GOOGLE_PROTOBUF_HASH_COMPARE<Key> {\n};\n\n// MSVC's hash_compare<const char*> hashes based on the string contents but\n// compares based on the string pointer.  WTF?\nclass CstringLess {\n public:\n  inline bool operator()(const char* a, const char* b) const {\n    return strcmp(a, b) < 0;\n  }\n};\n\ntemplate <>\nstruct hash<const char*>\n    : public GOOGLE_PROTOBUF_HASH_COMPARE<const char*, CstringLess> {};\n\n#ifdef GOOGLE_PROTOBUF_CONTAINERS_NEED_HASH_COMPARE\n\ntemplate <typename Key, typename HashFcn, typename EqualKey>\nstruct InternalHashCompare : public GOOGLE_PROTOBUF_HASH_COMPARE<Key> {\n  InternalHashCompare() {}\n  InternalHashCompare(HashFcn hashfcn, EqualKey equalkey)\n      : hashfcn_(hashfcn), equalkey_(equalkey) {}\n  size_t operator()(const Key& key) const { return hashfcn_(key); }\n  bool operator()(const Key& key1, const Key& key2) const {\n    return !equalkey_(key1, key2);\n  }\n  HashFcn hashfcn_;\n  EqualKey equalkey_;\n};\n\ntemplate <typename Key, typename Data,\n          typename HashFcn = hash<Key>,\n          typename EqualKey = std::equal_to<Key>,\n          typename Alloc = std::allocator< std::pair<const Key, Data> > >\nclass hash_map\n    : public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS<\n          Key, Data, InternalHashCompare<Key, HashFcn, EqualKey>, Alloc> {\n  typedef GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS<\n      Key, Data, InternalHashCompare<Key, HashFcn, EqualKey>, Alloc> BaseClass;\n\n public:\n  hash_map(int a = 0, const HashFcn& b = HashFcn(),\n           const EqualKey& c = EqualKey(), const Alloc& d = Alloc())\n      : BaseClass(InternalHashCompare<Key, HashFcn, EqualKey>(b, c), d) {}\n\n  HashFcn hash_function() const { return HashFcn(); }\n};\n\ntemplate <typename Key, typename HashFcn = hash<Key>,\n          typename EqualKey = std::equal_to<Key> >\nclass hash_set\n    : public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_SET_CLASS<\n          Key, InternalHashCompare<Key, HashFcn, EqualKey> > {\n public:\n  hash_set(int = 0) {}\n\n  HashFcn hash_function() const { return HashFcn(); }\n};\n\n#else  // GOOGLE_PROTOBUF_CONTAINERS_NEED_HASH_COMPARE\n\ntemplate <typename Key, typename Data,\n          typename HashFcn = hash<Key>,\n          typename EqualKey = std::equal_to<Key>,\n          typename Alloc = std::allocator< std::pair<const Key, Data> > >\nclass hash_map\n    : public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS<\n          Key, Data, HashFcn, EqualKey, Alloc> {\n  typedef GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS<\n      Key, Data, HashFcn, EqualKey, Alloc> BaseClass;\n\n public:\n  hash_map(int a = 0, const HashFcn& b = HashFcn(),\n           const EqualKey& c = EqualKey(),\n           const Alloc& d = Alloc()) : BaseClass(a, b, c, d) {}\n\n  HashFcn hash_function() const { return HashFcn(); }\n};\n\ntemplate <typename Key, typename HashFcn = hash<Key>,\n          typename EqualKey = std::equal_to<Key> >\nclass hash_set\n    : public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_SET_CLASS<\n          Key, HashFcn, EqualKey> {\n public:\n  hash_set(int = 0) {}\n\n  HashFcn hash_function() const { return HashFcn(); }\n};\n#endif  // GOOGLE_PROTOBUF_CONTAINERS_NEED_HASH_COMPARE\n\n#else  // defined(_MSC_VER) && !defined(_STLPORT_VERSION)\n\ntemplate <typename Key>\nstruct hash : public GOOGLE_PROTOBUF_HASH_NAMESPACE::hash<Key> {\n};\n\ntemplate <typename Key>\nstruct hash<const Key*> {\n  inline size_t operator()(const Key* key) const {\n    return reinterpret_cast<size_t>(key);\n  }\n};\n\n// Unlike the old SGI version, the TR1 \"hash\" does not special-case char*.  So,\n// we go ahead and provide our own implementation.\ntemplate <>\nstruct hash<const char*> {\n  inline size_t operator()(const char* str) const {\n    size_t result = 0;\n    for (; *str != '\\0'; str++) {\n      result = 5 * result + *str;\n    }\n    return result;\n  }\n};\n\ntemplate<>\nstruct hash<bool> {\n  size_t operator()(bool x) const {\n    return static_cast<size_t>(x);\n  }\n};\n\ntemplate <typename Key, typename Data,\n          typename HashFcn = hash<Key>,\n          typename EqualKey = std::equal_to<Key>,\n          typename Alloc = std::allocator< std::pair<const Key, Data> > >\nclass hash_map\n    : public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS<\n          Key, Data, HashFcn, EqualKey, Alloc> {\n  typedef GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_MAP_CLASS<\n      Key, Data, HashFcn, EqualKey, Alloc> BaseClass;\n\n public:\n  hash_map(int a = 0, const HashFcn& b = HashFcn(),\n           const EqualKey& c = EqualKey(),\n           const Alloc& d = Alloc()) : BaseClass(a, b, c, d) {}\n\n  HashFcn hash_function() const { return HashFcn(); }\n};\n\ntemplate <typename Key, typename HashFcn = hash<Key>,\n          typename EqualKey = std::equal_to<Key> >\nclass hash_set\n    : public GOOGLE_PROTOBUF_HASH_NAMESPACE::GOOGLE_PROTOBUF_HASH_SET_CLASS<\n          Key, HashFcn, EqualKey> {\n public:\n  hash_set(int = 0) {}\n\n  HashFcn hash_function() const { return HashFcn(); }\n};\n\n#endif  // !GOOGLE_PROTOBUF_MISSING_HASH\n\ntemplate <>\nstruct hash<string> {\n  inline size_t operator()(const string& key) const {\n    return hash<const char*>()(key.c_str());\n  }\n\n  static const size_t bucket_size = 4;\n  static const size_t min_buckets = 8;\n  inline bool operator()(const string& a, const string& b) const {\n    return a < b;\n  }\n};\n\ntemplate <typename First, typename Second>\nstruct hash<pair<First, Second> > {\n  inline size_t operator()(const pair<First, Second>& key) const {\n    size_t first_hash = hash<First>()(key.first);\n    size_t second_hash = hash<Second>()(key.second);\n\n    // FIXME(kenton):  What is the best way to compute this hash?  I have\n    // no idea!  This seems a bit better than an XOR.\n    return first_hash * ((1 << 16) - 1) + second_hash;\n  }\n\n  static const size_t bucket_size = 4;\n  static const size_t min_buckets = 8;\n  inline bool operator()(const pair<First, Second>& a,\n                           const pair<First, Second>& b) const {\n    return a < b;\n  }\n};\n\n// Used by GCC/SGI STL only.  (Why isn't this provided by the standard\n// library?  :( )\nstruct streq {\n  inline bool operator()(const char* a, const char* b) const {\n    return strcmp(a, b) == 0;\n  }\n};\n\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_STUBS_HASH_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/int128.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/stubs/int128.h>\n\n#include <iomanip>\n#include <ostream>  // NOLINT(readability/streams)\n#include <sstream>\n\nnamespace google {\nnamespace protobuf {\n\nconst uint128_pod kuint128max = {\n    static_cast<uint64>(GOOGLE_LONGLONG(0xFFFFFFFFFFFFFFFF)),\n    static_cast<uint64>(GOOGLE_LONGLONG(0xFFFFFFFFFFFFFFFF))\n};\n\n// Returns the 0-based position of the last set bit (i.e., most significant bit)\n// in the given uint64. The argument may not be 0.\n//\n// For example:\n//   Given: 5 (decimal) == 101 (binary)\n//   Returns: 2\n#define STEP(T, n, pos, sh)                   \\\n  do {                                        \\\n    if ((n) >= (static_cast<T>(1) << (sh))) { \\\n      (n) = (n) >> (sh);                      \\\n      (pos) |= (sh);                          \\\n    }                                         \\\n  } while (0)\nstatic inline int Fls64(uint64 n) {\n  GOOGLE_DCHECK_NE(0, n);\n  int pos = 0;\n  STEP(uint64, n, pos, 0x20);\n  uint32 n32 = n;\n  STEP(uint32, n32, pos, 0x10);\n  STEP(uint32, n32, pos, 0x08);\n  STEP(uint32, n32, pos, 0x04);\n  return pos + ((GOOGLE_ULONGLONG(0x3333333322221100) >> (n32 << 2)) & 0x3);\n}\n#undef STEP\n\n// Like Fls64() above, but returns the 0-based position of the last set bit\n// (i.e., most significant bit) in the given uint128. The argument may not be 0.\nstatic inline int Fls128(uint128 n) {\n  if (uint64 hi = Uint128High64(n)) {\n    return Fls64(hi) + 64;\n  }\n  return Fls64(Uint128Low64(n));\n}\n\n// Long division/modulo for uint128 implemented using the shift-subtract\n// division algorithm adapted from:\n// http://stackoverflow.com/questions/5386377/division-without-using\nvoid uint128::DivModImpl(uint128 dividend, uint128 divisor,\n                         uint128* quotient_ret, uint128* remainder_ret) {\n  if (divisor == 0) {\n    GOOGLE_LOG(FATAL) << \"Division or mod by zero: dividend.hi=\" << dividend.hi_\n                      << \", lo=\" << dividend.lo_;\n  }\n\n  if (divisor > dividend) {\n    *quotient_ret = 0;\n    *remainder_ret = dividend;\n    return;\n  }\n\n  if (divisor == dividend) {\n    *quotient_ret = 1;\n    *remainder_ret = 0;\n    return;\n  }\n\n  uint128 denominator = divisor;\n  uint128 position = 1;\n  uint128 quotient = 0;\n\n  // Left aligns the MSB of the denominator and the dividend.\n  int shift = Fls128(dividend) - Fls128(denominator);\n  denominator <<= shift;\n  position <<= shift;\n\n  // Uses shift-subtract algorithm to divide dividend by denominator. The\n  // remainder will be left in dividend.\n  while (position > 0) {\n    if (dividend >= denominator) {\n      dividend -= denominator;\n      quotient |= position;\n    }\n    position >>= 1;\n    denominator >>= 1;\n  }\n\n  *quotient_ret = quotient;\n  *remainder_ret = dividend;\n}\n\nuint128& uint128::operator/=(const uint128& divisor) {\n  uint128 quotient = 0;\n  uint128 remainder = 0;\n  DivModImpl(*this, divisor, &quotient, &remainder);\n  *this = quotient;\n  return *this;\n}\nuint128& uint128::operator%=(const uint128& divisor) {\n  uint128 quotient = 0;\n  uint128 remainder = 0;\n  DivModImpl(*this, divisor, &quotient, &remainder);\n  *this = remainder;\n  return *this;\n}\n\nstd::ostream& operator<<(std::ostream& o, const uint128& b) {\n  std::ios_base::fmtflags flags = o.flags();\n\n  // Select a divisor which is the largest power of the base < 2^64.\n  uint128 div;\n  std::streamsize div_base_log;\n  switch (flags & std::ios::basefield) {\n    case std::ios::hex:\n      div = static_cast<uint64>(GOOGLE_ULONGLONG(0x1000000000000000));  // 16^15\n      div_base_log = 15;\n      break;\n    case std::ios::oct:\n      div = static_cast<uint64>(GOOGLE_ULONGLONG(01000000000000000000000));  // 8^21\n      div_base_log = 21;\n      break;\n    default:  // std::ios::dec\n      div = static_cast<uint64>(GOOGLE_ULONGLONG(10000000000000000000));  // 10^19\n      div_base_log = 19;\n      break;\n  }\n\n  // Now piece together the uint128 representation from three chunks of\n  // the original value, each less than \"div\" and therefore representable\n  // as a uint64.\n  std::ostringstream os;\n  std::ios_base::fmtflags copy_mask =\n      std::ios::basefield | std::ios::showbase | std::ios::uppercase;\n  os.setf(flags & copy_mask, copy_mask);\n  uint128 high = b;\n  uint128 low;\n  uint128::DivModImpl(high, div, &high, &low);\n  uint128 mid;\n  uint128::DivModImpl(high, div, &high, &mid);\n  if (high.lo_ != 0) {\n    os << high.lo_;\n    os << std::noshowbase << std::setfill('0') << std::setw(div_base_log);\n    os << mid.lo_;\n    os << std::setw(div_base_log);\n  } else if (mid.lo_ != 0) {\n    os << mid.lo_;\n    os << std::noshowbase << std::setfill('0') << std::setw(div_base_log);\n  }\n  os << low.lo_;\n  std::string rep = os.str();\n\n  // Add the requisite padding.\n  std::streamsize width = o.width(0);\n  if (width > rep.size()) {\n    if ((flags & std::ios::adjustfield) == std::ios::left) {\n      rep.append(width - rep.size(), o.fill());\n    } else {\n      rep.insert(static_cast<std::string::size_type>(0),\n                 width - rep.size(), o.fill());\n    }\n  }\n\n  // Stream the final representation in a single \"<<\" call.\n  return o << rep;\n}\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/int128.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n#ifndef GOOGLE_PROTOBUF_STUBS_INT128_H_\n#define GOOGLE_PROTOBUF_STUBS_INT128_H_\n\n#include <google/protobuf/stubs/common.h>\n\n#include <iosfwd>\n\nnamespace google {\nnamespace protobuf {\n\nstruct uint128_pod;\n\n// TODO(xiaofeng): Define GOOGLE_PROTOBUF_HAS_CONSTEXPR when constexpr is\n// available.\n#ifdef GOOGLE_PROTOBUF_HAS_CONSTEXPR\n# define UINT128_CONSTEXPR constexpr\n#else\n# define UINT128_CONSTEXPR\n#endif\n\n// An unsigned 128-bit integer type. Thread-compatible.\nclass LIBPROTOBUF_EXPORT uint128 {\n public:\n  UINT128_CONSTEXPR uint128();  // Sets to 0, but don't trust on this behavior.\n  UINT128_CONSTEXPR uint128(uint64 top, uint64 bottom);\n#ifndef SWIG\n  UINT128_CONSTEXPR uint128(int bottom);\n  UINT128_CONSTEXPR uint128(uint32 bottom);   // Top 96 bits = 0\n#endif\n  UINT128_CONSTEXPR uint128(uint64 bottom);   // hi_ = 0\n  UINT128_CONSTEXPR uint128(const uint128_pod &val);\n\n  // Trivial copy constructor, assignment operator and destructor.\n\n  void Initialize(uint64 top, uint64 bottom);\n\n  // Arithmetic operators.\n  uint128& operator+=(const uint128& b);\n  uint128& operator-=(const uint128& b);\n  uint128& operator*=(const uint128& b);\n  // Long division/modulo for uint128.\n  uint128& operator/=(const uint128& b);\n  uint128& operator%=(const uint128& b);\n  uint128 operator++(int);\n  uint128 operator--(int);\n  uint128& operator<<=(int);\n  uint128& operator>>=(int);\n  uint128& operator&=(const uint128& b);\n  uint128& operator|=(const uint128& b);\n  uint128& operator^=(const uint128& b);\n  uint128& operator++();\n  uint128& operator--();\n\n  friend uint64 Uint128Low64(const uint128& v);\n  friend uint64 Uint128High64(const uint128& v);\n\n  // We add \"std::\" to avoid including all of port.h.\n  LIBPROTOBUF_EXPORT friend std::ostream& operator<<(std::ostream& o,\n                                                     const uint128& b);\n\n private:\n  static void DivModImpl(uint128 dividend, uint128 divisor,\n                         uint128* quotient_ret, uint128* remainder_ret);\n\n  // Little-endian memory order optimizations can benefit from\n  // having lo_ first, hi_ last.\n  // See util/endian/endian.h and Load128/Store128 for storing a uint128.\n  uint64        lo_;\n  uint64        hi_;\n\n  // Not implemented, just declared for catching automatic type conversions.\n  uint128(uint8);\n  uint128(uint16);\n  uint128(float v);\n  uint128(double v);\n};\n\n// This is a POD form of uint128 which can be used for static variables which\n// need to be operated on as uint128.\nstruct uint128_pod {\n  // Note: The ordering of fields is different than 'class uint128' but the\n  // same as its 2-arg constructor.  This enables more obvious initialization\n  // of static instances, which is the primary reason for this struct in the\n  // first place.  This does not seem to defeat any optimizations wrt\n  // operations involving this struct.\n  uint64 hi;\n  uint64 lo;\n};\n\nLIBPROTOBUF_EXPORT extern const uint128_pod kuint128max;\n\n// allow uint128 to be logged\nLIBPROTOBUF_EXPORT extern std::ostream& operator<<(std::ostream& o,\n                                                   const uint128& b);\n\n// Methods to access low and high pieces of 128-bit value.\n// Defined externally from uint128 to facilitate conversion\n// to native 128-bit types when compilers support them.\ninline uint64 Uint128Low64(const uint128& v) { return v.lo_; }\ninline uint64 Uint128High64(const uint128& v) { return v.hi_; }\n\n// TODO: perhaps it would be nice to have int128, a signed 128-bit type?\n\n// --------------------------------------------------------------------------\n//                      Implementation details follow\n// --------------------------------------------------------------------------\ninline bool operator==(const uint128& lhs, const uint128& rhs) {\n  return (Uint128Low64(lhs) == Uint128Low64(rhs) &&\n          Uint128High64(lhs) == Uint128High64(rhs));\n}\ninline bool operator!=(const uint128& lhs, const uint128& rhs) {\n  return !(lhs == rhs);\n}\n\ninline UINT128_CONSTEXPR uint128::uint128() : lo_(0), hi_(0) {}\ninline UINT128_CONSTEXPR uint128::uint128(uint64 top, uint64 bottom)\n    : lo_(bottom), hi_(top) {}\ninline UINT128_CONSTEXPR uint128::uint128(const uint128_pod& v)\n    : lo_(v.lo), hi_(v.hi) {}\ninline UINT128_CONSTEXPR uint128::uint128(uint64 bottom)\n    : lo_(bottom), hi_(0) {}\n#ifndef SWIG\ninline UINT128_CONSTEXPR uint128::uint128(uint32 bottom)\n    : lo_(bottom), hi_(0) {}\ninline UINT128_CONSTEXPR uint128::uint128(int bottom)\n    : lo_(bottom), hi_(static_cast<int64>((bottom < 0) ? -1 : 0)) {}\n#endif\n\n#undef UINT128_CONSTEXPR\n\ninline void uint128::Initialize(uint64 top, uint64 bottom) {\n  hi_ = top;\n  lo_ = bottom;\n}\n\n// Comparison operators.\n\n#define CMP128(op)                                                \\\ninline bool operator op(const uint128& lhs, const uint128& rhs) { \\\n  return (Uint128High64(lhs) == Uint128High64(rhs)) ?             \\\n      (Uint128Low64(lhs) op Uint128Low64(rhs)) :                  \\\n      (Uint128High64(lhs) op Uint128High64(rhs));                 \\\n}\n\nCMP128(<)\nCMP128(>)\nCMP128(>=)\nCMP128(<=)\n\n#undef CMP128\n\n// Unary operators\n\ninline uint128 operator-(const uint128& val) {\n  const uint64 hi_flip = ~Uint128High64(val);\n  const uint64 lo_flip = ~Uint128Low64(val);\n  const uint64 lo_add = lo_flip + 1;\n  if (lo_add < lo_flip) {\n    return uint128(hi_flip + 1, lo_add);\n  }\n  return uint128(hi_flip, lo_add);\n}\n\ninline bool operator!(const uint128& val) {\n  return !Uint128High64(val) && !Uint128Low64(val);\n}\n\n// Logical operators.\n\ninline uint128 operator~(const uint128& val) {\n  return uint128(~Uint128High64(val), ~Uint128Low64(val));\n}\n\n#define LOGIC128(op)                                                 \\\ninline uint128 operator op(const uint128& lhs, const uint128& rhs) { \\\n  return uint128(Uint128High64(lhs) op Uint128High64(rhs),           \\\n                 Uint128Low64(lhs) op Uint128Low64(rhs));            \\\n}\n\nLOGIC128(|)\nLOGIC128(&)\nLOGIC128(^)\n\n#undef LOGIC128\n\n#define LOGICASSIGN128(op)                                   \\\ninline uint128& uint128::operator op(const uint128& other) { \\\n  hi_ op other.hi_;                                          \\\n  lo_ op other.lo_;                                          \\\n  return *this;                                              \\\n}\n\nLOGICASSIGN128(|=)\nLOGICASSIGN128(&=)\nLOGICASSIGN128(^=)\n\n#undef LOGICASSIGN128\n\n// Shift operators.\n\ninline uint128 operator<<(const uint128& val, int amount) {\n  // uint64 shifts of >= 64 are undefined, so we will need some special-casing.\n  if (amount < 64) {\n    if (amount == 0) {\n      return val;\n    }\n    uint64 new_hi = (Uint128High64(val) << amount) |\n                    (Uint128Low64(val) >> (64 - amount));\n    uint64 new_lo = Uint128Low64(val) << amount;\n    return uint128(new_hi, new_lo);\n  } else if (amount < 128) {\n    return uint128(Uint128Low64(val) << (amount - 64), 0);\n  } else {\n    return uint128(0, 0);\n  }\n}\n\ninline uint128 operator>>(const uint128& val, int amount) {\n  // uint64 shifts of >= 64 are undefined, so we will need some special-casing.\n  if (amount < 64) {\n    if (amount == 0) {\n      return val;\n    }\n    uint64 new_hi = Uint128High64(val) >> amount;\n    uint64 new_lo = (Uint128Low64(val) >> amount) |\n                    (Uint128High64(val) << (64 - amount));\n    return uint128(new_hi, new_lo);\n  } else if (amount < 128) {\n    return uint128(0, Uint128High64(val) >> (amount - 64));\n  } else {\n    return uint128(0, 0);\n  }\n}\n\ninline uint128& uint128::operator<<=(int amount) {\n  // uint64 shifts of >= 64 are undefined, so we will need some special-casing.\n  if (amount < 64) {\n    if (amount != 0) {\n      hi_ = (hi_ << amount) | (lo_ >> (64 - amount));\n      lo_ = lo_ << amount;\n    }\n  } else if (amount < 128) {\n    hi_ = lo_ << (amount - 64);\n    lo_ = 0;\n  } else {\n    hi_ = 0;\n    lo_ = 0;\n  }\n  return *this;\n}\n\ninline uint128& uint128::operator>>=(int amount) {\n  // uint64 shifts of >= 64 are undefined, so we will need some special-casing.\n  if (amount < 64) {\n    if (amount != 0) {\n      lo_ = (lo_ >> amount) | (hi_ << (64 - amount));\n      hi_ = hi_ >> amount;\n    }\n  } else if (amount < 128) {\n    lo_ = hi_ >> (amount - 64);\n    hi_ = 0;\n  } else {\n    lo_ = 0;\n    hi_ = 0;\n  }\n  return *this;\n}\n\ninline uint128 operator+(const uint128& lhs, const uint128& rhs) {\n  return uint128(lhs) += rhs;\n}\n\ninline uint128 operator-(const uint128& lhs, const uint128& rhs) {\n  return uint128(lhs) -= rhs;\n}\n\ninline uint128 operator*(const uint128& lhs, const uint128& rhs) {\n  return uint128(lhs) *= rhs;\n}\n\ninline uint128 operator/(const uint128& lhs, const uint128& rhs) {\n  return uint128(lhs) /= rhs;\n}\n\ninline uint128 operator%(const uint128& lhs, const uint128& rhs) {\n  return uint128(lhs) %= rhs;\n}\n\ninline uint128& uint128::operator+=(const uint128& b) {\n  hi_ += b.hi_;\n  uint64 lolo = lo_ + b.lo_;\n  if (lolo < lo_)\n    ++hi_;\n  lo_ = lolo;\n  return *this;\n}\n\ninline uint128& uint128::operator-=(const uint128& b) {\n  hi_ -= b.hi_;\n  if (b.lo_ > lo_)\n    --hi_;\n  lo_ -= b.lo_;\n  return *this;\n}\n\ninline uint128& uint128::operator*=(const uint128& b) {\n  uint64 a96 = hi_ >> 32;\n  uint64 a64 = hi_ & 0xffffffffu;\n  uint64 a32 = lo_ >> 32;\n  uint64 a00 = lo_ & 0xffffffffu;\n  uint64 b96 = b.hi_ >> 32;\n  uint64 b64 = b.hi_ & 0xffffffffu;\n  uint64 b32 = b.lo_ >> 32;\n  uint64 b00 = b.lo_ & 0xffffffffu;\n  // multiply [a96 .. a00] x [b96 .. b00]\n  // terms higher than c96 disappear off the high side\n  // terms c96 and c64 are safe to ignore carry bit\n  uint64 c96 = a96 * b00 + a64 * b32 + a32 * b64 + a00 * b96;\n  uint64 c64 = a64 * b00 + a32 * b32 + a00 * b64;\n  this->hi_ = (c96 << 32) + c64;\n  this->lo_ = 0;\n  // add terms after this one at a time to capture carry\n  *this += uint128(a32 * b00) << 32;\n  *this += uint128(a00 * b32) << 32;\n  *this += a00 * b00;\n  return *this;\n}\n\ninline uint128 uint128::operator++(int) {\n  uint128 tmp(*this);\n  *this += 1;\n  return tmp;\n}\n\ninline uint128 uint128::operator--(int) {\n  uint128 tmp(*this);\n  *this -= 1;\n  return tmp;\n}\n\ninline uint128& uint128::operator++() {\n  *this += 1;\n  return *this;\n}\n\ninline uint128& uint128::operator--() {\n  *this -= 1;\n  return *this;\n}\n\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_STUBS_INT128_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/int128_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/stubs/int128.h>\n\n#include <algorithm>\n#include <sstream>\n#include <utility>\n\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\n\nTEST(Int128, AllTests) {\n  uint128 zero(0);\n  uint128 one(1);\n  uint128 one_2arg(0, 1);\n  uint128 two(0, 2);\n  uint128 three(0, 3);\n  uint128 big(2000, 2);\n  uint128 big_minus_one(2000, 1);\n  uint128 bigger(2001, 1);\n  uint128 biggest(kuint128max);\n  uint128 high_low(1, 0);\n  uint128 low_high(0, kuint64max);\n  EXPECT_LT(one, two);\n  EXPECT_GT(two, one);\n  EXPECT_LT(one, big);\n  EXPECT_LT(one, big);\n  EXPECT_EQ(one, one_2arg);\n  EXPECT_NE(one, two);\n  EXPECT_GT(big, one);\n  EXPECT_GE(big, two);\n  EXPECT_GE(big, big_minus_one);\n  EXPECT_GT(big, big_minus_one);\n  EXPECT_LT(big_minus_one, big);\n  EXPECT_LE(big_minus_one, big);\n  EXPECT_NE(big_minus_one, big);\n  EXPECT_LT(big, biggest);\n  EXPECT_LE(big, biggest);\n  EXPECT_GT(biggest, big);\n  EXPECT_GE(biggest, big);\n  EXPECT_EQ(big, ~~big);\n  EXPECT_EQ(one, one | one);\n  EXPECT_EQ(big, big | big);\n  EXPECT_EQ(one, one | zero);\n  EXPECT_EQ(one, one & one);\n  EXPECT_EQ(big, big & big);\n  EXPECT_EQ(zero, one & zero);\n  EXPECT_EQ(zero, big & ~big);\n  EXPECT_EQ(zero, one ^ one);\n  EXPECT_EQ(zero, big ^ big);\n  EXPECT_EQ(one, one ^ zero);\n\n  // Shift operators.\n  EXPECT_EQ(big, big << 0);\n  EXPECT_EQ(big, big >> 0);\n  EXPECT_GT(big << 1, big);\n  EXPECT_LT(big >> 1, big);\n  EXPECT_EQ(big, (big << 10) >> 10);\n  EXPECT_EQ(big, (big >> 1) << 1);\n  EXPECT_EQ(one, (one << 80) >> 80);\n  EXPECT_EQ(zero, (one >> 80) << 80);\n  EXPECT_EQ(zero, big >> 128);\n  EXPECT_EQ(zero, big << 128);\n\n  // Shift assignments.\n  uint128 big_copy = big;\n  EXPECT_EQ(big << 0, big_copy <<= 0);\n  big_copy = big;\n  EXPECT_EQ(big >> 0, big_copy >>= 0);\n  big_copy = big;\n  EXPECT_EQ(big << 1, big_copy <<= 1);\n  big_copy = big;\n  EXPECT_EQ(big >> 1, big_copy >>= 1);\n  big_copy = big;\n  EXPECT_EQ(big << 10, big_copy <<= 10);\n  big_copy = big;\n  EXPECT_EQ(big >> 10, big_copy >>= 10);\n  big_copy = big;\n  EXPECT_EQ(big << 64, big_copy <<= 64);\n  big_copy = big;\n  EXPECT_EQ(big >> 64, big_copy >>= 64);\n  big_copy = big;\n  EXPECT_EQ(big << 73, big_copy <<= 73);\n  big_copy = big;\n  EXPECT_EQ(big >> 73, big_copy >>= 73);\n  big_copy = big;\n  EXPECT_EQ(big << 128, big_copy <<= 128);\n  big_copy = big;\n  EXPECT_EQ(big >> 128, big_copy >>= 128);\n\n  EXPECT_EQ(Uint128High64(biggest), kuint64max);\n  EXPECT_EQ(Uint128Low64(biggest), kuint64max);\n  EXPECT_EQ(zero + one, one);\n  EXPECT_EQ(one + one, two);\n  EXPECT_EQ(big_minus_one + one, big);\n  EXPECT_EQ(one - one, zero);\n  EXPECT_EQ(one - zero, one);\n  EXPECT_EQ(zero - one, biggest);\n  EXPECT_EQ(big - big, zero);\n  EXPECT_EQ(big - one, big_minus_one);\n  EXPECT_EQ(big + kuint64max, bigger);\n  EXPECT_EQ(biggest + 1, zero);\n  EXPECT_EQ(zero - 1, biggest);\n  EXPECT_EQ(high_low - one, low_high);\n  EXPECT_EQ(low_high + one, high_low);\n  EXPECT_EQ(Uint128High64((uint128(1) << 64) - 1), 0);\n  EXPECT_EQ(Uint128Low64((uint128(1) << 64) - 1), kuint64max);\n  EXPECT_TRUE(!!one);\n  EXPECT_TRUE(!!high_low);\n  EXPECT_FALSE(!!zero);\n  EXPECT_FALSE(!one);\n  EXPECT_FALSE(!high_low);\n  EXPECT_TRUE(!zero);\n  EXPECT_TRUE(zero == 0);\n  EXPECT_FALSE(zero != 0);\n  EXPECT_FALSE(one == 0);\n  EXPECT_TRUE(one != 0);\n\n  uint128 test = zero;\n  EXPECT_EQ(++test, one);\n  EXPECT_EQ(test, one);\n  EXPECT_EQ(test++, one);\n  EXPECT_EQ(test, two);\n  EXPECT_EQ(test -= 2, zero);\n  EXPECT_EQ(test, zero);\n  EXPECT_EQ(test += 2, two);\n  EXPECT_EQ(test, two);\n  EXPECT_EQ(--test, one);\n  EXPECT_EQ(test, one);\n  EXPECT_EQ(test--, one);\n  EXPECT_EQ(test, zero);\n  EXPECT_EQ(test |= three, three);\n  EXPECT_EQ(test &= one, one);\n  EXPECT_EQ(test ^= three, two);\n  EXPECT_EQ(test >>= 1, one);\n  EXPECT_EQ(test <<= 1, two);\n\n  EXPECT_EQ(big, -(-big));\n  EXPECT_EQ(two, -((-one) - 1));\n  EXPECT_EQ(kuint128max, -one);\n  EXPECT_EQ(zero, -zero);\n\n  GOOGLE_LOG(INFO) << one;\n  GOOGLE_LOG(INFO) << big_minus_one;\n}\n\nTEST(Int128, PodTests) {\n  uint128_pod pod = { 12345, 67890 };\n  uint128 from_pod(pod);\n  EXPECT_EQ(12345, Uint128High64(from_pod));\n  EXPECT_EQ(67890, Uint128Low64(from_pod));\n\n  uint128 zero(0);\n  uint128_pod zero_pod = {0, 0};\n  uint128 one(1);\n  uint128_pod one_pod = {0, 1};\n  uint128 two(2);\n  uint128_pod two_pod = {0, 2};\n  uint128 three(3);\n  uint128_pod three_pod = {0, 3};\n  uint128 big(1, 0);\n  uint128_pod big_pod = {1, 0};\n\n  EXPECT_EQ(zero, zero_pod);\n  EXPECT_EQ(zero_pod, zero);\n  EXPECT_EQ(zero_pod, zero_pod);\n  EXPECT_EQ(one, one_pod);\n  EXPECT_EQ(one_pod, one);\n  EXPECT_EQ(one_pod, one_pod);\n  EXPECT_EQ(two, two_pod);\n  EXPECT_EQ(two_pod, two);\n  EXPECT_EQ(two_pod, two_pod);\n\n  EXPECT_NE(one, two_pod);\n  EXPECT_NE(one_pod, two);\n  EXPECT_NE(one_pod, two_pod);\n\n  EXPECT_LT(one, two_pod);\n  EXPECT_LT(one_pod, two);\n  EXPECT_LT(one_pod, two_pod);\n  EXPECT_LE(one, one_pod);\n  EXPECT_LE(one_pod, one);\n  EXPECT_LE(one_pod, one_pod);\n  EXPECT_LE(one, two_pod);\n  EXPECT_LE(one_pod, two);\n  EXPECT_LE(one_pod, two_pod);\n\n  EXPECT_GT(two, one_pod);\n  EXPECT_GT(two_pod, one);\n  EXPECT_GT(two_pod, one_pod);\n  EXPECT_GE(two, two_pod);\n  EXPECT_GE(two_pod, two);\n  EXPECT_GE(two_pod, two_pod);\n  EXPECT_GE(two, one_pod);\n  EXPECT_GE(two_pod, one);\n  EXPECT_GE(two_pod, one_pod);\n\n  EXPECT_EQ(three, one | two_pod);\n  EXPECT_EQ(three, one_pod | two);\n  EXPECT_EQ(three, one_pod | two_pod);\n  EXPECT_EQ(one, three & one_pod);\n  EXPECT_EQ(one, three_pod & one);\n  EXPECT_EQ(one, three_pod & one_pod);\n  EXPECT_EQ(two, three ^ one_pod);\n  EXPECT_EQ(two, three_pod ^ one);\n  EXPECT_EQ(two, three_pod ^ one_pod);\n  EXPECT_EQ(two, three & (~one));\n  EXPECT_EQ(three, ~~three);\n\n  EXPECT_EQ(two, two_pod << 0);\n  EXPECT_EQ(two, one_pod << 1);\n  EXPECT_EQ(big, one_pod << 64);\n  EXPECT_EQ(zero, one_pod << 128);\n  EXPECT_EQ(two, two_pod >> 0);\n  EXPECT_EQ(one, two_pod >> 1);\n  EXPECT_EQ(one, big_pod >> 64);\n\n  EXPECT_EQ(one, zero + one_pod);\n  EXPECT_EQ(one, zero_pod + one);\n  EXPECT_EQ(one, zero_pod + one_pod);\n  EXPECT_EQ(one, two - one_pod);\n  EXPECT_EQ(one, two_pod - one);\n  EXPECT_EQ(one, two_pod - one_pod);\n}\n\nTEST(Int128, OperatorAssignReturnRef) {\n  uint128 v(1);\n  (v += 4) -= 3;\n  EXPECT_EQ(2, v);\n}\n\nTEST(Int128, Multiply) {\n  uint128 a, b, c;\n\n  // Zero test.\n  a = 0;\n  b = 0;\n  c = a * b;\n  EXPECT_EQ(0, c);\n\n  // Max carries.\n  a = uint128(0) - 1;\n  b = uint128(0) - 1;\n  c = a * b;\n  EXPECT_EQ(1, c);\n\n  // Self-operation with max carries.\n  c = uint128(0) - 1;\n  c *= c;\n  EXPECT_EQ(1, c);\n\n  // 1-bit x 1-bit.\n  for (int i = 0; i < 64; ++i) {\n    for (int j = 0; j < 64; ++j) {\n      a = uint128(1) << i;\n      b = uint128(1) << j;\n      c = a * b;\n      EXPECT_EQ(uint128(1) << (i+j), c);\n    }\n  }\n\n  // Verified with dc.\n  a = uint128(GOOGLE_ULONGLONG(0xffffeeeeddddcccc),\n              GOOGLE_ULONGLONG(0xbbbbaaaa99998888));\n  b = uint128(GOOGLE_ULONGLONG(0x7777666655554444),\n              GOOGLE_ULONGLONG(0x3333222211110000));\n  c = a * b;\n  EXPECT_EQ(uint128(GOOGLE_ULONGLONG(0x530EDA741C71D4C3),\n                    GOOGLE_ULONGLONG(0xBF25975319080000)), c);\n  EXPECT_EQ(0, c - b * a);\n  EXPECT_EQ(a*a - b*b, (a+b) * (a-b));\n\n  // Verified with dc.\n  a = uint128(GOOGLE_ULONGLONG(0x0123456789abcdef),\n              GOOGLE_ULONGLONG(0xfedcba9876543210));\n  b = uint128(GOOGLE_ULONGLONG(0x02468ace13579bdf),\n              GOOGLE_ULONGLONG(0xfdb97531eca86420));\n  c = a * b;\n  EXPECT_EQ(uint128(GOOGLE_ULONGLONG(0x97a87f4f261ba3f2),\n                    GOOGLE_ULONGLONG(0x342d0bbf48948200)), c);\n  EXPECT_EQ(0, c - b * a);\n  EXPECT_EQ(a*a - b*b, (a+b) * (a-b));\n}\n\nTEST(Int128, AliasTests) {\n  uint128 x1(1, 2);\n  uint128 x2(2, 4);\n  x1 += x1;\n  EXPECT_EQ(x2, x1);\n\n  uint128 x3(1, static_cast<uint64>(1) << 63);\n  uint128 x4(3, 0);\n  x3 += x3;\n  EXPECT_EQ(x4, x3);\n}\n\n#ifdef PROTOBUF_HAS_DEATH_TEST\nTEST(Int128, DivideByZeroCheckFails) {\n  uint128 a = 0;\n  uint128 b = 0;\n  EXPECT_DEATH(a / b, \"Division or mod by zero:\");\n  a = 123;\n  EXPECT_DEATH(a / b, \"Division or mod by zero:\");\n}\n\nTEST(Int128, ModByZeroCheckFails) {\n  uint128 a = 0;\n  uint128 b = 0;\n  EXPECT_DEATH(a % b, \"Division or mod by zero:\");\n  a = 123;\n  EXPECT_DEATH(a % b, \"Division or mod by zero:\");\n}\n#endif  // PROTOBUF_HAS_DEATH_TEST\n\nTEST(Int128, DivideAndMod) {\n  // a := q * b + r\n  uint128 a, b, q, r;\n\n  // Zero test.\n  a = 0;\n  b = 123;\n  q = a / b;\n  r = a % b;\n  EXPECT_EQ(0, q);\n  EXPECT_EQ(0, r);\n\n  a = uint128(GOOGLE_ULONGLONG(0x530eda741c71d4c3),\n              GOOGLE_ULONGLONG(0xbf25975319080000));\n  q = uint128(GOOGLE_ULONGLONG(0x4de2cab081),\n              GOOGLE_ULONGLONG(0x14c34ab4676e4bab));\n  b = uint128(0x1110001);\n  r = uint128(0x3eb455);\n  ASSERT_EQ(a, q * b + r);  // Sanity-check.\n\n  uint128 result_q, result_r;\n  result_q = a / b;\n  result_r = a % b;\n  EXPECT_EQ(q, result_q);\n  EXPECT_EQ(r, result_r);\n\n  // Try the other way around.\n  swap(q, b);\n  result_q = a / b;\n  result_r = a % b;\n  EXPECT_EQ(q, result_q);\n  EXPECT_EQ(r, result_r);\n  // Restore.\n  swap(b, q);\n\n  // Dividend < divisor; result should be q:0 r:<dividend>.\n  swap(a, b);\n  result_q = a / b;\n  result_r = a % b;\n  EXPECT_EQ(0, result_q);\n  EXPECT_EQ(a, result_r);\n  // Try the other way around.\n  swap(a, q);\n  result_q = a / b;\n  result_r = a % b;\n  EXPECT_EQ(0, result_q);\n  EXPECT_EQ(a, result_r);\n  // Restore.\n  swap(q, a);\n  swap(b, a);\n\n  // Try a large remainder.\n  b = a / 2 + 1;\n  uint128 expected_r(GOOGLE_ULONGLONG(0x29876d3a0e38ea61),\n                     GOOGLE_ULONGLONG(0xdf92cba98c83ffff));\n  // Sanity checks.\n  ASSERT_EQ(a / 2 - 1, expected_r);\n  ASSERT_EQ(a, b + expected_r);\n  result_q = a / b;\n  result_r = a % b;\n  EXPECT_EQ(1, result_q);\n  EXPECT_EQ(expected_r, result_r);\n}\n\nstatic uint64 RandomUint64() {\n  uint64 v1 = rand();\n  uint64 v2 = rand();\n  uint64 v3 = rand();\n  return v1 * v2 + v3;\n}\n\nTEST(Int128, DivideAndModRandomInputs) {\n  const int kNumIters = 1 << 18;\n  for (int i = 0; i < kNumIters; ++i) {\n    const uint128 a(RandomUint64(), RandomUint64());\n    const uint128 b(RandomUint64(), RandomUint64());\n    if (b == 0) {\n      continue;  // Avoid a div-by-zero.\n    }\n    const uint128 q = a / b;\n    const uint128 r = a % b;\n    ASSERT_EQ(a, b * q + r);\n  }\n}\n\n#ifdef GOOGLE_PROTOBUF_HAS_CONSTEXPR\nTEST(Int128, ConstexprTest) {\n  constexpr uint128 zero;\n  constexpr uint128 one = 1;\n  constexpr uint128_pod pod = {2, 3};\n  constexpr uint128 from_pod = pod;\n  constexpr uint128 minus_two = -2;\n  EXPECT_EQ(one, uint128(1));\n  EXPECT_EQ(from_pod, uint128(2, 3));\n  EXPECT_EQ(minus_two, uint128(-1ULL, -2ULL));\n}\n\nTEST(Int128, Traits) {\n  EXPECT_TRUE(std::is_trivially_copy_constructible<uint128>::value);\n  EXPECT_TRUE(std::is_trivially_copy_assignable<uint128>::value);\n  EXPECT_TRUE(std::is_trivially_destructible<uint128>::value);\n}\n#endif  // GOOGLE_PROTOBUF_HAS_CONSTEXPR\n\nTEST(Int128, OStream) {\n  struct {\n    uint128 val;\n    std::ios_base::fmtflags flags;\n    std::streamsize width;\n    char fill;\n    const char* rep;\n  } cases[] = {\n        // zero with different bases\n        {uint128(0), std::ios::dec, 0, '_', \"0\"},\n        {uint128(0), std::ios::oct, 0, '_', \"0\"},\n        {uint128(0), std::ios::hex, 0, '_', \"0\"},\n        // crossover between lo_ and hi_\n        {uint128(0, -1), std::ios::dec, 0, '_', \"18446744073709551615\"},\n        {uint128(0, -1), std::ios::oct, 0, '_', \"1777777777777777777777\"},\n        {uint128(0, -1), std::ios::hex, 0, '_', \"ffffffffffffffff\"},\n        {uint128(1, 0), std::ios::dec, 0, '_', \"18446744073709551616\"},\n        {uint128(1, 0), std::ios::oct, 0, '_', \"2000000000000000000000\"},\n        {uint128(1, 0), std::ios::hex, 0, '_', \"10000000000000000\"},\n        // just the top bit\n        {uint128(GOOGLE_ULONGLONG(0x8000000000000000), 0), std::ios::dec, 0, '_',\n         \"170141183460469231731687303715884105728\"},\n        {uint128(GOOGLE_ULONGLONG(0x8000000000000000), 0), std::ios::oct, 0, '_',\n         \"2000000000000000000000000000000000000000000\"},\n        {uint128(GOOGLE_ULONGLONG(0x8000000000000000), 0), std::ios::hex, 0, '_',\n         \"80000000000000000000000000000000\"},\n        // maximum uint128 value\n        {uint128(-1, -1), std::ios::dec, 0, '_',\n         \"340282366920938463463374607431768211455\"},\n        {uint128(-1, -1), std::ios::oct, 0, '_',\n         \"3777777777777777777777777777777777777777777\"},\n        {uint128(-1, -1), std::ios::hex, 0, '_',\n         \"ffffffffffffffffffffffffffffffff\"},\n        // uppercase\n        {uint128(-1, -1), std::ios::hex | std::ios::uppercase, 0, '_',\n         \"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\"},\n        // showbase\n        {uint128(1), std::ios::dec | std::ios::showbase, 0, '_', \"1\"},\n        {uint128(1), std::ios::oct | std::ios::showbase, 0, '_', \"01\"},\n        {uint128(1), std::ios::hex | std::ios::showbase, 0, '_', \"0x1\"},\n        // showbase does nothing on zero\n        {uint128(0), std::ios::dec | std::ios::showbase, 0, '_', \"0\"},\n        {uint128(0), std::ios::oct | std::ios::showbase, 0, '_', \"0\"},\n        {uint128(0), std::ios::hex | std::ios::showbase, 0, '_', \"0\"},\n        // showpos does nothing on unsigned types\n        {uint128(1), std::ios::dec | std::ios::showpos, 0, '_', \"1\"},\n        // padding\n        {uint128(9), std::ios::dec, 6, '_', \"_____9\"},\n        {uint128(12345), std::ios::dec, 6, '_', \"_12345\"},\n        // left adjustment\n        {uint128(9), std::ios::dec | std::ios::left, 6, '_', \"9_____\"},\n        {uint128(12345), std::ios::dec | std::ios::left, 6, '_', \"12345_\"},\n  };\n  for (size_t i = 0; i < GOOGLE_ARRAYSIZE(cases); ++i) {\n    ostringstream os;\n    os.flags(cases[i].flags);\n    os.width(cases[i].width);\n    os.fill(cases[i].fill);\n    os << cases[i].val;\n    EXPECT_EQ(cases[i].rep, os.str());\n  }\n}\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/logging.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_STUBS_LOGGING_H_\n#define GOOGLE_PROTOBUF_STUBS_LOGGING_H_\n\n#include <google/protobuf/stubs/macros.h>\n#include <google/protobuf/stubs/port.h>\n\n// ===================================================================\n// emulates google3/base/logging.h\n\nnamespace google {\nnamespace protobuf {\n\nenum LogLevel {\n  LOGLEVEL_INFO,     // Informational.  This is never actually used by\n                     // libprotobuf.\n  LOGLEVEL_WARNING,  // Warns about issues that, although not technically a\n                     // problem now, could cause problems in the future.  For\n                     // example, a // warning will be printed when parsing a\n                     // message that is near the message size limit.\n  LOGLEVEL_ERROR,    // An error occurred which should never happen during\n                     // normal use.\n  LOGLEVEL_FATAL,    // An error occurred from which the library cannot\n                     // recover.  This usually indicates a programming error\n                     // in the code which calls the library, especially when\n                     // compiled in debug mode.\n\n#ifdef NDEBUG\n  LOGLEVEL_DFATAL = LOGLEVEL_ERROR\n#else\n  LOGLEVEL_DFATAL = LOGLEVEL_FATAL\n#endif\n};\n\nclass StringPiece;\nnamespace util {\nclass Status;\n}\nclass uint128;\nnamespace internal {\n\nclass LogFinisher;\n\nclass LIBPROTOBUF_EXPORT LogMessage {\n public:\n  LogMessage(LogLevel level, const char* filename, int line);\n  ~LogMessage();\n\n  LogMessage& operator<<(const std::string& value);\n  LogMessage& operator<<(const char* value);\n  LogMessage& operator<<(char value);\n  LogMessage& operator<<(int value);\n  LogMessage& operator<<(uint value);\n  LogMessage& operator<<(long value);\n  LogMessage& operator<<(unsigned long value);\n  LogMessage& operator<<(long long value);\n  LogMessage& operator<<(unsigned long long value);\n  LogMessage& operator<<(double value);\n  LogMessage& operator<<(void* value);\n  LogMessage& operator<<(const StringPiece& value);\n  LogMessage& operator<<(const ::google::protobuf::util::Status& status);\n  LogMessage& operator<<(const uint128& value);\n\n private:\n  friend class LogFinisher;\n  void Finish();\n\n  LogLevel level_;\n  const char* filename_;\n  int line_;\n  std::string message_;\n};\n\n// Used to make the entire \"LOG(BLAH) << etc.\" expression have a void return\n// type and print a newline after each message.\nclass LIBPROTOBUF_EXPORT LogFinisher {\n public:\n  void operator=(LogMessage& other);\n};\n\ntemplate<typename T>\nbool IsOk(T status) { return status.ok(); }\ntemplate<>\ninline bool IsOk(bool status) { return status; }\n\n}  // namespace internal\n\n// Undef everything in case we're being mixed with some other Google library\n// which already defined them itself.  Presumably all Google libraries will\n// support the same syntax for these so it should not be a big deal if they\n// end up using our definitions instead.\n#undef GOOGLE_LOG\n#undef GOOGLE_LOG_IF\n\n#undef GOOGLE_CHECK\n#undef GOOGLE_CHECK_OK\n#undef GOOGLE_CHECK_EQ\n#undef GOOGLE_CHECK_NE\n#undef GOOGLE_CHECK_LT\n#undef GOOGLE_CHECK_LE\n#undef GOOGLE_CHECK_GT\n#undef GOOGLE_CHECK_GE\n#undef GOOGLE_CHECK_NOTNULL\n\n#undef GOOGLE_DLOG\n#undef GOOGLE_DCHECK\n#undef GOOGLE_DCHECK_OK\n#undef GOOGLE_DCHECK_EQ\n#undef GOOGLE_DCHECK_NE\n#undef GOOGLE_DCHECK_LT\n#undef GOOGLE_DCHECK_LE\n#undef GOOGLE_DCHECK_GT\n#undef GOOGLE_DCHECK_GE\n\n#define GOOGLE_LOG(LEVEL)                                                 \\\n  ::google::protobuf::internal::LogFinisher() =                           \\\n    ::google::protobuf::internal::LogMessage(                             \\\n      ::google::protobuf::LOGLEVEL_##LEVEL, __FILE__, __LINE__)\n#define GOOGLE_LOG_IF(LEVEL, CONDITION) \\\n  !(CONDITION) ? (void)0 : GOOGLE_LOG(LEVEL)\n\n#define GOOGLE_CHECK(EXPRESSION) \\\n  GOOGLE_LOG_IF(FATAL, !(EXPRESSION)) << \"CHECK failed: \" #EXPRESSION \": \"\n#define GOOGLE_CHECK_OK(A) GOOGLE_CHECK(::google::protobuf::internal::IsOk(A))\n#define GOOGLE_CHECK_EQ(A, B) GOOGLE_CHECK((A) == (B))\n#define GOOGLE_CHECK_NE(A, B) GOOGLE_CHECK((A) != (B))\n#define GOOGLE_CHECK_LT(A, B) GOOGLE_CHECK((A) <  (B))\n#define GOOGLE_CHECK_LE(A, B) GOOGLE_CHECK((A) <= (B))\n#define GOOGLE_CHECK_GT(A, B) GOOGLE_CHECK((A) >  (B))\n#define GOOGLE_CHECK_GE(A, B) GOOGLE_CHECK((A) >= (B))\n\nnamespace internal {\ntemplate<typename T>\nT* CheckNotNull(const char* /* file */, int /* line */,\n                const char* name, T* val) {\n  if (val == NULL) {\n    GOOGLE_LOG(FATAL) << name;\n  }\n  return val;\n}\n}  // namespace internal\n#define GOOGLE_CHECK_NOTNULL(A) \\\n  ::google::protobuf::internal::CheckNotNull(\\\n      __FILE__, __LINE__, \"'\" #A \"' must not be NULL\", (A))\n\n#ifdef NDEBUG\n\n#define GOOGLE_DLOG(LEVEL) GOOGLE_LOG_IF(LEVEL, false)\n\n#define GOOGLE_DCHECK(EXPRESSION) while(false) GOOGLE_CHECK(EXPRESSION)\n#define GOOGLE_DCHECK_OK(E) GOOGLE_DCHECK(::google::protobuf::internal::IsOk(E))\n#define GOOGLE_DCHECK_EQ(A, B) GOOGLE_DCHECK((A) == (B))\n#define GOOGLE_DCHECK_NE(A, B) GOOGLE_DCHECK((A) != (B))\n#define GOOGLE_DCHECK_LT(A, B) GOOGLE_DCHECK((A) <  (B))\n#define GOOGLE_DCHECK_LE(A, B) GOOGLE_DCHECK((A) <= (B))\n#define GOOGLE_DCHECK_GT(A, B) GOOGLE_DCHECK((A) >  (B))\n#define GOOGLE_DCHECK_GE(A, B) GOOGLE_DCHECK((A) >= (B))\n\n#else  // NDEBUG\n\n#define GOOGLE_DLOG GOOGLE_LOG\n\n#define GOOGLE_DCHECK    GOOGLE_CHECK\n#define GOOGLE_DCHECK_OK GOOGLE_CHECK_OK\n#define GOOGLE_DCHECK_EQ GOOGLE_CHECK_EQ\n#define GOOGLE_DCHECK_NE GOOGLE_CHECK_NE\n#define GOOGLE_DCHECK_LT GOOGLE_CHECK_LT\n#define GOOGLE_DCHECK_LE GOOGLE_CHECK_LE\n#define GOOGLE_DCHECK_GT GOOGLE_CHECK_GT\n#define GOOGLE_DCHECK_GE GOOGLE_CHECK_GE\n\n#endif  // !NDEBUG\n\ntypedef void LogHandler(LogLevel level, const char* filename, int line,\n                        const std::string& message);\n\n// The protobuf library sometimes writes warning and error messages to\n// stderr.  These messages are primarily useful for developers, but may\n// also help end users figure out a problem.  If you would prefer that\n// these messages be sent somewhere other than stderr, call SetLogHandler()\n// to set your own handler.  This returns the old handler.  Set the handler\n// to NULL to ignore log messages (but see also LogSilencer, below).\n//\n// Obviously, SetLogHandler is not thread-safe.  You should only call it\n// at initialization time, and probably not from library code.  If you\n// simply want to suppress log messages temporarily (e.g. because you\n// have some code that tends to trigger them frequently and you know\n// the warnings are not important to you), use the LogSilencer class\n// below.\nLIBPROTOBUF_EXPORT LogHandler* SetLogHandler(LogHandler* new_func);\n\n// Create a LogSilencer if you want to temporarily suppress all log\n// messages.  As long as any LogSilencer objects exist, non-fatal\n// log messages will be discarded (the current LogHandler will *not*\n// be called).  Constructing a LogSilencer is thread-safe.  You may\n// accidentally suppress log messages occurring in another thread, but\n// since messages are generally for debugging purposes only, this isn't\n// a big deal.  If you want to intercept log messages, use SetLogHandler().\nclass LIBPROTOBUF_EXPORT LogSilencer {\n public:\n  LogSilencer();\n  ~LogSilencer();\n};\n\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_STUBS_LOGGING_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/macros.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_MACROS_H__\n#define GOOGLE_PROTOBUF_MACROS_H__\n\n#include <google/protobuf/stubs/port.h>\n\nnamespace google {\nnamespace protobuf {\n\n#undef GOOGLE_DISALLOW_EVIL_CONSTRUCTORS\n#define GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeName)    \\\n  TypeName(const TypeName&);                           \\\n  void operator=(const TypeName&)\n\n#undef GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS\n#define GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \\\n  TypeName();                                           \\\n  TypeName(const TypeName&);                            \\\n  void operator=(const TypeName&)\n\n// ===================================================================\n// from google3/base/basictypes.h\n\n// The GOOGLE_ARRAYSIZE(arr) macro returns the # of elements in an array arr.\n// The expression is a compile-time constant, and therefore can be\n// used in defining new arrays, for example.\n//\n// GOOGLE_ARRAYSIZE catches a few type errors.  If you see a compiler error\n//\n//   \"warning: division by zero in ...\"\n//\n// when using GOOGLE_ARRAYSIZE, you are (wrongfully) giving it a pointer.\n// You should only use GOOGLE_ARRAYSIZE on statically allocated arrays.\n//\n// The following comments are on the implementation details, and can\n// be ignored by the users.\n//\n// ARRAYSIZE(arr) works by inspecting sizeof(arr) (the # of bytes in\n// the array) and sizeof(*(arr)) (the # of bytes in one array\n// element).  If the former is divisible by the latter, perhaps arr is\n// indeed an array, in which case the division result is the # of\n// elements in the array.  Otherwise, arr cannot possibly be an array,\n// and we generate a compiler error to prevent the code from\n// compiling.\n//\n// Since the size of bool is implementation-defined, we need to cast\n// !(sizeof(a) & sizeof(*(a))) to size_t in order to ensure the final\n// result has type size_t.\n//\n// This macro is not perfect as it wrongfully accepts certain\n// pointers, namely where the pointer size is divisible by the pointee\n// size.  Since all our code has to go through a 32-bit compiler,\n// where a pointer is 4 bytes, this means all pointers to a type whose\n// size is 3 or greater than 4 will be (righteously) rejected.\n//\n// Kudos to Jorg Brown for this simple and elegant implementation.\n\n#undef GOOGLE_ARRAYSIZE\n#define GOOGLE_ARRAYSIZE(a) \\\n  ((sizeof(a) / sizeof(*(a))) / \\\n   static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))\n\n// The COMPILE_ASSERT macro can be used to verify that a compile time\n// expression is true. For example, you could use it to verify the\n// size of a static array:\n//\n//   COMPILE_ASSERT(ARRAYSIZE(content_type_names) == CONTENT_NUM_TYPES,\n//                  content_type_names_incorrect_size);\n//\n// or to make sure a struct is smaller than a certain size:\n//\n//   COMPILE_ASSERT(sizeof(foo) < 128, foo_too_large);\n//\n// The second argument to the macro is the name of the variable. If\n// the expression is false, most compilers will issue a warning/error\n// containing the name of the variable.\n\nnamespace internal {\n\ntemplate <bool>\nstruct CompileAssert {\n};\n\n}  // namespace internal\n\n#undef GOOGLE_COMPILE_ASSERT\n#if __cplusplus >= 201103L\n#define GOOGLE_COMPILE_ASSERT(expr, msg) static_assert(expr, #msg)\n#else\n#define GOOGLE_COMPILE_ASSERT(expr, msg) \\\n  ::google::protobuf::internal::CompileAssert<(bool(expr))> \\\n          msg[bool(expr) ? 1 : -1]; \\\n  (void)msg\n// Implementation details of COMPILE_ASSERT:\n//\n// - COMPILE_ASSERT works by defining an array type that has -1\n//   elements (and thus is invalid) when the expression is false.\n//\n// - The simpler definition\n//\n//     #define COMPILE_ASSERT(expr, msg) typedef char msg[(expr) ? 1 : -1]\n//\n//   does not work, as gcc supports variable-length arrays whose sizes\n//   are determined at run-time (this is gcc's extension and not part\n//   of the C++ standard).  As a result, gcc fails to reject the\n//   following code with the simple definition:\n//\n//     int foo;\n//     COMPILE_ASSERT(foo, msg); // not supposed to compile as foo is\n//                               // not a compile-time constant.\n//\n// - By using the type CompileAssert<(bool(expr))>, we ensures that\n//   expr is a compile-time constant.  (Template arguments must be\n//   determined at compile-time.)\n//\n// - The outter parentheses in CompileAssert<(bool(expr))> are necessary\n//   to work around a bug in gcc 3.4.4 and 4.0.1.  If we had written\n//\n//     CompileAssert<bool(expr)>\n//\n//   instead, these compilers will refuse to compile\n//\n//     COMPILE_ASSERT(5 > 0, some_message);\n//\n//   (They seem to think the \">\" in \"5 > 0\" marks the end of the\n//   template argument list.)\n//\n// - The array size is (bool(expr) ? 1 : -1), instead of simply\n//\n//     ((expr) ? 1 : -1).\n//\n//   This is to avoid running into a bug in MS VC 7.1, which\n//   causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1.\n#endif  // __cplusplus >= 201103L\n\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_MACROS_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/map_util.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2014 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// from google3/util/gtl/map_util.h\n// Author: Anton Carver\n\n#ifndef GOOGLE_PROTOBUF_STUBS_MAP_UTIL_H__\n#define GOOGLE_PROTOBUF_STUBS_MAP_UTIL_H__\n\n#include <stddef.h>\n#include <iterator>\n#include <string>\n#include <utility>\n#include <vector>\n\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n// Local implementation of RemoveConst to avoid including base/type_traits.h.\ntemplate <class T> struct RemoveConst { typedef T type; };\ntemplate <class T> struct RemoveConst<const T> : RemoveConst<T> {};\n}  // namespace internal\n\n//\n// Find*()\n//\n\n// Returns a const reference to the value associated with the given key if it\n// exists. Crashes otherwise.\n//\n// This is intended as a replacement for operator[] as an rvalue (for reading)\n// when the key is guaranteed to exist.\n//\n// operator[] for lookup is discouraged for several reasons:\n//  * It has a side-effect of inserting missing keys\n//  * It is not thread-safe (even when it is not inserting, it can still\n//      choose to resize the underlying storage)\n//  * It invalidates iterators (when it chooses to resize)\n//  * It default constructs a value object even if it doesn't need to\n//\n// This version assumes the key is printable, and includes it in the fatal log\n// message.\ntemplate <class Collection>\nconst typename Collection::value_type::second_type&\nFindOrDie(const Collection& collection,\n          const typename Collection::value_type::first_type& key) {\n  typename Collection::const_iterator it = collection.find(key);\n  GOOGLE_CHECK(it != collection.end()) << \"Map key not found: \" << key;\n  return it->second;\n}\n\n// Same as above, but returns a non-const reference.\ntemplate <class Collection>\ntypename Collection::value_type::second_type&\nFindOrDie(Collection& collection,  // NOLINT\n          const typename Collection::value_type::first_type& key) {\n  typename Collection::iterator it = collection.find(key);\n  GOOGLE_CHECK(it != collection.end()) << \"Map key not found: \" << key;\n  return it->second;\n}\n\n// Same as FindOrDie above, but doesn't log the key on failure.\ntemplate <class Collection>\nconst typename Collection::value_type::second_type&\nFindOrDieNoPrint(const Collection& collection,\n                 const typename Collection::value_type::first_type& key) {\n  typename Collection::const_iterator it = collection.find(key);\n  GOOGLE_CHECK(it != collection.end()) << \"Map key not found\";\n  return it->second;\n}\n\n// Same as above, but returns a non-const reference.\ntemplate <class Collection>\ntypename Collection::value_type::second_type&\nFindOrDieNoPrint(Collection& collection,  // NOLINT\n                 const typename Collection::value_type::first_type& key) {\n  typename Collection::iterator it = collection.find(key);\n  GOOGLE_CHECK(it != collection.end()) << \"Map key not found\";\n  return it->second;\n}\n\n// Returns a const reference to the value associated with the given key if it\n// exists, otherwise returns a const reference to the provided default value.\n//\n// WARNING: If a temporary object is passed as the default \"value,\"\n// this function will return a reference to that temporary object,\n// which will be destroyed at the end of the statement. A common\n// example: if you have a map with string values, and you pass a char*\n// as the default \"value,\" either use the returned value immediately\n// or store it in a string (not string&).\n// Details: http://go/findwithdefault\ntemplate <class Collection>\nconst typename Collection::value_type::second_type&\nFindWithDefault(const Collection& collection,\n                const typename Collection::value_type::first_type& key,\n                const typename Collection::value_type::second_type& value) {\n  typename Collection::const_iterator it = collection.find(key);\n  if (it == collection.end()) {\n    return value;\n  }\n  return it->second;\n}\n\n// Returns a pointer to the const value associated with the given key if it\n// exists, or NULL otherwise.\ntemplate <class Collection>\nconst typename Collection::value_type::second_type*\nFindOrNull(const Collection& collection,\n           const typename Collection::value_type::first_type& key) {\n  typename Collection::const_iterator it = collection.find(key);\n  if (it == collection.end()) {\n    return 0;\n  }\n  return &it->second;\n}\n\n// Same as above but returns a pointer to the non-const value.\ntemplate <class Collection>\ntypename Collection::value_type::second_type*\nFindOrNull(Collection& collection,  // NOLINT\n           const typename Collection::value_type::first_type& key) {\n  typename Collection::iterator it = collection.find(key);\n  if (it == collection.end()) {\n    return 0;\n  }\n  return &it->second;\n}\n\n// Returns the pointer value associated with the given key. If none is found,\n// NULL is returned. The function is designed to be used with a map of keys to\n// pointers.\n//\n// This function does not distinguish between a missing key and a key mapped\n// to a NULL value.\ntemplate <class Collection>\ntypename Collection::value_type::second_type\nFindPtrOrNull(const Collection& collection,\n              const typename Collection::value_type::first_type& key) {\n  typename Collection::const_iterator it = collection.find(key);\n  if (it == collection.end()) {\n    return typename Collection::value_type::second_type();\n  }\n  return it->second;\n}\n\n// Same as above, except takes non-const reference to collection.\n//\n// This function is needed for containers that propagate constness to the\n// pointee, such as boost::ptr_map.\ntemplate <class Collection>\ntypename Collection::value_type::second_type\nFindPtrOrNull(Collection& collection,  // NOLINT\n              const typename Collection::value_type::first_type& key) {\n  typename Collection::iterator it = collection.find(key);\n  if (it == collection.end()) {\n    return typename Collection::value_type::second_type();\n  }\n  return it->second;\n}\n\n// Finds the pointer value associated with the given key in a map whose values\n// are linked_ptrs. Returns NULL if key is not found.\ntemplate <class Collection>\ntypename Collection::value_type::second_type::element_type*\nFindLinkedPtrOrNull(const Collection& collection,\n                    const typename Collection::value_type::first_type& key) {\n  typename Collection::const_iterator it = collection.find(key);\n  if (it == collection.end()) {\n    return 0;\n  }\n  // Since linked_ptr::get() is a const member returning a non const,\n  // we do not need a version of this function taking a non const collection.\n  return it->second.get();\n}\n\n// Same as above, but dies if the key is not found.\ntemplate <class Collection>\ntypename Collection::value_type::second_type::element_type&\nFindLinkedPtrOrDie(const Collection& collection,\n                   const typename Collection::value_type::first_type& key) {\n  typename Collection::const_iterator it = collection.find(key);\n  CHECK(it != collection.end()) <<  \"key not found: \" << key;\n  // Since linked_ptr::operator*() is a const member returning a non const,\n  // we do not need a version of this function taking a non const collection.\n  return *it->second;\n}\n\n// Finds the value associated with the given key and copies it to *value (if not\n// NULL). Returns false if the key was not found, true otherwise.\ntemplate <class Collection, class Key, class Value>\nbool FindCopy(const Collection& collection,\n              const Key& key,\n              Value* const value) {\n  typename Collection::const_iterator it = collection.find(key);\n  if (it == collection.end()) {\n    return false;\n  }\n  if (value) {\n    *value = it->second;\n  }\n  return true;\n}\n\n//\n// Contains*()\n//\n\n// Returns true if and only if the given collection contains the given key.\ntemplate <class Collection, class Key>\nbool ContainsKey(const Collection& collection, const Key& key) {\n  return collection.find(key) != collection.end();\n}\n\n// Returns true if and only if the given collection contains the given key-value\n// pair.\ntemplate <class Collection, class Key, class Value>\nbool ContainsKeyValuePair(const Collection& collection,\n                          const Key& key,\n                          const Value& value) {\n  typedef typename Collection::const_iterator const_iterator;\n  std::pair<const_iterator, const_iterator> range = collection.equal_range(key);\n  for (const_iterator it = range.first; it != range.second; ++it) {\n    if (it->second == value) {\n      return true;\n    }\n  }\n  return false;\n}\n\n//\n// Insert*()\n//\n\n// Inserts the given key-value pair into the collection. Returns true if and\n// only if the key from the given pair didn't previously exist. Otherwise, the\n// value in the map is replaced with the value from the given pair.\ntemplate <class Collection>\nbool InsertOrUpdate(Collection* const collection,\n                    const typename Collection::value_type& vt) {\n  std::pair<typename Collection::iterator, bool> ret = collection->insert(vt);\n  if (!ret.second) {\n    // update\n    ret.first->second = vt.second;\n    return false;\n  }\n  return true;\n}\n\n// Same as above, except that the key and value are passed separately.\ntemplate <class Collection>\nbool InsertOrUpdate(Collection* const collection,\n                    const typename Collection::value_type::first_type& key,\n                    const typename Collection::value_type::second_type& value) {\n  return InsertOrUpdate(\n      collection, typename Collection::value_type(key, value));\n}\n\n// Inserts/updates all the key-value pairs from the range defined by the\n// iterators \"first\" and \"last\" into the given collection.\ntemplate <class Collection, class InputIterator>\nvoid InsertOrUpdateMany(Collection* const collection,\n                        InputIterator first, InputIterator last) {\n  for (; first != last; ++first) {\n    InsertOrUpdate(collection, *first);\n  }\n}\n\n// Change the value associated with a particular key in a map or hash_map\n// of the form map<Key, Value*> which owns the objects pointed to by the\n// value pointers.  If there was an existing value for the key, it is deleted.\n// True indicates an insert took place, false indicates an update + delete.\ntemplate <class Collection>\nbool InsertAndDeleteExisting(\n    Collection* const collection,\n    const typename Collection::value_type::first_type& key,\n    const typename Collection::value_type::second_type& value) {\n  std::pair<typename Collection::iterator, bool> ret =\n      collection->insert(typename Collection::value_type(key, value));\n  if (!ret.second) {\n    delete ret.first->second;\n    ret.first->second = value;\n    return false;\n  }\n  return true;\n}\n\n// Inserts the given key and value into the given collection if and only if the\n// given key did NOT already exist in the collection. If the key previously\n// existed in the collection, the value is not changed. Returns true if the\n// key-value pair was inserted; returns false if the key was already present.\ntemplate <class Collection>\nbool InsertIfNotPresent(Collection* const collection,\n                        const typename Collection::value_type& vt) {\n  return collection->insert(vt).second;\n}\n\n// Same as above except the key and value are passed separately.\ntemplate <class Collection>\nbool InsertIfNotPresent(\n    Collection* const collection,\n    const typename Collection::value_type::first_type& key,\n    const typename Collection::value_type::second_type& value) {\n  return InsertIfNotPresent(\n      collection, typename Collection::value_type(key, value));\n}\n\n// Same as above except dies if the key already exists in the collection.\ntemplate <class Collection>\nvoid InsertOrDie(Collection* const collection,\n                 const typename Collection::value_type& value) {\n  CHECK(InsertIfNotPresent(collection, value)) << \"duplicate value: \" << value;\n}\n\n// Same as above except doesn't log the value on error.\ntemplate <class Collection>\nvoid InsertOrDieNoPrint(Collection* const collection,\n                        const typename Collection::value_type& value) {\n  CHECK(InsertIfNotPresent(collection, value)) << \"duplicate value.\";\n}\n\n// Inserts the key-value pair into the collection. Dies if key was already\n// present.\ntemplate <class Collection>\nvoid InsertOrDie(Collection* const collection,\n                 const typename Collection::value_type::first_type& key,\n                 const typename Collection::value_type::second_type& data) {\n  GOOGLE_CHECK(InsertIfNotPresent(collection, key, data))\n      << \"duplicate key: \" << key;\n}\n\n// Same as above except doesn't log the key on error.\ntemplate <class Collection>\nvoid InsertOrDieNoPrint(\n    Collection* const collection,\n    const typename Collection::value_type::first_type& key,\n    const typename Collection::value_type::second_type& data) {\n  GOOGLE_CHECK(InsertIfNotPresent(collection, key, data)) << \"duplicate key.\";\n}\n\n// Inserts a new key and default-initialized value. Dies if the key was already\n// present. Returns a reference to the value. Example usage:\n//\n// map<int, SomeProto> m;\n// SomeProto& proto = InsertKeyOrDie(&m, 3);\n// proto.set_field(\"foo\");\ntemplate <class Collection>\ntypename Collection::value_type::second_type& InsertKeyOrDie(\n    Collection* const collection,\n    const typename Collection::value_type::first_type& key) {\n  typedef typename Collection::value_type value_type;\n  std::pair<typename Collection::iterator, bool> res =\n      collection->insert(value_type(key, typename value_type::second_type()));\n  GOOGLE_CHECK(res.second) << \"duplicate key: \" << key;\n  return res.first->second;\n}\n\n//\n// Lookup*()\n//\n\n// Looks up a given key and value pair in a collection and inserts the key-value\n// pair if it's not already present. Returns a reference to the value associated\n// with the key.\ntemplate <class Collection>\ntypename Collection::value_type::second_type&\nLookupOrInsert(Collection* const collection,\n               const typename Collection::value_type& vt) {\n  return collection->insert(vt).first->second;\n}\n\n// Same as above except the key-value are passed separately.\ntemplate <class Collection>\ntypename Collection::value_type::second_type&\nLookupOrInsert(Collection* const collection,\n               const typename Collection::value_type::first_type& key,\n               const typename Collection::value_type::second_type& value) {\n  return LookupOrInsert(\n      collection, typename Collection::value_type(key, value));\n}\n\n// Counts the number of equivalent elements in the given \"sequence\", and stores\n// the results in \"count_map\" with element as the key and count as the value.\n//\n// Example:\n//   vector<string> v = {\"a\", \"b\", \"c\", \"a\", \"b\"};\n//   map<string, int> m;\n//   AddTokenCounts(v, 1, &m);\n//   assert(m[\"a\"] == 2);\n//   assert(m[\"b\"] == 2);\n//   assert(m[\"c\"] == 1);\ntemplate <typename Sequence, typename Collection>\nvoid AddTokenCounts(\n    const Sequence& sequence,\n    const typename Collection::value_type::second_type& increment,\n    Collection* const count_map) {\n  for (typename Sequence::const_iterator it = sequence.begin();\n       it != sequence.end(); ++it) {\n    typename Collection::value_type::second_type& value =\n        LookupOrInsert(count_map, *it,\n                       typename Collection::value_type::second_type());\n    value += increment;\n  }\n}\n\n// Returns a reference to the value associated with key. If not found, a value\n// is default constructed on the heap and added to the map.\n//\n// This function is useful for containers of the form map<Key, Value*>, where\n// inserting a new key, value pair involves constructing a new heap-allocated\n// Value, and storing a pointer to that in the collection.\ntemplate <class Collection>\ntypename Collection::value_type::second_type&\nLookupOrInsertNew(Collection* const collection,\n                  const typename Collection::value_type::first_type& key) {\n  typedef typename std::iterator_traits<\n    typename Collection::value_type::second_type>::value_type Element;\n  std::pair<typename Collection::iterator, bool> ret =\n      collection->insert(typename Collection::value_type(\n          key,\n          static_cast<typename Collection::value_type::second_type>(NULL)));\n  if (ret.second) {\n    ret.first->second = new Element();\n  }\n  return ret.first->second;\n}\n\n// Same as above but constructs the value using the single-argument constructor\n// and the given \"arg\".\ntemplate <class Collection, class Arg>\ntypename Collection::value_type::second_type&\nLookupOrInsertNew(Collection* const collection,\n                  const typename Collection::value_type::first_type& key,\n                  const Arg& arg) {\n  typedef typename std::iterator_traits<\n    typename Collection::value_type::second_type>::value_type Element;\n  std::pair<typename Collection::iterator, bool> ret =\n      collection->insert(typename Collection::value_type(\n          key,\n          static_cast<typename Collection::value_type::second_type>(NULL)));\n  if (ret.second) {\n    ret.first->second = new Element(arg);\n  }\n  return ret.first->second;\n}\n\n// Lookup of linked/shared pointers is used in two scenarios:\n//\n// Use LookupOrInsertNewLinkedPtr if the container owns the elements.\n// In this case it is fine working with the raw pointer as long as it is\n// guaranteed that no other thread can delete/update an accessed element.\n// A mutex will need to lock the container operation as well as the use\n// of the returned elements. Finding an element may be performed using\n// FindLinkedPtr*().\n//\n// Use LookupOrInsertNewSharedPtr if the container does not own the elements\n// for their whole lifetime. This is typically the case when a reader allows\n// parallel updates to the container. In this case a Mutex only needs to lock\n// container operations, but all element operations must be performed on the\n// shared pointer. Finding an element must be performed using FindPtr*() and\n// cannot be done with FindLinkedPtr*() even though it compiles.\n\n// Lookup a key in a map or hash_map whose values are linked_ptrs.  If it is\n// missing, set collection[key].reset(new Value::element_type) and return that.\n// Value::element_type must be default constructable.\ntemplate <class Collection>\ntypename Collection::value_type::second_type::element_type*\nLookupOrInsertNewLinkedPtr(\n    Collection* const collection,\n    const typename Collection::value_type::first_type& key) {\n  typedef typename Collection::value_type::second_type Value;\n  std::pair<typename Collection::iterator, bool> ret =\n      collection->insert(typename Collection::value_type(key, Value()));\n  if (ret.second) {\n    ret.first->second.reset(new typename Value::element_type);\n  }\n  return ret.first->second.get();\n}\n\n// A variant of LookupOrInsertNewLinkedPtr where the value is constructed using\n// a single-parameter constructor.  Note: the constructor argument is computed\n// even if it will not be used, so only values cheap to compute should be passed\n// here.  On the other hand it does not matter how expensive the construction of\n// the actual stored value is, as that only occurs if necessary.\ntemplate <class Collection, class Arg>\ntypename Collection::value_type::second_type::element_type*\nLookupOrInsertNewLinkedPtr(\n    Collection* const collection,\n    const typename Collection::value_type::first_type& key,\n    const Arg& arg) {\n  typedef typename Collection::value_type::second_type Value;\n  std::pair<typename Collection::iterator, bool> ret =\n      collection->insert(typename Collection::value_type(key, Value()));\n  if (ret.second) {\n    ret.first->second.reset(new typename Value::element_type(arg));\n  }\n  return ret.first->second.get();\n}\n\n// Lookup a key in a map or hash_map whose values are shared_ptrs.  If it is\n// missing, set collection[key].reset(new Value::element_type). Unlike\n// LookupOrInsertNewLinkedPtr, this function returns the shared_ptr instead of\n// the raw pointer. Value::element_type must be default constructable.\ntemplate <class Collection>\ntypename Collection::value_type::second_type&\nLookupOrInsertNewSharedPtr(\n    Collection* const collection,\n    const typename Collection::value_type::first_type& key) {\n  typedef typename Collection::value_type::second_type SharedPtr;\n  typedef typename Collection::value_type::second_type::element_type Element;\n  std::pair<typename Collection::iterator, bool> ret =\n      collection->insert(typename Collection::value_type(key, SharedPtr()));\n  if (ret.second) {\n    ret.first->second.reset(new Element());\n  }\n  return ret.first->second;\n}\n\n// A variant of LookupOrInsertNewSharedPtr where the value is constructed using\n// a single-parameter constructor.  Note: the constructor argument is computed\n// even if it will not be used, so only values cheap to compute should be passed\n// here.  On the other hand it does not matter how expensive the construction of\n// the actual stored value is, as that only occurs if necessary.\ntemplate <class Collection, class Arg>\ntypename Collection::value_type::second_type&\nLookupOrInsertNewSharedPtr(\n    Collection* const collection,\n    const typename Collection::value_type::first_type& key,\n    const Arg& arg) {\n  typedef typename Collection::value_type::second_type SharedPtr;\n  typedef typename Collection::value_type::second_type::element_type Element;\n  std::pair<typename Collection::iterator, bool> ret =\n      collection->insert(typename Collection::value_type(key, SharedPtr()));\n  if (ret.second) {\n    ret.first->second.reset(new Element(arg));\n  }\n  return ret.first->second;\n}\n\n//\n// Misc Utility Functions\n//\n\n// Updates the value associated with the given key. If the key was not already\n// present, then the key-value pair are inserted and \"previous\" is unchanged. If\n// the key was already present, the value is updated and \"*previous\" will\n// contain a copy of the old value.\n//\n// InsertOrReturnExisting has complementary behavior that returns the\n// address of an already existing value, rather than updating it.\ntemplate <class Collection>\nbool UpdateReturnCopy(Collection* const collection,\n                      const typename Collection::value_type::first_type& key,\n                      const typename Collection::value_type::second_type& value,\n                      typename Collection::value_type::second_type* previous) {\n  std::pair<typename Collection::iterator, bool> ret =\n      collection->insert(typename Collection::value_type(key, value));\n  if (!ret.second) {\n    // update\n    if (previous) {\n      *previous = ret.first->second;\n    }\n    ret.first->second = value;\n    return true;\n  }\n  return false;\n}\n\n// Same as above except that the key and value are passed as a pair.\ntemplate <class Collection>\nbool UpdateReturnCopy(Collection* const collection,\n                      const typename Collection::value_type& vt,\n                      typename Collection::value_type::second_type* previous) {\n  std::pair<typename Collection::iterator, bool> ret = collection->insert(vt);\n  if (!ret.second) {\n    // update\n    if (previous) {\n      *previous = ret.first->second;\n    }\n    ret.first->second = vt.second;\n    return true;\n  }\n  return false;\n}\n\n// Tries to insert the given key-value pair into the collection. Returns NULL if\n// the insert succeeds. Otherwise, returns a pointer to the existing value.\n//\n// This complements UpdateReturnCopy in that it allows to update only after\n// verifying the old value and still insert quickly without having to look up\n// twice. Unlike UpdateReturnCopy this also does not come with the issue of an\n// undefined previous* in case new data was inserted.\ntemplate <class Collection>\ntypename Collection::value_type::second_type* const\nInsertOrReturnExisting(Collection* const collection,\n                       const typename Collection::value_type& vt) {\n  std::pair<typename Collection::iterator, bool> ret = collection->insert(vt);\n  if (ret.second) {\n    return NULL;  // Inserted, no existing previous value.\n  } else {\n    return &ret.first->second;  // Return address of already existing value.\n  }\n}\n\n// Same as above, except for explicit key and data.\ntemplate <class Collection>\ntypename Collection::value_type::second_type* const\nInsertOrReturnExisting(\n    Collection* const collection,\n    const typename Collection::value_type::first_type& key,\n    const typename Collection::value_type::second_type& data) {\n  return InsertOrReturnExisting(collection,\n                                typename Collection::value_type(key, data));\n}\n\n// Erases the collection item identified by the given key, and returns the value\n// associated with that key. It is assumed that the value (i.e., the\n// mapped_type) is a pointer. Returns NULL if the key was not found in the\n// collection.\n//\n// Examples:\n//   map<string, MyType*> my_map;\n//\n// One line cleanup:\n//     delete EraseKeyReturnValuePtr(&my_map, \"abc\");\n//\n// Use returned value:\n//     scoped_ptr<MyType> value_ptr(EraseKeyReturnValuePtr(&my_map, \"abc\"));\n//     if (value_ptr.get())\n//       value_ptr->DoSomething();\n//\ntemplate <class Collection>\ntypename Collection::value_type::second_type EraseKeyReturnValuePtr(\n    Collection* const collection,\n    const typename Collection::value_type::first_type& key) {\n  typename Collection::iterator it = collection->find(key);\n  if (it == collection->end()) {\n    return NULL;\n  }\n  typename Collection::value_type::second_type v = it->second;\n  collection->erase(it);\n  return v;\n}\n\n// Inserts all the keys from map_container into key_container, which must\n// support insert(MapContainer::key_type).\n//\n// Note: any initial contents of the key_container are not cleared.\ntemplate <class MapContainer, class KeyContainer>\nvoid InsertKeysFromMap(const MapContainer& map_container,\n                       KeyContainer* key_container) {\n  GOOGLE_CHECK(key_container != NULL);\n  for (typename MapContainer::const_iterator it = map_container.begin();\n       it != map_container.end(); ++it) {\n    key_container->insert(it->first);\n  }\n}\n\n// Appends all the keys from map_container into key_container, which must\n// support push_back(MapContainer::key_type).\n//\n// Note: any initial contents of the key_container are not cleared.\ntemplate <class MapContainer, class KeyContainer>\nvoid AppendKeysFromMap(const MapContainer& map_container,\n                       KeyContainer* key_container) {\n  GOOGLE_CHECK(key_container != NULL);\n  for (typename MapContainer::const_iterator it = map_container.begin();\n       it != map_container.end(); ++it) {\n    key_container->push_back(it->first);\n  }\n}\n\n// A more specialized overload of AppendKeysFromMap to optimize reallocations\n// for the common case in which we're appending keys to a vector and hence can\n// (and sometimes should) call reserve() first.\n//\n// (It would be possible to play SFINAE games to call reserve() for any\n// container that supports it, but this seems to get us 99% of what we need\n// without the complexity of a SFINAE-based solution.)\ntemplate <class MapContainer, class KeyType>\nvoid AppendKeysFromMap(const MapContainer& map_container,\n                       vector<KeyType>* key_container) {\n  GOOGLE_CHECK(key_container != NULL);\n  // We now have the opportunity to call reserve(). Calling reserve() every\n  // time is a bad idea for some use cases: libstdc++'s implementation of\n  // vector<>::reserve() resizes the vector's backing store to exactly the\n  // given size (unless it's already at least that big). Because of this,\n  // the use case that involves appending a lot of small maps (total size\n  // N) one by one to a vector would be O(N^2). But never calling reserve()\n  // loses the opportunity to improve the use case of adding from a large\n  // map to an empty vector (this improves performance by up to 33%). A\n  // number of heuristics are possible; see the discussion in\n  // cl/34081696. Here we use the simplest one.\n  if (key_container->empty()) {\n    key_container->reserve(map_container.size());\n  }\n  for (typename MapContainer::const_iterator it = map_container.begin();\n       it != map_container.end(); ++it) {\n    key_container->push_back(it->first);\n  }\n}\n\n// Inserts all the values from map_container into value_container, which must\n// support push_back(MapContainer::mapped_type).\n//\n// Note: any initial contents of the value_container are not cleared.\ntemplate <class MapContainer, class ValueContainer>\nvoid AppendValuesFromMap(const MapContainer& map_container,\n                         ValueContainer* value_container) {\n  GOOGLE_CHECK(value_container != NULL);\n  for (typename MapContainer::const_iterator it = map_container.begin();\n       it != map_container.end(); ++it) {\n    value_container->push_back(it->second);\n  }\n}\n\n// A more specialized overload of AppendValuesFromMap to optimize reallocations\n// for the common case in which we're appending values to a vector and hence\n// can (and sometimes should) call reserve() first.\n//\n// (It would be possible to play SFINAE games to call reserve() for any\n// container that supports it, but this seems to get us 99% of what we need\n// without the complexity of a SFINAE-based solution.)\ntemplate <class MapContainer, class ValueType>\nvoid AppendValuesFromMap(const MapContainer& map_container,\n                         vector<ValueType>* value_container) {\n  GOOGLE_CHECK(value_container != NULL);\n  // See AppendKeysFromMap for why this is done.\n  if (value_container->empty()) {\n    value_container->reserve(map_container.size());\n  }\n  for (typename MapContainer::const_iterator it = map_container.begin();\n       it != map_container.end(); ++it) {\n    value_container->push_back(it->second);\n  }\n}\n\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_STUBS_MAP_UTIL_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/mathlimits.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// All Rights Reserved.\n//\n// Author: Maxim Lifantsev\n//\n\n#include <google/protobuf/stubs/mathlimits.h>\n\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\n\n// MSVC++ 2005 and older compilers think the header declaration was a\n// definition, and erroneously flag these as a duplicate definition.\n#if defined(COMPILER_MSVC) || __cpluscplus < 201103L\n\n#define DEF_COMMON_LIMITS(Type)\n#define DEF_UNSIGNED_INT_LIMITS(Type)\n#define DEF_SIGNED_INT_LIMITS(Type)\n#define DEF_PRECISION_LIMITS(Type)\n\n#else\n\n#define DEF_COMMON_LIMITS(Type) \\\nconst bool MathLimits<Type>::kIsSigned; \\\nconst bool MathLimits<Type>::kIsInteger; \\\nconst int MathLimits<Type>::kMin10Exp; \\\nconst int MathLimits<Type>::kMax10Exp;\n\n#define DEF_UNSIGNED_INT_LIMITS(Type) \\\nDEF_COMMON_LIMITS(Type) \\\nconst Type MathLimits<Type>::kPosMin; \\\nconst Type MathLimits<Type>::kPosMax; \\\nconst Type MathLimits<Type>::kMin; \\\nconst Type MathLimits<Type>::kMax; \\\nconst Type MathLimits<Type>::kEpsilon; \\\nconst Type MathLimits<Type>::kStdError;\n\n#define DEF_SIGNED_INT_LIMITS(Type) \\\nDEF_UNSIGNED_INT_LIMITS(Type) \\\nconst Type MathLimits<Type>::kNegMin; \\\nconst Type MathLimits<Type>::kNegMax;\n\n#define DEF_PRECISION_LIMITS(Type) \\\nconst int MathLimits<Type>::kPrecisionDigits;\n\n#endif  // not COMPILER_MSVC\n\n// http://en.wikipedia.org/wiki/Quadruple_precision_floating-point_format#Double-double_arithmetic\n// With some compilers (gcc 4.6.x) on some platforms (powerpc64),\n// \"long double\" is implemented as a pair of double: \"double double\" format.\n// This causes a problem with epsilon (eps).\n// eps is the smallest positive number such that 1.0 + eps > 1.0\n//\n// Normal format:  1.0 + e = 1.0...01      // N-1 zeros for N fraction bits\n// D-D format:     1.0 + e = 1.000...0001  // epsilon can be very small\n//\n// In the normal format, 1.0 + e has to fit in one stretch of bits.\n// The maximum rounding error is half of eps.\n//\n// In the double-double format, 1.0 + e splits across two doubles:\n// 1.0 in the high double, e in the low double, and they do not have to\n// be contiguous.  The maximum rounding error on a value close to 1.0 is\n// much larger than eps.\n//\n// Some code checks for errors by comparing a computed value to a golden\n// value +/- some multiple of the maximum rounding error.  The maximum\n// rounding error is not available so we use eps as an approximation\n// instead.  That fails when long double is in the double-double format.\n// Therefore, we define kStdError as a multiple of\n// max(DBL_EPSILON * DBL_EPSILON, kEpsilon) rather than a multiple of kEpsilon.\n\n#define DEF_FP_LIMITS(Type, PREFIX) \\\nDEF_COMMON_LIMITS(Type) \\\nconst Type MathLimits<Type>::kPosMin = PREFIX##_MIN; \\\nconst Type MathLimits<Type>::kPosMax = PREFIX##_MAX; \\\nconst Type MathLimits<Type>::kMin = -MathLimits<Type>::kPosMax; \\\nconst Type MathLimits<Type>::kMax = MathLimits<Type>::kPosMax; \\\nconst Type MathLimits<Type>::kNegMin = -MathLimits<Type>::kPosMin; \\\nconst Type MathLimits<Type>::kNegMax = -MathLimits<Type>::kPosMax; \\\nconst Type MathLimits<Type>::kEpsilon = PREFIX##_EPSILON; \\\n/* 32 is 5 bits of mantissa error; should be adequate for common errors */ \\\nconst Type MathLimits<Type>::kStdError = \\\n  32 * (DBL_EPSILON * DBL_EPSILON > MathLimits<Type>::kEpsilon \\\n      ? DBL_EPSILON * DBL_EPSILON : MathLimits<Type>::kEpsilon); \\\nDEF_PRECISION_LIMITS(Type) \\\nconst Type MathLimits<Type>::kNaN = HUGE_VAL - HUGE_VAL; \\\nconst Type MathLimits<Type>::kPosInf = HUGE_VAL; \\\nconst Type MathLimits<Type>::kNegInf = -HUGE_VAL;\n\n// The following are *not* casts!\nDEF_SIGNED_INT_LIMITS(int8)\nDEF_SIGNED_INT_LIMITS(int16)  // NOLINT(readability/casting)\nDEF_SIGNED_INT_LIMITS(int32)  // NOLINT(readability/casting)\nDEF_SIGNED_INT_LIMITS(int64)  // NOLINT(readability/casting)\nDEF_UNSIGNED_INT_LIMITS(uint8)\nDEF_UNSIGNED_INT_LIMITS(uint16)  // NOLINT(readability/casting)\nDEF_UNSIGNED_INT_LIMITS(uint32)  // NOLINT(readability/casting)\nDEF_UNSIGNED_INT_LIMITS(uint64)  // NOLINT(readability/casting)\n\nDEF_SIGNED_INT_LIMITS(long int)\nDEF_UNSIGNED_INT_LIMITS(unsigned long int)\n\nDEF_FP_LIMITS(float, FLT)\nDEF_FP_LIMITS(double, DBL)\nDEF_FP_LIMITS(long double, LDBL);\n\n#undef DEF_COMMON_LIMITS\n#undef DEF_SIGNED_INT_LIMITS\n#undef DEF_UNSIGNED_INT_LIMITS\n#undef DEF_FP_LIMITS\n#undef DEF_PRECISION_LIMITS\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/mathlimits.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// All Rights Reserved.\n//\n// Author: Maxim Lifantsev\n//\n// Useful integer and floating point limits and type traits.\n//\n// This partially replaces/duplictes numeric_limits<> from <limits>.\n// We get a Google-style class that we have a greater control over\n// and thus can add new features to it or fix whatever happens to be broken in\n// numeric_limits for the compilers we use.\n//\n\n#ifndef UTIL_MATH_MATHLIMITS_H__\n#define UTIL_MATH_MATHLIMITS_H__\n\n// <math.h> lacks a lot of prototypes. However, this file needs <math.h> to\n// access old-fashioned isinf et al. Even worse more: this file must not\n// include <cmath> because that breaks the definition of isinf with gcc 4.9.\n//\n// TODO(mec): after C++11 everywhere, use <cmath> and std::isinf in this file.\n#include <math.h>\n#include <string.h>\n\n#include <cfloat>\n\n#include <google/protobuf/stubs/common.h>\n\n// ========================================================================= //\n\n// Useful integer and floating point limits and type traits.\n// This is just for the documentation;\n// real members are defined in our specializations below.\nnamespace google {\nnamespace protobuf {\ntemplate<typename T> struct MathLimits {\n  // Type name.\n  typedef T Type;\n  // Unsigned version of the Type with the same byte size.\n  // Same as Type for floating point and unsigned types.\n  typedef T UnsignedType;\n  // If the type supports negative values.\n  static const bool kIsSigned;\n  // If the type supports only integer values.\n  static const bool kIsInteger;\n  // Magnitude-wise smallest representable positive value.\n  static const Type kPosMin;\n  // Magnitude-wise largest representable positive value.\n  static const Type kPosMax;\n  // Smallest representable value.\n  static const Type kMin;\n  // Largest representable value.\n  static const Type kMax;\n  // Magnitude-wise smallest representable negative value.\n  // Present only if kIsSigned.\n  static const Type kNegMin;\n  // Magnitude-wise largest representable negative value.\n  // Present only if kIsSigned.\n  static const Type kNegMax;\n  // Smallest integer x such that 10^x is representable.\n  static const int kMin10Exp;\n  // Largest integer x such that 10^x is representable.\n  static const int kMax10Exp;\n  // Smallest positive value such that Type(1) + kEpsilon != Type(1)\n  static const Type kEpsilon;\n  // Typical rounding error that is enough to cover\n  // a few simple floating-point operations.\n  // Slightly larger than kEpsilon to account for a few rounding errors.\n  // Is zero if kIsInteger.\n  static const Type kStdError;\n  // Number of decimal digits of mantissa precision.\n  // Present only if !kIsInteger.\n  static const int kPrecisionDigits;\n  // Not a number, i.e. result of 0/0.\n  // Present only if !kIsInteger.\n  static const Type kNaN;\n  // Positive infinity, i.e. result of 1/0.\n  // Present only if !kIsInteger.\n  static const Type kPosInf;\n  // Negative infinity, i.e. result of -1/0.\n  // Present only if !kIsInteger.\n  static const Type kNegInf;\n\n  // NOTE: Special floating point values behave\n  // in a special (but mathematically-logical) way\n  // in terms of (in)equalty comparison and mathematical operations\n  // -- see out unittest for examples.\n\n  // Special floating point value testers.\n  // Present in integer types for convenience.\n  static bool IsFinite(const Type x);\n  static bool IsNaN(const Type x);\n  static bool IsInf(const Type x);\n  static bool IsPosInf(const Type x);\n  static bool IsNegInf(const Type x);\n};\n\n// ========================================================================= //\n\n// All #define-s below are simply to refactor the declarations of\n// MathLimits template specializations.\n// They are all #undef-ined below.\n\n// The hoop-jumping in *_INT_(MAX|MIN) below is so that the compiler does not\n// get an overflow while computing the constants.\n\n#define SIGNED_INT_MAX(Type) \\\n  (((Type(1) << (sizeof(Type)*8 - 2)) - 1) + (Type(1) << (sizeof(Type)*8 - 2)))\n\n#define SIGNED_INT_MIN(Type) \\\n  (-(Type(1) << (sizeof(Type)*8 - 2)) - (Type(1) << (sizeof(Type)*8 - 2)))\n\n#define UNSIGNED_INT_MAX(Type) \\\n  (((Type(1) << (sizeof(Type)*8 - 1)) - 1) + (Type(1) << (sizeof(Type)*8 - 1)))\n\n// Compile-time selected log10-related constants for integer types.\n#define SIGNED_MAX_10_EXP(Type) \\\n  (sizeof(Type) == 1 ? 2 : ( \\\n    sizeof(Type) == 2 ? 4 : ( \\\n      sizeof(Type) == 4 ? 9 : ( \\\n        sizeof(Type) == 8 ? 18 : -1))))\n\n#define UNSIGNED_MAX_10_EXP(Type) \\\n  (sizeof(Type) == 1 ? 2 : ( \\\n    sizeof(Type) == 2 ? 4 : ( \\\n      sizeof(Type) == 4 ? 9 : ( \\\n        sizeof(Type) == 8 ? 19 : -1))))\n\n#define DECL_INT_LIMIT_FUNCS \\\n  static bool IsFinite(const Type /*x*/) { return true; } \\\n  static bool IsNaN(const Type /*x*/) { return false; } \\\n  static bool IsInf(const Type /*x*/) { return false; } \\\n  static bool IsPosInf(const Type /*x*/) { return false; } \\\n  static bool IsNegInf(const Type /*x*/) { return false; }\n\n#define DECL_SIGNED_INT_LIMITS(IntType, UnsignedIntType) \\\ntemplate<> \\\nstruct LIBPROTOBUF_EXPORT MathLimits<IntType> { \\\n  typedef IntType Type; \\\n  typedef UnsignedIntType UnsignedType; \\\n  static const bool kIsSigned = true; \\\n  static const bool kIsInteger = true; \\\n  static const Type kPosMin = 1; \\\n  static const Type kPosMax = SIGNED_INT_MAX(Type); \\\n  static const Type kMin = SIGNED_INT_MIN(Type); \\\n  static const Type kMax = kPosMax; \\\n  static const Type kNegMin = -1; \\\n  static const Type kNegMax = kMin; \\\n  static const int kMin10Exp = 0; \\\n  static const int kMax10Exp = SIGNED_MAX_10_EXP(Type); \\\n  static const Type kEpsilon = 1; \\\n  static const Type kStdError = 0; \\\n  DECL_INT_LIMIT_FUNCS \\\n};\n\n#define DECL_UNSIGNED_INT_LIMITS(IntType) \\\ntemplate<> \\\nstruct LIBPROTOBUF_EXPORT MathLimits<IntType> { \\\n  typedef IntType Type; \\\n  typedef IntType UnsignedType; \\\n  static const bool kIsSigned = false; \\\n  static const bool kIsInteger = true; \\\n  static const Type kPosMin = 1; \\\n  static const Type kPosMax = UNSIGNED_INT_MAX(Type); \\\n  static const Type kMin = 0; \\\n  static const Type kMax = kPosMax; \\\n  static const int kMin10Exp = 0; \\\n  static const int kMax10Exp = UNSIGNED_MAX_10_EXP(Type); \\\n  static const Type kEpsilon = 1; \\\n  static const Type kStdError = 0; \\\n  DECL_INT_LIMIT_FUNCS \\\n};\n\nDECL_SIGNED_INT_LIMITS(signed char, unsigned char)\nDECL_SIGNED_INT_LIMITS(signed short int, unsigned short int)\nDECL_SIGNED_INT_LIMITS(signed int, unsigned int)\nDECL_SIGNED_INT_LIMITS(signed long int, unsigned long int)\nDECL_SIGNED_INT_LIMITS(signed long long int, unsigned long long int)\nDECL_UNSIGNED_INT_LIMITS(unsigned char)\nDECL_UNSIGNED_INT_LIMITS(unsigned short int)\nDECL_UNSIGNED_INT_LIMITS(unsigned int)\nDECL_UNSIGNED_INT_LIMITS(unsigned long int)\nDECL_UNSIGNED_INT_LIMITS(unsigned long long int)\n\n#undef DECL_SIGNED_INT_LIMITS\n#undef DECL_UNSIGNED_INT_LIMITS\n#undef SIGNED_INT_MAX\n#undef SIGNED_INT_MIN\n#undef UNSIGNED_INT_MAX\n#undef SIGNED_MAX_10_EXP\n#undef UNSIGNED_MAX_10_EXP\n#undef DECL_INT_LIMIT_FUNCS\n\n// ========================================================================= //\n#ifdef WIN32  // Lacks built-in isnan() and isinf()\n#define DECL_FP_LIMIT_FUNCS \\\n  static bool IsFinite(const Type x) { return _finite(x); } \\\n  static bool IsNaN(const Type x) { return _isnan(x); } \\\n  static bool IsInf(const Type x) { return (_fpclass(x) & (_FPCLASS_NINF | _FPCLASS_PINF)) != 0; } \\\n  static bool IsPosInf(const Type x) { return _fpclass(x) == _FPCLASS_PINF; } \\\n  static bool IsNegInf(const Type x) { return _fpclass(x) == _FPCLASS_NINF; }\n#else\n#define DECL_FP_LIMIT_FUNCS \\\n  static bool IsFinite(const Type x) { return !isinf(x) && !isnan(x); } \\\n  static bool IsNaN(const Type x) { return isnan(x); } \\\n  static bool IsInf(const Type x) { return isinf(x); } \\\n  static bool IsPosInf(const Type x) { return isinf(x) && x > 0; } \\\n  static bool IsNegInf(const Type x) { return isinf(x) && x < 0; }\n#endif\n\n// We can't put floating-point constant values in the header here because\n// such constants are not considered to be primitive-type constants by gcc.\n// CAVEAT: Hence, they are going to be initialized only during\n// the global objects construction time.\n#define DECL_FP_LIMITS(FP_Type, PREFIX) \\\ntemplate<> \\\nstruct LIBPROTOBUF_EXPORT MathLimits<FP_Type> { \\\n  typedef FP_Type Type; \\\n  typedef FP_Type UnsignedType; \\\n  static const bool kIsSigned = true; \\\n  static const bool kIsInteger = false; \\\n  static const Type kPosMin; \\\n  static const Type kPosMax; \\\n  static const Type kMin; \\\n  static const Type kMax; \\\n  static const Type kNegMin; \\\n  static const Type kNegMax; \\\n  static const int kMin10Exp = PREFIX##_MIN_10_EXP; \\\n  static const int kMax10Exp = PREFIX##_MAX_10_EXP; \\\n  static const Type kEpsilon; \\\n  static const Type kStdError; \\\n  static const int kPrecisionDigits = PREFIX##_DIG; \\\n  static const Type kNaN; \\\n  static const Type kPosInf; \\\n  static const Type kNegInf; \\\n  DECL_FP_LIMIT_FUNCS \\\n};\n\nDECL_FP_LIMITS(float, FLT)\nDECL_FP_LIMITS(double, DBL)\nDECL_FP_LIMITS(long double, LDBL)\n\n#undef DECL_FP_LIMITS\n#undef DECL_FP_LIMIT_FUNCS\n\n// ========================================================================= //\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // UTIL_MATH_MATHLIMITS_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/mathutil.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n#ifndef GOOGLE_PROTOBUF_STUBS_MATHUTIL_H_\n#define GOOGLE_PROTOBUF_STUBS_MATHUTIL_H_\n\n#include <float.h>\n#include <math.h>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/mathlimits.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\ntemplate<typename T>\nbool IsNan(T value) {\n  return false;\n}\ntemplate<>\ninline bool IsNan(float value) {\n#ifdef _MSC_VER\n  return _isnan(value);\n#else\n  return isnan(value);\n#endif\n}\ntemplate<>\ninline bool IsNan(double value) {\n#ifdef _MSC_VER\n  return _isnan(value);\n#else\n  return isnan(value);\n#endif\n}\n\ntemplate<typename T>\nbool AlmostEquals(T a, T b) {\n  return a == b;\n}\ntemplate<>\ninline bool AlmostEquals(float a, float b) {\n  return fabs(a - b) < 32 * FLT_EPSILON;\n}\n\ntemplate<>\ninline bool AlmostEquals(double a, double b) {\n  return fabs(a - b) < 32 * DBL_EPSILON;\n}\n}  // namespace internal\n\nclass MathUtil {\n public:\n  template<typename T>\n  static T Sign(T value) {\n    if (value == T(0) || ::google::protobuf::internal::IsNan<T>(value)) {\n      return value;\n    }\n    return value > T(0) ? 1 : -1;\n  }\n\n  template<typename T>\n  static bool AlmostEquals(T a, T b) {\n    return ::google::protobuf::internal::AlmostEquals(a, b);\n  }\n\n  // Largest of two values.\n  // Works correctly for special floating point values.\n  // Note: 0.0 and -0.0 are not differentiated by Max (Max(0.0, -0.0) is -0.0),\n  // which should be OK because, although they (can) have different\n  // bit representation, they are observably the same when examined\n  // with arithmetic and (in)equality operators.\n  template<typename T>\n  static T Max(const T x, const T y) {\n    return MathLimits<T>::IsNaN(x) || x > y ? x : y;\n  }\n\n  // Absolute value of x\n  // Works correctly for unsigned types and\n  // for special floating point values.\n  // Note: 0.0 and -0.0 are not differentiated by Abs (Abs(0.0) is -0.0),\n  // which should be OK: see the comment for Max above.\n  template<typename T>\n  static T Abs(const T x) {\n    return x > T(0) ? x : -x;\n  }\n\n  // Absolute value of the difference between two numbers.\n  // Works correctly for signed types and special floating point values.\n  template<typename T>\n  static typename MathLimits<T>::UnsignedType AbsDiff(const T x, const T y) {\n    // Carries out arithmetic as unsigned to avoid overflow.\n    typedef typename MathLimits<T>::UnsignedType R;\n    return x > y ? R(x) - R(y) : R(y) - R(x);\n  }\n\n  // If two (usually floating point) numbers are within a certain\n  // fraction of their magnitude or within a certain absolute margin of error.\n  // This is the same as the following but faster:\n  //   WithinFraction(x, y, fraction)  ||  WithinMargin(x, y, margin)\n  // E.g. WithinFraction(0.0, 1e-10, 1e-5) is false but\n  //      WithinFractionOrMargin(0.0, 1e-10, 1e-5, 1e-5) is true.\n  template<typename T>\n  static bool WithinFractionOrMargin(const T x, const T y,\n                                     const T fraction, const T margin);\n};\n\ntemplate<typename T>\nbool MathUtil::WithinFractionOrMargin(const T x, const T y,\n                                      const T fraction, const T margin) {\n  // Not just \"0 <= fraction\" to fool the compiler for unsigned types.\n  GOOGLE_DCHECK((T(0) < fraction || T(0) == fraction) &&\n         fraction < T(1) &&\n         margin >= T(0));\n\n  // Template specialization will convert the if() condition to a constant,\n  // which will cause the compiler to generate code for either the \"if\" part\n  // or the \"then\" part.  In this way we avoid a compiler warning\n  // about a potential integer overflow in crosstool v12 (gcc 4.3.1).\n  if (MathLimits<T>::kIsInteger) {\n    return x == y;\n  } else {\n    // IsFinite checks are to make kPosInf and kNegInf not within fraction\n    if (!MathLimits<T>::IsFinite(x) && !MathLimits<T>::IsFinite(y)) {\n      return false;\n    }\n    T relative_margin = static_cast<T>(fraction * Max(Abs(x), Abs(y)));\n    return AbsDiff(x, y) <= Max(margin, relative_margin);\n  }\n}\n\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_STUBS_MATHUTIL_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/mutex.h",
    "content": "// Copyright (c) 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_STUBS_MUTEX_H_\n#define GOOGLE_PROTOBUF_STUBS_MUTEX_H_\n\n#ifdef GOOGLE_PROTOBUF_NO_THREADLOCAL\n#include <pthread.h>\n#endif\n\n#include <google/protobuf/stubs/macros.h>\n\n// ===================================================================\n// emulates google3/base/mutex.h\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\n// A Mutex is a non-reentrant (aka non-recursive) mutex.  At most one thread T\n// may hold a mutex at a given time.  If T attempts to Lock() the same Mutex\n// while holding it, T will deadlock.\nclass LIBPROTOBUF_EXPORT Mutex {\n public:\n  // Create a Mutex that is not held by anybody.\n  Mutex();\n\n  // Destructor\n  ~Mutex();\n\n  // Block if necessary until this Mutex is free, then acquire it exclusively.\n  void Lock();\n\n  // Release this Mutex.  Caller must hold it exclusively.\n  void Unlock();\n\n  // Crash if this Mutex is not held exclusively by this thread.\n  // May fail to crash when it should; will never crash when it should not.\n  void AssertHeld();\n\n private:\n  struct Internal;\n  Internal* mInternal;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Mutex);\n};\n\n// Undefine the macros  to workaround the conflicts with Google internal\n// MutexLock implementation.\n// TODO(liujisi): Remove the undef once internal macros are removed.\n#undef MutexLock\n#undef ReaderMutexLock\n#undef WriterMutexLock\n#undef MutexLockMaybe\n\n// MutexLock(mu) acquires mu when constructed and releases it when destroyed.\nclass LIBPROTOBUF_EXPORT MutexLock {\n public:\n  explicit MutexLock(Mutex *mu) : mu_(mu) { this->mu_->Lock(); }\n  ~MutexLock() { this->mu_->Unlock(); }\n private:\n  Mutex *const mu_;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MutexLock);\n};\n\n// TODO(kenton):  Implement these?  Hard to implement portably.\ntypedef MutexLock ReaderMutexLock;\ntypedef MutexLock WriterMutexLock;\n\n// MutexLockMaybe is like MutexLock, but is a no-op when mu is NULL.\nclass LIBPROTOBUF_EXPORT MutexLockMaybe {\n public:\n  explicit MutexLockMaybe(Mutex *mu) :\n    mu_(mu) { if (this->mu_ != NULL) { this->mu_->Lock(); } }\n  ~MutexLockMaybe() { if (this->mu_ != NULL) { this->mu_->Unlock(); } }\n private:\n  Mutex *const mu_;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MutexLockMaybe);\n};\n\n#if defined(GOOGLE_PROTOBUF_NO_THREADLOCAL)\ntemplate<typename T>\nclass ThreadLocalStorage {\n public:\n  ThreadLocalStorage() {\n    pthread_key_create(&key_, &ThreadLocalStorage::Delete);\n  }\n  ~ThreadLocalStorage() {\n    pthread_key_delete(key_);\n  }\n  T* Get() {\n    T* result = static_cast<T*>(pthread_getspecific(key_));\n    if (result == NULL) {\n      result = new T();\n      pthread_setspecific(key_, result);\n    }\n    return result;\n  }\n private:\n  static void Delete(void* value) {\n    delete static_cast<T*>(value);\n  }\n  pthread_key_t key_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ThreadLocalStorage);\n};\n#endif\n\n}  // namespace internal\n\n// We made these internal so that they would show up as such in the docs,\n// but we don't want to stick \"internal::\" in front of them everywhere.\nusing internal::Mutex;\nusing internal::MutexLock;\nusing internal::ReaderMutexLock;\nusing internal::WriterMutexLock;\nusing internal::MutexLockMaybe;\n\n\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_STUBS_MUTEX_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/once.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//\n// emulates google3/base/once.h\n//\n// This header is intended to be included only by internal .cc files and\n// generated .pb.cc files.  Users should not use this directly.\n\n#include <google/protobuf/stubs/once.h>\n\n#ifndef GOOGLE_PROTOBUF_NO_THREAD_SAFETY\n\n#ifdef _WIN32\n#include <windows.h>\n#else\n#include <sched.h>\n#endif\n\n#include <google/protobuf/stubs/atomicops.h>\n\nnamespace google {\nnamespace protobuf {\n\nnamespace {\n\nvoid SchedYield() {\n#ifdef _WIN32\n  Sleep(0);\n#else  // POSIX\n  sched_yield();\n#endif\n}\n\n}  // namespace\n\nvoid GoogleOnceInitImpl(ProtobufOnceType* once, Closure* closure) {\n  internal::AtomicWord state = internal::Acquire_Load(once);\n  // Fast path. The provided closure was already executed.\n  if (state == ONCE_STATE_DONE) {\n    return;\n  }\n  // The closure execution did not complete yet. The once object can be in one\n  // of the two following states:\n  //   - UNINITIALIZED: We are the first thread calling this function.\n  //   - EXECUTING_CLOSURE: Another thread is already executing the closure.\n  //\n  // First, try to change the state from UNINITIALIZED to EXECUTING_CLOSURE\n  // atomically.\n  state = internal::Acquire_CompareAndSwap(\n      once, ONCE_STATE_UNINITIALIZED, ONCE_STATE_EXECUTING_CLOSURE);\n  if (state == ONCE_STATE_UNINITIALIZED) {\n    // We are the first thread to call this function, so we have to call the\n    // closure.\n    closure->Run();\n    internal::Release_Store(once, ONCE_STATE_DONE);\n  } else {\n    // Another thread has already started executing the closure. We need to\n    // wait until it completes the initialization.\n    while (state == ONCE_STATE_EXECUTING_CLOSURE) {\n      // Note that futex() could be used here on Linux as an improvement.\n      SchedYield();\n      state = internal::Acquire_Load(once);\n    }\n  }\n}\n\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_NO_THREAD_SAFETY\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/once.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//\n// emulates google3/base/once.h\n//\n// This header is intended to be included only by internal .cc files and\n// generated .pb.cc files.  Users should not use this directly.\n//\n// This is basically a portable version of pthread_once().\n//\n// This header declares:\n// * A type called ProtobufOnceType.\n// * A macro GOOGLE_PROTOBUF_DECLARE_ONCE() which declares a variable of type\n//   ProtobufOnceType.  This is the only legal way to declare such a variable.\n//   The macro may only be used at the global scope (you cannot create local or\n//   class member variables of this type).\n// * A function GoogleOnceInit(ProtobufOnceType* once, void (*init_func)()).\n//   This function, when invoked multiple times given the same ProtobufOnceType\n//   object, will invoke init_func on the first call only, and will make sure\n//   none of the calls return before that first call to init_func has finished.\n// * The user can provide a parameter which GoogleOnceInit() forwards to the\n//   user-provided function when it is called. Usage example:\n//     int a = 10;\n//     GoogleOnceInit(&my_once, &MyFunctionExpectingIntArgument, &a);\n// * This implementation guarantees that ProtobufOnceType is a POD (i.e. no\n//   static initializer generated).\n//\n// This implements a way to perform lazy initialization.  It's more efficient\n// than using mutexes as no lock is needed if initialization has already\n// happened.\n//\n// Example usage:\n//   void Init();\n//   GOOGLE_PROTOBUF_DECLARE_ONCE(once_init);\n//\n//   // Calls Init() exactly once.\n//   void InitOnce() {\n//     GoogleOnceInit(&once_init, &Init);\n//   }\n//\n// Note that if GoogleOnceInit() is called before main() has begun, it must\n// only be called by the thread that will eventually call main() -- that is,\n// the thread that performs dynamic initialization.  In general this is a safe\n// assumption since people don't usually construct threads before main() starts,\n// but it is technically not guaranteed.  Unfortunately, Win32 provides no way\n// whatsoever to statically-initialize its synchronization primitives, so our\n// only choice is to assume that dynamic initialization is single-threaded.\n\n#ifndef GOOGLE_PROTOBUF_STUBS_ONCE_H__\n#define GOOGLE_PROTOBUF_STUBS_ONCE_H__\n\n#include <google/protobuf/stubs/atomicops.h>\n#include <google/protobuf/stubs/callback.h>\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\n\n#ifdef GOOGLE_PROTOBUF_NO_THREAD_SAFETY\n\ntypedef bool ProtobufOnceType;\n\n#define GOOGLE_PROTOBUF_ONCE_INIT false\n\ninline void GoogleOnceInit(ProtobufOnceType* once, void (*init_func)()) {\n  if (!*once) {\n    *once = true;\n    init_func();\n  }\n}\n\ntemplate <typename Arg>\ninline void GoogleOnceInit(ProtobufOnceType* once, void (*init_func)(Arg),\n    Arg arg) {\n  if (!*once) {\n    *once = true;\n    init_func(arg);\n  }\n}\n\n#else\n\nenum {\n  ONCE_STATE_UNINITIALIZED = 0,\n  ONCE_STATE_EXECUTING_CLOSURE = 1,\n  ONCE_STATE_DONE = 2\n};\n\ntypedef internal::AtomicWord ProtobufOnceType;\n\n#define GOOGLE_PROTOBUF_ONCE_INIT ::google::protobuf::ONCE_STATE_UNINITIALIZED\n\nLIBPROTOBUF_EXPORT\nvoid GoogleOnceInitImpl(ProtobufOnceType* once, Closure* closure);\n\ninline void GoogleOnceInit(ProtobufOnceType* once, void (*init_func)()) {\n  if (internal::Acquire_Load(once) != ONCE_STATE_DONE) {\n    internal::FunctionClosure0 func(init_func, false);\n    GoogleOnceInitImpl(once, &func);\n  }\n}\n\ntemplate <typename Arg>\ninline void GoogleOnceInit(ProtobufOnceType* once, void (*init_func)(Arg*),\n    Arg* arg) {\n  if (internal::Acquire_Load(once) != ONCE_STATE_DONE) {\n    internal::FunctionClosure1<Arg*> func(init_func, false, arg);\n    GoogleOnceInitImpl(once, &func);\n  }\n}\n\n#endif  // GOOGLE_PROTOBUF_NO_THREAD_SAFETY\n\nclass GoogleOnceDynamic {\n public:\n  GoogleOnceDynamic() : state_(GOOGLE_PROTOBUF_ONCE_INIT) { }\n\n  // If this->Init() has not been called before by any thread,\n  // execute (*func_with_arg)(arg) then return.\n  // Otherwise, wait until that prior invocation has finished\n  // executing its function, then return.\n  template<typename T>\n  void Init(void (*func_with_arg)(T*), T* arg) {\n    GoogleOnceInit<T>(&this->state_,\n                      func_with_arg,\n                      arg);\n  }\n private:\n  ProtobufOnceType state_;\n};\n\n#define GOOGLE_PROTOBUF_DECLARE_ONCE(NAME) \\\n  ::google::protobuf::ProtobufOnceType NAME = GOOGLE_PROTOBUF_ONCE_INIT\n\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_STUBS_ONCE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/once_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n\n#ifdef _WIN32\n#include <windows.h>\n#else\n#include <unistd.h>\n#include <pthread.h>\n#endif\n\n#include <google/protobuf/stubs/once.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nusing internal::NewCallback;\nnamespace {\n\nclass OnceInitTest : public testing::Test {\n protected:\n  void SetUp() {\n    state_ = INIT_NOT_STARTED;\n    current_test_ = this;\n  }\n\n  // Since ProtobufOnceType is only allowed to be allocated in static storage,\n  // each test must use a different pair of ProtobufOnceType objects which it\n  // must declare itself.\n  void SetOnces(ProtobufOnceType* once, ProtobufOnceType* recursive_once) {\n    once_ = once;\n    recursive_once_ = recursive_once;\n  }\n\n  void InitOnce() {\n    GoogleOnceInit(once_, &InitStatic);\n  }\n  void InitRecursiveOnce() {\n    GoogleOnceInit(recursive_once_, &InitRecursiveStatic);\n  }\n\n  void BlockInit() { init_blocker_.Lock(); }\n  void UnblockInit() { init_blocker_.Unlock(); }\n\n  class TestThread {\n   public:\n    TestThread(Closure* callback)\n        : done_(false), joined_(false), callback_(callback) {\n#ifdef _WIN32\n      thread_ = CreateThread(NULL, 0, &Start, this, 0, NULL);\n#else\n      pthread_create(&thread_, NULL, &Start, this);\n#endif\n    }\n    ~TestThread() {\n      if (!joined_) Join();\n    }\n\n    bool IsDone() {\n      MutexLock lock(&done_mutex_);\n      return done_;\n    }\n    void Join() {\n      joined_ = true;\n#ifdef _WIN32\n      WaitForSingleObject(thread_, INFINITE);\n      CloseHandle(thread_);\n#else\n      pthread_join(thread_, NULL);\n#endif\n    }\n\n   private:\n#ifdef _WIN32\n    HANDLE thread_;\n#else\n    pthread_t thread_;\n#endif\n\n    Mutex done_mutex_;\n    bool done_;\n    bool joined_;\n    Closure* callback_;\n\n#ifdef _WIN32\n    static DWORD WINAPI Start(LPVOID arg) {\n#else\n    static void* Start(void* arg) {\n#endif\n      reinterpret_cast<TestThread*>(arg)->Run();\n      return 0;\n    }\n\n    void Run() {\n      callback_->Run();\n      MutexLock lock(&done_mutex_);\n      done_ = true;\n    }\n  };\n\n  TestThread* RunInitOnceInNewThread() {\n    return new TestThread(internal::NewCallback(this, &OnceInitTest::InitOnce));\n  }\n  TestThread* RunInitRecursiveOnceInNewThread() {\n    return new TestThread(\n        internal::NewCallback(this, &OnceInitTest::InitRecursiveOnce));\n  }\n\n  enum State {\n    INIT_NOT_STARTED,\n    INIT_STARTED,\n    INIT_DONE\n  };\n  State CurrentState() {\n    MutexLock lock(&mutex_);\n    return state_;\n  }\n\n  void WaitABit() {\n#ifdef _WIN32\n    Sleep(1000);\n#else\n    sleep(1);\n#endif\n  }\n\n private:\n  Mutex mutex_;\n  Mutex init_blocker_;\n  State state_;\n  ProtobufOnceType* once_;\n  ProtobufOnceType* recursive_once_;\n\n  void Init() {\n    MutexLock lock(&mutex_);\n    EXPECT_EQ(INIT_NOT_STARTED, state_);\n    state_ = INIT_STARTED;\n    mutex_.Unlock();\n    init_blocker_.Lock();\n    init_blocker_.Unlock();\n    mutex_.Lock();\n    state_ = INIT_DONE;\n  }\n\n  static OnceInitTest* current_test_;\n  static void InitStatic() { current_test_->Init(); }\n  static void InitRecursiveStatic() { current_test_->InitOnce(); }\n};\n\nOnceInitTest* OnceInitTest::current_test_ = NULL;\n\nGOOGLE_PROTOBUF_DECLARE_ONCE(simple_once);\n\nTEST_F(OnceInitTest, Simple) {\n  SetOnces(&simple_once, NULL);\n\n  EXPECT_EQ(INIT_NOT_STARTED, CurrentState());\n  InitOnce();\n  EXPECT_EQ(INIT_DONE, CurrentState());\n\n  // Calling again has no effect.\n  InitOnce();\n  EXPECT_EQ(INIT_DONE, CurrentState());\n}\n\nGOOGLE_PROTOBUF_DECLARE_ONCE(recursive_once1);\nGOOGLE_PROTOBUF_DECLARE_ONCE(recursive_once2);\n\nTEST_F(OnceInitTest, Recursive) {\n  SetOnces(&recursive_once1, &recursive_once2);\n\n  EXPECT_EQ(INIT_NOT_STARTED, CurrentState());\n  InitRecursiveOnce();\n  EXPECT_EQ(INIT_DONE, CurrentState());\n}\n\nGOOGLE_PROTOBUF_DECLARE_ONCE(multiple_threads_once);\n\nTEST_F(OnceInitTest, MultipleThreads) {\n  SetOnces(&multiple_threads_once, NULL);\n\n  scoped_ptr<TestThread> threads[4];\n  EXPECT_EQ(INIT_NOT_STARTED, CurrentState());\n  for (int i = 0; i < 4; i++) {\n    threads[i].reset(RunInitOnceInNewThread());\n  }\n  for (int i = 0; i < 4; i++) {\n    threads[i]->Join();\n  }\n  EXPECT_EQ(INIT_DONE, CurrentState());\n}\n\nGOOGLE_PROTOBUF_DECLARE_ONCE(multiple_threads_blocked_once1);\nGOOGLE_PROTOBUF_DECLARE_ONCE(multiple_threads_blocked_once2);\n\nTEST_F(OnceInitTest, MultipleThreadsBlocked) {\n  SetOnces(&multiple_threads_blocked_once1, &multiple_threads_blocked_once2);\n\n  scoped_ptr<TestThread> threads[8];\n  EXPECT_EQ(INIT_NOT_STARTED, CurrentState());\n\n  BlockInit();\n  for (int i = 0; i < 4; i++) {\n    threads[i].reset(RunInitOnceInNewThread());\n  }\n  for (int i = 4; i < 8; i++) {\n    threads[i].reset(RunInitRecursiveOnceInNewThread());\n  }\n\n  WaitABit();\n\n  // We should now have one thread blocked inside Init(), four blocked waiting\n  // for Init() to complete, and three blocked waiting for InitRecursive() to\n  // complete.\n  EXPECT_EQ(INIT_STARTED, CurrentState());\n  UnblockInit();\n\n  for (int i = 0; i < 8; i++) {\n    threads[i]->Join();\n  }\n  EXPECT_EQ(INIT_DONE, CurrentState());\n}\n\n}  // anonymous namespace\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/platform_macros.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2012 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_PLATFORM_MACROS_H_\n#define GOOGLE_PROTOBUF_PLATFORM_MACROS_H_\n\n#define GOOGLE_PROTOBUF_PLATFORM_ERROR \\\n#error \"Host platform was not detected as supported by protobuf\"\n\n// Processor architecture detection.  For more info on what's defined, see:\n//   http://msdn.microsoft.com/en-us/library/b0084kay.aspx\n//   http://www.agner.org/optimize/calling_conventions.pdf\n//   or with gcc, run: \"echo | gcc -E -dM -\"\n#if defined(_M_X64) || defined(__x86_64__)\n#define GOOGLE_PROTOBUF_ARCH_X64 1\n#define GOOGLE_PROTOBUF_ARCH_64_BIT 1\n#elif defined(_M_IX86) || defined(__i386__)\n#define GOOGLE_PROTOBUF_ARCH_IA32 1\n#define GOOGLE_PROTOBUF_ARCH_32_BIT 1\n#elif defined(__QNX__)\n#define GOOGLE_PROTOBUF_ARCH_ARM_QNX 1\n#define GOOGLE_PROTOBUF_ARCH_32_BIT 1\n#elif defined(__ARMEL__)\n#define GOOGLE_PROTOBUF_ARCH_ARM 1\n#define GOOGLE_PROTOBUF_ARCH_32_BIT 1\n#elif defined(__aarch64__)\n#define GOOGLE_PROTOBUF_ARCH_AARCH64 1\n#define GOOGLE_PROTOBUF_ARCH_64_BIT 1\n#elif defined(__MIPSEL__)\n#if defined(__LP64__)\n#define GOOGLE_PROTOBUF_ARCH_MIPS64 1\n#define GOOGLE_PROTOBUF_ARCH_64_BIT 1\n#else\n#define GOOGLE_PROTOBUF_ARCH_MIPS 1\n#define GOOGLE_PROTOBUF_ARCH_32_BIT 1\n#endif\n#elif defined(__pnacl__)\n#define GOOGLE_PROTOBUF_ARCH_32_BIT 1\n#elif defined(sparc)\n#define GOOGLE_PROTOBUF_ARCH_SPARC 1\n#if defined(__sparc_v9__) || defined(__sparcv9) || defined(__arch64__)\n#define GOOGLE_PROTOBUF_ARCH_64_BIT 1\n#else\n#define GOOGLE_PROTOBUF_ARCH_32_BIT 1\n#endif\n#elif defined(_POWER) || defined(__powerpc64__) || defined(__PPC64__)\n#define GOOGLE_PROTOBUF_ARCH_POWER 1\n#define GOOGLE_PROTOBUF_ARCH_64_BIT 1\n#elif defined(__PPC__)\n#define GOOGLE_PROTOBUF_ARCH_PPC 1\n#define GOOGLE_PROTOBUF_ARCH_32_BIT 1\n#elif defined(__GNUC__)\n# if (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)) || (__GNUC__ > 4))\n// We fallback to the generic Clang/GCC >= 4.7 implementation in atomicops.h\n# elif defined(__clang__)\n#  if !__has_extension(c_atomic)\nGOOGLE_PROTOBUF_PLATFORM_ERROR\n#  endif\n// We fallback to the generic Clang/GCC >= 4.7 implementation in atomicops.h\n# endif\n# if __LP64__\n#  define GOOGLE_PROTOBUF_ARCH_64_BIT 1\n# else\n#  define GOOGLE_PROTOBUF_ARCH_32_BIT 1\n# endif\n#else\nGOOGLE_PROTOBUF_PLATFORM_ERROR\n#endif\n\n#if defined(__APPLE__)\n#define GOOGLE_PROTOBUF_OS_APPLE\n#include <TargetConditionals.h>\n#if TARGET_OS_IPHONE\n#define GOOGLE_PROTOBUF_OS_IPHONE\n#endif\n#elif defined(__EMSCRIPTEN__)\n#define GOOGLE_PROTOBUF_OS_EMSCRIPTEN\n#elif defined(__native_client__)\n#define GOOGLE_PROTOBUF_OS_NACL\n#elif defined(sun)\n#define GOOGLE_PROTOBUF_OS_SOLARIS\n#elif defined(_AIX)\n#define GOOGLE_PROTOBUF_OS_AIX\n#elif defined(__ANDROID__)\n#define GOOGLE_PROTOBUF_OS_ANDROID\n#endif\n\n#undef GOOGLE_PROTOBUF_PLATFORM_ERROR\n\n#if defined(GOOGLE_PROTOBUF_OS_ANDROID) || defined(GOOGLE_PROTOBUF_OS_IPHONE)\n// Android ndk does not support the __thread keyword very well yet. Here\n// we use pthread_key_create()/pthread_getspecific()/... methods for\n// TLS support on android.\n// iOS also does not support the __thread keyword.\n#define GOOGLE_PROTOBUF_NO_THREADLOCAL\n#endif\n\n#endif  // GOOGLE_PROTOBUF_PLATFORM_MACROS_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/port.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_STUBS_PORT_H_\n#define GOOGLE_PROTOBUF_STUBS_PORT_H_\n\n#include <assert.h>\n#include <stdlib.h>\n#include <cstddef>\n#include <string>\n#include <string.h>\n#if defined(__osf__)\n// Tru64 lacks stdint.h, but has inttypes.h which defines a superset of\n// what stdint.h would define.\n#include <inttypes.h>\n#elif !defined(_MSC_VER)\n#include <stdint.h>\n#endif\n\n#undef PROTOBUF_LITTLE_ENDIAN\n#ifdef _WIN32\n  // Assuming windows is always little-endian.\n  // TODO(xiaofeng): The PROTOBUF_LITTLE_ENDIAN is not only used for\n  // optimization but also for correctness. We should define an\n  // different macro to test the big-endian code path in coded_stream.\n  #if !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)\n    #define PROTOBUF_LITTLE_ENDIAN 1\n  #endif\n  #if _MSC_VER >= 1300 && !defined(__INTEL_COMPILER)\n    // If MSVC has \"/RTCc\" set, it will complain about truncating casts at\n    // runtime.  This file contains some intentional truncating casts.\n    #pragma runtime_checks(\"c\", off)\n  #endif\n#else\n  #include <sys/param.h>   // __BYTE_ORDER\n  #if ((defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || \\\n         (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN)) && \\\n      !defined(PROTOBUF_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)\n    #define PROTOBUF_LITTLE_ENDIAN 1\n  #endif\n#endif\n#if defined(_MSC_VER) && defined(PROTOBUF_USE_DLLS)\n  #ifdef LIBPROTOBUF_EXPORTS\n    #define LIBPROTOBUF_EXPORT __declspec(dllexport)\n  #else\n    #define LIBPROTOBUF_EXPORT __declspec(dllimport)\n  #endif\n  #ifdef LIBPROTOC_EXPORTS\n    #define LIBPROTOC_EXPORT   __declspec(dllexport)\n  #else\n    #define LIBPROTOC_EXPORT   __declspec(dllimport)\n  #endif\n#else\n  #define LIBPROTOBUF_EXPORT\n  #define LIBPROTOC_EXPORT\n#endif\n\n// These #includes are for the byte swap functions declared later on.\n#ifdef _MSC_VER\n#include <stdlib.h>  // NOLINT(build/include)\n#elif defined(__APPLE__)\n#include <libkern/OSByteOrder.h>\n#elif defined(__GLIBC__) || defined(__CYGWIN__)\n#include <byteswap.h>  // IWYU pragma: export\n#endif\n\n// ===================================================================\n// from google3/base/port.h\nnamespace google {\nnamespace protobuf {\n\ntypedef unsigned int uint;\n\n#ifdef _MSC_VER\ntypedef signed __int8  int8;\ntypedef __int16 int16;\ntypedef __int32 int32;\ntypedef __int64 int64;\n\ntypedef unsigned __int8  uint8;\ntypedef unsigned __int16 uint16;\ntypedef unsigned __int32 uint32;\ntypedef unsigned __int64 uint64;\n#else\ntypedef int8_t int8;\ntypedef int16_t int16;\ntypedef int32_t int32;\ntypedef int64_t int64;\n\ntypedef uint8_t uint8;\ntypedef uint16_t uint16;\ntypedef uint32_t uint32;\ntypedef uint64_t uint64;\n#endif\n\n// long long macros to be used because gcc and vc++ use different suffixes,\n// and different size specifiers in format strings\n#undef GOOGLE_LONGLONG\n#undef GOOGLE_ULONGLONG\n#undef GOOGLE_LL_FORMAT\n\n#ifdef _MSC_VER\n#define GOOGLE_LONGLONG(x) x##I64\n#define GOOGLE_ULONGLONG(x) x##UI64\n#define GOOGLE_LL_FORMAT \"I64\"  // As in printf(\"%I64d\", ...)\n#else\n// By long long, we actually mean int64.\n#define GOOGLE_LONGLONG(x) x##LL\n#define GOOGLE_ULONGLONG(x) x##ULL\n// Used to format real long long integers.\n#define GOOGLE_LL_FORMAT \"ll\"  // As in \"%lld\". Note that \"q\" is poor form also.\n#endif\n\nstatic const int32 kint32max = 0x7FFFFFFF;\nstatic const int32 kint32min = -kint32max - 1;\nstatic const int64 kint64max = GOOGLE_LONGLONG(0x7FFFFFFFFFFFFFFF);\nstatic const int64 kint64min = -kint64max - 1;\nstatic const uint32 kuint32max = 0xFFFFFFFFu;\nstatic const uint64 kuint64max = GOOGLE_ULONGLONG(0xFFFFFFFFFFFFFFFF);\n\n// -------------------------------------------------------------------\n// Annotations:  Some parts of the code have been annotated in ways that might\n//   be useful to some compilers or tools, but are not supported universally.\n//   You can #define these annotations yourself if the default implementation\n//   is not right for you.\n\n#ifndef GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n#if defined(__GNUC__) && (__GNUC__ > 3 ||(__GNUC__ == 3 && __GNUC_MINOR__ >= 1))\n// For functions we want to force inline.\n// Introduced in gcc 3.1.\n#define GOOGLE_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((always_inline))\n#else\n// Other compilers will have to figure it out for themselves.\n#define GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n#endif\n#endif\n\n#ifndef GOOGLE_ATTRIBUTE_NOINLINE\n#if defined(__GNUC__) && (__GNUC__ > 3 ||(__GNUC__ == 3 && __GNUC_MINOR__ >= 1))\n// For functions we want to force not inline.\n// Introduced in gcc 3.1.\n#define GOOGLE_ATTRIBUTE_NOINLINE __attribute__ ((noinline))\n#elif defined(_MSC_VER) && (_MSC_VER >= 1400)\n// Seems to have been around since at least Visual Studio 2005\n#define GOOGLE_ATTRIBUTE_NOINLINE __declspec(noinline)\n#else\n// Other compilers will have to figure it out for themselves.\n#define GOOGLE_ATTRIBUTE_NOINLINE\n#endif\n#endif\n\n#ifndef GOOGLE_ATTRIBUTE_NORETURN\n#ifdef __GNUC__\n// Tell the compiler that a given function never returns.\n#define GOOGLE_ATTRIBUTE_NORETURN __attribute__((noreturn))\n#else\n#define GOOGLE_ATTRIBUTE_NORETURN\n#endif\n#endif\n\n#ifndef GOOGLE_ATTRIBUTE_DEPRECATED\n#ifdef __GNUC__\n// If the method/variable/type is used anywhere, produce a warning.\n#define GOOGLE_ATTRIBUTE_DEPRECATED __attribute__((deprecated))\n#else\n#define GOOGLE_ATTRIBUTE_DEPRECATED\n#endif\n#endif\n\n#ifndef GOOGLE_PREDICT_TRUE\n#ifdef __GNUC__\n// Provided at least since GCC 3.0.\n#define GOOGLE_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))\n#else\n#define GOOGLE_PREDICT_TRUE(x) (x)\n#endif\n#endif\n\n#ifndef GOOGLE_PREDICT_FALSE\n#ifdef __GNUC__\n// Provided at least since GCC 3.0.\n#define GOOGLE_PREDICT_FALSE(x) (__builtin_expect(x, 0))\n#else\n#define GOOGLE_PREDICT_FALSE(x) (x)\n#endif\n#endif\n\n// Delimits a block of code which may write to memory which is simultaneously\n// written by other threads, but which has been determined to be thread-safe\n// (e.g. because it is an idempotent write).\n#ifndef GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN\n#define GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN()\n#endif\n#ifndef GOOGLE_SAFE_CONCURRENT_WRITES_END\n#define GOOGLE_SAFE_CONCURRENT_WRITES_END()\n#endif\n\n#if defined(__clang__) && defined(__has_cpp_attribute) \\\n    && !defined(GOOGLE_PROTOBUF_OS_APPLE)\n# if defined(GOOGLE_PROTOBUF_OS_NACL) || defined(EMSCRIPTEN) || \\\n     __has_cpp_attribute(clang::fallthrough)\n#  define GOOGLE_FALLTHROUGH_INTENDED [[clang::fallthrough]]\n# endif\n#endif\n\n#ifndef GOOGLE_FALLTHROUGH_INTENDED\n# define GOOGLE_FALLTHROUGH_INTENDED\n#endif\n\n#define GOOGLE_GUARDED_BY(x)\n#define GOOGLE_ATTRIBUTE_COLD\n\n// x86 and x86-64 can perform unaligned loads/stores directly.\n#if defined(_M_X64) || defined(__x86_64__) || \\\n    defined(_M_IX86) || defined(__i386__)\n\n#define GOOGLE_UNALIGNED_LOAD16(_p) (*reinterpret_cast<const uint16 *>(_p))\n#define GOOGLE_UNALIGNED_LOAD32(_p) (*reinterpret_cast<const uint32 *>(_p))\n#define GOOGLE_UNALIGNED_LOAD64(_p) (*reinterpret_cast<const uint64 *>(_p))\n\n#define GOOGLE_UNALIGNED_STORE16(_p, _val) (*reinterpret_cast<uint16 *>(_p) = (_val))\n#define GOOGLE_UNALIGNED_STORE32(_p, _val) (*reinterpret_cast<uint32 *>(_p) = (_val))\n#define GOOGLE_UNALIGNED_STORE64(_p, _val) (*reinterpret_cast<uint64 *>(_p) = (_val))\n\n#else\ninline uint16 GOOGLE_UNALIGNED_LOAD16(const void *p) {\n  uint16 t;\n  memcpy(&t, p, sizeof t);\n  return t;\n}\n\ninline uint32 GOOGLE_UNALIGNED_LOAD32(const void *p) {\n  uint32 t;\n  memcpy(&t, p, sizeof t);\n  return t;\n}\n\ninline uint64 GOOGLE_UNALIGNED_LOAD64(const void *p) {\n  uint64 t;\n  memcpy(&t, p, sizeof t);\n  return t;\n}\n\ninline void GOOGLE_UNALIGNED_STORE16(void *p, uint16 v) {\n  memcpy(p, &v, sizeof v);\n}\n\ninline void GOOGLE_UNALIGNED_STORE32(void *p, uint32 v) {\n  memcpy(p, &v, sizeof v);\n}\n\ninline void GOOGLE_UNALIGNED_STORE64(void *p, uint64 v) {\n  memcpy(p, &v, sizeof v);\n}\n#endif\n\n#if defined(_MSC_VER)\n#define GOOGLE_THREAD_LOCAL __declspec(thread)\n#else\n#define GOOGLE_THREAD_LOCAL __thread\n#endif\n\n// The following guarantees declaration of the byte swap functions.\n#ifdef _MSC_VER\n#define bswap_16(x) _byteswap_ushort(x)\n#define bswap_32(x) _byteswap_ulong(x)\n#define bswap_64(x) _byteswap_uint64(x)\n\n#elif defined(__APPLE__)\n// Mac OS X / Darwin features\n#define bswap_16(x) OSSwapInt16(x)\n#define bswap_32(x) OSSwapInt32(x)\n#define bswap_64(x) OSSwapInt64(x)\n\n#elif !defined(__GLIBC__) && !defined(__CYGWIN__)\n\nstatic inline uint16 bswap_16(uint16 x) {\n  return static_cast<uint16>(((x & 0xFF) << 8) | ((x & 0xFF00) >> 8));\n}\n#define bswap_16(x) bswap_16(x)\nstatic inline uint32 bswap_32(uint32 x) {\n  return (((x & 0xFF) << 24) |\n          ((x & 0xFF00) << 8) |\n          ((x & 0xFF0000) >> 8) |\n          ((x & 0xFF000000) >> 24));\n}\n#define bswap_32(x) bswap_32(x)\nstatic inline uint64 bswap_64(uint64 x) {\n  return (((x & GOOGLE_ULONGLONG(0xFF)) << 56) |\n          ((x & GOOGLE_ULONGLONG(0xFF00)) << 40) |\n          ((x & GOOGLE_ULONGLONG(0xFF0000)) << 24) |\n          ((x & GOOGLE_ULONGLONG(0xFF000000)) << 8) |\n          ((x & GOOGLE_ULONGLONG(0xFF00000000)) >> 8) |\n          ((x & GOOGLE_ULONGLONG(0xFF0000000000)) >> 24) |\n          ((x & GOOGLE_ULONGLONG(0xFF000000000000)) >> 40) |\n          ((x & GOOGLE_ULONGLONG(0xFF00000000000000)) >> 56));\n}\n#define bswap_64(x) bswap_64(x)\n\n#endif\n\n// ===================================================================\n// from google3/util/endian/endian.h\nLIBPROTOBUF_EXPORT uint32 ghtonl(uint32 x);\n\nclass BigEndian {\n public:\n#ifdef PROTOBUF_LITTLE_ENDIAN\n\n  static uint16 FromHost16(uint16 x) { return bswap_16(x); }\n  static uint16 ToHost16(uint16 x) { return bswap_16(x); }\n\n  static uint32 FromHost32(uint32 x) { return bswap_32(x); }\n  static uint32 ToHost32(uint32 x) { return bswap_32(x); }\n\n  static uint64 FromHost64(uint64 x) { return bswap_64(x); }\n  static uint64 ToHost64(uint64 x) { return bswap_64(x); }\n\n  static bool IsLittleEndian() { return true; }\n\n#else\n\n  static uint16 FromHost16(uint16 x) { return x; }\n  static uint16 ToHost16(uint16 x) { return x; }\n\n  static uint32 FromHost32(uint32 x) { return x; }\n  static uint32 ToHost32(uint32 x) { return x; }\n\n  static uint64 FromHost64(uint64 x) { return x; }\n  static uint64 ToHost64(uint64 x) { return x; }\n\n  static bool IsLittleEndian() { return false; }\n\n#endif /* ENDIAN */\n\n  // Functions to do unaligned loads and stores in big-endian order.\n  static uint16 Load16(const void *p) {\n    return ToHost16(GOOGLE_UNALIGNED_LOAD16(p));\n  }\n\n  static void Store16(void *p, uint16 v) {\n    GOOGLE_UNALIGNED_STORE16(p, FromHost16(v));\n  }\n\n  static uint32 Load32(const void *p) {\n    return ToHost32(GOOGLE_UNALIGNED_LOAD32(p));\n  }\n\n  static void Store32(void *p, uint32 v) {\n    GOOGLE_UNALIGNED_STORE32(p, FromHost32(v));\n  }\n\n  static uint64 Load64(const void *p) {\n    return ToHost64(GOOGLE_UNALIGNED_LOAD64(p));\n  }\n\n  static void Store64(void *p, uint64 v) {\n    GOOGLE_UNALIGNED_STORE64(p, FromHost64(v));\n  }\n};\n\n\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_STUBS_PORT_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/scoped_ptr.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_STUBS_SCOPED_PTR_H_\n#define GOOGLE_PROTOBUF_STUBS_SCOPED_PTR_H_\n\n#include <google/protobuf/stubs/port.h>\n\nnamespace google {\nnamespace protobuf {\n\n// ===================================================================\n// from google3/base/scoped_ptr.h\n\nnamespace internal {\n\n//  This is an implementation designed to match the anticipated future TR2\n//  implementation of the scoped_ptr class, and its closely-related brethren,\n//  scoped_array, scoped_ptr_malloc, and make_scoped_ptr.\n\ntemplate <class C> class scoped_ptr;\ntemplate <class C> class scoped_array;\n\n// A scoped_ptr<T> is like a T*, except that the destructor of scoped_ptr<T>\n// automatically deletes the pointer it holds (if any).\n// That is, scoped_ptr<T> owns the T object that it points to.\n// Like a T*, a scoped_ptr<T> may hold either NULL or a pointer to a T object.\n//\n// The size of a scoped_ptr is small:\n// sizeof(scoped_ptr<C>) == sizeof(C*)\ntemplate <class C>\nclass scoped_ptr {\n public:\n\n  // The element type\n  typedef C element_type;\n\n  // Constructor.  Defaults to initializing with NULL.\n  // There is no way to create an uninitialized scoped_ptr.\n  // The input parameter must be allocated with new.\n  explicit scoped_ptr(C* p = NULL) : ptr_(p) { }\n\n  // Destructor.  If there is a C object, delete it.\n  // We don't need to test ptr_ == NULL because C++ does that for us.\n  ~scoped_ptr() {\n    enum { type_must_be_complete = sizeof(C) };\n    delete ptr_;\n  }\n\n  // Reset.  Deletes the current owned object, if any.\n  // Then takes ownership of a new object, if given.\n  // this->reset(this->get()) works.\n  void reset(C* p = NULL) {\n    if (p != ptr_) {\n      enum { type_must_be_complete = sizeof(C) };\n      delete ptr_;\n      ptr_ = p;\n    }\n  }\n\n  // Accessors to get the owned object.\n  // operator* and operator-> will assert() if there is no current object.\n  C& operator*() const {\n    assert(ptr_ != NULL);\n    return *ptr_;\n  }\n  C* operator->() const  {\n    assert(ptr_ != NULL);\n    return ptr_;\n  }\n  C* get() const { return ptr_; }\n\n  // Comparison operators.\n  // These return whether two scoped_ptr refer to the same object, not just to\n  // two different but equal objects.\n  bool operator==(C* p) const { return ptr_ == p; }\n  bool operator!=(C* p) const { return ptr_ != p; }\n\n  // Swap two scoped pointers.\n  void swap(scoped_ptr& p2) {\n    C* tmp = ptr_;\n    ptr_ = p2.ptr_;\n    p2.ptr_ = tmp;\n  }\n\n  // Release a pointer.\n  // The return value is the current pointer held by this object.\n  // If this object holds a NULL pointer, the return value is NULL.\n  // After this operation, this object will hold a NULL pointer,\n  // and will not own the object any more.\n  C* release() {\n    C* retVal = ptr_;\n    ptr_ = NULL;\n    return retVal;\n  }\n\n private:\n  C* ptr_;\n\n  // Forbid comparison of scoped_ptr types.  If C2 != C, it totally doesn't\n  // make sense, and if C2 == C, it still doesn't make sense because you should\n  // never have the same object owned by two different scoped_ptrs.\n  template <class C2> bool operator==(scoped_ptr<C2> const& p2) const;\n  template <class C2> bool operator!=(scoped_ptr<C2> const& p2) const;\n\n  // Disallow evil constructors\n  scoped_ptr(const scoped_ptr&);\n  void operator=(const scoped_ptr&);\n};\n\n// scoped_array<C> is like scoped_ptr<C>, except that the caller must allocate\n// with new [] and the destructor deletes objects with delete [].\n//\n// As with scoped_ptr<C>, a scoped_array<C> either points to an object\n// or is NULL.  A scoped_array<C> owns the object that it points to.\n//\n// Size: sizeof(scoped_array<C>) == sizeof(C*)\ntemplate <class C>\nclass scoped_array {\n public:\n\n  // The element type\n  typedef C element_type;\n\n  // Constructor.  Defaults to initializing with NULL.\n  // There is no way to create an uninitialized scoped_array.\n  // The input parameter must be allocated with new [].\n  explicit scoped_array(C* p = NULL) : array_(p) { }\n\n  // Destructor.  If there is a C object, delete it.\n  // We don't need to test ptr_ == NULL because C++ does that for us.\n  ~scoped_array() {\n    enum { type_must_be_complete = sizeof(C) };\n    delete[] array_;\n  }\n\n  // Reset.  Deletes the current owned object, if any.\n  // Then takes ownership of a new object, if given.\n  // this->reset(this->get()) works.\n  void reset(C* p = NULL) {\n    if (p != array_) {\n      enum { type_must_be_complete = sizeof(C) };\n      delete[] array_;\n      array_ = p;\n    }\n  }\n\n  // Get one element of the current object.\n  // Will assert() if there is no current object, or index i is negative.\n  C& operator[](std::ptrdiff_t i) const {\n    assert(i >= 0);\n    assert(array_ != NULL);\n    return array_[i];\n  }\n\n  // Get a pointer to the zeroth element of the current object.\n  // If there is no current object, return NULL.\n  C* get() const {\n    return array_;\n  }\n\n  // Comparison operators.\n  // These return whether two scoped_array refer to the same object, not just to\n  // two different but equal objects.\n  bool operator==(C* p) const { return array_ == p; }\n  bool operator!=(C* p) const { return array_ != p; }\n\n  // Swap two scoped arrays.\n  void swap(scoped_array& p2) {\n    C* tmp = array_;\n    array_ = p2.array_;\n    p2.array_ = tmp;\n  }\n\n  // Release an array.\n  // The return value is the current pointer held by this object.\n  // If this object holds a NULL pointer, the return value is NULL.\n  // After this operation, this object will hold a NULL pointer,\n  // and will not own the object any more.\n  C* release() {\n    C* retVal = array_;\n    array_ = NULL;\n    return retVal;\n  }\n\n private:\n  C* array_;\n\n  // Forbid comparison of different scoped_array types.\n  template <class C2> bool operator==(scoped_array<C2> const& p2) const;\n  template <class C2> bool operator!=(scoped_array<C2> const& p2) const;\n\n  // Disallow evil constructors\n  scoped_array(const scoped_array&);\n  void operator=(const scoped_array&);\n};\n\n}  // namespace internal\n\n// We made these internal so that they would show up as such in the docs,\n// but we don't want to stick \"internal::\" in front of them everywhere.\nusing internal::scoped_ptr;\nusing internal::scoped_array;\n\n\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_STUBS_SCOPED_PTR_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/shared_ptr.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2014 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// from google3/util/gtl/shared_ptr.h\n\n#ifndef GOOGLE_PROTOBUF_STUBS_SHARED_PTR_H__\n#define GOOGLE_PROTOBUF_STUBS_SHARED_PTR_H__\n\n#include <google/protobuf/stubs/atomicops.h>\n\n#include <algorithm>  // for swap\n#include <stddef.h>\n#include <memory>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\n// Alias to std::shared_ptr for any C++11 platform,\n// and for any supported MSVC compiler.\n#if !defined(UTIL_GTL_USE_STD_SHARED_PTR) && \\\n    (defined(COMPILER_MSVC) || defined(LANG_CXX11))\n#define UTIL_GTL_USE_STD_SHARED_PTR 1\n#endif\n\n#if defined(UTIL_GTL_USE_STD_SHARED_PTR) && UTIL_GTL_USE_STD_SHARED_PTR\n\n// These are transitional.  They will be going away soon.\n// Please just #include <memory> and just type std::shared_ptr yourself, instead\n// of relying on this file.\n//\n// Migration doc: http://go/std-shared-ptr-lsc\nusing std::enable_shared_from_this;\nusing std::shared_ptr;\nusing std::static_pointer_cast;\nusing std::weak_ptr;\n\n#else  // below, UTIL_GTL_USE_STD_SHARED_PTR not set or set to 0.\n\n// For everything else there is the google3 implementation.\ninline bool RefCountDec(volatile Atomic32 *ptr) {\n  return Barrier_AtomicIncrement(ptr, -1) != 0;\n}\n\ninline void RefCountInc(volatile Atomic32 *ptr) {\n  NoBarrier_AtomicIncrement(ptr, 1);\n}\n\ntemplate <typename T> class shared_ptr;\ntemplate <typename T> class weak_ptr;\n\n// This class is an internal implementation detail for shared_ptr. If two\n// shared_ptrs point to the same object, they also share a control block.\n// An \"empty\" shared_pointer refers to NULL and also has a NULL control block.\n// It contains all of the state that's needed for reference counting or any\n// other kind of resource management. In this implementation the control block\n// happens to consist of two atomic words, the reference count (the number\n// of shared_ptrs that share ownership of the object) and the weak count\n// (the number of weak_ptrs that observe the object, plus 1 if the\n// refcount is nonzero).\n//\n// The \"plus 1\" is to prevent a race condition in the shared_ptr and\n// weak_ptr destructors. We need to make sure the control block is\n// only deleted once, so we need to make sure that at most one\n// object sees the weak count decremented from 1 to 0.\nclass SharedPtrControlBlock {\n  template <typename T> friend class shared_ptr;\n  template <typename T> friend class weak_ptr;\n private:\n  SharedPtrControlBlock() : refcount_(1), weak_count_(1) { }\n  Atomic32 refcount_;\n  Atomic32 weak_count_;\n};\n\n// Forward declaration. The class is defined below.\ntemplate <typename T> class enable_shared_from_this;\n\ntemplate <typename T>\nclass shared_ptr {\n  template <typename U> friend class weak_ptr;\n public:\n  typedef T element_type;\n\n  shared_ptr() : ptr_(NULL), control_block_(NULL) {}\n\n  explicit shared_ptr(T* ptr)\n      : ptr_(ptr),\n        control_block_(ptr != NULL ? new SharedPtrControlBlock : NULL) {\n    // If p is non-null and T inherits from enable_shared_from_this, we\n    // set up the data that shared_from_this needs.\n    MaybeSetupWeakThis(ptr);\n  }\n\n  // Copy constructor: makes this object a copy of ptr, and increments\n  // the reference count.\n  template <typename U>\n  shared_ptr(const shared_ptr<U>& ptr)\n      : ptr_(NULL),\n        control_block_(NULL) {\n    Initialize(ptr);\n  }\n  // Need non-templated version to prevent the compiler-generated default\n  shared_ptr(const shared_ptr<T>& ptr)\n      : ptr_(NULL),\n        control_block_(NULL) {\n    Initialize(ptr);\n  }\n\n  // Assignment operator. Replaces the existing shared_ptr with ptr.\n  // Increment ptr's reference count and decrement the one being replaced.\n  template <typename U>\n  shared_ptr<T>& operator=(const shared_ptr<U>& ptr) {\n    if (ptr_ != ptr.ptr_) {\n      shared_ptr<T> me(ptr);   // will hold our previous state to be destroyed.\n      swap(me);\n    }\n    return *this;\n  }\n\n  // Need non-templated version to prevent the compiler-generated default\n  shared_ptr<T>& operator=(const shared_ptr<T>& ptr) {\n    if (ptr_ != ptr.ptr_) {\n      shared_ptr<T> me(ptr);   // will hold our previous state to be destroyed.\n      swap(me);\n    }\n    return *this;\n  }\n\n  // TODO(austern): Consider providing this constructor. The draft C++ standard\n  // (20.8.10.2.1) includes it. However, it says that this constructor throws\n  // a bad_weak_ptr exception when ptr is expired. Is it better to provide this\n  // constructor and make it do something else, like fail with a CHECK, or to\n  // leave this constructor out entirely?\n  //\n  // template <typename U>\n  // shared_ptr(const weak_ptr<U>& ptr);\n\n  ~shared_ptr() {\n    if (ptr_ != NULL) {\n      if (!RefCountDec(&control_block_->refcount_)) {\n        delete ptr_;\n\n        // weak_count_ is defined as the number of weak_ptrs that observe\n        // ptr_, plus 1 if refcount_ is nonzero.\n        if (!RefCountDec(&control_block_->weak_count_)) {\n          delete control_block_;\n        }\n      }\n    }\n  }\n\n  // Replaces underlying raw pointer with the one passed in.  The reference\n  // count is set to one (or zero if the pointer is NULL) for the pointer\n  // being passed in and decremented for the one being replaced.\n  //\n  // If you have a compilation error with this code, make sure you aren't\n  // passing NULL, nullptr, or 0 to this function.  Call reset without an\n  // argument to reset to a null ptr.\n  template <typename Y>\n  void reset(Y* p) {\n    if (p != ptr_) {\n      shared_ptr<T> tmp(p);\n      tmp.swap(*this);\n    }\n  }\n\n  void reset() {\n    reset(static_cast<T*>(NULL));\n  }\n\n  // Exchanges the contents of this with the contents of r.  This function\n  // supports more efficient swapping since it eliminates the need for a\n  // temporary shared_ptr object.\n  void swap(shared_ptr<T>& r) {\n    using std::swap;  // http://go/using-std-swap\n    swap(ptr_, r.ptr_);\n    swap(control_block_, r.control_block_);\n  }\n\n  // The following function is useful for gaining access to the underlying\n  // pointer when a shared_ptr remains in scope so the reference-count is\n  // known to be > 0 (e.g. for parameter passing).\n  T* get() const {\n    return ptr_;\n  }\n\n  T& operator*() const {\n    return *ptr_;\n  }\n\n  T* operator->() const {\n    return ptr_;\n  }\n\n  long use_count() const {\n    return control_block_ ? control_block_->refcount_ : 1;\n  }\n\n  bool unique() const {\n    return use_count() == 1;\n  }\n\n private:\n  // If r is non-empty, initialize *this to share ownership with r,\n  // increasing the underlying reference count.\n  // If r is empty, *this remains empty.\n  // Requires: this is empty, namely this->ptr_ == NULL.\n  template <typename U>\n  void Initialize(const shared_ptr<U>& r) {\n    // This performs a static_cast on r.ptr_ to U*, which is a no-op since it\n    // is already a U*. So initialization here requires that r.ptr_ is\n    // implicitly convertible to T*.\n    InitializeWithStaticCast<U>(r);\n  }\n\n  // Initializes *this as described in Initialize, but additionally performs a\n  // static_cast from r.ptr_ (V*) to U*.\n  // NOTE(gfc): We'd need a more general form to support const_pointer_cast and\n  // dynamic_pointer_cast, but those operations are sufficiently discouraged\n  // that supporting static_pointer_cast is sufficient.\n  template <typename U, typename V>\n  void InitializeWithStaticCast(const shared_ptr<V>& r) {\n    if (r.control_block_ != NULL) {\n      RefCountInc(&r.control_block_->refcount_);\n\n      ptr_ = static_cast<U*>(r.ptr_);\n      control_block_ = r.control_block_;\n    }\n  }\n\n  // Helper function for the constructor that takes a raw pointer. If T\n  // doesn't inherit from enable_shared_from_this<T> then we have nothing to\n  // do, so this function is trivial and inline. The other version is declared\n  // out of line, after the class definition of enable_shared_from_this.\n  void MaybeSetupWeakThis(enable_shared_from_this<T>* ptr);\n  void MaybeSetupWeakThis(...) { }\n\n  T* ptr_;\n  SharedPtrControlBlock* control_block_;\n\n#ifndef SWIG\n  template <typename U>\n  friend class shared_ptr;\n\n  template <typename U, typename V>\n  friend shared_ptr<U> static_pointer_cast(const shared_ptr<V>& rhs);\n#endif\n};\n\n// Matches the interface of std::swap as an aid to generic programming.\ntemplate <typename T> void swap(shared_ptr<T>& r, shared_ptr<T>& s) {\n  r.swap(s);\n}\n\ntemplate <typename T, typename U>\nshared_ptr<T> static_pointer_cast(const shared_ptr<U>& rhs) {\n  shared_ptr<T> lhs;\n  lhs.template InitializeWithStaticCast<T>(rhs);\n  return lhs;\n}\n\n// See comments at the top of the file for a description of why this\n// class exists, and the draft C++ standard (as of July 2009 the\n// latest draft is N2914) for the detailed specification.\ntemplate <typename T>\nclass weak_ptr {\n  template <typename U> friend class weak_ptr;\n public:\n  typedef T element_type;\n\n  // Create an empty (i.e. already expired) weak_ptr.\n  weak_ptr() : ptr_(NULL), control_block_(NULL) { }\n\n  // Create a weak_ptr that observes the same object that ptr points\n  // to.  Note that there is no race condition here: we know that the\n  // control block can't disappear while we're looking at it because\n  // it is owned by at least one shared_ptr, ptr.\n  template <typename U> weak_ptr(const shared_ptr<U>& ptr) {\n    CopyFrom(ptr.ptr_, ptr.control_block_);\n  }\n\n  // Copy a weak_ptr. The object it points to might disappear, but we\n  // don't care: we're only working with the control block, and it can't\n  // disappear while we're looking at because it's owned by at least one\n  // weak_ptr, ptr.\n  template <typename U> weak_ptr(const weak_ptr<U>& ptr) {\n    CopyFrom(ptr.ptr_, ptr.control_block_);\n  }\n\n  // Need non-templated version to prevent default copy constructor\n  weak_ptr(const weak_ptr& ptr) {\n    CopyFrom(ptr.ptr_, ptr.control_block_);\n  }\n\n  // Destroy the weak_ptr. If no shared_ptr owns the control block, and if\n  // we are the last weak_ptr to own it, then it can be deleted. Note that\n  // weak_count_ is defined as the number of weak_ptrs sharing this control\n  // block, plus 1 if there are any shared_ptrs. We therefore know that it's\n  // safe to delete the control block when weak_count_ reaches 0, without\n  // having to perform any additional tests.\n  ~weak_ptr() {\n    if (control_block_ != NULL &&\n        !RefCountDec(&control_block_->weak_count_)) {\n      delete control_block_;\n    }\n  }\n\n  weak_ptr& operator=(const weak_ptr& ptr) {\n    if (&ptr != this) {\n      weak_ptr tmp(ptr);\n      tmp.swap(*this);\n    }\n    return *this;\n  }\n  template <typename U> weak_ptr& operator=(const weak_ptr<U>& ptr) {\n    weak_ptr tmp(ptr);\n    tmp.swap(*this);\n    return *this;\n  }\n  template <typename U> weak_ptr& operator=(const shared_ptr<U>& ptr) {\n    weak_ptr tmp(ptr);\n    tmp.swap(*this);\n    return *this;\n  }\n\n  void swap(weak_ptr& ptr) {\n    using std::swap;  // http://go/using-std-swap\n    swap(ptr_, ptr.ptr_);\n    swap(control_block_, ptr.control_block_);\n  }\n\n  void reset() {\n    weak_ptr tmp;\n    tmp.swap(*this);\n  }\n\n  // Return the number of shared_ptrs that own the object we are observing.\n  // Note that this number can be 0 (if this pointer has expired).\n  long use_count() const {\n    return control_block_ != NULL ? control_block_->refcount_ : 0;\n  }\n\n  bool expired() const { return use_count() == 0; }\n\n  // Return a shared_ptr that owns the object we are observing. If we\n  // have expired, the shared_ptr will be empty. We have to be careful\n  // about concurrency, though, since some other thread might be\n  // destroying the last owning shared_ptr while we're in this\n  // function.  We want to increment the refcount only if it's nonzero\n  // and get the new value, and we want that whole operation to be\n  // atomic.\n  shared_ptr<T> lock() const {\n    shared_ptr<T> result;\n    if (control_block_ != NULL) {\n      Atomic32 old_refcount;\n      do {\n        old_refcount = control_block_->refcount_;\n        if (old_refcount == 0)\n          break;\n      } while (old_refcount !=\n               NoBarrier_CompareAndSwap(\n                   &control_block_->refcount_, old_refcount,\n                   old_refcount + 1));\n      if (old_refcount > 0) {\n        result.ptr_ = ptr_;\n        result.control_block_ = control_block_;\n      }\n    }\n\n    return result;\n  }\n\n private:\n  void CopyFrom(T* ptr, SharedPtrControlBlock* control_block) {\n    ptr_ = ptr;\n    control_block_ = control_block;\n    if (control_block_ != NULL)\n      RefCountInc(&control_block_->weak_count_);\n  }\n\n private:\n  element_type* ptr_;\n  SharedPtrControlBlock* control_block_;\n};\n\ntemplate <typename T> void swap(weak_ptr<T>& r, weak_ptr<T>& s) {\n  r.swap(s);\n}\n\n// See comments at the top of the file for a description of why this class\n// exists, and section 20.8.10.5 of the draft C++ standard (as of July 2009\n// the latest draft is N2914) for the detailed specification.\ntemplate <typename T>\nclass enable_shared_from_this {\n  friend class shared_ptr<T>;\n public:\n  // Precondition: there must be a shared_ptr that owns *this and that was\n  // created, directly or indirectly, from a raw pointer of type T*. (The\n  // latter part of the condition is technical but not quite redundant; it\n  // rules out some complicated uses involving inheritance hierarchies.)\n  shared_ptr<T> shared_from_this() {\n    // Behavior is undefined if the precondition isn't satisfied; we choose\n    // to die with a CHECK failure.\n    CHECK(!weak_this_.expired()) << \"No shared_ptr owns this object\";\n    return weak_this_.lock();\n  }\n  shared_ptr<const T> shared_from_this() const {\n    CHECK(!weak_this_.expired()) << \"No shared_ptr owns this object\";\n    return weak_this_.lock();\n  }\n\n protected:\n  enable_shared_from_this() { }\n  enable_shared_from_this(const enable_shared_from_this& other) { }\n  enable_shared_from_this& operator=(const enable_shared_from_this& other) {\n    return *this;\n  }\n  ~enable_shared_from_this() { }\n\n private:\n  weak_ptr<T> weak_this_;\n};\n\n// This is a helper function called by shared_ptr's constructor from a raw\n// pointer. If T inherits from enable_shared_from_this<T>, it sets up\n// weak_this_ so that shared_from_this works correctly. If T does not inherit\n// from weak_this we get a different overload, defined inline, which does\n// nothing.\ntemplate<typename T>\nvoid shared_ptr<T>::MaybeSetupWeakThis(enable_shared_from_this<T>* ptr) {\n  if (ptr) {\n    CHECK(ptr->weak_this_.expired()) << \"Object already owned by a shared_ptr\";\n    ptr->weak_this_ = *this;\n  }\n}\n\n#endif  // UTIL_GTL_USE_STD_SHARED_PTR\n\n}  // internal\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_STUBS_SHARED_PTR_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/singleton.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2014 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n#ifndef GOOGLE_PROTOBUF_STUBS_SINGLETON_H__\n#define GOOGLE_PROTOBUF_STUBS_SINGLETON_H__\n\n#include <google/protobuf/stubs/atomicops.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/once.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\ntemplate<typename T>\nclass Singleton {\n public:\n  static T* get() {\n    GoogleOnceInit(&once_, &Singleton<T>::Init);\n    return instance_;\n  }\n  static void ShutDown() {\n    delete instance_;\n    instance_ = NULL;\n  }\n private:\n  static void Init() {\n    instance_ = new T();\n  }\n  static ProtobufOnceType once_;\n  static T* instance_;\n};\n\ntemplate<typename T>\nProtobufOnceType Singleton<T>::once_;\n\ntemplate<typename T>\nT* Singleton<T>::instance_ = NULL;\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_STUBS_SINGLETON_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/status.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n#include <google/protobuf/stubs/status.h>\n\n#include <ostream>\n#include <stdio.h>\n#include <string>\n#include <utility>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace error {\ninline string CodeEnumToString(error::Code code) {\n  switch (code) {\n    case OK:\n      return \"OK\";\n    case CANCELLED:\n      return \"CANCELLED\";\n    case UNKNOWN:\n      return \"UNKNOWN\";\n    case INVALID_ARGUMENT:\n      return \"INVALID_ARGUMENT\";\n    case DEADLINE_EXCEEDED:\n      return \"DEADLINE_EXCEEDED\";\n    case NOT_FOUND:\n      return \"NOT_FOUND\";\n    case ALREADY_EXISTS:\n      return \"ALREADY_EXISTS\";\n    case PERMISSION_DENIED:\n      return \"PERMISSION_DENIED\";\n    case UNAUTHENTICATED:\n      return \"UNAUTHENTICATED\";\n    case RESOURCE_EXHAUSTED:\n      return \"RESOURCE_EXHAUSTED\";\n    case FAILED_PRECONDITION:\n      return \"FAILED_PRECONDITION\";\n    case ABORTED:\n      return \"ABORTED\";\n    case OUT_OF_RANGE:\n      return \"OUT_OF_RANGE\";\n    case UNIMPLEMENTED:\n      return \"UNIMPLEMENTED\";\n    case INTERNAL:\n      return \"INTERNAL\";\n    case UNAVAILABLE:\n      return \"UNAVAILABLE\";\n    case DATA_LOSS:\n      return \"DATA_LOSS\";\n  }\n\n  // No default clause, clang will abort if a code is missing from\n  // above switch.\n  return \"UNKNOWN\";\n}\n}  // namespace error.\n\nconst Status Status::OK = Status();\nconst Status Status::CANCELLED = Status(error::CANCELLED, \"\");\nconst Status Status::UNKNOWN = Status(error::UNKNOWN, \"\");\n\nStatus::Status() : error_code_(error::OK) {\n}\n\nStatus::Status(error::Code error_code, StringPiece error_message)\n    : error_code_(error_code) {\n  if (error_code != error::OK) {\n    error_message_ = error_message.ToString();\n  }\n}\n\nStatus::Status(const Status& other)\n    : error_code_(other.error_code_), error_message_(other.error_message_) {\n}\n\nStatus& Status::operator=(const Status& other) {\n  error_code_ = other.error_code_;\n  error_message_ = other.error_message_;\n  return *this;\n}\n\nbool Status::operator==(const Status& x) const {\n  return error_code_ == x.error_code_ &&\n      error_message_ == x.error_message_;\n}\n\nstring Status::ToString() const {\n  if (error_code_ == error::OK) {\n    return \"OK\";\n  } else {\n    if (error_message_.empty()) {\n      return error::CodeEnumToString(error_code_);\n    } else {\n      return error::CodeEnumToString(error_code_) + \":\" +\n          error_message_;\n    }\n  }\n}\n\nostream& operator<<(ostream& os, const Status& x) {\n  os << x.ToString();\n  return os;\n}\n\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/status.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n#ifndef GOOGLE_PROTOBUF_STUBS_STATUS_H_\n#define GOOGLE_PROTOBUF_STUBS_STATUS_H_\n\n#include <iosfwd>\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/stringpiece.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace error {\n// These values must match error codes defined in google/rpc/code.proto.\nenum Code {\n  OK = 0,\n  CANCELLED = 1,\n  UNKNOWN = 2,\n  INVALID_ARGUMENT = 3,\n  DEADLINE_EXCEEDED = 4,\n  NOT_FOUND = 5,\n  ALREADY_EXISTS = 6,\n  PERMISSION_DENIED = 7,\n  UNAUTHENTICATED = 16,\n  RESOURCE_EXHAUSTED = 8,\n  FAILED_PRECONDITION = 9,\n  ABORTED = 10,\n  OUT_OF_RANGE = 11,\n  UNIMPLEMENTED = 12,\n  INTERNAL = 13,\n  UNAVAILABLE = 14,\n  DATA_LOSS = 15,\n};\n}  // namespace error\n\nclass LIBPROTOBUF_EXPORT Status {\n public:\n  // Creates a \"successful\" status.\n  Status();\n\n  // Create a status in the canonical error space with the specified\n  // code, and error message.  If \"code == 0\", error_message is\n  // ignored and a Status object identical to Status::OK is\n  // constructed.\n  Status(error::Code error_code, StringPiece error_message);\n  Status(const Status&);\n  Status& operator=(const Status& x);\n  ~Status() {}\n\n  // Some pre-defined Status objects\n  static const Status OK;             // Identical to 0-arg constructor\n  static const Status CANCELLED;\n  static const Status UNKNOWN;\n\n  // Accessor\n  bool ok() const {\n    return error_code_ == error::OK;\n  }\n  int error_code() const {\n    return error_code_;\n  }\n  StringPiece error_message() const {\n    return error_message_;\n  }\n\n  bool operator==(const Status& x) const;\n  bool operator!=(const Status& x) const {\n    return !operator==(x);\n  }\n\n  // Return a combination of the error code name and message.\n  string ToString() const;\n\n private:\n  error::Code error_code_;\n  string error_message_;\n};\n\n// Prints a human-readable representation of 'x' to 'os'.\nLIBPROTOBUF_EXPORT ostream& operator<<(ostream& os, const Status& x);\n\n#define EXPECT_OK(value) EXPECT_TRUE((value).ok())\n\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_STUBS_STATUS_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/status_macros.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// From: util/task/contrib/status_macros/status_macros.h\n\n#ifndef GOOGLE_PROTOBUF_STUBS_STATUS_MACROS_H_\n#define GOOGLE_PROTOBUF_STUBS_STATUS_MACROS_H_\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/status.h>\n#include <google/protobuf/stubs/statusor.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\n\n// Run a command that returns a util::Status.  If the called code returns an\n// error status, return that status up out of this method too.\n//\n// Example:\n//   RETURN_IF_ERROR(DoThings(4));\n#define RETURN_IF_ERROR(expr) \\\n  do { \\\n    /* Using _status below to avoid capture problems if expr is \"status\". */ \\\n    const ::google::protobuf::util::Status _status = (expr); \\\n    if (GOOGLE_PREDICT_FALSE(!_status.ok())) return _status; \\\n  } while (0)\n\n// Internal helper for concatenating macro values.\n#define STATUS_MACROS_CONCAT_NAME_INNER(x, y) x##y\n#define STATUS_MACROS_CONCAT_NAME(x, y) STATUS_MACROS_CONCAT_NAME_INNER(x, y)\n\ntemplate<typename T>\nStatus DoAssignOrReturn(T& lhs, StatusOr<T> result) {\n  if (result.ok()) {\n    lhs = result.ValueOrDie();\n  }\n  return result.status();\n}\n\n#define ASSIGN_OR_RETURN_IMPL(status, lhs, rexpr) \\\n  Status status = DoAssignOrReturn(lhs, (rexpr)); \\\n  if (GOOGLE_PREDICT_FALSE(!status.ok())) return status;\n\n// Executes an expression that returns a util::StatusOr, extracting its value\n// into the variable defined by lhs (or returning on error).\n//\n// Example: Assigning to an existing value\n//   ValueType value;\n//   ASSIGN_OR_RETURN(value, MaybeGetValue(arg));\n//\n// WARNING: ASSIGN_OR_RETURN expands into multiple statements; it cannot be used\n//  in a single statement (e.g. as the body of an if statement without {})!\n#define ASSIGN_OR_RETURN(lhs, rexpr) \\\n  ASSIGN_OR_RETURN_IMPL( \\\n      STATUS_MACROS_CONCAT_NAME(_status_or_value, __COUNTER__), lhs, rexpr);\n\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_STUBS_STATUS_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/status_test.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n#include <google/protobuf/stubs/status.h>\n\n#include <stdio.h>\n\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace {\nTEST(Status, Empty) {\n  util::Status status;\n  EXPECT_EQ(util::error::OK, util::Status::OK.error_code());\n  EXPECT_EQ(\"OK\", util::Status::OK.ToString());\n}\n\nTEST(Status, GenericCodes) {\n  EXPECT_EQ(util::error::OK, util::Status::OK.error_code());\n  EXPECT_EQ(util::error::CANCELLED, util::Status::CANCELLED.error_code());\n  EXPECT_EQ(util::error::UNKNOWN, util::Status::UNKNOWN.error_code());\n}\n\nTEST(Status, ConstructorZero) {\n  util::Status status(util::error::OK, \"msg\");\n  EXPECT_TRUE(status.ok());\n  EXPECT_EQ(\"OK\", status.ToString());\n}\n\nTEST(Status, CheckOK) {\n  util::Status status;\n  GOOGLE_CHECK_OK(status);\n  GOOGLE_CHECK_OK(status) << \"Failed\";\n  GOOGLE_DCHECK_OK(status) << \"Failed\";\n}\n\nTEST(Status, ErrorMessage) {\n  util::Status status(util::error::INVALID_ARGUMENT, \"\");\n  EXPECT_FALSE(status.ok());\n  EXPECT_EQ(\"\", status.error_message().ToString());\n  EXPECT_EQ(\"INVALID_ARGUMENT\", status.ToString());\n  status = util::Status(util::error::INVALID_ARGUMENT, \"msg\");\n  EXPECT_FALSE(status.ok());\n  EXPECT_EQ(\"msg\", status.error_message().ToString());\n  EXPECT_EQ(\"INVALID_ARGUMENT:msg\", status.ToString());\n  status = util::Status(util::error::OK, \"msg\");\n  EXPECT_TRUE(status.ok());\n  EXPECT_EQ(\"\", status.error_message().ToString());\n  EXPECT_EQ(\"OK\", status.ToString());\n}\n\nTEST(Status, Copy) {\n  util::Status a(util::error::UNKNOWN, \"message\");\n  util::Status b(a);\n  ASSERT_EQ(a.ToString(), b.ToString());\n}\n\nTEST(Status, Assign) {\n  util::Status a(util::error::UNKNOWN, \"message\");\n  util::Status b;\n  b = a;\n  ASSERT_EQ(a.ToString(), b.ToString());\n}\n\nTEST(Status, AssignEmpty) {\n  util::Status a(util::error::UNKNOWN, \"message\");\n  util::Status b;\n  a = b;\n  ASSERT_EQ(string(\"OK\"), a.ToString());\n  ASSERT_TRUE(b.ok());\n  ASSERT_TRUE(a.ok());\n}\n\nTEST(Status, EqualsOK) {\n  ASSERT_EQ(util::Status::OK, util::Status());\n}\n\nTEST(Status, EqualsSame) {\n  const util::Status a = util::Status(util::error::CANCELLED, \"message\");\n  const util::Status b = util::Status(util::error::CANCELLED, \"message\");\n  ASSERT_EQ(a, b);\n}\n\nTEST(Status, EqualsCopy) {\n  const util::Status a = util::Status(util::error::CANCELLED, \"message\");\n  const util::Status b = a;\n  ASSERT_EQ(a, b);\n}\n\nTEST(Status, EqualsDifferentCode) {\n  const util::Status a = util::Status(util::error::CANCELLED, \"message\");\n  const util::Status b = util::Status(util::error::UNKNOWN, \"message\");\n  ASSERT_NE(a, b);\n}\n\nTEST(Status, EqualsDifferentMessage) {\n  const util::Status a = util::Status(util::error::CANCELLED, \"message\");\n  const util::Status b = util::Status(util::error::CANCELLED, \"another\");\n  ASSERT_NE(a, b);\n}\n}  // namespace\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/statusor.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/stubs/statusor.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace internal {\n\nvoid StatusOrHelper::Crash(const Status& status) {\n  GOOGLE_LOG(FATAL) << \"Attempting to fetch value instead of handling error \"\n                    << status.ToString();\n}\n\n}  // namespace internal\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/statusor.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// StatusOr<T> is the union of a Status object and a T\n// object. StatusOr models the concept of an object that is either a\n// usable value, or an error Status explaining why such a value is\n// not present. To this end, StatusOr<T> does not allow its Status\n// value to be Status::OK. Further, StatusOr<T*> does not allow the\n// contained pointer to be NULL.\n//\n// The primary use-case for StatusOr<T> is as the return value of a\n// function which may fail.\n//\n// Example client usage for a StatusOr<T>, where T is not a pointer:\n//\n//  StatusOr<float> result = DoBigCalculationThatCouldFail();\n//  if (result.ok()) {\n//    float answer = result.ValueOrDie();\n//    printf(\"Big calculation yielded: %f\", answer);\n//  } else {\n//    LOG(ERROR) << result.status();\n//  }\n//\n// Example client usage for a StatusOr<T*>:\n//\n//  StatusOr<Foo*> result = FooFactory::MakeNewFoo(arg);\n//  if (result.ok()) {\n//    std::unique_ptr<Foo> foo(result.ValueOrDie());\n//    foo->DoSomethingCool();\n//  } else {\n//    LOG(ERROR) << result.status();\n//  }\n//\n// Example client usage for a StatusOr<std::unique_ptr<T>>:\n//\n//  StatusOr<std::unique_ptr<Foo>> result = FooFactory::MakeNewFoo(arg);\n//  if (result.ok()) {\n//    std::unique_ptr<Foo> foo = result.ConsumeValueOrDie();\n//    foo->DoSomethingCool();\n//  } else {\n//    LOG(ERROR) << result.status();\n//  }\n//\n// Example factory implementation returning StatusOr<T*>:\n//\n//  StatusOr<Foo*> FooFactory::MakeNewFoo(int arg) {\n//    if (arg <= 0) {\n//      return ::util::Status(::util::error::INVALID_ARGUMENT,\n//                            \"Arg must be positive\");\n//    } else {\n//      return new Foo(arg);\n//    }\n//  }\n//\n\n#ifndef GOOGLE_PROTOBUF_STUBS_STATUSOR_H_\n#define GOOGLE_PROTOBUF_STUBS_STATUSOR_H_\n\n#include <new>\n#include <string>\n#include <utility>\n\n#include <google/protobuf/stubs/status.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\n\ntemplate<typename T>\nclass StatusOr {\n  template<typename U> friend class StatusOr;\n\n public:\n  // Construct a new StatusOr with Status::UNKNOWN status\n  StatusOr();\n\n  // Construct a new StatusOr with the given non-ok status. After calling\n  // this constructor, calls to ValueOrDie() will CHECK-fail.\n  //\n  // NOTE: Not explicit - we want to use StatusOr<T> as a return\n  // value, so it is convenient and sensible to be able to do 'return\n  // Status()' when the return type is StatusOr<T>.\n  //\n  // REQUIRES: status != Status::OK. This requirement is DCHECKed.\n  // In optimized builds, passing Status::OK here will have the effect\n  // of passing PosixErrorSpace::EINVAL as a fallback.\n  StatusOr(const Status& status);  // NOLINT\n\n  // Construct a new StatusOr with the given value. If T is a plain pointer,\n  // value must not be NULL. After calling this constructor, calls to\n  // ValueOrDie() will succeed, and calls to status() will return OK.\n  //\n  // NOTE: Not explicit - we want to use StatusOr<T> as a return type\n  // so it is convenient and sensible to be able to do 'return T()'\n  // when when the return type is StatusOr<T>.\n  //\n  // REQUIRES: if T is a plain pointer, value != NULL. This requirement is\n  // DCHECKed. In optimized builds, passing a NULL pointer here will have\n  // the effect of passing PosixErrorSpace::EINVAL as a fallback.\n  StatusOr(const T& value);  // NOLINT\n\n  // Copy constructor.\n  StatusOr(const StatusOr& other);\n\n  // Conversion copy constructor, T must be copy constructible from U\n  template<typename U>\n  StatusOr(const StatusOr<U>& other);\n\n  // Assignment operator.\n  StatusOr& operator=(const StatusOr& other);\n\n  // Conversion assignment operator, T must be assignable from U\n  template<typename U>\n  StatusOr& operator=(const StatusOr<U>& other);\n\n  // Returns a reference to our status. If this contains a T, then\n  // returns Status::OK.\n  const Status& status() const;\n\n  // Returns this->status().ok()\n  bool ok() const;\n\n  // Returns a reference to our current value, or CHECK-fails if !this->ok().\n  // If you need to initialize a T object from the stored value,\n  // ConsumeValueOrDie() may be more efficient.\n  const T& ValueOrDie() const;\n\n private:\n  Status status_;\n  T value_;\n};\n\n////////////////////////////////////////////////////////////////////////////////\n// Implementation details for StatusOr<T>\n\nnamespace internal {\n\nclass LIBPROTOBUF_EXPORT StatusOrHelper {\n public:\n  // Move type-agnostic error handling to the .cc.\n  static void Crash(const util::Status& status);\n\n  // Customized behavior for StatusOr<T> vs. StatusOr<T*>\n  template<typename T>\n  struct Specialize;\n};\n\ntemplate<typename T>\nstruct StatusOrHelper::Specialize {\n  // For non-pointer T, a reference can never be NULL.\n  static inline bool IsValueNull(const T& t) { return false; }\n};\n\ntemplate<typename T>\nstruct StatusOrHelper::Specialize<T*> {\n  static inline bool IsValueNull(const T* t) { return t == NULL; }\n};\n\n}  // namespace internal\n\ntemplate<typename T>\ninline StatusOr<T>::StatusOr()\n    : status_(util::Status::UNKNOWN) {\n}\n\ntemplate<typename T>\ninline StatusOr<T>::StatusOr(const Status& status) {\n  if (status.ok()) {\n    status_ = Status(error::INTERNAL, \"Status::OK is not a valid argument.\");\n  } else {\n    status_ = status;\n  }\n}\n\ntemplate<typename T>\ninline StatusOr<T>::StatusOr(const T& value) {\n  if (internal::StatusOrHelper::Specialize<T>::IsValueNull(value)) {\n    status_ = Status(error::INTERNAL, \"NULL is not a vaild argument.\");\n  } else {\n    status_ = Status::OK;\n    value_ = value;\n  }\n}\n\ntemplate<typename T>\ninline StatusOr<T>::StatusOr(const StatusOr<T>& other)\n    : status_(other.status_), value_(other.value_) {\n}\n\ntemplate<typename T>\ninline StatusOr<T>& StatusOr<T>::operator=(const StatusOr<T>& other) {\n  status_ = other.status_;\n  value_ = other.value_;\n  return *this;\n}\n\ntemplate<typename T>\ntemplate<typename U>\ninline StatusOr<T>::StatusOr(const StatusOr<U>& other)\n    : status_(other.status_), value_(other.status_.ok() ? other.value_ : T()) {\n}\n\ntemplate<typename T>\ntemplate<typename U>\ninline StatusOr<T>& StatusOr<T>::operator=(const StatusOr<U>& other) {\n  status_ = other.status_;\n  if (status_.ok()) value_ = other.value_;\n  return *this;\n}\n\ntemplate<typename T>\ninline const Status& StatusOr<T>::status() const {\n  return status_;\n}\n\ntemplate<typename T>\ninline bool StatusOr<T>::ok() const {\n  return status().ok();\n}\n\ntemplate<typename T>\ninline const T& StatusOr<T>::ValueOrDie() const {\n  if (!status_.ok()) {\n    internal::StatusOrHelper::Crash(status_);\n  }\n  return value_;\n}\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_STUBS_STATUSOR_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/statusor_test.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/stubs/statusor.h>\n\n#include <errno.h>\n#include <memory>\n\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace {\n\nclass Base1 {\n public:\n  virtual ~Base1() {}\n  int pad;\n};\n\nclass Base2 {\n public:\n  virtual ~Base2() {}\n  int yetotherpad;\n};\n\nclass Derived : public Base1, public Base2 {\n public:\n  virtual ~Derived() {}\n  int evenmorepad;\n};\n\nclass CopyNoAssign {\n public:\n  explicit CopyNoAssign(int value) : foo(value) {}\n  CopyNoAssign(const CopyNoAssign& other) : foo(other.foo) {}\n  int foo;\n private:\n  const CopyNoAssign& operator=(const CopyNoAssign&);\n};\n\nTEST(StatusOr, TestDefaultCtor) {\n  StatusOr<int> thing;\n  EXPECT_FALSE(thing.ok());\n  EXPECT_EQ(Status::UNKNOWN, thing.status());\n}\n\nTEST(StatusOr, TestStatusCtor) {\n  StatusOr<int> thing(Status::CANCELLED);\n  EXPECT_FALSE(thing.ok());\n  EXPECT_EQ(Status::CANCELLED, thing.status());\n}\n\nTEST(StatusOr, TestValueCtor) {\n  const int kI = 4;\n  StatusOr<int> thing(kI);\n  EXPECT_TRUE(thing.ok());\n  EXPECT_EQ(kI, thing.ValueOrDie());\n}\n\nTEST(StatusOr, TestCopyCtorStatusOk) {\n  const int kI = 4;\n  StatusOr<int> original(kI);\n  StatusOr<int> copy(original);\n  EXPECT_EQ(original.status(), copy.status());\n  EXPECT_EQ(original.ValueOrDie(), copy.ValueOrDie());\n}\n\nTEST(StatusOr, TestCopyCtorStatusNotOk) {\n  StatusOr<int> original(Status::CANCELLED);\n  StatusOr<int> copy(original);\n  EXPECT_EQ(original.status(), copy.status());\n}\n\nTEST(StatusOr, TestCopyCtorStatusOKConverting) {\n  const int kI = 4;\n  StatusOr<int>    original(kI);\n  StatusOr<double> copy(original);\n  EXPECT_EQ(original.status(), copy.status());\n  EXPECT_EQ(original.ValueOrDie(), copy.ValueOrDie());\n}\n\nTEST(StatusOr, TestCopyCtorStatusNotOkConverting) {\n  StatusOr<int>    original(Status::CANCELLED);\n  StatusOr<double> copy(original);\n  EXPECT_EQ(original.status(), copy.status());\n}\n\nTEST(StatusOr, TestAssignmentStatusOk) {\n  const int kI = 4;\n  StatusOr<int> source(kI);\n  StatusOr<int> target;\n  target = source;\n  EXPECT_EQ(source.status(), target.status());\n  EXPECT_EQ(source.ValueOrDie(), target.ValueOrDie());\n}\n\nTEST(StatusOr, TestAssignmentStatusNotOk) {\n  StatusOr<int> source(Status::CANCELLED);\n  StatusOr<int> target;\n  target = source;\n  EXPECT_EQ(source.status(), target.status());\n}\n\nTEST(StatusOr, TestAssignmentStatusOKConverting) {\n  const int kI = 4;\n  StatusOr<int>    source(kI);\n  StatusOr<double> target;\n  target = source;\n  EXPECT_EQ(source.status(), target.status());\n  EXPECT_DOUBLE_EQ(source.ValueOrDie(), target.ValueOrDie());\n}\n\nTEST(StatusOr, TestAssignmentStatusNotOkConverting) {\n  StatusOr<int>    source(Status::CANCELLED);\n  StatusOr<double> target;\n  target = source;\n  EXPECT_EQ(source.status(), target.status());\n}\n\nTEST(StatusOr, TestStatus) {\n  StatusOr<int> good(4);\n  EXPECT_TRUE(good.ok());\n  StatusOr<int> bad(Status::CANCELLED);\n  EXPECT_FALSE(bad.ok());\n  EXPECT_EQ(Status::CANCELLED, bad.status());\n}\n\nTEST(StatusOr, TestValue) {\n  const int kI = 4;\n  StatusOr<int> thing(kI);\n  EXPECT_EQ(kI, thing.ValueOrDie());\n}\n\nTEST(StatusOr, TestValueConst) {\n  const int kI = 4;\n  const StatusOr<int> thing(kI);\n  EXPECT_EQ(kI, thing.ValueOrDie());\n}\n\nTEST(StatusOr, TestPointerDefaultCtor) {\n  StatusOr<int*> thing;\n  EXPECT_FALSE(thing.ok());\n  EXPECT_EQ(Status::UNKNOWN, thing.status());\n}\n\nTEST(StatusOr, TestPointerStatusCtor) {\n  StatusOr<int*> thing(Status::CANCELLED);\n  EXPECT_FALSE(thing.ok());\n  EXPECT_EQ(Status::CANCELLED, thing.status());\n}\n\nTEST(StatusOr, TestPointerValueCtor) {\n  const int kI = 4;\n  StatusOr<const int*> thing(&kI);\n  EXPECT_TRUE(thing.ok());\n  EXPECT_EQ(&kI, thing.ValueOrDie());\n}\n\nTEST(StatusOr, TestPointerCopyCtorStatusOk) {\n  const int kI = 0;\n  StatusOr<const int*> original(&kI);\n  StatusOr<const int*> copy(original);\n  EXPECT_EQ(original.status(), copy.status());\n  EXPECT_EQ(original.ValueOrDie(), copy.ValueOrDie());\n}\n\nTEST(StatusOr, TestPointerCopyCtorStatusNotOk) {\n  StatusOr<int*> original(Status::CANCELLED);\n  StatusOr<int*> copy(original);\n  EXPECT_EQ(original.status(), copy.status());\n}\n\nTEST(StatusOr, TestPointerCopyCtorStatusOKConverting) {\n  Derived derived;\n  StatusOr<Derived*> original(&derived);\n  StatusOr<Base2*>   copy(original);\n  EXPECT_EQ(original.status(), copy.status());\n  EXPECT_EQ(static_cast<const Base2*>(original.ValueOrDie()),\n            copy.ValueOrDie());\n}\n\nTEST(StatusOr, TestPointerCopyCtorStatusNotOkConverting) {\n  StatusOr<Derived*> original(Status::CANCELLED);\n  StatusOr<Base2*>   copy(original);\n  EXPECT_EQ(original.status(), copy.status());\n}\n\nTEST(StatusOr, TestPointerAssignmentStatusOk) {\n  const int kI = 0;\n  StatusOr<const int*> source(&kI);\n  StatusOr<const int*> target;\n  target = source;\n  EXPECT_EQ(source.status(), target.status());\n  EXPECT_EQ(source.ValueOrDie(), target.ValueOrDie());\n}\n\nTEST(StatusOr, TestPointerAssignmentStatusNotOk) {\n  StatusOr<int*> source(Status::CANCELLED);\n  StatusOr<int*> target;\n  target = source;\n  EXPECT_EQ(source.status(), target.status());\n}\n\nTEST(StatusOr, TestPointerAssignmentStatusOKConverting) {\n  Derived derived;\n  StatusOr<Derived*> source(&derived);\n  StatusOr<Base2*>   target;\n  target = source;\n  EXPECT_EQ(source.status(), target.status());\n  EXPECT_EQ(static_cast<const Base2*>(source.ValueOrDie()),\n            target.ValueOrDie());\n}\n\nTEST(StatusOr, TestPointerAssignmentStatusNotOkConverting) {\n  StatusOr<Derived*> source(Status::CANCELLED);\n  StatusOr<Base2*>   target;\n  target = source;\n  EXPECT_EQ(source.status(), target.status());\n}\n\nTEST(StatusOr, TestPointerStatus) {\n  const int kI = 0;\n  StatusOr<const int*> good(&kI);\n  EXPECT_TRUE(good.ok());\n  StatusOr<const int*> bad(Status::CANCELLED);\n  EXPECT_EQ(Status::CANCELLED, bad.status());\n}\n\nTEST(StatusOr, TestPointerValue) {\n  const int kI = 0;\n  StatusOr<const int*> thing(&kI);\n  EXPECT_EQ(&kI, thing.ValueOrDie());\n}\n\nTEST(StatusOr, TestPointerValueConst) {\n  const int kI = 0;\n  const StatusOr<const int*> thing(&kI);\n  EXPECT_EQ(&kI, thing.ValueOrDie());\n}\n\n}  // namespace\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/stl_util.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// from google3/util/gtl/stl_util.h\n\n#ifndef GOOGLE_PROTOBUF_STUBS_STL_UTIL_H__\n#define GOOGLE_PROTOBUF_STUBS_STL_UTIL_H__\n\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\n\n// STLDeleteContainerPointers()\n//  For a range within a container of pointers, calls delete\n//  (non-array version) on these pointers.\n// NOTE: for these three functions, we could just implement a DeleteObject\n// functor and then call for_each() on the range and functor, but this\n// requires us to pull in all of algorithm.h, which seems expensive.\n// For hash_[multi]set, it is important that this deletes behind the iterator\n// because the hash_set may call the hash function on the iterator when it is\n// advanced, which could result in the hash function trying to deference a\n// stale pointer.\ntemplate <class ForwardIterator>\nvoid STLDeleteContainerPointers(ForwardIterator begin,\n                                ForwardIterator end) {\n  while (begin != end) {\n    ForwardIterator temp = begin;\n    ++begin;\n    delete *temp;\n  }\n}\n\n// Inside Google, this function implements a horrible, disgusting hack in which\n// we reach into the string's private implementation and resize it without\n// initializing the new bytes.  In some cases doing this can significantly\n// improve performance.  However, since it's totally non-portable it has no\n// place in open source code.  Feel free to fill this function in with your\n// own disgusting hack if you want the perf boost.\ninline void STLStringResizeUninitialized(string* s, size_t new_size) {\n  s->resize(new_size);\n}\n\n// Return a mutable char* pointing to a string's internal buffer,\n// which may not be null-terminated. Writing through this pointer will\n// modify the string.\n//\n// string_as_array(&str)[i] is valid for 0 <= i < str.size() until the\n// next call to a string method that invalidates iterators.\n//\n// As of 2006-04, there is no standard-blessed way of getting a\n// mutable reference to a string's internal buffer. However, issue 530\n// (http://www.open-std.org/JTC1/SC22/WG21/docs/lwg-active.html#530)\n// proposes this as the method. According to Matt Austern, this should\n// already work on all current implementations.\ninline char* string_as_array(string* str) {\n  // DO NOT USE const_cast<char*>(str->data())! See the unittest for why.\n  return str->empty() ? NULL : &*str->begin();\n}\n\n// STLDeleteElements() deletes all the elements in an STL container and clears\n// the container.  This function is suitable for use with a vector, set,\n// hash_set, or any other STL container which defines sensible begin(), end(),\n// and clear() methods.\n//\n// If container is NULL, this function is a no-op.\n//\n// As an alternative to calling STLDeleteElements() directly, consider\n// ElementDeleter (defined below), which ensures that your container's elements\n// are deleted when the ElementDeleter goes out of scope.\ntemplate <class T>\nvoid STLDeleteElements(T *container) {\n  if (!container) return;\n  STLDeleteContainerPointers(container->begin(), container->end());\n  container->clear();\n}\n\n// Given an STL container consisting of (key, value) pairs, STLDeleteValues\n// deletes all the \"value\" components and clears the container.  Does nothing\n// in the case it's given a NULL pointer.\n\ntemplate <class T>\nvoid STLDeleteValues(T *v) {\n  if (!v) return;\n  for (typename T::iterator i = v->begin(); i != v->end(); ++i) {\n    delete i->second;\n  }\n  v->clear();\n}\n\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_STUBS_STL_UTIL_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/stringpiece.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n#include <google/protobuf/stubs/stringpiece.h>\n\n#include <string.h>\n#include <algorithm>\n#include <climits>\n#include <string>\n#include <ostream>\n\nnamespace google {\nnamespace protobuf {\nstd::ostream& operator<<(std::ostream& o, StringPiece piece) {\n  o.write(piece.data(), piece.size());\n  return o;\n}\n\n// Out-of-line error path.\nvoid StringPiece::LogFatalSizeTooBig(size_t size, const char* details) {\n  GOOGLE_LOG(FATAL) << \"size too big: \" << size << \" details: \" << details;\n}\n\nStringPiece::StringPiece(StringPiece x, stringpiece_ssize_type pos)\n    : ptr_(x.ptr_ + pos), length_(x.length_ - pos) {\n  GOOGLE_DCHECK_LE(0, pos);\n  GOOGLE_DCHECK_LE(pos, x.length_);\n}\n\nStringPiece::StringPiece(StringPiece x,\n                         stringpiece_ssize_type pos,\n                         stringpiece_ssize_type len)\n    : ptr_(x.ptr_ + pos), length_(std::min(len, x.length_ - pos)) {\n  GOOGLE_DCHECK_LE(0, pos);\n  GOOGLE_DCHECK_LE(pos, x.length_);\n  GOOGLE_DCHECK_GE(len, 0);\n}\n\nvoid StringPiece::CopyToString(string* target) const {\n  target->assign(ptr_, length_);\n}\n\nvoid StringPiece::AppendToString(string* target) const {\n  target->append(ptr_, length_);\n}\n\nbool StringPiece::Consume(StringPiece x) {\n  if (starts_with(x)) {\n    ptr_ += x.length_;\n    length_ -= x.length_;\n    return true;\n  }\n  return false;\n}\n\nbool StringPiece::ConsumeFromEnd(StringPiece x) {\n  if (ends_with(x)) {\n    length_ -= x.length_;\n    return true;\n  }\n  return false;\n}\n\nstringpiece_ssize_type StringPiece::copy(char* buf,\n                                         size_type n,\n                                         size_type pos) const {\n  stringpiece_ssize_type ret = std::min(length_ - pos, n);\n  memcpy(buf, ptr_ + pos, ret);\n  return ret;\n}\n\nbool StringPiece::contains(StringPiece s) const {\n  return find(s, 0) != npos;\n}\n\nstringpiece_ssize_type StringPiece::find(StringPiece s, size_type pos) const {\n  if (length_ <= 0 || pos > static_cast<size_type>(length_)) {\n    if (length_ == 0 && pos == 0 && s.length_ == 0) return 0;\n    return npos;\n  }\n  const char *result = std::search(ptr_ + pos, ptr_ + length_,\n                                   s.ptr_, s.ptr_ + s.length_);\n  return result == ptr_ + length_ ? npos : result - ptr_;\n}\n\nstringpiece_ssize_type StringPiece::find(char c, size_type pos) const {\n  if (length_ <= 0 || pos >= static_cast<size_type>(length_)) {\n    return npos;\n  }\n  const char* result = static_cast<const char*>(\n      memchr(ptr_ + pos, c, length_ - pos));\n  return result != NULL ? result - ptr_ : npos;\n}\n\nstringpiece_ssize_type StringPiece::rfind(StringPiece s, size_type pos) const {\n  if (length_ < s.length_) return npos;\n  const size_t ulen = length_;\n  if (s.length_ == 0) return std::min(ulen, pos);\n\n  const char* last = ptr_ + std::min(ulen - s.length_, pos) + s.length_;\n  const char* result = std::find_end(ptr_, last, s.ptr_, s.ptr_ + s.length_);\n  return result != last ? result - ptr_ : npos;\n}\n\n// Search range is [0..pos] inclusive.  If pos == npos, search everything.\nstringpiece_ssize_type StringPiece::rfind(char c, size_type pos) const {\n  // Note: memrchr() is not available on Windows.\n  if (length_ <= 0) return npos;\n  for (stringpiece_ssize_type i =\n      std::min(pos, static_cast<size_type>(length_ - 1));\n       i >= 0; --i) {\n    if (ptr_[i] == c) {\n      return i;\n    }\n  }\n  return npos;\n}\n\n// For each character in characters_wanted, sets the index corresponding\n// to the ASCII code of that character to 1 in table.  This is used by\n// the find_.*_of methods below to tell whether or not a character is in\n// the lookup table in constant time.\n// The argument `table' must be an array that is large enough to hold all\n// the possible values of an unsigned char.  Thus it should be be declared\n// as follows:\n//   bool table[UCHAR_MAX + 1]\nstatic inline void BuildLookupTable(StringPiece characters_wanted,\n                                    bool* table) {\n  const stringpiece_ssize_type length = characters_wanted.length();\n  const char* const data = characters_wanted.data();\n  for (stringpiece_ssize_type i = 0; i < length; ++i) {\n    table[static_cast<unsigned char>(data[i])] = true;\n  }\n}\n\nstringpiece_ssize_type StringPiece::find_first_of(StringPiece s,\n                                                  size_type pos) const {\n  if (length_ <= 0 || s.length_ <= 0) {\n    return npos;\n  }\n  // Avoid the cost of BuildLookupTable() for a single-character search.\n  if (s.length_ == 1) return find_first_of(s.ptr_[0], pos);\n\n  bool lookup[UCHAR_MAX + 1] = { false };\n  BuildLookupTable(s, lookup);\n  for (stringpiece_ssize_type i = pos; i < length_; ++i) {\n    if (lookup[static_cast<unsigned char>(ptr_[i])]) {\n      return i;\n    }\n  }\n  return npos;\n}\n\nstringpiece_ssize_type StringPiece::find_first_not_of(StringPiece s,\n                                                      size_type pos) const {\n  if (length_ <= 0) return npos;\n  if (s.length_ <= 0) return 0;\n  // Avoid the cost of BuildLookupTable() for a single-character search.\n  if (s.length_ == 1) return find_first_not_of(s.ptr_[0], pos);\n\n  bool lookup[UCHAR_MAX + 1] = { false };\n  BuildLookupTable(s, lookup);\n  for (stringpiece_ssize_type i = pos; i < length_; ++i) {\n    if (!lookup[static_cast<unsigned char>(ptr_[i])]) {\n      return i;\n    }\n  }\n  return npos;\n}\n\nstringpiece_ssize_type StringPiece::find_first_not_of(char c,\n                                                      size_type pos) const {\n  if (length_ <= 0) return npos;\n\n  for (; pos < static_cast<size_type>(length_); ++pos) {\n    if (ptr_[pos] != c) {\n      return pos;\n    }\n  }\n  return npos;\n}\n\nstringpiece_ssize_type StringPiece::find_last_of(StringPiece s,\n                                                 size_type pos) const {\n  if (length_ <= 0 || s.length_ <= 0) return npos;\n  // Avoid the cost of BuildLookupTable() for a single-character search.\n  if (s.length_ == 1) return find_last_of(s.ptr_[0], pos);\n\n  bool lookup[UCHAR_MAX + 1] = { false };\n  BuildLookupTable(s, lookup);\n  for (stringpiece_ssize_type i =\n       std::min(pos, static_cast<size_type>(length_ - 1)); i >= 0; --i) {\n    if (lookup[static_cast<unsigned char>(ptr_[i])]) {\n      return i;\n    }\n  }\n  return npos;\n}\n\nstringpiece_ssize_type StringPiece::find_last_not_of(StringPiece s,\n                                                     size_type pos) const {\n  if (length_ <= 0) return npos;\n\n  stringpiece_ssize_type i = std::min(pos, static_cast<size_type>(length_ - 1));\n  if (s.length_ <= 0) return i;\n\n  // Avoid the cost of BuildLookupTable() for a single-character search.\n  if (s.length_ == 1) return find_last_not_of(s.ptr_[0], pos);\n\n  bool lookup[UCHAR_MAX + 1] = { false };\n  BuildLookupTable(s, lookup);\n  for (; i >= 0; --i) {\n    if (!lookup[static_cast<unsigned char>(ptr_[i])]) {\n      return i;\n    }\n  }\n  return npos;\n}\n\nstringpiece_ssize_type StringPiece::find_last_not_of(char c,\n                                                     size_type pos) const {\n  if (length_ <= 0) return npos;\n\n  for (stringpiece_ssize_type i =\n       std::min(pos, static_cast<size_type>(length_ - 1)); i >= 0; --i) {\n    if (ptr_[i] != c) {\n      return i;\n    }\n  }\n  return npos;\n}\n\nStringPiece StringPiece::substr(size_type pos, size_type n) const {\n  if (pos > length_) pos = length_;\n  if (n > length_ - pos) n = length_ - pos;\n  return StringPiece(ptr_ + pos, n);\n}\n\nconst StringPiece::size_type StringPiece::npos = size_type(-1);\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/stringpiece.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A StringPiece points to part or all of a string, Cord, double-quoted string\n// literal, or other string-like object.  A StringPiece does *not* own the\n// string to which it points.  A StringPiece is not null-terminated.\n//\n// You can use StringPiece as a function or method parameter.  A StringPiece\n// parameter can receive a double-quoted string literal argument, a \"const\n// char*\" argument, a string argument, or a StringPiece argument with no data\n// copying.  Systematic use of StringPiece for arguments reduces data\n// copies and strlen() calls.\n//\n// Prefer passing StringPieces by value:\n//   void MyFunction(StringPiece arg);\n// If circumstances require, you may also pass by const reference:\n//   void MyFunction(const StringPiece& arg);  // not preferred\n// Both of these have the same lifetime semantics.  Passing by value\n// generates slightly smaller code.  For more discussion, see the thread\n// go/stringpiecebyvalue on c-users.\n//\n// StringPiece is also suitable for local variables if you know that\n// the lifetime of the underlying object is longer than the lifetime\n// of your StringPiece variable.\n//\n// Beware of binding a StringPiece to a temporary:\n//   StringPiece sp = obj.MethodReturningString();  // BAD: lifetime problem\n//\n// This code is okay:\n//   string str = obj.MethodReturningString();  // str owns its contents\n//   StringPiece sp(str);  // GOOD, because str outlives sp\n//\n// StringPiece is sometimes a poor choice for a return value and usually a poor\n// choice for a data member.  If you do use a StringPiece this way, it is your\n// responsibility to ensure that the object pointed to by the StringPiece\n// outlives the StringPiece.\n//\n// A StringPiece may represent just part of a string; thus the name \"Piece\".\n// For example, when splitting a string, vector<StringPiece> is a natural data\n// type for the output.  For another example, a Cord is a non-contiguous,\n// potentially very long string-like object.  The Cord class has an interface\n// that iteratively provides StringPiece objects that point to the\n// successive pieces of a Cord object.\n//\n// A StringPiece is not null-terminated.  If you write code that scans a\n// StringPiece, you must check its length before reading any characters.\n// Common idioms that work on null-terminated strings do not work on\n// StringPiece objects.\n//\n// There are several ways to create a null StringPiece:\n//   StringPiece()\n//   StringPiece(NULL)\n//   StringPiece(NULL, 0)\n// For all of the above, sp.data() == NULL, sp.length() == 0,\n// and sp.empty() == true.  Also, if you create a StringPiece with\n// a non-NULL pointer then sp.data() != NULL.  Once created,\n// sp.data() will stay either NULL or not-NULL, except if you call\n// sp.clear() or sp.set().\n//\n// Thus, you can use StringPiece(NULL) to signal an out-of-band value\n// that is different from other StringPiece values.  This is similar\n// to the way that const char* p1 = NULL; is different from\n// const char* p2 = \"\";.\n//\n// There are many ways to create an empty StringPiece:\n//   StringPiece()\n//   StringPiece(NULL)\n//   StringPiece(NULL, 0)\n//   StringPiece(\"\")\n//   StringPiece(\"\", 0)\n//   StringPiece(\"abcdef\", 0)\n//   StringPiece(\"abcdef\"+6, 0)\n// For all of the above, sp.length() will be 0 and sp.empty() will be true.\n// For some empty StringPiece values, sp.data() will be NULL.\n// For some empty StringPiece values, sp.data() will not be NULL.\n//\n// Be careful not to confuse: null StringPiece and empty StringPiece.\n// The set of empty StringPieces properly includes the set of null StringPieces.\n// That is, every null StringPiece is an empty StringPiece,\n// but some non-null StringPieces are empty Stringpieces too.\n//\n// All empty StringPiece values compare equal to each other.\n// Even a null StringPieces compares equal to a non-null empty StringPiece:\n//  StringPiece() == StringPiece(\"\", 0)\n//  StringPiece(NULL) == StringPiece(\"abc\", 0)\n//  StringPiece(NULL, 0) == StringPiece(\"abcdef\"+6, 0)\n//\n// Look carefully at this example:\n//   StringPiece(\"\") == NULL\n// True or false?  TRUE, because StringPiece::operator== converts\n// the right-hand side from NULL to StringPiece(NULL),\n// and then compares two zero-length spans of characters.\n// However, we are working to make this example produce a compile error.\n//\n// Suppose you want to write:\n//   bool TestWhat?(StringPiece sp) { return sp == NULL; }  // BAD\n// Do not do that.  Write one of these instead:\n//   bool TestNull(StringPiece sp) { return sp.data() == NULL; }\n//   bool TestEmpty(StringPiece sp) { return sp.empty(); }\n// The intent of TestWhat? is unclear.  Did you mean TestNull or TestEmpty?\n// Right now, TestWhat? behaves likes TestEmpty.\n// We are working to make TestWhat? produce a compile error.\n// TestNull is good to test for an out-of-band signal.\n// TestEmpty is good to test for an empty StringPiece.\n//\n// Caveats (again):\n// (1) The lifetime of the pointed-to string (or piece of a string)\n//     must be longer than the lifetime of the StringPiece.\n// (2) There may or may not be a '\\0' character after the end of\n//     StringPiece data.\n// (3) A null StringPiece is empty.\n//     An empty StringPiece may or may not be a null StringPiece.\n\n#ifndef GOOGLE_PROTOBUF_STUBS_STRINGPIECE_H_\n#define GOOGLE_PROTOBUF_STUBS_STRINGPIECE_H_\n\n#include <assert.h>\n#include <stddef.h>\n#include <string.h>\n#include <iosfwd>\n#include <limits>\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/hash.h>\n\nnamespace google {\nnamespace protobuf {\n// StringPiece has *two* size types.\n// StringPiece::size_type\n//   is unsigned\n//   is 32 bits in LP32, 64 bits in LP64, 64 bits in LLP64\n//   no future changes intended\n// stringpiece_ssize_type\n//   is signed\n//   is 32 bits in LP32, 64 bits in LP64, 64 bits in LLP64\n//   future changes intended: http://go/64BitStringPiece\n//\ntypedef string::difference_type stringpiece_ssize_type;\n\n// STRINGPIECE_CHECK_SIZE protects us from 32-bit overflows.\n// TODO(mec): delete this after stringpiece_ssize_type goes 64 bit.\n#if !defined(NDEBUG)\n#define STRINGPIECE_CHECK_SIZE 1\n#elif defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0\n#define STRINGPIECE_CHECK_SIZE 1\n#else\n#define STRINGPIECE_CHECK_SIZE 0\n#endif\n\nclass LIBPROTOBUF_EXPORT StringPiece {\n private:\n  const char* ptr_;\n  stringpiece_ssize_type length_;\n\n  // Prevent overflow in debug mode or fortified mode.\n  // sizeof(stringpiece_ssize_type) may be smaller than sizeof(size_t).\n  static stringpiece_ssize_type CheckedSsizeTFromSizeT(size_t size) {\n#if STRINGPIECE_CHECK_SIZE > 0\n#ifdef max\n#undef max\n#endif\n    if (size > static_cast<size_t>(\n        std::numeric_limits<stringpiece_ssize_type>::max())) {\n      // Some people grep for this message in logs\n      // so take care if you ever change it.\n      LogFatalSizeTooBig(size, \"size_t to int conversion\");\n    }\n#endif\n    return static_cast<stringpiece_ssize_type>(size);\n  }\n\n  // Out-of-line error path.\n  static void LogFatalSizeTooBig(size_t size, const char* details);\n\n public:\n  // We provide non-explicit singleton constructors so users can pass\n  // in a \"const char*\" or a \"string\" wherever a \"StringPiece\" is\n  // expected.\n  //\n  // Style guide exception granted:\n  // http://goto/style-guide-exception-20978288\n  StringPiece() : ptr_(NULL), length_(0) {}\n\n  StringPiece(const char* str)  // NOLINT(runtime/explicit)\n      : ptr_(str), length_(0) {\n    if (str != NULL) {\n      length_ = CheckedSsizeTFromSizeT(strlen(str));\n    }\n  }\n\n  template <class Allocator>\n  StringPiece(  // NOLINT(runtime/explicit)\n      const std::basic_string<char, std::char_traits<char>, Allocator>& str)\n      : ptr_(str.data()), length_(0) {\n    length_ = CheckedSsizeTFromSizeT(str.size());\n  }\n\n  StringPiece(const char* offset, stringpiece_ssize_type len)\n      : ptr_(offset), length_(len) {\n    assert(len >= 0);\n  }\n\n  // Substring of another StringPiece.\n  // pos must be non-negative and <= x.length().\n  StringPiece(StringPiece x, stringpiece_ssize_type pos);\n  // Substring of another StringPiece.\n  // pos must be non-negative and <= x.length().\n  // len must be non-negative and will be pinned to at most x.length() - pos.\n  StringPiece(StringPiece x,\n              stringpiece_ssize_type pos,\n              stringpiece_ssize_type len);\n\n  // data() may return a pointer to a buffer with embedded NULs, and the\n  // returned buffer may or may not be null terminated.  Therefore it is\n  // typically a mistake to pass data() to a routine that expects a NUL\n  // terminated string.\n  const char* data() const { return ptr_; }\n  stringpiece_ssize_type size() const { return length_; }\n  stringpiece_ssize_type length() const { return length_; }\n  bool empty() const { return length_ == 0; }\n\n  void clear() {\n    ptr_ = NULL;\n    length_ = 0;\n  }\n\n  void set(const char* data, stringpiece_ssize_type len) {\n    assert(len >= 0);\n    ptr_ = data;\n    length_ = len;\n  }\n\n  void set(const char* str) {\n    ptr_ = str;\n    if (str != NULL)\n      length_ = CheckedSsizeTFromSizeT(strlen(str));\n    else\n      length_ = 0;\n  }\n\n  void set(const void* data, stringpiece_ssize_type len) {\n    ptr_ = reinterpret_cast<const char*>(data);\n    length_ = len;\n  }\n\n  char operator[](stringpiece_ssize_type i) const {\n    assert(0 <= i);\n    assert(i < length_);\n    return ptr_[i];\n  }\n\n  void remove_prefix(stringpiece_ssize_type n) {\n    assert(length_ >= n);\n    ptr_ += n;\n    length_ -= n;\n  }\n\n  void remove_suffix(stringpiece_ssize_type n) {\n    assert(length_ >= n);\n    length_ -= n;\n  }\n\n  // returns {-1, 0, 1}\n  int compare(StringPiece x) const {\n    const stringpiece_ssize_type min_size =\n        length_ < x.length_ ? length_ : x.length_;\n    int r = memcmp(ptr_, x.ptr_, min_size);\n    if (r < 0) return -1;\n    if (r > 0) return 1;\n    if (length_ < x.length_) return -1;\n    if (length_ > x.length_) return 1;\n    return 0;\n  }\n\n  string as_string() const {\n    return ToString();\n  }\n  // We also define ToString() here, since many other string-like\n  // interfaces name the routine that converts to a C++ string\n  // \"ToString\", and it's confusing to have the method that does that\n  // for a StringPiece be called \"as_string()\".  We also leave the\n  // \"as_string()\" method defined here for existing code.\n  string ToString() const {\n    if (ptr_ == NULL) return string();\n    return string(data(), size());\n  }\n\n  operator string() const {\n    return ToString();\n  }\n\n  void CopyToString(string* target) const;\n  void AppendToString(string* target) const;\n\n  bool starts_with(StringPiece x) const {\n    return (length_ >= x.length_) && (memcmp(ptr_, x.ptr_, x.length_) == 0);\n  }\n\n  bool ends_with(StringPiece x) const {\n    return ((length_ >= x.length_) &&\n            (memcmp(ptr_ + (length_-x.length_), x.ptr_, x.length_) == 0));\n  }\n\n  // Checks whether StringPiece starts with x and if so advances the beginning\n  // of it to past the match.  It's basically a shortcut for starts_with\n  // followed by remove_prefix.\n  bool Consume(StringPiece x);\n  // Like above but for the end of the string.\n  bool ConsumeFromEnd(StringPiece x);\n\n  // standard STL container boilerplate\n  typedef char value_type;\n  typedef const char* pointer;\n  typedef const char& reference;\n  typedef const char& const_reference;\n  typedef size_t size_type;\n  typedef ptrdiff_t difference_type;\n  static const size_type npos;\n  typedef const char* const_iterator;\n  typedef const char* iterator;\n  typedef std::reverse_iterator<const_iterator> const_reverse_iterator;\n  typedef std::reverse_iterator<iterator> reverse_iterator;\n  iterator begin() const { return ptr_; }\n  iterator end() const { return ptr_ + length_; }\n  const_reverse_iterator rbegin() const {\n    return const_reverse_iterator(ptr_ + length_);\n  }\n  const_reverse_iterator rend() const {\n    return const_reverse_iterator(ptr_);\n  }\n  stringpiece_ssize_type max_size() const { return length_; }\n  stringpiece_ssize_type capacity() const { return length_; }\n\n  // cpplint.py emits a false positive [build/include_what_you_use]\n  stringpiece_ssize_type copy(char* buf, size_type n, size_type pos = 0) const;  // NOLINT\n\n  bool contains(StringPiece s) const;\n\n  stringpiece_ssize_type find(StringPiece s, size_type pos = 0) const;\n  stringpiece_ssize_type find(char c, size_type pos = 0) const;\n  stringpiece_ssize_type rfind(StringPiece s, size_type pos = npos) const;\n  stringpiece_ssize_type rfind(char c, size_type pos = npos) const;\n\n  stringpiece_ssize_type find_first_of(StringPiece s, size_type pos = 0) const;\n  stringpiece_ssize_type find_first_of(char c, size_type pos = 0) const {\n    return find(c, pos);\n  }\n  stringpiece_ssize_type find_first_not_of(StringPiece s,\n                                           size_type pos = 0) const;\n  stringpiece_ssize_type find_first_not_of(char c, size_type pos = 0) const;\n  stringpiece_ssize_type find_last_of(StringPiece s,\n                                      size_type pos = npos) const;\n  stringpiece_ssize_type find_last_of(char c, size_type pos = npos) const {\n    return rfind(c, pos);\n  }\n  stringpiece_ssize_type find_last_not_of(StringPiece s,\n                                          size_type pos = npos) const;\n  stringpiece_ssize_type find_last_not_of(char c, size_type pos = npos) const;\n\n  StringPiece substr(size_type pos, size_type n = npos) const;\n};\n\n// This large function is defined inline so that in a fairly common case where\n// one of the arguments is a literal, the compiler can elide a lot of the\n// following comparisons.\ninline bool operator==(StringPiece x, StringPiece y) {\n  stringpiece_ssize_type len = x.size();\n  if (len != y.size()) {\n    return false;\n  }\n\n  return x.data() == y.data() || len <= 0 ||\n      memcmp(x.data(), y.data(), len) == 0;\n}\n\ninline bool operator!=(StringPiece x, StringPiece y) {\n  return !(x == y);\n}\n\ninline bool operator<(StringPiece x, StringPiece y) {\n  const stringpiece_ssize_type min_size =\n      x.size() < y.size() ? x.size() : y.size();\n  const int r = memcmp(x.data(), y.data(), min_size);\n  return (r < 0) || (r == 0 && x.size() < y.size());\n}\n\ninline bool operator>(StringPiece x, StringPiece y) {\n  return y < x;\n}\n\ninline bool operator<=(StringPiece x, StringPiece y) {\n  return !(x > y);\n}\n\ninline bool operator>=(StringPiece x, StringPiece y) {\n  return !(x < y);\n}\n\n// allow StringPiece to be logged\nextern std::ostream& operator<<(std::ostream& o, StringPiece piece);\n\nnamespace internal {\n// StringPiece is not a POD and can not be used in an union (pre C++11). We\n// need a POD version of it.\nstruct StringPiecePod {\n  // Create from a StringPiece.\n  static StringPiecePod CreateFromStringPiece(StringPiece str) {\n    StringPiecePod pod;\n    pod.data_ = str.data();\n    pod.size_ = str.size();\n    return pod;\n  }\n\n  // Cast to StringPiece.\n  operator StringPiece() const { return StringPiece(data_, size_); }\n\n  bool operator==(const char* value) const {\n    return StringPiece(data_, size_) == StringPiece(value);\n  }\n\n  char operator[](stringpiece_ssize_type i) const {\n    assert(0 <= i);\n    assert(i < size_);\n    return data_[i];\n  }\n\n  const char* data() const { return data_; }\n\n  stringpiece_ssize_type size() const {\n    return size_;\n  }\n\n  std::string ToString() const { return std::string(data_, size_); }\n private:\n  const char* data_;\n  stringpiece_ssize_type size_;\n};\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\nGOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_START\ntemplate<> struct hash<StringPiece> {\n  size_t operator()(const StringPiece& s) const {\n    size_t result = 0;\n    for (const char *str = s.data(), *end = str + s.size(); str < end; str++) {  \n      result = 5 * result + *str;\n    }\n    return result;\n  }\n};\nGOOGLE_PROTOBUF_HASH_NAMESPACE_DECLARATION_END\n\n#endif  // STRINGS_STRINGPIECE_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/stringpiece_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n#include <google/protobuf/stubs/stringpiece.h>\n\n#include <iterator>\n#include <map>\n#include <string>\n#include <utility>\n#include <vector>\n\n#include <google/protobuf/testing/googletest.h>\n#include <google/protobuf/stubs/hash.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace {\nTEST(StringPiece, Ctor) {\n  {\n    // Null.\n    StringPiece s10;\n    EXPECT_TRUE(s10.data() == NULL);\n    EXPECT_EQ(0, s10.length());\n  }\n\n  {\n    // const char* without length.\n    const char* hello = \"hello\";\n    StringPiece s20(hello);\n    EXPECT_TRUE(s20.data() == hello);\n    EXPECT_EQ(5, s20.length());\n\n    // const char* with length.\n    StringPiece s21(hello, 4);\n    EXPECT_TRUE(s21.data() == hello);\n    EXPECT_EQ(4, s21.length());\n\n    // Not recommended, but valid C++\n    StringPiece s22(hello, 6);\n    EXPECT_TRUE(s22.data() == hello);\n    EXPECT_EQ(6, s22.length());\n  }\n\n  {\n    // std::string.\n    std::string hola = \"hola\";\n    StringPiece s30(hola);\n    EXPECT_TRUE(s30.data() == hola.data());\n    EXPECT_EQ(4, s30.length());\n\n    // std::string with embedded '\\0'.\n    hola.push_back('\\0');\n    hola.append(\"h2\");\n    hola.push_back('\\0');\n    StringPiece s31(hola);\n    EXPECT_TRUE(s31.data() == hola.data());\n    EXPECT_EQ(8, s31.length());\n  }\n\n#if defined(HAS_GLOBAL_STRING)\n  {\n    // ::string\n    string bonjour = \"bonjour\";\n    StringPiece s40(bonjour);\n    EXPECT_TRUE(s40.data() == bonjour.data());\n    EXPECT_EQ(7, s40.length());\n  }\n#endif\n\n  // TODO(mec): StringPiece(StringPiece x, int pos);\n  // TODO(mec): StringPiece(StringPiece x, int pos, int len);\n  // TODO(mec): StringPiece(const StringPiece&);\n}\n\nTEST(StringPiece, STLComparator) {\n  string s1(\"foo\");\n  string s2(\"bar\");\n  string s3(\"baz\");\n\n  StringPiece p1(s1);\n  StringPiece p2(s2);\n  StringPiece p3(s3);\n\n  typedef std::map<StringPiece, int> TestMap;\n  TestMap map;\n\n  map.insert(std::make_pair(p1, 0));\n  map.insert(std::make_pair(p2, 1));\n  map.insert(std::make_pair(p3, 2));\n  EXPECT_EQ(map.size(), 3);\n\n  TestMap::const_iterator iter = map.begin();\n  EXPECT_EQ(iter->second, 1);\n  ++iter;\n  EXPECT_EQ(iter->second, 2);\n  ++iter;\n  EXPECT_EQ(iter->second, 0);\n  ++iter;\n  EXPECT_TRUE(iter == map.end());\n\n  TestMap::iterator new_iter = map.find(\"zot\");\n  EXPECT_TRUE(new_iter == map.end());\n\n  new_iter = map.find(\"bar\");\n  EXPECT_TRUE(new_iter != map.end());\n\n  map.erase(new_iter);\n  EXPECT_EQ(map.size(), 2);\n\n  iter = map.begin();\n  EXPECT_EQ(iter->second, 2);\n  ++iter;\n  EXPECT_EQ(iter->second, 0);\n  ++iter;\n  EXPECT_TRUE(iter == map.end());\n}\n\nTEST(StringPiece, ComparisonOperators) {\n#define COMPARE(result, op, x, y) \\\n  EXPECT_EQ(result, StringPiece((x)) op StringPiece((y))); \\\n  EXPECT_EQ(result, StringPiece((x)).compare(StringPiece((y))) op 0)\n\n  COMPARE(true, ==, \"\",   \"\");\n  COMPARE(true, ==, \"\", NULL);\n  COMPARE(true, ==, NULL, \"\");\n  COMPARE(true, ==, \"a\",  \"a\");\n  COMPARE(true, ==, \"aa\", \"aa\");\n  COMPARE(false, ==, \"a\",  \"\");\n  COMPARE(false, ==, \"\",   \"a\");\n  COMPARE(false, ==, \"a\",  \"b\");\n  COMPARE(false, ==, \"a\",  \"aa\");\n  COMPARE(false, ==, \"aa\", \"a\");\n\n  COMPARE(false, !=, \"\",   \"\");\n  COMPARE(false, !=, \"a\",  \"a\");\n  COMPARE(false, !=, \"aa\", \"aa\");\n  COMPARE(true, !=, \"a\",  \"\");\n  COMPARE(true, !=, \"\",   \"a\");\n  COMPARE(true, !=, \"a\",  \"b\");\n  COMPARE(true, !=, \"a\",  \"aa\");\n  COMPARE(true, !=, \"aa\", \"a\");\n\n  COMPARE(true, <, \"a\",  \"b\");\n  COMPARE(true, <, \"a\",  \"aa\");\n  COMPARE(true, <, \"aa\", \"b\");\n  COMPARE(true, <, \"aa\", \"bb\");\n  COMPARE(false, <, \"a\",  \"a\");\n  COMPARE(false, <, \"b\",  \"a\");\n  COMPARE(false, <, \"aa\", \"a\");\n  COMPARE(false, <, \"b\",  \"aa\");\n  COMPARE(false, <, \"bb\", \"aa\");\n\n  COMPARE(true, <=, \"a\",  \"a\");\n  COMPARE(true, <=, \"a\",  \"b\");\n  COMPARE(true, <=, \"a\",  \"aa\");\n  COMPARE(true, <=, \"aa\", \"b\");\n  COMPARE(true, <=, \"aa\", \"bb\");\n  COMPARE(false, <=, \"b\",  \"a\");\n  COMPARE(false, <=, \"aa\", \"a\");\n  COMPARE(false, <=, \"b\",  \"aa\");\n  COMPARE(false, <=, \"bb\", \"aa\");\n\n  COMPARE(false, >=, \"a\",  \"b\");\n  COMPARE(false, >=, \"a\",  \"aa\");\n  COMPARE(false, >=, \"aa\", \"b\");\n  COMPARE(false, >=, \"aa\", \"bb\");\n  COMPARE(true, >=, \"a\",  \"a\");\n  COMPARE(true, >=, \"b\",  \"a\");\n  COMPARE(true, >=, \"aa\", \"a\");\n  COMPARE(true, >=, \"b\",  \"aa\");\n  COMPARE(true, >=, \"bb\", \"aa\");\n\n  COMPARE(false, >, \"a\",  \"a\");\n  COMPARE(false, >, \"a\",  \"b\");\n  COMPARE(false, >, \"a\",  \"aa\");\n  COMPARE(false, >, \"aa\", \"b\");\n  COMPARE(false, >, \"aa\", \"bb\");\n  COMPARE(true, >, \"b\",  \"a\");\n  COMPARE(true, >, \"aa\", \"a\");\n  COMPARE(true, >, \"b\",  \"aa\");\n  COMPARE(true, >, \"bb\", \"aa\");\n\n  string x;\n  for (int i = 0; i < 256; i++) {\n    x += 'a';\n    string y = x;\n    COMPARE(true, ==, x, y);\n    for (int j = 0; j < i; j++) {\n      string z = x;\n      z[j] = 'b';       // Differs in position 'j'\n      COMPARE(false, ==, x, z);\n      COMPARE(true, <, x, z);\n      COMPARE(true, >, z, x);\n      if (j + 1 < i) {\n        z[j + 1] = 'A';  // Differs in position 'j+1' as well\n        COMPARE(false, ==, x, z);\n        COMPARE(true, <, x, z);\n        COMPARE(true, >, z, x);\n        z[j + 1] = 'z';  // Differs in position 'j+1' as well\n        COMPARE(false, ==, x, z);\n        COMPARE(true, <, x, z);\n        COMPARE(true, >, z, x);\n      }\n    }\n  }\n\n#undef COMPARE\n}\n\nTEST(StringPiece, STL1) {\n  const StringPiece a(\"abcdefghijklmnopqrstuvwxyz\");\n  const StringPiece b(\"abc\");\n  const StringPiece c(\"xyz\");\n  const StringPiece d(\"foobar\");\n  const StringPiece e;\n  string temp(\"123\");\n  temp += '\\0';\n  temp += \"456\";\n  const StringPiece f(temp);\n\n  EXPECT_EQ(a[6], 'g');\n  EXPECT_EQ(b[0], 'a');\n  EXPECT_EQ(c[2], 'z');\n  EXPECT_EQ(f[3], '\\0');\n  EXPECT_EQ(f[5], '5');\n\n  EXPECT_EQ(*d.data(), 'f');\n  EXPECT_EQ(d.data()[5], 'r');\n  EXPECT_TRUE(e.data() == NULL);\n\n  EXPECT_EQ(*a.begin(), 'a');\n  EXPECT_EQ(*(b.begin() + 2), 'c');\n  EXPECT_EQ(*(c.end() - 1), 'z');\n\n  EXPECT_EQ(*a.rbegin(), 'z');\n  EXPECT_EQ(*(b.rbegin() + 2), 'a');\n  EXPECT_EQ(*(c.rend() - 1), 'x');\n  EXPECT_TRUE(a.rbegin() + 26 == a.rend());\n\n  EXPECT_EQ(a.size(), 26);\n  EXPECT_EQ(b.size(), 3);\n  EXPECT_EQ(c.size(), 3);\n  EXPECT_EQ(d.size(), 6);\n  EXPECT_EQ(e.size(), 0);\n  EXPECT_EQ(f.size(), 7);\n\n  EXPECT_TRUE(!d.empty());\n  EXPECT_TRUE(d.begin() != d.end());\n  EXPECT_TRUE(d.begin() + 6 == d.end());\n\n  EXPECT_TRUE(e.empty());\n  EXPECT_TRUE(e.begin() == e.end());\n\n  EXPECT_GE(a.max_size(), a.capacity());\n  EXPECT_GE(a.capacity(), a.size());\n\n  char buf[4] = { '%', '%', '%', '%' };\n  EXPECT_EQ(a.copy(buf, 4), 4);\n  EXPECT_EQ(buf[0], a[0]);\n  EXPECT_EQ(buf[1], a[1]);\n  EXPECT_EQ(buf[2], a[2]);\n  EXPECT_EQ(buf[3], a[3]);\n  EXPECT_EQ(a.copy(buf, 3, 7), 3);\n  EXPECT_EQ(buf[0], a[7]);\n  EXPECT_EQ(buf[1], a[8]);\n  EXPECT_EQ(buf[2], a[9]);\n  EXPECT_EQ(buf[3], a[3]);\n  EXPECT_EQ(c.copy(buf, 99), 3);\n  EXPECT_EQ(buf[0], c[0]);\n  EXPECT_EQ(buf[1], c[1]);\n  EXPECT_EQ(buf[2], c[2]);\n  EXPECT_EQ(buf[3], a[3]);\n}\n\n// Separated from STL1() because some compilers produce an overly\n// large stack frame for the combined function.\nTEST(StringPiece, STL2) {\n  const StringPiece a(\"abcdefghijklmnopqrstuvwxyz\");\n  const StringPiece b(\"abc\");\n  const StringPiece c(\"xyz\");\n  StringPiece d(\"foobar\");\n  const StringPiece e;\n  const StringPiece f(\"123\" \"\\0\" \"456\", 7);\n\n  d.clear();\n  EXPECT_EQ(d.size(), 0);\n  EXPECT_TRUE(d.empty());\n  EXPECT_TRUE(d.data() == NULL);\n  EXPECT_TRUE(d.begin() == d.end());\n\n  EXPECT_EQ(StringPiece::npos, string::npos);\n\n  EXPECT_EQ(a.find(b), 0);\n  EXPECT_EQ(a.find(b, 1), StringPiece::npos);\n  EXPECT_EQ(a.find(c), 23);\n  EXPECT_EQ(a.find(c, 9), 23);\n  EXPECT_EQ(a.find(c, StringPiece::npos), StringPiece::npos);\n  EXPECT_EQ(b.find(c), StringPiece::npos);\n  EXPECT_EQ(b.find(c, StringPiece::npos), StringPiece::npos);\n  EXPECT_EQ(a.find(d), 0);\n  EXPECT_EQ(a.find(e), 0);\n  EXPECT_EQ(a.find(d, 12), 12);\n  EXPECT_EQ(a.find(e, 17), 17);\n  StringPiece g(\"xx not found bb\");\n  EXPECT_EQ(a.find(g), StringPiece::npos);\n  // empty string nonsense\n  EXPECT_EQ(d.find(b), StringPiece::npos);\n  EXPECT_EQ(e.find(b), StringPiece::npos);\n  EXPECT_EQ(d.find(b, 4), StringPiece::npos);\n  EXPECT_EQ(e.find(b, 7), StringPiece::npos);\n\n  size_t empty_search_pos = string().find(string());\n  EXPECT_EQ(d.find(d), empty_search_pos);\n  EXPECT_EQ(d.find(e), empty_search_pos);\n  EXPECT_EQ(e.find(d), empty_search_pos);\n  EXPECT_EQ(e.find(e), empty_search_pos);\n  EXPECT_EQ(d.find(d, 4), string().find(string(), 4));\n  EXPECT_EQ(d.find(e, 4), string().find(string(), 4));\n  EXPECT_EQ(e.find(d, 4), string().find(string(), 4));\n  EXPECT_EQ(e.find(e, 4), string().find(string(), 4));\n\n  EXPECT_EQ(a.find('a'), 0);\n  EXPECT_EQ(a.find('c'), 2);\n  EXPECT_EQ(a.find('z'), 25);\n  EXPECT_EQ(a.find('$'), StringPiece::npos);\n  EXPECT_EQ(a.find('\\0'), StringPiece::npos);\n  EXPECT_EQ(f.find('\\0'), 3);\n  EXPECT_EQ(f.find('3'), 2);\n  EXPECT_EQ(f.find('5'), 5);\n  EXPECT_EQ(g.find('o'), 4);\n  EXPECT_EQ(g.find('o', 4), 4);\n  EXPECT_EQ(g.find('o', 5), 8);\n  EXPECT_EQ(a.find('b', 5), StringPiece::npos);\n  // empty string nonsense\n  EXPECT_EQ(d.find('\\0'), StringPiece::npos);\n  EXPECT_EQ(e.find('\\0'), StringPiece::npos);\n  EXPECT_EQ(d.find('\\0', 4), StringPiece::npos);\n  EXPECT_EQ(e.find('\\0', 7), StringPiece::npos);\n  EXPECT_EQ(d.find('x'), StringPiece::npos);\n  EXPECT_EQ(e.find('x'), StringPiece::npos);\n  EXPECT_EQ(d.find('x', 4), StringPiece::npos);\n  EXPECT_EQ(e.find('x', 7), StringPiece::npos);\n\n  EXPECT_EQ(a.rfind(b), 0);\n  EXPECT_EQ(a.rfind(b, 1), 0);\n  EXPECT_EQ(a.rfind(c), 23);\n  EXPECT_EQ(a.rfind(c, 22), StringPiece::npos);\n  EXPECT_EQ(a.rfind(c, 1), StringPiece::npos);\n  EXPECT_EQ(a.rfind(c, 0), StringPiece::npos);\n  EXPECT_EQ(b.rfind(c), StringPiece::npos);\n  EXPECT_EQ(b.rfind(c, 0), StringPiece::npos);\n  EXPECT_EQ(a.rfind(d), a.as_string().rfind(string()));\n  EXPECT_EQ(a.rfind(e), a.as_string().rfind(string()));\n  EXPECT_EQ(a.rfind(d, 12), 12);\n  EXPECT_EQ(a.rfind(e, 17), 17);\n  EXPECT_EQ(a.rfind(g), StringPiece::npos);\n  EXPECT_EQ(d.rfind(b), StringPiece::npos);\n  EXPECT_EQ(e.rfind(b), StringPiece::npos);\n  EXPECT_EQ(d.rfind(b, 4), StringPiece::npos);\n  EXPECT_EQ(e.rfind(b, 7), StringPiece::npos);\n  // empty string nonsense\n  EXPECT_EQ(d.rfind(d, 4), string().rfind(string()));\n  EXPECT_EQ(e.rfind(d, 7), string().rfind(string()));\n  EXPECT_EQ(d.rfind(e, 4), string().rfind(string()));\n  EXPECT_EQ(e.rfind(e, 7), string().rfind(string()));\n  EXPECT_EQ(d.rfind(d), string().rfind(string()));\n  EXPECT_EQ(e.rfind(d), string().rfind(string()));\n  EXPECT_EQ(d.rfind(e), string().rfind(string()));\n  EXPECT_EQ(e.rfind(e), string().rfind(string()));\n\n  EXPECT_EQ(g.rfind('o'), 8);\n  EXPECT_EQ(g.rfind('q'), StringPiece::npos);\n  EXPECT_EQ(g.rfind('o', 8), 8);\n  EXPECT_EQ(g.rfind('o', 7), 4);\n  EXPECT_EQ(g.rfind('o', 3), StringPiece::npos);\n  EXPECT_EQ(f.rfind('\\0'), 3);\n  EXPECT_EQ(f.rfind('\\0', 12), 3);\n  EXPECT_EQ(f.rfind('3'), 2);\n  EXPECT_EQ(f.rfind('5'), 5);\n  // empty string nonsense\n  EXPECT_EQ(d.rfind('o'), StringPiece::npos);\n  EXPECT_EQ(e.rfind('o'), StringPiece::npos);\n  EXPECT_EQ(d.rfind('o', 4), StringPiece::npos);\n  EXPECT_EQ(e.rfind('o', 7), StringPiece::npos);\n\n  EXPECT_EQ(a.find_first_of(b), 0);\n  EXPECT_EQ(a.find_first_of(b, 0), 0);\n  EXPECT_EQ(a.find_first_of(b, 1), 1);\n  EXPECT_EQ(a.find_first_of(b, 2), 2);\n  EXPECT_EQ(a.find_first_of(b, 3), StringPiece::npos);\n  EXPECT_EQ(a.find_first_of(c), 23);\n  EXPECT_EQ(a.find_first_of(c, 23), 23);\n  EXPECT_EQ(a.find_first_of(c, 24), 24);\n  EXPECT_EQ(a.find_first_of(c, 25), 25);\n  EXPECT_EQ(a.find_first_of(c, 26), StringPiece::npos);\n  EXPECT_EQ(g.find_first_of(b), 13);\n  EXPECT_EQ(g.find_first_of(c), 0);\n  EXPECT_EQ(a.find_first_of(f), StringPiece::npos);\n  EXPECT_EQ(f.find_first_of(a), StringPiece::npos);\n  // empty string nonsense\n  EXPECT_EQ(a.find_first_of(d), StringPiece::npos);\n  EXPECT_EQ(a.find_first_of(e), StringPiece::npos);\n  EXPECT_EQ(d.find_first_of(b), StringPiece::npos);\n  EXPECT_EQ(e.find_first_of(b), StringPiece::npos);\n  EXPECT_EQ(d.find_first_of(d), StringPiece::npos);\n  EXPECT_EQ(e.find_first_of(d), StringPiece::npos);\n  EXPECT_EQ(d.find_first_of(e), StringPiece::npos);\n  EXPECT_EQ(e.find_first_of(e), StringPiece::npos);\n\n  EXPECT_EQ(a.find_first_not_of(b), 3);\n  EXPECT_EQ(a.find_first_not_of(c), 0);\n  EXPECT_EQ(b.find_first_not_of(a), StringPiece::npos);\n  EXPECT_EQ(c.find_first_not_of(a), StringPiece::npos);\n  EXPECT_EQ(f.find_first_not_of(a), 0);\n  EXPECT_EQ(a.find_first_not_of(f), 0);\n  EXPECT_EQ(a.find_first_not_of(d), 0);\n  EXPECT_EQ(a.find_first_not_of(e), 0);\n  // empty string nonsense\n  EXPECT_EQ(d.find_first_not_of(a), StringPiece::npos);\n  EXPECT_EQ(e.find_first_not_of(a), StringPiece::npos);\n  EXPECT_EQ(d.find_first_not_of(d), StringPiece::npos);\n  EXPECT_EQ(e.find_first_not_of(d), StringPiece::npos);\n  EXPECT_EQ(d.find_first_not_of(e), StringPiece::npos);\n  EXPECT_EQ(e.find_first_not_of(e), StringPiece::npos);\n\n  StringPiece h(\"====\");\n  EXPECT_EQ(h.find_first_not_of('='), StringPiece::npos);\n  EXPECT_EQ(h.find_first_not_of('=', 3), StringPiece::npos);\n  EXPECT_EQ(h.find_first_not_of('\\0'), 0);\n  EXPECT_EQ(g.find_first_not_of('x'), 2);\n  EXPECT_EQ(f.find_first_not_of('\\0'), 0);\n  EXPECT_EQ(f.find_first_not_of('\\0', 3), 4);\n  EXPECT_EQ(f.find_first_not_of('\\0', 2), 2);\n  // empty string nonsense\n  EXPECT_EQ(d.find_first_not_of('x'), StringPiece::npos);\n  EXPECT_EQ(e.find_first_not_of('x'), StringPiece::npos);\n  EXPECT_EQ(d.find_first_not_of('\\0'), StringPiece::npos);\n  EXPECT_EQ(e.find_first_not_of('\\0'), StringPiece::npos);\n\n  //  StringPiece g(\"xx not found bb\");\n  StringPiece i(\"56\");\n  EXPECT_EQ(h.find_last_of(a), StringPiece::npos);\n  EXPECT_EQ(g.find_last_of(a), g.size()-1);\n  EXPECT_EQ(a.find_last_of(b), 2);\n  EXPECT_EQ(a.find_last_of(c), a.size()-1);\n  EXPECT_EQ(f.find_last_of(i), 6);\n  EXPECT_EQ(a.find_last_of('a'), 0);\n  EXPECT_EQ(a.find_last_of('b'), 1);\n  EXPECT_EQ(a.find_last_of('z'), 25);\n  EXPECT_EQ(a.find_last_of('a', 5), 0);\n  EXPECT_EQ(a.find_last_of('b', 5), 1);\n  EXPECT_EQ(a.find_last_of('b', 0), StringPiece::npos);\n  EXPECT_EQ(a.find_last_of('z', 25), 25);\n  EXPECT_EQ(a.find_last_of('z', 24), StringPiece::npos);\n  EXPECT_EQ(f.find_last_of(i, 5), 5);\n  EXPECT_EQ(f.find_last_of(i, 6), 6);\n  EXPECT_EQ(f.find_last_of(a, 4), StringPiece::npos);\n  // empty string nonsense\n  EXPECT_EQ(f.find_last_of(d), StringPiece::npos);\n  EXPECT_EQ(f.find_last_of(e), StringPiece::npos);\n  EXPECT_EQ(f.find_last_of(d, 4), StringPiece::npos);\n  EXPECT_EQ(f.find_last_of(e, 4), StringPiece::npos);\n  EXPECT_EQ(d.find_last_of(d), StringPiece::npos);\n  EXPECT_EQ(d.find_last_of(e), StringPiece::npos);\n  EXPECT_EQ(e.find_last_of(d), StringPiece::npos);\n  EXPECT_EQ(e.find_last_of(e), StringPiece::npos);\n  EXPECT_EQ(d.find_last_of(f), StringPiece::npos);\n  EXPECT_EQ(e.find_last_of(f), StringPiece::npos);\n  EXPECT_EQ(d.find_last_of(d, 4), StringPiece::npos);\n  EXPECT_EQ(d.find_last_of(e, 4), StringPiece::npos);\n  EXPECT_EQ(e.find_last_of(d, 4), StringPiece::npos);\n  EXPECT_EQ(e.find_last_of(e, 4), StringPiece::npos);\n  EXPECT_EQ(d.find_last_of(f, 4), StringPiece::npos);\n  EXPECT_EQ(e.find_last_of(f, 4), StringPiece::npos);\n\n  EXPECT_EQ(a.find_last_not_of(b), a.size()-1);\n  EXPECT_EQ(a.find_last_not_of(c), 22);\n  EXPECT_EQ(b.find_last_not_of(a), StringPiece::npos);\n  EXPECT_EQ(b.find_last_not_of(b), StringPiece::npos);\n  EXPECT_EQ(f.find_last_not_of(i), 4);\n  EXPECT_EQ(a.find_last_not_of(c, 24), 22);\n  EXPECT_EQ(a.find_last_not_of(b, 3), 3);\n  EXPECT_EQ(a.find_last_not_of(b, 2), StringPiece::npos);\n  // empty string nonsense\n  EXPECT_EQ(f.find_last_not_of(d), f.size()-1);\n  EXPECT_EQ(f.find_last_not_of(e), f.size()-1);\n  EXPECT_EQ(f.find_last_not_of(d, 4), 4);\n  EXPECT_EQ(f.find_last_not_of(e, 4), 4);\n  EXPECT_EQ(d.find_last_not_of(d), StringPiece::npos);\n  EXPECT_EQ(d.find_last_not_of(e), StringPiece::npos);\n  EXPECT_EQ(e.find_last_not_of(d), StringPiece::npos);\n  EXPECT_EQ(e.find_last_not_of(e), StringPiece::npos);\n  EXPECT_EQ(d.find_last_not_of(f), StringPiece::npos);\n  EXPECT_EQ(e.find_last_not_of(f), StringPiece::npos);\n  EXPECT_EQ(d.find_last_not_of(d, 4), StringPiece::npos);\n  EXPECT_EQ(d.find_last_not_of(e, 4), StringPiece::npos);\n  EXPECT_EQ(e.find_last_not_of(d, 4), StringPiece::npos);\n  EXPECT_EQ(e.find_last_not_of(e, 4), StringPiece::npos);\n  EXPECT_EQ(d.find_last_not_of(f, 4), StringPiece::npos);\n  EXPECT_EQ(e.find_last_not_of(f, 4), StringPiece::npos);\n\n  EXPECT_EQ(h.find_last_not_of('x'), h.size() - 1);\n  EXPECT_EQ(h.find_last_not_of('='), StringPiece::npos);\n  EXPECT_EQ(b.find_last_not_of('c'), 1);\n  EXPECT_EQ(h.find_last_not_of('x', 2), 2);\n  EXPECT_EQ(h.find_last_not_of('=', 2), StringPiece::npos);\n  EXPECT_EQ(b.find_last_not_of('b', 1), 0);\n  // empty string nonsense\n  EXPECT_EQ(d.find_last_not_of('x'), StringPiece::npos);\n  EXPECT_EQ(e.find_last_not_of('x'), StringPiece::npos);\n  EXPECT_EQ(d.find_last_not_of('\\0'), StringPiece::npos);\n  EXPECT_EQ(e.find_last_not_of('\\0'), StringPiece::npos);\n\n  EXPECT_EQ(a.substr(0, 3), b);\n  EXPECT_EQ(a.substr(23), c);\n  EXPECT_EQ(a.substr(23, 3), c);\n  EXPECT_EQ(a.substr(23, 99), c);\n  EXPECT_EQ(a.substr(0), a);\n  EXPECT_EQ(a.substr(3, 2), \"de\");\n  // empty string nonsense\n  EXPECT_EQ(a.substr(99, 2), e);\n  EXPECT_EQ(d.substr(99), e);\n  EXPECT_EQ(d.substr(0, 99), e);\n  EXPECT_EQ(d.substr(99, 99), e);\n  // use of npos\n  EXPECT_EQ(a.substr(0, StringPiece::npos), a);\n  EXPECT_EQ(a.substr(23, StringPiece::npos), c);\n  EXPECT_EQ(a.substr(StringPiece::npos, 0), e);\n  EXPECT_EQ(a.substr(StringPiece::npos, 1), e);\n  EXPECT_EQ(a.substr(StringPiece::npos, StringPiece::npos), e);\n\n  // Substring constructors.\n  EXPECT_EQ(StringPiece(a, 0, 3), b);\n  EXPECT_EQ(StringPiece(a, 23), c);\n  EXPECT_EQ(StringPiece(a, 23, 3), c);\n  EXPECT_EQ(StringPiece(a, 23, 99), c);\n  EXPECT_EQ(StringPiece(a, 0), a);\n  EXPECT_EQ(StringPiece(a, 3, 2), \"de\");\n  // empty string nonsense\n  EXPECT_EQ(StringPiece(d, 0, 99), e);\n  // Verify that they work taking an actual string, not just a StringPiece.\n  string a2 = a.as_string();\n  EXPECT_EQ(StringPiece(a2, 0, 3), b);\n  EXPECT_EQ(StringPiece(a2, 23), c);\n  EXPECT_EQ(StringPiece(a2, 23, 3), c);\n  EXPECT_EQ(StringPiece(a2, 23, 99), c);\n  EXPECT_EQ(StringPiece(a2, 0), a);\n  EXPECT_EQ(StringPiece(a2, 3, 2), \"de\");\n}\n\nTEST(StringPiece, Custom) {\n  StringPiece a(\"foobar\");\n  string s1(\"123\");\n  s1 += '\\0';\n  s1 += \"456\";\n  StringPiece b(s1);\n  StringPiece e;\n  string s2;\n\n  // CopyToString\n  a.CopyToString(&s2);\n  EXPECT_EQ(s2.size(), 6);\n  EXPECT_EQ(s2, \"foobar\");\n  b.CopyToString(&s2);\n  EXPECT_EQ(s2.size(), 7);\n  EXPECT_EQ(s1, s2);\n  e.CopyToString(&s2);\n  EXPECT_TRUE(s2.empty());\n\n  // AppendToString\n  s2.erase();\n  a.AppendToString(&s2);\n  EXPECT_EQ(s2.size(), 6);\n  EXPECT_EQ(s2, \"foobar\");\n  a.AppendToString(&s2);\n  EXPECT_EQ(s2.size(), 12);\n  EXPECT_EQ(s2, \"foobarfoobar\");\n\n  // starts_with\n  EXPECT_TRUE(a.starts_with(a));\n  EXPECT_TRUE(a.starts_with(\"foo\"));\n  EXPECT_TRUE(a.starts_with(e));\n  EXPECT_TRUE(b.starts_with(s1));\n  EXPECT_TRUE(b.starts_with(b));\n  EXPECT_TRUE(b.starts_with(e));\n  EXPECT_TRUE(e.starts_with(\"\"));\n  EXPECT_TRUE(!a.starts_with(b));\n  EXPECT_TRUE(!b.starts_with(a));\n  EXPECT_TRUE(!e.starts_with(a));\n\n  // ends with\n  EXPECT_TRUE(a.ends_with(a));\n  EXPECT_TRUE(a.ends_with(\"bar\"));\n  EXPECT_TRUE(a.ends_with(e));\n  EXPECT_TRUE(b.ends_with(s1));\n  EXPECT_TRUE(b.ends_with(b));\n  EXPECT_TRUE(b.ends_with(e));\n  EXPECT_TRUE(e.ends_with(\"\"));\n  EXPECT_TRUE(!a.ends_with(b));\n  EXPECT_TRUE(!b.ends_with(a));\n  EXPECT_TRUE(!e.ends_with(a));\n\n  // remove_prefix\n  StringPiece c(a);\n  c.remove_prefix(3);\n  EXPECT_EQ(c, \"bar\");\n  c = a;\n  c.remove_prefix(0);\n  EXPECT_EQ(c, a);\n  c.remove_prefix(c.size());\n  EXPECT_EQ(c, e);\n\n  // remove_suffix\n  c = a;\n  c.remove_suffix(3);\n  EXPECT_EQ(c, \"foo\");\n  c = a;\n  c.remove_suffix(0);\n  EXPECT_EQ(c, a);\n  c.remove_suffix(c.size());\n  EXPECT_EQ(c, e);\n\n  // set\n  c.set(\"foobar\", 6);\n  EXPECT_EQ(c, a);\n  c.set(\"foobar\", 0);\n  EXPECT_EQ(c, e);\n  c.set(\"foobar\", 7);\n  EXPECT_NE(c, a);\n\n  c.set(\"foobar\");\n  EXPECT_EQ(c, a);\n\n  c.set(static_cast<const void*>(\"foobar\"), 6);\n  EXPECT_EQ(c, a);\n  c.set(static_cast<const void*>(\"foobar\"), 0);\n  EXPECT_EQ(c, e);\n  c.set(static_cast<const void*>(\"foobar\"), 7);\n  EXPECT_NE(c, a);\n\n  // as_string\n  string s3(a.as_string().c_str(), 7);\n  EXPECT_EQ(c, s3);\n  string s4(e.as_string());\n  EXPECT_TRUE(s4.empty());\n\n  // ToString\n  {\n    string s5(a.ToString().c_str(), 7);\n    EXPECT_EQ(c, s5);\n    string s6(e.ToString());\n    EXPECT_TRUE(s6.empty());\n  }\n\n  // Consume\n  a.set(\"foobar\");\n  EXPECT_TRUE(a.Consume(\"foo\"));\n  EXPECT_EQ(a, \"bar\");\n  EXPECT_FALSE(a.Consume(\"foo\"));\n  EXPECT_FALSE(a.Consume(\"barbar\"));\n  EXPECT_FALSE(a.Consume(\"ar\"));\n  EXPECT_EQ(a, \"bar\");\n\n  a.set(\"foobar\");\n  EXPECT_TRUE(a.ConsumeFromEnd(\"bar\"));\n  EXPECT_EQ(a, \"foo\");\n  EXPECT_FALSE(a.ConsumeFromEnd(\"bar\"));\n  EXPECT_FALSE(a.ConsumeFromEnd(\"foofoo\"));\n  EXPECT_FALSE(a.ConsumeFromEnd(\"fo\"));\n  EXPECT_EQ(a, \"foo\");\n}\n\nTEST(StringPiece, Contains) {\n  StringPiece a(\"abcdefg\");\n  StringPiece b(\"abcd\");\n  StringPiece c(\"efg\");\n  StringPiece d(\"gh\");\n  EXPECT_TRUE(a.contains(b));\n  EXPECT_TRUE(a.contains(c));\n  EXPECT_TRUE(!a.contains(d));\n}\n\nTEST(StringPiece, NULLInput) {\n  // we used to crash here, but now we don't.\n  StringPiece s(NULL);\n  EXPECT_EQ(s.data(), (const char*)NULL);\n  EXPECT_EQ(s.size(), 0);\n\n  s.set(NULL);\n  EXPECT_EQ(s.data(), (const char*)NULL);\n  EXPECT_EQ(s.size(), 0);\n\n  // .ToString() on a StringPiece with NULL should produce the empty string.\n  EXPECT_EQ(\"\", s.ToString());\n  EXPECT_EQ(\"\", s.as_string());\n}\n\nTEST(StringPiece, Comparisons2) {\n  StringPiece abc(\"abcdefghijklmnopqrstuvwxyz\");\n\n  // check comparison operations on strings longer than 4 bytes.\n  EXPECT_EQ(abc, StringPiece(\"abcdefghijklmnopqrstuvwxyz\"));\n  EXPECT_EQ(abc.compare(StringPiece(\"abcdefghijklmnopqrstuvwxyz\")), 0);\n\n  EXPECT_LT(abc, StringPiece(\"abcdefghijklmnopqrstuvwxzz\"));\n  EXPECT_LT(abc.compare(StringPiece(\"abcdefghijklmnopqrstuvwxzz\")), 0);\n\n  EXPECT_GT(abc, StringPiece(\"abcdefghijklmnopqrstuvwxyy\"));\n  EXPECT_GT(abc.compare(StringPiece(\"abcdefghijklmnopqrstuvwxyy\")), 0);\n\n  // starts_with\n  EXPECT_TRUE(abc.starts_with(abc));\n  EXPECT_TRUE(abc.starts_with(\"abcdefghijklm\"));\n  EXPECT_TRUE(!abc.starts_with(\"abcdefguvwxyz\"));\n\n  // ends_with\n  EXPECT_TRUE(abc.ends_with(abc));\n  EXPECT_TRUE(!abc.ends_with(\"abcdefguvwxyz\"));\n  EXPECT_TRUE(abc.ends_with(\"nopqrstuvwxyz\"));\n}\n\nTEST(ComparisonOpsTest, StringCompareNotAmbiguous) {\n  EXPECT_EQ(\"hello\", string(\"hello\"));\n  EXPECT_LT(\"hello\", string(\"world\"));\n}\n\nTEST(ComparisonOpsTest, HeterogenousStringPieceEquals) {\n  EXPECT_EQ(StringPiece(\"hello\"), string(\"hello\"));\n  EXPECT_EQ(\"hello\", StringPiece(\"hello\"));\n}\n\nTEST(FindOneCharTest, EdgeCases) {\n  StringPiece a(\"xxyyyxx\");\n\n  // Set a = \"xyyyx\".\n  a.remove_prefix(1);\n  a.remove_suffix(1);\n\n  EXPECT_EQ(0, a.find('x'));\n  EXPECT_EQ(0, a.find('x', 0));\n  EXPECT_EQ(4, a.find('x', 1));\n  EXPECT_EQ(4, a.find('x', 4));\n  EXPECT_EQ(StringPiece::npos, a.find('x', 5));\n\n  EXPECT_EQ(4, a.rfind('x'));\n  EXPECT_EQ(4, a.rfind('x', 5));\n  EXPECT_EQ(4, a.rfind('x', 4));\n  EXPECT_EQ(0, a.rfind('x', 3));\n  EXPECT_EQ(0, a.rfind('x', 0));\n\n  // Set a = \"yyy\".\n  a.remove_prefix(1);\n  a.remove_suffix(1);\n\n  EXPECT_EQ(StringPiece::npos, a.find('x'));\n  EXPECT_EQ(StringPiece::npos, a.rfind('x'));\n}\n\n#ifndef NDEBUG\nTEST(NonNegativeLenTest, NonNegativeLen) {\n  EXPECT_DEATH(StringPiece(\"xyz\", -1), \"len >= 0\");\n}\n#endif  // ndef DEBUG\n\n}  // namespace\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/stringprintf.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2012 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// from google3/base/stringprintf.cc\n\n#include <google/protobuf/stubs/stringprintf.h>\n\n#include <errno.h>\n#include <stdarg.h> // For va_list and related operations\n#include <stdio.h> // MSVC requires this for _vsnprintf\n#include <vector>\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\n\n#ifdef _MSC_VER\nenum { IS_COMPILER_MSVC = 1 };\n#ifndef va_copy\n// Define va_copy for MSVC. This is a hack, assuming va_list is simply a\n// pointer into the stack and is safe to copy.\n#define va_copy(dest, src) ((dest) = (src))\n#endif\n#else\nenum { IS_COMPILER_MSVC = 0 };\n#endif\n\nvoid StringAppendV(string* dst, const char* format, va_list ap) {\n  // First try with a small fixed size buffer\n  static const int kSpaceLength = 1024;\n  char space[kSpaceLength];\n\n  // It's possible for methods that use a va_list to invalidate\n  // the data in it upon use.  The fix is to make a copy\n  // of the structure before using it and use that copy instead.\n  va_list backup_ap;\n  va_copy(backup_ap, ap);\n  int result = vsnprintf(space, kSpaceLength, format, backup_ap);\n  va_end(backup_ap);\n\n  if (result < kSpaceLength) {\n    if (result >= 0) {\n      // Normal case -- everything fit.\n      dst->append(space, result);\n      return;\n    }\n\n    if (IS_COMPILER_MSVC) {\n      // Error or MSVC running out of space.  MSVC 8.0 and higher\n      // can be asked about space needed with the special idiom below:\n      va_copy(backup_ap, ap);\n      result = vsnprintf(NULL, 0, format, backup_ap);\n      va_end(backup_ap);\n    }\n\n    if (result < 0) {\n      // Just an error.\n      return;\n    }\n  }\n\n  // Increase the buffer size to the size requested by vsnprintf,\n  // plus one for the closing \\0.\n  int length = result+1;\n  char* buf = new char[length];\n\n  // Restore the va_list before we use it again\n  va_copy(backup_ap, ap);\n  result = vsnprintf(buf, length, format, backup_ap);\n  va_end(backup_ap);\n\n  if (result >= 0 && result < length) {\n    // It fit\n    dst->append(buf, result);\n  }\n  delete[] buf;\n}\n\n\nstring StringPrintf(const char* format, ...) {\n  va_list ap;\n  va_start(ap, format);\n  string result;\n  StringAppendV(&result, format, ap);\n  va_end(ap);\n  return result;\n}\n\nconst string& SStringPrintf(string* dst, const char* format, ...) {\n  va_list ap;\n  va_start(ap, format);\n  dst->clear();\n  StringAppendV(dst, format, ap);\n  va_end(ap);\n  return *dst;\n}\n\nvoid StringAppendF(string* dst, const char* format, ...) {\n  va_list ap;\n  va_start(ap, format);\n  StringAppendV(dst, format, ap);\n  va_end(ap);\n}\n\n// Max arguments supported by StringPrintVector\nconst int kStringPrintfVectorMaxArgs = 32;\n\n// An empty block of zero for filler arguments.  This is const so that if\n// printf tries to write to it (via %n) then the program gets a SIGSEGV\n// and we can fix the problem or protect against an attack.\nstatic const char string_printf_empty_block[256] = { '\\0' };\n\nstring StringPrintfVector(const char* format, const vector<string>& v) {\n  GOOGLE_CHECK_LE(v.size(), kStringPrintfVectorMaxArgs)\n      << \"StringPrintfVector currently only supports up to \"\n      << kStringPrintfVectorMaxArgs << \" arguments. \"\n      << \"Feel free to add support for more if you need it.\";\n\n  // Add filler arguments so that bogus format+args have a harder time\n  // crashing the program, corrupting the program (%n),\n  // or displaying random chunks of memory to users.\n\n  const char* cstr[kStringPrintfVectorMaxArgs];\n  for (int i = 0; i < v.size(); ++i) {\n    cstr[i] = v[i].c_str();\n  }\n  for (int i = v.size(); i < GOOGLE_ARRAYSIZE(cstr); ++i) {\n    cstr[i] = &string_printf_empty_block[0];\n  }\n\n  // I do not know any way to pass kStringPrintfVectorMaxArgs arguments,\n  // or any way to build a va_list by hand, or any API for printf\n  // that accepts an array of arguments.  The best I can do is stick\n  // this COMPILE_ASSERT right next to the actual statement.\n\n  GOOGLE_COMPILE_ASSERT(kStringPrintfVectorMaxArgs == 32, arg_count_mismatch);\n  return StringPrintf(format,\n                      cstr[0], cstr[1], cstr[2], cstr[3], cstr[4],\n                      cstr[5], cstr[6], cstr[7], cstr[8], cstr[9],\n                      cstr[10], cstr[11], cstr[12], cstr[13], cstr[14],\n                      cstr[15], cstr[16], cstr[17], cstr[18], cstr[19],\n                      cstr[20], cstr[21], cstr[22], cstr[23], cstr[24],\n                      cstr[25], cstr[26], cstr[27], cstr[28], cstr[29],\n                      cstr[30], cstr[31]);\n}\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/stringprintf.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2012 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// from google3/base/stringprintf.h\n//\n// Printf variants that place their output in a C++ string.\n//\n// Usage:\n//      string result = StringPrintf(\"%d %s\\n\", 10, \"hello\");\n//      SStringPrintf(&result, \"%d %s\\n\", 10, \"hello\");\n//      StringAppendF(&result, \"%d %s\\n\", 20, \"there\");\n\n#ifndef GOOGLE_PROTOBUF_STUBS_STRINGPRINTF_H\n#define GOOGLE_PROTOBUF_STUBS_STRINGPRINTF_H\n\n#include <stdarg.h>\n#include <string>\n#include <vector>\n\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\n\n// Return a C++ string\nLIBPROTOBUF_EXPORT extern string StringPrintf(const char* format, ...);\n\n// Store result into a supplied string and return it\nLIBPROTOBUF_EXPORT extern const string& SStringPrintf(string* dst, const char* format, ...);\n\n// Append result to a supplied string\nLIBPROTOBUF_EXPORT extern void StringAppendF(string* dst, const char* format, ...);\n\n// Lower-level routine that takes a va_list and appends to a specified\n// string.  All other routines are just convenience wrappers around it.\nLIBPROTOBUF_EXPORT extern void StringAppendV(string* dst, const char* format, va_list ap);\n\n// The max arguments supported by StringPrintfVector\nLIBPROTOBUF_EXPORT extern const int kStringPrintfVectorMaxArgs;\n\n// You can use this version when all your arguments are strings, but\n// you don't know how many arguments you'll have at compile time.\n// StringPrintfVector will LOG(FATAL) if v.size() > kStringPrintfVectorMaxArgs\nLIBPROTOBUF_EXPORT extern string StringPrintfVector(const char* format, const vector<string>& v);\n\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_STUBS_STRINGPRINTF_H\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/stringprintf_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2012 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// from google3/base/stringprintf_unittest.cc\n\n#include <google/protobuf/stubs/stringprintf.h>\n\n#include <cerrno>\n#include <string>\n\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace {\n\nTEST(StringPrintfTest, Empty) {\n#if 0\n  // gcc 2.95.3, gcc 4.1.0, and gcc 4.2.2 all warn about this:\n  // warning: zero-length printf format string.\n  // so we do not allow them in google3.\n  EXPECT_EQ(\"\", StringPrintf(\"\"));\n#endif\n  EXPECT_EQ(\"\", StringPrintf(\"%s\", string().c_str()));\n  EXPECT_EQ(\"\", StringPrintf(\"%s\", \"\"));\n}\n\nTEST(StringPrintfTest, Misc) {\n// MSVC and mingw does not support $ format specifier.\n#if !defined(_MSC_VER) && !defined(__MINGW32__)\n  EXPECT_EQ(\"123hello w\", StringPrintf(\"%3$d%2$s %1$c\", 'w', \"hello\", 123));\n#endif  // !_MSC_VER\n}\n\nTEST(StringAppendFTest, Empty) {\n  string value(\"Hello\");\n  const char* empty = \"\";\n  StringAppendF(&value, \"%s\", empty);\n  EXPECT_EQ(\"Hello\", value);\n}\n\nTEST(StringAppendFTest, EmptyString) {\n  string value(\"Hello\");\n  StringAppendF(&value, \"%s\", \"\");\n  EXPECT_EQ(\"Hello\", value);\n}\n\nTEST(StringAppendFTest, String) {\n  string value(\"Hello\");\n  StringAppendF(&value, \" %s\", \"World\");\n  EXPECT_EQ(\"Hello World\", value);\n}\n\nTEST(StringAppendFTest, Int) {\n  string value(\"Hello\");\n  StringAppendF(&value, \" %d\", 123);\n  EXPECT_EQ(\"Hello 123\", value);\n}\n\nTEST(StringPrintfTest, Multibyte) {\n  // If we are in multibyte mode and feed invalid multibyte sequence,\n  // StringPrintf should return an empty string instead of running\n  // out of memory while trying to determine destination buffer size.\n  // see b/4194543.\n\n  char* old_locale = setlocale(LC_CTYPE, NULL);\n  // Push locale with multibyte mode\n  setlocale(LC_CTYPE, \"en_US.utf8\");\n\n  const char kInvalidCodePoint[] = \"\\375\\067s\";\n  string value = StringPrintf(\"%.*s\", 3, kInvalidCodePoint);\n\n  // In some versions of glibc (e.g. eglibc-2.11.1, aka GRTEv2), snprintf\n  // returns error given an invalid codepoint. Other versions\n  // (e.g. eglibc-2.15, aka pre-GRTEv3) emit the codepoint verbatim.\n  // We test that the output is one of the above.\n  EXPECT_TRUE(value.empty() || value == kInvalidCodePoint);\n\n  // Repeat with longer string, to make sure that the dynamically\n  // allocated path in StringAppendV is handled correctly.\n  int n = 2048;\n  char* buf = new char[n+1];\n  memset(buf, ' ', n-3);\n  memcpy(buf + n - 3, kInvalidCodePoint, 4);\n  value =  StringPrintf(\"%.*s\", n, buf);\n  // See GRTEv2 vs. GRTEv3 comment above.\n  EXPECT_TRUE(value.empty() || value == buf);\n  delete[] buf;\n\n  setlocale(LC_CTYPE, old_locale);\n}\n\nTEST(StringPrintfTest, NoMultibyte) {\n  // No multibyte handling, but the string contains funny chars.\n  char* old_locale = setlocale(LC_CTYPE, NULL);\n  setlocale(LC_CTYPE, \"POSIX\");\n  string value = StringPrintf(\"%.*s\", 3, \"\\375\\067s\");\n  setlocale(LC_CTYPE, old_locale);\n  EXPECT_EQ(\"\\375\\067s\", value);\n}\n\nTEST(StringPrintfTest, DontOverwriteErrno) {\n  // Check that errno isn't overwritten unless we're printing\n  // something significantly larger than what people are normally\n  // printing in their badly written PLOG() statements.\n  errno = ECHILD;\n  string value = StringPrintf(\"Hello, %s!\", \"World\");\n  EXPECT_EQ(ECHILD, errno);\n}\n\nTEST(StringPrintfTest, LargeBuf) {\n  // Check that the large buffer is handled correctly.\n  int n = 2048;\n  char* buf = new char[n+1];\n  memset(buf, ' ', n);\n  buf[n] = 0;\n  string value = StringPrintf(\"%s\", buf);\n  EXPECT_EQ(buf, value);\n  delete[] buf;\n}\n\n}  // anonymous namespace\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/structurally_valid.cc",
    "content": "// Copyright 2005-2008 Google Inc. All Rights Reserved.\n// Author: jrm@google.com (Jim Meehan)\n\n#include <google/protobuf/stubs/common.h>\n\n#include <google/protobuf/stubs/stringpiece.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\n// These four-byte entries compactly encode how many bytes 0..255 to delete\n// in making a string replacement, how many bytes to add 0..255, and the offset\n// 0..64k-1 of the replacement string in remap_string.\nstruct RemapEntry {\n  uint8 delete_bytes;\n  uint8 add_bytes;\n  uint16 bytes_offset;\n};\n\n// Exit type codes for state tables. All but the first get stuffed into\n// signed one-byte entries. The first is only generated by executable code.\n// To distinguish from next-state entries, these must be contiguous and\n// all <= kExitNone\ntypedef enum {\n  kExitDstSpaceFull = 239,\n  kExitIllegalStructure,  // 240\n  kExitOK,                // 241\n  kExitReject,            // ...\n  kExitReplace1,\n  kExitReplace2,\n  kExitReplace3,\n  kExitReplace21,\n  kExitReplace31,\n  kExitReplace32,\n  kExitReplaceOffset1,\n  kExitReplaceOffset2,\n  kExitReplace1S0,\n  kExitSpecial,\n  kExitDoAgain,\n  kExitRejectAlt,\n  kExitNone               // 255\n} ExitReason;\n\n\n// This struct represents one entire state table. The three initialized byte\n// areas are state_table, remap_base, and remap_string. state0 and state0_size\n// give the byte offset and length within state_table of the initial state --\n// table lookups are expected to start and end in this state, but for\n// truncated UTF-8 strings, may end in a different state. These allow a quick\n// test for that condition. entry_shift is 8 for tables subscripted by a full\n// byte value and 6 for space-optimized tables subscripted by only six\n// significant bits in UTF-8 continuation bytes.\ntypedef struct {\n  const uint32 state0;\n  const uint32 state0_size;\n  const uint32 total_size;\n  const int max_expand;\n  const int entry_shift;\n  const int bytes_per_entry;\n  const uint32 losub;\n  const uint32 hiadd;\n  const uint8* state_table;\n  const RemapEntry* remap_base;\n  const uint8* remap_string;\n  const uint8* fast_state;\n} UTF8StateMachineObj;\n\ntypedef UTF8StateMachineObj UTF8ScanObj;\n\n#define X__ (kExitIllegalStructure)\n#define RJ_ (kExitReject)\n#define S1_ (kExitReplace1)\n#define S2_ (kExitReplace2)\n#define S3_ (kExitReplace3)\n#define S21 (kExitReplace21)\n#define S31 (kExitReplace31)\n#define S32 (kExitReplace32)\n#define T1_ (kExitReplaceOffset1)\n#define T2_ (kExitReplaceOffset2)\n#define S11 (kExitReplace1S0)\n#define SP_ (kExitSpecial)\n#define D__ (kExitDoAgain)\n#define RJA (kExitRejectAlt)\n\n//  Entire table has 9 state blocks of 256 entries each\nstatic const unsigned int utf8acceptnonsurrogates_STATE0 = 0;     // state[0]\nstatic const unsigned int utf8acceptnonsurrogates_STATE0_SIZE = 256;  // =[1]\nstatic const unsigned int utf8acceptnonsurrogates_TOTAL_SIZE = 2304;\nstatic const unsigned int utf8acceptnonsurrogates_MAX_EXPAND_X4 = 0;\nstatic const unsigned int utf8acceptnonsurrogates_SHIFT = 8;\nstatic const unsigned int utf8acceptnonsurrogates_BYTES = 1;\nstatic const unsigned int utf8acceptnonsurrogates_LOSUB = 0x20202020;\nstatic const unsigned int utf8acceptnonsurrogates_HIADD = 0x00000000;\n\nstatic const uint8 utf8acceptnonsurrogates[] = {\n// state[0] 0x000000 Byte 1\n  0,   0,   0,   0,   0,   0,   0,   0,    0,   0,   0,   0,   0,   0,   0,   0,\n  0,   0,   0,   0,   0,   0,   0,   0,    0,   0,   0,   0,   0,   0,   0,   0,\n  0,   0,   0,   0,   0,   0,   0,   0,    0,   0,   0,   0,   0,   0,   0,   0,\n  0,   0,   0,   0,   0,   0,   0,   0,    0,   0,   0,   0,   0,   0,   0,   0,\n\n  0,   0,   0,   0,   0,   0,   0,   0,    0,   0,   0,   0,   0,   0,   0,   0,\n  0,   0,   0,   0,   0,   0,   0,   0,    0,   0,   0,   0,   0,   0,   0,   0,\n  0,   0,   0,   0,   0,   0,   0,   0,    0,   0,   0,   0,   0,   0,   0,   0,\n  0,   0,   0,   0,   0,   0,   0,   0,    0,   0,   0,   0,   0,   0,   0,   0,\n\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\nX__, X__,   1,   1,   1,   1,   1,   1,    1,   1,   1,   1,   1,   1,   1,   1,\n  1,   1,   1,   1,   1,   1,   1,   1,    1,   1,   1,   1,   1,   1,   1,   1,\n  2,   3,   3,   3,   3,   3,   3,   3,    3,   3,   3,   3,   3,   7,   3,   3,\n  4,   5,   5,   5,   6, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\n// state[1] 0x000080 Byte 2 of 2\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\n  0,   0,   0,   0,   0,   0,   0,   0,    0,   0,   0,   0,   0,   0,   0,   0,\n  0,   0,   0,   0,   0,   0,   0,   0,    0,   0,   0,   0,   0,   0,   0,   0,\n  0,   0,   0,   0,   0,   0,   0,   0,    0,   0,   0,   0,   0,   0,   0,   0,\n  0,   0,   0,   0,   0,   0,   0,   0,    0,   0,   0,   0,   0,   0,   0,   0,\n\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\n// state[2] 0x000000 Byte 2 of 3\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n  1,   1,   1,   1,   1,   1,   1,   1,    1,   1,   1,   1,   1,   1,   1,   1,\n  1,   1,   1,   1,   1,   1,   1,   1,    1,   1,   1,   1,   1,   1,   1,   1,\n\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\n// state[3] 0x001000 Byte 2 of 3\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\n  1,   1,   1,   1,   1,   1,   1,   1,    1,   1,   1,   1,   1,   1,   1,   1,\n  1,   1,   1,   1,   1,   1,   1,   1,    1,   1,   1,   1,   1,   1,   1,   1,\n  1,   1,   1,   1,   1,   1,   1,   1,    1,   1,   1,   1,   1,   1,   1,   1,\n  1,   1,   1,   1,   1,   1,   1,   1,    1,   1,   1,   1,   1,   1,   1,   1,\n\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\n// state[4] 0x000000 Byte 2 of 4\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n  3,   3,   3,   3,   3,   3,   3,   3,    3,   3,   3,   3,   3,   3,   3,   3,\n  3,   3,   3,   3,   3,   3,   3,   3,    3,   3,   3,   3,   3,   3,   3,   3,\n  3,   3,   3,   3,   3,   3,   3,   3,    3,   3,   3,   3,   3,   3,   3,   3,\n\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\n// state[5] 0x040000 Byte 2 of 4\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\n  3,   3,   3,   3,   3,   3,   3,   3,    3,   3,   3,   3,   3,   3,   3,   3,\n  3,   3,   3,   3,   3,   3,   3,   3,    3,   3,   3,   3,   3,   3,   3,   3,\n  3,   3,   3,   3,   3,   3,   3,   3,    3,   3,   3,   3,   3,   3,   3,   3,\n  3,   3,   3,   3,   3,   3,   3,   3,    3,   3,   3,   3,   3,   3,   3,   3,\n\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\n// state[6] 0x100000 Byte 2 of 4\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\n  3,   3,   3,   3,   3,   3,   3,   3,    3,   3,   3,   3,   3,   3,   3,   3,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\n// state[7] 0x00d000 Byte 2 of 3\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\n  1,   1,   1,   1,   1,   1,   1,   1,    1,   1,   1,   1,   1,   1,   1,   1,\n  1,   1,   1,   1,   1,   1,   1,   1,    1,   1,   1,   1,   1,   1,   1,   1,\n  8,   8,   8,   8,   8,   8,   8,   8,    8,   8,   8,   8,   8,   8,   8,   8,\n  8,   8,   8,   8,   8,   8,   8,   8,    8,   8,   8,   8,   8,   8,   8,   8,\n\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\n// state[8] 0x00d800 Byte 3 of 3\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n\nRJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_,  RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_,\nRJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_,  RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_,\nRJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_,  RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_,\nRJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_,  RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_, RJ_,\n\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\nX__, X__, X__, X__, X__, X__, X__, X__,  X__, X__, X__, X__, X__, X__, X__, X__,\n};\n\n// Remap base[0] = (del, add, string_offset)\nstatic const RemapEntry utf8acceptnonsurrogates_remap_base[] = {\n{0, 0, 0} };\n\n// Remap string[0]\nstatic const unsigned char utf8acceptnonsurrogates_remap_string[] = {\n0 };\n\nstatic const unsigned char utf8acceptnonsurrogates_fast[256] = {\n0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n\n0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,\n\n1, 1, 1, 1, 1, 1, 1, 1,  1, 1, 1, 1, 1, 1, 1, 1,\n1, 1, 1, 1, 1, 1, 1, 1,  1, 1, 1, 1, 1, 1, 1, 1,\n1, 1, 1, 1, 1, 1, 1, 1,  1, 1, 1, 1, 1, 1, 1, 1,\n1, 1, 1, 1, 1, 1, 1, 1,  1, 1, 1, 1, 1, 1, 1, 1,\n\n1, 1, 1, 1, 1, 1, 1, 1,  1, 1, 1, 1, 1, 1, 1, 1,\n1, 1, 1, 1, 1, 1, 1, 1,  1, 1, 1, 1, 1, 1, 1, 1,\n1, 1, 1, 1, 1, 1, 1, 1,  1, 1, 1, 1, 1, 1, 1, 1,\n1, 1, 1, 1, 1, 1, 1, 1,  1, 1, 1, 1, 1, 1, 1, 1,\n};\n\nstatic const UTF8ScanObj utf8acceptnonsurrogates_obj = {\n  utf8acceptnonsurrogates_STATE0,\n  utf8acceptnonsurrogates_STATE0_SIZE,\n  utf8acceptnonsurrogates_TOTAL_SIZE,\n  utf8acceptnonsurrogates_MAX_EXPAND_X4,\n  utf8acceptnonsurrogates_SHIFT,\n  utf8acceptnonsurrogates_BYTES,\n  utf8acceptnonsurrogates_LOSUB,\n  utf8acceptnonsurrogates_HIADD,\n  utf8acceptnonsurrogates,\n  utf8acceptnonsurrogates_remap_base,\n  utf8acceptnonsurrogates_remap_string,\n  utf8acceptnonsurrogates_fast\n};\n\n\n#undef X__\n#undef RJ_\n#undef S1_\n#undef S2_\n#undef S3_\n#undef S21\n#undef S31\n#undef S32\n#undef T1_\n#undef T2_\n#undef S11\n#undef SP_\n#undef D__\n#undef RJA\n\n// Return true if current Tbl pointer is within state0 range\n// Note that unsigned compare checks both ends of range simultaneously\nstatic inline bool InStateZero(const UTF8ScanObj* st, const uint8* Tbl) {\n  const uint8* Tbl0 = &st->state_table[st->state0];\n  return (static_cast<uint32>(Tbl - Tbl0) < st->state0_size);\n}\n\n// Scan a UTF-8 string based on state table.\n// Always scan complete UTF-8 characters\n// Set number of bytes scanned. Return reason for exiting\nint UTF8GenericScan(const UTF8ScanObj* st,\n                    const char * str,\n                    int str_length,\n                    int* bytes_consumed) {\n  *bytes_consumed = 0;\n  if (str_length == 0) return kExitOK;\n\n  int eshift = st->entry_shift;\n  const uint8* isrc = reinterpret_cast<const uint8*>(str);\n  const uint8* src = isrc;\n  const uint8* srclimit = isrc + str_length;\n  const uint8* srclimit8 = srclimit - 7;\n  const uint8* Tbl_0 = &st->state_table[st->state0];\n\n DoAgain:\n  // Do state-table scan\n  int e = 0;\n  uint8 c;\n  const uint8* Tbl2 = &st->fast_state[0];\n  const uint32 losub = st->losub;\n  const uint32 hiadd = st->hiadd;\n  // Check initial few bytes one at a time until 8-byte aligned\n  //----------------------------\n  while ((((uintptr_t)src & 0x07) != 0) &&\n         (src < srclimit) &&\n         Tbl2[src[0]] == 0) {\n    src++;\n  }\n  if (((uintptr_t)src & 0x07) == 0) {\n    // Do fast for groups of 8 identity bytes.\n    // This covers a lot of 7-bit ASCII ~8x faster then the 1-byte loop,\n    // including slowing slightly on cr/lf/ht\n    //----------------------------\n    while (src < srclimit8) {\n      uint32 s0123 = (reinterpret_cast<const uint32 *>(src))[0];\n      uint32 s4567 = (reinterpret_cast<const uint32 *>(src))[1];\n      src += 8;\n      // This is a fast range check for all bytes in [lowsub..0x80-hiadd)\n      uint32 temp = (s0123 - losub) | (s0123 + hiadd) |\n                    (s4567 - losub) | (s4567 + hiadd);\n      if ((temp & 0x80808080) != 0) {\n        // We typically end up here on cr/lf/ht; src was incremented\n        int e0123 = (Tbl2[src[-8]] | Tbl2[src[-7]]) |\n                    (Tbl2[src[-6]] | Tbl2[src[-5]]);\n        if (e0123 != 0) {\n          src -= 8;\n          break;\n        }    // Exit on Non-interchange\n        e0123 = (Tbl2[src[-4]] | Tbl2[src[-3]]) |\n                (Tbl2[src[-2]] | Tbl2[src[-1]]);\n        if (e0123 != 0) {\n          src -= 4;\n          break;\n        }    // Exit on Non-interchange\n        // Else OK, go around again\n      }\n    }\n  }\n  //----------------------------\n\n  // Byte-at-a-time scan\n  //----------------------------\n  const uint8* Tbl = Tbl_0;\n  while (src < srclimit) {\n    c = *src;\n    e = Tbl[c];\n    src++;\n    if (e >= kExitIllegalStructure) {break;}\n    Tbl = &Tbl_0[e << eshift];\n  }\n  //----------------------------\n\n\n  // Exit posibilities:\n  //  Some exit code, !state0, back up over last char\n  //  Some exit code, state0, back up one byte exactly\n  //  source consumed, !state0, back up over partial char\n  //  source consumed, state0, exit OK\n  // For illegal byte in state0, avoid backup up over PREVIOUS char\n  // For truncated last char, back up to beginning of it\n\n  if (e >= kExitIllegalStructure) {\n    // Back up over exactly one byte of rejected/illegal UTF-8 character\n    src--;\n    // Back up more if needed\n    if (!InStateZero(st, Tbl)) {\n      do {\n        src--;\n      } while ((src > isrc) && ((src[0] & 0xc0) == 0x80));\n    }\n  } else if (!InStateZero(st, Tbl)) {\n    // Back up over truncated UTF-8 character\n    e = kExitIllegalStructure;\n    do {\n      src--;\n    } while ((src > isrc) && ((src[0] & 0xc0) == 0x80));\n  } else {\n    // Normal termination, source fully consumed\n    e = kExitOK;\n  }\n\n  if (e == kExitDoAgain) {\n    // Loop back up to the fast scan\n    goto DoAgain;\n  }\n\n  *bytes_consumed = src - isrc;\n  return e;\n}\n\nint UTF8GenericScanFastAscii(const UTF8ScanObj* st,\n                    const char * str,\n                    int str_length,\n                    int* bytes_consumed) {\n  *bytes_consumed = 0;\n  if (str_length == 0) return kExitOK;\n\n  const uint8* isrc =  reinterpret_cast<const uint8*>(str);\n  const uint8* src = isrc;\n  const uint8* srclimit = isrc + str_length;\n  const uint8* srclimit8 = srclimit - 7;\n  int n;\n  int rest_consumed;\n  int exit_reason;\n  do {\n    // Check initial few bytes one at a time until 8-byte aligned\n    while ((((uintptr_t)src & 0x07) != 0) &&\n           (src < srclimit) && (src[0] < 0x80)) {\n      src++;\n    }\n    if (((uintptr_t)src & 0x07) == 0) {\n      while ((src < srclimit8) &&\n             (((reinterpret_cast<const uint32*>(src)[0] |\n                reinterpret_cast<const uint32*>(src)[1]) & 0x80808080) == 0)) {\n        src += 8;\n      }\n    }\n    while ((src < srclimit) && (src[0] < 0x80)) {\n      src++;\n    }\n    // Run state table on the rest\n    n = src - isrc;\n    exit_reason = UTF8GenericScan(st, str + n, str_length - n, &rest_consumed);\n    src += rest_consumed;\n  } while ( exit_reason == kExitDoAgain );\n\n  *bytes_consumed = src - isrc;\n  return exit_reason;\n}\n\n// Hack:  On some compilers the static tables are initialized at startup.\n//   We can't use them until they are initialized.  However, some Protocol\n//   Buffer parsing happens at static init time and may try to validate\n//   UTF-8 strings.  Since UTF-8 validation is only used for debugging\n//   anyway, we simply always return success if initialization hasn't\n//   occurred yet.\nnamespace {\n\nbool module_initialized_ = false;\n\nstruct InitDetector {\n  InitDetector() {\n    module_initialized_ = true;\n  }\n};\nInitDetector init_detector;\n\n}  // namespace\n\nbool IsStructurallyValidUTF8(const char* buf, int len) {\n  if (!module_initialized_) return true;\n  \n  int bytes_consumed = 0;\n  UTF8GenericScanFastAscii(&utf8acceptnonsurrogates_obj,\n                           buf, len, &bytes_consumed);\n  return (bytes_consumed == len);\n}\n\nint UTF8SpnStructurallyValid(const StringPiece& str) {\n  if (!module_initialized_) return str.size();\n\n  int bytes_consumed = 0;\n  UTF8GenericScanFastAscii(&utf8acceptnonsurrogates_obj,\n                           str.data(), str.size(), &bytes_consumed);\n  return bytes_consumed;\n}\n\n// Coerce UTF-8 byte string in src_str to be\n// a structurally-valid equal-length string by selectively\n// overwriting illegal bytes with replace_char (typically blank).\n// replace_char must be legal printable 7-bit Ascii 0x20..0x7e.\n// src_str is read-only. If any overwriting is needed, a modified byte string\n// is created in idst, length isrclen.\n//\n// Returns pointer to output buffer, isrc if no changes were made,\n//  or idst if some bytes were changed.\n//\n// Fast case: all is structurally valid and no byte copying is done.\n//\nchar* UTF8CoerceToStructurallyValid(const StringPiece& src_str,\n                                    char* idst,\n                                    const char replace_char) {\n  const char* isrc = src_str.data();\n  const int len = src_str.length();\n  int n = UTF8SpnStructurallyValid(src_str);\n  if (n == len) {               // Normal case -- all is cool, return\n    return const_cast<char*>(isrc);\n  } else {                      // Unusual case -- copy w/o bad bytes\n    const char* src = isrc;\n    const char* srclimit = isrc + len;\n    char* dst = idst;\n    memmove(dst, src, n);       // Copy initial good chunk\n    src += n;\n    dst += n;\n    while (src < srclimit) {    // src points to bogus byte or is off the end\n      dst[0] = replace_char;                    // replace one bad byte\n      src++;\n      dst++;\n      StringPiece str2(src, srclimit - src);\n      n = UTF8SpnStructurallyValid(str2);       // scan the remainder\n      memmove(dst, src, n);                     // copy next good chunk\n      src += n;\n      dst += n;\n    }\n  }\n  return idst;\n}\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/structurally_valid_unittest.cc",
    "content": "// Copyright 2008 Google Inc. All Rights Reserved.\n// Author: xpeng@google.com (Peter Peng)\n\n#include <google/protobuf/stubs/common.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\nnamespace {\n\nTEST(StructurallyValidTest, ValidUTF8String) {\n  // On GCC, this string can be written as:\n  //   \"abcd 1234 - \\u2014\\u2013\\u2212\"\n  // MSVC seems to interpret \\u differently.\n  string valid_str(\"abcd 1234 - \\342\\200\\224\\342\\200\\223\\342\\210\\222 - xyz789\");\n  EXPECT_TRUE(IsStructurallyValidUTF8(valid_str.data(),\n                                      valid_str.size()));\n  // Additional check for pointer alignment\n  for (int i = 1; i < 8; ++i) {\n    EXPECT_TRUE(IsStructurallyValidUTF8(valid_str.data() + i,\n                                        valid_str.size() - i));\n  }\n}\n\nTEST(StructurallyValidTest, InvalidUTF8String) {\n  const string invalid_str(\"abcd\\xA0\\xB0\\xA0\\xB0\\xA0\\xB0 - xyz789\");\n  EXPECT_FALSE(IsStructurallyValidUTF8(invalid_str.data(),\n                                       invalid_str.size()));\n  // Additional check for pointer alignment\n  for (int i = 1; i < 8; ++i) {\n    EXPECT_FALSE(IsStructurallyValidUTF8(invalid_str.data() + i,\n                                         invalid_str.size() - i));\n  }\n}\n\n}  // namespace\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/strutil.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// from google3/strings/strutil.cc\n\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/mathlimits.h>\n\n#include <errno.h>\n#include <float.h>    // FLT_DIG and DBL_DIG\n#include <limits>\n#include <limits.h>\n#include <stdio.h>\n#include <iterator>\n\n#include <google/protobuf/stubs/stl_util.h>\n\n#ifdef _WIN32\n// MSVC has only _snprintf, not snprintf.\n//\n// MinGW has both snprintf and _snprintf, but they appear to be different\n// functions.  The former is buggy.  When invoked like so:\n//   char buffer[32];\n//   snprintf(buffer, 32, \"%.*g\\n\", FLT_DIG, 1.23e10f);\n// it prints \"1.23000e+10\".  This is plainly wrong:  %g should never print\n// trailing zeros after the decimal point.  For some reason this bug only\n// occurs with some input values, not all.  In any case, _snprintf does the\n// right thing, so we use it.\n#define snprintf _snprintf\n#endif\n\nnamespace google {\nnamespace protobuf {\n\n// These are defined as macros on some platforms.  #undef them so that we can\n// redefine them.\n#undef isxdigit\n#undef isprint\n\n// The definitions of these in ctype.h change based on locale.  Since our\n// string manipulation is all in relation to the protocol buffer and C++\n// languages, we always want to use the C locale.  So, we re-define these\n// exactly as we want them.\ninline bool isxdigit(char c) {\n  return ('0' <= c && c <= '9') ||\n         ('a' <= c && c <= 'f') ||\n         ('A' <= c && c <= 'F');\n}\n\ninline bool isprint(char c) {\n  return c >= 0x20 && c <= 0x7E;\n}\n\n// ----------------------------------------------------------------------\n// StripString\n//    Replaces any occurrence of the character 'remove' (or the characters\n//    in 'remove') with the character 'replacewith'.\n// ----------------------------------------------------------------------\nvoid StripString(string* s, const char* remove, char replacewith) {\n  const char * str_start = s->c_str();\n  const char * str = str_start;\n  for (str = strpbrk(str, remove);\n       str != NULL;\n       str = strpbrk(str + 1, remove)) {\n    (*s)[str - str_start] = replacewith;\n  }\n}\n\nvoid StripWhitespace(string* str) {\n  int str_length = str->length();\n\n  // Strip off leading whitespace.\n  int first = 0;\n  while (first < str_length && ascii_isspace(str->at(first))) {\n    ++first;\n  }\n  // If entire string is white space.\n  if (first == str_length) {\n    str->clear();\n    return;\n  }\n  if (first > 0) {\n    str->erase(0, first);\n    str_length -= first;\n  }\n\n  // Strip off trailing whitespace.\n  int last = str_length - 1;\n  while (last >= 0 && ascii_isspace(str->at(last))) {\n    --last;\n  }\n  if (last != (str_length - 1) && last >= 0) {\n    str->erase(last + 1, string::npos);\n  }\n}\n\n// ----------------------------------------------------------------------\n// StringReplace()\n//    Replace the \"old\" pattern with the \"new\" pattern in a string,\n//    and append the result to \"res\".  If replace_all is false,\n//    it only replaces the first instance of \"old.\"\n// ----------------------------------------------------------------------\n\nvoid StringReplace(const string& s, const string& oldsub,\n                   const string& newsub, bool replace_all,\n                   string* res) {\n  if (oldsub.empty()) {\n    res->append(s);  // if empty, append the given string.\n    return;\n  }\n\n  string::size_type start_pos = 0;\n  string::size_type pos;\n  do {\n    pos = s.find(oldsub, start_pos);\n    if (pos == string::npos) {\n      break;\n    }\n    res->append(s, start_pos, pos - start_pos);\n    res->append(newsub);\n    start_pos = pos + oldsub.size();  // start searching again after the \"old\"\n  } while (replace_all);\n  res->append(s, start_pos, s.length() - start_pos);\n}\n\n// ----------------------------------------------------------------------\n// StringReplace()\n//    Give me a string and two patterns \"old\" and \"new\", and I replace\n//    the first instance of \"old\" in the string with \"new\", if it\n//    exists.  If \"global\" is true; call this repeatedly until it\n//    fails.  RETURN a new string, regardless of whether the replacement\n//    happened or not.\n// ----------------------------------------------------------------------\n\nstring StringReplace(const string& s, const string& oldsub,\n                     const string& newsub, bool replace_all) {\n  string ret;\n  StringReplace(s, oldsub, newsub, replace_all, &ret);\n  return ret;\n}\n\n// ----------------------------------------------------------------------\n// SplitStringUsing()\n//    Split a string using a character delimiter. Append the components\n//    to 'result'.\n//\n// Note: For multi-character delimiters, this routine will split on *ANY* of\n// the characters in the string, not the entire string as a single delimiter.\n// ----------------------------------------------------------------------\ntemplate <typename ITR>\nstatic inline\nvoid SplitStringToIteratorUsing(const string& full,\n                                const char* delim,\n                                ITR& result) {\n  // Optimize the common case where delim is a single character.\n  if (delim[0] != '\\0' && delim[1] == '\\0') {\n    char c = delim[0];\n    const char* p = full.data();\n    const char* end = p + full.size();\n    while (p != end) {\n      if (*p == c) {\n        ++p;\n      } else {\n        const char* start = p;\n        while (++p != end && *p != c);\n        *result++ = string(start, p - start);\n      }\n    }\n    return;\n  }\n\n  string::size_type begin_index, end_index;\n  begin_index = full.find_first_not_of(delim);\n  while (begin_index != string::npos) {\n    end_index = full.find_first_of(delim, begin_index);\n    if (end_index == string::npos) {\n      *result++ = full.substr(begin_index);\n      return;\n    }\n    *result++ = full.substr(begin_index, (end_index - begin_index));\n    begin_index = full.find_first_not_of(delim, end_index);\n  }\n}\n\nvoid SplitStringUsing(const string& full,\n                      const char* delim,\n                      vector<string>* result) {\n  back_insert_iterator< vector<string> > it(*result);\n  SplitStringToIteratorUsing(full, delim, it);\n}\n\n// Split a string using a character delimiter. Append the components\n// to 'result'.  If there are consecutive delimiters, this function\n// will return corresponding empty strings. The string is split into\n// at most the specified number of pieces greedily. This means that the\n// last piece may possibly be split further. To split into as many pieces\n// as possible, specify 0 as the number of pieces.\n//\n// If \"full\" is the empty string, yields an empty string as the only value.\n//\n// If \"pieces\" is negative for some reason, it returns the whole string\n// ----------------------------------------------------------------------\ntemplate <typename StringType, typename ITR>\nstatic inline\nvoid SplitStringToIteratorAllowEmpty(const StringType& full,\n                                     const char* delim,\n                                     int pieces,\n                                     ITR& result) {\n  string::size_type begin_index, end_index;\n  begin_index = 0;\n\n  for (int i = 0; (i < pieces-1) || (pieces == 0); i++) {\n    end_index = full.find_first_of(delim, begin_index);\n    if (end_index == string::npos) {\n      *result++ = full.substr(begin_index);\n      return;\n    }\n    *result++ = full.substr(begin_index, (end_index - begin_index));\n    begin_index = end_index + 1;\n  }\n  *result++ = full.substr(begin_index);\n}\n\nvoid SplitStringAllowEmpty(const string& full, const char* delim,\n                           vector<string>* result) {\n  back_insert_iterator<vector<string> > it(*result);\n  SplitStringToIteratorAllowEmpty(full, delim, 0, it);\n}\n\n// ----------------------------------------------------------------------\n// JoinStrings()\n//    This merges a vector of string components with delim inserted\n//    as separaters between components.\n//\n// ----------------------------------------------------------------------\ntemplate <class ITERATOR>\nstatic void JoinStringsIterator(const ITERATOR& start,\n                                const ITERATOR& end,\n                                const char* delim,\n                                string* result) {\n  GOOGLE_CHECK(result != NULL);\n  result->clear();\n  int delim_length = strlen(delim);\n\n  // Precompute resulting length so we can reserve() memory in one shot.\n  int length = 0;\n  for (ITERATOR iter = start; iter != end; ++iter) {\n    if (iter != start) {\n      length += delim_length;\n    }\n    length += iter->size();\n  }\n  result->reserve(length);\n\n  // Now combine everything.\n  for (ITERATOR iter = start; iter != end; ++iter) {\n    if (iter != start) {\n      result->append(delim, delim_length);\n    }\n    result->append(iter->data(), iter->size());\n  }\n}\n\nvoid JoinStrings(const vector<string>& components,\n                 const char* delim,\n                 string * result) {\n  JoinStringsIterator(components.begin(), components.end(), delim, result);\n}\n\n// ----------------------------------------------------------------------\n// UnescapeCEscapeSequences()\n//    This does all the unescaping that C does: \\ooo, \\r, \\n, etc\n//    Returns length of resulting string.\n//    The implementation of \\x parses any positive number of hex digits,\n//    but it is an error if the value requires more than 8 bits, and the\n//    result is truncated to 8 bits.\n//\n//    The second call stores its errors in a supplied string vector.\n//    If the string vector pointer is NULL, it reports the errors with LOG().\n// ----------------------------------------------------------------------\n\n#define IS_OCTAL_DIGIT(c) (((c) >= '0') && ((c) <= '7'))\n\n// Protocol buffers doesn't ever care about errors, but I don't want to remove\n// the code.\n#define LOG_STRING(LEVEL, VECTOR) GOOGLE_LOG_IF(LEVEL, false)\n\nint UnescapeCEscapeSequences(const char* source, char* dest) {\n  return UnescapeCEscapeSequences(source, dest, NULL);\n}\n\nint UnescapeCEscapeSequences(const char* source, char* dest,\n                             vector<string> *errors) {\n  GOOGLE_DCHECK(errors == NULL) << \"Error reporting not implemented.\";\n\n  char* d = dest;\n  const char* p = source;\n\n  // Small optimization for case where source = dest and there's no escaping\n  while ( p == d && *p != '\\0' && *p != '\\\\' )\n    p++, d++;\n\n  while (*p != '\\0') {\n    if (*p != '\\\\') {\n      *d++ = *p++;\n    } else {\n      switch ( *++p ) {                    // skip past the '\\\\'\n        case '\\0':\n          LOG_STRING(ERROR, errors) << \"String cannot end with \\\\\";\n          *d = '\\0';\n          return d - dest;   // we're done with p\n        case 'a':  *d++ = '\\a';  break;\n        case 'b':  *d++ = '\\b';  break;\n        case 'f':  *d++ = '\\f';  break;\n        case 'n':  *d++ = '\\n';  break;\n        case 'r':  *d++ = '\\r';  break;\n        case 't':  *d++ = '\\t';  break;\n        case 'v':  *d++ = '\\v';  break;\n        case '\\\\': *d++ = '\\\\';  break;\n        case '?':  *d++ = '\\?';  break;    // \\?  Who knew?\n        case '\\'': *d++ = '\\'';  break;\n        case '\"':  *d++ = '\\\"';  break;\n        case '0': case '1': case '2': case '3':  // octal digit: 1 to 3 digits\n        case '4': case '5': case '6': case '7': {\n          char ch = *p - '0';\n          if ( IS_OCTAL_DIGIT(p[1]) )\n            ch = ch * 8 + *++p - '0';\n          if ( IS_OCTAL_DIGIT(p[1]) )      // safe (and easy) to do this twice\n            ch = ch * 8 + *++p - '0';      // now points at last digit\n          *d++ = ch;\n          break;\n        }\n        case 'x': case 'X': {\n          if (!isxdigit(p[1])) {\n            if (p[1] == '\\0') {\n              LOG_STRING(ERROR, errors) << \"String cannot end with \\\\x\";\n            } else {\n              LOG_STRING(ERROR, errors) <<\n                \"\\\\x cannot be followed by non-hex digit: \\\\\" << *p << p[1];\n            }\n            break;\n          }\n          unsigned int ch = 0;\n          const char *hex_start = p;\n          while (isxdigit(p[1]))  // arbitrarily many hex digits\n            ch = (ch << 4) + hex_digit_to_int(*++p);\n          if (ch > 0xFF)\n            LOG_STRING(ERROR, errors) << \"Value of \" <<\n              \"\\\\\" << string(hex_start, p+1-hex_start) << \" exceeds 8 bits\";\n          *d++ = ch;\n          break;\n        }\n#if 0  // TODO(kenton):  Support \\u and \\U?  Requires runetochar().\n        case 'u': {\n          // \\uhhhh => convert 4 hex digits to UTF-8\n          char32 rune = 0;\n          const char *hex_start = p;\n          for (int i = 0; i < 4; ++i) {\n            if (isxdigit(p[1])) {  // Look one char ahead.\n              rune = (rune << 4) + hex_digit_to_int(*++p);  // Advance p.\n            } else {\n              LOG_STRING(ERROR, errors)\n                << \"\\\\u must be followed by 4 hex digits: \\\\\"\n                <<  string(hex_start, p+1-hex_start);\n              break;\n            }\n          }\n          d += runetochar(d, &rune);\n          break;\n        }\n        case 'U': {\n          // \\Uhhhhhhhh => convert 8 hex digits to UTF-8\n          char32 rune = 0;\n          const char *hex_start = p;\n          for (int i = 0; i < 8; ++i) {\n            if (isxdigit(p[1])) {  // Look one char ahead.\n              // Don't change rune until we're sure this\n              // is within the Unicode limit, but do advance p.\n              char32 newrune = (rune << 4) + hex_digit_to_int(*++p);\n              if (newrune > 0x10FFFF) {\n                LOG_STRING(ERROR, errors)\n                  << \"Value of \\\\\"\n                  << string(hex_start, p + 1 - hex_start)\n                  << \" exceeds Unicode limit (0x10FFFF)\";\n                break;\n              } else {\n                rune = newrune;\n              }\n            } else {\n              LOG_STRING(ERROR, errors)\n                << \"\\\\U must be followed by 8 hex digits: \\\\\"\n                <<  string(hex_start, p+1-hex_start);\n              break;\n            }\n          }\n          d += runetochar(d, &rune);\n          break;\n        }\n#endif\n        default:\n          LOG_STRING(ERROR, errors) << \"Unknown escape sequence: \\\\\" << *p;\n      }\n      p++;                                 // read past letter we escaped\n    }\n  }\n  *d = '\\0';\n  return d - dest;\n}\n\n// ----------------------------------------------------------------------\n// UnescapeCEscapeString()\n//    This does the same thing as UnescapeCEscapeSequences, but creates\n//    a new string. The caller does not need to worry about allocating\n//    a dest buffer. This should be used for non performance critical\n//    tasks such as printing debug messages. It is safe for src and dest\n//    to be the same.\n//\n//    The second call stores its errors in a supplied string vector.\n//    If the string vector pointer is NULL, it reports the errors with LOG().\n//\n//    In the first and second calls, the length of dest is returned. In the\n//    the third call, the new string is returned.\n// ----------------------------------------------------------------------\nint UnescapeCEscapeString(const string& src, string* dest) {\n  return UnescapeCEscapeString(src, dest, NULL);\n}\n\nint UnescapeCEscapeString(const string& src, string* dest,\n                          vector<string> *errors) {\n  scoped_array<char> unescaped(new char[src.size() + 1]);\n  int len = UnescapeCEscapeSequences(src.c_str(), unescaped.get(), errors);\n  GOOGLE_CHECK(dest);\n  dest->assign(unescaped.get(), len);\n  return len;\n}\n\nstring UnescapeCEscapeString(const string& src) {\n  scoped_array<char> unescaped(new char[src.size() + 1]);\n  int len = UnescapeCEscapeSequences(src.c_str(), unescaped.get(), NULL);\n  return string(unescaped.get(), len);\n}\n\n// ----------------------------------------------------------------------\n// CEscapeString()\n// CHexEscapeString()\n//    Copies 'src' to 'dest', escaping dangerous characters using\n//    C-style escape sequences. This is very useful for preparing query\n//    flags. 'src' and 'dest' should not overlap. The 'Hex' version uses\n//    hexadecimal rather than octal sequences.\n//    Returns the number of bytes written to 'dest' (not including the \\0)\n//    or -1 if there was insufficient space.\n//\n//    Currently only \\n, \\r, \\t, \", ', \\ and !isprint() chars are escaped.\n// ----------------------------------------------------------------------\nint CEscapeInternal(const char* src, int src_len, char* dest,\n                    int dest_len, bool use_hex, bool utf8_safe) {\n  const char* src_end = src + src_len;\n  int used = 0;\n  bool last_hex_escape = false; // true if last output char was \\xNN\n\n  for (; src < src_end; src++) {\n    if (dest_len - used < 2)   // Need space for two letter escape\n      return -1;\n\n    bool is_hex_escape = false;\n    switch (*src) {\n      case '\\n': dest[used++] = '\\\\'; dest[used++] = 'n';  break;\n      case '\\r': dest[used++] = '\\\\'; dest[used++] = 'r';  break;\n      case '\\t': dest[used++] = '\\\\'; dest[used++] = 't';  break;\n      case '\\\"': dest[used++] = '\\\\'; dest[used++] = '\\\"'; break;\n      case '\\'': dest[used++] = '\\\\'; dest[used++] = '\\''; break;\n      case '\\\\': dest[used++] = '\\\\'; dest[used++] = '\\\\'; break;\n      default:\n        // Note that if we emit \\xNN and the src character after that is a hex\n        // digit then that digit must be escaped too to prevent it being\n        // interpreted as part of the character code by C.\n        if ((!utf8_safe || static_cast<uint8>(*src) < 0x80) &&\n            (!isprint(*src) ||\n             (last_hex_escape && isxdigit(*src)))) {\n          if (dest_len - used < 4) // need space for 4 letter escape\n            return -1;\n          sprintf(dest + used, (use_hex ? \"\\\\x%02x\" : \"\\\\%03o\"),\n                  static_cast<uint8>(*src));\n          is_hex_escape = use_hex;\n          used += 4;\n        } else {\n          dest[used++] = *src; break;\n        }\n    }\n    last_hex_escape = is_hex_escape;\n  }\n\n  if (dest_len - used < 1)   // make sure that there is room for \\0\n    return -1;\n\n  dest[used] = '\\0';   // doesn't count towards return value though\n  return used;\n}\n\n// Calculates the length of the C-style escaped version of 'src'.\n// Assumes that non-printable characters are escaped using octal sequences, and\n// that UTF-8 bytes are not handled specially.\nstatic inline size_t CEscapedLength(StringPiece src) {\n  static char c_escaped_len[256] = {\n    4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 4, 4, 2, 4, 4,  // \\t, \\n, \\r\n    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,\n    1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,  // \", '\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  // '0'..'9'\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  // 'A'..'O'\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1,  // 'P'..'Z', '\\'\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  // 'a'..'o'\n    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4,  // 'p'..'z', DEL\n    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,\n    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,\n    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,\n    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,\n    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,\n    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,\n    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,\n    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,\n  };\n\n  size_t escaped_len = 0;\n  for (int i = 0; i < src.size(); ++i) {\n    unsigned char c = static_cast<unsigned char>(src[i]);\n    escaped_len += c_escaped_len[c];\n  }\n  return escaped_len;\n}\n\n// ----------------------------------------------------------------------\n// Escapes 'src' using C-style escape sequences, and appends the escaped string\n// to 'dest'. This version is faster than calling CEscapeInternal as it computes\n// the required space using a lookup table, and also does not do any special\n// handling for Hex or UTF-8 characters.\n// ----------------------------------------------------------------------\nvoid CEscapeAndAppend(StringPiece src, string* dest) {\n  size_t escaped_len = CEscapedLength(src);\n  if (escaped_len == src.size()) {\n    dest->append(src.data(), src.size());\n    return;\n  }\n\n  size_t cur_dest_len = dest->size();\n  dest->resize(cur_dest_len + escaped_len);\n  char* append_ptr = &(*dest)[cur_dest_len];\n\n  for (int i = 0; i < src.size(); ++i) {\n    unsigned char c = static_cast<unsigned char>(src[i]);\n    switch (c) {\n      case '\\n': *append_ptr++ = '\\\\'; *append_ptr++ = 'n'; break;\n      case '\\r': *append_ptr++ = '\\\\'; *append_ptr++ = 'r'; break;\n      case '\\t': *append_ptr++ = '\\\\'; *append_ptr++ = 't'; break;\n      case '\\\"': *append_ptr++ = '\\\\'; *append_ptr++ = '\\\"'; break;\n      case '\\'': *append_ptr++ = '\\\\'; *append_ptr++ = '\\''; break;\n      case '\\\\': *append_ptr++ = '\\\\'; *append_ptr++ = '\\\\'; break;\n      default:\n        if (!isprint(c)) {\n          *append_ptr++ = '\\\\';\n          *append_ptr++ = '0' + c / 64;\n          *append_ptr++ = '0' + (c % 64) / 8;\n          *append_ptr++ = '0' + c % 8;\n        } else {\n          *append_ptr++ = c;\n        }\n        break;\n    }\n  }\n}\n\nstring CEscape(const string& src) {\n  string dest;\n  CEscapeAndAppend(src, &dest);\n  return dest;\n}\n\nnamespace strings {\n\nstring Utf8SafeCEscape(const string& src) {\n  const int dest_length = src.size() * 4 + 1; // Maximum possible expansion\n  scoped_array<char> dest(new char[dest_length]);\n  const int len = CEscapeInternal(src.data(), src.size(),\n                                  dest.get(), dest_length, false, true);\n  GOOGLE_DCHECK_GE(len, 0);\n  return string(dest.get(), len);\n}\n\nstring CHexEscape(const string& src) {\n  const int dest_length = src.size() * 4 + 1; // Maximum possible expansion\n  scoped_array<char> dest(new char[dest_length]);\n  const int len = CEscapeInternal(src.data(), src.size(),\n                                  dest.get(), dest_length, true, false);\n  GOOGLE_DCHECK_GE(len, 0);\n  return string(dest.get(), len);\n}\n\n}  // namespace strings\n\n// ----------------------------------------------------------------------\n// strto32_adaptor()\n// strtou32_adaptor()\n//    Implementation of strto[u]l replacements that have identical\n//    overflow and underflow characteristics for both ILP-32 and LP-64\n//    platforms, including errno preservation in error-free calls.\n// ----------------------------------------------------------------------\n\nint32 strto32_adaptor(const char *nptr, char **endptr, int base) {\n  const int saved_errno = errno;\n  errno = 0;\n  const long result = strtol(nptr, endptr, base);\n  if (errno == ERANGE && result == LONG_MIN) {\n    return kint32min;\n  } else if (errno == ERANGE && result == LONG_MAX) {\n    return kint32max;\n  } else if (errno == 0 && result < kint32min) {\n    errno = ERANGE;\n    return kint32min;\n  } else if (errno == 0 && result > kint32max) {\n    errno = ERANGE;\n    return kint32max;\n  }\n  if (errno == 0)\n    errno = saved_errno;\n  return static_cast<int32>(result);\n}\n\nuint32 strtou32_adaptor(const char *nptr, char **endptr, int base) {\n  const int saved_errno = errno;\n  errno = 0;\n  const unsigned long result = strtoul(nptr, endptr, base);\n  if (errno == ERANGE && result == ULONG_MAX) {\n    return kuint32max;\n  } else if (errno == 0 && result > kuint32max) {\n    errno = ERANGE;\n    return kuint32max;\n  }\n  if (errno == 0)\n    errno = saved_errno;\n  return static_cast<uint32>(result);\n}\n\ninline bool safe_parse_sign(string* text  /*inout*/,\n                            bool* negative_ptr  /*output*/) {\n  const char* start = text->data();\n  const char* end = start + text->size();\n\n  // Consume whitespace.\n  while (start < end && (start[0] == ' ')) {\n    ++start;\n  }\n  while (start < end && (end[-1] == ' ')) {\n    --end;\n  }\n  if (start >= end) {\n    return false;\n  }\n\n  // Consume sign.\n  *negative_ptr = (start[0] == '-');\n  if (*negative_ptr || start[0] == '+') {\n    ++start;\n    if (start >= end) {\n      return false;\n    }\n  }\n  *text = text->substr(start - text->data(), end - start);\n  return true;\n}\n\ntemplate<typename IntType>\nbool safe_parse_positive_int(\n    string text, IntType* value_p) {\n  int base = 10;\n  IntType value = 0;\n  const IntType vmax = std::numeric_limits<IntType>::max();\n  assert(vmax > 0);\n  assert(vmax >= base);\n  const IntType vmax_over_base = vmax / base;\n  const char* start = text.data();\n  const char* end = start + text.size();\n  // loop over digits\n  for (; start < end; ++start) {\n    unsigned char c = static_cast<unsigned char>(start[0]);\n    int digit = c - '0';\n    if (digit >= base || digit < 0) {\n      *value_p = value;\n      return false;\n    }\n    if (value > vmax_over_base) {\n      *value_p = vmax;\n      return false;\n    }\n    value *= base;\n    if (value > vmax - digit) {\n      *value_p = vmax;\n      return false;\n    }\n    value += digit;\n  }\n  *value_p = value;\n  return true;\n}\n\ntemplate<typename IntType>\nbool safe_parse_negative_int(\n    const string& text, IntType* value_p) {\n  int base = 10;\n  IntType value = 0;\n  const IntType vmin = std::numeric_limits<IntType>::min();\n  assert(vmin < 0);\n  assert(vmin <= 0 - base);\n  IntType vmin_over_base = vmin / base;\n  // 2003 c++ standard [expr.mul]\n  // \"... the sign of the remainder is implementation-defined.\"\n  // Although (vmin/base)*base + vmin%base is always vmin.\n  // 2011 c++ standard tightens the spec but we cannot rely on it.\n  if (vmin % base > 0) {\n    vmin_over_base += 1;\n  }\n  const char* start = text.data();\n  const char* end = start + text.size();\n  // loop over digits\n  for (; start < end; ++start) {\n    unsigned char c = static_cast<unsigned char>(start[0]);\n    int digit = c - '0';\n    if (digit >= base || digit < 0) {\n      *value_p = value;\n      return false;\n    }\n    if (value < vmin_over_base) {\n      *value_p = vmin;\n      return false;\n    }\n    value *= base;\n    if (value < vmin + digit) {\n      *value_p = vmin;\n      return false;\n    }\n    value -= digit;\n  }\n  *value_p = value;\n  return true;\n}\n\ntemplate<typename IntType>\nbool safe_int_internal(string text, IntType* value_p) {\n  *value_p = 0;\n  bool negative;\n  if (!safe_parse_sign(&text, &negative)) {\n    return false;\n  }\n  if (!negative) {\n    return safe_parse_positive_int(text, value_p);\n  } else {\n    return safe_parse_negative_int(text, value_p);\n  }\n}\n\ntemplate<typename IntType>\nbool safe_uint_internal(string text, IntType* value_p) {\n  *value_p = 0;\n  bool negative;\n  if (!safe_parse_sign(&text, &negative) || negative) {\n    return false;\n  }\n  return safe_parse_positive_int(text, value_p);\n}\n\n// ----------------------------------------------------------------------\n// FastIntToBuffer()\n// FastInt64ToBuffer()\n// FastHexToBuffer()\n// FastHex64ToBuffer()\n// FastHex32ToBuffer()\n// ----------------------------------------------------------------------\n\n// Offset into buffer where FastInt64ToBuffer places the end of string\n// null character.  Also used by FastInt64ToBufferLeft.\nstatic const int kFastInt64ToBufferOffset = 21;\n\nchar *FastInt64ToBuffer(int64 i, char* buffer) {\n  // We could collapse the positive and negative sections, but that\n  // would be slightly slower for positive numbers...\n  // 22 bytes is enough to store -2**64, -18446744073709551616.\n  char* p = buffer + kFastInt64ToBufferOffset;\n  *p-- = '\\0';\n  if (i >= 0) {\n    do {\n      *p-- = '0' + i % 10;\n      i /= 10;\n    } while (i > 0);\n    return p + 1;\n  } else {\n    // On different platforms, % and / have different behaviors for\n    // negative numbers, so we need to jump through hoops to make sure\n    // we don't divide negative numbers.\n    if (i > -10) {\n      i = -i;\n      *p-- = '0' + i;\n      *p = '-';\n      return p;\n    } else {\n      // Make sure we aren't at MIN_INT, in which case we can't say i = -i\n      i = i + 10;\n      i = -i;\n      *p-- = '0' + i % 10;\n      // Undo what we did a moment ago\n      i = i / 10 + 1;\n      do {\n        *p-- = '0' + i % 10;\n        i /= 10;\n      } while (i > 0);\n      *p = '-';\n      return p;\n    }\n  }\n}\n\n// Offset into buffer where FastInt32ToBuffer places the end of string\n// null character.  Also used by FastInt32ToBufferLeft\nstatic const int kFastInt32ToBufferOffset = 11;\n\n// Yes, this is a duplicate of FastInt64ToBuffer.  But, we need this for the\n// compiler to generate 32 bit arithmetic instructions.  It's much faster, at\n// least with 32 bit binaries.\nchar *FastInt32ToBuffer(int32 i, char* buffer) {\n  // We could collapse the positive and negative sections, but that\n  // would be slightly slower for positive numbers...\n  // 12 bytes is enough to store -2**32, -4294967296.\n  char* p = buffer + kFastInt32ToBufferOffset;\n  *p-- = '\\0';\n  if (i >= 0) {\n    do {\n      *p-- = '0' + i % 10;\n      i /= 10;\n    } while (i > 0);\n    return p + 1;\n  } else {\n    // On different platforms, % and / have different behaviors for\n    // negative numbers, so we need to jump through hoops to make sure\n    // we don't divide negative numbers.\n    if (i > -10) {\n      i = -i;\n      *p-- = '0' + i;\n      *p = '-';\n      return p;\n    } else {\n      // Make sure we aren't at MIN_INT, in which case we can't say i = -i\n      i = i + 10;\n      i = -i;\n      *p-- = '0' + i % 10;\n      // Undo what we did a moment ago\n      i = i / 10 + 1;\n      do {\n        *p-- = '0' + i % 10;\n        i /= 10;\n      } while (i > 0);\n      *p = '-';\n      return p;\n    }\n  }\n}\n\nchar *FastHexToBuffer(int i, char* buffer) {\n  GOOGLE_CHECK(i >= 0) << \"FastHexToBuffer() wants non-negative integers, not \" << i;\n\n  static const char *hexdigits = \"0123456789abcdef\";\n  char *p = buffer + 21;\n  *p-- = '\\0';\n  do {\n    *p-- = hexdigits[i & 15];   // mod by 16\n    i >>= 4;                    // divide by 16\n  } while (i > 0);\n  return p + 1;\n}\n\nchar *InternalFastHexToBuffer(uint64 value, char* buffer, int num_byte) {\n  static const char *hexdigits = \"0123456789abcdef\";\n  buffer[num_byte] = '\\0';\n  for (int i = num_byte - 1; i >= 0; i--) {\n#ifdef _M_X64\n    // MSVC x64 platform has a bug optimizing the uint32(value) in the #else\n    // block. Given that the uint32 cast was to improve performance on 32-bit\n    // platforms, we use 64-bit '&' directly.\n    buffer[i] = hexdigits[value & 0xf];\n#else\n    buffer[i] = hexdigits[uint32(value) & 0xf];\n#endif\n    value >>= 4;\n  }\n  return buffer;\n}\n\nchar *FastHex64ToBuffer(uint64 value, char* buffer) {\n  return InternalFastHexToBuffer(value, buffer, 16);\n}\n\nchar *FastHex32ToBuffer(uint32 value, char* buffer) {\n  return InternalFastHexToBuffer(value, buffer, 8);\n}\n\n// ----------------------------------------------------------------------\n// FastInt32ToBufferLeft()\n// FastUInt32ToBufferLeft()\n// FastInt64ToBufferLeft()\n// FastUInt64ToBufferLeft()\n//\n// Like the Fast*ToBuffer() functions above, these are intended for speed.\n// Unlike the Fast*ToBuffer() functions, however, these functions write\n// their output to the beginning of the buffer (hence the name, as the\n// output is left-aligned).  The caller is responsible for ensuring that\n// the buffer has enough space to hold the output.\n//\n// Returns a pointer to the end of the string (i.e. the null character\n// terminating the string).\n// ----------------------------------------------------------------------\n\nstatic const char two_ASCII_digits[100][2] = {\n  {'0','0'}, {'0','1'}, {'0','2'}, {'0','3'}, {'0','4'},\n  {'0','5'}, {'0','6'}, {'0','7'}, {'0','8'}, {'0','9'},\n  {'1','0'}, {'1','1'}, {'1','2'}, {'1','3'}, {'1','4'},\n  {'1','5'}, {'1','6'}, {'1','7'}, {'1','8'}, {'1','9'},\n  {'2','0'}, {'2','1'}, {'2','2'}, {'2','3'}, {'2','4'},\n  {'2','5'}, {'2','6'}, {'2','7'}, {'2','8'}, {'2','9'},\n  {'3','0'}, {'3','1'}, {'3','2'}, {'3','3'}, {'3','4'},\n  {'3','5'}, {'3','6'}, {'3','7'}, {'3','8'}, {'3','9'},\n  {'4','0'}, {'4','1'}, {'4','2'}, {'4','3'}, {'4','4'},\n  {'4','5'}, {'4','6'}, {'4','7'}, {'4','8'}, {'4','9'},\n  {'5','0'}, {'5','1'}, {'5','2'}, {'5','3'}, {'5','4'},\n  {'5','5'}, {'5','6'}, {'5','7'}, {'5','8'}, {'5','9'},\n  {'6','0'}, {'6','1'}, {'6','2'}, {'6','3'}, {'6','4'},\n  {'6','5'}, {'6','6'}, {'6','7'}, {'6','8'}, {'6','9'},\n  {'7','0'}, {'7','1'}, {'7','2'}, {'7','3'}, {'7','4'},\n  {'7','5'}, {'7','6'}, {'7','7'}, {'7','8'}, {'7','9'},\n  {'8','0'}, {'8','1'}, {'8','2'}, {'8','3'}, {'8','4'},\n  {'8','5'}, {'8','6'}, {'8','7'}, {'8','8'}, {'8','9'},\n  {'9','0'}, {'9','1'}, {'9','2'}, {'9','3'}, {'9','4'},\n  {'9','5'}, {'9','6'}, {'9','7'}, {'9','8'}, {'9','9'}\n};\n\nchar* FastUInt32ToBufferLeft(uint32 u, char* buffer) {\n  int digits;\n  const char *ASCII_digits = NULL;\n  // The idea of this implementation is to trim the number of divides to as few\n  // as possible by using multiplication and subtraction rather than mod (%),\n  // and by outputting two digits at a time rather than one.\n  // The huge-number case is first, in the hopes that the compiler will output\n  // that case in one branch-free block of code, and only output conditional\n  // branches into it from below.\n  if (u >= 1000000000) {  // >= 1,000,000,000\n    digits = u / 100000000;  // 100,000,000\n    ASCII_digits = two_ASCII_digits[digits];\n    buffer[0] = ASCII_digits[0];\n    buffer[1] = ASCII_digits[1];\n    buffer += 2;\nsublt100_000_000:\n    u -= digits * 100000000;  // 100,000,000\nlt100_000_000:\n    digits = u / 1000000;  // 1,000,000\n    ASCII_digits = two_ASCII_digits[digits];\n    buffer[0] = ASCII_digits[0];\n    buffer[1] = ASCII_digits[1];\n    buffer += 2;\nsublt1_000_000:\n    u -= digits * 1000000;  // 1,000,000\nlt1_000_000:\n    digits = u / 10000;  // 10,000\n    ASCII_digits = two_ASCII_digits[digits];\n    buffer[0] = ASCII_digits[0];\n    buffer[1] = ASCII_digits[1];\n    buffer += 2;\nsublt10_000:\n    u -= digits * 10000;  // 10,000\nlt10_000:\n    digits = u / 100;\n    ASCII_digits = two_ASCII_digits[digits];\n    buffer[0] = ASCII_digits[0];\n    buffer[1] = ASCII_digits[1];\n    buffer += 2;\nsublt100:\n    u -= digits * 100;\nlt100:\n    digits = u;\n    ASCII_digits = two_ASCII_digits[digits];\n    buffer[0] = ASCII_digits[0];\n    buffer[1] = ASCII_digits[1];\n    buffer += 2;\ndone:\n    *buffer = 0;\n    return buffer;\n  }\n\n  if (u < 100) {\n    digits = u;\n    if (u >= 10) goto lt100;\n    *buffer++ = '0' + digits;\n    goto done;\n  }\n  if (u  <  10000) {   // 10,000\n    if (u >= 1000) goto lt10_000;\n    digits = u / 100;\n    *buffer++ = '0' + digits;\n    goto sublt100;\n  }\n  if (u  <  1000000) {   // 1,000,000\n    if (u >= 100000) goto lt1_000_000;\n    digits = u / 10000;  //    10,000\n    *buffer++ = '0' + digits;\n    goto sublt10_000;\n  }\n  if (u  <  100000000) {   // 100,000,000\n    if (u >= 10000000) goto lt100_000_000;\n    digits = u / 1000000;  //   1,000,000\n    *buffer++ = '0' + digits;\n    goto sublt1_000_000;\n  }\n  // we already know that u < 1,000,000,000\n  digits = u / 100000000;   // 100,000,000\n  *buffer++ = '0' + digits;\n  goto sublt100_000_000;\n}\n\nchar* FastInt32ToBufferLeft(int32 i, char* buffer) {\n  uint32 u = i;\n  if (i < 0) {\n    *buffer++ = '-';\n    u = -i;\n  }\n  return FastUInt32ToBufferLeft(u, buffer);\n}\n\nchar* FastUInt64ToBufferLeft(uint64 u64, char* buffer) {\n  int digits;\n  const char *ASCII_digits = NULL;\n\n  uint32 u = static_cast<uint32>(u64);\n  if (u == u64) return FastUInt32ToBufferLeft(u, buffer);\n\n  uint64 top_11_digits = u64 / 1000000000;\n  buffer = FastUInt64ToBufferLeft(top_11_digits, buffer);\n  u = u64 - (top_11_digits * 1000000000);\n\n  digits = u / 10000000;  // 10,000,000\n  GOOGLE_DCHECK_LT(digits, 100);\n  ASCII_digits = two_ASCII_digits[digits];\n  buffer[0] = ASCII_digits[0];\n  buffer[1] = ASCII_digits[1];\n  buffer += 2;\n  u -= digits * 10000000;  // 10,000,000\n  digits = u / 100000;  // 100,000\n  ASCII_digits = two_ASCII_digits[digits];\n  buffer[0] = ASCII_digits[0];\n  buffer[1] = ASCII_digits[1];\n  buffer += 2;\n  u -= digits * 100000;  // 100,000\n  digits = u / 1000;  // 1,000\n  ASCII_digits = two_ASCII_digits[digits];\n  buffer[0] = ASCII_digits[0];\n  buffer[1] = ASCII_digits[1];\n  buffer += 2;\n  u -= digits * 1000;  // 1,000\n  digits = u / 10;\n  ASCII_digits = two_ASCII_digits[digits];\n  buffer[0] = ASCII_digits[0];\n  buffer[1] = ASCII_digits[1];\n  buffer += 2;\n  u -= digits * 10;\n  digits = u;\n  *buffer++ = '0' + digits;\n  *buffer = 0;\n  return buffer;\n}\n\nchar* FastInt64ToBufferLeft(int64 i, char* buffer) {\n  uint64 u = i;\n  if (i < 0) {\n    *buffer++ = '-';\n    u = -i;\n  }\n  return FastUInt64ToBufferLeft(u, buffer);\n}\n\n// ----------------------------------------------------------------------\n// SimpleItoa()\n//    Description: converts an integer to a string.\n//\n//    Return value: string\n// ----------------------------------------------------------------------\n\nstring SimpleItoa(int i) {\n  char buffer[kFastToBufferSize];\n  return (sizeof(i) == 4) ?\n    FastInt32ToBuffer(i, buffer) :\n    FastInt64ToBuffer(i, buffer);\n}\n\nstring SimpleItoa(unsigned int i) {\n  char buffer[kFastToBufferSize];\n  return string(buffer, (sizeof(i) == 4) ?\n    FastUInt32ToBufferLeft(i, buffer) :\n    FastUInt64ToBufferLeft(i, buffer));\n}\n\nstring SimpleItoa(long i) {\n  char buffer[kFastToBufferSize];\n  return (sizeof(i) == 4) ?\n    FastInt32ToBuffer(i, buffer) :\n    FastInt64ToBuffer(i, buffer);\n}\n\nstring SimpleItoa(unsigned long i) {\n  char buffer[kFastToBufferSize];\n  return string(buffer, (sizeof(i) == 4) ?\n    FastUInt32ToBufferLeft(i, buffer) :\n    FastUInt64ToBufferLeft(i, buffer));\n}\n\nstring SimpleItoa(long long i) {\n  char buffer[kFastToBufferSize];\n  return (sizeof(i) == 4) ?\n    FastInt32ToBuffer(i, buffer) :\n    FastInt64ToBuffer(i, buffer);\n}\n\nstring SimpleItoa(unsigned long long i) {\n  char buffer[kFastToBufferSize];\n  return string(buffer, (sizeof(i) == 4) ?\n    FastUInt32ToBufferLeft(i, buffer) :\n    FastUInt64ToBufferLeft(i, buffer));\n}\n\n// ----------------------------------------------------------------------\n// SimpleDtoa()\n// SimpleFtoa()\n// DoubleToBuffer()\n// FloatToBuffer()\n//    We want to print the value without losing precision, but we also do\n//    not want to print more digits than necessary.  This turns out to be\n//    trickier than it sounds.  Numbers like 0.2 cannot be represented\n//    exactly in binary.  If we print 0.2 with a very large precision,\n//    e.g. \"%.50g\", we get \"0.2000000000000000111022302462515654042363167\".\n//    On the other hand, if we set the precision too low, we lose\n//    significant digits when printing numbers that actually need them.\n//    It turns out there is no precision value that does the right thing\n//    for all numbers.\n//\n//    Our strategy is to first try printing with a precision that is never\n//    over-precise, then parse the result with strtod() to see if it\n//    matches.  If not, we print again with a precision that will always\n//    give a precise result, but may use more digits than necessary.\n//\n//    An arguably better strategy would be to use the algorithm described\n//    in \"How to Print Floating-Point Numbers Accurately\" by Steele &\n//    White, e.g. as implemented by David M. Gay's dtoa().  It turns out,\n//    however, that the following implementation is about as fast as\n//    DMG's code.  Furthermore, DMG's code locks mutexes, which means it\n//    will not scale well on multi-core machines.  DMG's code is slightly\n//    more accurate (in that it will never use more digits than\n//    necessary), but this is probably irrelevant for most users.\n//\n//    Rob Pike and Ken Thompson also have an implementation of dtoa() in\n//    third_party/fmt/fltfmt.cc.  Their implementation is similar to this\n//    one in that it makes guesses and then uses strtod() to check them.\n//    Their implementation is faster because they use their own code to\n//    generate the digits in the first place rather than use snprintf(),\n//    thus avoiding format string parsing overhead.  However, this makes\n//    it considerably more complicated than the following implementation,\n//    and it is embedded in a larger library.  If speed turns out to be\n//    an issue, we could re-implement this in terms of their\n//    implementation.\n// ----------------------------------------------------------------------\n\nstring SimpleDtoa(double value) {\n  char buffer[kDoubleToBufferSize];\n  return DoubleToBuffer(value, buffer);\n}\n\nstring SimpleFtoa(float value) {\n  char buffer[kFloatToBufferSize];\n  return FloatToBuffer(value, buffer);\n}\n\nstatic inline bool IsValidFloatChar(char c) {\n  return ('0' <= c && c <= '9') ||\n         c == 'e' || c == 'E' ||\n         c == '+' || c == '-';\n}\n\nvoid DelocalizeRadix(char* buffer) {\n  // Fast check:  if the buffer has a normal decimal point, assume no\n  // translation is needed.\n  if (strchr(buffer, '.') != NULL) return;\n\n  // Find the first unknown character.\n  while (IsValidFloatChar(*buffer)) ++buffer;\n\n  if (*buffer == '\\0') {\n    // No radix character found.\n    return;\n  }\n\n  // We are now pointing at the locale-specific radix character.  Replace it\n  // with '.'.\n  *buffer = '.';\n  ++buffer;\n\n  if (!IsValidFloatChar(*buffer) && *buffer != '\\0') {\n    // It appears the radix was a multi-byte character.  We need to remove the\n    // extra bytes.\n    char* target = buffer;\n    do { ++buffer; } while (!IsValidFloatChar(*buffer) && *buffer != '\\0');\n    memmove(target, buffer, strlen(buffer) + 1);\n  }\n}\n\nchar* DoubleToBuffer(double value, char* buffer) {\n  // DBL_DIG is 15 for IEEE-754 doubles, which are used on almost all\n  // platforms these days.  Just in case some system exists where DBL_DIG\n  // is significantly larger -- and risks overflowing our buffer -- we have\n  // this assert.\n  GOOGLE_COMPILE_ASSERT(DBL_DIG < 20, DBL_DIG_is_too_big);\n\n  if (value == numeric_limits<double>::infinity()) {\n    strcpy(buffer, \"inf\");\n    return buffer;\n  } else if (value == -numeric_limits<double>::infinity()) {\n    strcpy(buffer, \"-inf\");\n    return buffer;\n  } else if (MathLimits<double>::IsNaN(value)) {\n    strcpy(buffer, \"nan\");\n    return buffer;\n  }\n\n  int snprintf_result =\n    snprintf(buffer, kDoubleToBufferSize, \"%.*g\", DBL_DIG, value);\n\n  // The snprintf should never overflow because the buffer is significantly\n  // larger than the precision we asked for.\n  GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize);\n\n  // We need to make parsed_value volatile in order to force the compiler to\n  // write it out to the stack.  Otherwise, it may keep the value in a\n  // register, and if it does that, it may keep it as a long double instead\n  // of a double.  This long double may have extra bits that make it compare\n  // unequal to \"value\" even though it would be exactly equal if it were\n  // truncated to a double.\n  volatile double parsed_value = strtod(buffer, NULL);\n  if (parsed_value != value) {\n    int snprintf_result =\n      snprintf(buffer, kDoubleToBufferSize, \"%.*g\", DBL_DIG+2, value);\n\n    // Should never overflow; see above.\n    GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize);\n  }\n\n  DelocalizeRadix(buffer);\n  return buffer;\n}\n\nstatic int memcasecmp(const char *s1, const char *s2, size_t len) {\n  const unsigned char *us1 = reinterpret_cast<const unsigned char *>(s1);\n  const unsigned char *us2 = reinterpret_cast<const unsigned char *>(s2);\n\n  for ( int i = 0; i < len; i++ ) {\n    const int diff =\n      static_cast<int>(static_cast<unsigned char>(ascii_tolower(us1[i]))) -\n      static_cast<int>(static_cast<unsigned char>(ascii_tolower(us2[i])));\n    if (diff != 0) return diff;\n  }\n  return 0;\n}\n\ninline bool CaseEqual(StringPiece s1, StringPiece s2) {\n  if (s1.size() != s2.size()) return false;\n  return memcasecmp(s1.data(), s2.data(), s1.size()) == 0;\n}\n\nbool safe_strtob(StringPiece str, bool* value) {\n  GOOGLE_CHECK(value != NULL) << \"NULL output boolean given.\";\n  if (CaseEqual(str, \"true\") || CaseEqual(str, \"t\") ||\n      CaseEqual(str, \"yes\") || CaseEqual(str, \"y\") ||\n      CaseEqual(str, \"1\")) {\n    *value = true;\n    return true;\n  }\n  if (CaseEqual(str, \"false\") || CaseEqual(str, \"f\") ||\n      CaseEqual(str, \"no\") || CaseEqual(str, \"n\") ||\n      CaseEqual(str, \"0\")) {\n    *value = false;\n    return true;\n  }\n  return false;\n}\n\nbool safe_strtof(const char* str, float* value) {\n  char* endptr;\n  errno = 0;  // errno only gets set on errors\n#if defined(_WIN32) || defined (__hpux)  // has no strtof()\n  *value = strtod(str, &endptr);\n#else\n  *value = strtof(str, &endptr);\n#endif\n  return *str != 0 && *endptr == 0 && errno == 0;\n}\n\nbool safe_strtod(const char* str, double* value) {\n  char* endptr;\n  *value = strtod(str, &endptr);\n  if (endptr != str) {\n    while (ascii_isspace(*endptr)) ++endptr;\n  }\n  // Ignore range errors from strtod.  The values it\n  // returns on underflow and overflow are the right\n  // fallback in a robust setting.\n  return *str != '\\0' && *endptr == '\\0';\n}\n\nbool safe_strto32(const string& str, int32* value) {\n  return safe_int_internal(str, value);\n}\n\nbool safe_strtou32(const string& str, uint32* value) {\n  return safe_uint_internal(str, value);\n}\n\nbool safe_strto64(const string& str, int64* value) {\n  return safe_int_internal(str, value);\n}\n\nbool safe_strtou64(const string& str, uint64* value) {\n  return safe_uint_internal(str, value);\n}\n\nchar* FloatToBuffer(float value, char* buffer) {\n  // FLT_DIG is 6 for IEEE-754 floats, which are used on almost all\n  // platforms these days.  Just in case some system exists where FLT_DIG\n  // is significantly larger -- and risks overflowing our buffer -- we have\n  // this assert.\n  GOOGLE_COMPILE_ASSERT(FLT_DIG < 10, FLT_DIG_is_too_big);\n\n  if (value == numeric_limits<double>::infinity()) {\n    strcpy(buffer, \"inf\");\n    return buffer;\n  } else if (value == -numeric_limits<double>::infinity()) {\n    strcpy(buffer, \"-inf\");\n    return buffer;\n  } else if (MathLimits<float>::IsNaN(value)) {\n    strcpy(buffer, \"nan\");\n    return buffer;\n  }\n\n  int snprintf_result =\n    snprintf(buffer, kFloatToBufferSize, \"%.*g\", FLT_DIG, value);\n\n  // The snprintf should never overflow because the buffer is significantly\n  // larger than the precision we asked for.\n  GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize);\n\n  float parsed_value;\n  if (!safe_strtof(buffer, &parsed_value) || parsed_value != value) {\n    int snprintf_result =\n      snprintf(buffer, kFloatToBufferSize, \"%.*g\", FLT_DIG+2, value);\n\n    // Should never overflow; see above.\n    GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kFloatToBufferSize);\n  }\n\n  DelocalizeRadix(buffer);\n  return buffer;\n}\n\nnamespace strings {\n\nAlphaNum::AlphaNum(strings::Hex hex) {\n  char *const end = &digits[kFastToBufferSize];\n  char *writer = end;\n  uint64 value = hex.value;\n  uint64 width = hex.spec;\n  // We accomplish minimum width by OR'ing in 0x10000 to the user's value,\n  // where 0x10000 is the smallest hex number that is as wide as the user\n  // asked for.\n  uint64 mask = ((static_cast<uint64>(1) << (width - 1) * 4)) | value;\n  static const char hexdigits[] = \"0123456789abcdef\";\n  do {\n    *--writer = hexdigits[value & 0xF];\n    value >>= 4;\n    mask >>= 4;\n  } while (mask != 0);\n  piece_data_ = writer;\n  piece_size_ = end - writer;\n}\n\n}  // namespace strings\n\n// ----------------------------------------------------------------------\n// StrCat()\n//    This merges the given strings or integers, with no delimiter.  This\n//    is designed to be the fastest possible way to construct a string out\n//    of a mix of raw C strings, C++ strings, and integer values.\n// ----------------------------------------------------------------------\n\n// Append is merely a version of memcpy that returns the address of the byte\n// after the area just overwritten.  It comes in multiple flavors to minimize\n// call overhead.\nstatic char *Append1(char *out, const AlphaNum &x) {\n  memcpy(out, x.data(), x.size());\n  return out + x.size();\n}\n\nstatic char *Append2(char *out, const AlphaNum &x1, const AlphaNum &x2) {\n  memcpy(out, x1.data(), x1.size());\n  out += x1.size();\n\n  memcpy(out, x2.data(), x2.size());\n  return out + x2.size();\n}\n\nstatic char *Append4(char *out,\n                     const AlphaNum &x1, const AlphaNum &x2,\n                     const AlphaNum &x3, const AlphaNum &x4) {\n  memcpy(out, x1.data(), x1.size());\n  out += x1.size();\n\n  memcpy(out, x2.data(), x2.size());\n  out += x2.size();\n\n  memcpy(out, x3.data(), x3.size());\n  out += x3.size();\n\n  memcpy(out, x4.data(), x4.size());\n  return out + x4.size();\n}\n\nstring StrCat(const AlphaNum &a, const AlphaNum &b) {\n  string result;\n  result.resize(a.size() + b.size());\n  char *const begin = &*result.begin();\n  char *out = Append2(begin, a, b);\n  GOOGLE_DCHECK_EQ(out, begin + result.size());\n  return result;\n}\n\nstring StrCat(const AlphaNum &a, const AlphaNum &b, const AlphaNum &c) {\n  string result;\n  result.resize(a.size() + b.size() + c.size());\n  char *const begin = &*result.begin();\n  char *out = Append2(begin, a, b);\n  out = Append1(out, c);\n  GOOGLE_DCHECK_EQ(out, begin + result.size());\n  return result;\n}\n\nstring StrCat(const AlphaNum &a, const AlphaNum &b, const AlphaNum &c,\n              const AlphaNum &d) {\n  string result;\n  result.resize(a.size() + b.size() + c.size() + d.size());\n  char *const begin = &*result.begin();\n  char *out = Append4(begin, a, b, c, d);\n  GOOGLE_DCHECK_EQ(out, begin + result.size());\n  return result;\n}\n\nstring StrCat(const AlphaNum &a, const AlphaNum &b, const AlphaNum &c,\n              const AlphaNum &d, const AlphaNum &e) {\n  string result;\n  result.resize(a.size() + b.size() + c.size() + d.size() + e.size());\n  char *const begin = &*result.begin();\n  char *out = Append4(begin, a, b, c, d);\n  out = Append1(out, e);\n  GOOGLE_DCHECK_EQ(out, begin + result.size());\n  return result;\n}\n\nstring StrCat(const AlphaNum &a, const AlphaNum &b, const AlphaNum &c,\n              const AlphaNum &d, const AlphaNum &e, const AlphaNum &f) {\n  string result;\n  result.resize(a.size() + b.size() + c.size() + d.size() + e.size() +\n                f.size());\n  char *const begin = &*result.begin();\n  char *out = Append4(begin, a, b, c, d);\n  out = Append2(out, e, f);\n  GOOGLE_DCHECK_EQ(out, begin + result.size());\n  return result;\n}\n\nstring StrCat(const AlphaNum &a, const AlphaNum &b, const AlphaNum &c,\n              const AlphaNum &d, const AlphaNum &e, const AlphaNum &f,\n              const AlphaNum &g) {\n  string result;\n  result.resize(a.size() + b.size() + c.size() + d.size() + e.size() +\n                f.size() + g.size());\n  char *const begin = &*result.begin();\n  char *out = Append4(begin, a, b, c, d);\n  out = Append2(out, e, f);\n  out = Append1(out, g);\n  GOOGLE_DCHECK_EQ(out, begin + result.size());\n  return result;\n}\n\nstring StrCat(const AlphaNum &a, const AlphaNum &b, const AlphaNum &c,\n              const AlphaNum &d, const AlphaNum &e, const AlphaNum &f,\n              const AlphaNum &g, const AlphaNum &h) {\n  string result;\n  result.resize(a.size() + b.size() + c.size() + d.size() + e.size() +\n                f.size() + g.size() + h.size());\n  char *const begin = &*result.begin();\n  char *out = Append4(begin, a, b, c, d);\n  out = Append4(out, e, f, g, h);\n  GOOGLE_DCHECK_EQ(out, begin + result.size());\n  return result;\n}\n\nstring StrCat(const AlphaNum &a, const AlphaNum &b, const AlphaNum &c,\n              const AlphaNum &d, const AlphaNum &e, const AlphaNum &f,\n              const AlphaNum &g, const AlphaNum &h, const AlphaNum &i) {\n  string result;\n  result.resize(a.size() + b.size() + c.size() + d.size() + e.size() +\n                f.size() + g.size() + h.size() + i.size());\n  char *const begin = &*result.begin();\n  char *out = Append4(begin, a, b, c, d);\n  out = Append4(out, e, f, g, h);\n  out = Append1(out, i);\n  GOOGLE_DCHECK_EQ(out, begin + result.size());\n  return result;\n}\n\n// It's possible to call StrAppend with a char * pointer that is partway into\n// the string we're appending to.  However the results of this are random.\n// Therefore, check for this in debug mode.  Use unsigned math so we only have\n// to do one comparison.\n#define GOOGLE_DCHECK_NO_OVERLAP(dest, src) \\\n    GOOGLE_DCHECK_GT(uintptr_t((src).data() - (dest).data()), \\\n                     uintptr_t((dest).size()))\n\nvoid StrAppend(string *result, const AlphaNum &a) {\n  GOOGLE_DCHECK_NO_OVERLAP(*result, a);\n  result->append(a.data(), a.size());\n}\n\nvoid StrAppend(string *result, const AlphaNum &a, const AlphaNum &b) {\n  GOOGLE_DCHECK_NO_OVERLAP(*result, a);\n  GOOGLE_DCHECK_NO_OVERLAP(*result, b);\n  string::size_type old_size = result->size();\n  result->resize(old_size + a.size() + b.size());\n  char *const begin = &*result->begin();\n  char *out = Append2(begin + old_size, a, b);\n  GOOGLE_DCHECK_EQ(out, begin + result->size());\n}\n\nvoid StrAppend(string *result,\n               const AlphaNum &a, const AlphaNum &b, const AlphaNum &c) {\n  GOOGLE_DCHECK_NO_OVERLAP(*result, a);\n  GOOGLE_DCHECK_NO_OVERLAP(*result, b);\n  GOOGLE_DCHECK_NO_OVERLAP(*result, c);\n  string::size_type old_size = result->size();\n  result->resize(old_size + a.size() + b.size() + c.size());\n  char *const begin = &*result->begin();\n  char *out = Append2(begin + old_size, a, b);\n  out = Append1(out, c);\n  GOOGLE_DCHECK_EQ(out, begin + result->size());\n}\n\nvoid StrAppend(string *result,\n               const AlphaNum &a, const AlphaNum &b,\n               const AlphaNum &c, const AlphaNum &d) {\n  GOOGLE_DCHECK_NO_OVERLAP(*result, a);\n  GOOGLE_DCHECK_NO_OVERLAP(*result, b);\n  GOOGLE_DCHECK_NO_OVERLAP(*result, c);\n  GOOGLE_DCHECK_NO_OVERLAP(*result, d);\n  string::size_type old_size = result->size();\n  result->resize(old_size + a.size() + b.size() + c.size() + d.size());\n  char *const begin = &*result->begin();\n  char *out = Append4(begin + old_size, a, b, c, d);\n  GOOGLE_DCHECK_EQ(out, begin + result->size());\n}\n\nint GlobalReplaceSubstring(const string& substring,\n                           const string& replacement,\n                           string* s) {\n  GOOGLE_CHECK(s != NULL);\n  if (s->empty() || substring.empty())\n    return 0;\n  string tmp;\n  int num_replacements = 0;\n  int pos = 0;\n  for (int match_pos = s->find(substring.data(), pos, substring.length());\n       match_pos != string::npos;\n       pos = match_pos + substring.length(),\n           match_pos = s->find(substring.data(), pos, substring.length())) {\n    ++num_replacements;\n    // Append the original content before the match.\n    tmp.append(*s, pos, match_pos - pos);\n    // Append the replacement for the match.\n    tmp.append(replacement.begin(), replacement.end());\n  }\n  // Append the content after the last match. If no replacements were made, the\n  // original string is left untouched.\n  if (num_replacements > 0) {\n    tmp.append(*s, pos, s->length() - pos);\n    s->swap(tmp);\n  }\n  return num_replacements;\n}\n\nint CalculateBase64EscapedLen(int input_len, bool do_padding) {\n  // Base64 encodes three bytes of input at a time. If the input is not\n  // divisible by three, we pad as appropriate.\n  //\n  // (from http://tools.ietf.org/html/rfc3548)\n  // Special processing is performed if fewer than 24 bits are available\n  // at the end of the data being encoded.  A full encoding quantum is\n  // always completed at the end of a quantity.  When fewer than 24 input\n  // bits are available in an input group, zero bits are added (on the\n  // right) to form an integral number of 6-bit groups.  Padding at the\n  // end of the data is performed using the '=' character.  Since all base\n  // 64 input is an integral number of octets, only the following cases\n  // can arise:\n\n\n  // Base64 encodes each three bytes of input into four bytes of output.\n  int len = (input_len / 3) * 4;\n\n  if (input_len % 3 == 0) {\n    // (from http://tools.ietf.org/html/rfc3548)\n    // (1) the final quantum of encoding input is an integral multiple of 24\n    // bits; here, the final unit of encoded output will be an integral\n    // multiple of 4 characters with no \"=\" padding,\n  } else if (input_len % 3 == 1) {\n    // (from http://tools.ietf.org/html/rfc3548)\n    // (2) the final quantum of encoding input is exactly 8 bits; here, the\n    // final unit of encoded output will be two characters followed by two\n    // \"=\" padding characters, or\n    len += 2;\n    if (do_padding) {\n      len += 2;\n    }\n  } else {  // (input_len % 3 == 2)\n    // (from http://tools.ietf.org/html/rfc3548)\n    // (3) the final quantum of encoding input is exactly 16 bits; here, the\n    // final unit of encoded output will be three characters followed by one\n    // \"=\" padding character.\n    len += 3;\n    if (do_padding) {\n      len += 1;\n    }\n  }\n\n  assert(len >= input_len);  // make sure we didn't overflow\n  return len;\n}\n\n// Base64Escape does padding, so this calculation includes padding.\nint CalculateBase64EscapedLen(int input_len) {\n  return CalculateBase64EscapedLen(input_len, true);\n}\n\n// ----------------------------------------------------------------------\n// int Base64Unescape() - base64 decoder\n// int Base64Escape() - base64 encoder\n// int WebSafeBase64Unescape() - Google's variation of base64 decoder\n// int WebSafeBase64Escape() - Google's variation of base64 encoder\n//\n// Check out\n// http://tools.ietf.org/html/rfc2045 for formal description, but what we\n// care about is that...\n//   Take the encoded stuff in groups of 4 characters and turn each\n//   character into a code 0 to 63 thus:\n//           A-Z map to 0 to 25\n//           a-z map to 26 to 51\n//           0-9 map to 52 to 61\n//           +(- for WebSafe) maps to 62\n//           /(_ for WebSafe) maps to 63\n//   There will be four numbers, all less than 64 which can be represented\n//   by a 6 digit binary number (aaaaaa, bbbbbb, cccccc, dddddd respectively).\n//   Arrange the 6 digit binary numbers into three bytes as such:\n//   aaaaaabb bbbbcccc ccdddddd\n//   Equals signs (one or two) are used at the end of the encoded block to\n//   indicate that the text was not an integer multiple of three bytes long.\n// ----------------------------------------------------------------------\n\nint Base64UnescapeInternal(const char *src_param, int szsrc,\n                           char *dest, int szdest,\n                           const signed char* unbase64) {\n  static const char kPad64Equals = '=';\n  static const char kPad64Dot = '.';\n\n  int decode = 0;\n  int destidx = 0;\n  int state = 0;\n  unsigned int ch = 0;\n  unsigned int temp = 0;\n\n  // If \"char\" is signed by default, using *src as an array index results in\n  // accessing negative array elements. Treat the input as a pointer to\n  // unsigned char to avoid this.\n  const unsigned char *src = reinterpret_cast<const unsigned char*>(src_param);\n\n  // The GET_INPUT macro gets the next input character, skipping\n  // over any whitespace, and stopping when we reach the end of the\n  // string or when we read any non-data character.  The arguments are\n  // an arbitrary identifier (used as a label for goto) and the number\n  // of data bytes that must remain in the input to avoid aborting the\n  // loop.\n#define GET_INPUT(label, remain)                 \\\n  label:                                         \\\n    --szsrc;                                     \\\n    ch = *src++;                                 \\\n    decode = unbase64[ch];                       \\\n    if (decode < 0) {                            \\\n      if (ascii_isspace(ch) && szsrc >= remain)  \\\n        goto label;                              \\\n      state = 4 - remain;                        \\\n      break;                                     \\\n    }\n\n  // if dest is null, we're just checking to see if it's legal input\n  // rather than producing output.  (I suspect this could just be done\n  // with a regexp...).  We duplicate the loop so this test can be\n  // outside it instead of in every iteration.\n\n  if (dest) {\n    // This loop consumes 4 input bytes and produces 3 output bytes\n    // per iteration.  We can't know at the start that there is enough\n    // data left in the string for a full iteration, so the loop may\n    // break out in the middle; if so 'state' will be set to the\n    // number of input bytes read.\n\n    while (szsrc >= 4)  {\n      // We'll start by optimistically assuming that the next four\n      // bytes of the string (src[0..3]) are four good data bytes\n      // (that is, no nulls, whitespace, padding chars, or illegal\n      // chars).  We need to test src[0..2] for nulls individually\n      // before constructing temp to preserve the property that we\n      // never read past a null in the string (no matter how long\n      // szsrc claims the string is).\n\n      if (!src[0] || !src[1] || !src[2] ||\n          (temp = ((unsigned(unbase64[src[0]]) << 18) |\n                   (unsigned(unbase64[src[1]]) << 12) |\n                   (unsigned(unbase64[src[2]]) << 6) |\n                   (unsigned(unbase64[src[3]])))) & 0x80000000) {\n        // Iff any of those four characters was bad (null, illegal,\n        // whitespace, padding), then temp's high bit will be set\n        // (because unbase64[] is -1 for all bad characters).\n        //\n        // We'll back up and resort to the slower decoder, which knows\n        // how to handle those cases.\n\n        GET_INPUT(first, 4);\n        temp = decode;\n        GET_INPUT(second, 3);\n        temp = (temp << 6) | decode;\n        GET_INPUT(third, 2);\n        temp = (temp << 6) | decode;\n        GET_INPUT(fourth, 1);\n        temp = (temp << 6) | decode;\n      } else {\n        // We really did have four good data bytes, so advance four\n        // characters in the string.\n\n        szsrc -= 4;\n        src += 4;\n        decode = -1;\n        ch = '\\0';\n      }\n\n      // temp has 24 bits of input, so write that out as three bytes.\n\n      if (destidx+3 > szdest) return -1;\n      dest[destidx+2] = temp;\n      temp >>= 8;\n      dest[destidx+1] = temp;\n      temp >>= 8;\n      dest[destidx] = temp;\n      destidx += 3;\n    }\n  } else {\n    while (szsrc >= 4)  {\n      if (!src[0] || !src[1] || !src[2] ||\n          (temp = ((unsigned(unbase64[src[0]]) << 18) |\n                   (unsigned(unbase64[src[1]]) << 12) |\n                   (unsigned(unbase64[src[2]]) << 6) |\n                   (unsigned(unbase64[src[3]])))) & 0x80000000) {\n        GET_INPUT(first_no_dest, 4);\n        GET_INPUT(second_no_dest, 3);\n        GET_INPUT(third_no_dest, 2);\n        GET_INPUT(fourth_no_dest, 1);\n      } else {\n        szsrc -= 4;\n        src += 4;\n        decode = -1;\n        ch = '\\0';\n      }\n      destidx += 3;\n    }\n  }\n\n#undef GET_INPUT\n\n  // if the loop terminated because we read a bad character, return\n  // now.\n  if (decode < 0 && ch != '\\0' &&\n      ch != kPad64Equals && ch != kPad64Dot && !ascii_isspace(ch))\n    return -1;\n\n  if (ch == kPad64Equals || ch == kPad64Dot) {\n    // if we stopped by hitting an '=' or '.', un-read that character -- we'll\n    // look at it again when we count to check for the proper number of\n    // equals signs at the end.\n    ++szsrc;\n    --src;\n  } else {\n    // This loop consumes 1 input byte per iteration.  It's used to\n    // clean up the 0-3 input bytes remaining when the first, faster\n    // loop finishes.  'temp' contains the data from 'state' input\n    // characters read by the first loop.\n    while (szsrc > 0)  {\n      --szsrc;\n      ch = *src++;\n      decode = unbase64[ch];\n      if (decode < 0) {\n        if (ascii_isspace(ch)) {\n          continue;\n        } else if (ch == '\\0') {\n          break;\n        } else if (ch == kPad64Equals || ch == kPad64Dot) {\n          // back up one character; we'll read it again when we check\n          // for the correct number of pad characters at the end.\n          ++szsrc;\n          --src;\n          break;\n        } else {\n          return -1;\n        }\n      }\n\n      // Each input character gives us six bits of output.\n      temp = (temp << 6) | decode;\n      ++state;\n      if (state == 4) {\n        // If we've accumulated 24 bits of output, write that out as\n        // three bytes.\n        if (dest) {\n          if (destidx+3 > szdest) return -1;\n          dest[destidx+2] = temp;\n          temp >>= 8;\n          dest[destidx+1] = temp;\n          temp >>= 8;\n          dest[destidx] = temp;\n        }\n        destidx += 3;\n        state = 0;\n        temp = 0;\n      }\n    }\n  }\n\n  // Process the leftover data contained in 'temp' at the end of the input.\n  int expected_equals = 0;\n  switch (state) {\n    case 0:\n      // Nothing left over; output is a multiple of 3 bytes.\n      break;\n\n    case 1:\n      // Bad input; we have 6 bits left over.\n      return -1;\n\n    case 2:\n      // Produce one more output byte from the 12 input bits we have left.\n      if (dest) {\n        if (destidx+1 > szdest) return -1;\n        temp >>= 4;\n        dest[destidx] = temp;\n      }\n      ++destidx;\n      expected_equals = 2;\n      break;\n\n    case 3:\n      // Produce two more output bytes from the 18 input bits we have left.\n      if (dest) {\n        if (destidx+2 > szdest) return -1;\n        temp >>= 2;\n        dest[destidx+1] = temp;\n        temp >>= 8;\n        dest[destidx] = temp;\n      }\n      destidx += 2;\n      expected_equals = 1;\n      break;\n\n    default:\n      // state should have no other values at this point.\n      GOOGLE_LOG(FATAL) << \"This can't happen; base64 decoder state = \" << state;\n  }\n\n  // The remainder of the string should be all whitespace, mixed with\n  // exactly 0 equals signs, or exactly 'expected_equals' equals\n  // signs.  (Always accepting 0 equals signs is a google extension\n  // not covered in the RFC, as is accepting dot as the pad character.)\n\n  int equals = 0;\n  while (szsrc > 0 && *src) {\n    if (*src == kPad64Equals || *src == kPad64Dot)\n      ++equals;\n    else if (!ascii_isspace(*src))\n      return -1;\n    --szsrc;\n    ++src;\n  }\n\n  return (equals == 0 || equals == expected_equals) ? destidx : -1;\n}\n\n// The arrays below were generated by the following code\n// #include <sys/time.h>\n// #include <stdlib.h>\n// #include <string.h>\n// main()\n// {\n//   static const char Base64[] =\n//     \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n//   char *pos;\n//   int idx, i, j;\n//   printf(\"    \");\n//   for (i = 0; i < 255; i += 8) {\n//     for (j = i; j < i + 8; j++) {\n//       pos = strchr(Base64, j);\n//       if ((pos == NULL) || (j == 0))\n//         idx = -1;\n//       else\n//         idx = pos - Base64;\n//       if (idx == -1)\n//         printf(\" %2d,     \", idx);\n//       else\n//         printf(\" %2d/*%c*/,\", idx, j);\n//     }\n//     printf(\"\\n    \");\n//   }\n// }\n//\n// where the value of \"Base64[]\" was replaced by one of the base-64 conversion\n// tables from the functions below.\nstatic const signed char kUnBase64[] = {\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      62/*+*/, -1,      -1,      -1,      63/*/ */,\n  52/*0*/, 53/*1*/, 54/*2*/, 55/*3*/, 56/*4*/, 57/*5*/, 58/*6*/, 59/*7*/,\n  60/*8*/, 61/*9*/, -1,      -1,      -1,      -1,      -1,      -1,\n  -1,       0/*A*/,  1/*B*/,  2/*C*/,  3/*D*/,  4/*E*/,  5/*F*/,  6/*G*/,\n  07/*H*/,  8/*I*/,  9/*J*/, 10/*K*/, 11/*L*/, 12/*M*/, 13/*N*/, 14/*O*/,\n  15/*P*/, 16/*Q*/, 17/*R*/, 18/*S*/, 19/*T*/, 20/*U*/, 21/*V*/, 22/*W*/,\n  23/*X*/, 24/*Y*/, 25/*Z*/, -1,      -1,      -1,      -1,      -1,\n  -1,      26/*a*/, 27/*b*/, 28/*c*/, 29/*d*/, 30/*e*/, 31/*f*/, 32/*g*/,\n  33/*h*/, 34/*i*/, 35/*j*/, 36/*k*/, 37/*l*/, 38/*m*/, 39/*n*/, 40/*o*/,\n  41/*p*/, 42/*q*/, 43/*r*/, 44/*s*/, 45/*t*/, 46/*u*/, 47/*v*/, 48/*w*/,\n  49/*x*/, 50/*y*/, 51/*z*/, -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1\n};\nstatic const signed char kUnWebSafeBase64[] = {\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      62/*-*/, -1,      -1,\n  52/*0*/, 53/*1*/, 54/*2*/, 55/*3*/, 56/*4*/, 57/*5*/, 58/*6*/, 59/*7*/,\n  60/*8*/, 61/*9*/, -1,      -1,      -1,      -1,      -1,      -1,\n  -1,       0/*A*/,  1/*B*/,  2/*C*/,  3/*D*/,  4/*E*/,  5/*F*/,  6/*G*/,\n  07/*H*/,  8/*I*/,  9/*J*/, 10/*K*/, 11/*L*/, 12/*M*/, 13/*N*/, 14/*O*/,\n  15/*P*/, 16/*Q*/, 17/*R*/, 18/*S*/, 19/*T*/, 20/*U*/, 21/*V*/, 22/*W*/,\n  23/*X*/, 24/*Y*/, 25/*Z*/, -1,      -1,      -1,      -1,      63/*_*/,\n  -1,      26/*a*/, 27/*b*/, 28/*c*/, 29/*d*/, 30/*e*/, 31/*f*/, 32/*g*/,\n  33/*h*/, 34/*i*/, 35/*j*/, 36/*k*/, 37/*l*/, 38/*m*/, 39/*n*/, 40/*o*/,\n  41/*p*/, 42/*q*/, 43/*r*/, 44/*s*/, 45/*t*/, 46/*u*/, 47/*v*/, 48/*w*/,\n  49/*x*/, 50/*y*/, 51/*z*/, -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1,\n  -1,      -1,      -1,      -1,      -1,      -1,      -1,      -1\n};\n\nint WebSafeBase64Unescape(const char *src, int szsrc, char *dest, int szdest) {\n  return Base64UnescapeInternal(src, szsrc, dest, szdest, kUnWebSafeBase64);\n}\n\nstatic bool Base64UnescapeInternal(const char* src, int slen, string* dest,\n                                   const signed char* unbase64) {\n  // Determine the size of the output string.  Base64 encodes every 3 bytes into\n  // 4 characters.  any leftover chars are added directly for good measure.\n  // This is documented in the base64 RFC: http://tools.ietf.org/html/rfc3548\n  const int dest_len = 3 * (slen / 4) + (slen % 4);\n\n  dest->resize(dest_len);\n\n  // We are getting the destination buffer by getting the beginning of the\n  // string and converting it into a char *.\n  const int len = Base64UnescapeInternal(src, slen, string_as_array(dest),\n                                         dest_len, unbase64);\n  if (len < 0) {\n    dest->clear();\n    return false;\n  }\n\n  // could be shorter if there was padding\n  GOOGLE_DCHECK_LE(len, dest_len);\n  dest->erase(len);\n\n  return true;\n}\n\nbool Base64Unescape(StringPiece src, string* dest) {\n  return Base64UnescapeInternal(src.data(), src.size(), dest, kUnBase64);\n}\n\nbool WebSafeBase64Unescape(StringPiece src, string* dest) {\n  return Base64UnescapeInternal(src.data(), src.size(), dest, kUnWebSafeBase64);\n}\n\nint Base64EscapeInternal(const unsigned char *src, int szsrc,\n                         char *dest, int szdest, const char *base64,\n                         bool do_padding) {\n  static const char kPad64 = '=';\n\n  if (szsrc <= 0) return 0;\n\n  if (szsrc * 4 > szdest * 3) return 0;\n\n  char *cur_dest = dest;\n  const unsigned char *cur_src = src;\n\n  char *limit_dest = dest + szdest;\n  const unsigned char *limit_src = src + szsrc;\n\n  // Three bytes of data encodes to four characters of cyphertext.\n  // So we can pump through three-byte chunks atomically.\n  while (cur_src < limit_src - 3) {  // keep going as long as we have >= 32 bits\n    uint32 in = BigEndian::Load32(cur_src) >> 8;\n\n    cur_dest[0] = base64[in >> 18];\n    in &= 0x3FFFF;\n    cur_dest[1] = base64[in >> 12];\n    in &= 0xFFF;\n    cur_dest[2] = base64[in >> 6];\n    in &= 0x3F;\n    cur_dest[3] = base64[in];\n\n    cur_dest += 4;\n    cur_src += 3;\n  }\n  // To save time, we didn't update szdest or szsrc in the loop.  So do it now.\n  szdest = limit_dest - cur_dest;\n  szsrc = limit_src - cur_src;\n\n  /* now deal with the tail (<=3 bytes) */\n  switch (szsrc) {\n    case 0:\n      // Nothing left; nothing more to do.\n      break;\n    case 1: {\n      // One byte left: this encodes to two characters, and (optionally)\n      // two pad characters to round out the four-character cypherblock.\n      if ((szdest -= 2) < 0) return 0;\n      uint32 in = cur_src[0];\n      cur_dest[0] = base64[in >> 2];\n      in &= 0x3;\n      cur_dest[1] = base64[in << 4];\n      cur_dest += 2;\n      if (do_padding) {\n        if ((szdest -= 2) < 0) return 0;\n        cur_dest[0] = kPad64;\n        cur_dest[1] = kPad64;\n        cur_dest += 2;\n      }\n      break;\n    }\n    case 2: {\n      // Two bytes left: this encodes to three characters, and (optionally)\n      // one pad character to round out the four-character cypherblock.\n      if ((szdest -= 3) < 0) return 0;\n      uint32 in = BigEndian::Load16(cur_src);\n      cur_dest[0] = base64[in >> 10];\n      in &= 0x3FF;\n      cur_dest[1] = base64[in >> 4];\n      in &= 0x00F;\n      cur_dest[2] = base64[in << 2];\n      cur_dest += 3;\n      if (do_padding) {\n        if ((szdest -= 1) < 0) return 0;\n        cur_dest[0] = kPad64;\n        cur_dest += 1;\n      }\n      break;\n    }\n    case 3: {\n      // Three bytes left: same as in the big loop above.  We can't do this in\n      // the loop because the loop above always reads 4 bytes, and the fourth\n      // byte is past the end of the input.\n      if ((szdest -= 4) < 0) return 0;\n      uint32 in = (cur_src[0] << 16) + BigEndian::Load16(cur_src + 1);\n      cur_dest[0] = base64[in >> 18];\n      in &= 0x3FFFF;\n      cur_dest[1] = base64[in >> 12];\n      in &= 0xFFF;\n      cur_dest[2] = base64[in >> 6];\n      in &= 0x3F;\n      cur_dest[3] = base64[in];\n      cur_dest += 4;\n      break;\n    }\n    default:\n      // Should not be reached: blocks of 4 bytes are handled\n      // in the while loop before this switch statement.\n      GOOGLE_LOG(FATAL) << \"Logic problem? szsrc = \" << szsrc;\n      break;\n  }\n  return (cur_dest - dest);\n}\n\nstatic const char kBase64Chars[] =\n\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n\nstatic const char kWebSafeBase64Chars[] =\n\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_\";\n\nint Base64Escape(const unsigned char *src, int szsrc, char *dest, int szdest) {\n  return Base64EscapeInternal(src, szsrc, dest, szdest, kBase64Chars, true);\n}\nint WebSafeBase64Escape(const unsigned char *src, int szsrc, char *dest,\n                        int szdest, bool do_padding) {\n  return Base64EscapeInternal(src, szsrc, dest, szdest,\n                              kWebSafeBase64Chars, do_padding);\n}\n\nvoid Base64EscapeInternal(const unsigned char* src, int szsrc,\n                          string* dest, bool do_padding,\n                          const char* base64_chars) {\n  const int calc_escaped_size =\n    CalculateBase64EscapedLen(szsrc, do_padding);\n  dest->resize(calc_escaped_size);\n  const int escaped_len = Base64EscapeInternal(src, szsrc,\n                                               string_as_array(dest),\n                                               dest->size(),\n                                               base64_chars,\n                                               do_padding);\n  GOOGLE_DCHECK_EQ(calc_escaped_size, escaped_len);\n  dest->erase(escaped_len);\n}\n\nvoid Base64Escape(const unsigned char *src, int szsrc,\n                  string* dest, bool do_padding) {\n  Base64EscapeInternal(src, szsrc, dest, do_padding, kBase64Chars);\n}\n\nvoid WebSafeBase64Escape(const unsigned char *src, int szsrc,\n                         string *dest, bool do_padding) {\n  Base64EscapeInternal(src, szsrc, dest, do_padding, kWebSafeBase64Chars);\n}\n\nvoid Base64Escape(StringPiece src, string* dest) {\n  Base64Escape(reinterpret_cast<const unsigned char*>(src.data()),\n               src.size(), dest, true);\n}\n\nvoid WebSafeBase64Escape(StringPiece src, string* dest) {\n  WebSafeBase64Escape(reinterpret_cast<const unsigned char*>(src.data()),\n                      src.size(), dest, false);\n}\n\nvoid WebSafeBase64EscapeWithPadding(StringPiece src, string* dest) {\n  WebSafeBase64Escape(reinterpret_cast<const unsigned char*>(src.data()),\n                      src.size(), dest, true);\n}\n\n// Helper to append a Unicode code point to a string as UTF8, without bringing\n// in any external dependencies.\nint EncodeAsUTF8Char(uint32 code_point, char* output) {\n  uint32 tmp = 0;\n  int len = 0;\n  if (code_point <= 0x7f) {\n    tmp = code_point;\n    len = 1;\n  } else if (code_point <= 0x07ff) {\n    tmp = 0x0000c080 |\n        ((code_point & 0x07c0) << 2) |\n        (code_point & 0x003f);\n    len = 2;\n  } else if (code_point <= 0xffff) {\n    tmp = 0x00e08080 |\n        ((code_point & 0xf000) << 4) |\n        ((code_point & 0x0fc0) << 2) |\n        (code_point & 0x003f);\n    len = 3;\n  } else {\n    // UTF-16 is only defined for code points up to 0x10FFFF, and UTF-8 is\n    // normally only defined up to there as well.\n    tmp = 0xf0808080 |\n        ((code_point & 0x1c0000) << 6) |\n        ((code_point & 0x03f000) << 4) |\n        ((code_point & 0x000fc0) << 2) |\n        (code_point & 0x003f);\n    len = 4;\n  }\n  tmp = ghtonl(tmp);\n  memcpy(output, reinterpret_cast<const char*>(&tmp) + sizeof(tmp) - len, len);\n  return len;\n}\n\n// Table of UTF-8 character lengths, based on first byte\nstatic const unsigned char kUTF8LenTbl[256] = {\n  1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,\n  1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,\n  1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,\n  1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,\n\n  1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,\n  1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,\n  2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,\n  3,3,3,3,3,3,3,3, 3,3,3,3,3,3,3,3, 4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4\n};\n\n// Return length of a single UTF-8 source character\nint UTF8FirstLetterNumBytes(const char* src, int len) {\n  if (len == 0) {\n    return 0;\n  }\n  return kUTF8LenTbl[*reinterpret_cast<const uint8*>(src)];\n}\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/strutil.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// from google3/strings/strutil.h\n\n#ifndef GOOGLE_PROTOBUF_STUBS_STRUTIL_H__\n#define GOOGLE_PROTOBUF_STUBS_STRUTIL_H__\n\n#include <stdlib.h>\n#include <vector>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/stringpiece.h>\n\nnamespace google {\nnamespace protobuf {\n\n#ifdef _MSC_VER\n#define strtoll  _strtoi64\n#define strtoull _strtoui64\n#elif defined(__DECCXX) && defined(__osf__)\n// HP C++ on Tru64 does not have strtoll, but strtol is already 64-bit.\n#define strtoll strtol\n#define strtoull strtoul\n#endif\n\n// ----------------------------------------------------------------------\n// ascii_isalnum()\n//    Check if an ASCII character is alphanumeric.  We can't use ctype's\n//    isalnum() because it is affected by locale.  This function is applied\n//    to identifiers in the protocol buffer language, not to natural-language\n//    strings, so locale should not be taken into account.\n// ascii_isdigit()\n//    Like above, but only accepts digits.\n// ascii_isspace()\n//    Check if the character is a space character.\n// ----------------------------------------------------------------------\n\ninline bool ascii_isalnum(char c) {\n  return ('a' <= c && c <= 'z') ||\n         ('A' <= c && c <= 'Z') ||\n         ('0' <= c && c <= '9');\n}\n\ninline bool ascii_isdigit(char c) {\n  return ('0' <= c && c <= '9');\n}\n\ninline bool ascii_isspace(char c) {\n  return c == ' ' || c == '\\t' || c == '\\n' || c == '\\v' || c == '\\f' ||\n      c == '\\r';\n}\n\ninline bool ascii_isupper(char c) {\n  return c >= 'A' && c <= 'Z';\n}\n\ninline bool ascii_islower(char c) {\n  return c >= 'a' && c <= 'z';\n}\n\ninline char ascii_toupper(char c) {\n  return ascii_islower(c) ? c - ('a' - 'A') : c;\n}\n\ninline char ascii_tolower(char c) {\n  return ascii_isupper(c) ? c + ('a' - 'A') : c;\n}\n\ninline int hex_digit_to_int(char c) {\n  /* Assume ASCII. */\n  int x = static_cast<unsigned char>(c);\n  if (x > '9') {\n    x += 9;\n  }\n  return x & 0xf;\n}\n\n// ----------------------------------------------------------------------\n// HasPrefixString()\n//    Check if a string begins with a given prefix.\n// StripPrefixString()\n//    Given a string and a putative prefix, returns the string minus the\n//    prefix string if the prefix matches, otherwise the original\n//    string.\n// ----------------------------------------------------------------------\ninline bool HasPrefixString(const string& str,\n                            const string& prefix) {\n  return str.size() >= prefix.size() &&\n         str.compare(0, prefix.size(), prefix) == 0;\n}\n\ninline string StripPrefixString(const string& str, const string& prefix) {\n  if (HasPrefixString(str, prefix)) {\n    return str.substr(prefix.size());\n  } else {\n    return str;\n  }\n}\n\n// ----------------------------------------------------------------------\n// HasSuffixString()\n//    Return true if str ends in suffix.\n// StripSuffixString()\n//    Given a string and a putative suffix, returns the string minus the\n//    suffix string if the suffix matches, otherwise the original\n//    string.\n// ----------------------------------------------------------------------\ninline bool HasSuffixString(const string& str,\n                            const string& suffix) {\n  return str.size() >= suffix.size() &&\n         str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;\n}\n\ninline string StripSuffixString(const string& str, const string& suffix) {\n  if (HasSuffixString(str, suffix)) {\n    return str.substr(0, str.size() - suffix.size());\n  } else {\n    return str;\n  }\n}\n\n// ----------------------------------------------------------------------\n// StripString\n//    Replaces any occurrence of the character 'remove' (or the characters\n//    in 'remove') with the character 'replacewith'.\n//    Good for keeping html characters or protocol characters (\\t) out\n//    of places where they might cause a problem.\n// StripWhitespace\n//    Removes whitespaces from both ends of the given string.\n// ----------------------------------------------------------------------\nLIBPROTOBUF_EXPORT void StripString(string* s, const char* remove,\n                                    char replacewith);\n\nLIBPROTOBUF_EXPORT void StripWhitespace(string* s);\n\n\n// ----------------------------------------------------------------------\n// LowerString()\n// UpperString()\n// ToUpper()\n//    Convert the characters in \"s\" to lowercase or uppercase.  ASCII-only:\n//    these functions intentionally ignore locale because they are applied to\n//    identifiers used in the Protocol Buffer language, not to natural-language\n//    strings.\n// ----------------------------------------------------------------------\n\ninline void LowerString(string * s) {\n  string::iterator end = s->end();\n  for (string::iterator i = s->begin(); i != end; ++i) {\n    // tolower() changes based on locale.  We don't want this!\n    if ('A' <= *i && *i <= 'Z') *i += 'a' - 'A';\n  }\n}\n\ninline void UpperString(string * s) {\n  string::iterator end = s->end();\n  for (string::iterator i = s->begin(); i != end; ++i) {\n    // toupper() changes based on locale.  We don't want this!\n    if ('a' <= *i && *i <= 'z') *i += 'A' - 'a';\n  }\n}\n\ninline string ToUpper(const string& s) {\n  string out = s;\n  UpperString(&out);\n  return out;\n}\n\n// ----------------------------------------------------------------------\n// StringReplace()\n//    Give me a string and two patterns \"old\" and \"new\", and I replace\n//    the first instance of \"old\" in the string with \"new\", if it\n//    exists.  RETURN a new string, regardless of whether the replacement\n//    happened or not.\n// ----------------------------------------------------------------------\n\nLIBPROTOBUF_EXPORT string StringReplace(const string& s, const string& oldsub,\n                                        const string& newsub, bool replace_all);\n\n// ----------------------------------------------------------------------\n// SplitStringUsing()\n//    Split a string using a character delimiter. Append the components\n//    to 'result'.  If there are consecutive delimiters, this function skips\n//    over all of them.\n// ----------------------------------------------------------------------\nLIBPROTOBUF_EXPORT void SplitStringUsing(const string& full, const char* delim,\n                                         vector<string>* res);\n\n// Split a string using one or more byte delimiters, presented\n// as a nul-terminated c string. Append the components to 'result'.\n// If there are consecutive delimiters, this function will return\n// corresponding empty strings.  If you want to drop the empty\n// strings, try SplitStringUsing().\n//\n// If \"full\" is the empty string, yields an empty string as the only value.\n// ----------------------------------------------------------------------\nLIBPROTOBUF_EXPORT void SplitStringAllowEmpty(const string& full,\n                                              const char* delim,\n                                              vector<string>* result);\n\n// ----------------------------------------------------------------------\n// Split()\n//    Split a string using a character delimiter.\n// ----------------------------------------------------------------------\ninline vector<string> Split(\n    const string& full, const char* delim, bool skip_empty = true) {\n  vector<string> result;\n  if (skip_empty) {\n    SplitStringUsing(full, delim, &result);\n  } else {\n    SplitStringAllowEmpty(full, delim, &result);\n  }\n  return result;\n}\n\n// ----------------------------------------------------------------------\n// JoinStrings()\n//    These methods concatenate a vector of strings into a C++ string, using\n//    the C-string \"delim\" as a separator between components. There are two\n//    flavors of the function, one flavor returns the concatenated string,\n//    another takes a pointer to the target string. In the latter case the\n//    target string is cleared and overwritten.\n// ----------------------------------------------------------------------\nLIBPROTOBUF_EXPORT void JoinStrings(const vector<string>& components,\n                                    const char* delim, string* result);\n\ninline string JoinStrings(const vector<string>& components,\n                          const char* delim) {\n  string result;\n  JoinStrings(components, delim, &result);\n  return result;\n}\n\n// ----------------------------------------------------------------------\n// UnescapeCEscapeSequences()\n//    Copies \"source\" to \"dest\", rewriting C-style escape sequences\n//    -- '\\n', '\\r', '\\\\', '\\ooo', etc -- to their ASCII\n//    equivalents.  \"dest\" must be sufficiently large to hold all\n//    the characters in the rewritten string (i.e. at least as large\n//    as strlen(source) + 1 should be safe, since the replacements\n//    are always shorter than the original escaped sequences).  It's\n//    safe for source and dest to be the same.  RETURNS the length\n//    of dest.\n//\n//    It allows hex sequences \\xhh, or generally \\xhhhhh with an\n//    arbitrary number of hex digits, but all of them together must\n//    specify a value of a single byte (e.g. \\x0045 is equivalent\n//    to \\x45, and \\x1234 is erroneous).\n//\n//    It also allows escape sequences of the form \\uhhhh (exactly four\n//    hex digits, upper or lower case) or \\Uhhhhhhhh (exactly eight\n//    hex digits, upper or lower case) to specify a Unicode code\n//    point. The dest array will contain the UTF8-encoded version of\n//    that code-point (e.g., if source contains \\u2019, then dest will\n//    contain the three bytes 0xE2, 0x80, and 0x99).\n//\n//    Errors: In the first form of the call, errors are reported with\n//    LOG(ERROR). The same is true for the second form of the call if\n//    the pointer to the string vector is NULL; otherwise, error\n//    messages are stored in the vector. In either case, the effect on\n//    the dest array is not defined, but rest of the source will be\n//    processed.\n//    ----------------------------------------------------------------------\n\nLIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest);\nLIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest,\n                                                vector<string> *errors);\n\n// ----------------------------------------------------------------------\n// UnescapeCEscapeString()\n//    This does the same thing as UnescapeCEscapeSequences, but creates\n//    a new string. The caller does not need to worry about allocating\n//    a dest buffer. This should be used for non performance critical\n//    tasks such as printing debug messages. It is safe for src and dest\n//    to be the same.\n//\n//    The second call stores its errors in a supplied string vector.\n//    If the string vector pointer is NULL, it reports the errors with LOG().\n//\n//    In the first and second calls, the length of dest is returned. In the\n//    the third call, the new string is returned.\n// ----------------------------------------------------------------------\n\nLIBPROTOBUF_EXPORT int UnescapeCEscapeString(const string& src, string* dest);\nLIBPROTOBUF_EXPORT int UnescapeCEscapeString(const string& src, string* dest,\n                                             vector<string> *errors);\nLIBPROTOBUF_EXPORT string UnescapeCEscapeString(const string& src);\n\n// ----------------------------------------------------------------------\n// CEscape()\n//    Escapes 'src' using C-style escape sequences and returns the resulting\n//    string.\n//\n//    Escaped chars: \\n, \\r, \\t, \", ', \\, and !isprint().\n// ----------------------------------------------------------------------\nLIBPROTOBUF_EXPORT string CEscape(const string& src);\n\n// ----------------------------------------------------------------------\n// CEscapeAndAppend()\n//    Escapes 'src' using C-style escape sequences, and appends the escaped\n//    string to 'dest'.\n// ----------------------------------------------------------------------\nLIBPROTOBUF_EXPORT void CEscapeAndAppend(StringPiece src, string* dest);\n\nnamespace strings {\n// Like CEscape() but does not escape bytes with the upper bit set.\nLIBPROTOBUF_EXPORT string Utf8SafeCEscape(const string& src);\n\n// Like CEscape() but uses hex (\\x) escapes instead of octals.\nLIBPROTOBUF_EXPORT string CHexEscape(const string& src);\n}  // namespace strings\n\n// ----------------------------------------------------------------------\n// strto32()\n// strtou32()\n// strto64()\n// strtou64()\n//    Architecture-neutral plug compatible replacements for strtol() and\n//    strtoul().  Long's have different lengths on ILP-32 and LP-64\n//    platforms, so using these is safer, from the point of view of\n//    overflow behavior, than using the standard libc functions.\n// ----------------------------------------------------------------------\nLIBPROTOBUF_EXPORT int32 strto32_adaptor(const char *nptr, char **endptr,\n                                         int base);\nLIBPROTOBUF_EXPORT uint32 strtou32_adaptor(const char *nptr, char **endptr,\n                                           int base);\n\ninline int32 strto32(const char *nptr, char **endptr, int base) {\n  if (sizeof(int32) == sizeof(long))\n    return strtol(nptr, endptr, base);\n  else\n    return strto32_adaptor(nptr, endptr, base);\n}\n\ninline uint32 strtou32(const char *nptr, char **endptr, int base) {\n  if (sizeof(uint32) == sizeof(unsigned long))\n    return strtoul(nptr, endptr, base);\n  else\n    return strtou32_adaptor(nptr, endptr, base);\n}\n\n// For now, long long is 64-bit on all the platforms we care about, so these\n// functions can simply pass the call to strto[u]ll.\ninline int64 strto64(const char *nptr, char **endptr, int base) {\n  GOOGLE_COMPILE_ASSERT(sizeof(int64) == sizeof(long long),\n                        sizeof_int64_is_not_sizeof_long_long);\n  return strtoll(nptr, endptr, base);\n}\n\ninline uint64 strtou64(const char *nptr, char **endptr, int base) {\n  GOOGLE_COMPILE_ASSERT(sizeof(uint64) == sizeof(unsigned long long),\n                        sizeof_uint64_is_not_sizeof_long_long);\n  return strtoull(nptr, endptr, base);\n}\n\n// ----------------------------------------------------------------------\n// safe_strtob()\n// safe_strto32()\n// safe_strtou32()\n// safe_strto64()\n// safe_strtou64()\n// safe_strtof()\n// safe_strtod()\n// ----------------------------------------------------------------------\nLIBPROTOBUF_EXPORT bool safe_strtob(StringPiece str, bool* value);\n\nLIBPROTOBUF_EXPORT bool safe_strto32(const string& str, int32* value);\nLIBPROTOBUF_EXPORT bool safe_strtou32(const string& str, uint32* value);\ninline bool safe_strto32(const char* str, int32* value) {\n  return safe_strto32(string(str), value);\n}\ninline bool safe_strto32(StringPiece str, int32* value) {\n  return safe_strto32(str.ToString(), value);\n}\ninline bool safe_strtou32(const char* str, uint32* value) {\n  return safe_strtou32(string(str), value);\n}\ninline bool safe_strtou32(StringPiece str, uint32* value) {\n  return safe_strtou32(str.ToString(), value);\n}\n\nLIBPROTOBUF_EXPORT bool safe_strto64(const string& str, int64* value);\nLIBPROTOBUF_EXPORT bool safe_strtou64(const string& str, uint64* value);\ninline bool safe_strto64(const char* str, int64* value) {\n  return safe_strto64(string(str), value);\n}\ninline bool safe_strto64(StringPiece str, int64* value) {\n  return safe_strto64(str.ToString(), value);\n}\ninline bool safe_strtou64(const char* str, uint64* value) {\n  return safe_strtou64(string(str), value);\n}\ninline bool safe_strtou64(StringPiece str, uint64* value) {\n  return safe_strtou64(str.ToString(), value);\n}\n\nLIBPROTOBUF_EXPORT bool safe_strtof(const char* str, float* value);\nLIBPROTOBUF_EXPORT bool safe_strtod(const char* str, double* value);\ninline bool safe_strtof(const string& str, float* value) {\n  return safe_strtof(str.c_str(), value);\n}\ninline bool safe_strtod(const string& str, double* value) {\n  return safe_strtod(str.c_str(), value);\n}\ninline bool safe_strtof(StringPiece str, float* value) {\n  return safe_strtof(str.ToString(), value);\n}\ninline bool safe_strtod(StringPiece str, double* value) {\n  return safe_strtod(str.ToString(), value);\n}\n\n// ----------------------------------------------------------------------\n// FastIntToBuffer()\n// FastHexToBuffer()\n// FastHex64ToBuffer()\n// FastHex32ToBuffer()\n// FastTimeToBuffer()\n//    These are intended for speed.  FastIntToBuffer() assumes the\n//    integer is non-negative.  FastHexToBuffer() puts output in\n//    hex rather than decimal.  FastTimeToBuffer() puts the output\n//    into RFC822 format.\n//\n//    FastHex64ToBuffer() puts a 64-bit unsigned value in hex-format,\n//    padded to exactly 16 bytes (plus one byte for '\\0')\n//\n//    FastHex32ToBuffer() puts a 32-bit unsigned value in hex-format,\n//    padded to exactly 8 bytes (plus one byte for '\\0')\n//\n//       All functions take the output buffer as an arg.\n//    They all return a pointer to the beginning of the output,\n//    which may not be the beginning of the input buffer.\n// ----------------------------------------------------------------------\n\n// Suggested buffer size for FastToBuffer functions.  Also works with\n// DoubleToBuffer() and FloatToBuffer().\nstatic const int kFastToBufferSize = 32;\n\nLIBPROTOBUF_EXPORT char* FastInt32ToBuffer(int32 i, char* buffer);\nLIBPROTOBUF_EXPORT char* FastInt64ToBuffer(int64 i, char* buffer);\nchar* FastUInt32ToBuffer(uint32 i, char* buffer);  // inline below\nchar* FastUInt64ToBuffer(uint64 i, char* buffer);  // inline below\nLIBPROTOBUF_EXPORT char* FastHexToBuffer(int i, char* buffer);\nLIBPROTOBUF_EXPORT char* FastHex64ToBuffer(uint64 i, char* buffer);\nLIBPROTOBUF_EXPORT char* FastHex32ToBuffer(uint32 i, char* buffer);\n\n// at least 22 bytes long\ninline char* FastIntToBuffer(int i, char* buffer) {\n  return (sizeof(i) == 4 ?\n          FastInt32ToBuffer(i, buffer) : FastInt64ToBuffer(i, buffer));\n}\ninline char* FastUIntToBuffer(unsigned int i, char* buffer) {\n  return (sizeof(i) == 4 ?\n          FastUInt32ToBuffer(i, buffer) : FastUInt64ToBuffer(i, buffer));\n}\ninline char* FastLongToBuffer(long i, char* buffer) {\n  return (sizeof(i) == 4 ?\n          FastInt32ToBuffer(i, buffer) : FastInt64ToBuffer(i, buffer));\n}\ninline char* FastULongToBuffer(unsigned long i, char* buffer) {\n  return (sizeof(i) == 4 ?\n          FastUInt32ToBuffer(i, buffer) : FastUInt64ToBuffer(i, buffer));\n}\n\n// ----------------------------------------------------------------------\n// FastInt32ToBufferLeft()\n// FastUInt32ToBufferLeft()\n// FastInt64ToBufferLeft()\n// FastUInt64ToBufferLeft()\n//\n// Like the Fast*ToBuffer() functions above, these are intended for speed.\n// Unlike the Fast*ToBuffer() functions, however, these functions write\n// their output to the beginning of the buffer (hence the name, as the\n// output is left-aligned).  The caller is responsible for ensuring that\n// the buffer has enough space to hold the output.\n//\n// Returns a pointer to the end of the string (i.e. the null character\n// terminating the string).\n// ----------------------------------------------------------------------\n\nLIBPROTOBUF_EXPORT char* FastInt32ToBufferLeft(int32 i, char* buffer);\nLIBPROTOBUF_EXPORT char* FastUInt32ToBufferLeft(uint32 i, char* buffer);\nLIBPROTOBUF_EXPORT char* FastInt64ToBufferLeft(int64 i, char* buffer);\nLIBPROTOBUF_EXPORT char* FastUInt64ToBufferLeft(uint64 i, char* buffer);\n\n// Just define these in terms of the above.\ninline char* FastUInt32ToBuffer(uint32 i, char* buffer) {\n  FastUInt32ToBufferLeft(i, buffer);\n  return buffer;\n}\ninline char* FastUInt64ToBuffer(uint64 i, char* buffer) {\n  FastUInt64ToBufferLeft(i, buffer);\n  return buffer;\n}\n\ninline string SimpleBtoa(bool value) {\n  return value ? \"true\" : \"false\";\n}\n\n// ----------------------------------------------------------------------\n// SimpleItoa()\n//    Description: converts an integer to a string.\n//\n//    Return value: string\n// ----------------------------------------------------------------------\nLIBPROTOBUF_EXPORT string SimpleItoa(int i);\nLIBPROTOBUF_EXPORT string SimpleItoa(unsigned int i);\nLIBPROTOBUF_EXPORT string SimpleItoa(long i);\nLIBPROTOBUF_EXPORT string SimpleItoa(unsigned long i);\nLIBPROTOBUF_EXPORT string SimpleItoa(long long i);\nLIBPROTOBUF_EXPORT string SimpleItoa(unsigned long long i);\n\n// ----------------------------------------------------------------------\n// SimpleDtoa()\n// SimpleFtoa()\n// DoubleToBuffer()\n// FloatToBuffer()\n//    Description: converts a double or float to a string which, if\n//    passed to NoLocaleStrtod(), will produce the exact same original double\n//    (except in case of NaN; all NaNs are considered the same value).\n//    We try to keep the string short but it's not guaranteed to be as\n//    short as possible.\n//\n//    DoubleToBuffer() and FloatToBuffer() write the text to the given\n//    buffer and return it.  The buffer must be at least\n//    kDoubleToBufferSize bytes for doubles and kFloatToBufferSize\n//    bytes for floats.  kFastToBufferSize is also guaranteed to be large\n//    enough to hold either.\n//\n//    Return value: string\n// ----------------------------------------------------------------------\nLIBPROTOBUF_EXPORT string SimpleDtoa(double value);\nLIBPROTOBUF_EXPORT string SimpleFtoa(float value);\n\nLIBPROTOBUF_EXPORT char* DoubleToBuffer(double i, char* buffer);\nLIBPROTOBUF_EXPORT char* FloatToBuffer(float i, char* buffer);\n\n// In practice, doubles should never need more than 24 bytes and floats\n// should never need more than 14 (including null terminators), but we\n// overestimate to be safe.\nstatic const int kDoubleToBufferSize = 32;\nstatic const int kFloatToBufferSize = 24;\n\nnamespace strings {\n\nenum PadSpec {\n  NO_PAD = 1,\n  ZERO_PAD_2,\n  ZERO_PAD_3,\n  ZERO_PAD_4,\n  ZERO_PAD_5,\n  ZERO_PAD_6,\n  ZERO_PAD_7,\n  ZERO_PAD_8,\n  ZERO_PAD_9,\n  ZERO_PAD_10,\n  ZERO_PAD_11,\n  ZERO_PAD_12,\n  ZERO_PAD_13,\n  ZERO_PAD_14,\n  ZERO_PAD_15,\n  ZERO_PAD_16,\n};\n\nstruct Hex {\n  uint64 value;\n  enum PadSpec spec;\n  template <class Int>\n  explicit Hex(Int v, PadSpec s = NO_PAD)\n      : spec(s) {\n    // Prevent sign-extension by casting integers to\n    // their unsigned counterparts.\n#ifdef LANG_CXX11\n    static_assert(\n        sizeof(v) == 1 || sizeof(v) == 2 || sizeof(v) == 4 || sizeof(v) == 8,\n        \"Unknown integer type\");\n#endif\n    value = sizeof(v) == 1 ? static_cast<uint8>(v)\n          : sizeof(v) == 2 ? static_cast<uint16>(v)\n          : sizeof(v) == 4 ? static_cast<uint32>(v)\n          : static_cast<uint64>(v);\n  }\n};\n\nstruct LIBPROTOBUF_EXPORT AlphaNum {\n  const char *piece_data_;  // move these to string_ref eventually\n  size_t piece_size_;       // move these to string_ref eventually\n\n  char digits[kFastToBufferSize];\n\n  // No bool ctor -- bools convert to an integral type.\n  // A bool ctor would also convert incoming pointers (bletch).\n\n  AlphaNum(int32 i32)\n      : piece_data_(digits),\n        piece_size_(FastInt32ToBufferLeft(i32, digits) - &digits[0]) {}\n  AlphaNum(uint32 u32)\n      : piece_data_(digits),\n        piece_size_(FastUInt32ToBufferLeft(u32, digits) - &digits[0]) {}\n  AlphaNum(int64 i64)\n      : piece_data_(digits),\n        piece_size_(FastInt64ToBufferLeft(i64, digits) - &digits[0]) {}\n  AlphaNum(uint64 u64)\n      : piece_data_(digits),\n        piece_size_(FastUInt64ToBufferLeft(u64, digits) - &digits[0]) {}\n\n  AlphaNum(float f)\n    : piece_data_(digits), piece_size_(strlen(FloatToBuffer(f, digits))) {}\n  AlphaNum(double f)\n    : piece_data_(digits), piece_size_(strlen(DoubleToBuffer(f, digits))) {}\n\n  AlphaNum(Hex hex);\n\n  AlphaNum(const char* c_str)\n      : piece_data_(c_str), piece_size_(strlen(c_str)) {}\n  // TODO: Add a string_ref constructor, eventually\n  // AlphaNum(const StringPiece &pc) : piece(pc) {}\n\n  AlphaNum(const string& str)\n      : piece_data_(str.data()), piece_size_(str.size()) {}\n\n  AlphaNum(StringPiece str)\n      : piece_data_(str.data()), piece_size_(str.size()) {}\n\n  AlphaNum(internal::StringPiecePod str)\n      : piece_data_(str.data()), piece_size_(str.size()) {}\n\n  size_t size() const { return piece_size_; }\n  const char *data() const { return piece_data_; }\n\n private:\n  // Use \":\" not ':'\n  AlphaNum(char c);  // NOLINT(runtime/explicit)\n\n  // Disallow copy and assign.\n  AlphaNum(const AlphaNum&);\n  void operator=(const AlphaNum&);\n};\n\n}  // namespace strings\n\nusing strings::AlphaNum;\n\n// ----------------------------------------------------------------------\n// StrCat()\n//    This merges the given strings or numbers, with no delimiter.  This\n//    is designed to be the fastest possible way to construct a string out\n//    of a mix of raw C strings, strings, bool values,\n//    and numeric values.\n//\n//    Don't use this for user-visible strings.  The localization process\n//    works poorly on strings built up out of fragments.\n//\n//    For clarity and performance, don't use StrCat when appending to a\n//    string.  In particular, avoid using any of these (anti-)patterns:\n//      str.append(StrCat(...)\n//      str += StrCat(...)\n//      str = StrCat(str, ...)\n//    where the last is the worse, with the potential to change a loop\n//    from a linear time operation with O(1) dynamic allocations into a\n//    quadratic time operation with O(n) dynamic allocations.  StrAppend\n//    is a better choice than any of the above, subject to the restriction\n//    of StrAppend(&str, a, b, c, ...) that none of the a, b, c, ... may\n//    be a reference into str.\n// ----------------------------------------------------------------------\n\nLIBPROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b);\nLIBPROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b,\n                                 const AlphaNum& c);\nLIBPROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b,\n                                 const AlphaNum& c, const AlphaNum& d);\nLIBPROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b,\n                                 const AlphaNum& c, const AlphaNum& d,\n                                 const AlphaNum& e);\nLIBPROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b,\n                                 const AlphaNum& c, const AlphaNum& d,\n                                 const AlphaNum& e, const AlphaNum& f);\nLIBPROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b,\n                                 const AlphaNum& c, const AlphaNum& d,\n                                 const AlphaNum& e, const AlphaNum& f,\n                                 const AlphaNum& g);\nLIBPROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b,\n                                 const AlphaNum& c, const AlphaNum& d,\n                                 const AlphaNum& e, const AlphaNum& f,\n                                 const AlphaNum& g, const AlphaNum& h);\nLIBPROTOBUF_EXPORT string StrCat(const AlphaNum& a, const AlphaNum& b,\n                                 const AlphaNum& c, const AlphaNum& d,\n                                 const AlphaNum& e, const AlphaNum& f,\n                                 const AlphaNum& g, const AlphaNum& h,\n                                 const AlphaNum& i);\n\ninline string StrCat(const AlphaNum& a) { return string(a.data(), a.size()); }\n\n// ----------------------------------------------------------------------\n// StrAppend()\n//    Same as above, but adds the output to the given string.\n//    WARNING: For speed, StrAppend does not try to check each of its input\n//    arguments to be sure that they are not a subset of the string being\n//    appended to.  That is, while this will work:\n//\n//    string s = \"foo\";\n//    s += s;\n//\n//    This will not (necessarily) work:\n//\n//    string s = \"foo\";\n//    StrAppend(&s, s);\n//\n//    Note: while StrCat supports appending up to 9 arguments, StrAppend\n//    is currently limited to 4.  That's rarely an issue except when\n//    automatically transforming StrCat to StrAppend, and can easily be\n//    worked around as consecutive calls to StrAppend are quite efficient.\n// ----------------------------------------------------------------------\n\nLIBPROTOBUF_EXPORT void StrAppend(string* dest, const AlphaNum& a);\nLIBPROTOBUF_EXPORT void StrAppend(string* dest, const AlphaNum& a,\n                                  const AlphaNum& b);\nLIBPROTOBUF_EXPORT void StrAppend(string* dest, const AlphaNum& a,\n                                  const AlphaNum& b, const AlphaNum& c);\nLIBPROTOBUF_EXPORT void StrAppend(string* dest, const AlphaNum& a,\n                                  const AlphaNum& b, const AlphaNum& c,\n                                  const AlphaNum& d);\n\n// ----------------------------------------------------------------------\n// Join()\n//    These methods concatenate a range of components into a C++ string, using\n//    the C-string \"delim\" as a separator between components.\n// ----------------------------------------------------------------------\ntemplate <typename Iterator>\nvoid Join(Iterator start, Iterator end,\n          const char* delim, string* result) {\n  for (Iterator it = start; it != end; ++it) {\n    if (it != start) {\n      result->append(delim);\n    }\n    StrAppend(result, *it);\n  }\n}\n\ntemplate <typename Range>\nstring Join(const Range& components,\n            const char* delim) {\n  string result;\n  Join(components.begin(), components.end(), delim, &result);\n  return result;\n}\n\n// ----------------------------------------------------------------------\n// ToHex()\n//    Return a lower-case hex string representation of the given integer.\n// ----------------------------------------------------------------------\nLIBPROTOBUF_EXPORT string ToHex(uint64 num);\n\n// ----------------------------------------------------------------------\n// GlobalReplaceSubstring()\n//    Replaces all instances of a substring in a string.  Does nothing\n//    if 'substring' is empty.  Returns the number of replacements.\n//\n//    NOTE: The string pieces must not overlap s.\n// ----------------------------------------------------------------------\nLIBPROTOBUF_EXPORT int GlobalReplaceSubstring(const string& substring,\n                                              const string& replacement,\n                                              string* s);\n\n// ----------------------------------------------------------------------\n// Base64Unescape()\n//    Converts \"src\" which is encoded in Base64 to its binary equivalent and\n//    writes it to \"dest\". If src contains invalid characters, dest is cleared\n//    and the function returns false. Returns true on success.\n// ----------------------------------------------------------------------\nLIBPROTOBUF_EXPORT bool Base64Unescape(StringPiece src, string* dest);\n\n// ----------------------------------------------------------------------\n// WebSafeBase64Unescape()\n//    This is a variation of Base64Unescape which uses '-' instead of '+', and\n//    '_' instead of '/'. src is not null terminated, instead specify len. I\n//    recommend that slen<szdest, but we honor szdest anyway.\n//    RETURNS the length of dest, or -1 if src contains invalid chars.\n\n//    The variation that stores into a string clears the string first, and\n//    returns false (with dest empty) if src contains invalid chars; for\n//    this version src and dest must be different strings.\n// ----------------------------------------------------------------------\nLIBPROTOBUF_EXPORT int WebSafeBase64Unescape(const char* src, int slen,\n                                             char* dest, int szdest);\nLIBPROTOBUF_EXPORT bool WebSafeBase64Unescape(StringPiece src, string* dest);\n\n// Return the length to use for the output buffer given to the base64 escape\n// routines. Make sure to use the same value for do_padding in both.\n// This function may return incorrect results if given input_len values that\n// are extremely high, which should happen rarely.\nLIBPROTOBUF_EXPORT int CalculateBase64EscapedLen(int input_len,\n                                                 bool do_padding);\n// Use this version when calling Base64Escape without a do_padding arg.\nLIBPROTOBUF_EXPORT int CalculateBase64EscapedLen(int input_len);\n\n// ----------------------------------------------------------------------\n// Base64Escape()\n// WebSafeBase64Escape()\n//    Encode \"src\" to \"dest\" using base64 encoding.\n//    src is not null terminated, instead specify len.\n//    'dest' should have at least CalculateBase64EscapedLen() length.\n//    RETURNS the length of dest.\n//    The WebSafe variation use '-' instead of '+' and '_' instead of '/'\n//    so that we can place the out in the URL or cookies without having\n//    to escape them.  It also has an extra parameter \"do_padding\",\n//    which when set to false will prevent padding with \"=\".\n// ----------------------------------------------------------------------\nLIBPROTOBUF_EXPORT int Base64Escape(const unsigned char* src, int slen,\n                                    char* dest, int szdest);\nLIBPROTOBUF_EXPORT int WebSafeBase64Escape(\n    const unsigned char* src, int slen, char* dest,\n    int szdest, bool do_padding);\n// Encode src into dest with padding.\nLIBPROTOBUF_EXPORT void Base64Escape(StringPiece src, string* dest);\n// Encode src into dest web-safely without padding.\nLIBPROTOBUF_EXPORT void WebSafeBase64Escape(StringPiece src, string* dest);\n// Encode src into dest web-safely with padding.\nLIBPROTOBUF_EXPORT void WebSafeBase64EscapeWithPadding(StringPiece src,\n                                                       string* dest);\n\nLIBPROTOBUF_EXPORT void Base64Escape(const unsigned char* src, int szsrc,\n                                     string* dest, bool do_padding);\nLIBPROTOBUF_EXPORT void WebSafeBase64Escape(const unsigned char* src, int szsrc,\n                                            string* dest, bool do_padding);\n\ninline bool IsValidCodePoint(uint32 code_point) {\n  return code_point < 0xD800 ||\n         (code_point >= 0xE000 && code_point <= 0x10FFFF);\n}\n\nstatic const int UTFmax = 4;\n// ----------------------------------------------------------------------\n// EncodeAsUTF8Char()\n//  Helper to append a Unicode code point to a string as UTF8, without bringing\n//  in any external dependencies. The output buffer must be as least 4 bytes\n//  large.\n// ----------------------------------------------------------------------\nLIBPROTOBUF_EXPORT int EncodeAsUTF8Char(uint32 code_point, char* output);\n\n// ----------------------------------------------------------------------\n// UTF8FirstLetterNumBytes()\n//   Length of the first UTF-8 character.\n// ----------------------------------------------------------------------\nLIBPROTOBUF_EXPORT int UTF8FirstLetterNumBytes(const char* src, int len);\n\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_STUBS_STRUTIL_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/strutil_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n\n#include <google/protobuf/stubs/strutil.h>\n\n#include <locale.h>\n\n#include <google/protobuf/stubs/stl_util.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\n#ifdef _WIN32\n#define snprintf _snprintf\n#endif\n\nnamespace google {\nnamespace protobuf {\nnamespace {\n\n// TODO(kenton):  Copy strutil tests from google3?\n\nTEST(StringUtilityTest, ImmuneToLocales) {\n  // Remember the old locale.\n  char* old_locale_cstr = setlocale(LC_NUMERIC, NULL);\n  ASSERT_TRUE(old_locale_cstr != NULL);\n  string old_locale = old_locale_cstr;\n\n  // Set the locale to \"C\".\n  ASSERT_TRUE(setlocale(LC_NUMERIC, \"C\") != NULL);\n\n  EXPECT_EQ(\"1.5\", SimpleDtoa(1.5));\n  EXPECT_EQ(\"1.5\", SimpleFtoa(1.5));\n\n  if (setlocale(LC_NUMERIC, \"es_ES\") == NULL &&\n      setlocale(LC_NUMERIC, \"es_ES.utf8\") == NULL) {\n    // Some systems may not have the desired locale available.\n    GOOGLE_LOG(WARNING)\n      << \"Couldn't set locale to es_ES.  Skipping this test.\";\n  } else {\n    EXPECT_EQ(\"1.5\", SimpleDtoa(1.5));\n    EXPECT_EQ(\"1.5\", SimpleFtoa(1.5));\n  }\n\n  // Return to original locale.\n  setlocale(LC_NUMERIC, old_locale.c_str());\n}\n\n#define EXPECT_EQ_ARRAY(len, x, y, msg)                     \\\n  for (int j = 0; j < len; ++j) {                           \\\n    EXPECT_EQ(x[j], y[j]) << \"\" # x << \" != \" # y           \\\n                          << \" byte \" << j << \": \" << msg;  \\\n  }\n\nstatic struct {\n  int plain_length;\n  const char* plaintext;\n  const char* cyphertext;\n} base64_tests[] = {\n  // Empty string.\n  { 0, \"\", \"\"},\n\n  // Basic bit patterns;\n  // values obtained with \"echo -n '...' | uuencode -m test\"\n\n  { 1, \"\\000\", \"AA==\" },\n  { 1, \"\\001\", \"AQ==\" },\n  { 1, \"\\002\", \"Ag==\" },\n  { 1, \"\\004\", \"BA==\" },\n  { 1, \"\\010\", \"CA==\" },\n  { 1, \"\\020\", \"EA==\" },\n  { 1, \"\\040\", \"IA==\" },\n  { 1, \"\\100\", \"QA==\" },\n  { 1, \"\\200\", \"gA==\" },\n\n  { 1, \"\\377\", \"/w==\" },\n  { 1, \"\\376\", \"/g==\" },\n  { 1, \"\\375\", \"/Q==\" },\n  { 1, \"\\373\", \"+w==\" },\n  { 1, \"\\367\", \"9w==\" },\n  { 1, \"\\357\", \"7w==\" },\n  { 1, \"\\337\", \"3w==\" },\n  { 1, \"\\277\", \"vw==\" },\n  { 1, \"\\177\", \"fw==\" },\n  { 2, \"\\000\\000\", \"AAA=\" },\n  { 2, \"\\000\\001\", \"AAE=\" },\n  { 2, \"\\000\\002\", \"AAI=\" },\n  { 2, \"\\000\\004\", \"AAQ=\" },\n  { 2, \"\\000\\010\", \"AAg=\" },\n  { 2, \"\\000\\020\", \"ABA=\" },\n  { 2, \"\\000\\040\", \"ACA=\" },\n  { 2, \"\\000\\100\", \"AEA=\" },\n  { 2, \"\\000\\200\", \"AIA=\" },\n  { 2, \"\\001\\000\", \"AQA=\" },\n  { 2, \"\\002\\000\", \"AgA=\" },\n  { 2, \"\\004\\000\", \"BAA=\" },\n  { 2, \"\\010\\000\", \"CAA=\" },\n  { 2, \"\\020\\000\", \"EAA=\" },\n  { 2, \"\\040\\000\", \"IAA=\" },\n  { 2, \"\\100\\000\", \"QAA=\" },\n  { 2, \"\\200\\000\", \"gAA=\" },\n\n  { 2, \"\\377\\377\", \"//8=\" },\n  { 2, \"\\377\\376\", \"//4=\" },\n  { 2, \"\\377\\375\", \"//0=\" },\n  { 2, \"\\377\\373\", \"//s=\" },\n  { 2, \"\\377\\367\", \"//c=\" },\n  { 2, \"\\377\\357\", \"/+8=\" },\n  { 2, \"\\377\\337\", \"/98=\" },\n  { 2, \"\\377\\277\", \"/78=\" },\n  { 2, \"\\377\\177\", \"/38=\" },\n  { 2, \"\\376\\377\", \"/v8=\" },\n  { 2, \"\\375\\377\", \"/f8=\" },\n  { 2, \"\\373\\377\", \"+/8=\" },\n  { 2, \"\\367\\377\", \"9/8=\" },\n  { 2, \"\\357\\377\", \"7/8=\" },\n  { 2, \"\\337\\377\", \"3/8=\" },\n  { 2, \"\\277\\377\", \"v/8=\" },\n  { 2, \"\\177\\377\", \"f/8=\" },\n\n  { 3, \"\\000\\000\\000\", \"AAAA\" },\n  { 3, \"\\000\\000\\001\", \"AAAB\" },\n  { 3, \"\\000\\000\\002\", \"AAAC\" },\n  { 3, \"\\000\\000\\004\", \"AAAE\" },\n  { 3, \"\\000\\000\\010\", \"AAAI\" },\n  { 3, \"\\000\\000\\020\", \"AAAQ\" },\n  { 3, \"\\000\\000\\040\", \"AAAg\" },\n  { 3, \"\\000\\000\\100\", \"AABA\" },\n  { 3, \"\\000\\000\\200\", \"AACA\" },\n  { 3, \"\\000\\001\\000\", \"AAEA\" },\n  { 3, \"\\000\\002\\000\", \"AAIA\" },\n  { 3, \"\\000\\004\\000\", \"AAQA\" },\n  { 3, \"\\000\\010\\000\", \"AAgA\" },\n  { 3, \"\\000\\020\\000\", \"ABAA\" },\n  { 3, \"\\000\\040\\000\", \"ACAA\" },\n  { 3, \"\\000\\100\\000\", \"AEAA\" },\n  { 3, \"\\000\\200\\000\", \"AIAA\" },\n  { 3, \"\\001\\000\\000\", \"AQAA\" },\n  { 3, \"\\002\\000\\000\", \"AgAA\" },\n  { 3, \"\\004\\000\\000\", \"BAAA\" },\n  { 3, \"\\010\\000\\000\", \"CAAA\" },\n  { 3, \"\\020\\000\\000\", \"EAAA\" },\n  { 3, \"\\040\\000\\000\", \"IAAA\" },\n  { 3, \"\\100\\000\\000\", \"QAAA\" },\n  { 3, \"\\200\\000\\000\", \"gAAA\" },\n\n  { 3, \"\\377\\377\\377\", \"////\" },\n  { 3, \"\\377\\377\\376\", \"///+\" },\n  { 3, \"\\377\\377\\375\", \"///9\" },\n  { 3, \"\\377\\377\\373\", \"///7\" },\n  { 3, \"\\377\\377\\367\", \"///3\" },\n  { 3, \"\\377\\377\\357\", \"///v\" },\n  { 3, \"\\377\\377\\337\", \"///f\" },\n  { 3, \"\\377\\377\\277\", \"//+/\" },\n  { 3, \"\\377\\377\\177\", \"//9/\" },\n  { 3, \"\\377\\376\\377\", \"//7/\" },\n  { 3, \"\\377\\375\\377\", \"//3/\" },\n  { 3, \"\\377\\373\\377\", \"//v/\" },\n  { 3, \"\\377\\367\\377\", \"//f/\" },\n  { 3, \"\\377\\357\\377\", \"/+//\" },\n  { 3, \"\\377\\337\\377\", \"/9//\" },\n  { 3, \"\\377\\277\\377\", \"/7//\" },\n  { 3, \"\\377\\177\\377\", \"/3//\" },\n  { 3, \"\\376\\377\\377\", \"/v//\" },\n  { 3, \"\\375\\377\\377\", \"/f//\" },\n  { 3, \"\\373\\377\\377\", \"+///\" },\n  { 3, \"\\367\\377\\377\", \"9///\" },\n  { 3, \"\\357\\377\\377\", \"7///\" },\n  { 3, \"\\337\\377\\377\", \"3///\" },\n  { 3, \"\\277\\377\\377\", \"v///\" },\n  { 3, \"\\177\\377\\377\", \"f///\" },\n\n  // Random numbers: values obtained with\n  //\n  //  #! /bin/bash\n  //  dd bs=$1 count=1 if=/dev/random of=/tmp/bar.random\n  //  od -N $1 -t o1 /tmp/bar.random\n  //  uuencode -m test < /tmp/bar.random\n  //\n  // where $1 is the number of bytes (2, 3)\n\n  { 2, \"\\243\\361\", \"o/E=\" },\n  { 2, \"\\024\\167\", \"FHc=\" },\n  { 2, \"\\313\\252\", \"y6o=\" },\n  { 2, \"\\046\\041\", \"JiE=\" },\n  { 2, \"\\145\\236\", \"ZZ4=\" },\n  { 2, \"\\254\\325\", \"rNU=\" },\n  { 2, \"\\061\\330\", \"Mdg=\" },\n  { 2, \"\\245\\032\", \"pRo=\" },\n  { 2, \"\\006\\000\", \"BgA=\" },\n  { 2, \"\\375\\131\", \"/Vk=\" },\n  { 2, \"\\303\\210\", \"w4g=\" },\n  { 2, \"\\040\\037\", \"IB8=\" },\n  { 2, \"\\261\\372\", \"sfo=\" },\n  { 2, \"\\335\\014\", \"3Qw=\" },\n  { 2, \"\\233\\217\", \"m48=\" },\n  { 2, \"\\373\\056\", \"+y4=\" },\n  { 2, \"\\247\\232\", \"p5o=\" },\n  { 2, \"\\107\\053\", \"Rys=\" },\n  { 2, \"\\204\\077\", \"hD8=\" },\n  { 2, \"\\276\\211\", \"vok=\" },\n  { 2, \"\\313\\110\", \"y0g=\" },\n  { 2, \"\\363\\376\", \"8/4=\" },\n  { 2, \"\\251\\234\", \"qZw=\" },\n  { 2, \"\\103\\262\", \"Q7I=\" },\n  { 2, \"\\142\\312\", \"Yso=\" },\n  { 2, \"\\067\\211\", \"N4k=\" },\n  { 2, \"\\220\\001\", \"kAE=\" },\n  { 2, \"\\152\\240\", \"aqA=\" },\n  { 2, \"\\367\\061\", \"9zE=\" },\n  { 2, \"\\133\\255\", \"W60=\" },\n  { 2, \"\\176\\035\", \"fh0=\" },\n  { 2, \"\\032\\231\", \"Gpk=\" },\n\n  { 3, \"\\013\\007\\144\", \"Cwdk\" },\n  { 3, \"\\030\\112\\106\", \"GEpG\" },\n  { 3, \"\\047\\325\\046\", \"J9Um\" },\n  { 3, \"\\310\\160\\022\", \"yHAS\" },\n  { 3, \"\\131\\100\\237\", \"WUCf\" },\n  { 3, \"\\064\\342\\134\", \"NOJc\" },\n  { 3, \"\\010\\177\\004\", \"CH8E\" },\n  { 3, \"\\345\\147\\205\", \"5WeF\" },\n  { 3, \"\\300\\343\\360\", \"wOPw\" },\n  { 3, \"\\061\\240\\201\", \"MaCB\" },\n  { 3, \"\\225\\333\\044\", \"ldsk\" },\n  { 3, \"\\215\\137\\352\", \"jV/q\" },\n  { 3, \"\\371\\147\\160\", \"+Wdw\" },\n  { 3, \"\\030\\320\\051\", \"GNAp\" },\n  { 3, \"\\044\\174\\241\", \"JHyh\" },\n  { 3, \"\\260\\127\\037\", \"sFcf\" },\n  { 3, \"\\111\\045\\033\", \"SSUb\" },\n  { 3, \"\\202\\114\\107\", \"gkxH\" },\n  { 3, \"\\057\\371\\042\", \"L/ki\" },\n  { 3, \"\\223\\247\\244\", \"k6ek\" },\n  { 3, \"\\047\\216\\144\", \"J45k\" },\n  { 3, \"\\203\\070\\327\", \"gzjX\" },\n  { 3, \"\\247\\140\\072\", \"p2A6\" },\n  { 3, \"\\124\\115\\116\", \"VE1O\" },\n  { 3, \"\\157\\162\\050\", \"b3Io\" },\n  { 3, \"\\357\\223\\004\", \"75ME\" },\n  { 3, \"\\052\\117\\156\", \"Kk9u\" },\n  { 3, \"\\347\\154\\000\", \"52wA\" },\n  { 3, \"\\303\\012\\142\", \"wwpi\" },\n  { 3, \"\\060\\035\\362\", \"MB3y\" },\n  { 3, \"\\130\\226\\361\", \"WJbx\" },\n  { 3, \"\\173\\013\\071\", \"ews5\" },\n  { 3, \"\\336\\004\\027\", \"3gQX\" },\n  { 3, \"\\357\\366\\234\", \"7/ac\" },\n  { 3, \"\\353\\304\\111\", \"68RJ\" },\n  { 3, \"\\024\\264\\131\", \"FLRZ\" },\n  { 3, \"\\075\\114\\251\", \"PUyp\" },\n  { 3, \"\\315\\031\\225\", \"zRmV\" },\n  { 3, \"\\154\\201\\276\", \"bIG+\" },\n  { 3, \"\\200\\066\\072\", \"gDY6\" },\n  { 3, \"\\142\\350\\267\", \"Yui3\" },\n  { 3, \"\\033\\000\\166\", \"GwB2\" },\n  { 3, \"\\210\\055\\077\", \"iC0/\" },\n  { 3, \"\\341\\037\\124\", \"4R9U\" },\n  { 3, \"\\161\\103\\152\", \"cUNq\" },\n  { 3, \"\\270\\142\\131\", \"uGJZ\" },\n  { 3, \"\\337\\076\\074\", \"3z48\" },\n  { 3, \"\\375\\106\\362\", \"/Uby\" },\n  { 3, \"\\227\\301\\127\", \"l8FX\" },\n  { 3, \"\\340\\002\\234\", \"4AKc\" },\n  { 3, \"\\121\\064\\033\", \"UTQb\" },\n  { 3, \"\\157\\134\\143\", \"b1xj\" },\n  { 3, \"\\247\\055\\327\", \"py3X\" },\n  { 3, \"\\340\\142\\005\", \"4GIF\" },\n  { 3, \"\\060\\260\\143\", \"MLBj\" },\n  { 3, \"\\075\\203\\170\", \"PYN4\" },\n  { 3, \"\\143\\160\\016\", \"Y3AO\" },\n  { 3, \"\\313\\013\\063\", \"ywsz\" },\n  { 3, \"\\174\\236\\135\", \"fJ5d\" },\n  { 3, \"\\103\\047\\026\", \"QycW\" },\n  { 3, \"\\365\\005\\343\", \"9QXj\" },\n  { 3, \"\\271\\160\\223\", \"uXCT\" },\n  { 3, \"\\362\\255\\172\", \"8q16\" },\n  { 3, \"\\113\\012\\015\", \"SwoN\" },\n\n  // various lengths, generated by this python script:\n  //\n  // from string import lowercase as lc\n  // for i in range(27):\n  //   print '{ %2d, \"%s\",%s \"%s\" },' % (i, lc[:i], ' ' * (26-i),\n  //                                     lc[:i].encode('base64').strip())\n\n  {  0, \"\",                           \"\" },\n  {  1, \"a\",                          \"YQ==\" },\n  {  2, \"ab\",                         \"YWI=\" },\n  {  3, \"abc\",                        \"YWJj\" },\n  {  4, \"abcd\",                       \"YWJjZA==\" },\n  {  5, \"abcde\",                      \"YWJjZGU=\" },\n  {  6, \"abcdef\",                     \"YWJjZGVm\" },\n  {  7, \"abcdefg\",                    \"YWJjZGVmZw==\" },\n  {  8, \"abcdefgh\",                   \"YWJjZGVmZ2g=\" },\n  {  9, \"abcdefghi\",                  \"YWJjZGVmZ2hp\" },\n  { 10, \"abcdefghij\",                 \"YWJjZGVmZ2hpag==\" },\n  { 11, \"abcdefghijk\",                \"YWJjZGVmZ2hpams=\" },\n  { 12, \"abcdefghijkl\",               \"YWJjZGVmZ2hpamts\" },\n  { 13, \"abcdefghijklm\",              \"YWJjZGVmZ2hpamtsbQ==\" },\n  { 14, \"abcdefghijklmn\",             \"YWJjZGVmZ2hpamtsbW4=\" },\n  { 15, \"abcdefghijklmno\",            \"YWJjZGVmZ2hpamtsbW5v\" },\n  { 16, \"abcdefghijklmnop\",           \"YWJjZGVmZ2hpamtsbW5vcA==\" },\n  { 17, \"abcdefghijklmnopq\",          \"YWJjZGVmZ2hpamtsbW5vcHE=\" },\n  { 18, \"abcdefghijklmnopqr\",         \"YWJjZGVmZ2hpamtsbW5vcHFy\" },\n  { 19, \"abcdefghijklmnopqrs\",        \"YWJjZGVmZ2hpamtsbW5vcHFycw==\" },\n  { 20, \"abcdefghijklmnopqrst\",       \"YWJjZGVmZ2hpamtsbW5vcHFyc3Q=\" },\n  { 21, \"abcdefghijklmnopqrstu\",      \"YWJjZGVmZ2hpamtsbW5vcHFyc3R1\" },\n  { 22, \"abcdefghijklmnopqrstuv\",     \"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dg==\" },\n  { 23, \"abcdefghijklmnopqrstuvw\",    \"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnc=\" },\n  { 24, \"abcdefghijklmnopqrstuvwx\",   \"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4\" },\n  { 25, \"abcdefghijklmnopqrstuvwxy\",  \"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eQ==\" },\n  { 26, \"abcdefghijklmnopqrstuvwxyz\", \"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXo=\" },\n};\n\nstatic struct {\n  const char* plaintext;\n  const char* cyphertext;\n} base64_strings[] = {\n  // Some google quotes\n  // Cyphertext created with \"uuencode (GNU sharutils) 4.6.3\"\n  // (Note that we're testing the websafe encoding, though, so if\n  // you add messages, be sure to run \"tr -- '+/' '-_'\" on the output)\n  { \"I was always good at math and science, and I never realized \"\n    \"that was unusual or somehow undesirable. So one of the things \"\n    \"I care a lot about is helping to remove that stigma, \"\n    \"to show girls that you can be feminine, you can like the things \"\n    \"that girls like, but you can also be really good at technology. \"\n    \"You can be really good at building things.\"\n    \" - Marissa Meyer, Newsweek, 2010-12-22\" \"\\n\",\n\n    \"SSB3YXMgYWx3YXlzIGdvb2QgYXQgbWF0aCBhbmQgc2NpZW5jZSwgYW5kIEkg\"\n    \"bmV2ZXIgcmVhbGl6ZWQgdGhhdCB3YXMgdW51c3VhbCBvciBzb21laG93IHVu\"\n    \"ZGVzaXJhYmxlLiBTbyBvbmUgb2YgdGhlIHRoaW5ncyBJIGNhcmUgYSBsb3Qg\"\n    \"YWJvdXQgaXMgaGVscGluZyB0byByZW1vdmUgdGhhdCBzdGlnbWEsIHRvIHNo\"\n    \"b3cgZ2lybHMgdGhhdCB5b3UgY2FuIGJlIGZlbWluaW5lLCB5b3UgY2FuIGxp\"\n    \"a2UgdGhlIHRoaW5ncyB0aGF0IGdpcmxzIGxpa2UsIGJ1dCB5b3UgY2FuIGFs\"\n    \"c28gYmUgcmVhbGx5IGdvb2QgYXQgdGVjaG5vbG9neS4gWW91IGNhbiBiZSBy\"\n    \"ZWFsbHkgZ29vZCBhdCBidWlsZGluZyB0aGluZ3MuIC0gTWFyaXNzYSBNZXll\"\n    \"ciwgTmV3c3dlZWssIDIwMTAtMTItMjIK\" },\n\n  { \"Typical first year for a new cluster: \"\n    \"~0.5 overheating \"\n    \"~1 PDU failure \"\n    \"~1 rack-move \"\n    \"~1 network rewiring \"\n    \"~20 rack failures \"\n    \"~5 racks go wonky \"\n    \"~8 network maintenances \"\n    \"~12 router reloads \"\n    \"~3 router failures \"\n    \"~dozens of minor 30-second blips for dns \"\n    \"~1000 individual machine failures \"\n    \"~thousands of hard drive failures \"\n    \"slow disks, bad memory, misconfigured machines, flaky machines, etc.\"\n    \" - Jeff Dean, The Joys of Real Hardware\" \"\\n\",\n\n    \"VHlwaWNhbCBmaXJzdCB5ZWFyIGZvciBhIG5ldyBjbHVzdGVyOiB-MC41IG92\"\n    \"ZXJoZWF0aW5nIH4xIFBEVSBmYWlsdXJlIH4xIHJhY2stbW92ZSB-MSBuZXR3\"\n    \"b3JrIHJld2lyaW5nIH4yMCByYWNrIGZhaWx1cmVzIH41IHJhY2tzIGdvIHdv\"\n    \"bmt5IH44IG5ldHdvcmsgbWFpbnRlbmFuY2VzIH4xMiByb3V0ZXIgcmVsb2Fk\"\n    \"cyB-MyByb3V0ZXIgZmFpbHVyZXMgfmRvemVucyBvZiBtaW5vciAzMC1zZWNv\"\n    \"bmQgYmxpcHMgZm9yIGRucyB-MTAwMCBpbmRpdmlkdWFsIG1hY2hpbmUgZmFp\"\n    \"bHVyZXMgfnRob3VzYW5kcyBvZiBoYXJkIGRyaXZlIGZhaWx1cmVzIHNsb3cg\"\n    \"ZGlza3MsIGJhZCBtZW1vcnksIG1pc2NvbmZpZ3VyZWQgbWFjaGluZXMsIGZs\"\n    \"YWt5IG1hY2hpbmVzLCBldGMuIC0gSmVmZiBEZWFuLCBUaGUgSm95cyBvZiBS\"\n    \"ZWFsIEhhcmR3YXJlCg\" },\n\n  { \"I'm the head of the webspam team at Google.  \"\n    \"That means that if you type your name into Google and get porn back, \"\n    \"it's my fault. Unless you're a porn star, in which case porn is a \"\n    \"completely reasonable response.\"\n    \" - Matt Cutts, Google Plus\" \"\\n\",\n\n    \"SSdtIHRoZSBoZWFkIG9mIHRoZSB3ZWJzcGFtIHRlYW0gYXQgR29vZ2xlLiAg\"\n    \"VGhhdCBtZWFucyB0aGF0IGlmIHlvdSB0eXBlIHlvdXIgbmFtZSBpbnRvIEdv\"\n    \"b2dsZSBhbmQgZ2V0IHBvcm4gYmFjaywgaXQncyBteSBmYXVsdC4gVW5sZXNz\"\n    \"IHlvdSdyZSBhIHBvcm4gc3RhciwgaW4gd2hpY2ggY2FzZSBwb3JuIGlzIGEg\"\n    \"Y29tcGxldGVseSByZWFzb25hYmxlIHJlc3BvbnNlLiAtIE1hdHQgQ3V0dHMs\"\n    \"IEdvb2dsZSBQbHVzCg\" },\n\n  { \"It will still be a long time before machines approach human intelligence. \"\n    \"But luckily, machines don't actually have to be intelligent; \"\n    \"they just have to fake it. Access to a wealth of information, \"\n    \"combined with a rudimentary decision-making capacity, \"\n    \"can often be almost as useful. Of course, the results are better yet \"\n    \"when coupled with intelligence. A reference librarian with access to \"\n    \"a good search engine is a formidable tool.\"\n    \" - Craig Silverstein, Siemens Pictures of the Future, Spring 2004\" \"\\n\",\n\n    \"SXQgd2lsbCBzdGlsbCBiZSBhIGxvbmcgdGltZSBiZWZvcmUgbWFjaGluZXMg\"\n    \"YXBwcm9hY2ggaHVtYW4gaW50ZWxsaWdlbmNlLiBCdXQgbHVja2lseSwgbWFj\"\n    \"aGluZXMgZG9uJ3QgYWN0dWFsbHkgaGF2ZSB0byBiZSBpbnRlbGxpZ2VudDsg\"\n    \"dGhleSBqdXN0IGhhdmUgdG8gZmFrZSBpdC4gQWNjZXNzIHRvIGEgd2VhbHRo\"\n    \"IG9mIGluZm9ybWF0aW9uLCBjb21iaW5lZCB3aXRoIGEgcnVkaW1lbnRhcnkg\"\n    \"ZGVjaXNpb24tbWFraW5nIGNhcGFjaXR5LCBjYW4gb2Z0ZW4gYmUgYWxtb3N0\"\n    \"IGFzIHVzZWZ1bC4gT2YgY291cnNlLCB0aGUgcmVzdWx0cyBhcmUgYmV0dGVy\"\n    \"IHlldCB3aGVuIGNvdXBsZWQgd2l0aCBpbnRlbGxpZ2VuY2UuIEEgcmVmZXJl\"\n    \"bmNlIGxpYnJhcmlhbiB3aXRoIGFjY2VzcyB0byBhIGdvb2Qgc2VhcmNoIGVu\"\n    \"Z2luZSBpcyBhIGZvcm1pZGFibGUgdG9vbC4gLSBDcmFpZyBTaWx2ZXJzdGVp\"\n    \"biwgU2llbWVucyBQaWN0dXJlcyBvZiB0aGUgRnV0dXJlLCBTcHJpbmcgMjAw\"\n    \"NAo\" },\n\n  // Degenerate edge case\n  { \"\",\n    \"\" },\n};\n\nTEST(Base64, EscapeAndUnescape) {\n  // Check the short strings; this tests the math (and boundaries)\n  for (int i = 0; i < sizeof(base64_tests) / sizeof(base64_tests[0]); ++i) {\n    char encode_buffer[100];\n    int encode_length;\n    char decode_buffer[100];\n    int decode_length;\n    int cypher_length;\n    string decode_str;\n\n    const unsigned char* unsigned_plaintext =\n      reinterpret_cast<const unsigned char*>(base64_tests[i].plaintext);\n\n    StringPiece plaintext(base64_tests[i].plaintext,\n                          base64_tests[i].plain_length);\n\n    cypher_length = strlen(base64_tests[i].cyphertext);\n\n    // The basic escape function:\n    memset(encode_buffer, 0, sizeof(encode_buffer));\n    encode_length = Base64Escape(unsigned_plaintext,\n                                 base64_tests[i].plain_length,\n                                 encode_buffer,\n                                 sizeof(encode_buffer));\n    //    Is it of the expected length?\n    EXPECT_EQ(encode_length, cypher_length);\n    // Would it have been okay to allocate only CalculateBase64EscapeLen()?\n    EXPECT_EQ(CalculateBase64EscapedLen(base64_tests[i].plain_length),\n              encode_length);\n\n    //    Is it the expected encoded value?\n    ASSERT_STREQ(encode_buffer, base64_tests[i].cyphertext);\n\n    // If we encode it into a buffer of exactly the right length...\n    memset(encode_buffer, 0, sizeof(encode_buffer));\n    encode_length = Base64Escape(unsigned_plaintext,\n                                          base64_tests[i].plain_length,\n                                          encode_buffer,\n                                          cypher_length);\n    //    Is it still of the expected length?\n    EXPECT_EQ(encode_length, cypher_length);\n\n    //    And is the value still correct?  (i.e., not losing the last byte)\n    EXPECT_STREQ(encode_buffer, base64_tests[i].cyphertext);\n\n    // If we decode it back:\n    decode_str.clear();\n    EXPECT_TRUE(Base64Unescape(\n        StringPiece(encode_buffer, cypher_length), &decode_str));\n\n    //    Is it of the expected length?\n    EXPECT_EQ(base64_tests[i].plain_length, decode_str.length());\n\n    //    Is it the expected decoded value?\n    EXPECT_EQ(plaintext, decode_str);\n\n    // Let's try with a pre-populated string.\n    string encoded(\"this junk should be ignored\");\n    Base64Escape(string(base64_tests[i].plaintext,\n                        base64_tests[i].plain_length),\n                 &encoded);\n    EXPECT_EQ(encoded, string(encode_buffer, cypher_length));\n\n    string decoded(\"this junk should be ignored\");\n    EXPECT_TRUE(Base64Unescape(\n        StringPiece(encode_buffer, cypher_length), &decoded));\n    EXPECT_EQ(decoded.size(), base64_tests[i].plain_length);\n    EXPECT_EQ_ARRAY(decoded.size(), decoded, base64_tests[i].plaintext, i);\n\n    // Our decoder treats the padding '=' characters at the end as\n    // optional (but if there are any, there must be the correct\n    // number of them.)  If encode_buffer has any, run some additional\n    // tests that fiddle with them.\n    char* first_equals = strchr(encode_buffer, '=');\n    if (first_equals) {\n      // How many equals signs does the string start with?\n      int equals = (*(first_equals+1) == '=') ? 2 : 1;\n\n      // Try chopping off the equals sign(s) entirely.  The decoder\n      // should still be okay with this.\n      string decoded2(\"this junk should also be ignored\");\n      *first_equals = '\\0';\n      EXPECT_TRUE(Base64Unescape(\n          StringPiece(encode_buffer, first_equals - encode_buffer), &decoded2));\n      EXPECT_EQ(decoded.size(), base64_tests[i].plain_length);\n      EXPECT_EQ_ARRAY(decoded.size(), decoded, base64_tests[i].plaintext, i);\n\n      // Now test chopping off the equals sign(s) and adding\n      // whitespace.  Our decoder should still accept this.\n      decoded2.assign(\"this junk should be ignored\");\n      *first_equals = ' ';\n      *(first_equals+1) = '\\0';\n      EXPECT_TRUE(Base64Unescape(\n          StringPiece(encode_buffer, first_equals - encode_buffer + 1),\n          &decoded2));\n      EXPECT_EQ(decoded.size(), base64_tests[i].plain_length);\n      EXPECT_EQ_ARRAY(decoded.size(), decoded, base64_tests[i].plaintext, i);\n\n      // Now stick a bad character at the end of the string.  The decoder\n      // should refuse this string.\n      decoded2.assign(\"this junk should be ignored\");\n      *first_equals = '?';\n      *(first_equals+1) = '\\0';\n      EXPECT_TRUE(\n          !Base64Unescape(\n              StringPiece(encode_buffer, first_equals - encode_buffer + 1),\n              &decoded2));\n\n      int len;\n\n      // Test whitespace mixed with the padding.  (eg \"AA = = \")  The\n      // decoder should accept this.\n      if (equals == 2) {\n        snprintf(first_equals, 6, \" = = \");\n        len = first_equals - encode_buffer + 5;\n      } else {\n        snprintf(first_equals, 6, \" = \");\n        len = first_equals - encode_buffer + 3;\n      }\n      decoded2.assign(\"this junk should be ignored\");\n      EXPECT_TRUE(\n          Base64Unescape(StringPiece(encode_buffer, len), &decoded2));\n      EXPECT_EQ(decoded.size(), base64_tests[i].plain_length);\n      EXPECT_EQ_ARRAY(decoded.size(), decoded, base64_tests[i].plaintext, i);\n\n      // Test whitespace mixed with the padding, but with the wrong\n      // number of equals signs (eg \"AA = \").  The decoder should\n      // refuse these strings.\n      if (equals == 1) {\n        snprintf(first_equals, 6, \" = = \");\n        len = first_equals - encode_buffer + 5;\n      } else {\n        snprintf(first_equals, 6, \" = \");\n        len = first_equals - encode_buffer + 3;\n      }\n      EXPECT_TRUE(\n          !Base64Unescape(StringPiece(encode_buffer, len), &decoded2));\n    }\n\n    // Cool! the basic Base64 encoder/decoder works.\n    // Let's try the alternate alphabet: tr -- '+/' '-_'\n\n    char websafe[100];\n    memset(websafe, 0, sizeof(websafe));\n    strncpy(websafe, base64_tests[i].cyphertext, cypher_length);\n    for (int c = 0; c < sizeof(websafe); ++c) {\n      if ('+' == websafe[c]) { websafe[c] = '-'; }\n      if ('/' == websafe[c]) { websafe[c] = '_'; }\n    }\n\n    // The websafe escape function:\n    memset(encode_buffer, 0, sizeof(encode_buffer));\n    encode_length = WebSafeBase64Escape(unsigned_plaintext,\n                                                 base64_tests[i].plain_length,\n                                                 encode_buffer,\n                                                 sizeof(encode_buffer),\n                                                 true);\n    //    Is it of the expected length?\n    EXPECT_EQ(encode_length, cypher_length);\n    EXPECT_EQ(\n        CalculateBase64EscapedLen(base64_tests[i].plain_length, true),\n        encode_length);\n\n    //    Is it the expected encoded value?\n    EXPECT_STREQ(encode_buffer, websafe);\n\n    //    If we encode it into a buffer of exactly the right length...\n    memset(encode_buffer, 0, sizeof(encode_buffer));\n    encode_length = WebSafeBase64Escape(unsigned_plaintext,\n                                                 base64_tests[i].plain_length,\n                                                 encode_buffer,\n                                                 cypher_length,\n                                                 true);\n    //    Is it still of the expected length?\n    EXPECT_EQ(encode_length, cypher_length);\n\n    //    And is the value still correct?  (i.e., not losing the last byte)\n    EXPECT_STREQ(encode_buffer, websafe);\n\n    //    Let's try the string version of the encoder\n    encoded = \"this junk should be ignored\";\n    WebSafeBase64Escape(\n        unsigned_plaintext, base64_tests[i].plain_length,\n        &encoded, true);\n    EXPECT_EQ(encoded.size(), cypher_length);\n    EXPECT_STREQ(encoded.c_str(), websafe);\n\n    //    If we decode it back:\n    memset(decode_buffer, 0, sizeof(decode_buffer));\n    decode_length = WebSafeBase64Unescape(encode_buffer,\n                                                   cypher_length,\n                                                   decode_buffer,\n                                                   sizeof(decode_buffer));\n\n    //    Is it of the expected length?\n    EXPECT_EQ(decode_length, base64_tests[i].plain_length);\n\n    //    Is it the expected decoded value?\n    EXPECT_EQ(0,\n              memcmp(decode_buffer, base64_tests[i].plaintext, decode_length));\n\n    //    If we decode it into a buffer of exactly the right length...\n    memset(decode_buffer, 0, sizeof(decode_buffer));\n    decode_length = WebSafeBase64Unescape(encode_buffer,\n                                                   cypher_length,\n                                                   decode_buffer,\n                                                   decode_length);\n\n    //    Is it still of the expected length?\n    EXPECT_EQ(decode_length, base64_tests[i].plain_length);\n\n    //    And is it the expected decoded value?\n    EXPECT_EQ(0,\n              memcmp(decode_buffer, base64_tests[i].plaintext, decode_length));\n\n    // Try using '.' for the pad character.\n    for (int c = cypher_length - 1; c >= 0 && '=' == encode_buffer[c]; --c) {\n      encode_buffer[c] = '.';\n    }\n\n    // If we decode it back:\n    memset(decode_buffer, 0, sizeof(decode_buffer));\n    decode_length = WebSafeBase64Unescape(encode_buffer,\n                                                   cypher_length,\n                                                   decode_buffer,\n                                                   sizeof(decode_buffer));\n\n    // Is it of the expected length?\n    EXPECT_EQ(decode_length, base64_tests[i].plain_length);\n\n    // Is it the expected decoded value?\n    EXPECT_EQ(0,\n              memcmp(decode_buffer, base64_tests[i].plaintext, decode_length));\n\n    // If we decode it into a buffer of exactly the right length...\n    memset(decode_buffer, 0, sizeof(decode_buffer));\n    decode_length = WebSafeBase64Unescape(encode_buffer,\n                                                   cypher_length,\n                                                   decode_buffer,\n                                                   decode_length);\n\n    // Is it still of the expected length?\n    EXPECT_EQ(decode_length, base64_tests[i].plain_length);\n\n    // And is it the expected decoded value?\n    EXPECT_EQ(0,\n              memcmp(decode_buffer, base64_tests[i].plaintext, decode_length));\n\n    // Let's try the string version of the decoder\n    decoded = \"this junk should be ignored\";\n    EXPECT_TRUE(WebSafeBase64Unescape(\n        StringPiece(encode_buffer, cypher_length), &decoded));\n    EXPECT_EQ(decoded.size(), base64_tests[i].plain_length);\n    EXPECT_EQ_ARRAY(decoded.size(), decoded, base64_tests[i].plaintext, i);\n\n    // Okay! the websafe Base64 encoder/decoder works.\n    // Let's try the unpadded version\n\n    for (int c = 0; c < sizeof(websafe); ++c) {\n      if ('=' == websafe[c]) {\n        websafe[c] = '\\0';\n        cypher_length = c;\n        break;\n      }\n    }\n\n    // The websafe escape function:\n    memset(encode_buffer, 0, sizeof(encode_buffer));\n    encode_length = WebSafeBase64Escape(unsigned_plaintext,\n                                                 base64_tests[i].plain_length,\n                                                 encode_buffer,\n                                                 sizeof(encode_buffer),\n                                                 false);\n    //    Is it of the expected length?\n    EXPECT_EQ(encode_length, cypher_length);\n    EXPECT_EQ(\n        CalculateBase64EscapedLen(base64_tests[i].plain_length, false),\n        encode_length);\n\n    //    Is it the expected encoded value?\n    EXPECT_STREQ(encode_buffer, websafe);\n\n    //    If we encode it into a buffer of exactly the right length...\n    memset(encode_buffer, 0, sizeof(encode_buffer));\n    encode_length = WebSafeBase64Escape(unsigned_plaintext,\n                                                 base64_tests[i].plain_length,\n                                                 encode_buffer,\n                                                 cypher_length,\n                                                 false);\n    //    Is it still of the expected length?\n    EXPECT_EQ(encode_length, cypher_length);\n\n    //    And is the value still correct?  (i.e., not losing the last byte)\n    EXPECT_STREQ(encode_buffer, websafe);\n\n    // Let's try the (other) string version of the encoder\n    string plain(base64_tests[i].plaintext, base64_tests[i].plain_length);\n    encoded = \"this junk should be ignored\";\n    WebSafeBase64Escape(plain, &encoded);\n    EXPECT_EQ(encoded.size(), cypher_length);\n    EXPECT_STREQ(encoded.c_str(), websafe);\n\n    //    If we decode it back:\n    memset(decode_buffer, 0, sizeof(decode_buffer));\n    decode_length = WebSafeBase64Unescape(encode_buffer,\n                                                   cypher_length,\n                                                   decode_buffer,\n                                                   sizeof(decode_buffer));\n\n    //    Is it of the expected length?\n    EXPECT_EQ(decode_length, base64_tests[i].plain_length);\n\n    //    Is it the expected decoded value?\n    EXPECT_EQ(0,\n              memcmp(decode_buffer, base64_tests[i].plaintext, decode_length));\n\n    //    If we decode it into a buffer of exactly the right length...\n    memset(decode_buffer, 0, sizeof(decode_buffer));\n    decode_length = WebSafeBase64Unescape(encode_buffer,\n                                                   cypher_length,\n                                                   decode_buffer,\n                                                   decode_length);\n\n    //    Is it still of the expected length?\n    EXPECT_EQ(decode_length, base64_tests[i].plain_length);\n\n    //    And is it the expected decoded value?\n    EXPECT_EQ(0,\n              memcmp(decode_buffer, base64_tests[i].plaintext, decode_length));\n\n\n    // Let's try the string version of the decoder\n    decoded = \"this junk should be ignored\";\n    EXPECT_TRUE(WebSafeBase64Unescape(\n        StringPiece(encode_buffer, cypher_length), &decoded));\n    EXPECT_EQ(decoded.size(), base64_tests[i].plain_length);\n    EXPECT_EQ_ARRAY(decoded.size(), decoded, base64_tests[i].plaintext, i);\n\n    // This value works.  Try the next.\n  }\n\n  // Now try the long strings, this tests the streaming\n  for (int i = 0; i < sizeof(base64_strings) / sizeof(base64_strings[0]);\n       ++i) {\n    const unsigned char* unsigned_plaintext =\n      reinterpret_cast<const unsigned char*>(base64_strings[i].plaintext);\n    int plain_length = strlen(base64_strings[i].plaintext);\n    int cypher_length = strlen(base64_strings[i].cyphertext);\n    vector<char> buffer(cypher_length+1);\n    int encode_length = WebSafeBase64Escape(unsigned_plaintext,\n                                                     plain_length,\n                                                     &buffer[0],\n                                                     buffer.size(),\n                                                     false);\n    EXPECT_EQ(cypher_length, encode_length);\n    EXPECT_EQ(\n        CalculateBase64EscapedLen(plain_length, false), encode_length);\n    buffer[ encode_length ] = '\\0';\n    EXPECT_STREQ(base64_strings[i].cyphertext, &buffer[0]);\n  }\n\n  // Verify the behavior when decoding bad data\n  {\n    const char* bad_data = \"ab-/\";\n    string buf;\n    EXPECT_FALSE(Base64Unescape(StringPiece(bad_data), &buf));\n    EXPECT_TRUE(!WebSafeBase64Unescape(bad_data, &buf));\n    EXPECT_TRUE(buf.empty());\n  }\n}\n\n}  // anonymous namespace\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/substitute.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n\n#include <google/protobuf/stubs/substitute.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/stl_util.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace strings {\n\nusing internal::SubstituteArg;\n\n// Returns the number of args in arg_array which were passed explicitly\n// to Substitute().\nstatic int CountSubstituteArgs(const SubstituteArg* const* args_array) {\n  int count = 0;\n  while (args_array[count] != NULL && args_array[count]->size() != -1) {\n    ++count;\n  }\n  return count;\n}\n\nstring Substitute(\n    const char* format,\n    const SubstituteArg& arg0, const SubstituteArg& arg1,\n    const SubstituteArg& arg2, const SubstituteArg& arg3,\n    const SubstituteArg& arg4, const SubstituteArg& arg5,\n    const SubstituteArg& arg6, const SubstituteArg& arg7,\n    const SubstituteArg& arg8, const SubstituteArg& arg9) {\n  string result;\n  SubstituteAndAppend(&result, format, arg0, arg1, arg2, arg3, arg4,\n                                       arg5, arg6, arg7, arg8, arg9);\n  return result;\n}\n\nvoid SubstituteAndAppend(\n    string* output, const char* format,\n    const SubstituteArg& arg0, const SubstituteArg& arg1,\n    const SubstituteArg& arg2, const SubstituteArg& arg3,\n    const SubstituteArg& arg4, const SubstituteArg& arg5,\n    const SubstituteArg& arg6, const SubstituteArg& arg7,\n    const SubstituteArg& arg8, const SubstituteArg& arg9) {\n  const SubstituteArg* const args_array[] = {\n    &arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9, NULL\n  };\n\n  // Determine total size needed.\n  int size = 0;\n  for (int i = 0; format[i] != '\\0'; i++) {\n    if (format[i] == '$') {\n      if (ascii_isdigit(format[i+1])) {\n        int index = format[i+1] - '0';\n        if (args_array[index]->size() == -1) {\n          GOOGLE_LOG(DFATAL)\n            << \"strings::Substitute format string invalid: asked for \\\"$\"\n            << index << \"\\\", but only \" << CountSubstituteArgs(args_array)\n            << \" args were given.  Full format string was: \\\"\"\n            << CEscape(format) << \"\\\".\";\n          return;\n        }\n        size += args_array[index]->size();\n        ++i;  // Skip next char.\n      } else if (format[i+1] == '$') {\n        ++size;\n        ++i;  // Skip next char.\n      } else {\n        GOOGLE_LOG(DFATAL)\n          << \"Invalid strings::Substitute() format string: \\\"\"\n          << CEscape(format) << \"\\\".\";\n        return;\n      }\n    } else {\n      ++size;\n    }\n  }\n\n  if (size == 0) return;\n\n  // Build the string.\n  int original_size = output->size();\n  STLStringResizeUninitialized(output, original_size + size);\n  char* target = string_as_array(output) + original_size;\n  for (int i = 0; format[i] != '\\0'; i++) {\n    if (format[i] == '$') {\n      if (ascii_isdigit(format[i+1])) {\n        const SubstituteArg* src = args_array[format[i+1] - '0'];\n        memcpy(target, src->data(), src->size());\n        target += src->size();\n        ++i;  // Skip next char.\n      } else if (format[i+1] == '$') {\n        *target++ = '$';\n        ++i;  // Skip next char.\n      }\n    } else {\n      *target++ = format[i];\n    }\n  }\n\n  GOOGLE_DCHECK_EQ(target - output->data(), output->size());\n}\n\n}  // namespace strings\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/substitute.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n// from google3/strings/substitute.h\n\n#include <string>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/strutil.h>\n\n#ifndef GOOGLE_PROTOBUF_STUBS_SUBSTITUTE_H_\n#define GOOGLE_PROTOBUF_STUBS_SUBSTITUTE_H_\n\nnamespace google {\nnamespace protobuf {\nnamespace strings {\n\n// ----------------------------------------------------------------------\n// strings::Substitute()\n// strings::SubstituteAndAppend()\n//   Kind of like StringPrintf, but different.\n//\n//   Example:\n//     string GetMessage(string first_name, string last_name, int age) {\n//       return strings::Substitute(\"My name is $0 $1 and I am $2 years old.\",\n//                                  first_name, last_name, age);\n//     }\n//\n//   Differences from StringPrintf:\n//   * The format string does not identify the types of arguments.\n//     Instead, the magic of C++ deals with this for us.  See below\n//     for a list of accepted types.\n//   * Substitutions in the format string are identified by a '$'\n//     followed by a digit.  So, you can use arguments out-of-order and\n//     use the same argument multiple times.\n//   * It's much faster than StringPrintf.\n//\n//   Supported types:\n//   * Strings (const char*, const string&)\n//     * Note that this means you do not have to add .c_str() to all of\n//       your strings.  In fact, you shouldn't; it will be slower.\n//   * int32, int64, uint32, uint64:  Formatted using SimpleItoa().\n//   * float, double:  Formatted using SimpleFtoa() and SimpleDtoa().\n//   * bool:  Printed as \"true\" or \"false\".\n//\n//   SubstituteAndAppend() is like Substitute() but appends the result to\n//   *output.  Example:\n//\n//     string str;\n//     strings::SubstituteAndAppend(&str,\n//                                  \"My name is $0 $1 and I am $2 years old.\",\n//                                  first_name, last_name, age);\n//\n//   Substitute() is significantly faster than StringPrintf().  For very\n//   large strings, it may be orders of magnitude faster.\n// ----------------------------------------------------------------------\n\nnamespace internal {  // Implementation details.\n\nclass SubstituteArg {\n public:\n  inline SubstituteArg(const char* value)\n    : text_(value), size_(strlen(text_)) {}\n  inline SubstituteArg(const string& value)\n    : text_(value.data()), size_(value.size()) {}\n\n  // Indicates that no argument was given.\n  inline explicit SubstituteArg()\n    : text_(NULL), size_(-1) {}\n\n  // Primitives\n  // We don't overload for signed and unsigned char because if people are\n  // explicitly declaring their chars as signed or unsigned then they are\n  // probably actually using them as 8-bit integers and would probably\n  // prefer an integer representation.  But, we don't really know.  So, we\n  // make the caller decide what to do.\n  inline SubstituteArg(char value)\n    : text_(scratch_), size_(1) { scratch_[0] = value; }\n  inline SubstituteArg(short value)\n    : text_(FastInt32ToBuffer(value, scratch_)), size_(strlen(text_)) {}\n  inline SubstituteArg(unsigned short value)\n    : text_(FastUInt32ToBuffer(value, scratch_)), size_(strlen(text_)) {}\n  inline SubstituteArg(int value)\n    : text_(FastInt32ToBuffer(value, scratch_)), size_(strlen(text_)) {}\n  inline SubstituteArg(unsigned int value)\n    : text_(FastUInt32ToBuffer(value, scratch_)), size_(strlen(text_)) {}\n  inline SubstituteArg(long value)\n    : text_(FastLongToBuffer(value, scratch_)), size_(strlen(text_)) {}\n  inline SubstituteArg(unsigned long value)\n    : text_(FastULongToBuffer(value, scratch_)), size_(strlen(text_)) {}\n  inline SubstituteArg(long long value)\n    : text_(FastInt64ToBuffer(value, scratch_)), size_(strlen(text_)) {}\n  inline SubstituteArg(unsigned long long value)\n    : text_(FastUInt64ToBuffer(value, scratch_)), size_(strlen(text_)) {}\n  inline SubstituteArg(float value)\n    : text_(FloatToBuffer(value, scratch_)), size_(strlen(text_)) {}\n  inline SubstituteArg(double value)\n    : text_(DoubleToBuffer(value, scratch_)), size_(strlen(text_)) {}\n  inline SubstituteArg(bool value)\n    : text_(value ? \"true\" : \"false\"), size_(strlen(text_)) {}\n\n  inline const char* data() const { return text_; }\n  inline int size() const { return size_; }\n\n private:\n  const char* text_;\n  int size_;\n  char scratch_[kFastToBufferSize];\n};\n\n}  // namespace internal\n\nLIBPROTOBUF_EXPORT string Substitute(\n  const char* format,\n  const internal::SubstituteArg& arg0 = internal::SubstituteArg(),\n  const internal::SubstituteArg& arg1 = internal::SubstituteArg(),\n  const internal::SubstituteArg& arg2 = internal::SubstituteArg(),\n  const internal::SubstituteArg& arg3 = internal::SubstituteArg(),\n  const internal::SubstituteArg& arg4 = internal::SubstituteArg(),\n  const internal::SubstituteArg& arg5 = internal::SubstituteArg(),\n  const internal::SubstituteArg& arg6 = internal::SubstituteArg(),\n  const internal::SubstituteArg& arg7 = internal::SubstituteArg(),\n  const internal::SubstituteArg& arg8 = internal::SubstituteArg(),\n  const internal::SubstituteArg& arg9 = internal::SubstituteArg());\n\nLIBPROTOBUF_EXPORT void SubstituteAndAppend(\n  string* output, const char* format,\n  const internal::SubstituteArg& arg0 = internal::SubstituteArg(),\n  const internal::SubstituteArg& arg1 = internal::SubstituteArg(),\n  const internal::SubstituteArg& arg2 = internal::SubstituteArg(),\n  const internal::SubstituteArg& arg3 = internal::SubstituteArg(),\n  const internal::SubstituteArg& arg4 = internal::SubstituteArg(),\n  const internal::SubstituteArg& arg5 = internal::SubstituteArg(),\n  const internal::SubstituteArg& arg6 = internal::SubstituteArg(),\n  const internal::SubstituteArg& arg7 = internal::SubstituteArg(),\n  const internal::SubstituteArg& arg8 = internal::SubstituteArg(),\n  const internal::SubstituteArg& arg9 = internal::SubstituteArg());\n\n}  // namespace strings\n}  // namespace protobuf\n}  // namespace google\n\n#endif // GOOGLE_PROTOBUF_STUBS_SUBSTITUTE_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/template_util.h",
    "content": "// Copyright 2005 Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// ----\n// Author: lar@google.com (Laramie Leavitt)\n//\n// Template metaprogramming utility functions.\n//\n// This code is compiled directly on many platforms, including client\n// platforms like Windows, Mac, and embedded systems.  Before making\n// any changes here, make sure that you're not breaking any platforms.\n//\n//\n// The names chosen here reflect those used in tr1 and the boost::mpl\n// library, there are similar operations used in the Loki library as\n// well.  I prefer the boost names for 2 reasons:\n// 1.  I think that portions of the Boost libraries are more likely to\n// be included in the c++ standard.\n// 2.  It is not impossible that some of the boost libraries will be\n// included in our own build in the future.\n// Both of these outcomes means that we may be able to directly replace\n// some of these with boost equivalents.\n//\n#ifndef GOOGLE_PROTOBUF_TEMPLATE_UTIL_H_\n#define GOOGLE_PROTOBUF_TEMPLATE_UTIL_H_\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\n// Types small_ and big_ are guaranteed such that sizeof(small_) <\n// sizeof(big_)\ntypedef char small_;\n\nstruct big_ {\n  char dummy[2];\n};\n\n// Identity metafunction.\ntemplate <class T>\nstruct identity_ {\n  typedef T type;\n};\n\n// integral_constant, defined in tr1, is a wrapper for an integer\n// value. We don't really need this generality; we could get away\n// with hardcoding the integer type to bool. We use the fully\n// general integer_constant for compatibility with tr1.\n\ntemplate<class T, T v>\nstruct integral_constant {\n  static const T value = v;\n  typedef T value_type;\n  typedef integral_constant<T, v> type;\n};\n\ntemplate <class T, T v> const T integral_constant<T, v>::value;\n\n\n// Abbreviations: true_type and false_type are structs that represent boolean\n// true and false values. Also define the boost::mpl versions of those names,\n// true_ and false_.\ntypedef integral_constant<bool, true>  true_type;\ntypedef integral_constant<bool, false> false_type;\ntypedef true_type  true_;\ntypedef false_type false_;\n\n// if_ is a templatized conditional statement.\n// if_<cond, A, B> is a compile time evaluation of cond.\n// if_<>::type contains A if cond is true, B otherwise.\ntemplate<bool cond, typename A, typename B>\nstruct if_{\n  typedef A type;\n};\n\ntemplate<typename A, typename B>\nstruct if_<false, A, B> {\n  typedef B type;\n};\n\n\n// type_equals_ is a template type comparator, similar to Loki IsSameType.\n// type_equals_<A, B>::value is true iff \"A\" is the same type as \"B\".\n//\n// New code should prefer base::is_same, defined in base/type_traits.h.\n// It is functionally identical, but is_same is the standard spelling.\ntemplate<typename A, typename B>\nstruct type_equals_ : public false_ {\n};\n\ntemplate<typename A>\nstruct type_equals_<A, A> : public true_ {\n};\n\n// and_ is a template && operator.\n// and_<A, B>::value evaluates \"A::value && B::value\".\ntemplate<typename A, typename B>\nstruct and_ : public integral_constant<bool, (A::value && B::value)> {\n};\n\n// or_ is a template || operator.\n// or_<A, B>::value evaluates \"A::value || B::value\".\ntemplate<typename A, typename B>\nstruct or_ : public integral_constant<bool, (A::value || B::value)> {\n};\n\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_TEMPLATE_UTIL_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/template_util_unittest.cc",
    "content": "// Copyright 2005 Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// ----\n// Author: lar@google.com (Laramie Leavitt)\n//\n// These tests are really compile time tests.\n// If you try to step through this in a debugger\n// you will not see any evaluations, merely that\n// value is assigned true or false sequentially.\n\n#include <google/protobuf/stubs/template_util.h>\n\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace GOOGLE_NAMESPACE = google::protobuf::internal;\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\nnamespace {\n\nTEST(TemplateUtilTest, TestSize) {\n  EXPECT_GT(sizeof(GOOGLE_NAMESPACE::big_), sizeof(GOOGLE_NAMESPACE::small_));\n}\n\nTEST(TemplateUtilTest, TestIntegralConstants) {\n  // test the built-in types.\n  EXPECT_TRUE(true_type::value);\n  EXPECT_FALSE(false_type::value);\n\n  typedef integral_constant<int, 1> one_type;\n  EXPECT_EQ(1, one_type::value);\n}\n\nTEST(TemplateUtilTest, TestTemplateIf) {\n  typedef if_<true, true_type, false_type>::type if_true;\n  EXPECT_TRUE(if_true::value);\n\n  typedef if_<false, true_type, false_type>::type if_false;\n  EXPECT_FALSE(if_false::value);\n}\n\nTEST(TemplateUtilTest, TestTemplateTypeEquals) {\n  // Check that the TemplateTypeEquals works correctly.\n  bool value = false;\n\n  // Test the same type is true.\n  value = type_equals_<int, int>::value;\n  EXPECT_TRUE(value);\n\n  // Test different types are false.\n  value = type_equals_<float, int>::value;\n  EXPECT_FALSE(value);\n\n  // Test type aliasing.\n  typedef const int foo;\n  value = type_equals_<const foo, const int>::value;\n  EXPECT_TRUE(value);\n}\n\nTEST(TemplateUtilTest, TestTemplateAndOr) {\n  // Check that the TemplateTypeEquals works correctly.\n  bool value = false;\n\n  // Yes && Yes == true.\n  value = and_<true_, true_>::value;\n  EXPECT_TRUE(value);\n  // Yes && No == false.\n  value = and_<true_, false_>::value;\n  EXPECT_FALSE(value);\n  // No && Yes == false.\n  value = and_<false_, true_>::value;\n  EXPECT_FALSE(value);\n  // No && No == false.\n  value = and_<false_, false_>::value;\n  EXPECT_FALSE(value);\n\n  // Yes || Yes == true.\n  value = or_<true_, true_>::value;\n  EXPECT_TRUE(value);\n  // Yes || No == true.\n  value = or_<true_, false_>::value;\n  EXPECT_TRUE(value);\n  // No || Yes == true.\n  value = or_<false_, true_>::value;\n  EXPECT_TRUE(value);\n  // No || No == false.\n  value = or_<false_, false_>::value;\n  EXPECT_FALSE(value);\n}\n\nTEST(TemplateUtilTest, TestIdentity) {\n  EXPECT_TRUE(\n      (type_equals_<GOOGLE_NAMESPACE::identity_<int>::type, int>::value));\n  EXPECT_TRUE(\n      (type_equals_<GOOGLE_NAMESPACE::identity_<void>::type, void>::value));\n}\n\n}  // anonymous namespace\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/time.cc",
    "content": "#include <google/protobuf/stubs/time.h>\n\n#include <ctime>\n\n#include <google/protobuf/stubs/stringprintf.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\nnamespace {\nstatic const int64 kSecondsPerMinute = 60;\nstatic const int64 kSecondsPerHour = 3600;\nstatic const int64 kSecondsPerDay = kSecondsPerHour * 24;\nstatic const int64 kSecondsPer400Years =\n    kSecondsPerDay * (400 * 365 + 400 / 4 - 3);\n// Seconds from 0001-01-01T00:00:00 to 1970-01-01T:00:00:00\nstatic const int64 kSecondsFromEraToEpoch = 62135596800LL;\n// The range of timestamp values we support.\nstatic const int64 kMinTime = -62135596800LL;  // 0001-01-01T00:00:00\nstatic const int64 kMaxTime = 253402300799LL;  // 9999-12-31T23:59:59\n\nstatic const int kNanosPerMillisecond = 1000000;\nstatic const int kNanosPerMicrosecond = 1000;\n\n// Count the seconds from the given year (start at Jan 1, 00:00) to 100 years\n// after.\nint64 SecondsPer100Years(int year) {\n  if (year % 400 == 0 || year % 400 > 300) {\n    return kSecondsPerDay * (100 * 365 + 100 / 4);\n  } else {\n    return kSecondsPerDay * (100 * 365 + 100 / 4 - 1);\n  }\n}\n\n// Count the seconds from the given year (start at Jan 1, 00:00) to 4 years\n// after.\nint64 SecondsPer4Years(int year) {\n  if ((year % 100 == 0 || year % 100 > 96) &&\n      !(year % 400 == 0 || year % 400 > 396)) {\n    // No leap years.\n    return kSecondsPerDay * (4 * 365);\n  } else {\n    // One leap years.\n    return kSecondsPerDay * (4 * 365 + 1);\n  }\n}\n\nbool IsLeapYear(int year) {\n  return year % 400 == 0 || (year % 4 == 0 && year % 100 != 0);\n}\n\nint64 SecondsPerYear(int year) {\n  return kSecondsPerDay * (IsLeapYear(year) ? 366 : 365);\n}\n\nstatic const int kDaysInMonth[13] = {\n  0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31\n};\n\nint64 SecondsPerMonth(int month, bool leap) {\n  if (month == 2 && leap) {\n    return kSecondsPerDay * (kDaysInMonth[month] + 1);\n  }\n  return kSecondsPerDay * kDaysInMonth[month];\n}\n\nstatic const int kDaysSinceJan[13] = {\n  0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334,\n};\n\nbool ValidateDateTime(const DateTime& time) {\n  if (time.year < 1 || time.year > 9999 ||\n      time.month < 1 || time.month > 12 ||\n      time.day < 1 || time.day > 31 ||\n      time.hour < 0 || time.hour > 23 ||\n      time.minute < 0 || time.minute > 59 ||\n      time.second < 0 || time.second > 59) {\n    return false;\n  }\n  if (time.month == 2 && IsLeapYear(time.year)) {\n    return time.month <= kDaysInMonth[time.month] + 1;\n  } else {\n    return time.month <= kDaysInMonth[time.month];\n  }\n}\n\n// Count the number of seconds elapsed from 0001-01-01T00:00:00 to the given\n// time.\nint64 SecondsSinceCommonEra(const DateTime& time) {\n  int64 result = 0;\n  // Years should be between 1 and 9999.\n  assert(time.year >= 1 && time.year <= 9999);\n  int year = 1;\n  if ((time.year - year) >= 400) {\n    int count_400years = (time.year - year) / 400;\n    result += kSecondsPer400Years * count_400years;\n    year += count_400years * 400;\n  }\n  while ((time.year - year) >= 100) {\n    result += SecondsPer100Years(year);\n    year += 100;\n  }\n  while ((time.year - year) >= 4) {\n    result += SecondsPer4Years(year);\n    year += 4;\n  }\n  while (time.year > year) {\n    result += SecondsPerYear(year);\n    ++year;\n  }\n  // Months should be between 1 and 12.\n  assert(time.month >= 1 && time.month <= 12);\n  int month = time.month;\n  result += kSecondsPerDay * kDaysSinceJan[month];\n  if (month > 2 && IsLeapYear(year)) {\n    result += kSecondsPerDay;\n  }\n  assert(time.day >= 1 &&\n         time.day <= (month == 2 && IsLeapYear(year)\n                          ? kDaysInMonth[month] + 1\n                          : kDaysInMonth[month]));\n  result += kSecondsPerDay * (time.day - 1);\n  result += kSecondsPerHour * time.hour +\n      kSecondsPerMinute * time.minute +\n      time.second;\n  return result;\n}\n\n// Format nanoseconds with either 3, 6, or 9 digits depending on the required\n// precision to represent the exact value.\nstring FormatNanos(int32 nanos) {\n  if (nanos % kNanosPerMillisecond == 0) {\n    return StringPrintf(\"%03d\", nanos / kNanosPerMillisecond);\n  } else if (nanos % kNanosPerMicrosecond == 0) {\n    return StringPrintf(\"%06d\", nanos / kNanosPerMicrosecond);\n  } else {\n    return StringPrintf(\"%09d\", nanos);\n  }\n}\n\n// Parses an integer from a null-terminated char sequence. The method\n// consumes at most \"width\" chars. Returns a pointer after the consumed\n// integer, or NULL if the data does not start with an integer or the\n// integer value does not fall in the range of [min_value, max_value].\nconst char* ParseInt(const char* data, int width, int min_value,\n                     int max_value, int* result) {\n  if (!ascii_isdigit(*data)) {\n    return NULL;\n  }\n  int value = 0;\n  for (int i = 0; i < width; ++i, ++data) {\n    if (ascii_isdigit(*data)) {\n      value = value * 10 + (*data - '0');\n    } else {\n      break;\n    }\n  }\n  if (value >= min_value && value <= max_value) {\n    *result = value;\n    return data;\n  } else {\n    return NULL;\n  }\n}\n\n// Consumes the fractional parts of a second into nanos. For example,\n// \"010\" will be parsed to 10000000 nanos.\nconst char* ParseNanos(const char* data, int32* nanos) {\n  if (!ascii_isdigit(*data)) {\n    return NULL;\n  }\n  int value = 0;\n  int len = 0;\n  // Consume as many digits as there are but only take the first 9 into\n  // account.\n  while (ascii_isdigit(*data)) {\n    if (len < 9) {\n      value = value * 10 + *data - '0';\n    }\n    ++len;\n    ++data;\n  }\n  while (len < 9) {\n    value = value * 10;\n    ++len;\n  }\n  *nanos = value;\n  return data;\n}\n\nconst char* ParseTimezoneOffset(const char* data, int64* offset) {\n  // Accept format \"HH:MM\". E.g., \"08:00\"\n  int hour;\n  if ((data = ParseInt(data, 2, 0, 23, &hour)) == NULL) {\n    return NULL;\n  }\n  if (*data++ != ':') {\n    return NULL;\n  }\n  int minute;\n  if ((data = ParseInt(data, 2, 0, 59, &minute)) == NULL) {\n    return NULL;\n  }\n  *offset = (hour * 60 + minute) * 60;\n  return data;\n}\n}  // namespace\n\nbool SecondsToDateTime(int64 seconds, DateTime* time) {\n  if (seconds < kMinTime || seconds > kMaxTime) {\n    return false;\n  }\n  // It's easier to calcuate the DateTime starting from 0001-01-01T00:00:00\n  seconds = seconds + kSecondsFromEraToEpoch;\n  int year = 1;\n  if (seconds >= kSecondsPer400Years) {\n    int count_400years = seconds / kSecondsPer400Years;\n    year += 400 * count_400years;\n    seconds %= kSecondsPer400Years;\n  }\n  while (seconds >= SecondsPer100Years(year)) {\n    seconds -= SecondsPer100Years(year);\n    year += 100;\n  }\n  while (seconds >= SecondsPer4Years(year)) {\n    seconds -= SecondsPer4Years(year);\n    year += 4;\n  }\n  while (seconds >= SecondsPerYear(year)) {\n    seconds -= SecondsPerYear(year);\n    year += 1;\n  }\n  bool leap = IsLeapYear(year);\n  int month = 1;\n  while (seconds >= SecondsPerMonth(month, leap)) {\n    seconds -= SecondsPerMonth(month, leap);\n    ++month;\n  }\n  int day = 1 + seconds / kSecondsPerDay;\n  seconds %= kSecondsPerDay;\n  int hour = seconds / kSecondsPerHour;\n  seconds %= kSecondsPerHour;\n  int minute = seconds / kSecondsPerMinute;\n  seconds %= kSecondsPerMinute;\n  time->year = year;\n  time->month = month;\n  time->day = day;\n  time->hour = hour;\n  time->minute = minute;\n  time->second = static_cast<int>(seconds);\n  return true;\n}\n\nbool DateTimeToSeconds(const DateTime& time, int64* seconds) {\n  if (!ValidateDateTime(time)) {\n    return false;\n  }\n  *seconds = SecondsSinceCommonEra(time) - kSecondsFromEraToEpoch;\n  return true;\n}\n\nvoid GetCurrentTime(int64* seconds, int32* nanos) {\n  // TODO(xiaofeng): Improve the accuracy of this implementation (or just\n  // remove this method from protobuf).\n  *seconds = time(NULL);\n  *nanos = 0;\n}\n\nstring FormatTime(int64 seconds, int32 nanos) {\n  DateTime time;\n  if (nanos < 0 || nanos > 999999999 || !SecondsToDateTime(seconds, &time)) {\n    return \"InvalidTime\";\n  }\n  string result = StringPrintf(\"%04d-%02d-%02dT%02d:%02d:%02d\",\n                               time.year, time.month, time.day,\n                               time.hour, time.minute, time.second);\n  if (nanos != 0) {\n    result += \".\" + FormatNanos(nanos);\n  }\n  return result + \"Z\";\n}\n\nbool ParseTime(const string& value, int64* seconds, int32* nanos) {\n  DateTime time;\n  const char* data = value.c_str();\n  // We only accept:\n  //   Z-normalized: 2015-05-20T13:29:35.120Z\n  //   With UTC offset: 2015-05-20T13:29:35.120-08:00\n\n  // Parse year\n  if ((data = ParseInt(data, 4, 1, 9999, &time.year)) == NULL) {\n    return false;\n  }\n  // Expect '-'\n  if (*data++ != '-') return false;\n  // Parse month\n  if ((data = ParseInt(data, 2, 1, 12, &time.month)) == NULL) {\n    return false;\n  }\n  // Expect '-'\n  if (*data++ != '-') return false;\n  // Parse day\n  if ((data = ParseInt(data, 2, 1, 31, &time.day)) == NULL) {\n    return false;\n  }\n  // Expect 'T'\n  if (*data++ != 'T') return false;\n  // Parse hour\n  if ((data = ParseInt(data, 2, 0, 23, &time.hour)) == NULL) {\n    return false;\n  }\n  // Expect ':'\n  if (*data++ != ':') return false;\n  // Parse minute\n  if ((data = ParseInt(data, 2, 0, 59, &time.minute)) == NULL) {\n    return false;\n  }\n  // Expect ':'\n  if (*data++ != ':') return false;\n  // Parse second\n  if ((data = ParseInt(data, 2, 0, 59, &time.second)) == NULL) {\n    return false;\n  }\n  if (!DateTimeToSeconds(time, seconds)) {\n    return false;\n  }\n  // Parse nanoseconds.\n  if (*data == '.') {\n    ++data;\n    // Parse nanoseconds.\n    if ((data = ParseNanos(data, nanos)) == NULL) {\n      return false;\n    }\n  } else {\n    *nanos = 0;\n  }\n  // Parse UTC offsets.\n  if (*data == 'Z') {\n    ++data;\n  } else if (*data == '+') {\n    ++data;\n    int64 offset;\n    if ((data = ParseTimezoneOffset(data, &offset)) == NULL) {\n      return false;\n    }\n    *seconds -= offset;\n  } else if (*data == '-') {\n    ++data;\n    int64 offset;\n    if ((data = ParseTimezoneOffset(data, &offset)) == NULL) {\n      return false;\n    }\n    *seconds += offset;\n  } else {\n    return false;\n  }\n  // Done with parsing.\n  return *data == 0;\n}\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/time.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n#ifndef GOOGLE_PROTOBUF_STUBS_TIME_H_\n#define GOOGLE_PROTOBUF_STUBS_TIME_H_\n\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\nstruct DateTime {\n  int year;\n  int month;\n  int day;\n  int hour;\n  int minute;\n  int second;\n};\n\n// Converts a timestamp (seconds elapsed since 1970-01-01T00:00:00, could be\n// negative to represent time before 1970-01-01) to DateTime. Returns false\n// if the timestamp is not in the range between 0001-01-01T00:00:00 and\n// 9999-12-31T23:59:59.\nbool LIBPROTOBUF_EXPORT SecondsToDateTime(int64 seconds, DateTime* time);\n// Converts DateTime to a timestamp (seconds since 1970-01-01T00:00:00).\n// Returns false if the DateTime is not valid or is not in the valid range.\nbool LIBPROTOBUF_EXPORT DateTimeToSeconds(const DateTime& time, int64* seconds);\n\nvoid LIBPROTOBUF_EXPORT GetCurrentTime(int64* seconds, int32* nanos);\n\n// Formats a time string in RFC3339 fromat.\n//\n// For example, \"2015-05-20T13:29:35.120Z\". For nanos, 0, 3, 6 or 9 fractional\n// digits will be used depending on how many are required to represent the exact\n// value.\n//\n// Note that \"nanos\" must in the range of [0, 999999999].\nstring LIBPROTOBUF_EXPORT FormatTime(int64 seconds, int32 nanos);\n// Parses a time string. This method accepts RFC3339 date/time string with UTC\n// offset. For example, \"2015-05-20T13:29:35.120-08:00\".\nbool LIBPROTOBUF_EXPORT ParseTime(const string& value, int64* seconds, int32* nanos);\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_STUBS_TIME_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/time_test.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n#include <google/protobuf/stubs/time.h>\n\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\nnamespace {\nstatic const int64 kSecondsPerDay = 3600 * 24;\n\n// For DateTime, tests will mostly focuse on the date part because that's\n// the tricky one.\nint64 CreateTimestamp(int year, int month, int day) {\n  DateTime time;\n  time.year = year;\n  time.month = month;\n  time.day = day;\n  time.hour = time.minute = time.second = 0;\n  int64 result;\n  GOOGLE_CHECK(DateTimeToSeconds(time, &result));\n  // Check that a roundtrip produces the same result.\n  GOOGLE_CHECK(SecondsToDateTime(result, &time));\n  GOOGLE_CHECK(time.year == year);\n  GOOGLE_CHECK(time.month == month);\n  GOOGLE_CHECK(time.day == day);\n  return result;\n}\n\nTEST(DateTimeTest, SimpleTime) {\n  DateTime time;\n  ASSERT_TRUE(SecondsToDateTime(1, &time));\n  EXPECT_EQ(1970, time.year);\n  EXPECT_EQ(1, time.month);\n  EXPECT_EQ(1, time.day);\n  EXPECT_EQ(0, time.hour);\n  EXPECT_EQ(0, time.minute);\n  EXPECT_EQ(1, time.second);\n  int64 seconds;\n  ASSERT_TRUE(DateTimeToSeconds(time, &seconds));\n  EXPECT_EQ(1, seconds);\n\n  ASSERT_TRUE(SecondsToDateTime(-1, &time));\n  EXPECT_EQ(1969, time.year);\n  EXPECT_EQ(12, time.month);\n  EXPECT_EQ(31, time.day);\n  EXPECT_EQ(23, time.hour);\n  EXPECT_EQ(59, time.minute);\n  EXPECT_EQ(59, time.second);\n  ASSERT_TRUE(DateTimeToSeconds(time, &seconds));\n  EXPECT_EQ(-1, seconds);\n\n  DateTime start, end;\n  start.year = 1;\n  start.month = 1;\n  start.day = 1;\n  start.hour = 0;\n  start.minute = 0;\n  start.second = 0;\n  end.year = 9999;\n  end.month = 12;\n  end.day = 31;\n  end.hour = 23;\n  end.minute = 59;\n  end.second = 59;\n  int64 start_time, end_time;\n  ASSERT_TRUE(DateTimeToSeconds(start, &start_time));\n  ASSERT_TRUE(DateTimeToSeconds(end, &end_time));\n  EXPECT_EQ(315537897599LL, end_time - start_time);\n  ASSERT_TRUE(SecondsToDateTime(start_time, &time));\n  ASSERT_TRUE(DateTimeToSeconds(time, &seconds));\n  EXPECT_EQ(start_time, seconds);\n  ASSERT_TRUE(SecondsToDateTime(end_time, &time));\n  ASSERT_TRUE(DateTimeToSeconds(time, &seconds));\n  EXPECT_EQ(end_time, seconds);\n}\n\nTEST(DateTimeTest, DayInMonths) {\n  // Check that month boundaries are handled correctly.\n  EXPECT_EQ(kSecondsPerDay,\n            CreateTimestamp(2015, 1, 1) - CreateTimestamp(2014, 12, 31));\n  EXPECT_EQ(kSecondsPerDay,\n            CreateTimestamp(2015, 2, 1) - CreateTimestamp(2015, 1, 31));\n  EXPECT_EQ(kSecondsPerDay,\n            CreateTimestamp(2015, 3, 1) - CreateTimestamp(2015, 2, 28));\n  EXPECT_EQ(kSecondsPerDay,\n            CreateTimestamp(2015, 4, 1) - CreateTimestamp(2015, 3, 31));\n  EXPECT_EQ(kSecondsPerDay,\n            CreateTimestamp(2015, 5, 1) - CreateTimestamp(2015, 4, 30));\n  EXPECT_EQ(kSecondsPerDay,\n            CreateTimestamp(2015, 6, 1) - CreateTimestamp(2015, 5, 31));\n  EXPECT_EQ(kSecondsPerDay,\n            CreateTimestamp(2015, 7, 1) - CreateTimestamp(2015, 6, 30));\n  EXPECT_EQ(kSecondsPerDay,\n            CreateTimestamp(2015, 8, 1) - CreateTimestamp(2015, 7, 31));\n  EXPECT_EQ(kSecondsPerDay,\n            CreateTimestamp(2015, 9, 1) - CreateTimestamp(2015, 8, 31));\n  EXPECT_EQ(kSecondsPerDay,\n            CreateTimestamp(2015, 10, 1) - CreateTimestamp(2015, 9, 30));\n  EXPECT_EQ(kSecondsPerDay,\n            CreateTimestamp(2015, 11, 1) - CreateTimestamp(2015, 10, 31));\n  EXPECT_EQ(kSecondsPerDay,\n            CreateTimestamp(2015, 12, 1) - CreateTimestamp(2015, 11, 30));\n  EXPECT_EQ(kSecondsPerDay,\n            CreateTimestamp(2016, 1, 1) - CreateTimestamp(2015, 12, 31));\n}\n\nTEST(DateTimeTest, LeapYear) {\n  // Non-leap year.\n  EXPECT_EQ(kSecondsPerDay,\n            CreateTimestamp(2015, 3, 1) - CreateTimestamp(2015, 2, 28));\n  // Leap year.\n  EXPECT_EQ(kSecondsPerDay,\n            CreateTimestamp(2016, 3, 1) - CreateTimestamp(2016, 2, 29));\n  // Non-leap year.\n  EXPECT_EQ(kSecondsPerDay,\n            CreateTimestamp(2100, 3, 1) - CreateTimestamp(2100, 2, 28));\n  // Leap year.\n  EXPECT_EQ(kSecondsPerDay,\n            CreateTimestamp(2400, 3, 1) - CreateTimestamp(2400, 2, 29));\n}\n\nTEST(DateTimeTest, StringFormat) {\n  DateTime start, end;\n  start.year = 1;\n  start.month = 1;\n  start.day = 1;\n  start.hour = 0;\n  start.minute = 0;\n  start.second = 0;\n  end.year = 9999;\n  end.month = 12;\n  end.day = 31;\n  end.hour = 23;\n  end.minute = 59;\n  end.second = 59;\n  int64 start_time, end_time;\n  ASSERT_TRUE(DateTimeToSeconds(start, &start_time));\n  ASSERT_TRUE(DateTimeToSeconds(end, &end_time));\n\n  EXPECT_EQ(\"0001-01-01T00:00:00Z\", FormatTime(start_time, 0));\n  EXPECT_EQ(\"9999-12-31T23:59:59Z\", FormatTime(end_time, 0));\n\n  // Make sure the nanoseconds part is formated correctly.\n  EXPECT_EQ(\"1970-01-01T00:00:00.010Z\", FormatTime(0, 10000000));\n  EXPECT_EQ(\"1970-01-01T00:00:00.000010Z\", FormatTime(0, 10000));\n  EXPECT_EQ(\"1970-01-01T00:00:00.000000010Z\", FormatTime(0, 10));\n}\n\nTEST(DateTimeTest, ParseString) {\n  int64 seconds;\n  int32 nanos;\n  ASSERT_TRUE(ParseTime(\"0001-01-01T00:00:00Z\", &seconds, &nanos));\n  EXPECT_EQ(\"0001-01-01T00:00:00Z\", FormatTime(seconds, nanos));\n  ASSERT_TRUE(ParseTime(\"9999-12-31T23:59:59.999999999Z\", &seconds, &nanos));\n  EXPECT_EQ(\"9999-12-31T23:59:59.999999999Z\", FormatTime(seconds, nanos));\n\n  // Test time zone offsets.\n  ASSERT_TRUE(ParseTime(\"1970-01-01T00:00:00-08:00\", &seconds, &nanos));\n  EXPECT_EQ(\"1970-01-01T08:00:00Z\", FormatTime(seconds, nanos));\n  ASSERT_TRUE(ParseTime(\"1970-01-01T00:00:00+08:00\", &seconds, &nanos));\n  EXPECT_EQ(\"1969-12-31T16:00:00Z\", FormatTime(seconds, nanos));\n\n  // Test nanoseconds.\n  ASSERT_TRUE(ParseTime(\"1970-01-01T00:00:00.01Z\", &seconds, &nanos));\n  EXPECT_EQ(\"1970-01-01T00:00:00.010Z\", FormatTime(seconds, nanos));\n  ASSERT_TRUE(ParseTime(\"1970-01-01T00:00:00.00001-08:00\", &seconds, &nanos));\n  EXPECT_EQ(\"1970-01-01T08:00:00.000010Z\", FormatTime(seconds, nanos));\n  ASSERT_TRUE(ParseTime(\"1970-01-01T00:00:00.00000001+08:00\", &seconds, &nanos));\n  EXPECT_EQ(\"1969-12-31T16:00:00.000000010Z\", FormatTime(seconds, nanos));\n  // Fractional parts less than 1 nanosecond will be ignored.\n  ASSERT_TRUE(ParseTime(\"1970-01-01T00:00:00.0123456789Z\", &seconds, &nanos));\n  EXPECT_EQ(\"1970-01-01T00:00:00.012345678Z\", FormatTime(seconds, nanos));\n}\n\n}  // namespace\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/type_traits.h",
    "content": "// Copyright (c) 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// ----\n// Author: Matt Austern\n//\n// This code is compiled directly on many platforms, including client\n// platforms like Windows, Mac, and embedded systems.  Before making\n// any changes here, make sure that you're not breaking any platforms.\n//\n// Define a small subset of tr1 type traits. The traits we define are:\n//   enable_if\n//   is_integral\n//   is_floating_point\n//   is_pointer\n//   is_enum\n//   is_reference\n//   is_pod\n//   has_trivial_constructor\n//   has_trivial_copy\n//   has_trivial_assign\n//   has_trivial_destructor\n//   remove_const\n//   remove_volatile\n//   remove_cv\n//   remove_reference\n//   add_reference\n//   remove_pointer\n//   is_same\n//   is_convertible\n// We can add more type traits as required.\n\n#ifndef GOOGLE_PROTOBUF_TYPE_TRAITS_H_\n#define GOOGLE_PROTOBUF_TYPE_TRAITS_H_\n\n#include <cstddef>                  // for NULL\n#include <utility>                  // For pair\n\n#include <google/protobuf/stubs/template_util.h>  // For true_type and false_type\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\ntemplate<typename B, typename D>\nstruct is_base_of {\n  typedef char (&yes)[1];\n  typedef char (&no)[2];\n\n  // BEGIN GOOGLE LOCAL MODIFICATION -- check is a #define on Mac.\n  #undef check\n  // END GOOGLE LOCAL MODIFICATION\n\n  static yes check(const B*);\n  static no check(const void*);\n\n  enum {\n    value = sizeof(check(static_cast<const D*>(NULL))) == sizeof(yes),\n  };\n};\n\ntemplate <bool cond, class T = void> struct enable_if;\ntemplate <class T> struct is_integral;\ntemplate <class T> struct is_floating_point;\ntemplate <class T> struct is_pointer;\n// MSVC can't compile this correctly, and neither can gcc 3.3.5 (at least)\n#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)\n// is_enum uses is_convertible, which is not available on MSVC.\ntemplate <class T> struct is_enum;\n#endif\ntemplate <class T> struct is_reference;\ntemplate <class T> struct is_pod;\ntemplate <class T> struct has_trivial_constructor;\ntemplate <class T> struct has_trivial_copy;\ntemplate <class T> struct has_trivial_assign;\ntemplate <class T> struct has_trivial_destructor;\ntemplate <class T> struct remove_const;\ntemplate <class T> struct remove_volatile;\ntemplate <class T> struct remove_cv;\ntemplate <class T> struct remove_reference;\ntemplate <class T> struct add_reference;\ntemplate <class T> struct remove_pointer;\ntemplate <class T, class U> struct is_same;\n#if !(defined(__GNUC__) && __GNUC__ <= 3)\ntemplate <class From, class To> struct is_convertible;\n#endif\n\n// enable_if, equivalent semantics to c++11 std::enable_if, specifically:\n//   \"If B is true, the member typedef type shall equal T; otherwise, there\n//    shall be no member typedef type.\"\n// Specified by 20.9.7.6 [Other transformations]\n\ntemplate<bool cond, class T> struct enable_if { typedef T type; };\ntemplate<class T> struct enable_if<false, T> {};\n// is_integral is false except for the built-in integer types. A\n// cv-qualified type is integral if and only if the underlying type is.\ntemplate <class T> struct is_integral : false_type { };\ntemplate<> struct is_integral<bool> : true_type { };\ntemplate<> struct is_integral<char> : true_type { };\ntemplate<> struct is_integral<unsigned char> : true_type { };\ntemplate<> struct is_integral<signed char> : true_type { };\n#if defined(_MSC_VER)\n// wchar_t is not by default a distinct type from unsigned short in\n// Microsoft C.\n// See http://msdn2.microsoft.com/en-us/library/dh8che7s(VS.80).aspx\ntemplate<> struct is_integral<__wchar_t> : true_type { };\n#else\ntemplate<> struct is_integral<wchar_t> : true_type { };\n#endif\ntemplate<> struct is_integral<short> : true_type { };\ntemplate<> struct is_integral<unsigned short> : true_type { };\ntemplate<> struct is_integral<int> : true_type { };\ntemplate<> struct is_integral<unsigned int> : true_type { };\ntemplate<> struct is_integral<long> : true_type { };\ntemplate<> struct is_integral<unsigned long> : true_type { };\n#ifdef HAVE_LONG_LONG\ntemplate<> struct is_integral<long long> : true_type { };\ntemplate<> struct is_integral<unsigned long long> : true_type { };\n#endif\ntemplate <class T> struct is_integral<const T> : is_integral<T> { };\ntemplate <class T> struct is_integral<volatile T> : is_integral<T> { };\ntemplate <class T> struct is_integral<const volatile T> : is_integral<T> { };\n\n// is_floating_point is false except for the built-in floating-point types.\n// A cv-qualified type is integral if and only if the underlying type is.\ntemplate <class T> struct is_floating_point : false_type { };\ntemplate<> struct is_floating_point<float> : true_type { };\ntemplate<> struct is_floating_point<double> : true_type { };\ntemplate<> struct is_floating_point<long double> : true_type { };\ntemplate <class T> struct is_floating_point<const T>\n    : is_floating_point<T> { };\ntemplate <class T> struct is_floating_point<volatile T>\n    : is_floating_point<T> { };\ntemplate <class T> struct is_floating_point<const volatile T>\n    : is_floating_point<T> { };\n\n// is_pointer is false except for pointer types. A cv-qualified type (e.g.\n// \"int* const\", as opposed to \"int const*\") is cv-qualified if and only if\n// the underlying type is.\ntemplate <class T> struct is_pointer : false_type { };\ntemplate <class T> struct is_pointer<T*> : true_type { };\ntemplate <class T> struct is_pointer<const T> : is_pointer<T> { };\ntemplate <class T> struct is_pointer<volatile T> : is_pointer<T> { };\ntemplate <class T> struct is_pointer<const volatile T> : is_pointer<T> { };\n\n#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)\n\nnamespace type_traits_internal {\n\ntemplate <class T> struct is_class_or_union {\n  template <class U> static small_ tester(void (U::*)());\n  template <class U> static big_ tester(...);\n  static const bool value = sizeof(tester<T>(0)) == sizeof(small_);\n};\n\n// is_convertible chokes if the first argument is an array. That's why\n// we use add_reference here.\ntemplate <bool NotUnum, class T> struct is_enum_impl\n    : is_convertible<typename add_reference<T>::type, int> { };\n\ntemplate <class T> struct is_enum_impl<true, T> : false_type { };\n\n}  // namespace type_traits_internal\n\n// Specified by TR1 [4.5.1] primary type categories.\n\n// Implementation note:\n//\n// Each type is either void, integral, floating point, array, pointer,\n// reference, member object pointer, member function pointer, enum,\n// union or class. Out of these, only integral, floating point, reference,\n// class and enum types are potentially convertible to int. Therefore,\n// if a type is not a reference, integral, floating point or class and\n// is convertible to int, it's a enum. Adding cv-qualification to a type\n// does not change whether it's an enum.\n//\n// Is-convertible-to-int check is done only if all other checks pass,\n// because it can't be used with some types (e.g. void or classes with\n// inaccessible conversion operators).\ntemplate <class T> struct is_enum\n    : type_traits_internal::is_enum_impl<\n          is_same<T, void>::value ||\n              is_integral<T>::value ||\n              is_floating_point<T>::value ||\n              is_reference<T>::value ||\n              type_traits_internal::is_class_or_union<T>::value,\n          T> { };\n\ntemplate <class T> struct is_enum<const T> : is_enum<T> { };\ntemplate <class T> struct is_enum<volatile T> : is_enum<T> { };\ntemplate <class T> struct is_enum<const volatile T> : is_enum<T> { };\n\n#endif\n\n// is_reference is false except for reference types.\ntemplate<typename T> struct is_reference : false_type {};\ntemplate<typename T> struct is_reference<T&> : true_type {};\n\n\n// We can't get is_pod right without compiler help, so fail conservatively.\n// We will assume it's false except for arithmetic types, enumerations,\n// pointers and cv-qualified versions thereof. Note that std::pair<T,U>\n// is not a POD even if T and U are PODs.\ntemplate <class T> struct is_pod\n : integral_constant<bool, (is_integral<T>::value ||\n                            is_floating_point<T>::value ||\n#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)\n                            // is_enum is not available on MSVC.\n                            is_enum<T>::value ||\n#endif\n                            is_pointer<T>::value)> { };\ntemplate <class T> struct is_pod<const T> : is_pod<T> { };\ntemplate <class T> struct is_pod<volatile T> : is_pod<T> { };\ntemplate <class T> struct is_pod<const volatile T> : is_pod<T> { };\n\n\n// We can't get has_trivial_constructor right without compiler help, so\n// fail conservatively. We will assume it's false except for: (1) types\n// for which is_pod is true. (2) std::pair of types with trivial\n// constructors. (3) array of a type with a trivial constructor.\n// (4) const versions thereof.\ntemplate <class T> struct has_trivial_constructor : is_pod<T> { };\ntemplate <class T, class U> struct has_trivial_constructor<std::pair<T, U> >\n  : integral_constant<bool,\n                      (has_trivial_constructor<T>::value &&\n                       has_trivial_constructor<U>::value)> { };\ntemplate <class A, int N> struct has_trivial_constructor<A[N]>\n  : has_trivial_constructor<A> { };\ntemplate <class T> struct has_trivial_constructor<const T>\n  : has_trivial_constructor<T> { };\n\n// We can't get has_trivial_copy right without compiler help, so fail\n// conservatively. We will assume it's false except for: (1) types\n// for which is_pod is true. (2) std::pair of types with trivial copy\n// constructors. (3) array of a type with a trivial copy constructor.\n// (4) const versions thereof.\ntemplate <class T> struct has_trivial_copy : is_pod<T> { };\ntemplate <class T, class U> struct has_trivial_copy<std::pair<T, U> >\n  : integral_constant<bool,\n                      (has_trivial_copy<T>::value &&\n                       has_trivial_copy<U>::value)> { };\ntemplate <class A, int N> struct has_trivial_copy<A[N]>\n  : has_trivial_copy<A> { };\ntemplate <class T> struct has_trivial_copy<const T> : has_trivial_copy<T> { };\n\n// We can't get has_trivial_assign right without compiler help, so fail\n// conservatively. We will assume it's false except for: (1) types\n// for which is_pod is true. (2) std::pair of types with trivial copy\n// constructors. (3) array of a type with a trivial assign constructor.\ntemplate <class T> struct has_trivial_assign : is_pod<T> { };\ntemplate <class T, class U> struct has_trivial_assign<std::pair<T, U> >\n  : integral_constant<bool,\n                      (has_trivial_assign<T>::value &&\n                       has_trivial_assign<U>::value)> { };\ntemplate <class A, int N> struct has_trivial_assign<A[N]>\n  : has_trivial_assign<A> { };\n\n// We can't get has_trivial_destructor right without compiler help, so\n// fail conservatively. We will assume it's false except for: (1) types\n// for which is_pod is true. (2) std::pair of types with trivial\n// destructors. (3) array of a type with a trivial destructor.\n// (4) const versions thereof.\ntemplate <class T> struct has_trivial_destructor : is_pod<T> { };\ntemplate <class T, class U> struct has_trivial_destructor<std::pair<T, U> >\n  : integral_constant<bool,\n                      (has_trivial_destructor<T>::value &&\n                       has_trivial_destructor<U>::value)> { };\ntemplate <class A, int N> struct has_trivial_destructor<A[N]>\n  : has_trivial_destructor<A> { };\ntemplate <class T> struct has_trivial_destructor<const T>\n  : has_trivial_destructor<T> { };\n\n// Specified by TR1 [4.7.1]\ntemplate<typename T> struct remove_const { typedef T type; };\ntemplate<typename T> struct remove_const<T const> { typedef T type; };\ntemplate<typename T> struct remove_volatile { typedef T type; };\ntemplate<typename T> struct remove_volatile<T volatile> { typedef T type; };\ntemplate<typename T> struct remove_cv {\n  typedef typename remove_const<typename remove_volatile<T>::type>::type type;\n};\n\n\n// Specified by TR1 [4.7.2] Reference modifications.\ntemplate<typename T> struct remove_reference { typedef T type; };\ntemplate<typename T> struct remove_reference<T&> { typedef T type; };\n\ntemplate <typename T> struct add_reference { typedef T& type; };\ntemplate <typename T> struct add_reference<T&> { typedef T& type; };\n\n// Specified by TR1 [4.7.4] Pointer modifications.\ntemplate<typename T> struct remove_pointer { typedef T type; };\ntemplate<typename T> struct remove_pointer<T*> { typedef T type; };\ntemplate<typename T> struct remove_pointer<T* const> { typedef T type; };\ntemplate<typename T> struct remove_pointer<T* volatile> { typedef T type; };\ntemplate<typename T> struct remove_pointer<T* const volatile> {\n  typedef T type; };\n\n// Specified by TR1 [4.6] Relationships between types\ntemplate<typename T, typename U> struct is_same : public false_type { };\ntemplate<typename T> struct is_same<T, T> : public true_type { };\n\n// Specified by TR1 [4.6] Relationships between types\n#if !(defined(__GNUC__) && __GNUC__ <= 3)\nnamespace type_traits_internal {\n\n// This class is an implementation detail for is_convertible, and you\n// don't need to know how it works to use is_convertible. For those\n// who care: we declare two different functions, one whose argument is\n// of type To and one with a variadic argument list. We give them\n// return types of different size, so we can use sizeof to trick the\n// compiler into telling us which function it would have chosen if we\n// had called it with an argument of type From.  See Alexandrescu's\n// _Modern C++ Design_ for more details on this sort of trick.\n\ntemplate <typename From, typename To>\nstruct ConvertHelper {\n  static small_ Test(To);\n  static big_ Test(...);\n  static From Create();\n  enum {\n    value = sizeof(Test(Create())) == sizeof(small_)\n  };\n};\n}  // namespace type_traits_internal\n\n// Inherits from true_type if From is convertible to To, false_type otherwise.\ntemplate <typename From, typename To>\nstruct is_convertible\n    : integral_constant<bool,\n                        type_traits_internal::ConvertHelper<From, To>::value> {\n};\n#endif\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_TYPE_TRAITS_H_\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/stubs/type_traits_unittest.cc",
    "content": "// Copyright (c) 2006, Google Inc.\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// ----\n// Author: Matt Austern\n\n#include <google/protobuf/stubs/type_traits.h>\n\n#include <stdlib.h>   // for exit()\n#include <stdio.h>\n#include <string>\n#include <vector>\n\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\ntypedef int int32;\n// IBM AIX typedefs `int64` in `sys/inttypes.h`, included transitively above.\n#ifndef _AIX\ntypedef long int64;\n#endif\n\nusing std::string;\nusing std::vector;\nusing std::pair;\n\n\n// This assertion produces errors like \"error: invalid use of\n// incomplete type 'struct <unnamed>::AssertTypesEq<const int, int>'\"\n// when it fails.\ntemplate<typename T, typename U> struct AssertTypesEq;\ntemplate<typename T> struct AssertTypesEq<T, T> {};\n#define COMPILE_ASSERT_TYPES_EQ(T, U) static_cast<void>(AssertTypesEq<T, U>())\n\n// A user-defined POD type.\nstruct A {\n  int n_;\n};\n\n// A user-defined non-POD type with a trivial copy constructor.\nclass B {\n public:\n  explicit B(int n) : n_(n) { }\n private:\n  int n_;\n};\n\n// Another user-defined non-POD type with a trivial copy constructor.\n// We will explicitly declare C to have a trivial copy constructor\n// by specializing has_trivial_copy.\nclass C {\n public:\n  explicit C(int n) : n_(n) { }\n private:\n  int n_;\n};\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\ntemplate<> struct has_trivial_copy<C> : true_type { };\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n// Another user-defined non-POD type with a trivial assignment operator.\n// We will explicitly declare C to have a trivial assignment operator\n// by specializing has_trivial_assign.\nclass D {\n public:\n  explicit D(int n) : n_(n) { }\n private:\n  int n_;\n};\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\ntemplate<> struct has_trivial_assign<D> : true_type { };\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n// Another user-defined non-POD type with a trivial constructor.\n// We will explicitly declare E to have a trivial constructor\n// by specializing has_trivial_constructor.\nclass E {\n public:\n  int n_;\n};\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\ntemplate<> struct has_trivial_constructor<E> : true_type { };\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\n// Another user-defined non-POD type with a trivial destructor.\n// We will explicitly declare E to have a trivial destructor\n// by specializing has_trivial_destructor.\nclass F {\n public:\n  explicit F(int n) : n_(n) { }\n private:\n  int n_;\n};\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\ntemplate<> struct has_trivial_destructor<F> : true_type { };\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n\nenum G {};\n\nunion H {};\n\nclass I {\n public:\n  operator int() const;\n};\n\nclass J {\n private:\n  operator int() const;\n};\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\nnamespace {\n\n// A base class and a derived class that inherits from it, used for\n// testing conversion type traits.\nclass Base {\n public:\n  virtual ~Base() { }\n};\n\nclass Derived : public Base {\n};\n\nTEST(TypeTraitsTest, TestIsInteger) {\n  // Verify that is_integral is true for all integer types.\n  EXPECT_TRUE(is_integral<bool>::value);\n  EXPECT_TRUE(is_integral<char>::value);\n  EXPECT_TRUE(is_integral<unsigned char>::value);\n  EXPECT_TRUE(is_integral<signed char>::value);\n  EXPECT_TRUE(is_integral<wchar_t>::value);\n  EXPECT_TRUE(is_integral<int>::value);\n  EXPECT_TRUE(is_integral<unsigned int>::value);\n  EXPECT_TRUE(is_integral<short>::value);\n  EXPECT_TRUE(is_integral<unsigned short>::value);\n  EXPECT_TRUE(is_integral<long>::value);\n  EXPECT_TRUE(is_integral<unsigned long>::value);\n\n  // Verify that is_integral is false for a few non-integer types.\n  EXPECT_FALSE(is_integral<void>::value);\n  EXPECT_FALSE(is_integral<float>::value);\n  EXPECT_FALSE(is_integral<string>::value);\n  EXPECT_FALSE(is_integral<int*>::value);\n  EXPECT_FALSE(is_integral<A>::value);\n  EXPECT_FALSE((is_integral<pair<int, int> >::value));\n\n  // Verify that cv-qualified integral types are still integral, and\n  // cv-qualified non-integral types are still non-integral.\n  EXPECT_TRUE(is_integral<const char>::value);\n  EXPECT_TRUE(is_integral<volatile bool>::value);\n  EXPECT_TRUE(is_integral<const volatile unsigned int>::value);\n  EXPECT_FALSE(is_integral<const float>::value);\n  EXPECT_FALSE(is_integral<int* volatile>::value);\n  EXPECT_FALSE(is_integral<const volatile string>::value);\n}\n\nTEST(TypeTraitsTest, TestIsFloating) {\n  // Verify that is_floating_point is true for all floating-point types.\n  EXPECT_TRUE(is_floating_point<float>::value);\n  EXPECT_TRUE(is_floating_point<double>::value);\n  EXPECT_TRUE(is_floating_point<long double>::value);\n\n  // Verify that is_floating_point is false for a few non-float types.\n  EXPECT_FALSE(is_floating_point<void>::value);\n  EXPECT_FALSE(is_floating_point<long>::value);\n  EXPECT_FALSE(is_floating_point<string>::value);\n  EXPECT_FALSE(is_floating_point<float*>::value);\n  EXPECT_FALSE(is_floating_point<A>::value);\n  EXPECT_FALSE((is_floating_point<pair<int, int> >::value));\n\n  // Verify that cv-qualified floating point types are still floating, and\n  // cv-qualified non-floating types are still non-floating.\n  EXPECT_TRUE(is_floating_point<const float>::value);\n  EXPECT_TRUE(is_floating_point<volatile double>::value);\n  EXPECT_TRUE(is_floating_point<const volatile long double>::value);\n  EXPECT_FALSE(is_floating_point<const int>::value);\n  EXPECT_FALSE(is_floating_point<volatile string>::value);\n  EXPECT_FALSE(is_floating_point<const volatile char>::value);\n}\n\nTEST(TypeTraitsTest, TestIsPointer) {\n  // Verify that is_pointer is true for some pointer types.\n  EXPECT_TRUE(is_pointer<int*>::value);\n  EXPECT_TRUE(is_pointer<void*>::value);\n  EXPECT_TRUE(is_pointer<string*>::value);\n  EXPECT_TRUE(is_pointer<const void*>::value);\n  EXPECT_TRUE(is_pointer<volatile float* const*>::value);\n\n  // Verify that is_pointer is false for some non-pointer types.\n  EXPECT_FALSE(is_pointer<void>::value);\n  EXPECT_FALSE(is_pointer<float&>::value);\n  EXPECT_FALSE(is_pointer<long>::value);\n  EXPECT_FALSE(is_pointer<vector<int*> >::value);\n  EXPECT_FALSE(is_pointer<int[5]>::value);\n\n  // A function pointer is a pointer, but a function type, or a function\n  // reference type, is not.\n  EXPECT_TRUE(is_pointer<int (*)(int x)>::value);\n  EXPECT_FALSE(is_pointer<void(char x)>::value);\n  EXPECT_FALSE(is_pointer<double (&)(string x)>::value);\n\n  // Verify that is_pointer<T> is true for some cv-qualified pointer types,\n  // and false for some cv-qualified non-pointer types.\n  EXPECT_TRUE(is_pointer<int* const>::value);\n  EXPECT_TRUE(is_pointer<const void* volatile>::value);\n  EXPECT_TRUE(is_pointer<char** const volatile>::value);\n  EXPECT_FALSE(is_pointer<const int>::value);\n  EXPECT_FALSE(is_pointer<volatile vector<int*> >::value);\n  EXPECT_FALSE(is_pointer<const volatile double>::value);\n}\n\nTEST(TypeTraitsTest, TestIsEnum) {\n// is_enum isn't supported on MSVC or gcc 3.x\n#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)\n  // Verify that is_enum is true for enum types.\n  EXPECT_TRUE(is_enum<G>::value);\n  EXPECT_TRUE(is_enum<const G>::value);\n  EXPECT_TRUE(is_enum<volatile G>::value);\n  EXPECT_TRUE(is_enum<const volatile G>::value);\n\n  // Verify that is_enum is false for a few non-enum types.\n  EXPECT_FALSE(is_enum<void>::value);\n  EXPECT_FALSE(is_enum<G&>::value);\n  EXPECT_FALSE(is_enum<G[1]>::value);\n  EXPECT_FALSE(is_enum<const G[1]>::value);\n  EXPECT_FALSE(is_enum<G[]>::value);\n  EXPECT_FALSE(is_enum<int>::value);\n  EXPECT_FALSE(is_enum<float>::value);\n  EXPECT_FALSE(is_enum<A>::value);\n  EXPECT_FALSE(is_enum<A*>::value);\n  EXPECT_FALSE(is_enum<const A>::value);\n  EXPECT_FALSE(is_enum<H>::value);\n  EXPECT_FALSE(is_enum<I>::value);\n  EXPECT_FALSE(is_enum<J>::value);\n  EXPECT_FALSE(is_enum<void()>::value);\n  EXPECT_FALSE(is_enum<void(*)()>::value);\n  EXPECT_FALSE(is_enum<int A::*>::value);\n  EXPECT_FALSE(is_enum<void (A::*)()>::value);\n#endif\n}\n\nTEST(TypeTraitsTest, TestIsReference) {\n  // Verifies that is_reference is true for all reference types.\n  typedef float& RefFloat;\n  EXPECT_TRUE(is_reference<float&>::value);\n  EXPECT_TRUE(is_reference<const int&>::value);\n  EXPECT_TRUE(is_reference<const int*&>::value);\n  EXPECT_TRUE(is_reference<int (&)(bool)>::value);\n  EXPECT_TRUE(is_reference<RefFloat>::value);\n  EXPECT_TRUE(is_reference<const RefFloat>::value);\n  EXPECT_TRUE(is_reference<volatile RefFloat>::value);\n  EXPECT_TRUE(is_reference<const volatile RefFloat>::value);\n\n\n  // Verifies that is_reference is false for all non-reference types.\n  EXPECT_FALSE(is_reference<float>::value);\n  EXPECT_FALSE(is_reference<const float>::value);\n  EXPECT_FALSE(is_reference<volatile float>::value);\n  EXPECT_FALSE(is_reference<const volatile float>::value);\n  EXPECT_FALSE(is_reference<const int*>::value);\n  EXPECT_FALSE(is_reference<int()>::value);\n  EXPECT_FALSE(is_reference<void(*)(const char&)>::value);\n}\n\nTEST(TypeTraitsTest, TestAddReference) {\n  COMPILE_ASSERT_TYPES_EQ(int&, add_reference<int>::type);\n  COMPILE_ASSERT_TYPES_EQ(const int&, add_reference<const int>::type);\n  COMPILE_ASSERT_TYPES_EQ(volatile int&,\n                          add_reference<volatile int>::type);\n  COMPILE_ASSERT_TYPES_EQ(const volatile int&,\n                          add_reference<const volatile int>::type);\n  COMPILE_ASSERT_TYPES_EQ(int&, add_reference<int&>::type);\n  COMPILE_ASSERT_TYPES_EQ(const int&, add_reference<const int&>::type);\n  COMPILE_ASSERT_TYPES_EQ(volatile int&,\n                          add_reference<volatile int&>::type);\n  COMPILE_ASSERT_TYPES_EQ(const volatile int&,\n                          add_reference<const volatile int&>::type);\n}\n\nTEST(TypeTraitsTest, TestIsPod) {\n  // Verify that arithmetic types and pointers are marked as PODs.\n  EXPECT_TRUE(is_pod<bool>::value);\n  EXPECT_TRUE(is_pod<char>::value);\n  EXPECT_TRUE(is_pod<unsigned char>::value);\n  EXPECT_TRUE(is_pod<signed char>::value);\n  EXPECT_TRUE(is_pod<wchar_t>::value);\n  EXPECT_TRUE(is_pod<int>::value);\n  EXPECT_TRUE(is_pod<unsigned int>::value);\n  EXPECT_TRUE(is_pod<short>::value);\n  EXPECT_TRUE(is_pod<unsigned short>::value);\n  EXPECT_TRUE(is_pod<long>::value);\n  EXPECT_TRUE(is_pod<unsigned long>::value);\n  EXPECT_TRUE(is_pod<float>::value);\n  EXPECT_TRUE(is_pod<double>::value);\n  EXPECT_TRUE(is_pod<long double>::value);\n  EXPECT_TRUE(is_pod<string*>::value);\n  EXPECT_TRUE(is_pod<A*>::value);\n  EXPECT_TRUE(is_pod<const B*>::value);\n  EXPECT_TRUE(is_pod<C**>::value);\n  EXPECT_TRUE(is_pod<const int>::value);\n  EXPECT_TRUE(is_pod<char* volatile>::value);\n  EXPECT_TRUE(is_pod<const volatile double>::value);\n#if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)\n  EXPECT_TRUE(is_pod<G>::value);\n  EXPECT_TRUE(is_pod<const G>::value);\n  EXPECT_TRUE(is_pod<volatile G>::value);\n  EXPECT_TRUE(is_pod<const volatile G>::value);\n#endif\n\n  // Verify that some non-POD types are not marked as PODs.\n  EXPECT_FALSE(is_pod<void>::value);\n  EXPECT_FALSE(is_pod<string>::value);\n  EXPECT_FALSE((is_pod<pair<int, int> >::value));\n  EXPECT_FALSE(is_pod<A>::value);\n  EXPECT_FALSE(is_pod<B>::value);\n  EXPECT_FALSE(is_pod<C>::value);\n  EXPECT_FALSE(is_pod<const string>::value);\n  EXPECT_FALSE(is_pod<volatile A>::value);\n  EXPECT_FALSE(is_pod<const volatile B>::value);\n}\n\nTEST(TypeTraitsTest, TestHasTrivialConstructor) {\n  // Verify that arithmetic types and pointers have trivial constructors.\n  EXPECT_TRUE(has_trivial_constructor<bool>::value);\n  EXPECT_TRUE(has_trivial_constructor<char>::value);\n  EXPECT_TRUE(has_trivial_constructor<unsigned char>::value);\n  EXPECT_TRUE(has_trivial_constructor<signed char>::value);\n  EXPECT_TRUE(has_trivial_constructor<wchar_t>::value);\n  EXPECT_TRUE(has_trivial_constructor<int>::value);\n  EXPECT_TRUE(has_trivial_constructor<unsigned int>::value);\n  EXPECT_TRUE(has_trivial_constructor<short>::value);\n  EXPECT_TRUE(has_trivial_constructor<unsigned short>::value);\n  EXPECT_TRUE(has_trivial_constructor<long>::value);\n  EXPECT_TRUE(has_trivial_constructor<unsigned long>::value);\n  EXPECT_TRUE(has_trivial_constructor<float>::value);\n  EXPECT_TRUE(has_trivial_constructor<double>::value);\n  EXPECT_TRUE(has_trivial_constructor<long double>::value);\n  EXPECT_TRUE(has_trivial_constructor<string*>::value);\n  EXPECT_TRUE(has_trivial_constructor<A*>::value);\n  EXPECT_TRUE(has_trivial_constructor<const B*>::value);\n  EXPECT_TRUE(has_trivial_constructor<C**>::value);\n\n  // Verify that pairs and arrays of such types have trivial\n  // constructors.\n  typedef int int10[10];\n  EXPECT_TRUE((has_trivial_constructor<pair<int, char*> >::value));\n  EXPECT_TRUE(has_trivial_constructor<int10>::value);\n\n  // Verify that pairs of types without trivial constructors\n  // are not marked as trivial.\n  EXPECT_FALSE((has_trivial_constructor<pair<int, string> >::value));\n  EXPECT_FALSE((has_trivial_constructor<pair<string, int> >::value));\n\n  // Verify that types without trivial constructors are\n  // correctly marked as such.\n  EXPECT_FALSE(has_trivial_constructor<string>::value);\n  EXPECT_FALSE(has_trivial_constructor<vector<int> >::value);\n\n  // Verify that E, which we have declared to have a trivial\n  // constructor, is correctly marked as such.\n  EXPECT_TRUE(has_trivial_constructor<E>::value);\n}\n\nTEST(TypeTraitsTest, TestHasTrivialCopy) {\n  // Verify that arithmetic types and pointers have trivial copy\n  // constructors.\n  EXPECT_TRUE(has_trivial_copy<bool>::value);\n  EXPECT_TRUE(has_trivial_copy<char>::value);\n  EXPECT_TRUE(has_trivial_copy<unsigned char>::value);\n  EXPECT_TRUE(has_trivial_copy<signed char>::value);\n  EXPECT_TRUE(has_trivial_copy<wchar_t>::value);\n  EXPECT_TRUE(has_trivial_copy<int>::value);\n  EXPECT_TRUE(has_trivial_copy<unsigned int>::value);\n  EXPECT_TRUE(has_trivial_copy<short>::value);\n  EXPECT_TRUE(has_trivial_copy<unsigned short>::value);\n  EXPECT_TRUE(has_trivial_copy<long>::value);\n  EXPECT_TRUE(has_trivial_copy<unsigned long>::value);\n  EXPECT_TRUE(has_trivial_copy<float>::value);\n  EXPECT_TRUE(has_trivial_copy<double>::value);\n  EXPECT_TRUE(has_trivial_copy<long double>::value);\n  EXPECT_TRUE(has_trivial_copy<string*>::value);\n  EXPECT_TRUE(has_trivial_copy<A*>::value);\n  EXPECT_TRUE(has_trivial_copy<const B*>::value);\n  EXPECT_TRUE(has_trivial_copy<C**>::value);\n\n  // Verify that pairs and arrays of such types have trivial\n  // copy constructors.\n  typedef int int10[10];\n  EXPECT_TRUE((has_trivial_copy<pair<int, char*> >::value));\n  EXPECT_TRUE(has_trivial_copy<int10>::value);\n\n  // Verify that pairs of types without trivial copy constructors\n  // are not marked as trivial.\n  EXPECT_FALSE((has_trivial_copy<pair<int, string> >::value));\n  EXPECT_FALSE((has_trivial_copy<pair<string, int> >::value));\n\n  // Verify that types without trivial copy constructors are\n  // correctly marked as such.\n  EXPECT_FALSE(has_trivial_copy<string>::value);\n  EXPECT_FALSE(has_trivial_copy<vector<int> >::value);\n\n  // Verify that C, which we have declared to have a trivial\n  // copy constructor, is correctly marked as such.\n  EXPECT_TRUE(has_trivial_copy<C>::value);\n}\n\nTEST(TypeTraitsTest, TestHasTrivialAssign) {\n  // Verify that arithmetic types and pointers have trivial assignment\n  // operators.\n  EXPECT_TRUE(has_trivial_assign<bool>::value);\n  EXPECT_TRUE(has_trivial_assign<char>::value);\n  EXPECT_TRUE(has_trivial_assign<unsigned char>::value);\n  EXPECT_TRUE(has_trivial_assign<signed char>::value);\n  EXPECT_TRUE(has_trivial_assign<wchar_t>::value);\n  EXPECT_TRUE(has_trivial_assign<int>::value);\n  EXPECT_TRUE(has_trivial_assign<unsigned int>::value);\n  EXPECT_TRUE(has_trivial_assign<short>::value);\n  EXPECT_TRUE(has_trivial_assign<unsigned short>::value);\n  EXPECT_TRUE(has_trivial_assign<long>::value);\n  EXPECT_TRUE(has_trivial_assign<unsigned long>::value);\n  EXPECT_TRUE(has_trivial_assign<float>::value);\n  EXPECT_TRUE(has_trivial_assign<double>::value);\n  EXPECT_TRUE(has_trivial_assign<long double>::value);\n  EXPECT_TRUE(has_trivial_assign<string*>::value);\n  EXPECT_TRUE(has_trivial_assign<A*>::value);\n  EXPECT_TRUE(has_trivial_assign<const B*>::value);\n  EXPECT_TRUE(has_trivial_assign<C**>::value);\n\n  // Verify that pairs and arrays of such types have trivial\n  // assignment operators.\n  typedef int int10[10];\n  EXPECT_TRUE((has_trivial_assign<pair<int, char*> >::value));\n  EXPECT_TRUE(has_trivial_assign<int10>::value);\n\n  // Verify that pairs of types without trivial assignment operators\n  // are not marked as trivial.\n  EXPECT_FALSE((has_trivial_assign<pair<int, string> >::value));\n  EXPECT_FALSE((has_trivial_assign<pair<string, int> >::value));\n\n  // Verify that types without trivial assignment operators are\n  // correctly marked as such.\n  EXPECT_FALSE(has_trivial_assign<string>::value);\n  EXPECT_FALSE(has_trivial_assign<vector<int> >::value);\n\n  // Verify that D, which we have declared to have a trivial\n  // assignment operator, is correctly marked as such.\n  EXPECT_TRUE(has_trivial_assign<D>::value);\n}\n\nTEST(TypeTraitsTest, TestHasTrivialDestructor) {\n  // Verify that arithmetic types and pointers have trivial destructors.\n  EXPECT_TRUE(has_trivial_destructor<bool>::value);\n  EXPECT_TRUE(has_trivial_destructor<char>::value);\n  EXPECT_TRUE(has_trivial_destructor<unsigned char>::value);\n  EXPECT_TRUE(has_trivial_destructor<signed char>::value);\n  EXPECT_TRUE(has_trivial_destructor<wchar_t>::value);\n  EXPECT_TRUE(has_trivial_destructor<int>::value);\n  EXPECT_TRUE(has_trivial_destructor<unsigned int>::value);\n  EXPECT_TRUE(has_trivial_destructor<short>::value);\n  EXPECT_TRUE(has_trivial_destructor<unsigned short>::value);\n  EXPECT_TRUE(has_trivial_destructor<long>::value);\n  EXPECT_TRUE(has_trivial_destructor<unsigned long>::value);\n  EXPECT_TRUE(has_trivial_destructor<float>::value);\n  EXPECT_TRUE(has_trivial_destructor<double>::value);\n  EXPECT_TRUE(has_trivial_destructor<long double>::value);\n  EXPECT_TRUE(has_trivial_destructor<string*>::value);\n  EXPECT_TRUE(has_trivial_destructor<A*>::value);\n  EXPECT_TRUE(has_trivial_destructor<const B*>::value);\n  EXPECT_TRUE(has_trivial_destructor<C**>::value);\n\n  // Verify that pairs and arrays of such types have trivial\n  // destructors.\n  typedef int int10[10];\n  EXPECT_TRUE((has_trivial_destructor<pair<int, char*> >::value));\n  EXPECT_TRUE(has_trivial_destructor<int10>::value);\n\n  // Verify that pairs of types without trivial destructors\n  // are not marked as trivial.\n  EXPECT_FALSE((has_trivial_destructor<pair<int, string> >::value));\n  EXPECT_FALSE((has_trivial_destructor<pair<string, int> >::value));\n\n  // Verify that types without trivial destructors are\n  // correctly marked as such.\n  EXPECT_FALSE(has_trivial_destructor<string>::value);\n  EXPECT_FALSE(has_trivial_destructor<vector<int> >::value);\n\n  // Verify that F, which we have declared to have a trivial\n  // destructor, is correctly marked as such.\n  EXPECT_TRUE(has_trivial_destructor<F>::value);\n}\n\n// Tests remove_pointer.\nTEST(TypeTraitsTest, TestRemovePointer) {\n  COMPILE_ASSERT_TYPES_EQ(int, remove_pointer<int>::type);\n  COMPILE_ASSERT_TYPES_EQ(int, remove_pointer<int*>::type);\n  COMPILE_ASSERT_TYPES_EQ(const int, remove_pointer<const int*>::type);\n  COMPILE_ASSERT_TYPES_EQ(int, remove_pointer<int* const>::type);\n  COMPILE_ASSERT_TYPES_EQ(int, remove_pointer<int* volatile>::type);\n}\n\nTEST(TypeTraitsTest, TestRemoveConst) {\n  COMPILE_ASSERT_TYPES_EQ(int, remove_const<int>::type);\n  COMPILE_ASSERT_TYPES_EQ(int, remove_const<const int>::type);\n  COMPILE_ASSERT_TYPES_EQ(int *, remove_const<int * const>::type);\n  // TR1 examples.\n  COMPILE_ASSERT_TYPES_EQ(const int *, remove_const<const int *>::type);\n  COMPILE_ASSERT_TYPES_EQ(volatile int,\n                          remove_const<const volatile int>::type);\n}\n\nTEST(TypeTraitsTest, TestRemoveVolatile) {\n  COMPILE_ASSERT_TYPES_EQ(int, remove_volatile<int>::type);\n  COMPILE_ASSERT_TYPES_EQ(int, remove_volatile<volatile int>::type);\n  COMPILE_ASSERT_TYPES_EQ(int *, remove_volatile<int * volatile>::type);\n  // TR1 examples.\n  COMPILE_ASSERT_TYPES_EQ(volatile int *,\n                          remove_volatile<volatile int *>::type);\n  COMPILE_ASSERT_TYPES_EQ(const int,\n                          remove_volatile<const volatile int>::type);\n}\n\nTEST(TypeTraitsTest, TestRemoveCV) {\n  COMPILE_ASSERT_TYPES_EQ(int, remove_cv<int>::type);\n  COMPILE_ASSERT_TYPES_EQ(int, remove_cv<volatile int>::type);\n  COMPILE_ASSERT_TYPES_EQ(int, remove_cv<const int>::type);\n  COMPILE_ASSERT_TYPES_EQ(int *, remove_cv<int * const volatile>::type);\n  // TR1 examples.\n  COMPILE_ASSERT_TYPES_EQ(const volatile int *,\n                          remove_cv<const volatile int *>::type);\n  COMPILE_ASSERT_TYPES_EQ(int,\n                          remove_cv<const volatile int>::type);\n}\n\nTEST(TypeTraitsTest, TestRemoveReference) {\n  COMPILE_ASSERT_TYPES_EQ(int, remove_reference<int>::type);\n  COMPILE_ASSERT_TYPES_EQ(int, remove_reference<int&>::type);\n  COMPILE_ASSERT_TYPES_EQ(const int, remove_reference<const int&>::type);\n  COMPILE_ASSERT_TYPES_EQ(int*, remove_reference<int * &>::type);\n}\n\nTEST(TypeTraitsTest, TestIsSame) {\n  EXPECT_TRUE((is_same<int32, int32>::value));\n  EXPECT_FALSE((is_same<int32, int64>::value));\n  EXPECT_FALSE((is_same<int64, int32>::value));\n  EXPECT_FALSE((is_same<int, const int>::value));\n\n  EXPECT_TRUE((is_same<void, void>::value));\n  EXPECT_FALSE((is_same<void, int>::value));\n  EXPECT_FALSE((is_same<int, void>::value));\n\n  EXPECT_TRUE((is_same<int*, int*>::value));\n  EXPECT_TRUE((is_same<void*, void*>::value));\n  EXPECT_FALSE((is_same<int*, void*>::value));\n  EXPECT_FALSE((is_same<void*, int*>::value));\n  EXPECT_FALSE((is_same<void*, const void*>::value));\n  EXPECT_FALSE((is_same<void*, void* const>::value));\n\n  EXPECT_TRUE((is_same<Base*, Base*>::value));\n  EXPECT_TRUE((is_same<Derived*, Derived*>::value));\n  EXPECT_FALSE((is_same<Base*, Derived*>::value));\n  EXPECT_FALSE((is_same<Derived*, Base*>::value));\n}\n\nTEST(TypeTraitsTest, TestConvertible) {\n#if !(defined(__GNUC__) && __GNUC__ <= 3)\n  EXPECT_TRUE((is_convertible<int, int>::value));\n  EXPECT_TRUE((is_convertible<int, long>::value));\n  EXPECT_TRUE((is_convertible<long, int>::value));\n\n  EXPECT_TRUE((is_convertible<int*, void*>::value));\n  EXPECT_FALSE((is_convertible<void*, int*>::value));\n\n  EXPECT_TRUE((is_convertible<Derived*, Base*>::value));\n  EXPECT_FALSE((is_convertible<Base*, Derived*>::value));\n  EXPECT_TRUE((is_convertible<Derived*, const Base*>::value));\n  EXPECT_FALSE((is_convertible<const Derived*, Base*>::value));\n#endif\n}\n\n}  // anonymous namespace\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/test_util.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifdef _WIN32\n// Verify that #including windows.h does not break anything (e.g. because\n// windows.h #defines GetMessage() as a macro).\n#include <windows.h>\n#endif\n\n#include <google/protobuf/test_util.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/message.h>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\n\nvoid TestUtil::SetAllFields(unittest::TestAllTypes* message) {\n  SetOptionalFields(message);\n  AddRepeatedFields1(message);\n  AddRepeatedFields2(message);\n  SetDefaultFields(message);\n  SetOneofFields(message);\n}\n\nvoid TestUtil::SetOptionalFields(unittest::TestAllTypes* message) {\n  message->set_optional_int32   (101);\n  message->set_optional_int64   (102);\n  message->set_optional_uint32  (103);\n  message->set_optional_uint64  (104);\n  message->set_optional_sint32  (105);\n  message->set_optional_sint64  (106);\n  message->set_optional_fixed32 (107);\n  message->set_optional_fixed64 (108);\n  message->set_optional_sfixed32(109);\n  message->set_optional_sfixed64(110);\n  message->set_optional_float   (111);\n  message->set_optional_double  (112);\n  message->set_optional_bool    (true);\n  message->set_optional_string  (\"115\");\n  message->set_optional_bytes   (\"116\");\n\n  message->mutable_optionalgroup                 ()->set_a(117);\n  message->mutable_optional_nested_message       ()->set_bb(118);\n  message->mutable_optional_foreign_message      ()->set_c(119);\n  message->mutable_optional_import_message       ()->set_d(120);\n  message->mutable_optional_public_import_message()->set_e(126);\n  message->mutable_optional_lazy_message         ()->set_bb(127);\n\n  message->set_optional_nested_enum (unittest::TestAllTypes::BAZ);\n  message->set_optional_foreign_enum(unittest::FOREIGN_BAZ      );\n  message->set_optional_import_enum (unittest_import::IMPORT_BAZ);\n\n  // StringPiece and Cord fields are only accessible via reflection in the\n  // open source release; see comments in compiler/cpp/string_field.cc.\n#ifndef PROTOBUF_TEST_NO_DESCRIPTORS\n  message->GetReflection()->SetString(\n    message,\n    message->GetDescriptor()->FindFieldByName(\"optional_string_piece\"),\n    \"124\");\n  message->GetReflection()->SetString(\n    message,\n    message->GetDescriptor()->FindFieldByName(\"optional_cord\"),\n    \"125\");\n#endif  // !PROTOBUF_TEST_NO_DESCRIPTORS\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::AddRepeatedFields1(unittest::TestAllTypes* message) {\n  message->add_repeated_int32   (201);\n  message->add_repeated_int64   (202);\n  message->add_repeated_uint32  (203);\n  message->add_repeated_uint64  (204);\n  message->add_repeated_sint32  (205);\n  message->add_repeated_sint64  (206);\n  message->add_repeated_fixed32 (207);\n  message->add_repeated_fixed64 (208);\n  message->add_repeated_sfixed32(209);\n  message->add_repeated_sfixed64(210);\n  message->add_repeated_float   (211);\n  message->add_repeated_double  (212);\n  message->add_repeated_bool    (true);\n  message->add_repeated_string  (\"215\");\n  message->add_repeated_bytes   (\"216\");\n\n  message->add_repeatedgroup           ()->set_a(217);\n  message->add_repeated_nested_message ()->set_bb(218);\n  message->add_repeated_foreign_message()->set_c(219);\n  message->add_repeated_import_message ()->set_d(220);\n  message->add_repeated_lazy_message   ()->set_bb(227);\n\n  message->add_repeated_nested_enum (unittest::TestAllTypes::BAR);\n  message->add_repeated_foreign_enum(unittest::FOREIGN_BAR      );\n  message->add_repeated_import_enum (unittest_import::IMPORT_BAR);\n\n#ifndef PROTOBUF_TEST_NO_DESCRIPTORS\n  message->GetReflection()->AddString(\n    message,\n    message->GetDescriptor()->FindFieldByName(\"repeated_string_piece\"),\n    \"224\");\n  message->GetReflection()->AddString(\n    message,\n    message->GetDescriptor()->FindFieldByName(\"repeated_cord\"),\n    \"225\");\n#endif  // !PROTOBUF_TEST_NO_DESCRIPTORS\n}\n\nvoid TestUtil::AddRepeatedFields2(unittest::TestAllTypes* message) {\n  // Add a second one of each field.\n  message->add_repeated_int32   (301);\n  message->add_repeated_int64   (302);\n  message->add_repeated_uint32  (303);\n  message->add_repeated_uint64  (304);\n  message->add_repeated_sint32  (305);\n  message->add_repeated_sint64  (306);\n  message->add_repeated_fixed32 (307);\n  message->add_repeated_fixed64 (308);\n  message->add_repeated_sfixed32(309);\n  message->add_repeated_sfixed64(310);\n  message->add_repeated_float   (311);\n  message->add_repeated_double  (312);\n  message->add_repeated_bool    (false);\n  message->add_repeated_string  (\"315\");\n  message->add_repeated_bytes   (\"316\");\n\n  message->add_repeatedgroup           ()->set_a(317);\n  message->add_repeated_nested_message ()->set_bb(318);\n  message->add_repeated_foreign_message()->set_c(319);\n  message->add_repeated_import_message ()->set_d(320);\n  message->add_repeated_lazy_message   ()->set_bb(327);\n\n  message->add_repeated_nested_enum (unittest::TestAllTypes::BAZ);\n  message->add_repeated_foreign_enum(unittest::FOREIGN_BAZ      );\n  message->add_repeated_import_enum (unittest_import::IMPORT_BAZ);\n\n#ifndef PROTOBUF_TEST_NO_DESCRIPTORS\n  message->GetReflection()->AddString(\n    message,\n    message->GetDescriptor()->FindFieldByName(\"repeated_string_piece\"),\n    \"324\");\n  message->GetReflection()->AddString(\n    message,\n    message->GetDescriptor()->FindFieldByName(\"repeated_cord\"),\n    \"325\");\n#endif  // !PROTOBUF_TEST_NO_DESCRIPTORS\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::SetDefaultFields(unittest::TestAllTypes* message) {\n  message->set_default_int32   (401);\n  message->set_default_int64   (402);\n  message->set_default_uint32  (403);\n  message->set_default_uint64  (404);\n  message->set_default_sint32  (405);\n  message->set_default_sint64  (406);\n  message->set_default_fixed32 (407);\n  message->set_default_fixed64 (408);\n  message->set_default_sfixed32(409);\n  message->set_default_sfixed64(410);\n  message->set_default_float   (411);\n  message->set_default_double  (412);\n  message->set_default_bool    (false);\n  message->set_default_string  (\"415\");\n  message->set_default_bytes   (\"416\");\n\n  message->set_default_nested_enum (unittest::TestAllTypes::FOO);\n  message->set_default_foreign_enum(unittest::FOREIGN_FOO      );\n  message->set_default_import_enum (unittest_import::IMPORT_FOO);\n\n#ifndef PROTOBUF_TEST_NO_DESCRIPTORS\n  message->GetReflection()->SetString(\n    message,\n    message->GetDescriptor()->FindFieldByName(\"default_string_piece\"),\n    \"424\");\n  message->GetReflection()->SetString(\n    message,\n    message->GetDescriptor()->FindFieldByName(\"default_cord\"),\n    \"425\");\n#endif  // !PROTOBUF_TEST_NO_DESCRIPTORS\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::ModifyRepeatedFields(unittest::TestAllTypes* message) {\n  message->set_repeated_int32   (1, 501);\n  message->set_repeated_int64   (1, 502);\n  message->set_repeated_uint32  (1, 503);\n  message->set_repeated_uint64  (1, 504);\n  message->set_repeated_sint32  (1, 505);\n  message->set_repeated_sint64  (1, 506);\n  message->set_repeated_fixed32 (1, 507);\n  message->set_repeated_fixed64 (1, 508);\n  message->set_repeated_sfixed32(1, 509);\n  message->set_repeated_sfixed64(1, 510);\n  message->set_repeated_float   (1, 511);\n  message->set_repeated_double  (1, 512);\n  message->set_repeated_bool    (1, true);\n  message->set_repeated_string  (1, \"515\");\n  message->set_repeated_bytes   (1, \"516\");\n\n  message->mutable_repeatedgroup           (1)->set_a(517);\n  message->mutable_repeated_nested_message (1)->set_bb(518);\n  message->mutable_repeated_foreign_message(1)->set_c(519);\n  message->mutable_repeated_import_message (1)->set_d(520);\n  message->mutable_repeated_lazy_message   (1)->set_bb(527);\n\n  message->set_repeated_nested_enum (1, unittest::TestAllTypes::FOO);\n  message->set_repeated_foreign_enum(1, unittest::FOREIGN_FOO      );\n  message->set_repeated_import_enum (1, unittest_import::IMPORT_FOO);\n\n#ifndef PROTOBUF_TEST_NO_DESCRIPTORS\n  message->GetReflection()->SetRepeatedString(\n    message,\n    message->GetDescriptor()->FindFieldByName(\"repeated_string_piece\"),\n    1, \"524\");\n  message->GetReflection()->SetRepeatedString(\n    message,\n    message->GetDescriptor()->FindFieldByName(\"repeated_cord\"),\n    1, \"525\");\n#endif  // !PROTOBUF_TEST_NO_DESCRIPTORS\n}\n\n// ------------------------------------------------------------------\nvoid TestUtil::SetOneofFields(unittest::TestAllTypes* message) {\n  message->set_oneof_uint32(601);\n  message->mutable_oneof_nested_message()->set_bb(602);\n  message->set_oneof_string(\"603\");\n  message->set_oneof_bytes(\"604\");\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::ExpectAllFieldsSet(const unittest::TestAllTypes& message) {\n  EXPECT_TRUE(message.has_optional_int32   ());\n  EXPECT_TRUE(message.has_optional_int64   ());\n  EXPECT_TRUE(message.has_optional_uint32  ());\n  EXPECT_TRUE(message.has_optional_uint64  ());\n  EXPECT_TRUE(message.has_optional_sint32  ());\n  EXPECT_TRUE(message.has_optional_sint64  ());\n  EXPECT_TRUE(message.has_optional_fixed32 ());\n  EXPECT_TRUE(message.has_optional_fixed64 ());\n  EXPECT_TRUE(message.has_optional_sfixed32());\n  EXPECT_TRUE(message.has_optional_sfixed64());\n  EXPECT_TRUE(message.has_optional_float   ());\n  EXPECT_TRUE(message.has_optional_double  ());\n  EXPECT_TRUE(message.has_optional_bool    ());\n  EXPECT_TRUE(message.has_optional_string  ());\n  EXPECT_TRUE(message.has_optional_bytes   ());\n\n  EXPECT_TRUE(message.has_optionalgroup                 ());\n  EXPECT_TRUE(message.has_optional_nested_message       ());\n  EXPECT_TRUE(message.has_optional_foreign_message      ());\n  EXPECT_TRUE(message.has_optional_import_message       ());\n  EXPECT_TRUE(message.has_optional_public_import_message());\n  EXPECT_TRUE(message.has_optional_lazy_message         ());\n\n  EXPECT_TRUE(message.optionalgroup                 ().has_a());\n  EXPECT_TRUE(message.optional_nested_message       ().has_bb());\n  EXPECT_TRUE(message.optional_foreign_message      ().has_c());\n  EXPECT_TRUE(message.optional_import_message       ().has_d());\n  EXPECT_TRUE(message.optional_public_import_message().has_e());\n  EXPECT_TRUE(message.optional_lazy_message         ().has_bb());\n\n  EXPECT_TRUE(message.has_optional_nested_enum ());\n  EXPECT_TRUE(message.has_optional_foreign_enum());\n  EXPECT_TRUE(message.has_optional_import_enum ());\n\n#ifndef PROTOBUF_TEST_NO_DESCRIPTORS\n  EXPECT_TRUE(message.has_optional_string_piece());\n  EXPECT_TRUE(message.has_optional_cord());\n#endif\n\n  EXPECT_EQ(101  , message.optional_int32   ());\n  EXPECT_EQ(102  , message.optional_int64   ());\n  EXPECT_EQ(103  , message.optional_uint32  ());\n  EXPECT_EQ(104  , message.optional_uint64  ());\n  EXPECT_EQ(105  , message.optional_sint32  ());\n  EXPECT_EQ(106  , message.optional_sint64  ());\n  EXPECT_EQ(107  , message.optional_fixed32 ());\n  EXPECT_EQ(108  , message.optional_fixed64 ());\n  EXPECT_EQ(109  , message.optional_sfixed32());\n  EXPECT_EQ(110  , message.optional_sfixed64());\n  EXPECT_EQ(111  , message.optional_float   ());\n  EXPECT_EQ(112  , message.optional_double  ());\n  EXPECT_TRUE(     message.optional_bool    ());\n  EXPECT_EQ(\"115\", message.optional_string  ());\n  EXPECT_EQ(\"116\", message.optional_bytes   ());\n\n  EXPECT_EQ(117, message.optionalgroup                  ().a());\n  EXPECT_EQ(118, message.optional_nested_message        ().bb());\n  EXPECT_EQ(119, message.optional_foreign_message       ().c());\n  EXPECT_EQ(120, message.optional_import_message        ().d());\n  EXPECT_EQ(126, message.optional_public_import_message ().e());\n  EXPECT_EQ(127, message.optional_lazy_message          ().bb());\n\n  EXPECT_EQ(unittest::TestAllTypes::BAZ, message.optional_nested_enum ());\n  EXPECT_EQ(unittest::FOREIGN_BAZ      , message.optional_foreign_enum());\n  EXPECT_EQ(unittest_import::IMPORT_BAZ, message.optional_import_enum ());\n\n\n  // -----------------------------------------------------------------\n\n  ASSERT_EQ(2, message.repeated_int32_size   ());\n  ASSERT_EQ(2, message.repeated_int64_size   ());\n  ASSERT_EQ(2, message.repeated_uint32_size  ());\n  ASSERT_EQ(2, message.repeated_uint64_size  ());\n  ASSERT_EQ(2, message.repeated_sint32_size  ());\n  ASSERT_EQ(2, message.repeated_sint64_size  ());\n  ASSERT_EQ(2, message.repeated_fixed32_size ());\n  ASSERT_EQ(2, message.repeated_fixed64_size ());\n  ASSERT_EQ(2, message.repeated_sfixed32_size());\n  ASSERT_EQ(2, message.repeated_sfixed64_size());\n  ASSERT_EQ(2, message.repeated_float_size   ());\n  ASSERT_EQ(2, message.repeated_double_size  ());\n  ASSERT_EQ(2, message.repeated_bool_size    ());\n  ASSERT_EQ(2, message.repeated_string_size  ());\n  ASSERT_EQ(2, message.repeated_bytes_size   ());\n\n  ASSERT_EQ(2, message.repeatedgroup_size           ());\n  ASSERT_EQ(2, message.repeated_nested_message_size ());\n  ASSERT_EQ(2, message.repeated_foreign_message_size());\n  ASSERT_EQ(2, message.repeated_import_message_size ());\n  ASSERT_EQ(2, message.repeated_lazy_message_size   ());\n  ASSERT_EQ(2, message.repeated_nested_enum_size    ());\n  ASSERT_EQ(2, message.repeated_foreign_enum_size   ());\n  ASSERT_EQ(2, message.repeated_import_enum_size    ());\n\n#ifndef PROTOBUF_TEST_NO_DESCRIPTORS\n  ASSERT_EQ(2, message.repeated_string_piece_size());\n  ASSERT_EQ(2, message.repeated_cord_size());\n#endif\n\n  EXPECT_EQ(201  , message.repeated_int32   (0));\n  EXPECT_EQ(202  , message.repeated_int64   (0));\n  EXPECT_EQ(203  , message.repeated_uint32  (0));\n  EXPECT_EQ(204  , message.repeated_uint64  (0));\n  EXPECT_EQ(205  , message.repeated_sint32  (0));\n  EXPECT_EQ(206  , message.repeated_sint64  (0));\n  EXPECT_EQ(207  , message.repeated_fixed32 (0));\n  EXPECT_EQ(208  , message.repeated_fixed64 (0));\n  EXPECT_EQ(209  , message.repeated_sfixed32(0));\n  EXPECT_EQ(210  , message.repeated_sfixed64(0));\n  EXPECT_EQ(211  , message.repeated_float   (0));\n  EXPECT_EQ(212  , message.repeated_double  (0));\n  EXPECT_TRUE(     message.repeated_bool    (0));\n  EXPECT_EQ(\"215\", message.repeated_string  (0));\n  EXPECT_EQ(\"216\", message.repeated_bytes   (0));\n\n  EXPECT_EQ(217, message.repeatedgroup           (0).a());\n  EXPECT_EQ(218, message.repeated_nested_message (0).bb());\n  EXPECT_EQ(219, message.repeated_foreign_message(0).c());\n  EXPECT_EQ(220, message.repeated_import_message (0).d());\n  EXPECT_EQ(227, message.repeated_lazy_message   (0).bb());\n\n\n  EXPECT_EQ(unittest::TestAllTypes::BAR, message.repeated_nested_enum (0));\n  EXPECT_EQ(unittest::FOREIGN_BAR      , message.repeated_foreign_enum(0));\n  EXPECT_EQ(unittest_import::IMPORT_BAR, message.repeated_import_enum (0));\n\n  EXPECT_EQ(301  , message.repeated_int32   (1));\n  EXPECT_EQ(302  , message.repeated_int64   (1));\n  EXPECT_EQ(303  , message.repeated_uint32  (1));\n  EXPECT_EQ(304  , message.repeated_uint64  (1));\n  EXPECT_EQ(305  , message.repeated_sint32  (1));\n  EXPECT_EQ(306  , message.repeated_sint64  (1));\n  EXPECT_EQ(307  , message.repeated_fixed32 (1));\n  EXPECT_EQ(308  , message.repeated_fixed64 (1));\n  EXPECT_EQ(309  , message.repeated_sfixed32(1));\n  EXPECT_EQ(310  , message.repeated_sfixed64(1));\n  EXPECT_EQ(311  , message.repeated_float   (1));\n  EXPECT_EQ(312  , message.repeated_double  (1));\n  EXPECT_FALSE(    message.repeated_bool    (1));\n  EXPECT_EQ(\"315\", message.repeated_string  (1));\n  EXPECT_EQ(\"316\", message.repeated_bytes   (1));\n\n  EXPECT_EQ(317, message.repeatedgroup           (1).a());\n  EXPECT_EQ(318, message.repeated_nested_message (1).bb());\n  EXPECT_EQ(319, message.repeated_foreign_message(1).c());\n  EXPECT_EQ(320, message.repeated_import_message (1).d());\n  EXPECT_EQ(327, message.repeated_lazy_message   (1).bb());\n\n  EXPECT_EQ(unittest::TestAllTypes::BAZ, message.repeated_nested_enum (1));\n  EXPECT_EQ(unittest::FOREIGN_BAZ      , message.repeated_foreign_enum(1));\n  EXPECT_EQ(unittest_import::IMPORT_BAZ, message.repeated_import_enum (1));\n\n\n  // -----------------------------------------------------------------\n\n  EXPECT_TRUE(message.has_default_int32   ());\n  EXPECT_TRUE(message.has_default_int64   ());\n  EXPECT_TRUE(message.has_default_uint32  ());\n  EXPECT_TRUE(message.has_default_uint64  ());\n  EXPECT_TRUE(message.has_default_sint32  ());\n  EXPECT_TRUE(message.has_default_sint64  ());\n  EXPECT_TRUE(message.has_default_fixed32 ());\n  EXPECT_TRUE(message.has_default_fixed64 ());\n  EXPECT_TRUE(message.has_default_sfixed32());\n  EXPECT_TRUE(message.has_default_sfixed64());\n  EXPECT_TRUE(message.has_default_float   ());\n  EXPECT_TRUE(message.has_default_double  ());\n  EXPECT_TRUE(message.has_default_bool    ());\n  EXPECT_TRUE(message.has_default_string  ());\n  EXPECT_TRUE(message.has_default_bytes   ());\n\n  EXPECT_TRUE(message.has_default_nested_enum ());\n  EXPECT_TRUE(message.has_default_foreign_enum());\n  EXPECT_TRUE(message.has_default_import_enum ());\n\n\n  EXPECT_EQ(401  , message.default_int32   ());\n  EXPECT_EQ(402  , message.default_int64   ());\n  EXPECT_EQ(403  , message.default_uint32  ());\n  EXPECT_EQ(404  , message.default_uint64  ());\n  EXPECT_EQ(405  , message.default_sint32  ());\n  EXPECT_EQ(406  , message.default_sint64  ());\n  EXPECT_EQ(407  , message.default_fixed32 ());\n  EXPECT_EQ(408  , message.default_fixed64 ());\n  EXPECT_EQ(409  , message.default_sfixed32());\n  EXPECT_EQ(410  , message.default_sfixed64());\n  EXPECT_EQ(411  , message.default_float   ());\n  EXPECT_EQ(412  , message.default_double  ());\n  EXPECT_FALSE(    message.default_bool    ());\n  EXPECT_EQ(\"415\", message.default_string  ());\n  EXPECT_EQ(\"416\", message.default_bytes   ());\n\n  EXPECT_EQ(unittest::TestAllTypes::FOO, message.default_nested_enum ());\n  EXPECT_EQ(unittest::FOREIGN_FOO      , message.default_foreign_enum());\n  EXPECT_EQ(unittest_import::IMPORT_FOO, message.default_import_enum ());\n\n\n  EXPECT_FALSE(message.has_oneof_uint32        ());\n  EXPECT_FALSE(message.has_oneof_nested_message());\n  EXPECT_FALSE(message.has_oneof_string        ());\n  EXPECT_TRUE(message.has_oneof_bytes          ());\n\n  EXPECT_EQ(\"604\", message.oneof_bytes());\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::ExpectClear(const unittest::TestAllTypes& message) {\n  // has_blah() should initially be false for all optional fields.\n  EXPECT_FALSE(message.has_optional_int32   ());\n  EXPECT_FALSE(message.has_optional_int64   ());\n  EXPECT_FALSE(message.has_optional_uint32  ());\n  EXPECT_FALSE(message.has_optional_uint64  ());\n  EXPECT_FALSE(message.has_optional_sint32  ());\n  EXPECT_FALSE(message.has_optional_sint64  ());\n  EXPECT_FALSE(message.has_optional_fixed32 ());\n  EXPECT_FALSE(message.has_optional_fixed64 ());\n  EXPECT_FALSE(message.has_optional_sfixed32());\n  EXPECT_FALSE(message.has_optional_sfixed64());\n  EXPECT_FALSE(message.has_optional_float   ());\n  EXPECT_FALSE(message.has_optional_double  ());\n  EXPECT_FALSE(message.has_optional_bool    ());\n  EXPECT_FALSE(message.has_optional_string  ());\n  EXPECT_FALSE(message.has_optional_bytes   ());\n\n  EXPECT_FALSE(message.has_optionalgroup                 ());\n  EXPECT_FALSE(message.has_optional_nested_message       ());\n  EXPECT_FALSE(message.has_optional_foreign_message      ());\n  EXPECT_FALSE(message.has_optional_import_message       ());\n  EXPECT_FALSE(message.has_optional_public_import_message());\n  EXPECT_FALSE(message.has_optional_lazy_message         ());\n\n  EXPECT_FALSE(message.has_optional_nested_enum ());\n  EXPECT_FALSE(message.has_optional_foreign_enum());\n  EXPECT_FALSE(message.has_optional_import_enum ());\n\n  EXPECT_FALSE(message.has_optional_string_piece());\n  EXPECT_FALSE(message.has_optional_cord());\n\n  // Optional fields without defaults are set to zero or something like it.\n  EXPECT_EQ(0    , message.optional_int32   ());\n  EXPECT_EQ(0    , message.optional_int64   ());\n  EXPECT_EQ(0    , message.optional_uint32  ());\n  EXPECT_EQ(0    , message.optional_uint64  ());\n  EXPECT_EQ(0    , message.optional_sint32  ());\n  EXPECT_EQ(0    , message.optional_sint64  ());\n  EXPECT_EQ(0    , message.optional_fixed32 ());\n  EXPECT_EQ(0    , message.optional_fixed64 ());\n  EXPECT_EQ(0    , message.optional_sfixed32());\n  EXPECT_EQ(0    , message.optional_sfixed64());\n  EXPECT_EQ(0    , message.optional_float   ());\n  EXPECT_EQ(0    , message.optional_double  ());\n  EXPECT_FALSE(    message.optional_bool    ());\n  EXPECT_EQ(\"\"   , message.optional_string  ());\n  EXPECT_EQ(\"\"   , message.optional_bytes   ());\n\n  // Embedded messages should also be clear.\n  EXPECT_FALSE(message.optionalgroup                 ().has_a());\n  EXPECT_FALSE(message.optional_nested_message       ().has_bb());\n  EXPECT_FALSE(message.optional_foreign_message      ().has_c());\n  EXPECT_FALSE(message.optional_import_message       ().has_d());\n  EXPECT_FALSE(message.optional_public_import_message().has_e());\n  EXPECT_FALSE(message.optional_lazy_message         ().has_bb());\n\n  EXPECT_EQ(0, message.optionalgroup                 ().a());\n  EXPECT_EQ(0, message.optional_nested_message       ().bb());\n  EXPECT_EQ(0, message.optional_foreign_message      ().c());\n  EXPECT_EQ(0, message.optional_import_message       ().d());\n  EXPECT_EQ(0, message.optional_public_import_message().e());\n  EXPECT_EQ(0, message.optional_lazy_message         ().bb());\n\n  // Enums without defaults are set to the first value in the enum.\n  EXPECT_EQ(unittest::TestAllTypes::FOO, message.optional_nested_enum ());\n  EXPECT_EQ(unittest::FOREIGN_FOO      , message.optional_foreign_enum());\n  EXPECT_EQ(unittest_import::IMPORT_FOO, message.optional_import_enum ());\n\n\n  // Repeated fields are empty.\n  EXPECT_EQ(0, message.repeated_int32_size   ());\n  EXPECT_EQ(0, message.repeated_int64_size   ());\n  EXPECT_EQ(0, message.repeated_uint32_size  ());\n  EXPECT_EQ(0, message.repeated_uint64_size  ());\n  EXPECT_EQ(0, message.repeated_sint32_size  ());\n  EXPECT_EQ(0, message.repeated_sint64_size  ());\n  EXPECT_EQ(0, message.repeated_fixed32_size ());\n  EXPECT_EQ(0, message.repeated_fixed64_size ());\n  EXPECT_EQ(0, message.repeated_sfixed32_size());\n  EXPECT_EQ(0, message.repeated_sfixed64_size());\n  EXPECT_EQ(0, message.repeated_float_size   ());\n  EXPECT_EQ(0, message.repeated_double_size  ());\n  EXPECT_EQ(0, message.repeated_bool_size    ());\n  EXPECT_EQ(0, message.repeated_string_size  ());\n  EXPECT_EQ(0, message.repeated_bytes_size   ());\n\n  EXPECT_EQ(0, message.repeatedgroup_size           ());\n  EXPECT_EQ(0, message.repeated_nested_message_size ());\n  EXPECT_EQ(0, message.repeated_foreign_message_size());\n  EXPECT_EQ(0, message.repeated_import_message_size ());\n  EXPECT_EQ(0, message.repeated_lazy_message_size   ());\n  EXPECT_EQ(0, message.repeated_nested_enum_size    ());\n  EXPECT_EQ(0, message.repeated_foreign_enum_size   ());\n  EXPECT_EQ(0, message.repeated_import_enum_size    ());\n\n  EXPECT_EQ(0, message.repeated_string_piece_size());\n  EXPECT_EQ(0, message.repeated_cord_size());\n\n  // has_blah() should also be false for all default fields.\n  EXPECT_FALSE(message.has_default_int32   ());\n  EXPECT_FALSE(message.has_default_int64   ());\n  EXPECT_FALSE(message.has_default_uint32  ());\n  EXPECT_FALSE(message.has_default_uint64  ());\n  EXPECT_FALSE(message.has_default_sint32  ());\n  EXPECT_FALSE(message.has_default_sint64  ());\n  EXPECT_FALSE(message.has_default_fixed32 ());\n  EXPECT_FALSE(message.has_default_fixed64 ());\n  EXPECT_FALSE(message.has_default_sfixed32());\n  EXPECT_FALSE(message.has_default_sfixed64());\n  EXPECT_FALSE(message.has_default_float   ());\n  EXPECT_FALSE(message.has_default_double  ());\n  EXPECT_FALSE(message.has_default_bool    ());\n  EXPECT_FALSE(message.has_default_string  ());\n  EXPECT_FALSE(message.has_default_bytes   ());\n\n  EXPECT_FALSE(message.has_default_nested_enum ());\n  EXPECT_FALSE(message.has_default_foreign_enum());\n  EXPECT_FALSE(message.has_default_import_enum ());\n\n\n  // Fields with defaults have their default values (duh).\n  EXPECT_EQ( 41    , message.default_int32   ());\n  EXPECT_EQ( 42    , message.default_int64   ());\n  EXPECT_EQ( 43    , message.default_uint32  ());\n  EXPECT_EQ( 44    , message.default_uint64  ());\n  EXPECT_EQ(-45    , message.default_sint32  ());\n  EXPECT_EQ( 46    , message.default_sint64  ());\n  EXPECT_EQ( 47    , message.default_fixed32 ());\n  EXPECT_EQ( 48    , message.default_fixed64 ());\n  EXPECT_EQ( 49    , message.default_sfixed32());\n  EXPECT_EQ(-50    , message.default_sfixed64());\n  EXPECT_EQ( 51.5  , message.default_float   ());\n  EXPECT_EQ( 52e3  , message.default_double  ());\n  EXPECT_TRUE(       message.default_bool    ());\n  EXPECT_EQ(\"hello\", message.default_string  ());\n  EXPECT_EQ(\"world\", message.default_bytes   ());\n\n  EXPECT_EQ(unittest::TestAllTypes::BAR, message.default_nested_enum ());\n  EXPECT_EQ(unittest::FOREIGN_BAR      , message.default_foreign_enum());\n  EXPECT_EQ(unittest_import::IMPORT_BAR, message.default_import_enum ());\n\n\n  EXPECT_FALSE(message.has_oneof_uint32        ());\n  EXPECT_FALSE(message.has_oneof_nested_message());\n  EXPECT_FALSE(message.has_oneof_string        ());\n  EXPECT_FALSE(message.has_oneof_bytes         ());\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::ExpectRepeatedFieldsModified(\n    const unittest::TestAllTypes& message) {\n  // ModifyRepeatedFields only sets the second repeated element of each\n  // field.  In addition to verifying this, we also verify that the first\n  // element and size were *not* modified.\n  ASSERT_EQ(2, message.repeated_int32_size   ());\n  ASSERT_EQ(2, message.repeated_int64_size   ());\n  ASSERT_EQ(2, message.repeated_uint32_size  ());\n  ASSERT_EQ(2, message.repeated_uint64_size  ());\n  ASSERT_EQ(2, message.repeated_sint32_size  ());\n  ASSERT_EQ(2, message.repeated_sint64_size  ());\n  ASSERT_EQ(2, message.repeated_fixed32_size ());\n  ASSERT_EQ(2, message.repeated_fixed64_size ());\n  ASSERT_EQ(2, message.repeated_sfixed32_size());\n  ASSERT_EQ(2, message.repeated_sfixed64_size());\n  ASSERT_EQ(2, message.repeated_float_size   ());\n  ASSERT_EQ(2, message.repeated_double_size  ());\n  ASSERT_EQ(2, message.repeated_bool_size    ());\n  ASSERT_EQ(2, message.repeated_string_size  ());\n  ASSERT_EQ(2, message.repeated_bytes_size   ());\n\n  ASSERT_EQ(2, message.repeatedgroup_size           ());\n  ASSERT_EQ(2, message.repeated_nested_message_size ());\n  ASSERT_EQ(2, message.repeated_foreign_message_size());\n  ASSERT_EQ(2, message.repeated_import_message_size ());\n  ASSERT_EQ(2, message.repeated_lazy_message_size   ());\n  ASSERT_EQ(2, message.repeated_nested_enum_size    ());\n  ASSERT_EQ(2, message.repeated_foreign_enum_size   ());\n  ASSERT_EQ(2, message.repeated_import_enum_size    ());\n\n#ifndef PROTOBUF_TEST_NO_DESCRIPTORS\n  ASSERT_EQ(2, message.repeated_string_piece_size());\n  ASSERT_EQ(2, message.repeated_cord_size());\n#endif\n\n  EXPECT_EQ(201  , message.repeated_int32   (0));\n  EXPECT_EQ(202  , message.repeated_int64   (0));\n  EXPECT_EQ(203  , message.repeated_uint32  (0));\n  EXPECT_EQ(204  , message.repeated_uint64  (0));\n  EXPECT_EQ(205  , message.repeated_sint32  (0));\n  EXPECT_EQ(206  , message.repeated_sint64  (0));\n  EXPECT_EQ(207  , message.repeated_fixed32 (0));\n  EXPECT_EQ(208  , message.repeated_fixed64 (0));\n  EXPECT_EQ(209  , message.repeated_sfixed32(0));\n  EXPECT_EQ(210  , message.repeated_sfixed64(0));\n  EXPECT_EQ(211  , message.repeated_float   (0));\n  EXPECT_EQ(212  , message.repeated_double  (0));\n  EXPECT_TRUE(     message.repeated_bool    (0));\n  EXPECT_EQ(\"215\", message.repeated_string  (0));\n  EXPECT_EQ(\"216\", message.repeated_bytes   (0));\n\n  EXPECT_EQ(217, message.repeatedgroup           (0).a());\n  EXPECT_EQ(218, message.repeated_nested_message (0).bb());\n  EXPECT_EQ(219, message.repeated_foreign_message(0).c());\n  EXPECT_EQ(220, message.repeated_import_message (0).d());\n  EXPECT_EQ(227, message.repeated_lazy_message   (0).bb());\n\n  EXPECT_EQ(unittest::TestAllTypes::BAR, message.repeated_nested_enum (0));\n  EXPECT_EQ(unittest::FOREIGN_BAR      , message.repeated_foreign_enum(0));\n  EXPECT_EQ(unittest_import::IMPORT_BAR, message.repeated_import_enum (0));\n\n\n  // Actually verify the second (modified) elements now.\n  EXPECT_EQ(501  , message.repeated_int32   (1));\n  EXPECT_EQ(502  , message.repeated_int64   (1));\n  EXPECT_EQ(503  , message.repeated_uint32  (1));\n  EXPECT_EQ(504  , message.repeated_uint64  (1));\n  EXPECT_EQ(505  , message.repeated_sint32  (1));\n  EXPECT_EQ(506  , message.repeated_sint64  (1));\n  EXPECT_EQ(507  , message.repeated_fixed32 (1));\n  EXPECT_EQ(508  , message.repeated_fixed64 (1));\n  EXPECT_EQ(509  , message.repeated_sfixed32(1));\n  EXPECT_EQ(510  , message.repeated_sfixed64(1));\n  EXPECT_EQ(511  , message.repeated_float   (1));\n  EXPECT_EQ(512  , message.repeated_double  (1));\n  EXPECT_TRUE(     message.repeated_bool    (1));\n  EXPECT_EQ(\"515\", message.repeated_string  (1));\n  EXPECT_EQ(\"516\", message.repeated_bytes   (1));\n\n  EXPECT_EQ(517, message.repeatedgroup           (1).a());\n  EXPECT_EQ(518, message.repeated_nested_message (1).bb());\n  EXPECT_EQ(519, message.repeated_foreign_message(1).c());\n  EXPECT_EQ(520, message.repeated_import_message (1).d());\n  EXPECT_EQ(527, message.repeated_lazy_message   (1).bb());\n\n  EXPECT_EQ(unittest::TestAllTypes::FOO, message.repeated_nested_enum (1));\n  EXPECT_EQ(unittest::FOREIGN_FOO      , message.repeated_foreign_enum(1));\n  EXPECT_EQ(unittest_import::IMPORT_FOO, message.repeated_import_enum (1));\n\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::SetPackedFields(unittest::TestPackedTypes* message) {\n  message->add_packed_int32   (601);\n  message->add_packed_int64   (602);\n  message->add_packed_uint32  (603);\n  message->add_packed_uint64  (604);\n  message->add_packed_sint32  (605);\n  message->add_packed_sint64  (606);\n  message->add_packed_fixed32 (607);\n  message->add_packed_fixed64 (608);\n  message->add_packed_sfixed32(609);\n  message->add_packed_sfixed64(610);\n  message->add_packed_float   (611);\n  message->add_packed_double  (612);\n  message->add_packed_bool    (true);\n  message->add_packed_enum    (unittest::FOREIGN_BAR);\n  // add a second one of each field\n  message->add_packed_int32   (701);\n  message->add_packed_int64   (702);\n  message->add_packed_uint32  (703);\n  message->add_packed_uint64  (704);\n  message->add_packed_sint32  (705);\n  message->add_packed_sint64  (706);\n  message->add_packed_fixed32 (707);\n  message->add_packed_fixed64 (708);\n  message->add_packed_sfixed32(709);\n  message->add_packed_sfixed64(710);\n  message->add_packed_float   (711);\n  message->add_packed_double  (712);\n  message->add_packed_bool    (false);\n  message->add_packed_enum    (unittest::FOREIGN_BAZ);\n}\n\nvoid TestUtil::SetUnpackedFields(unittest::TestUnpackedTypes* message) {\n  // The values applied here must match those of SetPackedFields.\n\n  message->add_unpacked_int32   (601);\n  message->add_unpacked_int64   (602);\n  message->add_unpacked_uint32  (603);\n  message->add_unpacked_uint64  (604);\n  message->add_unpacked_sint32  (605);\n  message->add_unpacked_sint64  (606);\n  message->add_unpacked_fixed32 (607);\n  message->add_unpacked_fixed64 (608);\n  message->add_unpacked_sfixed32(609);\n  message->add_unpacked_sfixed64(610);\n  message->add_unpacked_float   (611);\n  message->add_unpacked_double  (612);\n  message->add_unpacked_bool    (true);\n  message->add_unpacked_enum    (unittest::FOREIGN_BAR);\n  // add a second one of each field\n  message->add_unpacked_int32   (701);\n  message->add_unpacked_int64   (702);\n  message->add_unpacked_uint32  (703);\n  message->add_unpacked_uint64  (704);\n  message->add_unpacked_sint32  (705);\n  message->add_unpacked_sint64  (706);\n  message->add_unpacked_fixed32 (707);\n  message->add_unpacked_fixed64 (708);\n  message->add_unpacked_sfixed32(709);\n  message->add_unpacked_sfixed64(710);\n  message->add_unpacked_float   (711);\n  message->add_unpacked_double  (712);\n  message->add_unpacked_bool    (false);\n  message->add_unpacked_enum    (unittest::FOREIGN_BAZ);\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::ModifyPackedFields(unittest::TestPackedTypes* message) {\n  message->set_packed_int32   (1, 801);\n  message->set_packed_int64   (1, 802);\n  message->set_packed_uint32  (1, 803);\n  message->set_packed_uint64  (1, 804);\n  message->set_packed_sint32  (1, 805);\n  message->set_packed_sint64  (1, 806);\n  message->set_packed_fixed32 (1, 807);\n  message->set_packed_fixed64 (1, 808);\n  message->set_packed_sfixed32(1, 809);\n  message->set_packed_sfixed64(1, 810);\n  message->set_packed_float   (1, 811);\n  message->set_packed_double  (1, 812);\n  message->set_packed_bool    (1, true);\n  message->set_packed_enum    (1, unittest::FOREIGN_FOO);\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::ExpectPackedFieldsSet(const unittest::TestPackedTypes& message) {\n  ASSERT_EQ(2, message.packed_int32_size   ());\n  ASSERT_EQ(2, message.packed_int64_size   ());\n  ASSERT_EQ(2, message.packed_uint32_size  ());\n  ASSERT_EQ(2, message.packed_uint64_size  ());\n  ASSERT_EQ(2, message.packed_sint32_size  ());\n  ASSERT_EQ(2, message.packed_sint64_size  ());\n  ASSERT_EQ(2, message.packed_fixed32_size ());\n  ASSERT_EQ(2, message.packed_fixed64_size ());\n  ASSERT_EQ(2, message.packed_sfixed32_size());\n  ASSERT_EQ(2, message.packed_sfixed64_size());\n  ASSERT_EQ(2, message.packed_float_size   ());\n  ASSERT_EQ(2, message.packed_double_size  ());\n  ASSERT_EQ(2, message.packed_bool_size    ());\n  ASSERT_EQ(2, message.packed_enum_size    ());\n\n  EXPECT_EQ(601  , message.packed_int32   (0));\n  EXPECT_EQ(602  , message.packed_int64   (0));\n  EXPECT_EQ(603  , message.packed_uint32  (0));\n  EXPECT_EQ(604  , message.packed_uint64  (0));\n  EXPECT_EQ(605  , message.packed_sint32  (0));\n  EXPECT_EQ(606  , message.packed_sint64  (0));\n  EXPECT_EQ(607  , message.packed_fixed32 (0));\n  EXPECT_EQ(608  , message.packed_fixed64 (0));\n  EXPECT_EQ(609  , message.packed_sfixed32(0));\n  EXPECT_EQ(610  , message.packed_sfixed64(0));\n  EXPECT_EQ(611  , message.packed_float   (0));\n  EXPECT_EQ(612  , message.packed_double  (0));\n  EXPECT_TRUE(     message.packed_bool    (0));\n  EXPECT_EQ(unittest::FOREIGN_BAR, message.packed_enum(0));\n\n  EXPECT_EQ(701  , message.packed_int32   (1));\n  EXPECT_EQ(702  , message.packed_int64   (1));\n  EXPECT_EQ(703  , message.packed_uint32  (1));\n  EXPECT_EQ(704  , message.packed_uint64  (1));\n  EXPECT_EQ(705  , message.packed_sint32  (1));\n  EXPECT_EQ(706  , message.packed_sint64  (1));\n  EXPECT_EQ(707  , message.packed_fixed32 (1));\n  EXPECT_EQ(708  , message.packed_fixed64 (1));\n  EXPECT_EQ(709  , message.packed_sfixed32(1));\n  EXPECT_EQ(710  , message.packed_sfixed64(1));\n  EXPECT_EQ(711  , message.packed_float   (1));\n  EXPECT_EQ(712  , message.packed_double  (1));\n  EXPECT_FALSE(    message.packed_bool    (1));\n  EXPECT_EQ(unittest::FOREIGN_BAZ, message.packed_enum(1));\n}\n\nvoid TestUtil::ExpectUnpackedFieldsSet(\n    const unittest::TestUnpackedTypes& message) {\n  // The values expected here must match those of ExpectPackedFieldsSet.\n\n  ASSERT_EQ(2, message.unpacked_int32_size   ());\n  ASSERT_EQ(2, message.unpacked_int64_size   ());\n  ASSERT_EQ(2, message.unpacked_uint32_size  ());\n  ASSERT_EQ(2, message.unpacked_uint64_size  ());\n  ASSERT_EQ(2, message.unpacked_sint32_size  ());\n  ASSERT_EQ(2, message.unpacked_sint64_size  ());\n  ASSERT_EQ(2, message.unpacked_fixed32_size ());\n  ASSERT_EQ(2, message.unpacked_fixed64_size ());\n  ASSERT_EQ(2, message.unpacked_sfixed32_size());\n  ASSERT_EQ(2, message.unpacked_sfixed64_size());\n  ASSERT_EQ(2, message.unpacked_float_size   ());\n  ASSERT_EQ(2, message.unpacked_double_size  ());\n  ASSERT_EQ(2, message.unpacked_bool_size    ());\n  ASSERT_EQ(2, message.unpacked_enum_size    ());\n\n  EXPECT_EQ(601  , message.unpacked_int32   (0));\n  EXPECT_EQ(602  , message.unpacked_int64   (0));\n  EXPECT_EQ(603  , message.unpacked_uint32  (0));\n  EXPECT_EQ(604  , message.unpacked_uint64  (0));\n  EXPECT_EQ(605  , message.unpacked_sint32  (0));\n  EXPECT_EQ(606  , message.unpacked_sint64  (0));\n  EXPECT_EQ(607  , message.unpacked_fixed32 (0));\n  EXPECT_EQ(608  , message.unpacked_fixed64 (0));\n  EXPECT_EQ(609  , message.unpacked_sfixed32(0));\n  EXPECT_EQ(610  , message.unpacked_sfixed64(0));\n  EXPECT_EQ(611  , message.unpacked_float   (0));\n  EXPECT_EQ(612  , message.unpacked_double  (0));\n  EXPECT_TRUE(     message.unpacked_bool    (0));\n  EXPECT_EQ(unittest::FOREIGN_BAR, message.unpacked_enum(0));\n\n  EXPECT_EQ(701  , message.unpacked_int32   (1));\n  EXPECT_EQ(702  , message.unpacked_int64   (1));\n  EXPECT_EQ(703  , message.unpacked_uint32  (1));\n  EXPECT_EQ(704  , message.unpacked_uint64  (1));\n  EXPECT_EQ(705  , message.unpacked_sint32  (1));\n  EXPECT_EQ(706  , message.unpacked_sint64  (1));\n  EXPECT_EQ(707  , message.unpacked_fixed32 (1));\n  EXPECT_EQ(708  , message.unpacked_fixed64 (1));\n  EXPECT_EQ(709  , message.unpacked_sfixed32(1));\n  EXPECT_EQ(710  , message.unpacked_sfixed64(1));\n  EXPECT_EQ(711  , message.unpacked_float   (1));\n  EXPECT_EQ(712  , message.unpacked_double  (1));\n  EXPECT_FALSE(    message.unpacked_bool    (1));\n  EXPECT_EQ(unittest::FOREIGN_BAZ, message.unpacked_enum(1));\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::ExpectPackedClear(\n    const unittest::TestPackedTypes& message) {\n  // Packed repeated fields are empty.\n  EXPECT_EQ(0, message.packed_int32_size   ());\n  EXPECT_EQ(0, message.packed_int64_size   ());\n  EXPECT_EQ(0, message.packed_uint32_size  ());\n  EXPECT_EQ(0, message.packed_uint64_size  ());\n  EXPECT_EQ(0, message.packed_sint32_size  ());\n  EXPECT_EQ(0, message.packed_sint64_size  ());\n  EXPECT_EQ(0, message.packed_fixed32_size ());\n  EXPECT_EQ(0, message.packed_fixed64_size ());\n  EXPECT_EQ(0, message.packed_sfixed32_size());\n  EXPECT_EQ(0, message.packed_sfixed64_size());\n  EXPECT_EQ(0, message.packed_float_size   ());\n  EXPECT_EQ(0, message.packed_double_size  ());\n  EXPECT_EQ(0, message.packed_bool_size    ());\n  EXPECT_EQ(0, message.packed_enum_size    ());\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::ExpectPackedFieldsModified(\n    const unittest::TestPackedTypes& message) {\n  // Do the same for packed repeated fields.\n  ASSERT_EQ(2, message.packed_int32_size   ());\n  ASSERT_EQ(2, message.packed_int64_size   ());\n  ASSERT_EQ(2, message.packed_uint32_size  ());\n  ASSERT_EQ(2, message.packed_uint64_size  ());\n  ASSERT_EQ(2, message.packed_sint32_size  ());\n  ASSERT_EQ(2, message.packed_sint64_size  ());\n  ASSERT_EQ(2, message.packed_fixed32_size ());\n  ASSERT_EQ(2, message.packed_fixed64_size ());\n  ASSERT_EQ(2, message.packed_sfixed32_size());\n  ASSERT_EQ(2, message.packed_sfixed64_size());\n  ASSERT_EQ(2, message.packed_float_size   ());\n  ASSERT_EQ(2, message.packed_double_size  ());\n  ASSERT_EQ(2, message.packed_bool_size    ());\n  ASSERT_EQ(2, message.packed_enum_size    ());\n\n  EXPECT_EQ(601  , message.packed_int32   (0));\n  EXPECT_EQ(602  , message.packed_int64   (0));\n  EXPECT_EQ(603  , message.packed_uint32  (0));\n  EXPECT_EQ(604  , message.packed_uint64  (0));\n  EXPECT_EQ(605  , message.packed_sint32  (0));\n  EXPECT_EQ(606  , message.packed_sint64  (0));\n  EXPECT_EQ(607  , message.packed_fixed32 (0));\n  EXPECT_EQ(608  , message.packed_fixed64 (0));\n  EXPECT_EQ(609  , message.packed_sfixed32(0));\n  EXPECT_EQ(610  , message.packed_sfixed64(0));\n  EXPECT_EQ(611  , message.packed_float   (0));\n  EXPECT_EQ(612  , message.packed_double  (0));\n  EXPECT_TRUE(     message.packed_bool    (0));\n  EXPECT_EQ(unittest::FOREIGN_BAR, message.packed_enum(0));\n  // Actually verify the second (modified) elements now.\n  EXPECT_EQ(801  , message.packed_int32   (1));\n  EXPECT_EQ(802  , message.packed_int64   (1));\n  EXPECT_EQ(803  , message.packed_uint32  (1));\n  EXPECT_EQ(804  , message.packed_uint64  (1));\n  EXPECT_EQ(805  , message.packed_sint32  (1));\n  EXPECT_EQ(806  , message.packed_sint64  (1));\n  EXPECT_EQ(807  , message.packed_fixed32 (1));\n  EXPECT_EQ(808  , message.packed_fixed64 (1));\n  EXPECT_EQ(809  , message.packed_sfixed32(1));\n  EXPECT_EQ(810  , message.packed_sfixed64(1));\n  EXPECT_EQ(811  , message.packed_float   (1));\n  EXPECT_EQ(812  , message.packed_double  (1));\n  EXPECT_TRUE(     message.packed_bool    (1));\n  EXPECT_EQ(unittest::FOREIGN_FOO, message.packed_enum(1));\n}\n\n// ===================================================================\n// Extensions\n//\n// All this code is exactly equivalent to the above code except that it's\n// manipulating extension fields instead of normal ones.\n//\n// I gave up on the 80-char limit here.  Sorry.\n\nvoid TestUtil::SetAllExtensions(unittest::TestAllExtensions* message) {\n  message->SetExtension(unittest::optional_int32_extension   , 101);\n  message->SetExtension(unittest::optional_int64_extension   , 102);\n  message->SetExtension(unittest::optional_uint32_extension  , 103);\n  message->SetExtension(unittest::optional_uint64_extension  , 104);\n  message->SetExtension(unittest::optional_sint32_extension  , 105);\n  message->SetExtension(unittest::optional_sint64_extension  , 106);\n  message->SetExtension(unittest::optional_fixed32_extension , 107);\n  message->SetExtension(unittest::optional_fixed64_extension , 108);\n  message->SetExtension(unittest::optional_sfixed32_extension, 109);\n  message->SetExtension(unittest::optional_sfixed64_extension, 110);\n  message->SetExtension(unittest::optional_float_extension   , 111);\n  message->SetExtension(unittest::optional_double_extension  , 112);\n  message->SetExtension(unittest::optional_bool_extension    , true);\n  message->SetExtension(unittest::optional_string_extension  , \"115\");\n  message->SetExtension(unittest::optional_bytes_extension   , \"116\");\n\n  message->MutableExtension(unittest::optionalgroup_extension           )->set_a(117);\n  message->MutableExtension(unittest::optional_nested_message_extension )->set_bb(118);\n  message->MutableExtension(unittest::optional_foreign_message_extension)->set_c(119);\n  message->MutableExtension(unittest::optional_import_message_extension )->set_d(120);\n\n  message->SetExtension(unittest::optional_nested_enum_extension , unittest::TestAllTypes::BAZ);\n  message->SetExtension(unittest::optional_foreign_enum_extension, unittest::FOREIGN_BAZ      );\n  message->SetExtension(unittest::optional_import_enum_extension , unittest_import::IMPORT_BAZ);\n\n  message->SetExtension(unittest::optional_string_piece_extension, \"124\");\n  message->SetExtension(unittest::optional_cord_extension, \"125\");\n\n  message->MutableExtension(unittest::optional_public_import_message_extension)->set_e(126);\n  message->MutableExtension(unittest::optional_lazy_message_extension)->set_bb(127);\n\n  // -----------------------------------------------------------------\n\n  message->AddExtension(unittest::repeated_int32_extension   , 201);\n  message->AddExtension(unittest::repeated_int64_extension   , 202);\n  message->AddExtension(unittest::repeated_uint32_extension  , 203);\n  message->AddExtension(unittest::repeated_uint64_extension  , 204);\n  message->AddExtension(unittest::repeated_sint32_extension  , 205);\n  message->AddExtension(unittest::repeated_sint64_extension  , 206);\n  message->AddExtension(unittest::repeated_fixed32_extension , 207);\n  message->AddExtension(unittest::repeated_fixed64_extension , 208);\n  message->AddExtension(unittest::repeated_sfixed32_extension, 209);\n  message->AddExtension(unittest::repeated_sfixed64_extension, 210);\n  message->AddExtension(unittest::repeated_float_extension   , 211);\n  message->AddExtension(unittest::repeated_double_extension  , 212);\n  message->AddExtension(unittest::repeated_bool_extension    , true);\n  message->AddExtension(unittest::repeated_string_extension  , \"215\");\n  message->AddExtension(unittest::repeated_bytes_extension   , \"216\");\n\n  message->AddExtension(unittest::repeatedgroup_extension           )->set_a(217);\n  message->AddExtension(unittest::repeated_nested_message_extension )->set_bb(218);\n  message->AddExtension(unittest::repeated_foreign_message_extension)->set_c(219);\n  message->AddExtension(unittest::repeated_import_message_extension )->set_d(220);\n  message->AddExtension(unittest::repeated_lazy_message_extension   )->set_bb(227);\n\n  message->AddExtension(unittest::repeated_nested_enum_extension , unittest::TestAllTypes::BAR);\n  message->AddExtension(unittest::repeated_foreign_enum_extension, unittest::FOREIGN_BAR      );\n  message->AddExtension(unittest::repeated_import_enum_extension , unittest_import::IMPORT_BAR);\n\n  message->AddExtension(unittest::repeated_string_piece_extension, \"224\");\n  message->AddExtension(unittest::repeated_cord_extension, \"225\");\n\n  // Add a second one of each field.\n  message->AddExtension(unittest::repeated_int32_extension   , 301);\n  message->AddExtension(unittest::repeated_int64_extension   , 302);\n  message->AddExtension(unittest::repeated_uint32_extension  , 303);\n  message->AddExtension(unittest::repeated_uint64_extension  , 304);\n  message->AddExtension(unittest::repeated_sint32_extension  , 305);\n  message->AddExtension(unittest::repeated_sint64_extension  , 306);\n  message->AddExtension(unittest::repeated_fixed32_extension , 307);\n  message->AddExtension(unittest::repeated_fixed64_extension , 308);\n  message->AddExtension(unittest::repeated_sfixed32_extension, 309);\n  message->AddExtension(unittest::repeated_sfixed64_extension, 310);\n  message->AddExtension(unittest::repeated_float_extension   , 311);\n  message->AddExtension(unittest::repeated_double_extension  , 312);\n  message->AddExtension(unittest::repeated_bool_extension    , false);\n  message->AddExtension(unittest::repeated_string_extension  , \"315\");\n  message->AddExtension(unittest::repeated_bytes_extension   , \"316\");\n\n  message->AddExtension(unittest::repeatedgroup_extension           )->set_a(317);\n  message->AddExtension(unittest::repeated_nested_message_extension )->set_bb(318);\n  message->AddExtension(unittest::repeated_foreign_message_extension)->set_c(319);\n  message->AddExtension(unittest::repeated_import_message_extension )->set_d(320);\n  message->AddExtension(unittest::repeated_lazy_message_extension   )->set_bb(327);\n\n  message->AddExtension(unittest::repeated_nested_enum_extension , unittest::TestAllTypes::BAZ);\n  message->AddExtension(unittest::repeated_foreign_enum_extension, unittest::FOREIGN_BAZ      );\n  message->AddExtension(unittest::repeated_import_enum_extension , unittest_import::IMPORT_BAZ);\n\n  message->AddExtension(unittest::repeated_string_piece_extension, \"324\");\n  message->AddExtension(unittest::repeated_cord_extension, \"325\");\n\n  // -----------------------------------------------------------------\n\n  message->SetExtension(unittest::default_int32_extension   , 401);\n  message->SetExtension(unittest::default_int64_extension   , 402);\n  message->SetExtension(unittest::default_uint32_extension  , 403);\n  message->SetExtension(unittest::default_uint64_extension  , 404);\n  message->SetExtension(unittest::default_sint32_extension  , 405);\n  message->SetExtension(unittest::default_sint64_extension  , 406);\n  message->SetExtension(unittest::default_fixed32_extension , 407);\n  message->SetExtension(unittest::default_fixed64_extension , 408);\n  message->SetExtension(unittest::default_sfixed32_extension, 409);\n  message->SetExtension(unittest::default_sfixed64_extension, 410);\n  message->SetExtension(unittest::default_float_extension   , 411);\n  message->SetExtension(unittest::default_double_extension  , 412);\n  message->SetExtension(unittest::default_bool_extension    , false);\n  message->SetExtension(unittest::default_string_extension  , \"415\");\n  message->SetExtension(unittest::default_bytes_extension   , \"416\");\n\n  message->SetExtension(unittest::default_nested_enum_extension , unittest::TestAllTypes::FOO);\n  message->SetExtension(unittest::default_foreign_enum_extension, unittest::FOREIGN_FOO      );\n  message->SetExtension(unittest::default_import_enum_extension , unittest_import::IMPORT_FOO);\n\n  message->SetExtension(unittest::default_string_piece_extension, \"424\");\n  message->SetExtension(unittest::default_cord_extension, \"425\");\n\n  SetOneofFields(message);\n}\n\nvoid TestUtil::SetOneofFields(unittest::TestAllExtensions* message) {\n  message->SetExtension(unittest::oneof_uint32_extension, 601);\n  message->MutableExtension(unittest::oneof_nested_message_extension)->set_bb(602);\n  message->SetExtension(unittest::oneof_string_extension, \"603\");\n  message->SetExtension(unittest::oneof_bytes_extension, \"604\");\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::SetAllFieldsAndExtensions(\n    unittest::TestFieldOrderings* message) {\n  GOOGLE_CHECK(message);\n  message->set_my_int(1);\n  message->set_my_string(\"foo\");\n  message->set_my_float(1.0);\n  message->SetExtension(unittest::my_extension_int, 23);\n  message->SetExtension(unittest::my_extension_string, \"bar\");\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::ModifyRepeatedExtensions(unittest::TestAllExtensions* message) {\n  message->SetExtension(unittest::repeated_int32_extension   , 1, 501);\n  message->SetExtension(unittest::repeated_int64_extension   , 1, 502);\n  message->SetExtension(unittest::repeated_uint32_extension  , 1, 503);\n  message->SetExtension(unittest::repeated_uint64_extension  , 1, 504);\n  message->SetExtension(unittest::repeated_sint32_extension  , 1, 505);\n  message->SetExtension(unittest::repeated_sint64_extension  , 1, 506);\n  message->SetExtension(unittest::repeated_fixed32_extension , 1, 507);\n  message->SetExtension(unittest::repeated_fixed64_extension , 1, 508);\n  message->SetExtension(unittest::repeated_sfixed32_extension, 1, 509);\n  message->SetExtension(unittest::repeated_sfixed64_extension, 1, 510);\n  message->SetExtension(unittest::repeated_float_extension   , 1, 511);\n  message->SetExtension(unittest::repeated_double_extension  , 1, 512);\n  message->SetExtension(unittest::repeated_bool_extension    , 1, true);\n  message->SetExtension(unittest::repeated_string_extension  , 1, \"515\");\n  message->SetExtension(unittest::repeated_bytes_extension   , 1, \"516\");\n\n  message->MutableExtension(unittest::repeatedgroup_extension           , 1)->set_a(517);\n  message->MutableExtension(unittest::repeated_nested_message_extension , 1)->set_bb(518);\n  message->MutableExtension(unittest::repeated_foreign_message_extension, 1)->set_c(519);\n  message->MutableExtension(unittest::repeated_import_message_extension , 1)->set_d(520);\n  message->MutableExtension(unittest::repeated_lazy_message_extension   , 1)->set_bb(527);\n\n  message->SetExtension(unittest::repeated_nested_enum_extension , 1, unittest::TestAllTypes::FOO);\n  message->SetExtension(unittest::repeated_foreign_enum_extension, 1, unittest::FOREIGN_FOO      );\n  message->SetExtension(unittest::repeated_import_enum_extension , 1, unittest_import::IMPORT_FOO);\n\n  message->SetExtension(unittest::repeated_string_piece_extension, 1, \"524\");\n  message->SetExtension(unittest::repeated_cord_extension, 1, \"525\");\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::ExpectAllExtensionsSet(\n    const unittest::TestAllExtensions& message) {\n  EXPECT_TRUE(message.HasExtension(unittest::optional_int32_extension   ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_int64_extension   ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_uint32_extension  ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_uint64_extension  ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_sint32_extension  ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_sint64_extension  ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_fixed32_extension ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_fixed64_extension ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_sfixed32_extension));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_sfixed64_extension));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_float_extension   ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_double_extension  ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_bool_extension    ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_string_extension  ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_bytes_extension   ));\n\n  EXPECT_TRUE(message.HasExtension(unittest::optionalgroup_extension                 ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_nested_message_extension       ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_foreign_message_extension      ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_import_message_extension       ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_public_import_message_extension));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_lazy_message_extension         ));\n\n  EXPECT_TRUE(message.GetExtension(unittest::optionalgroup_extension                 ).has_a());\n  EXPECT_TRUE(message.GetExtension(unittest::optional_nested_message_extension       ).has_bb());\n  EXPECT_TRUE(message.GetExtension(unittest::optional_foreign_message_extension      ).has_c());\n  EXPECT_TRUE(message.GetExtension(unittest::optional_import_message_extension       ).has_d());\n  EXPECT_TRUE(message.GetExtension(unittest::optional_public_import_message_extension).has_e());\n  EXPECT_TRUE(message.GetExtension(unittest::optional_lazy_message_extension         ).has_bb());\n\n  EXPECT_TRUE(message.HasExtension(unittest::optional_nested_enum_extension ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_foreign_enum_extension));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_import_enum_extension ));\n\n  EXPECT_TRUE(message.HasExtension(unittest::optional_string_piece_extension));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_cord_extension));\n\n  EXPECT_EQ(101  , message.GetExtension(unittest::optional_int32_extension   ));\n  EXPECT_EQ(102  , message.GetExtension(unittest::optional_int64_extension   ));\n  EXPECT_EQ(103  , message.GetExtension(unittest::optional_uint32_extension  ));\n  EXPECT_EQ(104  , message.GetExtension(unittest::optional_uint64_extension  ));\n  EXPECT_EQ(105  , message.GetExtension(unittest::optional_sint32_extension  ));\n  EXPECT_EQ(106  , message.GetExtension(unittest::optional_sint64_extension  ));\n  EXPECT_EQ(107  , message.GetExtension(unittest::optional_fixed32_extension ));\n  EXPECT_EQ(108  , message.GetExtension(unittest::optional_fixed64_extension ));\n  EXPECT_EQ(109  , message.GetExtension(unittest::optional_sfixed32_extension));\n  EXPECT_EQ(110  , message.GetExtension(unittest::optional_sfixed64_extension));\n  EXPECT_EQ(111  , message.GetExtension(unittest::optional_float_extension   ));\n  EXPECT_EQ(112  , message.GetExtension(unittest::optional_double_extension  ));\n  EXPECT_TRUE(     message.GetExtension(unittest::optional_bool_extension    ));\n  EXPECT_EQ(\"115\", message.GetExtension(unittest::optional_string_extension  ));\n  EXPECT_EQ(\"116\", message.GetExtension(unittest::optional_bytes_extension   ));\n\n  EXPECT_EQ(117, message.GetExtension(unittest::optionalgroup_extension           ).a());\n  EXPECT_EQ(118, message.GetExtension(unittest::optional_nested_message_extension ).bb());\n  EXPECT_EQ(119, message.GetExtension(unittest::optional_foreign_message_extension).c());\n  EXPECT_EQ(120, message.GetExtension(unittest::optional_import_message_extension ).d());\n\n  EXPECT_EQ(unittest::TestAllTypes::BAZ, message.GetExtension(unittest::optional_nested_enum_extension ));\n  EXPECT_EQ(unittest::FOREIGN_BAZ      , message.GetExtension(unittest::optional_foreign_enum_extension));\n  EXPECT_EQ(unittest_import::IMPORT_BAZ, message.GetExtension(unittest::optional_import_enum_extension ));\n\n  EXPECT_EQ(\"124\", message.GetExtension(unittest::optional_string_piece_extension));\n  EXPECT_EQ(\"125\", message.GetExtension(unittest::optional_cord_extension));\n  EXPECT_EQ(126, message.GetExtension(unittest::optional_public_import_message_extension ).e());\n  EXPECT_EQ(127, message.GetExtension(unittest::optional_lazy_message_extension).bb());\n\n  // -----------------------------------------------------------------\n\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_int32_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_int64_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_uint32_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_uint64_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sint32_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sint64_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_fixed32_extension ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_fixed64_extension ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sfixed32_extension));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sfixed64_extension));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_float_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_double_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_bool_extension    ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_string_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_bytes_extension   ));\n\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeatedgroup_extension           ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_nested_message_extension ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_foreign_message_extension));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_import_message_extension ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_lazy_message_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_nested_enum_extension    ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_foreign_enum_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_import_enum_extension    ));\n\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_string_piece_extension));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_cord_extension));\n\n  EXPECT_EQ(201  , message.GetExtension(unittest::repeated_int32_extension   , 0));\n  EXPECT_EQ(202  , message.GetExtension(unittest::repeated_int64_extension   , 0));\n  EXPECT_EQ(203  , message.GetExtension(unittest::repeated_uint32_extension  , 0));\n  EXPECT_EQ(204  , message.GetExtension(unittest::repeated_uint64_extension  , 0));\n  EXPECT_EQ(205  , message.GetExtension(unittest::repeated_sint32_extension  , 0));\n  EXPECT_EQ(206  , message.GetExtension(unittest::repeated_sint64_extension  , 0));\n  EXPECT_EQ(207  , message.GetExtension(unittest::repeated_fixed32_extension , 0));\n  EXPECT_EQ(208  , message.GetExtension(unittest::repeated_fixed64_extension , 0));\n  EXPECT_EQ(209  , message.GetExtension(unittest::repeated_sfixed32_extension, 0));\n  EXPECT_EQ(210  , message.GetExtension(unittest::repeated_sfixed64_extension, 0));\n  EXPECT_EQ(211  , message.GetExtension(unittest::repeated_float_extension   , 0));\n  EXPECT_EQ(212  , message.GetExtension(unittest::repeated_double_extension  , 0));\n  EXPECT_TRUE(     message.GetExtension(unittest::repeated_bool_extension    , 0));\n  EXPECT_EQ(\"215\", message.GetExtension(unittest::repeated_string_extension  , 0));\n  EXPECT_EQ(\"216\", message.GetExtension(unittest::repeated_bytes_extension   , 0));\n\n  EXPECT_EQ(217, message.GetExtension(unittest::repeatedgroup_extension           , 0).a());\n  EXPECT_EQ(218, message.GetExtension(unittest::repeated_nested_message_extension , 0).bb());\n  EXPECT_EQ(219, message.GetExtension(unittest::repeated_foreign_message_extension, 0).c());\n  EXPECT_EQ(220, message.GetExtension(unittest::repeated_import_message_extension , 0).d());\n  EXPECT_EQ(227, message.GetExtension(unittest::repeated_lazy_message_extension   , 0).bb());\n\n  EXPECT_EQ(unittest::TestAllTypes::BAR, message.GetExtension(unittest::repeated_nested_enum_extension , 0));\n  EXPECT_EQ(unittest::FOREIGN_BAR      , message.GetExtension(unittest::repeated_foreign_enum_extension, 0));\n  EXPECT_EQ(unittest_import::IMPORT_BAR, message.GetExtension(unittest::repeated_import_enum_extension , 0));\n\n  EXPECT_EQ(\"224\", message.GetExtension(unittest::repeated_string_piece_extension, 0));\n  EXPECT_EQ(\"225\", message.GetExtension(unittest::repeated_cord_extension, 0));\n\n  EXPECT_EQ(301  , message.GetExtension(unittest::repeated_int32_extension   , 1));\n  EXPECT_EQ(302  , message.GetExtension(unittest::repeated_int64_extension   , 1));\n  EXPECT_EQ(303  , message.GetExtension(unittest::repeated_uint32_extension  , 1));\n  EXPECT_EQ(304  , message.GetExtension(unittest::repeated_uint64_extension  , 1));\n  EXPECT_EQ(305  , message.GetExtension(unittest::repeated_sint32_extension  , 1));\n  EXPECT_EQ(306  , message.GetExtension(unittest::repeated_sint64_extension  , 1));\n  EXPECT_EQ(307  , message.GetExtension(unittest::repeated_fixed32_extension , 1));\n  EXPECT_EQ(308  , message.GetExtension(unittest::repeated_fixed64_extension , 1));\n  EXPECT_EQ(309  , message.GetExtension(unittest::repeated_sfixed32_extension, 1));\n  EXPECT_EQ(310  , message.GetExtension(unittest::repeated_sfixed64_extension, 1));\n  EXPECT_EQ(311  , message.GetExtension(unittest::repeated_float_extension   , 1));\n  EXPECT_EQ(312  , message.GetExtension(unittest::repeated_double_extension  , 1));\n  EXPECT_FALSE(    message.GetExtension(unittest::repeated_bool_extension    , 1));\n  EXPECT_EQ(\"315\", message.GetExtension(unittest::repeated_string_extension  , 1));\n  EXPECT_EQ(\"316\", message.GetExtension(unittest::repeated_bytes_extension   , 1));\n\n  EXPECT_EQ(317, message.GetExtension(unittest::repeatedgroup_extension           , 1).a());\n  EXPECT_EQ(318, message.GetExtension(unittest::repeated_nested_message_extension , 1).bb());\n  EXPECT_EQ(319, message.GetExtension(unittest::repeated_foreign_message_extension, 1).c());\n  EXPECT_EQ(320, message.GetExtension(unittest::repeated_import_message_extension , 1).d());\n  EXPECT_EQ(327, message.GetExtension(unittest::repeated_lazy_message_extension   , 1).bb());\n\n  EXPECT_EQ(unittest::TestAllTypes::BAZ, message.GetExtension(unittest::repeated_nested_enum_extension , 1));\n  EXPECT_EQ(unittest::FOREIGN_BAZ      , message.GetExtension(unittest::repeated_foreign_enum_extension, 1));\n  EXPECT_EQ(unittest_import::IMPORT_BAZ, message.GetExtension(unittest::repeated_import_enum_extension , 1));\n\n  EXPECT_EQ(\"324\", message.GetExtension(unittest::repeated_string_piece_extension, 1));\n  EXPECT_EQ(\"325\", message.GetExtension(unittest::repeated_cord_extension, 1));\n\n  // -----------------------------------------------------------------\n\n  EXPECT_TRUE(message.HasExtension(unittest::default_int32_extension   ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_int64_extension   ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_uint32_extension  ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_uint64_extension  ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_sint32_extension  ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_sint64_extension  ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_fixed32_extension ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_fixed64_extension ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_sfixed32_extension));\n  EXPECT_TRUE(message.HasExtension(unittest::default_sfixed64_extension));\n  EXPECT_TRUE(message.HasExtension(unittest::default_float_extension   ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_double_extension  ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_bool_extension    ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_string_extension  ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_bytes_extension   ));\n\n  EXPECT_TRUE(message.HasExtension(unittest::default_nested_enum_extension ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_foreign_enum_extension));\n  EXPECT_TRUE(message.HasExtension(unittest::default_import_enum_extension ));\n\n  EXPECT_TRUE(message.HasExtension(unittest::default_string_piece_extension));\n  EXPECT_TRUE(message.HasExtension(unittest::default_cord_extension));\n\n  EXPECT_EQ(401  , message.GetExtension(unittest::default_int32_extension   ));\n  EXPECT_EQ(402  , message.GetExtension(unittest::default_int64_extension   ));\n  EXPECT_EQ(403  , message.GetExtension(unittest::default_uint32_extension  ));\n  EXPECT_EQ(404  , message.GetExtension(unittest::default_uint64_extension  ));\n  EXPECT_EQ(405  , message.GetExtension(unittest::default_sint32_extension  ));\n  EXPECT_EQ(406  , message.GetExtension(unittest::default_sint64_extension  ));\n  EXPECT_EQ(407  , message.GetExtension(unittest::default_fixed32_extension ));\n  EXPECT_EQ(408  , message.GetExtension(unittest::default_fixed64_extension ));\n  EXPECT_EQ(409  , message.GetExtension(unittest::default_sfixed32_extension));\n  EXPECT_EQ(410  , message.GetExtension(unittest::default_sfixed64_extension));\n  EXPECT_EQ(411  , message.GetExtension(unittest::default_float_extension   ));\n  EXPECT_EQ(412  , message.GetExtension(unittest::default_double_extension  ));\n  EXPECT_FALSE(    message.GetExtension(unittest::default_bool_extension    ));\n  EXPECT_EQ(\"415\", message.GetExtension(unittest::default_string_extension  ));\n  EXPECT_EQ(\"416\", message.GetExtension(unittest::default_bytes_extension   ));\n\n  EXPECT_EQ(unittest::TestAllTypes::FOO, message.GetExtension(unittest::default_nested_enum_extension ));\n  EXPECT_EQ(unittest::FOREIGN_FOO      , message.GetExtension(unittest::default_foreign_enum_extension));\n  EXPECT_EQ(unittest_import::IMPORT_FOO, message.GetExtension(unittest::default_import_enum_extension ));\n\n  EXPECT_EQ(\"424\", message.GetExtension(unittest::default_string_piece_extension));\n  EXPECT_EQ(\"425\", message.GetExtension(unittest::default_cord_extension));\n\n  EXPECT_TRUE(message.HasExtension(unittest::oneof_uint32_extension));\n  EXPECT_TRUE(message.GetExtension(unittest::oneof_nested_message_extension).has_bb());\n  EXPECT_TRUE(message.HasExtension(unittest::oneof_string_extension));\n  EXPECT_TRUE(message.HasExtension(unittest::oneof_bytes_extension));\n\n  EXPECT_EQ(601, message.GetExtension(unittest::oneof_uint32_extension));\n  EXPECT_EQ(602, message.GetExtension(unittest::oneof_nested_message_extension).bb());\n  EXPECT_EQ(\"603\", message.GetExtension(unittest::oneof_string_extension));\n  EXPECT_EQ(\"604\", message.GetExtension(unittest::oneof_bytes_extension));\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::ExpectExtensionsClear(\n    const unittest::TestAllExtensions& message) {\n  string serialized;\n  ASSERT_TRUE(message.SerializeToString(&serialized));\n  EXPECT_EQ(\"\", serialized);\n  EXPECT_EQ(0, message.ByteSize());\n\n  // has_blah() should initially be false for all optional fields.\n  EXPECT_FALSE(message.HasExtension(unittest::optional_int32_extension   ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_int64_extension   ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_uint32_extension  ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_uint64_extension  ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_sint32_extension  ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_sint64_extension  ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_fixed32_extension ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_fixed64_extension ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_sfixed32_extension));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_sfixed64_extension));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_float_extension   ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_double_extension  ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_bool_extension    ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_string_extension  ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_bytes_extension   ));\n\n  EXPECT_FALSE(message.HasExtension(unittest::optionalgroup_extension                 ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_nested_message_extension       ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_foreign_message_extension      ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_import_message_extension       ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_public_import_message_extension));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_lazy_message_extension         ));\n\n  EXPECT_FALSE(message.HasExtension(unittest::optional_nested_enum_extension ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_foreign_enum_extension));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_import_enum_extension ));\n\n  EXPECT_FALSE(message.HasExtension(unittest::optional_string_piece_extension));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_cord_extension));\n\n  // Optional fields without defaults are set to zero or something like it.\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_int32_extension   ));\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_int64_extension   ));\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_uint32_extension  ));\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_uint64_extension  ));\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_sint32_extension  ));\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_sint64_extension  ));\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_fixed32_extension ));\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_fixed64_extension ));\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_sfixed32_extension));\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_sfixed64_extension));\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_float_extension   ));\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_double_extension  ));\n  EXPECT_FALSE(    message.GetExtension(unittest::optional_bool_extension    ));\n  EXPECT_EQ(\"\"   , message.GetExtension(unittest::optional_string_extension  ));\n  EXPECT_EQ(\"\"   , message.GetExtension(unittest::optional_bytes_extension   ));\n\n  // Embedded messages should also be clear.\n  EXPECT_FALSE(message.GetExtension(unittest::optionalgroup_extension                 ).has_a());\n  EXPECT_FALSE(message.GetExtension(unittest::optional_nested_message_extension       ).has_bb());\n  EXPECT_FALSE(message.GetExtension(unittest::optional_foreign_message_extension      ).has_c());\n  EXPECT_FALSE(message.GetExtension(unittest::optional_import_message_extension       ).has_d());\n  EXPECT_FALSE(message.GetExtension(unittest::optional_public_import_message_extension).has_e());\n  EXPECT_FALSE(message.GetExtension(unittest::optional_lazy_message_extension         ).has_bb());\n\n  EXPECT_EQ(0, message.GetExtension(unittest::optionalgroup_extension                 ).a());\n  EXPECT_EQ(0, message.GetExtension(unittest::optional_nested_message_extension       ).bb());\n  EXPECT_EQ(0, message.GetExtension(unittest::optional_foreign_message_extension      ).c());\n  EXPECT_EQ(0, message.GetExtension(unittest::optional_import_message_extension       ).d());\n  EXPECT_EQ(0, message.GetExtension(unittest::optional_public_import_message_extension).e());\n  EXPECT_EQ(0, message.GetExtension(unittest::optional_lazy_message_extension         ).bb());\n\n  // Enums without defaults are set to the first value in the enum.\n  EXPECT_EQ(unittest::TestAllTypes::FOO, message.GetExtension(unittest::optional_nested_enum_extension ));\n  EXPECT_EQ(unittest::FOREIGN_FOO      , message.GetExtension(unittest::optional_foreign_enum_extension));\n  EXPECT_EQ(unittest_import::IMPORT_FOO, message.GetExtension(unittest::optional_import_enum_extension ));\n\n  EXPECT_EQ(\"\", message.GetExtension(unittest::optional_string_piece_extension));\n  EXPECT_EQ(\"\", message.GetExtension(unittest::optional_cord_extension));\n\n  // Repeated fields are empty.\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_int32_extension   ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_int64_extension   ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_uint32_extension  ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_uint64_extension  ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_sint32_extension  ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_sint64_extension  ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_fixed32_extension ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_fixed64_extension ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_sfixed32_extension));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_sfixed64_extension));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_float_extension   ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_double_extension  ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_bool_extension    ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_string_extension  ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_bytes_extension   ));\n\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeatedgroup_extension           ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_nested_message_extension ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_foreign_message_extension));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_import_message_extension ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_lazy_message_extension   ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_nested_enum_extension    ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_foreign_enum_extension   ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_import_enum_extension    ));\n\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_string_piece_extension));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_cord_extension));\n\n  // has_blah() should also be false for all default fields.\n  EXPECT_FALSE(message.HasExtension(unittest::default_int32_extension   ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_int64_extension   ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_uint32_extension  ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_uint64_extension  ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_sint32_extension  ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_sint64_extension  ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_fixed32_extension ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_fixed64_extension ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_sfixed32_extension));\n  EXPECT_FALSE(message.HasExtension(unittest::default_sfixed64_extension));\n  EXPECT_FALSE(message.HasExtension(unittest::default_float_extension   ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_double_extension  ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_bool_extension    ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_string_extension  ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_bytes_extension   ));\n\n  EXPECT_FALSE(message.HasExtension(unittest::default_nested_enum_extension ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_foreign_enum_extension));\n  EXPECT_FALSE(message.HasExtension(unittest::default_import_enum_extension ));\n\n  EXPECT_FALSE(message.HasExtension(unittest::default_string_piece_extension));\n  EXPECT_FALSE(message.HasExtension(unittest::default_cord_extension));\n\n  // Fields with defaults have their default values (duh).\n  EXPECT_EQ( 41    , message.GetExtension(unittest::default_int32_extension   ));\n  EXPECT_EQ( 42    , message.GetExtension(unittest::default_int64_extension   ));\n  EXPECT_EQ( 43    , message.GetExtension(unittest::default_uint32_extension  ));\n  EXPECT_EQ( 44    , message.GetExtension(unittest::default_uint64_extension  ));\n  EXPECT_EQ(-45    , message.GetExtension(unittest::default_sint32_extension  ));\n  EXPECT_EQ( 46    , message.GetExtension(unittest::default_sint64_extension  ));\n  EXPECT_EQ( 47    , message.GetExtension(unittest::default_fixed32_extension ));\n  EXPECT_EQ( 48    , message.GetExtension(unittest::default_fixed64_extension ));\n  EXPECT_EQ( 49    , message.GetExtension(unittest::default_sfixed32_extension));\n  EXPECT_EQ(-50    , message.GetExtension(unittest::default_sfixed64_extension));\n  EXPECT_EQ( 51.5  , message.GetExtension(unittest::default_float_extension   ));\n  EXPECT_EQ( 52e3  , message.GetExtension(unittest::default_double_extension  ));\n  EXPECT_TRUE(       message.GetExtension(unittest::default_bool_extension    ));\n  EXPECT_EQ(\"hello\", message.GetExtension(unittest::default_string_extension  ));\n  EXPECT_EQ(\"world\", message.GetExtension(unittest::default_bytes_extension   ));\n\n  EXPECT_EQ(unittest::TestAllTypes::BAR, message.GetExtension(unittest::default_nested_enum_extension ));\n  EXPECT_EQ(unittest::FOREIGN_BAR      , message.GetExtension(unittest::default_foreign_enum_extension));\n  EXPECT_EQ(unittest_import::IMPORT_BAR, message.GetExtension(unittest::default_import_enum_extension ));\n\n  EXPECT_EQ(\"abc\", message.GetExtension(unittest::default_string_piece_extension));\n  EXPECT_EQ(\"123\", message.GetExtension(unittest::default_cord_extension));\n\n  EXPECT_FALSE(message.HasExtension(unittest::oneof_uint32_extension));\n  EXPECT_FALSE(message.GetExtension(unittest::oneof_nested_message_extension).has_bb());\n  EXPECT_FALSE(message.HasExtension(unittest::oneof_string_extension));\n  EXPECT_FALSE(message.HasExtension(unittest::oneof_bytes_extension));\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::ExpectRepeatedExtensionsModified(\n    const unittest::TestAllExtensions& message) {\n  // ModifyRepeatedFields only sets the second repeated element of each\n  // field.  In addition to verifying this, we also verify that the first\n  // element and size were *not* modified.\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_int32_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_int64_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_uint32_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_uint64_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sint32_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sint64_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_fixed32_extension ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_fixed64_extension ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sfixed32_extension));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sfixed64_extension));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_float_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_double_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_bool_extension    ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_string_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_bytes_extension   ));\n\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeatedgroup_extension           ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_nested_message_extension ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_foreign_message_extension));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_import_message_extension ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_lazy_message_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_nested_enum_extension    ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_foreign_enum_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_import_enum_extension    ));\n\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_string_piece_extension));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_cord_extension));\n\n  EXPECT_EQ(201  , message.GetExtension(unittest::repeated_int32_extension   , 0));\n  EXPECT_EQ(202  , message.GetExtension(unittest::repeated_int64_extension   , 0));\n  EXPECT_EQ(203  , message.GetExtension(unittest::repeated_uint32_extension  , 0));\n  EXPECT_EQ(204  , message.GetExtension(unittest::repeated_uint64_extension  , 0));\n  EXPECT_EQ(205  , message.GetExtension(unittest::repeated_sint32_extension  , 0));\n  EXPECT_EQ(206  , message.GetExtension(unittest::repeated_sint64_extension  , 0));\n  EXPECT_EQ(207  , message.GetExtension(unittest::repeated_fixed32_extension , 0));\n  EXPECT_EQ(208  , message.GetExtension(unittest::repeated_fixed64_extension , 0));\n  EXPECT_EQ(209  , message.GetExtension(unittest::repeated_sfixed32_extension, 0));\n  EXPECT_EQ(210  , message.GetExtension(unittest::repeated_sfixed64_extension, 0));\n  EXPECT_EQ(211  , message.GetExtension(unittest::repeated_float_extension   , 0));\n  EXPECT_EQ(212  , message.GetExtension(unittest::repeated_double_extension  , 0));\n  EXPECT_TRUE(     message.GetExtension(unittest::repeated_bool_extension    , 0));\n  EXPECT_EQ(\"215\", message.GetExtension(unittest::repeated_string_extension  , 0));\n  EXPECT_EQ(\"216\", message.GetExtension(unittest::repeated_bytes_extension   , 0));\n\n  EXPECT_EQ(217, message.GetExtension(unittest::repeatedgroup_extension           , 0).a());\n  EXPECT_EQ(218, message.GetExtension(unittest::repeated_nested_message_extension , 0).bb());\n  EXPECT_EQ(219, message.GetExtension(unittest::repeated_foreign_message_extension, 0).c());\n  EXPECT_EQ(220, message.GetExtension(unittest::repeated_import_message_extension , 0).d());\n  EXPECT_EQ(227, message.GetExtension(unittest::repeated_lazy_message_extension   , 0).bb());\n\n  EXPECT_EQ(unittest::TestAllTypes::BAR, message.GetExtension(unittest::repeated_nested_enum_extension , 0));\n  EXPECT_EQ(unittest::FOREIGN_BAR      , message.GetExtension(unittest::repeated_foreign_enum_extension, 0));\n  EXPECT_EQ(unittest_import::IMPORT_BAR, message.GetExtension(unittest::repeated_import_enum_extension , 0));\n\n  EXPECT_EQ(\"224\", message.GetExtension(unittest::repeated_string_piece_extension, 0));\n  EXPECT_EQ(\"225\", message.GetExtension(unittest::repeated_cord_extension, 0));\n\n  // Actually verify the second (modified) elements now.\n  EXPECT_EQ(501  , message.GetExtension(unittest::repeated_int32_extension   , 1));\n  EXPECT_EQ(502  , message.GetExtension(unittest::repeated_int64_extension   , 1));\n  EXPECT_EQ(503  , message.GetExtension(unittest::repeated_uint32_extension  , 1));\n  EXPECT_EQ(504  , message.GetExtension(unittest::repeated_uint64_extension  , 1));\n  EXPECT_EQ(505  , message.GetExtension(unittest::repeated_sint32_extension  , 1));\n  EXPECT_EQ(506  , message.GetExtension(unittest::repeated_sint64_extension  , 1));\n  EXPECT_EQ(507  , message.GetExtension(unittest::repeated_fixed32_extension , 1));\n  EXPECT_EQ(508  , message.GetExtension(unittest::repeated_fixed64_extension , 1));\n  EXPECT_EQ(509  , message.GetExtension(unittest::repeated_sfixed32_extension, 1));\n  EXPECT_EQ(510  , message.GetExtension(unittest::repeated_sfixed64_extension, 1));\n  EXPECT_EQ(511  , message.GetExtension(unittest::repeated_float_extension   , 1));\n  EXPECT_EQ(512  , message.GetExtension(unittest::repeated_double_extension  , 1));\n  EXPECT_TRUE(     message.GetExtension(unittest::repeated_bool_extension    , 1));\n  EXPECT_EQ(\"515\", message.GetExtension(unittest::repeated_string_extension  , 1));\n  EXPECT_EQ(\"516\", message.GetExtension(unittest::repeated_bytes_extension   , 1));\n\n  EXPECT_EQ(517, message.GetExtension(unittest::repeatedgroup_extension           , 1).a());\n  EXPECT_EQ(518, message.GetExtension(unittest::repeated_nested_message_extension , 1).bb());\n  EXPECT_EQ(519, message.GetExtension(unittest::repeated_foreign_message_extension, 1).c());\n  EXPECT_EQ(520, message.GetExtension(unittest::repeated_import_message_extension , 1).d());\n  EXPECT_EQ(527, message.GetExtension(unittest::repeated_lazy_message_extension   , 1).bb());\n\n  EXPECT_EQ(unittest::TestAllTypes::FOO, message.GetExtension(unittest::repeated_nested_enum_extension , 1));\n  EXPECT_EQ(unittest::FOREIGN_FOO      , message.GetExtension(unittest::repeated_foreign_enum_extension, 1));\n  EXPECT_EQ(unittest_import::IMPORT_FOO, message.GetExtension(unittest::repeated_import_enum_extension , 1));\n\n  EXPECT_EQ(\"524\", message.GetExtension(unittest::repeated_string_piece_extension, 1));\n  EXPECT_EQ(\"525\", message.GetExtension(unittest::repeated_cord_extension, 1));\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::SetPackedExtensions(unittest::TestPackedExtensions* message) {\n  message->AddExtension(unittest::packed_int32_extension   , 601);\n  message->AddExtension(unittest::packed_int64_extension   , 602);\n  message->AddExtension(unittest::packed_uint32_extension  , 603);\n  message->AddExtension(unittest::packed_uint64_extension  , 604);\n  message->AddExtension(unittest::packed_sint32_extension  , 605);\n  message->AddExtension(unittest::packed_sint64_extension  , 606);\n  message->AddExtension(unittest::packed_fixed32_extension , 607);\n  message->AddExtension(unittest::packed_fixed64_extension , 608);\n  message->AddExtension(unittest::packed_sfixed32_extension, 609);\n  message->AddExtension(unittest::packed_sfixed64_extension, 610);\n  message->AddExtension(unittest::packed_float_extension   , 611);\n  message->AddExtension(unittest::packed_double_extension  , 612);\n  message->AddExtension(unittest::packed_bool_extension    , true);\n  message->AddExtension(unittest::packed_enum_extension, unittest::FOREIGN_BAR);\n  // add a second one of each field\n  message->AddExtension(unittest::packed_int32_extension   , 701);\n  message->AddExtension(unittest::packed_int64_extension   , 702);\n  message->AddExtension(unittest::packed_uint32_extension  , 703);\n  message->AddExtension(unittest::packed_uint64_extension  , 704);\n  message->AddExtension(unittest::packed_sint32_extension  , 705);\n  message->AddExtension(unittest::packed_sint64_extension  , 706);\n  message->AddExtension(unittest::packed_fixed32_extension , 707);\n  message->AddExtension(unittest::packed_fixed64_extension , 708);\n  message->AddExtension(unittest::packed_sfixed32_extension, 709);\n  message->AddExtension(unittest::packed_sfixed64_extension, 710);\n  message->AddExtension(unittest::packed_float_extension   , 711);\n  message->AddExtension(unittest::packed_double_extension  , 712);\n  message->AddExtension(unittest::packed_bool_extension    , false);\n  message->AddExtension(unittest::packed_enum_extension, unittest::FOREIGN_BAZ);\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::ModifyPackedExtensions(unittest::TestPackedExtensions* message) {\n  message->SetExtension(unittest::packed_int32_extension   , 1, 801);\n  message->SetExtension(unittest::packed_int64_extension   , 1, 802);\n  message->SetExtension(unittest::packed_uint32_extension  , 1, 803);\n  message->SetExtension(unittest::packed_uint64_extension  , 1, 804);\n  message->SetExtension(unittest::packed_sint32_extension  , 1, 805);\n  message->SetExtension(unittest::packed_sint64_extension  , 1, 806);\n  message->SetExtension(unittest::packed_fixed32_extension , 1, 807);\n  message->SetExtension(unittest::packed_fixed64_extension , 1, 808);\n  message->SetExtension(unittest::packed_sfixed32_extension, 1, 809);\n  message->SetExtension(unittest::packed_sfixed64_extension, 1, 810);\n  message->SetExtension(unittest::packed_float_extension   , 1, 811);\n  message->SetExtension(unittest::packed_double_extension  , 1, 812);\n  message->SetExtension(unittest::packed_bool_extension    , 1, true);\n  message->SetExtension(unittest::packed_enum_extension    , 1,\n                        unittest::FOREIGN_FOO);\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::ExpectPackedExtensionsSet(\n    const unittest::TestPackedExtensions& message) {\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_int32_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_int64_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_uint32_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_uint64_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sint32_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sint64_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_fixed32_extension ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_fixed64_extension ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sfixed32_extension));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sfixed64_extension));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_float_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_double_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_bool_extension    ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_enum_extension    ));\n\n  EXPECT_EQ(601  , message.GetExtension(unittest::packed_int32_extension   , 0));\n  EXPECT_EQ(602  , message.GetExtension(unittest::packed_int64_extension   , 0));\n  EXPECT_EQ(603  , message.GetExtension(unittest::packed_uint32_extension  , 0));\n  EXPECT_EQ(604  , message.GetExtension(unittest::packed_uint64_extension  , 0));\n  EXPECT_EQ(605  , message.GetExtension(unittest::packed_sint32_extension  , 0));\n  EXPECT_EQ(606  , message.GetExtension(unittest::packed_sint64_extension  , 0));\n  EXPECT_EQ(607  , message.GetExtension(unittest::packed_fixed32_extension , 0));\n  EXPECT_EQ(608  , message.GetExtension(unittest::packed_fixed64_extension , 0));\n  EXPECT_EQ(609  , message.GetExtension(unittest::packed_sfixed32_extension, 0));\n  EXPECT_EQ(610  , message.GetExtension(unittest::packed_sfixed64_extension, 0));\n  EXPECT_EQ(611  , message.GetExtension(unittest::packed_float_extension   , 0));\n  EXPECT_EQ(612  , message.GetExtension(unittest::packed_double_extension  , 0));\n  EXPECT_TRUE(     message.GetExtension(unittest::packed_bool_extension    , 0));\n  EXPECT_EQ(unittest::FOREIGN_BAR,\n            message.GetExtension(unittest::packed_enum_extension, 0));\n  EXPECT_EQ(701  , message.GetExtension(unittest::packed_int32_extension   , 1));\n  EXPECT_EQ(702  , message.GetExtension(unittest::packed_int64_extension   , 1));\n  EXPECT_EQ(703  , message.GetExtension(unittest::packed_uint32_extension  , 1));\n  EXPECT_EQ(704  , message.GetExtension(unittest::packed_uint64_extension  , 1));\n  EXPECT_EQ(705  , message.GetExtension(unittest::packed_sint32_extension  , 1));\n  EXPECT_EQ(706  , message.GetExtension(unittest::packed_sint64_extension  , 1));\n  EXPECT_EQ(707  , message.GetExtension(unittest::packed_fixed32_extension , 1));\n  EXPECT_EQ(708  , message.GetExtension(unittest::packed_fixed64_extension , 1));\n  EXPECT_EQ(709  , message.GetExtension(unittest::packed_sfixed32_extension, 1));\n  EXPECT_EQ(710  , message.GetExtension(unittest::packed_sfixed64_extension, 1));\n  EXPECT_EQ(711  , message.GetExtension(unittest::packed_float_extension   , 1));\n  EXPECT_EQ(712  , message.GetExtension(unittest::packed_double_extension  , 1));\n  EXPECT_FALSE(    message.GetExtension(unittest::packed_bool_extension    , 1));\n  EXPECT_EQ(unittest::FOREIGN_BAZ,\n            message.GetExtension(unittest::packed_enum_extension, 1));\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::ExpectPackedExtensionsClear(\n    const unittest::TestPackedExtensions& message) {\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_int32_extension   ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_int64_extension   ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_uint32_extension  ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_uint64_extension  ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_sint32_extension  ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_sint64_extension  ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_fixed32_extension ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_fixed64_extension ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_sfixed32_extension));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_sfixed64_extension));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_float_extension   ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_double_extension  ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_bool_extension    ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_enum_extension    ));\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::ExpectPackedExtensionsModified(\n    const unittest::TestPackedExtensions& message) {\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_int32_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_int64_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_uint32_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_uint64_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sint32_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sint64_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_fixed32_extension ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_fixed64_extension ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sfixed32_extension));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sfixed64_extension));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_float_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_double_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_bool_extension    ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_enum_extension    ));\n  EXPECT_EQ(601  , message.GetExtension(unittest::packed_int32_extension   , 0));\n  EXPECT_EQ(602  , message.GetExtension(unittest::packed_int64_extension   , 0));\n  EXPECT_EQ(603  , message.GetExtension(unittest::packed_uint32_extension  , 0));\n  EXPECT_EQ(604  , message.GetExtension(unittest::packed_uint64_extension  , 0));\n  EXPECT_EQ(605  , message.GetExtension(unittest::packed_sint32_extension  , 0));\n  EXPECT_EQ(606  , message.GetExtension(unittest::packed_sint64_extension  , 0));\n  EXPECT_EQ(607  , message.GetExtension(unittest::packed_fixed32_extension , 0));\n  EXPECT_EQ(608  , message.GetExtension(unittest::packed_fixed64_extension , 0));\n  EXPECT_EQ(609  , message.GetExtension(unittest::packed_sfixed32_extension, 0));\n  EXPECT_EQ(610  , message.GetExtension(unittest::packed_sfixed64_extension, 0));\n  EXPECT_EQ(611  , message.GetExtension(unittest::packed_float_extension   , 0));\n  EXPECT_EQ(612  , message.GetExtension(unittest::packed_double_extension  , 0));\n  EXPECT_TRUE(     message.GetExtension(unittest::packed_bool_extension    , 0));\n  EXPECT_EQ(unittest::FOREIGN_BAR,\n            message.GetExtension(unittest::packed_enum_extension, 0));\n\n  // Actually verify the second (modified) elements now.\n  EXPECT_EQ(801  , message.GetExtension(unittest::packed_int32_extension   , 1));\n  EXPECT_EQ(802  , message.GetExtension(unittest::packed_int64_extension   , 1));\n  EXPECT_EQ(803  , message.GetExtension(unittest::packed_uint32_extension  , 1));\n  EXPECT_EQ(804  , message.GetExtension(unittest::packed_uint64_extension  , 1));\n  EXPECT_EQ(805  , message.GetExtension(unittest::packed_sint32_extension  , 1));\n  EXPECT_EQ(806  , message.GetExtension(unittest::packed_sint64_extension  , 1));\n  EXPECT_EQ(807  , message.GetExtension(unittest::packed_fixed32_extension , 1));\n  EXPECT_EQ(808  , message.GetExtension(unittest::packed_fixed64_extension , 1));\n  EXPECT_EQ(809  , message.GetExtension(unittest::packed_sfixed32_extension, 1));\n  EXPECT_EQ(810  , message.GetExtension(unittest::packed_sfixed64_extension, 1));\n  EXPECT_EQ(811  , message.GetExtension(unittest::packed_float_extension   , 1));\n  EXPECT_EQ(812  , message.GetExtension(unittest::packed_double_extension  , 1));\n  EXPECT_TRUE(     message.GetExtension(unittest::packed_bool_extension    , 1));\n  EXPECT_EQ(unittest::FOREIGN_FOO,\n            message.GetExtension(unittest::packed_enum_extension, 1));\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::ExpectUnpackedExtensionsSet(\n    const unittest::TestUnpackedExtensions& message) {\n  ASSERT_EQ(2, message.ExtensionSize(unittest::unpacked_int32_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::unpacked_int64_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::unpacked_uint32_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::unpacked_uint64_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::unpacked_sint32_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::unpacked_sint64_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::unpacked_fixed32_extension ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::unpacked_fixed64_extension ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::unpacked_sfixed32_extension));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::unpacked_sfixed64_extension));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::unpacked_float_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::unpacked_double_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::unpacked_bool_extension    ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::unpacked_enum_extension    ));\n\n  EXPECT_EQ(601  , message.GetExtension(unittest::unpacked_int32_extension   , 0));\n  EXPECT_EQ(602  , message.GetExtension(unittest::unpacked_int64_extension   , 0));\n  EXPECT_EQ(603  , message.GetExtension(unittest::unpacked_uint32_extension  , 0));\n  EXPECT_EQ(604  , message.GetExtension(unittest::unpacked_uint64_extension  , 0));\n  EXPECT_EQ(605  , message.GetExtension(unittest::unpacked_sint32_extension  , 0));\n  EXPECT_EQ(606  , message.GetExtension(unittest::unpacked_sint64_extension  , 0));\n  EXPECT_EQ(607  , message.GetExtension(unittest::unpacked_fixed32_extension , 0));\n  EXPECT_EQ(608  , message.GetExtension(unittest::unpacked_fixed64_extension , 0));\n  EXPECT_EQ(609  , message.GetExtension(unittest::unpacked_sfixed32_extension, 0));\n  EXPECT_EQ(610  , message.GetExtension(unittest::unpacked_sfixed64_extension, 0));\n  EXPECT_EQ(611  , message.GetExtension(unittest::unpacked_float_extension   , 0));\n  EXPECT_EQ(612  , message.GetExtension(unittest::unpacked_double_extension  , 0));\n  EXPECT_EQ(true , message.GetExtension(unittest::unpacked_bool_extension    , 0));\n  EXPECT_EQ(unittest::FOREIGN_BAR,\n            message.GetExtension(unittest::unpacked_enum_extension, 0));\n  EXPECT_EQ(701  , message.GetExtension(unittest::unpacked_int32_extension   , 1));\n  EXPECT_EQ(702  , message.GetExtension(unittest::unpacked_int64_extension   , 1));\n  EXPECT_EQ(703  , message.GetExtension(unittest::unpacked_uint32_extension  , 1));\n  EXPECT_EQ(704  , message.GetExtension(unittest::unpacked_uint64_extension  , 1));\n  EXPECT_EQ(705  , message.GetExtension(unittest::unpacked_sint32_extension  , 1));\n  EXPECT_EQ(706  , message.GetExtension(unittest::unpacked_sint64_extension  , 1));\n  EXPECT_EQ(707  , message.GetExtension(unittest::unpacked_fixed32_extension , 1));\n  EXPECT_EQ(708  , message.GetExtension(unittest::unpacked_fixed64_extension , 1));\n  EXPECT_EQ(709  , message.GetExtension(unittest::unpacked_sfixed32_extension, 1));\n  EXPECT_EQ(710  , message.GetExtension(unittest::unpacked_sfixed64_extension, 1));\n  EXPECT_EQ(711  , message.GetExtension(unittest::unpacked_float_extension   , 1));\n  EXPECT_EQ(712  , message.GetExtension(unittest::unpacked_double_extension  , 1));\n  EXPECT_EQ(false, message.GetExtension(unittest::unpacked_bool_extension    , 1));\n  EXPECT_EQ(unittest::FOREIGN_BAZ,\n            message.GetExtension(unittest::unpacked_enum_extension, 1));\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::ExpectAllFieldsAndExtensionsInOrder(const string& serialized) {\n  // We set each field individually, serialize separately, and concatenate all\n  // the strings in canonical order to determine the expected serialization.\n  string expected;\n  unittest::TestFieldOrderings message;\n  message.set_my_int(1);  // Field 1.\n  message.AppendToString(&expected);\n  message.Clear();\n  message.SetExtension(unittest::my_extension_int, 23);  // Field 5.\n  message.AppendToString(&expected);\n  message.Clear();\n  message.set_my_string(\"foo\");  // Field 11.\n  message.AppendToString(&expected);\n  message.Clear();\n  message.SetExtension(unittest::my_extension_string, \"bar\");  // Field 50.\n  message.AppendToString(&expected);\n  message.Clear();\n  message.set_my_float(1.0);  // Field 101.\n  message.AppendToString(&expected);\n  message.Clear();\n\n  // We don't EXPECT_EQ() since we don't want to print raw bytes to stdout.\n  EXPECT_TRUE(serialized == expected);\n}\n\nvoid TestUtil::ExpectLastRepeatedsRemoved(\n    const unittest::TestAllTypes& message) {\n  ASSERT_EQ(1, message.repeated_int32_size   ());\n  ASSERT_EQ(1, message.repeated_int64_size   ());\n  ASSERT_EQ(1, message.repeated_uint32_size  ());\n  ASSERT_EQ(1, message.repeated_uint64_size  ());\n  ASSERT_EQ(1, message.repeated_sint32_size  ());\n  ASSERT_EQ(1, message.repeated_sint64_size  ());\n  ASSERT_EQ(1, message.repeated_fixed32_size ());\n  ASSERT_EQ(1, message.repeated_fixed64_size ());\n  ASSERT_EQ(1, message.repeated_sfixed32_size());\n  ASSERT_EQ(1, message.repeated_sfixed64_size());\n  ASSERT_EQ(1, message.repeated_float_size   ());\n  ASSERT_EQ(1, message.repeated_double_size  ());\n  ASSERT_EQ(1, message.repeated_bool_size    ());\n  ASSERT_EQ(1, message.repeated_string_size  ());\n  ASSERT_EQ(1, message.repeated_bytes_size   ());\n\n  ASSERT_EQ(1, message.repeatedgroup_size           ());\n  ASSERT_EQ(1, message.repeated_nested_message_size ());\n  ASSERT_EQ(1, message.repeated_foreign_message_size());\n  ASSERT_EQ(1, message.repeated_import_message_size ());\n  ASSERT_EQ(1, message.repeated_import_message_size ());\n  ASSERT_EQ(1, message.repeated_nested_enum_size    ());\n  ASSERT_EQ(1, message.repeated_foreign_enum_size   ());\n  ASSERT_EQ(1, message.repeated_import_enum_size    ());\n\n#ifndef PROTOBUF_TEST_NO_DESCRIPTORS\n  ASSERT_EQ(1, message.repeated_string_piece_size());\n  ASSERT_EQ(1, message.repeated_cord_size());\n#endif\n\n  // Test that the remaining element is the correct one.\n  EXPECT_EQ(201  , message.repeated_int32   (0));\n  EXPECT_EQ(202  , message.repeated_int64   (0));\n  EXPECT_EQ(203  , message.repeated_uint32  (0));\n  EXPECT_EQ(204  , message.repeated_uint64  (0));\n  EXPECT_EQ(205  , message.repeated_sint32  (0));\n  EXPECT_EQ(206  , message.repeated_sint64  (0));\n  EXPECT_EQ(207  , message.repeated_fixed32 (0));\n  EXPECT_EQ(208  , message.repeated_fixed64 (0));\n  EXPECT_EQ(209  , message.repeated_sfixed32(0));\n  EXPECT_EQ(210  , message.repeated_sfixed64(0));\n  EXPECT_EQ(211  , message.repeated_float   (0));\n  EXPECT_EQ(212  , message.repeated_double  (0));\n  EXPECT_TRUE(     message.repeated_bool    (0));\n  EXPECT_EQ(\"215\", message.repeated_string  (0));\n  EXPECT_EQ(\"216\", message.repeated_bytes   (0));\n\n  EXPECT_EQ(217, message.repeatedgroup           (0).a());\n  EXPECT_EQ(218, message.repeated_nested_message (0).bb());\n  EXPECT_EQ(219, message.repeated_foreign_message(0).c());\n  EXPECT_EQ(220, message.repeated_import_message (0).d());\n  EXPECT_EQ(220, message.repeated_import_message (0).d());\n\n  EXPECT_EQ(unittest::TestAllTypes::BAR, message.repeated_nested_enum (0));\n  EXPECT_EQ(unittest::FOREIGN_BAR      , message.repeated_foreign_enum(0));\n  EXPECT_EQ(unittest_import::IMPORT_BAR, message.repeated_import_enum (0));\n}\n\nvoid TestUtil::ExpectLastRepeatedExtensionsRemoved(\n    const unittest::TestAllExtensions& message) {\n\n  // Test that one element was removed.\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_int32_extension   ));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_int64_extension   ));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_uint32_extension  ));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_uint64_extension  ));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_sint32_extension  ));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_sint64_extension  ));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_fixed32_extension ));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_fixed64_extension ));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_sfixed32_extension));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_sfixed64_extension));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_float_extension   ));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_double_extension  ));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_bool_extension    ));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_string_extension  ));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_bytes_extension   ));\n\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeatedgroup_extension           ));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_nested_message_extension ));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_foreign_message_extension));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_import_message_extension ));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_lazy_message_extension   ));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_nested_enum_extension    ));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_foreign_enum_extension   ));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_import_enum_extension    ));\n\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_string_piece_extension));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_cord_extension));\n\n  // Test that the remaining element is the correct one.\n  EXPECT_EQ(201  , message.GetExtension(unittest::repeated_int32_extension   , 0));\n  EXPECT_EQ(202  , message.GetExtension(unittest::repeated_int64_extension   , 0));\n  EXPECT_EQ(203  , message.GetExtension(unittest::repeated_uint32_extension  , 0));\n  EXPECT_EQ(204  , message.GetExtension(unittest::repeated_uint64_extension  , 0));\n  EXPECT_EQ(205  , message.GetExtension(unittest::repeated_sint32_extension  , 0));\n  EXPECT_EQ(206  , message.GetExtension(unittest::repeated_sint64_extension  , 0));\n  EXPECT_EQ(207  , message.GetExtension(unittest::repeated_fixed32_extension , 0));\n  EXPECT_EQ(208  , message.GetExtension(unittest::repeated_fixed64_extension , 0));\n  EXPECT_EQ(209  , message.GetExtension(unittest::repeated_sfixed32_extension, 0));\n  EXPECT_EQ(210  , message.GetExtension(unittest::repeated_sfixed64_extension, 0));\n  EXPECT_EQ(211  , message.GetExtension(unittest::repeated_float_extension   , 0));\n  EXPECT_EQ(212  , message.GetExtension(unittest::repeated_double_extension  , 0));\n  EXPECT_TRUE(     message.GetExtension(unittest::repeated_bool_extension    , 0));\n  EXPECT_EQ(\"215\", message.GetExtension(unittest::repeated_string_extension  , 0));\n  EXPECT_EQ(\"216\", message.GetExtension(unittest::repeated_bytes_extension   , 0));\n\n  EXPECT_EQ(217, message.GetExtension(unittest::repeatedgroup_extension           , 0).a());\n  EXPECT_EQ(218, message.GetExtension(unittest::repeated_nested_message_extension , 0).bb());\n  EXPECT_EQ(219, message.GetExtension(unittest::repeated_foreign_message_extension, 0).c());\n  EXPECT_EQ(220, message.GetExtension(unittest::repeated_import_message_extension , 0).d());\n  EXPECT_EQ(227, message.GetExtension(unittest::repeated_lazy_message_extension   , 0).bb());\n\n  EXPECT_EQ(unittest::TestAllTypes::BAR, message.GetExtension(unittest::repeated_nested_enum_extension , 0));\n  EXPECT_EQ(unittest::FOREIGN_BAR      , message.GetExtension(unittest::repeated_foreign_enum_extension, 0));\n  EXPECT_EQ(unittest_import::IMPORT_BAR, message.GetExtension(unittest::repeated_import_enum_extension , 0));\n\n  EXPECT_EQ(\"224\", message.GetExtension(unittest::repeated_string_piece_extension, 0));\n  EXPECT_EQ(\"225\", message.GetExtension(unittest::repeated_cord_extension, 0));\n}\n\nvoid TestUtil::ExpectLastRepeatedsReleased(\n    const unittest::TestAllTypes& message) {\n  ASSERT_EQ(1, message.repeatedgroup_size           ());\n  ASSERT_EQ(1, message.repeated_nested_message_size ());\n  ASSERT_EQ(1, message.repeated_foreign_message_size());\n  ASSERT_EQ(1, message.repeated_import_message_size ());\n  ASSERT_EQ(1, message.repeated_import_message_size ());\n\n  EXPECT_EQ(217, message.repeatedgroup           (0).a());\n  EXPECT_EQ(218, message.repeated_nested_message (0).bb());\n  EXPECT_EQ(219, message.repeated_foreign_message(0).c());\n  EXPECT_EQ(220, message.repeated_import_message (0).d());\n  EXPECT_EQ(220, message.repeated_import_message (0).d());\n}\n\nvoid TestUtil::ExpectLastRepeatedExtensionsReleased(\n    const unittest::TestAllExtensions& message) {\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeatedgroup_extension           ));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_nested_message_extension ));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_foreign_message_extension));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_import_message_extension ));\n  ASSERT_EQ(1, message.ExtensionSize(unittest::repeated_lazy_message_extension   ));\n\n  EXPECT_EQ(217, message.GetExtension(unittest::repeatedgroup_extension           , 0).a());\n  EXPECT_EQ(218, message.GetExtension(unittest::repeated_nested_message_extension , 0).bb());\n  EXPECT_EQ(219, message.GetExtension(unittest::repeated_foreign_message_extension, 0).c());\n  EXPECT_EQ(220, message.GetExtension(unittest::repeated_import_message_extension , 0).d());\n  EXPECT_EQ(227, message.GetExtension(unittest::repeated_lazy_message_extension   , 0).bb());\n}\n\nvoid TestUtil::ExpectRepeatedsSwapped(\n    const unittest::TestAllTypes& message) {\n  ASSERT_EQ(2, message.repeated_int32_size   ());\n  ASSERT_EQ(2, message.repeated_int64_size   ());\n  ASSERT_EQ(2, message.repeated_uint32_size  ());\n  ASSERT_EQ(2, message.repeated_uint64_size  ());\n  ASSERT_EQ(2, message.repeated_sint32_size  ());\n  ASSERT_EQ(2, message.repeated_sint64_size  ());\n  ASSERT_EQ(2, message.repeated_fixed32_size ());\n  ASSERT_EQ(2, message.repeated_fixed64_size ());\n  ASSERT_EQ(2, message.repeated_sfixed32_size());\n  ASSERT_EQ(2, message.repeated_sfixed64_size());\n  ASSERT_EQ(2, message.repeated_float_size   ());\n  ASSERT_EQ(2, message.repeated_double_size  ());\n  ASSERT_EQ(2, message.repeated_bool_size    ());\n  ASSERT_EQ(2, message.repeated_string_size  ());\n  ASSERT_EQ(2, message.repeated_bytes_size   ());\n\n  ASSERT_EQ(2, message.repeatedgroup_size           ());\n  ASSERT_EQ(2, message.repeated_nested_message_size ());\n  ASSERT_EQ(2, message.repeated_foreign_message_size());\n  ASSERT_EQ(2, message.repeated_import_message_size ());\n  ASSERT_EQ(2, message.repeated_import_message_size ());\n  ASSERT_EQ(2, message.repeated_nested_enum_size    ());\n  ASSERT_EQ(2, message.repeated_foreign_enum_size   ());\n  ASSERT_EQ(2, message.repeated_import_enum_size    ());\n\n#ifndef PROTOBUF_TEST_NO_DESCRIPTORS\n  ASSERT_EQ(2, message.repeated_string_piece_size());\n  ASSERT_EQ(2, message.repeated_cord_size());\n#endif\n\n  // Test that the first element and second element are flipped.\n  EXPECT_EQ(201  , message.repeated_int32   (1));\n  EXPECT_EQ(202  , message.repeated_int64   (1));\n  EXPECT_EQ(203  , message.repeated_uint32  (1));\n  EXPECT_EQ(204  , message.repeated_uint64  (1));\n  EXPECT_EQ(205  , message.repeated_sint32  (1));\n  EXPECT_EQ(206  , message.repeated_sint64  (1));\n  EXPECT_EQ(207  , message.repeated_fixed32 (1));\n  EXPECT_EQ(208  , message.repeated_fixed64 (1));\n  EXPECT_EQ(209  , message.repeated_sfixed32(1));\n  EXPECT_EQ(210  , message.repeated_sfixed64(1));\n  EXPECT_EQ(211  , message.repeated_float   (1));\n  EXPECT_EQ(212  , message.repeated_double  (1));\n  EXPECT_TRUE(     message.repeated_bool    (1));\n  EXPECT_EQ(\"215\", message.repeated_string  (1));\n  EXPECT_EQ(\"216\", message.repeated_bytes   (1));\n\n  EXPECT_EQ(217, message.repeatedgroup           (1).a());\n  EXPECT_EQ(218, message.repeated_nested_message (1).bb());\n  EXPECT_EQ(219, message.repeated_foreign_message(1).c());\n  EXPECT_EQ(220, message.repeated_import_message (1).d());\n  EXPECT_EQ(220, message.repeated_import_message (1).d());\n\n  EXPECT_EQ(unittest::TestAllTypes::BAR, message.repeated_nested_enum (1));\n  EXPECT_EQ(unittest::FOREIGN_BAR      , message.repeated_foreign_enum(1));\n  EXPECT_EQ(unittest_import::IMPORT_BAR, message.repeated_import_enum (1));\n\n  EXPECT_EQ(301  , message.repeated_int32   (0));\n  EXPECT_EQ(302  , message.repeated_int64   (0));\n  EXPECT_EQ(303  , message.repeated_uint32  (0));\n  EXPECT_EQ(304  , message.repeated_uint64  (0));\n  EXPECT_EQ(305  , message.repeated_sint32  (0));\n  EXPECT_EQ(306  , message.repeated_sint64  (0));\n  EXPECT_EQ(307  , message.repeated_fixed32 (0));\n  EXPECT_EQ(308  , message.repeated_fixed64 (0));\n  EXPECT_EQ(309  , message.repeated_sfixed32(0));\n  EXPECT_EQ(310  , message.repeated_sfixed64(0));\n  EXPECT_EQ(311  , message.repeated_float   (0));\n  EXPECT_EQ(312  , message.repeated_double  (0));\n  EXPECT_FALSE(    message.repeated_bool    (0));\n  EXPECT_EQ(\"315\", message.repeated_string  (0));\n  EXPECT_EQ(\"316\", message.repeated_bytes   (0));\n\n  EXPECT_EQ(317, message.repeatedgroup           (0).a());\n  EXPECT_EQ(318, message.repeated_nested_message (0).bb());\n  EXPECT_EQ(319, message.repeated_foreign_message(0).c());\n  EXPECT_EQ(320, message.repeated_import_message (0).d());\n  EXPECT_EQ(320, message.repeated_import_message (0).d());\n\n  EXPECT_EQ(unittest::TestAllTypes::BAZ, message.repeated_nested_enum (0));\n  EXPECT_EQ(unittest::FOREIGN_BAZ      , message.repeated_foreign_enum(0));\n  EXPECT_EQ(unittest_import::IMPORT_BAZ, message.repeated_import_enum (0));\n}\n\nvoid TestUtil::ExpectRepeatedExtensionsSwapped(\n    const unittest::TestAllExtensions& message) {\n\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_int32_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_int64_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_uint32_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_uint64_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sint32_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sint64_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_fixed32_extension ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_fixed64_extension ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sfixed32_extension));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sfixed64_extension));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_float_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_double_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_bool_extension    ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_string_extension  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_bytes_extension   ));\n\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeatedgroup_extension           ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_nested_message_extension ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_foreign_message_extension));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_import_message_extension ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_lazy_message_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_nested_enum_extension    ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_foreign_enum_extension   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_import_enum_extension    ));\n\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_string_piece_extension));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_cord_extension));\n\n  EXPECT_EQ(201  , message.GetExtension(unittest::repeated_int32_extension   , 1));\n  EXPECT_EQ(202  , message.GetExtension(unittest::repeated_int64_extension   , 1));\n  EXPECT_EQ(203  , message.GetExtension(unittest::repeated_uint32_extension  , 1));\n  EXPECT_EQ(204  , message.GetExtension(unittest::repeated_uint64_extension  , 1));\n  EXPECT_EQ(205  , message.GetExtension(unittest::repeated_sint32_extension  , 1));\n  EXPECT_EQ(206  , message.GetExtension(unittest::repeated_sint64_extension  , 1));\n  EXPECT_EQ(207  , message.GetExtension(unittest::repeated_fixed32_extension , 1));\n  EXPECT_EQ(208  , message.GetExtension(unittest::repeated_fixed64_extension , 1));\n  EXPECT_EQ(209  , message.GetExtension(unittest::repeated_sfixed32_extension, 1));\n  EXPECT_EQ(210  , message.GetExtension(unittest::repeated_sfixed64_extension, 1));\n  EXPECT_EQ(211  , message.GetExtension(unittest::repeated_float_extension   , 1));\n  EXPECT_EQ(212  , message.GetExtension(unittest::repeated_double_extension  , 1));\n  EXPECT_TRUE(     message.GetExtension(unittest::repeated_bool_extension    , 1));\n  EXPECT_EQ(\"215\", message.GetExtension(unittest::repeated_string_extension  , 1));\n  EXPECT_EQ(\"216\", message.GetExtension(unittest::repeated_bytes_extension   , 1));\n\n  EXPECT_EQ(217, message.GetExtension(unittest::repeatedgroup_extension           , 1).a());\n  EXPECT_EQ(218, message.GetExtension(unittest::repeated_nested_message_extension , 1).bb());\n  EXPECT_EQ(219, message.GetExtension(unittest::repeated_foreign_message_extension, 1).c());\n  EXPECT_EQ(220, message.GetExtension(unittest::repeated_import_message_extension , 1).d());\n  EXPECT_EQ(227, message.GetExtension(unittest::repeated_lazy_message_extension   , 1).bb());\n\n  EXPECT_EQ(unittest::TestAllTypes::BAR, message.GetExtension(unittest::repeated_nested_enum_extension , 1));\n  EXPECT_EQ(unittest::FOREIGN_BAR      , message.GetExtension(unittest::repeated_foreign_enum_extension, 1));\n  EXPECT_EQ(unittest_import::IMPORT_BAR, message.GetExtension(unittest::repeated_import_enum_extension , 1));\n\n  EXPECT_EQ(\"224\", message.GetExtension(unittest::repeated_string_piece_extension, 1));\n  EXPECT_EQ(\"225\", message.GetExtension(unittest::repeated_cord_extension, 1));\n\n  EXPECT_EQ(301  , message.GetExtension(unittest::repeated_int32_extension   , 0));\n  EXPECT_EQ(302  , message.GetExtension(unittest::repeated_int64_extension   , 0));\n  EXPECT_EQ(303  , message.GetExtension(unittest::repeated_uint32_extension  , 0));\n  EXPECT_EQ(304  , message.GetExtension(unittest::repeated_uint64_extension  , 0));\n  EXPECT_EQ(305  , message.GetExtension(unittest::repeated_sint32_extension  , 0));\n  EXPECT_EQ(306  , message.GetExtension(unittest::repeated_sint64_extension  , 0));\n  EXPECT_EQ(307  , message.GetExtension(unittest::repeated_fixed32_extension , 0));\n  EXPECT_EQ(308  , message.GetExtension(unittest::repeated_fixed64_extension , 0));\n  EXPECT_EQ(309  , message.GetExtension(unittest::repeated_sfixed32_extension, 0));\n  EXPECT_EQ(310  , message.GetExtension(unittest::repeated_sfixed64_extension, 0));\n  EXPECT_EQ(311  , message.GetExtension(unittest::repeated_float_extension   , 0));\n  EXPECT_EQ(312  , message.GetExtension(unittest::repeated_double_extension  , 0));\n  EXPECT_FALSE(    message.GetExtension(unittest::repeated_bool_extension    , 0));\n  EXPECT_EQ(\"315\", message.GetExtension(unittest::repeated_string_extension  , 0));\n  EXPECT_EQ(\"316\", message.GetExtension(unittest::repeated_bytes_extension   , 0));\n\n  EXPECT_EQ(317, message.GetExtension(unittest::repeatedgroup_extension           , 0).a());\n  EXPECT_EQ(318, message.GetExtension(unittest::repeated_nested_message_extension , 0).bb());\n  EXPECT_EQ(319, message.GetExtension(unittest::repeated_foreign_message_extension, 0).c());\n  EXPECT_EQ(320, message.GetExtension(unittest::repeated_import_message_extension , 0).d());\n  EXPECT_EQ(327, message.GetExtension(unittest::repeated_lazy_message_extension   , 0).bb());\n\n  EXPECT_EQ(unittest::TestAllTypes::BAZ, message.GetExtension(unittest::repeated_nested_enum_extension , 0));\n  EXPECT_EQ(unittest::FOREIGN_BAZ      , message.GetExtension(unittest::repeated_foreign_enum_extension, 0));\n  EXPECT_EQ(unittest_import::IMPORT_BAZ, message.GetExtension(unittest::repeated_import_enum_extension , 0));\n\n  EXPECT_EQ(\"324\", message.GetExtension(unittest::repeated_string_piece_extension, 0));\n  EXPECT_EQ(\"325\", message.GetExtension(unittest::repeated_cord_extension, 0));\n}\n\nvoid TestUtil::SetOneof1(unittest::TestOneof2* message) {\n  message->mutable_foo_lazy_message()->set_qux_int(100);\n  message->set_bar_string(\"101\");\n  message->set_baz_int(102);\n  message->set_baz_string(\"103\");\n}\n\nvoid TestUtil::SetOneof2(unittest::TestOneof2* message) {\n  message->set_foo_int(200);\n  message->set_bar_enum(unittest::TestOneof2::BAZ);\n  message->set_baz_int(202);\n  message->set_baz_string(\"203\");\n}\n\nvoid TestUtil::ExpectOneofSet1(const unittest::TestOneof2& message) {\n  ExpectAtMostOneFieldSetInOneof(message);\n\n  EXPECT_TRUE(message.has_foo_lazy_message          ());\n  EXPECT_TRUE(message.foo_lazy_message().has_qux_int());\n\n  EXPECT_TRUE(message.has_bar_string());\n  EXPECT_TRUE(message.has_baz_int   ());\n  EXPECT_TRUE(message.has_baz_string());\n\n  ASSERT_EQ(0, message.foo_lazy_message().corge_int_size());\n\n  EXPECT_EQ(100  , message.foo_lazy_message().qux_int());\n  EXPECT_EQ(\"101\", message.bar_string                ());\n  EXPECT_EQ(102  , message.baz_int                   ());\n  EXPECT_EQ(\"103\", message.baz_string                ());\n}\n\nvoid TestUtil::ExpectOneofSet2(const unittest::TestOneof2& message) {\n  ExpectAtMostOneFieldSetInOneof(message);\n\n  EXPECT_TRUE(message.has_foo_int   ());\n  EXPECT_TRUE(message.has_bar_enum  ());\n  EXPECT_TRUE(message.has_baz_int   ());\n  EXPECT_TRUE(message.has_baz_string());\n\n  EXPECT_EQ(200                      , message.foo_int   ());\n  EXPECT_EQ(unittest::TestOneof2::BAZ, message.bar_enum  ());\n  EXPECT_EQ(202                      , message.baz_int   ());\n  EXPECT_EQ(\"203\"                    , message.baz_string());\n}\n\nvoid TestUtil::ExpectOneofClear(const unittest::TestOneof2& message) {\n  EXPECT_FALSE(message.has_foo_int());\n  EXPECT_FALSE(message.has_foo_string());\n  EXPECT_FALSE(message.has_foo_bytes());\n  EXPECT_FALSE(message.has_foo_enum());\n  EXPECT_FALSE(message.has_foo_message());\n  EXPECT_FALSE(message.has_foogroup());\n  EXPECT_FALSE(message.has_foo_lazy_message());\n\n  EXPECT_FALSE(message.has_bar_int());\n  EXPECT_FALSE(message.has_bar_string());\n  EXPECT_FALSE(message.has_bar_bytes());\n  EXPECT_FALSE(message.has_bar_enum());\n\n  EXPECT_FALSE(message.has_baz_int());\n  EXPECT_FALSE(message.has_baz_string());\n\n  EXPECT_EQ(unittest::TestOneof2::FOO_NOT_SET, message.foo_case());\n  EXPECT_EQ(unittest::TestOneof2::BAR_NOT_SET, message.bar_case());\n}\n\nvoid TestUtil::ExpectAtMostOneFieldSetInOneof(\n    const unittest::TestOneof2& message) {\n  int count = 0;\n  if (message.has_foo_int()) count++;\n  if (message.has_foo_string()) count++;\n  if (message.has_foo_bytes()) count++;\n  if (message.has_foo_enum()) count++;\n  if (message.has_foo_message()) count++;\n  if (message.has_foogroup()) count++;\n  if (message.has_foo_lazy_message()) count++;\n  EXPECT_LE(count, 1);\n  count = 0;\n  if (message.has_bar_int()) count++;\n  if (message.has_bar_string()) count++;\n  if (message.has_bar_bytes()) count++;\n  if (message.has_bar_enum()) count++;\n  EXPECT_TRUE(count == 0 || count == 1);\n}\n\n// ===================================================================\n\nTestUtil::ReflectionTester::ReflectionTester(\n    const Descriptor* base_descriptor)\n  : base_descriptor_(base_descriptor) {\n\n  const DescriptorPool* pool = base_descriptor->file()->pool();\n\n  nested_b_ =\n    pool->FindFieldByName(\"protobuf_unittest.TestAllTypes.NestedMessage.bb\");\n  foreign_c_ =\n    pool->FindFieldByName(\"protobuf_unittest.ForeignMessage.c\");\n  import_d_ =\n    pool->FindFieldByName(\"protobuf_unittest_import.ImportMessage.d\");\n  import_e_ =\n    pool->FindFieldByName(\"protobuf_unittest_import.PublicImportMessage.e\");\n  nested_foo_ =\n    pool->FindEnumValueByName(\"protobuf_unittest.TestAllTypes.FOO\");\n  nested_bar_ =\n    pool->FindEnumValueByName(\"protobuf_unittest.TestAllTypes.BAR\");\n  nested_baz_ =\n    pool->FindEnumValueByName(\"protobuf_unittest.TestAllTypes.BAZ\");\n  foreign_foo_ =\n    pool->FindEnumValueByName(\"protobuf_unittest.FOREIGN_FOO\");\n  foreign_bar_ =\n    pool->FindEnumValueByName(\"protobuf_unittest.FOREIGN_BAR\");\n  foreign_baz_ =\n    pool->FindEnumValueByName(\"protobuf_unittest.FOREIGN_BAZ\");\n  import_foo_ =\n    pool->FindEnumValueByName(\"protobuf_unittest_import.IMPORT_FOO\");\n  import_bar_ =\n    pool->FindEnumValueByName(\"protobuf_unittest_import.IMPORT_BAR\");\n  import_baz_ =\n    pool->FindEnumValueByName(\"protobuf_unittest_import.IMPORT_BAZ\");\n\n  if (base_descriptor_->name() == \"TestAllExtensions\") {\n    group_a_ =\n      pool->FindFieldByName(\"protobuf_unittest.OptionalGroup_extension.a\");\n    repeated_group_a_ =\n      pool->FindFieldByName(\"protobuf_unittest.RepeatedGroup_extension.a\");\n  } else {\n    group_a_ =\n      pool->FindFieldByName(\"protobuf_unittest.TestAllTypes.OptionalGroup.a\");\n    repeated_group_a_ =\n      pool->FindFieldByName(\"protobuf_unittest.TestAllTypes.RepeatedGroup.a\");\n  }\n\n  EXPECT_TRUE(group_a_          != NULL);\n  EXPECT_TRUE(repeated_group_a_ != NULL);\n  EXPECT_TRUE(nested_b_         != NULL);\n  EXPECT_TRUE(foreign_c_        != NULL);\n  EXPECT_TRUE(import_d_         != NULL);\n  EXPECT_TRUE(import_e_         != NULL);\n  EXPECT_TRUE(nested_foo_       != NULL);\n  EXPECT_TRUE(nested_bar_       != NULL);\n  EXPECT_TRUE(nested_baz_       != NULL);\n  EXPECT_TRUE(foreign_foo_      != NULL);\n  EXPECT_TRUE(foreign_bar_      != NULL);\n  EXPECT_TRUE(foreign_baz_      != NULL);\n  EXPECT_TRUE(import_foo_       != NULL);\n  EXPECT_TRUE(import_bar_       != NULL);\n  EXPECT_TRUE(import_baz_       != NULL);\n}\n\n// Shorthand to get a FieldDescriptor for a field of unittest::TestAllTypes.\nconst FieldDescriptor* TestUtil::ReflectionTester::F(const string& name) {\n  const FieldDescriptor* result = NULL;\n  if (base_descriptor_->name() == \"TestAllExtensions\" ||\n      base_descriptor_->name() == \"TestPackedExtensions\") {\n    result = base_descriptor_->file()->FindExtensionByName(name + \"_extension\");\n  } else {\n    result = base_descriptor_->FindFieldByName(name);\n  }\n  GOOGLE_CHECK(result != NULL);\n  return result;\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::ReflectionTester::SetAllFieldsViaReflection(Message* message) {\n  const Reflection* reflection = message->GetReflection();\n  Message* sub_message;\n\n  reflection->SetInt32 (message, F(\"optional_int32\"   ), 101);\n  reflection->SetInt64 (message, F(\"optional_int64\"   ), 102);\n  reflection->SetUInt32(message, F(\"optional_uint32\"  ), 103);\n  reflection->SetUInt64(message, F(\"optional_uint64\"  ), 104);\n  reflection->SetInt32 (message, F(\"optional_sint32\"  ), 105);\n  reflection->SetInt64 (message, F(\"optional_sint64\"  ), 106);\n  reflection->SetUInt32(message, F(\"optional_fixed32\" ), 107);\n  reflection->SetUInt64(message, F(\"optional_fixed64\" ), 108);\n  reflection->SetInt32 (message, F(\"optional_sfixed32\"), 109);\n  reflection->SetInt64 (message, F(\"optional_sfixed64\"), 110);\n  reflection->SetFloat (message, F(\"optional_float\"   ), 111);\n  reflection->SetDouble(message, F(\"optional_double\"  ), 112);\n  reflection->SetBool  (message, F(\"optional_bool\"    ), true);\n  reflection->SetString(message, F(\"optional_string\"  ), \"115\");\n  reflection->SetString(message, F(\"optional_bytes\"   ), \"116\");\n\n  sub_message = reflection->MutableMessage(message, F(\"optionalgroup\"));\n  sub_message->GetReflection()->SetInt32(sub_message, group_a_, 117);\n  sub_message = reflection->MutableMessage(message, F(\"optional_nested_message\"));\n  sub_message->GetReflection()->SetInt32(sub_message, nested_b_, 118);\n  sub_message = reflection->MutableMessage(message, F(\"optional_foreign_message\"));\n  sub_message->GetReflection()->SetInt32(sub_message, foreign_c_, 119);\n  sub_message = reflection->MutableMessage(message, F(\"optional_import_message\"));\n  sub_message->GetReflection()->SetInt32(sub_message, import_d_, 120);\n\n  reflection->SetEnum(message, F(\"optional_nested_enum\" ),  nested_baz_);\n  reflection->SetEnum(message, F(\"optional_foreign_enum\"), foreign_baz_);\n  reflection->SetEnum(message, F(\"optional_import_enum\" ),  import_baz_);\n\n  reflection->SetString(message, F(\"optional_string_piece\"), \"124\");\n  reflection->SetString(message, F(\"optional_cord\"), \"125\");\n\n  sub_message = reflection->MutableMessage(message, F(\"optional_public_import_message\"));\n  sub_message->GetReflection()->SetInt32(sub_message, import_e_, 126);\n\n  sub_message = reflection->MutableMessage(message, F(\"optional_lazy_message\"));\n  sub_message->GetReflection()->SetInt32(sub_message, nested_b_, 127);\n\n  // -----------------------------------------------------------------\n\n  reflection->AddInt32 (message, F(\"repeated_int32\"   ), 201);\n  reflection->AddInt64 (message, F(\"repeated_int64\"   ), 202);\n  reflection->AddUInt32(message, F(\"repeated_uint32\"  ), 203);\n  reflection->AddUInt64(message, F(\"repeated_uint64\"  ), 204);\n  reflection->AddInt32 (message, F(\"repeated_sint32\"  ), 205);\n  reflection->AddInt64 (message, F(\"repeated_sint64\"  ), 206);\n  reflection->AddUInt32(message, F(\"repeated_fixed32\" ), 207);\n  reflection->AddUInt64(message, F(\"repeated_fixed64\" ), 208);\n  reflection->AddInt32 (message, F(\"repeated_sfixed32\"), 209);\n  reflection->AddInt64 (message, F(\"repeated_sfixed64\"), 210);\n  reflection->AddFloat (message, F(\"repeated_float\"   ), 211);\n  reflection->AddDouble(message, F(\"repeated_double\"  ), 212);\n  reflection->AddBool  (message, F(\"repeated_bool\"    ), true);\n  reflection->AddString(message, F(\"repeated_string\"  ), \"215\");\n  reflection->AddString(message, F(\"repeated_bytes\"   ), \"216\");\n\n  sub_message = reflection->AddMessage(message, F(\"repeatedgroup\"));\n  sub_message->GetReflection()->SetInt32(sub_message, repeated_group_a_, 217);\n  sub_message = reflection->AddMessage(message, F(\"repeated_nested_message\"));\n  sub_message->GetReflection()->SetInt32(sub_message, nested_b_, 218);\n  sub_message = reflection->AddMessage(message, F(\"repeated_foreign_message\"));\n  sub_message->GetReflection()->SetInt32(sub_message, foreign_c_, 219);\n  sub_message = reflection->AddMessage(message, F(\"repeated_import_message\"));\n  sub_message->GetReflection()->SetInt32(sub_message, import_d_, 220);\n  sub_message = reflection->AddMessage(message, F(\"repeated_lazy_message\"));\n  sub_message->GetReflection()->SetInt32(sub_message, nested_b_, 227);\n\n  reflection->AddEnum(message, F(\"repeated_nested_enum\" ),  nested_bar_);\n  reflection->AddEnum(message, F(\"repeated_foreign_enum\"), foreign_bar_);\n  reflection->AddEnum(message, F(\"repeated_import_enum\" ),  import_bar_);\n\n  reflection->AddString(message, F(\"repeated_string_piece\"), \"224\");\n  reflection->AddString(message, F(\"repeated_cord\"), \"225\");\n\n  // Add a second one of each field.\n  reflection->AddInt32 (message, F(\"repeated_int32\"   ), 301);\n  reflection->AddInt64 (message, F(\"repeated_int64\"   ), 302);\n  reflection->AddUInt32(message, F(\"repeated_uint32\"  ), 303);\n  reflection->AddUInt64(message, F(\"repeated_uint64\"  ), 304);\n  reflection->AddInt32 (message, F(\"repeated_sint32\"  ), 305);\n  reflection->AddInt64 (message, F(\"repeated_sint64\"  ), 306);\n  reflection->AddUInt32(message, F(\"repeated_fixed32\" ), 307);\n  reflection->AddUInt64(message, F(\"repeated_fixed64\" ), 308);\n  reflection->AddInt32 (message, F(\"repeated_sfixed32\"), 309);\n  reflection->AddInt64 (message, F(\"repeated_sfixed64\"), 310);\n  reflection->AddFloat (message, F(\"repeated_float\"   ), 311);\n  reflection->AddDouble(message, F(\"repeated_double\"  ), 312);\n  reflection->AddBool  (message, F(\"repeated_bool\"    ), false);\n  reflection->AddString(message, F(\"repeated_string\"  ), \"315\");\n  reflection->AddString(message, F(\"repeated_bytes\"   ), \"316\");\n\n  sub_message = reflection->AddMessage(message, F(\"repeatedgroup\"));\n  sub_message->GetReflection()->SetInt32(sub_message, repeated_group_a_, 317);\n  sub_message = reflection->AddMessage(message, F(\"repeated_nested_message\"));\n  sub_message->GetReflection()->SetInt32(sub_message, nested_b_, 318);\n  sub_message = reflection->AddMessage(message, F(\"repeated_foreign_message\"));\n  sub_message->GetReflection()->SetInt32(sub_message, foreign_c_, 319);\n  sub_message = reflection->AddMessage(message, F(\"repeated_import_message\"));\n  sub_message->GetReflection()->SetInt32(sub_message, import_d_, 320);\n  sub_message = reflection->AddMessage(message, F(\"repeated_lazy_message\"));\n  sub_message->GetReflection()->SetInt32(sub_message, nested_b_, 327);\n\n  reflection->AddEnum(message, F(\"repeated_nested_enum\" ),  nested_baz_);\n  reflection->AddEnum(message, F(\"repeated_foreign_enum\"), foreign_baz_);\n  reflection->AddEnum(message, F(\"repeated_import_enum\" ),  import_baz_);\n\n  reflection->AddString(message, F(\"repeated_string_piece\"), \"324\");\n  reflection->AddString(message, F(\"repeated_cord\"), \"325\");\n\n  // -----------------------------------------------------------------\n\n  reflection->SetInt32 (message, F(\"default_int32\"   ), 401);\n  reflection->SetInt64 (message, F(\"default_int64\"   ), 402);\n  reflection->SetUInt32(message, F(\"default_uint32\"  ), 403);\n  reflection->SetUInt64(message, F(\"default_uint64\"  ), 404);\n  reflection->SetInt32 (message, F(\"default_sint32\"  ), 405);\n  reflection->SetInt64 (message, F(\"default_sint64\"  ), 406);\n  reflection->SetUInt32(message, F(\"default_fixed32\" ), 407);\n  reflection->SetUInt64(message, F(\"default_fixed64\" ), 408);\n  reflection->SetInt32 (message, F(\"default_sfixed32\"), 409);\n  reflection->SetInt64 (message, F(\"default_sfixed64\"), 410);\n  reflection->SetFloat (message, F(\"default_float\"   ), 411);\n  reflection->SetDouble(message, F(\"default_double\"  ), 412);\n  reflection->SetBool  (message, F(\"default_bool\"    ), false);\n  reflection->SetString(message, F(\"default_string\"  ), \"415\");\n  reflection->SetString(message, F(\"default_bytes\"   ), \"416\");\n\n  reflection->SetEnum(message, F(\"default_nested_enum\" ),  nested_foo_);\n  reflection->SetEnum(message, F(\"default_foreign_enum\"), foreign_foo_);\n  reflection->SetEnum(message, F(\"default_import_enum\" ),  import_foo_);\n\n  reflection->SetString(message, F(\"default_string_piece\"), \"424\");\n  reflection->SetString(message, F(\"default_cord\"), \"425\");\n\n  reflection->SetUInt32(message, F(\"oneof_uint32\"   ), 601);\n  sub_message = reflection->MutableMessage(message, F(\"oneof_nested_message\"));\n  sub_message->GetReflection()->SetInt32(sub_message, nested_b_, 602);\n  reflection->SetString(message, F(\"oneof_string\"), \"603\");\n  reflection->SetString(message, F(\"oneof_bytes\" ), \"604\");\n}\n\nvoid TestUtil::ReflectionTester::SetOneofViaReflection(Message* message) {\n  const Descriptor* descriptor = message->GetDescriptor();\n  const Reflection* reflection = message->GetReflection();\n  Message* sub_message = reflection->MutableMessage(\n      message, descriptor->FindFieldByName(\"foo_lazy_message\"));\n  sub_message->GetReflection()->SetInt64(\n      sub_message,\n      descriptor->file()->pool()->FindFieldByName(\n          \"protobuf_unittest.TestOneof2.NestedMessage.qux_int\"),\n      100);\n\n  reflection->SetString(message,\n                        descriptor->FindFieldByName(\"bar_cord\"),\n                        \"101\");\n  reflection->SetInt32(message,\n                        descriptor->FindFieldByName(\"baz_int\"),\n                       102);\n  reflection->SetString(message,\n                        descriptor->FindFieldByName(\"baz_string\"),\n                        \"103\");\n}\n\nvoid TestUtil::ReflectionTester::ExpectOneofSetViaReflection(\n    const Message& message) {\n  const Descriptor* descriptor = message.GetDescriptor();\n  const Reflection* reflection = message.GetReflection();\n  string scratch;\n  EXPECT_TRUE(reflection->HasField(\n      message, descriptor->FindFieldByName(\"foo_lazy_message\")));\n  EXPECT_TRUE(reflection->HasField(\n      message, descriptor->FindFieldByName(\"bar_cord\")));\n  EXPECT_TRUE(reflection->HasField(\n      message, descriptor->FindFieldByName(\"baz_int\")));\n  EXPECT_TRUE(reflection->HasField(\n      message, descriptor->FindFieldByName(\"baz_string\")));\n\n  const Message* sub_message = &reflection->GetMessage(\n      message, descriptor->FindFieldByName(\"foo_lazy_message\"));\n  EXPECT_EQ(100, sub_message->GetReflection()->GetInt64(\n      *sub_message,\n      descriptor->file()->pool()->FindFieldByName(\n          \"protobuf_unittest.TestOneof2.NestedMessage.qux_int\")));\n\n  EXPECT_EQ(\"101\", reflection->GetString(\n      message, descriptor->FindFieldByName(\"bar_cord\")));\n  EXPECT_EQ(\"101\", reflection->GetStringReference(\n      message, descriptor->FindFieldByName(\"bar_cord\"), &scratch));\n\n  EXPECT_EQ(102, reflection->GetInt32(\n      message, descriptor->FindFieldByName(\"baz_int\")));\n\n  EXPECT_EQ(\"103\", reflection->GetString(\n      message, descriptor->FindFieldByName(\"baz_string\")));\n  EXPECT_EQ(\"103\", reflection->GetStringReference(\n      message, descriptor->FindFieldByName(\"baz_string\"), &scratch));\n}\n\nvoid TestUtil::ReflectionTester::SetPackedFieldsViaReflection(\n    Message* message) {\n  const Reflection* reflection = message->GetReflection();\n  reflection->AddInt32 (message, F(\"packed_int32\"   ), 601);\n  reflection->AddInt64 (message, F(\"packed_int64\"   ), 602);\n  reflection->AddUInt32(message, F(\"packed_uint32\"  ), 603);\n  reflection->AddUInt64(message, F(\"packed_uint64\"  ), 604);\n  reflection->AddInt32 (message, F(\"packed_sint32\"  ), 605);\n  reflection->AddInt64 (message, F(\"packed_sint64\"  ), 606);\n  reflection->AddUInt32(message, F(\"packed_fixed32\" ), 607);\n  reflection->AddUInt64(message, F(\"packed_fixed64\" ), 608);\n  reflection->AddInt32 (message, F(\"packed_sfixed32\"), 609);\n  reflection->AddInt64 (message, F(\"packed_sfixed64\"), 610);\n  reflection->AddFloat (message, F(\"packed_float\"   ), 611);\n  reflection->AddDouble(message, F(\"packed_double\"  ), 612);\n  reflection->AddBool  (message, F(\"packed_bool\"    ), true);\n  reflection->AddEnum  (message, F(\"packed_enum\"    ), foreign_bar_);\n\n  reflection->AddInt32 (message, F(\"packed_int32\"   ), 701);\n  reflection->AddInt64 (message, F(\"packed_int64\"   ), 702);\n  reflection->AddUInt32(message, F(\"packed_uint32\"  ), 703);\n  reflection->AddUInt64(message, F(\"packed_uint64\"  ), 704);\n  reflection->AddInt32 (message, F(\"packed_sint32\"  ), 705);\n  reflection->AddInt64 (message, F(\"packed_sint64\"  ), 706);\n  reflection->AddUInt32(message, F(\"packed_fixed32\" ), 707);\n  reflection->AddUInt64(message, F(\"packed_fixed64\" ), 708);\n  reflection->AddInt32 (message, F(\"packed_sfixed32\"), 709);\n  reflection->AddInt64 (message, F(\"packed_sfixed64\"), 710);\n  reflection->AddFloat (message, F(\"packed_float\"   ), 711);\n  reflection->AddDouble(message, F(\"packed_double\"  ), 712);\n  reflection->AddBool  (message, F(\"packed_bool\"    ), false);\n  reflection->AddEnum  (message, F(\"packed_enum\"    ), foreign_baz_);\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::ReflectionTester::ExpectAllFieldsSetViaReflection(\n    const Message& message) {\n  // We have to split this into three function otherwise it creates a stack\n  // frame so large that it triggers a warning.\n  ExpectAllFieldsSetViaReflection1(message);\n  ExpectAllFieldsSetViaReflection2(message);\n  ExpectAllFieldsSetViaReflection3(message);\n}\n\nvoid TestUtil::ReflectionTester::ExpectAllFieldsSetViaReflection1(\n    const Message& message) {\n  const Reflection* reflection = message.GetReflection();\n  string scratch;\n  const Message* sub_message;\n\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_int32\"   )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_int64\"   )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_uint32\"  )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_uint64\"  )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_sint32\"  )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_sint64\"  )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_fixed32\" )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_fixed64\" )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_sfixed32\")));\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_sfixed64\")));\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_float\"   )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_double\"  )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_bool\"    )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_string\"  )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_bytes\"   )));\n\n  EXPECT_TRUE(reflection->HasField(message, F(\"optionalgroup\"                 )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_nested_message\"       )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_foreign_message\"      )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_import_message\"       )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_public_import_message\")));\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_lazy_message\"         )));\n\n  sub_message = &reflection->GetMessage(message, F(\"optionalgroup\"));\n  EXPECT_TRUE(sub_message->GetReflection()->HasField(*sub_message, group_a_));\n  sub_message = &reflection->GetMessage(message, F(\"optional_nested_message\"));\n  EXPECT_TRUE(sub_message->GetReflection()->HasField(*sub_message, nested_b_));\n  sub_message = &reflection->GetMessage(message, F(\"optional_foreign_message\"));\n  EXPECT_TRUE(sub_message->GetReflection()->HasField(*sub_message, foreign_c_));\n  sub_message = &reflection->GetMessage(message, F(\"optional_import_message\"));\n  EXPECT_TRUE(sub_message->GetReflection()->HasField(*sub_message, import_d_));\n  sub_message = &reflection->GetMessage(message, F(\"optional_public_import_message\"));\n  EXPECT_TRUE(sub_message->GetReflection()->HasField(*sub_message, import_e_));\n  sub_message = &reflection->GetMessage(message, F(\"optional_lazy_message\"));\n  EXPECT_TRUE(sub_message->GetReflection()->HasField(*sub_message, nested_b_));\n\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_nested_enum\" )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_foreign_enum\")));\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_import_enum\" )));\n\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_string_piece\")));\n  EXPECT_TRUE(reflection->HasField(message, F(\"optional_cord\")));\n\n  EXPECT_EQ(101  , reflection->GetInt32 (message, F(\"optional_int32\"   )));\n  EXPECT_EQ(102  , reflection->GetInt64 (message, F(\"optional_int64\"   )));\n  EXPECT_EQ(103  , reflection->GetUInt32(message, F(\"optional_uint32\"  )));\n  EXPECT_EQ(104  , reflection->GetUInt64(message, F(\"optional_uint64\"  )));\n  EXPECT_EQ(105  , reflection->GetInt32 (message, F(\"optional_sint32\"  )));\n  EXPECT_EQ(106  , reflection->GetInt64 (message, F(\"optional_sint64\"  )));\n  EXPECT_EQ(107  , reflection->GetUInt32(message, F(\"optional_fixed32\" )));\n  EXPECT_EQ(108  , reflection->GetUInt64(message, F(\"optional_fixed64\" )));\n  EXPECT_EQ(109  , reflection->GetInt32 (message, F(\"optional_sfixed32\")));\n  EXPECT_EQ(110  , reflection->GetInt64 (message, F(\"optional_sfixed64\")));\n  EXPECT_EQ(111  , reflection->GetFloat (message, F(\"optional_float\"   )));\n  EXPECT_EQ(112  , reflection->GetDouble(message, F(\"optional_double\"  )));\n  EXPECT_TRUE(     reflection->GetBool  (message, F(\"optional_bool\"    )));\n  EXPECT_EQ(\"115\", reflection->GetString(message, F(\"optional_string\"  )));\n  EXPECT_EQ(\"116\", reflection->GetString(message, F(\"optional_bytes\"   )));\n\n  EXPECT_EQ(\"115\", reflection->GetStringReference(message, F(\"optional_string\"), &scratch));\n  EXPECT_EQ(\"116\", reflection->GetStringReference(message, F(\"optional_bytes\" ), &scratch));\n\n  sub_message = &reflection->GetMessage(message, F(\"optionalgroup\"));\n  EXPECT_EQ(117, sub_message->GetReflection()->GetInt32(*sub_message, group_a_));\n  sub_message = &reflection->GetMessage(message, F(\"optional_nested_message\"));\n  EXPECT_EQ(118, sub_message->GetReflection()->GetInt32(*sub_message, nested_b_));\n  sub_message = &reflection->GetMessage(message, F(\"optional_foreign_message\"));\n  EXPECT_EQ(119, sub_message->GetReflection()->GetInt32(*sub_message, foreign_c_));\n  sub_message = &reflection->GetMessage(message, F(\"optional_import_message\"));\n  EXPECT_EQ(120, sub_message->GetReflection()->GetInt32(*sub_message, import_d_));\n  sub_message = &reflection->GetMessage(message, F(\"optional_public_import_message\"));\n  EXPECT_EQ(126, sub_message->GetReflection()->GetInt32(*sub_message, import_e_));\n  sub_message = &reflection->GetMessage(message, F(\"optional_lazy_message\"));\n  EXPECT_EQ(127, sub_message->GetReflection()->GetInt32(*sub_message, nested_b_));\n\n  EXPECT_EQ( nested_baz_, reflection->GetEnum(message, F(\"optional_nested_enum\" )));\n  EXPECT_EQ(foreign_baz_, reflection->GetEnum(message, F(\"optional_foreign_enum\")));\n  EXPECT_EQ( import_baz_, reflection->GetEnum(message, F(\"optional_import_enum\" )));\n\n  EXPECT_EQ(\"124\", reflection->GetString(message, F(\"optional_string_piece\")));\n  EXPECT_EQ(\"124\", reflection->GetStringReference(message, F(\"optional_string_piece\"), &scratch));\n\n  EXPECT_EQ(\"125\", reflection->GetString(message, F(\"optional_cord\")));\n  EXPECT_EQ(\"125\", reflection->GetStringReference(message, F(\"optional_cord\"), &scratch));\n\n  EXPECT_TRUE(reflection->HasField(message, F(\"oneof_bytes\" )));\n  EXPECT_EQ(\"604\", reflection->GetString(message, F(\"oneof_bytes\"   )));\n\n  if (base_descriptor_->name() == \"TestAllTypes\") {\n    EXPECT_FALSE(reflection->HasField(message, F(\"oneof_uint32\")));\n    EXPECT_FALSE(reflection->HasField(message, F(\"oneof_string\")));\n  } else {\n    EXPECT_TRUE(reflection->HasField(message, F(\"oneof_uint32\")));\n    EXPECT_TRUE(reflection->HasField(message, F(\"oneof_string\")));\n    EXPECT_EQ(601  , reflection->GetUInt32(message, F(\"oneof_uint32\")));\n    EXPECT_EQ(\"603\", reflection->GetString(message, F(\"oneof_string\")));\n    sub_message = &reflection->GetMessage(message, F(\"oneof_nested_message\"));\n    EXPECT_EQ(602, sub_message->GetReflection()->GetInt32(*sub_message, nested_b_));\n  }\n}\n\nvoid TestUtil::ReflectionTester::ExpectAllFieldsSetViaReflection2(\n    const Message& message) {\n  const Reflection* reflection = message.GetReflection();\n  string scratch;\n  const Message* sub_message;\n\n  // -----------------------------------------------------------------\n\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_int32\"   )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_int64\"   )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_uint32\"  )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_uint64\"  )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_sint32\"  )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_sint64\"  )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_fixed32\" )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_fixed64\" )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_sfixed32\")));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_sfixed64\")));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_float\"   )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_double\"  )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_bool\"    )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_string\"  )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_bytes\"   )));\n\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeatedgroup\"           )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_nested_message\" )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_foreign_message\")));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_import_message\" )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_lazy_message\"   )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_nested_enum\"    )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_foreign_enum\"   )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_import_enum\"    )));\n\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_string_piece\")));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"repeated_cord\")));\n\n  EXPECT_EQ(201  , reflection->GetRepeatedInt32 (message, F(\"repeated_int32\"   ), 0));\n  EXPECT_EQ(202  , reflection->GetRepeatedInt64 (message, F(\"repeated_int64\"   ), 0));\n  EXPECT_EQ(203  , reflection->GetRepeatedUInt32(message, F(\"repeated_uint32\"  ), 0));\n  EXPECT_EQ(204  , reflection->GetRepeatedUInt64(message, F(\"repeated_uint64\"  ), 0));\n  EXPECT_EQ(205  , reflection->GetRepeatedInt32 (message, F(\"repeated_sint32\"  ), 0));\n  EXPECT_EQ(206  , reflection->GetRepeatedInt64 (message, F(\"repeated_sint64\"  ), 0));\n  EXPECT_EQ(207  , reflection->GetRepeatedUInt32(message, F(\"repeated_fixed32\" ), 0));\n  EXPECT_EQ(208  , reflection->GetRepeatedUInt64(message, F(\"repeated_fixed64\" ), 0));\n  EXPECT_EQ(209  , reflection->GetRepeatedInt32 (message, F(\"repeated_sfixed32\"), 0));\n  EXPECT_EQ(210  , reflection->GetRepeatedInt64 (message, F(\"repeated_sfixed64\"), 0));\n  EXPECT_EQ(211  , reflection->GetRepeatedFloat (message, F(\"repeated_float\"   ), 0));\n  EXPECT_EQ(212  , reflection->GetRepeatedDouble(message, F(\"repeated_double\"  ), 0));\n  EXPECT_TRUE(     reflection->GetRepeatedBool  (message, F(\"repeated_bool\"    ), 0));\n  EXPECT_EQ(\"215\", reflection->GetRepeatedString(message, F(\"repeated_string\"  ), 0));\n  EXPECT_EQ(\"216\", reflection->GetRepeatedString(message, F(\"repeated_bytes\"   ), 0));\n\n  EXPECT_EQ(\"215\", reflection->GetRepeatedStringReference(message, F(\"repeated_string\"), 0, &scratch));\n  EXPECT_EQ(\"216\", reflection->GetRepeatedStringReference(message, F(\"repeated_bytes\"), 0, &scratch));\n\n  sub_message = &reflection->GetRepeatedMessage(message, F(\"repeatedgroup\"), 0);\n  EXPECT_EQ(217, sub_message->GetReflection()->GetInt32(*sub_message, repeated_group_a_));\n  sub_message = &reflection->GetRepeatedMessage(message, F(\"repeated_nested_message\"), 0);\n  EXPECT_EQ(218, sub_message->GetReflection()->GetInt32(*sub_message, nested_b_));\n  sub_message = &reflection->GetRepeatedMessage(message, F(\"repeated_foreign_message\"), 0);\n  EXPECT_EQ(219, sub_message->GetReflection()->GetInt32(*sub_message, foreign_c_));\n  sub_message = &reflection->GetRepeatedMessage(message, F(\"repeated_import_message\"), 0);\n  EXPECT_EQ(220, sub_message->GetReflection()->GetInt32(*sub_message, import_d_));\n  sub_message = &reflection->GetRepeatedMessage(message, F(\"repeated_lazy_message\"), 0);\n  EXPECT_EQ(227, sub_message->GetReflection()->GetInt32(*sub_message, nested_b_));\n\n  EXPECT_EQ( nested_bar_, reflection->GetRepeatedEnum(message, F(\"repeated_nested_enum\" ),0));\n  EXPECT_EQ(foreign_bar_, reflection->GetRepeatedEnum(message, F(\"repeated_foreign_enum\"),0));\n  EXPECT_EQ( import_bar_, reflection->GetRepeatedEnum(message, F(\"repeated_import_enum\" ),0));\n\n  EXPECT_EQ(\"224\", reflection->GetRepeatedString(message, F(\"repeated_string_piece\"), 0));\n  EXPECT_EQ(\"224\", reflection->GetRepeatedStringReference(\n                        message, F(\"repeated_string_piece\"), 0, &scratch));\n\n  EXPECT_EQ(\"225\", reflection->GetRepeatedString(message, F(\"repeated_cord\"), 0));\n  EXPECT_EQ(\"225\", reflection->GetRepeatedStringReference(\n                        message, F(\"repeated_cord\"), 0, &scratch));\n\n  EXPECT_EQ(301  , reflection->GetRepeatedInt32 (message, F(\"repeated_int32\"   ), 1));\n  EXPECT_EQ(302  , reflection->GetRepeatedInt64 (message, F(\"repeated_int64\"   ), 1));\n  EXPECT_EQ(303  , reflection->GetRepeatedUInt32(message, F(\"repeated_uint32\"  ), 1));\n  EXPECT_EQ(304  , reflection->GetRepeatedUInt64(message, F(\"repeated_uint64\"  ), 1));\n  EXPECT_EQ(305  , reflection->GetRepeatedInt32 (message, F(\"repeated_sint32\"  ), 1));\n  EXPECT_EQ(306  , reflection->GetRepeatedInt64 (message, F(\"repeated_sint64\"  ), 1));\n  EXPECT_EQ(307  , reflection->GetRepeatedUInt32(message, F(\"repeated_fixed32\" ), 1));\n  EXPECT_EQ(308  , reflection->GetRepeatedUInt64(message, F(\"repeated_fixed64\" ), 1));\n  EXPECT_EQ(309  , reflection->GetRepeatedInt32 (message, F(\"repeated_sfixed32\"), 1));\n  EXPECT_EQ(310  , reflection->GetRepeatedInt64 (message, F(\"repeated_sfixed64\"), 1));\n  EXPECT_EQ(311  , reflection->GetRepeatedFloat (message, F(\"repeated_float\"   ), 1));\n  EXPECT_EQ(312  , reflection->GetRepeatedDouble(message, F(\"repeated_double\"  ), 1));\n  EXPECT_FALSE(    reflection->GetRepeatedBool  (message, F(\"repeated_bool\"    ), 1));\n  EXPECT_EQ(\"315\", reflection->GetRepeatedString(message, F(\"repeated_string\"  ), 1));\n  EXPECT_EQ(\"316\", reflection->GetRepeatedString(message, F(\"repeated_bytes\"   ), 1));\n\n  EXPECT_EQ(\"315\", reflection->GetRepeatedStringReference(message, F(\"repeated_string\"),\n                                                          1, &scratch));\n  EXPECT_EQ(\"316\", reflection->GetRepeatedStringReference(message, F(\"repeated_bytes\"),\n                                                          1, &scratch));\n\n  sub_message = &reflection->GetRepeatedMessage(message, F(\"repeatedgroup\"), 1);\n  EXPECT_EQ(317, sub_message->GetReflection()->GetInt32(*sub_message, repeated_group_a_));\n  sub_message = &reflection->GetRepeatedMessage(message, F(\"repeated_nested_message\"), 1);\n  EXPECT_EQ(318, sub_message->GetReflection()->GetInt32(*sub_message, nested_b_));\n  sub_message = &reflection->GetRepeatedMessage(message, F(\"repeated_foreign_message\"), 1);\n  EXPECT_EQ(319, sub_message->GetReflection()->GetInt32(*sub_message, foreign_c_));\n  sub_message = &reflection->GetRepeatedMessage(message, F(\"repeated_import_message\"), 1);\n  EXPECT_EQ(320, sub_message->GetReflection()->GetInt32(*sub_message, import_d_));\n  sub_message = &reflection->GetRepeatedMessage(message, F(\"repeated_lazy_message\"), 1);\n  EXPECT_EQ(327, sub_message->GetReflection()->GetInt32(*sub_message, nested_b_));\n\n  EXPECT_EQ( nested_baz_, reflection->GetRepeatedEnum(message, F(\"repeated_nested_enum\" ),1));\n  EXPECT_EQ(foreign_baz_, reflection->GetRepeatedEnum(message, F(\"repeated_foreign_enum\"),1));\n  EXPECT_EQ( import_baz_, reflection->GetRepeatedEnum(message, F(\"repeated_import_enum\" ),1));\n\n  EXPECT_EQ(\"324\", reflection->GetRepeatedString(message, F(\"repeated_string_piece\"), 1));\n  EXPECT_EQ(\"324\", reflection->GetRepeatedStringReference(\n                        message, F(\"repeated_string_piece\"), 1, &scratch));\n\n  EXPECT_EQ(\"325\", reflection->GetRepeatedString(message, F(\"repeated_cord\"), 1));\n  EXPECT_EQ(\"325\", reflection->GetRepeatedStringReference(\n                        message, F(\"repeated_cord\"), 1, &scratch));\n}\n\nvoid TestUtil::ReflectionTester::ExpectAllFieldsSetViaReflection3(\n    const Message& message) {\n  const Reflection* reflection = message.GetReflection();\n  string scratch;\n\n  // -----------------------------------------------------------------\n\n  EXPECT_TRUE(reflection->HasField(message, F(\"default_int32\"   )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"default_int64\"   )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"default_uint32\"  )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"default_uint64\"  )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"default_sint32\"  )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"default_sint64\"  )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"default_fixed32\" )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"default_fixed64\" )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"default_sfixed32\")));\n  EXPECT_TRUE(reflection->HasField(message, F(\"default_sfixed64\")));\n  EXPECT_TRUE(reflection->HasField(message, F(\"default_float\"   )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"default_double\"  )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"default_bool\"    )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"default_string\"  )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"default_bytes\"   )));\n\n  EXPECT_TRUE(reflection->HasField(message, F(\"default_nested_enum\" )));\n  EXPECT_TRUE(reflection->HasField(message, F(\"default_foreign_enum\")));\n  EXPECT_TRUE(reflection->HasField(message, F(\"default_import_enum\" )));\n\n  EXPECT_TRUE(reflection->HasField(message, F(\"default_string_piece\")));\n  EXPECT_TRUE(reflection->HasField(message, F(\"default_cord\")));\n\n  EXPECT_EQ(401  , reflection->GetInt32 (message, F(\"default_int32\"   )));\n  EXPECT_EQ(402  , reflection->GetInt64 (message, F(\"default_int64\"   )));\n  EXPECT_EQ(403  , reflection->GetUInt32(message, F(\"default_uint32\"  )));\n  EXPECT_EQ(404  , reflection->GetUInt64(message, F(\"default_uint64\"  )));\n  EXPECT_EQ(405  , reflection->GetInt32 (message, F(\"default_sint32\"  )));\n  EXPECT_EQ(406  , reflection->GetInt64 (message, F(\"default_sint64\"  )));\n  EXPECT_EQ(407  , reflection->GetUInt32(message, F(\"default_fixed32\" )));\n  EXPECT_EQ(408  , reflection->GetUInt64(message, F(\"default_fixed64\" )));\n  EXPECT_EQ(409  , reflection->GetInt32 (message, F(\"default_sfixed32\")));\n  EXPECT_EQ(410  , reflection->GetInt64 (message, F(\"default_sfixed64\")));\n  EXPECT_EQ(411  , reflection->GetFloat (message, F(\"default_float\"   )));\n  EXPECT_EQ(412  , reflection->GetDouble(message, F(\"default_double\"  )));\n  EXPECT_FALSE(    reflection->GetBool  (message, F(\"default_bool\"    )));\n  EXPECT_EQ(\"415\", reflection->GetString(message, F(\"default_string\"  )));\n  EXPECT_EQ(\"416\", reflection->GetString(message, F(\"default_bytes\"   )));\n\n  EXPECT_EQ(\"415\", reflection->GetStringReference(message, F(\"default_string\"), &scratch));\n  EXPECT_EQ(\"416\", reflection->GetStringReference(message, F(\"default_bytes\" ), &scratch));\n\n  EXPECT_EQ( nested_foo_, reflection->GetEnum(message, F(\"default_nested_enum\" )));\n  EXPECT_EQ(foreign_foo_, reflection->GetEnum(message, F(\"default_foreign_enum\")));\n  EXPECT_EQ( import_foo_, reflection->GetEnum(message, F(\"default_import_enum\" )));\n\n  EXPECT_EQ(\"424\", reflection->GetString(message, F(\"default_string_piece\")));\n  EXPECT_EQ(\"424\", reflection->GetStringReference(message, F(\"default_string_piece\"),\n                                                  &scratch));\n\n  EXPECT_EQ(\"425\", reflection->GetString(message, F(\"default_cord\")));\n  EXPECT_EQ(\"425\", reflection->GetStringReference(message, F(\"default_cord\"), &scratch));\n}\n\nvoid TestUtil::ReflectionTester::ExpectPackedFieldsSetViaReflection(\n    const Message& message) {\n  const Reflection* reflection = message.GetReflection();\n\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"packed_int32\"   )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"packed_int64\"   )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"packed_uint32\"  )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"packed_uint64\"  )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"packed_sint32\"  )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"packed_sint64\"  )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"packed_fixed32\" )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"packed_fixed64\" )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"packed_sfixed32\")));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"packed_sfixed64\")));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"packed_float\"   )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"packed_double\"  )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"packed_bool\"    )));\n  ASSERT_EQ(2, reflection->FieldSize(message, F(\"packed_enum\"    )));\n\n  EXPECT_EQ(601  , reflection->GetRepeatedInt32 (message, F(\"packed_int32\"   ), 0));\n  EXPECT_EQ(602  , reflection->GetRepeatedInt64 (message, F(\"packed_int64\"   ), 0));\n  EXPECT_EQ(603  , reflection->GetRepeatedUInt32(message, F(\"packed_uint32\"  ), 0));\n  EXPECT_EQ(604  , reflection->GetRepeatedUInt64(message, F(\"packed_uint64\"  ), 0));\n  EXPECT_EQ(605  , reflection->GetRepeatedInt32 (message, F(\"packed_sint32\"  ), 0));\n  EXPECT_EQ(606  , reflection->GetRepeatedInt64 (message, F(\"packed_sint64\"  ), 0));\n  EXPECT_EQ(607  , reflection->GetRepeatedUInt32(message, F(\"packed_fixed32\" ), 0));\n  EXPECT_EQ(608  , reflection->GetRepeatedUInt64(message, F(\"packed_fixed64\" ), 0));\n  EXPECT_EQ(609  , reflection->GetRepeatedInt32 (message, F(\"packed_sfixed32\"), 0));\n  EXPECT_EQ(610  , reflection->GetRepeatedInt64 (message, F(\"packed_sfixed64\"), 0));\n  EXPECT_EQ(611  , reflection->GetRepeatedFloat (message, F(\"packed_float\"   ), 0));\n  EXPECT_EQ(612  , reflection->GetRepeatedDouble(message, F(\"packed_double\"  ), 0));\n  EXPECT_TRUE(     reflection->GetRepeatedBool  (message, F(\"packed_bool\"    ), 0));\n  EXPECT_EQ(foreign_bar_,\n            reflection->GetRepeatedEnum(message, F(\"packed_enum\"), 0));\n\n  EXPECT_EQ(701  , reflection->GetRepeatedInt32 (message, F(\"packed_int32\"   ), 1));\n  EXPECT_EQ(702  , reflection->GetRepeatedInt64 (message, F(\"packed_int64\"   ), 1));\n  EXPECT_EQ(703  , reflection->GetRepeatedUInt32(message, F(\"packed_uint32\"  ), 1));\n  EXPECT_EQ(704  , reflection->GetRepeatedUInt64(message, F(\"packed_uint64\"  ), 1));\n  EXPECT_EQ(705  , reflection->GetRepeatedInt32 (message, F(\"packed_sint32\"  ), 1));\n  EXPECT_EQ(706  , reflection->GetRepeatedInt64 (message, F(\"packed_sint64\"  ), 1));\n  EXPECT_EQ(707  , reflection->GetRepeatedUInt32(message, F(\"packed_fixed32\" ), 1));\n  EXPECT_EQ(708  , reflection->GetRepeatedUInt64(message, F(\"packed_fixed64\" ), 1));\n  EXPECT_EQ(709  , reflection->GetRepeatedInt32 (message, F(\"packed_sfixed32\"), 1));\n  EXPECT_EQ(710  , reflection->GetRepeatedInt64 (message, F(\"packed_sfixed64\"), 1));\n  EXPECT_EQ(711  , reflection->GetRepeatedFloat (message, F(\"packed_float\"   ), 1));\n  EXPECT_EQ(712  , reflection->GetRepeatedDouble(message, F(\"packed_double\"  ), 1));\n  EXPECT_FALSE(    reflection->GetRepeatedBool  (message, F(\"packed_bool\"    ), 1));\n  EXPECT_EQ(foreign_baz_,\n            reflection->GetRepeatedEnum(message, F(\"packed_enum\"), 1));\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::ReflectionTester::ExpectClearViaReflection(\n    const Message& message) {\n  const Reflection* reflection = message.GetReflection();\n  string scratch;\n  const Message* sub_message;\n\n  // has_blah() should initially be false for all optional fields.\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_int32\"   )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_int64\"   )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_uint32\"  )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_uint64\"  )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_sint32\"  )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_sint64\"  )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_fixed32\" )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_fixed64\" )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_sfixed32\")));\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_sfixed64\")));\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_float\"   )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_double\"  )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_bool\"    )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_string\"  )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_bytes\"   )));\n\n  EXPECT_FALSE(reflection->HasField(message, F(\"optionalgroup\"           )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_nested_message\" )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_foreign_message\")));\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_import_message\" )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_public_import_message\")));\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_lazy_message\")));\n\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_nested_enum\" )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_foreign_enum\")));\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_import_enum\" )));\n\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_string_piece\")));\n  EXPECT_FALSE(reflection->HasField(message, F(\"optional_cord\")));\n\n  // Optional fields without defaults are set to zero or something like it.\n  EXPECT_EQ(0    , reflection->GetInt32 (message, F(\"optional_int32\"   )));\n  EXPECT_EQ(0    , reflection->GetInt64 (message, F(\"optional_int64\"   )));\n  EXPECT_EQ(0    , reflection->GetUInt32(message, F(\"optional_uint32\"  )));\n  EXPECT_EQ(0    , reflection->GetUInt64(message, F(\"optional_uint64\"  )));\n  EXPECT_EQ(0    , reflection->GetInt32 (message, F(\"optional_sint32\"  )));\n  EXPECT_EQ(0    , reflection->GetInt64 (message, F(\"optional_sint64\"  )));\n  EXPECT_EQ(0    , reflection->GetUInt32(message, F(\"optional_fixed32\" )));\n  EXPECT_EQ(0    , reflection->GetUInt64(message, F(\"optional_fixed64\" )));\n  EXPECT_EQ(0    , reflection->GetInt32 (message, F(\"optional_sfixed32\")));\n  EXPECT_EQ(0    , reflection->GetInt64 (message, F(\"optional_sfixed64\")));\n  EXPECT_EQ(0    , reflection->GetFloat (message, F(\"optional_float\"   )));\n  EXPECT_EQ(0    , reflection->GetDouble(message, F(\"optional_double\"  )));\n  EXPECT_FALSE(    reflection->GetBool  (message, F(\"optional_bool\"    )));\n  EXPECT_EQ(\"\"   , reflection->GetString(message, F(\"optional_string\"  )));\n  EXPECT_EQ(\"\"   , reflection->GetString(message, F(\"optional_bytes\"   )));\n\n  EXPECT_EQ(\"\", reflection->GetStringReference(message, F(\"optional_string\"), &scratch));\n  EXPECT_EQ(\"\", reflection->GetStringReference(message, F(\"optional_bytes\" ), &scratch));\n\n  // Embedded messages should also be clear.\n  sub_message = &reflection->GetMessage(message, F(\"optionalgroup\"));\n  EXPECT_FALSE(sub_message->GetReflection()->HasField(*sub_message, group_a_));\n  EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message, group_a_));\n  sub_message = &reflection->GetMessage(message, F(\"optional_nested_message\"));\n  EXPECT_FALSE(sub_message->GetReflection()->HasField(*sub_message, nested_b_));\n  EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message, nested_b_));\n  sub_message = &reflection->GetMessage(message, F(\"optional_foreign_message\"));\n  EXPECT_FALSE(sub_message->GetReflection()->HasField(*sub_message, foreign_c_));\n  EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message, foreign_c_));\n  sub_message = &reflection->GetMessage(message, F(\"optional_import_message\"));\n  EXPECT_FALSE(sub_message->GetReflection()->HasField(*sub_message, import_d_));\n  EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message, import_d_));\n  sub_message = &reflection->GetMessage(message, F(\"optional_public_import_message\"));\n  EXPECT_FALSE(sub_message->GetReflection()->HasField(*sub_message, import_e_));\n  EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message, import_e_));\n  sub_message = &reflection->GetMessage(message, F(\"optional_lazy_message\"));\n  EXPECT_FALSE(sub_message->GetReflection()->HasField(*sub_message, nested_b_));\n  EXPECT_EQ(0, sub_message->GetReflection()->GetInt32(*sub_message, nested_b_));\n\n  // Enums without defaults are set to the first value in the enum.\n  EXPECT_EQ( nested_foo_, reflection->GetEnum(message, F(\"optional_nested_enum\" )));\n  EXPECT_EQ(foreign_foo_, reflection->GetEnum(message, F(\"optional_foreign_enum\")));\n  EXPECT_EQ( import_foo_, reflection->GetEnum(message, F(\"optional_import_enum\" )));\n\n  EXPECT_EQ(\"\", reflection->GetString(message, F(\"optional_string_piece\")));\n  EXPECT_EQ(\"\", reflection->GetStringReference(message, F(\"optional_string_piece\"), &scratch));\n\n  EXPECT_EQ(\"\", reflection->GetString(message, F(\"optional_cord\")));\n  EXPECT_EQ(\"\", reflection->GetStringReference(message, F(\"optional_cord\"), &scratch));\n\n  // Repeated fields are empty.\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_int32\"   )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_int64\"   )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_uint32\"  )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_uint64\"  )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_sint32\"  )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_sint64\"  )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_fixed32\" )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_fixed64\" )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_sfixed32\")));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_sfixed64\")));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_float\"   )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_double\"  )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_bool\"    )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_string\"  )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_bytes\"   )));\n\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeatedgroup\"           )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_nested_message\" )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_foreign_message\")));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_import_message\" )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_lazy_message\"   )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_nested_enum\"    )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_foreign_enum\"   )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_import_enum\"    )));\n\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_string_piece\")));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"repeated_cord\")));\n\n  // has_blah() should also be false for all default fields.\n  EXPECT_FALSE(reflection->HasField(message, F(\"default_int32\"   )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"default_int64\"   )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"default_uint32\"  )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"default_uint64\"  )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"default_sint32\"  )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"default_sint64\"  )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"default_fixed32\" )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"default_fixed64\" )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"default_sfixed32\")));\n  EXPECT_FALSE(reflection->HasField(message, F(\"default_sfixed64\")));\n  EXPECT_FALSE(reflection->HasField(message, F(\"default_float\"   )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"default_double\"  )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"default_bool\"    )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"default_string\"  )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"default_bytes\"   )));\n\n  EXPECT_FALSE(reflection->HasField(message, F(\"default_nested_enum\" )));\n  EXPECT_FALSE(reflection->HasField(message, F(\"default_foreign_enum\")));\n  EXPECT_FALSE(reflection->HasField(message, F(\"default_import_enum\" )));\n\n  EXPECT_FALSE(reflection->HasField(message, F(\"default_string_piece\")));\n  EXPECT_FALSE(reflection->HasField(message, F(\"default_cord\")));\n\n  // Fields with defaults have their default values (duh).\n  EXPECT_EQ( 41    , reflection->GetInt32 (message, F(\"default_int32\"   )));\n  EXPECT_EQ( 42    , reflection->GetInt64 (message, F(\"default_int64\"   )));\n  EXPECT_EQ( 43    , reflection->GetUInt32(message, F(\"default_uint32\"  )));\n  EXPECT_EQ( 44    , reflection->GetUInt64(message, F(\"default_uint64\"  )));\n  EXPECT_EQ(-45    , reflection->GetInt32 (message, F(\"default_sint32\"  )));\n  EXPECT_EQ( 46    , reflection->GetInt64 (message, F(\"default_sint64\"  )));\n  EXPECT_EQ( 47    , reflection->GetUInt32(message, F(\"default_fixed32\" )));\n  EXPECT_EQ( 48    , reflection->GetUInt64(message, F(\"default_fixed64\" )));\n  EXPECT_EQ( 49    , reflection->GetInt32 (message, F(\"default_sfixed32\")));\n  EXPECT_EQ(-50    , reflection->GetInt64 (message, F(\"default_sfixed64\")));\n  EXPECT_EQ( 51.5  , reflection->GetFloat (message, F(\"default_float\"   )));\n  EXPECT_EQ( 52e3  , reflection->GetDouble(message, F(\"default_double\"  )));\n  EXPECT_TRUE(       reflection->GetBool  (message, F(\"default_bool\"    )));\n  EXPECT_EQ(\"hello\", reflection->GetString(message, F(\"default_string\"  )));\n  EXPECT_EQ(\"world\", reflection->GetString(message, F(\"default_bytes\"   )));\n\n  EXPECT_EQ(\"hello\", reflection->GetStringReference(message, F(\"default_string\"), &scratch));\n  EXPECT_EQ(\"world\", reflection->GetStringReference(message, F(\"default_bytes\" ), &scratch));\n\n  EXPECT_EQ( nested_bar_, reflection->GetEnum(message, F(\"default_nested_enum\" )));\n  EXPECT_EQ(foreign_bar_, reflection->GetEnum(message, F(\"default_foreign_enum\")));\n  EXPECT_EQ( import_bar_, reflection->GetEnum(message, F(\"default_import_enum\" )));\n\n  EXPECT_EQ(\"abc\", reflection->GetString(message, F(\"default_string_piece\")));\n  EXPECT_EQ(\"abc\", reflection->GetStringReference(message, F(\"default_string_piece\"), &scratch));\n\n  EXPECT_EQ(\"123\", reflection->GetString(message, F(\"default_cord\")));\n  EXPECT_EQ(\"123\", reflection->GetStringReference(message, F(\"default_cord\"), &scratch));\n}\n\nvoid TestUtil::ReflectionTester::ExpectPackedClearViaReflection(\n    const Message& message) {\n  const Reflection* reflection = message.GetReflection();\n\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"packed_int32\"   )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"packed_int64\"   )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"packed_uint32\"  )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"packed_uint64\"  )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"packed_sint32\"  )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"packed_sint64\"  )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"packed_fixed32\" )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"packed_fixed64\" )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"packed_sfixed32\")));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"packed_sfixed64\")));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"packed_float\"   )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"packed_double\"  )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"packed_bool\"    )));\n  EXPECT_EQ(0, reflection->FieldSize(message, F(\"packed_enum\"    )));\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtil::ReflectionTester::ModifyRepeatedFieldsViaReflection(\n    Message* message) {\n  const Reflection* reflection = message->GetReflection();\n  Message* sub_message;\n\n  reflection->SetRepeatedInt32 (message, F(\"repeated_int32\"   ), 1, 501);\n  reflection->SetRepeatedInt64 (message, F(\"repeated_int64\"   ), 1, 502);\n  reflection->SetRepeatedUInt32(message, F(\"repeated_uint32\"  ), 1, 503);\n  reflection->SetRepeatedUInt64(message, F(\"repeated_uint64\"  ), 1, 504);\n  reflection->SetRepeatedInt32 (message, F(\"repeated_sint32\"  ), 1, 505);\n  reflection->SetRepeatedInt64 (message, F(\"repeated_sint64\"  ), 1, 506);\n  reflection->SetRepeatedUInt32(message, F(\"repeated_fixed32\" ), 1, 507);\n  reflection->SetRepeatedUInt64(message, F(\"repeated_fixed64\" ), 1, 508);\n  reflection->SetRepeatedInt32 (message, F(\"repeated_sfixed32\"), 1, 509);\n  reflection->SetRepeatedInt64 (message, F(\"repeated_sfixed64\"), 1, 510);\n  reflection->SetRepeatedFloat (message, F(\"repeated_float\"   ), 1, 511);\n  reflection->SetRepeatedDouble(message, F(\"repeated_double\"  ), 1, 512);\n  reflection->SetRepeatedBool  (message, F(\"repeated_bool\"    ), 1, true);\n  reflection->SetRepeatedString(message, F(\"repeated_string\"  ), 1, \"515\");\n  reflection->SetRepeatedString(message, F(\"repeated_bytes\"   ), 1, \"516\");\n\n  sub_message = reflection->MutableRepeatedMessage(message, F(\"repeatedgroup\"), 1);\n  sub_message->GetReflection()->SetInt32(sub_message, repeated_group_a_, 517);\n  sub_message = reflection->MutableRepeatedMessage(message, F(\"repeated_nested_message\"), 1);\n  sub_message->GetReflection()->SetInt32(sub_message, nested_b_, 518);\n  sub_message = reflection->MutableRepeatedMessage(message, F(\"repeated_foreign_message\"), 1);\n  sub_message->GetReflection()->SetInt32(sub_message, foreign_c_, 519);\n  sub_message = reflection->MutableRepeatedMessage(message, F(\"repeated_import_message\"), 1);\n  sub_message->GetReflection()->SetInt32(sub_message, import_d_, 520);\n  sub_message = reflection->MutableRepeatedMessage(message, F(\"repeated_lazy_message\"), 1);\n  sub_message->GetReflection()->SetInt32(sub_message, nested_b_, 527);\n\n  reflection->SetRepeatedEnum(message, F(\"repeated_nested_enum\" ), 1,  nested_foo_);\n  reflection->SetRepeatedEnum(message, F(\"repeated_foreign_enum\"), 1, foreign_foo_);\n  reflection->SetRepeatedEnum(message, F(\"repeated_import_enum\" ), 1,  import_foo_);\n\n  reflection->SetRepeatedString(message, F(\"repeated_string_piece\"), 1, \"524\");\n  reflection->SetRepeatedString(message, F(\"repeated_cord\"), 1, \"525\");\n}\n\nvoid TestUtil::ReflectionTester::ModifyPackedFieldsViaReflection(\n    Message* message) {\n  const Reflection* reflection = message->GetReflection();\n  reflection->SetRepeatedInt32 (message, F(\"packed_int32\"   ), 1, 801);\n  reflection->SetRepeatedInt64 (message, F(\"packed_int64\"   ), 1, 802);\n  reflection->SetRepeatedUInt32(message, F(\"packed_uint32\"  ), 1, 803);\n  reflection->SetRepeatedUInt64(message, F(\"packed_uint64\"  ), 1, 804);\n  reflection->SetRepeatedInt32 (message, F(\"packed_sint32\"  ), 1, 805);\n  reflection->SetRepeatedInt64 (message, F(\"packed_sint64\"  ), 1, 806);\n  reflection->SetRepeatedUInt32(message, F(\"packed_fixed32\" ), 1, 807);\n  reflection->SetRepeatedUInt64(message, F(\"packed_fixed64\" ), 1, 808);\n  reflection->SetRepeatedInt32 (message, F(\"packed_sfixed32\"), 1, 809);\n  reflection->SetRepeatedInt64 (message, F(\"packed_sfixed64\"), 1, 810);\n  reflection->SetRepeatedFloat (message, F(\"packed_float\"   ), 1, 811);\n  reflection->SetRepeatedDouble(message, F(\"packed_double\"  ), 1, 812);\n  reflection->SetRepeatedBool  (message, F(\"packed_bool\"    ), 1, true);\n  reflection->SetRepeatedEnum  (message, F(\"packed_enum\"    ), 1, foreign_foo_);\n}\n\nvoid TestUtil::ReflectionTester::RemoveLastRepeatedsViaReflection(\n    Message* message) {\n  const Reflection* reflection = message->GetReflection();\n\n  vector<const FieldDescriptor*> output;\n  reflection->ListFields(*message, &output);\n  for (int i=0; i<output.size(); ++i) {\n    const FieldDescriptor* field = output[i];\n    if (!field->is_repeated()) continue;\n\n    reflection->RemoveLast(message, field);\n  }\n}\n\nvoid TestUtil::ReflectionTester::ReleaseLastRepeatedsViaReflection(\n    Message* message, bool expect_extensions_notnull) {\n  const Reflection* reflection = message->GetReflection();\n\n  vector<const FieldDescriptor*> output;\n  reflection->ListFields(*message, &output);\n  for (int i=0; i<output.size(); ++i) {\n    const FieldDescriptor* field = output[i];\n    if (!field->is_repeated()) continue;\n    if (field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) continue;\n\n    Message* released = reflection->ReleaseLast(message, field);\n    if (!field->is_extension() || expect_extensions_notnull) {\n      ASSERT_TRUE(released != NULL) << \"ReleaseLast returned NULL for: \"\n                                    << field->name();\n    }\n    delete released;\n  }\n}\n\nvoid TestUtil::ReflectionTester::SwapRepeatedsViaReflection(Message* message) {\n  const Reflection* reflection = message->GetReflection();\n\n  vector<const FieldDescriptor*> output;\n  reflection->ListFields(*message, &output);\n  for (int i=0; i<output.size(); ++i) {\n    const FieldDescriptor* field = output[i];\n    if (!field->is_repeated()) continue;\n\n    reflection->SwapElements(message, field, 0, 1);\n  }\n}\n\nvoid TestUtil::ReflectionTester::\nSetAllocatedOptionalMessageFieldsToNullViaReflection(\n    Message* message) {\n  const Reflection* reflection = message->GetReflection();\n\n  vector<const FieldDescriptor*> fields;\n  reflection->ListFields(*message, &fields);\n\n  for (int i = 0; i < fields.size(); ++i) {\n    const FieldDescriptor* field = fields[i];\n    if (!field->is_optional() ||\n        field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) continue;\n\n    reflection->SetAllocatedMessage(message, NULL, field);\n  }\n}\n\nvoid TestUtil::ReflectionTester::\nSetAllocatedOptionalMessageFieldsToMessageViaReflection(\n    Message* from_message,\n    Message* to_message) {\n  EXPECT_EQ(from_message->GetDescriptor(), to_message->GetDescriptor());\n  const Reflection* from_reflection = from_message->GetReflection();\n  const Reflection* to_reflection = to_message->GetReflection();\n\n  vector<const FieldDescriptor*> fields;\n  from_reflection->ListFields(*from_message, &fields);\n\n  for (int i = 0; i < fields.size(); ++i) {\n    const FieldDescriptor* field = fields[i];\n    if (!field->is_optional() ||\n        field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) continue;\n\n    Message* sub_message =\n        from_reflection->ReleaseMessage(from_message, field);\n    to_reflection->SetAllocatedMessage(to_message, sub_message, field);\n  }\n}\n\nvoid TestUtil::ReflectionTester::ExpectMessagesReleasedViaReflection(\n    Message* message,\n    TestUtil::ReflectionTester::MessageReleaseState expected_release_state) {\n  const Reflection* reflection = message->GetReflection();\n\n  static const char* fields[] = {\n    \"optionalgroup\",\n    \"optional_nested_message\",\n    \"optional_foreign_message\",\n    \"optional_import_message\",\n  };\n  for (int i = 0; i < GOOGLE_ARRAYSIZE(fields); i++) {\n    const Message& sub_message = reflection->GetMessage(*message, F(fields[i]));\n    Message* released = reflection->ReleaseMessage(message, F(fields[i]));\n    switch (expected_release_state) {\n      case IS_NULL:\n        EXPECT_TRUE(released == NULL);\n        break;\n      case NOT_NULL:\n        EXPECT_TRUE(released != NULL);\n        if (message->GetArena() == NULL) {\n          // released message must be same as sub_message if source message is\n          // not on arena.\n          EXPECT_EQ(&sub_message, released);\n        }\n        break;\n      case CAN_BE_NULL:\n        break;\n    }\n    delete released;\n    EXPECT_FALSE(reflection->HasField(*message, F(fields[i])));\n  }\n}\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/test_util.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_TEST_UTIL_H__\n#define GOOGLE_PROTOBUF_TEST_UTIL_H__\n\n#include <stack>\n#include <string>\n#include <google/protobuf/message.h>\n#include <google/protobuf/unittest.pb.h>\n\nnamespace google {\nnamespace protobuf {\n\nnamespace unittest = ::protobuf_unittest;\nnamespace unittest_import = protobuf_unittest_import;\n\nclass TestUtil {\n public:\n  // Set every field in the message to a unique value.\n  static void SetAllFields(unittest::TestAllTypes* message);\n  static void SetOptionalFields(unittest::TestAllTypes* message);\n  static void AddRepeatedFields1(unittest::TestAllTypes* message);\n  static void AddRepeatedFields2(unittest::TestAllTypes* message);\n  static void SetDefaultFields(unittest::TestAllTypes* message);\n  static void SetOneofFields(unittest::TestAllTypes* message);\n  static void SetAllExtensions(unittest::TestAllExtensions* message);\n  static void SetOneofFields(unittest::TestAllExtensions* message);\n  static void SetAllFieldsAndExtensions(unittest::TestFieldOrderings* message);\n  static void SetPackedFields(unittest::TestPackedTypes* message);\n  static void SetPackedExtensions(unittest::TestPackedExtensions* message);\n  static void SetUnpackedFields(unittest::TestUnpackedTypes* message);\n  static void SetOneof1(unittest::TestOneof2* message);\n  static void SetOneof2(unittest::TestOneof2* message);\n\n  // Use the repeated versions of the set_*() accessors to modify all the\n  // repeated fields of the message (which should already have been\n  // initialized with Set*Fields()).  Set*Fields() itself only tests\n  // the add_*() accessors.\n  static void ModifyRepeatedFields(unittest::TestAllTypes* message);\n  static void ModifyRepeatedExtensions(unittest::TestAllExtensions* message);\n  static void ModifyPackedFields(unittest::TestPackedTypes* message);\n  static void ModifyPackedExtensions(unittest::TestPackedExtensions* message);\n\n  // Check that all fields have the values that they should have after\n  // Set*Fields() is called.\n  static void ExpectAllFieldsSet(const unittest::TestAllTypes& message);\n  static void ExpectAllExtensionsSet(\n      const unittest::TestAllExtensions& message);\n  static void ExpectPackedFieldsSet(const unittest::TestPackedTypes& message);\n  static void ExpectPackedExtensionsSet(\n      const unittest::TestPackedExtensions& message);\n  static void ExpectUnpackedFieldsSet(\n      const unittest::TestUnpackedTypes& message);\n  static void ExpectUnpackedExtensionsSet(\n      const unittest::TestUnpackedExtensions& message);\n  static void ExpectOneofSet1(const unittest::TestOneof2& message);\n  static void ExpectOneofSet2(const unittest::TestOneof2& message);\n\n  // Expect that the message is modified as would be expected from\n  // Modify*Fields().\n  static void ExpectRepeatedFieldsModified(\n      const unittest::TestAllTypes& message);\n  static void ExpectRepeatedExtensionsModified(\n      const unittest::TestAllExtensions& message);\n  static void ExpectPackedFieldsModified(\n      const unittest::TestPackedTypes& message);\n  static void ExpectPackedExtensionsModified(\n      const unittest::TestPackedExtensions& message);\n\n  // Check that all fields have their default values.\n  static void ExpectClear(const unittest::TestAllTypes& message);\n  static void ExpectExtensionsClear(const unittest::TestAllExtensions& message);\n  static void ExpectPackedClear(const unittest::TestPackedTypes& message);\n  static void ExpectPackedExtensionsClear(\n      const unittest::TestPackedExtensions& message);\n  static void ExpectOneofClear(const unittest::TestOneof2& message);\n\n  // Check that the passed-in serialization is the canonical serialization we\n  // expect for a TestFieldOrderings message filled in by\n  // SetAllFieldsAndExtensions().\n  static void ExpectAllFieldsAndExtensionsInOrder(const string& serialized);\n\n  // Check that all repeated fields have had their last elements removed.\n  static void ExpectLastRepeatedsRemoved(\n      const unittest::TestAllTypes& message);\n  static void ExpectLastRepeatedExtensionsRemoved(\n      const unittest::TestAllExtensions& message);\n  static void ExpectLastRepeatedsReleased(\n      const unittest::TestAllTypes& message);\n  static void ExpectLastRepeatedExtensionsReleased(\n      const unittest::TestAllExtensions& message);\n\n  // Check that all repeated fields have had their first and last elements\n  // swapped.\n  static void ExpectRepeatedsSwapped(const unittest::TestAllTypes& message);\n  static void ExpectRepeatedExtensionsSwapped(\n      const unittest::TestAllExtensions& message);\n\n  static void ExpectAtMostOneFieldSetInOneof(\n      const unittest::TestOneof2 &message);\n\n  // Like above, but use the reflection interface.\n  class ReflectionTester {\n   public:\n    // base_descriptor must be a descriptor for TestAllTypes or\n    // TestAllExtensions.  In the former case, ReflectionTester fetches from\n    // it the FieldDescriptors needed to use the reflection interface.  In\n    // the latter case, ReflectionTester searches for extension fields in\n    // its file.\n    explicit ReflectionTester(const Descriptor* base_descriptor);\n\n    void SetAllFieldsViaReflection(Message* message);\n    void ModifyRepeatedFieldsViaReflection(Message* message);\n    void ExpectAllFieldsSetViaReflection(const Message& message);\n    void ExpectClearViaReflection(const Message& message);\n\n    void SetPackedFieldsViaReflection(Message* message);\n    void ModifyPackedFieldsViaReflection(Message* message);\n    void ExpectPackedFieldsSetViaReflection(const Message& message);\n    void ExpectPackedClearViaReflection(const Message& message);\n\n    void RemoveLastRepeatedsViaReflection(Message* message);\n    void ReleaseLastRepeatedsViaReflection(\n        Message* message, bool expect_extensions_notnull);\n    void SwapRepeatedsViaReflection(Message* message);\n    void SetAllocatedOptionalMessageFieldsToNullViaReflection(\n        Message* message);\n    static void SetAllocatedOptionalMessageFieldsToMessageViaReflection(\n        Message* from_message,\n        Message* to_message);\n\n    enum MessageReleaseState {\n      IS_NULL,\n      CAN_BE_NULL,\n      NOT_NULL,\n    };\n    void ExpectMessagesReleasedViaReflection(\n        Message* message, MessageReleaseState expected_release_state);\n\n    // Set and check functions for TestOneof2 messages. No need to construct\n    // the ReflectionTester by TestAllTypes nor TestAllExtensions.\n    static void SetOneofViaReflection(Message* message);\n    static void ExpectOneofSetViaReflection(const Message& message);\n\n   private:\n    const FieldDescriptor* F(const string& name);\n\n    const Descriptor* base_descriptor_;\n\n    const FieldDescriptor* group_a_;\n    const FieldDescriptor* repeated_group_a_;\n    const FieldDescriptor* nested_b_;\n    const FieldDescriptor* foreign_c_;\n    const FieldDescriptor* import_d_;\n    const FieldDescriptor* import_e_;\n\n    const EnumValueDescriptor* nested_foo_;\n    const EnumValueDescriptor* nested_bar_;\n    const EnumValueDescriptor* nested_baz_;\n    const EnumValueDescriptor* foreign_foo_;\n    const EnumValueDescriptor* foreign_bar_;\n    const EnumValueDescriptor* foreign_baz_;\n    const EnumValueDescriptor* import_foo_;\n    const EnumValueDescriptor* import_bar_;\n    const EnumValueDescriptor* import_baz_;\n\n    // We have to split this into three function otherwise it creates a stack\n    // frame so large that it triggers a warning.\n    void ExpectAllFieldsSetViaReflection1(const Message& message);\n    void ExpectAllFieldsSetViaReflection2(const Message& message);\n    void ExpectAllFieldsSetViaReflection3(const Message& message);\n\n    GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ReflectionTester);\n  };\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TestUtil);\n};\n\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_TEST_UTIL_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/test_util_lite.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/test_util_lite.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n\n\n#define EXPECT_TRUE GOOGLE_CHECK\n#define ASSERT_TRUE GOOGLE_CHECK\n#define EXPECT_FALSE(COND) GOOGLE_CHECK(!(COND))\n#define EXPECT_EQ GOOGLE_CHECK_EQ\n#define ASSERT_EQ GOOGLE_CHECK_EQ\n\nnamespace google {\nnamespace protobuf {\n\nvoid TestUtilLite::SetAllFields(unittest::TestAllTypesLite* message) {\n  message->set_optional_int32   (101);\n  message->set_optional_int64   (102);\n  message->set_optional_uint32  (103);\n  message->set_optional_uint64  (104);\n  message->set_optional_sint32  (105);\n  message->set_optional_sint64  (106);\n  message->set_optional_fixed32 (107);\n  message->set_optional_fixed64 (108);\n  message->set_optional_sfixed32(109);\n  message->set_optional_sfixed64(110);\n  message->set_optional_float   (111);\n  message->set_optional_double  (112);\n  message->set_optional_bool    (true);\n  message->set_optional_string  (\"115\");\n  message->set_optional_bytes   (\"116\");\n\n  message->mutable_optionalgroup                 ()->set_a(117);\n  message->mutable_optional_nested_message       ()->set_bb(118);\n  message->mutable_optional_foreign_message      ()->set_c(119);\n  message->mutable_optional_import_message       ()->set_d(120);\n  message->mutable_optional_public_import_message()->set_e(126);\n  message->mutable_optional_lazy_message         ()->set_bb(127);\n\n  message->set_optional_nested_enum (unittest::TestAllTypesLite::BAZ );\n  message->set_optional_foreign_enum(unittest::FOREIGN_LITE_BAZ      );\n  message->set_optional_import_enum (unittest_import::IMPORT_LITE_BAZ);\n\n\n  // -----------------------------------------------------------------\n\n  message->add_repeated_int32   (201);\n  message->add_repeated_int64   (202);\n  message->add_repeated_uint32  (203);\n  message->add_repeated_uint64  (204);\n  message->add_repeated_sint32  (205);\n  message->add_repeated_sint64  (206);\n  message->add_repeated_fixed32 (207);\n  message->add_repeated_fixed64 (208);\n  message->add_repeated_sfixed32(209);\n  message->add_repeated_sfixed64(210);\n  message->add_repeated_float   (211);\n  message->add_repeated_double  (212);\n  message->add_repeated_bool    (true);\n  message->add_repeated_string  (\"215\");\n  message->add_repeated_bytes   (\"216\");\n\n  message->add_repeatedgroup           ()->set_a(217);\n  message->add_repeated_nested_message ()->set_bb(218);\n  message->add_repeated_foreign_message()->set_c(219);\n  message->add_repeated_import_message ()->set_d(220);\n  message->add_repeated_lazy_message   ()->set_bb(227);\n\n  message->add_repeated_nested_enum (unittest::TestAllTypesLite::BAR );\n  message->add_repeated_foreign_enum(unittest::FOREIGN_LITE_BAR      );\n  message->add_repeated_import_enum (unittest_import::IMPORT_LITE_BAR);\n\n\n  // Add a second one of each field.\n  message->add_repeated_int32   (301);\n  message->add_repeated_int64   (302);\n  message->add_repeated_uint32  (303);\n  message->add_repeated_uint64  (304);\n  message->add_repeated_sint32  (305);\n  message->add_repeated_sint64  (306);\n  message->add_repeated_fixed32 (307);\n  message->add_repeated_fixed64 (308);\n  message->add_repeated_sfixed32(309);\n  message->add_repeated_sfixed64(310);\n  message->add_repeated_float   (311);\n  message->add_repeated_double  (312);\n  message->add_repeated_bool    (false);\n  message->add_repeated_string  (\"315\");\n  message->add_repeated_bytes   (\"316\");\n\n  message->add_repeatedgroup           ()->set_a(317);\n  message->add_repeated_nested_message ()->set_bb(318);\n  message->add_repeated_foreign_message()->set_c(319);\n  message->add_repeated_import_message ()->set_d(320);\n  message->add_repeated_lazy_message   ()->set_bb(327);\n\n  message->add_repeated_nested_enum (unittest::TestAllTypesLite::BAZ );\n  message->add_repeated_foreign_enum(unittest::FOREIGN_LITE_BAZ      );\n  message->add_repeated_import_enum (unittest_import::IMPORT_LITE_BAZ);\n\n\n  // -----------------------------------------------------------------\n\n  message->set_default_int32   (401);\n  message->set_default_int64   (402);\n  message->set_default_uint32  (403);\n  message->set_default_uint64  (404);\n  message->set_default_sint32  (405);\n  message->set_default_sint64  (406);\n  message->set_default_fixed32 (407);\n  message->set_default_fixed64 (408);\n  message->set_default_sfixed32(409);\n  message->set_default_sfixed64(410);\n  message->set_default_float   (411);\n  message->set_default_double  (412);\n  message->set_default_bool    (false);\n  message->set_default_string  (\"415\");\n  message->set_default_bytes   (\"416\");\n\n  message->set_default_nested_enum (unittest::TestAllTypesLite::FOO );\n  message->set_default_foreign_enum(unittest::FOREIGN_LITE_FOO      );\n  message->set_default_import_enum (unittest_import::IMPORT_LITE_FOO);\n\n\n  message->set_oneof_uint32(601);\n  message->mutable_oneof_nested_message()->set_bb(602);\n  message->set_oneof_string(\"603\");\n  message->set_oneof_bytes(\"604\");\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtilLite::ModifyRepeatedFields(unittest::TestAllTypesLite* message) {\n  message->set_repeated_int32   (1, 501);\n  message->set_repeated_int64   (1, 502);\n  message->set_repeated_uint32  (1, 503);\n  message->set_repeated_uint64  (1, 504);\n  message->set_repeated_sint32  (1, 505);\n  message->set_repeated_sint64  (1, 506);\n  message->set_repeated_fixed32 (1, 507);\n  message->set_repeated_fixed64 (1, 508);\n  message->set_repeated_sfixed32(1, 509);\n  message->set_repeated_sfixed64(1, 510);\n  message->set_repeated_float   (1, 511);\n  message->set_repeated_double  (1, 512);\n  message->set_repeated_bool    (1, true);\n  message->set_repeated_string  (1, \"515\");\n  message->set_repeated_bytes   (1, \"516\");\n\n  message->mutable_repeatedgroup           (1)->set_a(517);\n  message->mutable_repeated_nested_message (1)->set_bb(518);\n  message->mutable_repeated_foreign_message(1)->set_c(519);\n  message->mutable_repeated_import_message (1)->set_d(520);\n  message->mutable_repeated_lazy_message   (1)->set_bb(527);\n\n  message->set_repeated_nested_enum (1, unittest::TestAllTypesLite::FOO );\n  message->set_repeated_foreign_enum(1, unittest::FOREIGN_LITE_FOO      );\n  message->set_repeated_import_enum (1, unittest_import::IMPORT_LITE_FOO);\n\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtilLite::ExpectAllFieldsSet(\n    const unittest::TestAllTypesLite& message) {\n  EXPECT_TRUE(message.has_optional_int32   ());\n  EXPECT_TRUE(message.has_optional_int64   ());\n  EXPECT_TRUE(message.has_optional_uint32  ());\n  EXPECT_TRUE(message.has_optional_uint64  ());\n  EXPECT_TRUE(message.has_optional_sint32  ());\n  EXPECT_TRUE(message.has_optional_sint64  ());\n  EXPECT_TRUE(message.has_optional_fixed32 ());\n  EXPECT_TRUE(message.has_optional_fixed64 ());\n  EXPECT_TRUE(message.has_optional_sfixed32());\n  EXPECT_TRUE(message.has_optional_sfixed64());\n  EXPECT_TRUE(message.has_optional_float   ());\n  EXPECT_TRUE(message.has_optional_double  ());\n  EXPECT_TRUE(message.has_optional_bool    ());\n  EXPECT_TRUE(message.has_optional_string  ());\n  EXPECT_TRUE(message.has_optional_bytes   ());\n\n  EXPECT_TRUE(message.has_optionalgroup                 ());\n  EXPECT_TRUE(message.has_optional_nested_message       ());\n  EXPECT_TRUE(message.has_optional_foreign_message      ());\n  EXPECT_TRUE(message.has_optional_import_message       ());\n  EXPECT_TRUE(message.has_optional_public_import_message());\n  EXPECT_TRUE(message.has_optional_lazy_message         ());\n\n  EXPECT_TRUE(message.optionalgroup                 ().has_a());\n  EXPECT_TRUE(message.optional_nested_message       ().has_bb());\n  EXPECT_TRUE(message.optional_foreign_message      ().has_c());\n  EXPECT_TRUE(message.optional_import_message       ().has_d());\n  EXPECT_TRUE(message.optional_public_import_message().has_e());\n  EXPECT_TRUE(message.optional_lazy_message         ().has_bb());\n\n  EXPECT_TRUE(message.has_optional_nested_enum ());\n  EXPECT_TRUE(message.has_optional_foreign_enum());\n  EXPECT_TRUE(message.has_optional_import_enum ());\n\n\n  EXPECT_EQ(101  , message.optional_int32   ());\n  EXPECT_EQ(102  , message.optional_int64   ());\n  EXPECT_EQ(103  , message.optional_uint32  ());\n  EXPECT_EQ(104  , message.optional_uint64  ());\n  EXPECT_EQ(105  , message.optional_sint32  ());\n  EXPECT_EQ(106  , message.optional_sint64  ());\n  EXPECT_EQ(107  , message.optional_fixed32 ());\n  EXPECT_EQ(108  , message.optional_fixed64 ());\n  EXPECT_EQ(109  , message.optional_sfixed32());\n  EXPECT_EQ(110  , message.optional_sfixed64());\n  EXPECT_EQ(111  , message.optional_float   ());\n  EXPECT_EQ(112  , message.optional_double  ());\n  EXPECT_EQ(true , message.optional_bool    ());\n  EXPECT_EQ(\"115\", message.optional_string  ());\n  EXPECT_EQ(\"116\", message.optional_bytes   ());\n\n  EXPECT_EQ(117, message.optionalgroup                 ().a());\n  EXPECT_EQ(118, message.optional_nested_message       ().bb());\n  EXPECT_EQ(119, message.optional_foreign_message      ().c());\n  EXPECT_EQ(120, message.optional_import_message       ().d());\n  EXPECT_EQ(126, message.optional_public_import_message().e());\n  EXPECT_EQ(127, message.optional_lazy_message         ().bb());\n\n  EXPECT_EQ(unittest::TestAllTypesLite::BAZ , message.optional_nested_enum ());\n  EXPECT_EQ(unittest::FOREIGN_LITE_BAZ      , message.optional_foreign_enum());\n  EXPECT_EQ(unittest_import::IMPORT_LITE_BAZ, message.optional_import_enum ());\n\n\n  // -----------------------------------------------------------------\n\n  ASSERT_EQ(2, message.repeated_int32_size   ());\n  ASSERT_EQ(2, message.repeated_int64_size   ());\n  ASSERT_EQ(2, message.repeated_uint32_size  ());\n  ASSERT_EQ(2, message.repeated_uint64_size  ());\n  ASSERT_EQ(2, message.repeated_sint32_size  ());\n  ASSERT_EQ(2, message.repeated_sint64_size  ());\n  ASSERT_EQ(2, message.repeated_fixed32_size ());\n  ASSERT_EQ(2, message.repeated_fixed64_size ());\n  ASSERT_EQ(2, message.repeated_sfixed32_size());\n  ASSERT_EQ(2, message.repeated_sfixed64_size());\n  ASSERT_EQ(2, message.repeated_float_size   ());\n  ASSERT_EQ(2, message.repeated_double_size  ());\n  ASSERT_EQ(2, message.repeated_bool_size    ());\n  ASSERT_EQ(2, message.repeated_string_size  ());\n  ASSERT_EQ(2, message.repeated_bytes_size   ());\n\n  ASSERT_EQ(2, message.repeatedgroup_size           ());\n  ASSERT_EQ(2, message.repeated_nested_message_size ());\n  ASSERT_EQ(2, message.repeated_foreign_message_size());\n  ASSERT_EQ(2, message.repeated_import_message_size ());\n  ASSERT_EQ(2, message.repeated_lazy_message_size   ());\n  ASSERT_EQ(2, message.repeated_nested_enum_size    ());\n  ASSERT_EQ(2, message.repeated_foreign_enum_size   ());\n  ASSERT_EQ(2, message.repeated_import_enum_size    ());\n\n\n  EXPECT_EQ(201  , message.repeated_int32   (0));\n  EXPECT_EQ(202  , message.repeated_int64   (0));\n  EXPECT_EQ(203  , message.repeated_uint32  (0));\n  EXPECT_EQ(204  , message.repeated_uint64  (0));\n  EXPECT_EQ(205  , message.repeated_sint32  (0));\n  EXPECT_EQ(206  , message.repeated_sint64  (0));\n  EXPECT_EQ(207  , message.repeated_fixed32 (0));\n  EXPECT_EQ(208  , message.repeated_fixed64 (0));\n  EXPECT_EQ(209  , message.repeated_sfixed32(0));\n  EXPECT_EQ(210  , message.repeated_sfixed64(0));\n  EXPECT_EQ(211  , message.repeated_float   (0));\n  EXPECT_EQ(212  , message.repeated_double  (0));\n  EXPECT_EQ(true , message.repeated_bool    (0));\n  EXPECT_EQ(\"215\", message.repeated_string  (0));\n  EXPECT_EQ(\"216\", message.repeated_bytes   (0));\n\n  EXPECT_EQ(217, message.repeatedgroup           (0).a());\n  EXPECT_EQ(218, message.repeated_nested_message (0).bb());\n  EXPECT_EQ(219, message.repeated_foreign_message(0).c());\n  EXPECT_EQ(220, message.repeated_import_message (0).d());\n  EXPECT_EQ(227, message.repeated_lazy_message   (0).bb());\n\n\n  EXPECT_EQ(unittest::TestAllTypesLite::BAR , message.repeated_nested_enum (0));\n  EXPECT_EQ(unittest::FOREIGN_LITE_BAR      , message.repeated_foreign_enum(0));\n  EXPECT_EQ(unittest_import::IMPORT_LITE_BAR, message.repeated_import_enum (0));\n\n  EXPECT_EQ(301  , message.repeated_int32   (1));\n  EXPECT_EQ(302  , message.repeated_int64   (1));\n  EXPECT_EQ(303  , message.repeated_uint32  (1));\n  EXPECT_EQ(304  , message.repeated_uint64  (1));\n  EXPECT_EQ(305  , message.repeated_sint32  (1));\n  EXPECT_EQ(306  , message.repeated_sint64  (1));\n  EXPECT_EQ(307  , message.repeated_fixed32 (1));\n  EXPECT_EQ(308  , message.repeated_fixed64 (1));\n  EXPECT_EQ(309  , message.repeated_sfixed32(1));\n  EXPECT_EQ(310  , message.repeated_sfixed64(1));\n  EXPECT_EQ(311  , message.repeated_float   (1));\n  EXPECT_EQ(312  , message.repeated_double  (1));\n  EXPECT_EQ(false, message.repeated_bool    (1));\n  EXPECT_EQ(\"315\", message.repeated_string  (1));\n  EXPECT_EQ(\"316\", message.repeated_bytes   (1));\n\n  EXPECT_EQ(317, message.repeatedgroup           (1).a());\n  EXPECT_EQ(318, message.repeated_nested_message (1).bb());\n  EXPECT_EQ(319, message.repeated_foreign_message(1).c());\n  EXPECT_EQ(320, message.repeated_import_message (1).d());\n  EXPECT_EQ(327, message.repeated_lazy_message   (1).bb());\n\n  EXPECT_EQ(unittest::TestAllTypesLite::BAZ , message.repeated_nested_enum (1));\n  EXPECT_EQ(unittest::FOREIGN_LITE_BAZ      , message.repeated_foreign_enum(1));\n  EXPECT_EQ(unittest_import::IMPORT_LITE_BAZ, message.repeated_import_enum (1));\n\n\n  // -----------------------------------------------------------------\n\n  EXPECT_TRUE(message.has_default_int32   ());\n  EXPECT_TRUE(message.has_default_int64   ());\n  EXPECT_TRUE(message.has_default_uint32  ());\n  EXPECT_TRUE(message.has_default_uint64  ());\n  EXPECT_TRUE(message.has_default_sint32  ());\n  EXPECT_TRUE(message.has_default_sint64  ());\n  EXPECT_TRUE(message.has_default_fixed32 ());\n  EXPECT_TRUE(message.has_default_fixed64 ());\n  EXPECT_TRUE(message.has_default_sfixed32());\n  EXPECT_TRUE(message.has_default_sfixed64());\n  EXPECT_TRUE(message.has_default_float   ());\n  EXPECT_TRUE(message.has_default_double  ());\n  EXPECT_TRUE(message.has_default_bool    ());\n  EXPECT_TRUE(message.has_default_string  ());\n  EXPECT_TRUE(message.has_default_bytes   ());\n\n  EXPECT_TRUE(message.has_default_nested_enum ());\n  EXPECT_TRUE(message.has_default_foreign_enum());\n  EXPECT_TRUE(message.has_default_import_enum ());\n\n\n  EXPECT_EQ(401  , message.default_int32   ());\n  EXPECT_EQ(402  , message.default_int64   ());\n  EXPECT_EQ(403  , message.default_uint32  ());\n  EXPECT_EQ(404  , message.default_uint64  ());\n  EXPECT_EQ(405  , message.default_sint32  ());\n  EXPECT_EQ(406  , message.default_sint64  ());\n  EXPECT_EQ(407  , message.default_fixed32 ());\n  EXPECT_EQ(408  , message.default_fixed64 ());\n  EXPECT_EQ(409  , message.default_sfixed32());\n  EXPECT_EQ(410  , message.default_sfixed64());\n  EXPECT_EQ(411  , message.default_float   ());\n  EXPECT_EQ(412  , message.default_double  ());\n  EXPECT_EQ(false, message.default_bool    ());\n  EXPECT_EQ(\"415\", message.default_string  ());\n  EXPECT_EQ(\"416\", message.default_bytes   ());\n\n  EXPECT_EQ(unittest::TestAllTypesLite::FOO , message.default_nested_enum ());\n  EXPECT_EQ(unittest::FOREIGN_LITE_FOO      , message.default_foreign_enum());\n  EXPECT_EQ(unittest_import::IMPORT_LITE_FOO, message.default_import_enum ());\n\n\n  EXPECT_FALSE(message.has_oneof_uint32        ());\n  EXPECT_FALSE(message.has_oneof_nested_message());\n  EXPECT_FALSE(message.has_oneof_string        ());\n  EXPECT_TRUE(message.has_oneof_bytes          ());\n\n  EXPECT_EQ(\"604\", message.oneof_bytes());\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtilLite::ExpectClear(const unittest::TestAllTypesLite& message) {\n  // has_blah() should initially be false for all optional fields.\n  EXPECT_FALSE(message.has_optional_int32   ());\n  EXPECT_FALSE(message.has_optional_int64   ());\n  EXPECT_FALSE(message.has_optional_uint32  ());\n  EXPECT_FALSE(message.has_optional_uint64  ());\n  EXPECT_FALSE(message.has_optional_sint32  ());\n  EXPECT_FALSE(message.has_optional_sint64  ());\n  EXPECT_FALSE(message.has_optional_fixed32 ());\n  EXPECT_FALSE(message.has_optional_fixed64 ());\n  EXPECT_FALSE(message.has_optional_sfixed32());\n  EXPECT_FALSE(message.has_optional_sfixed64());\n  EXPECT_FALSE(message.has_optional_float   ());\n  EXPECT_FALSE(message.has_optional_double  ());\n  EXPECT_FALSE(message.has_optional_bool    ());\n  EXPECT_FALSE(message.has_optional_string  ());\n  EXPECT_FALSE(message.has_optional_bytes   ());\n\n  EXPECT_FALSE(message.has_optionalgroup                 ());\n  EXPECT_FALSE(message.has_optional_nested_message       ());\n  EXPECT_FALSE(message.has_optional_foreign_message      ());\n  EXPECT_FALSE(message.has_optional_import_message       ());\n  EXPECT_FALSE(message.has_optional_public_import_message());\n  EXPECT_FALSE(message.has_optional_lazy_message         ());\n\n  EXPECT_FALSE(message.has_optional_nested_enum ());\n  EXPECT_FALSE(message.has_optional_foreign_enum());\n  EXPECT_FALSE(message.has_optional_import_enum ());\n\n\n  // Optional fields without defaults are set to zero or something like it.\n  EXPECT_EQ(0    , message.optional_int32   ());\n  EXPECT_EQ(0    , message.optional_int64   ());\n  EXPECT_EQ(0    , message.optional_uint32  ());\n  EXPECT_EQ(0    , message.optional_uint64  ());\n  EXPECT_EQ(0    , message.optional_sint32  ());\n  EXPECT_EQ(0    , message.optional_sint64  ());\n  EXPECT_EQ(0    , message.optional_fixed32 ());\n  EXPECT_EQ(0    , message.optional_fixed64 ());\n  EXPECT_EQ(0    , message.optional_sfixed32());\n  EXPECT_EQ(0    , message.optional_sfixed64());\n  EXPECT_EQ(0    , message.optional_float   ());\n  EXPECT_EQ(0    , message.optional_double  ());\n  EXPECT_EQ(false, message.optional_bool    ());\n  EXPECT_EQ(\"\"   , message.optional_string  ());\n  EXPECT_EQ(\"\"   , message.optional_bytes   ());\n\n  // Embedded messages should also be clear.\n  EXPECT_FALSE(message.optionalgroup                 ().has_a());\n  EXPECT_FALSE(message.optional_nested_message       ().has_bb());\n  EXPECT_FALSE(message.optional_foreign_message      ().has_c());\n  EXPECT_FALSE(message.optional_import_message       ().has_d());\n  EXPECT_FALSE(message.optional_public_import_message().has_e());\n  EXPECT_FALSE(message.optional_lazy_message         ().has_bb());\n\n  EXPECT_EQ(0, message.optionalgroup           ().a());\n  EXPECT_EQ(0, message.optional_nested_message ().bb());\n  EXPECT_EQ(0, message.optional_foreign_message().c());\n  EXPECT_EQ(0, message.optional_import_message ().d());\n\n  // Enums without defaults are set to the first value in the enum.\n  EXPECT_EQ(unittest::TestAllTypesLite::FOO , message.optional_nested_enum ());\n  EXPECT_EQ(unittest::FOREIGN_LITE_FOO      , message.optional_foreign_enum());\n  EXPECT_EQ(unittest_import::IMPORT_LITE_FOO, message.optional_import_enum ());\n\n\n  // Repeated fields are empty.\n  EXPECT_EQ(0, message.repeated_int32_size   ());\n  EXPECT_EQ(0, message.repeated_int64_size   ());\n  EXPECT_EQ(0, message.repeated_uint32_size  ());\n  EXPECT_EQ(0, message.repeated_uint64_size  ());\n  EXPECT_EQ(0, message.repeated_sint32_size  ());\n  EXPECT_EQ(0, message.repeated_sint64_size  ());\n  EXPECT_EQ(0, message.repeated_fixed32_size ());\n  EXPECT_EQ(0, message.repeated_fixed64_size ());\n  EXPECT_EQ(0, message.repeated_sfixed32_size());\n  EXPECT_EQ(0, message.repeated_sfixed64_size());\n  EXPECT_EQ(0, message.repeated_float_size   ());\n  EXPECT_EQ(0, message.repeated_double_size  ());\n  EXPECT_EQ(0, message.repeated_bool_size    ());\n  EXPECT_EQ(0, message.repeated_string_size  ());\n  EXPECT_EQ(0, message.repeated_bytes_size   ());\n\n  EXPECT_EQ(0, message.repeatedgroup_size           ());\n  EXPECT_EQ(0, message.repeated_nested_message_size ());\n  EXPECT_EQ(0, message.repeated_foreign_message_size());\n  EXPECT_EQ(0, message.repeated_import_message_size ());\n  EXPECT_EQ(0, message.repeated_lazy_message_size   ());\n  EXPECT_EQ(0, message.repeated_nested_enum_size    ());\n  EXPECT_EQ(0, message.repeated_foreign_enum_size   ());\n  EXPECT_EQ(0, message.repeated_import_enum_size    ());\n\n\n  // has_blah() should also be false for all default fields.\n  EXPECT_FALSE(message.has_default_int32   ());\n  EXPECT_FALSE(message.has_default_int64   ());\n  EXPECT_FALSE(message.has_default_uint32  ());\n  EXPECT_FALSE(message.has_default_uint64  ());\n  EXPECT_FALSE(message.has_default_sint32  ());\n  EXPECT_FALSE(message.has_default_sint64  ());\n  EXPECT_FALSE(message.has_default_fixed32 ());\n  EXPECT_FALSE(message.has_default_fixed64 ());\n  EXPECT_FALSE(message.has_default_sfixed32());\n  EXPECT_FALSE(message.has_default_sfixed64());\n  EXPECT_FALSE(message.has_default_float   ());\n  EXPECT_FALSE(message.has_default_double  ());\n  EXPECT_FALSE(message.has_default_bool    ());\n  EXPECT_FALSE(message.has_default_string  ());\n  EXPECT_FALSE(message.has_default_bytes   ());\n\n  EXPECT_FALSE(message.has_default_nested_enum ());\n  EXPECT_FALSE(message.has_default_foreign_enum());\n  EXPECT_FALSE(message.has_default_import_enum ());\n\n\n  // Fields with defaults have their default values (duh).\n  EXPECT_EQ( 41    , message.default_int32   ());\n  EXPECT_EQ( 42    , message.default_int64   ());\n  EXPECT_EQ( 43    , message.default_uint32  ());\n  EXPECT_EQ( 44    , message.default_uint64  ());\n  EXPECT_EQ(-45    , message.default_sint32  ());\n  EXPECT_EQ( 46    , message.default_sint64  ());\n  EXPECT_EQ( 47    , message.default_fixed32 ());\n  EXPECT_EQ( 48    , message.default_fixed64 ());\n  EXPECT_EQ( 49    , message.default_sfixed32());\n  EXPECT_EQ(-50    , message.default_sfixed64());\n  EXPECT_EQ( 51.5  , message.default_float   ());\n  EXPECT_EQ( 52e3  , message.default_double  ());\n  EXPECT_EQ(true   , message.default_bool    ());\n  EXPECT_EQ(\"hello\", message.default_string  ());\n  EXPECT_EQ(\"world\", message.default_bytes   ());\n\n  EXPECT_EQ(unittest::TestAllTypesLite::BAR , message.default_nested_enum ());\n  EXPECT_EQ(unittest::FOREIGN_LITE_BAR      , message.default_foreign_enum());\n  EXPECT_EQ(unittest_import::IMPORT_LITE_BAR, message.default_import_enum ());\n\n\n  EXPECT_FALSE(message.has_oneof_uint32        ());\n  EXPECT_FALSE(message.has_oneof_nested_message());\n  EXPECT_FALSE(message.has_oneof_string        ());\n  EXPECT_FALSE(message.has_oneof_bytes         ());\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtilLite::ExpectRepeatedFieldsModified(\n    const unittest::TestAllTypesLite& message) {\n  // ModifyRepeatedFields only sets the second repeated element of each\n  // field.  In addition to verifying this, we also verify that the first\n  // element and size were *not* modified.\n  ASSERT_EQ(2, message.repeated_int32_size   ());\n  ASSERT_EQ(2, message.repeated_int64_size   ());\n  ASSERT_EQ(2, message.repeated_uint32_size  ());\n  ASSERT_EQ(2, message.repeated_uint64_size  ());\n  ASSERT_EQ(2, message.repeated_sint32_size  ());\n  ASSERT_EQ(2, message.repeated_sint64_size  ());\n  ASSERT_EQ(2, message.repeated_fixed32_size ());\n  ASSERT_EQ(2, message.repeated_fixed64_size ());\n  ASSERT_EQ(2, message.repeated_sfixed32_size());\n  ASSERT_EQ(2, message.repeated_sfixed64_size());\n  ASSERT_EQ(2, message.repeated_float_size   ());\n  ASSERT_EQ(2, message.repeated_double_size  ());\n  ASSERT_EQ(2, message.repeated_bool_size    ());\n  ASSERT_EQ(2, message.repeated_string_size  ());\n  ASSERT_EQ(2, message.repeated_bytes_size   ());\n\n  ASSERT_EQ(2, message.repeatedgroup_size           ());\n  ASSERT_EQ(2, message.repeated_nested_message_size ());\n  ASSERT_EQ(2, message.repeated_foreign_message_size());\n  ASSERT_EQ(2, message.repeated_import_message_size ());\n  ASSERT_EQ(2, message.repeated_lazy_message_size   ());\n  ASSERT_EQ(2, message.repeated_nested_enum_size    ());\n  ASSERT_EQ(2, message.repeated_foreign_enum_size   ());\n  ASSERT_EQ(2, message.repeated_import_enum_size    ());\n\n\n  EXPECT_EQ(201  , message.repeated_int32   (0));\n  EXPECT_EQ(202  , message.repeated_int64   (0));\n  EXPECT_EQ(203  , message.repeated_uint32  (0));\n  EXPECT_EQ(204  , message.repeated_uint64  (0));\n  EXPECT_EQ(205  , message.repeated_sint32  (0));\n  EXPECT_EQ(206  , message.repeated_sint64  (0));\n  EXPECT_EQ(207  , message.repeated_fixed32 (0));\n  EXPECT_EQ(208  , message.repeated_fixed64 (0));\n  EXPECT_EQ(209  , message.repeated_sfixed32(0));\n  EXPECT_EQ(210  , message.repeated_sfixed64(0));\n  EXPECT_EQ(211  , message.repeated_float   (0));\n  EXPECT_EQ(212  , message.repeated_double  (0));\n  EXPECT_EQ(true , message.repeated_bool    (0));\n  EXPECT_EQ(\"215\", message.repeated_string  (0));\n  EXPECT_EQ(\"216\", message.repeated_bytes   (0));\n\n  EXPECT_EQ(217, message.repeatedgroup           (0).a());\n  EXPECT_EQ(218, message.repeated_nested_message (0).bb());\n  EXPECT_EQ(219, message.repeated_foreign_message(0).c());\n  EXPECT_EQ(220, message.repeated_import_message (0).d());\n  EXPECT_EQ(227, message.repeated_lazy_message   (0).bb());\n\n  EXPECT_EQ(unittest::TestAllTypesLite::BAR , message.repeated_nested_enum (0));\n  EXPECT_EQ(unittest::FOREIGN_LITE_BAR      , message.repeated_foreign_enum(0));\n  EXPECT_EQ(unittest_import::IMPORT_LITE_BAR, message.repeated_import_enum (0));\n\n\n  // Actually verify the second (modified) elements now.\n  EXPECT_EQ(501  , message.repeated_int32   (1));\n  EXPECT_EQ(502  , message.repeated_int64   (1));\n  EXPECT_EQ(503  , message.repeated_uint32  (1));\n  EXPECT_EQ(504  , message.repeated_uint64  (1));\n  EXPECT_EQ(505  , message.repeated_sint32  (1));\n  EXPECT_EQ(506  , message.repeated_sint64  (1));\n  EXPECT_EQ(507  , message.repeated_fixed32 (1));\n  EXPECT_EQ(508  , message.repeated_fixed64 (1));\n  EXPECT_EQ(509  , message.repeated_sfixed32(1));\n  EXPECT_EQ(510  , message.repeated_sfixed64(1));\n  EXPECT_EQ(511  , message.repeated_float   (1));\n  EXPECT_EQ(512  , message.repeated_double  (1));\n  EXPECT_EQ(true , message.repeated_bool    (1));\n  EXPECT_EQ(\"515\", message.repeated_string  (1));\n  EXPECT_EQ(\"516\", message.repeated_bytes   (1));\n\n  EXPECT_EQ(517, message.repeatedgroup           (1).a());\n  EXPECT_EQ(518, message.repeated_nested_message (1).bb());\n  EXPECT_EQ(519, message.repeated_foreign_message(1).c());\n  EXPECT_EQ(520, message.repeated_import_message (1).d());\n  EXPECT_EQ(527, message.repeated_lazy_message   (1).bb());\n\n  EXPECT_EQ(unittest::TestAllTypesLite::FOO , message.repeated_nested_enum (1));\n  EXPECT_EQ(unittest::FOREIGN_LITE_FOO      , message.repeated_foreign_enum(1));\n  EXPECT_EQ(unittest_import::IMPORT_LITE_FOO, message.repeated_import_enum (1));\n\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtilLite::SetPackedFields(unittest::TestPackedTypesLite* message) {\n  message->add_packed_int32   (601);\n  message->add_packed_int64   (602);\n  message->add_packed_uint32  (603);\n  message->add_packed_uint64  (604);\n  message->add_packed_sint32  (605);\n  message->add_packed_sint64  (606);\n  message->add_packed_fixed32 (607);\n  message->add_packed_fixed64 (608);\n  message->add_packed_sfixed32(609);\n  message->add_packed_sfixed64(610);\n  message->add_packed_float   (611);\n  message->add_packed_double  (612);\n  message->add_packed_bool    (true);\n  message->add_packed_enum    (unittest::FOREIGN_LITE_BAR);\n  // add a second one of each field\n  message->add_packed_int32   (701);\n  message->add_packed_int64   (702);\n  message->add_packed_uint32  (703);\n  message->add_packed_uint64  (704);\n  message->add_packed_sint32  (705);\n  message->add_packed_sint64  (706);\n  message->add_packed_fixed32 (707);\n  message->add_packed_fixed64 (708);\n  message->add_packed_sfixed32(709);\n  message->add_packed_sfixed64(710);\n  message->add_packed_float   (711);\n  message->add_packed_double  (712);\n  message->add_packed_bool    (false);\n  message->add_packed_enum    (unittest::FOREIGN_LITE_BAZ);\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtilLite::ModifyPackedFields(unittest::TestPackedTypesLite* message) {\n  message->set_packed_int32   (1, 801);\n  message->set_packed_int64   (1, 802);\n  message->set_packed_uint32  (1, 803);\n  message->set_packed_uint64  (1, 804);\n  message->set_packed_sint32  (1, 805);\n  message->set_packed_sint64  (1, 806);\n  message->set_packed_fixed32 (1, 807);\n  message->set_packed_fixed64 (1, 808);\n  message->set_packed_sfixed32(1, 809);\n  message->set_packed_sfixed64(1, 810);\n  message->set_packed_float   (1, 811);\n  message->set_packed_double  (1, 812);\n  message->set_packed_bool    (1, true);\n  message->set_packed_enum    (1, unittest::FOREIGN_LITE_FOO);\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtilLite::ExpectPackedFieldsSet(\n    const unittest::TestPackedTypesLite& message) {\n  ASSERT_EQ(2, message.packed_int32_size   ());\n  ASSERT_EQ(2, message.packed_int64_size   ());\n  ASSERT_EQ(2, message.packed_uint32_size  ());\n  ASSERT_EQ(2, message.packed_uint64_size  ());\n  ASSERT_EQ(2, message.packed_sint32_size  ());\n  ASSERT_EQ(2, message.packed_sint64_size  ());\n  ASSERT_EQ(2, message.packed_fixed32_size ());\n  ASSERT_EQ(2, message.packed_fixed64_size ());\n  ASSERT_EQ(2, message.packed_sfixed32_size());\n  ASSERT_EQ(2, message.packed_sfixed64_size());\n  ASSERT_EQ(2, message.packed_float_size   ());\n  ASSERT_EQ(2, message.packed_double_size  ());\n  ASSERT_EQ(2, message.packed_bool_size    ());\n  ASSERT_EQ(2, message.packed_enum_size    ());\n\n  EXPECT_EQ(601  , message.packed_int32   (0));\n  EXPECT_EQ(602  , message.packed_int64   (0));\n  EXPECT_EQ(603  , message.packed_uint32  (0));\n  EXPECT_EQ(604  , message.packed_uint64  (0));\n  EXPECT_EQ(605  , message.packed_sint32  (0));\n  EXPECT_EQ(606  , message.packed_sint64  (0));\n  EXPECT_EQ(607  , message.packed_fixed32 (0));\n  EXPECT_EQ(608  , message.packed_fixed64 (0));\n  EXPECT_EQ(609  , message.packed_sfixed32(0));\n  EXPECT_EQ(610  , message.packed_sfixed64(0));\n  EXPECT_EQ(611  , message.packed_float   (0));\n  EXPECT_EQ(612  , message.packed_double  (0));\n  EXPECT_EQ(true , message.packed_bool    (0));\n  EXPECT_EQ(unittest::FOREIGN_LITE_BAR, message.packed_enum(0));\n\n  EXPECT_EQ(701  , message.packed_int32   (1));\n  EXPECT_EQ(702  , message.packed_int64   (1));\n  EXPECT_EQ(703  , message.packed_uint32  (1));\n  EXPECT_EQ(704  , message.packed_uint64  (1));\n  EXPECT_EQ(705  , message.packed_sint32  (1));\n  EXPECT_EQ(706  , message.packed_sint64  (1));\n  EXPECT_EQ(707  , message.packed_fixed32 (1));\n  EXPECT_EQ(708  , message.packed_fixed64 (1));\n  EXPECT_EQ(709  , message.packed_sfixed32(1));\n  EXPECT_EQ(710  , message.packed_sfixed64(1));\n  EXPECT_EQ(711  , message.packed_float   (1));\n  EXPECT_EQ(712  , message.packed_double  (1));\n  EXPECT_EQ(false, message.packed_bool    (1));\n  EXPECT_EQ(unittest::FOREIGN_LITE_BAZ, message.packed_enum(1));\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtilLite::ExpectPackedClear(\n    const unittest::TestPackedTypesLite& message) {\n  // Packed repeated fields are empty.\n  EXPECT_EQ(0, message.packed_int32_size   ());\n  EXPECT_EQ(0, message.packed_int64_size   ());\n  EXPECT_EQ(0, message.packed_uint32_size  ());\n  EXPECT_EQ(0, message.packed_uint64_size  ());\n  EXPECT_EQ(0, message.packed_sint32_size  ());\n  EXPECT_EQ(0, message.packed_sint64_size  ());\n  EXPECT_EQ(0, message.packed_fixed32_size ());\n  EXPECT_EQ(0, message.packed_fixed64_size ());\n  EXPECT_EQ(0, message.packed_sfixed32_size());\n  EXPECT_EQ(0, message.packed_sfixed64_size());\n  EXPECT_EQ(0, message.packed_float_size   ());\n  EXPECT_EQ(0, message.packed_double_size  ());\n  EXPECT_EQ(0, message.packed_bool_size    ());\n  EXPECT_EQ(0, message.packed_enum_size    ());\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtilLite::ExpectPackedFieldsModified(\n    const unittest::TestPackedTypesLite& message) {\n  // Do the same for packed repeated fields.\n  ASSERT_EQ(2, message.packed_int32_size   ());\n  ASSERT_EQ(2, message.packed_int64_size   ());\n  ASSERT_EQ(2, message.packed_uint32_size  ());\n  ASSERT_EQ(2, message.packed_uint64_size  ());\n  ASSERT_EQ(2, message.packed_sint32_size  ());\n  ASSERT_EQ(2, message.packed_sint64_size  ());\n  ASSERT_EQ(2, message.packed_fixed32_size ());\n  ASSERT_EQ(2, message.packed_fixed64_size ());\n  ASSERT_EQ(2, message.packed_sfixed32_size());\n  ASSERT_EQ(2, message.packed_sfixed64_size());\n  ASSERT_EQ(2, message.packed_float_size   ());\n  ASSERT_EQ(2, message.packed_double_size  ());\n  ASSERT_EQ(2, message.packed_bool_size    ());\n  ASSERT_EQ(2, message.packed_enum_size    ());\n\n  EXPECT_EQ(601  , message.packed_int32   (0));\n  EXPECT_EQ(602  , message.packed_int64   (0));\n  EXPECT_EQ(603  , message.packed_uint32  (0));\n  EXPECT_EQ(604  , message.packed_uint64  (0));\n  EXPECT_EQ(605  , message.packed_sint32  (0));\n  EXPECT_EQ(606  , message.packed_sint64  (0));\n  EXPECT_EQ(607  , message.packed_fixed32 (0));\n  EXPECT_EQ(608  , message.packed_fixed64 (0));\n  EXPECT_EQ(609  , message.packed_sfixed32(0));\n  EXPECT_EQ(610  , message.packed_sfixed64(0));\n  EXPECT_EQ(611  , message.packed_float   (0));\n  EXPECT_EQ(612  , message.packed_double  (0));\n  EXPECT_EQ(true , message.packed_bool    (0));\n  EXPECT_EQ(unittest::FOREIGN_LITE_BAR, message.packed_enum(0));\n  // Actually verify the second (modified) elements now.\n  EXPECT_EQ(801  , message.packed_int32   (1));\n  EXPECT_EQ(802  , message.packed_int64   (1));\n  EXPECT_EQ(803  , message.packed_uint32  (1));\n  EXPECT_EQ(804  , message.packed_uint64  (1));\n  EXPECT_EQ(805  , message.packed_sint32  (1));\n  EXPECT_EQ(806  , message.packed_sint64  (1));\n  EXPECT_EQ(807  , message.packed_fixed32 (1));\n  EXPECT_EQ(808  , message.packed_fixed64 (1));\n  EXPECT_EQ(809  , message.packed_sfixed32(1));\n  EXPECT_EQ(810  , message.packed_sfixed64(1));\n  EXPECT_EQ(811  , message.packed_float   (1));\n  EXPECT_EQ(812  , message.packed_double  (1));\n  EXPECT_EQ(true , message.packed_bool    (1));\n  EXPECT_EQ(unittest::FOREIGN_LITE_FOO, message.packed_enum(1));\n}\n\n// ===================================================================\n// Extensions\n//\n// All this code is exactly equivalent to the above code except that it's\n// manipulating extension fields instead of normal ones.\n//\n// I gave up on the 80-char limit here.  Sorry.\n\nvoid TestUtilLite::SetAllExtensions(unittest::TestAllExtensionsLite* message) {\n  message->SetExtension(unittest::optional_int32_extension_lite   , 101);\n  message->SetExtension(unittest::optional_int64_extension_lite   , 102);\n  message->SetExtension(unittest::optional_uint32_extension_lite  , 103);\n  message->SetExtension(unittest::optional_uint64_extension_lite  , 104);\n  message->SetExtension(unittest::optional_sint32_extension_lite  , 105);\n  message->SetExtension(unittest::optional_sint64_extension_lite  , 106);\n  message->SetExtension(unittest::optional_fixed32_extension_lite , 107);\n  message->SetExtension(unittest::optional_fixed64_extension_lite , 108);\n  message->SetExtension(unittest::optional_sfixed32_extension_lite, 109);\n  message->SetExtension(unittest::optional_sfixed64_extension_lite, 110);\n  message->SetExtension(unittest::optional_float_extension_lite   , 111);\n  message->SetExtension(unittest::optional_double_extension_lite  , 112);\n  message->SetExtension(unittest::optional_bool_extension_lite    , true);\n  message->SetExtension(unittest::optional_string_extension_lite  , \"115\");\n  message->SetExtension(unittest::optional_bytes_extension_lite   , \"116\");\n\n  message->MutableExtension(unittest::optionalgroup_extension_lite                 )->set_a(117);\n  message->MutableExtension(unittest::optional_nested_message_extension_lite       )->set_bb(118);\n  message->MutableExtension(unittest::optional_foreign_message_extension_lite      )->set_c(119);\n  message->MutableExtension(unittest::optional_import_message_extension_lite       )->set_d(120);\n  message->MutableExtension(unittest::optional_public_import_message_extension_lite)->set_e(126);\n  message->MutableExtension(unittest::optional_lazy_message_extension_lite         )->set_bb(127);\n\n  message->SetExtension(unittest::optional_nested_enum_extension_lite , unittest::TestAllTypesLite::BAZ );\n  message->SetExtension(unittest::optional_foreign_enum_extension_lite, unittest::FOREIGN_LITE_BAZ      );\n  message->SetExtension(unittest::optional_import_enum_extension_lite , unittest_import::IMPORT_LITE_BAZ);\n\n\n  // -----------------------------------------------------------------\n\n  message->AddExtension(unittest::repeated_int32_extension_lite   , 201);\n  message->AddExtension(unittest::repeated_int64_extension_lite   , 202);\n  message->AddExtension(unittest::repeated_uint32_extension_lite  , 203);\n  message->AddExtension(unittest::repeated_uint64_extension_lite  , 204);\n  message->AddExtension(unittest::repeated_sint32_extension_lite  , 205);\n  message->AddExtension(unittest::repeated_sint64_extension_lite  , 206);\n  message->AddExtension(unittest::repeated_fixed32_extension_lite , 207);\n  message->AddExtension(unittest::repeated_fixed64_extension_lite , 208);\n  message->AddExtension(unittest::repeated_sfixed32_extension_lite, 209);\n  message->AddExtension(unittest::repeated_sfixed64_extension_lite, 210);\n  message->AddExtension(unittest::repeated_float_extension_lite   , 211);\n  message->AddExtension(unittest::repeated_double_extension_lite  , 212);\n  message->AddExtension(unittest::repeated_bool_extension_lite    , true);\n  message->AddExtension(unittest::repeated_string_extension_lite  , \"215\");\n  message->AddExtension(unittest::repeated_bytes_extension_lite   , \"216\");\n\n  message->AddExtension(unittest::repeatedgroup_extension_lite           )->set_a(217);\n  message->AddExtension(unittest::repeated_nested_message_extension_lite )->set_bb(218);\n  message->AddExtension(unittest::repeated_foreign_message_extension_lite)->set_c(219);\n  message->AddExtension(unittest::repeated_import_message_extension_lite )->set_d(220);\n  message->AddExtension(unittest::repeated_lazy_message_extension_lite   )->set_bb(227);\n\n  message->AddExtension(unittest::repeated_nested_enum_extension_lite , unittest::TestAllTypesLite::BAR );\n  message->AddExtension(unittest::repeated_foreign_enum_extension_lite, unittest::FOREIGN_LITE_BAR      );\n  message->AddExtension(unittest::repeated_import_enum_extension_lite , unittest_import::IMPORT_LITE_BAR);\n\n\n  // Add a second one of each field.\n  message->AddExtension(unittest::repeated_int32_extension_lite   , 301);\n  message->AddExtension(unittest::repeated_int64_extension_lite   , 302);\n  message->AddExtension(unittest::repeated_uint32_extension_lite  , 303);\n  message->AddExtension(unittest::repeated_uint64_extension_lite  , 304);\n  message->AddExtension(unittest::repeated_sint32_extension_lite  , 305);\n  message->AddExtension(unittest::repeated_sint64_extension_lite  , 306);\n  message->AddExtension(unittest::repeated_fixed32_extension_lite , 307);\n  message->AddExtension(unittest::repeated_fixed64_extension_lite , 308);\n  message->AddExtension(unittest::repeated_sfixed32_extension_lite, 309);\n  message->AddExtension(unittest::repeated_sfixed64_extension_lite, 310);\n  message->AddExtension(unittest::repeated_float_extension_lite   , 311);\n  message->AddExtension(unittest::repeated_double_extension_lite  , 312);\n  message->AddExtension(unittest::repeated_bool_extension_lite    , false);\n  message->AddExtension(unittest::repeated_string_extension_lite  , \"315\");\n  message->AddExtension(unittest::repeated_bytes_extension_lite   , \"316\");\n\n  message->AddExtension(unittest::repeatedgroup_extension_lite           )->set_a(317);\n  message->AddExtension(unittest::repeated_nested_message_extension_lite )->set_bb(318);\n  message->AddExtension(unittest::repeated_foreign_message_extension_lite)->set_c(319);\n  message->AddExtension(unittest::repeated_import_message_extension_lite )->set_d(320);\n  message->AddExtension(unittest::repeated_lazy_message_extension_lite   )->set_bb(327);\n\n  message->AddExtension(unittest::repeated_nested_enum_extension_lite , unittest::TestAllTypesLite::BAZ );\n  message->AddExtension(unittest::repeated_foreign_enum_extension_lite, unittest::FOREIGN_LITE_BAZ      );\n  message->AddExtension(unittest::repeated_import_enum_extension_lite , unittest_import::IMPORT_LITE_BAZ);\n\n\n  // -----------------------------------------------------------------\n\n  message->SetExtension(unittest::default_int32_extension_lite   , 401);\n  message->SetExtension(unittest::default_int64_extension_lite   , 402);\n  message->SetExtension(unittest::default_uint32_extension_lite  , 403);\n  message->SetExtension(unittest::default_uint64_extension_lite  , 404);\n  message->SetExtension(unittest::default_sint32_extension_lite  , 405);\n  message->SetExtension(unittest::default_sint64_extension_lite  , 406);\n  message->SetExtension(unittest::default_fixed32_extension_lite , 407);\n  message->SetExtension(unittest::default_fixed64_extension_lite , 408);\n  message->SetExtension(unittest::default_sfixed32_extension_lite, 409);\n  message->SetExtension(unittest::default_sfixed64_extension_lite, 410);\n  message->SetExtension(unittest::default_float_extension_lite   , 411);\n  message->SetExtension(unittest::default_double_extension_lite  , 412);\n  message->SetExtension(unittest::default_bool_extension_lite    , false);\n  message->SetExtension(unittest::default_string_extension_lite  , \"415\");\n  message->SetExtension(unittest::default_bytes_extension_lite   , \"416\");\n\n  message->SetExtension(unittest::default_nested_enum_extension_lite , unittest::TestAllTypesLite::FOO );\n  message->SetExtension(unittest::default_foreign_enum_extension_lite, unittest::FOREIGN_LITE_FOO      );\n  message->SetExtension(unittest::default_import_enum_extension_lite , unittest_import::IMPORT_LITE_FOO);\n\n\n  message->SetExtension(unittest::oneof_uint32_extension_lite, 601);\n  message->MutableExtension(unittest::oneof_nested_message_extension_lite)->set_bb(602);;\n  message->SetExtension(unittest::oneof_string_extension_lite, \"603\");\n  message->SetExtension(unittest::oneof_bytes_extension_lite, \"604\");\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtilLite::ModifyRepeatedExtensions(\n    unittest::TestAllExtensionsLite* message) {\n  message->SetExtension(unittest::repeated_int32_extension_lite   , 1, 501);\n  message->SetExtension(unittest::repeated_int64_extension_lite   , 1, 502);\n  message->SetExtension(unittest::repeated_uint32_extension_lite  , 1, 503);\n  message->SetExtension(unittest::repeated_uint64_extension_lite  , 1, 504);\n  message->SetExtension(unittest::repeated_sint32_extension_lite  , 1, 505);\n  message->SetExtension(unittest::repeated_sint64_extension_lite  , 1, 506);\n  message->SetExtension(unittest::repeated_fixed32_extension_lite , 1, 507);\n  message->SetExtension(unittest::repeated_fixed64_extension_lite , 1, 508);\n  message->SetExtension(unittest::repeated_sfixed32_extension_lite, 1, 509);\n  message->SetExtension(unittest::repeated_sfixed64_extension_lite, 1, 510);\n  message->SetExtension(unittest::repeated_float_extension_lite   , 1, 511);\n  message->SetExtension(unittest::repeated_double_extension_lite  , 1, 512);\n  message->SetExtension(unittest::repeated_bool_extension_lite    , 1, true);\n  message->SetExtension(unittest::repeated_string_extension_lite  , 1, \"515\");\n  message->SetExtension(unittest::repeated_bytes_extension_lite   , 1, \"516\");\n\n  message->MutableExtension(unittest::repeatedgroup_extension_lite           , 1)->set_a(517);\n  message->MutableExtension(unittest::repeated_nested_message_extension_lite , 1)->set_bb(518);\n  message->MutableExtension(unittest::repeated_foreign_message_extension_lite, 1)->set_c(519);\n  message->MutableExtension(unittest::repeated_import_message_extension_lite , 1)->set_d(520);\n  message->MutableExtension(unittest::repeated_lazy_message_extension_lite   , 1)->set_bb(527);\n\n  message->SetExtension(unittest::repeated_nested_enum_extension_lite , 1, unittest::TestAllTypesLite::FOO );\n  message->SetExtension(unittest::repeated_foreign_enum_extension_lite, 1, unittest::FOREIGN_LITE_FOO      );\n  message->SetExtension(unittest::repeated_import_enum_extension_lite , 1, unittest_import::IMPORT_LITE_FOO);\n\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtilLite::ExpectAllExtensionsSet(\n    const unittest::TestAllExtensionsLite& message) {\n  EXPECT_TRUE(message.HasExtension(unittest::optional_int32_extension_lite   ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_int64_extension_lite   ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_uint32_extension_lite  ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_uint64_extension_lite  ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_sint32_extension_lite  ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_sint64_extension_lite  ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_fixed32_extension_lite ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_fixed64_extension_lite ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_sfixed32_extension_lite));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_sfixed64_extension_lite));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_float_extension_lite   ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_double_extension_lite  ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_bool_extension_lite    ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_string_extension_lite  ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_bytes_extension_lite   ));\n\n  EXPECT_TRUE(message.HasExtension(unittest::optionalgroup_extension_lite                 ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_nested_message_extension_lite       ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_foreign_message_extension_lite      ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_import_message_extension_lite       ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_public_import_message_extension_lite));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_lazy_message_extension_lite         ));\n\n  EXPECT_TRUE(message.GetExtension(unittest::optionalgroup_extension_lite                 ).has_a());\n  EXPECT_TRUE(message.GetExtension(unittest::optional_nested_message_extension_lite       ).has_bb());\n  EXPECT_TRUE(message.GetExtension(unittest::optional_foreign_message_extension_lite      ).has_c());\n  EXPECT_TRUE(message.GetExtension(unittest::optional_import_message_extension_lite       ).has_d());\n  EXPECT_TRUE(message.GetExtension(unittest::optional_public_import_message_extension_lite).has_e());\n  EXPECT_TRUE(message.GetExtension(unittest::optional_lazy_message_extension_lite         ).has_bb());\n\n  EXPECT_TRUE(message.HasExtension(unittest::optional_nested_enum_extension_lite ));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_foreign_enum_extension_lite));\n  EXPECT_TRUE(message.HasExtension(unittest::optional_import_enum_extension_lite ));\n\n\n  EXPECT_EQ(101  , message.GetExtension(unittest::optional_int32_extension_lite   ));\n  EXPECT_EQ(102  , message.GetExtension(unittest::optional_int64_extension_lite   ));\n  EXPECT_EQ(103  , message.GetExtension(unittest::optional_uint32_extension_lite  ));\n  EXPECT_EQ(104  , message.GetExtension(unittest::optional_uint64_extension_lite  ));\n  EXPECT_EQ(105  , message.GetExtension(unittest::optional_sint32_extension_lite  ));\n  EXPECT_EQ(106  , message.GetExtension(unittest::optional_sint64_extension_lite  ));\n  EXPECT_EQ(107  , message.GetExtension(unittest::optional_fixed32_extension_lite ));\n  EXPECT_EQ(108  , message.GetExtension(unittest::optional_fixed64_extension_lite ));\n  EXPECT_EQ(109  , message.GetExtension(unittest::optional_sfixed32_extension_lite));\n  EXPECT_EQ(110  , message.GetExtension(unittest::optional_sfixed64_extension_lite));\n  EXPECT_EQ(111  , message.GetExtension(unittest::optional_float_extension_lite   ));\n  EXPECT_EQ(112  , message.GetExtension(unittest::optional_double_extension_lite  ));\n  EXPECT_EQ(true , message.GetExtension(unittest::optional_bool_extension_lite    ));\n  EXPECT_EQ(\"115\", message.GetExtension(unittest::optional_string_extension_lite  ));\n  EXPECT_EQ(\"116\", message.GetExtension(unittest::optional_bytes_extension_lite   ));\n\n  EXPECT_EQ(117, message.GetExtension(unittest::optionalgroup_extension_lite                 ).a());\n  EXPECT_EQ(118, message.GetExtension(unittest::optional_nested_message_extension_lite       ).bb());\n  EXPECT_EQ(119, message.GetExtension(unittest::optional_foreign_message_extension_lite      ).c());\n  EXPECT_EQ(120, message.GetExtension(unittest::optional_import_message_extension_lite       ).d());\n  EXPECT_EQ(126, message.GetExtension(unittest::optional_public_import_message_extension_lite).e());\n  EXPECT_EQ(127, message.GetExtension(unittest::optional_lazy_message_extension_lite         ).bb());\n\n  EXPECT_EQ(unittest::TestAllTypesLite::BAZ , message.GetExtension(unittest::optional_nested_enum_extension_lite ));\n  EXPECT_EQ(unittest::FOREIGN_LITE_BAZ      , message.GetExtension(unittest::optional_foreign_enum_extension_lite));\n  EXPECT_EQ(unittest_import::IMPORT_LITE_BAZ, message.GetExtension(unittest::optional_import_enum_extension_lite ));\n\n\n  // -----------------------------------------------------------------\n\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_int32_extension_lite   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_int64_extension_lite   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_uint32_extension_lite  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_uint64_extension_lite  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sint32_extension_lite  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sint64_extension_lite  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_fixed32_extension_lite ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_fixed64_extension_lite ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sfixed32_extension_lite));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sfixed64_extension_lite));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_float_extension_lite   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_double_extension_lite  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_bool_extension_lite    ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_string_extension_lite  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_bytes_extension_lite   ));\n\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeatedgroup_extension_lite           ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_nested_message_extension_lite ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_foreign_message_extension_lite));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_import_message_extension_lite ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_lazy_message_extension_lite   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_nested_enum_extension_lite    ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_foreign_enum_extension_lite   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_import_enum_extension_lite    ));\n\n\n  EXPECT_EQ(201  , message.GetExtension(unittest::repeated_int32_extension_lite   , 0));\n  EXPECT_EQ(202  , message.GetExtension(unittest::repeated_int64_extension_lite   , 0));\n  EXPECT_EQ(203  , message.GetExtension(unittest::repeated_uint32_extension_lite  , 0));\n  EXPECT_EQ(204  , message.GetExtension(unittest::repeated_uint64_extension_lite  , 0));\n  EXPECT_EQ(205  , message.GetExtension(unittest::repeated_sint32_extension_lite  , 0));\n  EXPECT_EQ(206  , message.GetExtension(unittest::repeated_sint64_extension_lite  , 0));\n  EXPECT_EQ(207  , message.GetExtension(unittest::repeated_fixed32_extension_lite , 0));\n  EXPECT_EQ(208  , message.GetExtension(unittest::repeated_fixed64_extension_lite , 0));\n  EXPECT_EQ(209  , message.GetExtension(unittest::repeated_sfixed32_extension_lite, 0));\n  EXPECT_EQ(210  , message.GetExtension(unittest::repeated_sfixed64_extension_lite, 0));\n  EXPECT_EQ(211  , message.GetExtension(unittest::repeated_float_extension_lite   , 0));\n  EXPECT_EQ(212  , message.GetExtension(unittest::repeated_double_extension_lite  , 0));\n  EXPECT_EQ(true , message.GetExtension(unittest::repeated_bool_extension_lite    , 0));\n  EXPECT_EQ(\"215\", message.GetExtension(unittest::repeated_string_extension_lite  , 0));\n  EXPECT_EQ(\"216\", message.GetExtension(unittest::repeated_bytes_extension_lite   , 0));\n\n  EXPECT_EQ(217, message.GetExtension(unittest::repeatedgroup_extension_lite           , 0).a());\n  EXPECT_EQ(218, message.GetExtension(unittest::repeated_nested_message_extension_lite , 0).bb());\n  EXPECT_EQ(219, message.GetExtension(unittest::repeated_foreign_message_extension_lite, 0).c());\n  EXPECT_EQ(220, message.GetExtension(unittest::repeated_import_message_extension_lite , 0).d());\n  EXPECT_EQ(227, message.GetExtension(unittest::repeated_lazy_message_extension_lite   , 0).bb());\n\n  EXPECT_EQ(unittest::TestAllTypesLite::BAR , message.GetExtension(unittest::repeated_nested_enum_extension_lite , 0));\n  EXPECT_EQ(unittest::FOREIGN_LITE_BAR      , message.GetExtension(unittest::repeated_foreign_enum_extension_lite, 0));\n  EXPECT_EQ(unittest_import::IMPORT_LITE_BAR, message.GetExtension(unittest::repeated_import_enum_extension_lite , 0));\n\n\n  EXPECT_EQ(301  , message.GetExtension(unittest::repeated_int32_extension_lite   , 1));\n  EXPECT_EQ(302  , message.GetExtension(unittest::repeated_int64_extension_lite   , 1));\n  EXPECT_EQ(303  , message.GetExtension(unittest::repeated_uint32_extension_lite  , 1));\n  EXPECT_EQ(304  , message.GetExtension(unittest::repeated_uint64_extension_lite  , 1));\n  EXPECT_EQ(305  , message.GetExtension(unittest::repeated_sint32_extension_lite  , 1));\n  EXPECT_EQ(306  , message.GetExtension(unittest::repeated_sint64_extension_lite  , 1));\n  EXPECT_EQ(307  , message.GetExtension(unittest::repeated_fixed32_extension_lite , 1));\n  EXPECT_EQ(308  , message.GetExtension(unittest::repeated_fixed64_extension_lite , 1));\n  EXPECT_EQ(309  , message.GetExtension(unittest::repeated_sfixed32_extension_lite, 1));\n  EXPECT_EQ(310  , message.GetExtension(unittest::repeated_sfixed64_extension_lite, 1));\n  EXPECT_EQ(311  , message.GetExtension(unittest::repeated_float_extension_lite   , 1));\n  EXPECT_EQ(312  , message.GetExtension(unittest::repeated_double_extension_lite  , 1));\n  EXPECT_EQ(false, message.GetExtension(unittest::repeated_bool_extension_lite    , 1));\n  EXPECT_EQ(\"315\", message.GetExtension(unittest::repeated_string_extension_lite  , 1));\n  EXPECT_EQ(\"316\", message.GetExtension(unittest::repeated_bytes_extension_lite   , 1));\n\n  EXPECT_EQ(317, message.GetExtension(unittest::repeatedgroup_extension_lite           , 1).a());\n  EXPECT_EQ(318, message.GetExtension(unittest::repeated_nested_message_extension_lite , 1).bb());\n  EXPECT_EQ(319, message.GetExtension(unittest::repeated_foreign_message_extension_lite, 1).c());\n  EXPECT_EQ(320, message.GetExtension(unittest::repeated_import_message_extension_lite , 1).d());\n  EXPECT_EQ(327, message.GetExtension(unittest::repeated_lazy_message_extension_lite   , 1).bb());\n\n  EXPECT_EQ(unittest::TestAllTypesLite::BAZ , message.GetExtension(unittest::repeated_nested_enum_extension_lite , 1));\n  EXPECT_EQ(unittest::FOREIGN_LITE_BAZ      , message.GetExtension(unittest::repeated_foreign_enum_extension_lite, 1));\n  EXPECT_EQ(unittest_import::IMPORT_LITE_BAZ, message.GetExtension(unittest::repeated_import_enum_extension_lite , 1));\n\n\n  // -----------------------------------------------------------------\n\n  EXPECT_TRUE(message.HasExtension(unittest::default_int32_extension_lite   ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_int64_extension_lite   ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_uint32_extension_lite  ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_uint64_extension_lite  ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_sint32_extension_lite  ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_sint64_extension_lite  ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_fixed32_extension_lite ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_fixed64_extension_lite ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_sfixed32_extension_lite));\n  EXPECT_TRUE(message.HasExtension(unittest::default_sfixed64_extension_lite));\n  EXPECT_TRUE(message.HasExtension(unittest::default_float_extension_lite   ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_double_extension_lite  ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_bool_extension_lite    ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_string_extension_lite  ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_bytes_extension_lite   ));\n\n  EXPECT_TRUE(message.HasExtension(unittest::default_nested_enum_extension_lite ));\n  EXPECT_TRUE(message.HasExtension(unittest::default_foreign_enum_extension_lite));\n  EXPECT_TRUE(message.HasExtension(unittest::default_import_enum_extension_lite ));\n\n\n  EXPECT_EQ(401  , message.GetExtension(unittest::default_int32_extension_lite   ));\n  EXPECT_EQ(402  , message.GetExtension(unittest::default_int64_extension_lite   ));\n  EXPECT_EQ(403  , message.GetExtension(unittest::default_uint32_extension_lite  ));\n  EXPECT_EQ(404  , message.GetExtension(unittest::default_uint64_extension_lite  ));\n  EXPECT_EQ(405  , message.GetExtension(unittest::default_sint32_extension_lite  ));\n  EXPECT_EQ(406  , message.GetExtension(unittest::default_sint64_extension_lite  ));\n  EXPECT_EQ(407  , message.GetExtension(unittest::default_fixed32_extension_lite ));\n  EXPECT_EQ(408  , message.GetExtension(unittest::default_fixed64_extension_lite ));\n  EXPECT_EQ(409  , message.GetExtension(unittest::default_sfixed32_extension_lite));\n  EXPECT_EQ(410  , message.GetExtension(unittest::default_sfixed64_extension_lite));\n  EXPECT_EQ(411  , message.GetExtension(unittest::default_float_extension_lite   ));\n  EXPECT_EQ(412  , message.GetExtension(unittest::default_double_extension_lite  ));\n  EXPECT_EQ(false, message.GetExtension(unittest::default_bool_extension_lite    ));\n  EXPECT_EQ(\"415\", message.GetExtension(unittest::default_string_extension_lite  ));\n  EXPECT_EQ(\"416\", message.GetExtension(unittest::default_bytes_extension_lite   ));\n\n  EXPECT_EQ(unittest::TestAllTypesLite::FOO , message.GetExtension(unittest::default_nested_enum_extension_lite ));\n  EXPECT_EQ(unittest::FOREIGN_LITE_FOO      , message.GetExtension(unittest::default_foreign_enum_extension_lite));\n  EXPECT_EQ(unittest_import::IMPORT_LITE_FOO, message.GetExtension(unittest::default_import_enum_extension_lite ));\n\n\n  EXPECT_TRUE(message.HasExtension(unittest::oneof_uint32_extension_lite));\n  EXPECT_TRUE(message.GetExtension(unittest::oneof_nested_message_extension_lite).has_bb());\n  EXPECT_TRUE(message.HasExtension(unittest::oneof_string_extension_lite));\n  EXPECT_TRUE(message.HasExtension(unittest::oneof_bytes_extension_lite));\n\n  EXPECT_EQ(601, message.GetExtension(unittest::oneof_uint32_extension_lite));\n  EXPECT_EQ(602, message.GetExtension(unittest::oneof_nested_message_extension_lite).bb());\n  EXPECT_EQ(\"603\", message.GetExtension(unittest::oneof_string_extension_lite));\n  EXPECT_EQ(\"604\", message.GetExtension(unittest::oneof_bytes_extension_lite));\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtilLite::ExpectExtensionsClear(\n    const unittest::TestAllExtensionsLite& message) {\n  string serialized;\n  ASSERT_TRUE(message.SerializeToString(&serialized));\n  EXPECT_EQ(\"\", serialized);\n  EXPECT_EQ(0, message.ByteSize());\n\n  // has_blah() should initially be false for all optional fields.\n  EXPECT_FALSE(message.HasExtension(unittest::optional_int32_extension_lite   ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_int64_extension_lite   ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_uint32_extension_lite  ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_uint64_extension_lite  ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_sint32_extension_lite  ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_sint64_extension_lite  ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_fixed32_extension_lite ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_fixed64_extension_lite ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_sfixed32_extension_lite));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_sfixed64_extension_lite));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_float_extension_lite   ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_double_extension_lite  ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_bool_extension_lite    ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_string_extension_lite  ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_bytes_extension_lite   ));\n\n  EXPECT_FALSE(message.HasExtension(unittest::optionalgroup_extension_lite                 ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_nested_message_extension_lite       ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_foreign_message_extension_lite      ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_import_message_extension_lite       ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_public_import_message_extension_lite));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_lazy_message_extension_lite         ));\n\n  EXPECT_FALSE(message.HasExtension(unittest::optional_nested_enum_extension_lite ));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_foreign_enum_extension_lite));\n  EXPECT_FALSE(message.HasExtension(unittest::optional_import_enum_extension_lite ));\n\n\n  // Optional fields without defaults are set to zero or something like it.\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_int32_extension_lite   ));\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_int64_extension_lite   ));\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_uint32_extension_lite  ));\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_uint64_extension_lite  ));\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_sint32_extension_lite  ));\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_sint64_extension_lite  ));\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_fixed32_extension_lite ));\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_fixed64_extension_lite ));\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_sfixed32_extension_lite));\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_sfixed64_extension_lite));\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_float_extension_lite   ));\n  EXPECT_EQ(0    , message.GetExtension(unittest::optional_double_extension_lite  ));\n  EXPECT_EQ(false, message.GetExtension(unittest::optional_bool_extension_lite    ));\n  EXPECT_EQ(\"\"   , message.GetExtension(unittest::optional_string_extension_lite  ));\n  EXPECT_EQ(\"\"   , message.GetExtension(unittest::optional_bytes_extension_lite   ));\n\n  // Embedded messages should also be clear.\n  EXPECT_FALSE(message.GetExtension(unittest::optionalgroup_extension_lite                 ).has_a());\n  EXPECT_FALSE(message.GetExtension(unittest::optional_nested_message_extension_lite       ).has_bb());\n  EXPECT_FALSE(message.GetExtension(unittest::optional_foreign_message_extension_lite      ).has_c());\n  EXPECT_FALSE(message.GetExtension(unittest::optional_import_message_extension_lite       ).has_d());\n  EXPECT_FALSE(message.GetExtension(unittest::optional_public_import_message_extension_lite).has_e());\n  EXPECT_FALSE(message.GetExtension(unittest::optional_lazy_message_extension_lite         ).has_bb());\n\n  EXPECT_EQ(0, message.GetExtension(unittest::optionalgroup_extension_lite                 ).a());\n  EXPECT_EQ(0, message.GetExtension(unittest::optional_nested_message_extension_lite       ).bb());\n  EXPECT_EQ(0, message.GetExtension(unittest::optional_foreign_message_extension_lite      ).c());\n  EXPECT_EQ(0, message.GetExtension(unittest::optional_import_message_extension_lite       ).d());\n  EXPECT_EQ(0, message.GetExtension(unittest::optional_public_import_message_extension_lite).e());\n  EXPECT_EQ(0, message.GetExtension(unittest::optional_lazy_message_extension_lite         ).bb());\n\n  // Enums without defaults are set to the first value in the enum.\n  EXPECT_EQ(unittest::TestAllTypesLite::FOO , message.GetExtension(unittest::optional_nested_enum_extension_lite ));\n  EXPECT_EQ(unittest::FOREIGN_LITE_FOO      , message.GetExtension(unittest::optional_foreign_enum_extension_lite));\n  EXPECT_EQ(unittest_import::IMPORT_LITE_FOO, message.GetExtension(unittest::optional_import_enum_extension_lite ));\n\n\n  // Repeated fields are empty.\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_int32_extension_lite   ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_int64_extension_lite   ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_uint32_extension_lite  ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_uint64_extension_lite  ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_sint32_extension_lite  ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_sint64_extension_lite  ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_fixed32_extension_lite ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_fixed64_extension_lite ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_sfixed32_extension_lite));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_sfixed64_extension_lite));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_float_extension_lite   ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_double_extension_lite  ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_bool_extension_lite    ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_string_extension_lite  ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_bytes_extension_lite   ));\n\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeatedgroup_extension_lite           ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_nested_message_extension_lite ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_foreign_message_extension_lite));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_import_message_extension_lite ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_lazy_message_extension_lite   ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_nested_enum_extension_lite    ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_foreign_enum_extension_lite   ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::repeated_import_enum_extension_lite    ));\n\n\n  // has_blah() should also be false for all default fields.\n  EXPECT_FALSE(message.HasExtension(unittest::default_int32_extension_lite   ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_int64_extension_lite   ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_uint32_extension_lite  ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_uint64_extension_lite  ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_sint32_extension_lite  ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_sint64_extension_lite  ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_fixed32_extension_lite ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_fixed64_extension_lite ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_sfixed32_extension_lite));\n  EXPECT_FALSE(message.HasExtension(unittest::default_sfixed64_extension_lite));\n  EXPECT_FALSE(message.HasExtension(unittest::default_float_extension_lite   ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_double_extension_lite  ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_bool_extension_lite    ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_string_extension_lite  ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_bytes_extension_lite   ));\n\n  EXPECT_FALSE(message.HasExtension(unittest::default_nested_enum_extension_lite ));\n  EXPECT_FALSE(message.HasExtension(unittest::default_foreign_enum_extension_lite));\n  EXPECT_FALSE(message.HasExtension(unittest::default_import_enum_extension_lite ));\n\n\n  // Fields with defaults have their default values (duh).\n  EXPECT_EQ( 41    , message.GetExtension(unittest::default_int32_extension_lite   ));\n  EXPECT_EQ( 42    , message.GetExtension(unittest::default_int64_extension_lite   ));\n  EXPECT_EQ( 43    , message.GetExtension(unittest::default_uint32_extension_lite  ));\n  EXPECT_EQ( 44    , message.GetExtension(unittest::default_uint64_extension_lite  ));\n  EXPECT_EQ(-45    , message.GetExtension(unittest::default_sint32_extension_lite  ));\n  EXPECT_EQ( 46    , message.GetExtension(unittest::default_sint64_extension_lite  ));\n  EXPECT_EQ( 47    , message.GetExtension(unittest::default_fixed32_extension_lite ));\n  EXPECT_EQ( 48    , message.GetExtension(unittest::default_fixed64_extension_lite ));\n  EXPECT_EQ( 49    , message.GetExtension(unittest::default_sfixed32_extension_lite));\n  EXPECT_EQ(-50    , message.GetExtension(unittest::default_sfixed64_extension_lite));\n  EXPECT_EQ( 51.5  , message.GetExtension(unittest::default_float_extension_lite   ));\n  EXPECT_EQ( 52e3  , message.GetExtension(unittest::default_double_extension_lite  ));\n  EXPECT_EQ(true   , message.GetExtension(unittest::default_bool_extension_lite    ));\n  EXPECT_EQ(\"hello\", message.GetExtension(unittest::default_string_extension_lite  ));\n  EXPECT_EQ(\"world\", message.GetExtension(unittest::default_bytes_extension_lite   ));\n\n  EXPECT_EQ(unittest::TestAllTypesLite::BAR , message.GetExtension(unittest::default_nested_enum_extension_lite ));\n  EXPECT_EQ(unittest::FOREIGN_LITE_BAR      , message.GetExtension(unittest::default_foreign_enum_extension_lite));\n  EXPECT_EQ(unittest_import::IMPORT_LITE_BAR, message.GetExtension(unittest::default_import_enum_extension_lite ));\n\n\n  EXPECT_FALSE(message.HasExtension(unittest::oneof_uint32_extension_lite));\n  EXPECT_FALSE(message.GetExtension(unittest::oneof_nested_message_extension_lite).has_bb());\n  EXPECT_FALSE(message.HasExtension(unittest::oneof_string_extension_lite));\n  EXPECT_FALSE(message.HasExtension(unittest::oneof_bytes_extension_lite));\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtilLite::ExpectRepeatedExtensionsModified(\n    const unittest::TestAllExtensionsLite& message) {\n  // ModifyRepeatedFields only sets the second repeated element of each\n  // field.  In addition to verifying this, we also verify that the first\n  // element and size were *not* modified.\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_int32_extension_lite   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_int64_extension_lite   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_uint32_extension_lite  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_uint64_extension_lite  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sint32_extension_lite  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sint64_extension_lite  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_fixed32_extension_lite ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_fixed64_extension_lite ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sfixed32_extension_lite));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_sfixed64_extension_lite));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_float_extension_lite   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_double_extension_lite  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_bool_extension_lite    ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_string_extension_lite  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_bytes_extension_lite   ));\n\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeatedgroup_extension_lite           ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_nested_message_extension_lite ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_foreign_message_extension_lite));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_import_message_extension_lite ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_lazy_message_extension_lite   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_nested_enum_extension_lite    ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_foreign_enum_extension_lite   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::repeated_import_enum_extension_lite    ));\n\n\n  EXPECT_EQ(201  , message.GetExtension(unittest::repeated_int32_extension_lite   , 0));\n  EXPECT_EQ(202  , message.GetExtension(unittest::repeated_int64_extension_lite   , 0));\n  EXPECT_EQ(203  , message.GetExtension(unittest::repeated_uint32_extension_lite  , 0));\n  EXPECT_EQ(204  , message.GetExtension(unittest::repeated_uint64_extension_lite  , 0));\n  EXPECT_EQ(205  , message.GetExtension(unittest::repeated_sint32_extension_lite  , 0));\n  EXPECT_EQ(206  , message.GetExtension(unittest::repeated_sint64_extension_lite  , 0));\n  EXPECT_EQ(207  , message.GetExtension(unittest::repeated_fixed32_extension_lite , 0));\n  EXPECT_EQ(208  , message.GetExtension(unittest::repeated_fixed64_extension_lite , 0));\n  EXPECT_EQ(209  , message.GetExtension(unittest::repeated_sfixed32_extension_lite, 0));\n  EXPECT_EQ(210  , message.GetExtension(unittest::repeated_sfixed64_extension_lite, 0));\n  EXPECT_EQ(211  , message.GetExtension(unittest::repeated_float_extension_lite   , 0));\n  EXPECT_EQ(212  , message.GetExtension(unittest::repeated_double_extension_lite  , 0));\n  EXPECT_EQ(true , message.GetExtension(unittest::repeated_bool_extension_lite    , 0));\n  EXPECT_EQ(\"215\", message.GetExtension(unittest::repeated_string_extension_lite  , 0));\n  EXPECT_EQ(\"216\", message.GetExtension(unittest::repeated_bytes_extension_lite   , 0));\n\n  EXPECT_EQ(217, message.GetExtension(unittest::repeatedgroup_extension_lite           , 0).a());\n  EXPECT_EQ(218, message.GetExtension(unittest::repeated_nested_message_extension_lite , 0).bb());\n  EXPECT_EQ(219, message.GetExtension(unittest::repeated_foreign_message_extension_lite, 0).c());\n  EXPECT_EQ(220, message.GetExtension(unittest::repeated_import_message_extension_lite , 0).d());\n  EXPECT_EQ(227, message.GetExtension(unittest::repeated_lazy_message_extension_lite   , 0).bb());\n\n  EXPECT_EQ(unittest::TestAllTypesLite::BAR , message.GetExtension(unittest::repeated_nested_enum_extension_lite , 0));\n  EXPECT_EQ(unittest::FOREIGN_LITE_BAR      , message.GetExtension(unittest::repeated_foreign_enum_extension_lite, 0));\n  EXPECT_EQ(unittest_import::IMPORT_LITE_BAR, message.GetExtension(unittest::repeated_import_enum_extension_lite , 0));\n\n\n  // Actually verify the second (modified) elements now.\n  EXPECT_EQ(501  , message.GetExtension(unittest::repeated_int32_extension_lite   , 1));\n  EXPECT_EQ(502  , message.GetExtension(unittest::repeated_int64_extension_lite   , 1));\n  EXPECT_EQ(503  , message.GetExtension(unittest::repeated_uint32_extension_lite  , 1));\n  EXPECT_EQ(504  , message.GetExtension(unittest::repeated_uint64_extension_lite  , 1));\n  EXPECT_EQ(505  , message.GetExtension(unittest::repeated_sint32_extension_lite  , 1));\n  EXPECT_EQ(506  , message.GetExtension(unittest::repeated_sint64_extension_lite  , 1));\n  EXPECT_EQ(507  , message.GetExtension(unittest::repeated_fixed32_extension_lite , 1));\n  EXPECT_EQ(508  , message.GetExtension(unittest::repeated_fixed64_extension_lite , 1));\n  EXPECT_EQ(509  , message.GetExtension(unittest::repeated_sfixed32_extension_lite, 1));\n  EXPECT_EQ(510  , message.GetExtension(unittest::repeated_sfixed64_extension_lite, 1));\n  EXPECT_EQ(511  , message.GetExtension(unittest::repeated_float_extension_lite   , 1));\n  EXPECT_EQ(512  , message.GetExtension(unittest::repeated_double_extension_lite  , 1));\n  EXPECT_EQ(true , message.GetExtension(unittest::repeated_bool_extension_lite    , 1));\n  EXPECT_EQ(\"515\", message.GetExtension(unittest::repeated_string_extension_lite  , 1));\n  EXPECT_EQ(\"516\", message.GetExtension(unittest::repeated_bytes_extension_lite   , 1));\n\n  EXPECT_EQ(517, message.GetExtension(unittest::repeatedgroup_extension_lite           , 1).a());\n  EXPECT_EQ(518, message.GetExtension(unittest::repeated_nested_message_extension_lite , 1).bb());\n  EXPECT_EQ(519, message.GetExtension(unittest::repeated_foreign_message_extension_lite, 1).c());\n  EXPECT_EQ(520, message.GetExtension(unittest::repeated_import_message_extension_lite , 1).d());\n  EXPECT_EQ(527, message.GetExtension(unittest::repeated_lazy_message_extension_lite   , 1).bb());\n\n  EXPECT_EQ(unittest::TestAllTypesLite::FOO , message.GetExtension(unittest::repeated_nested_enum_extension_lite , 1));\n  EXPECT_EQ(unittest::FOREIGN_LITE_FOO      , message.GetExtension(unittest::repeated_foreign_enum_extension_lite, 1));\n  EXPECT_EQ(unittest_import::IMPORT_LITE_FOO, message.GetExtension(unittest::repeated_import_enum_extension_lite , 1));\n\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtilLite::SetPackedExtensions(\n    unittest::TestPackedExtensionsLite* message) {\n  message->AddExtension(unittest::packed_int32_extension_lite   , 601);\n  message->AddExtension(unittest::packed_int64_extension_lite   , 602);\n  message->AddExtension(unittest::packed_uint32_extension_lite  , 603);\n  message->AddExtension(unittest::packed_uint64_extension_lite  , 604);\n  message->AddExtension(unittest::packed_sint32_extension_lite  , 605);\n  message->AddExtension(unittest::packed_sint64_extension_lite  , 606);\n  message->AddExtension(unittest::packed_fixed32_extension_lite , 607);\n  message->AddExtension(unittest::packed_fixed64_extension_lite , 608);\n  message->AddExtension(unittest::packed_sfixed32_extension_lite, 609);\n  message->AddExtension(unittest::packed_sfixed64_extension_lite, 610);\n  message->AddExtension(unittest::packed_float_extension_lite   , 611);\n  message->AddExtension(unittest::packed_double_extension_lite  , 612);\n  message->AddExtension(unittest::packed_bool_extension_lite    , true);\n  message->AddExtension(unittest::packed_enum_extension_lite, unittest::FOREIGN_LITE_BAR);\n  // add a second one of each field\n  message->AddExtension(unittest::packed_int32_extension_lite   , 701);\n  message->AddExtension(unittest::packed_int64_extension_lite   , 702);\n  message->AddExtension(unittest::packed_uint32_extension_lite  , 703);\n  message->AddExtension(unittest::packed_uint64_extension_lite  , 704);\n  message->AddExtension(unittest::packed_sint32_extension_lite  , 705);\n  message->AddExtension(unittest::packed_sint64_extension_lite  , 706);\n  message->AddExtension(unittest::packed_fixed32_extension_lite , 707);\n  message->AddExtension(unittest::packed_fixed64_extension_lite , 708);\n  message->AddExtension(unittest::packed_sfixed32_extension_lite, 709);\n  message->AddExtension(unittest::packed_sfixed64_extension_lite, 710);\n  message->AddExtension(unittest::packed_float_extension_lite   , 711);\n  message->AddExtension(unittest::packed_double_extension_lite  , 712);\n  message->AddExtension(unittest::packed_bool_extension_lite    , false);\n  message->AddExtension(unittest::packed_enum_extension_lite, unittest::FOREIGN_LITE_BAZ);\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtilLite::ModifyPackedExtensions(\n    unittest::TestPackedExtensionsLite* message) {\n  message->SetExtension(unittest::packed_int32_extension_lite   , 1, 801);\n  message->SetExtension(unittest::packed_int64_extension_lite   , 1, 802);\n  message->SetExtension(unittest::packed_uint32_extension_lite  , 1, 803);\n  message->SetExtension(unittest::packed_uint64_extension_lite  , 1, 804);\n  message->SetExtension(unittest::packed_sint32_extension_lite  , 1, 805);\n  message->SetExtension(unittest::packed_sint64_extension_lite  , 1, 806);\n  message->SetExtension(unittest::packed_fixed32_extension_lite , 1, 807);\n  message->SetExtension(unittest::packed_fixed64_extension_lite , 1, 808);\n  message->SetExtension(unittest::packed_sfixed32_extension_lite, 1, 809);\n  message->SetExtension(unittest::packed_sfixed64_extension_lite, 1, 810);\n  message->SetExtension(unittest::packed_float_extension_lite   , 1, 811);\n  message->SetExtension(unittest::packed_double_extension_lite  , 1, 812);\n  message->SetExtension(unittest::packed_bool_extension_lite    , 1, true);\n  message->SetExtension(unittest::packed_enum_extension_lite    , 1,\n                        unittest::FOREIGN_LITE_FOO);\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtilLite::ExpectPackedExtensionsSet(\n    const unittest::TestPackedExtensionsLite& message) {\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_int32_extension_lite   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_int64_extension_lite   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_uint32_extension_lite  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_uint64_extension_lite  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sint32_extension_lite  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sint64_extension_lite  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_fixed32_extension_lite ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_fixed64_extension_lite ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sfixed32_extension_lite));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sfixed64_extension_lite));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_float_extension_lite   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_double_extension_lite  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_bool_extension_lite    ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_enum_extension_lite    ));\n\n  EXPECT_EQ(601  , message.GetExtension(unittest::packed_int32_extension_lite   , 0));\n  EXPECT_EQ(602  , message.GetExtension(unittest::packed_int64_extension_lite   , 0));\n  EXPECT_EQ(603  , message.GetExtension(unittest::packed_uint32_extension_lite  , 0));\n  EXPECT_EQ(604  , message.GetExtension(unittest::packed_uint64_extension_lite  , 0));\n  EXPECT_EQ(605  , message.GetExtension(unittest::packed_sint32_extension_lite  , 0));\n  EXPECT_EQ(606  , message.GetExtension(unittest::packed_sint64_extension_lite  , 0));\n  EXPECT_EQ(607  , message.GetExtension(unittest::packed_fixed32_extension_lite , 0));\n  EXPECT_EQ(608  , message.GetExtension(unittest::packed_fixed64_extension_lite , 0));\n  EXPECT_EQ(609  , message.GetExtension(unittest::packed_sfixed32_extension_lite, 0));\n  EXPECT_EQ(610  , message.GetExtension(unittest::packed_sfixed64_extension_lite, 0));\n  EXPECT_EQ(611  , message.GetExtension(unittest::packed_float_extension_lite   , 0));\n  EXPECT_EQ(612  , message.GetExtension(unittest::packed_double_extension_lite  , 0));\n  EXPECT_EQ(true , message.GetExtension(unittest::packed_bool_extension_lite    , 0));\n  EXPECT_EQ(unittest::FOREIGN_LITE_BAR,\n            message.GetExtension(unittest::packed_enum_extension_lite, 0));\n  EXPECT_EQ(701  , message.GetExtension(unittest::packed_int32_extension_lite   , 1));\n  EXPECT_EQ(702  , message.GetExtension(unittest::packed_int64_extension_lite   , 1));\n  EXPECT_EQ(703  , message.GetExtension(unittest::packed_uint32_extension_lite  , 1));\n  EXPECT_EQ(704  , message.GetExtension(unittest::packed_uint64_extension_lite  , 1));\n  EXPECT_EQ(705  , message.GetExtension(unittest::packed_sint32_extension_lite  , 1));\n  EXPECT_EQ(706  , message.GetExtension(unittest::packed_sint64_extension_lite  , 1));\n  EXPECT_EQ(707  , message.GetExtension(unittest::packed_fixed32_extension_lite , 1));\n  EXPECT_EQ(708  , message.GetExtension(unittest::packed_fixed64_extension_lite , 1));\n  EXPECT_EQ(709  , message.GetExtension(unittest::packed_sfixed32_extension_lite, 1));\n  EXPECT_EQ(710  , message.GetExtension(unittest::packed_sfixed64_extension_lite, 1));\n  EXPECT_EQ(711  , message.GetExtension(unittest::packed_float_extension_lite   , 1));\n  EXPECT_EQ(712  , message.GetExtension(unittest::packed_double_extension_lite  , 1));\n  EXPECT_EQ(false, message.GetExtension(unittest::packed_bool_extension_lite    , 1));\n  EXPECT_EQ(unittest::FOREIGN_LITE_BAZ,\n            message.GetExtension(unittest::packed_enum_extension_lite, 1));\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtilLite::ExpectPackedExtensionsClear(\n    const unittest::TestPackedExtensionsLite& message) {\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_int32_extension_lite   ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_int64_extension_lite   ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_uint32_extension_lite  ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_uint64_extension_lite  ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_sint32_extension_lite  ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_sint64_extension_lite  ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_fixed32_extension_lite ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_fixed64_extension_lite ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_sfixed32_extension_lite));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_sfixed64_extension_lite));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_float_extension_lite   ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_double_extension_lite  ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_bool_extension_lite    ));\n  EXPECT_EQ(0, message.ExtensionSize(unittest::packed_enum_extension_lite    ));\n}\n\n// -------------------------------------------------------------------\n\nvoid TestUtilLite::ExpectPackedExtensionsModified(\n    const unittest::TestPackedExtensionsLite& message) {\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_int32_extension_lite   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_int64_extension_lite   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_uint32_extension_lite  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_uint64_extension_lite  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sint32_extension_lite  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sint64_extension_lite  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_fixed32_extension_lite ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_fixed64_extension_lite ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sfixed32_extension_lite));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_sfixed64_extension_lite));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_float_extension_lite   ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_double_extension_lite  ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_bool_extension_lite    ));\n  ASSERT_EQ(2, message.ExtensionSize(unittest::packed_enum_extension_lite    ));\n  EXPECT_EQ(601  , message.GetExtension(unittest::packed_int32_extension_lite   , 0));\n  EXPECT_EQ(602  , message.GetExtension(unittest::packed_int64_extension_lite   , 0));\n  EXPECT_EQ(603  , message.GetExtension(unittest::packed_uint32_extension_lite  , 0));\n  EXPECT_EQ(604  , message.GetExtension(unittest::packed_uint64_extension_lite  , 0));\n  EXPECT_EQ(605  , message.GetExtension(unittest::packed_sint32_extension_lite  , 0));\n  EXPECT_EQ(606  , message.GetExtension(unittest::packed_sint64_extension_lite  , 0));\n  EXPECT_EQ(607  , message.GetExtension(unittest::packed_fixed32_extension_lite , 0));\n  EXPECT_EQ(608  , message.GetExtension(unittest::packed_fixed64_extension_lite , 0));\n  EXPECT_EQ(609  , message.GetExtension(unittest::packed_sfixed32_extension_lite, 0));\n  EXPECT_EQ(610  , message.GetExtension(unittest::packed_sfixed64_extension_lite, 0));\n  EXPECT_EQ(611  , message.GetExtension(unittest::packed_float_extension_lite   , 0));\n  EXPECT_EQ(612  , message.GetExtension(unittest::packed_double_extension_lite  , 0));\n  EXPECT_EQ(true , message.GetExtension(unittest::packed_bool_extension_lite    , 0));\n  EXPECT_EQ(unittest::FOREIGN_LITE_BAR,\n            message.GetExtension(unittest::packed_enum_extension_lite, 0));\n\n  // Actually verify the second (modified) elements now.\n  EXPECT_EQ(801  , message.GetExtension(unittest::packed_int32_extension_lite   , 1));\n  EXPECT_EQ(802  , message.GetExtension(unittest::packed_int64_extension_lite   , 1));\n  EXPECT_EQ(803  , message.GetExtension(unittest::packed_uint32_extension_lite  , 1));\n  EXPECT_EQ(804  , message.GetExtension(unittest::packed_uint64_extension_lite  , 1));\n  EXPECT_EQ(805  , message.GetExtension(unittest::packed_sint32_extension_lite  , 1));\n  EXPECT_EQ(806  , message.GetExtension(unittest::packed_sint64_extension_lite  , 1));\n  EXPECT_EQ(807  , message.GetExtension(unittest::packed_fixed32_extension_lite , 1));\n  EXPECT_EQ(808  , message.GetExtension(unittest::packed_fixed64_extension_lite , 1));\n  EXPECT_EQ(809  , message.GetExtension(unittest::packed_sfixed32_extension_lite, 1));\n  EXPECT_EQ(810  , message.GetExtension(unittest::packed_sfixed64_extension_lite, 1));\n  EXPECT_EQ(811  , message.GetExtension(unittest::packed_float_extension_lite   , 1));\n  EXPECT_EQ(812  , message.GetExtension(unittest::packed_double_extension_lite  , 1));\n  EXPECT_EQ(true , message.GetExtension(unittest::packed_bool_extension_lite    , 1));\n  EXPECT_EQ(unittest::FOREIGN_LITE_FOO,\n            message.GetExtension(unittest::packed_enum_extension_lite, 1));\n}\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/test_util_lite.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_TEST_UTIL_LITE_H__\n#define GOOGLE_PROTOBUF_TEST_UTIL_LITE_H__\n\n#include <google/protobuf/unittest_lite.pb.h>\n\nnamespace google {\nnamespace protobuf {\n\nnamespace unittest = protobuf_unittest;\nnamespace unittest_import = protobuf_unittest_import;\n\nclass TestUtilLite {\n public:\n  // Set every field in the message to a unique value.\n  static void SetAllFields(unittest::TestAllTypesLite* message);\n  static void SetAllExtensions(unittest::TestAllExtensionsLite* message);\n  static void SetPackedFields(unittest::TestPackedTypesLite* message);\n  static void SetPackedExtensions(unittest::TestPackedExtensionsLite* message);\n\n  // Use the repeated versions of the set_*() accessors to modify all the\n  // repeated fields of the message (which should already have been\n  // initialized with Set*Fields()).  Set*Fields() itself only tests\n  // the add_*() accessors.\n  static void ModifyRepeatedFields(unittest::TestAllTypesLite* message);\n  static void ModifyRepeatedExtensions(\n      unittest::TestAllExtensionsLite* message);\n  static void ModifyPackedFields(unittest::TestPackedTypesLite* message);\n  static void ModifyPackedExtensions(\n      unittest::TestPackedExtensionsLite* message);\n\n  // Check that all fields have the values that they should have after\n  // Set*Fields() is called.\n  static void ExpectAllFieldsSet(const unittest::TestAllTypesLite& message);\n  static void ExpectAllExtensionsSet(\n      const unittest::TestAllExtensionsLite& message);\n  static void ExpectPackedFieldsSet(\n      const unittest::TestPackedTypesLite& message);\n  static void ExpectPackedExtensionsSet(\n      const unittest::TestPackedExtensionsLite& message);\n\n  // Expect that the message is modified as would be expected from\n  // Modify*Fields().\n  static void ExpectRepeatedFieldsModified(\n      const unittest::TestAllTypesLite& message);\n  static void ExpectRepeatedExtensionsModified(\n      const unittest::TestAllExtensionsLite& message);\n  static void ExpectPackedFieldsModified(\n      const unittest::TestPackedTypesLite& message);\n  static void ExpectPackedExtensionsModified(\n      const unittest::TestPackedExtensionsLite& message);\n\n  // Check that all fields have their default values.\n  static void ExpectClear(const unittest::TestAllTypesLite& message);\n  static void ExpectExtensionsClear(\n      const unittest::TestAllExtensionsLite& message);\n  static void ExpectPackedClear(const unittest::TestPackedTypesLite& message);\n  static void ExpectPackedExtensionsClear(\n      const unittest::TestPackedExtensionsLite& message);\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TestUtilLite);\n};\n\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_TEST_UTIL_LITE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/testdata/bad_utf8_string",
    "content": "r\u0001"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/testdata/map_test_data.txt",
    "content": "map_int32_int32 {\n  key: 0\n  value: 0\n}\nmap_int32_int32 {\n  key: 1\n  value: 1\n}\nmap_int64_int64 {\n  key: 0\n  value: 0\n}\nmap_int64_int64 {\n  key: 1\n  value: 1\n}\nmap_uint32_uint32 {\n  key: 0\n  value: 0\n}\nmap_uint32_uint32 {\n  key: 1\n  value: 1\n}\nmap_uint64_uint64 {\n  key: 0\n  value: 0\n}\nmap_uint64_uint64 {\n  key: 1\n  value: 1\n}\nmap_sint32_sint32 {\n  key: 0\n  value: 0\n}\nmap_sint32_sint32 {\n  key: 1\n  value: 1\n}\nmap_sint64_sint64 {\n  key: 0\n  value: 0\n}\nmap_sint64_sint64 {\n  key: 1\n  value: 1\n}\nmap_fixed32_fixed32 {\n  key: 0\n  value: 0\n}\nmap_fixed32_fixed32 {\n  key: 1\n  value: 1\n}\nmap_fixed64_fixed64 {\n  key: 0\n  value: 0\n}\nmap_fixed64_fixed64 {\n  key: 1\n  value: 1\n}\nmap_sfixed32_sfixed32 {\n  key: 0\n  value: 0\n}\nmap_sfixed32_sfixed32 {\n  key: 1\n  value: 1\n}\nmap_sfixed64_sfixed64 {\n  key: 0\n  value: 0\n}\nmap_sfixed64_sfixed64 {\n  key: 1\n  value: 1\n}\nmap_int32_float {\n  key: 0\n  value: 0\n}\nmap_int32_float {\n  key: 1\n  value: 1\n}\nmap_int32_double {\n  key: 0\n  value: 0\n}\nmap_int32_double {\n  key: 1\n  value: 1\n}\nmap_bool_bool {\n  key: false\n  value: false\n}\nmap_bool_bool {\n  key: true\n  value: true\n}\nmap_string_string {\n  key: \"0\"\n  value: \"0\"\n}\nmap_string_string {\n  key: \"1\"\n  value: \"1\"\n}\nmap_int32_bytes {\n  key: 0\n  value: \"0\"\n}\nmap_int32_bytes {\n  key: 1\n  value: \"1\"\n}\nmap_int32_enum {\n  key: 0\n  value: MAP_ENUM_BAR\n}\nmap_int32_enum {\n  key: 1\n  value: MAP_ENUM_BAZ\n}\nmap_int32_foreign_message {\n  key: 0\n  value {\n    c: 0\n  }\n}\nmap_int32_foreign_message {\n  key: 1\n  value {\n    c: 1\n  }\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/testdata/text_format_unittest_data.txt",
    "content": "optional_int32: 101\noptional_int64: 102\noptional_uint32: 103\noptional_uint64: 104\noptional_sint32: 105\noptional_sint64: 106\noptional_fixed32: 107\noptional_fixed64: 108\noptional_sfixed32: 109\noptional_sfixed64: 110\noptional_float: 111\noptional_double: 112\noptional_bool: true\noptional_string: \"115\"\noptional_bytes: \"116\"\nOptionalGroup {\n  a: 117\n}\noptional_nested_message {\n  bb: 118\n}\noptional_foreign_message {\n  c: 119\n}\noptional_import_message {\n  d: 120\n}\noptional_nested_enum: BAZ\noptional_foreign_enum: FOREIGN_BAZ\noptional_import_enum: IMPORT_BAZ\noptional_string_piece: \"124\"\noptional_cord: \"125\"\noptional_public_import_message {\n  e: 126\n}\noptional_lazy_message {\n  bb: 127\n}\nrepeated_int32: 201\nrepeated_int32: 301\nrepeated_int64: 202\nrepeated_int64: 302\nrepeated_uint32: 203\nrepeated_uint32: 303\nrepeated_uint64: 204\nrepeated_uint64: 304\nrepeated_sint32: 205\nrepeated_sint32: 305\nrepeated_sint64: 206\nrepeated_sint64: 306\nrepeated_fixed32: 207\nrepeated_fixed32: 307\nrepeated_fixed64: 208\nrepeated_fixed64: 308\nrepeated_sfixed32: 209\nrepeated_sfixed32: 309\nrepeated_sfixed64: 210\nrepeated_sfixed64: 310\nrepeated_float: 211\nrepeated_float: 311\nrepeated_double: 212\nrepeated_double: 312\nrepeated_bool: true\nrepeated_bool: false\nrepeated_string: \"215\"\nrepeated_string: \"315\"\nrepeated_bytes: \"216\"\nrepeated_bytes: \"316\"\nRepeatedGroup {\n  a: 217\n}\nRepeatedGroup {\n  a: 317\n}\nrepeated_nested_message {\n  bb: 218\n}\nrepeated_nested_message {\n  bb: 318\n}\nrepeated_foreign_message {\n  c: 219\n}\nrepeated_foreign_message {\n  c: 319\n}\nrepeated_import_message {\n  d: 220\n}\nrepeated_import_message {\n  d: 320\n}\nrepeated_nested_enum: BAR\nrepeated_nested_enum: BAZ\nrepeated_foreign_enum: FOREIGN_BAR\nrepeated_foreign_enum: FOREIGN_BAZ\nrepeated_import_enum: IMPORT_BAR\nrepeated_import_enum: IMPORT_BAZ\nrepeated_string_piece: \"224\"\nrepeated_string_piece: \"324\"\nrepeated_cord: \"225\"\nrepeated_cord: \"325\"\nrepeated_lazy_message {\n  bb: 227\n}\nrepeated_lazy_message {\n  bb: 327\n}\ndefault_int32: 401\ndefault_int64: 402\ndefault_uint32: 403\ndefault_uint64: 404\ndefault_sint32: 405\ndefault_sint64: 406\ndefault_fixed32: 407\ndefault_fixed64: 408\ndefault_sfixed32: 409\ndefault_sfixed64: 410\ndefault_float: 411\ndefault_double: 412\ndefault_bool: false\ndefault_string: \"415\"\ndefault_bytes: \"416\"\ndefault_nested_enum: FOO\ndefault_foreign_enum: FOREIGN_FOO\ndefault_import_enum: IMPORT_FOO\ndefault_string_piece: \"424\"\ndefault_cord: \"425\"\noneof_uint32: 601\noneof_nested_message {\n  bb: 602\n}\noneof_string: \"603\"\noneof_bytes: \"604\"\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/testdata/text_format_unittest_data_oneof_implemented.txt",
    "content": "optional_int32: 101\noptional_int64: 102\noptional_uint32: 103\noptional_uint64: 104\noptional_sint32: 105\noptional_sint64: 106\noptional_fixed32: 107\noptional_fixed64: 108\noptional_sfixed32: 109\noptional_sfixed64: 110\noptional_float: 111\noptional_double: 112\noptional_bool: true\noptional_string: \"115\"\noptional_bytes: \"116\"\nOptionalGroup {\n  a: 117\n}\noptional_nested_message {\n  bb: 118\n}\noptional_foreign_message {\n  c: 119\n}\noptional_import_message {\n  d: 120\n}\noptional_nested_enum: BAZ\noptional_foreign_enum: FOREIGN_BAZ\noptional_import_enum: IMPORT_BAZ\noptional_string_piece: \"124\"\noptional_cord: \"125\"\noptional_public_import_message {\n  e: 126\n}\noptional_lazy_message {\n  bb: 127\n}\nrepeated_int32: 201\nrepeated_int32: 301\nrepeated_int64: 202\nrepeated_int64: 302\nrepeated_uint32: 203\nrepeated_uint32: 303\nrepeated_uint64: 204\nrepeated_uint64: 304\nrepeated_sint32: 205\nrepeated_sint32: 305\nrepeated_sint64: 206\nrepeated_sint64: 306\nrepeated_fixed32: 207\nrepeated_fixed32: 307\nrepeated_fixed64: 208\nrepeated_fixed64: 308\nrepeated_sfixed32: 209\nrepeated_sfixed32: 309\nrepeated_sfixed64: 210\nrepeated_sfixed64: 310\nrepeated_float: 211\nrepeated_float: 311\nrepeated_double: 212\nrepeated_double: 312\nrepeated_bool: true\nrepeated_bool: false\nrepeated_string: \"215\"\nrepeated_string: \"315\"\nrepeated_bytes: \"216\"\nrepeated_bytes: \"316\"\nRepeatedGroup {\n  a: 217\n}\nRepeatedGroup {\n  a: 317\n}\nrepeated_nested_message {\n  bb: 218\n}\nrepeated_nested_message {\n  bb: 318\n}\nrepeated_foreign_message {\n  c: 219\n}\nrepeated_foreign_message {\n  c: 319\n}\nrepeated_import_message {\n  d: 220\n}\nrepeated_import_message {\n  d: 320\n}\nrepeated_nested_enum: BAR\nrepeated_nested_enum: BAZ\nrepeated_foreign_enum: FOREIGN_BAR\nrepeated_foreign_enum: FOREIGN_BAZ\nrepeated_import_enum: IMPORT_BAR\nrepeated_import_enum: IMPORT_BAZ\nrepeated_string_piece: \"224\"\nrepeated_string_piece: \"324\"\nrepeated_cord: \"225\"\nrepeated_cord: \"325\"\nrepeated_lazy_message {\n  bb: 227\n}\nrepeated_lazy_message {\n  bb: 327\n}\ndefault_int32: 401\ndefault_int64: 402\ndefault_uint32: 403\ndefault_uint64: 404\ndefault_sint32: 405\ndefault_sint64: 406\ndefault_fixed32: 407\ndefault_fixed64: 408\ndefault_sfixed32: 409\ndefault_sfixed64: 410\ndefault_float: 411\ndefault_double: 412\ndefault_bool: false\ndefault_string: \"415\"\ndefault_bytes: \"416\"\ndefault_nested_enum: FOO\ndefault_foreign_enum: FOREIGN_FOO\ndefault_import_enum: IMPORT_FOO\ndefault_string_piece: \"424\"\ndefault_cord: \"425\"\noneof_bytes: \"604\"\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/testdata/text_format_unittest_data_pointy.txt",
    "content": "optional_int32: 101\noptional_int64: 102\noptional_uint32: 103\noptional_uint64: 104\noptional_sint32: 105\noptional_sint64: 106\noptional_fixed32: 107\noptional_fixed64: 108\noptional_sfixed32: 109\noptional_sfixed64: 110\noptional_float: 111\noptional_double: 112\noptional_bool: true\noptional_string: \"115\"\noptional_bytes: \"116\"\nOptionalGroup <\n  a: 117\n>\noptional_nested_message <\n  bb: 118\n>\noptional_foreign_message <\n  c: 119\n>\noptional_import_message <\n  d: 120\n>\noptional_nested_enum: BAZ\noptional_foreign_enum: FOREIGN_BAZ\noptional_import_enum: IMPORT_BAZ\noptional_string_piece: \"124\"\noptional_cord: \"125\"\noptional_public_import_message <\n  e: 126\n>\noptional_lazy_message <\n  bb: 127\n>\nrepeated_int32: 201\nrepeated_int32: 301\nrepeated_int64: 202\nrepeated_int64: 302\nrepeated_uint32: 203\nrepeated_uint32: 303\nrepeated_uint64: 204\nrepeated_uint64: 304\nrepeated_sint32: 205\nrepeated_sint32: 305\nrepeated_sint64: 206\nrepeated_sint64: 306\nrepeated_fixed32: 207\nrepeated_fixed32: 307\nrepeated_fixed64: 208\nrepeated_fixed64: 308\nrepeated_sfixed32: 209\nrepeated_sfixed32: 309\nrepeated_sfixed64: 210\nrepeated_sfixed64: 310\nrepeated_float: 211\nrepeated_float: 311\nrepeated_double: 212\nrepeated_double: 312\nrepeated_bool: true\nrepeated_bool: false\nrepeated_string: \"215\"\nrepeated_string: \"315\"\nrepeated_bytes: \"216\"\nrepeated_bytes: \"316\"\nRepeatedGroup <\n  a: 217\n>\nRepeatedGroup <\n  a: 317\n>\nrepeated_nested_message <\n  bb: 218\n>\nrepeated_nested_message <\n  bb: 318\n>\nrepeated_foreign_message <\n  c: 219\n>\nrepeated_foreign_message <\n  c: 319\n>\nrepeated_import_message <\n  d: 220\n>\nrepeated_import_message <\n  d: 320\n>\nrepeated_nested_enum: BAR\nrepeated_nested_enum: BAZ\nrepeated_foreign_enum: FOREIGN_BAR\nrepeated_foreign_enum: FOREIGN_BAZ\nrepeated_import_enum: IMPORT_BAR\nrepeated_import_enum: IMPORT_BAZ\nrepeated_string_piece: \"224\"\nrepeated_string_piece: \"324\"\nrepeated_cord: \"225\"\nrepeated_cord: \"325\"\nrepeated_lazy_message <\n  bb: 227\n>\nrepeated_lazy_message <\n  bb: 327\n>\ndefault_int32: 401\ndefault_int64: 402\ndefault_uint32: 403\ndefault_uint64: 404\ndefault_sint32: 405\ndefault_sint64: 406\ndefault_fixed32: 407\ndefault_fixed64: 408\ndefault_sfixed32: 409\ndefault_sfixed64: 410\ndefault_float: 411\ndefault_double: 412\ndefault_bool: false\ndefault_string: \"415\"\ndefault_bytes: \"416\"\ndefault_nested_enum: FOO\ndefault_foreign_enum: FOREIGN_FOO\ndefault_import_enum: IMPORT_FOO\ndefault_string_piece: \"424\"\ndefault_cord: \"425\"\noneof_uint32: 601\noneof_nested_message <\n  bb: 602\n>\noneof_string: \"603\"\noneof_bytes: \"604\"\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/testdata/text_format_unittest_data_pointy_oneof.txt",
    "content": "optional_int32: 101\noptional_int64: 102\noptional_uint32: 103\noptional_uint64: 104\noptional_sint32: 105\noptional_sint64: 106\noptional_fixed32: 107\noptional_fixed64: 108\noptional_sfixed32: 109\noptional_sfixed64: 110\noptional_float: 111\noptional_double: 112\noptional_bool: true\noptional_string: \"115\"\noptional_bytes: \"116\"\nOptionalGroup <\n  a: 117\n>\noptional_nested_message <\n  bb: 118\n>\noptional_foreign_message <\n  c: 119\n>\noptional_import_message <\n  d: 120\n>\noptional_nested_enum: BAZ\noptional_foreign_enum: FOREIGN_BAZ\noptional_import_enum: IMPORT_BAZ\noptional_string_piece: \"124\"\noptional_cord: \"125\"\noptional_public_import_message <\n  e: 126\n>\noptional_lazy_message <\n  bb: 127\n>\nrepeated_int32: 201\nrepeated_int32: 301\nrepeated_int64: 202\nrepeated_int64: 302\nrepeated_uint32: 203\nrepeated_uint32: 303\nrepeated_uint64: 204\nrepeated_uint64: 304\nrepeated_sint32: 205\nrepeated_sint32: 305\nrepeated_sint64: 206\nrepeated_sint64: 306\nrepeated_fixed32: 207\nrepeated_fixed32: 307\nrepeated_fixed64: 208\nrepeated_fixed64: 308\nrepeated_sfixed32: 209\nrepeated_sfixed32: 309\nrepeated_sfixed64: 210\nrepeated_sfixed64: 310\nrepeated_float: 211\nrepeated_float: 311\nrepeated_double: 212\nrepeated_double: 312\nrepeated_bool: true\nrepeated_bool: false\nrepeated_string: \"215\"\nrepeated_string: \"315\"\nrepeated_bytes: \"216\"\nrepeated_bytes: \"316\"\nRepeatedGroup <\n  a: 217\n>\nRepeatedGroup <\n  a: 317\n>\nrepeated_nested_message <\n  bb: 218\n>\nrepeated_nested_message <\n  bb: 318\n>\nrepeated_foreign_message <\n  c: 219\n>\nrepeated_foreign_message <\n  c: 319\n>\nrepeated_import_message <\n  d: 220\n>\nrepeated_import_message <\n  d: 320\n>\nrepeated_nested_enum: BAR\nrepeated_nested_enum: BAZ\nrepeated_foreign_enum: FOREIGN_BAR\nrepeated_foreign_enum: FOREIGN_BAZ\nrepeated_import_enum: IMPORT_BAR\nrepeated_import_enum: IMPORT_BAZ\nrepeated_string_piece: \"224\"\nrepeated_string_piece: \"324\"\nrepeated_cord: \"225\"\nrepeated_cord: \"325\"\nrepeated_lazy_message <\n  bb: 227\n>\nrepeated_lazy_message <\n  bb: 327\n>\ndefault_int32: 401\ndefault_int64: 402\ndefault_uint32: 403\ndefault_uint64: 404\ndefault_sint32: 405\ndefault_sint64: 406\ndefault_fixed32: 407\ndefault_fixed64: 408\ndefault_sfixed32: 409\ndefault_sfixed64: 410\ndefault_float: 411\ndefault_double: 412\ndefault_bool: false\ndefault_string: \"415\"\ndefault_bytes: \"416\"\ndefault_nested_enum: FOO\ndefault_foreign_enum: FOREIGN_FOO\ndefault_import_enum: IMPORT_FOO\ndefault_string_piece: \"424\"\ndefault_cord: \"425\"\noneof_bytes: \"604\"\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/testdata/text_format_unittest_extensions_data.txt",
    "content": "[protobuf_unittest.optional_int32_extension]: 101\n[protobuf_unittest.optional_int64_extension]: 102\n[protobuf_unittest.optional_uint32_extension]: 103\n[protobuf_unittest.optional_uint64_extension]: 104\n[protobuf_unittest.optional_sint32_extension]: 105\n[protobuf_unittest.optional_sint64_extension]: 106\n[protobuf_unittest.optional_fixed32_extension]: 107\n[protobuf_unittest.optional_fixed64_extension]: 108\n[protobuf_unittest.optional_sfixed32_extension]: 109\n[protobuf_unittest.optional_sfixed64_extension]: 110\n[protobuf_unittest.optional_float_extension]: 111\n[protobuf_unittest.optional_double_extension]: 112\n[protobuf_unittest.optional_bool_extension]: true\n[protobuf_unittest.optional_string_extension]: \"115\"\n[protobuf_unittest.optional_bytes_extension]: \"116\"\n[protobuf_unittest.optionalgroup_extension] {\n  a: 117\n}\n[protobuf_unittest.optional_nested_message_extension] {\n  bb: 118\n}\n[protobuf_unittest.optional_foreign_message_extension] {\n  c: 119\n}\n[protobuf_unittest.optional_import_message_extension] {\n  d: 120\n}\n[protobuf_unittest.optional_nested_enum_extension]: BAZ\n[protobuf_unittest.optional_foreign_enum_extension]: FOREIGN_BAZ\n[protobuf_unittest.optional_import_enum_extension]: IMPORT_BAZ\n[protobuf_unittest.optional_string_piece_extension]: \"124\"\n[protobuf_unittest.optional_cord_extension]: \"125\"\n[protobuf_unittest.optional_public_import_message_extension] {\n  e: 126\n}\n[protobuf_unittest.optional_lazy_message_extension] {\n  bb: 127\n}\n[protobuf_unittest.repeated_int32_extension]: 201\n[protobuf_unittest.repeated_int32_extension]: 301\n[protobuf_unittest.repeated_int64_extension]: 202\n[protobuf_unittest.repeated_int64_extension]: 302\n[protobuf_unittest.repeated_uint32_extension]: 203\n[protobuf_unittest.repeated_uint32_extension]: 303\n[protobuf_unittest.repeated_uint64_extension]: 204\n[protobuf_unittest.repeated_uint64_extension]: 304\n[protobuf_unittest.repeated_sint32_extension]: 205\n[protobuf_unittest.repeated_sint32_extension]: 305\n[protobuf_unittest.repeated_sint64_extension]: 206\n[protobuf_unittest.repeated_sint64_extension]: 306\n[protobuf_unittest.repeated_fixed32_extension]: 207\n[protobuf_unittest.repeated_fixed32_extension]: 307\n[protobuf_unittest.repeated_fixed64_extension]: 208\n[protobuf_unittest.repeated_fixed64_extension]: 308\n[protobuf_unittest.repeated_sfixed32_extension]: 209\n[protobuf_unittest.repeated_sfixed32_extension]: 309\n[protobuf_unittest.repeated_sfixed64_extension]: 210\n[protobuf_unittest.repeated_sfixed64_extension]: 310\n[protobuf_unittest.repeated_float_extension]: 211\n[protobuf_unittest.repeated_float_extension]: 311\n[protobuf_unittest.repeated_double_extension]: 212\n[protobuf_unittest.repeated_double_extension]: 312\n[protobuf_unittest.repeated_bool_extension]: true\n[protobuf_unittest.repeated_bool_extension]: false\n[protobuf_unittest.repeated_string_extension]: \"215\"\n[protobuf_unittest.repeated_string_extension]: \"315\"\n[protobuf_unittest.repeated_bytes_extension]: \"216\"\n[protobuf_unittest.repeated_bytes_extension]: \"316\"\n[protobuf_unittest.repeatedgroup_extension] {\n  a: 217\n}\n[protobuf_unittest.repeatedgroup_extension] {\n  a: 317\n}\n[protobuf_unittest.repeated_nested_message_extension] {\n  bb: 218\n}\n[protobuf_unittest.repeated_nested_message_extension] {\n  bb: 318\n}\n[protobuf_unittest.repeated_foreign_message_extension] {\n  c: 219\n}\n[protobuf_unittest.repeated_foreign_message_extension] {\n  c: 319\n}\n[protobuf_unittest.repeated_import_message_extension] {\n  d: 220\n}\n[protobuf_unittest.repeated_import_message_extension] {\n  d: 320\n}\n[protobuf_unittest.repeated_nested_enum_extension]: BAR\n[protobuf_unittest.repeated_nested_enum_extension]: BAZ\n[protobuf_unittest.repeated_foreign_enum_extension]: FOREIGN_BAR\n[protobuf_unittest.repeated_foreign_enum_extension]: FOREIGN_BAZ\n[protobuf_unittest.repeated_import_enum_extension]: IMPORT_BAR\n[protobuf_unittest.repeated_import_enum_extension]: IMPORT_BAZ\n[protobuf_unittest.repeated_string_piece_extension]: \"224\"\n[protobuf_unittest.repeated_string_piece_extension]: \"324\"\n[protobuf_unittest.repeated_cord_extension]: \"225\"\n[protobuf_unittest.repeated_cord_extension]: \"325\"\n[protobuf_unittest.repeated_lazy_message_extension] {\n  bb: 227\n}\n[protobuf_unittest.repeated_lazy_message_extension] {\n  bb: 327\n}\n[protobuf_unittest.default_int32_extension]: 401\n[protobuf_unittest.default_int64_extension]: 402\n[protobuf_unittest.default_uint32_extension]: 403\n[protobuf_unittest.default_uint64_extension]: 404\n[protobuf_unittest.default_sint32_extension]: 405\n[protobuf_unittest.default_sint64_extension]: 406\n[protobuf_unittest.default_fixed32_extension]: 407\n[protobuf_unittest.default_fixed64_extension]: 408\n[protobuf_unittest.default_sfixed32_extension]: 409\n[protobuf_unittest.default_sfixed64_extension]: 410\n[protobuf_unittest.default_float_extension]: 411\n[protobuf_unittest.default_double_extension]: 412\n[protobuf_unittest.default_bool_extension]: false\n[protobuf_unittest.default_string_extension]: \"415\"\n[protobuf_unittest.default_bytes_extension]: \"416\"\n[protobuf_unittest.default_nested_enum_extension]: FOO\n[protobuf_unittest.default_foreign_enum_extension]: FOREIGN_FOO\n[protobuf_unittest.default_import_enum_extension]: IMPORT_FOO\n[protobuf_unittest.default_string_piece_extension]: \"424\"\n[protobuf_unittest.default_cord_extension]: \"425\"\n[protobuf_unittest.oneof_uint32_extension]: 601\n[protobuf_unittest.oneof_nested_message_extension] {\n  bb: 602\n}\n[protobuf_unittest.oneof_string_extension]: \"603\"\n[protobuf_unittest.oneof_bytes_extension]: \"604\"\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/testdata/text_format_unittest_extensions_data_pointy.txt",
    "content": "[protobuf_unittest.optional_int32_extension]: 101\n[protobuf_unittest.optional_int64_extension]: 102\n[protobuf_unittest.optional_uint32_extension]: 103\n[protobuf_unittest.optional_uint64_extension]: 104\n[protobuf_unittest.optional_sint32_extension]: 105\n[protobuf_unittest.optional_sint64_extension]: 106\n[protobuf_unittest.optional_fixed32_extension]: 107\n[protobuf_unittest.optional_fixed64_extension]: 108\n[protobuf_unittest.optional_sfixed32_extension]: 109\n[protobuf_unittest.optional_sfixed64_extension]: 110\n[protobuf_unittest.optional_float_extension]: 111\n[protobuf_unittest.optional_double_extension]: 112\n[protobuf_unittest.optional_bool_extension]: true\n[protobuf_unittest.optional_string_extension]: \"115\"\n[protobuf_unittest.optional_bytes_extension]: \"116\"\n[protobuf_unittest.optionalgroup_extension] <\n  a: 117\n>\n[protobuf_unittest.optional_nested_message_extension] <\n  bb: 118\n>\n[protobuf_unittest.optional_foreign_message_extension] <\n  c: 119\n>\n[protobuf_unittest.optional_import_message_extension] <\n  d: 120\n>\n[protobuf_unittest.optional_nested_enum_extension]: BAZ\n[protobuf_unittest.optional_foreign_enum_extension]: FOREIGN_BAZ\n[protobuf_unittest.optional_import_enum_extension]: IMPORT_BAZ\n[protobuf_unittest.optional_string_piece_extension]: \"124\"\n[protobuf_unittest.optional_cord_extension]: \"125\"\n[protobuf_unittest.optional_public_import_message_extension] <\n  e: 126\n>\n[protobuf_unittest.optional_lazy_message_extension] <\n  bb: 127\n>\n[protobuf_unittest.repeated_int32_extension]: 201\n[protobuf_unittest.repeated_int32_extension]: 301\n[protobuf_unittest.repeated_int64_extension]: 202\n[protobuf_unittest.repeated_int64_extension]: 302\n[protobuf_unittest.repeated_uint32_extension]: 203\n[protobuf_unittest.repeated_uint32_extension]: 303\n[protobuf_unittest.repeated_uint64_extension]: 204\n[protobuf_unittest.repeated_uint64_extension]: 304\n[protobuf_unittest.repeated_sint32_extension]: 205\n[protobuf_unittest.repeated_sint32_extension]: 305\n[protobuf_unittest.repeated_sint64_extension]: 206\n[protobuf_unittest.repeated_sint64_extension]: 306\n[protobuf_unittest.repeated_fixed32_extension]: 207\n[protobuf_unittest.repeated_fixed32_extension]: 307\n[protobuf_unittest.repeated_fixed64_extension]: 208\n[protobuf_unittest.repeated_fixed64_extension]: 308\n[protobuf_unittest.repeated_sfixed32_extension]: 209\n[protobuf_unittest.repeated_sfixed32_extension]: 309\n[protobuf_unittest.repeated_sfixed64_extension]: 210\n[protobuf_unittest.repeated_sfixed64_extension]: 310\n[protobuf_unittest.repeated_float_extension]: 211\n[protobuf_unittest.repeated_float_extension]: 311\n[protobuf_unittest.repeated_double_extension]: 212\n[protobuf_unittest.repeated_double_extension]: 312\n[protobuf_unittest.repeated_bool_extension]: true\n[protobuf_unittest.repeated_bool_extension]: false\n[protobuf_unittest.repeated_string_extension]: \"215\"\n[protobuf_unittest.repeated_string_extension]: \"315\"\n[protobuf_unittest.repeated_bytes_extension]: \"216\"\n[protobuf_unittest.repeated_bytes_extension]: \"316\"\n[protobuf_unittest.repeatedgroup_extension] <\n  a: 217\n>\n[protobuf_unittest.repeatedgroup_extension] <\n  a: 317\n>\n[protobuf_unittest.repeated_nested_message_extension] <\n  bb: 218\n>\n[protobuf_unittest.repeated_nested_message_extension] <\n  bb: 318\n>\n[protobuf_unittest.repeated_foreign_message_extension] <\n  c: 219\n>\n[protobuf_unittest.repeated_foreign_message_extension] <\n  c: 319\n>\n[protobuf_unittest.repeated_import_message_extension] <\n  d: 220\n>\n[protobuf_unittest.repeated_import_message_extension] <\n  d: 320\n>\n[protobuf_unittest.repeated_nested_enum_extension]: BAR\n[protobuf_unittest.repeated_nested_enum_extension]: BAZ\n[protobuf_unittest.repeated_foreign_enum_extension]: FOREIGN_BAR\n[protobuf_unittest.repeated_foreign_enum_extension]: FOREIGN_BAZ\n[protobuf_unittest.repeated_import_enum_extension]: IMPORT_BAR\n[protobuf_unittest.repeated_import_enum_extension]: IMPORT_BAZ\n[protobuf_unittest.repeated_string_piece_extension]: \"224\"\n[protobuf_unittest.repeated_string_piece_extension]: \"324\"\n[protobuf_unittest.repeated_cord_extension]: \"225\"\n[protobuf_unittest.repeated_cord_extension]: \"325\"\n[protobuf_unittest.repeated_lazy_message_extension] <\n  bb: 227\n>\n[protobuf_unittest.repeated_lazy_message_extension] <\n  bb: 327\n>\n[protobuf_unittest.default_int32_extension]: 401\n[protobuf_unittest.default_int64_extension]: 402\n[protobuf_unittest.default_uint32_extension]: 403\n[protobuf_unittest.default_uint64_extension]: 404\n[protobuf_unittest.default_sint32_extension]: 405\n[protobuf_unittest.default_sint64_extension]: 406\n[protobuf_unittest.default_fixed32_extension]: 407\n[protobuf_unittest.default_fixed64_extension]: 408\n[protobuf_unittest.default_sfixed32_extension]: 409\n[protobuf_unittest.default_sfixed64_extension]: 410\n[protobuf_unittest.default_float_extension]: 411\n[protobuf_unittest.default_double_extension]: 412\n[protobuf_unittest.default_bool_extension]: false\n[protobuf_unittest.default_string_extension]: \"415\"\n[protobuf_unittest.default_bytes_extension]: \"416\"\n[protobuf_unittest.default_nested_enum_extension]: FOO\n[protobuf_unittest.default_foreign_enum_extension]: FOREIGN_FOO\n[protobuf_unittest.default_import_enum_extension]: IMPORT_FOO\n[protobuf_unittest.default_string_piece_extension]: \"424\"\n[protobuf_unittest.default_cord_extension]: \"425\"\n[protobuf_unittest.oneof_uint32_extension]: 601\n[protobuf_unittest.oneof_nested_message_extension] <\n  bb: 602\n>\n[protobuf_unittest.oneof_string_extension]: \"603\"\n[protobuf_unittest.oneof_bytes_extension]: \"604\"\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/testing/file.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n// emulates google3/file/base/file.cc\n\n#include <google/protobuf/testing/file.h>\n#include <stdio.h>\n#include <sys/stat.h>\n#include <sys/types.h>\n#ifdef _MSC_VER\n#define WIN32_LEAN_AND_MEAN  // yeah, right\n#include <windows.h>         // Find*File().  :(\n#include <io.h>\n#include <direct.h>\n#else\n#include <dirent.h>\n#include <unistd.h>\n#endif\n#include <errno.h>\n\nnamespace google {\nnamespace protobuf {\n\n#ifdef _WIN32\n#define mkdir(name, mode) mkdir(name)\n// Windows doesn't have symbolic links.\n#define lstat stat\n#ifndef F_OK\n#define F_OK 00  // not defined by MSVC for whatever reason\n#endif\n#endif\n\nbool File::Exists(const string& name) {\n  return access(name.c_str(), F_OK) == 0;\n}\n\nbool File::ReadFileToString(const string& name, string* output) {\n  char buffer[1024];\n  FILE* file = fopen(name.c_str(), \"rb\");\n  if (file == NULL) return false;\n\n  while (true) {\n    size_t n = fread(buffer, 1, sizeof(buffer), file);\n    if (n <= 0) break;\n    output->append(buffer, n);\n  }\n\n  int error = ferror(file);\n  if (fclose(file) != 0) return false;\n  return error == 0;\n}\n\nvoid File::ReadFileToStringOrDie(const string& name, string* output) {\n  GOOGLE_CHECK(ReadFileToString(name, output)) << \"Could not read: \" << name;\n}\n\nbool File::WriteStringToFile(const string& contents, const string& name) {\n  FILE* file = fopen(name.c_str(), \"wb\");\n  if (file == NULL) {\n    GOOGLE_LOG(ERROR) << \"fopen(\" << name << \", \\\"wb\\\"): \" << strerror(errno);\n    return false;\n  }\n\n  if (fwrite(contents.data(), 1, contents.size(), file) != contents.size()) {\n    GOOGLE_LOG(ERROR) << \"fwrite(\" << name << \"): \" << strerror(errno);\n    return false;\n  }\n\n  if (fclose(file) != 0) {\n    return false;\n  }\n  return true;\n}\n\nvoid File::WriteStringToFileOrDie(const string& contents, const string& name) {\n  FILE* file = fopen(name.c_str(), \"wb\");\n  GOOGLE_CHECK(file != NULL)\n      << \"fopen(\" << name << \", \\\"wb\\\"): \" << strerror(errno);\n  GOOGLE_CHECK_EQ(fwrite(contents.data(), 1, contents.size(), file),\n                  contents.size())\n      << \"fwrite(\" << name << \"): \" << strerror(errno);\n  GOOGLE_CHECK(fclose(file) == 0)\n      << \"fclose(\" << name << \"): \" << strerror(errno);\n}\n\nbool File::CreateDir(const string& name, int mode) {\n  return mkdir(name.c_str(), mode) == 0;\n}\n\nbool File::RecursivelyCreateDir(const string& path, int mode) {\n  if (CreateDir(path, mode)) return true;\n\n  if (Exists(path)) return false;\n\n  // Try creating the parent.\n  string::size_type slashpos = path.find_last_of('/');\n  if (slashpos == string::npos) {\n    // No parent given.\n    return false;\n  }\n\n  return RecursivelyCreateDir(path.substr(0, slashpos), mode) &&\n         CreateDir(path, mode);\n}\n\nvoid File::DeleteRecursively(const string& name,\n                             void* dummy1, void* dummy2) {\n  if (name.empty()) return;\n\n  // We don't care too much about error checking here since this is only used\n  // in tests to delete temporary directories that are under /tmp anyway.\n\n#ifdef _MSC_VER\n  // This interface is so weird.\n  WIN32_FIND_DATA find_data;\n  HANDLE find_handle = FindFirstFile((name + \"/*\").c_str(), &find_data);\n  if (find_handle == INVALID_HANDLE_VALUE) {\n    // Just delete it, whatever it is.\n    DeleteFile(name.c_str());\n    RemoveDirectory(name.c_str());\n    return;\n  }\n\n  do {\n    string entry_name = find_data.cFileName;\n    if (entry_name != \".\" && entry_name != \"..\") {\n      string path = name + \"/\" + entry_name;\n      if (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {\n        DeleteRecursively(path, NULL, NULL);\n        RemoveDirectory(path.c_str());\n      } else {\n        DeleteFile(path.c_str());\n      }\n    }\n  } while(FindNextFile(find_handle, &find_data));\n  FindClose(find_handle);\n\n  RemoveDirectory(name.c_str());\n#else\n  // Use opendir()!  Yay!\n  // lstat = Don't follow symbolic links.\n  struct stat stats;\n  if (lstat(name.c_str(), &stats) != 0) return;\n\n  if (S_ISDIR(stats.st_mode)) {\n    DIR* dir = opendir(name.c_str());\n    if (dir != NULL) {\n      while (true) {\n        struct dirent* entry = readdir(dir);\n        if (entry == NULL) break;\n        string entry_name = entry->d_name;\n        if (entry_name != \".\" && entry_name != \"..\") {\n          DeleteRecursively(name + \"/\" + entry_name, NULL, NULL);\n        }\n      }\n    }\n\n    closedir(dir);\n    rmdir(name.c_str());\n\n  } else if (S_ISREG(stats.st_mode)) {\n    remove(name.c_str());\n  }\n#endif\n}\n\nbool File::ChangeWorkingDirectory(const string& new_working_directory) {\n  return chdir(new_working_directory.c_str()) == 0;\n}\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/testing/file.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n// emulates google3/file/base/file.h\n\n#ifndef GOOGLE_PROTOBUF_TESTING_FILE_H__\n#define GOOGLE_PROTOBUF_TESTING_FILE_H__\n\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\n\nconst int DEFAULT_FILE_MODE = 0777;\n\n// Protocol buffer code only uses a couple static methods of File, and only\n// in tests.\nclass File {\n public:\n  // Check if the file exists.\n  static bool Exists(const string& name);\n\n  // Read an entire file to a string.  Return true if successful, false\n  // otherwise.\n  static bool ReadFileToString(const string& name, string* output);\n\n  // Same as above, but crash on failure.\n  static void ReadFileToStringOrDie(const string& name, string* output);\n\n  // Create a file and write a string to it.\n  static bool WriteStringToFile(const string& contents,\n                                const string& name);\n\n  // Same as above, but crash on failure.\n  static void WriteStringToFileOrDie(const string& contents,\n                                     const string& name);\n\n  // Create a directory.\n  static bool CreateDir(const string& name, int mode);\n\n  // Create a directory and all parent directories if necessary.\n  static bool RecursivelyCreateDir(const string& path, int mode);\n\n  // If \"name\" is a file, we delete it.  If it is a directory, we\n  // call DeleteRecursively() for each file or directory (other than\n  // dot and double-dot) within it, and then delete the directory itself.\n  // The \"dummy\" parameters have a meaning in the original version of this\n  // method but they are not used anywhere in protocol buffers.\n  static void DeleteRecursively(const string& name,\n                                void* dummy1, void* dummy2);\n\n  // Change working directory to given directory.\n  static bool ChangeWorkingDirectory(const string& new_working_directory);\n\n  static bool GetContents(\n      const string& name, string* output, bool /*is_default*/) {\n    return ReadFileToString(name, output);\n  }\n\n  static bool SetContents(\n      const string& name, const string& contents, bool /*is_default*/) {\n    return WriteStringToFile(contents, name);\n  }\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(File);\n};\n\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_TESTING_FILE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/testing/googletest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n// emulates google3/testing/base/public/googletest.cc\n\n#include <google/protobuf/testing/googletest.h>\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <sys/stat.h>\n#include <sys/types.h>\n#include <errno.h>\n#include <stdlib.h>\n#ifdef _MSC_VER\n#include <io.h>\n#include <direct.h>\n#else\n#include <unistd.h>\n#endif\n#include <stdio.h>\n#include <fcntl.h>\n#include <iostream>\n#include <fstream>\n\nnamespace google {\nnamespace protobuf {\n\n#ifdef _WIN32\n#define mkdir(name, mode) mkdir(name)\n#endif\n\n#ifndef O_BINARY\n#ifdef _O_BINARY\n#define O_BINARY _O_BINARY\n#else\n#define O_BINARY 0     // If this isn't defined, the platform doesn't need it.\n#endif\n#endif\n\nstring TestSourceDir() {\n#ifndef GOOGLE_THIRD_PARTY_PROTOBUF\n#ifdef GOOGLE_PROTOBUF_TEST_SOURCE_PATH\n  return GOOGLE_PROTOBUF_TEST_SOURCE_PATH;\n#else\n#ifndef _MSC_VER\n  // automake sets the \"srcdir\" environment variable.\n  char* result = getenv(\"srcdir\");\n  if (result != NULL) {\n    return result;\n  }\n#endif  // _MSC_VER\n\n  // Look for the \"src\" directory.\n  string prefix = \".\";\n\n  while (!File::Exists(prefix + \"/src/google/protobuf\")) {\n    if (!File::Exists(prefix)) {\n      GOOGLE_LOG(FATAL)\n        << \"Could not find protobuf source code.  Please run tests from \"\n           \"somewhere within the protobuf source package.\";\n    }\n    prefix += \"/..\";\n  }\n  return prefix + \"/src\";\n#endif  // GOOGLE_PROTOBUF_TEST_SOURCE_PATH\n#else\n  return \"third_party/protobuf/src\";\n#endif  // GOOGLE_THIRD_PARTY_PROTOBUF\n}\n\nnamespace {\n\nstring GetTemporaryDirectoryName() {\n  // Tests run under Bazel \"should not\" use /tmp. Bazel sets this environment\n  // variable for tests to use instead.\n  char *from_environment = getenv(\"TEST_TMPDIR\");\n  if (from_environment != NULL && from_environment[0] != '\\0') {\n    return string(from_environment) + \"/protobuf_tmpdir\";\n  }\n\n  // tmpnam() is generally not considered safe but we're only using it for\n  // testing.  We cannot use tmpfile() or mkstemp() since we're creating a\n  // directory.\n  char b[L_tmpnam + 1];     // HPUX multithread return 0 if s is 0\n  string result = tmpnam(b);\n#ifdef _WIN32\n  // On Win32, tmpnam() returns a file prefixed with '\\', but which is supposed\n  // to be used in the current working directory.  WTF?\n  if (HasPrefixString(result, \"\\\\\")) {\n    result.erase(0, 1);\n  }\n  // The Win32 API accepts forward slashes as a path delimiter even though\n  // backslashes are standard.  Let's avoid confusion and use only forward\n  // slashes.\n  result = StringReplace(result, \"\\\\\", \"/\", true);\n#endif  // _WIN32\n  return result;\n}\n\n// Creates a temporary directory on demand and deletes it when the process\n// quits.\nclass TempDirDeleter {\n public:\n  TempDirDeleter() {}\n  ~TempDirDeleter() {\n    if (!name_.empty()) {\n      File::DeleteRecursively(name_, NULL, NULL);\n    }\n  }\n\n  string GetTempDir() {\n    if (name_.empty()) {\n      name_ = GetTemporaryDirectoryName();\n      GOOGLE_CHECK(mkdir(name_.c_str(), 0777) == 0) << strerror(errno);\n\n      // Stick a file in the directory that tells people what this is, in case\n      // we abort and don't get a chance to delete it.\n      File::WriteStringToFileOrDie(\"\", name_ + \"/TEMP_DIR_FOR_PROTOBUF_TESTS\");\n    }\n    return name_;\n  }\n\n private:\n  string name_;\n};\n\nTempDirDeleter temp_dir_deleter_;\n\n}  // namespace\n\nstring TestTempDir() {\n  return temp_dir_deleter_.GetTempDir();\n}\n\n// TODO(kenton):  Share duplicated code below.  Too busy/lazy for now.\n\nstatic string stdout_capture_filename_;\nstatic string stderr_capture_filename_;\nstatic int original_stdout_ = -1;\nstatic int original_stderr_ = -1;\n\nvoid CaptureTestStdout() {\n  GOOGLE_CHECK_EQ(original_stdout_, -1) << \"Already capturing.\";\n\n  stdout_capture_filename_ = TestTempDir() + \"/captured_stdout\";\n\n  int fd = open(stdout_capture_filename_.c_str(),\n                O_WRONLY | O_CREAT | O_EXCL | O_BINARY, 0777);\n  GOOGLE_CHECK(fd >= 0) << \"open: \" << strerror(errno);\n\n  original_stdout_ = dup(1);\n  close(1);\n  dup2(fd, 1);\n  close(fd);\n}\n\nvoid CaptureTestStderr() {\n  GOOGLE_CHECK_EQ(original_stderr_, -1) << \"Already capturing.\";\n\n  stderr_capture_filename_ = TestTempDir() + \"/captured_stderr\";\n\n  int fd = open(stderr_capture_filename_.c_str(),\n                O_WRONLY | O_CREAT | O_EXCL | O_BINARY, 0777);\n  GOOGLE_CHECK(fd >= 0) << \"open: \" << strerror(errno);\n\n  original_stderr_ = dup(2);\n  close(2);\n  dup2(fd, 2);\n  close(fd);\n}\n\nstring GetCapturedTestStdout() {\n  GOOGLE_CHECK_NE(original_stdout_, -1) << \"Not capturing.\";\n\n  close(1);\n  dup2(original_stdout_, 1);\n  original_stdout_ = -1;\n\n  string result;\n  File::ReadFileToStringOrDie(stdout_capture_filename_, &result);\n\n  remove(stdout_capture_filename_.c_str());\n\n  return result;\n}\n\nstring GetCapturedTestStderr() {\n  GOOGLE_CHECK_NE(original_stderr_, -1) << \"Not capturing.\";\n\n  close(2);\n  dup2(original_stderr_, 2);\n  original_stderr_ = -1;\n\n  string result;\n  File::ReadFileToStringOrDie(stderr_capture_filename_, &result);\n\n  remove(stderr_capture_filename_.c_str());\n\n  return result;\n}\n\nScopedMemoryLog* ScopedMemoryLog::active_log_ = NULL;\n\nScopedMemoryLog::ScopedMemoryLog() {\n  GOOGLE_CHECK(active_log_ == NULL);\n  active_log_ = this;\n  old_handler_ = SetLogHandler(&HandleLog);\n}\n\nScopedMemoryLog::~ScopedMemoryLog() {\n  SetLogHandler(old_handler_);\n  active_log_ = NULL;\n}\n\nconst vector<string>& ScopedMemoryLog::GetMessages(LogLevel level) {\n  GOOGLE_CHECK(level == ERROR ||\n               level == WARNING);\n  return messages_[level];\n}\n\nvoid ScopedMemoryLog::HandleLog(LogLevel level, const char* filename,\n                                int line, const string& message) {\n  GOOGLE_CHECK(active_log_ != NULL);\n  if (level == ERROR || level == WARNING) {\n    active_log_->messages_[level].push_back(message);\n  }\n}\n\nnamespace {\n\n// Force shutdown at process exit so that we can test for memory leaks.  To\n// actually check for leaks, I suggest using the heap checker included with\n// google-perftools.  Set it to \"draconian\" mode to ensure that every last\n// call to malloc() has a corresponding free().\nstruct ForceShutdown {\n  ~ForceShutdown() {\n    ShutdownProtobufLibrary();\n  }\n} force_shutdown;\n\n}  // namespace\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/testing/googletest.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n// emulates google3/testing/base/public/googletest.h\n\n#ifndef GOOGLE_PROTOBUF_GOOGLETEST_H__\n#define GOOGLE_PROTOBUF_GOOGLETEST_H__\n\n#include <map>\n#include <vector>\n#include <google/protobuf/stubs/common.h>\n\n// Disable death tests if we use exceptions in CHECK().\n#if !PROTOBUF_USE_EXCEPTIONS && defined(GTEST_HAS_DEATH_TEST)\n#define PROTOBUF_HAS_DEATH_TEST\n#endif\n\nnamespace google {\nnamespace protobuf {\n\n// When running unittests, get the directory containing the source code.\nstring TestSourceDir();\n\n// When running unittests, get a directory where temporary files may be\n// placed.\nstring TestTempDir();\n\n// Capture all text written to stdout or stderr.\nvoid CaptureTestStdout();\nvoid CaptureTestStderr();\n\n// Stop capturing stdout or stderr and return the text captured.\nstring GetCapturedTestStdout();\nstring GetCapturedTestStderr();\n\n// For use with ScopedMemoryLog::GetMessages().  Inside Google the LogLevel\n// constants don't have the LOGLEVEL_ prefix, so the code that used\n// ScopedMemoryLog refers to LOGLEVEL_ERROR as just ERROR.\n#undef ERROR  // defend against promiscuous windows.h\nstatic const LogLevel ERROR = LOGLEVEL_ERROR;\nstatic const LogLevel WARNING = LOGLEVEL_WARNING;\n\n// Receives copies of all LOG(ERROR) messages while in scope.  Sample usage:\n//   {\n//     ScopedMemoryLog log;  // constructor registers object as a log sink\n//     SomeRoutineThatMayLogMessages();\n//     const vector<string>& warnings = log.GetMessages(ERROR);\n//   }  // destructor unregisters object as a log sink\n// This is a dummy implementation which covers only what is used by protocol\n// buffer unit tests.\nclass ScopedMemoryLog {\n public:\n  ScopedMemoryLog();\n  virtual ~ScopedMemoryLog();\n\n  // Fetches all messages with the given severity level.\n  const vector<string>& GetMessages(LogLevel error);\n\n private:\n  map<LogLevel, vector<string> > messages_;\n  LogHandler* old_handler_;\n\n  static void HandleLog(LogLevel level, const char* filename, int line,\n                        const string& message);\n\n  static ScopedMemoryLog* active_log_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ScopedMemoryLog);\n};\n\n}  // namespace protobuf\n}  // namespace google\n\n#endif  // GOOGLE_PROTOBUF_GOOGLETEST_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/testing/zcgunzip.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2009 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: brianolson@google.com (Brian Olson)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Test program to verify that GzipInputStream is compatible with command line\n// gunzip or java.util.zip.GzipInputStream\n//\n// Reads gzip stream on standard input and writes decompressed data to standard\n// output.\n\n#include <assert.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <fcntl.h>\n\n#ifdef _WIN32\n#ifndef STDIN_FILENO\n#define STDIN_FILENO 0\n#endif\n#ifndef STDOUT_FILENO\n#define STDOUT_FILENO 1\n#endif\n#endif\n\n#include <google/protobuf/io/gzip_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n\nusing google::protobuf::io::FileInputStream;\nusing google::protobuf::io::GzipInputStream;\n\nint main(int argc, const char** argv) {\n  FileInputStream fin(STDIN_FILENO);\n  GzipInputStream in(&fin);\n\n  while (true) {\n    const void* inptr;\n    int inlen;\n    bool ok;\n    ok = in.Next(&inptr, &inlen);\n    if (!ok) {\n      break;\n    }\n    if (inlen > 0) {\n      int err = write(STDOUT_FILENO, inptr, inlen);\n      assert(err == inlen);\n    }\n  }\n\n  return 0;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/testing/zcgzip.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2009 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: brianolson@google.com (Brian Olson)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Test program to verify that GzipOutputStream is compatible with command line\n// gzip or java.util.zip.GzipOutputStream\n//\n// Reads data on standard input and writes compressed gzip stream to standard\n// output.\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <fcntl.h>\n\n#ifdef _WIN32\n#ifndef STDIN_FILENO\n#define STDIN_FILENO 0\n#endif\n#ifndef STDOUT_FILENO\n#define STDOUT_FILENO 1\n#endif\n#endif\n\n#include <google/protobuf/io/gzip_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n\nusing google::protobuf::io::FileOutputStream;\nusing google::protobuf::io::GzipOutputStream;\n\nint main(int argc, const char** argv) {\n  FileOutputStream fout(STDOUT_FILENO);\n  GzipOutputStream out(&fout);\n  int readlen;\n\n  while (true) {\n    void* outptr;\n    int outlen;\n    bool ok;\n    do {\n      ok = out.Next(&outptr, &outlen);\n      if (!ok) {\n        break;\n      }\n    } while (outlen <= 0);\n    readlen = read(STDIN_FILENO, outptr, outlen);\n    if (readlen <= 0) {\n      out.BackUp(outlen);\n      break;\n    }\n    if (readlen < outlen) {\n      out.BackUp(outlen - readlen);\n    }\n  }\n\n  return 0;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/text_format.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: jschorr@google.com (Joseph Schorr)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <algorithm>\n#include <float.h>\n#include <math.h>\n#include <stdio.h>\n#include <stack>\n#include <limits>\n#include <vector>\n\n#include <google/protobuf/text_format.h>\n\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/dynamic_message.h>\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/wire_format_lite.h>\n#include <google/protobuf/io/strtod.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/unknown_field_set.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/io/tokenizer.h>\n#include <google/protobuf/any.h>\n#include <google/protobuf/stubs/stringprintf.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/map_util.h>\n#include <google/protobuf/stubs/stl_util.h>\n\nnamespace google {\nnamespace protobuf {\n\nnamespace {\n\ninline bool IsHexNumber(const string& str) {\n  return (str.length() >= 2 && str[0] == '0' &&\n          (str[1] == 'x' || str[1] == 'X'));\n}\n\ninline bool IsOctNumber(const string& str) {\n  return (str.length() >= 2 && str[0] == '0' &&\n          (str[1] >= '0' && str[1] < '8'));\n}\n\ninline bool GetAnyFieldDescriptors(const Message& message,\n                                   const FieldDescriptor** type_url_field,\n                                   const FieldDescriptor** value_field) {\n    const Descriptor* descriptor = message.GetDescriptor();\n    *type_url_field = descriptor->FindFieldByNumber(1);\n    *value_field = descriptor->FindFieldByNumber(2);\n    return (*type_url_field != NULL &&\n            (*type_url_field)->type() == FieldDescriptor::TYPE_STRING &&\n            *value_field != NULL &&\n            (*value_field)->type() == FieldDescriptor::TYPE_BYTES);\n}\n\n}  // namespace\n\nstring Message::DebugString() const {\n  string debug_string;\n\n  TextFormat::Printer printer;\n  printer.SetExpandAny(true);\n\n  printer.PrintToString(*this, &debug_string);\n\n  return debug_string;\n}\n\nstring Message::ShortDebugString() const {\n  string debug_string;\n\n  TextFormat::Printer printer;\n  printer.SetSingleLineMode(true);\n  printer.SetExpandAny(true);\n\n  printer.PrintToString(*this, &debug_string);\n  // Single line mode currently might have an extra space at the end.\n  if (debug_string.size() > 0 &&\n      debug_string[debug_string.size() - 1] == ' ') {\n    debug_string.resize(debug_string.size() - 1);\n  }\n\n  return debug_string;\n}\n\nstring Message::Utf8DebugString() const {\n  string debug_string;\n\n  TextFormat::Printer printer;\n  printer.SetUseUtf8StringEscaping(true);\n  printer.SetExpandAny(true);\n\n  printer.PrintToString(*this, &debug_string);\n\n  return debug_string;\n}\n\nvoid Message::PrintDebugString() const {\n  printf(\"%s\", DebugString().c_str());\n}\n\n\n// ===========================================================================\n// Implementation of the parse information tree class.\nTextFormat::ParseInfoTree::ParseInfoTree() { }\n\nTextFormat::ParseInfoTree::~ParseInfoTree() {\n  // Remove any nested information trees, as they are owned by this tree.\n  for (NestedMap::iterator it = nested_.begin(); it != nested_.end(); ++it) {\n    STLDeleteElements(&(it->second));\n  }\n}\n\nvoid TextFormat::ParseInfoTree::RecordLocation(\n    const FieldDescriptor* field,\n    TextFormat::ParseLocation location) {\n  locations_[field].push_back(location);\n}\n\nTextFormat::ParseInfoTree* TextFormat::ParseInfoTree::CreateNested(\n    const FieldDescriptor* field) {\n  // Owned by us in the map.\n  TextFormat::ParseInfoTree* instance = new TextFormat::ParseInfoTree();\n  vector<TextFormat::ParseInfoTree*>* trees = &nested_[field];\n  GOOGLE_CHECK(trees);\n  trees->push_back(instance);\n  return instance;\n}\n\nvoid CheckFieldIndex(const FieldDescriptor* field, int index) {\n  if (field == NULL) { return; }\n\n  if (field->is_repeated() && index == -1) {\n    GOOGLE_LOG(DFATAL) << \"Index must be in range of repeated field values. \"\n                << \"Field: \" << field->name();\n  } else if (!field->is_repeated() && index != -1) {\n    GOOGLE_LOG(DFATAL) << \"Index must be -1 for singular fields.\"\n                << \"Field: \" << field->name();\n  }\n}\n\nTextFormat::ParseLocation TextFormat::ParseInfoTree::GetLocation(\n    const FieldDescriptor* field, int index) const {\n  CheckFieldIndex(field, index);\n  if (index == -1) { index = 0; }\n\n  const vector<TextFormat::ParseLocation>* locations =\n      FindOrNull(locations_, field);\n  if (locations == NULL || index >= locations->size()) {\n    return TextFormat::ParseLocation();\n  }\n\n  return (*locations)[index];\n}\n\nTextFormat::ParseInfoTree* TextFormat::ParseInfoTree::GetTreeForNested(\n    const FieldDescriptor* field, int index) const {\n  CheckFieldIndex(field, index);\n  if (index == -1) { index = 0; }\n\n  const vector<TextFormat::ParseInfoTree*>* trees = FindOrNull(nested_, field);\n  if (trees == NULL || index >= trees->size()) {\n    return NULL;\n  }\n\n  return (*trees)[index];\n}\n\n\n// ===========================================================================\n// Internal class for parsing an ASCII representation of a Protocol Message.\n// This class makes use of the Protocol Message compiler's tokenizer found\n// in //google/protobuf/io/tokenizer.h. Note that class's Parse\n// method is *not* thread-safe and should only be used in a single thread at\n// a time.\n\n// Makes code slightly more readable.  The meaning of \"DO(foo)\" is\n// \"Execute foo and fail if it fails.\", where failure is indicated by\n// returning false. Borrowed from parser.cc (Thanks Kenton!).\n#define DO(STATEMENT) if (STATEMENT) {} else return false\n\nclass TextFormat::Parser::ParserImpl {\n public:\n\n  // Determines if repeated values for non-repeated fields and\n  // oneofs are permitted, e.g., the string \"foo: 1 foo: 2\" for a\n  // required/optional field named \"foo\", or \"baz: 1 qux: 2\"\n  // where \"baz\" and \"qux\" are members of the same oneof.\n  enum SingularOverwritePolicy {\n    ALLOW_SINGULAR_OVERWRITES = 0,   // the last value is retained\n    FORBID_SINGULAR_OVERWRITES = 1,  // an error is issued\n  };\n\n  ParserImpl(const Descriptor* root_message_type,\n             io::ZeroCopyInputStream* input_stream,\n             io::ErrorCollector* error_collector,\n             TextFormat::Finder* finder,\n             ParseInfoTree* parse_info_tree,\n             SingularOverwritePolicy singular_overwrite_policy,\n             bool allow_case_insensitive_field,\n             bool allow_unknown_field,\n             bool allow_unknown_enum,\n             bool allow_field_number,\n             bool allow_relaxed_whitespace,\n             bool allow_partial)\n    : error_collector_(error_collector),\n      finder_(finder),\n      parse_info_tree_(parse_info_tree),\n      tokenizer_error_collector_(this),\n      tokenizer_(input_stream, &tokenizer_error_collector_),\n      root_message_type_(root_message_type),\n      singular_overwrite_policy_(singular_overwrite_policy),\n      allow_case_insensitive_field_(allow_case_insensitive_field),\n      allow_unknown_field_(allow_unknown_field),\n      allow_unknown_enum_(allow_unknown_enum),\n      allow_field_number_(allow_field_number),\n      allow_partial_(allow_partial),\n      had_errors_(false) {\n    // For backwards-compatibility with proto1, we need to allow the 'f' suffix\n    // for floats.\n    tokenizer_.set_allow_f_after_float(true);\n\n    // '#' starts a comment.\n    tokenizer_.set_comment_style(io::Tokenizer::SH_COMMENT_STYLE);\n\n    if (allow_relaxed_whitespace) {\n      tokenizer_.set_require_space_after_number(false);\n      tokenizer_.set_allow_multiline_strings(true);\n    }\n\n    // Consume the starting token.\n    tokenizer_.Next();\n  }\n  ~ParserImpl() { }\n\n  // Parses the ASCII representation specified in input and saves the\n  // information into the output pointer (a Message). Returns\n  // false if an error occurs (an error will also be logged to\n  // GOOGLE_LOG(ERROR)).\n  bool Parse(Message* output) {\n    // Consume fields until we cannot do so anymore.\n    while (true) {\n      if (LookingAtType(io::Tokenizer::TYPE_END)) {\n        return !had_errors_;\n      }\n\n      DO(ConsumeField(output));\n    }\n  }\n\n  bool ParseField(const FieldDescriptor* field, Message* output) {\n    bool suc;\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n      suc = ConsumeFieldMessage(output, output->GetReflection(), field);\n    } else {\n      suc = ConsumeFieldValue(output, output->GetReflection(), field);\n    }\n    return suc && LookingAtType(io::Tokenizer::TYPE_END);\n  }\n\n  void ReportError(int line, int col, const string& message) {\n    had_errors_ = true;\n    if (error_collector_ == NULL) {\n      if (line >= 0) {\n        GOOGLE_LOG(ERROR) << \"Error parsing text-format \"\n                   << root_message_type_->full_name()\n                   << \": \" << (line + 1) << \":\"\n                   << (col + 1) << \": \" << message;\n      } else {\n        GOOGLE_LOG(ERROR) << \"Error parsing text-format \"\n                   << root_message_type_->full_name()\n                   << \": \" << message;\n      }\n    } else {\n      error_collector_->AddError(line, col, message);\n    }\n  }\n\n  void ReportWarning(int line, int col, const string& message) {\n    if (error_collector_ == NULL) {\n      if (line >= 0) {\n        GOOGLE_LOG(WARNING) << \"Warning parsing text-format \"\n                     << root_message_type_->full_name()\n                     << \": \" << (line + 1) << \":\"\n                     << (col + 1) << \": \" << message;\n      } else {\n        GOOGLE_LOG(WARNING) << \"Warning parsing text-format \"\n                     << root_message_type_->full_name()\n                     << \": \" << message;\n      }\n    } else {\n      error_collector_->AddWarning(line, col, message);\n    }\n  }\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ParserImpl);\n\n  // Reports an error with the given message with information indicating\n  // the position (as derived from the current token).\n  void ReportError(const string& message) {\n    ReportError(tokenizer_.current().line, tokenizer_.current().column,\n                message);\n  }\n\n  // Reports a warning with the given message with information indicating\n  // the position (as derived from the current token).\n  void ReportWarning(const string& message) {\n    ReportWarning(tokenizer_.current().line, tokenizer_.current().column,\n                  message);\n  }\n\n  // Consumes the specified message with the given starting delimiter.\n  // This method checks to see that the end delimiter at the conclusion of\n  // the consumption matches the starting delimiter passed in here.\n  bool ConsumeMessage(Message* message, const string delimiter) {\n    while (!LookingAt(\">\") &&  !LookingAt(\"}\")) {\n      DO(ConsumeField(message));\n    }\n\n    // Confirm that we have a valid ending delimiter.\n    DO(Consume(delimiter));\n    return true;\n  }\n\n  // Consume either \"<\" or \"{\".\n  bool ConsumeMessageDelimiter(string* delimiter) {\n    if (TryConsume(\"<\")) {\n      *delimiter = \">\";\n    } else {\n      DO(Consume(\"{\"));\n      *delimiter = \"}\";\n    }\n    return true;\n  }\n\n\n  // Consumes the current field (as returned by the tokenizer) on the\n  // passed in message.\n  bool ConsumeField(Message* message) {\n    const Reflection* reflection = message->GetReflection();\n    const Descriptor* descriptor = message->GetDescriptor();\n\n    string field_name;\n\n    const FieldDescriptor* field = NULL;\n    int start_line = tokenizer_.current().line;\n    int start_column = tokenizer_.current().column;\n\n    const FieldDescriptor* any_type_url_field;\n    const FieldDescriptor* any_value_field;\n    if (internal::GetAnyFieldDescriptors(*message, &any_type_url_field,\n                                         &any_value_field) &&\n        TryConsume(\"[\")) {\n      string full_type_name, prefix;\n      DO(ConsumeAnyTypeUrl(&full_type_name, &prefix));\n      DO(Consume(\"]\"));\n      TryConsume(\":\");  // ':' is optional between message labels and values.\n      string serialized_value;\n      DO(ConsumeAnyValue(full_type_name,\n                         message->GetDescriptor()->file()->pool(),\n                         &serialized_value));\n      reflection->SetString(\n          message, any_type_url_field,\n          string(prefix + full_type_name));\n      reflection->SetString(message, any_value_field, serialized_value);\n      return true;\n    }\n    if (TryConsume(\"[\")) {\n      // Extension.\n      DO(ConsumeFullTypeName(&field_name));\n      DO(Consume(\"]\"));\n\n      field = (finder_ != NULL\n               ? finder_->FindExtension(message, field_name)\n               : reflection->FindKnownExtensionByName(field_name));\n\n      if (field == NULL) {\n        if (!allow_unknown_field_) {\n          ReportError(\"Extension \\\"\" + field_name + \"\\\" is not defined or \"\n                      \"is not an extension of \\\"\" +\n                      descriptor->full_name() + \"\\\".\");\n          return false;\n        } else {\n          ReportWarning(\"Extension \\\"\" + field_name + \"\\\" is not defined or \"\n                        \"is not an extension of \\\"\" +\n                        descriptor->full_name() + \"\\\".\");\n        }\n      }\n    } else {\n      DO(ConsumeIdentifier(&field_name));\n\n      int32 field_number;\n      if (allow_field_number_ && safe_strto32(field_name, &field_number)) {\n        if (descriptor->IsExtensionNumber(field_number)) {\n          field = reflection->FindKnownExtensionByNumber(field_number);\n        } else {\n          field = descriptor->FindFieldByNumber(field_number);\n        }\n      } else {\n        field = descriptor->FindFieldByName(field_name);\n        // Group names are expected to be capitalized as they appear in the\n        // .proto file, which actually matches their type names, not their\n        // field names.\n        if (field == NULL) {\n          string lower_field_name = field_name;\n          LowerString(&lower_field_name);\n          field = descriptor->FindFieldByName(lower_field_name);\n          // If the case-insensitive match worked but the field is NOT a group,\n          if (field != NULL && field->type() != FieldDescriptor::TYPE_GROUP) {\n            field = NULL;\n          }\n        }\n        // Again, special-case group names as described above.\n        if (field != NULL && field->type() == FieldDescriptor::TYPE_GROUP\n            && field->message_type()->name() != field_name) {\n          field = NULL;\n        }\n\n        if (field == NULL && allow_case_insensitive_field_) {\n          string lower_field_name = field_name;\n          LowerString(&lower_field_name);\n          field = descriptor->FindFieldByLowercaseName(lower_field_name);\n        }\n      }\n\n      if (field == NULL) {\n        if (!allow_unknown_field_) {\n          ReportError(\"Message type \\\"\" + descriptor->full_name() +\n                      \"\\\" has no field named \\\"\" + field_name + \"\\\".\");\n          return false;\n        } else {\n          ReportWarning(\"Message type \\\"\" + descriptor->full_name() +\n                        \"\\\" has no field named \\\"\" + field_name + \"\\\".\");\n        }\n      }\n    }\n\n    // Skips unknown field.\n    if (field == NULL) {\n      GOOGLE_CHECK(allow_unknown_field_);\n      // Try to guess the type of this field.\n      // If this field is not a message, there should be a \":\" between the\n      // field name and the field value and also the field value should not\n      // start with \"{\" or \"<\" which indicates the beginning of a message body.\n      // If there is no \":\" or there is a \"{\" or \"<\" after \":\", this field has\n      // to be a message or the input is ill-formed.\n      if (TryConsume(\":\") && !LookingAt(\"{\") && !LookingAt(\"<\")) {\n        return SkipFieldValue();\n      } else {\n        return SkipFieldMessage();\n      }\n    }\n\n    if (singular_overwrite_policy_ == FORBID_SINGULAR_OVERWRITES) {\n      // Fail if the field is not repeated and it has already been specified.\n      if (!field->is_repeated() && reflection->HasField(*message, field)) {\n        ReportError(\"Non-repeated field \\\"\" + field_name +\n                    \"\\\" is specified multiple times.\");\n        return false;\n      }\n      // Fail if the field is a member of a oneof and another member has already\n      // been specified.\n      const OneofDescriptor* oneof = field->containing_oneof();\n      if (oneof != NULL && reflection->HasOneof(*message, oneof)) {\n        const FieldDescriptor* other_field =\n            reflection->GetOneofFieldDescriptor(*message, oneof);\n        ReportError(\"Field \\\"\" + field_name + \"\\\" is specified along with \"\n                    \"field \\\"\" + other_field->name() + \"\\\", another member \"\n                    \"of oneof \\\"\" + oneof->name() + \"\\\".\");\n        return false;\n      }\n    }\n\n    // Perform special handling for embedded message types.\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n      // ':' is optional here.\n      TryConsume(\":\");\n    } else {\n      // ':' is required here.\n      DO(Consume(\":\"));\n    }\n\n    if (field->is_repeated() && TryConsume(\"[\")) {\n      // Short repeated format, e.g.  \"foo: [1, 2, 3]\"\n      while (true) {\n        if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n          // Perform special handling for embedded message types.\n          DO(ConsumeFieldMessage(message, reflection, field));\n        } else {\n          DO(ConsumeFieldValue(message, reflection, field));\n        }\n        if (TryConsume(\"]\")) {\n          break;\n        }\n        DO(Consume(\",\"));\n      }\n    } else if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n      DO(ConsumeFieldMessage(message, reflection, field));\n    } else {\n      DO(ConsumeFieldValue(message, reflection, field));\n    }\n\n    // For historical reasons, fields may optionally be separated by commas or\n    // semicolons.\n    TryConsume(\";\") || TryConsume(\",\");\n\n    if (field->options().deprecated()) {\n      ReportWarning(\"text format contains deprecated field \\\"\"\n                    + field_name + \"\\\"\");\n    }\n\n    // If a parse info tree exists, add the location for the parsed\n    // field.\n    if (parse_info_tree_ != NULL) {\n      RecordLocation(parse_info_tree_, field,\n                     ParseLocation(start_line, start_column));\n    }\n\n    return true;\n  }\n\n  // Skips the next field including the field's name and value.\n  bool SkipField() {\n    string field_name;\n    if (TryConsume(\"[\")) {\n      // Extension name.\n      DO(ConsumeFullTypeName(&field_name));\n      DO(Consume(\"]\"));\n    } else {\n      DO(ConsumeIdentifier(&field_name));\n    }\n\n    // Try to guess the type of this field.\n    // If this field is not a message, there should be a \":\" between the\n    // field name and the field value and also the field value should not\n    // start with \"{\" or \"<\" which indicates the beginning of a message body.\n    // If there is no \":\" or there is a \"{\" or \"<\" after \":\", this field has\n    // to be a message or the input is ill-formed.\n    if (TryConsume(\":\") && !LookingAt(\"{\") && !LookingAt(\"<\")) {\n      DO(SkipFieldValue());\n    } else {\n      DO(SkipFieldMessage());\n    }\n    // For historical reasons, fields may optionally be separated by commas or\n    // semicolons.\n    TryConsume(\";\") || TryConsume(\",\");\n    return true;\n  }\n\n  bool ConsumeFieldMessage(Message* message,\n                           const Reflection* reflection,\n                           const FieldDescriptor* field) {\n\n    // If the parse information tree is not NULL, create a nested one\n    // for the nested message.\n    ParseInfoTree* parent = parse_info_tree_;\n    if (parent != NULL) {\n      parse_info_tree_ = CreateNested(parent, field);\n    }\n\n    string delimiter;\n    DO(ConsumeMessageDelimiter(&delimiter));\n    if (field->is_repeated()) {\n      DO(ConsumeMessage(reflection->AddMessage(message, field), delimiter));\n    } else {\n      DO(ConsumeMessage(reflection->MutableMessage(message, field),\n                        delimiter));\n    }\n\n    // Reset the parse information tree.\n    parse_info_tree_ = parent;\n    return true;\n  }\n\n  // Skips the whole body of a message including the beginning delimiter and\n  // the ending delimiter.\n  bool SkipFieldMessage() {\n    string delimiter;\n    DO(ConsumeMessageDelimiter(&delimiter));\n    while (!LookingAt(\">\") &&  !LookingAt(\"}\")) {\n      DO(SkipField());\n    }\n    DO(Consume(delimiter));\n    return true;\n  }\n\n  bool ConsumeFieldValue(Message* message,\n                         const Reflection* reflection,\n                         const FieldDescriptor* field) {\n\n// Define an easy to use macro for setting fields. This macro checks\n// to see if the field is repeated (in which case we need to use the Add\n// methods or not (in which case we need to use the Set methods).\n#define SET_FIELD(CPPTYPE, VALUE)                                  \\\n        if (field->is_repeated()) {                                \\\n          reflection->Add##CPPTYPE(message, field, VALUE);         \\\n        } else {                                                   \\\n          reflection->Set##CPPTYPE(message, field, VALUE);         \\\n        }                                                          \\\n\n    switch(field->cpp_type()) {\n      case FieldDescriptor::CPPTYPE_INT32: {\n        int64 value;\n        DO(ConsumeSignedInteger(&value, kint32max));\n        SET_FIELD(Int32, static_cast<int32>(value));\n        break;\n      }\n\n      case FieldDescriptor::CPPTYPE_UINT32: {\n        uint64 value;\n        DO(ConsumeUnsignedInteger(&value, kuint32max));\n        SET_FIELD(UInt32, static_cast<uint32>(value));\n        break;\n      }\n\n      case FieldDescriptor::CPPTYPE_INT64: {\n        int64 value;\n        DO(ConsumeSignedInteger(&value, kint64max));\n        SET_FIELD(Int64, value);\n        break;\n      }\n\n      case FieldDescriptor::CPPTYPE_UINT64: {\n        uint64 value;\n        DO(ConsumeUnsignedInteger(&value, kuint64max));\n        SET_FIELD(UInt64, value);\n        break;\n      }\n\n      case FieldDescriptor::CPPTYPE_FLOAT: {\n        double value;\n        DO(ConsumeDouble(&value));\n        SET_FIELD(Float, io::SafeDoubleToFloat(value));\n        break;\n      }\n\n      case FieldDescriptor::CPPTYPE_DOUBLE: {\n        double value;\n        DO(ConsumeDouble(&value));\n        SET_FIELD(Double, value);\n        break;\n      }\n\n      case FieldDescriptor::CPPTYPE_STRING: {\n        string value;\n        DO(ConsumeString(&value));\n        SET_FIELD(String, value);\n        break;\n      }\n\n      case FieldDescriptor::CPPTYPE_BOOL: {\n        if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) {\n          uint64 value;\n          DO(ConsumeUnsignedInteger(&value, 1));\n          SET_FIELD(Bool, value);\n        } else {\n          string value;\n          DO(ConsumeIdentifier(&value));\n          if (value == \"true\" || value == \"True\" || value == \"t\") {\n            SET_FIELD(Bool, true);\n          } else if (value == \"false\" || value == \"False\" || value == \"f\") {\n            SET_FIELD(Bool, false);\n          } else {\n            ReportError(\"Invalid value for boolean field \\\"\" + field->name()\n                        + \"\\\". Value: \\\"\" + value  + \"\\\".\");\n            return false;\n          }\n        }\n        break;\n      }\n\n      case FieldDescriptor::CPPTYPE_ENUM: {\n        string value;\n        const EnumDescriptor* enum_type = field->enum_type();\n        const EnumValueDescriptor* enum_value = NULL;\n\n        if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) {\n          DO(ConsumeIdentifier(&value));\n          // Find the enumeration value.\n          enum_value = enum_type->FindValueByName(value);\n\n        } else if (LookingAt(\"-\") ||\n                   LookingAtType(io::Tokenizer::TYPE_INTEGER)) {\n          int64 int_value;\n          DO(ConsumeSignedInteger(&int_value, kint32max));\n          value = SimpleItoa(int_value);        // for error reporting\n          enum_value = enum_type->FindValueByNumber(int_value);\n        } else {\n          ReportError(\"Expected integer or identifier, got: \" +\n                      tokenizer_.current().text);\n          return false;\n        }\n\n        if (enum_value == NULL) {\n          if (!allow_unknown_enum_) {\n            ReportError(\"Unknown enumeration value of \\\"\" + value  + \"\\\" for \"\n                        \"field \\\"\" + field->name() + \"\\\".\");\n            return false;\n          } else {\n            ReportWarning(\"Unknown enumeration value of \\\"\" + value  + \"\\\" for \"\n                          \"field \\\"\" + field->name() + \"\\\".\");\n            return true;\n          }\n        }\n\n        SET_FIELD(Enum, enum_value);\n        break;\n      }\n\n      case FieldDescriptor::CPPTYPE_MESSAGE: {\n        // We should never get here. Put here instead of a default\n        // so that if new types are added, we get a nice compiler warning.\n        GOOGLE_LOG(FATAL) << \"Reached an unintended state: CPPTYPE_MESSAGE\";\n        break;\n      }\n    }\n#undef SET_FIELD\n    return true;\n  }\n\n  bool SkipFieldValue() {\n    if (LookingAtType(io::Tokenizer::TYPE_STRING)) {\n      while (LookingAtType(io::Tokenizer::TYPE_STRING)) {\n        tokenizer_.Next();\n      }\n      return true;\n    }\n    if (TryConsume(\"[\")) {\n      while (true) {\n        if (!LookingAt(\"{\") && !LookingAt(\"<\")) {\n          DO(SkipFieldValue());\n        } else {\n          DO(SkipFieldMessage());\n        }\n        if (TryConsume(\"]\")) {\n          break;\n        }\n        DO(Consume(\",\"));\n      }\n      return true;\n    }\n    // Possible field values other than string:\n    //   12345        => TYPE_INTEGER\n    //   -12345       => TYPE_SYMBOL + TYPE_INTEGER\n    //   1.2345       => TYPE_FLOAT\n    //   -1.2345      => TYPE_SYMBOL + TYPE_FLOAT\n    //   inf          => TYPE_IDENTIFIER\n    //   -inf         => TYPE_SYMBOL + TYPE_IDENTIFIER\n    //   TYPE_INTEGER => TYPE_IDENTIFIER\n    // Divides them into two group, one with TYPE_SYMBOL\n    // and the other without:\n    //   Group one:\n    //     12345        => TYPE_INTEGER\n    //     1.2345       => TYPE_FLOAT\n    //     inf          => TYPE_IDENTIFIER\n    //     TYPE_INTEGER => TYPE_IDENTIFIER\n    //   Group two:\n    //     -12345       => TYPE_SYMBOL + TYPE_INTEGER\n    //     -1.2345      => TYPE_SYMBOL + TYPE_FLOAT\n    //     -inf         => TYPE_SYMBOL + TYPE_IDENTIFIER\n    // As we can see, the field value consists of an optional '-' and one of\n    // TYPE_INTEGER, TYPE_FLOAT and TYPE_IDENTIFIER.\n    bool has_minus = TryConsume(\"-\");\n    if (!LookingAtType(io::Tokenizer::TYPE_INTEGER) &&\n        !LookingAtType(io::Tokenizer::TYPE_FLOAT) &&\n        !LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) {\n      return false;\n    }\n    // Combination of '-' and TYPE_IDENTIFIER may result in an invalid field\n    // value while other combinations all generate valid values.\n    // We check if the value of this combination is valid here.\n    // TYPE_IDENTIFIER after a '-' should be one of the float values listed\n    // below:\n    //   inf, inff, infinity, nan\n    if (has_minus && LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) {\n      string text = tokenizer_.current().text;\n      LowerString(&text);\n      if (text != \"inf\" &&\n          text != \"infinity\" &&\n          text != \"nan\") {\n        ReportError(\"Invalid float number: \" + text);\n        return false;\n      }\n    }\n    tokenizer_.Next();\n    return true;\n  }\n\n  // Returns true if the current token's text is equal to that specified.\n  bool LookingAt(const string& text) {\n    return tokenizer_.current().text == text;\n  }\n\n  // Returns true if the current token's type is equal to that specified.\n  bool LookingAtType(io::Tokenizer::TokenType token_type) {\n    return tokenizer_.current().type == token_type;\n  }\n\n  // Consumes an identifier and saves its value in the identifier parameter.\n  // Returns false if the token is not of type IDENTFIER.\n  bool ConsumeIdentifier(string* identifier) {\n    if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) {\n      *identifier = tokenizer_.current().text;\n      tokenizer_.Next();\n      return true;\n    }\n\n    // If allow_field_numer_ or allow_unknown_field_ is true, we should able\n    // to parse integer identifiers.\n    if ((allow_field_number_ || allow_unknown_field_)\n        && LookingAtType(io::Tokenizer::TYPE_INTEGER)) {\n      *identifier = tokenizer_.current().text;\n      tokenizer_.Next();\n      return true;\n    }\n\n    ReportError(\"Expected identifier, got: \" + tokenizer_.current().text);\n    return false;\n  }\n\n  // Consume a string of form \"<id1>.<id2>....<idN>\".\n  bool ConsumeFullTypeName(string* name) {\n    DO(ConsumeIdentifier(name));\n    while (TryConsume(\".\")) {\n      string part;\n      DO(ConsumeIdentifier(&part));\n      *name += \".\";\n      *name += part;\n    }\n    return true;\n  }\n\n  // Consumes a string and saves its value in the text parameter.\n  // Returns false if the token is not of type STRING.\n  bool ConsumeString(string* text) {\n    if (!LookingAtType(io::Tokenizer::TYPE_STRING)) {\n      ReportError(\"Expected string, got: \" + tokenizer_.current().text);\n      return false;\n    }\n\n    text->clear();\n    while (LookingAtType(io::Tokenizer::TYPE_STRING)) {\n      io::Tokenizer::ParseStringAppend(tokenizer_.current().text, text);\n\n      tokenizer_.Next();\n    }\n\n    return true;\n  }\n\n  // Consumes a uint64 and saves its value in the value parameter.\n  // Returns false if the token is not of type INTEGER.\n  bool ConsumeUnsignedInteger(uint64* value, uint64 max_value) {\n    if (!LookingAtType(io::Tokenizer::TYPE_INTEGER)) {\n      ReportError(\"Expected integer, got: \" + tokenizer_.current().text);\n      return false;\n    }\n\n    if (!io::Tokenizer::ParseInteger(tokenizer_.current().text,\n                                     max_value, value)) {\n      ReportError(\"Integer out of range (\" + tokenizer_.current().text + \")\");\n      return false;\n    }\n\n    tokenizer_.Next();\n    return true;\n  }\n\n  // Consumes an int64 and saves its value in the value parameter.\n  // Note that since the tokenizer does not support negative numbers,\n  // we actually may consume an additional token (for the minus sign) in this\n  // method. Returns false if the token is not an integer\n  // (signed or otherwise).\n  bool ConsumeSignedInteger(int64* value, uint64 max_value) {\n    bool negative = false;\n\n    if (TryConsume(\"-\")) {\n      negative = true;\n      // Two's complement always allows one more negative integer than\n      // positive.\n      ++max_value;\n    }\n\n    uint64 unsigned_value;\n\n    DO(ConsumeUnsignedInteger(&unsigned_value, max_value));\n\n    if (negative) {\n      if ((static_cast<uint64>(kint64max) + 1) == unsigned_value) {\n        *value = kint64min;\n      } else {\n        *value = -static_cast<int64>(unsigned_value);\n      }\n    } else {\n      *value = static_cast<int64>(unsigned_value);\n    }\n\n    return true;\n  }\n\n  // Consumes a uint64 and saves its value in the value parameter.\n  // Accepts decimal numbers only, rejects hex or oct numbers.\n  bool ConsumeUnsignedDecimalInteger(uint64* value, uint64 max_value) {\n    if (!LookingAtType(io::Tokenizer::TYPE_INTEGER)) {\n      ReportError(\"Expected integer, got: \" + tokenizer_.current().text);\n      return false;\n    }\n\n    const string& text = tokenizer_.current().text;\n    if (IsHexNumber(text) || IsOctNumber(text)) {\n      ReportError(\"Expect a decimal number, got: \" + text);\n      return false;\n    }\n\n    if (!io::Tokenizer::ParseInteger(text, max_value, value)) {\n      ReportError(\"Integer out of range (\" + text + \")\");\n      return false;\n    }\n\n    tokenizer_.Next();\n    return true;\n  }\n\n  // Consumes a double and saves its value in the value parameter.\n  // Note that since the tokenizer does not support negative numbers,\n  // we actually may consume an additional token (for the minus sign) in this\n  // method. Returns false if the token is not a double\n  // (signed or otherwise).\n  bool ConsumeDouble(double* value) {\n    bool negative = false;\n\n    if (TryConsume(\"-\")) {\n      negative = true;\n    }\n\n    // A double can actually be an integer, according to the tokenizer.\n    // Therefore, we must check both cases here.\n    if (LookingAtType(io::Tokenizer::TYPE_INTEGER)) {\n      // We have found an integer value for the double.\n      uint64 integer_value;\n      DO(ConsumeUnsignedDecimalInteger(&integer_value, kuint64max));\n\n      *value = static_cast<double>(integer_value);\n    } else if (LookingAtType(io::Tokenizer::TYPE_FLOAT)) {\n      // We have found a float value for the double.\n      *value = io::Tokenizer::ParseFloat(tokenizer_.current().text);\n\n      // Mark the current token as consumed.\n      tokenizer_.Next();\n    } else if (LookingAtType(io::Tokenizer::TYPE_IDENTIFIER)) {\n      string text = tokenizer_.current().text;\n      LowerString(&text);\n      if (text == \"inf\" ||\n          text == \"infinity\") {\n        *value = std::numeric_limits<double>::infinity();\n        tokenizer_.Next();\n      } else if (text == \"nan\") {\n        *value = std::numeric_limits<double>::quiet_NaN();\n        tokenizer_.Next();\n      } else {\n        ReportError(\"Expected double, got: \" + text);\n        return false;\n      }\n    } else {\n      ReportError(\"Expected double, got: \" + tokenizer_.current().text);\n      return false;\n    }\n\n    if (negative) {\n      *value = -*value;\n    }\n\n    return true;\n  }\n\n  // Consumes Any::type_url value, of form \"type.googleapis.com/full.type.Name\"\n  // or \"type.googleprod.com/full.type.Name\"\n  bool ConsumeAnyTypeUrl(string* full_type_name, string* prefix) {\n    // TODO(saito) Extend Consume() to consume multiple tokens at once, so that\n    // this code can be written as just DO(Consume(kGoogleApisTypePrefix)).\n    string url1, url2, url3;\n    DO(ConsumeIdentifier(&url1));  // type\n    DO(Consume(\".\"));\n    DO(ConsumeIdentifier(&url2));  // googleapis\n    DO(Consume(\".\"));\n    DO(ConsumeIdentifier(&url3));  // com\n    DO(Consume(\"/\"));\n    DO(ConsumeFullTypeName(full_type_name));\n\n    *prefix = url1 + \".\" + url2 + \".\" + url3 + \"/\";\n    if (*prefix != internal::kTypeGoogleApisComPrefix &&\n        *prefix != internal::kTypeGoogleProdComPrefix) {\n      ReportError(\"TextFormat::Parser for Any supports only \"\n                  \"type.googleapis.com and type.googleprod.com, \"\n                  \"but found \\\"\" + *prefix + \"\\\"\");\n      return false;\n    }\n    return true;\n  }\n\n  // A helper function for reconstructing Any::value. Consumes a text of\n  // full_type_name, then serializes it into serialized_value. \"pool\" is used to\n  // look up and create a temporary object with full_type_name.\n  bool ConsumeAnyValue(const string& full_type_name, const DescriptorPool* pool,\n                       string* serialized_value) {\n    const Descriptor* value_descriptor =\n        pool->FindMessageTypeByName(full_type_name);\n    if (value_descriptor == NULL) {\n      ReportError(\"Could not find type \\\"\" + full_type_name +\n                  \"\\\" stored in google.protobuf.Any.\");\n      return false;\n    }\n    DynamicMessageFactory factory;\n    const Message* value_prototype = factory.GetPrototype(value_descriptor);\n    if (value_prototype == NULL) {\n      return false;\n    }\n    google::protobuf::scoped_ptr<Message> value(value_prototype->New());\n    string sub_delimiter;\n    DO(ConsumeMessageDelimiter(&sub_delimiter));\n    DO(ConsumeMessage(value.get(), sub_delimiter));\n\n    if (allow_partial_) {\n      value->AppendPartialToString(serialized_value);\n    } else {\n      if (!value->IsInitialized()) {\n        ReportError(\n            \"Value of type \\\"\" + full_type_name +\n            \"\\\" stored in google.protobuf.Any has missing required fields\");\n        return false;\n      }\n      value->AppendToString(serialized_value);\n    }\n    return true;\n  }\n\n  // Consumes a token and confirms that it matches that specified in the\n  // value parameter. Returns false if the token found does not match that\n  // which was specified.\n  bool Consume(const string& value) {\n    const string& current_value = tokenizer_.current().text;\n\n    if (current_value != value) {\n      ReportError(\"Expected \\\"\" + value + \"\\\", found \\\"\" + current_value\n                  + \"\\\".\");\n      return false;\n    }\n\n    tokenizer_.Next();\n\n    return true;\n  }\n\n  // Attempts to consume the supplied value. Returns false if a the\n  // token found does not match the value specified.\n  bool TryConsume(const string& value) {\n    if (tokenizer_.current().text == value) {\n      tokenizer_.Next();\n      return true;\n    } else {\n      return false;\n    }\n  }\n\n  // An internal instance of the Tokenizer's error collector, used to\n  // collect any base-level parse errors and feed them to the ParserImpl.\n  class ParserErrorCollector : public io::ErrorCollector {\n   public:\n    explicit ParserErrorCollector(TextFormat::Parser::ParserImpl* parser) :\n        parser_(parser) { }\n\n    virtual ~ParserErrorCollector() { }\n\n    virtual void AddError(int line, int column, const string& message) {\n      parser_->ReportError(line, column, message);\n    }\n\n    virtual void AddWarning(int line, int column, const string& message) {\n      parser_->ReportWarning(line, column, message);\n    }\n\n   private:\n    GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ParserErrorCollector);\n    TextFormat::Parser::ParserImpl* parser_;\n  };\n\n  io::ErrorCollector* error_collector_;\n  TextFormat::Finder* finder_;\n  ParseInfoTree* parse_info_tree_;\n  ParserErrorCollector tokenizer_error_collector_;\n  io::Tokenizer tokenizer_;\n  const Descriptor* root_message_type_;\n  SingularOverwritePolicy singular_overwrite_policy_;\n  const bool allow_case_insensitive_field_;\n  const bool allow_unknown_field_;\n  const bool allow_unknown_enum_;\n  const bool allow_field_number_;\n  const bool allow_partial_;\n  bool had_errors_;\n};\n\n#undef DO\n\n// ===========================================================================\n// Internal class for writing text to the io::ZeroCopyOutputStream. Adapted\n// from the Printer found in //google/protobuf/io/printer.h\nclass TextFormat::Printer::TextGenerator {\n public:\n  explicit TextGenerator(io::ZeroCopyOutputStream* output,\n                         int initial_indent_level)\n    : output_(output),\n      buffer_(NULL),\n      buffer_size_(0),\n      at_start_of_line_(true),\n      failed_(false),\n      indent_(\"\"),\n      initial_indent_level_(initial_indent_level) {\n    indent_.resize(initial_indent_level_ * 2, ' ');\n  }\n\n  ~TextGenerator() {\n    // Only BackUp() if we're sure we've successfully called Next() at least\n    // once.\n    if (!failed_ && buffer_size_ > 0) {\n      output_->BackUp(buffer_size_);\n    }\n  }\n\n  // Indent text by two spaces.  After calling Indent(), two spaces will be\n  // inserted at the beginning of each line of text.  Indent() may be called\n  // multiple times to produce deeper indents.\n  void Indent() {\n    indent_ += \"  \";\n  }\n\n  // Reduces the current indent level by two spaces, or crashes if the indent\n  // level is zero.\n  void Outdent() {\n    if (indent_.empty() ||\n        indent_.size() < initial_indent_level_ * 2) {\n      GOOGLE_LOG(DFATAL) << \" Outdent() without matching Indent().\";\n      return;\n    }\n\n    indent_.resize(indent_.size() - 2);\n  }\n\n  // Print text to the output stream.\n  void Print(const string& str) {\n    Print(str.data(), str.size());\n  }\n\n  // Print text to the output stream.\n  void Print(const char* text) {\n    Print(text, strlen(text));\n  }\n\n  // Print text to the output stream.\n  void Print(const char* text, size_t size) {\n    size_t pos = 0;  // The number of bytes we've written so far.\n\n    for (size_t i = 0; i < size; i++) {\n      if (text[i] == '\\n') {\n        // Saw newline.  If there is more text, we may need to insert an indent\n        // here.  So, write what we have so far, including the '\\n'.\n        Write(text + pos, i - pos + 1);\n        pos = i + 1;\n\n        // Setting this true will cause the next Write() to insert an indent\n        // first.\n        at_start_of_line_ = true;\n      }\n    }\n\n    // Write the rest.\n    Write(text + pos, size - pos);\n  }\n\n  // True if any write to the underlying stream failed.  (We don't just\n  // crash in this case because this is an I/O failure, not a programming\n  // error.)\n  bool failed() const { return failed_; }\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TextGenerator);\n\n  void Write(const char* data, size_t size) {\n    if (failed_) return;\n    if (size == 0) return;\n\n    if (at_start_of_line_) {\n      // Insert an indent.\n      at_start_of_line_ = false;\n      Write(indent_.data(), indent_.size());\n      if (failed_) return;\n    }\n\n    while (size > buffer_size_) {\n      // Data exceeds space in the buffer.  Copy what we can and request a\n      // new buffer.\n      memcpy(buffer_, data, buffer_size_);\n      data += buffer_size_;\n      size -= buffer_size_;\n      void* void_buffer;\n      failed_ = !output_->Next(&void_buffer, &buffer_size_);\n      if (failed_) return;\n      buffer_ = reinterpret_cast<char*>(void_buffer);\n    }\n\n    // Buffer is big enough to receive the data; copy it.\n    memcpy(buffer_, data, size);\n    buffer_ += size;\n    buffer_size_ -= size;\n  }\n\n  io::ZeroCopyOutputStream* const output_;\n  char* buffer_;\n  int buffer_size_;\n  bool at_start_of_line_;\n  bool failed_;\n\n  string indent_;\n  int initial_indent_level_;\n};\n\n// ===========================================================================\n\nTextFormat::Finder::~Finder() {\n}\n\nTextFormat::Parser::Parser()\n  : error_collector_(NULL),\n    finder_(NULL),\n    parse_info_tree_(NULL),\n    allow_partial_(false),\n    allow_case_insensitive_field_(false),\n    allow_unknown_field_(false),\n    allow_unknown_enum_(false),\n    allow_field_number_(false),\n    allow_relaxed_whitespace_(false),\n    allow_singular_overwrites_(false) {\n}\n\nTextFormat::Parser::~Parser() {}\n\nbool TextFormat::Parser::Parse(io::ZeroCopyInputStream* input,\n                               Message* output) {\n  output->Clear();\n\n  ParserImpl::SingularOverwritePolicy overwrites_policy =\n      allow_singular_overwrites_\n      ? ParserImpl::ALLOW_SINGULAR_OVERWRITES\n      : ParserImpl::FORBID_SINGULAR_OVERWRITES;\n\n  ParserImpl parser(output->GetDescriptor(), input, error_collector_,\n                    finder_, parse_info_tree_,\n                    overwrites_policy,\n                    allow_case_insensitive_field_, allow_unknown_field_,\n                    allow_unknown_enum_, allow_field_number_,\n                    allow_relaxed_whitespace_, allow_partial_);\n  return MergeUsingImpl(input, output, &parser);\n}\n\nbool TextFormat::Parser::ParseFromString(const string& input,\n                                         Message* output) {\n  io::ArrayInputStream input_stream(input.data(), input.size());\n  return Parse(&input_stream, output);\n}\n\nbool TextFormat::Parser::Merge(io::ZeroCopyInputStream* input,\n                               Message* output) {\n  ParserImpl parser(output->GetDescriptor(), input, error_collector_,\n                    finder_, parse_info_tree_,\n                    ParserImpl::ALLOW_SINGULAR_OVERWRITES,\n                    allow_case_insensitive_field_, allow_unknown_field_,\n                    allow_unknown_enum_, allow_field_number_,\n                    allow_relaxed_whitespace_, allow_partial_);\n  return MergeUsingImpl(input, output, &parser);\n}\n\nbool TextFormat::Parser::MergeFromString(const string& input,\n                                         Message* output) {\n  io::ArrayInputStream input_stream(input.data(), input.size());\n  return Merge(&input_stream, output);\n}\n\nbool TextFormat::Parser::MergeUsingImpl(io::ZeroCopyInputStream* /* input */,\n                                        Message* output,\n                                        ParserImpl* parser_impl) {\n  if (!parser_impl->Parse(output)) return false;\n  if (!allow_partial_ && !output->IsInitialized()) {\n    vector<string> missing_fields;\n    output->FindInitializationErrors(&missing_fields);\n    parser_impl->ReportError(-1, 0, \"Message missing required fields: \" +\n                                        Join(missing_fields, \", \"));\n    return false;\n  }\n  return true;\n}\n\nbool TextFormat::Parser::ParseFieldValueFromString(\n    const string& input,\n    const FieldDescriptor* field,\n    Message* output) {\n  io::ArrayInputStream input_stream(input.data(), input.size());\n  ParserImpl parser(output->GetDescriptor(), &input_stream, error_collector_,\n                    finder_, parse_info_tree_,\n                    ParserImpl::ALLOW_SINGULAR_OVERWRITES,\n                    allow_case_insensitive_field_, allow_unknown_field_,\n                    allow_unknown_enum_, allow_field_number_,\n                    allow_relaxed_whitespace_, allow_partial_);\n  return parser.ParseField(field, output);\n}\n\n/* static */ bool TextFormat::Parse(io::ZeroCopyInputStream* input,\n                                    Message* output) {\n  return Parser().Parse(input, output);\n}\n\n/* static */ bool TextFormat::Merge(io::ZeroCopyInputStream* input,\n                                    Message* output) {\n  return Parser().Merge(input, output);\n}\n\n/* static */ bool TextFormat::ParseFromString(const string& input,\n                                              Message* output) {\n  return Parser().ParseFromString(input, output);\n}\n\n/* static */ bool TextFormat::MergeFromString(const string& input,\n                                              Message* output) {\n  return Parser().MergeFromString(input, output);\n}\n\n// ===========================================================================\n\n// The default implementation for FieldValuePrinter. The base class just\n// does simple formatting. That way, deriving classes could decide to fallback\n// to that behavior.\nTextFormat::FieldValuePrinter::FieldValuePrinter() {}\nTextFormat::FieldValuePrinter::~FieldValuePrinter() {}\nstring TextFormat::FieldValuePrinter::PrintBool(bool val) const {\n  return val ? \"true\" : \"false\";\n}\nstring TextFormat::FieldValuePrinter::PrintInt32(int32 val) const {\n  return SimpleItoa(val);\n}\nstring TextFormat::FieldValuePrinter::PrintUInt32(uint32 val) const {\n  return SimpleItoa(val);\n}\nstring TextFormat::FieldValuePrinter::PrintInt64(int64 val) const {\n  return SimpleItoa(val);\n}\nstring TextFormat::FieldValuePrinter::PrintUInt64(uint64 val) const {\n  return SimpleItoa(val);\n}\nstring TextFormat::FieldValuePrinter::PrintFloat(float val) const {\n  return SimpleFtoa(val);\n}\nstring TextFormat::FieldValuePrinter::PrintDouble(double val) const {\n  return SimpleDtoa(val);\n}\nstring TextFormat::FieldValuePrinter::PrintString(const string& val) const {\n  string printed(\"\\\"\");\n  CEscapeAndAppend(val, &printed);\n  printed.push_back('\\\"');\n  return printed;\n}\nstring TextFormat::FieldValuePrinter::PrintBytes(const string& val) const {\n  return PrintString(val);\n}\nstring TextFormat::FieldValuePrinter::PrintEnum(int32 val,\n                                                const string& name) const {\n  return name;\n}\nstring TextFormat::FieldValuePrinter::PrintFieldName(\n    const Message& message,\n    const Reflection* reflection,\n    const FieldDescriptor* field) const {\n  if (field->is_extension()) {\n    // We special-case MessageSet elements for compatibility with proto1.\n    if (field->containing_type()->options().message_set_wire_format()\n        && field->type() == FieldDescriptor::TYPE_MESSAGE\n        && field->is_optional()\n        && field->extension_scope() == field->message_type()) {\n      return StrCat(\"[\", field->message_type()->full_name(), \"]\");\n    } else {\n      return StrCat(\"[\", field->full_name(), \"]\");\n    }\n  } else if (field->type() == FieldDescriptor::TYPE_GROUP) {\n    // Groups must be serialized with their original capitalization.\n    return field->message_type()->name();\n  } else {\n    return field->name();\n  }\n}\nstring TextFormat::FieldValuePrinter::PrintMessageStart(\n    const Message& message,\n    int field_index,\n    int field_count,\n    bool single_line_mode) const {\n  return single_line_mode ? \" { \" : \" {\\n\";\n}\nstring TextFormat::FieldValuePrinter::PrintMessageEnd(\n    const Message& message,\n    int field_index,\n    int field_count,\n    bool single_line_mode) const {\n  return single_line_mode ? \"} \" : \"}\\n\";\n}\n\nnamespace {\n// Our own specialization: for UTF8 escaped strings.\nclass FieldValuePrinterUtf8Escaping : public TextFormat::FieldValuePrinter {\n public:\n  virtual string PrintString(const string& val) const {\n    return StrCat(\"\\\"\", strings::Utf8SafeCEscape(val), \"\\\"\");\n  }\n  virtual string PrintBytes(const string& val) const {\n    return TextFormat::FieldValuePrinter::PrintString(val);\n  }\n};\n\n}  // namespace\n\nTextFormat::Printer::Printer()\n  : initial_indent_level_(0),\n    single_line_mode_(false),\n    use_field_number_(false),\n    use_short_repeated_primitives_(false),\n    hide_unknown_fields_(false),\n    print_message_fields_in_index_order_(false),\n    expand_any_(false),\n    truncate_string_field_longer_than_(0LL) {\n  SetUseUtf8StringEscaping(false);\n}\n\nTextFormat::Printer::~Printer() {\n  STLDeleteValues(&custom_printers_);\n}\n\nvoid TextFormat::Printer::SetUseUtf8StringEscaping(bool as_utf8) {\n  SetDefaultFieldValuePrinter(as_utf8\n                              ? new FieldValuePrinterUtf8Escaping()\n                              : new FieldValuePrinter());\n}\n\nvoid TextFormat::Printer::SetDefaultFieldValuePrinter(\n    const FieldValuePrinter* printer) {\n  default_field_value_printer_.reset(printer);\n}\n\nbool TextFormat::Printer::RegisterFieldValuePrinter(\n    const FieldDescriptor* field,\n    const FieldValuePrinter* printer) {\n  return field != NULL && printer != NULL &&\n         custom_printers_.insert(std::make_pair(field, printer)).second;\n}\n\nbool TextFormat::Printer::PrintToString(const Message& message,\n                                        string* output) const {\n  GOOGLE_DCHECK(output) << \"output specified is NULL\";\n\n  output->clear();\n  io::StringOutputStream output_stream(output);\n\n  return Print(message, &output_stream);\n}\n\nbool TextFormat::Printer::PrintUnknownFieldsToString(\n    const UnknownFieldSet& unknown_fields,\n    string* output) const {\n  GOOGLE_DCHECK(output) << \"output specified is NULL\";\n\n  output->clear();\n  io::StringOutputStream output_stream(output);\n  return PrintUnknownFields(unknown_fields, &output_stream);\n}\n\nbool TextFormat::Printer::Print(const Message& message,\n                                io::ZeroCopyOutputStream* output) const {\n  TextGenerator generator(output, initial_indent_level_);\n\n  Print(message, generator);\n\n  // Output false if the generator failed internally.\n  return !generator.failed();\n}\n\nbool TextFormat::Printer::PrintUnknownFields(\n    const UnknownFieldSet& unknown_fields,\n    io::ZeroCopyOutputStream* output) const {\n  TextGenerator generator(output, initial_indent_level_);\n\n  PrintUnknownFields(unknown_fields, generator);\n\n  // Output false if the generator failed internally.\n  return !generator.failed();\n}\n\nnamespace {\n// Comparison functor for sorting FieldDescriptors by field index.\nstruct FieldIndexSorter {\n  bool operator()(const FieldDescriptor* left,\n                  const FieldDescriptor* right) const {\n    return left->index() < right->index();\n  }\n};\n\n}  // namespace\n\nbool TextFormat::Printer::PrintAny(const Message& message,\n                                   TextGenerator& generator) const {\n  const FieldDescriptor* type_url_field;\n  const FieldDescriptor* value_field;\n  if (!internal::GetAnyFieldDescriptors(message, &type_url_field,\n                                        &value_field)) {\n    return false;\n  }\n\n  const Reflection* reflection = message.GetReflection();\n\n  // Extract the full type name from the type_url field.\n  const string& type_url = reflection->GetString(message, type_url_field);\n  string full_type_name;\n  if (!internal::ParseAnyTypeUrl(type_url, &full_type_name)) {\n    return false;\n  }\n\n  // Print the \"value\" in text.\n  const google::protobuf::Descriptor* value_descriptor =\n      message.GetDescriptor()->file()->pool()->FindMessageTypeByName(\n          full_type_name);\n  if (value_descriptor == NULL) {\n    GOOGLE_LOG(WARNING) << \"Proto type \" << type_url << \" not found\";\n    return false;\n  }\n  DynamicMessageFactory factory;\n  google::protobuf::scoped_ptr<google::protobuf::Message> value_message(\n      factory.GetPrototype(value_descriptor)->New());\n  string serialized_value = reflection->GetString(message, value_field);\n  if (!value_message->ParseFromString(serialized_value)) {\n    GOOGLE_LOG(WARNING) << type_url << \": failed to parse contents\";\n    return false;\n  }\n  generator.Print(StrCat(\"[\", type_url, \"]\"));\n  const FieldValuePrinter* printer = FindWithDefault(\n      custom_printers_, value_field, default_field_value_printer_.get());\n  generator.Print(\n      printer->PrintMessageStart(message, -1, 0, single_line_mode_));\n  generator.Indent();\n  Print(*value_message, generator);\n  generator.Outdent();\n  generator.Print(printer->PrintMessageEnd(message, -1, 0, single_line_mode_));\n  return true;\n}\n\nvoid TextFormat::Printer::Print(const Message& message,\n                                TextGenerator& generator) const {\n  const Descriptor* descriptor = message.GetDescriptor();\n  const Reflection* reflection = message.GetReflection();\n  if (descriptor->full_name() == internal::kAnyFullTypeName && expand_any_ &&\n      PrintAny(message, generator)) {\n    return;\n  }\n  vector<const FieldDescriptor*> fields;\n  reflection->ListFields(message, &fields);\n  if (print_message_fields_in_index_order_) {\n    std::sort(fields.begin(), fields.end(), FieldIndexSorter());\n  }\n  for (int i = 0; i < fields.size(); i++) {\n    PrintField(message, reflection, fields[i], generator);\n  }\n  if (!hide_unknown_fields_) {\n    PrintUnknownFields(reflection->GetUnknownFields(message), generator);\n  }\n}\n\nvoid TextFormat::Printer::PrintFieldValueToString(\n    const Message& message,\n    const FieldDescriptor* field,\n    int index,\n    string* output) const {\n\n  GOOGLE_DCHECK(output) << \"output specified is NULL\";\n\n  output->clear();\n  io::StringOutputStream output_stream(output);\n  TextGenerator generator(&output_stream, initial_indent_level_);\n\n  PrintFieldValue(message, message.GetReflection(), field, index, generator);\n}\n\nclass MapEntryMessageComparator {\n public:\n  explicit MapEntryMessageComparator(const Descriptor* descriptor)\n      : field_(descriptor->field(0)) {}\n\n  bool operator()(const Message* a, const Message* b) {\n    const Reflection* reflection = a->GetReflection();\n    switch (field_->cpp_type()) {\n      case FieldDescriptor::CPPTYPE_BOOL: {\n          bool first = reflection->GetBool(*a, field_);\n          bool second = reflection->GetBool(*b, field_);\n          return first < second;\n      }\n      case FieldDescriptor::CPPTYPE_INT32: {\n          int32 first = reflection->GetInt32(*a, field_);\n          int32 second = reflection->GetInt32(*b, field_);\n          return first < second;\n      }\n      case FieldDescriptor::CPPTYPE_INT64: {\n          int64 first = reflection->GetInt64(*a, field_);\n          int64 second = reflection->GetInt64(*b, field_);\n          return first < second;\n      }\n      case FieldDescriptor::CPPTYPE_UINT32: {\n          uint32 first = reflection->GetUInt32(*a, field_);\n          uint32 second = reflection->GetUInt32(*b, field_);\n          return first < second;\n      }\n      case FieldDescriptor::CPPTYPE_UINT64: {\n          uint64 first = reflection->GetUInt64(*a, field_);\n          uint64 second = reflection->GetUInt64(*b, field_);\n          return first < second;\n      }\n      case FieldDescriptor::CPPTYPE_STRING: {\n          string first = reflection->GetString(*a, field_);\n          string second = reflection->GetString(*b, field_);\n          return first < second;\n      }\n      default:\n        GOOGLE_LOG(DFATAL) << \"Invalid key for map field.\";\n        return true;\n    }\n  }\n\n private:\n  const FieldDescriptor* field_;\n};\n\nvoid TextFormat::Printer::PrintField(const Message& message,\n                                     const Reflection* reflection,\n                                     const FieldDescriptor* field,\n                                     TextGenerator& generator) const {\n  if (use_short_repeated_primitives_ &&\n      field->is_repeated() &&\n      field->cpp_type() != FieldDescriptor::CPPTYPE_STRING &&\n      field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) {\n    PrintShortRepeatedField(message, reflection, field, generator);\n    return;\n  }\n\n  int count = 0;\n\n  if (field->is_repeated()) {\n    count = reflection->FieldSize(message, field);\n  } else if (reflection->HasField(message, field)) {\n    count = 1;\n  }\n\n  std::vector<const Message*> sorted_map_field;\n  if (field->is_map()) {\n    const RepeatedPtrField<Message>& map_field =\n        reflection->GetRepeatedPtrField<Message>(message, field);\n    for (RepeatedPtrField<Message>::const_pointer_iterator it =\n             map_field.pointer_begin();\n         it != map_field.pointer_end(); ++it) {\n      sorted_map_field.push_back(*it);\n    }\n\n    MapEntryMessageComparator comparator(field->message_type());\n    std::stable_sort(sorted_map_field.begin(), sorted_map_field.end(),\n                     comparator);\n  }\n\n  for (int j = 0; j < count; ++j) {\n    const int field_index = field->is_repeated() ? j : -1;\n\n    PrintFieldName(message, reflection, field, generator);\n\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n      const FieldValuePrinter* printer = FindWithDefault(\n          custom_printers_, field, default_field_value_printer_.get());\n      const Message& sub_message =\n          field->is_repeated()\n              ? (field->is_map()\n                     ? *sorted_map_field[j]\n                     : reflection->GetRepeatedMessage(message, field, j))\n              : reflection->GetMessage(message, field);\n      generator.Print(\n          printer->PrintMessageStart(\n              sub_message, field_index, count, single_line_mode_));\n      generator.Indent();\n      Print(sub_message, generator);\n      generator.Outdent();\n      generator.Print(\n          printer->PrintMessageEnd(\n              sub_message, field_index, count, single_line_mode_));\n    } else {\n      generator.Print(\": \");\n      // Write the field value.\n      PrintFieldValue(message, reflection, field, field_index, generator);\n      if (single_line_mode_) {\n        generator.Print(\" \");\n      } else {\n        generator.Print(\"\\n\");\n      }\n    }\n  }\n}\n\nvoid TextFormat::Printer::PrintShortRepeatedField(\n    const Message& message,\n    const Reflection* reflection,\n    const FieldDescriptor* field,\n    TextGenerator& generator) const {\n  // Print primitive repeated field in short form.\n  PrintFieldName(message, reflection, field, generator);\n\n  int size = reflection->FieldSize(message, field);\n  generator.Print(\": [\");\n  for (int i = 0; i < size; i++) {\n    if (i > 0) generator.Print(\", \");\n    PrintFieldValue(message, reflection, field, i, generator);\n  }\n  if (single_line_mode_) {\n    generator.Print(\"] \");\n  } else {\n    generator.Print(\"]\\n\");\n  }\n}\n\nvoid TextFormat::Printer::PrintFieldName(const Message& message,\n                                         const Reflection* reflection,\n                                         const FieldDescriptor* field,\n                                         TextGenerator& generator) const {\n  // if use_field_number_ is true, prints field number instead\n  // of field name.\n  if (use_field_number_) {\n    generator.Print(SimpleItoa(field->number()));\n    return;\n  }\n\n  const FieldValuePrinter* printer = FindWithDefault(\n      custom_printers_, field, default_field_value_printer_.get());\n  generator.Print(printer->PrintFieldName(message, reflection, field));\n}\n\nvoid TextFormat::Printer::PrintFieldValue(\n    const Message& message,\n    const Reflection* reflection,\n    const FieldDescriptor* field,\n    int index,\n    TextGenerator& generator) const {\n  GOOGLE_DCHECK(field->is_repeated() || (index == -1))\n      << \"Index must be -1 for non-repeated fields\";\n\n  const FieldValuePrinter* printer\n      = FindWithDefault(custom_printers_, field,\n                        default_field_value_printer_.get());\n\n  switch (field->cpp_type()) {\n#define OUTPUT_FIELD(CPPTYPE, METHOD)                                   \\\n    case FieldDescriptor::CPPTYPE_##CPPTYPE:                            \\\n      generator.Print(printer->Print##METHOD(field->is_repeated()       \\\n               ? reflection->GetRepeated##METHOD(message, field, index) \\\n               : reflection->Get##METHOD(message, field)));             \\\n        break\n\n    OUTPUT_FIELD( INT32,  Int32);\n    OUTPUT_FIELD( INT64,  Int64);\n    OUTPUT_FIELD(UINT32, UInt32);\n    OUTPUT_FIELD(UINT64, UInt64);\n    OUTPUT_FIELD( FLOAT,  Float);\n    OUTPUT_FIELD(DOUBLE, Double);\n    OUTPUT_FIELD(  BOOL,   Bool);\n#undef OUTPUT_FIELD\n\n    case FieldDescriptor::CPPTYPE_STRING: {\n      string scratch;\n      const string& value = field->is_repeated()\n          ? reflection->GetRepeatedStringReference(\n              message, field, index, &scratch)\n          : reflection->GetStringReference(message, field, &scratch);\n      const string* value_to_print = &value;\n      string truncated_value;\n      if (truncate_string_field_longer_than_ > 0 &&\n          truncate_string_field_longer_than_ < value.size()) {\n        truncated_value = value.substr(0, truncate_string_field_longer_than_) +\n                          \"...<truncated>...\";\n        value_to_print = &truncated_value;\n      }\n      if (field->type() == FieldDescriptor::TYPE_STRING) {\n        generator.Print(printer->PrintString(*value_to_print));\n      } else {\n        GOOGLE_DCHECK_EQ(field->type(), FieldDescriptor::TYPE_BYTES);\n        generator.Print(printer->PrintBytes(*value_to_print));\n      }\n      break;\n    }\n\n    case FieldDescriptor::CPPTYPE_ENUM: {\n      int enum_value = field->is_repeated()\n          ? reflection->GetRepeatedEnumValue(message, field, index)\n          : reflection->GetEnumValue(message, field);\n      const EnumValueDescriptor* enum_desc =\n          field->enum_type()->FindValueByNumber(enum_value);\n      if (enum_desc != NULL) {\n        generator.Print(printer->PrintEnum(enum_value, enum_desc->name()));\n      } else {\n        // Ordinarily, enum_desc should not be null, because proto2 has the\n        // invariant that set enum field values must be in-range, but with the\n        // new integer-based API for enums (or the RepeatedField<int> loophole),\n        // it is possible for the user to force an unknown integer value.  So we\n        // simply use the integer value itself as the enum value name in this\n        // case.\n        generator.Print(printer->PrintEnum(enum_value,\n                                           StringPrintf(\"%d\", enum_value)));\n      }\n      break;\n    }\n\n    case FieldDescriptor::CPPTYPE_MESSAGE:\n      Print(field->is_repeated()\n            ? reflection->GetRepeatedMessage(message, field, index)\n            : reflection->GetMessage(message, field),\n            generator);\n      break;\n  }\n}\n\n/* static */ bool TextFormat::Print(const Message& message,\n                                    io::ZeroCopyOutputStream* output) {\n  return Printer().Print(message, output);\n}\n\n/* static */ bool TextFormat::PrintUnknownFields(\n    const UnknownFieldSet& unknown_fields,\n    io::ZeroCopyOutputStream* output) {\n  return Printer().PrintUnknownFields(unknown_fields, output);\n}\n\n/* static */ bool TextFormat::PrintToString(\n    const Message& message, string* output) {\n  return Printer().PrintToString(message, output);\n}\n\n/* static */ bool TextFormat::PrintUnknownFieldsToString(\n    const UnknownFieldSet& unknown_fields, string* output) {\n  return Printer().PrintUnknownFieldsToString(unknown_fields, output);\n}\n\n/* static */ void TextFormat::PrintFieldValueToString(\n    const Message& message,\n    const FieldDescriptor* field,\n    int index,\n    string* output) {\n  return Printer().PrintFieldValueToString(message, field, index, output);\n}\n\n/* static */ bool TextFormat::ParseFieldValueFromString(\n    const string& input,\n    const FieldDescriptor* field,\n    Message* message) {\n  return Parser().ParseFieldValueFromString(input, field, message);\n}\n\n// Prints an integer as hex with a fixed number of digits dependent on the\n// integer type.\ntemplate<typename IntType>\nstatic string PaddedHex(IntType value) {\n  string result;\n  result.reserve(sizeof(value) * 2);\n  for (int i = sizeof(value) * 2 - 1; i >= 0; i--) {\n    result.push_back(int_to_hex_digit(value >> (i*4) & 0x0F));\n  }\n  return result;\n}\n\nvoid TextFormat::Printer::PrintUnknownFields(\n    const UnknownFieldSet& unknown_fields, TextGenerator& generator) const {\n  for (int i = 0; i < unknown_fields.field_count(); i++) {\n    const UnknownField& field = unknown_fields.field(i);\n    string field_number = SimpleItoa(field.number());\n\n    switch (field.type()) {\n      case UnknownField::TYPE_VARINT:\n        generator.Print(field_number);\n        generator.Print(\": \");\n        generator.Print(SimpleItoa(field.varint()));\n        if (single_line_mode_) {\n          generator.Print(\" \");\n        } else {\n          generator.Print(\"\\n\");\n        }\n        break;\n      case UnknownField::TYPE_FIXED32: {\n        generator.Print(field_number);\n        generator.Print(\": 0x\");\n        generator.Print(\n            StrCat(strings::Hex(field.fixed32(), strings::ZERO_PAD_8)));\n        if (single_line_mode_) {\n          generator.Print(\" \");\n        } else {\n          generator.Print(\"\\n\");\n        }\n        break;\n      }\n      case UnknownField::TYPE_FIXED64: {\n        generator.Print(field_number);\n        generator.Print(\": 0x\");\n        generator.Print(\n            StrCat(strings::Hex(field.fixed64(), strings::ZERO_PAD_16)));\n        if (single_line_mode_) {\n          generator.Print(\" \");\n        } else {\n          generator.Print(\"\\n\");\n        }\n        break;\n      }\n      case UnknownField::TYPE_LENGTH_DELIMITED: {\n        generator.Print(field_number);\n        const string& value = field.length_delimited();\n        UnknownFieldSet embedded_unknown_fields;\n        if (!value.empty() && embedded_unknown_fields.ParseFromString(value)) {\n          // This field is parseable as a Message.\n          // So it is probably an embedded message.\n          if (single_line_mode_) {\n            generator.Print(\" { \");\n          } else {\n            generator.Print(\" {\\n\");\n            generator.Indent();\n          }\n          PrintUnknownFields(embedded_unknown_fields, generator);\n          if (single_line_mode_) {\n            generator.Print(\"} \");\n          } else {\n            generator.Outdent();\n            generator.Print(\"}\\n\");\n          }\n        } else {\n          // This field is not parseable as a Message.\n          // So it is probably just a plain string.\n          string printed(\": \\\"\");\n          CEscapeAndAppend(value, &printed);\n          printed.append(single_line_mode_ ? \"\\\" \" : \"\\\"\\n\");\n          generator.Print(printed);\n        }\n        break;\n      }\n      case UnknownField::TYPE_GROUP:\n        generator.Print(field_number);\n        if (single_line_mode_) {\n          generator.Print(\" { \");\n        } else {\n          generator.Print(\" {\\n\");\n          generator.Indent();\n        }\n        PrintUnknownFields(field.group(), generator);\n        if (single_line_mode_) {\n          generator.Print(\"} \");\n        } else {\n          generator.Outdent();\n          generator.Print(\"}\\n\");\n        }\n        break;\n    }\n  }\n}\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/text_format.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: jschorr@google.com (Joseph Schorr)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Utilities for printing and parsing protocol messages in a human-readable,\n// text-based format.\n\n#ifndef GOOGLE_PROTOBUF_TEXT_FORMAT_H__\n#define GOOGLE_PROTOBUF_TEXT_FORMAT_H__\n\n#include <map>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <string>\n#include <vector>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/message.h>\n\nnamespace google {\nnamespace protobuf {\n\nnamespace io {\n  class ErrorCollector;      // tokenizer.h\n}\n\n// This class implements protocol buffer text format.  Printing and parsing\n// protocol messages in text format is useful for debugging and human editing\n// of messages.\n//\n// This class is really a namespace that contains only static methods.\nclass LIBPROTOBUF_EXPORT TextFormat {\n public:\n  // Outputs a textual representation of the given message to the given\n  // output stream.\n  static bool Print(const Message& message, io::ZeroCopyOutputStream* output);\n\n  // Print the fields in an UnknownFieldSet.  They are printed by tag number\n  // only.  Embedded messages are heuristically identified by attempting to\n  // parse them.\n  static bool PrintUnknownFields(const UnknownFieldSet& unknown_fields,\n                                 io::ZeroCopyOutputStream* output);\n\n  // Like Print(), but outputs directly to a string.\n  static bool PrintToString(const Message& message, string* output);\n\n  // Like PrintUnknownFields(), but outputs directly to a string.\n  static bool PrintUnknownFieldsToString(const UnknownFieldSet& unknown_fields,\n                                         string* output);\n\n  // Outputs a textual representation of the value of the field supplied on\n  // the message supplied. For non-repeated fields, an index of -1 must\n  // be supplied. Note that this method will print the default value for a\n  // field if it is not set.\n  static void PrintFieldValueToString(const Message& message,\n                                      const FieldDescriptor* field,\n                                      int index,\n                                      string* output);\n\n  // The default printer that converts scalar values from fields into\n  // their string representation.\n  // You can derive from this FieldValuePrinter if you want to have\n  // fields to be printed in a different way and register it at the\n  // Printer.\n  class LIBPROTOBUF_EXPORT FieldValuePrinter {\n   public:\n    FieldValuePrinter();\n    virtual ~FieldValuePrinter();\n    virtual string PrintBool(bool val) const;\n    virtual string PrintInt32(int32 val) const;\n    virtual string PrintUInt32(uint32 val) const;\n    virtual string PrintInt64(int64 val) const;\n    virtual string PrintUInt64(uint64 val) const;\n    virtual string PrintFloat(float val) const;\n    virtual string PrintDouble(double val) const;\n    virtual string PrintString(const string& val) const;\n    virtual string PrintBytes(const string& val) const;\n    virtual string PrintEnum(int32 val, const string& name) const;\n    virtual string PrintFieldName(const Message& message,\n                                  const Reflection* reflection,\n                                  const FieldDescriptor* field) const;\n    virtual string PrintMessageStart(const Message& message,\n                                     int field_index,\n                                     int field_count,\n                                     bool single_line_mode) const;\n    virtual string PrintMessageEnd(const Message& message,\n                                   int field_index,\n                                   int field_count,\n                                   bool single_line_mode) const;\n\n   private:\n    GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldValuePrinter);\n  };\n\n  // Class for those users which require more fine-grained control over how\n  // a protobuffer message is printed out.\n  class LIBPROTOBUF_EXPORT Printer {\n   public:\n    Printer();\n    ~Printer();\n\n    // Like TextFormat::Print\n    bool Print(const Message& message, io::ZeroCopyOutputStream* output) const;\n    // Like TextFormat::PrintUnknownFields\n    bool PrintUnknownFields(const UnknownFieldSet& unknown_fields,\n                            io::ZeroCopyOutputStream* output) const;\n    // Like TextFormat::PrintToString\n    bool PrintToString(const Message& message, string* output) const;\n    // Like TextFormat::PrintUnknownFieldsToString\n    bool PrintUnknownFieldsToString(const UnknownFieldSet& unknown_fields,\n                                    string* output) const;\n    // Like TextFormat::PrintFieldValueToString\n    void PrintFieldValueToString(const Message& message,\n                                 const FieldDescriptor* field,\n                                 int index,\n                                 string* output) const;\n\n    // Adjust the initial indent level of all output.  Each indent level is\n    // equal to two spaces.\n    void SetInitialIndentLevel(int indent_level) {\n      initial_indent_level_ = indent_level;\n    }\n\n    // If printing in single line mode, then the entire message will be output\n    // on a single line with no line breaks.\n    void SetSingleLineMode(bool single_line_mode) {\n      single_line_mode_ = single_line_mode;\n    }\n\n    bool IsInSingleLineMode() {\n      return single_line_mode_;\n    }\n\n    // If use_field_number is true, uses field number instead of field name.\n    void SetUseFieldNumber(bool use_field_number) {\n      use_field_number_ = use_field_number;\n    }\n\n    // Set true to print repeated primitives in a format like:\n    //   field_name: [1, 2, 3, 4]\n    // instead of printing each value on its own line.  Short format applies\n    // only to primitive values -- i.e. everything except strings and\n    // sub-messages/groups.\n    void SetUseShortRepeatedPrimitives(bool use_short_repeated_primitives) {\n      use_short_repeated_primitives_ = use_short_repeated_primitives;\n    }\n\n    // Set true to output UTF-8 instead of ASCII.  The only difference\n    // is that bytes >= 0x80 in string fields will not be escaped,\n    // because they are assumed to be part of UTF-8 multi-byte\n    // sequences. This will change the default FieldValuePrinter.\n    void SetUseUtf8StringEscaping(bool as_utf8);\n\n    // Set the default FieldValuePrinter that is used for all fields that\n    // don't have a field-specific printer registered.\n    // Takes ownership of the printer.\n    void SetDefaultFieldValuePrinter(const FieldValuePrinter* printer);\n\n    // Sets whether we want to hide unknown fields or not.\n    // Usually unknown fields are printed in a generic way that includes the\n    // tag number of the field instead of field name. However, sometimes it\n    // is useful to be able to print the message without unknown fields (e.g.\n    // for the python protobuf version to maintain consistency between its pure\n    // python and c++ implementations).\n    void SetHideUnknownFields(bool hide) {\n      hide_unknown_fields_ = hide;\n    }\n\n    // If print_message_fields_in_index_order is true, print fields of a proto\n    // message using the order defined in source code instead of the field\n    // number. By default, use the field number order.\n    void SetPrintMessageFieldsInIndexOrder(\n        bool print_message_fields_in_index_order) {\n      print_message_fields_in_index_order_ =\n          print_message_fields_in_index_order;\n    }\n\n    // If expand==true, expand google.protobuf.Any payloads. The output\n    // will be of form\n    //    [type_url] { <value_printed_in_text> }\n    //\n    // If expand==false, print Any using the default printer. The output will\n    // look like\n    //    type_url: \"<type_url>\"  value: \"serialized_content\"\n    void SetExpandAny(bool expand) {\n      expand_any_ = expand;\n    }\n\n    // If non-zero, we truncate all string fields that are  longer than this\n    // threshold.  This is useful when the proto message has very long strings,\n    // e.g., dump of encoded image file.\n    //\n    // NOTE(hfgong):  Setting a non-zero value breaks round-trip safe\n    // property of TextFormat::Printer.  That is, from the printed message, we\n    // cannot fully recover the original string field any more.\n    void SetTruncateStringFieldLongerThan(\n        const int64 truncate_string_field_longer_than) {\n      truncate_string_field_longer_than_ = truncate_string_field_longer_than;\n    }\n\n    // Register a custom field-specific FieldValuePrinter for fields\n    // with a particular FieldDescriptor.\n    // Returns \"true\" if the registration succeeded, or \"false\", if there is\n    // already a printer for that FieldDescriptor.\n    // Takes ownership of the printer on successful registration.\n    bool RegisterFieldValuePrinter(const FieldDescriptor* field,\n                                   const FieldValuePrinter* printer);\n\n   private:\n    // Forward declaration of an internal class used to print the text\n    // output to the OutputStream (see text_format.cc for implementation).\n    class TextGenerator;\n\n    // Internal Print method, used for writing to the OutputStream via\n    // the TextGenerator class.\n    void Print(const Message& message,\n               TextGenerator& generator) const;\n\n    // Print a single field.\n    void PrintField(const Message& message,\n                    const Reflection* reflection,\n                    const FieldDescriptor* field,\n                    TextGenerator& generator) const;\n\n    // Print a repeated primitive field in short form.\n    void PrintShortRepeatedField(const Message& message,\n                                 const Reflection* reflection,\n                                 const FieldDescriptor* field,\n                                 TextGenerator& generator) const;\n\n    // Print the name of a field -- i.e. everything that comes before the\n    // ':' for a single name/value pair.\n    void PrintFieldName(const Message& message,\n                        const Reflection* reflection,\n                        const FieldDescriptor* field,\n                        TextGenerator& generator) const;\n\n    // Outputs a textual representation of the value of the field supplied on\n    // the message supplied or the default value if not set.\n    void PrintFieldValue(const Message& message,\n                         const Reflection* reflection,\n                         const FieldDescriptor* field,\n                         int index,\n                         TextGenerator& generator) const;\n\n    // Print the fields in an UnknownFieldSet.  They are printed by tag number\n    // only.  Embedded messages are heuristically identified by attempting to\n    // parse them.\n    void PrintUnknownFields(const UnknownFieldSet& unknown_fields,\n                            TextGenerator& generator) const;\n\n    bool PrintAny(const Message& message, TextGenerator& generator) const;\n\n    int initial_indent_level_;\n\n    bool single_line_mode_;\n\n    bool use_field_number_;\n\n    bool use_short_repeated_primitives_;\n\n    bool hide_unknown_fields_;\n\n    bool print_message_fields_in_index_order_;\n\n    bool expand_any_;\n\n    int64 truncate_string_field_longer_than_;\n\n    google::protobuf::scoped_ptr<const FieldValuePrinter> default_field_value_printer_;\n    typedef map<const FieldDescriptor*,\n                const FieldValuePrinter*> CustomPrinterMap;\n    CustomPrinterMap custom_printers_;\n  };\n\n  // Parses a text-format protocol message from the given input stream to\n  // the given message object. This function parses the human-readable format\n  // written by Print(). Returns true on success. The message is cleared first,\n  // even if the function fails -- See Merge() to avoid this behavior.\n  //\n  // Example input: \"user {\\n id: 123 extra { gender: MALE language: 'en' }\\n}\"\n  //\n  // One use for this function is parsing handwritten strings in test code.\n  // Another use is to parse the output from google::protobuf::Message::DebugString()\n  // (or ShortDebugString()), because these functions output using\n  // google::protobuf::TextFormat::Print().\n  //\n  // If you would like to read a protocol buffer serialized in the\n  // (non-human-readable) binary wire format, see\n  // google::protobuf::MessageLite::ParseFromString().\n  static bool Parse(io::ZeroCopyInputStream* input, Message* output);\n  // Like Parse(), but reads directly from a string.\n  static bool ParseFromString(const string& input, Message* output);\n\n  // Like Parse(), but the data is merged into the given message, as if\n  // using Message::MergeFrom().\n  static bool Merge(io::ZeroCopyInputStream* input, Message* output);\n  // Like Merge(), but reads directly from a string.\n  static bool MergeFromString(const string& input, Message* output);\n\n  // Parse the given text as a single field value and store it into the\n  // given field of the given message. If the field is a repeated field,\n  // the new value will be added to the end\n  static bool ParseFieldValueFromString(const string& input,\n                                        const FieldDescriptor* field,\n                                        Message* message);\n\n  // Interface that TextFormat::Parser can use to find extensions.\n  // This class may be extended in the future to find more information\n  // like fields, etc.\n  class LIBPROTOBUF_EXPORT Finder {\n   public:\n    virtual ~Finder();\n\n    // Try to find an extension of *message by fully-qualified field\n    // name.  Returns NULL if no extension is known for this name or number.\n    virtual const FieldDescriptor* FindExtension(\n        Message* message,\n        const string& name) const = 0;\n  };\n\n  // A location in the parsed text.\n  struct ParseLocation {\n    int line;\n    int column;\n\n    ParseLocation() : line(-1), column(-1) {}\n    ParseLocation(int line_param, int column_param)\n        : line(line_param), column(column_param) {}\n  };\n\n  // Data structure which is populated with the locations of each field\n  // value parsed from the text.\n  class LIBPROTOBUF_EXPORT ParseInfoTree {\n   public:\n    ParseInfoTree();\n    ~ParseInfoTree();\n\n    // Returns the parse location for index-th value of the field in the parsed\n    // text. If none exists, returns a location with line = -1. Index should be\n    // -1 for not-repeated fields.\n    ParseLocation GetLocation(const FieldDescriptor* field, int index) const;\n\n    // Returns the parse info tree for the given field, which must be a message\n    // type. The nested information tree is owned by the root tree and will be\n    // deleted when it is deleted.\n    ParseInfoTree* GetTreeForNested(const FieldDescriptor* field,\n                                    int index) const;\n\n   private:\n    // Allow the text format parser to record information into the tree.\n    friend class TextFormat;\n\n    // Records the starting location of a single value for a field.\n    void RecordLocation(const FieldDescriptor* field, ParseLocation location);\n\n    // Create and records a nested tree for a nested message field.\n    ParseInfoTree* CreateNested(const FieldDescriptor* field);\n\n    // Defines the map from the index-th field descriptor to its parse location.\n    typedef map<const FieldDescriptor*, vector<ParseLocation> > LocationMap;\n\n    // Defines the map from the index-th field descriptor to the nested parse\n    // info tree.\n    typedef map<const FieldDescriptor*, vector<ParseInfoTree*> > NestedMap;\n\n    LocationMap locations_;\n    NestedMap nested_;\n\n    GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ParseInfoTree);\n  };\n\n  // For more control over parsing, use this class.\n  class LIBPROTOBUF_EXPORT Parser {\n   public:\n    Parser();\n    ~Parser();\n\n    // Like TextFormat::Parse().\n    bool Parse(io::ZeroCopyInputStream* input, Message* output);\n    // Like TextFormat::ParseFromString().\n    bool ParseFromString(const string& input, Message* output);\n    // Like TextFormat::Merge().\n    bool Merge(io::ZeroCopyInputStream* input, Message* output);\n    // Like TextFormat::MergeFromString().\n    bool MergeFromString(const string& input, Message* output);\n\n    // Set where to report parse errors.  If NULL (the default), errors will\n    // be printed to stderr.\n    void RecordErrorsTo(io::ErrorCollector* error_collector) {\n      error_collector_ = error_collector;\n    }\n\n    // Set how parser finds extensions.  If NULL (the default), the\n    // parser will use the standard Reflection object associated with\n    // the message being parsed.\n    void SetFinder(Finder* finder) {\n      finder_ = finder;\n    }\n\n    // Sets where location information about the parse will be written. If NULL\n    // (the default), then no location will be written.\n    void WriteLocationsTo(ParseInfoTree* tree) {\n      parse_info_tree_ = tree;\n    }\n\n    // Normally parsing fails if, after parsing, output->IsInitialized()\n    // returns false.  Call AllowPartialMessage(true) to skip this check.\n    void AllowPartialMessage(bool allow) {\n      allow_partial_ = allow;\n    }\n\n    // Allow field names to be matched case-insensitively.\n    // This is not advisable if there are fields that only differ in case, or\n    // if you want to enforce writing in the canonical form.\n    // This is 'false' by default.\n    void AllowCaseInsensitiveField(bool allow) {\n      allow_case_insensitive_field_ = allow;\n    }\n\n    // Like TextFormat::ParseFieldValueFromString\n    bool ParseFieldValueFromString(const string& input,\n                                   const FieldDescriptor* field,\n                                   Message* output);\n\n\n    void AllowFieldNumber(bool allow) {\n      allow_field_number_ = allow;\n    }\n\n   private:\n    // Forward declaration of an internal class used to parse text\n    // representations (see text_format.cc for implementation).\n    class ParserImpl;\n\n    // Like TextFormat::Merge().  The provided implementation is used\n    // to do the parsing.\n    bool MergeUsingImpl(io::ZeroCopyInputStream* input,\n                        Message* output,\n                        ParserImpl* parser_impl);\n\n    io::ErrorCollector* error_collector_;\n    Finder* finder_;\n    ParseInfoTree* parse_info_tree_;\n    bool allow_partial_;\n    bool allow_case_insensitive_field_;\n    bool allow_unknown_field_;\n    bool allow_unknown_enum_;\n    bool allow_field_number_;\n    bool allow_relaxed_whitespace_;\n    bool allow_singular_overwrites_;\n  };\n\n\n private:\n  // Hack: ParseInfoTree declares TextFormat as a friend which should extend\n  // the friendship to TextFormat::Parser::ParserImpl, but unfortunately some\n  // old compilers (e.g. GCC 3.4.6) don't implement this correctly. We provide\n  // helpers for ParserImpl to call methods of ParseInfoTree.\n  static inline void RecordLocation(ParseInfoTree* info_tree,\n                                    const FieldDescriptor* field,\n                                    ParseLocation location);\n  static inline ParseInfoTree* CreateNested(ParseInfoTree* info_tree,\n                                            const FieldDescriptor* field);\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TextFormat);\n};\n\ninline void TextFormat::RecordLocation(ParseInfoTree* info_tree,\n                                       const FieldDescriptor* field,\n                                       ParseLocation location) {\n  info_tree->RecordLocation(field, location);\n}\n\n\ninline TextFormat::ParseInfoTree* TextFormat::CreateNested(\n    ParseInfoTree* info_tree, const FieldDescriptor* field) {\n  return info_tree->CreateNested(field);\n}\n\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_TEXT_FORMAT_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/text_format_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: jschorr@google.com (Joseph Schorr)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/text_format.h>\n\n#include <math.h>\n#include <stdlib.h>\n#include <limits>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/testing/file.h>\n#include <google/protobuf/test_util.h>\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/unittest_mset.pb.h>\n#include <google/protobuf/unittest_mset_wire_format.pb.h>\n#include <google/protobuf/io/tokenizer.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/stubs/mathlimits.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/substitute.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\n\nnamespace google {\nnamespace protobuf {\n\n// Can't use an anonymous namespace here due to brokenness of Tru64 compiler.\nnamespace text_format_unittest {\n\n// A basic string with different escapable characters for testing.\nconst string kEscapeTestString =\n  \"\\\"A string with ' characters \\n and \\r newlines and \\t tabs and \\001 \"\n  \"slashes \\\\ and  multiple   spaces\";\n\n// A representation of the above string with all the characters escaped.\nconst string kEscapeTestStringEscaped =\n  \"\\\"\\\\\\\"A string with \\\\' characters \\\\n and \\\\r newlines \"\n  \"and \\\\t tabs and \\\\001 slashes \\\\\\\\ and  multiple   spaces\\\"\";\n\nclass TextFormatTest : public testing::Test {\n public:\n  static void SetUpTestCase() {\n    GOOGLE_CHECK_OK(File::GetContents(\n        TestSourceDir() +\n            \"/google/protobuf/\"\n            \"testdata/text_format_unittest_data_oneof_implemented.txt\",\n        &static_proto_debug_string_, true));\n  }\n\n  TextFormatTest() : proto_debug_string_(static_proto_debug_string_) {}\n\n protected:\n  // Debug string read from text_format_unittest_data.txt.\n  const string proto_debug_string_;\n  unittest::TestAllTypes proto_;\n\n private:\n  static string static_proto_debug_string_;\n};\nstring TextFormatTest::static_proto_debug_string_;\n\nclass TextFormatExtensionsTest : public testing::Test {\n public:\n  static void SetUpTestCase() {\n    GOOGLE_CHECK_OK(File::GetContents(TestSourceDir() +\n                                   \"/google/protobuf/testdata/\"\n                                   \"text_format_unittest_extensions_data.txt\",\n                               &static_proto_debug_string_, true));\n  }\n\n  TextFormatExtensionsTest()\n      : proto_debug_string_(static_proto_debug_string_) {}\n\n protected:\n  // Debug string read from text_format_unittest_data.txt.\n  const string proto_debug_string_;\n  unittest::TestAllExtensions proto_;\n\n private:\n  static string static_proto_debug_string_;\n};\nstring TextFormatExtensionsTest::static_proto_debug_string_;\n\n\nTEST_F(TextFormatTest, Basic) {\n  TestUtil::SetAllFields(&proto_);\n  EXPECT_EQ(proto_debug_string_, proto_.DebugString());\n}\n\nTEST_F(TextFormatExtensionsTest, Extensions) {\n  TestUtil::SetAllExtensions(&proto_);\n  EXPECT_EQ(proto_debug_string_, proto_.DebugString());\n}\n\nTEST_F(TextFormatTest, ShortDebugString) {\n  proto_.set_optional_int32(1);\n  proto_.set_optional_string(\"hello\");\n  proto_.mutable_optional_nested_message()->set_bb(2);\n  proto_.mutable_optional_foreign_message();\n\n  EXPECT_EQ(\"optional_int32: 1 optional_string: \\\"hello\\\" \"\n            \"optional_nested_message { bb: 2 } \"\n            \"optional_foreign_message { }\",\n            proto_.ShortDebugString());\n}\n\nTEST_F(TextFormatTest, ShortPrimitiveRepeateds) {\n  proto_.set_optional_int32(123);\n  proto_.add_repeated_int32(456);\n  proto_.add_repeated_int32(789);\n  proto_.add_repeated_string(\"foo\");\n  proto_.add_repeated_string(\"bar\");\n  proto_.add_repeated_nested_message()->set_bb(2);\n  proto_.add_repeated_nested_message()->set_bb(3);\n  proto_.add_repeated_nested_enum(unittest::TestAllTypes::FOO);\n  proto_.add_repeated_nested_enum(unittest::TestAllTypes::BAR);\n\n  TextFormat::Printer printer;\n  printer.SetUseShortRepeatedPrimitives(true);\n  string text;\n  printer.PrintToString(proto_, &text);\n\n  EXPECT_EQ(\"optional_int32: 123\\n\"\n            \"repeated_int32: [456, 789]\\n\"\n            \"repeated_string: \\\"foo\\\"\\n\"\n            \"repeated_string: \\\"bar\\\"\\n\"\n            \"repeated_nested_message {\\n  bb: 2\\n}\\n\"\n            \"repeated_nested_message {\\n  bb: 3\\n}\\n\"\n            \"repeated_nested_enum: [FOO, BAR]\\n\",\n            text);\n\n  // Try in single-line mode.\n  printer.SetSingleLineMode(true);\n  printer.PrintToString(proto_, &text);\n\n  EXPECT_EQ(\"optional_int32: 123 \"\n            \"repeated_int32: [456, 789] \"\n            \"repeated_string: \\\"foo\\\" \"\n            \"repeated_string: \\\"bar\\\" \"\n            \"repeated_nested_message { bb: 2 } \"\n            \"repeated_nested_message { bb: 3 } \"\n            \"repeated_nested_enum: [FOO, BAR] \",\n            text);\n}\n\n\nTEST_F(TextFormatTest, StringEscape) {\n  // Set the string value to test.\n  proto_.set_optional_string(kEscapeTestString);\n\n  // Get the DebugString from the proto.\n  string debug_string = proto_.DebugString();\n  string utf8_debug_string = proto_.Utf8DebugString();\n\n  // Hardcode a correct value to test against.\n  string correct_string = \"optional_string: \"\n      + kEscapeTestStringEscaped\n       + \"\\n\";\n\n  // Compare.\n  EXPECT_EQ(correct_string, debug_string);\n  // UTF-8 string is the same as non-UTF-8 because\n  // the protocol buffer contains no UTF-8 text.\n  EXPECT_EQ(correct_string, utf8_debug_string);\n\n  string expected_short_debug_string = \"optional_string: \"\n      + kEscapeTestStringEscaped;\n  EXPECT_EQ(expected_short_debug_string, proto_.ShortDebugString());\n}\n\nTEST_F(TextFormatTest, Utf8DebugString) {\n  // Set the string value to test.\n  proto_.set_optional_string(\"\\350\\260\\267\\346\\255\\214\");\n  proto_.set_optional_bytes(\"\\350\\260\\267\\346\\255\\214\");\n\n  // Get the DebugString from the proto.\n  string debug_string = proto_.DebugString();\n  string utf8_debug_string = proto_.Utf8DebugString();\n\n  // Hardcode a correct value to test against.\n  string correct_utf8_string =\n      \"optional_string: \"\n      \"\\\"\\350\\260\\267\\346\\255\\214\\\"\"\n      \"\\n\"\n      \"optional_bytes: \"\n      \"\\\"\\\\350\\\\260\\\\267\\\\346\\\\255\\\\214\\\"\"\n      \"\\n\";\n  string correct_string =\n      \"optional_string: \"\n      \"\\\"\\\\350\\\\260\\\\267\\\\346\\\\255\\\\214\\\"\"\n      \"\\n\"\n      \"optional_bytes: \"\n      \"\\\"\\\\350\\\\260\\\\267\\\\346\\\\255\\\\214\\\"\"\n      \"\\n\";\n\n  // Compare.\n  EXPECT_EQ(correct_utf8_string, utf8_debug_string);\n  EXPECT_EQ(correct_string, debug_string);\n}\n\nTEST_F(TextFormatTest, PrintUnknownFields) {\n  // Test printing of unknown fields in a message.\n\n  unittest::TestEmptyMessage message;\n  UnknownFieldSet* unknown_fields = message.mutable_unknown_fields();\n\n  unknown_fields->AddVarint(5, 1);\n  unknown_fields->AddFixed32(5, 2);\n  unknown_fields->AddFixed64(5, 3);\n  unknown_fields->AddLengthDelimited(5, \"4\");\n  unknown_fields->AddGroup(5)->AddVarint(10, 5);\n\n  unknown_fields->AddVarint(8, 1);\n  unknown_fields->AddVarint(8, 2);\n  unknown_fields->AddVarint(8, 3);\n\n  EXPECT_EQ(\n    \"5: 1\\n\"\n    \"5: 0x00000002\\n\"\n    \"5: 0x0000000000000003\\n\"\n    \"5: \\\"4\\\"\\n\"\n    \"5 {\\n\"\n    \"  10: 5\\n\"\n    \"}\\n\"\n    \"8: 1\\n\"\n    \"8: 2\\n\"\n    \"8: 3\\n\",\n    message.DebugString());\n}\n\nTEST_F(TextFormatTest, PrintUnknownFieldsHidden) {\n  // Test printing of unknown fields in a message when suppressed.\n\n  unittest::OneString message;\n  message.set_data(\"data\");\n  UnknownFieldSet* unknown_fields = message.mutable_unknown_fields();\n\n  unknown_fields->AddVarint(5, 1);\n  unknown_fields->AddFixed32(5, 2);\n  unknown_fields->AddFixed64(5, 3);\n  unknown_fields->AddLengthDelimited(5, \"4\");\n  unknown_fields->AddGroup(5)->AddVarint(10, 5);\n\n  unknown_fields->AddVarint(8, 1);\n  unknown_fields->AddVarint(8, 2);\n  unknown_fields->AddVarint(8, 3);\n\n  TextFormat::Printer printer;\n  printer.SetHideUnknownFields(true);\n  string output;\n  printer.PrintToString(message, &output);\n\n  EXPECT_EQ(\"data: \\\"data\\\"\\n\", output);\n}\n\nTEST_F(TextFormatTest, PrintUnknownMessage) {\n  // Test heuristic printing of messages in an UnknownFieldSet.\n\n  protobuf_unittest::TestAllTypes message;\n\n  // Cases which should not be interpreted as sub-messages.\n\n  // 'a' is a valid FIXED64 tag, so for the string to be parseable as a message\n  // it should be followed by 8 bytes.  Since this string only has two\n  // subsequent bytes, it should be treated as a string.\n  message.add_repeated_string(\"abc\");\n\n  // 'd' happens to be a valid ENDGROUP tag.  So,\n  // UnknownFieldSet::MergeFromCodedStream() will successfully parse \"def\", but\n  // the ConsumedEntireMessage() check should fail.\n  message.add_repeated_string(\"def\");\n\n  // A zero-length string should never be interpreted as a message even though\n  // it is technically valid as one.\n  message.add_repeated_string(\"\");\n\n  // Case which should be interpreted as a sub-message.\n\n  // An actual nested message with content should always be interpreted as a\n  // nested message.\n  message.add_repeated_nested_message()->set_bb(123);\n\n  string data;\n  message.SerializeToString(&data);\n\n  string text;\n  UnknownFieldSet unknown_fields;\n  EXPECT_TRUE(unknown_fields.ParseFromString(data));\n  EXPECT_TRUE(TextFormat::PrintUnknownFieldsToString(unknown_fields, &text));\n  EXPECT_EQ(\n    \"44: \\\"abc\\\"\\n\"\n    \"44: \\\"def\\\"\\n\"\n    \"44: \\\"\\\"\\n\"\n    \"48 {\\n\"\n    \"  1: 123\\n\"\n    \"}\\n\",\n    text);\n}\n\nTEST_F(TextFormatTest, PrintMessageWithIndent) {\n  // Test adding an initial indent to printing.\n\n  protobuf_unittest::TestAllTypes message;\n\n  message.add_repeated_string(\"abc\");\n  message.add_repeated_string(\"def\");\n  message.add_repeated_nested_message()->set_bb(123);\n\n  string text;\n  TextFormat::Printer printer;\n  printer.SetInitialIndentLevel(1);\n  EXPECT_TRUE(printer.PrintToString(message, &text));\n  EXPECT_EQ(\n    \"  repeated_string: \\\"abc\\\"\\n\"\n    \"  repeated_string: \\\"def\\\"\\n\"\n    \"  repeated_nested_message {\\n\"\n    \"    bb: 123\\n\"\n    \"  }\\n\",\n    text);\n}\n\nTEST_F(TextFormatTest, PrintMessageSingleLine) {\n  // Test printing a message on a single line.\n\n  protobuf_unittest::TestAllTypes message;\n\n  message.add_repeated_string(\"abc\");\n  message.add_repeated_string(\"def\");\n  message.add_repeated_nested_message()->set_bb(123);\n\n  string text;\n  TextFormat::Printer printer;\n  printer.SetInitialIndentLevel(1);\n  printer.SetSingleLineMode(true);\n  EXPECT_TRUE(printer.PrintToString(message, &text));\n  EXPECT_EQ(\n    \"  repeated_string: \\\"abc\\\" repeated_string: \\\"def\\\" \"\n    \"repeated_nested_message { bb: 123 } \",\n    text);\n}\n\nTEST_F(TextFormatTest, PrintBufferTooSmall) {\n  // Test printing a message to a buffer that is too small.\n\n  protobuf_unittest::TestAllTypes message;\n\n  message.add_repeated_string(\"abc\");\n  message.add_repeated_string(\"def\");\n\n  char buffer[1] = \"\";\n  io::ArrayOutputStream output_stream(buffer, 1);\n  EXPECT_FALSE(TextFormat::Print(message, &output_stream));\n  EXPECT_EQ(buffer[0], 'r');\n  EXPECT_EQ(output_stream.ByteCount(), 1);\n}\n\n// A printer that appends 'u' to all unsigned int32.\nclass CustomUInt32FieldValuePrinter : public TextFormat::FieldValuePrinter {\n public:\n  virtual string PrintUInt32(uint32 val) const {\n    return StrCat(FieldValuePrinter::PrintUInt32(val), \"u\");\n  }\n};\n\nTEST_F(TextFormatTest, DefaultCustomFieldPrinter) {\n  protobuf_unittest::TestAllTypes message;\n\n  message.set_optional_uint32(42);\n  message.add_repeated_uint32(1);\n  message.add_repeated_uint32(2);\n  message.add_repeated_uint32(3);\n\n  TextFormat::Printer printer;\n  printer.SetDefaultFieldValuePrinter(new CustomUInt32FieldValuePrinter());\n  // Let's see if that works well together with the repeated primitives:\n  printer.SetUseShortRepeatedPrimitives(true);\n  string text;\n  printer.PrintToString(message, &text);\n  EXPECT_EQ(\"optional_uint32: 42u\\nrepeated_uint32: [1u, 2u, 3u]\\n\", text);\n}\n\nclass CustomInt32FieldValuePrinter : public TextFormat::FieldValuePrinter {\n public:\n  virtual string PrintInt32(int32 val) const {\n    return StrCat(\"value-is(\", FieldValuePrinter::PrintInt32(val), \")\");\n  }\n};\n\nTEST_F(TextFormatTest, FieldSpecificCustomPrinter) {\n  protobuf_unittest::TestAllTypes message;\n\n  message.set_optional_int32(42);  // This will be handled by our Printer.\n  message.add_repeated_int32(42);  // This will be printed as number.\n\n  TextFormat::Printer printer;\n  EXPECT_TRUE(printer.RegisterFieldValuePrinter(\n      message.GetDescriptor()->FindFieldByName(\"optional_int32\"),\n      new CustomInt32FieldValuePrinter()));\n  string text;\n  printer.PrintToString(message, &text);\n  EXPECT_EQ(\"optional_int32: value-is(42)\\nrepeated_int32: 42\\n\", text);\n}\n\nTEST_F(TextFormatTest, ErrorCasesRegisteringFieldValuePrinterShouldFail) {\n  protobuf_unittest::TestAllTypes message;\n  TextFormat::Printer printer;\n  // NULL printer.\n  EXPECT_FALSE(printer.RegisterFieldValuePrinter(\n      message.GetDescriptor()->FindFieldByName(\"optional_int32\"),\n      NULL));\n  // Because registration fails, the ownership of this printer is never taken.\n  TextFormat::FieldValuePrinter my_field_printer;\n  // NULL field\n  EXPECT_FALSE(printer.RegisterFieldValuePrinter(NULL, &my_field_printer));\n}\n\nclass CustomMessageFieldValuePrinter : public TextFormat::FieldValuePrinter {\n public:\n  virtual string PrintInt32(int32 v) const {\n    return StrCat(FieldValuePrinter::PrintInt32(v), \"  # x\", strings::Hex(v));\n  }\n\n  virtual string PrintMessageStart(const Message& message,\n                                   int field_index,\n                                   int field_count,\n                                   bool single_line_mode) const {\n    if (single_line_mode) {\n      return \" { \";\n    }\n    return StrCat(\n        \" {  # \", message.GetDescriptor()->name(), \": \", field_index, \"\\n\");\n  }\n};\n\nTEST_F(TextFormatTest, CustomPrinterForComments) {\n  protobuf_unittest::TestAllTypes message;\n  message.mutable_optional_nested_message();\n  message.mutable_optional_import_message()->set_d(42);\n  message.add_repeated_nested_message();\n  message.add_repeated_nested_message();\n  message.add_repeated_import_message()->set_d(43);\n  message.add_repeated_import_message()->set_d(44);\n  TextFormat::Printer printer;\n  CustomMessageFieldValuePrinter my_field_printer;\n  printer.SetDefaultFieldValuePrinter(new CustomMessageFieldValuePrinter());\n  string text;\n  printer.PrintToString(message, &text);\n  EXPECT_EQ(\n      \"optional_nested_message {  # NestedMessage: -1\\n\"\n      \"}\\n\"\n      \"optional_import_message {  # ImportMessage: -1\\n\"\n      \"  d: 42  # x2a\\n\"\n      \"}\\n\"\n      \"repeated_nested_message {  # NestedMessage: 0\\n\"\n      \"}\\n\"\n      \"repeated_nested_message {  # NestedMessage: 1\\n\"\n      \"}\\n\"\n      \"repeated_import_message {  # ImportMessage: 0\\n\"\n      \"  d: 43  # x2b\\n\"\n      \"}\\n\"\n      \"repeated_import_message {  # ImportMessage: 1\\n\"\n      \"  d: 44  # x2c\\n\"\n      \"}\\n\",\n      text);\n}\n\nclass CustomMultilineCommentPrinter : public TextFormat::FieldValuePrinter {\n public:\n  virtual string PrintMessageStart(const Message& message,\n                                   int field_index,\n                                   int field_count,\n                                   bool single_line_comment) const {\n    return StrCat(\" {  # 1\\n\", \"  # 2\\n\");\n  }\n};\n\nTEST_F(TextFormatTest, CustomPrinterForMultilineComments) {\n  protobuf_unittest::TestAllTypes message;\n  message.mutable_optional_nested_message();\n  message.mutable_optional_import_message()->set_d(42);\n  TextFormat::Printer printer;\n  CustomMessageFieldValuePrinter my_field_printer;\n  printer.SetDefaultFieldValuePrinter(new CustomMultilineCommentPrinter());\n  string text;\n  printer.PrintToString(message, &text);\n  EXPECT_EQ(\n      \"optional_nested_message {  # 1\\n\"\n      \"  # 2\\n\"\n      \"}\\n\"\n      \"optional_import_message {  # 1\\n\"\n      \"  # 2\\n\"\n      \"  d: 42\\n\"\n      \"}\\n\",\n      text);\n}\n\nTEST_F(TextFormatTest, ParseBasic) {\n  io::ArrayInputStream input_stream(proto_debug_string_.data(),\n                                    proto_debug_string_.size());\n  TextFormat::Parse(&input_stream, &proto_);\n  TestUtil::ExpectAllFieldsSet(proto_);\n}\n\nTEST_F(TextFormatExtensionsTest, ParseExtensions) {\n  io::ArrayInputStream input_stream(proto_debug_string_.data(),\n                                    proto_debug_string_.size());\n  TextFormat::Parse(&input_stream, &proto_);\n  TestUtil::ExpectAllExtensionsSet(proto_);\n}\n\nTEST_F(TextFormatTest, ParseEnumFieldFromNumber) {\n  // Create a parse string with a numerical value for an enum field.\n  string parse_string = strings::Substitute(\"optional_nested_enum: $0\",\n                                            unittest::TestAllTypes::BAZ);\n  EXPECT_TRUE(TextFormat::ParseFromString(parse_string, &proto_));\n  EXPECT_TRUE(proto_.has_optional_nested_enum());\n  EXPECT_EQ(unittest::TestAllTypes::BAZ, proto_.optional_nested_enum());\n}\n\nTEST_F(TextFormatTest, ParseEnumFieldFromNegativeNumber) {\n  ASSERT_LT(unittest::SPARSE_E, 0);\n  string parse_string = strings::Substitute(\"sparse_enum: $0\",\n                                            unittest::SPARSE_E);\n  unittest::SparseEnumMessage proto;\n  EXPECT_TRUE(TextFormat::ParseFromString(parse_string, &proto));\n  EXPECT_TRUE(proto.has_sparse_enum());\n  EXPECT_EQ(unittest::SPARSE_E, proto.sparse_enum());\n}\n\nTEST_F(TextFormatTest, ParseStringEscape) {\n  // Create a parse string with escpaed characters in it.\n  string parse_string = \"optional_string: \"\n      + kEscapeTestStringEscaped\n      + \"\\n\";\n\n  io::ArrayInputStream input_stream(parse_string.data(),\n                                    parse_string.size());\n  TextFormat::Parse(&input_stream, &proto_);\n\n  // Compare.\n  EXPECT_EQ(kEscapeTestString, proto_.optional_string());\n}\n\nTEST_F(TextFormatTest, ParseConcatenatedString) {\n  // Create a parse string with multiple parts on one line.\n  string parse_string = \"optional_string: \\\"foo\\\" \\\"bar\\\"\\n\";\n\n  io::ArrayInputStream input_stream1(parse_string.data(),\n                                    parse_string.size());\n  TextFormat::Parse(&input_stream1, &proto_);\n\n  // Compare.\n  EXPECT_EQ(\"foobar\", proto_.optional_string());\n\n  // Create a parse string with multiple parts on separate lines.\n  parse_string = \"optional_string: \\\"foo\\\"\\n\"\n                 \"\\\"bar\\\"\\n\";\n\n  io::ArrayInputStream input_stream2(parse_string.data(),\n                                    parse_string.size());\n  TextFormat::Parse(&input_stream2, &proto_);\n\n  // Compare.\n  EXPECT_EQ(\"foobar\", proto_.optional_string());\n}\n\nTEST_F(TextFormatTest, ParseFloatWithSuffix) {\n  // Test that we can parse a floating-point value with 'f' appended to the\n  // end.  This is needed for backwards-compatibility with proto1.\n\n  // Have it parse a float with the 'f' suffix.\n  string parse_string = \"optional_float: 1.0f\\n\";\n\n  io::ArrayInputStream input_stream(parse_string.data(),\n                                    parse_string.size());\n\n  TextFormat::Parse(&input_stream, &proto_);\n\n  // Compare.\n  EXPECT_EQ(1.0, proto_.optional_float());\n}\n\nTEST_F(TextFormatTest, ParseShortRepeatedForm) {\n  string parse_string =\n      // Mixed short-form and long-form are simply concatenated.\n      \"repeated_int32: 1\\n\"\n      \"repeated_int32: [456, 789]\\n\"\n      \"repeated_nested_enum: [  FOO ,BAR, # comment\\n\"\n      \"                         3]\\n\"\n      // Note that while the printer won't print repeated strings in short-form,\n      // the parser will accept them.\n      \"repeated_string: [ \\\"foo\\\", 'bar' ]\\n\"\n      // Repeated message\n      \"repeated_nested_message: [ { bb: 1 }, { bb : 2 }]\\n\"\n      // Repeated group\n      \"RepeatedGroup [{ a: 3 },{ a: 4 }]\\n\";\n\n  ASSERT_TRUE(TextFormat::ParseFromString(parse_string, &proto_));\n\n  ASSERT_EQ(3, proto_.repeated_int32_size());\n  EXPECT_EQ(1, proto_.repeated_int32(0));\n  EXPECT_EQ(456, proto_.repeated_int32(1));\n  EXPECT_EQ(789, proto_.repeated_int32(2));\n\n  ASSERT_EQ(3, proto_.repeated_nested_enum_size());\n  EXPECT_EQ(unittest::TestAllTypes::FOO, proto_.repeated_nested_enum(0));\n  EXPECT_EQ(unittest::TestAllTypes::BAR, proto_.repeated_nested_enum(1));\n  EXPECT_EQ(unittest::TestAllTypes::BAZ, proto_.repeated_nested_enum(2));\n\n  ASSERT_EQ(2, proto_.repeated_string_size());\n  EXPECT_EQ(\"foo\", proto_.repeated_string(0));\n  EXPECT_EQ(\"bar\", proto_.repeated_string(1));\n\n  ASSERT_EQ(2, proto_.repeated_nested_message_size());\n  EXPECT_EQ(1, proto_.repeated_nested_message(0).bb());\n  EXPECT_EQ(2, proto_.repeated_nested_message(1).bb());\n\n  ASSERT_EQ(2, proto_.repeatedgroup_size());\n  EXPECT_EQ(3, proto_.repeatedgroup(0).a());\n  EXPECT_EQ(4, proto_.repeatedgroup(1).a());\n}\n\n\nTEST_F(TextFormatTest, Comments) {\n  // Test that comments are ignored.\n\n  string parse_string = \"optional_int32: 1  # a comment\\n\"\n                        \"optional_int64: 2  # another comment\";\n\n  io::ArrayInputStream input_stream(parse_string.data(),\n                                    parse_string.size());\n\n  TextFormat::Parse(&input_stream, &proto_);\n\n  // Compare.\n  EXPECT_EQ(1, proto_.optional_int32());\n  EXPECT_EQ(2, proto_.optional_int64());\n}\n\nTEST_F(TextFormatTest, OptionalColon) {\n  // Test that we can place a ':' after the field name of a nested message,\n  // even though we don't have to.\n\n  string parse_string = \"optional_nested_message: { bb: 1}\\n\";\n\n  io::ArrayInputStream input_stream(parse_string.data(),\n                                    parse_string.size());\n\n  TextFormat::Parse(&input_stream, &proto_);\n\n  // Compare.\n  EXPECT_TRUE(proto_.has_optional_nested_message());\n  EXPECT_EQ(1, proto_.optional_nested_message().bb());\n}\n\n// Some platforms (e.g. Windows) insist on padding the exponent to three\n// digits when one or two would be just fine.\nstatic string RemoveRedundantZeros(string text) {\n  text = StringReplace(text, \"e+0\", \"e+\", true);\n  text = StringReplace(text, \"e-0\", \"e-\", true);\n  return text;\n}\n\nTEST_F(TextFormatTest, PrintExotic) {\n  unittest::TestAllTypes message;\n\n  // Note:  In C, a negative integer literal is actually the unary negation\n  //   operator being applied to a positive integer literal, and\n  //   9223372036854775808 is outside the range of int64.  However, it is not\n  //   outside the range of uint64.  Confusingly, this means that everything\n  //   works if we make the literal unsigned, even though we are negating it.\n  message.add_repeated_int64(-GOOGLE_ULONGLONG(9223372036854775808));\n  message.add_repeated_uint64(GOOGLE_ULONGLONG(18446744073709551615));\n  message.add_repeated_double(123.456);\n  message.add_repeated_double(1.23e21);\n  message.add_repeated_double(1.23e-18);\n  message.add_repeated_double(std::numeric_limits<double>::infinity());\n  message.add_repeated_double(-std::numeric_limits<double>::infinity());\n  message.add_repeated_double(std::numeric_limits<double>::quiet_NaN());\n  message.add_repeated_string(string(\"\\000\\001\\a\\b\\f\\n\\r\\t\\v\\\\\\'\\\"\", 12));\n\n  // Fun story:  We used to use 1.23e22 instead of 1.23e21 above, but this\n  //   seemed to trigger an odd case on MinGW/GCC 3.4.5 where GCC's parsing of\n  //   the value differed from strtod()'s parsing.  That is to say, the\n  //   following assertion fails on MinGW:\n  //     assert(1.23e22 == strtod(\"1.23e22\", NULL));\n  //   As a result, SimpleDtoa() would print the value as\n  //   \"1.2300000000000001e+22\" to make sure strtod() produce the exact same\n  //   result.  Our goal is to test runtime parsing, not compile-time parsing,\n  //   so this wasn't our problem.  It was found that using 1.23e21 did not\n  //   have this problem, so we switched to that instead.\n\n  EXPECT_EQ(\n    \"repeated_int64: -9223372036854775808\\n\"\n    \"repeated_uint64: 18446744073709551615\\n\"\n    \"repeated_double: 123.456\\n\"\n    \"repeated_double: 1.23e+21\\n\"\n    \"repeated_double: 1.23e-18\\n\"\n    \"repeated_double: inf\\n\"\n    \"repeated_double: -inf\\n\"\n    \"repeated_double: nan\\n\"\n    \"repeated_string: \\\"\\\\000\\\\001\\\\007\\\\010\\\\014\\\\n\\\\r\\\\t\\\\013\\\\\\\\\\\\'\\\\\\\"\\\"\\n\",\n    RemoveRedundantZeros(message.DebugString()));\n}\n\nTEST_F(TextFormatTest, PrintFloatPrecision) {\n  unittest::TestAllTypes message;\n\n  message.add_repeated_float(1.2);\n  message.add_repeated_float(1.23);\n  message.add_repeated_float(1.234);\n  message.add_repeated_float(1.2345);\n  message.add_repeated_float(1.23456);\n  message.add_repeated_float(1.2e10);\n  message.add_repeated_float(1.23e10);\n  message.add_repeated_float(1.234e10);\n  message.add_repeated_float(1.2345e10);\n  message.add_repeated_float(1.23456e10);\n  message.add_repeated_double(1.2);\n  message.add_repeated_double(1.23);\n  message.add_repeated_double(1.234);\n  message.add_repeated_double(1.2345);\n  message.add_repeated_double(1.23456);\n  message.add_repeated_double(1.234567);\n  message.add_repeated_double(1.2345678);\n  message.add_repeated_double(1.23456789);\n  message.add_repeated_double(1.234567898);\n  message.add_repeated_double(1.2345678987);\n  message.add_repeated_double(1.23456789876);\n  message.add_repeated_double(1.234567898765);\n  message.add_repeated_double(1.2345678987654);\n  message.add_repeated_double(1.23456789876543);\n  message.add_repeated_double(1.2e100);\n  message.add_repeated_double(1.23e100);\n  message.add_repeated_double(1.234e100);\n  message.add_repeated_double(1.2345e100);\n  message.add_repeated_double(1.23456e100);\n  message.add_repeated_double(1.234567e100);\n  message.add_repeated_double(1.2345678e100);\n  message.add_repeated_double(1.23456789e100);\n  message.add_repeated_double(1.234567898e100);\n  message.add_repeated_double(1.2345678987e100);\n  message.add_repeated_double(1.23456789876e100);\n  message.add_repeated_double(1.234567898765e100);\n  message.add_repeated_double(1.2345678987654e100);\n  message.add_repeated_double(1.23456789876543e100);\n\n  EXPECT_EQ(\n    \"repeated_float: 1.2\\n\"\n    \"repeated_float: 1.23\\n\"\n    \"repeated_float: 1.234\\n\"\n    \"repeated_float: 1.2345\\n\"\n    \"repeated_float: 1.23456\\n\"\n    \"repeated_float: 1.2e+10\\n\"\n    \"repeated_float: 1.23e+10\\n\"\n    \"repeated_float: 1.234e+10\\n\"\n    \"repeated_float: 1.2345e+10\\n\"\n    \"repeated_float: 1.23456e+10\\n\"\n    \"repeated_double: 1.2\\n\"\n    \"repeated_double: 1.23\\n\"\n    \"repeated_double: 1.234\\n\"\n    \"repeated_double: 1.2345\\n\"\n    \"repeated_double: 1.23456\\n\"\n    \"repeated_double: 1.234567\\n\"\n    \"repeated_double: 1.2345678\\n\"\n    \"repeated_double: 1.23456789\\n\"\n    \"repeated_double: 1.234567898\\n\"\n    \"repeated_double: 1.2345678987\\n\"\n    \"repeated_double: 1.23456789876\\n\"\n    \"repeated_double: 1.234567898765\\n\"\n    \"repeated_double: 1.2345678987654\\n\"\n    \"repeated_double: 1.23456789876543\\n\"\n    \"repeated_double: 1.2e+100\\n\"\n    \"repeated_double: 1.23e+100\\n\"\n    \"repeated_double: 1.234e+100\\n\"\n    \"repeated_double: 1.2345e+100\\n\"\n    \"repeated_double: 1.23456e+100\\n\"\n    \"repeated_double: 1.234567e+100\\n\"\n    \"repeated_double: 1.2345678e+100\\n\"\n    \"repeated_double: 1.23456789e+100\\n\"\n    \"repeated_double: 1.234567898e+100\\n\"\n    \"repeated_double: 1.2345678987e+100\\n\"\n    \"repeated_double: 1.23456789876e+100\\n\"\n    \"repeated_double: 1.234567898765e+100\\n\"\n    \"repeated_double: 1.2345678987654e+100\\n\"\n    \"repeated_double: 1.23456789876543e+100\\n\",\n    RemoveRedundantZeros(message.DebugString()));\n}\n\n\nTEST_F(TextFormatTest, AllowPartial) {\n  unittest::TestRequired message;\n  TextFormat::Parser parser;\n  parser.AllowPartialMessage(true);\n  EXPECT_TRUE(parser.ParseFromString(\"a: 1\", &message));\n  EXPECT_EQ(1, message.a());\n  EXPECT_FALSE(message.has_b());\n  EXPECT_FALSE(message.has_c());\n}\n\nTEST_F(TextFormatTest, ParseExotic) {\n  unittest::TestAllTypes message;\n  ASSERT_TRUE(TextFormat::ParseFromString(\n    \"repeated_int32: -1\\n\"\n    \"repeated_int32: -2147483648\\n\"\n    \"repeated_int64: -1\\n\"\n    \"repeated_int64: -9223372036854775808\\n\"\n    \"repeated_uint32: 4294967295\\n\"\n    \"repeated_uint32: 2147483648\\n\"\n    \"repeated_uint64: 18446744073709551615\\n\"\n    \"repeated_uint64: 9223372036854775808\\n\"\n    \"repeated_double: 123.0\\n\"\n    \"repeated_double: 123.5\\n\"\n    \"repeated_double: 0.125\\n\"\n    \"repeated_double: 1.23E17\\n\"\n    \"repeated_double: 1.235E+22\\n\"\n    \"repeated_double: 1.235e-18\\n\"\n    \"repeated_double: 123.456789\\n\"\n    \"repeated_double: inf\\n\"\n    \"repeated_double: Infinity\\n\"\n    \"repeated_double: -inf\\n\"\n    \"repeated_double: -Infinity\\n\"\n    \"repeated_double: nan\\n\"\n    \"repeated_double: NaN\\n\"\n    \"repeated_string: \\\"\\\\000\\\\001\\\\a\\\\b\\\\f\\\\n\\\\r\\\\t\\\\v\\\\\\\\\\\\'\\\\\\\"\\\"\\n\",\n    &message));\n\n  ASSERT_EQ(2, message.repeated_int32_size());\n  EXPECT_EQ(-1, message.repeated_int32(0));\n  // Note:  In C, a negative integer literal is actually the unary negation\n  //   operator being applied to a positive integer literal, and 2147483648 is\n  //   outside the range of int32.  However, it is not outside the range of\n  //   uint32.  Confusingly, this means that everything works if we make the\n  //   literal unsigned, even though we are negating it.\n  EXPECT_EQ(-2147483648u, message.repeated_int32(1));\n\n  ASSERT_EQ(2, message.repeated_int64_size());\n  EXPECT_EQ(-1, message.repeated_int64(0));\n  // Note:  In C, a negative integer literal is actually the unary negation\n  //   operator being applied to a positive integer literal, and\n  //   9223372036854775808 is outside the range of int64.  However, it is not\n  //   outside the range of uint64.  Confusingly, this means that everything\n  //   works if we make the literal unsigned, even though we are negating it.\n  EXPECT_EQ(-GOOGLE_ULONGLONG(9223372036854775808), message.repeated_int64(1));\n\n  ASSERT_EQ(2, message.repeated_uint32_size());\n  EXPECT_EQ(4294967295u, message.repeated_uint32(0));\n  EXPECT_EQ(2147483648u, message.repeated_uint32(1));\n\n  ASSERT_EQ(2, message.repeated_uint64_size());\n  EXPECT_EQ(GOOGLE_ULONGLONG(18446744073709551615), message.repeated_uint64(0));\n  EXPECT_EQ(GOOGLE_ULONGLONG(9223372036854775808), message.repeated_uint64(1));\n\n  ASSERT_EQ(13, message.repeated_double_size());\n  EXPECT_EQ(123.0     , message.repeated_double(0));\n  EXPECT_EQ(123.5     , message.repeated_double(1));\n  EXPECT_EQ(0.125     , message.repeated_double(2));\n  EXPECT_EQ(1.23E17   , message.repeated_double(3));\n  EXPECT_EQ(1.235E22  , message.repeated_double(4));\n  EXPECT_EQ(1.235E-18 , message.repeated_double(5));\n  EXPECT_EQ(123.456789, message.repeated_double(6));\n  EXPECT_EQ(message.repeated_double(7), numeric_limits<double>::infinity());\n  EXPECT_EQ(message.repeated_double(8), numeric_limits<double>::infinity());\n  EXPECT_EQ(message.repeated_double(9), -numeric_limits<double>::infinity());\n  EXPECT_EQ(message.repeated_double(10), -numeric_limits<double>::infinity());\n  EXPECT_TRUE(MathLimits<double>::IsNaN(message.repeated_double(11)));\n  EXPECT_TRUE(MathLimits<double>::IsNaN(message.repeated_double(12)));\n\n  // Note:  Since these string literals have \\0's in them, we must explicitly\n  //   pass their sizes to string's constructor.\n  ASSERT_EQ(1, message.repeated_string_size());\n  EXPECT_EQ(string(\"\\000\\001\\a\\b\\f\\n\\r\\t\\v\\\\\\'\\\"\", 12),\n            message.repeated_string(0));\n}\n\nTEST_F(TextFormatTest, PrintFieldsInIndexOrder) {\n  protobuf_unittest::TestFieldOrderings message;\n  // Fields are listed in index order instead of field number.\n  message.set_my_string(\"Test String\");   // Field number 11\n  message.set_my_int(12345);              // Field number 1\n  message.set_my_float(0.999);            // Field number 101\n  TextFormat::Printer printer;\n  string text;\n\n  // By default, print in field number order.\n  printer.PrintToString(message, &text);\n  EXPECT_EQ(\"my_int: 12345\\nmy_string: \\\"Test String\\\"\\nmy_float: 0.999\\n\",\n            text);\n\n  // Print in index order.\n  printer.SetPrintMessageFieldsInIndexOrder(true);\n  printer.PrintToString(message, &text);\n  EXPECT_EQ(\"my_string: \\\"Test String\\\"\\nmy_int: 12345\\nmy_float: 0.999\\n\",\n            text);\n}\n\nclass TextFormatParserTest : public testing::Test {\n protected:\n  void ExpectFailure(const string& input, const string& message, int line,\n                     int col) {\n    google::protobuf::scoped_ptr<unittest::TestAllTypes> proto(new unittest::TestAllTypes);\n    ExpectFailure(input, message, line, col, proto.get());\n  }\n\n  void ExpectFailure(const string& input, const string& message, int line,\n                     int col, Message* proto) {\n    ExpectMessage(input, message, line, col, proto, false);\n  }\n\n  void ExpectMessage(const string& input, const string& message, int line,\n                     int col, Message* proto, bool expected_result) {\n    TextFormat::Parser parser;\n    MockErrorCollector error_collector;\n    parser.RecordErrorsTo(&error_collector);\n    EXPECT_EQ(expected_result, parser.ParseFromString(input, proto))\n        << input << \" -> \" << proto->DebugString();\n    EXPECT_EQ(SimpleItoa(line) + \":\" + SimpleItoa(col) + \": \" + message + \"\\n\",\n              error_collector.text_);\n  }\n\n  void ExpectSuccessAndTree(const string& input, Message* proto,\n                            TextFormat::ParseInfoTree* info_tree) {\n    TextFormat::Parser parser;\n    MockErrorCollector error_collector;\n    parser.RecordErrorsTo(&error_collector);\n    parser.WriteLocationsTo(info_tree);\n\n    EXPECT_TRUE(parser.ParseFromString(input, proto));\n  }\n\n  void ExpectLocation(TextFormat::ParseInfoTree* tree,\n                      const Descriptor* d, const string& field_name,\n                      int index, int line, int column) {\n    TextFormat::ParseLocation location = tree->GetLocation(\n        d->FindFieldByName(field_name), index);\n    EXPECT_EQ(line, location.line);\n    EXPECT_EQ(column, location.column);\n  }\n\n  // An error collector which simply concatenates all its errors into a big\n  // block of text which can be checked.\n  class MockErrorCollector : public io::ErrorCollector {\n   public:\n    MockErrorCollector() {}\n    ~MockErrorCollector() {}\n\n    string text_;\n\n    // implements ErrorCollector -------------------------------------\n    void AddError(int line, int column, const string& message) {\n      strings::SubstituteAndAppend(&text_, \"$0:$1: $2\\n\",\n                                   line + 1, column + 1, message);\n    }\n\n    void AddWarning(int line, int column, const string& message) {\n      AddError(line, column, \"WARNING:\" + message);\n    }\n  };\n};\n\nTEST_F(TextFormatParserTest, ParseInfoTreeBuilding) {\n  google::protobuf::scoped_ptr<unittest::TestAllTypes> message(new unittest::TestAllTypes);\n  const Descriptor* d = message->GetDescriptor();\n\n  string stringData =\n      \"optional_int32: 1\\n\"\n      \"optional_int64: 2\\n\"\n      \"  optional_double: 2.4\\n\"\n      \"repeated_int32: 5\\n\"\n      \"repeated_int32: 10\\n\"\n      \"optional_nested_message <\\n\"\n      \"  bb: 78\\n\"\n      \">\\n\"\n      \"repeated_nested_message <\\n\"\n      \"  bb: 79\\n\"\n      \">\\n\"\n      \"repeated_nested_message <\\n\"\n      \"  bb: 80\\n\"\n      \">\";\n\n\n  TextFormat::ParseInfoTree tree;\n  ExpectSuccessAndTree(stringData, message.get(), &tree);\n\n  // Verify that the tree has the correct positions.\n  ExpectLocation(&tree, d, \"optional_int32\", -1, 0, 0);\n  ExpectLocation(&tree, d, \"optional_int64\", -1, 1, 0);\n  ExpectLocation(&tree, d, \"optional_double\", -1, 2, 2);\n\n  ExpectLocation(&tree, d, \"repeated_int32\", 0, 3, 0);\n  ExpectLocation(&tree, d, \"repeated_int32\", 1, 4, 0);\n\n  ExpectLocation(&tree, d, \"optional_nested_message\", -1, 5, 0);\n  ExpectLocation(&tree, d, \"repeated_nested_message\", 0, 8, 0);\n  ExpectLocation(&tree, d, \"repeated_nested_message\", 1, 11, 0);\n\n  // Check for fields not set. For an invalid field, the location returned\n  // should be -1, -1.\n  ExpectLocation(&tree, d, \"repeated_int64\", 0, -1, -1);\n  ExpectLocation(&tree, d, \"repeated_int32\", 6, -1, -1);\n  ExpectLocation(&tree, d, \"some_unknown_field\", -1, -1, -1);\n\n  // Verify inside the nested message.\n  const FieldDescriptor* nested_field =\n      d->FindFieldByName(\"optional_nested_message\");\n\n  TextFormat::ParseInfoTree* nested_tree =\n      tree.GetTreeForNested(nested_field, -1);\n  ExpectLocation(nested_tree, nested_field->message_type(), \"bb\", -1, 6, 2);\n\n  // Verify inside another nested message.\n  nested_field = d->FindFieldByName(\"repeated_nested_message\");\n  nested_tree = tree.GetTreeForNested(nested_field, 0);\n  ExpectLocation(nested_tree, nested_field->message_type(), \"bb\", -1, 9, 2);\n\n  nested_tree = tree.GetTreeForNested(nested_field, 1);\n  ExpectLocation(nested_tree, nested_field->message_type(), \"bb\", -1, 12, 2);\n\n  // Verify a NULL tree for an unknown nested field.\n  TextFormat::ParseInfoTree* unknown_nested_tree =\n      tree.GetTreeForNested(nested_field, 2);\n\n  EXPECT_EQ(NULL, unknown_nested_tree);\n}\n\nTEST_F(TextFormatParserTest, ParseFieldValueFromString) {\n  google::protobuf::scoped_ptr<unittest::TestAllTypes> message(new unittest::TestAllTypes);\n  const Descriptor* d = message->GetDescriptor();\n\n#define EXPECT_FIELD(name, value, valuestring) \\\n  EXPECT_TRUE(TextFormat::ParseFieldValueFromString( \\\n    valuestring, d->FindFieldByName(\"optional_\" #name), message.get())); \\\n  EXPECT_EQ(value, message->optional_##name()); \\\n  EXPECT_TRUE(message->has_optional_##name());\n\n#define EXPECT_BOOL_FIELD(name, value, valuestring) \\\n  EXPECT_TRUE(TextFormat::ParseFieldValueFromString( \\\n    valuestring, d->FindFieldByName(\"optional_\" #name), message.get())); \\\n  EXPECT_TRUE(message->optional_##name() == value); \\\n  EXPECT_TRUE(message->has_optional_##name());\n\n#define EXPECT_FLOAT_FIELD(name, value, valuestring) \\\n  EXPECT_TRUE(TextFormat::ParseFieldValueFromString( \\\n    valuestring, d->FindFieldByName(\"optional_\" #name), message.get())); \\\n  EXPECT_FLOAT_EQ(value, message->optional_##name()); \\\n  EXPECT_TRUE(message->has_optional_##name());\n\n#define EXPECT_DOUBLE_FIELD(name, value, valuestring) \\\n  EXPECT_TRUE(TextFormat::ParseFieldValueFromString( \\\n    valuestring, d->FindFieldByName(\"optional_\" #name), message.get())); \\\n  EXPECT_DOUBLE_EQ(value, message->optional_##name()); \\\n  EXPECT_TRUE(message->has_optional_##name());\n\n#define EXPECT_INVALID(name, valuestring) \\\n  EXPECT_FALSE(TextFormat::ParseFieldValueFromString( \\\n    valuestring, d->FindFieldByName(\"optional_\" #name), message.get()));\n\n  // int32\n  EXPECT_FIELD(int32, 1, \"1\");\n  EXPECT_FIELD(int32, -1, \"-1\");\n  EXPECT_FIELD(int32, 0x1234, \"0x1234\");\n  EXPECT_INVALID(int32, \"a\");\n  EXPECT_INVALID(int32, \"999999999999999999999999999999999999\");\n  EXPECT_INVALID(int32, \"1,2\");\n\n  // int64\n  EXPECT_FIELD(int64, 1, \"1\");\n  EXPECT_FIELD(int64, -1, \"-1\");\n  EXPECT_FIELD(int64, 0x1234567812345678LL, \"0x1234567812345678\");\n  EXPECT_INVALID(int64, \"a\");\n  EXPECT_INVALID(int64, \"999999999999999999999999999999999999\");\n  EXPECT_INVALID(int64, \"1,2\");\n\n  // uint64\n  EXPECT_FIELD(uint64, 1, \"1\");\n  EXPECT_FIELD(uint64, 0xf234567812345678ULL, \"0xf234567812345678\");\n  EXPECT_INVALID(uint64, \"-1\");\n  EXPECT_INVALID(uint64, \"a\");\n  EXPECT_INVALID(uint64, \"999999999999999999999999999999999999\");\n  EXPECT_INVALID(uint64, \"1,2\");\n\n  // fixed32\n  EXPECT_FIELD(fixed32, 1, \"1\");\n  EXPECT_FIELD(fixed32, 0x12345678, \"0x12345678\");\n  EXPECT_INVALID(fixed32, \"-1\");\n  EXPECT_INVALID(fixed32, \"a\");\n  EXPECT_INVALID(fixed32, \"999999999999999999999999999999999999\");\n  EXPECT_INVALID(fixed32, \"1,2\");\n\n  // fixed64\n  EXPECT_FIELD(fixed64, 1, \"1\");\n  EXPECT_FIELD(fixed64, 0x1234567812345678ULL, \"0x1234567812345678\");\n  EXPECT_INVALID(fixed64, \"-1\");\n  EXPECT_INVALID(fixed64, \"a\");\n  EXPECT_INVALID(fixed64, \"999999999999999999999999999999999999\");\n  EXPECT_INVALID(fixed64, \"1,2\");\n\n  // bool\n  EXPECT_BOOL_FIELD(bool, true, \"true\");\n  EXPECT_BOOL_FIELD(bool, false, \"false\");\n  EXPECT_BOOL_FIELD(bool, true, \"1\");\n  EXPECT_BOOL_FIELD(bool, true, \"t\");\n  EXPECT_BOOL_FIELD(bool, false, \"0\");\n  EXPECT_BOOL_FIELD(bool, false, \"f\");\n  EXPECT_FIELD(bool, true, \"True\");\n  EXPECT_FIELD(bool, false, \"False\");\n  EXPECT_INVALID(bool, \"tRue\");\n  EXPECT_INVALID(bool, \"faLse\");\n  EXPECT_INVALID(bool, \"2\");\n  EXPECT_INVALID(bool, \"-0\");\n  EXPECT_INVALID(bool, \"on\");\n  EXPECT_INVALID(bool, \"a\");\n\n  // float\n  EXPECT_FIELD(float, 1, \"1\");\n  EXPECT_FLOAT_FIELD(float, 1.5, \"1.5\");\n  EXPECT_FLOAT_FIELD(float, 1.5e3, \"1.5e3\");\n  EXPECT_FLOAT_FIELD(float, -4.55, \"-4.55\");\n  EXPECT_INVALID(float, \"a\");\n  EXPECT_INVALID(float, \"1,2\");\n\n  // double\n  EXPECT_FIELD(double, 1, \"1\");\n  EXPECT_FIELD(double, -1, \"-1\");\n  EXPECT_DOUBLE_FIELD(double, 2.3, \"2.3\");\n  EXPECT_DOUBLE_FIELD(double, 3e5, \"3e5\");\n  EXPECT_INVALID(double, \"a\");\n  EXPECT_INVALID(double, \"1,2\");\n  // Rejects hex and oct numbers for a double field.\n  EXPECT_INVALID(double, \"0xf\");\n  EXPECT_INVALID(double, \"012\");\n\n  // string\n  EXPECT_FIELD(string, \"hello\", \"\\\"hello\\\"\");\n  EXPECT_FIELD(string, \"-1.87\", \"'-1.87'\");\n  EXPECT_INVALID(string, \"hello\");  // without quote for value\n\n  // enum\n  EXPECT_FIELD(nested_enum, unittest::TestAllTypes::BAR, \"BAR\");\n  EXPECT_FIELD(nested_enum, unittest::TestAllTypes::BAZ,\n               SimpleItoa(unittest::TestAllTypes::BAZ));\n  EXPECT_INVALID(nested_enum, \"FOOBAR\");\n\n  // message\n  EXPECT_TRUE(TextFormat::ParseFieldValueFromString(\n    \"<bb:12>\", d->FindFieldByName(\"optional_nested_message\"), message.get()));\n  EXPECT_EQ(12, message->optional_nested_message().bb()); \\\n  EXPECT_TRUE(message->has_optional_nested_message());\n  EXPECT_INVALID(nested_message, \"any\");\n\n#undef EXPECT_FIELD\n#undef EXPECT_BOOL_FIELD\n#undef EXPECT_FLOAT_FIELD\n#undef EXPECT_DOUBLE_FIELD\n#undef EXPECT_INVALID\n}\n\n\nTEST_F(TextFormatParserTest, InvalidToken) {\n  ExpectFailure(\"optional_bool: true\\n-5\\n\", \"Expected identifier, got: -\",\n                2, 1);\n\n  ExpectFailure(\"optional_bool: true!\\n\", \"Expected identifier, got: !\", 1,\n                20);\n  ExpectFailure(\"\\\"some string\\\"\",\n                \"Expected identifier, got: \\\"some string\\\"\", 1, 1);\n}\n\nTEST_F(TextFormatParserTest, InvalidFieldName) {\n  ExpectFailure(\n      \"invalid_field: somevalue\\n\",\n      \"Message type \\\"protobuf_unittest.TestAllTypes\\\" has no field named \"\n      \"\\\"invalid_field\\\".\",\n      1, 14);\n}\n\nTEST_F(TextFormatParserTest, InvalidCapitalization) {\n  // We require that group names be exactly as they appear in the .proto.\n  ExpectFailure(\n      \"optionalgroup {\\na: 15\\n}\\n\",\n      \"Message type \\\"protobuf_unittest.TestAllTypes\\\" has no field named \"\n      \"\\\"optionalgroup\\\".\",\n      1, 15);\n  ExpectFailure(\n      \"OPTIONALgroup {\\na: 15\\n}\\n\",\n      \"Message type \\\"protobuf_unittest.TestAllTypes\\\" has no field named \"\n      \"\\\"OPTIONALgroup\\\".\",\n      1, 15);\n  ExpectFailure(\n      \"Optional_Double: 10.0\\n\",\n      \"Message type \\\"protobuf_unittest.TestAllTypes\\\" has no field named \"\n      \"\\\"Optional_Double\\\".\",\n      1, 16);\n}\n\nTEST_F(TextFormatParserTest, AllowIgnoreCapitalizationError) {\n  TextFormat::Parser parser;\n  protobuf_unittest::TestAllTypes proto;\n\n  // These fields have a mismatching case.\n  EXPECT_FALSE(parser.ParseFromString(\"Optional_Double: 10.0\", &proto));\n  EXPECT_FALSE(parser.ParseFromString(\"oPtIoNaLgRoUp { a: 15 }\", &proto));\n\n  // ... but are parsed correctly if we match case insensitive.\n  parser.AllowCaseInsensitiveField(true);\n  EXPECT_TRUE(parser.ParseFromString(\"Optional_Double: 10.0\", &proto));\n  EXPECT_EQ(10.0, proto.optional_double());\n  EXPECT_TRUE(parser.ParseFromString(\"oPtIoNaLgRoUp { a: 15 }\", &proto));\n  EXPECT_EQ(15, proto.optionalgroup().a());\n}\n\nTEST_F(TextFormatParserTest, InvalidFieldValues) {\n  // Invalid values for a double/float field.\n  ExpectFailure(\"optional_double: \\\"hello\\\"\\n\",\n                \"Expected double, got: \\\"hello\\\"\", 1, 18);\n  ExpectFailure(\"optional_double: true\\n\", \"Expected double, got: true\", 1,\n                18);\n  ExpectFailure(\"optional_double: !\\n\", \"Expected double, got: !\", 1, 18);\n  ExpectFailure(\"optional_double {\\n  \\n}\\n\", \"Expected \\\":\\\", found \\\"{\\\".\",\n                1, 17);\n\n  // Invalid values for a signed integer field.\n  ExpectFailure(\"optional_int32: \\\"hello\\\"\\n\",\n                \"Expected integer, got: \\\"hello\\\"\", 1, 17);\n  ExpectFailure(\"optional_int32: true\\n\", \"Expected integer, got: true\", 1, 17);\n  ExpectFailure(\"optional_int32: 4.5\\n\", \"Expected integer, got: 4.5\", 1, 17);\n  ExpectFailure(\"optional_int32: !\\n\", \"Expected integer, got: !\", 1, 17);\n  ExpectFailure(\"optional_int32 {\\n \\n}\\n\", \"Expected \\\":\\\", found \\\"{\\\".\",\n                1, 16);\n  ExpectFailure(\"optional_int32: 0x80000000\\n\",\n                \"Integer out of range (0x80000000)\", 1, 17);\n  ExpectFailure(\"optional_int64: 0x8000000000000000\\n\",\n                \"Integer out of range (0x8000000000000000)\", 1, 17);\n  ExpectFailure(\"optional_int32: -0x80000001\\n\",\n                \"Integer out of range (0x80000001)\", 1, 18);\n  ExpectFailure(\"optional_int64: -0x8000000000000001\\n\",\n                \"Integer out of range (0x8000000000000001)\", 1, 18);\n\n  // Invalid values for an unsigned integer field.\n  ExpectFailure(\"optional_uint64: \\\"hello\\\"\\n\",\n                \"Expected integer, got: \\\"hello\\\"\", 1, 18);\n  ExpectFailure(\"optional_uint64: true\\n\",\n                \"Expected integer, got: true\", 1, 18);\n  ExpectFailure(\"optional_uint64: 4.5\\n\", \"Expected integer, got: 4.5\", 1, 18);\n  ExpectFailure(\"optional_uint64: -5\\n\", \"Expected integer, got: -\", 1, 18);\n  ExpectFailure(\"optional_uint64: !\\n\", \"Expected integer, got: !\", 1, 18);\n  ExpectFailure(\"optional_uint64 {\\n \\n}\\n\", \"Expected \\\":\\\", found \\\"{\\\".\",\n                1, 17);\n  ExpectFailure(\"optional_uint32: 0x100000000\\n\",\n                \"Integer out of range (0x100000000)\", 1, 18);\n  ExpectFailure(\"optional_uint64: 0x10000000000000000\\n\",\n                \"Integer out of range (0x10000000000000000)\", 1, 18);\n\n  // Invalid values for a boolean field.\n  ExpectFailure(\"optional_bool: \\\"hello\\\"\\n\",\n                \"Expected identifier, got: \\\"hello\\\"\", 1, 16);\n  ExpectFailure(\"optional_bool: 5\\n\", \"Integer out of range (5)\", 1, 16);\n  ExpectFailure(\"optional_bool: -7.5\\n\", \"Expected identifier, got: -\", 1, 16);\n  ExpectFailure(\"optional_bool: !\\n\", \"Expected identifier, got: !\", 1, 16);\n\n  ExpectFailure(\n      \"optional_bool: meh\\n\",\n      \"Invalid value for boolean field \\\"optional_bool\\\". Value: \\\"meh\\\".\",\n      2, 1);\n\n  ExpectFailure(\"optional_bool {\\n \\n}\\n\", \"Expected \\\":\\\", found \\\"{\\\".\",\n                1, 15);\n\n  // Invalid values for a string field.\n  ExpectFailure(\"optional_string: true\\n\", \"Expected string, got: true\", 1, 18);\n  ExpectFailure(\"optional_string: 5\\n\", \"Expected string, got: 5\", 1, 18);\n  ExpectFailure(\"optional_string: -7.5\\n\", \"Expected string, got: -\", 1, 18);\n  ExpectFailure(\"optional_string: !\\n\", \"Expected string, got: !\", 1, 18);\n  ExpectFailure(\"optional_string {\\n \\n}\\n\", \"Expected \\\":\\\", found \\\"{\\\".\",\n                1, 17);\n\n  // Invalid values for an enumeration field.\n  ExpectFailure(\"optional_nested_enum: \\\"hello\\\"\\n\",\n                \"Expected integer or identifier, got: \\\"hello\\\"\", 1, 23);\n\n  // Valid token, but enum value is not defined.\n  ExpectFailure(\"optional_nested_enum: 5\\n\",\n                \"Unknown enumeration value of \\\"5\\\" for field \"\n                \"\\\"optional_nested_enum\\\".\", 2, 1);\n  // We consume the negative sign, so the error position starts one character\n  // later.\n  ExpectFailure(\"optional_nested_enum: -7.5\\n\", \"Expected integer, got: 7.5\", 1,\n                24);\n  ExpectFailure(\"optional_nested_enum: !\\n\",\n                \"Expected integer or identifier, got: !\", 1, 23);\n\n  ExpectFailure(\n      \"optional_nested_enum: grah\\n\",\n      \"Unknown enumeration value of \\\"grah\\\" for field \"\n      \"\\\"optional_nested_enum\\\".\", 2, 1);\n\n  ExpectFailure(\n      \"optional_nested_enum {\\n \\n}\\n\",\n      \"Expected \\\":\\\", found \\\"{\\\".\", 1, 22);\n}\n\nTEST_F(TextFormatParserTest, MessageDelimiters) {\n  // Non-matching delimiters.\n  ExpectFailure(\"OptionalGroup <\\n \\n}\\n\", \"Expected \\\">\\\", found \\\"}\\\".\",\n                3, 1);\n\n  // Invalid delimiters.\n  ExpectFailure(\"OptionalGroup [\\n \\n]\\n\", \"Expected \\\"{\\\", found \\\"[\\\".\",\n                1, 15);\n\n  // Unending message.\n  ExpectFailure(\"optional_nested_message {\\n \\nbb: 118\\n\",\n                \"Expected identifier, got: \",\n                4, 1);\n}\n\nTEST_F(TextFormatParserTest, UnknownExtension) {\n  // Non-matching delimiters.\n  ExpectFailure(\"[blahblah]: 123\",\n                \"Extension \\\"blahblah\\\" is not defined or is not an \"\n                \"extension of \\\"protobuf_unittest.TestAllTypes\\\".\",\n                1, 11);\n}\n\nTEST_F(TextFormatParserTest, MissingRequired) {\n  unittest::TestRequired message;\n  ExpectFailure(\"a: 1\",\n                \"Message missing required fields: b, c\",\n                0, 1, &message);\n}\n\nTEST_F(TextFormatParserTest, ParseDuplicateRequired) {\n  unittest::TestRequired message;\n  ExpectFailure(\"a: 1 b: 2 c: 3 a: 1\",\n                \"Non-repeated field \\\"a\\\" is specified multiple times.\",\n                1, 17, &message);\n}\n\nTEST_F(TextFormatParserTest, ParseDuplicateOptional) {\n  unittest::ForeignMessage message;\n  ExpectFailure(\"c: 1 c: 2\",\n                \"Non-repeated field \\\"c\\\" is specified multiple times.\",\n                1, 7, &message);\n}\n\nTEST_F(TextFormatParserTest, MergeDuplicateRequired) {\n  unittest::TestRequired message;\n  TextFormat::Parser parser;\n  EXPECT_TRUE(parser.MergeFromString(\"a: 1 b: 2 c: 3 a: 4\", &message));\n  EXPECT_EQ(4, message.a());\n}\n\nTEST_F(TextFormatParserTest, MergeDuplicateOptional) {\n  unittest::ForeignMessage message;\n  TextFormat::Parser parser;\n  EXPECT_TRUE(parser.MergeFromString(\"c: 1 c: 2\", &message));\n  EXPECT_EQ(2, message.c());\n}\n\nTEST_F(TextFormatParserTest, ExplicitDelimiters) {\n  unittest::TestRequired message;\n  EXPECT_TRUE(TextFormat::ParseFromString(\"a:1,b:2;c:3\", &message));\n  EXPECT_EQ(1, message.a());\n  EXPECT_EQ(2, message.b());\n  EXPECT_EQ(3, message.c());\n}\n\nTEST_F(TextFormatParserTest, PrintErrorsToStderr) {\n  vector<string> errors;\n\n  {\n    ScopedMemoryLog log;\n    unittest::TestAllTypes proto;\n    EXPECT_FALSE(TextFormat::ParseFromString(\"no_such_field: 1\", &proto));\n    errors = log.GetMessages(ERROR);\n  }\n\n  ASSERT_EQ(1, errors.size());\n  EXPECT_EQ(\"Error parsing text-format protobuf_unittest.TestAllTypes: \"\n            \"1:14: Message type \\\"protobuf_unittest.TestAllTypes\\\" has no field \"\n            \"named \\\"no_such_field\\\".\",\n            errors[0]);\n}\n\nTEST_F(TextFormatParserTest, FailsOnTokenizationError) {\n  vector<string> errors;\n\n  {\n    ScopedMemoryLog log;\n    unittest::TestAllTypes proto;\n    EXPECT_FALSE(TextFormat::ParseFromString(\"\\020\", &proto));\n    errors = log.GetMessages(ERROR);\n  }\n\n  ASSERT_EQ(1, errors.size());\n  EXPECT_EQ(\"Error parsing text-format protobuf_unittest.TestAllTypes: \"\n            \"1:1: Invalid control characters encountered in text.\",\n            errors[0]);\n}\n\nTEST_F(TextFormatParserTest, ParseDeprecatedField) {\n  unittest::TestDeprecatedFields message;\n  ExpectMessage(\"deprecated_int32: 42\",\n                \"WARNING:text format contains deprecated field \"\n                \"\\\"deprecated_int32\\\"\", 1, 21, &message, true);\n}\n\nclass TextFormatMessageSetTest : public testing::Test {\n protected:\n  static const char proto_debug_string_[];\n};\nconst char TextFormatMessageSetTest::proto_debug_string_[] =\n\"message_set {\\n\"\n\"  [protobuf_unittest.TestMessageSetExtension1] {\\n\"\n\"    i: 23\\n\"\n\"  }\\n\"\n\"  [protobuf_unittest.TestMessageSetExtension2] {\\n\"\n\"    str: \\\"foo\\\"\\n\"\n\"  }\\n\"\n\"}\\n\";\n\n\nTEST_F(TextFormatMessageSetTest, Serialize) {\n  protobuf_unittest::TestMessageSetContainer proto;\n  protobuf_unittest::TestMessageSetExtension1* item_a =\n    proto.mutable_message_set()->MutableExtension(\n      protobuf_unittest::TestMessageSetExtension1::message_set_extension);\n  item_a->set_i(23);\n  protobuf_unittest::TestMessageSetExtension2* item_b =\n    proto.mutable_message_set()->MutableExtension(\n      protobuf_unittest::TestMessageSetExtension2::message_set_extension);\n  item_b->set_str(\"foo\");\n  EXPECT_EQ(proto_debug_string_, proto.DebugString());\n}\n\nTEST_F(TextFormatMessageSetTest, Deserialize) {\n  protobuf_unittest::TestMessageSetContainer proto;\n  ASSERT_TRUE(TextFormat::ParseFromString(proto_debug_string_, &proto));\n  EXPECT_EQ(23, proto.message_set().GetExtension(\n    protobuf_unittest::TestMessageSetExtension1::message_set_extension).i());\n  EXPECT_EQ(\"foo\", proto.message_set().GetExtension(\n    protobuf_unittest::TestMessageSetExtension2::message_set_extension).str());\n\n  // Ensure that these are the only entries present.\n  vector<const FieldDescriptor*> descriptors;\n  proto.message_set().GetReflection()->ListFields(\n    proto.message_set(), &descriptors);\n  EXPECT_EQ(2, descriptors.size());\n}\n\n\n}  // namespace text_format_unittest\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/timestamp.pb.cc",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/timestamp.proto\n\n#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION\n#include <google/protobuf/timestamp.pb.h>\n\n#include <algorithm>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/port.h>\n#include <google/protobuf/stubs/once.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/generated_message_reflection.h>\n#include <google/protobuf/reflection_ops.h>\n#include <google/protobuf/wire_format.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\n\nnamespace {\n\nconst ::google::protobuf::Descriptor* Timestamp_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  Timestamp_reflection_ = NULL;\n\n}  // namespace\n\n\nvoid protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto() {\n  protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto();\n  const ::google::protobuf::FileDescriptor* file =\n    ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(\n      \"google/protobuf/timestamp.proto\");\n  GOOGLE_CHECK(file != NULL);\n  Timestamp_descriptor_ = file->message_type(0);\n  static const int Timestamp_offsets_[2] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, seconds_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, nanos_),\n  };\n  Timestamp_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      Timestamp_descriptor_,\n      Timestamp::default_instance_,\n      Timestamp_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(Timestamp),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Timestamp, _is_default_instance_));\n}\n\nnamespace {\n\nGOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);\ninline void protobuf_AssignDescriptorsOnce() {\n  ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,\n                 &protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto);\n}\n\nvoid protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_RegisterTypes(const ::std::string&) {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      Timestamp_descriptor_, &Timestamp::default_instance());\n}\n\n}  // namespace\n\nvoid protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto() {\n  delete Timestamp::default_instance_;\n  delete Timestamp_reflection_;\n}\n\nvoid protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto() {\n  static bool already_here = false;\n  if (already_here) return;\n  already_here = true;\n  GOOGLE_PROTOBUF_VERIFY_VERSION;\n\n  ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(\n    \"\\n\\037google/protobuf/timestamp.proto\\022\\017googl\"\n    \"e.protobuf\\\"+\\n\\tTimestamp\\022\\017\\n\\007seconds\\030\\001 \\001(\\003\"\n    \"\\022\\r\\n\\005nanos\\030\\002 \\001(\\005B\\201\\001\\n\\023com.google.protobufB\"\n    \"\\016TimestampProtoP\\001Z+github.com/golang/pro\"\n    \"tobuf/ptypes/timestamp\\240\\001\\001\\370\\001\\001\\242\\002\\003GPB\\252\\002\\036Goo\"\n    \"gle.Protobuf.WellKnownTypesb\\006proto3\", 235);\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(\n    \"google/protobuf/timestamp.proto\", &protobuf_RegisterTypes);\n  Timestamp::default_instance_ = new Timestamp();\n  Timestamp::default_instance_->InitAsDefaultInstance();\n  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto);\n}\n\n// Force AddDescriptors() to be called at static initialization time.\nstruct StaticDescriptorInitializer_google_2fprotobuf_2ftimestamp_2eproto {\n  StaticDescriptorInitializer_google_2fprotobuf_2ftimestamp_2eproto() {\n    protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto();\n  }\n} static_descriptor_initializer_google_2fprotobuf_2ftimestamp_2eproto_;\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int Timestamp::kSecondsFieldNumber;\nconst int Timestamp::kNanosFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nTimestamp::Timestamp()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.Timestamp)\n}\n\nTimestamp::Timestamp(::google::protobuf::Arena* arena)\n  : ::google::protobuf::Message(),\n  _internal_metadata_(arena) {\n  SharedCtor();\n  RegisterArenaDtor(arena);\n  // @@protoc_insertion_point(arena_constructor:google.protobuf.Timestamp)\n}\n\nvoid Timestamp::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n}\n\nTimestamp::Timestamp(const Timestamp& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.Timestamp)\n}\n\nvoid Timestamp::SharedCtor() {\n    _is_default_instance_ = false;\n  _cached_size_ = 0;\n  seconds_ = GOOGLE_LONGLONG(0);\n  nanos_ = 0;\n}\n\nTimestamp::~Timestamp() {\n  // @@protoc_insertion_point(destructor:google.protobuf.Timestamp)\n  SharedDtor();\n}\n\nvoid Timestamp::SharedDtor() {\n  if (GetArenaNoVirtual() != NULL) {\n    return;\n  }\n\n  if (this != default_instance_) {\n  }\n}\n\nvoid Timestamp::ArenaDtor(void* object) {\n  Timestamp* _this = reinterpret_cast< Timestamp* >(object);\n  (void)_this;\n}\nvoid Timestamp::RegisterArenaDtor(::google::protobuf::Arena* arena) {\n}\nvoid Timestamp::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* Timestamp::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return Timestamp_descriptor_;\n}\n\nconst Timestamp& Timestamp::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto();\n  return *default_instance_;\n}\n\nTimestamp* Timestamp::default_instance_ = NULL;\n\nTimestamp* Timestamp::New(::google::protobuf::Arena* arena) const {\n  return ::google::protobuf::Arena::CreateMessage<Timestamp>(arena);\n}\n\nvoid Timestamp::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.Timestamp)\n#if defined(__clang__)\n#define ZR_HELPER_(f) \\\n  _Pragma(\"clang diagnostic push\") \\\n  _Pragma(\"clang diagnostic ignored \\\"-Winvalid-offsetof\\\"\") \\\n  __builtin_offsetof(Timestamp, f) \\\n  _Pragma(\"clang diagnostic pop\")\n#else\n#define ZR_HELPER_(f) reinterpret_cast<char*>(\\\n  &reinterpret_cast<Timestamp*>(16)->f)\n#endif\n\n#define ZR_(first, last) do {\\\n  ::memset(&first, 0,\\\n           ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\\\n} while (0)\n\n  ZR_(seconds_, nanos_);\n\n#undef ZR_HELPER_\n#undef ZR_\n\n}\n\nbool Timestamp::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.Timestamp)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional int64 seconds = 1;\n      case 1: {\n        if (tag == 8) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(\n                 input, &seconds_)));\n\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(16)) goto parse_nanos;\n        break;\n      }\n\n      // optional int32 nanos = 2;\n      case 2: {\n        if (tag == 16) {\n         parse_nanos:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 input, &nanos_)));\n\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.Timestamp)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.Timestamp)\n  return false;\n#undef DO_\n}\n\nvoid Timestamp::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.Timestamp)\n  // optional int64 seconds = 1;\n  if (this->seconds() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt64(1, this->seconds(), output);\n  }\n\n  // optional int32 nanos = 2;\n  if (this->nanos() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->nanos(), output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.Timestamp)\n}\n\n::google::protobuf::uint8* Timestamp::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Timestamp)\n  // optional int64 seconds = 1;\n  if (this->seconds() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(1, this->seconds(), target);\n  }\n\n  // optional int32 nanos = 2;\n  if (this->nanos() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->nanos(), target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Timestamp)\n  return target;\n}\n\nint Timestamp::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Timestamp)\n  int total_size = 0;\n\n  // optional int64 seconds = 1;\n  if (this->seconds() != 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::Int64Size(\n        this->seconds());\n  }\n\n  // optional int32 nanos = 2;\n  if (this->nanos() != 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::Int32Size(\n        this->nanos());\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid Timestamp::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Timestamp)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const Timestamp* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const Timestamp>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.Timestamp)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Timestamp)\n    MergeFrom(*source);\n  }\n}\n\nvoid Timestamp::MergeFrom(const Timestamp& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Timestamp)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from.seconds() != 0) {\n    set_seconds(from.seconds());\n  }\n  if (from.nanos() != 0) {\n    set_nanos(from.nanos());\n  }\n}\n\nvoid Timestamp::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.Timestamp)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid Timestamp::CopyFrom(const Timestamp& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Timestamp)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool Timestamp::IsInitialized() const {\n\n  return true;\n}\n\nvoid Timestamp::Swap(Timestamp* other) {\n  if (other == this) return;\n  if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {\n    InternalSwap(other);\n  } else {\n    Timestamp temp;\n    temp.MergeFrom(*this);\n    CopyFrom(*other);\n    other->CopyFrom(temp);\n  }\n}\nvoid Timestamp::UnsafeArenaSwap(Timestamp* other) {\n  if (other == this) return;\n  GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());\n  InternalSwap(other);\n}\nvoid Timestamp::InternalSwap(Timestamp* other) {\n  std::swap(seconds_, other->seconds_);\n  std::swap(nanos_, other->nanos_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata Timestamp::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = Timestamp_descriptor_;\n  metadata.reflection = Timestamp_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// Timestamp\n\n// optional int64 seconds = 1;\nvoid Timestamp::clear_seconds() {\n  seconds_ = GOOGLE_LONGLONG(0);\n}\n ::google::protobuf::int64 Timestamp::seconds() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Timestamp.seconds)\n  return seconds_;\n}\n void Timestamp::set_seconds(::google::protobuf::int64 value) {\n  \n  seconds_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Timestamp.seconds)\n}\n\n// optional int32 nanos = 2;\nvoid Timestamp::clear_nanos() {\n  nanos_ = 0;\n}\n ::google::protobuf::int32 Timestamp::nanos() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Timestamp.nanos)\n  return nanos_;\n}\n void Timestamp::set_nanos(::google::protobuf::int32 value) {\n  \n  nanos_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Timestamp.nanos)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace protobuf\n}  // namespace google\n\n// @@protoc_insertion_point(global_scope)\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/timestamp.pb.h",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/timestamp.proto\n\n#ifndef PROTOBUF_google_2fprotobuf_2ftimestamp_2eproto__INCLUDED\n#define PROTOBUF_google_2fprotobuf_2ftimestamp_2eproto__INCLUDED\n\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n\n#if GOOGLE_PROTOBUF_VERSION < 3000000\n#error This file was generated by a newer version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please update\n#error your headers.\n#endif\n#if 3000000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION\n#error This file was generated by an older version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please\n#error regenerate this file with a newer version of protoc.\n#endif\n\n#include <google/protobuf/arena.h>\n#include <google/protobuf/arenastring.h>\n#include <google/protobuf/generated_message_util.h>\n#include <google/protobuf/metadata.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/extension_set.h>\n#include <google/protobuf/unknown_field_set.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\n\n// Internal implementation detail -- do not call these.\nvoid LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto();\nvoid protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto();\nvoid protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto();\n\nclass Timestamp;\n\n// ===================================================================\n\nclass LIBPROTOBUF_EXPORT Timestamp : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Timestamp) */ {\n public:\n  Timestamp();\n  virtual ~Timestamp();\n\n  Timestamp(const Timestamp& from);\n\n  inline Timestamp& operator=(const Timestamp& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }\n  inline void* GetMaybeArenaPointer() const {\n    return MaybeArenaPtr();\n  }\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const Timestamp& default_instance();\n\n  void UnsafeArenaSwap(Timestamp* other);\n  void Swap(Timestamp* other);\n\n  // implements Message ----------------------------------------------\n\n  inline Timestamp* New() const { return New(NULL); }\n\n  Timestamp* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const Timestamp& from);\n  void MergeFrom(const Timestamp& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(Timestamp* other);\n  protected:\n  explicit Timestamp(::google::protobuf::Arena* arena);\n  private:\n  static void ArenaDtor(void* object);\n  inline void RegisterArenaDtor(::google::protobuf::Arena* arena);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional int64 seconds = 1;\n  void clear_seconds();\n  static const int kSecondsFieldNumber = 1;\n  ::google::protobuf::int64 seconds() const;\n  void set_seconds(::google::protobuf::int64 value);\n\n  // optional int32 nanos = 2;\n  void clear_nanos();\n  static const int kNanosFieldNumber = 2;\n  ::google::protobuf::int32 nanos() const;\n  void set_nanos(::google::protobuf::int32 value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.Timestamp)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  friend class ::google::protobuf::Arena;\n  typedef void InternalArenaConstructable_;\n  typedef void DestructorSkippable_;\n  bool _is_default_instance_;\n  ::google::protobuf::int64 seconds_;\n  ::google::protobuf::int32 nanos_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftimestamp_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2ftimestamp_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2ftimestamp_2eproto();\n\n  void InitAsDefaultInstance();\n  static Timestamp* default_instance_;\n};\n// ===================================================================\n\n\n// ===================================================================\n\n#if !PROTOBUF_INLINE_NOT_IN_HEADERS\n// Timestamp\n\n// optional int64 seconds = 1;\ninline void Timestamp::clear_seconds() {\n  seconds_ = GOOGLE_LONGLONG(0);\n}\ninline ::google::protobuf::int64 Timestamp::seconds() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Timestamp.seconds)\n  return seconds_;\n}\ninline void Timestamp::set_seconds(::google::protobuf::int64 value) {\n  \n  seconds_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Timestamp.seconds)\n}\n\n// optional int32 nanos = 2;\ninline void Timestamp::clear_nanos() {\n  nanos_ = 0;\n}\ninline ::google::protobuf::int32 Timestamp::nanos() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Timestamp.nanos)\n  return nanos_;\n}\ninline void Timestamp::set_nanos(::google::protobuf::int32 value) {\n  \n  nanos_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Timestamp.nanos)\n}\n\n#endif  // !PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace protobuf\n}  // namespace google\n\n// @@protoc_insertion_point(global_scope)\n\n#endif  // PROTOBUF_google_2fprotobuf_2ftimestamp_2eproto__INCLUDED\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/timestamp.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto3\";\n\npackage google.protobuf;\n\noption csharp_namespace = \"Google.Protobuf.WellKnownTypes\";\noption cc_enable_arenas = true;\noption go_package = \"github.com/golang/protobuf/ptypes/timestamp\";\noption java_package = \"com.google.protobuf\";\noption java_outer_classname = \"TimestampProto\";\noption java_multiple_files = true;\noption java_generate_equals_and_hash = true;\noption objc_class_prefix = \"GPB\";\n\n// A Timestamp represents a point in time independent of any time zone\n// or calendar, represented as seconds and fractions of seconds at\n// nanosecond resolution in UTC Epoch time. It is encoded using the\n// Proleptic Gregorian Calendar which extends the Gregorian calendar\n// backwards to year one. It is encoded assuming all minutes are 60\n// seconds long, i.e. leap seconds are \"smeared\" so that no leap second\n// table is needed for interpretation. Range is from\n// 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.\n// By restricting to that range, we ensure that we can convert to\n// and from  RFC 3339 date strings.\n// See [https://www.ietf.org/rfc/rfc3339.txt](https://www.ietf.org/rfc/rfc3339.txt).\n//\n// Example 1: Compute Timestamp from POSIX `time()`.\n//\n//     Timestamp timestamp;\n//     timestamp.set_seconds(time(NULL));\n//     timestamp.set_nanos(0);\n//\n// Example 2: Compute Timestamp from POSIX `gettimeofday()`.\n//\n//     struct timeval tv;\n//     gettimeofday(&tv, NULL);\n//\n//     Timestamp timestamp;\n//     timestamp.set_seconds(tv.tv_sec);\n//     timestamp.set_nanos(tv.tv_usec * 1000);\n//\n// Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.\n//\n//     FILETIME ft;\n//     GetSystemTimeAsFileTime(&ft);\n//     UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;\n//\n//     // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z\n//     // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.\n//     Timestamp timestamp;\n//     timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));\n//     timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));\n//\n// Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.\n//\n//     long millis = System.currentTimeMillis();\n//\n//     Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)\n//         .setNanos((int) ((millis % 1000) * 1000000)).build();\n//\n//\n// Example 5: Compute Timestamp from current time in Python.\n//\n//     now = time.time()\n//     seconds = int(now)\n//     nanos = int((now - seconds) * 10**9)\n//     timestamp = Timestamp(seconds=seconds, nanos=nanos)\n//\n//\nmessage Timestamp {\n\n  // Represents seconds of UTC time since Unix epoch\n  // 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to\n  // 9999-12-31T23:59:59Z inclusive.\n  int64 seconds = 1;\n\n  // Non-negative fractions of a second at nanosecond resolution. Negative\n  // second values with fractions must still have non-negative nanos values\n  // that count forward in time. Must be from 0 to 999,999,999\n  // inclusive.\n  int32 nanos = 2;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/type.pb.cc",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/type.proto\n\n#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION\n#include <google/protobuf/type.pb.h>\n\n#include <algorithm>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/port.h>\n#include <google/protobuf/stubs/once.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/generated_message_reflection.h>\n#include <google/protobuf/reflection_ops.h>\n#include <google/protobuf/wire_format.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\n\nnamespace {\n\nconst ::google::protobuf::Descriptor* Type_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  Type_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* Field_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  Field_reflection_ = NULL;\nconst ::google::protobuf::EnumDescriptor* Field_Kind_descriptor_ = NULL;\nconst ::google::protobuf::EnumDescriptor* Field_Cardinality_descriptor_ = NULL;\nconst ::google::protobuf::Descriptor* Enum_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  Enum_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* EnumValue_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  EnumValue_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* Option_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  Option_reflection_ = NULL;\nconst ::google::protobuf::EnumDescriptor* Syntax_descriptor_ = NULL;\n\n}  // namespace\n\n\nvoid protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto() {\n  protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();\n  const ::google::protobuf::FileDescriptor* file =\n    ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(\n      \"google/protobuf/type.proto\");\n  GOOGLE_CHECK(file != NULL);\n  Type_descriptor_ = file->message_type(0);\n  static const int Type_offsets_[6] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, name_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, fields_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, oneofs_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, options_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, source_context_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, syntax_),\n  };\n  Type_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      Type_descriptor_,\n      Type::default_instance_,\n      Type_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(Type),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Type, _is_default_instance_));\n  Field_descriptor_ = file->message_type(1);\n  static const int Field_offsets_[10] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, kind_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, cardinality_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, number_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, name_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, type_url_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, oneof_index_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, packed_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, options_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, json_name_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, default_value_),\n  };\n  Field_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      Field_descriptor_,\n      Field::default_instance_,\n      Field_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(Field),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Field, _is_default_instance_));\n  Field_Kind_descriptor_ = Field_descriptor_->enum_type(0);\n  Field_Cardinality_descriptor_ = Field_descriptor_->enum_type(1);\n  Enum_descriptor_ = file->message_type(2);\n  static const int Enum_offsets_[5] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, name_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, enumvalue_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, options_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, source_context_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, syntax_),\n  };\n  Enum_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      Enum_descriptor_,\n      Enum::default_instance_,\n      Enum_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(Enum),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Enum, _is_default_instance_));\n  EnumValue_descriptor_ = file->message_type(3);\n  static const int EnumValue_offsets_[3] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, name_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, number_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, options_),\n  };\n  EnumValue_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      EnumValue_descriptor_,\n      EnumValue::default_instance_,\n      EnumValue_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(EnumValue),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(EnumValue, _is_default_instance_));\n  Option_descriptor_ = file->message_type(4);\n  static const int Option_offsets_[2] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, name_),\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, value_),\n  };\n  Option_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      Option_descriptor_,\n      Option::default_instance_,\n      Option_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(Option),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Option, _is_default_instance_));\n  Syntax_descriptor_ = file->enum_type(0);\n}\n\nnamespace {\n\nGOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);\ninline void protobuf_AssignDescriptorsOnce() {\n  ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,\n                 &protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto);\n}\n\nvoid protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_RegisterTypes(const ::std::string&) {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      Type_descriptor_, &Type::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      Field_descriptor_, &Field::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      Enum_descriptor_, &Enum::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      EnumValue_descriptor_, &EnumValue::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      Option_descriptor_, &Option::default_instance());\n}\n\n}  // namespace\n\nvoid protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto() {\n  delete Type::default_instance_;\n  delete Type_reflection_;\n  delete Field::default_instance_;\n  delete Field_reflection_;\n  delete Enum::default_instance_;\n  delete Enum_reflection_;\n  delete EnumValue::default_instance_;\n  delete EnumValue_reflection_;\n  delete Option::default_instance_;\n  delete Option_reflection_;\n}\n\nvoid protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto() {\n  static bool already_here = false;\n  if (already_here) return;\n  already_here = true;\n  GOOGLE_PROTOBUF_VERIFY_VERSION;\n\n  ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fany_2eproto();\n  ::google::protobuf::protobuf_AddDesc_google_2fprotobuf_2fsource_5fcontext_2eproto();\n  ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(\n    \"\\n\\032google/protobuf/type.proto\\022\\017google.pro\"\n    \"tobuf\\032\\031google/protobuf/any.proto\\032$google\"\n    \"/protobuf/source_context.proto\\\"\\327\\001\\n\\004Type\\022\"\n    \"\\014\\n\\004name\\030\\001 \\001(\\t\\022&\\n\\006fields\\030\\002 \\003(\\0132\\026.google.p\"\n    \"rotobuf.Field\\022\\016\\n\\006oneofs\\030\\003 \\003(\\t\\022(\\n\\007options\"\n    \"\\030\\004 \\003(\\0132\\027.google.protobuf.Option\\0226\\n\\016sourc\"\n    \"e_context\\030\\005 \\001(\\0132\\036.google.protobuf.Source\"\n    \"Context\\022\\'\\n\\006syntax\\030\\006 \\001(\\0162\\027.google.protobu\"\n    \"f.Syntax\\\"\\325\\005\\n\\005Field\\022)\\n\\004kind\\030\\001 \\001(\\0162\\033.googl\"\n    \"e.protobuf.Field.Kind\\0227\\n\\013cardinality\\030\\002 \\001\"\n    \"(\\0162\\\".google.protobuf.Field.Cardinality\\022\\016\"\n    \"\\n\\006number\\030\\003 \\001(\\005\\022\\014\\n\\004name\\030\\004 \\001(\\t\\022\\020\\n\\010type_url\"\n    \"\\030\\006 \\001(\\t\\022\\023\\n\\013oneof_index\\030\\007 \\001(\\005\\022\\016\\n\\006packed\\030\\010 \"\n    \"\\001(\\010\\022(\\n\\007options\\030\\t \\003(\\0132\\027.google.protobuf.O\"\n    \"ption\\022\\021\\n\\tjson_name\\030\\n \\001(\\t\\022\\025\\n\\rdefault_valu\"\n    \"e\\030\\013 \\001(\\t\\\"\\310\\002\\n\\004Kind\\022\\020\\n\\014TYPE_UNKNOWN\\020\\000\\022\\017\\n\\013TY\"\n    \"PE_DOUBLE\\020\\001\\022\\016\\n\\nTYPE_FLOAT\\020\\002\\022\\016\\n\\nTYPE_INT6\"\n    \"4\\020\\003\\022\\017\\n\\013TYPE_UINT64\\020\\004\\022\\016\\n\\nTYPE_INT32\\020\\005\\022\\020\\n\\014\"\n    \"TYPE_FIXED64\\020\\006\\022\\020\\n\\014TYPE_FIXED32\\020\\007\\022\\r\\n\\tTYPE\"\n    \"_BOOL\\020\\010\\022\\017\\n\\013TYPE_STRING\\020\\t\\022\\016\\n\\nTYPE_GROUP\\020\\n\"\n    \"\\022\\020\\n\\014TYPE_MESSAGE\\020\\013\\022\\016\\n\\nTYPE_BYTES\\020\\014\\022\\017\\n\\013TY\"\n    \"PE_UINT32\\020\\r\\022\\r\\n\\tTYPE_ENUM\\020\\016\\022\\021\\n\\rTYPE_SFIXE\"\n    \"D32\\020\\017\\022\\021\\n\\rTYPE_SFIXED64\\020\\020\\022\\017\\n\\013TYPE_SINT32\\020\"\n    \"\\021\\022\\017\\n\\013TYPE_SINT64\\020\\022\\\"t\\n\\013Cardinality\\022\\027\\n\\023CAR\"\n    \"DINALITY_UNKNOWN\\020\\000\\022\\030\\n\\024CARDINALITY_OPTION\"\n    \"AL\\020\\001\\022\\030\\n\\024CARDINALITY_REQUIRED\\020\\002\\022\\030\\n\\024CARDIN\"\n    \"ALITY_REPEATED\\020\\003\\\"\\316\\001\\n\\004Enum\\022\\014\\n\\004name\\030\\001 \\001(\\t\\022\"\n    \"-\\n\\tenumvalue\\030\\002 \\003(\\0132\\032.google.protobuf.Enu\"\n    \"mValue\\022(\\n\\007options\\030\\003 \\003(\\0132\\027.google.protobu\"\n    \"f.Option\\0226\\n\\016source_context\\030\\004 \\001(\\0132\\036.googl\"\n    \"e.protobuf.SourceContext\\022\\'\\n\\006syntax\\030\\005 \\001(\\016\"\n    \"2\\027.google.protobuf.Syntax\\\"S\\n\\tEnumValue\\022\\014\"\n    \"\\n\\004name\\030\\001 \\001(\\t\\022\\016\\n\\006number\\030\\002 \\001(\\005\\022(\\n\\007options\\030\"\n    \"\\003 \\003(\\0132\\027.google.protobuf.Option\\\";\\n\\006Option\"\n    \"\\022\\014\\n\\004name\\030\\001 \\001(\\t\\022#\\n\\005value\\030\\002 \\001(\\0132\\024.google.p\"\n    \"rotobuf.Any*.\\n\\006Syntax\\022\\021\\n\\rSYNTAX_PROTO2\\020\\000\"\n    \"\\022\\021\\n\\rSYNTAX_PROTO3\\020\\001BL\\n\\023com.google.protob\"\n    \"ufB\\tTypeProtoP\\001\\240\\001\\001\\242\\002\\003GPB\\252\\002\\036Google.Protob\"\n    \"uf.WellKnownTypesb\\006proto3\", 1545);\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(\n    \"google/protobuf/type.proto\", &protobuf_RegisterTypes);\n  Type::default_instance_ = new Type();\n  Field::default_instance_ = new Field();\n  Enum::default_instance_ = new Enum();\n  EnumValue::default_instance_ = new EnumValue();\n  Option::default_instance_ = new Option();\n  Type::default_instance_->InitAsDefaultInstance();\n  Field::default_instance_->InitAsDefaultInstance();\n  Enum::default_instance_->InitAsDefaultInstance();\n  EnumValue::default_instance_->InitAsDefaultInstance();\n  Option::default_instance_->InitAsDefaultInstance();\n  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto);\n}\n\n// Force AddDescriptors() to be called at static initialization time.\nstruct StaticDescriptorInitializer_google_2fprotobuf_2ftype_2eproto {\n  StaticDescriptorInitializer_google_2fprotobuf_2ftype_2eproto() {\n    protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();\n  }\n} static_descriptor_initializer_google_2fprotobuf_2ftype_2eproto_;\nconst ::google::protobuf::EnumDescriptor* Syntax_descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return Syntax_descriptor_;\n}\nbool Syntax_IsValid(int value) {\n  switch(value) {\n    case 0:\n    case 1:\n      return true;\n    default:\n      return false;\n  }\n}\n\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int Type::kNameFieldNumber;\nconst int Type::kFieldsFieldNumber;\nconst int Type::kOneofsFieldNumber;\nconst int Type::kOptionsFieldNumber;\nconst int Type::kSourceContextFieldNumber;\nconst int Type::kSyntaxFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nType::Type()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.Type)\n}\n\nvoid Type::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n  source_context_ = const_cast< ::google::protobuf::SourceContext*>(&::google::protobuf::SourceContext::default_instance());\n}\n\nType::Type(const Type& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.Type)\n}\n\nvoid Type::SharedCtor() {\n    _is_default_instance_ = false;\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  source_context_ = NULL;\n  syntax_ = 0;\n}\n\nType::~Type() {\n  // @@protoc_insertion_point(destructor:google.protobuf.Type)\n  SharedDtor();\n}\n\nvoid Type::SharedDtor() {\n  name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n    delete source_context_;\n  }\n}\n\nvoid Type::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* Type::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return Type_descriptor_;\n}\n\nconst Type& Type::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();\n  return *default_instance_;\n}\n\nType* Type::default_instance_ = NULL;\n\nType* Type::New(::google::protobuf::Arena* arena) const {\n  Type* n = new Type;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid Type::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.Type)\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_;\n  source_context_ = NULL;\n  syntax_ = 0;\n  fields_.Clear();\n  oneofs_.Clear();\n  options_.Clear();\n}\n\nbool Type::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.Type)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional string name = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_name()));\n          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n            this->name().data(), this->name().length(),\n            ::google::protobuf::internal::WireFormatLite::PARSE,\n            \"google.protobuf.Type.name\"));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_fields;\n        break;\n      }\n\n      // repeated .google.protobuf.Field fields = 2;\n      case 2: {\n        if (tag == 18) {\n         parse_fields:\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_fields:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_fields()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_loop_fields;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectTag(26)) goto parse_oneofs;\n        break;\n      }\n\n      // repeated string oneofs = 3;\n      case 3: {\n        if (tag == 26) {\n         parse_oneofs:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->add_oneofs()));\n          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n            this->oneofs(this->oneofs_size() - 1).data(),\n            this->oneofs(this->oneofs_size() - 1).length(),\n            ::google::protobuf::internal::WireFormatLite::PARSE,\n            \"google.protobuf.Type.oneofs\"));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(26)) goto parse_oneofs;\n        if (input->ExpectTag(34)) goto parse_options;\n        break;\n      }\n\n      // repeated .google.protobuf.Option options = 4;\n      case 4: {\n        if (tag == 34) {\n         parse_options:\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_options:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_options()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(34)) goto parse_loop_options;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectTag(42)) goto parse_source_context;\n        break;\n      }\n\n      // optional .google.protobuf.SourceContext source_context = 5;\n      case 5: {\n        if (tag == 42) {\n         parse_source_context:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\n               input, mutable_source_context()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(48)) goto parse_syntax;\n        break;\n      }\n\n      // optional .google.protobuf.Syntax syntax = 6;\n      case 6: {\n        if (tag == 48) {\n         parse_syntax:\n          int value;\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n                 input, &value)));\n          set_syntax(static_cast< ::google::protobuf::Syntax >(value));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.Type)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.Type)\n  return false;\n#undef DO_\n}\n\nvoid Type::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.Type)\n  // optional string name = 1;\n  if (this->name().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Type.name\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      1, this->name(), output);\n  }\n\n  // repeated .google.protobuf.Field fields = 2;\n  for (unsigned int i = 0, n = this->fields_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      2, this->fields(i), output);\n  }\n\n  // repeated string oneofs = 3;\n  for (int i = 0; i < this->oneofs_size(); i++) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->oneofs(i).data(), this->oneofs(i).length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Type.oneofs\");\n    ::google::protobuf::internal::WireFormatLite::WriteString(\n      3, this->oneofs(i), output);\n  }\n\n  // repeated .google.protobuf.Option options = 4;\n  for (unsigned int i = 0, n = this->options_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      4, this->options(i), output);\n  }\n\n  // optional .google.protobuf.SourceContext source_context = 5;\n  if (this->has_source_context()) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      5, *this->source_context_, output);\n  }\n\n  // optional .google.protobuf.Syntax syntax = 6;\n  if (this->syntax() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteEnum(\n      6, this->syntax(), output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.Type)\n}\n\n::google::protobuf::uint8* Type::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Type)\n  // optional string name = 1;\n  if (this->name().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Type.name\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        1, this->name(), target);\n  }\n\n  // repeated .google.protobuf.Field fields = 2;\n  for (unsigned int i = 0, n = this->fields_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        2, this->fields(i), false, target);\n  }\n\n  // repeated string oneofs = 3;\n  for (int i = 0; i < this->oneofs_size(); i++) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->oneofs(i).data(), this->oneofs(i).length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Type.oneofs\");\n    target = ::google::protobuf::internal::WireFormatLite::\n      WriteStringToArray(3, this->oneofs(i), target);\n  }\n\n  // repeated .google.protobuf.Option options = 4;\n  for (unsigned int i = 0, n = this->options_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        4, this->options(i), false, target);\n  }\n\n  // optional .google.protobuf.SourceContext source_context = 5;\n  if (this->has_source_context()) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        5, *this->source_context_, false, target);\n  }\n\n  // optional .google.protobuf.Syntax syntax = 6;\n  if (this->syntax() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(\n      6, this->syntax(), target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Type)\n  return target;\n}\n\nint Type::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Type)\n  int total_size = 0;\n\n  // optional string name = 1;\n  if (this->name().size() > 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::StringSize(\n        this->name());\n  }\n\n  // optional .google.protobuf.SourceContext source_context = 5;\n  if (this->has_source_context()) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        *this->source_context_);\n  }\n\n  // optional .google.protobuf.Syntax syntax = 6;\n  if (this->syntax() != 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax());\n  }\n\n  // repeated .google.protobuf.Field fields = 2;\n  total_size += 1 * this->fields_size();\n  for (int i = 0; i < this->fields_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->fields(i));\n  }\n\n  // repeated string oneofs = 3;\n  total_size += 1 * this->oneofs_size();\n  for (int i = 0; i < this->oneofs_size(); i++) {\n    total_size += ::google::protobuf::internal::WireFormatLite::StringSize(\n      this->oneofs(i));\n  }\n\n  // repeated .google.protobuf.Option options = 4;\n  total_size += 1 * this->options_size();\n  for (int i = 0; i < this->options_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->options(i));\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid Type::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Type)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const Type* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const Type>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.Type)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Type)\n    MergeFrom(*source);\n  }\n}\n\nvoid Type::MergeFrom(const Type& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Type)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  fields_.MergeFrom(from.fields_);\n  oneofs_.MergeFrom(from.oneofs_);\n  options_.MergeFrom(from.options_);\n  if (from.name().size() > 0) {\n\n    name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);\n  }\n  if (from.has_source_context()) {\n    mutable_source_context()->::google::protobuf::SourceContext::MergeFrom(from.source_context());\n  }\n  if (from.syntax() != 0) {\n    set_syntax(from.syntax());\n  }\n}\n\nvoid Type::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.Type)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid Type::CopyFrom(const Type& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Type)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool Type::IsInitialized() const {\n\n  return true;\n}\n\nvoid Type::Swap(Type* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid Type::InternalSwap(Type* other) {\n  name_.Swap(&other->name_);\n  fields_.UnsafeArenaSwap(&other->fields_);\n  oneofs_.UnsafeArenaSwap(&other->oneofs_);\n  options_.UnsafeArenaSwap(&other->options_);\n  std::swap(source_context_, other->source_context_);\n  std::swap(syntax_, other->syntax_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata Type::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = Type_descriptor_;\n  metadata.reflection = Type_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// Type\n\n// optional string name = 1;\nvoid Type::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n const ::std::string& Type::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Type.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Type::set_name(const ::std::string& value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Type.name)\n}\n void Type::set_name(const char* value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Type.name)\n}\n void Type::set_name(const char* value, size_t size) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Type.name)\n}\n ::std::string* Type::mutable_name() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Type.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* Type::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Type.name)\n  \n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Type::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    \n  } else {\n    \n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.name)\n}\n\n// repeated .google.protobuf.Field fields = 2;\nint Type::fields_size() const {\n  return fields_.size();\n}\nvoid Type::clear_fields() {\n  fields_.Clear();\n}\nconst ::google::protobuf::Field& Type::fields(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Type.fields)\n  return fields_.Get(index);\n}\n::google::protobuf::Field* Type::mutable_fields(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Type.fields)\n  return fields_.Mutable(index);\n}\n::google::protobuf::Field* Type::add_fields() {\n  // @@protoc_insertion_point(field_add:google.protobuf.Type.fields)\n  return fields_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::Field >*\nType::mutable_fields() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.Type.fields)\n  return &fields_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::Field >&\nType::fields() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.Type.fields)\n  return fields_;\n}\n\n// repeated string oneofs = 3;\nint Type::oneofs_size() const {\n  return oneofs_.size();\n}\nvoid Type::clear_oneofs() {\n  oneofs_.Clear();\n}\n const ::std::string& Type::oneofs(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Type.oneofs)\n  return oneofs_.Get(index);\n}\n ::std::string* Type::mutable_oneofs(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Type.oneofs)\n  return oneofs_.Mutable(index);\n}\n void Type::set_oneofs(int index, const ::std::string& value) {\n  // @@protoc_insertion_point(field_set:google.protobuf.Type.oneofs)\n  oneofs_.Mutable(index)->assign(value);\n}\n void Type::set_oneofs(int index, const char* value) {\n  oneofs_.Mutable(index)->assign(value);\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Type.oneofs)\n}\n void Type::set_oneofs(int index, const char* value, size_t size) {\n  oneofs_.Mutable(index)->assign(\n    reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Type.oneofs)\n}\n ::std::string* Type::add_oneofs() {\n  // @@protoc_insertion_point(field_add_mutable:google.protobuf.Type.oneofs)\n  return oneofs_.Add();\n}\n void Type::add_oneofs(const ::std::string& value) {\n  oneofs_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add:google.protobuf.Type.oneofs)\n}\n void Type::add_oneofs(const char* value) {\n  oneofs_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add_char:google.protobuf.Type.oneofs)\n}\n void Type::add_oneofs(const char* value, size_t size) {\n  oneofs_.Add()->assign(reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_add_pointer:google.protobuf.Type.oneofs)\n}\n const ::google::protobuf::RepeatedPtrField< ::std::string>&\nType::oneofs() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.Type.oneofs)\n  return oneofs_;\n}\n ::google::protobuf::RepeatedPtrField< ::std::string>*\nType::mutable_oneofs() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.Type.oneofs)\n  return &oneofs_;\n}\n\n// repeated .google.protobuf.Option options = 4;\nint Type::options_size() const {\n  return options_.size();\n}\nvoid Type::clear_options() {\n  options_.Clear();\n}\nconst ::google::protobuf::Option& Type::options(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Type.options)\n  return options_.Get(index);\n}\n::google::protobuf::Option* Type::mutable_options(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Type.options)\n  return options_.Mutable(index);\n}\n::google::protobuf::Option* Type::add_options() {\n  // @@protoc_insertion_point(field_add:google.protobuf.Type.options)\n  return options_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*\nType::mutable_options() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.Type.options)\n  return &options_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&\nType::options() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.Type.options)\n  return options_;\n}\n\n// optional .google.protobuf.SourceContext source_context = 5;\nbool Type::has_source_context() const {\n  return !_is_default_instance_ && source_context_ != NULL;\n}\nvoid Type::clear_source_context() {\n  if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_;\n  source_context_ = NULL;\n}\nconst ::google::protobuf::SourceContext& Type::source_context() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Type.source_context)\n  return source_context_ != NULL ? *source_context_ : *default_instance_->source_context_;\n}\n::google::protobuf::SourceContext* Type::mutable_source_context() {\n  \n  if (source_context_ == NULL) {\n    source_context_ = new ::google::protobuf::SourceContext;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Type.source_context)\n  return source_context_;\n}\n::google::protobuf::SourceContext* Type::release_source_context() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Type.source_context)\n  \n  ::google::protobuf::SourceContext* temp = source_context_;\n  source_context_ = NULL;\n  return temp;\n}\nvoid Type::set_allocated_source_context(::google::protobuf::SourceContext* source_context) {\n  delete source_context_;\n  source_context_ = source_context;\n  if (source_context) {\n    \n  } else {\n    \n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.source_context)\n}\n\n// optional .google.protobuf.Syntax syntax = 6;\nvoid Type::clear_syntax() {\n  syntax_ = 0;\n}\n ::google::protobuf::Syntax Type::syntax() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Type.syntax)\n  return static_cast< ::google::protobuf::Syntax >(syntax_);\n}\n void Type::set_syntax(::google::protobuf::Syntax value) {\n  \n  syntax_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Type.syntax)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\nconst ::google::protobuf::EnumDescriptor* Field_Kind_descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return Field_Kind_descriptor_;\n}\nbool Field_Kind_IsValid(int value) {\n  switch(value) {\n    case 0:\n    case 1:\n    case 2:\n    case 3:\n    case 4:\n    case 5:\n    case 6:\n    case 7:\n    case 8:\n    case 9:\n    case 10:\n    case 11:\n    case 12:\n    case 13:\n    case 14:\n    case 15:\n    case 16:\n    case 17:\n    case 18:\n      return true;\n    default:\n      return false;\n  }\n}\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst Field_Kind Field::TYPE_UNKNOWN;\nconst Field_Kind Field::TYPE_DOUBLE;\nconst Field_Kind Field::TYPE_FLOAT;\nconst Field_Kind Field::TYPE_INT64;\nconst Field_Kind Field::TYPE_UINT64;\nconst Field_Kind Field::TYPE_INT32;\nconst Field_Kind Field::TYPE_FIXED64;\nconst Field_Kind Field::TYPE_FIXED32;\nconst Field_Kind Field::TYPE_BOOL;\nconst Field_Kind Field::TYPE_STRING;\nconst Field_Kind Field::TYPE_GROUP;\nconst Field_Kind Field::TYPE_MESSAGE;\nconst Field_Kind Field::TYPE_BYTES;\nconst Field_Kind Field::TYPE_UINT32;\nconst Field_Kind Field::TYPE_ENUM;\nconst Field_Kind Field::TYPE_SFIXED32;\nconst Field_Kind Field::TYPE_SFIXED64;\nconst Field_Kind Field::TYPE_SINT32;\nconst Field_Kind Field::TYPE_SINT64;\nconst Field_Kind Field::Kind_MIN;\nconst Field_Kind Field::Kind_MAX;\nconst int Field::Kind_ARRAYSIZE;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\nconst ::google::protobuf::EnumDescriptor* Field_Cardinality_descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return Field_Cardinality_descriptor_;\n}\nbool Field_Cardinality_IsValid(int value) {\n  switch(value) {\n    case 0:\n    case 1:\n    case 2:\n    case 3:\n      return true;\n    default:\n      return false;\n  }\n}\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst Field_Cardinality Field::CARDINALITY_UNKNOWN;\nconst Field_Cardinality Field::CARDINALITY_OPTIONAL;\nconst Field_Cardinality Field::CARDINALITY_REQUIRED;\nconst Field_Cardinality Field::CARDINALITY_REPEATED;\nconst Field_Cardinality Field::Cardinality_MIN;\nconst Field_Cardinality Field::Cardinality_MAX;\nconst int Field::Cardinality_ARRAYSIZE;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int Field::kKindFieldNumber;\nconst int Field::kCardinalityFieldNumber;\nconst int Field::kNumberFieldNumber;\nconst int Field::kNameFieldNumber;\nconst int Field::kTypeUrlFieldNumber;\nconst int Field::kOneofIndexFieldNumber;\nconst int Field::kPackedFieldNumber;\nconst int Field::kOptionsFieldNumber;\nconst int Field::kJsonNameFieldNumber;\nconst int Field::kDefaultValueFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nField::Field()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.Field)\n}\n\nvoid Field::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n}\n\nField::Field(const Field& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.Field)\n}\n\nvoid Field::SharedCtor() {\n    _is_default_instance_ = false;\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  kind_ = 0;\n  cardinality_ = 0;\n  number_ = 0;\n  name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  type_url_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  oneof_index_ = 0;\n  packed_ = false;\n  json_name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  default_value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n\nField::~Field() {\n  // @@protoc_insertion_point(destructor:google.protobuf.Field)\n  SharedDtor();\n}\n\nvoid Field::SharedDtor() {\n  name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  type_url_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  json_name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  default_value_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n  }\n}\n\nvoid Field::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* Field::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return Field_descriptor_;\n}\n\nconst Field& Field::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();\n  return *default_instance_;\n}\n\nField* Field::default_instance_ = NULL;\n\nField* Field::New(::google::protobuf::Arena* arena) const {\n  Field* n = new Field;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid Field::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.Field)\n#if defined(__clang__)\n#define ZR_HELPER_(f) \\\n  _Pragma(\"clang diagnostic push\") \\\n  _Pragma(\"clang diagnostic ignored \\\"-Winvalid-offsetof\\\"\") \\\n  __builtin_offsetof(Field, f) \\\n  _Pragma(\"clang diagnostic pop\")\n#else\n#define ZR_HELPER_(f) reinterpret_cast<char*>(\\\n  &reinterpret_cast<Field*>(16)->f)\n#endif\n\n#define ZR_(first, last) do {\\\n  ::memset(&first, 0,\\\n           ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\\\n} while (0)\n\n  ZR_(kind_, cardinality_);\n  ZR_(number_, oneof_index_);\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  packed_ = false;\n  json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n\n#undef ZR_HELPER_\n#undef ZR_\n\n  options_.Clear();\n}\n\nbool Field::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.Field)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional .google.protobuf.Field.Kind kind = 1;\n      case 1: {\n        if (tag == 8) {\n          int value;\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n                 input, &value)));\n          set_kind(static_cast< ::google::protobuf::Field_Kind >(value));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(16)) goto parse_cardinality;\n        break;\n      }\n\n      // optional .google.protobuf.Field.Cardinality cardinality = 2;\n      case 2: {\n        if (tag == 16) {\n         parse_cardinality:\n          int value;\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n                 input, &value)));\n          set_cardinality(static_cast< ::google::protobuf::Field_Cardinality >(value));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(24)) goto parse_number;\n        break;\n      }\n\n      // optional int32 number = 3;\n      case 3: {\n        if (tag == 24) {\n         parse_number:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 input, &number_)));\n\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(34)) goto parse_name;\n        break;\n      }\n\n      // optional string name = 4;\n      case 4: {\n        if (tag == 34) {\n         parse_name:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_name()));\n          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n            this->name().data(), this->name().length(),\n            ::google::protobuf::internal::WireFormatLite::PARSE,\n            \"google.protobuf.Field.name\"));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(50)) goto parse_type_url;\n        break;\n      }\n\n      // optional string type_url = 6;\n      case 6: {\n        if (tag == 50) {\n         parse_type_url:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_type_url()));\n          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n            this->type_url().data(), this->type_url().length(),\n            ::google::protobuf::internal::WireFormatLite::PARSE,\n            \"google.protobuf.Field.type_url\"));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(56)) goto parse_oneof_index;\n        break;\n      }\n\n      // optional int32 oneof_index = 7;\n      case 7: {\n        if (tag == 56) {\n         parse_oneof_index:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 input, &oneof_index_)));\n\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(64)) goto parse_packed;\n        break;\n      }\n\n      // optional bool packed = 8;\n      case 8: {\n        if (tag == 64) {\n         parse_packed:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &packed_)));\n\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(74)) goto parse_options;\n        break;\n      }\n\n      // repeated .google.protobuf.Option options = 9;\n      case 9: {\n        if (tag == 74) {\n         parse_options:\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_options:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_options()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(74)) goto parse_loop_options;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectTag(82)) goto parse_json_name;\n        break;\n      }\n\n      // optional string json_name = 10;\n      case 10: {\n        if (tag == 82) {\n         parse_json_name:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_json_name()));\n          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n            this->json_name().data(), this->json_name().length(),\n            ::google::protobuf::internal::WireFormatLite::PARSE,\n            \"google.protobuf.Field.json_name\"));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(90)) goto parse_default_value;\n        break;\n      }\n\n      // optional string default_value = 11;\n      case 11: {\n        if (tag == 90) {\n         parse_default_value:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_default_value()));\n          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n            this->default_value().data(), this->default_value().length(),\n            ::google::protobuf::internal::WireFormatLite::PARSE,\n            \"google.protobuf.Field.default_value\"));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.Field)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.Field)\n  return false;\n#undef DO_\n}\n\nvoid Field::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.Field)\n  // optional .google.protobuf.Field.Kind kind = 1;\n  if (this->kind() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteEnum(\n      1, this->kind(), output);\n  }\n\n  // optional .google.protobuf.Field.Cardinality cardinality = 2;\n  if (this->cardinality() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteEnum(\n      2, this->cardinality(), output);\n  }\n\n  // optional int32 number = 3;\n  if (this->number() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->number(), output);\n  }\n\n  // optional string name = 4;\n  if (this->name().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Field.name\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      4, this->name(), output);\n  }\n\n  // optional string type_url = 6;\n  if (this->type_url().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->type_url().data(), this->type_url().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Field.type_url\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      6, this->type_url(), output);\n  }\n\n  // optional int32 oneof_index = 7;\n  if (this->oneof_index() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt32(7, this->oneof_index(), output);\n  }\n\n  // optional bool packed = 8;\n  if (this->packed() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(8, this->packed(), output);\n  }\n\n  // repeated .google.protobuf.Option options = 9;\n  for (unsigned int i = 0, n = this->options_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      9, this->options(i), output);\n  }\n\n  // optional string json_name = 10;\n  if (this->json_name().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->json_name().data(), this->json_name().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Field.json_name\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      10, this->json_name(), output);\n  }\n\n  // optional string default_value = 11;\n  if (this->default_value().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->default_value().data(), this->default_value().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Field.default_value\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      11, this->default_value(), output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.Field)\n}\n\n::google::protobuf::uint8* Field::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Field)\n  // optional .google.protobuf.Field.Kind kind = 1;\n  if (this->kind() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(\n      1, this->kind(), target);\n  }\n\n  // optional .google.protobuf.Field.Cardinality cardinality = 2;\n  if (this->cardinality() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(\n      2, this->cardinality(), target);\n  }\n\n  // optional int32 number = 3;\n  if (this->number() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(3, this->number(), target);\n  }\n\n  // optional string name = 4;\n  if (this->name().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Field.name\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        4, this->name(), target);\n  }\n\n  // optional string type_url = 6;\n  if (this->type_url().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->type_url().data(), this->type_url().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Field.type_url\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        6, this->type_url(), target);\n  }\n\n  // optional int32 oneof_index = 7;\n  if (this->oneof_index() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(7, this->oneof_index(), target);\n  }\n\n  // optional bool packed = 8;\n  if (this->packed() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(8, this->packed(), target);\n  }\n\n  // repeated .google.protobuf.Option options = 9;\n  for (unsigned int i = 0, n = this->options_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        9, this->options(i), false, target);\n  }\n\n  // optional string json_name = 10;\n  if (this->json_name().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->json_name().data(), this->json_name().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Field.json_name\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        10, this->json_name(), target);\n  }\n\n  // optional string default_value = 11;\n  if (this->default_value().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->default_value().data(), this->default_value().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Field.default_value\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        11, this->default_value(), target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Field)\n  return target;\n}\n\nint Field::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Field)\n  int total_size = 0;\n\n  // optional .google.protobuf.Field.Kind kind = 1;\n  if (this->kind() != 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::EnumSize(this->kind());\n  }\n\n  // optional .google.protobuf.Field.Cardinality cardinality = 2;\n  if (this->cardinality() != 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::EnumSize(this->cardinality());\n  }\n\n  // optional int32 number = 3;\n  if (this->number() != 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::Int32Size(\n        this->number());\n  }\n\n  // optional string name = 4;\n  if (this->name().size() > 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::StringSize(\n        this->name());\n  }\n\n  // optional string type_url = 6;\n  if (this->type_url().size() > 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::StringSize(\n        this->type_url());\n  }\n\n  // optional int32 oneof_index = 7;\n  if (this->oneof_index() != 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::Int32Size(\n        this->oneof_index());\n  }\n\n  // optional bool packed = 8;\n  if (this->packed() != 0) {\n    total_size += 1 + 1;\n  }\n\n  // optional string json_name = 10;\n  if (this->json_name().size() > 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::StringSize(\n        this->json_name());\n  }\n\n  // optional string default_value = 11;\n  if (this->default_value().size() > 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::StringSize(\n        this->default_value());\n  }\n\n  // repeated .google.protobuf.Option options = 9;\n  total_size += 1 * this->options_size();\n  for (int i = 0; i < this->options_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->options(i));\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid Field::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Field)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const Field* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const Field>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.Field)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Field)\n    MergeFrom(*source);\n  }\n}\n\nvoid Field::MergeFrom(const Field& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Field)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  options_.MergeFrom(from.options_);\n  if (from.kind() != 0) {\n    set_kind(from.kind());\n  }\n  if (from.cardinality() != 0) {\n    set_cardinality(from.cardinality());\n  }\n  if (from.number() != 0) {\n    set_number(from.number());\n  }\n  if (from.name().size() > 0) {\n\n    name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);\n  }\n  if (from.type_url().size() > 0) {\n\n    type_url_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.type_url_);\n  }\n  if (from.oneof_index() != 0) {\n    set_oneof_index(from.oneof_index());\n  }\n  if (from.packed() != 0) {\n    set_packed(from.packed());\n  }\n  if (from.json_name().size() > 0) {\n\n    json_name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.json_name_);\n  }\n  if (from.default_value().size() > 0) {\n\n    default_value_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.default_value_);\n  }\n}\n\nvoid Field::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.Field)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid Field::CopyFrom(const Field& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Field)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool Field::IsInitialized() const {\n\n  return true;\n}\n\nvoid Field::Swap(Field* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid Field::InternalSwap(Field* other) {\n  std::swap(kind_, other->kind_);\n  std::swap(cardinality_, other->cardinality_);\n  std::swap(number_, other->number_);\n  name_.Swap(&other->name_);\n  type_url_.Swap(&other->type_url_);\n  std::swap(oneof_index_, other->oneof_index_);\n  std::swap(packed_, other->packed_);\n  options_.UnsafeArenaSwap(&other->options_);\n  json_name_.Swap(&other->json_name_);\n  default_value_.Swap(&other->default_value_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata Field::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = Field_descriptor_;\n  metadata.reflection = Field_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// Field\n\n// optional .google.protobuf.Field.Kind kind = 1;\nvoid Field::clear_kind() {\n  kind_ = 0;\n}\n ::google::protobuf::Field_Kind Field::kind() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Field.kind)\n  return static_cast< ::google::protobuf::Field_Kind >(kind_);\n}\n void Field::set_kind(::google::protobuf::Field_Kind value) {\n  \n  kind_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Field.kind)\n}\n\n// optional .google.protobuf.Field.Cardinality cardinality = 2;\nvoid Field::clear_cardinality() {\n  cardinality_ = 0;\n}\n ::google::protobuf::Field_Cardinality Field::cardinality() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Field.cardinality)\n  return static_cast< ::google::protobuf::Field_Cardinality >(cardinality_);\n}\n void Field::set_cardinality(::google::protobuf::Field_Cardinality value) {\n  \n  cardinality_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Field.cardinality)\n}\n\n// optional int32 number = 3;\nvoid Field::clear_number() {\n  number_ = 0;\n}\n ::google::protobuf::int32 Field::number() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Field.number)\n  return number_;\n}\n void Field::set_number(::google::protobuf::int32 value) {\n  \n  number_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Field.number)\n}\n\n// optional string name = 4;\nvoid Field::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n const ::std::string& Field::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Field.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Field::set_name(const ::std::string& value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Field.name)\n}\n void Field::set_name(const char* value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Field.name)\n}\n void Field::set_name(const char* value, size_t size) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.name)\n}\n ::std::string* Field::mutable_name() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Field.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* Field::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Field.name)\n  \n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Field::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    \n  } else {\n    \n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.name)\n}\n\n// optional string type_url = 6;\nvoid Field::clear_type_url() {\n  type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n const ::std::string& Field::type_url() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Field.type_url)\n  return type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Field::set_type_url(const ::std::string& value) {\n  \n  type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Field.type_url)\n}\n void Field::set_type_url(const char* value) {\n  \n  type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Field.type_url)\n}\n void Field::set_type_url(const char* value, size_t size) {\n  \n  type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.type_url)\n}\n ::std::string* Field::mutable_type_url() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Field.type_url)\n  return type_url_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* Field::release_type_url() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Field.type_url)\n  \n  return type_url_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Field::set_allocated_type_url(::std::string* type_url) {\n  if (type_url != NULL) {\n    \n  } else {\n    \n  }\n  type_url_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type_url);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.type_url)\n}\n\n// optional int32 oneof_index = 7;\nvoid Field::clear_oneof_index() {\n  oneof_index_ = 0;\n}\n ::google::protobuf::int32 Field::oneof_index() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Field.oneof_index)\n  return oneof_index_;\n}\n void Field::set_oneof_index(::google::protobuf::int32 value) {\n  \n  oneof_index_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Field.oneof_index)\n}\n\n// optional bool packed = 8;\nvoid Field::clear_packed() {\n  packed_ = false;\n}\n bool Field::packed() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Field.packed)\n  return packed_;\n}\n void Field::set_packed(bool value) {\n  \n  packed_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Field.packed)\n}\n\n// repeated .google.protobuf.Option options = 9;\nint Field::options_size() const {\n  return options_.size();\n}\nvoid Field::clear_options() {\n  options_.Clear();\n}\nconst ::google::protobuf::Option& Field::options(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Field.options)\n  return options_.Get(index);\n}\n::google::protobuf::Option* Field::mutable_options(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Field.options)\n  return options_.Mutable(index);\n}\n::google::protobuf::Option* Field::add_options() {\n  // @@protoc_insertion_point(field_add:google.protobuf.Field.options)\n  return options_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*\nField::mutable_options() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.Field.options)\n  return &options_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&\nField::options() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.Field.options)\n  return options_;\n}\n\n// optional string json_name = 10;\nvoid Field::clear_json_name() {\n  json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n const ::std::string& Field::json_name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Field.json_name)\n  return json_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Field::set_json_name(const ::std::string& value) {\n  \n  json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Field.json_name)\n}\n void Field::set_json_name(const char* value) {\n  \n  json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Field.json_name)\n}\n void Field::set_json_name(const char* value, size_t size) {\n  \n  json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.json_name)\n}\n ::std::string* Field::mutable_json_name() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Field.json_name)\n  return json_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* Field::release_json_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Field.json_name)\n  \n  return json_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Field::set_allocated_json_name(::std::string* json_name) {\n  if (json_name != NULL) {\n    \n  } else {\n    \n  }\n  json_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), json_name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.json_name)\n}\n\n// optional string default_value = 11;\nvoid Field::clear_default_value() {\n  default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n const ::std::string& Field::default_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Field.default_value)\n  return default_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Field::set_default_value(const ::std::string& value) {\n  \n  default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Field.default_value)\n}\n void Field::set_default_value(const char* value) {\n  \n  default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Field.default_value)\n}\n void Field::set_default_value(const char* value, size_t size) {\n  \n  default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.default_value)\n}\n ::std::string* Field::mutable_default_value() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Field.default_value)\n  return default_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* Field::release_default_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Field.default_value)\n  \n  return default_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Field::set_allocated_default_value(::std::string* default_value) {\n  if (default_value != NULL) {\n    \n  } else {\n    \n  }\n  default_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), default_value);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.default_value)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int Enum::kNameFieldNumber;\nconst int Enum::kEnumvalueFieldNumber;\nconst int Enum::kOptionsFieldNumber;\nconst int Enum::kSourceContextFieldNumber;\nconst int Enum::kSyntaxFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nEnum::Enum()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.Enum)\n}\n\nvoid Enum::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n  source_context_ = const_cast< ::google::protobuf::SourceContext*>(&::google::protobuf::SourceContext::default_instance());\n}\n\nEnum::Enum(const Enum& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.Enum)\n}\n\nvoid Enum::SharedCtor() {\n    _is_default_instance_ = false;\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  source_context_ = NULL;\n  syntax_ = 0;\n}\n\nEnum::~Enum() {\n  // @@protoc_insertion_point(destructor:google.protobuf.Enum)\n  SharedDtor();\n}\n\nvoid Enum::SharedDtor() {\n  name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n    delete source_context_;\n  }\n}\n\nvoid Enum::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* Enum::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return Enum_descriptor_;\n}\n\nconst Enum& Enum::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();\n  return *default_instance_;\n}\n\nEnum* Enum::default_instance_ = NULL;\n\nEnum* Enum::New(::google::protobuf::Arena* arena) const {\n  Enum* n = new Enum;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid Enum::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.Enum)\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_;\n  source_context_ = NULL;\n  syntax_ = 0;\n  enumvalue_.Clear();\n  options_.Clear();\n}\n\nbool Enum::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.Enum)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional string name = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_name()));\n          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n            this->name().data(), this->name().length(),\n            ::google::protobuf::internal::WireFormatLite::PARSE,\n            \"google.protobuf.Enum.name\"));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_enumvalue;\n        break;\n      }\n\n      // repeated .google.protobuf.EnumValue enumvalue = 2;\n      case 2: {\n        if (tag == 18) {\n         parse_enumvalue:\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_enumvalue:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_enumvalue()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_loop_enumvalue;\n        if (input->ExpectTag(26)) goto parse_loop_options;\n        input->UnsafeDecrementRecursionDepth();\n        break;\n      }\n\n      // repeated .google.protobuf.Option options = 3;\n      case 3: {\n        if (tag == 26) {\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_options:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_options()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(26)) goto parse_loop_options;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectTag(34)) goto parse_source_context;\n        break;\n      }\n\n      // optional .google.protobuf.SourceContext source_context = 4;\n      case 4: {\n        if (tag == 34) {\n         parse_source_context:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\n               input, mutable_source_context()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(40)) goto parse_syntax;\n        break;\n      }\n\n      // optional .google.protobuf.Syntax syntax = 5;\n      case 5: {\n        if (tag == 40) {\n         parse_syntax:\n          int value;\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   int, ::google::protobuf::internal::WireFormatLite::TYPE_ENUM>(\n                 input, &value)));\n          set_syntax(static_cast< ::google::protobuf::Syntax >(value));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.Enum)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.Enum)\n  return false;\n#undef DO_\n}\n\nvoid Enum::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.Enum)\n  // optional string name = 1;\n  if (this->name().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Enum.name\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      1, this->name(), output);\n  }\n\n  // repeated .google.protobuf.EnumValue enumvalue = 2;\n  for (unsigned int i = 0, n = this->enumvalue_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      2, this->enumvalue(i), output);\n  }\n\n  // repeated .google.protobuf.Option options = 3;\n  for (unsigned int i = 0, n = this->options_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      3, this->options(i), output);\n  }\n\n  // optional .google.protobuf.SourceContext source_context = 4;\n  if (this->has_source_context()) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      4, *this->source_context_, output);\n  }\n\n  // optional .google.protobuf.Syntax syntax = 5;\n  if (this->syntax() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteEnum(\n      5, this->syntax(), output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.Enum)\n}\n\n::google::protobuf::uint8* Enum::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Enum)\n  // optional string name = 1;\n  if (this->name().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Enum.name\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        1, this->name(), target);\n  }\n\n  // repeated .google.protobuf.EnumValue enumvalue = 2;\n  for (unsigned int i = 0, n = this->enumvalue_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        2, this->enumvalue(i), false, target);\n  }\n\n  // repeated .google.protobuf.Option options = 3;\n  for (unsigned int i = 0, n = this->options_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        3, this->options(i), false, target);\n  }\n\n  // optional .google.protobuf.SourceContext source_context = 4;\n  if (this->has_source_context()) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        4, *this->source_context_, false, target);\n  }\n\n  // optional .google.protobuf.Syntax syntax = 5;\n  if (this->syntax() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteEnumToArray(\n      5, this->syntax(), target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Enum)\n  return target;\n}\n\nint Enum::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Enum)\n  int total_size = 0;\n\n  // optional string name = 1;\n  if (this->name().size() > 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::StringSize(\n        this->name());\n  }\n\n  // optional .google.protobuf.SourceContext source_context = 4;\n  if (this->has_source_context()) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        *this->source_context_);\n  }\n\n  // optional .google.protobuf.Syntax syntax = 5;\n  if (this->syntax() != 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::EnumSize(this->syntax());\n  }\n\n  // repeated .google.protobuf.EnumValue enumvalue = 2;\n  total_size += 1 * this->enumvalue_size();\n  for (int i = 0; i < this->enumvalue_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->enumvalue(i));\n  }\n\n  // repeated .google.protobuf.Option options = 3;\n  total_size += 1 * this->options_size();\n  for (int i = 0; i < this->options_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->options(i));\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid Enum::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Enum)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const Enum* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const Enum>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.Enum)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Enum)\n    MergeFrom(*source);\n  }\n}\n\nvoid Enum::MergeFrom(const Enum& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Enum)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  enumvalue_.MergeFrom(from.enumvalue_);\n  options_.MergeFrom(from.options_);\n  if (from.name().size() > 0) {\n\n    name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);\n  }\n  if (from.has_source_context()) {\n    mutable_source_context()->::google::protobuf::SourceContext::MergeFrom(from.source_context());\n  }\n  if (from.syntax() != 0) {\n    set_syntax(from.syntax());\n  }\n}\n\nvoid Enum::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.Enum)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid Enum::CopyFrom(const Enum& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Enum)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool Enum::IsInitialized() const {\n\n  return true;\n}\n\nvoid Enum::Swap(Enum* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid Enum::InternalSwap(Enum* other) {\n  name_.Swap(&other->name_);\n  enumvalue_.UnsafeArenaSwap(&other->enumvalue_);\n  options_.UnsafeArenaSwap(&other->options_);\n  std::swap(source_context_, other->source_context_);\n  std::swap(syntax_, other->syntax_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata Enum::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = Enum_descriptor_;\n  metadata.reflection = Enum_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// Enum\n\n// optional string name = 1;\nvoid Enum::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n const ::std::string& Enum::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Enum.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Enum::set_name(const ::std::string& value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Enum.name)\n}\n void Enum::set_name(const char* value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Enum.name)\n}\n void Enum::set_name(const char* value, size_t size) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Enum.name)\n}\n ::std::string* Enum::mutable_name() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* Enum::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Enum.name)\n  \n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Enum::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    \n  } else {\n    \n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.name)\n}\n\n// repeated .google.protobuf.EnumValue enumvalue = 2;\nint Enum::enumvalue_size() const {\n  return enumvalue_.size();\n}\nvoid Enum::clear_enumvalue() {\n  enumvalue_.Clear();\n}\nconst ::google::protobuf::EnumValue& Enum::enumvalue(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Enum.enumvalue)\n  return enumvalue_.Get(index);\n}\n::google::protobuf::EnumValue* Enum::mutable_enumvalue(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.enumvalue)\n  return enumvalue_.Mutable(index);\n}\n::google::protobuf::EnumValue* Enum::add_enumvalue() {\n  // @@protoc_insertion_point(field_add:google.protobuf.Enum.enumvalue)\n  return enumvalue_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValue >*\nEnum::mutable_enumvalue() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.Enum.enumvalue)\n  return &enumvalue_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValue >&\nEnum::enumvalue() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.Enum.enumvalue)\n  return enumvalue_;\n}\n\n// repeated .google.protobuf.Option options = 3;\nint Enum::options_size() const {\n  return options_.size();\n}\nvoid Enum::clear_options() {\n  options_.Clear();\n}\nconst ::google::protobuf::Option& Enum::options(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Enum.options)\n  return options_.Get(index);\n}\n::google::protobuf::Option* Enum::mutable_options(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.options)\n  return options_.Mutable(index);\n}\n::google::protobuf::Option* Enum::add_options() {\n  // @@protoc_insertion_point(field_add:google.protobuf.Enum.options)\n  return options_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*\nEnum::mutable_options() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.Enum.options)\n  return &options_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&\nEnum::options() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.Enum.options)\n  return options_;\n}\n\n// optional .google.protobuf.SourceContext source_context = 4;\nbool Enum::has_source_context() const {\n  return !_is_default_instance_ && source_context_ != NULL;\n}\nvoid Enum::clear_source_context() {\n  if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_;\n  source_context_ = NULL;\n}\nconst ::google::protobuf::SourceContext& Enum::source_context() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Enum.source_context)\n  return source_context_ != NULL ? *source_context_ : *default_instance_->source_context_;\n}\n::google::protobuf::SourceContext* Enum::mutable_source_context() {\n  \n  if (source_context_ == NULL) {\n    source_context_ = new ::google::protobuf::SourceContext;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.source_context)\n  return source_context_;\n}\n::google::protobuf::SourceContext* Enum::release_source_context() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Enum.source_context)\n  \n  ::google::protobuf::SourceContext* temp = source_context_;\n  source_context_ = NULL;\n  return temp;\n}\nvoid Enum::set_allocated_source_context(::google::protobuf::SourceContext* source_context) {\n  delete source_context_;\n  source_context_ = source_context;\n  if (source_context) {\n    \n  } else {\n    \n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.source_context)\n}\n\n// optional .google.protobuf.Syntax syntax = 5;\nvoid Enum::clear_syntax() {\n  syntax_ = 0;\n}\n ::google::protobuf::Syntax Enum::syntax() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Enum.syntax)\n  return static_cast< ::google::protobuf::Syntax >(syntax_);\n}\n void Enum::set_syntax(::google::protobuf::Syntax value) {\n  \n  syntax_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Enum.syntax)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int EnumValue::kNameFieldNumber;\nconst int EnumValue::kNumberFieldNumber;\nconst int EnumValue::kOptionsFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nEnumValue::EnumValue()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.EnumValue)\n}\n\nvoid EnumValue::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n}\n\nEnumValue::EnumValue(const EnumValue& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.EnumValue)\n}\n\nvoid EnumValue::SharedCtor() {\n    _is_default_instance_ = false;\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  number_ = 0;\n}\n\nEnumValue::~EnumValue() {\n  // @@protoc_insertion_point(destructor:google.protobuf.EnumValue)\n  SharedDtor();\n}\n\nvoid EnumValue::SharedDtor() {\n  name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n  }\n}\n\nvoid EnumValue::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* EnumValue::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return EnumValue_descriptor_;\n}\n\nconst EnumValue& EnumValue::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();\n  return *default_instance_;\n}\n\nEnumValue* EnumValue::default_instance_ = NULL;\n\nEnumValue* EnumValue::New(::google::protobuf::Arena* arena) const {\n  EnumValue* n = new EnumValue;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid EnumValue::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.EnumValue)\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  number_ = 0;\n  options_.Clear();\n}\n\nbool EnumValue::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.EnumValue)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional string name = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_name()));\n          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n            this->name().data(), this->name().length(),\n            ::google::protobuf::internal::WireFormatLite::PARSE,\n            \"google.protobuf.EnumValue.name\"));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(16)) goto parse_number;\n        break;\n      }\n\n      // optional int32 number = 2;\n      case 2: {\n        if (tag == 16) {\n         parse_number:\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 input, &number_)));\n\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(26)) goto parse_options;\n        break;\n      }\n\n      // repeated .google.protobuf.Option options = 3;\n      case 3: {\n        if (tag == 26) {\n         parse_options:\n          DO_(input->IncrementRecursionDepth());\n         parse_loop_options:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n                input, add_options()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(26)) goto parse_loop_options;\n        input->UnsafeDecrementRecursionDepth();\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.EnumValue)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.EnumValue)\n  return false;\n#undef DO_\n}\n\nvoid EnumValue::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.EnumValue)\n  // optional string name = 1;\n  if (this->name().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.EnumValue.name\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      1, this->name(), output);\n  }\n\n  // optional int32 number = 2;\n  if (this->number() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt32(2, this->number(), output);\n  }\n\n  // repeated .google.protobuf.Option options = 3;\n  for (unsigned int i = 0, n = this->options_size(); i < n; i++) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      3, this->options(i), output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.EnumValue)\n}\n\n::google::protobuf::uint8* EnumValue::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.EnumValue)\n  // optional string name = 1;\n  if (this->name().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.EnumValue.name\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        1, this->name(), target);\n  }\n\n  // optional int32 number = 2;\n  if (this->number() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(2, this->number(), target);\n  }\n\n  // repeated .google.protobuf.Option options = 3;\n  for (unsigned int i = 0, n = this->options_size(); i < n; i++) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        3, this->options(i), false, target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.EnumValue)\n  return target;\n}\n\nint EnumValue::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.EnumValue)\n  int total_size = 0;\n\n  // optional string name = 1;\n  if (this->name().size() > 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::StringSize(\n        this->name());\n  }\n\n  // optional int32 number = 2;\n  if (this->number() != 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::Int32Size(\n        this->number());\n  }\n\n  // repeated .google.protobuf.Option options = 3;\n  total_size += 1 * this->options_size();\n  for (int i = 0; i < this->options_size(); i++) {\n    total_size +=\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        this->options(i));\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid EnumValue::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.EnumValue)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const EnumValue* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const EnumValue>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.EnumValue)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.EnumValue)\n    MergeFrom(*source);\n  }\n}\n\nvoid EnumValue::MergeFrom(const EnumValue& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.EnumValue)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  options_.MergeFrom(from.options_);\n  if (from.name().size() > 0) {\n\n    name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);\n  }\n  if (from.number() != 0) {\n    set_number(from.number());\n  }\n}\n\nvoid EnumValue::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.EnumValue)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid EnumValue::CopyFrom(const EnumValue& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.EnumValue)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool EnumValue::IsInitialized() const {\n\n  return true;\n}\n\nvoid EnumValue::Swap(EnumValue* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid EnumValue::InternalSwap(EnumValue* other) {\n  name_.Swap(&other->name_);\n  std::swap(number_, other->number_);\n  options_.UnsafeArenaSwap(&other->options_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata EnumValue::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = EnumValue_descriptor_;\n  metadata.reflection = EnumValue_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// EnumValue\n\n// optional string name = 1;\nvoid EnumValue::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n const ::std::string& EnumValue::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void EnumValue::set_name(const ::std::string& value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.EnumValue.name)\n}\n void EnumValue::set_name(const char* value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.EnumValue.name)\n}\n void EnumValue::set_name(const char* value, size_t size) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumValue.name)\n}\n ::std::string* EnumValue::mutable_name() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValue.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* EnumValue::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.EnumValue.name)\n  \n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void EnumValue::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    \n  } else {\n    \n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValue.name)\n}\n\n// optional int32 number = 2;\nvoid EnumValue::clear_number() {\n  number_ = 0;\n}\n ::google::protobuf::int32 EnumValue::number() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.number)\n  return number_;\n}\n void EnumValue::set_number(::google::protobuf::int32 value) {\n  \n  number_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.EnumValue.number)\n}\n\n// repeated .google.protobuf.Option options = 3;\nint EnumValue::options_size() const {\n  return options_.size();\n}\nvoid EnumValue::clear_options() {\n  options_.Clear();\n}\nconst ::google::protobuf::Option& EnumValue::options(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.options)\n  return options_.Get(index);\n}\n::google::protobuf::Option* EnumValue::mutable_options(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValue.options)\n  return options_.Mutable(index);\n}\n::google::protobuf::Option* EnumValue::add_options() {\n  // @@protoc_insertion_point(field_add:google.protobuf.EnumValue.options)\n  return options_.Add();\n}\n::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*\nEnumValue::mutable_options() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumValue.options)\n  return &options_;\n}\nconst ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&\nEnumValue::options() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.EnumValue.options)\n  return options_;\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int Option::kNameFieldNumber;\nconst int Option::kValueFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nOption::Option()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.Option)\n}\n\nvoid Option::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n  value_ = const_cast< ::google::protobuf::Any*>(&::google::protobuf::Any::default_instance());\n}\n\nOption::Option(const Option& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.Option)\n}\n\nvoid Option::SharedCtor() {\n    _is_default_instance_ = false;\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  name_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  value_ = NULL;\n}\n\nOption::~Option() {\n  // @@protoc_insertion_point(destructor:google.protobuf.Option)\n  SharedDtor();\n}\n\nvoid Option::SharedDtor() {\n  name_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (this != default_instance_) {\n    delete value_;\n  }\n}\n\nvoid Option::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* Option::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return Option_descriptor_;\n}\n\nconst Option& Option::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();\n  return *default_instance_;\n}\n\nOption* Option::default_instance_ = NULL;\n\nOption* Option::New(::google::protobuf::Arena* arena) const {\n  Option* n = new Option;\n  if (arena != NULL) {\n    arena->Own(n);\n  }\n  return n;\n}\n\nvoid Option::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.Option)\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n  if (GetArenaNoVirtual() == NULL && value_ != NULL) delete value_;\n  value_ = NULL;\n}\n\nbool Option::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.Option)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional string name = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_name()));\n          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n            this->name().data(), this->name().length(),\n            ::google::protobuf::internal::WireFormatLite::PARSE,\n            \"google.protobuf.Option.name\"));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectTag(18)) goto parse_value;\n        break;\n      }\n\n      // optional .google.protobuf.Any value = 2;\n      case 2: {\n        if (tag == 18) {\n         parse_value:\n          DO_(::google::protobuf::internal::WireFormatLite::ReadMessageNoVirtual(\n               input, mutable_value()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.Option)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.Option)\n  return false;\n#undef DO_\n}\n\nvoid Option::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.Option)\n  // optional string name = 1;\n  if (this->name().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Option.name\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      1, this->name(), output);\n  }\n\n  // optional .google.protobuf.Any value = 2;\n  if (this->has_value()) {\n    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n      2, *this->value_, output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.Option)\n}\n\n::google::protobuf::uint8* Option::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Option)\n  // optional string name = 1;\n  if (this->name().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->name().data(), this->name().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.Option.name\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        1, this->name(), target);\n  }\n\n  // optional .google.protobuf.Any value = 2;\n  if (this->has_value()) {\n    target = ::google::protobuf::internal::WireFormatLite::\n      InternalWriteMessageNoVirtualToArray(\n        2, *this->value_, false, target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Option)\n  return target;\n}\n\nint Option::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Option)\n  int total_size = 0;\n\n  // optional string name = 1;\n  if (this->name().size() > 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::StringSize(\n        this->name());\n  }\n\n  // optional .google.protobuf.Any value = 2;\n  if (this->has_value()) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(\n        *this->value_);\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid Option::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Option)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const Option* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const Option>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.Option)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Option)\n    MergeFrom(*source);\n  }\n}\n\nvoid Option::MergeFrom(const Option& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Option)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from.name().size() > 0) {\n\n    name_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.name_);\n  }\n  if (from.has_value()) {\n    mutable_value()->::google::protobuf::Any::MergeFrom(from.value());\n  }\n}\n\nvoid Option::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.Option)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid Option::CopyFrom(const Option& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Option)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool Option::IsInitialized() const {\n\n  return true;\n}\n\nvoid Option::Swap(Option* other) {\n  if (other == this) return;\n  InternalSwap(other);\n}\nvoid Option::InternalSwap(Option* other) {\n  name_.Swap(&other->name_);\n  std::swap(value_, other->value_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata Option::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = Option_descriptor_;\n  metadata.reflection = Option_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// Option\n\n// optional string name = 1;\nvoid Option::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n const ::std::string& Option::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Option.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Option::set_name(const ::std::string& value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Option.name)\n}\n void Option::set_name(const char* value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Option.name)\n}\n void Option::set_name(const char* value, size_t size) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Option.name)\n}\n ::std::string* Option::mutable_name() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Option.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n ::std::string* Option::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Option.name)\n  \n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void Option::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    \n  } else {\n    \n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.name)\n}\n\n// optional .google.protobuf.Any value = 2;\nbool Option::has_value() const {\n  return !_is_default_instance_ && value_ != NULL;\n}\nvoid Option::clear_value() {\n  if (GetArenaNoVirtual() == NULL && value_ != NULL) delete value_;\n  value_ = NULL;\n}\nconst ::google::protobuf::Any& Option::value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Option.value)\n  return value_ != NULL ? *value_ : *default_instance_->value_;\n}\n::google::protobuf::Any* Option::mutable_value() {\n  \n  if (value_ == NULL) {\n    value_ = new ::google::protobuf::Any;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Option.value)\n  return value_;\n}\n::google::protobuf::Any* Option::release_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Option.value)\n  \n  ::google::protobuf::Any* temp = value_;\n  value_ = NULL;\n  return temp;\n}\nvoid Option::set_allocated_value(::google::protobuf::Any* value) {\n  delete value_;\n  value_ = value;\n  if (value) {\n    \n  } else {\n    \n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.value)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace protobuf\n}  // namespace google\n\n// @@protoc_insertion_point(global_scope)\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/type.pb.h",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/type.proto\n\n#ifndef PROTOBUF_google_2fprotobuf_2ftype_2eproto__INCLUDED\n#define PROTOBUF_google_2fprotobuf_2ftype_2eproto__INCLUDED\n\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n\n#if GOOGLE_PROTOBUF_VERSION < 3000000\n#error This file was generated by a newer version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please update\n#error your headers.\n#endif\n#if 3000000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION\n#error This file was generated by an older version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please\n#error regenerate this file with a newer version of protoc.\n#endif\n\n#include <google/protobuf/arena.h>\n#include <google/protobuf/arenastring.h>\n#include <google/protobuf/generated_message_util.h>\n#include <google/protobuf/metadata.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/extension_set.h>\n#include <google/protobuf/generated_enum_reflection.h>\n#include <google/protobuf/unknown_field_set.h>\n#include <google/protobuf/any.pb.h>\n#include <google/protobuf/source_context.pb.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\n\n// Internal implementation detail -- do not call these.\nvoid LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();\nvoid protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto();\nvoid protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto();\n\nclass Enum;\nclass EnumValue;\nclass Field;\nclass Option;\nclass Type;\n\nenum Field_Kind {\n  Field_Kind_TYPE_UNKNOWN = 0,\n  Field_Kind_TYPE_DOUBLE = 1,\n  Field_Kind_TYPE_FLOAT = 2,\n  Field_Kind_TYPE_INT64 = 3,\n  Field_Kind_TYPE_UINT64 = 4,\n  Field_Kind_TYPE_INT32 = 5,\n  Field_Kind_TYPE_FIXED64 = 6,\n  Field_Kind_TYPE_FIXED32 = 7,\n  Field_Kind_TYPE_BOOL = 8,\n  Field_Kind_TYPE_STRING = 9,\n  Field_Kind_TYPE_GROUP = 10,\n  Field_Kind_TYPE_MESSAGE = 11,\n  Field_Kind_TYPE_BYTES = 12,\n  Field_Kind_TYPE_UINT32 = 13,\n  Field_Kind_TYPE_ENUM = 14,\n  Field_Kind_TYPE_SFIXED32 = 15,\n  Field_Kind_TYPE_SFIXED64 = 16,\n  Field_Kind_TYPE_SINT32 = 17,\n  Field_Kind_TYPE_SINT64 = 18,\n  Field_Kind_Field_Kind_INT_MIN_SENTINEL_DO_NOT_USE_ = ::google::protobuf::kint32min,\n  Field_Kind_Field_Kind_INT_MAX_SENTINEL_DO_NOT_USE_ = ::google::protobuf::kint32max\n};\nLIBPROTOBUF_EXPORT bool Field_Kind_IsValid(int value);\nconst Field_Kind Field_Kind_Kind_MIN = Field_Kind_TYPE_UNKNOWN;\nconst Field_Kind Field_Kind_Kind_MAX = Field_Kind_TYPE_SINT64;\nconst int Field_Kind_Kind_ARRAYSIZE = Field_Kind_Kind_MAX + 1;\n\nLIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* Field_Kind_descriptor();\ninline const ::std::string& Field_Kind_Name(Field_Kind value) {\n  return ::google::protobuf::internal::NameOfEnum(\n    Field_Kind_descriptor(), value);\n}\ninline bool Field_Kind_Parse(\n    const ::std::string& name, Field_Kind* value) {\n  return ::google::protobuf::internal::ParseNamedEnum<Field_Kind>(\n    Field_Kind_descriptor(), name, value);\n}\nenum Field_Cardinality {\n  Field_Cardinality_CARDINALITY_UNKNOWN = 0,\n  Field_Cardinality_CARDINALITY_OPTIONAL = 1,\n  Field_Cardinality_CARDINALITY_REQUIRED = 2,\n  Field_Cardinality_CARDINALITY_REPEATED = 3,\n  Field_Cardinality_Field_Cardinality_INT_MIN_SENTINEL_DO_NOT_USE_ = ::google::protobuf::kint32min,\n  Field_Cardinality_Field_Cardinality_INT_MAX_SENTINEL_DO_NOT_USE_ = ::google::protobuf::kint32max\n};\nLIBPROTOBUF_EXPORT bool Field_Cardinality_IsValid(int value);\nconst Field_Cardinality Field_Cardinality_Cardinality_MIN = Field_Cardinality_CARDINALITY_UNKNOWN;\nconst Field_Cardinality Field_Cardinality_Cardinality_MAX = Field_Cardinality_CARDINALITY_REPEATED;\nconst int Field_Cardinality_Cardinality_ARRAYSIZE = Field_Cardinality_Cardinality_MAX + 1;\n\nLIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* Field_Cardinality_descriptor();\ninline const ::std::string& Field_Cardinality_Name(Field_Cardinality value) {\n  return ::google::protobuf::internal::NameOfEnum(\n    Field_Cardinality_descriptor(), value);\n}\ninline bool Field_Cardinality_Parse(\n    const ::std::string& name, Field_Cardinality* value) {\n  return ::google::protobuf::internal::ParseNamedEnum<Field_Cardinality>(\n    Field_Cardinality_descriptor(), name, value);\n}\nenum Syntax {\n  SYNTAX_PROTO2 = 0,\n  SYNTAX_PROTO3 = 1,\n  Syntax_INT_MIN_SENTINEL_DO_NOT_USE_ = ::google::protobuf::kint32min,\n  Syntax_INT_MAX_SENTINEL_DO_NOT_USE_ = ::google::protobuf::kint32max\n};\nLIBPROTOBUF_EXPORT bool Syntax_IsValid(int value);\nconst Syntax Syntax_MIN = SYNTAX_PROTO2;\nconst Syntax Syntax_MAX = SYNTAX_PROTO3;\nconst int Syntax_ARRAYSIZE = Syntax_MAX + 1;\n\nLIBPROTOBUF_EXPORT const ::google::protobuf::EnumDescriptor* Syntax_descriptor();\ninline const ::std::string& Syntax_Name(Syntax value) {\n  return ::google::protobuf::internal::NameOfEnum(\n    Syntax_descriptor(), value);\n}\ninline bool Syntax_Parse(\n    const ::std::string& name, Syntax* value) {\n  return ::google::protobuf::internal::ParseNamedEnum<Syntax>(\n    Syntax_descriptor(), name, value);\n}\n// ===================================================================\n\nclass LIBPROTOBUF_EXPORT Type : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Type) */ {\n public:\n  Type();\n  virtual ~Type();\n\n  Type(const Type& from);\n\n  inline Type& operator=(const Type& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const Type& default_instance();\n\n  void Swap(Type* other);\n\n  // implements Message ----------------------------------------------\n\n  inline Type* New() const { return New(NULL); }\n\n  Type* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const Type& from);\n  void MergeFrom(const Type& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(Type* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional string name = 1;\n  void clear_name();\n  static const int kNameFieldNumber = 1;\n  const ::std::string& name() const;\n  void set_name(const ::std::string& value);\n  void set_name(const char* value);\n  void set_name(const char* value, size_t size);\n  ::std::string* mutable_name();\n  ::std::string* release_name();\n  void set_allocated_name(::std::string* name);\n\n  // repeated .google.protobuf.Field fields = 2;\n  int fields_size() const;\n  void clear_fields();\n  static const int kFieldsFieldNumber = 2;\n  const ::google::protobuf::Field& fields(int index) const;\n  ::google::protobuf::Field* mutable_fields(int index);\n  ::google::protobuf::Field* add_fields();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Field >*\n      mutable_fields();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Field >&\n      fields() const;\n\n  // repeated string oneofs = 3;\n  int oneofs_size() const;\n  void clear_oneofs();\n  static const int kOneofsFieldNumber = 3;\n  const ::std::string& oneofs(int index) const;\n  ::std::string* mutable_oneofs(int index);\n  void set_oneofs(int index, const ::std::string& value);\n  void set_oneofs(int index, const char* value);\n  void set_oneofs(int index, const char* value, size_t size);\n  ::std::string* add_oneofs();\n  void add_oneofs(const ::std::string& value);\n  void add_oneofs(const char* value);\n  void add_oneofs(const char* value, size_t size);\n  const ::google::protobuf::RepeatedPtrField< ::std::string>& oneofs() const;\n  ::google::protobuf::RepeatedPtrField< ::std::string>* mutable_oneofs();\n\n  // repeated .google.protobuf.Option options = 4;\n  int options_size() const;\n  void clear_options();\n  static const int kOptionsFieldNumber = 4;\n  const ::google::protobuf::Option& options(int index) const;\n  ::google::protobuf::Option* mutable_options(int index);\n  ::google::protobuf::Option* add_options();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*\n      mutable_options();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&\n      options() const;\n\n  // optional .google.protobuf.SourceContext source_context = 5;\n  bool has_source_context() const;\n  void clear_source_context();\n  static const int kSourceContextFieldNumber = 5;\n  const ::google::protobuf::SourceContext& source_context() const;\n  ::google::protobuf::SourceContext* mutable_source_context();\n  ::google::protobuf::SourceContext* release_source_context();\n  void set_allocated_source_context(::google::protobuf::SourceContext* source_context);\n\n  // optional .google.protobuf.Syntax syntax = 6;\n  void clear_syntax();\n  static const int kSyntaxFieldNumber = 6;\n  ::google::protobuf::Syntax syntax() const;\n  void set_syntax(::google::protobuf::Syntax value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.Type)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  bool _is_default_instance_;\n  ::google::protobuf::internal::ArenaStringPtr name_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Field > fields_;\n  ::google::protobuf::RepeatedPtrField< ::std::string> oneofs_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_;\n  ::google::protobuf::SourceContext* source_context_;\n  int syntax_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto();\n\n  void InitAsDefaultInstance();\n  static Type* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT Field : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Field) */ {\n public:\n  Field();\n  virtual ~Field();\n\n  Field(const Field& from);\n\n  inline Field& operator=(const Field& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const Field& default_instance();\n\n  void Swap(Field* other);\n\n  // implements Message ----------------------------------------------\n\n  inline Field* New() const { return New(NULL); }\n\n  Field* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const Field& from);\n  void MergeFrom(const Field& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(Field* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  typedef Field_Kind Kind;\n  static const Kind TYPE_UNKNOWN =\n    Field_Kind_TYPE_UNKNOWN;\n  static const Kind TYPE_DOUBLE =\n    Field_Kind_TYPE_DOUBLE;\n  static const Kind TYPE_FLOAT =\n    Field_Kind_TYPE_FLOAT;\n  static const Kind TYPE_INT64 =\n    Field_Kind_TYPE_INT64;\n  static const Kind TYPE_UINT64 =\n    Field_Kind_TYPE_UINT64;\n  static const Kind TYPE_INT32 =\n    Field_Kind_TYPE_INT32;\n  static const Kind TYPE_FIXED64 =\n    Field_Kind_TYPE_FIXED64;\n  static const Kind TYPE_FIXED32 =\n    Field_Kind_TYPE_FIXED32;\n  static const Kind TYPE_BOOL =\n    Field_Kind_TYPE_BOOL;\n  static const Kind TYPE_STRING =\n    Field_Kind_TYPE_STRING;\n  static const Kind TYPE_GROUP =\n    Field_Kind_TYPE_GROUP;\n  static const Kind TYPE_MESSAGE =\n    Field_Kind_TYPE_MESSAGE;\n  static const Kind TYPE_BYTES =\n    Field_Kind_TYPE_BYTES;\n  static const Kind TYPE_UINT32 =\n    Field_Kind_TYPE_UINT32;\n  static const Kind TYPE_ENUM =\n    Field_Kind_TYPE_ENUM;\n  static const Kind TYPE_SFIXED32 =\n    Field_Kind_TYPE_SFIXED32;\n  static const Kind TYPE_SFIXED64 =\n    Field_Kind_TYPE_SFIXED64;\n  static const Kind TYPE_SINT32 =\n    Field_Kind_TYPE_SINT32;\n  static const Kind TYPE_SINT64 =\n    Field_Kind_TYPE_SINT64;\n  static inline bool Kind_IsValid(int value) {\n    return Field_Kind_IsValid(value);\n  }\n  static const Kind Kind_MIN =\n    Field_Kind_Kind_MIN;\n  static const Kind Kind_MAX =\n    Field_Kind_Kind_MAX;\n  static const int Kind_ARRAYSIZE =\n    Field_Kind_Kind_ARRAYSIZE;\n  static inline const ::google::protobuf::EnumDescriptor*\n  Kind_descriptor() {\n    return Field_Kind_descriptor();\n  }\n  static inline const ::std::string& Kind_Name(Kind value) {\n    return Field_Kind_Name(value);\n  }\n  static inline bool Kind_Parse(const ::std::string& name,\n      Kind* value) {\n    return Field_Kind_Parse(name, value);\n  }\n\n  typedef Field_Cardinality Cardinality;\n  static const Cardinality CARDINALITY_UNKNOWN =\n    Field_Cardinality_CARDINALITY_UNKNOWN;\n  static const Cardinality CARDINALITY_OPTIONAL =\n    Field_Cardinality_CARDINALITY_OPTIONAL;\n  static const Cardinality CARDINALITY_REQUIRED =\n    Field_Cardinality_CARDINALITY_REQUIRED;\n  static const Cardinality CARDINALITY_REPEATED =\n    Field_Cardinality_CARDINALITY_REPEATED;\n  static inline bool Cardinality_IsValid(int value) {\n    return Field_Cardinality_IsValid(value);\n  }\n  static const Cardinality Cardinality_MIN =\n    Field_Cardinality_Cardinality_MIN;\n  static const Cardinality Cardinality_MAX =\n    Field_Cardinality_Cardinality_MAX;\n  static const int Cardinality_ARRAYSIZE =\n    Field_Cardinality_Cardinality_ARRAYSIZE;\n  static inline const ::google::protobuf::EnumDescriptor*\n  Cardinality_descriptor() {\n    return Field_Cardinality_descriptor();\n  }\n  static inline const ::std::string& Cardinality_Name(Cardinality value) {\n    return Field_Cardinality_Name(value);\n  }\n  static inline bool Cardinality_Parse(const ::std::string& name,\n      Cardinality* value) {\n    return Field_Cardinality_Parse(name, value);\n  }\n\n  // accessors -------------------------------------------------------\n\n  // optional .google.protobuf.Field.Kind kind = 1;\n  void clear_kind();\n  static const int kKindFieldNumber = 1;\n  ::google::protobuf::Field_Kind kind() const;\n  void set_kind(::google::protobuf::Field_Kind value);\n\n  // optional .google.protobuf.Field.Cardinality cardinality = 2;\n  void clear_cardinality();\n  static const int kCardinalityFieldNumber = 2;\n  ::google::protobuf::Field_Cardinality cardinality() const;\n  void set_cardinality(::google::protobuf::Field_Cardinality value);\n\n  // optional int32 number = 3;\n  void clear_number();\n  static const int kNumberFieldNumber = 3;\n  ::google::protobuf::int32 number() const;\n  void set_number(::google::protobuf::int32 value);\n\n  // optional string name = 4;\n  void clear_name();\n  static const int kNameFieldNumber = 4;\n  const ::std::string& name() const;\n  void set_name(const ::std::string& value);\n  void set_name(const char* value);\n  void set_name(const char* value, size_t size);\n  ::std::string* mutable_name();\n  ::std::string* release_name();\n  void set_allocated_name(::std::string* name);\n\n  // optional string type_url = 6;\n  void clear_type_url();\n  static const int kTypeUrlFieldNumber = 6;\n  const ::std::string& type_url() const;\n  void set_type_url(const ::std::string& value);\n  void set_type_url(const char* value);\n  void set_type_url(const char* value, size_t size);\n  ::std::string* mutable_type_url();\n  ::std::string* release_type_url();\n  void set_allocated_type_url(::std::string* type_url);\n\n  // optional int32 oneof_index = 7;\n  void clear_oneof_index();\n  static const int kOneofIndexFieldNumber = 7;\n  ::google::protobuf::int32 oneof_index() const;\n  void set_oneof_index(::google::protobuf::int32 value);\n\n  // optional bool packed = 8;\n  void clear_packed();\n  static const int kPackedFieldNumber = 8;\n  bool packed() const;\n  void set_packed(bool value);\n\n  // repeated .google.protobuf.Option options = 9;\n  int options_size() const;\n  void clear_options();\n  static const int kOptionsFieldNumber = 9;\n  const ::google::protobuf::Option& options(int index) const;\n  ::google::protobuf::Option* mutable_options(int index);\n  ::google::protobuf::Option* add_options();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*\n      mutable_options();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&\n      options() const;\n\n  // optional string json_name = 10;\n  void clear_json_name();\n  static const int kJsonNameFieldNumber = 10;\n  const ::std::string& json_name() const;\n  void set_json_name(const ::std::string& value);\n  void set_json_name(const char* value);\n  void set_json_name(const char* value, size_t size);\n  ::std::string* mutable_json_name();\n  ::std::string* release_json_name();\n  void set_allocated_json_name(::std::string* json_name);\n\n  // optional string default_value = 11;\n  void clear_default_value();\n  static const int kDefaultValueFieldNumber = 11;\n  const ::std::string& default_value() const;\n  void set_default_value(const ::std::string& value);\n  void set_default_value(const char* value);\n  void set_default_value(const char* value, size_t size);\n  ::std::string* mutable_default_value();\n  ::std::string* release_default_value();\n  void set_allocated_default_value(::std::string* default_value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.Field)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  bool _is_default_instance_;\n  int kind_;\n  int cardinality_;\n  ::google::protobuf::internal::ArenaStringPtr name_;\n  ::google::protobuf::int32 number_;\n  ::google::protobuf::int32 oneof_index_;\n  ::google::protobuf::internal::ArenaStringPtr type_url_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_;\n  ::google::protobuf::internal::ArenaStringPtr json_name_;\n  ::google::protobuf::internal::ArenaStringPtr default_value_;\n  bool packed_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto();\n\n  void InitAsDefaultInstance();\n  static Field* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT Enum : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Enum) */ {\n public:\n  Enum();\n  virtual ~Enum();\n\n  Enum(const Enum& from);\n\n  inline Enum& operator=(const Enum& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const Enum& default_instance();\n\n  void Swap(Enum* other);\n\n  // implements Message ----------------------------------------------\n\n  inline Enum* New() const { return New(NULL); }\n\n  Enum* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const Enum& from);\n  void MergeFrom(const Enum& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(Enum* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional string name = 1;\n  void clear_name();\n  static const int kNameFieldNumber = 1;\n  const ::std::string& name() const;\n  void set_name(const ::std::string& value);\n  void set_name(const char* value);\n  void set_name(const char* value, size_t size);\n  ::std::string* mutable_name();\n  ::std::string* release_name();\n  void set_allocated_name(::std::string* name);\n\n  // repeated .google.protobuf.EnumValue enumvalue = 2;\n  int enumvalue_size() const;\n  void clear_enumvalue();\n  static const int kEnumvalueFieldNumber = 2;\n  const ::google::protobuf::EnumValue& enumvalue(int index) const;\n  ::google::protobuf::EnumValue* mutable_enumvalue(int index);\n  ::google::protobuf::EnumValue* add_enumvalue();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValue >*\n      mutable_enumvalue();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValue >&\n      enumvalue() const;\n\n  // repeated .google.protobuf.Option options = 3;\n  int options_size() const;\n  void clear_options();\n  static const int kOptionsFieldNumber = 3;\n  const ::google::protobuf::Option& options(int index) const;\n  ::google::protobuf::Option* mutable_options(int index);\n  ::google::protobuf::Option* add_options();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*\n      mutable_options();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&\n      options() const;\n\n  // optional .google.protobuf.SourceContext source_context = 4;\n  bool has_source_context() const;\n  void clear_source_context();\n  static const int kSourceContextFieldNumber = 4;\n  const ::google::protobuf::SourceContext& source_context() const;\n  ::google::protobuf::SourceContext* mutable_source_context();\n  ::google::protobuf::SourceContext* release_source_context();\n  void set_allocated_source_context(::google::protobuf::SourceContext* source_context);\n\n  // optional .google.protobuf.Syntax syntax = 5;\n  void clear_syntax();\n  static const int kSyntaxFieldNumber = 5;\n  ::google::protobuf::Syntax syntax() const;\n  void set_syntax(::google::protobuf::Syntax value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.Enum)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  bool _is_default_instance_;\n  ::google::protobuf::internal::ArenaStringPtr name_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValue > enumvalue_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_;\n  ::google::protobuf::SourceContext* source_context_;\n  int syntax_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto();\n\n  void InitAsDefaultInstance();\n  static Enum* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT EnumValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.EnumValue) */ {\n public:\n  EnumValue();\n  virtual ~EnumValue();\n\n  EnumValue(const EnumValue& from);\n\n  inline EnumValue& operator=(const EnumValue& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const EnumValue& default_instance();\n\n  void Swap(EnumValue* other);\n\n  // implements Message ----------------------------------------------\n\n  inline EnumValue* New() const { return New(NULL); }\n\n  EnumValue* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const EnumValue& from);\n  void MergeFrom(const EnumValue& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(EnumValue* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional string name = 1;\n  void clear_name();\n  static const int kNameFieldNumber = 1;\n  const ::std::string& name() const;\n  void set_name(const ::std::string& value);\n  void set_name(const char* value);\n  void set_name(const char* value, size_t size);\n  ::std::string* mutable_name();\n  ::std::string* release_name();\n  void set_allocated_name(::std::string* name);\n\n  // optional int32 number = 2;\n  void clear_number();\n  static const int kNumberFieldNumber = 2;\n  ::google::protobuf::int32 number() const;\n  void set_number(::google::protobuf::int32 value);\n\n  // repeated .google.protobuf.Option options = 3;\n  int options_size() const;\n  void clear_options();\n  static const int kOptionsFieldNumber = 3;\n  const ::google::protobuf::Option& options(int index) const;\n  ::google::protobuf::Option* mutable_options(int index);\n  ::google::protobuf::Option* add_options();\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*\n      mutable_options();\n  const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&\n      options() const;\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.EnumValue)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  bool _is_default_instance_;\n  ::google::protobuf::internal::ArenaStringPtr name_;\n  ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option > options_;\n  ::google::protobuf::int32 number_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto();\n\n  void InitAsDefaultInstance();\n  static EnumValue* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT Option : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Option) */ {\n public:\n  Option();\n  virtual ~Option();\n\n  Option(const Option& from);\n\n  inline Option& operator=(const Option& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const Option& default_instance();\n\n  void Swap(Option* other);\n\n  // implements Message ----------------------------------------------\n\n  inline Option* New() const { return New(NULL); }\n\n  Option* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const Option& from);\n  void MergeFrom(const Option& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(Option* other);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional string name = 1;\n  void clear_name();\n  static const int kNameFieldNumber = 1;\n  const ::std::string& name() const;\n  void set_name(const ::std::string& value);\n  void set_name(const char* value);\n  void set_name(const char* value, size_t size);\n  ::std::string* mutable_name();\n  ::std::string* release_name();\n  void set_allocated_name(::std::string* name);\n\n  // optional .google.protobuf.Any value = 2;\n  bool has_value() const;\n  void clear_value();\n  static const int kValueFieldNumber = 2;\n  const ::google::protobuf::Any& value() const;\n  ::google::protobuf::Any* mutable_value();\n  ::google::protobuf::Any* release_value();\n  void set_allocated_value(::google::protobuf::Any* value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.Option)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  bool _is_default_instance_;\n  ::google::protobuf::internal::ArenaStringPtr name_;\n  ::google::protobuf::Any* value_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2ftype_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2ftype_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2ftype_2eproto();\n\n  void InitAsDefaultInstance();\n  static Option* default_instance_;\n};\n// ===================================================================\n\n\n// ===================================================================\n\n#if !PROTOBUF_INLINE_NOT_IN_HEADERS\n// Type\n\n// optional string name = 1;\ninline void Type::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline const ::std::string& Type::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Type.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Type::set_name(const ::std::string& value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Type.name)\n}\ninline void Type::set_name(const char* value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Type.name)\n}\ninline void Type::set_name(const char* value, size_t size) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Type.name)\n}\ninline ::std::string* Type::mutable_name() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Type.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* Type::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Type.name)\n  \n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Type::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    \n  } else {\n    \n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.name)\n}\n\n// repeated .google.protobuf.Field fields = 2;\ninline int Type::fields_size() const {\n  return fields_.size();\n}\ninline void Type::clear_fields() {\n  fields_.Clear();\n}\ninline const ::google::protobuf::Field& Type::fields(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Type.fields)\n  return fields_.Get(index);\n}\ninline ::google::protobuf::Field* Type::mutable_fields(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Type.fields)\n  return fields_.Mutable(index);\n}\ninline ::google::protobuf::Field* Type::add_fields() {\n  // @@protoc_insertion_point(field_add:google.protobuf.Type.fields)\n  return fields_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Field >*\nType::mutable_fields() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.Type.fields)\n  return &fields_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Field >&\nType::fields() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.Type.fields)\n  return fields_;\n}\n\n// repeated string oneofs = 3;\ninline int Type::oneofs_size() const {\n  return oneofs_.size();\n}\ninline void Type::clear_oneofs() {\n  oneofs_.Clear();\n}\ninline const ::std::string& Type::oneofs(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Type.oneofs)\n  return oneofs_.Get(index);\n}\ninline ::std::string* Type::mutable_oneofs(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Type.oneofs)\n  return oneofs_.Mutable(index);\n}\ninline void Type::set_oneofs(int index, const ::std::string& value) {\n  // @@protoc_insertion_point(field_set:google.protobuf.Type.oneofs)\n  oneofs_.Mutable(index)->assign(value);\n}\ninline void Type::set_oneofs(int index, const char* value) {\n  oneofs_.Mutable(index)->assign(value);\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Type.oneofs)\n}\ninline void Type::set_oneofs(int index, const char* value, size_t size) {\n  oneofs_.Mutable(index)->assign(\n    reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Type.oneofs)\n}\ninline ::std::string* Type::add_oneofs() {\n  // @@protoc_insertion_point(field_add_mutable:google.protobuf.Type.oneofs)\n  return oneofs_.Add();\n}\ninline void Type::add_oneofs(const ::std::string& value) {\n  oneofs_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add:google.protobuf.Type.oneofs)\n}\ninline void Type::add_oneofs(const char* value) {\n  oneofs_.Add()->assign(value);\n  // @@protoc_insertion_point(field_add_char:google.protobuf.Type.oneofs)\n}\ninline void Type::add_oneofs(const char* value, size_t size) {\n  oneofs_.Add()->assign(reinterpret_cast<const char*>(value), size);\n  // @@protoc_insertion_point(field_add_pointer:google.protobuf.Type.oneofs)\n}\ninline const ::google::protobuf::RepeatedPtrField< ::std::string>&\nType::oneofs() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.Type.oneofs)\n  return oneofs_;\n}\ninline ::google::protobuf::RepeatedPtrField< ::std::string>*\nType::mutable_oneofs() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.Type.oneofs)\n  return &oneofs_;\n}\n\n// repeated .google.protobuf.Option options = 4;\ninline int Type::options_size() const {\n  return options_.size();\n}\ninline void Type::clear_options() {\n  options_.Clear();\n}\ninline const ::google::protobuf::Option& Type::options(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Type.options)\n  return options_.Get(index);\n}\ninline ::google::protobuf::Option* Type::mutable_options(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Type.options)\n  return options_.Mutable(index);\n}\ninline ::google::protobuf::Option* Type::add_options() {\n  // @@protoc_insertion_point(field_add:google.protobuf.Type.options)\n  return options_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*\nType::mutable_options() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.Type.options)\n  return &options_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&\nType::options() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.Type.options)\n  return options_;\n}\n\n// optional .google.protobuf.SourceContext source_context = 5;\ninline bool Type::has_source_context() const {\n  return !_is_default_instance_ && source_context_ != NULL;\n}\ninline void Type::clear_source_context() {\n  if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_;\n  source_context_ = NULL;\n}\ninline const ::google::protobuf::SourceContext& Type::source_context() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Type.source_context)\n  return source_context_ != NULL ? *source_context_ : *default_instance_->source_context_;\n}\ninline ::google::protobuf::SourceContext* Type::mutable_source_context() {\n  \n  if (source_context_ == NULL) {\n    source_context_ = new ::google::protobuf::SourceContext;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Type.source_context)\n  return source_context_;\n}\ninline ::google::protobuf::SourceContext* Type::release_source_context() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Type.source_context)\n  \n  ::google::protobuf::SourceContext* temp = source_context_;\n  source_context_ = NULL;\n  return temp;\n}\ninline void Type::set_allocated_source_context(::google::protobuf::SourceContext* source_context) {\n  delete source_context_;\n  source_context_ = source_context;\n  if (source_context) {\n    \n  } else {\n    \n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Type.source_context)\n}\n\n// optional .google.protobuf.Syntax syntax = 6;\ninline void Type::clear_syntax() {\n  syntax_ = 0;\n}\ninline ::google::protobuf::Syntax Type::syntax() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Type.syntax)\n  return static_cast< ::google::protobuf::Syntax >(syntax_);\n}\ninline void Type::set_syntax(::google::protobuf::Syntax value) {\n  \n  syntax_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Type.syntax)\n}\n\n// -------------------------------------------------------------------\n\n// Field\n\n// optional .google.protobuf.Field.Kind kind = 1;\ninline void Field::clear_kind() {\n  kind_ = 0;\n}\ninline ::google::protobuf::Field_Kind Field::kind() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Field.kind)\n  return static_cast< ::google::protobuf::Field_Kind >(kind_);\n}\ninline void Field::set_kind(::google::protobuf::Field_Kind value) {\n  \n  kind_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Field.kind)\n}\n\n// optional .google.protobuf.Field.Cardinality cardinality = 2;\ninline void Field::clear_cardinality() {\n  cardinality_ = 0;\n}\ninline ::google::protobuf::Field_Cardinality Field::cardinality() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Field.cardinality)\n  return static_cast< ::google::protobuf::Field_Cardinality >(cardinality_);\n}\ninline void Field::set_cardinality(::google::protobuf::Field_Cardinality value) {\n  \n  cardinality_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Field.cardinality)\n}\n\n// optional int32 number = 3;\ninline void Field::clear_number() {\n  number_ = 0;\n}\ninline ::google::protobuf::int32 Field::number() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Field.number)\n  return number_;\n}\ninline void Field::set_number(::google::protobuf::int32 value) {\n  \n  number_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Field.number)\n}\n\n// optional string name = 4;\ninline void Field::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline const ::std::string& Field::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Field.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Field::set_name(const ::std::string& value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Field.name)\n}\ninline void Field::set_name(const char* value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Field.name)\n}\ninline void Field::set_name(const char* value, size_t size) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.name)\n}\ninline ::std::string* Field::mutable_name() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Field.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* Field::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Field.name)\n  \n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Field::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    \n  } else {\n    \n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.name)\n}\n\n// optional string type_url = 6;\ninline void Field::clear_type_url() {\n  type_url_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline const ::std::string& Field::type_url() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Field.type_url)\n  return type_url_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Field::set_type_url(const ::std::string& value) {\n  \n  type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Field.type_url)\n}\ninline void Field::set_type_url(const char* value) {\n  \n  type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Field.type_url)\n}\ninline void Field::set_type_url(const char* value, size_t size) {\n  \n  type_url_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.type_url)\n}\ninline ::std::string* Field::mutable_type_url() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Field.type_url)\n  return type_url_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* Field::release_type_url() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Field.type_url)\n  \n  return type_url_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Field::set_allocated_type_url(::std::string* type_url) {\n  if (type_url != NULL) {\n    \n  } else {\n    \n  }\n  type_url_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), type_url);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.type_url)\n}\n\n// optional int32 oneof_index = 7;\ninline void Field::clear_oneof_index() {\n  oneof_index_ = 0;\n}\ninline ::google::protobuf::int32 Field::oneof_index() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Field.oneof_index)\n  return oneof_index_;\n}\ninline void Field::set_oneof_index(::google::protobuf::int32 value) {\n  \n  oneof_index_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Field.oneof_index)\n}\n\n// optional bool packed = 8;\ninline void Field::clear_packed() {\n  packed_ = false;\n}\ninline bool Field::packed() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Field.packed)\n  return packed_;\n}\ninline void Field::set_packed(bool value) {\n  \n  packed_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Field.packed)\n}\n\n// repeated .google.protobuf.Option options = 9;\ninline int Field::options_size() const {\n  return options_.size();\n}\ninline void Field::clear_options() {\n  options_.Clear();\n}\ninline const ::google::protobuf::Option& Field::options(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Field.options)\n  return options_.Get(index);\n}\ninline ::google::protobuf::Option* Field::mutable_options(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Field.options)\n  return options_.Mutable(index);\n}\ninline ::google::protobuf::Option* Field::add_options() {\n  // @@protoc_insertion_point(field_add:google.protobuf.Field.options)\n  return options_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*\nField::mutable_options() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.Field.options)\n  return &options_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&\nField::options() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.Field.options)\n  return options_;\n}\n\n// optional string json_name = 10;\ninline void Field::clear_json_name() {\n  json_name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline const ::std::string& Field::json_name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Field.json_name)\n  return json_name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Field::set_json_name(const ::std::string& value) {\n  \n  json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Field.json_name)\n}\ninline void Field::set_json_name(const char* value) {\n  \n  json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Field.json_name)\n}\ninline void Field::set_json_name(const char* value, size_t size) {\n  \n  json_name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.json_name)\n}\ninline ::std::string* Field::mutable_json_name() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Field.json_name)\n  return json_name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* Field::release_json_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Field.json_name)\n  \n  return json_name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Field::set_allocated_json_name(::std::string* json_name) {\n  if (json_name != NULL) {\n    \n  } else {\n    \n  }\n  json_name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), json_name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.json_name)\n}\n\n// optional string default_value = 11;\ninline void Field::clear_default_value() {\n  default_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline const ::std::string& Field::default_value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Field.default_value)\n  return default_value_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Field::set_default_value(const ::std::string& value) {\n  \n  default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Field.default_value)\n}\ninline void Field::set_default_value(const char* value) {\n  \n  default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Field.default_value)\n}\ninline void Field::set_default_value(const char* value, size_t size) {\n  \n  default_value_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Field.default_value)\n}\ninline ::std::string* Field::mutable_default_value() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Field.default_value)\n  return default_value_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* Field::release_default_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Field.default_value)\n  \n  return default_value_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Field::set_allocated_default_value(::std::string* default_value) {\n  if (default_value != NULL) {\n    \n  } else {\n    \n  }\n  default_value_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), default_value);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Field.default_value)\n}\n\n// -------------------------------------------------------------------\n\n// Enum\n\n// optional string name = 1;\ninline void Enum::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline const ::std::string& Enum::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Enum.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Enum::set_name(const ::std::string& value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Enum.name)\n}\ninline void Enum::set_name(const char* value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Enum.name)\n}\ninline void Enum::set_name(const char* value, size_t size) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Enum.name)\n}\ninline ::std::string* Enum::mutable_name() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* Enum::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Enum.name)\n  \n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Enum::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    \n  } else {\n    \n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.name)\n}\n\n// repeated .google.protobuf.EnumValue enumvalue = 2;\ninline int Enum::enumvalue_size() const {\n  return enumvalue_.size();\n}\ninline void Enum::clear_enumvalue() {\n  enumvalue_.Clear();\n}\ninline const ::google::protobuf::EnumValue& Enum::enumvalue(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Enum.enumvalue)\n  return enumvalue_.Get(index);\n}\ninline ::google::protobuf::EnumValue* Enum::mutable_enumvalue(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.enumvalue)\n  return enumvalue_.Mutable(index);\n}\ninline ::google::protobuf::EnumValue* Enum::add_enumvalue() {\n  // @@protoc_insertion_point(field_add:google.protobuf.Enum.enumvalue)\n  return enumvalue_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValue >*\nEnum::mutable_enumvalue() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.Enum.enumvalue)\n  return &enumvalue_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::EnumValue >&\nEnum::enumvalue() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.Enum.enumvalue)\n  return enumvalue_;\n}\n\n// repeated .google.protobuf.Option options = 3;\ninline int Enum::options_size() const {\n  return options_.size();\n}\ninline void Enum::clear_options() {\n  options_.Clear();\n}\ninline const ::google::protobuf::Option& Enum::options(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Enum.options)\n  return options_.Get(index);\n}\ninline ::google::protobuf::Option* Enum::mutable_options(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.options)\n  return options_.Mutable(index);\n}\ninline ::google::protobuf::Option* Enum::add_options() {\n  // @@protoc_insertion_point(field_add:google.protobuf.Enum.options)\n  return options_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*\nEnum::mutable_options() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.Enum.options)\n  return &options_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&\nEnum::options() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.Enum.options)\n  return options_;\n}\n\n// optional .google.protobuf.SourceContext source_context = 4;\ninline bool Enum::has_source_context() const {\n  return !_is_default_instance_ && source_context_ != NULL;\n}\ninline void Enum::clear_source_context() {\n  if (GetArenaNoVirtual() == NULL && source_context_ != NULL) delete source_context_;\n  source_context_ = NULL;\n}\ninline const ::google::protobuf::SourceContext& Enum::source_context() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Enum.source_context)\n  return source_context_ != NULL ? *source_context_ : *default_instance_->source_context_;\n}\ninline ::google::protobuf::SourceContext* Enum::mutable_source_context() {\n  \n  if (source_context_ == NULL) {\n    source_context_ = new ::google::protobuf::SourceContext;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Enum.source_context)\n  return source_context_;\n}\ninline ::google::protobuf::SourceContext* Enum::release_source_context() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Enum.source_context)\n  \n  ::google::protobuf::SourceContext* temp = source_context_;\n  source_context_ = NULL;\n  return temp;\n}\ninline void Enum::set_allocated_source_context(::google::protobuf::SourceContext* source_context) {\n  delete source_context_;\n  source_context_ = source_context;\n  if (source_context) {\n    \n  } else {\n    \n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Enum.source_context)\n}\n\n// optional .google.protobuf.Syntax syntax = 5;\ninline void Enum::clear_syntax() {\n  syntax_ = 0;\n}\ninline ::google::protobuf::Syntax Enum::syntax() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Enum.syntax)\n  return static_cast< ::google::protobuf::Syntax >(syntax_);\n}\ninline void Enum::set_syntax(::google::protobuf::Syntax value) {\n  \n  syntax_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Enum.syntax)\n}\n\n// -------------------------------------------------------------------\n\n// EnumValue\n\n// optional string name = 1;\ninline void EnumValue::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline const ::std::string& EnumValue::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void EnumValue::set_name(const ::std::string& value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.EnumValue.name)\n}\ninline void EnumValue::set_name(const char* value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.EnumValue.name)\n}\ninline void EnumValue::set_name(const char* value, size_t size) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.EnumValue.name)\n}\ninline ::std::string* EnumValue::mutable_name() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValue.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* EnumValue::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.EnumValue.name)\n  \n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void EnumValue::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    \n  } else {\n    \n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.EnumValue.name)\n}\n\n// optional int32 number = 2;\ninline void EnumValue::clear_number() {\n  number_ = 0;\n}\ninline ::google::protobuf::int32 EnumValue::number() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.number)\n  return number_;\n}\ninline void EnumValue::set_number(::google::protobuf::int32 value) {\n  \n  number_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.EnumValue.number)\n}\n\n// repeated .google.protobuf.Option options = 3;\ninline int EnumValue::options_size() const {\n  return options_.size();\n}\ninline void EnumValue::clear_options() {\n  options_.Clear();\n}\ninline const ::google::protobuf::Option& EnumValue::options(int index) const {\n  // @@protoc_insertion_point(field_get:google.protobuf.EnumValue.options)\n  return options_.Get(index);\n}\ninline ::google::protobuf::Option* EnumValue::mutable_options(int index) {\n  // @@protoc_insertion_point(field_mutable:google.protobuf.EnumValue.options)\n  return options_.Mutable(index);\n}\ninline ::google::protobuf::Option* EnumValue::add_options() {\n  // @@protoc_insertion_point(field_add:google.protobuf.EnumValue.options)\n  return options_.Add();\n}\ninline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >*\nEnumValue::mutable_options() {\n  // @@protoc_insertion_point(field_mutable_list:google.protobuf.EnumValue.options)\n  return &options_;\n}\ninline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Option >&\nEnumValue::options() const {\n  // @@protoc_insertion_point(field_list:google.protobuf.EnumValue.options)\n  return options_;\n}\n\n// -------------------------------------------------------------------\n\n// Option\n\n// optional string name = 1;\ninline void Option::clear_name() {\n  name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline const ::std::string& Option::name() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Option.name)\n  return name_.GetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Option::set_name(const ::std::string& value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value);\n  // @@protoc_insertion_point(field_set:google.protobuf.Option.name)\n}\ninline void Option::set_name(const char* value) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value));\n  // @@protoc_insertion_point(field_set_char:google.protobuf.Option.name)\n}\ninline void Option::set_name(const char* value, size_t size) {\n  \n  name_.SetNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      ::std::string(reinterpret_cast<const char*>(value), size));\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.Option.name)\n}\ninline ::std::string* Option::mutable_name() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.Option.name)\n  return name_.MutableNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline ::std::string* Option::release_name() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Option.name)\n  \n  return name_.ReleaseNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void Option::set_allocated_name(::std::string* name) {\n  if (name != NULL) {\n    \n  } else {\n    \n  }\n  name_.SetAllocatedNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), name);\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.name)\n}\n\n// optional .google.protobuf.Any value = 2;\ninline bool Option::has_value() const {\n  return !_is_default_instance_ && value_ != NULL;\n}\ninline void Option::clear_value() {\n  if (GetArenaNoVirtual() == NULL && value_ != NULL) delete value_;\n  value_ = NULL;\n}\ninline const ::google::protobuf::Any& Option::value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Option.value)\n  return value_ != NULL ? *value_ : *default_instance_->value_;\n}\ninline ::google::protobuf::Any* Option::mutable_value() {\n  \n  if (value_ == NULL) {\n    value_ = new ::google::protobuf::Any;\n  }\n  // @@protoc_insertion_point(field_mutable:google.protobuf.Option.value)\n  return value_;\n}\ninline ::google::protobuf::Any* Option::release_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.Option.value)\n  \n  ::google::protobuf::Any* temp = value_;\n  value_ = NULL;\n  return temp;\n}\ninline void Option::set_allocated_value(::google::protobuf::Any* value) {\n  delete value_;\n  value_ = value;\n  if (value) {\n    \n  } else {\n    \n  }\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.Option.value)\n}\n\n#endif  // !PROTOBUF_INLINE_NOT_IN_HEADERS\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace protobuf\n}  // namespace google\n\n#ifndef SWIG\nnamespace google {\nnamespace protobuf {\n\ntemplate <> struct is_proto_enum< ::google::protobuf::Field_Kind> : ::google::protobuf::internal::true_type {};\ntemplate <>\ninline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::Field_Kind>() {\n  return ::google::protobuf::Field_Kind_descriptor();\n}\ntemplate <> struct is_proto_enum< ::google::protobuf::Field_Cardinality> : ::google::protobuf::internal::true_type {};\ntemplate <>\ninline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::Field_Cardinality>() {\n  return ::google::protobuf::Field_Cardinality_descriptor();\n}\ntemplate <> struct is_proto_enum< ::google::protobuf::Syntax> : ::google::protobuf::internal::true_type {};\ntemplate <>\ninline const EnumDescriptor* GetEnumDescriptor< ::google::protobuf::Syntax>() {\n  return ::google::protobuf::Syntax_descriptor();\n}\n\n}  // namespace protobuf\n}  // namespace google\n#endif  // SWIG\n\n// @@protoc_insertion_point(global_scope)\n\n#endif  // PROTOBUF_google_2fprotobuf_2ftype_2eproto__INCLUDED\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/type.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto3\";\n\npackage google.protobuf;\n\nimport \"google/protobuf/any.proto\";\nimport \"google/protobuf/source_context.proto\";\n\noption csharp_namespace = \"Google.Protobuf.WellKnownTypes\";\noption java_package = \"com.google.protobuf\";\noption java_outer_classname = \"TypeProto\";\noption java_multiple_files = true;\noption java_generate_equals_and_hash = true;\noption objc_class_prefix = \"GPB\";\n\n// A protocol buffer message type.\nmessage Type {\n  // The fully qualified message name.\n  string name = 1;\n  // The list of fields.\n  repeated Field fields = 2;\n  // The list of types appearing in `oneof` definitions in this type.\n  repeated string oneofs = 3;\n  // The protocol buffer options.\n  repeated Option options = 4;\n  // The source context.\n  SourceContext source_context = 5;\n  // The source syntax.\n  Syntax syntax = 6;\n}\n\n// A single field of a message type.\nmessage Field {\n  // Basic field types.\n  enum Kind {\n    // Field type unknown.\n    TYPE_UNKNOWN        = 0;\n    // Field type double.\n    TYPE_DOUBLE         = 1;\n    // Field type float.\n    TYPE_FLOAT          = 2;\n    // Field type int64.\n    TYPE_INT64          = 3;\n    // Field type uint64.\n    TYPE_UINT64         = 4;\n    // Field type int32.\n    TYPE_INT32          = 5;\n    // Field type fixed64.\n    TYPE_FIXED64        = 6;\n    // Field type fixed32.\n    TYPE_FIXED32        = 7;\n    // Field type bool.\n    TYPE_BOOL           = 8;\n    // Field type string.\n    TYPE_STRING         = 9;\n    // Field type group. Proto2 syntax only, and deprecated.\n    TYPE_GROUP          = 10;\n    // Field type message.\n    TYPE_MESSAGE        = 11;\n    // Field type bytes.\n    TYPE_BYTES          = 12;\n    // Field type uint32.\n    TYPE_UINT32         = 13;\n    // Field type enum.\n    TYPE_ENUM           = 14;\n    // Field type sfixed32.\n    TYPE_SFIXED32       = 15;\n    // Field type sfixed64.\n    TYPE_SFIXED64       = 16;\n    // Field type sint32.\n    TYPE_SINT32         = 17;\n    // Field type sint64.\n    TYPE_SINT64         = 18;\n  };\n\n  // Whether a field is optional, required, or repeated.\n  enum Cardinality {\n    // For fields with unknown cardinality.\n    CARDINALITY_UNKNOWN = 0;\n    // For optional fields.\n    CARDINALITY_OPTIONAL = 1;\n    // For required fields. Proto2 syntax only.\n    CARDINALITY_REQUIRED = 2;\n    // For repeated fields.\n    CARDINALITY_REPEATED = 3;\n  };\n\n  // The field type.\n  Kind kind = 1;\n  // The field cardinality.\n  Cardinality cardinality = 2;\n  // The field number.\n  int32 number = 3;\n  // The field name.\n  string name = 4;\n  // The field type URL, without the scheme, for message or enumeration\n  // types. Example: `\"type.googleapis.com/google.protobuf.Timestamp\"`.\n  string type_url = 6;\n  // The index of the field type in `Type.oneofs`, for message or enumeration\n  // types. The first type has index 1; zero means the type is not in the list.\n  int32 oneof_index = 7;\n  // Whether to use alternative packed wire representation.\n  bool packed = 8;\n  // The protocol buffer options.\n  repeated Option options = 9;\n  // The field JSON name.\n  string json_name = 10;\n  // The string value of the default value of this field. Proto2 syntax only.\n  string default_value = 11;\n}\n\n// Enum type definition.\nmessage Enum {\n  // Enum type name.\n  string name = 1;\n  // Enum value definitions.\n  repeated EnumValue enumvalue = 2;\n  // Protocol buffer options.\n  repeated Option options = 3;\n  // The source context.\n  SourceContext source_context = 4;\n  // The source syntax.\n  Syntax syntax = 5;\n}\n\n// Enum value definition.\nmessage EnumValue {\n  // Enum value name.\n  string name = 1;\n  // Enum value number.\n  int32 number = 2;\n  // Protocol buffer options.\n  repeated Option options = 3;\n}\n\n// A protocol buffer option, which can be attached to a message, field,\n// enumeration, etc.\nmessage Option {\n  // The option's name. For example, `\"java_package\"`.\n  string name = 1;\n  // The option's value. For example, `\"com.google.protobuf\"`.\n  Any value = 2;\n}\n\n// The syntax in which a protocol buffer element is defined.\nenum Syntax {\n  // Syntax `proto2`.\n  SYNTAX_PROTO2 = 0;\n  // Syntax `proto3`.\n  SYNTAX_PROTO3 = 1;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// A proto file we will use for unit testing.\n\nsyntax = \"proto2\";\n\n// Some generic_services option(s) added automatically.\n// See:  http://go/proto2-generic-services-default\noption cc_generic_services = true;     // auto-added\noption java_generic_services = true;   // auto-added\noption py_generic_services = true;     // auto-added\noption cc_enable_arenas = true;\n\nimport \"google/protobuf/unittest_import.proto\";\n\n// We don't put this in a package within proto2 because we need to make sure\n// that the generated code doesn't depend on being in the proto2 namespace.\n// In test_util.h we do \"using namespace unittest = protobuf_unittest\".\npackage protobuf_unittest;\n\n// Protos optimized for SPEED use a strict superset of the generated code\n// of equivalent ones optimized for CODE_SIZE, so we should optimize all our\n// tests for speed unless explicitly testing code size optimization.\noption optimize_for = SPEED;\n\noption java_outer_classname = \"UnittestProto\";\n\n// This proto includes every type of field in both singular and repeated\n// forms.\nmessage TestAllTypes {\n  message NestedMessage {\n    // The field name \"b\" fails to compile in proto1 because it conflicts with\n    // a local variable named \"b\" in one of the generated methods.  Doh.\n    // This file needs to compile in proto1 to test backwards-compatibility.\n    optional int32 bb = 1;\n  }\n\n  enum NestedEnum {\n    FOO = 1;\n    BAR = 2;\n    BAZ = 3;\n    NEG = -1;  // Intentionally negative.\n  }\n\n  // Singular\n  optional    int32 optional_int32    =  1;\n  optional    int64 optional_int64    =  2;\n  optional   uint32 optional_uint32   =  3;\n  optional   uint64 optional_uint64   =  4;\n  optional   sint32 optional_sint32   =  5;\n  optional   sint64 optional_sint64   =  6;\n  optional  fixed32 optional_fixed32  =  7;\n  optional  fixed64 optional_fixed64  =  8;\n  optional sfixed32 optional_sfixed32 =  9;\n  optional sfixed64 optional_sfixed64 = 10;\n  optional    float optional_float    = 11;\n  optional   double optional_double   = 12;\n  optional     bool optional_bool     = 13;\n  optional   string optional_string   = 14;\n  optional    bytes optional_bytes    = 15;\n\n  optional group OptionalGroup = 16 {\n    optional int32 a = 17;\n  }\n\n  optional NestedMessage                        optional_nested_message  = 18;\n  optional ForeignMessage                       optional_foreign_message = 19;\n  optional protobuf_unittest_import.ImportMessage optional_import_message  = 20;\n\n  optional NestedEnum                           optional_nested_enum     = 21;\n  optional ForeignEnum                          optional_foreign_enum    = 22;\n  optional protobuf_unittest_import.ImportEnum    optional_import_enum     = 23;\n\n  optional string optional_string_piece = 24 [ctype=STRING_PIECE];\n  optional string optional_cord = 25 [ctype=CORD];\n\n  // Defined in unittest_import_public.proto\n  optional protobuf_unittest_import.PublicImportMessage\n      optional_public_import_message = 26;\n\n  optional NestedMessage optional_lazy_message = 27 [lazy=true];\n\n  // Repeated\n  repeated    int32 repeated_int32    = 31;\n  repeated    int64 repeated_int64    = 32;\n  repeated   uint32 repeated_uint32   = 33;\n  repeated   uint64 repeated_uint64   = 34;\n  repeated   sint32 repeated_sint32   = 35;\n  repeated   sint64 repeated_sint64   = 36;\n  repeated  fixed32 repeated_fixed32  = 37;\n  repeated  fixed64 repeated_fixed64  = 38;\n  repeated sfixed32 repeated_sfixed32 = 39;\n  repeated sfixed64 repeated_sfixed64 = 40;\n  repeated    float repeated_float    = 41;\n  repeated   double repeated_double   = 42;\n  repeated     bool repeated_bool     = 43;\n  repeated   string repeated_string   = 44;\n  repeated    bytes repeated_bytes    = 45;\n\n  repeated group RepeatedGroup = 46 {\n    optional int32 a = 47;\n  }\n\n  repeated NestedMessage                        repeated_nested_message  = 48;\n  repeated ForeignMessage                       repeated_foreign_message = 49;\n  repeated protobuf_unittest_import.ImportMessage repeated_import_message  = 50;\n\n  repeated NestedEnum                           repeated_nested_enum     = 51;\n  repeated ForeignEnum                          repeated_foreign_enum    = 52;\n  repeated protobuf_unittest_import.ImportEnum    repeated_import_enum     = 53;\n\n  repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];\n  repeated string repeated_cord = 55 [ctype=CORD];\n\n  repeated NestedMessage repeated_lazy_message = 57 [lazy=true];\n\n  // Singular with defaults\n  optional    int32 default_int32    = 61 [default =  41    ];\n  optional    int64 default_int64    = 62 [default =  42    ];\n  optional   uint32 default_uint32   = 63 [default =  43    ];\n  optional   uint64 default_uint64   = 64 [default =  44    ];\n  optional   sint32 default_sint32   = 65 [default = -45    ];\n  optional   sint64 default_sint64   = 66 [default =  46    ];\n  optional  fixed32 default_fixed32  = 67 [default =  47    ];\n  optional  fixed64 default_fixed64  = 68 [default =  48    ];\n  optional sfixed32 default_sfixed32 = 69 [default =  49    ];\n  optional sfixed64 default_sfixed64 = 70 [default = -50    ];\n  optional    float default_float    = 71 [default =  51.5  ];\n  optional   double default_double   = 72 [default =  52e3  ];\n  optional     bool default_bool     = 73 [default = true   ];\n  optional   string default_string   = 74 [default = \"hello\"];\n  optional    bytes default_bytes    = 75 [default = \"world\"];\n\n  optional NestedEnum  default_nested_enum  = 81 [default = BAR        ];\n  optional ForeignEnum default_foreign_enum = 82 [default = FOREIGN_BAR];\n  optional protobuf_unittest_import.ImportEnum\n      default_import_enum = 83 [default = IMPORT_BAR];\n\n  optional string default_string_piece = 84 [ctype=STRING_PIECE,default=\"abc\"];\n  optional string default_cord = 85 [ctype=CORD,default=\"123\"];\n\n  // For oneof test\n  oneof oneof_field {\n    uint32 oneof_uint32 = 111;\n    NestedMessage oneof_nested_message = 112;\n    string oneof_string = 113;\n    bytes oneof_bytes = 114;\n  }\n}\n\n// This proto includes a recusively nested message.\nmessage NestedTestAllTypes {\n  optional NestedTestAllTypes child = 1;\n  optional TestAllTypes payload = 2;\n  repeated NestedTestAllTypes repeated_child = 3;\n}\n\nmessage TestDeprecatedFields {\n  optional int32 deprecated_int32 = 1 [deprecated=true];\n}\n\n// Define these after TestAllTypes to make sure the compiler can handle\n// that.\nmessage ForeignMessage {\n  optional int32 c = 1;\n  optional int32 d = 2;\n}\n\nenum ForeignEnum {\n  FOREIGN_FOO = 4;\n  FOREIGN_BAR = 5;\n  FOREIGN_BAZ = 6;\n}\n\nmessage TestReservedFields {\n  reserved 2, 15, 9 to 11;\n  reserved \"bar\", \"baz\";\n}\n\nmessage TestAllExtensions {\n  extensions 1 to max;\n}\n\nextend TestAllExtensions {\n  // Singular\n  optional    int32 optional_int32_extension    =  1;\n  optional    int64 optional_int64_extension    =  2;\n  optional   uint32 optional_uint32_extension   =  3;\n  optional   uint64 optional_uint64_extension   =  4;\n  optional   sint32 optional_sint32_extension   =  5;\n  optional   sint64 optional_sint64_extension   =  6;\n  optional  fixed32 optional_fixed32_extension  =  7;\n  optional  fixed64 optional_fixed64_extension  =  8;\n  optional sfixed32 optional_sfixed32_extension =  9;\n  optional sfixed64 optional_sfixed64_extension = 10;\n  optional    float optional_float_extension    = 11;\n  optional   double optional_double_extension   = 12;\n  optional     bool optional_bool_extension     = 13;\n  optional   string optional_string_extension   = 14;\n  optional    bytes optional_bytes_extension    = 15;\n\n  optional group OptionalGroup_extension = 16 {\n    optional int32 a = 17;\n  }\n\n  optional TestAllTypes.NestedMessage optional_nested_message_extension = 18;\n  optional ForeignMessage optional_foreign_message_extension = 19;\n  optional protobuf_unittest_import.ImportMessage\n    optional_import_message_extension = 20;\n\n  optional TestAllTypes.NestedEnum optional_nested_enum_extension = 21;\n  optional ForeignEnum optional_foreign_enum_extension = 22;\n  optional protobuf_unittest_import.ImportEnum\n    optional_import_enum_extension = 23;\n\n  optional string optional_string_piece_extension = 24 [ctype=STRING_PIECE];\n  optional string optional_cord_extension = 25 [ctype=CORD];\n\n  optional protobuf_unittest_import.PublicImportMessage\n    optional_public_import_message_extension = 26;\n\n  optional TestAllTypes.NestedMessage\n    optional_lazy_message_extension = 27 [lazy=true];\n\n  // Repeated\n  repeated    int32 repeated_int32_extension    = 31;\n  repeated    int64 repeated_int64_extension    = 32;\n  repeated   uint32 repeated_uint32_extension   = 33;\n  repeated   uint64 repeated_uint64_extension   = 34;\n  repeated   sint32 repeated_sint32_extension   = 35;\n  repeated   sint64 repeated_sint64_extension   = 36;\n  repeated  fixed32 repeated_fixed32_extension  = 37;\n  repeated  fixed64 repeated_fixed64_extension  = 38;\n  repeated sfixed32 repeated_sfixed32_extension = 39;\n  repeated sfixed64 repeated_sfixed64_extension = 40;\n  repeated    float repeated_float_extension    = 41;\n  repeated   double repeated_double_extension   = 42;\n  repeated     bool repeated_bool_extension     = 43;\n  repeated   string repeated_string_extension   = 44;\n  repeated    bytes repeated_bytes_extension    = 45;\n\n  repeated group RepeatedGroup_extension = 46 {\n    optional int32 a = 47;\n  }\n\n  repeated TestAllTypes.NestedMessage repeated_nested_message_extension = 48;\n  repeated ForeignMessage repeated_foreign_message_extension = 49;\n  repeated protobuf_unittest_import.ImportMessage\n    repeated_import_message_extension = 50;\n\n  repeated TestAllTypes.NestedEnum repeated_nested_enum_extension = 51;\n  repeated ForeignEnum repeated_foreign_enum_extension = 52;\n  repeated protobuf_unittest_import.ImportEnum\n    repeated_import_enum_extension = 53;\n\n  repeated string repeated_string_piece_extension = 54 [ctype=STRING_PIECE];\n  repeated string repeated_cord_extension = 55 [ctype=CORD];\n\n  repeated TestAllTypes.NestedMessage\n    repeated_lazy_message_extension = 57 [lazy=true];\n\n  // Singular with defaults\n  optional    int32 default_int32_extension    = 61 [default =  41    ];\n  optional    int64 default_int64_extension    = 62 [default =  42    ];\n  optional   uint32 default_uint32_extension   = 63 [default =  43    ];\n  optional   uint64 default_uint64_extension   = 64 [default =  44    ];\n  optional   sint32 default_sint32_extension   = 65 [default = -45    ];\n  optional   sint64 default_sint64_extension   = 66 [default =  46    ];\n  optional  fixed32 default_fixed32_extension  = 67 [default =  47    ];\n  optional  fixed64 default_fixed64_extension  = 68 [default =  48    ];\n  optional sfixed32 default_sfixed32_extension = 69 [default =  49    ];\n  optional sfixed64 default_sfixed64_extension = 70 [default = -50    ];\n  optional    float default_float_extension    = 71 [default =  51.5  ];\n  optional   double default_double_extension   = 72 [default =  52e3  ];\n  optional     bool default_bool_extension     = 73 [default = true   ];\n  optional   string default_string_extension   = 74 [default = \"hello\"];\n  optional    bytes default_bytes_extension    = 75 [default = \"world\"];\n\n  optional TestAllTypes.NestedEnum\n    default_nested_enum_extension = 81 [default = BAR];\n  optional ForeignEnum\n    default_foreign_enum_extension = 82 [default = FOREIGN_BAR];\n  optional protobuf_unittest_import.ImportEnum\n    default_import_enum_extension = 83 [default = IMPORT_BAR];\n\n  optional string default_string_piece_extension = 84 [ctype=STRING_PIECE,\n                                                       default=\"abc\"];\n  optional string default_cord_extension = 85 [ctype=CORD, default=\"123\"];\n\n  // For oneof test\n  optional uint32 oneof_uint32_extension = 111;\n  optional TestAllTypes.NestedMessage oneof_nested_message_extension = 112;\n  optional string oneof_string_extension = 113;\n  optional bytes oneof_bytes_extension = 114;\n}\n\nmessage TestNestedExtension {\n  extend TestAllExtensions {\n    // Check for bug where string extensions declared in tested scope did not\n    // compile.\n    optional string test = 1002 [default=\"test\"];\n    // Used to test if generated extension name is correct when there are\n    // underscores.\n    optional string nested_string_extension = 1003;\n  }\n}\n\n// We have separate messages for testing required fields because it's\n// annoying to have to fill in required fields in TestProto in order to\n// do anything with it.  Note that we don't need to test every type of\n// required filed because the code output is basically identical to\n// optional fields for all types.\nmessage TestRequired {\n  required int32 a = 1;\n  optional int32 dummy2 = 2;\n  required int32 b = 3;\n\n  extend TestAllExtensions {\n    optional TestRequired single = 1000;\n    repeated TestRequired multi  = 1001;\n  }\n\n  // Pad the field count to 32 so that we can test that IsInitialized()\n  // properly checks multiple elements of has_bits_.\n  optional int32 dummy4  =  4;\n  optional int32 dummy5  =  5;\n  optional int32 dummy6  =  6;\n  optional int32 dummy7  =  7;\n  optional int32 dummy8  =  8;\n  optional int32 dummy9  =  9;\n  optional int32 dummy10 = 10;\n  optional int32 dummy11 = 11;\n  optional int32 dummy12 = 12;\n  optional int32 dummy13 = 13;\n  optional int32 dummy14 = 14;\n  optional int32 dummy15 = 15;\n  optional int32 dummy16 = 16;\n  optional int32 dummy17 = 17;\n  optional int32 dummy18 = 18;\n  optional int32 dummy19 = 19;\n  optional int32 dummy20 = 20;\n  optional int32 dummy21 = 21;\n  optional int32 dummy22 = 22;\n  optional int32 dummy23 = 23;\n  optional int32 dummy24 = 24;\n  optional int32 dummy25 = 25;\n  optional int32 dummy26 = 26;\n  optional int32 dummy27 = 27;\n  optional int32 dummy28 = 28;\n  optional int32 dummy29 = 29;\n  optional int32 dummy30 = 30;\n  optional int32 dummy31 = 31;\n  optional int32 dummy32 = 32;\n\n  required int32 c = 33;\n}\n\nmessage TestRequiredForeign {\n  optional TestRequired optional_message = 1;\n  repeated TestRequired repeated_message = 2;\n  optional int32 dummy = 3;\n}\n\n// Test that we can use NestedMessage from outside TestAllTypes.\nmessage TestForeignNested {\n  optional TestAllTypes.NestedMessage foreign_nested = 1;\n}\n\n// TestEmptyMessage is used to test unknown field support.\nmessage TestEmptyMessage {\n}\n\n// Like above, but declare all field numbers as potential extensions.  No\n// actual extensions should ever be defined for this type.\nmessage TestEmptyMessageWithExtensions {\n  extensions 1 to max;\n}\n\nmessage TestMultipleExtensionRanges {\n  extensions 42;\n  extensions 4143 to 4243;\n  extensions 65536 to max;\n}\n\n// Test that really large tag numbers don't break anything.\nmessage TestReallyLargeTagNumber {\n  // The largest possible tag number is 2^28 - 1, since the wire format uses\n  // three bits to communicate wire type.\n  optional int32 a = 1;\n  optional int32 bb = 268435455;\n}\n\nmessage TestRecursiveMessage {\n  optional TestRecursiveMessage a = 1;\n  optional int32 i = 2;\n}\n\n// Test that mutual recursion works.\nmessage TestMutualRecursionA {\n  optional TestMutualRecursionB bb = 1;\n}\n\nmessage TestMutualRecursionB {\n  optional TestMutualRecursionA a = 1;\n  optional int32 optional_int32 = 2;\n}\n\n// Test that groups have disjoint field numbers from their siblings and\n// parents.  This is NOT possible in proto1; only google.protobuf.  When attempting\n// to compile with proto1, this will emit an error; so we only include it\n// in protobuf_unittest_proto.\nmessage TestDupFieldNumber {                        // NO_PROTO1\n  optional int32 a = 1;                             // NO_PROTO1\n  optional group Foo = 2 { optional int32 a = 1; }  // NO_PROTO1\n  optional group Bar = 3 { optional int32 a = 1; }  // NO_PROTO1\n}                                                   // NO_PROTO1\n\n// Additional messages for testing lazy fields.\nmessage TestEagerMessage {\n  optional TestAllTypes sub_message = 1 [lazy=false];\n}\nmessage TestLazyMessage {\n  optional TestAllTypes sub_message = 1 [lazy=true];\n}\n\n// Needed for a Python test.\nmessage TestNestedMessageHasBits {\n  message NestedMessage {\n    repeated int32 nestedmessage_repeated_int32 = 1;\n    repeated ForeignMessage nestedmessage_repeated_foreignmessage = 2;\n  }\n  optional NestedMessage optional_nested_message = 1;\n}\n\n\n// Test an enum that has multiple values with the same number.\nenum TestEnumWithDupValue {\n  option allow_alias = true;\n\n  FOO1 = 1;\n  BAR1 = 2;\n  BAZ = 3;\n  FOO2 = 1;\n  BAR2 = 2;\n}\n\n// Test an enum with large, unordered values.\nenum TestSparseEnum {\n  SPARSE_A = 123;\n  SPARSE_B = 62374;\n  SPARSE_C = 12589234;\n  SPARSE_D = -15;\n  SPARSE_E = -53452;\n  SPARSE_F = 0;\n  SPARSE_G = 2;\n}\n\n// Test message with CamelCase field names.  This violates Protocol Buffer\n// standard style.\nmessage TestCamelCaseFieldNames {\n  optional int32 PrimitiveField = 1;\n  optional string StringField = 2;\n  optional ForeignEnum EnumField = 3;\n  optional ForeignMessage MessageField = 4;\n  optional string StringPieceField = 5 [ctype=STRING_PIECE];\n  optional string CordField = 6 [ctype=CORD];\n\n  repeated int32 RepeatedPrimitiveField = 7;\n  repeated string RepeatedStringField = 8;\n  repeated ForeignEnum RepeatedEnumField = 9;\n  repeated ForeignMessage RepeatedMessageField = 10;\n  repeated string RepeatedStringPieceField = 11 [ctype=STRING_PIECE];\n  repeated string RepeatedCordField = 12 [ctype=CORD];\n}\n\n\n// We list fields out of order, to ensure that we're using field number and not\n// field index to determine serialization order.\nmessage TestFieldOrderings {\n  optional string my_string = 11;\n  extensions 2 to 10;\n  optional int64 my_int = 1;\n  extensions 12 to 100;\n  optional float my_float = 101;\n  message NestedMessage {\n    optional int64 oo = 2;\n    // The field name \"b\" fails to compile in proto1 because it conflicts with\n    // a local variable named \"b\" in one of the generated methods.  Doh.\n    // This file needs to compile in proto1 to test backwards-compatibility.\n    optional int32 bb = 1;\n  }\n\n  optional NestedMessage optional_nested_message  = 200;\n}\n\n\nextend TestFieldOrderings {\n  optional string my_extension_string = 50;\n  optional int32 my_extension_int = 5;\n}\n\n\nmessage TestExtremeDefaultValues {\n  optional bytes escaped_bytes = 1 [default = \"\\0\\001\\a\\b\\f\\n\\r\\t\\v\\\\\\'\\\"\\xfe\"];\n  optional uint32 large_uint32 = 2 [default = 0xFFFFFFFF];\n  optional uint64 large_uint64 = 3 [default = 0xFFFFFFFFFFFFFFFF];\n  optional  int32 small_int32  = 4 [default = -0x7FFFFFFF];\n  optional  int64 small_int64  = 5 [default = -0x7FFFFFFFFFFFFFFF];\n  optional  int32 really_small_int32 = 21 [default = -0x80000000];\n  optional  int64 really_small_int64 = 22 [default = -0x8000000000000000];\n\n  // The default value here is UTF-8 for \"\\u1234\".  (We could also just type\n  // the UTF-8 text directly into this text file rather than escape it, but\n  // lots of people use editors that would be confused by this.)\n  optional string utf8_string = 6 [default = \"\\341\\210\\264\"];\n\n  // Tests for single-precision floating-point values.\n  optional float zero_float = 7 [default = 0];\n  optional float one_float = 8 [default = 1];\n  optional float small_float = 9 [default = 1.5];\n  optional float negative_one_float = 10 [default = -1];\n  optional float negative_float = 11 [default = -1.5];\n  // Using exponents\n  optional float large_float = 12 [default = 2E8];\n  optional float small_negative_float = 13 [default = -8e-28];\n\n  // Text for nonfinite floating-point values.\n  optional double inf_double = 14 [default = inf];\n  optional double neg_inf_double = 15 [default = -inf];\n  optional double nan_double = 16 [default = nan];\n  optional float inf_float = 17 [default = inf];\n  optional float neg_inf_float = 18 [default = -inf];\n  optional float nan_float = 19 [default = nan];\n\n  // Tests for C++ trigraphs.\n  // Trigraphs should be escaped in C++ generated files, but they should not be\n  // escaped for other languages.\n  // Note that in .proto file, \"\\?\" is a valid way to escape ? in string\n  // literals.\n  optional string cpp_trigraph = 20 [default = \"? \\? ?? \\?? \\??? ??/ ?\\?-\"];\n\n  // String defaults containing the character '\\000'\n  optional string string_with_zero       = 23 [default = \"hel\\000lo\"];\n  optional  bytes bytes_with_zero        = 24 [default = \"wor\\000ld\"];\n  optional string string_piece_with_zero = 25 [ctype=STRING_PIECE,\n                                               default=\"ab\\000c\"];\n  optional string cord_with_zero         = 26 [ctype=CORD,\n                                               default=\"12\\0003\"];\n  optional string replacement_string     = 27 [default=\"${unknown}\"];\n}\n\nmessage SparseEnumMessage {\n  optional TestSparseEnum sparse_enum = 1;\n}\n\n// Test String and Bytes: string is for valid UTF-8 strings\nmessage OneString {\n  optional string data = 1;\n}\n\nmessage MoreString {\n  repeated string data = 1;\n}\n\nmessage OneBytes {\n  optional bytes data = 1;\n}\n\nmessage MoreBytes {\n  repeated bytes data = 1;\n}\n\n// Test int32, uint32, int64, uint64, and bool are all compatible\nmessage Int32Message {\n  optional int32 data = 1;\n}\n\nmessage Uint32Message {\n  optional uint32 data = 1;\n}\n\nmessage Int64Message {\n  optional int64 data = 1;\n}\n\nmessage Uint64Message {\n  optional uint64 data = 1;\n}\n\nmessage BoolMessage {\n  optional bool data = 1;\n}\n\n// Test oneofs.\nmessage TestOneof {\n  oneof foo {\n    int32 foo_int = 1;\n    string foo_string = 2;\n    TestAllTypes foo_message = 3;\n    group FooGroup = 4 {\n      optional int32 a = 5;\n      optional string b = 6;\n    }\n  }\n}\n\nmessage TestOneofBackwardsCompatible {\n  optional int32 foo_int = 1;\n  optional string foo_string = 2;\n  optional TestAllTypes foo_message = 3;\n  optional group FooGroup = 4 {\n    optional int32 a = 5;\n    optional string b = 6;\n  }\n}\n\nmessage TestOneof2 {\n  oneof foo {\n    int32 foo_int = 1;\n    string foo_string = 2;\n    string foo_cord = 3 [ctype=CORD];\n    string foo_string_piece = 4 [ctype=STRING_PIECE];\n    bytes foo_bytes = 5;\n    NestedEnum foo_enum = 6;\n    NestedMessage foo_message = 7;\n    group FooGroup = 8 {\n      optional int32 a = 9;\n      optional string b = 10;\n    }\n    NestedMessage foo_lazy_message = 11 [lazy=true];\n  }\n\n  oneof bar {\n    int32 bar_int = 12 [default = 5];\n    string bar_string = 13 [default = \"STRING\"];\n    string bar_cord = 14 [ctype=CORD, default = \"CORD\"];\n    string bar_string_piece = 15 [ctype=STRING_PIECE, default = \"SPIECE\"];\n    bytes bar_bytes = 16 [default = \"BYTES\"];\n    NestedEnum bar_enum = 17 [default = BAR];\n  }\n\n  optional int32 baz_int = 18;\n  optional string baz_string = 19 [default = \"BAZ\"];\n\n  message NestedMessage {\n    optional int64 qux_int = 1;\n    repeated int32 corge_int = 2;\n  }\n\n  enum NestedEnum {\n    FOO = 1;\n    BAR = 2;\n    BAZ = 3;\n  }\n}\n\nmessage TestRequiredOneof {\n  oneof foo {\n    int32 foo_int = 1;\n    string foo_string = 2;\n    NestedMessage foo_message = 3;\n  }\n  message NestedMessage {\n    required double required_double = 1;\n  }\n}\n\n\n// Test messages for packed fields\n\nmessage TestPackedTypes {\n  repeated    int32 packed_int32    =  90 [packed = true];\n  repeated    int64 packed_int64    =  91 [packed = true];\n  repeated   uint32 packed_uint32   =  92 [packed = true];\n  repeated   uint64 packed_uint64   =  93 [packed = true];\n  repeated   sint32 packed_sint32   =  94 [packed = true];\n  repeated   sint64 packed_sint64   =  95 [packed = true];\n  repeated  fixed32 packed_fixed32  =  96 [packed = true];\n  repeated  fixed64 packed_fixed64  =  97 [packed = true];\n  repeated sfixed32 packed_sfixed32 =  98 [packed = true];\n  repeated sfixed64 packed_sfixed64 =  99 [packed = true];\n  repeated    float packed_float    = 100 [packed = true];\n  repeated   double packed_double   = 101 [packed = true];\n  repeated     bool packed_bool     = 102 [packed = true];\n  repeated ForeignEnum packed_enum  = 103 [packed = true];\n}\n\n// A message with the same fields as TestPackedTypes, but without packing. Used\n// to test packed <-> unpacked wire compatibility.\nmessage TestUnpackedTypes {\n  repeated    int32 unpacked_int32    =  90 [packed = false];\n  repeated    int64 unpacked_int64    =  91 [packed = false];\n  repeated   uint32 unpacked_uint32   =  92 [packed = false];\n  repeated   uint64 unpacked_uint64   =  93 [packed = false];\n  repeated   sint32 unpacked_sint32   =  94 [packed = false];\n  repeated   sint64 unpacked_sint64   =  95 [packed = false];\n  repeated  fixed32 unpacked_fixed32  =  96 [packed = false];\n  repeated  fixed64 unpacked_fixed64  =  97 [packed = false];\n  repeated sfixed32 unpacked_sfixed32 =  98 [packed = false];\n  repeated sfixed64 unpacked_sfixed64 =  99 [packed = false];\n  repeated    float unpacked_float    = 100 [packed = false];\n  repeated   double unpacked_double   = 101 [packed = false];\n  repeated     bool unpacked_bool     = 102 [packed = false];\n  repeated ForeignEnum unpacked_enum  = 103 [packed = false];\n}\n\nmessage TestPackedExtensions {\n  extensions 1 to max;\n}\n\nextend TestPackedExtensions {\n  repeated    int32 packed_int32_extension    =  90 [packed = true];\n  repeated    int64 packed_int64_extension    =  91 [packed = true];\n  repeated   uint32 packed_uint32_extension   =  92 [packed = true];\n  repeated   uint64 packed_uint64_extension   =  93 [packed = true];\n  repeated   sint32 packed_sint32_extension   =  94 [packed = true];\n  repeated   sint64 packed_sint64_extension   =  95 [packed = true];\n  repeated  fixed32 packed_fixed32_extension  =  96 [packed = true];\n  repeated  fixed64 packed_fixed64_extension  =  97 [packed = true];\n  repeated sfixed32 packed_sfixed32_extension =  98 [packed = true];\n  repeated sfixed64 packed_sfixed64_extension =  99 [packed = true];\n  repeated    float packed_float_extension    = 100 [packed = true];\n  repeated   double packed_double_extension   = 101 [packed = true];\n  repeated     bool packed_bool_extension     = 102 [packed = true];\n  repeated ForeignEnum packed_enum_extension  = 103 [packed = true];\n}\n\nmessage TestUnpackedExtensions {\n  extensions 1 to max;\n}\n\nextend TestUnpackedExtensions {\n  repeated    int32 unpacked_int32_extension    =  90 [packed = false];\n  repeated    int64 unpacked_int64_extension    =  91 [packed = false];\n  repeated   uint32 unpacked_uint32_extension   =  92 [packed = false];\n  repeated   uint64 unpacked_uint64_extension   =  93 [packed = false];\n  repeated   sint32 unpacked_sint32_extension   =  94 [packed = false];\n  repeated   sint64 unpacked_sint64_extension   =  95 [packed = false];\n  repeated  fixed32 unpacked_fixed32_extension  =  96 [packed = false];\n  repeated  fixed64 unpacked_fixed64_extension  =  97 [packed = false];\n  repeated sfixed32 unpacked_sfixed32_extension =  98 [packed = false];\n  repeated sfixed64 unpacked_sfixed64_extension =  99 [packed = false];\n  repeated    float unpacked_float_extension    = 100 [packed = false];\n  repeated   double unpacked_double_extension   = 101 [packed = false];\n  repeated     bool unpacked_bool_extension     = 102 [packed = false];\n  repeated ForeignEnum unpacked_enum_extension  = 103 [packed = false];\n}\n\n// Used by ExtensionSetTest/DynamicExtensions.  The test actually builds\n// a set of extensions to TestAllExtensions dynamically, based on the fields\n// of this message type.\nmessage TestDynamicExtensions {\n  enum DynamicEnumType {\n    DYNAMIC_FOO = 2200;\n    DYNAMIC_BAR = 2201;\n    DYNAMIC_BAZ = 2202;\n  }\n  message DynamicMessageType {\n    optional int32 dynamic_field = 2100;\n  }\n\n  optional fixed32 scalar_extension = 2000;\n  optional ForeignEnum enum_extension = 2001;\n  optional DynamicEnumType dynamic_enum_extension = 2002;\n\n  optional ForeignMessage message_extension = 2003;\n  optional DynamicMessageType dynamic_message_extension = 2004;\n\n  repeated string repeated_extension = 2005;\n  repeated sint32 packed_extension = 2006 [packed = true];\n}\n\nmessage TestRepeatedScalarDifferentTagSizes {\n  // Parsing repeated fixed size values used to fail. This message needs to be\n  // used in order to get a tag of the right size; all of the repeated fields\n  // in TestAllTypes didn't trigger the check.\n  repeated fixed32 repeated_fixed32 = 12;\n  // Check for a varint type, just for good measure.\n  repeated int32   repeated_int32   = 13;\n\n  // These have two-byte tags.\n  repeated fixed64 repeated_fixed64 = 2046;\n  repeated int64   repeated_int64   = 2047;\n\n  // Three byte tags.\n  repeated float   repeated_float   = 262142;\n  repeated uint64  repeated_uint64  = 262143;\n}\n\n// Test that if an optional or required message/group field appears multiple\n// times in the input, they need to be merged.\nmessage TestParsingMerge {\n  // RepeatedFieldsGenerator defines matching field types as TestParsingMerge,\n  // except that all fields are repeated. In the tests, we will serialize the\n  // RepeatedFieldsGenerator to bytes, and parse the bytes to TestParsingMerge.\n  // Repeated fields in RepeatedFieldsGenerator are expected to be merged into\n  // the corresponding required/optional fields in TestParsingMerge.\n  message RepeatedFieldsGenerator {\n    repeated TestAllTypes field1 = 1;\n    repeated TestAllTypes field2 = 2;\n    repeated TestAllTypes field3 = 3;\n    repeated group Group1 = 10 {\n      optional TestAllTypes field1 = 11;\n    }\n    repeated group Group2 = 20 {\n      optional TestAllTypes field1 = 21;\n    }\n    repeated TestAllTypes ext1 = 1000;\n    repeated TestAllTypes ext2 = 1001;\n  }\n  required TestAllTypes required_all_types = 1;\n  optional TestAllTypes optional_all_types = 2;\n  repeated TestAllTypes repeated_all_types = 3;\n  optional group OptionalGroup = 10 {\n    optional TestAllTypes optional_group_all_types = 11;\n  }\n  repeated group RepeatedGroup = 20 {\n    optional TestAllTypes repeated_group_all_types = 21;\n  }\n  extensions 1000 to max;\n  extend TestParsingMerge {\n    optional TestAllTypes optional_ext = 1000;\n    repeated TestAllTypes repeated_ext = 1001;\n  }\n}\n\nmessage TestCommentInjectionMessage {\n  // */ <- This should not close the generated doc comment\n  optional string a = 1 [default=\"*/ <- Neither should this.\"];\n}\n\n\n// Test that RPC services work.\nmessage FooRequest  {}\nmessage FooResponse {}\n\nmessage FooClientMessage {}\nmessage FooServerMessage{}\n\nservice TestService {\n  rpc Foo(FooRequest) returns (FooResponse);\n  rpc Bar(BarRequest) returns (BarResponse);\n}\n\n\nmessage BarRequest  {}\nmessage BarResponse {}\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_arena.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto2\";\n\nimport \"google/protobuf/unittest_no_arena_import.proto\";\n\npackage proto2_arena_unittest;\n\noption cc_enable_arenas = true;\n\nmessage NestedMessage {\n  optional int32 d = 1;\n}\n\nmessage ArenaMessage {\n  repeated NestedMessage  repeated_nested_message = 1;\n  repeated ImportNoArenaNestedMessage  repeated_import_no_arena_message = 2;\n};\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_custom_options.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: benjy@google.com (Benjy Weinberger)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// A proto file used to test the \"custom options\" feature of google.protobuf.\n\nsyntax = \"proto2\";\n\n// Some generic_services option(s) added automatically.\n// See:  http://go/proto2-generic-services-default\noption cc_generic_services = true;     // auto-added\noption java_generic_services = true;   // auto-added\noption py_generic_services = true;\n\n// A custom file option (defined below).\noption (file_opt1) = 9876543210;\n\nimport \"google/protobuf/descriptor.proto\";\n\n// We don't put this in a package within proto2 because we need to make sure\n// that the generated code doesn't depend on being in the proto2 namespace.\npackage protobuf_unittest;\n\n\n// Some simple test custom options of various types.\n\nextend google.protobuf.FileOptions {\n  optional uint64 file_opt1 = 7736974;\n}\n\nextend google.protobuf.MessageOptions {\n  optional int32 message_opt1 = 7739036;\n}\n\nextend google.protobuf.FieldOptions {\n  optional fixed64 field_opt1 = 7740936;\n  // This is useful for testing that we correctly register default values for\n  // extension options.\n  optional int32 field_opt2 = 7753913 [default=42];\n}\n\nextend google.protobuf.OneofOptions {\n  optional int32 oneof_opt1 = 7740111;\n}\n\nextend google.protobuf.EnumOptions {\n  optional sfixed32 enum_opt1 = 7753576;\n}\n\nextend google.protobuf.EnumValueOptions {\n  optional int32 enum_value_opt1 = 1560678;\n}\n\nextend google.protobuf.ServiceOptions {\n  optional sint64 service_opt1 = 7887650;\n}\n\nenum MethodOpt1 {\n  METHODOPT1_VAL1 = 1;\n  METHODOPT1_VAL2 = 2;\n}\n\nextend google.protobuf.MethodOptions {\n  optional MethodOpt1 method_opt1 = 7890860;\n}\n\n// A test message with custom options at all possible locations (and also some\n// regular options, to make sure they interact nicely).\nmessage TestMessageWithCustomOptions {\n  option message_set_wire_format = false;\n\n  option (message_opt1) = -56;\n\n  optional string field1 = 1 [ctype=CORD,\n                              (field_opt1)=8765432109];\n\n  oneof AnOneof {\n    option (oneof_opt1) = -99;\n    int32 oneof_field = 2;\n  }\n\n  enum AnEnum {\n    option (enum_opt1) = -789;\n\n    ANENUM_VAL1 = 1;\n    ANENUM_VAL2 = 2 [(enum_value_opt1) = 123];\n  }\n}\n\n\n// A test RPC service with custom options at all possible locations (and also\n// some regular options, to make sure they interact nicely).\nmessage CustomOptionFooRequest {\n}\n\nmessage CustomOptionFooResponse {\n}\n\nmessage CustomOptionFooClientMessage {\n}\n\nmessage CustomOptionFooServerMessage {\n}\n\nservice TestServiceWithCustomOptions {\n  option (service_opt1) = -9876543210;\n\n  rpc Foo(CustomOptionFooRequest) returns (CustomOptionFooResponse) {\n    option (method_opt1) = METHODOPT1_VAL2;\n  }\n}\n\n\n\n// Options of every possible field type, so we can test them all exhaustively.\n\nmessage DummyMessageContainingEnum {\n  enum TestEnumType {\n    TEST_OPTION_ENUM_TYPE1 = 22;\n    TEST_OPTION_ENUM_TYPE2 = -23;\n  }\n}\n\nmessage DummyMessageInvalidAsOptionType {\n}\n\nextend google.protobuf.MessageOptions {\n  optional         bool     bool_opt = 7706090;\n  optional        int32    int32_opt = 7705709;\n  optional        int64    int64_opt = 7705542;\n  optional       uint32   uint32_opt = 7704880;\n  optional       uint64   uint64_opt = 7702367;\n  optional       sint32   sint32_opt = 7701568;\n  optional       sint64   sint64_opt = 7700863;\n  optional      fixed32  fixed32_opt = 7700307;\n  optional      fixed64  fixed64_opt = 7700194;\n  optional     sfixed32 sfixed32_opt = 7698645;\n  optional     sfixed64 sfixed64_opt = 7685475;\n  optional        float    float_opt = 7675390;\n  optional       double   double_opt = 7673293;\n  optional       string   string_opt = 7673285;\n  optional        bytes    bytes_opt = 7673238;\n  optional DummyMessageContainingEnum.TestEnumType enum_opt = 7673233;\n  optional DummyMessageInvalidAsOptionType message_type_opt = 7665967;\n}\n\nmessage CustomOptionMinIntegerValues {\n  option     (bool_opt) = false;\n  option    (int32_opt) = -0x80000000;\n  option    (int64_opt) = -0x8000000000000000;\n  option   (uint32_opt) = 0;\n  option   (uint64_opt) = 0;\n  option   (sint32_opt) = -0x80000000;\n  option   (sint64_opt) = -0x8000000000000000;\n  option  (fixed32_opt) = 0;\n  option  (fixed64_opt) = 0;\n  option (sfixed32_opt) = -0x80000000;\n  option (sfixed64_opt) = -0x8000000000000000;\n}\n\nmessage CustomOptionMaxIntegerValues {\n  option     (bool_opt) = true;\n  option    (int32_opt) = 0x7FFFFFFF;\n  option    (int64_opt) = 0x7FFFFFFFFFFFFFFF;\n  option   (uint32_opt) = 0xFFFFFFFF;\n  option   (uint64_opt) = 0xFFFFFFFFFFFFFFFF;\n  option   (sint32_opt) = 0x7FFFFFFF;\n  option   (sint64_opt) = 0x7FFFFFFFFFFFFFFF;\n  option  (fixed32_opt) = 0xFFFFFFFF;\n  option  (fixed64_opt) = 0xFFFFFFFFFFFFFFFF;\n  option (sfixed32_opt) = 0x7FFFFFFF;\n  option (sfixed64_opt) = 0x7FFFFFFFFFFFFFFF;\n}\n\nmessage CustomOptionOtherValues {\n  option  (int32_opt) = -100;  // To test sign-extension.\n  option  (float_opt) = 12.3456789;\n  option (double_opt) = 1.234567890123456789;\n  option (string_opt) = \"Hello, \\\"World\\\"\";\n  option  (bytes_opt) = \"Hello\\0World\";\n  option   (enum_opt) = TEST_OPTION_ENUM_TYPE2;\n}\n\nmessage SettingRealsFromPositiveInts {\n  option  (float_opt) = 12;\n  option (double_opt) = 154;\n}\n\nmessage SettingRealsFromNegativeInts {\n  option  (float_opt) = -12;\n  option  (double_opt) = -154;\n}\n\n// Options of complex message types, themselves combined and extended in\n// various ways.\n\nmessage ComplexOptionType1 {\n  optional int32 foo = 1;\n  optional int32 foo2 = 2;\n  optional int32 foo3 = 3;\n  repeated int32 foo4 = 4;\n\n  extensions 100 to max;\n}\n\nmessage ComplexOptionType2 {\n  optional ComplexOptionType1 bar = 1;\n  optional int32 baz = 2;\n\n  message ComplexOptionType4 {\n    optional int32 waldo = 1;\n\n    extend google.protobuf.MessageOptions {\n      optional ComplexOptionType4 complex_opt4 = 7633546;\n    }\n  }\n\n  optional ComplexOptionType4 fred = 3;\n  repeated ComplexOptionType4 barney = 4;\n\n  extensions 100 to max;\n}\n\nmessage ComplexOptionType3 {\n  optional int32 qux = 1;\n\n  optional group ComplexOptionType5 = 2 {\n    optional int32 plugh = 3;\n  }\n}\n\nextend ComplexOptionType1 {\n  optional int32 quux = 7663707;\n  optional ComplexOptionType3 corge = 7663442;\n}\n\nextend ComplexOptionType2 {\n  optional int32 grault = 7650927;\n  optional ComplexOptionType1 garply = 7649992;\n}\n\nextend google.protobuf.MessageOptions {\n  optional protobuf_unittest.ComplexOptionType1 complex_opt1 = 7646756;\n  optional ComplexOptionType2 complex_opt2 = 7636949;\n  optional ComplexOptionType3 complex_opt3 = 7636463;\n  optional group ComplexOpt6 = 7595468 {\n    optional int32 xyzzy = 7593951;\n  }\n}\n\n// Note that we try various different ways of naming the same extension.\nmessage VariousComplexOptions {\n  option (.protobuf_unittest.complex_opt1).foo = 42;\n  option (protobuf_unittest.complex_opt1).(.protobuf_unittest.quux) = 324;\n  option (.protobuf_unittest.complex_opt1).(protobuf_unittest.corge).qux = 876;\n  option (protobuf_unittest.complex_opt1).foo4 = 99;\n  option (protobuf_unittest.complex_opt1).foo4 = 88;\n  option (complex_opt2).baz = 987;\n  option (complex_opt2).(grault) = 654;\n  option (complex_opt2).bar.foo = 743;\n  option (complex_opt2).bar.(quux) = 1999;\n  option (complex_opt2).bar.(protobuf_unittest.corge).qux = 2008;\n  option (complex_opt2).(garply).foo = 741;\n  option (complex_opt2).(garply).(.protobuf_unittest.quux) = 1998;\n  option (complex_opt2).(protobuf_unittest.garply).(corge).qux = 2121;\n  option (ComplexOptionType2.ComplexOptionType4.complex_opt4).waldo = 1971;\n  option (complex_opt2).fred.waldo = 321;\n  option (complex_opt2).barney = { waldo: 101 };\n  option (complex_opt2).barney = { waldo: 212 };\n  option (protobuf_unittest.complex_opt3).qux = 9;\n  option (complex_opt3).complexoptiontype5.plugh = 22;\n  option (complexopt6).xyzzy = 24;\n}\n\n// ------------------------------------------------------\n// Definitions for testing aggregate option parsing.\n// See descriptor_unittest.cc.\n\nmessage AggregateMessageSet {\n  option message_set_wire_format = true;\n  extensions 4 to max;\n}\n\nmessage AggregateMessageSetElement {\n  extend AggregateMessageSet {\n    optional AggregateMessageSetElement message_set_extension = 15447542;\n  }\n  optional string s = 1;\n}\n\n// A helper type used to test aggregate option parsing\nmessage Aggregate {\n  optional int32 i = 1;\n  optional string s = 2;\n\n  // A nested object\n  optional Aggregate sub = 3;\n\n  // To test the parsing of extensions inside aggregate values\n  optional google.protobuf.FileOptions file = 4;\n  extend google.protobuf.FileOptions {\n    optional Aggregate nested = 15476903;\n  }\n\n  // An embedded message set\n  optional AggregateMessageSet mset = 5;\n}\n\n// Allow Aggregate to be used as an option at all possible locations\n// in the .proto grammer.\nextend google.protobuf.FileOptions      { optional Aggregate fileopt    = 15478479; }\nextend google.protobuf.MessageOptions   { optional Aggregate msgopt     = 15480088; }\nextend google.protobuf.FieldOptions     { optional Aggregate fieldopt   = 15481374; }\nextend google.protobuf.EnumOptions      { optional Aggregate enumopt    = 15483218; }\nextend google.protobuf.EnumValueOptions { optional Aggregate enumvalopt = 15486921; }\nextend google.protobuf.ServiceOptions   { optional Aggregate serviceopt = 15497145; }\nextend google.protobuf.MethodOptions    { optional Aggregate methodopt  = 15512713; }\n\n// Try using AggregateOption at different points in the proto grammar\noption (fileopt) = {\n  s: 'FileAnnotation'\n  // Also test the handling of comments\n  /* of both types */ i: 100\n\n  sub { s: 'NestedFileAnnotation' }\n\n  // Include a google.protobuf.FileOptions and recursively extend it with\n  // another fileopt.\n  file {\n    [protobuf_unittest.fileopt] {\n      s:'FileExtensionAnnotation'\n    }\n  }\n\n  // A message set inside an option value\n  mset {\n    [protobuf_unittest.AggregateMessageSetElement.message_set_extension] {\n      s: 'EmbeddedMessageSetElement'\n    }\n  }\n};\n\nmessage AggregateMessage {\n  option (msgopt) = { i:101 s:'MessageAnnotation' };\n  optional int32 fieldname = 1 [(fieldopt) = { s:'FieldAnnotation' }];\n}\n\nservice AggregateService {\n  option (serviceopt) = { s:'ServiceAnnotation' };\n  rpc Method (AggregateMessage) returns (AggregateMessage) {\n    option (methodopt) = { s:'MethodAnnotation' };\n  }\n}\n\nenum AggregateEnum {\n  option (enumopt) = { s:'EnumAnnotation' };\n  VALUE = 1 [(enumvalopt) = { s:'EnumValueAnnotation' }];\n}\n\n// Test custom options for nested type.\nmessage NestedOptionType {\n  message NestedMessage {\n    option (message_opt1) = 1001;\n    optional int32 nested_field = 1 [(field_opt1) = 1002];\n  }\n  enum NestedEnum {\n    option (enum_opt1) = 1003;\n    NESTED_ENUM_VALUE = 1 [(enum_value_opt1) = 1004];\n  }\n  extend google.protobuf.FileOptions {\n    optional int32 nested_extension = 7912573 [(field_opt2) = 1005];\n  }\n}\n\n// Custom message option that has a required enum field.\n// WARNING: this is strongly discouraged!\nmessage OldOptionType {\n  enum TestEnum {\n    OLD_VALUE = 0;\n  }\n  required TestEnum value = 1;\n}\n\n// Updated version of the custom option above.\nmessage NewOptionType {\n  enum TestEnum {\n    OLD_VALUE = 0;\n    NEW_VALUE = 1;\n  }\n  required TestEnum value = 1;\n}\n\nextend google.protobuf.MessageOptions {\n  optional OldOptionType required_enum_opt = 106161807;\n}\n\n// Test message using the \"required_enum_opt\" option defined above.\nmessage TestMessageWithRequiredEnumOption {\n  option (required_enum_opt) = { value: OLD_VALUE };\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_drop_unknown_fields.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto3\";\n\npackage unittest_drop_unknown_fields;\noption objc_class_prefix = \"DropUnknowns\";\n\noption csharp_namespace = \"Google.Protobuf.TestProtos\";\n\nmessage Foo {\n  enum NestedEnum {\n    FOO = 0;\n    BAR = 1;\n    BAZ = 2;\n  }\n  int32 int32_value = 1;\n  NestedEnum enum_value = 2;\n}\n\nmessage FooWithExtraFields {\n  enum NestedEnum {\n    FOO = 0;\n    BAR = 1;\n    BAZ = 2;\n    QUX = 3;\n  }\n  int32 int32_value = 1;\n  NestedEnum enum_value = 2;\n  int32 extra_int32_value = 3;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_embed_optimize_for.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// A proto file which imports a proto file that uses optimize_for = CODE_SIZE.\n\nsyntax = \"proto2\";\nimport \"google/protobuf/unittest_optimize_for.proto\";\n\npackage protobuf_unittest;\n\n// We optimize for speed here, but we are importing a proto that is optimized\n// for code size.\noption optimize_for = SPEED;\n\nmessage TestEmbedOptimizedForSize {\n  // Test that embedding a message which has optimize_for = CODE_SIZE into\n  // one optimized for speed works.\n  optional TestOptimizedForSize optional_message = 1;\n  repeated TestOptimizedForSize repeated_message = 2;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_empty.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This file intentionally left blank.  (At one point this wouldn't compile\n// correctly.)\n\nsyntax = \"proto2\";\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_enormous_descriptor.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// A proto file that has an extremely large descriptor.  Used to test that\n// descriptors over 64k don't break language-specific limits in generated code,\n// such as the string literal length limit in Java.\n\nsyntax = \"proto2\";\n\npackage google.protobuf;\noption java_package = \"com.google.protobuf\";\n\n// Avoid generating insanely long methods.\noption optimize_for = CODE_SIZE;\n\nmessage TestEnormousDescriptor {\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_1 = 1 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_2 = 2 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_3 = 3 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_4 = 4 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_5 = 5 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_6 = 6 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_7 = 7 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_8 = 8 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_9 = 9 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_10 = 10 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_11 = 11 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_12 = 12 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_13 = 13 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_14 = 14 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_15 = 15 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_16 = 16 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_17 = 17 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_18 = 18 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_19 = 19 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_20 = 20 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_21 = 21 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_22 = 22 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_23 = 23 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_24 = 24 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_25 = 25 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_26 = 26 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_27 = 27 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_28 = 28 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_29 = 29 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_30 = 30 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_31 = 31 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_32 = 32 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_33 = 33 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_34 = 34 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_35 = 35 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_36 = 36 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_37 = 37 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_38 = 38 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_39 = 39 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_40 = 40 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_41 = 41 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_42 = 42 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_43 = 43 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_44 = 44 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_45 = 45 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_46 = 46 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_47 = 47 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_48 = 48 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_49 = 49 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_50 = 50 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_51 = 51 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_52 = 52 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_53 = 53 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_54 = 54 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_55 = 55 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_56 = 56 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_57 = 57 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_58 = 58 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_59 = 59 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_60 = 60 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_61 = 61 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_62 = 62 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_63 = 63 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_64 = 64 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_65 = 65 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_66 = 66 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_67 = 67 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_68 = 68 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_69 = 69 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_70 = 70 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_71 = 71 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_72 = 72 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_73 = 73 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_74 = 74 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_75 = 75 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_76 = 76 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_77 = 77 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_78 = 78 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_79 = 79 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_80 = 80 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_81 = 81 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_82 = 82 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_83 = 83 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_84 = 84 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_85 = 85 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_86 = 86 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_87 = 87 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_88 = 88 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_89 = 89 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_90 = 90 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_91 = 91 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_92 = 92 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_93 = 93 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_94 = 94 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_95 = 95 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_96 = 96 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_97 = 97 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_98 = 98 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_99 = 99 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_100 = 100 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_101 = 101 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_102 = 102 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_103 = 103 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_104 = 104 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_105 = 105 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_106 = 106 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_107 = 107 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_108 = 108 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_109 = 109 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_110 = 110 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_111 = 111 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_112 = 112 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_113 = 113 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_114 = 114 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_115 = 115 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_116 = 116 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_117 = 117 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_118 = 118 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_119 = 119 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_120 = 120 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_121 = 121 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_122 = 122 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_123 = 123 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_124 = 124 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_125 = 125 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_126 = 126 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_127 = 127 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_128 = 128 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_129 = 129 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_130 = 130 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_131 = 131 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_132 = 132 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_133 = 133 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_134 = 134 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_135 = 135 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_136 = 136 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_137 = 137 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_138 = 138 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_139 = 139 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_140 = 140 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_141 = 141 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_142 = 142 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_143 = 143 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_144 = 144 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_145 = 145 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_146 = 146 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_147 = 147 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_148 = 148 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_149 = 149 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_150 = 150 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_151 = 151 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_152 = 152 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_153 = 153 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_154 = 154 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_155 = 155 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_156 = 156 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_157 = 157 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_158 = 158 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_159 = 159 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_160 = 160 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_161 = 161 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_162 = 162 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_163 = 163 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_164 = 164 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_165 = 165 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_166 = 166 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_167 = 167 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_168 = 168 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_169 = 169 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_170 = 170 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_171 = 171 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_172 = 172 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_173 = 173 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_174 = 174 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_175 = 175 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_176 = 176 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_177 = 177 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_178 = 178 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_179 = 179 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_180 = 180 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_181 = 181 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_182 = 182 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_183 = 183 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_184 = 184 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_185 = 185 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_186 = 186 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_187 = 187 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_188 = 188 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_189 = 189 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_190 = 190 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_191 = 191 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_192 = 192 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_193 = 193 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_194 = 194 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_195 = 195 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_196 = 196 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_197 = 197 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_198 = 198 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_199 = 199 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_200 = 200 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_201 = 201 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_202 = 202 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_203 = 203 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_204 = 204 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_205 = 205 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_206 = 206 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_207 = 207 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_208 = 208 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_209 = 209 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_210 = 210 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_211 = 211 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_212 = 212 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_213 = 213 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_214 = 214 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_215 = 215 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_216 = 216 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_217 = 217 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_218 = 218 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_219 = 219 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_220 = 220 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_221 = 221 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_222 = 222 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_223 = 223 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_224 = 224 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_225 = 225 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_226 = 226 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_227 = 227 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_228 = 228 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_229 = 229 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_230 = 230 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_231 = 231 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_232 = 232 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_233 = 233 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_234 = 234 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_235 = 235 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_236 = 236 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_237 = 237 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_238 = 238 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_239 = 239 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_240 = 240 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_241 = 241 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_242 = 242 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_243 = 243 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_244 = 244 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_245 = 245 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_246 = 246 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_247 = 247 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_248 = 248 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_249 = 249 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_250 = 250 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_251 = 251 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_252 = 252 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_253 = 253 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_254 = 254 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_255 = 255 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_256 = 256 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_257 = 257 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_258 = 258 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_259 = 259 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_260 = 260 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_261 = 261 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_262 = 262 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_263 = 263 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_264 = 264 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_265 = 265 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_266 = 266 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_267 = 267 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_268 = 268 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_269 = 269 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_270 = 270 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_271 = 271 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_272 = 272 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_273 = 273 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_274 = 274 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_275 = 275 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_276 = 276 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_277 = 277 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_278 = 278 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_279 = 279 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_280 = 280 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_281 = 281 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_282 = 282 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_283 = 283 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_284 = 284 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_285 = 285 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_286 = 286 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_287 = 287 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_288 = 288 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_289 = 289 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_290 = 290 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_291 = 291 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_292 = 292 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_293 = 293 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_294 = 294 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_295 = 295 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_296 = 296 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_297 = 297 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_298 = 298 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_299 = 299 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_300 = 300 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_301 = 301 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_302 = 302 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_303 = 303 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_304 = 304 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_305 = 305 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_306 = 306 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_307 = 307 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_308 = 308 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_309 = 309 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_310 = 310 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_311 = 311 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_312 = 312 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_313 = 313 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_314 = 314 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_315 = 315 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_316 = 316 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_317 = 317 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_318 = 318 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_319 = 319 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_320 = 320 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_321 = 321 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_322 = 322 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_323 = 323 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_324 = 324 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_325 = 325 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_326 = 326 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_327 = 327 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_328 = 328 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_329 = 329 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_330 = 330 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_331 = 331 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_332 = 332 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_333 = 333 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_334 = 334 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_335 = 335 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_336 = 336 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_337 = 337 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_338 = 338 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_339 = 339 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_340 = 340 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_341 = 341 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_342 = 342 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_343 = 343 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_344 = 344 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_345 = 345 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_346 = 346 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_347 = 347 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_348 = 348 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_349 = 349 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_350 = 350 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_351 = 351 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_352 = 352 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_353 = 353 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_354 = 354 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_355 = 355 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_356 = 356 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_357 = 357 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_358 = 358 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_359 = 359 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_360 = 360 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_361 = 361 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_362 = 362 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_363 = 363 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_364 = 364 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_365 = 365 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_366 = 366 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_367 = 367 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_368 = 368 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_369 = 369 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_370 = 370 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_371 = 371 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_372 = 372 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_373 = 373 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_374 = 374 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_375 = 375 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_376 = 376 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_377 = 377 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_378 = 378 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_379 = 379 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_380 = 380 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_381 = 381 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_382 = 382 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_383 = 383 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_384 = 384 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_385 = 385 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_386 = 386 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_387 = 387 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_388 = 388 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_389 = 389 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_390 = 390 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_391 = 391 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_392 = 392 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_393 = 393 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_394 = 394 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_395 = 395 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_396 = 396 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_397 = 397 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_398 = 398 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_399 = 399 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_400 = 400 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_401 = 401 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_402 = 402 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_403 = 403 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_404 = 404 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_405 = 405 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_406 = 406 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_407 = 407 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_408 = 408 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_409 = 409 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_410 = 410 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_411 = 411 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_412 = 412 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_413 = 413 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_414 = 414 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_415 = 415 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_416 = 416 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_417 = 417 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_418 = 418 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_419 = 419 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_420 = 420 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_421 = 421 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_422 = 422 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_423 = 423 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_424 = 424 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_425 = 425 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_426 = 426 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_427 = 427 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_428 = 428 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_429 = 429 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_430 = 430 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_431 = 431 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_432 = 432 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_433 = 433 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_434 = 434 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_435 = 435 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_436 = 436 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_437 = 437 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_438 = 438 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_439 = 439 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_440 = 440 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_441 = 441 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_442 = 442 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_443 = 443 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_444 = 444 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_445 = 445 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_446 = 446 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_447 = 447 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_448 = 448 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_449 = 449 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_450 = 450 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_451 = 451 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_452 = 452 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_453 = 453 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_454 = 454 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_455 = 455 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_456 = 456 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_457 = 457 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_458 = 458 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_459 = 459 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_460 = 460 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_461 = 461 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_462 = 462 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_463 = 463 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_464 = 464 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_465 = 465 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_466 = 466 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_467 = 467 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_468 = 468 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_469 = 469 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_470 = 470 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_471 = 471 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_472 = 472 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_473 = 473 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_474 = 474 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_475 = 475 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_476 = 476 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_477 = 477 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_478 = 478 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_479 = 479 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_480 = 480 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_481 = 481 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_482 = 482 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_483 = 483 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_484 = 484 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_485 = 485 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_486 = 486 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_487 = 487 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_488 = 488 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_489 = 489 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_490 = 490 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_491 = 491 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_492 = 492 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_493 = 493 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_494 = 494 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_495 = 495 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_496 = 496 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_497 = 497 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_498 = 498 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_499 = 499 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_500 = 500 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_501 = 501 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_502 = 502 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_503 = 503 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_504 = 504 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_505 = 505 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_506 = 506 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_507 = 507 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_508 = 508 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_509 = 509 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_510 = 510 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_511 = 511 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_512 = 512 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_513 = 513 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_514 = 514 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_515 = 515 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_516 = 516 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_517 = 517 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_518 = 518 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_519 = 519 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_520 = 520 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_521 = 521 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_522 = 522 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_523 = 523 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_524 = 524 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_525 = 525 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_526 = 526 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_527 = 527 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_528 = 528 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_529 = 529 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_530 = 530 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_531 = 531 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_532 = 532 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_533 = 533 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_534 = 534 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_535 = 535 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_536 = 536 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_537 = 537 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_538 = 538 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_539 = 539 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_540 = 540 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_541 = 541 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_542 = 542 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_543 = 543 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_544 = 544 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_545 = 545 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_546 = 546 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_547 = 547 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_548 = 548 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_549 = 549 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_550 = 550 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_551 = 551 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_552 = 552 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_553 = 553 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_554 = 554 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_555 = 555 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_556 = 556 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_557 = 557 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_558 = 558 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_559 = 559 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_560 = 560 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_561 = 561 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_562 = 562 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_563 = 563 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_564 = 564 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_565 = 565 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_566 = 566 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_567 = 567 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_568 = 568 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_569 = 569 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_570 = 570 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_571 = 571 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_572 = 572 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_573 = 573 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_574 = 574 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_575 = 575 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_576 = 576 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_577 = 577 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_578 = 578 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_579 = 579 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_580 = 580 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_581 = 581 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_582 = 582 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_583 = 583 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_584 = 584 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_585 = 585 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_586 = 586 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_587 = 587 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_588 = 588 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_589 = 589 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_590 = 590 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_591 = 591 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_592 = 592 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_593 = 593 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_594 = 594 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_595 = 595 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_596 = 596 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_597 = 597 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_598 = 598 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_599 = 599 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_600 = 600 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_601 = 601 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_602 = 602 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_603 = 603 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_604 = 604 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_605 = 605 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_606 = 606 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_607 = 607 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_608 = 608 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_609 = 609 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_610 = 610 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_611 = 611 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_612 = 612 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_613 = 613 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_614 = 614 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_615 = 615 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_616 = 616 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_617 = 617 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_618 = 618 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_619 = 619 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_620 = 620 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_621 = 621 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_622 = 622 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_623 = 623 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_624 = 624 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_625 = 625 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_626 = 626 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_627 = 627 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_628 = 628 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_629 = 629 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_630 = 630 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_631 = 631 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_632 = 632 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_633 = 633 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_634 = 634 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_635 = 635 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_636 = 636 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_637 = 637 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_638 = 638 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_639 = 639 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_640 = 640 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_641 = 641 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_642 = 642 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_643 = 643 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_644 = 644 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_645 = 645 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_646 = 646 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_647 = 647 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_648 = 648 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_649 = 649 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_650 = 650 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_651 = 651 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_652 = 652 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_653 = 653 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_654 = 654 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_655 = 655 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_656 = 656 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_657 = 657 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_658 = 658 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_659 = 659 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_660 = 660 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_661 = 661 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_662 = 662 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_663 = 663 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_664 = 664 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_665 = 665 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_666 = 666 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_667 = 667 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_668 = 668 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_669 = 669 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_670 = 670 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_671 = 671 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_672 = 672 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_673 = 673 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_674 = 674 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_675 = 675 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_676 = 676 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_677 = 677 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_678 = 678 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_679 = 679 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_680 = 680 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_681 = 681 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_682 = 682 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_683 = 683 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_684 = 684 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_685 = 685 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_686 = 686 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_687 = 687 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_688 = 688 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_689 = 689 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_690 = 690 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_691 = 691 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_692 = 692 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_693 = 693 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_694 = 694 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_695 = 695 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_696 = 696 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_697 = 697 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_698 = 698 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_699 = 699 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_700 = 700 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_701 = 701 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_702 = 702 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_703 = 703 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_704 = 704 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_705 = 705 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_706 = 706 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_707 = 707 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_708 = 708 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_709 = 709 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_710 = 710 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_711 = 711 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_712 = 712 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_713 = 713 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_714 = 714 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_715 = 715 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_716 = 716 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_717 = 717 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_718 = 718 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_719 = 719 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_720 = 720 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_721 = 721 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_722 = 722 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_723 = 723 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_724 = 724 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_725 = 725 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_726 = 726 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_727 = 727 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_728 = 728 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_729 = 729 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_730 = 730 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_731 = 731 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_732 = 732 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_733 = 733 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_734 = 734 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_735 = 735 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_736 = 736 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_737 = 737 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_738 = 738 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_739 = 739 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_740 = 740 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_741 = 741 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_742 = 742 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_743 = 743 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_744 = 744 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_745 = 745 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_746 = 746 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_747 = 747 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_748 = 748 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_749 = 749 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_750 = 750 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_751 = 751 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_752 = 752 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_753 = 753 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_754 = 754 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_755 = 755 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_756 = 756 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_757 = 757 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_758 = 758 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_759 = 759 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_760 = 760 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_761 = 761 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_762 = 762 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_763 = 763 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_764 = 764 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_765 = 765 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_766 = 766 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_767 = 767 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_768 = 768 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_769 = 769 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_770 = 770 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_771 = 771 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_772 = 772 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_773 = 773 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_774 = 774 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_775 = 775 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_776 = 776 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_777 = 777 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_778 = 778 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_779 = 779 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_780 = 780 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_781 = 781 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_782 = 782 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_783 = 783 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_784 = 784 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_785 = 785 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_786 = 786 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_787 = 787 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_788 = 788 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_789 = 789 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_790 = 790 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_791 = 791 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_792 = 792 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_793 = 793 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_794 = 794 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_795 = 795 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_796 = 796 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_797 = 797 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_798 = 798 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_799 = 799 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_800 = 800 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_801 = 801 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_802 = 802 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_803 = 803 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_804 = 804 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_805 = 805 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_806 = 806 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_807 = 807 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_808 = 808 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_809 = 809 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_810 = 810 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_811 = 811 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_812 = 812 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_813 = 813 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_814 = 814 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_815 = 815 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_816 = 816 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_817 = 817 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_818 = 818 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_819 = 819 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_820 = 820 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_821 = 821 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_822 = 822 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_823 = 823 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_824 = 824 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_825 = 825 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_826 = 826 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_827 = 827 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_828 = 828 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_829 = 829 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_830 = 830 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_831 = 831 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_832 = 832 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_833 = 833 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_834 = 834 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_835 = 835 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_836 = 836 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_837 = 837 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_838 = 838 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_839 = 839 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_840 = 840 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_841 = 841 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_842 = 842 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_843 = 843 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_844 = 844 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_845 = 845 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_846 = 846 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_847 = 847 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_848 = 848 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_849 = 849 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_850 = 850 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_851 = 851 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_852 = 852 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_853 = 853 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_854 = 854 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_855 = 855 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_856 = 856 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_857 = 857 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_858 = 858 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_859 = 859 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_860 = 860 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_861 = 861 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_862 = 862 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_863 = 863 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_864 = 864 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_865 = 865 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_866 = 866 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_867 = 867 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_868 = 868 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_869 = 869 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_870 = 870 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_871 = 871 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_872 = 872 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_873 = 873 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_874 = 874 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_875 = 875 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_876 = 876 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_877 = 877 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_878 = 878 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_879 = 879 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_880 = 880 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_881 = 881 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_882 = 882 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_883 = 883 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_884 = 884 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_885 = 885 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_886 = 886 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_887 = 887 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_888 = 888 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_889 = 889 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_890 = 890 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_891 = 891 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_892 = 892 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_893 = 893 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_894 = 894 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_895 = 895 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_896 = 896 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_897 = 897 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_898 = 898 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_899 = 899 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_900 = 900 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_901 = 901 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_902 = 902 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_903 = 903 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_904 = 904 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_905 = 905 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_906 = 906 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_907 = 907 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_908 = 908 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_909 = 909 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_910 = 910 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_911 = 911 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_912 = 912 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_913 = 913 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_914 = 914 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_915 = 915 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_916 = 916 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_917 = 917 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_918 = 918 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_919 = 919 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_920 = 920 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_921 = 921 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_922 = 922 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_923 = 923 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_924 = 924 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_925 = 925 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_926 = 926 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_927 = 927 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_928 = 928 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_929 = 929 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_930 = 930 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_931 = 931 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_932 = 932 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_933 = 933 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_934 = 934 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_935 = 935 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_936 = 936 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_937 = 937 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_938 = 938 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_939 = 939 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_940 = 940 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_941 = 941 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_942 = 942 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_943 = 943 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_944 = 944 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_945 = 945 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_946 = 946 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_947 = 947 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_948 = 948 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_949 = 949 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_950 = 950 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_951 = 951 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_952 = 952 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_953 = 953 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_954 = 954 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_955 = 955 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_956 = 956 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_957 = 957 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_958 = 958 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_959 = 959 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_960 = 960 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_961 = 961 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_962 = 962 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_963 = 963 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_964 = 964 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_965 = 965 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_966 = 966 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_967 = 967 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_968 = 968 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_969 = 969 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_970 = 970 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_971 = 971 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_972 = 972 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_973 = 973 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_974 = 974 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_975 = 975 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_976 = 976 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_977 = 977 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_978 = 978 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_979 = 979 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_980 = 980 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_981 = 981 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_982 = 982 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_983 = 983 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_984 = 984 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_985 = 985 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_986 = 986 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_987 = 987 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_988 = 988 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_989 = 989 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_990 = 990 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_991 = 991 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_992 = 992 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_993 = 993 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_994 = 994 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_995 = 995 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_996 = 996 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_997 = 997 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_998 = 998 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_999 = 999 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n  optional string long_field_name_is_looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong_1000 = 1000 [default=\"long default value is also loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong\"];\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_import.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// A proto file which is imported by unittest.proto to test importing.\n\nsyntax = \"proto2\";\n\n// We don't put this in a package within proto2 because we need to make sure\n// that the generated code doesn't depend on being in the proto2 namespace.\n// In test_util.h we do\n// \"using namespace unittest_import = protobuf_unittest_import\".\npackage protobuf_unittest_import;\n\noption optimize_for = SPEED;\noption cc_enable_arenas = true;\n\n// Exercise the java_package option.\noption java_package = \"com.google.protobuf.test\";\n\n// Do not set a java_outer_classname here to verify that Proto2 works without\n// one.\n\n// Test public import\nimport public \"google/protobuf/unittest_import_public.proto\";\n\nmessage ImportMessage {\n  optional int32 d = 1;\n}\n\nenum ImportEnum {\n  IMPORT_FOO = 7;\n  IMPORT_BAR = 8;\n  IMPORT_BAZ = 9;\n}\n\n\n// To use an enum in a map, it must has the first value as 0.\nenum ImportEnumForMap {\n  UNKNOWN = 0;\n  FOO = 1;\n  BAR = 2;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_import_lite.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//\n// This is like unittest_import.proto but with optimize_for = LITE_RUNTIME.\n\nsyntax = \"proto2\";\npackage protobuf_unittest_import;\n\noption optimize_for = LITE_RUNTIME;\n\noption java_package = \"com.google.protobuf\";\n\nimport public \"google/protobuf/unittest_import_public_lite.proto\";\n\nmessage ImportMessageLite {\n  optional int32 d = 1;\n}\n\nenum ImportEnumLite {\n  IMPORT_LITE_FOO = 7;\n  IMPORT_LITE_BAR = 8;\n  IMPORT_LITE_BAZ = 9;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_import_public.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: liujisi@google.com (Pherl Liu)\n\nsyntax = \"proto2\";\n\npackage protobuf_unittest_import;\n\noption java_package = \"com.google.protobuf.test\";\n\nmessage PublicImportMessage {\n  optional int32 e = 1;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_import_public_lite.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: liujisi@google.com (Pherl Liu)\n\nsyntax = \"proto2\";\n\npackage protobuf_unittest_import;\n\noption optimize_for = LITE_RUNTIME;\n\noption java_package = \"com.google.protobuf\";\n\nmessage PublicImportMessageLite {\n  optional int32 e = 1;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_lite.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//\n// This is like unittest.proto but with optimize_for = LITE_RUNTIME.\n\nsyntax = \"proto2\";\npackage protobuf_unittest;\n\nimport \"google/protobuf/unittest_import_lite.proto\";\n\noption optimize_for = LITE_RUNTIME;\n\noption java_package = \"com.google.protobuf\";\n\n// Same as TestAllTypes but with the lite runtime.\nmessage TestAllTypesLite {\n\n  message NestedMessage {\n    optional int32 bb = 1;\n    optional int64 cc = 2;\n  }\n\n  enum NestedEnum {\n    FOO = 1;\n    BAR = 2;\n    BAZ = 3;\n  }\n\n  // Singular\n  optional    int32 optional_int32    =  1;\n  optional    int64 optional_int64    =  2;\n  optional   uint32 optional_uint32   =  3;\n  optional   uint64 optional_uint64   =  4;\n  optional   sint32 optional_sint32   =  5;\n  optional   sint64 optional_sint64   =  6;\n  optional  fixed32 optional_fixed32  =  7;\n  optional  fixed64 optional_fixed64  =  8;\n  optional sfixed32 optional_sfixed32 =  9;\n  optional sfixed64 optional_sfixed64 = 10;\n  optional    float optional_float    = 11;\n  optional   double optional_double   = 12;\n  optional     bool optional_bool     = 13;\n  optional   string optional_string   = 14;\n  optional    bytes optional_bytes    = 15;\n\n  optional group OptionalGroup = 16 {\n    optional int32 a = 17;\n  }\n\n  optional NestedMessage      optional_nested_message  = 18;\n  optional ForeignMessageLite optional_foreign_message = 19;\n  optional protobuf_unittest_import.ImportMessageLite\n    optional_import_message = 20;\n\n  optional NestedEnum      optional_nested_enum     = 21;\n  optional ForeignEnumLite optional_foreign_enum    = 22;\n  optional protobuf_unittest_import.ImportEnumLite optional_import_enum = 23;\n\n  optional string optional_string_piece = 24 [ctype=STRING_PIECE];\n  optional string optional_cord = 25 [ctype=CORD];\n\n  // Defined in unittest_import_public.proto\n  optional protobuf_unittest_import.PublicImportMessageLite\n      optional_public_import_message = 26;\n\n  optional NestedMessage optional_lazy_message = 27 [lazy=true];\n\n  // Repeated\n  repeated    int32 repeated_int32    = 31;\n  repeated    int64 repeated_int64    = 32;\n  repeated   uint32 repeated_uint32   = 33;\n  repeated   uint64 repeated_uint64   = 34;\n  repeated   sint32 repeated_sint32   = 35;\n  repeated   sint64 repeated_sint64   = 36;\n  repeated  fixed32 repeated_fixed32  = 37;\n  repeated  fixed64 repeated_fixed64  = 38;\n  repeated sfixed32 repeated_sfixed32 = 39;\n  repeated sfixed64 repeated_sfixed64 = 40;\n  repeated    float repeated_float    = 41;\n  repeated   double repeated_double   = 42;\n  repeated     bool repeated_bool     = 43;\n  repeated   string repeated_string   = 44;\n  repeated    bytes repeated_bytes    = 45;\n\n  repeated group RepeatedGroup = 46 {\n    optional int32 a = 47;\n  }\n\n  repeated NestedMessage      repeated_nested_message  = 48;\n  repeated ForeignMessageLite repeated_foreign_message = 49;\n  repeated protobuf_unittest_import.ImportMessageLite\n    repeated_import_message = 50;\n\n  repeated NestedEnum      repeated_nested_enum  = 51;\n  repeated ForeignEnumLite repeated_foreign_enum = 52;\n  repeated protobuf_unittest_import.ImportEnumLite repeated_import_enum = 53;\n\n  repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];\n  repeated string repeated_cord = 55 [ctype=CORD];\n\n  repeated NestedMessage repeated_lazy_message = 57 [lazy=true];\n\n  // Singular with defaults\n  optional    int32 default_int32    = 61 [default =  41    ];\n  optional    int64 default_int64    = 62 [default =  42    ];\n  optional   uint32 default_uint32   = 63 [default =  43    ];\n  optional   uint64 default_uint64   = 64 [default =  44    ];\n  optional   sint32 default_sint32   = 65 [default = -45    ];\n  optional   sint64 default_sint64   = 66 [default =  46    ];\n  optional  fixed32 default_fixed32  = 67 [default =  47    ];\n  optional  fixed64 default_fixed64  = 68 [default =  48    ];\n  optional sfixed32 default_sfixed32 = 69 [default =  49    ];\n  optional sfixed64 default_sfixed64 = 70 [default = -50    ];\n  optional    float default_float    = 71 [default =  51.5  ];\n  optional   double default_double   = 72 [default =  52e3  ];\n  optional     bool default_bool     = 73 [default = true   ];\n  optional   string default_string   = 74 [default = \"hello\"];\n  optional    bytes default_bytes    = 75 [default = \"world\"];\n\n  optional NestedEnum default_nested_enum = 81 [default = BAR];\n  optional ForeignEnumLite default_foreign_enum = 82\n      [default = FOREIGN_LITE_BAR];\n  optional protobuf_unittest_import.ImportEnumLite\n      default_import_enum = 83 [default = IMPORT_LITE_BAR];\n\n  optional string default_string_piece = 84 [ctype=STRING_PIECE,default=\"abc\"];\n  optional string default_cord = 85 [ctype=CORD,default=\"123\"];\n\n  // For oneof test\n  oneof oneof_field {\n    uint32 oneof_uint32 = 111;\n    NestedMessage oneof_nested_message = 112;\n    string oneof_string = 113;\n    bytes oneof_bytes = 114;\n    NestedMessage oneof_lazy_nested_message = 115 [lazy = true];\n  }\n}\n\nmessage ForeignMessageLite {\n  optional int32 c = 1;\n}\n\nenum ForeignEnumLite {\n  FOREIGN_LITE_FOO = 4;\n  FOREIGN_LITE_BAR = 5;\n  FOREIGN_LITE_BAZ = 6;\n}\n\nmessage TestPackedTypesLite {\n  repeated    int32 packed_int32    =  90 [packed = true];\n  repeated    int64 packed_int64    =  91 [packed = true];\n  repeated   uint32 packed_uint32   =  92 [packed = true];\n  repeated   uint64 packed_uint64   =  93 [packed = true];\n  repeated   sint32 packed_sint32   =  94 [packed = true];\n  repeated   sint64 packed_sint64   =  95 [packed = true];\n  repeated  fixed32 packed_fixed32  =  96 [packed = true];\n  repeated  fixed64 packed_fixed64  =  97 [packed = true];\n  repeated sfixed32 packed_sfixed32 =  98 [packed = true];\n  repeated sfixed64 packed_sfixed64 =  99 [packed = true];\n  repeated    float packed_float    = 100 [packed = true];\n  repeated   double packed_double   = 101 [packed = true];\n  repeated     bool packed_bool     = 102 [packed = true];\n  repeated ForeignEnumLite packed_enum  = 103 [packed = true];\n}\n\nmessage TestAllExtensionsLite {\n  extensions 1 to max;\n}\n\nextend TestAllExtensionsLite {\n  // Singular\n  optional    int32 optional_int32_extension_lite    =  1;\n  optional    int64 optional_int64_extension_lite    =  2;\n  optional   uint32 optional_uint32_extension_lite   =  3;\n  optional   uint64 optional_uint64_extension_lite   =  4;\n  optional   sint32 optional_sint32_extension_lite   =  5;\n  optional   sint64 optional_sint64_extension_lite   =  6;\n  optional  fixed32 optional_fixed32_extension_lite  =  7;\n  optional  fixed64 optional_fixed64_extension_lite  =  8;\n  optional sfixed32 optional_sfixed32_extension_lite =  9;\n  optional sfixed64 optional_sfixed64_extension_lite = 10;\n  optional    float optional_float_extension_lite    = 11;\n  optional   double optional_double_extension_lite   = 12;\n  optional     bool optional_bool_extension_lite     = 13;\n  optional   string optional_string_extension_lite   = 14;\n  optional    bytes optional_bytes_extension_lite    = 15;\n\n  optional group OptionalGroup_extension_lite = 16 {\n    optional int32 a = 17;\n  }\n\n  optional TestAllTypesLite.NestedMessage optional_nested_message_extension_lite\n      = 18;\n  optional ForeignMessageLite optional_foreign_message_extension_lite = 19;\n  optional protobuf_unittest_import.ImportMessageLite\n    optional_import_message_extension_lite = 20;\n\n  optional TestAllTypesLite.NestedEnum optional_nested_enum_extension_lite = 21;\n  optional ForeignEnumLite optional_foreign_enum_extension_lite = 22;\n  optional protobuf_unittest_import.ImportEnumLite\n    optional_import_enum_extension_lite = 23;\n\n  optional string optional_string_piece_extension_lite = 24\n      [ctype=STRING_PIECE];\n  optional string optional_cord_extension_lite = 25 [ctype=CORD];\n\n  optional protobuf_unittest_import.PublicImportMessageLite\n    optional_public_import_message_extension_lite = 26;\n\n  optional TestAllTypesLite.NestedMessage\n    optional_lazy_message_extension_lite = 27 [lazy=true];\n\n  // Repeated\n  repeated    int32 repeated_int32_extension_lite    = 31;\n  repeated    int64 repeated_int64_extension_lite    = 32;\n  repeated   uint32 repeated_uint32_extension_lite   = 33;\n  repeated   uint64 repeated_uint64_extension_lite   = 34;\n  repeated   sint32 repeated_sint32_extension_lite   = 35;\n  repeated   sint64 repeated_sint64_extension_lite   = 36;\n  repeated  fixed32 repeated_fixed32_extension_lite  = 37;\n  repeated  fixed64 repeated_fixed64_extension_lite  = 38;\n  repeated sfixed32 repeated_sfixed32_extension_lite = 39;\n  repeated sfixed64 repeated_sfixed64_extension_lite = 40;\n  repeated    float repeated_float_extension_lite    = 41;\n  repeated   double repeated_double_extension_lite   = 42;\n  repeated     bool repeated_bool_extension_lite     = 43;\n  repeated   string repeated_string_extension_lite   = 44;\n  repeated    bytes repeated_bytes_extension_lite    = 45;\n\n  repeated group RepeatedGroup_extension_lite = 46 {\n    optional int32 a = 47;\n  }\n\n  repeated TestAllTypesLite.NestedMessage repeated_nested_message_extension_lite\n      = 48;\n  repeated ForeignMessageLite repeated_foreign_message_extension_lite = 49;\n  repeated protobuf_unittest_import.ImportMessageLite\n    repeated_import_message_extension_lite = 50;\n\n  repeated TestAllTypesLite.NestedEnum repeated_nested_enum_extension_lite = 51;\n  repeated ForeignEnumLite repeated_foreign_enum_extension_lite = 52;\n  repeated protobuf_unittest_import.ImportEnumLite\n    repeated_import_enum_extension_lite = 53;\n\n  repeated string repeated_string_piece_extension_lite = 54\n      [ctype=STRING_PIECE];\n  repeated string repeated_cord_extension_lite = 55 [ctype=CORD];\n\n  repeated TestAllTypesLite.NestedMessage\n    repeated_lazy_message_extension_lite = 57 [lazy=true];\n\n  // Singular with defaults\n  optional    int32 default_int32_extension_lite    = 61 [default =  41    ];\n  optional    int64 default_int64_extension_lite    = 62 [default =  42    ];\n  optional   uint32 default_uint32_extension_lite   = 63 [default =  43    ];\n  optional   uint64 default_uint64_extension_lite   = 64 [default =  44    ];\n  optional   sint32 default_sint32_extension_lite   = 65 [default = -45    ];\n  optional   sint64 default_sint64_extension_lite   = 66 [default =  46    ];\n  optional  fixed32 default_fixed32_extension_lite  = 67 [default =  47    ];\n  optional  fixed64 default_fixed64_extension_lite  = 68 [default =  48    ];\n  optional sfixed32 default_sfixed32_extension_lite = 69 [default =  49    ];\n  optional sfixed64 default_sfixed64_extension_lite = 70 [default = -50    ];\n  optional    float default_float_extension_lite    = 71 [default =  51.5  ];\n  optional   double default_double_extension_lite   = 72 [default =  52e3  ];\n  optional     bool default_bool_extension_lite     = 73 [default = true   ];\n  optional   string default_string_extension_lite   = 74 [default = \"hello\"];\n  optional    bytes default_bytes_extension_lite    = 75 [default = \"world\"];\n\n  optional TestAllTypesLite.NestedEnum\n    default_nested_enum_extension_lite = 81 [default = BAR];\n  optional ForeignEnumLite\n    default_foreign_enum_extension_lite = 82 [default = FOREIGN_LITE_BAR];\n  optional protobuf_unittest_import.ImportEnumLite\n    default_import_enum_extension_lite = 83 [default = IMPORT_LITE_BAR];\n\n  optional string default_string_piece_extension_lite = 84 [ctype=STRING_PIECE,\n                                                            default=\"abc\"];\n  optional string default_cord_extension_lite = 85 [ctype=CORD, default=\"123\"];\n\n  // For oneof test\n  optional uint32 oneof_uint32_extension_lite = 111;\n  optional TestAllTypesLite.NestedMessage oneof_nested_message_extension_lite = 112;\n  optional string oneof_string_extension_lite = 113;\n  optional bytes oneof_bytes_extension_lite = 114;\n}\n\nmessage TestPackedExtensionsLite {\n  extensions 1 to max;\n}\n\nextend TestPackedExtensionsLite {\n  repeated    int32 packed_int32_extension_lite    =  90 [packed = true];\n  repeated    int64 packed_int64_extension_lite    =  91 [packed = true];\n  repeated   uint32 packed_uint32_extension_lite   =  92 [packed = true];\n  repeated   uint64 packed_uint64_extension_lite   =  93 [packed = true];\n  repeated   sint32 packed_sint32_extension_lite   =  94 [packed = true];\n  repeated   sint64 packed_sint64_extension_lite   =  95 [packed = true];\n  repeated  fixed32 packed_fixed32_extension_lite  =  96 [packed = true];\n  repeated  fixed64 packed_fixed64_extension_lite  =  97 [packed = true];\n  repeated sfixed32 packed_sfixed32_extension_lite =  98 [packed = true];\n  repeated sfixed64 packed_sfixed64_extension_lite =  99 [packed = true];\n  repeated    float packed_float_extension_lite    = 100 [packed = true];\n  repeated   double packed_double_extension_lite   = 101 [packed = true];\n  repeated     bool packed_bool_extension_lite     = 102 [packed = true];\n  repeated ForeignEnumLite packed_enum_extension_lite = 103 [packed = true];\n}\n\nmessage TestNestedExtensionLite {\n  extend TestAllExtensionsLite {\n    optional int32 nested_extension = 12345;\n  }\n}\n\n// Test that deprecated fields work.  We only verify that they compile (at one\n// point this failed).\nmessage TestDeprecatedLite {\n  optional int32 deprecated_field = 1 [deprecated = true];\n}\n\n// See the comments of the same type in unittest.proto.\nmessage TestParsingMergeLite {\n  message RepeatedFieldsGenerator {\n    repeated TestAllTypesLite field1 = 1;\n    repeated TestAllTypesLite field2 = 2;\n    repeated TestAllTypesLite field3 = 3;\n    repeated group Group1 = 10 {\n      optional TestAllTypesLite field1 = 11;\n    }\n    repeated group Group2 = 20 {\n      optional TestAllTypesLite field1 = 21;\n    }\n    repeated TestAllTypesLite ext1 = 1000;\n    repeated TestAllTypesLite ext2 = 1001;\n  }\n  required TestAllTypesLite required_all_types = 1;\n  optional TestAllTypesLite optional_all_types = 2;\n  repeated TestAllTypesLite repeated_all_types = 3;\n  optional group OptionalGroup = 10 {\n    optional TestAllTypesLite optional_group_all_types = 11;\n  }\n  repeated group RepeatedGroup = 20 {\n    optional TestAllTypesLite repeated_group_all_types = 21;\n  }\n  extensions 1000 to max;\n  extend TestParsingMergeLite {\n    optional TestAllTypesLite optional_ext = 1000;\n    repeated TestAllTypesLite repeated_ext = 1001;\n  }\n}\n\n// TestEmptyMessageLite is used to test unknown fields support in lite mode.\nmessage TestEmptyMessageLite{\n}\n\n// Like above, but declare all field numbers as potential extensions.  No\n// actual extensions should ever be defined for this type.\nmessage TestEmptyMessageWithExtensionsLite {\n  extensions 1 to max;\n}\n\nenum V1EnumLite {\n    V1_FIRST = 1;\n}\n\nenum V2EnumLite {\n    V2_FIRST = 1;\n    V2_SECOND = 2;\n}\n\nmessage V1MessageLite {\n    required int32 int_field = 1;\n    optional V1EnumLite enum_field = 2 [ default = V1_FIRST ];\n}\n\nmessage V2MessageLite {\n    required int32 int_field = 1;\n    optional V2EnumLite enum_field = 2 [ default = V2_FIRST ];\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_lite_imports_nonlite.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//\n// Tests that a \"lite\" message can import a regular message.\n\nsyntax = \"proto2\";\npackage protobuf_unittest;\n\nimport \"google/protobuf/unittest.proto\";\n\noption optimize_for = LITE_RUNTIME;\n\nmessage TestLiteImportsNonlite {\n  optional TestAllTypes message = 1;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_mset.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This file is similar to unittest_mset_wire_format.proto, but does not\n// have a TestMessageSet, so it can be downgraded to proto1.\n\nsyntax = \"proto2\";\n\nimport \"google/protobuf/unittest_mset_wire_format.proto\";\n\npackage protobuf_unittest;\n\noption cc_enable_arenas = true;\noption optimize_for = SPEED;\n\nmessage TestMessageSetContainer {\n  optional proto2_wireformat_unittest.TestMessageSet message_set = 1;\n}\n\nmessage TestMessageSetExtension1 {\n  extend proto2_wireformat_unittest.TestMessageSet {\n    optional TestMessageSetExtension1 message_set_extension = 1545008;\n  }\n  optional int32 i = 15;\n}\n\nmessage TestMessageSetExtension2 {\n  extend proto2_wireformat_unittest.TestMessageSet {\n    optional TestMessageSetExtension2 message_set_extension = 1547769;\n  }\n  optional string str = 25;\n}\n\n// This message was used to generate\n// //net/proto2/python/internal/testdata/message_set_message, but is commented\n// out since it must not actually exist in code, to simulate an \"unknown\"\n// extension.\n// message TestMessageSetUnknownExtension {\n//   extend TestMessageSet {\n//     optional TestMessageSetUnknownExtension message_set_extension = 56141421;\n//   }\n//   optional int64 a = 1;\n// }\n\n// MessageSet wire format is equivalent to this.\nmessage RawMessageSet {\n  repeated group Item = 1 {\n    required int32 type_id = 2;\n    required bytes message = 3;\n  }\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_mset_wire_format.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This file contains messages for testing message_set_wire_format.\n\nsyntax = \"proto2\";\npackage proto2_wireformat_unittest;\n\noption cc_enable_arenas = true;\noption optimize_for = SPEED;\noption csharp_namespace = \"Google.ProtocolBuffers.TestProtos\";\n\n// A message with message_set_wire_format.\nmessage TestMessageSet {\n  option message_set_wire_format = true;\n  extensions 4 to max;\n}\n\nmessage TestMessageSetWireFormatContainer {\n  optional TestMessageSet message_set = 1;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_no_arena.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This proto file contains copies of TestAllTypes and friends, but with arena\n// support disabled in code generation. It allows us to test the performance\n// impact against baseline (non-arena) google.protobuf.\n\nsyntax = \"proto2\";\n\n// Some generic_services option(s) added automatically.\n// See:  http://go/proto2-generic-services-default\noption cc_generic_services = true;     // auto-added\noption java_generic_services = true;   // auto-added\noption py_generic_services = true;     // auto-added\noption cc_enable_arenas = false;\noption objc_class_prefix = \"NOARN\";\n\nimport \"google/protobuf/unittest_import.proto\";\nimport \"google/protobuf/unittest_arena.proto\";\n\n// We don't put this in a package within proto2 because we need to make sure\n// that the generated code doesn't depend on being in the proto2 namespace.\n// In test_util.h we do \"using namespace unittest = protobuf_unittest\".\npackage protobuf_unittest_no_arena;\n\n// Protos optimized for SPEED use a strict superset of the generated code\n// of equivalent ones optimized for CODE_SIZE, so we should optimize all our\n// tests for speed unless explicitly testing code size optimization.\noption optimize_for = SPEED;\n\noption java_outer_classname = \"UnittestProto\";\n\n// This proto includes every type of field in both singular and repeated\n// forms.\nmessage TestAllTypes {\n  message NestedMessage {\n    // The field name \"b\" fails to compile in proto1 because it conflicts with\n    // a local variable named \"b\" in one of the generated methods.  Doh.\n    // This file needs to compile in proto1 to test backwards-compatibility.\n    optional int32 bb = 1;\n  }\n\n  enum NestedEnum {\n    FOO = 1;\n    BAR = 2;\n    BAZ = 3;\n    NEG = -1;  // Intentionally negative.\n  }\n\n  // Singular\n  optional    int32 optional_int32    =  1;\n  optional    int64 optional_int64    =  2;\n  optional   uint32 optional_uint32   =  3;\n  optional   uint64 optional_uint64   =  4;\n  optional   sint32 optional_sint32   =  5;\n  optional   sint64 optional_sint64   =  6;\n  optional  fixed32 optional_fixed32  =  7;\n  optional  fixed64 optional_fixed64  =  8;\n  optional sfixed32 optional_sfixed32 =  9;\n  optional sfixed64 optional_sfixed64 = 10;\n  optional    float optional_float    = 11;\n  optional   double optional_double   = 12;\n  optional     bool optional_bool     = 13;\n  optional   string optional_string   = 14;\n  optional    bytes optional_bytes    = 15;\n\n  optional group OptionalGroup = 16 {\n    optional int32 a = 17;\n  }\n\n  optional NestedMessage                        optional_nested_message  = 18;\n  optional ForeignMessage                       optional_foreign_message = 19;\n  optional protobuf_unittest_import.ImportMessage optional_import_message  = 20;\n\n  optional NestedEnum                           optional_nested_enum     = 21;\n  optional ForeignEnum                          optional_foreign_enum    = 22;\n  optional protobuf_unittest_import.ImportEnum    optional_import_enum     = 23;\n\n  optional string optional_string_piece = 24 [ctype=STRING_PIECE];\n  optional string optional_cord = 25 [ctype=CORD];\n\n  // Defined in unittest_import_public.proto\n  optional protobuf_unittest_import.PublicImportMessage\n      optional_public_import_message = 26;\n\n  optional NestedMessage optional_message = 27 [lazy=true];\n\n  // Repeated\n  repeated    int32 repeated_int32    = 31;\n  repeated    int64 repeated_int64    = 32;\n  repeated   uint32 repeated_uint32   = 33;\n  repeated   uint64 repeated_uint64   = 34;\n  repeated   sint32 repeated_sint32   = 35;\n  repeated   sint64 repeated_sint64   = 36;\n  repeated  fixed32 repeated_fixed32  = 37;\n  repeated  fixed64 repeated_fixed64  = 38;\n  repeated sfixed32 repeated_sfixed32 = 39;\n  repeated sfixed64 repeated_sfixed64 = 40;\n  repeated    float repeated_float    = 41;\n  repeated   double repeated_double   = 42;\n  repeated     bool repeated_bool     = 43;\n  repeated   string repeated_string   = 44;\n  repeated    bytes repeated_bytes    = 45;\n\n  repeated group RepeatedGroup = 46 {\n    optional int32 a = 47;\n  }\n\n  repeated NestedMessage                        repeated_nested_message  = 48;\n  repeated ForeignMessage                       repeated_foreign_message = 49;\n  repeated protobuf_unittest_import.ImportMessage repeated_import_message  = 50;\n\n  repeated NestedEnum                           repeated_nested_enum     = 51;\n  repeated ForeignEnum                          repeated_foreign_enum    = 52;\n  repeated protobuf_unittest_import.ImportEnum    repeated_import_enum     = 53;\n\n  repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];\n  repeated string repeated_cord = 55 [ctype=CORD];\n\n  repeated NestedMessage repeated_lazy_message = 57 [lazy=true];\n\n  // Singular with defaults\n  optional    int32 default_int32    = 61 [default =  41    ];\n  optional    int64 default_int64    = 62 [default =  42    ];\n  optional   uint32 default_uint32   = 63 [default =  43    ];\n  optional   uint64 default_uint64   = 64 [default =  44    ];\n  optional   sint32 default_sint32   = 65 [default = -45    ];\n  optional   sint64 default_sint64   = 66 [default =  46    ];\n  optional  fixed32 default_fixed32  = 67 [default =  47    ];\n  optional  fixed64 default_fixed64  = 68 [default =  48    ];\n  optional sfixed32 default_sfixed32 = 69 [default =  49    ];\n  optional sfixed64 default_sfixed64 = 70 [default = -50    ];\n  optional    float default_float    = 71 [default =  51.5  ];\n  optional   double default_double   = 72 [default =  52e3  ];\n  optional     bool default_bool     = 73 [default = true   ];\n  optional   string default_string   = 74 [default = \"hello\"];\n  optional    bytes default_bytes    = 75 [default = \"world\"];\n\n  optional NestedEnum  default_nested_enum  = 81 [default = BAR        ];\n  optional ForeignEnum default_foreign_enum = 82 [default = FOREIGN_BAR];\n  optional protobuf_unittest_import.ImportEnum\n      default_import_enum = 83 [default = IMPORT_BAR];\n\n  optional string default_string_piece = 84 [ctype=STRING_PIECE,default=\"abc\"];\n  optional string default_cord = 85 [ctype=CORD,default=\"123\"];\n\n  // For oneof test\n  oneof oneof_field {\n    uint32 oneof_uint32 = 111;\n    NestedMessage oneof_nested_message = 112;\n    string oneof_string = 113;\n    bytes oneof_bytes = 114;\n    NestedMessage lazy_oneof_nested_message = 115 [lazy=true];\n  }\n}\n\n// Define these after TestAllTypes to make sure the compiler can handle\n// that.\nmessage ForeignMessage {\n  optional int32 c = 1;\n}\n\nenum ForeignEnum {\n  FOREIGN_FOO = 4;\n  FOREIGN_BAR = 5;\n  FOREIGN_BAZ = 6;\n}\n\nmessage TestNoArenaMessage {\n  optional proto2_arena_unittest.ArenaMessage arena_message = 1;\n};\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_no_arena_import.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto2\";\n\npackage proto2_arena_unittest;\n\nmessage ImportNoArenaNestedMessage {\n  optional int32 d = 1;\n};\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_no_arena_lite.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto2\";\n\noption optimize_for = LITE_RUNTIME;\n\n// We don't put this in a package within proto2 because we need to make sure\n// that the generated code doesn't depend on being in the proto2 namespace.\n// In test_util.h we do \"using namespace unittest = protobuf_unittest\".\npackage protobuf_unittest_no_arena;\n\nmessage ForeignMessageLite {\n  optional int32 c = 1;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_no_field_presence.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// A proto file used to test a message type with no explicit field presence.\n\nsyntax = \"proto3\";\n\n// We want to test embedded proto2 messages, so include some proto2 types.\nimport \"google/protobuf/unittest.proto\";\n\npackage proto2_nofieldpresence_unittest;\n\n// This proto includes every type of field in both singular and repeated\n// forms.\nmessage TestAllTypes {\n  message NestedMessage {\n    int32 bb = 1;\n  }\n\n  enum NestedEnum {\n    FOO = 0;\n    BAR = 1;\n    BAZ = 2;\n  }\n\n  // Singular\n  // TODO: remove 'optional' labels as soon as CL 69188077 is LGTM'd to make\n  // 'optional' optional.\n     int32 optional_int32    =  1;\n     int64 optional_int64    =  2;\n    uint32 optional_uint32   =  3;\n    uint64 optional_uint64   =  4;\n    sint32 optional_sint32   =  5;\n    sint64 optional_sint64   =  6;\n   fixed32 optional_fixed32  =  7;\n   fixed64 optional_fixed64  =  8;\n  sfixed32 optional_sfixed32 =  9;\n  sfixed64 optional_sfixed64 = 10;\n     float optional_float    = 11;\n    double optional_double   = 12;\n      bool optional_bool     = 13;\n    string optional_string   = 14;\n     bytes optional_bytes    = 15;\n\n  NestedMessage                        optional_nested_message  = 18;\n  ForeignMessage                       optional_foreign_message = 19;\n  protobuf_unittest.TestAllTypes         optional_proto2_message = 20;\n\n  NestedEnum                           optional_nested_enum     = 21;\n  ForeignEnum                          optional_foreign_enum    = 22;\n  // N.B.: proto2-enum-type fields not allowed, because their default values\n  // might not be zero.\n  //optional protobuf_unittest.ForeignEnum          optional_proto2_enum     = 23;\n\n  string optional_string_piece = 24 [ctype=STRING_PIECE];\n  string optional_cord = 25 [ctype=CORD];\n\n  NestedMessage optional_lazy_message = 30 [lazy=true];\n\n  // Repeated\n  repeated    int32 repeated_int32    = 31;\n  repeated    int64 repeated_int64    = 32;\n  repeated   uint32 repeated_uint32   = 33;\n  repeated   uint64 repeated_uint64   = 34;\n  repeated   sint32 repeated_sint32   = 35;\n  repeated   sint64 repeated_sint64   = 36;\n  repeated  fixed32 repeated_fixed32  = 37;\n  repeated  fixed64 repeated_fixed64  = 38;\n  repeated sfixed32 repeated_sfixed32 = 39;\n  repeated sfixed64 repeated_sfixed64 = 40;\n  repeated    float repeated_float    = 41;\n  repeated   double repeated_double   = 42;\n  repeated     bool repeated_bool     = 43;\n  repeated   string repeated_string   = 44;\n  repeated    bytes repeated_bytes    = 45;\n\n  repeated NestedMessage                        repeated_nested_message  = 48;\n  repeated ForeignMessage                       repeated_foreign_message = 49;\n  repeated protobuf_unittest.TestAllTypes         repeated_proto2_message  = 50;\n\n  repeated NestedEnum                           repeated_nested_enum     = 51;\n  repeated ForeignEnum                          repeated_foreign_enum    = 52;\n\n  repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];\n  repeated string repeated_cord = 55 [ctype=CORD];\n\n  repeated NestedMessage repeated_lazy_message = 57 [lazy=true];\n\n  oneof oneof_field {\n    uint32 oneof_uint32 = 111;\n    NestedMessage oneof_nested_message = 112;\n    string oneof_string = 113;\n    NestedEnum oneof_enum = 114;\n  }\n}\n\nmessage TestProto2Required {\n  protobuf_unittest.TestRequired proto2 = 1;\n}\n\n// Define these after TestAllTypes to make sure the compiler can handle\n// that.\nmessage ForeignMessage {\n  int32 c = 1;\n}\n\nenum ForeignEnum {\n  FOREIGN_FOO = 0;\n  FOREIGN_BAR = 1;\n  FOREIGN_BAZ = 2;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_no_generic_services.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n\nsyntax = \"proto2\";\npackage google.protobuf.no_generic_services_test;\n\n\n// *_generic_services are false by default.\n\nmessage TestMessage {\n  optional int32 a = 1;\n  extensions 1000 to max;\n}\n\nenum TestEnum {\n  FOO = 1;\n}\n\nextend TestMessage {\n  optional int32 test_extension = 1000;\n}\n\nservice TestService {\n  rpc Foo(TestMessage) returns(TestMessage);\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_optimize_for.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// A proto file which uses optimize_for = CODE_SIZE.\n\nsyntax = \"proto2\";\nimport \"google/protobuf/unittest.proto\";\n\npackage protobuf_unittest;\n\noption optimize_for = CODE_SIZE;\n\nmessage TestOptimizedForSize {\n  optional int32 i = 1;\n  optional ForeignMessage msg = 19;\n\n  extensions 1000 to max;\n\n  extend TestOptimizedForSize {\n    optional int32 test_extension = 1234;\n    optional TestRequiredOptimizedForSize test_extension2 = 1235;\n  }\n\n  oneof foo {\n    int32 integer_field = 2;\n    string string_field = 3;\n  }\n}\n\nmessage TestRequiredOptimizedForSize {\n  required int32 x = 1;\n}\n\nmessage TestOptionalOptimizedForSize {\n  optional TestRequiredOptimizedForSize o = 1;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_preserve_unknown_enum.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto3\";\n\npackage proto3_preserve_unknown_enum_unittest;\noption objc_class_prefix = \"UnknownEnums\";\n\noption csharp_namespace = \"Google.Protobuf.TestProtos\";\n\nenum MyEnum {\n  FOO = 0;\n  BAR = 1;\n  BAZ = 2;\n}\n\nenum MyEnumPlusExtra {\n  E_FOO = 0;\n  E_BAR = 1;\n  E_BAZ = 2;\n  E_EXTRA = 3;\n}\n\nmessage MyMessage {\n  MyEnum e = 1;\n  repeated MyEnum repeated_e = 2;\n  repeated MyEnum repeated_packed_e = 3 [packed=true];\n  repeated MyEnumPlusExtra repeated_packed_unexpected_e = 4;  // not packed\n  oneof o {\n    MyEnum oneof_e_1 = 5;\n    MyEnum oneof_e_2 = 6;\n  }\n}\n\nmessage MyMessagePlusExtra {\n  MyEnumPlusExtra e = 1;\n  repeated MyEnumPlusExtra repeated_e = 2;\n  repeated MyEnumPlusExtra repeated_packed_e = 3 [packed=true];\n  repeated MyEnumPlusExtra repeated_packed_unexpected_e = 4 [packed=true];\n  oneof o {\n    MyEnumPlusExtra oneof_e_1 = 5;\n    MyEnumPlusExtra oneof_e_2 = 6;\n  }\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_preserve_unknown_enum2.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto2\";\n\npackage proto2_preserve_unknown_enum_unittest;\n\nenum MyEnum {\n  FOO = 0;\n  BAR = 1;\n  BAZ = 2;\n}\n\nmessage MyMessage {\n  optional MyEnum e = 1;\n  repeated MyEnum repeated_e = 2;\n  repeated MyEnum repeated_packed_e = 3 [packed=true];\n  repeated MyEnum repeated_packed_unexpected_e = 4;  // not packed\n  oneof o {\n    MyEnum oneof_e_1 = 5;\n    MyEnum oneof_e_2 = 6;\n  }\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_proto3_arena.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto3\";\n\noption cc_enable_arenas = true;\n\nimport \"google/protobuf/unittest_import.proto\";\n\npackage proto3_arena_unittest;\n\n// This proto includes every type of field in both singular and repeated\n// forms.\nmessage TestAllTypes {\n  message NestedMessage {\n    // The field name \"b\" fails to compile in proto1 because it conflicts with\n    // a local variable named \"b\" in one of the generated methods.  Doh.\n    // This file needs to compile in proto1 to test backwards-compatibility.\n    int32 bb = 1;\n  }\n\n  enum NestedEnum {\n    ZERO = 0;\n    FOO = 1;\n    BAR = 2;\n    BAZ = 3;\n    NEG = -1;  // Intentionally negative.\n  }\n\n  // Singular\n     int32 optional_int32    =  1;\n     int64 optional_int64    =  2;\n    uint32 optional_uint32   =  3;\n    uint64 optional_uint64   =  4;\n    sint32 optional_sint32   =  5;\n    sint64 optional_sint64   =  6;\n   fixed32 optional_fixed32  =  7;\n   fixed64 optional_fixed64  =  8;\n  sfixed32 optional_sfixed32 =  9;\n  sfixed64 optional_sfixed64 = 10;\n     float optional_float    = 11;\n    double optional_double   = 12;\n      bool optional_bool     = 13;\n    string optional_string   = 14;\n     bytes optional_bytes    = 15;\n\n  // Groups are not allowed in proto3.\n  // optional group OptionalGroup = 16 {\n  //   optional int32 a = 17;\n  // }\n\n  NestedMessage                        optional_nested_message  = 18;\n  ForeignMessage                       optional_foreign_message = 19;\n  protobuf_unittest_import.ImportMessage optional_import_message  = 20;\n\n  NestedEnum                           optional_nested_enum     = 21;\n  ForeignEnum                          optional_foreign_enum    = 22;\n\n  // Omitted (compared to unittest.proto) because proto2 enums are not allowed\n  // inside proto2 messages.\n  //\n  // optional protobuf_unittest_import.ImportEnum    optional_import_enum  = 23;\n\n  string optional_string_piece = 24 [ctype=STRING_PIECE];\n  string optional_cord = 25 [ctype=CORD];\n\n  // Defined in unittest_import_public.proto\n  protobuf_unittest_import.PublicImportMessage\n      optional_public_import_message = 26;\n\n  NestedMessage optional_lazy_message = 27 [lazy=true];\n\n  // Repeated\n  repeated    int32 repeated_int32    = 31;\n  repeated    int64 repeated_int64    = 32;\n  repeated   uint32 repeated_uint32   = 33;\n  repeated   uint64 repeated_uint64   = 34;\n  repeated   sint32 repeated_sint32   = 35;\n  repeated   sint64 repeated_sint64   = 36;\n  repeated  fixed32 repeated_fixed32  = 37;\n  repeated  fixed64 repeated_fixed64  = 38;\n  repeated sfixed32 repeated_sfixed32 = 39;\n  repeated sfixed64 repeated_sfixed64 = 40;\n  repeated    float repeated_float    = 41;\n  repeated   double repeated_double   = 42;\n  repeated     bool repeated_bool     = 43;\n  repeated   string repeated_string   = 44;\n  repeated    bytes repeated_bytes    = 45;\n\n  // Groups are not allowed in proto3.\n  // repeated group RepeatedGroup = 46 {\n  //   optional int32 a = 47;\n  // }\n\n  repeated NestedMessage                        repeated_nested_message  = 48;\n  repeated ForeignMessage                       repeated_foreign_message = 49;\n  repeated protobuf_unittest_import.ImportMessage repeated_import_message  = 50;\n\n  repeated NestedEnum                           repeated_nested_enum     = 51;\n  repeated ForeignEnum                          repeated_foreign_enum    = 52;\n\n  // Omitted (compared to unittest.proto) because proto2 enums are not allowed\n  // inside proto2 messages.\n  //\n  // repeated protobuf_unittest_import.ImportEnum    repeated_import_enum  = 53;\n\n  repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];\n  repeated string repeated_cord = 55 [ctype=CORD];\n\n  repeated NestedMessage repeated_lazy_message = 57 [lazy=true];\n\n  oneof oneof_field {\n    uint32 oneof_uint32 = 111;\n    NestedMessage oneof_nested_message = 112;\n    string oneof_string = 113;\n    bytes oneof_bytes = 114;\n  }\n}\n\n// Test messages for packed fields\n\nmessage TestPackedTypes {\n  repeated    int32 packed_int32    =  90 [packed = true];\n  repeated    int64 packed_int64    =  91 [packed = true];\n  repeated   uint32 packed_uint32   =  92 [packed = true];\n  repeated   uint64 packed_uint64   =  93 [packed = true];\n  repeated   sint32 packed_sint32   =  94 [packed = true];\n  repeated   sint64 packed_sint64   =  95 [packed = true];\n  repeated  fixed32 packed_fixed32  =  96 [packed = true];\n  repeated  fixed64 packed_fixed64  =  97 [packed = true];\n  repeated sfixed32 packed_sfixed32 =  98 [packed = true];\n  repeated sfixed64 packed_sfixed64 =  99 [packed = true];\n  repeated    float packed_float    = 100 [packed = true];\n  repeated   double packed_double   = 101 [packed = true];\n  repeated     bool packed_bool     = 102 [packed = true];\n  repeated ForeignEnum packed_enum  = 103 [packed = true];\n}\n\n// Explicitly set packed to false\nmessage TestUnpackedTypes {\n  repeated    int32 repeated_int32    =  1 [packed = false];\n  repeated    int64 repeated_int64    =  2 [packed = false];\n  repeated   uint32 repeated_uint32   =  3 [packed = false];\n  repeated   uint64 repeated_uint64   =  4 [packed = false];\n  repeated   sint32 repeated_sint32   =  5 [packed = false];\n  repeated   sint64 repeated_sint64   =  6 [packed = false];\n  repeated  fixed32 repeated_fixed32  =  7 [packed = false];\n  repeated  fixed64 repeated_fixed64  =  8 [packed = false];\n  repeated sfixed32 repeated_sfixed32 =  9 [packed = false];\n  repeated sfixed64 repeated_sfixed64 = 10 [packed = false];\n  repeated    float repeated_float    = 11 [packed = false];\n  repeated   double repeated_double   = 12 [packed = false];\n  repeated     bool repeated_bool     = 13 [packed = false];\n  repeated TestAllTypes.NestedEnum repeated_nested_enum = 14 [packed = false];\n}\n\n// This proto includes a recusively nested message.\nmessage NestedTestAllTypes {\n  NestedTestAllTypes child = 1;\n  TestAllTypes payload = 2;\n}\n\n// Define these after TestAllTypes to make sure the compiler can handle\n// that.\nmessage ForeignMessage {\n  int32 c = 1;\n}\n\nenum ForeignEnum {\n  FOREIGN_ZERO = 0;\n  FOREIGN_FOO = 4;\n  FOREIGN_BAR = 5;\n  FOREIGN_BAZ = 6;\n}\n\n// TestEmptyMessage is used to test behavior of unknown fields.\nmessage TestEmptyMessage {\n}\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_proto3_arena_lite.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto3\";\n\noption cc_enable_arenas = true;\noption optimize_for = LITE_RUNTIME;\n\nimport \"google/protobuf/unittest_import.proto\";\n\npackage proto3_arena_lite_unittest;\n\n// This proto includes every type of field in both singular and repeated\n// forms.\nmessage TestAllTypes {\n  message NestedMessage {\n    // The field name \"b\" fails to compile in proto1 because it conflicts with\n    // a local variable named \"b\" in one of the generated methods.  Doh.\n    // This file needs to compile in proto1 to test backwards-compatibility.\n    int32 bb = 1;\n  }\n\n  enum NestedEnum {\n    ZERO = 0;\n    FOO = 1;\n    BAR = 2;\n    BAZ = 3;\n    NEG = -1;  // Intentionally negative.\n  }\n\n  // Singular\n     int32 optional_int32    =  1;\n     int64 optional_int64    =  2;\n    uint32 optional_uint32   =  3;\n    uint64 optional_uint64   =  4;\n    sint32 optional_sint32   =  5;\n    sint64 optional_sint64   =  6;\n   fixed32 optional_fixed32  =  7;\n   fixed64 optional_fixed64  =  8;\n  sfixed32 optional_sfixed32 =  9;\n  sfixed64 optional_sfixed64 = 10;\n     float optional_float    = 11;\n    double optional_double   = 12;\n      bool optional_bool     = 13;\n    string optional_string   = 14;\n     bytes optional_bytes    = 15;\n\n  // Groups are not allowed in proto3.\n  // optional group OptionalGroup = 16 {\n  //   optional int32 a = 17;\n  // }\n\n  NestedMessage                        optional_nested_message  = 18;\n  ForeignMessage                       optional_foreign_message = 19;\n  protobuf_unittest_import.ImportMessage optional_import_message  = 20;\n\n  NestedEnum                           optional_nested_enum     = 21;\n  ForeignEnum                          optional_foreign_enum    = 22;\n\n  // Omitted (compared to unittest.proto) because proto2 enums are not allowed\n  // inside proto2 messages.\n  //\n  // optional protobuf_unittest_import.ImportEnum    optional_import_enum  = 23;\n\n  string optional_string_piece = 24 [ctype=STRING_PIECE];\n  string optional_cord = 25 [ctype=CORD];\n\n  // Defined in unittest_import_public.proto\n  protobuf_unittest_import.PublicImportMessage\n      optional_public_import_message = 26;\n\n  NestedMessage optional_lazy_message = 27 [lazy=true];\n\n  // Repeated\n  repeated    int32 repeated_int32    = 31;\n  repeated    int64 repeated_int64    = 32;\n  repeated   uint32 repeated_uint32   = 33;\n  repeated   uint64 repeated_uint64   = 34;\n  repeated   sint32 repeated_sint32   = 35;\n  repeated   sint64 repeated_sint64   = 36;\n  repeated  fixed32 repeated_fixed32  = 37;\n  repeated  fixed64 repeated_fixed64  = 38;\n  repeated sfixed32 repeated_sfixed32 = 39;\n  repeated sfixed64 repeated_sfixed64 = 40;\n  repeated    float repeated_float    = 41;\n  repeated   double repeated_double   = 42;\n  repeated     bool repeated_bool     = 43;\n  repeated   string repeated_string   = 44;\n  repeated    bytes repeated_bytes    = 45;\n\n  // Groups are not allowed in proto3.\n  // repeated group RepeatedGroup = 46 {\n  //   optional int32 a = 47;\n  // }\n\n  repeated NestedMessage                        repeated_nested_message  = 48;\n  repeated ForeignMessage                       repeated_foreign_message = 49;\n  repeated protobuf_unittest_import.ImportMessage repeated_import_message  = 50;\n\n  repeated NestedEnum                           repeated_nested_enum     = 51;\n  repeated ForeignEnum                          repeated_foreign_enum    = 52;\n\n  // Omitted (compared to unittest.proto) because proto2 enums are not allowed\n  // inside proto2 messages.\n  //\n  // repeated protobuf_unittest_import.ImportEnum    repeated_import_enum  = 53;\n\n  repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];\n  repeated string repeated_cord = 55 [ctype=CORD];\n\n  repeated NestedMessage repeated_lazy_message = 57 [lazy=true];\n\n  oneof oneof_field {\n    uint32 oneof_uint32 = 111;\n    NestedMessage oneof_nested_message = 112;\n    string oneof_string = 113;\n    bytes oneof_bytes = 114;\n  }\n}\n\n// Test messages for packed fields\n\nmessage TestPackedTypes {\n  repeated    int32 packed_int32    =  90 [packed = true];\n  repeated    int64 packed_int64    =  91 [packed = true];\n  repeated   uint32 packed_uint32   =  92 [packed = true];\n  repeated   uint64 packed_uint64   =  93 [packed = true];\n  repeated   sint32 packed_sint32   =  94 [packed = true];\n  repeated   sint64 packed_sint64   =  95 [packed = true];\n  repeated  fixed32 packed_fixed32  =  96 [packed = true];\n  repeated  fixed64 packed_fixed64  =  97 [packed = true];\n  repeated sfixed32 packed_sfixed32 =  98 [packed = true];\n  repeated sfixed64 packed_sfixed64 =  99 [packed = true];\n  repeated    float packed_float    = 100 [packed = true];\n  repeated   double packed_double   = 101 [packed = true];\n  repeated     bool packed_bool     = 102 [packed = true];\n  repeated ForeignEnum packed_enum  = 103 [packed = true];\n}\n\n// Explicitly set packed to false\nmessage TestUnpackedTypes {\n  repeated    int32 repeated_int32    =  1 [packed = false];\n  repeated    int64 repeated_int64    =  2 [packed = false];\n  repeated   uint32 repeated_uint32   =  3 [packed = false];\n  repeated   uint64 repeated_uint64   =  4 [packed = false];\n  repeated   sint32 repeated_sint32   =  5 [packed = false];\n  repeated   sint64 repeated_sint64   =  6 [packed = false];\n  repeated  fixed32 repeated_fixed32  =  7 [packed = false];\n  repeated  fixed64 repeated_fixed64  =  8 [packed = false];\n  repeated sfixed32 repeated_sfixed32 =  9 [packed = false];\n  repeated sfixed64 repeated_sfixed64 = 10 [packed = false];\n  repeated    float repeated_float    = 11 [packed = false];\n  repeated   double repeated_double   = 12 [packed = false];\n  repeated     bool repeated_bool     = 13 [packed = false];\n  repeated TestAllTypes.NestedEnum repeated_nested_enum = 14 [packed = false];\n}\n\n// This proto includes a recusively nested message.\nmessage NestedTestAllTypes {\n  NestedTestAllTypes child = 1;\n  TestAllTypes payload = 2;\n}\n\n// Define these after TestAllTypes to make sure the compiler can handle\n// that.\nmessage ForeignMessage {\n  int32 c = 1;\n}\n\nenum ForeignEnum {\n  FOREIGN_ZERO = 0;\n  FOREIGN_FOO = 4;\n  FOREIGN_BAR = 5;\n  FOREIGN_BAZ = 6;\n}\n\n// TestEmptyMessage is used to test behavior of unknown fields.\nmessage TestEmptyMessage {\n}\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_proto3_lite.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto3\";\n\noption optimize_for = LITE_RUNTIME;\n\nimport \"google/protobuf/unittest_import.proto\";\n\npackage proto3_lite_unittest;\n\n// This proto includes every type of field in both singular and repeated\n// forms.\nmessage TestAllTypes {\n  message NestedMessage {\n    // The field name \"b\" fails to compile in proto1 because it conflicts with\n    // a local variable named \"b\" in one of the generated methods.  Doh.\n    // This file needs to compile in proto1 to test backwards-compatibility.\n    int32 bb = 1;\n  }\n\n  enum NestedEnum {\n    ZERO = 0;\n    FOO = 1;\n    BAR = 2;\n    BAZ = 3;\n    NEG = -1;  // Intentionally negative.\n  }\n\n  // Singular\n     int32 optional_int32    =  1;\n     int64 optional_int64    =  2;\n    uint32 optional_uint32   =  3;\n    uint64 optional_uint64   =  4;\n    sint32 optional_sint32   =  5;\n    sint64 optional_sint64   =  6;\n   fixed32 optional_fixed32  =  7;\n   fixed64 optional_fixed64  =  8;\n  sfixed32 optional_sfixed32 =  9;\n  sfixed64 optional_sfixed64 = 10;\n     float optional_float    = 11;\n    double optional_double   = 12;\n      bool optional_bool     = 13;\n    string optional_string   = 14;\n     bytes optional_bytes    = 15;\n\n  // Groups are not allowed in proto3.\n  // optional group OptionalGroup = 16 {\n  //   optional int32 a = 17;\n  // }\n\n  NestedMessage                        optional_nested_message  = 18;\n  ForeignMessage                       optional_foreign_message = 19;\n  protobuf_unittest_import.ImportMessage optional_import_message  = 20;\n\n  NestedEnum                           optional_nested_enum     = 21;\n  ForeignEnum                          optional_foreign_enum    = 22;\n\n  // Omitted (compared to unittest.proto) because proto2 enums are not allowed\n  // inside proto2 messages.\n  //\n  // optional protobuf_unittest_import.ImportEnum    optional_import_enum  = 23;\n\n  string optional_string_piece = 24 [ctype=STRING_PIECE];\n  string optional_cord = 25 [ctype=CORD];\n\n  // Defined in unittest_import_public.proto\n  protobuf_unittest_import.PublicImportMessage\n      optional_public_import_message = 26;\n\n  NestedMessage optional_lazy_message = 27 [lazy=true];\n\n  // Repeated\n  repeated    int32 repeated_int32    = 31;\n  repeated    int64 repeated_int64    = 32;\n  repeated   uint32 repeated_uint32   = 33;\n  repeated   uint64 repeated_uint64   = 34;\n  repeated   sint32 repeated_sint32   = 35;\n  repeated   sint64 repeated_sint64   = 36;\n  repeated  fixed32 repeated_fixed32  = 37;\n  repeated  fixed64 repeated_fixed64  = 38;\n  repeated sfixed32 repeated_sfixed32 = 39;\n  repeated sfixed64 repeated_sfixed64 = 40;\n  repeated    float repeated_float    = 41;\n  repeated   double repeated_double   = 42;\n  repeated     bool repeated_bool     = 43;\n  repeated   string repeated_string   = 44;\n  repeated    bytes repeated_bytes    = 45;\n\n  // Groups are not allowed in proto3.\n  // repeated group RepeatedGroup = 46 {\n  //   optional int32 a = 47;\n  // }\n\n  repeated NestedMessage                        repeated_nested_message  = 48;\n  repeated ForeignMessage                       repeated_foreign_message = 49;\n  repeated protobuf_unittest_import.ImportMessage repeated_import_message  = 50;\n\n  repeated NestedEnum                           repeated_nested_enum     = 51;\n  repeated ForeignEnum                          repeated_foreign_enum    = 52;\n\n  // Omitted (compared to unittest.proto) because proto2 enums are not allowed\n  // inside proto2 messages.\n  //\n  // repeated protobuf_unittest_import.ImportEnum    repeated_import_enum  = 53;\n\n  repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];\n  repeated string repeated_cord = 55 [ctype=CORD];\n\n  repeated NestedMessage repeated_lazy_message = 57 [lazy=true];\n\n  oneof oneof_field {\n    uint32 oneof_uint32 = 111;\n    NestedMessage oneof_nested_message = 112;\n    string oneof_string = 113;\n    bytes oneof_bytes = 114;\n  }\n}\n\n// Test messages for packed fields\n\nmessage TestPackedTypes {\n  repeated    int32 packed_int32    =  90 [packed = true];\n  repeated    int64 packed_int64    =  91 [packed = true];\n  repeated   uint32 packed_uint32   =  92 [packed = true];\n  repeated   uint64 packed_uint64   =  93 [packed = true];\n  repeated   sint32 packed_sint32   =  94 [packed = true];\n  repeated   sint64 packed_sint64   =  95 [packed = true];\n  repeated  fixed32 packed_fixed32  =  96 [packed = true];\n  repeated  fixed64 packed_fixed64  =  97 [packed = true];\n  repeated sfixed32 packed_sfixed32 =  98 [packed = true];\n  repeated sfixed64 packed_sfixed64 =  99 [packed = true];\n  repeated    float packed_float    = 100 [packed = true];\n  repeated   double packed_double   = 101 [packed = true];\n  repeated     bool packed_bool     = 102 [packed = true];\n  repeated ForeignEnum packed_enum  = 103 [packed = true];\n}\n\n// Explicitly set packed to false\nmessage TestUnpackedTypes {\n  repeated    int32 repeated_int32    =  1 [packed = false];\n  repeated    int64 repeated_int64    =  2 [packed = false];\n  repeated   uint32 repeated_uint32   =  3 [packed = false];\n  repeated   uint64 repeated_uint64   =  4 [packed = false];\n  repeated   sint32 repeated_sint32   =  5 [packed = false];\n  repeated   sint64 repeated_sint64   =  6 [packed = false];\n  repeated  fixed32 repeated_fixed32  =  7 [packed = false];\n  repeated  fixed64 repeated_fixed64  =  8 [packed = false];\n  repeated sfixed32 repeated_sfixed32 =  9 [packed = false];\n  repeated sfixed64 repeated_sfixed64 = 10 [packed = false];\n  repeated    float repeated_float    = 11 [packed = false];\n  repeated   double repeated_double   = 12 [packed = false];\n  repeated     bool repeated_bool     = 13 [packed = false];\n  repeated TestAllTypes.NestedEnum repeated_nested_enum = 14 [packed = false];\n}\n\n// This proto includes a recusively nested message.\nmessage NestedTestAllTypes {\n  NestedTestAllTypes child = 1;\n  TestAllTypes payload = 2;\n}\n\n// Define these after TestAllTypes to make sure the compiler can handle\n// that.\nmessage ForeignMessage {\n  int32 c = 1;\n}\n\nenum ForeignEnum {\n  FOREIGN_ZERO = 0;\n  FOREIGN_FOO = 4;\n  FOREIGN_BAR = 5;\n  FOREIGN_BAZ = 6;\n}\n\n// TestEmptyMessage is used to test behavior of unknown fields.\nmessage TestEmptyMessage {\n}\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unittest_well_known_types.proto",
    "content": "syntax = \"proto3\";\n\npackage protobuf_unittest;\n\noption csharp_namespace = \"Google.Protobuf.TestProtos\";\noption java_multiple_files = true;\noption java_package = \"com.google.protobuf.test\";\n\nimport \"google/protobuf/any.proto\";\nimport \"google/protobuf/api.proto\";\nimport \"google/protobuf/duration.proto\";\nimport \"google/protobuf/empty.proto\";\nimport \"google/protobuf/field_mask.proto\";\nimport \"google/protobuf/source_context.proto\";\nimport \"google/protobuf/struct.proto\";\nimport \"google/protobuf/timestamp.proto\";\nimport \"google/protobuf/type.proto\";\nimport \"google/protobuf/wrappers.proto\";\n\n// Test that we can include all well-known types.\n// Each wrapper type is included separately, as languages\n// map handle different wrappers in different ways.\nmessage TestWellKnownTypes {\n  google.protobuf.Any any_field = 1;\n  google.protobuf.Api api_field = 2;\n  google.protobuf.Duration duration_field = 3;\n  google.protobuf.Empty empty_field = 4;\n  google.protobuf.FieldMask field_mask_field = 5;\n  google.protobuf.SourceContext source_context_field = 6;\n  google.protobuf.Struct struct_field = 7;\n  google.protobuf.Timestamp timestamp_field = 8;\n  google.protobuf.Type type_field = 9;\n  google.protobuf.DoubleValue double_field = 10;\n  google.protobuf.FloatValue float_field = 11;\n  google.protobuf.Int64Value int64_field = 12;\n  google.protobuf.UInt64Value uint64_field = 13;\n  google.protobuf.Int32Value int32_field = 14;\n  google.protobuf.UInt32Value uint32_field = 15;\n  google.protobuf.BoolValue bool_field = 16;\n  google.protobuf.StringValue string_field = 17;\n  google.protobuf.BytesValue bytes_field = 18;\n  // Part of struct, but useful to be able to test separately\n  google.protobuf.Value value_field = 19;\n}\n\n// A repeated field for each well-known type.\nmessage RepeatedWellKnownTypes {\n  repeated google.protobuf.Any any_field = 1;\n  repeated google.protobuf.Api api_field = 2;\n  repeated google.protobuf.Duration duration_field = 3;\n  repeated google.protobuf.Empty empty_field = 4;\n  repeated google.protobuf.FieldMask field_mask_field = 5;\n  repeated google.protobuf.SourceContext source_context_field = 6;\n  repeated google.protobuf.Struct struct_field = 7;\n  repeated google.protobuf.Timestamp timestamp_field = 8;\n  repeated google.protobuf.Type type_field = 9;\n  // These don't actually make a lot of sense, but they're not prohibited...\n  repeated google.protobuf.DoubleValue double_field = 10;\n  repeated google.protobuf.FloatValue float_field = 11;\n  repeated google.protobuf.Int64Value int64_field = 12;\n  repeated google.protobuf.UInt64Value uint64_field = 13;\n  repeated google.protobuf.Int32Value int32_field = 14;\n  repeated google.protobuf.UInt32Value uint32_field = 15;\n  repeated google.protobuf.BoolValue bool_field = 16;\n  repeated google.protobuf.StringValue string_field = 17;\n  repeated google.protobuf.BytesValue bytes_field = 18;\n}\n\nmessage OneofWellKnownTypes {\n  oneof oneof_field {\n    google.protobuf.Any any_field = 1;\n    google.protobuf.Api api_field = 2;\n    google.protobuf.Duration duration_field = 3;\n    google.protobuf.Empty empty_field = 4;\n    google.protobuf.FieldMask field_mask_field = 5;\n    google.protobuf.SourceContext source_context_field = 6;\n    google.protobuf.Struct struct_field = 7;\n    google.protobuf.Timestamp timestamp_field = 8;\n    google.protobuf.Type type_field = 9;\n    google.protobuf.DoubleValue double_field = 10;\n    google.protobuf.FloatValue float_field = 11;\n    google.protobuf.Int64Value int64_field = 12;\n    google.protobuf.UInt64Value uint64_field = 13;\n    google.protobuf.Int32Value int32_field = 14;\n    google.protobuf.UInt32Value uint32_field = 15;\n    google.protobuf.BoolValue bool_field = 16;\n    google.protobuf.StringValue string_field = 17;\n    google.protobuf.BytesValue bytes_field = 18;\n  }\n}\n\n// A map field for each well-known type. We only\n// need to worry about the value part of the map being the\n// well-known types, as messages can't be map keys.\nmessage MapWellKnownTypes {\n  map<int32,google.protobuf.Any> any_field = 1;\n  map<int32,google.protobuf.Api> api_field = 2;\n  map<int32,google.protobuf.Duration> duration_field = 3;\n  map<int32,google.protobuf.Empty> empty_field = 4;\n  map<int32,google.protobuf.FieldMask> field_mask_field = 5;\n  map<int32,google.protobuf.SourceContext> source_context_field = 6;\n  map<int32,google.protobuf.Struct> struct_field = 7;\n  map<int32,google.protobuf.Timestamp> timestamp_field = 8;\n  map<int32,google.protobuf.Type> type_field = 9;\n  map<int32,google.protobuf.DoubleValue> double_field = 10;\n  map<int32,google.protobuf.FloatValue> float_field = 11;\n  map<int32,google.protobuf.Int64Value> int64_field = 12;\n  map<int32,google.protobuf.UInt64Value> uint64_field = 13;\n  map<int32,google.protobuf.Int32Value> int32_field = 14;\n  map<int32,google.protobuf.UInt32Value> uint32_field = 15;\n  map<int32,google.protobuf.BoolValue> bool_field = 16;\n  map<int32,google.protobuf.StringValue> string_field = 17;\n  map<int32,google.protobuf.BytesValue> bytes_field = 18;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unknown_field_set.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/unknown_field_set.h>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/stubs/stl_util.h>\n\nnamespace google {\nnamespace protobuf {\n\nnamespace {\n// This global instance is returned by unknown_fields() on any message class\n// when the object has no unknown fields. This is necessary because we now\n// instantiate the UnknownFieldSet dynamically only when required.\nUnknownFieldSet* default_unknown_field_set_instance_ = NULL;\n\nvoid DeleteDefaultUnknownFieldSet() {\n  delete default_unknown_field_set_instance_;\n}\n\nvoid InitDefaultUnknownFieldSet() {\n  default_unknown_field_set_instance_ = new UnknownFieldSet();\n  internal::OnShutdown(&DeleteDefaultUnknownFieldSet);\n}\n\nGOOGLE_PROTOBUF_DECLARE_ONCE(default_unknown_field_set_once_init_);\n}\n\nconst UnknownFieldSet* UnknownFieldSet::default_instance() {\n  ::google::protobuf::GoogleOnceInit(&default_unknown_field_set_once_init_,\n                 &InitDefaultUnknownFieldSet);\n  return default_unknown_field_set_instance_;\n}\n\nvoid UnknownFieldSet::ClearFallback() {\n  GOOGLE_DCHECK(fields_ != NULL && fields_->size() > 0);\n  int n = fields_->size();\n  do {\n    (*fields_)[--n].Delete();\n  } while (n > 0);\n  delete fields_;\n  fields_ = NULL;\n}\n\nvoid UnknownFieldSet::InternalMergeFrom(const UnknownFieldSet& other) {\n  int other_field_count = other.field_count();\n  if (other_field_count > 0) {\n    fields_ = new vector<UnknownField>();\n    for (int i = 0; i < other_field_count; i++) {\n      fields_->push_back((*other.fields_)[i]);\n      fields_->back().DeepCopy((*other.fields_)[i]);\n    }\n  }\n}\n\nvoid UnknownFieldSet::MergeFrom(const UnknownFieldSet& other) {\n  int other_field_count = other.field_count();\n  if (other_field_count > 0) {\n    if (fields_ == NULL) fields_ = new vector<UnknownField>();\n    for (int i = 0; i < other_field_count; i++) {\n      fields_->push_back((*other.fields_)[i]);\n      fields_->back().DeepCopy((*other.fields_)[i]);\n    }\n  }\n}\n\n// A specialized MergeFrom for performance when we are merging from an UFS that\n// is temporary and can be destroyed in the process.\nvoid UnknownFieldSet::MergeFromAndDestroy(UnknownFieldSet* other) {\n  int other_field_count = other->field_count();\n  if (other_field_count > 0) {\n    if (fields_ == NULL) fields_ = new vector<UnknownField>();\n    for (int i = 0; i < other_field_count; i++) {\n      fields_->push_back((*other->fields_)[i]);\n      (*other->fields_)[i].Reset();\n    }\n  }\n  delete other->fields_;\n  other->fields_ = NULL;\n}\n\nint UnknownFieldSet::SpaceUsedExcludingSelf() const {\n  if (fields_ == NULL) return 0;\n\n  int total_size = sizeof(*fields_) + sizeof(UnknownField) * fields_->size();\n\n  for (int i = 0; i < fields_->size(); i++) {\n    const UnknownField& field = (*fields_)[i];\n    switch (field.type()) {\n      case UnknownField::TYPE_LENGTH_DELIMITED:\n        total_size += sizeof(*field.length_delimited_.string_value_) +\n                      internal::StringSpaceUsedExcludingSelf(\n                          *field.length_delimited_.string_value_);\n        break;\n      case UnknownField::TYPE_GROUP:\n        total_size += field.group_->SpaceUsed();\n        break;\n      default:\n        break;\n    }\n  }\n  return total_size;\n}\n\nint UnknownFieldSet::SpaceUsed() const {\n  return sizeof(*this) + SpaceUsedExcludingSelf();\n}\n\nvoid UnknownFieldSet::AddVarint(int number, uint64 value) {\n  UnknownField field;\n  field.number_ = number;\n  field.SetType(UnknownField::TYPE_VARINT);\n  field.varint_ = value;\n  if (fields_ == NULL) fields_ = new vector<UnknownField>();\n  fields_->push_back(field);\n}\n\nvoid UnknownFieldSet::AddFixed32(int number, uint32 value) {\n  UnknownField field;\n  field.number_ = number;\n  field.SetType(UnknownField::TYPE_FIXED32);\n  field.fixed32_ = value;\n  if (fields_ == NULL) fields_ = new vector<UnknownField>();\n  fields_->push_back(field);\n}\n\nvoid UnknownFieldSet::AddFixed64(int number, uint64 value) {\n  UnknownField field;\n  field.number_ = number;\n  field.SetType(UnknownField::TYPE_FIXED64);\n  field.fixed64_ = value;\n  if (fields_ == NULL) fields_ = new vector<UnknownField>();\n  fields_->push_back(field);\n}\n\nstring* UnknownFieldSet::AddLengthDelimited(int number) {\n  UnknownField field;\n  field.number_ = number;\n  field.SetType(UnknownField::TYPE_LENGTH_DELIMITED);\n  field.length_delimited_.string_value_ = new string;\n  if (fields_ == NULL) fields_ = new vector<UnknownField>();\n  fields_->push_back(field);\n  return field.length_delimited_.string_value_;\n}\n\n\nUnknownFieldSet* UnknownFieldSet::AddGroup(int number) {\n  UnknownField field;\n  field.number_ = number;\n  field.SetType(UnknownField::TYPE_GROUP);\n  field.group_ = new UnknownFieldSet;\n  if (fields_ == NULL) fields_ = new vector<UnknownField>();\n  fields_->push_back(field);\n  return field.group_;\n}\n\nvoid UnknownFieldSet::AddField(const UnknownField& field) {\n  if (fields_ == NULL) fields_ = new vector<UnknownField>();\n  fields_->push_back(field);\n  fields_->back().DeepCopy(field);\n}\n\nvoid UnknownFieldSet::DeleteSubrange(int start, int num) {\n  // Delete the specified fields.\n  for (int i = 0; i < num; ++i) {\n    (*fields_)[i + start].Delete();\n  }\n  // Slide down the remaining fields.\n  for (int i = start + num; i < fields_->size(); ++i) {\n    (*fields_)[i - num] = (*fields_)[i];\n  }\n  // Pop off the # of deleted fields.\n  for (int i = 0; i < num; ++i) {\n    fields_->pop_back();\n  }\n  if (fields_ && fields_->size() == 0) {\n    // maintain invariant: never hold fields_ if empty.\n    delete fields_;\n    fields_ = NULL;\n  }\n}\n\nvoid UnknownFieldSet::DeleteByNumber(int number) {\n  if (fields_ == NULL) return;\n  int left = 0;  // The number of fields left after deletion.\n  for (int i = 0; i < fields_->size(); ++i) {\n    UnknownField* field = &(*fields_)[i];\n    if (field->number() == number) {\n      field->Delete();\n    } else {\n      if (i != left) {\n        (*fields_)[left] = (*fields_)[i];\n      }\n      ++left;\n    }\n  }\n  fields_->resize(left);\n  if (left == 0) {\n    // maintain invariant: never hold fields_ if empty.\n    delete fields_;\n    fields_ = NULL;\n  }\n}\n\nbool UnknownFieldSet::MergeFromCodedStream(io::CodedInputStream* input) {\n  UnknownFieldSet other;\n  if (internal::WireFormat::SkipMessage(input, &other) &&\n      input->ConsumedEntireMessage()) {\n    MergeFromAndDestroy(&other);\n    return true;\n  } else {\n    return false;\n  }\n}\n\nbool UnknownFieldSet::ParseFromCodedStream(io::CodedInputStream* input) {\n  Clear();\n  return MergeFromCodedStream(input);\n}\n\nbool UnknownFieldSet::ParseFromZeroCopyStream(io::ZeroCopyInputStream* input) {\n  io::CodedInputStream coded_input(input);\n  return (ParseFromCodedStream(&coded_input) &&\n          coded_input.ConsumedEntireMessage());\n}\n\nbool UnknownFieldSet::ParseFromArray(const void* data, int size) {\n  io::ArrayInputStream input(data, size);\n  return ParseFromZeroCopyStream(&input);\n}\n\nvoid UnknownField::Delete() {\n  switch (type()) {\n    case UnknownField::TYPE_LENGTH_DELIMITED:\n      delete length_delimited_.string_value_;\n      break;\n    case UnknownField::TYPE_GROUP:\n      delete group_;\n      break;\n    default:\n      break;\n  }\n}\n\n// Reset all owned ptrs, a special function for performance, to avoid double\n// owning the ptrs, when we merge from a temporary UnknownFieldSet objects.\nvoid UnknownField::Reset() {\n  switch (type()) {\n    case UnknownField::TYPE_LENGTH_DELIMITED:\n      length_delimited_.string_value_ = NULL;\n      break;\n    case UnknownField::TYPE_GROUP: {\n      group_ = NULL;\n      break;\n    }\n    default:\n      break;\n  }\n}\n\nvoid UnknownField::DeepCopy(const UnknownField& other) {\n  switch (type()) {\n    case UnknownField::TYPE_LENGTH_DELIMITED:\n      length_delimited_.string_value_ = new string(\n          *length_delimited_.string_value_);\n      break;\n    case UnknownField::TYPE_GROUP: {\n      UnknownFieldSet* group = new UnknownFieldSet();\n      group->InternalMergeFrom(*group_);\n      group_ = group;\n      break;\n    }\n    default:\n      break;\n  }\n}\n\n\nvoid UnknownField::SerializeLengthDelimitedNoTag(\n    io::CodedOutputStream* output) const {\n  GOOGLE_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type());\n  const string& data = *length_delimited_.string_value_;\n  output->WriteVarint32(data.size());\n  output->WriteRawMaybeAliased(data.data(), data.size());\n}\n\nuint8* UnknownField::SerializeLengthDelimitedNoTagToArray(uint8* target) const {\n  GOOGLE_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type());\n  const string& data = *length_delimited_.string_value_;\n  target = io::CodedOutputStream::WriteVarint32ToArray(data.size(), target);\n  target = io::CodedOutputStream::WriteStringToArray(data, target);\n  return target;\n}\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unknown_field_set.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// Contains classes used to keep track of unrecognized fields seen while\n// parsing a protocol message.\n\n#ifndef GOOGLE_PROTOBUF_UNKNOWN_FIELD_SET_H__\n#define GOOGLE_PROTOBUF_UNKNOWN_FIELD_SET_H__\n\n#include <assert.h>\n#include <string>\n#include <vector>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n\nnamespace google {\nnamespace protobuf {\n  namespace io {\n    class CodedInputStream;         // coded_stream.h\n    class CodedOutputStream;        // coded_stream.h\n    class ZeroCopyInputStream;      // zero_copy_stream.h\n  }\n  namespace internal {\n    class WireFormat;               // wire_format.h\n    class MessageSetFieldSkipperUsingCord;\n                                    // extension_set_heavy.cc\n  }\n\nclass Message;                      // message.h\nclass UnknownField;                 // below\n\n// An UnknownFieldSet contains fields that were encountered while parsing a\n// message but were not defined by its type.  Keeping track of these can be\n// useful, especially in that they may be written if the message is serialized\n// again without being cleared in between.  This means that software which\n// simply receives messages and forwards them to other servers does not need\n// to be updated every time a new field is added to the message definition.\n//\n// To get the UnknownFieldSet attached to any message, call\n// Reflection::GetUnknownFields().\n//\n// This class is necessarily tied to the protocol buffer wire format, unlike\n// the Reflection interface which is independent of any serialization scheme.\nclass LIBPROTOBUF_EXPORT UnknownFieldSet {\n public:\n  UnknownFieldSet();\n  ~UnknownFieldSet();\n\n  // Remove all fields.\n  inline void Clear();\n\n  // Remove all fields and deallocate internal data objects\n  void ClearAndFreeMemory();\n\n  // Is this set empty?\n  inline bool empty() const;\n\n  // Merge the contents of some other UnknownFieldSet with this one.\n  void MergeFrom(const UnknownFieldSet& other);\n\n  // Similar to above, but this function will destroy the contents of other.\n  void MergeFromAndDestroy(UnknownFieldSet* other);\n\n  // Swaps the contents of some other UnknownFieldSet with this one.\n  inline void Swap(UnknownFieldSet* x);\n\n  // Computes (an estimate of) the total number of bytes currently used for\n  // storing the unknown fields in memory. Does NOT include\n  // sizeof(*this) in the calculation.\n  int SpaceUsedExcludingSelf() const;\n\n  // Version of SpaceUsed() including sizeof(*this).\n  int SpaceUsed() const;\n\n  // Returns the number of fields present in the UnknownFieldSet.\n  inline int field_count() const;\n  // Get a field in the set, where 0 <= index < field_count().  The fields\n  // appear in the order in which they were added.\n  inline const UnknownField& field(int index) const;\n  // Get a mutable pointer to a field in the set, where\n  // 0 <= index < field_count().  The fields appear in the order in which\n  // they were added.\n  inline UnknownField* mutable_field(int index);\n\n  // Adding fields ---------------------------------------------------\n\n  void AddVarint(int number, uint64 value);\n  void AddFixed32(int number, uint32 value);\n  void AddFixed64(int number, uint64 value);\n  void AddLengthDelimited(int number, const string& value);\n  string* AddLengthDelimited(int number);\n  UnknownFieldSet* AddGroup(int number);\n\n  // Adds an unknown field from another set.\n  void AddField(const UnknownField& field);\n\n  // Delete fields with indices in the range [start .. start+num-1].\n  // Caution: implementation moves all fields with indices [start+num .. ].\n  void DeleteSubrange(int start, int num);\n\n  // Delete all fields with a specific field number. The order of left fields\n  // is preserved.\n  // Caution: implementation moves all fields after the first deleted field.\n  void DeleteByNumber(int number);\n\n  // Parsing helpers -------------------------------------------------\n  // These work exactly like the similarly-named methods of Message.\n\n  bool MergeFromCodedStream(io::CodedInputStream* input);\n  bool ParseFromCodedStream(io::CodedInputStream* input);\n  bool ParseFromZeroCopyStream(io::ZeroCopyInputStream* input);\n  bool ParseFromArray(const void* data, int size);\n  inline bool ParseFromString(const string& data) {\n    return ParseFromArray(data.data(), static_cast<int>(data.size()));\n  }\n\n  static const UnknownFieldSet* default_instance();\n private:\n  // For InternalMergeFrom\n  friend class UnknownField;\n  // Merges from other UnknownFieldSet. This method assumes, that this object\n  // is newly created and has fields_ == NULL;\n  void InternalMergeFrom(const UnknownFieldSet& other);\n  void ClearFallback();\n\n  // fields_ is either NULL, or a pointer to a vector that is *non-empty*. We\n  // never hold the empty vector because we want the 'do we have any unknown\n  // fields' check to be fast, and avoid a cache miss: the UFS instance gets\n  // embedded in the message object, so 'fields_ != NULL' tests a member\n  // variable hot in the cache, without the need to go touch a vector somewhere\n  // else in memory.\n  std::vector<UnknownField>* fields_;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(UnknownFieldSet);\n};\n\n// Represents one field in an UnknownFieldSet.\nclass LIBPROTOBUF_EXPORT UnknownField {\n public:\n  enum Type {\n    TYPE_VARINT,\n    TYPE_FIXED32,\n    TYPE_FIXED64,\n    TYPE_LENGTH_DELIMITED,\n    TYPE_GROUP\n  };\n\n  // The field's tag number, as seen on the wire.\n  inline int number() const;\n\n  // The field type.\n  inline Type type() const;\n\n  // Accessors -------------------------------------------------------\n  // Each method works only for UnknownFields of the corresponding type.\n\n  inline uint64 varint() const;\n  inline uint32 fixed32() const;\n  inline uint64 fixed64() const;\n  inline const string& length_delimited() const;\n  inline const UnknownFieldSet& group() const;\n\n  inline void set_varint(uint64 value);\n  inline void set_fixed32(uint32 value);\n  inline void set_fixed64(uint64 value);\n  inline void set_length_delimited(const string& value);\n  inline string* mutable_length_delimited();\n  inline UnknownFieldSet* mutable_group();\n\n  // Serialization API.\n  // These methods can take advantage of the underlying implementation and may\n  // archieve a better performance than using getters to retrieve the data and\n  // do the serialization yourself.\n  void SerializeLengthDelimitedNoTag(io::CodedOutputStream* output) const;\n  uint8* SerializeLengthDelimitedNoTagToArray(uint8* target) const;\n\n  inline int GetLengthDelimitedSize() const;\n\n private:\n  friend class UnknownFieldSet;\n\n  // If this UnknownField contains a pointer, delete it.\n  void Delete();\n\n  // Reset all the underlying pointers to NULL. A special function to be only\n  // used while merging from a temporary UFS.\n  void Reset();\n\n  // Make a deep copy of any pointers in this UnknownField.\n  void DeepCopy(const UnknownField& other);\n\n  // Set the wire type of this UnknownField. Should only be used when this\n  // UnknownField is being created.\n  inline void SetType(Type type);\n\n  union LengthDelimited {\n    string* string_value_;\n  };\n\n  uint32 number_;\n  uint32 type_;\n  union {\n    uint64 varint_;\n    uint32 fixed32_;\n    uint64 fixed64_;\n    mutable union LengthDelimited length_delimited_;\n    UnknownFieldSet* group_;\n  };\n};\n\n// ===================================================================\n// inline implementations\n\ninline UnknownFieldSet::UnknownFieldSet() : fields_(NULL) {}\n\ninline UnknownFieldSet::~UnknownFieldSet() { Clear(); }\n\ninline void UnknownFieldSet::ClearAndFreeMemory() { Clear(); }\n\ninline void UnknownFieldSet::Clear() {\n  if (fields_ != NULL) {\n    ClearFallback();\n  }\n}\n\ninline bool UnknownFieldSet::empty() const {\n  // Invariant: fields_ is never empty if present.\n  return !fields_;\n}\n\ninline void UnknownFieldSet::Swap(UnknownFieldSet* x) {\n  std::swap(fields_, x->fields_);\n}\n\ninline int UnknownFieldSet::field_count() const {\n  return fields_ ? static_cast<int>(fields_->size()) : 0;\n}\ninline const UnknownField& UnknownFieldSet::field(int index) const {\n  GOOGLE_DCHECK(fields_ != NULL);\n  return (*fields_)[index];\n}\ninline UnknownField* UnknownFieldSet::mutable_field(int index) {\n  return &(*fields_)[index];\n}\n\ninline void UnknownFieldSet::AddLengthDelimited(\n    int number, const string& value) {\n  AddLengthDelimited(number)->assign(value);\n}\n\n\ninline int UnknownField::number() const { return number_; }\ninline UnknownField::Type UnknownField::type() const {\n  return static_cast<Type>(type_);\n}\n\ninline uint64 UnknownField::varint() const {\n  assert(type() == TYPE_VARINT);\n  return varint_;\n}\ninline uint32 UnknownField::fixed32() const {\n  assert(type() == TYPE_FIXED32);\n  return fixed32_;\n}\ninline uint64 UnknownField::fixed64() const {\n  assert(type() == TYPE_FIXED64);\n  return fixed64_;\n}\ninline const string& UnknownField::length_delimited() const {\n  assert(type() == TYPE_LENGTH_DELIMITED);\n  return *length_delimited_.string_value_;\n}\ninline const UnknownFieldSet& UnknownField::group() const {\n  assert(type() == TYPE_GROUP);\n  return *group_;\n}\n\ninline void UnknownField::set_varint(uint64 value) {\n  assert(type() == TYPE_VARINT);\n  varint_ = value;\n}\ninline void UnknownField::set_fixed32(uint32 value) {\n  assert(type() == TYPE_FIXED32);\n  fixed32_ = value;\n}\ninline void UnknownField::set_fixed64(uint64 value) {\n  assert(type() == TYPE_FIXED64);\n  fixed64_ = value;\n}\ninline void UnknownField::set_length_delimited(const string& value) {\n  assert(type() == TYPE_LENGTH_DELIMITED);\n  length_delimited_.string_value_->assign(value);\n}\ninline string* UnknownField::mutable_length_delimited() {\n  assert(type() == TYPE_LENGTH_DELIMITED);\n  return length_delimited_.string_value_;\n}\ninline UnknownFieldSet* UnknownField::mutable_group() {\n  assert(type() == TYPE_GROUP);\n  return group_;\n}\n\ninline int UnknownField::GetLengthDelimitedSize() const {\n  GOOGLE_DCHECK_EQ(TYPE_LENGTH_DELIMITED, type());\n  return static_cast<int>(length_delimited_.string_value_->size());\n}\n\ninline void UnknownField::SetType(Type type) {\n  type_ = type;\n}\n\n\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UNKNOWN_FIELD_SET_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/unknown_field_set_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This test is testing a lot more than just the UnknownFieldSet class.  It\n// tests handling of unknown fields throughout the system.\n\n#include <google/protobuf/unknown_field_set.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/test_util.h>\n\n#include <google/protobuf/stubs/callback.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/mutex.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n#include <google/protobuf/stubs/stl_util.h>\n\nnamespace google {\nnamespace protobuf {\n\nusing internal::WireFormat;\n\nclass UnknownFieldSetTest : public testing::Test {\n protected:\n  virtual void SetUp() {\n    descriptor_ = unittest::TestAllTypes::descriptor();\n    TestUtil::SetAllFields(&all_fields_);\n    all_fields_.SerializeToString(&all_fields_data_);\n    ASSERT_TRUE(empty_message_.ParseFromString(all_fields_data_));\n    unknown_fields_ = empty_message_.mutable_unknown_fields();\n  }\n\n  const UnknownField* GetField(const string& name) {\n    const FieldDescriptor* field = descriptor_->FindFieldByName(name);\n    if (field == NULL) return NULL;\n    for (int i = 0; i < unknown_fields_->field_count(); i++) {\n      if (unknown_fields_->field(i).number() == field->number()) {\n        return &unknown_fields_->field(i);\n      }\n    }\n    return NULL;\n  }\n\n  // Constructs a protocol buffer which contains fields with all the same\n  // numbers as all_fields_data_ except that each field is some other wire\n  // type.\n  string GetBizarroData() {\n    unittest::TestEmptyMessage bizarro_message;\n    UnknownFieldSet* bizarro_unknown_fields =\n      bizarro_message.mutable_unknown_fields();\n    for (int i = 0; i < unknown_fields_->field_count(); i++) {\n      const UnknownField& unknown_field = unknown_fields_->field(i);\n      if (unknown_field.type() == UnknownField::TYPE_VARINT) {\n        bizarro_unknown_fields->AddFixed32(unknown_field.number(), 1);\n      } else {\n        bizarro_unknown_fields->AddVarint(unknown_field.number(), 1);\n      }\n    }\n\n    string data;\n    EXPECT_TRUE(bizarro_message.SerializeToString(&data));\n    return data;\n  }\n\n  const Descriptor* descriptor_;\n  unittest::TestAllTypes all_fields_;\n  string all_fields_data_;\n\n  // An empty message that has been parsed from all_fields_data_.  So, it has\n  // unknown fields of every type.\n  unittest::TestEmptyMessage empty_message_;\n  UnknownFieldSet* unknown_fields_;\n};\n\nnamespace {\n\nTEST_F(UnknownFieldSetTest, AllFieldsPresent) {\n  // All fields of TestAllTypes should be present, in numeric order (because\n  // that's the order we parsed them in).  Fields that are not valid field\n  // numbers of TestAllTypes should NOT be present.\n\n  int pos = 0;\n\n  for (int i = 0; i < 1000; i++) {\n    const FieldDescriptor* field = descriptor_->FindFieldByNumber(i);\n    if (field != NULL) {\n      ASSERT_LT(pos, unknown_fields_->field_count());\n      // Do not check oneof field if it is not set.\n      if (field->containing_oneof() == NULL) {\n        EXPECT_EQ(i, unknown_fields_->field(pos++).number());\n      } else if (i == unknown_fields_->field(pos).number()) {\n        pos++;\n      }\n      if (field->is_repeated()) {\n        // Should have a second instance.\n        ASSERT_LT(pos, unknown_fields_->field_count());\n        EXPECT_EQ(i, unknown_fields_->field(pos++).number());\n      }\n    }\n  }\n  EXPECT_EQ(unknown_fields_->field_count(), pos);\n}\n\nTEST_F(UnknownFieldSetTest, Varint) {\n  const UnknownField* field = GetField(\"optional_int32\");\n  ASSERT_TRUE(field != NULL);\n\n  ASSERT_EQ(UnknownField::TYPE_VARINT, field->type());\n  EXPECT_EQ(all_fields_.optional_int32(), field->varint());\n}\n\nTEST_F(UnknownFieldSetTest, Fixed32) {\n  const UnknownField* field = GetField(\"optional_fixed32\");\n  ASSERT_TRUE(field != NULL);\n\n  ASSERT_EQ(UnknownField::TYPE_FIXED32, field->type());\n  EXPECT_EQ(all_fields_.optional_fixed32(), field->fixed32());\n}\n\nTEST_F(UnknownFieldSetTest, Fixed64) {\n  const UnknownField* field = GetField(\"optional_fixed64\");\n  ASSERT_TRUE(field != NULL);\n\n  ASSERT_EQ(UnknownField::TYPE_FIXED64, field->type());\n  EXPECT_EQ(all_fields_.optional_fixed64(), field->fixed64());\n}\n\nTEST_F(UnknownFieldSetTest, LengthDelimited) {\n  const UnknownField* field = GetField(\"optional_string\");\n  ASSERT_TRUE(field != NULL);\n\n  ASSERT_EQ(UnknownField::TYPE_LENGTH_DELIMITED, field->type());\n  EXPECT_EQ(all_fields_.optional_string(), field->length_delimited());\n}\n\nTEST_F(UnknownFieldSetTest, Group) {\n  const UnknownField* field = GetField(\"optionalgroup\");\n  ASSERT_TRUE(field != NULL);\n\n  ASSERT_EQ(UnknownField::TYPE_GROUP, field->type());\n  ASSERT_EQ(1, field->group().field_count());\n\n  const UnknownField& nested_field = field->group().field(0);\n  const FieldDescriptor* nested_field_descriptor =\n    unittest::TestAllTypes::OptionalGroup::descriptor()->FindFieldByName(\"a\");\n  ASSERT_TRUE(nested_field_descriptor != NULL);\n\n  EXPECT_EQ(nested_field_descriptor->number(), nested_field.number());\n  ASSERT_EQ(UnknownField::TYPE_VARINT, nested_field.type());\n  EXPECT_EQ(all_fields_.optionalgroup().a(), nested_field.varint());\n}\n\nTEST_F(UnknownFieldSetTest, SerializeFastAndSlowAreEquivalent) {\n  int size = WireFormat::ComputeUnknownFieldsSize(\n      empty_message_.unknown_fields());\n  string slow_buffer;\n  string fast_buffer;\n  slow_buffer.resize(size);\n  fast_buffer.resize(size);\n\n  uint8* target = reinterpret_cast<uint8*>(string_as_array(&fast_buffer));\n  uint8* result = WireFormat::SerializeUnknownFieldsToArray(\n          empty_message_.unknown_fields(), target);\n  EXPECT_EQ(size, result - target);\n\n  {\n    io::ArrayOutputStream raw_stream(string_as_array(&slow_buffer), size, 1);\n    io::CodedOutputStream output_stream(&raw_stream);\n    WireFormat::SerializeUnknownFields(empty_message_.unknown_fields(),\n                                       &output_stream);\n    ASSERT_FALSE(output_stream.HadError());\n  }\n  EXPECT_TRUE(fast_buffer == slow_buffer);\n}\n\nTEST_F(UnknownFieldSetTest, Serialize) {\n  // Check that serializing the UnknownFieldSet produces the original data\n  // again.\n\n  string data;\n  empty_message_.SerializeToString(&data);\n\n  // Don't use EXPECT_EQ because we don't want to dump raw binary data to\n  // stdout.\n  EXPECT_TRUE(data == all_fields_data_);\n}\n\nTEST_F(UnknownFieldSetTest, ParseViaReflection) {\n  // Make sure fields are properly parsed to the UnknownFieldSet when parsing\n  // via reflection.\n\n  unittest::TestEmptyMessage message;\n  io::ArrayInputStream raw_input(all_fields_data_.data(),\n                                 all_fields_data_.size());\n  io::CodedInputStream input(&raw_input);\n  ASSERT_TRUE(WireFormat::ParseAndMergePartial(&input, &message));\n\n  EXPECT_EQ(message.DebugString(), empty_message_.DebugString());\n}\n\nTEST_F(UnknownFieldSetTest, SerializeViaReflection) {\n  // Make sure fields are properly written from the UnknownFieldSet when\n  // serializing via reflection.\n\n  string data;\n\n  {\n    io::StringOutputStream raw_output(&data);\n    io::CodedOutputStream output(&raw_output);\n    int size = WireFormat::ByteSize(empty_message_);\n    WireFormat::SerializeWithCachedSizes(empty_message_, size, &output);\n    ASSERT_FALSE(output.HadError());\n  }\n\n  // Don't use EXPECT_EQ because we don't want to dump raw binary data to\n  // stdout.\n  EXPECT_TRUE(data == all_fields_data_);\n}\n\nTEST_F(UnknownFieldSetTest, CopyFrom) {\n  unittest::TestEmptyMessage message;\n\n  message.CopyFrom(empty_message_);\n\n  EXPECT_EQ(empty_message_.DebugString(), message.DebugString());\n}\n\nTEST_F(UnknownFieldSetTest, Swap) {\n  unittest::TestEmptyMessage other_message;\n  ASSERT_TRUE(other_message.ParseFromString(GetBizarroData()));\n\n  EXPECT_GT(empty_message_.unknown_fields().field_count(), 0);\n  EXPECT_GT(other_message.unknown_fields().field_count(), 0);\n  const string debug_string = empty_message_.DebugString();\n  const string other_debug_string = other_message.DebugString();\n  EXPECT_NE(debug_string, other_debug_string);\n\n  empty_message_.Swap(&other_message);\n  EXPECT_EQ(debug_string, other_message.DebugString());\n  EXPECT_EQ(other_debug_string, empty_message_.DebugString());\n}\n\nTEST_F(UnknownFieldSetTest, SwapWithSelf) {\n  const string debug_string = empty_message_.DebugString();\n  EXPECT_GT(empty_message_.unknown_fields().field_count(), 0);\n\n  empty_message_.Swap(&empty_message_);\n  EXPECT_GT(empty_message_.unknown_fields().field_count(), 0);\n  EXPECT_EQ(debug_string, empty_message_.DebugString());\n}\n\nTEST_F(UnknownFieldSetTest, MergeFrom) {\n  unittest::TestEmptyMessage source, destination;\n\n  destination.mutable_unknown_fields()->AddVarint(1, 1);\n  destination.mutable_unknown_fields()->AddVarint(3, 2);\n  source.mutable_unknown_fields()->AddVarint(2, 3);\n  source.mutable_unknown_fields()->AddVarint(3, 4);\n\n  destination.MergeFrom(source);\n\n  EXPECT_EQ(\n    // Note:  The ordering of fields here depends on the ordering of adds\n    //   and merging, above.\n    \"1: 1\\n\"\n    \"3: 2\\n\"\n    \"2: 3\\n\"\n    \"3: 4\\n\",\n    destination.DebugString());\n}\n\n\nTEST_F(UnknownFieldSetTest, Clear) {\n  // Clear the set.\n  empty_message_.Clear();\n  EXPECT_EQ(0, unknown_fields_->field_count());\n}\n\nTEST_F(UnknownFieldSetTest, ClearAndFreeMemory) {\n  EXPECT_GT(unknown_fields_->field_count(), 0);\n  unknown_fields_->ClearAndFreeMemory();\n  EXPECT_EQ(0, unknown_fields_->field_count());\n  unknown_fields_->AddVarint(123456, 654321);\n  EXPECT_EQ(1, unknown_fields_->field_count());\n}\n\nTEST_F(UnknownFieldSetTest, ParseKnownAndUnknown) {\n  // Test mixing known and unknown fields when parsing.\n\n  unittest::TestEmptyMessage source;\n  source.mutable_unknown_fields()->AddVarint(123456, 654321);\n  string data;\n  ASSERT_TRUE(source.SerializeToString(&data));\n\n  unittest::TestAllTypes destination;\n  ASSERT_TRUE(destination.ParseFromString(all_fields_data_ + data));\n\n  TestUtil::ExpectAllFieldsSet(destination);\n  ASSERT_EQ(1, destination.unknown_fields().field_count());\n  ASSERT_EQ(UnknownField::TYPE_VARINT,\n            destination.unknown_fields().field(0).type());\n  EXPECT_EQ(654321, destination.unknown_fields().field(0).varint());\n}\n\nTEST_F(UnknownFieldSetTest, WrongTypeTreatedAsUnknown) {\n  // Test that fields of the wrong wire type are treated like unknown fields\n  // when parsing.\n\n  unittest::TestAllTypes all_types_message;\n  unittest::TestEmptyMessage empty_message;\n  string bizarro_data = GetBizarroData();\n  ASSERT_TRUE(all_types_message.ParseFromString(bizarro_data));\n  ASSERT_TRUE(empty_message.ParseFromString(bizarro_data));\n\n  // All fields should have been interpreted as unknown, so the debug strings\n  // should be the same.\n  EXPECT_EQ(empty_message.DebugString(), all_types_message.DebugString());\n}\n\nTEST_F(UnknownFieldSetTest, WrongTypeTreatedAsUnknownViaReflection) {\n  // Same as WrongTypeTreatedAsUnknown but via the reflection interface.\n\n  unittest::TestAllTypes all_types_message;\n  unittest::TestEmptyMessage empty_message;\n  string bizarro_data = GetBizarroData();\n  io::ArrayInputStream raw_input(bizarro_data.data(), bizarro_data.size());\n  io::CodedInputStream input(&raw_input);\n  ASSERT_TRUE(WireFormat::ParseAndMergePartial(&input, &all_types_message));\n  ASSERT_TRUE(empty_message.ParseFromString(bizarro_data));\n\n  EXPECT_EQ(empty_message.DebugString(), all_types_message.DebugString());\n}\n\nTEST_F(UnknownFieldSetTest, UnknownExtensions) {\n  // Make sure fields are properly parsed to the UnknownFieldSet even when\n  // they are declared as extension numbers.\n\n  unittest::TestEmptyMessageWithExtensions message;\n  ASSERT_TRUE(message.ParseFromString(all_fields_data_));\n\n  EXPECT_EQ(message.DebugString(), empty_message_.DebugString());\n}\n\nTEST_F(UnknownFieldSetTest, UnknownExtensionsReflection) {\n  // Same as UnknownExtensions except parsing via reflection.\n\n  unittest::TestEmptyMessageWithExtensions message;\n  io::ArrayInputStream raw_input(all_fields_data_.data(),\n                                 all_fields_data_.size());\n  io::CodedInputStream input(&raw_input);\n  ASSERT_TRUE(WireFormat::ParseAndMergePartial(&input, &message));\n\n  EXPECT_EQ(message.DebugString(), empty_message_.DebugString());\n}\n\nTEST_F(UnknownFieldSetTest, WrongExtensionTypeTreatedAsUnknown) {\n  // Test that fields of the wrong wire type are treated like unknown fields\n  // when parsing extensions.\n\n  unittest::TestAllExtensions all_extensions_message;\n  unittest::TestEmptyMessage empty_message;\n  string bizarro_data = GetBizarroData();\n  ASSERT_TRUE(all_extensions_message.ParseFromString(bizarro_data));\n  ASSERT_TRUE(empty_message.ParseFromString(bizarro_data));\n\n  // All fields should have been interpreted as unknown, so the debug strings\n  // should be the same.\n  EXPECT_EQ(empty_message.DebugString(), all_extensions_message.DebugString());\n}\n\nTEST_F(UnknownFieldSetTest, UnknownEnumValue) {\n  using unittest::TestAllTypes;\n  using unittest::TestAllExtensions;\n  using unittest::TestEmptyMessage;\n\n  const FieldDescriptor* singular_field =\n    TestAllTypes::descriptor()->FindFieldByName(\"optional_nested_enum\");\n  const FieldDescriptor* repeated_field =\n    TestAllTypes::descriptor()->FindFieldByName(\"repeated_nested_enum\");\n  ASSERT_TRUE(singular_field != NULL);\n  ASSERT_TRUE(repeated_field != NULL);\n\n  string data;\n\n  {\n    TestEmptyMessage empty_message;\n    UnknownFieldSet* unknown_fields = empty_message.mutable_unknown_fields();\n    unknown_fields->AddVarint(singular_field->number(), TestAllTypes::BAR);\n    unknown_fields->AddVarint(singular_field->number(), 5);  // not valid\n    unknown_fields->AddVarint(repeated_field->number(), TestAllTypes::FOO);\n    unknown_fields->AddVarint(repeated_field->number(), 4);  // not valid\n    unknown_fields->AddVarint(repeated_field->number(), TestAllTypes::BAZ);\n    unknown_fields->AddVarint(repeated_field->number(), 6);  // not valid\n    empty_message.SerializeToString(&data);\n  }\n\n  {\n    TestAllTypes message;\n    ASSERT_TRUE(message.ParseFromString(data));\n    EXPECT_EQ(TestAllTypes::BAR, message.optional_nested_enum());\n    ASSERT_EQ(2, message.repeated_nested_enum_size());\n    EXPECT_EQ(TestAllTypes::FOO, message.repeated_nested_enum(0));\n    EXPECT_EQ(TestAllTypes::BAZ, message.repeated_nested_enum(1));\n\n    const UnknownFieldSet& unknown_fields = message.unknown_fields();\n    ASSERT_EQ(3, unknown_fields.field_count());\n\n    EXPECT_EQ(singular_field->number(), unknown_fields.field(0).number());\n    ASSERT_EQ(UnknownField::TYPE_VARINT, unknown_fields.field(0).type());\n    EXPECT_EQ(5, unknown_fields.field(0).varint());\n\n    EXPECT_EQ(repeated_field->number(), unknown_fields.field(1).number());\n    ASSERT_EQ(UnknownField::TYPE_VARINT, unknown_fields.field(1).type());\n    EXPECT_EQ(4, unknown_fields.field(1).varint());\n\n    EXPECT_EQ(repeated_field->number(), unknown_fields.field(2).number());\n    ASSERT_EQ(UnknownField::TYPE_VARINT, unknown_fields.field(2).type());\n    EXPECT_EQ(6, unknown_fields.field(2).varint());\n  }\n\n  {\n    using unittest::optional_nested_enum_extension;\n    using unittest::repeated_nested_enum_extension;\n\n    TestAllExtensions message;\n    ASSERT_TRUE(message.ParseFromString(data));\n    EXPECT_EQ(TestAllTypes::BAR,\n              message.GetExtension(optional_nested_enum_extension));\n    ASSERT_EQ(2, message.ExtensionSize(repeated_nested_enum_extension));\n    EXPECT_EQ(TestAllTypes::FOO,\n              message.GetExtension(repeated_nested_enum_extension, 0));\n    EXPECT_EQ(TestAllTypes::BAZ,\n              message.GetExtension(repeated_nested_enum_extension, 1));\n\n    const UnknownFieldSet& unknown_fields = message.unknown_fields();\n    ASSERT_EQ(3, unknown_fields.field_count());\n\n    EXPECT_EQ(singular_field->number(), unknown_fields.field(0).number());\n    ASSERT_EQ(UnknownField::TYPE_VARINT, unknown_fields.field(0).type());\n    EXPECT_EQ(5, unknown_fields.field(0).varint());\n\n    EXPECT_EQ(repeated_field->number(), unknown_fields.field(1).number());\n    ASSERT_EQ(UnknownField::TYPE_VARINT, unknown_fields.field(1).type());\n    EXPECT_EQ(4, unknown_fields.field(1).varint());\n\n    EXPECT_EQ(repeated_field->number(), unknown_fields.field(2).number());\n    ASSERT_EQ(UnknownField::TYPE_VARINT, unknown_fields.field(2).type());\n    EXPECT_EQ(6, unknown_fields.field(2).varint());\n  }\n}\n\nTEST_F(UnknownFieldSetTest, SpaceUsedExcludingSelf) {\n  UnknownFieldSet empty;\n  empty.AddVarint(1, 0);\n  EXPECT_EQ(sizeof(vector<UnknownField>) + sizeof(UnknownField),\n            empty.SpaceUsedExcludingSelf());\n}\n\nTEST_F(UnknownFieldSetTest, SpaceUsed) {\n  unittest::TestEmptyMessage empty_message;\n\n  // Make sure an unknown field set has zero space used until a field is\n  // actually added.\n  int base_size = empty_message.SpaceUsed();\n  UnknownFieldSet* unknown_fields = empty_message.mutable_unknown_fields();\n  EXPECT_EQ(base_size, empty_message.SpaceUsed());\n\n  // Make sure each thing we add to the set increases the SpaceUsed().\n  unknown_fields->AddVarint(1, 0);\n  EXPECT_LT(base_size, empty_message.SpaceUsed());\n  base_size = empty_message.SpaceUsed();\n\n  string* str = unknown_fields->AddLengthDelimited(1);\n  EXPECT_LT(base_size, empty_message.SpaceUsed());\n  base_size = empty_message.SpaceUsed();\n\n  str->assign(sizeof(string) + 1, 'x');\n  EXPECT_LT(base_size, empty_message.SpaceUsed());\n  base_size = empty_message.SpaceUsed();\n\n  UnknownFieldSet* group = unknown_fields->AddGroup(1);\n  EXPECT_LT(base_size, empty_message.SpaceUsed());\n  base_size = empty_message.SpaceUsed();\n\n  group->AddVarint(1, 0);\n  EXPECT_LT(base_size, empty_message.SpaceUsed());\n}\n\n\nTEST_F(UnknownFieldSetTest, Empty) {\n  UnknownFieldSet unknown_fields;\n  EXPECT_TRUE(unknown_fields.empty());\n  unknown_fields.AddVarint(6, 123);\n  EXPECT_FALSE(unknown_fields.empty());\n  unknown_fields.Clear();\n  EXPECT_TRUE(unknown_fields.empty());\n}\n\nTEST_F(UnknownFieldSetTest, DeleteSubrange) {\n  // Exhaustively test the deletion of every possible subrange in arrays of all\n  // sizes from 0 through 9.\n  for (int size = 0; size < 10; ++size) {\n    for (int num = 0; num <= size; ++num) {\n      for (int start = 0; start < size - num; ++start) {\n        // Create a set with \"size\" fields.\n        UnknownFieldSet unknown;\n        for (int i = 0; i < size; ++i) {\n          unknown.AddFixed32(i, i);\n        }\n        // Delete the specified subrange.\n        unknown.DeleteSubrange(start, num);\n        // Make sure the resulting field values are still correct.\n        EXPECT_EQ(size - num, unknown.field_count());\n        for (int i = 0; i < unknown.field_count(); ++i) {\n          if (i < start) {\n            EXPECT_EQ(i, unknown.field(i).fixed32());\n          } else {\n            EXPECT_EQ(i + num, unknown.field(i).fixed32());\n          }\n        }\n      }\n    }\n  }\n}\n\nvoid CheckDeleteByNumber(const vector<int>& field_numbers, int deleted_number,\n                        const vector<int>& expected_field_nubmers) {\n  UnknownFieldSet unknown_fields;\n  for (int i = 0; i < field_numbers.size(); ++i) {\n    unknown_fields.AddFixed32(field_numbers[i], i);\n  }\n  unknown_fields.DeleteByNumber(deleted_number);\n  ASSERT_EQ(expected_field_nubmers.size(), unknown_fields.field_count());\n  for (int i = 0; i < expected_field_nubmers.size(); ++i) {\n    EXPECT_EQ(expected_field_nubmers[i],\n              unknown_fields.field(i).number());\n  }\n}\n\n#define MAKE_VECTOR(x) vector<int>(x, x + GOOGLE_ARRAYSIZE(x))\nTEST_F(UnknownFieldSetTest, DeleteByNumber) {\n  CheckDeleteByNumber(vector<int>(), 1, vector<int>());\n  static const int kTestFieldNumbers1[] = {1, 2, 3};\n  static const int kFieldNumberToDelete1 = 1;\n  static const int kExpectedFieldNumbers1[] = {2, 3};\n  CheckDeleteByNumber(MAKE_VECTOR(kTestFieldNumbers1), kFieldNumberToDelete1,\n                      MAKE_VECTOR(kExpectedFieldNumbers1));\n  static const int kTestFieldNumbers2[] = {1, 2, 3};\n  static const int kFieldNumberToDelete2 = 2;\n  static const int kExpectedFieldNumbers2[] = {1, 3};\n  CheckDeleteByNumber(MAKE_VECTOR(kTestFieldNumbers2), kFieldNumberToDelete2,\n                      MAKE_VECTOR(kExpectedFieldNumbers2));\n  static const int kTestFieldNumbers3[] = {1, 2, 3};\n  static const int kFieldNumberToDelete3 = 3;\n  static const int kExpectedFieldNumbers3[] = {1, 2};\n  CheckDeleteByNumber(MAKE_VECTOR(kTestFieldNumbers3), kFieldNumberToDelete3,\n                      MAKE_VECTOR(kExpectedFieldNumbers3));\n  static const int kTestFieldNumbers4[] = {1, 2, 1, 4, 1};\n  static const int kFieldNumberToDelete4 = 1;\n  static const int kExpectedFieldNumbers4[] = {2, 4};\n  CheckDeleteByNumber(MAKE_VECTOR(kTestFieldNumbers4), kFieldNumberToDelete4,\n                      MAKE_VECTOR(kExpectedFieldNumbers4));\n  static const int kTestFieldNumbers5[] = {1, 2, 3, 4, 5};\n  static const int kFieldNumberToDelete5 = 6;\n  static const int kExpectedFieldNumbers5[] = {1, 2, 3, 4, 5};\n  CheckDeleteByNumber(MAKE_VECTOR(kTestFieldNumbers5), kFieldNumberToDelete5,\n                      MAKE_VECTOR(kExpectedFieldNumbers5));\n}\n#undef MAKE_VECTOR\n}  // namespace\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/field_comparator.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: ksroka@google.com (Krzysztof Sroka)\n\n#include <google/protobuf/util/field_comparator.h>\n\n#include <string>\n\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/stubs/map_util.h>\n#include <google/protobuf/stubs/mathlimits.h>\n#include <google/protobuf/stubs/mathutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\n\nFieldComparator::FieldComparator() {}\nFieldComparator::~FieldComparator() {}\n\nDefaultFieldComparator::DefaultFieldComparator()\n    : float_comparison_(EXACT),\n      treat_nan_as_equal_(false),\n      has_default_tolerance_(false) {\n}\n\nDefaultFieldComparator::~DefaultFieldComparator() {}\n\nFieldComparator::ComparisonResult DefaultFieldComparator::Compare(\n      const google::protobuf::Message& message_1,\n      const google::protobuf::Message& message_2,\n      const google::protobuf::FieldDescriptor* field,\n      int index_1, int index_2,\n      const google::protobuf::util::FieldContext* field_context) {\n  const Reflection* reflection_1 = message_1.GetReflection();\n  const Reflection* reflection_2 = message_2.GetReflection();\n\n  switch (field->cpp_type()) {\n#define COMPARE_FIELD(METHOD)                                              \\\n    if (field->is_repeated()) {                                            \\\n      return ResultFromBoolean(Compare##METHOD(                            \\\n          *field,                                                          \\\n          reflection_1->GetRepeated##METHOD(message_1, field, index_1),    \\\n          reflection_2->GetRepeated##METHOD(message_2, field, index_2)));  \\\n    } else {                                                               \\\n      return ResultFromBoolean(Compare##METHOD(                            \\\n          *field,                                                          \\\n          reflection_1->Get##METHOD(message_1, field),                     \\\n          reflection_2->Get##METHOD(message_2, field)));                   \\\n    }                                                                      \\\n    break;  // Make sure no fall-through is introduced.\n\n    case FieldDescriptor::CPPTYPE_BOOL:\n      COMPARE_FIELD(Bool);\n    case FieldDescriptor::CPPTYPE_DOUBLE:\n      COMPARE_FIELD(Double);\n    case FieldDescriptor::CPPTYPE_ENUM:\n      COMPARE_FIELD(Enum);\n    case FieldDescriptor::CPPTYPE_FLOAT:\n      COMPARE_FIELD(Float);\n    case FieldDescriptor::CPPTYPE_INT32:\n      COMPARE_FIELD(Int32);\n    case FieldDescriptor::CPPTYPE_INT64:\n      COMPARE_FIELD(Int64);\n    case FieldDescriptor::CPPTYPE_STRING:\n      if (field->is_repeated()) {\n        // Allocate scratch strings to store the result if a conversion is\n        // needed.\n        string scratch1;\n        string scratch2;\n        return ResultFromBoolean(\n            CompareString(*field, reflection_1->GetRepeatedStringReference(\n                                      message_1, field, index_1, &scratch1),\n                          reflection_2->GetRepeatedStringReference(\n                              message_2, field, index_2, &scratch2)));\n      } else {\n        // Allocate scratch strings to store the result if a conversion is\n        // needed.\n        string scratch1;\n        string scratch2;\n        return ResultFromBoolean(CompareString(\n            *field,\n            reflection_1->GetStringReference(message_1, field, &scratch1),\n            reflection_2->GetStringReference(message_2, field, &scratch2)));\n      }\n      break;\n    case FieldDescriptor::CPPTYPE_UINT32:\n      COMPARE_FIELD(UInt32);\n    case FieldDescriptor::CPPTYPE_UINT64:\n      COMPARE_FIELD(UInt64);\n\n#undef COMPARE_FIELD\n\n    case FieldDescriptor::CPPTYPE_MESSAGE:\n      return RECURSE;\n\n    default:\n      GOOGLE_LOG(FATAL) << \"No comparison code for field \" << field->full_name()\n                 << \" of CppType = \" << field->cpp_type();\n      return DIFFERENT;\n  }\n}\n\nvoid DefaultFieldComparator::SetDefaultFractionAndMargin(double fraction,\n                                                         double margin) {\n  default_tolerance_ = Tolerance(fraction, margin);\n  has_default_tolerance_ = true;\n}\n\nvoid DefaultFieldComparator::SetFractionAndMargin(const FieldDescriptor* field,\n                                                  double fraction,\n                                                  double margin) {\n  GOOGLE_CHECK(FieldDescriptor::CPPTYPE_FLOAT == field->cpp_type() ||\n        FieldDescriptor::CPPTYPE_DOUBLE == field->cpp_type())\n      << \"Field has to be float or double type. Field name is: \"\n      << field->full_name();\n  map_tolerance_[field] = Tolerance(fraction, margin);\n}\n\nbool DefaultFieldComparator::CompareDouble(const FieldDescriptor& field,\n                                           double value_1, double value_2) {\n  return CompareDoubleOrFloat(field, value_1, value_2);\n}\n\nbool DefaultFieldComparator::CompareEnum(const FieldDescriptor& field,\n                                         const EnumValueDescriptor* value_1,\n                                         const EnumValueDescriptor* value_2) {\n  return value_1->number() == value_2->number();\n}\n\nbool DefaultFieldComparator::CompareFloat(const FieldDescriptor& field,\n                                          float value_1, float value_2) {\n  return CompareDoubleOrFloat(field, value_1, value_2);\n}\n\ntemplate<typename T>\nbool DefaultFieldComparator::CompareDoubleOrFloat(const FieldDescriptor& field,\n                                                  T value_1, T value_2) {\n  if (value_1 == value_2) {\n    // Covers +inf and -inf (which are not within margin or fraction of\n    // themselves), and is a shortcut for finite values.\n    return true;\n  } else if (float_comparison_ == EXACT) {\n    if (treat_nan_as_equal_ &&\n        MathLimits<T>::IsNaN(value_1) && MathLimits<T>::IsNaN(value_2)) {\n      return true;\n    }\n    return false;\n  } else {\n    if (treat_nan_as_equal_ &&\n        MathLimits<T>::IsNaN(value_1) && MathLimits<T>::IsNaN(value_2)) {\n      return true;\n    }\n    // float_comparison_ == APPROXIMATE covers two use cases.\n    Tolerance* tolerance = FindOrNull(map_tolerance_, &field);\n    if (tolerance == NULL && has_default_tolerance_) {\n      tolerance = &default_tolerance_;\n    }\n    if (tolerance == NULL) {\n      return MathUtil::AlmostEquals(value_1, value_2);\n    } else {\n      // Use user-provided fraction and margin. Since they are stored as\n      // doubles, we explicitly cast them to types of values provided. This\n      // is very likely to fail if provided values are not numeric.\n      return MathUtil::WithinFractionOrMargin(\n          value_1, value_2, static_cast<T>(tolerance->fraction),\n          static_cast<T>(tolerance->margin));\n    }\n  }\n}\n\nFieldComparator::ComparisonResult DefaultFieldComparator::ResultFromBoolean(\n    bool boolean_result) const {\n  return boolean_result ? FieldComparator::SAME : FieldComparator::DIFFERENT;\n}\n\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/field_comparator.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: ksroka@google.com (Krzysztof Sroka)\n\n#ifndef GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__\n#define GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__\n\n#include <map>\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\n\nclass Message;\nclass EnumValueDescriptor;\nclass FieldDescriptor;\n\nnamespace util {\n\nclass FieldContext;\n\n// Base class specifying the interface for comparing protocol buffer fields.\n// Regular users should consider using or subclassing DefaultFieldComparator\n// rather than this interface.\n// Currently, this does not support comparing unknown fields.\nclass LIBPROTOBUF_EXPORT FieldComparator {\n public:\n  FieldComparator();\n  virtual ~FieldComparator();\n\n  enum ComparisonResult {\n    SAME,       // Compared fields are equal. In case of comparing submessages,\n                // user should not recursively compare their contents.\n    DIFFERENT,  // Compared fields are different. In case of comparing\n                // submessages, user should not recursively compare their\n                // contents.\n    RECURSE,    // Compared submessages need to be compared recursively.\n                // FieldComparator does not specify the semantics of recursive\n                // comparison. This value should not be returned for simple\n                // values.\n  };\n\n  // Compares the values of a field in two protocol buffer messages.\n  // Returns SAME or DIFFERENT for simple values, and SAME, DIFFERENT or RECURSE\n  // for submessages. Returning RECURSE for fields not being submessages is\n  // illegal.\n  // In case the given FieldDescriptor points to a repeated field, the indices\n  // need to be valid. Otherwise they should be ignored.\n  //\n  // FieldContext contains information about the specific instances of the\n  // fields being compared, versus FieldDescriptor which only contains general\n  // type information about the fields.\n  virtual ComparisonResult Compare(\n      const google::protobuf::Message& message_1,\n      const google::protobuf::Message& message_2,\n      const google::protobuf::FieldDescriptor* field,\n      int index_1, int index_2,\n      const google::protobuf::util::FieldContext* field_context) = 0;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldComparator);\n};\n\n// Basic implementation of FieldComparator.  Supports three modes of floating\n// point value comparison: exact, approximate using MathUtil::AlmostEqual\n// method, and arbitrarily precise using MathUtil::WithinFractionOrMargin.\nclass LIBPROTOBUF_EXPORT DefaultFieldComparator : public FieldComparator {\n public:\n  enum FloatComparison {\n     EXACT,               // Floats and doubles are compared exactly.\n     APPROXIMATE,         // Floats and doubles are compared using the\n                          // MathUtil::AlmostEqual method or\n                          // MathUtil::WithinFractionOrMargin method.\n     // TODO(ksroka): Introduce third value to differenciate uses of AlmostEqual\n     //               and WithinFractionOrMargin.\n  };\n\n  // Creates new comparator with float comparison set to EXACT.\n  DefaultFieldComparator();\n\n  virtual ~DefaultFieldComparator();\n\n  virtual ComparisonResult Compare(\n      const google::protobuf::Message& message_1,\n      const google::protobuf::Message& message_2,\n      const google::protobuf::FieldDescriptor* field,\n      int index_1, int index_2,\n      const google::protobuf::util::FieldContext* field_context);\n\n  void set_float_comparison(FloatComparison float_comparison) {\n    float_comparison_ = float_comparison;\n  }\n\n  FloatComparison float_comparison() const {\n    return float_comparison_;\n  }\n\n  // Set whether the FieldComparator shall treat floats or doubles that are both\n  // NaN as equal (treat_nan_as_equal = true) or as different\n  // (treat_nan_as_equal = false). Default is treating NaNs always as different.\n  void set_treat_nan_as_equal(bool treat_nan_as_equal) {\n    treat_nan_as_equal_ = treat_nan_as_equal;\n  }\n\n  bool treat_nan_as_equal() const {\n    return treat_nan_as_equal_;\n  }\n\n  // Sets the fraction and margin for the float comparison of a given field.\n  // Uses MathUtil::WithinFractionOrMargin to compare the values.\n  //\n  // REQUIRES: field->cpp_type == FieldDescriptor::CPPTYPE_DOUBLE or\n  //           field->cpp_type == FieldDescriptor::CPPTYPE_FLOAT\n  // REQUIRES: float_comparison_ == APPROXIMATE\n  void SetFractionAndMargin(const FieldDescriptor* field, double fraction,\n                            double margin);\n\n  // Sets the fraction and margin for the float comparison of all float and\n  // double fields, unless a field has been given a specific setting via\n  // SetFractionAndMargin() above.\n  // Uses MathUtil::WithinFractionOrMargin to compare the values.\n  //\n  // REQUIRES: float_comparison_ == APPROXIMATE\n  void SetDefaultFractionAndMargin(double fraction, double margin);\n\n private:\n  // Defines the tolerance for floating point comparison (fraction and margin).\n  struct Tolerance {\n    double fraction;\n    double margin;\n    Tolerance()\n        : fraction(0.0),\n          margin(0.0) {}\n    Tolerance(double f, double m)\n        : fraction(f),\n          margin(m) {}\n  };\n\n  // Defines the map to store the tolerances for floating point comparison.\n  typedef map<const FieldDescriptor*, Tolerance> ToleranceMap;\n\n  // The following methods get executed when CompareFields is called for the\n  // basic types (instead of submessages). They return true on success. One\n  // can use ResultFromBoolean() to convert that boolean to a ComparisonResult\n  // value.\n  bool CompareBool(const google::protobuf::FieldDescriptor& field,\n                   bool value_1, bool value_2) {\n    return value_1 == value_2;\n  }\n\n  // Uses CompareDoubleOrFloat, a helper function used by both CompareDouble and\n  // CompareFloat.\n  bool CompareDouble(const google::protobuf::FieldDescriptor& field,\n                     double value_1, double value_2);\n\n  bool CompareEnum(const google::protobuf::FieldDescriptor& field,\n                   const EnumValueDescriptor* value_1,\n                   const EnumValueDescriptor* value_2);\n\n  // Uses CompareDoubleOrFloat, a helper function used by both CompareDouble and\n  // CompareFloat.\n  bool CompareFloat(const google::protobuf::FieldDescriptor& field,\n                    float value_1, float value_2);\n\n  bool CompareInt32(const google::protobuf::FieldDescriptor& field,\n                    int32 value_1, int32 value_2) {\n    return value_1 == value_2;\n  }\n\n  bool CompareInt64(const google::protobuf::FieldDescriptor& field,\n                    int64 value_1, int64 value_2) {\n    return value_1 == value_2;\n  }\n\n  bool CompareString(const google::protobuf::FieldDescriptor& field,\n                     const string& value_1, const string& value_2) {\n    return value_1 == value_2;\n  }\n\n  bool CompareUInt32(const google::protobuf::FieldDescriptor& field,\n                     uint32 value_1, uint32 value_2) {\n    return value_1 == value_2;\n  }\n\n  bool CompareUInt64(const google::protobuf::FieldDescriptor& field,\n                     uint64 value_1, uint64 value_2) {\n    return value_1 == value_2;\n  }\n\n  // This function is used by CompareDouble and CompareFloat to avoid code\n  // duplication. There are no checks done against types of the values passed,\n  // but it's likely to fail if passed non-numeric arguments.\n  template<typename T>\n  bool CompareDoubleOrFloat(const google::protobuf::FieldDescriptor& field,\n                            T value_1, T value_2);\n\n  // Returns FieldComparator::SAME if boolean_result is true and\n  // FieldComparator::DIFFERENT otherwise.\n  ComparisonResult ResultFromBoolean(bool boolean_result) const;\n\n  FloatComparison float_comparison_;\n\n  // If true, floats and doubles that are both NaN are considered to be\n  // equal. Otherwise, two floats or doubles that are NaN are considered to be\n  // different.\n  bool treat_nan_as_equal_;\n\n  // True iff default_tolerance_ has been explicitly set.\n  //\n  // If false, then the default tolerance for flaots and doubles is that which\n  // is used by MathUtil::AlmostEquals().\n  bool has_default_tolerance_;\n\n  // Default float/double tolerance. Only meaningful if\n  // has_default_tolerance_ == true.\n  Tolerance default_tolerance_;\n\n  // Field-specific float/double tolerances, which override any default for\n  // those particular fields.\n  ToleranceMap map_tolerance_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DefaultFieldComparator);\n};\n\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_FIELD_COMPARATOR_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/field_comparator_test.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: ksroka@google.com (Krzysztof Sroka)\n\n#include <google/protobuf/util/field_comparator.h>\n\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/stubs/mathutil.h>\n// This gtest header is put after mathutil.h intentionally. We have to do\n// this because mathutil.h includes mathlimits.h which requires cmath not\n// being included to compile on some versions of gcc:\n//   https://github.com/google/protobuf/blob/818c5eee08840355d70d2f3bdf1a2f17986a5e70/src/google/protobuf/stubs/mathlimits.h#L48\n// and the opensource version gtest.h header includes cmath transitively\n// somehow.\n#include <gtest/gtest.h>\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace {\n\nusing protobuf_unittest::TestAllTypes;\n\nclass DefaultFieldComparatorTest : public ::testing::Test {\n protected:\n  void SetUp() {\n    descriptor_ = TestAllTypes::descriptor();\n  }\n\n  const Descriptor* descriptor_;\n  DefaultFieldComparator comparator_;\n  TestAllTypes message_1_;\n  TestAllTypes message_2_;\n};\n\nTEST_F(DefaultFieldComparatorTest, RecursesIntoGroup) {\n  const FieldDescriptor* field =\n      descriptor_->FindFieldByName(\"optionalgroup\");\n  EXPECT_EQ(FieldComparator::RECURSE,\n            comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL));\n}\n\nTEST_F(DefaultFieldComparatorTest, RecursesIntoNestedMessage) {\n  const FieldDescriptor* field =\n      descriptor_->FindFieldByName(\"optional_nested_message\");\n  EXPECT_EQ(FieldComparator::RECURSE,\n            comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL));\n}\n\nTEST_F(DefaultFieldComparatorTest, RecursesIntoForeignMessage) {\n  const FieldDescriptor* field =\n      descriptor_->FindFieldByName(\"optional_foreign_message\");\n  EXPECT_EQ(FieldComparator::RECURSE,\n            comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL));\n}\n\nTEST_F(DefaultFieldComparatorTest, Int32Comparison) {\n  const FieldDescriptor* field = descriptor_->FindFieldByName(\"optional_int32\");\n  message_1_.set_optional_int32(1);\n  message_2_.set_optional_int32(1);\n\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL));\n\n  message_2_.set_optional_int32(-1);\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL));\n}\n\nTEST_F(DefaultFieldComparatorTest, Int64Comparison) {\n  const FieldDescriptor* field = descriptor_->FindFieldByName(\"optional_int64\");\n  message_1_.set_optional_int64(1L);\n  message_2_.set_optional_int64(1L);\n\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL));\n\n  message_2_.set_optional_int64(-1L);\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL));\n}\n\nTEST_F(DefaultFieldComparatorTest, UInt32Comparison) {\n  const FieldDescriptor* field =\n      descriptor_->FindFieldByName(\"optional_uint32\");\n  message_1_.set_optional_uint32(1);\n  message_2_.set_optional_uint32(1);\n\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL));\n\n  message_2_.set_optional_uint32(2);\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL));\n}\n\nTEST_F(DefaultFieldComparatorTest, UInt64Comparison) {\n  const FieldDescriptor* field =\n      descriptor_->FindFieldByName(\"optional_uint64\");\n  message_1_.set_optional_uint64(1L);\n  message_2_.set_optional_uint64(1L);\n\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL));\n\n  message_2_.set_optional_uint64(2L);\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL));\n}\n\nTEST_F(DefaultFieldComparatorTest, BooleanComparison) {\n  const FieldDescriptor* field =\n      descriptor_->FindFieldByName(\"optional_bool\");\n  message_1_.set_optional_bool(true);\n  message_2_.set_optional_bool(true);\n\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL));\n\n  message_2_.set_optional_bool(false);\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL));\n}\n\nTEST_F(DefaultFieldComparatorTest, EnumComparison) {\n  const FieldDescriptor* field =\n      descriptor_->FindFieldByName(\"optional_nested_enum\");\n  message_1_.set_optional_nested_enum(TestAllTypes::BAR);\n  message_2_.set_optional_nested_enum(TestAllTypes::BAR);\n\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL));\n\n  message_2_.set_optional_nested_enum(TestAllTypes::BAZ);\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL));\n}\n\nTEST_F(DefaultFieldComparatorTest, StringComparison) {\n  const FieldDescriptor* field =\n      descriptor_->FindFieldByName(\"optional_string\");\n  message_1_.set_optional_string(\"foo\");\n  message_2_.set_optional_string(\"foo\");\n\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL));\n\n  message_2_.set_optional_string(\"bar\");\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_, field, -1, -1, NULL));\n}\n\nTEST_F(DefaultFieldComparatorTest, FloatingPointComparisonExact) {\n  const FieldDescriptor* field_float =\n      descriptor_->FindFieldByName(\"optional_float\");\n  const FieldDescriptor* field_double =\n      descriptor_->FindFieldByName(\"optional_double\");\n\n  message_1_.set_optional_float(0.1f);\n  message_2_.set_optional_float(0.1f);\n  message_1_.set_optional_double(0.1);\n  message_2_.set_optional_double(0.1);\n\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_,\n                                field_float, -1, -1, NULL));\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_,\n                                field_double, -1, -1, NULL));\n\n  message_2_.set_optional_float(0.2f);\n  message_2_.set_optional_double(0.2);\n\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_,\n                                field_float, -1, -1, NULL));\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_,\n                                field_double, -1, -1, NULL));\n}\n\nTEST_F(DefaultFieldComparatorTest, FloatingPointComparisonApproximate) {\n  const FieldDescriptor* field_float =\n      descriptor_->FindFieldByName(\"optional_float\");\n  const FieldDescriptor* field_double =\n      descriptor_->FindFieldByName(\"optional_double\");\n\n  message_1_.set_optional_float(2.300005f);\n  message_2_.set_optional_float(2.300006f);\n  message_1_.set_optional_double(2.3000000000000003);\n  message_2_.set_optional_double(2.3000000000000007);\n\n  // Approximate comparison depends on MathUtil, so we assert on MathUtil\n  // results first to check if that's where the failure was introduced.\n  ASSERT_NE(message_1_.optional_float(), message_2_.optional_float());\n  ASSERT_NE(message_1_.optional_double(), message_2_.optional_double());\n  ASSERT_TRUE(MathUtil::AlmostEquals(message_1_.optional_float(),\n                                     message_2_.optional_float()));\n  ASSERT_TRUE(MathUtil::AlmostEquals(message_1_.optional_double(),\n                                     message_2_.optional_double()));\n\n  // DefaultFieldComparator's default float comparison mode is EXACT.\n  ASSERT_EQ(DefaultFieldComparator::EXACT, comparator_.float_comparison());\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_,\n                                field_float, -1, -1, NULL));\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_,\n                                field_double, -1, -1, NULL));\n\n  comparator_.set_float_comparison(DefaultFieldComparator::APPROXIMATE);\n\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_,\n                                field_float, -1, -1, NULL));\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_,\n                                field_double, -1, -1, NULL));\n}\n\nTEST_F(DefaultFieldComparatorTest, FloatingPointComparisonTreatNaNsAsEqual) {\n  const FieldDescriptor* field_float =\n      descriptor_->FindFieldByName(\"optional_float\");\n  const FieldDescriptor* field_double =\n      descriptor_->FindFieldByName(\"optional_double\");\n\n  message_1_.set_optional_float(MathLimits<float>::kNaN);\n  message_2_.set_optional_float(MathLimits<float>::kNaN);\n  message_1_.set_optional_double(MathLimits<double>::kNaN);\n  message_2_.set_optional_double(MathLimits<double>::kNaN);\n\n  // DefaultFieldComparator's default float comparison mode is EXACT with\n  // treating NaNs as different.\n  ASSERT_EQ(DefaultFieldComparator::EXACT, comparator_.float_comparison());\n  ASSERT_EQ(false, comparator_.treat_nan_as_equal());\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_,\n                                field_float, -1, -1, NULL));\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_,\n                                field_double, -1, -1, NULL));\n  comparator_.set_float_comparison(DefaultFieldComparator::APPROXIMATE);\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_,\n                                field_float, -1, -1, NULL));\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_,\n                                field_double, -1, -1, NULL));\n\n  comparator_.set_treat_nan_as_equal(true);\n  ASSERT_EQ(true, comparator_.treat_nan_as_equal());\n  comparator_.set_float_comparison(DefaultFieldComparator::EXACT);\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_,\n                                field_float, -1, -1, NULL));\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_,\n                                field_double, -1, -1, NULL));\n  comparator_.set_float_comparison(DefaultFieldComparator::APPROXIMATE);\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_,\n                                field_float, -1, -1, NULL));\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_,\n                                field_double, -1, -1, NULL));\n}\n\nTEST_F(DefaultFieldComparatorTest,\n       FloatingPointComparisonWithinFractionOrMargin) {\n  const FieldDescriptor* field_float =\n      descriptor_->FindFieldByName(\"optional_float\");\n  const FieldDescriptor* field_double =\n      descriptor_->FindFieldByName(\"optional_double\");\n\n  message_1_.set_optional_float(100.0f);\n  message_2_.set_optional_float(109.9f);\n  message_1_.set_optional_double(100.0);\n  message_2_.set_optional_double(109.9);\n\n  comparator_.set_float_comparison(DefaultFieldComparator::APPROXIMATE);\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_,\n                                field_float, -1, -1, NULL));\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_,\n                                field_double, -1, -1, NULL));\n\n  // Should fail since the fraction is too low.\n  comparator_.SetFractionAndMargin(field_float, 0.01, 0.0);\n  comparator_.SetFractionAndMargin(field_double, 0.01, 0.0);\n\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_,\n                                field_float, -1, -1, NULL));\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_,\n                                field_double, -1, -1, NULL));\n\n  // Should fail since the margin is too low.\n  comparator_.SetFractionAndMargin(field_float, 0.0, 9.0);\n  comparator_.SetFractionAndMargin(field_double, 0.0, 9.0);\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_,\n                                field_float, -1, -1, NULL));\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_,\n                                field_double, -1, -1, NULL));\n\n  // Should succeed since the fraction is high enough.\n  comparator_.SetFractionAndMargin(field_float, 0.2, 0.0);\n  comparator_.SetFractionAndMargin(field_double, 0.2, 0.0);\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_,\n                                field_float, -1, -1, NULL));\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_,\n                                field_double, -1, -1, NULL));\n\n  // Should succeed since the margin is high enough.\n  comparator_.SetFractionAndMargin(field_float, 0.0, 10.0);\n  comparator_.SetFractionAndMargin(field_double, 0.0, 10.0);\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_,\n                                field_float, -1, -1, NULL));\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_,\n                                field_double, -1, -1, NULL));\n\n  // Setting values for one of the fields should not affect the other.\n  comparator_.SetFractionAndMargin(field_double, 0.0, 0.0);\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_,\n                                field_float, -1, -1, NULL));\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_,\n                                field_double, -1, -1, NULL));\n\n  // +inf should be equal even though they are not technically within margin or\n  // fraction.\n  message_1_.set_optional_float(numeric_limits<float>::infinity());\n  message_2_.set_optional_float(numeric_limits<float>::infinity());\n  message_1_.set_optional_double(numeric_limits<double>::infinity());\n  message_2_.set_optional_double(numeric_limits<double>::infinity());\n  comparator_.SetFractionAndMargin(field_float, 0.0, 0.0);\n  comparator_.SetFractionAndMargin(field_double, 0.0, 0.0);\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_,\n                                field_float, -1, -1, NULL));\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_,\n                                field_double, -1, -1, NULL));\n\n  // -inf should be equal even though they are not technically within margin or\n  // fraction.\n  message_1_.set_optional_float(-numeric_limits<float>::infinity());\n  message_2_.set_optional_float(-numeric_limits<float>::infinity());\n  message_1_.set_optional_double(-numeric_limits<double>::infinity());\n  message_2_.set_optional_double(-numeric_limits<double>::infinity());\n  comparator_.SetFractionAndMargin(field_float, 0.0, 0.0);\n  comparator_.SetFractionAndMargin(field_double, 0.0, 0.0);\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_,\n                                field_float, -1, -1, NULL));\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_,\n                                field_double, -1, -1, NULL));\n}\n\nTEST_F(DefaultFieldComparatorTest,\n       FloatingPointComparisonWithinDefaultFractionOrMargin) {\n  const FieldDescriptor* field_float =\n      descriptor_->FindFieldByName(\"optional_float\");\n  const FieldDescriptor* field_double =\n      descriptor_->FindFieldByName(\"optional_double\");\n\n  message_1_.set_optional_float(100.0f);\n  message_2_.set_optional_float(109.9f);\n  message_1_.set_optional_double(100.0);\n  message_2_.set_optional_double(109.9);\n\n  comparator_.set_float_comparison(DefaultFieldComparator::APPROXIMATE);\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_,\n                                field_float, -1, -1, NULL));\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_,\n                                field_double, -1, -1, NULL));\n\n  // Set default fraction and margin.\n  comparator_.SetDefaultFractionAndMargin(0.01, 0.0);\n\n  // Float comparisons should fail since the fraction is too low.\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_,\n                                field_float, -1, -1, NULL));\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_,\n                                field_double, -1, -1, NULL));\n\n  // Set field-specific fraction and margin for one field (field_float) but not\n  // the other (field_double)\n  comparator_.SetFractionAndMargin(field_float, 0.2, 0.0);\n\n  // The field with the override should succeed, since its field-specific\n  // fraction is high enough.\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_,\n                                field_float, -1, -1, NULL));\n  // The field with no override should fail, since the default fraction is too\n  // low\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_,\n                                field_double, -1, -1, NULL));\n\n  // Set the default fraction and margin high enough so that fields that use\n  // the default should succeed\n  comparator_.SetDefaultFractionAndMargin(0.2, 0.0);\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_,\n                                field_double, -1, -1, NULL));\n\n  // The field with an override should still be OK\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_,\n                                field_float, -1, -1, NULL));\n\n  // Set fraction and margin for the field with an override to be too low\n  comparator_.SetFractionAndMargin(field_float, 0.01, 0.0);\n\n  // Now our default is high enough but field_float's override is too low.\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_,\n                                field_float, -1, -1, NULL));\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_,\n                                field_double, -1, -1, NULL));\n}\n\n// Simple test checking whether we compare values at correct indices.\nTEST_F(DefaultFieldComparatorTest, RepeatedFieldComparison) {\n  const FieldDescriptor* field =\n      descriptor_->FindFieldByName(\"repeated_string\");\n\n  message_1_.add_repeated_string(\"foo\");\n  message_1_.add_repeated_string(\"bar\");\n  message_2_.add_repeated_string(\"bar\");\n  message_2_.add_repeated_string(\"baz\");\n\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_, field, 0, 0, NULL));\n  EXPECT_EQ(FieldComparator::DIFFERENT,\n            comparator_.Compare(message_1_, message_2_, field, 1, 1, NULL));\n  EXPECT_EQ(FieldComparator::SAME,\n            comparator_.Compare(message_1_, message_2_, field, 1, 0, NULL));\n}\n\n}  // namespace util\n}  // namespace protobuf\n}  // namespace\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/field_mask_util.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/field_mask_util.h>\n\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/map_util.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\n\nusing google::protobuf::FieldMask;\n\nstring FieldMaskUtil::ToString(const FieldMask& mask) {\n  return Join(mask.paths(), \",\");\n}\n\nvoid FieldMaskUtil::FromString(StringPiece str, FieldMask* out) {\n  out->Clear();\n  vector<string> paths = Split(str, \",\");\n  for (int i = 0; i < paths.size(); ++i) {\n    if (paths[i].empty()) continue;\n    out->add_paths(paths[i]);\n  }\n}\n\nbool FieldMaskUtil::SnakeCaseToCamelCase(StringPiece input, string* output) {\n  output->clear();\n  bool after_underscore = false;\n  for (int i = 0; i < input.size(); ++i) {\n    if (input[i] >= 'A' && input[i] <= 'Z') {\n      // The field name must not contain uppercase letters.\n      return false;\n    }\n    if (after_underscore) {\n      if (input[i] >= 'a' && input[i] <= 'z') {\n        output->push_back(input[i] + 'A' - 'a');\n        after_underscore = false;\n      } else {\n        // The character after a \"_\" must be a lowercase letter.\n        return false;\n      }\n    } else if (input[i] == '_') {\n      after_underscore = true;\n    } else {\n      output->push_back(input[i]);\n    }\n  }\n  if (after_underscore) {\n    // Trailing \"_\".\n    return false;\n  }\n  return true;\n}\n\nbool FieldMaskUtil::CamelCaseToSnakeCase(StringPiece input, string* output) {\n  output->clear();\n  for (int i = 0; i < input.size(); ++i) {\n    if (input[i] == '_') {\n      // The field name must not contain \"_\"s.\n      return false;\n    }\n    if (input[i] >= 'A' && input[i] <= 'Z') {\n      output->push_back('_');\n      output->push_back(input[i] + 'a' - 'A');\n    } else {\n      output->push_back(input[i]);\n    }\n  }\n  return true;\n}\n\nbool FieldMaskUtil::ToJsonString(const FieldMask& mask, string* out) {\n  out->clear();\n  for (int i = 0; i < mask.paths_size(); ++i) {\n    const string& path = mask.paths(i);\n    string camelcase_path;\n    if (!SnakeCaseToCamelCase(path, &camelcase_path)) {\n      return false;\n    }\n    if (i > 0) {\n      out->push_back(',');\n    }\n    out->append(camelcase_path);\n  }\n  return true;\n}\n\nbool FieldMaskUtil::FromJsonString(StringPiece str, FieldMask* out) {\n  out->Clear();\n  vector<string> paths = Split(str, \",\");\n  for (int i = 0; i < paths.size(); ++i) {\n    if (paths[i].empty()) continue;\n    string snakecase_path;\n    if (!CamelCaseToSnakeCase(paths[i], &snakecase_path)) {\n      return false;\n    }\n    out->add_paths(snakecase_path);\n  }\n  return true;\n}\n\nbool FieldMaskUtil::InternalIsValidPath(const Descriptor* descriptor,\n                                        StringPiece path) {\n  vector<string> parts = Split(path, \".\");\n  for (int i = 0; i < parts.size(); ++i) {\n    const string& field_name = parts[i];\n    if (descriptor == NULL) {\n      return false;\n    }\n    const FieldDescriptor* field = descriptor->FindFieldByName(field_name);\n    if (field == NULL) {\n      return false;\n    }\n    if (!field->is_repeated() &&\n        field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n      descriptor = field->message_type();\n    } else {\n      descriptor = NULL;\n    }\n  }\n  return true;\n}\n\nvoid FieldMaskUtil::InternalGetFieldMaskForAllFields(\n    const Descriptor* descriptor, FieldMask* out) {\n  for (int i = 0; i < descriptor->field_count(); ++i) {\n    out->add_paths(descriptor->field(i)->name());\n  }\n}\n\nnamespace {\n// A FieldMaskTree represents a FieldMask in a tree structure. For example,\n// given a FieldMask \"foo.bar,foo.baz,bar.baz\", the FieldMaskTree will be:\n//\n//   [root] -+- foo -+- bar\n//           |       |\n//           |       +- baz\n//           |\n//           +- bar --- baz\n//\n// In the tree, each leaf node represents a field path.\nclass FieldMaskTree {\n public:\n  FieldMaskTree();\n  ~FieldMaskTree();\n\n  void MergeFromFieldMask(const FieldMask& mask);\n  void MergeToFieldMask(FieldMask* mask);\n\n  // Add a field path into the tree. In a FieldMask, each field path matches\n  // the specified field and also all its sub-fields. If the field path to\n  // add is a sub-path of an existing field path in the tree (i.e., a leaf\n  // node), it means the tree already matches the given path so nothing will\n  // be added to the tree. If the path matches an existing non-leaf node in the\n  // tree, that non-leaf node will be turned into a leaf node with all its\n  // children removed because the path matches all the node's children.\n  void AddPath(const string& path);\n\n  // Calculate the intersection part of a field path with this tree and add\n  // the intersection field path into out.\n  void IntersectPath(const string& path, FieldMaskTree* out);\n\n  // Merge all fields specified by this tree from one message to another.\n  void MergeMessage(const Message& source,\n                    const FieldMaskUtil::MergeOptions& options,\n                    Message* destination) {\n    // Do nothing if the tree is empty.\n    if (root_.children.empty()) {\n      return;\n    }\n    MergeMessage(&root_, source, options, destination);\n  }\n\n  // Trims all fields not specified by this tree from the given message.\n  void TrimMessage(Message* message) {\n    // Do nothing if the tree is empty.\n    if (root_.children.empty()) {\n      return;\n    }\n    TrimMessage(&root_, message);\n  }\n\n private:\n  struct Node {\n    Node() {}\n\n    ~Node() { ClearChildren(); }\n\n    void ClearChildren() {\n      for (map<string, Node*>::iterator it = children.begin();\n           it != children.end(); ++it) {\n        delete it->second;\n      }\n      children.clear();\n    }\n\n    map<string, Node*> children;\n\n   private:\n    GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Node);\n  };\n\n  // Merge a sub-tree to mask. This method adds the field paths represented\n  // by all leaf nodes descended from \"node\" to mask.\n  void MergeToFieldMask(const string& prefix, const Node* node, FieldMask* out);\n\n  // Merge all leaf nodes of a sub-tree to another tree.\n  void MergeLeafNodesToTree(const string& prefix, const Node* node,\n                            FieldMaskTree* out);\n\n  // Merge all fields specified by a sub-tree from one message to another.\n  void MergeMessage(const Node* node, const Message& source,\n                    const FieldMaskUtil::MergeOptions& options,\n                    Message* destination);\n\n  // Trims all fields not specified by this sub-tree from the given message.\n  void TrimMessage(const Node* node, Message* message);\n\n  Node root_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(FieldMaskTree);\n};\n\nFieldMaskTree::FieldMaskTree() {}\n\nFieldMaskTree::~FieldMaskTree() {}\n\nvoid FieldMaskTree::MergeFromFieldMask(const FieldMask& mask) {\n  for (int i = 0; i < mask.paths_size(); ++i) {\n    AddPath(mask.paths(i));\n  }\n}\n\nvoid FieldMaskTree::MergeToFieldMask(FieldMask* mask) {\n  MergeToFieldMask(\"\", &root_, mask);\n}\n\nvoid FieldMaskTree::MergeToFieldMask(const string& prefix, const Node* node,\n                                     FieldMask* out) {\n  if (node->children.empty()) {\n    if (prefix.empty()) {\n      // This is the root node.\n      return;\n    }\n    out->add_paths(prefix);\n    return;\n  }\n  for (map<string, Node*>::const_iterator it = node->children.begin();\n       it != node->children.end(); ++it) {\n    string current_path = prefix.empty() ? it->first : prefix + \".\" + it->first;\n    MergeToFieldMask(current_path, it->second, out);\n  }\n}\n\nvoid FieldMaskTree::AddPath(const string& path) {\n  vector<string> parts = Split(path, \".\");\n  if (parts.empty()) {\n    return;\n  }\n  bool new_branch = false;\n  Node* node = &root_;\n  for (int i = 0; i < parts.size(); ++i) {\n    if (!new_branch && node != &root_ && node->children.empty()) {\n      // Path matches an existing leaf node. This means the path is already\n      // coverred by this tree (for example, adding \"foo.bar.baz\" to a tree\n      // which already contains \"foo.bar\").\n      return;\n    }\n    const string& node_name = parts[i];\n    Node*& child = node->children[node_name];\n    if (child == NULL) {\n      new_branch = true;\n      child = new Node();\n    }\n    node = child;\n  }\n  if (!node->children.empty()) {\n    node->ClearChildren();\n  }\n}\n\nvoid FieldMaskTree::IntersectPath(const string& path, FieldMaskTree* out) {\n  vector<string> parts = Split(path, \".\");\n  if (parts.empty()) {\n    return;\n  }\n  const Node* node = &root_;\n  for (int i = 0; i < parts.size(); ++i) {\n    if (node->children.empty()) {\n      if (node != &root_) {\n        out->AddPath(path);\n      }\n      return;\n    }\n    const string& node_name = parts[i];\n    const Node* result = FindPtrOrNull(node->children, node_name);\n    if (result == NULL) {\n      // No intersection found.\n      return;\n    }\n    node = result;\n  }\n  // Now we found a matching node with the given path. Add all leaf nodes\n  // to out.\n  MergeLeafNodesToTree(path, node, out);\n}\n\nvoid FieldMaskTree::MergeLeafNodesToTree(const string& prefix, const Node* node,\n                                         FieldMaskTree* out) {\n  if (node->children.empty()) {\n    out->AddPath(prefix);\n  }\n  for (map<string, Node*>::const_iterator it = node->children.begin();\n       it != node->children.end(); ++it) {\n    string current_path = prefix.empty() ? it->first : prefix + \".\" + it->first;\n    MergeLeafNodesToTree(current_path, it->second, out);\n  }\n}\n\nvoid FieldMaskTree::MergeMessage(const Node* node, const Message& source,\n                                 const FieldMaskUtil::MergeOptions& options,\n                                 Message* destination) {\n  GOOGLE_DCHECK(!node->children.empty());\n  const Reflection* source_reflection = source.GetReflection();\n  const Reflection* destination_reflection = destination->GetReflection();\n  const Descriptor* descriptor = source.GetDescriptor();\n  for (map<string, Node*>::const_iterator it = node->children.begin();\n       it != node->children.end(); ++it) {\n    const string& field_name = it->first;\n    const Node* child = it->second;\n    const FieldDescriptor* field = descriptor->FindFieldByName(field_name);\n    if (field == NULL) {\n      GOOGLE_LOG(ERROR) << \"Cannot find field \\\"\" << field_name << \"\\\" in message \"\n                 << descriptor->full_name();\n      continue;\n    }\n    if (!child->children.empty()) {\n      // Sub-paths are only allowed for singular message fields.\n      if (field->is_repeated() ||\n          field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) {\n        GOOGLE_LOG(ERROR) << \"Field \\\"\" << field_name << \"\\\" in message \"\n                   << descriptor->full_name()\n                   << \" is not a singular message field and cannot \"\n                   << \"have sub-fields.\";\n        continue;\n      }\n      MergeMessage(child, source_reflection->GetMessage(source, field), options,\n                   destination_reflection->MutableMessage(destination, field));\n      continue;\n    }\n    if (!field->is_repeated()) {\n      switch (field->cpp_type()) {\n#define COPY_VALUE(TYPE, Name)                                              \\\n  case FieldDescriptor::CPPTYPE_##TYPE: {                                   \\\n    if (source_reflection->HasField(source, field)) {                       \\\n      destination_reflection->Set##Name(                                    \\\n          destination, field, source_reflection->Get##Name(source, field)); \\\n    } else {                                                                \\\n      destination_reflection->ClearField(destination, field);               \\\n    }                                                                       \\\n    break;                                                                  \\\n  }\n        COPY_VALUE(BOOL, Bool)\n        COPY_VALUE(INT32, Int32)\n        COPY_VALUE(INT64, Int64)\n        COPY_VALUE(UINT32, UInt32)\n        COPY_VALUE(UINT64, UInt64)\n        COPY_VALUE(FLOAT, Float)\n        COPY_VALUE(DOUBLE, Double)\n        COPY_VALUE(ENUM, Enum)\n        COPY_VALUE(STRING, String)\n#undef COPY_VALUE\n        case FieldDescriptor::CPPTYPE_MESSAGE: {\n          if (options.replace_message_fields()) {\n            destination_reflection->ClearField(destination, field);\n          }\n          if (source_reflection->HasField(source, field)) {\n            destination_reflection->MutableMessage(destination, field)\n                ->MergeFrom(source_reflection->GetMessage(source, field));\n          }\n          break;\n        }\n      }\n    } else {\n      if (options.replace_repeated_fields()) {\n        destination_reflection->ClearField(destination, field);\n      }\n      switch (field->cpp_type()) {\n#define COPY_REPEATED_VALUE(TYPE, Name)                            \\\n  case FieldDescriptor::CPPTYPE_##TYPE: {                          \\\n    int size = source_reflection->FieldSize(source, field);        \\\n    for (int i = 0; i < size; ++i) {                               \\\n      destination_reflection->Add##Name(                           \\\n          destination, field,                                      \\\n          source_reflection->GetRepeated##Name(source, field, i)); \\\n    }                                                              \\\n    break;                                                         \\\n  }\n        COPY_REPEATED_VALUE(BOOL, Bool)\n        COPY_REPEATED_VALUE(INT32, Int32)\n        COPY_REPEATED_VALUE(INT64, Int64)\n        COPY_REPEATED_VALUE(UINT32, UInt32)\n        COPY_REPEATED_VALUE(UINT64, UInt64)\n        COPY_REPEATED_VALUE(FLOAT, Float)\n        COPY_REPEATED_VALUE(DOUBLE, Double)\n        COPY_REPEATED_VALUE(ENUM, Enum)\n        COPY_REPEATED_VALUE(STRING, String)\n#undef COPY_REPEATED_VALUE\n        case FieldDescriptor::CPPTYPE_MESSAGE: {\n          int size = source_reflection->FieldSize(source, field);\n          for (int i = 0; i < size; ++i) {\n            destination_reflection->AddMessage(destination, field)\n                ->MergeFrom(\n                    source_reflection->GetRepeatedMessage(source, field, i));\n          }\n          break;\n        }\n      }\n    }\n  }\n}\n\nvoid FieldMaskTree::TrimMessage(const Node* node, Message* message) {\n  GOOGLE_DCHECK(!node->children.empty());\n  const Reflection* reflection = message->GetReflection();\n  const Descriptor* descriptor = message->GetDescriptor();\n  const int32 field_count = descriptor->field_count();\n  for (int index = 0; index < field_count; ++index) {\n    const FieldDescriptor* field = descriptor->field(index);\n    if (!ContainsKey(node->children, field->name())) {\n      reflection->ClearField(message, field);\n    } else {\n      if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n        Node* child = node->children.at(field->name());\n        if (!child->children.empty()) {\n          TrimMessage(child, reflection->MutableMessage(message, field));\n        }\n      }\n    }\n  }\n}\n\n}  // namespace\n\nvoid FieldMaskUtil::ToCanonicalForm(const FieldMask& mask, FieldMask* out) {\n  FieldMaskTree tree;\n  tree.MergeFromFieldMask(mask);\n  out->Clear();\n  tree.MergeToFieldMask(out);\n}\n\nvoid FieldMaskUtil::Union(const FieldMask& mask1, const FieldMask& mask2,\n                          FieldMask* out) {\n  FieldMaskTree tree;\n  tree.MergeFromFieldMask(mask1);\n  tree.MergeFromFieldMask(mask2);\n  out->Clear();\n  tree.MergeToFieldMask(out);\n}\n\nvoid FieldMaskUtil::Intersect(const FieldMask& mask1, const FieldMask& mask2,\n                              FieldMask* out) {\n  FieldMaskTree tree, intersection;\n  tree.MergeFromFieldMask(mask1);\n  for (int i = 0; i < mask2.paths_size(); ++i) {\n    tree.IntersectPath(mask2.paths(i), &intersection);\n  }\n  out->Clear();\n  intersection.MergeToFieldMask(out);\n}\n\nbool FieldMaskUtil::IsPathInFieldMask(StringPiece path, const FieldMask& mask) {\n  for (int i = 0; i < mask.paths_size(); ++i) {\n    const string& mask_path = mask.paths(i);\n    if (path == mask_path) {\n      return true;\n    } else if (mask_path.length() < path.length()) {\n      // Also check whether mask.paths(i) is a prefix of path.\n      if (path.substr(0, mask_path.length() + 1).compare(mask_path + \".\") ==\n          0) {\n        return true;\n      }\n    }\n  }\n  return false;\n}\n\nvoid FieldMaskUtil::MergeMessageTo(const Message& source, const FieldMask& mask,\n                                   const MergeOptions& options,\n                                   Message* destination) {\n  GOOGLE_CHECK(source.GetDescriptor() == destination->GetDescriptor());\n  // Build a FieldMaskTree and walk through the tree to merge all specified\n  // fields.\n  FieldMaskTree tree;\n  tree.MergeFromFieldMask(mask);\n  tree.MergeMessage(source, options, destination);\n}\n\nvoid FieldMaskUtil::TrimMessage(const FieldMask& mask, Message* destination) {\n  // Build a FieldMaskTree and walk through the tree to merge all specified\n  // fields.\n  FieldMaskTree tree;\n  tree.MergeFromFieldMask(mask);\n  tree.TrimMessage(GOOGLE_CHECK_NOTNULL(destination));\n}\n\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/field_mask_util.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_FIELD_MASK_UTIL_H__\n#define GOOGLE_PROTOBUF_UTIL_FIELD_MASK_UTIL_H__\n\n#include <string>\n\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/field_mask.pb.h>\n#include <google/protobuf/stubs/stringpiece.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\n\nclass LIBPROTOBUF_EXPORT FieldMaskUtil {\n  typedef google::protobuf::FieldMask FieldMask;\n\n public:\n  // Converts FieldMask to/from string, formatted by separating each path\n  // with a comma (e.g., \"foo_bar,baz.quz\").\n  static string ToString(const FieldMask& mask);\n  static void FromString(StringPiece str, FieldMask* out);\n\n  // Converts FieldMask to/from string, formatted according to proto3 JSON\n  // spec for FieldMask (e.g., \"fooBar,baz.quz\"). If the field name is not\n  // style conforming (i.e., not snake_case when converted to string, or not\n  // camelCase when converted from string), the conversion will fail.\n  static bool ToJsonString(const FieldMask& mask, string* out);\n  static bool FromJsonString(StringPiece str, FieldMask* out);\n\n  // Checks whether the given path is valid for type T.\n  template <typename T>\n  static bool IsValidPath(StringPiece path) {\n    return InternalIsValidPath(T::descriptor(), path);\n  }\n\n  // Checks whether the given FieldMask is valid for type T.\n  template <typename T>\n  static bool IsValidFieldMask(const FieldMask& mask) {\n    for (int i = 0; i < mask.paths_size(); ++i) {\n      if (!InternalIsValidPath(T::descriptor(), mask.paths(i))) return false;\n    }\n    return true;\n  }\n\n  // Adds a path to FieldMask after checking whether the given path is valid.\n  // This method check-fails if the path is not a valid path for type T.\n  template <typename T>\n  static void AddPathToFieldMask(StringPiece path, FieldMask* mask) {\n    GOOGLE_CHECK(IsValidPath<T>(path));\n    mask->add_paths(path);\n  }\n\n  // Creates a FieldMask with all fields of type T. This FieldMask only\n  // contains fields of T but not any sub-message fields.\n  template <typename T>\n  static void GetFieldMaskForAllFields(FieldMask* out) {\n    InternalGetFieldMaskForAllFields(T::descriptor(), out);\n  }\n\n  // Converts a FieldMask to the canonical form. It will:\n  //   1. Remove paths that are covered by another path. For example,\n  //      \"foo.bar\" is covered by \"foo\" and will be removed if \"foo\"\n  //      is also in the FieldMask.\n  //   2. Sort all paths in alphabetical order.\n  static void ToCanonicalForm(const FieldMask& mask, FieldMask* out);\n\n  // Creates an union of two FieldMasks.\n  static void Union(const FieldMask& mask1, const FieldMask& mask2,\n                    FieldMask* out);\n\n  // Creates an intersection of two FieldMasks.\n  static void Intersect(const FieldMask& mask1, const FieldMask& mask2,\n                        FieldMask* out);\n\n  // Returns true if path is covered by the given FieldMask. Note that path\n  // \"foo.bar\" covers all paths like \"foo.bar.baz\", \"foo.bar.quz.x\", etc.\n  static bool IsPathInFieldMask(StringPiece path, const FieldMask& mask);\n\n  class MergeOptions;\n  // Merges fields specified in a FieldMask into another message. See the\n  // comments in MergeOptions regarding compatibility with\n  // google/protobuf/field_mask.proto\n  static void MergeMessageTo(const Message& source, const FieldMask& mask,\n                             const MergeOptions& options, Message* destination);\n\n  // Removes from 'message' any field that is not represented in the given\n  // FieldMask. If the FieldMask is empty, does nothing.\n  static void TrimMessage(const FieldMask& mask, Message* message);\n\n private:\n  friend class SnakeCaseCamelCaseTest;\n  // Converts a field name from snake_case to camelCase:\n  //   1. Every character after \"_\" will be converted to uppercase.\n  //   2. All \"_\"s are removed.\n  // The conversion will fail if:\n  //   1. The field name contains uppercase letters.\n  //   2. Any character after a \"_\" is not a lowercase letter.\n  // If the conversion succeeds, it's guaranteed that the resulted\n  // camelCase name will yield the original snake_case name when\n  // converted using CamelCaseToSnakeCase().\n  //\n  // Note that the input can contain characters not allowed in C identifiers.\n  // For example, \"foo_bar,baz_quz\" will be converted to \"fooBar,bazQuz\"\n  // successfully.\n  static bool SnakeCaseToCamelCase(StringPiece input, string* output);\n  // Converts a field name from camelCase to snake_case:\n  //   1. Every uppercase letter is converted to lowercase with a additional\n  //      preceding \"-\".\n  // The conversion will fail if:\n  //   1. The field name contains \"_\"s.\n  // If the conversion succeeds, it's guaranteed that the resulted\n  // snake_case name will yield the original camelCase name when\n  // converted using SnakeCaseToCamelCase().\n  //\n  // Note that the input can contain characters not allowed in C identifiers.\n  // For example, \"fooBar,bazQuz\" will be converted to \"foo_bar,baz_quz\"\n  // successfully.\n  static bool CamelCaseToSnakeCase(StringPiece input, string* output);\n\n  static bool InternalIsValidPath(const Descriptor* descriptor,\n                                  StringPiece path);\n\n  static void InternalGetFieldMaskForAllFields(const Descriptor* descriptor,\n                                               FieldMask* out);\n};\n\n// Note that for compatibility with the defined behaviour for FieldMask in\n// google/protobuf/field_mask.proto, set replace_message_fields and\n// replace_repeated_fields to 'true'. The default options are not compatible\n// with google/protobuf/field_mask.proto.\nclass LIBPROTOBUF_EXPORT FieldMaskUtil::MergeOptions {\n public:\n  MergeOptions()\n      : replace_message_fields_(false), replace_repeated_fields_(false) {}\n  // When merging message fields, the default behavior is to merge the\n  // content of two message fields together. If you instead want to use\n  // the field from the source message to replace the corresponding field\n  // in the destination message, set this flag to true. When this flag is set,\n  // specified submessage fields that are missing in source will be cleared in\n  // destination.\n  void set_replace_message_fields(bool value) {\n    replace_message_fields_ = value;\n  }\n  bool replace_message_fields() const { return replace_message_fields_; }\n  // The default merging behavior will append entries from the source\n  // repeated field to the destination repeated field. If you only want\n  // to keep the entries from the source repeated field, set this flag\n  // to true.\n  void set_replace_repeated_fields(bool value) {\n    replace_repeated_fields_ = value;\n  }\n  bool replace_repeated_fields() const { return replace_repeated_fields_; }\n\n private:\n  bool replace_message_fields_;\n  bool replace_repeated_fields_;\n};\n\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_FIELD_MASK_UTIL_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/field_mask_util_test.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/field_mask_util.h>\n\n#include <algorithm>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/field_mask.pb.h>\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/test_util.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\n\nclass SnakeCaseCamelCaseTest : public ::testing::Test {\n protected:\n  string SnakeCaseToCamelCase(const string& input) {\n    string output;\n    if (FieldMaskUtil::SnakeCaseToCamelCase(input, &output)) {\n      return output;\n    } else {\n      return \"#FAIL#\";\n    }\n  }\n\n  string CamelCaseToSnakeCase(const string& input) {\n    string output;\n    if (FieldMaskUtil::CamelCaseToSnakeCase(input, &output)) {\n      return output;\n    } else {\n      return \"#FAIL#\";\n    }\n  }\n};\n\nnamespace {\n\nTEST_F(SnakeCaseCamelCaseTest, SnakeToCamel) {\n  EXPECT_EQ(\"fooBar\", SnakeCaseToCamelCase(\"foo_bar\"));\n  EXPECT_EQ(\"FooBar\", SnakeCaseToCamelCase(\"_foo_bar\"));\n  EXPECT_EQ(\"foo3Bar\", SnakeCaseToCamelCase(\"foo3_bar\"));\n  // No uppercase letter is allowed.\n  EXPECT_EQ(\"#FAIL#\", SnakeCaseToCamelCase(\"Foo\"));\n  // Any character after a \"_\" must be a lowercase letter.\n  //   1. \"_\" cannot be followed by another \"_\".\n  //   2. \"_\" cannot be followed by a digit.\n  //   3. \"_\" cannot appear as the last character.\n  EXPECT_EQ(\"#FAIL#\", SnakeCaseToCamelCase(\"foo__bar\"));\n  EXPECT_EQ(\"#FAIL#\", SnakeCaseToCamelCase(\"foo_3bar\"));\n  EXPECT_EQ(\"#FAIL#\", SnakeCaseToCamelCase(\"foo_bar_\"));\n}\n\nTEST_F(SnakeCaseCamelCaseTest, CamelToSnake) {\n  EXPECT_EQ(\"foo_bar\", CamelCaseToSnakeCase(\"fooBar\"));\n  EXPECT_EQ(\"_foo_bar\", CamelCaseToSnakeCase(\"FooBar\"));\n  EXPECT_EQ(\"foo3_bar\", CamelCaseToSnakeCase(\"foo3Bar\"));\n  // \"_\"s are not allowed.\n  EXPECT_EQ(\"#FAIL#\", CamelCaseToSnakeCase(\"foo_bar\"));\n}\n\nTEST_F(SnakeCaseCamelCaseTest, RoundTripTest) {\n  // Enumerates all possible snake_case names and test that converting it to\n  // camelCase and then to snake_case again will yield the original name.\n  string name = \"___abc123\";\n  std::sort(name.begin(), name.end());\n  do {\n    string camelName = SnakeCaseToCamelCase(name);\n    if (camelName != \"#FAIL#\") {\n      EXPECT_EQ(name, CamelCaseToSnakeCase(camelName));\n    }\n  } while (std::next_permutation(name.begin(), name.end()));\n\n  // Enumerates all possible camelCase names and test that converting it to\n  // snake_case and then to camelCase again will yield the original name.\n  name = \"abcABC123\";\n  std::sort(name.begin(), name.end());\n  do {\n    string camelName = CamelCaseToSnakeCase(name);\n    if (camelName != \"#FAIL#\") {\n      EXPECT_EQ(name, SnakeCaseToCamelCase(camelName));\n    }\n  } while (std::next_permutation(name.begin(), name.end()));\n}\n\nusing protobuf_unittest::TestAllTypes;\nusing protobuf_unittest::NestedTestAllTypes;\nusing google::protobuf::FieldMask;\n\nTEST(FieldMaskUtilTest, StringFormat) {\n  FieldMask mask;\n  EXPECT_EQ(\"\", FieldMaskUtil::ToString(mask));\n  mask.add_paths(\"foo_bar\");\n  EXPECT_EQ(\"foo_bar\", FieldMaskUtil::ToString(mask));\n  mask.add_paths(\"baz_quz\");\n  EXPECT_EQ(\"foo_bar,baz_quz\", FieldMaskUtil::ToString(mask));\n\n  FieldMaskUtil::FromString(\"\", &mask);\n  EXPECT_EQ(0, mask.paths_size());\n  FieldMaskUtil::FromString(\"fooBar\", &mask);\n  EXPECT_EQ(1, mask.paths_size());\n  EXPECT_EQ(\"fooBar\", mask.paths(0));\n  FieldMaskUtil::FromString(\"fooBar,bazQuz\", &mask);\n  EXPECT_EQ(2, mask.paths_size());\n  EXPECT_EQ(\"fooBar\", mask.paths(0));\n  EXPECT_EQ(\"bazQuz\", mask.paths(1));\n}\n\nTEST(FieldMaskUtilTest, JsonStringFormat) {\n  FieldMask mask;\n  string value;\n  EXPECT_TRUE(FieldMaskUtil::ToJsonString(mask, &value));\n  EXPECT_EQ(\"\", value);\n  mask.add_paths(\"foo_bar\");\n  EXPECT_TRUE(FieldMaskUtil::ToJsonString(mask, &value));\n  EXPECT_EQ(\"fooBar\", value);\n  mask.add_paths(\"bar_quz\");\n  EXPECT_TRUE(FieldMaskUtil::ToJsonString(mask, &value));\n  EXPECT_EQ(\"fooBar,barQuz\", value);\n\n  FieldMaskUtil::FromJsonString(\"\", &mask);\n  EXPECT_EQ(0, mask.paths_size());\n  FieldMaskUtil::FromJsonString(\"fooBar\", &mask);\n  EXPECT_EQ(1, mask.paths_size());\n  EXPECT_EQ(\"foo_bar\", mask.paths(0));\n  FieldMaskUtil::FromJsonString(\"fooBar,bazQuz\", &mask);\n  EXPECT_EQ(2, mask.paths_size());\n  EXPECT_EQ(\"foo_bar\", mask.paths(0));\n  EXPECT_EQ(\"baz_quz\", mask.paths(1));\n}\n\nTEST(FieldMaskUtilTest, TestIsVaildPath) {\n  EXPECT_TRUE(FieldMaskUtil::IsValidPath<TestAllTypes>(\"optional_int32\"));\n  EXPECT_FALSE(FieldMaskUtil::IsValidPath<TestAllTypes>(\"optional_nonexist\"));\n  EXPECT_TRUE(\n      FieldMaskUtil::IsValidPath<TestAllTypes>(\"optional_nested_message.bb\"));\n  EXPECT_FALSE(FieldMaskUtil::IsValidPath<TestAllTypes>(\n      \"optional_nested_message.nonexist\"));\n  // FieldMask cannot be used to specify sub-fields of a repeated message.\n  EXPECT_FALSE(\n      FieldMaskUtil::IsValidPath<TestAllTypes>(\"repeated_nested_message.bb\"));\n}\n\nTEST(FieldMaskUtilTest, TestIsValidFieldMask) {\n  FieldMask mask;\n  FieldMaskUtil::FromString(\"optional_int32,optional_nested_message.bb\", &mask);\n  EXPECT_TRUE(FieldMaskUtil::IsValidFieldMask<TestAllTypes>(mask));\n\n  FieldMaskUtil::FromString(\n      \"optional_int32,optional_nested_message.bb,optional_nonexist\", &mask);\n  EXPECT_FALSE(FieldMaskUtil::IsValidFieldMask<TestAllTypes>(mask));\n}\n\nTEST(FieldMaskUtilTest, TestGetFieldMaskForAllFields) {\n  FieldMask mask;\n  FieldMaskUtil::GetFieldMaskForAllFields<TestAllTypes::NestedMessage>(&mask);\n  EXPECT_EQ(1, mask.paths_size());\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"bb\", mask));\n\n  FieldMaskUtil::GetFieldMaskForAllFields<TestAllTypes>(&mask);\n  EXPECT_EQ(76, mask.paths_size());\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"optional_int32\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"optional_int64\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"optional_uint32\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"optional_uint64\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"optional_sint32\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"optional_sint64\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"optional_fixed32\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"optional_fixed64\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"optional_sfixed32\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"optional_sfixed64\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"optional_float\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"optional_double\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"optional_bool\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"optional_string\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"optional_bytes\", mask));\n  EXPECT_TRUE(\n      FieldMaskUtil::IsPathInFieldMask(\"optional_nested_message\", mask));\n  EXPECT_TRUE(\n      FieldMaskUtil::IsPathInFieldMask(\"optional_foreign_message\", mask));\n  EXPECT_TRUE(\n      FieldMaskUtil::IsPathInFieldMask(\"optional_import_message\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"optional_nested_enum\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"optional_foreign_enum\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"optional_import_enum\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"repeated_int32\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"repeated_int64\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"repeated_uint32\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"repeated_uint64\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"repeated_sint32\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"repeated_sint64\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"repeated_fixed32\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"repeated_fixed64\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"repeated_sfixed32\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"repeated_sfixed64\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"repeated_float\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"repeated_double\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"repeated_bool\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"repeated_string\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"repeated_bytes\", mask));\n  EXPECT_TRUE(\n      FieldMaskUtil::IsPathInFieldMask(\"repeated_nested_message\", mask));\n  EXPECT_TRUE(\n      FieldMaskUtil::IsPathInFieldMask(\"repeated_foreign_message\", mask));\n  EXPECT_TRUE(\n      FieldMaskUtil::IsPathInFieldMask(\"repeated_import_message\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"repeated_nested_enum\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"repeated_foreign_enum\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"repeated_import_enum\", mask));\n}\n\nTEST(FieldMaskUtilTest, TestToCanonicalForm) {\n  FieldMask in, out;\n  // Paths will be sorted.\n  FieldMaskUtil::FromString(\"baz.quz,bar,foo\", &in);\n  FieldMaskUtil::ToCanonicalForm(in, &out);\n  EXPECT_EQ(\"bar,baz.quz,foo\", FieldMaskUtil::ToString(out));\n  // Duplicated paths will be removed.\n  FieldMaskUtil::FromString(\"foo,bar,foo\", &in);\n  FieldMaskUtil::ToCanonicalForm(in, &out);\n  EXPECT_EQ(\"bar,foo\", FieldMaskUtil::ToString(out));\n  // Sub-paths of other paths will be removed.\n  FieldMaskUtil::FromString(\"foo.b1,bar.b1,foo.b2,bar\", &in);\n  FieldMaskUtil::ToCanonicalForm(in, &out);\n  EXPECT_EQ(\"bar,foo.b1,foo.b2\", FieldMaskUtil::ToString(out));\n\n  // Test more deeply nested cases.\n  FieldMaskUtil::FromString(\n      \"foo.bar.baz1,\"\n      \"foo.bar.baz2.quz,\"\n      \"foo.bar.baz2\",\n      &in);\n  FieldMaskUtil::ToCanonicalForm(in, &out);\n  EXPECT_EQ(\"foo.bar.baz1,foo.bar.baz2\", FieldMaskUtil::ToString(out));\n  FieldMaskUtil::FromString(\n      \"foo.bar.baz1,\"\n      \"foo.bar.baz2,\"\n      \"foo.bar.baz2.quz\",\n      &in);\n  FieldMaskUtil::ToCanonicalForm(in, &out);\n  EXPECT_EQ(\"foo.bar.baz1,foo.bar.baz2\", FieldMaskUtil::ToString(out));\n  FieldMaskUtil::FromString(\n      \"foo.bar.baz1,\"\n      \"foo.bar.baz2,\"\n      \"foo.bar.baz2.quz,\"\n      \"foo.bar\",\n      &in);\n  FieldMaskUtil::ToCanonicalForm(in, &out);\n  EXPECT_EQ(\"foo.bar\", FieldMaskUtil::ToString(out));\n  FieldMaskUtil::FromString(\n      \"foo.bar.baz1,\"\n      \"foo.bar.baz2,\"\n      \"foo.bar.baz2.quz,\"\n      \"foo\",\n      &in);\n  FieldMaskUtil::ToCanonicalForm(in, &out);\n  EXPECT_EQ(\"foo\", FieldMaskUtil::ToString(out));\n}\n\nTEST(FieldMaskUtilTest, TestUnion) {\n  FieldMask mask1, mask2, out;\n  // Test cases without overlapping.\n  FieldMaskUtil::FromString(\"foo,baz\", &mask1);\n  FieldMaskUtil::FromString(\"bar,quz\", &mask2);\n  FieldMaskUtil::Union(mask1, mask2, &out);\n  EXPECT_EQ(\"bar,baz,foo,quz\", FieldMaskUtil::ToString(out));\n  // Overlap with duplicated paths.\n  FieldMaskUtil::FromString(\"foo,baz.bb\", &mask1);\n  FieldMaskUtil::FromString(\"baz.bb,quz\", &mask2);\n  FieldMaskUtil::Union(mask1, mask2, &out);\n  EXPECT_EQ(\"baz.bb,foo,quz\", FieldMaskUtil::ToString(out));\n  // Overlap with paths covering some other paths.\n  FieldMaskUtil::FromString(\"foo.bar.baz,quz\", &mask1);\n  FieldMaskUtil::FromString(\"foo.bar,bar\", &mask2);\n  FieldMaskUtil::Union(mask1, mask2, &out);\n  EXPECT_EQ(\"bar,foo.bar,quz\", FieldMaskUtil::ToString(out));\n}\n\nTEST(FieldMaskUtilTest, TestIntersect) {\n  FieldMask mask1, mask2, out;\n  // Test cases without overlapping.\n  FieldMaskUtil::FromString(\"foo,baz\", &mask1);\n  FieldMaskUtil::FromString(\"bar,quz\", &mask2);\n  FieldMaskUtil::Intersect(mask1, mask2, &out);\n  EXPECT_EQ(\"\", FieldMaskUtil::ToString(out));\n  // Overlap with duplicated paths.\n  FieldMaskUtil::FromString(\"foo,baz.bb\", &mask1);\n  FieldMaskUtil::FromString(\"baz.bb,quz\", &mask2);\n  FieldMaskUtil::Intersect(mask1, mask2, &out);\n  EXPECT_EQ(\"baz.bb\", FieldMaskUtil::ToString(out));\n  // Overlap with paths covering some other paths.\n  FieldMaskUtil::FromString(\"foo.bar.baz,quz\", &mask1);\n  FieldMaskUtil::FromString(\"foo.bar,bar\", &mask2);\n  FieldMaskUtil::Intersect(mask1, mask2, &out);\n  EXPECT_EQ(\"foo.bar.baz\", FieldMaskUtil::ToString(out));\n}\n\nTEST(FieldMaskUtilTest, TestIspathInFieldMask) {\n  FieldMask mask;\n  FieldMaskUtil::FromString(\"foo.bar\", &mask);\n  EXPECT_FALSE(FieldMaskUtil::IsPathInFieldMask(\"\", mask));\n  EXPECT_FALSE(FieldMaskUtil::IsPathInFieldMask(\"foo\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"foo.bar\", mask));\n  EXPECT_TRUE(FieldMaskUtil::IsPathInFieldMask(\"foo.bar.baz\", mask));\n  EXPECT_FALSE(FieldMaskUtil::IsPathInFieldMask(\"foo.bar0.baz\", mask));\n}\n\nTEST(FieldMaskUtilTest, MergeMessage) {\n  TestAllTypes src, dst;\n  TestUtil::SetAllFields(&src);\n  FieldMaskUtil::MergeOptions options;\n\n#define TEST_MERGE_ONE_PRIMITIVE_FIELD(field_name)           \\\n  {                                                          \\\n    TestAllTypes tmp;                                        \\\n    tmp.set_##field_name(src.field_name());                  \\\n    FieldMask mask;                                          \\\n    mask.add_paths(#field_name);                             \\\n    dst.Clear();                                             \\\n    FieldMaskUtil::MergeMessageTo(src, mask, options, &dst); \\\n    EXPECT_EQ(tmp.DebugString(), dst.DebugString());         \\\n    src.clear_##field_name();                                \\\n    tmp.clear_##field_name();                                \\\n    FieldMaskUtil::MergeMessageTo(src, mask, options, &dst); \\\n    EXPECT_EQ(tmp.DebugString(), dst.DebugString());         \\\n  }\n  TEST_MERGE_ONE_PRIMITIVE_FIELD(optional_int32)\n  TEST_MERGE_ONE_PRIMITIVE_FIELD(optional_int64)\n  TEST_MERGE_ONE_PRIMITIVE_FIELD(optional_uint32)\n  TEST_MERGE_ONE_PRIMITIVE_FIELD(optional_uint64)\n  TEST_MERGE_ONE_PRIMITIVE_FIELD(optional_sint32)\n  TEST_MERGE_ONE_PRIMITIVE_FIELD(optional_sint64)\n  TEST_MERGE_ONE_PRIMITIVE_FIELD(optional_fixed32)\n  TEST_MERGE_ONE_PRIMITIVE_FIELD(optional_fixed64)\n  TEST_MERGE_ONE_PRIMITIVE_FIELD(optional_sfixed32)\n  TEST_MERGE_ONE_PRIMITIVE_FIELD(optional_sfixed64)\n  TEST_MERGE_ONE_PRIMITIVE_FIELD(optional_float)\n  TEST_MERGE_ONE_PRIMITIVE_FIELD(optional_double)\n  TEST_MERGE_ONE_PRIMITIVE_FIELD(optional_bool)\n  TEST_MERGE_ONE_PRIMITIVE_FIELD(optional_string)\n  TEST_MERGE_ONE_PRIMITIVE_FIELD(optional_bytes)\n  TEST_MERGE_ONE_PRIMITIVE_FIELD(optional_nested_enum)\n  TEST_MERGE_ONE_PRIMITIVE_FIELD(optional_foreign_enum)\n  TEST_MERGE_ONE_PRIMITIVE_FIELD(optional_import_enum)\n#undef TEST_MERGE_ONE_PRIMITIVE_FIELD\n\n#define TEST_MERGE_ONE_FIELD(field_name)                     \\\n  {                                                          \\\n    TestAllTypes tmp;                                        \\\n    *tmp.mutable_##field_name() = src.field_name();          \\\n    FieldMask mask;                                          \\\n    mask.add_paths(#field_name);                             \\\n    dst.Clear();                                             \\\n    FieldMaskUtil::MergeMessageTo(src, mask, options, &dst); \\\n    EXPECT_EQ(tmp.DebugString(), dst.DebugString());         \\\n  }\n  TEST_MERGE_ONE_FIELD(optional_nested_message)\n  TEST_MERGE_ONE_FIELD(optional_foreign_message)\n  TEST_MERGE_ONE_FIELD(optional_import_message)\n\n  TEST_MERGE_ONE_FIELD(repeated_int32)\n  TEST_MERGE_ONE_FIELD(repeated_int64)\n  TEST_MERGE_ONE_FIELD(repeated_uint32)\n  TEST_MERGE_ONE_FIELD(repeated_uint64)\n  TEST_MERGE_ONE_FIELD(repeated_sint32)\n  TEST_MERGE_ONE_FIELD(repeated_sint64)\n  TEST_MERGE_ONE_FIELD(repeated_fixed32)\n  TEST_MERGE_ONE_FIELD(repeated_fixed64)\n  TEST_MERGE_ONE_FIELD(repeated_sfixed32)\n  TEST_MERGE_ONE_FIELD(repeated_sfixed64)\n  TEST_MERGE_ONE_FIELD(repeated_float)\n  TEST_MERGE_ONE_FIELD(repeated_double)\n  TEST_MERGE_ONE_FIELD(repeated_bool)\n  TEST_MERGE_ONE_FIELD(repeated_string)\n  TEST_MERGE_ONE_FIELD(repeated_bytes)\n  TEST_MERGE_ONE_FIELD(repeated_nested_message)\n  TEST_MERGE_ONE_FIELD(repeated_foreign_message)\n  TEST_MERGE_ONE_FIELD(repeated_import_message)\n  TEST_MERGE_ONE_FIELD(repeated_nested_enum)\n  TEST_MERGE_ONE_FIELD(repeated_foreign_enum)\n  TEST_MERGE_ONE_FIELD(repeated_import_enum)\n#undef TEST_MERGE_ONE_FIELD\n\n  // Test merge nested fields.\n  NestedTestAllTypes nested_src, nested_dst;\n  nested_src.mutable_child()->mutable_payload()->set_optional_int32(1234);\n  nested_src.mutable_child()\n      ->mutable_child()\n      ->mutable_payload()\n      ->set_optional_int32(5678);\n  FieldMask mask;\n  FieldMaskUtil::FromString(\"child.payload\", &mask);\n  FieldMaskUtil::MergeMessageTo(nested_src, mask, options, &nested_dst);\n  EXPECT_EQ(1234, nested_dst.child().payload().optional_int32());\n  EXPECT_EQ(0, nested_dst.child().child().payload().optional_int32());\n\n  FieldMaskUtil::FromString(\"child.child.payload\", &mask);\n  FieldMaskUtil::MergeMessageTo(nested_src, mask, options, &nested_dst);\n  EXPECT_EQ(1234, nested_dst.child().payload().optional_int32());\n  EXPECT_EQ(5678, nested_dst.child().child().payload().optional_int32());\n\n  nested_dst.Clear();\n  FieldMaskUtil::FromString(\"child.child.payload\", &mask);\n  FieldMaskUtil::MergeMessageTo(nested_src, mask, options, &nested_dst);\n  EXPECT_EQ(0, nested_dst.child().payload().optional_int32());\n  EXPECT_EQ(5678, nested_dst.child().child().payload().optional_int32());\n\n  nested_dst.Clear();\n  FieldMaskUtil::FromString(\"child\", &mask);\n  FieldMaskUtil::MergeMessageTo(nested_src, mask, options, &nested_dst);\n  EXPECT_EQ(1234, nested_dst.child().payload().optional_int32());\n  EXPECT_EQ(5678, nested_dst.child().child().payload().optional_int32());\n\n  // Test MergeOptions.\n\n  nested_dst.Clear();\n  nested_dst.mutable_child()->mutable_payload()->set_optional_int64(4321);\n  // Message fields will be merged by default.\n  FieldMaskUtil::FromString(\"child.payload\", &mask);\n  FieldMaskUtil::MergeMessageTo(nested_src, mask, options, &nested_dst);\n  EXPECT_EQ(1234, nested_dst.child().payload().optional_int32());\n  EXPECT_EQ(4321, nested_dst.child().payload().optional_int64());\n  // Change the behavior to replace message fields.\n  options.set_replace_message_fields(true);\n  FieldMaskUtil::FromString(\"child.payload\", &mask);\n  FieldMaskUtil::MergeMessageTo(nested_src, mask, options, &nested_dst);\n  EXPECT_EQ(1234, nested_dst.child().payload().optional_int32());\n  EXPECT_EQ(0, nested_dst.child().payload().optional_int64());\n\n  // By default, fields missing in source are not cleared in destination.\n  options.set_replace_message_fields(false);\n  nested_dst.mutable_payload();\n  EXPECT_TRUE(nested_dst.has_payload());\n  FieldMaskUtil::FromString(\"payload\", &mask);\n  FieldMaskUtil::MergeMessageTo(nested_src, mask, options, &nested_dst);\n  EXPECT_TRUE(nested_dst.has_payload());\n  // But they are cleared when replacing message fields.\n  options.set_replace_message_fields(true);\n  nested_dst.Clear();\n  nested_dst.mutable_payload();\n  FieldMaskUtil::FromString(\"payload\", &mask);\n  FieldMaskUtil::MergeMessageTo(nested_src, mask, options, &nested_dst);\n  EXPECT_FALSE(nested_dst.has_payload());\n\n  nested_src.mutable_payload()->add_repeated_int32(1234);\n  nested_dst.mutable_payload()->add_repeated_int32(5678);\n  // Repeated fields will be appended by default.\n  FieldMaskUtil::FromString(\"payload.repeated_int32\", &mask);\n  FieldMaskUtil::MergeMessageTo(nested_src, mask, options, &nested_dst);\n  ASSERT_EQ(2, nested_dst.payload().repeated_int32_size());\n  EXPECT_EQ(5678, nested_dst.payload().repeated_int32(0));\n  EXPECT_EQ(1234, nested_dst.payload().repeated_int32(1));\n  // Change the behavior to replace repeated fields.\n  options.set_replace_repeated_fields(true);\n  FieldMaskUtil::FromString(\"payload.repeated_int32\", &mask);\n  FieldMaskUtil::MergeMessageTo(nested_src, mask, options, &nested_dst);\n  ASSERT_EQ(1, nested_dst.payload().repeated_int32_size());\n  EXPECT_EQ(1234, nested_dst.payload().repeated_int32(0));\n}\n\nTEST(FieldMaskUtilTest, TrimMessage) {\n#define TEST_TRIM_ONE_PRIMITIVE_FIELD(field_name)    \\\n  {                                                  \\\n    TestAllTypes msg;                                \\\n    TestUtil::SetAllFields(&msg);                    \\\n    TestAllTypes tmp;                                \\\n    tmp.set_##field_name(msg.field_name());          \\\n    FieldMask mask;                                  \\\n    mask.add_paths(#field_name);                     \\\n    FieldMaskUtil::TrimMessage(mask, &msg);          \\\n    EXPECT_EQ(tmp.DebugString(), msg.DebugString()); \\\n  }\n  TEST_TRIM_ONE_PRIMITIVE_FIELD(optional_int32)\n  TEST_TRIM_ONE_PRIMITIVE_FIELD(optional_int64)\n  TEST_TRIM_ONE_PRIMITIVE_FIELD(optional_uint32)\n  TEST_TRIM_ONE_PRIMITIVE_FIELD(optional_uint64)\n  TEST_TRIM_ONE_PRIMITIVE_FIELD(optional_sint32)\n  TEST_TRIM_ONE_PRIMITIVE_FIELD(optional_sint64)\n  TEST_TRIM_ONE_PRIMITIVE_FIELD(optional_fixed32)\n  TEST_TRIM_ONE_PRIMITIVE_FIELD(optional_fixed64)\n  TEST_TRIM_ONE_PRIMITIVE_FIELD(optional_sfixed32)\n  TEST_TRIM_ONE_PRIMITIVE_FIELD(optional_sfixed64)\n  TEST_TRIM_ONE_PRIMITIVE_FIELD(optional_float)\n  TEST_TRIM_ONE_PRIMITIVE_FIELD(optional_double)\n  TEST_TRIM_ONE_PRIMITIVE_FIELD(optional_bool)\n  TEST_TRIM_ONE_PRIMITIVE_FIELD(optional_string)\n  TEST_TRIM_ONE_PRIMITIVE_FIELD(optional_bytes)\n  TEST_TRIM_ONE_PRIMITIVE_FIELD(optional_nested_enum)\n  TEST_TRIM_ONE_PRIMITIVE_FIELD(optional_foreign_enum)\n  TEST_TRIM_ONE_PRIMITIVE_FIELD(optional_import_enum)\n#undef TEST_TRIM_ONE_PRIMITIVE_FIELD\n\n#define TEST_TRIM_ONE_FIELD(field_name)              \\\n  {                                                  \\\n    TestAllTypes msg;                                \\\n    TestUtil::SetAllFields(&msg);                    \\\n    TestAllTypes tmp;                                \\\n    *tmp.mutable_##field_name() = msg.field_name();  \\\n    FieldMask mask;                                  \\\n    mask.add_paths(#field_name);                     \\\n    FieldMaskUtil::TrimMessage(mask, &msg);          \\\n    EXPECT_EQ(tmp.DebugString(), msg.DebugString()); \\\n  }\n  TEST_TRIM_ONE_FIELD(optional_nested_message)\n  TEST_TRIM_ONE_FIELD(optional_foreign_message)\n  TEST_TRIM_ONE_FIELD(optional_import_message)\n\n  TEST_TRIM_ONE_FIELD(repeated_int32)\n  TEST_TRIM_ONE_FIELD(repeated_int64)\n  TEST_TRIM_ONE_FIELD(repeated_uint32)\n  TEST_TRIM_ONE_FIELD(repeated_uint64)\n  TEST_TRIM_ONE_FIELD(repeated_sint32)\n  TEST_TRIM_ONE_FIELD(repeated_sint64)\n  TEST_TRIM_ONE_FIELD(repeated_fixed32)\n  TEST_TRIM_ONE_FIELD(repeated_fixed64)\n  TEST_TRIM_ONE_FIELD(repeated_sfixed32)\n  TEST_TRIM_ONE_FIELD(repeated_sfixed64)\n  TEST_TRIM_ONE_FIELD(repeated_float)\n  TEST_TRIM_ONE_FIELD(repeated_double)\n  TEST_TRIM_ONE_FIELD(repeated_bool)\n  TEST_TRIM_ONE_FIELD(repeated_string)\n  TEST_TRIM_ONE_FIELD(repeated_bytes)\n  TEST_TRIM_ONE_FIELD(repeated_nested_message)\n  TEST_TRIM_ONE_FIELD(repeated_foreign_message)\n  TEST_TRIM_ONE_FIELD(repeated_import_message)\n  TEST_TRIM_ONE_FIELD(repeated_nested_enum)\n  TEST_TRIM_ONE_FIELD(repeated_foreign_enum)\n  TEST_TRIM_ONE_FIELD(repeated_import_enum)\n#undef TEST_TRIM_ONE_FIELD\n\n  // Test trim nested fields.\n  NestedTestAllTypes nested_msg;\n  nested_msg.mutable_child()->mutable_payload()->set_optional_int32(1234);\n  nested_msg.mutable_child()\n      ->mutable_child()\n      ->mutable_payload()\n      ->set_optional_int32(5678);\n  NestedTestAllTypes trimmed_msg(nested_msg);\n  FieldMask mask;\n  FieldMaskUtil::FromString(\"child.payload\", &mask);\n  FieldMaskUtil::TrimMessage(mask, &trimmed_msg);\n  EXPECT_EQ(1234, trimmed_msg.child().payload().optional_int32());\n  EXPECT_EQ(0, trimmed_msg.child().child().payload().optional_int32());\n\n  trimmed_msg = nested_msg;\n  FieldMaskUtil::FromString(\"child.child.payload\", &mask);\n  FieldMaskUtil::TrimMessage(mask, &trimmed_msg);\n  EXPECT_EQ(0, trimmed_msg.child().payload().optional_int32());\n  EXPECT_EQ(5678, trimmed_msg.child().child().payload().optional_int32());\n\n  trimmed_msg = nested_msg;\n  FieldMaskUtil::FromString(\"child\", &mask);\n  FieldMaskUtil::TrimMessage(mask, &trimmed_msg);\n  EXPECT_EQ(1234, trimmed_msg.child().payload().optional_int32());\n  EXPECT_EQ(5678, trimmed_msg.child().child().payload().optional_int32());\n\n  trimmed_msg = nested_msg;\n  FieldMaskUtil::FromString(\"child.child\", &mask);\n  FieldMaskUtil::TrimMessage(mask, &trimmed_msg);\n  EXPECT_EQ(0, trimmed_msg.child().payload().optional_int32());\n  EXPECT_EQ(5678, trimmed_msg.child().child().payload().optional_int32());\n\n  // Verify than an empty FieldMask trims nothing\n  TestAllTypes all_types_msg;\n  TestUtil::SetAllFields(&all_types_msg);\n  TestAllTypes trimmed_all_types(all_types_msg);\n  FieldMask empty_mask;\n  FieldMaskUtil::TrimMessage(empty_mask, &trimmed_all_types);\n  EXPECT_EQ(trimmed_all_types.DebugString(), all_types_msg.DebugString());\n}\n\n\n}  // namespace\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/constants.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_CONSTANTS_H__\n#define GOOGLE_PROTOBUF_UTIL_CONVERTER_CONSTANTS_H__\n\n#include <google/protobuf/stubs/common.h>\n\n// This file contains constants used by //net/proto2/util/converter.\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n// Prefix for type URLs.\nconst char kTypeServiceBaseUrl[] = \"type.googleapis.com\";\n\n// Format string for RFC3339 timestamp formatting.\nconst char kRfc3339TimeFormat[] = \"%E4Y-%m-%dT%H:%M:%S\";\n\n// Same as above, but the year value is not zero-padded i.e. this accepts\n// timestamps like \"1-01-0001T23:59:59Z\" instead of \"0001-01-0001T23:59:59Z\".\nconst char kRfc3339TimeFormatNoPadding[] = \"%Y-%m-%dT%H:%M:%S\";\n\n// Minimun seconds allowed in a google.protobuf.Timestamp value.\nconst int64 kTimestampMinSeconds = -62135596800;\n\n// Maximum seconds allowed in a google.protobuf.Timestamp value.\nconst int64 kTimestampMaxSeconds = 253402300799;\n\n// Minimum seconds allowed in a google.protobuf.Duration value.\nconst int64 kDurationMinSeconds = -315576000000;\n\n// Maximum seconds allowed in a google.protobuf.Duration value.\nconst int64 kDurationMaxSeconds = 315576000000;\n\n// Nano seconds in a second.\nconst int32 kNanosPerSecond = 1000000000;\n\n// Type url representing NULL values in google.protobuf.Struct type.\nconst char kStructNullValueTypeUrl[] =\n    \"type.googleapis.com/google.protobuf.NullValue\";\n\n// Type string for google.protobuf.Struct\nconst char kStructType[] = \"google.protobuf.Struct\";\n\n// Type string for struct.proto's google.protobuf.Value value type.\nconst char kStructValueType[] = \"google.protobuf.Value\";\n\n// Type string for struct.proto's google.protobuf.ListValue value type.\nconst char kStructListValueType[] = \"google.protobuf.ListValue\";\n\n// Type string for google.protobuf.Timestamp\nconst char kTimestampType[] = \"google.protobuf.Timestamp\";\n\n// Type string for google.protobuf.Duration\nconst char kDurationType[] = \"google.protobuf.Duration\";\n\n// Type URL for struct value type google.protobuf.Value\nconst char kStructValueTypeUrl[] = \"type.googleapis.com/google.protobuf.Value\";\n\n// Type URL for struct value type google.protobuf.Value\nconst char kStructTypeUrl[] = \"type.googleapis.com/google.protobuf.Struct\";\n\n// Type string for google.protobuf.Any\nconst char kAnyType[] = \"google.protobuf.Any\";\n\n// The type URL of google.protobuf.FieldMask;\nconst char kFieldMaskTypeUrl[] =\n    \"type.googleapis.com/google.protobuf.FieldMask\";\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_CONVERTER_CONSTANTS_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/datapiece.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/internal/datapiece.h>\n\n#include <google/protobuf/struct.pb.h>\n#include <google/protobuf/type.pb.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/util/internal/utility.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/mathlimits.h>\n#include <google/protobuf/stubs/mathutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\nusing google::protobuf::EnumDescriptor;\nusing google::protobuf::EnumValueDescriptor;\n;\n;\n;\nusing util::error::Code;\nusing util::Status;\nusing util::StatusOr;\n\nnamespace {\n\ninline Status InvalidArgument(StringPiece value_str) {\n  return Status(util::error::INVALID_ARGUMENT, value_str);\n}\n\ntemplate <typename To, typename From>\nStatusOr<To> ValidateNumberConversion(To after, From before) {\n  if (after == before &&\n      MathUtil::Sign<From>(before) == MathUtil::Sign<To>(after)) {\n    return after;\n  } else {\n    return InvalidArgument(::google::protobuf::internal::is_integral<From>::value\n                               ? ValueAsString(before)\n                               : ::google::protobuf::internal::is_same<From, double>::value\n                                     ? DoubleAsString(before)\n                                     : FloatAsString(before));\n  }\n}\n\n// For general conversion between\n//     int32, int64, uint32, uint64, double and float\n// except conversion between double and float.\ntemplate <typename To, typename From>\nStatusOr<To> NumberConvertAndCheck(From before) {\n  if (::google::protobuf::internal::is_same<From, To>::value) return before;\n\n  To after = static_cast<To>(before);\n  return ValidateNumberConversion(after, before);\n}\n\n// For conversion to integer types (int32, int64, uint32, uint64) from floating\n// point types (double, float) only.\ntemplate <typename To, typename From>\nStatusOr<To> FloatingPointToIntConvertAndCheck(From before) {\n  if (::google::protobuf::internal::is_same<From, To>::value) return before;\n\n  To after = static_cast<To>(before);\n  return ValidateNumberConversion(after, before);\n}\n\n// For conversion between double and float only.\ntemplate <typename To, typename From>\nStatusOr<To> FloatingPointConvertAndCheck(From before) {\n  if (MathLimits<From>::IsNaN(before)) {\n    return std::numeric_limits<To>::quiet_NaN();\n  }\n\n  To after = static_cast<To>(before);\n  if (MathUtil::AlmostEquals<To>(after, before)) {\n    return after;\n  } else {\n    return InvalidArgument(::google::protobuf::internal::is_same<From, double>::value\n                               ? DoubleAsString(before)\n                               : FloatAsString(before));\n  }\n}\n\n}  // namespace\n\nStatusOr<int32> DataPiece::ToInt32() const {\n  if (type_ == TYPE_STRING) return StringToNumber<int32>(safe_strto32);\n\n  if (type_ == TYPE_DOUBLE)\n    return FloatingPointToIntConvertAndCheck<int32, double>(double_);\n\n  if (type_ == TYPE_FLOAT)\n    return FloatingPointToIntConvertAndCheck<int32, float>(float_);\n\n  return GenericConvert<int32>();\n}\n\nStatusOr<uint32> DataPiece::ToUint32() const {\n  if (type_ == TYPE_STRING) return StringToNumber<uint32>(safe_strtou32);\n\n  if (type_ == TYPE_DOUBLE)\n    return FloatingPointToIntConvertAndCheck<uint32, double>(double_);\n\n  if (type_ == TYPE_FLOAT)\n    return FloatingPointToIntConvertAndCheck<uint32, float>(float_);\n\n  return GenericConvert<uint32>();\n}\n\nStatusOr<int64> DataPiece::ToInt64() const {\n  if (type_ == TYPE_STRING) return StringToNumber<int64>(safe_strto64);\n\n  if (type_ == TYPE_DOUBLE)\n    return FloatingPointToIntConvertAndCheck<int64, double>(double_);\n\n  if (type_ == TYPE_FLOAT)\n    return FloatingPointToIntConvertAndCheck<int64, float>(float_);\n\n  return GenericConvert<int64>();\n}\n\nStatusOr<uint64> DataPiece::ToUint64() const {\n  if (type_ == TYPE_STRING) return StringToNumber<uint64>(safe_strtou64);\n\n  if (type_ == TYPE_DOUBLE)\n    return FloatingPointToIntConvertAndCheck<uint64, double>(double_);\n\n  if (type_ == TYPE_FLOAT)\n    return FloatingPointToIntConvertAndCheck<uint64, float>(float_);\n\n  return GenericConvert<uint64>();\n}\n\nStatusOr<double> DataPiece::ToDouble() const {\n  if (type_ == TYPE_FLOAT) {\n    return FloatingPointConvertAndCheck<double, float>(float_);\n  }\n  if (type_ == TYPE_STRING) {\n    if (str_ == \"Infinity\") return std::numeric_limits<double>::infinity();\n    if (str_ == \"-Infinity\") return -std::numeric_limits<double>::infinity();\n    if (str_ == \"NaN\") return std::numeric_limits<double>::quiet_NaN();\n    return StringToNumber<double>(safe_strtod);\n  }\n  return GenericConvert<double>();\n}\n\nStatusOr<float> DataPiece::ToFloat() const {\n  if (type_ == TYPE_DOUBLE) {\n    return FloatingPointConvertAndCheck<float, double>(double_);\n  }\n  if (type_ == TYPE_STRING) {\n    if (str_ == \"Infinity\") return std::numeric_limits<float>::infinity();\n    if (str_ == \"-Infinity\") return -std::numeric_limits<float>::infinity();\n    if (str_ == \"NaN\") return std::numeric_limits<float>::quiet_NaN();\n    // SafeStrToFloat() is used instead of safe_strtof() because the later\n    // does not fail on inputs like SimpleDtoa(DBL_MAX).\n    return StringToNumber<float>(SafeStrToFloat);\n  }\n  return GenericConvert<float>();\n}\n\nStatusOr<bool> DataPiece::ToBool() const {\n  switch (type_) {\n    case TYPE_BOOL:\n      return bool_;\n    case TYPE_STRING:\n      return StringToNumber<bool>(safe_strtob);\n    default:\n      return InvalidArgument(\n          ValueAsStringOrDefault(\"Wrong type. Cannot convert to Bool.\"));\n  }\n}\n\nStatusOr<string> DataPiece::ToString() const {\n  switch (type_) {\n    case TYPE_STRING:\n      return str_.ToString();\n    case TYPE_BYTES: {\n      string base64;\n      Base64Escape(str_, &base64);\n      return base64;\n    }\n    default:\n      return InvalidArgument(\n          ValueAsStringOrDefault(\"Cannot convert to string.\"));\n  }\n}\n\nstring DataPiece::ValueAsStringOrDefault(StringPiece default_string) const {\n  switch (type_) {\n    case TYPE_INT32:\n      return SimpleItoa(i32_);\n    case TYPE_INT64:\n      return SimpleItoa(i64_);\n    case TYPE_UINT32:\n      return SimpleItoa(u32_);\n    case TYPE_UINT64:\n      return SimpleItoa(u64_);\n    case TYPE_DOUBLE:\n      return DoubleAsString(double_);\n    case TYPE_FLOAT:\n      return FloatAsString(float_);\n    case TYPE_BOOL:\n      return SimpleBtoa(bool_);\n    case TYPE_STRING:\n      return StrCat(\"\\\"\", str_.ToString(), \"\\\"\");\n    case TYPE_BYTES: {\n      string base64;\n      WebSafeBase64Escape(str_, &base64);\n      return StrCat(\"\\\"\", base64, \"\\\"\");\n    }\n    case TYPE_NULL:\n      return \"null\";\n    default:\n      return default_string.ToString();\n  }\n}\n\nStatusOr<string> DataPiece::ToBytes() const {\n  if (type_ == TYPE_BYTES) return str_.ToString();\n  if (type_ == TYPE_STRING) {\n    string decoded;\n    if (!DecodeBase64(str_, &decoded)) {\n      return InvalidArgument(ValueAsStringOrDefault(\"Invalid data in input.\"));\n    }\n    return decoded;\n  } else {\n    return InvalidArgument(ValueAsStringOrDefault(\n        \"Wrong type. Only String or Bytes can be converted to Bytes.\"));\n  }\n}\n\nStatusOr<int> DataPiece::ToEnum(const google::protobuf::Enum* enum_type) const {\n  if (type_ == TYPE_NULL) return google::protobuf::NULL_VALUE;\n\n  if (type_ == TYPE_STRING) {\n    // First try the given value as a name.\n    string enum_name = str_.ToString();\n    const google::protobuf::EnumValue* value =\n        FindEnumValueByNameOrNull(enum_type, enum_name);\n    if (value != NULL) return value->number();\n    // Next try a normalized name.\n    for (string::iterator it = enum_name.begin(); it != enum_name.end(); ++it) {\n      *it = *it == '-' ? '_' : ascii_toupper(*it);\n    }\n    value = FindEnumValueByNameOrNull(enum_type, enum_name);\n    if (value != NULL) return value->number();\n  } else {\n    StatusOr<int32> value = ToInt32();\n    if (value.ok()) {\n      if (const google::protobuf::EnumValue* enum_value =\n              FindEnumValueByNumberOrNull(enum_type, value.ValueOrDie())) {\n        return enum_value->number();\n      }\n    }\n  }\n  return InvalidArgument(\n      ValueAsStringOrDefault(\"Cannot find enum with given value.\"));\n}\n\ntemplate <typename To>\nStatusOr<To> DataPiece::GenericConvert() const {\n  switch (type_) {\n    case TYPE_INT32:\n      return NumberConvertAndCheck<To, int32>(i32_);\n    case TYPE_INT64:\n      return NumberConvertAndCheck<To, int64>(i64_);\n    case TYPE_UINT32:\n      return NumberConvertAndCheck<To, uint32>(u32_);\n    case TYPE_UINT64:\n      return NumberConvertAndCheck<To, uint64>(u64_);\n    case TYPE_DOUBLE:\n      return NumberConvertAndCheck<To, double>(double_);\n    case TYPE_FLOAT:\n      return NumberConvertAndCheck<To, float>(float_);\n    default:  // TYPE_ENUM, TYPE_STRING, TYPE_CORD, TYPE_BOOL\n      return InvalidArgument(ValueAsStringOrDefault(\n          \"Wrong type. Bool, Enum, String and Cord not supported in \"\n          \"GenericConvert.\"));\n  }\n}\n\ntemplate <typename To>\nStatusOr<To> DataPiece::StringToNumber(bool (*func)(StringPiece, To*)) const {\n  if (str_.size() > 0 && (str_[0] == ' ' || str_[str_.size() - 1] == ' ')) {\n    return InvalidArgument(StrCat(\"\\\"\", str_, \"\\\"\"));\n  }\n  To result;\n  if (func(str_, &result)) return result;\n  return InvalidArgument(StrCat(\"\\\"\", str_.ToString(), \"\\\"\"));\n}\n\nbool DataPiece::DecodeBase64(StringPiece src, string* dest) const {\n  // Try web-safe decode first, if it fails, try the non-web-safe decode.\n  if (WebSafeBase64Unescape(src, dest)) {\n    if (use_strict_base64_decoding_) {\n      // In strict mode, check if the escaped version gives us the same value as\n      // unescaped.\n      string encoded;\n      // WebSafeBase64Escape does no padding by default.\n      WebSafeBase64Escape(*dest, &encoded);\n      // Remove trailing padding '=' characters before comparison.\n      StringPiece src_no_padding = StringPiece(src).substr(\n          0, src.ends_with(\"=\") ? src.find_last_not_of('=') + 1 : src.length());\n      return encoded == src_no_padding;\n    }\n    return true;\n  }\n\n  if (Base64Unescape(src, dest)) {\n    if (use_strict_base64_decoding_) {\n      string encoded;\n      Base64Escape(\n          reinterpret_cast<const unsigned char*>(dest->data()), dest->length(),\n          &encoded, false);\n      StringPiece src_no_padding = StringPiece(src).substr(\n          0, src.ends_with(\"=\") ? src.find_last_not_of('=') + 1 : src.length());\n      return encoded == src_no_padding;\n    }\n    return true;\n  }\n\n  return false;\n}\n\nvoid DataPiece::InternalCopy(const DataPiece& other) {\n  type_ = other.type_;\n  switch (type_) {\n    case TYPE_INT32:\n    case TYPE_INT64:\n    case TYPE_UINT32:\n    case TYPE_UINT64:\n    case TYPE_DOUBLE:\n    case TYPE_FLOAT:\n    case TYPE_BOOL:\n    case TYPE_ENUM:\n    case TYPE_NULL:\n    case TYPE_BYTES:\n    case TYPE_STRING: {\n      str_ = other.str_;\n      break;\n    }\n  }\n}\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/datapiece.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_DATAPIECE_H__\n#define GOOGLE_PROTOBUF_UTIL_CONVERTER_DATAPIECE_H__\n\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/stringpiece.h>\n#include <google/protobuf/stubs/statusor.h>\n\n\nnamespace google {\nnamespace protobuf {\nclass Enum;\n}  // namespace protobuf\n\n\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\n// Container for a single piece of data together with its data type.\n//\n// For primitive types (int32, int64, uint32, uint64, double, float, bool),\n// the data is stored by value.\n//\n// For string, a StringPiece is stored. For Cord, a pointer to Cord is stored.\n// Just like StringPiece, the DataPiece class does not own the storage for\n// the actual string or Cord, so it is the user's responsiblity to guarantee\n// that the underlying storage is still valid when the DataPiece is accessed.\nclass LIBPROTOBUF_EXPORT DataPiece {\n public:\n  // Identifies data type of the value.\n  // These are the types supported by DataPiece.\n  enum Type {\n    TYPE_INT32 = 1,\n    TYPE_INT64 = 2,\n    TYPE_UINT32 = 3,\n    TYPE_UINT64 = 4,\n    TYPE_DOUBLE = 5,\n    TYPE_FLOAT = 6,\n    TYPE_BOOL = 7,\n    TYPE_ENUM = 8,\n    TYPE_STRING = 9,\n    TYPE_BYTES = 10,\n    TYPE_NULL = 11,  // explicit NULL type\n  };\n\n  // Constructors and Destructor\n  explicit DataPiece(const int32 value) : type_(TYPE_INT32), i32_(value) {}\n  explicit DataPiece(const int64 value) : type_(TYPE_INT64), i64_(value) {}\n  explicit DataPiece(const uint32 value) : type_(TYPE_UINT32), u32_(value) {}\n  explicit DataPiece(const uint64 value) : type_(TYPE_UINT64), u64_(value) {}\n  explicit DataPiece(const double value) : type_(TYPE_DOUBLE), double_(value) {}\n  explicit DataPiece(const float value) : type_(TYPE_FLOAT), float_(value) {}\n  explicit DataPiece(const bool value) : type_(TYPE_BOOL), bool_(value) {}\n  DataPiece(StringPiece value, bool use_strict_base64_decoding)\n      : type_(TYPE_STRING),\n        str_(StringPiecePod::CreateFromStringPiece(value)),\n        use_strict_base64_decoding_(use_strict_base64_decoding) {}\n  // Constructor for bytes. The second parameter is not used.\n  DataPiece(StringPiece value, bool dummy, bool use_strict_base64_decoding)\n      : type_(TYPE_BYTES),\n        str_(StringPiecePod::CreateFromStringPiece(value)),\n        use_strict_base64_decoding_(use_strict_base64_decoding) {}\n\n  DataPiece(const DataPiece& r) : type_(r.type_) { InternalCopy(r); }\n\n  DataPiece& operator=(const DataPiece& x) {\n    InternalCopy(x);\n    return *this;\n  }\n\n  static DataPiece NullData() { return DataPiece(TYPE_NULL, 0); }\n\n  virtual ~DataPiece() {\n  }\n\n  // Accessors\n  Type type() const { return type_; }\n\n  StringPiece str() const {\n    GOOGLE_LOG_IF(DFATAL, type_ != TYPE_STRING) << \"Not a string type.\";\n    return str_;\n  }\n\n\n  // Parses, casts or converts the value stored in the DataPiece into an int32.\n  util::StatusOr<int32> ToInt32() const;\n\n  // Parses, casts or converts the value stored in the DataPiece into a uint32.\n  util::StatusOr<uint32> ToUint32() const;\n\n  // Parses, casts or converts the value stored in the DataPiece into an int64.\n  util::StatusOr<int64> ToInt64() const;\n\n  // Parses, casts or converts the value stored in the DataPiece into a uint64.\n  util::StatusOr<uint64> ToUint64() const;\n\n  // Parses, casts or converts the value stored in the DataPiece into a double.\n  util::StatusOr<double> ToDouble() const;\n\n  // Parses, casts or converts the value stored in the DataPiece into a float.\n  util::StatusOr<float> ToFloat() const;\n\n  // Parses, casts or converts the value stored in the DataPiece into a bool.\n  util::StatusOr<bool> ToBool() const;\n\n  // Parses, casts or converts the value stored in the DataPiece into a string.\n  util::StatusOr<string> ToString() const;\n\n  // Tries to convert the value contained in this datapiece to string. If the\n  // conversion fails, it returns the default_string.\n  string ValueAsStringOrDefault(StringPiece default_string) const;\n\n  util::StatusOr<string> ToBytes() const;\n\n  // Converts a value into protocol buffer enum number. If the value is a\n  // string, first attempts conversion by name, trying names as follows:\n  //   1) the directly provided string value.\n  //   2) the value upper-cased and replacing '-' by '_'\n  // If the value is not a string, attempts to convert to a 32-bit integer.\n  // If none of these succeeds, returns a conversion error status.\n  util::StatusOr<int> ToEnum(const google::protobuf::Enum* enum_type) const;\n\n private:\n  // Disallow implicit constructor.\n  DataPiece();\n\n  // Helper to create NULL or ENUM types.\n  DataPiece(Type type, int32 val) : type_(type), i32_(val) {}\n\n  // For numeric conversion between\n  //     int32, int64, uint32, uint64, double, float and bool\n  template <typename To>\n  util::StatusOr<To> GenericConvert() const;\n\n  // For conversion from string to\n  //     int32, int64, uint32, uint64, double, float and bool\n  template <typename To>\n  util::StatusOr<To> StringToNumber(bool (*func)(StringPiece, To*)) const;\n\n  // Decodes a base64 string. Returns true on success.\n  bool DecodeBase64(StringPiece src, string* dest) const;\n\n  // Helper function to initialize this DataPiece with 'other'.\n  void InternalCopy(const DataPiece& other);\n\n  // Data type for this piece of data.\n  Type type_;\n\n  typedef ::google::protobuf::internal::StringPiecePod StringPiecePod;\n\n  // Stored piece of data.\n  union {\n    int32 i32_;\n    int64 i64_;\n    uint32 u32_;\n    uint64 u64_;\n    double double_;\n    float float_;\n    bool bool_;\n    StringPiecePod str_;\n  };\n\n  // Uses a stricter version of base64 decoding for byte fields.\n  bool use_strict_base64_decoding_;\n};\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_CONVERTER_DATAPIECE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/default_value_objectwriter.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/internal/default_value_objectwriter.h>\n\n#include <google/protobuf/stubs/hash.h>\n\n#include <google/protobuf/util/internal/constants.h>\n#include <google/protobuf/util/internal/utility.h>\n#include <google/protobuf/stubs/map_util.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nusing util::Status;\nusing util::StatusOr;\nnamespace converter {\n\nnamespace {\n// Helper function to convert string value to given data type by calling the\n// passed converter function on the DataPiece created from \"value\" argument.\n// If value is empty or if conversion fails, the default_value is returned.\ntemplate <typename T>\nT ConvertTo(StringPiece value, StatusOr<T> (DataPiece::*converter_fn)() const,\n            T default_value) {\n  if (value.empty()) return default_value;\n  StatusOr<T> result = (DataPiece(value, true).*converter_fn)();\n  return result.ok() ? result.ValueOrDie() : default_value;\n}\n}  // namespace\n\nDefaultValueObjectWriter::DefaultValueObjectWriter(\n    TypeResolver* type_resolver, const google::protobuf::Type& type,\n    ObjectWriter* ow)\n    : typeinfo_(TypeInfo::NewTypeInfo(type_resolver)),\n      own_typeinfo_(true),\n      type_(type),\n      current_(NULL),\n      root_(NULL),\n      suppress_empty_list_(false),\n      field_scrub_callback_(NULL),\n      ow_(ow) {}\n\nDefaultValueObjectWriter::~DefaultValueObjectWriter() {\n  for (int i = 0; i < string_values_.size(); ++i) {\n    delete string_values_[i];\n  }\n  if (own_typeinfo_) {\n    delete typeinfo_;\n  }\n}\n\nDefaultValueObjectWriter* DefaultValueObjectWriter::RenderBool(StringPiece name,\n                                                               bool value) {\n  if (current_ == NULL) {\n    ow_->RenderBool(name, value);\n  } else {\n    RenderDataPiece(name, DataPiece(value));\n  }\n  return this;\n}\n\nDefaultValueObjectWriter* DefaultValueObjectWriter::RenderInt32(\n    StringPiece name, int32 value) {\n  if (current_ == NULL) {\n    ow_->RenderInt32(name, value);\n  } else {\n    RenderDataPiece(name, DataPiece(value));\n  }\n  return this;\n}\n\nDefaultValueObjectWriter* DefaultValueObjectWriter::RenderUint32(\n    StringPiece name, uint32 value) {\n  if (current_ == NULL) {\n    ow_->RenderUint32(name, value);\n  } else {\n    RenderDataPiece(name, DataPiece(value));\n  }\n  return this;\n}\n\nDefaultValueObjectWriter* DefaultValueObjectWriter::RenderInt64(\n    StringPiece name, int64 value) {\n  if (current_ == NULL) {\n    ow_->RenderInt64(name, value);\n  } else {\n    RenderDataPiece(name, DataPiece(value));\n  }\n  return this;\n}\n\nDefaultValueObjectWriter* DefaultValueObjectWriter::RenderUint64(\n    StringPiece name, uint64 value) {\n  if (current_ == NULL) {\n    ow_->RenderUint64(name, value);\n  } else {\n    RenderDataPiece(name, DataPiece(value));\n  }\n  return this;\n}\n\nDefaultValueObjectWriter* DefaultValueObjectWriter::RenderDouble(\n    StringPiece name, double value) {\n  if (current_ == NULL) {\n    ow_->RenderDouble(name, value);\n  } else {\n    RenderDataPiece(name, DataPiece(value));\n  }\n  return this;\n}\n\nDefaultValueObjectWriter* DefaultValueObjectWriter::RenderFloat(\n    StringPiece name, float value) {\n  if (current_ == NULL) {\n    ow_->RenderBool(name, value);\n  } else {\n    RenderDataPiece(name, DataPiece(value));\n  }\n  return this;\n}\n\nDefaultValueObjectWriter* DefaultValueObjectWriter::RenderString(\n    StringPiece name, StringPiece value) {\n  if (current_ == NULL) {\n    ow_->RenderString(name, value);\n  } else {\n    // Since StringPiece is essentially a pointer, takes a copy of \"value\" to\n    // avoid ownership issues.\n    string_values_.push_back(new string(value.ToString()));\n    RenderDataPiece(name, DataPiece(*string_values_.back(), true));\n  }\n  return this;\n}\n\nDefaultValueObjectWriter* DefaultValueObjectWriter::RenderBytes(\n    StringPiece name, StringPiece value) {\n  if (current_ == NULL) {\n    ow_->RenderBytes(name, value);\n  } else {\n    RenderDataPiece(name, DataPiece(value, false, true));\n  }\n  return this;\n}\n\nDefaultValueObjectWriter* DefaultValueObjectWriter::RenderNull(\n    StringPiece name) {\n  if (current_ == NULL) {\n    ow_->RenderNull(name);\n  } else {\n    RenderDataPiece(name, DataPiece::NullData());\n  }\n  return this;\n}\n\nvoid DefaultValueObjectWriter::RegisterFieldScrubCallBack(\n    FieldScrubCallBackPtr field_scrub_callback) {\n  field_scrub_callback_.reset(field_scrub_callback.release());\n}\n\nDefaultValueObjectWriter::Node::Node(\n    const string& name, const google::protobuf::Type* type, NodeKind kind,\n    const DataPiece& data, bool is_placeholder, const vector<string>& path,\n    bool suppress_empty_list, FieldScrubCallBack* field_scrub_callback)\n    : name_(name),\n      type_(type),\n      kind_(kind),\n      is_any_(false),\n      data_(data),\n      is_placeholder_(is_placeholder),\n      path_(path),\n      suppress_empty_list_(suppress_empty_list),\n      field_scrub_callback_(field_scrub_callback) {}\n\nDefaultValueObjectWriter::Node* DefaultValueObjectWriter::Node::FindChild(\n    StringPiece name) {\n  if (name.empty() || kind_ != OBJECT) {\n    return NULL;\n  }\n  for (int i = 0; i < children_.size(); ++i) {\n    Node* child = children_[i];\n    if (child->name() == name) {\n      return child;\n    }\n  }\n  return NULL;\n}\n\nvoid DefaultValueObjectWriter::Node::WriteTo(ObjectWriter* ow) {\n  if (kind_ == PRIMITIVE) {\n    ObjectWriter::RenderDataPieceTo(data_, name_, ow);\n    return;\n  }\n\n  // Render maps. Empty maps are rendered as \"{}\".\n  if (kind_ == MAP) {\n    ow->StartObject(name_);\n    WriteChildren(ow);\n    ow->EndObject();\n    return;\n  }\n\n  // Write out lists. If we didn't have any list in response, write out empty\n  // list.\n  if (kind_ == LIST) {\n    // Suppress empty lists if requested.\n    if (suppress_empty_list_ && is_placeholder_) return;\n\n    ow->StartList(name_);\n    WriteChildren(ow);\n    ow->EndList();\n    return;\n  }\n\n  // If is_placeholder_ = true, we didn't see this node in the response, so\n  // skip output.\n  if (is_placeholder_) return;\n\n  ow->StartObject(name_);\n  WriteChildren(ow);\n  ow->EndObject();\n}\n\nvoid DefaultValueObjectWriter::Node::WriteChildren(ObjectWriter* ow) {\n  for (int i = 0; i < children_.size(); ++i) {\n    Node* child = children_[i];\n    child->WriteTo(ow);\n  }\n}\n\nconst google::protobuf::Type* DefaultValueObjectWriter::Node::GetMapValueType(\n    const google::protobuf::Type& found_type, const TypeInfo* typeinfo) {\n  // If this field is a map, we should use the type of its \"Value\" as\n  // the type of the child node.\n  for (int i = 0; i < found_type.fields_size(); ++i) {\n    const google::protobuf::Field& sub_field = found_type.fields(i);\n    if (sub_field.number() != 2) {\n      continue;\n    }\n    if (sub_field.kind() != google::protobuf::Field_Kind_TYPE_MESSAGE) {\n      // This map's value type is not a message type. We don't need to\n      // get the field_type in this case.\n      break;\n    }\n    util::StatusOr<const google::protobuf::Type*> sub_type =\n        typeinfo->ResolveTypeUrl(sub_field.type_url());\n    if (!sub_type.ok()) {\n      GOOGLE_LOG(WARNING) << \"Cannot resolve type '\" << sub_field.type_url() << \"'.\";\n    } else {\n      return sub_type.ValueOrDie();\n    }\n    break;\n  }\n  return NULL;\n}\n\nvoid DefaultValueObjectWriter::Node::PopulateChildren(\n    const TypeInfo* typeinfo) {\n  // Ignores well known types that don't require automatically populating their\n  // primitive children. For type \"Any\", we only populate its children when the\n  // \"@type\" field is set.\n  // TODO(tsun): remove \"kStructValueType\" from the list. It's being checked\n  //     now because of a bug in the tool-chain that causes the \"oneof_index\"\n  //     of kStructValueType to not be set correctly.\n  if (type_ == NULL || type_->name() == kAnyType ||\n      type_->name() == kStructType || type_->name() == kTimestampType ||\n      type_->name() == kDurationType || type_->name() == kStructValueType) {\n    return;\n  }\n  std::vector<Node*> new_children;\n  hash_map<string, int> orig_children_map;\n\n  // Creates a map of child nodes to speed up lookup.\n  for (int i = 0; i < children_.size(); ++i) {\n    InsertIfNotPresent(&orig_children_map, children_[i]->name_, i);\n  }\n\n  for (int i = 0; i < type_->fields_size(); ++i) {\n    const google::protobuf::Field& field = type_->fields(i);\n\n    // This code is checking if the field to be added to the tree should be\n    // scrubbed or not by calling the field_scrub_callback_ callback function.\n    vector<string> path;\n    if (!path_.empty()) {\n      path.insert(path.begin(), path_.begin(), path_.end());\n    }\n    path.push_back(field.name());\n    if (field_scrub_callback_ != NULL &&\n        field_scrub_callback_->Run(path, &field)) {\n      continue;\n    }\n\n    hash_map<string, int>::iterator found =\n        orig_children_map.find(field.name());\n    // If the child field has already been set, we just add it to the new list\n    // of children.\n    if (found != orig_children_map.end()) {\n      new_children.push_back(children_[found->second]);\n      children_[found->second] = NULL;\n      continue;\n    }\n\n    const google::protobuf::Type* field_type = NULL;\n    bool is_map = false;\n    NodeKind kind = PRIMITIVE;\n\n    if (field.kind() == google::protobuf::Field_Kind_TYPE_MESSAGE) {\n      kind = OBJECT;\n      util::StatusOr<const google::protobuf::Type*> found_result =\n          typeinfo->ResolveTypeUrl(field.type_url());\n      if (!found_result.ok()) {\n        // \"field\" is of an unknown type.\n        GOOGLE_LOG(WARNING) << \"Cannot resolve type '\" << field.type_url() << \"'.\";\n      } else {\n        const google::protobuf::Type* found_type = found_result.ValueOrDie();\n        is_map = IsMap(field, *found_type);\n\n        if (!is_map) {\n          field_type = found_type;\n        } else {\n          // If this field is a map, we should use the type of its \"Value\" as\n          // the type of the child node.\n          field_type = GetMapValueType(*found_type, typeinfo);\n          kind = MAP;\n        }\n      }\n    }\n\n    if (!is_map &&\n        field.cardinality() ==\n            google::protobuf::Field_Cardinality_CARDINALITY_REPEATED) {\n      kind = LIST;\n    }\n\n    // If oneof_index() != 0, the child field is part of a \"oneof\", which means\n    // the child field is optional and we shouldn't populate its default value.\n    if (field.oneof_index() != 0) continue;\n\n    // If the child field is of primitive type, sets its data to the default\n    // value of its type.\n    google::protobuf::scoped_ptr<Node> child(new Node(\n        field.json_name(), field_type, kind,\n        kind == PRIMITIVE ? CreateDefaultDataPieceForField(field, typeinfo)\n                          : DataPiece::NullData(),\n        true, path, suppress_empty_list_, field_scrub_callback_));\n    new_children.push_back(child.release());\n  }\n  // Adds all leftover nodes in children_ to the beginning of new_child.\n  for (int i = 0; i < children_.size(); ++i) {\n    if (children_[i] == NULL) {\n      continue;\n    }\n    new_children.insert(new_children.begin(), children_[i]);\n    children_[i] = NULL;\n  }\n  children_.swap(new_children);\n}\n\nvoid DefaultValueObjectWriter::MaybePopulateChildrenOfAny(Node* node) {\n  // If this is an \"Any\" node with \"@type\" already given and no other children\n  // have been added, populates its children.\n  if (node != NULL && node->is_any() && node->type() != NULL &&\n      node->type()->name() != kAnyType && node->number_of_children() == 1) {\n    node->PopulateChildren(typeinfo_);\n  }\n}\n\nDataPiece DefaultValueObjectWriter::FindEnumDefault(\n    const google::protobuf::Field& field, const TypeInfo* typeinfo) {\n  if (!field.default_value().empty())\n    return DataPiece(field.default_value(), true);\n\n  const google::protobuf::Enum* enum_type =\n      typeinfo->GetEnumByTypeUrl(field.type_url());\n  if (!enum_type) {\n    GOOGLE_LOG(WARNING) << \"Could not find enum with type '\" << field.type_url()\n                 << \"'\";\n    return DataPiece::NullData();\n  }\n  // We treat the first value as the default if none is specified.\n  return enum_type->enumvalue_size() > 0\n             ? DataPiece(enum_type->enumvalue(0).name(), true)\n             : DataPiece::NullData();\n}\n\nDataPiece DefaultValueObjectWriter::CreateDefaultDataPieceForField(\n    const google::protobuf::Field& field, const TypeInfo* typeinfo) {\n  switch (field.kind()) {\n    case google::protobuf::Field_Kind_TYPE_DOUBLE: {\n      return DataPiece(ConvertTo<double>(\n          field.default_value(), &DataPiece::ToDouble, static_cast<double>(0)));\n    }\n    case google::protobuf::Field_Kind_TYPE_FLOAT: {\n      return DataPiece(ConvertTo<float>(\n          field.default_value(), &DataPiece::ToFloat, static_cast<float>(0)));\n    }\n    case google::protobuf::Field_Kind_TYPE_INT64:\n    case google::protobuf::Field_Kind_TYPE_SINT64:\n    case google::protobuf::Field_Kind_TYPE_SFIXED64: {\n      return DataPiece(ConvertTo<int64>(\n          field.default_value(), &DataPiece::ToInt64, static_cast<int64>(0)));\n    }\n    case google::protobuf::Field_Kind_TYPE_UINT64:\n    case google::protobuf::Field_Kind_TYPE_FIXED64: {\n      return DataPiece(ConvertTo<uint64>(\n          field.default_value(), &DataPiece::ToUint64, static_cast<uint64>(0)));\n    }\n    case google::protobuf::Field_Kind_TYPE_INT32:\n    case google::protobuf::Field_Kind_TYPE_SINT32:\n    case google::protobuf::Field_Kind_TYPE_SFIXED32: {\n      return DataPiece(ConvertTo<int32>(\n          field.default_value(), &DataPiece::ToInt32, static_cast<int32>(0)));\n    }\n    case google::protobuf::Field_Kind_TYPE_BOOL: {\n      return DataPiece(\n          ConvertTo<bool>(field.default_value(), &DataPiece::ToBool, false));\n    }\n    case google::protobuf::Field_Kind_TYPE_STRING: {\n      return DataPiece(field.default_value(), true);\n    }\n    case google::protobuf::Field_Kind_TYPE_BYTES: {\n      return DataPiece(field.default_value(), false, true);\n    }\n    case google::protobuf::Field_Kind_TYPE_UINT32:\n    case google::protobuf::Field_Kind_TYPE_FIXED32: {\n      return DataPiece(ConvertTo<uint32>(\n          field.default_value(), &DataPiece::ToUint32, static_cast<uint32>(0)));\n    }\n    case google::protobuf::Field_Kind_TYPE_ENUM: {\n      return FindEnumDefault(field, typeinfo);\n    }\n    default: { return DataPiece::NullData(); }\n  }\n}\n\nDefaultValueObjectWriter* DefaultValueObjectWriter::StartObject(\n    StringPiece name) {\n  if (current_ == NULL) {\n    vector<string> path;\n    root_.reset(new Node(name.ToString(), &type_, OBJECT, DataPiece::NullData(),\n                         false, path, suppress_empty_list_,\n                         field_scrub_callback_.get()));\n    root_->PopulateChildren(typeinfo_);\n    current_ = root_.get();\n    return this;\n  }\n  MaybePopulateChildrenOfAny(current_);\n  Node* child = current_->FindChild(name);\n  if (current_->kind() == LIST || current_->kind() == MAP || child == NULL) {\n    // If current_ is a list or a map node, we should create a new child and use\n    // the type of current_ as the type of the new child.\n    google::protobuf::scoped_ptr<Node> node(new Node(\n        name.ToString(), ((current_->kind() == LIST || current_->kind() == MAP)\n                              ? current_->type()\n                              : NULL),\n        OBJECT, DataPiece::NullData(), false,\n        child == NULL ? current_->path() : child->path(),\n        suppress_empty_list_, field_scrub_callback_.get()));\n    child = node.get();\n    current_->AddChild(node.release());\n  }\n\n  child->set_is_placeholder(false);\n  if (child->kind() == OBJECT && child->number_of_children() == 0) {\n    child->PopulateChildren(typeinfo_);\n  }\n\n  stack_.push(current_);\n  current_ = child;\n  return this;\n}\n\nDefaultValueObjectWriter* DefaultValueObjectWriter::EndObject() {\n  if (stack_.empty()) {\n    // The root object ends here. Writes out the tree.\n    WriteRoot();\n    return this;\n  }\n  current_ = stack_.top();\n  stack_.pop();\n  return this;\n}\n\nDefaultValueObjectWriter* DefaultValueObjectWriter::StartList(\n    StringPiece name) {\n  if (current_ == NULL) {\n    vector<string> path;\n    root_.reset(new Node(name.ToString(), &type_, LIST, DataPiece::NullData(),\n                         false, path, suppress_empty_list_,\n                         field_scrub_callback_.get()));\n    current_ = root_.get();\n    return this;\n  }\n  MaybePopulateChildrenOfAny(current_);\n  Node* child = current_->FindChild(name);\n  if (child == NULL || child->kind() != LIST) {\n    google::protobuf::scoped_ptr<Node> node(\n        new Node(name.ToString(), NULL, LIST, DataPiece::NullData(), false,\n                 child == NULL ? current_->path() : child->path(),\n                 suppress_empty_list_, field_scrub_callback_.get()));\n    child = node.get();\n    current_->AddChild(node.release());\n  }\n  child->set_is_placeholder(false);\n\n  stack_.push(current_);\n  current_ = child;\n  return this;\n}\n\nvoid DefaultValueObjectWriter::WriteRoot() {\n  root_->WriteTo(ow_);\n  root_.reset(NULL);\n  current_ = NULL;\n}\n\nDefaultValueObjectWriter* DefaultValueObjectWriter::EndList() {\n  if (stack_.empty()) {\n    WriteRoot();\n    return this;\n  }\n  current_ = stack_.top();\n  stack_.pop();\n  return this;\n}\n\nvoid DefaultValueObjectWriter::RenderDataPiece(StringPiece name,\n                                               const DataPiece& data) {\n  MaybePopulateChildrenOfAny(current_);\n  util::StatusOr<string> data_string = data.ToString();\n  if (current_->type() != NULL && current_->type()->name() == kAnyType &&\n      name == \"@type\" && data_string.ok()) {\n    const string& string_value = data_string.ValueOrDie();\n    // If the type of current_ is \"Any\" and its \"@type\" field is being set here,\n    // sets the type of current_ to be the type specified by the \"@type\".\n    util::StatusOr<const google::protobuf::Type*> found_type =\n        typeinfo_->ResolveTypeUrl(string_value);\n    if (!found_type.ok()) {\n      GOOGLE_LOG(WARNING) << \"Failed to resolve type '\" << string_value << \"'.\";\n    } else {\n      current_->set_type(found_type.ValueOrDie());\n    }\n    current_->set_is_any(true);\n    // If the \"@type\" field is placed after other fields, we should populate\n    // other children of primitive type now. Otherwise, we should wait until the\n    // first value field is rendered before we populate the children, because\n    // the \"value\" field of a Any message could be omitted.\n    if (current_->number_of_children() > 1 && current_->type() != NULL) {\n      current_->PopulateChildren(typeinfo_);\n    }\n  }\n  Node* child = current_->FindChild(name);\n  if (child == NULL || child->kind() != PRIMITIVE) {\n    // No children are found, creates a new child.\n    google::protobuf::scoped_ptr<Node> node(\n        new Node(name.ToString(), NULL, PRIMITIVE, data, false,\n                 child == NULL ? current_->path() : child->path(),\n                 suppress_empty_list_, field_scrub_callback_.get()));\n    child = node.get();\n    current_->AddChild(node.release());\n  } else {\n    child->set_data(data);\n  }\n}\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/default_value_objectwriter.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_DEFAULT_VALUE_OBJECTWRITER_H__\n#define GOOGLE_PROTOBUF_UTIL_CONVERTER_DEFAULT_VALUE_OBJECTWRITER_H__\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <stack>\n#include <vector>\n\n#include <google/protobuf/stubs/callback.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/util/internal/type_info.h>\n#include <google/protobuf/util/internal/datapiece.h>\n#include <google/protobuf/util/internal/object_writer.h>\n#include <google/protobuf/util/internal/utility.h>\n#include <google/protobuf/util/type_resolver.h>\n#include <google/protobuf/stubs/stringpiece.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\n// An ObjectWriter that renders non-repeated primitive fields of proto messages\n// with their default values. DefaultValueObjectWriter holds objects, lists and\n// fields it receives in a tree structure and writes them out to another\n// ObjectWriter when EndObject() is called on the root object. It also writes\n// out all non-repeated primitive fields that haven't been explicitly rendered\n// with their default values (0 for numbers, \"\" for strings, etc).\nclass LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {\n public:\n  // A Callback function to check whether a field needs to be scrubbed.\n  //\n  // Returns true if the field should not be present in the output. Returns\n  // false otherwise.\n  //\n  // The 'path' parameter is a vector of path to the field from root. For\n  // example: if a nested field \"a.b.c\" (b is the parent message field of c and\n  // a is the parent message field of b), then the vector should contain { \"a\",\n  // \"b\", \"c\" }.\n  //\n  // The Field* should point to the google::protobuf::Field of \"c\".\n  typedef ResultCallback2<bool /*return*/,\n                          const std::vector<string>& /*path of the field*/,\n                          const google::protobuf::Field* /*field*/>\n      FieldScrubCallBack;\n\n  // A unique pointer to a DefaultValueObjectWriter::FieldScrubCallBack.\n  typedef google::protobuf::scoped_ptr<FieldScrubCallBack> FieldScrubCallBackPtr;\n\n  DefaultValueObjectWriter(TypeResolver* type_resolver,\n                           const google::protobuf::Type& type,\n                           ObjectWriter* ow);\n\n  virtual ~DefaultValueObjectWriter();\n\n  // ObjectWriter methods.\n  virtual DefaultValueObjectWriter* StartObject(StringPiece name);\n\n  virtual DefaultValueObjectWriter* EndObject();\n\n  virtual DefaultValueObjectWriter* StartList(StringPiece name);\n\n  virtual DefaultValueObjectWriter* EndList();\n\n  virtual DefaultValueObjectWriter* RenderBool(StringPiece name, bool value);\n\n  virtual DefaultValueObjectWriter* RenderInt32(StringPiece name, int32 value);\n\n  virtual DefaultValueObjectWriter* RenderUint32(StringPiece name,\n                                                 uint32 value);\n\n  virtual DefaultValueObjectWriter* RenderInt64(StringPiece name, int64 value);\n\n  virtual DefaultValueObjectWriter* RenderUint64(StringPiece name,\n                                                 uint64 value);\n\n  virtual DefaultValueObjectWriter* RenderDouble(StringPiece name,\n                                                 double value);\n\n  virtual DefaultValueObjectWriter* RenderFloat(StringPiece name, float value);\n\n  virtual DefaultValueObjectWriter* RenderString(StringPiece name,\n                                                 StringPiece value);\n  virtual DefaultValueObjectWriter* RenderBytes(StringPiece name,\n                                                StringPiece value);\n\n  virtual DefaultValueObjectWriter* RenderNull(StringPiece name);\n\n  // Register the callback for scrubbing of fields. Owership of\n  // field_scrub_callback pointer is also transferred to this class\n  void RegisterFieldScrubCallBack(FieldScrubCallBackPtr field_scrub_callback);\n\n  // If set to true, empty lists are suppressed from output when default values\n  // are written.\n  void set_suppress_empty_list(bool value) { suppress_empty_list_ = value; }\n\n private:\n  enum NodeKind {\n    PRIMITIVE = 0,\n    OBJECT = 1,\n    LIST = 2,\n    MAP = 3,\n  };\n\n  // \"Node\" represents a node in the tree that holds the input of\n  // DefaultValueObjectWriter.\n  class LIBPROTOBUF_EXPORT Node {\n   public:\n    Node(const string& name, const google::protobuf::Type* type, NodeKind kind,\n         const DataPiece& data, bool is_placeholder, const vector<string>& path,\n         bool suppress_empty_list, FieldScrubCallBack* field_scrub_callback);\n    virtual ~Node() {\n      for (int i = 0; i < children_.size(); ++i) {\n        delete children_[i];\n      }\n    }\n\n    // Adds a child to this node. Takes ownership of this child.\n    void AddChild(Node* child) { children_.push_back(child); }\n\n    // Finds the child given its name.\n    Node* FindChild(StringPiece name);\n\n    // Populates children of this Node based on its type. If there are already\n    // children created, they will be merged to the result. Caller should pass\n    // in TypeInfo for looking up types of the children.\n    void PopulateChildren(const TypeInfo* typeinfo);\n\n    // If this node is a leaf (has data), writes the current node to the\n    // ObjectWriter; if not, then recursively writes the children to the\n    // ObjectWriter.\n    void WriteTo(ObjectWriter* ow);\n\n    // Accessors\n    const string& name() const { return name_; }\n\n    const vector<string>& path() const { return path_; }\n\n    const google::protobuf::Type* type() const { return type_; }\n\n    void set_type(const google::protobuf::Type* type) { type_ = type; }\n\n    NodeKind kind() const { return kind_; }\n\n    int number_of_children() const { return children_.size(); }\n\n    void set_data(const DataPiece& data) { data_ = data; }\n\n    bool is_any() const { return is_any_; }\n\n    void set_is_any(bool is_any) { is_any_ = is_any; }\n\n    void set_is_placeholder(bool is_placeholder) {\n      is_placeholder_ = is_placeholder;\n    }\n\n   private:\n    // Returns the Value Type of a map given the Type of the map entry and a\n    // TypeInfo instance.\n    const google::protobuf::Type* GetMapValueType(\n        const google::protobuf::Type& entry_type, const TypeInfo* typeinfo);\n\n    // Calls WriteTo() on every child in children_.\n    void WriteChildren(ObjectWriter* ow);\n\n    // The name of this node.\n    string name_;\n    // google::protobuf::Type of this node. Owned by TypeInfo.\n    const google::protobuf::Type* type_;\n    // The kind of this node.\n    NodeKind kind_;\n    // Whether this is a node for \"Any\".\n    bool is_any_;\n    // The data of this node when it is a leaf node.\n    DataPiece data_;\n    // Children of this node.\n    std::vector<Node*> children_;\n    // Whether this node is a placeholder for an object or list automatically\n    // generated when creating the parent node. Should be set to false after\n    // the parent node's StartObject()/StartList() method is called with this\n    // node's name.\n    bool is_placeholder_;\n\n    // Path of the field of this node\n    std::vector<string> path_;\n\n    // Whether to suppress empty list output.\n    bool suppress_empty_list_;\n\n    // Pointer to function for determining whether a field needs to be scrubbed\n    // or not. This callback is owned by the creator of this node.\n    FieldScrubCallBack* field_scrub_callback_;\n\n    GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Node);\n  };\n\n  // Populates children of \"node\" if it is an \"any\" Node and its real type has\n  // been given.\n  void MaybePopulateChildrenOfAny(Node* node);\n\n  // Writes the root_ node to ow_ and resets the root_ and current_ pointer to\n  // NULL.\n  void WriteRoot();\n\n  // Creates a DataPiece containing the default value of the type of the field.\n  static DataPiece CreateDefaultDataPieceForField(\n      const google::protobuf::Field& field, const TypeInfo* typeinfo);\n\n  // Adds or replaces the data_ of a primitive child node.\n  void RenderDataPiece(StringPiece name, const DataPiece& data);\n\n  // Returns the default enum value as a DataPiece, or the first enum value if\n  // there is no default. For proto3, where we cannot specify an explicit\n  // default, a zero value will always be returned.\n  static DataPiece FindEnumDefault(const google::protobuf::Field& field,\n                                   const TypeInfo* typeinfo);\n\n  // Type information for all the types used in the descriptor. Used to find\n  // google::protobuf::Type of nested messages/enums.\n  const TypeInfo* typeinfo_;\n  // Whether the TypeInfo object is owned by this class.\n  bool own_typeinfo_;\n  // google::protobuf::Type of the root message type.\n  const google::protobuf::Type& type_;\n  // Holds copies of strings passed to RenderString.\n  vector<string*> string_values_;\n\n  // The current Node. Owned by its parents.\n  Node* current_;\n  // The root Node.\n  google::protobuf::scoped_ptr<Node> root_;\n  // The stack to hold the path of Nodes from current_ to root_;\n  std::stack<Node*> stack_;\n\n  // Whether to suppress output of empty lists.\n  bool suppress_empty_list_;\n\n  // Unique Pointer to function for determining whether a field needs to be\n  // scrubbed or not.\n  FieldScrubCallBackPtr field_scrub_callback_;\n\n  ObjectWriter* ow_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(DefaultValueObjectWriter);\n};\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_CONVERTER_DEFAULT_VALUE_OBJECTWRITER_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/default_value_objectwriter_test.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/internal/default_value_objectwriter.h>\n#include <google/protobuf/util/internal/expecting_objectwriter.h>\n#include <google/protobuf/util/internal/testdata/default_value_test.pb.h>\n#include <google/protobuf/util/internal/type_info_test_helper.h>\n#include <google/protobuf/util/internal/constants.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\nnamespace testing {\n\nusing google::protobuf::testing::DefaultValueTest;\n\n// Base class for setting up required state for running default values tests on\n// different descriptors.\nclass BaseDefaultValueObjectWriterTest\n    : public ::testing::TestWithParam<testing::TypeInfoSource> {\n protected:\n  explicit BaseDefaultValueObjectWriterTest(const Descriptor* descriptor)\n      : helper_(GetParam()), mock_(), expects_(&mock_) {\n    helper_.ResetTypeInfo(descriptor);\n    testing_.reset(helper_.NewDefaultValueWriter(\n        string(kTypeServiceBaseUrl) + \"/\" + descriptor->full_name(), &mock_));\n  }\n\n  virtual ~BaseDefaultValueObjectWriterTest() {}\n\n  TypeInfoTestHelper helper_;\n  MockObjectWriter mock_;\n  ExpectingObjectWriter expects_;\n  google::protobuf::scoped_ptr<DefaultValueObjectWriter> testing_;\n};\n\n// Tests to cover some basic DefaultValueObjectWriter use cases. More tests are\n// in the marshalling_test.cc and translator_integration_test.cc.\nclass DefaultValueObjectWriterTest : public BaseDefaultValueObjectWriterTest {\n protected:\n  DefaultValueObjectWriterTest()\n      : BaseDefaultValueObjectWriterTest(DefaultValueTest::descriptor()) {}\n  virtual ~DefaultValueObjectWriterTest() {}\n};\n\nINSTANTIATE_TEST_CASE_P(DifferentTypeInfoSourceTest,\n                        DefaultValueObjectWriterTest,\n                        ::testing::Values(\n                            testing::USE_TYPE_RESOLVER));\n\nTEST_P(DefaultValueObjectWriterTest, Empty) {\n  // Set expectation\n  expects_.StartObject(\"\")\n      ->RenderDouble(\"doubleValue\", 0.0)\n      ->StartList(\"repeatedDouble\")\n      ->EndList()\n      ->RenderFloat(\"floatValue\", 0.0)\n      ->RenderInt64(\"int64Value\", 0)\n      ->RenderUint64(\"uint64Value\", 0)\n      ->RenderInt32(\"int32Value\", 0)\n      ->RenderUint32(\"uint32Value\", 0)\n      ->RenderBool(\"boolValue\", false)\n      ->RenderString(\"stringValue\", \"\")\n      ->RenderBytes(\"bytesValue\", \"\")\n      ->RenderString(\"enumValue\", \"ENUM_FIRST\")\n      ->EndObject();\n\n  // Actual testing\n  testing_->StartObject(\"\")->EndObject();\n}\n\nTEST_P(DefaultValueObjectWriterTest, NonDefaultDouble) {\n  // Set expectation\n  expects_.StartObject(\"\")\n      ->RenderDouble(\"doubleValue\", 1.0)\n      ->StartList(\"repeatedDouble\")\n      ->EndList()\n      ->RenderFloat(\"floatValue\", 0.0)\n      ->RenderInt64(\"int64Value\", 0)\n      ->RenderUint64(\"uint64Value\", 0)\n      ->RenderInt32(\"int32Value\", 0)\n      ->RenderUint32(\"uint32Value\", 0)\n      ->RenderBool(\"boolValue\", false)\n      ->RenderString(\"stringValue\", \"\")\n      ->RenderString(\"enumValue\", \"ENUM_FIRST\")\n      ->EndObject();\n\n  // Actual testing\n  testing_->StartObject(\"\")->RenderDouble(\"doubleValue\", 1.0)->EndObject();\n}\n\nTEST_P(DefaultValueObjectWriterTest, ShouldRetainUnknownField) {\n  // Set expectation\n  expects_.StartObject(\"\")\n      ->RenderDouble(\"doubleValue\", 1.0)\n      ->StartList(\"repeatedDouble\")\n      ->EndList()\n      ->RenderFloat(\"floatValue\", 0.0)\n      ->RenderInt64(\"int64Value\", 0)\n      ->RenderUint64(\"uint64Value\", 0)\n      ->RenderInt32(\"int32Value\", 0)\n      ->RenderUint32(\"uint32Value\", 0)\n      ->RenderBool(\"boolValue\", false)\n      ->RenderString(\"stringValue\", \"\")\n      ->RenderString(\"unknown\", \"abc\")\n      ->StartObject(\"unknownObject\")\n      ->RenderString(\"unknown\", \"def\")\n      ->EndObject()\n      ->RenderString(\"enumValue\", \"ENUM_FIRST\")\n      ->EndObject();\n\n  // Actual testing\n  testing_->StartObject(\"\")\n      ->RenderDouble(\"doubleValue\", 1.0)\n      ->RenderString(\"unknown\", \"abc\")\n      ->StartObject(\"unknownObject\")\n      ->RenderString(\"unknown\", \"def\")\n      ->EndObject()\n      ->EndObject();\n}\n\n\nclass DefaultValueObjectWriterSuppressListTest\n    : public BaseDefaultValueObjectWriterTest {\n protected:\n  DefaultValueObjectWriterSuppressListTest()\n      : BaseDefaultValueObjectWriterTest(DefaultValueTest::descriptor()) {\n    testing_->set_suppress_empty_list(true);\n  }\n  ~DefaultValueObjectWriterSuppressListTest() {}\n};\n\nINSTANTIATE_TEST_CASE_P(DifferentTypeInfoSourceTest,\n                        DefaultValueObjectWriterSuppressListTest,\n                        ::testing::Values(\n                            testing::USE_TYPE_RESOLVER));\n\nTEST_P(DefaultValueObjectWriterSuppressListTest, Empty) {\n  // Set expectation. Emtpy lists should be suppressed.\n  expects_.StartObject(\"\")\n      ->RenderDouble(\"doubleValue\", 0.0)\n      ->RenderFloat(\"floatValue\", 0.0)\n      ->RenderInt64(\"int64Value\", 0)\n      ->RenderUint64(\"uint64Value\", 0)\n      ->RenderInt32(\"int32Value\", 0)\n      ->RenderUint32(\"uint32Value\", 0)\n      ->RenderBool(\"boolValue\", false)\n      ->RenderString(\"stringValue\", \"\")\n      ->RenderBytes(\"bytesValue\", \"\")\n      ->RenderString(\"enumValue\", \"ENUM_FIRST\")\n      ->EndObject();\n\n  // Actual testing\n  testing_->StartObject(\"\")->EndObject();\n}\n}  // namespace testing\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/error_listener.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/internal/error_listener.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/error_listener.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_ERROR_LISTENER_H__\n#define GOOGLE_PROTOBUF_UTIL_CONVERTER_ERROR_LISTENER_H__\n\n#include <algorithm>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <string>\n#include <vector>\n\n#include <google/protobuf/stubs/callback.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/util/internal/location_tracker.h>\n#include <google/protobuf/stubs/stringpiece.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\n// Interface for error listener.\nclass LIBPROTOBUF_EXPORT ErrorListener {\n public:\n  virtual ~ErrorListener() {}\n\n  // Reports an invalid name at the given location.\n  virtual void InvalidName(const LocationTrackerInterface& loc,\n                           StringPiece unknown_name, StringPiece message) = 0;\n\n  // Reports an invalid value for a field.\n  virtual void InvalidValue(const LocationTrackerInterface& loc,\n                            StringPiece type_name, StringPiece value) = 0;\n\n  // Reports a missing required field.\n  virtual void MissingField(const LocationTrackerInterface& loc,\n                            StringPiece missing_name) = 0;\n\n protected:\n  ErrorListener() {}\n\n private:\n  // Do not add any data members to this class.\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ErrorListener);\n};\n\n// An error listener that ignores all errors.\nclass LIBPROTOBUF_EXPORT NoopErrorListener : public ErrorListener {\n public:\n  NoopErrorListener() {}\n  virtual ~NoopErrorListener() {}\n\n  virtual void InvalidName(const LocationTrackerInterface& loc,\n                           StringPiece unknown_name, StringPiece message) {}\n\n  virtual void InvalidValue(const LocationTrackerInterface& loc,\n                            StringPiece type_name, StringPiece value) {}\n\n  virtual void MissingField(const LocationTrackerInterface& loc,\n                            StringPiece missing_name) {}\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(NoopErrorListener);\n};\n\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_CONVERTER_ERROR_LISTENER_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/expecting_objectwriter.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_EXPECTING_OBJECTWRITER_H__\n#define GOOGLE_PROTOBUF_UTIL_CONVERTER_EXPECTING_OBJECTWRITER_H__\n\n// An implementation of ObjectWriter that automatically sets the\n// gmock expectations for the response to a method. Every method\n// returns the object itself for chaining.\n//\n// Usage:\n//   // Setup\n//   MockObjectWriter mock;\n//   ExpectingObjectWriter ow(&mock);\n//\n//   // Set expectation\n//   ow.StartObject(\"\")\n//       ->RenderString(\"key\", \"value\")\n//     ->EndObject();\n//\n//   // Actual testing\n//   mock.StartObject(StringPiece())\n//         ->RenderString(\"key\", \"value\")\n//       ->EndObject();\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/util/internal/object_writer.h>\n#include <gmock/gmock.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\nusing testing::IsEmpty;\nusing testing::NanSensitiveDoubleEq;\nusing testing::NanSensitiveFloatEq;\nusing testing::Return;\nusing testing::StrEq;\nusing testing::TypedEq;\n\nclass MockObjectWriter : public ObjectWriter {\n public:\n  MockObjectWriter() {}\n\n  MOCK_METHOD1(StartObject, ObjectWriter*(StringPiece));\n  MOCK_METHOD0(EndObject, ObjectWriter*());\n  MOCK_METHOD1(StartList, ObjectWriter*(StringPiece));\n  MOCK_METHOD0(EndList, ObjectWriter*());\n  MOCK_METHOD2(RenderBool, ObjectWriter*(StringPiece, bool));\n  MOCK_METHOD2(RenderInt32, ObjectWriter*(StringPiece, int32));\n  MOCK_METHOD2(RenderUint32, ObjectWriter*(StringPiece, uint32));\n  MOCK_METHOD2(RenderInt64, ObjectWriter*(StringPiece, int64));\n  MOCK_METHOD2(RenderUint64, ObjectWriter*(StringPiece, uint64));\n  MOCK_METHOD2(RenderDouble, ObjectWriter*(StringPiece, double));\n  MOCK_METHOD2(RenderFloat, ObjectWriter*(StringPiece, float));\n  MOCK_METHOD2(RenderString, ObjectWriter*(StringPiece, StringPiece));\n  MOCK_METHOD2(RenderBytes, ObjectWriter*(StringPiece, StringPiece));\n  MOCK_METHOD1(RenderNull, ObjectWriter*(StringPiece));\n};\n\nclass ExpectingObjectWriter : public ObjectWriter {\n public:\n  explicit ExpectingObjectWriter(MockObjectWriter* mock) : mock_(mock) {}\n\n  virtual ObjectWriter* StartObject(StringPiece name) {\n    (name.empty()\n         ? EXPECT_CALL(*mock_, StartObject(IsEmpty()))\n         : EXPECT_CALL(*mock_, StartObject(StrEq(name.ToString()))))\n        .WillOnce(Return(mock_))\n        .RetiresOnSaturation();\n    return this;\n  }\n\n  virtual ObjectWriter* EndObject() {\n    EXPECT_CALL(*mock_, EndObject())\n        .WillOnce(Return(mock_))\n        .RetiresOnSaturation();\n    return this;\n  }\n\n  virtual ObjectWriter* StartList(StringPiece name) {\n    (name.empty()\n         ? EXPECT_CALL(*mock_, StartList(IsEmpty()))\n         : EXPECT_CALL(*mock_, StartList(StrEq(name.ToString()))))\n        .WillOnce(Return(mock_))\n        .RetiresOnSaturation();\n    return this;\n  }\n\n  virtual ObjectWriter* EndList() {\n    EXPECT_CALL(*mock_, EndList())\n        .WillOnce(Return(mock_))\n        .RetiresOnSaturation();\n    return this;\n  }\n\n  virtual ObjectWriter* RenderBool(StringPiece name, bool value) {\n    (name.empty()\n         ? EXPECT_CALL(*mock_, RenderBool(IsEmpty(), TypedEq<bool>(value)))\n         : EXPECT_CALL(*mock_, RenderBool(StrEq(name.ToString()),\n                                          TypedEq<bool>(value))))\n        .WillOnce(Return(mock_))\n        .RetiresOnSaturation();\n    return this;\n  }\n\n  virtual ObjectWriter* RenderInt32(StringPiece name, int32 value) {\n    (name.empty()\n         ? EXPECT_CALL(*mock_, RenderInt32(IsEmpty(), TypedEq<int32>(value)))\n         : EXPECT_CALL(*mock_, RenderInt32(StrEq(name.ToString()),\n                                           TypedEq<int32>(value))))\n        .WillOnce(Return(mock_))\n        .RetiresOnSaturation();\n    return this;\n  }\n\n  virtual ObjectWriter* RenderUint32(StringPiece name, uint32 value) {\n    (name.empty()\n         ? EXPECT_CALL(*mock_, RenderUint32(IsEmpty(), TypedEq<uint32>(value)))\n         : EXPECT_CALL(*mock_, RenderUint32(StrEq(name.ToString()),\n                                            TypedEq<uint32>(value))))\n        .WillOnce(Return(mock_))\n        .RetiresOnSaturation();\n    return this;\n  }\n\n  virtual ObjectWriter* RenderInt64(StringPiece name, int64 value) {\n    (name.empty()\n         ? EXPECT_CALL(*mock_, RenderInt64(IsEmpty(), TypedEq<int64>(value)))\n         : EXPECT_CALL(*mock_, RenderInt64(StrEq(name.ToString()),\n                                           TypedEq<int64>(value))))\n        .WillOnce(Return(mock_))\n        .RetiresOnSaturation();\n    return this;\n  }\n\n  virtual ObjectWriter* RenderUint64(StringPiece name, uint64 value) {\n    (name.empty()\n         ? EXPECT_CALL(*mock_, RenderUint64(IsEmpty(), TypedEq<uint64>(value)))\n         : EXPECT_CALL(*mock_, RenderUint64(StrEq(name.ToString()),\n                                            TypedEq<uint64>(value))))\n        .WillOnce(Return(mock_))\n        .RetiresOnSaturation();\n    return this;\n  }\n\n  virtual ObjectWriter* RenderDouble(StringPiece name, double value) {\n    (name.empty()\n         ? EXPECT_CALL(*mock_, RenderDouble(IsEmpty(),\n                                            NanSensitiveDoubleEq(value)))\n         : EXPECT_CALL(*mock_, RenderDouble(StrEq(name.ToString()),\n                                            NanSensitiveDoubleEq(value))))\n        .WillOnce(Return(mock_))\n        .RetiresOnSaturation();\n    return this;\n  }\n\n  virtual ObjectWriter* RenderFloat(StringPiece name, float value) {\n    (name.empty()\n         ? EXPECT_CALL(*mock_, RenderFloat(IsEmpty(),\n                                           NanSensitiveFloatEq(value)))\n         : EXPECT_CALL(*mock_, RenderFloat(StrEq(name.ToString()),\n                                           NanSensitiveFloatEq(value))))\n        .WillOnce(Return(mock_))\n        .RetiresOnSaturation();\n    return this;\n  }\n\n  virtual ObjectWriter* RenderString(StringPiece name, StringPiece value) {\n    (name.empty()\n         ? EXPECT_CALL(*mock_, RenderString(IsEmpty(),\n               TypedEq<StringPiece>(value.ToString())))\n         : EXPECT_CALL(*mock_, RenderString(StrEq(name.ToString()),\n               TypedEq<StringPiece>(value.ToString()))))\n        .WillOnce(Return(mock_))\n        .RetiresOnSaturation();\n    return this;\n  }\n  virtual ObjectWriter* RenderBytes(StringPiece name, StringPiece value) {\n    (name.empty()\n         ? EXPECT_CALL(*mock_, RenderBytes(IsEmpty(), TypedEq<StringPiece>(\n                                                          value.ToString())))\n         : EXPECT_CALL(*mock_,\n                       RenderBytes(StrEq(name.ToString()),\n                                   TypedEq<StringPiece>(value.ToString()))))\n        .WillOnce(Return(mock_))\n        .RetiresOnSaturation();\n    return this;\n  }\n\n  virtual ObjectWriter* RenderNull(StringPiece name) {\n    (name.empty() ? EXPECT_CALL(*mock_, RenderNull(IsEmpty()))\n                  : EXPECT_CALL(*mock_, RenderNull(StrEq(name.ToString())))\n                        .WillOnce(Return(mock_))\n                        .RetiresOnSaturation());\n    return this;\n  }\n\n private:\n  MockObjectWriter* mock_;\n\n  GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(ExpectingObjectWriter);\n};\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_CONVERTER_EXPECTING_OBJECTWRITER_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/field_mask_utility.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/internal/field_mask_utility.h>\n\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/status_macros.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\nnamespace {\ninline util::Status CallPathSink(PathSinkCallback path_sink,\n                                   StringPiece arg) {\n  return path_sink->Run(arg);\n}\n\nutil::Status CreatePublicError(util::error::Code code,\n                                 const string& message) {\n  return util::Status(code, message);\n}\n\n// Appends a FieldMask path segment to a prefix.\nstring AppendPathSegmentToPrefix(StringPiece prefix, StringPiece segment) {\n  if (prefix.empty()) {\n    return segment.ToString();\n  }\n  if (segment.empty()) {\n    return prefix.ToString();\n  }\n  // If the segment is a map key, appends it to the prefix without the \".\".\n  if (segment.starts_with(\"[\\\"\")) {\n    return StrCat(prefix, segment);\n  }\n  return StrCat(prefix, \".\", segment);\n}\n\n}  // namespace\n\nstring ConvertFieldMaskPath(const StringPiece path,\n                            ConverterCallback converter) {\n  string result;\n  result.reserve(path.size() << 1);\n\n  bool is_quoted = false;\n  bool is_escaping = false;\n  int current_segment_start = 0;\n\n  // Loops until 1 passed the end of the input to make handling the last\n  // segment easier.\n  for (size_t i = 0; i <= path.size(); ++i) {\n    // Outputs quoted string as-is.\n    if (is_quoted) {\n      if (i == path.size()) {\n        break;\n      }\n      result.push_back(path[i]);\n      if (is_escaping) {\n        is_escaping = false;\n      } else if (path[i] == '\\\\') {\n        is_escaping = true;\n      } else if (path[i] == '\\\"') {\n        current_segment_start = i + 1;\n        is_quoted = false;\n      }\n      continue;\n    }\n    if (i == path.size() || path[i] == '.' || path[i] == '(' ||\n        path[i] == ')' || path[i] == '\\\"') {\n      result += converter(\n          path.substr(current_segment_start, i - current_segment_start));\n      if (i < path.size()) {\n        result.push_back(path[i]);\n      }\n      current_segment_start = i + 1;\n    }\n    if (i < path.size() && path[i] == '\\\"') {\n      is_quoted = true;\n    }\n  }\n  return result;\n}\n\nutil::Status DecodeCompactFieldMaskPaths(StringPiece paths,\n                                           PathSinkCallback path_sink) {\n  stack<string> prefix;\n  int length = paths.length();\n  int previous_position = 0;\n  bool in_map_key = false;\n  bool is_escaping = false;\n  // Loops until 1 passed the end of the input to make the handle of the last\n  // segment easier.\n  for (int i = 0; i <= length; ++i) {\n    if (i != length) {\n      // Skips everything in a map key until we hit the end of it, which is\n      // marked by an un-escaped '\"' immediately followed by a ']'.\n      if (in_map_key) {\n        if (is_escaping) {\n          is_escaping = false;\n          continue;\n        }\n        if (paths[i] == '\\\\') {\n          is_escaping = true;\n          continue;\n        }\n        if (paths[i] != '\\\"') {\n          continue;\n        }\n        // Un-escaped '\"' must be followed with a ']'.\n        if (i >= length - 1 || paths[i + 1] != ']') {\n          return util::Status(\n              util::error::INVALID_ARGUMENT,\n              StrCat(\"Invalid FieldMask '\", paths,\n                     \"'. Map keys should be represented as [\\\"some_key\\\"].\"));\n        }\n        // The end of the map key (\"\\\"]\") has been found.\n        in_map_key = false;\n        // Skips ']'.\n        i++;\n        // Checks whether the key ends at the end of a path segment.\n        if (i < length - 1 && paths[i + 1] != '.' && paths[i + 1] != ',' &&\n            paths[i + 1] != ')' && paths[i + 1] != '(') {\n          return util::Status(\n              util::error::INVALID_ARGUMENT,\n              StrCat(\"Invalid FieldMask '\", paths,\n                     \"'. Map keys should be at the end of a path segment.\"));\n        }\n        is_escaping = false;\n        continue;\n      }\n\n      // We are not in a map key, look for the start of one.\n      if (paths[i] == '[') {\n        if (i >= length - 1 || paths[i + 1] != '\\\"') {\n          return util::Status(\n              util::error::INVALID_ARGUMENT,\n              StrCat(\"Invalid FieldMask '\", paths,\n                     \"'. Map keys should be represented as [\\\"some_key\\\"].\"));\n        }\n        // \"[\\\"\" starts a map key.\n        in_map_key = true;\n        i++;  // Skips the '\\\"'.\n        continue;\n      }\n      // If the current character is not a special character (',', '(' or ')'),\n      // continue to the next.\n      if (paths[i] != ',' && paths[i] != ')' && paths[i] != '(') {\n        continue;\n      }\n    }\n    // Gets the current segment - sub-string between previous position (after\n    // '(', ')', ',', or the beginning of the input) and the current position.\n    StringPiece segment =\n        paths.substr(previous_position, i - previous_position);\n    string current_prefix = prefix.empty() ? \"\" : prefix.top();\n\n    if (i < length && paths[i] == '(') {\n      // Builds a prefix and save it into the stack.\n      prefix.push(AppendPathSegmentToPrefix(current_prefix, segment));\n    } else if (!segment.empty()) {\n      // When the current charactor is ')', ',' or the current position has\n      // passed the end of the input, builds and outputs a new paths by\n      // concatenating the last prefix with the current segment.\n      RETURN_IF_ERROR(CallPathSink(\n          path_sink, AppendPathSegmentToPrefix(current_prefix, segment)));\n    }\n\n    // Removes the last prefix after seeing a ')'.\n    if (i < length && paths[i] == ')') {\n      if (prefix.empty()) {\n        return util::Status(\n            util::error::INVALID_ARGUMENT,\n            StrCat(\"Invalid FieldMask '\", paths,\n                   \"'. Cannot find matching '(' for all ')'.\"));\n      }\n      prefix.pop();\n    }\n    previous_position = i + 1;\n  }\n  if (in_map_key) {\n    return util::Status(util::error::INVALID_ARGUMENT,\n                          StrCat(\"Invalid FieldMask '\", paths,\n                                 \"'. Cannot find matching ']' for all '['.\"));\n  }\n  if (!prefix.empty()) {\n    return util::Status(util::error::INVALID_ARGUMENT,\n                          StrCat(\"Invalid FieldMask '\", paths,\n                                 \"'. Cannot find matching ')' for all '('.\"));\n  }\n  return util::Status::OK;\n}\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/field_mask_utility.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// FieldMask related utility methods.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_FIELD_MASK_UTILITY_H__\n#define GOOGLE_PROTOBUF_UTIL_CONVERTER_FIELD_MASK_UTILITY_H__\n\n#include <functional>\n#include <stack>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/stringpiece.h>\n#include <google/protobuf/stubs/status.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\ntypedef string (*ConverterCallback)(StringPiece);\ntypedef ResultCallback1<util::Status, StringPiece>* PathSinkCallback;\n\n// Applies a 'converter' to each segment of a FieldMask path and returns the\n// result. Quoted strings in the 'path' are copied to the output as-is without\n// converting their content. Escaping is supported within quoted strings.\n// For example, \"ab\\\"_c\" will be returned as \"ab\\\"_c\" without any changes.\nstring ConvertFieldMaskPath(const StringPiece path,\n                            ConverterCallback converter);\n\n// Decodes a compact list of FieldMasks. For example, \"a.b,a.c.d,a.c.e\" will be\n// decoded into a list of field paths - \"a.b\", \"a.c.d\", \"a.c.e\". And the results\n// will be sent to 'path_sink', i.e. 'path_sink' will be called once per\n// resulting path.\n// Note that we also support Apiary style FieldMask form. The above example in\n// the Apiary style will look like \"a.b,a.c(d,e)\".\nutil::Status DecodeCompactFieldMaskPaths(StringPiece paths,\n                                           PathSinkCallback path_sink);\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_CONVERTER_FIELD_MASK_UTILITY_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/json_escaping.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/internal/json_escaping.h>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\nnamespace {\n\n// Array of hex characters for conversion to hex.\nstatic const char kHex[] = \"0123456789abcdef\";\n\n// Characters 0x00 to 0x9f are very commonly used, so we provide a special\n// table lookup.\n//\n// For unicode code point ch < 0xa0:\n// kCommonEscapes[ch] is the escaped string of ch, if escaping is needed;\n//                    or an empty string, if escaping is not needed.\nstatic const char kCommonEscapes[160][7] = {\n  // C0 (ASCII and derivatives) control characters\n  \"\\\\u0000\", \"\\\\u0001\", \"\\\\u0002\", \"\\\\u0003\",  // 0x00\n  \"\\\\u0004\", \"\\\\u0005\", \"\\\\u0006\", \"\\\\u0007\",\n  \"\\\\b\",     \"\\\\t\",     \"\\\\n\",     \"\\\\u000b\",\n  \"\\\\f\",     \"\\\\r\",     \"\\\\u000e\", \"\\\\u000f\",\n  \"\\\\u0010\", \"\\\\u0011\", \"\\\\u0012\", \"\\\\u0013\",  // 0x10\n  \"\\\\u0014\", \"\\\\u0015\", \"\\\\u0016\", \"\\\\u0017\",\n  \"\\\\u0018\", \"\\\\u0019\", \"\\\\u001a\", \"\\\\u001b\",\n  \"\\\\u001c\", \"\\\\u001d\", \"\\\\u001e\", \"\\\\u001f\",\n  // Escaping of \" and \\ are required by www.json.org string definition.\n  // Escaping of < and > are required for HTML security.\n  \"\", \"\", \"\\\\\\\"\", \"\", \"\",        \"\", \"\",        \"\",  // 0x20\n  \"\", \"\", \"\",     \"\", \"\",        \"\", \"\",        \"\",\n  \"\", \"\", \"\",     \"\", \"\",        \"\", \"\",        \"\",  // 0x30\n  \"\", \"\", \"\",     \"\", \"\\\\u003c\", \"\", \"\\\\u003e\", \"\",\n  \"\", \"\", \"\",     \"\", \"\",        \"\", \"\",        \"\",  // 0x40\n  \"\", \"\", \"\",     \"\", \"\",        \"\", \"\",        \"\",\n  \"\", \"\", \"\",     \"\", \"\",        \"\", \"\",        \"\",  // 0x50\n  \"\", \"\", \"\",     \"\", \"\\\\\\\\\",    \"\", \"\",        \"\",\n  \"\", \"\", \"\",     \"\", \"\",        \"\", \"\",        \"\",  // 0x60\n  \"\", \"\", \"\",     \"\", \"\",        \"\", \"\",        \"\",\n  \"\", \"\", \"\",     \"\", \"\",        \"\", \"\",        \"\",  // 0x70\n  \"\", \"\", \"\",     \"\", \"\",        \"\", \"\",        \"\\\\u007f\",\n  // C1 (ISO 8859 and Unicode) extended control characters\n  \"\\\\u0080\", \"\\\\u0081\", \"\\\\u0082\", \"\\\\u0083\",  // 0x80\n  \"\\\\u0084\", \"\\\\u0085\", \"\\\\u0086\", \"\\\\u0087\",\n  \"\\\\u0088\", \"\\\\u0089\", \"\\\\u008a\", \"\\\\u008b\",\n  \"\\\\u008c\", \"\\\\u008d\", \"\\\\u008e\", \"\\\\u008f\",\n  \"\\\\u0090\", \"\\\\u0091\", \"\\\\u0092\", \"\\\\u0093\",  // 0x90\n  \"\\\\u0094\", \"\\\\u0095\", \"\\\\u0096\", \"\\\\u0097\",\n  \"\\\\u0098\", \"\\\\u0099\", \"\\\\u009a\", \"\\\\u009b\",\n  \"\\\\u009c\", \"\\\\u009d\", \"\\\\u009e\", \"\\\\u009f\"\n};\n\n// Determines if the given char value is a unicode high-surrogate code unit.\n// Such values do not represent characters by themselves, but are used in the\n// representation of supplementary characters in the utf-16 encoding.\ninline bool IsHighSurrogate(uint16 c) {\n  // Optimized form of:\n  // return c >= kMinHighSurrogate && c <= kMaxHighSurrogate;\n  // (Reduced from 3 ALU instructions to 2 ALU instructions)\n  return (c & ~(JsonEscaping::kMaxHighSurrogate -\n                JsonEscaping::kMinHighSurrogate))\n      == JsonEscaping::kMinHighSurrogate;\n}\n\n// Determines if the given char value is a unicode low-surrogate code unit.\n// Such values do not represent characters by themselves, but are used in the\n// representation of supplementary characters in the utf-16 encoding.\ninline bool IsLowSurrogate(uint16 c) {\n  // Optimized form of:\n  // return c >= kMinLowSurrogate && c <= kMaxLowSurrogate;\n  // (Reduced from 3 ALU instructions to 2 ALU instructions)\n  return (c & ~(JsonEscaping::kMaxLowSurrogate -\n                JsonEscaping::kMinLowSurrogate))\n      == JsonEscaping::kMinLowSurrogate;\n}\n\n// Determines if the given char value is a unicode surrogate code unit (either\n// high-surrogate or low-surrogate).\ninline bool IsSurrogate(uint32 c) {\n  // Optimized form of:\n  // return c >= kMinHighSurrogate && c <= kMaxLowSurrogate;\n  // (Reduced from 3 ALU instructions to 2 ALU instructions)\n  return (c & 0xfffff800) == JsonEscaping::kMinHighSurrogate;\n}\n\n// Returns true if the given unicode code point cp is\n// in the supplementary character range.\ninline bool IsSupplementalCodePoint(uint32 cp) {\n  // Optimized form of:\n  // return kMinSupplementaryCodePoint <= cp && cp <= kMaxCodePoint;\n  // (Reduced from 3 ALU instructions to 2 ALU instructions)\n  return (cp & ~(JsonEscaping::kMinSupplementaryCodePoint - 1))\n      < JsonEscaping::kMaxCodePoint;\n}\n\n// Returns true if the given unicode code point cp is a valid\n// unicode code point (i.e. in the range 0 <= cp <= kMaxCodePoint).\ninline bool IsValidCodePoint(uint32 cp) {\n  return cp <= JsonEscaping::kMaxCodePoint;\n}\n\n// Converts the specified surrogate pair to its supplementary code point value.\n// It is the callers' responsibility to validate the specified surrogate pair.\ninline uint32 ToCodePoint(uint16 high, uint16 low) {\n  // Optimized form of:\n  // return ((high - kMinHighSurrogate) << 10)\n  //     + (low - kMinLowSurrogate)\n  //     + kMinSupplementaryCodePoint;\n  // (Reduced from 5 ALU instructions to 3 ALU instructions)\n  return (high << 10) + low +\n      (JsonEscaping::kMinSupplementaryCodePoint\n       - (static_cast<unsigned>(JsonEscaping::kMinHighSurrogate) << 10)\n       - JsonEscaping::kMinLowSurrogate);\n}\n\n// Returns the low surrogate for the given unicode code point. The result is\n// meaningless if the given code point is not a supplementary character.\ninline uint16 ToLowSurrogate(uint32 cp) {\n  return (cp & (JsonEscaping::kMaxLowSurrogate\n                - JsonEscaping::kMinLowSurrogate))\n      + JsonEscaping::kMinLowSurrogate;\n}\n\n// Returns the high surrogate for the given unicode code point. The result is\n// meaningless if the given code point is not a supplementary character.\ninline uint16 ToHighSurrogate(uint32 cp) {\n  return (cp >> 10) + (JsonEscaping::kMinHighSurrogate -\n                       (JsonEscaping::kMinSupplementaryCodePoint >> 10));\n}\n\n// Input str is encoded in UTF-8. A unicode code point could be encoded in\n// UTF-8 using anywhere from 1 to 4 characters, and it could span multiple\n// reads of the ByteSource.\n//\n// This function reads the next unicode code point from the input (str) at\n// the given position (index), taking into account any left-over partial\n// code point from the previous iteration (cp), together with the number\n// of characters left to read to complete this code point (num_left).\n//\n// This function assumes that the input (str) is valid at the given position\n// (index). In order words, at least one character could be read successfully.\n//\n// The code point read (partial or complete) is stored in (cp). Upon return,\n// (num_left) stores the number of characters that has yet to be read in\n// order to complete the current unicode code point. If the read is complete,\n// then (num_left) is 0. Also, (num_read) is the number of characters read.\n//\n// Returns false if we encounter an invalid UTF-8 string. Returns true\n// otherwise, including the case when we reach the end of the input (str)\n// before a complete unicode code point is read.\nbool ReadCodePoint(StringPiece str, int index,\n                   uint32 *cp, int* num_left, int *num_read) {\n  if (*num_left == 0) {\n    // Last read was complete. Start reading a new unicode code point.\n    *cp = static_cast<uint8>(str[index++]);\n    *num_read = 1;\n    // The length of the code point is determined from reading the first byte.\n    //\n    // If the first byte is between:\n    //    0..0x7f: that's the value of the code point.\n    // 0x80..0xbf: <invalid>\n    // 0xc0..0xdf: 11-bit code point encoded in 2 bytes.\n    //                                   bit 10-6, bit 5-0\n    // 0xe0..0xef: 16-bit code point encoded in 3 bytes.\n    //                        bit 15-12, bit 11-6, bit 5-0\n    // 0xf0..0xf7: 21-bit code point encoded in 4 bytes.\n    //             bit 20-18, bit 17-12, bit 11-6, bit 5-0\n    // 0xf8..0xff: <invalid>\n    //\n    // Meaning of each bit:\n    // <msb> bit 7: 0 - single byte code point: bits 6-0 are values.\n    //              1 - multibyte code point\n    //       bit 6: 0 - subsequent bytes of multibyte code point:\n    //                  bits 5-0 are values.\n    //              1 - first byte of multibyte code point\n    //       bit 5: 0 - first byte of 2-byte code point: bits 4-0 are values.\n    //              1 - first byte of code point with >= 3 bytes.\n    //       bit 4: 0 - first byte of 3-byte code point: bits 3-0 are values.\n    //              1 - first byte of code point with >= 4 bytes.\n    //       bit 3: 0 - first byte of 4-byte code point: bits 2-0 are values.\n    //              1 - reserved for future expansion.\n    if (*cp <= 0x7f) {\n      return true;\n    } else if (*cp <= 0xbf) {\n      return false;\n    } else if (*cp <= 0xdf) {\n      *cp &= 0x1f;\n      *num_left = 1;\n    } else if (*cp <= 0xef) {\n      *cp &= 0x0f;\n      *num_left = 2;\n    } else if (*cp <= 0xf7) {\n      *cp &= 0x07;\n      *num_left = 3;\n    } else {\n      return false;\n    }\n  } else {\n    // Last read was partial. Initialize num_read to 0 and continue reading\n    // the last unicode code point.\n    *num_read = 0;\n  }\n  while (*num_left > 0 && index < str.size()) {\n    uint32 ch = static_cast<uint8>(str[index++]);\n    --(*num_left);\n    ++(*num_read);\n    *cp = (*cp << 6) | (ch & 0x3f);\n    if (ch < 0x80 || ch > 0xbf) return false;\n  }\n  return *num_left > 0 || (!IsSurrogate(*cp) && IsValidCodePoint(*cp));\n}\n\n// Stores the 16-bit unicode code point as its hexadecimal digits in buffer\n// and returns a StringPiece that points to this buffer. The input buffer needs\n// to be at least 6 bytes long.\nStringPiece ToHex(uint16 cp, char* buffer) {\n  buffer[5] = kHex[cp & 0x0f];\n  cp >>= 4;\n  buffer[4] = kHex[cp & 0x0f];\n  cp >>= 4;\n  buffer[3] = kHex[cp & 0x0f];\n  cp >>= 4;\n  buffer[2] = kHex[cp & 0x0f];\n  return StringPiece(buffer).substr(0, 6);\n}\n\n// Stores the 32-bit unicode code point as its hexadecimal digits in buffer\n// and returns a StringPiece that points to this buffer. The input buffer needs\n// to be at least 12 bytes long.\nStringPiece ToSurrogateHex(uint32 cp, char* buffer) {\n  uint16 low = ToLowSurrogate(cp);\n  uint16 high = ToHighSurrogate(cp);\n\n  buffer[11] = kHex[low & 0x0f];\n  low >>= 4;\n  buffer[10] = kHex[low & 0x0f];\n  low >>= 4;\n  buffer[9] = kHex[low & 0x0f];\n  low >>= 4;\n  buffer[8] = kHex[low & 0x0f];\n\n  buffer[5] = kHex[high & 0x0f];\n  high >>= 4;\n  buffer[4] = kHex[high & 0x0f];\n  high >>= 4;\n  buffer[3] = kHex[high & 0x0f];\n  high >>= 4;\n  buffer[2] = kHex[high & 0x0f];\n\n  return StringPiece(buffer, 12);\n}\n\n// If the given unicode code point needs escaping, then returns the\n// escaped form. The returned StringPiece either points to statically\n// pre-allocated char[] or to the given buffer. The input buffer needs\n// to be at least 12 bytes long.\n//\n// If the given unicode code point does not need escaping, an empty\n// StringPiece is returned.\nStringPiece EscapeCodePoint(uint32 cp, char* buffer) {\n  if (cp < 0xa0) return kCommonEscapes[cp];\n  switch (cp) {\n    // These are not required by json spec\n    // but used to prevent security bugs in javascript.\n    case 0xfeff:  // Zero width no-break space\n    case 0xfff9:  // Interlinear annotation anchor\n    case 0xfffa:  // Interlinear annotation separator\n    case 0xfffb:  // Interlinear annotation terminator\n\n    case 0x00ad:  // Soft-hyphen\n    case 0x06dd:  // Arabic end of ayah\n    case 0x070f:  // Syriac abbreviation mark\n    case 0x17b4:  // Khmer vowel inherent Aq\n    case 0x17b5:  // Khmer vowel inherent Aa\n      return ToHex(cp, buffer);\n\n    default:\n      if ((cp >= 0x0600 && cp <= 0x0603) ||  // Arabic signs\n          (cp >= 0x200b && cp <= 0x200f) ||  // Zero width etc.\n          (cp >= 0x2028 && cp <= 0x202e) ||  // Separators etc.\n          (cp >= 0x2060 && cp <= 0x2064) ||  // Invisible etc.\n          (cp >= 0x206a && cp <= 0x206f)) {  // Shaping etc.\n        return ToHex(cp, buffer);\n      }\n\n      if (cp == 0x000e0001 ||                        // Language tag\n          (cp >= 0x0001d173 && cp <= 0x0001d17a) ||  // Music formatting\n          (cp >= 0x000e0020 && cp <= 0x000e007f)) {  // TAG symbols\n        return ToSurrogateHex(cp, buffer);\n      }\n  }\n  return StringPiece();\n}\n\n// Tries to escape the given code point first. If the given code point\n// does not need to be escaped, but force_output is true, then render\n// the given multi-byte code point in UTF8 in the buffer and returns it.\nStringPiece EscapeCodePoint(uint32 cp, char* buffer, bool force_output) {\n  StringPiece sp = EscapeCodePoint(cp, buffer);\n  if (force_output && sp.empty()) {\n    buffer[5] = (cp & 0x3f) | 0x80;\n    cp >>= 6;\n    if (cp <= 0x1f) {\n      buffer[4] = cp | 0xc0;\n      sp.set(buffer + 4, 2);\n      return sp;\n    }\n    buffer[4] = (cp & 0x3f) | 0x80;\n    cp >>= 6;\n    if (cp <= 0x0f) {\n      buffer[3] = cp | 0xe0;\n      sp.set(buffer + 3, 3);\n      return sp;\n    }\n    buffer[3] = (cp & 0x3f) | 0x80;\n    buffer[2] = ((cp >> 6) & 0x07) | 0xf0;\n    sp.set(buffer + 2, 4);\n  }\n  return sp;\n}\n\n}  // namespace\n\nvoid JsonEscaping::Escape(strings::ByteSource* input,\n                          strings::ByteSink* output) {\n  char buffer[12] = \"\\\\udead\\\\ubee\";\n  uint32 cp = 0;     // Current unicode code point.\n  int num_left = 0;  // Num of chars to read to complete the code point.\n  while (input->Available() > 0) {\n    StringPiece str = input->Peek();\n    StringPiece escaped;\n    int i = 0;\n    int num_read;\n    bool ok;\n    bool cp_was_split = num_left > 0;\n    // Loop until we encounter either\n    //   i) a code point that needs to be escaped; or\n    //  ii) a split code point is completely read; or\n    // iii) a character that is not a valid utf8; or\n    //  iv) end of the StringPiece str is reached.\n    do {\n      ok = ReadCodePoint(str, i, &cp, &num_left, &num_read);\n      if (num_left > 0 || !ok) break;  // case iii or iv\n      escaped = EscapeCodePoint(cp, buffer, cp_was_split);\n      if (!escaped.empty()) break;     // case i or ii\n      i += num_read;\n      num_read = 0;\n    } while (i < str.length());        // case iv\n    // First copy the un-escaped prefix, if any, to the output ByteSink.\n    if (i > 0) input->CopyTo(output, i);\n    if (num_read > 0) input->Skip(num_read);\n    if (!ok) {\n      // Case iii: Report error.\n      // TODO(wpoon): Add error reporting.\n      num_left = 0;\n    } else if (num_left == 0 && !escaped.empty()) {\n      // Case i or ii: Append the escaped code point to the output ByteSink.\n      output->Append(escaped.data(), escaped.size());\n    }\n  }\n  if (num_left > 0) {\n    // Treat as case iii: report error.\n    // TODO(wpoon): Add error reporting.\n  }\n}\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/json_escaping.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef NET_PROTO2_UTIL_CONVERTER_STRINGS_JSON_ESCAPING_H_\n#define NET_PROTO2_UTIL_CONVERTER_STRINGS_JSON_ESCAPING_H_\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/bytestream.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\nclass JsonEscaping {\n public:\n  // The minimum value of a unicode high-surrogate code unit in the utf-16\n  // encoding. A high-surrogate is also known as a leading-surrogate.\n  // See http://www.unicode.org/glossary/#high_surrogate_code_unit\n  static const uint16 kMinHighSurrogate = 0xd800;\n\n  // The maximum value of a unicide high-surrogate code unit in the utf-16\n  // encoding. A high-surrogate is also known as a leading-surrogate.\n  // See http://www.unicode.org/glossary/#high_surrogate_code_unit\n  static const uint16 kMaxHighSurrogate = 0xdbff;\n\n  // The minimum value of a unicode low-surrogate code unit in the utf-16\n  // encoding. A low-surrogate is also known as a trailing-surrogate.\n  // See http://www.unicode.org/glossary/#low_surrogate_code_unit\n  static const uint16 kMinLowSurrogate = 0xdc00;\n\n  // The maximum value of a unicode low-surrogate code unit in the utf-16\n  // encoding. A low-surrogate is also known as a trailing surrogate.\n  // See http://www.unicode.org/glossary/#low_surrogate_code_unit\n  static const uint16 kMaxLowSurrogate = 0xdfff;\n\n  // The minimum value of a unicode supplementary code point.\n  // See http://www.unicode.org/glossary/#supplementary_code_point\n  static const uint32 kMinSupplementaryCodePoint = 0x010000;\n\n  // The minimum value of a unicode code point.\n  // See http://www.unicode.org/glossary/#code_point\n  static const uint32 kMinCodePoint = 0x000000;\n\n  // The maximum value of a unicode code point.\n  // See http://www.unicode.org/glossary/#code_point\n  static const uint32 kMaxCodePoint = 0x10ffff;\n\n  JsonEscaping() {}\n  virtual ~JsonEscaping() {}\n\n  // Escape the given ByteSource to the given ByteSink.\n  static void Escape(strings::ByteSource* input, strings::ByteSink* output);\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(JsonEscaping);\n};\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n\n#endif  // NET_PROTO2_UTIL_CONVERTER_STRINGS_JSON_ESCAPING_H_\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/json_objectwriter.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/internal/json_objectwriter.h>\n\n#include <math.h>\n\n#include <google/protobuf/stubs/casts.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/util/internal/utility.h>\n#include <google/protobuf/util/internal/json_escaping.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/mathlimits.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\nusing strings::ArrayByteSource;\n;\n\nJsonObjectWriter::~JsonObjectWriter() {\n  if (!element_->is_root()) {\n    GOOGLE_LOG(WARNING) << \"JsonObjectWriter was not fully closed.\";\n  }\n}\n\nJsonObjectWriter* JsonObjectWriter::StartObject(StringPiece name) {\n  WritePrefix(name);\n  WriteChar('{');\n  Push();\n  return this;\n}\n\nJsonObjectWriter* JsonObjectWriter::EndObject() {\n  Pop();\n  WriteChar('}');\n  if (element()->is_root()) NewLine();\n  return this;\n}\n\nJsonObjectWriter* JsonObjectWriter::StartList(StringPiece name) {\n  WritePrefix(name);\n  WriteChar('[');\n  Push();\n  return this;\n}\n\nJsonObjectWriter* JsonObjectWriter::EndList() {\n  Pop();\n  WriteChar(']');\n  if (element()->is_root()) NewLine();\n  return this;\n}\n\nJsonObjectWriter* JsonObjectWriter::RenderBool(StringPiece name, bool value) {\n  return RenderSimple(name, value ? \"true\" : \"false\");\n}\n\nJsonObjectWriter* JsonObjectWriter::RenderInt32(StringPiece name, int32 value) {\n  return RenderSimple(name, SimpleItoa(value));\n}\n\nJsonObjectWriter* JsonObjectWriter::RenderUint32(StringPiece name,\n                                                 uint32 value) {\n  return RenderSimple(name, SimpleItoa(value));\n}\n\nJsonObjectWriter* JsonObjectWriter::RenderInt64(StringPiece name, int64 value) {\n  WritePrefix(name);\n  WriteChar('\"');\n  stream_->WriteString(SimpleItoa(value));\n  WriteChar('\"');\n  return this;\n}\n\nJsonObjectWriter* JsonObjectWriter::RenderUint64(StringPiece name,\n                                                 uint64 value) {\n  WritePrefix(name);\n  WriteChar('\"');\n  stream_->WriteString(SimpleItoa(value));\n  WriteChar('\"');\n  return this;\n}\n\nJsonObjectWriter* JsonObjectWriter::RenderDouble(StringPiece name,\n                                                 double value) {\n  if (MathLimits<double>::IsFinite(value)) {\n    return RenderSimple(name, SimpleDtoa(value));\n  }\n\n  // Render quoted with NaN/Infinity-aware DoubleAsString.\n  return RenderString(name, DoubleAsString(value));\n}\n\nJsonObjectWriter* JsonObjectWriter::RenderFloat(StringPiece name, float value) {\n  if (MathLimits<float>::IsFinite(value)) {\n    return RenderSimple(name, SimpleFtoa(value));\n  }\n\n  // Render quoted with NaN/Infinity-aware FloatAsString.\n  return RenderString(name, FloatAsString(value));\n}\n\nJsonObjectWriter* JsonObjectWriter::RenderString(StringPiece name,\n                                                 StringPiece value) {\n  WritePrefix(name);\n  WriteChar('\"');\n  ArrayByteSource source(value);\n  JsonEscaping::Escape(&source, &sink_);\n  WriteChar('\"');\n  return this;\n}\n\nJsonObjectWriter* JsonObjectWriter::RenderBytes(StringPiece name,\n                                                StringPiece value) {\n  WritePrefix(name);\n  string base64;\n\n  if (use_websafe_base64_for_bytes_)\n    WebSafeBase64Escape(value.ToString(), &base64);\n  else\n    Base64Escape(value, &base64);\n\n  WriteChar('\"');\n  // TODO(wpoon): Consider a ByteSink solution that writes the base64 bytes\n  //              directly to the stream, rather than first putting them\n  //              into a string and then writing them to the stream.\n  stream_->WriteRaw(base64.data(), base64.size());\n  WriteChar('\"');\n  return this;\n}\n\nJsonObjectWriter* JsonObjectWriter::RenderNull(StringPiece name) {\n  return RenderSimple(name, \"null\");\n}\n\nvoid JsonObjectWriter::WritePrefix(StringPiece name) {\n  bool not_first = !element()->is_first();\n  if (not_first) WriteChar(',');\n  if (not_first || !element()->is_root()) NewLine();\n  if (!name.empty()) {\n    WriteChar('\"');\n    ArrayByteSource source(name);\n    JsonEscaping::Escape(&source, &sink_);\n    stream_->WriteString(\"\\\":\");\n    if (!indent_string_.empty()) WriteChar(' ');\n  }\n}\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/json_objectwriter.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_OBJECTWRITER_H__\n#define GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_OBJECTWRITER_H__\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <string>\n\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/util/internal/structured_objectwriter.h>\n#include <google/protobuf/stubs/bytestream.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\n// An ObjectWriter implementation that outputs JSON. This ObjectWriter\n// supports writing a compact form or a pretty printed form.\n//\n// Sample usage:\n//   string output;\n//   StringOutputStream* str_stream = new StringOutputStream(&output);\n//   CodedOutputStream* out_stream = new CodedOutputStream(str_stream);\n//   JsonObjectWriter* ow = new JsonObjectWriter(\"  \", out_stream);\n//   ow->StartObject(\"\")\n//       ->RenderString(\"name\", \"value\")\n//       ->RenderString(\"emptystring\", string())\n//       ->StartObject(\"nested\")\n//         ->RenderInt64(\"light\", 299792458);\n//         ->RenderDouble(\"pi\", 3.141592653589793);\n//       ->EndObject()\n//       ->StartList(\"empty\")\n//       ->EndList()\n//     ->EndObject();\n//\n// And then the output string would become:\n// {\n//   \"name\": \"value\",\n//   \"emptystring\": \"\",\n//   \"nested\": {\n//     \"light\": \"299792458\",\n//     \"pi\": 3.141592653589793\n//   },\n//   \"empty\": []\n// }\n//\n// JsonObjectWriter does not validate if calls actually result in valid JSON.\n// For example, passing an empty name when one would be required won't result\n// in an error, just an invalid output.\n//\n// Note that all int64 and uint64 are rendered as strings instead of numbers.\n// This is because JavaScript parses numbers as 64-bit float thus int64 and\n// uint64 would lose precision if rendered as numbers.\n//\n// JsonObjectWriter is thread-unsafe.\nclass LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {\n public:\n  JsonObjectWriter(StringPiece indent_string,\n                   google::protobuf::io::CodedOutputStream* out)\n      : element_(new Element(NULL)),\n        stream_(out),\n        sink_(out),\n        indent_string_(indent_string.ToString()),\n        use_websafe_base64_for_bytes_(false) {}\n  virtual ~JsonObjectWriter();\n\n  // ObjectWriter methods.\n  virtual JsonObjectWriter* StartObject(StringPiece name);\n  virtual JsonObjectWriter* EndObject();\n  virtual JsonObjectWriter* StartList(StringPiece name);\n  virtual JsonObjectWriter* EndList();\n  virtual JsonObjectWriter* RenderBool(StringPiece name, bool value);\n  virtual JsonObjectWriter* RenderInt32(StringPiece name, int32 value);\n  virtual JsonObjectWriter* RenderUint32(StringPiece name, uint32 value);\n  virtual JsonObjectWriter* RenderInt64(StringPiece name, int64 value);\n  virtual JsonObjectWriter* RenderUint64(StringPiece name, uint64 value);\n  virtual JsonObjectWriter* RenderDouble(StringPiece name, double value);\n  virtual JsonObjectWriter* RenderFloat(StringPiece name, float value);\n  virtual JsonObjectWriter* RenderString(StringPiece name, StringPiece value);\n  virtual JsonObjectWriter* RenderBytes(StringPiece name, StringPiece value);\n  virtual JsonObjectWriter* RenderNull(StringPiece name);\n\n  void set_use_websafe_base64_for_bytes(bool value) {\n    use_websafe_base64_for_bytes_ = value;\n  }\n\n protected:\n  class LIBPROTOBUF_EXPORT Element : public BaseElement {\n   public:\n    explicit Element(Element* parent) : BaseElement(parent), is_first_(true) {}\n\n    // Called before each field of the Element is to be processed.\n    // Returns true if this is the first call (processing the first field).\n    bool is_first() {\n      if (is_first_) {\n        is_first_ = false;\n        return true;\n      }\n      return false;\n    }\n\n   private:\n    bool is_first_;\n\n    GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(Element);\n  };\n\n  virtual Element* element() { return element_.get(); }\n\n private:\n  class LIBPROTOBUF_EXPORT ByteSinkWrapper : public strings::ByteSink {\n   public:\n    explicit ByteSinkWrapper(google::protobuf::io::CodedOutputStream* stream)\n        : stream_(stream) {}\n    virtual ~ByteSinkWrapper() {}\n\n    // ByteSink methods.\n    virtual void Append(const char* bytes, size_t n) {\n      stream_->WriteRaw(bytes, n);\n    }\n\n   private:\n    google::protobuf::io::CodedOutputStream* stream_;\n\n    GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ByteSinkWrapper);\n  };\n\n  // Renders a simple value as a string. By default all non-string Render\n  // methods convert their argument to a string and call this method. This\n  // method can then be used to render the simple value without escaping it.\n  JsonObjectWriter* RenderSimple(StringPiece name, const string& value) {\n    WritePrefix(name);\n    stream_->WriteString(value);\n    return this;\n  }\n\n  // Pushes a new element to the stack.\n  void Push() { element_.reset(new Element(element_.release())); }\n\n  // Pops an element off of the stack and deletes the popped element.\n  void Pop() {\n    bool needs_newline = !element_->is_first();\n    element_.reset(element_->pop<Element>());\n    if (needs_newline) NewLine();\n  }\n\n  // If pretty printing is enabled, this will write a newline to the output,\n  // followed by optional indentation. Otherwise this method is a noop.\n  void NewLine() {\n    if (!indent_string_.empty()) {\n      WriteChar('\\n');\n      for (int i = 0; i < element()->level(); i++) {\n        stream_->WriteString(indent_string_);\n      }\n    }\n  }\n\n  // Writes a prefix. This will write out any pretty printing and\n  // commas that are required, followed by the name and a ':' if\n  // the name is not null.\n  void WritePrefix(StringPiece name);\n\n  // Writes an individual character to the output.\n  void WriteChar(const char c) { stream_->WriteRaw(&c, sizeof(c)); }\n\n  google::protobuf::scoped_ptr<Element> element_;\n  google::protobuf::io::CodedOutputStream* stream_;\n  ByteSinkWrapper sink_;\n  const string indent_string_;\n\n  // Whether to use regular or websafe base64 encoding for byte fields. Defaults\n  // to regular base64 encoding.\n  bool use_websafe_base64_for_bytes_;\n\n  GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(JsonObjectWriter);\n};\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_OBJECTWRITER_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/json_objectwriter_test.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/internal/json_objectwriter.h>\n\n#include <google/protobuf/io/zero_copy_stream_impl_lite.h>\n#include <google/protobuf/util/internal/utility.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\nusing google::protobuf::io::CodedOutputStream;\nusing google::protobuf::io::StringOutputStream;\n\nclass JsonObjectWriterTest : public ::testing::Test {\n protected:\n  JsonObjectWriterTest()\n      : str_stream_(new StringOutputStream(&output_)),\n        out_stream_(new CodedOutputStream(str_stream_)),\n        ow_(NULL) {}\n\n  virtual ~JsonObjectWriterTest() {\n    delete ow_;\n    delete out_stream_;\n    delete str_stream_;\n  }\n\n  string output_;\n  StringOutputStream* const str_stream_;\n  CodedOutputStream* const out_stream_;\n  JsonObjectWriter* ow_;\n};\n\nTEST_F(JsonObjectWriterTest, EmptyRootObject) {\n  ow_ = new JsonObjectWriter(\"\", out_stream_);\n  ow_->StartObject(\"\")->EndObject();\n  EXPECT_EQ(\"{}\", output_.substr(0, out_stream_->ByteCount()));\n}\n\nTEST_F(JsonObjectWriterTest, EmptyObject) {\n  ow_ = new JsonObjectWriter(\"\", out_stream_);\n  ow_->StartObject(\"\")\n      ->RenderString(\"test\", \"value\")\n      ->StartObject(\"empty\")\n      ->EndObject()\n      ->EndObject();\n  EXPECT_EQ(\"{\\\"test\\\":\\\"value\\\",\\\"empty\\\":{}}\",\n            output_.substr(0, out_stream_->ByteCount()));\n}\n\nTEST_F(JsonObjectWriterTest, EmptyRootList) {\n  ow_ = new JsonObjectWriter(\"\", out_stream_);\n  ow_->StartList(\"\")->EndList();\n  EXPECT_EQ(\"[]\", output_.substr(0, out_stream_->ByteCount()));\n}\n\nTEST_F(JsonObjectWriterTest, EmptyList) {\n  ow_ = new JsonObjectWriter(\"\", out_stream_);\n  ow_->StartObject(\"\")\n      ->RenderString(\"test\", \"value\")\n      ->StartList(\"empty\")\n      ->EndList()\n      ->EndObject();\n  EXPECT_EQ(\"{\\\"test\\\":\\\"value\\\",\\\"empty\\\":[]}\",\n            output_.substr(0, out_stream_->ByteCount()));\n}\n\nTEST_F(JsonObjectWriterTest, ObjectInObject) {\n  ow_ = new JsonObjectWriter(\"\", out_stream_);\n  ow_->StartObject(\"\")\n      ->StartObject(\"nested\")\n      ->RenderString(\"field\", \"value\")\n      ->EndObject()\n      ->EndObject();\n  EXPECT_EQ(\"{\\\"nested\\\":{\\\"field\\\":\\\"value\\\"}}\",\n            output_.substr(0, out_stream_->ByteCount()));\n}\n\nTEST_F(JsonObjectWriterTest, ListInObject) {\n  ow_ = new JsonObjectWriter(\"\", out_stream_);\n  ow_->StartObject(\"\")\n      ->StartList(\"nested\")\n      ->RenderString(\"\", \"value\")\n      ->EndList()\n      ->EndObject();\n  EXPECT_EQ(\"{\\\"nested\\\":[\\\"value\\\"]}\",\n            output_.substr(0, out_stream_->ByteCount()));\n}\n\nTEST_F(JsonObjectWriterTest, ObjectInList) {\n  ow_ = new JsonObjectWriter(\"\", out_stream_);\n  ow_->StartList(\"\")\n      ->StartObject(\"\")\n      ->RenderString(\"field\", \"value\")\n      ->EndObject()\n      ->EndList();\n  EXPECT_EQ(\"[{\\\"field\\\":\\\"value\\\"}]\",\n            output_.substr(0, out_stream_->ByteCount()));\n}\n\nTEST_F(JsonObjectWriterTest, ListInList) {\n  ow_ = new JsonObjectWriter(\"\", out_stream_);\n  ow_->StartList(\"\")\n      ->StartList(\"\")\n      ->RenderString(\"\", \"value\")\n      ->EndList()\n      ->EndList();\n  EXPECT_EQ(\"[[\\\"value\\\"]]\", output_.substr(0, out_stream_->ByteCount()));\n}\n\nTEST_F(JsonObjectWriterTest, RenderPrimitives) {\n  ow_ = new JsonObjectWriter(\"\", out_stream_);\n  ow_->StartObject(\"\")\n      ->RenderBool(\"bool\", true)\n      ->RenderDouble(\"double\", std::numeric_limits<double>::max())\n      ->RenderFloat(\"float\", std::numeric_limits<float>::max())\n      ->RenderInt32(\"int\", std::numeric_limits<int32>::min())\n      ->RenderInt64(\"long\", std::numeric_limits<int64>::min())\n      ->RenderBytes(\"bytes\", \"abracadabra\")\n      ->RenderString(\"string\", \"string\")\n      ->RenderBytes(\"emptybytes\", \"\")\n      ->RenderString(\"emptystring\", string())\n      ->EndObject();\n  EXPECT_EQ(\n      \"{\\\"bool\\\":true,\"\n      \"\\\"double\\\":\" +\n          ValueAsString<double>(std::numeric_limits<double>::max()) +\n          \",\"\n          \"\\\"float\\\":\" +\n          ValueAsString<float>(std::numeric_limits<float>::max()) +\n          \",\"\n          \"\\\"int\\\":-2147483648,\"\n          \"\\\"long\\\":\\\"-9223372036854775808\\\",\"\n          \"\\\"bytes\\\":\\\"YWJyYWNhZGFicmE=\\\",\"\n          \"\\\"string\\\":\\\"string\\\",\"\n          \"\\\"emptybytes\\\":\\\"\\\",\"\n          \"\\\"emptystring\\\":\\\"\\\"}\",\n      output_.substr(0, out_stream_->ByteCount()));\n}\n\nTEST_F(JsonObjectWriterTest, BytesEncodesAsNonWebSafeBase64) {\n  string s;\n  s.push_back('\\377');\n  s.push_back('\\357');\n  ow_ = new JsonObjectWriter(\"\", out_stream_);\n  ow_->StartObject(\"\")->RenderBytes(\"bytes\", s)->EndObject();\n  // Non-web-safe would encode this as \"/+8=\"\n  EXPECT_EQ(\"{\\\"bytes\\\":\\\"/+8=\\\"}\",\n            output_.substr(0, out_stream_->ByteCount()));\n}\n\nTEST_F(JsonObjectWriterTest, PrettyPrintList) {\n  ow_ = new JsonObjectWriter(\" \", out_stream_);\n  ow_->StartObject(\"\")\n      ->StartList(\"items\")\n      ->RenderString(\"\", \"item1\")\n      ->RenderString(\"\", \"item2\")\n      ->RenderString(\"\", \"item3\")\n      ->EndList()\n      ->StartList(\"empty\")\n      ->EndList()\n      ->EndObject();\n  EXPECT_EQ(\n      \"{\\n\"\n      \" \\\"items\\\": [\\n\"\n      \"  \\\"item1\\\",\\n\"\n      \"  \\\"item2\\\",\\n\"\n      \"  \\\"item3\\\"\\n\"\n      \" ],\\n\"\n      \" \\\"empty\\\": []\\n\"\n      \"}\\n\",\n      output_.substr(0, out_stream_->ByteCount()));\n}\n\nTEST_F(JsonObjectWriterTest, PrettyPrintObject) {\n  ow_ = new JsonObjectWriter(\" \", out_stream_);\n  ow_->StartObject(\"\")\n      ->StartObject(\"items\")\n      ->RenderString(\"key1\", \"item1\")\n      ->RenderString(\"key2\", \"item2\")\n      ->RenderString(\"key3\", \"item3\")\n      ->EndObject()\n      ->StartObject(\"empty\")\n      ->EndObject()\n      ->EndObject();\n  EXPECT_EQ(\n      \"{\\n\"\n      \" \\\"items\\\": {\\n\"\n      \"  \\\"key1\\\": \\\"item1\\\",\\n\"\n      \"  \\\"key2\\\": \\\"item2\\\",\\n\"\n      \"  \\\"key3\\\": \\\"item3\\\"\\n\"\n      \" },\\n\"\n      \" \\\"empty\\\": {}\\n\"\n      \"}\\n\",\n      output_.substr(0, out_stream_->ByteCount()));\n}\n\nTEST_F(JsonObjectWriterTest, PrettyPrintEmptyObjectInEmptyList) {\n  ow_ = new JsonObjectWriter(\" \", out_stream_);\n  ow_->StartObject(\"\")\n      ->StartList(\"list\")\n      ->StartObject(\"\")\n      ->EndObject()\n      ->EndList()\n      ->EndObject();\n  EXPECT_EQ(\n      \"{\\n\"\n      \" \\\"list\\\": [\\n\"\n      \"  {}\\n\"\n      \" ]\\n\"\n      \"}\\n\",\n      output_.substr(0, out_stream_->ByteCount()));\n}\n\nTEST_F(JsonObjectWriterTest, PrettyPrintDoubleIndent) {\n  ow_ = new JsonObjectWriter(\"  \", out_stream_);\n  ow_->StartObject(\"\")\n      ->RenderBool(\"bool\", true)\n      ->RenderInt32(\"int\", 42)\n      ->EndObject();\n  EXPECT_EQ(\n      \"{\\n\"\n      \"  \\\"bool\\\": true,\\n\"\n      \"  \\\"int\\\": 42\\n\"\n      \"}\\n\",\n      output_.substr(0, out_stream_->ByteCount()));\n}\n\nTEST_F(JsonObjectWriterTest, StringsEscapedAndEnclosedInDoubleQuotes) {\n  ow_ = new JsonObjectWriter(\"\", out_stream_);\n  ow_->StartObject(\"\")->RenderString(\"string\", \"'<>&amp;\\\\\\\"\\r\\n\")->EndObject();\n  EXPECT_EQ(\"{\\\"string\\\":\\\"'\\\\u003c\\\\u003e&amp;\\\\\\\\\\\\\\\"\\\\r\\\\n\\\"}\",\n            output_.substr(0, out_stream_->ByteCount()));\n}\n\nTEST_F(JsonObjectWriterTest, Stringification) {\n  ow_ = new JsonObjectWriter(\"\", out_stream_);\n  ow_->StartObject(\"\")\n      ->RenderDouble(\"double_nan\", std::numeric_limits<double>::quiet_NaN())\n      ->RenderFloat(\"float_nan\", std::numeric_limits<float>::quiet_NaN())\n      ->RenderDouble(\"double_pos\", std::numeric_limits<double>::infinity())\n      ->RenderFloat(\"float_pos\", std::numeric_limits<float>::infinity())\n      ->RenderDouble(\"double_neg\", -std::numeric_limits<double>::infinity())\n      ->RenderFloat(\"float_neg\", -std::numeric_limits<float>::infinity())\n      ->EndObject();\n  EXPECT_EQ(\n      \"{\\\"double_nan\\\":\\\"NaN\\\",\"\n      \"\\\"float_nan\\\":\\\"NaN\\\",\"\n      \"\\\"double_pos\\\":\\\"Infinity\\\",\"\n      \"\\\"float_pos\\\":\\\"Infinity\\\",\"\n      \"\\\"double_neg\\\":\\\"-Infinity\\\",\"\n      \"\\\"float_neg\\\":\\\"-Infinity\\\"}\",\n      output_.substr(0, out_stream_->ByteCount()));\n}\n\nTEST_F(JsonObjectWriterTest, TestRegularByteEncoding) {\n  ow_ = new JsonObjectWriter(\"\", out_stream_);\n  ow_->StartObject(\"\")\n      ->RenderBytes(\"bytes\", \"\\x03\\xef\\xc0\")\n      ->EndObject();\n\n  // Test that we get regular (non websafe) base64 encoding on byte fields by\n  // default.\n  EXPECT_EQ(\"{\\\"bytes\\\":\\\"A+/A\\\"}\",\n            output_.substr(0, out_stream_->ByteCount()));\n}\n\nTEST_F(JsonObjectWriterTest, TestWebsafeByteEncoding) {\n  ow_ = new JsonObjectWriter(\"\", out_stream_);\n  ow_->set_use_websafe_base64_for_bytes(true);\n  ow_->StartObject(\"\")\n      ->RenderBytes(\"bytes\", \"\\x03\\xef\\xc0\")\n      ->EndObject();\n\n  // Test that we get websafe base64 encoding when explicitly asked.\n  EXPECT_EQ(\"{\\\"bytes\\\":\\\"A-_A\\\"}\",\n            output_.substr(0, out_stream_->ByteCount()));\n}\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/json_stream_parser.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/internal/json_stream_parser.h>\n\n#include <algorithm>\n#include <cctype>\n#include <cerrno>\n#include <cstdlib>\n#include <cstring>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/util/internal/object_writer.h>\n#include <google/protobuf/util/internal/json_escaping.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\n\n// Allow these symbols to be referenced as util::Status, util::error::* in\n// this file.\nusing util::Status;\nnamespace error {\nusing util::error::INTERNAL;\nusing util::error::INVALID_ARGUMENT;\n}  // namespace error\n\nnamespace converter {\n\n// Number of digits in an escaped UTF-16 code unit ('\\\\' 'u' X X X X)\nstatic const int kUnicodeEscapedLength = 6;\n\n// Length of the true, false, and null literals.\nstatic const int true_len = strlen(\"true\");\nstatic const int false_len = strlen(\"false\");\nstatic const int null_len = strlen(\"null\");\n\ninline bool IsLetter(char c) {\n  return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || (c == '_') ||\n         (c == '$');\n}\n\ninline bool IsAlphanumeric(char c) {\n  return IsLetter(c) || ('0' <= c && c <= '9');\n}\n\nstatic bool ConsumeKey(StringPiece* input, StringPiece* key) {\n  if (input->empty() || !IsLetter((*input)[0])) return false;\n  int len = 1;\n  for (; len < input->size(); ++len) {\n    if (!IsAlphanumeric((*input)[len])) {\n      break;\n    }\n  }\n  *key = StringPiece(input->data(), len);\n  *input = StringPiece(input->data() + len, input->size() - len);\n  return true;\n}\n\nstatic bool MatchKey(StringPiece input) {\n  return !input.empty() && IsLetter(input[0]);\n}\n\nJsonStreamParser::JsonStreamParser(ObjectWriter* ow)\n    : ow_(ow),\n      stack_(),\n      leftover_(),\n      json_(),\n      p_(),\n      key_(),\n      key_storage_(),\n      finishing_(false),\n      parsed_(),\n      parsed_storage_(),\n      string_open_(0),\n      chunk_storage_(),\n      coerce_to_utf8_(false) {\n  // Initialize the stack with a single value to be parsed.\n  stack_.push(VALUE);\n}\n\nJsonStreamParser::~JsonStreamParser() {}\n\n\nutil::Status JsonStreamParser::Parse(StringPiece json) {\n  StringPiece chunk = json;\n  // If we have leftovers from a previous chunk, append the new chunk to it\n  // and create a new StringPiece pointing at the string's data. This could\n  // be large but we rely on the chunks to be small, assuming they are\n  // fragments of a Cord.\n  if (!leftover_.empty()) {\n    // Don't point chunk to leftover_ because leftover_ will be updated in\n    // ParseChunk(chunk).\n    chunk_storage_.swap(leftover_);\n    json.AppendToString(&chunk_storage_);\n    chunk = StringPiece(chunk_storage_);\n  }\n\n  // Find the structurally valid UTF8 prefix and parse only that.\n  int n = internal::UTF8SpnStructurallyValid(chunk);\n  if (n > 0) {\n    util::Status status = ParseChunk(chunk.substr(0, n));\n\n    // Any leftover characters are stashed in leftover_ for later parsing when\n    // there is more data available.\n    chunk.substr(n).AppendToString(&leftover_);\n    return status;\n  } else {\n    chunk.CopyToString(&leftover_);\n    return util::Status::OK;\n  }\n}\n\nutil::Status JsonStreamParser::FinishParse() {\n  // If we do not expect anything and there is nothing left to parse we're all\n  // done.\n  if (stack_.empty() && leftover_.empty()) {\n    return util::Status::OK;\n  }\n\n  // Storage for UTF8-coerced string.\n  google::protobuf::scoped_array<char> utf8;\n  if (coerce_to_utf8_) {\n    utf8.reset(new char[leftover_.size()]);\n    char* coerced = internal::UTF8CoerceToStructurallyValid(leftover_, utf8.get(), ' ');\n    p_ = json_ = StringPiece(coerced, leftover_.size());\n  } else {\n    p_ = json_ = leftover_;\n    if (!internal::IsStructurallyValidUTF8(leftover_)) {\n      return ReportFailure(\"Encountered non UTF-8 code points.\");\n    }\n  }\n\n  // Parse the remainder in finishing mode, which reports errors for things like\n  // unterminated strings or unknown tokens that would normally be retried.\n  finishing_ = true;\n  util::Status result = RunParser();\n  if (result.ok()) {\n    SkipWhitespace();\n    if (!p_.empty()) {\n      result = ReportFailure(\"Parsing terminated before end of input.\");\n    }\n  }\n  return result;\n}\n\nutil::Status JsonStreamParser::ParseChunk(StringPiece chunk) {\n  // Do not do any work if the chunk is empty.\n  if (chunk.empty()) return util::Status::OK;\n\n  p_ = json_ = chunk;\n\n  finishing_ = false;\n  util::Status result = RunParser();\n  if (!result.ok()) return result;\n\n  SkipWhitespace();\n  if (p_.empty()) {\n    // If we parsed everything we had, clear the leftover.\n    leftover_.clear();\n  } else {\n    // If we do not expect anything i.e. stack is empty, and we have non-empty\n    // string left to parse, we report an error.\n    if (stack_.empty()) {\n      return ReportFailure(\"Parsing terminated before end of input.\");\n    }\n    // If we expect future data i.e. stack is non-empty, and we have some\n    // unparsed data left, we save it for later parse.\n    leftover_ = p_.ToString();\n  }\n  return util::Status::OK;\n}\n\nutil::Status JsonStreamParser::RunParser() {\n  while (!stack_.empty()) {\n    ParseType type = stack_.top();\n    TokenType t = (string_open_ == 0) ? GetNextTokenType() : BEGIN_STRING;\n    stack_.pop();\n    util::Status result;\n    switch (type) {\n      case VALUE:\n        result = ParseValue(t);\n        break;\n\n      case OBJ_MID:\n        result = ParseObjectMid(t);\n        break;\n\n      case ENTRY:\n        result = ParseEntry(t);\n        break;\n\n      case ENTRY_MID:\n        result = ParseEntryMid(t);\n        break;\n\n      case ARRAY_VALUE:\n        result = ParseArrayValue(t);\n        break;\n\n      case ARRAY_MID:\n        result = ParseArrayMid(t);\n        break;\n\n      default:\n        result = util::Status(util::error::INTERNAL,\n                              StrCat(\"Unknown parse type: \", type));\n        break;\n    }\n    if (!result.ok()) {\n      // If we were cancelled, save our state and try again later.\n      if (!finishing_ && result == util::Status::CANCELLED) {\n        stack_.push(type);\n        // If we have a key we still need to render, make sure to save off the\n        // contents in our own storage.\n        if (!key_.empty() && key_storage_.empty()) {\n          key_.AppendToString(&key_storage_);\n          key_ = StringPiece(key_storage_);\n        }\n        result = util::Status::OK;\n      }\n      return result;\n    }\n  }\n  return util::Status::OK;\n}\n\nutil::Status JsonStreamParser::ParseValue(TokenType type) {\n  switch (type) {\n    case BEGIN_OBJECT:\n      return HandleBeginObject();\n    case BEGIN_ARRAY:\n      return HandleBeginArray();\n    case BEGIN_STRING:\n      return ParseString();\n    case BEGIN_NUMBER:\n      return ParseNumber();\n    case BEGIN_TRUE:\n      return ParseTrue();\n    case BEGIN_FALSE:\n      return ParseFalse();\n    case BEGIN_NULL:\n      return ParseNull();\n    case UNKNOWN:\n      return ReportUnknown(\"Expected a value.\");\n    default: {\n      // Special case for having been cut off while parsing, wait for more data.\n      // This handles things like 'fals' being at the end of the string, we\n      // don't know if the next char would be e, completing it, or something\n      // else, making it invalid.\n      if (!finishing_ && p_.length() < false_len) {\n        return util::Status::CANCELLED;\n      }\n      return ReportFailure(\"Unexpected token.\");\n    }\n  }\n}\n\nutil::Status JsonStreamParser::ParseString() {\n  util::Status result = ParseStringHelper();\n  if (result.ok()) {\n    ow_->RenderString(key_, parsed_);\n    key_.clear();\n    parsed_.clear();\n    parsed_storage_.clear();\n  }\n  return result;\n}\n\nutil::Status JsonStreamParser::ParseStringHelper() {\n  // If we haven't seen the start quote, grab it and remember it for later.\n  if (string_open_ == 0) {\n    string_open_ = *p_.data();\n    GOOGLE_DCHECK(string_open_ == '\\\"' || string_open_ == '\\'');\n    Advance();\n  }\n  // Track where we last copied data from so we can minimize copying.\n  const char* last = p_.data();\n  while (!p_.empty()) {\n    const char* data = p_.data();\n    if (*data == '\\\\') {\n      // We're about to handle an escape, copy all bytes from last to data.\n      if (last < data) {\n        parsed_storage_.append(last, data - last);\n        last = data;\n      }\n      // If we ran out of string after the \\, cancel or report an error\n      // depending on if we expect more data later.\n      if (p_.length() == 1) {\n        if (!finishing_) {\n          return util::Status::CANCELLED;\n        }\n        return ReportFailure(\"Closing quote expected in string.\");\n      }\n      // Parse a unicode escape if we found \\u in the string.\n      if (data[1] == 'u') {\n        util::Status result = ParseUnicodeEscape();\n        if (!result.ok()) {\n          return result;\n        }\n        // Move last pointer past the unicode escape and continue.\n        last = p_.data();\n        continue;\n      }\n      // Handle the standard set of backslash-escaped characters.\n      switch (data[1]) {\n        case 'b':\n          parsed_storage_.push_back('\\b');\n          break;\n        case 'f':\n          parsed_storage_.push_back('\\f');\n          break;\n        case 'n':\n          parsed_storage_.push_back('\\n');\n          break;\n        case 'r':\n          parsed_storage_.push_back('\\r');\n          break;\n        case 't':\n          parsed_storage_.push_back('\\t');\n          break;\n        case 'v':\n          parsed_storage_.push_back('\\v');\n          break;\n        default:\n          parsed_storage_.push_back(data[1]);\n      }\n      // We handled two characters, so advance past them and continue.\n      p_.remove_prefix(2);\n      last = p_.data();\n      continue;\n    }\n    // If we found the closing quote note it, advance past it, and return.\n    if (*data == string_open_) {\n      // If we didn't copy anything, reuse the input buffer.\n      if (parsed_storage_.empty()) {\n        parsed_ = StringPiece(last, data - last);\n      } else {\n        if (last < data) {\n          parsed_storage_.append(last, data - last);\n          last = data;\n        }\n        parsed_ = StringPiece(parsed_storage_);\n      }\n      // Clear the quote char so next time we try to parse a string we'll\n      // start fresh.\n      string_open_ = 0;\n      Advance();\n      return util::Status::OK;\n    }\n    // Normal character, just advance past it.\n    Advance();\n  }\n  // If we ran out of characters, copy over what we have so far.\n  if (last < p_.data()) {\n    parsed_storage_.append(last, p_.data() - last);\n  }\n  // If we didn't find the closing quote but we expect more data, cancel for now\n  if (!finishing_) {\n    return util::Status::CANCELLED;\n  }\n  // End of string reached without a closing quote, report an error.\n  string_open_ = 0;\n  return ReportFailure(\"Closing quote expected in string.\");\n}\n\n// Converts a unicode escaped character to a decimal value stored in a char32\n// for use in UTF8 encoding utility.  We assume that str begins with \\uhhhh and\n// convert that from the hex number to a decimal value.\n//\n// There are some security exploits with UTF-8 that we should be careful of:\n//   - http://www.unicode.org/reports/tr36/#UTF-8_Exploit\n//   - http://sites/intl-eng/design-guide/core-application\nutil::Status JsonStreamParser::ParseUnicodeEscape() {\n  if (p_.length() < kUnicodeEscapedLength) {\n    if (!finishing_) {\n      return util::Status::CANCELLED;\n    }\n    return ReportFailure(\"Illegal hex string.\");\n  }\n  GOOGLE_DCHECK_EQ('\\\\', p_.data()[0]);\n  GOOGLE_DCHECK_EQ('u', p_.data()[1]);\n  uint32 code = 0;\n  for (int i = 2; i < kUnicodeEscapedLength; ++i) {\n    if (!isxdigit(p_.data()[i])) {\n      return ReportFailure(\"Invalid escape sequence.\");\n    }\n    code = (code << 4) + hex_digit_to_int(p_.data()[i]);\n  }\n  if (code >= JsonEscaping::kMinHighSurrogate &&\n      code <= JsonEscaping::kMaxHighSurrogate) {\n    if (p_.length() < 2 * kUnicodeEscapedLength) {\n      if (!finishing_) {\n        return util::Status::CANCELLED;\n      }\n      if (!coerce_to_utf8_) {\n        return ReportFailure(\"Missing low surrogate.\");\n      }\n    } else if (p_.data()[kUnicodeEscapedLength] == '\\\\' &&\n               p_.data()[kUnicodeEscapedLength + 1] == 'u') {\n      uint32 low_code = 0;\n      for (int i = kUnicodeEscapedLength + 2; i < 2 * kUnicodeEscapedLength;\n           ++i) {\n        if (!isxdigit(p_.data()[i])) {\n          return ReportFailure(\"Invalid escape sequence.\");\n        }\n        low_code = (low_code << 4) + hex_digit_to_int(p_.data()[i]);\n      }\n      if (low_code >= JsonEscaping::kMinLowSurrogate &&\n          low_code <= JsonEscaping::kMaxLowSurrogate) {\n        // Convert UTF-16 surrogate pair to 21-bit Unicode codepoint.\n        code = (((code & 0x3FF) << 10) | (low_code & 0x3FF)) +\n               JsonEscaping::kMinSupplementaryCodePoint;\n        // Advance past the first code unit escape.\n        p_.remove_prefix(kUnicodeEscapedLength);\n      } else if (!coerce_to_utf8_) {\n        return ReportFailure(\"Invalid low surrogate.\");\n      }\n    } else if (!coerce_to_utf8_) {\n      return ReportFailure(\"Missing low surrogate.\");\n    }\n  }\n  if (!coerce_to_utf8_ && !IsValidCodePoint(code)) {\n    return ReportFailure(\"Invalid unicode code point.\");\n  }\n  char buf[UTFmax];\n  int len = EncodeAsUTF8Char(code, buf);\n  // Advance past the [final] code unit escape.\n  p_.remove_prefix(kUnicodeEscapedLength);\n  parsed_storage_.append(buf, len);\n  return util::Status::OK;\n}\n\nutil::Status JsonStreamParser::ParseNumber() {\n  NumberResult number;\n  util::Status result = ParseNumberHelper(&number);\n  if (result.ok()) {\n    switch (number.type) {\n      case NumberResult::DOUBLE:\n        ow_->RenderDouble(key_, number.double_val);\n        key_.clear();\n        break;\n\n      case NumberResult::INT:\n        ow_->RenderInt64(key_, number.int_val);\n        key_.clear();\n        break;\n\n      case NumberResult::UINT:\n        ow_->RenderUint64(key_, number.uint_val);\n        key_.clear();\n        break;\n\n      default:\n        return ReportFailure(\"Unable to parse number.\");\n    }\n  }\n  return result;\n}\n\nutil::Status JsonStreamParser::ParseNumberHelper(NumberResult* result) {\n  const char* data = p_.data();\n  int length = p_.length();\n\n  // Look for the first non-numeric character, or the end of the string.\n  int index = 0;\n  bool floating = false;\n  bool negative = data[index] == '-';\n  // Find the first character that cannot be part of the number. Along the way\n  // detect if the number needs to be parsed as a double.\n  // Note that this restricts numbers to the JSON specification, so for example\n  // we do not support hex or octal notations.\n  for (; index < length; ++index) {\n    char c = data[index];\n    if (isdigit(c)) continue;\n    if (c == '.' || c == 'e' || c == 'E') {\n      floating = true;\n      continue;\n    }\n    if (c == '+' || c == '-' || c == 'x') continue;\n    // Not a valid number character, break out.\n    break;\n  }\n\n  // If the entire input is a valid number, and we may have more content in the\n  // future, we abort for now and resume when we know more.\n  if (index == length && !finishing_) {\n    return util::Status::CANCELLED;\n  }\n\n  // Create a string containing just the number, so we can use safe_strtoX\n  string number = p_.substr(0, index).ToString();\n\n  // Floating point number, parse as a double.\n  if (floating) {\n    if (!safe_strtod(number, &result->double_val)) {\n      return ReportFailure(\"Unable to parse number.\");\n    }\n    result->type = NumberResult::DOUBLE;\n    p_.remove_prefix(index);\n    return util::Status::OK;\n  }\n\n  // Positive non-floating point number, parse as a uint64.\n  if (!negative) {\n    // Octal/Hex numbers are not valid JSON values.\n    if (number.length() >= 2 && number[0] == '0') {\n      return ReportFailure(\"Octal/hex numbers are not valid JSON values.\");\n    }\n    if (!safe_strtou64(number, &result->uint_val)) {\n      return ReportFailure(\"Unable to parse number.\");\n    }\n    result->type = NumberResult::UINT;\n    p_.remove_prefix(index);\n    return util::Status::OK;\n  }\n\n  // Octal/Hex numbers are not valid JSON values.\n  if (number.length() >= 3 && number[1] == '0') {\n    return ReportFailure(\"Octal/hex numbers are not valid JSON values.\");\n  }\n  // Negative non-floating point number, parse as an int64.\n  if (!safe_strto64(number, &result->int_val)) {\n    return ReportFailure(\"Unable to parse number.\");\n  }\n  result->type = NumberResult::INT;\n  p_.remove_prefix(index);\n  return util::Status::OK;\n}\n\nutil::Status JsonStreamParser::HandleBeginObject() {\n  GOOGLE_DCHECK_EQ('{', *p_.data());\n  Advance();\n  ow_->StartObject(key_);\n  key_.clear();\n  stack_.push(ENTRY);\n  return util::Status::OK;\n}\n\nutil::Status JsonStreamParser::ParseObjectMid(TokenType type) {\n  if (type == UNKNOWN) {\n    return ReportUnknown(\"Expected , or } after key:value pair.\");\n  }\n\n  // Object is complete, advance past the comma and render the EndObject.\n  if (type == END_OBJECT) {\n    Advance();\n    ow_->EndObject();\n    return util::Status::OK;\n  }\n  // Found a comma, advance past it and get ready for an entry.\n  if (type == VALUE_SEPARATOR) {\n    Advance();\n    stack_.push(ENTRY);\n    return util::Status::OK;\n  }\n  // Illegal token after key:value pair.\n  return ReportFailure(\"Expected , or } after key:value pair.\");\n}\n\nutil::Status JsonStreamParser::ParseEntry(TokenType type) {\n  if (type == UNKNOWN) {\n    return ReportUnknown(\"Expected an object key or }.\");\n  }\n\n  // Close the object and return. This allows for trailing commas.\n  if (type == END_OBJECT) {\n    ow_->EndObject();\n    Advance();\n    return util::Status::OK;\n  }\n\n  util::Status result;\n  if (type == BEGIN_STRING) {\n    // Key is a string (standard JSON), parse it and store the string.\n    result = ParseStringHelper();\n    if (result.ok()) {\n      key_storage_.clear();\n      if (!parsed_storage_.empty()) {\n        parsed_storage_.swap(key_storage_);\n        key_ = StringPiece(key_storage_);\n      } else {\n        key_ = parsed_;\n      }\n      parsed_.clear();\n    }\n  } else if (type == BEGIN_KEY) {\n    // Key is a bare key (back compat), create a StringPiece pointing to it.\n    result = ParseKey();\n  } else {\n    // Unknown key type, report an error.\n    result = ReportFailure(\"Expected an object key or }.\");\n  }\n  // On success we next expect an entry mid ':' then an object mid ',' or '}'\n  if (result.ok()) {\n    stack_.push(OBJ_MID);\n    stack_.push(ENTRY_MID);\n  }\n  return result;\n}\n\nutil::Status JsonStreamParser::ParseEntryMid(TokenType type) {\n  if (type == UNKNOWN) {\n    return ReportUnknown(\"Expected : between key:value pair.\");\n  }\n  if (type == ENTRY_SEPARATOR) {\n    Advance();\n    stack_.push(VALUE);\n    return util::Status::OK;\n  }\n  return ReportFailure(\"Expected : between key:value pair.\");\n}\n\nutil::Status JsonStreamParser::HandleBeginArray() {\n  GOOGLE_DCHECK_EQ('[', *p_.data());\n  Advance();\n  ow_->StartList(key_);\n  key_.clear();\n  stack_.push(ARRAY_VALUE);\n  return util::Status::OK;\n}\n\nutil::Status JsonStreamParser::ParseArrayValue(TokenType type) {\n  if (type == UNKNOWN) {\n    return ReportUnknown(\"Expected a value or ] within an array.\");\n  }\n\n  if (type == END_ARRAY) {\n    ow_->EndList();\n    Advance();\n    return util::Status::OK;\n  }\n\n  // The ParseValue call may push something onto the stack so we need to make\n  // sure an ARRAY_MID is after it, so we push it on now.\n  stack_.push(ARRAY_MID);\n  util::Status result = ParseValue(type);\n  if (result == util::Status::CANCELLED) {\n    // If we were cancelled, pop back off the ARRAY_MID so we don't try to\n    // push it on again when we try over.\n    stack_.pop();\n  }\n  return result;\n}\n\nutil::Status JsonStreamParser::ParseArrayMid(TokenType type) {\n  if (type == UNKNOWN) {\n    return ReportUnknown(\"Expected , or ] after array value.\");\n  }\n\n  if (type == END_ARRAY) {\n    ow_->EndList();\n    Advance();\n    return util::Status::OK;\n  }\n\n  // Found a comma, advance past it and expect an array value next.\n  if (type == VALUE_SEPARATOR) {\n    Advance();\n    stack_.push(ARRAY_VALUE);\n    return util::Status::OK;\n  }\n  // Illegal token after array value.\n  return ReportFailure(\"Expected , or ] after array value.\");\n}\n\nutil::Status JsonStreamParser::ParseTrue() {\n  ow_->RenderBool(key_, true);\n  key_.clear();\n  p_.remove_prefix(true_len);\n  return util::Status::OK;\n}\n\nutil::Status JsonStreamParser::ParseFalse() {\n  ow_->RenderBool(key_, false);\n  key_.clear();\n  p_.remove_prefix(false_len);\n  return util::Status::OK;\n}\n\nutil::Status JsonStreamParser::ParseNull() {\n  ow_->RenderNull(key_);\n  key_.clear();\n  p_.remove_prefix(null_len);\n  return util::Status::OK;\n}\n\nutil::Status JsonStreamParser::ReportFailure(StringPiece message) {\n  static const int kContextLength = 20;\n  const char* p_start = p_.data();\n  const char* json_start = json_.data();\n  const char* begin = std::max(p_start - kContextLength, json_start);\n  const char* end =\n      std::min(p_start + kContextLength, json_start + json_.size());\n  StringPiece segment(begin, end - begin);\n  string location(p_start - begin, ' ');\n  location.push_back('^');\n  return util::Status(util::error::INVALID_ARGUMENT,\n                      StrCat(message, \"\\n\", segment, \"\\n\", location));\n}\n\nutil::Status JsonStreamParser::ReportUnknown(StringPiece message) {\n  // If we aren't finishing the parse, cancel parsing and try later.\n  if (!finishing_) {\n    return util::Status::CANCELLED;\n  }\n  if (p_.empty()) {\n    return ReportFailure(StrCat(\"Unexpected end of string. \", message));\n  }\n  return ReportFailure(message);\n}\n\nvoid JsonStreamParser::SkipWhitespace() {\n  while (!p_.empty() && ascii_isspace(*p_.data())) {\n    Advance();\n  }\n}\n\nvoid JsonStreamParser::Advance() {\n  // Advance by moving one UTF8 character while making sure we don't go beyond\n  // the length of StringPiece.\n  p_.remove_prefix(std::min<int>(\n      p_.length(), UTF8FirstLetterNumBytes(p_.data(), p_.length())));\n}\n\nutil::Status JsonStreamParser::ParseKey() {\n  StringPiece original = p_;\n  if (!ConsumeKey(&p_, &key_)) {\n    return ReportFailure(\"Invalid key or variable name.\");\n  }\n  // If we consumed everything but expect more data, reset p_ and cancel since\n  // we can't know if the key was complete or not.\n  if (!finishing_ && p_.empty()) {\n    p_ = original;\n    return util::Status::CANCELLED;\n  }\n  // Since we aren't using the key storage, clear it out.\n  key_storage_.clear();\n  return util::Status::OK;\n}\n\nJsonStreamParser::TokenType JsonStreamParser::GetNextTokenType() {\n  SkipWhitespace();\n\n  int size = p_.size();\n  if (size == 0) {\n    // If we ran out of data, report unknown and we'll place the previous parse\n    // type onto the stack and try again when we have more data.\n    return UNKNOWN;\n  }\n  // TODO(sven): Split this method based on context since different contexts\n  // support different tokens. Would slightly speed up processing?\n  const char* data = p_.data();\n  if (*data == '\\\"' || *data == '\\'') return BEGIN_STRING;\n  if (*data == '-' || ('0' <= *data && *data <= '9')) {\n    return BEGIN_NUMBER;\n  }\n  if (size >= true_len && !strncmp(data, \"true\", true_len)) {\n    return BEGIN_TRUE;\n  }\n  if (size >= false_len && !strncmp(data, \"false\", false_len)) {\n    return BEGIN_FALSE;\n  }\n  if (size >= null_len && !strncmp(data, \"null\", null_len)) {\n    return BEGIN_NULL;\n  }\n  if (*data == '{') return BEGIN_OBJECT;\n  if (*data == '}') return END_OBJECT;\n  if (*data == '[') return BEGIN_ARRAY;\n  if (*data == ']') return END_ARRAY;\n  if (*data == ':') return ENTRY_SEPARATOR;\n  if (*data == ',') return VALUE_SEPARATOR;\n  if (MatchKey(p_)) {\n    return BEGIN_KEY;\n  }\n\n  // We don't know that we necessarily have an invalid token here, just that we\n  // can't parse what we have so far. So we don't report an error and just\n  // return UNKNOWN so we can try again later when we have more data, or if we\n  // finish and we have leftovers.\n  return UNKNOWN;\n}\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/json_stream_parser.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_STREAM_PARSER_H__\n#define GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_STREAM_PARSER_H__\n\n#include <stack>\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/stringpiece.h>\n#include <google/protobuf/stubs/status.h>\n\nnamespace google {\nnamespace util {\nclass Status;\n}  // namespace util\n\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\nclass ObjectWriter;\n\n// A JSON parser that can parse a stream of JSON chunks rather than needing the\n// entire JSON string up front. It is a modified version of the parser in\n// //net/proto/json/json-parser.h that has been changed in the following ways:\n// - Changed from recursion to an explicit stack to allow resumption\n// - Added support for int64 and uint64 numbers\n// - Removed support for octal and decimal escapes\n// - Removed support for numeric keys\n// - Removed support for functions (javascript)\n// - Removed some lax-comma support (but kept trailing comma support)\n// - Writes directly to an ObjectWriter rather than using subclassing\n//\n// Here is an example usage:\n// JsonStreamParser parser(ow_.get());\n// util::Status result = parser.Parse(chunk1);\n// result.Update(parser.Parse(chunk2));\n// result.Update(parser.FinishParse());\n// GOOGLE_DCHECK(result.ok()) << \"Failed to parse JSON\";\n//\n// This parser is thread-compatible as long as only one thread is calling a\n// Parse() method at a time.\nclass LIBPROTOBUF_EXPORT JsonStreamParser {\n public:\n  // Creates a JsonStreamParser that will write to the given ObjectWriter.\n  explicit JsonStreamParser(ObjectWriter* ow);\n  virtual ~JsonStreamParser();\n\n  // Parses a UTF-8 encoded JSON string from a StringPiece.\n  util::Status Parse(StringPiece json);\n\n\n  // Finish parsing the JSON string.\n  util::Status FinishParse();\n\n\n private:\n  enum TokenType {\n    BEGIN_STRING,     // \" or '\n    BEGIN_NUMBER,     // - or digit\n    BEGIN_TRUE,       // true\n    BEGIN_FALSE,      // false\n    BEGIN_NULL,       // null\n    BEGIN_OBJECT,     // {\n    END_OBJECT,       // }\n    BEGIN_ARRAY,      // [\n    END_ARRAY,        // ]\n    ENTRY_SEPARATOR,  // :\n    VALUE_SEPARATOR,  // ,\n    BEGIN_KEY,        // letter, _, $ or digit.  Must begin with non-digit\n    UNKNOWN           // Unknown token or we ran out of the stream.\n  };\n\n  enum ParseType {\n    VALUE,        // Expects a {, [, true, false, null, string or number\n    OBJ_MID,      // Expects a ',' or }\n    ENTRY,        // Expects a key or }\n    ENTRY_MID,    // Expects a :\n    ARRAY_VALUE,  // Expects a value or ]\n    ARRAY_MID     // Expects a ',' or ]\n  };\n\n  // Holds the result of parsing a number\n  struct NumberResult {\n    enum Type { DOUBLE, INT, UINT };\n    Type type;\n    union {\n      double double_val;\n      int64 int_val;\n      uint64 uint_val;\n    };\n  };\n\n  // Parses a single chunk of JSON, returning an error if the JSON was invalid.\n  util::Status ParseChunk(StringPiece json);\n\n  // Runs the parser based on stack_ and p_, until the stack is empty or p_ runs\n  // out of data. If we unexpectedly run out of p_ we push the latest back onto\n  // the stack and return.\n  util::Status RunParser();\n\n  // Parses a value from p_ and writes it to ow_.\n  // A value may be an object, array, true, false, null, string or number.\n  util::Status ParseValue(TokenType type);\n\n  // Parses a string and writes it out to the ow_.\n  util::Status ParseString();\n\n  // Parses a string, storing the result in parsed_.\n  util::Status ParseStringHelper();\n\n  // This function parses unicode escape sequences in strings. It returns an\n  // error when there's a parsing error, either the size is not the expected\n  // size or a character is not a hex digit.  When it returns str will contain\n  // what has been successfully parsed so far.\n  util::Status ParseUnicodeEscape();\n\n  // Expects p_ to point to a JSON number, writes the number to the writer using\n  // the appropriate Render method based on the type of number.\n  util::Status ParseNumber();\n\n  // Parse a number into a NumberResult, reporting an error if no number could\n  // be parsed. This method will try to parse into a uint64, int64, or double\n  // based on whether the number was positive or negative or had a decimal\n  // component.\n  util::Status ParseNumberHelper(NumberResult* result);\n\n  // Handles a { during parsing of a value.\n  util::Status HandleBeginObject();\n\n  // Parses from the ENTRY state.\n  util::Status ParseEntry(TokenType type);\n\n  // Parses from the ENTRY_MID state.\n  util::Status ParseEntryMid(TokenType type);\n\n  // Parses from the OBJ_MID state.\n  util::Status ParseObjectMid(TokenType type);\n\n  // Handles a [ during parsing of a value.\n  util::Status HandleBeginArray();\n\n  // Parses from the ARRAY_VALUE state.\n  util::Status ParseArrayValue(TokenType type);\n\n  // Parses from the ARRAY_MID state.\n  util::Status ParseArrayMid(TokenType type);\n\n  // Expects p_ to point to an unquoted literal\n  util::Status ParseTrue();\n  util::Status ParseFalse();\n  util::Status ParseNull();\n\n  // Report a failure as a util::Status.\n  util::Status ReportFailure(StringPiece message);\n\n  // Report a failure due to an UNKNOWN token type. We check if we hit the\n  // end of the stream and if we're finishing or not to detect what type of\n  // status to return in this case.\n  util::Status ReportUnknown(StringPiece message);\n\n  // Advance p_ past all whitespace or until the end of the string.\n  void SkipWhitespace();\n\n  // Advance p_ one UTF-8 character\n  void Advance();\n\n  // Expects p_ to point to the beginning of a key.\n  util::Status ParseKey();\n\n  // Return the type of the next token at p_.\n  TokenType GetNextTokenType();\n\n  // The object writer to write parse events to.\n  ObjectWriter* ow_;\n\n  // The stack of parsing we still need to do. When the stack runs empty we will\n  // have parsed a single value from the root (e.g. an object or list).\n  std::stack<ParseType> stack_;\n\n  // Contains any leftover text from a previous chunk that we weren't able to\n  // fully parse, for example the start of a key or number.\n  string leftover_;\n\n  // The current chunk of JSON being parsed. Primarily used for providing\n  // context during error reporting.\n  StringPiece json_;\n\n  // A pointer within the current JSON being parsed, used to track location.\n  StringPiece p_;\n\n  // Stores the last key read, as we separate parsing of keys and values.\n  StringPiece key_;\n\n  // Storage for key_ if we need to keep ownership, for example between chunks\n  // or if the key was unescaped from a JSON string.\n  string key_storage_;\n\n  // True during the FinishParse() call, so we know that any errors are fatal.\n  // For example an unterminated string will normally result in cancelling and\n  // trying during the next chunk, but during FinishParse() it is an error.\n  bool finishing_;\n\n  // String we parsed during a call to ParseStringHelper().\n  StringPiece parsed_;\n\n  // Storage for the string we parsed. This may be empty if the string was able\n  // to be parsed directly from the input.\n  string parsed_storage_;\n\n  // The character that opened the string, either ' or \".\n  // A value of 0 indicates that string parsing is not in process.\n  char string_open_;\n\n  // Storage for the chunk that are being parsed in ParseChunk().\n  string chunk_storage_;\n\n  // Whether to allow non UTF-8 encoded input and replace invalid code points.\n  bool coerce_to_utf8_;\n\n  GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(JsonStreamParser);\n};\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_CONVERTER_JSON_STREAM_PARSER_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/json_stream_parser_test.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/internal/json_stream_parser.h>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/time.h>\n#include <google/protobuf/util/internal/expecting_objectwriter.h>\n#include <google/protobuf/util/internal/object_writer.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <gtest/gtest.h>\n#include <google/protobuf/stubs/status.h>\n\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nusing util::Status;\nnamespace error {\nusing util::error::INVALID_ARGUMENT;\n}  // namespace error\nnamespace converter {\n\nusing util::Status;\n\n// Tests for the JSON Stream Parser. These tests are intended to be\n// comprehensive and cover the following:\n//\n// Positive tests:\n// - true, false, null\n// - empty object or array.\n// - negative and positive double and int, unsigned int\n// - single and double quoted strings\n// - string key, unquoted key, numeric key\n// - array containing array, object, value\n// - object containing array, object, value\n// - unicode handling in strings\n// - ascii escaping (\\b, \\f, \\n, \\r, \\t, \\v)\n// - trailing commas\n//\n// Negative tests:\n// - illegal literals\n// - mismatched quotes failure on strings\n// - unterminated string failure\n// - unexpected end of string failure\n// - mismatched object and array closing\n// - Failure to close array or object\n// - numbers too large\n// - invalid unicode escapes.\n// - invalid unicode sequences.\n// - numbers as keys\n//\n// For each test we split the input string on every possible character to ensure\n// the parser is able to handle arbitrarily split input for all cases. We also\n// do a final test of the entire test case one character at a time.\nclass JsonStreamParserTest : public ::testing::Test {\n protected:\n  JsonStreamParserTest() : mock_(), ow_(&mock_) {}\n  virtual ~JsonStreamParserTest() {}\n\n  util::Status RunTest(StringPiece json, int split, bool coerce_utf8 = false) {\n    JsonStreamParser parser(&mock_);\n\n    // Special case for split == length, test parsing one character at a time.\n    if (split == json.length()) {\n      GOOGLE_LOG(INFO) << \"Testing split every char: \" << json;\n      for (int i = 0; i < json.length(); ++i) {\n        StringPiece single = json.substr(i, 1);\n        util::Status result = parser.Parse(single);\n        if (!result.ok()) {\n          return result;\n        }\n      }\n      return parser.FinishParse();\n    }\n\n    // Normal case, split at the split point and parse two substrings.\n    StringPiece first = json.substr(0, split);\n    StringPiece rest = json.substr(split);\n    GOOGLE_LOG(INFO) << \"Testing split: \" << first << \"><\" << rest;\n    util::Status result = parser.Parse(first);\n    if (result.ok()) {\n      result = parser.Parse(rest);\n      if (result.ok()) {\n        result = parser.FinishParse();\n      }\n    }\n    return result;\n  }\n\n  void DoTest(StringPiece json, int split, bool coerce_utf8 = false) {\n    util::Status result = RunTest(json, split, coerce_utf8);\n    if (!result.ok()) {\n      GOOGLE_LOG(WARNING) << result;\n    }\n    EXPECT_OK(result);\n  }\n\n  void DoErrorTest(StringPiece json, int split, StringPiece error_prefix,\n                   bool coerce_utf8 = false) {\n    util::Status result = RunTest(json, split, coerce_utf8);\n    EXPECT_EQ(util::error::INVALID_ARGUMENT, result.error_code());\n    StringPiece error_message(result.error_message());\n    EXPECT_EQ(error_prefix, error_message.substr(0, error_prefix.size()));\n  }\n\n\n  MockObjectWriter mock_;\n  ExpectingObjectWriter ow_;\n};\n\n\n// Positive tests\n\n// - true, false, null\nTEST_F(JsonStreamParserTest, SimpleTrue) {\n  StringPiece str = \"true\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.RenderBool(\"\", true);\n    DoTest(str, i);\n  }\n}\n\nTEST_F(JsonStreamParserTest, SimpleFalse) {\n  StringPiece str = \"false\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.RenderBool(\"\", false);\n    DoTest(str, i);\n  }\n}\n\nTEST_F(JsonStreamParserTest, SimpleNull) {\n  StringPiece str = \"null\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.RenderNull(\"\");\n    DoTest(str, i);\n  }\n}\n\n// - empty object and array.\nTEST_F(JsonStreamParserTest, EmptyObject) {\n  StringPiece str = \"{}\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartObject(\"\")->EndObject();\n    DoTest(str, i);\n  }\n}\n\nTEST_F(JsonStreamParserTest, EmptyList) {\n  StringPiece str = \"[]\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartList(\"\")->EndList();\n    DoTest(str, i);\n  }\n}\n\n// - negative and positive double and int, unsigned int\nTEST_F(JsonStreamParserTest, SimpleDouble) {\n  StringPiece str = \"42.5\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.RenderDouble(\"\", 42.5);\n    DoTest(str, i);\n  }\n}\n\nTEST_F(JsonStreamParserTest, ScientificDouble) {\n  StringPiece str = \"1.2345e-10\";\n  for (int i = 0; i < str.length(); ++i) {\n    ow_.RenderDouble(\"\", 1.2345e-10);\n    DoTest(str, i);\n  }\n}\n\nTEST_F(JsonStreamParserTest, SimpleNegativeDouble) {\n  StringPiece str = \"-1045.235\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.RenderDouble(\"\", -1045.235);\n    DoTest(str, i);\n  }\n}\n\nTEST_F(JsonStreamParserTest, SimpleInt) {\n  StringPiece str = \"123456\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.RenderUint64(\"\", 123456);\n    DoTest(str, i);\n  }\n}\n\nTEST_F(JsonStreamParserTest, SimpleNegativeInt) {\n  StringPiece str = \"-79497823553162765\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.RenderInt64(\"\", -79497823553162765LL);\n    DoTest(str, i);\n  }\n}\n\nTEST_F(JsonStreamParserTest, SimpleUnsignedInt) {\n  StringPiece str = \"11779497823553162765\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.RenderUint64(\"\", 11779497823553162765ULL);\n    DoTest(str, i);\n  }\n}\n\nTEST_F(JsonStreamParserTest, OctalNumberIsInvalid) {\n  StringPiece str = \"01234\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Octal/hex numbers are not valid JSON values.\");\n  }\n  str = \"-01234\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Octal/hex numbers are not valid JSON values.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, HexNumberIsInvalid) {\n  StringPiece str = \"0x1234\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Octal/hex numbers are not valid JSON values.\");\n  }\n  str = \"-0x1234\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Octal/hex numbers are not valid JSON values.\");\n  }\n  str = \"12x34\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Unable to parse number.\");\n  }\n}\n\n// - single and double quoted strings\nTEST_F(JsonStreamParserTest, EmptyDoubleQuotedString) {\n  StringPiece str = \"\\\"\\\"\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.RenderString(\"\", \"\");\n    DoTest(str, i);\n  }\n}\n\nTEST_F(JsonStreamParserTest, EmptySingleQuotedString) {\n  StringPiece str = \"''\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.RenderString(\"\", \"\");\n    DoTest(str, i);\n  }\n}\n\nTEST_F(JsonStreamParserTest, SimpleDoubleQuotedString) {\n  StringPiece str = \"\\\"Some String\\\"\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.RenderString(\"\", \"Some String\");\n    DoTest(str, i);\n  }\n}\n\nTEST_F(JsonStreamParserTest, SimpleSingleQuotedString) {\n  StringPiece str = \"'Another String'\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.RenderString(\"\", \"Another String\");\n    DoTest(str, i);\n  }\n}\n\n// - string key, unquoted key, numeric key\nTEST_F(JsonStreamParserTest, ObjectKeyTypes) {\n  StringPiece str =\n      \"{'s': true, \\\"d\\\": false, key: null, snake_key: [], camelKey: {}}\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartObject(\"\")\n        ->RenderBool(\"s\", true)\n        ->RenderBool(\"d\", false)\n        ->RenderNull(\"key\")\n        ->StartList(\"snake_key\")\n        ->EndList()\n        ->StartObject(\"camelKey\")\n        ->EndObject()\n        ->EndObject();\n    DoTest(str, i);\n  }\n}\n\n// - array containing array, object, values (true, false, null, num, string)\nTEST_F(JsonStreamParserTest, ArrayValues) {\n  StringPiece str =\n      \"[true, false, null, 'a string', \\\"another string\\\", [22, -127, 45.3, \"\n      \"-1056.4, 11779497823553162765], {'key': true}]\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartList(\"\")\n        ->RenderBool(\"\", true)\n        ->RenderBool(\"\", false)\n        ->RenderNull(\"\")\n        ->RenderString(\"\", \"a string\")\n        ->RenderString(\"\", \"another string\")\n        ->StartList(\"\")\n        ->RenderUint64(\"\", 22)\n        ->RenderInt64(\"\", -127)\n        ->RenderDouble(\"\", 45.3)\n        ->RenderDouble(\"\", -1056.4)\n        ->RenderUint64(\"\", 11779497823553162765ULL)\n        ->EndList()\n        ->StartObject(\"\")\n        ->RenderBool(\"key\", true)\n        ->EndObject()\n        ->EndList();\n    DoTest(str, i);\n  }\n}\n\n// - object containing array, object, value (true, false, null, num, string)\nTEST_F(JsonStreamParserTest, ObjectValues) {\n  StringPiece str =\n      \"{t: true, f: false, n: null, s: 'a string', d: \\\"another string\\\", pi: \"\n      \"22, ni: -127, pd: 45.3, nd: -1056.4, pl: 11779497823553162765, l: [[]], \"\n      \"o: {'key': true}}\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartObject(\"\")\n        ->RenderBool(\"t\", true)\n        ->RenderBool(\"f\", false)\n        ->RenderNull(\"n\")\n        ->RenderString(\"s\", \"a string\")\n        ->RenderString(\"d\", \"another string\")\n        ->RenderUint64(\"pi\", 22)\n        ->RenderInt64(\"ni\", -127)\n        ->RenderDouble(\"pd\", 45.3)\n        ->RenderDouble(\"nd\", -1056.4)\n        ->RenderUint64(\"pl\", 11779497823553162765ULL)\n        ->StartList(\"l\")\n        ->StartList(\"\")\n        ->EndList()\n        ->EndList()\n        ->StartObject(\"o\")\n        ->RenderBool(\"key\", true)\n        ->EndObject()\n        ->EndObject();\n    DoTest(str, i);\n  }\n}\n\n\nTEST_F(JsonStreamParserTest, RejectNonUtf8WhenNotCoerced) {\n  StringPiece json = \"{\\\"address\\\":\\xFF\\\"חרושת 23, רעננה, ישראל\\\"}\";\n  for (int i = 0; i <= json.length(); ++i) {\n    DoErrorTest(json, i, \"Encountered non UTF-8 code points.\");\n  }\n  json = \"{\\\"address\\\": \\\"חרושת 23,\\xFFרעננה, ישראל\\\"}\";\n  for (int i = 0; i <= json.length(); ++i) {\n    DoErrorTest(json, i, \"Encountered non UTF-8 code points.\");\n  }\n  DoErrorTest(\"\\xFF{}\", 0, \"Encountered non UTF-8 code points.\");\n}\n\n// - unicode handling in strings\nTEST_F(JsonStreamParserTest, UnicodeEscaping) {\n  StringPiece str = \"[\\\"\\\\u0639\\\\u0631\\\\u0628\\\\u0649\\\"]\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartList(\"\")\n        ->RenderString(\"\", \"\\xD8\\xB9\\xD8\\xB1\\xD8\\xA8\\xD9\\x89\")\n        ->EndList();\n    DoTest(str, i);\n  }\n}\n\n// - unicode UTF-16 surrogate pair handling in strings\nTEST_F(JsonStreamParserTest, UnicodeSurrogatePairEscaping) {\n  StringPiece str =\n      \"[\\\"\\\\u0bee\\\\ud800\\\\uddf1\\\\uD80C\\\\uDDA4\\\\uD83d\\\\udC1D\\\\uD83C\\\\uDF6F\\\"]\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartList(\"\")\n        ->RenderString(\"\",\n                       \"\\xE0\\xAF\\xAE\\xF0\\x90\\x87\\xB1\\xF0\\x93\\x86\\xA4\\xF0\"\n                       \"\\x9F\\x90\\x9D\\xF0\\x9F\\x8D\\xAF\")\n        ->EndList();\n    DoTest(str, i);\n  }\n}\n\n\nTEST_F(JsonStreamParserTest, UnicodeEscapingInvalidCodePointWhenNotCoerced) {\n  // A low surrogate alone.\n  StringPiece str = \"[\\\"\\\\ude36\\\"]\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Invalid unicode code point.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, UnicodeEscapingMissingLowSurrogateWhenNotCoerced) {\n  // A high surrogate alone.\n  StringPiece str = \"[\\\"\\\\ud83d\\\"]\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Missing low surrogate.\");\n  }\n  // A high surrogate with some trailing characters.\n  str = \"[\\\"\\\\ud83d|ude36\\\"]\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Missing low surrogate.\");\n  }\n  // A high surrogate with half a low surrogate.\n  str = \"[\\\"\\\\ud83d\\\\ude--\\\"]\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Invalid escape sequence.\");\n  }\n  // Two high surrogates.\n  str = \"[\\\"\\\\ud83d\\\\ud83d\\\"]\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Invalid low surrogate.\");\n  }\n}\n\n// - ascii escaping (\\b, \\f, \\n, \\r, \\t, \\v)\nTEST_F(JsonStreamParserTest, AsciiEscaping) {\n  StringPiece str =\n      \"[\\\"\\\\b\\\", \\\"\\\\ning\\\", \\\"test\\\\f\\\", \\\"\\\\r\\\\t\\\", \\\"test\\\\\\\\\\\\ving\\\"]\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartList(\"\")\n        ->RenderString(\"\", \"\\b\")\n        ->RenderString(\"\", \"\\ning\")\n        ->RenderString(\"\", \"test\\f\")\n        ->RenderString(\"\", \"\\r\\t\")\n        ->RenderString(\"\", \"test\\\\\\ving\")\n        ->EndList();\n    DoTest(str, i);\n  }\n}\n\n// - trailing commas, we support a single trailing comma but no internal commas.\nTEST_F(JsonStreamParserTest, TrailingCommas) {\n  StringPiece str = \"[['a',true,], {b: null,},]\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartList(\"\")\n        ->StartList(\"\")\n        ->RenderString(\"\", \"a\")\n        ->RenderBool(\"\", true)\n        ->EndList()\n        ->StartObject(\"\")\n        ->RenderNull(\"b\")\n        ->EndObject()\n        ->EndList();\n    DoTest(str, i);\n  }\n}\n\n// Negative tests\n\n// illegal literals\nTEST_F(JsonStreamParserTest, ExtraTextAfterTrue) {\n  StringPiece str = \"truee\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.RenderBool(\"\", true);\n    DoErrorTest(str, i, \"Parsing terminated before end of input.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, InvalidNumberDashOnly) {\n  StringPiece str = \"-\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Unable to parse number.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, InvalidNumberDashName) {\n  StringPiece str = \"-foo\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Unable to parse number.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, InvalidLiteralInArray) {\n  StringPiece str = \"[nule]\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartList(\"\");\n    DoErrorTest(str, i, \"Unexpected token.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, InvalidLiteralInObject) {\n  StringPiece str = \"{123false}\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartObject(\"\");\n    DoErrorTest(str, i, \"Expected an object key or }.\");\n  }\n}\n\n// mismatched quotes failure on strings\nTEST_F(JsonStreamParserTest, MismatchedSingleQuotedLiteral) {\n  StringPiece str = \"'Some str\\\"\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Closing quote expected in string.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, MismatchedDoubleQuotedLiteral) {\n  StringPiece str = \"\\\"Another string that ends poorly!'\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Closing quote expected in string.\");\n  }\n}\n\n// unterminated strings\nTEST_F(JsonStreamParserTest, UnterminatedLiteralString) {\n  StringPiece str = \"\\\"Forgot the rest of i\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Closing quote expected in string.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, UnterminatedStringEscape) {\n  StringPiece str = \"\\\"Forgot the rest of \\\\\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Closing quote expected in string.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, UnterminatedStringInArray) {\n  StringPiece str = \"[\\\"Forgot to close the string]\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartList(\"\");\n    DoErrorTest(str, i, \"Closing quote expected in string.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, UnterminatedStringInObject) {\n  StringPiece str = \"{f: \\\"Forgot to close the string}\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartObject(\"\");\n    DoErrorTest(str, i, \"Closing quote expected in string.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, UnterminatedObject) {\n  StringPiece str = \"{\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartObject(\"\");\n    DoErrorTest(str, i, \"Unexpected end of string.\");\n  }\n}\n\n\n// mismatched object and array closing\nTEST_F(JsonStreamParserTest, MismatchedCloseObject) {\n  StringPiece str = \"{'key': true]\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartObject(\"\")->RenderBool(\"key\", true);\n    DoErrorTest(str, i, \"Expected , or } after key:value pair.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, MismatchedCloseArray) {\n  StringPiece str = \"[true, null}\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartList(\"\")->RenderBool(\"\", true)->RenderNull(\"\");\n    DoErrorTest(str, i, \"Expected , or ] after array value.\");\n  }\n}\n\n// Invalid object keys.\nTEST_F(JsonStreamParserTest, InvalidNumericObjectKey) {\n  StringPiece str = \"{42: true}\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartObject(\"\");\n    DoErrorTest(str, i, \"Expected an object key or }.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, InvalidLiteralObjectInObject) {\n  StringPiece str = \"{{bob: true}}\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartObject(\"\");\n    DoErrorTest(str, i, \"Expected an object key or }.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, InvalidLiteralArrayInObject) {\n  StringPiece str = \"{[null]}\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartObject(\"\");\n    DoErrorTest(str, i, \"Expected an object key or }.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, InvalidLiteralValueInObject) {\n  StringPiece str = \"{false}\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartObject(\"\");\n    DoErrorTest(str, i, \"Expected an object key or }.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, MissingColonAfterStringInObject) {\n  StringPiece str = \"{\\\"key\\\"}\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartObject(\"\");\n    DoErrorTest(str, i, \"Expected : between key:value pair.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, MissingColonAfterKeyInObject) {\n  StringPiece str = \"{key}\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartObject(\"\");\n    DoErrorTest(str, i, \"Expected : between key:value pair.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, EndOfTextAfterKeyInObject) {\n  StringPiece str = \"{key\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartObject(\"\");\n    DoErrorTest(str, i, \"Unexpected end of string.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, MissingValueAfterColonInObject) {\n  StringPiece str = \"{key:}\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartObject(\"\");\n    DoErrorTest(str, i, \"Unexpected token.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, MissingCommaBetweenObjectEntries) {\n  StringPiece str = \"{key:20 'hello': true}\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartObject(\"\")->RenderUint64(\"key\", 20);\n    DoErrorTest(str, i, \"Expected , or } after key:value pair.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, InvalidLiteralAsObjectKey) {\n  StringPiece str = \"{false: 20}\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartObject(\"\");\n    DoErrorTest(str, i, \"Expected an object key or }.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, ExtraCharactersAfterObject) {\n  StringPiece str = \"{}}\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartObject(\"\")->EndObject();\n    DoErrorTest(str, i, \"Parsing terminated before end of input.\");\n  }\n}\n\n// numbers too large\nTEST_F(JsonStreamParserTest, PositiveNumberTooBig) {\n  StringPiece str = \"[18446744073709551616]\";  // 2^64\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartList(\"\");\n    DoErrorTest(str, i, \"Unable to parse number.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, NegativeNumberTooBig) {\n  StringPiece str = \"[-18446744073709551616]\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartList(\"\");\n    DoErrorTest(str, i, \"Unable to parse number.\");\n  }\n}\n\n/*\nTODO(sven): Fail parsing when parsing a double that is too large.\n\nTEST_F(JsonStreamParserTest, DoubleTooBig) {\n  StringPiece str = \"[184464073709551232321616.45]\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartList(\"\");\n    DoErrorTest(str, i, \"Unable to parse number\");\n  }\n}\n*/\n\n// invalid bare backslash.\nTEST_F(JsonStreamParserTest, UnfinishedEscape) {\n  StringPiece str = \"\\\"\\\\\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Closing quote expected in string.\");\n  }\n}\n\n// invalid bare backslash u.\nTEST_F(JsonStreamParserTest, UnfinishedUnicodeEscape) {\n  StringPiece str = \"\\\"\\\\u\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Illegal hex string.\");\n  }\n}\n\n// invalid unicode sequence.\nTEST_F(JsonStreamParserTest, UnicodeEscapeCutOff) {\n  StringPiece str = \"\\\"\\\\u12\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Illegal hex string.\");\n  }\n}\n\n// invalid unicode sequence (valid in modern EcmaScript but not in JSON).\nTEST_F(JsonStreamParserTest, BracketedUnicodeEscape) {\n  StringPiece str = \"\\\"\\\\u{1f36f}\\\"\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Invalid escape sequence.\");\n  }\n}\n\n\nTEST_F(JsonStreamParserTest, UnicodeEscapeInvalidCharacters) {\n  StringPiece str = \"\\\"\\\\u12$4hello\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Invalid escape sequence.\");\n  }\n}\n\n// invalid unicode sequence in low half surrogate: g is not a hex digit.\nTEST_F(JsonStreamParserTest, UnicodeEscapeLowHalfSurrogateInvalidCharacters) {\n  StringPiece str = \"\\\"\\\\ud800\\\\udcfg\\\"\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Invalid escape sequence.\");\n  }\n}\n\n// Extra commas with an object or array.\nTEST_F(JsonStreamParserTest, ExtraCommaInObject) {\n  StringPiece str = \"{'k1': true,,'k2': false}\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartObject(\"\")->RenderBool(\"k1\", true);\n    DoErrorTest(str, i, \"Expected an object key or }.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, ExtraCommaInArray) {\n  StringPiece str = \"[true,,false}\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartList(\"\")->RenderBool(\"\", true);\n    DoErrorTest(str, i, \"Unexpected token.\");\n  }\n}\n\n// Extra text beyond end of value.\nTEST_F(JsonStreamParserTest, ExtraTextAfterLiteral) {\n  StringPiece str = \"'hello', 'world'\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.RenderString(\"\", \"hello\");\n    DoErrorTest(str, i, \"Parsing terminated before end of input.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, ExtraTextAfterObject) {\n  StringPiece str = \"{'key': true} 'oops'\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartObject(\"\")->RenderBool(\"key\", true)->EndObject();\n    DoErrorTest(str, i, \"Parsing terminated before end of input.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, ExtraTextAfterArray) {\n  StringPiece str = \"[null] 'oops'\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartList(\"\")->RenderNull(\"\")->EndList();\n    DoErrorTest(str, i, \"Parsing terminated before end of input.\");\n  }\n}\n\n// Random unknown text in the value.\nTEST_F(JsonStreamParserTest, UnknownCharactersAsValue) {\n  StringPiece str = \"*&#25\";\n  for (int i = 0; i <= str.length(); ++i) {\n    DoErrorTest(str, i, \"Expected a value.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, UnknownCharactersInArray) {\n  StringPiece str = \"[*&#25]\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartList(\"\");\n    DoErrorTest(str, i, \"Expected a value or ] within an array.\");\n  }\n}\n\nTEST_F(JsonStreamParserTest, UnknownCharactersInObject) {\n  StringPiece str = \"{'key': *&#25}\";\n  for (int i = 0; i <= str.length(); ++i) {\n    ow_.StartObject(\"\");\n    DoErrorTest(str, i, \"Expected a value.\");\n  }\n}\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/location_tracker.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_LOCATION_TRACKER_H__\n#define GOOGLE_PROTOBUF_UTIL_CONVERTER_LOCATION_TRACKER_H__\n\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\n// LocationTrackerInterface is an interface for classes that track\n// the location information for the purpose of error reporting.\nclass LIBPROTOBUF_EXPORT LocationTrackerInterface {\n public:\n  virtual ~LocationTrackerInterface() {}\n\n  // Returns the object location as human readable string.\n  virtual string ToString() const = 0;\n\n protected:\n  LocationTrackerInterface() {}\n\n private:\n  // Please do not add any data members to this class.\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(LocationTrackerInterface);\n};\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_CONVERTER_LOCATION_TRACKER_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/mock_error_listener.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_MOCK_ERROR_LISTENER_H__\n#define GOOGLE_PROTOBUF_UTIL_CONVERTER_MOCK_ERROR_LISTENER_H__\n\n#include <google/protobuf/stubs/stringpiece.h>\n#include <google/protobuf/util/internal/error_listener.h>\n#include <google/protobuf/util/internal/location_tracker.h>\n#include <gmock/gmock.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\nclass MockErrorListener : public ErrorListener {\n public:\n  MockErrorListener() {}\n  virtual ~MockErrorListener() {}\n\n  MOCK_METHOD3(InvalidName, void(const LocationTrackerInterface& loc,\n                                 StringPiece unknown_name,\n                                 StringPiece message));\n  MOCK_METHOD3(InvalidValue, void(const LocationTrackerInterface& loc,\n                                  StringPiece type_name, StringPiece value));\n  MOCK_METHOD2(MissingField, void(const LocationTrackerInterface& loc,\n                                  StringPiece missing_name));\n};\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_CONVERTER_MOCK_ERROR_LISTENER_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/object_location_tracker.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_LOCATION_TRACKER_H__\n#define GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_LOCATION_TRACKER_H__\n\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/util/internal/location_tracker.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\n// An empty concrete implementation of LocationTrackerInterface.\nclass ObjectLocationTracker : public LocationTrackerInterface {\n public:\n  // Creates an empty location tracker.\n  ObjectLocationTracker() {}\n\n  virtual ~ObjectLocationTracker() {}\n\n  // Returns empty because nothing is tracked.\n  virtual string ToString() const { return \"\"; }\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjectLocationTracker);\n};\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_LOCATION_TRACKER_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/object_source.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_SOURCE_H__\n#define GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_SOURCE_H__\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/stringpiece.h>\n#include <google/protobuf/stubs/status.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\nclass ObjectWriter;\n\n// An ObjectSource is anything that can write to an ObjectWriter.\n// Implementation of this interface typically provide constructors or\n// factory methods to create an instance based on some source data, for\n// example, a character stream, or protobuf.\n//\n// Derived classes could be thread-unsafe.\nclass LIBPROTOBUF_EXPORT ObjectSource {\n public:\n  virtual ~ObjectSource() {}\n\n  // Writes to the ObjectWriter\n  virtual util::Status WriteTo(ObjectWriter* ow) const {\n    return NamedWriteTo(\"\", ow);\n  }\n\n  // Writes to the ObjectWriter with a custom name for the message.\n  // This is useful when you chain ObjectSource together by embedding one\n  // within another.\n  virtual util::Status NamedWriteTo(StringPiece name,\n                                      ObjectWriter* ow) const = 0;\n\n protected:\n  ObjectSource() {}\n\n private:\n  // Do not add any data members to this class.\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjectSource);\n};\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_SOURCE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/object_writer.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/internal/object_writer.h>\n\n#include <google/protobuf/util/internal/datapiece.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\n// static\nvoid ObjectWriter::RenderDataPieceTo(const DataPiece& data, StringPiece name,\n                                     ObjectWriter* ow) {\n  switch (data.type()) {\n    case DataPiece::TYPE_INT32: {\n      ow->RenderInt32(name, data.ToInt32().ValueOrDie());\n      break;\n    }\n    case DataPiece::TYPE_INT64: {\n      ow->RenderInt64(name, data.ToInt64().ValueOrDie());\n      break;\n    }\n    case DataPiece::TYPE_UINT32: {\n      ow->RenderUint32(name, data.ToUint32().ValueOrDie());\n      break;\n    }\n    case DataPiece::TYPE_UINT64: {\n      ow->RenderUint64(name, data.ToUint64().ValueOrDie());\n      break;\n    }\n    case DataPiece::TYPE_DOUBLE: {\n      ow->RenderDouble(name, data.ToDouble().ValueOrDie());\n      break;\n    }\n    case DataPiece::TYPE_FLOAT: {\n      ow->RenderFloat(name, data.ToFloat().ValueOrDie());\n      break;\n    }\n    case DataPiece::TYPE_BOOL: {\n      ow->RenderBool(name, data.ToBool().ValueOrDie());\n      break;\n    }\n    case DataPiece::TYPE_STRING: {\n      ow->RenderString(name, data.ToString().ValueOrDie());\n      break;\n    }\n    case DataPiece::TYPE_BYTES: {\n      ow->RenderBytes(name, data.ToBytes().ValueOrDie());\n      break;\n    }\n    case DataPiece::TYPE_NULL: {\n      ow->RenderNull(name);\n      break;\n    }\n    default:\n      break;\n  }\n}\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/object_writer.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_WRITER_H__\n#define GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_WRITER_H__\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/stringpiece.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\nclass DataPiece;\n\n// An ObjectWriter is an interface for writing a stream of events\n// representing objects and collections. Implementation of this\n// interface can be used to write an object stream to an in-memory\n// structure, protobufs, JSON, XML, or any other output format\n// desired. The ObjectSource interface is typically used as the\n// source of an object stream.\n//\n// See JsonObjectWriter for a sample implementation of ObjectWriter\n// and its use.\n//\n// Derived classes could be thread-unsafe.\n//\n// TODO(xinb): seems like a prime candidate to apply the RAII paradigm\n// and get rid the need to call EndXXX().\nclass LIBPROTOBUF_EXPORT ObjectWriter {\n public:\n  virtual ~ObjectWriter() {}\n\n  // Starts an object. If the name is empty, the object will not be named.\n  virtual ObjectWriter* StartObject(StringPiece name) = 0;\n\n  // Ends an object.\n  virtual ObjectWriter* EndObject() = 0;\n\n  // Starts a list. If the name is empty, the list will not be named.\n  virtual ObjectWriter* StartList(StringPiece name) = 0;\n\n  // Ends a list.\n  virtual ObjectWriter* EndList() = 0;\n\n  // Renders a boolean value.\n  virtual ObjectWriter* RenderBool(StringPiece name, bool value) = 0;\n\n  // Renders an 32-bit integer value.\n  virtual ObjectWriter* RenderInt32(StringPiece name, int32 value) = 0;\n\n  // Renders an 32-bit unsigned integer value.\n  virtual ObjectWriter* RenderUint32(StringPiece name, uint32 value) = 0;\n\n  // Renders a 64-bit integer value.\n  virtual ObjectWriter* RenderInt64(StringPiece name, int64 value) = 0;\n\n  // Renders an 64-bit unsigned integer value.\n  virtual ObjectWriter* RenderUint64(StringPiece name, uint64 value) = 0;\n\n  // Renders a double value.\n  virtual ObjectWriter* RenderDouble(StringPiece name, double value) = 0;\n\n  // Renders a float value.\n  virtual ObjectWriter* RenderFloat(StringPiece name, float value) = 0;\n\n  // Renders a StringPiece value. This is for rendering strings.\n  virtual ObjectWriter* RenderString(StringPiece name, StringPiece value) = 0;\n\n  // Renders a bytes value.\n  virtual ObjectWriter* RenderBytes(StringPiece name, StringPiece value) = 0;\n\n  // Renders a Null value.\n  virtual ObjectWriter* RenderNull(StringPiece name) = 0;\n\n\n  // Renders a DataPiece object to a ObjectWriter.\n  static void RenderDataPieceTo(const DataPiece& data, StringPiece name,\n                                ObjectWriter* ow);\n\n  // Indicates whether this ObjectWriter has completed writing the root message,\n  // usually this means writing of one complete object. Subclasses must override\n  // this behavior appropriately.\n  virtual bool done() { return false; }\n\n  void set_use_strict_base64_decoding(bool value) {\n    use_strict_base64_decoding_ = value;\n  }\n\n  bool use_strict_base64_decoding() const {\n    return use_strict_base64_decoding_;\n  }\n\n protected:\n  ObjectWriter() : use_strict_base64_decoding_(true) {}\n\n private:\n  // If set to true, we use the stricter version of base64 decoding for byte\n  // fields by making sure decoded version encodes back to the original string.\n  bool use_strict_base64_decoding_;\n\n  // Do not add any data members to this class.\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ObjectWriter);\n};\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_CONVERTER_OBJECT_WRITER_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/proto_writer.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/internal/proto_writer.h>\n\n#include <functional>\n#include <stack>\n\n#include <google/protobuf/stubs/once.h>\n#include <google/protobuf/stubs/time.h>\n#include <google/protobuf/wire_format_lite.h>\n#include <google/protobuf/util/internal/field_mask_utility.h>\n#include <google/protobuf/util/internal/object_location_tracker.h>\n#include <google/protobuf/util/internal/constants.h>\n#include <google/protobuf/util/internal/utility.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/map_util.h>\n#include <google/protobuf/stubs/statusor.h>\n\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\nusing google::protobuf::internal::WireFormatLite;\nusing google::protobuf::io::CodedOutputStream;\nusing util::error::INVALID_ARGUMENT;\nusing util::Status;\nusing util::StatusOr;\n\n\nProtoWriter::ProtoWriter(TypeResolver* type_resolver,\n                         const google::protobuf::Type& type,\n                         strings::ByteSink* output, ErrorListener* listener)\n    : master_type_(type),\n      typeinfo_(TypeInfo::NewTypeInfo(type_resolver)),\n      own_typeinfo_(true),\n      done_(false),\n      ignore_unknown_fields_(false),\n      element_(NULL),\n      size_insert_(),\n      output_(output),\n      buffer_(),\n      adapter_(&buffer_),\n      stream_(new CodedOutputStream(&adapter_)),\n      listener_(listener),\n      invalid_depth_(0),\n      tracker_(new ObjectLocationTracker()) {}\n\nProtoWriter::ProtoWriter(const TypeInfo* typeinfo,\n                         const google::protobuf::Type& type,\n                         strings::ByteSink* output, ErrorListener* listener)\n    : master_type_(type),\n      typeinfo_(typeinfo),\n      own_typeinfo_(false),\n      done_(false),\n      ignore_unknown_fields_(false),\n      element_(NULL),\n      size_insert_(),\n      output_(output),\n      buffer_(),\n      adapter_(&buffer_),\n      stream_(new CodedOutputStream(&adapter_)),\n      listener_(listener),\n      invalid_depth_(0),\n      tracker_(new ObjectLocationTracker()) {}\n\nProtoWriter::~ProtoWriter() {\n  if (own_typeinfo_) {\n    delete typeinfo_;\n  }\n  if (element_ == NULL) return;\n  // Cleanup explicitly in order to avoid destructor stack overflow when input\n  // is deeply nested.\n  // Cast to BaseElement to avoid doing additional checks (like missing fields)\n  // during pop().\n  google::protobuf::scoped_ptr<BaseElement> element(\n      static_cast<BaseElement*>(element_.get())->pop<BaseElement>());\n  while (element != NULL) {\n    element.reset(element->pop<BaseElement>());\n  }\n}\n\nnamespace {\n\n// Writes an INT32 field, including tag to the stream.\ninline Status WriteInt32(int field_number, const DataPiece& data,\n                         CodedOutputStream* stream) {\n  StatusOr<int32> i32 = data.ToInt32();\n  if (i32.ok()) {\n    WireFormatLite::WriteInt32(field_number, i32.ValueOrDie(), stream);\n  }\n  return i32.status();\n}\n\n// writes an SFIXED32 field, including tag, to the stream.\ninline Status WriteSFixed32(int field_number, const DataPiece& data,\n                            CodedOutputStream* stream) {\n  StatusOr<int32> i32 = data.ToInt32();\n  if (i32.ok()) {\n    WireFormatLite::WriteSFixed32(field_number, i32.ValueOrDie(), stream);\n  }\n  return i32.status();\n}\n\n// Writes an SINT32 field, including tag, to the stream.\ninline Status WriteSInt32(int field_number, const DataPiece& data,\n                          CodedOutputStream* stream) {\n  StatusOr<int32> i32 = data.ToInt32();\n  if (i32.ok()) {\n    WireFormatLite::WriteSInt32(field_number, i32.ValueOrDie(), stream);\n  }\n  return i32.status();\n}\n\n// Writes a FIXED32 field, including tag, to the stream.\ninline Status WriteFixed32(int field_number, const DataPiece& data,\n                           CodedOutputStream* stream) {\n  StatusOr<uint32> u32 = data.ToUint32();\n  if (u32.ok()) {\n    WireFormatLite::WriteFixed32(field_number, u32.ValueOrDie(), stream);\n  }\n  return u32.status();\n}\n\n// Writes a UINT32 field, including tag, to the stream.\ninline Status WriteUInt32(int field_number, const DataPiece& data,\n                          CodedOutputStream* stream) {\n  StatusOr<uint32> u32 = data.ToUint32();\n  if (u32.ok()) {\n    WireFormatLite::WriteUInt32(field_number, u32.ValueOrDie(), stream);\n  }\n  return u32.status();\n}\n\n// Writes an INT64 field, including tag, to the stream.\ninline Status WriteInt64(int field_number, const DataPiece& data,\n                         CodedOutputStream* stream) {\n  StatusOr<int64> i64 = data.ToInt64();\n  if (i64.ok()) {\n    WireFormatLite::WriteInt64(field_number, i64.ValueOrDie(), stream);\n  }\n  return i64.status();\n}\n\n// Writes an SFIXED64 field, including tag, to the stream.\ninline Status WriteSFixed64(int field_number, const DataPiece& data,\n                            CodedOutputStream* stream) {\n  StatusOr<int64> i64 = data.ToInt64();\n  if (i64.ok()) {\n    WireFormatLite::WriteSFixed64(field_number, i64.ValueOrDie(), stream);\n  }\n  return i64.status();\n}\n\n// Writes an SINT64 field, including tag, to the stream.\ninline Status WriteSInt64(int field_number, const DataPiece& data,\n                          CodedOutputStream* stream) {\n  StatusOr<int64> i64 = data.ToInt64();\n  if (i64.ok()) {\n    WireFormatLite::WriteSInt64(field_number, i64.ValueOrDie(), stream);\n  }\n  return i64.status();\n}\n\n// Writes a FIXED64 field, including tag, to the stream.\ninline Status WriteFixed64(int field_number, const DataPiece& data,\n                           CodedOutputStream* stream) {\n  StatusOr<uint64> u64 = data.ToUint64();\n  if (u64.ok()) {\n    WireFormatLite::WriteFixed64(field_number, u64.ValueOrDie(), stream);\n  }\n  return u64.status();\n}\n\n// Writes a UINT64 field, including tag, to the stream.\ninline Status WriteUInt64(int field_number, const DataPiece& data,\n                          CodedOutputStream* stream) {\n  StatusOr<uint64> u64 = data.ToUint64();\n  if (u64.ok()) {\n    WireFormatLite::WriteUInt64(field_number, u64.ValueOrDie(), stream);\n  }\n  return u64.status();\n}\n\n// Writes a DOUBLE field, including tag, to the stream.\ninline Status WriteDouble(int field_number, const DataPiece& data,\n                          CodedOutputStream* stream) {\n  StatusOr<double> d = data.ToDouble();\n  if (d.ok()) {\n    WireFormatLite::WriteDouble(field_number, d.ValueOrDie(), stream);\n  }\n  return d.status();\n}\n\n// Writes a FLOAT field, including tag, to the stream.\ninline Status WriteFloat(int field_number, const DataPiece& data,\n                         CodedOutputStream* stream) {\n  StatusOr<float> f = data.ToFloat();\n  if (f.ok()) {\n    WireFormatLite::WriteFloat(field_number, f.ValueOrDie(), stream);\n  }\n  return f.status();\n}\n\n// Writes a BOOL field, including tag, to the stream.\ninline Status WriteBool(int field_number, const DataPiece& data,\n                        CodedOutputStream* stream) {\n  StatusOr<bool> b = data.ToBool();\n  if (b.ok()) {\n    WireFormatLite::WriteBool(field_number, b.ValueOrDie(), stream);\n  }\n  return b.status();\n}\n\n// Writes a BYTES field, including tag, to the stream.\ninline Status WriteBytes(int field_number, const DataPiece& data,\n                         CodedOutputStream* stream) {\n  StatusOr<string> c = data.ToBytes();\n  if (c.ok()) {\n    WireFormatLite::WriteBytes(field_number, c.ValueOrDie(), stream);\n  }\n  return c.status();\n}\n\n// Writes a STRING field, including tag, to the stream.\ninline Status WriteString(int field_number, const DataPiece& data,\n                          CodedOutputStream* stream) {\n  StatusOr<string> s = data.ToString();\n  if (s.ok()) {\n    WireFormatLite::WriteString(field_number, s.ValueOrDie(), stream);\n  }\n  return s.status();\n}\n\n// Writes an ENUM field, including tag, to the stream.\ninline Status WriteEnum(int field_number, const DataPiece& data,\n                        const google::protobuf::Enum* enum_type,\n                        CodedOutputStream* stream) {\n  StatusOr<int> e = data.ToEnum(enum_type);\n  if (e.ok()) {\n    WireFormatLite::WriteEnum(field_number, e.ValueOrDie(), stream);\n  }\n  return e.status();\n}\n\n// Given a google::protobuf::Type, returns the set of all required fields.\nstd::set<const google::protobuf::Field*> GetRequiredFields(\n    const google::protobuf::Type& type) {\n  std::set<const google::protobuf::Field*> required;\n  for (int i = 0; i < type.fields_size(); i++) {\n    const google::protobuf::Field& field = type.fields(i);\n    if (field.cardinality() ==\n        google::protobuf::Field_Cardinality_CARDINALITY_REQUIRED) {\n      required.insert(&field);\n    }\n  }\n  return required;\n}\n\n}  // namespace\n\nProtoWriter::ProtoElement::ProtoElement(const TypeInfo* typeinfo,\n                                        const google::protobuf::Type& type,\n                                        ProtoWriter* enclosing)\n    : BaseElement(NULL),\n      ow_(enclosing),\n      parent_field_(NULL),\n      typeinfo_(typeinfo),\n      proto3_(type.syntax() == google::protobuf::SYNTAX_PROTO3),\n      type_(type),\n      size_index_(-1),\n      array_index_(-1),\n      // oneof_indices_ values are 1-indexed (0 means not present).\n      oneof_indices_(type.oneofs_size() + 1) {\n  if (!proto3_) {\n    required_fields_ = GetRequiredFields(type_);\n  }\n}\n\nProtoWriter::ProtoElement::ProtoElement(ProtoWriter::ProtoElement* parent,\n                                        const google::protobuf::Field* field,\n                                        const google::protobuf::Type& type,\n                                        bool is_list)\n    : BaseElement(parent),\n      ow_(this->parent()->ow_),\n      parent_field_(field),\n      typeinfo_(this->parent()->typeinfo_),\n      proto3_(type.syntax() == google::protobuf::SYNTAX_PROTO3),\n      type_(type),\n      size_index_(\n          !is_list && field->kind() == google::protobuf::Field_Kind_TYPE_MESSAGE\n              ? ow_->size_insert_.size()\n              : -1),\n      array_index_(is_list ? 0 : -1),\n      // oneof_indices_ values are 1-indexed (0 means not present).\n      oneof_indices_(type_.oneofs_size() + 1) {\n  if (!is_list) {\n    if (ow_->IsRepeated(*field)) {\n      // Update array_index_ if it is an explicit list.\n      if (this->parent()->array_index_ >= 0) this->parent()->array_index_++;\n    } else if (!proto3_) {\n      // For required fields tracking.\n      this->parent()->RegisterField(field);\n    }\n\n    if (field->kind() == google::protobuf::Field_Kind_TYPE_MESSAGE) {\n      if (!proto3_) {\n        required_fields_ = GetRequiredFields(type_);\n      }\n      int start_pos = ow_->stream_->ByteCount();\n      // length of serialized message is the final buffer position minus\n      // starting buffer position, plus length adjustments for size fields\n      // of any nested messages. We start with -start_pos here, so we only\n      // need to add the final buffer position to it at the end.\n      SizeInfo info = {start_pos, -start_pos};\n      ow_->size_insert_.push_back(info);\n    }\n  }\n}\n\nProtoWriter::ProtoElement* ProtoWriter::ProtoElement::pop() {\n  if (!proto3_) {\n    // Calls the registered error listener for any required field(s) not yet\n    // seen.\n    for (set<const google::protobuf::Field*>::iterator it =\n             required_fields_.begin();\n         it != required_fields_.end(); ++it) {\n      ow_->MissingField((*it)->name());\n    }\n  }\n  // Computes the total number of proto bytes used by a message, also adjusts\n  // the size of all parent messages by the length of this size field.\n  // If size_index_ < 0, this is not a message, so no size field is added.\n  if (size_index_ >= 0) {\n    // Add the final buffer position to compute the total length of this\n    // serialized message. The stored value (before this addition) already\n    // contains the total length of the size fields of all nested messages\n    // minus the initial buffer position.\n    ow_->size_insert_[size_index_].size += ow_->stream_->ByteCount();\n    // Calculate the length required to serialize the size field of the\n    // message, and propagate this additional size information upward to\n    // all enclosing messages.\n    int size = ow_->size_insert_[size_index_].size;\n    int length = CodedOutputStream::VarintSize32(size);\n    for (ProtoElement* e = parent(); e != NULL; e = e->parent()) {\n      // Only nested messages have size field, lists do not have size field.\n      if (e->size_index_ >= 0) {\n        ow_->size_insert_[e->size_index_].size += length;\n      }\n    }\n  }\n  return BaseElement::pop<ProtoElement>();\n}\n\nvoid ProtoWriter::ProtoElement::RegisterField(\n    const google::protobuf::Field* field) {\n  if (!required_fields_.empty() &&\n      field->cardinality() ==\n          google::protobuf::Field_Cardinality_CARDINALITY_REQUIRED) {\n    required_fields_.erase(field);\n  }\n}\n\nstring ProtoWriter::ProtoElement::ToString() const {\n  if (parent() == NULL) return \"\";\n  string loc = parent()->ToString();\n  if (!ow_->IsRepeated(*parent_field_) ||\n      parent()->parent_field_ != parent_field_) {\n    string name = parent_field_->name();\n    int i = 0;\n    while (i < name.size() && (ascii_isalnum(name[i]) || name[i] == '_')) ++i;\n    if (i > 0 && i == name.size()) {  // safe field name\n      if (loc.empty()) {\n        loc = name;\n      } else {\n        StrAppend(&loc, \".\", name);\n      }\n    } else {\n      StrAppend(&loc, \"[\\\"\", CEscape(name), \"\\\"]\");\n    }\n  }\n  if (ow_->IsRepeated(*parent_field_) && array_index_ > 0) {\n    StrAppend(&loc, \"[\", array_index_ - 1, \"]\");\n  }\n  return loc.empty() ? \".\" : loc;\n}\n\nbool ProtoWriter::ProtoElement::IsOneofIndexTaken(int32 index) {\n  return oneof_indices_[index];\n}\n\nvoid ProtoWriter::ProtoElement::TakeOneofIndex(int32 index) {\n  oneof_indices_[index] = true;\n}\n\nvoid ProtoWriter::InvalidName(StringPiece unknown_name, StringPiece message) {\n  listener_->InvalidName(location(), ToSnakeCase(unknown_name), message);\n}\n\nvoid ProtoWriter::InvalidValue(StringPiece type_name, StringPiece value) {\n  listener_->InvalidValue(location(), type_name, value);\n}\n\nvoid ProtoWriter::MissingField(StringPiece missing_name) {\n  listener_->MissingField(location(), missing_name);\n}\n\nProtoWriter* ProtoWriter::StartObject(StringPiece name) {\n  // Starting the root message. Create the root ProtoElement and return.\n  if (element_ == NULL) {\n    if (!name.empty()) {\n      InvalidName(name, \"Root element should not be named.\");\n    }\n    element_.reset(new ProtoElement(typeinfo_, master_type_, this));\n    return this;\n  }\n\n  const google::protobuf::Field* field = NULL;\n  field = BeginNamed(name, false);\n  if (field == NULL) return this;\n\n  // Check to see if this field is a oneof and that no oneof in that group has\n  // already been set.\n  if (!ValidOneof(*field, name)) {\n    ++invalid_depth_;\n    return this;\n  }\n\n  const google::protobuf::Type* type = LookupType(field);\n  if (type == NULL) {\n    ++invalid_depth_;\n    InvalidName(name,\n                StrCat(\"Missing descriptor for field: \", field->type_url()));\n    return this;\n  }\n\n  return StartObjectField(*field, *type);\n}\n\nProtoWriter* ProtoWriter::EndObject() {\n  if (invalid_depth_ > 0) {\n    --invalid_depth_;\n    return this;\n  }\n\n  if (element_ != NULL) {\n    element_.reset(element_->pop());\n  }\n\n\n  // If ending the root element,\n  // then serialize the full message with calculated sizes.\n  if (element_ == NULL) {\n    WriteRootMessage();\n  }\n  return this;\n}\n\nProtoWriter* ProtoWriter::StartList(StringPiece name) {\n  const google::protobuf::Field* field = BeginNamed(name, true);\n  if (field == NULL) return this;\n\n  if (!ValidOneof(*field, name)) {\n    ++invalid_depth_;\n    return this;\n  }\n\n  const google::protobuf::Type* type = LookupType(field);\n  if (type == NULL) {\n    ++invalid_depth_;\n    InvalidName(name,\n                StrCat(\"Missing descriptor for field: \", field->type_url()));\n    return this;\n  }\n\n  return StartListField(*field, *type);\n}\n\nProtoWriter* ProtoWriter::EndList() {\n  if (invalid_depth_ > 0) {\n    --invalid_depth_;\n  } else if (element_ != NULL) {\n    element_.reset(element_->pop());\n  }\n  return this;\n}\n\nProtoWriter* ProtoWriter::RenderDataPiece(StringPiece name,\n                                          const DataPiece& data) {\n  Status status;\n  if (invalid_depth_ > 0) return this;\n\n  const google::protobuf::Field* field = Lookup(name);\n  if (field == NULL) return this;\n\n  if (!ValidOneof(*field, name)) return this;\n\n  const google::protobuf::Type* type = LookupType(field);\n  if (type == NULL) {\n    InvalidName(name,\n                StrCat(\"Missing descriptor for field: \", field->type_url()));\n    return this;\n  }\n\n  return RenderPrimitiveField(*field, *type, data);\n}\n\nbool ProtoWriter::ValidOneof(const google::protobuf::Field& field,\n                             StringPiece unnormalized_name) {\n  if (element_ == NULL) return true;\n\n  if (field.oneof_index() > 0) {\n    if (element_->IsOneofIndexTaken(field.oneof_index())) {\n      InvalidValue(\n          \"oneof\",\n          StrCat(\"oneof field '\",\n                 element_->type().oneofs(field.oneof_index() - 1),\n                 \"' is already set. Cannot set '\", unnormalized_name, \"'\"));\n      return false;\n    }\n    element_->TakeOneofIndex(field.oneof_index());\n  }\n  return true;\n}\n\nbool ProtoWriter::IsRepeated(const google::protobuf::Field& field) {\n  return field.cardinality() ==\n         google::protobuf::Field_Cardinality_CARDINALITY_REPEATED;\n}\n\nProtoWriter* ProtoWriter::StartObjectField(const google::protobuf::Field& field,\n                                           const google::protobuf::Type& type) {\n    WriteTag(field);\n  element_.reset(new ProtoElement(element_.release(), &field, type, false));\n  return this;\n}\n\nProtoWriter* ProtoWriter::StartListField(const google::protobuf::Field& field,\n                                         const google::protobuf::Type& type) {\n  element_.reset(new ProtoElement(element_.release(), &field, type, true));\n  return this;\n}\n\nProtoWriter* ProtoWriter::RenderPrimitiveField(\n    const google::protobuf::Field& field, const google::protobuf::Type& type,\n    const DataPiece& data) {\n  Status status;\n\n  // Pushing a ProtoElement and then pop it off at the end for 2 purposes:\n  // error location reporting and required field accounting.\n  //\n  // For proto3, since there is no required field tracking, we only need to push\n  // ProtoElement for error cases.\n  if (!element_->proto3()) {\n    element_.reset(new ProtoElement(element_.release(), &field, type, false));\n  }\n\n  if (field.kind() == google::protobuf::Field_Kind_TYPE_UNKNOWN ||\n      field.kind() == google::protobuf::Field_Kind_TYPE_MESSAGE) {\n    // Push a ProtoElement for location reporting purposes.\n    if (element_->proto3()) {\n      element_.reset(new ProtoElement(element_.release(), &field, type, false));\n    }\n    InvalidValue(field.type_url().empty()\n                     ? google::protobuf::Field_Kind_Name(field.kind())\n                     : field.type_url(),\n                 data.ValueAsStringOrDefault(\"\"));\n    element_.reset(element()->pop());\n    return this;\n  }\n\n  switch (field.kind()) {\n    case google::protobuf::Field_Kind_TYPE_INT32: {\n      status = WriteInt32(field.number(), data, stream_.get());\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_SFIXED32: {\n      status = WriteSFixed32(field.number(), data, stream_.get());\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_SINT32: {\n      status = WriteSInt32(field.number(), data, stream_.get());\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_FIXED32: {\n      status = WriteFixed32(field.number(), data, stream_.get());\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_UINT32: {\n      status = WriteUInt32(field.number(), data, stream_.get());\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_INT64: {\n      status = WriteInt64(field.number(), data, stream_.get());\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_SFIXED64: {\n      status = WriteSFixed64(field.number(), data, stream_.get());\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_SINT64: {\n      status = WriteSInt64(field.number(), data, stream_.get());\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_FIXED64: {\n      status = WriteFixed64(field.number(), data, stream_.get());\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_UINT64: {\n      status = WriteUInt64(field.number(), data, stream_.get());\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_DOUBLE: {\n      status = WriteDouble(field.number(), data, stream_.get());\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_FLOAT: {\n      status = WriteFloat(field.number(), data, stream_.get());\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_BOOL: {\n      status = WriteBool(field.number(), data, stream_.get());\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_BYTES: {\n      status = WriteBytes(field.number(), data, stream_.get());\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_STRING: {\n      status = WriteString(field.number(), data, stream_.get());\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_ENUM: {\n      status = WriteEnum(field.number(), data,\n                         typeinfo_->GetEnumByTypeUrl(field.type_url()),\n                         stream_.get());\n      break;\n    }\n    default:  // TYPE_GROUP or TYPE_MESSAGE\n      status = Status(INVALID_ARGUMENT, data.ToString().ValueOrDie());\n  }\n\n  if (!status.ok()) {\n    // Push a ProtoElement for location reporting purposes.\n    if (element_->proto3()) {\n      element_.reset(new ProtoElement(element_.release(), &field, type, false));\n    }\n    InvalidValue(google::protobuf::Field_Kind_Name(field.kind()),\n                 status.error_message());\n    element_.reset(element()->pop());\n    return this;\n  }\n\n  if (!element_->proto3()) element_.reset(element()->pop());\n\n  return this;\n}\n\nconst google::protobuf::Field* ProtoWriter::BeginNamed(StringPiece name,\n                                                       bool is_list) {\n  if (invalid_depth_ > 0) {\n    ++invalid_depth_;\n    return NULL;\n  }\n  const google::protobuf::Field* field = Lookup(name);\n  if (field == NULL) {\n    ++invalid_depth_;\n    // InvalidName() already called in Lookup().\n    return NULL;\n  }\n  if (is_list && !IsRepeated(*field)) {\n    ++invalid_depth_;\n    InvalidName(name, \"Proto field is not repeating, cannot start list.\");\n    return NULL;\n  }\n  return field;\n}\n\nconst google::protobuf::Field* ProtoWriter::Lookup(\n    StringPiece unnormalized_name) {\n  ProtoElement* e = element();\n  if (e == NULL) {\n    InvalidName(unnormalized_name, \"Root element must be a message.\");\n    return NULL;\n  }\n  if (unnormalized_name.empty()) {\n    // Objects in repeated field inherit the same field descriptor.\n    if (e->parent_field() == NULL) {\n      InvalidName(unnormalized_name, \"Proto fields must have a name.\");\n    } else if (!IsRepeated(*e->parent_field())) {\n      InvalidName(unnormalized_name, \"Proto fields must have a name.\");\n      return NULL;\n    }\n    return e->parent_field();\n  }\n  const google::protobuf::Field* field =\n      typeinfo_->FindField(&e->type(), unnormalized_name);\n  if (field == NULL && !ignore_unknown_fields_) {\n    InvalidName(unnormalized_name, \"Cannot find field.\");\n  }\n  return field;\n}\n\nconst google::protobuf::Type* ProtoWriter::LookupType(\n    const google::protobuf::Field* field) {\n  return ((field->kind() == google::protobuf::Field_Kind_TYPE_MESSAGE ||\n           field->kind() == google::protobuf::Field_Kind_TYPE_GROUP)\n              ? typeinfo_->GetTypeByTypeUrl(field->type_url())\n              : &element_->type());\n}\n\nvoid ProtoWriter::WriteRootMessage() {\n  GOOGLE_DCHECK(!done_);\n  int curr_pos = 0;\n  // Calls the destructor of CodedOutputStream to remove any uninitialized\n  // memory from the Cord before we read it.\n  stream_.reset(NULL);\n  const void* data;\n  int length;\n  google::protobuf::io::ArrayInputStream input_stream(buffer_.data(), buffer_.size());\n  while (input_stream.Next(&data, &length)) {\n    if (length == 0) continue;\n    int num_bytes = length;\n    // Write up to where we need to insert the size field.\n    // The number of bytes we may write is the smaller of:\n    //   - the current fragment size\n    //   - the distance to the next position where a size field needs to be\n    //     inserted.\n    if (!size_insert_.empty() &&\n        size_insert_.front().pos - curr_pos < num_bytes) {\n      num_bytes = size_insert_.front().pos - curr_pos;\n    }\n    output_->Append(static_cast<const char*>(data), num_bytes);\n    if (num_bytes < length) {\n      input_stream.BackUp(length - num_bytes);\n    }\n    curr_pos += num_bytes;\n    // Insert the size field.\n    //   size_insert_.front():      the next <index, size> pair to be written.\n    //   size_insert_.front().pos:  position of the size field.\n    //   size_insert_.front().size: the size (integer) to be inserted.\n    if (!size_insert_.empty() && curr_pos == size_insert_.front().pos) {\n      // Varint32 occupies at most 10 bytes.\n      uint8 insert_buffer[10];\n      uint8* insert_buffer_pos = CodedOutputStream::WriteVarint32ToArray(\n          size_insert_.front().size, insert_buffer);\n      output_->Append(reinterpret_cast<const char*>(insert_buffer),\n                      insert_buffer_pos - insert_buffer);\n      size_insert_.pop_front();\n    }\n  }\n  output_->Flush();\n  stream_.reset(new CodedOutputStream(&adapter_));\n  done_ = true;\n}\n\nvoid ProtoWriter::WriteTag(const google::protobuf::Field& field) {\n  WireFormatLite::WireType wire_type = WireFormatLite::WireTypeForFieldType(\n      static_cast<WireFormatLite::FieldType>(field.kind()));\n  stream_->WriteTag(WireFormatLite::MakeTag(field.number(), wire_type));\n}\n\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/proto_writer.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTO_WRITER_H__\n#define GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTO_WRITER_H__\n\n#include <deque>\n#include <string>\n#include <vector>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/util/internal/type_info.h>\n#include <google/protobuf/util/internal/datapiece.h>\n#include <google/protobuf/util/internal/error_listener.h>\n#include <google/protobuf/util/internal/structured_objectwriter.h>\n#include <google/protobuf/util/type_resolver.h>\n#include <google/protobuf/stubs/bytestream.h>\n#include <google/protobuf/stubs/hash.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\nclass CodedOutputStream;\n}  // namespace io\n}  // namespace protobuf\n\n\nnamespace protobuf {\nclass Type;\nclass Field;\n}  // namespace protobuf\n\n\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\nclass ObjectLocationTracker;\n\n// An ObjectWriter that can write protobuf bytes directly from writer events.\n// This class does not support special types like Struct or Map. However, since\n// this class supports raw protobuf, it can be used to provide support for\n// special types by inheriting from it or by wrapping it.\n//\n// It also supports streaming.\nclass LIBPROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter {\n public:\n// Constructor. Does not take ownership of any parameter passed in.\n  ProtoWriter(TypeResolver* type_resolver, const google::protobuf::Type& type,\n              strings::ByteSink* output, ErrorListener* listener);\n  virtual ~ProtoWriter();\n\n  // ObjectWriter methods.\n  virtual ProtoWriter* StartObject(StringPiece name);\n  virtual ProtoWriter* EndObject();\n  virtual ProtoWriter* StartList(StringPiece name);\n  virtual ProtoWriter* EndList();\n  virtual ProtoWriter* RenderBool(StringPiece name, bool value) {\n    return RenderDataPiece(name, DataPiece(value));\n  }\n  virtual ProtoWriter* RenderInt32(StringPiece name, int32 value) {\n    return RenderDataPiece(name, DataPiece(value));\n  }\n  virtual ProtoWriter* RenderUint32(StringPiece name, uint32 value) {\n    return RenderDataPiece(name, DataPiece(value));\n  }\n  virtual ProtoWriter* RenderInt64(StringPiece name, int64 value) {\n    return RenderDataPiece(name, DataPiece(value));\n  }\n  virtual ProtoWriter* RenderUint64(StringPiece name, uint64 value) {\n    return RenderDataPiece(name, DataPiece(value));\n  }\n  virtual ProtoWriter* RenderDouble(StringPiece name, double value) {\n    return RenderDataPiece(name, DataPiece(value));\n  }\n  virtual ProtoWriter* RenderFloat(StringPiece name, float value) {\n    return RenderDataPiece(name, DataPiece(value));\n  }\n  virtual ProtoWriter* RenderString(StringPiece name, StringPiece value) {\n    return RenderDataPiece(name,\n                           DataPiece(value, use_strict_base64_decoding()));\n  }\n  virtual ProtoWriter* RenderBytes(StringPiece name, StringPiece value) {\n    return RenderDataPiece(\n        name, DataPiece(value, false, use_strict_base64_decoding()));\n  }\n  virtual ProtoWriter* RenderNull(StringPiece name) {\n    return RenderDataPiece(name, DataPiece::NullData());\n  }\n\n\n  // Renders a DataPiece 'value' into a field whose wire type is determined\n  // from the given field 'name'.\n  virtual ProtoWriter* RenderDataPiece(StringPiece name,\n                                       const DataPiece& value);\n\n  // Returns the location tracker to use for tracking locations for errors.\n  const LocationTrackerInterface& location() {\n    return element_ != NULL ? *element_ : *tracker_;\n  }\n\n  // When true, we finished writing to output a complete message.\n  bool done() { return done_; }\n\n  // Returns the proto stream object.\n  google::protobuf::io::CodedOutputStream* stream() { return stream_.get(); }\n\n  // Getters and mutators of invalid_depth_.\n  void IncrementInvalidDepth() { ++invalid_depth_; }\n  void DecrementInvalidDepth() { --invalid_depth_; }\n  int invalid_depth() { return invalid_depth_; }\n\n  ErrorListener* listener() { return listener_; }\n\n  const TypeInfo* typeinfo() { return typeinfo_; }\n\n  void set_ignore_unknown_fields(bool ignore_unknown_fields) {\n    ignore_unknown_fields_ = ignore_unknown_fields;\n  }\n\n protected:\n  class LIBPROTOBUF_EXPORT ProtoElement : public BaseElement, public LocationTrackerInterface {\n   public:\n    // Constructor for the root element. No parent nor field.\n    ProtoElement(const TypeInfo* typeinfo, const google::protobuf::Type& type,\n                 ProtoWriter* enclosing);\n\n    // Constructor for a field of an element.\n    ProtoElement(ProtoElement* parent, const google::protobuf::Field* field,\n                 const google::protobuf::Type& type, bool is_list);\n\n    virtual ~ProtoElement() {}\n\n    // Called just before the destructor for clean up:\n    //   - reports any missing required fields\n    //   - computes the space needed by the size field, and augment the\n    //     length of all parent messages by this additional space.\n    //   - releases and returns the parent pointer.\n    ProtoElement* pop();\n\n    // Accessors\n    // parent_field() may be NULL if we are at root.\n    const google::protobuf::Field* parent_field() const {\n      return parent_field_;\n    }\n    const google::protobuf::Type& type() const { return type_; }\n\n    // Registers field for accounting required fields.\n    void RegisterField(const google::protobuf::Field* field);\n\n    // To report location on error messages.\n    virtual string ToString() const;\n\n    virtual ProtoElement* parent() const {\n      return static_cast<ProtoElement*>(BaseElement::parent());\n    }\n\n    // Returns true if the index is already taken by a preceding oneof input.\n    bool IsOneofIndexTaken(int32 index);\n\n    // Marks the oneof 'index' as taken. Future inputs to this oneof will\n    // generate an error.\n    void TakeOneofIndex(int32 index);\n\n    bool proto3() { return proto3_; }\n\n   private:\n    // Used for access to variables of the enclosing instance of\n    // ProtoWriter.\n    ProtoWriter* ow_;\n\n    // Describes the element as a field in the parent message.\n    // parent_field_ is NULL if and only if this element is the root element.\n    const google::protobuf::Field* parent_field_;\n\n    // TypeInfo to lookup types.\n    const TypeInfo* typeinfo_;\n\n    // Whether the type_ is proto3 or not.\n    bool proto3_;\n\n    // Additional variables if this element is a message:\n    // (Root element is always a message).\n    // type_             : the type of this element.\n    // required_fields_  : set of required fields.\n    // size_index_       : index into ProtoWriter::size_insert_\n    //                     for later insertion of serialized message length.\n    const google::protobuf::Type& type_;\n    std::set<const google::protobuf::Field*> required_fields_;\n    const int size_index_;\n\n    // Tracks position in repeated fields, needed for LocationTrackerInterface.\n    int array_index_;\n\n    // Set of oneof indices already seen for the type_. Used to validate\n    // incoming messages so no more than one oneof is set.\n    std::vector<bool> oneof_indices_;\n\n    GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(ProtoElement);\n  };\n\n  // Container for inserting 'size' information at the 'pos' position.\n  struct SizeInfo {\n    const int pos;\n    int size;\n  };\n\n  ProtoWriter(const TypeInfo* typeinfo, const google::protobuf::Type& type,\n              strings::ByteSink* output, ErrorListener* listener);\n\n  virtual ProtoElement* element() { return element_.get(); }\n\n  // Helper methods for calling ErrorListener. See error_listener.h.\n  void InvalidName(StringPiece unknown_name, StringPiece message);\n  void InvalidValue(StringPiece type_name, StringPiece value);\n  void MissingField(StringPiece missing_name);\n\n  // Common code for BeginObject() and BeginList() that does invalid_depth_\n  // bookkeeping associated with name lookup.\n  const google::protobuf::Field* BeginNamed(StringPiece name, bool is_list);\n\n  // Lookup the field in the current element. Looks in the base descriptor\n  // and in any extension. This will report an error if the field cannot be\n  // found when ignore_unknown_names_ is false or if multiple matching\n  // extensions are found.\n  const google::protobuf::Field* Lookup(StringPiece name);\n\n  // Lookup the field type in the type descriptor. Returns NULL if the type\n  // is not known.\n  const google::protobuf::Type* LookupType(\n      const google::protobuf::Field* field);\n\n  // Write serialized output to the final output ByteSink, inserting all\n  // the size information for nested messages that are missing from the\n  // intermediate Cord buffer.\n  void WriteRootMessage();\n\n  // Helper method to write proto tags based on the given field.\n  void WriteTag(const google::protobuf::Field& field);\n\n\n  // Returns true if the field for type_ can be set as a oneof. If field is not\n  // a oneof type, this function does nothing and returns true.\n  // If another field for this oneof is already set, this function returns\n  // false. It also calls the appropriate error callback.\n  // unnormalized_name is used for error string.\n  bool ValidOneof(const google::protobuf::Field& field,\n                  StringPiece unnormalized_name);\n\n  // Returns true if the field is repeated.\n  bool IsRepeated(const google::protobuf::Field& field);\n\n  // Starts an object given the field and the enclosing type.\n  ProtoWriter* StartObjectField(const google::protobuf::Field& field,\n                                const google::protobuf::Type& type);\n\n  // Starts a list given the field and the enclosing type.\n  ProtoWriter* StartListField(const google::protobuf::Field& field,\n                              const google::protobuf::Type& type);\n\n  // Renders a primitve field given the field and the enclosing type.\n  ProtoWriter* RenderPrimitiveField(const google::protobuf::Field& field,\n                                    const google::protobuf::Type& type,\n                                    const DataPiece& value);\n\n private:\n  // Variables for describing the structure of the input tree:\n  // master_type_: descriptor for the whole protobuf message.\n  // typeinfo_ : the TypeInfo object to lookup types.\n  const google::protobuf::Type& master_type_;\n  const TypeInfo* typeinfo_;\n  // Whether we own the typeinfo_ object.\n  bool own_typeinfo_;\n\n  // Indicates whether we finished writing root message completely.\n  bool done_;\n\n  // If true, don't report unknown field names to the listener.\n  bool ignore_unknown_fields_;\n\n  // Variable for internal state processing:\n  // element_    : the current element.\n  // size_insert_: sizes of nested messages.\n  //               pos  - position to insert the size field.\n  //               size - size value to be inserted.\n  google::protobuf::scoped_ptr<ProtoElement> element_;\n  std::deque<SizeInfo> size_insert_;\n\n  // Variables for output generation:\n  // output_  : pointer to an external ByteSink for final user-visible output.\n  // buffer_  : buffer holding partial message before being ready for output_.\n  // adapter_ : internal adapter between CodedOutputStream and buffer_.\n  // stream_  : wrapper for writing tags and other encodings in wire format.\n  strings::ByteSink* output_;\n  string buffer_;\n  google::protobuf::io::StringOutputStream adapter_;\n  google::protobuf::scoped_ptr<google::protobuf::io::CodedOutputStream> stream_;\n\n  // Variables for error tracking and reporting:\n  // listener_     : a place to report any errors found.\n  // invalid_depth_: number of enclosing invalid nested messages.\n  // tracker_      : the root location tracker interface.\n  ErrorListener* listener_;\n  int invalid_depth_;\n  google::protobuf::scoped_ptr<LocationTrackerInterface> tracker_;\n\n  GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(ProtoWriter);\n};\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTO_WRITER_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/protostream_objectsource.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/internal/protostream_objectsource.h>\n\n#include <utility>\n\n#include <google/protobuf/stubs/casts.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/stringprintf.h>\n#include <google/protobuf/stubs/time.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/wire_format_lite.h>\n#include <google/protobuf/util/internal/field_mask_utility.h>\n#include <google/protobuf/util/internal/constants.h>\n#include <google/protobuf/util/internal/utility.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/map_util.h>\n#include <google/protobuf/stubs/status_macros.h>\n\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nusing util::Status;\nusing util::StatusOr;\nnamespace error {\nusing util::error::Code;\nusing util::error::INTERNAL;\n}\nnamespace converter {\n\nusing google::protobuf::Descriptor;\nusing google::protobuf::EnumValueDescriptor;\nusing google::protobuf::FieldDescriptor;\nusing google::protobuf::internal::WireFormat;\nusing google::protobuf::internal::WireFormatLite;\nusing util::Status;\nusing util::StatusOr;\n\nnamespace {\n\nstatic int kDefaultMaxRecursionDepth = 64;\n\n// Finds a field with the given number. NULL if none found.\nconst google::protobuf::Field* FindFieldByNumber(\n    const google::protobuf::Type& type, int number);\n\n// Returns true if the field is packable.\nbool IsPackable(const google::protobuf::Field& field);\n\n// Finds an enum value with the given number. NULL if none found.\nconst google::protobuf::EnumValue* FindEnumValueByNumber(\n    const google::protobuf::Enum& tech_enum, int number);\n\n// Utility function to format nanos.\nconst string FormatNanos(uint32 nanos);\n\nStatusOr<string> MapKeyDefaultValueAsString(\n    const google::protobuf::Field& field) {\n  switch (field.kind()) {\n    case google::protobuf::Field_Kind_TYPE_BOOL:\n      return string(\"false\");\n    case google::protobuf::Field_Kind_TYPE_INT32:\n    case google::protobuf::Field_Kind_TYPE_INT64:\n    case google::protobuf::Field_Kind_TYPE_UINT32:\n    case google::protobuf::Field_Kind_TYPE_UINT64:\n    case google::protobuf::Field_Kind_TYPE_SINT32:\n    case google::protobuf::Field_Kind_TYPE_SINT64:\n    case google::protobuf::Field_Kind_TYPE_SFIXED32:\n    case google::protobuf::Field_Kind_TYPE_SFIXED64:\n    case google::protobuf::Field_Kind_TYPE_FIXED32:\n    case google::protobuf::Field_Kind_TYPE_FIXED64:\n      return string(\"0\");\n    case google::protobuf::Field_Kind_TYPE_STRING:\n      return string();\n    default:\n      return Status(util::error::INTERNAL, \"Invalid map key type.\");\n  }\n}\n}  // namespace\n\n\nProtoStreamObjectSource::ProtoStreamObjectSource(\n    google::protobuf::io::CodedInputStream* stream, TypeResolver* type_resolver,\n    const google::protobuf::Type& type)\n    : stream_(stream),\n      typeinfo_(TypeInfo::NewTypeInfo(type_resolver)),\n      own_typeinfo_(true),\n      type_(type),\n      use_lower_camel_for_enums_(false),\n      recursion_depth_(0),\n      max_recursion_depth_(kDefaultMaxRecursionDepth),\n      render_unknown_fields_(false) {\n  GOOGLE_LOG_IF(DFATAL, stream == NULL) << \"Input stream is NULL.\";\n}\n\nProtoStreamObjectSource::ProtoStreamObjectSource(\n    google::protobuf::io::CodedInputStream* stream, const TypeInfo* typeinfo,\n    const google::protobuf::Type& type)\n    : stream_(stream),\n      typeinfo_(typeinfo),\n      own_typeinfo_(false),\n      type_(type),\n      use_lower_camel_for_enums_(false),\n      recursion_depth_(0),\n      max_recursion_depth_(kDefaultMaxRecursionDepth),\n      render_unknown_fields_(false) {\n  GOOGLE_LOG_IF(DFATAL, stream == NULL) << \"Input stream is NULL.\";\n}\n\nProtoStreamObjectSource::~ProtoStreamObjectSource() {\n  if (own_typeinfo_) {\n    delete typeinfo_;\n  }\n}\n\nStatus ProtoStreamObjectSource::NamedWriteTo(StringPiece name,\n                                             ObjectWriter* ow) const {\n  return WriteMessage(type_, name, 0, true, ow);\n}\n\nconst google::protobuf::Field* ProtoStreamObjectSource::FindAndVerifyField(\n    const google::protobuf::Type& type, uint32 tag) const {\n  // Lookup the new field in the type by tag number.\n  const google::protobuf::Field* field = FindFieldByNumber(type, tag >> 3);\n  // Verify if the field corresponds to the wire type in tag.\n  // If there is any discrepancy, mark the field as not found.\n  if (field != NULL) {\n    WireFormatLite::WireType expected_type =\n        WireFormatLite::WireTypeForFieldType(\n            static_cast<WireFormatLite::FieldType>(field->kind()));\n    WireFormatLite::WireType actual_type = WireFormatLite::GetTagWireType(tag);\n    if (actual_type != expected_type &&\n        (!IsPackable(*field) ||\n         actual_type != WireFormatLite::WIRETYPE_LENGTH_DELIMITED)) {\n      field = NULL;\n    }\n  }\n  return field;\n}\n\nStatus ProtoStreamObjectSource::WriteMessage(const google::protobuf::Type& type,\n                                             StringPiece name,\n                                             const uint32 end_tag,\n                                             bool include_start_and_end,\n                                             ObjectWriter* ow) const {\n\n    const TypeRenderer* type_renderer = FindTypeRenderer(type.name());\n    if (type_renderer != NULL) {\n      return (*type_renderer)(this, type, name, ow);\n    }\n\n  const google::protobuf::Field* field = NULL;\n  string field_name;\n  // last_tag set to dummy value that is different from tag.\n  uint32 tag = stream_->ReadTag(), last_tag = tag + 1;\n  google::protobuf::UnknownFieldSet unknown_fields;\n\n  if (include_start_and_end) {\n    ow->StartObject(name);\n  }\n  while (tag != end_tag) {\n    if (tag != last_tag) {  // Update field only if tag is changed.\n      last_tag = tag;\n      field = FindAndVerifyField(type, tag);\n      if (field != NULL) {\n        field_name = field->json_name();\n      }\n    }\n    if (field == NULL) {\n      // If we didn't find a field, skip this unknown tag.\n      // TODO(wpoon): Check return boolean value.\n      WireFormat::SkipField(stream_, tag,\n                            render_unknown_fields_ ? &unknown_fields : NULL);\n      tag = stream_->ReadTag();\n      continue;\n    }\n\n    if (field->cardinality() ==\n        google::protobuf::Field_Cardinality_CARDINALITY_REPEATED) {\n      bool check_maps = true;\n\n      if (check_maps && IsMap(*field)) {\n        ow->StartObject(field_name);\n        ASSIGN_OR_RETURN(tag, RenderMap(field, field_name, tag, ow));\n        ow->EndObject();\n      } else {\n        ASSIGN_OR_RETURN(tag, RenderList(field, field_name, tag, ow));\n      }\n    } else {\n      // Render the field.\n      RETURN_IF_ERROR(RenderField(field, field_name, ow));\n      tag = stream_->ReadTag();\n    }\n  }\n\n\n  if (include_start_and_end) {\n    ow->EndObject();\n  }\n  return Status::OK;\n}\n\nStatusOr<uint32> ProtoStreamObjectSource::RenderList(\n    const google::protobuf::Field* field, StringPiece name, uint32 list_tag,\n    ObjectWriter* ow) const {\n  uint32 tag_to_return = 0;\n  ow->StartList(name);\n  if (IsPackable(*field) &&\n      list_tag ==\n          WireFormatLite::MakeTag(field->number(),\n                                  WireFormatLite::WIRETYPE_LENGTH_DELIMITED)) {\n    RETURN_IF_ERROR(RenderPacked(field, ow));\n    // Since packed fields have a single tag, read another tag from stream to\n    // return.\n    tag_to_return = stream_->ReadTag();\n  } else {\n    do {\n      RETURN_IF_ERROR(RenderField(field, \"\", ow));\n    } while ((tag_to_return = stream_->ReadTag()) == list_tag);\n  }\n  ow->EndList();\n  return tag_to_return;\n}\n\nStatusOr<uint32> ProtoStreamObjectSource::RenderMap(\n    const google::protobuf::Field* field, StringPiece name, uint32 list_tag,\n    ObjectWriter* ow) const {\n  const google::protobuf::Type* field_type =\n      typeinfo_->GetTypeByTypeUrl(field->type_url());\n  uint32 tag_to_return = 0;\n  do {\n    // Render map entry message type.\n    uint32 buffer32;\n    stream_->ReadVarint32(&buffer32);  // message length\n    int old_limit = stream_->PushLimit(buffer32);\n    string map_key;\n    for (uint32 tag = stream_->ReadTag(); tag != 0; tag = stream_->ReadTag()) {\n      const google::protobuf::Field* field =\n          FindAndVerifyField(*field_type, tag);\n      if (field == NULL) {\n        WireFormat::SkipField(stream_, tag, NULL);\n        continue;\n      }\n      // Map field numbers are key = 1 and value = 2\n      if (field->number() == 1) {\n        map_key = ReadFieldValueAsString(*field);\n      } else if (field->number() == 2) {\n        if (map_key.empty()) {\n          // An absent map key is treated as the default.\n          const google::protobuf::Field* key_field =\n              FindFieldByNumber(*field_type, 1);\n          if (key_field == NULL) {\n            // The Type info for this map entry is incorrect. It should always\n            // have a field named \"key\" and with field number 1.\n            return Status(util::error::INTERNAL, \"Invalid map entry.\");\n          }\n          ASSIGN_OR_RETURN(map_key, MapKeyDefaultValueAsString(*key_field));\n        }\n        RETURN_IF_ERROR(RenderField(field, map_key, ow));\n      } else {\n        // The Type info for this map entry is incorrect. It should contain\n        // exactly two fields with field number 1 and 2.\n        return Status(util::error::INTERNAL, \"Invalid map entry.\");\n      }\n    }\n    stream_->PopLimit(old_limit);\n  } while ((tag_to_return = stream_->ReadTag()) == list_tag);\n  return tag_to_return;\n}\n\nStatus ProtoStreamObjectSource::RenderPacked(\n    const google::protobuf::Field* field, ObjectWriter* ow) const {\n  uint32 length;\n  stream_->ReadVarint32(&length);\n  int old_limit = stream_->PushLimit(length);\n  while (stream_->BytesUntilLimit() > 0) {\n    RETURN_IF_ERROR(RenderField(field, StringPiece(), ow));\n  }\n  stream_->PopLimit(old_limit);\n  return Status::OK;\n}\n\nStatus ProtoStreamObjectSource::RenderTimestamp(\n    const ProtoStreamObjectSource* os, const google::protobuf::Type& type,\n    StringPiece field_name, ObjectWriter* ow) {\n  pair<int64, int32> p = os->ReadSecondsAndNanos(type);\n  int64 seconds = p.first;\n  int32 nanos = p.second;\n  if (seconds > kTimestampMaxSeconds || seconds < kTimestampMinSeconds) {\n    return Status(\n        util::error::INTERNAL,\n        StrCat(\"Timestamp seconds exceeds limit for field: \", field_name));\n  }\n\n  if (nanos < 0 || nanos >= kNanosPerSecond) {\n    return Status(\n        util::error::INTERNAL,\n        StrCat(\"Timestamp nanos exceeds limit for field: \", field_name));\n  }\n\n  ow->RenderString(field_name,\n                   ::google::protobuf::internal::FormatTime(seconds, nanos));\n\n  return Status::OK;\n}\n\nStatus ProtoStreamObjectSource::RenderDuration(\n    const ProtoStreamObjectSource* os, const google::protobuf::Type& type,\n    StringPiece field_name, ObjectWriter* ow) {\n  pair<int64, int32> p = os->ReadSecondsAndNanos(type);\n  int64 seconds = p.first;\n  int32 nanos = p.second;\n  if (seconds > kDurationMaxSeconds || seconds < kDurationMinSeconds) {\n    return Status(\n        util::error::INTERNAL,\n        StrCat(\"Duration seconds exceeds limit for field: \", field_name));\n  }\n\n  if (nanos <= -kNanosPerSecond || nanos >= kNanosPerSecond) {\n    return Status(\n        util::error::INTERNAL,\n        StrCat(\"Duration nanos exceeds limit for field: \", field_name));\n  }\n\n  string sign = \"\";\n  if (seconds < 0) {\n    if (nanos > 0) {\n      return Status(util::error::INTERNAL,\n                    StrCat(\"Duration nanos is non-negative, but seconds is \"\n                           \"negative for field: \",\n                           field_name));\n    }\n    sign = \"-\";\n    seconds = -seconds;\n    nanos = -nanos;\n  } else if (seconds == 0 && nanos < 0) {\n    sign = \"-\";\n    nanos = -nanos;\n  }\n  string formatted_duration = StringPrintf(\"%s%lld%ss\", sign.c_str(), seconds,\n                                           FormatNanos(nanos).c_str());\n  ow->RenderString(field_name, formatted_duration);\n  return Status::OK;\n}\n\nStatus ProtoStreamObjectSource::RenderDouble(const ProtoStreamObjectSource* os,\n                                             const google::protobuf::Type& type,\n                                             StringPiece field_name,\n                                             ObjectWriter* ow) {\n  uint32 tag = os->stream_->ReadTag();\n  uint64 buffer64 = 0;  // default value of Double wrapper value\n  if (tag != 0) {\n    os->stream_->ReadLittleEndian64(&buffer64);\n    os->stream_->ReadTag();\n  }\n  ow->RenderDouble(field_name, bit_cast<double>(buffer64));\n  return Status::OK;\n}\n\nStatus ProtoStreamObjectSource::RenderFloat(const ProtoStreamObjectSource* os,\n                                            const google::protobuf::Type& type,\n                                            StringPiece field_name,\n                                            ObjectWriter* ow) {\n  uint32 tag = os->stream_->ReadTag();\n  uint32 buffer32 = 0;  // default value of Float wrapper value\n  if (tag != 0) {\n    os->stream_->ReadLittleEndian32(&buffer32);\n    os->stream_->ReadTag();\n  }\n  ow->RenderFloat(field_name, bit_cast<float>(buffer32));\n  return Status::OK;\n}\n\nStatus ProtoStreamObjectSource::RenderInt64(const ProtoStreamObjectSource* os,\n                                            const google::protobuf::Type& type,\n                                            StringPiece field_name,\n                                            ObjectWriter* ow) {\n  uint32 tag = os->stream_->ReadTag();\n  uint64 buffer64 = 0;  // default value of Int64 wrapper value\n  if (tag != 0) {\n    os->stream_->ReadVarint64(&buffer64);\n    os->stream_->ReadTag();\n  }\n  ow->RenderInt64(field_name, bit_cast<int64>(buffer64));\n  return Status::OK;\n}\n\nStatus ProtoStreamObjectSource::RenderUInt64(const ProtoStreamObjectSource* os,\n                                             const google::protobuf::Type& type,\n                                             StringPiece field_name,\n                                             ObjectWriter* ow) {\n  uint32 tag = os->stream_->ReadTag();\n  uint64 buffer64 = 0;  // default value of UInt64 wrapper value\n  if (tag != 0) {\n    os->stream_->ReadVarint64(&buffer64);\n    os->stream_->ReadTag();\n  }\n  ow->RenderUint64(field_name, bit_cast<uint64>(buffer64));\n  return Status::OK;\n}\n\nStatus ProtoStreamObjectSource::RenderInt32(const ProtoStreamObjectSource* os,\n                                            const google::protobuf::Type& type,\n                                            StringPiece field_name,\n                                            ObjectWriter* ow) {\n  uint32 tag = os->stream_->ReadTag();\n  uint32 buffer32 = 0;  // default value of Int32 wrapper value\n  if (tag != 0) {\n    os->stream_->ReadVarint32(&buffer32);\n    os->stream_->ReadTag();\n  }\n  ow->RenderInt32(field_name, bit_cast<int32>(buffer32));\n  return Status::OK;\n}\n\nStatus ProtoStreamObjectSource::RenderUInt32(const ProtoStreamObjectSource* os,\n                                             const google::protobuf::Type& type,\n                                             StringPiece field_name,\n                                             ObjectWriter* ow) {\n  uint32 tag = os->stream_->ReadTag();\n  uint32 buffer32 = 0;  // default value of UInt32 wrapper value\n  if (tag != 0) {\n    os->stream_->ReadVarint32(&buffer32);\n    os->stream_->ReadTag();\n  }\n  ow->RenderUint32(field_name, bit_cast<uint32>(buffer32));\n  return Status::OK;\n}\n\nStatus ProtoStreamObjectSource::RenderBool(const ProtoStreamObjectSource* os,\n                                           const google::protobuf::Type& type,\n                                           StringPiece field_name,\n                                           ObjectWriter* ow) {\n  uint32 tag = os->stream_->ReadTag();\n  uint64 buffer64 = 0;  // results in 'false' value as default, which is the\n                        // default value of Bool wrapper\n  if (tag != 0) {\n    os->stream_->ReadVarint64(&buffer64);\n    os->stream_->ReadTag();\n  }\n  ow->RenderBool(field_name, buffer64 != 0);\n  return Status::OK;\n}\n\nStatus ProtoStreamObjectSource::RenderString(const ProtoStreamObjectSource* os,\n                                             const google::protobuf::Type& type,\n                                             StringPiece field_name,\n                                             ObjectWriter* ow) {\n  uint32 tag = os->stream_->ReadTag();\n  uint32 buffer32;\n  string str;  // default value of empty for String wrapper\n  if (tag != 0) {\n    os->stream_->ReadVarint32(&buffer32);  // string size.\n    os->stream_->ReadString(&str, buffer32);\n    os->stream_->ReadTag();\n  }\n  ow->RenderString(field_name, str);\n  return Status::OK;\n}\n\nStatus ProtoStreamObjectSource::RenderBytes(const ProtoStreamObjectSource* os,\n                                            const google::protobuf::Type& type,\n                                            StringPiece field_name,\n                                            ObjectWriter* ow) {\n  uint32 tag = os->stream_->ReadTag();\n  uint32 buffer32;\n  string str;\n  if (tag != 0) {\n    os->stream_->ReadVarint32(&buffer32);\n    os->stream_->ReadString(&str, buffer32);\n    os->stream_->ReadTag();\n  }\n  ow->RenderBytes(field_name, str);\n  return Status::OK;\n}\n\nStatus ProtoStreamObjectSource::RenderStruct(const ProtoStreamObjectSource* os,\n                                             const google::protobuf::Type& type,\n                                             StringPiece field_name,\n                                             ObjectWriter* ow) {\n  const google::protobuf::Field* field = NULL;\n  uint32 tag = os->stream_->ReadTag();\n  ow->StartObject(field_name);\n  while (tag != 0) {\n    field = os->FindAndVerifyField(type, tag);\n    // google.protobuf.Struct has only one field that is a map. Hence we use\n    // RenderMap to render that field.\n    if (os->IsMap(*field)) {\n      ASSIGN_OR_RETURN(tag, os->RenderMap(field, field_name, tag, ow));\n    }\n  }\n  ow->EndObject();\n  return Status::OK;\n}\n\nStatus ProtoStreamObjectSource::RenderStructValue(\n    const ProtoStreamObjectSource* os, const google::protobuf::Type& type,\n    StringPiece field_name, ObjectWriter* ow) {\n  const google::protobuf::Field* field = NULL;\n  for (uint32 tag = os->stream_->ReadTag(); tag != 0;\n       tag = os->stream_->ReadTag()) {\n    field = os->FindAndVerifyField(type, tag);\n    if (field == NULL) {\n      WireFormat::SkipField(os->stream_, tag, NULL);\n      continue;\n    }\n    RETURN_IF_ERROR(os->RenderField(field, field_name, ow));\n  }\n  return Status::OK;\n}\n\n// TODO(skarvaje): Avoid code duplication of for loops and SkipField logic.\nStatus ProtoStreamObjectSource::RenderStructListValue(\n    const ProtoStreamObjectSource* os, const google::protobuf::Type& type,\n    StringPiece field_name, ObjectWriter* ow) {\n  uint32 tag = os->stream_->ReadTag();\n\n  // Render empty list when we find empty ListValue message.\n  if (tag == 0) {\n    ow->StartList(field_name);\n    ow->EndList();\n    return Status::OK;\n  }\n\n  while (tag != 0) {\n    const google::protobuf::Field* field = os->FindAndVerifyField(type, tag);\n    if (field == NULL) {\n      WireFormat::SkipField(os->stream_, tag, NULL);\n      tag = os->stream_->ReadTag();\n      continue;\n    }\n    ASSIGN_OR_RETURN(tag, os->RenderList(field, field_name, tag, ow));\n  }\n  return Status::OK;\n}\n\nStatus ProtoStreamObjectSource::RenderAny(const ProtoStreamObjectSource* os,\n                                          const google::protobuf::Type& type,\n                                          StringPiece field_name,\n                                          ObjectWriter* ow) {\n  // An Any is of the form { string type_url = 1; bytes value = 2; }\n  uint32 tag;\n  string type_url;\n  string value;\n\n  // First read out the type_url and value from the proto stream\n  for (tag = os->stream_->ReadTag(); tag != 0; tag = os->stream_->ReadTag()) {\n    const google::protobuf::Field* field = os->FindAndVerifyField(type, tag);\n    if (field == NULL) {\n      WireFormat::SkipField(os->stream_, tag, NULL);\n      continue;\n    }\n    // 'type_url' has field number of 1 and 'value' has field number 2\n    // //google/protobuf/any.proto\n    if (field->number() == 1) {\n      // read type_url\n      uint32 type_url_size;\n      os->stream_->ReadVarint32(&type_url_size);\n      os->stream_->ReadString(&type_url, type_url_size);\n    } else if (field->number() == 2) {\n      // read value\n      uint32 value_size;\n      os->stream_->ReadVarint32(&value_size);\n      os->stream_->ReadString(&value, value_size);\n    }\n  }\n\n  // If there is no value, we don't lookup the type, we just output it (if\n  // present). If both type and value are empty we output an empty object.\n  if (value.empty()) {\n    ow->StartObject(field_name);\n    if (!type_url.empty()) {\n      ow->RenderString(\"@type\", type_url);\n    }\n    ow->EndObject();\n    return util::Status::OK;\n  }\n\n  // If there is a value but no type, we cannot render it, so report an error.\n  if (type_url.empty()) {\n    // TODO(sven): Add an external message once those are ready.\n    return util::Status(util::error::INTERNAL,\n                        \"Invalid Any, the type_url is missing.\");\n  }\n\n  util::StatusOr<const google::protobuf::Type*> resolved_type =\n      os->typeinfo_->ResolveTypeUrl(type_url);\n\n  if (!resolved_type.ok()) {\n    // Convert into an internal error, since this means the backend gave us\n    // an invalid response (missing or invalid type information).\n    return util::Status(util::error::INTERNAL,\n                        resolved_type.status().error_message());\n  }\n  // nested_type cannot be null at this time.\n  const google::protobuf::Type* nested_type = resolved_type.ValueOrDie();\n\n  google::protobuf::io::ArrayInputStream zero_copy_stream(value.data(), value.size());\n  google::protobuf::io::CodedInputStream in_stream(&zero_copy_stream);\n  // We know the type so we can render it. Recursively parse the nested stream\n  // using a nested ProtoStreamObjectSource using our nested type information.\n  ProtoStreamObjectSource nested_os(&in_stream, os->typeinfo_, *nested_type);\n\n  // We manually call start and end object here so we can inject the @type.\n  ow->StartObject(field_name);\n  ow->RenderString(\"@type\", type_url);\n  util::Status result =\n      nested_os.WriteMessage(nested_os.type_, \"value\", 0, false, ow);\n  ow->EndObject();\n  return result;\n}\n\nStatus ProtoStreamObjectSource::RenderFieldMask(\n    const ProtoStreamObjectSource* os, const google::protobuf::Type& type,\n    StringPiece field_name, ObjectWriter* ow) {\n  string combined;\n  uint32 buffer32;\n  uint32 paths_field_tag = 0;\n  for (uint32 tag = os->stream_->ReadTag(); tag != 0;\n       tag = os->stream_->ReadTag()) {\n    if (paths_field_tag == 0) {\n      const google::protobuf::Field* field = os->FindAndVerifyField(type, tag);\n      if (field != NULL && field->number() == 1 &&\n          field->name() == \"paths\") {\n        paths_field_tag = tag;\n      }\n    }\n    if (paths_field_tag != tag) {\n      return util::Status(util::error::INTERNAL,\n                          \"Invalid FieldMask, unexpected field.\");\n    }\n    string str;\n    os->stream_->ReadVarint32(&buffer32);  // string size.\n    os->stream_->ReadString(&str, buffer32);\n    if (!combined.empty()) {\n      combined.append(\",\");\n    }\n    combined.append(ConvertFieldMaskPath(str, &ToCamelCase));\n  }\n  ow->RenderString(field_name, combined);\n  return Status::OK;\n}\n\n\nhash_map<string, ProtoStreamObjectSource::TypeRenderer>*\n    ProtoStreamObjectSource::renderers_ = NULL;\nGOOGLE_PROTOBUF_DECLARE_ONCE(source_renderers_init_);\n\nvoid ProtoStreamObjectSource::InitRendererMap() {\n  renderers_ = new hash_map<string, ProtoStreamObjectSource::TypeRenderer>();\n  (*renderers_)[\"google.protobuf.Timestamp\"] =\n      &ProtoStreamObjectSource::RenderTimestamp;\n  (*renderers_)[\"google.protobuf.Duration\"] =\n      &ProtoStreamObjectSource::RenderDuration;\n  (*renderers_)[\"google.protobuf.DoubleValue\"] =\n      &ProtoStreamObjectSource::RenderDouble;\n  (*renderers_)[\"google.protobuf.FloatValue\"] =\n      &ProtoStreamObjectSource::RenderFloat;\n  (*renderers_)[\"google.protobuf.Int64Value\"] =\n      &ProtoStreamObjectSource::RenderInt64;\n  (*renderers_)[\"google.protobuf.UInt64Value\"] =\n      &ProtoStreamObjectSource::RenderUInt64;\n  (*renderers_)[\"google.protobuf.Int32Value\"] =\n      &ProtoStreamObjectSource::RenderInt32;\n  (*renderers_)[\"google.protobuf.UInt32Value\"] =\n      &ProtoStreamObjectSource::RenderUInt32;\n  (*renderers_)[\"google.protobuf.BoolValue\"] =\n      &ProtoStreamObjectSource::RenderBool;\n  (*renderers_)[\"google.protobuf.StringValue\"] =\n      &ProtoStreamObjectSource::RenderString;\n  (*renderers_)[\"google.protobuf.BytesValue\"] =\n      &ProtoStreamObjectSource::RenderBytes;\n  (*renderers_)[\"google.protobuf.Any\"] = &ProtoStreamObjectSource::RenderAny;\n  (*renderers_)[\"google.protobuf.Struct\"] =\n      &ProtoStreamObjectSource::RenderStruct;\n  (*renderers_)[\"google.protobuf.Value\"] =\n      &ProtoStreamObjectSource::RenderStructValue;\n  (*renderers_)[\"google.protobuf.ListValue\"] =\n      &ProtoStreamObjectSource::RenderStructListValue;\n  (*renderers_)[\"google.protobuf.FieldMask\"] =\n      &ProtoStreamObjectSource::RenderFieldMask;\n  ::google::protobuf::internal::OnShutdown(&DeleteRendererMap);\n}\n\nvoid ProtoStreamObjectSource::DeleteRendererMap() {\n  delete ProtoStreamObjectSource::renderers_;\n  renderers_ = NULL;\n}\n\n// static\nProtoStreamObjectSource::TypeRenderer*\nProtoStreamObjectSource::FindTypeRenderer(const string& type_url) {\n  ::google::protobuf::GoogleOnceInit(&source_renderers_init_, &InitRendererMap);\n  return FindOrNull(*renderers_, type_url);\n}\n\nStatus ProtoStreamObjectSource::RenderField(\n    const google::protobuf::Field* field, StringPiece field_name,\n    ObjectWriter* ow) const {\n  // Short-circuit message types as it tends to call WriteMessage recursively\n  // and ends up using a lot of stack space. Keep the stack usage of this\n  // message small in order to preserve stack space and not crash.\n  if (field->kind() == google::protobuf::Field_Kind_TYPE_MESSAGE) {\n    uint32 buffer32;\n    stream_->ReadVarint32(&buffer32);  // message length\n    int old_limit = stream_->PushLimit(buffer32);\n    // Get the nested message type for this field.\n    const google::protobuf::Type* type =\n        typeinfo_->GetTypeByTypeUrl(field->type_url());\n    if (type == NULL) {\n      return Status(util::error::INTERNAL,\n                    StrCat(\"Invalid configuration. Could not find the type: \",\n                           field->type_url()));\n    }\n\n    // Short-circuit any special type rendering to save call-stack space.\n    const TypeRenderer* type_renderer = FindTypeRenderer(type->name());\n\n    bool use_type_renderer = type_renderer != NULL;\n\n    if (use_type_renderer) {\n      RETURN_IF_ERROR((*type_renderer)(this, *type, field_name, ow));\n    } else {\n      RETURN_IF_ERROR(IncrementRecursionDepth(type->name(), field_name));\n      RETURN_IF_ERROR(WriteMessage(*type, field_name, 0, true, ow));\n      --recursion_depth_;\n    }\n    if (!stream_->ConsumedEntireMessage()) {\n      return Status(util::error::INVALID_ARGUMENT,\n                    \"Nested protocol message not parsed in its entirety.\");\n    }\n    stream_->PopLimit(old_limit);\n  } else {\n    // Render all other non-message types.\n    return RenderNonMessageField(field, field_name, ow);\n  }\n  return Status::OK;\n}\n\nStatus ProtoStreamObjectSource::RenderNonMessageField(\n    const google::protobuf::Field* field, StringPiece field_name,\n    ObjectWriter* ow) const {\n  // Temporary buffers of different types.\n  uint32 buffer32;\n  uint64 buffer64;\n  string strbuffer;\n  switch (field->kind()) {\n    case google::protobuf::Field_Kind_TYPE_BOOL: {\n      stream_->ReadVarint64(&buffer64);\n      ow->RenderBool(field_name, buffer64 != 0);\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_INT32: {\n      stream_->ReadVarint32(&buffer32);\n      ow->RenderInt32(field_name, bit_cast<int32>(buffer32));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_INT64: {\n      stream_->ReadVarint64(&buffer64);\n      ow->RenderInt64(field_name, bit_cast<int64>(buffer64));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_UINT32: {\n      stream_->ReadVarint32(&buffer32);\n      ow->RenderUint32(field_name, bit_cast<uint32>(buffer32));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_UINT64: {\n      stream_->ReadVarint64(&buffer64);\n      ow->RenderUint64(field_name, bit_cast<uint64>(buffer64));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_SINT32: {\n      stream_->ReadVarint32(&buffer32);\n      ow->RenderInt32(field_name, WireFormatLite::ZigZagDecode32(buffer32));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_SINT64: {\n      stream_->ReadVarint64(&buffer64);\n      ow->RenderInt64(field_name, WireFormatLite::ZigZagDecode64(buffer64));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_SFIXED32: {\n      stream_->ReadLittleEndian32(&buffer32);\n      ow->RenderInt32(field_name, bit_cast<int32>(buffer32));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_SFIXED64: {\n      stream_->ReadLittleEndian64(&buffer64);\n      ow->RenderInt64(field_name, bit_cast<int64>(buffer64));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_FIXED32: {\n      stream_->ReadLittleEndian32(&buffer32);\n      ow->RenderUint32(field_name, bit_cast<uint32>(buffer32));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_FIXED64: {\n      stream_->ReadLittleEndian64(&buffer64);\n      ow->RenderUint64(field_name, bit_cast<uint64>(buffer64));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_FLOAT: {\n      stream_->ReadLittleEndian32(&buffer32);\n      ow->RenderFloat(field_name, bit_cast<float>(buffer32));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_DOUBLE: {\n      stream_->ReadLittleEndian64(&buffer64);\n      ow->RenderDouble(field_name, bit_cast<double>(buffer64));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_ENUM: {\n      stream_->ReadVarint32(&buffer32);\n\n      // If the field represents an explicit NULL value, render null.\n      if (field->type_url() == kStructNullValueTypeUrl) {\n        ow->RenderNull(field_name);\n        break;\n      }\n\n      // Get the nested enum type for this field.\n      // TODO(skarvaje): Avoid string manipulation. Find ways to speed this\n      // up.\n      const google::protobuf::Enum* en =\n          typeinfo_->GetEnumByTypeUrl(field->type_url());\n      // Lookup the name of the enum, and render that. Skips unknown enums.\n      if (en != NULL) {\n        const google::protobuf::EnumValue* enum_value =\n            FindEnumValueByNumber(*en, buffer32);\n        if (enum_value != NULL) {\n          if (use_lower_camel_for_enums_)\n            ow->RenderString(field_name, ToCamelCase(enum_value->name()));\n          else\n            ow->RenderString(field_name, enum_value->name());\n        }\n      } else {\n        GOOGLE_LOG(INFO) << \"Unknown enum skipped: \" << field->type_url();\n      }\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_STRING: {\n      stream_->ReadVarint32(&buffer32);  // string size.\n      stream_->ReadString(&strbuffer, buffer32);\n      ow->RenderString(field_name, strbuffer);\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_BYTES: {\n      stream_->ReadVarint32(&buffer32);  // bytes size.\n      stream_->ReadString(&strbuffer, buffer32);\n      ow->RenderBytes(field_name, strbuffer);\n      break;\n    }\n    default:\n      break;\n  }\n  return Status::OK;\n}\n\n// TODO(skarvaje): Fix this to avoid code duplication.\nconst string ProtoStreamObjectSource::ReadFieldValueAsString(\n    const google::protobuf::Field& field) const {\n  string result;\n  switch (field.kind()) {\n    case google::protobuf::Field_Kind_TYPE_BOOL: {\n      uint64 buffer64;\n      stream_->ReadVarint64(&buffer64);\n      result = buffer64 != 0 ? \"true\" : \"false\";\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_INT32: {\n      uint32 buffer32;\n      stream_->ReadVarint32(&buffer32);\n      result = SimpleItoa(bit_cast<int32>(buffer32));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_INT64: {\n      uint64 buffer64;\n      stream_->ReadVarint64(&buffer64);\n      result = SimpleItoa(bit_cast<int64>(buffer64));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_UINT32: {\n      uint32 buffer32;\n      stream_->ReadVarint32(&buffer32);\n      result = SimpleItoa(bit_cast<uint32>(buffer32));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_UINT64: {\n      uint64 buffer64;\n      stream_->ReadVarint64(&buffer64);\n      result = SimpleItoa(bit_cast<uint64>(buffer64));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_SINT32: {\n      uint32 buffer32;\n      stream_->ReadVarint32(&buffer32);\n      result = SimpleItoa(WireFormatLite::ZigZagDecode32(buffer32));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_SINT64: {\n      uint64 buffer64;\n      stream_->ReadVarint64(&buffer64);\n      result = SimpleItoa(WireFormatLite::ZigZagDecode64(buffer64));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_SFIXED32: {\n      uint32 buffer32;\n      stream_->ReadLittleEndian32(&buffer32);\n      result = SimpleItoa(bit_cast<int32>(buffer32));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_SFIXED64: {\n      uint64 buffer64;\n      stream_->ReadLittleEndian64(&buffer64);\n      result = SimpleItoa(bit_cast<int64>(buffer64));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_FIXED32: {\n      uint32 buffer32;\n      stream_->ReadLittleEndian32(&buffer32);\n      result = SimpleItoa(bit_cast<uint32>(buffer32));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_FIXED64: {\n      uint64 buffer64;\n      stream_->ReadLittleEndian64(&buffer64);\n      result = SimpleItoa(bit_cast<uint64>(buffer64));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_FLOAT: {\n      uint32 buffer32;\n      stream_->ReadLittleEndian32(&buffer32);\n      result = SimpleFtoa(bit_cast<float>(buffer32));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_DOUBLE: {\n      uint64 buffer64;\n      stream_->ReadLittleEndian64(&buffer64);\n      result = SimpleDtoa(bit_cast<double>(buffer64));\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_ENUM: {\n      uint32 buffer32;\n      stream_->ReadVarint32(&buffer32);\n      // Get the nested enum type for this field.\n      // TODO(skarvaje): Avoid string manipulation. Find ways to speed this\n      // up.\n      const google::protobuf::Enum* en =\n          typeinfo_->GetEnumByTypeUrl(field.type_url());\n      // Lookup the name of the enum, and render that. Skips unknown enums.\n      if (en != NULL) {\n        const google::protobuf::EnumValue* enum_value =\n            FindEnumValueByNumber(*en, buffer32);\n        if (enum_value != NULL) {\n          result = enum_value->name();\n        }\n      }\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_STRING: {\n      uint32 buffer32;\n      stream_->ReadVarint32(&buffer32);  // string size.\n      stream_->ReadString(&result, buffer32);\n      break;\n    }\n    case google::protobuf::Field_Kind_TYPE_BYTES: {\n      uint32 buffer32;\n      stream_->ReadVarint32(&buffer32);  // bytes size.\n      stream_->ReadString(&result, buffer32);\n      break;\n    }\n    default:\n      break;\n  }\n  return result;\n}\n\n// Field is a map if it is a repeated message and it has an option \"map_type\".\n// TODO(skarvaje): Consider pre-computing the IsMap() into Field directly.\nbool ProtoStreamObjectSource::IsMap(\n    const google::protobuf::Field& field) const {\n  const google::protobuf::Type* field_type =\n      typeinfo_->GetTypeByTypeUrl(field.type_url());\n\n  // TODO(xiaofeng): Unify option names.\n  return field.kind() == google::protobuf::Field_Kind_TYPE_MESSAGE &&\n         (GetBoolOptionOrDefault(field_type->options(),\n                                 \"google.protobuf.MessageOptions.map_entry\", false) ||\n          GetBoolOptionOrDefault(field_type->options(), \"map_entry\", false));\n}\n\nstd::pair<int64, int32> ProtoStreamObjectSource::ReadSecondsAndNanos(\n    const google::protobuf::Type& type) const {\n  uint64 seconds = 0;\n  uint32 nanos = 0;\n  uint32 tag = 0;\n  int64 signed_seconds = 0;\n  int32 signed_nanos = 0;\n\n  for (tag = stream_->ReadTag(); tag != 0; tag = stream_->ReadTag()) {\n    const google::protobuf::Field* field = FindAndVerifyField(type, tag);\n    if (field == NULL) {\n      WireFormat::SkipField(stream_, tag, NULL);\n      continue;\n    }\n    // 'seconds' has field number of 1 and 'nanos' has field number 2\n    // //google/protobuf/timestamp.proto & duration.proto\n    if (field->number() == 1) {\n      // read seconds\n      stream_->ReadVarint64(&seconds);\n      signed_seconds = bit_cast<int64>(seconds);\n    } else if (field->number() == 2) {\n      // read nanos\n      stream_->ReadVarint32(&nanos);\n      signed_nanos = bit_cast<int32>(nanos);\n    }\n  }\n  return std::pair<int64, int32>(signed_seconds, signed_nanos);\n}\n\nStatus ProtoStreamObjectSource::IncrementRecursionDepth(\n    StringPiece type_name, StringPiece field_name) const {\n  if (++recursion_depth_ > max_recursion_depth_) {\n    return Status(\n        util::error::INVALID_ARGUMENT,\n        StrCat(\"Message too deep. Max recursion depth reached for type '\",\n               type_name, \"', field '\", field_name, \"'\"));\n  }\n  return Status::OK;\n}\n\nnamespace {\n// TODO(skarvaje): Speed this up by not doing a linear scan.\nconst google::protobuf::Field* FindFieldByNumber(\n    const google::protobuf::Type& type, int number) {\n  for (int i = 0; i < type.fields_size(); ++i) {\n    if (type.fields(i).number() == number) {\n      return &type.fields(i);\n    }\n  }\n  return NULL;\n}\n\n// TODO(skarvaje): Replace FieldDescriptor by implementing IsTypePackable()\n// using tech Field.\nbool IsPackable(const google::protobuf::Field& field) {\n  return field.cardinality() ==\n             google::protobuf::Field_Cardinality_CARDINALITY_REPEATED &&\n         google::protobuf::FieldDescriptor::IsTypePackable(\n             static_cast<google::protobuf::FieldDescriptor::Type>(field.kind()));\n}\n\n// TODO(skarvaje): Speed this up by not doing a linear scan.\nconst google::protobuf::EnumValue* FindEnumValueByNumber(\n    const google::protobuf::Enum& tech_enum, int number) {\n  for (int i = 0; i < tech_enum.enumvalue_size(); ++i) {\n    const google::protobuf::EnumValue& ev = tech_enum.enumvalue(i);\n    if (ev.number() == number) {\n      return &ev;\n    }\n  }\n  return NULL;\n}\n\n// TODO(skarvaje): Look into optimizing this by not doing computation on\n// double.\nconst string FormatNanos(uint32 nanos) {\n  const char* format =\n      (nanos % 1000 != 0) ? \"%.9f\" : (nanos % 1000000 != 0) ? \"%.6f\" : \"%.3f\";\n  string formatted =\n      StringPrintf(format, static_cast<double>(nanos) / kNanosPerSecond);\n  // remove the leading 0 before decimal.\n  return formatted.substr(1);\n}\n}  // namespace\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/protostream_objectsource.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTSOURCE_H__\n#define GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTSOURCE_H__\n\n#include <functional>\n#include <google/protobuf/stubs/hash.h>\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/type.pb.h>\n#include <google/protobuf/util/internal/object_source.h>\n#include <google/protobuf/util/internal/object_writer.h>\n#include <google/protobuf/util/internal/type_info.h>\n#include <google/protobuf/util/type_resolver.h>\n#include <google/protobuf/stubs/stringpiece.h>\n#include <google/protobuf/stubs/status.h>\n#include <google/protobuf/stubs/statusor.h>\n\n\nnamespace google {\nnamespace protobuf {\nclass Field;\nclass Type;\n}  // namespace protobuf\n\n\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\nclass TypeInfo;\n\n// An ObjectSource that can parse a stream of bytes as a protocol buffer.\n// Its WriteTo() method can be given an ObjectWriter.\n// This implementation uses a google.protobuf.Type for tag and name lookup.\n// The field names are converted into lower camel-case when writing to the\n// ObjectWriter.\n//\n// Sample usage: (suppose input is: string proto)\n//   ArrayInputStream arr_stream(proto.data(), proto.size());\n//   CodedInputStream in_stream(&arr_stream);\n//   ProtoStreamObjectSource os(&in_stream, /*ServiceTypeInfo*/ typeinfo,\n//                              <your message google::protobuf::Type>);\n//\n//   Status status = os.WriteTo(<some ObjectWriter>);\nclass LIBPROTOBUF_EXPORT ProtoStreamObjectSource : public ObjectSource {\n public:\n  ProtoStreamObjectSource(google::protobuf::io::CodedInputStream* stream,\n                          TypeResolver* type_resolver,\n                          const google::protobuf::Type& type);\n\n  virtual ~ProtoStreamObjectSource();\n\n  virtual util::Status NamedWriteTo(StringPiece name, ObjectWriter* ow) const;\n\n  // Sets whether or not to use lowerCamelCase casing for enum values. If set to\n  // false, enum values are output without any case conversions.\n  //\n  // For example, if we have an enum:\n  // enum Type {\n  //   ACTION_AND_ADVENTURE = 1;\n  // }\n  // Type type = 20;\n  //\n  // And this option is set to true. Then the rendered \"type\" field will have\n  // the string \"actionAndAdventure\".\n  // {\n  //   ...\n  //   \"type\": \"actionAndAdventure\",\n  //   ...\n  // }\n  //\n  // If set to false, the rendered \"type\" field will have the string\n  // \"ACTION_AND_ADVENTURE\".\n  // {\n  //   ...\n  //   \"type\": \"ACTION_AND_ADVENTURE\",\n  //   ...\n  // }\n  void set_use_lower_camel_for_enums(bool value) {\n    use_lower_camel_for_enums_ = value;\n  }\n\n  // Sets the max recursion depth of proto message to be deserialized. Proto\n  // messages over this depth will fail to be deserialized.\n  // Default value is 64.\n  void set_max_recursion_depth(int max_depth) {\n    max_recursion_depth_ = max_depth;\n  }\n\n\n protected:\n  // Writes a proto2 Message to the ObjectWriter. When the given end_tag is\n  // found this method will complete, allowing it to be used for parsing both\n  // nested messages (end with 0) and nested groups (end with group end tag).\n  // The include_start_and_end parameter allows this method to be called when\n  // already inside of an object, and skip calling StartObject and EndObject.\n  virtual util::Status WriteMessage(const google::protobuf::Type& descriptor,\n                                      StringPiece name, const uint32 end_tag,\n                                      bool include_start_and_end,\n                                      ObjectWriter* ow) const;\n\n private:\n  ProtoStreamObjectSource(google::protobuf::io::CodedInputStream* stream,\n                          const TypeInfo* typeinfo,\n                          const google::protobuf::Type& type);\n  // Function that renders a well known type with a modified behavior.\n  typedef util::Status (*TypeRenderer)(const ProtoStreamObjectSource*,\n                                         const google::protobuf::Type&,\n                                         StringPiece, ObjectWriter*);\n\n  // Looks up a field and verify its consistency with wire type in tag.\n  const google::protobuf::Field* FindAndVerifyField(\n      const google::protobuf::Type& type, uint32 tag) const;\n\n  // TODO(skarvaje): Mark these methods as non-const as they modify internal\n  // state (stream_).\n  //\n  // Renders a repeating field (packed or unpacked).\n  // Returns the next tag after reading all sequential repeating elements. The\n  // caller should use this tag before reading more tags from the stream.\n  util::StatusOr<uint32> RenderList(const google::protobuf::Field* field,\n                                      StringPiece name, uint32 list_tag,\n                                      ObjectWriter* ow) const;\n  // Renders a NWP map.\n  // Returns the next tag after reading all map entries. The caller should use\n  // this tag before reading more tags from the stream.\n  util::StatusOr<uint32> RenderMap(const google::protobuf::Field* field,\n                                     StringPiece name, uint32 list_tag,\n                                     ObjectWriter* ow) const;\n\n  // Renders a packed repeating field. A packed field is stored as:\n  // {tag length item1 item2 item3} instead of the less efficient\n  // {tag item1 tag item2 tag item3}.\n  util::Status RenderPacked(const google::protobuf::Field* field,\n                              ObjectWriter* ow) const;\n\n  // Renders a google.protobuf.Timestamp value to ObjectWriter\n  static util::Status RenderTimestamp(const ProtoStreamObjectSource* os,\n                                        const google::protobuf::Type& type,\n                                        StringPiece name, ObjectWriter* ow);\n\n  // Renders a google.protobuf.Duration value to ObjectWriter\n  static util::Status RenderDuration(const ProtoStreamObjectSource* os,\n                                       const google::protobuf::Type& type,\n                                       StringPiece name, ObjectWriter* ow);\n\n  // Following RenderTYPE functions render well known types in\n  // google/protobuf/wrappers.proto corresponding to TYPE.\n  static util::Status RenderDouble(const ProtoStreamObjectSource* os,\n                                     const google::protobuf::Type& type,\n                                     StringPiece name, ObjectWriter* ow);\n  static util::Status RenderFloat(const ProtoStreamObjectSource* os,\n                                    const google::protobuf::Type& type,\n                                    StringPiece name, ObjectWriter* ow);\n  static util::Status RenderInt64(const ProtoStreamObjectSource* os,\n                                    const google::protobuf::Type& type,\n                                    StringPiece name, ObjectWriter* ow);\n  static util::Status RenderUInt64(const ProtoStreamObjectSource* os,\n                                     const google::protobuf::Type& type,\n                                     StringPiece name, ObjectWriter* ow);\n  static util::Status RenderInt32(const ProtoStreamObjectSource* os,\n                                    const google::protobuf::Type& type,\n                                    StringPiece name, ObjectWriter* ow);\n  static util::Status RenderUInt32(const ProtoStreamObjectSource* os,\n                                     const google::protobuf::Type& type,\n                                     StringPiece name, ObjectWriter* ow);\n  static util::Status RenderBool(const ProtoStreamObjectSource* os,\n                                   const google::protobuf::Type& type,\n                                   StringPiece name, ObjectWriter* ow);\n  static util::Status RenderString(const ProtoStreamObjectSource* os,\n                                     const google::protobuf::Type& type,\n                                     StringPiece name, ObjectWriter* ow);\n  static util::Status RenderBytes(const ProtoStreamObjectSource* os,\n                                    const google::protobuf::Type& type,\n                                    StringPiece name, ObjectWriter* ow);\n\n  // Renders a google.protobuf.Struct to ObjectWriter.\n  static util::Status RenderStruct(const ProtoStreamObjectSource* os,\n                                     const google::protobuf::Type& type,\n                                     StringPiece name, ObjectWriter* ow);\n\n  // Helper to render google.protobuf.Struct's Value fields to ObjectWriter.\n  static util::Status RenderStructValue(const ProtoStreamObjectSource* os,\n                                          const google::protobuf::Type& type,\n                                          StringPiece name, ObjectWriter* ow);\n\n  // Helper to render google.protobuf.Struct's ListValue fields to ObjectWriter.\n  static util::Status RenderStructListValue(\n      const ProtoStreamObjectSource* os, const google::protobuf::Type& type,\n      StringPiece name, ObjectWriter* ow);\n\n  // Render the \"Any\" type.\n  static util::Status RenderAny(const ProtoStreamObjectSource* os,\n                                  const google::protobuf::Type& type,\n                                  StringPiece name, ObjectWriter* ow);\n\n  // Render the \"FieldMask\" type.\n  static util::Status RenderFieldMask(const ProtoStreamObjectSource* os,\n                                        const google::protobuf::Type& type,\n                                        StringPiece name, ObjectWriter* ow);\n\n  static hash_map<string, TypeRenderer>* renderers_;\n  static void InitRendererMap();\n  static void DeleteRendererMap();\n  static TypeRenderer* FindTypeRenderer(const string& type_url);\n\n  // Renders a field value to the ObjectWriter.\n  util::Status RenderField(const google::protobuf::Field* field,\n                             StringPiece field_name, ObjectWriter* ow) const;\n\n  // Same as above but renders all non-message field types. Callers don't call\n  // this function directly. They just use RenderField.\n  util::Status RenderNonMessageField(const google::protobuf::Field* field,\n                                       StringPiece field_name,\n                                       ObjectWriter* ow) const;\n\n\n  // Reads field value according to Field spec in 'field' and returns the read\n  // value as string. This only works for primitive datatypes (no message\n  // types).\n  const string ReadFieldValueAsString(\n      const google::protobuf::Field& field) const;\n\n  // Utility function to detect proto maps. The 'field' MUST be repeated.\n  bool IsMap(const google::protobuf::Field& field) const;\n\n  // Utility to read int64 and int32 values from a message type in stream_.\n  // Used for reading google.protobuf.Timestamp and Duration messages.\n  std::pair<int64, int32> ReadSecondsAndNanos(\n      const google::protobuf::Type& type) const;\n\n  // Helper function to check recursion depth and increment it. It will return\n  // Status::OK if the current depth is allowed. Otherwise an error is returned.\n  // type_name and field_name are used for error reporting.\n  util::Status IncrementRecursionDepth(StringPiece type_name,\n                                         StringPiece field_name) const;\n\n  // Input stream to read from. Ownership rests with the caller.\n  google::protobuf::io::CodedInputStream* stream_;\n\n  // Type information for all the types used in the descriptor. Used to find\n  // google::protobuf::Type of nested messages/enums.\n  const TypeInfo* typeinfo_;\n  // Whether this class owns the typeinfo_ object. If true the typeinfo_ object\n  // should be deleted in the destructor.\n  bool own_typeinfo_;\n\n  // google::protobuf::Type of the message source.\n  const google::protobuf::Type& type_;\n\n\n  // Whether to render enums using lowerCamelCase. Defaults to false.\n  bool use_lower_camel_for_enums_;\n\n  // Tracks current recursion depth.\n  mutable int recursion_depth_;\n\n  // Maximum allowed recursion depth.\n  int max_recursion_depth_;\n\n  // Whether to render unknown fields.\n  bool render_unknown_fields_;\n\n  GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(ProtoStreamObjectSource);\n};\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTSOURCE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/protostream_objectsource_test.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/internal/protostream_objectsource.h>\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <sstream>\n\n#include <google/protobuf/stubs/casts.h>\n#include <google/protobuf/any.pb.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl_lite.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/util/internal/expecting_objectwriter.h>\n#include <google/protobuf/util/internal/testdata/books.pb.h>\n#include <google/protobuf/util/internal/testdata/field_mask.pb.h>\n#include <google/protobuf/util/internal/type_info_test_helper.h>\n#include <google/protobuf/util/internal/constants.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/util/internal/testdata/anys.pb.h>\n#include <google/protobuf/util/internal/testdata/maps.pb.h>\n#include <google/protobuf/util/internal/testdata/struct.pb.h>\n#include <google/protobuf/util/internal/testdata/timestamp_duration.pb.h>\n#include <gtest/gtest.h>\n\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\nusing google::protobuf::Descriptor;\nusing google::protobuf::DescriptorPool;\nusing google::protobuf::FileDescriptorProto;\nusing google::protobuf::Message;\nusing google::protobuf::io::ArrayInputStream;\nusing google::protobuf::io::CodedInputStream;\nusing util::Status;\nusing google::protobuf::testing::Author;\nusing google::protobuf::testing::BadAuthor;\nusing google::protobuf::testing::BadNestedBook;\nusing google::protobuf::testing::Book;\nusing google::protobuf::testing::Cyclic;\nusing google::protobuf::testing::Book_Label;\nusing google::protobuf::testing::NestedBook;\nusing google::protobuf::testing::PackedPrimitive;\nusing google::protobuf::testing::Primitive;\nusing google::protobuf::testing::more_author;\nusing google::protobuf::testing::maps::MapOut;\nusing google::protobuf::testing::maps::MapOutWireFormat;\nusing google::protobuf::testing::timestampduration::TimestampDuration;\nusing google::protobuf::testing::anys::AnyOut;\nusing google::protobuf::testing::anys::AnyM;\nusing google::protobuf::testing::FieldMaskTest;\nusing google::protobuf::testing::NestedFieldMask;\nusing google::protobuf::testing::structs::StructType;\nusing ::testing::_;\n\n\nnamespace {\nstring GetTypeUrl(const Descriptor* descriptor) {\n  return string(kTypeServiceBaseUrl) + \"/\" + descriptor->full_name();\n}\n}  // namespace\n\nclass ProtostreamObjectSourceTest\n    : public ::testing::TestWithParam<testing::TypeInfoSource> {\n protected:\n  ProtostreamObjectSourceTest()\n      : helper_(GetParam()),\n        mock_(),\n        ow_(&mock_),\n        use_lower_camel_for_enums_(false) {\n    helper_.ResetTypeInfo(Book::descriptor());\n  }\n\n  virtual ~ProtostreamObjectSourceTest() {}\n\n  void DoTest(const Message& msg, const Descriptor* descriptor) {\n    Status status = ExecuteTest(msg, descriptor);\n    EXPECT_EQ(Status::OK, status);\n  }\n\n  Status ExecuteTest(const Message& msg, const Descriptor* descriptor) {\n    ostringstream oss;\n    msg.SerializePartialToOstream(&oss);\n    string proto = oss.str();\n    ArrayInputStream arr_stream(proto.data(), proto.size());\n    CodedInputStream in_stream(&arr_stream);\n\n    google::protobuf::scoped_ptr<ProtoStreamObjectSource> os(\n        helper_.NewProtoSource(&in_stream, GetTypeUrl(descriptor)));\n    if (use_lower_camel_for_enums_) os->set_use_lower_camel_for_enums(true);\n    os->set_max_recursion_depth(64);\n    return os->WriteTo(&mock_);\n  }\n\n  void PrepareExpectingObjectWriterForRepeatedPrimitive() {\n    ow_.StartObject(\"\")\n        ->StartList(\"repFix32\")\n        ->RenderUint32(\"\", bit_cast<uint32>(3201))\n        ->RenderUint32(\"\", bit_cast<uint32>(0))\n        ->RenderUint32(\"\", bit_cast<uint32>(3202))\n        ->EndList()\n        ->StartList(\"repU32\")\n        ->RenderUint32(\"\", bit_cast<uint32>(3203))\n        ->RenderUint32(\"\", bit_cast<uint32>(0))\n        ->EndList()\n        ->StartList(\"repI32\")\n        ->RenderInt32(\"\", 0)\n        ->RenderInt32(\"\", 3204)\n        ->RenderInt32(\"\", 3205)\n        ->EndList()\n        ->StartList(\"repSf32\")\n        ->RenderInt32(\"\", 3206)\n        ->RenderInt32(\"\", 0)\n        ->EndList()\n        ->StartList(\"repS32\")\n        ->RenderInt32(\"\", 0)\n        ->RenderInt32(\"\", 3207)\n        ->RenderInt32(\"\", 3208)\n        ->EndList()\n        ->StartList(\"repFix64\")\n        ->RenderUint64(\"\", bit_cast<uint64>(6401LL))\n        ->RenderUint64(\"\", bit_cast<uint64>(0LL))\n        ->EndList()\n        ->StartList(\"repU64\")\n        ->RenderUint64(\"\", bit_cast<uint64>(0LL))\n        ->RenderUint64(\"\", bit_cast<uint64>(6402LL))\n        ->RenderUint64(\"\", bit_cast<uint64>(6403LL))\n        ->EndList()\n        ->StartList(\"repI64\")\n        ->RenderInt64(\"\", 6404L)\n        ->RenderInt64(\"\", 0L)\n        ->EndList()\n        ->StartList(\"repSf64\")\n        ->RenderInt64(\"\", 0L)\n        ->RenderInt64(\"\", 6405L)\n        ->RenderInt64(\"\", 6406L)\n        ->EndList()\n        ->StartList(\"repS64\")\n        ->RenderInt64(\"\", 6407L)\n        ->RenderInt64(\"\", 0L)\n        ->EndList()\n        ->StartList(\"repFloat\")\n        ->RenderFloat(\"\", 0.0f)\n        ->RenderFloat(\"\", 32.1f)\n        ->RenderFloat(\"\", 32.2f)\n        ->EndList()\n        ->StartList(\"repDouble\")\n        ->RenderDouble(\"\", 64.1L)\n        ->RenderDouble(\"\", 0.0L)\n        ->EndList()\n        ->StartList(\"repBool\")\n        ->RenderBool(\"\", true)\n        ->RenderBool(\"\", false)\n        ->EndList()\n        ->EndObject();\n  }\n\n  Primitive PrepareRepeatedPrimitive() {\n    Primitive primitive;\n    primitive.add_rep_fix32(3201);\n    primitive.add_rep_fix32(0);\n    primitive.add_rep_fix32(3202);\n    primitive.add_rep_u32(3203);\n    primitive.add_rep_u32(0);\n    primitive.add_rep_i32(0);\n    primitive.add_rep_i32(3204);\n    primitive.add_rep_i32(3205);\n    primitive.add_rep_sf32(3206);\n    primitive.add_rep_sf32(0);\n    primitive.add_rep_s32(0);\n    primitive.add_rep_s32(3207);\n    primitive.add_rep_s32(3208);\n    primitive.add_rep_fix64(6401L);\n    primitive.add_rep_fix64(0L);\n    primitive.add_rep_u64(0L);\n    primitive.add_rep_u64(6402L);\n    primitive.add_rep_u64(6403L);\n    primitive.add_rep_i64(6404L);\n    primitive.add_rep_i64(0L);\n    primitive.add_rep_sf64(0L);\n    primitive.add_rep_sf64(6405L);\n    primitive.add_rep_sf64(6406L);\n    primitive.add_rep_s64(6407L);\n    primitive.add_rep_s64(0L);\n    primitive.add_rep_float(0.0f);\n    primitive.add_rep_float(32.1f);\n    primitive.add_rep_float(32.2f);\n    primitive.add_rep_double(64.1L);\n    primitive.add_rep_double(0.0);\n    primitive.add_rep_bool(true);\n    primitive.add_rep_bool(false);\n\n    PrepareExpectingObjectWriterForRepeatedPrimitive();\n    return primitive;\n  }\n\n  PackedPrimitive PreparePackedPrimitive() {\n    PackedPrimitive primitive;\n    primitive.add_rep_fix32(3201);\n    primitive.add_rep_fix32(0);\n    primitive.add_rep_fix32(3202);\n    primitive.add_rep_u32(3203);\n    primitive.add_rep_u32(0);\n    primitive.add_rep_i32(0);\n    primitive.add_rep_i32(3204);\n    primitive.add_rep_i32(3205);\n    primitive.add_rep_sf32(3206);\n    primitive.add_rep_sf32(0);\n    primitive.add_rep_s32(0);\n    primitive.add_rep_s32(3207);\n    primitive.add_rep_s32(3208);\n    primitive.add_rep_fix64(6401L);\n    primitive.add_rep_fix64(0L);\n    primitive.add_rep_u64(0L);\n    primitive.add_rep_u64(6402L);\n    primitive.add_rep_u64(6403L);\n    primitive.add_rep_i64(6404L);\n    primitive.add_rep_i64(0L);\n    primitive.add_rep_sf64(0L);\n    primitive.add_rep_sf64(6405L);\n    primitive.add_rep_sf64(6406L);\n    primitive.add_rep_s64(6407L);\n    primitive.add_rep_s64(0L);\n    primitive.add_rep_float(0.0f);\n    primitive.add_rep_float(32.1f);\n    primitive.add_rep_float(32.2f);\n    primitive.add_rep_double(64.1L);\n    primitive.add_rep_double(0.0);\n    primitive.add_rep_bool(true);\n    primitive.add_rep_bool(false);\n\n    PrepareExpectingObjectWriterForRepeatedPrimitive();\n    return primitive;\n  }\n\n  void UseLowerCamelForEnums() { use_lower_camel_for_enums_ = true; }\n\n  testing::TypeInfoTestHelper helper_;\n\n  ::testing::NiceMock<MockObjectWriter> mock_;\n  ExpectingObjectWriter ow_;\n  bool use_lower_camel_for_enums_;\n};\n\nINSTANTIATE_TEST_CASE_P(DifferentTypeInfoSourceTest,\n                        ProtostreamObjectSourceTest,\n                        ::testing::Values(\n                            testing::USE_TYPE_RESOLVER));\n\nTEST_P(ProtostreamObjectSourceTest, EmptyMessage) {\n  Book empty;\n  ow_.StartObject(\"\")->EndObject();\n  DoTest(empty, Book::descriptor());\n}\n\nTEST_P(ProtostreamObjectSourceTest, Primitives) {\n  Primitive primitive;\n  primitive.set_fix32(3201);\n  primitive.set_u32(3202);\n  primitive.set_i32(3203);\n  primitive.set_sf32(3204);\n  primitive.set_s32(3205);\n  primitive.set_fix64(6401L);\n  primitive.set_u64(6402L);\n  primitive.set_i64(6403L);\n  primitive.set_sf64(6404L);\n  primitive.set_s64(6405L);\n  primitive.set_str(\"String Value\");\n  primitive.set_bytes(\"Some Bytes\");\n  primitive.set_float_(32.1f);\n  primitive.set_double_(64.1L);\n  primitive.set_bool_(true);\n\n  ow_.StartObject(\"\")\n      ->RenderUint32(\"fix32\", bit_cast<uint32>(3201))\n      ->RenderUint32(\"u32\", bit_cast<uint32>(3202))\n      ->RenderInt32(\"i32\", 3203)\n      ->RenderInt32(\"sf32\", 3204)\n      ->RenderInt32(\"s32\", 3205)\n      ->RenderUint64(\"fix64\", bit_cast<uint64>(6401LL))\n      ->RenderUint64(\"u64\", bit_cast<uint64>(6402LL))\n      ->RenderInt64(\"i64\", 6403L)\n      ->RenderInt64(\"sf64\", 6404L)\n      ->RenderInt64(\"s64\", 6405L)\n      ->RenderString(\"str\", \"String Value\")\n      ->RenderBytes(\"bytes\", \"Some Bytes\")\n      ->RenderFloat(\"float\", 32.1f)\n      ->RenderDouble(\"double\", 64.1L)\n      ->RenderBool(\"bool\", true)\n      ->EndObject();\n  DoTest(primitive, Primitive::descriptor());\n}\n\nTEST_P(ProtostreamObjectSourceTest, RepeatingPrimitives) {\n  Primitive primitive = PrepareRepeatedPrimitive();\n  primitive.add_rep_str(\"String One\");\n  primitive.add_rep_str(\"String Two\");\n  primitive.add_rep_bytes(\"Some Bytes\");\n\n  ow_.StartList(\"repStr\")\n      ->RenderString(\"\", \"String One\")\n      ->RenderString(\"\", \"String Two\")\n      ->EndList()\n      ->StartList(\"repBytes\")\n      ->RenderBytes(\"\", \"Some Bytes\")\n      ->EndList();\n  DoTest(primitive, Primitive::descriptor());\n}\n\nTEST_P(ProtostreamObjectSourceTest, CustomJsonName) {\n  Author author;\n  author.set_id(12345);\n\n  ow_.StartObject(\"\")->RenderUint64(\"@id\", 12345)->EndObject();\n  DoTest(author, Author::descriptor());\n}\n\nTEST_P(ProtostreamObjectSourceTest, NestedMessage) {\n  Author* author = new Author();\n  author->set_name(\"Tolstoy\");\n  Book book;\n  book.set_title(\"My Book\");\n  book.set_allocated_author(author);\n\n  ow_.StartObject(\"\")\n      ->RenderString(\"title\", \"My Book\")\n      ->StartObject(\"author\")\n      ->RenderString(\"name\", \"Tolstoy\")\n      ->EndObject()\n      ->EndObject();\n  DoTest(book, Book::descriptor());\n}\n\nTEST_P(ProtostreamObjectSourceTest, RepeatingField) {\n  Author author;\n  author.set_alive(false);\n  author.set_name(\"john\");\n  author.add_pseudonym(\"phil\");\n  author.add_pseudonym(\"bob\");\n\n  ow_.StartObject(\"\")\n      ->RenderBool(\"alive\", false)\n      ->RenderString(\"name\", \"john\")\n      ->StartList(\"pseudonym\")\n      ->RenderString(\"\", \"phil\")\n      ->RenderString(\"\", \"bob\")\n      ->EndList()\n      ->EndObject();\n  DoTest(author, Author::descriptor());\n}\n\nTEST_P(ProtostreamObjectSourceTest, PackedRepeatingFields) {\n  DoTest(PreparePackedPrimitive(), PackedPrimitive::descriptor());\n}\n\nTEST_P(ProtostreamObjectSourceTest, NonPackedPackableFieldsActuallyPacked) {\n  // Protostream is packed, but parse with non-packed Primitive.\n  DoTest(PreparePackedPrimitive(), Primitive::descriptor());\n}\n\nTEST_P(ProtostreamObjectSourceTest, PackedPackableFieldNotActuallyPacked) {\n  // Protostream is not packed, but parse with PackedPrimitive.\n  DoTest(PrepareRepeatedPrimitive(), PackedPrimitive::descriptor());\n}\n\nTEST_P(ProtostreamObjectSourceTest, BadAuthor) {\n  Author author;\n  author.set_alive(false);\n  author.set_name(\"john\");\n  author.set_id(1234L);\n  author.add_pseudonym(\"phil\");\n  author.add_pseudonym(\"bob\");\n\n  ow_.StartObject(\"\")\n      ->StartList(\"alive\")\n      ->RenderBool(\"\", false)\n      ->EndList()\n      ->StartList(\"name\")\n      ->RenderUint64(\"\", static_cast<uint64>('j'))\n      ->RenderUint64(\"\", static_cast<uint64>('o'))\n      ->RenderUint64(\"\", static_cast<uint64>('h'))\n      ->RenderUint64(\"\", static_cast<uint64>('n'))\n      ->EndList()\n      ->RenderString(\"pseudonym\", \"phil\")\n      ->RenderString(\"pseudonym\", \"bob\")\n      ->EndObject();\n  // Protostream created with Author, but parsed with BadAuthor.\n  DoTest(author, BadAuthor::descriptor());\n}\n\nTEST_P(ProtostreamObjectSourceTest, NestedBookToBadNestedBook) {\n  Book* book = new Book();\n  book->set_length(250);\n  book->set_published(2014L);\n  NestedBook nested;\n  nested.set_allocated_book(book);\n\n  ow_.StartObject(\"\")\n      ->StartList(\"book\")\n      ->RenderUint32(\"\", 24)  // tag for field length (3 << 3)\n      ->RenderUint32(\"\", 250)\n      ->RenderUint32(\"\", 32)  // tag for field published (4 << 3)\n      ->RenderUint32(\"\", 2014)\n      ->EndList()\n      ->EndObject();\n  // Protostream created with NestedBook, but parsed with BadNestedBook.\n  DoTest(nested, BadNestedBook::descriptor());\n}\n\nTEST_P(ProtostreamObjectSourceTest, BadNestedBookToNestedBook) {\n  BadNestedBook nested;\n  nested.add_book(1);\n  nested.add_book(2);\n  nested.add_book(3);\n  nested.add_book(4);\n  nested.add_book(5);\n  nested.add_book(6);\n  nested.add_book(7);\n\n  ow_.StartObject(\"\")->StartObject(\"book\")->EndObject()->EndObject();\n  // Protostream created with BadNestedBook, but parsed with NestedBook.\n  DoTest(nested, NestedBook::descriptor());\n}\n\nTEST_P(ProtostreamObjectSourceTest,\n       LongRepeatedListDoesNotBreakIntoMultipleJsonLists) {\n  Book book;\n\n  int repeat = 10000;\n  for (int i = 0; i < repeat; ++i) {\n    Book_Label* label = book.add_labels();\n    label->set_key(StrCat(\"i\", i));\n    label->set_value(StrCat(\"v\", i));\n  }\n\n  // Make sure StartList and EndList are called exactly once (see b/18227499 for\n  // problems when this doesn't happen)\n  EXPECT_CALL(mock_, StartList(_)).Times(1);\n  EXPECT_CALL(mock_, EndList()).Times(1);\n\n  DoTest(book, Book::descriptor());\n}\n\nTEST_P(ProtostreamObjectSourceTest, LowerCamelEnumOutputTest) {\n  Book book;\n  book.set_type(Book::ACTION_AND_ADVENTURE);\n\n  UseLowerCamelForEnums();\n\n  ow_.StartObject(\"\")->RenderString(\"type\", \"actionAndAdventure\")->EndObject();\n  DoTest(book, Book::descriptor());\n}\n\nTEST_P(ProtostreamObjectSourceTest, EnumCaseIsUnchangedByDefault) {\n  Book book;\n  book.set_type(Book::ACTION_AND_ADVENTURE);\n  ow_.StartObject(\"\")\n      ->RenderString(\"type\", \"ACTION_AND_ADVENTURE\")\n      ->EndObject();\n  DoTest(book, Book::descriptor());\n}\n\nTEST_P(ProtostreamObjectSourceTest, CyclicMessageDepthTest) {\n  Cyclic cyclic;\n  cyclic.set_m_int(123);\n\n  Book* book = cyclic.mutable_m_book();\n  book->set_title(\"book title\");\n  Cyclic* current = cyclic.mutable_m_cyclic();\n  Author* current_author = cyclic.add_m_author();\n  for (int i = 0; i < 63; ++i) {\n    Author* next = current_author->add_friend_();\n    next->set_id(i);\n    next->set_name(StrCat(\"author_name_\", i));\n    next->set_alive(true);\n    current_author = next;\n  }\n\n  // Recursive message with depth (65) > max (max is 64).\n  for (int i = 0; i < 64; ++i) {\n    Cyclic* next = current->mutable_m_cyclic();\n    next->set_m_str(StrCat(\"count_\", i));\n    current = next;\n  }\n\n  Status status = ExecuteTest(cyclic, Cyclic::descriptor());\n  EXPECT_EQ(util::error::INVALID_ARGUMENT, status.error_code());\n}\n\nclass ProtostreamObjectSourceMapsTest : public ProtostreamObjectSourceTest {\n protected:\n  ProtostreamObjectSourceMapsTest() {\n    helper_.ResetTypeInfo(MapOut::descriptor());\n  }\n};\n\nINSTANTIATE_TEST_CASE_P(DifferentTypeInfoSourceTest,\n                        ProtostreamObjectSourceMapsTest,\n                        ::testing::Values(\n                            testing::USE_TYPE_RESOLVER));\n\n// Tests JSON map.\n//\n// This is the example expected output.\n// {\n//   \"map1\": {\n//     \"key1\": {\n//       \"foo\": \"foovalue\"\n//     },\n//     \"key2\": {\n//       \"foo\": \"barvalue\"\n//     }\n//   },\n//   \"map2\": {\n//     \"nestedself\": {\n//       \"map1\": {\n//         \"nested_key1\": {\n//           \"foo\": \"nested_foo\"\n//         }\n//       },\n//       \"bar\": \"nested_bar_string\"\n//     }\n//   },\n//   \"map3\": {\n//     \"111\": \"one one one\"\n//   },\n//   \"bar\": \"top bar\"\n// }\nTEST_P(ProtostreamObjectSourceMapsTest, MapsTest) {\n  MapOut out;\n  (*out.mutable_map1())[\"key1\"].set_foo(\"foovalue\");\n  (*out.mutable_map1())[\"key2\"].set_foo(\"barvalue\");\n\n  MapOut* nested_value = &(*out.mutable_map2())[\"nestedself\"];\n  (*nested_value->mutable_map1())[\"nested_key1\"].set_foo(\"nested_foo\");\n  nested_value->set_bar(\"nested_bar_string\");\n\n  (*out.mutable_map3())[111] = \"one one one\";\n\n  out.set_bar(\"top bar\");\n\n  ow_.StartObject(\"\")\n      ->StartObject(\"map1\")\n      ->StartObject(\"key1\")\n      ->RenderString(\"foo\", \"foovalue\")\n      ->EndObject()\n      ->StartObject(\"key2\")\n      ->RenderString(\"foo\", \"barvalue\")\n      ->EndObject()\n      ->StartObject(\"map2\")\n      ->StartObject(\"nestedself\")\n      ->StartObject(\"map1\")\n      ->StartObject(\"nested_key1\")\n      ->RenderString(\"foo\", \"nested_foo\")\n      ->EndObject()\n      ->EndObject()\n      ->RenderString(\"bar\", \"nested_bar_string\")\n      ->EndObject()\n      ->EndObject()\n      ->StartObject(\"map3\")\n      ->RenderString(\"111\", \"one one one\")\n      ->EndObject()\n      ->EndObject()\n      ->RenderString(\"bar\", \"top bar\")\n      ->EndObject();\n\n  DoTest(out, MapOut::descriptor());\n}\n\nTEST_P(ProtostreamObjectSourceMapsTest, MissingKeysTest) {\n  // MapOutWireFormat has the same wire representation with MapOut but uses\n  // repeated message fields to represent map fields so we can intentionally\n  // leave out the key field or the value field of a map entry.\n  MapOutWireFormat out;\n  // Create some map entries without keys. They will be rendered with the\n  // default values (\"\" for strings, \"0\" for integers, etc.).\n  // {\n  //   \"map1\": {\n  //     \"\": {\n  //       \"foo\": \"foovalue\"\n  //     }\n  //   },\n  //   \"map2\": {\n  //     \"\": {\n  //       \"map1\": {\n  //         \"nested_key1\": {\n  //           \"foo\": \"nested_foo\"\n  //         }\n  //       }\n  //     }\n  //   },\n  //   \"map3\": {\n  //     \"0\": \"one one one\"\n  //   },\n  //   \"map4\": {\n  //     \"false\": \"bool\"\n  //   }\n  // }\n  out.add_map1()->mutable_value()->set_foo(\"foovalue\");\n  MapOut* nested = out.add_map2()->mutable_value();\n  (*nested->mutable_map1())[\"nested_key1\"].set_foo(\"nested_foo\");\n  out.add_map3()->set_value(\"one one one\");\n  out.add_map4()->set_value(\"bool\");\n\n  ow_.StartObject(\"\")\n      ->StartObject(\"map1\")\n      ->StartObject(\"\")\n      ->RenderString(\"foo\", \"foovalue\")\n      ->EndObject()\n      ->EndObject()\n      ->StartObject(\"map2\")\n      ->StartObject(\"\")\n      ->StartObject(\"map1\")\n      ->StartObject(\"nested_key1\")\n      ->RenderString(\"foo\", \"nested_foo\")\n      ->EndObject()\n      ->EndObject()\n      ->EndObject()\n      ->EndObject()\n      ->StartObject(\"map3\")\n      ->RenderString(\"0\", \"one one one\")\n      ->EndObject()\n      ->StartObject(\"map4\")\n      ->RenderString(\"false\", \"bool\")\n      ->EndObject()\n      ->EndObject();\n\n  DoTest(out, MapOut::descriptor());\n}\n\nclass ProtostreamObjectSourceAnysTest : public ProtostreamObjectSourceTest {\n protected:\n  ProtostreamObjectSourceAnysTest() {\n    helper_.ResetTypeInfo(AnyOut::descriptor(),\n                          google::protobuf::Any::descriptor());\n  }\n};\n\nINSTANTIATE_TEST_CASE_P(DifferentTypeInfoSourceTest,\n                        ProtostreamObjectSourceAnysTest,\n                        ::testing::Values(\n                            testing::USE_TYPE_RESOLVER));\n\n// Tests JSON any support.\n//\n// This is the example expected output.\n// {\n//   \"any\": {\n//     \"@type\": \"type.googleapis.com/google.protobuf.testing.anys.AnyM\"\n//     \"foo\": \"foovalue\"\n//   }\n// }\nTEST_P(ProtostreamObjectSourceAnysTest, BasicAny) {\n  AnyOut out;\n  ::google::protobuf::Any* any = out.mutable_any();\n\n  AnyM m;\n  m.set_foo(\"foovalue\");\n  any->PackFrom(m);\n\n  ow_.StartObject(\"\")\n      ->StartObject(\"any\")\n      ->RenderString(\"@type\",\n                     \"type.googleapis.com/google.protobuf.testing.anys.AnyM\")\n      ->RenderString(\"foo\", \"foovalue\")\n      ->EndObject()\n      ->EndObject();\n\n  DoTest(out, AnyOut::descriptor());\n}\n\nTEST_P(ProtostreamObjectSourceAnysTest, RecursiveAny) {\n  AnyOut out;\n  ::google::protobuf::Any* any = out.mutable_any();\n  any->set_type_url(\"type.googleapis.com/google.protobuf.Any\");\n\n  ::google::protobuf::Any nested_any;\n  nested_any.set_type_url(\n      \"type.googleapis.com/google.protobuf.testing.anys.AnyM\");\n\n  AnyM m;\n  m.set_foo(\"foovalue\");\n  nested_any.set_value(m.SerializeAsString());\n\n  any->set_value(nested_any.SerializeAsString());\n\n  ow_.StartObject(\"\")\n      ->StartObject(\"any\")\n      ->RenderString(\"@type\", \"type.googleapis.com/google.protobuf.Any\")\n      ->StartObject(\"value\")\n      ->RenderString(\"@type\",\n                     \"type.googleapis.com/google.protobuf.testing.anys.AnyM\")\n      ->RenderString(\"foo\", \"foovalue\")\n      ->EndObject()\n      ->EndObject()\n      ->EndObject();\n\n  DoTest(out, AnyOut::descriptor());\n}\n\nTEST_P(ProtostreamObjectSourceAnysTest, DoubleRecursiveAny) {\n  AnyOut out;\n  ::google::protobuf::Any* any = out.mutable_any();\n  any->set_type_url(\"type.googleapis.com/google.protobuf.Any\");\n\n  ::google::protobuf::Any nested_any;\n  nested_any.set_type_url(\"type.googleapis.com/google.protobuf.Any\");\n\n  ::google::protobuf::Any second_nested_any;\n  second_nested_any.set_type_url(\n      \"type.googleapis.com/google.protobuf.testing.anys.AnyM\");\n\n  AnyM m;\n  m.set_foo(\"foovalue\");\n  second_nested_any.set_value(m.SerializeAsString());\n  nested_any.set_value(second_nested_any.SerializeAsString());\n  any->set_value(nested_any.SerializeAsString());\n\n  ow_.StartObject(\"\")\n      ->StartObject(\"any\")\n      ->RenderString(\"@type\", \"type.googleapis.com/google.protobuf.Any\")\n      ->StartObject(\"value\")\n      ->RenderString(\"@type\", \"type.googleapis.com/google.protobuf.Any\")\n      ->StartObject(\"value\")\n      ->RenderString(\"@type\",\n                     \"type.googleapis.com/google.protobuf.testing.anys.AnyM\")\n      ->RenderString(\"foo\", \"foovalue\")\n      ->EndObject()\n      ->EndObject()\n      ->EndObject()\n      ->EndObject();\n\n  DoTest(out, AnyOut::descriptor());\n}\n\nTEST_P(ProtostreamObjectSourceAnysTest, EmptyAnyOutputsEmptyObject) {\n  AnyOut out;\n  out.mutable_any();\n\n  ow_.StartObject(\"\")->StartObject(\"any\")->EndObject()->EndObject();\n\n  DoTest(out, AnyOut::descriptor());\n}\n\nTEST_P(ProtostreamObjectSourceAnysTest, EmptyWithTypeAndNoValueOutputsType) {\n  AnyOut out;\n  out.mutable_any()->set_type_url(\"foo.googleapis.com/my.Type\");\n\n  ow_.StartObject(\"\")\n      ->StartObject(\"any\")\n      ->RenderString(\"@type\", \"foo.googleapis.com/my.Type\")\n      ->EndObject()\n      ->EndObject();\n\n  DoTest(out, AnyOut::descriptor());\n}\n\nTEST_P(ProtostreamObjectSourceAnysTest, MissingTypeUrlError) {\n  AnyOut out;\n  ::google::protobuf::Any* any = out.mutable_any();\n\n  AnyM m;\n  m.set_foo(\"foovalue\");\n  any->set_value(m.SerializeAsString());\n\n  // We start the \"AnyOut\" part and then fail when we hit the Any object.\n  ow_.StartObject(\"\");\n\n  Status status = ExecuteTest(out, AnyOut::descriptor());\n  EXPECT_EQ(util::error::INTERNAL, status.error_code());\n}\n\nTEST_P(ProtostreamObjectSourceAnysTest, UnknownTypeServiceError) {\n  AnyOut out;\n  ::google::protobuf::Any* any = out.mutable_any();\n  any->set_type_url(\"foo.googleapis.com/my.own.Type\");\n\n  AnyM m;\n  m.set_foo(\"foovalue\");\n  any->set_value(m.SerializeAsString());\n\n  // We start the \"AnyOut\" part and then fail when we hit the Any object.\n  ow_.StartObject(\"\");\n\n  Status status = ExecuteTest(out, AnyOut::descriptor());\n  EXPECT_EQ(util::error::INTERNAL, status.error_code());\n}\n\nTEST_P(ProtostreamObjectSourceAnysTest, UnknownTypeError) {\n  AnyOut out;\n  ::google::protobuf::Any* any = out.mutable_any();\n  any->set_type_url(\"type.googleapis.com/unknown.Type\");\n\n  AnyM m;\n  m.set_foo(\"foovalue\");\n  any->set_value(m.SerializeAsString());\n\n  // We start the \"AnyOut\" part and then fail when we hit the Any object.\n  ow_.StartObject(\"\");\n\n  Status status = ExecuteTest(out, AnyOut::descriptor());\n  EXPECT_EQ(util::error::INTERNAL, status.error_code());\n}\n\nclass ProtostreamObjectSourceStructTest : public ProtostreamObjectSourceTest {\n protected:\n  ProtostreamObjectSourceStructTest() {\n    helper_.ResetTypeInfo(StructType::descriptor(),\n                          google::protobuf::Struct::descriptor());\n  }\n};\n\nINSTANTIATE_TEST_CASE_P(DifferentTypeInfoSourceTest,\n                        ProtostreamObjectSourceStructTest,\n                        ::testing::Values(\n                            testing::USE_TYPE_RESOLVER));\n\n// Tests struct\n//\n//  \"object\": {\n//    \"k1\": 123,\n//    \"k2\": true\n//  }\nTEST_P(ProtostreamObjectSourceStructTest, StructRenderSuccess) {\n  StructType out;\n  google::protobuf::Struct* s = out.mutable_object();\n  s->mutable_fields()->operator[](\"k1\").set_number_value(123);\n  s->mutable_fields()->operator[](\"k2\").set_bool_value(true);\n\n  ow_.StartObject(\"\")\n      ->StartObject(\"object\")\n      ->RenderDouble(\"k1\", 123)\n      ->RenderBool(\"k2\", true)\n      ->EndObject()\n      ->EndObject();\n\n  DoTest(out, StructType::descriptor());\n}\n\nTEST_P(ProtostreamObjectSourceStructTest, MissingValueSkipsField) {\n  StructType out;\n  google::protobuf::Struct* s = out.mutable_object();\n  s->mutable_fields()->operator[](\"k1\");\n\n  ow_.StartObject(\"\")->StartObject(\"object\")->EndObject()->EndObject();\n\n  DoTest(out, StructType::descriptor());\n}\n\nclass ProtostreamObjectSourceFieldMaskTest\n    : public ProtostreamObjectSourceTest {\n protected:\n  ProtostreamObjectSourceFieldMaskTest() {\n    helper_.ResetTypeInfo(FieldMaskTest::descriptor(),\n                          google::protobuf::FieldMask::descriptor());\n  }\n};\n\nINSTANTIATE_TEST_CASE_P(DifferentTypeInfoSourceTest,\n                        ProtostreamObjectSourceFieldMaskTest,\n                        ::testing::Values(\n                            testing::USE_TYPE_RESOLVER));\n\nTEST_P(ProtostreamObjectSourceFieldMaskTest, FieldMaskRenderSuccess) {\n  FieldMaskTest out;\n  out.set_id(\"1\");\n  out.mutable_single_mask()->add_paths(\"path1\");\n  out.mutable_single_mask()->add_paths(\"snake_case_path2\");\n  ::google::protobuf::FieldMask* mask = out.add_repeated_mask();\n  mask->add_paths(\"path3\");\n  mask = out.add_repeated_mask();\n  mask->add_paths(\"snake_case_path4\");\n  mask->add_paths(\"path5\");\n  NestedFieldMask* nested = out.add_nested_mask();\n  nested->set_data(\"data\");\n  nested->mutable_single_mask()->add_paths(\"nested.path1\");\n  nested->mutable_single_mask()->add_paths(\"nested_field.snake_case_path2\");\n  mask = nested->add_repeated_mask();\n  mask->add_paths(\"nested_field.path3\");\n  mask->add_paths(\"nested.snake_case_path4\");\n  mask = nested->add_repeated_mask();\n  mask->add_paths(\"nested.path5\");\n  mask = nested->add_repeated_mask();\n  mask->add_paths(\n      \"snake_case.map_field[\\\"map_key_should_be_ignored\\\"].nested_snake_case.\"\n      \"map_field[\\\"map_key_sho\\\\\\\"uld_be_ignored\\\"]\");\n\n  ow_.StartObject(\"\")\n      ->RenderString(\"id\", \"1\")\n      ->RenderString(\"singleMask\", \"path1,snakeCasePath2\")\n      ->StartList(\"repeatedMask\")\n      ->RenderString(\"\", \"path3\")\n      ->RenderString(\"\", \"snakeCasePath4,path5\")\n      ->EndList()\n      ->StartList(\"nestedMask\")\n      ->StartObject(\"\")\n      ->RenderString(\"data\", \"data\")\n      ->RenderString(\"singleMask\", \"nested.path1,nestedField.snakeCasePath2\")\n      ->StartList(\"repeatedMask\")\n      ->RenderString(\"\", \"nestedField.path3,nested.snakeCasePath4\")\n      ->RenderString(\"\", \"nested.path5\")\n      ->RenderString(\"\",\n                     \"snakeCase.mapField[\\\"map_key_should_be_ignored\\\"].\"\n                     \"nestedSnakeCase.mapField[\\\"map_key_sho\\\\\\\"uld_be_\"\n                     \"ignored\\\"]\")\n      ->EndList()\n      ->EndObject()\n      ->EndList()\n      ->EndObject();\n\n  DoTest(out, FieldMaskTest::descriptor());\n}\n\nclass ProtostreamObjectSourceTimestampTest\n    : public ProtostreamObjectSourceTest {\n protected:\n  ProtostreamObjectSourceTimestampTest() {\n    helper_.ResetTypeInfo(TimestampDuration::descriptor());\n  }\n};\n\nINSTANTIATE_TEST_CASE_P(DifferentTypeInfoSourceTest,\n                        ProtostreamObjectSourceTimestampTest,\n                        ::testing::Values(\n                            testing::USE_TYPE_RESOLVER));\n\nTEST_P(ProtostreamObjectSourceTimestampTest, InvalidTimestampBelowMinTest) {\n  TimestampDuration out;\n  google::protobuf::Timestamp* ts = out.mutable_ts();\n  // Min allowed seconds - 1\n  ts->set_seconds(kTimestampMinSeconds - 1);\n  ow_.StartObject(\"\");\n\n  Status status = ExecuteTest(out, TimestampDuration::descriptor());\n  EXPECT_EQ(util::error::INTERNAL, status.error_code());\n}\n\nTEST_P(ProtostreamObjectSourceTimestampTest, InvalidTimestampAboveMaxTest) {\n  TimestampDuration out;\n  google::protobuf::Timestamp* ts = out.mutable_ts();\n  // Max allowed seconds + 1\n  ts->set_seconds(kTimestampMaxSeconds + 1);\n  ow_.StartObject(\"\");\n\n  Status status = ExecuteTest(out, TimestampDuration::descriptor());\n  EXPECT_EQ(util::error::INTERNAL, status.error_code());\n}\n\nTEST_P(ProtostreamObjectSourceTimestampTest, InvalidDurationBelowMinTest) {\n  TimestampDuration out;\n  google::protobuf::Duration* dur = out.mutable_dur();\n  // Min allowed seconds - 1\n  dur->set_seconds(kDurationMinSeconds - 1);\n  ow_.StartObject(\"\");\n\n  Status status = ExecuteTest(out, TimestampDuration::descriptor());\n  EXPECT_EQ(util::error::INTERNAL, status.error_code());\n}\n\nTEST_P(ProtostreamObjectSourceTimestampTest, InvalidDurationAboveMaxTest) {\n  TimestampDuration out;\n  google::protobuf::Duration* dur = out.mutable_dur();\n  // Min allowed seconds + 1\n  dur->set_seconds(kDurationMaxSeconds + 1);\n  ow_.StartObject(\"\");\n\n  Status status = ExecuteTest(out, TimestampDuration::descriptor());\n  EXPECT_EQ(util::error::INTERNAL, status.error_code());\n}\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/protostream_objectwriter.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/internal/protostream_objectwriter.h>\n\n#include <functional>\n#include <stack>\n\n#include <google/protobuf/stubs/once.h>\n#include <google/protobuf/stubs/time.h>\n#include <google/protobuf/wire_format_lite.h>\n#include <google/protobuf/util/internal/field_mask_utility.h>\n#include <google/protobuf/util/internal/object_location_tracker.h>\n#include <google/protobuf/util/internal/constants.h>\n#include <google/protobuf/util/internal/utility.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/map_util.h>\n#include <google/protobuf/stubs/statusor.h>\n\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\nusing google::protobuf::internal::WireFormatLite;\nusing util::error::INVALID_ARGUMENT;\nusing util::Status;\nusing util::StatusOr;\n\n\nProtoStreamObjectWriter::ProtoStreamObjectWriter(\n    TypeResolver* type_resolver, const google::protobuf::Type& type,\n    strings::ByteSink* output, ErrorListener* listener,\n    const ProtoStreamObjectWriter::Options& options)\n    : ProtoWriter(type_resolver, type, output, listener),\n      master_type_(type),\n      current_(NULL),\n      options_(options) {\n  set_ignore_unknown_fields(options_.ignore_unknown_fields);\n}\n\nProtoStreamObjectWriter::ProtoStreamObjectWriter(\n    const TypeInfo* typeinfo, const google::protobuf::Type& type,\n    strings::ByteSink* output, ErrorListener* listener)\n    : ProtoWriter(typeinfo, type, output, listener),\n      master_type_(type),\n      current_(NULL),\n      options_(ProtoStreamObjectWriter::Options::Defaults()) {}\n\nProtoStreamObjectWriter::~ProtoStreamObjectWriter() {\n  if (current_ == NULL) return;\n  // Cleanup explicitly in order to avoid destructor stack overflow when input\n  // is deeply nested.\n  // Cast to BaseElement to avoid doing additional checks (like missing fields)\n  // during pop().\n  google::protobuf::scoped_ptr<BaseElement> element(\n      static_cast<BaseElement*>(current_.get())->pop<BaseElement>());\n  while (element != NULL) {\n    element.reset(element->pop<BaseElement>());\n  }\n}\n\nnamespace {\n// Utility method to split a string representation of Timestamp or Duration and\n// return the parts.\nvoid SplitSecondsAndNanos(StringPiece input, StringPiece* seconds,\n                          StringPiece* nanos) {\n  size_t idx = input.rfind('.');\n  if (idx != string::npos) {\n    *seconds = input.substr(0, idx);\n    *nanos = input.substr(idx + 1);\n  } else {\n    *seconds = input;\n    *nanos = StringPiece();\n  }\n}\n\nStatus GetNanosFromStringPiece(StringPiece s_nanos,\n                               const char* parse_failure_message,\n                               const char* exceeded_limit_message,\n                               int32* nanos) {\n  *nanos = 0;\n\n  // Count the number of leading 0s and consume them.\n  int num_leading_zeros = 0;\n  while (s_nanos.Consume(\"0\")) {\n    num_leading_zeros++;\n  }\n  int32 i_nanos = 0;\n  // 's_nanos' contains fractional seconds -- i.e. 'nanos' is equal to\n  // \"0.\" + s_nanos.ToString() seconds. An int32 is used for the\n  // conversion to 'nanos', rather than a double, so that there is no\n  // loss of precision.\n  if (!s_nanos.empty() && !safe_strto32(s_nanos.ToString(), &i_nanos)) {\n    return Status(INVALID_ARGUMENT, parse_failure_message);\n  }\n  if (i_nanos > kNanosPerSecond || i_nanos < 0) {\n    return Status(INVALID_ARGUMENT, exceeded_limit_message);\n  }\n  // s_nanos should only have digits. No whitespace.\n  if (s_nanos.find_first_not_of(\"0123456789\") != StringPiece::npos) {\n    return Status(INVALID_ARGUMENT, parse_failure_message);\n  }\n\n  if (i_nanos > 0) {\n    // 'scale' is the number of digits to the right of the decimal\n    // point in \"0.\" + s_nanos.ToString()\n    int32 scale = num_leading_zeros + s_nanos.size();\n    // 'conversion' converts i_nanos into nanoseconds.\n    // conversion = kNanosPerSecond / static_cast<int32>(std::pow(10, scale))\n    // For efficiency, we precompute the conversion factor.\n    int32 conversion = 0;\n    switch (scale) {\n      case 1:\n        conversion = 100000000;\n        break;\n      case 2:\n        conversion = 10000000;\n        break;\n      case 3:\n        conversion = 1000000;\n        break;\n      case 4:\n        conversion = 100000;\n        break;\n      case 5:\n        conversion = 10000;\n        break;\n      case 6:\n        conversion = 1000;\n        break;\n      case 7:\n        conversion = 100;\n        break;\n      case 8:\n        conversion = 10;\n        break;\n      case 9:\n        conversion = 1;\n        break;\n      default:\n        return Status(INVALID_ARGUMENT, exceeded_limit_message);\n    }\n    *nanos = i_nanos * conversion;\n  }\n\n  return Status::OK;\n}\n\n}  // namespace\n\nProtoStreamObjectWriter::AnyWriter::AnyWriter(ProtoStreamObjectWriter* parent)\n    : parent_(parent),\n      ow_(),\n      invalid_(false),\n      data_(),\n      output_(&data_),\n      depth_(0),\n      is_well_known_type_(false),\n      well_known_type_render_(NULL) {}\n\nProtoStreamObjectWriter::AnyWriter::~AnyWriter() {}\n\nvoid ProtoStreamObjectWriter::AnyWriter::StartObject(StringPiece name) {\n  ++depth_;\n  // If an object writer is absent, that means we have not called StartAny()\n  // before reaching here. This is an invalid state. StartAny() gets called\n  // whenever we see an \"@type\" being rendered (see AnyWriter::RenderDataPiece).\n  if (ow_ == NULL) {\n    // Make sure we are not already in an invalid state. This avoids making\n    // multiple unnecessary InvalidValue calls.\n    if (!invalid_) {\n      parent_->InvalidValue(\"Any\",\n                            StrCat(\"Missing or invalid @type for any field in \",\n                                   parent_->master_type_.name()));\n      invalid_ = true;\n    }\n  } else if (is_well_known_type_ && depth_ == 1) {\n    // For well-known types, the only other field besides \"@type\" should be a\n    // \"value\" field.\n    if (name != \"value\" && !invalid_) {\n      parent_->InvalidValue(\"Any\",\n                            \"Expect a \\\"value\\\" field for well-known types.\");\n      invalid_ = true;\n    }\n    ow_->StartObject(\"\");\n  } else {\n    // Forward the call to the child writer if:\n    //   1. the type is not a well-known type.\n    //   2. or, we are in a nested Any, Struct, or Value object.\n    ow_->StartObject(name);\n  }\n}\n\nbool ProtoStreamObjectWriter::AnyWriter::EndObject() {\n  --depth_;\n  // As long as depth_ >= 0, we know we haven't reached the end of Any.\n  // Propagate these EndObject() calls to the contained ow_. For regular\n  // message types, we propagate the end of Any as well.\n  if (ow_ != NULL && (depth_ >= 0 || !is_well_known_type_)) {\n    ow_->EndObject();\n  }\n  // A negative depth_ implies that we have reached the end of Any\n  // object. Now we write out its contents.\n  if (depth_ < 0) {\n    WriteAny();\n    return false;\n  }\n  return true;\n}\n\nvoid ProtoStreamObjectWriter::AnyWriter::StartList(StringPiece name) {\n  ++depth_;\n  // We expect ow_ to be present as this call only makes sense inside an Any.\n  if (ow_ == NULL) {\n    if (!invalid_) {\n      parent_->InvalidValue(\"Any\",\n                            StrCat(\"Missing or invalid @type for any field in \",\n                                   parent_->master_type_.name()));\n      invalid_ = true;\n    }\n  } else if (is_well_known_type_ && depth_ == 1) {\n    if (name != \"value\" && !invalid_) {\n      parent_->InvalidValue(\"Any\",\n                            \"Expect a \\\"value\\\" field for well-known types.\");\n      invalid_ = true;\n    }\n    ow_->StartList(\"\");\n  } else {\n    ow_->StartList(name);\n  }\n}\n\nvoid ProtoStreamObjectWriter::AnyWriter::EndList() {\n  --depth_;\n  if (depth_ < 0) {\n    GOOGLE_LOG(DFATAL) << \"Mismatched EndList found, should not be possible\";\n    depth_ = 0;\n  }\n  // We don't write an error on the close, only on the open\n  if (ow_ != NULL) {\n    ow_->EndList();\n  }\n}\n\nvoid ProtoStreamObjectWriter::AnyWriter::RenderDataPiece(\n    StringPiece name, const DataPiece& value) {\n  // Start an Any only at depth_ 0. Other RenderDataPiece calls with \"@type\"\n  // should go to the contained ow_ as they indicate nested Anys.\n  if (depth_ == 0 && ow_ == NULL && name == \"@type\") {\n    StartAny(value);\n  } else if (ow_ == NULL) {\n    if (!invalid_) {\n      parent_->InvalidValue(\"Any\",\n                            StrCat(\"Missing or invalid @type for any field in \",\n                                   parent_->master_type_.name()));\n      invalid_ = true;\n    }\n  } else if (depth_ == 0 && is_well_known_type_) {\n    if (name != \"value\" && !invalid_) {\n      parent_->InvalidValue(\"Any\",\n                            \"Expect a \\\"value\\\" field for well-known types.\");\n      invalid_ = true;\n    }\n    if (well_known_type_render_ == NULL) {\n      // Only Any and Struct don't have a special type render but both of\n      // them expect a JSON object (i.e., a StartObject() call).\n      if (!invalid_) {\n        parent_->InvalidValue(\"Any\", \"Expect a JSON object.\");\n        invalid_ = true;\n      }\n    } else {\n      ow_->ProtoWriter::StartObject(\"\");\n      Status status = (*well_known_type_render_)(ow_.get(), value);\n      if (!status.ok()) ow_->InvalidValue(\"Any\", status.error_message());\n      ow_->ProtoWriter::EndObject();\n    }\n  } else {\n    ow_->RenderDataPiece(name, value);\n  }\n}\n\nvoid ProtoStreamObjectWriter::AnyWriter::StartAny(const DataPiece& value) {\n  // Figure out the type url. This is a copy-paste from WriteString but we also\n  // need the value, so we can't just call through to that.\n  if (value.type() == DataPiece::TYPE_STRING) {\n    type_url_ = value.str().ToString();\n  } else {\n    StatusOr<string> s = value.ToString();\n    if (!s.ok()) {\n      parent_->InvalidValue(\"String\", s.status().error_message());\n      invalid_ = true;\n      return;\n    }\n    type_url_ = s.ValueOrDie();\n  }\n  // Resolve the type url, and report an error if we failed to resolve it.\n  StatusOr<const google::protobuf::Type*> resolved_type =\n      parent_->typeinfo()->ResolveTypeUrl(type_url_);\n  if (!resolved_type.ok()) {\n    parent_->InvalidValue(\"Any\", resolved_type.status().error_message());\n    invalid_ = true;\n    return;\n  }\n  // At this point, type is never null.\n  const google::protobuf::Type* type = resolved_type.ValueOrDie();\n\n  well_known_type_render_ = FindTypeRenderer(type_url_);\n  if (well_known_type_render_ != NULL ||\n      // Explicitly list Any and Struct here because they don't have a\n      // custom renderer.\n      type->name() == kAnyType || type->name() == kStructType) {\n    is_well_known_type_ = true;\n  }\n\n  // Create our object writer and initialize it with the first StartObject\n  // call.\n  ow_.reset(new ProtoStreamObjectWriter(parent_->typeinfo(), *type, &output_,\n                                        parent_->listener()));\n\n  // Don't call StartObject() for well-known types yet. Depending on the\n  // type of actual data, we may not need to call StartObject(). For\n  // example:\n  // {\n  //   \"@type\": \"type.googleapis.com/google.protobuf.Value\",\n  //   \"value\": [1, 2, 3],\n  // }\n  // With the above JSON representation, we will only call StartList() on the\n  // contained ow_.\n  if (!is_well_known_type_) {\n    ow_->StartObject(\"\");\n  }\n}\n\nvoid ProtoStreamObjectWriter::AnyWriter::WriteAny() {\n  if (ow_ == NULL) {\n    // If we had no object writer, we never got any content, so just return\n    // immediately, which is equivalent to writing an empty Any.\n    return;\n  }\n  // Render the type_url and value fields directly to the stream.\n  // type_url has tag 1 and value has tag 2.\n  WireFormatLite::WriteString(1, type_url_, parent_->stream());\n  if (!data_.empty()) {\n    WireFormatLite::WriteBytes(2, data_, parent_->stream());\n  }\n}\n\nProtoStreamObjectWriter::Item::Item(ProtoStreamObjectWriter* enclosing,\n                                    ItemType item_type, bool is_placeholder,\n                                    bool is_list)\n    : BaseElement(NULL),\n      ow_(enclosing),\n      any_(),\n      item_type_(item_type),\n      is_placeholder_(is_placeholder),\n      is_list_(is_list) {\n  if (item_type_ == ANY) {\n    any_.reset(new AnyWriter(ow_));\n  }\n  if (item_type == MAP) {\n    map_keys_.reset(new hash_set<string>);\n  }\n}\n\nProtoStreamObjectWriter::Item::Item(ProtoStreamObjectWriter::Item* parent,\n                                    ItemType item_type, bool is_placeholder,\n                                    bool is_list)\n    : BaseElement(parent),\n      ow_(this->parent()->ow_),\n      any_(),\n      item_type_(item_type),\n      is_placeholder_(is_placeholder),\n      is_list_(is_list) {\n  if (item_type == ANY) {\n    any_.reset(new AnyWriter(ow_));\n  }\n  if (item_type == MAP) {\n    map_keys_.reset(new hash_set<string>);\n  }\n}\n\nbool ProtoStreamObjectWriter::Item::InsertMapKeyIfNotPresent(\n    StringPiece map_key) {\n  return InsertIfNotPresent(map_keys_.get(), map_key.ToString());\n}\n\nProtoStreamObjectWriter* ProtoStreamObjectWriter::StartObject(\n    StringPiece name) {\n  if (invalid_depth() > 0) {\n    IncrementInvalidDepth();\n    return this;\n  }\n\n  // Starting the root message. Create the root Item and return.\n  // ANY message type does not need special handling, just set the ItemType\n  // to ANY.\n  if (current_ == NULL) {\n    ProtoWriter::StartObject(name);\n    current_.reset(new Item(\n        this, master_type_.name() == kAnyType ? Item::ANY : Item::MESSAGE,\n        false, false));\n\n    // If master type is a special type that needs extra values to be written to\n    // stream, we write those values.\n    if (master_type_.name() == kStructType) {\n      // Struct has a map<string, Value> field called \"fields\".\n      // https://github.com/google/protobuf/blob/master/src/google/protobuf/struct.proto\n      // \"fields\": [\n      Push(\"fields\", Item::MAP, true, true);\n      return this;\n    }\n\n    if (master_type_.name() == kStructValueType) {\n      // We got a StartObject call with google.protobuf.Value field. The only\n      // object within that type is a struct type. So start a struct.\n      //\n      // The struct field in Value type is named \"struct_value\"\n      // https://github.com/google/protobuf/blob/master/src/google/protobuf/struct.proto\n      // Also start the map field \"fields\" within the struct.\n      // \"struct_value\": {\n      //   \"fields\": [\n      Push(\"struct_value\", Item::MESSAGE, true, false);\n      Push(\"fields\", Item::MAP, true, true);\n      return this;\n    }\n\n    if (master_type_.name() == kStructListValueType) {\n      InvalidValue(kStructListValueType,\n                   \"Cannot start root message with ListValue.\");\n    }\n\n    return this;\n  }\n\n  // Send all ANY events to AnyWriter.\n  if (current_->IsAny()) {\n    current_->any()->StartObject(name);\n    return this;\n  }\n\n  // If we are within a map, we render name as keys and send StartObject to the\n  // value field.\n  if (current_->IsMap()) {\n    if (!ValidMapKey(name)) {\n      IncrementInvalidDepth();\n      return this;\n    }\n\n    // Map is a repeated field of message type with a \"key\" and a \"value\" field.\n    // https://developers.google.com/protocol-buffers/docs/proto3?hl=en#maps\n    // message MapFieldEntry {\n    //   key_type key = 1;\n    //   value_type value = 2;\n    // }\n    //\n    // repeated MapFieldEntry map_field = N;\n    //\n    // That means, we render the following element within a list (hence no\n    // name):\n    // { \"key\": \"<name>\", \"value\": {\n    Push(\"\", Item::MESSAGE, false, false);\n    ProtoWriter::RenderDataPiece(\"key\",\n                                 DataPiece(name, use_strict_base64_decoding()));\n    Push(\"value\", Item::MESSAGE, true, false);\n\n    // Make sure we are valid so far after starting map fields.\n    if (invalid_depth() > 0) return this;\n\n    // If top of stack is g.p.Struct type, start the struct the map field within\n    // it.\n    if (element() != NULL && IsStruct(*element()->parent_field())) {\n      // Render \"fields\": [\n      Push(\"fields\", Item::MAP, true, true);\n      return this;\n    }\n\n    // If top of stack is g.p.Value type, start the Struct within it.\n    if (element() != NULL && IsStructValue(*element()->parent_field())) {\n      // Render\n      // \"struct_value\": {\n      //   \"fields\": [\n      Push(\"struct_value\", Item::MESSAGE, true, false);\n      Push(\"fields\", Item::MAP, true, true);\n    }\n    return this;\n  }\n\n  const google::protobuf::Field* field = BeginNamed(name, false);\n  if (field == NULL) return this;\n\n  if (IsStruct(*field)) {\n    // Start a struct object.\n    // Render\n    // \"<name>\": {\n    //   \"fields\": {\n    Push(name, Item::MESSAGE, false, false);\n    Push(\"fields\", Item::MAP, true, true);\n    return this;\n  }\n\n  if (IsStructValue(*field)) {\n    // We got a StartObject call with google.protobuf.Value field.  The only\n    // object within that type is a struct type. So start a struct.\n    // Render\n    // \"<name>\": {\n    //   \"struct_value\": {\n    //     \"fields\": {\n    Push(name, Item::MESSAGE, false, false);\n    Push(\"struct_value\", Item::MESSAGE, true, false);\n    Push(\"fields\", Item::MAP, true, true);\n    return this;\n  }\n\n  if (IsMap(*field)) {\n    // Begin a map. A map is triggered by a StartObject() call if the current\n    // field has a map type.\n    // A map type is always repeated, hence set is_list to true.\n    // Render\n    // \"<name>\": [\n    Push(name, Item::MAP, false, true);\n    return this;\n  }\n\n  // A regular message type. Pass it directly to ProtoWriter.\n  // Render\n  // \"<name>\": {\n  Push(name, IsAny(*field) ? Item::ANY : Item::MESSAGE, false, false);\n  return this;\n}\n\nProtoStreamObjectWriter* ProtoStreamObjectWriter::EndObject() {\n  if (invalid_depth() > 0) {\n    DecrementInvalidDepth();\n    return this;\n  }\n\n  if (current_ == NULL) return this;\n\n  if (current_->IsAny()) {\n    if (current_->any()->EndObject()) return this;\n  }\n\n  Pop();\n\n  return this;\n}\n\nProtoStreamObjectWriter* ProtoStreamObjectWriter::StartList(StringPiece name) {\n  if (invalid_depth() > 0) {\n    IncrementInvalidDepth();\n    return this;\n  }\n\n  // Since we cannot have a top-level repeated item in protobuf, the only way\n  // this is valid is if we start a special type google.protobuf.ListValue or\n  // google.protobuf.Value.\n  if (current_ == NULL) {\n    if (!name.empty()) {\n      InvalidName(name, \"Root element should not be named.\");\n      IncrementInvalidDepth();\n      return this;\n    }\n\n    // If master type is a special type that needs extra values to be written to\n    // stream, we write those values.\n    if (master_type_.name() == kStructValueType) {\n      // We got a StartList with google.protobuf.Value master type. This means\n      // we have to start the \"list_value\" within google.protobuf.Value.\n      //\n      // See\n      // https://github.com/google/protobuf/blob/master/src/google/protobuf/struct.proto\n      //\n      // Render\n      // \"<name>\": {\n      //   \"list_value\": {\n      //     \"values\": [  // Start this list.\n      ProtoWriter::StartObject(name);\n      current_.reset(new Item(this, Item::MESSAGE, false, false));\n      Push(\"list_value\", Item::MESSAGE, true, false);\n      Push(\"values\", Item::MESSAGE, true, true);\n      return this;\n    }\n\n    if (master_type_.name() == kStructListValueType) {\n      // We got a StartList with google.protobuf.ListValue master type. This\n      // means we have to start the \"values\" within google.protobuf.ListValue.\n      //\n      // Render\n      // \"<name>\": {\n      //   \"values\": [  // Start this list.\n      ProtoWriter::StartObject(name);\n      current_.reset(new Item(this, Item::MESSAGE, false, false));\n      Push(\"values\", Item::MESSAGE, true, true);\n      return this;\n    }\n\n    // Send the event to ProtoWriter so proper errors can be reported.\n    //\n    // Render a regular list:\n    // \"<name>\": [\n    ProtoWriter::StartList(name);\n    current_.reset(new Item(this, Item::MESSAGE, false, true));\n    return this;\n  }\n\n  if (current_->IsAny()) {\n    current_->any()->StartList(name);\n    return this;\n  }\n\n  // If the top of stack is a map, we are starting a list value within a map.\n  // Since map does not allow repeated values, this can only happen when the map\n  // value is of a special type that renders a list in JSON.  These can be one\n  // of 3 cases:\n  // i. We are rendering a list value within google.protobuf.Struct\n  // ii. We are rendering a list value within google.protobuf.Value\n  // iii. We are rendering a list value with type google.protobuf.ListValue.\n  if (current_->IsMap()) {\n    if (!ValidMapKey(name)) {\n      IncrementInvalidDepth();\n      return this;\n    }\n\n    // Start the repeated map entry object.\n    // Render\n    // { \"key\": \"<name>\", \"value\": {\n    Push(\"\", Item::MESSAGE, false, false);\n    ProtoWriter::RenderDataPiece(\"key\",\n                                 DataPiece(name, use_strict_base64_decoding()));\n    Push(\"value\", Item::MESSAGE, true, false);\n\n    // Make sure we are valid after pushing all above items.\n    if (invalid_depth() > 0) return this;\n\n    // case i and ii above. Start \"list_value\" field within g.p.Value\n    if (element() != NULL && element()->parent_field() != NULL) {\n      // Render\n      // \"list_value\": {\n      //   \"values\": [  // Start this list\n      if (IsStructValue(*element()->parent_field())) {\n        Push(\"list_value\", Item::MESSAGE, true, false);\n        Push(\"values\", Item::MESSAGE, true, true);\n        return this;\n      }\n\n      // Render\n      // \"values\": [\n      if (IsStructListValue(*element()->parent_field())) {\n        // case iii above. Bind directly to g.p.ListValue\n        Push(\"values\", Item::MESSAGE, true, true);\n        return this;\n      }\n    }\n\n    // Report an error.\n    InvalidValue(\"Map\", StrCat(\"Cannot have repeated items ('\", name,\n                               \"') within a map.\"));\n    return this;\n  }\n\n  // When name is empty and stack is not empty, we are rendering an item within\n  // a list.\n  if (name.empty()) {\n    if (element() != NULL && element()->parent_field() != NULL) {\n      if (IsStructValue(*element()->parent_field())) {\n        // Since it is g.p.Value, we bind directly to the list_value.\n        // Render\n        // {  // g.p.Value item within the list\n        //   \"list_value\": {\n        //     \"values\": [\n        Push(\"\", Item::MESSAGE, false, false);\n        Push(\"list_value\", Item::MESSAGE, true, false);\n        Push(\"values\", Item::MESSAGE, true, true);\n        return this;\n      }\n\n      if (IsStructListValue(*element()->parent_field())) {\n        // Since it is g.p.ListValue, we bind to it directly.\n        // Render\n        // {  // g.p.ListValue item within the list\n        //   \"values\": [\n        Push(\"\", Item::MESSAGE, false, false);\n        Push(\"values\", Item::MESSAGE, true, true);\n        return this;\n      }\n    }\n\n    // Pass the event to underlying ProtoWriter.\n    Push(name, Item::MESSAGE, false, true);\n    return this;\n  }\n\n  // name is not empty\n  const google::protobuf::Field* field = Lookup(name);\n  if (field == NULL) {\n    IncrementInvalidDepth();\n    return this;\n  }\n\n  if (IsStructValue(*field)) {\n    // If g.p.Value is repeated, start that list. Otherwise, start the\n    // \"list_value\" within it.\n    if (IsRepeated(*field)) {\n      // Render it just like a regular repeated field.\n      // \"<name>\": [\n      Push(name, Item::MESSAGE, false, true);\n      return this;\n    }\n\n    // Start the \"list_value\" field.\n    // Render\n    // \"<name>\": {\n    //   \"list_value\": {\n    //     \"values\": [\n    Push(name, Item::MESSAGE, false, false);\n    Push(\"list_value\", Item::MESSAGE, true, false);\n    Push(\"values\", Item::MESSAGE, true, true);\n    return this;\n  }\n\n  if (IsStructListValue(*field)) {\n    // If g.p.ListValue is repeated, start that list. Otherwise, start the\n    // \"values\" within it.\n    if (IsRepeated(*field)) {\n      // Render it just like a regular repeated field.\n      // \"<name>\": [\n      Push(name, Item::MESSAGE, false, true);\n      return this;\n    }\n\n    // Start the \"values\" field within g.p.ListValue.\n    // Render\n    // \"<name>\": {\n    //   \"values\": [\n    Push(name, Item::MESSAGE, false, false);\n    Push(\"values\", Item::MESSAGE, true, true);\n    return this;\n  }\n\n  // If we are here, the field should be repeated. Report an error otherwise.\n  if (!IsRepeated(*field)) {\n    IncrementInvalidDepth();\n    InvalidName(name, \"Proto field is not repeating, cannot start list.\");\n    return this;\n  }\n\n  if (IsMap(*field)) {\n    InvalidValue(\"Map\",\n                 StrCat(\"Cannot bind a list to map for field '\", name, \"'.\"));\n    IncrementInvalidDepth();\n    return this;\n  }\n\n  // Pass the event to ProtoWriter.\n  // Render\n  // \"<name>\": [\n  Push(name, Item::MESSAGE, false, true);\n  return this;\n}\n\nProtoStreamObjectWriter* ProtoStreamObjectWriter::EndList() {\n  if (invalid_depth() > 0) {\n    DecrementInvalidDepth();\n    return this;\n  }\n\n  if (current_ == NULL) return this;\n\n  if (current_->IsAny()) {\n    current_->any()->EndList();\n    return this;\n  }\n\n  Pop();\n  return this;\n}\n\nStatus ProtoStreamObjectWriter::RenderStructValue(ProtoStreamObjectWriter* ow,\n                                                  const DataPiece& data) {\n  string struct_field_name;\n  switch (data.type()) {\n    // Our JSON parser parses numbers as either int64, uint64, or double.\n    case DataPiece::TYPE_INT64: {\n      // If the option to treat integers as strings is set, then render them as\n      // strings. Otherwise, fallback to rendering them as double.\n      if (ow->options_.struct_integers_as_strings) {\n        StatusOr<int64> int_value = data.ToInt64();\n        if (int_value.ok()) {\n          ow->ProtoWriter::RenderDataPiece(\n              \"string_value\",\n              DataPiece(SimpleItoa(int_value.ValueOrDie()), true));\n          return Status::OK;\n        }\n      }\n      struct_field_name = \"number_value\";\n      break;\n    }\n    case DataPiece::TYPE_UINT64: {\n      // If the option to treat integers as strings is set, then render them as\n      // strings. Otherwise, fallback to rendering them as double.\n      if (ow->options_.struct_integers_as_strings) {\n        StatusOr<uint64> int_value = data.ToUint64();\n        if (int_value.ok()) {\n          ow->ProtoWriter::RenderDataPiece(\n              \"string_value\",\n              DataPiece(SimpleItoa(int_value.ValueOrDie()), true));\n          return Status::OK;\n        }\n      }\n      struct_field_name = \"number_value\";\n      break;\n    }\n    case DataPiece::TYPE_DOUBLE: {\n      struct_field_name = \"number_value\";\n      break;\n    }\n    case DataPiece::TYPE_STRING: {\n      struct_field_name = \"string_value\";\n      break;\n    }\n    case DataPiece::TYPE_BOOL: {\n      struct_field_name = \"bool_value\";\n      break;\n    }\n    case DataPiece::TYPE_NULL: {\n      struct_field_name = \"null_value\";\n      break;\n    }\n    default: {\n      return Status(INVALID_ARGUMENT,\n                    \"Invalid struct data type. Only number, string, boolean or \"\n                    \"null values are supported.\");\n    }\n  }\n  ow->ProtoWriter::RenderDataPiece(struct_field_name, data);\n  return Status::OK;\n}\n\nStatus ProtoStreamObjectWriter::RenderTimestamp(ProtoStreamObjectWriter* ow,\n                                                const DataPiece& data) {\n  if (data.type() != DataPiece::TYPE_STRING) {\n    return Status(INVALID_ARGUMENT,\n                  StrCat(\"Invalid data type for timestamp, value is \",\n                         data.ValueAsStringOrDefault(\"\")));\n  }\n\n  StringPiece value(data.str());\n\n  int64 seconds;\n  int32 nanos;\n  if (!::google::protobuf::internal::ParseTime(value.ToString(), &seconds,\n                                               &nanos)) {\n    return Status(INVALID_ARGUMENT, StrCat(\"Invalid time format: \", value));\n  }\n\n\n  ow->ProtoWriter::RenderDataPiece(\"seconds\", DataPiece(seconds));\n  ow->ProtoWriter::RenderDataPiece(\"nanos\", DataPiece(nanos));\n  return Status::OK;\n}\n\nstatic inline util::Status RenderOneFieldPath(ProtoStreamObjectWriter* ow,\n                                                StringPiece path) {\n  ow->ProtoWriter::RenderDataPiece(\n      \"paths\", DataPiece(ConvertFieldMaskPath(path, &ToSnakeCase), true));\n  return Status::OK;\n}\n\nStatus ProtoStreamObjectWriter::RenderFieldMask(ProtoStreamObjectWriter* ow,\n                                                const DataPiece& data) {\n  if (data.type() != DataPiece::TYPE_STRING) {\n    return Status(INVALID_ARGUMENT,\n                  StrCat(\"Invalid data type for field mask, value is \",\n                         data.ValueAsStringOrDefault(\"\")));\n  }\n\n// TODO(tsun): figure out how to do proto descriptor based snake case\n// conversions as much as possible. Because ToSnakeCase sometimes returns the\n// wrong value.\n  google::protobuf::scoped_ptr<ResultCallback1<util::Status, StringPiece> > callback(\n      ::google::protobuf::internal::NewPermanentCallback(&RenderOneFieldPath, ow));\n  return DecodeCompactFieldMaskPaths(data.str(), callback.get());\n}\n\nStatus ProtoStreamObjectWriter::RenderDuration(ProtoStreamObjectWriter* ow,\n                                               const DataPiece& data) {\n  if (data.type() != DataPiece::TYPE_STRING) {\n    return Status(INVALID_ARGUMENT,\n                  StrCat(\"Invalid data type for duration, value is \",\n                         data.ValueAsStringOrDefault(\"\")));\n  }\n\n  StringPiece value(data.str());\n\n  if (!value.ends_with(\"s\")) {\n    return Status(INVALID_ARGUMENT,\n                  \"Illegal duration format; duration must end with 's'\");\n  }\n  value = value.substr(0, value.size() - 1);\n  int sign = 1;\n  if (value.starts_with(\"-\")) {\n    sign = -1;\n    value = value.substr(1);\n  }\n\n  StringPiece s_secs, s_nanos;\n  SplitSecondsAndNanos(value, &s_secs, &s_nanos);\n  uint64 unsigned_seconds;\n  if (!safe_strtou64(s_secs, &unsigned_seconds)) {\n    return Status(INVALID_ARGUMENT,\n                  \"Invalid duration format, failed to parse seconds\");\n  }\n\n  int32 nanos = 0;\n  Status nanos_status = GetNanosFromStringPiece(\n      s_nanos, \"Invalid duration format, failed to parse nano seconds\",\n      \"Duration value exceeds limits\", &nanos);\n  if (!nanos_status.ok()) {\n    return nanos_status;\n  }\n  nanos = sign * nanos;\n\n  int64 seconds = sign * unsigned_seconds;\n  if (seconds > kDurationMaxSeconds || seconds < kDurationMinSeconds ||\n      nanos <= -kNanosPerSecond || nanos >= kNanosPerSecond) {\n    return Status(INVALID_ARGUMENT, \"Duration value exceeds limits\");\n  }\n\n  ow->ProtoWriter::RenderDataPiece(\"seconds\", DataPiece(seconds));\n  ow->ProtoWriter::RenderDataPiece(\"nanos\", DataPiece(nanos));\n  return Status::OK;\n}\n\nStatus ProtoStreamObjectWriter::RenderWrapperType(ProtoStreamObjectWriter* ow,\n                                                  const DataPiece& data) {\n  ow->ProtoWriter::RenderDataPiece(\"value\", data);\n  return Status::OK;\n}\n\nProtoStreamObjectWriter* ProtoStreamObjectWriter::RenderDataPiece(\n    StringPiece name, const DataPiece& data) {\n  Status status;\n  if (invalid_depth() > 0) return this;\n\n  if (current_ == NULL) {\n    const TypeRenderer* type_renderer =\n        FindTypeRenderer(GetFullTypeWithUrl(master_type_.name()));\n    if (type_renderer == NULL) {\n      InvalidName(name, \"Root element must be a message.\");\n      return this;\n    }\n    // Render the special type.\n    // \"<name>\": {\n    //   ... Render special type ...\n    // }\n    ProtoWriter::StartObject(name);\n    status = (*type_renderer)(this, data);\n    if (!status.ok()) {\n      InvalidValue(master_type_.name(),\n                   StrCat(\"Field '\", name, \"', \", status.error_message()));\n    }\n    ProtoWriter::EndObject();\n    return this;\n  }\n\n  if (current_->IsAny()) {\n    current_->any()->RenderDataPiece(name, data);\n    return this;\n  }\n\n  const google::protobuf::Field* field = NULL;\n  if (current_->IsMap()) {\n    if (!ValidMapKey(name)) return this;\n\n    // Render an item in repeated map list.\n    // { \"key\": \"<name>\", \"value\":\n    Push(\"\", Item::MESSAGE, false, false);\n    ProtoWriter::RenderDataPiece(\"key\",\n                                 DataPiece(name, use_strict_base64_decoding()));\n    field = Lookup(\"value\");\n    if (field == NULL) {\n      Pop();\n      GOOGLE_LOG(DFATAL) << \"Map does not have a value field.\";\n      return this;\n    }\n\n    const TypeRenderer* type_renderer = FindTypeRenderer(field->type_url());\n    if (type_renderer != NULL) {\n      // Map's value type is a special type. Render it like a message:\n      // \"value\": {\n      //   ... Render special type ...\n      // }\n      Push(\"value\", Item::MESSAGE, true, false);\n      status = (*type_renderer)(this, data);\n      if (!status.ok()) {\n        InvalidValue(field->type_url(),\n                     StrCat(\"Field '\", name, \"', \", status.error_message()));\n      }\n      Pop();\n      return this;\n    }\n\n    // If we are rendering explicit null values and the backend proto field is\n    // not of the google.protobuf.NullType type, we do nothing.\n    if (data.type() == DataPiece::TYPE_NULL &&\n        field->type_url() != kStructNullValueTypeUrl) {\n      Pop();\n      return this;\n    }\n\n    // Render the map value as a primitive type.\n    ProtoWriter::RenderDataPiece(\"value\", data);\n    Pop();\n    return this;\n  }\n\n  field = Lookup(name);\n  if (field == NULL) return this;\n\n  // Check if the field is of special type. Render it accordingly if so.\n  const TypeRenderer* type_renderer = FindTypeRenderer(field->type_url());\n  if (type_renderer != NULL) {\n    Push(name, Item::MESSAGE, false, false);\n    status = (*type_renderer)(this, data);\n    if (!status.ok()) {\n      InvalidValue(field->type_url(),\n                   StrCat(\"Field '\", name, \"', \", status.error_message()));\n    }\n    Pop();\n    return this;\n  }\n\n  // If we are rendering explicit null values and the backend proto field is\n  // not of the google.protobuf.NullType type, we do nothing.\n  if (data.type() == DataPiece::TYPE_NULL &&\n      field->type_url() != kStructNullValueTypeUrl) {\n    return this;\n  }\n\n  ProtoWriter::RenderDataPiece(name, data);\n  return this;\n}\n\n// Map of functions that are responsible for rendering well known type\n// represented by the key.\nhash_map<string, ProtoStreamObjectWriter::TypeRenderer>*\n    ProtoStreamObjectWriter::renderers_ = NULL;\nGOOGLE_PROTOBUF_DECLARE_ONCE(writer_renderers_init_);\n\nvoid ProtoStreamObjectWriter::InitRendererMap() {\n  renderers_ = new hash_map<string, ProtoStreamObjectWriter::TypeRenderer>();\n  (*renderers_)[\"type.googleapis.com/google.protobuf.Timestamp\"] =\n      &ProtoStreamObjectWriter::RenderTimestamp;\n  (*renderers_)[\"type.googleapis.com/google.protobuf.Duration\"] =\n      &ProtoStreamObjectWriter::RenderDuration;\n  (*renderers_)[\"type.googleapis.com/google.protobuf.FieldMask\"] =\n      &ProtoStreamObjectWriter::RenderFieldMask;\n  (*renderers_)[\"type.googleapis.com/google.protobuf.Double\"] =\n      &ProtoStreamObjectWriter::RenderWrapperType;\n  (*renderers_)[\"type.googleapis.com/google.protobuf.Float\"] =\n      &ProtoStreamObjectWriter::RenderWrapperType;\n  (*renderers_)[\"type.googleapis.com/google.protobuf.Int64\"] =\n      &ProtoStreamObjectWriter::RenderWrapperType;\n  (*renderers_)[\"type.googleapis.com/google.protobuf.UInt64\"] =\n      &ProtoStreamObjectWriter::RenderWrapperType;\n  (*renderers_)[\"type.googleapis.com/google.protobuf.Int32\"] =\n      &ProtoStreamObjectWriter::RenderWrapperType;\n  (*renderers_)[\"type.googleapis.com/google.protobuf.UInt32\"] =\n      &ProtoStreamObjectWriter::RenderWrapperType;\n  (*renderers_)[\"type.googleapis.com/google.protobuf.Bool\"] =\n      &ProtoStreamObjectWriter::RenderWrapperType;\n  (*renderers_)[\"type.googleapis.com/google.protobuf.String\"] =\n      &ProtoStreamObjectWriter::RenderWrapperType;\n  (*renderers_)[\"type.googleapis.com/google.protobuf.Bytes\"] =\n      &ProtoStreamObjectWriter::RenderWrapperType;\n  (*renderers_)[\"type.googleapis.com/google.protobuf.DoubleValue\"] =\n      &ProtoStreamObjectWriter::RenderWrapperType;\n  (*renderers_)[\"type.googleapis.com/google.protobuf.FloatValue\"] =\n      &ProtoStreamObjectWriter::RenderWrapperType;\n  (*renderers_)[\"type.googleapis.com/google.protobuf.Int64Value\"] =\n      &ProtoStreamObjectWriter::RenderWrapperType;\n  (*renderers_)[\"type.googleapis.com/google.protobuf.UInt64Value\"] =\n      &ProtoStreamObjectWriter::RenderWrapperType;\n  (*renderers_)[\"type.googleapis.com/google.protobuf.Int32Value\"] =\n      &ProtoStreamObjectWriter::RenderWrapperType;\n  (*renderers_)[\"type.googleapis.com/google.protobuf.UInt32Value\"] =\n      &ProtoStreamObjectWriter::RenderWrapperType;\n  (*renderers_)[\"type.googleapis.com/google.protobuf.BoolValue\"] =\n      &ProtoStreamObjectWriter::RenderWrapperType;\n  (*renderers_)[\"type.googleapis.com/google.protobuf.StringValue\"] =\n      &ProtoStreamObjectWriter::RenderWrapperType;\n  (*renderers_)[\"type.googleapis.com/google.protobuf.BytesValue\"] =\n      &ProtoStreamObjectWriter::RenderWrapperType;\n  (*renderers_)[\"type.googleapis.com/google.protobuf.Value\"] =\n      &ProtoStreamObjectWriter::RenderStructValue;\n  ::google::protobuf::internal::OnShutdown(&DeleteRendererMap);\n}\n\nvoid ProtoStreamObjectWriter::DeleteRendererMap() {\n  delete ProtoStreamObjectWriter::renderers_;\n  renderers_ = NULL;\n}\n\nProtoStreamObjectWriter::TypeRenderer*\nProtoStreamObjectWriter::FindTypeRenderer(const string& type_url) {\n  ::google::protobuf::GoogleOnceInit(&writer_renderers_init_, &InitRendererMap);\n  return FindOrNull(*renderers_, type_url);\n}\n\nbool ProtoStreamObjectWriter::ValidMapKey(StringPiece unnormalized_name) {\n  if (current_ == NULL) return true;\n\n  if (!current_->InsertMapKeyIfNotPresent(unnormalized_name)) {\n    listener()->InvalidName(\n        location(), unnormalized_name,\n        StrCat(\"Repeated map key: '\", unnormalized_name, \"' is already set.\"));\n    return false;\n  }\n\n  return true;\n}\n\nvoid ProtoStreamObjectWriter::Push(StringPiece name, Item::ItemType item_type,\n                                   bool is_placeholder, bool is_list) {\n  is_list ? ProtoWriter::StartList(name) : ProtoWriter::StartObject(name);\n\n  // invalid_depth == 0 means it is a successful StartObject or StartList.\n  if (invalid_depth() == 0)\n    current_.reset(\n        new Item(current_.release(), item_type, is_placeholder, is_list));\n}\n\nvoid ProtoStreamObjectWriter::Pop() {\n  // Pop all placeholder items sending StartObject or StartList events to\n  // ProtoWriter according to is_list value.\n  while (current_ != NULL && current_->is_placeholder()) {\n    PopOneElement();\n  }\n  if (current_ != NULL) {\n    PopOneElement();\n  }\n}\n\nvoid ProtoStreamObjectWriter::PopOneElement() {\n  current_->is_list() ? ProtoWriter::EndList() : ProtoWriter::EndObject();\n  current_.reset(current_->pop<Item>());\n}\n\nbool ProtoStreamObjectWriter::IsMap(const google::protobuf::Field& field) {\n  if (field.type_url().empty() ||\n      field.kind() != google::protobuf::Field_Kind_TYPE_MESSAGE ||\n      field.cardinality() !=\n          google::protobuf::Field_Cardinality_CARDINALITY_REPEATED) {\n    return false;\n  }\n  const google::protobuf::Type* field_type =\n      typeinfo()->GetTypeByTypeUrl(field.type_url());\n\n  // TODO(xiaofeng): Unify option names.\n  return GetBoolOptionOrDefault(field_type->options(),\n                                \"google.protobuf.MessageOptions.map_entry\", false) ||\n         GetBoolOptionOrDefault(field_type->options(), \"map_entry\", false);\n}\n\nbool ProtoStreamObjectWriter::IsAny(const google::protobuf::Field& field) {\n  return GetTypeWithoutUrl(field.type_url()) == kAnyType;\n}\n\nbool ProtoStreamObjectWriter::IsStruct(const google::protobuf::Field& field) {\n  return GetTypeWithoutUrl(field.type_url()) == kStructType;\n}\n\nbool ProtoStreamObjectWriter::IsStructValue(\n    const google::protobuf::Field& field) {\n  return GetTypeWithoutUrl(field.type_url()) == kStructValueType;\n}\n\nbool ProtoStreamObjectWriter::IsStructListValue(\n    const google::protobuf::Field& field) {\n  return GetTypeWithoutUrl(field.type_url()) == kStructListValueType;\n}\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/protostream_objectwriter.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTWRITER_H__\n#define GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTWRITER_H__\n\n#include <deque>\n#include <google/protobuf/stubs/hash.h>\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/util/internal/type_info.h>\n#include <google/protobuf/util/internal/datapiece.h>\n#include <google/protobuf/util/internal/error_listener.h>\n#include <google/protobuf/util/internal/proto_writer.h>\n#include <google/protobuf/util/internal/structured_objectwriter.h>\n#include <google/protobuf/util/type_resolver.h>\n#include <google/protobuf/stubs/bytestream.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\nclass CodedOutputStream;\n}  // namespace io\n}  // namespace protobuf\n\n\nnamespace protobuf {\nclass Type;\nclass Field;\n}  // namespace protobuf\n\n\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\nclass ObjectLocationTracker;\n\n// An ObjectWriter that can write protobuf bytes directly from writer events.\n// This class supports all special types like Struct and Map. It uses\n// the ProtoWriter class to write raw proto bytes.\n//\n// It also supports streaming.\nclass LIBPROTOBUF_EXPORT ProtoStreamObjectWriter : public ProtoWriter {\n public:\n  // Options that control ProtoStreamObjectWriter class's behavior.\n  struct Options {\n    // Treats integer inputs in google.protobuf.Struct as strings. Normally,\n    // integer values are returned in double field \"number_value\" of\n    // google.protobuf.Struct. However, this can cause precision loss for\n    // int64/uint64 inputs. This option is provided for cases that want to\n    // preserve integer precision.\n    bool struct_integers_as_strings;\n\n    // Not treat unknown fields as an error. If there is an unknown fields,\n    // just ignore it and continue to process the rest.\n    bool ignore_unknown_fields;\n\n    Options()\n        : struct_integers_as_strings(false), ignore_unknown_fields(false) {}\n\n    // Default instance of Options with all options set to defaults.\n    static const Options& Defaults() {\n      static Options defaults;\n      return defaults;\n    }\n  };\n\n// Constructor. Does not take ownership of any parameter passed in.\n  ProtoStreamObjectWriter(TypeResolver* type_resolver,\n                          const google::protobuf::Type& type,\n                          strings::ByteSink* output, ErrorListener* listener,\n                          const ProtoStreamObjectWriter::Options& options =\n                              ProtoStreamObjectWriter::Options::Defaults());\n  virtual ~ProtoStreamObjectWriter();\n\n  // ObjectWriter methods.\n  virtual ProtoStreamObjectWriter* StartObject(StringPiece name);\n  virtual ProtoStreamObjectWriter* EndObject();\n  virtual ProtoStreamObjectWriter* StartList(StringPiece name);\n  virtual ProtoStreamObjectWriter* EndList();\n\n  // Renders a DataPiece 'value' into a field whose wire type is determined\n  // from the given field 'name'.\n  virtual ProtoStreamObjectWriter* RenderDataPiece(StringPiece name,\n                                                   const DataPiece& value);\n\n protected:\n  // Function that renders a well known type with modified behavior.\n  typedef util::Status (*TypeRenderer)(ProtoStreamObjectWriter*,\n                                         const DataPiece&);\n\n  // Handles writing Anys out using nested object writers and the like.\n  class LIBPROTOBUF_EXPORT AnyWriter {\n   public:\n    explicit AnyWriter(ProtoStreamObjectWriter* parent);\n    ~AnyWriter();\n\n    // Passes a StartObject call through to the Any writer.\n    void StartObject(StringPiece name);\n\n    // Passes an EndObject call through to the Any. Returns true if the any\n    // handled the EndObject call, false if the Any is now all done and is no\n    // longer needed.\n    bool EndObject();\n\n    // Passes a StartList call through to the Any writer.\n    void StartList(StringPiece name);\n\n    // Passes an EndList call through to the Any writer.\n    void EndList();\n\n    // Renders a data piece on the any.\n    void RenderDataPiece(StringPiece name, const DataPiece& value);\n\n   private:\n    // Handles starting up the any once we have a type.\n    void StartAny(const DataPiece& value);\n\n    // Writes the Any out to the parent writer in its serialized form.\n    void WriteAny();\n\n    // The parent of this writer, needed for various bits such as type info and\n    // the listeners.\n    ProtoStreamObjectWriter* parent_;\n\n    // The nested object writer, used to write events.\n    google::protobuf::scoped_ptr<ProtoStreamObjectWriter> ow_;\n\n    // The type_url_ that this Any represents.\n    string type_url_;\n\n    // Whether this any is invalid. This allows us to only report an invalid\n    // Any message a single time rather than every time we get a nested field.\n    bool invalid_;\n\n    // The output data and wrapping ByteSink.\n    string data_;\n    strings::StringByteSink output_;\n\n    // The depth within the Any, so we can track when we're done.\n    int depth_;\n\n    // True if the type is a well-known type. Well-known types in Any\n    // has a special formating:\n    // {\n    //   \"@type\": \"type.googleapis.com/google.protobuf.XXX\",\n    //   \"value\": <JSON representation of the type>,\n    // }\n    bool is_well_known_type_;\n    TypeRenderer* well_known_type_render_;\n  };\n\n  // Represents an item in a stack of items used to keep state between\n  // ObjectWrier events.\n  class LIBPROTOBUF_EXPORT Item : public BaseElement {\n   public:\n    // Indicates the type of item.\n    enum ItemType {\n      MESSAGE,  // Simple message\n      MAP,      // Proto3 map type\n      ANY,      // Proto3 Any type\n    };\n\n    // Constructor for the root item.\n    Item(ProtoStreamObjectWriter* enclosing, ItemType item_type,\n         bool is_placeholder, bool is_list);\n\n    // Constructor for a field of a message.\n    Item(Item* parent, ItemType item_type, bool is_placeholder, bool is_list);\n\n    virtual ~Item() {}\n\n    // These functions return true if the element type is corresponding to the\n    // type in function name.\n    bool IsMap() { return item_type_ == MAP; }\n    bool IsAny() { return item_type_ == ANY; }\n\n    AnyWriter* any() const { return any_.get(); }\n\n    virtual Item* parent() const {\n      return static_cast<Item*>(BaseElement::parent());\n    }\n\n    // Inserts map key into hash set if and only if the key did NOT already\n    // exist in hash set.\n    // The hash set (map_keys_) is ONLY used to keep track of map keys.\n    // Return true if insert successfully; returns false if the map key was\n    // already present.\n    bool InsertMapKeyIfNotPresent(StringPiece map_key);\n\n    bool is_placeholder() const { return is_placeholder_; }\n    bool is_list() const { return is_list_; }\n\n   private:\n    // Used for access to variables of the enclosing instance of\n    // ProtoStreamObjectWriter.\n    ProtoStreamObjectWriter* ow_;\n\n    // A writer for Any objects, handles all Any-related nonsense.\n    google::protobuf::scoped_ptr<AnyWriter> any_;\n\n    // The type of this element, see enum for permissible types.\n    ItemType item_type_;\n\n    // Set of map keys already seen for the type_. Used to validate incoming\n    // messages so no map key appears more than once.\n    google::protobuf::scoped_ptr<hash_set<string> > map_keys_;\n\n    // Conveys whether this Item is a placeholder or not. Placeholder items are\n    // pushed to stack to account for special types.\n    bool is_placeholder_;\n\n    // Conveys whether this Item is a list or not. This is used to send\n    // StartList or EndList calls to underlying ObjectWriter.\n    bool is_list_;\n\n    GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(Item);\n  };\n\n  ProtoStreamObjectWriter(const TypeInfo* typeinfo,\n                          const google::protobuf::Type& type,\n                          strings::ByteSink* output, ErrorListener* listener);\n\n  // Returns true if the field is a map.\n  inline bool IsMap(const google::protobuf::Field& field);\n\n  // Returns true if the field is an any.\n  inline bool IsAny(const google::protobuf::Field& field);\n\n  // Returns true if the field is google.protobuf.Struct.\n  inline bool IsStruct(const google::protobuf::Field& field);\n\n  // Returns true if the field is google.protobuf.Value.\n  inline bool IsStructValue(const google::protobuf::Field& field);\n\n  // Returns true if the field is google.protobuf.ListValue.\n  inline bool IsStructListValue(const google::protobuf::Field& field);\n\n  // Renders google.protobuf.Value in struct.proto. It picks the right oneof\n  // type based on value's type.\n  static util::Status RenderStructValue(ProtoStreamObjectWriter* ow,\n                                          const DataPiece& value);\n\n  // Renders google.protobuf.Timestamp value.\n  static util::Status RenderTimestamp(ProtoStreamObjectWriter* ow,\n                                        const DataPiece& value);\n\n  // Renders google.protobuf.FieldMask value.\n  static util::Status RenderFieldMask(ProtoStreamObjectWriter* ow,\n                                        const DataPiece& value);\n\n  // Renders google.protobuf.Duration value.\n  static util::Status RenderDuration(ProtoStreamObjectWriter* ow,\n                                       const DataPiece& value);\n\n  // Renders wrapper message types for primitive types in\n  // google/protobuf/wrappers.proto.\n  static util::Status RenderWrapperType(ProtoStreamObjectWriter* ow,\n                                          const DataPiece& value);\n\n  static void InitRendererMap();\n  static void DeleteRendererMap();\n  static TypeRenderer* FindTypeRenderer(const string& type_url);\n\n  // Returns true if the map key for type_ is not duplicated key.\n  // If map key is duplicated key, this function returns false.\n  // Note that caller should make sure that the current proto element (current_)\n  // is of element type MAP or STRUCT_MAP.\n  // It also calls the appropriate error callback and unnormalzied_name is used\n  // for error string.\n  bool ValidMapKey(StringPiece unnormalized_name);\n\n  // Pushes an item on to the stack. Also calls either StartObject or StartList\n  // on the underlying ObjectWriter depending on whether is_list is false or\n  // not.\n  // is_placeholder conveys whether the item is a placeholder item or not.\n  // Placeholder items are pushed when adding auxillary types' StartObject or\n  // StartList calls.\n  void Push(StringPiece name, Item::ItemType item_type, bool is_placeholder,\n            bool is_list);\n\n  // Pops items from the stack. All placeholder items are popped until a\n  // non-placeholder item is found.\n  void Pop();\n\n  // Pops one element from the stack. Calls EndObject() or EndList() on the\n  // underlying ObjectWriter depending on the value of is_list_.\n  void PopOneElement();\n\n private:\n  // Helper functions to create the map and find functions responsible for\n  // rendering well known types, keyed by type URL.\n  static hash_map<string, TypeRenderer>* renderers_;\n\n  // Variables for describing the structure of the input tree:\n  // master_type_: descriptor for the whole protobuf message.\n  const google::protobuf::Type& master_type_;\n\n  // The current element, variable for internal state processing.\n  google::protobuf::scoped_ptr<Item> current_;\n\n  // Reference to the options that control this class's behavior.\n  const ProtoStreamObjectWriter::Options options_;\n\n  GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(ProtoStreamObjectWriter);\n};\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTWRITER_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/protostream_objectwriter_test.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/internal/protostream_objectwriter.h>\n\n#include <stddef.h>  // For size_t\n\n#include <google/protobuf/field_mask.pb.h>\n#include <google/protobuf/timestamp.pb.h>\n#include <google/protobuf/wrappers.pb.h>\n#include <google/protobuf/io/zero_copy_stream_impl_lite.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/dynamic_message.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/util/internal/mock_error_listener.h>\n#include <google/protobuf/util/internal/testdata/books.pb.h>\n#include <google/protobuf/util/internal/testdata/field_mask.pb.h>\n#include <google/protobuf/util/internal/type_info_test_helper.h>\n#include <google/protobuf/util/internal/constants.h>\n#include <google/protobuf/util/message_differencer.h>\n#include <google/protobuf/stubs/bytestream.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/util/internal/testdata/anys.pb.h>\n#include <google/protobuf/util/internal/testdata/maps.pb.h>\n#include <google/protobuf/util/internal/testdata/oneofs.pb.h>\n#include <google/protobuf/util/internal/testdata/struct.pb.h>\n#include <google/protobuf/util/internal/testdata/timestamp_duration.pb.h>\n#include <gtest/gtest.h>\n\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\nusing google::protobuf::testing::Author;\nusing google::protobuf::testing::Book;\nusing google::protobuf::testing::Book_Data;\nusing google::protobuf::testing::Primitive;\nusing google::protobuf::testing::Publisher;\nusing google::protobuf::Descriptor;\nusing google::protobuf::DescriptorPool;\nusing google::protobuf::DynamicMessageFactory;\nusing google::protobuf::FileDescriptorProto;\nusing google::protobuf::Message;\nusing google::protobuf::io::ArrayInputStream;\nusing strings::GrowingArrayByteSink;\nusing ::testing::_;\nusing ::testing::Args;\nusing google::protobuf::testing::anys::AnyM;\nusing google::protobuf::testing::anys::AnyOut;\nusing google::protobuf::testing::oneofs::OneOfsRequest;\nusing google::protobuf::testing::FieldMaskTest;\nusing google::protobuf::testing::maps::MapIn;\nusing google::protobuf::testing::structs::StructType;\nusing google::protobuf::testing::timestampduration::TimestampDuration;\n\n\nnamespace {\nstring GetTypeUrl(const Descriptor* descriptor) {\n  return string(kTypeServiceBaseUrl) + \"/\" + descriptor->full_name();\n}\n}  // namespace\n\n#if __cplusplus >= 201103L\n  using std::get;\n#else\n  using std::tr1::get;\n#endif\n\nclass BaseProtoStreamObjectWriterTest\n    : public ::testing::TestWithParam<testing::TypeInfoSource> {\n protected:\n  BaseProtoStreamObjectWriterTest()\n      : helper_(GetParam()),\n        listener_(),\n        output_(new GrowingArrayByteSink(1000)),\n        ow_() {}\n\n  explicit BaseProtoStreamObjectWriterTest(const Descriptor* descriptor)\n      : helper_(GetParam()),\n        listener_(),\n        output_(new GrowingArrayByteSink(1000)),\n        ow_() {\n    vector<const Descriptor*> descriptors;\n    descriptors.push_back(descriptor);\n    ResetTypeInfo(descriptors);\n  }\n\n  explicit BaseProtoStreamObjectWriterTest(\n      vector<const Descriptor*> descriptors)\n      : helper_(GetParam()),\n        listener_(),\n        output_(new GrowingArrayByteSink(1000)),\n        ow_() {\n    ResetTypeInfo(descriptors);\n  }\n\n  void ResetTypeInfo(vector<const Descriptor*> descriptors) {\n    GOOGLE_CHECK(!descriptors.empty()) << \"Must have at least one descriptor!\";\n    helper_.ResetTypeInfo(descriptors);\n    ow_.reset(helper_.NewProtoWriter(GetTypeUrl(descriptors[0]), output_.get(),\n                                     &listener_, options_));\n  }\n\n  void ResetTypeInfo(const Descriptor* descriptor) {\n    vector<const Descriptor*> descriptors;\n    descriptors.push_back(descriptor);\n    ResetTypeInfo(descriptors);\n  }\n\n  virtual ~BaseProtoStreamObjectWriterTest() {}\n\n  void CheckOutput(const Message& expected, int expected_length) {\n    size_t nbytes;\n    google::protobuf::scoped_array<char> buffer(output_->GetBuffer(&nbytes));\n    if (expected_length >= 0) {\n      EXPECT_EQ(expected_length, nbytes);\n    }\n    string str(buffer.get(), nbytes);\n\n    std::stringbuf str_buf(str, std::ios_base::in);\n    std::istream istream(&str_buf);\n    google::protobuf::scoped_ptr<Message> message(expected.New());\n    message->ParsePartialFromIstream(&istream);\n\n    if (!MessageDifferencer::Equivalent(expected, *message)) {\n      EXPECT_EQ(expected.DebugString(), message->DebugString());\n    }\n  }\n\n  void CheckOutput(const Message& expected) { CheckOutput(expected, -1); }\n\n  const google::protobuf::Type* GetType(const Descriptor* descriptor) {\n    return helper_.GetTypeInfo()->GetTypeByTypeUrl(GetTypeUrl(descriptor));\n  }\n\n  testing::TypeInfoTestHelper helper_;\n  MockErrorListener listener_;\n  google::protobuf::scoped_ptr<GrowingArrayByteSink> output_;\n  google::protobuf::scoped_ptr<ProtoStreamObjectWriter> ow_;\n  ProtoStreamObjectWriter::Options options_;\n};\n\nMATCHER_P(HasObjectLocation, expected,\n          \"Verifies the expected object location\") {\n  string actual = get<0>(arg).ToString();\n  if (actual.compare(expected) == 0) return true;\n  *result_listener << \"actual location is: \" << actual;\n  return false;\n}\n\nclass ProtoStreamObjectWriterTest : public BaseProtoStreamObjectWriterTest {\n protected:\n  ProtoStreamObjectWriterTest()\n      : BaseProtoStreamObjectWriterTest(Book::descriptor()) {}\n\n  void ResetProtoWriter() {\n    ResetTypeInfo(Book::descriptor());\n  }\n\n  virtual ~ProtoStreamObjectWriterTest() {}\n};\n\nINSTANTIATE_TEST_CASE_P(DifferentTypeInfoSourceTest,\n                        ProtoStreamObjectWriterTest,\n                        ::testing::Values(\n                            testing::USE_TYPE_RESOLVER));\n\nTEST_P(ProtoStreamObjectWriterTest, EmptyObject) {\n  Book empty;\n  ow_->StartObject(\"\")->EndObject();\n  CheckOutput(empty, 0);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, SimpleObject) {\n  string content(\"My content\");\n\n  Book book;\n  book.set_title(\"My Title\");\n  book.set_length(222);\n  book.set_content(content);\n\n  ow_->StartObject(\"\")\n      ->RenderString(\"title\", \"My Title\")\n      ->RenderInt32(\"length\", 222)\n      ->RenderBytes(\"content\", content)\n      ->EndObject();\n  CheckOutput(book);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, SimpleMessage) {\n  Book book;\n  book.set_title(\"Some Book\");\n  book.set_length(102);\n  Publisher* publisher = book.mutable_publisher();\n  publisher->set_name(\"My Publisher\");\n  Author* robert = book.mutable_author();\n  robert->set_alive(true);\n  robert->set_name(\"robert\");\n  robert->add_pseudonym(\"bob\");\n  robert->add_pseudonym(\"bobby\");\n  robert->add_friend_()->set_name(\"john\");\n\n  ow_->StartObject(\"\")\n      ->RenderString(\"title\", \"Some Book\")\n      ->RenderInt32(\"length\", 102)\n      ->StartObject(\"publisher\")\n      ->RenderString(\"name\", \"My Publisher\")\n      ->EndObject()\n      ->StartObject(\"author\")\n      ->RenderBool(\"alive\", true)\n      ->RenderString(\"name\", \"robert\")\n      ->StartList(\"pseudonym\")\n      ->RenderString(\"\", \"bob\")\n      ->RenderString(\"\", \"bobby\")\n      ->EndList()\n      ->StartList(\"friend\")\n      ->StartObject(\"\")\n      ->RenderString(\"name\", \"john\")\n      ->EndObject()\n      ->EndList()\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(book);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, CustomJsonName) {\n  Book book;\n  Author* robert = book.mutable_author();\n  robert->set_id(12345);\n  robert->set_name(\"robert\");\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"author\")\n      ->RenderUint64(\"@id\", 12345)\n      ->RenderString(\"name\", \"robert\")\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(book);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, PrimitiveFromStringConversion) {\n  Primitive full;\n  full.set_fix32(101);\n  full.set_u32(102);\n  full.set_i32(-103);\n  full.set_sf32(-104);\n  full.set_s32(-105);\n  full.set_fix64(40000000001L);\n  full.set_u64(40000000002L);\n  full.set_i64(-40000000003L);\n  full.set_sf64(-40000000004L);\n  full.set_s64(-40000000005L);\n  full.set_str(\"string1\");\n  full.set_bytes(\"Some Bytes\");\n  full.set_float_(3.14f);\n  full.set_double_(-4.05L);\n  full.set_bool_(true);\n  full.add_rep_fix32(201);\n  full.add_rep_u32(202);\n  full.add_rep_i32(-203);\n  full.add_rep_sf32(-204);\n  full.add_rep_s32(-205);\n  full.add_rep_fix64(80000000001L);\n  full.add_rep_u64(80000000002L);\n  full.add_rep_i64(-80000000003L);\n  full.add_rep_sf64(-80000000004L);\n  full.add_rep_s64(-80000000005L);\n  full.add_rep_str(\"string2\");\n  full.add_rep_bytes(\"More Bytes\");\n  full.add_rep_float(6.14f);\n  full.add_rep_double(-8.05L);\n  full.add_rep_bool(false);\n\n  ResetTypeInfo(Primitive::descriptor());\n\n  ow_->StartObject(\"\")\n      ->RenderString(\"fix32\", \"101\")\n      ->RenderString(\"u32\", \"102\")\n      ->RenderString(\"i32\", \"-103\")\n      ->RenderString(\"sf32\", \"-104\")\n      ->RenderString(\"s32\", \"-105\")\n      ->RenderString(\"fix64\", \"40000000001\")\n      ->RenderString(\"u64\", \"40000000002\")\n      ->RenderString(\"i64\", \"-40000000003\")\n      ->RenderString(\"sf64\", \"-40000000004\")\n      ->RenderString(\"s64\", \"-40000000005\")\n      ->RenderString(\"str\", \"string1\")\n      ->RenderString(\"bytes\", \"U29tZSBCeXRlcw==\")  // \"Some Bytes\"\n      ->RenderString(\"float\", \"3.14\")\n      ->RenderString(\"double\", \"-4.05\")\n      ->RenderString(\"bool\", \"true\")\n      ->StartList(\"rep_fix32\")\n      ->RenderString(\"\", \"201\")\n      ->EndList()\n      ->StartList(\"rep_u32\")\n      ->RenderString(\"\", \"202\")\n      ->EndList()\n      ->StartList(\"rep_i32\")\n      ->RenderString(\"\", \"-203\")\n      ->EndList()\n      ->StartList(\"rep_sf32\")\n      ->RenderString(\"\", \"-204\")\n      ->EndList()\n      ->StartList(\"rep_s32\")\n      ->RenderString(\"\", \"-205\")\n      ->EndList()\n      ->StartList(\"rep_fix64\")\n      ->RenderString(\"\", \"80000000001\")\n      ->EndList()\n      ->StartList(\"rep_u64\")\n      ->RenderString(\"\", \"80000000002\")\n      ->EndList()\n      ->StartList(\"rep_i64\")\n      ->RenderString(\"\", \"-80000000003\")\n      ->EndList()\n      ->StartList(\"rep_sf64\")\n      ->RenderString(\"\", \"-80000000004\")\n      ->EndList()\n      ->StartList(\"rep_s64\")\n      ->RenderString(\"\", \"-80000000005\")\n      ->EndList()\n      ->StartList(\"rep_str\")\n      ->RenderString(\"\", \"string2\")\n      ->EndList()\n      ->StartList(\"rep_bytes\")\n      ->RenderString(\"\", \"TW9yZSBCeXRlcw==\")  // \"More Bytes\"\n      ->EndList()\n      ->StartList(\"rep_float\")\n      ->RenderString(\"\", \"6.14\")\n      ->EndList()\n      ->StartList(\"rep_double\")\n      ->RenderString(\"\", \"-8.05\")\n      ->EndList()\n      ->StartList(\"rep_bool\")\n      ->RenderString(\"\", \"false\")\n      ->EndList()\n      ->EndObject();\n  CheckOutput(full);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, InfinityInputTest) {\n  Primitive full;\n  full.set_double_(std::numeric_limits<double>::infinity());\n  full.set_float_(std::numeric_limits<float>::infinity());\n  full.set_str(\"-Infinity\");\n\n  ResetTypeInfo(Primitive::descriptor());\n\n  EXPECT_CALL(listener_, InvalidValue(_, StringPiece(\"TYPE_INT32\"),\n                                      StringPiece(\"\\\"Infinity\\\"\")))\n      .With(Args<0>(HasObjectLocation(\"i32\")));\n  EXPECT_CALL(listener_, InvalidValue(_, StringPiece(\"TYPE_UINT32\"),\n                                      StringPiece(\"\\\"Infinity\\\"\")))\n      .With(Args<0>(HasObjectLocation(\"u32\")));\n  EXPECT_CALL(listener_, InvalidValue(_, StringPiece(\"TYPE_SFIXED64\"),\n                                      StringPiece(\"\\\"-Infinity\\\"\")))\n      .With(Args<0>(HasObjectLocation(\"sf64\")));\n  EXPECT_CALL(listener_, InvalidValue(_, StringPiece(\"TYPE_BOOL\"),\n                                      StringPiece(\"\\\"Infinity\\\"\")))\n      .With(Args<0>(HasObjectLocation(\"bool\")));\n\n  ow_->StartObject(\"\")\n      ->RenderString(\"double\", \"Infinity\")\n      ->RenderString(\"float\", \"Infinity\")\n      ->RenderString(\"i32\", \"Infinity\")\n      ->RenderString(\"u32\", \"Infinity\")\n      ->RenderString(\"sf64\", \"-Infinity\")\n      ->RenderString(\"str\", \"-Infinity\")\n      ->RenderString(\"bool\", \"Infinity\")\n      ->EndObject();\n  CheckOutput(full);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, NaNInputTest) {\n  Primitive full;\n  full.set_double_(std::numeric_limits<double>::quiet_NaN());\n  full.set_float_(std::numeric_limits<float>::quiet_NaN());\n  full.set_str(\"NaN\");\n\n  ResetTypeInfo(Primitive::descriptor());\n\n  EXPECT_CALL(listener_, InvalidValue(_, StringPiece(\"TYPE_INT32\"),\n                                      StringPiece(\"\\\"NaN\\\"\")))\n      .With(Args<0>(HasObjectLocation(\"i32\")));\n  EXPECT_CALL(listener_, InvalidValue(_, StringPiece(\"TYPE_UINT32\"),\n                                      StringPiece(\"\\\"NaN\\\"\")))\n      .With(Args<0>(HasObjectLocation(\"u32\")));\n  EXPECT_CALL(listener_, InvalidValue(_, StringPiece(\"TYPE_SFIXED64\"),\n                                      StringPiece(\"\\\"NaN\\\"\")))\n      .With(Args<0>(HasObjectLocation(\"sf64\")));\n  EXPECT_CALL(listener_,\n              InvalidValue(_, StringPiece(\"TYPE_BOOL\"), StringPiece(\"\\\"NaN\\\"\")))\n      .With(Args<0>(HasObjectLocation(\"bool\")));\n\n  ow_->StartObject(\"\")\n      ->RenderString(\"double\", \"NaN\")\n      ->RenderString(\"float\", \"NaN\")\n      ->RenderString(\"i32\", \"NaN\")\n      ->RenderString(\"u32\", \"NaN\")\n      ->RenderString(\"sf64\", \"NaN\")\n      ->RenderString(\"str\", \"NaN\")\n      ->RenderString(\"bool\", \"NaN\")\n      ->EndObject();\n\n  CheckOutput(full);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, ImplicitPrimitiveList) {\n  Book expected;\n  Author* author = expected.mutable_author();\n  author->set_name(\"The Author\");\n  author->add_pseudonym(\"first\");\n  author->add_pseudonym(\"second\");\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"author\")\n      ->RenderString(\"name\", \"The Author\")\n      ->RenderString(\"pseudonym\", \"first\")\n      ->RenderString(\"pseudonym\", \"second\")\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterTest,\n       LastWriteWinsOnNonRepeatedPrimitiveFieldWithDuplicates) {\n  Book expected;\n  Author* author = expected.mutable_author();\n  author->set_name(\"second\");\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"author\")\n      ->RenderString(\"name\", \"first\")\n      ->RenderString(\"name\", \"second\")\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, ExplicitPrimitiveList) {\n  Book expected;\n  Author* author = expected.mutable_author();\n  author->set_name(\"The Author\");\n  author->add_pseudonym(\"first\");\n  author->add_pseudonym(\"second\");\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"author\")\n      ->RenderString(\"name\", \"The Author\")\n      ->StartList(\"pseudonym\")\n      ->RenderString(\"\", \"first\")\n      ->RenderString(\"\", \"second\")\n      ->EndList()\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, NonRepeatedExplicitPrimitiveList) {\n  Book expected;\n  expected.set_allocated_author(new Author());\n\n  EXPECT_CALL(\n      listener_,\n      InvalidName(\n          _, StringPiece(\"name\"),\n          StringPiece(\"Proto field is not repeating, cannot start list.\")))\n      .With(Args<0>(HasObjectLocation(\"author\")));\n  ow_->StartObject(\"\")\n      ->StartObject(\"author\")\n      ->StartList(\"name\")\n      ->RenderString(\"\", \"first\")\n      ->RenderString(\"\", \"second\")\n      ->EndList()\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, ImplicitMessageList) {\n  Book expected;\n  Author* outer = expected.mutable_author();\n  outer->set_name(\"outer\");\n  outer->set_alive(true);\n  Author* first = outer->add_friend_();\n  first->set_name(\"first\");\n  Author* second = outer->add_friend_();\n  second->set_name(\"second\");\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"author\")\n      ->RenderString(\"name\", \"outer\")\n      ->RenderBool(\"alive\", true)\n      ->StartObject(\"friend\")\n      ->RenderString(\"name\", \"first\")\n      ->EndObject()\n      ->StartObject(\"friend\")\n      ->RenderString(\"name\", \"second\")\n      ->EndObject()\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterTest,\n       LastWriteWinsOnNonRepeatedMessageFieldWithDuplicates) {\n  Book expected;\n  Author* author = expected.mutable_author();\n  author->set_name(\"The Author\");\n  Publisher* publisher = expected.mutable_publisher();\n  publisher->set_name(\"second\");\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"author\")\n      ->RenderString(\"name\", \"The Author\")\n      ->EndObject()\n      ->StartObject(\"publisher\")\n      ->RenderString(\"name\", \"first\")\n      ->EndObject()\n      ->StartObject(\"publisher\")\n      ->RenderString(\"name\", \"second\")\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, ExplicitMessageList) {\n  Book expected;\n  Author* outer = expected.mutable_author();\n  outer->set_name(\"outer\");\n  outer->set_alive(true);\n  Author* first = outer->add_friend_();\n  first->set_name(\"first\");\n  Author* second = outer->add_friend_();\n  second->set_name(\"second\");\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"author\")\n      ->RenderString(\"name\", \"outer\")\n      ->RenderBool(\"alive\", true)\n      ->StartList(\"friend\")\n      ->StartObject(\"\")\n      ->RenderString(\"name\", \"first\")\n      ->EndObject()\n      ->StartObject(\"\")\n      ->RenderString(\"name\", \"second\")\n      ->EndObject()\n      ->EndList()\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, NonRepeatedExplicitMessageList) {\n  Book expected;\n  Author* author = expected.mutable_author();\n  author->set_name(\"The Author\");\n\n  EXPECT_CALL(\n      listener_,\n      InvalidName(\n          _, StringPiece(\"publisher\"),\n          StringPiece(\"Proto field is not repeating, cannot start list.\")))\n      .With(Args<0>(HasObjectLocation(\"\")));\n  ow_->StartObject(\"\")\n      ->StartObject(\"author\")\n      ->RenderString(\"name\", \"The Author\")\n      ->EndObject()\n      ->StartList(\"publisher\")\n      ->StartObject(\"\")\n      ->RenderString(\"name\", \"first\")\n      ->EndObject()\n      ->StartObject(\"\")\n      ->RenderString(\"name\", \"second\")\n      ->EndObject()\n      ->EndList()\n      ->EndObject();\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, UnknownFieldAtRoot) {\n  Book empty;\n\n  EXPECT_CALL(listener_, InvalidName(_, StringPiece(\"unknown\"),\n                                     StringPiece(\"Cannot find field.\")))\n      .With(Args<0>(HasObjectLocation(\"\")));\n  ow_->StartObject(\"\")->RenderString(\"unknown\", \"Nope!\")->EndObject();\n  CheckOutput(empty, 0);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, UnknownFieldAtAuthorFriend) {\n  Book expected;\n  Author* paul = expected.mutable_author();\n  paul->set_name(\"Paul\");\n  Author* mark = paul->add_friend_();\n  mark->set_name(\"Mark\");\n  Author* john = paul->add_friend_();\n  john->set_name(\"John\");\n  Author* luke = paul->add_friend_();\n  luke->set_name(\"Luke\");\n\n  EXPECT_CALL(listener_, InvalidName(_, StringPiece(\"address\"),\n                                     StringPiece(\"Cannot find field.\")))\n      .With(Args<0>(HasObjectLocation(\"author.friend[1]\")));\n  ow_->StartObject(\"\")\n      ->StartObject(\"author\")\n      ->RenderString(\"name\", \"Paul\")\n      ->StartList(\"friend\")\n      ->StartObject(\"\")\n      ->RenderString(\"name\", \"Mark\")\n      ->EndObject()\n      ->StartObject(\"\")\n      ->RenderString(\"name\", \"John\")\n      ->RenderString(\"address\", \"Patmos\")\n      ->EndObject()\n      ->StartObject(\"\")\n      ->RenderString(\"name\", \"Luke\")\n      ->EndObject()\n      ->EndList()\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, UnknownObjectAtRoot) {\n  Book empty;\n\n  EXPECT_CALL(listener_, InvalidName(_, StringPiece(\"unknown\"),\n                                     StringPiece(\"Cannot find field.\")))\n      .With(Args<0>(HasObjectLocation(\"\")));\n  ow_->StartObject(\"\")->StartObject(\"unknown\")->EndObject()->EndObject();\n  CheckOutput(empty, 0);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, UnknownObjectAtAuthor) {\n  Book expected;\n  Author* author = expected.mutable_author();\n  author->set_name(\"William\");\n  author->add_pseudonym(\"Bill\");\n\n  EXPECT_CALL(listener_, InvalidName(_, StringPiece(\"wife\"),\n                                     StringPiece(\"Cannot find field.\")))\n      .With(Args<0>(HasObjectLocation(\"author\")));\n  ow_->StartObject(\"\")\n      ->StartObject(\"author\")\n      ->RenderString(\"name\", \"William\")\n      ->StartObject(\"wife\")\n      ->RenderString(\"name\", \"Hilary\")\n      ->EndObject()\n      ->RenderString(\"pseudonym\", \"Bill\")\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, UnknownListAtRoot) {\n  Book empty;\n\n  EXPECT_CALL(listener_, InvalidName(_, StringPiece(\"unknown\"),\n                                     StringPiece(\"Cannot find field.\")))\n      .With(Args<0>(HasObjectLocation(\"\")));\n  ow_->StartObject(\"\")->StartList(\"unknown\")->EndList()->EndObject();\n  CheckOutput(empty, 0);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, UnknownListAtPublisher) {\n  Book expected;\n  expected.set_title(\"Brainwashing\");\n  Publisher* publisher = expected.mutable_publisher();\n  publisher->set_name(\"propaganda\");\n\n  EXPECT_CALL(listener_, InvalidName(_, StringPiece(\"alliance\"),\n                                     StringPiece(\"Cannot find field.\")))\n      .With(Args<0>(HasObjectLocation(\"publisher\")));\n  ow_->StartObject(\"\")\n      ->StartObject(\"publisher\")\n      ->RenderString(\"name\", \"propaganda\")\n      ->StartList(\"alliance\")\n      ->EndList()\n      ->EndObject()\n      ->RenderString(\"title\", \"Brainwashing\")\n      ->EndObject();\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, IgnoreUnknownFieldAtRoot) {\n  Book empty;\n\n  options_.ignore_unknown_fields = true;\n  ResetProtoWriter();\n\n  EXPECT_CALL(listener_, InvalidName(_, _, _)).Times(0);\n  ow_->StartObject(\"\")->RenderString(\"unknown\", \"Nope!\")->EndObject();\n  CheckOutput(empty, 0);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, IgnoreUnknownFieldAtAuthorFriend) {\n  Book expected;\n  Author* paul = expected.mutable_author();\n  paul->set_name(\"Paul\");\n  Author* mark = paul->add_friend_();\n  mark->set_name(\"Mark\");\n  Author* john = paul->add_friend_();\n  john->set_name(\"John\");\n  Author* luke = paul->add_friend_();\n  luke->set_name(\"Luke\");\n\n  options_.ignore_unknown_fields = true;\n  ResetProtoWriter();\n\n  EXPECT_CALL(listener_, InvalidName(_, _, _)).Times(0);\n  ow_->StartObject(\"\")\n      ->StartObject(\"author\")\n      ->RenderString(\"name\", \"Paul\")\n      ->StartList(\"friend\")\n      ->StartObject(\"\")\n      ->RenderString(\"name\", \"Mark\")\n      ->EndObject()\n      ->StartObject(\"\")\n      ->RenderString(\"name\", \"John\")\n      ->RenderString(\"address\", \"Patmos\")\n      ->EndObject()\n      ->StartObject(\"\")\n      ->RenderString(\"name\", \"Luke\")\n      ->EndObject()\n      ->EndList()\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, IgnoreUnknownObjectAtRoot) {\n  Book empty;\n\n  options_.ignore_unknown_fields = true;\n  ResetProtoWriter();\n\n  EXPECT_CALL(listener_, InvalidName(_, StringPiece(\"unknown\"),\n                                     StringPiece(\"Cannot find field.\")))\n      .Times(0);\n  ow_->StartObject(\"\")->StartObject(\"unknown\")->EndObject()->EndObject();\n  CheckOutput(empty, 0);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, IgnoreUnknownObjectAtAuthor) {\n  Book expected;\n  Author* author = expected.mutable_author();\n  author->set_name(\"William\");\n  author->add_pseudonym(\"Bill\");\n\n  options_.ignore_unknown_fields = true;\n  ResetProtoWriter();\n\n  EXPECT_CALL(listener_, InvalidName(_, _, _)).Times(0);\n  ow_->StartObject(\"\")\n      ->StartObject(\"author\")\n      ->RenderString(\"name\", \"William\")\n      ->StartObject(\"wife\")\n      ->RenderString(\"name\", \"Hilary\")\n      ->EndObject()\n      ->RenderString(\"pseudonym\", \"Bill\")\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, IgnoreUnknownListAtRoot) {\n  Book empty;\n\n  options_.ignore_unknown_fields = true;\n  ResetProtoWriter();\n\n  EXPECT_CALL(listener_, InvalidName(_, _, _)).Times(0);\n  ow_->StartObject(\"\")->StartList(\"unknown\")->EndList()->EndObject();\n  CheckOutput(empty, 0);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, IgnoreUnknownListAtPublisher) {\n  Book expected;\n  expected.set_title(\"Brainwashing\");\n  Publisher* publisher = expected.mutable_publisher();\n  publisher->set_name(\"propaganda\");\n\n  options_.ignore_unknown_fields = true;\n  ResetProtoWriter();\n\n  EXPECT_CALL(listener_, InvalidName(_, _, _)).Times(0);\n  ow_->StartObject(\"\")\n      ->StartObject(\"publisher\")\n      ->RenderString(\"name\", \"propaganda\")\n      ->StartList(\"alliance\")\n      ->EndList()\n      ->EndObject()\n      ->RenderString(\"title\", \"Brainwashing\")\n      ->EndObject();\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, MissingRequiredField) {\n  Book expected;\n  expected.set_title(\"My Title\");\n  expected.set_allocated_publisher(new Publisher());\n\n  EXPECT_CALL(listener_, MissingField(_, StringPiece(\"name\")))\n      .With(Args<0>(HasObjectLocation(\"publisher\")));\n  ow_->StartObject(\"\")\n      ->StartObject(\"publisher\")\n      ->EndObject()\n      ->RenderString(\"title\", \"My Title\")\n      ->EndObject();\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, InvalidFieldValueAtRoot) {\n  Book empty;\n\n  EXPECT_CALL(listener_, InvalidValue(_, StringPiece(\"TYPE_UINT32\"),\n                                      StringPiece(\"\\\"garbage\\\"\")))\n      .With(Args<0>(HasObjectLocation(\"length\")));\n  ow_->StartObject(\"\")->RenderString(\"length\", \"garbage\")->EndObject();\n  CheckOutput(empty, 0);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, MultipleInvalidFieldValues) {\n  Book expected;\n  expected.set_title(\"My Title\");\n\n  EXPECT_CALL(listener_, InvalidValue(_, StringPiece(\"TYPE_UINT32\"),\n                                      StringPiece(\"\\\"-400\\\"\")))\n      .With(Args<0>(HasObjectLocation(\"length\")));\n  EXPECT_CALL(listener_, InvalidValue(_, StringPiece(\"TYPE_INT64\"),\n                                      StringPiece(\"\\\"3.14\\\"\")))\n      .With(Args<0>(HasObjectLocation(\"published\")));\n  ow_->StartObject(\"\")\n      ->RenderString(\"length\", \"-400\")\n      ->RenderString(\"published\", \"3.14\")\n      ->RenderString(\"title\", \"My Title\")\n      ->EndObject();\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, UnnamedFieldAtRoot) {\n  Book empty;\n\n  EXPECT_CALL(listener_,\n              InvalidName(_, StringPiece(\"\"),\n                          StringPiece(\"Proto fields must have a name.\")))\n      .With(Args<0>(HasObjectLocation(\"\")));\n  ow_->StartObject(\"\")->RenderFloat(\"\", 3.14)->EndObject();\n  CheckOutput(empty, 0);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, UnnamedFieldAtAuthor) {\n  Book expected;\n  expected.set_title(\"noname\");\n  expected.set_allocated_author(new Author());\n\n  EXPECT_CALL(listener_,\n              InvalidName(_, StringPiece(\"\"),\n                          StringPiece(\"Proto fields must have a name.\")))\n      .With(Args<0>(HasObjectLocation(\"author\")));\n  ow_->StartObject(\"\")\n      ->StartObject(\"author\")\n      ->RenderInt32(\"\", 123)\n      ->EndObject()\n      ->RenderString(\"title\", \"noname\")\n      ->EndObject();\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, UnnamedListAtRoot) {\n  Book expected;\n  expected.set_title(\"noname\");\n\n  EXPECT_CALL(listener_,\n              InvalidName(_, StringPiece(\"\"),\n                          StringPiece(\"Proto fields must have a name.\")))\n      .With(Args<0>(HasObjectLocation(\"\")));\n  ow_->StartObject(\"\")\n      ->StartList(\"\")\n      ->EndList()\n      ->RenderString(\"title\", \"noname\")\n      ->EndObject();\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, RootNamedObject) {\n  Book expected;\n  expected.set_title(\"Annie\");\n\n  EXPECT_CALL(listener_,\n              InvalidName(_, StringPiece(\"oops\"),\n                          StringPiece(\"Root element should not be named.\")))\n      .With(Args<0>(HasObjectLocation(\"\")));\n  ow_->StartObject(\"oops\")->RenderString(\"title\", \"Annie\")->EndObject();\n  CheckOutput(expected, 7);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, RootNamedList) {\n  Book empty;\n\n  EXPECT_CALL(listener_,\n              InvalidName(_, StringPiece(\"oops\"),\n                          StringPiece(\"Root element should not be named.\")))\n      .With(Args<0>(HasObjectLocation(\"\")));\n  ow_->StartList(\"oops\")->RenderString(\"\", \"item\")->EndList();\n  CheckOutput(empty, 0);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, RootUnnamedField) {\n  Book empty;\n\n  EXPECT_CALL(listener_,\n              InvalidName(_, StringPiece(\"\"),\n                          StringPiece(\"Root element must be a message.\")))\n      .With(Args<0>(HasObjectLocation(\"\")));\n  ow_->RenderBool(\"\", true);\n  CheckOutput(empty, 0);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, RootNamedField) {\n  Book empty;\n\n  EXPECT_CALL(listener_,\n              InvalidName(_, StringPiece(\"oops\"),\n                          StringPiece(\"Root element must be a message.\")))\n      .With(Args<0>(HasObjectLocation(\"\")));\n  ow_->RenderBool(\"oops\", true);\n  CheckOutput(empty, 0);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, NullValue) {\n  Book empty;\n\n  ow_->RenderNull(\"\");\n  CheckOutput(empty, 0);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, NullValueForMessageField) {\n  Book empty;\n\n  ow_->RenderNull(\"author\");\n  CheckOutput(empty, 0);\n}\n\nTEST_P(ProtoStreamObjectWriterTest, NullValueForPrimitiveField) {\n  Book empty;\n\n  ow_->RenderNull(\"length\");\n  CheckOutput(empty, 0);\n}\n\nclass ProtoStreamObjectWriterTimestampDurationTest\n    : public BaseProtoStreamObjectWriterTest {\n protected:\n  ProtoStreamObjectWriterTimestampDurationTest() {\n    vector<const Descriptor*> descriptors;\n    descriptors.push_back(TimestampDuration::descriptor());\n    descriptors.push_back(google::protobuf::Timestamp::descriptor());\n    descriptors.push_back(google::protobuf::Duration::descriptor());\n    ResetTypeInfo(descriptors);\n  }\n};\n\nINSTANTIATE_TEST_CASE_P(DifferentTypeInfoSourceTest,\n                        ProtoStreamObjectWriterTimestampDurationTest,\n                        ::testing::Values(\n                            testing::USE_TYPE_RESOLVER));\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest, ParseTimestamp) {\n  TimestampDuration timestamp;\n  google::protobuf::Timestamp* ts = timestamp.mutable_ts();\n  ts->set_seconds(1448249855);\n  ts->set_nanos(33155000);\n\n  ow_->StartObject(\"\")\n      ->RenderString(\"ts\", \"2015-11-23T03:37:35.033155Z\")\n      ->EndObject();\n  CheckOutput(timestamp);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest,\n       ParseTimestampYearNotZeroPadded) {\n  TimestampDuration timestamp;\n  google::protobuf::Timestamp* ts = timestamp.mutable_ts();\n  ts->set_seconds(-61665654145);\n  ts->set_nanos(33155000);\n\n  ow_->StartObject(\"\")\n      ->RenderString(\"ts\", \"15-11-23T03:37:35.033155Z\")\n      ->EndObject();\n  CheckOutput(timestamp);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest,\n       ParseTimestampYearZeroPadded) {\n  TimestampDuration timestamp;\n  google::protobuf::Timestamp* ts = timestamp.mutable_ts();\n  ts->set_seconds(-61665654145);\n  ts->set_nanos(33155000);\n\n  ow_->StartObject(\"\")\n      ->RenderString(\"ts\", \"0015-11-23T03:37:35.033155Z\")\n      ->EndObject();\n  CheckOutput(timestamp);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest,\n       ParseTimestampWithPositiveOffset) {\n  TimestampDuration timestamp;\n  google::protobuf::Timestamp* ts = timestamp.mutable_ts();\n  ts->set_seconds(1448249855);\n  ts->set_nanos(33155000);\n\n  ow_->StartObject(\"\")\n      ->RenderString(\"ts\", \"2015-11-23T11:47:35.033155+08:10\")\n      ->EndObject();\n  CheckOutput(timestamp);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest,\n       ParseTimestampWithNegativeOffset) {\n  TimestampDuration timestamp;\n  google::protobuf::Timestamp* ts = timestamp.mutable_ts();\n  ts->set_seconds(1448249855);\n  ts->set_nanos(33155000);\n\n  ow_->StartObject(\"\")\n      ->RenderString(\"ts\", \"2015-11-22T19:47:35.033155-07:50\")\n      ->EndObject();\n  CheckOutput(timestamp);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest,\n       TimestampWithInvalidOffset1) {\n  TimestampDuration timestamp;\n\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(_,\n                   StringPiece(\"type.googleapis.com/google.protobuf.Timestamp\"),\n                   StringPiece(\"Field 'ts', Invalid time format: \"\n                               \"2016-03-07T15:14:23+\")));\n\n  ow_->StartObject(\"\")->RenderString(\"ts\", \"2016-03-07T15:14:23+\")->EndObject();\n  CheckOutput(timestamp);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest,\n       TimestampWithInvalidOffset2) {\n  TimestampDuration timestamp;\n\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(_,\n                   StringPiece(\"type.googleapis.com/google.protobuf.Timestamp\"),\n                   StringPiece(\"Field 'ts', Invalid time format: \"\n                               \"2016-03-07T15:14:23+08-10\")));\n\n  ow_->StartObject(\"\")\n      ->RenderString(\"ts\", \"2016-03-07T15:14:23+08-10\")\n      ->EndObject();\n  CheckOutput(timestamp);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest,\n       TimestampWithInvalidOffset3) {\n  TimestampDuration timestamp;\n\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(_,\n                   StringPiece(\"type.googleapis.com/google.protobuf.Timestamp\"),\n                   StringPiece(\"Field 'ts', Invalid time format: \"\n                               \"2016-03-07T15:14:23+24:10\")));\n\n  ow_->StartObject(\"\")\n      ->RenderString(\"ts\", \"2016-03-07T15:14:23+24:10\")\n      ->EndObject();\n  CheckOutput(timestamp);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest,\n       TimestampWithInvalidOffset4) {\n  TimestampDuration timestamp;\n\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(_,\n                   StringPiece(\"type.googleapis.com/google.protobuf.Timestamp\"),\n                   StringPiece(\"Field 'ts', Invalid time format: \"\n                               \"2016-03-07T15:14:23+04:60\")));\n\n  ow_->StartObject(\"\")\n      ->RenderString(\"ts\", \"2016-03-07T15:14:23+04:60\")\n      ->EndObject();\n  CheckOutput(timestamp);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest, InvalidTimestampError1) {\n  TimestampDuration timestamp;\n\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(_,\n                   StringPiece(\"type.googleapis.com/google.protobuf.Timestamp\"),\n                   StringPiece(\"Field 'ts', Invalid time format: \")));\n\n  ow_->StartObject(\"\")->RenderString(\"ts\", \"\")->EndObject();\n  CheckOutput(timestamp);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest, InvalidTimestampError2) {\n  TimestampDuration timestamp;\n\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(_,\n                   StringPiece(\"type.googleapis.com/google.protobuf.Timestamp\"),\n                   StringPiece(\"Field 'ts', Invalid time format: Z\")));\n\n  ow_->StartObject(\"\")->RenderString(\"ts\", \"Z\")->EndObject();\n  CheckOutput(timestamp);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest, InvalidTimestampError3) {\n  TimestampDuration timestamp;\n\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(_,\n                   StringPiece(\"type.googleapis.com/google.protobuf.Timestamp\"),\n                   StringPiece(\"Field 'ts', Invalid time format: \"\n                               \"1970-01-01T00:00:00.ABZ\")));\n\n  ow_->StartObject(\"\")\n      ->RenderString(\"ts\", \"1970-01-01T00:00:00.ABZ\")\n      ->EndObject();\n  CheckOutput(timestamp);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest, InvalidTimestampError4) {\n  TimestampDuration timestamp;\n\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(_,\n                   StringPiece(\"type.googleapis.com/google.protobuf.Timestamp\"),\n                   StringPiece(\"Field 'ts', Invalid time format: \"\n                               \"-8031-10-18T00:00:00.000Z\")));\n\n  ow_->StartObject(\"\")\n      ->RenderString(\"ts\", \"-8031-10-18T00:00:00.000Z\")\n      ->EndObject();\n  CheckOutput(timestamp);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest, InvalidTimestampError5) {\n  TimestampDuration timestamp;\n\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(_,\n                   StringPiece(\"type.googleapis.com/google.protobuf.Timestamp\"),\n                   StringPiece(\"Field 'ts', Invalid time format: \"\n                               \"2015-11-23T03:37:35.033155   Z\")));\n\n  ow_->StartObject(\"\")\n      // Whitespace in the Timestamp nanos is not allowed.\n      ->RenderString(\"ts\", \"2015-11-23T03:37:35.033155   Z\")\n      ->EndObject();\n  CheckOutput(timestamp);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest, InvalidTimestampError6) {\n  TimestampDuration timestamp;\n\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(_,\n                   StringPiece(\"type.googleapis.com/google.protobuf.Timestamp\"),\n                   StringPiece(\"Field 'ts', Invalid time format: \"\n                               \"2015-11-23T03:37:35.033155 1234Z\")));\n\n  ow_->StartObject(\"\")\n      // Whitespace in the Timestamp nanos is not allowed.\n      ->RenderString(\"ts\", \"2015-11-23T03:37:35.033155 1234Z\")\n      ->EndObject();\n  CheckOutput(timestamp);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest, InvalidTimestampError7) {\n  TimestampDuration timestamp;\n\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(_,\n                   StringPiece(\"type.googleapis.com/google.protobuf.Timestamp\"),\n                   StringPiece(\"Field 'ts', Invalid time format: \"\n                               \"2015-11-23T03:37:35.033abc155Z\")));\n\n  ow_->StartObject(\"\")\n      // Non-numeric characters in the Timestamp nanos is not allowed.\n      ->RenderString(\"ts\", \"2015-11-23T03:37:35.033abc155Z\")\n      ->EndObject();\n  CheckOutput(timestamp);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest, InvalidTimestampError8) {\n  TimestampDuration timestamp;\n\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(_,\n                   StringPiece(\"type.googleapis.com/google.protobuf.Timestamp\"),\n                   StringPiece(\"Field 'ts', Invalid time format: \"\n                               \"0-12-31T23:59:59.000Z\")));\n\n  ow_->StartObject(\"\")\n      ->RenderString(\"ts\", \"0-12-31T23:59:59.000Z\")\n      ->EndObject();\n  CheckOutput(timestamp);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest, ParseDuration) {\n  TimestampDuration duration;\n  google::protobuf::Duration* dur = duration.mutable_dur();\n  dur->set_seconds(1448216930);\n  dur->set_nanos(132262000);\n\n  ow_->StartObject(\"\")->RenderString(\"dur\", \"1448216930.132262s\")->EndObject();\n  CheckOutput(duration);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest, InvalidDurationError1) {\n  TimestampDuration duration;\n\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(\n          _, StringPiece(\"type.googleapis.com/google.protobuf.Duration\"),\n          StringPiece(\"Field 'dur', Illegal duration format; duration must \"\n                      \"end with 's'\")));\n\n  ow_->StartObject(\"\")->RenderString(\"dur\", \"\")->EndObject();\n  CheckOutput(duration);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest, InvalidDurationError2) {\n  TimestampDuration duration;\n\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(\n          _, StringPiece(\"type.googleapis.com/google.protobuf.Duration\"),\n          StringPiece(\"Field 'dur', Invalid duration format, failed to parse \"\n                      \"seconds\")));\n\n  ow_->StartObject(\"\")->RenderString(\"dur\", \"s\")->EndObject();\n  CheckOutput(duration);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest, InvalidDurationError3) {\n  TimestampDuration duration;\n\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(\n          _, StringPiece(\"type.googleapis.com/google.protobuf.Duration\"),\n          StringPiece(\"Field 'dur', Invalid duration format, failed to \"\n                      \"parse nano seconds\")));\n\n  ow_->StartObject(\"\")->RenderString(\"dur\", \"123.DEFs\")->EndObject();\n  CheckOutput(duration);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest, InvalidDurationError4) {\n  TimestampDuration duration;\n\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(_,\n                   StringPiece(\"type.googleapis.com/google.protobuf.Duration\"),\n                   StringPiece(\"Field 'dur', Duration value exceeds limits\")));\n\n  ow_->StartObject(\"\")->RenderString(\"dur\", \"315576000002s\")->EndObject();\n  CheckOutput(duration);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest, InvalidDurationError5) {\n  TimestampDuration duration;\n\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(_,\n                   StringPiece(\"type.googleapis.com/google.protobuf.Duration\"),\n                   StringPiece(\"Field 'dur', Duration value exceeds limits\")));\n\n  ow_->StartObject(\"\")->RenderString(\"dur\", \"0.1000000001s\")->EndObject();\n  CheckOutput(duration);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest,\n       MismatchedTimestampTypeInput) {\n  TimestampDuration timestamp;\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(\n          _, StringPiece(\"type.googleapis.com/google.protobuf.Timestamp\"),\n          StringPiece(\n              \"Field 'ts', Invalid data type for timestamp, value is null\")))\n      .With(Args<0>(HasObjectLocation(\"ts\")));\n  ow_->StartObject(\"\")->RenderNull(\"ts\")->EndObject();\n  CheckOutput(timestamp);\n}\n\nTEST_P(ProtoStreamObjectWriterTimestampDurationTest,\n       MismatchedDurationTypeInput) {\n  TimestampDuration duration;\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(\n          _, StringPiece(\"type.googleapis.com/google.protobuf.Duration\"),\n          StringPiece(\n              \"Field 'dur', Invalid data type for duration, value is null\")))\n      .With(Args<0>(HasObjectLocation(\"dur\")));\n  ow_->StartObject(\"\")->RenderNull(\"dur\")->EndObject();\n  CheckOutput(duration);\n}\n\nclass ProtoStreamObjectWriterStructTest\n    : public BaseProtoStreamObjectWriterTest {\n protected:\n  ProtoStreamObjectWriterStructTest() { ResetProtoWriter(); }\n\n  // Resets ProtoWriter with current set of options and other state.\n  void ResetProtoWriter() {\n    vector<const Descriptor*> descriptors;\n    descriptors.push_back(StructType::descriptor());\n    descriptors.push_back(google::protobuf::Struct::descriptor());\n    ResetTypeInfo(descriptors);\n  }\n};\n\nINSTANTIATE_TEST_CASE_P(DifferentTypeInfoSourceTest,\n                        ProtoStreamObjectWriterStructTest,\n                        ::testing::Values(\n                            testing::USE_TYPE_RESOLVER));\n\n// TODO(skarvaje): Write tests for failure cases.\nTEST_P(ProtoStreamObjectWriterStructTest, StructRenderSuccess) {\n  StructType struct_type;\n  google::protobuf::Struct* s = struct_type.mutable_object();\n  s->mutable_fields()->operator[](\"k1\").set_number_value(123);\n  s->mutable_fields()->operator[](\"k2\").set_bool_value(true);\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"object\")\n      ->RenderDouble(\"k1\", 123)\n      ->RenderBool(\"k2\", true)\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(struct_type);\n}\n\nTEST_P(ProtoStreamObjectWriterStructTest, StructNullInputSuccess) {\n  StructType struct_type;\n  EXPECT_CALL(listener_,\n              InvalidName(_, StringPiece(\"\"),\n                          StringPiece(\"Proto fields must have a name.\")))\n      .With(Args<0>(HasObjectLocation(\"\")));\n  ow_->StartObject(\"\")->RenderNull(\"\")->EndObject();\n  CheckOutput(struct_type);\n}\n\nTEST_P(ProtoStreamObjectWriterStructTest, StructInvalidInputFailure) {\n  StructType struct_type;\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(_, StringPiece(\"type.googleapis.com/google.protobuf.Struct\"),\n                   StringPiece(\"true\")))\n      .With(Args<0>(HasObjectLocation(\"object\")));\n\n  ow_->StartObject(\"\")->RenderBool(\"object\", true)->EndObject();\n  CheckOutput(struct_type);\n}\n\nTEST_P(ProtoStreamObjectWriterStructTest, SimpleRepeatedStructMapKeyTest) {\n  EXPECT_CALL(\n      listener_,\n      InvalidName(_, StringPiece(\"gBike\"),\n                  StringPiece(\"Repeated map key: 'gBike' is already set.\")));\n  ow_->StartObject(\"\")\n      ->StartObject(\"object\")\n      ->RenderString(\"gBike\", \"v1\")\n      ->RenderString(\"gBike\", \"v2\")\n      ->EndObject()\n      ->EndObject();\n}\n\nTEST_P(ProtoStreamObjectWriterStructTest, RepeatedStructMapListKeyTest) {\n  EXPECT_CALL(\n      listener_,\n      InvalidName(_, StringPiece(\"k1\"),\n                  StringPiece(\"Repeated map key: 'k1' is already set.\")));\n  ow_->StartObject(\"\")\n      ->StartObject(\"object\")\n      ->RenderString(\"k1\", \"v1\")\n      ->StartList(\"k1\")\n      ->RenderString(\"\", \"v2\")\n      ->EndList()\n      ->EndObject()\n      ->EndObject();\n}\n\nTEST_P(ProtoStreamObjectWriterStructTest, RepeatedStructMapObjectKeyTest) {\n  EXPECT_CALL(\n      listener_,\n      InvalidName(_, StringPiece(\"k1\"),\n                  StringPiece(\"Repeated map key: 'k1' is already set.\")));\n  ow_->StartObject(\"\")\n      ->StartObject(\"object\")\n      ->StartObject(\"k1\")\n      ->RenderString(\"sub_k1\", \"v1\")\n      ->EndObject()\n      ->StartObject(\"k1\")\n      ->RenderString(\"sub_k2\", \"v2\")\n      ->EndObject()\n      ->EndObject()\n      ->EndObject();\n}\n\nTEST_P(ProtoStreamObjectWriterStructTest, OptionStructIntAsStringsTest) {\n  StructType struct_type;\n  google::protobuf::Struct* s = struct_type.mutable_object();\n  s->mutable_fields()->operator[](\"k1\").set_number_value(123);\n  s->mutable_fields()->operator[](\"k2\").set_bool_value(true);\n  s->mutable_fields()->operator[](\"k3\").set_string_value(\"-222222222\");\n  s->mutable_fields()->operator[](\"k4\").set_string_value(\"33333333\");\n\n  options_.struct_integers_as_strings = true;\n  ResetProtoWriter();\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"object\")\n      ->RenderDouble(\"k1\", 123)\n      ->RenderBool(\"k2\", true)\n      ->RenderInt64(\"k3\", -222222222)\n      ->RenderUint64(\"k4\", 33333333)\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(struct_type);\n}\n\nclass ProtoStreamObjectWriterMapTest : public BaseProtoStreamObjectWriterTest {\n protected:\n  ProtoStreamObjectWriterMapTest()\n      : BaseProtoStreamObjectWriterTest(MapIn::descriptor()) {}\n};\n\nINSTANTIATE_TEST_CASE_P(DifferentTypeInfoSourceTest,\n                        ProtoStreamObjectWriterMapTest,\n                        ::testing::Values(\n                            testing::USE_TYPE_RESOLVER));\n\nTEST_P(ProtoStreamObjectWriterMapTest, MapShouldNotAcceptList) {\n  MapIn mm;\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(\n          _, StringPiece(\"Map\"),\n          StringPiece(\"Cannot bind a list to map for field 'map_input'.\")));\n  ow_->StartObject(\"\")\n      ->StartList(\"map_input\")\n      ->RenderString(\"a\", \"b\")\n      ->EndList()\n      ->EndObject();\n  CheckOutput(mm);\n}\n\nTEST_P(ProtoStreamObjectWriterMapTest, RepeatedMapKeyTest) {\n  EXPECT_CALL(\n      listener_,\n      InvalidName(_, StringPiece(\"k1\"),\n                  StringPiece(\"Repeated map key: 'k1' is already set.\")));\n  ow_->StartObject(\"\")\n      ->RenderString(\"other\", \"test\")\n      ->StartObject(\"map_input\")\n      ->RenderString(\"k1\", \"v1\")\n      ->RenderString(\"k1\", \"v2\")\n      ->EndObject()\n      ->EndObject();\n}\n\nclass ProtoStreamObjectWriterAnyTest : public BaseProtoStreamObjectWriterTest {\n protected:\n  ProtoStreamObjectWriterAnyTest() {\n    vector<const Descriptor*> descriptors;\n    descriptors.push_back(AnyOut::descriptor());\n    descriptors.push_back(google::protobuf::DoubleValue::descriptor());\n    descriptors.push_back(google::protobuf::Timestamp::descriptor());\n    descriptors.push_back(google::protobuf::Any::descriptor());\n    descriptors.push_back(google::protobuf::Value::descriptor());\n    descriptors.push_back(google::protobuf::Struct::descriptor());\n    ResetTypeInfo(descriptors);\n  }\n};\n\nINSTANTIATE_TEST_CASE_P(DifferentTypeInfoSourceTest,\n                        ProtoStreamObjectWriterAnyTest,\n                        ::testing::Values(\n                            testing::USE_TYPE_RESOLVER));\n\nTEST_P(ProtoStreamObjectWriterAnyTest, AnyRenderSuccess) {\n  AnyOut any;\n  google::protobuf::Any* any_type = any.mutable_any();\n  any_type->set_type_url(\"type.googleapis.com/google.protobuf.DoubleValue\");\n  google::protobuf::DoubleValue d;\n  d.set_value(40.2);\n  any_type->set_value(d.SerializeAsString());\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"any\")\n      ->RenderString(\"@type\", \"type.googleapis.com/google.protobuf.DoubleValue\")\n      ->RenderDouble(\"value\", 40.2)\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(any);\n}\n\nTEST_P(ProtoStreamObjectWriterAnyTest, RecursiveAny) {\n  AnyOut out;\n  ::google::protobuf::Any* any = out.mutable_any();\n  any->set_type_url(\"type.googleapis.com/google.protobuf.Any\");\n\n  ::google::protobuf::Any nested_any;\n  nested_any.set_type_url(\n      \"type.googleapis.com/google.protobuf.testing.anys.AnyM\");\n\n  AnyM m;\n  m.set_foo(\"foovalue\");\n  nested_any.set_value(m.SerializeAsString());\n\n  any->set_value(nested_any.SerializeAsString());\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"any\")\n      ->RenderString(\"@type\", \"type.googleapis.com/google.protobuf.Any\")\n      ->StartObject(\"value\")\n      ->RenderString(\"@type\",\n                     \"type.googleapis.com/google.protobuf.testing.anys.AnyM\")\n      ->RenderString(\"foo\", \"foovalue\")\n      ->EndObject()\n      ->EndObject()\n      ->EndObject();\n}\n\nTEST_P(ProtoStreamObjectWriterAnyTest, DoubleRecursiveAny) {\n  AnyOut out;\n  ::google::protobuf::Any* any = out.mutable_any();\n  any->set_type_url(\"type.googleapis.com/google.protobuf.Any\");\n\n  ::google::protobuf::Any nested_any;\n  nested_any.set_type_url(\"type.googleapis.com/google.protobuf.Any\");\n\n  ::google::protobuf::Any second_nested_any;\n  second_nested_any.set_type_url(\n      \"type.googleapis.com/google.protobuf.testing.anys.AnyM\");\n\n  AnyM m;\n  m.set_foo(\"foovalue\");\n  second_nested_any.set_value(m.SerializeAsString());\n\n  nested_any.set_value(second_nested_any.SerializeAsString());\n  any->set_value(nested_any.SerializeAsString());\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"any\")\n      ->RenderString(\"@type\", \"type.googleapis.com/google.protobuf.Any\")\n      ->StartObject(\"value\")\n      ->RenderString(\"@type\", \"type.googleapis.com/google.protobuf.Any\")\n      ->StartObject(\"value\")\n      ->RenderString(\"@type\",\n                     \"type.googleapis.com/google.protobuf.testing.anys.AnyM\")\n      ->RenderString(\"foo\", \"foovalue\")\n      ->EndObject()\n      ->EndObject()\n      ->EndObject()\n      ->EndObject();\n}\n\nTEST_P(ProtoStreamObjectWriterAnyTest, EmptyAnyFromEmptyObject) {\n  AnyOut out;\n  out.mutable_any();\n\n  ow_->StartObject(\"\")->StartObject(\"any\")->EndObject()->EndObject();\n\n  CheckOutput(out, 2);\n}\n\nTEST_P(ProtoStreamObjectWriterAnyTest, AnyWithoutTypeUrlFails1) {\n  AnyOut any;\n\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(_, StringPiece(\"Any\"),\n                   StringPiece(\"Missing or invalid @type for any field in \"\n                               \"google.protobuf.testing.anys.AnyOut\")));\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"any\")\n      ->StartObject(\"another\")\n      ->EndObject()\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(any);\n}\n\nTEST_P(ProtoStreamObjectWriterAnyTest, AnyWithoutTypeUrlFails2) {\n  AnyOut any;\n\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(_, StringPiece(\"Any\"),\n                   StringPiece(\"Missing or invalid @type for any field in \"\n                               \"google.protobuf.testing.anys.AnyOut\")));\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"any\")\n      ->StartList(\"another\")\n      ->EndObject()\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(any);\n}\n\nTEST_P(ProtoStreamObjectWriterAnyTest, AnyWithoutTypeUrlFails3) {\n  AnyOut any;\n\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(_, StringPiece(\"Any\"),\n                   StringPiece(\"Missing or invalid @type for any field in \"\n                               \"google.protobuf.testing.anys.AnyOut\")));\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"any\")\n      ->RenderString(\"value\", \"somevalue\")\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(any);\n}\n\nTEST_P(ProtoStreamObjectWriterAnyTest, AnyWithInvalidTypeUrlFails) {\n  AnyOut any;\n\n  EXPECT_CALL(listener_,\n              InvalidValue(\n                  _, StringPiece(\"Any\"),\n                  StringPiece(\"Invalid type URL, type URLs must be of the form \"\n                              \"'type.googleapis.com/<typename>', got: \"\n                              \"type.other.com/some.Type\")));\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"any\")\n      ->RenderString(\"@type\", \"type.other.com/some.Type\")\n      ->RenderDouble(\"value\", 40.2)\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(any);\n}\n\nTEST_P(ProtoStreamObjectWriterAnyTest, AnyWithUnknownTypeFails) {\n  AnyOut any;\n\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(_, StringPiece(\"Any\"),\n                   StringPiece(\"Invalid type URL, unknown type: some.Type\")));\n  ow_->StartObject(\"\")\n      ->StartObject(\"any\")\n      ->RenderString(\"@type\", \"type.googleapis.com/some.Type\")\n      ->RenderDouble(\"value\", 40.2)\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(any);\n}\n\nTEST_P(ProtoStreamObjectWriterAnyTest, AnyNullInputFails) {\n  AnyOut any;\n\n  ow_->StartObject(\"\")->RenderNull(\"any\")->EndObject();\n  CheckOutput(any);\n}\n\nTEST_P(ProtoStreamObjectWriterAnyTest, AnyWellKnownTypeErrorTest) {\n  EXPECT_CALL(listener_, InvalidValue(_, StringPiece(\"Any\"),\n                                      StringPiece(\"Invalid time format: \")));\n\n  AnyOut any;\n  google::protobuf::Any* any_type = any.mutable_any();\n  any_type->set_type_url(\"type.googleapis.com/google.protobuf.Timestamp\");\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"any\")\n      ->RenderString(\"@type\", \"type.googleapis.com/google.protobuf.Timestamp\")\n      ->RenderString(\"value\", \"\")\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(any);\n}\n\n// Test the following case:\n//\n// {\n//   \"any\": {\n//     \"@type\": \"type.googleapis.com/google.protobuf.Value\",\n//     \"value\": \"abc\"\n//   }\n// }\nTEST_P(ProtoStreamObjectWriterAnyTest, AnyWithNestedPrimitiveValue) {\n  AnyOut out;\n  ::google::protobuf::Any* any = out.mutable_any();\n\n  ::google::protobuf::Value value;\n  value.set_string_value(\"abc\");\n  any->PackFrom(value);\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"any\")\n      ->RenderString(\"@type\", \"type.googleapis.com/google.protobuf.Value\")\n      ->RenderString(\"value\", \"abc\")\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(out);\n}\n\n// Test the following case:\n//\n// {\n//   \"any\": {\n//     \"@type\": \"type.googleapis.com/google.protobuf.Value\",\n//     \"value\": {\n//       \"foo\": \"abc\"\n//     }\n//   }\n// }\nTEST_P(ProtoStreamObjectWriterAnyTest, AnyWithNestedObjectValue) {\n  AnyOut out;\n  ::google::protobuf::Any* any = out.mutable_any();\n\n  ::google::protobuf::Value value;\n  (*value.mutable_struct_value()->mutable_fields())[\"foo\"].set_string_value(\n      \"abc\");\n  any->PackFrom(value);\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"any\")\n      ->RenderString(\"@type\", \"type.googleapis.com/google.protobuf.Value\")\n      ->StartObject(\"value\")\n      ->RenderString(\"foo\", \"abc\")\n      ->EndObject()\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(out);\n}\n\n// Test the following case:\n//\n// {\n//   \"any\": {\n//     \"@type\": \"type.googleapis.com/google.protobuf.Value\",\n//     \"value\": [\"hello\"],\n//   }\n// }\nTEST_P(ProtoStreamObjectWriterAnyTest, AnyWithNestedArrayValue) {\n  AnyOut out;\n  ::google::protobuf::Any* any = out.mutable_any();\n\n  ::google::protobuf::Value value;\n  value.mutable_list_value()->add_values()->set_string_value(\"hello\");\n  any->PackFrom(value);\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"any\")\n      ->RenderString(\"@type\", \"type.googleapis.com/google.protobuf.Value\")\n      ->StartList(\"value\")\n      ->RenderString(\"\", \"hello\")\n      ->EndList()\n      ->EndObject()\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(out);\n}\n\n// Test the following case:\n//\n// {\n//   \"any\": {\n//     \"@type\": \"type.googleapis.com/google.protobuf.Value\",\n//     \"not_value\": \"\"\n//   }\n// }\nTEST_P(ProtoStreamObjectWriterAnyTest,\n       AnyWellKnownTypesNoValueFieldForPrimitive) {\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(\n          _, StringPiece(\"Any\"),\n          StringPiece(\"Expect a \\\"value\\\" field for well-known types.\")));\n  AnyOut any;\n  google::protobuf::Any* any_type = any.mutable_any();\n  any_type->set_type_url(\"type.googleapis.com/google.protobuf.Value\");\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"any\")\n      ->RenderString(\"@type\", \"type.googleapis.com/google.protobuf.Value\")\n      ->RenderString(\"not_value\", \"\")\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(any);\n}\n\n// Test the following case:\n//\n// {\n//   \"any\": {\n//     \"@type\": \"type.googleapis.com/google.protobuf.Value\",\n//     \"not_value\": {}\n//   }\n// }\nTEST_P(ProtoStreamObjectWriterAnyTest, AnyWellKnownTypesNoValueFieldForObject) {\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(\n          _, StringPiece(\"Any\"),\n          StringPiece(\"Expect a \\\"value\\\" field for well-known types.\")));\n  AnyOut any;\n  google::protobuf::Any* any_type = any.mutable_any();\n  any_type->set_type_url(\"type.googleapis.com/google.protobuf.Value\");\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"any\")\n      ->RenderString(\"@type\", \"type.googleapis.com/google.protobuf.Value\")\n      ->StartObject(\"not_value\")\n      ->EndObject()\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(any);\n}\n\n// Test the following case:\n//\n// {\n//   \"any\": {\n//     \"@type\": \"type.googleapis.com/google.protobuf.Value\",\n//     \"not_value\": [],\n//   }\n// }\nTEST_P(ProtoStreamObjectWriterAnyTest, AnyWellKnownTypesNoValueFieldForArray) {\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(\n          _, StringPiece(\"Any\"),\n          StringPiece(\"Expect a \\\"value\\\" field for well-known types.\")));\n  AnyOut any;\n  google::protobuf::Any* any_type = any.mutable_any();\n  any_type->set_type_url(\"type.googleapis.com/google.protobuf.Value\");\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"any\")\n      ->RenderString(\"@type\", \"type.googleapis.com/google.protobuf.Value\")\n      ->StartList(\"not_value\")\n      ->EndList()\n      ->EndObject()\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(any);\n}\n\n// Test the following case:\n//\n// {\n//   \"any\": {\n//     \"@type\": \"type.googleapis.com/google.protobuf.Struct\",\n//     \"value\": \"\",\n//   }\n// }\nTEST_P(ProtoStreamObjectWriterAnyTest, AnyWellKnownTypesExpectObjectForStruct) {\n  EXPECT_CALL(listener_, InvalidValue(_, StringPiece(\"Any\"),\n                                      StringPiece(\"Expect a JSON object.\")));\n  AnyOut any;\n  google::protobuf::Any* any_type = any.mutable_any();\n  any_type->set_type_url(\"type.googleapis.com/google.protobuf.Struct\");\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"any\")\n      ->RenderString(\"@type\", \"type.googleapis.com/google.protobuf.Struct\")\n      ->RenderString(\"value\", \"\")\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(any);\n}\n\n// Test the following case:\n//\n// {\n//   \"any\": {\n//     \"@type\": \"type.googleapis.com/google.protobuf.Any\",\n//     \"value\": \"\",\n//   }\n// }\nTEST_P(ProtoStreamObjectWriterAnyTest, AnyWellKnownTypesExpectObjectForAny) {\n  EXPECT_CALL(listener_, InvalidValue(_, StringPiece(\"Any\"),\n                                      StringPiece(\"Expect a JSON object.\")));\n  AnyOut any;\n  google::protobuf::Any* any_type = any.mutable_any();\n  any_type->set_type_url(\"type.googleapis.com/google.protobuf.Any\");\n\n  ow_->StartObject(\"\")\n      ->StartObject(\"any\")\n      ->RenderString(\"@type\", \"type.googleapis.com/google.protobuf.Any\")\n      ->RenderString(\"value\", \"\")\n      ->EndObject()\n      ->EndObject();\n  CheckOutput(any);\n}\n\nclass ProtoStreamObjectWriterFieldMaskTest\n    : public BaseProtoStreamObjectWriterTest {\n protected:\n  ProtoStreamObjectWriterFieldMaskTest() {\n    vector<const Descriptor*> descriptors;\n    descriptors.push_back(FieldMaskTest::descriptor());\n    descriptors.push_back(google::protobuf::FieldMask::descriptor());\n    ResetTypeInfo(descriptors);\n  }\n};\n\nINSTANTIATE_TEST_CASE_P(DifferentTypeInfoSourceTest,\n                        ProtoStreamObjectWriterFieldMaskTest,\n                        ::testing::Values(\n                            testing::USE_TYPE_RESOLVER));\n\nTEST_P(ProtoStreamObjectWriterFieldMaskTest, SimpleFieldMaskTest) {\n  FieldMaskTest expected;\n  expected.set_id(\"1\");\n  expected.mutable_single_mask()->add_paths(\"path1\");\n\n  ow_->StartObject(\"\");\n  ow_->RenderString(\"id\", \"1\");\n  ow_->RenderString(\"single_mask\", \"path1\");\n  ow_->EndObject();\n\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterFieldMaskTest, MutipleMasksInCompactForm) {\n  FieldMaskTest expected;\n  expected.set_id(\"1\");\n  expected.mutable_single_mask()->add_paths(\"camel_case1\");\n  expected.mutable_single_mask()->add_paths(\"camel_case2\");\n  expected.mutable_single_mask()->add_paths(\"camel_case3\");\n\n  ow_->StartObject(\"\");\n  ow_->RenderString(\"id\", \"1\");\n  ow_->RenderString(\"single_mask\", \"camelCase1,camelCase2,camelCase3\");\n  ow_->EndObject();\n\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterFieldMaskTest, RepeatedFieldMaskTest) {\n  FieldMaskTest expected;\n  expected.set_id(\"1\");\n  google::protobuf::FieldMask* mask = expected.add_repeated_mask();\n  mask->add_paths(\"field1\");\n  mask->add_paths(\"field2\");\n  expected.add_repeated_mask()->add_paths(\"field3\");\n\n  ow_->StartObject(\"\");\n  ow_->RenderString(\"id\", \"1\");\n  ow_->StartList(\"repeated_mask\");\n  ow_->RenderString(\"\", \"field1,field2\");\n  ow_->RenderString(\"\", \"field3\");\n  ow_->EndList();\n  ow_->EndObject();\n\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterFieldMaskTest, EmptyFieldMaskTest) {\n  FieldMaskTest expected;\n  expected.set_id(\"1\");\n\n  ow_->StartObject(\"\");\n  ow_->RenderString(\"id\", \"1\");\n  ow_->RenderString(\"single_mask\", \"\");\n  ow_->EndObject();\n\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterFieldMaskTest, MaskUsingApiaryStyleShouldWork) {\n  FieldMaskTest expected;\n  expected.set_id(\"1\");\n\n  ow_->StartObject(\"\");\n  ow_->RenderString(\"id\", \"1\");\n  // Case1\n  ow_->RenderString(\"single_mask\",\n                    \"outerField(camelCase1,camelCase2,camelCase3)\");\n  expected.mutable_single_mask()->add_paths(\"outer_field.camel_case1\");\n  expected.mutable_single_mask()->add_paths(\"outer_field.camel_case2\");\n  expected.mutable_single_mask()->add_paths(\"outer_field.camel_case3\");\n\n  ow_->StartList(\"repeated_mask\");\n\n  ow_->RenderString(\"\", \"a(field1,field2)\");\n  google::protobuf::FieldMask* mask = expected.add_repeated_mask();\n  mask->add_paths(\"a.field1\");\n  mask->add_paths(\"a.field2\");\n\n  ow_->RenderString(\"\", \"a(field3)\");\n  mask = expected.add_repeated_mask();\n  mask->add_paths(\"a.field3\");\n\n  ow_->RenderString(\"\", \"a()\");\n  expected.add_repeated_mask();\n\n  ow_->RenderString(\"\", \"a(,)\");\n  expected.add_repeated_mask();\n\n  ow_->RenderString(\"\", \"a(field1(field2(field3)))\");\n  mask = expected.add_repeated_mask();\n  mask->add_paths(\"a.field1.field2.field3\");\n\n  ow_->RenderString(\"\", \"a(field1(field2(field3,field4),field5),field6)\");\n  mask = expected.add_repeated_mask();\n  mask->add_paths(\"a.field1.field2.field3\");\n  mask->add_paths(\"a.field1.field2.field4\");\n  mask->add_paths(\"a.field1.field5\");\n  mask->add_paths(\"a.field6\");\n\n  ow_->RenderString(\"\", \"a(id,field1(id,field2(field3,field4),field5),field6)\");\n  mask = expected.add_repeated_mask();\n  mask->add_paths(\"a.id\");\n  mask->add_paths(\"a.field1.id\");\n  mask->add_paths(\"a.field1.field2.field3\");\n  mask->add_paths(\"a.field1.field2.field4\");\n  mask->add_paths(\"a.field1.field5\");\n  mask->add_paths(\"a.field6\");\n\n  ow_->RenderString(\"\", \"a(((field3,field4)))\");\n  mask = expected.add_repeated_mask();\n  mask->add_paths(\"a.field3\");\n  mask->add_paths(\"a.field4\");\n\n  ow_->EndList();\n  ow_->EndObject();\n\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterFieldMaskTest, MoreCloseThanOpenParentheses) {\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(\n          _, StringPiece(\"type.googleapis.com/google.protobuf.FieldMask\"),\n          StringPiece(\"Field 'single_mask', Invalid FieldMask 'a(b,c))'. \"\n                      \"Cannot find matching '(' for all ')'.\")));\n\n  ow_->StartObject(\"\");\n  ow_->RenderString(\"id\", \"1\");\n  ow_->RenderString(\"single_mask\", \"a(b,c))\");\n  ow_->EndObject();\n}\n\nTEST_P(ProtoStreamObjectWriterFieldMaskTest, MoreOpenThanCloseParentheses) {\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(\n          _, StringPiece(\"type.googleapis.com/google.protobuf.FieldMask\"),\n          StringPiece(\n              \"Field 'single_mask', Invalid FieldMask 'a(((b,c)'. Cannot \"\n              \"find matching ')' for all '('.\")));\n\n  ow_->StartObject(\"\");\n  ow_->RenderString(\"id\", \"1\");\n  ow_->RenderString(\"single_mask\", \"a(((b,c)\");\n  ow_->EndObject();\n}\n\nTEST_P(ProtoStreamObjectWriterFieldMaskTest, PathWithMapKeyShouldWork) {\n  FieldMaskTest expected;\n  expected.mutable_single_mask()->add_paths(\"path.to.map[\\\"key1\\\"]\");\n  expected.mutable_single_mask()->add_paths(\n      \"path.to.map[\\\"e\\\\\\\"[]][scape\\\\\\\"\\\"]\");\n  expected.mutable_single_mask()->add_paths(\"path.to.map[\\\"key2\\\"]\");\n\n  ow_->StartObject(\"\");\n  ow_->RenderString(\"single_mask\",\n                    \"path.to.map[\\\"key1\\\"],path.to.map[\\\"e\\\\\\\"[]][scape\\\\\\\"\\\"],\"\n                    \"path.to.map[\\\"key2\\\"]\");\n  ow_->EndObject();\n\n  CheckOutput(expected);\n}\n\nTEST_P(ProtoStreamObjectWriterFieldMaskTest,\n       MapKeyMustBeAtTheEndOfAPathSegment) {\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(\n          _, StringPiece(\"type.googleapis.com/google.protobuf.FieldMask\"),\n          StringPiece(\"Field 'single_mask', Invalid FieldMask \"\n                      \"'path.to.map[\\\"key1\\\"]a,path.to.map[\\\"key2\\\"]'. \"\n                      \"Map keys should be at the end of a path segment.\")));\n\n  ow_->StartObject(\"\");\n  ow_->RenderString(\"single_mask\",\n                    \"path.to.map[\\\"key1\\\"]a,path.to.map[\\\"key2\\\"]\");\n  ow_->EndObject();\n}\n\nTEST_P(ProtoStreamObjectWriterFieldMaskTest, MapKeyMustEnd) {\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(_,\n                   StringPiece(\"type.googleapis.com/google.protobuf.FieldMask\"),\n                   StringPiece(\"Field 'single_mask', Invalid FieldMask \"\n                               \"'path.to.map[\\\"key1\\\"'. Map keys should be \"\n                               \"represented as [\\\"some_key\\\"].\")));\n\n  ow_->StartObject(\"\");\n  ow_->RenderString(\"single_mask\", \"path.to.map[\\\"key1\\\"\");\n  ow_->EndObject();\n}\n\nTEST_P(ProtoStreamObjectWriterFieldMaskTest, MapKeyMustBeEscapedCorrectly) {\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(_,\n                   StringPiece(\"type.googleapis.com/google.protobuf.FieldMask\"),\n                   StringPiece(\"Field 'single_mask', Invalid FieldMask \"\n                               \"'path.to.map[\\\"ke\\\"y1\\\"]'. Map keys should be \"\n                               \"represented as [\\\"some_key\\\"].\")));\n\n  ow_->StartObject(\"\");\n  ow_->RenderString(\"single_mask\", \"path.to.map[\\\"ke\\\"y1\\\"]\");\n  ow_->EndObject();\n}\n\nTEST_P(ProtoStreamObjectWriterFieldMaskTest, MapKeyCanContainAnyChars) {\n  FieldMaskTest expected;\n  expected.mutable_single_mask()->add_paths(\n      // \\xE5\\xAD\\x99 is the UTF-8 byte sequence for chinese character 孙.\n      // We cannot embed non-ASCII characters in the code directly because\n      // some windows compilers will try to interpret them using the system's\n      // current encoding and end up with invalid UTF-8 byte sequence.\n      \"path.to.map[\\\"(),[],\\\\\\\"'!@#$%^&*123_|War\\xE5\\xAD\\x99,./?><\\\\\\\\\\\"]\");\n  expected.mutable_single_mask()->add_paths(\"path.to.map[\\\"key2\\\"]\");\n\n  ow_->StartObject(\"\");\n  ow_->RenderString(\n      \"single_mask\",\n      \"path.to.map[\\\"(),[],\\\\\\\"'!@#$%^&*123_|War\\xE5\\xAD\\x99,./?><\\\\\\\\\\\"],\"\n      \"path.to.map[\\\"key2\\\"]\");\n  ow_->EndObject();\n\n  CheckOutput(expected);\n}\n\nclass ProtoStreamObjectWriterOneOfsTest\n    : public BaseProtoStreamObjectWriterTest {\n protected:\n  ProtoStreamObjectWriterOneOfsTest() {\n    vector<const Descriptor*> descriptors;\n    descriptors.push_back(OneOfsRequest::descriptor());\n    descriptors.push_back(google::protobuf::Struct::descriptor());\n    ResetTypeInfo(descriptors);\n  }\n};\n\nINSTANTIATE_TEST_CASE_P(DifferentTypeInfoSourceTest,\n                        ProtoStreamObjectWriterOneOfsTest,\n                        ::testing::Values(\n                            testing::USE_TYPE_RESOLVER));\n\nTEST_P(ProtoStreamObjectWriterOneOfsTest,\n       MultipleOneofsFailForPrimitiveTypesTest) {\n  EXPECT_CALL(\n      listener_,\n      InvalidValue(\n          _, StringPiece(\"oneof\"),\n          StringPiece(\n              \"oneof field 'data' is already set. Cannot set 'intData'\")));\n\n  ow_->StartObject(\"\");\n  ow_->RenderString(\"strData\", \"blah\");\n  ow_->RenderString(\"intData\", \"123\");\n  ow_->EndObject();\n}\n\nTEST_P(ProtoStreamObjectWriterOneOfsTest,\n       MultipleOneofsFailForMessageTypesPrimitiveFirstTest) {\n  // Test for setting primitive oneof field first and then message field.\n  EXPECT_CALL(listener_,\n              InvalidValue(_, StringPiece(\"oneof\"),\n                           StringPiece(\"oneof field 'data' is already set. \"\n                                       \"Cannot set 'messageData'\")));\n\n  // JSON: { \"strData\": \"blah\", \"messageData\": { \"dataValue\": 123 } }\n  ow_->StartObject(\"\");\n  ow_->RenderString(\"strData\", \"blah\");\n  ow_->StartObject(\"messageData\");\n  ow_->RenderInt32(\"dataValue\", 123);\n  ow_->EndObject();\n  ow_->EndObject();\n}\n\nTEST_P(ProtoStreamObjectWriterOneOfsTest,\n       MultipleOneofsFailForMessageTypesMessageFirstTest) {\n  // Test for setting message oneof field first and then primitive field.\n  EXPECT_CALL(listener_,\n              InvalidValue(_, StringPiece(\"oneof\"),\n                           StringPiece(\"oneof field 'data' is already set. \"\n                                       \"Cannot set 'strData'\")));\n\n  // JSON: { \"messageData\": { \"dataValue\": 123 }, \"strData\": \"blah\" }\n  ow_->StartObject(\"\");\n  ow_->StartObject(\"messageData\");\n  ow_->RenderInt32(\"dataValue\", 123);\n  ow_->EndObject();\n  ow_->RenderString(\"strData\", \"blah\");\n  ow_->EndObject();\n}\n\nTEST_P(ProtoStreamObjectWriterOneOfsTest,\n       MultipleOneofsFailForStructTypesPrimitiveFirstTest) {\n  EXPECT_CALL(listener_,\n              InvalidValue(_, StringPiece(\"oneof\"),\n                           StringPiece(\"oneof field 'data' is already set. \"\n                                       \"Cannot set 'structData'\")));\n\n  // JSON: { \"strData\": \"blah\", \"structData\": { \"a\": \"b\" } }\n  ow_->StartObject(\"\");\n  ow_->RenderString(\"strData\", \"blah\");\n  ow_->StartObject(\"structData\");\n  ow_->RenderString(\"a\", \"b\");\n  ow_->EndObject();\n  ow_->EndObject();\n}\n\nTEST_P(ProtoStreamObjectWriterOneOfsTest,\n       MultipleOneofsFailForStructTypesStructFirstTest) {\n  EXPECT_CALL(listener_,\n              InvalidValue(_, StringPiece(\"oneof\"),\n                           StringPiece(\"oneof field 'data' is already set. \"\n                                       \"Cannot set 'strData'\")));\n\n  // JSON: { \"structData\": { \"a\": \"b\" }, \"strData\": \"blah\" }\n  ow_->StartObject(\"\");\n  ow_->StartObject(\"structData\");\n  ow_->RenderString(\"a\", \"b\");\n  ow_->EndObject();\n  ow_->RenderString(\"strData\", \"blah\");\n  ow_->EndObject();\n}\n\nTEST_P(ProtoStreamObjectWriterOneOfsTest,\n       MultipleOneofsFailForStructValueTypesTest) {\n  EXPECT_CALL(listener_,\n              InvalidValue(_, StringPiece(\"oneof\"),\n                           StringPiece(\"oneof field 'data' is already set. \"\n                                       \"Cannot set 'valueData'\")));\n\n  // JSON: { \"messageData\": { \"dataValue\": 123 }, \"valueData\": { \"a\": \"b\" } }\n  ow_->StartObject(\"\");\n  ow_->StartObject(\"messageData\");\n  ow_->RenderInt32(\"dataValue\", 123);\n  ow_->EndObject();\n  ow_->StartObject(\"valueData\");\n  ow_->RenderString(\"a\", \"b\");\n  ow_->EndObject();\n  ow_->EndObject();\n}\n\nTEST_P(ProtoStreamObjectWriterOneOfsTest,\n       MultipleOneofsFailForWellKnownTypesPrimitiveFirstTest) {\n  EXPECT_CALL(listener_,\n              InvalidValue(_, StringPiece(\"oneof\"),\n                           StringPiece(\"oneof field 'data' is already set. \"\n                                       \"Cannot set 'tsData'\")));\n\n  // JSON: { \"intData\": 123, \"tsData\": \"1970-01-02T01:00:00.000Z\" }\n  ow_->StartObject(\"\");\n  ow_->RenderInt32(\"intData\", 123);\n  ow_->RenderString(\"tsData\", \"1970-01-02T01:00:00.000Z\");\n  ow_->EndObject();\n}\n\nTEST_P(ProtoStreamObjectWriterOneOfsTest,\n       MultipleOneofsFailForWellKnownTypesWktFirstTest) {\n  EXPECT_CALL(listener_,\n              InvalidValue(_, StringPiece(\"oneof\"),\n                           StringPiece(\"oneof field 'data' is already set. \"\n                                       \"Cannot set 'intData'\")));\n\n  // JSON: { \"tsData\": \"1970-01-02T01:00:00.000Z\", \"intData\": 123 }\n  ow_->StartObject(\"\");\n  ow_->RenderString(\"tsData\", \"1970-01-02T01:00:00.000Z\");\n  ow_->RenderInt32(\"intData\", 123);\n  ow_->EndObject();\n}\n\nTEST_P(ProtoStreamObjectWriterOneOfsTest,\n       MultipleOneofsFailForWellKnownTypesAndMessageTest) {\n  EXPECT_CALL(listener_,\n              InvalidValue(_, StringPiece(\"oneof\"),\n                           StringPiece(\"oneof field 'data' is already set. \"\n                                       \"Cannot set 'messageData'\")));\n\n  // JSON: { \"tsData\": \"1970-01-02T01:00:00.000Z\",\n  //         \"messageData\": { \"dataValue\": 123 } }\n  ow_->StartObject(\"\");\n  ow_->RenderString(\"tsData\", \"1970-01-02T01:00:00.000Z\");\n  ow_->StartObject(\"messageData\");\n  ow_->RenderInt32(\"dataValue\", 123);\n  ow_->EndObject();\n  ow_->EndObject();\n}\n\nTEST_P(ProtoStreamObjectWriterOneOfsTest,\n       MultipleOneofsFailForOneofWithinAnyTest) {\n  EXPECT_CALL(listener_,\n              InvalidValue(_, StringPiece(\"oneof\"),\n                           StringPiece(\"oneof field 'data' is already set. \"\n                                       \"Cannot set 'intData'\")));\n\n  using google::protobuf::testing::oneofs::OneOfsRequest;\n  // JSON:\n  // { \"anyData\":\n  //    { \"@type\":\n  //       \"type.googleapis.com/google.protobuf.testing.oneofs.OneOfsRequest\",\n  //     \"strData\": \"blah\",\n  //     \"intData\": 123\n  //    }\n  // }\n  ow_->StartObject(\"\");\n  ow_->StartObject(\"anyData\");\n  ow_->RenderString(\n      \"@type\",\n      \"type.googleapis.com/google.protobuf.testing.oneofs.OneOfsRequest\");\n  ow_->RenderString(\"strData\", \"blah\");\n  ow_->RenderInt32(\"intData\", 123);\n  ow_->EndObject();\n  ow_->EndObject();\n}\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/structured_objectwriter.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_STRUCTURED_OBJECTWRITER_H__\n#define GOOGLE_PROTOBUF_UTIL_CONVERTER_STRUCTURED_OBJECTWRITER_H__\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n\n#include <google/protobuf/stubs/casts.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/util/internal/object_writer.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\n// An StructuredObjectWriter is an ObjectWriter for writing\n// tree-structured data in a stream of events representing objects\n// and collections. Implementation of this interface can be used to\n// write an object stream to an in-memory structure, protobufs,\n// JSON, XML, or any other output format desired. The ObjectSource\n// interface is typically used as the source of an object stream.\n//\n// See JsonObjectWriter for a sample implementation of\n// StructuredObjectWriter and its use.\n//\n// Derived classes could be thread-unsafe.\nclass LIBPROTOBUF_EXPORT StructuredObjectWriter : public ObjectWriter {\n public:\n  virtual ~StructuredObjectWriter() {}\n\n protected:\n  // A base element class for subclasses to extend, makes tracking state easier.\n  //\n  // StructuredObjectWriter behaves as a visitor. BaseElement represents a node\n  // in the input tree. Implementation of StructuredObjectWriter should also\n  // extend BaseElement to keep track of the location in the input tree.\n  class LIBPROTOBUF_EXPORT BaseElement {\n   public:\n    // Takes ownership of the parent Element.\n    explicit BaseElement(BaseElement* parent)\n        : parent_(parent), level_(parent == NULL ? 0 : parent->level() + 1) {}\n    virtual ~BaseElement() {}\n\n    // Releases ownership of the parent and returns a pointer to it.\n    template <typename ElementType>\n    ElementType* pop() {\n      return down_cast<ElementType*>(parent_.release());\n    }\n\n    // Returns true if this element is the root.\n    bool is_root() const { return parent_ == NULL; }\n\n    // Returns the number of hops from this element to the root element.\n    int level() const { return level_; }\n\n   protected:\n    // Returns pointer to parent element without releasing ownership.\n    virtual BaseElement* parent() const { return parent_.get(); }\n\n   private:\n    // Pointer to the parent Element.\n    google::protobuf::scoped_ptr<BaseElement> parent_;\n\n    // Number of hops to the root Element.\n    // The root Element has NULL parent_ and a level_ of 0.\n    const int level_;\n\n    GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(BaseElement);\n  };\n\n  StructuredObjectWriter() {}\n\n  // Returns the current element. Used for indentation and name overrides.\n  virtual BaseElement* element() = 0;\n\n private:\n  // Do not add any data members to this class.\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StructuredObjectWriter);\n};\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_CONVERTER_STRUCTURED_OBJECTWRITER_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/testdata/anys.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Proto to test Proto3 Any serialization.\nsyntax = \"proto3\";\n\npackage google.protobuf.testing.anys;\noption java_package = \"com.google.protobuf.testing.anys\";\n\nimport \"google/protobuf/any.proto\";\n\nmessage AnyIn {\n  string something = 1;\n}\n\nmessage AnyOut {\n  google.protobuf.Any any = 1;\n}\n\nmessage AnyM {\n  string foo = 1;\n}\n\nservice TestService {\n  rpc Call(AnyIn) returns (AnyOut);\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/testdata/books.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: sven@google.com (Sven Mawson)\n//\n// Sample protos for testing.\nsyntax = \"proto2\";\n\npackage google.protobuf.testing;\n\n// A book\nmessage Book {\n  optional string title = 1;\n  optional Author author = 2;\n  optional uint32 length = 3;\n  optional int64 published = 4;\n  optional bytes content = 5;\n\n  optional group Data = 6 {\n    optional uint32 year = 7;\n    optional string copyright = 8;\n  }\n\n  message Label {\n    optional string key = 1;\n    optional string value = 2;\n  }\n\n  optional Publisher publisher = 9;\n  repeated Label labels = 10;\n\n  enum Type {\n    FICTION = 1;\n    KIDS = 2;\n    ACTION_AND_ADVENTURE = 3;\n  }\n  optional Type type = 11;\n\n  extensions 200 to 499;\n}\n\n// A publisher of a book, tests required fields.\nmessage Publisher {\n  required string name = 1;\n}\n\n// An author of a book\nmessage Author {\n  optional uint64 id = 1 [json_name = \"@id\"];\n  optional string name = 2;\n  repeated string pseudonym = 3;\n  optional bool alive = 4;\n  repeated Author friend = 5;\n}\n\n// For testing resiliency of our protostream parser.\n// Field numbers of Author are reused for something else.\nmessage BadAuthor {\n  optional string id = 1;  // non-length-delimited to length-delimited.\n  repeated uint64 name = 2;  // string to repeated (both length-delimited).\n  optional string pseudonym = 3;  // Repeated to optional.\n  repeated bool alive = 4 [packed=true];  // Optional to repeated.\n}\n\n// All primitive types\nmessage Primitive {\n  // 32 bit numbers:\n  optional fixed32 fix32 = 1;\n  optional uint32 u32 = 2;\n  optional int32 i32 = 3;\n  optional sfixed32 sf32 = 4;\n  optional sint32 s32 = 5;\n\n  // 64 bit numbers:\n  optional fixed64 fix64 = 6;\n  optional uint64 u64 = 7;\n  optional int64 i64 = 8;\n  optional sfixed64 sf64 = 9;\n  optional sint64 s64 = 10;\n\n  // The other stuff.\n  optional string str = 11;\n  optional bytes bytes = 12;\n  optional float float = 13;\n  optional double double = 14;\n  optional bool bool = 15;\n\n  // repeated 32 bit numbers:\n  repeated fixed32 rep_fix32 = 16;\n  repeated uint32 rep_u32 = 17;\n  repeated int32 rep_i32 = 18;\n  repeated sfixed32 rep_sf32 = 19;\n  repeated sint32 rep_s32 = 20;\n\n  // repeated 64 bit numbers:\n  repeated fixed64 rep_fix64 = 21;\n  repeated uint64 rep_u64 = 22;\n  repeated int64 rep_i64 = 23;\n  repeated sfixed64 rep_sf64 = 24;\n  repeated sint64 rep_s64 = 25;\n\n  // repeated other stuff:\n  repeated string rep_str = 26;\n  repeated bytes rep_bytes = 27;\n  repeated float rep_float = 28;\n  repeated double rep_double = 29;\n  repeated bool rep_bool = 30;\n}\n\n// Test packed versions of all repeated primitives.\n// The field numbers should match their non-packed version in Primitive message.\nmessage PackedPrimitive {\n  // repeated 32 bit numbers:\n  repeated fixed32 rep_fix32 = 16 [packed=true];\n  repeated uint32 rep_u32 = 17 [packed=true];\n  repeated int32 rep_i32 = 18 [packed=true];\n  repeated sfixed32 rep_sf32 = 19 [packed=true];\n  repeated sint32 rep_s32 = 20 [packed=true];\n\n  // repeated 64 bit numbers:\n  repeated fixed64 rep_fix64 = 21 [packed=true];\n  repeated uint64 rep_u64 = 22 [packed=true];\n  repeated int64 rep_i64 = 23 [packed=true];\n  repeated sfixed64 rep_sf64 = 24 [packed=true];\n  repeated sint64 rep_s64 = 25 [packed=true];\n\n  // repeated other stuff:\n  repeated float rep_float = 28 [packed=true];\n  repeated double rep_double = 29 [packed=true];\n  repeated bool rep_bool = 30 [packed=true];\n}\n\n// Test extensions.\nextend Book {\n  repeated Author more_author = 201;\n}\n\n// Test nested extensions.\nmessage NestedBook {\n  extend Book {\n    optional NestedBook another_book = 301;\n  }\n  // Recurse\n  optional Book book = 1;\n}\n\n// For testing resiliency of our protostream parser.\n// Field number of NestedBook is reused for something else.\nmessage BadNestedBook {\n  repeated uint32 book = 1 [packed=true];  // Packed to optional message.\n}\n\n// A recursively defined message.\nmessage Cyclic {\n  optional int32 m_int = 1;\n  optional string m_str = 2;\n  optional Book m_book = 3;\n  repeated Author m_author = 5;\n  optional Cyclic m_cyclic = 4;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/testdata/default_value.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto3\";\n\npackage google.protobuf.testing;\n\nimport \"google/protobuf/any.proto\";\nimport \"google/protobuf/struct.proto\";\nimport \"google/protobuf/wrappers.proto\";\n\nmessage DefaultValueTestCases {\n  DoubleMessage empty_double = 1;\n  DoubleMessage double_with_default_value = 2;\n  DoubleMessage double_with_nondefault_value = 3;\n  DoubleMessage repeated_double = 4;\n  DoubleMessage nested_message = 5;\n  DoubleMessage repeated_nested_message = 6;\n  DoubleMessage double_message_with_oneof = 7;\n  StructMessage empty_struct = 201;\n  StructMessage empty_struct2 = 202;\n  StructMessage struct_with_null_value = 203;\n  StructMessage struct_with_values = 204;\n  StructMessage struct_with_nested_struct = 205;\n  StructMessage struct_with_nested_list = 206;\n  StructMessage struct_with_list_of_nulls = 207;\n  StructMessage struct_with_list_of_lists = 208;\n  StructMessage struct_with_list_of_structs = 209;\n  google.protobuf.Struct top_level_struct = 210;\n  ValueMessage value_wrapper_simple = 212;\n  ValueMessage value_wrapper_with_struct = 213;\n  ValueMessage value_wrapper_with_list = 214;\n  ListValueMessage list_value_wrapper = 215;\n  google.protobuf.Value top_level_value_simple = 216;\n  google.protobuf.Value top_level_value_with_struct = 217;\n  google.protobuf.Value top_level_value_with_list = 218;\n  google.protobuf.ListValue top_level_listvalue = 219;\n  AnyMessage empty_any = 301;\n  AnyMessage type_only_any = 302;\n  AnyMessage recursive_any = 303;\n  AnyMessage any_with_message_value = 304;\n  AnyMessage any_with_nested_message = 305;\n  AnyMessage any_with_message_containing_map = 306;\n  AnyMessage any_with_message_containing_struct = 307;\n  google.protobuf.Any top_level_any = 308;\n  StringtoIntMap empty_map = 401;\n  StringtoIntMap string_to_int = 402;\n  IntToStringMap int_to_string = 403;\n  MixedMap mixed1 = 404;\n  MixedMap2 mixed2 = 405;\n  MixedMap2 empty_mixed2 = 406;\n  MessageMap map_of_objects = 407;\n  MixedMap mixed_empty = 408;\n  MessageMap message_map_empty = 409;\n  DoubleValueMessage double_value = 501;\n  DoubleValueMessage double_value_default = 502;\n}\n\nmessage DoubleMessage {\n  double double_value = 1;\n  repeated double repeated_double = 2;\n  DoubleMessage nested_message = 3;\n  repeated DoubleMessage repeated_nested_message = 4;\n  google.protobuf.DoubleValue double_wrapper = 100;\n  oneof value {\n    string str_value = 112;\n    int64 num_value = 113;\n  }\n}\n\nmessage StructMessage {\n  google.protobuf.Struct struct = 1;\n}\n\nmessage ValueMessage {\n  google.protobuf.Value value = 1;\n}\n\nmessage ListValueMessage {\n  google.protobuf.ListValue shopping_list = 1;\n}\nmessage RequestMessage {\n  string content = 1;\n}\n\n// A test service.\nservice DefaultValueTestService {\n  // A test method.\n  rpc Call(RequestMessage) returns (DefaultValueTestCases);\n}\n\nmessage AnyMessage {\n  google.protobuf.Any any = 1;\n  AnyData data = 2;\n}\n\nmessage AnyData {\n  int32 attr = 1;\n  string str = 2;\n  repeated string msgs = 3;\n  AnyData nested_data = 4;\n  map<string, string> map_data = 7;\n  google.protobuf.Struct struct_data = 8;\n  repeated AnyData repeated_data = 9;\n}\n\nmessage StringtoIntMap {\n  map<string, int32> map = 1;\n}\n\nmessage IntToStringMap {\n  map<int32, string> map = 1;\n}\n\nmessage MixedMap {\n  string msg = 1;\n  map<string, float> map = 2;\n  int32 int_value = 3;\n}\n\nmessage MixedMap2 {\n  enum E {\n    E0 = 0;\n    E1 = 1;\n    E2 = 2;\n    E3 = 3;\n  }\n  map<int32, bool> map = 1;\n  E ee = 2;\n  string msg = 4;\n}\n\nmessage MessageMap {\n  message M {\n    int32 inner_int = 1;\n    string inner_text = 2;\n  }\n  map<string, M> map = 1;\n}\n\nmessage DoubleValueMessage {\n  google.protobuf.DoubleValue double = 1;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/testdata/default_value_test.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto3\";\n\npackage google.protobuf.testing;\n\nmessage DefaultValueTest {\n  double double_value = 1;\n  repeated double repeated_double = 2;\n  float float_value = 3;\n  int64 int64_value = 5;\n  uint64 uint64_value = 7;\n  int32 int32_value = 9;\n  uint32 uint32_value = 11;\n  bool bool_value = 13;\n  string string_value = 15;\n  bytes bytes_value = 17 [ctype = CORD];\n\n  enum EnumDefault {\n    ENUM_FIRST = 0;\n    ENUM_SECOND = 1;\n    ENUM_THIRD = 2;\n  }\n  EnumDefault enum_value = 18;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/testdata/field_mask.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto3\";\n\npackage google.protobuf.testing;\n\nimport \"google/protobuf/field_mask.proto\";\n\nmessage NestedFieldMask {\n  string data = 1;\n  google.protobuf.FieldMask single_mask = 2;\n  repeated google.protobuf.FieldMask repeated_mask = 3;\n}\n\nmessage FieldMaskTest {\n  string id = 1;\n  google.protobuf.FieldMask single_mask = 2;\n  repeated google.protobuf.FieldMask repeated_mask = 3;\n  repeated NestedFieldMask nested_mask = 4;\n}\n\nmessage FieldMaskTestCases {\n  FieldMaskWrapper single_mask = 1;\n  FieldMaskWrapper multiple_mask = 2;\n  FieldMaskWrapper snake_camel = 3;\n  FieldMaskWrapper empty_field = 4;\n  FieldMaskWrapper apiary_format1 = 5;\n  FieldMaskWrapper apiary_format2 = 6;\n  FieldMaskWrapper apiary_format3 = 7;\n  FieldMaskWrapper map_key1 = 8;\n  FieldMaskWrapper map_key2 = 9;\n  FieldMaskWrapper map_key3 = 10;\n  FieldMaskWrapper map_key4 = 11;\n  FieldMaskWrapper map_key5 = 12;\n}\n\nmessage FieldMaskWrapper {\n  google.protobuf.FieldMask mask = 1;\n}\n\nservice FieldMaskTestService {\n  rpc Call(FieldMaskTestCases) returns (FieldMaskTestCases);\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/testdata/maps.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Proto to test proto3 maps.\nsyntax = \"proto3\";\n\npackage google.protobuf.testing.maps;\noption java_package = \"com.google.protobuf.testing.maps\";\n\nmessage MapIn {\n  string other = 1;\n  repeated string things = 2;\n  map<string, string> map_input = 3;\n}\n\nmessage MapOut {\n  map<string, MapM> map1 = 1;\n  map<string, MapOut> map2 = 2;\n  map<int32, string> map3 = 3;\n  map<bool, string> map4 = 5;\n  string bar = 4;\n}\n\n// A message with exactly the same wire representation as MapOut, but using\n// repeated message fields instead of map fields. We use this message to test\n// the wire-format compatibility of the JSON transcoder (e.g., whether it\n// handles missing keys correctly).\nmessage MapOutWireFormat {\n  message Map1Entry {\n    string key = 1;\n    MapM value = 2;\n  }\n  repeated Map1Entry map1 = 1;\n  message Map2Entry {\n    string key = 1;\n    MapOut value = 2;\n  }\n  repeated Map2Entry map2 = 2;\n  message Map3Entry {\n    int32 key = 1;\n    string value = 2;\n  }\n  repeated Map3Entry map3 = 3;\n  message Map4Entry {\n    bool key = 1;\n    string value = 2;\n  }\n  repeated Map4Entry map4 = 5;\n  string bar = 4;\n}\n\nmessage MapM {\n  string foo = 1;\n}\n\nservice TestService {\n  rpc Call1(MapIn) returns (MapOut);\n  rpc Call2(MapIn) returns (MapOut);\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/testdata/oneofs.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Proto to test oneofs.\nsyntax = \"proto3\";\n\nimport \"google/protobuf/any.proto\";\nimport \"google/protobuf/struct.proto\";\nimport \"google/protobuf/timestamp.proto\";\n\npackage google.protobuf.testing.oneofs;\noption java_package = \"com.google.protobuf.testing.oneofs\";\n\nmessage OneOfsRequest {\n  string value = 1;\n  oneof data {\n    string str_data = 2;\n    int32 int_data = 3;\n    // Simple message\n    Data message_data = 4;\n    // Well known types\n    google.protobuf.Struct struct_data = 5;\n    google.protobuf.Value value_data = 6;\n    google.protobuf.ListValue list_value_data = 7;\n    google.protobuf.Timestamp ts_data = 8;\n  }\n  google.protobuf.Any any_data = 19;\n}\n\nmessage Data {\n  int32 data_value = 1;\n}\n\nmessage Response {\n  string value = 1;\n}\n\nservice TestService {\n  // Test call.\n  rpc Call(OneOfsRequest) returns (Response);\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/testdata/struct.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Proto to test proto3 struct.\nsyntax = \"proto3\";\n\npackage google.protobuf.testing.structs;\noption java_package = \"com.google.protobuf.testing.structs\";\n\nimport \"google/protobuf/struct.proto\";\n\nmessage StructType {\n  google.protobuf.Struct object = 1;\n}\n\nservice TestService {\n  rpc Call(StructType) returns (StructType);\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/testdata/timestamp_duration.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Proto to test proto3 Timestamp and Duration.\nsyntax = \"proto3\";\n\npackage google.protobuf.testing.timestampduration;\noption java_package = \"com.google.protobuf.testing.timestampduration\";\n\nimport \"google/protobuf/timestamp.proto\";\nimport \"google/protobuf/duration.proto\";\n\nmessage TimestampDuration {\n  google.protobuf.Timestamp ts = 1;\n  google.protobuf.Duration dur = 2;\n}\n\nservice TestService {\n  rpc Call(TimestampDuration) returns (TimestampDuration);\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/type_info.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/internal/type_info.h>\n\n#include <map>\n#include <set>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/type.pb.h>\n#include <google/protobuf/util/internal/utility.h>\n#include <google/protobuf/stubs/stringpiece.h>\n#include <google/protobuf/stubs/map_util.h>\n#include <google/protobuf/stubs/status.h>\n#include <google/protobuf/stubs/statusor.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\nnamespace {\n// A TypeInfo that looks up information provided by a TypeResolver.\nclass TypeInfoForTypeResolver : public TypeInfo {\n public:\n  explicit TypeInfoForTypeResolver(TypeResolver* type_resolver)\n      : type_resolver_(type_resolver) {}\n\n  virtual ~TypeInfoForTypeResolver() {\n    DeleteCachedTypes(&cached_types_);\n    DeleteCachedTypes(&cached_enums_);\n  }\n\n  virtual util::StatusOr<const google::protobuf::Type*> ResolveTypeUrl(\n      StringPiece type_url) const {\n    map<StringPiece, StatusOrType>::iterator it = cached_types_.find(type_url);\n    if (it != cached_types_.end()) {\n      return it->second;\n    }\n    // Stores the string value so it can be referenced using StringPiece in the\n    // cached_types_ map.\n    const string& string_type_url =\n        *string_storage_.insert(type_url.ToString()).first;\n    google::protobuf::scoped_ptr<google::protobuf::Type> type(new google::protobuf::Type());\n    util::Status status =\n        type_resolver_->ResolveMessageType(string_type_url, type.get());\n    StatusOrType result =\n        status.ok() ? StatusOrType(type.release()) : StatusOrType(status);\n    cached_types_[string_type_url] = result;\n    return result;\n  }\n\n  virtual const google::protobuf::Type* GetTypeByTypeUrl(\n      StringPiece type_url) const {\n    StatusOrType result = ResolveTypeUrl(type_url);\n    return result.ok() ? result.ValueOrDie() : NULL;\n  }\n\n  virtual const google::protobuf::Enum* GetEnumByTypeUrl(\n      StringPiece type_url) const {\n    map<StringPiece, StatusOrEnum>::iterator it = cached_enums_.find(type_url);\n    if (it != cached_enums_.end()) {\n      return it->second.ok() ? it->second.ValueOrDie() : NULL;\n    }\n    // Stores the string value so it can be referenced using StringPiece in the\n    // cached_enums_ map.\n    const string& string_type_url =\n        *string_storage_.insert(type_url.ToString()).first;\n    google::protobuf::scoped_ptr<google::protobuf::Enum> enum_type(\n        new google::protobuf::Enum());\n    util::Status status =\n        type_resolver_->ResolveEnumType(string_type_url, enum_type.get());\n    StatusOrEnum result =\n        status.ok() ? StatusOrEnum(enum_type.release()) : StatusOrEnum(status);\n    cached_enums_[string_type_url] = result;\n    return result.ok() ? result.ValueOrDie() : NULL;\n  }\n\n  virtual const google::protobuf::Field* FindField(\n      const google::protobuf::Type* type, StringPiece camel_case_name) const {\n    if (indexed_types_.find(type) == indexed_types_.end()) {\n      PopulateNameLookupTable(type);\n      indexed_types_.insert(type);\n    }\n    StringPiece name =\n        FindWithDefault(camel_case_name_table_, camel_case_name, StringPiece());\n    if (name.empty()) {\n      // Didn't find a mapping. Use whatever provided.\n      name = camel_case_name;\n    }\n    return FindFieldInTypeOrNull(type, name);\n  }\n\n private:\n  typedef util::StatusOr<const google::protobuf::Type*> StatusOrType;\n  typedef util::StatusOr<const google::protobuf::Enum*> StatusOrEnum;\n\n  template <typename T>\n  static void DeleteCachedTypes(map<StringPiece, T>* cached_types) {\n    for (typename map<StringPiece, T>::iterator it = cached_types->begin();\n         it != cached_types->end(); ++it) {\n      if (it->second.ok()) {\n        delete it->second.ValueOrDie();\n      }\n    }\n  }\n\n  void PopulateNameLookupTable(const google::protobuf::Type* type) const {\n    for (int i = 0; i < type->fields_size(); ++i) {\n      const google::protobuf::Field& field = type->fields(i);\n      StringPiece name = field.name();\n      StringPiece camel_case_name = field.json_name();\n      const StringPiece* existing = InsertOrReturnExisting(\n          &camel_case_name_table_, camel_case_name, name);\n      if (existing && *existing != name) {\n        GOOGLE_LOG(WARNING) << \"Field '\" << name << \"' and '\" << *existing\n                     << \"' map to the same camel case name '\" << camel_case_name\n                     << \"'.\";\n      }\n    }\n  }\n\n  TypeResolver* type_resolver_;\n\n  // Stores string values that will be referenced by StringPieces in\n  // cached_types_, cached_enums_ and camel_case_name_table_.\n  mutable set<string> string_storage_;\n\n  mutable map<StringPiece, StatusOrType> cached_types_;\n  mutable map<StringPiece, StatusOrEnum> cached_enums_;\n\n  mutable set<const google::protobuf::Type*> indexed_types_;\n  mutable map<StringPiece, StringPiece> camel_case_name_table_;\n};\n}  // namespace\n\nTypeInfo* TypeInfo::NewTypeInfo(TypeResolver* type_resolver) {\n  return new TypeInfoForTypeResolver(type_resolver);\n}\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/type_info.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_H__\n#define GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_H__\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/type.pb.h>\n#include <google/protobuf/util/type_resolver.h>\n#include <google/protobuf/stubs/stringpiece.h>\n#include <google/protobuf/stubs/status.h>\n#include <google/protobuf/stubs/statusor.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n// Internal helper class for type resolving. Note that this class is not\n// thread-safe and should only be accessed in one thread.\nclass LIBPROTOBUF_EXPORT TypeInfo {\n public:\n  TypeInfo() {}\n  virtual ~TypeInfo() {}\n\n  // Resolves a type url into a Type. If the type url is invalid, returns\n  // INVALID_ARGUMENT error status. If the type url is valid but the\n  // corresponding type cannot be found, returns a NOT_FOUND error status.\n  //\n  // This TypeInfo class retains the ownership of the returned pointer.\n  virtual util::StatusOr<const google::protobuf::Type*> ResolveTypeUrl(\n      StringPiece type_url) const = 0;\n\n  // Resolves a type url into a Type. Like ResolveTypeUrl() but returns\n  // NULL if the type url is invalid or the type cannot be found.\n  //\n  // This TypeInfo class retains the ownership of the returned pointer.\n  virtual const google::protobuf::Type* GetTypeByTypeUrl(\n      StringPiece type_url) const = 0;\n\n  // Resolves a type url for an enum. Returns NULL if the type url is\n  // invalid or the type cannot be found.\n  //\n  // This TypeInfo class retains the ownership of the returned pointer.\n  virtual const google::protobuf::Enum* GetEnumByTypeUrl(\n      StringPiece type_url) const = 0;\n\n  // Looks up a field in the specified type given a CamelCase name.\n  virtual const google::protobuf::Field* FindField(\n      const google::protobuf::Type* type,\n      StringPiece camel_case_name) const = 0;\n\n  // Creates a TypeInfo object that looks up type information from a\n  // TypeResolver. Caller takes ownership of the returned pointer.\n  static TypeInfo* NewTypeInfo(TypeResolver* type_resolver);\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeInfo);\n};\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/type_info_test_helper.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/internal/type_info_test_helper.h>\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <vector>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/util/internal/default_value_objectwriter.h>\n#include <google/protobuf/util/internal/type_info.h>\n#include <google/protobuf/util/internal/constants.h>\n#include <google/protobuf/util/internal/protostream_objectsource.h>\n#include <google/protobuf/util/internal/protostream_objectwriter.h>\n#include <google/protobuf/util/type_resolver.h>\n#include <google/protobuf/util/type_resolver_util.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\nnamespace testing {\n\n\nvoid TypeInfoTestHelper::ResetTypeInfo(\n    const vector<const Descriptor*>& descriptors) {\n  switch (type_) {\n    case USE_TYPE_RESOLVER: {\n      const DescriptorPool* pool = descriptors[0]->file()->pool();\n      for (int i = 1; i < descriptors.size(); ++i) {\n        GOOGLE_CHECK(pool == descriptors[i]->file()->pool())\n            << \"Descriptors from different pools are not supported.\";\n      }\n      type_resolver_.reset(\n          NewTypeResolverForDescriptorPool(kTypeServiceBaseUrl, pool));\n      typeinfo_.reset(TypeInfo::NewTypeInfo(type_resolver_.get()));\n      return;\n    }\n  }\n  GOOGLE_LOG(FATAL) << \"Can not reach here.\";\n}\n\nvoid TypeInfoTestHelper::ResetTypeInfo(const Descriptor* descriptor) {\n  vector<const Descriptor*> descriptors;\n  descriptors.push_back(descriptor);\n  ResetTypeInfo(descriptors);\n}\n\nvoid TypeInfoTestHelper::ResetTypeInfo(const Descriptor* descriptor1,\n                                       const Descriptor* descriptor2) {\n  vector<const Descriptor*> descriptors;\n  descriptors.push_back(descriptor1);\n  descriptors.push_back(descriptor2);\n  ResetTypeInfo(descriptors);\n}\n\nTypeInfo* TypeInfoTestHelper::GetTypeInfo() { return typeinfo_.get(); }\n\nProtoStreamObjectSource* TypeInfoTestHelper::NewProtoSource(\n    io::CodedInputStream* coded_input, const string& type_url) {\n  const google::protobuf::Type* type = typeinfo_->GetTypeByTypeUrl(type_url);\n  switch (type_) {\n    case USE_TYPE_RESOLVER: {\n      return new ProtoStreamObjectSource(coded_input, type_resolver_.get(),\n                                         *type);\n    }\n  }\n  GOOGLE_LOG(FATAL) << \"Can not reach here.\";\n  return NULL;\n}\n\nProtoStreamObjectWriter* TypeInfoTestHelper::NewProtoWriter(\n    const string& type_url, strings::ByteSink* output, ErrorListener* listener,\n    const ProtoStreamObjectWriter::Options& options) {\n  const google::protobuf::Type* type = typeinfo_->GetTypeByTypeUrl(type_url);\n  switch (type_) {\n    case USE_TYPE_RESOLVER: {\n      return new ProtoStreamObjectWriter(type_resolver_.get(), *type, output,\n                                         listener, options);\n    }\n  }\n  GOOGLE_LOG(FATAL) << \"Can not reach here.\";\n  return NULL;\n}\n\nDefaultValueObjectWriter* TypeInfoTestHelper::NewDefaultValueWriter(\n    const string& type_url, ObjectWriter* writer) {\n  const google::protobuf::Type* type = typeinfo_->GetTypeByTypeUrl(type_url);\n  switch (type_) {\n    case USE_TYPE_RESOLVER: {\n      return new DefaultValueObjectWriter(type_resolver_.get(), *type, writer);\n    }\n  }\n  GOOGLE_LOG(FATAL) << \"Can not reach here.\";\n  return NULL;\n}\n\n}  // namespace testing\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/type_info_test_helper.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_TEST_HELPER_H__\n#define GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_TEST_HELPER_H__\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <vector>\n\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/util/internal/default_value_objectwriter.h>\n#include <google/protobuf/util/internal/type_info.h>\n#include <google/protobuf/util/internal/protostream_objectsource.h>\n#include <google/protobuf/util/internal/protostream_objectwriter.h>\n#include <google/protobuf/util/type_resolver.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\nnamespace testing {\n\nenum TypeInfoSource {\n  USE_TYPE_RESOLVER,\n};\n\n// In the unit-tests we want to test two scenarios: one with type info from\n// ServiceTypeInfo, the other with type info from TypeResolver. This class\n// wraps the detail of where the type info is from and provides the same\n// interface so the same unit-test code can test both scenarios.\nclass TypeInfoTestHelper {\n public:\n  explicit TypeInfoTestHelper(TypeInfoSource type) : type_(type) {}\n\n  // Creates a TypeInfo object for the given set of descriptors.\n  void ResetTypeInfo(const vector<const Descriptor*>& descriptors);\n\n  // Convinent overloads.\n  void ResetTypeInfo(const Descriptor* descriptor);\n  void ResetTypeInfo(const Descriptor* descriptor1,\n                     const Descriptor* descriptor2);\n\n  // Returns the TypeInfo created after ResetTypeInfo.\n  TypeInfo* GetTypeInfo();\n\n  ProtoStreamObjectSource* NewProtoSource(io::CodedInputStream* coded_input,\n                                          const string& type_url);\n\n  ProtoStreamObjectWriter* NewProtoWriter(\n      const string& type_url, strings::ByteSink* output,\n      ErrorListener* listener, const ProtoStreamObjectWriter::Options& options);\n\n  DefaultValueObjectWriter* NewDefaultValueWriter(const string& type_url,\n                                                  ObjectWriter* writer);\n\n private:\n  TypeInfoSource type_;\n  google::protobuf::scoped_ptr<TypeInfo> typeinfo_;\n  google::protobuf::scoped_ptr<TypeResolver> type_resolver_;\n};\n}  // namespace testing\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_CONVERTER_TYPE_INFO_TEST_HELPER_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/utility.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/internal/utility.h>\n\n#include <google/protobuf/stubs/callback.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/wrappers.pb.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/util/internal/constants.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/map_util.h>\n#include <google/protobuf/stubs/mathlimits.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\nnamespace {\nconst StringPiece SkipWhiteSpace(StringPiece str) {\n  StringPiece::size_type i;\n  for (i = 0; i < str.size() && isspace(str[i]); ++i) {\n  }\n  GOOGLE_DCHECK(i == str.size() || !isspace(str[i]));\n  return str.substr(i);\n}\n}  // namespace\n\nbool GetBoolOptionOrDefault(\n    const google::protobuf::RepeatedPtrField<google::protobuf::Option>& options,\n    const string& option_name, bool default_value) {\n  const google::protobuf::Option* opt = FindOptionOrNull(options, option_name);\n  if (opt == NULL) {\n    return default_value;\n  }\n  return GetBoolFromAny(opt->value());\n}\n\nint64 GetInt64OptionOrDefault(\n    const google::protobuf::RepeatedPtrField<google::protobuf::Option>& options,\n    const string& option_name, int64 default_value) {\n  const google::protobuf::Option* opt = FindOptionOrNull(options, option_name);\n  if (opt == NULL) {\n    return default_value;\n  }\n  return GetInt64FromAny(opt->value());\n}\n\ndouble GetDoubleOptionOrDefault(\n    const google::protobuf::RepeatedPtrField<google::protobuf::Option>& options,\n    const string& option_name, double default_value) {\n  const google::protobuf::Option* opt = FindOptionOrNull(options, option_name);\n  if (opt == NULL) {\n    return default_value;\n  }\n  return GetDoubleFromAny(opt->value());\n}\n\nstring GetStringOptionOrDefault(\n    const google::protobuf::RepeatedPtrField<google::protobuf::Option>& options,\n    const string& option_name, const string& default_value) {\n  const google::protobuf::Option* opt = FindOptionOrNull(options, option_name);\n  if (opt == NULL) {\n    return default_value;\n  }\n  return GetStringFromAny(opt->value());\n}\n\ntemplate <typename T>\nvoid ParseFromAny(const string& data, T* result) {\n  result->ParseFromString(data);\n}\n\n// Returns a boolean value contained in Any type.\n// TODO(skarvaje): Add type checking & error messages here.\nbool GetBoolFromAny(const google::protobuf::Any& any) {\n  google::protobuf::BoolValue b;\n  ParseFromAny(any.value(), &b);\n  return b.value();\n}\n\nint64 GetInt64FromAny(const google::protobuf::Any& any) {\n  google::protobuf::Int64Value i;\n  ParseFromAny(any.value(), &i);\n  return i.value();\n}\n\ndouble GetDoubleFromAny(const google::protobuf::Any& any) {\n  google::protobuf::DoubleValue i;\n  ParseFromAny(any.value(), &i);\n  return i.value();\n}\n\nstring GetStringFromAny(const google::protobuf::Any& any) {\n  google::protobuf::StringValue s;\n  ParseFromAny(any.value(), &s);\n  return s.value();\n}\n\nconst StringPiece GetTypeWithoutUrl(StringPiece type_url) {\n  if (type_url.size() > kTypeUrlSize && type_url[kTypeUrlSize] == '/') {\n    return type_url.substr(kTypeUrlSize + 1);\n  } else {\n    size_t idx = type_url.rfind('/');\n    return type_url.substr(idx + 1);\n  }\n}\n\nconst string GetFullTypeWithUrl(StringPiece simple_type) {\n  return StrCat(kTypeServiceBaseUrl, \"/\", simple_type);\n}\n\nconst google::protobuf::Option* FindOptionOrNull(\n    const google::protobuf::RepeatedPtrField<google::protobuf::Option>& options,\n    const string& option_name) {\n  for (int i = 0; i < options.size(); ++i) {\n    const google::protobuf::Option& opt = options.Get(i);\n    if (opt.name() == option_name) {\n      return &opt;\n    }\n  }\n  return NULL;\n}\n\nconst google::protobuf::Field* FindFieldInTypeOrNull(\n    const google::protobuf::Type* type, StringPiece field_name) {\n  if (type != NULL) {\n    for (int i = 0; i < type->fields_size(); ++i) {\n      const google::protobuf::Field& field = type->fields(i);\n      if (field.name() == field_name) {\n        return &field;\n      }\n    }\n  }\n  return NULL;\n}\n\nconst google::protobuf::Field* FindJsonFieldInTypeOrNull(\n    const google::protobuf::Type* type, StringPiece json_name) {\n  if (type != NULL) {\n    for (int i = 0; i < type->fields_size(); ++i) {\n      const google::protobuf::Field& field = type->fields(i);\n      if (field.json_name() == json_name) {\n        return &field;\n      }\n    }\n  }\n  return NULL;\n}\n\nconst google::protobuf::EnumValue* FindEnumValueByNameOrNull(\n    const google::protobuf::Enum* enum_type, StringPiece enum_name) {\n  if (enum_type != NULL) {\n    for (int i = 0; i < enum_type->enumvalue_size(); ++i) {\n      const google::protobuf::EnumValue& enum_value = enum_type->enumvalue(i);\n      if (enum_value.name() == enum_name) {\n        return &enum_value;\n      }\n    }\n  }\n  return NULL;\n}\n\nconst google::protobuf::EnumValue* FindEnumValueByNumberOrNull(\n    const google::protobuf::Enum* enum_type, int32 value) {\n  if (enum_type != NULL) {\n    for (int i = 0; i < enum_type->enumvalue_size(); ++i) {\n      const google::protobuf::EnumValue& enum_value = enum_type->enumvalue(i);\n      if (enum_value.number() == value) {\n        return &enum_value;\n      }\n    }\n  }\n  return NULL;\n}\n\nstring ToCamelCase(const StringPiece input) {\n  bool capitalize_next = false;\n  bool was_cap = true;\n  bool is_cap = false;\n  bool first_word = true;\n  string result;\n  result.reserve(input.size());\n\n  for (size_t i = 0; i < input.size(); ++i, was_cap = is_cap) {\n    is_cap = ascii_isupper(input[i]);\n    if (input[i] == '_') {\n      capitalize_next = true;\n      if (!result.empty()) first_word = false;\n      continue;\n    } else if (first_word) {\n      // Consider when the current character B is capitalized,\n      // first word ends when:\n      // 1) following a lowercase:   \"...aB...\"\n      // 2) followed by a lowercase: \"...ABc...\"\n      if (!result.empty() && is_cap &&\n          (!was_cap || (i + 1 < input.size() && ascii_islower(input[i + 1])))) {\n        first_word = false;\n        result.push_back(input[i]);\n      } else {\n        result.push_back(ascii_tolower(input[i]));\n        continue;\n      }\n    } else if (capitalize_next) {\n      capitalize_next = false;\n      if (ascii_islower(input[i])) {\n        result.push_back(ascii_toupper(input[i]));\n        continue;\n      } else {\n        result.push_back(input[i]);\n        continue;\n      }\n    } else {\n      result.push_back(ascii_tolower(input[i]));\n    }\n  }\n  return result;\n}\n\nstring ToSnakeCase(StringPiece input) {\n  bool was_not_underscore = false;  // Initialize to false for case 1 (below)\n  bool was_not_cap = false;\n  string result;\n  result.reserve(input.size() << 1);\n\n  for (size_t i = 0; i < input.size(); ++i) {\n    if (ascii_isupper(input[i])) {\n      // Consider when the current character B is capitalized:\n      // 1) At beginning of input:   \"B...\" => \"b...\"\n      //    (e.g. \"Biscuit\" => \"biscuit\")\n      // 2) Following a lowercase:   \"...aB...\" => \"...a_b...\"\n      //    (e.g. \"gBike\" => \"g_bike\")\n      // 3) At the end of input:     \"...AB\" => \"...ab\"\n      //    (e.g. \"GoogleLAB\" => \"google_lab\")\n      // 4) Followed by a lowercase: \"...ABc...\" => \"...a_bc...\"\n      //    (e.g. \"GBike\" => \"g_bike\")\n      if (was_not_underscore &&               //            case 1 out\n          (was_not_cap ||                     // case 2 in, case 3 out\n           (i + 1 < input.size() &&           //            case 3 out\n            ascii_islower(input[i + 1])))) {  // case 4 in\n        // We add an underscore for case 2 and case 4.\n        result.push_back('_');\n      }\n      result.push_back(ascii_tolower(input[i]));\n      was_not_underscore = true;\n      was_not_cap = false;\n    } else {\n      result.push_back(input[i]);\n      was_not_underscore = input[i] != '_';\n      was_not_cap = true;\n    }\n  }\n  return result;\n}\n\nset<string>* well_known_types_ = NULL;\nGOOGLE_PROTOBUF_DECLARE_ONCE(well_known_types_init_);\nconst char* well_known_types_name_array_[] = {\n    \"google.protobuf.Timestamp\",   \"google.protobuf.Duration\",\n    \"google.protobuf.DoubleValue\", \"google.protobuf.FloatValue\",\n    \"google.protobuf.Int64Value\",  \"google.protobuf.UInt64Value\",\n    \"google.protobuf.Int32Value\",  \"google.protobuf.UInt32Value\",\n    \"google.protobuf.BoolValue\",   \"google.protobuf.StringValue\",\n    \"google.protobuf.BytesValue\",  \"google.protobuf.FieldMask\"};\n\nvoid DeleteWellKnownTypes() { delete well_known_types_; }\n\nvoid InitWellKnownTypes() {\n  well_known_types_ = new set<string>;\n  for (int i = 0; i < GOOGLE_ARRAYSIZE(well_known_types_name_array_); ++i) {\n    well_known_types_->insert(well_known_types_name_array_[i]);\n  }\n  google::protobuf::internal::OnShutdown(&DeleteWellKnownTypes);\n}\n\nbool IsWellKnownType(const string& type_name) {\n  InitWellKnownTypes();\n  return ContainsKey(*well_known_types_, type_name);\n}\n\nbool IsValidBoolString(const string& bool_string) {\n  return bool_string == \"true\" || bool_string == \"false\" ||\n         bool_string == \"1\" || bool_string == \"0\";\n}\n\nbool IsMap(const google::protobuf::Field& field,\n           const google::protobuf::Type& type) {\n  return (field.cardinality() ==\n              google::protobuf::Field_Cardinality_CARDINALITY_REPEATED &&\n          GetBoolOptionOrDefault(type.options(),\n                                 \"google.protobuf.MessageOptions.map_entry\", false));\n}\n\nbool IsMessageSetWireFormat(const google::protobuf::Type& type) {\n  return GetBoolOptionOrDefault(\n      type.options(), \"google.protobuf.MessageOptions.message_set_wire_format\", false);\n}\n\nstring DoubleAsString(double value) {\n  if (MathLimits<double>::IsPosInf(value)) return \"Infinity\";\n  if (MathLimits<double>::IsNegInf(value)) return \"-Infinity\";\n  if (MathLimits<double>::IsNaN(value)) return \"NaN\";\n\n  return SimpleDtoa(value);\n}\n\nstring FloatAsString(float value) {\n  if (MathLimits<float>::IsFinite(value)) return SimpleFtoa(value);\n  return DoubleAsString(value);\n}\n\nbool SafeStrToFloat(StringPiece str, float* value) {\n  double double_value;\n  if (!safe_strtod(str, &double_value)) {\n    return false;\n  }\n\n  if (MathLimits<double>::IsInf(double_value) ||\n      MathLimits<double>::IsNaN(double_value))\n    return false;\n\n  // Fail if the value is not representable in float.\n  if (double_value > std::numeric_limits<float>::max() ||\n      double_value < -std::numeric_limits<float>::max()) {\n    return false;\n  }\n\n  *value = static_cast<float>(double_value);\n  return true;\n}\n\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/internal/utility.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_UTILITY_H__\n#define GOOGLE_PROTOBUF_UTIL_CONVERTER_UTILITY_H__\n\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <string>\n#include <utility>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/type.pb.h>\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/stubs/stringpiece.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/status.h>\n#include <google/protobuf/stubs/statusor.h>\n\n\nnamespace google {\nnamespace protobuf {\nclass Method;\nclass Any;\nclass Bool;\nclass Option;\nclass Field;\nclass Type;\nclass Enum;\nclass EnumValue;\n}  // namespace protobuf\n\n\nnamespace protobuf {\nnamespace util {\nnamespace converter {\n\n// Size of \"type.googleapis.com\"\nstatic const int64 kTypeUrlSize = 19;\n\n// Finds the tech option identified by option_name. Parses the boolean value and\n// returns it.\n// When the option with the given name is not found, default_value is returned.\nLIBPROTOBUF_EXPORT bool GetBoolOptionOrDefault(\n    const google::protobuf::RepeatedPtrField<google::protobuf::Option>& options,\n    const string& option_name, bool default_value);\n\n// Returns int64 option value. If the option isn't found, returns the\n// default_value.\nLIBPROTOBUF_EXPORT int64 GetInt64OptionOrDefault(\n    const google::protobuf::RepeatedPtrField<google::protobuf::Option>& options,\n    const string& option_name, int64 default_value);\n\n// Returns double option value. If the option isn't found, returns the\n// default_value.\nLIBPROTOBUF_EXPORT double GetDoubleOptionOrDefault(\n    const google::protobuf::RepeatedPtrField<google::protobuf::Option>& options,\n    const string& option_name, double default_value);\n\n// Returns string option value. If the option isn't found, returns the\n// default_value.\nLIBPROTOBUF_EXPORT string GetStringOptionOrDefault(\n    const google::protobuf::RepeatedPtrField<google::protobuf::Option>& options,\n    const string& option_name, const string& default_value);\n\n// Returns a boolean value contained in Any type.\n// TODO(skarvaje): Make these utilities dealing with Any types more generic,\n// add more error checking and move to a more public/sharable location so others\n// can use.\nLIBPROTOBUF_EXPORT bool GetBoolFromAny(const google::protobuf::Any& any);\n\n// Returns int64 value contained in Any type.\nLIBPROTOBUF_EXPORT int64 GetInt64FromAny(const google::protobuf::Any& any);\n\n// Returns double value contained in Any type.\nLIBPROTOBUF_EXPORT double GetDoubleFromAny(const google::protobuf::Any& any);\n\n// Returns string value contained in Any type.\nLIBPROTOBUF_EXPORT string GetStringFromAny(const google::protobuf::Any& any);\n\n// Returns the type string without the url prefix. e.g.: If the passed type is\n// 'type.googleapis.com/tech.type.Bool', the returned value is 'tech.type.Bool'.\nLIBPROTOBUF_EXPORT const StringPiece GetTypeWithoutUrl(StringPiece type_url);\n\n// Returns the simple_type with the base type url (kTypeServiceBaseUrl)\n// prefixed.\n//\n// E.g:\n// GetFullTypeWithUrl(\"google.protobuf.Timestamp\") returns the string\n// \"type.googleapis.com/google.protobuf.Timestamp\".\nLIBPROTOBUF_EXPORT const string GetFullTypeWithUrl(StringPiece simple_type);\n\n// Finds and returns option identified by name and option_name within the\n// provided map. Returns NULL if none found.\nconst google::protobuf::Option* FindOptionOrNull(\n    const google::protobuf::RepeatedPtrField<google::protobuf::Option>& options,\n    const string& option_name);\n\n// Finds and returns the field identified by field_name in the passed tech Type\n// object. Returns NULL if none found.\nconst google::protobuf::Field* FindFieldInTypeOrNull(\n    const google::protobuf::Type* type, StringPiece field_name);\n\n// Similar to FindFieldInTypeOrNull, but this looks up fields with given\n// json_name.\nconst google::protobuf::Field* FindJsonFieldInTypeOrNull(\n    const google::protobuf::Type* type, StringPiece json_name);\n\n// Finds and returns the EnumValue identified by enum_name in the passed tech\n// Enum object. Returns NULL if none found.\nconst google::protobuf::EnumValue* FindEnumValueByNameOrNull(\n    const google::protobuf::Enum* enum_type, StringPiece enum_name);\n\n// Finds and returns the EnumValue identified by value in the passed tech\n// Enum object. Returns NULL if none found.\nconst google::protobuf::EnumValue* FindEnumValueByNumberOrNull(\n    const google::protobuf::Enum* enum_type, int32 value);\n\n// Converts input to camel-case and returns it.\nLIBPROTOBUF_EXPORT string ToCamelCase(const StringPiece input);\n\n// Converts input to snake_case and returns it.\nLIBPROTOBUF_EXPORT string ToSnakeCase(StringPiece input);\n\n// Returns true if type_name represents a well-known type.\nLIBPROTOBUF_EXPORT bool IsWellKnownType(const string& type_name);\n\n// Returns true if 'bool_string' represents a valid boolean value. Only \"true\",\n// \"false\", \"0\" and \"1\" are allowed.\nLIBPROTOBUF_EXPORT bool IsValidBoolString(const string& bool_string);\n\n// Returns true if \"field\" is a protobuf map field based on its type.\nLIBPROTOBUF_EXPORT bool IsMap(const google::protobuf::Field& field,\n           const google::protobuf::Type& type);\n\n// Returns true if the given type has special MessageSet wire format.\nbool IsMessageSetWireFormat(const google::protobuf::Type& type);\n\n// Infinity/NaN-aware conversion to string.\nLIBPROTOBUF_EXPORT string DoubleAsString(double value);\nLIBPROTOBUF_EXPORT string FloatAsString(float value);\n\n// Convert from int32, int64, uint32, uint64, double or float to string.\ntemplate <typename T>\nstring ValueAsString(T value) {\n  return SimpleItoa(value);\n}\n\ntemplate <>\ninline string ValueAsString(float value) {\n  return FloatAsString(value);\n}\n\ntemplate <>\ninline string ValueAsString(double value) {\n  return DoubleAsString(value);\n}\n\n// Converts a string to float. Unlike safe_strtof, conversion will fail if the\n// value fits into double but not float (e.g., DBL_MAX).\nLIBPROTOBUF_EXPORT bool SafeStrToFloat(StringPiece str, float* value);\n}  // namespace converter\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_CONVERTER_UTILITY_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/json_format_proto3.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nsyntax = \"proto3\";\n\npackage proto3;\n\n\nimport \"google/protobuf/duration.proto\";\nimport \"google/protobuf/timestamp.proto\";\nimport \"google/protobuf/wrappers.proto\";\nimport \"google/protobuf/struct.proto\";\nimport \"google/protobuf/any.proto\";\nimport \"google/protobuf/field_mask.proto\";\nimport \"google/protobuf/unittest.proto\";\n\nenum EnumType {\n  FOO = 0;\n  BAR = 1;\n}\n\nmessage MessageType {\n  int32 value = 1;\n}\n\nmessage TestMessage {\n  bool bool_value = 1;\n  int32 int32_value = 2;\n  int64 int64_value = 3;\n  uint32 uint32_value = 4;\n  uint64 uint64_value = 5;\n  float float_value = 6;\n  double double_value = 7;\n  string string_value = 8;\n  bytes bytes_value = 9;\n  EnumType enum_value = 10;\n  MessageType message_value = 11;\n\n  repeated bool repeated_bool_value = 21;\n  repeated int32 repeated_int32_value = 22;\n  repeated int64 repeated_int64_value = 23;\n  repeated uint32 repeated_uint32_value = 24;\n  repeated uint64 repeated_uint64_value = 25;\n  repeated float repeated_float_value = 26;\n  repeated double repeated_double_value = 27;\n  repeated string repeated_string_value = 28;\n  repeated bytes repeated_bytes_value = 29;\n  repeated EnumType repeated_enum_value = 30;\n  repeated MessageType repeated_message_value = 31;\n}\n\nmessage TestOneof {\n  // In JSON format oneof fields behave mostly the same as optional\n  // fields except that:\n  //   1. Oneof fields have field presence information and will be\n  //      printed if it's set no matter whether it's the default value.\n  //   2. Multiple oneof fields in the same oneof cannot appear at the\n  //      same time in the input.\n  oneof oneof_value {\n    int32 oneof_int32_value = 1;\n    string oneof_string_value = 2;\n    bytes oneof_bytes_value = 3;\n    EnumType oneof_enum_value = 4;\n    MessageType oneof_message_value = 5;\n  }\n}\n\nmessage TestMap {\n  map<bool, int32> bool_map = 1;\n  map<int32, int32> int32_map = 2;\n  map<int64, int32> int64_map = 3;\n  map<uint32, int32> uint32_map = 4;\n  map<uint64, int32> uint64_map = 5;\n  map<string, int32> string_map = 6;\n}\n\nmessage TestNestedMap {\n  map<bool, int32> bool_map = 1;\n  map<int32, int32> int32_map = 2;\n  map<int64, int32> int64_map = 3;\n  map<uint32, int32> uint32_map = 4;\n  map<uint64, int32> uint64_map = 5;\n  map<string, int32> string_map = 6;\n  map<string, TestNestedMap> map_map = 7;\n}\n\nmessage TestWrapper {\n  google.protobuf.BoolValue bool_value = 1;\n  google.protobuf.Int32Value int32_value = 2;\n  google.protobuf.Int64Value int64_value = 3;\n  google.protobuf.UInt32Value uint32_value = 4;\n  google.protobuf.UInt64Value uint64_value = 5;\n  google.protobuf.FloatValue float_value = 6;\n  google.protobuf.DoubleValue double_value = 7;\n  google.protobuf.StringValue string_value = 8;\n  google.protobuf.BytesValue bytes_value = 9;\n\n  repeated google.protobuf.BoolValue repeated_bool_value = 11;\n  repeated google.protobuf.Int32Value repeated_int32_value = 12;\n  repeated google.protobuf.Int64Value repeated_int64_value = 13;\n  repeated google.protobuf.UInt32Value repeated_uint32_value = 14;\n  repeated google.protobuf.UInt64Value repeated_uint64_value = 15;\n  repeated google.protobuf.FloatValue repeated_float_value = 16;\n  repeated google.protobuf.DoubleValue repeated_double_value = 17;\n  repeated google.protobuf.StringValue repeated_string_value = 18;\n  repeated google.protobuf.BytesValue repeated_bytes_value = 19;\n}\n\nmessage TestTimestamp {\n  google.protobuf.Timestamp value = 1;\n  repeated google.protobuf.Timestamp repeated_value = 2;\n}\n\nmessage TestDuration {\n  google.protobuf.Duration value = 1;\n  repeated google.protobuf.Duration repeated_value = 2;\n}\n\nmessage TestFieldMask {\n  google.protobuf.FieldMask value = 1;\n}\n\nmessage TestStruct {\n  google.protobuf.Struct value = 1;\n  repeated google.protobuf.Struct repeated_value = 2;\n}\n\nmessage TestAny {\n  google.protobuf.Any value = 1;\n  repeated google.protobuf.Any repeated_value = 2;\n}\n\nmessage TestValue {\n  google.protobuf.Value value = 1;\n  repeated google.protobuf.Value repeated_value = 2;\n}\n\nmessage TestListValue {\n  google.protobuf.ListValue value = 1;\n  repeated google.protobuf.ListValue repeated_value = 2;\n}\n\nmessage TestBoolValue {\n  bool bool_value = 1;\n  map<bool, int32> bool_map = 2;\n}\n\nmessage TestCustomJsonName {\n  int32 value = 1 [json_name = \"@value\"];\n}\n\nmessage TestExtensions {\n  .protobuf_unittest.TestAllExtensions extensions = 1;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/json_util.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/json_util.h>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/util/internal/default_value_objectwriter.h>\n#include <google/protobuf/util/internal/error_listener.h>\n#include <google/protobuf/util/internal/json_objectwriter.h>\n#include <google/protobuf/util/internal/json_stream_parser.h>\n#include <google/protobuf/util/internal/protostream_objectsource.h>\n#include <google/protobuf/util/internal/protostream_objectwriter.h>\n#include <google/protobuf/util/type_resolver.h>\n#include <google/protobuf/util/type_resolver_util.h>\n#include <google/protobuf/stubs/bytestream.h>\n#include <google/protobuf/stubs/status_macros.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\n\nnamespace internal {\nvoid ZeroCopyStreamByteSink::Append(const char* bytes, size_t len) {\n  while (len > 0) {\n    void* buffer;\n    int length;\n    if (!stream_->Next(&buffer, &length)) {\n      // There isn't a way for ByteSink to report errors.\n      return;\n    }\n    if (len < length) {\n      memcpy(buffer, bytes, len);\n      stream_->BackUp(length - len);\n      break;\n    } else {\n      memcpy(buffer, bytes, length);\n      bytes += length;\n      len -= length;\n    }\n  }\n}\n}  // namespace internal\n\nutil::Status BinaryToJsonStream(TypeResolver* resolver,\n                                  const string& type_url,\n                                  io::ZeroCopyInputStream* binary_input,\n                                  io::ZeroCopyOutputStream* json_output,\n                                  const JsonPrintOptions& options) {\n  io::CodedInputStream in_stream(binary_input);\n  google::protobuf::Type type;\n  RETURN_IF_ERROR(resolver->ResolveMessageType(type_url, &type));\n  converter::ProtoStreamObjectSource proto_source(&in_stream, resolver, type);\n  io::CodedOutputStream out_stream(json_output);\n  converter::JsonObjectWriter json_writer(options.add_whitespace ? \" \" : \"\",\n                                          &out_stream);\n  if (options.always_print_primitive_fields) {\n    converter::DefaultValueObjectWriter default_value_writer(\n        resolver, type, &json_writer);\n    return proto_source.WriteTo(&default_value_writer);\n  } else {\n    return proto_source.WriteTo(&json_writer);\n  }\n}\n\nutil::Status BinaryToJsonString(TypeResolver* resolver,\n                                  const string& type_url,\n                                  const string& binary_input,\n                                  string* json_output,\n                                  const JsonPrintOptions& options) {\n  io::ArrayInputStream input_stream(binary_input.data(), binary_input.size());\n  io::StringOutputStream output_stream(json_output);\n  return BinaryToJsonStream(resolver, type_url, &input_stream, &output_stream,\n                            options);\n}\n\nnamespace {\nclass StatusErrorListener : public converter::ErrorListener {\n public:\n  StatusErrorListener() : status_(util::Status::OK) {}\n  virtual ~StatusErrorListener() {}\n\n  util::Status GetStatus() { return status_; }\n\n  virtual void InvalidName(const converter::LocationTrackerInterface& loc,\n                           StringPiece unknown_name, StringPiece message) {\n    status_ = util::Status(util::error::INVALID_ARGUMENT,\n                             loc.ToString() + \": \" + message.ToString());\n  }\n\n  virtual void InvalidValue(const converter::LocationTrackerInterface& loc,\n                            StringPiece type_name, StringPiece value) {\n    status_ =\n        util::Status(util::error::INVALID_ARGUMENT,\n                       loc.ToString() + \": invalid value \" + value.ToString() +\n                           \" for type \" + type_name.ToString());\n  }\n\n  virtual void MissingField(const converter::LocationTrackerInterface& loc,\n                            StringPiece missing_name) {\n    status_ = util::Status(\n        util::error::INVALID_ARGUMENT,\n        loc.ToString() + \": missing field \" + missing_name.ToString());\n  }\n\n private:\n  util::Status status_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StatusErrorListener);\n};\n}  // namespace\n\nutil::Status JsonToBinaryStream(TypeResolver* resolver,\n                                  const string& type_url,\n                                  io::ZeroCopyInputStream* json_input,\n                                  io::ZeroCopyOutputStream* binary_output,\n                                  const JsonParseOptions& options) {\n  google::protobuf::Type type;\n  RETURN_IF_ERROR(resolver->ResolveMessageType(type_url, &type));\n  internal::ZeroCopyStreamByteSink sink(binary_output);\n  StatusErrorListener listener;\n  converter::ProtoStreamObjectWriter::Options proto_writer_options;\n  proto_writer_options.ignore_unknown_fields = options.ignore_unknown_fields;\n  converter::ProtoStreamObjectWriter proto_writer(resolver, type, &sink,\n                                                  &listener,\n                                                  proto_writer_options);\n\n  converter::JsonStreamParser parser(&proto_writer);\n  const void* buffer;\n  int length;\n  while (json_input->Next(&buffer, &length)) {\n    if (length == 0) continue;\n    RETURN_IF_ERROR(\n        parser.Parse(StringPiece(static_cast<const char*>(buffer), length)));\n  }\n  RETURN_IF_ERROR(parser.FinishParse());\n\n  return listener.GetStatus();\n}\n\nutil::Status JsonToBinaryString(TypeResolver* resolver,\n                                  const string& type_url,\n                                  const string& json_input,\n                                  string* binary_output,\n                                  const JsonParseOptions& options) {\n  io::ArrayInputStream input_stream(json_input.data(), json_input.size());\n  io::StringOutputStream output_stream(binary_output);\n  return JsonToBinaryStream(\n      resolver, type_url, &input_stream, &output_stream, options);\n}\n\nnamespace {\nconst char* kTypeUrlPrefix = \"type.googleapis.com\";\nTypeResolver* generated_type_resolver_ = NULL;\nGOOGLE_PROTOBUF_DECLARE_ONCE(generated_type_resolver_init_);\n\nstring GetTypeUrl(const Message& message) {\n  return string(kTypeUrlPrefix) + \"/\" + message.GetDescriptor()->full_name();\n}\n\nvoid DeleteGeneratedTypeResolver() { delete generated_type_resolver_; }\n\nvoid InitGeneratedTypeResolver() {\n  generated_type_resolver_ = NewTypeResolverForDescriptorPool(\n      kTypeUrlPrefix, DescriptorPool::generated_pool());\n  ::google::protobuf::internal::OnShutdown(&DeleteGeneratedTypeResolver);\n}\n\nTypeResolver* GetGeneratedTypeResolver() {\n  ::google::protobuf::GoogleOnceInit(&generated_type_resolver_init_, &InitGeneratedTypeResolver);\n  return generated_type_resolver_;\n}\n}  // namespace\n\nutil::Status MessageToJsonString(const Message& message, string* output,\n                                   const JsonOptions& options) {\n  const DescriptorPool* pool = message.GetDescriptor()->file()->pool();\n  TypeResolver* resolver =\n      pool == DescriptorPool::generated_pool()\n          ? GetGeneratedTypeResolver()\n          : NewTypeResolverForDescriptorPool(kTypeUrlPrefix, pool);\n  util::Status result =\n      BinaryToJsonString(resolver, GetTypeUrl(message),\n                         message.SerializeAsString(), output, options);\n  if (pool != DescriptorPool::generated_pool()) {\n    delete resolver;\n  }\n  return result;\n}\n\nutil::Status JsonStringToMessage(const string& input, Message* message,\n                                   const JsonParseOptions& options) {\n  const DescriptorPool* pool = message->GetDescriptor()->file()->pool();\n  TypeResolver* resolver =\n      pool == DescriptorPool::generated_pool()\n          ? GetGeneratedTypeResolver()\n          : NewTypeResolverForDescriptorPool(kTypeUrlPrefix, pool);\n  string binary;\n  util::Status result = JsonToBinaryString(\n      resolver, GetTypeUrl(*message), input, &binary, options);\n  if (result.ok() && !message->ParseFromString(binary)) {\n    result =\n        util::Status(util::error::INVALID_ARGUMENT,\n                       \"JSON transcoder produced invalid protobuf output.\");\n  }\n  if (pool != DescriptorPool::generated_pool()) {\n    delete resolver;\n  }\n  return result;\n}\n\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/json_util.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Utility functions to convert between protobuf binary format and proto3 JSON\n// format.\n#ifndef GOOGLE_PROTOBUF_UTIL_JSON_UTIL_H__\n#define GOOGLE_PROTOBUF_UTIL_JSON_UTIL_H__\n\n#include <google/protobuf/message.h>\n#include <google/protobuf/util/type_resolver.h>\n#include <google/protobuf/stubs/bytestream.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace io {\nclass ZeroCopyInputStream;\nclass ZeroCopyOutputStream;\n}  // namespace io\nnamespace util {\n\nstruct JsonParseOptions {\n  // Whether to ignore unknown JSON fields during parsing\n  bool ignore_unknown_fields;\n\n  JsonParseOptions() : ignore_unknown_fields(false) {}\n};\n\nstruct JsonPrintOptions {\n  // Whether to add spaces, line breaks and indentation to make the JSON output\n  // easy to read.\n  bool add_whitespace;\n  // Whether to always print primitive fields. By default primitive fields with\n  // default values will be omitted in JSON joutput. For example, an int32 field\n  // set to 0 will be omitted. Set this flag to true will override the default\n  // behavior and print primitive fields regardless of their values.\n  bool always_print_primitive_fields;\n\n  JsonPrintOptions() : add_whitespace(false),\n                       always_print_primitive_fields(false) {\n  }\n};\n\n// DEPRECATED. Use JsonPrintOptions instead.\ntypedef JsonPrintOptions JsonOptions;\n\n// Converts from protobuf message to JSON. This is a simple wrapper of\n// BinaryToJsonString(). It will use the DescriptorPool of the passed-in\n// message to resolve Any types.\nLIBPROTOBUF_EXPORT util::Status MessageToJsonString(const Message& message,\n                                   string* output,\n                                   const JsonOptions& options);\n\ninline util::Status MessageToJsonString(const Message& message,\n                                          string* output) {\n  return MessageToJsonString(message, output, JsonOptions());\n}\n\n// Converts from JSON to protobuf message. This is a simple wrapper of\n// JsonStringToBinary(). It will use the DescriptorPool of the passed-in\n// message to resolve Any types.\nLIBPROTOBUF_EXPORT util::Status JsonStringToMessage(const string& input,\n                                   Message* message,\n                                   const JsonParseOptions& options);\n\ninline util::Status JsonStringToMessage(const string& input,\n                                          Message* message) {\n  return JsonStringToMessage(input, message, JsonParseOptions());\n}\n\n// Converts protobuf binary data to JSON.\n// The conversion will fail if:\n//   1. TypeResolver fails to resolve a type.\n//   2. input is not valid protobuf wire format, or conflicts with the type\n//      information returned by TypeResolver.\n// Note that unknown fields will be discarded silently.\nLIBPROTOBUF_EXPORT util::Status BinaryToJsonStream(\n    TypeResolver* resolver,\n    const string& type_url,\n    io::ZeroCopyInputStream* binary_input,\n    io::ZeroCopyOutputStream* json_output,\n    const JsonPrintOptions& options);\n\ninline util::Status BinaryToJsonStream(\n    TypeResolver* resolver, const string& type_url,\n    io::ZeroCopyInputStream* binary_input,\n    io::ZeroCopyOutputStream* json_output) {\n  return BinaryToJsonStream(resolver, type_url, binary_input, json_output,\n                            JsonPrintOptions());\n}\n\nLIBPROTOBUF_EXPORT util::Status BinaryToJsonString(\n    TypeResolver* resolver,\n    const string& type_url,\n    const string& binary_input,\n    string* json_output,\n    const JsonPrintOptions& options);\n\ninline util::Status BinaryToJsonString(TypeResolver* resolver,\n                                         const string& type_url,\n                                         const string& binary_input,\n                                         string* json_output) {\n  return BinaryToJsonString(resolver, type_url, binary_input, json_output,\n                            JsonPrintOptions());\n}\n\n// Converts JSON data to protobuf binary format.\n// The conversion will fail if:\n//   1. TypeResolver fails to resolve a type.\n//   2. input is not valid JSON format, or conflicts with the type\n//      information returned by TypeResolver.\nLIBPROTOBUF_EXPORT util::Status JsonToBinaryStream(\n    TypeResolver* resolver,\n    const string& type_url,\n    io::ZeroCopyInputStream* json_input,\n    io::ZeroCopyOutputStream* binary_output,\n    const JsonParseOptions& options);\n\ninline util::Status JsonToBinaryStream(\n    TypeResolver* resolver,\n    const string& type_url,\n    io::ZeroCopyInputStream* json_input,\n    io::ZeroCopyOutputStream* binary_output) {\n  return JsonToBinaryStream(resolver, type_url, json_input, binary_output,\n                            JsonParseOptions());\n}\n\nLIBPROTOBUF_EXPORT util::Status JsonToBinaryString(\n    TypeResolver* resolver,\n    const string& type_url,\n    const string& json_input,\n    string* binary_output,\n    const JsonParseOptions& options);\n\ninline util::Status JsonToBinaryString(\n    TypeResolver* resolver,\n    const string& type_url,\n    const string& json_input,\n    string* binary_output) {\n  return JsonToBinaryString(resolver, type_url, json_input, binary_output,\n                            JsonParseOptions());\n}\n\nnamespace internal {\n// Internal helper class. Put in the header so we can write unit-tests for it.\nclass LIBPROTOBUF_EXPORT ZeroCopyStreamByteSink : public strings::ByteSink {\n public:\n  explicit ZeroCopyStreamByteSink(io::ZeroCopyOutputStream* stream)\n      : stream_(stream) {}\n\n  virtual void Append(const char* bytes, size_t len);\n\n private:\n  io::ZeroCopyOutputStream* stream_;\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(ZeroCopyStreamByteSink);\n};\n}  // namespace internal\n\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_JSON_UTIL_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/json_util_test.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/json_util.h>\n\n#include <list>\n#include <string>\n\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/descriptor_database.h>\n#include <google/protobuf/dynamic_message.h>\n#include <google/protobuf/util/json_format_proto3.pb.h>\n#include <google/protobuf/util/type_resolver.h>\n#include <google/protobuf/util/type_resolver_util.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace {\n\nusing proto3::FOO;\nusing proto3::BAR;\nusing proto3::TestMessage;\nusing proto3::TestMap;\n\nstatic const char kTypeUrlPrefix[] = \"type.googleapis.com\";\n\nstatic string GetTypeUrl(const Descriptor* message) {\n  return string(kTypeUrlPrefix) + \"/\" + message->full_name();\n}\n\n// As functions defined in json_util.h are just thin wrappers around the\n// JSON conversion code in //net/proto2/util/converter, in this test we\n// only cover some very basic cases to make sure the wrappers have forwarded\n// parameters to the underlying implementation correctly. More detailed\n// tests are contained in the //net/proto2/util/converter directory.\nclass JsonUtilTest : public testing::Test {\n protected:\n  JsonUtilTest() {\n  }\n\n  string ToJson(const Message& message, const JsonPrintOptions& options) {\n    string result;\n    GOOGLE_CHECK_OK(MessageToJsonString(message, &result, options));\n    return result;\n  }\n\n  bool FromJson(const string& json, Message* message,\n                const JsonParseOptions& options) {\n    return JsonStringToMessage(json, message, options).ok();\n  }\n\n  bool FromJson(const string& json, Message* message) {\n    return FromJson(json, message, JsonParseOptions());\n  }\n\n  google::protobuf::scoped_ptr<TypeResolver> resolver_;\n};\n\nTEST_F(JsonUtilTest, TestWhitespaces) {\n  TestMessage m;\n  m.mutable_message_value();\n\n  JsonPrintOptions options;\n  EXPECT_EQ(\"{\\\"messageValue\\\":{}}\", ToJson(m, options));\n  options.add_whitespace = true;\n  EXPECT_EQ(\n      \"{\\n\"\n      \" \\\"messageValue\\\": {}\\n\"\n      \"}\\n\",\n      ToJson(m, options));\n}\n\nTEST_F(JsonUtilTest, TestDefaultValues) {\n  TestMessage m;\n  JsonPrintOptions options;\n  EXPECT_EQ(\"{}\", ToJson(m, options));\n  options.always_print_primitive_fields = true;\n  EXPECT_EQ(\n      \"{\\\"boolValue\\\":false,\"\n      \"\\\"int32Value\\\":0,\"\n      \"\\\"int64Value\\\":\\\"0\\\",\"\n      \"\\\"uint32Value\\\":0,\"\n      \"\\\"uint64Value\\\":\\\"0\\\",\"\n      \"\\\"floatValue\\\":0,\"\n      \"\\\"doubleValue\\\":0,\"\n      \"\\\"stringValue\\\":\\\"\\\",\"\n      \"\\\"bytesValue\\\":\\\"\\\",\"\n      \"\\\"enumValue\\\":\\\"FOO\\\",\"\n      \"\\\"repeatedBoolValue\\\":[],\"\n      \"\\\"repeatedInt32Value\\\":[],\"\n      \"\\\"repeatedInt64Value\\\":[],\"\n      \"\\\"repeatedUint32Value\\\":[],\"\n      \"\\\"repeatedUint64Value\\\":[],\"\n      \"\\\"repeatedFloatValue\\\":[],\"\n      \"\\\"repeatedDoubleValue\\\":[],\"\n      \"\\\"repeatedStringValue\\\":[],\"\n      \"\\\"repeatedBytesValue\\\":[],\"\n      \"\\\"repeatedEnumValue\\\":[],\"\n      \"\\\"repeatedMessageValue\\\":[]\"\n      \"}\",\n      ToJson(m, options));\n}\n\nTEST_F(JsonUtilTest, ParseMessage) {\n  // Some random message but good enough to verify that the parsing warpper\n  // functions are working properly.\n  string input =\n      \"{\\n\"\n      \"  \\\"int32Value\\\": 1024,\\n\"\n      \"  \\\"repeatedInt32Value\\\": [1, 2],\\n\"\n      \"  \\\"messageValue\\\": {\\n\"\n      \"    \\\"value\\\": 2048\\n\"\n      \"  },\\n\"\n      \"  \\\"repeatedMessageValue\\\": [\\n\"\n      \"    {\\\"value\\\": 40}, {\\\"value\\\": 96}\\n\"\n      \"  ]\\n\"\n      \"}\\n\";\n  JsonParseOptions options;\n  TestMessage m;\n  ASSERT_TRUE(FromJson(input, &m, options));\n  EXPECT_EQ(1024, m.int32_value());\n  ASSERT_EQ(2, m.repeated_int32_value_size());\n  EXPECT_EQ(1, m.repeated_int32_value(0));\n  EXPECT_EQ(2, m.repeated_int32_value(1));\n  EXPECT_EQ(2048, m.message_value().value());\n  ASSERT_EQ(2, m.repeated_message_value_size());\n  EXPECT_EQ(40, m.repeated_message_value(0).value());\n  EXPECT_EQ(96, m.repeated_message_value(1).value());\n}\n\nTEST_F(JsonUtilTest, ParseMap) {\n  TestMap message;\n  (*message.mutable_string_map())[\"hello\"] = 1234;\n  JsonPrintOptions print_options;\n  JsonParseOptions parse_options;\n  EXPECT_EQ(\"{\\\"stringMap\\\":{\\\"hello\\\":1234}}\", ToJson(message, print_options));\n  TestMap other;\n  ASSERT_TRUE(FromJson(ToJson(message, print_options), &other, parse_options));\n  EXPECT_EQ(message.DebugString(), other.DebugString());\n}\n\nTEST_F(JsonUtilTest, TestParseIgnoreUnknownFields) {\n  TestMessage m;\n  JsonParseOptions options;\n  options.ignore_unknown_fields = true;\n  EXPECT_TRUE(FromJson(\"{\\\"unknownName\\\":0}\", &m, options));\n}\n\nTEST_F(JsonUtilTest, TestParseErrors) {\n  TestMessage m;\n  JsonParseOptions options;\n  // Parsing should fail if the field name can not be recognized.\n  EXPECT_FALSE(FromJson(\"{\\\"unknownName\\\":0}\", &m, options));\n  // Parsing should fail if the value is invalid.\n  EXPECT_FALSE(FromJson(\"{\\\"int32Value\\\":2147483648}\", &m, options));\n}\n\nTEST_F(JsonUtilTest, TestDynamicMessage) {\n  // Some random message but good enough to test the wrapper functions.\n  string input =\n      \"{\\n\"\n      \"  \\\"int32Value\\\": 1024,\\n\"\n      \"  \\\"repeatedInt32Value\\\": [1, 2],\\n\"\n      \"  \\\"messageValue\\\": {\\n\"\n      \"    \\\"value\\\": 2048\\n\"\n      \"  },\\n\"\n      \"  \\\"repeatedMessageValue\\\": [\\n\"\n      \"    {\\\"value\\\": 40}, {\\\"value\\\": 96}\\n\"\n      \"  ]\\n\"\n      \"}\\n\";\n\n  // Create a new DescriptorPool with the same protos as the generated one.\n  DescriptorPoolDatabase database(*DescriptorPool::generated_pool());\n  DescriptorPool pool(&database);\n  // A dynamic version of the test proto.\n  DynamicMessageFactory factory;\n  google::protobuf::scoped_ptr<Message> message(factory.GetPrototype(\n      pool.FindMessageTypeByName(\"proto3.TestMessage\"))->New());\n  EXPECT_TRUE(FromJson(input, message.get()));\n\n  // Convert to generated message for easy inspection.\n  TestMessage generated;\n  EXPECT_TRUE(generated.ParseFromString(message->SerializeAsString()));\n  EXPECT_EQ(1024, generated.int32_value());\n  ASSERT_EQ(2, generated.repeated_int32_value_size());\n  EXPECT_EQ(1, generated.repeated_int32_value(0));\n  EXPECT_EQ(2, generated.repeated_int32_value(1));\n  EXPECT_EQ(2048, generated.message_value().value());\n  ASSERT_EQ(2, generated.repeated_message_value_size());\n  EXPECT_EQ(40, generated.repeated_message_value(0).value());\n  EXPECT_EQ(96, generated.repeated_message_value(1).value());\n\n  JsonOptions options;\n  EXPECT_EQ(ToJson(generated, options), ToJson(*message, options));\n}\n\ntypedef pair<char*, int> Segment;\n// A ZeroCopyOutputStream that writes to multiple buffers.\nclass SegmentedZeroCopyOutputStream : public io::ZeroCopyOutputStream {\n public:\n  explicit SegmentedZeroCopyOutputStream(list<Segment> segments)\n      : segments_(segments), last_segment_(static_cast<char*>(NULL), 0), byte_count_(0) {}\n\n  virtual bool Next(void** buffer, int* length) {\n    if (segments_.empty()) {\n      return false;\n    }\n    last_segment_ = segments_.front();\n    segments_.pop_front();\n    *buffer = last_segment_.first;\n    *length = last_segment_.second;\n    byte_count_ += *length;\n    return true;\n  }\n\n  virtual void BackUp(int length) {\n    GOOGLE_CHECK(length <= last_segment_.second);\n    segments_.push_front(\n        Segment(last_segment_.first + last_segment_.second - length, length));\n    last_segment_ = Segment(last_segment_.first, last_segment_.second - length);\n    byte_count_ -= length;\n  }\n\n  virtual int64 ByteCount() const { return byte_count_; }\n\n private:\n  list<Segment> segments_;\n  Segment last_segment_;\n  int64 byte_count_;\n};\n\n// This test splits the output buffer and also the input data into multiple\n// segments and checks that the implementation of ZeroCopyStreamByteSink\n// handles all possible cases correctly.\nTEST(ZeroCopyStreamByteSinkTest, TestAllInputOutputPatterns) {\n  static const int kOutputBufferLength = 10;\n  // An exhaustive test takes too long, skip some combinations to make the test\n  // run faster.\n  static const int kSkippedPatternCount = 7;\n\n  char buffer[kOutputBufferLength];\n  for (int split_pattern = 0; split_pattern < (1 << (kOutputBufferLength - 1));\n       split_pattern += kSkippedPatternCount) {\n    // Split the buffer into small segments according to the split_pattern.\n    list<Segment> segments;\n    int segment_start = 0;\n    for (int i = 0; i < kOutputBufferLength - 1; ++i) {\n      if (split_pattern & (1 << i)) {\n        segments.push_back(\n            Segment(buffer + segment_start, i - segment_start + 1));\n        segment_start = i + 1;\n      }\n    }\n    segments.push_back(\n        Segment(buffer + segment_start, kOutputBufferLength - segment_start));\n\n    // Write exactly 10 bytes through the ByteSink.\n    string input_data = \"0123456789\";\n    for (int input_pattern = 0; input_pattern < (1 << (input_data.size() - 1));\n         input_pattern += kSkippedPatternCount) {\n      memset(buffer, 0, sizeof(buffer));\n      {\n        SegmentedZeroCopyOutputStream output_stream(segments);\n        internal::ZeroCopyStreamByteSink byte_sink(&output_stream);\n        int start = 0;\n        for (int j = 0; j < input_data.length() - 1; ++j) {\n          if (input_pattern & (1 << j)) {\n            byte_sink.Append(&input_data[start], j - start + 1);\n            start = j + 1;\n          }\n        }\n        byte_sink.Append(&input_data[start], input_data.length() - start);\n      }\n      EXPECT_EQ(input_data, string(buffer, input_data.length()));\n    }\n\n    // Write only 9 bytes through the ByteSink.\n    input_data = \"012345678\";\n    for (int input_pattern = 0; input_pattern < (1 << (input_data.size() - 1));\n         input_pattern += kSkippedPatternCount) {\n      memset(buffer, 0, sizeof(buffer));\n      {\n        SegmentedZeroCopyOutputStream output_stream(segments);\n        internal::ZeroCopyStreamByteSink byte_sink(&output_stream);\n        int start = 0;\n        for (int j = 0; j < input_data.length() - 1; ++j) {\n          if (input_pattern & (1 << j)) {\n            byte_sink.Append(&input_data[start], j - start + 1);\n            start = j + 1;\n          }\n        }\n        byte_sink.Append(&input_data[start], input_data.length() - start);\n      }\n      EXPECT_EQ(input_data, string(buffer, input_data.length()));\n      EXPECT_EQ(0, buffer[input_data.length()]);\n    }\n\n    // Write 11 bytes through the ByteSink. The extra byte will just\n    // be ignored.\n    input_data = \"0123456789A\";\n    for (int input_pattern = 0; input_pattern < (1 << (input_data.size() - 1));\n         input_pattern += kSkippedPatternCount) {\n      memset(buffer, 0, sizeof(buffer));\n      {\n        SegmentedZeroCopyOutputStream output_stream(segments);\n        internal::ZeroCopyStreamByteSink byte_sink(&output_stream);\n        int start = 0;\n        for (int j = 0; j < input_data.length() - 1; ++j) {\n          if (input_pattern & (1 << j)) {\n            byte_sink.Append(&input_data[start], j - start + 1);\n            start = j + 1;\n          }\n        }\n        byte_sink.Append(&input_data[start], input_data.length() - start);\n      }\n      EXPECT_EQ(input_data.substr(0, kOutputBufferLength),\n                string(buffer, kOutputBufferLength));\n    }\n  }\n}\n\n}  // namespace\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/message_differencer.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: jschorr@google.com (Joseph Schorr)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This file defines static methods and classes for comparing Protocol\n// Messages (see //google/protobuf/util/message_differencer.h for more\n// information).\n\n#include <google/protobuf/util/message_differencer.h>\n\n#include <algorithm>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <utility>\n\n#include <google/protobuf/stubs/callback.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/stringprintf.h>\n#include <google/protobuf/any.h>\n#include <google/protobuf/io/printer.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/dynamic_message.h>\n#include <google/protobuf/text_format.h>\n#include <google/protobuf/util/field_comparator.h>\n#include <google/protobuf/stubs/strutil.h>\n\nnamespace google {\nnamespace protobuf {\n\nnamespace util {\n\n// When comparing a repeated field as map, MultipleFieldMapKeyComparator can\n// be used to specify multiple fields as key for key comparison.\n// Two elements of a repeated field will be regarded as having the same key\n// iff they have the same value for every specified key field.\n// Note that you can also specify only one field as key.\nclass MessageDifferencer::MultipleFieldsMapKeyComparator\n    : public MessageDifferencer::MapKeyComparator {\n public:\n  MultipleFieldsMapKeyComparator(\n      MessageDifferencer* message_differencer,\n      const vector<vector<const FieldDescriptor*> >& key_field_paths)\n        : message_differencer_(message_differencer),\n          key_field_paths_(key_field_paths) {\n    GOOGLE_CHECK(!key_field_paths_.empty());\n    for (int i = 0; i < key_field_paths_.size(); ++i) {\n      GOOGLE_CHECK(!key_field_paths_[i].empty());\n    }\n  }\n  MultipleFieldsMapKeyComparator(\n      MessageDifferencer* message_differencer,\n      const FieldDescriptor* key)\n        : message_differencer_(message_differencer) {\n    vector<const FieldDescriptor*> key_field_path;\n    key_field_path.push_back(key);\n    key_field_paths_.push_back(key_field_path);\n  }\n  virtual bool IsMatch(\n      const Message& message1,\n      const Message& message2,\n      const vector<SpecificField>& parent_fields) const {\n    for (int i = 0; i < key_field_paths_.size(); ++i) {\n      if (!IsMatchInternal(message1, message2, parent_fields,\n                           key_field_paths_[i], 0)) {\n        return false;\n      }\n    }\n    return true;\n  }\n private:\n  bool IsMatchInternal(\n      const Message& message1,\n      const Message& message2,\n      const vector<SpecificField>& parent_fields,\n      const vector<const FieldDescriptor*>& key_field_path,\n      int path_index) const {\n    const FieldDescriptor* field = key_field_path[path_index];\n    vector<SpecificField> current_parent_fields(parent_fields);\n    if (path_index == key_field_path.size() - 1) {\n      if (field->is_repeated()) {\n        if (!message_differencer_->CompareRepeatedField(\n            message1, message2, field, &current_parent_fields)) {\n          return false;\n        }\n      } else {\n        if (!message_differencer_->CompareFieldValueUsingParentFields(\n            message1, message2, field, -1, -1, &current_parent_fields)) {\n          return false;\n        }\n      }\n      return true;\n    } else {\n      const Reflection* reflection1 = message1.GetReflection();\n      const Reflection* reflection2 = message2.GetReflection();\n      bool has_field1 = reflection1->HasField(message1, field);\n      bool has_field2 = reflection2->HasField(message2, field);\n      if (!has_field1 && !has_field2) {\n        return true;\n      }\n      if (has_field1 != has_field2) {\n        return false;\n      }\n      SpecificField specific_field;\n      specific_field.field = field;\n      current_parent_fields.push_back(specific_field);\n      return IsMatchInternal(\n          reflection1->GetMessage(message1, field),\n          reflection2->GetMessage(message2, field),\n          current_parent_fields,\n          key_field_path,\n          path_index + 1);\n    }\n  }\n  MessageDifferencer* message_differencer_;\n  vector<vector<const FieldDescriptor*> > key_field_paths_;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MultipleFieldsMapKeyComparator);\n};\n\nbool MessageDifferencer::Equals(const Message& message1,\n                                const Message& message2) {\n  MessageDifferencer differencer;\n\n  return differencer.Compare(message1, message2);\n}\n\nbool MessageDifferencer::Equivalent(const Message& message1,\n                                    const Message& message2) {\n  MessageDifferencer differencer;\n  differencer.set_message_field_comparison(MessageDifferencer::EQUIVALENT);\n\n  return differencer.Compare(message1, message2);\n}\n\nbool MessageDifferencer::ApproximatelyEquals(const Message& message1,\n                                             const Message& message2) {\n  MessageDifferencer differencer;\n  differencer.set_float_comparison(\n      MessageDifferencer::APPROXIMATE);\n\n  return differencer.Compare(message1, message2);\n}\n\nbool MessageDifferencer::ApproximatelyEquivalent(const Message& message1,\n                                                 const Message& message2) {\n  MessageDifferencer differencer;\n  differencer.set_message_field_comparison(MessageDifferencer::EQUIVALENT);\n  differencer.set_float_comparison(MessageDifferencer::APPROXIMATE);\n\n  return differencer.Compare(message1, message2);\n}\n\n// ===========================================================================\n\nMessageDifferencer::MessageDifferencer()\n    : reporter_(NULL),\n      field_comparator_(NULL),\n      message_field_comparison_(EQUAL),\n      scope_(FULL),\n      repeated_field_comparison_(AS_LIST),\n      report_matches_(false),\n      output_string_(NULL) { }\n\nMessageDifferencer::~MessageDifferencer() {\n  for (int i = 0; i < owned_key_comparators_.size(); ++i) {\n    delete owned_key_comparators_[i];\n  }\n  for (int i = 0; i < ignore_criteria_.size(); ++i) {\n    delete ignore_criteria_[i];\n  }\n}\n\nvoid MessageDifferencer::set_field_comparator(FieldComparator* comparator) {\n  GOOGLE_CHECK(comparator) << \"Field comparator can't be NULL.\";\n  field_comparator_ = comparator;\n}\n\nvoid MessageDifferencer::set_message_field_comparison(\n    MessageFieldComparison comparison) {\n  message_field_comparison_ = comparison;\n}\n\nvoid MessageDifferencer::set_scope(Scope scope) {\n  scope_ = scope;\n}\n\nMessageDifferencer::Scope MessageDifferencer::scope() {\n  return scope_;\n}\n\nvoid MessageDifferencer::set_float_comparison(FloatComparison comparison) {\n  default_field_comparator_.set_float_comparison(\n      comparison == EXACT ?\n      DefaultFieldComparator::EXACT : DefaultFieldComparator::APPROXIMATE);\n}\n\nvoid MessageDifferencer::set_repeated_field_comparison(\n    RepeatedFieldComparison comparison) {\n  repeated_field_comparison_ = comparison;\n}\n\nvoid MessageDifferencer::TreatAsSet(const FieldDescriptor* field) {\n  GOOGLE_CHECK(field->is_repeated()) << \"Field must be repeated: \"\n                               << field->full_name();\n  const MapKeyComparator* key_comparator = GetMapKeyComparator(field);\n  GOOGLE_CHECK(key_comparator == NULL)\n      << \"Cannot treat this repeated field as both Map and Set for\"\n      << \" comparison.  Field name is: \" << field->full_name();\n  GOOGLE_CHECK(list_fields_.find(field) == list_fields_.end())\n      << \"Cannot treat the same field as both SET and LIST. Field name is: \"\n      << field->full_name();\n  set_fields_.insert(field);\n}\n\nvoid MessageDifferencer::TreatAsList(const FieldDescriptor* field) {\n  GOOGLE_CHECK(field->is_repeated()) << \"Field must be repeated: \"\n                              << field->full_name();\n  const MapKeyComparator* key_comparator = GetMapKeyComparator(field);\n  GOOGLE_CHECK(key_comparator == NULL)\n      << \"Cannot treat this repeated field as both Map and Set for\"\n      << \" comparison.  Field name is: \" << field->full_name();\n  GOOGLE_CHECK(set_fields_.find(field) == set_fields_.end())\n      << \"Cannot treat the same field as both SET and LIST. Field name is: \"\n      << field->full_name();\n  list_fields_.insert(field);\n}\n\nvoid MessageDifferencer::TreatAsMap(const FieldDescriptor* field,\n                                    const FieldDescriptor* key) {\n  GOOGLE_CHECK(field->is_repeated()) << \"Field must be repeated: \"\n                               << field->full_name();\n  GOOGLE_CHECK_EQ(FieldDescriptor::CPPTYPE_MESSAGE, field->cpp_type())\n      << \"Field has to be message type.  Field name is: \"\n      << field->full_name();\n  GOOGLE_CHECK(key->containing_type() == field->message_type())\n      << key->full_name()\n      << \" must be a direct subfield within the repeated field \"\n      << field->full_name() << \", not \" << key->containing_type()->full_name();\n  GOOGLE_CHECK(set_fields_.find(field) == set_fields_.end())\n      << \"Cannot treat this repeated field as both Map and Set for \"\n      << \"comparison.\";\n  GOOGLE_CHECK(list_fields_.find(field) == list_fields_.end())\n      << \"Cannot treat this repeated field as both Map and List for \"\n      << \"comparison.\";\n  MapKeyComparator* key_comparator =\n      new MultipleFieldsMapKeyComparator(this, key);\n  owned_key_comparators_.push_back(key_comparator);\n  map_field_key_comparator_[field] = key_comparator;\n}\n\nvoid MessageDifferencer::TreatAsMapWithMultipleFieldsAsKey(\n    const FieldDescriptor* field,\n    const vector<const FieldDescriptor*>& key_fields) {\n  vector<vector<const FieldDescriptor*> > key_field_paths;\n  for (int i = 0; i < key_fields.size(); ++i) {\n    vector<const FieldDescriptor*> key_field_path;\n    key_field_path.push_back(key_fields[i]);\n    key_field_paths.push_back(key_field_path);\n  }\n  TreatAsMapWithMultipleFieldPathsAsKey(field, key_field_paths);\n}\n\nvoid MessageDifferencer::TreatAsMapWithMultipleFieldPathsAsKey(\n    const FieldDescriptor* field,\n    const vector<vector<const FieldDescriptor*> >& key_field_paths) {\n  GOOGLE_CHECK(field->is_repeated()) << \"Field must be repeated: \"\n                              << field->full_name();\n  GOOGLE_CHECK_EQ(FieldDescriptor::CPPTYPE_MESSAGE, field->cpp_type())\n      << \"Field has to be message type.  Field name is: \"\n      << field->full_name();\n  for (int i = 0; i < key_field_paths.size(); ++i) {\n    const vector<const FieldDescriptor*>& key_field_path = key_field_paths[i];\n    for (int j = 0; j < key_field_path.size(); ++j) {\n      const FieldDescriptor* parent_field =\n          j == 0 ? field : key_field_path[j - 1];\n      const FieldDescriptor* child_field = key_field_path[j];\n      GOOGLE_CHECK(child_field->containing_type() == parent_field->message_type())\n          << child_field->full_name()\n          << \" must be a direct subfield within the field: \"\n          << parent_field->full_name();\n      if (j != 0) {\n        GOOGLE_CHECK_EQ(FieldDescriptor::CPPTYPE_MESSAGE, parent_field->cpp_type())\n            << parent_field->full_name() << \" has to be of type message.\";\n        GOOGLE_CHECK(!parent_field->is_repeated())\n            << parent_field->full_name() << \" cannot be a repeated field.\";\n      }\n    }\n  }\n  GOOGLE_CHECK(set_fields_.find(field) == set_fields_.end())\n      << \"Cannot treat this repeated field as both Map and Set for \"\n      << \"comparison.\";\n  MapKeyComparator* key_comparator =\n      new MultipleFieldsMapKeyComparator(this, key_field_paths);\n  owned_key_comparators_.push_back(key_comparator);\n  map_field_key_comparator_[field] = key_comparator;\n}\n\nvoid MessageDifferencer::TreatAsMapUsingKeyComparator(\n    const FieldDescriptor* field,\n    const MapKeyComparator* key_comparator) {\n  GOOGLE_CHECK(field->is_repeated()) << \"Field must be repeated: \"\n                               << field->full_name();\n  GOOGLE_CHECK_EQ(FieldDescriptor::CPPTYPE_MESSAGE, field->cpp_type())\n      << \"Field has to be message type.  Field name is: \"\n      << field->full_name();\n  GOOGLE_CHECK(set_fields_.find(field) == set_fields_.end())\n      << \"Cannot treat this repeated field as both Map and Set for \"\n      << \"comparison.\";\n  map_field_key_comparator_[field] = key_comparator;\n}\n\nvoid MessageDifferencer::AddIgnoreCriteria(IgnoreCriteria* ignore_criteria) {\n  ignore_criteria_.push_back(ignore_criteria);\n}\n\nvoid MessageDifferencer::IgnoreField(const FieldDescriptor* field) {\n  ignored_fields_.insert(field);\n}\n\nvoid MessageDifferencer::SetFractionAndMargin(const FieldDescriptor* field,\n                                              double fraction, double margin) {\n  default_field_comparator_.SetFractionAndMargin(field, fraction, margin);\n}\n\nvoid MessageDifferencer::ReportDifferencesToString(string* output) {\n  GOOGLE_DCHECK(output) << \"Specified output string was NULL\";\n\n  output_string_ = output;\n  output_string_->clear();\n}\n\nvoid MessageDifferencer::ReportDifferencesTo(Reporter* reporter) {\n  // If an output string is set, clear it to prevent\n  // it superceding the specified reporter.\n  if (output_string_) {\n    output_string_ = NULL;\n  }\n\n  reporter_ = reporter;\n}\n\nbool MessageDifferencer::FieldBefore(const FieldDescriptor* field1,\n                                     const FieldDescriptor* field2) {\n  // Handle sentinel values (i.e. make sure NULLs are always ordered\n  // at the end of the list).\n  if (field1 == NULL) {\n    return false;\n  }\n\n  if (field2 == NULL) {\n    return true;\n  }\n\n  // Always order fields by their tag number\n  return (field1->number() < field2->number());\n}\n\nbool MessageDifferencer::Compare(const Message& message1,\n                                 const Message& message2) {\n  vector<SpecificField> parent_fields;\n\n  bool result = false;\n\n  // Setup the internal reporter if need be.\n  if (output_string_) {\n    io::StringOutputStream output_stream(output_string_);\n    StreamReporter reporter(&output_stream);\n    reporter_ = &reporter;\n    result = Compare(message1, message2, &parent_fields);\n    reporter_ = NULL;\n  } else {\n    result = Compare(message1, message2, &parent_fields);\n  }\n\n  return result;\n}\n\nbool MessageDifferencer::CompareWithFields(\n    const Message& message1,\n    const Message& message2,\n    const vector<const FieldDescriptor*>& message1_fields_arg,\n    const vector<const FieldDescriptor*>& message2_fields_arg) {\n  if (message1.GetDescriptor() != message2.GetDescriptor()) {\n    GOOGLE_LOG(DFATAL) << \"Comparison between two messages with different \"\n                << \"descriptors.\";\n    return false;\n  }\n\n  vector<SpecificField> parent_fields;\n\n  bool result = false;\n\n  vector<const FieldDescriptor*> message1_fields(message1_fields_arg);\n  vector<const FieldDescriptor*> message2_fields(message2_fields_arg);\n\n  std::sort(message1_fields.begin(), message1_fields.end(), FieldBefore);\n  std::sort(message2_fields.begin(), message2_fields.end(), FieldBefore);\n  // Append NULL sentinel values.\n  message1_fields.push_back(NULL);\n  message2_fields.push_back(NULL);\n\n  // Setup the internal reporter if need be.\n  if (output_string_) {\n    io::StringOutputStream output_stream(output_string_);\n    StreamReporter reporter(&output_stream);\n    reporter_ = &reporter;\n    result = CompareRequestedFieldsUsingSettings(\n        message1, message2, message1_fields, message2_fields, &parent_fields);\n    reporter_ = NULL;\n  } else {\n    result = CompareRequestedFieldsUsingSettings(\n        message1, message2, message1_fields, message2_fields, &parent_fields);\n  }\n\n  return result;\n}\n\nbool MessageDifferencer::Compare(\n    const Message& message1,\n    const Message& message2,\n    vector<SpecificField>* parent_fields) {\n  const Descriptor* descriptor1 = message1.GetDescriptor();\n  const Descriptor* descriptor2 = message2.GetDescriptor();\n  if (descriptor1 != descriptor2) {\n    GOOGLE_LOG(DFATAL) << \"Comparison between two messages with different \"\n                << \"descriptors. \"\n                << descriptor1->full_name() << \" vs \"\n                << descriptor2->full_name();\n    return false;\n  }\n  // Expand google.protobuf.Any payload if possible.\n  if (descriptor1->full_name() == internal::kAnyFullTypeName) {\n    google::protobuf::scoped_ptr<Message> data1;\n    google::protobuf::scoped_ptr<Message> data2;\n    if (UnpackAny(message1, &data1) && UnpackAny(message2, &data2)) {\n      return Compare(*data1, *data2, parent_fields);\n    }\n  }\n  const Reflection* reflection1 = message1.GetReflection();\n  const Reflection* reflection2 = message2.GetReflection();\n\n  // Retrieve all the set fields, including extensions.\n  vector<const FieldDescriptor*> message1_fields;\n  message1_fields.reserve(1 + message1.GetDescriptor()->field_count());\n\n  vector<const FieldDescriptor*> message2_fields;\n  message2_fields.reserve(1 + message2.GetDescriptor()->field_count());\n\n  reflection1->ListFields(message1, &message1_fields);\n  reflection2->ListFields(message2, &message2_fields);\n\n  // Add sentinel values to deal with the\n  // case where the number of the fields in\n  // each list are different.\n  message1_fields.push_back(NULL);\n  message2_fields.push_back(NULL);\n\n  bool unknown_compare_result = true;\n  // Ignore unknown fields in EQUIVALENT mode\n  if (message_field_comparison_ != EQUIVALENT) {\n    const google::protobuf::UnknownFieldSet* unknown_field_set1 =\n        &reflection1->GetUnknownFields(message1);\n    const google::protobuf::UnknownFieldSet* unknown_field_set2 =\n        &reflection2->GetUnknownFields(message2);\n    if (!CompareUnknownFields(message1, message2,\n                              *unknown_field_set1, *unknown_field_set2,\n                              parent_fields)) {\n      if (reporter_ == NULL) {\n        return false;\n      };\n      unknown_compare_result = false;\n    }\n  }\n\n  return CompareRequestedFieldsUsingSettings(\n      message1, message2,\n      message1_fields, message2_fields,\n      parent_fields) && unknown_compare_result;\n}\n\nbool MessageDifferencer::CompareRequestedFieldsUsingSettings(\n    const Message& message1,\n    const Message& message2,\n    const vector<const FieldDescriptor*>& message1_fields,\n    const vector<const FieldDescriptor*>& message2_fields,\n    vector<SpecificField>* parent_fields) {\n  if (scope_ == FULL) {\n    if (message_field_comparison_ == EQUIVALENT) {\n      // We need to merge the field lists of both messages (i.e.\n      // we are merely checking for a difference in field values,\n      // rather than the addition or deletion of fields).\n      vector<const FieldDescriptor*> fields_union;\n      CombineFields(message1_fields, FULL, message2_fields, FULL,\n                    &fields_union);\n      return CompareWithFieldsInternal(message1, message2, fields_union,\n                                       fields_union, parent_fields);\n    } else {\n      // Simple equality comparison, use the unaltered field lists.\n      return CompareWithFieldsInternal(message1, message2, message1_fields,\n                                       message2_fields, parent_fields);\n    }\n  } else {\n    if (message_field_comparison_ == EQUIVALENT) {\n      // We use the list of fields for message1 for both messages when\n      // comparing.  This way, extra fields in message2 are ignored,\n      // and missing fields in message2 use their default value.\n      return CompareWithFieldsInternal(message1, message2, message1_fields,\n                                       message1_fields, parent_fields);\n    } else {\n      // We need to consider the full list of fields for message1\n      // but only the intersection for message2.  This way, any fields\n      // only present in message2 will be ignored, but any fields only\n      // present in message1 will be marked as a difference.\n      vector<const FieldDescriptor*> fields_intersection;\n      CombineFields(message1_fields, PARTIAL, message2_fields, PARTIAL,\n                    &fields_intersection);\n      return CompareWithFieldsInternal(message1, message2, message1_fields,\n                                       fields_intersection, parent_fields);\n    }\n  }\n}\n\nvoid MessageDifferencer::CombineFields(\n    const vector<const FieldDescriptor*>& fields1,\n    Scope fields1_scope,\n    const vector<const FieldDescriptor*>& fields2,\n    Scope fields2_scope,\n    vector<const FieldDescriptor*>* combined_fields) {\n\n  int index1 = 0;\n  int index2 = 0;\n\n  while (index1 < fields1.size() && index2 < fields2.size()) {\n    const FieldDescriptor* field1 = fields1[index1];\n    const FieldDescriptor* field2 = fields2[index2];\n\n    if (FieldBefore(field1, field2)) {\n      if (fields1_scope == FULL) {\n        combined_fields->push_back(fields1[index1]);\n      }\n      ++index1;\n    } else if (FieldBefore(field2, field1)) {\n      if (fields2_scope == FULL) {\n        combined_fields->push_back(fields2[index2]);\n      }\n      ++index2;\n    } else {\n      combined_fields->push_back(fields1[index1]);\n      ++index1;\n      ++index2;\n    }\n  }\n}\n\nbool MessageDifferencer::CompareWithFieldsInternal(\n    const Message& message1,\n    const Message& message2,\n    const vector<const FieldDescriptor*>& message1_fields,\n    const vector<const FieldDescriptor*>& message2_fields,\n    vector<SpecificField>* parent_fields) {\n  bool isDifferent = false;\n  int field_index1 = 0;\n  int field_index2 = 0;\n\n  const Reflection* reflection1 = message1.GetReflection();\n  const Reflection* reflection2 = message2.GetReflection();\n\n  while (true) {\n    const FieldDescriptor* field1 = message1_fields[field_index1];\n    const FieldDescriptor* field2 = message2_fields[field_index2];\n\n    // Once we have reached sentinel values, we are done the comparison.\n    if (field1 == NULL && field2 == NULL) {\n      break;\n    }\n\n    // Check for differences in the field itself.\n    if (FieldBefore(field1, field2)) {\n      // Field 1 is not in the field list for message 2.\n      if (IsIgnored(message1, message2, field1, *parent_fields)) {\n        // We are ignoring field1. Report the ignore and move on to\n        // the next field in message1_fields.\n        if (reporter_ != NULL) {\n          SpecificField specific_field;\n          specific_field.field = field1;\n\n          parent_fields->push_back(specific_field);\n          reporter_->ReportIgnored(message1, message2, *parent_fields);\n          parent_fields->pop_back();\n        }\n        ++field_index1;\n        continue;\n      }\n\n      if (reporter_ != NULL) {\n        int count = field1->is_repeated() ?\n            reflection1->FieldSize(message1, field1) : 1;\n\n        for (int i = 0; i < count; ++i) {\n          SpecificField specific_field;\n          specific_field.field = field1;\n          specific_field.index = field1->is_repeated() ? i : -1;\n\n          parent_fields->push_back(specific_field);\n          reporter_->ReportDeleted(message1, message2, *parent_fields);\n          parent_fields->pop_back();\n        }\n\n        isDifferent = true;\n      } else {\n        return false;\n      }\n\n      ++field_index1;\n      continue;\n    } else if (FieldBefore(field2, field1)) {\n      // Field 2 is not in the field list for message 1.\n      if (IsIgnored(message1, message2, field2, *parent_fields)) {\n        // We are ignoring field2. Report the ignore and move on to\n        // the next field in message2_fields.\n        if (reporter_ != NULL) {\n          SpecificField specific_field;\n          specific_field.field = field2;\n\n          parent_fields->push_back(specific_field);\n          reporter_->ReportIgnored(message1, message2, *parent_fields);\n          parent_fields->pop_back();\n        }\n        ++field_index2;\n        continue;\n      }\n\n      if (reporter_ != NULL) {\n        int count = field2->is_repeated() ?\n            reflection2->FieldSize(message2, field2) : 1;\n\n        for (int i = 0; i < count; ++i) {\n          SpecificField specific_field;\n          specific_field.field = field2;\n          specific_field.index = field2->is_repeated() ? i : -1;\n          specific_field.new_index = specific_field.index;\n\n          parent_fields->push_back(specific_field);\n          reporter_->ReportAdded(message1, message2, *parent_fields);\n          parent_fields->pop_back();\n        }\n\n        isDifferent = true;\n      } else {\n        return false;\n      }\n\n      ++field_index2;\n      continue;\n    }\n\n    // By this point, field1 and field2 are guarenteed to point to the same\n    // field, so we can now compare the values.\n    if (IsIgnored(message1, message2, field1, *parent_fields)) {\n      // Ignore this field. Report and move on.\n      if (reporter_ != NULL) {\n        SpecificField specific_field;\n        specific_field.field = field1;\n\n        parent_fields->push_back(specific_field);\n        reporter_->ReportIgnored(message1, message2, *parent_fields);\n        parent_fields->pop_back();\n      }\n\n      ++field_index1;\n      ++field_index2;\n      continue;\n    }\n\n    bool fieldDifferent = false;\n    if (field1->is_repeated()) {\n      fieldDifferent = !CompareRepeatedField(message1, message2, field1,\n                                             parent_fields);\n      if (fieldDifferent) {\n        if (reporter_ == NULL) return false;\n        isDifferent = true;\n      }\n    } else {\n      fieldDifferent = !CompareFieldValueUsingParentFields(\n          message1, message2, field1, -1, -1, parent_fields);\n\n      // If we have found differences, either report them or terminate if\n      // no reporter is present.\n      if (fieldDifferent && reporter_ == NULL) {\n        return false;\n      }\n\n      if (reporter_ != NULL) {\n        SpecificField specific_field;\n        specific_field.field = field1;\n        parent_fields->push_back(specific_field);\n        if (fieldDifferent) {\n          reporter_->ReportModified(message1, message2, *parent_fields);\n          isDifferent = true;\n        } else if (report_matches_) {\n          reporter_->ReportMatched(message1, message2, *parent_fields);\n        }\n        parent_fields->pop_back();\n      }\n    }\n    // Increment the field indicies.\n    ++field_index1;\n    ++field_index2;\n  }\n\n  return !isDifferent;\n}\n\nbool MessageDifferencer::IsMatch(const FieldDescriptor* repeated_field,\n                                 const MapKeyComparator* key_comparator,\n                                 const Message* message1,\n                                 const Message* message2,\n                                 const vector<SpecificField>& parent_fields,\n                                 int index1, int index2) {\n  vector<SpecificField> current_parent_fields(parent_fields);\n  if (repeated_field->cpp_type() != FieldDescriptor::CPPTYPE_MESSAGE) {\n    return CompareFieldValueUsingParentFields(\n        *message1, *message2, repeated_field, index1, index2,\n        &current_parent_fields);\n  }\n  // Back up the Reporter and output_string_.  They will be reset in the\n  // following code.\n  Reporter* backup_reporter = reporter_;\n  string* output_string = output_string_;\n  reporter_ = NULL;\n  output_string_ = NULL;\n  bool match;\n\n  if (key_comparator == NULL) {\n    match = CompareFieldValueUsingParentFields(\n        *message1, *message2, repeated_field, index1, index2,\n        &current_parent_fields);\n  } else {\n    const Reflection* reflection1 = message1->GetReflection();\n    const Reflection* reflection2 = message2->GetReflection();\n    const Message& m1 =\n        reflection1->GetRepeatedMessage(*message1, repeated_field, index1);\n    const Message& m2 =\n        reflection2->GetRepeatedMessage(*message2, repeated_field, index2);\n    SpecificField specific_field;\n    specific_field.field = repeated_field;\n    current_parent_fields.push_back(specific_field);\n    match = key_comparator->IsMatch(m1, m2, current_parent_fields);\n  }\n\n  reporter_ = backup_reporter;\n  output_string_ = output_string;\n  return match;\n}\n\nbool MessageDifferencer::CompareRepeatedField(\n    const Message& message1,\n    const Message& message2,\n    const FieldDescriptor* repeated_field,\n    vector<SpecificField>* parent_fields) {\n  // the input FieldDescriptor is guaranteed to be repeated field.\n  const Reflection* reflection1 = message1.GetReflection();\n  const Reflection* reflection2 = message2.GetReflection();\n  const int count1 = reflection1->FieldSize(message1, repeated_field);\n  const int count2 = reflection2->FieldSize(message2, repeated_field);\n  const bool treated_as_subset = IsTreatedAsSubset(repeated_field);\n\n  // If the field is not treated as subset and no detailed reports is needed,\n  // we do a quick check on the number of the elements to avoid unnecessary\n  // comparison.\n  if (count1 != count2 && reporter_ == NULL && !treated_as_subset) {\n    return false;\n  }\n  // A match can never be found if message1 has more items than message2.\n  if (count1 > count2 && reporter_ == NULL) {\n    return false;\n  }\n\n  // These two list are used for store the index of the correspondent\n  // element in peer repeated field.\n  vector<int> match_list1;\n  vector<int> match_list2;\n\n  // Try to match indices of the repeated fields. Return false if match fails\n  // and there's no detailed report needed.\n  if (!MatchRepeatedFieldIndices(message1, message2, repeated_field,\n                                 *parent_fields, &match_list1, &match_list2) &&\n      reporter_ == NULL) {\n    return false;\n  }\n\n  bool fieldDifferent = false;\n  SpecificField specific_field;\n  specific_field.field = repeated_field;\n\n  // At this point, we have already matched pairs of fields (with the reporting\n  // to be done later). Now to check if the paired elements are different.\n  for (int i = 0; i < count1; i++) {\n    if (match_list1[i] == -1) continue;\n    specific_field.index = i;\n    specific_field.new_index = match_list1[i];\n\n    const bool result = CompareFieldValueUsingParentFields(\n        message1, message2, repeated_field, i, specific_field.new_index,\n        parent_fields);\n\n    // If we have found differences, either report them or terminate if\n    // no reporter is present. Note that ReportModified, ReportMoved, and\n    // ReportMatched are all mutually exclusive.\n    if (!result) {\n      if (reporter_ == NULL) return false;\n      parent_fields->push_back(specific_field);\n      reporter_->ReportModified(message1, message2, *parent_fields);\n      parent_fields->pop_back();\n      fieldDifferent = true;\n    } else if (reporter_ != NULL &&\n               specific_field.index != specific_field.new_index) {\n      parent_fields->push_back(specific_field);\n      reporter_->ReportMoved(message1, message2, *parent_fields);\n      parent_fields->pop_back();\n    } else if (report_matches_ && reporter_ != NULL) {\n      parent_fields->push_back(specific_field);\n      reporter_->ReportMatched(message1, message2, *parent_fields);\n      parent_fields->pop_back();\n    }\n  }\n\n  // Report any remaining additions or deletions.\n  for (int i = 0; i < count2; ++i) {\n    if (match_list2[i] != -1) continue;\n    if (!treated_as_subset) {\n      fieldDifferent = true;\n    }\n\n    if (reporter_ == NULL) continue;\n    specific_field.index = i;\n    specific_field.new_index = i;\n    parent_fields->push_back(specific_field);\n    reporter_->ReportAdded(message1, message2, *parent_fields);\n    parent_fields->pop_back();\n  }\n\n  for (int i = 0; i < count1; ++i) {\n    if (match_list1[i] != -1) continue;\n    specific_field.index = i;\n    parent_fields->push_back(specific_field);\n    reporter_->ReportDeleted(message1, message2, *parent_fields);\n    parent_fields->pop_back();\n    fieldDifferent = true;\n  }\n  return !fieldDifferent;\n}\n\nbool MessageDifferencer::CompareFieldValue(const Message& message1,\n                                           const Message& message2,\n                                           const FieldDescriptor* field,\n                                           int index1,\n                                           int index2) {\n  return CompareFieldValueUsingParentFields(message1, message2, field, index1,\n                                            index2, NULL);\n}\n\nbool MessageDifferencer::CompareFieldValueUsingParentFields(\n    const Message& message1, const Message& message2,\n    const FieldDescriptor* field, int index1, int index2,\n    vector<SpecificField>* parent_fields) {\n  FieldContext field_context(parent_fields);\n  FieldComparator::ComparisonResult result = GetFieldComparisonResult(\n      message1, message2, field, index1, index2, &field_context);\n\n  if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&\n      result == FieldComparator::RECURSE) {\n    // Get the nested messages and compare them using one of the Compare\n    // methods.\n    const Reflection* reflection1 = message1.GetReflection();\n    const Reflection* reflection2 = message2.GetReflection();\n    const Message& m1 = field->is_repeated() ?\n        reflection1->GetRepeatedMessage(message1, field, index1) :\n        reflection1->GetMessage(message1, field);\n    const Message& m2 = field->is_repeated() ?\n        reflection2->GetRepeatedMessage(message2, field, index2) :\n        reflection2->GetMessage(message2, field);\n\n    // parent_fields is used in calls to Reporter methods.\n    if (parent_fields != NULL) {\n      // Append currently compared field to the end of parent_fields.\n      SpecificField specific_field;\n      specific_field.field = field;\n      specific_field.index = index1;\n      specific_field.new_index = index2;\n      parent_fields->push_back(specific_field);\n      const bool compare_result = Compare(m1, m2, parent_fields);\n      parent_fields->pop_back();\n      return compare_result;\n    } else {\n      // Recreates parent_fields as if m1 and m2 had no parents.\n      return Compare(m1, m2);\n    }\n  } else {\n    return (result == FieldComparator::SAME);\n  }\n}\n\nbool MessageDifferencer::CheckPathChanged(\n    const vector<SpecificField>& field_path) {\n  for (int i = 0; i < field_path.size(); ++i) {\n    if (field_path[i].index != field_path[i].new_index) return true;\n  }\n  return false;\n}\n\nbool MessageDifferencer::IsTreatedAsSet(const FieldDescriptor* field) {\n  if (!field->is_repeated()) return false;\n  if (field->is_map()) return true;\n  if (repeated_field_comparison_ == AS_SET)\n    return list_fields_.find(field) == list_fields_.end();\n  return (set_fields_.find(field) != set_fields_.end());\n}\n\nbool MessageDifferencer::IsTreatedAsSubset(const FieldDescriptor* field) {\n  return scope_ == PARTIAL &&\n      (IsTreatedAsSet(field) || GetMapKeyComparator(field) != NULL);\n}\n\nbool MessageDifferencer::IsIgnored(\n    const Message& message1,\n    const Message& message2,\n    const FieldDescriptor* field,\n    const vector<SpecificField>& parent_fields) {\n  if (ignored_fields_.find(field) != ignored_fields_.end()) {\n    return true;\n  }\n  for (int i = 0; i < ignore_criteria_.size(); ++i) {\n    if (ignore_criteria_[i]->IsIgnored(message1, message2, field,\n                                       parent_fields)) {\n      return true;\n    }\n  }\n  return false;\n}\n\nbool MessageDifferencer::IsUnknownFieldIgnored(\n    const Message& message1, const Message& message2,\n    const SpecificField& field, const vector<SpecificField>& parent_fields) {\n  for (int i = 0; i < ignore_criteria_.size(); ++i) {\n    if (ignore_criteria_[i]->IsUnknownFieldIgnored(message1, message2, field,\n                                                   parent_fields)) {\n      return true;\n    }\n  }\n  return false;\n}\n\nconst MessageDifferencer::MapKeyComparator* MessageDifferencer\n    ::GetMapKeyComparator(const FieldDescriptor* field) {\n  if (!field->is_repeated()) return NULL;\n  if (map_field_key_comparator_.find(field) !=\n      map_field_key_comparator_.end()) {\n    return map_field_key_comparator_[field];\n  }\n  return NULL;\n}\n\nnamespace {\n\ntypedef pair<int, const UnknownField*> IndexUnknownFieldPair;\n\nstruct UnknownFieldOrdering {\n  inline bool operator()(const IndexUnknownFieldPair& a,\n                         const IndexUnknownFieldPair& b) const {\n    if (a.second->number() < b.second->number()) return true;\n    if (a.second->number() > b.second->number()) return false;\n    return a.second->type() < b.second->type();\n  }\n};\n\n}  // namespace\n\nbool MessageDifferencer::UnpackAny(const Message& any,\n                                   google::protobuf::scoped_ptr<Message>* data) {\n  const Reflection* reflection = any.GetReflection();\n  const FieldDescriptor* type_url_field;\n  const FieldDescriptor* value_field;\n  if (!internal::GetAnyFieldDescriptors(any, &type_url_field, &value_field)) {\n    return false;\n  }\n  const string& type_url = reflection->GetString(any, type_url_field);\n  string full_type_name;\n  if (!internal::ParseAnyTypeUrl(type_url, &full_type_name)) {\n    return false;\n  }\n\n  const google::protobuf::Descriptor* desc =\n      any.GetDescriptor()->file()->pool()->FindMessageTypeByName(\n          full_type_name);\n  if (desc == NULL) {\n    GOOGLE_DLOG(ERROR) << \"Proto type '\" << full_type_name << \"' not found\";\n    return false;\n  }\n\n  if (dynamic_message_factory_ == NULL) {\n    dynamic_message_factory_.reset(new DynamicMessageFactory());\n  }\n  data->reset(dynamic_message_factory_->GetPrototype(desc)->New());\n  string serialized_value = reflection->GetString(any, value_field);\n  if (!(*data)->ParseFromString(serialized_value)) {\n    GOOGLE_DLOG(ERROR) << \"Failed to parse value for \" << full_type_name;\n    return false;\n  }\n  return true;\n}\n\nbool MessageDifferencer::CompareUnknownFields(\n    const Message& message1, const Message& message2,\n    const google::protobuf::UnknownFieldSet& unknown_field_set1,\n    const google::protobuf::UnknownFieldSet& unknown_field_set2,\n    vector<SpecificField>* parent_field) {\n  // Ignore unknown fields in EQUIVALENT mode.\n  if (message_field_comparison_ == EQUIVALENT) return true;\n\n  if (unknown_field_set1.empty() && unknown_field_set2.empty()) {\n    return true;\n  }\n\n  bool is_different = false;\n\n  // We first sort the unknown fields by field number and type (in other words,\n  // in tag order), making sure to preserve ordering of values with the same\n  // tag.  This allows us to report only meaningful differences between the\n  // two sets -- that is, differing values for the same tag.  We use\n  // IndexUnknownFieldPairs to keep track of the field's original index for\n  // reporting purposes.\n  vector<IndexUnknownFieldPair> fields1;  // unknown_field_set1, sorted\n  vector<IndexUnknownFieldPair> fields2;  // unknown_field_set2, sorted\n  fields1.reserve(unknown_field_set1.field_count());\n  fields2.reserve(unknown_field_set2.field_count());\n\n  for (int i = 0; i < unknown_field_set1.field_count(); i++) {\n    fields1.push_back(std::make_pair(i, &unknown_field_set1.field(i)));\n  }\n  for (int i = 0; i < unknown_field_set2.field_count(); i++) {\n    fields2.push_back(std::make_pair(i, &unknown_field_set2.field(i)));\n  }\n\n  UnknownFieldOrdering is_before;\n  std::stable_sort(fields1.begin(), fields1.end(), is_before);\n  std::stable_sort(fields2.begin(), fields2.end(), is_before);\n\n  // In order to fill in SpecificField::index, we have to keep track of how\n  // many values we've seen with the same field number and type.\n  // current_repeated points at the first field in this range, and\n  // current_repeated_start{1,2} are the indexes of the first field in the\n  // range within fields1 and fields2.\n  const UnknownField* current_repeated = NULL;\n  int current_repeated_start1 = 0;\n  int current_repeated_start2 = 0;\n\n  // Now that we have two sorted lists, we can detect fields which appear only\n  // in one list or the other by traversing them simultaneously.\n  int index1 = 0;\n  int index2 = 0;\n  while (index1 < fields1.size() || index2 < fields2.size()) {\n    enum { ADDITION, DELETION, MODIFICATION, COMPARE_GROUPS,\n      NO_CHANGE } change_type;\n\n    // focus_field is the field we're currently reporting on.  (In the case\n    // of a modification, it's the field on the left side.)\n    const UnknownField* focus_field;\n    bool match = false;\n\n    if (index2 == fields2.size() ||\n        (index1 < fields1.size() &&\n          is_before(fields1[index1], fields2[index2]))) {\n      // fields1[index1] is not present in fields2.\n      change_type = DELETION;\n      focus_field = fields1[index1].second;\n    } else if (index1 == fields1.size() ||\n               is_before(fields2[index2], fields1[index1])) {\n      // fields2[index2] is not present in fields1.\n      if (scope_ == PARTIAL) {\n        // Ignore.\n        ++index2;\n        continue;\n      }\n      change_type = ADDITION;\n      focus_field = fields2[index2].second;\n    } else {\n      // Field type and number are the same.  See if the values differ.\n      change_type = MODIFICATION;\n      focus_field = fields1[index1].second;\n\n      switch (focus_field->type()) {\n        case UnknownField::TYPE_VARINT:\n          match = fields1[index1].second->varint() ==\n                  fields2[index2].second->varint();\n          break;\n        case UnknownField::TYPE_FIXED32:\n          match = fields1[index1].second->fixed32() ==\n                  fields2[index2].second->fixed32();\n          break;\n        case UnknownField::TYPE_FIXED64:\n          match = fields1[index1].second->fixed64() ==\n                  fields2[index2].second->fixed64();\n          break;\n        case UnknownField::TYPE_LENGTH_DELIMITED:\n          match = fields1[index1].second->length_delimited() ==\n                  fields2[index2].second->length_delimited();\n          break;\n        case UnknownField::TYPE_GROUP:\n          // We must deal with this later, after building the SpecificField.\n          change_type = COMPARE_GROUPS;\n          break;\n      }\n      if (match && change_type != COMPARE_GROUPS) {\n        change_type = NO_CHANGE;\n      }\n    }\n\n    if (current_repeated == NULL ||\n        focus_field->number() != current_repeated->number() ||\n        focus_field->type() != current_repeated->type()) {\n      // We've started a new repeated field.\n      current_repeated = focus_field;\n      current_repeated_start1 = index1;\n      current_repeated_start2 = index2;\n    }\n\n    if (change_type == NO_CHANGE && reporter_ == NULL) {\n      // Fields were already compared and matched and we have no reporter.\n      ++index1;\n      ++index2;\n      continue;\n    }\n\n    // Build the SpecificField.  This is slightly complicated.\n    SpecificField specific_field;\n    specific_field.unknown_field_number = focus_field->number();\n    specific_field.unknown_field_type = focus_field->type();\n\n    specific_field.unknown_field_set1 = &unknown_field_set1;\n    specific_field.unknown_field_set2 = &unknown_field_set2;\n\n    if (change_type != ADDITION) {\n      specific_field.unknown_field_index1 = fields1[index1].first;\n    }\n    if (change_type != DELETION) {\n      specific_field.unknown_field_index2 = fields2[index2].first;\n    }\n\n    // Calculate the field index.\n    if (change_type == ADDITION) {\n      specific_field.index = index2 - current_repeated_start2;\n      specific_field.new_index = index2 - current_repeated_start2;\n    } else {\n      specific_field.index = index1 - current_repeated_start1;\n      specific_field.new_index = index2 - current_repeated_start2;\n    }\n\n    if (IsUnknownFieldIgnored(message1, message2, specific_field,\n                              *parent_field)) {\n      if (reporter_ != NULL) {\n        parent_field->push_back(specific_field);\n        reporter_->ReportUnknownFieldIgnored(message1, message2, *parent_field);\n        parent_field->pop_back();\n      }\n      return true;\n    }\n\n    if (change_type == ADDITION || change_type == DELETION ||\n        change_type == MODIFICATION) {\n      if (reporter_ == NULL) {\n        // We found a difference and we have no reproter.\n        return false;\n      }\n      is_different = true;\n    }\n\n    parent_field->push_back(specific_field);\n\n    switch (change_type) {\n      case ADDITION:\n        reporter_->ReportAdded(message1, message2, *parent_field);\n        ++index2;\n        break;\n      case DELETION:\n        reporter_->ReportDeleted(message1, message2, *parent_field);\n        ++index1;\n        break;\n      case MODIFICATION:\n        reporter_->ReportModified(message1, message2, *parent_field);\n        ++index1;\n        ++index2;\n        break;\n      case COMPARE_GROUPS:\n        if (!CompareUnknownFields(message1, message2,\n                                  fields1[index1].second->group(),\n                                  fields2[index2].second->group(),\n                                  parent_field)) {\n          if (reporter_ == NULL) return false;\n          is_different = true;\n          reporter_->ReportModified(message1, message2, *parent_field);\n        }\n        ++index1;\n        ++index2;\n        break;\n      case NO_CHANGE:\n        ++index1;\n        ++index2;\n        if (report_matches_) {\n          reporter_->ReportMatched(message1, message2, *parent_field);\n        }\n    }\n\n    parent_field->pop_back();\n  }\n\n  return !is_different;\n}\n\nnamespace {\n\n// Find maximum bipartite matching using the argumenting path algorithm.\nclass MaximumMatcher {\n public:\n  typedef ResultCallback2<bool, int, int> NodeMatchCallback;\n  // MaximumMatcher takes ownership of the passed in callback and uses it to\n  // determine whether a node on the left side of the bipartial graph matches\n  // a node on the right side. count1 is the number of nodes on the left side\n  // of the graph and count2 to is the number of nodes on the right side.\n  // Every node is referred to using 0-based indices.\n  // If a maximum match is found, the result will be stored in match_list1 and\n  // match_list2. match_list1[i] == j means the i-th node on the left side is\n  // matched to the j-th node on the right side and match_list2[x] == y means\n  // the x-th node on the right side is matched to y-th node on the left side.\n  // match_list1[i] == -1 means the node is not matched. Same with match_list2.\n  MaximumMatcher(int count1, int count2, NodeMatchCallback* callback,\n                 vector<int>* match_list1, vector<int>* match_list2);\n  // Find a maximum match and return the number of matched node pairs.\n  // If early_return is true, this method will return 0 immediately when it\n  // finds that not all nodes on the left side can be matched.\n  int FindMaximumMatch(bool early_return);\n private:\n  // Determines whether the node on the left side of the bipartial graph\n  // matches the one on the right side.\n  bool Match(int left, int right);\n  // Find an argumenting path starting from the node v on the left side. If a\n  // path can be found, update match_list2_ to reflect the path and return\n  // true.\n  bool FindArgumentPathDFS(int v, vector<bool>* visited);\n\n  int count1_;\n  int count2_;\n  google::protobuf::scoped_ptr<NodeMatchCallback> match_callback_;\n  map<pair<int, int>, bool> cached_match_results_;\n  vector<int>* match_list1_;\n  vector<int>* match_list2_;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MaximumMatcher);\n};\n\nMaximumMatcher::MaximumMatcher(int count1, int count2,\n                               NodeMatchCallback* callback,\n                               vector<int>* match_list1,\n                               vector<int>* match_list2)\n    : count1_(count1), count2_(count2), match_callback_(callback),\n      match_list1_(match_list1), match_list2_(match_list2) {\n  match_list1_->assign(count1, -1);\n  match_list2_->assign(count2, -1);\n}\n\nint MaximumMatcher::FindMaximumMatch(bool early_return) {\n  int result = 0;\n  for (int i = 0; i < count1_; ++i) {\n    vector<bool> visited(count1_);\n    if (FindArgumentPathDFS(i, &visited)) {\n      ++result;\n    } else if (early_return) {\n      return 0;\n    }\n  }\n  // Backfill match_list1_ as we only filled match_list2_ when finding\n  // argumenting pathes.\n  for (int i = 0; i < count2_; ++i) {\n    if ((*match_list2_)[i] != -1) {\n      (*match_list1_)[(*match_list2_)[i]] = i;\n    }\n  }\n  return result;\n}\n\nbool MaximumMatcher::Match(int left, int right) {\n  pair<int, int> p(left, right);\n  map<pair<int, int>, bool>::iterator it = cached_match_results_.find(p);\n  if (it != cached_match_results_.end()) {\n    return it->second;\n  }\n  cached_match_results_[p] = match_callback_->Run(left, right);\n  return cached_match_results_[p];\n}\n\nbool MaximumMatcher::FindArgumentPathDFS(int v, vector<bool>* visited) {\n  (*visited)[v] = true;\n  // We try to match those un-matched nodes on the right side first. This is\n  // the step that the navie greedy matching algorithm uses. In the best cases\n  // where the greedy algorithm can find a maximum matching, we will always\n  // find a match in this step and the performance will be identical to the\n  // greedy algorithm.\n  for (int i = 0; i < count2_; ++i) {\n    int matched = (*match_list2_)[i];\n    if (matched == -1 && Match(v, i)) {\n      (*match_list2_)[i] = v;\n      return true;\n    }\n  }\n  // Then we try those already matched nodes and see if we can find an\n  // alternaive match for the node matched to them.\n  // The greedy algorithm will stop before this and fail to produce the\n  // correct result.\n  for (int i = 0; i < count2_; ++i) {\n    int matched = (*match_list2_)[i];\n    if (matched != -1 && Match(v, i)) {\n      if (!(*visited)[matched] && FindArgumentPathDFS(matched, visited)) {\n        (*match_list2_)[i] = v;\n        return true;\n      }\n    }\n  }\n  return false;\n}\n\n}  // namespace\n\nbool MessageDifferencer::MatchRepeatedFieldIndices(\n    const Message& message1,\n    const Message& message2,\n    const FieldDescriptor* repeated_field,\n    const vector<SpecificField>& parent_fields,\n    vector<int>* match_list1,\n    vector<int>* match_list2) {\n  const int count1 =\n      message1.GetReflection()->FieldSize(message1, repeated_field);\n  const int count2 =\n      message2.GetReflection()->FieldSize(message2, repeated_field);\n  const MapKeyComparator* key_comparator = GetMapKeyComparator(repeated_field);\n\n  match_list1->assign(count1, -1);\n  match_list2->assign(count2, -1);\n\n  SpecificField specific_field;\n  specific_field.field = repeated_field;\n\n  bool success = true;\n  // Find potential match if this is a special repeated field.\n  if (key_comparator != NULL || IsTreatedAsSet(repeated_field)) {\n    if (scope_ == PARTIAL) {\n      // When partial matching is enabled, Compare(a, b) && Compare(a, c)\n      // doesn't necessarily imply Compare(b, c). Therefore a naive greedy\n      // algorithm will fail to find a maximum matching.\n      // Here we use the argumenting path algorithm.\n      MaximumMatcher::NodeMatchCallback* callback =\n          ::google::protobuf::internal::NewPermanentCallback(\n              this, &MessageDifferencer::IsMatch,\n              repeated_field, key_comparator,\n              &message1, &message2, parent_fields);\n      MaximumMatcher matcher(count1, count2, callback, match_list1,\n                             match_list2);\n      // If diff info is not needed, we should end the matching process as\n      // soon as possible if not all items can be matched.\n      bool early_return = (reporter_ == NULL);\n      int match_count = matcher.FindMaximumMatch(early_return);\n      if (match_count != count1 && reporter_ == NULL) return false;\n      success = success && (match_count == count1);\n    } else {\n      for (int i = 0; i < count1; ++i) {\n        // Indicates any matched elements for this repeated field.\n        bool match = false;\n\n        specific_field.index = i;\n        specific_field.new_index = i;\n\n        for (int j = 0; j < count2; j++) {\n          if (match_list2->at(j) != -1) continue;\n          specific_field.index = i;\n          specific_field.new_index = j;\n\n          match = IsMatch(repeated_field, key_comparator,\n                          &message1, &message2, parent_fields, i, j);\n\n          if (match) {\n            match_list1->at(specific_field.index) = specific_field.new_index;\n            match_list2->at(specific_field.new_index) = specific_field.index;\n            break;\n          }\n        }\n        if (!match && reporter_ == NULL) return false;\n        success = success && match;\n      }\n    }\n  } else {\n    // If this field should be treated as list, just label the match_list.\n    for (int i = 0; i < count1 && i < count2; i++) {\n      match_list1->at(i) = i;\n      match_list2->at(i) = i;\n    }\n  }\n\n  return success;\n}\n\nFieldComparator::ComparisonResult MessageDifferencer::GetFieldComparisonResult(\n    const Message& message1, const Message& message2,\n    const FieldDescriptor* field, int index1, int index2,\n    const FieldContext* field_context) {\n  FieldComparator* comparator = field_comparator_ != NULL ?\n      field_comparator_ : &default_field_comparator_;\n  return comparator->Compare(message1, message2, field,\n                             index1, index2, field_context);\n}\n\n// ===========================================================================\n\nMessageDifferencer::Reporter::Reporter() { }\nMessageDifferencer::Reporter::~Reporter() {}\n\n// ===========================================================================\n\nMessageDifferencer::MapKeyComparator::MapKeyComparator() {}\nMessageDifferencer::MapKeyComparator::~MapKeyComparator() {}\n\n// ===========================================================================\n\nMessageDifferencer::IgnoreCriteria::IgnoreCriteria() {}\nMessageDifferencer::IgnoreCriteria::~IgnoreCriteria() {}\n\n// ===========================================================================\n\n// Note that the printer's delimiter is not used, because if we are given a\n// printer, we don't know its delimiter.\nMessageDifferencer::StreamReporter::StreamReporter(\n    io::ZeroCopyOutputStream* output) : printer_(new io::Printer(output, '$')),\n                                        delete_printer_(true),\n                                        report_modified_aggregates_(false) { }\n\nMessageDifferencer::StreamReporter::StreamReporter(\n    io::Printer* printer) : printer_(printer),\n                            delete_printer_(false),\n                            report_modified_aggregates_(false) { }\n\nMessageDifferencer::StreamReporter::~StreamReporter() {\n  if (delete_printer_) delete printer_;\n}\n\nvoid MessageDifferencer::StreamReporter::PrintPath(\n    const vector<SpecificField>& field_path, bool left_side) {\n  for (int i = 0; i < field_path.size(); ++i) {\n    if (i > 0) {\n      printer_->Print(\".\");\n    }\n\n    SpecificField specific_field = field_path[i];\n\n    if (specific_field.field != NULL) {\n      if (specific_field.field->is_extension()) {\n        printer_->Print(\"($name$)\", \"name\",\n                        specific_field.field->full_name());\n      } else {\n        printer_->PrintRaw(specific_field.field->name());\n      }\n    } else {\n      printer_->PrintRaw(SimpleItoa(specific_field.unknown_field_number));\n    }\n    if (left_side && specific_field.index >= 0) {\n      printer_->Print(\"[$name$]\", \"name\", SimpleItoa(specific_field.index));\n    }\n    if (!left_side && specific_field.new_index >= 0) {\n      printer_->Print(\"[$name$]\", \"name\", SimpleItoa(specific_field.new_index));\n    }\n  }\n}\n\nvoid MessageDifferencer::\nStreamReporter::PrintValue(const Message& message,\n                           const vector<SpecificField>& field_path,\n                           bool left_side) {\n  const SpecificField& specific_field = field_path.back();\n  const FieldDescriptor* field = specific_field.field;\n  if (field != NULL) {\n    string output;\n    int index = left_side ? specific_field.index : specific_field.new_index;\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n      const Reflection* reflection = message.GetReflection();\n      const Message& field_message = field->is_repeated() ?\n          reflection->GetRepeatedMessage(message, field, index) :\n          reflection->GetMessage(message, field);\n      output = field_message.ShortDebugString();\n      if (output.empty()) {\n        printer_->Print(\"{ }\");\n      } else {\n        printer_->Print(\"{ $name$ }\", \"name\", output);\n      }\n    } else {\n      TextFormat::PrintFieldValueToString(message, field, index, &output);\n      printer_->PrintRaw(output);\n    }\n  } else {\n    const UnknownFieldSet* unknown_fields =\n        (left_side ?\n         specific_field.unknown_field_set1 :\n         specific_field.unknown_field_set2);\n    const UnknownField* unknown_field = &unknown_fields->field(\n        left_side ?\n        specific_field.unknown_field_index1 :\n        specific_field.unknown_field_index2);\n    PrintUnknownFieldValue(unknown_field);\n  }\n}\n\nvoid MessageDifferencer::\nStreamReporter::PrintUnknownFieldValue(const UnknownField* unknown_field) {\n  GOOGLE_CHECK(unknown_field != NULL) << \" Cannot print NULL unknown_field.\";\n\n  string output;\n  switch (unknown_field->type()) {\n    case UnknownField::TYPE_VARINT:\n      output = SimpleItoa(unknown_field->varint());\n      break;\n    case UnknownField::TYPE_FIXED32:\n      output = StrCat(\"0x\", strings::Hex(unknown_field->fixed32(),\n                                         strings::ZERO_PAD_8));\n      break;\n    case UnknownField::TYPE_FIXED64:\n      output = StrCat(\"0x\", strings::Hex(unknown_field->fixed64(),\n                                         strings::ZERO_PAD_16));\n      break;\n    case UnknownField::TYPE_LENGTH_DELIMITED:\n      output = StringPrintf(\"\\\"%s\\\"\",\n          CEscape(unknown_field->length_delimited()).c_str());\n      break;\n    case UnknownField::TYPE_GROUP:\n      // TODO(kenton):  Print the contents of the group like we do for\n      //   messages.  Requires an equivalent of ShortDebugString() for\n      //   UnknownFieldSet.\n      output = \"{ ... }\";\n      break;\n  }\n  printer_->PrintRaw(output);\n}\n\nvoid MessageDifferencer::StreamReporter::Print(const string& str) {\n  printer_->Print(str.c_str());\n}\n\nvoid MessageDifferencer::StreamReporter::ReportAdded(\n    const Message& message1,\n    const Message& message2,\n    const vector<SpecificField>& field_path) {\n  printer_->Print(\"added: \");\n  PrintPath(field_path, false);\n  printer_->Print(\": \");\n  PrintValue(message2, field_path, false);\n  printer_->Print(\"\\n\");  // Print for newlines.\n}\n\nvoid MessageDifferencer::StreamReporter::ReportDeleted(\n    const Message& message1,\n    const Message& message2,\n    const vector<SpecificField>& field_path) {\n  printer_->Print(\"deleted: \");\n  PrintPath(field_path, true);\n  printer_->Print(\": \");\n  PrintValue(message1, field_path, true);\n  printer_->Print(\"\\n\");  // Print for newlines\n}\n\nvoid MessageDifferencer::StreamReporter::ReportModified(\n    const Message& message1,\n    const Message& message2,\n    const vector<SpecificField>& field_path) {\n  if (!report_modified_aggregates_ && field_path.back().field == NULL) {\n    if (field_path.back().unknown_field_type == UnknownField::TYPE_GROUP) {\n      // Any changes to the subfields have already been printed.\n      return;\n    }\n  } else if (!report_modified_aggregates_) {\n    if (field_path.back().field->cpp_type() ==\n        FieldDescriptor::CPPTYPE_MESSAGE) {\n      // Any changes to the subfields have already been printed.\n      return;\n    }\n  }\n\n  printer_->Print(\"modified: \");\n  PrintPath(field_path, true);\n  if (CheckPathChanged(field_path)) {\n    printer_->Print(\" -> \");\n    PrintPath(field_path, false);\n  }\n  printer_->Print(\": \");\n  PrintValue(message1, field_path, true);\n  printer_->Print(\" -> \");\n  PrintValue(message2, field_path, false);\n  printer_->Print(\"\\n\");  // Print for newlines.\n}\n\nvoid MessageDifferencer::StreamReporter::ReportMoved(\n    const Message& message1,\n    const Message& message2,\n    const vector<SpecificField>& field_path) {\n  printer_->Print(\"moved: \");\n  PrintPath(field_path, true);\n  printer_->Print(\" -> \");\n  PrintPath(field_path, false);\n  printer_->Print(\" : \");\n  PrintValue(message1, field_path, true);\n  printer_->Print(\"\\n\");  // Print for newlines.\n}\n\nvoid MessageDifferencer::StreamReporter::ReportMatched(\n    const Message& message1,\n    const Message& message2,\n    const vector<SpecificField>& field_path) {\n  printer_->Print(\"matched: \");\n  PrintPath(field_path, true);\n  if (CheckPathChanged(field_path)) {\n    printer_->Print(\" -> \");\n    PrintPath(field_path, false);\n  }\n  printer_->Print(\" : \");\n  PrintValue(message1, field_path, true);\n  printer_->Print(\"\\n\");  // Print for newlines.\n}\n\nvoid MessageDifferencer::StreamReporter::ReportIgnored(\n    const Message& message1,\n    const Message& message2,\n    const vector<SpecificField>& field_path) {\n  printer_->Print(\"ignored: \");\n  PrintPath(field_path, true);\n  if (CheckPathChanged(field_path)) {\n    printer_->Print(\" -> \");\n    PrintPath(field_path, false);\n  }\n  printer_->Print(\"\\n\");  // Print for newlines.\n}\n\nvoid MessageDifferencer::StreamReporter::ReportUnknownFieldIgnored(\n    const Message& message1, const Message& message2,\n    const vector<SpecificField>& field_path) {\n  printer_->Print(\"ignored: \");\n  PrintPath(field_path, true);\n  if (CheckPathChanged(field_path)) {\n    printer_->Print(\" -> \");\n    PrintPath(field_path, false);\n  }\n  printer_->Print(\"\\n\");  // Print for newlines.\n}\n\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/message_differencer.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: jschorr@google.com (Joseph Schorr)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This file defines static methods and classes for comparing Protocol\n// Messages.\n//\n// Aug. 2008: Added Unknown Fields Comparison for messages.\n// Aug. 2009: Added different options to compare repeated fields.\n// Apr. 2010: Moved field comparison to FieldComparator.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_MESSAGE_DIFFERENCER_H__\n#define GOOGLE_PROTOBUF_UTIL_MESSAGE_DIFFERENCER_H__\n\n#include <map>\n#include <set>\n#include <string>\n#include <vector>\n#include <google/protobuf/descriptor.h>  // FieldDescriptor\n#include <google/protobuf/message.h>  // Message\n#include <google/protobuf/unknown_field_set.h>\n#include <google/protobuf/util/field_comparator.h>\n\nnamespace google {\nnamespace protobuf {\n\nclass DynamicMessageFactory;\nclass FieldDescriptor;\n\nnamespace io {\nclass ZeroCopyOutputStream;\nclass Printer;\n}\n\nnamespace util {\n\nclass FieldContext;  // declared below MessageDifferencer\n\n// A basic differencer that can be used to determine\n// the differences between two specified Protocol Messages. If any differences\n// are found, the Compare method will return false, and any differencer reporter\n// specified via ReportDifferencesTo will have its reporting methods called (see\n// below for implementation of the report). Based off of the original\n// ProtocolDifferencer implementation in //net/proto/protocol-differencer.h\n// (Thanks Todd!).\n//\n// MessageDifferencer REQUIRES that compared messages be the same type, defined\n// as messages that share the same descriptor.  If not, the behavior of this\n// class is undefined.\n//\n// People disagree on what MessageDifferencer should do when asked to compare\n// messages with different descriptors.  Some people think it should always\n// return false.  Others expect it to try to look for similar fields and\n// compare them anyway -- especially if the descriptors happen to be identical.\n// If we chose either of these behaviors, some set of people would find it\n// surprising, and could end up writing code expecting the other behavior\n// without realizing their error.  Therefore, we forbid that usage.\n//\n// This class is implemented based on the proto2 reflection. The performance\n// should be good enough for normal usages. However, for places where the\n// performance is extremely sensitive, there are several alternatives:\n// - Comparing serialized string\n// Downside: false negatives (there are messages that are the same but their\n// serialized strings are different).\n// - Equals code generator by compiler plugin (net/proto2/contrib/equals_plugin)\n// Downside: more generated code; maintenance overhead for the additional rule\n// (must be in sync with the original proto_library).\n//\n// Note on handling of google.protobuf.Any: MessageDifferencer automatically\n// unpacks Any::value into a Message and compares its individual fields.\n// Messages encoded in a repeated Any cannot be compared using TreatAsMap.\n//\n//\n// Note on thread-safety: MessageDifferencer is *not* thread-safe. You need to\n// guard it with a lock to use the same MessageDifferencer instance from\n// multiple threads. Note that it's fine to call static comparison methods\n// (like MessageDifferencer::Equals) concurrently.\nclass LIBPROTOBUF_EXPORT MessageDifferencer {\n public:\n  // Determines whether the supplied messages are equal. Equality is defined as\n  // all fields within the two messages being set to the same value. Primitive\n  // fields and strings are compared by value while embedded messages/groups\n  // are compared as if via a recursive call. Use IgnoreField() and Compare()\n  // if some fields should be ignored in the comparison.\n  //\n  // This method REQUIRES that the two messages have the same\n  // Descriptor (message1.GetDescriptor() == message2.GetDescriptor()).\n  static bool Equals(const Message& message1, const Message& message2);\n\n  // Determines whether the supplied messages are equivalent. Equivalency is\n  // defined as all fields within the two messages having the same value. This\n  // differs from the Equals method above in that fields with default values\n  // are considered set to said value automatically. For details on how default\n  // values are defined for each field type, see http://shortn/_x2Gv6XFrWt.\n  // Also, Equivalent() ignores unknown fields. Use IgnoreField() and Compare()\n  // if some fields should be ignored in the comparison.\n  //\n  // This method REQUIRES that the two messages have the same\n  // Descriptor (message1.GetDescriptor() == message2.GetDescriptor()).\n  static bool Equivalent(const Message& message1, const Message& message2);\n\n  // Determines whether the supplied messages are approximately equal.\n  // Approximate equality is defined as all fields within the two messages\n  // being approximately equal.  Primitive (non-float) fields and strings are\n  // compared by value, floats are compared using MathUtil::AlmostEquals() and\n  // embedded messages/groups are compared as if via a recursive call. Use\n  // IgnoreField() and Compare() if some fields should be ignored in the\n  // comparison.\n  //\n  // This method REQUIRES that the two messages have the same\n  // Descriptor (message1.GetDescriptor() == message2.GetDescriptor()).\n  static bool ApproximatelyEquals(const Message& message1,\n                                  const Message& message2);\n\n  // Determines whether the supplied messages are approximately equivalent.\n  // Approximate equivalency is defined as all fields within the two messages\n  // being approximately equivalent. As in\n  // MessageDifferencer::ApproximatelyEquals, primitive (non-float) fields and\n  // strings are compared by value, floats are compared using\n  // MathUtil::AlmostEquals() and embedded messages/groups are compared as if\n  // via a recursive call. However, fields with default values are considered\n  // set to said value, as per MessageDiffencer::Equivalent. Use IgnoreField()\n  // and Compare() if some fields should be ignored in the comparison.\n  //\n  // This method REQUIRES that the two messages have the same\n  // Descriptor (message1.GetDescriptor() == message2.GetDescriptor()).\n  static bool ApproximatelyEquivalent(const Message& message1,\n                                      const Message& message2);\n\n  // Identifies an individual field in a message instance.  Used for field_path,\n  // below.\n  struct SpecificField {\n    // For known fields, \"field\" is filled in and \"unknown_field_number\" is -1.\n    // For unknown fields, \"field\" is NULL, \"unknown_field_number\" is the field\n    // number, and \"unknown_field_type\" is its type.\n    const FieldDescriptor* field;\n    int unknown_field_number;\n    UnknownField::Type unknown_field_type;\n\n    // If this a repeated field, \"index\" is the index within it.  For unknown\n    // fields, this is the index of the field among all unknown fields of the\n    // same field number and type.\n    int index;\n\n    // If \"field\" is a repeated field which is being treated as a map or\n    // a set (see TreatAsMap() and TreatAsSet(), below), new_index indicates\n    // the index the position to which the element has moved.  This only\n    // applies to ReportMoved() and (in the case of TreatAsMap())\n    // ReportModified().  In all other cases, \"new_index\" will have the same\n    // value as \"index\".\n    int new_index;\n\n    // For unknown fields, these are the pointers to the UnknownFieldSet\n    // containing the unknown fields. In certain cases (e.g. proto1's\n    // MessageSet, or nested groups of unknown fields), these may differ from\n    // the messages' internal UnknownFieldSets.\n    const UnknownFieldSet* unknown_field_set1;\n    const UnknownFieldSet* unknown_field_set2;\n\n    // For unknown fields, these are the index of the field within the\n    // UnknownFieldSets. One or the other will be -1 when\n    // reporting an addition or deletion.\n    int unknown_field_index1;\n    int unknown_field_index2;\n\n    SpecificField()\n        : field(NULL),\n          unknown_field_number(-1),\n          index(-1),\n          new_index(-1),\n          unknown_field_set1(NULL),\n          unknown_field_set2(NULL),\n          unknown_field_index1(-1),\n          unknown_field_index2(-1) {}\n  };\n\n  // Abstract base class from which all MessageDifferencer\n  // reporters derive. The five Report* methods below will be called when\n  // a field has been added, deleted, modified, moved, or matched. The third\n  // argument is a vector of FieldDescriptor pointers which describes the chain\n  // of fields that was taken to find the current field. For example, for a\n  // field found in an embedded message, the vector will contain two\n  // FieldDescriptors. The first will be the field of the embedded message\n  // itself and the second will be the actual field in the embedded message\n  // that was added/deleted/modified.\n  class LIBPROTOBUF_EXPORT Reporter {\n   public:\n    Reporter();\n    virtual ~Reporter();\n\n    // Reports that a field has been added into Message2.\n    virtual void ReportAdded(\n        const Message& message1, const Message& message2,\n        const vector<SpecificField>& field_path) = 0;\n\n    // Reports that a field has been deleted from Message1.\n    virtual void ReportDeleted(\n        const Message& message1,\n        const Message& message2,\n        const vector<SpecificField>& field_path) = 0;\n\n    // Reports that the value of a field has been modified.\n    virtual void ReportModified(\n        const Message& message1,\n        const Message& message2,\n        const vector<SpecificField>& field_path) = 0;\n\n    // Reports that a repeated field has been moved to another location.  This\n    // only applies when using TreatAsSet or TreatAsMap()  -- see below. Also\n    // note that for any given field, ReportModified and ReportMoved are\n    // mutually exclusive. If a field has been both moved and modified, then\n    // only ReportModified will be called.\n    virtual void ReportMoved(\n        const Message& message1,\n        const Message& message2,\n        const vector<SpecificField>& field_path) { }\n\n    // Reports that two fields match. Useful for doing side-by-side diffs.\n    // This function is mutually exclusive with ReportModified and ReportMoved.\n    // Note that you must call set_report_matches(true) before calling Compare\n    // to make use of this function.\n    virtual void ReportMatched(\n        const Message& message1,\n        const Message& message2,\n        const vector<SpecificField>& field_path) { }\n\n    // Reports that two fields would have been compared, but the\n    // comparison has been skipped because the field was marked as\n    // 'ignored' using IgnoreField().  This function is mutually\n    // exclusive with all the other Report() functions.\n    //\n    // The contract of ReportIgnored is slightly different than the\n    // other Report() functions, in that |field_path.back().index| is\n    // always equal to -1, even if the last field is repeated. This is\n    // because while the other Report() functions indicate where in a\n    // repeated field the action (Addition, Deletion, etc...)\n    // happened, when a repeated field is 'ignored', the differencer\n    // simply calls ReportIgnored on the repeated field as a whole and\n    // moves on without looking at its individual elements.\n    //\n    // Furthermore, ReportIgnored() does not indicate whether the\n    // fields were in fact equal or not, as Compare() does not inspect\n    // these fields at all. It is up to the Reporter to decide whether\n    // the fields are equal or not (perhaps with a second call to\n    // Compare()), if it cares.\n    virtual void ReportIgnored(\n        const Message& message1,\n        const Message& message2,\n        const vector<SpecificField>& field_path) { }\n\n    // Report that an unknown field is ignored. (see comment above).\n    // Note this is a different function since the last SpecificField in field\n    // path has a null field.  This could break existing Reporter.\n    virtual void ReportUnknownFieldIgnored(\n        const Message& message1, const Message& message2,\n        const vector<SpecificField>& field_path) {}\n\n   private:\n    GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(Reporter);\n  };\n\n  // MapKeyComparator is used to determine if two elements have the same key\n  // when comparing elements of a repeated field as a map.\n  class LIBPROTOBUF_EXPORT MapKeyComparator {\n   public:\n    MapKeyComparator();\n    virtual ~MapKeyComparator();\n\n    virtual bool IsMatch(const Message& message1,\n                         const Message& message2,\n                         const vector<SpecificField>& parent_fields) const {\n      GOOGLE_CHECK(false) << \"IsMatch() is not implemented.\";\n      return false;\n    }\n\n   private:\n    GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MapKeyComparator);\n  };\n\n  // Abstract base class from which all IgnoreCriteria derive.\n  // By adding IgnoreCriteria more complex ignore logic can be implemented.\n  // IgnoreCriteria are registed with AddIgnoreCriteria. For each compared\n  // field IsIgnored is called on each added IgnoreCriteria until one returns\n  // true or all return false.\n  // IsIgnored is called for fields where at least one side has a value.\n  class LIBPROTOBUF_EXPORT IgnoreCriteria {\n   public:\n    IgnoreCriteria();\n    virtual ~IgnoreCriteria();\n\n    // Returns true if the field should be ignored.\n    virtual bool IsIgnored(\n        const Message& message1,\n        const Message& message2,\n        const FieldDescriptor* field,\n        const vector<SpecificField>& parent_fields) = 0;\n\n    // Returns true if the unknown field should be ignored.\n    // Note: This will be called for unknown fields as well in which case\n    //       field.field will be null.\n    virtual bool IsUnknownFieldIgnored(\n        const Message& message1, const Message& message2,\n        const SpecificField& field,\n        const vector<SpecificField>& parent_fields) {\n      return false;\n    }\n  };\n\n  // To add a Reporter, construct default here, then use ReportDifferencesTo or\n  // ReportDifferencesToString.\n  explicit MessageDifferencer();\n\n  ~MessageDifferencer();\n\n  enum MessageFieldComparison {\n    EQUAL,       // Fields must be present in both messages\n                 // for the messages to be considered the same.\n    EQUIVALENT,  // Fields with default values are considered set\n                 // for comparison purposes even if not explicitly\n                 // set in the messages themselves.  Unknown fields\n                 // are ignored.\n  };\n\n  enum Scope {\n    FULL,    // All fields of both messages are considered in the comparison.\n    PARTIAL  // Only fields present in the first message are considered; fields\n             // set only in the second message will be skipped during\n             // comparison.\n  };\n\n  // DEPRECATED. Use FieldComparator::FloatComparison instead.\n  enum FloatComparison {\n    EXACT,       // Floats and doubles are compared exactly.\n    APPROXIMATE  // Floats and doubles are compared using the\n                 // MathUtil::AlmostEquals method.\n  };\n\n  enum RepeatedFieldComparison {\n    AS_LIST,     // Repeated fields are compared in order.  Differing values at\n                 // the same index are reported using ReportModified().  If the\n                 // repeated fields have different numbers of elements, the\n                 // unpaired elements are reported using ReportAdded() or\n                 // ReportDeleted().\n    AS_SET,      // Treat all the repeated fields as sets by default.\n                 // See TreatAsSet(), as below.\n  };\n\n  // The elements of the given repeated field will be treated as a set for\n  // diffing purposes, so different orderings of the same elements will be\n  // considered equal.  Elements which are present on both sides of the\n  // comparison but which have changed position will be reported with\n  // ReportMoved().  Elements which only exist on one side or the other are\n  // reported with ReportAdded() and ReportDeleted() regardless of their\n  // positions.  ReportModified() is never used for this repeated field.  If\n  // the only differences between the compared messages is that some fields\n  // have been moved, then the comparison returns true.\n  //\n  // If the scope of comparison is set to PARTIAL, then in addition to what's\n  // above, extra values added to repeated fields of the second message will\n  // not cause the comparison to fail.\n  //\n  // Note that set comparison is currently O(k * n^2) (where n is the total\n  // number of elements, and k is the average size of each element). In theory\n  // it could be made O(n * k) with a more complex hashing implementation. Feel\n  // free to contribute one if the current implementation is too slow for you.\n  // If partial matching is also enabled, the time complexity will be O(k * n^2\n  // + n^3) in which n^3 is the time complexity of the maximum matching\n  // algorithm.\n  //\n  // REQUIRES:  field->is_repeated() and field not registered with TreatAsList\n  void TreatAsSet(const FieldDescriptor* field);\n\n  // The elements of the given repeated field will be treated as a list for\n  // diffing purposes, so different orderings of the same elements will NOT be\n  // considered equal.\n  //\n  // REQUIRED: field->is_repeated() and field not registered with TreatAsSet\n  void TreatAsList(const FieldDescriptor* field);\n\n  // The elements of the given repeated field will be treated as a map for\n  // diffing purposes, with |key| being the map key.  Thus, elements with the\n  // same key will be compared even if they do not appear at the same index.\n  // Differences are reported similarly to TreatAsSet(), except that\n  // ReportModified() is used to report elements with the same key but\n  // different values.  Note that if an element is both moved and modified,\n  // only ReportModified() will be called.  As with TreatAsSet, if the only\n  // differences between the compared messages is that some fields have been\n  // moved, then the comparison returns true. See TreatAsSet for notes on\n  // performance.\n  //\n  // REQUIRES:  field->is_repeated()\n  // REQUIRES:  field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE\n  // REQUIRES:  key->containing_type() == field->message_type()\n  void TreatAsMap(const FieldDescriptor* field, const FieldDescriptor* key);\n  // Same as TreatAsMap except that this method will use multiple fields as\n  // the key in comparison. All specified fields in 'key_fields' should be\n  // present in the compared elements. Two elements will be treated as having\n  // the same key iff they have the same value for every specified field. There\n  // are two steps in the comparison process. The first one is key matching.\n  // Every element from one message will be compared to every element from\n  // the other message. Only fields in 'key_fields' are compared in this step\n  // to decide if two elements have the same key. The second step is value\n  // comparison. Those pairs of elements with the same key (with equal value\n  // for every field in 'key_fields') will be compared in this step.\n  // Time complexity of the first step is O(s * m * n ^ 2) where s is the\n  // average size of the fields specified in 'key_fields', m is the number of\n  // fields in 'key_fields' and n is the number of elements. If partial\n  // matching is enabled, an extra O(n^3) will be incured by the maximum\n  // matching algorithm. The second step is O(k * n) where k is the average\n  // size of each element.\n  void TreatAsMapWithMultipleFieldsAsKey(\n      const FieldDescriptor* field,\n      const vector<const FieldDescriptor*>& key_fields);\n  // Same as TreatAsMapWithMultipleFieldsAsKey, except that each of the field\n  // do not necessarily need to be a direct subfield. Each element in\n  // key_field_paths indicate a path from the message being compared, listing\n  // successive subfield to reach the key field.\n  //\n  // REQUIRES:\n  //   for key_field_path in key_field_paths:\n  //     key_field_path[0]->containing_type() == field->message_type()\n  //     for i in [0, key_field_path.size() - 1):\n  //       key_field_path[i+1]->containing_type() ==\n  //           key_field_path[i]->message_type()\n  //       key_field_path[i]->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE\n  //       !key_field_path[i]->is_repeated()\n  void TreatAsMapWithMultipleFieldPathsAsKey(\n      const FieldDescriptor* field,\n      const vector<vector<const FieldDescriptor*> >& key_field_paths);\n\n  // Uses a custom MapKeyComparator to determine if two elements have the same\n  // key when comparing a repeated field as a map.\n  // The caller is responsible to delete the key_comparator.\n  // This method varies from TreatAsMapWithMultipleFieldsAsKey only in the\n  // first key matching step. Rather than comparing some specified fields, it\n  // will invoke the IsMatch method of the given 'key_comparator' to decide if\n  // two elements have the same key.\n  void TreatAsMapUsingKeyComparator(\n      const FieldDescriptor* field,\n      const MapKeyComparator* key_comparator);\n\n  // Add a custom ignore criteria that is evaluated in addition to the\n  // ignored fields added with IgnoreField.\n  // Takes ownership of ignore_criteria.\n  void AddIgnoreCriteria(IgnoreCriteria* ignore_criteria);\n\n  // Indicates that any field with the given descriptor should be\n  // ignored for the purposes of comparing two messages. This applies\n  // to fields nested in the message structure as well as top level\n  // ones. When the MessageDifferencer encounters an ignored field,\n  // ReportIgnored is called on the reporter, if one is specified.\n  //\n  // The only place where the field's 'ignored' status is not applied is when\n  // it is being used as a key in a field passed to TreatAsMap or is one of\n  // the fields passed to TreatAsMapWithMultipleFieldsAsKey.\n  // In this case it is compared in key matching but after that it's ignored\n  // in value comparison.\n  void IgnoreField(const FieldDescriptor* field);\n\n  // Sets the field comparator used to determine differences between protocol\n  // buffer fields. By default it's set to a DefaultFieldComparator instance.\n  // MessageDifferencer doesn't take ownership over the passed object.\n  // Note that this method must be called before Compare for the comparator to\n  // be used.\n  void set_field_comparator(FieldComparator* comparator);\n\n  // DEPRECATED. Pass a DefaultFieldComparator instance instead.\n  // Sets the fraction and margin for the float comparison of a given field.\n  // Uses MathUtil::WithinFractionOrMargin to compare the values.\n  // NOTE: this method does nothing if differencer's field comparator has been\n  //       set to a custom object.\n  //\n  // REQUIRES: field->cpp_type == FieldDescriptor::CPPTYPE_DOUBLE or\n  //           field->cpp_type == FieldDescriptor::CPPTYPE_FLOAT\n  // REQUIRES: float_comparison_ == APPROXIMATE\n  void SetFractionAndMargin(const FieldDescriptor* field, double fraction,\n                            double margin);\n\n  // Sets the type of comparison (as defined in the MessageFieldComparison\n  // enumeration above) that is used by this differencer when determining how\n  // to compare fields in messages.\n  void set_message_field_comparison(MessageFieldComparison comparison);\n\n  // Tells the differencer whether or not to report matches. This method must\n  // be called before Compare. The default for a new differencer is false.\n  void set_report_matches(bool report_matches) {\n    report_matches_ = report_matches;\n  }\n\n  // Sets the scope of the comparison (as defined in the Scope enumeration\n  // above) that is used by this differencer when determining which fields to\n  // compare between the messages.\n  void set_scope(Scope scope);\n\n  // Returns the current scope used by this differencer.\n  Scope scope();\n\n  // DEPRECATED. Pass a DefaultFieldComparator instance instead.\n  // Sets the type of comparison (as defined in the FloatComparison enumeration\n  // above) that is used by this differencer when comparing float (and double)\n  // fields in messages.\n  // NOTE: this method does nothing if differencer's field comparator has been\n  //       set to a custom object.\n  void set_float_comparison(FloatComparison comparison);\n\n  // Sets the type of comparison for repeated field (as defined in the\n  // RepeatedFieldComparison enumeration above) that is used by this\n  // differencer when compare repeated fields in messages.\n  void set_repeated_field_comparison(RepeatedFieldComparison comparison);\n\n  // Compares the two specified messages, returning true if they are the same,\n  // false otherwise. If this method returns false, any changes between the\n  // two messages will be reported if a Reporter was specified via\n  // ReportDifferencesTo (see also ReportDifferencesToString).\n  //\n  // This method REQUIRES that the two messages have the same\n  // Descriptor (message1.GetDescriptor() == message2.GetDescriptor()).\n  bool Compare(const Message& message1, const Message& message2);\n\n  // Same as above, except comparing only the list of fields specified by the\n  // two vectors of FieldDescriptors.\n  bool CompareWithFields(const Message& message1, const Message& message2,\n                         const vector<const FieldDescriptor*>& message1_fields,\n                         const vector<const FieldDescriptor*>& message2_fields);\n\n  // Automatically creates a reporter that will output the differences\n  // found (if any) to the specified output string pointer. Note that this\n  // method must be called before Compare.\n  void ReportDifferencesToString(string* output);\n\n  // Tells the MessageDifferencer to report differences via the specified\n  // reporter. Note that this method must be called before Compare for\n  // the reporter to be used. It is the responsibility of the caller to delete\n  // this object.\n  // If the provided pointer equals NULL, the MessageDifferencer stops reporting\n  // differences to any previously set reporters or output strings.\n  void ReportDifferencesTo(Reporter* reporter);\n\n  // An implementation of the MessageDifferencer Reporter that outputs\n  // any differences found in human-readable form to the supplied\n  // ZeroCopyOutputStream or Printer. If a printer is used, the delimiter\n  // *must* be '$'.\n  //\n  // WARNING: this reporter does not necessarily flush its output until it is\n  // destroyed. As a result, it is not safe to assume the output is valid or\n  // complete until after you destroy the reporter. For example, if you use a\n  // StreamReporter to write to a StringOutputStream, the target string may\n  // contain uninitialized data until the reporter is destroyed.\n  class LIBPROTOBUF_EXPORT StreamReporter : public Reporter {\n   public:\n    explicit StreamReporter(io::ZeroCopyOutputStream* output);\n    explicit StreamReporter(io::Printer* printer);  // delimiter '$'\n    virtual ~StreamReporter();\n\n    // When set to true, the stream reporter will also output aggregates nodes\n    // (i.e. messages and groups) whose subfields have been modified. When\n    // false, will only report the individual subfields. Defaults to false.\n    void set_report_modified_aggregates(bool report) {\n      report_modified_aggregates_ = report;\n    }\n\n    // The following are implementations of the methods described above.\n    virtual void ReportAdded(const Message& message1, const Message& message2,\n                             const vector<SpecificField>& field_path);\n\n    virtual void ReportDeleted(const Message& message1,\n                               const Message& message2,\n                               const vector<SpecificField>& field_path);\n\n    virtual void ReportModified(const Message& message1,\n                                const Message& message2,\n                                const vector<SpecificField>& field_path);\n\n    virtual void ReportMoved(const Message& message1,\n                             const Message& message2,\n                             const vector<SpecificField>& field_path);\n\n    virtual void ReportMatched(const Message& message1,\n                               const Message& message2,\n                               const vector<SpecificField>& field_path);\n\n    virtual void ReportIgnored(const Message& message1,\n                               const Message& message2,\n                               const vector<SpecificField>& field_path);\n\n    virtual void ReportUnknownFieldIgnored(\n        const Message& message1, const Message& message2,\n        const vector<SpecificField>& field_path);\n\n   protected:\n    // Prints the specified path of fields to the buffer.\n    virtual void PrintPath(const vector<SpecificField>& field_path,\n                           bool left_side);\n\n    // Prints the value of fields to the buffer.  left_side is true if the\n    // given message is from the left side of the comparison, false if it\n    // was the right.  This is relevant only to decide whether to follow\n    // unknown_field_index1 or unknown_field_index2 when an unknown field\n    // is encountered in field_path.\n    virtual void PrintValue(const Message& message,\n                            const vector<SpecificField>& field_path,\n                            bool left_side);\n\n    // Prints the specified path of unknown fields to the buffer.\n    virtual void PrintUnknownFieldValue(const UnknownField* unknown_field);\n\n    // Just print a string\n    void Print(const string& str);\n\n   private:\n    io::Printer* printer_;\n    bool delete_printer_;\n    bool report_modified_aggregates_;\n\n    GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(StreamReporter);\n  };\n\n private:\n  // A MapKeyComparator to be used in TreatAsMapUsingKeyComparator.\n  // Implementation of this class needs to do field value comparison which\n  // relies on some private methods of MessageDifferencer. That's why this\n  // class is declared as a nested class of MessageDifferencer.\n  class MultipleFieldsMapKeyComparator;\n  // Returns true if field1's number() is less than field2's.\n  static bool FieldBefore(const FieldDescriptor* field1,\n                          const FieldDescriptor* field2);\n\n  // Combine the two lists of fields into the combined_fields output vector.\n  // All fields present in both lists will always be included in the combined\n  // list.  Fields only present in one of the lists will only appear in the\n  // combined list if the corresponding fields_scope option is set to FULL.\n  void CombineFields(const vector<const FieldDescriptor*>& fields1,\n                     Scope fields1_scope,\n                     const vector<const FieldDescriptor*>& fields2,\n                     Scope fields2_scope,\n                     vector<const FieldDescriptor*>* combined_fields);\n\n  // Internal version of the Compare method which performs the actual\n  // comparison. The parent_fields vector is a vector containing field\n  // descriptors of all fields accessed to get to this comparison operation\n  // (i.e. if the current message is an embedded message, the parent_fields\n  // vector will contain the field that has this embedded message).\n  bool Compare(const Message& message1, const Message& message2,\n               vector<SpecificField>* parent_fields);\n\n  // Compares all the unknown fields in two messages.\n  bool CompareUnknownFields(const Message& message1, const Message& message2,\n                            const google::protobuf::UnknownFieldSet&,\n                            const google::protobuf::UnknownFieldSet&,\n                            vector<SpecificField>* parent_fields);\n\n  // Compares the specified messages for the requested field lists. The field\n  // lists are modified depending on comparison settings, and then passed to\n  // CompareWithFieldsInternal.\n  bool CompareRequestedFieldsUsingSettings(\n      const Message& message1, const Message& message2,\n      const vector<const FieldDescriptor*>& message1_fields,\n      const vector<const FieldDescriptor*>& message2_fields,\n      vector<SpecificField>* parent_fields);\n\n  // Compares the specified messages with the specified field lists.\n  bool CompareWithFieldsInternal(\n      const Message& message1, const Message& message2,\n      const vector<const FieldDescriptor*>& message1_fields,\n      const vector<const FieldDescriptor*>& message2_fields,\n      vector<SpecificField>* parent_fields);\n\n  // Compares the repeated fields, and report the error.\n  bool CompareRepeatedField(const Message& message1, const Message& message2,\n                            const FieldDescriptor* field,\n                            vector<SpecificField>* parent_fields);\n\n  // Shorthand for CompareFieldValueUsingParentFields with NULL parent_fields.\n  bool CompareFieldValue(const Message& message1,\n                         const Message& message2,\n                         const FieldDescriptor* field,\n                         int index1,\n                         int index2);\n\n  // Compares the specified field on the two messages, returning\n  // true if they are the same, false otherwise. For repeated fields,\n  // this method only compares the value in the specified index. This method\n  // uses Compare functions to recurse into submessages.\n  // The parent_fields vector is used in calls to a Reporter instance calls.\n  // It can be NULL, in which case the MessageDifferencer will create new\n  // list of parent messages if it needs to recursively compare the given field.\n  // To avoid confusing users you should not set it to NULL unless you modified\n  // Reporter to handle the change of parent_fields correctly.\n  bool CompareFieldValueUsingParentFields(const Message& message1,\n                                          const Message& message2,\n                                          const FieldDescriptor* field,\n                                          int index1,\n                                          int index2,\n                                          vector<SpecificField>* parent_fields);\n\n  // Compares the specified field on the two messages, returning comparison\n  // result, as returned by appropriate FieldComparator.\n  FieldComparator::ComparisonResult GetFieldComparisonResult(\n      const Message& message1, const Message& message2,\n      const FieldDescriptor* field, int index1, int index2,\n      const FieldContext* field_context);\n\n  // Check if the two elements in the repeated field are match to each other.\n  // if the key_comprator is NULL, this function returns true when the two\n  // elements are equal.\n  bool IsMatch(const FieldDescriptor* repeated_field,\n               const MapKeyComparator* key_comparator,\n               const Message* message1, const Message* message2,\n               const vector<SpecificField>& parent_fields,\n               int index1, int index2);\n\n  // Returns true when this repeated field has been configured to be treated\n  // as a set.\n  bool IsTreatedAsSet(const FieldDescriptor* field);\n\n  // Returns true when this repeated field is to be compared as a subset, ie.\n  // has been configured to be treated as a set or map and scope is set to\n  // PARTIAL.\n  bool IsTreatedAsSubset(const FieldDescriptor* field);\n\n  // Returns true if this field is to be ignored when this\n  // MessageDifferencer compares messages.\n  bool IsIgnored(\n      const Message& message1,\n      const Message& message2,\n      const FieldDescriptor* field,\n      const vector<SpecificField>& parent_fields);\n\n  // Returns true if this unknown field is to be ignored when this\n  // MessageDifferencer compares messages.\n  bool IsUnknownFieldIgnored(const Message& message1, const Message& message2,\n                             const SpecificField& field,\n                             const vector<SpecificField>& parent_fields);\n\n  // Returns MapKeyComparator* when this field has been configured to\n  // be treated as a map.  If not, returns NULL.\n  const MapKeyComparator* GetMapKeyComparator(const FieldDescriptor* field);\n\n  // Attempts to match indices of a repeated field, so that the contained values\n  // match. Clears output vectors and sets their values to indices of paired\n  // messages, ie. if message1[0] matches message2[1], then match_list1[0] == 1\n  // and match_list2[1] == 0. The unmatched indices are indicated by -1.\n  // This method returns false if the match failed. However, it doesn't mean\n  // that the comparison succeeds when this method returns true (you need to\n  // double-check in this case).\n  bool MatchRepeatedFieldIndices(const Message& message1,\n                                 const Message& message2,\n                                 const FieldDescriptor* repeated_field,\n                                 const vector<SpecificField>& parent_fields,\n                                 vector<int>* match_list1,\n                                 vector<int>* match_list2);\n\n  // If \"any\" is of type google.protobuf.Any, extract its payload using\n  // DynamicMessageFactory and store in \"data\".\n  bool UnpackAny(const Message& any, google::protobuf::scoped_ptr<Message>* data);\n\n  // Checks if index is equal to new_index in all the specific fields.\n  static bool CheckPathChanged(const vector<SpecificField>& parent_fields);\n\n  // Defines a map between field descriptors and their MapKeyComparators.\n  // Used for repeated fields when they are configured as TreatAsMap.\n  typedef map<const FieldDescriptor*,\n              const MapKeyComparator*> FieldKeyComparatorMap;\n\n  // Defines a set to store field descriptors.  Used for repeated fields when\n  // they are configured as TreatAsSet.\n  typedef set<const FieldDescriptor*> FieldSet;\n\n  Reporter* reporter_;\n  DefaultFieldComparator default_field_comparator_;\n  FieldComparator* field_comparator_;\n  MessageFieldComparison message_field_comparison_;\n  Scope scope_;\n  RepeatedFieldComparison repeated_field_comparison_;\n\n  FieldSet set_fields_;\n  FieldSet list_fields_;\n  // Keeps track of MapKeyComparators that are created within\n  // MessageDifferencer. These MapKeyComparators should be deleted\n  // before MessageDifferencer is destroyed.\n  // When TreatAsMap or TreatAsMapWithMultipleFieldsAsKey is called, we don't\n  // store the supplied FieldDescriptors directly. Instead, a new\n  // MapKeyComparator is created for comparison purpose.\n  vector<MapKeyComparator*> owned_key_comparators_;\n  FieldKeyComparatorMap map_field_key_comparator_;\n  vector<IgnoreCriteria*> ignore_criteria_;\n\n  FieldSet ignored_fields_;\n\n  bool compare_unknown_fields_;\n  bool report_matches_;\n\n  string* output_string_;\n\n  google::protobuf::scoped_ptr<DynamicMessageFactory> dynamic_message_factory_;\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MessageDifferencer);\n};\n\n// This class provides extra information to the FieldComparator::Compare\n// function.\nclass LIBPROTOBUF_EXPORT FieldContext {\n public:\n  explicit FieldContext(\n      vector<MessageDifferencer::SpecificField>* parent_fields)\n      : parent_fields_(parent_fields) {}\n\n  vector<MessageDifferencer::SpecificField>* parent_fields() const {\n    return parent_fields_;\n  }\n\n private:\n  vector<MessageDifferencer::SpecificField>* parent_fields_;\n};\n\n}\n}\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_MESSAGE_DIFFERENCER_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/message_differencer_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: jschorr@google.com (Joseph Schorr)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// TODO(ksroka): Move some of these tests to field_comparator_test.cc.\n\n#include <algorithm>\n#include <string>\n#include <vector>\n\n\n#include <google/protobuf/util/field_comparator.h>\n#include <google/protobuf/util/message_differencer.h>\n#include <google/protobuf/util/message_differencer_unittest.pb.h>\n#include <google/protobuf/text_format.h>\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/any_test.pb.h>\n#include <google/protobuf/map_unittest.pb.h>\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/map_test_util.h>\n#include <google/protobuf/test_util.h>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\n\nnamespace {\n\n\nconst FieldDescriptor* GetFieldDescriptor(\n    const Message& message, const string& field_name) {\n  vector<string> field_path =\n      Split(field_name, \".\", true);\n  const Descriptor* descriptor = message.GetDescriptor();\n  const FieldDescriptor* field = NULL;\n  for (int i = 0; i < field_path.size(); i++) {\n    field = descriptor->FindFieldByName(field_path[i]);\n    descriptor = field->message_type();\n  }\n  return field;\n}\n\nvoid ExpectEqualsWithDifferencer(util::MessageDifferencer* differencer,\n                                 const Message& msg1,\n                                 const Message& msg2) {\n  differencer->set_scope(util::MessageDifferencer::FULL);\n  EXPECT_TRUE(differencer->Compare(msg1, msg2));\n\n  differencer->set_scope(util::MessageDifferencer::PARTIAL);\n  EXPECT_TRUE(differencer->Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, BasicEqualityTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  // Compare\n  EXPECT_TRUE(util::MessageDifferencer::Equals(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, BasicInequalityTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  msg1.set_optional_int32(-1);\n\n  // Compare\n  EXPECT_FALSE(util::MessageDifferencer::Equals(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, RepeatedFieldInequalityTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  msg1.add_repeated_int32(-1);\n\n  // Compare\n  EXPECT_FALSE(util::MessageDifferencer::Equals(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, MapFieldEqualityTest) {\n  // Create the testing protos\n  unittest::TestMap msg1;\n  unittest::TestMap msg2;\n\n  MapReflectionTester tester(unittest::TestMap::descriptor());\n  tester.SetMapFieldsViaReflection(&msg1);\n  tester.SetMapFieldsViaReflection(&msg2);\n  tester.SwapMapsViaReflection(&msg1);\n\n  // Compare\n  EXPECT_TRUE(util::MessageDifferencer::Equals(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, BasicPartialEqualityTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  // Compare\n  util::MessageDifferencer differencer;\n  differencer.set_scope(util::MessageDifferencer::PARTIAL);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, PartialEqualityTestExtraField) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  msg1.clear_optional_int32();\n\n  // Compare\n  util::MessageDifferencer differencer;\n  differencer.set_scope(util::MessageDifferencer::PARTIAL);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, PartialEqualityTestSkipRequiredField) {\n  // Create the testing protos\n  unittest::TestRequired msg1;\n  unittest::TestRequired msg2;\n\n  msg1.set_a(401);\n  msg2.set_a(401);\n  msg2.set_b(402);\n\n  // Compare\n  util::MessageDifferencer differencer;\n  differencer.set_scope(util::MessageDifferencer::PARTIAL);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, BasicPartialInequalityTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  msg1.set_optional_int32(-1);\n\n  // Compare\n  util::MessageDifferencer differencer;\n  differencer.set_scope(util::MessageDifferencer::PARTIAL);\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, PartialInequalityMissingFieldTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  msg2.clear_optional_int32();\n\n  // Compare\n  util::MessageDifferencer differencer;\n  differencer.set_scope(util::MessageDifferencer::PARTIAL);\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, RepeatedFieldPartialInequalityTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  msg1.add_repeated_int32(-1);\n\n  // Compare\n  util::MessageDifferencer differencer;\n  differencer.set_scope(util::MessageDifferencer::PARTIAL);\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, BasicEquivalencyTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  // Compare\n  EXPECT_TRUE(util::MessageDifferencer::Equivalent(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, EquivalencyNotEqualTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  msg1.clear_optional_int32();\n  msg2.set_optional_int32(0);\n\n  // Compare\n  EXPECT_FALSE(util::MessageDifferencer::Equals(msg1, msg2));\n  EXPECT_TRUE(util::MessageDifferencer::Equivalent(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, BasicInequivalencyTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  msg1.set_optional_int32(-1);\n\n  // Compare\n  EXPECT_FALSE(util::MessageDifferencer::Equivalent(msg1, msg2));\n}\n\n\nTEST(MessageDifferencerTest, BasicEquivalencyNonSetTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  // Compare\n  EXPECT_TRUE(util::MessageDifferencer::Equivalent(msg1, msg2));\n}\n\n\nTEST(MessageDifferencerTest, BasicInequivalencyNonSetTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  msg1.set_optional_int32(-1);\n\n  // Compare\n  EXPECT_FALSE(util::MessageDifferencer::Equivalent(msg1, msg2));\n}\n\n\nTEST(MessageDifferencerTest, BasicPartialEquivalencyTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  // Compare\n  util::MessageDifferencer differencer;\n  differencer.set_message_field_comparison(\n      util::MessageDifferencer::EQUIVALENT);\n  differencer.set_scope(util::MessageDifferencer::PARTIAL);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, PartialEquivalencyNotEqualTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  msg1.set_optional_int32(0);\n  msg2.clear_optional_int32();\n\n  // Compare\n  EXPECT_FALSE(util::MessageDifferencer::Equals(msg1, msg2));\n  util::MessageDifferencer differencer;\n  differencer.set_message_field_comparison(\n      util::MessageDifferencer::EQUIVALENT);\n  differencer.set_scope(util::MessageDifferencer::PARTIAL);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, PartialEquivalencyTestExtraField) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  msg1.clear_optional_int32();\n\n  // Compare\n  util::MessageDifferencer differencer;\n  differencer.set_message_field_comparison(\n      util::MessageDifferencer::EQUIVALENT);\n  differencer.set_scope(util::MessageDifferencer::PARTIAL);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, PartialEquivalencyTestSkipRequiredField) {\n  // Create the testing protos\n  unittest::TestRequired msg1;\n  unittest::TestRequired msg2;\n\n  msg1.set_a(401);\n  msg2.set_a(401);\n  msg2.set_b(402);\n\n  // Compare\n  util::MessageDifferencer differencer;\n  differencer.set_message_field_comparison(\n      util::MessageDifferencer::EQUIVALENT);\n  differencer.set_scope(util::MessageDifferencer::PARTIAL);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, BasicPartialInequivalencyTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  msg1.set_optional_int32(-1);\n\n  // Compare\n  util::MessageDifferencer differencer;\n  differencer.set_message_field_comparison(\n      util::MessageDifferencer::EQUIVALENT);\n  differencer.set_scope(util::MessageDifferencer::PARTIAL);\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, BasicPartialEquivalencyNonSetTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  // Compare\n  util::MessageDifferencer differencer;\n  differencer.set_message_field_comparison(\n      util::MessageDifferencer::EQUIVALENT);\n  differencer.set_scope(util::MessageDifferencer::PARTIAL);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, BasicPartialInequivalencyNonSetTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  msg1.set_optional_int32(-1);\n\n  // Compare\n  util::MessageDifferencer differencer;\n  differencer.set_message_field_comparison(\n      util::MessageDifferencer::EQUIVALENT);\n  differencer.set_scope(util::MessageDifferencer::PARTIAL);\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, ApproximateEqualityTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  // Compare\n  EXPECT_TRUE(util::MessageDifferencer::ApproximatelyEquals(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, ApproximateModifiedEqualityTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  const float v1 = 2.300005f;\n  const float v2 = 2.300006f;\n  msg1.set_optional_float(v1);\n  msg2.set_optional_float(v2);\n\n  // Compare\n  ASSERT_NE(v1, v2) << \"Should not be the same: \" << v1 << \", \" << v2;\n  ASSERT_FLOAT_EQ(v1, v2) << \"Should be approx. equal: \" << v1 << \", \" << v2;\n  EXPECT_FALSE(util::MessageDifferencer::Equals(msg1, msg2));\n  EXPECT_TRUE(util::MessageDifferencer::ApproximatelyEquals(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, ApproximateEquivalencyTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  // Compare\n  EXPECT_TRUE(util::MessageDifferencer::ApproximatelyEquivalent(msg1,\n                                                                msg2));\n}\n\nTEST(MessageDifferencerTest, ApproximateModifiedEquivalencyTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  // Modify the approximateness requirement\n  const float v1 = 2.300005f;\n  const float v2 = 2.300006f;\n  msg1.set_optional_float(v1);\n  msg2.set_optional_float(v2);\n\n  // Compare\n  ASSERT_NE(v1, v2) << \"Should not be the same: \" << v1 << \", \" << v2;\n  ASSERT_FLOAT_EQ(v1, v2) << \"Should be approx. equal: \" << v1 << \", \" << v2;\n  EXPECT_FALSE(util::MessageDifferencer::Equals(msg1, msg2));\n  EXPECT_TRUE(util::MessageDifferencer::ApproximatelyEquivalent(msg1,\n                                                                msg2));\n\n  // Modify the equivalency requirement too\n  msg1.clear_optional_int32();\n  msg2.set_optional_int32(0);\n\n  // Compare. Now should only pass on ApproximatelyEquivalent\n  EXPECT_FALSE(util::MessageDifferencer::Equals(msg1, msg2));\n  EXPECT_FALSE(util::MessageDifferencer::Equivalent(msg1, msg2));\n  EXPECT_FALSE(util::MessageDifferencer::ApproximatelyEquals(msg1, msg2));\n  EXPECT_TRUE(util::MessageDifferencer::ApproximatelyEquivalent(msg1,\n                                                                msg2));\n}\n\nTEST(MessageDifferencerTest, ApproximateInequivalencyTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  // Should fail on equivalency\n  msg1.set_optional_int32(-1);\n  EXPECT_FALSE(util::MessageDifferencer::ApproximatelyEquivalent(msg1,\n                                                                 msg2));\n\n  // Make these fields the same again.\n  msg1.set_optional_int32(0);\n  msg2.set_optional_int32(0);\n  EXPECT_TRUE(util::MessageDifferencer::ApproximatelyEquivalent(msg1,\n                                                                msg2));\n\n  // Should fail on approximate equality check\n  const float v1 = 2.3f;\n  const float v2 = 9.3f;\n  msg1.set_optional_float(v1);\n  msg2.set_optional_float(v2);\n  EXPECT_FALSE(util::MessageDifferencer::ApproximatelyEquivalent(msg1,\n                                                                 msg2));\n}\n\nTEST(MessageDifferencerTest, WithinFractionOrMarginFloatTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  // Should fail on approximate equality check\n  const float v1 = 100.0f;\n  const float v2 = 109.9f;\n  msg1.set_optional_float(v1);\n  msg2.set_optional_float(v2);\n\n  // Compare\n  util::MessageDifferencer differencer;\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n  const FieldDescriptor* fd =\n      msg1.GetDescriptor()->FindFieldByName(\"optional_float\");\n\n  // Set float comparison to exact, margin and fraction value should not matter.\n  differencer.set_float_comparison(util::MessageDifferencer::EXACT);\n  // Set margin for float comparison.\n  differencer.SetFractionAndMargin(fd, 0.0, 10.0);\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n\n  // Margin and fraction float comparison is activated when float comparison is\n  // set to approximate.\n  differencer.set_float_comparison(util::MessageDifferencer::APPROXIMATE);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n\n  // Test out float comparison with fraction.\n  differencer.SetFractionAndMargin(fd, 0.2, 0.0);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n\n  // Should fail since the fraction is smaller than error.\n  differencer.SetFractionAndMargin(fd, 0.01, 0.0);\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n\n  // Should pass if either fraction or margin are satisfied.\n  differencer.SetFractionAndMargin(fd, 0.01, 10.0);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n\n  // Make sure that the margin and fraction only affects the field that it was\n  // set for.\n  msg1.set_default_float(v1);\n  msg2.set_default_float(v2);\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n  msg1.set_default_float(v1);\n  msg2.set_default_float(v1);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, WithinFractionOrMarginDoubleTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  // Should fail on approximate equality check\n  const double v1 = 100.0;\n  const double v2 = 109.9;\n  msg1.set_optional_double(v1);\n  msg2.set_optional_double(v2);\n\n  // Compare\n  util::MessageDifferencer differencer;\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n\n  // Set comparison to exact, margin and fraction value should not matter.\n  differencer.set_float_comparison(util::MessageDifferencer::EXACT);\n  // Set margin for float comparison.\n  const FieldDescriptor* fd =\n      msg1.GetDescriptor()->FindFieldByName(\"optional_double\");\n  differencer.SetFractionAndMargin(fd, 0.0, 10.0);\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n\n  // Margin and fraction comparison is activated when float comparison is\n  // set to approximate.\n  differencer.set_float_comparison(util::MessageDifferencer::APPROXIMATE);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n\n  // Test out comparison with fraction.\n  differencer.SetFractionAndMargin(fd, 0.2, 0.0);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n\n  // Should fail since the fraction is smaller than error.\n  differencer.SetFractionAndMargin(fd, 0.01, 0.0);\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n\n  // Should pass if either fraction or margin are satisfied.\n  differencer.SetFractionAndMargin(fd, 0.01, 10.0);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n\n  // Make sure that the margin and fraction only affects the field that it was\n  // set for.\n  msg1.set_default_double(v1);\n  msg2.set_default_double(v2);\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n  msg1.set_default_double(v1);\n  msg2.set_default_double(v1);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, WithinDefaultFractionOrMarginDoubleTest) {\n  // Create the testing protos\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  // Should fail on approximate equality check\n  const double v1 = 100.0;\n  const double v2 = 109.9;\n  msg1.set_optional_double(v1);\n  msg2.set_optional_double(v2);\n\n  util::MessageDifferencer differencer;\n\n  // Compare\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n\n  // Set up a custom field comparitor, with a default fraction and margin for\n  // float and double comparison.\n  util::DefaultFieldComparator field_comparitor;\n  field_comparitor.SetDefaultFractionAndMargin(0.0, 10.0);\n  differencer.set_field_comparator(&field_comparitor);\n\n  // Set comparison to exact, margin and fraction value should not matter.\n  field_comparitor.set_float_comparison(util::DefaultFieldComparator::EXACT);\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n\n  // Margin and fraction comparison is activated when float comparison is\n  // set to approximate.\n  field_comparitor.set_float_comparison(\n      util::DefaultFieldComparator::APPROXIMATE);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n\n  // Test out comparison with fraction.\n  field_comparitor.SetDefaultFractionAndMargin(0.2, 0.0);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n\n  // Should fail since the fraction is smaller than error.\n  field_comparitor.SetDefaultFractionAndMargin(0.01, 0.0);\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n\n  // Should pass if either fraction or margin are satisfied.\n  field_comparitor.SetDefaultFractionAndMargin(0.01, 10.0);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n\n  // Make sure that the default margin and fraction affects all fields\n  msg1.set_default_double(v1);\n  msg2.set_default_double(v2);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, BasicFieldOrderingsTest) {\n  // Create the testing protos\n  unittest::TestFieldOrderings msg1;\n  unittest::TestFieldOrderings msg2;\n\n  TestUtil::SetAllFieldsAndExtensions(&msg1);\n  TestUtil::SetAllFieldsAndExtensions(&msg2);\n\n  // Compare\n  EXPECT_TRUE(util::MessageDifferencer::Equals(msg1, msg2));\n}\n\n\nTEST(MessageDifferencerTest, BasicFieldOrderingInequalityTest) {\n  // Create the testing protos\n  unittest::TestFieldOrderings msg1;\n  unittest::TestFieldOrderings msg2;\n\n  TestUtil::SetAllFieldsAndExtensions(&msg1);\n  TestUtil::SetAllFieldsAndExtensions(&msg2);\n\n  msg1.set_my_float(15.00);\n  msg2.set_my_float(16.00);\n\n  // Compare\n  EXPECT_FALSE(util::MessageDifferencer::Equals(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, BasicExtensionTest) {\n  // Create the testing protos\n  unittest::TestAllExtensions msg1;\n  unittest::TestAllExtensions msg2;\n\n  TestUtil::SetAllExtensions(&msg1);\n  TestUtil::SetAllExtensions(&msg2);\n\n  // Compare\n  EXPECT_TRUE(util::MessageDifferencer::Equals(msg1, msg2));\n}\n\n\nTEST(MessageDifferencerTest, BasicExtensionInequalityTest) {\n  // Create the testing protos\n  unittest::TestAllExtensions msg1;\n  unittest::TestAllExtensions msg2;\n\n  TestUtil::SetAllExtensions(&msg1);\n  TestUtil::SetAllExtensions(&msg2);\n\n  msg1.SetExtension(unittest::optional_int32_extension, 101);\n  msg2.SetExtension(unittest::optional_int32_extension, 102);\n\n  // Compare\n  EXPECT_FALSE(util::MessageDifferencer::Equals(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, OneofTest) {\n  // Create the testing protos\n  unittest::TestOneof2 msg1;\n  unittest::TestOneof2 msg2;\n\n  TestUtil::SetOneof1(&msg1);\n  TestUtil::SetOneof1(&msg2);\n\n  // Compare\n  EXPECT_TRUE(util::MessageDifferencer::Equals(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, OneofInequalityTest) {\n  // Create the testing protos\n  unittest::TestOneof2 msg1;\n  unittest::TestOneof2 msg2;\n\n  TestUtil::SetOneof1(&msg1);\n  TestUtil::SetOneof2(&msg2);\n\n  // Compare\n  EXPECT_FALSE(util::MessageDifferencer::Equals(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, UnknownFieldPartialEqualTest) {\n  unittest::TestEmptyMessage empty1;\n  unittest::TestEmptyMessage empty2;\n\n  UnknownFieldSet* unknown1 = empty1.mutable_unknown_fields();\n  UnknownFieldSet* unknown2 = empty2.mutable_unknown_fields();\n\n  unknown1->AddVarint(243, 122);\n  unknown1->AddLengthDelimited(245, \"abc\");\n  unknown1->AddGroup(246)->AddFixed32(248, 1);\n  unknown1->mutable_field(2)->mutable_group()->AddFixed32(248, 2);\n\n  unknown2->AddVarint(243, 122);\n  unknown2->AddLengthDelimited(245, \"abc\");\n  unknown2->AddGroup(246)->AddFixed32(248, 1);\n  unknown2->mutable_field(2)->mutable_group()->AddFixed32(248, 2);\n\n  util::MessageDifferencer differencer;\n  differencer.set_scope(util::MessageDifferencer::PARTIAL);\n  EXPECT_TRUE(differencer.Compare(empty1, empty2));\n}\n\nTEST(MessageDifferencerTest, SpecifiedFieldsEqualityAllTest) {\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  vector<const FieldDescriptor*> fields1;\n  vector<const FieldDescriptor*> fields2;\n  msg1.GetReflection()->ListFields(msg1, &fields1);\n  msg2.GetReflection()->ListFields(msg2, &fields2);\n\n  util::MessageDifferencer differencer;\n  EXPECT_TRUE(differencer.CompareWithFields(msg1, msg2, fields1, fields2));\n}\n\nTEST(MessageDifferencerTest, SpecifiedFieldsInequalityAllTest) {\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n\n  vector<const FieldDescriptor*> fields1;\n  vector<const FieldDescriptor*> fields2;\n  msg1.GetReflection()->ListFields(msg1, &fields1);\n  msg2.GetReflection()->ListFields(msg2, &fields2);\n\n  util::MessageDifferencer differencer;\n  EXPECT_FALSE(differencer.CompareWithFields(msg1, msg2, fields1, fields2));\n}\n\nTEST(MessageDifferencerTest, SpecifiedFieldsEmptyListAlwaysSucceeds) {\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n\n  vector<const FieldDescriptor*> empty_fields;\n\n  util::MessageDifferencer differencer;\n  EXPECT_TRUE(differencer.CompareWithFields(msg1, msg2,\n                                            empty_fields, empty_fields));\n\n  TestUtil::SetAllFields(&msg2);\n  EXPECT_TRUE(differencer.CompareWithFields(msg1, msg2,\n                                            empty_fields, empty_fields));\n}\n\nTEST(MessageDifferencerTest, SpecifiedFieldsCompareWithSelf) {\n  unittest::TestAllTypes msg1;\n  TestUtil::SetAllFields(&msg1);\n\n  vector<const FieldDescriptor*> fields;\n  msg1.GetReflection()->ListFields(msg1, &fields);\n\n  util::MessageDifferencer differencer;\n  EXPECT_TRUE(differencer.CompareWithFields(msg1, msg1, fields, fields));\n\n  {\n    // Compare with a subset of fields.\n    vector<const FieldDescriptor*> compare_fields;\n    for (int i = 0; i < fields.size(); ++i) {\n      if (i % 2 == 0) {\n        compare_fields.push_back(fields[i]);\n      }\n    }\n    EXPECT_TRUE(differencer.CompareWithFields(msg1, msg1,\n                                              compare_fields, compare_fields));\n  }\n  {\n    // Specify a different set of fields to compare, even though we're using the\n    // same message. This should fail, since we are explicitly saying that the\n    // set of fields are different.\n    vector<const FieldDescriptor*> compare_fields1;\n    vector<const FieldDescriptor*> compare_fields2;\n    for (int i = 0; i < fields.size(); ++i) {\n      if (i % 2 == 0) {\n        compare_fields1.push_back(fields[i]);\n      } else {\n        compare_fields2.push_back(fields[i]);\n      }\n    }\n    EXPECT_FALSE(differencer.CompareWithFields(\n        msg1, msg1, compare_fields1, compare_fields2));\n  }\n}\n\nTEST(MessageDifferencerTest, SpecifiedFieldsEqualityAllShuffledTest) {\n  // This is a public function, so make sure there are no assumptions about the\n  // list of fields. Randomly shuffle them to make sure that they are properly\n  // ordered for comparison.\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  vector<const FieldDescriptor*> fields1;\n  vector<const FieldDescriptor*> fields2;\n  msg1.GetReflection()->ListFields(msg1, &fields1);\n  msg2.GetReflection()->ListFields(msg2, &fields2);\n\n  std::random_shuffle(fields1.begin(), fields1.end());\n  std::random_shuffle(fields2.begin(), fields2.end());\n\n  util::MessageDifferencer differencer;\n  EXPECT_TRUE(differencer.CompareWithFields(msg1, msg2, fields1, fields2));\n}\n\nTEST(MessageDifferencerTest, SpecifiedFieldsSubsetEqualityTest) {\n  // Specify a set of fields to compare. All the fields are equal.\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  vector<const FieldDescriptor*> fields1;\n  msg1.GetReflection()->ListFields(msg1, &fields1);\n\n  vector<const FieldDescriptor*> compare_fields;\n  // Only compare the field descriptors with even indices.\n  for (int i = 0; i < fields1.size(); ++i) {\n    if (i % 2 == 0) {\n      compare_fields.push_back(fields1[i]);\n    }\n  }\n\n  util::MessageDifferencer differencer;\n  EXPECT_TRUE(differencer.CompareWithFields(msg1, msg2,\n                                            compare_fields, compare_fields));\n}\n\nTEST(MessageDifferencerTest,\n     SpecifiedFieldsSubsetIgnoresOtherFieldDifferencesTest) {\n  // Specify a set of fields to compare, but clear all the other fields in one\n  // of the messages. This should fail a regular compare, but CompareWithFields\n  // should succeed.\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  vector<const FieldDescriptor*> fields1;\n  const Reflection* reflection = msg1.GetReflection();\n  reflection->ListFields(msg1, &fields1);\n\n  vector<const FieldDescriptor*> compare_fields;\n  // Only compare the field descriptors with even indices.\n  for (int i = 0; i < fields1.size(); ++i) {\n    if (i % 2 == 0) {\n      compare_fields.push_back(fields1[i]);\n    } else {\n      reflection->ClearField(&msg2, fields1[i]);\n    }\n  }\n\n  util::MessageDifferencer differencer;\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n  EXPECT_TRUE(differencer.CompareWithFields(msg1, msg2,\n                                            compare_fields, compare_fields));\n}\n\nTEST(MessageDifferencerTest, SpecifiedFieldsDetectsDifferencesTest) {\n  // Change all of the repeated fields in one of the messages, and use only\n  // those fields for comparison.\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n  TestUtil::ModifyRepeatedFields(&msg2);\n\n  vector<const FieldDescriptor*> fields1;\n  msg1.GetReflection()->ListFields(msg1, &fields1);\n\n  vector<const FieldDescriptor*> compare_fields;\n  // Only compare the repeated field descriptors.\n  for (int i = 0; i < fields1.size(); ++i) {\n    if (fields1[i]->is_repeated()) {\n      compare_fields.push_back(fields1[i]);\n    }\n  }\n\n  util::MessageDifferencer differencer;\n  EXPECT_FALSE(differencer.CompareWithFields(msg1, msg2,\n                                             compare_fields, compare_fields));\n}\n\nTEST(MessageDifferencerTest, SpecifiedFieldsEquivalenceAllTest) {\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n\n  TestUtil::SetAllFields(&msg1);\n  TestUtil::SetAllFields(&msg2);\n\n  vector<const FieldDescriptor*> fields1;\n  vector<const FieldDescriptor*> fields2;\n  msg1.GetReflection()->ListFields(msg1, &fields1);\n  msg2.GetReflection()->ListFields(msg2, &fields2);\n\n  util::MessageDifferencer differencer;\n  differencer.set_message_field_comparison(\n      util::MessageDifferencer::EQUIVALENT);\n  EXPECT_TRUE(differencer.CompareWithFields(msg1, msg2, fields1, fields2));\n}\n\nTEST(MessageDifferencerTest,\n     SpecifiedFieldsEquivalenceIgnoresOtherFieldDifferencesTest) {\n  unittest::TestAllTypes msg1;\n  unittest::TestAllTypes msg2;\n  const Descriptor* desc = msg1.GetDescriptor();\n\n  const FieldDescriptor* optional_int32_desc =\n      desc->FindFieldByName(\"optional_int32\");\n  const FieldDescriptor* optional_int64_desc =\n      desc->FindFieldByName(\"optional_int64\");\n  const FieldDescriptor* default_int64_desc =\n      desc->FindFieldByName(\"default_int64\");\n  ASSERT_TRUE(optional_int32_desc != NULL);\n  ASSERT_TRUE(optional_int64_desc != NULL);\n  ASSERT_TRUE(default_int64_desc != NULL);\n  msg1.set_optional_int32(0);\n  msg2.set_optional_int64(0);\n  msg1.set_default_int64(default_int64_desc->default_value_int64());\n\n  // Set a field to a non-default value so we know that field selection is\n  // actually doing something.\n  msg2.set_optional_uint64(23);\n\n  vector<const FieldDescriptor*> fields1;\n  vector<const FieldDescriptor*> fields2;\n  fields1.push_back(optional_int32_desc);\n  fields1.push_back(default_int64_desc);\n\n  fields2.push_back(optional_int64_desc);\n\n  util::MessageDifferencer differencer;\n  EXPECT_FALSE(differencer.CompareWithFields(msg1, msg2, fields1, fields2));\n  differencer.set_message_field_comparison(\n      util::MessageDifferencer::EQUIVALENT);\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n  EXPECT_TRUE(differencer.CompareWithFields(msg1, msg2, fields1, fields2));\n}\n\nTEST(MessageDifferencerTest, RepeatedFieldSetTest_SetOfSet) {\n  // Create the testing protos\n  protobuf_unittest::TestDiffMessage msg1;\n  protobuf_unittest::TestDiffMessage msg2;\n\n  protobuf_unittest::TestDiffMessage::Item* item = msg1.add_item();\n  item->add_ra(1); item->add_ra(2); item->add_ra(3);\n  item = msg1.add_item();\n  item->add_ra(5); item->add_ra(6);\n  item = msg1.add_item();\n  item->add_ra(1); item->add_ra(3);\n  item = msg1.add_item();\n  item->add_ra(6); item->add_ra(7); item->add_ra(8);\n\n  item = msg2.add_item();\n  item->add_ra(6); item->add_ra(5);\n  item = msg2.add_item();\n  item->add_ra(6); item->add_ra(8); item->add_ra(7);\n  item = msg2.add_item();\n  item->add_ra(1); item->add_ra(3);\n  item = msg2.add_item();\n  item->add_ra(3); item->add_ra(2); item->add_ra(1);\n\n  // Compare\n  util::MessageDifferencer differencer;\n  differencer.set_repeated_field_comparison(util::MessageDifferencer::AS_SET);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, RepeatedFieldSetTest_Combination) {\n  // Create the testing protos\n  protobuf_unittest::TestDiffMessage msg1;\n  protobuf_unittest::TestDiffMessage msg2;\n  // Treat \"item\" as Map, with key = \"a\"\n  // Treat \"item.ra\" also as Set\n  // Treat \"rv\" as Set\n  // Treat \"rw\" as List\n  protobuf_unittest::TestDiffMessage::Item* item = msg1.add_item();\n  item->set_a(3);\n  item->add_ra(1); item->add_ra(2); item->add_ra(3);\n  item = msg1.add_item();\n  item->set_a(4);\n  item->add_ra(5); item->add_ra(6);\n  item = msg1.add_item();\n  item->set_a(1);\n  item->add_ra(1); item->add_ra(3);\n  item = msg1.add_item();\n  item->set_a(2);\n  item->add_ra(6); item->add_ra(7); item->add_ra(8);\n\n  item = msg2.add_item();\n  item->set_a(4);\n  item->add_ra(6); item->add_ra(5);\n  item = msg2.add_item();\n  item->set_a(2);\n  item->add_ra(6); item->add_ra(8); item->add_ra(7);\n  item = msg2.add_item();\n  item->set_a(1);\n  item->add_ra(1); item->add_ra(3);\n  item = msg2.add_item();\n  item->set_a(3);\n  item->add_ra(3); item->add_ra(2); item->add_ra(1);\n\n  msg1.add_rv(3);\n  msg1.add_rv(4);\n  msg1.add_rv(7);\n  msg1.add_rv(0);\n  msg2.add_rv(4);\n  msg2.add_rv(3);\n  msg2.add_rv(0);\n  msg2.add_rv(7);\n\n  msg1.add_rw(\"nothing\"); msg2.add_rw(\"nothing\");\n  msg1.add_rw(\"should\"); msg2.add_rw(\"should\");\n  msg1.add_rw(\"change\"); msg2.add_rw(\"change\");\n\n  // Compare\n  util::MessageDifferencer differencer1;\n  differencer1.TreatAsMap(msg1.GetDescriptor()->FindFieldByName(\"item\"),\n                          item->GetDescriptor()->FindFieldByName(\"a\"));\n  differencer1.TreatAsSet(msg1.GetDescriptor()->FindFieldByName(\"rv\"));\n  differencer1.TreatAsSet(item->GetDescriptor()->FindFieldByName(\"ra\"));\n  EXPECT_TRUE(differencer1.Compare(msg1, msg2));\n\n  util::MessageDifferencer differencer2;\n  differencer2.TreatAsMap(msg1.GetDescriptor()->FindFieldByName(\"item\"),\n                          item->GetDescriptor()->FindFieldByName(\"a\"));\n  differencer2.set_repeated_field_comparison(util::MessageDifferencer::AS_SET);\n  differencer2.TreatAsList(msg1.GetDescriptor()->FindFieldByName(\"rw\"));\n  EXPECT_TRUE(differencer2.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, RepeatedFieldMapTest_Partial) {\n  protobuf_unittest::TestDiffMessage msg1;\n  // message msg1 {\n  //   item { a: 1; b: \"11\" }\n  // }\n  protobuf_unittest::TestDiffMessage::Item* item = msg1.add_item();\n  item->set_a(1);\n  item->set_b(\"11\");\n\n  protobuf_unittest::TestDiffMessage msg2;\n  // message msg2 {\n  //   item { a: 2; b: \"22\" }\n  //   item { a: 1; b: \"11\" }\n  // }\n  item = msg2.add_item();\n  item->set_a(2);\n  item->set_b(\"22\");\n  item = msg2.add_item();\n  item->set_a(1);\n  item->set_b(\"11\");\n\n  // Compare\n  util::MessageDifferencer differencer;\n  differencer.TreatAsMap(GetFieldDescriptor(msg1, \"item\"),\n                         GetFieldDescriptor(msg1, \"item.a\"));\n  differencer.set_scope(util::MessageDifferencer::PARTIAL);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, RepeatedFieldSetTest_Duplicates) {\n  protobuf_unittest::TestDiffMessage a, b, c;\n  // message a: {\n  //   rv: 0\n  //   rv: 1\n  //   rv: 0\n  // }\n  a.add_rv(0);\n  a.add_rv(1);\n  a.add_rv(0);\n  // message b: {\n  //   rv: 0\n  //   rv: 0\n  //   rv: 1\n  // }\n  b.add_rv(0);\n  b.add_rv(0);\n  b.add_rv(1);\n  // message c: {\n  //   rv: 0\n  //   rv: 1\n  // }\n  c.add_rv(0);\n  c.add_rv(1);\n  util::MessageDifferencer differencer;\n  differencer.TreatAsSet(GetFieldDescriptor(a, \"rv\"));\n  EXPECT_TRUE(differencer.Compare(b, a));\n  EXPECT_FALSE(differencer.Compare(c, a));\n\n  util::MessageDifferencer differencer1;\n  differencer1.set_repeated_field_comparison(util::MessageDifferencer::AS_SET);\n  EXPECT_TRUE(differencer1.Compare(b, a));\n  EXPECT_FALSE(differencer1.Compare(c, a));\n}\n\nTEST(MessageDifferencerTest, RepeatedFieldSetTest_PartialSimple) {\n  protobuf_unittest::TestDiffMessage a, b, c;\n  // message a: {\n  //   rm { c: 1 }\n  //   rm { c: 0 }\n  // }\n  a.add_rm()->set_c(1);\n  a.add_rm()->set_c(0);\n  // message b: {\n  //   rm { c: 1 }\n  //   rm {}\n  // }\n  b.add_rm()->set_c(1);\n  b.add_rm();\n  // message c: {\n  //   rm {}\n  //   rm { c: 1 }\n  // }\n  c.add_rm();\n  c.add_rm()->set_c(1);\n  util::MessageDifferencer differencer;\n  differencer.set_scope(util::MessageDifferencer::PARTIAL);\n  differencer.TreatAsSet(GetFieldDescriptor(a, \"rm\"));\n  EXPECT_TRUE(differencer.Compare(b, a));\n  EXPECT_TRUE(differencer.Compare(c, a));\n}\n\nTEST(MessageDifferencerTest, RepeatedFieldSetTest_Partial) {\n  protobuf_unittest::TestDiffMessage msg1, msg2;\n  // message msg1: {\n  //   rm { a: 1 }\n  //   rm { b: 2 }\n  //   rm { c: 3 }\n  // }\n  msg1.add_rm()->set_a(1);\n  msg1.add_rm()->set_b(2);\n  msg1.add_rm()->set_c(3);\n  // message msg2: {\n  //   rm { a: 1; c: 3 }\n  //   rm { b: 2; c: 3 }\n  //   rm { b: 2 }\n  // }\n  protobuf_unittest::TestField* field = msg2.add_rm();\n  field->set_a(1);\n  field->set_c(3);\n  field = msg2.add_rm();\n  field->set_b(2);\n  field->set_c(3);\n  field = msg2.add_rm();\n  field->set_b(2);\n\n  util::MessageDifferencer differencer;\n  differencer.set_scope(util::MessageDifferencer::PARTIAL);\n  differencer.TreatAsSet(GetFieldDescriptor(msg1, \"rm\"));\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, RepeatedFieldMapTest_MultipleFieldsAsKey) {\n  protobuf_unittest::TestDiffMessage msg1;\n  protobuf_unittest::TestDiffMessage msg2;\n  // Treat \"item\" as Map, with key = (\"a\", \"ra\")\n  // Treat \"item.ra\" as Set\n  protobuf_unittest::TestDiffMessage::Item* item = msg1.add_item();\n  // key => value: (1, {2, 3}) => \"a\"\n  item->set_a(1);\n  item->add_ra(2);\n  item->add_ra(3);\n  item->set_b(\"a\");\n  item = msg1.add_item();\n  // key => value: (2, {1, 3}) => \"b\"\n  item->set_a(2);\n  item->add_ra(1);\n  item->add_ra(3);\n  item->set_b(\"b\");\n  item = msg1.add_item();\n  // key => value: (1, {1, 3}) => \"c\"\n  item->set_a(1);\n  item->add_ra(1);\n  item->add_ra(3);\n  item->set_b(\"c\");\n\n  item = msg2.add_item();\n  // key => value: (1, {1, 3}) => \"c\"\n  item->set_a(1);\n  item->add_ra(3);\n  item->add_ra(1);\n  item->set_b(\"c\");\n  item = msg2.add_item();\n  // key => value: (1, {2, 3}) => \"a\"\n  item->set_a(1);\n  item->add_ra(3);\n  item->add_ra(2);\n  item->set_b(\"a\");\n  item = msg2.add_item();\n  // key => value: (2, {1, 3}) => \"b\"\n  item->set_a(2);\n  item->add_ra(3);\n  item->add_ra(1);\n  item->set_b(\"b\");\n\n  // Compare\n  util::MessageDifferencer differencer;\n  differencer.TreatAsSet(GetFieldDescriptor(msg1, \"item.ra\"));\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n  vector<const FieldDescriptor*> key_fields;\n  key_fields.push_back(GetFieldDescriptor(msg1, \"item.a\"));\n  key_fields.push_back(GetFieldDescriptor(msg1, \"item.ra\"));\n  differencer.TreatAsMapWithMultipleFieldsAsKey(\n      GetFieldDescriptor(msg1, \"item\"), key_fields);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n\n  // Introduce some differences.\n  msg1.clear_item();\n  msg2.clear_item();\n  item = msg1.add_item();\n  item->set_a(4);\n  item->add_ra(5);\n  item->add_ra(6);\n  item->set_b(\"hello\");\n  item = msg2.add_item();\n  item->set_a(4);\n  item->add_ra(6);\n  item->add_ra(5);\n  item->set_b(\"world\");\n  string output;\n  differencer.ReportDifferencesToString(&output);\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n  EXPECT_EQ(\n      \"moved: item[0].ra[0] -> item[0].ra[1] : 5\\n\"\n      \"moved: item[0].ra[1] -> item[0].ra[0] : 6\\n\"\n      \"modified: item[0].b: \\\"hello\\\" -> \\\"world\\\"\\n\",\n      output);\n}\n\nTEST(MessageDifferencerTest, RepeatedFieldMapTest_MultipleFieldPathsAsKey) {\n  protobuf_unittest::TestDiffMessage msg1;\n  protobuf_unittest::TestDiffMessage msg2;\n  // Treat \"item\" as Map, with key = (\"m.a\", \"m.rc\")\n  // Treat \"item.m.rc\" as Set\n  protobuf_unittest::TestDiffMessage::Item* item = msg1.add_item();\n  // key => value: (1, {2, 3}) => \"a\"\n  item->mutable_m()->set_a(1);\n  item->mutable_m()->add_rc(2);\n  item->mutable_m()->add_rc(3);\n  item->set_b(\"a\");\n  item = msg1.add_item();\n  // key => value: (2, {1, 3}) => \"b\"\n  item->mutable_m()->set_a(2);\n  item->mutable_m()->add_rc(1);\n  item->mutable_m()->add_rc(3);\n  item->set_b(\"b\");\n  item = msg1.add_item();\n  // key => value: (1, {1, 3}) => \"c\"\n  item->mutable_m()->set_a(1);\n  item->mutable_m()->add_rc(1);\n  item->mutable_m()->add_rc(3);\n  item->set_b(\"c\");\n\n  item = msg2.add_item();\n  // key => value: (1, {1, 3}) => \"c\"\n  item->mutable_m()->set_a(1);\n  item->mutable_m()->add_rc(3);\n  item->mutable_m()->add_rc(1);\n  item->set_b(\"c\");\n  item = msg2.add_item();\n  // key => value: (1, {2, 3}) => \"a\"\n  item->mutable_m()->set_a(1);\n  item->mutable_m()->add_rc(3);\n  item->mutable_m()->add_rc(2);\n  item->set_b(\"a\");\n  item = msg2.add_item();\n  // key => value: (2, {1, 3}) => \"b\"\n  item->mutable_m()->set_a(2);\n  item->mutable_m()->add_rc(3);\n  item->mutable_m()->add_rc(1);\n  item->set_b(\"b\");\n\n  // Compare\n  util::MessageDifferencer differencer;\n  differencer.TreatAsSet(GetFieldDescriptor(msg1, \"item.m.rc\"));\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n  vector<vector<const FieldDescriptor*> > key_field_paths;\n  vector<const FieldDescriptor*> key_field_path1;\n  key_field_path1.push_back(GetFieldDescriptor(msg1, \"item.m\"));\n  key_field_path1.push_back(GetFieldDescriptor(msg1, \"item.m.a\"));\n  vector<const FieldDescriptor*> key_field_path2;\n  key_field_path2.push_back(GetFieldDescriptor(msg1, \"item.m\"));\n  key_field_path2.push_back(GetFieldDescriptor(msg1, \"item.m.rc\"));\n  key_field_paths.push_back(key_field_path1);\n  key_field_paths.push_back(key_field_path2);\n  differencer.TreatAsMapWithMultipleFieldPathsAsKey(\n      GetFieldDescriptor(msg1, \"item\"), key_field_paths);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n\n  // Introduce some differences.\n  msg1.clear_item();\n  msg2.clear_item();\n  item = msg1.add_item();\n  item->mutable_m()->set_a(4);\n  item->mutable_m()->add_rc(5);\n  item->mutable_m()->add_rc(6);\n  item->set_b(\"hello\");\n  item = msg2.add_item();\n  item->mutable_m()->set_a(4);\n  item->mutable_m()->add_rc(6);\n  item->mutable_m()->add_rc(5);\n  item->set_b(\"world\");\n  string output;\n  differencer.ReportDifferencesToString(&output);\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n  EXPECT_EQ(\n      \"modified: item[0].b: \\\"hello\\\" -> \\\"world\\\"\\n\"\n      \"moved: item[0].m.rc[0] -> item[0].m.rc[1] : 5\\n\"\n      \"moved: item[0].m.rc[1] -> item[0].m.rc[0] : 6\\n\",\n      output);\n}\n\nTEST(MessageDifferencerTest, RepeatedFieldMapTest_IgnoredKeyFields) {\n  protobuf_unittest::TestDiffMessage msg1;\n  protobuf_unittest::TestDiffMessage msg2;\n  // Treat \"item\" as Map, with key = (\"a\", \"ra\")\n  protobuf_unittest::TestDiffMessage::Item* item = msg1.add_item();\n  item->set_a(1);\n  item->add_ra(2);\n  item->set_b(\"hello\");\n  item = msg2.add_item();\n  item->set_a(1);\n  item->add_ra(3);\n  item->set_b(\"world\");\n  // Compare\n  util::MessageDifferencer differencer;\n  vector<const FieldDescriptor*> key_fields;\n  key_fields.push_back(GetFieldDescriptor(msg1, \"item.a\"));\n  key_fields.push_back(GetFieldDescriptor(msg1, \"item.ra\"));\n  differencer.TreatAsMapWithMultipleFieldsAsKey(\n      GetFieldDescriptor(msg1, \"item\"), key_fields);\n  string output;\n  differencer.ReportDifferencesToString(&output);\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n  EXPECT_EQ(\n      \"added: item[0]: { a: 1 ra: 3 b: \\\"world\\\" }\\n\"\n      \"deleted: item[0]: { a: 1 ra: 2 b: \\\"hello\\\" }\\n\",\n      output);\n  // Ignored fields that are listed as parts of the key are still used\n  // in key comparison, but they're not used in value comparison.\n  differencer.IgnoreField(GetFieldDescriptor(msg1, \"item.ra\"));\n  output.clear();\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n  EXPECT_EQ(\n      \"added: item[0]: { a: 1 ra: 3 b: \\\"world\\\" }\\n\"\n      \"deleted: item[0]: { a: 1 ra: 2 b: \\\"hello\\\" }\\n\",\n      output);\n  // Ignoring a field in the key is different from treating the left fields\n  // as key. That is:\n  //   (key = (\"a\", \"ra\") && ignore \"ra\") != (key = (\"a\") && ignore \"ra\")\n  util::MessageDifferencer differencer2;\n  differencer2.TreatAsMap(GetFieldDescriptor(msg1, \"item\"),\n                          GetFieldDescriptor(msg1, \"item.a\"));\n  differencer2.IgnoreField(GetFieldDescriptor(msg1, \"item.ra\"));\n  output.clear();\n  differencer2.ReportDifferencesToString(&output);\n  EXPECT_FALSE(differencer2.Compare(msg1, msg2));\n  EXPECT_EQ(\n      \"ignored: item[0].ra\\n\"\n      \"modified: item[0].b: \\\"hello\\\" -> \\\"world\\\"\\n\",\n      output);\n}\n\nstatic const char* const kIgnoredFields[] = {\"rm.b\", \"rm.m.b\"};\n\nclass TestIgnorer : public util::MessageDifferencer::IgnoreCriteria {\n public:\n  virtual bool IsIgnored(\n      const Message& message1, const Message& message2,\n      const FieldDescriptor* field,\n      const vector<util::MessageDifferencer::SpecificField>& parent_fields) {\n    string name = \"\";\n    for (int i = 0; i < parent_fields.size(); ++i) {\n      name += parent_fields[i].field->name() + \".\";\n    }\n    name += field->name();\n    for (int i = 0; i < GOOGLE_ARRAYSIZE(kIgnoredFields); ++i) {\n      if (name.compare(kIgnoredFields[i]) == 0) {\n        return true;\n      }\n    }\n    return false;\n  }\n};\n\nTEST(MessageDifferencerTest, TreatRepeatedFieldAsSetWithIgnoredFields) {\n  protobuf_unittest::TestDiffMessage msg1;\n  protobuf_unittest::TestDiffMessage msg2;\n  TextFormat::MergeFromString(\"rm { a: 11\\n b: 12 }\", &msg1);\n  TextFormat::MergeFromString(\"rm { a: 11\\n b: 13 }\", &msg2);\n  util::MessageDifferencer differ;\n  differ.TreatAsSet(GetFieldDescriptor(msg1, \"rm\"));\n  differ.AddIgnoreCriteria(new TestIgnorer);\n  EXPECT_TRUE(differ.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, TreatRepeatedFieldAsMapWithIgnoredKeyFields) {\n  protobuf_unittest::TestDiffMessage msg1;\n  protobuf_unittest::TestDiffMessage msg2;\n  TextFormat::MergeFromString(\"rm { a: 11\\n m { a: 12\\n b: 13\\n } }\", &msg1);\n  TextFormat::MergeFromString(\"rm { a: 11\\n m { a: 12\\n b: 14\\n } }\", &msg2);\n  util::MessageDifferencer differ;\n  differ.TreatAsMap(GetFieldDescriptor(msg1, \"rm\"),\n                    GetFieldDescriptor(msg1, \"rm.m\"));\n  differ.AddIgnoreCriteria(new TestIgnorer);\n  EXPECT_TRUE(differ.Compare(msg1, msg2));\n}\n\n// Takes the product of all elements of item.ra as the key for key comparison.\nclass ValueProductMapKeyComparator\n    : public util::MessageDifferencer::MapKeyComparator {\n public:\n  typedef util::MessageDifferencer::SpecificField SpecificField;\n  virtual bool IsMatch(\n      const Message &message1, const Message &message2,\n      const vector<SpecificField>& parent_fields) const {\n    const Reflection* reflection1 = message1.GetReflection();\n    const Reflection* reflection2 = message2.GetReflection();\n    // FieldDescriptor for item.ra\n    const FieldDescriptor* ra_field =\n        message1.GetDescriptor()->FindFieldByName(\"ra\");\n    // Get the product of all elements in item.ra\n    int result1 = 1, result2 = 1;\n    for (int i = 0; i < reflection1->FieldSize(message1, ra_field); ++i) {\n      result1 *= reflection1->GetRepeatedInt32(message1, ra_field, i);\n    }\n    for (int i = 0; i < reflection2->FieldSize(message2, ra_field); ++i) {\n      result2 *= reflection2->GetRepeatedInt32(message2, ra_field, i);\n    }\n    return result1 == result2;\n  }\n};\n\nTEST(MessageDifferencerTest, RepeatedFieldMapTest_CustomMapKeyComparator) {\n  protobuf_unittest::TestDiffMessage msg1;\n  protobuf_unittest::TestDiffMessage msg2;\n  // Treat \"item\" as Map, using custom key comparator to determine if two\n  // elements have the same key.\n  protobuf_unittest::TestDiffMessage::Item* item = msg1.add_item();\n  item->add_ra(6);\n  item->add_ra(35);\n  item->set_b(\"hello\");\n  item = msg2.add_item();\n  item->add_ra(10);\n  item->add_ra(21);\n  item->set_b(\"hello\");\n  util::MessageDifferencer differencer;\n  ValueProductMapKeyComparator key_comparator;\n  differencer.TreatAsMapUsingKeyComparator(\n      GetFieldDescriptor(msg1, \"item\"), &key_comparator);\n  string output;\n  differencer.ReportDifferencesToString(&output);\n  // Though the above two messages have different values for item.ra, they\n  // are regarded as having the same key because 6 * 35 == 10 * 21. That's\n  // how the key comparator determines if the two have the same key.\n  // However, in value comparison, all fields of the message are taken into\n  // consideration, so they are different because their item.ra fields have\n  // different values using normal value comparison.\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n  EXPECT_EQ(\n      \"modified: item[0].ra[0]: 6 -> 10\\n\"\n      \"modified: item[0].ra[1]: 35 -> 21\\n\",\n      output);\n  differencer.IgnoreField(GetFieldDescriptor(msg1, \"item.ra\"));\n  output.clear();\n  // item.ra is ignored in value comparison, so the two messages equal.\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n  EXPECT_EQ(\"ignored: item[0].ra\\n\", output);\n}\n\nTEST(MessageDifferencerTest, RepeatedFieldSetTest_Subset) {\n  protobuf_unittest::TestDiffMessage msg1;\n  protobuf_unittest::TestDiffMessage msg2;\n\n  msg1.add_rv(3);\n  msg1.add_rv(8);\n  msg1.add_rv(2);\n  msg2.add_rv(2);\n  msg2.add_rv(3);\n  msg2.add_rv(5);\n  msg2.add_rv(8);\n\n  util::MessageDifferencer differencer;\n\n  // Fail with only partial scope set.\n  differencer.set_scope(util::MessageDifferencer::PARTIAL);\n  differencer.set_repeated_field_comparison(util::MessageDifferencer::AS_LIST);\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n\n  // Fail with only set-like comparison set.\n  differencer.set_scope(util::MessageDifferencer::FULL);\n  differencer.set_repeated_field_comparison(util::MessageDifferencer::AS_SET);\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n\n  // Succeed with scope and repeated field comparison set properly.\n  differencer.set_scope(util::MessageDifferencer::PARTIAL);\n  differencer.set_repeated_field_comparison(util::MessageDifferencer::AS_SET);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, IgnoreField_Single) {\n  protobuf_unittest::TestField msg1;\n  protobuf_unittest::TestField msg2;\n\n  msg1.set_c(3);\n  msg1.add_rc(1);\n\n  msg2.set_c(5);\n  msg2.add_rc(1);\n\n  util::MessageDifferencer differencer;\n  differencer.IgnoreField(GetFieldDescriptor(msg1, \"c\"));\n\n  ExpectEqualsWithDifferencer(&differencer, msg1, msg2);\n}\n\nTEST(MessageDifferencerTest, IgnoreField_Repeated) {\n  protobuf_unittest::TestField msg1;\n  protobuf_unittest::TestField msg2;\n\n  msg1.set_c(3);\n  msg1.add_rc(1);\n  msg1.add_rc(2);\n\n  msg2.set_c(3);\n  msg2.add_rc(1);\n  msg2.add_rc(3);\n\n  util::MessageDifferencer differencer;\n  differencer.IgnoreField(GetFieldDescriptor(msg1, \"rc\"));\n\n  ExpectEqualsWithDifferencer(&differencer, msg1, msg2);\n}\n\nTEST(MessageDifferencerTest, IgnoreField_Message) {\n  protobuf_unittest::TestDiffMessage msg1;\n  protobuf_unittest::TestDiffMessage msg2;\n\n  protobuf_unittest::TestField* field;\n\n  field = msg1.add_rm();\n  field->set_c(3);\n\n  field = msg2.add_rm();\n  field->set_c(4);\n\n  util::MessageDifferencer differencer;\n  differencer.IgnoreField(GetFieldDescriptor(msg1, \"rm\"));\n\n  ExpectEqualsWithDifferencer(&differencer, msg1, msg2);\n}\n\nTEST(MessageDifferencerTest, IgnoreField_Group) {\n  protobuf_unittest::TestDiffMessage msg1;\n  protobuf_unittest::TestDiffMessage msg2;\n\n  protobuf_unittest::TestDiffMessage::Item* item;\n\n  item = msg1.add_item();\n  item->set_a(3);\n\n  item = msg2.add_item();\n  item->set_a(4);\n\n  util::MessageDifferencer differencer;\n  differencer.IgnoreField(GetFieldDescriptor(msg1, \"item\"));\n\n  ExpectEqualsWithDifferencer(&differencer, msg1, msg2);\n}\n\nTEST(MessageDifferencerTest, IgnoreField_Missing) {\n  protobuf_unittest::TestField msg1;\n  protobuf_unittest::TestField msg2;\n\n  msg1.set_c(3);\n  msg1.add_rc(1);\n\n  msg2.add_rc(1);\n\n  util::MessageDifferencer differencer;\n  differencer.IgnoreField(GetFieldDescriptor(msg1, \"c\"));\n\n  ExpectEqualsWithDifferencer(&differencer, msg1, msg2);\n  ExpectEqualsWithDifferencer(&differencer, msg2, msg1);\n}\n\nTEST(MessageDifferencerTest, IgnoreField_Multiple) {\n  protobuf_unittest::TestField msg1;\n  protobuf_unittest::TestField msg2;\n\n  msg1.set_c(3);\n  msg1.add_rc(1);\n  msg1.add_rc(2);\n\n  msg2.set_c(5);\n  msg2.add_rc(1);\n  msg2.add_rc(3);\n\n  const FieldDescriptor* c = GetFieldDescriptor(msg1, \"c\");\n  const FieldDescriptor* rc = GetFieldDescriptor(msg1, \"rc\");\n\n  { // Ignore c\n    util::MessageDifferencer differencer;\n    differencer.IgnoreField(c);\n\n    EXPECT_FALSE(differencer.Compare(msg1, msg2));\n  }\n  { // Ignore rc\n    util::MessageDifferencer differencer;\n    differencer.IgnoreField(rc);\n\n    EXPECT_FALSE(differencer.Compare(msg1, msg2));\n  }\n  { // Ignore both\n    util::MessageDifferencer differencer;\n    differencer.IgnoreField(c);\n    differencer.IgnoreField(rc);\n\n    ExpectEqualsWithDifferencer(&differencer, msg1, msg2);\n  }\n}\n\nTEST(MessageDifferencerTest, IgnoreField_NestedMessage) {\n  protobuf_unittest::TestDiffMessage msg1;\n  protobuf_unittest::TestDiffMessage msg2;\n\n  protobuf_unittest::TestField* field;\n\n  field = msg1.add_rm();\n  field->set_c(3);\n  field->add_rc(1);\n\n  field = msg2.add_rm();\n  field->set_c(4);\n  field->add_rc(1);\n\n  util::MessageDifferencer differencer;\n  differencer.IgnoreField(GetFieldDescriptor(msg1, \"rm.c\"));\n\n  ExpectEqualsWithDifferencer(&differencer, msg1, msg2);\n}\n\nTEST(MessageDifferencerTest, IgnoreField_NestedGroup) {\n  protobuf_unittest::TestDiffMessage msg1;\n  protobuf_unittest::TestDiffMessage msg2;\n\n  protobuf_unittest::TestDiffMessage::Item* item;\n\n  item = msg1.add_item();\n  item->set_a(3);\n  item->set_b(\"foo\");\n\n  item = msg2.add_item();\n  item->set_a(4);\n  item->set_b(\"foo\");\n\n  util::MessageDifferencer differencer;\n  differencer.IgnoreField(GetFieldDescriptor(msg1, \"item.a\"));\n\n  ExpectEqualsWithDifferencer(&differencer, msg1, msg2);\n}\n\nTEST(MessageDifferencerTest, IgnoreField_InsideSet) {\n  protobuf_unittest::TestDiffMessage msg1;\n  protobuf_unittest::TestDiffMessage msg2;\n\n  protobuf_unittest::TestDiffMessage::Item* item;\n\n  item = msg1.add_item();\n  item->set_a(1);\n  item->set_b(\"foo\");\n  item->add_ra(1);\n\n  item = msg1.add_item();\n  item->set_a(2);\n  item->set_b(\"bar\");\n  item->add_ra(2);\n\n  item = msg2.add_item();\n  item->set_a(2);\n  item->set_b(\"bar\");\n  item->add_ra(2);\n\n  item = msg2.add_item();\n  item->set_a(1);\n  item->set_b(\"baz\");\n  item->add_ra(1);\n\n  const FieldDescriptor* item_desc = GetFieldDescriptor(msg1, \"item\");\n  const FieldDescriptor* b = GetFieldDescriptor(msg1, \"item.b\");\n\n  util::MessageDifferencer differencer;\n  differencer.IgnoreField(b);\n  differencer.TreatAsSet(item_desc);\n\n  ExpectEqualsWithDifferencer(&differencer, msg1, msg2);\n}\n\nTEST(MessageDifferencerTest, IgnoreField_InsideMap) {\n  protobuf_unittest::TestDiffMessage msg1;\n  protobuf_unittest::TestDiffMessage msg2;\n\n  protobuf_unittest::TestDiffMessage::Item* item;\n\n  item = msg1.add_item();\n  item->set_a(1);\n  item->set_b(\"foo\");\n  item->add_ra(1);\n\n  item = msg1.add_item();\n  item->set_a(2);\n  item->set_b(\"bar\");\n  item->add_ra(2);\n\n  item = msg2.add_item();\n  item->set_a(2);\n  item->set_b(\"bar\");\n  item->add_ra(2);\n\n  item = msg2.add_item();\n  item->set_a(1);\n  item->set_b(\"baz\");\n  item->add_ra(1);\n\n  const FieldDescriptor* item_desc = GetFieldDescriptor(msg1, \"item\");\n  const FieldDescriptor* a = GetFieldDescriptor(msg1, \"item.a\");\n  const FieldDescriptor* b = GetFieldDescriptor(msg1, \"item.b\");\n\n  util::MessageDifferencer differencer;\n  differencer.IgnoreField(b);\n  differencer.TreatAsMap(item_desc, a);\n\n  ExpectEqualsWithDifferencer(&differencer, msg1, msg2);\n}\n\nTEST(MessageDifferencerTest, IgnoreField_DoesNotIgnoreKey) {\n  protobuf_unittest::TestDiffMessage msg1;\n  protobuf_unittest::TestDiffMessage msg2;\n\n  protobuf_unittest::TestDiffMessage::Item* item;\n\n  item = msg1.add_item();\n  item->set_a(1);\n  item->set_b(\"foo\");\n  item->add_ra(1);\n\n  item = msg2.add_item();\n  item->set_a(2);\n  item->set_b(\"foo\");\n  item->add_ra(1);\n\n  const FieldDescriptor* item_desc = GetFieldDescriptor(msg1, \"item\");\n  const FieldDescriptor* a = GetFieldDescriptor(msg1, \"item.a\");\n\n  util::MessageDifferencer differencer;\n  differencer.IgnoreField(a);\n  differencer.TreatAsMap(item_desc, a);\n\n  EXPECT_FALSE(differencer.Compare(msg1, msg2));\n}\n\nTEST(MessageDifferencerTest, IgnoreField_TrumpsCompareWithFields) {\n  protobuf_unittest::TestField msg1;\n  protobuf_unittest::TestField msg2;\n\n  msg1.set_c(3);\n  msg1.add_rc(1);\n  msg1.add_rc(2);\n\n  msg2.set_c(3);\n  msg2.add_rc(1);\n  msg2.add_rc(3);\n\n  const FieldDescriptor* c = GetFieldDescriptor(msg1, \"c\");\n  const FieldDescriptor* rc = GetFieldDescriptor(msg1, \"rc\");\n\n  vector<const FieldDescriptor*> fields;\n  fields.push_back(c);\n  fields.push_back(rc);\n\n  util::MessageDifferencer differencer;\n  differencer.IgnoreField(rc);\n\n  differencer.set_scope(util::MessageDifferencer::FULL);\n  EXPECT_TRUE(differencer.CompareWithFields(msg1, msg2, fields, fields));\n\n  differencer.set_scope(util::MessageDifferencer::PARTIAL);\n  EXPECT_TRUE(differencer.CompareWithFields(msg1, msg2, fields, fields));\n}\n\n\n// Test class to save a copy of the last field_context.parent_fields() vector\n// passed to the comparison function.\nclass ParentSavingFieldComparator : public util::FieldComparator {\n public:\n  ParentSavingFieldComparator() {}\n\n  virtual ComparisonResult Compare(\n      const google::protobuf::Message& message_1,\n      const google::protobuf::Message& message_2,\n      const google::protobuf::FieldDescriptor* field,\n      int index_1, int index_2,\n      const google::protobuf::util::FieldContext* field_context) {\n    if (field_context)\n      parent_fields_ = *(field_context->parent_fields());\n    if (field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE) {\n      return RECURSE;\n    } else {\n      return SAME;\n    }\n  }\n\n  vector<google::protobuf::util::MessageDifferencer::SpecificField> parent_fields() {\n    return parent_fields_;\n  }\n\n private:\n  vector<google::protobuf::util::MessageDifferencer::SpecificField> parent_fields_;\n};\n\n// Tests if MessageDifferencer sends the parent fields in the FieldContext\n// parameter.\nTEST(MessageDifferencerTest, FieldContextParentFieldsTest) {\n  protobuf_unittest::TestDiffMessage msg1;\n  msg1.add_rm()->set_c(1);\n  protobuf_unittest::TestDiffMessage msg2;\n  msg2.add_rm()->set_c(1);\n\n  ParentSavingFieldComparator field_comparator;\n  util::MessageDifferencer differencer;\n  differencer.set_field_comparator(&field_comparator);\n  differencer.Compare(msg1, msg2);\n\n  // We want only one parent with the name \"rm\"\n  ASSERT_EQ(1, field_comparator.parent_fields().size());\n  EXPECT_EQ(\"rm\", field_comparator.parent_fields()[0].field->name());\n}\n\n\nclass ComparisonTest : public testing::Test {\n protected:\n  ComparisonTest() : use_equivalency_(false), repeated_field_as_set_(false) {\n    // Setup the test.\n    TestUtil::SetAllFields(&proto1_);\n    TestUtil::SetAllFields(&proto2_);\n\n    TestUtil::SetAllExtensions(&proto1ex_);\n    TestUtil::SetAllExtensions(&proto2ex_);\n\n    TestUtil::SetAllFieldsAndExtensions(&orderings_proto1_);\n    TestUtil::SetAllFieldsAndExtensions(&orderings_proto2_);\n\n    unknown1_ = empty1_.mutable_unknown_fields();\n    unknown2_ = empty2_.mutable_unknown_fields();\n  }\n\n  ~ComparisonTest() { }\n\n  void SetSpecialFieldOption(const Message& message,\n                              util::MessageDifferencer* d) {\n    if (!ignored_field_.empty()) {\n      d->IgnoreField(GetFieldDescriptor(message, ignored_field_));\n    }\n\n    if (repeated_field_as_set_) {\n      d->set_repeated_field_comparison(util::MessageDifferencer::AS_SET);\n    }\n\n    if (!set_field_.empty()) {\n      d->TreatAsSet(GetFieldDescriptor(message, set_field_));\n    }\n\n    if (!map_field_.empty() && !map_key_.empty()) {\n      d->TreatAsMap(GetFieldDescriptor(message, map_field_),\n                    GetFieldDescriptor(message, map_field_ + \".\" + map_key_));\n    }\n  }\n\n  string Run(const Message& msg1, const Message& msg2) {\n    string output;\n\n    // Setup the comparison.\n    util::MessageDifferencer differencer;\n    differencer.ReportDifferencesToString(&output);\n\n    if (use_equivalency_) {\n      differencer.set_message_field_comparison(\n          util::MessageDifferencer::EQUIVALENT);\n    }\n\n    SetSpecialFieldOption(msg1, &differencer);\n\n    // Conduct the comparison.\n    EXPECT_FALSE(differencer.Compare(msg1, msg2));\n\n    return output;\n  }\n\n  string Run() {\n    return Run(proto1_, proto2_);\n  }\n\n  string RunOrder() {\n    return Run(orderings_proto1_, orderings_proto2_);\n  }\n\n  string RunEx() {\n    return Run(proto1ex_, proto2ex_);\n  }\n\n  string RunDiff() {\n    return Run(proto1diff_, proto2diff_);\n  }\n\n  string RunUn() {\n    return Run(empty1_, empty2_);\n  }\n\n  void use_equivalency() {\n    use_equivalency_ = true;\n  }\n\n  void repeated_field_as_set() {\n    repeated_field_as_set_ = true;\n  }\n\n  void field_as_set(const string& field) {\n    set_field_ = field;\n  }\n\n  void field_as_map(const string& field, const string& key) {\n    map_field_ = field;\n    map_key_   = key;\n  }\n\n  void ignore_field(const string& field) {\n    ignored_field_ = field;\n  }\n\n  unittest::TestAllTypes proto1_;\n  unittest::TestAllTypes proto2_;\n\n  unittest::TestFieldOrderings orderings_proto1_;\n  unittest::TestFieldOrderings orderings_proto2_;\n\n  unittest::TestAllExtensions proto1ex_;\n  unittest::TestAllExtensions proto2ex_;\n\n  unittest::TestDiffMessage proto1diff_;\n  unittest::TestDiffMessage proto2diff_;\n\n  unittest::TestEmptyMessage empty1_;\n  unittest::TestEmptyMessage empty2_;\n\n  UnknownFieldSet* unknown1_;\n  UnknownFieldSet* unknown2_;\n\n  bool use_equivalency_;\n  bool repeated_field_as_set_;\n\n  string set_field_;\n  string map_field_;\n  string map_key_;\n  string ignored_field_;\n};\n\n// Basic tests.\nTEST_F(ComparisonTest, AdditionTest) {\n  proto1_.clear_optional_int32();\n\n  EXPECT_EQ(\"added: optional_int32: 101\\n\",\n            Run());\n}\n\nTEST_F(ComparisonTest, Addition_OrderTest) {\n  orderings_proto1_.clear_my_int();\n\n  EXPECT_EQ(\"added: my_int: 1\\n\",\n            RunOrder());\n}\n\nTEST_F(ComparisonTest, DeletionTest) {\n  proto2_.clear_optional_int32();\n\n  EXPECT_EQ(\"deleted: optional_int32: 101\\n\",\n            Run());\n}\n\nTEST_F(ComparisonTest, Deletion_OrderTest) {\n  orderings_proto2_.clear_my_string();\n\n  EXPECT_EQ(\"deleted: my_string: \\\"foo\\\"\\n\",\n            RunOrder());\n}\n\nTEST_F(ComparisonTest, RepeatedDeletionTest) {\n  proto2_.clear_repeated_int32();\n\n  EXPECT_EQ(\"deleted: repeated_int32[0]: 201\\n\"\n            \"deleted: repeated_int32[1]: 301\\n\",\n            Run());\n}\n\nTEST_F(ComparisonTest, ModificationTest) {\n  proto1_.set_optional_int32(-1);\n\n  EXPECT_EQ(\"modified: optional_int32: -1 -> 101\\n\",\n            Run());\n}\n\n// Basic equivalency tests.\nTEST_F(ComparisonTest, EquivalencyAdditionTest) {\n  use_equivalency();\n\n  proto1_.clear_optional_int32();\n\n  EXPECT_EQ(\"modified: optional_int32: 0 -> 101\\n\",\n            Run());\n}\n\nTEST_F(ComparisonTest, EquivalencyDeletionTest) {\n  use_equivalency();\n\n  proto2_.clear_optional_int32();\n\n  EXPECT_EQ(\"modified: optional_int32: 101 -> 0\\n\",\n            Run());\n}\n\n// Group tests.\nTEST_F(ComparisonTest, GroupAdditionTest) {\n  proto1_.mutable_optionalgroup()->clear_a();\n\n  EXPECT_EQ(\"added: optionalgroup.a: 117\\n\",\n            Run());\n}\n\nTEST_F(ComparisonTest, GroupDeletionTest) {\n  proto2_.mutable_optionalgroup()->clear_a();\n\n  EXPECT_EQ(\"deleted: optionalgroup.a: 117\\n\",\n            Run());\n}\n\nTEST_F(ComparisonTest, GroupModificationTest) {\n  proto1_.mutable_optionalgroup()->set_a(2);\n\n  EXPECT_EQ(\"modified: optionalgroup.a: 2 -> 117\\n\",\n            Run());\n}\n\nTEST_F(ComparisonTest, GroupFullAdditionTest) {\n  proto1_.clear_optionalgroup();\n\n  // Note the difference in the output between this and GroupAdditionTest.\n  EXPECT_EQ(\"added: optionalgroup: { a: 117 }\\n\",\n            Run());\n}\n\nTEST_F(ComparisonTest, GroupFullDeletionTest) {\n  proto2_.clear_optionalgroup();\n\n  EXPECT_EQ(\"deleted: optionalgroup: { a: 117 }\\n\",\n            Run());\n}\n\nTEST_F(ComparisonTest, RepeatedSetOptionTest) {\n  repeated_field_as_set();\n\n  proto2_.clear_repeatedgroup();\n  proto1_.clear_repeatedgroup();\n  proto1_.add_repeatedgroup()->set_a(317);\n  proto2_.add_repeatedgroup()->set_a(909);\n  proto2_.add_repeatedgroup()->set_a(907);\n  proto1_.add_repeatedgroup()->set_a(904);\n  proto1_.add_repeatedgroup()->set_a(907);\n  proto1_.add_repeatedgroup()->set_a(909);\n\n  EXPECT_EQ(\"moved: repeatedgroup[2] -> repeatedgroup[1] : { a: 907 }\\n\"\n            \"moved: repeatedgroup[3] -> repeatedgroup[0] : { a: 909 }\\n\"\n            \"deleted: repeatedgroup[0]: { a: 317 }\\n\"\n            \"deleted: repeatedgroup[1]: { a: 904 }\\n\",\n            Run());\n}\n\nTEST_F(ComparisonTest, RepeatedSetOptionTest_Ex) {\n  repeated_field_as_set();\n\n  proto1ex_.ClearExtension(protobuf_unittest::repeated_nested_message_extension);\n  proto2ex_.ClearExtension(protobuf_unittest::repeated_nested_message_extension);\n  proto2ex_.AddExtension(protobuf_unittest::repeated_nested_message_extension)\n      ->set_bb(909);\n  proto2ex_.AddExtension(protobuf_unittest::repeated_nested_message_extension)\n      ->set_bb(907);\n  proto1ex_.AddExtension(protobuf_unittest::repeated_nested_message_extension)\n      ->set_bb(904);\n  proto1ex_.AddExtension(protobuf_unittest::repeated_nested_message_extension)\n      ->set_bb(907);\n  proto1ex_.AddExtension(protobuf_unittest::repeated_nested_message_extension)\n      ->set_bb(909);\n\n  EXPECT_EQ(\"moved: (protobuf_unittest.repeated_nested_message_extension)[2] ->\"\n            \" (protobuf_unittest.repeated_nested_message_extension)[0] :\"\n            \" { bb: 909 }\\n\"\n            \"deleted: (protobuf_unittest.repeated_nested_message_extension)[0]:\"\n            \" { bb: 904 }\\n\",\n            RunEx());\n}\n\nTEST_F(ComparisonTest, RepeatedMapFieldTest_Group) {\n  field_as_map(\"repeatedgroup\", \"a\");\n  proto1_.clear_repeatedgroup();\n  proto2_.clear_repeatedgroup();\n\n  proto1_.add_repeatedgroup()->set_a(317);  // deleted\n  proto1_.add_repeatedgroup()->set_a(904);  // deleted\n  proto1_.add_repeatedgroup()->set_a(907);  // moved from\n  proto1_.add_repeatedgroup()->set_a(909);  // moved from\n\n  proto2_.add_repeatedgroup()->set_a(909);  // moved to\n  proto2_.add_repeatedgroup()->set_a(318);  // added\n  proto2_.add_repeatedgroup()->set_a(907);  // moved to\n\n  EXPECT_EQ(\"moved: repeatedgroup[3] -> repeatedgroup[0] : { a: 909 }\\n\"\n            \"added: repeatedgroup[1]: { a: 318 }\\n\"\n            \"deleted: repeatedgroup[0]: { a: 317 }\\n\"\n            \"deleted: repeatedgroup[1]: { a: 904 }\\n\",\n            Run());\n}\n\nTEST_F(ComparisonTest, RepeatedMapFieldTest_MessageKey) {\n  // Use m as key, but use b as value.\n  field_as_map(\"item\", \"m\");\n\n  protobuf_unittest::TestDiffMessage msg1;\n  protobuf_unittest::TestDiffMessage msg2;\n  protobuf_unittest::TestDiffMessage::Item* item = msg1.add_item();\n\n  // The following code creates one deletion, one addition and two moved fields\n  // on the messages.\n  item->mutable_m()->set_c(0);\n  item->set_b(\"first\");\n  item = msg1.add_item();\n  item->mutable_m()->set_c(2);\n  item->set_b(\"second\");\n  item = msg1.add_item(); item->set_b(\"null\");  // empty key moved\n  item = msg1.add_item();\n  item->mutable_m()->set_c(3);\n  item->set_b(\"third\");   // deletion\n  item = msg1.add_item();\n  item->mutable_m()->set_c(2);\n  item->set_b(\"second\");  // duplicated key ( deletion )\n  item = msg2.add_item();\n  item->mutable_m()->set_c(2);\n  item->set_b(\"second\");  // modification\n  item = msg2.add_item();\n  item->mutable_m()->set_c(4);\n  item->set_b(\"fourth\");  // addition\n  item = msg2.add_item();\n  item->mutable_m()->set_c(0);\n  item->set_b(\"fist\");    // move with change\n  item = msg2.add_item(); item->set_b(\"null\");\n\n  EXPECT_EQ(\n      \"modified: item[0].b -> item[2].b: \\\"first\\\" -> \\\"fist\\\"\\n\"\n      \"moved: item[1] -> item[0] : { b: \\\"second\\\" m { c: 2 } }\\n\"\n      \"moved: item[2] -> item[3] : { b: \\\"null\\\" }\\n\"\n      \"added: item[1]: { b: \\\"fourth\\\" m { c: 4 } }\\n\"\n      \"deleted: item[3]: { b: \\\"third\\\" m { c: 3 } }\\n\"\n      \"deleted: item[4]: { b: \\\"second\\\" m { c: 2 } }\\n\",\n      Run(msg1, msg2));\n}\n\nTEST_F(ComparisonTest, RepeatedFieldSetTest_SetOfSet) {\n  repeated_field_as_set();\n  // Create the testing protos\n  protobuf_unittest::TestDiffMessage msg1;\n  protobuf_unittest::TestDiffMessage msg2;\n\n  protobuf_unittest::TestDiffMessage::Item* item = msg1.add_item();\n  item->add_ra(1); item->add_ra(2); item->add_ra(3);\n  item = msg1.add_item();\n  item->add_ra(5); item->add_ra(6);\n  item = msg1.add_item();\n  item->add_ra(1); item->add_ra(3);\n  item = msg1.add_item();\n  item->add_ra(6); item->add_ra(7); item->add_ra(8);\n\n  item = msg2.add_item();\n  item->add_ra(6); item->add_ra(5);\n  item = msg2.add_item();\n  item->add_ra(6); item->add_ra(8);\n  item = msg2.add_item();\n  item->add_ra(1); item->add_ra(3);\n  item = msg2.add_item();\n  item->add_ra(3); item->add_ra(2); item->add_ra(1);\n\n  // Compare\n  EXPECT_EQ(\"moved: item[0].ra[0] -> item[3].ra[2] : 1\\n\"\n            \"moved: item[0].ra[2] -> item[3].ra[0] : 3\\n\"\n            \"moved: item[0] -> item[3] : { ra: 1 ra: 2 ra: 3 }\\n\"\n            \"moved: item[1].ra[0] -> item[0].ra[1] : 5\\n\"\n            \"moved: item[1].ra[1] -> item[0].ra[0] : 6\\n\"\n            \"moved: item[1] -> item[0] : { ra: 5 ra: 6 }\\n\"\n            \"added: item[1]: { ra: 6 ra: 8 }\\n\"\n            \"deleted: item[3]: { ra: 6 ra: 7 ra: 8 }\\n\",\n            Run(msg1, msg2));\n}\n\nTEST_F(ComparisonTest, RepeatedMapFieldTest_RepeatedKey) {\n  // used rb as a key, but b is the value.\n  repeated_field_as_set();\n  field_as_map(\"item\", \"rb\");\n\n  protobuf_unittest::TestDiffMessage msg1;\n  protobuf_unittest::TestDiffMessage msg2;\n  protobuf_unittest::TestDiffMessage::Item* item = msg1.add_item();\n  item->add_rb(\"a\");\n  item->add_rb(\"b\");\n  item->set_b(\"first\");\n\n  item = msg2.add_item();\n  item->add_rb(\"c\");\n  item->set_b(\"second\");\n\n  item = msg2.add_item();\n  item->add_rb(\"b\");\n  item->add_rb(\"a\");\n  item->set_b(\"fist\");\n\n\n  EXPECT_EQ(\"modified: item[0].b -> item[1].b: \\\"first\\\" -> \\\"fist\\\"\\n\"\n            \"moved: item[0].rb[0] -> item[1].rb[1] : \\\"a\\\"\\n\"\n            \"moved: item[0].rb[1] -> item[1].rb[0] : \\\"b\\\"\\n\"\n            \"added: item[0]: { b: \\\"second\\\" rb: \\\"c\\\" }\\n\",\n            Run(msg1, msg2));\n}\n\nTEST_F(ComparisonTest, RepeatedMapFieldTest_RepeatedMessageKey) {\n  field_as_map(\"item\", \"rm\");\n\n  protobuf_unittest::TestDiffMessage msg1;\n  protobuf_unittest::TestDiffMessage msg2;\n  protobuf_unittest::TestDiffMessage::Item* item = msg1.add_item();\n  protobuf_unittest::TestField* key = item->add_rm();\n  key->set_c(2); key->add_rc(10); key->add_rc(10);\n  item = msg1.add_item(); key = item->add_rm();\n  key->set_c(0); key->add_rc(1); key->add_rc(2);\n  key = item->add_rm();\n  key->set_c(0);\n  item->add_rb(\"first\");\n\n  item = msg2.add_item();\n  item->CopyFrom(msg1.item(1));\n  item->add_rb(\"second\");\n\n  EXPECT_EQ(\"added: item[0].rb[1]: \\\"second\\\"\\n\"\n            \"deleted: item[0]: { rm { c: 2 rc: 10 rc: 10 } }\\n\",\n            Run(msg1, msg2));\n}\n\nTEST_F(ComparisonTest, RepeatedSetOptionTest_Unknown) {\n  // Currently, as_set option doesn't have affects on unknown field.\n  // If needed, this feature will be added by request.\n  repeated_field_as_set();\n  unknown1_->AddGroup(245)->AddFixed32(248, 1);\n  unknown2_->AddGroup(245)->AddFixed32(248, 3);\n  unknown2_->AddGroup(245)->AddFixed32(248, 1);\n\n  // We expect it behaves the same as normal comparison.\n  EXPECT_EQ(\"modified: 245[0].248[0]: 0x00000001 -> 0x00000003\\n\"\n            \"added: 245[1]: { ... }\\n\",\n            RunUn());\n}\n\nTEST_F(ComparisonTest, Matching_Unknown) {\n  unknown1_->AddGroup(245)->AddFixed32(248, 1);\n  unknown2_->AddGroup(245)->AddFixed32(248, 1);\n  unknown1_->AddGroup(245)->AddFixed32(248, 3);\n  unknown2_->AddGroup(245)->AddFixed32(248, 3);\n  unknown2_->AddLengthDelimited(242, \"cat\");\n  unknown2_->AddGroup(246)->AddFixed32(248, 4);\n\n  // report_match is false so only added/modified fields are expected.\n  EXPECT_EQ(\"added: 242[0]: \\\"cat\\\"\\n\"\n            \"added: 246[0]: { ... }\\n\",\n            RunUn());\n}\n\nTEST_F(ComparisonTest, RepeatedSetFieldTest) {\n  field_as_set(\"repeatedgroup\");\n\n  proto1_.clear_repeatedgroup();\n  proto2_.clear_repeatedgroup();\n  proto2_.add_repeatedgroup()->set_a(909);\n  proto2_.add_repeatedgroup()->set_a(907);\n  proto1_.add_repeatedgroup()->set_a(317);\n  proto1_.add_repeatedgroup()->set_a(904);\n  proto1_.add_repeatedgroup()->set_a(907);\n  proto1_.add_repeatedgroup()->set_a(909);\n\n  EXPECT_EQ(\"moved: repeatedgroup[2] -> repeatedgroup[1] : { a: 907 }\\n\"\n            \"moved: repeatedgroup[3] -> repeatedgroup[0] : { a: 909 }\\n\"\n            \"deleted: repeatedgroup[0]: { a: 317 }\\n\"\n            \"deleted: repeatedgroup[1]: { a: 904 }\\n\",\n            Run());\n}\n\n// Embedded message tests.\nTEST_F(ComparisonTest, EmbeddedAdditionTest) {\n  proto1_.mutable_optional_nested_message()->clear_bb();\n\n  EXPECT_EQ(\"added: optional_nested_message.bb: 118\\n\",\n            Run());\n}\n\nTEST_F(ComparisonTest, EmbeddedDeletionTest) {\n  proto2_.mutable_optional_nested_message()->clear_bb();\n\n  EXPECT_EQ(\"deleted: optional_nested_message.bb: 118\\n\",\n            Run());\n}\n\nTEST_F(ComparisonTest, EmbeddedModificationTest) {\n  proto1_.mutable_optional_nested_message()->set_bb(2);\n\n  EXPECT_EQ(\"modified: optional_nested_message.bb: 2 -> 118\\n\",\n            Run());\n}\n\nTEST_F(ComparisonTest, EmbeddedFullAdditionTest) {\n  proto1_.clear_optional_nested_message();\n\n  EXPECT_EQ(\"added: optional_nested_message: { bb: 118 }\\n\",\n            Run());\n}\n\nTEST_F(ComparisonTest, EmbeddedPartialAdditionTest) {\n  proto1_.clear_optional_nested_message();\n  proto2_.mutable_optional_nested_message()->clear_bb();\n\n  EXPECT_EQ(\"added: optional_nested_message: { }\\n\",\n            Run());\n}\n\nTEST_F(ComparisonTest, EmbeddedFullDeletionTest) {\n  proto2_.clear_optional_nested_message();\n\n  EXPECT_EQ(\"deleted: optional_nested_message: { bb: 118 }\\n\",\n            Run());\n}\n\n// Repeated element tests.\nTEST_F(ComparisonTest, BasicRepeatedTest) {\n  proto1_.clear_repeated_int32();\n  proto2_.clear_repeated_int32();\n\n  proto1_.add_repeated_int32(500);\n  proto1_.add_repeated_int32(501);\n  proto1_.add_repeated_int32(502);\n  proto1_.add_repeated_int32(503);\n  proto1_.add_repeated_int32(500);\n\n  proto2_.add_repeated_int32(500);\n  proto2_.add_repeated_int32(509);\n  proto2_.add_repeated_int32(502);\n  proto2_.add_repeated_int32(504);\n\n  EXPECT_EQ(\"modified: repeated_int32[1]: 501 -> 509\\n\"\n            \"modified: repeated_int32[3]: 503 -> 504\\n\"\n            \"deleted: repeated_int32[4]: 500\\n\",\n            Run());\n}\n\nTEST_F(ComparisonTest, BasicRepeatedTest_SetOption) {\n  repeated_field_as_set();\n  proto1_.clear_repeated_int32();\n  proto2_.clear_repeated_int32();\n\n  proto1_.add_repeated_int32(501);\n  proto1_.add_repeated_int32(502);\n  proto1_.add_repeated_int32(503);\n  proto1_.add_repeated_int32(500);\n  proto1_.add_repeated_int32(500);\n\n  proto2_.add_repeated_int32(500);\n  proto2_.add_repeated_int32(509);\n  proto2_.add_repeated_int32(503);\n  proto2_.add_repeated_int32(502);\n  proto2_.add_repeated_int32(504);\n\n  EXPECT_EQ(\"moved: repeated_int32[1] -> repeated_int32[3] : 502\\n\"\n            \"moved: repeated_int32[3] -> repeated_int32[0] : 500\\n\"\n            \"added: repeated_int32[1]: 509\\n\"\n            \"added: repeated_int32[4]: 504\\n\"\n            \"deleted: repeated_int32[0]: 501\\n\"\n            \"deleted: repeated_int32[4]: 500\\n\",\n            Run());\n}\n\nTEST_F(ComparisonTest, BasicRepeatedTest_SetField) {\n  field_as_set(\"repeated_int32\");\n  proto1_.clear_repeated_int32();\n  proto2_.clear_repeated_int32();\n\n  proto1_.add_repeated_int32(501);\n  proto1_.add_repeated_int32(502);\n  proto1_.add_repeated_int32(503);\n  proto1_.add_repeated_int32(500);\n  proto1_.add_repeated_int32(500);\n\n  proto2_.add_repeated_int32(500);\n  proto2_.add_repeated_int32(509);\n  proto2_.add_repeated_int32(503);\n  proto2_.add_repeated_int32(502);\n  proto2_.add_repeated_int32(504);\n\n  EXPECT_EQ(\"moved: repeated_int32[1] -> repeated_int32[3] : 502\\n\"\n            \"moved: repeated_int32[3] -> repeated_int32[0] : 500\\n\"\n            \"added: repeated_int32[1]: 509\\n\"\n            \"added: repeated_int32[4]: 504\\n\"\n            \"deleted: repeated_int32[0]: 501\\n\"\n            \"deleted: repeated_int32[4]: 500\\n\",\n            Run());\n}\n\n// Multiple action tests.\nTEST_F(ComparisonTest, AddDeleteTest) {\n  proto1_.clear_optional_int32();\n  proto2_.clear_optional_int64();\n\n  EXPECT_EQ(\"added: optional_int32: 101\\n\"\n            \"deleted: optional_int64: 102\\n\",\n            Run());\n}\n\nTEST_F(ComparisonTest, AddDelete_FieldOrderingTest) {\n  orderings_proto1_.ClearExtension(unittest::my_extension_string);\n  orderings_proto2_.clear_my_int();\n\n  EXPECT_EQ(\"deleted: my_int: 1\\n\"\n            \"added: (protobuf_unittest.my_extension_string): \\\"bar\\\"\\n\",\n            RunOrder());\n}\n\nTEST_F(ComparisonTest, AllThreeTest) {\n  proto1_.clear_optional_int32();\n  proto2_.clear_optional_float();\n  proto2_.set_optional_string(\"hello world!\");\n\n  EXPECT_EQ(\"added: optional_int32: 101\\n\"\n            \"deleted: optional_float: 111\\n\"\n            \"modified: optional_string: \\\"115\\\" -> \\\"hello world!\\\"\\n\",\n            Run());\n}\n\nTEST_F(ComparisonTest, SandwhichTest) {\n  proto1_.clear_optional_int64();\n  proto1_.clear_optional_uint32();\n\n  proto2_.clear_optional_uint64();\n\n  EXPECT_EQ(\"added: optional_int64: 102\\n\"\n            \"added: optional_uint32: 103\\n\"\n            \"deleted: optional_uint64: 104\\n\",\n            Run());\n}\n\nTEST_F(ComparisonTest, IgnoredNoChangeTest) {\n  proto1diff_.set_v(3);\n  proto2diff_.set_v(3);\n  proto2diff_.set_w(\"foo\");\n\n  ignore_field(\"v\");\n\n  EXPECT_EQ(\"ignored: v\\n\"\n            \"added: w: \\\"foo\\\"\\n\",\n            RunDiff());\n}\n\nTEST_F(ComparisonTest, IgnoredAddTest) {\n  proto2diff_.set_v(3);\n  proto2diff_.set_w(\"foo\");\n\n  ignore_field(\"v\");\n\n  EXPECT_EQ(\"ignored: v\\n\"\n            \"added: w: \\\"foo\\\"\\n\",\n            RunDiff());\n}\n\nTEST_F(ComparisonTest, IgnoredDeleteTest) {\n  proto1diff_.set_v(3);\n  proto2diff_.set_w(\"foo\");\n\n  ignore_field(\"v\");\n\n  EXPECT_EQ(\"ignored: v\\n\"\n            \"added: w: \\\"foo\\\"\\n\",\n            RunDiff());\n}\n\nTEST_F(ComparisonTest, IgnoredModifyTest) {\n  proto1diff_.set_v(3);\n  proto2diff_.set_v(4);\n  proto2diff_.set_w(\"foo\");\n\n  ignore_field(\"v\");\n\n  EXPECT_EQ(\"ignored: v\\n\"\n            \"added: w: \\\"foo\\\"\\n\",\n            RunDiff());\n}\n\nTEST_F(ComparisonTest, IgnoredRepeatedAddTest) {\n  proto1diff_.add_rv(3);\n  proto1diff_.add_rv(4);\n\n  proto2diff_.add_rv(3);\n  proto2diff_.add_rv(4);\n  proto2diff_.add_rv(5);\n\n  proto2diff_.set_w(\"foo\");\n\n  ignore_field(\"rv\");\n\n  EXPECT_EQ(\"ignored: rv\\n\"\n            \"added: w: \\\"foo\\\"\\n\",\n            RunDiff());\n}\n\nTEST_F(ComparisonTest, IgnoredRepeatedDeleteTest) {\n  proto1diff_.add_rv(3);\n  proto1diff_.add_rv(4);\n  proto1diff_.add_rv(5);\n\n  proto2diff_.add_rv(3);\n  proto2diff_.add_rv(4);\n\n  proto2diff_.set_w(\"foo\");\n\n  ignore_field(\"rv\");\n\n  EXPECT_EQ(\"ignored: rv\\n\"\n            \"added: w: \\\"foo\\\"\\n\",\n            RunDiff());\n}\n\nTEST_F(ComparisonTest, IgnoredRepeatedModifyTest) {\n  proto1diff_.add_rv(3);\n  proto1diff_.add_rv(4);\n\n  proto2diff_.add_rv(3);\n  proto2diff_.add_rv(5);\n\n  proto2diff_.set_w(\"foo\");\n\n  ignore_field(\"rv\");\n\n  EXPECT_EQ(\"ignored: rv\\n\"\n            \"added: w: \\\"foo\\\"\\n\",\n            RunDiff());\n}\n\nTEST_F(ComparisonTest, IgnoredWholeNestedMessage) {\n  proto1diff_.mutable_m()->set_c(3);\n  proto2diff_.mutable_m()->set_c(4);\n\n  proto2diff_.set_w(\"foo\");\n\n  ignore_field(\"m\");\n\n  EXPECT_EQ(\"added: w: \\\"foo\\\"\\n\"\n            \"ignored: m\\n\",\n            RunDiff());\n}\n\nTEST_F(ComparisonTest, IgnoredNestedField) {\n  proto1diff_.mutable_m()->set_c(3);\n  proto2diff_.mutable_m()->set_c(4);\n\n  proto2diff_.set_w(\"foo\");\n\n  ignore_field(\"m.c\");\n\n  EXPECT_EQ(\"added: w: \\\"foo\\\"\\n\"\n            \"ignored: m.c\\n\",\n            RunDiff());\n}\n\nTEST_F(ComparisonTest, IgnoredRepeatedNested) {\n  proto1diff_.add_rm()->set_c(0);\n  proto1diff_.add_rm()->set_c(1);\n  proto2diff_.add_rm()->set_c(2);\n  proto2diff_.add_rm()->set_c(3);\n\n  proto2diff_.set_w(\"foo\");\n\n  ignore_field(\"rm.c\");\n\n  EXPECT_EQ(\"ignored: rm[0].c\\n\"\n            \"ignored: rm[1].c\\n\"\n            \"added: w: \\\"foo\\\"\\n\",\n            RunDiff());\n}\n\nTEST_F(ComparisonTest, IgnoredNestedRepeated) {\n  proto1diff_.mutable_m()->add_rc(23);\n  proto1diff_.mutable_m()->add_rc(24);\n  proto2diff_.mutable_m()->add_rc(25);\n\n  proto2diff_.set_w(\"foo\");\n\n  ignore_field(\"m.rc\");\n\n  EXPECT_EQ(\"added: w: \\\"foo\\\"\\n\"\n            \"ignored: m.rc\\n\",\n            RunDiff());\n}\n\nTEST_F(ComparisonTest, ExtensionTest) {\n  proto1ex_.SetExtension(unittest::optional_int32_extension, 401);\n  proto2ex_.SetExtension(unittest::optional_int32_extension, 402);\n\n  proto1ex_.ClearExtension(unittest::optional_int64_extension);\n  proto2ex_.SetExtension(unittest::optional_int64_extension, 403);\n\n  EXPECT_EQ(\n      \"modified: (protobuf_unittest.optional_int32_extension): 401 -> 402\\n\"\n      \"added: (protobuf_unittest.optional_int64_extension): 403\\n\",\n      RunEx());\n}\n\nTEST_F(ComparisonTest, MatchedUnknownFieldTagTest) {\n  unknown1_->AddVarint(240, 122);\n  unknown2_->AddVarint(240, 121);\n  unknown1_->AddFixed32(241, 1);\n  unknown2_->AddFixed64(241, 2);\n  unknown1_->AddLengthDelimited(242, \"cat\");\n  unknown2_->AddLengthDelimited(242, \"dog\");\n\n  EXPECT_EQ(\n      \"modified: 240[0]: 122 -> 121\\n\"\n      \"deleted: 241[0]: 0x00000001\\n\"\n      \"added: 241[0]: 0x0000000000000002\\n\"\n      \"modified: 242[0]: \\\"cat\\\" -> \\\"dog\\\"\\n\",\n      RunUn());\n}\n\nTEST_F(ComparisonTest, UnmatchedUnknownFieldTagTest) {\n  unknown1_->AddFixed32(243, 1);\n  unknown2_->AddVarint(244, 2);\n  unknown2_->AddVarint(244, 4);\n\n  EXPECT_EQ(\n      \"deleted: 243[0]: 0x00000001\\n\"\n      \"added: 244[0]: 2\\n\"\n      \"added: 244[1]: 4\\n\",\n      RunUn());\n}\n\nTEST_F(ComparisonTest, DifferentSizedUnknownFieldTest) {\n  unknown1_->AddVarint(240, 1);\n  unknown1_->AddVarint(240, 3);\n  unknown1_->AddVarint(240, 4);\n  unknown2_->AddVarint(240, 2);\n  unknown2_->AddVarint(240, 3);\n  unknown2_->AddVarint(240, 2);\n  unknown2_->AddVarint(240, 5);\n\n  EXPECT_EQ(\n      \"modified: 240[0]: 1 -> 2\\n\"\n      \"modified: 240[2]: 4 -> 2\\n\"\n      \"added: 240[3]: 5\\n\",\n      RunUn());\n}\n\nTEST_F(ComparisonTest, UnknownFieldsAll) {\n  unknown1_->AddVarint(243, 122);\n  unknown1_->AddFixed64(244, 0x0172356);\n  unknown1_->AddFixed64(244, 0x098);\n  unknown1_->AddGroup(245)->AddFixed32(248, 1);\n  unknown1_->mutable_field(3)->mutable_group()->AddFixed32(248, 2);\n  unknown1_->AddGroup(249)->AddFixed64(250, 1);\n\n  unknown2_->AddVarint(243, 121);\n  unknown2_->AddLengthDelimited(73882, \"test 123\");\n  unknown2_->AddGroup(245)->AddFixed32(248, 3);\n  unknown2_->AddGroup(247);\n\n  EXPECT_EQ(\n      \"modified: 243[0]: 122 -> 121\\n\"\n      \"deleted: 244[0]: 0x0000000000172356\\n\"\n      \"deleted: 244[1]: 0x0000000000000098\\n\"\n      \"modified: 245[0].248[0]: 0x00000001 -> 0x00000003\\n\"\n      \"deleted: 245[0].248[1]: 0x00000002\\n\"\n      \"added: 247[0]: { ... }\\n\"\n      \"deleted: 249[0]: { ... }\\n\"\n      \"added: 73882[0]: \\\"test 123\\\"\\n\",\n      RunUn());\n}\n\nTEST_F(ComparisonTest, EquivalentIgnoresUnknown) {\n  unittest::ForeignMessage message1, message2;\n\n  message1.set_c(5);\n  message1.mutable_unknown_fields()->AddVarint(123, 456);\n  message2.set_c(5);\n  message2.mutable_unknown_fields()->AddVarint(321, 654);\n\n  EXPECT_FALSE(util::MessageDifferencer::Equals(message1, message2));\n  EXPECT_TRUE(util::MessageDifferencer::Equivalent(message1, message2));\n}\n\nclass MatchingTest : public testing::Test {\n public:\n  typedef util::MessageDifferencer MessageDifferencer;\n\n protected:\n  MatchingTest() {\n  }\n\n  ~MatchingTest() {\n  }\n\n  string RunWithResult(MessageDifferencer* differencer,\n                              const Message& msg1, const Message& msg2,\n                              bool result) {\n    string output;\n    {\n      // Before we return the \"output\" string, we must make sure the\n      // StreamReporter is destructored because its destructor will\n      // flush the stream.\n      io::StringOutputStream output_stream(&output);\n      MessageDifferencer::StreamReporter reporter(&output_stream);\n      reporter.set_report_modified_aggregates(true);\n      differencer->set_report_matches(true);\n      differencer->ReportDifferencesTo(&reporter);\n      if (result) {\n        EXPECT_TRUE(differencer->Compare(msg1, msg2));\n      } else {\n        EXPECT_FALSE(differencer->Compare(msg1, msg2));\n      }\n    }\n    return output;\n  }\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MatchingTest);\n};\n\nTEST_F(MatchingTest, StreamReporterMatching) {\n  protobuf_unittest::TestField msg1, msg2;\n  msg1.set_c(72);\n  msg2.set_c(72);\n  msg1.add_rc(13);\n  msg2.add_rc(13);\n  msg1.add_rc(17);\n  msg2.add_rc(17);\n  string output;\n  MessageDifferencer differencer;\n  differencer.set_report_matches(true);\n  differencer.ReportDifferencesToString(&output);\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n  EXPECT_EQ(\n      \"matched: c : 72\\n\"\n      \"matched: rc[0] : 13\\n\"\n      \"matched: rc[1] : 17\\n\",\n      output);\n}\n\nTEST_F(MatchingTest, DontReportMatchedWhenIgnoring) {\n  protobuf_unittest::TestField msg1, msg2;\n  msg1.set_c(72);\n  msg2.set_c(72);\n  msg1.add_rc(13);\n  msg2.add_rc(13);\n  msg1.add_rc(17);\n  msg2.add_rc(17);\n  string output;\n  MessageDifferencer differencer;\n  differencer.set_report_matches(true);\n  differencer.ReportDifferencesToString(&output);\n\n  differencer.IgnoreField(msg1.GetDescriptor()->FindFieldByName(\"c\"));\n\n  EXPECT_TRUE(differencer.Compare(msg1, msg2));\n  EXPECT_EQ(\n      \"ignored: c\\n\"\n      \"matched: rc[0] : 13\\n\"\n      \"matched: rc[1] : 17\\n\",\n      output);\n}\n\nTEST_F(MatchingTest, ReportMatchedForMovedFields) {\n  protobuf_unittest::TestDiffMessage msg1, msg2;\n  protobuf_unittest::TestDiffMessage::Item* item = msg1.add_item();\n  item->set_a(53);\n  item->set_b(\"hello\");\n  item = msg2.add_item();\n  item->set_a(27);\n  item = msg2.add_item();\n  item->set_a(53);\n  item->set_b(\"hello\");\n  item = msg1.add_item();\n  item->set_a(27);\n  MessageDifferencer differencer;\n  const FieldDescriptor* desc;\n  desc = msg1.GetDescriptor()->FindFieldByName(\"item\");\n  differencer.TreatAsSet(desc);\n\n  EXPECT_EQ(\n      \"matched: item[0].a -> item[1].a : 53\\n\"\n      \"matched: item[0].b -> item[1].b : \\\"hello\\\"\\n\"\n      \"moved: item[0] -> item[1] : { a: 53 b: \\\"hello\\\" }\\n\"\n      \"matched: item[1].a -> item[0].a : 27\\n\"\n      \"moved: item[1] -> item[0] : { a: 27 }\\n\",\n      RunWithResult(&differencer, msg1, msg2, true));\n}\n\nTEST_F(MatchingTest, MatchesAppearInPostTraversalOrderForMovedFields) {\n  protobuf_unittest::TestDiffMessage msg1, msg2;\n  protobuf_unittest::TestDiffMessage::Item* item;\n  protobuf_unittest::TestField* field;\n\n  const FieldDescriptor* desc;\n  const FieldDescriptor* nested_desc;\n  const FieldDescriptor* double_nested_desc;\n  desc = msg1.GetDescriptor()->FindFieldByName(\"item\");\n  nested_desc = desc->message_type()->FindFieldByName(\"rm\");\n  double_nested_desc = nested_desc->message_type()->FindFieldByName(\"rc\");\n  MessageDifferencer differencer;\n  differencer.TreatAsSet(desc);\n  differencer.TreatAsSet(nested_desc);\n  differencer.TreatAsSet(double_nested_desc);\n\n  item = msg1.add_item();\n  field = item->add_rm();\n  field->set_c(1);\n  field->add_rc(2);\n  field->add_rc(3);\n  field = item->add_rm();\n  field->set_c(4);\n  field->add_rc(5);\n  field->add_rc(6);\n  field->add_rc(7);\n  item = msg2.add_item();\n  field = item->add_rm();\n  field->set_c(4);\n  field->add_rc(7);\n  field->add_rc(6);\n  field->add_rc(5);\n  field = item->add_rm();\n  field->set_c(1);\n  field->add_rc(3);\n  field->add_rc(2);\n  item = msg1.add_item();\n  field = item->add_rm();\n  field->set_c(8);\n  field->add_rc(10);\n  field->add_rc(11);\n  field->add_rc(9);\n  item = msg2.add_item();\n  field = item->add_rm();\n  field->set_c(8);\n  field->add_rc(9);\n  field->add_rc(10);\n  field->add_rc(11);\n\n  EXPECT_EQ(\n      \"matched: item[0].rm[0].c -> item[0].rm[1].c : 1\\n\"\n      \"moved: item[0].rm[0].rc[0] -> item[0].rm[1].rc[1] : 2\\n\"\n      \"moved: item[0].rm[0].rc[1] -> item[0].rm[1].rc[0] : 3\\n\"\n      \"moved: item[0].rm[0] -> item[0].rm[1] : { c: 1 rc: 2 rc: 3 }\\n\"\n      \"matched: item[0].rm[1].c -> item[0].rm[0].c : 4\\n\"\n      \"moved: item[0].rm[1].rc[0] -> item[0].rm[0].rc[2] : 5\\n\"\n      \"matched: item[0].rm[1].rc[1] -> item[0].rm[0].rc[1] : 6\\n\"\n      \"moved: item[0].rm[1].rc[2] -> item[0].rm[0].rc[0] : 7\\n\"\n      \"moved: item[0].rm[1] -> item[0].rm[0] : { c: 4 rc: 5 rc: 6 rc: 7 }\\n\"\n      \"matched: item[0] : { rm { c: 1 rc: 2 rc: 3 }\"\n                          \" rm { c: 4 rc: 5 rc: 6 rc: 7 } }\\n\"\n      \"matched: item[1].rm[0].c : 8\\n\"\n      \"moved: item[1].rm[0].rc[0] -> item[1].rm[0].rc[1] : 10\\n\"\n      \"moved: item[1].rm[0].rc[1] -> item[1].rm[0].rc[2] : 11\\n\"\n      \"moved: item[1].rm[0].rc[2] -> item[1].rm[0].rc[0] : 9\\n\"\n      \"matched: item[1].rm[0] : { c: 8 rc: 10 rc: 11 rc: 9 }\\n\"\n      \"matched: item[1] : { rm { c: 8 rc: 10 rc: 11 rc: 9 } }\\n\",\n      RunWithResult(&differencer, msg1, msg2, true));\n}\n\nTEST_F(MatchingTest, MatchAndModifiedInterleaveProperly) {\n  protobuf_unittest::TestDiffMessage msg1, msg2;\n  protobuf_unittest::TestDiffMessage::Item* item;\n  protobuf_unittest::TestField* field;\n\n  const FieldDescriptor* desc;\n  const FieldDescriptor* nested_key;\n  const FieldDescriptor* nested_desc;\n  const FieldDescriptor* double_nested_key;\n  const FieldDescriptor* double_nested_desc;\n  desc = msg1.GetDescriptor()->FindFieldByName(\"item\");\n  nested_key = desc->message_type()->FindFieldByName(\"a\");\n  nested_desc = desc->message_type()->FindFieldByName(\"rm\");\n  double_nested_key = nested_desc->message_type()->FindFieldByName(\"c\");\n  double_nested_desc = nested_desc->message_type()->FindFieldByName(\"rc\");\n\n  MessageDifferencer differencer;\n  differencer.TreatAsMap(desc, nested_key);\n  differencer.TreatAsMap(nested_desc, double_nested_key);\n  differencer.TreatAsSet(double_nested_desc);\n\n  item = msg1.add_item();\n  item->set_a(1);\n  field = item->add_rm();\n  field->set_c(2);\n  field->add_rc(3);\n  field->add_rc(4);\n  field = item->add_rm();\n  field->set_c(5);\n  field->add_rc(6);\n  field->add_rc(7);\n  field->add_rc(8);\n  item = msg1.add_item();\n  item->set_a(9);\n  field = item->add_rm();\n  field->set_c(10);\n  field->add_rc(11);\n  field->add_rc(12);\n  field = item->add_rm();\n  field->set_c(13);\n\n  item = msg2.add_item();\n  item->set_a(1);\n  field = item->add_rm();\n  field->set_c(5);\n  field->add_rc(8);\n  field->add_rc(8);\n  field->add_rc(6);\n  field = item->add_rm();\n  field->set_c(3);\n  field->add_rc(2);\n  field->add_rc(4);\n  item = msg2.add_item();\n  item->set_a(9);\n  field = item->add_rm();\n  field->set_c(10);\n  field->add_rc(12);\n  field->add_rc(11);\n  field = item->add_rm();\n  field->set_c(13);\n\n  EXPECT_EQ(\n      \"matched: item[0].a : 1\\n\"\n      \"matched: item[0].rm[1].c -> item[0].rm[0].c : 5\\n\"\n      \"moved: item[0].rm[1].rc[0] -> item[0].rm[0].rc[2] : 6\\n\"\n      \"moved: item[0].rm[1].rc[2] -> item[0].rm[0].rc[0] : 8\\n\"\n      \"added: item[0].rm[0].rc[1]: 8\\n\"\n      \"deleted: item[0].rm[1].rc[1]: 7\\n\"\n      \"modified: item[0].rm[1] -> item[0].rm[0]: { c: 5 rc: 6 rc: 7 rc: 8 } ->\"\n                                               \" { c: 5 rc: 8 rc: 8 rc: 6 }\\n\"\n      \"added: item[0].rm[1]: { c: 3 rc: 2 rc: 4 }\\n\"\n      \"deleted: item[0].rm[0]: { c: 2 rc: 3 rc: 4 }\\n\"\n      \"modified: item[0]: { a: 1 rm { c: 2 rc: 3 rc: 4 }\"\n                               \" rm { c: 5 rc: 6 rc: 7 rc: 8 } } ->\"\n                        \" { a: 1 rm { c: 5 rc: 8 rc: 8 rc: 6 }\"\n                               \" rm { c: 3 rc: 2 rc: 4 } }\\n\"\n      \"matched: item[1].a : 9\\n\"\n      \"matched: item[1].rm[0].c : 10\\n\"\n      \"moved: item[1].rm[0].rc[0] -> item[1].rm[0].rc[1] : 11\\n\"\n      \"moved: item[1].rm[0].rc[1] -> item[1].rm[0].rc[0] : 12\\n\"\n      \"matched: item[1].rm[0] : { c: 10 rc: 11 rc: 12 }\\n\"\n      \"matched: item[1].rm[1].c : 13\\n\"\n      \"matched: item[1].rm[1] : { c: 13 }\\n\"\n      \"matched: item[1] : { a: 9 rm { c: 10 rc: 11 rc: 12 } rm { c: 13 } }\\n\",\n      RunWithResult(&differencer, msg1, msg2, false));\n}\n\nTEST_F(MatchingTest, MatchingWorksWithExtensions) {\n  protobuf_unittest::TestAllExtensions msg1, msg2;\n  protobuf_unittest::TestAllTypes::NestedMessage* nested;\n  using protobuf_unittest::repeated_nested_message_extension;\n\n  const FileDescriptor* descriptor;\n  const FieldDescriptor* desc;\n  const FieldDescriptor* nested_key;\n  descriptor = msg1.GetDescriptor()->file();\n  desc = descriptor->FindExtensionByName(\"repeated_nested_message_extension\");\n  ASSERT_FALSE(desc == NULL);\n  nested_key = desc->message_type()->FindFieldByName(\"bb\");\n\n  MessageDifferencer differencer;\n  differencer.TreatAsMap(desc, nested_key);\n\n  nested = msg1.AddExtension(repeated_nested_message_extension);\n  nested->set_bb(7);\n  nested = msg1.AddExtension(repeated_nested_message_extension);\n  nested->set_bb(13);\n  nested = msg1.AddExtension(repeated_nested_message_extension);\n  nested->set_bb(11);\n  nested = msg2.AddExtension(repeated_nested_message_extension);\n  nested->set_bb(11);\n  nested = msg2.AddExtension(repeated_nested_message_extension);\n  nested->set_bb(13);\n  nested = msg2.AddExtension(repeated_nested_message_extension);\n  nested->set_bb(7);\n\n  EXPECT_EQ(\n      \"matched: (protobuf_unittest.repeated_nested_message_extension)[0].bb ->\"\n              \" (protobuf_unittest.repeated_nested_message_extension)[2].bb : 7\\n\"\n      \"moved: (protobuf_unittest.repeated_nested_message_extension)[0] ->\"\n            \" (protobuf_unittest.repeated_nested_message_extension)[2] :\"\n                \" { bb: 7 }\\n\"\n      \"matched: (protobuf_unittest.repeated_nested_message_extension)[1].bb :\"\n                  \" 13\\n\"\n      \"matched: (protobuf_unittest.repeated_nested_message_extension)[1] :\"\n                  \" { bb: 13 }\\n\"\n      \"matched: (protobuf_unittest.repeated_nested_message_extension)[2].bb ->\"\n              \" (protobuf_unittest.repeated_nested_message_extension)[0].bb :\"\n                  \" 11\\n\"\n      \"moved: (protobuf_unittest.repeated_nested_message_extension)[2] ->\"\n            \" (protobuf_unittest.repeated_nested_message_extension)[0] :\"\n                \" { bb: 11 }\\n\",\n      RunWithResult(&differencer, msg1, msg2, true));\n}\n\nTEST(AnyTest, Simple) {\n  protobuf_unittest::TestField value1, value2;\n  value1.set_a(20);\n  value2.set_a(21);\n\n  protobuf_unittest::TestAny m1, m2;\n  m1.mutable_any_value()->PackFrom(value1);\n  m2.mutable_any_value()->PackFrom(value2);\n  util::MessageDifferencer message_differencer;\n  string difference_string;\n  message_differencer.ReportDifferencesToString(&difference_string);\n  EXPECT_FALSE(message_differencer.Compare(m1, m2));\n  EXPECT_EQ(\"modified: any_value.a: 20 -> 21\\n\", difference_string);\n}\n\nTEST(Anytest, TreatAsSet) {\n  protobuf_unittest::TestField value1, value2;\n  value1.set_a(20);\n  value1.set_b(30);\n  value2.set_a(20);\n  value2.set_b(31);\n\n  protobuf_unittest::TestAny m1, m2;\n  m1.add_repeated_any_value()->PackFrom(value1);\n  m1.add_repeated_any_value()->PackFrom(value2);\n  m2.add_repeated_any_value()->PackFrom(value2);\n  m2.add_repeated_any_value()->PackFrom(value1);\n\n  util::MessageDifferencer message_differencer;\n  message_differencer.TreatAsSet(GetFieldDescriptor(m1, \"repeated_any_value\"));\n  EXPECT_TRUE(message_differencer.Compare(m1, m2));\n}\n\n\n}  // namespace\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/message_differencer_unittest.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This file contains messages for testing repeated field comparison\n\nsyntax = \"proto2\";\npackage protobuf_unittest;\n\noption optimize_for = SPEED;\n\nmessage TestField {\n  optional int32 a = 3;\n  optional int32 b = 4;\n  optional int32 c = 1;\n  repeated int32 rc = 2;\n  optional TestField m = 5;\n\n  extend TestDiffMessage {\n    optional TestField tf = 100;\n  }\n}\n\nmessage TestDiffMessage {\n  repeated group Item = 1 {\n    optional int32  a  =  2;     // Test basic repeated field comparison.\n    optional string b  =  4;     // Test basic repeated field comparison.\n    repeated int32  ra =  3;     // Test SetOfSet Comparison.\n    repeated string rb =  5;     // Test TreatAsMap when key is repeated\n    optional TestField m  = 6;   // Test TreatAsMap when key is a message\n    repeated TestField rm = 7;   // Test TreatAsMap when key is a repeated\n                                 // message\n  }\n\n  optional int32  v  = 13 [deprecated = true];\n  optional string w  = 14;\n  optional TestField m  = 15;\n  repeated int32  rv = 11;       // Test for combinations\n  repeated string rw = 10;       // Test for combinations\n  repeated TestField rm = 12 [deprecated = true];    // Test for combinations\n\n  extensions 100 to 199;\n}\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/time_util.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/time_util.h>\n\n#include <google/protobuf/stubs/time.h>\n#include <google/protobuf/stubs/int128.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/stringprintf.h>\n#include <google/protobuf/duration.pb.h>\n#include <google/protobuf/timestamp.pb.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\n\nusing google::protobuf::Timestamp;\nusing google::protobuf::Duration;\n\nnamespace {\nstatic const int kNanosPerSecond = 1000000000;\nstatic const int kMicrosPerSecond = 1000000;\nstatic const int kMillisPerSecond = 1000;\nstatic const int kNanosPerMillisecond = 1000000;\nstatic const int kMicrosPerMillisecond = 1000;\nstatic const int kNanosPerMicrosecond = 1000;\nstatic const int kSecondsPerMinute = 60;  // Note that we ignore leap seconds.\nstatic const int kSecondsPerHour = 3600;\nstatic const char kTimestampFormat[] = \"%E4Y-%m-%dT%H:%M:%S\";\n\ntemplate <typename T>\nT CreateNormalized(int64 seconds, int64 nanos);\n\ntemplate <>\nTimestamp CreateNormalized(int64 seconds, int64 nanos) {\n  // Make sure nanos is in the range.\n  if (nanos <= -kNanosPerSecond || nanos >= kNanosPerSecond) {\n    seconds += nanos / kNanosPerSecond;\n    nanos = nanos % kNanosPerSecond;\n  }\n  // For Timestamp nanos should be in the range [0, 999999999]\n  if (nanos < 0) {\n    seconds -= 1;\n    nanos += kNanosPerSecond;\n  }\n  GOOGLE_DCHECK(seconds >= TimeUtil::kTimestampMinSeconds &&\n         seconds <= TimeUtil::kTimestampMaxSeconds);\n  Timestamp result;\n  result.set_seconds(seconds);\n  result.set_nanos(static_cast<int32>(nanos));\n  return result;\n}\n\ntemplate <>\nDuration CreateNormalized(int64 seconds, int64 nanos) {\n  // Make sure nanos is in the range.\n  if (nanos <= -kNanosPerSecond || nanos >= kNanosPerSecond) {\n    seconds += nanos / kNanosPerSecond;\n    nanos = nanos % kNanosPerSecond;\n  }\n  // nanos should have the same sign as seconds.\n  if (seconds < 0 && nanos > 0) {\n    seconds += 1;\n    nanos -= kNanosPerSecond;\n  } else if (seconds > 0 && nanos < 0) {\n    seconds -= 1;\n    nanos += kNanosPerSecond;\n  }\n  GOOGLE_DCHECK(seconds >= TimeUtil::kDurationMinSeconds &&\n         seconds <= TimeUtil::kDurationMaxSeconds);\n  Duration result;\n  result.set_seconds(seconds);\n  result.set_nanos(static_cast<int32>(nanos));\n  return result;\n}\n\n// Format nanoseconds with either 3, 6, or 9 digits depending on the required\n// precision to represent the exact value.\nstring FormatNanos(int32 nanos) {\n  if (nanos % kNanosPerMillisecond == 0) {\n    return StringPrintf(\"%03d\", nanos / kNanosPerMillisecond);\n  } else if (nanos % kNanosPerMicrosecond == 0) {\n    return StringPrintf(\"%06d\", nanos / kNanosPerMicrosecond);\n  } else {\n    return StringPrintf(\"%09d\", nanos);\n  }\n}\n\nstring FormatTime(int64 seconds, int32 nanos) {\n  return ::google::protobuf::internal::FormatTime(seconds, nanos);\n}\n\nbool ParseTime(const string& value, int64* seconds, int32* nanos) {\n  return ::google::protobuf::internal::ParseTime(value, seconds, nanos);\n}\n\nvoid CurrentTime(int64* seconds, int32* nanos) {\n  return ::google::protobuf::internal::GetCurrentTime(seconds, nanos);\n}\n\n// Truncates the remainder part after division.\nint64 RoundTowardZero(int64 value, int64 divider) {\n  int64 result = value / divider;\n  int64 remainder = value % divider;\n  // Before C++11, the sign of the remainder is implementation dependent if\n  // any of the operands is negative. Here we try to enforce C++11's \"rounded\n  // toward zero\" semantics. For example, for (-5) / 2 an implementation may\n  // give -3 as the result with the remainder being 1. This function ensures\n  // we always return -2 (closer to zero) regardless of the implementation.\n  if (result < 0 && remainder > 0) {\n    return result + 1;\n  } else {\n    return result;\n  }\n}\n}  // namespace\n\n// Actually define these static const integers. Required by C++ standard (but\n// omitting them may still work with some compilers).\nconst int64 TimeUtil::kTimestampMinSeconds;\nconst int64 TimeUtil::kTimestampMaxSeconds;\nconst int64 TimeUtil::kDurationMaxSeconds;\nconst int64 TimeUtil::kDurationMinSeconds;\n\nstring TimeUtil::ToString(const Timestamp& timestamp) {\n  return FormatTime(timestamp.seconds(), timestamp.nanos());\n}\n\nbool TimeUtil::FromString(const string& value, Timestamp* timestamp) {\n  int64 seconds;\n  int32 nanos;\n  if (!ParseTime(value, &seconds, &nanos)) {\n    return false;\n  }\n  *timestamp = CreateNormalized<Timestamp>(seconds, nanos);\n  return true;\n}\n\nTimestamp TimeUtil::GetCurrentTime() {\n  int64 seconds;\n  int32 nanos;\n  CurrentTime(&seconds, &nanos);\n  return CreateNormalized<Timestamp>(seconds, nanos);\n}\n\nTimestamp TimeUtil::GetEpoch() { return Timestamp(); }\n\nstring TimeUtil::ToString(const Duration& duration) {\n  string result;\n  int64 seconds = duration.seconds();\n  int32 nanos = duration.nanos();\n  if (seconds < 0 || nanos < 0) {\n    result += \"-\";\n    seconds = -seconds;\n    nanos = -nanos;\n  }\n  result += SimpleItoa(seconds);\n  if (nanos != 0) {\n    result += \".\" + FormatNanos(nanos);\n  }\n  result += \"s\";\n  return result;\n}\n\nstatic int64 Pow(int64 x, int y) {\n  int64 result = 1;\n  for (int i = 0; i < y; ++i) {\n    result *= x;\n  }\n  return result;\n}\n\nbool TimeUtil::FromString(const string& value, Duration* duration) {\n  if (value.length() <= 1 || value[value.length() - 1] != 's') {\n    return false;\n  }\n  bool negative = (value[0] == '-');\n  int sign_length = (negative ? 1 : 0);\n  // Parse the duration value as two integers rather than a float value\n  // to avoid precision loss.\n  string seconds_part, nanos_part;\n  size_t pos = value.find_last_of(\".\");\n  if (pos == string::npos) {\n    seconds_part = value.substr(sign_length, value.length() - 1 - sign_length);\n    nanos_part = \"0\";\n  } else {\n    seconds_part = value.substr(sign_length, pos - sign_length);\n    nanos_part = value.substr(pos + 1, value.length() - pos - 2);\n  }\n  char* end;\n  int64 seconds = strto64(seconds_part.c_str(), &end, 10);\n  if (end != seconds_part.c_str() + seconds_part.length()) {\n    return false;\n  }\n  int64 nanos = strto64(nanos_part.c_str(), &end, 10);\n  if (end != nanos_part.c_str() + nanos_part.length()) {\n    return false;\n  }\n  nanos = nanos * Pow(10, 9 - nanos_part.length());\n  if (negative) {\n    // If a Duration is negative, both seconds and nanos should be negative.\n    seconds = -seconds;\n    nanos = -nanos;\n  }\n  duration->set_seconds(seconds);\n  duration->set_nanos(static_cast<int32>(nanos));\n  return true;\n}\n\nDuration TimeUtil::NanosecondsToDuration(int64 nanos) {\n  return CreateNormalized<Duration>(nanos / kNanosPerSecond,\n                                    nanos % kNanosPerSecond);\n}\n\nDuration TimeUtil::MicrosecondsToDuration(int64 micros) {\n  return CreateNormalized<Duration>(\n      micros / kMicrosPerSecond,\n      (micros % kMicrosPerSecond) * kNanosPerMicrosecond);\n}\n\nDuration TimeUtil::MillisecondsToDuration(int64 millis) {\n  return CreateNormalized<Duration>(\n      millis / kMillisPerSecond,\n      (millis % kMillisPerSecond) * kNanosPerMillisecond);\n}\n\nDuration TimeUtil::SecondsToDuration(int64 seconds) {\n  return CreateNormalized<Duration>(seconds, 0);\n}\n\nDuration TimeUtil::MinutesToDuration(int64 minutes) {\n  return CreateNormalized<Duration>(minutes * kSecondsPerMinute, 0);\n}\n\nDuration TimeUtil::HoursToDuration(int64 hours) {\n  return CreateNormalized<Duration>(hours * kSecondsPerHour, 0);\n}\n\nint64 TimeUtil::DurationToNanoseconds(const Duration& duration) {\n  return duration.seconds() * kNanosPerSecond + duration.nanos();\n}\n\nint64 TimeUtil::DurationToMicroseconds(const Duration& duration) {\n  return duration.seconds() * kMicrosPerSecond +\n         RoundTowardZero(duration.nanos(), kNanosPerMicrosecond);\n}\n\nint64 TimeUtil::DurationToMilliseconds(const Duration& duration) {\n  return duration.seconds() * kMillisPerSecond +\n         RoundTowardZero(duration.nanos(), kNanosPerMillisecond);\n}\n\nint64 TimeUtil::DurationToSeconds(const Duration& duration) {\n  return duration.seconds();\n}\n\nint64 TimeUtil::DurationToMinutes(const Duration& duration) {\n  return RoundTowardZero(duration.seconds(), kSecondsPerMinute);\n}\n\nint64 TimeUtil::DurationToHours(const Duration& duration) {\n  return RoundTowardZero(duration.seconds(), kSecondsPerHour);\n}\n\nTimestamp TimeUtil::NanosecondsToTimestamp(int64 nanos) {\n  return CreateNormalized<Timestamp>(nanos / kNanosPerSecond,\n                                     nanos % kNanosPerSecond);\n}\n\nTimestamp TimeUtil::MicrosecondsToTimestamp(int64 micros) {\n  return CreateNormalized<Timestamp>(\n      micros / kMicrosPerSecond,\n      micros % kMicrosPerSecond * kNanosPerMicrosecond);\n}\n\nTimestamp TimeUtil::MillisecondsToTimestamp(int64 millis) {\n  return CreateNormalized<Timestamp>(\n      millis / kMillisPerSecond,\n      millis % kMillisPerSecond * kNanosPerMillisecond);\n}\n\nTimestamp TimeUtil::SecondsToTimestamp(int64 seconds) {\n  return CreateNormalized<Timestamp>(seconds, 0);\n}\n\nint64 TimeUtil::TimestampToNanoseconds(const Timestamp& timestamp) {\n  return timestamp.seconds() * kNanosPerSecond + timestamp.nanos();\n}\n\nint64 TimeUtil::TimestampToMicroseconds(const Timestamp& timestamp) {\n  return timestamp.seconds() * kMicrosPerSecond +\n         RoundTowardZero(timestamp.nanos(), kNanosPerMicrosecond);\n}\n\nint64 TimeUtil::TimestampToMilliseconds(const Timestamp& timestamp) {\n  return timestamp.seconds() * kMillisPerSecond +\n         RoundTowardZero(timestamp.nanos(), kNanosPerMillisecond);\n}\n\nint64 TimeUtil::TimestampToSeconds(const Timestamp& timestamp) {\n  return timestamp.seconds();\n}\n\nTimestamp TimeUtil::TimeTToTimestamp(time_t value) {\n  return CreateNormalized<Timestamp>(static_cast<int64>(value), 0);\n}\n\ntime_t TimeUtil::TimestampToTimeT(const Timestamp& value) {\n  return static_cast<time_t>(value.seconds());\n}\n\nTimestamp TimeUtil::TimevalToTimestamp(const timeval& value) {\n  return CreateNormalized<Timestamp>(value.tv_sec,\n                                     value.tv_usec * kNanosPerMicrosecond);\n}\n\ntimeval TimeUtil::TimestampToTimeval(const Timestamp& value) {\n  timeval result;\n  result.tv_sec = value.seconds();\n  result.tv_usec = RoundTowardZero(value.nanos(), kNanosPerMicrosecond);\n  return result;\n}\n\nDuration TimeUtil::TimevalToDuration(const timeval& value) {\n  return CreateNormalized<Duration>(value.tv_sec,\n                                    value.tv_usec * kNanosPerMicrosecond);\n}\n\ntimeval TimeUtil::DurationToTimeval(const Duration& value) {\n  timeval result;\n  result.tv_sec = value.seconds();\n  result.tv_usec = RoundTowardZero(value.nanos(), kNanosPerMicrosecond);\n  // timeval.tv_usec's range is [0, 1000000)\n  if (result.tv_usec < 0) {\n    result.tv_sec -= 1;\n    result.tv_usec += kMicrosPerSecond;\n  }\n  return result;\n}\n\n}  // namespace util\n}  // namespace protobuf\n\n\nnamespace protobuf {\nnamespace {\nusing google::protobuf::util::kNanosPerSecond;\nusing google::protobuf::util::CreateNormalized;\n\n// Convert a Timestamp to uint128.\nvoid ToUint128(const Timestamp& value, uint128* result, bool* negative) {\n  if (value.seconds() < 0) {\n    *negative = true;\n    *result = static_cast<uint64>(-value.seconds());\n    *result = *result * kNanosPerSecond - static_cast<uint32>(value.nanos());\n  } else {\n    *negative = false;\n    *result = static_cast<uint64>(value.seconds());\n    *result = *result * kNanosPerSecond + static_cast<uint32>(value.nanos());\n  }\n}\n\n// Convert a Duration to uint128.\nvoid ToUint128(const Duration& value, uint128* result, bool* negative) {\n  if (value.seconds() < 0 || value.nanos() < 0) {\n    *negative = true;\n    *result = static_cast<uint64>(-value.seconds());\n    *result = *result * kNanosPerSecond + static_cast<uint32>(-value.nanos());\n  } else {\n    *negative = false;\n    *result = static_cast<uint64>(value.seconds());\n    *result = *result * kNanosPerSecond + static_cast<uint32>(value.nanos());\n  }\n}\n\nvoid ToTimestamp(const uint128& value, bool negative, Timestamp* timestamp) {\n  int64 seconds = static_cast<int64>(Uint128Low64(value / kNanosPerSecond));\n  int32 nanos = static_cast<int32>(Uint128Low64(value % kNanosPerSecond));\n  if (negative) {\n    seconds = -seconds;\n    nanos = -nanos;\n    if (nanos < 0) {\n      nanos += kNanosPerSecond;\n      seconds -= 1;\n    }\n  }\n  timestamp->set_seconds(seconds);\n  timestamp->set_nanos(nanos);\n}\n\nvoid ToDuration(const uint128& value, bool negative, Duration* duration) {\n  int64 seconds = static_cast<int64>(Uint128Low64(value / kNanosPerSecond));\n  int32 nanos = static_cast<int32>(Uint128Low64(value % kNanosPerSecond));\n  if (negative) {\n    seconds = -seconds;\n    nanos = -nanos;\n  }\n  duration->set_seconds(seconds);\n  duration->set_nanos(nanos);\n}\n}  // namespace\n\nDuration& operator+=(Duration& d1, const Duration& d2) {\n  d1 = CreateNormalized<Duration>(d1.seconds() + d2.seconds(),\n                                  d1.nanos() + d2.nanos());\n  return d1;\n}\n\nDuration& operator-=(Duration& d1, const Duration& d2) {  // NOLINT\n  d1 = CreateNormalized<Duration>(d1.seconds() - d2.seconds(),\n                                  d1.nanos() - d2.nanos());\n  return d1;\n}\n\nDuration& operator*=(Duration& d, int64 r) {  // NOLINT\n  bool negative;\n  uint128 value;\n  ToUint128(d, &value, &negative);\n  if (r > 0) {\n    value *= static_cast<uint64>(r);\n  } else {\n    negative = !negative;\n    value *= static_cast<uint64>(-r);\n  }\n  ToDuration(value, negative, &d);\n  return d;\n}\n\nDuration& operator*=(Duration& d, double r) {  // NOLINT\n  double result = (d.seconds() * 1.0 + 1.0 * d.nanos() / kNanosPerSecond) * r;\n  int64 seconds = static_cast<int64>(result);\n  int32 nanos = static_cast<int32>((result - seconds) * kNanosPerSecond);\n  // Note that we normalize here not just because nanos can have a different\n  // sign from seconds but also that nanos can be any arbitrary value when\n  // overflow happens (i.e., the result is a much larger value than what\n  // int64 can represent).\n  d = CreateNormalized<Duration>(seconds, nanos);\n  return d;\n}\n\nDuration& operator/=(Duration& d, int64 r) {  // NOLINT\n  bool negative;\n  uint128 value;\n  ToUint128(d, &value, &negative);\n  if (r > 0) {\n    value /= static_cast<uint64>(r);\n  } else {\n    negative = !negative;\n    value /= static_cast<uint64>(-r);\n  }\n  ToDuration(value, negative, &d);\n  return d;\n}\n\nDuration& operator/=(Duration& d, double r) {  // NOLINT\n  return d *= 1.0 / r;\n}\n\nDuration& operator%=(Duration& d1, const Duration& d2) {  // NOLINT\n  bool negative1, negative2;\n  uint128 value1, value2;\n  ToUint128(d1, &value1, &negative1);\n  ToUint128(d2, &value2, &negative2);\n  uint128 result = value1 % value2;\n  // When negative values are involved in division, we round the division\n  // result towards zero. With this semantics, sign of the remainder is the\n  // same as the dividend. For example:\n  //     -5 / 10    = 0, -5 % 10    = -5\n  //     -5 / (-10) = 0, -5 % (-10) = -5\n  //      5 / (-10) = 0,  5 % (-10) = 5\n  ToDuration(result, negative1, &d1);\n  return d1;\n}\n\nint64 operator/(const Duration& d1, const Duration& d2) {\n  bool negative1, negative2;\n  uint128 value1, value2;\n  ToUint128(d1, &value1, &negative1);\n  ToUint128(d2, &value2, &negative2);\n  int64 result = Uint128Low64(value1 / value2);\n  if (negative1 != negative2) {\n    result = -result;\n  }\n  return result;\n}\n\nTimestamp& operator+=(Timestamp& t, const Duration& d) {  // NOLINT\n  t = CreateNormalized<Timestamp>(t.seconds() + d.seconds(),\n                                  t.nanos() + d.nanos());\n  return t;\n}\n\nTimestamp& operator-=(Timestamp& t, const Duration& d) {  // NOLINT\n  t = CreateNormalized<Timestamp>(t.seconds() - d.seconds(),\n                                  t.nanos() - d.nanos());\n  return t;\n}\n\nDuration operator-(const Timestamp& t1, const Timestamp& t2) {\n  return CreateNormalized<Duration>(t1.seconds() - t2.seconds(),\n                                    t1.nanos() - t2.nanos());\n}\n}  // namespace protobuf\n\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/time_util.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_TIME_UTIL_H__\n#define GOOGLE_PROTOBUF_UTIL_TIME_UTIL_H__\n\n#include <ctime>\n#include <ostream>\n#include <string>\n#ifdef _MSC_VER\n#include <winsock2.h>\n#else\n#include <sys/time.h>\n#endif\n\n#include <google/protobuf/duration.pb.h>\n#include <google/protobuf/timestamp.pb.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\n\nclass LIBPROTOBUF_EXPORT TimeUtil {\n  typedef google::protobuf::Timestamp Timestamp;\n  typedef google::protobuf::Duration Duration;\n\n public:\n  // The min/max Timestamp/Duration values we support.\n  //\n  // For \"0001-01-01T00:00:00Z\".\n  static const int64 kTimestampMinSeconds = -62135596800LL;\n  // For \"9999-12-31T23:59:59.999999999Z\".\n  static const int64 kTimestampMaxSeconds = 253402300799LL;\n  static const int64 kDurationMinSeconds = -315576000000LL;\n  static const int64 kDurationMaxSeconds = 315576000000LL;\n\n  // Converts Timestamp to/from RFC 3339 date string format.\n  // Generated output will always be Z-normalized and uses 3, 6 or 9\n  // fractional digits as required to represent the exact time. When\n  // parsing, any fractional digits (or none) and any offset are\n  // accepted as long as they fit into nano-seconds precision.\n  // Note that Timestamp can only represent time from\n  // 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. Converting\n  // a Timestamp outside of this range is undefined behavior.\n  // See https://www.ietf.org/rfc/rfc3339.txt\n  //\n  // Example of generated format:\n  //   \"1972-01-01T10:00:20.021Z\"\n  //\n  // Example of accepted format:\n  //   \"1972-01-01T10:00:20.021-05:00\"\n  static string ToString(const Timestamp& timestamp);\n  static bool FromString(const string& value, Timestamp* timestamp);\n\n  // Converts Duration to/from string format. The string format will contains\n  // 3, 6, or 9 fractional digits depending on the precision required to\n  // represent the exact Duration value. For example:\n  //   \"1s\", \"1.010s\", \"1.000000100s\", \"-3.100s\"\n  // The range that can be represented by Duration is from -315,576,000,000\n  // to +315,576,000,000 inclusive (in seconds).\n  static string ToString(const Duration& duration);\n  static bool FromString(const string& value, Duration* timestamp);\n\n#ifdef GetCurrentTime\n#undef GetCurrentTime  // Visual Studio has macro GetCurrentTime\n#endif\n  // Gets the current UTC time.\n  static Timestamp GetCurrentTime();\n  // Returns the Time representing \"1970-01-01 00:00:00\".\n  static Timestamp GetEpoch();\n\n  // Converts between Duration and integer types. The behavior is undefined if\n  // the input value is not in the valid range of Duration.\n  static Duration NanosecondsToDuration(int64 nanos);\n  static Duration MicrosecondsToDuration(int64 micros);\n  static Duration MillisecondsToDuration(int64 millis);\n  static Duration SecondsToDuration(int64 seconds);\n  static Duration MinutesToDuration(int64 minutes);\n  static Duration HoursToDuration(int64 hours);\n  // Result will be truncated towards zero. For example, \"-1.5s\" will be\n  // truncated to \"-1s\", and \"1.5s\" to \"1s\" when converting to seconds.\n  // It's undefined behavior if the input duration is not valid or the result\n  // exceeds the range of int64. A duration is not valid if it's not in the\n  // valid range of Duration, or have an invalid nanos value (i.e., larger\n  // than 999999999, less than -999999999, or have a different sign from the\n  // seconds part).\n  static int64 DurationToNanoseconds(const Duration& duration);\n  static int64 DurationToMicroseconds(const Duration& duration);\n  static int64 DurationToMilliseconds(const Duration& duration);\n  static int64 DurationToSeconds(const Duration& duration);\n  static int64 DurationToMinutes(const Duration& duration);\n  static int64 DurationToHours(const Duration& duration);\n  // Creates Timestamp from integer types. The integer value indicates the\n  // time elapsed from Epoch time. The behavior is undefined if the input\n  // value is not in the valid range of Timestamp.\n  static Timestamp NanosecondsToTimestamp(int64 nanos);\n  static Timestamp MicrosecondsToTimestamp(int64 micros);\n  static Timestamp MillisecondsToTimestamp(int64 millis);\n  static Timestamp SecondsToTimestamp(int64 seconds);\n  // Result will be truncated down to the nearest integer value. For example,\n  // with \"1969-12-31T23:59:59.9Z\", TimestampToMilliseconds() returns -100\n  // and TimestampToSeconds() returns -1. It's undefined behavior if the input\n  // Timestamp is not valid (i.e., its seconds part or nanos part does not fall\n  // in the valid range) or the return value doesn't fit into int64.\n  static int64 TimestampToNanoseconds(const Timestamp& timestamp);\n  static int64 TimestampToMicroseconds(const Timestamp& timestamp);\n  static int64 TimestampToMilliseconds(const Timestamp& timestamp);\n  static int64 TimestampToSeconds(const Timestamp& timestamp);\n\n  // Conversion to/from other time/date types. Note that these types may\n  // have a different precision and time range from Timestamp/Duration.\n  // When converting to a lower precision type, the value will be truncated\n  // to the nearest value that can be represented. If the value is\n  // out of the range of the result type, the return value is undefined.\n  //\n  // Conversion to/from time_t\n  static Timestamp TimeTToTimestamp(time_t value);\n  static time_t TimestampToTimeT(const Timestamp& value);\n\n  // Conversion to/from timeval\n  static Timestamp TimevalToTimestamp(const timeval& value);\n  static timeval TimestampToTimeval(const Timestamp& value);\n  static Duration TimevalToDuration(const timeval& value);\n  static timeval DurationToTimeval(const Duration& value);\n};\n\n}  // namespace util\n}  // namespace protobuf\n\n\nnamespace protobuf {\n// Overloaded operators for Duration.\n//\n// Assignment operators.\nLIBPROTOBUF_EXPORT Duration& operator+=(Duration& d1, const Duration& d2);  // NOLINT\nLIBPROTOBUF_EXPORT Duration& operator-=(Duration& d1, const Duration& d2);  // NOLINT\nLIBPROTOBUF_EXPORT Duration& operator*=(Duration& d, int64 r);  // NOLINT\nLIBPROTOBUF_EXPORT Duration& operator*=(Duration& d, double r);  // NOLINT\nLIBPROTOBUF_EXPORT Duration& operator/=(Duration& d, int64 r);  // NOLINT\nLIBPROTOBUF_EXPORT Duration& operator/=(Duration& d, double r);  // NOLINT\n// Overload for other integer types.\ntemplate <typename T>\nDuration& operator*=(Duration& d, T r) {  // NOLINT\n  int64 x = r;\n  return d *= x;\n}\ntemplate <typename T>\nDuration& operator/=(Duration& d, T r) {  // NOLINT\n  int64 x = r;\n  return d /= x;\n}\nLIBPROTOBUF_EXPORT Duration& operator%=(Duration& d1, const Duration& d2);  // NOLINT\n// Relational operators.\ninline bool operator<(const Duration& d1, const Duration& d2) {\n  if (d1.seconds() == d2.seconds()) {\n    return d1.nanos() < d2.nanos();\n  }\n  return d1.seconds() < d2.seconds();\n}\ninline bool operator>(const Duration& d1, const Duration& d2) {\n  return d2 < d1;\n}\ninline bool operator>=(const Duration& d1, const Duration& d2) {\n  return !(d1 < d2);\n}\ninline bool operator<=(const Duration& d1, const Duration& d2) {\n  return !(d2 < d1);\n}\ninline bool operator==(const Duration& d1, const Duration& d2) {\n  return d1.seconds() == d2.seconds() && d1.nanos() == d2.nanos();\n}\ninline bool operator!=(const Duration& d1, const Duration& d2) {\n  return !(d1 == d2);\n}\n// Additive operators\ninline Duration operator-(const Duration& d) {\n  Duration result;\n  result.set_seconds(-d.seconds());\n  result.set_nanos(-d.nanos());\n  return result;\n}\ninline Duration operator+(const Duration& d1, const Duration& d2) {\n  Duration result = d1;\n  return result += d2;\n}\ninline Duration operator-(const Duration& d1, const Duration& d2) {\n  Duration result = d1;\n  return result -= d2;\n}\n// Multiplicative operators\ntemplate<typename T>\ninline Duration operator*(Duration d, T r) {\n  return d *= r;\n}\ntemplate<typename T>\ninline Duration operator*(T r, Duration d) {\n  return d *= r;\n}\ntemplate<typename T>\ninline Duration operator/(Duration d, T r) {\n  return d /= r;\n}\nLIBPROTOBUF_EXPORT int64 operator/(const Duration& d1, const Duration& d2);\n\ninline Duration operator%(const Duration& d1, const Duration& d2) {\n  Duration result = d1;\n  return result %= d2;\n}\n\ninline ostream& operator<<(ostream& out, const Duration& d) {\n  out << google::protobuf::util::TimeUtil::ToString(d);\n  return out;\n}\n\n// Overloaded operators for Timestamp\n//\n// Assignement operators.\nLIBPROTOBUF_EXPORT Timestamp& operator+=(Timestamp& t, const Duration& d);  // NOLINT\nLIBPROTOBUF_EXPORT Timestamp& operator-=(Timestamp& t, const Duration& d);  // NOLINT\n// Relational operators.\ninline bool operator<(const Timestamp& t1, const Timestamp& t2) {\n  if (t1.seconds() == t2.seconds()) {\n    return t1.nanos() < t2.nanos();\n  }\n  return t1.seconds() < t2.seconds();\n}\ninline bool operator>(const Timestamp& t1, const Timestamp& t2) {\n  return t2 < t1;\n}\ninline bool operator>=(const Timestamp& t1, const Timestamp& t2) {\n  return !(t1 < t2);\n}\ninline bool operator<=(const Timestamp& t1, const Timestamp& t2) {\n  return !(t2 < t1);\n}\ninline bool operator==(const Timestamp& t1, const Timestamp& t2) {\n  return t1.seconds() == t2.seconds() && t1.nanos() == t2.nanos();\n}\ninline bool operator!=(const Timestamp& t1, const Timestamp& t2) {\n  return !(t1 == t2);\n}\n// Additive operators.\ninline Timestamp operator+(const Timestamp& t, const Duration& d) {\n  Timestamp result = t;\n  return result += d;\n}\ninline Timestamp operator+(const Duration& d, const Timestamp& t) {\n  Timestamp result = t;\n  return result += d;\n}\ninline Timestamp operator-(const Timestamp& t, const Duration& d) {\n  Timestamp result = t;\n  return result -= d;\n}\nLIBPROTOBUF_EXPORT Duration operator-(const Timestamp& t1, const Timestamp& t2);\n\ninline ostream& operator<<(ostream& out, const Timestamp& t) {\n  out << google::protobuf::util::TimeUtil::ToString(t);\n  return out;\n}\n\n}  // namespace protobuf\n\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_TIME_UTIL_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/time_util_test.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/time_util.h>\n\n#include <ctime>\n\n#include <google/protobuf/timestamp.pb.h>\n#include <google/protobuf/duration.pb.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\n\nusing google::protobuf::Timestamp;\nusing google::protobuf::Duration;\n\nnamespace {\n\nTEST(TimeUtilTest, TimestampStringFormat) {\n  Timestamp begin, end;\n  EXPECT_TRUE(TimeUtil::FromString(\"0001-01-01T00:00:00Z\", &begin));\n  EXPECT_EQ(TimeUtil::kTimestampMinSeconds, begin.seconds());\n  EXPECT_EQ(0, begin.nanos());\n  EXPECT_TRUE(TimeUtil::FromString(\"9999-12-31T23:59:59.999999999Z\", &end));\n  EXPECT_EQ(TimeUtil::kTimestampMaxSeconds, end.seconds());\n  EXPECT_EQ(999999999, end.nanos());\n  EXPECT_EQ(\"0001-01-01T00:00:00Z\", TimeUtil::ToString(begin));\n  EXPECT_EQ(\"9999-12-31T23:59:59.999999999Z\", TimeUtil::ToString(end));\n\n  // Test negative timestamps.\n  Timestamp time = TimeUtil::NanosecondsToTimestamp(-1);\n  EXPECT_EQ(-1, time.seconds());\n  // Timestamp's nano part is always non-negative.\n  EXPECT_EQ(999999999, time.nanos());\n  EXPECT_EQ(\"1969-12-31T23:59:59.999999999Z\", TimeUtil::ToString(time));\n\n  // Generated output should contain 3, 6, or 9 fractional digits.\n  EXPECT_EQ(\"1970-01-01T00:00:00Z\",\n            TimeUtil::ToString(TimeUtil::NanosecondsToTimestamp(0)));\n  EXPECT_EQ(\"1970-01-01T00:00:00.010Z\",\n            TimeUtil::ToString(TimeUtil::NanosecondsToTimestamp(10000000)));\n  EXPECT_EQ(\"1970-01-01T00:00:00.000010Z\",\n            TimeUtil::ToString(TimeUtil::NanosecondsToTimestamp(10000)));\n  EXPECT_EQ(\"1970-01-01T00:00:00.000000010Z\",\n            TimeUtil::ToString(TimeUtil::NanosecondsToTimestamp(10)));\n\n  // Parsing accepts an fractional digits as long as they fit into nano\n  // precision.\n  EXPECT_TRUE(TimeUtil::FromString(\"1970-01-01T00:00:00.1Z\", &time));\n  EXPECT_EQ(100000000, TimeUtil::TimestampToNanoseconds(time));\n  EXPECT_TRUE(TimeUtil::FromString(\"1970-01-01T00:00:00.0001Z\", &time));\n  EXPECT_EQ(100000, TimeUtil::TimestampToNanoseconds(time));\n  EXPECT_TRUE(TimeUtil::FromString(\"1970-01-01T00:00:00.0000001Z\", &time));\n  EXPECT_EQ(100, TimeUtil::TimestampToNanoseconds(time));\n\n  // Also accpets offsets.\n  EXPECT_TRUE(TimeUtil::FromString(\"1970-01-01T00:00:00-08:00\", &time));\n  EXPECT_EQ(8 * 3600, TimeUtil::TimestampToSeconds(time));\n}\n\nTEST(TimeUtilTest, DurationStringFormat) {\n  Timestamp begin, end;\n  EXPECT_TRUE(TimeUtil::FromString(\"0001-01-01T00:00:00Z\", &begin));\n  EXPECT_TRUE(TimeUtil::FromString(\"9999-12-31T23:59:59.999999999Z\", &end));\n\n  EXPECT_EQ(\"315537897599.999999999s\", TimeUtil::ToString(end - begin));\n  EXPECT_EQ(999999999, (end - begin).nanos());\n  EXPECT_EQ(\"-315537897599.999999999s\", TimeUtil::ToString(begin - end));\n  EXPECT_EQ(-999999999, (begin - end).nanos());\n\n  // Generated output should contain 3, 6, or 9 fractional digits.\n  EXPECT_EQ(\"1s\", TimeUtil::ToString(TimeUtil::SecondsToDuration(1)));\n  EXPECT_EQ(\"0.010s\", TimeUtil::ToString(TimeUtil::MillisecondsToDuration(10)));\n  EXPECT_EQ(\"0.000010s\",\n            TimeUtil::ToString(TimeUtil::MicrosecondsToDuration(10)));\n  EXPECT_EQ(\"0.000000010s\",\n            TimeUtil::ToString(TimeUtil::NanosecondsToDuration(10)));\n\n  // Parsing accepts an fractional digits as long as they fit into nano\n  // precision.\n  Duration d;\n  EXPECT_TRUE(TimeUtil::FromString(\"0.1s\", &d));\n  EXPECT_EQ(100, TimeUtil::DurationToMilliseconds(d));\n  EXPECT_TRUE(TimeUtil::FromString(\"0.0001s\", &d));\n  EXPECT_EQ(100, TimeUtil::DurationToMicroseconds(d));\n  EXPECT_TRUE(TimeUtil::FromString(\"0.0000001s\", &d));\n  EXPECT_EQ(100, TimeUtil::DurationToNanoseconds(d));\n\n  // Duration must support range from -315,576,000,000s to +315576000000s\n  // which includes negative values.\n  EXPECT_TRUE(TimeUtil::FromString(\"315576000000.999999999s\", &d));\n  EXPECT_EQ(315576000000LL, d.seconds());\n  EXPECT_EQ(999999999, d.nanos());\n  EXPECT_TRUE(TimeUtil::FromString(\"-315576000000.999999999s\", &d));\n  EXPECT_EQ(-315576000000LL, d.seconds());\n  EXPECT_EQ(-999999999, d.nanos());\n}\n\nTEST(TimeUtilTest, GetEpoch) {\n  EXPECT_EQ(0, TimeUtil::TimestampToNanoseconds(TimeUtil::GetEpoch()));\n}\n\nTEST(TimeUtilTest, DurationIntegerConversion) {\n  EXPECT_EQ(\"0.000000001s\",\n            TimeUtil::ToString(TimeUtil::NanosecondsToDuration(1)));\n  EXPECT_EQ(\"-0.000000001s\",\n            TimeUtil::ToString(TimeUtil::NanosecondsToDuration(-1)));\n  EXPECT_EQ(\"0.000001s\",\n            TimeUtil::ToString(TimeUtil::MicrosecondsToDuration(1)));\n  EXPECT_EQ(\"-0.000001s\",\n            TimeUtil::ToString(TimeUtil::MicrosecondsToDuration(-1)));\n  EXPECT_EQ(\"0.001s\", TimeUtil::ToString(TimeUtil::MillisecondsToDuration(1)));\n  EXPECT_EQ(\"-0.001s\",\n            TimeUtil::ToString(TimeUtil::MillisecondsToDuration(-1)));\n  EXPECT_EQ(\"1s\", TimeUtil::ToString(TimeUtil::SecondsToDuration(1)));\n  EXPECT_EQ(\"-1s\", TimeUtil::ToString(TimeUtil::SecondsToDuration(-1)));\n  EXPECT_EQ(\"60s\", TimeUtil::ToString(TimeUtil::MinutesToDuration(1)));\n  EXPECT_EQ(\"-60s\", TimeUtil::ToString(TimeUtil::MinutesToDuration(-1)));\n  EXPECT_EQ(\"3600s\", TimeUtil::ToString(TimeUtil::HoursToDuration(1)));\n  EXPECT_EQ(\"-3600s\", TimeUtil::ToString(TimeUtil::HoursToDuration(-1)));\n\n  EXPECT_EQ(\n      1, TimeUtil::DurationToNanoseconds(TimeUtil::NanosecondsToDuration(1)));\n  EXPECT_EQ(\n      -1, TimeUtil::DurationToNanoseconds(TimeUtil::NanosecondsToDuration(-1)));\n  EXPECT_EQ(\n      1, TimeUtil::DurationToMicroseconds(TimeUtil::MicrosecondsToDuration(1)));\n  EXPECT_EQ(-1, TimeUtil::DurationToMicroseconds(\n                    TimeUtil::MicrosecondsToDuration(-1)));\n  EXPECT_EQ(\n      1, TimeUtil::DurationToMilliseconds(TimeUtil::MillisecondsToDuration(1)));\n  EXPECT_EQ(-1, TimeUtil::DurationToMilliseconds(\n                    TimeUtil::MillisecondsToDuration(-1)));\n  EXPECT_EQ(1, TimeUtil::DurationToSeconds(TimeUtil::SecondsToDuration(1)));\n  EXPECT_EQ(-1, TimeUtil::DurationToSeconds(TimeUtil::SecondsToDuration(-1)));\n  EXPECT_EQ(1, TimeUtil::DurationToMinutes(TimeUtil::MinutesToDuration(1)));\n  EXPECT_EQ(-1, TimeUtil::DurationToMinutes(TimeUtil::MinutesToDuration(-1)));\n  EXPECT_EQ(1, TimeUtil::DurationToHours(TimeUtil::HoursToDuration(1)));\n  EXPECT_EQ(-1, TimeUtil::DurationToHours(TimeUtil::HoursToDuration(-1)));\n\n  // Test truncation behavior.\n  EXPECT_EQ(1, TimeUtil::DurationToMicroseconds(\n                   TimeUtil::NanosecondsToDuration(1999)));\n  // For negative values, Duration will be rounded towards 0.\n  EXPECT_EQ(-1, TimeUtil::DurationToMicroseconds(\n                    TimeUtil::NanosecondsToDuration(-1999)));\n}\n\nTEST(TestUtilTest, TimestampIntegerConversion) {\n  EXPECT_EQ(\"1970-01-01T00:00:00.000000001Z\",\n            TimeUtil::ToString(TimeUtil::NanosecondsToTimestamp(1)));\n  EXPECT_EQ(\"1969-12-31T23:59:59.999999999Z\",\n            TimeUtil::ToString(TimeUtil::NanosecondsToTimestamp(-1)));\n  EXPECT_EQ(\"1970-01-01T00:00:00.000001Z\",\n            TimeUtil::ToString(TimeUtil::MicrosecondsToTimestamp(1)));\n  EXPECT_EQ(\"1969-12-31T23:59:59.999999Z\",\n            TimeUtil::ToString(TimeUtil::MicrosecondsToTimestamp(-1)));\n  EXPECT_EQ(\"1970-01-01T00:00:00.001Z\",\n            TimeUtil::ToString(TimeUtil::MillisecondsToTimestamp(1)));\n  EXPECT_EQ(\"1969-12-31T23:59:59.999Z\",\n            TimeUtil::ToString(TimeUtil::MillisecondsToTimestamp(-1)));\n  EXPECT_EQ(\"1970-01-01T00:00:01Z\",\n            TimeUtil::ToString(TimeUtil::SecondsToTimestamp(1)));\n  EXPECT_EQ(\"1969-12-31T23:59:59Z\",\n            TimeUtil::ToString(TimeUtil::SecondsToTimestamp(-1)));\n\n  EXPECT_EQ(\n      1, TimeUtil::TimestampToNanoseconds(TimeUtil::NanosecondsToTimestamp(1)));\n  EXPECT_EQ(-1, TimeUtil::TimestampToNanoseconds(\n                    TimeUtil::NanosecondsToTimestamp(-1)));\n  EXPECT_EQ(1, TimeUtil::TimestampToMicroseconds(\n                   TimeUtil::MicrosecondsToTimestamp(1)));\n  EXPECT_EQ(-1, TimeUtil::TimestampToMicroseconds(\n                    TimeUtil::MicrosecondsToTimestamp(-1)));\n  EXPECT_EQ(1, TimeUtil::TimestampToMilliseconds(\n                   TimeUtil::MillisecondsToTimestamp(1)));\n  EXPECT_EQ(-1, TimeUtil::TimestampToMilliseconds(\n                    TimeUtil::MillisecondsToTimestamp(-1)));\n  EXPECT_EQ(1, TimeUtil::TimestampToSeconds(TimeUtil::SecondsToTimestamp(1)));\n  EXPECT_EQ(-1, TimeUtil::TimestampToSeconds(TimeUtil::SecondsToTimestamp(-1)));\n\n  // Test truncation behavior.\n  EXPECT_EQ(1, TimeUtil::TimestampToMicroseconds(\n                   TimeUtil::NanosecondsToTimestamp(1999)));\n  // For negative values, Timestamp will be rounded down.\n  // For example, \"1969-12-31T23:59:59.5Z\" (i.e., -0.5s) rounded to seconds\n  // will be \"1969-12-31T23:59:59Z\" (i.e., -1s) rather than\n  // \"1970-01-01T00:00:00Z\" (i.e., 0s).\n  EXPECT_EQ(-2, TimeUtil::TimestampToMicroseconds(\n                    TimeUtil::NanosecondsToTimestamp(-1999)));\n}\n\nTEST(TimeUtilTest, TimeTConversion) {\n  time_t value = time(NULL);\n  EXPECT_EQ(value,\n            TimeUtil::TimestampToTimeT(TimeUtil::TimeTToTimestamp(value)));\n  EXPECT_EQ(\n      1, TimeUtil::TimestampToTimeT(TimeUtil::MillisecondsToTimestamp(1999)));\n}\n\nTEST(TimeUtilTest, TimevalConversion) {\n  timeval value = TimeUtil::TimestampToTimeval(\n      TimeUtil::NanosecondsToTimestamp(1999999999));\n  EXPECT_EQ(1, value.tv_sec);\n  EXPECT_EQ(999999, value.tv_usec);\n  value = TimeUtil::TimestampToTimeval(\n      TimeUtil::NanosecondsToTimestamp(-1999999999));\n  EXPECT_EQ(-2, value.tv_sec);\n  EXPECT_EQ(0, value.tv_usec);\n\n  value =\n      TimeUtil::DurationToTimeval(TimeUtil::NanosecondsToDuration(1999999999));\n  EXPECT_EQ(1, value.tv_sec);\n  EXPECT_EQ(999999, value.tv_usec);\n  value =\n      TimeUtil::DurationToTimeval(TimeUtil::NanosecondsToDuration(-1999999999));\n  EXPECT_EQ(-2, value.tv_sec);\n  EXPECT_EQ(1, value.tv_usec);\n}\n\nTEST(TimeUtilTest, DurationOperators) {\n  Duration one_second = TimeUtil::SecondsToDuration(1);\n  Duration one_nano = TimeUtil::NanosecondsToDuration(1);\n\n  // Test +/-\n  Duration a = one_second;\n  a += one_second;\n  a -= one_nano;\n  EXPECT_EQ(\"1.999999999s\", TimeUtil::ToString(a));\n  Duration b = -a;\n  EXPECT_EQ(\"-1.999999999s\", TimeUtil::ToString(b));\n  EXPECT_EQ(\"3.999999998s\", TimeUtil::ToString(a + a));\n  EXPECT_EQ(\"0s\", TimeUtil::ToString(a + b));\n  EXPECT_EQ(\"0s\", TimeUtil::ToString(b + a));\n  EXPECT_EQ(\"-3.999999998s\", TimeUtil::ToString(b + b));\n  EXPECT_EQ(\"3.999999998s\", TimeUtil::ToString(a - b));\n  EXPECT_EQ(\"0s\", TimeUtil::ToString(a - a));\n  EXPECT_EQ(\"0s\", TimeUtil::ToString(b - b));\n  EXPECT_EQ(\"-3.999999998s\", TimeUtil::ToString(b - a));\n\n  // Test *\n  EXPECT_EQ(a + a, a * 2);\n  EXPECT_EQ(b + b, a * (-2));\n  EXPECT_EQ(b + b, b * 2);\n  EXPECT_EQ(a + a, b * (-2));\n  EXPECT_EQ(\"0.999999999s\", TimeUtil::ToString(a * 0.5));\n  EXPECT_EQ(\"-0.999999999s\", TimeUtil::ToString(b * 0.5));\n  // Multiplication should not overflow if the result fits into the supported\n  // range of Duration (intermediate result may be larger than int64).\n  EXPECT_EQ(\"315575999684.424s\",\n            TimeUtil::ToString((one_second - one_nano) * 315576000000LL));\n  EXPECT_EQ(\"-315575999684.424s\",\n            TimeUtil::ToString((one_nano - one_second) * 315576000000LL));\n  EXPECT_EQ(\"-315575999684.424s\",\n            TimeUtil::ToString((one_second - one_nano) * (-315576000000LL)));\n\n  // Test / and %\n  EXPECT_EQ(\"0.999999999s\", TimeUtil::ToString(a / 2));\n  EXPECT_EQ(\"-0.999999999s\", TimeUtil::ToString(b / 2));\n  Duration large = TimeUtil::SecondsToDuration(315576000000LL) - one_nano;\n  // We have to handle division with values beyond 64 bits.\n  EXPECT_EQ(\"0.999999999s\", TimeUtil::ToString(large / 315576000000LL));\n  EXPECT_EQ(\"-0.999999999s\", TimeUtil::ToString((-large) / 315576000000LL));\n  EXPECT_EQ(\"-0.999999999s\", TimeUtil::ToString(large / (-315576000000LL)));\n  Duration large2 = large + one_nano;\n  EXPECT_EQ(large, large % large2);\n  EXPECT_EQ(-large, (-large) % large2);\n  EXPECT_EQ(large, large % (-large2));\n  EXPECT_EQ(one_nano, large2 % large);\n  EXPECT_EQ(-one_nano, (-large2) % large);\n  EXPECT_EQ(one_nano, large2 % (-large));\n  // Some corner cases about negative values.\n  //\n  // (-5) / 2 = -2, remainder = -1\n  // (-5) / (-2) = 2, remainder = -1\n  a = TimeUtil::NanosecondsToDuration(-5);\n  EXPECT_EQ(TimeUtil::NanosecondsToDuration(-2), a / 2);\n  EXPECT_EQ(TimeUtil::NanosecondsToDuration(2), a / (-2));\n  b = TimeUtil::NanosecondsToDuration(2);\n  EXPECT_EQ(-2, a / b);\n  EXPECT_EQ(TimeUtil::NanosecondsToDuration(-1), a % b);\n  EXPECT_EQ(2, a / (-b));\n  EXPECT_EQ(TimeUtil::NanosecondsToDuration(-1), a % (-b));\n\n  // Test relational operators.\n  EXPECT_TRUE(one_nano < one_second);\n  EXPECT_FALSE(one_second < one_second);\n  EXPECT_FALSE(one_second < one_nano);\n  EXPECT_FALSE(-one_nano < -one_second);\n  EXPECT_FALSE(-one_second < -one_second);\n  EXPECT_TRUE(-one_second < -one_nano);\n  EXPECT_TRUE(-one_nano < one_nano);\n  EXPECT_FALSE(one_nano < -one_nano);\n\n  EXPECT_FALSE(one_nano > one_second);\n  EXPECT_FALSE(one_nano > one_nano);\n  EXPECT_TRUE(one_second > one_nano);\n\n  EXPECT_FALSE(one_nano >= one_second);\n  EXPECT_TRUE(one_nano >= one_nano);\n  EXPECT_TRUE(one_second >= one_nano);\n\n  EXPECT_TRUE(one_nano <= one_second);\n  EXPECT_TRUE(one_nano <= one_nano);\n  EXPECT_FALSE(one_second <= one_nano);\n\n  EXPECT_TRUE(one_nano == one_nano);\n  EXPECT_FALSE(one_nano == one_second);\n\n  EXPECT_FALSE(one_nano != one_nano);\n  EXPECT_TRUE(one_nano != one_second);\n}\n\nTEST(TimeUtilTest, TimestampOperators) {\n  Timestamp begin, end;\n  EXPECT_TRUE(TimeUtil::FromString(\"0001-01-01T00:00:00Z\", &begin));\n  EXPECT_TRUE(TimeUtil::FromString(\"9999-12-31T23:59:59.999999999Z\", &end));\n  Duration d = end - begin;\n  EXPECT_TRUE(end == begin + d);\n  EXPECT_TRUE(end == d + begin);\n  EXPECT_TRUE(begin == end - d);\n\n  // Test relational operators\n  Timestamp t1 = begin + d / 4;\n  Timestamp t2 = end - d / 4;\n  EXPECT_TRUE(t1 < t2);\n  EXPECT_FALSE(t1 < t1);\n  EXPECT_FALSE(t2 < t1);\n  EXPECT_FALSE(t1 > t2);\n  EXPECT_FALSE(t1 > t1);\n  EXPECT_TRUE(t2 > t1);\n  EXPECT_FALSE(t1 >= t2);\n  EXPECT_TRUE(t1 >= t1);\n  EXPECT_TRUE(t2 >= t1);\n  EXPECT_TRUE(t1 <= t2);\n  EXPECT_TRUE(t1 <= t1);\n  EXPECT_FALSE(t2 <= t1);\n\n  EXPECT_FALSE(t1 == t2);\n  EXPECT_TRUE(t1 == t1);\n  EXPECT_FALSE(t2 == t1);\n  EXPECT_TRUE(t1 != t2);\n  EXPECT_FALSE(t1 != t1);\n  EXPECT_TRUE(t2 != t1);\n}\n\n}  // namespace\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/type_resolver.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_H__\n#define GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_H__\n\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/status.h>\n\n\nnamespace google {\nnamespace protobuf {\nclass Type;\nclass Enum;\n}  // namespace protobuf\n\n\nnamespace protobuf {\nclass DescriptorPool;\nnamespace util {\n\n// Abstract interface for a type resovler.\n//\n// Implementations of this interface must be thread-safe.\nclass LIBPROTOBUF_EXPORT TypeResolver {\n public:\n  TypeResolver() {}\n  virtual ~TypeResolver() {}\n\n  // Resolves a type url for a message type.\n  virtual util::Status ResolveMessageType(\n      const string& type_url, google::protobuf::Type* message_type) = 0;\n\n  // Resolves a type url for an enum type.\n  virtual util::Status ResolveEnumType(const string& type_url,\n                                         google::protobuf::Enum* enum_type) = 0;\n\n private:\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(TypeResolver);\n};\n\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/type_resolver_util.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/type_resolver_util.h>\n\n#include <google/protobuf/type.pb.h>\n#include <google/protobuf/wrappers.pb.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/util/internal/utility.h>\n#include <google/protobuf/util/type_resolver.h>\n#include <google/protobuf/stubs/strutil.h>\n#include <google/protobuf/stubs/status.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace {\nusing google::protobuf::BoolValue;\nusing google::protobuf::Enum;\nusing google::protobuf::EnumValue;\nusing google::protobuf::Field;\nusing google::protobuf::Option;\nusing google::protobuf::Type;\n\nusing util::Status;\nusing util::error::INVALID_ARGUMENT;\nusing util::error::NOT_FOUND;\n\nbool SplitTypeUrl(const string& type_url, string* url_prefix,\n                  string* message_name) {\n  size_t pos = type_url.find_last_of(\"/\");\n  if (pos == string::npos) {\n    return false;\n  }\n  *url_prefix = type_url.substr(0, pos);\n  *message_name = type_url.substr(pos + 1);\n  return true;\n}\n\nclass DescriptorPoolTypeResolver : public TypeResolver {\n public:\n  DescriptorPoolTypeResolver(const string& url_prefix,\n                             const DescriptorPool* pool)\n      : url_prefix_(url_prefix), pool_(pool) {}\n\n  Status ResolveMessageType(const string& type_url, Type* type) {\n    string url_prefix, message_name;\n    if (!SplitTypeUrl(type_url, &url_prefix, &message_name) ||\n        url_prefix != url_prefix_) {\n      return Status(INVALID_ARGUMENT,\n                    StrCat(\"Invalid type URL, type URLs must be of the form '\",\n                           url_prefix_, \"/<typename>', got: \", type_url));\n    }\n    if (url_prefix != url_prefix_) {\n      return Status(INVALID_ARGUMENT,\n                    \"Cannot resolve types from URL: \" + url_prefix);\n    }\n    const Descriptor* descriptor = pool_->FindMessageTypeByName(message_name);\n    if (descriptor == NULL) {\n      return Status(NOT_FOUND,\n                    \"Invalid type URL, unknown type: \" + message_name);\n    }\n    ConvertDescriptor(descriptor, type);\n    return Status();\n  }\n\n  Status ResolveEnumType(const string& type_url, Enum* enum_type) {\n    string url_prefix, type_name;\n    if (!SplitTypeUrl(type_url, &url_prefix, &type_name) ||\n        url_prefix != url_prefix_) {\n      return Status(INVALID_ARGUMENT,\n                    StrCat(\"Invalid type URL, type URLs must be of the form '\",\n                           url_prefix_, \"/<typename>', got: \", type_url));\n    }\n    if (url_prefix != url_prefix_) {\n      return Status(INVALID_ARGUMENT,\n                    \"Cannot resolve types from URL: \" + url_prefix);\n    }\n    const EnumDescriptor* descriptor = pool_->FindEnumTypeByName(type_name);\n    if (descriptor == NULL) {\n      return Status(NOT_FOUND, \"Invalid type URL, unknown type: \" + type_name);\n    }\n    ConvertEnumDescriptor(descriptor, enum_type);\n    return Status();\n  }\n\n private:\n  void ConvertDescriptor(const Descriptor* descriptor, Type* type) {\n    type->Clear();\n    type->set_name(descriptor->full_name());\n    for (int i = 0; i < descriptor->field_count(); ++i) {\n      const FieldDescriptor* field = descriptor->field(i);\n      if (field->type() == FieldDescriptor::TYPE_GROUP) {\n        // Group fields cannot be represented with Type. We discard them.\n        continue;\n      }\n      ConvertFieldDescriptor(descriptor->field(i), type->add_fields());\n    }\n    for (int i = 0; i < descriptor->oneof_decl_count(); ++i) {\n      type->add_oneofs(descriptor->oneof_decl(i)->name());\n    }\n    type->mutable_source_context()->set_file_name(descriptor->file()->name());\n    ConvertMessageOptions(descriptor->options(), type->mutable_options());\n  }\n\n  void ConvertMessageOptions(const MessageOptions& options,\n                             RepeatedPtrField<Option>* output) {\n    if (options.map_entry()) {\n      Option* option = output->Add();\n      option->set_name(\"map_entry\");\n      BoolValue value;\n      value.set_value(true);\n      option->mutable_value()->PackFrom(value);\n    }\n\n    // TODO(xiaofeng): Set other \"options\"?\n  }\n\n  void ConvertFieldDescriptor(const FieldDescriptor* descriptor, Field* field) {\n    field->set_kind(static_cast<Field::Kind>(descriptor->type()));\n    switch (descriptor->label()) {\n      case FieldDescriptor::LABEL_OPTIONAL:\n        field->set_cardinality(Field::CARDINALITY_OPTIONAL);\n        break;\n      case FieldDescriptor::LABEL_REPEATED:\n        field->set_cardinality(Field::CARDINALITY_REPEATED);\n        break;\n      case FieldDescriptor::LABEL_REQUIRED:\n        field->set_cardinality(Field::CARDINALITY_REQUIRED);\n        break;\n    }\n    field->set_number(descriptor->number());\n    field->set_name(descriptor->name());\n    field->set_json_name(descriptor->json_name());\n    if (descriptor->has_default_value()) {\n      field->set_default_value(DefaultValueAsString(descriptor));\n    }\n    if (descriptor->type() == FieldDescriptor::TYPE_MESSAGE) {\n      field->set_type_url(GetTypeUrl(descriptor->message_type()));\n    } else if (descriptor->type() == FieldDescriptor::TYPE_ENUM) {\n      field->set_type_url(GetTypeUrl(descriptor->enum_type()));\n    }\n    if (descriptor->containing_oneof() != NULL) {\n      field->set_oneof_index(descriptor->containing_oneof()->index() + 1);\n    }\n    if (descriptor->is_packed()) {\n      field->set_packed(true);\n    }\n\n    // TODO(xiaofeng): Set other field \"options\"?\n  }\n\n  void ConvertEnumDescriptor(const EnumDescriptor* descriptor,\n                             Enum* enum_type) {\n    enum_type->Clear();\n    enum_type->set_name(descriptor->full_name());\n    enum_type->mutable_source_context()->set_file_name(\n        descriptor->file()->name());\n    for (int i = 0; i < descriptor->value_count(); ++i) {\n      const EnumValueDescriptor* value_descriptor = descriptor->value(i);\n      EnumValue* value = enum_type->mutable_enumvalue()->Add();\n      value->set_name(value_descriptor->name());\n      value->set_number(value_descriptor->number());\n\n      // TODO(xiaofeng): Set EnumValue options.\n    }\n    // TODO(xiaofeng): Set Enum \"options\".\n  }\n\n  string GetTypeUrl(const Descriptor* descriptor) {\n    return url_prefix_ + \"/\" + descriptor->full_name();\n  }\n\n  string GetTypeUrl(const EnumDescriptor* descriptor) {\n    return url_prefix_ + \"/\" + descriptor->full_name();\n  }\n\n  string DefaultValueAsString(const FieldDescriptor* descriptor) {\n    switch (descriptor->cpp_type()) {\n      case FieldDescriptor::CPPTYPE_INT32:\n        return SimpleItoa(descriptor->default_value_int32());\n        break;\n      case FieldDescriptor::CPPTYPE_INT64:\n        return SimpleItoa(descriptor->default_value_int64());\n        break;\n      case FieldDescriptor::CPPTYPE_UINT32:\n        return SimpleItoa(descriptor->default_value_uint32());\n        break;\n      case FieldDescriptor::CPPTYPE_UINT64:\n        return SimpleItoa(descriptor->default_value_uint64());\n        break;\n      case FieldDescriptor::CPPTYPE_FLOAT:\n        return SimpleFtoa(descriptor->default_value_float());\n        break;\n      case FieldDescriptor::CPPTYPE_DOUBLE:\n        return SimpleDtoa(descriptor->default_value_double());\n        break;\n      case FieldDescriptor::CPPTYPE_BOOL:\n        return descriptor->default_value_bool() ? \"true\" : \"false\";\n        break;\n      case FieldDescriptor::CPPTYPE_STRING:\n        if (descriptor->type() == FieldDescriptor::TYPE_BYTES) {\n          return CEscape(descriptor->default_value_string());\n        } else {\n          return descriptor->default_value_string();\n        }\n        break;\n      case FieldDescriptor::CPPTYPE_ENUM:\n        return descriptor->default_value_enum()->name();\n        break;\n      case FieldDescriptor::CPPTYPE_MESSAGE:\n        GOOGLE_LOG(DFATAL) << \"Messages can't have default values!\";\n        break;\n    }\n    return \"\";\n  }\n\n  string url_prefix_;\n  const DescriptorPool* pool_;\n};\n\n}  // namespace\n\nTypeResolver* NewTypeResolverForDescriptorPool(const string& url_prefix,\n                                               const DescriptorPool* pool) {\n  return new DescriptorPoolTypeResolver(url_prefix, pool);\n}\n\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/type_resolver_util.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#ifndef GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_UTIL_H__\n#define GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_UTIL_H__\n\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\nnamespace google {\nnamespace protobuf {\nclass DescriptorPool;\nnamespace util {\nclass TypeResolver;\n\n// Creates a TypeResolver that serves type information in the given descriptor\n// pool. Caller takes ownership of the returned TypeResolver.\nLIBPROTOBUF_EXPORT TypeResolver* NewTypeResolverForDescriptorPool(\n    const string& url_prefix, const DescriptorPool* pool);\n\n}  // namespace util\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_UTIL_TYPE_RESOLVER_UTIL_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/util/type_resolver_util_test.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n#include <google/protobuf/util/type_resolver_util.h>\n\n#include <limits>\n#include <memory>\n#ifndef _SHARED_PTR_H\n#include <google/protobuf/stubs/shared_ptr.h>\n#endif\n#include <string>\n#include <vector>\n\n#include <google/protobuf/type.pb.h>\n#include <google/protobuf/wrappers.pb.h>\n#include <google/protobuf/map_unittest.pb.h>\n#include <google/protobuf/test_util.h>\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/util/json_format_proto3.pb.h>\n#include <google/protobuf/util/type_resolver.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace util {\nnamespace {\nusing google::protobuf::Type;\nusing google::protobuf::Enum;\nusing google::protobuf::Field;\nusing google::protobuf::Option;\nusing google::protobuf::BoolValue;\n\nstatic const char kUrlPrefix[] = \"type.googleapis.com\";\n\nclass DescriptorPoolTypeResolverTest : public testing::Test {\n public:\n  DescriptorPoolTypeResolverTest() {\n    resolver_.reset(NewTypeResolverForDescriptorPool(\n        kUrlPrefix, DescriptorPool::generated_pool()));\n  }\n\n  const Field* FindField(const Type& type, const string& name) {\n    for (int i = 0; i < type.fields_size(); ++i) {\n      const Field& field = type.fields(i);\n      if (field.name() == name) {\n        return &field;\n      }\n    }\n    return NULL;\n  }\n\n  bool HasField(const Type& type, const string& name) {\n    return FindField(type, name) != NULL;\n  }\n\n  bool HasField(const Type& type, Field::Cardinality cardinality,\n                Field::Kind kind, const string& name, int number) {\n    const Field* field = FindField(type, name);\n    if (field == NULL) {\n      return false;\n    }\n    return field->cardinality() == cardinality &&\n        field->kind() == kind && field->number() == number;\n  }\n\n  bool CheckFieldTypeUrl(const Type& type, const string& name,\n                         const string& type_url) {\n    const Field* field = FindField(type, name);\n    if (field == NULL) {\n      return false;\n    }\n    return field->type_url() == type_url;\n  }\n\n  bool FieldInOneof(const Type& type, const string& name,\n                    const string& oneof_name) {\n    const Field* field = FindField(type, name);\n    if (field == NULL || field->oneof_index() <= 0 ||\n        field->oneof_index() > type.oneofs_size()) {\n      return false;\n    }\n    return type.oneofs(field->oneof_index() - 1) == oneof_name;\n  }\n\n  bool IsPacked(const Type& type, const string& name) {\n    const Field* field = FindField(type, name);\n    if (field == NULL) {\n      return false;\n    }\n    return field->packed();\n  }\n\n  bool EnumHasValue(const Enum& type, const string& name, int number) {\n    for (int i = 0; i < type.enumvalue_size(); ++i) {\n      if (type.enumvalue(i).name() == name &&\n          type.enumvalue(i).number() == number) {\n        return true;\n      }\n    }\n    return false;\n  }\n\n  bool HasBoolOption(const RepeatedPtrField<Option>& options,\n                     const string& name, bool value) {\n    for (int i = 0; i < options.size(); ++i) {\n      const Option& option = options.Get(i);\n      if (option.name() == name) {\n        BoolValue bool_value;\n        if (option.value().UnpackTo(&bool_value) &&\n            bool_value.value() == value) {\n          return true;\n        }\n      }\n    }\n    return false;\n  }\n\n  string GetTypeUrl(string full_name) {\n    return kUrlPrefix + string(\"/\") + full_name;\n  }\n\n  template<typename T>\n  string GetTypeUrl() {\n    return GetTypeUrl(T::descriptor()->full_name());\n  }\n\n protected:\n  google::protobuf::scoped_ptr<TypeResolver> resolver_;\n};\n\nTEST_F(DescriptorPoolTypeResolverTest, TestAllTypes) {\n  Type type;\n  ASSERT_TRUE(resolver_->ResolveMessageType(\n      GetTypeUrl<protobuf_unittest::TestAllTypes>(), &type).ok());\n  // Check all optional fields.\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_INT32, \"optional_int32\", 1));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_INT64, \"optional_int64\", 2));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_UINT32, \"optional_uint32\", 3));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_UINT64, \"optional_uint64\", 4));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_SINT32, \"optional_sint32\", 5));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_SINT64, \"optional_sint64\", 6));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_FIXED32, \"optional_fixed32\", 7));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_FIXED64, \"optional_fixed64\", 8));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_SFIXED32, \"optional_sfixed32\", 9));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_SFIXED64, \"optional_sfixed64\", 10));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_FLOAT, \"optional_float\", 11));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_DOUBLE, \"optional_double\", 12));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_BOOL, \"optional_bool\", 13));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_STRING, \"optional_string\", 14));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_BYTES, \"optional_bytes\", 15));\n\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_MESSAGE, \"optional_nested_message\", 18));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_MESSAGE, \"optional_foreign_message\", 19));\n\n  EXPECT_TRUE(CheckFieldTypeUrl(\n      type, \"optional_nested_message\",\n      GetTypeUrl<protobuf_unittest::TestAllTypes::NestedMessage>()));\n  EXPECT_TRUE(CheckFieldTypeUrl(\n      type, \"optional_foreign_message\",\n      GetTypeUrl<protobuf_unittest::ForeignMessage>()));\n\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_ENUM, \"optional_nested_enum\", 21));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_ENUM, \"optional_foreign_enum\", 22));\n\n  EXPECT_TRUE(CheckFieldTypeUrl(\n      type, \"optional_nested_enum\",\n      GetTypeUrl(\"protobuf_unittest.TestAllTypes.NestedEnum\")));\n  EXPECT_TRUE(CheckFieldTypeUrl(\n      type, \"optional_foreign_enum\",\n      GetTypeUrl(\"protobuf_unittest.ForeignEnum\")));\n\n  // Check all repeated fields.\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_REPEATED,\n                       Field::TYPE_INT32, \"repeated_int32\", 31));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_REPEATED,\n                       Field::TYPE_INT64, \"repeated_int64\", 32));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_REPEATED,\n                       Field::TYPE_UINT32, \"repeated_uint32\", 33));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_REPEATED,\n                       Field::TYPE_UINT64, \"repeated_uint64\", 34));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_REPEATED,\n                       Field::TYPE_SINT32, \"repeated_sint32\", 35));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_REPEATED,\n                       Field::TYPE_SINT64, \"repeated_sint64\", 36));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_REPEATED,\n                       Field::TYPE_FIXED32, \"repeated_fixed32\", 37));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_REPEATED,\n                       Field::TYPE_FIXED64, \"repeated_fixed64\", 38));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_REPEATED,\n                       Field::TYPE_SFIXED32, \"repeated_sfixed32\", 39));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_REPEATED,\n                       Field::TYPE_SFIXED64, \"repeated_sfixed64\", 40));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_REPEATED,\n                       Field::TYPE_FLOAT, \"repeated_float\", 41));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_REPEATED,\n                       Field::TYPE_DOUBLE, \"repeated_double\", 42));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_REPEATED,\n                       Field::TYPE_BOOL, \"repeated_bool\", 43));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_REPEATED,\n                       Field::TYPE_STRING, \"repeated_string\", 44));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_REPEATED,\n                       Field::TYPE_BYTES, \"repeated_bytes\", 45));\n\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_REPEATED,\n                       Field::TYPE_MESSAGE, \"repeated_nested_message\", 48));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_REPEATED,\n                       Field::TYPE_MESSAGE, \"repeated_foreign_message\", 49));\n\n  EXPECT_TRUE(CheckFieldTypeUrl(\n      type, \"repeated_nested_message\",\n      GetTypeUrl<protobuf_unittest::TestAllTypes::NestedMessage>()));\n  EXPECT_TRUE(CheckFieldTypeUrl(\n      type, \"repeated_foreign_message\",\n      GetTypeUrl<protobuf_unittest::ForeignMessage>()));\n\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_REPEATED,\n                       Field::TYPE_ENUM, \"repeated_nested_enum\", 51));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_REPEATED,\n                       Field::TYPE_ENUM, \"repeated_foreign_enum\", 52));\n\n  EXPECT_TRUE(CheckFieldTypeUrl(\n      type, \"repeated_nested_enum\",\n      GetTypeUrl(\"protobuf_unittest.TestAllTypes.NestedEnum\")));\n  EXPECT_TRUE(CheckFieldTypeUrl(\n      type, \"repeated_foreign_enum\",\n      GetTypeUrl(\"protobuf_unittest.ForeignEnum\")));\n\n  // Groups are discarded when converting to Type.\n  const Descriptor* descriptor = protobuf_unittest::TestAllTypes::descriptor();\n  EXPECT_TRUE(descriptor->FindFieldByName(\"optionalgroup\") != NULL);\n  EXPECT_TRUE(descriptor->FindFieldByName(\"repeatedgroup\") != NULL);\n  ASSERT_FALSE(HasField(type, \"optionalgroup\"));\n  ASSERT_FALSE(HasField(type, \"repeatedgroup\"));\n}\n\nTEST_F(DescriptorPoolTypeResolverTest, TestPackedField) {\n  Type type;\n  ASSERT_TRUE(resolver_->ResolveMessageType(\n      GetTypeUrl<protobuf_unittest::TestPackedTypes>(), &type).ok());\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_REPEATED,\n                       Field::TYPE_INT32, \"packed_int32\", 90));\n  EXPECT_TRUE(IsPacked(type, \"packed_int32\"));\n}\n\nTEST_F(DescriptorPoolTypeResolverTest, TestOneof) {\n  Type type;\n  ASSERT_TRUE(resolver_->ResolveMessageType(\n      GetTypeUrl<protobuf_unittest::TestAllTypes>(), &type).ok());\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_UINT32, \"oneof_uint32\", 111));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_MESSAGE, \"oneof_nested_message\", 112));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_STRING, \"oneof_string\", 113));\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_OPTIONAL,\n                       Field::TYPE_BYTES, \"oneof_bytes\", 114));\n  EXPECT_TRUE(FieldInOneof(type, \"oneof_uint32\", \"oneof_field\"));\n  EXPECT_TRUE(FieldInOneof(type, \"oneof_nested_message\", \"oneof_field\"));\n  EXPECT_TRUE(FieldInOneof(type, \"oneof_string\", \"oneof_field\"));\n  EXPECT_TRUE(FieldInOneof(type, \"oneof_bytes\", \"oneof_field\"));\n}\n\nTEST_F(DescriptorPoolTypeResolverTest, TestMap) {\n  Type type;\n  ASSERT_TRUE(resolver_->ResolveMessageType(\n      GetTypeUrl<protobuf_unittest::TestMap>(), &type).ok());\n  EXPECT_TRUE(HasField(type, Field::CARDINALITY_REPEATED,\n                       Field::TYPE_MESSAGE, \"map_int32_int32\", 1));\n  EXPECT_TRUE(CheckFieldTypeUrl(\n      type, \"map_int32_int32\",\n      GetTypeUrl(\"protobuf_unittest.TestMap.MapInt32Int32Entry\")));\n\n  ASSERT_TRUE(resolver_->ResolveMessageType(\n      GetTypeUrl(\"protobuf_unittest.TestMap.MapInt32Int32Entry\"),\n      &type).ok());\n  EXPECT_TRUE(HasBoolOption(type.options(), \"map_entry\", true));\n}\n\nTEST_F(DescriptorPoolTypeResolverTest, TestEnum) {\n  Enum type;\n  ASSERT_TRUE(resolver_->ResolveEnumType(\n      GetTypeUrl(\"protobuf_unittest.TestAllTypes.NestedEnum\"), &type).ok());\n  EnumHasValue(type, \"FOO\", 1);\n  EnumHasValue(type, \"BAR\", 2);\n  EnumHasValue(type, \"BAZ\", 3);\n  EnumHasValue(type, \"NEG\", -1);\n}\n\nTEST_F(DescriptorPoolTypeResolverTest, TestJsonName) {\n  Type type;\n  ASSERT_TRUE(resolver_->ResolveMessageType(\n                           GetTypeUrl<protobuf_unittest::TestAllTypes>(), &type)\n                  .ok());\n  EXPECT_EQ(\"optionalInt32\", FindField(type, \"optional_int32\")->json_name());\n\n  ASSERT_TRUE(resolver_->ResolveMessageType(\n                           GetTypeUrl<proto3::TestCustomJsonName>(), &type)\n                  .ok());\n  EXPECT_EQ(\"@value\", FindField(type, \"value\")->json_name());\n}\n\n}  // namespace\n}  // namespace util\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/well_known_types_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n#include <google/protobuf/unittest_well_known_types.pb.h>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n#include <google/protobuf/stubs/stl_util.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace {\n\n// This test only checks whether well-known types are included in protobuf\n// runtime library. The test passes if it compiles.\nTEST(WellKnownTypesTest, AllKnownTypesAreIncluded) {\n  protobuf_unittest::TestWellKnownTypes message;\n  EXPECT_EQ(0, message.any_field().ByteSize());\n  EXPECT_EQ(0, message.api_field().ByteSize());\n  EXPECT_EQ(0, message.duration_field().ByteSize());\n  EXPECT_EQ(0, message.empty_field().ByteSize());\n  EXPECT_EQ(0, message.field_mask_field().ByteSize());\n  EXPECT_EQ(0, message.source_context_field().ByteSize());\n  EXPECT_EQ(0, message.struct_field().ByteSize());\n  EXPECT_EQ(0, message.timestamp_field().ByteSize());\n  EXPECT_EQ(0, message.type_field().ByteSize());\n  EXPECT_EQ(0, message.int32_field().ByteSize());\n}\n\n}  // namespace\n\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/wire_format.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <stack>\n#include <string>\n#include <vector>\n\n#include <google/protobuf/wire_format.h>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/stringprintf.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/unknown_field_set.h>\n\n\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\n// ===================================================================\n\nbool UnknownFieldSetFieldSkipper::SkipField(\n    io::CodedInputStream* input, uint32 tag) {\n  return WireFormat::SkipField(input, tag, unknown_fields_);\n}\n\nbool UnknownFieldSetFieldSkipper::SkipMessage(io::CodedInputStream* input) {\n  return WireFormat::SkipMessage(input, unknown_fields_);\n}\n\nvoid UnknownFieldSetFieldSkipper::SkipUnknownEnum(\n    int field_number, int value) {\n  unknown_fields_->AddVarint(field_number, value);\n}\n\nbool WireFormat::SkipField(io::CodedInputStream* input, uint32 tag,\n                           UnknownFieldSet* unknown_fields) {\n  int number = WireFormatLite::GetTagFieldNumber(tag);\n\n  switch (WireFormatLite::GetTagWireType(tag)) {\n    case WireFormatLite::WIRETYPE_VARINT: {\n      uint64 value;\n      if (!input->ReadVarint64(&value)) return false;\n      if (unknown_fields != NULL) unknown_fields->AddVarint(number, value);\n      return true;\n    }\n    case WireFormatLite::WIRETYPE_FIXED64: {\n      uint64 value;\n      if (!input->ReadLittleEndian64(&value)) return false;\n      if (unknown_fields != NULL) unknown_fields->AddFixed64(number, value);\n      return true;\n    }\n    case WireFormatLite::WIRETYPE_LENGTH_DELIMITED: {\n      uint32 length;\n      if (!input->ReadVarint32(&length)) return false;\n      if (unknown_fields == NULL) {\n        if (!input->Skip(length)) return false;\n      } else {\n        if (!input->ReadString(unknown_fields->AddLengthDelimited(number),\n                               length)) {\n          return false;\n        }\n      }\n      return true;\n    }\n    case WireFormatLite::WIRETYPE_START_GROUP: {\n      if (!input->IncrementRecursionDepth()) return false;\n      if (!SkipMessage(input, (unknown_fields == NULL) ?\n                              NULL : unknown_fields->AddGroup(number))) {\n        return false;\n      }\n      input->DecrementRecursionDepth();\n      // Check that the ending tag matched the starting tag.\n      if (!input->LastTagWas(WireFormatLite::MakeTag(\n          WireFormatLite::GetTagFieldNumber(tag),\n          WireFormatLite::WIRETYPE_END_GROUP))) {\n        return false;\n      }\n      return true;\n    }\n    case WireFormatLite::WIRETYPE_END_GROUP: {\n      return false;\n    }\n    case WireFormatLite::WIRETYPE_FIXED32: {\n      uint32 value;\n      if (!input->ReadLittleEndian32(&value)) return false;\n      if (unknown_fields != NULL) unknown_fields->AddFixed32(number, value);\n      return true;\n    }\n    default: {\n      return false;\n    }\n  }\n}\n\nbool WireFormat::SkipMessage(io::CodedInputStream* input,\n                             UnknownFieldSet* unknown_fields) {\n  while (true) {\n    uint32 tag = input->ReadTag();\n    if (tag == 0) {\n      // End of input.  This is a valid place to end, so return true.\n      return true;\n    }\n\n    WireFormatLite::WireType wire_type = WireFormatLite::GetTagWireType(tag);\n\n    if (wire_type == WireFormatLite::WIRETYPE_END_GROUP) {\n      // Must be the end of the message.\n      return true;\n    }\n\n    if (!SkipField(input, tag, unknown_fields)) return false;\n  }\n}\n\nbool WireFormat::ReadPackedEnumPreserveUnknowns(io::CodedInputStream* input,\n                                                uint32 field_number,\n                                                bool (*is_valid)(int),\n                                                UnknownFieldSet* unknown_fields,\n                                                RepeatedField<int>* values) {\n  uint32 length;\n  if (!input->ReadVarint32(&length)) return false;\n  io::CodedInputStream::Limit limit = input->PushLimit(length);\n  while (input->BytesUntilLimit() > 0) {\n    int value;\n    if (!google::protobuf::internal::WireFormatLite::ReadPrimitive<\n        int, WireFormatLite::TYPE_ENUM>(input, &value)) {\n      return false;\n    }\n    if (is_valid == NULL || is_valid(value)) {\n      values->Add(value);\n    } else {\n      unknown_fields->AddVarint(field_number, value);\n    }\n  }\n  input->PopLimit(limit);\n  return true;\n}\n\n\nvoid WireFormat::SerializeUnknownFields(const UnknownFieldSet& unknown_fields,\n                                        io::CodedOutputStream* output) {\n  for (int i = 0; i < unknown_fields.field_count(); i++) {\n    const UnknownField& field = unknown_fields.field(i);\n    switch (field.type()) {\n      case UnknownField::TYPE_VARINT:\n        output->WriteVarint32(WireFormatLite::MakeTag(field.number(),\n            WireFormatLite::WIRETYPE_VARINT));\n        output->WriteVarint64(field.varint());\n        break;\n      case UnknownField::TYPE_FIXED32:\n        output->WriteVarint32(WireFormatLite::MakeTag(field.number(),\n            WireFormatLite::WIRETYPE_FIXED32));\n        output->WriteLittleEndian32(field.fixed32());\n        break;\n      case UnknownField::TYPE_FIXED64:\n        output->WriteVarint32(WireFormatLite::MakeTag(field.number(),\n            WireFormatLite::WIRETYPE_FIXED64));\n        output->WriteLittleEndian64(field.fixed64());\n        break;\n      case UnknownField::TYPE_LENGTH_DELIMITED:\n        output->WriteVarint32(WireFormatLite::MakeTag(field.number(),\n            WireFormatLite::WIRETYPE_LENGTH_DELIMITED));\n        output->WriteVarint32(field.length_delimited().size());\n        output->WriteRawMaybeAliased(field.length_delimited().data(),\n                                     field.length_delimited().size());\n        break;\n      case UnknownField::TYPE_GROUP:\n        output->WriteVarint32(WireFormatLite::MakeTag(field.number(),\n            WireFormatLite::WIRETYPE_START_GROUP));\n        SerializeUnknownFields(field.group(), output);\n        output->WriteVarint32(WireFormatLite::MakeTag(field.number(),\n            WireFormatLite::WIRETYPE_END_GROUP));\n        break;\n    }\n  }\n}\n\nuint8* WireFormat::SerializeUnknownFieldsToArray(\n    const UnknownFieldSet& unknown_fields,\n    uint8* target) {\n  for (int i = 0; i < unknown_fields.field_count(); i++) {\n    const UnknownField& field = unknown_fields.field(i);\n\n    switch (field.type()) {\n      case UnknownField::TYPE_VARINT:\n        target = WireFormatLite::WriteInt64ToArray(\n            field.number(), field.varint(), target);\n        break;\n      case UnknownField::TYPE_FIXED32:\n        target = WireFormatLite::WriteFixed32ToArray(\n            field.number(), field.fixed32(), target);\n        break;\n      case UnknownField::TYPE_FIXED64:\n        target = WireFormatLite::WriteFixed64ToArray(\n            field.number(), field.fixed64(), target);\n        break;\n      case UnknownField::TYPE_LENGTH_DELIMITED:\n        target = WireFormatLite::WriteBytesToArray(\n            field.number(), field.length_delimited(), target);\n        break;\n      case UnknownField::TYPE_GROUP:\n        target = WireFormatLite::WriteTagToArray(\n            field.number(), WireFormatLite::WIRETYPE_START_GROUP, target);\n        target = SerializeUnknownFieldsToArray(field.group(), target);\n        target = WireFormatLite::WriteTagToArray(\n            field.number(), WireFormatLite::WIRETYPE_END_GROUP, target);\n        break;\n    }\n  }\n  return target;\n}\n\nvoid WireFormat::SerializeUnknownMessageSetItems(\n    const UnknownFieldSet& unknown_fields,\n    io::CodedOutputStream* output) {\n  for (int i = 0; i < unknown_fields.field_count(); i++) {\n    const UnknownField& field = unknown_fields.field(i);\n    // The only unknown fields that are allowed to exist in a MessageSet are\n    // messages, which are length-delimited.\n    if (field.type() == UnknownField::TYPE_LENGTH_DELIMITED) {\n      // Start group.\n      output->WriteVarint32(WireFormatLite::kMessageSetItemStartTag);\n\n      // Write type ID.\n      output->WriteVarint32(WireFormatLite::kMessageSetTypeIdTag);\n      output->WriteVarint32(field.number());\n\n      // Write message.\n      output->WriteVarint32(WireFormatLite::kMessageSetMessageTag);\n      field.SerializeLengthDelimitedNoTag(output);\n\n      // End group.\n      output->WriteVarint32(WireFormatLite::kMessageSetItemEndTag);\n    }\n  }\n}\n\nuint8* WireFormat::SerializeUnknownMessageSetItemsToArray(\n    const UnknownFieldSet& unknown_fields,\n    uint8* target) {\n  for (int i = 0; i < unknown_fields.field_count(); i++) {\n    const UnknownField& field = unknown_fields.field(i);\n\n    // The only unknown fields that are allowed to exist in a MessageSet are\n    // messages, which are length-delimited.\n    if (field.type() == UnknownField::TYPE_LENGTH_DELIMITED) {\n      // Start group.\n      target = io::CodedOutputStream::WriteTagToArray(\n          WireFormatLite::kMessageSetItemStartTag, target);\n\n      // Write type ID.\n      target = io::CodedOutputStream::WriteTagToArray(\n          WireFormatLite::kMessageSetTypeIdTag, target);\n      target = io::CodedOutputStream::WriteVarint32ToArray(\n          field.number(), target);\n\n      // Write message.\n      target = io::CodedOutputStream::WriteTagToArray(\n          WireFormatLite::kMessageSetMessageTag, target);\n      target = field.SerializeLengthDelimitedNoTagToArray(target);\n\n      // End group.\n      target = io::CodedOutputStream::WriteTagToArray(\n          WireFormatLite::kMessageSetItemEndTag, target);\n    }\n  }\n\n  return target;\n}\n\nint WireFormat::ComputeUnknownFieldsSize(\n    const UnknownFieldSet& unknown_fields) {\n  int size = 0;\n  for (int i = 0; i < unknown_fields.field_count(); i++) {\n    const UnknownField& field = unknown_fields.field(i);\n\n    switch (field.type()) {\n      case UnknownField::TYPE_VARINT:\n        size += io::CodedOutputStream::VarintSize32(\n            WireFormatLite::MakeTag(field.number(),\n            WireFormatLite::WIRETYPE_VARINT));\n        size += io::CodedOutputStream::VarintSize64(field.varint());\n        break;\n      case UnknownField::TYPE_FIXED32:\n        size += io::CodedOutputStream::VarintSize32(\n            WireFormatLite::MakeTag(field.number(),\n            WireFormatLite::WIRETYPE_FIXED32));\n        size += sizeof(int32);\n        break;\n      case UnknownField::TYPE_FIXED64:\n        size += io::CodedOutputStream::VarintSize32(\n            WireFormatLite::MakeTag(field.number(),\n            WireFormatLite::WIRETYPE_FIXED64));\n        size += sizeof(int64);\n        break;\n      case UnknownField::TYPE_LENGTH_DELIMITED:\n        size += io::CodedOutputStream::VarintSize32(\n            WireFormatLite::MakeTag(field.number(),\n            WireFormatLite::WIRETYPE_LENGTH_DELIMITED));\n        size += io::CodedOutputStream::VarintSize32(\n            field.length_delimited().size());\n        size += field.length_delimited().size();\n        break;\n      case UnknownField::TYPE_GROUP:\n        size += io::CodedOutputStream::VarintSize32(\n            WireFormatLite::MakeTag(field.number(),\n            WireFormatLite::WIRETYPE_START_GROUP));\n        size += ComputeUnknownFieldsSize(field.group());\n        size += io::CodedOutputStream::VarintSize32(\n            WireFormatLite::MakeTag(field.number(),\n            WireFormatLite::WIRETYPE_END_GROUP));\n        break;\n    }\n  }\n\n  return size;\n}\n\nint WireFormat::ComputeUnknownMessageSetItemsSize(\n    const UnknownFieldSet& unknown_fields) {\n  int size = 0;\n  for (int i = 0; i < unknown_fields.field_count(); i++) {\n    const UnknownField& field = unknown_fields.field(i);\n\n    // The only unknown fields that are allowed to exist in a MessageSet are\n    // messages, which are length-delimited.\n    if (field.type() == UnknownField::TYPE_LENGTH_DELIMITED) {\n      size += WireFormatLite::kMessageSetItemTagsSize;\n      size += io::CodedOutputStream::VarintSize32(field.number());\n\n      int field_size = field.GetLengthDelimitedSize();\n      size += io::CodedOutputStream::VarintSize32(field_size);\n      size += field_size;\n    }\n  }\n\n  return size;\n}\n\n// ===================================================================\n\nbool WireFormat::ParseAndMergePartial(io::CodedInputStream* input,\n                                      Message* message) {\n  const Descriptor* descriptor = message->GetDescriptor();\n  const Reflection* message_reflection = message->GetReflection();\n\n  while(true) {\n    uint32 tag = input->ReadTag();\n    if (tag == 0) {\n      // End of input.  This is a valid place to end, so return true.\n      return true;\n    }\n\n    if (WireFormatLite::GetTagWireType(tag) ==\n        WireFormatLite::WIRETYPE_END_GROUP) {\n      // Must be the end of the message.\n      return true;\n    }\n\n    const FieldDescriptor* field = NULL;\n\n    if (descriptor != NULL) {\n      int field_number = WireFormatLite::GetTagFieldNumber(tag);\n      field = descriptor->FindFieldByNumber(field_number);\n\n      // If that failed, check if the field is an extension.\n      if (field == NULL && descriptor->IsExtensionNumber(field_number)) {\n        if (input->GetExtensionPool() == NULL) {\n          field = message_reflection->FindKnownExtensionByNumber(field_number);\n        } else {\n          field = input->GetExtensionPool()\n                       ->FindExtensionByNumber(descriptor, field_number);\n        }\n      }\n\n      // If that failed, but we're a MessageSet, and this is the tag for a\n      // MessageSet item, then parse that.\n      if (field == NULL &&\n          descriptor->options().message_set_wire_format() &&\n          tag == WireFormatLite::kMessageSetItemStartTag) {\n        if (!ParseAndMergeMessageSetItem(input, message)) {\n          return false;\n        }\n        continue;  // Skip ParseAndMergeField(); already taken care of.\n      }\n    }\n\n    if (!ParseAndMergeField(tag, field, message, input)) {\n      return false;\n    }\n  }\n}\n\nbool WireFormat::SkipMessageSetField(io::CodedInputStream* input,\n                                     uint32 field_number,\n                                     UnknownFieldSet* unknown_fields) {\n  uint32 length;\n  if (!input->ReadVarint32(&length)) return false;\n  return input->ReadString(\n      unknown_fields->AddLengthDelimited(field_number), length);\n}\n\nbool WireFormat::ParseAndMergeMessageSetField(uint32 field_number,\n                                              const FieldDescriptor* field,\n                                              Message* message,\n                                              io::CodedInputStream* input) {\n  const Reflection* message_reflection = message->GetReflection();\n  if (field == NULL) {\n    // We store unknown MessageSet extensions as groups.\n    return SkipMessageSetField(\n        input, field_number, message_reflection->MutableUnknownFields(message));\n  } else if (field->is_repeated() ||\n             field->type() != FieldDescriptor::TYPE_MESSAGE) {\n    // This shouldn't happen as we only allow optional message extensions to\n    // MessageSet.\n    GOOGLE_LOG(ERROR) << \"Extensions of MessageSets must be optional messages.\";\n    return false;\n  } else {\n    Message* sub_message = message_reflection->MutableMessage(\n        message, field, input->GetExtensionFactory());\n    return WireFormatLite::ReadMessage(input, sub_message);\n  }\n}\n\nstatic bool StrictUtf8Check(const FieldDescriptor* field) {\n  return field->file()->syntax() == FileDescriptor::SYNTAX_PROTO3;\n}\n\nbool WireFormat::ParseAndMergeField(\n    uint32 tag,\n    const FieldDescriptor* field,        // May be NULL for unknown\n    Message* message,\n    io::CodedInputStream* input) {\n  const Reflection* message_reflection = message->GetReflection();\n\n  enum { UNKNOWN, NORMAL_FORMAT, PACKED_FORMAT } value_format;\n\n  if (field == NULL) {\n    value_format = UNKNOWN;\n  } else if (WireFormatLite::GetTagWireType(tag) ==\n             WireTypeForFieldType(field->type())) {\n    value_format = NORMAL_FORMAT;\n  } else if (field->is_packable() &&\n             WireFormatLite::GetTagWireType(tag) ==\n             WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {\n    value_format = PACKED_FORMAT;\n  } else {\n    // We don't recognize this field. Either the field number is unknown\n    // or the wire type doesn't match. Put it in our unknown field set.\n    value_format = UNKNOWN;\n  }\n\n  if (value_format == UNKNOWN) {\n    return SkipField(input, tag,\n                     message_reflection->MutableUnknownFields(message));\n  } else if (value_format == PACKED_FORMAT) {\n    uint32 length;\n    if (!input->ReadVarint32(&length)) return false;\n    io::CodedInputStream::Limit limit = input->PushLimit(length);\n\n    switch (field->type()) {\n#define HANDLE_PACKED_TYPE(TYPE, CPPTYPE, CPPTYPE_METHOD)                      \\\n      case FieldDescriptor::TYPE_##TYPE: {                                     \\\n        while (input->BytesUntilLimit() > 0) {                                 \\\n          CPPTYPE value;                                                       \\\n          if (!WireFormatLite::ReadPrimitive<                                  \\\n                CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, &value))          \\\n            return false;                                                      \\\n          message_reflection->Add##CPPTYPE_METHOD(message, field, value);      \\\n        }                                                                      \\\n        break;                                                                 \\\n      }\n\n      HANDLE_PACKED_TYPE( INT32,  int32,  Int32)\n      HANDLE_PACKED_TYPE( INT64,  int64,  Int64)\n      HANDLE_PACKED_TYPE(SINT32,  int32,  Int32)\n      HANDLE_PACKED_TYPE(SINT64,  int64,  Int64)\n      HANDLE_PACKED_TYPE(UINT32, uint32, UInt32)\n      HANDLE_PACKED_TYPE(UINT64, uint64, UInt64)\n\n      HANDLE_PACKED_TYPE( FIXED32, uint32, UInt32)\n      HANDLE_PACKED_TYPE( FIXED64, uint64, UInt64)\n      HANDLE_PACKED_TYPE(SFIXED32,  int32,  Int32)\n      HANDLE_PACKED_TYPE(SFIXED64,  int64,  Int64)\n\n      HANDLE_PACKED_TYPE(FLOAT , float , Float )\n      HANDLE_PACKED_TYPE(DOUBLE, double, Double)\n\n      HANDLE_PACKED_TYPE(BOOL, bool, Bool)\n#undef HANDLE_PACKED_TYPE\n\n      case FieldDescriptor::TYPE_ENUM: {\n        while (input->BytesUntilLimit() > 0) {\n          int value;\n          if (!WireFormatLite::ReadPrimitive<int, WireFormatLite::TYPE_ENUM>(\n                  input, &value)) return false;\n          if (message->GetDescriptor()->file()->syntax() ==\n              FileDescriptor::SYNTAX_PROTO3) {\n            message_reflection->AddEnumValue(message, field, value);\n          } else {\n            const EnumValueDescriptor* enum_value =\n                field->enum_type()->FindValueByNumber(value);\n            if (enum_value != NULL) {\n              message_reflection->AddEnum(message, field, enum_value);\n            } else {\n              // The enum value is not one of the known values.  Add it to the\n              // UnknownFieldSet.\n              int64 sign_extended_value = static_cast<int64>(value);\n              message_reflection->MutableUnknownFields(message)\n                  ->AddVarint(\n                      WireFormatLite::GetTagFieldNumber(tag),\n                      sign_extended_value);\n            }\n          }\n        }\n\n        break;\n      }\n\n      case FieldDescriptor::TYPE_STRING:\n      case FieldDescriptor::TYPE_GROUP:\n      case FieldDescriptor::TYPE_MESSAGE:\n      case FieldDescriptor::TYPE_BYTES:\n        // Can't have packed fields of these types: these should be caught by\n        // the protocol compiler.\n        return false;\n        break;\n    }\n\n    input->PopLimit(limit);\n  } else {\n    // Non-packed value (value_format == NORMAL_FORMAT)\n    switch (field->type()) {\n#define HANDLE_TYPE(TYPE, CPPTYPE, CPPTYPE_METHOD)                            \\\n      case FieldDescriptor::TYPE_##TYPE: {                                    \\\n        CPPTYPE value;                                                        \\\n        if (!WireFormatLite::ReadPrimitive<                                   \\\n                CPPTYPE, WireFormatLite::TYPE_##TYPE>(input, &value))         \\\n          return false;                                                       \\\n        if (field->is_repeated()) {                                           \\\n          message_reflection->Add##CPPTYPE_METHOD(message, field, value);     \\\n        } else {                                                              \\\n          message_reflection->Set##CPPTYPE_METHOD(message, field, value);     \\\n        }                                                                     \\\n        break;                                                                \\\n      }\n\n      HANDLE_TYPE( INT32,  int32,  Int32)\n      HANDLE_TYPE( INT64,  int64,  Int64)\n      HANDLE_TYPE(SINT32,  int32,  Int32)\n      HANDLE_TYPE(SINT64,  int64,  Int64)\n      HANDLE_TYPE(UINT32, uint32, UInt32)\n      HANDLE_TYPE(UINT64, uint64, UInt64)\n\n      HANDLE_TYPE( FIXED32, uint32, UInt32)\n      HANDLE_TYPE( FIXED64, uint64, UInt64)\n      HANDLE_TYPE(SFIXED32,  int32,  Int32)\n      HANDLE_TYPE(SFIXED64,  int64,  Int64)\n\n      HANDLE_TYPE(FLOAT , float , Float )\n      HANDLE_TYPE(DOUBLE, double, Double)\n\n      HANDLE_TYPE(BOOL, bool, Bool)\n#undef HANDLE_TYPE\n\n      case FieldDescriptor::TYPE_ENUM: {\n        int value;\n        if (!WireFormatLite::ReadPrimitive<int, WireFormatLite::TYPE_ENUM>(\n                input, &value)) return false;\n        if (message->GetDescriptor()->file()->syntax() ==\n            FileDescriptor::SYNTAX_PROTO3) {\n          if (field->is_repeated()) {\n            message_reflection->AddEnumValue(message, field, value);\n          } else {\n            message_reflection->SetEnumValue(message, field, value);\n          }\n        } else {\n          const EnumValueDescriptor* enum_value =\n              field->enum_type()->FindValueByNumber(value);\n          if (enum_value != NULL) {\n            if (field->is_repeated()) {\n              message_reflection->AddEnum(message, field, enum_value);\n            } else {\n              message_reflection->SetEnum(message, field, enum_value);\n            }\n          } else {\n            // The enum value is not one of the known values.  Add it to the\n            // UnknownFieldSet.\n            int64 sign_extended_value = static_cast<int64>(value);\n            message_reflection->MutableUnknownFields(message)\n                              ->AddVarint(\n                                  WireFormatLite::GetTagFieldNumber(tag),\n                                  sign_extended_value);\n          }\n        }\n        break;\n      }\n\n      // Handle strings separately so that we can optimize the ctype=CORD case.\n      case FieldDescriptor::TYPE_STRING: {\n        bool strict_utf8_check = StrictUtf8Check(field);\n        string value;\n        if (!WireFormatLite::ReadString(input, &value)) return false;\n        if (strict_utf8_check) {\n          if (!WireFormatLite::VerifyUtf8String(\n                  value.data(), value.length(), WireFormatLite::PARSE,\n                  field->full_name().c_str())) {\n            return false;\n          }\n        } else {\n          VerifyUTF8StringNamedField(value.data(), value.length(), PARSE,\n                                     field->full_name().c_str());\n        }\n        if (field->is_repeated()) {\n          message_reflection->AddString(message, field, value);\n        } else {\n          message_reflection->SetString(message, field, value);\n        }\n        break;\n      }\n\n      case FieldDescriptor::TYPE_BYTES: {\n        string value;\n        if (!WireFormatLite::ReadBytes(input, &value)) return false;\n        if (field->is_repeated()) {\n          message_reflection->AddString(message, field, value);\n        } else {\n          message_reflection->SetString(message, field, value);\n        }\n        break;\n      }\n\n      case FieldDescriptor::TYPE_GROUP: {\n        Message* sub_message;\n        if (field->is_repeated()) {\n          sub_message = message_reflection->AddMessage(\n              message, field, input->GetExtensionFactory());\n        } else {\n          sub_message = message_reflection->MutableMessage(\n              message, field, input->GetExtensionFactory());\n        }\n\n        if (!WireFormatLite::ReadGroup(WireFormatLite::GetTagFieldNumber(tag),\n                                       input, sub_message))\n          return false;\n        break;\n      }\n\n      case FieldDescriptor::TYPE_MESSAGE: {\n        Message* sub_message;\n        if (field->is_repeated()) {\n          sub_message = message_reflection->AddMessage(\n              message, field, input->GetExtensionFactory());\n        } else {\n          sub_message = message_reflection->MutableMessage(\n              message, field, input->GetExtensionFactory());\n        }\n\n        if (!WireFormatLite::ReadMessage(input, sub_message)) return false;\n        break;\n      }\n    }\n  }\n\n  return true;\n}\n\nbool WireFormat::ParseAndMergeMessageSetItem(\n    io::CodedInputStream* input,\n    Message* message) {\n  const Reflection* message_reflection = message->GetReflection();\n\n  // This method parses a group which should contain two fields:\n  //   required int32 type_id = 2;\n  //   required data message = 3;\n\n  uint32 last_type_id = 0;\n\n  // Once we see a type_id, we'll look up the FieldDescriptor for the\n  // extension.\n  const FieldDescriptor* field = NULL;\n\n  // If we see message data before the type_id, we'll append it to this so\n  // we can parse it later.\n  string message_data;\n\n  while (true) {\n    uint32 tag = input->ReadTag();\n    if (tag == 0) return false;\n\n    switch (tag) {\n      case WireFormatLite::kMessageSetTypeIdTag: {\n        uint32 type_id;\n        if (!input->ReadVarint32(&type_id)) return false;\n        last_type_id = type_id;\n        field = message_reflection->FindKnownExtensionByNumber(type_id);\n\n        if (!message_data.empty()) {\n          // We saw some message data before the type_id.  Have to parse it\n          // now.\n          io::ArrayInputStream raw_input(message_data.data(),\n                                         message_data.size());\n          io::CodedInputStream sub_input(&raw_input);\n          if (!ParseAndMergeMessageSetField(last_type_id, field, message,\n                                            &sub_input)) {\n            return false;\n          }\n          message_data.clear();\n        }\n\n        break;\n      }\n\n      case WireFormatLite::kMessageSetMessageTag: {\n        if (last_type_id == 0) {\n          // We haven't seen a type_id yet.  Append this data to message_data.\n          string temp;\n          uint32 length;\n          if (!input->ReadVarint32(&length)) return false;\n          if (!input->ReadString(&temp, length)) return false;\n          io::StringOutputStream output_stream(&message_data);\n          io::CodedOutputStream coded_output(&output_stream);\n          coded_output.WriteVarint32(length);\n          coded_output.WriteString(temp);\n        } else {\n          // Already saw type_id, so we can parse this directly.\n          if (!ParseAndMergeMessageSetField(last_type_id, field, message,\n                                            input)) {\n            return false;\n          }\n        }\n\n        break;\n      }\n\n      case WireFormatLite::kMessageSetItemEndTag: {\n        return true;\n      }\n\n      default: {\n        if (!SkipField(input, tag, NULL)) return false;\n      }\n    }\n  }\n}\n\n// ===================================================================\n\nvoid WireFormat::SerializeWithCachedSizes(\n    const Message& message,\n    int size, io::CodedOutputStream* output) {\n  const Descriptor* descriptor = message.GetDescriptor();\n  const Reflection* message_reflection = message.GetReflection();\n  int expected_endpoint = output->ByteCount() + size;\n\n  vector<const FieldDescriptor*> fields;\n  message_reflection->ListFields(message, &fields);\n  for (int i = 0; i < fields.size(); i++) {\n    SerializeFieldWithCachedSizes(fields[i], message, output);\n  }\n\n  if (descriptor->options().message_set_wire_format()) {\n    SerializeUnknownMessageSetItems(\n        message_reflection->GetUnknownFields(message), output);\n  } else {\n    SerializeUnknownFields(\n        message_reflection->GetUnknownFields(message), output);\n  }\n\n  GOOGLE_CHECK_EQ(output->ByteCount(), expected_endpoint)\n    << \": Protocol message serialized to a size different from what was \"\n       \"originally expected.  Perhaps it was modified by another thread \"\n       \"during serialization?\";\n}\n\nvoid WireFormat::SerializeFieldWithCachedSizes(\n    const FieldDescriptor* field,\n    const Message& message,\n    io::CodedOutputStream* output) {\n  const Reflection* message_reflection = message.GetReflection();\n\n  if (field->is_extension() &&\n      field->containing_type()->options().message_set_wire_format() &&\n      field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&\n      !field->is_repeated()) {\n    SerializeMessageSetItemWithCachedSizes(field, message, output);\n    return;\n  }\n\n  int count = 0;\n\n  if (field->is_repeated()) {\n    count = message_reflection->FieldSize(message, field);\n  } else if (message_reflection->HasField(message, field)) {\n    count = 1;\n  }\n\n  const bool is_packed = field->is_packed();\n  if (is_packed && count > 0) {\n    WireFormatLite::WriteTag(field->number(),\n        WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);\n    const int data_size = FieldDataOnlyByteSize(field, message);\n    output->WriteVarint32(data_size);\n  }\n\n  for (int j = 0; j < count; j++) {\n    switch (field->type()) {\n#define HANDLE_PRIMITIVE_TYPE(TYPE, CPPTYPE, TYPE_METHOD, CPPTYPE_METHOD)      \\\n      case FieldDescriptor::TYPE_##TYPE: {                                     \\\n        const CPPTYPE value = field->is_repeated() ?                           \\\n                              message_reflection->GetRepeated##CPPTYPE_METHOD( \\\n                                message, field, j) :                           \\\n                              message_reflection->Get##CPPTYPE_METHOD(         \\\n                                message, field);                               \\\n        if (is_packed) {                                                       \\\n          WireFormatLite::Write##TYPE_METHOD##NoTag(value, output);            \\\n        } else {                                                               \\\n          WireFormatLite::Write##TYPE_METHOD(field->number(), value, output);  \\\n        }                                                                      \\\n        break;                                                                 \\\n      }\n\n      HANDLE_PRIMITIVE_TYPE( INT32,  int32,  Int32,  Int32)\n      HANDLE_PRIMITIVE_TYPE( INT64,  int64,  Int64,  Int64)\n      HANDLE_PRIMITIVE_TYPE(SINT32,  int32, SInt32,  Int32)\n      HANDLE_PRIMITIVE_TYPE(SINT64,  int64, SInt64,  Int64)\n      HANDLE_PRIMITIVE_TYPE(UINT32, uint32, UInt32, UInt32)\n      HANDLE_PRIMITIVE_TYPE(UINT64, uint64, UInt64, UInt64)\n\n      HANDLE_PRIMITIVE_TYPE( FIXED32, uint32,  Fixed32, UInt32)\n      HANDLE_PRIMITIVE_TYPE( FIXED64, uint64,  Fixed64, UInt64)\n      HANDLE_PRIMITIVE_TYPE(SFIXED32,  int32, SFixed32,  Int32)\n      HANDLE_PRIMITIVE_TYPE(SFIXED64,  int64, SFixed64,  Int64)\n\n      HANDLE_PRIMITIVE_TYPE(FLOAT , float , Float , Float )\n      HANDLE_PRIMITIVE_TYPE(DOUBLE, double, Double, Double)\n\n      HANDLE_PRIMITIVE_TYPE(BOOL, bool, Bool, Bool)\n#undef HANDLE_PRIMITIVE_TYPE\n\n#define HANDLE_TYPE(TYPE, TYPE_METHOD, CPPTYPE_METHOD)                       \\\n      case FieldDescriptor::TYPE_##TYPE:                                     \\\n        WireFormatLite::Write##TYPE_METHOD(                                  \\\n              field->number(),                                               \\\n              field->is_repeated() ?                                         \\\n                message_reflection->GetRepeated##CPPTYPE_METHOD(             \\\n                  message, field, j) :                                       \\\n                message_reflection->Get##CPPTYPE_METHOD(message, field),     \\\n              output);                                                       \\\n        break;\n\n      HANDLE_TYPE(GROUP  , Group  , Message)\n      HANDLE_TYPE(MESSAGE, Message, Message)\n#undef HANDLE_TYPE\n\n      case FieldDescriptor::TYPE_ENUM: {\n        const EnumValueDescriptor* value = field->is_repeated() ?\n          message_reflection->GetRepeatedEnum(message, field, j) :\n          message_reflection->GetEnum(message, field);\n        if (is_packed) {\n          WireFormatLite::WriteEnumNoTag(value->number(), output);\n        } else {\n          WireFormatLite::WriteEnum(field->number(), value->number(), output);\n        }\n        break;\n      }\n\n      // Handle strings separately so that we can get string references\n      // instead of copying.\n      case FieldDescriptor::TYPE_STRING: {\n        bool strict_utf8_check = StrictUtf8Check(field);\n        string scratch;\n        const string& value = field->is_repeated() ?\n          message_reflection->GetRepeatedStringReference(\n            message, field, j, &scratch) :\n          message_reflection->GetStringReference(message, field, &scratch);\n        if (strict_utf8_check) {\n          WireFormatLite::VerifyUtf8String(value.data(), value.length(),\n                                           WireFormatLite::SERIALIZE,\n                                           field->full_name().c_str());\n        } else {\n          VerifyUTF8StringNamedField(value.data(), value.length(), SERIALIZE,\n                                     field->full_name().c_str());\n        }\n        WireFormatLite::WriteString(field->number(), value, output);\n        break;\n      }\n\n      case FieldDescriptor::TYPE_BYTES: {\n        string scratch;\n        const string& value = field->is_repeated() ?\n          message_reflection->GetRepeatedStringReference(\n            message, field, j, &scratch) :\n          message_reflection->GetStringReference(message, field, &scratch);\n        WireFormatLite::WriteBytes(field->number(), value, output);\n        break;\n      }\n    }\n  }\n}\n\nvoid WireFormat::SerializeMessageSetItemWithCachedSizes(\n    const FieldDescriptor* field,\n    const Message& message,\n    io::CodedOutputStream* output) {\n  const Reflection* message_reflection = message.GetReflection();\n\n  // Start group.\n  output->WriteVarint32(WireFormatLite::kMessageSetItemStartTag);\n\n  // Write type ID.\n  output->WriteVarint32(WireFormatLite::kMessageSetTypeIdTag);\n  output->WriteVarint32(field->number());\n\n  // Write message.\n  output->WriteVarint32(WireFormatLite::kMessageSetMessageTag);\n\n  const Message& sub_message = message_reflection->GetMessage(message, field);\n  output->WriteVarint32(sub_message.GetCachedSize());\n  sub_message.SerializeWithCachedSizes(output);\n\n  // End group.\n  output->WriteVarint32(WireFormatLite::kMessageSetItemEndTag);\n}\n\n// ===================================================================\n\nint WireFormat::ByteSize(const Message& message) {\n  const Descriptor* descriptor = message.GetDescriptor();\n  const Reflection* message_reflection = message.GetReflection();\n\n  int our_size = 0;\n\n  vector<const FieldDescriptor*> fields;\n  message_reflection->ListFields(message, &fields);\n  for (int i = 0; i < fields.size(); i++) {\n    our_size += FieldByteSize(fields[i], message);\n  }\n\n  if (descriptor->options().message_set_wire_format()) {\n    our_size += ComputeUnknownMessageSetItemsSize(\n      message_reflection->GetUnknownFields(message));\n  } else {\n    our_size += ComputeUnknownFieldsSize(\n      message_reflection->GetUnknownFields(message));\n  }\n\n  return our_size;\n}\n\nint WireFormat::FieldByteSize(\n    const FieldDescriptor* field,\n    const Message& message) {\n  const Reflection* message_reflection = message.GetReflection();\n\n  if (field->is_extension() &&\n      field->containing_type()->options().message_set_wire_format() &&\n      field->cpp_type() == FieldDescriptor::CPPTYPE_MESSAGE &&\n      !field->is_repeated()) {\n    return MessageSetItemByteSize(field, message);\n  }\n\n  int count = 0;\n  if (field->is_repeated()) {\n    count = message_reflection->FieldSize(message, field);\n  } else if (message_reflection->HasField(message, field)) {\n    count = 1;\n  }\n\n  const int data_size = FieldDataOnlyByteSize(field, message);\n  int our_size = data_size;\n  if (field->is_packed()) {\n    if (data_size > 0) {\n      // Packed fields get serialized like a string, not their native type.\n      // Technically this doesn't really matter; the size only changes if it's\n      // a GROUP\n      our_size += TagSize(field->number(), FieldDescriptor::TYPE_STRING);\n      our_size += io::CodedOutputStream::VarintSize32(data_size);\n    }\n  } else {\n    our_size += count * TagSize(field->number(), field->type());\n  }\n  return our_size;\n}\n\nint WireFormat::FieldDataOnlyByteSize(\n    const FieldDescriptor* field,\n    const Message& message) {\n  const Reflection* message_reflection = message.GetReflection();\n\n  int count = 0;\n  if (field->is_repeated()) {\n    count = message_reflection->FieldSize(message, field);\n  } else if (message_reflection->HasField(message, field)) {\n    count = 1;\n  }\n\n  int data_size = 0;\n  switch (field->type()) {\n#define HANDLE_TYPE(TYPE, TYPE_METHOD, CPPTYPE_METHOD)                     \\\n    case FieldDescriptor::TYPE_##TYPE:                                     \\\n      if (field->is_repeated()) {                                          \\\n        for (int j = 0; j < count; j++) {                                  \\\n          data_size += WireFormatLite::TYPE_METHOD##Size(                  \\\n            message_reflection->GetRepeated##CPPTYPE_METHOD(               \\\n              message, field, j));                                         \\\n        }                                                                  \\\n      } else {                                                             \\\n        data_size += WireFormatLite::TYPE_METHOD##Size(                    \\\n          message_reflection->Get##CPPTYPE_METHOD(message, field));        \\\n      }                                                                    \\\n      break;\n\n#define HANDLE_FIXED_TYPE(TYPE, TYPE_METHOD)                               \\\n    case FieldDescriptor::TYPE_##TYPE:                                     \\\n      data_size += count * WireFormatLite::k##TYPE_METHOD##Size;           \\\n      break;\n\n    HANDLE_TYPE( INT32,  Int32,  Int32)\n    HANDLE_TYPE( INT64,  Int64,  Int64)\n    HANDLE_TYPE(SINT32, SInt32,  Int32)\n    HANDLE_TYPE(SINT64, SInt64,  Int64)\n    HANDLE_TYPE(UINT32, UInt32, UInt32)\n    HANDLE_TYPE(UINT64, UInt64, UInt64)\n\n    HANDLE_FIXED_TYPE( FIXED32,  Fixed32)\n    HANDLE_FIXED_TYPE( FIXED64,  Fixed64)\n    HANDLE_FIXED_TYPE(SFIXED32, SFixed32)\n    HANDLE_FIXED_TYPE(SFIXED64, SFixed64)\n\n    HANDLE_FIXED_TYPE(FLOAT , Float )\n    HANDLE_FIXED_TYPE(DOUBLE, Double)\n\n    HANDLE_FIXED_TYPE(BOOL, Bool)\n\n    HANDLE_TYPE(GROUP  , Group  , Message)\n    HANDLE_TYPE(MESSAGE, Message, Message)\n#undef HANDLE_TYPE\n#undef HANDLE_FIXED_TYPE\n\n    case FieldDescriptor::TYPE_ENUM: {\n      if (field->is_repeated()) {\n        for (int j = 0; j < count; j++) {\n          data_size += WireFormatLite::EnumSize(\n            message_reflection->GetRepeatedEnum(message, field, j)->number());\n        }\n      } else {\n        data_size += WireFormatLite::EnumSize(\n          message_reflection->GetEnum(message, field)->number());\n      }\n      break;\n    }\n\n    // Handle strings separately so that we can get string references\n    // instead of copying.\n    case FieldDescriptor::TYPE_STRING:\n    case FieldDescriptor::TYPE_BYTES: {\n      for (int j = 0; j < count; j++) {\n        string scratch;\n        const string& value = field->is_repeated() ?\n          message_reflection->GetRepeatedStringReference(\n            message, field, j, &scratch) :\n          message_reflection->GetStringReference(message, field, &scratch);\n        data_size += WireFormatLite::StringSize(value);\n      }\n      break;\n    }\n  }\n  return data_size;\n}\n\nint WireFormat::MessageSetItemByteSize(\n    const FieldDescriptor* field,\n    const Message& message) {\n  const Reflection* message_reflection = message.GetReflection();\n\n  int our_size = WireFormatLite::kMessageSetItemTagsSize;\n\n  // type_id\n  our_size += io::CodedOutputStream::VarintSize32(field->number());\n\n  // message\n  const Message& sub_message = message_reflection->GetMessage(message, field);\n  int message_size = sub_message.ByteSize();\n\n  our_size += io::CodedOutputStream::VarintSize32(message_size);\n  our_size += message_size;\n\n  return our_size;\n}\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/wire_format.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//         atenasio@google.com (Chris Atenasio) (ZigZag transform)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This header is logically internal, but is made public because it is used\n// from protocol-compiler-generated code, which may reside in other components.\n\n#ifndef GOOGLE_PROTOBUF_WIRE_FORMAT_H__\n#define GOOGLE_PROTOBUF_WIRE_FORMAT_H__\n\n#include <string>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/descriptor.pb.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/wire_format_lite.h>\n\n// Do UTF-8 validation on string type in Debug build only\n#ifndef NDEBUG\n#define GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED\n#endif\n\nnamespace google {\nnamespace protobuf {\n  namespace io {\n    class CodedInputStream;      // coded_stream.h\n    class CodedOutputStream;     // coded_stream.h\n  }\n  class UnknownFieldSet;         // unknown_field_set.h\n}\n\nnamespace protobuf {\nnamespace internal {\n\n// This class is for internal use by the protocol buffer library and by\n// protocol-complier-generated message classes.  It must not be called\n// directly by clients.\n//\n// This class contains code for implementing the binary protocol buffer\n// wire format via reflection.  The WireFormatLite class implements the\n// non-reflection based routines.\n//\n// This class is really a namespace that contains only static methods\nclass LIBPROTOBUF_EXPORT WireFormat {\n public:\n\n  // Given a field return its WireType\n  static inline WireFormatLite::WireType WireTypeForField(\n      const FieldDescriptor* field);\n\n  // Given a FieldDescriptor::Type return its WireType\n  static inline WireFormatLite::WireType WireTypeForFieldType(\n      FieldDescriptor::Type type);\n\n  // Compute the byte size of a tag.  For groups, this includes both the start\n  // and end tags.\n  static inline int TagSize(int field_number, FieldDescriptor::Type type);\n\n  // These procedures can be used to implement the methods of Message which\n  // handle parsing and serialization of the protocol buffer wire format\n  // using only the Reflection interface.  When you ask the protocol\n  // compiler to optimize for code size rather than speed, it will implement\n  // those methods in terms of these procedures.  Of course, these are much\n  // slower than the specialized implementations which the protocol compiler\n  // generates when told to optimize for speed.\n\n  // Read a message in protocol buffer wire format.\n  //\n  // This procedure reads either to the end of the input stream or through\n  // a WIRETYPE_END_GROUP tag ending the message, whichever comes first.\n  // It returns false if the input is invalid.\n  //\n  // Required fields are NOT checked by this method.  You must call\n  // IsInitialized() on the resulting message yourself.\n  static bool ParseAndMergePartial(io::CodedInputStream* input,\n                                   Message* message);\n\n  // Serialize a message in protocol buffer wire format.\n  //\n  // Any embedded messages within the message must have their correct sizes\n  // cached.  However, the top-level message need not; its size is passed as\n  // a parameter to this procedure.\n  //\n  // These return false iff the underlying stream returns a write error.\n  static void SerializeWithCachedSizes(\n      const Message& message,\n      int size, io::CodedOutputStream* output);\n\n  // Implements Message::ByteSize() via reflection.  WARNING:  The result\n  // of this method is *not* cached anywhere.  However, all embedded messages\n  // will have their ByteSize() methods called, so their sizes will be cached.\n  // Therefore, calling this method is sufficient to allow you to call\n  // WireFormat::SerializeWithCachedSizes() on the same object.\n  static int ByteSize(const Message& message);\n\n  // -----------------------------------------------------------------\n  // Helpers for dealing with unknown fields\n\n  // Skips a field value of the given WireType.  The input should start\n  // positioned immediately after the tag.  If unknown_fields is non-NULL,\n  // the contents of the field will be added to it.\n  static bool SkipField(io::CodedInputStream* input, uint32 tag,\n                        UnknownFieldSet* unknown_fields);\n\n  // Reads and ignores a message from the input.  If unknown_fields is non-NULL,\n  // the contents will be added to it.\n  static bool SkipMessage(io::CodedInputStream* input,\n                          UnknownFieldSet* unknown_fields);\n\n  // Read a packed enum field. If the is_valid function is not NULL, values for\n  // which is_valid(value) returns false are appended to unknown_fields_stream.\n  static bool ReadPackedEnumPreserveUnknowns(io::CodedInputStream* input,\n                                             uint32 field_number,\n                                             bool (*is_valid)(int),\n                                             UnknownFieldSet* unknown_fields,\n                                             RepeatedField<int>* values);\n\n  // Write the contents of an UnknownFieldSet to the output.\n  static void SerializeUnknownFields(const UnknownFieldSet& unknown_fields,\n                                     io::CodedOutputStream* output);\n  // Same as above, except writing directly to the provided buffer.\n  // Requires that the buffer have sufficient capacity for\n  // ComputeUnknownFieldsSize(unknown_fields).\n  //\n  // Returns a pointer past the last written byte.\n  static uint8* SerializeUnknownFieldsToArray(\n      const UnknownFieldSet& unknown_fields,\n      uint8* target);\n\n  // Same thing except for messages that have the message_set_wire_format\n  // option.\n  static void SerializeUnknownMessageSetItems(\n      const UnknownFieldSet& unknown_fields,\n      io::CodedOutputStream* output);\n  // Same as above, except writing directly to the provided buffer.\n  // Requires that the buffer have sufficient capacity for\n  // ComputeUnknownMessageSetItemsSize(unknown_fields).\n  //\n  // Returns a pointer past the last written byte.\n  static uint8* SerializeUnknownMessageSetItemsToArray(\n      const UnknownFieldSet& unknown_fields,\n      uint8* target);\n\n  // Compute the size of the UnknownFieldSet on the wire.\n  static int ComputeUnknownFieldsSize(const UnknownFieldSet& unknown_fields);\n\n  // Same thing except for messages that have the message_set_wire_format\n  // option.\n  static int ComputeUnknownMessageSetItemsSize(\n      const UnknownFieldSet& unknown_fields);\n\n\n  // Helper functions for encoding and decoding tags.  (Inlined below and in\n  // _inl.h)\n  //\n  // This is different from MakeTag(field->number(), field->type()) in the case\n  // of packed repeated fields.\n  static uint32 MakeTag(const FieldDescriptor* field);\n\n  // Parse a single field.  The input should start out positioned immediately\n  // after the tag.\n  static bool ParseAndMergeField(\n      uint32 tag,\n      const FieldDescriptor* field,        // May be NULL for unknown\n      Message* message,\n      io::CodedInputStream* input);\n\n  // Serialize a single field.\n  static void SerializeFieldWithCachedSizes(\n      const FieldDescriptor* field,        // Cannot be NULL\n      const Message& message,\n      io::CodedOutputStream* output);\n\n  // Compute size of a single field.  If the field is a message type, this\n  // will call ByteSize() for the embedded message, insuring that it caches\n  // its size.\n  static int FieldByteSize(\n      const FieldDescriptor* field,        // Cannot be NULL\n      const Message& message);\n\n  // Parse/serialize a MessageSet::Item group.  Used with messages that use\n  // opion message_set_wire_format = true.\n  static bool ParseAndMergeMessageSetItem(\n      io::CodedInputStream* input,\n      Message* message);\n  static void SerializeMessageSetItemWithCachedSizes(\n      const FieldDescriptor* field,\n      const Message& message,\n      io::CodedOutputStream* output);\n  static int MessageSetItemByteSize(\n      const FieldDescriptor* field,\n      const Message& message);\n\n  // Computes the byte size of a field, excluding tags. For packed fields, it\n  // only includes the size of the raw data, and not the size of the total\n  // length, but for other length-delimited types, the size of the length is\n  // included.\n  static int FieldDataOnlyByteSize(\n      const FieldDescriptor* field,        // Cannot be NULL\n      const Message& message);\n\n  enum Operation {\n    PARSE = 0,\n    SERIALIZE = 1,\n  };\n\n  // Verifies that a string field is valid UTF8, logging an error if not.\n  // This function will not be called by newly generated protobuf code\n  // but remains present to support existing code.\n  static void VerifyUTF8String(const char* data, int size, Operation op);\n  // The NamedField variant takes a field name in order to produce an\n  // informative error message if verification fails.\n  static void VerifyUTF8StringNamedField(const char* data,\n                                         int size,\n                                         Operation op,\n                                         const char* field_name);\n\n private:\n  // Skip a MessageSet field.\n  static bool SkipMessageSetField(io::CodedInputStream* input,\n                                  uint32 field_number,\n                                  UnknownFieldSet* unknown_fields);\n\n  // Parse a MessageSet field.\n  static bool ParseAndMergeMessageSetField(uint32 field_number,\n                                           const FieldDescriptor* field,\n                                           Message* message,\n                                           io::CodedInputStream* input);\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(WireFormat);\n};\n\n// Subclass of FieldSkipper which saves skipped fields to an UnknownFieldSet.\nclass LIBPROTOBUF_EXPORT UnknownFieldSetFieldSkipper : public FieldSkipper {\n public:\n  UnknownFieldSetFieldSkipper(UnknownFieldSet* unknown_fields)\n      : unknown_fields_(unknown_fields) {}\n  virtual ~UnknownFieldSetFieldSkipper() {}\n\n  // implements FieldSkipper -----------------------------------------\n  virtual bool SkipField(io::CodedInputStream* input, uint32 tag);\n  virtual bool SkipMessage(io::CodedInputStream* input);\n  virtual void SkipUnknownEnum(int field_number, int value);\n\n protected:\n  UnknownFieldSet* unknown_fields_;\n};\n\n// inline methods ====================================================\n\ninline WireFormatLite::WireType WireFormat::WireTypeForField(\n    const FieldDescriptor* field) {\n  if (field->is_packed()) {\n    return WireFormatLite::WIRETYPE_LENGTH_DELIMITED;\n  } else {\n    return WireTypeForFieldType(field->type());\n  }\n}\n\ninline WireFormatLite::WireType WireFormat::WireTypeForFieldType(\n    FieldDescriptor::Type type) {\n  // Some compilers don't like enum -> enum casts, so we implicit_cast to\n  // int first.\n  return WireFormatLite::WireTypeForFieldType(\n      static_cast<WireFormatLite::FieldType>(\n        implicit_cast<int>(type)));\n}\n\ninline uint32 WireFormat::MakeTag(const FieldDescriptor* field) {\n  return WireFormatLite::MakeTag(field->number(), WireTypeForField(field));\n}\n\ninline int WireFormat::TagSize(int field_number, FieldDescriptor::Type type) {\n  // Some compilers don't like enum -> enum casts, so we implicit_cast to\n  // int first.\n  return WireFormatLite::TagSize(field_number,\n      static_cast<WireFormatLite::FieldType>(\n        implicit_cast<int>(type)));\n}\n\ninline void WireFormat::VerifyUTF8String(const char* data, int size,\n    WireFormat::Operation op) {\n#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED\n  WireFormatLite::VerifyUtf8String(\n      data, size, static_cast<WireFormatLite::Operation>(op), NULL);\n#else\n  // Avoid the compiler warning about unused variables.\n  (void)data; (void)size; (void)op;\n#endif\n}\n\ninline void WireFormat::VerifyUTF8StringNamedField(\n    const char* data, int size, WireFormat::Operation op,\n    const char* field_name) {\n#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED\n  WireFormatLite::VerifyUtf8String(\n      data, size, static_cast<WireFormatLite::Operation>(op), field_name);\n#endif\n}\n\n\n}  // namespace internal\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_WIRE_FORMAT_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/wire_format_lite.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/wire_format_lite_inl.h>\n\n#include <stack>\n#include <string>\n#include <vector>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/stringprintf.h>\n#include <google/protobuf/io/coded_stream_inl.h>\n#include <google/protobuf/io/zero_copy_stream.h>\n#include <google/protobuf/io/zero_copy_stream_impl_lite.h>\n\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\n// Old version of MSVC doesn't like definitions of inline constants, GCC\n// requires them.\nconst int WireFormatLite::kMessageSetItemStartTag;\nconst int WireFormatLite::kMessageSetItemEndTag;\nconst int WireFormatLite::kMessageSetTypeIdTag;\nconst int WireFormatLite::kMessageSetMessageTag;\n\n#endif\n\n// IBM xlC requires prefixing constants with WireFormatLite::\nconst int WireFormatLite::kMessageSetItemTagsSize =\n  io::CodedOutputStream::StaticVarintSize32<\n      WireFormatLite::kMessageSetItemStartTag>::value +\n  io::CodedOutputStream::StaticVarintSize32<\n      WireFormatLite::kMessageSetItemEndTag>::value +\n  io::CodedOutputStream::StaticVarintSize32<\n      WireFormatLite::kMessageSetTypeIdTag>::value +\n  io::CodedOutputStream::StaticVarintSize32<\n      WireFormatLite::kMessageSetMessageTag>::value;\n\nconst WireFormatLite::CppType\nWireFormatLite::kFieldTypeToCppTypeMap[MAX_FIELD_TYPE + 1] = {\n  static_cast<CppType>(0),  // 0 is reserved for errors\n\n  CPPTYPE_DOUBLE,   // TYPE_DOUBLE\n  CPPTYPE_FLOAT,    // TYPE_FLOAT\n  CPPTYPE_INT64,    // TYPE_INT64\n  CPPTYPE_UINT64,   // TYPE_UINT64\n  CPPTYPE_INT32,    // TYPE_INT32\n  CPPTYPE_UINT64,   // TYPE_FIXED64\n  CPPTYPE_UINT32,   // TYPE_FIXED32\n  CPPTYPE_BOOL,     // TYPE_BOOL\n  CPPTYPE_STRING,   // TYPE_STRING\n  CPPTYPE_MESSAGE,  // TYPE_GROUP\n  CPPTYPE_MESSAGE,  // TYPE_MESSAGE\n  CPPTYPE_STRING,   // TYPE_BYTES\n  CPPTYPE_UINT32,   // TYPE_UINT32\n  CPPTYPE_ENUM,     // TYPE_ENUM\n  CPPTYPE_INT32,    // TYPE_SFIXED32\n  CPPTYPE_INT64,    // TYPE_SFIXED64\n  CPPTYPE_INT32,    // TYPE_SINT32\n  CPPTYPE_INT64,    // TYPE_SINT64\n};\n\nconst WireFormatLite::WireType\nWireFormatLite::kWireTypeForFieldType[MAX_FIELD_TYPE + 1] = {\n  static_cast<WireFormatLite::WireType>(-1),  // invalid\n  WireFormatLite::WIRETYPE_FIXED64,           // TYPE_DOUBLE\n  WireFormatLite::WIRETYPE_FIXED32,           // TYPE_FLOAT\n  WireFormatLite::WIRETYPE_VARINT,            // TYPE_INT64\n  WireFormatLite::WIRETYPE_VARINT,            // TYPE_UINT64\n  WireFormatLite::WIRETYPE_VARINT,            // TYPE_INT32\n  WireFormatLite::WIRETYPE_FIXED64,           // TYPE_FIXED64\n  WireFormatLite::WIRETYPE_FIXED32,           // TYPE_FIXED32\n  WireFormatLite::WIRETYPE_VARINT,            // TYPE_BOOL\n  WireFormatLite::WIRETYPE_LENGTH_DELIMITED,  // TYPE_STRING\n  WireFormatLite::WIRETYPE_START_GROUP,       // TYPE_GROUP\n  WireFormatLite::WIRETYPE_LENGTH_DELIMITED,  // TYPE_MESSAGE\n  WireFormatLite::WIRETYPE_LENGTH_DELIMITED,  // TYPE_BYTES\n  WireFormatLite::WIRETYPE_VARINT,            // TYPE_UINT32\n  WireFormatLite::WIRETYPE_VARINT,            // TYPE_ENUM\n  WireFormatLite::WIRETYPE_FIXED32,           // TYPE_SFIXED32\n  WireFormatLite::WIRETYPE_FIXED64,           // TYPE_SFIXED64\n  WireFormatLite::WIRETYPE_VARINT,            // TYPE_SINT32\n  WireFormatLite::WIRETYPE_VARINT,            // TYPE_SINT64\n};\n\nbool WireFormatLite::SkipField(\n    io::CodedInputStream* input, uint32 tag) {\n  switch (WireFormatLite::GetTagWireType(tag)) {\n    case WireFormatLite::WIRETYPE_VARINT: {\n      uint64 value;\n      if (!input->ReadVarint64(&value)) return false;\n      return true;\n    }\n    case WireFormatLite::WIRETYPE_FIXED64: {\n      uint64 value;\n      if (!input->ReadLittleEndian64(&value)) return false;\n      return true;\n    }\n    case WireFormatLite::WIRETYPE_LENGTH_DELIMITED: {\n      uint32 length;\n      if (!input->ReadVarint32(&length)) return false;\n      if (!input->Skip(length)) return false;\n      return true;\n    }\n    case WireFormatLite::WIRETYPE_START_GROUP: {\n      if (!input->IncrementRecursionDepth()) return false;\n      if (!SkipMessage(input)) return false;\n      input->DecrementRecursionDepth();\n      // Check that the ending tag matched the starting tag.\n      if (!input->LastTagWas(WireFormatLite::MakeTag(\n          WireFormatLite::GetTagFieldNumber(tag),\n          WireFormatLite::WIRETYPE_END_GROUP))) {\n        return false;\n      }\n      return true;\n    }\n    case WireFormatLite::WIRETYPE_END_GROUP: {\n      return false;\n    }\n    case WireFormatLite::WIRETYPE_FIXED32: {\n      uint32 value;\n      if (!input->ReadLittleEndian32(&value)) return false;\n      return true;\n    }\n    default: {\n      return false;\n    }\n  }\n}\n\nbool WireFormatLite::SkipField(\n    io::CodedInputStream* input, uint32 tag, io::CodedOutputStream* output) {\n  switch (WireFormatLite::GetTagWireType(tag)) {\n    case WireFormatLite::WIRETYPE_VARINT: {\n      uint64 value;\n      if (!input->ReadVarint64(&value)) return false;\n      output->WriteVarint32(tag);\n      output->WriteVarint64(value);\n      return true;\n    }\n    case WireFormatLite::WIRETYPE_FIXED64: {\n      uint64 value;\n      if (!input->ReadLittleEndian64(&value)) return false;\n      output->WriteVarint32(tag);\n      output->WriteLittleEndian64(value);\n      return true;\n    }\n    case WireFormatLite::WIRETYPE_LENGTH_DELIMITED: {\n      uint32 length;\n      if (!input->ReadVarint32(&length)) return false;\n      output->WriteVarint32(tag);\n      output->WriteVarint32(length);\n      // TODO(mkilavuz): Provide API to prevent extra string copying.\n      string temp;\n      if (!input->ReadString(&temp, length)) return false;\n      output->WriteString(temp);\n      return true;\n    }\n    case WireFormatLite::WIRETYPE_START_GROUP: {\n      output->WriteVarint32(tag);\n      if (!input->IncrementRecursionDepth()) return false;\n      if (!SkipMessage(input, output)) return false;\n      input->DecrementRecursionDepth();\n      // Check that the ending tag matched the starting tag.\n      if (!input->LastTagWas(WireFormatLite::MakeTag(\n          WireFormatLite::GetTagFieldNumber(tag),\n          WireFormatLite::WIRETYPE_END_GROUP))) {\n        return false;\n      }\n      return true;\n    }\n    case WireFormatLite::WIRETYPE_END_GROUP: {\n      return false;\n    }\n    case WireFormatLite::WIRETYPE_FIXED32: {\n      uint32 value;\n      if (!input->ReadLittleEndian32(&value)) return false;\n      output->WriteVarint32(tag);\n      output->WriteLittleEndian32(value);\n      return true;\n    }\n    default: {\n      return false;\n    }\n  }\n}\n\nbool WireFormatLite::SkipMessage(io::CodedInputStream* input) {\n  while (true) {\n    uint32 tag = input->ReadTag();\n    if (tag == 0) {\n      // End of input.  This is a valid place to end, so return true.\n      return true;\n    }\n\n    WireFormatLite::WireType wire_type = WireFormatLite::GetTagWireType(tag);\n\n    if (wire_type == WireFormatLite::WIRETYPE_END_GROUP) {\n      // Must be the end of the message.\n      return true;\n    }\n\n    if (!SkipField(input, tag)) return false;\n  }\n}\n\nbool WireFormatLite::SkipMessage(io::CodedInputStream* input,\n    io::CodedOutputStream* output) {\n  while (true) {\n    uint32 tag = input->ReadTag();\n    if (tag == 0) {\n      // End of input.  This is a valid place to end, so return true.\n      return true;\n    }\n\n    WireFormatLite::WireType wire_type = WireFormatLite::GetTagWireType(tag);\n\n    if (wire_type == WireFormatLite::WIRETYPE_END_GROUP) {\n      output->WriteVarint32(tag);\n      // Must be the end of the message.\n      return true;\n    }\n\n    if (!SkipField(input, tag, output)) return false;\n  }\n}\n\nbool FieldSkipper::SkipField(\n    io::CodedInputStream* input, uint32 tag) {\n  return WireFormatLite::SkipField(input, tag);\n}\n\nbool FieldSkipper::SkipMessage(io::CodedInputStream* input) {\n  return WireFormatLite::SkipMessage(input);\n}\n\nvoid FieldSkipper::SkipUnknownEnum(\n    int /* field_number */, int /* value */) {\n  // Nothing.\n}\n\nbool CodedOutputStreamFieldSkipper::SkipField(\n    io::CodedInputStream* input, uint32 tag) {\n  return WireFormatLite::SkipField(input, tag, unknown_fields_);\n}\n\nbool CodedOutputStreamFieldSkipper::SkipMessage(io::CodedInputStream* input) {\n  return WireFormatLite::SkipMessage(input, unknown_fields_);\n}\n\nvoid CodedOutputStreamFieldSkipper::SkipUnknownEnum(\n    int field_number, int value) {\n  unknown_fields_->WriteVarint32(field_number);\n  unknown_fields_->WriteVarint64(value);\n}\n\nbool WireFormatLite::ReadPackedEnumNoInline(io::CodedInputStream* input,\n                                            bool (*is_valid)(int),\n                                            RepeatedField<int>* values) {\n  uint32 length;\n  if (!input->ReadVarint32(&length)) return false;\n  io::CodedInputStream::Limit limit = input->PushLimit(length);\n  while (input->BytesUntilLimit() > 0) {\n    int value;\n    if (!google::protobuf::internal::WireFormatLite::ReadPrimitive<\n        int, WireFormatLite::TYPE_ENUM>(input, &value)) {\n      return false;\n    }\n    if (is_valid == NULL || is_valid(value)) {\n      values->Add(value);\n    }\n  }\n  input->PopLimit(limit);\n  return true;\n}\n\nbool WireFormatLite::ReadPackedEnumPreserveUnknowns(\n    io::CodedInputStream* input,\n    int field_number,\n    bool (*is_valid)(int),\n    io::CodedOutputStream* unknown_fields_stream,\n    RepeatedField<int>* values) {\n  uint32 length;\n  if (!input->ReadVarint32(&length)) return false;\n  io::CodedInputStream::Limit limit = input->PushLimit(length);\n  while (input->BytesUntilLimit() > 0) {\n    int value;\n    if (!google::protobuf::internal::WireFormatLite::ReadPrimitive<\n        int, WireFormatLite::TYPE_ENUM>(input, &value)) {\n      return false;\n    }\n    if (is_valid == NULL || is_valid(value)) {\n      values->Add(value);\n    } else {\n      uint32 tag = WireFormatLite::MakeTag(field_number,\n                                           WireFormatLite::WIRETYPE_VARINT);\n      unknown_fields_stream->WriteVarint32(tag);\n      unknown_fields_stream->WriteVarint32(value);\n    }\n  }\n  input->PopLimit(limit);\n  return true;\n}\n\nvoid WireFormatLite::WriteInt32(int field_number, int32 value,\n                                io::CodedOutputStream* output) {\n  WriteTag(field_number, WIRETYPE_VARINT, output);\n  WriteInt32NoTag(value, output);\n}\nvoid WireFormatLite::WriteInt64(int field_number, int64 value,\n                                io::CodedOutputStream* output) {\n  WriteTag(field_number, WIRETYPE_VARINT, output);\n  WriteInt64NoTag(value, output);\n}\nvoid WireFormatLite::WriteUInt32(int field_number, uint32 value,\n                                 io::CodedOutputStream* output) {\n  WriteTag(field_number, WIRETYPE_VARINT, output);\n  WriteUInt32NoTag(value, output);\n}\nvoid WireFormatLite::WriteUInt64(int field_number, uint64 value,\n                                 io::CodedOutputStream* output) {\n  WriteTag(field_number, WIRETYPE_VARINT, output);\n  WriteUInt64NoTag(value, output);\n}\nvoid WireFormatLite::WriteSInt32(int field_number, int32 value,\n                                 io::CodedOutputStream* output) {\n  WriteTag(field_number, WIRETYPE_VARINT, output);\n  WriteSInt32NoTag(value, output);\n}\nvoid WireFormatLite::WriteSInt64(int field_number, int64 value,\n                                 io::CodedOutputStream* output) {\n  WriteTag(field_number, WIRETYPE_VARINT, output);\n  WriteSInt64NoTag(value, output);\n}\nvoid WireFormatLite::WriteFixed32(int field_number, uint32 value,\n                                  io::CodedOutputStream* output) {\n  WriteTag(field_number, WIRETYPE_FIXED32, output);\n  WriteFixed32NoTag(value, output);\n}\nvoid WireFormatLite::WriteFixed64(int field_number, uint64 value,\n                                  io::CodedOutputStream* output) {\n  WriteTag(field_number, WIRETYPE_FIXED64, output);\n  WriteFixed64NoTag(value, output);\n}\nvoid WireFormatLite::WriteSFixed32(int field_number, int32 value,\n                                   io::CodedOutputStream* output) {\n  WriteTag(field_number, WIRETYPE_FIXED32, output);\n  WriteSFixed32NoTag(value, output);\n}\nvoid WireFormatLite::WriteSFixed64(int field_number, int64 value,\n                                   io::CodedOutputStream* output) {\n  WriteTag(field_number, WIRETYPE_FIXED64, output);\n  WriteSFixed64NoTag(value, output);\n}\nvoid WireFormatLite::WriteFloat(int field_number, float value,\n                                io::CodedOutputStream* output) {\n  WriteTag(field_number, WIRETYPE_FIXED32, output);\n  WriteFloatNoTag(value, output);\n}\nvoid WireFormatLite::WriteDouble(int field_number, double value,\n                                 io::CodedOutputStream* output) {\n  WriteTag(field_number, WIRETYPE_FIXED64, output);\n  WriteDoubleNoTag(value, output);\n}\nvoid WireFormatLite::WriteBool(int field_number, bool value,\n                               io::CodedOutputStream* output) {\n  WriteTag(field_number, WIRETYPE_VARINT, output);\n  WriteBoolNoTag(value, output);\n}\nvoid WireFormatLite::WriteEnum(int field_number, int value,\n                               io::CodedOutputStream* output) {\n  WriteTag(field_number, WIRETYPE_VARINT, output);\n  WriteEnumNoTag(value, output);\n}\n\nvoid WireFormatLite::WriteString(int field_number, const string& value,\n                                 io::CodedOutputStream* output) {\n  // String is for UTF-8 text only\n  WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output);\n  GOOGLE_CHECK_LE(value.size(), kint32max);\n  output->WriteVarint32(value.size());\n  output->WriteString(value);\n}\nvoid WireFormatLite::WriteStringMaybeAliased(\n    int field_number, const string& value,\n    io::CodedOutputStream* output) {\n  // String is for UTF-8 text only\n  WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output);\n  GOOGLE_CHECK_LE(value.size(), kint32max);\n  output->WriteVarint32(value.size());\n  output->WriteRawMaybeAliased(value.data(), value.size());\n}\nvoid WireFormatLite::WriteBytes(int field_number, const string& value,\n                                io::CodedOutputStream* output) {\n  WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output);\n  GOOGLE_CHECK_LE(value.size(), kint32max);\n  output->WriteVarint32(value.size());\n  output->WriteString(value);\n}\nvoid WireFormatLite::WriteBytesMaybeAliased(\n    int field_number, const string& value,\n    io::CodedOutputStream* output) {\n  WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output);\n  GOOGLE_CHECK_LE(value.size(), kint32max);\n  output->WriteVarint32(value.size());\n  output->WriteRawMaybeAliased(value.data(), value.size());\n}\n\n\nvoid WireFormatLite::WriteGroup(int field_number,\n                                const MessageLite& value,\n                                io::CodedOutputStream* output) {\n  WriteTag(field_number, WIRETYPE_START_GROUP, output);\n  value.SerializeWithCachedSizes(output);\n  WriteTag(field_number, WIRETYPE_END_GROUP, output);\n}\n\nvoid WireFormatLite::WriteMessage(int field_number,\n                                  const MessageLite& value,\n                                  io::CodedOutputStream* output) {\n  WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output);\n  const int size = value.GetCachedSize();\n  output->WriteVarint32(size);\n  value.SerializeWithCachedSizes(output);\n}\n\nvoid WireFormatLite::WriteGroupMaybeToArray(int field_number,\n                                            const MessageLite& value,\n                                            io::CodedOutputStream* output) {\n  WriteTag(field_number, WIRETYPE_START_GROUP, output);\n  const int size = value.GetCachedSize();\n  uint8* target = output->GetDirectBufferForNBytesAndAdvance(size);\n  if (target != NULL) {\n    uint8* end = value.InternalSerializeWithCachedSizesToArray(\n        output->IsSerializationDeterminstic(), target);\n    GOOGLE_DCHECK_EQ(end - target, size);\n  } else {\n    value.SerializeWithCachedSizes(output);\n  }\n  WriteTag(field_number, WIRETYPE_END_GROUP, output);\n}\n\nvoid WireFormatLite::WriteMessageMaybeToArray(int field_number,\n                                              const MessageLite& value,\n                                              io::CodedOutputStream* output) {\n  WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output);\n  const int size = value.GetCachedSize();\n  output->WriteVarint32(size);\n  uint8* target = output->GetDirectBufferForNBytesAndAdvance(size);\n  if (target != NULL) {\n    uint8* end = value.InternalSerializeWithCachedSizesToArray(\n        output->IsSerializationDeterminstic(), target);\n    GOOGLE_DCHECK_EQ(end - target, size);\n  } else {\n    value.SerializeWithCachedSizes(output);\n  }\n}\n\nGOOGLE_ATTRIBUTE_ALWAYS_INLINE static bool ReadBytesToString(\n    io::CodedInputStream* input, string* value);\ninline static bool ReadBytesToString(io::CodedInputStream* input,\n                                     string* value) {\n  uint32 length;\n  return input->ReadVarint32(&length) &&\n      input->InternalReadStringInline(value, length);\n}\n\nbool WireFormatLite::ReadBytes(io::CodedInputStream* input, string* value) {\n  return ReadBytesToString(input, value);\n}\n\nbool WireFormatLite::ReadBytes(io::CodedInputStream* input, string** p) {\n  if (*p == &::google::protobuf::internal::GetEmptyStringAlreadyInited()) {\n    *p = new ::std::string();\n  }\n  return ReadBytesToString(input, *p);\n}\n\nbool WireFormatLite::VerifyUtf8String(const char* data,\n                                      int size,\n                                      Operation op,\n                                      const char* field_name) {\n  if (!IsStructurallyValidUTF8(data, size)) {\n    const char* operation_str = NULL;\n    switch (op) {\n      case PARSE:\n        operation_str = \"parsing\";\n        break;\n      case SERIALIZE:\n        operation_str = \"serializing\";\n        break;\n      // no default case: have the compiler warn if a case is not covered.\n    }\n    string quoted_field_name = \"\";\n    if (field_name != NULL) {\n      quoted_field_name = StringPrintf(\" '%s'\", field_name);\n    }\n    // no space below to avoid double space when the field name is missing.\n    GOOGLE_LOG(ERROR) << \"String field\" << quoted_field_name << \" contains invalid \"\n               << \"UTF-8 data when \" << operation_str << \" a protocol \"\n               << \"buffer. Use the 'bytes' type if you intend to send raw \"\n               << \"bytes. \";\n    return false;\n  }\n  return true;\n}\n\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/wire_format_lite.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//         atenasio@google.com (Chris Atenasio) (ZigZag transform)\n//         wink@google.com (Wink Saville) (refactored from wire_format.h)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n//\n// This header is logically internal, but is made public because it is used\n// from protocol-compiler-generated code, which may reside in other components.\n\n#ifndef GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_H__\n#define GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_H__\n\n#include <string>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/message_lite.h>\n#include <google/protobuf/io/coded_stream.h>  // for CodedOutputStream::Varint32Size\n\nnamespace google {\n\nnamespace protobuf {\n  template <typename T> class RepeatedField;  // repeated_field.h\n}\n\nnamespace protobuf {\nnamespace internal {\n\nclass StringPieceField;\n\n// This class is for internal use by the protocol buffer library and by\n// protocol-complier-generated message classes.  It must not be called\n// directly by clients.\n//\n// This class contains helpers for implementing the binary protocol buffer\n// wire format without the need for reflection. Use WireFormat when using\n// reflection.\n//\n// This class is really a namespace that contains only static methods.\nclass LIBPROTOBUF_EXPORT WireFormatLite {\n public:\n\n  // -----------------------------------------------------------------\n  // Helper constants and functions related to the format.  These are\n  // mostly meant for internal and generated code to use.\n\n  // The wire format is composed of a sequence of tag/value pairs, each\n  // of which contains the value of one field (or one element of a repeated\n  // field).  Each tag is encoded as a varint.  The lower bits of the tag\n  // identify its wire type, which specifies the format of the data to follow.\n  // The rest of the bits contain the field number.  Each type of field (as\n  // declared by FieldDescriptor::Type, in descriptor.h) maps to one of\n  // these wire types.  Immediately following each tag is the field's value,\n  // encoded in the format specified by the wire type.  Because the tag\n  // identifies the encoding of this data, it is possible to skip\n  // unrecognized fields for forwards compatibility.\n\n  enum WireType {\n    WIRETYPE_VARINT           = 0,\n    WIRETYPE_FIXED64          = 1,\n    WIRETYPE_LENGTH_DELIMITED = 2,\n    WIRETYPE_START_GROUP      = 3,\n    WIRETYPE_END_GROUP        = 4,\n    WIRETYPE_FIXED32          = 5,\n  };\n\n  // Lite alternative to FieldDescriptor::Type.  Must be kept in sync.\n  enum FieldType {\n    TYPE_DOUBLE         = 1,\n    TYPE_FLOAT          = 2,\n    TYPE_INT64          = 3,\n    TYPE_UINT64         = 4,\n    TYPE_INT32          = 5,\n    TYPE_FIXED64        = 6,\n    TYPE_FIXED32        = 7,\n    TYPE_BOOL           = 8,\n    TYPE_STRING         = 9,\n    TYPE_GROUP          = 10,\n    TYPE_MESSAGE        = 11,\n    TYPE_BYTES          = 12,\n    TYPE_UINT32         = 13,\n    TYPE_ENUM           = 14,\n    TYPE_SFIXED32       = 15,\n    TYPE_SFIXED64       = 16,\n    TYPE_SINT32         = 17,\n    TYPE_SINT64         = 18,\n    MAX_FIELD_TYPE      = 18,\n  };\n\n  // Lite alternative to FieldDescriptor::CppType.  Must be kept in sync.\n  enum CppType {\n    CPPTYPE_INT32       = 1,\n    CPPTYPE_INT64       = 2,\n    CPPTYPE_UINT32      = 3,\n    CPPTYPE_UINT64      = 4,\n    CPPTYPE_DOUBLE      = 5,\n    CPPTYPE_FLOAT       = 6,\n    CPPTYPE_BOOL        = 7,\n    CPPTYPE_ENUM        = 8,\n    CPPTYPE_STRING      = 9,\n    CPPTYPE_MESSAGE     = 10,\n    MAX_CPPTYPE         = 10,\n  };\n\n  // Helper method to get the CppType for a particular Type.\n  static CppType FieldTypeToCppType(FieldType type);\n\n  // Given a FieldSescriptor::Type return its WireType\n  static inline WireFormatLite::WireType WireTypeForFieldType(\n      WireFormatLite::FieldType type) {\n    return kWireTypeForFieldType[type];\n  }\n\n  // Number of bits in a tag which identify the wire type.\n  static const int kTagTypeBits = 3;\n  // Mask for those bits.\n  static const uint32 kTagTypeMask = (1 << kTagTypeBits) - 1;\n\n  // Helper functions for encoding and decoding tags.  (Inlined below and in\n  // _inl.h)\n  //\n  // This is different from MakeTag(field->number(), field->type()) in the case\n  // of packed repeated fields.\n  static uint32 MakeTag(int field_number, WireType type);\n  static WireType GetTagWireType(uint32 tag);\n  static int GetTagFieldNumber(uint32 tag);\n\n  // Compute the byte size of a tag.  For groups, this includes both the start\n  // and end tags.\n  static inline int TagSize(int field_number, WireFormatLite::FieldType type);\n\n  // Skips a field value with the given tag.  The input should start\n  // positioned immediately after the tag.  Skipped values are simply discarded,\n  // not recorded anywhere.  See WireFormat::SkipField() for a version that\n  // records to an UnknownFieldSet.\n  static bool SkipField(io::CodedInputStream* input, uint32 tag);\n\n  // Skips a field value with the given tag.  The input should start\n  // positioned immediately after the tag. Skipped values are recorded to a\n  // CodedOutputStream.\n  static bool SkipField(io::CodedInputStream* input, uint32 tag,\n                        io::CodedOutputStream* output);\n\n  // Reads and ignores a message from the input.  Skipped values are simply\n  // discarded, not recorded anywhere.  See WireFormat::SkipMessage() for a\n  // version that records to an UnknownFieldSet.\n  static bool SkipMessage(io::CodedInputStream* input);\n\n  // Reads and ignores a message from the input.  Skipped values are recorded\n  // to a CodedOutputStream.\n  static bool SkipMessage(io::CodedInputStream* input,\n                          io::CodedOutputStream* output);\n\n// This macro does the same thing as WireFormatLite::MakeTag(), but the\n// result is usable as a compile-time constant, which makes it usable\n// as a switch case or a template input.  WireFormatLite::MakeTag() is more\n// type-safe, though, so prefer it if possible.\n#define GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(FIELD_NUMBER, TYPE)                  \\\n  static_cast<uint32>(                                                   \\\n    ((FIELD_NUMBER) << ::google::protobuf::internal::WireFormatLite::kTagTypeBits) \\\n      | (TYPE))\n\n  // These are the tags for the old MessageSet format, which was defined as:\n  //   message MessageSet {\n  //     repeated group Item = 1 {\n  //       required int32 type_id = 2;\n  //       required string message = 3;\n  //     }\n  //   }\n  static const int kMessageSetItemNumber = 1;\n  static const int kMessageSetTypeIdNumber = 2;\n  static const int kMessageSetMessageNumber = 3;\n  static const int kMessageSetItemStartTag =\n    GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(kMessageSetItemNumber,\n                                WireFormatLite::WIRETYPE_START_GROUP);\n  static const int kMessageSetItemEndTag =\n    GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(kMessageSetItemNumber,\n                                WireFormatLite::WIRETYPE_END_GROUP);\n  static const int kMessageSetTypeIdTag =\n    GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(kMessageSetTypeIdNumber,\n                                WireFormatLite::WIRETYPE_VARINT);\n  static const int kMessageSetMessageTag =\n    GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(kMessageSetMessageNumber,\n                                WireFormatLite::WIRETYPE_LENGTH_DELIMITED);\n\n  // Byte size of all tags of a MessageSet::Item combined.\n  static const int kMessageSetItemTagsSize;\n\n  // Helper functions for converting between floats/doubles and IEEE-754\n  // uint32s/uint64s so that they can be written.  (Assumes your platform\n  // uses IEEE-754 floats.)\n  static uint32 EncodeFloat(float value);\n  static float DecodeFloat(uint32 value);\n  static uint64 EncodeDouble(double value);\n  static double DecodeDouble(uint64 value);\n\n  // Helper functions for mapping signed integers to unsigned integers in\n  // such a way that numbers with small magnitudes will encode to smaller\n  // varints.  If you simply static_cast a negative number to an unsigned\n  // number and varint-encode it, it will always take 10 bytes, defeating\n  // the purpose of varint.  So, for the \"sint32\" and \"sint64\" field types,\n  // we ZigZag-encode the values.\n  static uint32 ZigZagEncode32(int32 n);\n  static int32  ZigZagDecode32(uint32 n);\n  static uint64 ZigZagEncode64(int64 n);\n  static int64  ZigZagDecode64(uint64 n);\n\n  // =================================================================\n  // Methods for reading/writing individual field.  The implementations\n  // of these methods are defined in wire_format_lite_inl.h; you must #include\n  // that file to use these.\n\n// Avoid ugly line wrapping\n#define input  io::CodedInputStream*  input_arg\n#define output io::CodedOutputStream* output_arg\n#define field_number int field_number_arg\n#define INL GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n\n  // Read fields, not including tags.  The assumption is that you already\n  // read the tag to determine what field to read.\n\n  // For primitive fields, we just use a templatized routine parameterized by\n  // the represented type and the FieldType. These are specialized with the\n  // appropriate definition for each declared type.\n  template <typename CType, enum FieldType DeclaredType> INL\n  static bool ReadPrimitive(input, CType* value);\n\n  // Reads repeated primitive values, with optimizations for repeats.\n  // tag_size and tag should both be compile-time constants provided by the\n  // protocol compiler.\n  template <typename CType, enum FieldType DeclaredType> INL\n  static bool ReadRepeatedPrimitive(int tag_size,\n                                    uint32 tag,\n                                    input,\n                                    RepeatedField<CType>* value);\n\n  // Identical to ReadRepeatedPrimitive, except will not inline the\n  // implementation.\n  template <typename CType, enum FieldType DeclaredType>\n  static bool ReadRepeatedPrimitiveNoInline(int tag_size,\n                                            uint32 tag,\n                                            input,\n                                            RepeatedField<CType>* value);\n\n  // Reads a primitive value directly from the provided buffer. It returns a\n  // pointer past the segment of data that was read.\n  //\n  // This is only implemented for the types with fixed wire size, e.g.\n  // float, double, and the (s)fixed* types.\n  template <typename CType, enum FieldType DeclaredType> INL\n  static const uint8* ReadPrimitiveFromArray(const uint8* buffer, CType* value);\n\n  // Reads a primitive packed field.\n  //\n  // This is only implemented for packable types.\n  template <typename CType, enum FieldType DeclaredType> INL\n  static bool ReadPackedPrimitive(input, RepeatedField<CType>* value);\n\n  // Identical to ReadPackedPrimitive, except will not inline the\n  // implementation.\n  template <typename CType, enum FieldType DeclaredType>\n  static bool ReadPackedPrimitiveNoInline(input, RepeatedField<CType>* value);\n\n  // Read a packed enum field. If the is_valid function is not NULL, values for\n  // which is_valid(value) returns false are silently dropped.\n  static bool ReadPackedEnumNoInline(input,\n                                     bool (*is_valid)(int),\n                                     RepeatedField<int>* values);\n\n  // Read a packed enum field. If the is_valid function is not NULL, values for\n  // which is_valid(value) returns false are appended to unknown_fields_stream.\n  static bool ReadPackedEnumPreserveUnknowns(\n      input,\n      field_number,\n      bool (*is_valid)(int),\n      io::CodedOutputStream* unknown_fields_stream,\n      RepeatedField<int>* values);\n\n  // Read a string.  ReadString(..., string* value) requires an existing string.\n  static inline bool ReadString(input, string* value);\n  // ReadString(..., string** p) is internal-only, and should only be called\n  // from generated code. It starts by setting *p to \"new string\"\n  // if *p == &GetEmptyStringAlreadyInited().  It then invokes\n  // ReadString(input, *p).  This is useful for reducing code size.\n  static inline bool ReadString(input, string** p);\n  // Analogous to ReadString().\n  static bool ReadBytes(input, string* value);\n  static bool ReadBytes(input, string** p);\n\n\n  enum Operation {\n    PARSE = 0,\n    SERIALIZE = 1,\n  };\n\n  // Returns true if the data is valid UTF-8.\n  static bool VerifyUtf8String(const char* data, int size,\n                               Operation op,\n                               const char* field_name);\n\n  static inline bool ReadGroup  (field_number, input, MessageLite* value);\n  static inline bool ReadMessage(input, MessageLite* value);\n\n  // Like above, but de-virtualize the call to MergePartialFromCodedStream().\n  // The pointer must point at an instance of MessageType, *not* a subclass (or\n  // the subclass must not override MergePartialFromCodedStream()).\n  template<typename MessageType>\n  static inline bool ReadGroupNoVirtual(field_number, input,\n                                        MessageType* value);\n  template<typename MessageType>\n  static inline bool ReadMessageNoVirtual(input, MessageType* value);\n\n  // The same, but do not modify input's recursion depth.  This is useful\n  // when reading a bunch of groups or messages in a loop, because then the\n  // recursion depth can be incremented before the loop and decremented after.\n  template<typename MessageType>\n  static inline bool ReadGroupNoVirtualNoRecursionDepth(field_number, input,\n                                                        MessageType* value);\n\n  template<typename MessageType>\n  static inline bool ReadMessageNoVirtualNoRecursionDepth(input,\n                                                          MessageType* value);\n\n  // Write a tag.  The Write*() functions typically include the tag, so\n  // normally there's no need to call this unless using the Write*NoTag()\n  // variants.\n  INL static void WriteTag(field_number, WireType type, output);\n\n  // Write fields, without tags.\n  INL static void WriteInt32NoTag   (int32 value, output);\n  INL static void WriteInt64NoTag   (int64 value, output);\n  INL static void WriteUInt32NoTag  (uint32 value, output);\n  INL static void WriteUInt64NoTag  (uint64 value, output);\n  INL static void WriteSInt32NoTag  (int32 value, output);\n  INL static void WriteSInt64NoTag  (int64 value, output);\n  INL static void WriteFixed32NoTag (uint32 value, output);\n  INL static void WriteFixed64NoTag (uint64 value, output);\n  INL static void WriteSFixed32NoTag(int32 value, output);\n  INL static void WriteSFixed64NoTag(int64 value, output);\n  INL static void WriteFloatNoTag   (float value, output);\n  INL static void WriteDoubleNoTag  (double value, output);\n  INL static void WriteBoolNoTag    (bool value, output);\n  INL static void WriteEnumNoTag    (int value, output);\n\n  // Write fields, including tags.\n  static void WriteInt32   (field_number,  int32 value, output);\n  static void WriteInt64   (field_number,  int64 value, output);\n  static void WriteUInt32  (field_number, uint32 value, output);\n  static void WriteUInt64  (field_number, uint64 value, output);\n  static void WriteSInt32  (field_number,  int32 value, output);\n  static void WriteSInt64  (field_number,  int64 value, output);\n  static void WriteFixed32 (field_number, uint32 value, output);\n  static void WriteFixed64 (field_number, uint64 value, output);\n  static void WriteSFixed32(field_number,  int32 value, output);\n  static void WriteSFixed64(field_number,  int64 value, output);\n  static void WriteFloat   (field_number,  float value, output);\n  static void WriteDouble  (field_number, double value, output);\n  static void WriteBool    (field_number,   bool value, output);\n  static void WriteEnum    (field_number,    int value, output);\n\n  static void WriteString(field_number, const string& value, output);\n  static void WriteBytes (field_number, const string& value, output);\n  static void WriteStringMaybeAliased(\n      field_number, const string& value, output);\n  static void WriteBytesMaybeAliased(\n      field_number, const string& value, output);\n\n  static void WriteGroup(\n    field_number, const MessageLite& value, output);\n  static void WriteMessage(\n    field_number, const MessageLite& value, output);\n  // Like above, but these will check if the output stream has enough\n  // space to write directly to a flat array.\n  static void WriteGroupMaybeToArray(\n    field_number, const MessageLite& value, output);\n  static void WriteMessageMaybeToArray(\n    field_number, const MessageLite& value, output);\n\n  // Like above, but de-virtualize the call to SerializeWithCachedSizes().  The\n  // pointer must point at an instance of MessageType, *not* a subclass (or\n  // the subclass must not override SerializeWithCachedSizes()).\n  template<typename MessageType>\n  static inline void WriteGroupNoVirtual(\n    field_number, const MessageType& value, output);\n  template<typename MessageType>\n  static inline void WriteMessageNoVirtual(\n    field_number, const MessageType& value, output);\n\n#undef output\n#define output uint8* target\n\n  // Like above, but use only *ToArray methods of CodedOutputStream.\n  INL static uint8* WriteTagToArray(field_number, WireType type, output);\n\n  // Write fields, without tags.\n  INL static uint8* WriteInt32NoTagToArray   (int32 value, output);\n  INL static uint8* WriteInt64NoTagToArray   (int64 value, output);\n  INL static uint8* WriteUInt32NoTagToArray  (uint32 value, output);\n  INL static uint8* WriteUInt64NoTagToArray  (uint64 value, output);\n  INL static uint8* WriteSInt32NoTagToArray  (int32 value, output);\n  INL static uint8* WriteSInt64NoTagToArray  (int64 value, output);\n  INL static uint8* WriteFixed32NoTagToArray (uint32 value, output);\n  INL static uint8* WriteFixed64NoTagToArray (uint64 value, output);\n  INL static uint8* WriteSFixed32NoTagToArray(int32 value, output);\n  INL static uint8* WriteSFixed64NoTagToArray(int64 value, output);\n  INL static uint8* WriteFloatNoTagToArray   (float value, output);\n  INL static uint8* WriteDoubleNoTagToArray  (double value, output);\n  INL static uint8* WriteBoolNoTagToArray    (bool value, output);\n  INL static uint8* WriteEnumNoTagToArray    (int value, output);\n\n  // Write fields, including tags.\n  INL static uint8* WriteInt32ToArray(field_number, int32 value, output);\n  INL static uint8* WriteInt64ToArray(field_number, int64 value, output);\n  INL static uint8* WriteUInt32ToArray(field_number, uint32 value, output);\n  INL static uint8* WriteUInt64ToArray(field_number, uint64 value, output);\n  INL static uint8* WriteSInt32ToArray(field_number, int32 value, output);\n  INL static uint8* WriteSInt64ToArray(field_number, int64 value, output);\n  INL static uint8* WriteFixed32ToArray(field_number, uint32 value, output);\n  INL static uint8* WriteFixed64ToArray(field_number, uint64 value, output);\n  INL static uint8* WriteSFixed32ToArray(field_number, int32 value, output);\n  INL static uint8* WriteSFixed64ToArray(field_number, int64 value, output);\n  INL static uint8* WriteFloatToArray(field_number, float value, output);\n  INL static uint8* WriteDoubleToArray(field_number, double value, output);\n  INL static uint8* WriteBoolToArray(field_number, bool value, output);\n  INL static uint8* WriteEnumToArray(field_number, int value, output);\n\n  INL static uint8* WriteStringToArray(\n    field_number, const string& value, output);\n  INL static uint8* WriteBytesToArray(\n    field_number, const string& value, output);\n\n  // Whether to serialize deterministically (e.g., map keys are\n  // sorted) is a property of a CodedOutputStream, and in the process\n  // of serialization, the \"ToArray\" variants may be invoked.  But they don't\n  // have a CodedOutputStream available, so they get an additional parameter\n  // telling them whether to serialize deterministically.\n  INL static uint8* InternalWriteGroupToArray(\n      field_number, const MessageLite& value, bool deterministic, output);\n  INL static uint8* InternalWriteMessageToArray(\n      field_number, const MessageLite& value, bool deterministic, output);\n\n  // Like above, but de-virtualize the call to SerializeWithCachedSizes().  The\n  // pointer must point at an instance of MessageType, *not* a subclass (or\n  // the subclass must not override SerializeWithCachedSizes()).\n  template<typename MessageType>\n  INL static uint8* InternalWriteGroupNoVirtualToArray(\n    field_number, const MessageType& value, bool deterministic, output);\n  template<typename MessageType>\n  INL static uint8* InternalWriteMessageNoVirtualToArray(\n    field_number, const MessageType& value, bool deterministic, output);\n\n  // For backward-compatibility, the last four methods also have versions\n  // that are non-deterministic always.\n  INL static uint8* WriteGroupToArray(\n      field_number, const MessageLite& value, output) {\n    return InternalWriteGroupToArray(field_number_arg, value, false, target);\n  }\n  INL static uint8* WriteMessageToArray(\n      field_number, const MessageLite& value, output) {\n    return InternalWriteMessageToArray(field_number_arg, value, false, target);\n  }\n  template<typename MessageType>\n  INL static uint8* WriteGroupNoVirtualToArray(\n      field_number, const MessageType& value, output) {\n    return InternalWriteGroupNoVirtualToArray(field_number_arg, value, false,\n                                              target);\n  }\n  template<typename MessageType>\n  INL static uint8* WriteMessageNoVirtualToArray(\n      field_number, const MessageType& value, output) {\n    return InternalWriteMessageNoVirtualToArray(field_number_arg, value, false,\n                                                target);\n  }\n\n#undef output\n#undef input\n#undef INL\n\n#undef field_number\n\n  // Compute the byte size of a field.  The XxSize() functions do NOT include\n  // the tag, so you must also call TagSize().  (This is because, for repeated\n  // fields, you should only call TagSize() once and multiply it by the element\n  // count, but you may have to call XxSize() for each individual element.)\n  static inline int Int32Size   ( int32 value);\n  static inline int Int64Size   ( int64 value);\n  static inline int UInt32Size  (uint32 value);\n  static inline int UInt64Size  (uint64 value);\n  static inline int SInt32Size  ( int32 value);\n  static inline int SInt64Size  ( int64 value);\n  static inline int EnumSize    (   int value);\n\n  // These types always have the same size.\n  static const int kFixed32Size  = 4;\n  static const int kFixed64Size  = 8;\n  static const int kSFixed32Size = 4;\n  static const int kSFixed64Size = 8;\n  static const int kFloatSize    = 4;\n  static const int kDoubleSize   = 8;\n  static const int kBoolSize     = 1;\n\n  static inline int StringSize(const string& value);\n  static inline int BytesSize (const string& value);\n\n  static inline int GroupSize  (const MessageLite& value);\n  static inline int MessageSize(const MessageLite& value);\n\n  // Like above, but de-virtualize the call to ByteSize().  The\n  // pointer must point at an instance of MessageType, *not* a subclass (or\n  // the subclass must not override ByteSize()).\n  template<typename MessageType>\n  static inline int GroupSizeNoVirtual  (const MessageType& value);\n  template<typename MessageType>\n  static inline int MessageSizeNoVirtual(const MessageType& value);\n\n  // Given the length of data, calculate the byte size of the data on the\n  // wire if we encode the data as a length delimited field.\n  static inline int LengthDelimitedSize(int length);\n\n private:\n  // A helper method for the repeated primitive reader. This method has\n  // optimizations for primitive types that have fixed size on the wire, and\n  // can be read using potentially faster paths.\n  template <typename CType, enum FieldType DeclaredType> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  static bool ReadRepeatedFixedSizePrimitive(\n      int tag_size,\n      uint32 tag,\n      google::protobuf::io::CodedInputStream* input,\n      RepeatedField<CType>* value);\n\n  // Like ReadRepeatedFixedSizePrimitive but for packed primitive fields.\n  template <typename CType, enum FieldType DeclaredType> GOOGLE_ATTRIBUTE_ALWAYS_INLINE\n  static bool ReadPackedFixedSizePrimitive(google::protobuf::io::CodedInputStream* input,\n                                           RepeatedField<CType>* value);\n\n  static const CppType kFieldTypeToCppTypeMap[];\n  static const WireFormatLite::WireType kWireTypeForFieldType[];\n\n  GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(WireFormatLite);\n};\n\n// A class which deals with unknown values.  The default implementation just\n// discards them.  WireFormat defines a subclass which writes to an\n// UnknownFieldSet.  This class is used by ExtensionSet::ParseField(), since\n// ExtensionSet is part of the lite library but UnknownFieldSet is not.\nclass LIBPROTOBUF_EXPORT FieldSkipper {\n public:\n  FieldSkipper() {}\n  virtual ~FieldSkipper() {}\n\n  // Skip a field whose tag has already been consumed.\n  virtual bool SkipField(io::CodedInputStream* input, uint32 tag);\n\n  // Skip an entire message or group, up to an end-group tag (which is consumed)\n  // or end-of-stream.\n  virtual bool SkipMessage(io::CodedInputStream* input);\n\n  // Deal with an already-parsed unrecognized enum value.  The default\n  // implementation does nothing, but the UnknownFieldSet-based implementation\n  // saves it as an unknown varint.\n  virtual void SkipUnknownEnum(int field_number, int value);\n};\n\n// Subclass of FieldSkipper which saves skipped fields to a CodedOutputStream.\n\nclass LIBPROTOBUF_EXPORT CodedOutputStreamFieldSkipper : public FieldSkipper {\n public:\n  explicit CodedOutputStreamFieldSkipper(io::CodedOutputStream* unknown_fields)\n      : unknown_fields_(unknown_fields) {}\n  virtual ~CodedOutputStreamFieldSkipper() {}\n\n  // implements FieldSkipper -----------------------------------------\n  virtual bool SkipField(io::CodedInputStream* input, uint32 tag);\n  virtual bool SkipMessage(io::CodedInputStream* input);\n  virtual void SkipUnknownEnum(int field_number, int value);\n\n protected:\n  io::CodedOutputStream* unknown_fields_;\n};\n\n\n// inline methods ====================================================\n\ninline WireFormatLite::CppType\nWireFormatLite::FieldTypeToCppType(FieldType type) {\n  return kFieldTypeToCppTypeMap[type];\n}\n\ninline uint32 WireFormatLite::MakeTag(int field_number, WireType type) {\n  return GOOGLE_PROTOBUF_WIRE_FORMAT_MAKE_TAG(field_number, type);\n}\n\ninline WireFormatLite::WireType WireFormatLite::GetTagWireType(uint32 tag) {\n  return static_cast<WireType>(tag & kTagTypeMask);\n}\n\ninline int WireFormatLite::GetTagFieldNumber(uint32 tag) {\n  return static_cast<int>(tag >> kTagTypeBits);\n}\n\ninline int WireFormatLite::TagSize(int field_number,\n                                   WireFormatLite::FieldType type) {\n  int result = io::CodedOutputStream::VarintSize32(\n    field_number << kTagTypeBits);\n  if (type == TYPE_GROUP) {\n    // Groups have both a start and an end tag.\n    return result * 2;\n  } else {\n    return result;\n  }\n}\n\ninline uint32 WireFormatLite::EncodeFloat(float value) {\n  union {float f; uint32 i;};\n  f = value;\n  return i;\n}\n\ninline float WireFormatLite::DecodeFloat(uint32 value) {\n  union {float f; uint32 i;};\n  i = value;\n  return f;\n}\n\ninline uint64 WireFormatLite::EncodeDouble(double value) {\n  union {double f; uint64 i;};\n  f = value;\n  return i;\n}\n\ninline double WireFormatLite::DecodeDouble(uint64 value) {\n  union {double f; uint64 i;};\n  i = value;\n  return f;\n}\n\n// ZigZag Transform:  Encodes signed integers so that they can be\n// effectively used with varint encoding.\n//\n// varint operates on unsigned integers, encoding smaller numbers into\n// fewer bytes.  If you try to use it on a signed integer, it will treat\n// this number as a very large unsigned integer, which means that even\n// small signed numbers like -1 will take the maximum number of bytes\n// (10) to encode.  ZigZagEncode() maps signed integers to unsigned\n// in such a way that those with a small absolute value will have smaller\n// encoded values, making them appropriate for encoding using varint.\n//\n//       int32 ->     uint32\n// -------------------------\n//           0 ->          0\n//          -1 ->          1\n//           1 ->          2\n//          -2 ->          3\n//         ... ->        ...\n//  2147483647 -> 4294967294\n// -2147483648 -> 4294967295\n//\n//        >> encode >>\n//        << decode <<\n\ninline uint32 WireFormatLite::ZigZagEncode32(int32 n) {\n  // Note:  the right-shift must be arithmetic\n  return (static_cast<uint32>(n) << 1) ^ (n >> 31);\n}\n\ninline int32 WireFormatLite::ZigZagDecode32(uint32 n) {\n  return (n >> 1) ^ -static_cast<int32>(n & 1);\n}\n\ninline uint64 WireFormatLite::ZigZagEncode64(int64 n) {\n  // Note:  the right-shift must be arithmetic\n  return (static_cast<uint64>(n) << 1) ^ (n >> 63);\n}\n\ninline int64 WireFormatLite::ZigZagDecode64(uint64 n) {\n  return (n >> 1) ^ -static_cast<int64>(n & 1);\n}\n\n// String is for UTF-8 text only, but, even so, ReadString() can simply\n// call ReadBytes().\n\ninline bool WireFormatLite::ReadString(io::CodedInputStream* input,\n                                       string* value) {\n  return ReadBytes(input, value);\n}\n\ninline bool WireFormatLite::ReadString(io::CodedInputStream* input,\n                                       string** p) {\n  return ReadBytes(input, p);\n}\n\n}  // namespace internal\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/wire_format_lite_inl.h",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//         wink@google.com (Wink Saville) (refactored from wire_format.h)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#ifndef GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_INL_H__\n#define GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_INL_H__\n\n#ifdef _MSC_VER\n// This is required for min/max on VS2013 only.\n#include <algorithm>\n#endif\n\n#include <string>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/message_lite.h>\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/wire_format_lite.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/arenastring.h>\n\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\n\n// Implementation details of ReadPrimitive.\n\ntemplate <>\ninline bool WireFormatLite::ReadPrimitive<int32, WireFormatLite::TYPE_INT32>(\n    io::CodedInputStream* input,\n    int32* value) {\n  uint32 temp;\n  if (!input->ReadVarint32(&temp)) return false;\n  *value = static_cast<int32>(temp);\n  return true;\n}\ntemplate <>\ninline bool WireFormatLite::ReadPrimitive<int64, WireFormatLite::TYPE_INT64>(\n    io::CodedInputStream* input,\n    int64* value) {\n  uint64 temp;\n  if (!input->ReadVarint64(&temp)) return false;\n  *value = static_cast<int64>(temp);\n  return true;\n}\ntemplate <>\ninline bool WireFormatLite::ReadPrimitive<uint32, WireFormatLite::TYPE_UINT32>(\n    io::CodedInputStream* input,\n    uint32* value) {\n  return input->ReadVarint32(value);\n}\ntemplate <>\ninline bool WireFormatLite::ReadPrimitive<uint64, WireFormatLite::TYPE_UINT64>(\n    io::CodedInputStream* input,\n    uint64* value) {\n  return input->ReadVarint64(value);\n}\ntemplate <>\ninline bool WireFormatLite::ReadPrimitive<int32, WireFormatLite::TYPE_SINT32>(\n    io::CodedInputStream* input,\n    int32* value) {\n  uint32 temp;\n  if (!input->ReadVarint32(&temp)) return false;\n  *value = ZigZagDecode32(temp);\n  return true;\n}\ntemplate <>\ninline bool WireFormatLite::ReadPrimitive<int64, WireFormatLite::TYPE_SINT64>(\n    io::CodedInputStream* input,\n    int64* value) {\n  uint64 temp;\n  if (!input->ReadVarint64(&temp)) return false;\n  *value = ZigZagDecode64(temp);\n  return true;\n}\ntemplate <>\ninline bool WireFormatLite::ReadPrimitive<uint32, WireFormatLite::TYPE_FIXED32>(\n    io::CodedInputStream* input,\n    uint32* value) {\n  return input->ReadLittleEndian32(value);\n}\ntemplate <>\ninline bool WireFormatLite::ReadPrimitive<uint64, WireFormatLite::TYPE_FIXED64>(\n    io::CodedInputStream* input,\n    uint64* value) {\n  return input->ReadLittleEndian64(value);\n}\ntemplate <>\ninline bool WireFormatLite::ReadPrimitive<int32, WireFormatLite::TYPE_SFIXED32>(\n    io::CodedInputStream* input,\n    int32* value) {\n  uint32 temp;\n  if (!input->ReadLittleEndian32(&temp)) return false;\n  *value = static_cast<int32>(temp);\n  return true;\n}\ntemplate <>\ninline bool WireFormatLite::ReadPrimitive<int64, WireFormatLite::TYPE_SFIXED64>(\n    io::CodedInputStream* input,\n    int64* value) {\n  uint64 temp;\n  if (!input->ReadLittleEndian64(&temp)) return false;\n  *value = static_cast<int64>(temp);\n  return true;\n}\ntemplate <>\ninline bool WireFormatLite::ReadPrimitive<float, WireFormatLite::TYPE_FLOAT>(\n    io::CodedInputStream* input,\n    float* value) {\n  uint32 temp;\n  if (!input->ReadLittleEndian32(&temp)) return false;\n  *value = DecodeFloat(temp);\n  return true;\n}\ntemplate <>\ninline bool WireFormatLite::ReadPrimitive<double, WireFormatLite::TYPE_DOUBLE>(\n    io::CodedInputStream* input,\n    double* value) {\n  uint64 temp;\n  if (!input->ReadLittleEndian64(&temp)) return false;\n  *value = DecodeDouble(temp);\n  return true;\n}\ntemplate <>\ninline bool WireFormatLite::ReadPrimitive<bool, WireFormatLite::TYPE_BOOL>(\n    io::CodedInputStream* input,\n    bool* value) {\n  uint64 temp;\n  if (!input->ReadVarint64(&temp)) return false;\n  *value = temp != 0;\n  return true;\n}\ntemplate <>\ninline bool WireFormatLite::ReadPrimitive<int, WireFormatLite::TYPE_ENUM>(\n    io::CodedInputStream* input,\n    int* value) {\n  uint32 temp;\n  if (!input->ReadVarint32(&temp)) return false;\n  *value = static_cast<int>(temp);\n  return true;\n}\n\ntemplate <>\ninline const uint8* WireFormatLite::ReadPrimitiveFromArray<\n  uint32, WireFormatLite::TYPE_FIXED32>(\n    const uint8* buffer,\n    uint32* value) {\n  return io::CodedInputStream::ReadLittleEndian32FromArray(buffer, value);\n}\ntemplate <>\ninline const uint8* WireFormatLite::ReadPrimitiveFromArray<\n  uint64, WireFormatLite::TYPE_FIXED64>(\n    const uint8* buffer,\n    uint64* value) {\n  return io::CodedInputStream::ReadLittleEndian64FromArray(buffer, value);\n}\ntemplate <>\ninline const uint8* WireFormatLite::ReadPrimitiveFromArray<\n  int32, WireFormatLite::TYPE_SFIXED32>(\n    const uint8* buffer,\n    int32* value) {\n  uint32 temp;\n  buffer = io::CodedInputStream::ReadLittleEndian32FromArray(buffer, &temp);\n  *value = static_cast<int32>(temp);\n  return buffer;\n}\ntemplate <>\ninline const uint8* WireFormatLite::ReadPrimitiveFromArray<\n  int64, WireFormatLite::TYPE_SFIXED64>(\n    const uint8* buffer,\n    int64* value) {\n  uint64 temp;\n  buffer = io::CodedInputStream::ReadLittleEndian64FromArray(buffer, &temp);\n  *value = static_cast<int64>(temp);\n  return buffer;\n}\ntemplate <>\ninline const uint8* WireFormatLite::ReadPrimitiveFromArray<\n  float, WireFormatLite::TYPE_FLOAT>(\n    const uint8* buffer,\n    float* value) {\n  uint32 temp;\n  buffer = io::CodedInputStream::ReadLittleEndian32FromArray(buffer, &temp);\n  *value = DecodeFloat(temp);\n  return buffer;\n}\ntemplate <>\ninline const uint8* WireFormatLite::ReadPrimitiveFromArray<\n  double, WireFormatLite::TYPE_DOUBLE>(\n    const uint8* buffer,\n    double* value) {\n  uint64 temp;\n  buffer = io::CodedInputStream::ReadLittleEndian64FromArray(buffer, &temp);\n  *value = DecodeDouble(temp);\n  return buffer;\n}\n\ntemplate <typename CType, enum WireFormatLite::FieldType DeclaredType>\ninline bool WireFormatLite::ReadRepeatedPrimitive(\n    int,  // tag_size, unused.\n    uint32 tag,\n    io::CodedInputStream* input,\n    RepeatedField<CType>* values) {\n  CType value;\n  if (!ReadPrimitive<CType, DeclaredType>(input, &value)) return false;\n  values->Add(value);\n  int elements_already_reserved = values->Capacity() - values->size();\n  while (elements_already_reserved > 0 && input->ExpectTag(tag)) {\n    if (!ReadPrimitive<CType, DeclaredType>(input, &value)) return false;\n    values->AddAlreadyReserved(value);\n    elements_already_reserved--;\n  }\n  return true;\n}\n\ntemplate <typename CType, enum WireFormatLite::FieldType DeclaredType>\ninline bool WireFormatLite::ReadRepeatedFixedSizePrimitive(\n    int tag_size,\n    uint32 tag,\n    io::CodedInputStream* input,\n    RepeatedField<CType>* values) {\n  GOOGLE_DCHECK_EQ(UInt32Size(tag), tag_size);\n  CType value;\n  if (!ReadPrimitive<CType, DeclaredType>(input, &value))\n    return false;\n  values->Add(value);\n\n  // For fixed size values, repeated values can be read more quickly by\n  // reading directly from a raw array.\n  //\n  // We can get a tight loop by only reading as many elements as can be\n  // added to the RepeatedField without having to do any resizing. Additionally,\n  // we only try to read as many elements as are available from the current\n  // buffer space. Doing so avoids having to perform boundary checks when\n  // reading the value: the maximum number of elements that can be read is\n  // known outside of the loop.\n  const void* void_pointer;\n  int size;\n  input->GetDirectBufferPointerInline(&void_pointer, &size);\n  if (size > 0) {\n    const uint8* buffer = reinterpret_cast<const uint8*>(void_pointer);\n    // The number of bytes each type occupies on the wire.\n    const int per_value_size = tag_size + sizeof(value);\n\n    int elements_available =\n        std::min(values->Capacity() - values->size(), size / per_value_size);\n    int num_read = 0;\n    while (num_read < elements_available &&\n           (buffer = io::CodedInputStream::ExpectTagFromArray(\n               buffer, tag)) != NULL) {\n      buffer = ReadPrimitiveFromArray<CType, DeclaredType>(buffer, &value);\n      values->AddAlreadyReserved(value);\n      ++num_read;\n    }\n    const int read_bytes = num_read * per_value_size;\n    if (read_bytes > 0) {\n      input->Skip(read_bytes);\n    }\n  }\n  return true;\n}\n\n// Specializations of ReadRepeatedPrimitive for the fixed size types, which use\n// the optimized code path.\n#define READ_REPEATED_FIXED_SIZE_PRIMITIVE(CPPTYPE, DECLARED_TYPE)             \\\ntemplate <>                                                                    \\\ninline bool WireFormatLite::ReadRepeatedPrimitive<                             \\\n  CPPTYPE, WireFormatLite::DECLARED_TYPE>(                                     \\\n    int tag_size,                                                              \\\n    uint32 tag,                                                                \\\n    io::CodedInputStream* input,                                               \\\n    RepeatedField<CPPTYPE>* values) {                                          \\\n  return ReadRepeatedFixedSizePrimitive<                                       \\\n    CPPTYPE, WireFormatLite::DECLARED_TYPE>(                                   \\\n      tag_size, tag, input, values);                                           \\\n}\n\nREAD_REPEATED_FIXED_SIZE_PRIMITIVE(uint32, TYPE_FIXED32)\nREAD_REPEATED_FIXED_SIZE_PRIMITIVE(uint64, TYPE_FIXED64)\nREAD_REPEATED_FIXED_SIZE_PRIMITIVE(int32, TYPE_SFIXED32)\nREAD_REPEATED_FIXED_SIZE_PRIMITIVE(int64, TYPE_SFIXED64)\nREAD_REPEATED_FIXED_SIZE_PRIMITIVE(float, TYPE_FLOAT)\nREAD_REPEATED_FIXED_SIZE_PRIMITIVE(double, TYPE_DOUBLE)\n\n#undef READ_REPEATED_FIXED_SIZE_PRIMITIVE\n\ntemplate <typename CType, enum WireFormatLite::FieldType DeclaredType>\nbool WireFormatLite::ReadRepeatedPrimitiveNoInline(\n    int tag_size,\n    uint32 tag,\n    io::CodedInputStream* input,\n    RepeatedField<CType>* value) {\n  return ReadRepeatedPrimitive<CType, DeclaredType>(\n      tag_size, tag, input, value);\n}\n\ntemplate <typename CType, enum WireFormatLite::FieldType DeclaredType>\ninline bool WireFormatLite::ReadPackedPrimitive(io::CodedInputStream* input,\n                                                RepeatedField<CType>* values) {\n  int length;\n  if (!input->ReadVarintSizeAsInt(&length)) return false;\n  io::CodedInputStream::Limit limit = input->PushLimit(length);\n  while (input->BytesUntilLimit() > 0) {\n    CType value;\n    if (!ReadPrimitive<CType, DeclaredType>(input, &value)) return false;\n    values->Add(value);\n  }\n  input->PopLimit(limit);\n  return true;\n}\n\ntemplate <typename CType, enum WireFormatLite::FieldType DeclaredType>\ninline bool WireFormatLite::ReadPackedFixedSizePrimitive(\n    io::CodedInputStream* input, RepeatedField<CType>* values) {\n  int length;\n  if (!input->ReadVarintSizeAsInt(&length)) return false;\n  const int old_entries = values->size();\n  const int new_entries = length / sizeof(CType);\n  const int new_bytes = new_entries * sizeof(CType);\n  if (new_bytes != length) return false;\n  // We would *like* to pre-allocate the buffer to write into (for\n  // speed), but *must* avoid performing a very large allocation due\n  // to a malicious user-supplied \"length\" above.  So we have a fast\n  // path that pre-allocates when the \"length\" is less than a bound.\n  // We determine the bound by calling BytesUntilTotalBytesLimit() and\n  // BytesUntilLimit().  These return -1 to mean \"no limit set\".\n  // There are four cases:\n  // TotalBytesLimit  Limit\n  // -1               -1     Use slow path.\n  // -1               >= 0   Use fast path if length <= Limit.\n  // >= 0             -1     Use slow path.\n  // >= 0             >= 0   Use fast path if length <= min(both limits).\n  int64 bytes_limit = input->BytesUntilTotalBytesLimit();\n  if (bytes_limit == -1) {\n    bytes_limit = input->BytesUntilLimit();\n  } else {\n    bytes_limit =\n        std::min(bytes_limit, static_cast<int64>(input->BytesUntilLimit()));\n  }\n  if (bytes_limit >= new_bytes) {\n    // Fast-path that pre-allocates *values to the final size.\n#if defined(PROTOBUF_LITTLE_ENDIAN)\n    values->Resize(old_entries + new_entries, 0);\n    // values->mutable_data() may change after Resize(), so do this after:\n    void* dest = reinterpret_cast<void*>(values->mutable_data() + old_entries);\n    if (!input->ReadRaw(dest, new_bytes)) {\n      values->Truncate(old_entries);\n      return false;\n    }\n#else\n    values->Reserve(old_entries + new_entries);\n    CType value;\n    for (int i = 0; i < new_entries; ++i) {\n      if (!ReadPrimitive<CType, DeclaredType>(input, &value)) return false;\n      values->AddAlreadyReserved(value);\n    }\n#endif\n  } else {\n    // This is the slow-path case where \"length\" may be too large to\n    // safely allocate.  We read as much as we can into *values\n    // without pre-allocating \"length\" bytes.\n    CType value;\n    for (int i = 0; i < new_entries; ++i) {\n      if (!ReadPrimitive<CType, DeclaredType>(input, &value)) return false;\n      values->Add(value);\n    }\n  }\n  return true;\n}\n\n// Specializations of ReadPackedPrimitive for the fixed size types, which use\n// an optimized code path.\n#define READ_REPEATED_PACKED_FIXED_SIZE_PRIMITIVE(CPPTYPE, DECLARED_TYPE)      \\\ntemplate <>                                                                    \\\ninline bool WireFormatLite::ReadPackedPrimitive<                               \\\n  CPPTYPE, WireFormatLite::DECLARED_TYPE>(                                     \\\n    io::CodedInputStream* input,                                               \\\n    RepeatedField<CPPTYPE>* values) {                                          \\\n  return ReadPackedFixedSizePrimitive<                                         \\\n      CPPTYPE, WireFormatLite::DECLARED_TYPE>(input, values);                  \\\n}\n\nREAD_REPEATED_PACKED_FIXED_SIZE_PRIMITIVE(uint32, TYPE_FIXED32)\nREAD_REPEATED_PACKED_FIXED_SIZE_PRIMITIVE(uint64, TYPE_FIXED64)\nREAD_REPEATED_PACKED_FIXED_SIZE_PRIMITIVE(int32, TYPE_SFIXED32)\nREAD_REPEATED_PACKED_FIXED_SIZE_PRIMITIVE(int64, TYPE_SFIXED64)\nREAD_REPEATED_PACKED_FIXED_SIZE_PRIMITIVE(float, TYPE_FLOAT)\nREAD_REPEATED_PACKED_FIXED_SIZE_PRIMITIVE(double, TYPE_DOUBLE)\n\n#undef READ_REPEATED_PACKED_FIXED_SIZE_PRIMITIVE\n\ntemplate <typename CType, enum WireFormatLite::FieldType DeclaredType>\nbool WireFormatLite::ReadPackedPrimitiveNoInline(io::CodedInputStream* input,\n                                                 RepeatedField<CType>* values) {\n  return ReadPackedPrimitive<CType, DeclaredType>(input, values);\n}\n\n\n\ninline bool WireFormatLite::ReadGroup(int field_number,\n                                      io::CodedInputStream* input,\n                                      MessageLite* value) {\n  if (!input->IncrementRecursionDepth()) return false;\n  if (!value->MergePartialFromCodedStream(input)) return false;\n  input->DecrementRecursionDepth();\n  // Make sure the last thing read was an end tag for this group.\n  if (!input->LastTagWas(MakeTag(field_number, WIRETYPE_END_GROUP))) {\n    return false;\n  }\n  return true;\n}\ninline bool WireFormatLite::ReadMessage(io::CodedInputStream* input,\n                                        MessageLite* value) {\n  int length;\n  if (!input->ReadVarintSizeAsInt(&length)) return false;\n  std::pair<io::CodedInputStream::Limit, int> p =\n      input->IncrementRecursionDepthAndPushLimit(length);\n  if (p.second < 0 || !value->MergePartialFromCodedStream(input)) return false;\n  // Make sure that parsing stopped when the limit was hit, not at an endgroup\n  // tag.\n  return input->DecrementRecursionDepthAndPopLimit(p.first);\n}\n\n// We name the template parameter something long and extremely unlikely to occur\n// elsewhere because a *qualified* member access expression designed to avoid\n// virtual dispatch, C++03 [basic.lookup.classref] 3.4.5/4 requires that the\n// name of the qualifying class to be looked up both in the context of the full\n// expression (finding the template parameter) and in the context of the object\n// whose member we are accessing. This could potentially find a nested type\n// within that object. The standard goes on to require these names to refer to\n// the same entity, which this collision would violate. The lack of a safe way\n// to avoid this collision appears to be a defect in the standard, but until it\n// is corrected, we choose the name to avoid accidental collisions.\ntemplate<typename MessageType_WorkAroundCppLookupDefect>\ninline bool WireFormatLite::ReadGroupNoVirtual(\n    int field_number, io::CodedInputStream* input,\n    MessageType_WorkAroundCppLookupDefect* value) {\n  if (!input->IncrementRecursionDepth()) return false;\n  if (!value->\n      MessageType_WorkAroundCppLookupDefect::MergePartialFromCodedStream(input))\n    return false;\n  input->UnsafeDecrementRecursionDepth();\n  // Make sure the last thing read was an end tag for this group.\n  if (!input->LastTagWas(MakeTag(field_number, WIRETYPE_END_GROUP))) {\n    return false;\n  }\n  return true;\n}\ntemplate<typename MessageType_WorkAroundCppLookupDefect>\ninline bool WireFormatLite::ReadGroupNoVirtualNoRecursionDepth(\n    int field_number, io::CodedInputStream* input,\n    MessageType_WorkAroundCppLookupDefect* value) {\n  return value->MessageType_WorkAroundCppLookupDefect::\n             MergePartialFromCodedStream(input) &&\n         input->LastTagWas(MakeTag(field_number, WIRETYPE_END_GROUP));\n}\ntemplate<typename MessageType_WorkAroundCppLookupDefect>\ninline bool WireFormatLite::ReadMessageNoVirtual(\n    io::CodedInputStream* input, MessageType_WorkAroundCppLookupDefect* value) {\n  int length;\n  if (!input->ReadVarintSizeAsInt(&length)) return false;\n  std::pair<io::CodedInputStream::Limit, int> p =\n      input->IncrementRecursionDepthAndPushLimit(length);\n  if (p.second < 0 || !value->\n      MessageType_WorkAroundCppLookupDefect::MergePartialFromCodedStream(input))\n    return false;\n  // Make sure that parsing stopped when the limit was hit, not at an endgroup\n  // tag.\n  return input->DecrementRecursionDepthAndPopLimit(p.first);\n}\ntemplate<typename MessageType_WorkAroundCppLookupDefect>\ninline bool WireFormatLite::ReadMessageNoVirtualNoRecursionDepth(\n    io::CodedInputStream* input, MessageType_WorkAroundCppLookupDefect* value) {\n  io::CodedInputStream::Limit old_limit = input->ReadLengthAndPushLimit();\n  if (!value->\n      MessageType_WorkAroundCppLookupDefect::MergePartialFromCodedStream(input))\n    return false;\n  // Make sure that parsing stopped when the limit was hit, not at an endgroup\n  // tag.\n  return input->CheckEntireMessageConsumedAndPopLimit(old_limit);\n}\n\n// ===================================================================\n\ninline void WireFormatLite::WriteTag(int field_number, WireType type,\n                                     io::CodedOutputStream* output) {\n  output->WriteTag(MakeTag(field_number, type));\n}\n\ninline void WireFormatLite::WriteInt32NoTag(int32 value,\n                                            io::CodedOutputStream* output) {\n  output->WriteVarint32SignExtended(value);\n}\ninline void WireFormatLite::WriteInt64NoTag(int64 value,\n                                            io::CodedOutputStream* output) {\n  output->WriteVarint64(static_cast<uint64>(value));\n}\ninline void WireFormatLite::WriteUInt32NoTag(uint32 value,\n                                             io::CodedOutputStream* output) {\n  output->WriteVarint32(value);\n}\ninline void WireFormatLite::WriteUInt64NoTag(uint64 value,\n                                             io::CodedOutputStream* output) {\n  output->WriteVarint64(value);\n}\ninline void WireFormatLite::WriteSInt32NoTag(int32 value,\n                                             io::CodedOutputStream* output) {\n  output->WriteVarint32(ZigZagEncode32(value));\n}\ninline void WireFormatLite::WriteSInt64NoTag(int64 value,\n                                             io::CodedOutputStream* output) {\n  output->WriteVarint64(ZigZagEncode64(value));\n}\ninline void WireFormatLite::WriteFixed32NoTag(uint32 value,\n                                              io::CodedOutputStream* output) {\n  output->WriteLittleEndian32(value);\n}\ninline void WireFormatLite::WriteFixed64NoTag(uint64 value,\n                                              io::CodedOutputStream* output) {\n  output->WriteLittleEndian64(value);\n}\ninline void WireFormatLite::WriteSFixed32NoTag(int32 value,\n                                               io::CodedOutputStream* output) {\n  output->WriteLittleEndian32(static_cast<uint32>(value));\n}\ninline void WireFormatLite::WriteSFixed64NoTag(int64 value,\n                                               io::CodedOutputStream* output) {\n  output->WriteLittleEndian64(static_cast<uint64>(value));\n}\ninline void WireFormatLite::WriteFloatNoTag(float value,\n                                            io::CodedOutputStream* output) {\n  output->WriteLittleEndian32(EncodeFloat(value));\n}\ninline void WireFormatLite::WriteDoubleNoTag(double value,\n                                             io::CodedOutputStream* output) {\n  output->WriteLittleEndian64(EncodeDouble(value));\n}\ninline void WireFormatLite::WriteBoolNoTag(bool value,\n                                           io::CodedOutputStream* output) {\n  output->WriteVarint32(value ? 1 : 0);\n}\ninline void WireFormatLite::WriteEnumNoTag(int value,\n                                           io::CodedOutputStream* output) {\n  output->WriteVarint32SignExtended(value);\n}\n\n// See comment on ReadGroupNoVirtual to understand the need for this template\n// parameter name.\ntemplate<typename MessageType_WorkAroundCppLookupDefect>\ninline void WireFormatLite::WriteGroupNoVirtual(\n    int field_number, const MessageType_WorkAroundCppLookupDefect& value,\n    io::CodedOutputStream* output) {\n  WriteTag(field_number, WIRETYPE_START_GROUP, output);\n  value.MessageType_WorkAroundCppLookupDefect::SerializeWithCachedSizes(output);\n  WriteTag(field_number, WIRETYPE_END_GROUP, output);\n}\ntemplate<typename MessageType_WorkAroundCppLookupDefect>\ninline void WireFormatLite::WriteMessageNoVirtual(\n    int field_number, const MessageType_WorkAroundCppLookupDefect& value,\n    io::CodedOutputStream* output) {\n  WriteTag(field_number, WIRETYPE_LENGTH_DELIMITED, output);\n  output->WriteVarint32(\n      value.MessageType_WorkAroundCppLookupDefect::GetCachedSize());\n  value.MessageType_WorkAroundCppLookupDefect::SerializeWithCachedSizes(output);\n}\n\n// ===================================================================\n\ninline uint8* WireFormatLite::WriteTagToArray(int field_number,\n                                              WireType type,\n                                              uint8* target) {\n  return io::CodedOutputStream::WriteTagToArray(MakeTag(field_number, type),\n                                                target);\n}\n\ninline uint8* WireFormatLite::WriteInt32NoTagToArray(int32 value,\n                                                     uint8* target) {\n  return io::CodedOutputStream::WriteVarint32SignExtendedToArray(value, target);\n}\ninline uint8* WireFormatLite::WriteInt64NoTagToArray(int64 value,\n                                                     uint8* target) {\n  return io::CodedOutputStream::WriteVarint64ToArray(\n      static_cast<uint64>(value), target);\n}\ninline uint8* WireFormatLite::WriteUInt32NoTagToArray(uint32 value,\n                                                      uint8* target) {\n  return io::CodedOutputStream::WriteVarint32ToArray(value, target);\n}\ninline uint8* WireFormatLite::WriteUInt64NoTagToArray(uint64 value,\n                                                      uint8* target) {\n  return io::CodedOutputStream::WriteVarint64ToArray(value, target);\n}\ninline uint8* WireFormatLite::WriteSInt32NoTagToArray(int32 value,\n                                                      uint8* target) {\n  return io::CodedOutputStream::WriteVarint32ToArray(ZigZagEncode32(value),\n                                                     target);\n}\ninline uint8* WireFormatLite::WriteSInt64NoTagToArray(int64 value,\n                                                      uint8* target) {\n  return io::CodedOutputStream::WriteVarint64ToArray(ZigZagEncode64(value),\n                                                     target);\n}\ninline uint8* WireFormatLite::WriteFixed32NoTagToArray(uint32 value,\n                                                       uint8* target) {\n  return io::CodedOutputStream::WriteLittleEndian32ToArray(value, target);\n}\ninline uint8* WireFormatLite::WriteFixed64NoTagToArray(uint64 value,\n                                                       uint8* target) {\n  return io::CodedOutputStream::WriteLittleEndian64ToArray(value, target);\n}\ninline uint8* WireFormatLite::WriteSFixed32NoTagToArray(int32 value,\n                                                        uint8* target) {\n  return io::CodedOutputStream::WriteLittleEndian32ToArray(\n      static_cast<uint32>(value), target);\n}\ninline uint8* WireFormatLite::WriteSFixed64NoTagToArray(int64 value,\n                                                        uint8* target) {\n  return io::CodedOutputStream::WriteLittleEndian64ToArray(\n      static_cast<uint64>(value), target);\n}\ninline uint8* WireFormatLite::WriteFloatNoTagToArray(float value,\n                                                     uint8* target) {\n  return io::CodedOutputStream::WriteLittleEndian32ToArray(EncodeFloat(value),\n                                                           target);\n}\ninline uint8* WireFormatLite::WriteDoubleNoTagToArray(double value,\n                                                      uint8* target) {\n  return io::CodedOutputStream::WriteLittleEndian64ToArray(EncodeDouble(value),\n                                                           target);\n}\ninline uint8* WireFormatLite::WriteBoolNoTagToArray(bool value,\n                                                    uint8* target) {\n  return io::CodedOutputStream::WriteVarint32ToArray(value ? 1 : 0, target);\n}\ninline uint8* WireFormatLite::WriteEnumNoTagToArray(int value,\n                                                    uint8* target) {\n  return io::CodedOutputStream::WriteVarint32SignExtendedToArray(value, target);\n}\n\ninline uint8* WireFormatLite::WriteInt32ToArray(int field_number,\n                                                int32 value,\n                                                uint8* target) {\n  target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);\n  return WriteInt32NoTagToArray(value, target);\n}\ninline uint8* WireFormatLite::WriteInt64ToArray(int field_number,\n                                                int64 value,\n                                                uint8* target) {\n  target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);\n  return WriteInt64NoTagToArray(value, target);\n}\ninline uint8* WireFormatLite::WriteUInt32ToArray(int field_number,\n                                                 uint32 value,\n                                                 uint8* target) {\n  target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);\n  return WriteUInt32NoTagToArray(value, target);\n}\ninline uint8* WireFormatLite::WriteUInt64ToArray(int field_number,\n                                                 uint64 value,\n                                                 uint8* target) {\n  target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);\n  return WriteUInt64NoTagToArray(value, target);\n}\ninline uint8* WireFormatLite::WriteSInt32ToArray(int field_number,\n                                                 int32 value,\n                                                 uint8* target) {\n  target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);\n  return WriteSInt32NoTagToArray(value, target);\n}\ninline uint8* WireFormatLite::WriteSInt64ToArray(int field_number,\n                                                 int64 value,\n                                                 uint8* target) {\n  target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);\n  return WriteSInt64NoTagToArray(value, target);\n}\ninline uint8* WireFormatLite::WriteFixed32ToArray(int field_number,\n                                                  uint32 value,\n                                                  uint8* target) {\n  target = WriteTagToArray(field_number, WIRETYPE_FIXED32, target);\n  return WriteFixed32NoTagToArray(value, target);\n}\ninline uint8* WireFormatLite::WriteFixed64ToArray(int field_number,\n                                                  uint64 value,\n                                                  uint8* target) {\n  target = WriteTagToArray(field_number, WIRETYPE_FIXED64, target);\n  return WriteFixed64NoTagToArray(value, target);\n}\ninline uint8* WireFormatLite::WriteSFixed32ToArray(int field_number,\n                                                   int32 value,\n                                                   uint8* target) {\n  target = WriteTagToArray(field_number, WIRETYPE_FIXED32, target);\n  return WriteSFixed32NoTagToArray(value, target);\n}\ninline uint8* WireFormatLite::WriteSFixed64ToArray(int field_number,\n                                                   int64 value,\n                                                   uint8* target) {\n  target = WriteTagToArray(field_number, WIRETYPE_FIXED64, target);\n  return WriteSFixed64NoTagToArray(value, target);\n}\ninline uint8* WireFormatLite::WriteFloatToArray(int field_number,\n                                                float value,\n                                                uint8* target) {\n  target = WriteTagToArray(field_number, WIRETYPE_FIXED32, target);\n  return WriteFloatNoTagToArray(value, target);\n}\ninline uint8* WireFormatLite::WriteDoubleToArray(int field_number,\n                                                 double value,\n                                                 uint8* target) {\n  target = WriteTagToArray(field_number, WIRETYPE_FIXED64, target);\n  return WriteDoubleNoTagToArray(value, target);\n}\ninline uint8* WireFormatLite::WriteBoolToArray(int field_number,\n                                               bool value,\n                                               uint8* target) {\n  target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);\n  return WriteBoolNoTagToArray(value, target);\n}\ninline uint8* WireFormatLite::WriteEnumToArray(int field_number,\n                                               int value,\n                                               uint8* target) {\n  target = WriteTagToArray(field_number, WIRETYPE_VARINT, target);\n  return WriteEnumNoTagToArray(value, target);\n}\n\ninline uint8* WireFormatLite::WriteStringToArray(int field_number,\n                                                 const string& value,\n                                                 uint8* target) {\n  // String is for UTF-8 text only\n  // WARNING:  In wire_format.cc, both strings and bytes are handled by\n  //   WriteString() to avoid code duplication.  If the implementations become\n  //   different, you will need to update that usage.\n  target = WriteTagToArray(field_number, WIRETYPE_LENGTH_DELIMITED, target);\n  return io::CodedOutputStream::WriteStringWithSizeToArray(value, target);\n}\ninline uint8* WireFormatLite::WriteBytesToArray(int field_number,\n                                                const string& value,\n                                                uint8* target) {\n  target = WriteTagToArray(field_number, WIRETYPE_LENGTH_DELIMITED, target);\n  return io::CodedOutputStream::WriteStringWithSizeToArray(value, target);\n}\n\n\ninline uint8* WireFormatLite::InternalWriteGroupToArray(\n    int field_number, const MessageLite& value, bool deterministic,\n    uint8* target) {\n  target = WriteTagToArray(field_number, WIRETYPE_START_GROUP, target);\n  target = value.InternalSerializeWithCachedSizesToArray(deterministic, target);\n  return WriteTagToArray(field_number, WIRETYPE_END_GROUP, target);\n}\ninline uint8* WireFormatLite::InternalWriteMessageToArray(\n    int field_number, const MessageLite& value, bool deterministic,\n    uint8* target) {\n  target = WriteTagToArray(field_number, WIRETYPE_LENGTH_DELIMITED, target);\n  target = io::CodedOutputStream::WriteVarint32ToArray(\n    value.GetCachedSize(), target);\n  return value.InternalSerializeWithCachedSizesToArray(deterministic, target);\n}\n\n// See comment on ReadGroupNoVirtual to understand the need for this template\n// parameter name.\ntemplate<typename MessageType_WorkAroundCppLookupDefect>\ninline uint8* WireFormatLite::InternalWriteGroupNoVirtualToArray(\n    int field_number, const MessageType_WorkAroundCppLookupDefect& value,\n    bool deterministic, uint8* target) {\n  target = WriteTagToArray(field_number, WIRETYPE_START_GROUP, target);\n  target = value.InternalSerializeWithCachedSizesToArray(deterministic, target);\n  return WriteTagToArray(field_number, WIRETYPE_END_GROUP, target);\n}\ntemplate<typename MessageType_WorkAroundCppLookupDefect>\ninline uint8* WireFormatLite::InternalWriteMessageNoVirtualToArray(\n    int field_number, const MessageType_WorkAroundCppLookupDefect& value,\n    bool deterministic, uint8* target) {\n  target = WriteTagToArray(field_number, WIRETYPE_LENGTH_DELIMITED, target);\n  target = io::CodedOutputStream::WriteVarint32ToArray(\n    value.MessageType_WorkAroundCppLookupDefect::GetCachedSize(), target);\n  return value.InternalSerializeWithCachedSizesToArray(deterministic, target);\n}\n\n// ===================================================================\n\ninline int WireFormatLite::Int32Size(int32 value) {\n  return io::CodedOutputStream::VarintSize32SignExtended(value);\n}\ninline int WireFormatLite::Int64Size(int64 value) {\n  return io::CodedOutputStream::VarintSize64(static_cast<uint64>(value));\n}\ninline int WireFormatLite::UInt32Size(uint32 value) {\n  return io::CodedOutputStream::VarintSize32(value);\n}\ninline int WireFormatLite::UInt64Size(uint64 value) {\n  return io::CodedOutputStream::VarintSize64(value);\n}\ninline int WireFormatLite::SInt32Size(int32 value) {\n  return io::CodedOutputStream::VarintSize32(ZigZagEncode32(value));\n}\ninline int WireFormatLite::SInt64Size(int64 value) {\n  return io::CodedOutputStream::VarintSize64(ZigZagEncode64(value));\n}\ninline int WireFormatLite::EnumSize(int value) {\n  return io::CodedOutputStream::VarintSize32SignExtended(value);\n}\n\ninline int WireFormatLite::StringSize(const string& value) {\n  return static_cast<int>(\n      io::CodedOutputStream::VarintSize32(static_cast<uint32>(value.size())) +\n      value.size());\n}\ninline int WireFormatLite::BytesSize(const string& value) {\n  return static_cast<int>(\n      io::CodedOutputStream::VarintSize32(static_cast<uint32>(value.size())) +\n      value.size());\n}\n\n\ninline int WireFormatLite::GroupSize(const MessageLite& value) {\n  return value.ByteSize();\n}\ninline int WireFormatLite::MessageSize(const MessageLite& value) {\n  return LengthDelimitedSize(value.ByteSize());\n}\n\n// See comment on ReadGroupNoVirtual to understand the need for this template\n// parameter name.\ntemplate<typename MessageType_WorkAroundCppLookupDefect>\ninline int WireFormatLite::GroupSizeNoVirtual(\n    const MessageType_WorkAroundCppLookupDefect& value) {\n  return value.MessageType_WorkAroundCppLookupDefect::ByteSize();\n}\ntemplate<typename MessageType_WorkAroundCppLookupDefect>\ninline int WireFormatLite::MessageSizeNoVirtual(\n    const MessageType_WorkAroundCppLookupDefect& value) {\n  return LengthDelimitedSize(\n      value.MessageType_WorkAroundCppLookupDefect::ByteSize());\n}\n\ninline int WireFormatLite::LengthDelimitedSize(int length) {\n  return io::CodedOutputStream::VarintSize32(length) + length;\n}\n\n}  // namespace internal\n}  // namespace protobuf\n\n}  // namespace google\n#endif  // GOOGLE_PROTOBUF_WIRE_FORMAT_LITE_INL_H__\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/wire_format_unittest.cc",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Author: kenton@google.com (Kenton Varda)\n//  Based on original Protocol Buffers design by\n//  Sanjay Ghemawat, Jeff Dean, and others.\n\n#include <google/protobuf/wire_format.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/io/zero_copy_stream_impl.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/unittest.pb.h>\n#include <google/protobuf/unittest_proto3_arena.pb.h>\n#include <google/protobuf/unittest_mset.pb.h>\n#include <google/protobuf/unittest_mset_wire_format.pb.h>\n#include <google/protobuf/test_util.h>\n\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/logging.h>\n#include <google/protobuf/testing/googletest.h>\n#include <gtest/gtest.h>\n#include <google/protobuf/stubs/stl_util.h>\n\nnamespace google {\nnamespace protobuf {\nnamespace internal {\nnamespace {\n\nTEST(WireFormatTest, EnumsInSync) {\n  // Verify that WireFormatLite::FieldType and WireFormatLite::CppType match\n  // FieldDescriptor::Type and FieldDescriptor::CppType.\n\n  EXPECT_EQ(implicit_cast<int>(FieldDescriptor::MAX_TYPE),\n            implicit_cast<int>(WireFormatLite::MAX_FIELD_TYPE));\n  EXPECT_EQ(implicit_cast<int>(FieldDescriptor::MAX_CPPTYPE),\n            implicit_cast<int>(WireFormatLite::MAX_CPPTYPE));\n\n  for (int i = 1; i <= WireFormatLite::MAX_FIELD_TYPE; i++) {\n    EXPECT_EQ(\n      implicit_cast<int>(FieldDescriptor::TypeToCppType(\n        static_cast<FieldDescriptor::Type>(i))),\n      implicit_cast<int>(WireFormatLite::FieldTypeToCppType(\n        static_cast<WireFormatLite::FieldType>(i))));\n  }\n}\n\nTEST(WireFormatTest, MaxFieldNumber) {\n  // Make sure the max field number constant is accurate.\n  EXPECT_EQ((1 << (32 - WireFormatLite::kTagTypeBits)) - 1,\n            FieldDescriptor::kMaxNumber);\n}\n\nTEST(WireFormatTest, Parse) {\n  unittest::TestAllTypes source, dest;\n  string data;\n\n  // Serialize using the generated code.\n  TestUtil::SetAllFields(&source);\n  source.SerializeToString(&data);\n\n  // Parse using WireFormat.\n  io::ArrayInputStream raw_input(data.data(), data.size());\n  io::CodedInputStream input(&raw_input);\n  WireFormat::ParseAndMergePartial(&input, &dest);\n\n  // Check.\n  TestUtil::ExpectAllFieldsSet(dest);\n}\n\nTEST(WireFormatTest, ParseExtensions) {\n  unittest::TestAllExtensions source, dest;\n  string data;\n\n  // Serialize using the generated code.\n  TestUtil::SetAllExtensions(&source);\n  source.SerializeToString(&data);\n\n  // Parse using WireFormat.\n  io::ArrayInputStream raw_input(data.data(), data.size());\n  io::CodedInputStream input(&raw_input);\n  WireFormat::ParseAndMergePartial(&input, &dest);\n\n  // Check.\n  TestUtil::ExpectAllExtensionsSet(dest);\n}\n\nTEST(WireFormatTest, ParsePacked) {\n  unittest::TestPackedTypes source, dest;\n  string data;\n\n  // Serialize using the generated code.\n  TestUtil::SetPackedFields(&source);\n  source.SerializeToString(&data);\n\n  // Parse using WireFormat.\n  io::ArrayInputStream raw_input(data.data(), data.size());\n  io::CodedInputStream input(&raw_input);\n  WireFormat::ParseAndMergePartial(&input, &dest);\n\n  // Check.\n  TestUtil::ExpectPackedFieldsSet(dest);\n}\n\nTEST(WireFormatTest, ParsePackedFromUnpacked) {\n  // Serialize using the generated code.\n  unittest::TestUnpackedTypes source;\n  TestUtil::SetUnpackedFields(&source);\n  string data = source.SerializeAsString();\n\n  // Parse using WireFormat.\n  unittest::TestPackedTypes dest;\n  io::ArrayInputStream raw_input(data.data(), data.size());\n  io::CodedInputStream input(&raw_input);\n  WireFormat::ParseAndMergePartial(&input, &dest);\n\n  // Check.\n  TestUtil::ExpectPackedFieldsSet(dest);\n}\n\nTEST(WireFormatTest, ParseUnpackedFromPacked) {\n  // Serialize using the generated code.\n  unittest::TestPackedTypes source;\n  TestUtil::SetPackedFields(&source);\n  string data = source.SerializeAsString();\n\n  // Parse using WireFormat.\n  unittest::TestUnpackedTypes dest;\n  io::ArrayInputStream raw_input(data.data(), data.size());\n  io::CodedInputStream input(&raw_input);\n  WireFormat::ParseAndMergePartial(&input, &dest);\n\n  // Check.\n  TestUtil::ExpectUnpackedFieldsSet(dest);\n}\n\nTEST(WireFormatTest, ParsePackedExtensions) {\n  unittest::TestPackedExtensions source, dest;\n  string data;\n\n  // Serialize using the generated code.\n  TestUtil::SetPackedExtensions(&source);\n  source.SerializeToString(&data);\n\n  // Parse using WireFormat.\n  io::ArrayInputStream raw_input(data.data(), data.size());\n  io::CodedInputStream input(&raw_input);\n  WireFormat::ParseAndMergePartial(&input, &dest);\n\n  // Check.\n  TestUtil::ExpectPackedExtensionsSet(dest);\n}\n\nTEST(WireFormatTest, ParseOneof) {\n  unittest::TestOneof2 source, dest;\n  string data;\n\n  // Serialize using the generated code.\n  TestUtil::SetOneof1(&source);\n  source.SerializeToString(&data);\n\n  // Parse using WireFormat.\n  io::ArrayInputStream raw_input(data.data(), data.size());\n  io::CodedInputStream input(&raw_input);\n  WireFormat::ParseAndMergePartial(&input, &dest);\n\n  // Check.\n  TestUtil::ExpectOneofSet1(dest);\n}\n\nTEST(WireFormatTest, OneofOnlySetLast) {\n  unittest::TestOneofBackwardsCompatible source;\n  unittest::TestOneof oneof_dest;\n  string data;\n\n  // Set two fields\n  source.set_foo_int(100);\n  source.set_foo_string(\"101\");\n\n  // Serialize and parse to oneof message.\n  source.SerializeToString(&data);\n  io::ArrayInputStream raw_input(data.data(), data.size());\n  io::CodedInputStream input(&raw_input);\n  WireFormat::ParseAndMergePartial(&input, &oneof_dest);\n\n  // Only the last field is set.\n  EXPECT_FALSE(oneof_dest.has_foo_int());\n  EXPECT_TRUE(oneof_dest.has_foo_string());\n}\n\nTEST(WireFormatTest, ByteSize) {\n  unittest::TestAllTypes message;\n  TestUtil::SetAllFields(&message);\n\n  EXPECT_EQ(message.ByteSize(), WireFormat::ByteSize(message));\n  message.Clear();\n  EXPECT_EQ(0, message.ByteSize());\n  EXPECT_EQ(0, WireFormat::ByteSize(message));\n}\n\nTEST(WireFormatTest, ByteSizeExtensions) {\n  unittest::TestAllExtensions message;\n  TestUtil::SetAllExtensions(&message);\n\n  EXPECT_EQ(message.ByteSize(),\n            WireFormat::ByteSize(message));\n  message.Clear();\n  EXPECT_EQ(0, message.ByteSize());\n  EXPECT_EQ(0, WireFormat::ByteSize(message));\n}\n\nTEST(WireFormatTest, ByteSizePacked) {\n  unittest::TestPackedTypes message;\n  TestUtil::SetPackedFields(&message);\n\n  EXPECT_EQ(message.ByteSize(), WireFormat::ByteSize(message));\n  message.Clear();\n  EXPECT_EQ(0, message.ByteSize());\n  EXPECT_EQ(0, WireFormat::ByteSize(message));\n}\n\nTEST(WireFormatTest, ByteSizePackedExtensions) {\n  unittest::TestPackedExtensions message;\n  TestUtil::SetPackedExtensions(&message);\n\n  EXPECT_EQ(message.ByteSize(),\n            WireFormat::ByteSize(message));\n  message.Clear();\n  EXPECT_EQ(0, message.ByteSize());\n  EXPECT_EQ(0, WireFormat::ByteSize(message));\n}\n\nTEST(WireFormatTest, ByteSizeOneof) {\n  unittest::TestOneof2 message;\n  TestUtil::SetOneof1(&message);\n\n  EXPECT_EQ(message.ByteSize(),\n  WireFormat::ByteSize(message));\n  message.Clear();\n\n  EXPECT_EQ(0, message.ByteSize());\n  EXPECT_EQ(0, WireFormat::ByteSize(message));\n}\n\nTEST(WireFormatTest, Serialize) {\n  unittest::TestAllTypes message;\n  string generated_data;\n  string dynamic_data;\n\n  TestUtil::SetAllFields(&message);\n  int size = message.ByteSize();\n\n  // Serialize using the generated code.\n  {\n    io::StringOutputStream raw_output(&generated_data);\n    io::CodedOutputStream output(&raw_output);\n    message.SerializeWithCachedSizes(&output);\n    ASSERT_FALSE(output.HadError());\n  }\n\n  // Serialize using WireFormat.\n  {\n    io::StringOutputStream raw_output(&dynamic_data);\n    io::CodedOutputStream output(&raw_output);\n    WireFormat::SerializeWithCachedSizes(message, size, &output);\n    ASSERT_FALSE(output.HadError());\n  }\n\n  // Should be the same.\n  // Don't use EXPECT_EQ here because we're comparing raw binary data and\n  // we really don't want it dumped to stdout on failure.\n  EXPECT_TRUE(dynamic_data == generated_data);\n}\n\nTEST(WireFormatTest, SerializeExtensions) {\n  unittest::TestAllExtensions message;\n  string generated_data;\n  string dynamic_data;\n\n  TestUtil::SetAllExtensions(&message);\n  int size = message.ByteSize();\n\n  // Serialize using the generated code.\n  {\n    io::StringOutputStream raw_output(&generated_data);\n    io::CodedOutputStream output(&raw_output);\n    message.SerializeWithCachedSizes(&output);\n    ASSERT_FALSE(output.HadError());\n  }\n\n  // Serialize using WireFormat.\n  {\n    io::StringOutputStream raw_output(&dynamic_data);\n    io::CodedOutputStream output(&raw_output);\n    WireFormat::SerializeWithCachedSizes(message, size, &output);\n    ASSERT_FALSE(output.HadError());\n  }\n\n  // Should be the same.\n  // Don't use EXPECT_EQ here because we're comparing raw binary data and\n  // we really don't want it dumped to stdout on failure.\n  EXPECT_TRUE(dynamic_data == generated_data);\n}\n\nTEST(WireFormatTest, SerializeFieldsAndExtensions) {\n  unittest::TestFieldOrderings message;\n  string generated_data;\n  string dynamic_data;\n\n  TestUtil::SetAllFieldsAndExtensions(&message);\n  int size = message.ByteSize();\n\n  // Serialize using the generated code.\n  {\n    io::StringOutputStream raw_output(&generated_data);\n    io::CodedOutputStream output(&raw_output);\n    message.SerializeWithCachedSizes(&output);\n    ASSERT_FALSE(output.HadError());\n  }\n\n  // Serialize using WireFormat.\n  {\n    io::StringOutputStream raw_output(&dynamic_data);\n    io::CodedOutputStream output(&raw_output);\n    WireFormat::SerializeWithCachedSizes(message, size, &output);\n    ASSERT_FALSE(output.HadError());\n  }\n\n  // Should be the same.\n  // Don't use EXPECT_EQ here because we're comparing raw binary data and\n  // we really don't want it dumped to stdout on failure.\n  EXPECT_TRUE(dynamic_data == generated_data);\n\n  // Should output in canonical order.\n  TestUtil::ExpectAllFieldsAndExtensionsInOrder(dynamic_data);\n  TestUtil::ExpectAllFieldsAndExtensionsInOrder(generated_data);\n}\n\nTEST(WireFormatTest, SerializeOneof) {\n  unittest::TestOneof2 message;\n  string generated_data;\n  string dynamic_data;\n\n  TestUtil::SetOneof1(&message);\n  int size = message.ByteSize();\n\n  // Serialize using the generated code.\n  {\n    io::StringOutputStream raw_output(&generated_data);\n    io::CodedOutputStream output(&raw_output);\n    message.SerializeWithCachedSizes(&output);\n    ASSERT_FALSE(output.HadError());\n  }\n\n  // Serialize using WireFormat.\n  {\n    io::StringOutputStream raw_output(&dynamic_data);\n    io::CodedOutputStream output(&raw_output);\n    WireFormat::SerializeWithCachedSizes(message, size, &output);\n    ASSERT_FALSE(output.HadError());\n  }\n\n  // Should be the same.\n  // Don't use EXPECT_EQ here because we're comparing raw binary data and\n  // we really don't want it dumped to stdout on failure.\n  EXPECT_TRUE(dynamic_data == generated_data);\n}\n\nTEST(WireFormatTest, ParseMultipleExtensionRanges) {\n  // Make sure we can parse a message that contains multiple extensions ranges.\n  unittest::TestFieldOrderings source;\n  string data;\n\n  TestUtil::SetAllFieldsAndExtensions(&source);\n  source.SerializeToString(&data);\n\n  {\n    unittest::TestFieldOrderings dest;\n    EXPECT_TRUE(dest.ParseFromString(data));\n    EXPECT_EQ(source.DebugString(), dest.DebugString());\n  }\n\n  // Also test using reflection-based parsing.\n  {\n    unittest::TestFieldOrderings dest;\n    io::ArrayInputStream raw_input(data.data(), data.size());\n    io::CodedInputStream coded_input(&raw_input);\n    EXPECT_TRUE(WireFormat::ParseAndMergePartial(&coded_input, &dest));\n    EXPECT_EQ(source.DebugString(), dest.DebugString());\n  }\n}\n\nconst int kUnknownTypeId = 1550055;\n\nTEST(WireFormatTest, SerializeMessageSet) {\n  // Set up a TestMessageSet with two known messages and an unknown one.\n  proto2_wireformat_unittest::TestMessageSet message_set;\n  message_set.MutableExtension(\n    unittest::TestMessageSetExtension1::message_set_extension)->set_i(123);\n  message_set.MutableExtension(\n    unittest::TestMessageSetExtension2::message_set_extension)->set_str(\"foo\");\n  message_set.mutable_unknown_fields()->AddLengthDelimited(\n    kUnknownTypeId, \"bar\");\n\n  string data;\n  ASSERT_TRUE(message_set.SerializeToString(&data));\n\n  // Parse back using RawMessageSet and check the contents.\n  unittest::RawMessageSet raw;\n  ASSERT_TRUE(raw.ParseFromString(data));\n\n  EXPECT_EQ(0, raw.unknown_fields().field_count());\n\n  ASSERT_EQ(3, raw.item_size());\n  EXPECT_EQ(\n    unittest::TestMessageSetExtension1::descriptor()->extension(0)->number(),\n    raw.item(0).type_id());\n  EXPECT_EQ(\n    unittest::TestMessageSetExtension2::descriptor()->extension(0)->number(),\n    raw.item(1).type_id());\n  EXPECT_EQ(kUnknownTypeId, raw.item(2).type_id());\n\n  unittest::TestMessageSetExtension1 message1;\n  EXPECT_TRUE(message1.ParseFromString(raw.item(0).message()));\n  EXPECT_EQ(123, message1.i());\n\n  unittest::TestMessageSetExtension2 message2;\n  EXPECT_TRUE(message2.ParseFromString(raw.item(1).message()));\n  EXPECT_EQ(\"foo\", message2.str());\n\n  EXPECT_EQ(\"bar\", raw.item(2).message());\n}\n\nTEST(WireFormatTest, SerializeMessageSetVariousWaysAreEqual) {\n  // Serialize a MessageSet to a stream and to a flat array using generated\n  // code, and also using WireFormat, and check that the results are equal.\n  // Set up a TestMessageSet with two known messages and an unknown one, as\n  // above.\n\n  proto2_wireformat_unittest::TestMessageSet message_set;\n  message_set.MutableExtension(\n    unittest::TestMessageSetExtension1::message_set_extension)->set_i(123);\n  message_set.MutableExtension(\n    unittest::TestMessageSetExtension2::message_set_extension)->set_str(\"foo\");\n  message_set.mutable_unknown_fields()->AddLengthDelimited(\n    kUnknownTypeId, \"bar\");\n\n  int size = message_set.ByteSize();\n  EXPECT_EQ(size, message_set.GetCachedSize());\n  ASSERT_EQ(size, WireFormat::ByteSize(message_set));\n\n  string flat_data;\n  string stream_data;\n  string dynamic_data;\n  flat_data.resize(size);\n  stream_data.resize(size);\n\n  // Serialize to flat array\n  {\n    uint8* target = reinterpret_cast<uint8*>(string_as_array(&flat_data));\n    uint8* end = message_set.SerializeWithCachedSizesToArray(target);\n    EXPECT_EQ(size, end - target);\n  }\n\n  // Serialize to buffer\n  {\n    io::ArrayOutputStream array_stream(string_as_array(&stream_data), size, 1);\n    io::CodedOutputStream output_stream(&array_stream);\n    message_set.SerializeWithCachedSizes(&output_stream);\n    ASSERT_FALSE(output_stream.HadError());\n  }\n\n  // Serialize to buffer with WireFormat.\n  {\n    io::StringOutputStream string_stream(&dynamic_data);\n    io::CodedOutputStream output_stream(&string_stream);\n    WireFormat::SerializeWithCachedSizes(message_set, size, &output_stream);\n    ASSERT_FALSE(output_stream.HadError());\n  }\n\n  EXPECT_TRUE(flat_data == stream_data);\n  EXPECT_TRUE(flat_data == dynamic_data);\n}\n\nTEST(WireFormatTest, ParseMessageSet) {\n  // Set up a RawMessageSet with two known messages and an unknown one.\n  unittest::RawMessageSet raw;\n\n  {\n    unittest::RawMessageSet::Item* item = raw.add_item();\n    item->set_type_id(\n      unittest::TestMessageSetExtension1::descriptor()->extension(0)->number());\n    unittest::TestMessageSetExtension1 message;\n    message.set_i(123);\n    message.SerializeToString(item->mutable_message());\n  }\n\n  {\n    unittest::RawMessageSet::Item* item = raw.add_item();\n    item->set_type_id(\n      unittest::TestMessageSetExtension2::descriptor()->extension(0)->number());\n    unittest::TestMessageSetExtension2 message;\n    message.set_str(\"foo\");\n    message.SerializeToString(item->mutable_message());\n  }\n\n  {\n    unittest::RawMessageSet::Item* item = raw.add_item();\n    item->set_type_id(kUnknownTypeId);\n    item->set_message(\"bar\");\n  }\n\n  string data;\n  ASSERT_TRUE(raw.SerializeToString(&data));\n\n  // Parse as a TestMessageSet and check the contents.\n  proto2_wireformat_unittest::TestMessageSet message_set;\n  ASSERT_TRUE(message_set.ParseFromString(data));\n\n  EXPECT_EQ(123, message_set.GetExtension(\n    unittest::TestMessageSetExtension1::message_set_extension).i());\n  EXPECT_EQ(\"foo\", message_set.GetExtension(\n    unittest::TestMessageSetExtension2::message_set_extension).str());\n\n  ASSERT_EQ(1, message_set.unknown_fields().field_count());\n  ASSERT_EQ(UnknownField::TYPE_LENGTH_DELIMITED,\n            message_set.unknown_fields().field(0).type());\n  EXPECT_EQ(\"bar\", message_set.unknown_fields().field(0).length_delimited());\n\n  // Also parse using WireFormat.\n  proto2_wireformat_unittest::TestMessageSet dynamic_message_set;\n  io::CodedInputStream input(reinterpret_cast<const uint8*>(data.data()),\n                             data.size());\n  ASSERT_TRUE(WireFormat::ParseAndMergePartial(&input, &dynamic_message_set));\n  EXPECT_EQ(message_set.DebugString(), dynamic_message_set.DebugString());\n}\n\nTEST(WireFormatTest, ParseMessageSetWithReverseTagOrder) {\n  string data;\n  {\n    unittest::TestMessageSetExtension1 message;\n    message.set_i(123);\n    // Build a MessageSet manually with its message content put before its\n    // type_id.\n    io::StringOutputStream output_stream(&data);\n    io::CodedOutputStream coded_output(&output_stream);\n    coded_output.WriteTag(WireFormatLite::kMessageSetItemStartTag);\n    // Write the message content first.\n    WireFormatLite::WriteTag(WireFormatLite::kMessageSetMessageNumber,\n                             WireFormatLite::WIRETYPE_LENGTH_DELIMITED,\n                             &coded_output);\n    coded_output.WriteVarint32(message.ByteSize());\n    message.SerializeWithCachedSizes(&coded_output);\n    // Write the type id.\n    uint32 type_id = message.GetDescriptor()->extension(0)->number();\n    WireFormatLite::WriteUInt32(WireFormatLite::kMessageSetTypeIdNumber,\n                                type_id, &coded_output);\n    coded_output.WriteTag(WireFormatLite::kMessageSetItemEndTag);\n  }\n  {\n    proto2_wireformat_unittest::TestMessageSet message_set;\n    ASSERT_TRUE(message_set.ParseFromString(data));\n\n    EXPECT_EQ(123, message_set.GetExtension(\n        unittest::TestMessageSetExtension1::message_set_extension).i());\n  }\n  {\n    // Test parse the message via Reflection.\n    proto2_wireformat_unittest::TestMessageSet message_set;\n    io::CodedInputStream input(\n        reinterpret_cast<const uint8*>(data.data()), data.size());\n    EXPECT_TRUE(WireFormat::ParseAndMergePartial(&input, &message_set));\n    EXPECT_TRUE(input.ConsumedEntireMessage());\n\n    EXPECT_EQ(123, message_set.GetExtension(\n        unittest::TestMessageSetExtension1::message_set_extension).i());\n  }\n}\n\nTEST(WireFormatTest, ParseBrokenMessageSet) {\n  proto2_wireformat_unittest::TestMessageSet message_set;\n  string input(\"goodbye\");  // Invalid wire format data.\n  EXPECT_FALSE(message_set.ParseFromString(input));\n}\n\nTEST(WireFormatTest, RecursionLimit) {\n  unittest::TestRecursiveMessage message;\n  message.mutable_a()->mutable_a()->mutable_a()->mutable_a()->set_i(1);\n  string data;\n  message.SerializeToString(&data);\n\n  {\n    io::ArrayInputStream raw_input(data.data(), data.size());\n    io::CodedInputStream input(&raw_input);\n    input.SetRecursionLimit(4);\n    unittest::TestRecursiveMessage message2;\n    EXPECT_TRUE(message2.ParseFromCodedStream(&input));\n  }\n\n  {\n    io::ArrayInputStream raw_input(data.data(), data.size());\n    io::CodedInputStream input(&raw_input);\n    input.SetRecursionLimit(3);\n    unittest::TestRecursiveMessage message2;\n    EXPECT_FALSE(message2.ParseFromCodedStream(&input));\n  }\n}\n\nTEST(WireFormatTest, UnknownFieldRecursionLimit) {\n  unittest::TestEmptyMessage message;\n  message.mutable_unknown_fields()\n        ->AddGroup(1234)\n        ->AddGroup(1234)\n        ->AddGroup(1234)\n        ->AddGroup(1234)\n        ->AddVarint(1234, 123);\n  string data;\n  message.SerializeToString(&data);\n\n  {\n    io::ArrayInputStream raw_input(data.data(), data.size());\n    io::CodedInputStream input(&raw_input);\n    input.SetRecursionLimit(4);\n    unittest::TestEmptyMessage message2;\n    EXPECT_TRUE(message2.ParseFromCodedStream(&input));\n  }\n\n  {\n    io::ArrayInputStream raw_input(data.data(), data.size());\n    io::CodedInputStream input(&raw_input);\n    input.SetRecursionLimit(3);\n    unittest::TestEmptyMessage message2;\n    EXPECT_FALSE(message2.ParseFromCodedStream(&input));\n  }\n}\n\nTEST(WireFormatTest, ZigZag) {\n// avoid line-wrapping\n#define LL(x) GOOGLE_LONGLONG(x)\n#define ULL(x) GOOGLE_ULONGLONG(x)\n#define ZigZagEncode32(x) WireFormatLite::ZigZagEncode32(x)\n#define ZigZagDecode32(x) WireFormatLite::ZigZagDecode32(x)\n#define ZigZagEncode64(x) WireFormatLite::ZigZagEncode64(x)\n#define ZigZagDecode64(x) WireFormatLite::ZigZagDecode64(x)\n\n  EXPECT_EQ(0u, ZigZagEncode32( 0));\n  EXPECT_EQ(1u, ZigZagEncode32(-1));\n  EXPECT_EQ(2u, ZigZagEncode32( 1));\n  EXPECT_EQ(3u, ZigZagEncode32(-2));\n  EXPECT_EQ(0x7FFFFFFEu, ZigZagEncode32(0x3FFFFFFF));\n  EXPECT_EQ(0x7FFFFFFFu, ZigZagEncode32(0xC0000000));\n  EXPECT_EQ(0xFFFFFFFEu, ZigZagEncode32(0x7FFFFFFF));\n  EXPECT_EQ(0xFFFFFFFFu, ZigZagEncode32(0x80000000));\n\n  EXPECT_EQ( 0, ZigZagDecode32(0u));\n  EXPECT_EQ(-1, ZigZagDecode32(1u));\n  EXPECT_EQ( 1, ZigZagDecode32(2u));\n  EXPECT_EQ(-2, ZigZagDecode32(3u));\n  EXPECT_EQ(0x3FFFFFFF, ZigZagDecode32(0x7FFFFFFEu));\n  EXPECT_EQ(0xC0000000, ZigZagDecode32(0x7FFFFFFFu));\n  EXPECT_EQ(0x7FFFFFFF, ZigZagDecode32(0xFFFFFFFEu));\n  EXPECT_EQ(0x80000000, ZigZagDecode32(0xFFFFFFFFu));\n\n  EXPECT_EQ(0u, ZigZagEncode64( 0));\n  EXPECT_EQ(1u, ZigZagEncode64(-1));\n  EXPECT_EQ(2u, ZigZagEncode64( 1));\n  EXPECT_EQ(3u, ZigZagEncode64(-2));\n  EXPECT_EQ(ULL(0x000000007FFFFFFE), ZigZagEncode64(LL(0x000000003FFFFFFF)));\n  EXPECT_EQ(ULL(0x000000007FFFFFFF), ZigZagEncode64(LL(0xFFFFFFFFC0000000)));\n  EXPECT_EQ(ULL(0x00000000FFFFFFFE), ZigZagEncode64(LL(0x000000007FFFFFFF)));\n  EXPECT_EQ(ULL(0x00000000FFFFFFFF), ZigZagEncode64(LL(0xFFFFFFFF80000000)));\n  EXPECT_EQ(ULL(0xFFFFFFFFFFFFFFFE), ZigZagEncode64(LL(0x7FFFFFFFFFFFFFFF)));\n  EXPECT_EQ(ULL(0xFFFFFFFFFFFFFFFF), ZigZagEncode64(LL(0x8000000000000000)));\n\n  EXPECT_EQ( 0, ZigZagDecode64(0u));\n  EXPECT_EQ(-1, ZigZagDecode64(1u));\n  EXPECT_EQ( 1, ZigZagDecode64(2u));\n  EXPECT_EQ(-2, ZigZagDecode64(3u));\n  EXPECT_EQ(LL(0x000000003FFFFFFF), ZigZagDecode64(ULL(0x000000007FFFFFFE)));\n  EXPECT_EQ(LL(0xFFFFFFFFC0000000), ZigZagDecode64(ULL(0x000000007FFFFFFF)));\n  EXPECT_EQ(LL(0x000000007FFFFFFF), ZigZagDecode64(ULL(0x00000000FFFFFFFE)));\n  EXPECT_EQ(LL(0xFFFFFFFF80000000), ZigZagDecode64(ULL(0x00000000FFFFFFFF)));\n  EXPECT_EQ(LL(0x7FFFFFFFFFFFFFFF), ZigZagDecode64(ULL(0xFFFFFFFFFFFFFFFE)));\n  EXPECT_EQ(LL(0x8000000000000000), ZigZagDecode64(ULL(0xFFFFFFFFFFFFFFFF)));\n\n  // Some easier-to-verify round-trip tests.  The inputs (other than 0, 1, -1)\n  // were chosen semi-randomly via keyboard bashing.\n  EXPECT_EQ(    0, ZigZagDecode32(ZigZagEncode32(    0)));\n  EXPECT_EQ(    1, ZigZagDecode32(ZigZagEncode32(    1)));\n  EXPECT_EQ(   -1, ZigZagDecode32(ZigZagEncode32(   -1)));\n  EXPECT_EQ(14927, ZigZagDecode32(ZigZagEncode32(14927)));\n  EXPECT_EQ(-3612, ZigZagDecode32(ZigZagEncode32(-3612)));\n\n  EXPECT_EQ(    0, ZigZagDecode64(ZigZagEncode64(    0)));\n  EXPECT_EQ(    1, ZigZagDecode64(ZigZagEncode64(    1)));\n  EXPECT_EQ(   -1, ZigZagDecode64(ZigZagEncode64(   -1)));\n  EXPECT_EQ(14927, ZigZagDecode64(ZigZagEncode64(14927)));\n  EXPECT_EQ(-3612, ZigZagDecode64(ZigZagEncode64(-3612)));\n\n  EXPECT_EQ(LL(856912304801416), ZigZagDecode64(ZigZagEncode64(\n            LL(856912304801416))));\n  EXPECT_EQ(LL(-75123905439571256), ZigZagDecode64(ZigZagEncode64(\n            LL(-75123905439571256))));\n}\n\nTEST(WireFormatTest, RepeatedScalarsDifferentTagSizes) {\n  // At one point checks would trigger when parsing repeated fixed scalar\n  // fields.\n  protobuf_unittest::TestRepeatedScalarDifferentTagSizes msg1, msg2;\n  for (int i = 0; i < 100; ++i) {\n    msg1.add_repeated_fixed32(i);\n    msg1.add_repeated_int32(i);\n    msg1.add_repeated_fixed64(i);\n    msg1.add_repeated_int64(i);\n    msg1.add_repeated_float(i);\n    msg1.add_repeated_uint64(i);\n  }\n\n  // Make sure that we have a variety of tag sizes.\n  const google::protobuf::Descriptor* desc = msg1.GetDescriptor();\n  const google::protobuf::FieldDescriptor* field;\n  field = desc->FindFieldByName(\"repeated_fixed32\");\n  ASSERT_TRUE(field != NULL);\n  ASSERT_EQ(1, WireFormat::TagSize(field->number(), field->type()));\n  field = desc->FindFieldByName(\"repeated_int32\");\n  ASSERT_TRUE(field != NULL);\n  ASSERT_EQ(1, WireFormat::TagSize(field->number(), field->type()));\n  field = desc->FindFieldByName(\"repeated_fixed64\");\n  ASSERT_TRUE(field != NULL);\n  ASSERT_EQ(2, WireFormat::TagSize(field->number(), field->type()));\n  field = desc->FindFieldByName(\"repeated_int64\");\n  ASSERT_TRUE(field != NULL);\n  ASSERT_EQ(2, WireFormat::TagSize(field->number(), field->type()));\n  field = desc->FindFieldByName(\"repeated_float\");\n  ASSERT_TRUE(field != NULL);\n  ASSERT_EQ(3, WireFormat::TagSize(field->number(), field->type()));\n  field = desc->FindFieldByName(\"repeated_uint64\");\n  ASSERT_TRUE(field != NULL);\n  ASSERT_EQ(3, WireFormat::TagSize(field->number(), field->type()));\n\n  EXPECT_TRUE(msg2.ParseFromString(msg1.SerializeAsString()));\n  EXPECT_EQ(msg1.DebugString(), msg2.DebugString());\n}\n\nTEST(WireFormatTest, CompatibleTypes) {\n  const int64 data = 0x100000000LL;\n  unittest::Int64Message msg1;\n  msg1.set_data(data);\n  string serialized;\n  msg1.SerializeToString(&serialized);\n\n  // Test int64 is compatible with bool\n  unittest::BoolMessage msg2;\n  ASSERT_TRUE(msg2.ParseFromString(serialized));\n  ASSERT_EQ(static_cast<bool>(data), msg2.data());\n\n  // Test int64 is compatible with uint64\n  unittest::Uint64Message msg3;\n  ASSERT_TRUE(msg3.ParseFromString(serialized));\n  ASSERT_EQ(static_cast<uint64>(data), msg3.data());\n\n  // Test int64 is compatible with int32\n  unittest::Int32Message msg4;\n  ASSERT_TRUE(msg4.ParseFromString(serialized));\n  ASSERT_EQ(static_cast<int32>(data), msg4.data());\n\n  // Test int64 is compatible with uint32\n  unittest::Uint32Message msg5;\n  ASSERT_TRUE(msg5.ParseFromString(serialized));\n  ASSERT_EQ(static_cast<uint32>(data), msg5.data());\n}\n\nclass Proto3PrimitiveRepeatedWireFormatTest : public ::testing::Test {\n protected:\n  Proto3PrimitiveRepeatedWireFormatTest()\n      : packedTestAllTypes_(\n            \"\\xFA\\x01\\x01\\x01\"\n            \"\\x82\\x02\\x01\\x01\"\n            \"\\x8A\\x02\\x01\\x01\"\n            \"\\x92\\x02\\x01\\x01\"\n            \"\\x9A\\x02\\x01\\x02\"\n            \"\\xA2\\x02\\x01\\x02\"\n            \"\\xAA\\x02\\x04\\x01\\x00\\x00\\x00\"\n            \"\\xB2\\x02\\x08\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"\n            \"\\xBA\\x02\\x04\\x01\\x00\\x00\\x00\"\n            \"\\xC2\\x02\\x08\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"\n            \"\\xCA\\x02\\x04\\x00\\x00\\x80\\x3f\"\n            \"\\xD2\\x02\\x08\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\x3f\"\n            \"\\xDA\\x02\\x01\\x01\"\n            \"\\x9A\\x03\\x01\\x01\",\n            86),\n        packedTestUnpackedTypes_(\n            \"\\x0A\\x01\\x01\"\n            \"\\x12\\x01\\x01\"\n            \"\\x1A\\x01\\x01\"\n            \"\\x22\\x01\\x01\"\n            \"\\x2A\\x01\\x02\"\n            \"\\x32\\x01\\x02\"\n            \"\\x3A\\x04\\x01\\x00\\x00\\x00\"\n            \"\\x42\\x08\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"\n            \"\\x4A\\x04\\x01\\x00\\x00\\x00\"\n            \"\\x52\\x08\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"\n            \"\\x5A\\x04\\x00\\x00\\x80\\x3f\"\n            \"\\x62\\x08\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\x3f\"\n            \"\\x6A\\x01\\x01\"\n            \"\\x72\\x01\\x01\",\n            72),\n        unpackedTestAllTypes_(\n            \"\\xF8\\x01\\x01\"\n            \"\\x80\\x02\\x01\"\n            \"\\x88\\x02\\x01\"\n            \"\\x90\\x02\\x01\"\n            \"\\x98\\x02\\x02\"\n            \"\\xA0\\x02\\x02\"\n            \"\\xAD\\x02\\x01\\x00\\x00\\x00\"\n            \"\\xB1\\x02\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"\n            \"\\xBD\\x02\\x01\\x00\\x00\\x00\"\n            \"\\xC1\\x02\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"\n            \"\\xCD\\x02\\x00\\x00\\x80\\x3f\"\n            \"\\xD1\\x02\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\x3f\"\n            \"\\xD8\\x02\\x01\"\n            \"\\x98\\x03\\x01\",\n            72),\n        unpackedTestUnpackedTypes_(\n            \"\\x08\\x01\"\n            \"\\x10\\x01\"\n            \"\\x18\\x01\"\n            \"\\x20\\x01\"\n            \"\\x28\\x02\"\n            \"\\x30\\x02\"\n            \"\\x3D\\x01\\x00\\x00\\x00\"\n            \"\\x41\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"\n            \"\\x4D\\x01\\x00\\x00\\x00\"\n            \"\\x51\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"\n            \"\\x5D\\x00\\x00\\x80\\x3f\"\n            \"\\x61\\x00\\x00\\x00\\x00\\x00\\x00\\xf0\\x3f\"\n            \"\\x68\\x01\"\n            \"\\x70\\x01\",\n            58) {}\n  template <class Proto>\n  void SetProto3PrimitiveRepeatedFields(Proto* message) {\n    message->add_repeated_int32(1);\n    message->add_repeated_int64(1);\n    message->add_repeated_uint32(1);\n    message->add_repeated_uint64(1);\n    message->add_repeated_sint32(1);\n    message->add_repeated_sint64(1);\n    message->add_repeated_fixed32(1);\n    message->add_repeated_fixed64(1);\n    message->add_repeated_sfixed32(1);\n    message->add_repeated_sfixed64(1);\n    message->add_repeated_float(1.0);\n    message->add_repeated_double(1.0);\n    message->add_repeated_bool(true);\n    message->add_repeated_nested_enum(\n        proto3_arena_unittest::TestAllTypes_NestedEnum_FOO);\n  }\n\n  template <class Proto>\n  void ExpectProto3PrimitiveRepeatedFieldsSet(const Proto& message) {\n    EXPECT_EQ(1, message.repeated_int32(0));\n    EXPECT_EQ(1, message.repeated_int64(0));\n    EXPECT_EQ(1, message.repeated_uint32(0));\n    EXPECT_EQ(1, message.repeated_uint64(0));\n    EXPECT_EQ(1, message.repeated_sint32(0));\n    EXPECT_EQ(1, message.repeated_sint64(0));\n    EXPECT_EQ(1, message.repeated_fixed32(0));\n    EXPECT_EQ(1, message.repeated_fixed64(0));\n    EXPECT_EQ(1, message.repeated_sfixed32(0));\n    EXPECT_EQ(1, message.repeated_sfixed64(0));\n    EXPECT_EQ(1.0, message.repeated_float(0));\n    EXPECT_EQ(1.0, message.repeated_double(0));\n    EXPECT_EQ(true, message.repeated_bool(0));\n    EXPECT_EQ(proto3_arena_unittest::TestAllTypes_NestedEnum_FOO,\n              message.repeated_nested_enum(0));\n  }\n\n  template <class Proto>\n  void TestSerialization(Proto* message, const string& expected) {\n    SetProto3PrimitiveRepeatedFields(message);\n\n    int size = message->ByteSize();\n\n    // Serialize using the generated code.\n    string generated_data;\n    {\n      io::StringOutputStream raw_output(&generated_data);\n      io::CodedOutputStream output(&raw_output);\n      message->SerializeWithCachedSizes(&output);\n      ASSERT_FALSE(output.HadError());\n    }\n    EXPECT_TRUE(expected == generated_data);\n\n    // Serialize using the dynamic code.\n    string dynamic_data;\n    {\n      io::StringOutputStream raw_output(&dynamic_data);\n      io::CodedOutputStream output(&raw_output);\n      WireFormat::SerializeWithCachedSizes(*message, size, &output);\n      ASSERT_FALSE(output.HadError());\n    }\n    EXPECT_TRUE(expected == dynamic_data);\n  }\n\n  template <class Proto>\n  void TestParsing(Proto* message, const string& compatible_data) {\n    message->Clear();\n    message->ParseFromString(compatible_data);\n    ExpectProto3PrimitiveRepeatedFieldsSet(*message);\n\n    message->Clear();\n    io::CodedInputStream input(\n        reinterpret_cast<const uint8*>(compatible_data.data()),\n        compatible_data.size());\n    WireFormat::ParseAndMergePartial(&input, message);\n    ExpectProto3PrimitiveRepeatedFieldsSet(*message);\n  }\n\n  const string packedTestAllTypes_;\n  const string packedTestUnpackedTypes_;\n  const string unpackedTestAllTypes_;\n  const string unpackedTestUnpackedTypes_;\n};\n\nTEST_F(Proto3PrimitiveRepeatedWireFormatTest, Proto3PrimitiveRepeated) {\n  proto3_arena_unittest::TestAllTypes packed_message;\n  proto3_arena_unittest::TestUnpackedTypes unpacked_message;\n  TestSerialization(&packed_message, packedTestAllTypes_);\n  TestParsing(&packed_message, packedTestAllTypes_);\n  TestParsing(&packed_message, unpackedTestAllTypes_);\n  TestSerialization(&unpacked_message, unpackedTestUnpackedTypes_);\n  TestParsing(&unpacked_message, packedTestUnpackedTypes_);\n  TestParsing(&unpacked_message, unpackedTestUnpackedTypes_);\n}\n\nclass WireFormatInvalidInputTest : public testing::Test {\n protected:\n  // Make a serialized TestAllTypes in which the field optional_nested_message\n  // contains exactly the given bytes, which may be invalid.\n  string MakeInvalidEmbeddedMessage(const char* bytes, int size) {\n    const FieldDescriptor* field =\n      unittest::TestAllTypes::descriptor()->FindFieldByName(\n        \"optional_nested_message\");\n    GOOGLE_CHECK(field != NULL);\n\n    string result;\n\n    {\n      io::StringOutputStream raw_output(&result);\n      io::CodedOutputStream output(&raw_output);\n\n      WireFormatLite::WriteBytes(field->number(), string(bytes, size), &output);\n    }\n\n    return result;\n  }\n\n  // Make a serialized TestAllTypes in which the field optionalgroup\n  // contains exactly the given bytes -- which may be invalid -- and\n  // possibly no end tag.\n  string MakeInvalidGroup(const char* bytes, int size, bool include_end_tag) {\n    const FieldDescriptor* field =\n      unittest::TestAllTypes::descriptor()->FindFieldByName(\n        \"optionalgroup\");\n    GOOGLE_CHECK(field != NULL);\n\n    string result;\n\n    {\n      io::StringOutputStream raw_output(&result);\n      io::CodedOutputStream output(&raw_output);\n\n      output.WriteVarint32(WireFormat::MakeTag(field));\n      output.WriteString(string(bytes, size));\n      if (include_end_tag) {\n        output.WriteVarint32(WireFormatLite::MakeTag(\n          field->number(), WireFormatLite::WIRETYPE_END_GROUP));\n      }\n    }\n\n    return result;\n  }\n};\n\nTEST_F(WireFormatInvalidInputTest, InvalidSubMessage) {\n  unittest::TestAllTypes message;\n\n  // Control case.\n  EXPECT_TRUE(message.ParseFromString(MakeInvalidEmbeddedMessage(\"\", 0)));\n\n  // The byte is a valid varint, but not a valid tag (zero).\n  EXPECT_FALSE(message.ParseFromString(MakeInvalidEmbeddedMessage(\"\\0\", 1)));\n\n  // The byte is a malformed varint.\n  EXPECT_FALSE(message.ParseFromString(MakeInvalidEmbeddedMessage(\"\\200\", 1)));\n\n  // The byte is an endgroup tag, but we aren't parsing a group.\n  EXPECT_FALSE(message.ParseFromString(MakeInvalidEmbeddedMessage(\"\\014\", 1)));\n\n  // The byte is a valid varint but not a valid tag (bad wire type).\n  EXPECT_FALSE(message.ParseFromString(MakeInvalidEmbeddedMessage(\"\\017\", 1)));\n}\n\nTEST_F(WireFormatInvalidInputTest, InvalidGroup) {\n  unittest::TestAllTypes message;\n\n  // Control case.\n  EXPECT_TRUE(message.ParseFromString(MakeInvalidGroup(\"\", 0, true)));\n\n  // Missing end tag.  Groups cannot end at EOF.\n  EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup(\"\", 0, false)));\n\n  // The byte is a valid varint, but not a valid tag (zero).\n  EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup(\"\\0\", 1, false)));\n\n  // The byte is a malformed varint.\n  EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup(\"\\200\", 1, false)));\n\n  // The byte is an endgroup tag, but not the right one for this group.\n  EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup(\"\\014\", 1, false)));\n\n  // The byte is a valid varint but not a valid tag (bad wire type).\n  EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup(\"\\017\", 1, true)));\n}\n\nTEST_F(WireFormatInvalidInputTest, InvalidUnknownGroup) {\n  // Use TestEmptyMessage so that the group made by MakeInvalidGroup will not\n  // be a known tag number.\n  unittest::TestEmptyMessage message;\n\n  // Control case.\n  EXPECT_TRUE(message.ParseFromString(MakeInvalidGroup(\"\", 0, true)));\n\n  // Missing end tag.  Groups cannot end at EOF.\n  EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup(\"\", 0, false)));\n\n  // The byte is a valid varint, but not a valid tag (zero).\n  EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup(\"\\0\", 1, false)));\n\n  // The byte is a malformed varint.\n  EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup(\"\\200\", 1, false)));\n\n  // The byte is an endgroup tag, but not the right one for this group.\n  EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup(\"\\014\", 1, false)));\n\n  // The byte is a valid varint but not a valid tag (bad wire type).\n  EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup(\"\\017\", 1, true)));\n}\n\nTEST_F(WireFormatInvalidInputTest, InvalidStringInUnknownGroup) {\n  // Test a bug fix:  SkipMessage should fail if the message contains a string\n  // whose length would extend beyond the message end.\n\n  unittest::TestAllTypes message;\n  message.set_optional_string(\"foo foo foo foo\");\n  string data;\n  message.SerializeToString(&data);\n\n  // Chop some bytes off the end.\n  data.resize(data.size() - 4);\n\n  // Try to skip it.  Note that the bug was only present when parsing to an\n  // UnknownFieldSet.\n  io::ArrayInputStream raw_input(data.data(), data.size());\n  io::CodedInputStream coded_input(&raw_input);\n  UnknownFieldSet unknown_fields;\n  EXPECT_FALSE(WireFormat::SkipMessage(&coded_input, &unknown_fields));\n}\n\n// Test differences between string and bytes.\n// Value of a string type must be valid UTF-8 string.  When UTF-8\n// validation is enabled (GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED):\n// WriteInvalidUTF8String:  see error message.\n// ReadInvalidUTF8String:  see error message.\n// WriteValidUTF8String: fine.\n// ReadValidUTF8String:  fine.\n// WriteAnyBytes: fine.\n// ReadAnyBytes: fine.\nconst char * kInvalidUTF8String = \"Invalid UTF-8: \\xA0\\xB0\\xC0\\xD0\";\n// This used to be \"Valid UTF-8: \\x01\\x02\\u8C37\\u6B4C\", but MSVC seems to\n// interpret \\u differently from GCC.\nconst char * kValidUTF8String = \"Valid UTF-8: \\x01\\x02\\350\\260\\267\\346\\255\\214\";\n\ntemplate<typename T>\nbool WriteMessage(const char *value, T *message, string *wire_buffer) {\n  message->set_data(value);\n  wire_buffer->clear();\n  message->AppendToString(wire_buffer);\n  return (wire_buffer->size() > 0);\n}\n\ntemplate<typename T>\nbool ReadMessage(const string &wire_buffer, T *message) {\n  return message->ParseFromArray(wire_buffer.data(), wire_buffer.size());\n}\n\nbool StartsWith(const string& s, const string& prefix) {\n  return s.substr(0, prefix.length()) == prefix;\n}\n\nclass Utf8ValidationTest : public ::testing::Test {\n protected:\n  Utf8ValidationTest() {}\n  virtual ~Utf8ValidationTest() {}\n  virtual void SetUp() {\n  }\n\n};\n\nTEST_F(Utf8ValidationTest, WriteInvalidUTF8String) {\n  string wire_buffer;\n  protobuf_unittest::OneString input;\n  vector<string> errors;\n  {\n    ScopedMemoryLog log;\n    WriteMessage(kInvalidUTF8String, &input, &wire_buffer);\n    errors = log.GetMessages(ERROR);\n  }\n#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED\n  ASSERT_EQ(1, errors.size());\n  EXPECT_TRUE(StartsWith(errors[0],\n                         \"String field 'protobuf_unittest.OneString.data' \"\n                         \"contains invalid UTF-8 data when \"\n                         \"serializing a protocol buffer. Use the \"\n                         \"'bytes' type if you intend to send raw bytes.\"));\n#else\n  ASSERT_EQ(0, errors.size());\n#endif  // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED\n}\n\n\nTEST_F(Utf8ValidationTest, ReadInvalidUTF8String) {\n  string wire_buffer;\n  protobuf_unittest::OneString input;\n  WriteMessage(kInvalidUTF8String, &input, &wire_buffer);\n  protobuf_unittest::OneString output;\n  vector<string> errors;\n  {\n    ScopedMemoryLog log;\n    ReadMessage(wire_buffer, &output);\n    errors = log.GetMessages(ERROR);\n  }\n#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED\n  ASSERT_EQ(1, errors.size());\n  EXPECT_TRUE(StartsWith(errors[0],\n                         \"String field 'protobuf_unittest.OneString.data' \"\n                         \"contains invalid UTF-8 data when \"\n                         \"parsing a protocol buffer. Use the \"\n                         \"'bytes' type if you intend to send raw bytes.\"));\n\n#else\n  ASSERT_EQ(0, errors.size());\n#endif  // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED\n}\n\n\nTEST_F(Utf8ValidationTest, WriteValidUTF8String) {\n  string wire_buffer;\n  protobuf_unittest::OneString input;\n  vector<string> errors;\n  {\n    ScopedMemoryLog log;\n    WriteMessage(kValidUTF8String, &input, &wire_buffer);\n    errors = log.GetMessages(ERROR);\n  }\n  ASSERT_EQ(0, errors.size());\n}\n\nTEST_F(Utf8ValidationTest, ReadValidUTF8String) {\n  string wire_buffer;\n  protobuf_unittest::OneString input;\n  WriteMessage(kValidUTF8String, &input, &wire_buffer);\n  protobuf_unittest::OneString output;\n  vector<string> errors;\n  {\n    ScopedMemoryLog log;\n    ReadMessage(wire_buffer, &output);\n    errors = log.GetMessages(ERROR);\n  }\n  ASSERT_EQ(0, errors.size());\n  EXPECT_EQ(input.data(), output.data());\n}\n\n// Bytes: anything can pass as bytes, use invalid UTF-8 string to test\nTEST_F(Utf8ValidationTest, WriteArbitraryBytes) {\n  string wire_buffer;\n  protobuf_unittest::OneBytes input;\n  vector<string> errors;\n  {\n    ScopedMemoryLog log;\n    WriteMessage(kInvalidUTF8String, &input, &wire_buffer);\n    errors = log.GetMessages(ERROR);\n  }\n  ASSERT_EQ(0, errors.size());\n}\n\nTEST_F(Utf8ValidationTest, ReadArbitraryBytes) {\n  string wire_buffer;\n  protobuf_unittest::OneBytes input;\n  WriteMessage(kInvalidUTF8String, &input, &wire_buffer);\n  protobuf_unittest::OneBytes output;\n  vector<string> errors;\n  {\n    ScopedMemoryLog log;\n    ReadMessage(wire_buffer, &output);\n    errors = log.GetMessages(ERROR);\n  }\n  ASSERT_EQ(0, errors.size());\n  EXPECT_EQ(input.data(), output.data());\n}\n\nTEST_F(Utf8ValidationTest, ParseRepeatedString) {\n  protobuf_unittest::MoreBytes input;\n  input.add_data(kValidUTF8String);\n  input.add_data(kInvalidUTF8String);\n  input.add_data(kInvalidUTF8String);\n  string wire_buffer = input.SerializeAsString();\n\n  protobuf_unittest::MoreString output;\n  vector<string> errors;\n  {\n    ScopedMemoryLog log;\n    ReadMessage(wire_buffer, &output);\n    errors = log.GetMessages(ERROR);\n  }\n#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED\n  ASSERT_EQ(2, errors.size());\n#else\n  ASSERT_EQ(0, errors.size());\n#endif  // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED\n  EXPECT_EQ(wire_buffer, output.SerializeAsString());\n}\n\n// Test the old VerifyUTF8String() function, which may still be called by old\n// generated code.\nTEST_F(Utf8ValidationTest, OldVerifyUTF8String) {\n  string data(kInvalidUTF8String);\n\n  vector<string> errors;\n  {\n    ScopedMemoryLog log;\n    WireFormat::VerifyUTF8String(data.data(), data.size(),\n                                 WireFormat::SERIALIZE);\n    errors = log.GetMessages(ERROR);\n  }\n#ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED\n  ASSERT_EQ(1, errors.size());\n  EXPECT_TRUE(StartsWith(errors[0],\n                         \"String field contains invalid UTF-8 data when \"\n                         \"serializing a protocol buffer. Use the \"\n                         \"'bytes' type if you intend to send raw bytes.\"));\n#else\n  ASSERT_EQ(0, errors.size());\n#endif\n}\n\n\n}  // namespace\n}  // namespace internal\n}  // namespace protobuf\n}  // namespace google\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/wrappers.pb.cc",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/wrappers.proto\n\n#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION\n#include <google/protobuf/wrappers.pb.h>\n\n#include <algorithm>\n\n#include <google/protobuf/stubs/common.h>\n#include <google/protobuf/stubs/port.h>\n#include <google/protobuf/stubs/once.h>\n#include <google/protobuf/io/coded_stream.h>\n#include <google/protobuf/wire_format_lite_inl.h>\n#include <google/protobuf/descriptor.h>\n#include <google/protobuf/generated_message_reflection.h>\n#include <google/protobuf/reflection_ops.h>\n#include <google/protobuf/wire_format.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\n\nnamespace {\n\nconst ::google::protobuf::Descriptor* DoubleValue_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  DoubleValue_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* FloatValue_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  FloatValue_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* Int64Value_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  Int64Value_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* UInt64Value_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  UInt64Value_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* Int32Value_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  Int32Value_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* UInt32Value_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  UInt32Value_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* BoolValue_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  BoolValue_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* StringValue_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  StringValue_reflection_ = NULL;\nconst ::google::protobuf::Descriptor* BytesValue_descriptor_ = NULL;\nconst ::google::protobuf::internal::GeneratedMessageReflection*\n  BytesValue_reflection_ = NULL;\n\n}  // namespace\n\n\nvoid protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto() {\n  protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();\n  const ::google::protobuf::FileDescriptor* file =\n    ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(\n      \"google/protobuf/wrappers.proto\");\n  GOOGLE_CHECK(file != NULL);\n  DoubleValue_descriptor_ = file->message_type(0);\n  static const int DoubleValue_offsets_[1] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DoubleValue, value_),\n  };\n  DoubleValue_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      DoubleValue_descriptor_,\n      DoubleValue::default_instance_,\n      DoubleValue_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(DoubleValue),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DoubleValue, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DoubleValue, _is_default_instance_));\n  FloatValue_descriptor_ = file->message_type(1);\n  static const int FloatValue_offsets_[1] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FloatValue, value_),\n  };\n  FloatValue_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      FloatValue_descriptor_,\n      FloatValue::default_instance_,\n      FloatValue_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(FloatValue),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FloatValue, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(FloatValue, _is_default_instance_));\n  Int64Value_descriptor_ = file->message_type(2);\n  static const int Int64Value_offsets_[1] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int64Value, value_),\n  };\n  Int64Value_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      Int64Value_descriptor_,\n      Int64Value::default_instance_,\n      Int64Value_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(Int64Value),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int64Value, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int64Value, _is_default_instance_));\n  UInt64Value_descriptor_ = file->message_type(3);\n  static const int UInt64Value_offsets_[1] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt64Value, value_),\n  };\n  UInt64Value_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      UInt64Value_descriptor_,\n      UInt64Value::default_instance_,\n      UInt64Value_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(UInt64Value),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt64Value, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt64Value, _is_default_instance_));\n  Int32Value_descriptor_ = file->message_type(4);\n  static const int Int32Value_offsets_[1] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int32Value, value_),\n  };\n  Int32Value_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      Int32Value_descriptor_,\n      Int32Value::default_instance_,\n      Int32Value_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(Int32Value),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int32Value, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Int32Value, _is_default_instance_));\n  UInt32Value_descriptor_ = file->message_type(5);\n  static const int UInt32Value_offsets_[1] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt32Value, value_),\n  };\n  UInt32Value_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      UInt32Value_descriptor_,\n      UInt32Value::default_instance_,\n      UInt32Value_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(UInt32Value),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt32Value, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(UInt32Value, _is_default_instance_));\n  BoolValue_descriptor_ = file->message_type(6);\n  static const int BoolValue_offsets_[1] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BoolValue, value_),\n  };\n  BoolValue_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      BoolValue_descriptor_,\n      BoolValue::default_instance_,\n      BoolValue_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(BoolValue),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BoolValue, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BoolValue, _is_default_instance_));\n  StringValue_descriptor_ = file->message_type(7);\n  static const int StringValue_offsets_[1] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(StringValue, value_),\n  };\n  StringValue_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      StringValue_descriptor_,\n      StringValue::default_instance_,\n      StringValue_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(StringValue),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(StringValue, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(StringValue, _is_default_instance_));\n  BytesValue_descriptor_ = file->message_type(8);\n  static const int BytesValue_offsets_[1] = {\n    GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BytesValue, value_),\n  };\n  BytesValue_reflection_ =\n    ::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(\n      BytesValue_descriptor_,\n      BytesValue::default_instance_,\n      BytesValue_offsets_,\n      -1,\n      -1,\n      -1,\n      sizeof(BytesValue),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BytesValue, _internal_metadata_),\n      GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(BytesValue, _is_default_instance_));\n}\n\nnamespace {\n\nGOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_);\ninline void protobuf_AssignDescriptorsOnce() {\n  ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_,\n                 &protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto);\n}\n\nvoid protobuf_RegisterTypes(const ::std::string&) GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_RegisterTypes(const ::std::string&) {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      DoubleValue_descriptor_, &DoubleValue::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      FloatValue_descriptor_, &FloatValue::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      Int64Value_descriptor_, &Int64Value::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      UInt64Value_descriptor_, &UInt64Value::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      Int32Value_descriptor_, &Int32Value::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      UInt32Value_descriptor_, &UInt32Value::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      BoolValue_descriptor_, &BoolValue::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      StringValue_descriptor_, &StringValue::default_instance());\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage(\n      BytesValue_descriptor_, &BytesValue::default_instance());\n}\n\n}  // namespace\n\nvoid protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto() {\n  delete DoubleValue::default_instance_;\n  delete DoubleValue_reflection_;\n  delete FloatValue::default_instance_;\n  delete FloatValue_reflection_;\n  delete Int64Value::default_instance_;\n  delete Int64Value_reflection_;\n  delete UInt64Value::default_instance_;\n  delete UInt64Value_reflection_;\n  delete Int32Value::default_instance_;\n  delete Int32Value_reflection_;\n  delete UInt32Value::default_instance_;\n  delete UInt32Value_reflection_;\n  delete BoolValue::default_instance_;\n  delete BoolValue_reflection_;\n  delete StringValue::default_instance_;\n  delete StringValue_reflection_;\n  delete BytesValue::default_instance_;\n  delete BytesValue_reflection_;\n}\n\nvoid protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto() GOOGLE_ATTRIBUTE_COLD;\nvoid protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto() {\n  static bool already_here = false;\n  if (already_here) return;\n  already_here = true;\n  GOOGLE_PROTOBUF_VERIFY_VERSION;\n\n  ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(\n    \"\\n\\036google/protobuf/wrappers.proto\\022\\017google\"\n    \".protobuf\\\"\\034\\n\\013DoubleValue\\022\\r\\n\\005value\\030\\001 \\001(\\001\\\"\"\n    \"\\033\\n\\nFloatValue\\022\\r\\n\\005value\\030\\001 \\001(\\002\\\"\\033\\n\\nInt64Val\"\n    \"ue\\022\\r\\n\\005value\\030\\001 \\001(\\003\\\"\\034\\n\\013UInt64Value\\022\\r\\n\\005valu\"\n    \"e\\030\\001 \\001(\\004\\\"\\033\\n\\nInt32Value\\022\\r\\n\\005value\\030\\001 \\001(\\005\\\"\\034\\n\\013\"\n    \"UInt32Value\\022\\r\\n\\005value\\030\\001 \\001(\\r\\\"\\032\\n\\tBoolValue\\022\"\n    \"\\r\\n\\005value\\030\\001 \\001(\\010\\\"\\034\\n\\013StringValue\\022\\r\\n\\005value\\030\\001\"\n    \" \\001(\\t\\\"\\033\\n\\nBytesValue\\022\\r\\n\\005value\\030\\001 \\001(\\014B\\177\\n\\023com\"\n    \".google.protobufB\\rWrappersProtoP\\001Z*githu\"\n    \"b.com/golang/protobuf/ptypes/wrappers\\240\\001\\001\"\n    \"\\370\\001\\001\\242\\002\\003GPB\\252\\002\\036Google.Protobuf.WellKnownTyp\"\n    \"esb\\006proto3\", 450);\n  ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(\n    \"google/protobuf/wrappers.proto\", &protobuf_RegisterTypes);\n  DoubleValue::default_instance_ = new DoubleValue();\n  FloatValue::default_instance_ = new FloatValue();\n  Int64Value::default_instance_ = new Int64Value();\n  UInt64Value::default_instance_ = new UInt64Value();\n  Int32Value::default_instance_ = new Int32Value();\n  UInt32Value::default_instance_ = new UInt32Value();\n  BoolValue::default_instance_ = new BoolValue();\n  StringValue::default_instance_ = new StringValue();\n  BytesValue::default_instance_ = new BytesValue();\n  DoubleValue::default_instance_->InitAsDefaultInstance();\n  FloatValue::default_instance_->InitAsDefaultInstance();\n  Int64Value::default_instance_->InitAsDefaultInstance();\n  UInt64Value::default_instance_->InitAsDefaultInstance();\n  Int32Value::default_instance_->InitAsDefaultInstance();\n  UInt32Value::default_instance_->InitAsDefaultInstance();\n  BoolValue::default_instance_->InitAsDefaultInstance();\n  StringValue::default_instance_->InitAsDefaultInstance();\n  BytesValue::default_instance_->InitAsDefaultInstance();\n  ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto);\n}\n\n// Force AddDescriptors() to be called at static initialization time.\nstruct StaticDescriptorInitializer_google_2fprotobuf_2fwrappers_2eproto {\n  StaticDescriptorInitializer_google_2fprotobuf_2fwrappers_2eproto() {\n    protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();\n  }\n} static_descriptor_initializer_google_2fprotobuf_2fwrappers_2eproto_;\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int DoubleValue::kValueFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nDoubleValue::DoubleValue()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.DoubleValue)\n}\n\nDoubleValue::DoubleValue(::google::protobuf::Arena* arena)\n  : ::google::protobuf::Message(),\n  _internal_metadata_(arena) {\n  SharedCtor();\n  RegisterArenaDtor(arena);\n  // @@protoc_insertion_point(arena_constructor:google.protobuf.DoubleValue)\n}\n\nvoid DoubleValue::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n}\n\nDoubleValue::DoubleValue(const DoubleValue& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.DoubleValue)\n}\n\nvoid DoubleValue::SharedCtor() {\n    _is_default_instance_ = false;\n  _cached_size_ = 0;\n  value_ = 0;\n}\n\nDoubleValue::~DoubleValue() {\n  // @@protoc_insertion_point(destructor:google.protobuf.DoubleValue)\n  SharedDtor();\n}\n\nvoid DoubleValue::SharedDtor() {\n  if (GetArenaNoVirtual() != NULL) {\n    return;\n  }\n\n  if (this != default_instance_) {\n  }\n}\n\nvoid DoubleValue::ArenaDtor(void* object) {\n  DoubleValue* _this = reinterpret_cast< DoubleValue* >(object);\n  (void)_this;\n}\nvoid DoubleValue::RegisterArenaDtor(::google::protobuf::Arena* arena) {\n}\nvoid DoubleValue::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* DoubleValue::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return DoubleValue_descriptor_;\n}\n\nconst DoubleValue& DoubleValue::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();\n  return *default_instance_;\n}\n\nDoubleValue* DoubleValue::default_instance_ = NULL;\n\nDoubleValue* DoubleValue::New(::google::protobuf::Arena* arena) const {\n  return ::google::protobuf::Arena::CreateMessage<DoubleValue>(arena);\n}\n\nvoid DoubleValue::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.DoubleValue)\n  value_ = 0;\n}\n\nbool DoubleValue::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.DoubleValue)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional double value = 1;\n      case 1: {\n        if (tag == 9) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   double, ::google::protobuf::internal::WireFormatLite::TYPE_DOUBLE>(\n                 input, &value_)));\n\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.DoubleValue)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.DoubleValue)\n  return false;\n#undef DO_\n}\n\nvoid DoubleValue::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.DoubleValue)\n  // optional double value = 1;\n  if (this->value() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteDouble(1, this->value(), output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.DoubleValue)\n}\n\n::google::protobuf::uint8* DoubleValue::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.DoubleValue)\n  // optional double value = 1;\n  if (this->value() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteDoubleToArray(1, this->value(), target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.DoubleValue)\n  return target;\n}\n\nint DoubleValue::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.DoubleValue)\n  int total_size = 0;\n\n  // optional double value = 1;\n  if (this->value() != 0) {\n    total_size += 1 + 8;\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid DoubleValue::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.DoubleValue)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const DoubleValue* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const DoubleValue>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.DoubleValue)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.DoubleValue)\n    MergeFrom(*source);\n  }\n}\n\nvoid DoubleValue::MergeFrom(const DoubleValue& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.DoubleValue)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from.value() != 0) {\n    set_value(from.value());\n  }\n}\n\nvoid DoubleValue::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.DoubleValue)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid DoubleValue::CopyFrom(const DoubleValue& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.DoubleValue)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool DoubleValue::IsInitialized() const {\n\n  return true;\n}\n\nvoid DoubleValue::Swap(DoubleValue* other) {\n  if (other == this) return;\n  if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {\n    InternalSwap(other);\n  } else {\n    DoubleValue temp;\n    temp.MergeFrom(*this);\n    CopyFrom(*other);\n    other->CopyFrom(temp);\n  }\n}\nvoid DoubleValue::UnsafeArenaSwap(DoubleValue* other) {\n  if (other == this) return;\n  GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());\n  InternalSwap(other);\n}\nvoid DoubleValue::InternalSwap(DoubleValue* other) {\n  std::swap(value_, other->value_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata DoubleValue::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = DoubleValue_descriptor_;\n  metadata.reflection = DoubleValue_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// DoubleValue\n\n// optional double value = 1;\nvoid DoubleValue::clear_value() {\n  value_ = 0;\n}\n double DoubleValue::value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DoubleValue.value)\n  return value_;\n}\n void DoubleValue::set_value(double value) {\n  \n  value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.DoubleValue.value)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int FloatValue::kValueFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nFloatValue::FloatValue()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.FloatValue)\n}\n\nFloatValue::FloatValue(::google::protobuf::Arena* arena)\n  : ::google::protobuf::Message(),\n  _internal_metadata_(arena) {\n  SharedCtor();\n  RegisterArenaDtor(arena);\n  // @@protoc_insertion_point(arena_constructor:google.protobuf.FloatValue)\n}\n\nvoid FloatValue::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n}\n\nFloatValue::FloatValue(const FloatValue& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.FloatValue)\n}\n\nvoid FloatValue::SharedCtor() {\n    _is_default_instance_ = false;\n  _cached_size_ = 0;\n  value_ = 0;\n}\n\nFloatValue::~FloatValue() {\n  // @@protoc_insertion_point(destructor:google.protobuf.FloatValue)\n  SharedDtor();\n}\n\nvoid FloatValue::SharedDtor() {\n  if (GetArenaNoVirtual() != NULL) {\n    return;\n  }\n\n  if (this != default_instance_) {\n  }\n}\n\nvoid FloatValue::ArenaDtor(void* object) {\n  FloatValue* _this = reinterpret_cast< FloatValue* >(object);\n  (void)_this;\n}\nvoid FloatValue::RegisterArenaDtor(::google::protobuf::Arena* arena) {\n}\nvoid FloatValue::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* FloatValue::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return FloatValue_descriptor_;\n}\n\nconst FloatValue& FloatValue::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();\n  return *default_instance_;\n}\n\nFloatValue* FloatValue::default_instance_ = NULL;\n\nFloatValue* FloatValue::New(::google::protobuf::Arena* arena) const {\n  return ::google::protobuf::Arena::CreateMessage<FloatValue>(arena);\n}\n\nvoid FloatValue::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.FloatValue)\n  value_ = 0;\n}\n\nbool FloatValue::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.FloatValue)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional float value = 1;\n      case 1: {\n        if (tag == 13) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   float, ::google::protobuf::internal::WireFormatLite::TYPE_FLOAT>(\n                 input, &value_)));\n\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.FloatValue)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.FloatValue)\n  return false;\n#undef DO_\n}\n\nvoid FloatValue::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.FloatValue)\n  // optional float value = 1;\n  if (this->value() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteFloat(1, this->value(), output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.FloatValue)\n}\n\n::google::protobuf::uint8* FloatValue::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.FloatValue)\n  // optional float value = 1;\n  if (this->value() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(1, this->value(), target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.FloatValue)\n  return target;\n}\n\nint FloatValue::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.FloatValue)\n  int total_size = 0;\n\n  // optional float value = 1;\n  if (this->value() != 0) {\n    total_size += 1 + 4;\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid FloatValue::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.FloatValue)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const FloatValue* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const FloatValue>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.FloatValue)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.FloatValue)\n    MergeFrom(*source);\n  }\n}\n\nvoid FloatValue::MergeFrom(const FloatValue& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.FloatValue)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from.value() != 0) {\n    set_value(from.value());\n  }\n}\n\nvoid FloatValue::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.FloatValue)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid FloatValue::CopyFrom(const FloatValue& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.FloatValue)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool FloatValue::IsInitialized() const {\n\n  return true;\n}\n\nvoid FloatValue::Swap(FloatValue* other) {\n  if (other == this) return;\n  if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {\n    InternalSwap(other);\n  } else {\n    FloatValue temp;\n    temp.MergeFrom(*this);\n    CopyFrom(*other);\n    other->CopyFrom(temp);\n  }\n}\nvoid FloatValue::UnsafeArenaSwap(FloatValue* other) {\n  if (other == this) return;\n  GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());\n  InternalSwap(other);\n}\nvoid FloatValue::InternalSwap(FloatValue* other) {\n  std::swap(value_, other->value_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata FloatValue::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = FloatValue_descriptor_;\n  metadata.reflection = FloatValue_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// FloatValue\n\n// optional float value = 1;\nvoid FloatValue::clear_value() {\n  value_ = 0;\n}\n float FloatValue::value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FloatValue.value)\n  return value_;\n}\n void FloatValue::set_value(float value) {\n  \n  value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FloatValue.value)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int Int64Value::kValueFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nInt64Value::Int64Value()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.Int64Value)\n}\n\nInt64Value::Int64Value(::google::protobuf::Arena* arena)\n  : ::google::protobuf::Message(),\n  _internal_metadata_(arena) {\n  SharedCtor();\n  RegisterArenaDtor(arena);\n  // @@protoc_insertion_point(arena_constructor:google.protobuf.Int64Value)\n}\n\nvoid Int64Value::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n}\n\nInt64Value::Int64Value(const Int64Value& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.Int64Value)\n}\n\nvoid Int64Value::SharedCtor() {\n    _is_default_instance_ = false;\n  _cached_size_ = 0;\n  value_ = GOOGLE_LONGLONG(0);\n}\n\nInt64Value::~Int64Value() {\n  // @@protoc_insertion_point(destructor:google.protobuf.Int64Value)\n  SharedDtor();\n}\n\nvoid Int64Value::SharedDtor() {\n  if (GetArenaNoVirtual() != NULL) {\n    return;\n  }\n\n  if (this != default_instance_) {\n  }\n}\n\nvoid Int64Value::ArenaDtor(void* object) {\n  Int64Value* _this = reinterpret_cast< Int64Value* >(object);\n  (void)_this;\n}\nvoid Int64Value::RegisterArenaDtor(::google::protobuf::Arena* arena) {\n}\nvoid Int64Value::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* Int64Value::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return Int64Value_descriptor_;\n}\n\nconst Int64Value& Int64Value::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();\n  return *default_instance_;\n}\n\nInt64Value* Int64Value::default_instance_ = NULL;\n\nInt64Value* Int64Value::New(::google::protobuf::Arena* arena) const {\n  return ::google::protobuf::Arena::CreateMessage<Int64Value>(arena);\n}\n\nvoid Int64Value::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.Int64Value)\n  value_ = GOOGLE_LONGLONG(0);\n}\n\nbool Int64Value::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.Int64Value)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional int64 value = 1;\n      case 1: {\n        if (tag == 8) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   ::google::protobuf::int64, ::google::protobuf::internal::WireFormatLite::TYPE_INT64>(\n                 input, &value_)));\n\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.Int64Value)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.Int64Value)\n  return false;\n#undef DO_\n}\n\nvoid Int64Value::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.Int64Value)\n  // optional int64 value = 1;\n  if (this->value() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt64(1, this->value(), output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.Int64Value)\n}\n\n::google::protobuf::uint8* Int64Value::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Int64Value)\n  // optional int64 value = 1;\n  if (this->value() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteInt64ToArray(1, this->value(), target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Int64Value)\n  return target;\n}\n\nint Int64Value::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Int64Value)\n  int total_size = 0;\n\n  // optional int64 value = 1;\n  if (this->value() != 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::Int64Size(\n        this->value());\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid Int64Value::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Int64Value)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const Int64Value* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const Int64Value>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.Int64Value)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Int64Value)\n    MergeFrom(*source);\n  }\n}\n\nvoid Int64Value::MergeFrom(const Int64Value& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Int64Value)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from.value() != 0) {\n    set_value(from.value());\n  }\n}\n\nvoid Int64Value::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.Int64Value)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid Int64Value::CopyFrom(const Int64Value& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Int64Value)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool Int64Value::IsInitialized() const {\n\n  return true;\n}\n\nvoid Int64Value::Swap(Int64Value* other) {\n  if (other == this) return;\n  if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {\n    InternalSwap(other);\n  } else {\n    Int64Value temp;\n    temp.MergeFrom(*this);\n    CopyFrom(*other);\n    other->CopyFrom(temp);\n  }\n}\nvoid Int64Value::UnsafeArenaSwap(Int64Value* other) {\n  if (other == this) return;\n  GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());\n  InternalSwap(other);\n}\nvoid Int64Value::InternalSwap(Int64Value* other) {\n  std::swap(value_, other->value_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata Int64Value::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = Int64Value_descriptor_;\n  metadata.reflection = Int64Value_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// Int64Value\n\n// optional int64 value = 1;\nvoid Int64Value::clear_value() {\n  value_ = GOOGLE_LONGLONG(0);\n}\n ::google::protobuf::int64 Int64Value::value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Int64Value.value)\n  return value_;\n}\n void Int64Value::set_value(::google::protobuf::int64 value) {\n  \n  value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Int64Value.value)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int UInt64Value::kValueFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nUInt64Value::UInt64Value()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.UInt64Value)\n}\n\nUInt64Value::UInt64Value(::google::protobuf::Arena* arena)\n  : ::google::protobuf::Message(),\n  _internal_metadata_(arena) {\n  SharedCtor();\n  RegisterArenaDtor(arena);\n  // @@protoc_insertion_point(arena_constructor:google.protobuf.UInt64Value)\n}\n\nvoid UInt64Value::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n}\n\nUInt64Value::UInt64Value(const UInt64Value& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.UInt64Value)\n}\n\nvoid UInt64Value::SharedCtor() {\n    _is_default_instance_ = false;\n  _cached_size_ = 0;\n  value_ = GOOGLE_ULONGLONG(0);\n}\n\nUInt64Value::~UInt64Value() {\n  // @@protoc_insertion_point(destructor:google.protobuf.UInt64Value)\n  SharedDtor();\n}\n\nvoid UInt64Value::SharedDtor() {\n  if (GetArenaNoVirtual() != NULL) {\n    return;\n  }\n\n  if (this != default_instance_) {\n  }\n}\n\nvoid UInt64Value::ArenaDtor(void* object) {\n  UInt64Value* _this = reinterpret_cast< UInt64Value* >(object);\n  (void)_this;\n}\nvoid UInt64Value::RegisterArenaDtor(::google::protobuf::Arena* arena) {\n}\nvoid UInt64Value::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* UInt64Value::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return UInt64Value_descriptor_;\n}\n\nconst UInt64Value& UInt64Value::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();\n  return *default_instance_;\n}\n\nUInt64Value* UInt64Value::default_instance_ = NULL;\n\nUInt64Value* UInt64Value::New(::google::protobuf::Arena* arena) const {\n  return ::google::protobuf::Arena::CreateMessage<UInt64Value>(arena);\n}\n\nvoid UInt64Value::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.UInt64Value)\n  value_ = GOOGLE_ULONGLONG(0);\n}\n\nbool UInt64Value::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.UInt64Value)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional uint64 value = 1;\n      case 1: {\n        if (tag == 8) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   ::google::protobuf::uint64, ::google::protobuf::internal::WireFormatLite::TYPE_UINT64>(\n                 input, &value_)));\n\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.UInt64Value)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.UInt64Value)\n  return false;\n#undef DO_\n}\n\nvoid UInt64Value::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.UInt64Value)\n  // optional uint64 value = 1;\n  if (this->value() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteUInt64(1, this->value(), output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.UInt64Value)\n}\n\n::google::protobuf::uint8* UInt64Value::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UInt64Value)\n  // optional uint64 value = 1;\n  if (this->value() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteUInt64ToArray(1, this->value(), target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.UInt64Value)\n  return target;\n}\n\nint UInt64Value::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.UInt64Value)\n  int total_size = 0;\n\n  // optional uint64 value = 1;\n  if (this->value() != 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::UInt64Size(\n        this->value());\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid UInt64Value::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UInt64Value)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const UInt64Value* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const UInt64Value>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.UInt64Value)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.UInt64Value)\n    MergeFrom(*source);\n  }\n}\n\nvoid UInt64Value::MergeFrom(const UInt64Value& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UInt64Value)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from.value() != 0) {\n    set_value(from.value());\n  }\n}\n\nvoid UInt64Value::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.UInt64Value)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid UInt64Value::CopyFrom(const UInt64Value& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UInt64Value)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool UInt64Value::IsInitialized() const {\n\n  return true;\n}\n\nvoid UInt64Value::Swap(UInt64Value* other) {\n  if (other == this) return;\n  if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {\n    InternalSwap(other);\n  } else {\n    UInt64Value temp;\n    temp.MergeFrom(*this);\n    CopyFrom(*other);\n    other->CopyFrom(temp);\n  }\n}\nvoid UInt64Value::UnsafeArenaSwap(UInt64Value* other) {\n  if (other == this) return;\n  GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());\n  InternalSwap(other);\n}\nvoid UInt64Value::InternalSwap(UInt64Value* other) {\n  std::swap(value_, other->value_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata UInt64Value::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = UInt64Value_descriptor_;\n  metadata.reflection = UInt64Value_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// UInt64Value\n\n// optional uint64 value = 1;\nvoid UInt64Value::clear_value() {\n  value_ = GOOGLE_ULONGLONG(0);\n}\n ::google::protobuf::uint64 UInt64Value::value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.UInt64Value.value)\n  return value_;\n}\n void UInt64Value::set_value(::google::protobuf::uint64 value) {\n  \n  value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.UInt64Value.value)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int Int32Value::kValueFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nInt32Value::Int32Value()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.Int32Value)\n}\n\nInt32Value::Int32Value(::google::protobuf::Arena* arena)\n  : ::google::protobuf::Message(),\n  _internal_metadata_(arena) {\n  SharedCtor();\n  RegisterArenaDtor(arena);\n  // @@protoc_insertion_point(arena_constructor:google.protobuf.Int32Value)\n}\n\nvoid Int32Value::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n}\n\nInt32Value::Int32Value(const Int32Value& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.Int32Value)\n}\n\nvoid Int32Value::SharedCtor() {\n    _is_default_instance_ = false;\n  _cached_size_ = 0;\n  value_ = 0;\n}\n\nInt32Value::~Int32Value() {\n  // @@protoc_insertion_point(destructor:google.protobuf.Int32Value)\n  SharedDtor();\n}\n\nvoid Int32Value::SharedDtor() {\n  if (GetArenaNoVirtual() != NULL) {\n    return;\n  }\n\n  if (this != default_instance_) {\n  }\n}\n\nvoid Int32Value::ArenaDtor(void* object) {\n  Int32Value* _this = reinterpret_cast< Int32Value* >(object);\n  (void)_this;\n}\nvoid Int32Value::RegisterArenaDtor(::google::protobuf::Arena* arena) {\n}\nvoid Int32Value::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* Int32Value::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return Int32Value_descriptor_;\n}\n\nconst Int32Value& Int32Value::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();\n  return *default_instance_;\n}\n\nInt32Value* Int32Value::default_instance_ = NULL;\n\nInt32Value* Int32Value::New(::google::protobuf::Arena* arena) const {\n  return ::google::protobuf::Arena::CreateMessage<Int32Value>(arena);\n}\n\nvoid Int32Value::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.Int32Value)\n  value_ = 0;\n}\n\nbool Int32Value::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.Int32Value)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional int32 value = 1;\n      case 1: {\n        if (tag == 8) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(\n                 input, &value_)));\n\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.Int32Value)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.Int32Value)\n  return false;\n#undef DO_\n}\n\nvoid Int32Value::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.Int32Value)\n  // optional int32 value = 1;\n  if (this->value() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->value(), output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.Int32Value)\n}\n\n::google::protobuf::uint8* Int32Value::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.Int32Value)\n  // optional int32 value = 1;\n  if (this->value() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->value(), target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.Int32Value)\n  return target;\n}\n\nint Int32Value::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.Int32Value)\n  int total_size = 0;\n\n  // optional int32 value = 1;\n  if (this->value() != 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::Int32Size(\n        this->value());\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid Int32Value::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.Int32Value)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const Int32Value* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const Int32Value>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.Int32Value)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.Int32Value)\n    MergeFrom(*source);\n  }\n}\n\nvoid Int32Value::MergeFrom(const Int32Value& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.Int32Value)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from.value() != 0) {\n    set_value(from.value());\n  }\n}\n\nvoid Int32Value::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.Int32Value)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid Int32Value::CopyFrom(const Int32Value& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.Int32Value)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool Int32Value::IsInitialized() const {\n\n  return true;\n}\n\nvoid Int32Value::Swap(Int32Value* other) {\n  if (other == this) return;\n  if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {\n    InternalSwap(other);\n  } else {\n    Int32Value temp;\n    temp.MergeFrom(*this);\n    CopyFrom(*other);\n    other->CopyFrom(temp);\n  }\n}\nvoid Int32Value::UnsafeArenaSwap(Int32Value* other) {\n  if (other == this) return;\n  GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());\n  InternalSwap(other);\n}\nvoid Int32Value::InternalSwap(Int32Value* other) {\n  std::swap(value_, other->value_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata Int32Value::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = Int32Value_descriptor_;\n  metadata.reflection = Int32Value_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// Int32Value\n\n// optional int32 value = 1;\nvoid Int32Value::clear_value() {\n  value_ = 0;\n}\n ::google::protobuf::int32 Int32Value::value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Int32Value.value)\n  return value_;\n}\n void Int32Value::set_value(::google::protobuf::int32 value) {\n  \n  value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Int32Value.value)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int UInt32Value::kValueFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nUInt32Value::UInt32Value()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.UInt32Value)\n}\n\nUInt32Value::UInt32Value(::google::protobuf::Arena* arena)\n  : ::google::protobuf::Message(),\n  _internal_metadata_(arena) {\n  SharedCtor();\n  RegisterArenaDtor(arena);\n  // @@protoc_insertion_point(arena_constructor:google.protobuf.UInt32Value)\n}\n\nvoid UInt32Value::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n}\n\nUInt32Value::UInt32Value(const UInt32Value& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.UInt32Value)\n}\n\nvoid UInt32Value::SharedCtor() {\n    _is_default_instance_ = false;\n  _cached_size_ = 0;\n  value_ = 0u;\n}\n\nUInt32Value::~UInt32Value() {\n  // @@protoc_insertion_point(destructor:google.protobuf.UInt32Value)\n  SharedDtor();\n}\n\nvoid UInt32Value::SharedDtor() {\n  if (GetArenaNoVirtual() != NULL) {\n    return;\n  }\n\n  if (this != default_instance_) {\n  }\n}\n\nvoid UInt32Value::ArenaDtor(void* object) {\n  UInt32Value* _this = reinterpret_cast< UInt32Value* >(object);\n  (void)_this;\n}\nvoid UInt32Value::RegisterArenaDtor(::google::protobuf::Arena* arena) {\n}\nvoid UInt32Value::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* UInt32Value::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return UInt32Value_descriptor_;\n}\n\nconst UInt32Value& UInt32Value::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();\n  return *default_instance_;\n}\n\nUInt32Value* UInt32Value::default_instance_ = NULL;\n\nUInt32Value* UInt32Value::New(::google::protobuf::Arena* arena) const {\n  return ::google::protobuf::Arena::CreateMessage<UInt32Value>(arena);\n}\n\nvoid UInt32Value::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.UInt32Value)\n  value_ = 0u;\n}\n\nbool UInt32Value::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.UInt32Value)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional uint32 value = 1;\n      case 1: {\n        if (tag == 8) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(\n                 input, &value_)));\n\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.UInt32Value)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.UInt32Value)\n  return false;\n#undef DO_\n}\n\nvoid UInt32Value::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.UInt32Value)\n  // optional uint32 value = 1;\n  if (this->value() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->value(), output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.UInt32Value)\n}\n\n::google::protobuf::uint8* UInt32Value::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.UInt32Value)\n  // optional uint32 value = 1;\n  if (this->value() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->value(), target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.UInt32Value)\n  return target;\n}\n\nint UInt32Value::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.UInt32Value)\n  int total_size = 0;\n\n  // optional uint32 value = 1;\n  if (this->value() != 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::UInt32Size(\n        this->value());\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid UInt32Value::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.UInt32Value)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const UInt32Value* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const UInt32Value>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.UInt32Value)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.UInt32Value)\n    MergeFrom(*source);\n  }\n}\n\nvoid UInt32Value::MergeFrom(const UInt32Value& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.UInt32Value)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from.value() != 0) {\n    set_value(from.value());\n  }\n}\n\nvoid UInt32Value::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.UInt32Value)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid UInt32Value::CopyFrom(const UInt32Value& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.UInt32Value)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool UInt32Value::IsInitialized() const {\n\n  return true;\n}\n\nvoid UInt32Value::Swap(UInt32Value* other) {\n  if (other == this) return;\n  if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {\n    InternalSwap(other);\n  } else {\n    UInt32Value temp;\n    temp.MergeFrom(*this);\n    CopyFrom(*other);\n    other->CopyFrom(temp);\n  }\n}\nvoid UInt32Value::UnsafeArenaSwap(UInt32Value* other) {\n  if (other == this) return;\n  GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());\n  InternalSwap(other);\n}\nvoid UInt32Value::InternalSwap(UInt32Value* other) {\n  std::swap(value_, other->value_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata UInt32Value::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = UInt32Value_descriptor_;\n  metadata.reflection = UInt32Value_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// UInt32Value\n\n// optional uint32 value = 1;\nvoid UInt32Value::clear_value() {\n  value_ = 0u;\n}\n ::google::protobuf::uint32 UInt32Value::value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.UInt32Value.value)\n  return value_;\n}\n void UInt32Value::set_value(::google::protobuf::uint32 value) {\n  \n  value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.UInt32Value.value)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int BoolValue::kValueFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nBoolValue::BoolValue()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.BoolValue)\n}\n\nBoolValue::BoolValue(::google::protobuf::Arena* arena)\n  : ::google::protobuf::Message(),\n  _internal_metadata_(arena) {\n  SharedCtor();\n  RegisterArenaDtor(arena);\n  // @@protoc_insertion_point(arena_constructor:google.protobuf.BoolValue)\n}\n\nvoid BoolValue::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n}\n\nBoolValue::BoolValue(const BoolValue& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.BoolValue)\n}\n\nvoid BoolValue::SharedCtor() {\n    _is_default_instance_ = false;\n  _cached_size_ = 0;\n  value_ = false;\n}\n\nBoolValue::~BoolValue() {\n  // @@protoc_insertion_point(destructor:google.protobuf.BoolValue)\n  SharedDtor();\n}\n\nvoid BoolValue::SharedDtor() {\n  if (GetArenaNoVirtual() != NULL) {\n    return;\n  }\n\n  if (this != default_instance_) {\n  }\n}\n\nvoid BoolValue::ArenaDtor(void* object) {\n  BoolValue* _this = reinterpret_cast< BoolValue* >(object);\n  (void)_this;\n}\nvoid BoolValue::RegisterArenaDtor(::google::protobuf::Arena* arena) {\n}\nvoid BoolValue::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* BoolValue::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return BoolValue_descriptor_;\n}\n\nconst BoolValue& BoolValue::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();\n  return *default_instance_;\n}\n\nBoolValue* BoolValue::default_instance_ = NULL;\n\nBoolValue* BoolValue::New(::google::protobuf::Arena* arena) const {\n  return ::google::protobuf::Arena::CreateMessage<BoolValue>(arena);\n}\n\nvoid BoolValue::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.BoolValue)\n  value_ = false;\n}\n\nbool BoolValue::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.BoolValue)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional bool value = 1;\n      case 1: {\n        if (tag == 8) {\n          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<\n                   bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(\n                 input, &value_)));\n\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.BoolValue)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.BoolValue)\n  return false;\n#undef DO_\n}\n\nvoid BoolValue::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.BoolValue)\n  // optional bool value = 1;\n  if (this->value() != 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteBool(1, this->value(), output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.BoolValue)\n}\n\n::google::protobuf::uint8* BoolValue::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.BoolValue)\n  // optional bool value = 1;\n  if (this->value() != 0) {\n    target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(1, this->value(), target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.BoolValue)\n  return target;\n}\n\nint BoolValue::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.BoolValue)\n  int total_size = 0;\n\n  // optional bool value = 1;\n  if (this->value() != 0) {\n    total_size += 1 + 1;\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid BoolValue::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.BoolValue)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const BoolValue* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const BoolValue>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.BoolValue)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.BoolValue)\n    MergeFrom(*source);\n  }\n}\n\nvoid BoolValue::MergeFrom(const BoolValue& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.BoolValue)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from.value() != 0) {\n    set_value(from.value());\n  }\n}\n\nvoid BoolValue::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.BoolValue)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid BoolValue::CopyFrom(const BoolValue& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.BoolValue)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool BoolValue::IsInitialized() const {\n\n  return true;\n}\n\nvoid BoolValue::Swap(BoolValue* other) {\n  if (other == this) return;\n  if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {\n    InternalSwap(other);\n  } else {\n    BoolValue temp;\n    temp.MergeFrom(*this);\n    CopyFrom(*other);\n    other->CopyFrom(temp);\n  }\n}\nvoid BoolValue::UnsafeArenaSwap(BoolValue* other) {\n  if (other == this) return;\n  GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());\n  InternalSwap(other);\n}\nvoid BoolValue::InternalSwap(BoolValue* other) {\n  std::swap(value_, other->value_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata BoolValue::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = BoolValue_descriptor_;\n  metadata.reflection = BoolValue_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// BoolValue\n\n// optional bool value = 1;\nvoid BoolValue::clear_value() {\n  value_ = false;\n}\n bool BoolValue::value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.BoolValue.value)\n  return value_;\n}\n void BoolValue::set_value(bool value) {\n  \n  value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.BoolValue.value)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int StringValue::kValueFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nStringValue::StringValue()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.StringValue)\n}\n\nStringValue::StringValue(::google::protobuf::Arena* arena)\n  : ::google::protobuf::Message(),\n  _internal_metadata_(arena) {\n  SharedCtor();\n  RegisterArenaDtor(arena);\n  // @@protoc_insertion_point(arena_constructor:google.protobuf.StringValue)\n}\n\nvoid StringValue::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n}\n\nStringValue::StringValue(const StringValue& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.StringValue)\n}\n\nvoid StringValue::SharedCtor() {\n    _is_default_instance_ = false;\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n\nStringValue::~StringValue() {\n  // @@protoc_insertion_point(destructor:google.protobuf.StringValue)\n  SharedDtor();\n}\n\nvoid StringValue::SharedDtor() {\n  if (GetArenaNoVirtual() != NULL) {\n    return;\n  }\n\n  value_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());\n  if (this != default_instance_) {\n  }\n}\n\nvoid StringValue::ArenaDtor(void* object) {\n  StringValue* _this = reinterpret_cast< StringValue* >(object);\n  (void)_this;\n}\nvoid StringValue::RegisterArenaDtor(::google::protobuf::Arena* arena) {\n}\nvoid StringValue::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* StringValue::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return StringValue_descriptor_;\n}\n\nconst StringValue& StringValue::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();\n  return *default_instance_;\n}\n\nStringValue* StringValue::default_instance_ = NULL;\n\nStringValue* StringValue::New(::google::protobuf::Arena* arena) const {\n  return ::google::protobuf::Arena::CreateMessage<StringValue>(arena);\n}\n\nvoid StringValue::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.StringValue)\n  value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());\n}\n\nbool StringValue::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.StringValue)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional string value = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadString(\n                input, this->mutable_value()));\n          DO_(::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n            this->value().data(), this->value().length(),\n            ::google::protobuf::internal::WireFormatLite::PARSE,\n            \"google.protobuf.StringValue.value\"));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.StringValue)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.StringValue)\n  return false;\n#undef DO_\n}\n\nvoid StringValue::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.StringValue)\n  // optional string value = 1;\n  if (this->value().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->value().data(), this->value().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.StringValue.value\");\n    ::google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(\n      1, this->value(), output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.StringValue)\n}\n\n::google::protobuf::uint8* StringValue::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.StringValue)\n  // optional string value = 1;\n  if (this->value().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::VerifyUtf8String(\n      this->value().data(), this->value().length(),\n      ::google::protobuf::internal::WireFormatLite::SERIALIZE,\n      \"google.protobuf.StringValue.value\");\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteStringToArray(\n        1, this->value(), target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.StringValue)\n  return target;\n}\n\nint StringValue::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.StringValue)\n  int total_size = 0;\n\n  // optional string value = 1;\n  if (this->value().size() > 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::StringSize(\n        this->value());\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid StringValue::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.StringValue)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const StringValue* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const StringValue>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.StringValue)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.StringValue)\n    MergeFrom(*source);\n  }\n}\n\nvoid StringValue::MergeFrom(const StringValue& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.StringValue)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from.value().size() > 0) {\n    set_value(from.value());\n  }\n}\n\nvoid StringValue::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.StringValue)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid StringValue::CopyFrom(const StringValue& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.StringValue)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool StringValue::IsInitialized() const {\n\n  return true;\n}\n\nvoid StringValue::Swap(StringValue* other) {\n  if (other == this) return;\n  if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {\n    InternalSwap(other);\n  } else {\n    StringValue temp;\n    temp.MergeFrom(*this);\n    CopyFrom(*other);\n    other->CopyFrom(temp);\n  }\n}\nvoid StringValue::UnsafeArenaSwap(StringValue* other) {\n  if (other == this) return;\n  GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());\n  InternalSwap(other);\n}\nvoid StringValue::InternalSwap(StringValue* other) {\n  value_.Swap(&other->value_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata StringValue::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = StringValue_descriptor_;\n  metadata.reflection = StringValue_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// StringValue\n\n// optional string value = 1;\nvoid StringValue::clear_value() {\n  value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());\n}\n const ::std::string& StringValue::value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.StringValue.value)\n  return value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void StringValue::set_value(const ::std::string& value) {\n  \n  value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual());\n  // @@protoc_insertion_point(field_set:google.protobuf.StringValue.value)\n}\n void StringValue::set_value(const char* value) {\n  \n  value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value),\n              GetArenaNoVirtual());\n  // @@protoc_insertion_point(field_set_char:google.protobuf.StringValue.value)\n}\n void StringValue::set_value(const char* value,\n    size_t size) {\n  \n  value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(\n      reinterpret_cast<const char*>(value), size), GetArenaNoVirtual());\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.StringValue.value)\n}\n ::std::string* StringValue::mutable_value() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.StringValue.value)\n  return value_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());\n}\n ::std::string* StringValue::release_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.StringValue.value)\n  \n  return value_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());\n}\n ::std::string* StringValue::unsafe_arena_release_value() {\n  // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.StringValue.value)\n  GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n  \n  return value_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      GetArenaNoVirtual());\n}\n void StringValue::set_allocated_value(::std::string* value) {\n  if (value != NULL) {\n    \n  } else {\n    \n  }\n  value_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value,\n      GetArenaNoVirtual());\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.StringValue.value)\n}\n void StringValue::unsafe_arena_set_allocated_value(\n    ::std::string* value) {\n  GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n  if (value != NULL) {\n    \n  } else {\n    \n  }\n  value_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      value, GetArenaNoVirtual());\n  // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.StringValue.value)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// ===================================================================\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1900\nconst int BytesValue::kValueFieldNumber;\n#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900\n\nBytesValue::BytesValue()\n  : ::google::protobuf::Message(), _internal_metadata_(NULL) {\n  SharedCtor();\n  // @@protoc_insertion_point(constructor:google.protobuf.BytesValue)\n}\n\nBytesValue::BytesValue(::google::protobuf::Arena* arena)\n  : ::google::protobuf::Message(),\n  _internal_metadata_(arena) {\n  SharedCtor();\n  RegisterArenaDtor(arena);\n  // @@protoc_insertion_point(arena_constructor:google.protobuf.BytesValue)\n}\n\nvoid BytesValue::InitAsDefaultInstance() {\n  _is_default_instance_ = true;\n}\n\nBytesValue::BytesValue(const BytesValue& from)\n  : ::google::protobuf::Message(),\n    _internal_metadata_(NULL) {\n  SharedCtor();\n  MergeFrom(from);\n  // @@protoc_insertion_point(copy_constructor:google.protobuf.BytesValue)\n}\n\nvoid BytesValue::SharedCtor() {\n    _is_default_instance_ = false;\n  ::google::protobuf::internal::GetEmptyString();\n  _cached_size_ = 0;\n  value_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n\nBytesValue::~BytesValue() {\n  // @@protoc_insertion_point(destructor:google.protobuf.BytesValue)\n  SharedDtor();\n}\n\nvoid BytesValue::SharedDtor() {\n  if (GetArenaNoVirtual() != NULL) {\n    return;\n  }\n\n  value_.Destroy(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());\n  if (this != default_instance_) {\n  }\n}\n\nvoid BytesValue::ArenaDtor(void* object) {\n  BytesValue* _this = reinterpret_cast< BytesValue* >(object);\n  (void)_this;\n}\nvoid BytesValue::RegisterArenaDtor(::google::protobuf::Arena* arena) {\n}\nvoid BytesValue::SetCachedSize(int size) const {\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n}\nconst ::google::protobuf::Descriptor* BytesValue::descriptor() {\n  protobuf_AssignDescriptorsOnce();\n  return BytesValue_descriptor_;\n}\n\nconst BytesValue& BytesValue::default_instance() {\n  if (default_instance_ == NULL) protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();\n  return *default_instance_;\n}\n\nBytesValue* BytesValue::default_instance_ = NULL;\n\nBytesValue* BytesValue::New(::google::protobuf::Arena* arena) const {\n  return ::google::protobuf::Arena::CreateMessage<BytesValue>(arena);\n}\n\nvoid BytesValue::Clear() {\n// @@protoc_insertion_point(message_clear_start:google.protobuf.BytesValue)\n  value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());\n}\n\nbool BytesValue::MergePartialFromCodedStream(\n    ::google::protobuf::io::CodedInputStream* input) {\n#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure\n  ::google::protobuf::uint32 tag;\n  // @@protoc_insertion_point(parse_start:google.protobuf.BytesValue)\n  for (;;) {\n    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoff(127);\n    tag = p.first;\n    if (!p.second) goto handle_unusual;\n    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {\n      // optional bytes value = 1;\n      case 1: {\n        if (tag == 10) {\n          DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(\n                input, this->mutable_value()));\n        } else {\n          goto handle_unusual;\n        }\n        if (input->ExpectAtEnd()) goto success;\n        break;\n      }\n\n      default: {\n      handle_unusual:\n        if (tag == 0 ||\n            ::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==\n            ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) {\n          goto success;\n        }\n        DO_(::google::protobuf::internal::WireFormatLite::SkipField(input, tag));\n        break;\n      }\n    }\n  }\nsuccess:\n  // @@protoc_insertion_point(parse_success:google.protobuf.BytesValue)\n  return true;\nfailure:\n  // @@protoc_insertion_point(parse_failure:google.protobuf.BytesValue)\n  return false;\n#undef DO_\n}\n\nvoid BytesValue::SerializeWithCachedSizes(\n    ::google::protobuf::io::CodedOutputStream* output) const {\n  // @@protoc_insertion_point(serialize_start:google.protobuf.BytesValue)\n  // optional bytes value = 1;\n  if (this->value().size() > 0) {\n    ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(\n      1, this->value(), output);\n  }\n\n  // @@protoc_insertion_point(serialize_end:google.protobuf.BytesValue)\n}\n\n::google::protobuf::uint8* BytesValue::InternalSerializeWithCachedSizesToArray(\n    bool deterministic, ::google::protobuf::uint8* target) const {\n  // @@protoc_insertion_point(serialize_to_array_start:google.protobuf.BytesValue)\n  // optional bytes value = 1;\n  if (this->value().size() > 0) {\n    target =\n      ::google::protobuf::internal::WireFormatLite::WriteBytesToArray(\n        1, this->value(), target);\n  }\n\n  // @@protoc_insertion_point(serialize_to_array_end:google.protobuf.BytesValue)\n  return target;\n}\n\nint BytesValue::ByteSize() const {\n// @@protoc_insertion_point(message_byte_size_start:google.protobuf.BytesValue)\n  int total_size = 0;\n\n  // optional bytes value = 1;\n  if (this->value().size() > 0) {\n    total_size += 1 +\n      ::google::protobuf::internal::WireFormatLite::BytesSize(\n        this->value());\n  }\n\n  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();\n  _cached_size_ = total_size;\n  GOOGLE_SAFE_CONCURRENT_WRITES_END();\n  return total_size;\n}\n\nvoid BytesValue::MergeFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_merge_from_start:google.protobuf.BytesValue)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  const BytesValue* source = \n      ::google::protobuf::internal::DynamicCastToGenerated<const BytesValue>(\n          &from);\n  if (source == NULL) {\n  // @@protoc_insertion_point(generalized_merge_from_cast_fail:google.protobuf.BytesValue)\n    ::google::protobuf::internal::ReflectionOps::Merge(from, this);\n  } else {\n  // @@protoc_insertion_point(generalized_merge_from_cast_success:google.protobuf.BytesValue)\n    MergeFrom(*source);\n  }\n}\n\nvoid BytesValue::MergeFrom(const BytesValue& from) {\n// @@protoc_insertion_point(class_specific_merge_from_start:google.protobuf.BytesValue)\n  if (GOOGLE_PREDICT_FALSE(&from == this)) {\n    ::google::protobuf::internal::MergeFromFail(__FILE__, __LINE__);\n  }\n  if (from.value().size() > 0) {\n    set_value(from.value());\n  }\n}\n\nvoid BytesValue::CopyFrom(const ::google::protobuf::Message& from) {\n// @@protoc_insertion_point(generalized_copy_from_start:google.protobuf.BytesValue)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nvoid BytesValue::CopyFrom(const BytesValue& from) {\n// @@protoc_insertion_point(class_specific_copy_from_start:google.protobuf.BytesValue)\n  if (&from == this) return;\n  Clear();\n  MergeFrom(from);\n}\n\nbool BytesValue::IsInitialized() const {\n\n  return true;\n}\n\nvoid BytesValue::Swap(BytesValue* other) {\n  if (other == this) return;\n  if (GetArenaNoVirtual() == other->GetArenaNoVirtual()) {\n    InternalSwap(other);\n  } else {\n    BytesValue temp;\n    temp.MergeFrom(*this);\n    CopyFrom(*other);\n    other->CopyFrom(temp);\n  }\n}\nvoid BytesValue::UnsafeArenaSwap(BytesValue* other) {\n  if (other == this) return;\n  GOOGLE_DCHECK(GetArenaNoVirtual() == other->GetArenaNoVirtual());\n  InternalSwap(other);\n}\nvoid BytesValue::InternalSwap(BytesValue* other) {\n  value_.Swap(&other->value_);\n  _internal_metadata_.Swap(&other->_internal_metadata_);\n  std::swap(_cached_size_, other->_cached_size_);\n}\n\n::google::protobuf::Metadata BytesValue::GetMetadata() const {\n  protobuf_AssignDescriptorsOnce();\n  ::google::protobuf::Metadata metadata;\n  metadata.descriptor = BytesValue_descriptor_;\n  metadata.reflection = BytesValue_reflection_;\n  return metadata;\n}\n\n#if PROTOBUF_INLINE_NOT_IN_HEADERS\n// BytesValue\n\n// optional bytes value = 1;\nvoid BytesValue::clear_value() {\n  value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());\n}\n const ::std::string& BytesValue::value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.BytesValue.value)\n  return value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\n void BytesValue::set_value(const ::std::string& value) {\n  \n  value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual());\n  // @@protoc_insertion_point(field_set:google.protobuf.BytesValue.value)\n}\n void BytesValue::set_value(const char* value) {\n  \n  value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value),\n              GetArenaNoVirtual());\n  // @@protoc_insertion_point(field_set_char:google.protobuf.BytesValue.value)\n}\n void BytesValue::set_value(const void* value,\n    size_t size) {\n  \n  value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(\n      reinterpret_cast<const char*>(value), size), GetArenaNoVirtual());\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.BytesValue.value)\n}\n ::std::string* BytesValue::mutable_value() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.BytesValue.value)\n  return value_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());\n}\n ::std::string* BytesValue::release_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.BytesValue.value)\n  \n  return value_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());\n}\n ::std::string* BytesValue::unsafe_arena_release_value() {\n  // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.BytesValue.value)\n  GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n  \n  return value_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      GetArenaNoVirtual());\n}\n void BytesValue::set_allocated_value(::std::string* value) {\n  if (value != NULL) {\n    \n  } else {\n    \n  }\n  value_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value,\n      GetArenaNoVirtual());\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.BytesValue.value)\n}\n void BytesValue::unsafe_arena_set_allocated_value(\n    ::std::string* value) {\n  GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n  if (value != NULL) {\n    \n  } else {\n    \n  }\n  value_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      value, GetArenaNoVirtual());\n  // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.BytesValue.value)\n}\n\n#endif  // PROTOBUF_INLINE_NOT_IN_HEADERS\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace protobuf\n}  // namespace google\n\n// @@protoc_insertion_point(global_scope)\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/wrappers.pb.h",
    "content": "// Generated by the protocol buffer compiler.  DO NOT EDIT!\n// source: google/protobuf/wrappers.proto\n\n#ifndef PROTOBUF_google_2fprotobuf_2fwrappers_2eproto__INCLUDED\n#define PROTOBUF_google_2fprotobuf_2fwrappers_2eproto__INCLUDED\n\n#include <string>\n\n#include <google/protobuf/stubs/common.h>\n\n#if GOOGLE_PROTOBUF_VERSION < 3000000\n#error This file was generated by a newer version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please update\n#error your headers.\n#endif\n#if 3000000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION\n#error This file was generated by an older version of protoc which is\n#error incompatible with your Protocol Buffer headers.  Please\n#error regenerate this file with a newer version of protoc.\n#endif\n\n#include <google/protobuf/arena.h>\n#include <google/protobuf/arenastring.h>\n#include <google/protobuf/generated_message_util.h>\n#include <google/protobuf/metadata.h>\n#include <google/protobuf/message.h>\n#include <google/protobuf/repeated_field.h>\n#include <google/protobuf/extension_set.h>\n#include <google/protobuf/unknown_field_set.h>\n// @@protoc_insertion_point(includes)\n\nnamespace google {\nnamespace protobuf {\n\n// Internal implementation detail -- do not call these.\nvoid LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();\nvoid protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto();\nvoid protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto();\n\nclass BoolValue;\nclass BytesValue;\nclass DoubleValue;\nclass FloatValue;\nclass Int32Value;\nclass Int64Value;\nclass StringValue;\nclass UInt32Value;\nclass UInt64Value;\n\n// ===================================================================\n\nclass LIBPROTOBUF_EXPORT DoubleValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.DoubleValue) */ {\n public:\n  DoubleValue();\n  virtual ~DoubleValue();\n\n  DoubleValue(const DoubleValue& from);\n\n  inline DoubleValue& operator=(const DoubleValue& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }\n  inline void* GetMaybeArenaPointer() const {\n    return MaybeArenaPtr();\n  }\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const DoubleValue& default_instance();\n\n  void UnsafeArenaSwap(DoubleValue* other);\n  void Swap(DoubleValue* other);\n\n  // implements Message ----------------------------------------------\n\n  inline DoubleValue* New() const { return New(NULL); }\n\n  DoubleValue* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const DoubleValue& from);\n  void MergeFrom(const DoubleValue& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(DoubleValue* other);\n  protected:\n  explicit DoubleValue(::google::protobuf::Arena* arena);\n  private:\n  static void ArenaDtor(void* object);\n  inline void RegisterArenaDtor(::google::protobuf::Arena* arena);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional double value = 1;\n  void clear_value();\n  static const int kValueFieldNumber = 1;\n  double value() const;\n  void set_value(double value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.DoubleValue)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  friend class ::google::protobuf::Arena;\n  typedef void InternalArenaConstructable_;\n  typedef void DestructorSkippable_;\n  bool _is_default_instance_;\n  double value_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto();\n\n  void InitAsDefaultInstance();\n  static DoubleValue* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT FloatValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.FloatValue) */ {\n public:\n  FloatValue();\n  virtual ~FloatValue();\n\n  FloatValue(const FloatValue& from);\n\n  inline FloatValue& operator=(const FloatValue& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }\n  inline void* GetMaybeArenaPointer() const {\n    return MaybeArenaPtr();\n  }\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const FloatValue& default_instance();\n\n  void UnsafeArenaSwap(FloatValue* other);\n  void Swap(FloatValue* other);\n\n  // implements Message ----------------------------------------------\n\n  inline FloatValue* New() const { return New(NULL); }\n\n  FloatValue* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const FloatValue& from);\n  void MergeFrom(const FloatValue& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(FloatValue* other);\n  protected:\n  explicit FloatValue(::google::protobuf::Arena* arena);\n  private:\n  static void ArenaDtor(void* object);\n  inline void RegisterArenaDtor(::google::protobuf::Arena* arena);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional float value = 1;\n  void clear_value();\n  static const int kValueFieldNumber = 1;\n  float value() const;\n  void set_value(float value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.FloatValue)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  friend class ::google::protobuf::Arena;\n  typedef void InternalArenaConstructable_;\n  typedef void DestructorSkippable_;\n  bool _is_default_instance_;\n  float value_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto();\n\n  void InitAsDefaultInstance();\n  static FloatValue* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT Int64Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Int64Value) */ {\n public:\n  Int64Value();\n  virtual ~Int64Value();\n\n  Int64Value(const Int64Value& from);\n\n  inline Int64Value& operator=(const Int64Value& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }\n  inline void* GetMaybeArenaPointer() const {\n    return MaybeArenaPtr();\n  }\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const Int64Value& default_instance();\n\n  void UnsafeArenaSwap(Int64Value* other);\n  void Swap(Int64Value* other);\n\n  // implements Message ----------------------------------------------\n\n  inline Int64Value* New() const { return New(NULL); }\n\n  Int64Value* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const Int64Value& from);\n  void MergeFrom(const Int64Value& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(Int64Value* other);\n  protected:\n  explicit Int64Value(::google::protobuf::Arena* arena);\n  private:\n  static void ArenaDtor(void* object);\n  inline void RegisterArenaDtor(::google::protobuf::Arena* arena);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional int64 value = 1;\n  void clear_value();\n  static const int kValueFieldNumber = 1;\n  ::google::protobuf::int64 value() const;\n  void set_value(::google::protobuf::int64 value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.Int64Value)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  friend class ::google::protobuf::Arena;\n  typedef void InternalArenaConstructable_;\n  typedef void DestructorSkippable_;\n  bool _is_default_instance_;\n  ::google::protobuf::int64 value_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto();\n\n  void InitAsDefaultInstance();\n  static Int64Value* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT UInt64Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UInt64Value) */ {\n public:\n  UInt64Value();\n  virtual ~UInt64Value();\n\n  UInt64Value(const UInt64Value& from);\n\n  inline UInt64Value& operator=(const UInt64Value& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }\n  inline void* GetMaybeArenaPointer() const {\n    return MaybeArenaPtr();\n  }\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const UInt64Value& default_instance();\n\n  void UnsafeArenaSwap(UInt64Value* other);\n  void Swap(UInt64Value* other);\n\n  // implements Message ----------------------------------------------\n\n  inline UInt64Value* New() const { return New(NULL); }\n\n  UInt64Value* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const UInt64Value& from);\n  void MergeFrom(const UInt64Value& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(UInt64Value* other);\n  protected:\n  explicit UInt64Value(::google::protobuf::Arena* arena);\n  private:\n  static void ArenaDtor(void* object);\n  inline void RegisterArenaDtor(::google::protobuf::Arena* arena);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional uint64 value = 1;\n  void clear_value();\n  static const int kValueFieldNumber = 1;\n  ::google::protobuf::uint64 value() const;\n  void set_value(::google::protobuf::uint64 value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.UInt64Value)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  friend class ::google::protobuf::Arena;\n  typedef void InternalArenaConstructable_;\n  typedef void DestructorSkippable_;\n  bool _is_default_instance_;\n  ::google::protobuf::uint64 value_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto();\n\n  void InitAsDefaultInstance();\n  static UInt64Value* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT Int32Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.Int32Value) */ {\n public:\n  Int32Value();\n  virtual ~Int32Value();\n\n  Int32Value(const Int32Value& from);\n\n  inline Int32Value& operator=(const Int32Value& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }\n  inline void* GetMaybeArenaPointer() const {\n    return MaybeArenaPtr();\n  }\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const Int32Value& default_instance();\n\n  void UnsafeArenaSwap(Int32Value* other);\n  void Swap(Int32Value* other);\n\n  // implements Message ----------------------------------------------\n\n  inline Int32Value* New() const { return New(NULL); }\n\n  Int32Value* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const Int32Value& from);\n  void MergeFrom(const Int32Value& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(Int32Value* other);\n  protected:\n  explicit Int32Value(::google::protobuf::Arena* arena);\n  private:\n  static void ArenaDtor(void* object);\n  inline void RegisterArenaDtor(::google::protobuf::Arena* arena);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional int32 value = 1;\n  void clear_value();\n  static const int kValueFieldNumber = 1;\n  ::google::protobuf::int32 value() const;\n  void set_value(::google::protobuf::int32 value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.Int32Value)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  friend class ::google::protobuf::Arena;\n  typedef void InternalArenaConstructable_;\n  typedef void DestructorSkippable_;\n  bool _is_default_instance_;\n  ::google::protobuf::int32 value_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto();\n\n  void InitAsDefaultInstance();\n  static Int32Value* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT UInt32Value : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.UInt32Value) */ {\n public:\n  UInt32Value();\n  virtual ~UInt32Value();\n\n  UInt32Value(const UInt32Value& from);\n\n  inline UInt32Value& operator=(const UInt32Value& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }\n  inline void* GetMaybeArenaPointer() const {\n    return MaybeArenaPtr();\n  }\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const UInt32Value& default_instance();\n\n  void UnsafeArenaSwap(UInt32Value* other);\n  void Swap(UInt32Value* other);\n\n  // implements Message ----------------------------------------------\n\n  inline UInt32Value* New() const { return New(NULL); }\n\n  UInt32Value* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const UInt32Value& from);\n  void MergeFrom(const UInt32Value& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(UInt32Value* other);\n  protected:\n  explicit UInt32Value(::google::protobuf::Arena* arena);\n  private:\n  static void ArenaDtor(void* object);\n  inline void RegisterArenaDtor(::google::protobuf::Arena* arena);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional uint32 value = 1;\n  void clear_value();\n  static const int kValueFieldNumber = 1;\n  ::google::protobuf::uint32 value() const;\n  void set_value(::google::protobuf::uint32 value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.UInt32Value)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  friend class ::google::protobuf::Arena;\n  typedef void InternalArenaConstructable_;\n  typedef void DestructorSkippable_;\n  bool _is_default_instance_;\n  ::google::protobuf::uint32 value_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto();\n\n  void InitAsDefaultInstance();\n  static UInt32Value* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT BoolValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.BoolValue) */ {\n public:\n  BoolValue();\n  virtual ~BoolValue();\n\n  BoolValue(const BoolValue& from);\n\n  inline BoolValue& operator=(const BoolValue& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }\n  inline void* GetMaybeArenaPointer() const {\n    return MaybeArenaPtr();\n  }\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const BoolValue& default_instance();\n\n  void UnsafeArenaSwap(BoolValue* other);\n  void Swap(BoolValue* other);\n\n  // implements Message ----------------------------------------------\n\n  inline BoolValue* New() const { return New(NULL); }\n\n  BoolValue* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const BoolValue& from);\n  void MergeFrom(const BoolValue& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(BoolValue* other);\n  protected:\n  explicit BoolValue(::google::protobuf::Arena* arena);\n  private:\n  static void ArenaDtor(void* object);\n  inline void RegisterArenaDtor(::google::protobuf::Arena* arena);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional bool value = 1;\n  void clear_value();\n  static const int kValueFieldNumber = 1;\n  bool value() const;\n  void set_value(bool value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.BoolValue)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  friend class ::google::protobuf::Arena;\n  typedef void InternalArenaConstructable_;\n  typedef void DestructorSkippable_;\n  bool _is_default_instance_;\n  bool value_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto();\n\n  void InitAsDefaultInstance();\n  static BoolValue* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT StringValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.StringValue) */ {\n public:\n  StringValue();\n  virtual ~StringValue();\n\n  StringValue(const StringValue& from);\n\n  inline StringValue& operator=(const StringValue& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }\n  inline void* GetMaybeArenaPointer() const {\n    return MaybeArenaPtr();\n  }\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const StringValue& default_instance();\n\n  void UnsafeArenaSwap(StringValue* other);\n  void Swap(StringValue* other);\n\n  // implements Message ----------------------------------------------\n\n  inline StringValue* New() const { return New(NULL); }\n\n  StringValue* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const StringValue& from);\n  void MergeFrom(const StringValue& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(StringValue* other);\n  protected:\n  explicit StringValue(::google::protobuf::Arena* arena);\n  private:\n  static void ArenaDtor(void* object);\n  inline void RegisterArenaDtor(::google::protobuf::Arena* arena);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional string value = 1;\n  void clear_value();\n  static const int kValueFieldNumber = 1;\n  const ::std::string& value() const;\n  void set_value(const ::std::string& value);\n  void set_value(const char* value);\n  void set_value(const char* value, size_t size);\n  ::std::string* mutable_value();\n  ::std::string* release_value();\n  void set_allocated_value(::std::string* value);\n  ::std::string* unsafe_arena_release_value();\n  void unsafe_arena_set_allocated_value(\n      ::std::string* value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.StringValue)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  friend class ::google::protobuf::Arena;\n  typedef void InternalArenaConstructable_;\n  typedef void DestructorSkippable_;\n  bool _is_default_instance_;\n  ::google::protobuf::internal::ArenaStringPtr value_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto();\n\n  void InitAsDefaultInstance();\n  static StringValue* default_instance_;\n};\n// -------------------------------------------------------------------\n\nclass LIBPROTOBUF_EXPORT BytesValue : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:google.protobuf.BytesValue) */ {\n public:\n  BytesValue();\n  virtual ~BytesValue();\n\n  BytesValue(const BytesValue& from);\n\n  inline BytesValue& operator=(const BytesValue& from) {\n    CopyFrom(from);\n    return *this;\n  }\n\n  inline ::google::protobuf::Arena* GetArena() const { return GetArenaNoVirtual(); }\n  inline void* GetMaybeArenaPointer() const {\n    return MaybeArenaPtr();\n  }\n  static const ::google::protobuf::Descriptor* descriptor();\n  static const BytesValue& default_instance();\n\n  void UnsafeArenaSwap(BytesValue* other);\n  void Swap(BytesValue* other);\n\n  // implements Message ----------------------------------------------\n\n  inline BytesValue* New() const { return New(NULL); }\n\n  BytesValue* New(::google::protobuf::Arena* arena) const;\n  void CopyFrom(const ::google::protobuf::Message& from);\n  void MergeFrom(const ::google::protobuf::Message& from);\n  void CopyFrom(const BytesValue& from);\n  void MergeFrom(const BytesValue& from);\n  void Clear();\n  bool IsInitialized() const;\n\n  int ByteSize() const;\n  bool MergePartialFromCodedStream(\n      ::google::protobuf::io::CodedInputStream* input);\n  void SerializeWithCachedSizes(\n      ::google::protobuf::io::CodedOutputStream* output) const;\n  ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray(\n      bool deterministic, ::google::protobuf::uint8* output) const;\n  ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const {\n    return InternalSerializeWithCachedSizesToArray(false, output);\n  }\n  int GetCachedSize() const { return _cached_size_; }\n  private:\n  void SharedCtor();\n  void SharedDtor();\n  void SetCachedSize(int size) const;\n  void InternalSwap(BytesValue* other);\n  protected:\n  explicit BytesValue(::google::protobuf::Arena* arena);\n  private:\n  static void ArenaDtor(void* object);\n  inline void RegisterArenaDtor(::google::protobuf::Arena* arena);\n  private:\n  inline ::google::protobuf::Arena* GetArenaNoVirtual() const {\n    return _internal_metadata_.arena();\n  }\n  inline void* MaybeArenaPtr() const {\n    return _internal_metadata_.raw_arena_ptr();\n  }\n  public:\n\n  ::google::protobuf::Metadata GetMetadata() const;\n\n  // nested types ----------------------------------------------------\n\n  // accessors -------------------------------------------------------\n\n  // optional bytes value = 1;\n  void clear_value();\n  static const int kValueFieldNumber = 1;\n  const ::std::string& value() const;\n  void set_value(const ::std::string& value);\n  void set_value(const char* value);\n  void set_value(const void* value, size_t size);\n  ::std::string* mutable_value();\n  ::std::string* release_value();\n  void set_allocated_value(::std::string* value);\n  ::std::string* unsafe_arena_release_value();\n  void unsafe_arena_set_allocated_value(\n      ::std::string* value);\n\n  // @@protoc_insertion_point(class_scope:google.protobuf.BytesValue)\n private:\n\n  ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;\n  friend class ::google::protobuf::Arena;\n  typedef void InternalArenaConstructable_;\n  typedef void DestructorSkippable_;\n  bool _is_default_instance_;\n  ::google::protobuf::internal::ArenaStringPtr value_;\n  mutable int _cached_size_;\n  friend void LIBPROTOBUF_EXPORT protobuf_AddDesc_google_2fprotobuf_2fwrappers_2eproto();\n  friend void protobuf_AssignDesc_google_2fprotobuf_2fwrappers_2eproto();\n  friend void protobuf_ShutdownFile_google_2fprotobuf_2fwrappers_2eproto();\n\n  void InitAsDefaultInstance();\n  static BytesValue* default_instance_;\n};\n// ===================================================================\n\n\n// ===================================================================\n\n#if !PROTOBUF_INLINE_NOT_IN_HEADERS\n// DoubleValue\n\n// optional double value = 1;\ninline void DoubleValue::clear_value() {\n  value_ = 0;\n}\ninline double DoubleValue::value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.DoubleValue.value)\n  return value_;\n}\ninline void DoubleValue::set_value(double value) {\n  \n  value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.DoubleValue.value)\n}\n\n// -------------------------------------------------------------------\n\n// FloatValue\n\n// optional float value = 1;\ninline void FloatValue::clear_value() {\n  value_ = 0;\n}\ninline float FloatValue::value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.FloatValue.value)\n  return value_;\n}\ninline void FloatValue::set_value(float value) {\n  \n  value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.FloatValue.value)\n}\n\n// -------------------------------------------------------------------\n\n// Int64Value\n\n// optional int64 value = 1;\ninline void Int64Value::clear_value() {\n  value_ = GOOGLE_LONGLONG(0);\n}\ninline ::google::protobuf::int64 Int64Value::value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Int64Value.value)\n  return value_;\n}\ninline void Int64Value::set_value(::google::protobuf::int64 value) {\n  \n  value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Int64Value.value)\n}\n\n// -------------------------------------------------------------------\n\n// UInt64Value\n\n// optional uint64 value = 1;\ninline void UInt64Value::clear_value() {\n  value_ = GOOGLE_ULONGLONG(0);\n}\ninline ::google::protobuf::uint64 UInt64Value::value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.UInt64Value.value)\n  return value_;\n}\ninline void UInt64Value::set_value(::google::protobuf::uint64 value) {\n  \n  value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.UInt64Value.value)\n}\n\n// -------------------------------------------------------------------\n\n// Int32Value\n\n// optional int32 value = 1;\ninline void Int32Value::clear_value() {\n  value_ = 0;\n}\ninline ::google::protobuf::int32 Int32Value::value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.Int32Value.value)\n  return value_;\n}\ninline void Int32Value::set_value(::google::protobuf::int32 value) {\n  \n  value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.Int32Value.value)\n}\n\n// -------------------------------------------------------------------\n\n// UInt32Value\n\n// optional uint32 value = 1;\ninline void UInt32Value::clear_value() {\n  value_ = 0u;\n}\ninline ::google::protobuf::uint32 UInt32Value::value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.UInt32Value.value)\n  return value_;\n}\ninline void UInt32Value::set_value(::google::protobuf::uint32 value) {\n  \n  value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.UInt32Value.value)\n}\n\n// -------------------------------------------------------------------\n\n// BoolValue\n\n// optional bool value = 1;\ninline void BoolValue::clear_value() {\n  value_ = false;\n}\ninline bool BoolValue::value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.BoolValue.value)\n  return value_;\n}\ninline void BoolValue::set_value(bool value) {\n  \n  value_ = value;\n  // @@protoc_insertion_point(field_set:google.protobuf.BoolValue.value)\n}\n\n// -------------------------------------------------------------------\n\n// StringValue\n\n// optional string value = 1;\ninline void StringValue::clear_value() {\n  value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());\n}\ninline const ::std::string& StringValue::value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.StringValue.value)\n  return value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void StringValue::set_value(const ::std::string& value) {\n  \n  value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual());\n  // @@protoc_insertion_point(field_set:google.protobuf.StringValue.value)\n}\ninline void StringValue::set_value(const char* value) {\n  \n  value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value),\n              GetArenaNoVirtual());\n  // @@protoc_insertion_point(field_set_char:google.protobuf.StringValue.value)\n}\ninline void StringValue::set_value(const char* value,\n    size_t size) {\n  \n  value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(\n      reinterpret_cast<const char*>(value), size), GetArenaNoVirtual());\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.StringValue.value)\n}\ninline ::std::string* StringValue::mutable_value() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.StringValue.value)\n  return value_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());\n}\ninline ::std::string* StringValue::release_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.StringValue.value)\n  \n  return value_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());\n}\ninline ::std::string* StringValue::unsafe_arena_release_value() {\n  // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.StringValue.value)\n  GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n  \n  return value_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      GetArenaNoVirtual());\n}\ninline void StringValue::set_allocated_value(::std::string* value) {\n  if (value != NULL) {\n    \n  } else {\n    \n  }\n  value_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value,\n      GetArenaNoVirtual());\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.StringValue.value)\n}\ninline void StringValue::unsafe_arena_set_allocated_value(\n    ::std::string* value) {\n  GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n  if (value != NULL) {\n    \n  } else {\n    \n  }\n  value_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      value, GetArenaNoVirtual());\n  // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.StringValue.value)\n}\n\n// -------------------------------------------------------------------\n\n// BytesValue\n\n// optional bytes value = 1;\ninline void BytesValue::clear_value() {\n  value_.ClearToEmpty(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());\n}\ninline const ::std::string& BytesValue::value() const {\n  // @@protoc_insertion_point(field_get:google.protobuf.BytesValue.value)\n  return value_.Get(&::google::protobuf::internal::GetEmptyStringAlreadyInited());\n}\ninline void BytesValue::set_value(const ::std::string& value) {\n  \n  value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value, GetArenaNoVirtual());\n  // @@protoc_insertion_point(field_set:google.protobuf.BytesValue.value)\n}\ninline void BytesValue::set_value(const char* value) {\n  \n  value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(value),\n              GetArenaNoVirtual());\n  // @@protoc_insertion_point(field_set_char:google.protobuf.BytesValue.value)\n}\ninline void BytesValue::set_value(const void* value,\n    size_t size) {\n  \n  value_.Set(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), ::std::string(\n      reinterpret_cast<const char*>(value), size), GetArenaNoVirtual());\n  // @@protoc_insertion_point(field_set_pointer:google.protobuf.BytesValue.value)\n}\ninline ::std::string* BytesValue::mutable_value() {\n  \n  // @@protoc_insertion_point(field_mutable:google.protobuf.BytesValue.value)\n  return value_.Mutable(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());\n}\ninline ::std::string* BytesValue::release_value() {\n  // @@protoc_insertion_point(field_release:google.protobuf.BytesValue.value)\n  \n  return value_.Release(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), GetArenaNoVirtual());\n}\ninline ::std::string* BytesValue::unsafe_arena_release_value() {\n  // @@protoc_insertion_point(field_unsafe_arena_release:google.protobuf.BytesValue.value)\n  GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n  \n  return value_.UnsafeArenaRelease(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      GetArenaNoVirtual());\n}\ninline void BytesValue::set_allocated_value(::std::string* value) {\n  if (value != NULL) {\n    \n  } else {\n    \n  }\n  value_.SetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), value,\n      GetArenaNoVirtual());\n  // @@protoc_insertion_point(field_set_allocated:google.protobuf.BytesValue.value)\n}\ninline void BytesValue::unsafe_arena_set_allocated_value(\n    ::std::string* value) {\n  GOOGLE_DCHECK(GetArenaNoVirtual() != NULL);\n  if (value != NULL) {\n    \n  } else {\n    \n  }\n  value_.UnsafeArenaSetAllocated(&::google::protobuf::internal::GetEmptyStringAlreadyInited(),\n      value, GetArenaNoVirtual());\n  // @@protoc_insertion_point(field_unsafe_arena_set_allocated:google.protobuf.BytesValue.value)\n}\n\n#endif  // !PROTOBUF_INLINE_NOT_IN_HEADERS\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n// -------------------------------------------------------------------\n\n\n// @@protoc_insertion_point(namespace_scope)\n\n}  // namespace protobuf\n}  // namespace google\n\n// @@protoc_insertion_point(global_scope)\n\n#endif  // PROTOBUF_google_2fprotobuf_2fwrappers_2eproto__INCLUDED\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/src/google/protobuf/wrappers.proto",
    "content": "// Protocol Buffers - Google's data interchange format\n// Copyright 2008 Google Inc.  All rights reserved.\n// https://developers.google.com/protocol-buffers/\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n//     * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n//     * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n//     * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n// Wrappers for primitive (non-message) types. These types are useful\n// for embedding primitives in the `google.protobuf.Any` type and for places\n// where we need to distinguish between the absence of a primitive\n// typed field and its default value.\n\nsyntax = \"proto3\";\n\npackage google.protobuf;\n\noption csharp_namespace = \"Google.Protobuf.WellKnownTypes\";\noption cc_enable_arenas = true;\noption go_package = \"github.com/golang/protobuf/ptypes/wrappers\";\noption java_package = \"com.google.protobuf\";\noption java_outer_classname = \"WrappersProto\";\noption java_multiple_files = true;\noption java_generate_equals_and_hash = true;\noption objc_class_prefix = \"GPB\";\n\n// Wrapper message for `double`.\n//\n// The JSON representation for `DoubleValue` is JSON number.\nmessage DoubleValue {\n  // The double value.\n  double value = 1;\n}\n\n// Wrapper message for `float`.\n//\n// The JSON representation for `FloatValue` is JSON number.\nmessage FloatValue {\n  // The float value.\n  float value = 1;\n}\n\n// Wrapper message for `int64`.\n//\n// The JSON representation for `Int64Value` is JSON string.\nmessage Int64Value {\n  // The int64 value.\n  int64 value = 1;\n}\n\n// Wrapper message for `uint64`.\n//\n// The JSON representation for `UInt64Value` is JSON string.\nmessage UInt64Value {\n  // The uint64 value.\n  uint64 value = 1;\n}\n\n// Wrapper message for `int32`.\n//\n// The JSON representation for `Int32Value` is JSON number.\nmessage Int32Value {\n  // The int32 value.\n  int32 value = 1;\n}\n\n// Wrapper message for `uint32`.\n//\n// The JSON representation for `UInt32Value` is JSON number.\nmessage UInt32Value {\n  // The uint32 value.\n  uint32 value = 1;\n}\n\n// Wrapper message for `bool`.\n//\n// The JSON representation for `BoolValue` is JSON `true` and `false`.\nmessage BoolValue {\n  // The bool value.\n  bool value = 1;\n}\n\n// Wrapper message for `string`.\n//\n// The JSON representation for `StringValue` is JSON string.\nmessage StringValue {\n  // The string value.\n  string value = 1;\n}\n\n// Wrapper message for `bytes`.\n//\n// The JSON representation for `BytesValue` is JSON string.\nmessage BytesValue {\n  // The bytes value.\n  bytes value = 1;\n}\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/test-driver",
    "content": "#! /bin/sh\n# test-driver - basic testsuite driver script.\n\nscriptversion=2013-07-13.22; # UTC\n\n# Copyright (C) 2011-2013 Free Software Foundation, Inc.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; either version 2, or (at your option)\n# any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\n# As a special exception to the GNU General Public License, if you\n# distribute this file as part of a program that contains a\n# configuration script generated by Autoconf, you may include it under\n# the same distribution terms that you use for the rest of that program.\n\n# This file is maintained in Automake, please report\n# bugs to <bug-automake@gnu.org> or send patches to\n# <automake-patches@gnu.org>.\n\n# Make unconditional expansion of undefined variables an error.  This\n# helps a lot in preventing typo-related bugs.\nset -u\n\nusage_error ()\n{\n  echo \"$0: $*\" >&2\n  print_usage >&2\n  exit 2\n}\n\nprint_usage ()\n{\n  cat <<END\nUsage:\n  test-driver --test-name=NAME --log-file=PATH --trs-file=PATH\n              [--expect-failure={yes|no}] [--color-tests={yes|no}]\n              [--enable-hard-errors={yes|no}] [--]\n              TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS]\nThe '--test-name', '--log-file' and '--trs-file' options are mandatory.\nEND\n}\n\ntest_name= # Used for reporting.\nlog_file=  # Where to save the output of the test script.\ntrs_file=  # Where to save the metadata of the test run.\nexpect_failure=no\ncolor_tests=no\nenable_hard_errors=yes\nwhile test $# -gt 0; do\n  case $1 in\n  --help) print_usage; exit $?;;\n  --version) echo \"test-driver $scriptversion\"; exit $?;;\n  --test-name) test_name=$2; shift;;\n  --log-file) log_file=$2; shift;;\n  --trs-file) trs_file=$2; shift;;\n  --color-tests) color_tests=$2; shift;;\n  --expect-failure) expect_failure=$2; shift;;\n  --enable-hard-errors) enable_hard_errors=$2; shift;;\n  --) shift; break;;\n  -*) usage_error \"invalid option: '$1'\";;\n   *) break;;\n  esac\n  shift\ndone\n\nmissing_opts=\ntest x\"$test_name\" = x && missing_opts=\"$missing_opts --test-name\"\ntest x\"$log_file\"  = x && missing_opts=\"$missing_opts --log-file\"\ntest x\"$trs_file\"  = x && missing_opts=\"$missing_opts --trs-file\"\nif test x\"$missing_opts\" != x; then\n  usage_error \"the following mandatory options are missing:$missing_opts\"\nfi\n\nif test $# -eq 0; then\n  usage_error \"missing argument\"\nfi\n\nif test $color_tests = yes; then\n  # Keep this in sync with 'lib/am/check.am:$(am__tty_colors)'.\n  red='\u001b[0;31m' # Red.\n  grn='\u001b[0;32m' # Green.\n  lgn='\u001b[1;32m' # Light green.\n  blu='\u001b[1;34m' # Blue.\n  mgn='\u001b[0;35m' # Magenta.\n  std='\u001b[m'     # No color.\nelse\n  red= grn= lgn= blu= mgn= std=\nfi\n\ndo_exit='rm -f $log_file $trs_file; (exit $st); exit $st'\ntrap \"st=129; $do_exit\" 1\ntrap \"st=130; $do_exit\" 2\ntrap \"st=141; $do_exit\" 13\ntrap \"st=143; $do_exit\" 15\n\n# Test script is run here.\n\"$@\" >$log_file 2>&1\nestatus=$?\nif test $enable_hard_errors = no && test $estatus -eq 99; then\n  estatus=1\nfi\n\ncase $estatus:$expect_failure in\n  0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;\n  0:*)   col=$grn res=PASS  recheck=no  gcopy=no;;\n  77:*)  col=$blu res=SKIP  recheck=no  gcopy=yes;;\n  99:*)  col=$mgn res=ERROR recheck=yes gcopy=yes;;\n  *:yes) col=$lgn res=XFAIL recheck=no  gcopy=yes;;\n  *:*)   col=$red res=FAIL  recheck=yes gcopy=yes;;\nesac\n\n# Report outcome to console.\necho \"${col}${res}${std}: $test_name\"\n\n# Register the test result, and other relevant metadata.\necho \":test-result: $res\" > $trs_file\necho \":global-test-result: $res\" >> $trs_file\necho \":recheck: $recheck\" >> $trs_file\necho \":copy-in-global-log: $gcopy\" >> $trs_file\n\n# Local Variables:\n# mode: shell-script\n# sh-indentation: 2\n# eval: (add-hook 'write-file-hooks 'time-stamp)\n# time-stamp-start: \"scriptversion=\"\n# time-stamp-format: \"%:y-%02m-%02d.%02H\"\n# time-stamp-time-zone: \"UTC\"\n# time-stamp-end: \"; # UTC\"\n# End:\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/update_file_lists.sh",
    "content": "#!/bin/sh\n\n# This script copies source file lists from src/Makefile.am to cmake files.\n\nget_variable_value() {\n  local FILENAME=$1\n  local VARNAME=$2\n  awk \"\n    BEGIN { start = 0; }\n    /^$VARNAME =/ { start = 1; }\n    { if (start) { print \\$0; } }\n    /\\\\\\\\\\$/ { next; }\n    { start = 0; }\n  \" $FILENAME \\\n    | sed \"s/^$VARNAME =//\" \\\n    | sed \"s/[ \\\\]//g\" \\\n    | grep -v \"^\\\\$\" \\\n    | grep -v \"^$\" \\\n    | LC_ALL=C sort | uniq\n}\n\nget_header_files() {\n  get_variable_value $@ | grep '\\.h$'\n}\n\nget_source_files() {\n  get_variable_value $@ | grep \"cc$\"\n}\n\nget_proto_files_blacklisted() {\n  get_proto_files $@ | sed '/^google\\/protobuf\\/unittest_enormous_descriptor.proto$/d'\n}\n\nget_proto_files() {\n  get_variable_value $@ | grep \"pb.cc$\" | sed \"s/pb.cc/proto/\"\n}\n\nsort_files() {\n  for FILE in $@; do\n    echo $FILE\n  done | LC_ALL=C sort | uniq\n}\n\nMAKEFILE=src/Makefile.am\n\n[ -f \"$MAKEFILE\" ] || {\n  echo \"Cannot find: $MAKEFILE\"\n  exit 1\n}\n\n# Extract file lists from src/Makefile.am\nGZHEADERS=$(get_variable_value $MAKEFILE GZHEADERS)\nHEADERS=$(get_variable_value $MAKEFILE nobase_include_HEADERS)\nPUBLIC_HEADERS=$(sort_files $GZHEADERS $HEADERS)\nLIBPROTOBUF_LITE_SOURCES=$(get_source_files $MAKEFILE libprotobuf_lite_la_SOURCES)\nLIBPROTOBUF_SOURCES=$(get_source_files $MAKEFILE libprotobuf_la_SOURCES)\nLIBPROTOC_SOURCES=$(get_source_files $MAKEFILE libprotoc_la_SOURCES)\nLITE_PROTOS=$(get_proto_files $MAKEFILE protoc_lite_outputs)\nPROTOS=$(get_proto_files $MAKEFILE protoc_outputs)\nPROTOS_BLACKLISTED=$(get_proto_files_blacklisted $MAKEFILE protoc_outputs)\nWKT_PROTOS=$(get_variable_value $MAKEFILE nobase_dist_proto_DATA)\nCOMMON_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_TEST_SOURCES)\nCOMMON_LITE_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_LITE_TEST_SOURCES)\nTEST_SOURCES=$(get_source_files $MAKEFILE protobuf_test_SOURCES)\nLITE_TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_lite_test_SOURCES)\nLITE_ARENA_TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_lite_arena_test_SOURCES)\nTEST_PLUGIN_SOURCES=$(get_source_files $MAKEFILE test_plugin_SOURCES)\n\n################################################################################\n# Update cmake files.\n################################################################################\n\nCMAKE_DIR=cmake\nEXTRACT_INCLUDES_BAT=cmake/extract_includes.bat.in\n[ -d \"$CMAKE_DIR\" ] || {\n  echo \"Cannot find: $CMAKE_DIR\"\n  exit 1\n}\n\n[ -f \"$EXTRACT_INCLUDES_BAT\" ] || {\n  echo \"Cannot find: $EXTRACT_INCLUDES_BAT\"\n  exit 1\n}\n\nset_cmake_value() {\n  local FILENAME=$1\n  local VARNAME=$2\n  local PREFIX=$3\n  shift\n  shift\n  shift\n  awk -v values=\"$*\" -v prefix=\"$PREFIX\" \"\n    BEGIN { start = 0; }\n    /^set\\\\($VARNAME/ {\n      start = 1;\n      print \\$0;\n      len = split(values, vlist, \\\" \\\");\n      for (i = 1; i <= len; ++i) {\n        printf(\\\"  %s%s\\\\n\\\", prefix, vlist[i]);\n      }\n      next;\n    }\n    start && /^\\\\)/ {\n      start = 0;\n    }\n    !start {\n      print \\$0;\n    }\n  \" $FILENAME > /tmp/$$\n  cp /tmp/$$ $FILENAME\n}\n\n\n# Replace file lists in cmake files.\nCMAKE_PREFIX=\"\\${protobuf_source_dir}/src/\"\nset_cmake_value $CMAKE_DIR/libprotobuf-lite.cmake libprotobuf_lite_files $CMAKE_PREFIX $LIBPROTOBUF_LITE_SOURCES\nset_cmake_value $CMAKE_DIR/libprotobuf.cmake libprotobuf_files $CMAKE_PREFIX $LIBPROTOBUF_SOURCES\nset_cmake_value $CMAKE_DIR/libprotoc.cmake libprotoc_files $CMAKE_PREFIX $LIBPROTOC_SOURCES\nset_cmake_value $CMAKE_DIR/tests.cmake lite_test_protos \"\" $LITE_PROTOS\nset_cmake_value $CMAKE_DIR/tests.cmake tests_protos \"\" $PROTOS_BLACKLISTED\nset_cmake_value $CMAKE_DIR/tests.cmake common_test_files $CMAKE_PREFIX $COMMON_TEST_SOURCES\nset_cmake_value $CMAKE_DIR/tests.cmake common_lite_test_files $CMAKE_PREFIX $COMMON_LITE_TEST_SOURCES\nset_cmake_value $CMAKE_DIR/tests.cmake tests_files $CMAKE_PREFIX $TEST_SOURCES\nset_cmake_value $CMAKE_DIR/tests.cmake lite_test_files $CMAKE_PREFIX $LITE_TEST_SOURCES\nset_cmake_value $CMAKE_DIR/tests.cmake lite_arena_test_files $CMAKE_PREFIX $LITE_ARENA_TEST_SOURCES\n\n# Generate extract_includes.bat\necho \"mkdir include\" > $EXTRACT_INCLUDES_BAT\nfor HEADER in $PUBLIC_HEADERS; do\n  HEADER_DIR=$(dirname $HEADER)\n  while [ ! \"$HEADER_DIR\" = \".\" ]; do\n    echo $HEADER_DIR | sed \"s/\\\\//\\\\\\\\/g\"\n    HEADER_DIR=$(dirname $HEADER_DIR)\n  done\ndone | sort | uniq | sed \"s/^/mkdir include\\\\\\\\/\" >> $EXTRACT_INCLUDES_BAT\nfor HEADER in $PUBLIC_HEADERS; do\n  WINPATH=$(echo $HEADER | sed 's;/;\\\\;g')\n  echo \"copy \\${PROTOBUF_SOURCE_WIN32_PATH}\\\\..\\\\src\\\\$WINPATH include\\\\$WINPATH\" >> $EXTRACT_INCLUDES_BAT\ndone\n\n################################################################################\n# Update bazel BUILD files.\n################################################################################\n\nset_bazel_value() {\n  local FILENAME=$1\n  local VARNAME=$2\n  local PREFIX=$3\n  shift\n  shift\n  shift\n  awk -v values=\"$*\" -v prefix=\"$PREFIX\" \"\n    BEGIN { start = 0; }\n    /# AUTOGEN\\\\($VARNAME\\\\)/ {\n      start = 1;\n      print \\$0;\n      # replace \\$0 with indent.\n      sub(/#.*/, \\\"\\\", \\$0)\n      len = split(values, vlist, \\\" \\\");\n      for (i = 1; i <= len; ++i) {\n        printf(\\\"%s\\\\\\\"%s%s\\\\\\\",\\n\\\", \\$0, prefix, vlist[i]);\n      }\n      next;\n    }\n    start && /\\]/ {\n      start = 0\n    }\n    !start {\n      print \\$0;\n    }\n  \" $FILENAME > /tmp/$$\n  cp /tmp/$$ $FILENAME\n}\n\n\nBAZEL_BUILD=./BUILD\nBAZEL_PREFIX=\"src/\"\nif [ -f \"$BAZEL_BUILD\" ]; then\n  set_bazel_value $BAZEL_BUILD protobuf_lite_srcs $BAZEL_PREFIX $LIBPROTOBUF_LITE_SOURCES\n  set_bazel_value $BAZEL_BUILD protobuf_srcs $BAZEL_PREFIX $LIBPROTOBUF_SOURCES\n  set_bazel_value $BAZEL_BUILD protoc_lib_srcs $BAZEL_PREFIX $LIBPROTOC_SOURCES\n  set_bazel_value $BAZEL_BUILD lite_test_protos \"\" $LITE_PROTOS\n  set_bazel_value $BAZEL_BUILD well_known_protos \"\" $WKT_PROTOS\n  set_bazel_value $BAZEL_BUILD test_protos \"\" $PROTOS\n  set_bazel_value $BAZEL_BUILD common_test_srcs $BAZEL_PREFIX $COMMON_TEST_SOURCES\n  set_bazel_value $BAZEL_BUILD test_srcs $BAZEL_PREFIX $TEST_SOURCES\n  set_bazel_value $BAZEL_BUILD test_plugin_srcs $BAZEL_PREFIX $TEST_PLUGIN_SOURCES\nelse\n  echo \"Skipped BUILD file update.\"\nfi\n\n"
  },
  {
    "path": "ext/protobuf/protobuf-3.0.0/util/python/BUILD",
    "content": "# This is a placeholder for python headers. Projects needing to use\n# fast cpp protos in protobuf's python interface should build with\n# --define=use_fast_cpp_protos=true, and in addition, provide\n# //external:python_headers dependency that in turn provides Python.h.\n#\n# Projects that include protobuf using a Bazel external repository will need to\n# add a workspace rule to their WORKSPACE files to add an external workspace\n# that includes the Python headers. For example, the protobuf WORKSPACE file\n# includes the following local_repository rule that points to this directory:\n#\n# new_local_repository(\n#   name = \"python\",\n#   path = __workspace_dir__ + \"/util/python\",\n# )\ncc_library(\n    name = \"python_headers\",\n    visibility = [\"//visibility:public\"],\n)\n"
  },
  {
    "path": "ext/rapidjson/.gitattributes",
    "content": "# Set the default behavior, in case people don't have core.autocrlf set.\n* text=auto\n\n# Explicitly declare text files you want to always be normalized and converted\n# to native line endings on checkout.\n*.cpp text\n*.h text\n*.txt text\n*.md text\n*.cmake text\n*.svg text\n*.dot text\n*.yml text\n*.in text\n*.sh text\n*.autopkg text\nDockerfile text\n\n# Denote all files that are truly binary and should not be modified.\n*.png binary\n*.jpg binary\n*.json binary"
  },
  {
    "path": "ext/rapidjson/.gitignore",
    "content": "/bin/*\n!/bin/data\n!/bin/encodings\n!/bin/jsonchecker\n!/bin/types\n/build\n/doc/html\n/doc/doxygen_*.db\n*.a\n\n# Temporary files created during CMake build\nCMakeCache.txt\nCMakeFiles\ncmake_install.cmake\nCTestTestfile.cmake\nMakefile\nRapidJSON*.cmake\nRapidJSON.pc\nTesting\n/googletest\ninstall_manifest.txt\nDoxyfile\nDoxyfile.zh-cn\nDartConfiguration.tcl\n*.nupkg\n"
  },
  {
    "path": "ext/rapidjson/.gitmodules",
    "content": "[submodule \"thirdparty/gtest\"]\n\tpath = thirdparty/gtest\n\turl = https://github.com/google/googletest.git\n"
  },
  {
    "path": "ext/rapidjson/.travis.yml",
    "content": "sudo: required\ndist: precise\n\nlanguage: cpp\ncache:\n  - ccache\n\nenv:\n  global:\n    - USE_CCACHE=1\n    - CCACHE_SLOPPINESS=pch_defines,time_macros\n    - CCACHE_COMPRESS=1\n    - CCACHE_MAXSIZE=100M\n    - ARCH_FLAGS_x86='-m32'        # #266: don't use SSE on 32-bit\n    - ARCH_FLAGS_x86_64='-msse4.2' #       use SSE4.2 on 64-bit\n    - GITHUB_REPO='miloyip/rapidjson'\n    - secure: \"HrsaCb+N66EG1HR+LWH1u51SjaJyRwJEDzqJGYMB7LJ/bfqb9mWKF1fLvZGk46W5t7TVaXRDD5KHFx9DPWvKn4gRUVkwTHEy262ah5ORh8M6n/6VVVajeV/AYt2C0sswdkDBDO4Xq+xy5gdw3G8s1A4Inbm73pUh+6vx+7ltBbk=\"\n\nbefore_install:\n    - sudo apt-add-repository -y ppa:ubuntu-toolchain-r/test\n    - sudo apt-get update -qq\n    - sudo apt-get install -y cmake valgrind g++-multilib libc6-dbg:i386\n\nmatrix:\n  include:\n    # gcc\n    - env: CONF=release ARCH=x86    CXX11=ON\n      compiler: gcc\n    - env: CONF=release ARCH=x86_64 CXX11=ON\n      compiler: gcc\n    - env: CONF=debug   ARCH=x86    CXX11=OFF\n      compiler: gcc\n    - env: CONF=debug   ARCH=x86_64 CXX11=OFF\n      compiler: gcc\n    # clang\n    - env: CONF=debug   ARCH=x86    CXX11=ON CCACHE_CPP2=yes\n      compiler: clang\n    - env: CONF=debug   ARCH=x86_64 CXX11=ON CCACHE_CPP2=yes\n      compiler: clang\n    - env: CONF=debug   ARCH=x86    CXX11=OFF CCACHE_CPP2=yes\n      compiler: clang\n    - env: CONF=debug   ARCH=x86_64 CXX11=OFF CCACHE_CPP2=yes\n      compiler: clang\n    - env: CONF=release ARCH=x86    CXX11=ON CCACHE_CPP2=yes\n      compiler: clang\n    - env: CONF=release ARCH=x86_64 CXX11=ON CCACHE_CPP2=yes\n      compiler: clang\n    # coverage report\n    - env: CONF=debug   ARCH=x86    CXX11=ON GCOV_FLAGS='--coverage'\n      compiler: gcc\n      cache:\n        - ccache\n        - pip\n      after_success:\n        - pip install --user cpp-coveralls\n        - coveralls -r .. --gcov-options '\\-lp' -e thirdparty -e example -e test -e build/CMakeFiles -e include/rapidjson/msinttypes -e include/rapidjson/internal/meta.h -e include/rapidjson/error/en.h\n    - env: CONF=debug   ARCH=x86_64 GCOV_FLAGS='--coverage'\n      compiler: gcc\n      cache:\n        - ccache\n        - pip\n      after_success:\n        - pip install --user cpp-coveralls\n        - coveralls -r .. --gcov-options '\\-lp' -e thirdparty -e example -e test -e build/CMakeFiles -e include/rapidjson/msinttypes -e include/rapidjson/internal/meta.h -e include/rapidjson/error/en.h\n    - script: # Documentation task\n      - cd build\n      - cmake .. -DRAPIDJSON_HAS_STDSTRING=ON -DCMAKE_VERBOSE_MAKEFILE=ON\n      - make travis_doc\n      cache: false\n      addons:\n        apt:\n          packages:\n            - doxygen\n\nbefore_script:\n    - ccache -s\n      #   hack to avoid Valgrind bug (https://bugs.kde.org/show_bug.cgi?id=326469),\n      #   exposed by merging PR#163 (using -march=native)\n      #   TODO: Since this bug is already fixed. Remove this when valgrind can be upgraded.\n    - sed -i \"s/-march=native//\" CMakeLists.txt\n    - mkdir build\n\nscript:\n  - if [ \"$CXX\" = \"clang++\" ]; then export CXXFLAGS=\"-stdlib=libc++ ${CXXFLAGS}\"; fi\n  - >\n      eval \"ARCH_FLAGS=\\${ARCH_FLAGS_${ARCH}}\" ;\n      (cd build && cmake\n      -DRAPIDJSON_HAS_STDSTRING=ON\n      -DRAPIDJSON_BUILD_CXX11=$CXX11\n      -DCMAKE_VERBOSE_MAKEFILE=ON\n      -DCMAKE_BUILD_TYPE=$CONF\n      -DCMAKE_CXX_FLAGS=\"$ARCH_FLAGS $GCOV_FLAGS\"\n      -DCMAKE_EXE_LINKER_FLAGS=$GCOV_FLAGS\n      ..)\n  - cd build\n  - make tests -j 2\n  - make examples -j 2\n  - ctest -j 2 -V `[ \"$CONF\" = \"release\" ] || echo \"-E perftest\"`\n"
  },
  {
    "path": "ext/rapidjson/CHANGELOG.md",
    "content": "# Change Log\nAll notable changes to this project will be documented in this file.\nThis project adheres to [Semantic Versioning](http://semver.org/).\n\n## [Unreleased]\n\n## 1.1.0 - 2016-08-25\n\n### Added\n* Add GenericDocument ctor overload to specify JSON type (#369)\n* Add FAQ (#372, #373, #374, #376)\n* Add forward declaration header `fwd.h`\n* Add @PlatformIO Library Registry manifest file (#400)\n* Implement assignment operator for BigInteger (#404)\n* Add comments support (#443)\n* Adding coapp definition (#460)\n* documenttest.cpp: EXPECT_THROW when checking empty allocator (470)\n* GenericDocument: add implicit conversion to ParseResult (#480)\n* Use <wchar.h> with C++ linkage on Windows ARM (#485)\n* Detect little endian for Microsoft ARM targets \n* Check Nan/Inf when writing a double (#510)\n* Add JSON Schema Implementation (#522)\n* Add iostream wrapper (#530)\n* Add Jsonx example for converting JSON into JSONx (a XML format) (#531)\n* Add optional unresolvedTokenIndex parameter to Pointer::Get() (#532)\n* Add encoding validation option for Writer/PrettyWriter (#534)\n* Add Writer::SetMaxDecimalPlaces() (#536)\n* Support {0, } and {0, m} in Regex (#539)\n* Add Value::Get/SetFloat(), Value::IsLossLessFloat/Double() (#540)\n* Add stream position check to reader unit tests (#541)\n* Add Templated accessors and range-based for (#542)\n* Add (Pretty)Writer::RawValue() (#543)\n* Add Document::Parse(std::string), Document::Parse(const char*, size_t length) and related APIs. (#553)\n* Add move constructor for GenericSchemaDocument (#554)\n* Add VS2010 and VS2015 to AppVeyor CI (#555)\n* Add parse-by-parts example (#556, #562)\n* Support parse number as string (#564, #589)\n* Add kFormatSingleLineArray for PrettyWriter (#577)\n* Added optional support for trailing commas (#584)\n* Added filterkey and filterkeydom examples (#615)\n* Added npm docs (#639)\n* Allow options for writing and parsing NaN/Infinity (#641)\n* Add std::string overload to PrettyWriter::Key() when RAPIDJSON_HAS_STDSTRING is defined (#698)\n\n### Fixed\n* Fix gcc/clang/vc warnings (#350, #394, #397, #444, #447, #473, #515, #582, #589, #595, #667)\n* Fix documentation (#482, #511, #550, #557, #614, #635, #660)\n* Fix emscripten alignment issue (#535)\n* Fix missing allocator to uses of AddMember in document (#365)\n* CMake will no longer complain that the minimum CMake version is not specified (#501)\n* Make it usable with old VC8 (VS2005) (#383)\n* Prohibit C++11 move from Document to Value (#391)\n* Try to fix incorrect 64-bit alignment (#419)\n* Check return of fwrite to avoid warn_unused_result build failures (#421)\n* Fix UB in GenericDocument::ParseStream (#426)\n* Keep Document value unchanged on parse error (#439)\n* Add missing return statement (#450)\n* Fix Document::Parse(const Ch*) for transcoding (#478)\n* encodings.h: fix typo in preprocessor condition (#495)\n* Custom Microsoft headers are necessary only for Visual Studio 2012 and lower (#559)\n* Fix memory leak for invalid regex (26e69ffde95ba4773ab06db6457b78f308716f4b)\n* Fix a bug in schema minimum/maximum keywords for 64-bit integer (e7149d665941068ccf8c565e77495521331cf390)\n* Fix a crash bug in regex (#605)\n* Fix schema \"required\" keyword cannot handle duplicated keys (#609)\n* Fix cmake CMP0054 warning (#612)\n* Added missing include guards in istreamwrapper.h and ostreamwrapper.h (#634)\n* Fix undefined behaviour (#646)\n* Fix buffer overrun using PutN (#673)\n* Fix rapidjson::value::Get<std::string>() may returns wrong data (#681)\n* Add Flush() for all value types (#689)\n* Handle malloc() fail in PoolAllocator (#691)\n* Fix builds on x32 platform. #703\n\n### Changed\n* Clarify problematic JSON license (#392)\n* Move Travis to container based infrastructure (#504, #558)\n* Make whitespace array more compact (#513)\n* Optimize Writer::WriteString() with SIMD (#544)\n* x86-64 48-bit pointer optimization for GenericValue (#546)\n* Define RAPIDJSON_HAS_CXX11_RVALUE_REFS directly in clang (#617)\n* Make GenericSchemaDocument constructor explicit (#674)\n* Optimize FindMember when use std::string (#690)\n\n## [1.0.2] - 2015-05-14\n\n### Added\n* Add Value::XXXMember(...) overloads for std::string (#335)\n\n### Fixed\n* Include rapidjson.h for all internal/error headers.\n* Parsing some numbers incorrectly in full-precision mode (`kFullPrecisionParseFlag`) (#342)\n* Fix some numbers parsed incorrectly (#336)\n* Fix alignment of 64bit platforms (#328)\n* Fix MemoryPoolAllocator::Clear() to clear user-buffer (0691502573f1afd3341073dd24b12c3db20fbde4)\n\n### Changed\n* CMakeLists for include as a thirdparty in projects (#334, #337)\n* Change Document::ParseStream() to use stack allocator for Reader (ffbe38614732af8e0b3abdc8b50071f386a4a685) \n\n## [1.0.1] - 2015-04-25\n\n### Added\n* Changelog following [Keep a CHANGELOG](https://github.com/olivierlacan/keep-a-changelog) suggestions.\n\n### Fixed\n* Parsing of some numbers (e.g. \"1e-00011111111111\") causing assertion (#314).\n* Visual C++ 32-bit compilation error in `diyfp.h` (#317).\n\n## [1.0.0] - 2015-04-22\n\n### Added\n* 100% [Coverall](https://coveralls.io/r/miloyip/rapidjson?branch=master) coverage.\n* Version macros (#311)\n\n### Fixed\n* A bug in trimming long number sequence (4824f12efbf01af72b8cb6fc96fae7b097b73015).\n* Double quote in unicode escape (#288).\n* Negative zero roundtrip (double only) (#289).\n* Standardize behavior of `memcpy()` and `malloc()` (0c5c1538dcfc7f160e5a4aa208ddf092c787be5a, #305, 0e8bbe5e3ef375e7f052f556878be0bd79e9062d).\n\n### Removed\n* Remove an invalid `Document::ParseInsitu()` API (e7f1c6dd08b522cfcf9aed58a333bd9a0c0ccbeb).\n\n## 1.0-beta - 2015-04-8\n\n### Added\n* RFC 7159 (#101)\n* Optional Iterative Parser (#76)\n* Deep-copy values (#20)\n* Error code and message (#27)\n* ASCII Encoding (#70)\n* `kParseStopWhenDoneFlag` (#83)\n* `kParseFullPrecisionFlag` (881c91d696f06b7f302af6d04ec14dd08db66ceb)\n* Add `Key()` to handler concept (#134)\n* C++11 compatibility and support (#128)\n* Optimized number-to-string and vice versa conversions (#137, #80)\n* Short-String Optimization (#131)\n* Local stream optimization by traits (#32)\n* Travis & Appveyor Continuous Integration, with Valgrind verification (#24, #242)\n* Redo all documentation (English, Simplified Chinese)\n\n### Changed\n* Copyright ownership transfered to THL A29 Limited (a Tencent company).\n* Migrating from Premake to CMAKE (#192)\n* Resolve all warning reports\n\n### Removed\n* Remove other JSON libraries for performance comparison (#180)\n\n## 0.11 - 2012-11-16\n\n## 0.1 - 2011-11-18\n\n[Unreleased]: https://github.com/miloyip/rapidjson/compare/v1.1.0...HEAD\n[1.1.0]: https://github.com/miloyip/rapidjson/compare/v1.0.2...v1.1.0\n[1.0.2]: https://github.com/miloyip/rapidjson/compare/v1.0.1...v1.0.2\n[1.0.1]: https://github.com/miloyip/rapidjson/compare/v1.0.0...v1.0.1\n[1.0.0]: https://github.com/miloyip/rapidjson/compare/v1.0-beta...v1.0.0\n"
  },
  {
    "path": "ext/rapidjson/CMakeLists.txt",
    "content": "CMAKE_MINIMUM_REQUIRED(VERSION 2.8)\nif(POLICY CMP0025)\n  # detect Apple's Clang\n  cmake_policy(SET CMP0025 NEW)\nendif()\nif(POLICY CMP0054)\n  cmake_policy(SET CMP0054 NEW)\nendif()\n\nSET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules)\n\nPROJECT(RapidJSON CXX)\n\nset(LIB_MAJOR_VERSION \"1\")\nset(LIB_MINOR_VERSION \"1\")\nset(LIB_PATCH_VERSION \"0\")\nset(LIB_VERSION_STRING \"${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_PATCH_VERSION}\")\n\n# compile in release with debug info mode by default\nif(NOT CMAKE_BUILD_TYPE)\n    set(CMAKE_BUILD_TYPE \"RelWithDebInfo\" CACHE STRING \"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel.\" FORCE)\nendif()\n\n# Build all binaries in a separate directory\nSET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)\n\noption(RAPIDJSON_BUILD_DOC \"Build rapidjson documentation.\" ON)\noption(RAPIDJSON_BUILD_EXAMPLES \"Build rapidjson examples.\" ON)\noption(RAPIDJSON_BUILD_TESTS \"Build rapidjson perftests and unittests.\" ON)\noption(RAPIDJSON_BUILD_THIRDPARTY_GTEST\n    \"Use gtest installation in `thirdparty/gtest` by default if available\" OFF)\n\noption(RAPIDJSON_BUILD_CXX11 \"Build rapidjson with C++11 (gcc/clang)\" ON)\n\noption(RAPIDJSON_BUILD_ASAN \"Build rapidjson with address sanitizer (gcc/clang)\" OFF)\noption(RAPIDJSON_BUILD_UBSAN \"Build rapidjson with undefined behavior sanitizer (gcc/clang)\" OFF)\n\noption(RAPIDJSON_HAS_STDSTRING \"\" OFF)\nif(RAPIDJSON_HAS_STDSTRING)\n    add_definitions(-DRAPIDJSON_HAS_STDSTRING)\nendif()\n\nfind_program(CCACHE_FOUND ccache)\nif(CCACHE_FOUND)\n    set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)\n    set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)\n    if (CMAKE_CXX_COMPILER_ID MATCHES \"Clang\")\n        set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics\")\n    endif()\nendif(CCACHE_FOUND)\n\nif (\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"GNU\")\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra -Werror\")\n    if (RAPIDJSON_BUILD_CXX11)\n        if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS \"4.7.0\")\n            set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -std=c++0x\")\n        else()\n            set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -std=c++11\")\n        endif()\n    endif()\n    if (RAPIDJSON_BUILD_ASAN)\n        if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS \"4.8.0\")\n            message(FATAL_ERROR \"GCC < 4.8 doesn't support the address sanitizer\")\n        else()\n            set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -fsanitize=address\")\n        endif()\n    endif()\n    if (RAPIDJSON_BUILD_UBSAN)\n        if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS \"4.9.0\")\n            message(FATAL_ERROR \"GCC < 4.9 doesn't support the undefined behavior sanitizer\")\n        else()\n            set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -fsanitize=undefined\")\n        endif()\n    endif()\nelseif (CMAKE_CXX_COMPILER_ID MATCHES \"Clang\")\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -march=native -Wall -Wextra -Werror -Wno-missing-field-initializers\")\n    if (RAPIDJSON_BUILD_CXX11)\n        set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -std=c++11\")\n    endif()\n    if (RAPIDJSON_BUILD_ASAN)\n        set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -fsanitize=address\")\n    endif()\n    if (RAPIDJSON_BUILD_UBSAN)\n        if (CMAKE_CXX_COMPILER_ID STREQUAL \"AppleClang\")\n            set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -fsanitize=undefined-trap -fsanitize-undefined-trap-on-error\")\n        else()\n            set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -fsanitize=undefined\")\n        endif()\n    endif()\nelseif (\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"MSVC\")\n    add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} /EHsc\")\nendif()\n\n#add extra search paths for libraries and includes\nSET(INCLUDE_INSTALL_DIR \"${CMAKE_INSTALL_PREFIX}/include\" CACHE PATH \"The directory the headers are installed in\")\nSET(LIB_INSTALL_DIR \"${CMAKE_INSTALL_PREFIX}/lib\" CACHE STRING \"Directory where lib will install\")\nSET(DOC_INSTALL_DIR \"${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}\" CACHE PATH \"Path to the documentation\")\n\nIF(UNIX OR CYGWIN)\n    SET(_CMAKE_INSTALL_DIR \"${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME}\")\nELSEIF(WIN32)\n    SET(_CMAKE_INSTALL_DIR \"${CMAKE_INSTALL_PREFIX}/cmake\")\nENDIF()\nSET(CMAKE_INSTALL_DIR \"${_CMAKE_INSTALL_DIR}\" CACHE PATH \"The directory cmake fiels are installed in\")\n\ninclude_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)\n\nif(RAPIDJSON_BUILD_DOC)\n    add_subdirectory(doc)\nendif()\n\nadd_custom_target(travis_doc)\nadd_custom_command(TARGET travis_doc\n    COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/travis-doxygen.sh)\n\nif(RAPIDJSON_BUILD_EXAMPLES)\n    add_subdirectory(example)\nendif()\n\nif(RAPIDJSON_BUILD_TESTS)\n    if(MSVC11)\n        # required for VS2012 due to missing support for variadic templates\n        add_definitions(-D_VARIADIC_MAX=10)\n    endif(MSVC11)\n    add_subdirectory(test)\n    include(CTest)\nendif()\n\n# pkg-config\nIF (UNIX OR CYGWIN)\n  CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in\n                  ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc\n                  @ONLY)\n  INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc\n      DESTINATION \"${LIB_INSTALL_DIR}/pkgconfig\"\n      COMPONENT pkgconfig)\nENDIF()\n\ninstall(FILES readme.md\n        DESTINATION \"${DOC_INSTALL_DIR}\"\n        COMPONENT doc)\n\ninstall(DIRECTORY include/rapidjson\n    DESTINATION \"${INCLUDE_INSTALL_DIR}\"\n    COMPONENT dev)\n\ninstall(DIRECTORY example/\n    DESTINATION \"${DOC_INSTALL_DIR}/examples\"\n    COMPONENT examples\n    # Following patterns are for excluding the intermediate/object files\n    # from an install of in-source CMake build.\n    PATTERN \"CMakeFiles\" EXCLUDE\n    PATTERN \"Makefile\" EXCLUDE\n    PATTERN \"cmake_install.cmake\" EXCLUDE)\n\n# Provide config and version files to be used by other applications\n# ===============================\n\nexport(PACKAGE ${PROJECT_NAME})\n\n# cmake-modules\nCONFIGURE_FILE(${PROJECT_NAME}Config.cmake.in\n    ${PROJECT_NAME}Config.cmake\n    @ONLY)\nCONFIGURE_FILE(${PROJECT_NAME}ConfigVersion.cmake.in\n    ${PROJECT_NAME}ConfigVersion.cmake\n    @ONLY)\nINSTALL(FILES\n    ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake\n    ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake\n    DESTINATION \"${CMAKE_INSTALL_DIR}\"\n    COMPONENT dev)\n"
  },
  {
    "path": "ext/rapidjson/CMakeModules/FindGTestSrc.cmake",
    "content": "\nSET(GTEST_SEARCH_PATH\n    \"${GTEST_SOURCE_DIR}\"\n    \"${CMAKE_CURRENT_LIST_DIR}/../thirdparty/gtest/googletest\")\n\nIF(UNIX)\n    IF(RAPIDJSON_BUILD_THIRDPARTY_GTEST)\n        LIST(APPEND GTEST_SEARCH_PATH \"/usr/src/gtest\")\n    ELSE()\n        LIST(INSERT GTEST_SEARCH_PATH 1 \"/usr/src/gtest\")\n    ENDIF()\nENDIF()\n\nFIND_PATH(GTEST_SOURCE_DIR\n    NAMES CMakeLists.txt src/gtest_main.cc\n    PATHS ${GTEST_SEARCH_PATH})\n\n\n# Debian installs gtest include directory in /usr/include, thus need to look\n# for include directory separately from source directory.\nFIND_PATH(GTEST_INCLUDE_DIR\n    NAMES gtest/gtest.h\n    PATH_SUFFIXES include\n    HINTS ${GTEST_SOURCE_DIR}\n    PATHS ${GTEST_SEARCH_PATH})\n\nINCLUDE(FindPackageHandleStandardArgs)\nfind_package_handle_standard_args(GTestSrc DEFAULT_MSG\n    GTEST_SOURCE_DIR\n    GTEST_INCLUDE_DIR)\n"
  },
  {
    "path": "ext/rapidjson/RapidJSON.pc.in",
    "content": "includedir=@INCLUDE_INSTALL_DIR@\n\nName: @PROJECT_NAME@\nDescription: A fast JSON parser/generator for C++ with both SAX/DOM style API\nVersion: @LIB_VERSION_STRING@\nURL: https://github.com/miloyip/rapidjson\nCflags: -I${includedir}\n"
  },
  {
    "path": "ext/rapidjson/RapidJSONConfig.cmake.in",
    "content": "get_filename_component(RAPIDJSON_CMAKE_DIR \"${CMAKE_CURRENT_LIST_FILE}\" PATH)\nset(RAPIDJSON_INCLUDE_DIRS \"@INCLUDE_INSTALL_DIR@\")\nmessage(STATUS \"RapidJSON found. Headers: ${RAPIDJSON_INCLUDE_DIRS}\")\n"
  },
  {
    "path": "ext/rapidjson/RapidJSONConfigVersion.cmake.in",
    "content": "SET(PACKAGE_VERSION \"@LIB_VERSION_STRING@\")\n\nIF (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)\n  SET(PACKAGE_VERSION_EXACT \"true\")\nENDIF (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)\nIF (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)\n  SET(PACKAGE_VERSION_COMPATIBLE \"true\")\nELSE (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)\n  SET(PACKAGE_VERSION_UNSUITABLE \"true\")\nENDIF (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)\n"
  },
  {
    "path": "ext/rapidjson/appveyor.yml",
    "content": "os: Visual Studio 2015 CTP  \nversion: 1.1.0.{build}\n\nconfiguration:\n- Debug\n- Release\n\nenvironment:\n  matrix:\n  # - VS_VERSION: 9 2008\n  #   VS_PLATFORM: win32\n  # - VS_VERSION: 9 2008\n  #   VS_PLATFORM: x64\n  - VS_VERSION: 10 2010\n    VS_PLATFORM: win32\n  - VS_VERSION: 10 2010\n    VS_PLATFORM: x64\n  - VS_VERSION: 11 2012\n    VS_PLATFORM: win32\n  - VS_VERSION: 11 2012\n    VS_PLATFORM: x64\n  - VS_VERSION: 12 2013\n    VS_PLATFORM: win32\n  - VS_VERSION: 12 2013\n    VS_PLATFORM: x64\n  - VS_VERSION: 14 2015\n    VS_PLATFORM: win32\n  - VS_VERSION: 14 2015\n    VS_PLATFORM: x64\n\nbefore_build:\n- git submodule update --init --recursive\n- cmake -H. -BBuild/VS -G \"Visual Studio %VS_VERSION%\" -DCMAKE_GENERATOR_PLATFORM=%VS_PLATFORM% -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_SHARED_LIBS=true -Wno-dev\n\nbuild:\n  project: Build\\VS\\RapidJSON.sln\n  parallel: true\n  verbosity: minimal\n\ntest_script:\n- cd Build\\VS && if %CONFIGURATION%==Debug (ctest --verbose -E perftest --build-config %CONFIGURATION%) else (ctest --verbose --build-config %CONFIGURATION%)\n"
  },
  {
    "path": "ext/rapidjson/bin/data/glossary.json",
    "content": "{\r\n    \"glossary\": {\r\n        \"title\": \"example glossary\",\r\n\t\t\"GlossDiv\": {\r\n            \"title\": \"S\",\r\n\t\t\t\"GlossList\": {\r\n                \"GlossEntry\": {\r\n                    \"ID\": \"SGML\",\r\n\t\t\t\t\t\"SortAs\": \"SGML\",\r\n\t\t\t\t\t\"GlossTerm\": \"Standard Generalized Markup Language\",\r\n\t\t\t\t\t\"Acronym\": \"SGML\",\r\n\t\t\t\t\t\"Abbrev\": \"ISO 8879:1986\",\r\n\t\t\t\t\t\"GlossDef\": {\r\n                        \"para\": \"A meta-markup language, used to create markup languages such as DocBook.\",\r\n\t\t\t\t\t\t\"GlossSeeAlso\": [\"GML\", \"XML\"]\r\n                    },\r\n\t\t\t\t\t\"GlossSee\": \"markup\"\r\n                }\r\n            }\r\n        }\r\n    }\r\n}"
  },
  {
    "path": "ext/rapidjson/bin/data/menu.json",
    "content": "{\"menu\": {\r\n    \"header\": \"SVG Viewer\",\r\n    \"items\": [\r\n        {\"id\": \"Open\"},\r\n        {\"id\": \"OpenNew\", \"label\": \"Open New\"},\r\n        null,\r\n        {\"id\": \"ZoomIn\", \"label\": \"Zoom In\"},\r\n        {\"id\": \"ZoomOut\", \"label\": \"Zoom Out\"},\r\n        {\"id\": \"OriginalView\", \"label\": \"Original View\"},\r\n        null,\r\n        {\"id\": \"Quality\"},\r\n        {\"id\": \"Pause\"},\r\n        {\"id\": \"Mute\"},\r\n        null,\r\n        {\"id\": \"Find\", \"label\": \"Find...\"},\r\n        {\"id\": \"FindAgain\", \"label\": \"Find Again\"},\r\n        {\"id\": \"Copy\"},\r\n        {\"id\": \"CopyAgain\", \"label\": \"Copy Again\"},\r\n        {\"id\": \"CopySVG\", \"label\": \"Copy SVG\"},\r\n        {\"id\": \"ViewSVG\", \"label\": \"View SVG\"},\r\n        {\"id\": \"ViewSource\", \"label\": \"View Source\"},\r\n        {\"id\": \"SaveAs\", \"label\": \"Save As\"},\r\n        null,\r\n        {\"id\": \"Help\"},\r\n        {\"id\": \"About\", \"label\": \"About Adobe CVG Viewer...\"}\r\n    ]\r\n}}"
  },
  {
    "path": "ext/rapidjson/bin/data/readme.txt",
    "content": "sample.json is obtained from http://code.google.com/p/json-test-suite/downloads/detail?name=sample.zip\n"
  },
  {
    "path": "ext/rapidjson/bin/data/sample.json",
    "content": "{\n \"a\": {\n  \"6U閆崬밺뀫颒myj츥휘:$薈mY햚#rz飏+玭V㭢뾿愴YꖚX亥ᮉ푊\\u0006垡㐭룝\\\"厓ᔧḅ^Sqpv媫\\\"⤽걒\\\"˽Ἆ?ꇆ䬔未tv{DV鯀Tἆl凸g\\\\㈭ĭ즿UH㽤\": null,\n  \"b茤z\\\\.N\": [[\n   \"ZL:ￄዎ*Y|猫劁櫕荾Oj为1糕쪥泏S룂w࡛Ᏺ⸥蚙)\",\n   {\n    \"\\\"䬰ỐwD捾V`邀⠕VD㺝sH6[칑.:醥葹*뻵倻aD\\\"\": true,\n    \"e浱up蔽Cr෠JK軵xCʨ<뜡癙Y獩ｹ齈X/螗唻?<蘡+뷄㩤쳖3偑犾&\\\\첊xz坍崦ݻ鍴\\\"嵥B3㰃詤豺嚼aqJ⑆∥韼@\\u000b㢊\\u0015L臯.샥\": false,\n    \"l?Ǩ喳e6㔡$M꼄I,(3᝝縢,䊀疅뉲B㴔傳䂴\\u0088㮰钘ꜵ!ᅛ韽>\": -5514085325291784739,\n    \"o㮚?\\\"춛㵉<\\/﬊ࠃ䃪䝣wp6ἀ䱄[s*S嬈貒pᛥ㰉'돀\": [{\n     \"(QP윤懊FI<ꃣ『䕷[\\\"珒嶮?%Ḭ壍಻䇟0荤!藲끹bd浶tl\\u2049#쯀@僞\": {\"i妾8홫\": {\n      \",M맃䞛K5nAㆴVN㒊햬$n꩑&ꎝ椞阫?/ṏ세뉪1x쥼㻤㪙`\\\"$쟒薟B煌܀쨝ଢ଼2掳7㙟鴙X婢\\u0002\": \"Vዉ菈᧷⦌kﮞఈnz*<?੃'ahhCFX(\\u0007⮊E㭍䱾Gxꥩr❣.洎\",\n      \"뻴5bDD큯O傆盓왻U?ꞅꐊN鐭᧢τ\\\"迳豲8\\u001b䃥ꂻ䴺ྸH筴,\": {\n       \"\\\"L鸔SE㬡XV&~͎'놅蔞눶l匛?'.K氁\\\\ƢẨ疇mΊ'꽳&!鹠m'|{P痊 秄쒿u\\u00111䋧gϩx7t丗D䊨䠻z0.A0\": -1.50139930144708198E18,\n       \"8鋂뛷?첒B☚>﷜FM\\\"荭7ꍀ-VR<\\/';䁙E9$䩉\\f @s?퍪o3^衴cඎ䧪aK鼟ｑ䆨c{䳠5mᒲՙ蘹ᮩ\": {\n        \"F㲷JGo⯍P덵x뒳p䘧☔\\\"+ꨲ吿JfR㔹)4n紬G练Q፞!C|\": true,\n        \"p^㫮솎oc.೚A㤠??r\\u000f)⾽⌲們M2.䴘䩳:⫭胃\\\\፾@Fᭌ\\\\K\": false,\n        \"蟌Tk愙潦伩\": {\n         \"a<\\/@ᾛ慂侇瘎\": -7271305752851720826,\n         \"艓藬/>၄ṯ,XW~㲆w\": {\"E痧郶)㜓ha朗!N赻瞉駠uC\\u20ad辠<Ve?폱!Im䁎搄:*s 9諚Prᵾ뒰髶B̌qWA8梸vS⫊⢳{t㺲q㺈랊뮣RqK밢쳪\": [\n          false,\n          {\n           \"\\u000b=>x퓮⣫P1ࠫLMMX'M刼唳됤\": null,\n           \"P쓫晥%k覛ዩIUᇸ滨:噐혲lMR5䋈V梗>%幽u頖\\\\)쟟\": null,\n           \"eg+昉~矠䧞难\\b?gQ쭷筝\\\\eꮠNl{ಢ哭|]Mn銌╥zꖘzⱷ⭤ᮜ^\": [\n            -1.30142114406914976E17,\n            -1.7555215491128452E-19,\n            null,\n            \"渾㨝ߏ牄귛r?돌?w[⚞ӻ~廩輫㼧/\",\n            -4.5737191805302129E18,\n            null,\n            \"xy࿑M[oc셒竓Ⓔx?뜓y䊦>-D켍(&&?XKkc꩖ﺸᏋ뵞K伕6ী)딀P朁yW揙?훻魢傎EG碸9類៌g踲C⟌aEX舲:z꒸许\",\n            3808159498143417627,\n            null,\n            {\"m試\\u20df1{G8&뚈h홯J<\\/\": {\n             \"3ஸ厠zs#1K7:rᥞoꅔꯧ&띇鵼鞫6跜#赿5l'8{7㕳(b/j\\\"厢aq籀ꏚ\\u0015厼稥\": [\n              -2226135764510113982,\n              true,\n              null,\n              {\n               \"h%'맞S싅Hs&dl슾W0j鿏MםD놯L~S-㇡R쭬%\": null,\n               \"⟓咔謡칲\\u0000孺ꛭx旑檉㶆?\": null,\n               \"恇I転;￸B2Y`z\\\\獓w,놏濐撐埵䂄)!䶢D=ഭ㴟jyY\": {\n                \"$ࡘt厛毣ൢI芁<겿骫⫦6tr惺a\": [\n                 6.385779736989334E-20,\n                 false,\n                 true,\n                 true,\n                 [\n                  -6.891946211462334E-19,\n                  null,\n                  {\n                   \"]-\\\\Ꟑ1/薓❧Ὂ\\\\l牑\\u0007A郃)阜ᇒᓌ-塯`W峬G}SDb㬨Q臉⮻빌O鞟톴첂B㺱<ƈmu챑J㴹㷳픷Oㆩs\": {\n                    \"\\\"◉B\\\"pᶉt骔J꩸ᄇᛐi╰栛K쉷㉯鐩!㈐n칍䟅難>盥y铿e୔蒏M貹ヅ8嘋퀯䉶ጥ㏢殊뻳\\\"絧╿ꉑ䠥?∃蓊{}㣣Gk긔H1哵峱\": false,\n                    \"6.瀫cN䇮F㧺?\\\\椯=ڈT䘆4␘8qv\": -3.5687501019676885E-19,\n                    \"Q?yऴr혴{஀䳘p惭f1ﹸ䅷䕋贲<ྃᄊ繲hq\\\\b|#QSTs1c-7(䵢\\u2069匏絘ꯉ:l毴汞t戀oෟᵶ뮱፣-醇Jx䙬䐁햢0࣫ᡁgrㄛ\": \"\\u0011_xM/蘇Chv;dhA5.嗀绱V爤ﰦi뵲M\",\n                    \"⏑[\\\"ugoy^儣횎~U\\\\섯겜論l2jw஌yD腅̂\\u0019\": true,\n                    \"ⵯɇ䐲᫿࢚!㯢l샅笶戮1꣖0Xe\": null,\n                    \"劅f넀識b宁焊E찓橵G!ʱ獓뭔雩괛\": [{\"p⹣켙[q>燣䍃㞽ᩲx:쓤삘7玑퇼0<\\/q璂ᑁ[Z\\\\3䅵䧳\\u0011㤧|妱緒C['췓Yꞟ3Z鳱雼P錻BU씧U`ᢶg蓱>.1ӧ譫'L_5V䏵Ц\": [\n                     false,\n                     false,\n                     {\"22䂍盥N霂얢<F8꼵7Gసyh뀍g᦭ꄢx硴嬢\\u001a?E괆T|;7犟\\\"Wt%䐩O⨵t&#ᬋK'蜍Ძ揔⾠鲂T멷靃\\u0018䓞cE\": {\"f=䏏츜瞾zw?孡鏣\\\\铀᫞yẆg(\\u0011M6(s2]`ਫ\": [[[{\n                      \"'y몱纣4S@\\\\,i㷯럹Ua充Tᣢ9躘Zଞ쥿䐊s<\\/刎\\\\\\\"뉦-8/\": \"蜑.X0꭛낢륹i젨ꚁ<8?s볕蝡|Q✬᯦@\\\\G㑢屿Mn졾J굤⥟JW뤵苑r쁕툄嵵?⾥O\",\n                      \"^1挲~[n귆誈央碠멪gI洷\": -8214236471236116548,\n                      \"sሣ%娌暡clr蟜㑓2\\u000bS❟_X㨔⚴5~蔷ꀇ|Xu㬖,꤭卹r(g믇쩍%췸앙|栣U\\\\2]䤉+啠菡ꯎT鉹m\\n/`SzDᅼ鞶\": 1.1217523390167132E-19,\n                      \"u톇=黚\\\\ ꂮ췵L>躰e9⑩_뵜斌n@B}$괻Yᐱ@䧋V\\\"☒-諯cV돯ʠ\": true,\n                      \"Ű螧ᔼ檍鍎땒딜qꄃH뜣<獧ूCY吓⸏>XQ㵡趌o끬k픀빯a(ܵ甏끆୯/6Nᪧ}搚ᆚ짌P牰泱鈷^d꣟#L삀\\\"㕹襻;k㸊\\\\f+\": true,\n                      \"쎣\\\",|⫝̸阊x庿k잣v庅$鈏괎炔k쬪O_\": [\n                       \"잩AzZGz3v愠ꉈⵎ?㊱}S尳௏p\\r2>췝IP䘈M)w|\\u000eE\",\n                       -9222726055990423201,\n                       null,\n                       [\n                        false,\n                        {\"´킮'뮤쯽Wx讐V,6ᩪ1紲aႈ\\u205czD\": [\n                         -930994432421097536,\n                         3157232031581030121,\n                         \"l貚PY䃛5@䭄<nW\\u001e\",\n                         [\n                          3.801747732605161E18,\n                          [\n                           null,\n                           false,\n                           {\n                            \"\": 4.0442013775147072E16,\n                            \"2J[sᡪ㞿|n'#廲꯬乞\": true,\n                            \"B[繰`\\\\㏏a̼㨀偛㽓<\\/꥖ᵈO让\\r43⡩徑ﬓ๨ﮕx:㣜o玐ꉟぢC珵὆ᓞ쇓Qs氯였9駵q혃Ljꂔ<\\/昺+t䐋༻猙c沪~櫆bpJ9UᏐ:칣妙!皗F4㑄탎䕀櫳振讓\": 7.3924182188256287E18,\n                            \"H磵ai委曷n柋T<\\/勿F&:ꣴfU@㿗榻Lb+?퍄sp\\\"᪟~>귻m㎮琸f\": 1.0318894506812084E-19,\n                            \"࢜⩢Ш䧔1肽씮+༎ᣰ闺馺窃䕨8Mƶq腽xc(៯夐J5굄䕁Qj_훨/~価.䢵慯틠퇱豠㼇Qﵘ$DuSp(8Uญ<\\/ಟ룴𥳐ݩ$\": 8350772684161555590,\n                            \"ㆎQ䄾\\u001bpᩭ${[諟^^骴᤮b^ㅥI┧T㉇⾞\\\"绦<AYJ⒃-oF<\\/蛎mm;obh婃ᦢ\": false,\n                            \"䔤䣈?汝.p襟&d㱅\\\\Jᚠ@?O첁ࢽ휔VR蔩|㒢柺\": [[\n                             \"-ꕨ岓棻r@鿆^3~䪤Ѐ狼︌ﹲ\\\\᝸MlE쵠Q+\",\n                             null,\n                             false,\n                             3346674396990536343,\n                             null,\n                             {\n                              \"\": null,\n                              \"/䏨S쨑,&繷㉥8C엮赸3馢|뇲{鄎ꗇqFﶉ雕UD躢?Ꟛအ꽡[hᕱᗅ㦋쭞Mユ茍?L槽암V#성唐%㣕嘵\\\\ڹ(嘏躿&q\": [\n                               -1364715155337673920,\n                               false,\n                               -8197733031775379251,\n                               \"E팗鮲JwH\\\\觡܈᜝\\\"+뉞娂N휗v噙၂깼\\u001dD帒l%-斔N\",\n                               -3.844267973858711E-20,\n                               [{\"쬯(褈Q 蟚뿢 /ⱖ㻥\\u0017/?v邘䃡0U.Z1x?鯔V尠8Em<\": [[[\n                                null,\n                                [\n                                 null,\n                                 -5841406347577698873,\n                                 \"킷\\\"S⋄籞繗솸ᵣ浵w쑿ퟗ7nᎏx3앙z㘌쿸I葥覯㬏0ᆝb汆狺뷘ႀnꋋ\",\n                                 -1227911573141158702,\n                                 {\n                                  \"u㉮PᾺV鵸A\\\\g*ࡗ9슟晭+ͧↀ쿅H\\u001c꾣犓}癇恛ᗬ黩䟘X梑鐆e>r䰂f矩'-7䡭桥Dz兔V9谶居㺍ᔊ䩯덲.\\u001eL0ὅㅷ釣\": [{\n                                   \"<쯬J卷^숞u࠯䌗艞R9닪g㐾볎a䂈歖意:%鐔|ﵤ|y}>;2,覂⶚啵tb*仛8乒㓶B࿠㯉戩oX 貘5V嗆렽낁߼4h䧛ꍺM空\\\\b꿋貼\": 8478577078537189402,\n                                   \"VD*|吝z~h譺aᯒ\": {\n                                    \"YI췢K<\\/濳xNne玗rJo쾘3핰鴊\\\"↱AR:ࢷ\\\"9?\\\"臁說)?誚ꊏe)_D翾W?&F6J@뺾ꍰNZ醊Z쾈വH嶿?炫㷱鬰M겈<bS}㎥l|刖k\": {\"H7鷮퇢_k\": [\n                                     true,\n                                     \"s㟑瀭좾쮀⑁Y찺k맢戲쀸俻ກ6儮끗扖puߖꜻ馶rꈞ痘?3ྚ畊惘䎗\\\"vv)*臔웅鿈䧲^v,껛㰙J <ᚶ5\",\n                                     7950276470944656796,\n                                     4.9392301536234746E17,\n                                     -4796050478201554639,\n                                     \"yꬴc<3㻚\",\n                                     \"o塁\\u20a4蒵鮬裢CᴧnB㭱f.\",\n                                     false,\n                                     [\n                                      false,\n                                      \"㡐弑V?瀆䰺q!출㇞yᘪ꼼(IS~Ka 烿ꟿ샕桤\\u0005HQҹ㯪罂q萾⚇懋⦕둡v\",\n                                      1862560050083946970,\n                                      \"\\u20b6[|(뭹gꍒ펉O轄Dl묽]ﯨ髯QEbA㒾m@롴礠㕓2땫n6ْ엘঵篳R잷꙲m색摪|@㿫5aK设f胭r8/NI4춫栵\\\\꯬2]\",\n                                      false,\n                                      {\n                                       \"\\u000b7*㙛燏.~?䔊p搕e_拺艿뷍f{ꔻ1s驙`$Ė戧?q⋬沭?塷᭚蹀unoa5\": {\n                                        \"S귯o紞㾕ᅶ侏銇12|ʟ畴iNAo?|Sw$M拲գ㭄紧螆+,梔\": null,\n                                        \"㭚0?xB疱敻ேBPwv뾃熉(ӠpJ]갢\\\"Bj'\\u0016GE椱<\\/zgៅx黢礇h},M9ﴦ?LḨ\": \"Si B%~㬒E\",\n                                        \"핇㉊살㍢숨~ȪRo䦅D桺0z]﬽蠆c9ᣨyPP㿷U~㞐?쯟퍸宒뉆U|}㉓郾ࣻ*櫎꼪䁗s?~7\\u001e㘔h9{aឋ}:㶒P8\": [{\"\\\\R囡쐬nN柋琍؛7칾 :㶃衇徜V 深f1淍♠i?3S角폞^ᆞ\\u20e8ṰD\\u0007秡+躒臔&-6\": {\n                                         \"䨑g.fh㔗=8!\\\"狿ൻLU^뻱g䲚㻐'W}k欤?๒鲇S꧗䫾$ĥ피\": -794055816303360636,\n                                         \"外頮詋~텡竆繃䏩苨뾺朁꼃瘹f*㉀枙NH/\\u2027ꢁ}j묎vペq︉식뜡Od5 N顯ି烅仟Qfㆤ嚢(i䬅c;맧?嶰㩼츱獡?-\": {\n                                          \"e݆㍡⬬'2㻒?U篲鿄\\\"隻Ҭ5NꭰꤺBꀈ拾᩺[刯5곑Na램ﴦ዆]㝓qw钄\\u001b\\\"Y洊䗿祏塥迵[⼞⠳P$꠱5먃0轢`\": [{\"獰E賝﫚b먭N긆Ⰹ史2逶ꜛ?H짉~?P}jj}侷珿_T>᭨b,⻁鈵P䕡䀠८ⱄ홎鄣\": {\n                                           \"@?k2鶖㋮\\\"Oರ K㨇廪儲\\u0017䍾J?);\\b*묀㗠섳햭1MC V\": null,\n                                           \"UIICP!BUA`ᢈ㋸~袩㗪⾒=fB﮴l1ꡛ죘R辂여ҳ7쮡<䩲`熕8頁\": 4481809488267626463,\n                                           \"Y?+8먙ᚔ鋳蜩럶1㥔y璜౩`\": [\n                                            null,\n                                            1.2850335807501874E-19,\n                                            \"~V2\",\n                                            2035406654801997866,\n                                            {\n                                             \"<숻1>\\\"\": -8062468865199390827,\n                                             \"M㿣E]}qwG莎Gn᝶(ꔙ\\\\D⬲iꇲs寢t駇S뀡ꢜ\": false,\n                                             \"pꝤ㎏9W%>M;-U璏f(^j1?&RB隧 忓b똊E\": \"#G?C8.躬ꥯ'?냪#< 渟&헿란zpo왓Kj}鷧XﻘMツb䕖;㪻\",\n                                             \"vE풤幉xz뱕쫥Ug㦲aH} ᣟp:鬼Yᰟ<Fɋ잣緂頒⺏䉲瑑䅂,C~ޅG!f熢-B7~9Pqࡢ[츑#3ꕎ,Öඳ聁⩅㵧춀뿍xy䌏͂tdj!箧᳆|9蚡돬\": -2.54467378964089632E17,\n                                             \"䵈䅦5빖,궆-:໿댾仫0ᙚyᦝhqᚄ\": null,\n                                             \"侯Y\\\"湛졯劇U셎YX灍ⅸ2伴|筧\\\\䁒㶶᷏쁑Waᦵᗱ㜏늾膠<Jc63<G\\u20fe䇹66僣k0O\\\"_@U\": null,\n                                             \"姪y$#s漴JH璌Ӊ脛J㝾펔ﹴoꈶ㚸PD:薠쏖%說ថ蹂1］⾕5튄\": {\n                                              \"᝾Huw3䮅如쿺䍟嫝]<鰨ݷ?꯯䫓傩|ᐶස媽\\\\澒≡闢\": \"Mm\\\"쏇ᯄ졽\\\"楇<\\/ꥆ흭局n隴@鿣w⠊4P贈徎W㊋;䤞'.팇蒁䡴egpx嗎wஅ獗堮ᛐnˁ︖䀤4噙?໚郝᱋ޘॎt恑姫籕殥陃\\\"4[ꝬqL4Wꠎx\",\n                                              \"ℇj遌5B뒚\\\" U\": \"硄ꏘ{憠굏:&t䌨m Cઌ쿣鞛XFꠟs䝭ﶃ\\\"格a0x闊昵吲L\\\\杚聈aꁸj싹獅\\\"灟ﱡ馆*굖糠<ꔏ躎\",\n                                              \"톌賠弳ꟍb\\\"螖X50sĶ晠3f秂坯Iⓟ:萘\": 5.573183333596288E18,\n                                              \"%䴺\": [[[[\n                                               -6957233336860166165,\n                                               false,\n                                               null,\n                                               {\n                                                \"\\\"\\\\௮茒袀ᕥ23ୃ괶?䕎.嚲◉㏞L+ᵡ艱hL콇붆@\": null,\n                                                \"%螥9ꭌ<\\/-t\": true,\n                                                \",9|耢椸䁓Xk죱\\u0015$Ώ鲞[?엢ᝲ혪즈ⴂ▂ℴ㗯\\\"g뺘\\\\ꍜ#\\u0002ヮ}ሎ芲P[鹮轧@냲䃦=#(\": 2.78562909315899616E17,\n                                                \"R?H䧰ⵇ<,憰쮼Q總iR>H3镔ᴚ斦\\\\鏑r*2橱G⼔F/.j\": true,\n                                                \"RK좬뎂a홠f*f㱉ᮍ⦋潙㨋Gu곌SGI3I뿐\\\\F',)t`荁蘯囯ﮉ裲뇟쥼_ገ驪▵撏ᕤV\": 1.52738225997956557E18,\n                                                \"^k굲䪿꠹B逤%F㱢漥O披M㽯镞竇霒i꼂焅륓\\u00059=皫之눃\\u2047娤閍銤唫ၕb<\\/w踲䔼u솆맚,䝒ᝳ'/it\": \"B餹饴is権ꖪ怯ꦂẉဎt\\\"!凢谵⧿0\\\\<=(uL䷍刨쑪>俆揓Cy襸Q힆䆭涷<\\/ᐱ0ɧ䗾䚹\\\\ኜ?ꄢᇘ`䴢{囇}᠈䴥X4퓪檄]ꥷ/3謒ሴn+g騍X\",\n                                                \"GgG꽬[(嫓몍6\\u0004궍宩㙻/>\\u0011^辍dT腪hxǑ%ꊇk,8(W⧂結P鬜O\": [{\n                                                 \"M㴾c>\\\\ᓲ\\u0019V{>ꤩ혙넪㭪躂TS-痴໸闓⍵/徯O.M㏥ʷD囎⧔쁳휤T??鉬뇙=#ꢫ숣BX䭼<\\/d똬졬g榿)eꨋﯪ좇첻<?2K)\": null,\n                                                 \"Z17縬z]愀䖌 ᾋBCg5딒국憍꾓aⲷ턷u:U촳驿?雺楶\\u0001\\u001c{q*ᰗ苑B@k揰z.*蓗7ረIm\\\"Oᱍ@7?_\": true,\n                                                 \"㺃Z<\": -4349275766673120695,\n                                                 \"휃䠂fa塆ﬃxKe'덬鏗੄뺾w࠾鑎k땢m*႑햞鐮6攊&虜h黚,Y䱳Sﭼ둺pN6\": [\n                                                  false,\n                                                  \"IΎ䣲,\\\"ᬮ˪癘P~Qlnx喁Sᮔ༬˨I珌m䜛酛\\u0003iꐸ㦧cQ帲晼D' \\\\(粋wQcN\\\\뵰跈\",\n                                                  [\n                                                   \"D0\\\\L?M1쥍Kaꏌsd+盌귤憊tz䌣댐בO坂wϢ%ὒgp,Ai⎧ᶆI餾ꦍ棩嘅᳉怴%m]ၶis纖D凜镧o심b U\",\n                                                   {\n                                                    \"?଼\\u0011Rv&^[+匚I趈T媫\\u0010.䥤ᆯ1q僤HydⲰl㒽K'ᅾiౕ豲초딨@\\u0013J'쪪VD౼P4Ezg#8*㋤W馓]c쿯8\": false,\n                                                    \"c/擯X5~JmK䵶^쐎ച|B|u[솝(X뚤6v}W㤘⠛aR弌臌쾭諦eⒷ僡-;㩩⭖ⷴ徆龄갬{䱓ᥩ!﯏⊚ᇨ<v燡露`:볉癮꨽り★Ax7Ꮀ譥~舑\\\\Vꍋ\\\"$)v\": \"e&sFF쬘OBd슊寮f蠛জ봞mn~锆竒G脁\\\"趵G刕䕳&L唽붵<\\/I,X팚B⍥X,kԇҗ眄_慡:U附ᓚA蕧>\\u001a\\u0011\\\";~쓆BH4坋攊7힪\",\n                                                    \"iT:L闞椕윚*滛gI≀Wਟඊ'ꢆ縺뱹鮚Nꩁ᧬蕼21줧\\\\䋯``⍐\\\\㏱鳨\": 1927052677739832894,\n                                                    \"쮁缦腃g]礿Y㬙 fヺSɪ꾾N㞈\": [\n                                                     null,\n                                                     null,\n                                                     {\n                                                      \"!t,灝Y 1䗉罵?c饃호䉂Cᐭ쒘z(즽sZG㬣sഖE4뢜㓕䏞丮Qp簍6EZឪ겛fx'ꩱQ0罣i{k锩*㤴㯞r迎jTⲤ渔m炅肳\": [\n                                                       -3.3325685522591933E18,\n                                                       [{\"㓁5]A䢕1룥BC?Ꙍ`r룔Ⳛ䙡u伲+\\u0001്o\": [\n                                                        null,\n                                                        4975309147809803991,\n                                                        null,\n                                                        null,\n                                                        {\"T팘8Dﯲ稟MM☻㧚䥧/8ﻥ⥯aXLaH\\\"顾S☟耲ît7fS෉놁뮔/ꕼ䓈쁺4\\\\霶䠴ᩢ<\\/t4?죵>uD5➶༆쉌럮⢀秙䘥\\u20972ETR3濡恆vB? ~鸆\\u0005\": {\n                                                         \"`閖m璝㥉b뜴?Wf;?DV콜\\u2020퍉౓擝宏ZMj3mJ먡-傷뱙yח㸷꥿ ໘u=M읝!5吭L4v\\\\?ǎ7C홫\": null,\n                                                         \"|\": false,\n                                                         \"~Ztᛋ䚘\\\\擭㗝傪W陖+㗶qᵿ蘥ᙄp%䫎)}=⠔6ᮢS湟-螾-mXH?cp\": 448751162044282216,\n                                                         \"\\u209fad놹j檋䇌ᶾ梕㉝bוּ<d䗱:줰M酄\\u0000X#_r獢A饓ꍗُKo_跔?ᪧ嵜鼲<\": null,\n                                                         \"ꆘ)ubI@h@洭Ai㜎䏱k\\u0003?T䉐3间%j6j棍j=❁\\\\U毮ᬹ*8䀔v6cpj⭬~Q꿾뺶펵悡!쩭厝l六㽫6퇓ޭ2>\": {\"?苴ꩠD䋓帘5騱qﱖPF?☸珗顒yU ᡫcb䫎 S@㥚gꮒ쎘泴멖\\\\:I鮱TZ듒ᶨQ3+f7캙\\\"?\\f풾\\\\o杞紟﻽M.⏎靑OP\": [\n                                                          -2.6990368911551596E18,\n                                                          [{\"䒖@<᰿<\\/⽬tTr腞&G%᳊秩蜰擻f㎳?S㵧\\r*k뎾-乢겹隷j軛겷0룁鮁\": {\")DO0腦:춍逿:1㥨่!蛍樋2\": [{\n                                                           \",ꌣf侴笾m๫ꆽ?1?U?\\u0011ꌈꂇ\": {\n                                                            \"x捗甠nVq䅦w`CD⦂惺嘴0I#vỵ} \\\\귂S끴D얾?Ԓj溯\\\"v餄a\": {\n                                                             \"@翙c⢃趚痋i\\u0015OQ⍝lq돆Y0pࢥ3쉨䜩^<8g懥0w)]䊑n洺o5쭝QL댊랖L镈Qnt⪟㒅십q헎鳒⮤眉ᔹ梠@O縠u泌ㄘb榚癸XޔFtj;iC\": false,\n                                                             \"I&뱋゘|蓔䔕측瓯%6ᗻHW\\\\N1貇#?僐ᗜgh᭪o'䗈꽹Rc욏/蔳迄༝!0邔䨷푪8疩)[쭶緄㇈୧ፐ\": {\n                                                              \"B+:ꉰ`s쾭)빼C羍A䫊pMgjdx䐝Hf9᥸W0!C樃'蘿f䫤סи\\u0017Jve? 覝f둀⬣퓉Whk\\\"஼=չﳐ皆笁BIW虨쫓F廰饞\": -642906201042308791,\n                                                              \"sb,XcZ<\\/m㉹ ;䑷@c䵀s奤⬷7`ꘖ蕘戚?Feb#輜}p4nH⬮eKL트}\": [\n                                                               \"RK鳗z=袤Pf|[,u욺\",\n                                                               \"Ẏᏻ罯뉋⺖锅젯㷻{H䰞쬙-쩓D]~\\u0013O㳢gb@揶蔉|kᦂ❗!\\u001ebM褐sca쨜襒y⺉룓\",\n                                                               null,\n                                                               null,\n                                                               true,\n                                                               -1.650777344339075E-19,\n                                                               false,\n                                                               \"☑lꄆs힨꤇]'uTന⌳농].1⋔괁沰\\\"IWഩ\\u0019氜8쟇䔻;3衲恋,窌z펏喁횗?4?C넁问?ᥙ橭{稻Ⴗ_썔\",\n                                                               \"n?]讇빽嗁}1孅9#ꭨ靶v\\u0014喈)vw祔}룼쮿I\",\n                                                               -2.7033457331882025E18,\n                                                               {\n                                                                \";⚃^㱋x:饬ኡj'꧵T☽O㔬RO婎?향ᒭ搩$渣y4i;(Q>꿘e8q\": \"j~錘}0g;L萺*;ᕭꄮ0l潛烢5H▄쳂ꏒוֹꙶT犘≫x閦웧v\",\n                                                                \"~揯\\u2018c4職렁E~ᑅቚꈂ?nq뎤.:慹`F햘+%鉎O瀜쟏敛菮⍌浢<\\/㮺紿P鳆ࠉ8I-o?#jﮨ7v3Dt赻J9\": null,\n                                                                \"ࣝW䌈0ꍎqC逖,횅c၃swj;jJS櫍5槗OaB>D踾Y\": {\"㒰䵝F%?59.㍈cᕨ흕틎ḏ㋩B=9IېⓌ{:9.yw｝呰ㆮ肒᎒tI㾴62\\\"ዃ抡C﹬B<\\/<EO꽓ᇕu&鋫\\\\禞퐹u꒍.7훯ಶ2䩦͉ᶱf깵ᷣ늎\": [\n                                                                 5.5099570884646902E18,\n                                                                 \"uQN濿m臇<%?谣鮢s]]x0躩慌闋<;( 鋤.0ᠵd1#벘a:Gs?햷'.)ㅴ䞟琯崈FS@O㌛ᓬ抢큌ើ냷쿟툥IZn[惵ꐧ3뙍[&v憙J>촋jo朣\",\n                                                                 [\n                                                                  -7675533242647793366,\n                                                                  {\"ᙧ呃:[㒺쳀쌡쏂H稈㢤\\u001dᶗGG-{GHྻຊꡃ哸䵬;$?&d\\\\⥬こN圴됤挨-'ꕮ$PU%?冕눖i魁q騎Q\": [\n                                                                   false,\n                                                                   [[\n                                                                    7929823049157504248,\n                                                                    [[\n                                                                     true,\n                                                                     \"Z菙\\u0017'eꕤ᱕l,0\\\\X\\u001c[=雿8蠬L<\\/낲긯W99g톉4ퟋb㝺\\u0007劁'!麕Q궈oW:@X၎z蘻m絙璩귓죉+3柚怫tS捇蒣䝠-擶D[0=퉿8)q0ٟ\",\n                                                                     \"唉\\nFA椭穒巯\\\\䥴䅺鿤S#b迅獘 ﶗ꬘\\\\?q1qN犠pX꜅^䤊⛤㢌[⬛휖岺q唻ⳡ틍\\\"㙙Eh@oA賑㗠y必Nꊑᗘ\",\n                                                                     -2154220236962890773,\n                                                                     -3.2442003245397908E18,\n                                                                     \"Wᄿ筠:瘫퀩?o貸q⊻(᎞KWf宛尨h^残3[U(='橄\",\n                                                                     -7857990034281549164,\n                                                                     1.44283696979059942E18,\n                                                                     null,\n                                                                     {\"ꫯAw跭喀 ?_9\\\"Aty背F=9缉ྦྷ@;?^鞀w:uN㘢Rỏ\": [\n                                                                      7.393662029337442E15,\n                                                                      3564680942654233068,\n                                                                      [\n                                                                       false,\n                                                                       -5253931502642112194,\n                                                                       \"煉\\\\辎ೆ罍5⒭1䪁䃑s䎢:[e5}峳ﴱn騎3?腳Hyꏃ膼N潭錖,Yᝋ˜YAၓ㬠bG렣䰣:\",\n                                                                       true,\n                                                                       null,\n                                                                       {\n                                                                        \"⒛'P&%죮|:⫶춞\": -3818336746965687085,\n                                                                        \"钖m<\\/0ݎMtF2Pk=瓰୮洽겎.\": [[\n                                                                         -8757574841556350607,\n                                                                         -3045234949333270161,\n                                                                         null,\n                                                                         {\n                                                                          \"Ꮬr輳>⫇9hU##w@귪A\\\\C 鋺㘓ꖐ梒뒬묹㹻+郸嬏윤'+g<\\/碴,}ꙫ>손;情d齆J䬁ຩ撛챝탹/R澡7剌tꤼ?ặ!`⏲睤\\u00002똥଴⟏\": null,\n                                                                          \"\\u20f2ܹe\\\\tAꥍư\\\\x当뿖렉禛;G檳ﯪS૰3~㘠#[J<}{奲 5箉⨔{놁<\\/釿抋,嚠/曳m&WaOvT赋皺璑텁\": [[\n                                                                           false,\n                                                                           null,\n                                                                           true,\n                                                                           -5.7131445659795661E18,\n                                                                           \"萭m䓪D5|3婁ఞ>蠇晼6nﴺPp禽羱DS<睓닫屚삏姿\",\n                                                                           true,\n                                                                           [\n                                                                            -8759747687917306831,\n                                                                            {\n                                                                             \">ⓛ\\t,odKr{䘠?b퓸C嶈=DyEᙬ@ᴔ쨺芛髿UT퓻春<\\/yꏸ>豚W釺N뜨^?꽴﨟5殺ᗃ翐%>퍂ဿ䄸沂Ea;A_\\u0005閹殀W+窊?Ꭼd\\u0013P汴G5썓揘\": 4.342729067882445E-18,\n                                                                             \"Q^즾眆@AN\\u0011Kb榰냎Y#䝀ꀒᳺ'q暇睵s\\\"!3#I⊆畼寤@HxJ9\": false,\n                                                                             \"⿾D[)袨㇩i]웪䀤ᛰMvR<蟏㣨\": {\"v퇓L㪱ꖣ豛톤\\\\곱#kDTN\": [{\n                                                                              \"(쾴䡣,寴ph(C\\\"㳶w\\\"憳2s馆E!n!&柄<\\/0Pꈗſ?㿳Qd鵔\": {\"娇堰孹L錮h嵅⛤躏顒?CglN束+쨣ﺜ\\\\MrH\": {\"獞䎇둃ቲ弭팭^ꄞ踦涟XK錆쳞ឌ`;੶S炥騞ଋ褂B៎{ڒ䭷ᶼ靜pI荗虶K$\": [{\"◖S~躘蒉꫿輜譝Q㽙闐@ᢗ¥E榁iء5┄^B[絮跉ᰥ遙PWi3wㄾⵀDJ9!w㞣ᄎ{듒ꓓb6\\\\篴??c⼰鶹⟧\\\\鮇ꮇ\": [[\n                                                                               654120831325413520,\n                                                                               -1.9562073916357608E-19,\n                                                                               {\n                                                                                \"DC(昐衵ἡ긙갵姭|֛[t\": 7.6979110359897907E18,\n                                                                                \"J␅))嫼❳9Xfd飉j7猬ᩉ+⤻眗벎E鰉Zﾶ63zၝ69}ZᶐL崭ᦥ⡦靚⋛ꎨ~i㨃咊ꧭo䰠阀3C(\": -3.5844809362512589E17,\n                                                                                \"p꣑팱쒬ꎑ뛡Ꙩ挴恍胔&7ᔈ묒4Hd硶훐㎖zꢼ豍㿢aሃ=<\\/湉鵲EӅ%$F!퍶棌孼{O駍਺geu+\": \")\\u001b잓kŀX쩫A밁®ڣ癦狢)扔弒p}k縕ꩋ,䃉tࣼi\",\n                                                                                \"ァF肿輸<솄G-䢹䛸ꊏl`Tqꕗ蒞a氷⸅ᴉ蠰]S/{J왲m5{9.uέ~㕚㣹u>x8U讁B덺襪盎QhVS맅킃i识{벂磄Iහ䙅xZy/抍૭Z鲁-霳V据挦ℒ\": null,\n                                                                                \"㯛|Nꐸb7ⵐb?拠O\\u0014ކ?-(EꞨ4ꕷᄤYᯕOW瞺~螸\\\"욿ќ<u鵵઎⸊倾쑷෻rT⪄牤銱;W殆͢芄ਰ嚝훚샢⊿+㲽\": null,\n                                                                                \"単逆ົ%_맛d)zJ%3칧_릟#95䌨怡\\u001ci턠ॣi冘4赖'ਐ䧐_栔!\": {\n                                                                                 \"*?2~4㲌᭳쯁ftႷ1#oJ\\b䊇镇됔 \\u2079x䛁㊝ᮂN;穽跖s휇ᣄ홄傷z⸷(霸!3y뺏M쒿햏۽v㳉tở心3黎v쭻 Rp཮Vr~T?&˴k糒븥쩩r*D\": null,\n                                                                                 \"8@~홟ꔘk1[\": -5570970366240640754,\n                                                                                 \"BZt鏦ꡬc餖  s(mᛴ\\u0000◄d腑t84C⟐坯VṊ뉙'噱Ꝕ珽GC顀?허0ꞹ&돇䛭C䷫](\": 2.4303828213012387E-20,\n                                                                                 \"y撔Z외放+}ḑ骈ᙝ&\\u0016`G便2|-e]঳?QF㜹YF\\\"㿒緄햷㈟塚䷦ୀጤlM蘸N㾆▛럪㞂tᕬ镈쇝喠l amcxPnm\\u001a᱋<\\/]_]ﻹ瞧?H\": false,\n                                                                                 \"ፏ氏묢뜚I[♺뽛x?0H봬Wpn꨹Ra䝿쌑{㴂ni祻윸A'y|⺴ᚘ庌9{$恲{톽=m#@6ᨧfgs44陎J#<Ễ쨓瀵❩a୛㷉㙉ܸ◠냔嬯~呄籁羥镳\": false,\n                                                                                 \"㘱{<頬22?IF@곊I겂嶻L᝛D{@r쒂?IAᣧ洪惒誸b徂z췺꾍㠭\\\\刊%禨쌐ⶣ仵\\\\P[:47;<ᇅ<\\/\": {\n                                                                                  \"^U釳-v㢈ꗝ◄菘rᜨi;起kR犺䵫\\u0000锍쁙m-ԙ!lḃ꛸뻾F(W귛y\": \"#ᠺH㸢5v8_洑C\",\n                                                                                  \"䔵໳$ᙠ6菞\\u206e摎q圩P|慍sV4:㜾(I溞I?\": -6569206717947549676,\n                                                                                  \"透Ꞃ緵퇝8 >e㺰\\\"'㌢ƐW\\u0004瞕>0?V鷵엳\": true,\n                                                                                  \"뤥G\\\\迋䠿[庩'꼡\\u001aiᩮV쯁ᳪ䦪Ô;倱ନ뛁誈\": null,\n                                                                                  \"쥹䄆䚟Q榁䎐᢭<\\/2㕣p}HW蟔|䃏꿈ꚉ锳2Pb7㙑Tⅹᵅ\": {\n                                                                                   \"Y?֭$>#cVBꩨ:>eL蒁務\": {\n                                                                                    \"86柡0po 䏚&-捑Ћ祌<\\/휃-G*㶢הּ쩍s㶟餇c걺yu꽎還5*턧簕Og婥SꝐ\": null,\n                                                                                    \"a+葞h٥ࠆ裈嗫ﵢ5輙퀟ᛜ,QDﹼ⟶Y騠锪E_|x죗j侵;m蜫轘趥?븅w5+mi콛L\": {\n                                                                                     \";⯭ﱢ!买F⽍柤鶂n䵣V㫚墱2렾ELEl⣆\": [\n                                                                                      true,\n                                                                                      -3.6479311868339015E-18,\n                                                                                      -7270785619461995400,\n                                                                                      3.334081886177621E18,\n                                                                                      2.581457786298155E18,\n                                                                                      -6.605252412954115E-20,\n                                                                                      -3.9232347037744167E-20,\n                                                                                      {\n                                                                                       \"B6㊕.k1\": null,\n                                                                                       \"ZAꄮJ鮷ᳱo갘硥鈠䠒츼\": {\n                                                                                        \"ᕅ}럡}.@y陪鶁r業'援퀉x䉴ﵴl퍘):씭脴ᥞhiꃰblﲂ䡲엕8߇M㶭0燋標挝-?PCwe⾕J碻Ᾱ䬈䈥뷰憵賣뵓痬+\": {\"a췩v礗X⋈耓ፊf罅靮!㔽YYᣓw澍33⎔芲F|\\\"䜏T↮輦挑6ᓘL侘?ￆ]덆1R௯✎餘6ꏽ<\\/௨\\\\?q喷ꁫj~@ulq\": {\"嗫欆뾔Xꆹ4H㌋F嵧]ࠎ]㠖1ꞤT<$m뫏O i댳0䲝i\": {\"?෩?\\u20cd슮|ꯆjs{?d7?eNs⢚嫥氂䡮쎱:鑵롟2hJꎒﯭ鱢3춲亄:뼣v䊭諱Yj択cVmR䩃㘬T\\\"N홝*ै%x^F\\\\_s9보zz4淗?q\": [\n                                                                                         null,\n                                                                                         \"?\",\n                                                                                         2941869570821073737,\n                                                                                         \"{5{殇0䝾g6밖퍋臩綹R$䖭j紋釰7sXI繳漪행y\",\n                                                                                         false,\n                                                                                         \"aH磂?뛡#惇d婅?Fe,쐘+늵䍘\\\"3r瘆唊勐j⳧࠴ꇓ<\\/唕윈x⬌讣䋵%拗ᛆⰿ妴᝔M2㳗必꧂淲?ゥ젯檢<8끒MidX䏒3᳻Q▮佐UT|⤪봦靏⊏\",\n                                                                                         [[{\n                                                                                          \"颉(&뜸귙{y^\\\"P퟉춝Ჟ䮭D顡9=?}Y誱<$b뱣RvO8cH煉＠tk~4ǂ⤧⩝屋SS;J{vV#剤餓ᯅc?#a6D,s\": [\n                                                                                           -7.8781018564821536E16,\n                                                                                           true,\n                                                                                           [\n                                                                                            -2.28770899315832371E18,\n                                                                                            false,\n                                                                                            -1.0863912140143876E-20,\n                                                                                            -6282721572097446995,\n                                                                                            6767121921199223078,\n                                                                                            -2545487755405567831,\n                                                                                            false,\n                                                                                            null,\n                                                                                            -9065970397975641765,\n                                                                                            [\n                                                                                             -5.928721243413937E-20,\n                                                                                             {\"6촊\\u001a홯kB0w撨燠룉{绎6⳹!턍贑y▾鱧ժ[;7ᨷ∀*땒䪮1x霆Hᩭ☔\\\"r䝐7毟ᝰr惃3ꉭE+>僒澐\": [\n                                                                                              \"Ta쎩aƝt쵯ⰪVb\",\n                                                                                              [\n                                                                                               -5222472249213580702,\n                                                                                               null,\n                                                                                               -2851641861541559595,\n                                                                                               null,\n                                                                                               4808804630502809099,\n                                                                                               5657671602244269874,\n                                                                                               \"5犲﨣4mᥣ?yf젫꾯|䋬잁$`Iⳉﴷ扳兝,'c\",\n                                                                                               false,\n                                                                                               [\n                                                                                                null,\n                                                                                                {\n                                                                                                 \"DyUIN쎾M仼惀⮥裎岶泭lh扠\\u001e礼.tEC癯튻@_Qd4c5S熯A<\\/＼6U윲蹴Q=%푫汹\\\\\\u20614b[௒C⒥Xe⊇囙b,服3ss땊뢍i~逇PA쇸1\": -2.63273619193485312E17,\n                                                                                                 \"Mq꺋貘k휕=nK硍뫞輩>㾆~἞ࡹ긐榵l⋙Hw뮢帋M엳뢯v⅃^\": 1877913476688465125,\n                                                                                                 \"ᶴ뻗`~筗免⚽টW˃⽝b犳䓺Iz篤p;乨A\\u20ef쩏?疊m㝀컩뫡b탔鄃ᾈV(遢珳=뎲ିeF仢䆡谨8t0醄7㭧瘵⻰컆r厡궥d)a阄፷Ed&c﯄伮1p\": null,\n                                                                                                 \"⯁w4曢\\\"(欷輡\": \"\\\"M᭫]䣒頳B\\\\燧ࠃN㡇j姈g⊸⺌忉ꡥF矉স%^\",\n                                                                                                 \"㣡Oᄦ昵⫮Y祎S쐐級㭻撥>{I$\": -378474210562741663,\n                                                                                                 \"䛒掷留Q%쓗1*1J*끓헩ᦢ﫫哉쩧EↅIcꅡ\\\\?ⴊl귛顮4\": false,\n                                                                                                 \"寔愆샠5]䗄IH贈=d﯊/偶?ॊn%晥D視N򗘈'᫂⚦|X쵩넽z질tskxDQ莮Aoﱻ뛓\": true,\n                                                                                                 \"钣xp?&\\u001e侉/y䴼~?U篔蘚缣/I畚?Q绊\": -3034854258736382234,\n                                                                                                 \"꺲໣眀)⿷J暘pИfAV삕쳭Nꯗ4々'唄ⶑ伻㷯騑倭D*Ok꧁3b␽_<\\/챣Xm톰ၕ䆄`*fl㭀暮滠毡?\": [\n                                                                                                  \"D男p`V뙸擨忝븪9c麺`淂⢦Yw⡢+kzܖ\\fY1䬡H歁)벾Z♤溊-혰셢?1<-\\u0005;搢Tᐁle\\\\ᛵߓﭩ榩<QF;t=?Qꀞ\",\n                                                                                                  [\n                                                                                                   null,\n                                                                                                   [{\"-췫揲ᬨ墊臸<ࠒH跥 㔭쥃㫯W=z[wধ╌<~yW楄S!⑻h즓lĖN￧篌W듷튗乵᪪템먵Pf悥ᘀk䷭焼\\\\讄r擁鐬y6VF<\\/6랿p)麡ꁠ㪁\\\"pழe\": [\n                                                                                                    \"#幎杴颒嶈)ㄛJ.嶤26_⋌东챯ꠉ⤋ؚ/⏚%秼Q룠QGztﾺ㎷អI翰Xp睔鍜ꨍ\",\n                                                                                                    {\",T?\": [\n                                                                                                     false,\n                                                                                                     [[\n                                                                                                      true,\n                                                                                                      7974824014498027996,\n                                                                                                      false,\n                                                                                                      [\n                                                                                                       4.3305464880956252E18,\n                                                                                                       {\n                                                                                                        \"᱿W^A]'rᮢ)鏥z餝;Hu\\\\Fk?ﴺ?IG浅-䙧>訝-xJ;巡8깊蠝ﻓU$K\": {\n                                                                                                         \"Vꕡ諅搓W=斸s︪vﲜ츧$)iꡟ싉e寳?ጭムVથ嵬i楝Fg<\\/Z|៪ꩆ-5'@ꃱ80!燱R쇤t糳]罛逇dṌ֣XHiͦ{\": true,\n                                                                                                         \"Ya矲C멗Q9膲墅携휻c\\\\딶G甔<\\/.齵휴\": -1.1456247877031811E-19,\n                                                                                                         \"z#.OO￝J\": -8263224695871959017,\n                                                                                                         \"崍_3夼ᮟ1F븍뽯ᦓ鴭V豈Ь\": [{\n                                                                                                          \"N蒬74\": null,\n                                                                                                          \"yuB?厅vK笗!ᔸcXQ旦컶P-녫mﾵ麟_\": \"1R@ 톘xa_|﩯遘s槞d!d껀筤⬫薐焵먑D{\\\\6k共倌☀G~AS_D\\\"딟쬚뮥馲렓쓠攥WTMܭ8nX㩴䕅檹E\\u0007ﭨN 2 ℆涐ꥏ꠵3▙玽|됨_\\u2048\",\n                                                                                                          \"恐A C䧩G\": {\":M큣5e들\\\\ꍀ恼ᔄ靸|I﨏$)n\": {\n                                                                                                           \"|U䬫㟯SKV6ꛤ㗮\\bn봻䲄fＸT:㾯쳤'笓0b/ೢC쳖?2浓uO.䰴\": \"ཐ꼋e?``,ᚇ慐^8ꜙNM䂱\\u0001IᖙꝧM'vKdꌊH牮r\\\\O@䊷ᓵ쀆(fy聻i툺\\\"?<\\/峧ࣞ⓺ᤤ쵒߯ꎺ騬?)刦\\u2072l慪y꺜ﲖTj+u\",\n                                                                                                           \"뽫<G;稳UL⸙q2n쵿C396炿J蓡z⣁zဩSOU?<\\/뙍oE큸O鿅෴ꍈEm#\\\"[瑦⤫ᝆgl⡗q8\\\"큘덥係@ᆤ=\\u0001爖羝췀㸩b9\\\\jeqt㟿㮸龾m㳳긄\": {\n                                                                                                            \"9\\\"V霟釜{/o0嫲C咀-饷䈍[녩)\\r䤴tMW\\\\龟ϣ^ي㪙忩䞞N湆Y笕)萨ꖤ誥煽:14⫻57U$擒䲐薡Qvↇ櫲현誧?nஷ6\": {\"l웾䌵.䅋䦝ic碳g[糲Ƿ-ឈᚱ4쑧\\u0004C࿼\\u0018&쬑?멲<\\/fD_檼픃pd쪼n㕊渪V䛉m揈W儅톳뗳䓆7㭽諤T煠Ney?0᪵鈑&\": [\n                                                                                                             false,\n                                                                                                             null,\n                                                                                                             {\n                                                                                                              \"\\r;鼶j᠂꼍RLz~♔9gf?ӡ浐\": -1.4843072575250897E-19,\n                                                                                                              \"&ꊒ\\\"ꋟ䝭E诮ﯚO?SW뒁훪mb旙⎕ᗕ⶙|ᷤ5y4甥\": \"j5|庠t铱?v 횋0\\\"'rxz䃢杺Ɜ!\\u0002\",\n                                                                                                              \"Q ၩ㟧\": {\"Hﬔ\\u2058䪠틙izZㅛ탟H^ﶲA??R6呠Z솋R.࿶g8\": [\n                                                                                                               -8762672252886298799,\n                                                                                                               -1.9486830507000208E17,\n                                                                                                               null,\n                                                                                                               -7157359405410123024,\n                                                                                                               null,\n                                                                                                               null,\n                                                                                                               -995856734219489233,\n                                                                                                               \"呧㫹A4!\",\n                                                                                                               null,\n                                                                                                               -1.9105609358624648E-19,\n                                                                                                               5888184370445333848,\n                                                                                                               2.25460605078245E-19,\n                                                                                                               2.5302739297121987E18,\n                                                                                                               \"뢹sbEf捵2丯?뗾耸(Wd띙SବꭖrtU?筤P똙QpbbKqaE$来V웰3i/lK퉜,8︸e= g螓t竦컼?.寋8鵗\",\n                                                                                                               7377742975895263424,\n                                                                                                               2.4218442017790503E-19,\n                                                                                                               {\n                                                                                                                \"y꒚ཫ쨘醬킃糟}yTSt䡀⇂뿽4ൢ戰U\": [[\n                                                                                                                 3600537227234741875,\n                                                                                                                 4435474101760273035,\n                                                                                                                 -1.42274517007951795E18,\n                                                                                                                 -5567915915496026866,\n                                                                                                                 null,\n                                                                                                                 null,\n                                                                                                                 [\n                                                                                                                  -3204084299154861161,\n                                                                                                                  {\n                                                                                                                   \"7梧慸憏.a瘎\\u00041U鵮Ck֨d惥耍ⳡY,⭏써E垁FFI鱑ⳬ줢7⧵Bﴠ耘줕햸q컴~*瑍W.떛ࡆ@'᐀+轳\": -961121410259132975,\n                                                                                                                   \"⥅]l黭㣓绶;!!⎃=朼㐿e&ἂ繤C﯀l䝣㌀6TM쑮w懃ꡡ#ᤆ䰓,墼湼゙뽸㲿䧽쫨xᵖ듨<\\/ T0峸iQ:溫脐\\\\\\\"쎪ὴ砇宖^M泼큥➅鈫@ᄟ༩\\u2008⥼\": true,\n                                                                                                                   \"⩐\\\"籽汎P싯鲘蟼sRᐯ䅩\\u0019R(kRᖁ&ಌ 0\\\"鳶!馼YH\": null,\n                                                                                                                   \"鮼ꚇ싋։刟\\rRLd步Nⴗ5Eࡆ訛갚[I醵NC(郴ṉy5D뤺౳QY壯5苴y훨(W\\\\Cଇ姚C艄깹\\u001c歷㋵ZC᥂\": [\n                                                                                                                    -6806235313106257498,\n                                                                                                                    null,\n                                                                                                                    \"}N⸿讽sꚪ;\\\\p繇j苄䫨\\u20e7%5x?t#\",\n                                                                                                                    {\n                                                                                                                     \"O〗k<墻yV$ఁrs-c1ఌ唪.C7_Yobᦜ褷'b帰mㄑl⌅\": {\"qB뗗擄3隂5뺍櫂䱟e촸P/鏩,3掁ꗩ=冉棓㑉|˞F襴뿴,:㞦<퓂⧙礞♗g뚎ᛩ<\\/뉽ⶳ⸻A?_x2I㽝勒*I홱鍧粿~曟㤙2绥Ly6+썃uu鿜בf큘|歍ࣖÉ\": [\n                                                                                                                      \">hh䈵w>1ⲏ쐭V[ⅎ\\\\헑벑F_㖝⠗㫇h恽;῝汰ᱼ瀖J옆9RR셏vsZ柺鶶툤r뢱橾/ꉇ囦FGm\\\"謗ꉦ⨶쒿⥡%]鵩#ᖣ_蹎 u5|祥?O\",\n                                                                                                                      null,\n                                                                                                                      2.0150326776036215E-19,\n                                                                                                                      null,\n                                                                                                                      true,\n                                                                                                                      false,\n                                                                                                                      true,\n                                                                                                                      {\"\\fa᭶P捤WWc᠟f뚉ᬏ퓗ⳀW睹5:HXH=q7x찙X$)모r뚥ᆟ!Jﳸf\": [\n                                                                                                                       -2995806398034583407,\n                                                                                                                       [\n                                                                                                                        6441377066589744683,\n                                                                                                                        \"Mﶒ醹i)Gἦ廃s6몞 KJ౹礎VZ螺费힀\\u0000冺업{谥'꡾뱻:.ꘘ굄奉攼Di᷑K鶲y繈욊阓v㻘}枭캗e矮1c?휐\\\"4\\u0005厑莔뀾墓낝⽴洗ṹ䇃糞@b1\\u0016즽Y轹\",\n                                                                                                                        {\n                                                                                                                         \"1⽕⌰鉟픏M㤭n⧴ỼD#%鐘⊯쿼稁븣몐紧ᅇ㓕ᛖcw嬀~ഌ㖓(0r⧦Q䑕髍ര铂㓻R儮\\\"@ꇱm❈௿᦯頌8}㿹犴?xn잆꥽R\": 2.07321075750427366E18,\n                                                                                                                         \"˳b18㗈䃟柵Z曆VTAu7+㛂cb0﯑Wp執<\\/臋뭡뚋刼틮荋벲TLP预庰܈G\\\\O@VD'鱃#乖끺*鑪ꬳ?Mޞdﭹ{␇圯쇜㼞顄︖Y홡g\": [{\n                                                                                                                          \"0a,FZ\": true,\n                                                                                                                          \"2z̬蝣ꧦ驸\\u0006L↛Ḣ4๚뿀'?lcwᄧ㐮!蓚䃦-|7.飑挴.樵*+1ﮊ\\u0010ꛌ%貨啺/JdM:똍!FBe?鰴㨗0O财I藻ʔWA᫓G쳛u`<\\/I\": [{\n                                                                                                                           \"$τ5V鴐a뾆両環iZp頻යn븃v\": -4869131188151215571,\n                                                                                                                           \"*즢[⦃b礞R◚nΰꕢH=귰燙[yc誘g䆌?ଜ臛\": {\n                                                                                                                            \"洤湌鲒)⟻\\\\䥳va}PeAMnＮ[\": \"㐳ɪ/(軆lZR,Cp殍ȮN啷\\\"3B婴?i=r$펽ᤐ쀸\",\n                                                                                                                            \"阄R4㒿㯔ڀ69ZᲦ2癁핌噗P崜#\\\\-쭍袛&鐑/$4童V꩑_ZHA澢fZ3\": {\"x;P{긳:G閉:9?活H\": [\n                                                                                                                             \"繺漮6?z犞焃슳\\\">ỏ[Ⳛ䌜녏䂹>聵⼶煜Y桥[泥뚩MvK$4jtﾛ\",\n                                                                                                                             \"E#갶霠좭㦻ୗ먵F+䪀o蝒ba쮎4X㣵 h\",\n                                                                                                                             -335836610224228782,\n                                                                                                                             null,\n                                                                                                                             null,\n                                                                                                                             [\n                                                                                                                              \"r1᫩0>danjY짿bs{\",\n                                                                                                                              [\n                                                                                                                               -9.594464059325631E-23,\n                                                                                                                               1.0456894622831624E-20,\n                                                                                                                               null,\n                                                                                                                               5.803973284253454E-20,\n                                                                                                                               -8141787905188892123,\n                                                                                                                               true,\n                                                                                                                               -4735305442504973382,\n                                                                                                                               9.513150514479281E-20,\n                                                                                                                               \"7넳$螔忷㶪}䪪l짴\\u0007鹁P鰚HF銏ZJﳴ/⍎1ᷓ忉睇ᜋ쓈x뵠m䷐窥Ꮤ^\\u0019ᶌ偭#ヂt☆၃pᎍ臶䟱5$䰵&๵分숝]䝈뉍♂坎\\u0011<>\",\n                                                                                                                               \"C蒑貑藁lﰰ}X喇몛;t밿O7/᯹f\\u0015kI嘦<ዴ㟮ᗎZ`GWퟩ瑹࡮ᅴB꿊칈??R校s脚\",\n                                                                                                                               {\n                                                                                                                                \"9珵戬+AU^洘拻ቒy柭床'粙XG鞕᠜繀伪%]hC,$輙?Ut乖Qm떚W8઼}~q⠪rU䤶CQ痗ig@#≲t샌f㈥酧l;y闥ZH斦e⸬]j⸗?ঢ拻퀆滌\": null,\n                                                                                                                                \"畯}㧢J罚帐VX㨑>1ꢶkT⿄蘥㝑o|<嗸層沈挄GEOM@-䞚䧰$만峬輏䠱V✩5宸-揂D'㗪yP掶7b⠟J㕻SfP?d}v㼂Ꮕ'猘\": {\n                                                                                                                                 \"陓y잀v>╪\": null,\n                                                                                                                                 \"鬿L+7:됑Y=焠U;킻䯌잫!韎ஔ\\f\": {\n                                                                                                                                  \"駫WmGጶ\": {\n                                                                                                                                   \"\\\\~m6狩K\": -2586304199791962143,\n                                                                                                                                   \"ႜࠀ%͑l⿅D.瑢Dk%0紪dḨTI픸%뗜☓s榗኉\\\"?V籄7w髄♲쟗翛歂E䤓皹t ?)ᄟ鬲鐜6C\": {\n                                                                                                                                    \"_췤a圷1\\u000eB-XOy缿請∎$`쳌eZ~杁튻/蜞`塣৙\\\"⪰\\\"沒l}蕌\\\\롃荫氌.望wZ|o!)Hn獝qg}\": null,\n                                                                                                                                    \"kOSܧ䖨钨:಼鉝ꭝO醧S`십`ꓭ쭁ﯢN&Et㺪馻㍢ⅳ㢺崡ຊ蜚锫\\\\%ahx켨|ż劻ꎄ㢄쐟A躊᰹p譞綨Ir쿯\\u0016ﵚOd럂*僨郀N*b㕷63z\": {\n                                                                                                                                     \":L5r+T㡲\": [{\n                                                                                                                                      \"VK泓돲ᮙRy㓤➙Ⱗ38oi}LJቨ7Ó㹡৘*q)1豢⛃e᫛뙪壥镇枝7G藯g㨛oI䄽 孂L缊ꋕ'EN`\": -2148138481412096818,\n                                                                                                                                      \"`⛝ᘑ$(खꊲ⤖ᄁꤒ䦦3=)]Y㢌跨NĴ驳줟秠++d孳>8ᎊ떩EꡣSv룃 쯫أ?#E|᭙㎐?zv:5祉^⋑V\": [\n                                                                                                                                       -1.4691944435285607E-19,\n                                                                                                                                       3.4128661569395795E17,\n                                                                                                                                       \"㐃촗^G9佭龶n募8R厞eEw⺡_ㆱ%⼨D뉄퉠2ꩵᛅⳍ搿L팹Lවn=\\\"慉념ᛮy>!`g!풲晴[/;?[v겁軇}⤳⤁핏∌T㽲R홓遉㓥\",\n                                                                                                                                       \"愰_⮹T䓒妒閤둥?0aB@㈧g焻-#~跬x<\\/舁P݄ꐡ=\\\\׳P\\u0015jᳪᢁq;㯏l%᭗;砢觨▝,謁ꍰGy?躤O黩퍋Y㒝a擯\\n7覌똟_䔡]fJ晋IAS\",\n                                                                                                                                       4367930106786121250,\n                                                                                                                                       -4.9421193149720582E17,\n                                                                                                                                       null,\n                                                                                                                                       {\n                                                                                                                                        \";ﾸ똾柉곟ⰺKpፇ䱻ฺ䖝{o~h!ｅꁿ઻욄ښ\\u0002y?xUd\\u207c悜ꌭ\": [\n                                                                                                                                         1.6010824122815255E-19,\n                                                                                                                                         [\n                                                                                                                                          \"宨︩9앉檥pr쇷?WxLb\",\n                                                                                                                                          \"氇9】J玚\\u000f옛呲~ 輠1D嬛,*mW3?n휂糊γ虻*ᴫ꾠?q凐趗Ko↦GT铮\",\n                                                                                                                                          \"㶢ថmO㍔k'诔栀Z蛟}GZ钹D\",\n                                                                                                                                          false,\n                                                                                                                                          -6.366995517736813E-20,\n                                                                                                                                          -4894479530745302899,\n                                                                                                                                          null,\n                                                                                                                                          \"V%᫡II璅䅛䓎풹ﱢ/pU9se되뛞x梔~C)䨧䩻蜺(g㘚R?/Ự[忓C뾠ࢤc왈邠买?嫥挤풜隊枕\",\n                                                                                                                                          \",v碍喔㌲쟚蔚톬៓ꭶ\",\n                                                                                                                                          3.9625444752577524E-19,\n                                                                                                                                          null,\n                                                                                                                                          [\n                                                                                                                                           \"kO8란뿒䱕馔b臻⍟隨\\\"㜮鲣Yq5m퐔<u뷆c譆\\u001bN?<\",\n                                                                                                                                           [{\n                                                                                                                                            \";涉c蒀ᴧN䘱䤳 ÿꭷ,핉dSTDB>K#ꢘug㼈ᝦ=P^6탲@䧔%$CqSw铜랊0&m⟭<\\/a逎ym\\u0013vᯗ\": true,\n                                                                                                                                            \"洫`|XN뤮\\u0018詞=紩鴘_sX)㯅鿻Ố싹\": 7.168252736947373E-20,\n                                                                                                                                            \"ꛊ饤ﴏ袁(逊+~⽫얢鈮艬O힉7D筗S곯w操I斞᠈븘蓷x\": [[[[\n                                                                                                                                             -7.3136069426336952E18,\n                                                                                                                                             -2.13572396712722688E18,\n                                                                                                                                             {\n                                                                                                                                              \"硢3㇩R:o칢行E<=\\u0018ၬYuH!\\u00044U%卝炼2>\\u001eSi$⓷ꒈ'렢gᙫ番ꯒ㛹럥嶀澈v;葷鄕x蓎\\\\惩+稘UEᖸﳊ㊈壋N嫿⏾挎,袯苷ኢ\\\\x|3c\": 7540762493381776411,\n                                                                                                                                              \"?!*^ᢏ窯?\\u0001ڔꙃw虜돳FgJ?&⨫*uo籤:?}ꃹ=ٴ惨瓜Z媊@ત戹㔏똩Ԛ耦Wt轁\\\\枒^\\\\ꩵ}}}ꀣD\\\\]6M_⌫)H豣:36섘㑜\": {\n                                                                                                                                               \";홗ᰰU஋㙛`D왔ཿЃS회爁\\u001b-㢈`봆?盂㛣듿ᦾ蒽_AD~EEຆ㊋(eNwk=Rɠ峭q\\\"5Ἠ婾^>'ls\\n8QAK<l_⭨穟\": [\n                                                                                                                                                true,\n                                                                                                                                                true,\n                                                                                                                                                {\"ﳷm箅6qⷈ?ﲈ憟b۷⫉἞V뚴少U呡瓴ꉆs~嘵得㌶4XR漊\": [\n                                                                                                                                                 \"폆介fM暪$9K[ㄇ샍큳撦g撟恸jҐF㹹aj bHᘀ踉ꎐＣ粄 a?\\u000fK즉郝 幨9D舢槷Xh뵎u훩Ꜿ턾ƅ埂P埆k멀{䢹~?D<\\/꼢XR\\u001b〱䝽꼨i㘀ḟ㚺A-挸\",\n                                                                                                                                                 false,\n                                                                                                                                                 null,\n                                                                                                                                                 -1.1710758021294953E-20,\n                                                                                                                                                 3996737830256461142,\n                                                                                                                                                 true,\n                                                                                                                                                 null,\n                                                                                                                                                 -8271596984134071193,\n                                                                                                                                                 \"_1G퉁텑m䮔鰼6멲Nmꇩﬅ쓟튍N许FDj+3^ﶜ⎸\\u0019⤕橥!\\\"s-뾞lz北׸ꍚ랬)?l⻮고i䑰\\u001f䪬\",\n                                                                                                                                                 4.459124464204517E-19,\n                                                                                                                                                 -4.0967172848578447E18,\n                                                                                                                                                 5643211135841796287,\n                                                                                                                                                 -9.482336221192844E-19,\n                                                                                                                                                 \"౪冏釶9D?s螭X榈枸j2秀v]泌鰚岒聵轀쌶i텽qMbL]R,\",\n                                                                                                                                                 null,\n                                                                                                                                                 [\n                                                                                                                                                  null,\n                                                                                                                                                  {\"M쪊ꯪ@;\\u0011罙ꕅ<e᝺|爑Yⵝ<\\/&ᩎ<腊ሑᮔ੃F豭\": [\n                                                                                                                                                   \"^0࡟1볏P폋ፏ杈F⨥Iꂴ\\\"z磣VⅡ=8퀝2]䢹h1\\u0017{jT<I煛5%D셍S⑙⅏J*샐 巙ດ;᧡䙞\",\n                                                                                                                                                   [{\n                                                                                                                                                    \"'㶡큾鄧`跊\\\"gV[?u᭒Ʊ髷%葉굵a띦N켧Qﯳy%y䩟髒L䯜S䵳r絅肾킂ၐ'ꔦg긓a'@혔যW谁ᝬF栩ŷ+7w鞚\": 6.3544416675584832E17,\n                                                                                                                                                    \"苎脷v改hm쏵|㋊g_ᔐ 뒨蹨峟썎㷸|Ο刢?Gͨ옛-?GꦱIEYUX4?%ꘋᆊ㱺\": -2.8418378709165287E-19,\n                                                                                                                                                    \"誰?(H]N맘]k洳\\\"q蒧蘞!R퐫\\\\(Q$T5N堍⫣윿6|럦속︅ﭗ(\": [\n                                                                                                                                                     \"峩_\\u0003A瘘?✓[硫䎯ၽuጭ\\\"@Y綅첞m榾=贮9R벿῜Z\",\n                                                                                                                                                     null,\n                                                                                                                                                     \"䰉㗹㷾Iaᝃqcp쓘὾൫Q|ﵓ<\\/ḙ>)- Q䲌mo펹L_칍樖庫9꩝쪹ᘹ䑖瀍aK ?*趤f뭓廝p=磕\",\n                                                                                                                                                     \"哑z懅ᤏ-ꍹux쀭\",\n                                                                                                                                                     [\n                                                                                                                                                      true,\n                                                                                                                                                      3998739591332339511,\n                                                                                                                                                      \"ጻ㙙?᳸aK<\\/囩U`B3袗ﱱ?\\\"/k鏔䍧2l@쿎VZ쨎/6ꃭ脥|B?31+on颼-ꮧ,O嫚m ࡭`KH葦:粘i]aSU쓙$쐂f+詛頖b\",\n                                                                                                                                                      [{\"^<9<箝&絡;%i﫡2攑紴\\\\켉h쓙-柂䚝ven\\u20f7浯-Ꮏ\\r^훁䓚헬\\u000e?\\\\ㅡֺJ떷VOt\": [{\n                                                                                                                                                       \"-௄卶k㘆혐஽y⎱㢬sS઄+^瞥h;ᾷj;抭\\u0003밫f<\\/5Ⱗ裏_朻%*[-撵䷮彈-芈\": {\n                                                                                                                                                        \"㩩p3篊G|宮hz䑊o곥j^Co0\": [\n                                                                                                                                                         653239109285256503,\n                                                                                                                                                         {\"궲?|\\\":N1ۿ氃NZ#깩:쇡o8킗ࡊ[\\\"됸Po핇1(6鰏$膓}⽐*)渽J'DN<썙긘毦끲Ys칖\": {\n                                                                                                                                                          \"2Pr?Xjㆠ?搮/?㓦柖馃5뚣Nᦼ|铢r衴㩖\\\"甝湗ܝ憍\": \"\\\"뾯i띇筝牻$珲/4ka $匝휴译zbAᩁꇸ瑅&뵲衯ꎀᆿ7@ꈋ'ᶨH@ᠴl+\",\n                                                                                                                                                          \"7뢽뚐v?4^ꊥ_⪛.>pởr渲<\\/⢕疻c\\\"g䇘vU剺dஔ鮥꒚(dv祴X⼹\\\\a8y5坆\": true,\n                                                                                                                                                          \"o뼄B욞羁hr﷔폘뒚⿛U5pꪴfg!6\\\\\\\"爑쏍䢱W<ﶕ\\\\텣珇oI/BK뺡'谑♟[Ut븷亮g(\\\"t⡎有?ꬊ躺翁艩nl F⤿蠜\": 1695826030502619742,\n                                                                                                                                                          \"ۊ깖>ࡹ햹^ⵕ쌾BnN〳2C䌕tʬ]찠?ݾ2饺蹳ぶꌭ訍\\\"◹ᬁD鯎4e滨T輀ﵣ੃3\\u20f3킙D瘮g\\\\擦+泙ၧ 鬹ﯨַ肋7놷郟lP冝{ߒhড়r5,꓋\": null,\n                                                                                                                                                          \"ΉN$y{}2\\\\N﹯ⱙK'8ɜͣwt,．钟廣䎘ꆚk媄_\": null,\n                                                                                                                                                          \"䎥eᾆᝦ읉,Jުn岪㥐s搖謽䚔5t㯏㰳㱊ZhD䃭f絕s鋡篟a`Q鬃┦鸳n_靂(E4迠_觅뷝_宪D(NL疶hL追V熑%]v肫=惂!㇫5⬒\\u001f喺4랪옑\": {\n                                                                                                                                                           \"2a輍85먙R㮧㚪Sm}E2yꆣꫨrRym㐱膶ᔨ\\\\t綾A☰.焄뙗9<쫷챻䒵셴᭛䮜.<\\/慌꽒9叻Ok䰊Z㥪幸k\": [\n                                                                                                                                                            null,\n                                                                                                                                                            true,\n                                                                                                                                                            {\"쌞쐍\": {\n                                                                                                                                                             \"▟GL K2i뛱iＱ\\\"̠.옛1X$}涺]靎懠ڦ늷?tf灟ݞゟ{\": 1.227740268699265E-19,\n                                                                                                                                                             \"꒶]퓚%ฬK❅\": [{\n                                                                                                                                                              \"(ෛ@Ǯっ䧼䵤[aﾃൖvEnAdU렖뗈@볓yꈪ,mԴ|꟢캁(而첸죕CX4Y믅\": \"2⯩㳿ꢚ훀~迯?᪑\\\\啚;4X\\u20c2襏B箹)俣eỻw䇄\",\n                                                                                                                                                              \"75༂f詳䅫ꐧ鏿 }3\\u20b5'∓䝱虀f菼Iq鈆﨤g퍩)BFa왢d0뮪痮M鋡nw∵謊;ꝧf美箈ḋ*\\u001c`퇚퐋䳫$!V#N㹲抗ⱉ珎(V嵟鬒_b㳅\\u0019\": null,\n                                                                                                                                                              \"e_m@(i㜀3ꦗ䕯䭰Oc+-련0뭦⢹苿蟰ꂏSV䰭勢덥.ྈ爑Vd,ᕥ=퀍)vz뱊ꈊB_6듯\\\"?{㒲&㵞뵫疝돡믈%Qw限,?\\r枮\\\"? N~癃ruࡗdn&\": null,\n                                                                                                                                                              \"㉹&'Pfs䑜공j<\\/?|8oc᧨L7\\\\pXᭁ 9᪘\": -2.423073789014103E18,\n                                                                                                                                                              \"䝄瑄䢸穊f盈᥸,B뾧푗횵B1쟢f\\u001f凄\": \"魖⚝2儉j꼂긾껢嗎0ࢇ纬xI4](੓`蕞;픬\\fC\\\"斒\\\")2櫷I﹥迧\",\n                                                                                                                                                              \"ퟯ詔x悝령+T?Bg⥄섅kOeQ큼㻴*{E靼6氿L缋\\u001c둌๶-㥂2==-츫I즃㠐Lg踞ꙂEG貨鞠\\\"\\u0014d'.缗gI-lIb䋱ᎂDy缦?\": null,\n                                                                                                                                                              \"紝M㦁犿w浴詟棓쵫G:䜁?V2ힽ7N*n&㖊Nd-'ຊ?-樹DIv⊜)g䑜9뉂ㄹ푍阉~ꅐ쵃#R^\\u000bB䌎䦾]p.䀳\": [{\"ϒ爛\\\"ꄱ︗竒G䃓-ま帳あ.j)qgu扐徣ਁZ鼗A9A鸦甈!k蔁喙:3T%&㠘+,䷞|챽v䚞문H<\\/醯r셓㶾\\\\a볜卺zE䝷_죤ဵ뿰᎟CB\": [\n                                                                                                                                                               6233512720017661219,\n                                                                                                                                                               null,\n                                                                                                                                                               -1638543730522713294,\n                                                                                                                                                               false,\n                                                                                                                                                               -8901187771615024724,\n                                                                                                                                                               [\n                                                                                                                                                                3891351109509829590,\n                                                                                                                                                                true,\n                                                                                                                                                                false,\n                                                                                                                                                                -1.03836679125188032E18,\n                                                                                                                                                                {\n                                                                                                                                                                 \"<?起HCᷭ죎劐莇逰/{gs\\u0014⽛㰾愫tￖ<솞ڢ됌煲膺਻9x닳x࡭Q訽,ᶭඦtt掾\\\"秧㺌d˪䙻꫗:ᭈh4緞痐䤴c뫚떩త<?ᕢ謚6]폛O鰐鋛镠贩赟\\\"<G♷1'\": true,\n                                                                                                                                                                 \"቙ht4ߝBqꦤ+\\u0006멲趫灔)椾\": -1100102890585798710,\n                                                                                                                                                                 \"総兎곇뇸粟F醇;朠?厱楛㶆ⶏ7r⾛o꯬᳡F\\\\머幖 㜦\\f[搦᥽㮣0䕊?J㊳뀄e㔔+?<n↴复\": [\n                                                                                                                                                                  \"4~ꉍ羁\\\\偮(泤叕빜\\u0014>j랎:g曞ѕᘼ}链N\",\n                                                                                                                                                                  -1.1103819473845426E-19,\n                                                                                                                                                                  true,\n                                                                                                                                                                  [\n                                                                                                                                                                   true,\n                                                                                                                                                                   null,\n                                                                                                                                                                   -7.9091791735309888E17,\n                                                                                                                                                                   true,\n                                                                                                                                                                   {\"}蔰鋈+ꐨ啵0?g*사%`J?*\": [{\n                                                                                                                                                                    \"\\\"2wG?yn,癷BK\\\\龞䑞x?蠢\": -3.7220345009853505E-19,\n                                                                                                                                                                    \";饹়❀)皋`噿焒j(3⿏w>偍5X<np?<줯<Y]捘!J೸UⳂNे7v௸㛃ᄧ톿䨷鯻v焇=烻TQ!F⦰䣣눿K鷚눁'⭲m捠(䚻\": [\n                                                                                                                                                                     \"蹕 淜੃b\\\"+몾ⴕ\",\n                                                                                                                                                                     null,\n                                                                                                                                                                     35892237756161615,\n                                                                                                                                                                     {\n                                                                                                                                                                      \" 듹㏝)5慁箱&$~:遰쮐<\\/堋?% \\\\勽唅z손帋䘺H髀麡M퇖uz\\u0012m諦d᳤콌樝\\rX싹̡Ო\": -433791617729505482,\n                                                                                                                                                                      \"-j溗ࢵcz!:}✽5ഇ,욨ݏs#덫=南浺^}E\\\\Y\\\\T*뼈cd꺐cۘ뎁䨸됱K䠴㉿恿逳@wf쏢<\\/[L[\": -9.3228549642908109E17,\n                                                                                                                                                                      \"Ms킭u஗%\\\\u⍎/家欲ἅ答㓽/꯳齳|㭘Pr\\\"v<\\/禇䔆$GA䊻˔-:틊[h?倬荤ᾞ৳.Gw\\u000b\": [\n                                                                                                                                                                       \"0宜塙I@䏴蝉\\\\Uy뒅=2<h暒K._贡璐Yi檻_⮵uᐝ㘗聠[f\\u0015힢Hꔮ}጑;誏yf0\\\"\\u20cc?(=q斠➽5ꎾ鞘kⲃ\",\n                                                                                                                                                                       -2.9234211354411E-19,\n                                                                                                                                                                       false,\n                                                                                                                                                                       true,\n                                                                                                                                                                       {\n                                                                                                                                                                        \"\\u0011⟴GH_;#怵:\\u001c\\u0002n1U\\\\p/왔(┫]hꐚ7\\r0䵷첗岷O௷?㝎[殇|J=?韷pᶟ儜犆?5კ1kꍖiH竧뛈ପdmk游y(콪팱꾍k慧 y辣\": [\n                                                                                                                                                                         false,\n                                                                                                                                                                         \"O\\\"끍p覈ykv磂㢠㝵~뀬튍lC&4솎䇃:Mj\",\n                                                                                                                                                                         -7.009964654003924E-20,\n                                                                                                                                                                         false,\n                                                                                                                                                                         -49306078522414046,\n                                                                                                                                                                         null,\n                                                                                                                                                                         null,\n                                                                                                                                                                         2160432477732354319,\n                                                                                                                                                                         true,\n                                                                                                                                                                         \"4횡h+!踹ꐬP鮄{0&뱥M?샍鞅n㮞ᨹ?쒆毪l'箅^ꚥ頛`e㻨52柳⮙嫪࡟딯a.~䵮1f吘N&zȭL榓ۃ鳠5d㟆M@㣥ӋA΍q0縶$\",\n                                                                                                                                                                         -3.848996532974368E16,\n                                                                                                                                                                         true,\n                                                                                                                                                                         null,\n                                                                                                                                                                         -3.5240055580952525E18,\n                                                                                                                                                                         {\n                                                                                                                                                                          \" vﭷၵ#ce乃5僞?Z D`묨粇ᐔ绠vWL譢u뽀\\\\J|tⓙt№\\\"ꨋnT凮ᒩ蝂篝b騩:䢭Hbv읻峨z㹚T趗햆귣학津XiＹ@ᖥK\": true,\n                                                                                                                                                                          \"!F 醌y䉸W2ꇬ\\u0006/䒏7~%9擛햀徉9⛰+?㌘;ꠓX䇻Dfi뼧쒒\\u0012F謞՝絺+臕kऍLSQ쌁X쎬幦HZ98蒊枳\": \"澤令#\\u001d抍⛳@N搕퀂[5,✄ꘇ~䘷?\\u0011Xꈺ[硸⠘⛯X醪聡x\\u0007쌇MiX/|ﾐ뚁K8䁡W)銀q僞綂蔕E\",\n                                                                                                                                                                          \"6␲䣖R৞@ငg?<\\/೴x陙Xꈺ崸⠅ᇾ\\\\0X,H쟴셭A稂ힿゝF\\\\쑞\\u0012懦(Aᯕ灭~\\u0001껮X?逊\": 5.7566819207732864E17,\n                                                                                                                                                                          \"[c?椓\": false,\n                                                                                                                                                                          \"k䒇\": 2583824107104166717,\n                                                                                                                                                                          \"꙯N훙㏅ﮒ燣㨊瞯咽jMxby뻭뵫װ[\\\"1畈?ৱL\": \"띣ᔂ魠羓犴ꚃ+|rY\",\n                                                                                                                                                                          \"녺Z?䬝鉉:?ⳙ瘏Cኯ.Vs[釿䨉쐧\\\\\\\\*쵢猒$\\\\y溔^,㑳\": {\"藶꺟\": [{\n                                                                                                                                                                           \"\\\"d훣N2zq]?'檿죸忷篇ﮟ擤m'9!죶≓p뭻\\\\ᇷ\\f퇶_䰸h๐Q嵃訾㘑従ꯦ䞶jL틊r澵Omᾫ!H䱤팼/;|᭺I7슎YhuXi⚼\": -1.352716906472438E-19,\n                                                                                                                                                                           \"M⽇倻5J䂫औ᝔楸#J[Fﹱ쫮W誻bWz?}1\\\"9硪뻶fe\": \"盬:Ѹ砿획땣T凊(m灦呜ﻝR㿎艴䂵h\",\n                                                                                                                                                                           \"R띾k힪CH钙_i苮ⰵoᾨ紑퉎7h؉\\\"柀蝽z0့\\\"<?嘭$蜝?礲7岇槀묡?V钿T⣜v+솒灚ԛ2米mH?>薙婏聿3aFÆÝ\": \"2,ꓴg?_섦_>Y쪥션钺;=趘F~?D㨫\\bX?㹤+>/믟kᠪ멅쬂Uzỵ]$珧`m雁瑊ඖ鯬cꙉ梢f묛bB\",\n                                                                                                                                                                           \"♽n$YjKiXX*GO贩鏃豮祴遞K醞眡}ꗨv嵎꼷0୸+M菋eH徸J꣆:⼐悥B켽迚㯃b諂\\u000bjꠜ碱逮m8\": [\n                                                                                                                                                                            \"푷᣺ﻯd8ﱖ嬇ភH鹎⡱᱅0g:果6$GQ췎{vᷧYy-脕x偹砡館⮸C蓼ꏚ=軄H犠G谖ES詤Z蠂3l봟hￒ7䦹1GPQG癸숟~[#駥8zQ뛣J소obg,\",\n                                                                                                                                                                            null,\n                                                                                                                                                                            1513751096373485652,\n                                                                                                                                                                            null,\n                                                                                                                                                                            -6.851466660824754E-19,\n                                                                                                                                                                            {\"䩂-⴮2ٰK솖풄꾚ႻP앳1H鷛wmR䗂皎칄?醜<\\/&ࠧ㬍X濬䵈K`vJ륒Q/IC묛!;$vϑ\": {\n                                                                                                                                                                             \"@-ꚗxྐྵ@m瘬\\u0010U絨ﮌ驐\\\\켑寛넆T=tQ㭤L연@脸삯e-:⩼u㎳VQ㋱襗ຓ<Ⅶ䌸cML3+\\u001e_C)r\\\\9+Jn\\\\Pﺔ8蠱檾萅Pq鐳话T䄐I\": -1.80683891195530061E18,\n                                                                                                                                                                             \"ᷭዻU~ཷsgSJ`᪅'%㖔n5픆桪砳峣3獮枾䌷⊰呀\": {\n                                                                                                                                                                              \"Ş੉䓰邟自~X耤pl7间懑徛s첦5ਕXexh⬖鎥᐀nNr(J컗｜ૃF\\\"Q겮葲놔엞^겄+㈆话〾희紐G'E?飕1f❼텬悚泬먐U睬훶Qs\": false,\n                                                                                                                                                                              \"(\\u20dag8큽튣>^Y{뤋.袊䂓;_g]S\\u202a꽬L;^'#땏bႌ?C緡<䝲䲝断ꏏ6\\u001asD7IK5Wxo8\\u0006p弊⼂ꯍ扵\\u0003`뵂픋%ꄰ⫙됶l囏尛+䗅E쟇\\\\\": [\n                                                                                                                                                                               true,\n                                                                                                                                                                               {\n                                                                                                                                                                                \"\\n鱿aK㝡␒㼙2촹f;`쾏qIࡔG}㝷䐍瓰w늮*粅9뒪ㄊCj倡翑閳R渚MiUO~仨䜶RꙀA僈㉋⦋n{㖥0딿벑逦⥻0h薓쯴Ꝼ\": [\n                                                                                                                                                                                 5188716534221998369,\n                                                                                                                                                                                 2579413015347802508,\n                                                                                                                                                                                 9.010794400256652E-21,\n                                                                                                                                                                                 -6.5327297761238093E17,\n                                                                                                                                                                                 1.11635352494065523E18,\n                                                                                                                                                                                 -6656281618760253655,\n                                                                                                                                                                                 {\n                                                                                                                                                                                  \"\": \")?\",\n                                                                                                                                                                                  \"TWKLꑙ裑꺔UE俸塑炌Ũ᜕-o\\\"徚#\": {\"M/癟6!oI51ni퐚=댡>xꍨ\\u0004 ?\": {\n                                                                                                                                                                                   \"皭\": {\"⢫䋖>u%w잼<䕏꘍P䋵$魋拝U䮎緧皇Y훂&|羋ꋕ잿cJ䨈跓齳5\\u001a삱籷I꿾뤔S8㌷繖_Yឯ䲱B턼O歵F\\\\l醴o_欬6籏=D\": [\n                                                                                                                                                                                    false,\n                                                                                                                                                                                    true,\n                                                                                                                                                                                    {\"Mt|ꏞD|F궣MQ뵕T,띺k+?㍵i\": [\n                                                                                                                                                                                     7828094884540988137,\n                                                                                                                                                                                     false,\n                                                                                                                                                                                     {\n                                                                                                                                                                                      \"!༦鯠,&aﳑ>[euJꏽ綷搐B.h\": -7648546591767075632,\n                                                                                                                                                                                      \"-n켧嘰{7挐毄Y,>❏螵煫乌pv醑Q嶚!|⌝責0왾덢ꏅ蛨S\\\\)竰'舓Q}A釡5#v\": 3344849660672723988,\n                                                                                                                                                                                      \"8閪麁V=鈢1녈幬6棉⪮둌\\u207d᚛驉ꛃ'r䆉惏ै|bἧﺢᒙ<=穊强s혧eꮿ慩⌡ \\\\槳W븧J檀C,ᘉ의0俯퀉M;筷ࣴ瓿{늊埂鄧_4揸Nn阼Jੵ˥(社\": true,\n                                                                                                                                                                                      \"o뼀vw)4A뢵(a䵢)p姃뛸\\u000fK#KiQp\\u0005ꅍ芅쏅\": null,\n                                                                                                                                                                                      \"砥$ꥸ┇耽u斮Gc{z빔깎밇\\\\숰\\u001e괷各㶇쵿_ᴄ+h穢p촀Ნ䃬z䝁酳ӂ31xꔄ1_砚W렘G#2葊P \": [\n                                                                                                                                                                                       -3709692921720865059,\n                                                                                                                                                                                       null,\n                                                                                                                                                                                       [\n                                                                                                                                                                                        6669892810652602379,\n                                                                                                                                                                                        -135535375466621127,\n                                                                                                                                                                                        \"뎴iO}Z? 馢녱稹ᄾ䐩rSt帤넆&7i騏멗畖9誧鄜'w{Ͻ^2窭외b㑎粖i矪ꦨ탪跣)KEㆹ\\u0015V8[W?⽉>'kc$䨘ᮛ뉻٬M5\",\n                                                                                                                                                                                        1.10439588726055846E18,\n                                                                                                                                                                                        false,\n                                                                                                                                                                                        -4349729830749729097,\n                                                                                                                                                                                        null,\n                                                                                                                                                                                        [\n                                                                                                                                                                                         false,\n                                                                                                                                                                                         \"_蠢㠝^䟪/D녒㡋ỎC䒈판\\u0006એq@O펢%;鹐쏌o戥~A[ꡉ濽ỳ&虃᩾荣唙藍茨Ig楡꒻M窓冉?\",\n                                                                                                                                                                                         true,\n                                                                                                                                                                                         2.17220752996421728E17,\n                                                                                                                                                                                         -5079714907315156164,\n                                                                                                                                                                                         -9.960375974658589E-20,\n                                                                                                                                                                                         \"ᾎ戞༒\",\n                                                                                                                                                                                         true,\n                                                                                                                                                                                         false,\n                                                                                                                                                                                         [[\n                                                                                                                                                                                          \"ⶉᖌX⧕홇)g엃⹪x뚐癟\\u0002\",\n                                                                                                                                                                                          -5185853871623955469,\n                                                                                                                                                                                          {\n                                                                                                                                                                                           \"L㜤9ợㇶK鐰⋓V뽋˖!斫as|9＂፬䆪?7胜&n薑~\": -2.11545634977136992E17,\n                                                                                                                                                                                           \"O8뀩D}캖q萂6༣㏗䈓煮吽ਆᎼDᣘ폛;\": false,\n                                                                                                                                                                                           \"YTᡅ^L㗎cbY$pᣞ縿#fh!ꘂb삵玊颟샞ဢ$䁗鼒몁~rkH^:닮먖츸륈⪺쒉砉?㙓扫㆕꣒`R䢱B酂?C뇞<5Iޚ讳騕S瞦z\": null,\n                                                                                                                                                                                           \"\\\\RB?`mG댵鉡幐物䵎有5*e骄T㌓ᛪ琾駒Ku\\u001a[柆jUq8⋈5鿋츿myﻗ?雍ux঴?\": 5828963951918205428,\n                                                                                                                                                                                           \"n0晅:黯 xu씪^퓞cB㎊ᬍ⺘٤փ~B岚3㥕擄vᲂ~F?C䶖@$m~忔S왖㲚?챴⊟W#벌{'㰝I䝠縁s樘\\\\X뢻9핡I6菍ㄛ8쯶]wॽ0L\\\"q\": null,\n                                                                                                                                                                                           \"x增줖j⦦t䏢᎙㛿Yf鼘~꫓恄4惊\\u209c\": \"oOhbᤃ᛽z&Bi犑\\\\3B㩬劇䄑oŁ쨅孥멁ຖacA㖫借㞝vg싰샂㐜#譞⢤@k]鋰嘘䜾L熶塥_<\\/⍾屈ﮊ_mY菹t뙺}Ox=w鮮4S1ꐩמּ'巑\",\n                                                                                                                                                                                           \"㗓蟵ꂾe蠅匳(JP䗏෸\\u0089耀왲\": [{\n                                                                                                                                                                                            \"ᤃ㵥韎뤽\\r?挥O쯡⇔㞚3伖\\u0005P⋪\\\"D궣QLn(⚘罩䩢Ŏv䤘尗뼤됛O淽鋋闚r崩a{4箙{煷m6〈\": {\n                                                                                                                                                                                             \"l곺1L\": {\n                                                                                                                                                                                              \"T'ਤ?砅|੬Km]䄩\\\"(࿶<\\/6U爢䫈倔郴l2㴱^줣k'L浖L鰄Rp今鎗⒗C얨M훁㡧ΘX粜뫈N꤇輊㌻켑#㮮샶-䍗룲蠝癜㱐V>=\\\\I尬癤t=\": 7648082845323511446,\n                                                                                                                                                                                              \"鋞EP:<\\/_`ၧe混ㇹBd⯢㮂驋\\\\q碽饩跓྿ᴜ+j箿렏㗑yK毢宸p謹h䦹乕U媣\\\\炤\": [[\n                                                                                                                                                                                               \"3\",\n                                                                                                                                                                                               [\n                                                                                                                                                                                                true,\n                                                                                                                                                                                                3.4058271399411134E-20,\n                                                                                                                                                                                                true,\n                                                                                                                                                                                                \"揀+憱f逮@먻BpW曉\\u001a㣐⎊$n劈D枤㡞좾\\u001aᛁ苔౩闝1B䷒Ṋ݋➐ꀞꐃ磍$t੤_:蘺⮼(#N\",\n                                                                                                                                                                                                697483894874368636,\n                                                                                                                                                                                                [\n                                                                                                                                                                                                 \"vᘯ锴)0訶}䳅⩚0O壱韈ߜ\\u0018*U鍾䏖=䧉뽑单휻ID쿇嘗?ꌸῬ07\",\n                                                                                                                                                                                                 -5.4858784319382006E18,\n                                                                                                                                                                                                 7.5467775182251151E18,\n                                                                                                                                                                                                 -8911128589670029195,\n                                                                                                                                                                                                 -7531052386005780140,\n                                                                                                                                                                                                 null,\n                                                                                                                                                                                                 [\n                                                                                                                                                                                                  null,\n                                                                                                                                                                                                  true,\n                                                                                                                                                                                                  [[{\n                                                                                                                                                                                                   \"1欯twG<u䝮␽ꇣ_ჟﱴଶ-쪋\\\"?홺k:莝Ꜫ*⺵꽹댅釔좵}P?=9렿46b\\u001c\\\\S?(筈僦⇶爷谰1ྷa\": true,\n                                                                                                                                                                                                   \"TҫJYxڪ\\\\鰔℮혡)m_WVi眪1[71><\\/Q:0怯押殃탷聫사<ỗꕧ蚨䡁nDꌕ\\u001c녬~蓩<N蹑\\\"{䫥lKc혁뫖앺:vⵑ\": \"g槵?\",\n                                                                                                                                                                                                   \"aꨩ뻃싥렌1`롗}Yg>鲃g儊>ꏡl㻿/⑷*챳6㻜W毤緛ﹺᨪ4\\u0013뺚J髬e3쳸䘦伧?恪&{L掾p+꬜M䏊d娘6\": {\n                                                                                                                                                                                                    \"2p첼양棜h䜢﮶aQ*c扦v︥뮓kC寵횂S銩&ǝ{O*य़iH`U큅ࡓr䩕5ꄸ?`\\\\᧫?ᮼ?t〟崾훈k薐ì/ｉy꤃뵰z1<\\/AQ#뿩8jJ1z@u䕥\": 1.82135747285215155E18,\n                                                                                                                                                                                                    \"ZdN &=d년ᅆ'쑏ⅉ:烋5&៏ᄂ汎来L㯄固{钧u\\\\㊏튚e摑&t嗄ꖄUb❌?m䴘熚9EW\": [{\n                                                                                                                                                                                                     \"ଛ{i*a(\": -8.0314147546006822E17,\n                                                                                                                                                                                                     \"⫾ꃆY\\u000e+W`௸ \\\"M뒶+\\\\뷐lKE}(NT킶Yj選篒쁶'jNQ硾(똡\\\\\\\"逌ⴍy? IRꜘ὞鄬﨧:M\\\\f⠋Cꚜ쫊ᚴNV^D䕗ㅖἔIao꿬C⍏8\": [\n                                                                                                                                                                                                      287156137829026547,\n                                                                                                                                                                                                      {\n                                                                                                                                                                                                       \"H丞N逕<rO䎗:텕<\\/䶩샌Sd%^ᵯ눐엑者g䖩똭蕮1U驣?Pⰰ\\u001fp(W]67\\u0015﫣6굺OR羸#촐F蒈;嘙i✵@_撶y㤏⤍(:᧗뼢༌朆@⏰㤨ꭲ?-n>⯲\": {\"\": {\n                                                                                                                                                                                                        \"7-;枮阕梒9ᑄZ\": [[[[\n                                                                                                                                                                                                         null,\n                                                                                                                                                                                                         {\n                                                                                                                                                                                                          \"\": [[[[\n                                                                                                                                                                                                           -7.365909561486078E-19,\n                                                                                                                                                                                                           2948694324944243408,\n                                                                                                                                                                                                           null,\n                                                                                                                                                                                                           [\n                                                                                                                                                                                                            true,\n                                                                                                                                                                                                            \"荒\\\"并孷䂡쵼9o䀘F\\u0002龬7⮹Wz%厖/*? a*R枈㌦됾g뒠䤈q딄㺿$쮸tᶎ릑弣^鏎<\\/Y鷇驜L鿽<\\/춋9Mᲆឨ^<\\/庲3'l낢\",\n                                                                                                                                                                                                            \"c鮦\\u001b두\\\\~?眾ಢu݆綑෪蘛轋◜gȃ<\\/ⴃcpkDt誩܅\\\"Y\",\n                                                                                                                                                                                                            [[\n                                                                                                                                                                                                             null,\n                                                                                                                                                                                                             null,\n                                                                                                                                                                                                             [\n                                                                                                                                                                                                              3113744396744005402,\n                                                                                                                                                                                                              true,\n                                                                                                                                                                                                              \"v(y\",\n                                                                                                                                                                                                              {\n                                                                                                                                                                                                               \"AQ幆h쾜O+꺷铀ꛉ練A蚗⼺螔j㌍3꽂楎䥯뎸먩?\": null,\n                                                                                                                                                                                                               \"蠗渗iz鱖w]擪E\": 1.2927828494783804E-17,\n                                                                                                                                                                                                               \"튷|䀭n*曎b✿~杤U]Gz鄭kW|㴚#㟗ഠ8u擨\": [[\n                                                                                                                                                                                                                true,\n                                                                                                                                                                                                                null,\n                                                                                                                                                                                                                null,\n                                                                                                                                                                                                                {\"⾪壯톽g7?㥜ώQꑐ㦀恃㧽伓\\\\*᧰閖樧뢇赸N휶䎈pI氇镊maᬠ탷#X?A+kНM ༑᩟؝?5꧎鰜ṚY즫궔 =ঈ;ﳈ?*s|켦蜌wM笙莔\": [\n                                                                                                                                                                                                                 null,\n                                                                                                                                                                                                                 -3808207793125626469,\n                                                                                                                                                                                                                 [\n                                                                                                                                                                                                                  -469910450345251234,\n                                                                                                                                                                                                                  7852761921290328872,\n                                                                                                                                                                                                                  -2.7979740127017492E18,\n                                                                                                                                                                                                                  1.4458504352519893E-20,\n                                                                                                                                                                                                                  true,\n                                                                                                                                                                                                                  \"㽙깹?먏䆢:䴎ۻg殠JBTU⇞}ꄹꗣi#I뵣鉍r혯~脀쏃#釯:场:䔁>䰮o'㼽HZ擓௧nd\",\n                                                                                                                                                                                                                  [\n                                                                                                                                                                                                                   974441101787238751,\n                                                                                                                                                                                                                   null,\n                                                                                                                                                                                                                   -2.1647718292441327E-19,\n                                                                                                                                                                                                                   1.03602824249831488E18,\n                                                                                                                                                                                                                   [\n                                                                                                                                                                                                                    null,\n                                                                                                                                                                                                                    1.0311977941822604E-17,\n                                                                                                                                                                                                                    false,\n                                                                                                                                                                                                                    true,\n                                                                                                                                                                                                                    {\n                                                                                                                                                                                                                     \"\": -3.7019778830816707E18,\n                                                                                                                                                                                                                     \"E峾恆茍6xLIm縂0n2视֯J-ᤜz+ᨣ跐mYD豍繹⹺䊓몓ﴀE(@詮(!Y膽#᎙2䟓섣A䈀㟎,囪QbK插wcG湎ꤧtG엝x⥏俎j'A一ᯥ뛙6ㅑ鬀\": 8999803005418087004,\n                                                                                                                                                                                                                     \"よ殳\\\\zD⧅%Y泥簳Uꈩ*wRL{3#3FYHା[d岀䉯T稉駅䞘礄P:闈W怏ElB㤍喬赔bG䠼U଄Nw鰯闀楈ePsDꥷ꭬⊊\": [\n                                                                                                                                                                                                                      6.77723657904486E-20,\n                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                      [\n                                                                                                                                                                                                                       \"ཚ_뷎꾑蹝q'㾱ꂓ钚蘞慵렜떆`ⴹ⎼櫯]J?[t9Ⓢ !컶躔I᮸uz>3a㠕i,錃L$氰텰@7녫W㸮?羧W뇧ꃞ,N鋮숪2ɼ콏┍䁲6\",\n                                                                                                                                                                                                                       \"&y?뢶=킕올Za惻HZk>c\\u20b58i?ꦶcfBv잉ET9j䡡\",\n                                                                                                                                                                                                                       \"im珊Ճb칧<D-諂*u2ꡜ췛~䬢(텸ﵦ>校\\\\뼾쯀\",\n                                                                                                                                                                                                                       9.555715121193197E-20,\n                                                                                                                                                                                                                       true,\n                                                                                                                                                                                                                       {\n                                                                                                                                                                                                                        \"<㫚v6腓㨭e1㕔&&V∌ᗈT奄5Lጥ>탤?튣瑦㳆ꉰ!(ᙪ㿬擇_n쌯IMΉ㕨␰櫈ᱷ5풔蟹&L.첽e鰷쯃劼﫭b#ﭶ퓀7뷄Wr㢈๧Tʴશ㶑澕鍍%\": -1810142373373748101,\n                                                                                                                                                                                                                        \"fg晌o?߲ꗄ;>C>?=鑰監侯Kt굅\": true,\n                                                                                                                                                                                                                        \"䫡蓺ꑷ]C蒹㦘\\\"1ః@呫\\u0014NL䏾eg呮፳,r$裢k>/\\\\<z\": [[\n                                                                                                                                                                                                                         null,\n                                                                                                                                                                                                                         \"C䡏>?ㄤᇰﻛ쉕1஥'Ċ\\\" \\\\_?쨔\\\"ʾr: 9S䘏禺ᪧꄂ㲄\",\n                                                                                                                                                                                                                         [[{\n                                                                                                                                                                                                                          \"*硙^+E쌺I1䀖ju?:⦈Ꞓl๴竣迃xKC/饉:\\fl\\\"XTFﾨ蟭,芢<\\/骡軺띜hꏘ\\u001f銿<棔햳▨(궆*=乥b8\\\\媦䷀뫝}닶ꇭ(Kej䤑M\": [{\n                                                                                                                                                                                                                           \"1Ꮼ?>옿I╅C<ގ?ꊌ冉SV5A㢊㶆z-๎玶绢2F뵨@㉌뀌o嶔f9-庒茪珓뷳4\": null,\n                                                                                                                                                                                                                           \";lᰳ\": \"CbB+肻a䄷苝*/볳+/4fq=㰁h6瘉샴4铢Y骐.⌖@哼猎㦞+'gꋸ㒕ߤ㞑(䶒跲ti⑴a硂#No볔\",\n                                                                                                                                                                                                                           \"t?/jE幸YHT셵⩎K!Eq糦ꗣv刴w\\\"l$ο:=6:移\": {\n                                                                                                                                                                                                                            \"z]鑪醊嫗J-Xm銌翁絨c里됏炙Ep㣋鏣똼嚌䀓GP﹖cmf4鹭T䅿꣭姧␸wy6ꦶ;S&(}ᎧKxᾂQ|t뻳k\\\"d6\\\"|Ml췆hwLt꼼4$&8Պ褵婶鯀9\": {\"嵃닢ᒯ'd᧫䳳#NXe3-붋鸿ଢ떓%dK\\u0013䲎ꖍYV.裸R⍉rR3蟛\\\\:젯:南ĺLʆ넕>|텩鴷矔ꋅⒹ{t孶㓑4_\": [\n                                                                                                                                                                                                                             true,\n                                                                                                                                                                                                                             null,\n                                                                                                                                                                                                                             [\n                                                                                                                                                                                                                              false,\n                                                                                                                                                                                                                              \"l怨콈lᏒ\",\n                                                                                                                                                                                                                              {\n                                                                                                                                                                                                                               \"0w䲏嬧-:`䉅쉇漧\\\\܂yㄨb%㽄j7ᦶ涶<\": 3.7899452730383747E-19,\n                                                                                                                                                                                                                               \"ꯛTẀq纤q嶏V⿣?\\\"g}ი艹(쥯B T騠I=仵및X\": {\"KX6颠+&ᅃ^f畒y[\": {\n                                                                                                                                                                                                                                \"H?뱜^?꤂-⦲1a㋞&ꍃ精Ii᤾챪咽쬘唂쫷<땡劈훫놡o㥂\\\\ KⴙD秼F氮[{'좴:례晰Iq+I쭥_T綺砸GO煝䟪ᚪ`↹l羉q쐼D꽁ᜅ훦: vUV\": true,\n                                                                                                                                                                                                                                \"u^yﳍ0㱓#[y뜌앸ꊬL㷩?蕶蘾⻍KӼ\": -7931695755102841701,\n                                                                                                                                                                                                                                \"䤬轉車>\\u001c鴵惋\\\"$쯃྆⇻n뽀G氠S坪]ಲꨍ捇Qxኻ椕駔\\\\9ࣼ﫻읜磡煮뺪ᶚ볝l㕆t+sζ\": [[[\n                                                                                                                                                                                                                                 true,\n                                                                                                                                                                                                                                 false,\n                                                                                                                                                                                                                                 [\n                                                                                                                                                                                                                                  null,\n                                                                                                                                                                                                                                  3363739578828074923,\n                                                                                                                                                                                                                                  true,\n                                                                                                                                                                                                                                  {\n                                                                                                                                                                                                                                   \"\\\"鸣詩 볰㑵gL㯦῅춝旫}ED辗ﮈI쀤-ꧤ|㠦Z\\\"娑ᕸ4爏騍㣐\\\"]쳝Af]茛⬻싦o蚁k䢯䩐菽3廇喑ޅ\": 4.5017999150704666E17,\n                                                                                                                                                                                                                                   \"TYႇ7ʠ值4챳唤~Zo&ݛ\": false,\n                                                                                                                                                                                                                                   \"`塄J袛㭆끺㳀N㺣`꽐嶥KﯝSVᶔ∲퀠獾N딂X\\\"ᤏhNﬨvI\": {\"\\u20bb㭘I䖵䰼?sw䂷쇪](泒f\\\"~;꼪Fԝsᝦ\": {\"p,'ꉂ軿=A蚶?bƉ㏵䅰諬'LYKL6B깯⋩겦뎙(ᜭ\\u0006噣d꾆㗼Z;䄝䚔cd<情@䞂3苼㸲U{)<6&ꩻ钛\\u001au〷N숨囖愙j=BXW욕^x芜堏Ῑ爂뛷꒻t✘Q\\b\": [[\n                                                                                                                                                                                                                                    \"籛&ଃ䩹.ꃩ㦔\\\\C颫#暪&!勹ꇶ놽攺J堬镙~軌C'꾖䣹㮅岃ᙴ鵣\",\n                                                                                                                                                                                                                                    4.317829988264744E15,\n                                                                                                                                                                                                                                    6.013585322002147E-20,\n                                                                                                                                                                                                                                    false,\n                                                                                                                                                                                                                                    true,\n                                                                                                                                                                                                                                    null,\n                                                                                                                                                                                                                                    null,\n                                                                                                                                                                                                                                    -3.084633632357326E-20,\n                                                                                                                                                                                                                                    false,\n                                                                                                                                                                                                                                    null,\n                                                                                                                                                                                                                                    {\n                                                                                                                                                                                                                                     \"\\\"짫愔昻  X\\\"藣j\\\"\\\"먁ཅѻ㘤㬯0晲DU꟒㸃d벀윒l䦾c੻*3\": null,\n                                                                                                                                                                                                                                     \"谈Wm陧阦咟ฯ歖擓N喴㋐銭rCCnVࢥ^♼Ⅾ젲씗刊S༝+_t赔\\\\b䚍뉨ꬫ6펛cL䊘᜼<\\/澤pF懽&H\": [\n                                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                                      {\n                                                                                                                                                                                                                                       \"W\\\"HDUuΌ퀟M'P4࿰H똆ⰱﮯ<\\/凐蘲\\\"C鴫ﭒж}ꭩ쥾t5yd诪ﮡ퍉ⴰ@?氐醳rj4I6Qt\": 6.9090159359219891E17,\n                                                                                                                                                                                                                                       \"絛ﳛ⺂\": {\"諰P㗮聦`ZQ?ꫦh*റcb⧱}埌茥h{棩렛툽o3钛5鮁l7Q榛6_g)ὄ\\u0013kj뤬^爖eO4Ⱈ槞鉨ͺ订%qX0T썗嫷$?\\\\\\\"봅늆'%\": [\n                                                                                                                                                                                                                                        -2.348150870600346E-19,\n                                                                                                                                                                                                                                        [[\n                                                                                                                                                                                                                                         true,\n                                                                                                                                                                                                                                         -6619392047819511778,\n                                                                                                                                                                                                                                         false,\n                                                                                                                                                                                                                                         [[\n                                                                                                                                                                                                                                          -1.2929189982356161E-20,\n                                                                                                                                                                                                                                          1.7417192219309838E-19,\n                                                                                                                                                                                                                                          {\"?嵲2࿐2\\u0001啑㷳c縯\": [\n                                                                                                                                                                                                                                           null,\n                                                                                                                                                                                                                                           [\n                                                                                                                                                                                                                                            false,\n                                                                                                                                                                                                                                            true,\n                                                                                                                                                                                                                                            2578060295690793218,\n                                                                                                                                                                                                                                            {\n                                                                                                                                                                                                                                             \"?\\\"殃呎#㑑F\": true,\n                                                                                                                                                                                                                                             \"}F炊_殛oU헢兔Ꝉ,赭9703.B数gTz3⏬\": {\n                                                                                                                                                                                                                                              \"5&t3,햓Mݸᵣ㴵;꣫䩍↳#@뫷䠅+W-ࣇzᓃ鿕ಔ梭?T䮑ꥬ旴]u뫵막bB讍:왳둛lEh=숾鱠p咐$짏#?g⹷ᗊv㷵.斈u頻\\u0018-G.\": \"뽙m-ouࣤ஫牷\\\"`Ksꕞ筼3HlȨvC堈\\\"I]㖡玎r먞#'W賜鴇k'c룼髋䆿飉㗆xg巤9;芔cጐ/ax䊨♢큓r吓㸫೼䢗da᩾\\\"]屣`\",\n                                                                                                                                                                                                                                              \":M딪<䢥喠\\u0013㖅x9蕐㑂XO]ｆ*Q呰瞊吭VP@9,㨣 D\\\\穎vˤƩs㜂-曱唅L걬/롬j㈹EB8g<\\/섩o渀\\\"u0y&룣\": \">氍緩L/䕑돯Ꟙ蕞^aB뒣+0jK⪄瑨痜LXK^힦1qK{淚t츔X:Vm{2r獁B뾄H첚7氥?쉟䨗ꠂv팳圎踁齀\\\\\",\n                                                                                                                                                                                                                                              \"D彤5㢷Gꪻ[lㄆ@὜⓰絳[ଃ獽쮹☒[*0ꑚ㜳\": 9022717159376231865,\n                                                                                                                                                                                                                                              \"ҖaV銣tW+$魿\\u20c3亜~뫡ᙰ禿쨽㏡fṼzE/h\": \"5臐㋇Ჯ쮺? 昨탰Wﾑ밎#'\\\"崲钅U?幫뺀⍾@4kh>騧\\\\0ҾEV=爐͌U捀%ꉼ 㮋<{j]{R>:gԩL\\u001c瀈锌ﯲﳡꚒ'⫿E4暍㌗뵉X\\\"H᝜\",\n                                                                                                                                                                                                                                              \"ᱚגּ;s醒}犍SἿ㦣&{T$jkB\\\\\\tḮ앾䤹o<避(tW\": \"vb⯽䴪䮢@|)\",\n                                                                                                                                                                                                                                              \"⥒퐁껉%惀뗌+녣迺顀q條g⚯i⤭룐M琹j̈́⽜A\": -8385214638503106917,\n                                                                                                                                                                                                                                              \"逨ꊶZ<\\/W⫟솪㎮ᘇb?ꠔi\\\"H㧺x෷韒Xꫨฟ|]窽\\u001a熑}Agn?Mᶖa<rఄ4Ů䢤슲Axģe곖㴤x竾郍B謉鸵k薽M)\\\"芣眜`菉ꉛ䴺\": \"鹏^ె캫?3耲]|Ü1䡒㝮]8e?䶍^\",\n                                                                                                                                                                                                                                              \"뿸樅#P㡊1M룮Uꪭ绢ꑮZ9꽸\": {\"\\nJ^є|3袄ㅐ7⨆銦y睝⋷仴ct?[,<\\/ㅬ`?갔髞%揁A೚C\": {\n                                                                                                                                                                                                                                               \" 䇞3갫䅪\": [{\n                                                                                                                                                                                                                                                \"0|⩁㑂砕ㅻ\": null,\n                                                                                                                                                                                                                                                \"D箳᠉`|=⼭)\\\"*࣊㦏LjO誋\": \"\",\n                                                                                                                                                                                                                                                \"ࠚǱmꗥ}ᷴ╈r7헴ȥ4Kp5a)o}鎘门L搰䆓'✎k俎c#T68ӏ⩶6L鎴<r൦$黊BQY㼳\\\\跿F慮⡨拵贀!甶V喅/\": null,\n                                                                                                                                                                                                                                                \"ⵣq⳹ﻨLk]晩1*y\\\\$%}䖶P煑㇆䈦E嫁櫕Y࣓嫨䓏OL낮梚㸇洛洚BYtgl∛S☕䉓宑⋢粚ꔯ꠼붠\": \")ꬑ윤`\\\"Ⱓ<\\/婽*Y䔸ᓰ_ﳍt슲坩隥&S糧䛮闵诌豐sh쯽邴*섴؏͎=㯨\\\"RVힳ,^t\\\"ac?䤒ꉀxHa=Uꛕ㐙TkF껾\",\n                                                                                                                                                                                                                                                \"弾cUAF?暤c덽.欀nK앭]r傊䀓ﯳ馽垃[䥛oI0N砊鈥헅Co쟋钄ㅷ㊌뷚7\": [\n                                                                                                                                                                                                                                                 null,\n                                                                                                                                                                                                                                                 \"૓鏨?^䆏{\\u0006`X䧵儱&롡尙砡\\u0006뻝쑬sj▻XfᬶgcㄢV >9韲4$3Ỵ^=쏍煤ፐ돷2䣃%鷠/eQ9頸쥎\",\n                                                                                                                                                                                                                                                 2398360204813891033,\n                                                                                                                                                                                                                                                 false,\n                                                                                                                                                                                                                                                 3.2658897259932633E-19,\n                                                                                                                                                                                                                                                 null,\n                                                                                                                                                                                                                                                 \"?ꚃ8Nn㞷幵d䲳䱲뀙ꪛQ瑓鎴]䩋-鰾捡䳡??掊\",\n                                                                                                                                                                                                                                                 false,\n                                                                                                                                                                                                                                                 -1309779089385483661,\n                                                                                                                                                                                                                                                 \"ᦲxu_/yecR.6芏.ᜇ過 ~\",\n                                                                                                                                                                                                                                                 -5658779764160586501,\n                                                                                                                                                                                                                                                 \"쒌:曠=l썜䢜wk#s蕚\\\"互㮉m䉤~0듐䋙#G;h숄옥顇෤勹(C7㢅雚㐯L⠅VV簅<\",\n                                                                                                                                                                                                                                                 null,\n                                                                                                                                                                                                                                                 -4.664877097240962E18,\n                                                                                                                                                                                                                                                 -4.1931322262828017E18,\n                                                                                                                                                                                                                                                 {\n                                                                                                                                                                                                                                                  \",\": {\n                                                                                                                                                                                                                                                   \"v㮟麑䄠뤵g{M띮.\\u001bzt뢜뵡0Ǥ龍떟Ᾰ怷ϓRT@Lꀌ樂U㏠⾕e扉|bJg(뵒㠶唺~ꂿ(땉x⻫싉쁊;%0鎻V(o\\f,N鏊%nk郼螺\": -1.73631993428376141E18,\n                                                                                                                                                                                                                                                   \"쟧摑繮Q@Rᕾ㭚㾣4隅待㓎3蒟\": [\n                                                                                                                                                                                                                                                    4971487283312058201,\n                                                                                                                                                                                                                                                    8973067552274458613,\n                                                                                                                                                                                                                                                    {\n                                                                                                                                                                                                                                                     \"`a揙ᣗ\\u0015i<S幼訃锭B0&槩✨[Wp皩[g≊k葾x2ᡆ橲䲢W\": true,\n                                                                                                                                                                                                                                                     \"kH皈Sꁱq傑u?솹풑~o^F=劣N*reJ沤wW苯7p㼹䎐a=ꮧL㷩냴nWꌑ㞱uu谁lVN珿᤻(e豶5#L쪉ᅄ઄\\u0015숟봊P瀚X蓎\": false,\n                                                                                                                                                                                                                                                     \"䫯דּ〖Sc䛭점L뵾pCꙞ\\\"엇즓_ﰛ톣ꫀ먩㺣㮠⭴!\\\\W┏t䖰軅y\\u0014~ᇰ렢E7*俜䥪W䀩䷐h봆vjஉ묣༏G39.뼳輼:㮿ᐦA饕TUL}~\": [\n                                                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                                                      8.8648298810470003E17,\n                                                                                                                                                                                                                                                      5.735561205600924E-20,\n                                                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                                                      -102555823658171644,\n                                                                                                                                                                                                                                                      1.2674932032973067E-19,\n                                                                                                                                                                                                                                                      {\n                                                                                                                                                                                                                                                       \"D胣O㯨\\u0017Ku눓㒏텁nᨊ!Ꚇ廫_>Bo¸\": 4.3236479112537999E18,\n                                                                                                                                                                                                                                                       \"HW&퉡ぁ圍<W)6悰ꠑHEp14xy峑ft\\u0005s亘V튉䢮ꦈX嵐꬝?lI_덝춇-6Ss噺Nk-ﮥ큃܁郪*PR(S6╋@仙V懸뺵ﯜV粹\": \"9䗌斀4㐈^Qs隄硏j\\u0003\",\n                                                                                                                                                                                                                                                       \"Vk鶅C泹筁HX훉朗*r\\\\z顊誌儖4?n7᏾6몋䎡ﳈ],H頢p蚐㑄P4满E䏩V䬕ญL廂쒬쑨ꆷh迡ꍰ譖墎 ]鹿ฌ7ﶽ冭༽<ꈓS\\\\l䋮?_ﾕ檒?\": -8598528325153980065,\n                                                                                                                                                                                                                                                       \"t=q퍣疻тZ\\\\錅J.镎|nfḷ鴒1厰L灯纜E]୦⥪]Ꮾ'羝p/咩0닳ﳁqﳖཽk ?X1Ft%ś뭢v鋋⺃爵⒗\": [[\n                                                                                                                                                                                                                                                        5.0824756359232045E-19,\n                                                                                                                                                                                                                                                        [\n                                                                                                                                                                                                                                                         7.268480839079619E-19,\n                                                                                                                                                                                                                                                         {\"탿^굞⧕iј덊ꀛw껩6ꟳXs酚\\\\>Y?瑡Qy훍q!帰敏s舠㫸zꚗaS歲v`G株巷Jp6킼 (귶鍔⾏⡈>M汐㞍ቴ꙲dv@i㳓ᇆ?黍\": [\n                                                                                                                                                                                                                                                          null,\n                                                                                                                                                                                                                                                          4997607199327183467,\n                                                                                                                                                                                                                                                          \"E㻎蠫ᐾ高䙟蘬洼旾﫠텛㇛?'M$㣒蔸=A_亀绉앭rN帮\",\n                                                                                                                                                                                                                                                          null,\n                                                                                                                                                                                                                                                          [{\n                                                                                                                                                                                                                                                           \"Eᑞ)8<Z㡿W镀䛒C생V?0ꯦ+tL)`齳AjB姀XೳD빠㻲ƙgn9⑰ྍ῜&\\\"㚹>餧A5u&㗾q?\": [\n                                                                                                                                                                                                                                                            -1.969987519306507E-19,\n                                                                                                                                                                                                                                                            null,\n                                                                                                                                                                                                                                                            [\n                                                                                                                                                                                                                                                             3.42437673373841E-20,\n                                                                                                                                                                                                                                                             true,\n                                                                                                                                                                                                                                                             \"e걷M墁\\\"割P␛퍧厀R䱜3ﻴO퓫r﹉⹊\",\n                                                                                                                                                                                                                                                             [\n                                                                                                                                                                                                                                                              -8164221302779285367,\n                                                                                                                                                                                                                                                              [\n                                                                                                                                                                                                                                                               true,\n                                                                                                                                                                                                                                                               null,\n                                                                                                                                                                                                                                                               \"爘y^-?蘞Ⲽꪓa␅ꍨ}I\",\n                                                                                                                                                                                                                                                               1.4645984996724427E-19,\n                                                                                                                                                                                                                                                               [{\n                                                                                                                                                                                                                                                                \"tY좗⧑mrzﺝ㿥ⴖ᥷j諅\\u0000q賋譁Ꞅ⮱S\\nࡣB/큃굪3Zɑ复o<\\/;롋\": null,\n                                                                                                                                                                                                                                                                \"彟h浠_|V4䦭Dᙣ♞u쿻=삮㍦\\u001e哀鬌\": [{\"6횣楠,qʎꗇ鎆빙]㱭R굋鈌%栲j分僅ペ䇰w폦p蛃N溈ꡐꏀ?@(GI뉬$ﮄ9誁ꓚ2e甸ڋ[䁺,\\u0011\\u001cࢃ=\\\\+衪䷨ᯕ鬸K\": [[\n                                                                                                                                                                                                                                                                 \"ㅩ拏鈩勥\\u000etgWVXs陂規p狵w퓼{뮵_i\\u0002ퟑႢ⬐d6鋫F~챿搟\\u0096䚼1ۼ칥0꣯儏=鋷牋ⅈꍞ龐\",\n                                                                                                                                                                                                                                                                 -7283717290969427831,\n                                                                                                                                                                                                                                                                 true,\n                                                                                                                                                                                                                                                                 [\n                                                                                                                                                                                                                                                                  4911644391234541055,\n                                                                                                                                                                                                                                                                  {\n                                                                                                                                                                                                                                                                   \"I鈒첽P릜朸W徨觘-Hᎄ퐟⓺>8kr1{겵䍃〛ᬡ̨O귑o䝕'쿡鉕p5\": \"fv粖RN瞖蛐a?q꤄\\u001d⸥}'ꣴ犿ꦼ?뤋?鵆쥴덋䡫s矷̄?ඣ/;괱絢oWfV<\\/\\u202cC,㖦0䑾%n賹g&T;|ǉ_欂N4w\",\n                                                                                                                                                                                                                                                                   \"짨䠗;䌕u i+r๏0\": [{\"9䥁\\\\఩8\\\"馇z䇔<\\/ႡY3e狚쐡\\\"ุ6ﰆZ遖c\\\"Ll:ꮾ疣<\\/᭙Ｏ◌납୕湞9⡳Und㫜\\u0018^4pj1;䧐儂䗷ୗ>@e톬\": {\n                                                                                                                                                                                                                                                                    \"a⑂F鋻Q螰'<퇽Q贝瀧{ᘪ,cP&~䮃Z?gＩ彃\": [\n                                                                                                                                                                                                                                                                     -1.69158726118025933E18,\n                                                                                                                                                                                                                                                                     [\n                                                                                                                                                                                                                                                                      \"궂z簽㔛㮨瘥⤜䛖Gℤ逆Y⪾j08Sn昞ꘔ캻禀鴚P謦b{ꓮmN靐Mᥙ5\\\"睏2냑I\\u0011.L&=?6ᄠ뻷X鸌t刑\\\"#z)o꫚n쳟줋\",\n                                                                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                                                                      7517598198523963704,\n                                                                                                                                                                                                                                                                      \"ኑQp襟`uᩄr方]*F48ꔵn俺ሙ9뇒\",\n                                                                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                                                                      6645782462773449868,\n                                                                                                                                                                                                                                                                      1219168146640438184,\n                                                                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                                                                      {\n                                                                                                                                                                                                                                                                       \")ယ넌竀Sd䰾zq⫣⏌ʥ\\u0010ΐ' |磪&p牢蔑mV蘸૰짬꺵;K\": [\n                                                                                                                                                                                                                                                                        -7.539062290108008E-20,\n                                                                                                                                                                                                                                                                        [\n                                                                                                                                                                                                                                                                         true,\n                                                                                                                                                                                                                                                                         false,\n                                                                                                                                                                                                                                                                         null,\n                                                                                                                                                                                                                                                                         true,\n                                                                                                                                                                                                                                                                         6574577753576444630,\n                                                                                                                                                                                                                                                                         [[\n                                                                                                                                                                                                                                                                          1.2760162530699766E-19,\n                                                                                                                                                                                                                                                                          [\n                                                                                                                                                                                                                                                                           null,\n                                                                                                                                                                                                                                                                           [\n                                                                                                                                                                                                                                                                            \"顊\\\\憎zXB,\",\n                                                                                                                                                                                                                                                                            [{\n                                                                                                                                                                                                                                                                             \"㇆{CVC9－MN㜋ઘR눽#{h@ퟨ!鼚׼XOvXS\\u0017ᝣ=cS+梽៲綆16s덽휐y屬?ᇳG2ᴭ\\u00054쫖y룇nKcW̭炦s/鰘ᬽ?J|퓀髣n勌\\u0010홠P>j\": false,\n                                                                                                                                                                                                                                                                             \"箴\": [\n                                                                                                                                                                                                                                                                              false,\n                                                                                                                                                                                                                                                                              \"鍞j\\\"ꮾ*엇칬瘫xṬ⭽쩁䃳\\\"-⋵?ᦽ<cਔ↎⩧%鱩涎삧u9K⦈\\\"῝ᬑV绩킯愌ṱv@GꝾ跶Ꚇ(?䖃vI᧊xV\\r哦j㠒?*=S굤紴ꊀ鹭쬈s<DrIu솹꧑?\",\n                                                                                                                                                                                                                                                                              {\n                                                                                                                                                                                                                                                                               \".}S㸼L?t\\u000fK⑤s~hU鱜꘦}쪍C滈4ꓗ蛌):ྦ\\\"顥이⢷ῳYLn\\\"?fꘌ>댎Ĝ\": true,\n                                                                                                                                                                                                                                                                               \"Pg帯佃籛n㔠⭹࠳뷏≻࿟3㞱!-쒾!}쭪䃕!籿n涻J5ਲ਼yvy;Rኂ%ᔡጀ裃;M⣼)쵂쑈\": 1.80447711803435366E18,\n                                                                                                                                                                                                                                                                               \"ꈑC⡂ᑆ㤉壂뎃Xub<\\/쀆༈憓ق쨐ק\\\\\": [\n                                                                                                                                                                                                                                                                                7706977185172797197,\n                                                                                                                                                                                                                                                                                {\"\": {\"K╥踮砆NWࡆFy韣7ä밥{|紒︧䃀榫rᩛꦡTSy잺iH8}ퟴ,M?Ʂ勺ᴹ@T@~꾂=I㙕뾰_涀쑜嫴曣8IY?ҿo줫fऒ}\\\\S\\\"ᦨ뵼#nDX\": {\n                                                                                                                                                                                                                                                                                 \"♘k6?଱癫d68?㽚乳䬳-V顷\\u0005蝕?\\u0018䞊V{邾zじl]雏k臤~ൖH뒐iꢥ]g?.G碄懺䔛p<q꜉S岗_.%\": 7688630934772863849,\n                                                                                                                                                                                                                                                                                 \"溗摽嗙O㧀,⡢⼰呠ꅧ㓲/葇䢛icc@-r\\b渂ꌳ뻨饑觝ᖜ\\\\鮭\\u0014엙㥀᧺@浹W2꛵{W률G溮킀轡䬆g㨑'Q聨៪网Hd\\\"Q늴ᱢﶨ邮昕纚枑?▰hr羌驀[痹<\\/\": [\n                                                                                                                                                                                                                                                                                  -1.0189902027934687E-19,\n                                                                                                                                                                                                                                                                                  {\"窶椸릎뚻shE\\\"ꪗႥꎳU矖佟{SJ\": [{\"-慜x櫹XY-澐ܨ⣷ઢ鯙%Fu\\u0000迋▒}᥷L嗭臖oញc넨\\u0016/迎1b꯸g뢱㐧蓤䒏8C散삭|\\\"컪輩鹩\\\"\\\\g$zG䥽긷?狸꿭扵㲐:URON&oU8\": [\n                                                                                                                                                                                                                                                                                   null,\n                                                                                                                                                                                                                                                                                   true,\n                                                                                                                                                                                                                                                                                   null,\n                                                                                                                                                                                                                                                                                   -2.8907335031148883E17,\n                                                                                                                                                                                                                                                                                   -3864019407187144121,\n                                                                                                                                                                                                                                                                                   {\n                                                                                                                                                                                                                                                                                    \"`빬d⵺4H뜳⧈쓑ohஸ*㶐ﻇ⸕䠵!i䝬﹑h夘▥ꗐ푹갇㵳TA鳠嚵\\\\B<X}3訒c⋝{*﫢w]璨-g捭\\\\j໵侠Ei层\\u0011\": 3.758356090089446E-19,\n                                                                                                                                                                                                                                                                                    \"䄘ﮐ)Y놞씃㾱陰큁:{\\u2059/S⓴\": [[\n                                                                                                                                                                                                                                                                                     null,\n                                                                                                                                                                                                                                                                                     [[\n                                                                                                                                                                                                                                                                                      -3.8256602120220546E-20,\n                                                                                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                                                                                      7202317607724472882,\n                                                                                                                                                                                                                                                                                      \"CWQ뚿\",\n                                                                                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                                                                                      false,\n                                                                                                                                                                                                                                                                                      true,\n                                                                                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                                                                                      2857038485417498625,\n                                                                                                                                                                                                                                                                                      6.191302233218633E-20,\n                                                                                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                                                                                      -6795250594296208046,\n                                                                                                                                                                                                                                                                                      [\n                                                                                                                                                                                                                                                                                       true,\n                                                                                                                                                                                                                                                                                       {\n                                                                                                                                                                                                                                                                                        \"%ዧ遰Yᚯ⚀x莰愒Vᔈ턗BN洝ꤟA1⍌l콹풪H;OX๫륞쪐ᰚц@͎黾a邬<L厒Xb龃7f웨窂二;\": [[\n                                                                                                                                                                                                                                                                                         null,\n                                                                                                                                                                                                                                                                                         \"耲?䙧㘓F6Xs틭멢.v뚌?鄟恠▽'묺競?WvᆾCtxo?dZ;䨸疎\",\n                                                                                                                                                                                                                                                                                         {\n                                                                                                                                                                                                                                                                                          \"@hWꉁ&\\\"빜4礚UO~C;う殩_ꀥ蘁奢^챟k→ᡱKMⵉ<\\/Jㅲ붉L͟Q\": false,\n                                                                                                                                                                                                                                                                                          \"tU뢂8龰I먽7,.Y搽Z툼=&⨥覽K乫햶㠸%#@Z끖愓^⍊⾂몒3E_噆J(廊ឭyd䞜鈬Ћ档'⣘I\": {\n                                                                                                                                                                                                                                                                                           \"tK*ꔵ銂u艗ԃ쿏∳ꄂ霫X3♢9y?=ⲭdЊb&xy}\": [\n                                                                                                                                                                                                                                                                                            -4.097346784534325E-20,\n                                                                                                                                                                                                                                                                                            null,\n                                                                                                                                                                                                                                                                                            6016848468610144624,\n                                                                                                                                                                                                                                                                                            -8194387253692332861,\n                                                                                                                                                                                                                                                                                            null,\n                                                                                                                                                                                                                                                                                            {\n                                                                                                                                                                                                                                                                                             \"(祬诀譕쯠娣c봝r?畄kT뼾⌘⎨?noV䏘쥝硎n?\": [\n                                                                                                                                                                                                                                                                                              1.82679422844617293E18,\n                                                                                                                                                                                                                                                                                              [\n                                                                                                                                                                                                                                                                                               false,\n                                                                                                                                                                                                                                                                                               2.6849944122427694E18,\n                                                                                                                                                                                                                                                                                               true,\n                                                                                                                                                                                                                                                                                               [\n                                                                                                                                                                                                                                                                                                false,\n                                                                                                                                                                                                                                                                                                {\n                                                                                                                                                                                                                                                                                                 \";0z⭆;화$bਔ瀓\\\"衱^?잢ᢛ⣿~`ꕉ薸⌳໿湘腌'&:ryБꋥၼ꒥筙꬜긨?X\": -3536753685245791530,\n                                                                                                                                                                                                                                                                                                 \"c;Y7釚Uꃣ割J༨Y戣w}c峰뢨㽑㫈0N>R$䅒X觨l봜A刊8R梒',}u邩퉕?;91Ea䈈믁G⊶芔h袪&廣㺄j;㡏綽\\u001bN頸쳘橆\": -2272208444812560733,\n                                                                                                                                                                                                                                                                                                 \"拑Wﵚj鵼駳Oࣿ)#㾅顂N傓纝y僱栜'Bꐍ-!KF*ꭇK￤?䈴^:啤wG逭w᧯\": \"xᣱmYe1ۏ@霄F$ě꧘푫O䤕퀐Pq52憬ꀜ兴㑗ᡚ?L鷝ퟐ뭐zJꑙ}╆ᅨJB]\\\"袌㺲u8䯆f\",\n                                                                                                                                                                                                                                                                                                 \"꿽၅㔂긱Ǧ?SI\": -1669030251960539193,\n                                                                                                                                                                                                                                                                                                 \"쇝ɨ`!葎>瞺瘡驷錶❤ﻮ酜=\": -6961311505642101651,\n                                                                                                                                                                                                                                                                                                 \"?f7♄꫄Jᡔ훮e읇퍾፣䭴KhखT;Qty}O\\\\|뫁IῒNe(5惁ꥶㆷY9ﮡ\\\\ oy⭖-䆩婁m#x봉>Y鈕E疣s驇↙ᙰm<\": {\"퉻:dꂁ&efￎ쫢[\\\"돈늖꺙|Ô剐1͖-K:ʚ᭕/;쏖㷛]I痐职4g<Oꗢ뫺N쯂륬J╆.`ᇵP轆&fd$?苅o궓vO侃沲⍩嚅沗 E%⿰얦wi\\\\*趫\": [\n                                                                                                                                                                                                                                                                                                  3504362220185634767,\n                                                                                                                                                                                                                                                                                                  false,\n                                                                                                                                                                                                                                                                                                  \"qzX朝qT3軞T垈ꮲQ览ᚻ⻑쎎b驌䵆ꬠ5Fୗ䲁缿ꝁ蒇潇Ltᆄ钯蜀W欥ሺ\",\n                                                                                                                                                                                                                                                                                                  \"볰ɐ霬)젝鶼kwoc엷荁r \\u001d쒷⎹8{%澡K늒?iﺩd=&皼倚J9s@３偛twὡgj䁠흪5⭉⨺役&놎cﺉ㺡N5\",\n                                                                                                                                                                                                                                                                                                  false,\n                                                                                                                                                                                                                                                                                                  null,\n                                                                                                                                                                                                                                                                                                  \"D0ﬆ[ni锹r*0k6ꀎ덇UX2⽼৞䃚粭#)Z桷36P]<\\/`\",\n                                                                                                                                                                                                                                                                                                  4281410120849816730,\n                                                                                                                                                                                                                                                                                                  null,\n                                                                                                                                                                                                                                                                                                  -3256922126984394461,\n                                                                                                                                                                                                                                                                                                  1.16174580369801549E18,\n                                                                                                                                                                                                                                                                                                  {\n                                                                                                                                                                                                                                                                                                   \" ᆼꤗ~*TN긂<㡴턱℃酰^蘒涯잰淭傛2rൡet쾣䐇m*㸏y\\\"\\\\糮᧺qv쌜镜T@yg1譬ﭧﳭ\\f\": null,\n                                                                                                                                                                                                                                                                                                   \"圾ᨿ0xᮛ禵ਗ਼D-㟻ẵ錚e\\\"赜.˶m)鴑B(I$<\\/轴퉯揷⋏⏺*)宓쓌?*橯Lx\\\\f쩂㞼⇸\\\"ﺧ軂遳V\\\\땒\\\"캘c:G\": null,\n                                                                                                                                                                                                                                                                                                   \"?﵁_곢翸폈8㿠h열Q2㭛}RY㯕ＹT놂⽻e^B<\\/맫ﻇ繱\\u0017Gц⟊ᢑﵩS:jt櫣嗒⟰W㴚搦ᅉe[w䋺?藂翙Ⲱ芮䍘╢囥lpdu7r볺I 近qFyᗊ\": [\n                                                                                                                                                                                                                                                                                                    \"$b脬aﾠ襬育Bگ嵺Pw+'M<\\/כֿn䚚v螁bN⒂}褺%lቦ阤\\\"ꓺᏗM牏,۞Ҷ!矬?ke9銊X괦)䈽틁脽ṫ䈞ᴆ^=Yᗿ遛4I귺⋥%\",\n                                                                                                                                                                                                                                                                                                    false,\n                                                                                                                                                                                                                                                                                                    2.9444482723232051E18,\n                                                                                                                                                                                                                                                                                                    2072621064799640026,\n                                                                                                                                                                                                                                                                                                    \"/_뇴뫢j㍒=Nꡦ↍Ժ赒❬톥䨞珯su*媸瀳鷔抡o흺-៳辏勷f绔:䵢搢2\",\n                                                                                                                                                                                                                                                                                                    false,\n                                                                                                                                                                                                                                                                                                    \"쒜 E䌐/큁\\u0018懺_<\\\\隺&{wF⤊谼(<죽遠8?@*rᶊGd뻻갇&Ⳇq᣿e࢔t_ꩄ梸O詬C᧧Kꩠ풤9눙醅됞}竸rw?滨ӽK⥿ཊG魲']`๖5㄰\",\n                                                                                                                                                                                                                                                                                                    -2375253967958699084,\n                                                                                                                                                                                                                                                                                                    {\"嗱⿲\\\"f億ᝬ\": {\"v?䚑킡`◤k3,骥曘뒤Oᒱ㲹^圮᠀YT껛&촮P:G/T⣝#튣k3炩蠏k@橈䏷S䧕,熜晬k1鮥玸먚7䤡f绝嗚샴ᥒ~0q拮垑a뻱LⰖ_\": [{\n                                                                                                                                                                                                                                                                                                     \":p尢\": -6.688985172863383E17,\n                                                                                                                                                                                                                                                                                                     \"A0\\u0001疠ﻵ爻鼀湶I~W^岀mZx#㍈7r拣$Ꜷ疕≛⦒痋盩Vꬷ᭝ΩQꍪ療鈑A(劽詗ꭅo-獶鑺\\\"Ⓠ@$j탥;\": [\n                                                                                                                                                                                                                                                                                                      8565614620787930994,\n                                                                                                                                                                                                                                                                                                      [\n                                                                                                                                                                                                                                                                                                       \"嶗PC?උQ㪣$&j幾㾷h慑 즊慧⪉霄M窊ꁷ'鮕)䊏铨m趦䗲(g罣ЮKVﯦ鏮5囗ﰼ鿦\",\n                                                                                                                                                                                                                                                                                                       -7168038789747526632,\n                                                                                                                                                                                                                                                                                                       null,\n                                                                                                                                                                                                                                                                                                       -7.8069738975270288E16,\n                                                                                                                                                                                                                                                                                                       2.25819579241348352E17,\n                                                                                                                                                                                                                                                                                                       -6.5597416611655936E18,\n                                                                                                                                                                                                                                                                                                       {\n                                                                                                                                                                                                                                                                                                        \"瘕멦핓+?ﾌZ귢z鍛V\": {\n                                                                                                                                                                                                                                                                                                         \"ᕾ\": 1.7363275204701887E-19,\n                                                                                                                                                                                                                                                                                                         \"㭌s뎹㳉\": {\"\\u00187FI6Yf靺+UC쬸麁␲䂿긕R\\\\ᆮC?Φ耭\\rOத际핅홦*베W㸫㯼᡹cㅜ|G㮗\\u0013[o`?jHV앝?蒪꩚!퍫ᜦ㌇䚇鿘:@\": [\n                                                                                                                                                                                                                                                                                                          \"}푛Г콲<䟏C藐呈#2㓋#ྕ፟尿9q竓gI%랙mꍬoa睕贿J咿D_熏Zz皳験I豼B扳ḢQ≖㻹㱣D䝦練2'ᗍ㗣▌砲8罿%హF姦;0悇<\\/\\\"p嚧\",\n                                                                                                                                                                                                                                                                                                          -710184373154164247,\n                                                                                                                                                                                                                                                                                                          \"Vo쫬⬾ꝫⴷŻ\\u0004靎HBꅸ_aVBＨbN>Z4⍜kเꛘZ⥺\\\\Bʫᇩ鄨魢弞&幟ᓮ2̊盜\",\n                                                                                                                                                                                                                                                                                                          -9006004849098116748,\n                                                                                                                                                                                                                                                                                                          -3118404930403695681,\n                                                                                                                                                                                                                                                                                                          {\n                                                                                                                                                                                                                                                                                                           \"_彃Y艘-\\\"Xx㤩㳷瑃?%2䐡鵛o<A?\\\"顜ᘌΈ;ⷅC洺L蚴蚀voq:,Oo4쪂)\": 5719065258177391842,\n                                                                                                                                                                                                                                                                                                           \"l륪맽耞塻論倐E㗑/㲕QM辬I\\\"qi酨玑㖪5q]尾魨鲡ƞY}⮯蠇%衟Fsf윔䐚찤i腳\": {\"ꢪ'a䣊糈\": {\"밑/♋S8s㼴5瓹O{댞\\\"9XﰇlJ近8}q{긧ⓈI᱑꿋腸D瀬H\\\"ﺬ'3?}\\u0014#?丙㑯ᥨ圦',g鑠(樴턇?\": [\n                                                                                                                                                                                                                                                                                                            2.5879275511391145E18,\n                                                                                                                                                                                                                                                                                                            null,\n                                                                                                                                                                                                                                                                                                            [\n                                                                                                                                                                                                                                                                                                             \"3㼮ꔌ1Gẃ2W龙j͊{1囐㦭9x宠㑝oR䐕犽\",\n                                                                                                                                                                                                                                                                                                             1268729930083267852,\n                                                                                                                                                                                                                                                                                                             \"땕軚⿦7C\",\n                                                                                                                                                                                                                                                                                                             [\n                                                                                                                                                                                                                                                                                                              -3.757935946502082E18,\n                                                                                                                                                                                                                                                                                                              \"\\\"赌'糬_2뭾᝝b\",\n                                                                                                                                                                                                                                                                                                              {\n                                                                                                                                                                                                                                                                                                               \"(a䕎ጽjҰD4.ᴡ66ԃ畮<\\/l`k癸\\\\㇋ࣆ욯R㫜픉녬挛;ڴ맺`.;焓q淞뮕ٹ趴r蔞ꯔ䟩v粏u5<\\/pZ埖Skrvj帛=\\u0005aa\": null,\n                                                                                                                                                                                                                                                                                                               \"璄≩ v몛ᘮ%?:1頌챀H㷪뉮k滘e\": [\n                                                                                                                                                                                                                                                                                                                \"ꤾ{`c샬왌펡[俊络vmz㪀悫⸹ᷥ5o'㾵 L蹦qjYIYណԠW냁剫<\\/W嗂0,}\",\n                                                                                                                                                                                                                                                                                                                2.4817616702666762E18,\n                                                                                                                                                                                                                                                                                                                false,\n                                                                                                                                                                                                                                                                                                                null,\n                                                                                                                                                                                                                                                                                                                null,\n                                                                                                                                                                                                                                                                                                                -8.6036958071260979E17,\n                                                                                                                                                                                                                                                                                                                null,\n                                                                                                                                                                                                                                                                                                                -1.2744078022652468E-19,\n                                                                                                                                                                                                                                                                                                                -4.4752020268429594E17,\n                                                                                                                                                                                                                                                                                                                1.13672865156637872E17,\n                                                                                                                                                                                                                                                                                                                [\n                                                                                                                                                                                                                                                                                                                 false,\n                                                                                                                                                                                                                                                                                                                 false,\n                                                                                                                                                                                                                                                                                                                 null,\n                                                                                                                                                                                                                                                                                                                 -4.178004168554046E-20,\n                                                                                                                                                                                                                                                                                                                 true,\n                                                                                                                                                                                                                                                                                                                 2927542512798605527,\n                                                                                                                                                                                                                                                                                                                 {\n                                                                                                                                                                                                                                                                                                                  \".ꔓ뉤1䵬cHy汼䊆賓ᐇƩ|樷❇醎㬅4\\u0003赵}#yD5膏晹뱓9ꖁ虛J㺕 t䊛膎ؤ\": {\n                                                                                                                                                                                                                                                                                                                   \"rVtᓸ5^`েN⹻Yv᥋lꌫt拘?<鮰넿ZC?㒽^\": {\"␪k_:>귵옔夘v*탋职&㳈챗|O钧\": [\n                                                                                                                                                                                                                                                                                                                    false,\n                                                                                                                                                                                                                                                                                                                    \"daꧺdᗹ羞쯧H㍤鄳頳<型孒ン냆㹀f4㹰\\u000f|C*ሟ鰠(O<ꨭ峹ipຠ*y೧4VQ蔔hV淬{?ᵌEfrI_\",\n                                                                                                                                                                                                                                                                                                                    \"j;ꗣ밷邍副]ᗓ\",\n                                                                                                                                                                                                                                                                                                                    -4299029053086432759,\n                                                                                                                                                                                                                                                                                                                    -5610837526958786727,\n                                                                                                                                                                                                                                                                                                                    [\n                                                                                                                                                                                                                                                                                                                     null,\n                                                                                                                                                                                                                                                                                                                     [\n                                                                                                                                                                                                                                                                                                                      -1.3958390678662759E-19,\n                                                                                                                                                                                                                                                                                                                      {\n                                                                                                                                                                                                                                                                                                                       \"lh좈T_믝Y\\\"伨\\u001cꔌG爔겕ꫳ晚踍⿻읐T䯎]~e#฽燇\\\"5hٔ嶰`泯r;ᗜ쮪Q):/t筑,榄&5懶뎫狝(\": [{\n                                                                                                                                                                                                                                                                                                                        \"2ፁⓛ]r3C攟וּ9賵s⛔6'ஂ|\\\"ⵈ鶆䐹禝3\\\"痰ࢤ霏䵩옆䌀?栕r7O簂Isd?K᫜`^讶}z8?z얰T:X倫⨎ꑹ\": -6731128077618251511,\n                                                                                                                                                                                                                                                                                                                        \"|︦僰~m漿햭\\\\Y1'Vvخ굇ቍ챢c趖\": [null]\n                                                                                                                                                                                                                                                                                                                       }],\n                                                                                                                                                                                                                                                                                                                       \"虌魿閆5⛔煊뎰㞤ᗴꥰF䮥蘦䂪樳-K᝷-(^\\u20dd_\": 2.11318679791770592E17\n                                                                                                                                                                                                                                                                                                                      }\n                                                                                                                                                                                                                                                                                                                     ]\n                                                                                                                                                                                                                                                                                                                    ]\n                                                                                                                                                                                                                                                                                                                   ]},\n                                                                                                                                                                                                                                                                                                                   \"묗E䀳㧯᳀逞GMc\\b墹㓄끖Ơ&U??펌鑍 媋k))ᄊ\": null,\n                                                                                                                                                                                                                                                                                                                   \"묥7콽벼諌J_DɯﮪM殴䣏,煚ྼ`Y:씧<\\/⩫%yf䦀!1Ჶk춎Q米W∠WC跉鬽*ᛱi<?,l<崣炂骵*?8푐៣ⰵ憉⎑.,Nw罣q+ο컆弎\": false\n                                                                                                                                                                                                                                                                                                                  },\n                                                                                                                                                                                                                                                                                                                  \"e[|଀+lꑸ㝈TT?뿿|ꫛ9`㱯䊸楋-곳賨?쳁k棽擋wQ餈⟐Nq[q霩䵀뷮锅ꚢ\": 5753148631596678144,\n                                                                                                                                                                                                                                                                                                                  \"sᓝ鴻߸d렶ὕ蜗ဟ툑!诉౿\": false,\n                                                                                                                                                                                                                                                                                                                  \"|4䕳鵻?䈔(]틍/Ui#湻{듲ーMዀt7潔泄Ch⸨}쏣`螧銚㋼壯kⰥQ戵峉갑x辙'첛\": \"jd䘯$䕌茷!auw眶ㅥ䁣ꆢ民i\",\n                                                                                                                                                                                                                                                                                                                  \"剖駰ꞫsM2]ᾴ2ࡷ祅拌Av狔꩛'ꓗ킧ꣁ0酜✘O'\": false,\n                                                                                                                                                                                                                                                                                                                  \"澩뢣ꀁeU~D\\\\ꮡ킠\": \"v^YC嚈ί\\u0007죋h>㴕L꘻ꀏ쓪\\\"_g鿄'#t⽙?,Wg㥖|D鑆e⥏쪸僬h鯔咼ඡ;4TK聎졠嫞\"\n                                                                                                                                                                                                                                                                                                                 }\n                                                                                                                                                                                                                                                                                                                ]\n                                                                                                                                                                                                                                                                                                               ]\n                                                                                                                                                                                                                                                                                                              }\n                                                                                                                                                                                                                                                                                                             ]\n                                                                                                                                                                                                                                                                                                            ]\n                                                                                                                                                                                                                                                                                                           ]}}\n                                                                                                                                                                                                                                                                                                          }\n                                                                                                                                                                                                                                                                                                         ]}\n                                                                                                                                                                                                                                                                                                        },\n                                                                                                                                                                                                                                                                                                        \"뿋뀾淣截䔲踀&XJ펖꙯^Xb訅ꫥgᬐ>棟S\\\"혧騾밫겁7-\": \"擹8C憎W\\\"쵮yR뢩浗絆䠣簿9䏈引Wcy䤶孖ꯥ;퐌]輩䍐3@{叝 뽸0ᡈ쵡Ⲇ\\u001dL匁꧐2F~ݕ㪂@W^靽L襒ᦘ~沦zZ棸!꒲栬R\"\n                                                                                                                                                                                                                                                                                                       }\n                                                                                                                                                                                                                                                                                                      ]\n                                                                                                                                                                                                                                                                                                     ],\n                                                                                                                                                                                                                                                                                                     \"Z:덃൛5Iz찇䅄駠㭧蓡K1\": \"e8᧤좱U%?ⵇ䯿鿝\\u0013縮R∱骒EO\\u000fg?幤@֗퉙vU`\",\n                                                                                                                                                                                                                                                                                                     \"䐃쪈埽້=Ij,쭗쓇చ\": false\n                                                                                                                                                                                                                                                                                                    }]}}\n                                                                                                                                                                                                                                                                                                   ]\n                                                                                                                                                                                                                                                                                                  }\n                                                                                                                                                                                                                                                                                                 ]}\n                                                                                                                                                                                                                                                                                                }\n                                                                                                                                                                                                                                                                                               ]\n                                                                                                                                                                                                                                                                                              ]\n                                                                                                                                                                                                                                                                                             ],\n                                                                                                                                                                                                                                                                                             \"咰긖VM]᝼6䓑쇎琺etDҌ?㞏ꩄ퇫밉gj8蠃\\\"⩐5䛹1ࣚ㵪\": \"ക蹊?⎲⧘⾚̀I#\\\"䈈⦞돷`wo窭戕෱휾䃼)앷嵃꾞稧,Ⴆ윧9S?೗EMk3Მ3+e{⹔Te驨7䵒?타Ulg悳o43\"\n                                                                                                                                                                                                                                                                                            }\n                                                                                                                                                                                                                                                                                           ],\n                                                                                                                                                                                                                                                                                           \"zQᤚ纂땺6#ٽ﹧v￿#ࠫ휊冟蹧텈ꃊʆ?&a䥯De潝|쿓pt瓞㭻啹^盚2Ꝋf醪,얏T窧\\\\Di䕎谄nn父ꋊE\": -2914269627845628872,\n                                                                                                                                                                                                                                                                                           \"䉩跐|㨻ᷢ㝉B{蓧瞸`I!℄욃힕#ೲᙾ竛ᔺCjk췒늕貭词\\u0017署?W딚%(pꍁ⤼띳^=on뺲l䆼bzrﳨ[&j狸䠠=ᜑꦦ\\u2061յnj=牲攑)M\\\\龏\": false,\n                                                                                                                                                                                                                                                                                           \"뎕y絬᫡⥮Ϙᯑ㌔/NF*˓.,QEzvK!Iwz?|쥾\\\"ꩻL꼗Bꔧ賴緜s뉣隤茛>ロ?(?^`>冺飒=噸泥⺭Ᲊ婓鎔븜z^坷裮êⓅ໗jM7ﶕ找\\\\O\": 1.376745434746303E-19\n                                                                                                                                                                                                                                                                                          },\n                                                                                                                                                                                                                                                                                          \"䐛r滖w㏤<k;l8ꡔጵ⮂ny辶⋃퍼僮z\\\"﮲X@t5෼暧퓞猋♅䦖QC鹮|픨( ,>,|Nዜ\": false\n                                                                                                                                                                                                                                                                                         }\n                                                                                                                                                                                                                                                                                        ]],\n                                                                                                                                                                                                                                                                                        \"@꿙?薕尬 gd晆(띄5躕ﻫS蔺4)떒錸瓍?~\": 1665108992286702624,\n                                                                                                                                                                                                                                                                                        \"w믍nᏠ=`঺ￆC>'從됐槷䤝眷螄㎻揰扰XￊC贽uჍ낟jKD03T!lDV쀉Ӊy뢖,袛!终캨G?鉮Q)⑗1쾅庅O4ꁉH7?d\\u0010蠈줘월ސ粯Q!낇껉6텝|{\": null,\n                                                                                                                                                                                                                                                                                        \"~˷jg쿤촖쉯y\": -5.5527605669177098E18,\n                                                                                                                                                                                                                                                                                        \"펅Wᶺzꐆと푭e?4j仪열[D<鈑皶婆䵽ehS?袪;HꍨM뗎ば[(嗏M3q퍟g4y╸鰧茀[Bi盤~﫝唎鋆彺⦊q?B4쉓癚O洙킋툈䶯_?ퟲ\": null\n                                                                                                                                                                                                                                                                                       }\n                                                                                                                                                                                                                                                                                      ]\n                                                                                                                                                                                                                                                                                     ]]\n                                                                                                                                                                                                                                                                                    ]],\n                                                                                                                                                                                                                                                                                    \"꟱Ԕ㍤7曁聯ಃ錐V䷰?v㪃૦~K\\\"$%请|ꇹn\\\"k䫛㏨鲨\\u2023䄢\\u0004[<S8ᐬ뭩脥7U.m࿹:D葍┆2蘸^U'w1젅;䠆ꋪB껮>︊VJ?䶟ាꮈ䗱=깘U빩\": -4863152493797013264\n                                                                                                                                                                                                                                                                                   }\n                                                                                                                                                                                                                                                                                  ]}]}\n                                                                                                                                                                                                                                                                                 ]\n                                                                                                                                                                                                                                                                                }}}\n                                                                                                                                                                                                                                                                               ],\n                                                                                                                                                                                                                                                                               \"쏷쐲۹퉃~aE唙a챑,9㮹gLHd'䔏|킗㍞䎥&KZYT맵7䥺N<Hp4ꕭ⹠꽐c~皽z\": \"课|ᖾ䡁廋萄䐪W\\u0016&Jn괝b~摓M>ⱳ同莞鿧w\\\\༌疣n/+ꎥU\\\"封랾○ퟙAJᭌ?9䛝$?驔9讐짘魡T֯c藳`虉C읇쐦T\"\n                                                                                                                                                                                                                                                                              }\n                                                                                                                                                                                                                                                                             ],\n                                                                                                                                                                                                                                                                             \"谶개gTR￐>ၵ͚dt晑䉇陏滺}9㉸P漄\": -3350307268584339381\n                                                                                                                                                                                                                                                                            }]\n                                                                                                                                                                                                                                                                           ]\n                                                                                                                                                                                                                                                                          ]\n                                                                                                                                                                                                                                                                         ]]\n                                                                                                                                                                                                                                                                        ]\n                                                                                                                                                                                                                                                                       ],\n                                                                                                                                                                                                                                                                       \"0y꟭馋X뱔瑇:䌚￐廿jg-懲鸭䷭垤㒬茭u賚찶ಽ+\\\\mT땱\\u20821殑㐄J쩩䭛ꬿNS潔*d\\\\X,壠뒦e殟%LxG9:摸\": 3737064585881894882,\n                                                                                                                                                                                                                                                                       \"풵O^-⧧ⅶvѪ8廸鉵㈉ר↝Q㿴뺟EႳvNM:磇>w/៻唎뷭୥!냹D䯙i뵱貁C#⼉NH6`柴ʗ#\\\\!2䂗Ⱨf?諳.P덈-返I꘶6?8ꐘ\": -8934657287877777844,\n                                                                                                                                                                                                                                                                       \"溎-蘍寃i诖ര\\\"汵\\\"\\ftl,?d⼡쾪⺋h匱[,෩I8MҧF{k瓿PA'橸ꩯ綷퉲翓\": null\n                                                                                                                                                                                                                                                                      }\n                                                                                                                                                                                                                                                                     ]\n                                                                                                                                                                                                                                                                    ],\n                                                                                                                                                                                                                                                                    \"ោ係؁<元\": 1.7926963090826924E-18\n                                                                                                                                                                                                                                                                   }}]\n                                                                                                                                                                                                                                                                  }\n                                                                                                                                                                                                                                                                 ]\n                                                                                                                                                                                                                                                                ]]}]\n                                                                                                                                                                                                                                                               }]\n                                                                                                                                                                                                                                                              ]\n                                                                                                                                                                                                                                                             ]\n                                                                                                                                                                                                                                                            ]\n                                                                                                                                                                                                                                                           ],\n                                                                                                                                                                                                                                                           \"ጩV<\\\"ڸsOᤘ\": 2.0527167903723048E-19\n                                                                                                                                                                                                                                                          }]\n                                                                                                                                                                                                                                                         ]}\n                                                                                                                                                                                                                                                        ]\n                                                                                                                                                                                                                                                       ]],\n                                                                                                                                                                                                                                                       \"∳㙰3젴p᧗䱙?`<U὇<\\/意E[ᮚAj诂ᒽ阚uv徢ဎ떗尔Ᵹ훀쩑J䐴?⪏=륪ᆩ푰ஓ㐕?럽VK\\\"X?檨လ齿I/耉A(AWA~⏯稐蹫\": false,\n                                                                                                                                                                                                                                                       \"偒妝뾇}䀼链i⇃%⋜&璪Ix渥5涧qq棩ᥝ-⠫AA낇yY颕A*裦O|n?䭬혗F\": null,\n                                                                                                                                                                                                                                                       \"琭CL얭B혆Kॎ`鎃nrsZiժW砏)?p~K~A眱䲏QO妣\\u001b\\u001b]ᵆᆯ&㐋ᏹ豉뺘$ꭧ#j=C)祤⫢歑1o㒙諩\": 7028426989382601021,\n                                                                                                                                                                                                                                                       \"쳱冲&ဤ䌏앧h胺-齱H忱8왪RDKᅒ䬋ᔶS*J}ስ漵'㼹뮠9걢9p봋경ጕtởꚳT䶽瘙%춴`@nಆ4<d??#僜ᙤ钴=薔ꭂbLXNam蹈\": \"樭る蹿= Uurwkn뙧⌲%\\\"쑃牪\\\"cq윕o@\",\n                                                                                                                                                                                                                                                       \"溌[H]焎SLㅁ?뀼䫨災W\": 1.1714289118497062E-19,\n                                                                                                                                                                                                                                                       \"ﬢp븇剌燇kĔ尘㶿㴞睠꾘Ia;s❺^)$穮?sHᢥ폪l\": null\n                                                                                                                                                                                                                                                      }\n                                                                                                                                                                                                                                                     ]\n                                                                                                                                                                                                                                                    }\n                                                                                                                                                                                                                                                   ]\n                                                                                                                                                                                                                                                  },\n                                                                                                                                                                                                                                                  \"TKnzj5o<\\/K㊗ꗣ藠⦪駇>yZA8Ez0,^ᙛ4_0븢\\u001ft:~䎼s.bb룦明yNP8弆C偯;⪾짍'蕴뮛\": -6976654157771105701,\n                                                                                                                                                                                                                                                  \"큵ꦀ\\\\㇑:nv+뒤燻䀪ﴣ﷍9ᚈ኷K㚊誦撪䚛,ꮪxሲ쳊\\u0005HSf?asg昱dqꬌVꙇ㼺'k*'㈈\": -5.937042203633044E-20\n                                                                                                                                                                                                                                                 }\n                                                                                                                                                                                                                                                ]\n                                                                                                                                                                                                                                               }],\n                                                                                                                                                                                                                                               \"?}\\u20e0],s嶳菋@#2u쒴sQS䩗=ꥮ;烌,|ꘔ䘆\": \"ᅩ영N璠kZ먕眻?2ቲ芋眑D륟渂⸑ﴃIRE]啗`K'\"\n                                                                                                                                                                                                                                              }},\n                                                                                                                                                                                                                                              \"쨀jmV賂ﰊ姐䂦玞㬙ᏪM᪟Վ씜~`uOn*ॠ8\\u000ef6??\\\\@/?9見d筜ﳋB|S䝬葫㽁o\": true\n                                                                                                                                                                                                                                             },\n                                                                                                                                                                                                                                             \"즛ꄤ酳艚␂㺘봿㎨iG৕ࡿ?1\\\"䘓您\\u001fSኝ⺿溏zៀ뻤B\\u0019?윐a䳵᭱䉺膷d:<\\/\": 3935553551038864272\n                                                                                                                                                                                                                                            }\n                                                                                                                                                                                                                                           ]\n                                                                                                                                                                                                                                          ]}\n                                                                                                                                                                                                                                         ]]\n                                                                                                                                                                                                                                        ]]\n                                                                                                                                                                                                                                       ]}\n                                                                                                                                                                                                                                      }\n                                                                                                                                                                                                                                     ]\n                                                                                                                                                                                                                                    }\n                                                                                                                                                                                                                                   ]]}},\n                                                                                                                                                                                                                                   \"᥺3h↛!ꋰy\\\"攜(ெl䪕oUkc1A㘞ᡲ촾ᣫ<\\/䒌E㛝潨i{v?W౾H\\\\RჅpz蝬R脾;v:碽✘↯삞鷱o㸧瑠jcmK7㶧뾥찲n\": true,\n                                                                                                                                                                                                                                   \"ⶸ?x䊺⬝-䰅≁!e쩆2ꎿ准G踌XXᩯ1߁}0?.헀Z馟;稄\\baDꟹ{-寪⚈ꉷ鮸_L7ƽᾚ<\\u001bጨA䧆송뇵⨔\\\\礍뗔d设룱㶉cq{HyぱR㥽吢ﬅp\": -7985372423148569301,\n                                                                                                                                                                                                                                   \"緫#콮IB6<\\/=5Eh礹\\t8럭@饹韠r㰛斣$甝LV췐a갵'请o0g:^\": \"䔨(.\",\n                                                                                                                                                                                                                                   \"띳℡圤pﾝ௄ĝ倧訜B쁟G䙔\\\"Sb⓮;$$▏S1J뢙SF|赡g*\\\"Vu䲌y\": \"䪈&틐),\\\\kT鬜1풥;뷴'Zေ䩹@J鞽NぼM?坥eWb6榀ƩZڮ淽⺞삳煳xჿ絯8eⶍ羷V}ჿ쎱䄫R뱃9Z>'\\u20f1ⓕ䏜齮\"\n                                                                                                                                                                                                                                  }\n                                                                                                                                                                                                                                 ]\n                                                                                                                                                                                                                                ]]]\n                                                                                                                                                                                                                               }}\n                                                                                                                                                                                                                              }\n                                                                                                                                                                                                                             ]\n                                                                                                                                                                                                                            ]},\n                                                                                                                                                                                                                            \"펮b.h粔폯2npX詫g錰鷇㇒<쐙S値bBi@?镬矉`剔}c2壧ଭfhY깨R()痩⺃a\\\\⍔?M&ﯟ<劜꺄멊ᄟA\\\"_=\": null\n                                                                                                                                                                                                                           },\n                                                                                                                                                                                                                           \"~潹Rqn榢㆓aR鬨侅?䜑亡V_翅㭔(䓷w劸ၳDp䀅<\\/ﰎ鶊m䵱팱긽ꆘ<tD쇋>긓准D3掱;o:_ќ)껚콥8곤d矦8nP倥ꃸI\": null,\n                                                                                                                                                                                                                           \"뾎/Q㣩㫸벯➡㠦◕挮a鶧⋓偼\\u00001뱓fm覞n?㛅\\\"\": 2.8515592202045408E17\n                                                                                                                                                                                                                          }],\n                                                                                                                                                                                                                          \",\": -5426918750465854828,\n                                                                                                                                                                                                                          \"2櫫@0柡g䢻/gꆑ6演&D稒肩Y?艘/놘p{f투`飷ᒉ챻돎<늛䘍ﴡ줰쫄\": false,\n                                                                                                                                                                                                                          \"8(鸑嵀⵹ퟡ<9㣎Tߗ┘d슒ل蘯&㠦뮮eࠍk砝g 엻\": false,\n                                                                                                                                                                                                                          \"d-\\u208b?0ﳮ嵙'(J`蔿d^踅⤔榥\\\\J⵲v7\": 6.8002426206715341E17,\n                                                                                                                                                                                                                          \"ཎ耰큓ꐕ㱷\\u0013y=詽I\\\"盈xm{0쾽倻䉚ષso#鰑/8㸴짯%ꀄ떸b츟*\\\\鲷礬ZQ兩?np㋄椂榨kc᡹醅3\": false,\n                                                                                                                                                                                                                          \"싊j20\": false\n                                                                                                                                                                                                                         }]]\n                                                                                                                                                                                                                        ]],\n                                                                                                                                                                                                                        \"俛\\u0017n緽Tu뫉蜍鼟烬.ꭠIⰓ\\\"Ἀ᜾uC쎆J@古%ꛍm뻨ᾀ画蛐휃T:錖㑸ዚ9죡$\": true\n                                                                                                                                                                                                                       }\n                                                                                                                                                                                                                      ]\n                                                                                                                                                                                                                     ],\n                                                                                                                                                                                                                     \"㍵⇘ꦖ辈s}㱮慀밒s`\\\"㞟j:`i픻Z<C1衽$\\\"-饧?℃\\u0010⼒{p飗%R\\\"䲔\\\")칀\\\\%\": true,\n                                                                                                                                                                                                                     \"苧.8\\u00120ݬ仓\": 6912164821255417986,\n                                                                                                                                                                                                                     \"떎顣俁X;.#Q틝.笂'p쟨唒퐏랩냆¦aⱍ{谐.b我$蜑SH\\u000f琾=䟼⣼奔ᜏ攕B&挰繗㝔ꅂ-Qv\\\\0䶝䚥ぺio［㑮-ᇼ䬰컪ṼiY){데\\u0010q螰掻~\\n輚x\\u0014罺)軴\": 3.024364150712629E-20\n                                                                                                                                                                                                                    }\n                                                                                                                                                                                                                   ]\n                                                                                                                                                                                                                  ]\n                                                                                                                                                                                                                 ]\n                                                                                                                                                                                                                ]}\n                                                                                                                                                                                                               ]]\n                                                                                                                                                                                                              }\n                                                                                                                                                                                                             ]\n                                                                                                                                                                                                            ]]\n                                                                                                                                                                                                           ]\n                                                                                                                                                                                                          ]]]],\n                                                                                                                                                                                                          \"\\\"凲o肉Iz絾豉J8?i~傠᫽䇂!WD溊J?ᡒvs菆嵹➒淴>섫^諎0Ok{켿歁෣胰a2﨤[탳뚬쎼嫭뉮m\": 409440660915023105,\n                                                                                                                                                                                                          \"w墄#*ᢄ峠밮jLa`ㆪ꺊漓Lで끎!Agk'ꁛ뢃㯐岬D#㒦\": false,\n                                                                                                                                                                                                          \"ଦPGI䕺L몥罭ꃑ궩﮶#⮈ᢓӢ䚬p7웼臧%~S菠␌힀6&t䳙y㪘냏\\\\*;鉏ￊ鿵'嗕pa\\\"oL쇿꬈Cg\": \"㶽1灸D⟸䴅ᆤ뉎﷛渤csx 䝔цꬃ锚捬?ຽ+x~꘩uI࡞\\u0007栲5呚ẓem?袝\\\")=㥴䨃pac!/揎Y\",\n                                                                                                                                                                                                          \"ᷱo\\\\||뎂몷r篙|#X䦜I#딌媸픕叞RD斳X4t⯩夬=[뭲r=绥jh뷱츝⪘%]⚋܈㖴スH텹m(WO曝劉0~K3c柢Ր㏉着逳~\": false,\n                                                                                                                                                                                                          \"煽_qb[첑\\\\륌wE❽ZtCNﭝ+餌ᕜOꛭ\": \"{ﳾ쉌&s惧ᭁⵆ3䢫;䨞팑꒪흘褀࢖Q䠿V5뭀䎂澻%받u5텸oA⮥U㎦;B䳌wz䕙$ឿ\\\\௅婺돵⪾퐆\\\\`Kyौꋟ._\\u0006L챯l뇠Hi䧈偒5\",\n                                                                                                                                                                                                          \"艊佁ࣃ롇䱠爬!*;⨣捎慓q靓|儑ᨋL+迥=6㒺딉6弄3辅J-㕎뛄듘SG㆛(\\noAzQꝱ䰩X*ぢO퀌%펠낌mo틮a^<\\/F&_눊ᾉ㨦ы4\\\"8H\": 2974648459619059400,\n                                                                                                                                                                                                          \"鬙@뎣䫳ၮ끡?){y?5K;TA*k溱䫜J汃ꂯ싔썍\\u001dA}룖(<\\/^,\": false,\n                                                                                                                                                                                                          \"몏@QꋦFꊩᒐ뎶lXl垨4^郣|ꮇ;䝴ᝓ}쵲z珖\": null\n                                                                                                                                                                                                         }\n                                                                                                                                                                                                        ]]]],\n                                                                                                                                                                                                        \":_=닧弗D䙋暨鏛. 㱻붘䂍J儒&ZK/녩䪜r囁⽯D喠죥7⹌䪥c\\u001a\\u2076￞妈朹oLk菮F౟覛쐧㮏7T;}蛙2{9\\\"崓bB<\\/⡷룀;즮鿹)丒툃୤뷠5W⊢嶜(fb뭳갣\": \"E{响1WM\"\n                                                                                                                                                                                                       }},\n                                                                                                                                                                                                       \"䘨tjJ驳豨?y輊M*᳑梵瞻઻ofQG瑮e\": 2.222802939724948E-19,\n                                                                                                                                                                                                       \"䮴=❑➶T෋w䞜\\\"垦ꃼUt\\u001dx;B$뵣䙶E↌艣ᡥ!᧟;䱀[䔯k쬃`੍8饙른熏'2_'袻tGf蒭J땟as꯳╖&啒zWࡇᒫYSᏬ\\u0014ℑ첥鈤|cG~Pᓮ\\\">\\\"\": \"ႆl\\f7V儊㦬nHꄬꨧC{쐢~C⮃⛓嶦vꄎ1w鰠嘩뿠魄&\\\"_qMⵖ釔녮ꝇ 㝚{糍J哋 cv?-jkﻯྌ鹑L舟r\",\n                                                                                                                                                                                                       \"龧葆yB✱H盋夔ﶉ?n*0(\": \"ꧣኆ㢓氥qZZ酒ຜ)鮢樛)X䣆gTSґG텞k.J圬疝롫쯭z L：\\\\ྤ@w炋塜쿖ᾳy뢀䶃뱝N䥨㚔勇겁#p\",\n                                                                                                                                                                                                       \"도畎Q娡\\\"@S/뼋:䵏!P衅촚fVHQs✜ᐫi㻑殡B䜇%믚k*U#濨낄~\": \"ꍟዕ쳸ꍈ敋&l妏\\u0005憡멗瘌uPgᅪm<\\/To쯬锩h뒓k\"\n                                                                                                                                                                                                      }\n                                                                                                                                                                                                     ]\n                                                                                                                                                                                                    }],\n                                                                                                                                                                                                    \"墥홞r绚<\\/⸹ⰃB}<躅\\\\Y;๑@䔸>韫䜲뱀X뗩鿥쩗SI%ﴞ㳕䛇?<\\/\\u00018x\\\\&侂9鋙a[LR㋭W胕)⡿8㞙0JF,}?허d1cDMᐃ␛鄝ⱕ%X)!XQ\": \"ⳍꗳ=橇a;3t⦾꼑仈ူaᚯ⯋ꕃAs鴷N⍕_䎃ꙎAz\\u0016䯷\\\\<࿫>8q{}ｷ?ᣰ}'0ᴕ펓B┦lF#趤厃T?㕊#撹圂䆲\"\n                                                                                                                                                                                                   },\n                                                                                                                                                                                                   \"܋닐龫論c웑\": false,\n                                                                                                                                                                                                   \"ㇿ/q\\\"6-co髨휝C큦#\\u001b4~?3䐹E삇<<\": 7.600917488140322E-20,\n                                                                                                                                                                                                   \"䁝E6?㣖ꃁ间t祗*鑠{ḣV(浾h逇큞=W?ૉ?nꇽ8ꅉຉj으쮺@Ꚅ㰤u]Oyr\": \"v≁᫸_*όAඤԆl)ۓᦇQ}폠z༏q滚\",\n                                                                                                                                                                                                   \"ｿ᥊/넺I\": true\n                                                                                                                                                                                                  }]]\n                                                                                                                                                                                                 ]\n                                                                                                                                                                                                ]\n                                                                                                                                                                                               ]\n                                                                                                                                                                                              ]]\n                                                                                                                                                                                             },\n                                                                                                                                                                                             \"䭑Ik攑\\u0002QV烄:芩.麑㟴㘨≕\": true,\n                                                                                                                                                                                             \"坄꿕C쇻풉~崍%碼\\\\8\\\"䬦꣙\": null,\n                                                                                                                                                                                             \"欌L圬䅘Y8c(♺2?ON}o椳s宥2䉀eJ%闹r冁O^K諭%凞⺉⡻,掜?$ꥉ?略焕찳㯊艼誜4?\\\"﯎<゛XፈINT:詓 +\": -1.0750456770694562E-19,\n                                                                                                                                                                                             \"獒àc뜭싼ﺳ뎤K`]p隨LtE\": null,\n                                                                                                                                                                                             \"甙8䵊神EIꩤ鐯ᢀ,ﵮU䝑u疒ử驺䚿≚ഋ梶秓F`覤譐#짾蔀묊4<媍쬦靪_Yzgcࡶ4k紥`kc[Lﮗ簐*I瀑[⾰L殽鑥_mGȠ<\\/|囹灠g桰iri\": true,\n                                                                                                                                                                                             \"챓ꖙꟻ좝菇ou,嗠0\\\\jK핻뜠qwQ?ഩ㼕3Y彦b\\u009bJ榶N棨f?됦鏖綃6鳵M[OE봨u햏.Ꮁ癜蟳뽲ꩌ뻾rM豈R嗀羫 uDꎚ%\": null\n                                                                                                                                                                                            },\n                                                                                                                                                                                            \"V傜2<\": 7175127699521359521\n                                                                                                                                                                                           }],\n                                                                                                                                                                                           \"铫aG切<\\/\\\"ী⊆e<^g࢛)D顝ｎאַ饼\\u008c猪繩嵿ﱚCꡬ㻊g엺A엦\\u000f暿_f꿤볝㦕桦`蒦䎔j甬%岝rj 糏\": \"䚢偎눴Au<4箞7礦Iﱔ坠eȧ䪸u䵁p|逹$嗫쨘ꖾ﷐!胠z寓팢^㨔|u8Nሇe텔ꅦ抷]،鹎㳁#༔繁 \",\n                                                                                                                                                                                           \"낂乕ꃻ볨ϱ-ꇋ㖍fs⿫)zꜦ/K?솞♞ꑌ宭hJ᤭瑥Fu\": false,\n                                                                                                                                                                                           \"쟰ぜ魛G\\u0003u?`㾕ℾ㣭5螠烶這趩ꖢ:@咕ꐶx뒘느m䰨b痃렐0鳊喵熬딃$摉_~7*ⱦ녯1錾GKhJ惎秴6'H妈Tᧅ窹㺒疄矤铟wላ\": null,\n                                                                                                                                                                                           \"쯆q4!3錕㲏ⵆ㇛꘷Z瑩뭆\\\\◪NH\\u001d\\\\㽰U~㯶<\\\"쑣낞3ᵤ'峉eꢬ;鬹o꣒木X*長PXᘱu\\\"䠹n惞\": null,\n                                                                                                                                                                                           \"ᅸ祊\\\"&ꥴCjࢼ﴿?䡉`U效5殼㮞V昽ꏪ#ﺸ\\\\&t6x꠹盥꣰a[\\u001aꪍSpe鎿蠹\": -1.1564713893659811E-19\n                                                                                                                                                                                          }\n                                                                                                                                                                                         ]]\n                                                                                                                                                                                        ]\n                                                                                                                                                                                       ]\n                                                                                                                                                                                      ],\n                                                                                                                                                                                      \"羵䥳H,6ⱎ겾|@t\\\"#햊1|稃 섭)띜=뻔ꡜ???櫎~*ῡ꫌/繣ﻠq\": null\n                                                                                                                                                                                     }\n                                                                                                                                                                                    ]}\n                                                                                                                                                                                   ]},\n                                                                                                                                                                                   \"츤\": false\n                                                                                                                                                                                  }},\n                                                                                                                                                                                  \"s\": 3.7339341963399598E18\n                                                                                                                                                                                 }\n                                                                                                                                                                                ],\n                                                                                                                                                                                \"N,I?1+㢓|ࣱ嶃쩥V2\\u0012(4EE虪朶$|w颇v步\": \"~읢~_,Mzr㐫YB溓E淚\\\"ⅹ䈔ᏺ抙 b,nt5V㐒J檶ꏨ⻔?\",\n                                                                                                                                                                                \"Q껑ꡡ}$넎qH煔惍/ez^!ẳF댙䝌馻剁8\": \"梲;yt钰$i冄}AL%a j뜐奷걳뚾d꿽*ሬuDY3?뮟鼯뮟w㍪틱V\",\n                                                                                                                                                                                \"o{Q/K O胟㍏zUdꀐm&⨺J舕⾏魸訟㌥[T籨櫉唐킝 aṭ뱫촙莛>碶覆⧬짙쭰ׯdAiH໥벤퐥_恸[ 0e:죃TC弼荎뵁DA:w唵ꣁ\": null,\n                                                                                                                                                                                \"὏樎䵮軧|?౗aWH쩃1 ꅭsu\": null\n                                                                                                                                                                               }\n                                                                                                                                                                              ]\n                                                                                                                                                                             },\n                                                                                                                                                                             \"勂\\\\&m鰈J釮=Ⲽ鳋+䂡郑\": null,\n                                                                                                                                                                             \"殣b綊倶5㥗惢⳷萢ᑀ䬄镧M^ﱴ3⣢翣n櫻1㨵}ኯ뗙顖Z.Q➷ꮨ뗇\\u0004\": \"ꔙ䁼>n^[GीA䨟AM琢ᒊS쨲w?d㶣젊嘶纝麓+愣a%気ྞSc됓ᔘ:8bM7Xd8㶑臌]Ꙥ0ꐭ쒙䫣挵C薽Dfⵃ떼᷸\",\n                                                                                                                                                                             \"?紡.셪_෨j\\u0013Ox┠$Xᶨ-ᅇo薹-}軫;y毝㪜K㣁?.EV쮱4둽⛻䤜'2盡\\u001f60(|e쐰㼎ᦀ㒧-$l@ﻑ坳\\u0003䭱响巗WFo5c㧆T턁Y맸♤(\": -2.50917882560589088E17\n                                                                                                                                                                            }}\n                                                                                                                                                                           ],\n                                                                                                                                                                           \"侸\\\\릩.᳠뎠狣살cs项䭩畳H1s瀉븇19?.w骴崖㤊h痠볭㞳㞳䁮Ql怠㦵\": \"@䟴-=7f\",\n                                                                                                                                                                           \"鹟1x௢+d ;vi䭴FSDS\\u0004hꎹ㚍?⒍⦏ў6u,扩@됷Su)Pag휛TᒗV痩!瞏釀ꖞ蘥&ೞ蘐ꭰꞇᝎ\": \"ah懱Ժ&\\u20f7䵅♎඀䞧鿪굛ౕ湚粎蚵ᯋ幌YOE)५襦㊝Y*^\\\"R+ඈ咷蝶9ꥂ榨艦멎헦閝돶v좛咊E)K㓷ྭr\",\n                                                                                                                                                                           \"搆q쮦4綱켙셁.f4<\\/g<籽늷?#蚴픘:fF\\u00051㹉뀭.ᰖ풎f֦Hv蔎㧤.!䭽=鞽]음H:?\\\"-4\": 8.740133984938656E-20\n                                                                                                                                                                          }]}\n                                                                                                                                                                         }\n                                                                                                                                                                        ],\n                                                                                                                                                                        \"tVKn딩꘥⊾蹓᤹{\\u0003lR꼽ᄲQFᅏ傅ﱋ猢⤊ᔁ,E㓒秤nTතv`♛I\\u0000]꫔ṞD\\\"麵c踝杰X&濿또꣹깳౥葂鿎\\\\aꡨ?\": 3900062609292104525\n                                                                                                                                                                       }\n                                                                                                                                                                      ],\n                                                                                                                                                                      \"ਉ샒⊩Lu@S䧰^g\": -1.1487677090371648E18,\n                                                                                                                                                                      \"⎢k⑊꬗yᏫ7^err糎Dt\\u000bJ礯확ㆍ沑ｻꋽe赔㝢^J\\u0004笲㿋idra剰-᪉C錇/Ĝ䂾ညS지?~콮gR敉⬹'䧭\": 1901472137232418266,\n                                                                                                                                                                      \"灗k䶥:?촽贍쓉꓈㒸g獘[뵎\\\\胕?\\u0014_榙p.j稶,$`糉妋0>Fᡰly㘽$?\": \"]ꙛO赎&#㠃돱剳\\\"<◆>0誉齐_|z|裵씪>ᐌ㼍\\\"Z[琕}O?G뚇諦cs⠜撺5cu痑U圲\\u001c?鴴計l춥/╓哼䄗茏ꮅ뫈댽A돌롖뤫V窗讬sHd&\\nOi;_u\"\n                                                                                                                                                                     }\n                                                                                                                                                                    ],\n                                                                                                                                                                    \"Uﺗ\\\\Y\\\\梷䄬~\\u0002\": null,\n                                                                                                                                                                    \"k\\\"Y磓ᗔ휎@U冈<\\/w컑)[\": false,\n                                                                                                                                                                    \"曏J蝷⌻덦\\u001f㙳s꥓⍟邫P늮쥄c∬ྡྷ舆렮칤Z趣5콡넛A쳨\\\\뀙骫(棻.*&輛LiIfi{@EA婳KᬰTXT\": -4.3088230431977587E17\n                                                                                                                                                                   }]}\n                                                                                                                                                                  ]\n                                                                                                                                                                 ],\n                                                                                                                                                                 \"곃㲧<\\/dఓꂟs其ࡧ&N葶=?c㠤Ჴ'횠숄臼#\\u001a~\": false\n                                                                                                                                                                }\n                                                                                                                                                               ]\n                                                                                                                                                              ]}]\n                                                                                                                                                             }]\n                                                                                                                                                            }}\n                                                                                                                                                           ],\n                                                                                                                                                           \"2f`⽰E쵟>J笂裭!〛觬囀ۺ쟰#桊l鹛ⲋ|RA_Vx፭gE됓h﵀mfỐ|?juTU档[d⢼⺻p濚7E峿\": 5613688852456817133\n                                                                                                                                                          },\n                                                                                                                                                          \"濘끶g忮7㏵殬W팕Q曁 뫰)惃廊5%-蹚zYZ樭ﴷQ锘쯤崫gg\": true,\n                                                                                                                                                          \"絥ᇑ⦏쒓븣爚H.㗊߄o蘵貆ꂚ(쎔O᥉ﮓ]姨Wꁓ!RMA|o퉢THx轮7M껁U즨'i뾘舯o\": \"跥f꜃?\"\n                                                                                                                                                         }}\n                                                                                                                                                        ],\n                                                                                                                                                        \"鷰鹮K-9k;ﰰ?_ݦѷ-ꅣ䩨Zꥱ\\\"mꠟ屎/콑Y╘2&鸞脇㏢ꀇ࠺ⰼ拾喭틮L꽩bt俸墶 [l/웄\\\"꾦\\u20d3iও-&+\\u000fQ+໱뵞\": -1.296494662286671E-19\n                                                                                                                                                       },\n                                                                                                                                                       \"HX੹/⨇୕붷Uﮘ旧\\\\쾜͔3l鄈磣糂̖䟎Eᐳw橖b῀_딕hu葰窳闹вU颵|染H죶.fP䗮:j䫢\\\\b뎖i燕ꜚG⮠W-≚뉗l趕\": \"ଊ칭Oa᡺$IV㷧L\\u0019脴셀붿餲햪$迳向쐯켂PqfT\\\" ?I屉鴼쿕@硙z^鏕㊵M}㚛T젣쓌-W⩐-g%⺵<뮱~빅╴瑿浂脬\\u0005왦燲4Ⴭb|D堧 <\\/oEQh\",\n                                                                                                                                                       \"䘶#㥘੐캔f巋ἡAJ䢚쭈ࣨ뫒*mᇊK，ࣺAꑱ\\u000bR<\\/A\\\"1a6鵌㯀bh곿w(\\\"$ꘁ*rಐ趣.d࿩k/抶면䒎9W⊃9\": \"漩b挋Sw藎\\u0000\",\n                                                                                                                                                       \"畀e㨼mK꙼HglKb,\\\"'䤜\": null\n                                                                                                                                                      }]}]\n                                                                                                                                                     ]\n                                                                                                                                                    ]\n                                                                                                                                                   }]\n                                                                                                                                                  ]}\n                                                                                                                                                 ]\n                                                                                                                                                ]}\n                                                                                                                                               ],\n                                                                                                                                               \"歙>駿ꣂ숰Q`J΋方樛(d鱾뼣(뫖턭\\u20f9lচ9歌8o]8윶l얶?镖G摄탗6폋폵+g:䱫홊<멀뀿/س|ꭺs걐跶稚W々c㫣⎖\": \"㣮蔊깚Cꓔ舊|XRf遻㆚︆'쾉췝\\\\&言\",\n                                                                                                                                               \"殭\\\"cށɨꝙ䞘:嬮e潽Y펪㳅/\\\"O@ࠗ겴]췖YǞ(t>R\\\"N?梳LD恭=n氯T豰2R諸#N}*灧4}㶊G䍣b얚\": null,\n                                                                                                                                               \"襞<\\/啧 B|싞W瓇)6簭鼡艆lN쩝`|펭佡\\\\間邝[z릶&쭟愱ꅅ\\\\T᰽1鯯偐栈4̸s윜R7⒝/똽?치X\": \"⏊躖Cﱰ2Qẫ脐&இ?%냝悊\",\n                                                                                                                                               \",鰧偵셣싹xᎹ힨᯳EṬH㹖9\": -4604276727380542356\n                                                                                                                                              }\n                                                                                                                                             }\n                                                                                                                                            ]]]],\n                                                                                                                                            \"웺㚑xs}q䭵䪠馯8?LB犯zK'os䚛HZ\\\"L?셎s^㿧㴘Cv2\": null\n                                                                                                                                           }]\n                                                                                                                                          ]\n                                                                                                                                         ]\n                                                                                                                                        ],\n                                                                                                                                        \"Kd2Kv+|z\": 7367845130646124107,\n                                                                                                                                        \"ᦂⶨ?ᝢ 祂些ഷ牢㋇操\\\"腭䙾㖪\\\\(y4cE뽺ㆷ쫺ᔖ%zfۻ$ў1柦,㶢9r漢\": -3.133230960444846E-20,\n                                                                                                                                        \"琘M焀q%㢟f鸯O⣏蓑맕鯊$O噷|)z褫^㢦⠮ꚯ꫞`毕1qꢚ{ĭ䎀বώT\\\"뱘3G൴?^^of\": null\n                                                                                                                                       }\n                                                                                                                                      ],\n                                                                                                                                      \"a8V᯺?:ﺃ/8ꉿBq|9啓댚;*i2\": null,\n                                                                                                                                      \"cpT瀇H珰Ừpೃi鎪Rr␣숬-鹸ҩ䠚z脚цGoN8入y%趌I┽2ឪЀiJNcN)槣/▟6S숆牟\\\"箑X僛G殱娇葱T%杻:J諹昰qV쨰\": 8331037591040855245\n                                                                                                                                     }],\n                                                                                                                                     \"G5ᩜ䄗巢껳\": true\n                                                                                                                                    }\n                                                                                                                                   },\n                                                                                                                                   \"Ồ巢ゕ@_譙A`碫鄐㡥砄㠓(^K\": \"?܃B혢▦@犑ὺD~T⧁|醁;o=J牌9냚⢽㨘{4觍蚔9#$∺\\u0016p囅\\\\3Xk阖⪚\\\"UzA穕롬✎➁㭒춺C㣌ဉ\\\"2瓑员ᅽꝶ뫍}꽚ꞇ鶂舟彺]ꍽJC蝧銉\",\n                                                                                                                                   \"␆Ě膝\\\"b-퉐ACR言J謈53~V튥x䜢?ꃽɄY뮩ꚜ\": \"K/↾e萃}]Bs⾿q룅鷦-膋?m+死^魊镲6\",\n                                                                                                                                   \"粡霦c枋AHퟁo礼Ke?qWcA趸㡔ꂏ?\\u000e춂8iতᦜ婪\\u0015㢼nﵿꍻ!ᐴ関\\u001d5j㨻gfῩUK5Ju丝tかTI'?㓏t>⼟o a>i}ᰗ;뤕ܝ\": false,\n                                                                                                                                   \"ꄮ匴껢ꂰ涽+䜨B蛹H䛓-k蕞fu7kL谖,'涃V~챳逋穞cT\\\"vQ쓕ObaCRQ㓡Ⲯ?轭⫦輢墳?vA餽=h䮇킵n폲퉅喙?\\\"'1疬V嬗Qd灗'Lự\": \"6v!s믁㭟㣯獃!磸餠ቂh0C뿯봗F鷭gꖶ~ｺkK<ᦈTt\\\\跓w㭣횋钘ᆹ듡䑚W䟾X'ꅔ4FL勉Vܴ邨y)2'〚쭉⽵-鞣E,Q.?块\",\n                                                                                                                                   \"?(˧쩯@崟吋歄K\": null\n                                                                                                                                  },\n                                                                                                                                  \"Gc럃녧>?2DYI鴿\\\\륨)澔0ᔬlx'觔7젘⤡縷螩%Sv׫묈/]↱&S h\\u0006歋ᑛxi̘}ひY蔯_醨鯘煑橾8?䵎쨋z儬ꁏ*@츾:\": null\n                                                                                                                                 }\n                                                                                                                                }\n                                                                                                                               }\n                                                                                                                              ]\n                                                                                                                             ]\n                                                                                                                            ]}\n                                                                                                                           },\n                                                                                                                           \"HO츧G\": 3.694949578823609E17,\n                                                                                                                           \"QC\\u0012(翻曇Tf㷟bGBJ옉53\\\\嚇ᛎD/\\u001b夾၉4\\\"핀@祎)쫆yD\\\"i먎Vn㿿V1W᨝䶀\": -6150931500380982286,\n                                                                                                                           \"Z㓮P翸鍱鉼K䋞꘺튿⭁Y\": -7704503411315138850,\n                                                                                                                           \"]모开ꬖP븣c霤<[3aΠ\\\"黁䖖䰑뮋ꤦ秽∼㑷冹T+YUt\\\"싳F↭䖏&鋌\": -2.7231911483181824E18,\n                                                                                                                           \"tꎖ\": -4.9517948741799555E-19,\n                                                                                                                           \"䋘즊.⬅IꬃۣQ챢ꄑ黐|f?C⾺|兕읯sC鬸섾整腨솷V\": \"旆柩l<K髝M戶鯮t:wR2ꉱ`9'l픪*폍芦㊢Pjjo堡^  읇얛嶅있ষ0?F\",\n                                                                                                                           \"下9T挞\\\\$yᮇk쌋⼇,ਉ\": true,\n                                                                                                                           \"櫨:ㆣ,邍lr崕祜㐮烜Z,XXD蕼㉴ kM꯽?P0﹉릗\": null,\n                                                                                                                           \"gv솠歽閘4镳䗄2澾>쪦sᖸMy㦅울썉瘗㎜檵9ꍂ駓ૉᚿ/u3씅徐拉[Z䞸ࡗ1ꆱ&Ｑ풘?ǂ8\\u0011BCDY2볨;鸏\": null,\n                                                                                                                           \"幫 n煥s쁇펇 왊-$C\\\"衝:\\u0014㣯舼.3뙗Yl⋇\\\"K迎멎[꽵s}9鉳UK8쐥\\\"掄㹖h㙈!얄સ?Ꜳ봺R伕UTD媚Ｉ䜘W鏨蔮\": -4.150842714188901E-17,\n                                                                                                                           \"ﺯ^㄄\\b죵@fྉkf颡팋Ꞧ{/Pm0V둳⻿/落韒ꊔᚬ@5螺G\\\\咸a谆⊪ቧ慷绖?财(鷇u錝F=r၍橢ឳn:^iᴵtD볠覅N赴\": null\n                                                                                                                          }]\n                                                                                                                         }]\n                                                                                                                        }\n                                                                                                                       ]\n                                                                                                                      ]}\n                                                                                                                     ]},\n                                                                                                                     \"謯?w厓奰T李헗聝ឍ貖o⪇弒L!캶$ᆅ\": -4299324168507841322,\n                                                                                                                     \"뺊奉_垐浸延몏孄Z舰2i$q붿좾껇d▵餏\\\"v暜Ҭ섁m￴g>\": -1.60911932510533427E18\n                                                                                                                    }\n                                                                                                                   ]\n                                                                                                                  }\n                                                                                                                 ]\n                                                                                                                ]],\n                                                                                                                \"퉝꺔㠦楶Pꅱ\": 7517896876489142899,\n                                                                                                                \"\": false\n                                                                                                               }\n                                                                                                              ]},\n                                                                                                              \"是u&I狻餼|谖j\\\"7c됮sסּ-踳鉷`䣷쉄_A艣鳞凃*m⯾☦椿q㎭N溔铉tlㆈ^\": 1.93547720203604352E18,\n                                                                                                              \"kⲨ\\\\%vr#\\u000bⒺY\\\\t<\\/3﬌R訤='﹠8蝤Ꞵ렴曔r\": false\n                                                                                                             }\n                                                                                                            ]},\n                                                                                                            \"阨{c?C\\u001d~K?鎌Ԭ8烫#뙣P초遗t㭱E­돒䆺}甗[R*1!\\\\~h㕅᰺@<9JꏏષI䳖栭6綘걹ￌM\\\"▯是∔v鬽顭⋊譬\": \"운ﶁK敂(欖C취پ℄爦賾\"\n                                                                                                           }\n                                                                                                          }}\n                                                                                                         }],\n                                                                                                         \"鷨赼鸙+\\\\䭣t圙ڹx᜾ČN<\\/踘\\\"S_맶a鷺漇T彚⎲i㈥LT-xA캔$\\u001cUH=a0츺l릦\": \"溣㣂0濕=鉵氬駘>Pꌢpb솇쬤h힊줎獪㪬CrQ矠a&脍꼬爼M茴/΅\\u0017弝轼y#Ꞡc6둴=?R崏뷠麖w?\"\n                                                                                                        },\n                                                                                                        \"閕ᘜ]CT)䵞l9z'xZF{:ؐI/躅匽졁:䟇AGF૸\\u001cퟗ9)駬慟ꡒꆒRS״툋A<>\\u0010\\\"ꂔ炃7g덚E৏bꅰ輤]o㱏_뷕ܘ暂\\\"u\": \"芢+U^+㢩^鱆8*1鈶鮀\\u0002뺰9⬳ꪮlL䃣괟,G8\\u20a8DF㉪錖0ㄤ瓶8Nଷd?眡GLc陓\\\\_죌V쁰ल二?c띦捱 \\u0019JC\\u0011b⤉zẒT볕\\\"绣蘨뚋cꡉkI\\u001e鳴\",\n                                                                                                        \"ꃣI'{6u^㡃#཰Kq4逹y൒䧠䵮!㱙/n??{L풓ZET㙠퍿X2᩟綳跠葿㚙w཮x캽扳B唕S|尾}촕%N?o䪨\": null,\n                                                                                                        \"ⰴFjෟ셈[\\u0018辷px?椯\\\\1<ﲻ栘ᣁ봢憠뉴p\": -5263694954586507640\n                                                                                                       }\n                                                                                                      ]\n                                                                                                     ]]\n                                                                                                    ]}\n                                                                                                   ]}]\n                                                                                                  ]\n                                                                                                 ],\n                                                                                                 \"?#癘82禩鋆ꊝty?&\": -1.9419029518535086E-19\n                                                                                                }\n                                                                                               ]\n                                                                                              ]\n                                                                                             ]}\n                                                                                            ]\n                                                                                           ]\n                                                                                          ],\n                                                                                          \"훊榲.|῕戄&.㚏Zꛦ2\\\"䢥ሆ⤢fV_摕婔?≍Fji冀탆꜕i㏬_ẑKᅢ꫄蔻XWc|饡Siẘ^㲦?羡2ぴ1縁ᙅ?쐉Ou\": false\n                                                                                         }]]\n                                                                                        ]}}},\n                                                                                        \"慂뗄卓蓔ᐓ匐嚖/颹蘯/翻ㆼL?뇊,텵<\\\\獷ごCボ\": null\n                                                                                       },\n                                                                                       \"p溉ᑟi짣z:䒤棇r^٫%G9缑r砌롧.물农g?0׼ሩ4ƸO㣥㯄쩞ጩ\": null,\n                                                                                       \"껎繥YxK\\\"F젷쨹뤤1wq轫o?鱑뜀瘊?뎃h灑\\\\ꛣ}K峐^ኖ⤐林ꉓhy\": null\n                                                                                      }\n                                                                                     ],\n                                                                                     \"᱀n肓ㄛ\\\"堻2>m殮'1橌%Ꞵ군=Ӳ鯨9耛<\\/n據0u彘8㬇៩f᏿诙]嚊\": \"䋯쪦S럶匏ㅛ#)O`ሀX_鐪渲⛀㨻宅闩➈ꢙஶDR⪍\"\n                                                                                    },\n                                                                                    \"tA썓龇 ⋥bj왎录r땽✒롰;羋^\\\\?툳*┎?썀ma䵳넅U䳆૘〹䆀LQ0\\b疀U~u$M}(鵸g⳾i抦뛹?䤈땚검.鹆?ꩡtⶥGĒ;!ቹHS峻B츪켏f5≺\": 2366175040075384032,\n                                                                                    \"전pJjleb]ួ\": -7.5418493141528422E18,\n                                                                                    \"n.鎖ጲ\\n?,$䪘\": true\n                                                                                   },\n                                                                                   \"欈Ar㉣螵᪚茩?O)\": null\n                                                                                  },\n                                                                                  \"쫸M#x}D秱欐K=侫们丐.KꕾxẠ\\u001e㿯䣛F܍캗qq8꟞ṢFD훎⵳簕꭛^鳜\\u205c٫~⑟~冫ऊ2쫰<\\/戲윱o<\\\"\": true\n                                                                                 },\n                                                                                 \"㷝聥/T뱂\\u0010锕|内䞇x侁≦㭖:M?iM᣿IJe煜dG࣯尃⚩gPt*辂.{磼럾䝪@a\\\\袛?}ᓺB珼\": true\n                                                                                }\n                                                                               }\n                                                                              ]]}]}},\n                                                                              \"tn\\\"6ꫤ샾䄄;銞^%VBPwu묪`Y僑N.↺Ws?3C⤻9唩S䠮ᐴm;sᇷ냞඘B/;툥B?lB∤)G+O9m裢0kC햪䪤\": -4.5941249382502277E18,\n                                                                              \"ᚔt'\\\\愫?鵀@\\\\びꂕP큠<<]煹G-b!S?\\nꖽ鼫,ݛ&頺y踦?E揆릱H}햧캡b@手.p탻>췽㣬ꒅ`qe佭P>ᓂ&?u}毚ᜉ蟶頳졪ᎏzl2wO\": -2.53561440423275936E17\n                                                                             }]}\n                                                                            }\n                                                                           ]\n                                                                          ]],\n                                                                          \"潈촒⿂叡\": 5495738871964062986\n                                                                         }\n                                                                        ]]\n                                                                       }\n                                                                      ]\n                                                                     ]}\n                                                                    ]]\n                                                                   ]]\n                                                                  ]}\n                                                                 ]\n                                                                ]},\n                                                                \"ႁq킍蓅R`謈蟐ᦏ儂槐僻ﹶ9婌櫞釈~\\\"%匹躾ɢ뤥>࢟瀴愅?殕节/냔O✬H鲽엢?ᮈੁ⋧d␽㫐zCe*\": 2.15062231586689536E17,\n                                                                \"㶵Ui曚珰鋪ᾼ臧P{䍏䷪쨑̟A뼿T渠誈䏚D1!잶<\\/㡍7?)2l≣穷᛾稝{:;㡹nemיּ訊`G\": null,\n                                                                \"䀕\\\"飕辭p圁f#뫆䶷뛮;⛴ᩍ3灚덏ᰝ쎓⦷詵%᜖Մfs⇫(\\u001e~P|ﭗCⲾផv湟W첋(텪બT<บSꏉ੗⋲X婵i ӵ⇮?L䬇|ꈏ?졸\": 1.548341247351782E-19\n                                                               }\n                                                              ]\n                                                             },\n                                                             \"t;:N\\u0015q鐦Rt缆{ꮐC?஛㷱敪\\\\+鲊㉫㓪몗릙竏(氵kYS\": \"XᰂT?൮ô\",\n                                                             \"碕飦幑|+ 㚦鏶`镥ꁩ B<\\/加륙\": -4314053432419755959,\n                                                             \"秌孳(p!G?V傫%8ሽ8w;5鲗㦙LI檸\\u2098\": \"zG N볞䆭鎍흘\\\\ONK3횙<\\/樚立圌Q튅k쩎Ff쁋aׂJK銆ઘ즐狩6༥✙䩜篥CzP(聻駇HHퟲ讃%,ά{렍p而刲vy䦅ክ^톺M楒鍢㹳]Mdg2>䤉洞\",\n                                                             \"踛M젧>忔芿㌜Zk\": 2215369545966507819,\n                                                             \"씐A`$槭頰퍻^U覒\\bG毲aᣴU;8!팲f꜇E⸃_卵{嫏羃X쀳C7뗮m(嚼u N܁谟D劯9]#\": true,\n                                                             \"ﻩ!뵸-筚P᭛}ἰ履lPh?౮ⶹꆛ穉뎃g萑㑓溢CX뾇G㖬A錟]RKaꄘ]Yo+@䘁's섎襠$^홰}F\": null\n                                                            },\n                                                            \"粘ꪒ4HXᕘ蹵.$區\\r\\u001d묁77pPc^y笲Q<\\/ꖶ 訍䃍ᨕG?*\": 1.73773035935040224E17\n                                                           },\n                                                           \"婅拳?bkU;#D矠❴vVN쩆t㜷A풃갮娪a%鮏絪3dAv룒#tm쑬⌛qYwc4|L8KZ;xU⓭㳔밆拓EZ7襨eD|隰ऌ䧼u9Ԣ+]贴P荿\": 2.9628516456987075E18\n                                                          }]}}]\n                                                         ]}\n                                                        }}\n                                                       ]}]\n                                                      ],\n                                                      \"|g翉F*湹̶\\u0005⏐1脉̀eI쩓ᖂ㫱0碞l䴨ꑅ㵽7AtἈ턧yq䳥塑:z:遀ﾼX눔擉)`N3昛oQ셖y-ڨ⾶恢ꈵq^<\\/\": null,\n                                                      \"菹\\\\랓G^璬x৴뭸ゆUS겧﮷Bꮤ ┉銜᯻0%N7}~f洋坄Xꔼ<\\/4妟Vꄟ9:౟곡t킅冩䧉笭裟炂4봋ⱳ叺怊t+怯涗\\\"0㖈Hq\": false,\n                                                      \"졬믟'ﺇফ圪쓬멤m邸QLব䗁愍4jvs翙 ྍ꧀艳H-|\": null,\n                                                      \"컮襱⣱뗠 R毪/鹙꾀%헳8&\": -5770986448525107020\n                                                     }\n                                                    ],\n                                                    \"B䔚bꐻ뙏姓展槰T-똌鷺tc灿᫽^㓟䏀o3o$꘭趙萬I顩)뇭Ἑ䓝\\f@{ᣨ`x3蔛\": null\n                                                   }\n                                                  ]\n                                                 ]\n                                                }],\n                                                \"⦖扚vWꃱ꥙㾠壢輓{-⎳鹷贏璿䜑bG倛⋐磎c皇皩7a~ﳫU╣Q࠭ꎉS摅姽OW.홌ೞ.\": null,\n                                                \"蚪eVlH献r}ᮏ믠ﰩꔄ@瑄ⲱ\": null,\n                                                \"퀭$JWoꩢg역쁍䖔㑺h&ୢtXX愰㱇?㾫I_6 OaB瑈q裿\": null,\n                                                \"꽦ﲼLyr纛Zdu珍B絟쬴糔?㕂짹䏵e\": \"ḱ\\u2009cX9멀i䶛簆㳀k\"\n                                               }\n                                              ]]]],\n                                              \"(_ꏮg່澮?ᩑyM<艷\\u001aꪽ\\\\庼뙭Z맷㰩Vm\\\\lY筺]3㋲2㌩㄀Eਟ䝵⨄쐨ᔟgङHn鐖⤇놋瓇Q탚單oY\\\"♆臾jHᶈ征ቄ??uㇰA?#1侓\": null\n                                             },\n                                             \"觓^~ሢ&iI띆g륎ḱ캀.ᓡꀮ胙鈉\": 1.0664523593012836E-19,\n                                             \"y詭Gbᔶऽs댁U:杜⤎ϲ쁗⮼D醄诿q뙰I#즧v蔎xHᵿt᡽[**?崮耖p缫쿃L菝,봬ꤦC쯵#=X1瞻@OZc鱗CQTx\": null\n                                            }\n                                           ]\n                                          }}],\n                                          \"剘紁\\u0004\\\\Xn⊠6,တױ;嵣崇}讃iႽ)d1\\\\䔓\": null\n                                         },\n                                         \"脨z\\\"{X,1u찜<'k&@?1}Yn$\\u0015Rd輲ｰa쮂굄+B$l\": true,\n                                         \"諳>*쭮괐䵟Ґ+<箁}빀䅱⡔檏臒hIH脟ꩪC핝ଗP좕\\\"0i<\\/C褻D۞恗+^5?'ꂱ䚫^7}㡠cq6\\\\쨪ꔞꥢ?纖䫀氮蒫侲빦敶q{A煲G\": -6880961710038544266\n                                        }}]\n                                       },\n                                       \"5s⨲JvಽῶꭂᄢI.a৊\": null,\n                                       \"?1q꽏쿻ꛋDR%U娝>DgN乭G\": -1.2105047302732358E-19\n                                      }\n                                     ]\n                                    ]},\n                                    \"qZz`撋뙹둣j碇쁏\\\\ꆥ\\u0018@藴疰Wz)O{F䶛l᷂绘訥$]뮍夻䢋䩇萿獰樧猵⣭j萶q)$꬚⵷0馢W:Ⱍ!Qoe\": -1666634370862219540,\n                                    \"t\": \"=wp|~碎Q鬳Ӎ\\\\l-<\\/^ﳊhn퐖}䍔t碵ḛ혷?靻䊗\",\n                                    \"邙쇡㯇%#=,E4勃驆V繚q[Y댻XV㡸[逹ᰏ葢B@u=JS5?bLRn얮㍉⏅ﰳ?a6[&큟!藈\": 1.2722786745736667E-19\n                                   },\n                                   \"X블땨4{ph鵋ꉯ웸 5p簂䦭s_E徔濧d稝~No穔噕뽲)뉈c5M윅>⚋[岦䲟懷恁?鎐꓆ฬ爋獠䜔s{\\u001bm鐚儸煛%bﯿXT>ꗘ@8G\": 1157841540507770724,\n                                   \"媤娪Q杸\\u0011SAyᡈ쿯\": true,\n                                   \"灚^ಸ%걁<\\/蛯<O\\\"-刷㏠R(kO=䢊䅎l䰓팪A絫픧\": \"譔\\\\㚄 ?R7㔪G㋉⣰渆?\\\\#|gN⤴;W칷A׫癮଼ೣ㏳뒜7d恓꾲0扬S0ᆵi/贎ྡn䆋武\",\n                                   \"萇砇Gこ朦켋Wq`㞲攊*冁~霓L剢zI腧튴T繙Cঅ뫬╈뮜ㄾ䦧촄椘B⊬츩r2f㶱厊8eϬ{挚␯OM焄覤\\\\(Kӡ>?\\\"祴坓\\\\\\\\'흍\": -3.4614808555942579E18,\n                                   \"釴U:O湛㴑䀣렑縓\\ta)<D8ﭳ槁髭D.L|xs斋敠\\\"띋早7wᎍ\": true,\n                                   \"쵈+쬎簨up䓬?q+~\\u0019仇뵈᫯3ᵣ恘枰劫㪢u珘-퀭:컙:u`⌿A(9鄦!<珚nj3:Hࣨ巋䀁旸뎈맻v\\\"\\\\(곘vO㤰aZe<\\/W鹙鄜;l厮둝\": null,\n                                   \"\": -1.2019926774977002E-18,\n                                   \"%者O7.Nꪍs梇接z蕜綛<\\/䜭\\\"죊y<曋漵@Ś⹝sD⟓jݗᢜ?z/9ၲMa쨮긗贎8ᔮ㦛;6p뾥໭䭊0B찛+)(Y㿠鸁䕒^옥\": \"鬃뫤&痽舎J콮藐󽸰ᨨMꈫ髿v<N\\\\.삒껅я1ꭼ5䴷5쳬臨wj덥\"\n                                  }],\n                                  \"鷎'㳗@帚妇OAj' 谬f94ǯ(횡ﾋ%io쪖삐좛>(j:숾却䗌gCiB뽬Oyuq輥厁/7)?今hY︺Q\": null\n                                 }\n                                ]\n                               ]]]}]\n                              ],\n                              \"I笔趠Ph!<ཛྷ㸞诘X$畉F\\u0005笷菟.Esr릙!W☆䲖뗷莾뒭U\\\"䀸犜Uo3Gꯌx4r蔇᡹㧪쨢準<䂀%ࡡꟼ瑍8炝Xs0䀝销?fi쥱ꆝલBB\": -8571484181158525797,\n                              \"L⦁o#J|\\\"⽩-㱢d㌛8d\\\\㶤傩儻E[Y熯)r噤὘勇 }\": \"e(濨쓌K䧚僒㘍蠤Vᛸ\\\"络QJL2,嬓왍伢㋒䴿考澰@(㏾`kX$끑эE斡,蜍&~y\",\n                              \"vj.|统圪ᵮPL?2oŶ`밧\\\"勃+0ue%⿥绬췈체$6:qa렐Q;~晘3㙘鹑\": true,\n                              \"ශؙ4獄⶿c︋i⚅:ん閝Ⳙ苆籦kw{䙞셕pC췃ꍬ␜꟯ꚓ酄b힝hwk꭭M鬋8B耳쑘WQ\\\\偙ac'唀x᪌\\u2048*h짎#ፇ鮠뾏ឿ뀌\": false,\n                              \"⎀jꄒ牺3Ⓝ컴~?親ꕽぼܓ喏瘘!@<튋㐌꿱⩦{a?Yv%⪧笯Uܱ栅E搚i뚬:ꄃx7䙳ꦋ&䓹vq☶I䁘ᾘ涜\\\\썉뺌Lr%Bc㍜3?ꝭ砿裞]\": null,\n                              \"⭤뙓z(㡂%亳K䌽꫿AԾ岺㦦㼴輞낚Vꦴw냟鬓㹈뽈+o3譻K1잞\": 2091209026076965894,\n                              \"ㇲ\\t⋇轑ꠤ룫X긒\\\"zoY읇희wj梐쐑l侸`e%s\": -9.9240075473576563E17,\n                              \"啸ꮑ㉰!ᚓ}銏\": -4.0694813896301194E18,\n                              \">]囋੽EK뇜>_ꀣ緳碖{쐐裔[<ನ\\\"䇅\\\"5L?#xTwv#罐\\u0005래t应\\\\N?빗;\": \"v쮽瞭p뭃\"\n                             }\n                            ]],\n                            \"斴槾?Z翁\\\"~慍弞ﻆ=꜡o5鐋dw\\\"?K蠡i샾ogDﲰ_C*⬟iㇷ4nય蟏[㟉U꽌娛苸 ঢ়操贻洞펻)쿗૊許X⨪VY츚Z䍾㶭~튃ᵦ<\\/E臭tve猑x嚢\": null,\n                            \"锡⛩<\\/칥ꈙᬙ蝀&Ꚑ籬■865?_>L詏쿨䈌浿弥爫̫lj&zx<\\/C쉾?覯n?\": null,\n                            \"꾳鑤/꼩d=ᘈn挫ᑩ䰬ZC\": \"3錢爋6Ƹ䴗v⪿Wr益G韠[\\u0010屗9쁡钁u?殢c䳀蓃樄욂NAq赟c튒瘁렶Aૡɚ捍\"\n                           }\n                          ]\n                         ]\n                        ]}\n                       ]\n                      ]\n                     }]]]}}\n                    ]}],\n                    \"Ej䗳U<\\/Q=灒샎䞦,堰頠@褙g_\\u0003ꤾfⶽ?퇋!łB〙ד3CC䌴鈌U:뭔咎(Qો臃䡬荋BO7㢝䟸\\\"Yb\": 2.36010731779814E-20,\n                    \"逸'0岔j\\u000e눘먷翌C츊秦=ꭣ棭ှ;鳸=麱$XP⩉駚橄A\\\\좱⛌jqv䰞3Ь踌v㳆¹gT┌gvLB賖烡m?@E঳i\": null\n                   },\n                   \"曺v찘ׁ?&绫O័\": 9107241066550187880\n                  }\n                 ]\n                ],\n                \"(e屄\\u0019昜훕琖b蓘ᬄ0/۲묇Z蘮ဏ⨏蛘胯뢃@㘉8ሪWᨮ⦬ᅳ䅴HI၇쨳z囕陻엣1赳o\": true,\n                \",b刈Z,ၠ晐T솝ŕB⩆ou'퐼≃绗雗d譊\": null,\n                \"a唥KB\\\"ﳝ肕$u\\n^⅄P䟼냉䞸⩪u윗瀱ꔨ#yşs꒬=1|ﲤ爢`t౐튼쳫_Az(Ṋ擬㦷좕耈6\": 2099309172767331582,\n                \"?㴸U<\\/䢔ꯡ阽扆㐤q鐋?f㔫wM嬙-;UV죫嚔픞G&\\\"Cᗍ䪏풊Q\": \"VM7疹+陕枡툩窲}翡䖶8欞čsT뮐}璤:jﺋ鎴}HfA൝⧻Zd#Qu茅J髒皣Y-︴[?-~쉜v딏璮㹚䅊﩯<-#\\u000e걀h\\u0004u抱﵊㼃U<㱷⊱IC進\"\n               },\n               \"숌dee節鏽邺p넱蹓+e罕U\": true\n              }\n             ],\n             \"b⧴룏??ᔠ3ぱ>%郿劃翐ꏬꠛW瞳᫏누躨狀ໄy੽\\\"ីuS=㨞馸k乆E\": \"トz݈^9R䬑<ﮛG<s~<\\/?ⵆᏥ老熷u듷\"\n            }}\n           ]\n          }\n         ]}\n        }\n       }\n      }\n     }},\n     \"宩j鬅쳜QꝖјy獔Z᭵1v擖}䨿F%cֲ᫺贴m塼딚NP亪\\\"ￋsa뺯ꘓ2:9뛓༂쌅䊈#>Rꨳ\\u000fTT泠纷꽀MR<CBxP񱒫X쇤\": -2.22390568492330598E18,\n     \"?䯣ᄽ@Z鸅->ᴱ纊:㠭볮?%N56%鈕1䗍䜁a䲗j陇=뿻偂衋࿘ᓸ?ᕵZ+<\\/}H耢b䀁z^f$&㝒LkꢳI脚뙛u\": 5.694374481577558E-20\n    }]\n   }\n  ]],\n  \"obj\": {\"key\": \"wrong value\"},\n  \"퓲꽪m{㶩/뇿#⼢&᭙硞㪔E嚉c樱㬇1a綑᝖DḾ䝩\": null\n },\n \"key\": \"6.908319653520691E8\",\n \"z\": {\n  \"6U閆崬밺뀫颒myj츥휘:$薈mY햚#rz飏+玭V㭢뾿愴YꖚX亥ᮉ푊\\u0006垡㐭룝\\\"厓ᔧḅ^Sqpv媫\\\"⤽걒\\\"˽Ἆ?ꇆ䬔未tv{DV鯀Tἆl凸g\\\\㈭ĭ즿UH㽤\": null,\n  \"b茤z\\\\.N\": [[\n   \"ZL:ￄዎ*Y|猫劁櫕荾Oj为1糕쪥泏S룂w࡛Ᏺ⸥蚙)\",\n   {\n    \"\\\"䬰ỐwD捾V`邀⠕VD㺝sH6[칑.:醥葹*뻵倻aD\\\"\": true,\n    \"e浱up蔽Cr෠JK軵xCʨ<뜡癙Y獩ｹ齈X/螗唻?<蘡+뷄㩤쳖3偑犾&\\\\첊xz坍崦ݻ鍴\\\"嵥B3㰃詤豺嚼aqJ⑆∥韼@\\u000b㢊\\u0015L臯.샥\": false,\n    \"l?Ǩ喳e6㔡$M꼄I,(3᝝縢,䊀疅뉲B㴔傳䂴\\u0088㮰钘ꜵ!ᅛ韽>\": -5514085325291784739,\n    \"o㮚?\\\"춛㵉<\\/﬊ࠃ䃪䝣wp6ἀ䱄[s*S嬈貒pᛥ㰉'돀\": [{\n     \"(QP윤懊FI<ꃣ『䕷[\\\"珒嶮?%Ḭ壍಻䇟0荤!藲끹bd浶tl\\u2049#쯀@僞\": {\"i妾8홫\": {\n      \",M맃䞛K5nAㆴVN㒊햬$n꩑&ꎝ椞阫?/ṏ세뉪1x쥼㻤㪙`\\\"$쟒薟B煌܀쨝ଢ଼2掳7㙟鴙X婢\\u0002\": \"Vዉ菈᧷⦌kﮞఈnz*<?੃'ahhCFX(\\u0007⮊E㭍䱾Gxꥩr❣.洎\",\n      \"뻴5bDD큯O傆盓왻U?ꞅꐊN鐭᧢τ\\\"迳豲8\\u001b䃥ꂻ䴺ྸH筴,\": {\n       \"\\\"L鸔SE㬡XV&~͎'놅蔞눶l匛?'.K氁\\\\ƢẨ疇mΊ'꽳&!鹠m'|{P痊 秄쒿u\\u00111䋧gϩx7t丗D䊨䠻z0.A0\": -1.50139930144708198E18,\n       \"8鋂뛷?첒B☚>﷜FM\\\"荭7ꍀ-VR<\\/';䁙E9$䩉\\f @s?퍪o3^衴cඎ䧪aK鼟ｑ䆨c{䳠5mᒲՙ蘹ᮩ\": {\n        \"F㲷JGo⯍P덵x뒳p䘧☔\\\"+ꨲ吿JfR㔹)4n紬G练Q፞!C|\": true,\n        \"p^㫮솎oc.೚A㤠??r\\u000f)⾽⌲們M2.䴘䩳:⫭胃\\\\፾@Fᭌ\\\\K\": false,\n        \"蟌Tk愙潦伩\": {\n         \"a<\\/@ᾛ慂侇瘎\": -7271305752851720826,\n         \"艓藬/>၄ṯ,XW~㲆w\": {\"E痧郶)㜓ha朗!N赻瞉駠uC\\u20ad辠<Ve?폱!Im䁎搄:*s 9諚Prᵾ뒰髶B̌qWA8梸vS⫊⢳{t㺲q㺈랊뮣RqK밢쳪\": [\n          false,\n          {\n           \"\\u000b=>x퓮⣫P1ࠫLMMX'M刼唳됤\": null,\n           \"P쓫晥%k覛ዩIUᇸ滨:噐혲lMR5䋈V梗>%幽u頖\\\\)쟟\": null,\n           \"eg+昉~矠䧞难\\b?gQ쭷筝\\\\eꮠNl{ಢ哭|]Mn銌╥zꖘzⱷ⭤ᮜ^\": [\n            -1.30142114406914976E17,\n            -1.7555215491128452E-19,\n            null,\n            \"渾㨝ߏ牄귛r?돌?w[⚞ӻ~廩輫㼧/\",\n            -4.5737191805302129E18,\n            null,\n            \"xy࿑M[oc셒竓Ⓔx?뜓y䊦>-D켍(&&?XKkc꩖ﺸᏋ뵞K伕6ী)딀P朁yW揙?훻魢傎EG碸9類៌g踲C⟌aEX舲:z꒸许\",\n            3808159498143417627,\n            null,\n            {\"m試\\u20df1{G8&뚈h홯J<\\/\": {\n             \"3ஸ厠zs#1K7:rᥞoꅔꯧ&띇鵼鞫6跜#赿5l'8{7㕳(b/j\\\"厢aq籀ꏚ\\u0015厼稥\": [\n              -2226135764510113982,\n              true,\n              null,\n              {\n               \"h%'맞S싅Hs&dl슾W0j鿏MםD놯L~S-㇡R쭬%\": null,\n               \"⟓咔謡칲\\u0000孺ꛭx旑檉㶆?\": null,\n               \"恇I転;￸B2Y`z\\\\獓w,놏濐撐埵䂄)!䶢D=ഭ㴟jyY\": {\n                \"$ࡘt厛毣ൢI芁<겿骫⫦6tr惺a\": [\n                 6.385779736989334E-20,\n                 false,\n                 true,\n                 true,\n                 [\n                  -6.891946211462334E-19,\n                  null,\n                  {\n                   \"]-\\\\Ꟑ1/薓❧Ὂ\\\\l牑\\u0007A郃)阜ᇒᓌ-塯`W峬G}SDb㬨Q臉⮻빌O鞟톴첂B㺱<ƈmu챑J㴹㷳픷Oㆩs\": {\n                    \"\\\"◉B\\\"pᶉt骔J꩸ᄇᛐi╰栛K쉷㉯鐩!㈐n칍䟅難>盥y铿e୔蒏M貹ヅ8嘋퀯䉶ጥ㏢殊뻳\\\"絧╿ꉑ䠥?∃蓊{}㣣Gk긔H1哵峱\": false,\n                    \"6.瀫cN䇮F㧺?\\\\椯=ڈT䘆4␘8qv\": -3.5687501019676885E-19,\n                    \"Q?yऴr혴{஀䳘p惭f1ﹸ䅷䕋贲<ྃᄊ繲hq\\\\b|#QSTs1c-7(䵢\\u2069匏絘ꯉ:l毴汞t戀oෟᵶ뮱፣-醇Jx䙬䐁햢0࣫ᡁgrㄛ\": \"\\u0011_xM/蘇Chv;dhA5.嗀绱V爤ﰦi뵲M\",\n                    \"⏑[\\\"ugoy^儣횎~U\\\\섯겜論l2jw஌yD腅̂\\u0019\": true,\n                    \"ⵯɇ䐲᫿࢚!㯢l샅笶戮1꣖0Xe\": null,\n                    \"劅f넀識b宁焊E찓橵G!ʱ獓뭔雩괛\": [{\"p⹣켙[q>燣䍃㞽ᩲx:쓤삘7玑퇼0<\\/q璂ᑁ[Z\\\\3䅵䧳\\u0011㤧|妱緒C['췓Yꞟ3Z鳱雼P錻BU씧U`ᢶg蓱>.1ӧ譫'L_5V䏵Ц\": [\n                     false,\n                     false,\n                     {\"22䂍盥N霂얢<F8꼵7Gసyh뀍g᦭ꄢx硴嬢\\u001a?E괆T|;7犟\\\"Wt%䐩O⨵t&#ᬋK'蜍Ძ揔⾠鲂T멷靃\\u0018䓞cE\": {\"f=䏏츜瞾zw?孡鏣\\\\铀᫞yẆg(\\u0011M6(s2]`ਫ\": [[[{\n                      \"'y몱纣4S@\\\\,i㷯럹Ua充Tᣢ9躘Zଞ쥿䐊s<\\/刎\\\\\\\"뉦-8/\": \"蜑.X0꭛낢륹i젨ꚁ<8?s볕蝡|Q✬᯦@\\\\G㑢屿Mn졾J굤⥟JW뤵苑r쁕툄嵵?⾥O\",\n                      \"^1挲~[n귆誈央碠멪gI洷\": -8214236471236116548,\n                      \"sሣ%娌暡clr蟜㑓2\\u000bS❟_X㨔⚴5~蔷ꀇ|Xu㬖,꤭卹r(g믇쩍%췸앙|栣U\\\\2]䤉+啠菡ꯎT鉹m\\n/`SzDᅼ鞶\": 1.1217523390167132E-19,\n                      \"u톇=黚\\\\ ꂮ췵L>躰e9⑩_뵜斌n@B}$괻Yᐱ@䧋V\\\"☒-諯cV돯ʠ\": true,\n                      \"Ű螧ᔼ檍鍎땒딜qꄃH뜣<獧ूCY吓⸏>XQ㵡趌o끬k픀빯a(ܵ甏끆୯/6Nᪧ}搚ᆚ짌P牰泱鈷^d꣟#L삀\\\"㕹襻;k㸊\\\\f+\": true,\n                      \"쎣\\\",|⫝̸阊x庿k잣v庅$鈏괎炔k쬪O_\": [\n                       \"잩AzZGz3v愠ꉈⵎ?㊱}S尳௏p\\r2>췝IP䘈M)w|\\u000eE\",\n                       -9222726055990423201,\n                       null,\n                       [\n                        false,\n                        {\"´킮'뮤쯽Wx讐V,6ᩪ1紲aႈ\\u205czD\": [\n                         -930994432421097536,\n                         3157232031581030121,\n                         \"l貚PY䃛5@䭄<nW\\u001e\",\n                         [\n                          3.801747732605161E18,\n                          [\n                           null,\n                           false,\n                           {\n                            \"\": 4.0442013775147072E16,\n                            \"2J[sᡪ㞿|n'#廲꯬乞\": true,\n                            \"B[繰`\\\\㏏a̼㨀偛㽓<\\/꥖ᵈO让\\r43⡩徑ﬓ๨ﮕx:㣜o玐ꉟぢC珵὆ᓞ쇓Qs氯였9駵q혃Ljꂔ<\\/昺+t䐋༻猙c沪~櫆bpJ9UᏐ:칣妙!皗F4㑄탎䕀櫳振讓\": 7.3924182188256287E18,\n                            \"H磵ai委曷n柋T<\\/勿F&:ꣴfU@㿗榻Lb+?퍄sp\\\"᪟~>귻m㎮琸f\": 1.0318894506812084E-19,\n                            \"࢜⩢Ш䧔1肽씮+༎ᣰ闺馺窃䕨8Mƶq腽xc(៯夐J5굄䕁Qj_훨/~価.䢵慯틠퇱豠㼇Qﵘ$DuSp(8Uญ<\\/ಟ룴𥳐ݩ$\": 8350772684161555590,\n                            \"ㆎQ䄾\\u001bpᩭ${[諟^^骴᤮b^ㅥI┧T㉇⾞\\\"绦<AYJ⒃-oF<\\/蛎mm;obh婃ᦢ\": false,\n                            \"䔤䣈?汝.p襟&d㱅\\\\Jᚠ@?O첁ࢽ휔VR蔩|㒢柺\": [[\n                             \"-ꕨ岓棻r@鿆^3~䪤Ѐ狼︌ﹲ\\\\᝸MlE쵠Q+\",\n                             null,\n                             false,\n                             3346674396990536343,\n                             null,\n                             {\n                              \"\": null,\n                              \"/䏨S쨑,&繷㉥8C엮赸3馢|뇲{鄎ꗇqFﶉ雕UD躢?Ꟛအ꽡[hᕱᗅ㦋쭞Mユ茍?L槽암V#성唐%㣕嘵\\\\ڹ(嘏躿&q\": [\n                               -1364715155337673920,\n                               false,\n                               -8197733031775379251,\n                               \"E팗鮲JwH\\\\觡܈᜝\\\"+뉞娂N휗v噙၂깼\\u001dD帒l%-斔N\",\n                               -3.844267973858711E-20,\n                               [{\"쬯(褈Q 蟚뿢 /ⱖ㻥\\u0017/?v邘䃡0U.Z1x?鯔V尠8Em<\": [[[\n                                null,\n                                [\n                                 null,\n                                 -5841406347577698873,\n                                 \"킷\\\"S⋄籞繗솸ᵣ浵w쑿ퟗ7nᎏx3앙z㘌쿸I葥覯㬏0ᆝb汆狺뷘ႀnꋋ\",\n                                 -1227911573141158702,\n                                 {\n                                  \"u㉮PᾺV鵸A\\\\g*ࡗ9슟晭+ͧↀ쿅H\\u001c꾣犓}癇恛ᗬ黩䟘X梑鐆e>r䰂f矩'-7䡭桥Dz兔V9谶居㺍ᔊ䩯덲.\\u001eL0ὅㅷ釣\": [{\n                                   \"<쯬J卷^숞u࠯䌗艞R9닪g㐾볎a䂈歖意:%鐔|ﵤ|y}>;2,覂⶚啵tb*仛8乒㓶B࿠㯉戩oX 貘5V嗆렽낁߼4h䧛ꍺM空\\\\b꿋貼\": 8478577078537189402,\n                                   \"VD*|吝z~h譺aᯒ\": {\n                                    \"YI췢K<\\/濳xNne玗rJo쾘3핰鴊\\\"↱AR:ࢷ\\\"9?\\\"臁說)?誚ꊏe)_D翾W?&F6J@뺾ꍰNZ醊Z쾈വH嶿?炫㷱鬰M겈<bS}㎥l|刖k\": {\"H7鷮퇢_k\": [\n                                     true,\n                                     \"s㟑瀭좾쮀⑁Y찺k맢戲쀸俻ກ6儮끗扖puߖꜻ馶rꈞ痘?3ྚ畊惘䎗\\\"vv)*臔웅鿈䧲^v,껛㰙J <ᚶ5\",\n                                     7950276470944656796,\n                                     4.9392301536234746E17,\n                                     -4796050478201554639,\n                                     \"yꬴc<3㻚\",\n                                     \"o塁\\u20a4蒵鮬裢CᴧnB㭱f.\",\n                                     false,\n                                     [\n                                      false,\n                                      \"㡐弑V?瀆䰺q!출㇞yᘪ꼼(IS~Ka 烿ꟿ샕桤\\u0005HQҹ㯪罂q萾⚇懋⦕둡v\",\n                                      1862560050083946970,\n                                      \"\\u20b6[|(뭹gꍒ펉O轄Dl묽]ﯨ髯QEbA㒾m@롴礠㕓2땫n6ْ엘঵篳R잷꙲m색摪|@㿫5aK设f胭r8/NI4춫栵\\\\꯬2]\",\n                                      false,\n                                      {\n                                       \"\\u000b7*㙛燏.~?䔊p搕e_拺艿뷍f{ꔻ1s驙`$Ė戧?q⋬沭?塷᭚蹀unoa5\": {\n                                        \"S귯o紞㾕ᅶ侏銇12|ʟ畴iNAo?|Sw$M拲գ㭄紧螆+,梔\": null,\n                                        \"㭚0?xB疱敻ேBPwv뾃熉(ӠpJ]갢\\\"Bj'\\u0016GE椱<\\/zgៅx黢礇h},M9ﴦ?LḨ\": \"Si B%~㬒E\",\n                                        \"핇㉊살㍢숨~ȪRo䦅D桺0z]﬽蠆c9ᣨyPP㿷U~㞐?쯟퍸宒뉆U|}㉓郾ࣻ*櫎꼪䁗s?~7\\u001e㘔h9{aឋ}:㶒P8\": [{\"\\\\R囡쐬nN柋琍؛7칾 :㶃衇徜V 深f1淍♠i?3S角폞^ᆞ\\u20e8ṰD\\u0007秡+躒臔&-6\": {\n                                         \"䨑g.fh㔗=8!\\\"狿ൻLU^뻱g䲚㻐'W}k欤?๒鲇S꧗䫾$ĥ피\": -794055816303360636,\n                                         \"外頮詋~텡竆繃䏩苨뾺朁꼃瘹f*㉀枙NH/\\u2027ꢁ}j묎vペq︉식뜡Od5 N顯ି烅仟Qfㆤ嚢(i䬅c;맧?嶰㩼츱獡?-\": {\n                                          \"e݆㍡⬬'2㻒?U篲鿄\\\"隻Ҭ5NꭰꤺBꀈ拾᩺[刯5곑Na램ﴦ዆]㝓qw钄\\u001b\\\"Y洊䗿祏塥迵[⼞⠳P$꠱5먃0轢`\": [{\"獰E賝﫚b먭N긆Ⰹ史2逶ꜛ?H짉~?P}jj}侷珿_T>᭨b,⻁鈵P䕡䀠८ⱄ홎鄣\": {\n                                           \"@?k2鶖㋮\\\"Oರ K㨇廪儲\\u0017䍾J?);\\b*묀㗠섳햭1MC V\": null,\n                                           \"UIICP!BUA`ᢈ㋸~袩㗪⾒=fB﮴l1ꡛ죘R辂여ҳ7쮡<䩲`熕8頁\": 4481809488267626463,\n                                           \"Y?+8먙ᚔ鋳蜩럶1㥔y璜౩`\": [\n                                            null,\n                                            1.2850335807501874E-19,\n                                            \"~V2\",\n                                            2035406654801997866,\n                                            {\n                                             \"<숻1>\\\"\": -8062468865199390827,\n                                             \"M㿣E]}qwG莎Gn᝶(ꔙ\\\\D⬲iꇲs寢t駇S뀡ꢜ\": false,\n                                             \"pꝤ㎏9W%>M;-U璏f(^j1?&RB隧 忓b똊E\": \"#G?C8.躬ꥯ'?냪#< 渟&헿란zpo왓Kj}鷧XﻘMツb䕖;㪻\",\n                                             \"vE풤幉xz뱕쫥Ug㦲aH} ᣟp:鬼Yᰟ<Fɋ잣緂頒⺏䉲瑑䅂,C~ޅG!f熢-B7~9Pqࡢ[츑#3ꕎ,Öඳ聁⩅㵧춀뿍xy䌏͂tdj!箧᳆|9蚡돬\": -2.54467378964089632E17,\n                                             \"䵈䅦5빖,궆-:໿댾仫0ᙚyᦝhqᚄ\": null,\n                                             \"侯Y\\\"湛졯劇U셎YX灍ⅸ2伴|筧\\\\䁒㶶᷏쁑Waᦵᗱ㜏늾膠<Jc63<G\\u20fe䇹66僣k0O\\\"_@U\": null,\n                                             \"姪y$#s漴JH璌Ӊ脛J㝾펔ﹴoꈶ㚸PD:薠쏖%說ថ蹂1］⾕5튄\": {\n                                              \"᝾Huw3䮅如쿺䍟嫝]<鰨ݷ?꯯䫓傩|ᐶස媽\\\\澒≡闢\": \"Mm\\\"쏇ᯄ졽\\\"楇<\\/ꥆ흭局n隴@鿣w⠊4P贈徎W㊋;䤞'.팇蒁䡴egpx嗎wஅ獗堮ᛐnˁ︖䀤4噙?໚郝᱋ޘॎt恑姫籕殥陃\\\"4[ꝬqL4Wꠎx\",\n                                              \"ℇj遌5B뒚\\\" U\": \"硄ꏘ{憠굏:&t䌨m Cઌ쿣鞛XFꠟs䝭ﶃ\\\"格a0x闊昵吲L\\\\杚聈aꁸj싹獅\\\"灟ﱡ馆*굖糠<ꔏ躎\",\n                                              \"톌賠弳ꟍb\\\"螖X50sĶ晠3f秂坯Iⓟ:萘\": 5.573183333596288E18,\n                                              \"%䴺\": [[[[\n                                               -6957233336860166165,\n                                               false,\n                                               null,\n                                               {\n                                                \"\\\"\\\\௮茒袀ᕥ23ୃ괶?䕎.嚲◉㏞L+ᵡ艱hL콇붆@\": null,\n                                                \"%螥9ꭌ<\\/-t\": true,\n                                                \",9|耢椸䁓Xk죱\\u0015$Ώ鲞[?엢ᝲ혪즈ⴂ▂ℴ㗯\\\"g뺘\\\\ꍜ#\\u0002ヮ}ሎ芲P[鹮轧@냲䃦=#(\": 2.78562909315899616E17,\n                                                \"R?H䧰ⵇ<,憰쮼Q總iR>H3镔ᴚ斦\\\\鏑r*2橱G⼔F/.j\": true,\n                                                \"RK좬뎂a홠f*f㱉ᮍ⦋潙㨋Gu곌SGI3I뿐\\\\F',)t`荁蘯囯ﮉ裲뇟쥼_ገ驪▵撏ᕤV\": 1.52738225997956557E18,\n                                                \"^k굲䪿꠹B逤%F㱢漥O披M㽯镞竇霒i꼂焅륓\\u00059=皫之눃\\u2047娤閍銤唫ၕb<\\/w踲䔼u솆맚,䝒ᝳ'/it\": \"B餹饴is権ꖪ怯ꦂẉဎt\\\"!凢谵⧿0\\\\<=(uL䷍刨쑪>俆揓Cy襸Q힆䆭涷<\\/ᐱ0ɧ䗾䚹\\\\ኜ?ꄢᇘ`䴢{囇}᠈䴥X4퓪檄]ꥷ/3謒ሴn+g騍X\",\n                                                \"GgG꽬[(嫓몍6\\u0004궍宩㙻/>\\u0011^辍dT腪hxǑ%ꊇk,8(W⧂結P鬜O\": [{\n                                                 \"M㴾c>\\\\ᓲ\\u0019V{>ꤩ혙넪㭪躂TS-痴໸闓⍵/徯O.M㏥ʷD囎⧔쁳휤T??鉬뇙=#ꢫ숣BX䭼<\\/d똬졬g榿)eꨋﯪ좇첻<?2K)\": null,\n                                                 \"Z17縬z]愀䖌 ᾋBCg5딒국憍꾓aⲷ턷u:U촳驿?雺楶\\u0001\\u001c{q*ᰗ苑B@k揰z.*蓗7ረIm\\\"Oᱍ@7?_\": true,\n                                                 \"㺃Z<\": -4349275766673120695,\n                                                 \"휃䠂fa塆ﬃxKe'덬鏗੄뺾w࠾鑎k땢m*႑햞鐮6攊&虜h黚,Y䱳Sﭼ둺pN6\": [\n                                                  false,\n                                                  \"IΎ䣲,\\\"ᬮ˪癘P~Qlnx喁Sᮔ༬˨I珌m䜛酛\\u0003iꐸ㦧cQ帲晼D' \\\\(粋wQcN\\\\뵰跈\",\n                                                  [\n                                                   \"D0\\\\L?M1쥍Kaꏌsd+盌귤憊tz䌣댐בO坂wϢ%ὒgp,Ai⎧ᶆI餾ꦍ棩嘅᳉怴%m]ၶis纖D凜镧o심b U\",\n                                                   {\n                                                    \"?଼\\u0011Rv&^[+匚I趈T媫\\u0010.䥤ᆯ1q僤HydⲰl㒽K'ᅾiౕ豲초딨@\\u0013J'쪪VD౼P4Ezg#8*㋤W馓]c쿯8\": false,\n                                                    \"c/擯X5~JmK䵶^쐎ച|B|u[솝(X뚤6v}W㤘⠛aR弌臌쾭諦eⒷ僡-;㩩⭖ⷴ徆龄갬{䱓ᥩ!﯏⊚ᇨ<v燡露`:볉癮꨽り★Ax7Ꮀ譥~舑\\\\Vꍋ\\\"$)v\": \"e&sFF쬘OBd슊寮f蠛জ봞mn~锆竒G脁\\\"趵G刕䕳&L唽붵<\\/I,X팚B⍥X,kԇҗ眄_慡:U附ᓚA蕧>\\u001a\\u0011\\\";~쓆BH4坋攊7힪\",\n                                                    \"iT:L闞椕윚*滛gI≀Wਟඊ'ꢆ縺뱹鮚Nꩁ᧬蕼21줧\\\\䋯``⍐\\\\㏱鳨\": 1927052677739832894,\n                                                    \"쮁缦腃g]礿Y㬙 fヺSɪ꾾N㞈\": [\n                                                     null,\n                                                     null,\n                                                     {\n                                                      \"!t,灝Y 1䗉罵?c饃호䉂Cᐭ쒘z(즽sZG㬣sഖE4뢜㓕䏞丮Qp簍6EZឪ겛fx'ꩱQ0罣i{k锩*㤴㯞r迎jTⲤ渔m炅肳\": [\n                                                       -3.3325685522591933E18,\n                                                       [{\"㓁5]A䢕1룥BC?Ꙍ`r룔Ⳛ䙡u伲+\\u0001്o\": [\n                                                        null,\n                                                        4975309147809803991,\n                                                        null,\n                                                        null,\n                                                        {\"T팘8Dﯲ稟MM☻㧚䥧/8ﻥ⥯aXLaH\\\"顾S☟耲ît7fS෉놁뮔/ꕼ䓈쁺4\\\\霶䠴ᩢ<\\/t4?죵>uD5➶༆쉌럮⢀秙䘥\\u20972ETR3濡恆vB? ~鸆\\u0005\": {\n                                                         \"`閖m璝㥉b뜴?Wf;?DV콜\\u2020퍉౓擝宏ZMj3mJ먡-傷뱙yח㸷꥿ ໘u=M읝!5吭L4v\\\\?ǎ7C홫\": null,\n                                                         \"|\": false,\n                                                         \"~Ztᛋ䚘\\\\擭㗝傪W陖+㗶qᵿ蘥ᙄp%䫎)}=⠔6ᮢS湟-螾-mXH?cp\": 448751162044282216,\n                                                         \"\\u209fad놹j檋䇌ᶾ梕㉝bוּ<d䗱:줰M酄\\u0000X#_r獢A饓ꍗُKo_跔?ᪧ嵜鼲<\": null,\n                                                         \"ꆘ)ubI@h@洭Ai㜎䏱k\\u0003?T䉐3间%j6j棍j=❁\\\\U毮ᬹ*8䀔v6cpj⭬~Q꿾뺶펵悡!쩭厝l六㽫6퇓ޭ2>\": {\"?苴ꩠD䋓帘5騱qﱖPF?☸珗顒yU ᡫcb䫎 S@㥚gꮒ쎘泴멖\\\\:I鮱TZ듒ᶨQ3+f7캙\\\"?\\f풾\\\\o杞紟﻽M.⏎靑OP\": [\n                                                          -2.6990368911551596E18,\n                                                          [{\"䒖@<᰿<\\/⽬tTr腞&G%᳊秩蜰擻f㎳?S㵧\\r*k뎾-乢겹隷j軛겷0룁鮁\": {\")DO0腦:춍逿:1㥨่!蛍樋2\": [{\n                                                           \",ꌣf侴笾m๫ꆽ?1?U?\\u0011ꌈꂇ\": {\n                                                            \"x捗甠nVq䅦w`CD⦂惺嘴0I#vỵ} \\\\귂S끴D얾?Ԓj溯\\\"v餄a\": {\n                                                             \"@翙c⢃趚痋i\\u0015OQ⍝lq돆Y0pࢥ3쉨䜩^<8g懥0w)]䊑n洺o5쭝QL댊랖L镈Qnt⪟㒅십q헎鳒⮤眉ᔹ梠@O縠u泌ㄘb榚癸XޔFtj;iC\": false,\n                                                             \"I&뱋゘|蓔䔕측瓯%6ᗻHW\\\\N1貇#?僐ᗜgh᭪o'䗈꽹Rc욏/蔳迄༝!0邔䨷푪8疩)[쭶緄㇈୧ፐ\": {\n                                                              \"B+:ꉰ`s쾭)빼C羍A䫊pMgjdx䐝Hf9᥸W0!C樃'蘿f䫤סи\\u0017Jve? 覝f둀⬣퓉Whk\\\"஼=չﳐ皆笁BIW虨쫓F廰饞\": -642906201042308791,\n                                                              \"sb,XcZ<\\/m㉹ ;䑷@c䵀s奤⬷7`ꘖ蕘戚?Feb#輜}p4nH⬮eKL트}\": [\n                                                               \"RK鳗z=袤Pf|[,u욺\",\n                                                               \"Ẏᏻ罯뉋⺖锅젯㷻{H䰞쬙-쩓D]~\\u0013O㳢gb@揶蔉|kᦂ❗!\\u001ebM褐sca쨜襒y⺉룓\",\n                                                               null,\n                                                               null,\n                                                               true,\n                                                               -1.650777344339075E-19,\n                                                               false,\n                                                               \"☑lꄆs힨꤇]'uTന⌳농].1⋔괁沰\\\"IWഩ\\u0019氜8쟇䔻;3衲恋,窌z펏喁횗?4?C넁问?ᥙ橭{稻Ⴗ_썔\",\n                                                               \"n?]讇빽嗁}1孅9#ꭨ靶v\\u0014喈)vw祔}룼쮿I\",\n                                                               -2.7033457331882025E18,\n                                                               {\n                                                                \";⚃^㱋x:饬ኡj'꧵T☽O㔬RO婎?향ᒭ搩$渣y4i;(Q>꿘e8q\": \"j~錘}0g;L萺*;ᕭꄮ0l潛烢5H▄쳂ꏒוֹꙶT犘≫x閦웧v\",\n                                                                \"~揯\\u2018c4職렁E~ᑅቚꈂ?nq뎤.:慹`F햘+%鉎O瀜쟏敛菮⍌浢<\\/㮺紿P鳆ࠉ8I-o?#jﮨ7v3Dt赻J9\": null,\n                                                                \"ࣝW䌈0ꍎqC逖,횅c၃swj;jJS櫍5槗OaB>D踾Y\": {\"㒰䵝F%?59.㍈cᕨ흕틎ḏ㋩B=9IېⓌ{:9.yw｝呰ㆮ肒᎒tI㾴62\\\"ዃ抡C﹬B<\\/<EO꽓ᇕu&鋫\\\\禞퐹u꒍.7훯ಶ2䩦͉ᶱf깵ᷣ늎\": [\n                                                                 5.5099570884646902E18,\n                                                                 \"uQN濿m臇<%?谣鮢s]]x0躩慌闋<;( 鋤.0ᠵd1#벘a:Gs?햷'.)ㅴ䞟琯崈FS@O㌛ᓬ抢큌ើ냷쿟툥IZn[惵ꐧ3뙍[&v憙J>촋jo朣\",\n                                                                 [\n                                                                  -7675533242647793366,\n                                                                  {\"ᙧ呃:[㒺쳀쌡쏂H稈㢤\\u001dᶗGG-{GHྻຊꡃ哸䵬;$?&d\\\\⥬こN圴됤挨-'ꕮ$PU%?冕눖i魁q騎Q\": [\n                                                                   false,\n                                                                   [[\n                                                                    7929823049157504248,\n                                                                    [[\n                                                                     true,\n                                                                     \"Z菙\\u0017'eꕤ᱕l,0\\\\X\\u001c[=雿8蠬L<\\/낲긯W99g톉4ퟋb㝺\\u0007劁'!麕Q궈oW:@X၎z蘻m絙璩귓죉+3柚怫tS捇蒣䝠-擶D[0=퉿8)q0ٟ\",\n                                                                     \"唉\\nFA椭穒巯\\\\䥴䅺鿤S#b迅獘 ﶗ꬘\\\\?q1qN犠pX꜅^䤊⛤㢌[⬛휖岺q唻ⳡ틍\\\"㙙Eh@oA賑㗠y必Nꊑᗘ\",\n                                                                     -2154220236962890773,\n                                                                     -3.2442003245397908E18,\n                                                                     \"Wᄿ筠:瘫퀩?o貸q⊻(᎞KWf宛尨h^残3[U(='橄\",\n                                                                     -7857990034281549164,\n                                                                     1.44283696979059942E18,\n                                                                     null,\n                                                                     {\"ꫯAw跭喀 ?_9\\\"Aty背F=9缉ྦྷ@;?^鞀w:uN㘢Rỏ\": [\n                                                                      7.393662029337442E15,\n                                                                      3564680942654233068,\n                                                                      [\n                                                                       false,\n                                                                       -5253931502642112194,\n                                                                       \"煉\\\\辎ೆ罍5⒭1䪁䃑s䎢:[e5}峳ﴱn騎3?腳Hyꏃ膼N潭錖,Yᝋ˜YAၓ㬠bG렣䰣:\",\n                                                                       true,\n                                                                       null,\n                                                                       {\n                                                                        \"⒛'P&%죮|:⫶춞\": -3818336746965687085,\n                                                                        \"钖m<\\/0ݎMtF2Pk=瓰୮洽겎.\": [[\n                                                                         -8757574841556350607,\n                                                                         -3045234949333270161,\n                                                                         null,\n                                                                         {\n                                                                          \"Ꮬr輳>⫇9hU##w@귪A\\\\C 鋺㘓ꖐ梒뒬묹㹻+郸嬏윤'+g<\\/碴,}ꙫ>손;情d齆J䬁ຩ撛챝탹/R澡7剌tꤼ?ặ!`⏲睤\\u00002똥଴⟏\": null,\n                                                                          \"\\u20f2ܹe\\\\tAꥍư\\\\x当뿖렉禛;G檳ﯪS૰3~㘠#[J<}{奲 5箉⨔{놁<\\/釿抋,嚠/曳m&WaOvT赋皺璑텁\": [[\n                                                                           false,\n                                                                           null,\n                                                                           true,\n                                                                           -5.7131445659795661E18,\n                                                                           \"萭m䓪D5|3婁ఞ>蠇晼6nﴺPp禽羱DS<睓닫屚삏姿\",\n                                                                           true,\n                                                                           [\n                                                                            -8759747687917306831,\n                                                                            {\n                                                                             \">ⓛ\\t,odKr{䘠?b퓸C嶈=DyEᙬ@ᴔ쨺芛髿UT퓻春<\\/yꏸ>豚W釺N뜨^?꽴﨟5殺ᗃ翐%>퍂ဿ䄸沂Ea;A_\\u0005閹殀W+窊?Ꭼd\\u0013P汴G5썓揘\": 4.342729067882445E-18,\n                                                                             \"Q^즾眆@AN\\u0011Kb榰냎Y#䝀ꀒᳺ'q暇睵s\\\"!3#I⊆畼寤@HxJ9\": false,\n                                                                             \"⿾D[)袨㇩i]웪䀤ᛰMvR<蟏㣨\": {\"v퇓L㪱ꖣ豛톤\\\\곱#kDTN\": [{\n                                                                              \"(쾴䡣,寴ph(C\\\"㳶w\\\"憳2s馆E!n!&柄<\\/0Pꈗſ?㿳Qd鵔\": {\"娇堰孹L錮h嵅⛤躏顒?CglN束+쨣ﺜ\\\\MrH\": {\"獞䎇둃ቲ弭팭^ꄞ踦涟XK錆쳞ឌ`;੶S炥騞ଋ褂B៎{ڒ䭷ᶼ靜pI荗虶K$\": [{\"◖S~躘蒉꫿輜譝Q㽙闐@ᢗ¥E榁iء5┄^B[絮跉ᰥ遙PWi3wㄾⵀDJ9!w㞣ᄎ{듒ꓓb6\\\\篴??c⼰鶹⟧\\\\鮇ꮇ\": [[\n                                                                               654120831325413520,\n                                                                               -1.9562073916357608E-19,\n                                                                               {\n                                                                                \"DC(昐衵ἡ긙갵姭|֛[t\": 7.6979110359897907E18,\n                                                                                \"J␅))嫼❳9Xfd飉j7猬ᩉ+⤻眗벎E鰉Zﾶ63zၝ69}ZᶐL崭ᦥ⡦靚⋛ꎨ~i㨃咊ꧭo䰠阀3C(\": -3.5844809362512589E17,\n                                                                                \"p꣑팱쒬ꎑ뛡Ꙩ挴恍胔&7ᔈ묒4Hd硶훐㎖zꢼ豍㿢aሃ=<\\/湉鵲EӅ%$F!퍶棌孼{O駍਺geu+\": \")\\u001b잓kŀX쩫A밁®ڣ癦狢)扔弒p}k縕ꩋ,䃉tࣼi\",\n                                                                                \"ァF肿輸<솄G-䢹䛸ꊏl`Tqꕗ蒞a氷⸅ᴉ蠰]S/{J왲m5{9.uέ~㕚㣹u>x8U讁B덺襪盎QhVS맅킃i识{벂磄Iහ䙅xZy/抍૭Z鲁-霳V据挦ℒ\": null,\n                                                                                \"㯛|Nꐸb7ⵐb?拠O\\u0014ކ?-(EꞨ4ꕷᄤYᯕOW瞺~螸\\\"욿ќ<u鵵઎⸊倾쑷෻rT⪄牤銱;W殆͢芄ਰ嚝훚샢⊿+㲽\": null,\n                                                                                \"単逆ົ%_맛d)zJ%3칧_릟#95䌨怡\\u001ci턠ॣi冘4赖'ਐ䧐_栔!\": {\n                                                                                 \"*?2~4㲌᭳쯁ftႷ1#oJ\\b䊇镇됔 \\u2079x䛁㊝ᮂN;穽跖s휇ᣄ홄傷z⸷(霸!3y뺏M쒿햏۽v㳉tở心3黎v쭻 Rp཮Vr~T?&˴k糒븥쩩r*D\": null,\n                                                                                 \"8@~홟ꔘk1[\": -5570970366240640754,\n                                                                                 \"BZt鏦ꡬc餖  s(mᛴ\\u0000◄d腑t84C⟐坯VṊ뉙'噱Ꝕ珽GC顀?허0ꞹ&돇䛭C䷫](\": 2.4303828213012387E-20,\n                                                                                 \"y撔Z외放+}ḑ骈ᙝ&\\u0016`G便2|-e]঳?QF㜹YF\\\"㿒緄햷㈟塚䷦ୀጤlM蘸N㾆▛럪㞂tᕬ镈쇝喠l amcxPnm\\u001a᱋<\\/]_]ﻹ瞧?H\": false,\n                                                                                 \"ፏ氏묢뜚I[♺뽛x?0H봬Wpn꨹Ra䝿쌑{㴂ni祻윸A'y|⺴ᚘ庌9{$恲{톽=m#@6ᨧfgs44陎J#<Ễ쨓瀵❩a୛㷉㙉ܸ◠냔嬯~呄籁羥镳\": false,\n                                                                                 \"㘱{<頬22?IF@곊I겂嶻L᝛D{@r쒂?IAᣧ洪惒誸b徂z췺꾍㠭\\\\刊%禨쌐ⶣ仵\\\\P[:47;<ᇅ<\\/\": {\n                                                                                  \"^U釳-v㢈ꗝ◄菘rᜨi;起kR犺䵫\\u0000锍쁙m-ԙ!lḃ꛸뻾F(W귛y\": \"#ᠺH㸢5v8_洑C\",\n                                                                                  \"䔵໳$ᙠ6菞\\u206e摎q圩P|慍sV4:㜾(I溞I?\": -6569206717947549676,\n                                                                                  \"透Ꞃ緵퇝8 >e㺰\\\"'㌢ƐW\\u0004瞕>0?V鷵엳\": true,\n                                                                                  \"뤥G\\\\迋䠿[庩'꼡\\u001aiᩮV쯁ᳪ䦪Ô;倱ନ뛁誈\": null,\n                                                                                  \"쥹䄆䚟Q榁䎐᢭<\\/2㕣p}HW蟔|䃏꿈ꚉ锳2Pb7㙑Tⅹᵅ\": {\n                                                                                   \"Y?֭$>#cVBꩨ:>eL蒁務\": {\n                                                                                    \"86柡0po 䏚&-捑Ћ祌<\\/휃-G*㶢הּ쩍s㶟餇c걺yu꽎還5*턧簕Og婥SꝐ\": null,\n                                                                                    \"a+葞h٥ࠆ裈嗫ﵢ5輙퀟ᛜ,QDﹼ⟶Y騠锪E_|x죗j侵;m蜫轘趥?븅w5+mi콛L\": {\n                                                                                     \";⯭ﱢ!买F⽍柤鶂n䵣V㫚墱2렾ELEl⣆\": [\n                                                                                      true,\n                                                                                      -3.6479311868339015E-18,\n                                                                                      -7270785619461995400,\n                                                                                      3.334081886177621E18,\n                                                                                      2.581457786298155E18,\n                                                                                      -6.605252412954115E-20,\n                                                                                      -3.9232347037744167E-20,\n                                                                                      {\n                                                                                       \"B6㊕.k1\": null,\n                                                                                       \"ZAꄮJ鮷ᳱo갘硥鈠䠒츼\": {\n                                                                                        \"ᕅ}럡}.@y陪鶁r業'援퀉x䉴ﵴl퍘):씭脴ᥞhiꃰblﲂ䡲엕8߇M㶭0燋標挝-?PCwe⾕J碻Ᾱ䬈䈥뷰憵賣뵓痬+\": {\"a췩v礗X⋈耓ፊf罅靮!㔽YYᣓw澍33⎔芲F|\\\"䜏T↮輦挑6ᓘL侘?ￆ]덆1R௯✎餘6ꏽ<\\/௨\\\\?q喷ꁫj~@ulq\": {\"嗫欆뾔Xꆹ4H㌋F嵧]ࠎ]㠖1ꞤT<$m뫏O i댳0䲝i\": {\"?෩?\\u20cd슮|ꯆjs{?d7?eNs⢚嫥氂䡮쎱:鑵롟2hJꎒﯭ鱢3춲亄:뼣v䊭諱Yj択cVmR䩃㘬T\\\"N홝*ै%x^F\\\\_s9보zz4淗?q\": [\n                                                                                         null,\n                                                                                         \"?\",\n                                                                                         2941869570821073737,\n                                                                                         \"{5{殇0䝾g6밖퍋臩綹R$䖭j紋釰7sXI繳漪행y\",\n                                                                                         false,\n                                                                                         \"aH磂?뛡#惇d婅?Fe,쐘+늵䍘\\\"3r瘆唊勐j⳧࠴ꇓ<\\/唕윈x⬌讣䋵%拗ᛆⰿ妴᝔M2㳗必꧂淲?ゥ젯檢<8끒MidX䏒3᳻Q▮佐UT|⤪봦靏⊏\",\n                                                                                         [[{\n                                                                                          \"颉(&뜸귙{y^\\\"P퟉춝Ჟ䮭D顡9=?}Y誱<$b뱣RvO8cH煉＠tk~4ǂ⤧⩝屋SS;J{vV#剤餓ᯅc?#a6D,s\": [\n                                                                                           -7.8781018564821536E16,\n                                                                                           true,\n                                                                                           [\n                                                                                            -2.28770899315832371E18,\n                                                                                            false,\n                                                                                            -1.0863912140143876E-20,\n                                                                                            -6282721572097446995,\n                                                                                            6767121921199223078,\n                                                                                            -2545487755405567831,\n                                                                                            false,\n                                                                                            null,\n                                                                                            -9065970397975641765,\n                                                                                            [\n                                                                                             -5.928721243413937E-20,\n                                                                                             {\"6촊\\u001a홯kB0w撨燠룉{绎6⳹!턍贑y▾鱧ժ[;7ᨷ∀*땒䪮1x霆Hᩭ☔\\\"r䝐7毟ᝰr惃3ꉭE+>僒澐\": [\n                                                                                              \"Ta쎩aƝt쵯ⰪVb\",\n                                                                                              [\n                                                                                               -5222472249213580702,\n                                                                                               null,\n                                                                                               -2851641861541559595,\n                                                                                               null,\n                                                                                               4808804630502809099,\n                                                                                               5657671602244269874,\n                                                                                               \"5犲﨣4mᥣ?yf젫꾯|䋬잁$`Iⳉﴷ扳兝,'c\",\n                                                                                               false,\n                                                                                               [\n                                                                                                null,\n                                                                                                {\n                                                                                                 \"DyUIN쎾M仼惀⮥裎岶泭lh扠\\u001e礼.tEC癯튻@_Qd4c5S熯A<\\/＼6U윲蹴Q=%푫汹\\\\\\u20614b[௒C⒥Xe⊇囙b,服3ss땊뢍i~逇PA쇸1\": -2.63273619193485312E17,\n                                                                                                 \"Mq꺋貘k휕=nK硍뫞輩>㾆~἞ࡹ긐榵l⋙Hw뮢帋M엳뢯v⅃^\": 1877913476688465125,\n                                                                                                 \"ᶴ뻗`~筗免⚽টW˃⽝b犳䓺Iz篤p;乨A\\u20ef쩏?疊m㝀컩뫡b탔鄃ᾈV(遢珳=뎲ିeF仢䆡谨8t0醄7㭧瘵⻰컆r厡궥d)a阄፷Ed&c﯄伮1p\": null,\n                                                                                                 \"⯁w4曢\\\"(欷輡\": \"\\\"M᭫]䣒頳B\\\\燧ࠃN㡇j姈g⊸⺌忉ꡥF矉স%^\",\n                                                                                                 \"㣡Oᄦ昵⫮Y祎S쐐級㭻撥>{I$\": -378474210562741663,\n                                                                                                 \"䛒掷留Q%쓗1*1J*끓헩ᦢ﫫哉쩧EↅIcꅡ\\\\?ⴊl귛顮4\": false,\n                                                                                                 \"寔愆샠5]䗄IH贈=d﯊/偶?ॊn%晥D視N򗘈'᫂⚦|X쵩넽z질tskxDQ莮Aoﱻ뛓\": true,\n                                                                                                 \"钣xp?&\\u001e侉/y䴼~?U篔蘚缣/I畚?Q绊\": -3034854258736382234,\n                                                                                                 \"꺲໣眀)⿷J暘pИfAV삕쳭Nꯗ4々'唄ⶑ伻㷯騑倭D*Ok꧁3b␽_<\\/챣Xm톰ၕ䆄`*fl㭀暮滠毡?\": [\n                                                                                                  \"D男p`V뙸擨忝븪9c麺`淂⢦Yw⡢+kzܖ\\fY1䬡H歁)벾Z♤溊-혰셢?1<-\\u0005;搢Tᐁle\\\\ᛵߓﭩ榩<QF;t=?Qꀞ\",\n                                                                                                  [\n                                                                                                   null,\n                                                                                                   [{\"-췫揲ᬨ墊臸<ࠒH跥 㔭쥃㫯W=z[wধ╌<~yW楄S!⑻h즓lĖN￧篌W듷튗乵᪪템먵Pf悥ᘀk䷭焼\\\\讄r擁鐬y6VF<\\/6랿p)麡ꁠ㪁\\\"pழe\": [\n                                                                                                    \"#幎杴颒嶈)ㄛJ.嶤26_⋌东챯ꠉ⤋ؚ/⏚%秼Q룠QGztﾺ㎷អI翰Xp睔鍜ꨍ\",\n                                                                                                    {\",T?\": [\n                                                                                                     false,\n                                                                                                     [[\n                                                                                                      true,\n                                                                                                      7974824014498027996,\n                                                                                                      false,\n                                                                                                      [\n                                                                                                       4.3305464880956252E18,\n                                                                                                       {\n                                                                                                        \"᱿W^A]'rᮢ)鏥z餝;Hu\\\\Fk?ﴺ?IG浅-䙧>訝-xJ;巡8깊蠝ﻓU$K\": {\n                                                                                                         \"Vꕡ諅搓W=斸s︪vﲜ츧$)iꡟ싉e寳?ጭムVથ嵬i楝Fg<\\/Z|៪ꩆ-5'@ꃱ80!燱R쇤t糳]罛逇dṌ֣XHiͦ{\": true,\n                                                                                                         \"Ya矲C멗Q9膲墅携휻c\\\\딶G甔<\\/.齵휴\": -1.1456247877031811E-19,\n                                                                                                         \"z#.OO￝J\": -8263224695871959017,\n                                                                                                         \"崍_3夼ᮟ1F븍뽯ᦓ鴭V豈Ь\": [{\n                                                                                                          \"N蒬74\": null,\n                                                                                                          \"yuB?厅vK笗!ᔸcXQ旦컶P-녫mﾵ麟_\": \"1R@ 톘xa_|﩯遘s槞d!d껀筤⬫薐焵먑D{\\\\6k共倌☀G~AS_D\\\"딟쬚뮥馲렓쓠攥WTMܭ8nX㩴䕅檹E\\u0007ﭨN 2 ℆涐ꥏ꠵3▙玽|됨_\\u2048\",\n                                                                                                          \"恐A C䧩G\": {\":M큣5e들\\\\ꍀ恼ᔄ靸|I﨏$)n\": {\n                                                                                                           \"|U䬫㟯SKV6ꛤ㗮\\bn봻䲄fＸT:㾯쳤'笓0b/ೢC쳖?2浓uO.䰴\": \"ཐ꼋e?``,ᚇ慐^8ꜙNM䂱\\u0001IᖙꝧM'vKdꌊH牮r\\\\O@䊷ᓵ쀆(fy聻i툺\\\"?<\\/峧ࣞ⓺ᤤ쵒߯ꎺ騬?)刦\\u2072l慪y꺜ﲖTj+u\",\n                                                                                                           \"뽫<G;稳UL⸙q2n쵿C396炿J蓡z⣁zဩSOU?<\\/뙍oE큸O鿅෴ꍈEm#\\\"[瑦⤫ᝆgl⡗q8\\\"큘덥係@ᆤ=\\u0001爖羝췀㸩b9\\\\jeqt㟿㮸龾m㳳긄\": {\n                                                                                                            \"9\\\"V霟釜{/o0嫲C咀-饷䈍[녩)\\r䤴tMW\\\\龟ϣ^ي㪙忩䞞N湆Y笕)萨ꖤ誥煽:14⫻57U$擒䲐薡Qvↇ櫲현誧?nஷ6\": {\"l웾䌵.䅋䦝ic碳g[糲Ƿ-ឈᚱ4쑧\\u0004C࿼\\u0018&쬑?멲<\\/fD_檼픃pd쪼n㕊渪V䛉m揈W儅톳뗳䓆7㭽諤T煠Ney?0᪵鈑&\": [\n                                                                                                             false,\n                                                                                                             null,\n                                                                                                             {\n                                                                                                              \"\\r;鼶j᠂꼍RLz~♔9gf?ӡ浐\": -1.4843072575250897E-19,\n                                                                                                              \"&ꊒ\\\"ꋟ䝭E诮ﯚO?SW뒁훪mb旙⎕ᗕ⶙|ᷤ5y4甥\": \"j5|庠t铱?v 횋0\\\"'rxz䃢杺Ɜ!\\u0002\",\n                                                                                                              \"Q ၩ㟧\": {\"Hﬔ\\u2058䪠틙izZㅛ탟H^ﶲA??R6呠Z솋R.࿶g8\": [\n                                                                                                               -8762672252886298799,\n                                                                                                               -1.9486830507000208E17,\n                                                                                                               null,\n                                                                                                               -7157359405410123024,\n                                                                                                               null,\n                                                                                                               null,\n                                                                                                               -995856734219489233,\n                                                                                                               \"呧㫹A4!\",\n                                                                                                               null,\n                                                                                                               -1.9105609358624648E-19,\n                                                                                                               5888184370445333848,\n                                                                                                               2.25460605078245E-19,\n                                                                                                               2.5302739297121987E18,\n                                                                                                               \"뢹sbEf捵2丯?뗾耸(Wd띙SବꭖrtU?筤P똙QpbbKqaE$来V웰3i/lK퉜,8︸e= g螓t竦컼?.寋8鵗\",\n                                                                                                               7377742975895263424,\n                                                                                                               2.4218442017790503E-19,\n                                                                                                               {\n                                                                                                                \"y꒚ཫ쨘醬킃糟}yTSt䡀⇂뿽4ൢ戰U\": [[\n                                                                                                                 3600537227234741875,\n                                                                                                                 4435474101760273035,\n                                                                                                                 -1.42274517007951795E18,\n                                                                                                                 -5567915915496026866,\n                                                                                                                 null,\n                                                                                                                 null,\n                                                                                                                 [\n                                                                                                                  -3204084299154861161,\n                                                                                                                  {\n                                                                                                                   \"7梧慸憏.a瘎\\u00041U鵮Ck֨d惥耍ⳡY,⭏써E垁FFI鱑ⳬ줢7⧵Bﴠ耘줕햸q컴~*瑍W.떛ࡆ@'᐀+轳\": -961121410259132975,\n                                                                                                                   \"⥅]l黭㣓绶;!!⎃=朼㐿e&ἂ繤C﯀l䝣㌀6TM쑮w懃ꡡ#ᤆ䰓,墼湼゙뽸㲿䧽쫨xᵖ듨<\\/ T0峸iQ:溫脐\\\\\\\"쎪ὴ砇宖^M泼큥➅鈫@ᄟ༩\\u2008⥼\": true,\n                                                                                                                   \"⩐\\\"籽汎P싯鲘蟼sRᐯ䅩\\u0019R(kRᖁ&ಌ 0\\\"鳶!馼YH\": null,\n                                                                                                                   \"鮼ꚇ싋։刟\\rRLd步Nⴗ5Eࡆ訛갚[I醵NC(郴ṉy5D뤺౳QY壯5苴y훨(W\\\\Cଇ姚C艄깹\\u001c歷㋵ZC᥂\": [\n                                                                                                                    -6806235313106257498,\n                                                                                                                    null,\n                                                                                                                    \"}N⸿讽sꚪ;\\\\p繇j苄䫨\\u20e7%5x?t#\",\n                                                                                                                    {\n                                                                                                                     \"O〗k<墻yV$ఁrs-c1ఌ唪.C7_Yobᦜ褷'b帰mㄑl⌅\": {\"qB뗗擄3隂5뺍櫂䱟e촸P/鏩,3掁ꗩ=冉棓㑉|˞F襴뿴,:㞦<퓂⧙礞♗g뚎ᛩ<\\/뉽ⶳ⸻A?_x2I㽝勒*I홱鍧粿~曟㤙2绥Ly6+썃uu鿜בf큘|歍ࣖÉ\": [\n                                                                                                                      \">hh䈵w>1ⲏ쐭V[ⅎ\\\\헑벑F_㖝⠗㫇h恽;῝汰ᱼ瀖J옆9RR셏vsZ柺鶶툤r뢱橾/ꉇ囦FGm\\\"謗ꉦ⨶쒿⥡%]鵩#ᖣ_蹎 u5|祥?O\",\n                                                                                                                      null,\n                                                                                                                      2.0150326776036215E-19,\n                                                                                                                      null,\n                                                                                                                      true,\n                                                                                                                      false,\n                                                                                                                      true,\n                                                                                                                      {\"\\fa᭶P捤WWc᠟f뚉ᬏ퓗ⳀW睹5:HXH=q7x찙X$)모r뚥ᆟ!Jﳸf\": [\n                                                                                                                       -2995806398034583407,\n                                                                                                                       [\n                                                                                                                        6441377066589744683,\n                                                                                                                        \"Mﶒ醹i)Gἦ廃s6몞 KJ౹礎VZ螺费힀\\u0000冺업{谥'꡾뱻:.ꘘ굄奉攼Di᷑K鶲y繈욊阓v㻘}枭캗e矮1c?휐\\\"4\\u0005厑莔뀾墓낝⽴洗ṹ䇃糞@b1\\u0016즽Y轹\",\n                                                                                                                        {\n                                                                                                                         \"1⽕⌰鉟픏M㤭n⧴ỼD#%鐘⊯쿼稁븣몐紧ᅇ㓕ᛖcw嬀~ഌ㖓(0r⧦Q䑕髍ര铂㓻R儮\\\"@ꇱm❈௿᦯頌8}㿹犴?xn잆꥽R\": 2.07321075750427366E18,\n                                                                                                                         \"˳b18㗈䃟柵Z曆VTAu7+㛂cb0﯑Wp執<\\/臋뭡뚋刼틮荋벲TLP预庰܈G\\\\O@VD'鱃#乖끺*鑪ꬳ?Mޞdﭹ{␇圯쇜㼞顄︖Y홡g\": [{\n                                                                                                                          \"0a,FZ\": true,\n                                                                                                                          \"2z̬蝣ꧦ驸\\u0006L↛Ḣ4๚뿀'?lcwᄧ㐮!蓚䃦-|7.飑挴.樵*+1ﮊ\\u0010ꛌ%貨啺/JdM:똍!FBe?鰴㨗0O财I藻ʔWA᫓G쳛u`<\\/I\": [{\n                                                                                                                           \"$τ5V鴐a뾆両環iZp頻යn븃v\": -4869131188151215571,\n                                                                                                                           \"*즢[⦃b礞R◚nΰꕢH=귰燙[yc誘g䆌?ଜ臛\": {\n                                                                                                                            \"洤湌鲒)⟻\\\\䥳va}PeAMnＮ[\": \"㐳ɪ/(軆lZR,Cp殍ȮN啷\\\"3B婴?i=r$펽ᤐ쀸\",\n                                                                                                                            \"阄R4㒿㯔ڀ69ZᲦ2癁핌噗P崜#\\\\-쭍袛&鐑/$4童V꩑_ZHA澢fZ3\": {\"x;P{긳:G閉:9?活H\": [\n                                                                                                                             \"繺漮6?z犞焃슳\\\">ỏ[Ⳛ䌜녏䂹>聵⼶煜Y桥[泥뚩MvK$4jtﾛ\",\n                                                                                                                             \"E#갶霠좭㦻ୗ먵F+䪀o蝒ba쮎4X㣵 h\",\n                                                                                                                             -335836610224228782,\n                                                                                                                             null,\n                                                                                                                             null,\n                                                                                                                             [\n                                                                                                                              \"r1᫩0>danjY짿bs{\",\n                                                                                                                              [\n                                                                                                                               -9.594464059325631E-23,\n                                                                                                                               1.0456894622831624E-20,\n                                                                                                                               null,\n                                                                                                                               5.803973284253454E-20,\n                                                                                                                               -8141787905188892123,\n                                                                                                                               true,\n                                                                                                                               -4735305442504973382,\n                                                                                                                               9.513150514479281E-20,\n                                                                                                                               \"7넳$螔忷㶪}䪪l짴\\u0007鹁P鰚HF銏ZJﳴ/⍎1ᷓ忉睇ᜋ쓈x뵠m䷐窥Ꮤ^\\u0019ᶌ偭#ヂt☆၃pᎍ臶䟱5$䰵&๵分숝]䝈뉍♂坎\\u0011<>\",\n                                                                                                                               \"C蒑貑藁lﰰ}X喇몛;t밿O7/᯹f\\u0015kI嘦<ዴ㟮ᗎZ`GWퟩ瑹࡮ᅴB꿊칈??R校s脚\",\n                                                                                                                               {\n                                                                                                                                \"9珵戬+AU^洘拻ቒy柭床'粙XG鞕᠜繀伪%]hC,$輙?Ut乖Qm떚W8઼}~q⠪rU䤶CQ痗ig@#≲t샌f㈥酧l;y闥ZH斦e⸬]j⸗?ঢ拻퀆滌\": null,\n                                                                                                                                \"畯}㧢J罚帐VX㨑>1ꢶkT⿄蘥㝑o|<嗸層沈挄GEOM@-䞚䧰$만峬輏䠱V✩5宸-揂D'㗪yP掶7b⠟J㕻SfP?d}v㼂Ꮕ'猘\": {\n                                                                                                                                 \"陓y잀v>╪\": null,\n                                                                                                                                 \"鬿L+7:됑Y=焠U;킻䯌잫!韎ஔ\\f\": {\n                                                                                                                                  \"駫WmGጶ\": {\n                                                                                                                                   \"\\\\~m6狩K\": -2586304199791962143,\n                                                                                                                                   \"ႜࠀ%͑l⿅D.瑢Dk%0紪dḨTI픸%뗜☓s榗኉\\\"?V籄7w髄♲쟗翛歂E䤓皹t ?)ᄟ鬲鐜6C\": {\n                                                                                                                                    \"_췤a圷1\\u000eB-XOy缿請∎$`쳌eZ~杁튻/蜞`塣৙\\\"⪰\\\"沒l}蕌\\\\롃荫氌.望wZ|o!)Hn獝qg}\": null,\n                                                                                                                                    \"kOSܧ䖨钨:಼鉝ꭝO醧S`십`ꓭ쭁ﯢN&Et㺪馻㍢ⅳ㢺崡ຊ蜚锫\\\\%ahx켨|ż劻ꎄ㢄쐟A躊᰹p譞綨Ir쿯\\u0016ﵚOd럂*僨郀N*b㕷63z\": {\n                                                                                                                                     \":L5r+T㡲\": [{\n                                                                                                                                      \"VK泓돲ᮙRy㓤➙Ⱗ38oi}LJቨ7Ó㹡৘*q)1豢⛃e᫛뙪壥镇枝7G藯g㨛oI䄽 孂L缊ꋕ'EN`\": -2148138481412096818,\n                                                                                                                                      \"`⛝ᘑ$(खꊲ⤖ᄁꤒ䦦3=)]Y㢌跨NĴ驳줟秠++d孳>8ᎊ떩EꡣSv룃 쯫أ?#E|᭙㎐?zv:5祉^⋑V\": [\n                                                                                                                                       -1.4691944435285607E-19,\n                                                                                                                                       3.4128661569395795E17,\n                                                                                                                                       \"㐃촗^G9佭龶n募8R厞eEw⺡_ㆱ%⼨D뉄퉠2ꩵᛅⳍ搿L팹Lවn=\\\"慉념ᛮy>!`g!풲晴[/;?[v겁軇}⤳⤁핏∌T㽲R홓遉㓥\",\n                                                                                                                                       \"愰_⮹T䓒妒閤둥?0aB@㈧g焻-#~跬x<\\/舁P݄ꐡ=\\\\׳P\\u0015jᳪᢁq;㯏l%᭗;砢觨▝,謁ꍰGy?躤O黩퍋Y㒝a擯\\n7覌똟_䔡]fJ晋IAS\",\n                                                                                                                                       4367930106786121250,\n                                                                                                                                       -4.9421193149720582E17,\n                                                                                                                                       null,\n                                                                                                                                       {\n                                                                                                                                        \";ﾸ똾柉곟ⰺKpፇ䱻ฺ䖝{o~h!ｅꁿ઻욄ښ\\u0002y?xUd\\u207c悜ꌭ\": [\n                                                                                                                                         1.6010824122815255E-19,\n                                                                                                                                         [\n                                                                                                                                          \"宨︩9앉檥pr쇷?WxLb\",\n                                                                                                                                          \"氇9】J玚\\u000f옛呲~ 輠1D嬛,*mW3?n휂糊γ虻*ᴫ꾠?q凐趗Ko↦GT铮\",\n                                                                                                                                          \"㶢ថmO㍔k'诔栀Z蛟}GZ钹D\",\n                                                                                                                                          false,\n                                                                                                                                          -6.366995517736813E-20,\n                                                                                                                                          -4894479530745302899,\n                                                                                                                                          null,\n                                                                                                                                          \"V%᫡II璅䅛䓎풹ﱢ/pU9se되뛞x梔~C)䨧䩻蜺(g㘚R?/Ự[忓C뾠ࢤc왈邠买?嫥挤풜隊枕\",\n                                                                                                                                          \",v碍喔㌲쟚蔚톬៓ꭶ\",\n                                                                                                                                          3.9625444752577524E-19,\n                                                                                                                                          null,\n                                                                                                                                          [\n                                                                                                                                           \"kO8란뿒䱕馔b臻⍟隨\\\"㜮鲣Yq5m퐔<u뷆c譆\\u001bN?<\",\n                                                                                                                                           [{\n                                                                                                                                            \";涉c蒀ᴧN䘱䤳 ÿꭷ,핉dSTDB>K#ꢘug㼈ᝦ=P^6탲@䧔%$CqSw铜랊0&m⟭<\\/a逎ym\\u0013vᯗ\": true,\n                                                                                                                                            \"洫`|XN뤮\\u0018詞=紩鴘_sX)㯅鿻Ố싹\": 7.168252736947373E-20,\n                                                                                                                                            \"ꛊ饤ﴏ袁(逊+~⽫얢鈮艬O힉7D筗S곯w操I斞᠈븘蓷x\": [[[[\n                                                                                                                                             -7.3136069426336952E18,\n                                                                                                                                             -2.13572396712722688E18,\n                                                                                                                                             {\n                                                                                                                                              \"硢3㇩R:o칢行E<=\\u0018ၬYuH!\\u00044U%卝炼2>\\u001eSi$⓷ꒈ'렢gᙫ番ꯒ㛹럥嶀澈v;葷鄕x蓎\\\\惩+稘UEᖸﳊ㊈壋N嫿⏾挎,袯苷ኢ\\\\x|3c\": 7540762493381776411,\n                                                                                                                                              \"?!*^ᢏ窯?\\u0001ڔꙃw虜돳FgJ?&⨫*uo籤:?}ꃹ=ٴ惨瓜Z媊@ત戹㔏똩Ԛ耦Wt轁\\\\枒^\\\\ꩵ}}}ꀣD\\\\]6M_⌫)H豣:36섘㑜\": {\n                                                                                                                                               \";홗ᰰU஋㙛`D왔ཿЃS회爁\\u001b-㢈`봆?盂㛣듿ᦾ蒽_AD~EEຆ㊋(eNwk=Rɠ峭q\\\"5Ἠ婾^>'ls\\n8QAK<l_⭨穟\": [\n                                                                                                                                                true,\n                                                                                                                                                true,\n                                                                                                                                                {\"ﳷm箅6qⷈ?ﲈ憟b۷⫉἞V뚴少U呡瓴ꉆs~嘵得㌶4XR漊\": [\n                                                                                                                                                 \"폆介fM暪$9K[ㄇ샍큳撦g撟恸jҐF㹹aj bHᘀ踉ꎐＣ粄 a?\\u000fK즉郝 幨9D舢槷Xh뵎u훩Ꜿ턾ƅ埂P埆k멀{䢹~?D<\\/꼢XR\\u001b〱䝽꼨i㘀ḟ㚺A-挸\",\n                                                                                                                                                 false,\n                                                                                                                                                 null,\n                                                                                                                                                 -1.1710758021294953E-20,\n                                                                                                                                                 3996737830256461142,\n                                                                                                                                                 true,\n                                                                                                                                                 null,\n                                                                                                                                                 -8271596984134071193,\n                                                                                                                                                 \"_1G퉁텑m䮔鰼6멲Nmꇩﬅ쓟튍N许FDj+3^ﶜ⎸\\u0019⤕橥!\\\"s-뾞lz北׸ꍚ랬)?l⻮고i䑰\\u001f䪬\",\n                                                                                                                                                 4.459124464204517E-19,\n                                                                                                                                                 -4.0967172848578447E18,\n                                                                                                                                                 5643211135841796287,\n                                                                                                                                                 -9.482336221192844E-19,\n                                                                                                                                                 \"౪冏釶9D?s螭X榈枸j2秀v]泌鰚岒聵轀쌶i텽qMbL]R,\",\n                                                                                                                                                 null,\n                                                                                                                                                 [\n                                                                                                                                                  null,\n                                                                                                                                                  {\"M쪊ꯪ@;\\u0011罙ꕅ<e᝺|爑Yⵝ<\\/&ᩎ<腊ሑᮔ੃F豭\": [\n                                                                                                                                                   \"^0࡟1볏P폋ፏ杈F⨥Iꂴ\\\"z磣VⅡ=8퀝2]䢹h1\\u0017{jT<I煛5%D셍S⑙⅏J*샐 巙ດ;᧡䙞\",\n                                                                                                                                                   [{\n                                                                                                                                                    \"'㶡큾鄧`跊\\\"gV[?u᭒Ʊ髷%葉굵a띦N켧Qﯳy%y䩟髒L䯜S䵳r絅肾킂ၐ'ꔦg긓a'@혔যW谁ᝬF栩ŷ+7w鞚\": 6.3544416675584832E17,\n                                                                                                                                                    \"苎脷v改hm쏵|㋊g_ᔐ 뒨蹨峟썎㷸|Ο刢?Gͨ옛-?GꦱIEYUX4?%ꘋᆊ㱺\": -2.8418378709165287E-19,\n                                                                                                                                                    \"誰?(H]N맘]k洳\\\"q蒧蘞!R퐫\\\\(Q$T5N堍⫣윿6|럦속︅ﭗ(\": [\n                                                                                                                                                     \"峩_\\u0003A瘘?✓[硫䎯ၽuጭ\\\"@Y綅첞m榾=贮9R벿῜Z\",\n                                                                                                                                                     null,\n                                                                                                                                                     \"䰉㗹㷾Iaᝃqcp쓘὾൫Q|ﵓ<\\/ḙ>)- Q䲌mo펹L_칍樖庫9꩝쪹ᘹ䑖瀍aK ?*趤f뭓廝p=磕\",\n                                                                                                                                                     \"哑z懅ᤏ-ꍹux쀭\",\n                                                                                                                                                     [\n                                                                                                                                                      true,\n                                                                                                                                                      3998739591332339511,\n                                                                                                                                                      \"ጻ㙙?᳸aK<\\/囩U`B3袗ﱱ?\\\"/k鏔䍧2l@쿎VZ쨎/6ꃭ脥|B?31+on颼-ꮧ,O嫚m ࡭`KH葦:粘i]aSU쓙$쐂f+詛頖b\",\n                                                                                                                                                      [{\"^<9<箝&絡;%i﫡2攑紴\\\\켉h쓙-柂䚝ven\\u20f7浯-Ꮏ\\r^훁䓚헬\\u000e?\\\\ㅡֺJ떷VOt\": [{\n                                                                                                                                                       \"-௄卶k㘆혐஽y⎱㢬sS઄+^瞥h;ᾷj;抭\\u0003밫f<\\/5Ⱗ裏_朻%*[-撵䷮彈-芈\": {\n                                                                                                                                                        \"㩩p3篊G|宮hz䑊o곥j^Co0\": [\n                                                                                                                                                         653239109285256503,\n                                                                                                                                                         {\"궲?|\\\":N1ۿ氃NZ#깩:쇡o8킗ࡊ[\\\"됸Po핇1(6鰏$膓}⽐*)渽J'DN<썙긘毦끲Ys칖\": {\n                                                                                                                                                          \"2Pr?Xjㆠ?搮/?㓦柖馃5뚣Nᦼ|铢r衴㩖\\\"甝湗ܝ憍\": \"\\\"뾯i띇筝牻$珲/4ka $匝휴译zbAᩁꇸ瑅&뵲衯ꎀᆿ7@ꈋ'ᶨH@ᠴl+\",\n                                                                                                                                                          \"7뢽뚐v?4^ꊥ_⪛.>pởr渲<\\/⢕疻c\\\"g䇘vU剺dஔ鮥꒚(dv祴X⼹\\\\a8y5坆\": true,\n                                                                                                                                                          \"o뼄B욞羁hr﷔폘뒚⿛U5pꪴfg!6\\\\\\\"爑쏍䢱W<ﶕ\\\\텣珇oI/BK뺡'谑♟[Ut븷亮g(\\\"t⡎有?ꬊ躺翁艩nl F⤿蠜\": 1695826030502619742,\n                                                                                                                                                          \"ۊ깖>ࡹ햹^ⵕ쌾BnN〳2C䌕tʬ]찠?ݾ2饺蹳ぶꌭ訍\\\"◹ᬁD鯎4e滨T輀ﵣ੃3\\u20f3킙D瘮g\\\\擦+泙ၧ 鬹ﯨַ肋7놷郟lP冝{ߒhড়r5,꓋\": null,\n                                                                                                                                                          \"ΉN$y{}2\\\\N﹯ⱙK'8ɜͣwt,．钟廣䎘ꆚk媄_\": null,\n                                                                                                                                                          \"䎥eᾆᝦ읉,Jުn岪㥐s搖謽䚔5t㯏㰳㱊ZhD䃭f絕s鋡篟a`Q鬃┦鸳n_靂(E4迠_觅뷝_宪D(NL疶hL追V熑%]v肫=惂!㇫5⬒\\u001f喺4랪옑\": {\n                                                                                                                                                           \"2a輍85먙R㮧㚪Sm}E2yꆣꫨrRym㐱膶ᔨ\\\\t綾A☰.焄뙗9<쫷챻䒵셴᭛䮜.<\\/慌꽒9叻Ok䰊Z㥪幸k\": [\n                                                                                                                                                            null,\n                                                                                                                                                            true,\n                                                                                                                                                            {\"쌞쐍\": {\n                                                                                                                                                             \"▟GL K2i뛱iＱ\\\"̠.옛1X$}涺]靎懠ڦ늷?tf灟ݞゟ{\": 1.227740268699265E-19,\n                                                                                                                                                             \"꒶]퓚%ฬK❅\": [{\n                                                                                                                                                              \"(ෛ@Ǯっ䧼䵤[aﾃൖvEnAdU렖뗈@볓yꈪ,mԴ|꟢캁(而첸죕CX4Y믅\": \"2⯩㳿ꢚ훀~迯?᪑\\\\啚;4X\\u20c2襏B箹)俣eỻw䇄\",\n                                                                                                                                                              \"75༂f詳䅫ꐧ鏿 }3\\u20b5'∓䝱虀f菼Iq鈆﨤g퍩)BFa왢d0뮪痮M鋡nw∵謊;ꝧf美箈ḋ*\\u001c`퇚퐋䳫$!V#N㹲抗ⱉ珎(V嵟鬒_b㳅\\u0019\": null,\n                                                                                                                                                              \"e_m@(i㜀3ꦗ䕯䭰Oc+-련0뭦⢹苿蟰ꂏSV䰭勢덥.ྈ爑Vd,ᕥ=퀍)vz뱊ꈊB_6듯\\\"?{㒲&㵞뵫疝돡믈%Qw限,?\\r枮\\\"? N~癃ruࡗdn&\": null,\n                                                                                                                                                              \"㉹&'Pfs䑜공j<\\/?|8oc᧨L7\\\\pXᭁ 9᪘\": -2.423073789014103E18,\n                                                                                                                                                              \"䝄瑄䢸穊f盈᥸,B뾧푗횵B1쟢f\\u001f凄\": \"魖⚝2儉j꼂긾껢嗎0ࢇ纬xI4](੓`蕞;픬\\fC\\\"斒\\\")2櫷I﹥迧\",\n                                                                                                                                                              \"ퟯ詔x悝령+T?Bg⥄섅kOeQ큼㻴*{E靼6氿L缋\\u001c둌๶-㥂2==-츫I즃㠐Lg踞ꙂEG貨鞠\\\"\\u0014d'.缗gI-lIb䋱ᎂDy缦?\": null,\n                                                                                                                                                              \"紝M㦁犿w浴詟棓쵫G:䜁?V2ힽ7N*n&㖊Nd-'ຊ?-樹DIv⊜)g䑜9뉂ㄹ푍阉~ꅐ쵃#R^\\u000bB䌎䦾]p.䀳\": [{\"ϒ爛\\\"ꄱ︗竒G䃓-ま帳あ.j)qgu扐徣ਁZ鼗A9A鸦甈!k蔁喙:3T%&㠘+,䷞|챽v䚞문H<\\/醯r셓㶾\\\\a볜卺zE䝷_죤ဵ뿰᎟CB\": [\n                                                                                                                                                               6233512720017661219,\n                                                                                                                                                               null,\n                                                                                                                                                               -1638543730522713294,\n                                                                                                                                                               false,\n                                                                                                                                                               -8901187771615024724,\n                                                                                                                                                               [\n                                                                                                                                                                3891351109509829590,\n                                                                                                                                                                true,\n                                                                                                                                                                false,\n                                                                                                                                                                -1.03836679125188032E18,\n                                                                                                                                                                {\n                                                                                                                                                                 \"<?起HCᷭ죎劐莇逰/{gs\\u0014⽛㰾愫tￖ<솞ڢ됌煲膺਻9x닳x࡭Q訽,ᶭඦtt掾\\\"秧㺌d˪䙻꫗:ᭈh4緞痐䤴c뫚떩త<?ᕢ謚6]폛O鰐鋛镠贩赟\\\"<G♷1'\": true,\n                                                                                                                                                                 \"቙ht4ߝBqꦤ+\\u0006멲趫灔)椾\": -1100102890585798710,\n                                                                                                                                                                 \"総兎곇뇸粟F醇;朠?厱楛㶆ⶏ7r⾛o꯬᳡F\\\\머幖 㜦\\f[搦᥽㮣0䕊?J㊳뀄e㔔+?<n↴复\": [\n                                                                                                                                                                  \"4~ꉍ羁\\\\偮(泤叕빜\\u0014>j랎:g曞ѕᘼ}链N\",\n                                                                                                                                                                  -1.1103819473845426E-19,\n                                                                                                                                                                  true,\n                                                                                                                                                                  [\n                                                                                                                                                                   true,\n                                                                                                                                                                   null,\n                                                                                                                                                                   -7.9091791735309888E17,\n                                                                                                                                                                   true,\n                                                                                                                                                                   {\"}蔰鋈+ꐨ啵0?g*사%`J?*\": [{\n                                                                                                                                                                    \"\\\"2wG?yn,癷BK\\\\龞䑞x?蠢\": -3.7220345009853505E-19,\n                                                                                                                                                                    \";饹়❀)皋`噿焒j(3⿏w>偍5X<np?<줯<Y]捘!J೸UⳂNे7v௸㛃ᄧ톿䨷鯻v焇=烻TQ!F⦰䣣눿K鷚눁'⭲m捠(䚻\": [\n                                                                                                                                                                     \"蹕 淜੃b\\\"+몾ⴕ\",\n                                                                                                                                                                     null,\n                                                                                                                                                                     35892237756161615,\n                                                                                                                                                                     {\n                                                                                                                                                                      \" 듹㏝)5慁箱&$~:遰쮐<\\/堋?% \\\\勽唅z손帋䘺H髀麡M퇖uz\\u0012m諦d᳤콌樝\\rX싹̡Ო\": -433791617729505482,\n                                                                                                                                                                      \"-j溗ࢵcz!:}✽5ഇ,욨ݏs#덫=南浺^}E\\\\Y\\\\T*뼈cd꺐cۘ뎁䨸됱K䠴㉿恿逳@wf쏢<\\/[L[\": -9.3228549642908109E17,\n                                                                                                                                                                      \"Ms킭u஗%\\\\u⍎/家欲ἅ答㓽/꯳齳|㭘Pr\\\"v<\\/禇䔆$GA䊻˔-:틊[h?倬荤ᾞ৳.Gw\\u000b\": [\n                                                                                                                                                                       \"0宜塙I@䏴蝉\\\\Uy뒅=2<h暒K._贡璐Yi檻_⮵uᐝ㘗聠[f\\u0015힢Hꔮ}጑;誏yf0\\\"\\u20cc?(=q斠➽5ꎾ鞘kⲃ\",\n                                                                                                                                                                       -2.9234211354411E-19,\n                                                                                                                                                                       false,\n                                                                                                                                                                       true,\n                                                                                                                                                                       {\n                                                                                                                                                                        \"\\u0011⟴GH_;#怵:\\u001c\\u0002n1U\\\\p/왔(┫]hꐚ7\\r0䵷첗岷O௷?㝎[殇|J=?韷pᶟ儜犆?5კ1kꍖiH竧뛈ପdmk游y(콪팱꾍k慧 y辣\": [\n                                                                                                                                                                         false,\n                                                                                                                                                                         \"O\\\"끍p覈ykv磂㢠㝵~뀬튍lC&4솎䇃:Mj\",\n                                                                                                                                                                         -7.009964654003924E-20,\n                                                                                                                                                                         false,\n                                                                                                                                                                         -49306078522414046,\n                                                                                                                                                                         null,\n                                                                                                                                                                         null,\n                                                                                                                                                                         2160432477732354319,\n                                                                                                                                                                         true,\n                                                                                                                                                                         \"4횡h+!踹ꐬP鮄{0&뱥M?샍鞅n㮞ᨹ?쒆毪l'箅^ꚥ頛`e㻨52柳⮙嫪࡟딯a.~䵮1f吘N&zȭL榓ۃ鳠5d㟆M@㣥ӋA΍q0縶$\",\n                                                                                                                                                                         -3.848996532974368E16,\n                                                                                                                                                                         true,\n                                                                                                                                                                         null,\n                                                                                                                                                                         -3.5240055580952525E18,\n                                                                                                                                                                         {\n                                                                                                                                                                          \" vﭷၵ#ce乃5僞?Z D`묨粇ᐔ绠vWL譢u뽀\\\\J|tⓙt№\\\"ꨋnT凮ᒩ蝂篝b騩:䢭Hbv읻峨z㹚T趗햆귣학津XiＹ@ᖥK\": true,\n                                                                                                                                                                          \"!F 醌y䉸W2ꇬ\\u0006/䒏7~%9擛햀徉9⛰+?㌘;ꠓX䇻Dfi뼧쒒\\u0012F謞՝絺+臕kऍLSQ쌁X쎬幦HZ98蒊枳\": \"澤令#\\u001d抍⛳@N搕퀂[5,✄ꘇ~䘷?\\u0011Xꈺ[硸⠘⛯X醪聡x\\u0007쌇MiX/|ﾐ뚁K8䁡W)銀q僞綂蔕E\",\n                                                                                                                                                                          \"6␲䣖R৞@ငg?<\\/೴x陙Xꈺ崸⠅ᇾ\\\\0X,H쟴셭A稂ힿゝF\\\\쑞\\u0012懦(Aᯕ灭~\\u0001껮X?逊\": 5.7566819207732864E17,\n                                                                                                                                                                          \"[c?椓\": false,\n                                                                                                                                                                          \"k䒇\": 2583824107104166717,\n                                                                                                                                                                          \"꙯N훙㏅ﮒ燣㨊瞯咽jMxby뻭뵫װ[\\\"1畈?ৱL\": \"띣ᔂ魠羓犴ꚃ+|rY\",\n                                                                                                                                                                          \"녺Z?䬝鉉:?ⳙ瘏Cኯ.Vs[釿䨉쐧\\\\\\\\*쵢猒$\\\\y溔^,㑳\": {\"藶꺟\": [{\n                                                                                                                                                                           \"\\\"d훣N2zq]?'檿죸忷篇ﮟ擤m'9!죶≓p뭻\\\\ᇷ\\f퇶_䰸h๐Q嵃訾㘑従ꯦ䞶jL틊r澵Omᾫ!H䱤팼/;|᭺I7슎YhuXi⚼\": -1.352716906472438E-19,\n                                                                                                                                                                           \"M⽇倻5J䂫औ᝔楸#J[Fﹱ쫮W誻bWz?}1\\\"9硪뻶fe\": \"盬:Ѹ砿획땣T凊(m灦呜ﻝR㿎艴䂵h\",\n                                                                                                                                                                           \"R띾k힪CH钙_i苮ⰵoᾨ紑퉎7h؉\\\"柀蝽z0့\\\"<?嘭$蜝?礲7岇槀묡?V钿T⣜v+솒灚ԛ2米mH?>薙婏聿3aFÆÝ\": \"2,ꓴg?_섦_>Y쪥션钺;=趘F~?D㨫\\bX?㹤+>/믟kᠪ멅쬂Uzỵ]$珧`m雁瑊ඖ鯬cꙉ梢f묛bB\",\n                                                                                                                                                                           \"♽n$YjKiXX*GO贩鏃豮祴遞K醞眡}ꗨv嵎꼷0୸+M菋eH徸J꣆:⼐悥B켽迚㯃b諂\\u000bjꠜ碱逮m8\": [\n                                                                                                                                                                            \"푷᣺ﻯd8ﱖ嬇ភH鹎⡱᱅0g:果6$GQ췎{vᷧYy-脕x偹砡館⮸C蓼ꏚ=軄H犠G谖ES詤Z蠂3l봟hￒ7䦹1GPQG癸숟~[#駥8zQ뛣J소obg,\",\n                                                                                                                                                                            null,\n                                                                                                                                                                            1513751096373485652,\n                                                                                                                                                                            null,\n                                                                                                                                                                            -6.851466660824754E-19,\n                                                                                                                                                                            {\"䩂-⴮2ٰK솖풄꾚ႻP앳1H鷛wmR䗂皎칄?醜<\\/&ࠧ㬍X濬䵈K`vJ륒Q/IC묛!;$vϑ\": {\n                                                                                                                                                                             \"@-ꚗxྐྵ@m瘬\\u0010U絨ﮌ驐\\\\켑寛넆T=tQ㭤L연@脸삯e-:⩼u㎳VQ㋱襗ຓ<Ⅶ䌸cML3+\\u001e_C)r\\\\9+Jn\\\\Pﺔ8蠱檾萅Pq鐳话T䄐I\": -1.80683891195530061E18,\n                                                                                                                                                                             \"ᷭዻU~ཷsgSJ`᪅'%㖔n5픆桪砳峣3獮枾䌷⊰呀\": {\n                                                                                                                                                                              \"Ş੉䓰邟自~X耤pl7间懑徛s첦5ਕXexh⬖鎥᐀nNr(J컗｜ૃF\\\"Q겮葲놔엞^겄+㈆话〾희紐G'E?飕1f❼텬悚泬먐U睬훶Qs\": false,\n                                                                                                                                                                              \"(\\u20dag8큽튣>^Y{뤋.袊䂓;_g]S\\u202a꽬L;^'#땏bႌ?C緡<䝲䲝断ꏏ6\\u001asD7IK5Wxo8\\u0006p弊⼂ꯍ扵\\u0003`뵂픋%ꄰ⫙됶l囏尛+䗅E쟇\\\\\": [\n                                                                                                                                                                               true,\n                                                                                                                                                                               {\n                                                                                                                                                                                \"\\n鱿aK㝡␒㼙2촹f;`쾏qIࡔG}㝷䐍瓰w늮*粅9뒪ㄊCj倡翑閳R渚MiUO~仨䜶RꙀA僈㉋⦋n{㖥0딿벑逦⥻0h薓쯴Ꝼ\": [\n                                                                                                                                                                                 5188716534221998369,\n                                                                                                                                                                                 2579413015347802508,\n                                                                                                                                                                                 9.010794400256652E-21,\n                                                                                                                                                                                 -6.5327297761238093E17,\n                                                                                                                                                                                 1.11635352494065523E18,\n                                                                                                                                                                                 -6656281618760253655,\n                                                                                                                                                                                 {\n                                                                                                                                                                                  \"\": \")?\",\n                                                                                                                                                                                  \"TWKLꑙ裑꺔UE俸塑炌Ũ᜕-o\\\"徚#\": {\"M/癟6!oI51ni퐚=댡>xꍨ\\u0004 ?\": {\n                                                                                                                                                                                   \"皭\": {\"⢫䋖>u%w잼<䕏꘍P䋵$魋拝U䮎緧皇Y훂&|羋ꋕ잿cJ䨈跓齳5\\u001a삱籷I꿾뤔S8㌷繖_Yឯ䲱B턼O歵F\\\\l醴o_欬6籏=D\": [\n                                                                                                                                                                                    false,\n                                                                                                                                                                                    true,\n                                                                                                                                                                                    {\"Mt|ꏞD|F궣MQ뵕T,띺k+?㍵i\": [\n                                                                                                                                                                                     7828094884540988137,\n                                                                                                                                                                                     false,\n                                                                                                                                                                                     {\n                                                                                                                                                                                      \"!༦鯠,&aﳑ>[euJꏽ綷搐B.h\": -7648546591767075632,\n                                                                                                                                                                                      \"-n켧嘰{7挐毄Y,>❏螵煫乌pv醑Q嶚!|⌝責0왾덢ꏅ蛨S\\\\)竰'舓Q}A釡5#v\": 3344849660672723988,\n                                                                                                                                                                                      \"8閪麁V=鈢1녈幬6棉⪮둌\\u207d᚛驉ꛃ'r䆉惏ै|bἧﺢᒙ<=穊强s혧eꮿ慩⌡ \\\\槳W븧J檀C,ᘉ의0俯퀉M;筷ࣴ瓿{늊埂鄧_4揸Nn阼Jੵ˥(社\": true,\n                                                                                                                                                                                      \"o뼀vw)4A뢵(a䵢)p姃뛸\\u000fK#KiQp\\u0005ꅍ芅쏅\": null,\n                                                                                                                                                                                      \"砥$ꥸ┇耽u斮Gc{z빔깎밇\\\\숰\\u001e괷各㶇쵿_ᴄ+h穢p촀Ნ䃬z䝁酳ӂ31xꔄ1_砚W렘G#2葊P \": [\n                                                                                                                                                                                       -3709692921720865059,\n                                                                                                                                                                                       null,\n                                                                                                                                                                                       [\n                                                                                                                                                                                        6669892810652602379,\n                                                                                                                                                                                        -135535375466621127,\n                                                                                                                                                                                        \"뎴iO}Z? 馢녱稹ᄾ䐩rSt帤넆&7i騏멗畖9誧鄜'w{Ͻ^2窭외b㑎粖i矪ꦨ탪跣)KEㆹ\\u0015V8[W?⽉>'kc$䨘ᮛ뉻٬M5\",\n                                                                                                                                                                                        1.10439588726055846E18,\n                                                                                                                                                                                        false,\n                                                                                                                                                                                        -4349729830749729097,\n                                                                                                                                                                                        null,\n                                                                                                                                                                                        [\n                                                                                                                                                                                         false,\n                                                                                                                                                                                         \"_蠢㠝^䟪/D녒㡋ỎC䒈판\\u0006એq@O펢%;鹐쏌o戥~A[ꡉ濽ỳ&虃᩾荣唙藍茨Ig楡꒻M窓冉?\",\n                                                                                                                                                                                         true,\n                                                                                                                                                                                         2.17220752996421728E17,\n                                                                                                                                                                                         -5079714907315156164,\n                                                                                                                                                                                         -9.960375974658589E-20,\n                                                                                                                                                                                         \"ᾎ戞༒\",\n                                                                                                                                                                                         true,\n                                                                                                                                                                                         false,\n                                                                                                                                                                                         [[\n                                                                                                                                                                                          \"ⶉᖌX⧕홇)g엃⹪x뚐癟\\u0002\",\n                                                                                                                                                                                          -5185853871623955469,\n                                                                                                                                                                                          {\n                                                                                                                                                                                           \"L㜤9ợㇶK鐰⋓V뽋˖!斫as|9＂፬䆪?7胜&n薑~\": -2.11545634977136992E17,\n                                                                                                                                                                                           \"O8뀩D}캖q萂6༣㏗䈓煮吽ਆᎼDᣘ폛;\": false,\n                                                                                                                                                                                           \"YTᡅ^L㗎cbY$pᣞ縿#fh!ꘂb삵玊颟샞ဢ$䁗鼒몁~rkH^:닮먖츸륈⪺쒉砉?㙓扫㆕꣒`R䢱B酂?C뇞<5Iޚ讳騕S瞦z\": null,\n                                                                                                                                                                                           \"\\\\RB?`mG댵鉡幐物䵎有5*e骄T㌓ᛪ琾駒Ku\\u001a[柆jUq8⋈5鿋츿myﻗ?雍ux঴?\": 5828963951918205428,\n                                                                                                                                                                                           \"n0晅:黯 xu씪^퓞cB㎊ᬍ⺘٤փ~B岚3㥕擄vᲂ~F?C䶖@$m~忔S왖㲚?챴⊟W#벌{'㰝I䝠縁s樘\\\\X뢻9핡I6菍ㄛ8쯶]wॽ0L\\\"q\": null,\n                                                                                                                                                                                           \"x增줖j⦦t䏢᎙㛿Yf鼘~꫓恄4惊\\u209c\": \"oOhbᤃ᛽z&Bi犑\\\\3B㩬劇䄑oŁ쨅孥멁ຖacA㖫借㞝vg싰샂㐜#譞⢤@k]鋰嘘䜾L熶塥_<\\/⍾屈ﮊ_mY菹t뙺}Ox=w鮮4S1ꐩמּ'巑\",\n                                                                                                                                                                                           \"㗓蟵ꂾe蠅匳(JP䗏෸\\u0089耀왲\": [{\n                                                                                                                                                                                            \"ᤃ㵥韎뤽\\r?挥O쯡⇔㞚3伖\\u0005P⋪\\\"D궣QLn(⚘罩䩢Ŏv䤘尗뼤됛O淽鋋闚r崩a{4箙{煷m6〈\": {\n                                                                                                                                                                                             \"l곺1L\": {\n                                                                                                                                                                                              \"T'ਤ?砅|੬Km]䄩\\\"(࿶<\\/6U爢䫈倔郴l2㴱^줣k'L浖L鰄Rp今鎗⒗C얨M훁㡧ΘX粜뫈N꤇輊㌻켑#㮮샶-䍗룲蠝癜㱐V>=\\\\I尬癤t=\": 7648082845323511446,\n                                                                                                                                                                                              \"鋞EP:<\\/_`ၧe混ㇹBd⯢㮂驋\\\\q碽饩跓྿ᴜ+j箿렏㗑yK毢宸p謹h䦹乕U媣\\\\炤\": [[\n                                                                                                                                                                                               \"3\",\n                                                                                                                                                                                               [\n                                                                                                                                                                                                true,\n                                                                                                                                                                                                3.4058271399411134E-20,\n                                                                                                                                                                                                true,\n                                                                                                                                                                                                \"揀+憱f逮@먻BpW曉\\u001a㣐⎊$n劈D枤㡞좾\\u001aᛁ苔౩闝1B䷒Ṋ݋➐ꀞꐃ磍$t੤_:蘺⮼(#N\",\n                                                                                                                                                                                                697483894874368636,\n                                                                                                                                                                                                [\n                                                                                                                                                                                                 \"vᘯ锴)0訶}䳅⩚0O壱韈ߜ\\u0018*U鍾䏖=䧉뽑单휻ID쿇嘗?ꌸῬ07\",\n                                                                                                                                                                                                 -5.4858784319382006E18,\n                                                                                                                                                                                                 7.5467775182251151E18,\n                                                                                                                                                                                                 -8911128589670029195,\n                                                                                                                                                                                                 -7531052386005780140,\n                                                                                                                                                                                                 null,\n                                                                                                                                                                                                 [\n                                                                                                                                                                                                  null,\n                                                                                                                                                                                                  true,\n                                                                                                                                                                                                  [[{\n                                                                                                                                                                                                   \"1欯twG<u䝮␽ꇣ_ჟﱴଶ-쪋\\\"?홺k:莝Ꜫ*⺵꽹댅釔좵}P?=9렿46b\\u001c\\\\S?(筈僦⇶爷谰1ྷa\": true,\n                                                                                                                                                                                                   \"TҫJYxڪ\\\\鰔℮혡)m_WVi眪1[71><\\/Q:0怯押殃탷聫사<ỗꕧ蚨䡁nDꌕ\\u001c녬~蓩<N蹑\\\"{䫥lKc혁뫖앺:vⵑ\": \"g槵?\",\n                                                                                                                                                                                                   \"aꨩ뻃싥렌1`롗}Yg>鲃g儊>ꏡl㻿/⑷*챳6㻜W毤緛ﹺᨪ4\\u0013뺚J髬e3쳸䘦伧?恪&{L掾p+꬜M䏊d娘6\": {\n                                                                                                                                                                                                    \"2p첼양棜h䜢﮶aQ*c扦v︥뮓kC寵횂S銩&ǝ{O*य़iH`U큅ࡓr䩕5ꄸ?`\\\\᧫?ᮼ?t〟崾훈k薐ì/ｉy꤃뵰z1<\\/AQ#뿩8jJ1z@u䕥\": 1.82135747285215155E18,\n                                                                                                                                                                                                    \"ZdN &=d년ᅆ'쑏ⅉ:烋5&៏ᄂ汎来L㯄固{钧u\\\\㊏튚e摑&t嗄ꖄUb❌?m䴘熚9EW\": [{\n                                                                                                                                                                                                     \"ଛ{i*a(\": -8.0314147546006822E17,\n                                                                                                                                                                                                     \"⫾ꃆY\\u000e+W`௸ \\\"M뒶+\\\\뷐lKE}(NT킶Yj選篒쁶'jNQ硾(똡\\\\\\\"逌ⴍy? IRꜘ὞鄬﨧:M\\\\f⠋Cꚜ쫊ᚴNV^D䕗ㅖἔIao꿬C⍏8\": [\n                                                                                                                                                                                                      287156137829026547,\n                                                                                                                                                                                                      {\n                                                                                                                                                                                                       \"H丞N逕<rO䎗:텕<\\/䶩샌Sd%^ᵯ눐엑者g䖩똭蕮1U驣?Pⰰ\\u001fp(W]67\\u0015﫣6굺OR羸#촐F蒈;嘙i✵@_撶y㤏⤍(:᧗뼢༌朆@⏰㤨ꭲ?-n>⯲\": {\"\": {\n                                                                                                                                                                                                        \"7-;枮阕梒9ᑄZ\": [[[[\n                                                                                                                                                                                                         null,\n                                                                                                                                                                                                         {\n                                                                                                                                                                                                          \"\": [[[[\n                                                                                                                                                                                                           -7.365909561486078E-19,\n                                                                                                                                                                                                           2948694324944243408,\n                                                                                                                                                                                                           null,\n                                                                                                                                                                                                           [\n                                                                                                                                                                                                            true,\n                                                                                                                                                                                                            \"荒\\\"并孷䂡쵼9o䀘F\\u0002龬7⮹Wz%厖/*? a*R枈㌦됾g뒠䤈q딄㺿$쮸tᶎ릑弣^鏎<\\/Y鷇驜L鿽<\\/춋9Mᲆឨ^<\\/庲3'l낢\",\n                                                                                                                                                                                                            \"c鮦\\u001b두\\\\~?眾ಢu݆綑෪蘛轋◜gȃ<\\/ⴃcpkDt誩܅\\\"Y\",\n                                                                                                                                                                                                            [[\n                                                                                                                                                                                                             null,\n                                                                                                                                                                                                             null,\n                                                                                                                                                                                                             [\n                                                                                                                                                                                                              3113744396744005402,\n                                                                                                                                                                                                              true,\n                                                                                                                                                                                                              \"v(y\",\n                                                                                                                                                                                                              {\n                                                                                                                                                                                                               \"AQ幆h쾜O+꺷铀ꛉ練A蚗⼺螔j㌍3꽂楎䥯뎸먩?\": null,\n                                                                                                                                                                                                               \"蠗渗iz鱖w]擪E\": 1.2927828494783804E-17,\n                                                                                                                                                                                                               \"튷|䀭n*曎b✿~杤U]Gz鄭kW|㴚#㟗ഠ8u擨\": [[\n                                                                                                                                                                                                                true,\n                                                                                                                                                                                                                null,\n                                                                                                                                                                                                                null,\n                                                                                                                                                                                                                {\"⾪壯톽g7?㥜ώQꑐ㦀恃㧽伓\\\\*᧰閖樧뢇赸N휶䎈pI氇镊maᬠ탷#X?A+kНM ༑᩟؝?5꧎鰜ṚY즫궔 =ঈ;ﳈ?*s|켦蜌wM笙莔\": [\n                                                                                                                                                                                                                 null,\n                                                                                                                                                                                                                 -3808207793125626469,\n                                                                                                                                                                                                                 [\n                                                                                                                                                                                                                  -469910450345251234,\n                                                                                                                                                                                                                  7852761921290328872,\n                                                                                                                                                                                                                  -2.7979740127017492E18,\n                                                                                                                                                                                                                  1.4458504352519893E-20,\n                                                                                                                                                                                                                  true,\n                                                                                                                                                                                                                  \"㽙깹?먏䆢:䴎ۻg殠JBTU⇞}ꄹꗣi#I뵣鉍r혯~脀쏃#釯:场:䔁>䰮o'㼽HZ擓௧nd\",\n                                                                                                                                                                                                                  [\n                                                                                                                                                                                                                   974441101787238751,\n                                                                                                                                                                                                                   null,\n                                                                                                                                                                                                                   -2.1647718292441327E-19,\n                                                                                                                                                                                                                   1.03602824249831488E18,\n                                                                                                                                                                                                                   [\n                                                                                                                                                                                                                    null,\n                                                                                                                                                                                                                    1.0311977941822604E-17,\n                                                                                                                                                                                                                    false,\n                                                                                                                                                                                                                    true,\n                                                                                                                                                                                                                    {\n                                                                                                                                                                                                                     \"\": -3.7019778830816707E18,\n                                                                                                                                                                                                                     \"E峾恆茍6xLIm縂0n2视֯J-ᤜz+ᨣ跐mYD豍繹⹺䊓몓ﴀE(@詮(!Y膽#᎙2䟓섣A䈀㟎,囪QbK插wcG湎ꤧtG엝x⥏俎j'A一ᯥ뛙6ㅑ鬀\": 8999803005418087004,\n                                                                                                                                                                                                                     \"よ殳\\\\zD⧅%Y泥簳Uꈩ*wRL{3#3FYHା[d岀䉯T稉駅䞘礄P:闈W怏ElB㤍喬赔bG䠼U଄Nw鰯闀楈ePsDꥷ꭬⊊\": [\n                                                                                                                                                                                                                      6.77723657904486E-20,\n                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                      [\n                                                                                                                                                                                                                       \"ཚ_뷎꾑蹝q'㾱ꂓ钚蘞慵렜떆`ⴹ⎼櫯]J?[t9Ⓢ !컶躔I᮸uz>3a㠕i,錃L$氰텰@7녫W㸮?羧W뇧ꃞ,N鋮숪2ɼ콏┍䁲6\",\n                                                                                                                                                                                                                       \"&y?뢶=킕올Za惻HZk>c\\u20b58i?ꦶcfBv잉ET9j䡡\",\n                                                                                                                                                                                                                       \"im珊Ճb칧<D-諂*u2ꡜ췛~䬢(텸ﵦ>校\\\\뼾쯀\",\n                                                                                                                                                                                                                       9.555715121193197E-20,\n                                                                                                                                                                                                                       true,\n                                                                                                                                                                                                                       {\n                                                                                                                                                                                                                        \"<㫚v6腓㨭e1㕔&&V∌ᗈT奄5Lጥ>탤?튣瑦㳆ꉰ!(ᙪ㿬擇_n쌯IMΉ㕨␰櫈ᱷ5풔蟹&L.첽e鰷쯃劼﫭b#ﭶ퓀7뷄Wr㢈๧Tʴશ㶑澕鍍%\": -1810142373373748101,\n                                                                                                                                                                                                                        \"fg晌o?߲ꗄ;>C>?=鑰監侯Kt굅\": true,\n                                                                                                                                                                                                                        \"䫡蓺ꑷ]C蒹㦘\\\"1ః@呫\\u0014NL䏾eg呮፳,r$裢k>/\\\\<z\": [[\n                                                                                                                                                                                                                         null,\n                                                                                                                                                                                                                         \"C䡏>?ㄤᇰﻛ쉕1஥'Ċ\\\" \\\\_?쨔\\\"ʾr: 9S䘏禺ᪧꄂ㲄\",\n                                                                                                                                                                                                                         [[{\n                                                                                                                                                                                                                          \"*硙^+E쌺I1䀖ju?:⦈Ꞓl๴竣迃xKC/饉:\\fl\\\"XTFﾨ蟭,芢<\\/骡軺띜hꏘ\\u001f銿<棔햳▨(궆*=乥b8\\\\媦䷀뫝}닶ꇭ(Kej䤑M\": [{\n                                                                                                                                                                                                                           \"1Ꮼ?>옿I╅C<ގ?ꊌ冉SV5A㢊㶆z-๎玶绢2F뵨@㉌뀌o嶔f9-庒茪珓뷳4\": null,\n                                                                                                                                                                                                                           \";lᰳ\": \"CbB+肻a䄷苝*/볳+/4fq=㰁h6瘉샴4铢Y骐.⌖@哼猎㦞+'gꋸ㒕ߤ㞑(䶒跲ti⑴a硂#No볔\",\n                                                                                                                                                                                                                           \"t?/jE幸YHT셵⩎K!Eq糦ꗣv刴w\\\"l$ο:=6:移\": {\n                                                                                                                                                                                                                            \"z]鑪醊嫗J-Xm銌翁絨c里됏炙Ep㣋鏣똼嚌䀓GP﹖cmf4鹭T䅿꣭姧␸wy6ꦶ;S&(}ᎧKxᾂQ|t뻳k\\\"d6\\\"|Ml췆hwLt꼼4$&8Պ褵婶鯀9\": {\"嵃닢ᒯ'd᧫䳳#NXe3-붋鸿ଢ떓%dK\\u0013䲎ꖍYV.裸R⍉rR3蟛\\\\:젯:南ĺLʆ넕>|텩鴷矔ꋅⒹ{t孶㓑4_\": [\n                                                                                                                                                                                                                             true,\n                                                                                                                                                                                                                             null,\n                                                                                                                                                                                                                             [\n                                                                                                                                                                                                                              false,\n                                                                                                                                                                                                                              \"l怨콈lᏒ\",\n                                                                                                                                                                                                                              {\n                                                                                                                                                                                                                               \"0w䲏嬧-:`䉅쉇漧\\\\܂yㄨb%㽄j7ᦶ涶<\": 3.7899452730383747E-19,\n                                                                                                                                                                                                                               \"ꯛTẀq纤q嶏V⿣?\\\"g}ი艹(쥯B T騠I=仵및X\": {\"KX6颠+&ᅃ^f畒y[\": {\n                                                                                                                                                                                                                                \"H?뱜^?꤂-⦲1a㋞&ꍃ精Ii᤾챪咽쬘唂쫷<땡劈훫놡o㥂\\\\ KⴙD秼F氮[{'좴:례晰Iq+I쭥_T綺砸GO煝䟪ᚪ`↹l羉q쐼D꽁ᜅ훦: vUV\": true,\n                                                                                                                                                                                                                                \"u^yﳍ0㱓#[y뜌앸ꊬL㷩?蕶蘾⻍KӼ\": -7931695755102841701,\n                                                                                                                                                                                                                                \"䤬轉車>\\u001c鴵惋\\\"$쯃྆⇻n뽀G氠S坪]ಲꨍ捇Qxኻ椕駔\\\\9ࣼ﫻읜磡煮뺪ᶚ볝l㕆t+sζ\": [[[\n                                                                                                                                                                                                                                 true,\n                                                                                                                                                                                                                                 false,\n                                                                                                                                                                                                                                 [\n                                                                                                                                                                                                                                  null,\n                                                                                                                                                                                                                                  3363739578828074923,\n                                                                                                                                                                                                                                  true,\n                                                                                                                                                                                                                                  {\n                                                                                                                                                                                                                                   \"\\\"鸣詩 볰㑵gL㯦῅춝旫}ED辗ﮈI쀤-ꧤ|㠦Z\\\"娑ᕸ4爏騍㣐\\\"]쳝Af]茛⬻싦o蚁k䢯䩐菽3廇喑ޅ\": 4.5017999150704666E17,\n                                                                                                                                                                                                                                   \"TYႇ7ʠ值4챳唤~Zo&ݛ\": false,\n                                                                                                                                                                                                                                   \"`塄J袛㭆끺㳀N㺣`꽐嶥KﯝSVᶔ∲퀠獾N딂X\\\"ᤏhNﬨvI\": {\"\\u20bb㭘I䖵䰼?sw䂷쇪](泒f\\\"~;꼪Fԝsᝦ\": {\"p,'ꉂ軿=A蚶?bƉ㏵䅰諬'LYKL6B깯⋩겦뎙(ᜭ\\u0006噣d꾆㗼Z;䄝䚔cd<情@䞂3苼㸲U{)<6&ꩻ钛\\u001au〷N숨囖愙j=BXW욕^x芜堏Ῑ爂뛷꒻t✘Q\\b\": [[\n                                                                                                                                                                                                                                    \"籛&ଃ䩹.ꃩ㦔\\\\C颫#暪&!勹ꇶ놽攺J堬镙~軌C'꾖䣹㮅岃ᙴ鵣\",\n                                                                                                                                                                                                                                    4.317829988264744E15,\n                                                                                                                                                                                                                                    6.013585322002147E-20,\n                                                                                                                                                                                                                                    false,\n                                                                                                                                                                                                                                    true,\n                                                                                                                                                                                                                                    null,\n                                                                                                                                                                                                                                    null,\n                                                                                                                                                                                                                                    -3.084633632357326E-20,\n                                                                                                                                                                                                                                    false,\n                                                                                                                                                                                                                                    null,\n                                                                                                                                                                                                                                    {\n                                                                                                                                                                                                                                     \"\\\"짫愔昻  X\\\"藣j\\\"\\\"먁ཅѻ㘤㬯0晲DU꟒㸃d벀윒l䦾c੻*3\": null,\n                                                                                                                                                                                                                                     \"谈Wm陧阦咟ฯ歖擓N喴㋐銭rCCnVࢥ^♼Ⅾ젲씗刊S༝+_t赔\\\\b䚍뉨ꬫ6펛cL䊘᜼<\\/澤pF懽&H\": [\n                                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                                      {\n                                                                                                                                                                                                                                       \"W\\\"HDUuΌ퀟M'P4࿰H똆ⰱﮯ<\\/凐蘲\\\"C鴫ﭒж}ꭩ쥾t5yd诪ﮡ퍉ⴰ@?氐醳rj4I6Qt\": 6.9090159359219891E17,\n                                                                                                                                                                                                                                       \"絛ﳛ⺂\": {\"諰P㗮聦`ZQ?ꫦh*റcb⧱}埌茥h{棩렛툽o3钛5鮁l7Q榛6_g)ὄ\\u0013kj뤬^爖eO4Ⱈ槞鉨ͺ订%qX0T썗嫷$?\\\\\\\"봅늆'%\": [\n                                                                                                                                                                                                                                        -2.348150870600346E-19,\n                                                                                                                                                                                                                                        [[\n                                                                                                                                                                                                                                         true,\n                                                                                                                                                                                                                                         -6619392047819511778,\n                                                                                                                                                                                                                                         false,\n                                                                                                                                                                                                                                         [[\n                                                                                                                                                                                                                                          -1.2929189982356161E-20,\n                                                                                                                                                                                                                                          1.7417192219309838E-19,\n                                                                                                                                                                                                                                          {\"?嵲2࿐2\\u0001啑㷳c縯\": [\n                                                                                                                                                                                                                                           null,\n                                                                                                                                                                                                                                           [\n                                                                                                                                                                                                                                            false,\n                                                                                                                                                                                                                                            true,\n                                                                                                                                                                                                                                            2578060295690793218,\n                                                                                                                                                                                                                                            {\n                                                                                                                                                                                                                                             \"?\\\"殃呎#㑑F\": true,\n                                                                                                                                                                                                                                             \"}F炊_殛oU헢兔Ꝉ,赭9703.B数gTz3⏬\": {\n                                                                                                                                                                                                                                              \"5&t3,햓Mݸᵣ㴵;꣫䩍↳#@뫷䠅+W-ࣇzᓃ鿕ಔ梭?T䮑ꥬ旴]u뫵막bB讍:왳둛lEh=숾鱠p咐$짏#?g⹷ᗊv㷵.斈u頻\\u0018-G.\": \"뽙m-ouࣤ஫牷\\\"`Ksꕞ筼3HlȨvC堈\\\"I]㖡玎r먞#'W賜鴇k'c룼髋䆿飉㗆xg巤9;芔cጐ/ax䊨♢큓r吓㸫೼䢗da᩾\\\"]屣`\",\n                                                                                                                                                                                                                                              \":M딪<䢥喠\\u0013㖅x9蕐㑂XO]ｆ*Q呰瞊吭VP@9,㨣 D\\\\穎vˤƩs㜂-曱唅L걬/롬j㈹EB8g<\\/섩o渀\\\"u0y&룣\": \">氍緩L/䕑돯Ꟙ蕞^aB뒣+0jK⪄瑨痜LXK^힦1qK{淚t츔X:Vm{2r獁B뾄H첚7氥?쉟䨗ꠂv팳圎踁齀\\\\\",\n                                                                                                                                                                                                                                              \"D彤5㢷Gꪻ[lㄆ@὜⓰絳[ଃ獽쮹☒[*0ꑚ㜳\": 9022717159376231865,\n                                                                                                                                                                                                                                              \"ҖaV銣tW+$魿\\u20c3亜~뫡ᙰ禿쨽㏡fṼzE/h\": \"5臐㋇Ჯ쮺? 昨탰Wﾑ밎#'\\\"崲钅U?幫뺀⍾@4kh>騧\\\\0ҾEV=爐͌U捀%ꉼ 㮋<{j]{R>:gԩL\\u001c瀈锌ﯲﳡꚒ'⫿E4暍㌗뵉X\\\"H᝜\",\n                                                                                                                                                                                                                                              \"ᱚגּ;s醒}犍SἿ㦣&{T$jkB\\\\\\tḮ앾䤹o<避(tW\": \"vb⯽䴪䮢@|)\",\n                                                                                                                                                                                                                                              \"⥒퐁껉%惀뗌+녣迺顀q條g⚯i⤭룐M琹j̈́⽜A\": -8385214638503106917,\n                                                                                                                                                                                                                                              \"逨ꊶZ<\\/W⫟솪㎮ᘇb?ꠔi\\\"H㧺x෷韒Xꫨฟ|]窽\\u001a熑}Agn?Mᶖa<rఄ4Ů䢤슲Axģe곖㴤x竾郍B謉鸵k薽M)\\\"芣眜`菉ꉛ䴺\": \"鹏^ె캫?3耲]|Ü1䡒㝮]8e?䶍^\",\n                                                                                                                                                                                                                                              \"뿸樅#P㡊1M룮Uꪭ绢ꑮZ9꽸\": {\"\\nJ^є|3袄ㅐ7⨆銦y睝⋷仴ct?[,<\\/ㅬ`?갔髞%揁A೚C\": {\n                                                                                                                                                                                                                                               \" 䇞3갫䅪\": [{\n                                                                                                                                                                                                                                                \"0|⩁㑂砕ㅻ\": null,\n                                                                                                                                                                                                                                                \"D箳᠉`|=⼭)\\\"*࣊㦏LjO誋\": \"\",\n                                                                                                                                                                                                                                                \"ࠚǱmꗥ}ᷴ╈r7헴ȥ4Kp5a)o}鎘门L搰䆓'✎k俎c#T68ӏ⩶6L鎴<r൦$黊BQY㼳\\\\跿F慮⡨拵贀!甶V喅/\": null,\n                                                                                                                                                                                                                                                \"ⵣq⳹ﻨLk]晩1*y\\\\$%}䖶P煑㇆䈦E嫁櫕Y࣓嫨䓏OL낮梚㸇洛洚BYtgl∛S☕䉓宑⋢粚ꔯ꠼붠\": \")ꬑ윤`\\\"Ⱓ<\\/婽*Y䔸ᓰ_ﳍt슲坩隥&S糧䛮闵诌豐sh쯽邴*섴؏͎=㯨\\\"RVힳ,^t\\\"ac?䤒ꉀxHa=Uꛕ㐙TkF껾\",\n                                                                                                                                                                                                                                                \"弾cUAF?暤c덽.欀nK앭]r傊䀓ﯳ馽垃[䥛oI0N砊鈥헅Co쟋钄ㅷ㊌뷚7\": [\n                                                                                                                                                                                                                                                 null,\n                                                                                                                                                                                                                                                 \"૓鏨?^䆏{\\u0006`X䧵儱&롡尙砡\\u0006뻝쑬sj▻XfᬶgcㄢV >9韲4$3Ỵ^=쏍煤ፐ돷2䣃%鷠/eQ9頸쥎\",\n                                                                                                                                                                                                                                                 2398360204813891033,\n                                                                                                                                                                                                                                                 false,\n                                                                                                                                                                                                                                                 3.2658897259932633E-19,\n                                                                                                                                                                                                                                                 null,\n                                                                                                                                                                                                                                                 \"?ꚃ8Nn㞷幵d䲳䱲뀙ꪛQ瑓鎴]䩋-鰾捡䳡??掊\",\n                                                                                                                                                                                                                                                 false,\n                                                                                                                                                                                                                                                 -1309779089385483661,\n                                                                                                                                                                                                                                                 \"ᦲxu_/yecR.6芏.ᜇ過 ~\",\n                                                                                                                                                                                                                                                 -5658779764160586501,\n                                                                                                                                                                                                                                                 \"쒌:曠=l썜䢜wk#s蕚\\\"互㮉m䉤~0듐䋙#G;h숄옥顇෤勹(C7㢅雚㐯L⠅VV簅<\",\n                                                                                                                                                                                                                                                 null,\n                                                                                                                                                                                                                                                 -4.664877097240962E18,\n                                                                                                                                                                                                                                                 -4.1931322262828017E18,\n                                                                                                                                                                                                                                                 {\n                                                                                                                                                                                                                                                  \",\": {\n                                                                                                                                                                                                                                                   \"v㮟麑䄠뤵g{M띮.\\u001bzt뢜뵡0Ǥ龍떟Ᾰ怷ϓRT@Lꀌ樂U㏠⾕e扉|bJg(뵒㠶唺~ꂿ(땉x⻫싉쁊;%0鎻V(o\\f,N鏊%nk郼螺\": -1.73631993428376141E18,\n                                                                                                                                                                                                                                                   \"쟧摑繮Q@Rᕾ㭚㾣4隅待㓎3蒟\": [\n                                                                                                                                                                                                                                                    4971487283312058201,\n                                                                                                                                                                                                                                                    8973067552274458613,\n                                                                                                                                                                                                                                                    {\n                                                                                                                                                                                                                                                     \"`a揙ᣗ\\u0015i<S幼訃锭B0&槩✨[Wp皩[g≊k葾x2ᡆ橲䲢W\": true,\n                                                                                                                                                                                                                                                     \"kH皈Sꁱq傑u?솹풑~o^F=劣N*reJ沤wW苯7p㼹䎐a=ꮧL㷩냴nWꌑ㞱uu谁lVN珿᤻(e豶5#L쪉ᅄ઄\\u0015숟봊P瀚X蓎\": false,\n                                                                                                                                                                                                                                                     \"䫯דּ〖Sc䛭점L뵾pCꙞ\\\"엇즓_ﰛ톣ꫀ먩㺣㮠⭴!\\\\W┏t䖰軅y\\u0014~ᇰ렢E7*俜䥪W䀩䷐h봆vjஉ묣༏G39.뼳輼:㮿ᐦA饕TUL}~\": [\n                                                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                                                      8.8648298810470003E17,\n                                                                                                                                                                                                                                                      5.735561205600924E-20,\n                                                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                                                      -102555823658171644,\n                                                                                                                                                                                                                                                      1.2674932032973067E-19,\n                                                                                                                                                                                                                                                      {\n                                                                                                                                                                                                                                                       \"D胣O㯨\\u0017Ku눓㒏텁nᨊ!Ꚇ廫_>Bo¸\": 4.3236479112537999E18,\n                                                                                                                                                                                                                                                       \"HW&퉡ぁ圍<W)6悰ꠑHEp14xy峑ft\\u0005s亘V튉䢮ꦈX嵐꬝?lI_덝춇-6Ss噺Nk-ﮥ큃܁郪*PR(S6╋@仙V懸뺵ﯜV粹\": \"9䗌斀4㐈^Qs隄硏j\\u0003\",\n                                                                                                                                                                                                                                                       \"Vk鶅C泹筁HX훉朗*r\\\\z顊誌儖4?n7᏾6몋䎡ﳈ],H頢p蚐㑄P4满E䏩V䬕ญL廂쒬쑨ꆷh迡ꍰ譖墎 ]鹿ฌ7ﶽ冭༽<ꈓS\\\\l䋮?_ﾕ檒?\": -8598528325153980065,\n                                                                                                                                                                                                                                                       \"t=q퍣疻тZ\\\\錅J.镎|nfḷ鴒1厰L灯纜E]୦⥪]Ꮾ'羝p/咩0닳ﳁqﳖཽk ?X1Ft%ś뭢v鋋⺃爵⒗\": [[\n                                                                                                                                                                                                                                                        5.0824756359232045E-19,\n                                                                                                                                                                                                                                                        [\n                                                                                                                                                                                                                                                         7.268480839079619E-19,\n                                                                                                                                                                                                                                                         {\"탿^굞⧕iј덊ꀛw껩6ꟳXs酚\\\\>Y?瑡Qy훍q!帰敏s舠㫸zꚗaS歲v`G株巷Jp6킼 (귶鍔⾏⡈>M汐㞍ቴ꙲dv@i㳓ᇆ?黍\": [\n                                                                                                                                                                                                                                                          null,\n                                                                                                                                                                                                                                                          4997607199327183467,\n                                                                                                                                                                                                                                                          \"E㻎蠫ᐾ高䙟蘬洼旾﫠텛㇛?'M$㣒蔸=A_亀绉앭rN帮\",\n                                                                                                                                                                                                                                                          null,\n                                                                                                                                                                                                                                                          [{\n                                                                                                                                                                                                                                                           \"Eᑞ)8<Z㡿W镀䛒C생V?0ꯦ+tL)`齳AjB姀XೳD빠㻲ƙgn9⑰ྍ῜&\\\"㚹>餧A5u&㗾q?\": [\n                                                                                                                                                                                                                                                            -1.969987519306507E-19,\n                                                                                                                                                                                                                                                            null,\n                                                                                                                                                                                                                                                            [\n                                                                                                                                                                                                                                                             3.42437673373841E-20,\n                                                                                                                                                                                                                                                             true,\n                                                                                                                                                                                                                                                             \"e걷M墁\\\"割P␛퍧厀R䱜3ﻴO퓫r﹉⹊\",\n                                                                                                                                                                                                                                                             [\n                                                                                                                                                                                                                                                              -8164221302779285367,\n                                                                                                                                                                                                                                                              [\n                                                                                                                                                                                                                                                               true,\n                                                                                                                                                                                                                                                               null,\n                                                                                                                                                                                                                                                               \"爘y^-?蘞Ⲽꪓa␅ꍨ}I\",\n                                                                                                                                                                                                                                                               1.4645984996724427E-19,\n                                                                                                                                                                                                                                                               [{\n                                                                                                                                                                                                                                                                \"tY좗⧑mrzﺝ㿥ⴖ᥷j諅\\u0000q賋譁Ꞅ⮱S\\nࡣB/큃굪3Zɑ复o<\\/;롋\": null,\n                                                                                                                                                                                                                                                                \"彟h浠_|V4䦭Dᙣ♞u쿻=삮㍦\\u001e哀鬌\": [{\"6횣楠,qʎꗇ鎆빙]㱭R굋鈌%栲j分僅ペ䇰w폦p蛃N溈ꡐꏀ?@(GI뉬$ﮄ9誁ꓚ2e甸ڋ[䁺,\\u0011\\u001cࢃ=\\\\+衪䷨ᯕ鬸K\": [[\n                                                                                                                                                                                                                                                                 \"ㅩ拏鈩勥\\u000etgWVXs陂規p狵w퓼{뮵_i\\u0002ퟑႢ⬐d6鋫F~챿搟\\u0096䚼1ۼ칥0꣯儏=鋷牋ⅈꍞ龐\",\n                                                                                                                                                                                                                                                                 -7283717290969427831,\n                                                                                                                                                                                                                                                                 true,\n                                                                                                                                                                                                                                                                 [\n                                                                                                                                                                                                                                                                  4911644391234541055,\n                                                                                                                                                                                                                                                                  {\n                                                                                                                                                                                                                                                                   \"I鈒첽P릜朸W徨觘-Hᎄ퐟⓺>8kr1{겵䍃〛ᬡ̨O귑o䝕'쿡鉕p5\": \"fv粖RN瞖蛐a?q꤄\\u001d⸥}'ꣴ犿ꦼ?뤋?鵆쥴덋䡫s矷̄?ඣ/;괱絢oWfV<\\/\\u202cC,㖦0䑾%n賹g&T;|ǉ_欂N4w\",\n                                                                                                                                                                                                                                                                   \"짨䠗;䌕u i+r๏0\": [{\"9䥁\\\\఩8\\\"馇z䇔<\\/ႡY3e狚쐡\\\"ุ6ﰆZ遖c\\\"Ll:ꮾ疣<\\/᭙Ｏ◌납୕湞9⡳Und㫜\\u0018^4pj1;䧐儂䗷ୗ>@e톬\": {\n                                                                                                                                                                                                                                                                    \"a⑂F鋻Q螰'<퇽Q贝瀧{ᘪ,cP&~䮃Z?gＩ彃\": [\n                                                                                                                                                                                                                                                                     -1.69158726118025933E18,\n                                                                                                                                                                                                                                                                     [\n                                                                                                                                                                                                                                                                      \"궂z簽㔛㮨瘥⤜䛖Gℤ逆Y⪾j08Sn昞ꘔ캻禀鴚P謦b{ꓮmN靐Mᥙ5\\\"睏2냑I\\u0011.L&=?6ᄠ뻷X鸌t刑\\\"#z)o꫚n쳟줋\",\n                                                                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                                                                      7517598198523963704,\n                                                                                                                                                                                                                                                                      \"ኑQp襟`uᩄr方]*F48ꔵn俺ሙ9뇒\",\n                                                                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                                                                      6645782462773449868,\n                                                                                                                                                                                                                                                                      1219168146640438184,\n                                                                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                                                                      {\n                                                                                                                                                                                                                                                                       \")ယ넌竀Sd䰾zq⫣⏌ʥ\\u0010ΐ' |磪&p牢蔑mV蘸૰짬꺵;K\": [\n                                                                                                                                                                                                                                                                        -7.539062290108008E-20,\n                                                                                                                                                                                                                                                                        [\n                                                                                                                                                                                                                                                                         true,\n                                                                                                                                                                                                                                                                         false,\n                                                                                                                                                                                                                                                                         null,\n                                                                                                                                                                                                                                                                         true,\n                                                                                                                                                                                                                                                                         6574577753576444630,\n                                                                                                                                                                                                                                                                         [[\n                                                                                                                                                                                                                                                                          1.2760162530699766E-19,\n                                                                                                                                                                                                                                                                          [\n                                                                                                                                                                                                                                                                           null,\n                                                                                                                                                                                                                                                                           [\n                                                                                                                                                                                                                                                                            \"顊\\\\憎zXB,\",\n                                                                                                                                                                                                                                                                            [{\n                                                                                                                                                                                                                                                                             \"㇆{CVC9－MN㜋ઘR눽#{h@ퟨ!鼚׼XOvXS\\u0017ᝣ=cS+梽៲綆16s덽휐y屬?ᇳG2ᴭ\\u00054쫖y룇nKcW̭炦s/鰘ᬽ?J|퓀髣n勌\\u0010홠P>j\": false,\n                                                                                                                                                                                                                                                                             \"箴\": [\n                                                                                                                                                                                                                                                                              false,\n                                                                                                                                                                                                                                                                              \"鍞j\\\"ꮾ*엇칬瘫xṬ⭽쩁䃳\\\"-⋵?ᦽ<cਔ↎⩧%鱩涎삧u9K⦈\\\"῝ᬑV绩킯愌ṱv@GꝾ跶Ꚇ(?䖃vI᧊xV\\r哦j㠒?*=S굤紴ꊀ鹭쬈s<DrIu솹꧑?\",\n                                                                                                                                                                                                                                                                              {\n                                                                                                                                                                                                                                                                               \".}S㸼L?t\\u000fK⑤s~hU鱜꘦}쪍C滈4ꓗ蛌):ྦ\\\"顥이⢷ῳYLn\\\"?fꘌ>댎Ĝ\": true,\n                                                                                                                                                                                                                                                                               \"Pg帯佃籛n㔠⭹࠳뷏≻࿟3㞱!-쒾!}쭪䃕!籿n涻J5ਲ਼yvy;Rኂ%ᔡጀ裃;M⣼)쵂쑈\": 1.80447711803435366E18,\n                                                                                                                                                                                                                                                                               \"ꈑC⡂ᑆ㤉壂뎃Xub<\\/쀆༈憓ق쨐ק\\\\\": [\n                                                                                                                                                                                                                                                                                7706977185172797197,\n                                                                                                                                                                                                                                                                                {\"\": {\"K╥踮砆NWࡆFy韣7ä밥{|紒︧䃀榫rᩛꦡTSy잺iH8}ퟴ,M?Ʂ勺ᴹ@T@~꾂=I㙕뾰_涀쑜嫴曣8IY?ҿo줫fऒ}\\\\S\\\"ᦨ뵼#nDX\": {\n                                                                                                                                                                                                                                                                                 \"♘k6?଱癫d68?㽚乳䬳-V顷\\u0005蝕?\\u0018䞊V{邾zじl]雏k臤~ൖH뒐iꢥ]g?.G碄懺䔛p<q꜉S岗_.%\": 7688630934772863849,\n                                                                                                                                                                                                                                                                                 \"溗摽嗙O㧀,⡢⼰呠ꅧ㓲/葇䢛icc@-r\\b渂ꌳ뻨饑觝ᖜ\\\\鮭\\u0014엙㥀᧺@浹W2꛵{W률G溮킀轡䬆g㨑'Q聨៪网Hd\\\"Q늴ᱢﶨ邮昕纚枑?▰hr羌驀[痹<\\/\": [\n                                                                                                                                                                                                                                                                                  -1.0189902027934687E-19,\n                                                                                                                                                                                                                                                                                  {\"窶椸릎뚻shE\\\"ꪗႥꎳU矖佟{SJ\": [{\"-慜x櫹XY-澐ܨ⣷ઢ鯙%Fu\\u0000迋▒}᥷L嗭臖oញc넨\\u0016/迎1b꯸g뢱㐧蓤䒏8C散삭|\\\"컪輩鹩\\\"\\\\g$zG䥽긷?狸꿭扵㲐:URON&oU8\": [\n                                                                                                                                                                                                                                                                                   null,\n                                                                                                                                                                                                                                                                                   true,\n                                                                                                                                                                                                                                                                                   null,\n                                                                                                                                                                                                                                                                                   -2.8907335031148883E17,\n                                                                                                                                                                                                                                                                                   -3864019407187144121,\n                                                                                                                                                                                                                                                                                   {\n                                                                                                                                                                                                                                                                                    \"`빬d⵺4H뜳⧈쓑ohஸ*㶐ﻇ⸕䠵!i䝬﹑h夘▥ꗐ푹갇㵳TA鳠嚵\\\\B<X}3訒c⋝{*﫢w]璨-g捭\\\\j໵侠Ei层\\u0011\": 3.758356090089446E-19,\n                                                                                                                                                                                                                                                                                    \"䄘ﮐ)Y놞씃㾱陰큁:{\\u2059/S⓴\": [[\n                                                                                                                                                                                                                                                                                     null,\n                                                                                                                                                                                                                                                                                     [[\n                                                                                                                                                                                                                                                                                      -3.8256602120220546E-20,\n                                                                                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                                                                                      7202317607724472882,\n                                                                                                                                                                                                                                                                                      \"CWQ뚿\",\n                                                                                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                                                                                      false,\n                                                                                                                                                                                                                                                                                      true,\n                                                                                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                                                                                      2857038485417498625,\n                                                                                                                                                                                                                                                                                      6.191302233218633E-20,\n                                                                                                                                                                                                                                                                                      null,\n                                                                                                                                                                                                                                                                                      -6795250594296208046,\n                                                                                                                                                                                                                                                                                      [\n                                                                                                                                                                                                                                                                                       true,\n                                                                                                                                                                                                                                                                                       {\n                                                                                                                                                                                                                                                                                        \"%ዧ遰Yᚯ⚀x莰愒Vᔈ턗BN洝ꤟA1⍌l콹풪H;OX๫륞쪐ᰚц@͎黾a邬<L厒Xb龃7f웨窂二;\": [[\n                                                                                                                                                                                                                                                                                         null,\n                                                                                                                                                                                                                                                                                         \"耲?䙧㘓F6Xs틭멢.v뚌?鄟恠▽'묺競?WvᆾCtxo?dZ;䨸疎\",\n                                                                                                                                                                                                                                                                                         {\n                                                                                                                                                                                                                                                                                          \"@hWꉁ&\\\"빜4礚UO~C;う殩_ꀥ蘁奢^챟k→ᡱKMⵉ<\\/Jㅲ붉L͟Q\": false,\n                                                                                                                                                                                                                                                                                          \"tU뢂8龰I먽7,.Y搽Z툼=&⨥覽K乫햶㠸%#@Z끖愓^⍊⾂몒3E_噆J(廊ឭyd䞜鈬Ћ档'⣘I\": {\n                                                                                                                                                                                                                                                                                           \"tK*ꔵ銂u艗ԃ쿏∳ꄂ霫X3♢9y?=ⲭdЊb&xy}\": [\n                                                                                                                                                                                                                                                                                            -4.097346784534325E-20,\n                                                                                                                                                                                                                                                                                            null,\n                                                                                                                                                                                                                                                                                            6016848468610144624,\n                                                                                                                                                                                                                                                                                            -8194387253692332861,\n                                                                                                                                                                                                                                                                                            null,\n                                                                                                                                                                                                                                                                                            {\n                                                                                                                                                                                                                                                                                             \"(祬诀譕쯠娣c봝r?畄kT뼾⌘⎨?noV䏘쥝硎n?\": [\n                                                                                                                                                                                                                                                                                              1.82679422844617293E18,\n                                                                                                                                                                                                                                                                                              [\n                                                                                                                                                                                                                                                                                               false,\n                                                                                                                                                                                                                                                                                               2.6849944122427694E18,\n                                                                                                                                                                                                                                                                                               true,\n                                                                                                                                                                                                                                                                                               [\n                                                                                                                                                                                                                                                                                                false,\n                                                                                                                                                                                                                                                                                                {\n                                                                                                                                                                                                                                                                                                 \";0z⭆;화$bਔ瀓\\\"衱^?잢ᢛ⣿~`ꕉ薸⌳໿湘腌'&:ryБꋥၼ꒥筙꬜긨?X\": -3536753685245791530,\n                                                                                                                                                                                                                                                                                                 \"c;Y7釚Uꃣ割J༨Y戣w}c峰뢨㽑㫈0N>R$䅒X觨l봜A刊8R梒',}u邩퉕?;91Ea䈈믁G⊶芔h袪&廣㺄j;㡏綽\\u001bN頸쳘橆\": -2272208444812560733,\n                                                                                                                                                                                                                                                                                                 \"拑Wﵚj鵼駳Oࣿ)#㾅顂N傓纝y僱栜'Bꐍ-!KF*ꭇK￤?䈴^:啤wG逭w᧯\": \"xᣱmYe1ۏ@霄F$ě꧘푫O䤕퀐Pq52憬ꀜ兴㑗ᡚ?L鷝ퟐ뭐zJꑙ}╆ᅨJB]\\\"袌㺲u8䯆f\",\n                                                                                                                                                                                                                                                                                                 \"꿽၅㔂긱Ǧ?SI\": -1669030251960539193,\n                                                                                                                                                                                                                                                                                                 \"쇝ɨ`!葎>瞺瘡驷錶❤ﻮ酜=\": -6961311505642101651,\n                                                                                                                                                                                                                                                                                                 \"?f7♄꫄Jᡔ훮e읇퍾፣䭴KhखT;Qty}O\\\\|뫁IῒNe(5惁ꥶㆷY9ﮡ\\\\ oy⭖-䆩婁m#x봉>Y鈕E疣s驇↙ᙰm<\": {\"퉻:dꂁ&efￎ쫢[\\\"돈늖꺙|Ô剐1͖-K:ʚ᭕/;쏖㷛]I痐职4g<Oꗢ뫺N쯂륬J╆.`ᇵP轆&fd$?苅o궓vO侃沲⍩嚅沗 E%⿰얦wi\\\\*趫\": [\n                                                                                                                                                                                                                                                                                                  3504362220185634767,\n                                                                                                                                                                                                                                                                                                  false,\n                                                                                                                                                                                                                                                                                                  \"qzX朝qT3軞T垈ꮲQ览ᚻ⻑쎎b驌䵆ꬠ5Fୗ䲁缿ꝁ蒇潇Ltᆄ钯蜀W欥ሺ\",\n                                                                                                                                                                                                                                                                                                  \"볰ɐ霬)젝鶼kwoc엷荁r \\u001d쒷⎹8{%澡K늒?iﺩd=&皼倚J9s@３偛twὡgj䁠흪5⭉⨺役&놎cﺉ㺡N5\",\n                                                                                                                                                                                                                                                                                                  false,\n                                                                                                                                                                                                                                                                                                  null,\n                                                                                                                                                                                                                                                                                                  \"D0ﬆ[ni锹r*0k6ꀎ덇UX2⽼৞䃚粭#)Z桷36P]<\\/`\",\n                                                                                                                                                                                                                                                                                                  4281410120849816730,\n                                                                                                                                                                                                                                                                                                  null,\n                                                                                                                                                                                                                                                                                                  -3256922126984394461,\n                                                                                                                                                                                                                                                                                                  1.16174580369801549E18,\n                                                                                                                                                                                                                                                                                                  {\n                                                                                                                                                                                                                                                                                                   \" ᆼꤗ~*TN긂<㡴턱℃酰^蘒涯잰淭傛2rൡet쾣䐇m*㸏y\\\"\\\\糮᧺qv쌜镜T@yg1譬ﭧﳭ\\f\": null,\n                                                                                                                                                                                                                                                                                                   \"圾ᨿ0xᮛ禵ਗ਼D-㟻ẵ錚e\\\"赜.˶m)鴑B(I$<\\/轴퉯揷⋏⏺*)宓쓌?*橯Lx\\\\f쩂㞼⇸\\\"ﺧ軂遳V\\\\땒\\\"캘c:G\": null,\n                                                                                                                                                                                                                                                                                                   \"?﵁_곢翸폈8㿠h열Q2㭛}RY㯕ＹT놂⽻e^B<\\/맫ﻇ繱\\u0017Gц⟊ᢑﵩS:jt櫣嗒⟰W㴚搦ᅉe[w䋺?藂翙Ⲱ芮䍘╢囥lpdu7r볺I 近qFyᗊ\": [\n                                                                                                                                                                                                                                                                                                    \"$b脬aﾠ襬育Bگ嵺Pw+'M<\\/כֿn䚚v螁bN⒂}褺%lቦ阤\\\"ꓺᏗM牏,۞Ҷ!矬?ke9銊X괦)䈽틁脽ṫ䈞ᴆ^=Yᗿ遛4I귺⋥%\",\n                                                                                                                                                                                                                                                                                                    false,\n                                                                                                                                                                                                                                                                                                    2.9444482723232051E18,\n                                                                                                                                                                                                                                                                                                    2072621064799640026,\n                                                                                                                                                                                                                                                                                                    \"/_뇴뫢j㍒=Nꡦ↍Ժ赒❬톥䨞珯su*媸瀳鷔抡o흺-៳辏勷f绔:䵢搢2\",\n                                                                                                                                                                                                                                                                                                    false,\n                                                                                                                                                                                                                                                                                                    \"쒜 E䌐/큁\\u0018懺_<\\\\隺&{wF⤊谼(<죽遠8?@*rᶊGd뻻갇&Ⳇq᣿e࢔t_ꩄ梸O詬C᧧Kꩠ풤9눙醅됞}竸rw?滨ӽK⥿ཊG魲']`๖5㄰\",\n                                                                                                                                                                                                                                                                                                    -2375253967958699084,\n                                                                                                                                                                                                                                                                                                    {\"嗱⿲\\\"f億ᝬ\": {\"v?䚑킡`◤k3,骥曘뒤Oᒱ㲹^圮᠀YT껛&촮P:G/T⣝#튣k3炩蠏k@橈䏷S䧕,熜晬k1鮥玸먚7䤡f绝嗚샴ᥒ~0q拮垑a뻱LⰖ_\": [{\n                                                                                                                                                                                                                                                                                                     \":p尢\": -6.688985172863383E17,\n                                                                                                                                                                                                                                                                                                     \"A0\\u0001疠ﻵ爻鼀湶I~W^岀mZx#㍈7r拣$Ꜷ疕≛⦒痋盩Vꬷ᭝ΩQꍪ療鈑A(劽詗ꭅo-獶鑺\\\"Ⓠ@$j탥;\": [\n                                                                                                                                                                                                                                                                                                      8565614620787930994,\n                                                                                                                                                                                                                                                                                                      [\n                                                                                                                                                                                                                                                                                                       \"嶗PC?උQ㪣$&j幾㾷h慑 즊慧⪉霄M窊ꁷ'鮕)䊏铨m趦䗲(g罣ЮKVﯦ鏮5囗ﰼ鿦\",\n                                                                                                                                                                                                                                                                                                       -7168038789747526632,\n                                                                                                                                                                                                                                                                                                       null,\n                                                                                                                                                                                                                                                                                                       -7.8069738975270288E16,\n                                                                                                                                                                                                                                                                                                       2.25819579241348352E17,\n                                                                                                                                                                                                                                                                                                       -6.5597416611655936E18,\n                                                                                                                                                                                                                                                                                                       {\n                                                                                                                                                                                                                                                                                                        \"瘕멦핓+?ﾌZ귢z鍛V\": {\n                                                                                                                                                                                                                                                                                                         \"ᕾ\": 1.7363275204701887E-19,\n                                                                                                                                                                                                                                                                                                         \"㭌s뎹㳉\": {\"\\u00187FI6Yf靺+UC쬸麁␲䂿긕R\\\\ᆮC?Φ耭\\rOத际핅홦*베W㸫㯼᡹cㅜ|G㮗\\u0013[o`?jHV앝?蒪꩚!퍫ᜦ㌇䚇鿘:@\": [\n                                                                                                                                                                                                                                                                                                          \"}푛Г콲<䟏C藐呈#2㓋#ྕ፟尿9q竓gI%랙mꍬoa睕贿J咿D_熏Zz皳験I豼B扳ḢQ≖㻹㱣D䝦練2'ᗍ㗣▌砲8罿%హF姦;0悇<\\/\\\"p嚧\",\n                                                                                                                                                                                                                                                                                                          -710184373154164247,\n                                                                                                                                                                                                                                                                                                          \"Vo쫬⬾ꝫⴷŻ\\u0004靎HBꅸ_aVBＨbN>Z4⍜kเꛘZ⥺\\\\Bʫᇩ鄨魢弞&幟ᓮ2̊盜\",\n                                                                                                                                                                                                                                                                                                          -9006004849098116748,\n                                                                                                                                                                                                                                                                                                          -3118404930403695681,\n                                                                                                                                                                                                                                                                                                          {\n                                                                                                                                                                                                                                                                                                           \"_彃Y艘-\\\"Xx㤩㳷瑃?%2䐡鵛o<A?\\\"顜ᘌΈ;ⷅC洺L蚴蚀voq:,Oo4쪂)\": 5719065258177391842,\n                                                                                                                                                                                                                                                                                                           \"l륪맽耞塻論倐E㗑/㲕QM辬I\\\"qi酨玑㖪5q]尾魨鲡ƞY}⮯蠇%衟Fsf윔䐚찤i腳\": {\"ꢪ'a䣊糈\": {\"밑/♋S8s㼴5瓹O{댞\\\"9XﰇlJ近8}q{긧ⓈI᱑꿋腸D瀬H\\\"ﺬ'3?}\\u0014#?丙㑯ᥨ圦',g鑠(樴턇?\": [\n                                                                                                                                                                                                                                                                                                            2.5879275511391145E18,\n                                                                                                                                                                                                                                                                                                            null,\n                                                                                                                                                                                                                                                                                                            [\n                                                                                                                                                                                                                                                                                                             \"3㼮ꔌ1Gẃ2W龙j͊{1囐㦭9x宠㑝oR䐕犽\",\n                                                                                                                                                                                                                                                                                                             1268729930083267852,\n                                                                                                                                                                                                                                                                                                             \"땕軚⿦7C\",\n                                                                                                                                                                                                                                                                                                             [\n                                                                                                                                                                                                                                                                                                              -3.757935946502082E18,\n                                                                                                                                                                                                                                                                                                              \"\\\"赌'糬_2뭾᝝b\",\n                                                                                                                                                                                                                                                                                                              {\n                                                                                                                                                                                                                                                                                                               \"(a䕎ጽjҰD4.ᴡ66ԃ畮<\\/l`k癸\\\\㇋ࣆ욯R㫜픉녬挛;ڴ맺`.;焓q淞뮕ٹ趴r蔞ꯔ䟩v粏u5<\\/pZ埖Skrvj帛=\\u0005aa\": null,\n                                                                                                                                                                                                                                                                                                               \"璄≩ v몛ᘮ%?:1頌챀H㷪뉮k滘e\": [\n                                                                                                                                                                                                                                                                                                                \"ꤾ{`c샬왌펡[俊络vmz㪀悫⸹ᷥ5o'㾵 L蹦qjYIYណԠW냁剫<\\/W嗂0,}\",\n                                                                                                                                                                                                                                                                                                                2.4817616702666762E18,\n                                                                                                                                                                                                                                                                                                                false,\n                                                                                                                                                                                                                                                                                                                null,\n                                                                                                                                                                                                                                                                                                                null,\n                                                                                                                                                                                                                                                                                                                -8.6036958071260979E17,\n                                                                                                                                                                                                                                                                                                                null,\n                                                                                                                                                                                                                                                                                                                -1.2744078022652468E-19,\n                                                                                                                                                                                                                                                                                                                -4.4752020268429594E17,\n                                                                                                                                                                                                                                                                                                                1.13672865156637872E17,\n                                                                                                                                                                                                                                                                                                                [\n                                                                                                                                                                                                                                                                                                                 false,\n                                                                                                                                                                                                                                                                                                                 false,\n                                                                                                                                                                                                                                                                                                                 null,\n                                                                                                                                                                                                                                                                                                                 -4.178004168554046E-20,\n                                                                                                                                                                                                                                                                                                                 true,\n                                                                                                                                                                                                                                                                                                                 2927542512798605527,\n                                                                                                                                                                                                                                                                                                                 {\n                                                                                                                                                                                                                                                                                                                  \".ꔓ뉤1䵬cHy汼䊆賓ᐇƩ|樷❇醎㬅4\\u0003赵}#yD5膏晹뱓9ꖁ虛J㺕 t䊛膎ؤ\": {\n                                                                                                                                                                                                                                                                                                                   \"rVtᓸ5^`েN⹻Yv᥋lꌫt拘?<鮰넿ZC?㒽^\": {\"␪k_:>귵옔夘v*탋职&㳈챗|O钧\": [\n                                                                                                                                                                                                                                                                                                                    false,\n                                                                                                                                                                                                                                                                                                                    \"daꧺdᗹ羞쯧H㍤鄳頳<型孒ン냆㹀f4㹰\\u000f|C*ሟ鰠(O<ꨭ峹ipຠ*y೧4VQ蔔hV淬{?ᵌEfrI_\",\n                                                                                                                                                                                                                                                                                                                    \"j;ꗣ밷邍副]ᗓ\",\n                                                                                                                                                                                                                                                                                                                    -4299029053086432759,\n                                                                                                                                                                                                                                                                                                                    -5610837526958786727,\n                                                                                                                                                                                                                                                                                                                    [\n                                                                                                                                                                                                                                                                                                                     null,\n                                                                                                                                                                                                                                                                                                                     [\n                                                                                                                                                                                                                                                                                                                      -1.3958390678662759E-19,\n                                                                                                                                                                                                                                                                                                                      {\n                                                                                                                                                                                                                                                                                                                       \"lh좈T_믝Y\\\"伨\\u001cꔌG爔겕ꫳ晚踍⿻읐T䯎]~e#฽燇\\\"5hٔ嶰`泯r;ᗜ쮪Q):/t筑,榄&5懶뎫狝(\": [{\n                                                                                                                                                                                                                                                                                                                        \"2ፁⓛ]r3C攟וּ9賵s⛔6'ஂ|\\\"ⵈ鶆䐹禝3\\\"痰ࢤ霏䵩옆䌀?栕r7O簂Isd?K᫜`^讶}z8?z얰T:X倫⨎ꑹ\": -6731128077618251511,\n                                                                                                                                                                                                                                                                                                                        \"|︦僰~m漿햭\\\\Y1'Vvخ굇ቍ챢c趖\": [null]\n                                                                                                                                                                                                                                                                                                                       }],\n                                                                                                                                                                                                                                                                                                                       \"虌魿閆5⛔煊뎰㞤ᗴꥰF䮥蘦䂪樳-K᝷-(^\\u20dd_\": 2.11318679791770592E17\n                                                                                                                                                                                                                                                                                                                      }\n                                                                                                                                                                                                                                                                                                                     ]\n                                                                                                                                                                                                                                                                                                                    ]\n                                                                                                                                                                                                                                                                                                                   ]},\n                                                                                                                                                                                                                                                                                                                   \"묗E䀳㧯᳀逞GMc\\b墹㓄끖Ơ&U??펌鑍 媋k))ᄊ\": null,\n                                                                                                                                                                                                                                                                                                                   \"묥7콽벼諌J_DɯﮪM殴䣏,煚ྼ`Y:씧<\\/⩫%yf䦀!1Ჶk춎Q米W∠WC跉鬽*ᛱi<?,l<崣炂骵*?8푐៣ⰵ憉⎑.,Nw罣q+ο컆弎\": false\n                                                                                                                                                                                                                                                                                                                  },\n                                                                                                                                                                                                                                                                                                                  \"e[|଀+lꑸ㝈TT?뿿|ꫛ9`㱯䊸楋-곳賨?쳁k棽擋wQ餈⟐Nq[q霩䵀뷮锅ꚢ\": 5753148631596678144,\n                                                                                                                                                                                                                                                                                                                  \"sᓝ鴻߸d렶ὕ蜗ဟ툑!诉౿\": false,\n                                                                                                                                                                                                                                                                                                                  \"|4䕳鵻?䈔(]틍/Ui#湻{듲ーMዀt7潔泄Ch⸨}쏣`螧銚㋼壯kⰥQ戵峉갑x辙'첛\": \"jd䘯$䕌茷!auw眶ㅥ䁣ꆢ民i\",\n                                                                                                                                                                                                                                                                                                                  \"剖駰ꞫsM2]ᾴ2ࡷ祅拌Av狔꩛'ꓗ킧ꣁ0酜✘O'\": false,\n                                                                                                                                                                                                                                                                                                                  \"澩뢣ꀁeU~D\\\\ꮡ킠\": \"v^YC嚈ί\\u0007죋h>㴕L꘻ꀏ쓪\\\"_g鿄'#t⽙?,Wg㥖|D鑆e⥏쪸僬h鯔咼ඡ;4TK聎졠嫞\"\n                                                                                                                                                                                                                                                                                                                 }\n                                                                                                                                                                                                                                                                                                                ]\n                                                                                                                                                                                                                                                                                                               ]\n                                                                                                                                                                                                                                                                                                              }\n                                                                                                                                                                                                                                                                                                             ]\n                                                                                                                                                                                                                                                                                                            ]\n                                                                                                                                                                                                                                                                                                           ]}}\n                                                                                                                                                                                                                                                                                                          }\n                                                                                                                                                                                                                                                                                                         ]}\n                                                                                                                                                                                                                                                                                                        },\n                                                                                                                                                                                                                                                                                                        \"뿋뀾淣截䔲踀&XJ펖꙯^Xb訅ꫥgᬐ>棟S\\\"혧騾밫겁7-\": \"擹8C憎W\\\"쵮yR뢩浗絆䠣簿9䏈引Wcy䤶孖ꯥ;퐌]輩䍐3@{叝 뽸0ᡈ쵡Ⲇ\\u001dL匁꧐2F~ݕ㪂@W^靽L襒ᦘ~沦zZ棸!꒲栬R\"\n                                                                                                                                                                                                                                                                                                       }\n                                                                                                                                                                                                                                                                                                      ]\n                                                                                                                                                                                                                                                                                                     ],\n                                                                                                                                                                                                                                                                                                     \"Z:덃൛5Iz찇䅄駠㭧蓡K1\": \"e8᧤좱U%?ⵇ䯿鿝\\u0013縮R∱骒EO\\u000fg?幤@֗퉙vU`\",\n                                                                                                                                                                                                                                                                                                     \"䐃쪈埽້=Ij,쭗쓇చ\": false\n                                                                                                                                                                                                                                                                                                    }]}}\n                                                                                                                                                                                                                                                                                                   ]\n                                                                                                                                                                                                                                                                                                  }\n                                                                                                                                                                                                                                                                                                 ]}\n                                                                                                                                                                                                                                                                                                }\n                                                                                                                                                                                                                                                                                               ]\n                                                                                                                                                                                                                                                                                              ]\n                                                                                                                                                                                                                                                                                             ],\n                                                                                                                                                                                                                                                                                             \"咰긖VM]᝼6䓑쇎琺etDҌ?㞏ꩄ퇫밉gj8蠃\\\"⩐5䛹1ࣚ㵪\": \"ക蹊?⎲⧘⾚̀I#\\\"䈈⦞돷`wo窭戕෱휾䃼)앷嵃꾞稧,Ⴆ윧9S?೗EMk3Მ3+e{⹔Te驨7䵒?타Ulg悳o43\"\n                                                                                                                                                                                                                                                                                            }\n                                                                                                                                                                                                                                                                                           ],\n                                                                                                                                                                                                                                                                                           \"zQᤚ纂땺6#ٽ﹧v￿#ࠫ휊冟蹧텈ꃊʆ?&a䥯De潝|쿓pt瓞㭻啹^盚2Ꝋf醪,얏T窧\\\\Di䕎谄nn父ꋊE\": -2914269627845628872,\n                                                                                                                                                                                                                                                                                           \"䉩跐|㨻ᷢ㝉B{蓧瞸`I!℄욃힕#ೲᙾ竛ᔺCjk췒늕貭词\\u0017署?W딚%(pꍁ⤼띳^=on뺲l䆼bzrﳨ[&j狸䠠=ᜑꦦ\\u2061յnj=牲攑)M\\\\龏\": false,\n                                                                                                                                                                                                                                                                                           \"뎕y絬᫡⥮Ϙᯑ㌔/NF*˓.,QEzvK!Iwz?|쥾\\\"ꩻL꼗Bꔧ賴緜s뉣隤茛>ロ?(?^`>冺飒=噸泥⺭Ᲊ婓鎔븜z^坷裮êⓅ໗jM7ﶕ找\\\\O\": 1.376745434746303E-19\n                                                                                                                                                                                                                                                                                          },\n                                                                                                                                                                                                                                                                                          \"䐛r滖w㏤<k;l8ꡔጵ⮂ny辶⋃퍼僮z\\\"﮲X@t5෼暧퓞猋♅䦖QC鹮|픨( ,>,|Nዜ\": false\n                                                                                                                                                                                                                                                                                         }\n                                                                                                                                                                                                                                                                                        ]],\n                                                                                                                                                                                                                                                                                        \"@꿙?薕尬 gd晆(띄5躕ﻫS蔺4)떒錸瓍?~\": 1665108992286702624,\n                                                                                                                                                                                                                                                                                        \"w믍nᏠ=`঺ￆC>'從됐槷䤝眷螄㎻揰扰XￊC贽uჍ낟jKD03T!lDV쀉Ӊy뢖,袛!终캨G?鉮Q)⑗1쾅庅O4ꁉH7?d\\u0010蠈줘월ސ粯Q!낇껉6텝|{\": null,\n                                                                                                                                                                                                                                                                                        \"~˷jg쿤촖쉯y\": -5.5527605669177098E18,\n                                                                                                                                                                                                                                                                                        \"펅Wᶺzꐆと푭e?4j仪열[D<鈑皶婆䵽ehS?袪;HꍨM뗎ば[(嗏M3q퍟g4y╸鰧茀[Bi盤~﫝唎鋆彺⦊q?B4쉓癚O洙킋툈䶯_?ퟲ\": null\n                                                                                                                                                                                                                                                                                       }\n                                                                                                                                                                                                                                                                                      ]\n                                                                                                                                                                                                                                                                                     ]]\n                                                                                                                                                                                                                                                                                    ]],\n                                                                                                                                                                                                                                                                                    \"꟱Ԕ㍤7曁聯ಃ錐V䷰?v㪃૦~K\\\"$%请|ꇹn\\\"k䫛㏨鲨\\u2023䄢\\u0004[<S8ᐬ뭩脥7U.m࿹:D葍┆2蘸^U'w1젅;䠆ꋪB껮>︊VJ?䶟ាꮈ䗱=깘U빩\": -4863152493797013264\n                                                                                                                                                                                                                                                                                   }\n                                                                                                                                                                                                                                                                                  ]}]}\n                                                                                                                                                                                                                                                                                 ]\n                                                                                                                                                                                                                                                                                }}}\n                                                                                                                                                                                                                                                                               ],\n                                                                                                                                                                                                                                                                               \"쏷쐲۹퉃~aE唙a챑,9㮹gLHd'䔏|킗㍞䎥&KZYT맵7䥺N<Hp4ꕭ⹠꽐c~皽z\": \"课|ᖾ䡁廋萄䐪W\\u0016&Jn괝b~摓M>ⱳ同莞鿧w\\\\༌疣n/+ꎥU\\\"封랾○ퟙAJᭌ?9䛝$?驔9讐짘魡T֯c藳`虉C읇쐦T\"\n                                                                                                                                                                                                                                                                              }\n                                                                                                                                                                                                                                                                             ],\n                                                                                                                                                                                                                                                                             \"谶개gTR￐>ၵ͚dt晑䉇陏滺}9㉸P漄\": -3350307268584339381\n                                                                                                                                                                                                                                                                            }]\n                                                                                                                                                                                                                                                                           ]\n                                                                                                                                                                                                                                                                          ]\n                                                                                                                                                                                                                                                                         ]]\n                                                                                                                                                                                                                                                                        ]\n                                                                                                                                                                                                                                                                       ],\n                                                                                                                                                                                                                                                                       \"0y꟭馋X뱔瑇:䌚￐廿jg-懲鸭䷭垤㒬茭u賚찶ಽ+\\\\mT땱\\u20821殑㐄J쩩䭛ꬿNS潔*d\\\\X,壠뒦e殟%LxG9:摸\": 3737064585881894882,\n                                                                                                                                                                                                                                                                       \"풵O^-⧧ⅶvѪ8廸鉵㈉ר↝Q㿴뺟EႳvNM:磇>w/៻唎뷭୥!냹D䯙i뵱貁C#⼉NH6`柴ʗ#\\\\!2䂗Ⱨf?諳.P덈-返I꘶6?8ꐘ\": -8934657287877777844,\n                                                                                                                                                                                                                                                                       \"溎-蘍寃i诖ര\\\"汵\\\"\\ftl,?d⼡쾪⺋h匱[,෩I8MҧF{k瓿PA'橸ꩯ綷퉲翓\": null\n                                                                                                                                                                                                                                                                      }\n                                                                                                                                                                                                                                                                     ]\n                                                                                                                                                                                                                                                                    ],\n                                                                                                                                                                                                                                                                    \"ោ係؁<元\": 1.7926963090826924E-18\n                                                                                                                                                                                                                                                                   }}]\n                                                                                                                                                                                                                                                                  }\n                                                                                                                                                                                                                                                                 ]\n                                                                                                                                                                                                                                                                ]]}]\n                                                                                                                                                                                                                                                               }]\n                                                                                                                                                                                                                                                              ]\n                                                                                                                                                                                                                                                             ]\n                                                                                                                                                                                                                                                            ]\n                                                                                                                                                                                                                                                           ],\n                                                                                                                                                                                                                                                           \"ጩV<\\\"ڸsOᤘ\": 2.0527167903723048E-19\n                                                                                                                                                                                                                                                          }]\n                                                                                                                                                                                                                                                         ]}\n                                                                                                                                                                                                                                                        ]\n                                                                                                                                                                                                                                                       ]],\n                                                                                                                                                                                                                                                       \"∳㙰3젴p᧗䱙?`<U὇<\\/意E[ᮚAj诂ᒽ阚uv徢ဎ떗尔Ᵹ훀쩑J䐴?⪏=륪ᆩ푰ஓ㐕?럽VK\\\"X?檨လ齿I/耉A(AWA~⏯稐蹫\": false,\n                                                                                                                                                                                                                                                       \"偒妝뾇}䀼链i⇃%⋜&璪Ix渥5涧qq棩ᥝ-⠫AA낇yY颕A*裦O|n?䭬혗F\": null,\n                                                                                                                                                                                                                                                       \"琭CL얭B혆Kॎ`鎃nrsZiժW砏)?p~K~A眱䲏QO妣\\u001b\\u001b]ᵆᆯ&㐋ᏹ豉뺘$ꭧ#j=C)祤⫢歑1o㒙諩\": 7028426989382601021,\n                                                                                                                                                                                                                                                       \"쳱冲&ဤ䌏앧h胺-齱H忱8왪RDKᅒ䬋ᔶS*J}ስ漵'㼹뮠9걢9p봋경ጕtởꚳT䶽瘙%춴`@nಆ4<d??#僜ᙤ钴=薔ꭂbLXNam蹈\": \"樭る蹿= Uurwkn뙧⌲%\\\"쑃牪\\\"cq윕o@\",\n                                                                                                                                                                                                                                                       \"溌[H]焎SLㅁ?뀼䫨災W\": 1.1714289118497062E-19,\n                                                                                                                                                                                                                                                       \"ﬢp븇剌燇kĔ尘㶿㴞睠꾘Ia;s❺^)$穮?sHᢥ폪l\": null\n                                                                                                                                                                                                                                                      }\n                                                                                                                                                                                                                                                     ]\n                                                                                                                                                                                                                                                    }\n                                                                                                                                                                                                                                                   ]\n                                                                                                                                                                                                                                                  },\n                                                                                                                                                                                                                                                  \"TKnzj5o<\\/K㊗ꗣ藠⦪駇>yZA8Ez0,^ᙛ4_0븢\\u001ft:~䎼s.bb룦明yNP8弆C偯;⪾짍'蕴뮛\": -6976654157771105701,\n                                                                                                                                                                                                                                                  \"큵ꦀ\\\\㇑:nv+뒤燻䀪ﴣ﷍9ᚈ኷K㚊誦撪䚛,ꮪxሲ쳊\\u0005HSf?asg昱dqꬌVꙇ㼺'k*'㈈\": -5.937042203633044E-20\n                                                                                                                                                                                                                                                 }\n                                                                                                                                                                                                                                                ]\n                                                                                                                                                                                                                                               }],\n                                                                                                                                                                                                                                               \"?}\\u20e0],s嶳菋@#2u쒴sQS䩗=ꥮ;烌,|ꘔ䘆\": \"ᅩ영N璠kZ먕眻?2ቲ芋眑D륟渂⸑ﴃIRE]啗`K'\"\n                                                                                                                                                                                                                                              }},\n                                                                                                                                                                                                                                              \"쨀jmV賂ﰊ姐䂦玞㬙ᏪM᪟Վ씜~`uOn*ॠ8\\u000ef6??\\\\@/?9見d筜ﳋB|S䝬葫㽁o\": true\n                                                                                                                                                                                                                                             },\n                                                                                                                                                                                                                                             \"즛ꄤ酳艚␂㺘봿㎨iG৕ࡿ?1\\\"䘓您\\u001fSኝ⺿溏zៀ뻤B\\u0019?윐a䳵᭱䉺膷d:<\\/\": 3935553551038864272\n                                                                                                                                                                                                                                            }\n                                                                                                                                                                                                                                           ]\n                                                                                                                                                                                                                                          ]}\n                                                                                                                                                                                                                                         ]]\n                                                                                                                                                                                                                                        ]]\n                                                                                                                                                                                                                                       ]}\n                                                                                                                                                                                                                                      }\n                                                                                                                                                                                                                                     ]\n                                                                                                                                                                                                                                    }\n                                                                                                                                                                                                                                   ]]}},\n                                                                                                                                                                                                                                   \"᥺3h↛!ꋰy\\\"攜(ெl䪕oUkc1A㘞ᡲ촾ᣫ<\\/䒌E㛝潨i{v?W౾H\\\\RჅpz蝬R脾;v:碽✘↯삞鷱o㸧瑠jcmK7㶧뾥찲n\": true,\n                                                                                                                                                                                                                                   \"ⶸ?x䊺⬝-䰅≁!e쩆2ꎿ准G踌XXᩯ1߁}0?.헀Z馟;稄\\baDꟹ{-寪⚈ꉷ鮸_L7ƽᾚ<\\u001bጨA䧆송뇵⨔\\\\礍뗔d设룱㶉cq{HyぱR㥽吢ﬅp\": -7985372423148569301,\n                                                                                                                                                                                                                                   \"緫#콮IB6<\\/=5Eh礹\\t8럭@饹韠r㰛斣$甝LV췐a갵'请o0g:^\": \"䔨(.\",\n                                                                                                                                                                                                                                   \"띳℡圤pﾝ௄ĝ倧訜B쁟G䙔\\\"Sb⓮;$$▏S1J뢙SF|赡g*\\\"Vu䲌y\": \"䪈&틐),\\\\kT鬜1풥;뷴'Zေ䩹@J鞽NぼM?坥eWb6榀ƩZڮ淽⺞삳煳xჿ絯8eⶍ羷V}ჿ쎱䄫R뱃9Z>'\\u20f1ⓕ䏜齮\"\n                                                                                                                                                                                                                                  }\n                                                                                                                                                                                                                                 ]\n                                                                                                                                                                                                                                ]]]\n                                                                                                                                                                                                                               }}\n                                                                                                                                                                                                                              }\n                                                                                                                                                                                                                             ]\n                                                                                                                                                                                                                            ]},\n                                                                                                                                                                                                                            \"펮b.h粔폯2npX詫g錰鷇㇒<쐙S値bBi@?镬矉`剔}c2壧ଭfhY깨R()痩⺃a\\\\⍔?M&ﯟ<劜꺄멊ᄟA\\\"_=\": null\n                                                                                                                                                                                                                           },\n                                                                                                                                                                                                                           \"~潹Rqn榢㆓aR鬨侅?䜑亡V_翅㭔(䓷w劸ၳDp䀅<\\/ﰎ鶊m䵱팱긽ꆘ<tD쇋>긓准D3掱;o:_ќ)껚콥8곤d矦8nP倥ꃸI\": null,\n                                                                                                                                                                                                                           \"뾎/Q㣩㫸벯➡㠦◕挮a鶧⋓偼\\u00001뱓fm覞n?㛅\\\"\": 2.8515592202045408E17\n                                                                                                                                                                                                                          }],\n                                                                                                                                                                                                                          \",\": -5426918750465854828,\n                                                                                                                                                                                                                          \"2櫫@0柡g䢻/gꆑ6演&D稒肩Y?艘/놘p{f투`飷ᒉ챻돎<늛䘍ﴡ줰쫄\": false,\n                                                                                                                                                                                                                          \"8(鸑嵀⵹ퟡ<9㣎Tߗ┘d슒ل蘯&㠦뮮eࠍk砝g 엻\": false,\n                                                                                                                                                                                                                          \"d-\\u208b?0ﳮ嵙'(J`蔿d^踅⤔榥\\\\J⵲v7\": 6.8002426206715341E17,\n                                                                                                                                                                                                                          \"ཎ耰큓ꐕ㱷\\u0013y=詽I\\\"盈xm{0쾽倻䉚ષso#鰑/8㸴짯%ꀄ떸b츟*\\\\鲷礬ZQ兩?np㋄椂榨kc᡹醅3\": false,\n                                                                                                                                                                                                                          \"싊j20\": false\n                                                                                                                                                                                                                         }]]\n                                                                                                                                                                                                                        ]],\n                                                                                                                                                                                                                        \"俛\\u0017n緽Tu뫉蜍鼟烬.ꭠIⰓ\\\"Ἀ᜾uC쎆J@古%ꛍm뻨ᾀ画蛐휃T:錖㑸ዚ9죡$\": true\n                                                                                                                                                                                                                       }\n                                                                                                                                                                                                                      ]\n                                                                                                                                                                                                                     ],\n                                                                                                                                                                                                                     \"㍵⇘ꦖ辈s}㱮慀밒s`\\\"㞟j:`i픻Z<C1衽$\\\"-饧?℃\\u0010⼒{p飗%R\\\"䲔\\\")칀\\\\%\": true,\n                                                                                                                                                                                                                     \"苧.8\\u00120ݬ仓\": 6912164821255417986,\n                                                                                                                                                                                                                     \"떎顣俁X;.#Q틝.笂'p쟨唒퐏랩냆¦aⱍ{谐.b我$蜑SH\\u000f琾=䟼⣼奔ᜏ攕B&挰繗㝔ꅂ-Qv\\\\0䶝䚥ぺio［㑮-ᇼ䬰컪ṼiY){데\\u0010q螰掻~\\n輚x\\u0014罺)軴\": 3.024364150712629E-20\n                                                                                                                                                                                                                    }\n                                                                                                                                                                                                                   ]\n                                                                                                                                                                                                                  ]\n                                                                                                                                                                                                                 ]\n                                                                                                                                                                                                                ]}\n                                                                                                                                                                                                               ]]\n                                                                                                                                                                                                              }\n                                                                                                                                                                                                             ]\n                                                                                                                                                                                                            ]]\n                                                                                                                                                                                                           ]\n                                                                                                                                                                                                          ]]]],\n                                                                                                                                                                                                          \"\\\"凲o肉Iz絾豉J8?i~傠᫽䇂!WD溊J?ᡒvs菆嵹➒淴>섫^諎0Ok{켿歁෣胰a2﨤[탳뚬쎼嫭뉮m\": 409440660915023105,\n                                                                                                                                                                                                          \"w墄#*ᢄ峠밮jLa`ㆪ꺊漓Lで끎!Agk'ꁛ뢃㯐岬D#㒦\": false,\n                                                                                                                                                                                                          \"ଦPGI䕺L몥罭ꃑ궩﮶#⮈ᢓӢ䚬p7웼臧%~S菠␌힀6&t䳙y㪘냏\\\\*;鉏ￊ鿵'嗕pa\\\"oL쇿꬈Cg\": \"㶽1灸D⟸䴅ᆤ뉎﷛渤csx 䝔цꬃ锚捬?ຽ+x~꘩uI࡞\\u0007栲5呚ẓem?袝\\\")=㥴䨃pac!/揎Y\",\n                                                                                                                                                                                                          \"ᷱo\\\\||뎂몷r篙|#X䦜I#딌媸픕叞RD斳X4t⯩夬=[뭲r=绥jh뷱츝⪘%]⚋܈㖴スH텹m(WO曝劉0~K3c柢Ր㏉着逳~\": false,\n                                                                                                                                                                                                          \"煽_qb[첑\\\\륌wE❽ZtCNﭝ+餌ᕜOꛭ\": \"{ﳾ쉌&s惧ᭁⵆ3䢫;䨞팑꒪흘褀࢖Q䠿V5뭀䎂澻%받u5텸oA⮥U㎦;B䳌wz䕙$ឿ\\\\௅婺돵⪾퐆\\\\`Kyौꋟ._\\u0006L챯l뇠Hi䧈偒5\",\n                                                                                                                                                                                                          \"艊佁ࣃ롇䱠爬!*;⨣捎慓q靓|儑ᨋL+迥=6㒺딉6弄3辅J-㕎뛄듘SG㆛(\\noAzQꝱ䰩X*ぢO퀌%펠낌mo틮a^<\\/F&_눊ᾉ㨦ы4\\\"8H\": 2974648459619059400,\n                                                                                                                                                                                                          \"鬙@뎣䫳ၮ끡?){y?5K;TA*k溱䫜J汃ꂯ싔썍\\u001dA}룖(<\\/^,\": false,\n                                                                                                                                                                                                          \"몏@QꋦFꊩᒐ뎶lXl垨4^郣|ꮇ;䝴ᝓ}쵲z珖\": null\n                                                                                                                                                                                                         }\n                                                                                                                                                                                                        ]]]],\n                                                                                                                                                                                                        \":_=닧弗D䙋暨鏛. 㱻붘䂍J儒&ZK/녩䪜r囁⽯D喠죥7⹌䪥c\\u001a\\u2076￞妈朹oLk菮F౟覛쐧㮏7T;}蛙2{9\\\"崓bB<\\/⡷룀;즮鿹)丒툃୤뷠5W⊢嶜(fb뭳갣\": \"E{响1WM\"\n                                                                                                                                                                                                       }},\n                                                                                                                                                                                                       \"䘨tjJ驳豨?y輊M*᳑梵瞻઻ofQG瑮e\": 2.222802939724948E-19,\n                                                                                                                                                                                                       \"䮴=❑➶T෋w䞜\\\"垦ꃼUt\\u001dx;B$뵣䙶E↌艣ᡥ!᧟;䱀[䔯k쬃`੍8饙른熏'2_'袻tGf蒭J땟as꯳╖&啒zWࡇᒫYSᏬ\\u0014ℑ첥鈤|cG~Pᓮ\\\">\\\"\": \"ႆl\\f7V儊㦬nHꄬꨧC{쐢~C⮃⛓嶦vꄎ1w鰠嘩뿠魄&\\\"_qMⵖ釔녮ꝇ 㝚{糍J哋 cv?-jkﻯྌ鹑L舟r\",\n                                                                                                                                                                                                       \"龧葆yB✱H盋夔ﶉ?n*0(\": \"ꧣኆ㢓氥qZZ酒ຜ)鮢樛)X䣆gTSґG텞k.J圬疝롫쯭z L：\\\\ྤ@w炋塜쿖ᾳy뢀䶃뱝N䥨㚔勇겁#p\",\n                                                                                                                                                                                                       \"도畎Q娡\\\"@S/뼋:䵏!P衅촚fVHQs✜ᐫi㻑殡B䜇%믚k*U#濨낄~\": \"ꍟዕ쳸ꍈ敋&l妏\\u0005憡멗瘌uPgᅪm<\\/To쯬锩h뒓k\"\n                                                                                                                                                                                                      }\n                                                                                                                                                                                                     ]\n                                                                                                                                                                                                    }],\n                                                                                                                                                                                                    \"墥홞r绚<\\/⸹ⰃB}<躅\\\\Y;๑@䔸>韫䜲뱀X뗩鿥쩗SI%ﴞ㳕䛇?<\\/\\u00018x\\\\&侂9鋙a[LR㋭W胕)⡿8㞙0JF,}?허d1cDMᐃ␛鄝ⱕ%X)!XQ\": \"ⳍꗳ=橇a;3t⦾꼑仈ူaᚯ⯋ꕃAs鴷N⍕_䎃ꙎAz\\u0016䯷\\\\<࿫>8q{}ｷ?ᣰ}'0ᴕ펓B┦lF#趤厃T?㕊#撹圂䆲\"\n                                                                                                                                                                                                   },\n                                                                                                                                                                                                   \"܋닐龫論c웑\": false,\n                                                                                                                                                                                                   \"ㇿ/q\\\"6-co髨휝C큦#\\u001b4~?3䐹E삇<<\": 7.600917488140322E-20,\n                                                                                                                                                                                                   \"䁝E6?㣖ꃁ间t祗*鑠{ḣV(浾h逇큞=W?ૉ?nꇽ8ꅉຉj으쮺@Ꚅ㰤u]Oyr\": \"v≁᫸_*όAඤԆl)ۓᦇQ}폠z༏q滚\",\n                                                                                                                                                                                                   \"ｿ᥊/넺I\": true\n                                                                                                                                                                                                  }]]\n                                                                                                                                                                                                 ]\n                                                                                                                                                                                                ]\n                                                                                                                                                                                               ]\n                                                                                                                                                                                              ]]\n                                                                                                                                                                                             },\n                                                                                                                                                                                             \"䭑Ik攑\\u0002QV烄:芩.麑㟴㘨≕\": true,\n                                                                                                                                                                                             \"坄꿕C쇻풉~崍%碼\\\\8\\\"䬦꣙\": null,\n                                                                                                                                                                                             \"欌L圬䅘Y8c(♺2?ON}o椳s宥2䉀eJ%闹r冁O^K諭%凞⺉⡻,掜?$ꥉ?略焕찳㯊艼誜4?\\\"﯎<゛XፈINT:詓 +\": -1.0750456770694562E-19,\n                                                                                                                                                                                             \"獒àc뜭싼ﺳ뎤K`]p隨LtE\": null,\n                                                                                                                                                                                             \"甙8䵊神EIꩤ鐯ᢀ,ﵮU䝑u疒ử驺䚿≚ഋ梶秓F`覤譐#짾蔀묊4<媍쬦靪_Yzgcࡶ4k紥`kc[Lﮗ簐*I瀑[⾰L殽鑥_mGȠ<\\/|囹灠g桰iri\": true,\n                                                                                                                                                                                             \"챓ꖙꟻ좝菇ou,嗠0\\\\jK핻뜠qwQ?ഩ㼕3Y彦b\\u009bJ榶N棨f?됦鏖綃6鳵M[OE봨u햏.Ꮁ癜蟳뽲ꩌ뻾rM豈R嗀羫 uDꎚ%\": null\n                                                                                                                                                                                            },\n                                                                                                                                                                                            \"V傜2<\": 7175127699521359521\n                                                                                                                                                                                           }],\n                                                                                                                                                                                           \"铫aG切<\\/\\\"ী⊆e<^g࢛)D顝ｎאַ饼\\u008c猪繩嵿ﱚCꡬ㻊g엺A엦\\u000f暿_f꿤볝㦕桦`蒦䎔j甬%岝rj 糏\": \"䚢偎눴Au<4箞7礦Iﱔ坠eȧ䪸u䵁p|逹$嗫쨘ꖾ﷐!胠z寓팢^㨔|u8Nሇe텔ꅦ抷]،鹎㳁#༔繁 \",\n                                                                                                                                                                                           \"낂乕ꃻ볨ϱ-ꇋ㖍fs⿫)zꜦ/K?솞♞ꑌ宭hJ᤭瑥Fu\": false,\n                                                                                                                                                                                           \"쟰ぜ魛G\\u0003u?`㾕ℾ㣭5螠烶這趩ꖢ:@咕ꐶx뒘느m䰨b痃렐0鳊喵熬딃$摉_~7*ⱦ녯1錾GKhJ惎秴6'H妈Tᧅ窹㺒疄矤铟wላ\": null,\n                                                                                                                                                                                           \"쯆q4!3錕㲏ⵆ㇛꘷Z瑩뭆\\\\◪NH\\u001d\\\\㽰U~㯶<\\\"쑣낞3ᵤ'峉eꢬ;鬹o꣒木X*長PXᘱu\\\"䠹n惞\": null,\n                                                                                                                                                                                           \"ᅸ祊\\\"&ꥴCjࢼ﴿?䡉`U效5殼㮞V昽ꏪ#ﺸ\\\\&t6x꠹盥꣰a[\\u001aꪍSpe鎿蠹\": -1.1564713893659811E-19\n                                                                                                                                                                                          }\n                                                                                                                                                                                         ]]\n                                                                                                                                                                                        ]\n                                                                                                                                                                                       ]\n                                                                                                                                                                                      ],\n                                                                                                                                                                                      \"羵䥳H,6ⱎ겾|@t\\\"#햊1|稃 섭)띜=뻔ꡜ???櫎~*ῡ꫌/繣ﻠq\": null\n                                                                                                                                                                                     }\n                                                                                                                                                                                    ]}\n                                                                                                                                                                                   ]},\n                                                                                                                                                                                   \"츤\": false\n                                                                                                                                                                                  }},\n                                                                                                                                                                                  \"s\": 3.7339341963399598E18\n                                                                                                                                                                                 }\n                                                                                                                                                                                ],\n                                                                                                                                                                                \"N,I?1+㢓|ࣱ嶃쩥V2\\u0012(4EE虪朶$|w颇v步\": \"~읢~_,Mzr㐫YB溓E淚\\\"ⅹ䈔ᏺ抙 b,nt5V㐒J檶ꏨ⻔?\",\n                                                                                                                                                                                \"Q껑ꡡ}$넎qH煔惍/ez^!ẳF댙䝌馻剁8\": \"梲;yt钰$i冄}AL%a j뜐奷걳뚾d꿽*ሬuDY3?뮟鼯뮟w㍪틱V\",\n                                                                                                                                                                                \"o{Q/K O胟㍏zUdꀐm&⨺J舕⾏魸訟㌥[T籨櫉唐킝 aṭ뱫촙莛>碶覆⧬짙쭰ׯdAiH໥벤퐥_恸[ 0e:죃TC弼荎뵁DA:w唵ꣁ\": null,\n                                                                                                                                                                                \"὏樎䵮軧|?౗aWH쩃1 ꅭsu\": null\n                                                                                                                                                                               }\n                                                                                                                                                                              ]\n                                                                                                                                                                             },\n                                                                                                                                                                             \"勂\\\\&m鰈J釮=Ⲽ鳋+䂡郑\": null,\n                                                                                                                                                                             \"殣b綊倶5㥗惢⳷萢ᑀ䬄镧M^ﱴ3⣢翣n櫻1㨵}ኯ뗙顖Z.Q➷ꮨ뗇\\u0004\": \"ꔙ䁼>n^[GीA䨟AM琢ᒊS쨲w?d㶣젊嘶纝麓+愣a%気ྞSc됓ᔘ:8bM7Xd8㶑臌]Ꙥ0ꐭ쒙䫣挵C薽Dfⵃ떼᷸\",\n                                                                                                                                                                             \"?紡.셪_෨j\\u0013Ox┠$Xᶨ-ᅇo薹-}軫;y毝㪜K㣁?.EV쮱4둽⛻䤜'2盡\\u001f60(|e쐰㼎ᦀ㒧-$l@ﻑ坳\\u0003䭱响巗WFo5c㧆T턁Y맸♤(\": -2.50917882560589088E17\n                                                                                                                                                                            }}\n                                                                                                                                                                           ],\n                                                                                                                                                                           \"侸\\\\릩.᳠뎠狣살cs项䭩畳H1s瀉븇19?.w骴崖㤊h痠볭㞳㞳䁮Ql怠㦵\": \"@䟴-=7f\",\n                                                                                                                                                                           \"鹟1x௢+d ;vi䭴FSDS\\u0004hꎹ㚍?⒍⦏ў6u,扩@됷Su)Pag휛TᒗV痩!瞏釀ꖞ蘥&ೞ蘐ꭰꞇᝎ\": \"ah懱Ժ&\\u20f7䵅♎඀䞧鿪굛ౕ湚粎蚵ᯋ幌YOE)५襦㊝Y*^\\\"R+ඈ咷蝶9ꥂ榨艦멎헦閝돶v좛咊E)K㓷ྭr\",\n                                                                                                                                                                           \"搆q쮦4綱켙셁.f4<\\/g<籽늷?#蚴픘:fF\\u00051㹉뀭.ᰖ풎f֦Hv蔎㧤.!䭽=鞽]음H:?\\\"-4\": 8.740133984938656E-20\n                                                                                                                                                                          }]}\n                                                                                                                                                                         }\n                                                                                                                                                                        ],\n                                                                                                                                                                        \"tVKn딩꘥⊾蹓᤹{\\u0003lR꼽ᄲQFᅏ傅ﱋ猢⤊ᔁ,E㓒秤nTතv`♛I\\u0000]꫔ṞD\\\"麵c踝杰X&濿또꣹깳౥葂鿎\\\\aꡨ?\": 3900062609292104525\n                                                                                                                                                                       }\n                                                                                                                                                                      ],\n                                                                                                                                                                      \"ਉ샒⊩Lu@S䧰^g\": -1.1487677090371648E18,\n                                                                                                                                                                      \"⎢k⑊꬗yᏫ7^err糎Dt\\u000bJ礯확ㆍ沑ｻꋽe赔㝢^J\\u0004笲㿋idra剰-᪉C錇/Ĝ䂾ညS지?~콮gR敉⬹'䧭\": 1901472137232418266,\n                                                                                                                                                                      \"灗k䶥:?촽贍쓉꓈㒸g獘[뵎\\\\胕?\\u0014_榙p.j稶,$`糉妋0>Fᡰly㘽$?\": \"]ꙛO赎&#㠃돱剳\\\"<◆>0誉齐_|z|裵씪>ᐌ㼍\\\"Z[琕}O?G뚇諦cs⠜撺5cu痑U圲\\u001c?鴴計l춥/╓哼䄗茏ꮅ뫈댽A돌롖뤫V窗讬sHd&\\nOi;_u\"\n                                                                                                                                                                     }\n                                                                                                                                                                    ],\n                                                                                                                                                                    \"Uﺗ\\\\Y\\\\梷䄬~\\u0002\": null,\n                                                                                                                                                                    \"k\\\"Y磓ᗔ휎@U冈<\\/w컑)[\": false,\n                                                                                                                                                                    \"曏J蝷⌻덦\\u001f㙳s꥓⍟邫P늮쥄c∬ྡྷ舆렮칤Z趣5콡넛A쳨\\\\뀙骫(棻.*&輛LiIfi{@EA婳KᬰTXT\": -4.3088230431977587E17\n                                                                                                                                                                   }]}\n                                                                                                                                                                  ]\n                                                                                                                                                                 ],\n                                                                                                                                                                 \"곃㲧<\\/dఓꂟs其ࡧ&N葶=?c㠤Ჴ'횠숄臼#\\u001a~\": false\n                                                                                                                                                                }\n                                                                                                                                                               ]\n                                                                                                                                                              ]}]\n                                                                                                                                                             }]\n                                                                                                                                                            }}\n                                                                                                                                                           ],\n                                                                                                                                                           \"2f`⽰E쵟>J笂裭!〛觬囀ۺ쟰#桊l鹛ⲋ|RA_Vx፭gE됓h﵀mfỐ|?juTU档[d⢼⺻p濚7E峿\": 5613688852456817133\n                                                                                                                                                          },\n                                                                                                                                                          \"濘끶g忮7㏵殬W팕Q曁 뫰)惃廊5%-蹚zYZ樭ﴷQ锘쯤崫gg\": true,\n                                                                                                                                                          \"絥ᇑ⦏쒓븣爚H.㗊߄o蘵貆ꂚ(쎔O᥉ﮓ]姨Wꁓ!RMA|o퉢THx轮7M껁U즨'i뾘舯o\": \"跥f꜃?\"\n                                                                                                                                                         }}\n                                                                                                                                                        ],\n                                                                                                                                                        \"鷰鹮K-9k;ﰰ?_ݦѷ-ꅣ䩨Zꥱ\\\"mꠟ屎/콑Y╘2&鸞脇㏢ꀇ࠺ⰼ拾喭틮L꽩bt俸墶 [l/웄\\\"꾦\\u20d3iও-&+\\u000fQ+໱뵞\": -1.296494662286671E-19\n                                                                                                                                                       },\n                                                                                                                                                       \"HX੹/⨇୕붷Uﮘ旧\\\\쾜͔3l鄈磣糂̖䟎Eᐳw橖b῀_딕hu葰窳闹вU颵|染H죶.fP䗮:j䫢\\\\b뎖i燕ꜚG⮠W-≚뉗l趕\": \"ଊ칭Oa᡺$IV㷧L\\u0019脴셀붿餲햪$迳向쐯켂PqfT\\\" ?I屉鴼쿕@硙z^鏕㊵M}㚛T젣쓌-W⩐-g%⺵<뮱~빅╴瑿浂脬\\u0005왦燲4Ⴭb|D堧 <\\/oEQh\",\n                                                                                                                                                       \"䘶#㥘੐캔f巋ἡAJ䢚쭈ࣨ뫒*mᇊK，ࣺAꑱ\\u000bR<\\/A\\\"1a6鵌㯀bh곿w(\\\"$ꘁ*rಐ趣.d࿩k/抶면䒎9W⊃9\": \"漩b挋Sw藎\\u0000\",\n                                                                                                                                                       \"畀e㨼mK꙼HglKb,\\\"'䤜\": null\n                                                                                                                                                      }]}]\n                                                                                                                                                     ]\n                                                                                                                                                    ]\n                                                                                                                                                   }]\n                                                                                                                                                  ]}\n                                                                                                                                                 ]\n                                                                                                                                                ]}\n                                                                                                                                               ],\n                                                                                                                                               \"歙>駿ꣂ숰Q`J΋方樛(d鱾뼣(뫖턭\\u20f9lচ9歌8o]8윶l얶?镖G摄탗6폋폵+g:䱫홊<멀뀿/س|ꭺs걐跶稚W々c㫣⎖\": \"㣮蔊깚Cꓔ舊|XRf遻㆚︆'쾉췝\\\\&言\",\n                                                                                                                                               \"殭\\\"cށɨꝙ䞘:嬮e潽Y펪㳅/\\\"O@ࠗ겴]췖YǞ(t>R\\\"N?梳LD恭=n氯T豰2R諸#N}*灧4}㶊G䍣b얚\": null,\n                                                                                                                                               \"襞<\\/啧 B|싞W瓇)6簭鼡艆lN쩝`|펭佡\\\\間邝[z릶&쭟愱ꅅ\\\\T᰽1鯯偐栈4̸s윜R7⒝/똽?치X\": \"⏊躖Cﱰ2Qẫ脐&இ?%냝悊\",\n                                                                                                                                               \",鰧偵셣싹xᎹ힨᯳EṬH㹖9\": -4604276727380542356\n                                                                                                                                              }\n                                                                                                                                             }\n                                                                                                                                            ]]]],\n                                                                                                                                            \"웺㚑xs}q䭵䪠馯8?LB犯zK'os䚛HZ\\\"L?셎s^㿧㴘Cv2\": null\n                                                                                                                                           }]\n                                                                                                                                          ]\n                                                                                                                                         ]\n                                                                                                                                        ],\n                                                                                                                                        \"Kd2Kv+|z\": 7367845130646124107,\n                                                                                                                                        \"ᦂⶨ?ᝢ 祂些ഷ牢㋇操\\\"腭䙾㖪\\\\(y4cE뽺ㆷ쫺ᔖ%zfۻ$ў1柦,㶢9r漢\": -3.133230960444846E-20,\n                                                                                                                                        \"琘M焀q%㢟f鸯O⣏蓑맕鯊$O噷|)z褫^㢦⠮ꚯ꫞`毕1qꢚ{ĭ䎀বώT\\\"뱘3G൴?^^of\": null\n                                                                                                                                       }\n                                                                                                                                      ],\n                                                                                                                                      \"a8V᯺?:ﺃ/8ꉿBq|9啓댚;*i2\": null,\n                                                                                                                                      \"cpT瀇H珰Ừpೃi鎪Rr␣숬-鹸ҩ䠚z脚цGoN8入y%趌I┽2ឪЀiJNcN)槣/▟6S숆牟\\\"箑X僛G殱娇葱T%杻:J諹昰qV쨰\": 8331037591040855245\n                                                                                                                                     }],\n                                                                                                                                     \"G5ᩜ䄗巢껳\": true\n                                                                                                                                    }\n                                                                                                                                   },\n                                                                                                                                   \"Ồ巢ゕ@_譙A`碫鄐㡥砄㠓(^K\": \"?܃B혢▦@犑ὺD~T⧁|醁;o=J牌9냚⢽㨘{4觍蚔9#$∺\\u0016p囅\\\\3Xk阖⪚\\\"UzA穕롬✎➁㭒춺C㣌ဉ\\\"2瓑员ᅽꝶ뫍}꽚ꞇ鶂舟彺]ꍽJC蝧銉\",\n                                                                                                                                   \"␆Ě膝\\\"b-퉐ACR言J謈53~V튥x䜢?ꃽɄY뮩ꚜ\": \"K/↾e萃}]Bs⾿q룅鷦-膋?m+死^魊镲6\",\n                                                                                                                                   \"粡霦c枋AHퟁo礼Ke?qWcA趸㡔ꂏ?\\u000e춂8iতᦜ婪\\u0015㢼nﵿꍻ!ᐴ関\\u001d5j㨻gfῩUK5Ju丝tかTI'?㓏t>⼟o a>i}ᰗ;뤕ܝ\": false,\n                                                                                                                                   \"ꄮ匴껢ꂰ涽+䜨B蛹H䛓-k蕞fu7kL谖,'涃V~챳逋穞cT\\\"vQ쓕ObaCRQ㓡Ⲯ?轭⫦輢墳?vA餽=h䮇킵n폲퉅喙?\\\"'1疬V嬗Qd灗'Lự\": \"6v!s믁㭟㣯獃!磸餠ቂh0C뿯봗F鷭gꖶ~ｺkK<ᦈTt\\\\跓w㭣횋钘ᆹ듡䑚W䟾X'ꅔ4FL勉Vܴ邨y)2'〚쭉⽵-鞣E,Q.?块\",\n                                                                                                                                   \"?(˧쩯@崟吋歄K\": null\n                                                                                                                                  },\n                                                                                                                                  \"Gc럃녧>?2DYI鴿\\\\륨)澔0ᔬlx'觔7젘⤡縷螩%Sv׫묈/]↱&S h\\u0006歋ᑛxi̘}ひY蔯_醨鯘煑橾8?䵎쨋z儬ꁏ*@츾:\": null\n                                                                                                                                 }\n                                                                                                                                }\n                                                                                                                               }\n                                                                                                                              ]\n                                                                                                                             ]\n                                                                                                                            ]}\n                                                                                                                           },\n                                                                                                                           \"HO츧G\": 3.694949578823609E17,\n                                                                                                                           \"QC\\u0012(翻曇Tf㷟bGBJ옉53\\\\嚇ᛎD/\\u001b夾၉4\\\"핀@祎)쫆yD\\\"i먎Vn㿿V1W᨝䶀\": -6150931500380982286,\n                                                                                                                           \"Z㓮P翸鍱鉼K䋞꘺튿⭁Y\": -7704503411315138850,\n                                                                                                                           \"]모开ꬖP븣c霤<[3aΠ\\\"黁䖖䰑뮋ꤦ秽∼㑷冹T+YUt\\\"싳F↭䖏&鋌\": -2.7231911483181824E18,\n                                                                                                                           \"tꎖ\": -4.9517948741799555E-19,\n                                                                                                                           \"䋘즊.⬅IꬃۣQ챢ꄑ黐|f?C⾺|兕읯sC鬸섾整腨솷V\": \"旆柩l<K髝M戶鯮t:wR2ꉱ`9'l픪*폍芦㊢Pjjo堡^  읇얛嶅있ষ0?F\",\n                                                                                                                           \"下9T挞\\\\$yᮇk쌋⼇,ਉ\": true,\n                                                                                                                           \"櫨:ㆣ,邍lr崕祜㐮烜Z,XXD蕼㉴ kM꯽?P0﹉릗\": null,\n                                                                                                                           \"gv솠歽閘4镳䗄2澾>쪦sᖸMy㦅울썉瘗㎜檵9ꍂ駓ૉᚿ/u3씅徐拉[Z䞸ࡗ1ꆱ&Ｑ풘?ǂ8\\u0011BCDY2볨;鸏\": null,\n                                                                                                                           \"幫 n煥s쁇펇 왊-$C\\\"衝:\\u0014㣯舼.3뙗Yl⋇\\\"K迎멎[꽵s}9鉳UK8쐥\\\"掄㹖h㙈!얄સ?Ꜳ봺R伕UTD媚Ｉ䜘W鏨蔮\": -4.150842714188901E-17,\n                                                                                                                           \"ﺯ^㄄\\b죵@fྉkf颡팋Ꞧ{/Pm0V둳⻿/落韒ꊔᚬ@5螺G\\\\咸a谆⊪ቧ慷绖?财(鷇u錝F=r၍橢ឳn:^iᴵtD볠覅N赴\": null\n                                                                                                                          }]\n                                                                                                                         }]\n                                                                                                                        }\n                                                                                                                       ]\n                                                                                                                      ]}\n                                                                                                                     ]},\n                                                                                                                     \"謯?w厓奰T李헗聝ឍ貖o⪇弒L!캶$ᆅ\": -4299324168507841322,\n                                                                                                                     \"뺊奉_垐浸延몏孄Z舰2i$q붿좾껇d▵餏\\\"v暜Ҭ섁m￴g>\": -1.60911932510533427E18\n                                                                                                                    }\n                                                                                                                   ]\n                                                                                                                  }\n                                                                                                                 ]\n                                                                                                                ]],\n                                                                                                                \"퉝꺔㠦楶Pꅱ\": 7517896876489142899,\n                                                                                                                \"\": false\n                                                                                                               }\n                                                                                                              ]},\n                                                                                                              \"是u&I狻餼|谖j\\\"7c됮sסּ-踳鉷`䣷쉄_A艣鳞凃*m⯾☦椿q㎭N溔铉tlㆈ^\": 1.93547720203604352E18,\n                                                                                                              \"kⲨ\\\\%vr#\\u000bⒺY\\\\t<\\/3﬌R訤='﹠8蝤Ꞵ렴曔r\": false\n                                                                                                             }\n                                                                                                            ]},\n                                                                                                            \"阨{c?C\\u001d~K?鎌Ԭ8烫#뙣P초遗t㭱E­돒䆺}甗[R*1!\\\\~h㕅᰺@<9JꏏષI䳖栭6綘걹ￌM\\\"▯是∔v鬽顭⋊譬\": \"운ﶁK敂(欖C취پ℄爦賾\"\n                                                                                                           }\n                                                                                                          }}\n                                                                                                         }],\n                                                                                                         \"鷨赼鸙+\\\\䭣t圙ڹx᜾ČN<\\/踘\\\"S_맶a鷺漇T彚⎲i㈥LT-xA캔$\\u001cUH=a0츺l릦\": \"溣㣂0濕=鉵氬駘>Pꌢpb솇쬤h힊줎獪㪬CrQ矠a&脍꼬爼M茴/΅\\u0017弝轼y#Ꞡc6둴=?R崏뷠麖w?\"\n                                                                                                        },\n                                                                                                        \"閕ᘜ]CT)䵞l9z'xZF{:ؐI/躅匽졁:䟇AGF૸\\u001cퟗ9)駬慟ꡒꆒRS״툋A<>\\u0010\\\"ꂔ炃7g덚E৏bꅰ輤]o㱏_뷕ܘ暂\\\"u\": \"芢+U^+㢩^鱆8*1鈶鮀\\u0002뺰9⬳ꪮlL䃣괟,G8\\u20a8DF㉪錖0ㄤ瓶8Nଷd?眡GLc陓\\\\_죌V쁰ल二?c띦捱 \\u0019JC\\u0011b⤉zẒT볕\\\"绣蘨뚋cꡉkI\\u001e鳴\",\n                                                                                                        \"ꃣI'{6u^㡃#཰Kq4逹y൒䧠䵮!㱙/n??{L풓ZET㙠퍿X2᩟綳跠葿㚙w཮x캽扳B唕S|尾}촕%N?o䪨\": null,\n                                                                                                        \"ⰴFjෟ셈[\\u0018辷px?椯\\\\1<ﲻ栘ᣁ봢憠뉴p\": -5263694954586507640\n                                                                                                       }\n                                                                                                      ]\n                                                                                                     ]]\n                                                                                                    ]}\n                                                                                                   ]}]\n                                                                                                  ]\n                                                                                                 ],\n                                                                                                 \"?#癘82禩鋆ꊝty?&\": -1.9419029518535086E-19\n                                                                                                }\n                                                                                               ]\n                                                                                              ]\n                                                                                             ]}\n                                                                                            ]\n                                                                                           ]\n                                                                                          ],\n                                                                                          \"훊榲.|῕戄&.㚏Zꛦ2\\\"䢥ሆ⤢fV_摕婔?≍Fji冀탆꜕i㏬_ẑKᅢ꫄蔻XWc|饡Siẘ^㲦?羡2ぴ1縁ᙅ?쐉Ou\": false\n                                                                                         }]]\n                                                                                        ]}}},\n                                                                                        \"慂뗄卓蓔ᐓ匐嚖/颹蘯/翻ㆼL?뇊,텵<\\\\獷ごCボ\": null\n                                                                                       },\n                                                                                       \"p溉ᑟi짣z:䒤棇r^٫%G9缑r砌롧.물农g?0׼ሩ4ƸO㣥㯄쩞ጩ\": null,\n                                                                                       \"껎繥YxK\\\"F젷쨹뤤1wq轫o?鱑뜀瘊?뎃h灑\\\\ꛣ}K峐^ኖ⤐林ꉓhy\": null\n                                                                                      }\n                                                                                     ],\n                                                                                     \"᱀n肓ㄛ\\\"堻2>m殮'1橌%Ꞵ군=Ӳ鯨9耛<\\/n據0u彘8㬇៩f᏿诙]嚊\": \"䋯쪦S럶匏ㅛ#)O`ሀX_鐪渲⛀㨻宅闩➈ꢙஶDR⪍\"\n                                                                                    },\n                                                                                    \"tA썓龇 ⋥bj왎录r땽✒롰;羋^\\\\?툳*┎?썀ma䵳넅U䳆૘〹䆀LQ0\\b疀U~u$M}(鵸g⳾i抦뛹?䤈땚검.鹆?ꩡtⶥGĒ;!ቹHS峻B츪켏f5≺\": 2366175040075384032,\n                                                                                    \"전pJjleb]ួ\": -7.5418493141528422E18,\n                                                                                    \"n.鎖ጲ\\n?,$䪘\": true\n                                                                                   },\n                                                                                   \"欈Ar㉣螵᪚茩?O)\": null\n                                                                                  },\n                                                                                  \"쫸M#x}D秱欐K=侫们丐.KꕾxẠ\\u001e㿯䣛F܍캗qq8꟞ṢFD훎⵳簕꭛^鳜\\u205c٫~⑟~冫ऊ2쫰<\\/戲윱o<\\\"\": true\n                                                                                 },\n                                                                                 \"㷝聥/T뱂\\u0010锕|内䞇x侁≦㭖:M?iM᣿IJe煜dG࣯尃⚩gPt*辂.{磼럾䝪@a\\\\袛?}ᓺB珼\": true\n                                                                                }\n                                                                               }\n                                                                              ]]}]}},\n                                                                              \"tn\\\"6ꫤ샾䄄;銞^%VBPwu묪`Y僑N.↺Ws?3C⤻9唩S䠮ᐴm;sᇷ냞඘B/;툥B?lB∤)G+O9m裢0kC햪䪤\": -4.5941249382502277E18,\n                                                                              \"ᚔt'\\\\愫?鵀@\\\\びꂕP큠<<]煹G-b!S?\\nꖽ鼫,ݛ&頺y踦?E揆릱H}햧캡b@手.p탻>췽㣬ꒅ`qe佭P>ᓂ&?u}毚ᜉ蟶頳졪ᎏzl2wO\": -2.53561440423275936E17\n                                                                             }]}\n                                                                            }\n                                                                           ]\n                                                                          ]],\n                                                                          \"潈촒⿂叡\": 5495738871964062986\n                                                                         }\n                                                                        ]]\n                                                                       }\n                                                                      ]\n                                                                     ]}\n                                                                    ]]\n                                                                   ]]\n                                                                  ]}\n                                                                 ]\n                                                                ]},\n                                                                \"ႁq킍蓅R`謈蟐ᦏ儂槐僻ﹶ9婌櫞釈~\\\"%匹躾ɢ뤥>࢟瀴愅?殕节/냔O✬H鲽엢?ᮈੁ⋧d␽㫐zCe*\": 2.15062231586689536E17,\n                                                                \"㶵Ui曚珰鋪ᾼ臧P{䍏䷪쨑̟A뼿T渠誈䏚D1!잶<\\/㡍7?)2l≣穷᛾稝{:;㡹nemיּ訊`G\": null,\n                                                                \"䀕\\\"飕辭p圁f#뫆䶷뛮;⛴ᩍ3灚덏ᰝ쎓⦷詵%᜖Մfs⇫(\\u001e~P|ﭗCⲾផv湟W첋(텪બT<บSꏉ੗⋲X婵i ӵ⇮?L䬇|ꈏ?졸\": 1.548341247351782E-19\n                                                               }\n                                                              ]\n                                                             },\n                                                             \"t;:N\\u0015q鐦Rt缆{ꮐC?஛㷱敪\\\\+鲊㉫㓪몗릙竏(氵kYS\": \"XᰂT?൮ô\",\n                                                             \"碕飦幑|+ 㚦鏶`镥ꁩ B<\\/加륙\": -4314053432419755959,\n                                                             \"秌孳(p!G?V傫%8ሽ8w;5鲗㦙LI檸\\u2098\": \"zG N볞䆭鎍흘\\\\ONK3횙<\\/樚立圌Q튅k쩎Ff쁋aׂJK銆ઘ즐狩6༥✙䩜篥CzP(聻駇HHퟲ讃%,ά{렍p而刲vy䦅ክ^톺M楒鍢㹳]Mdg2>䤉洞\",\n                                                             \"踛M젧>忔芿㌜Zk\": 2215369545966507819,\n                                                             \"씐A`$槭頰퍻^U覒\\bG毲aᣴU;8!팲f꜇E⸃_卵{嫏羃X쀳C7뗮m(嚼u N܁谟D劯9]#\": true,\n                                                             \"ﻩ!뵸-筚P᭛}ἰ履lPh?౮ⶹꆛ穉뎃g萑㑓溢CX뾇G㖬A錟]RKaꄘ]Yo+@䘁's섎襠$^홰}F\": null\n                                                            },\n                                                            \"粘ꪒ4HXᕘ蹵.$區\\r\\u001d묁77pPc^y笲Q<\\/ꖶ 訍䃍ᨕG?*\": 1.73773035935040224E17\n                                                           },\n                                                           \"婅拳?bkU;#D矠❴vVN쩆t㜷A풃갮娪a%鮏絪3dAv룒#tm쑬⌛qYwc4|L8KZ;xU⓭㳔밆拓EZ7襨eD|隰ऌ䧼u9Ԣ+]贴P荿\": 2.9628516456987075E18\n                                                          }]}}]\n                                                         ]}\n                                                        }}\n                                                       ]}]\n                                                      ],\n                                                      \"|g翉F*湹̶\\u0005⏐1脉̀eI쩓ᖂ㫱0碞l䴨ꑅ㵽7AtἈ턧yq䳥塑:z:遀ﾼX눔擉)`N3昛oQ셖y-ڨ⾶恢ꈵq^<\\/\": null,\n                                                      \"菹\\\\랓G^璬x৴뭸ゆUS겧﮷Bꮤ ┉銜᯻0%N7}~f洋坄Xꔼ<\\/4妟Vꄟ9:౟곡t킅冩䧉笭裟炂4봋ⱳ叺怊t+怯涗\\\"0㖈Hq\": false,\n                                                      \"졬믟'ﺇফ圪쓬멤m邸QLব䗁愍4jvs翙 ྍ꧀艳H-|\": null,\n                                                      \"컮襱⣱뗠 R毪/鹙꾀%헳8&\": -5770986448525107020\n                                                     }\n                                                    ],\n                                                    \"B䔚bꐻ뙏姓展槰T-똌鷺tc灿᫽^㓟䏀o3o$꘭趙萬I顩)뇭Ἑ䓝\\f@{ᣨ`x3蔛\": null\n                                                   }\n                                                  ]\n                                                 ]\n                                                }],\n                                                \"⦖扚vWꃱ꥙㾠壢輓{-⎳鹷贏璿䜑bG倛⋐磎c皇皩7a~ﳫU╣Q࠭ꎉS摅姽OW.홌ೞ.\": null,\n                                                \"蚪eVlH献r}ᮏ믠ﰩꔄ@瑄ⲱ\": null,\n                                                \"퀭$JWoꩢg역쁍䖔㑺h&ୢtXX愰㱇?㾫I_6 OaB瑈q裿\": null,\n                                                \"꽦ﲼLyr纛Zdu珍B絟쬴糔?㕂짹䏵e\": \"ḱ\\u2009cX9멀i䶛簆㳀k\"\n                                               }\n                                              ]]]],\n                                              \"(_ꏮg່澮?ᩑyM<艷\\u001aꪽ\\\\庼뙭Z맷㰩Vm\\\\lY筺]3㋲2㌩㄀Eਟ䝵⨄쐨ᔟgङHn鐖⤇놋瓇Q탚單oY\\\"♆臾jHᶈ征ቄ??uㇰA?#1侓\": null\n                                             },\n                                             \"觓^~ሢ&iI띆g륎ḱ캀.ᓡꀮ胙鈉\": 1.0664523593012836E-19,\n                                             \"y詭Gbᔶऽs댁U:杜⤎ϲ쁗⮼D醄诿q뙰I#즧v蔎xHᵿt᡽[**?崮耖p缫쿃L菝,봬ꤦC쯵#=X1瞻@OZc鱗CQTx\": null\n                                            }\n                                           ]\n                                          }}],\n                                          \"剘紁\\u0004\\\\Xn⊠6,တױ;嵣崇}讃iႽ)d1\\\\䔓\": null\n                                         },\n                                         \"脨z\\\"{X,1u찜<'k&@?1}Yn$\\u0015Rd輲ｰa쮂굄+B$l\": true,\n                                         \"諳>*쭮괐䵟Ґ+<箁}빀䅱⡔檏臒hIH脟ꩪC핝ଗP좕\\\"0i<\\/C褻D۞恗+^5?'ꂱ䚫^7}㡠cq6\\\\쨪ꔞꥢ?纖䫀氮蒫侲빦敶q{A煲G\": -6880961710038544266\n                                        }}]\n                                       },\n                                       \"5s⨲JvಽῶꭂᄢI.a৊\": null,\n                                       \"?1q꽏쿻ꛋDR%U娝>DgN乭G\": -1.2105047302732358E-19\n                                      }\n                                     ]\n                                    ]},\n                                    \"qZz`撋뙹둣j碇쁏\\\\ꆥ\\u0018@藴疰Wz)O{F䶛l᷂绘訥$]뮍夻䢋䩇萿獰樧猵⣭j萶q)$꬚⵷0馢W:Ⱍ!Qoe\": -1666634370862219540,\n                                    \"t\": \"=wp|~碎Q鬳Ӎ\\\\l-<\\/^ﳊhn퐖}䍔t碵ḛ혷?靻䊗\",\n                                    \"邙쇡㯇%#=,E4勃驆V繚q[Y댻XV㡸[逹ᰏ葢B@u=JS5?bLRn얮㍉⏅ﰳ?a6[&큟!藈\": 1.2722786745736667E-19\n                                   },\n                                   \"X블땨4{ph鵋ꉯ웸 5p簂䦭s_E徔濧d稝~No穔噕뽲)뉈c5M윅>⚋[岦䲟懷恁?鎐꓆ฬ爋獠䜔s{\\u001bm鐚儸煛%bﯿXT>ꗘ@8G\": 1157841540507770724,\n                                   \"媤娪Q杸\\u0011SAyᡈ쿯\": true,\n                                   \"灚^ಸ%걁<\\/蛯<O\\\"-刷㏠R(kO=䢊䅎l䰓팪A絫픧\": \"譔\\\\㚄 ?R7㔪G㋉⣰渆?\\\\#|gN⤴;W칷A׫癮଼ೣ㏳뒜7d恓꾲0扬S0ᆵi/贎ྡn䆋武\",\n                                   \"萇砇Gこ朦켋Wq`㞲攊*冁~霓L剢zI腧튴T繙Cঅ뫬╈뮜ㄾ䦧촄椘B⊬츩r2f㶱厊8eϬ{挚␯OM焄覤\\\\(Kӡ>?\\\"祴坓\\\\\\\\'흍\": -3.4614808555942579E18,\n                                   \"釴U:O湛㴑䀣렑縓\\ta)<D8ﭳ槁髭D.L|xs斋敠\\\"띋早7wᎍ\": true,\n                                   \"쵈+쬎簨up䓬?q+~\\u0019仇뵈᫯3ᵣ恘枰劫㪢u珘-퀭:컙:u`⌿A(9鄦!<珚nj3:Hࣨ巋䀁旸뎈맻v\\\"\\\\(곘vO㤰aZe<\\/W鹙鄜;l厮둝\": null,\n                                   \"\": -1.2019926774977002E-18,\n                                   \"%者O7.Nꪍs梇接z蕜綛<\\/䜭\\\"죊y<曋漵@Ś⹝sD⟓jݗᢜ?z/9ၲMa쨮긗贎8ᔮ㦛;6p뾥໭䭊0B찛+)(Y㿠鸁䕒^옥\": \"鬃뫤&痽舎J콮藐󽸰ᨨMꈫ髿v<N\\\\.삒껅я1ꭼ5䴷5쳬臨wj덥\"\n                                  }],\n                                  \"鷎'㳗@帚妇OAj' 谬f94ǯ(횡ﾋ%io쪖삐좛>(j:숾却䗌gCiB뽬Oyuq輥厁/7)?今hY︺Q\": null\n                                 }\n                                ]\n                               ]]]}]\n                              ],\n                              \"I笔趠Ph!<ཛྷ㸞诘X$畉F\\u0005笷菟.Esr릙!W☆䲖뗷莾뒭U\\\"䀸犜Uo3Gꯌx4r蔇᡹㧪쨢準<䂀%ࡡꟼ瑍8炝Xs0䀝销?fi쥱ꆝલBB\": -8571484181158525797,\n                              \"L⦁o#J|\\\"⽩-㱢d㌛8d\\\\㶤傩儻E[Y熯)r噤὘勇 }\": \"e(濨쓌K䧚僒㘍蠤Vᛸ\\\"络QJL2,嬓왍伢㋒䴿考澰@(㏾`kX$끑эE斡,蜍&~y\",\n                              \"vj.|统圪ᵮPL?2oŶ`밧\\\"勃+0ue%⿥绬췈체$6:qa렐Q;~晘3㙘鹑\": true,\n                              \"ශؙ4獄⶿c︋i⚅:ん閝Ⳙ苆籦kw{䙞셕pC췃ꍬ␜꟯ꚓ酄b힝hwk꭭M鬋8B耳쑘WQ\\\\偙ac'唀x᪌\\u2048*h짎#ፇ鮠뾏ឿ뀌\": false,\n                              \"⎀jꄒ牺3Ⓝ컴~?親ꕽぼܓ喏瘘!@<튋㐌꿱⩦{a?Yv%⪧笯Uܱ栅E搚i뚬:ꄃx7䙳ꦋ&䓹vq☶I䁘ᾘ涜\\\\썉뺌Lr%Bc㍜3?ꝭ砿裞]\": null,\n                              \"⭤뙓z(㡂%亳K䌽꫿AԾ岺㦦㼴輞낚Vꦴw냟鬓㹈뽈+o3譻K1잞\": 2091209026076965894,\n                              \"ㇲ\\t⋇轑ꠤ룫X긒\\\"zoY읇희wj梐쐑l侸`e%s\": -9.9240075473576563E17,\n                              \"啸ꮑ㉰!ᚓ}銏\": -4.0694813896301194E18,\n                              \">]囋੽EK뇜>_ꀣ緳碖{쐐裔[<ನ\\\"䇅\\\"5L?#xTwv#罐\\u0005래t应\\\\N?빗;\": \"v쮽瞭p뭃\"\n                             }\n                            ]],\n                            \"斴槾?Z翁\\\"~慍弞ﻆ=꜡o5鐋dw\\\"?K蠡i샾ogDﲰ_C*⬟iㇷ4nય蟏[㟉U꽌娛苸 ঢ়操贻洞펻)쿗૊許X⨪VY츚Z䍾㶭~튃ᵦ<\\/E臭tve猑x嚢\": null,\n                            \"锡⛩<\\/칥ꈙᬙ蝀&Ꚑ籬■865?_>L詏쿨䈌浿弥爫̫lj&zx<\\/C쉾?覯n?\": null,\n                            \"꾳鑤/꼩d=ᘈn挫ᑩ䰬ZC\": \"3錢爋6Ƹ䴗v⪿Wr益G韠[\\u0010屗9쁡钁u?殢c䳀蓃樄욂NAq赟c튒瘁렶Aૡɚ捍\"\n                           }\n                          ]\n                         ]\n                        ]}\n                       ]\n                      ]\n                     }]]]}}\n                    ]}],\n                    \"Ej䗳U<\\/Q=灒샎䞦,堰頠@褙g_\\u0003ꤾfⶽ?퇋!łB〙ד3CC䌴鈌U:뭔咎(Qો臃䡬荋BO7㢝䟸\\\"Yb\": 2.36010731779814E-20,\n                    \"逸'0岔j\\u000e눘먷翌C츊秦=ꭣ棭ှ;鳸=麱$XP⩉駚橄A\\\\좱⛌jqv䰞3Ь踌v㳆¹gT┌gvLB賖烡m?@E঳i\": null\n                   },\n                   \"曺v찘ׁ?&绫O័\": 9107241066550187880\n                  }\n                 ]\n                ],\n                \"(e屄\\u0019昜훕琖b蓘ᬄ0/۲묇Z蘮ဏ⨏蛘胯뢃@㘉8ሪWᨮ⦬ᅳ䅴HI၇쨳z囕陻엣1赳o\": true,\n                \",b刈Z,ၠ晐T솝ŕB⩆ou'퐼≃绗雗d譊\": null,\n                \"a唥KB\\\"ﳝ肕$u\\n^⅄P䟼냉䞸⩪u윗瀱ꔨ#yşs꒬=1|ﲤ爢`t౐튼쳫_Az(Ṋ擬㦷좕耈6\": 2099309172767331582,\n                \"?㴸U<\\/䢔ꯡ阽扆㐤q鐋?f㔫wM嬙-;UV죫嚔픞G&\\\"Cᗍ䪏풊Q\": \"VM7疹+陕枡툩窲}翡䖶8欞čsT뮐}璤:jﺋ鎴}HfA൝⧻Zd#Qu茅J髒皣Y-︴[?-~쉜v딏璮㹚䅊﩯<-#\\u000e걀h\\u0004u抱﵊㼃U<㱷⊱IC進\"\n               },\n               \"숌dee節鏽邺p넱蹓+e罕U\": true\n              }\n             ],\n             \"b⧴룏??ᔠ3ぱ>%郿劃翐ꏬꠛW瞳᫏누躨狀ໄy੽\\\"ីuS=㨞馸k乆E\": \"トz݈^9R䬑<ﮛG<s~<\\/?ⵆᏥ老熷u듷\"\n            }}\n           ]\n          }\n         ]}\n        }\n       }\n      }\n     }},\n     \"宩j鬅쳜QꝖјy獔Z᭵1v擖}䨿F%cֲ᫺贴m塼딚NP亪\\\"ￋsa뺯ꘓ2:9뛓༂쌅䊈#>Rꨳ\\u000fTT泠纷꽀MR<CBxP񱒫X쇤\": -2.22390568492330598E18,\n     \"?䯣ᄽ@Z鸅->ᴱ纊:㠭볮?%N56%鈕1䗍䜁a䲗j陇=뿻偂衋࿘ᓸ?ᕵZ+<\\/}H耢b䀁z^f$&㝒LkꢳI脚뙛u\": 5.694374481577558E-20\n    }]\n   }\n  ]],\n  \"obj\": {\"key\": \"wrong value\"},\n  \"퓲꽪m{㶩/뇿#⼢&᭙硞㪔E嚉c樱㬇1a綑᝖DḾ䝩\": null\n }\n}"
  },
  {
    "path": "ext/rapidjson/bin/data/webapp.json",
    "content": "{\"web-app\": {\r\n  \"servlet\": [   \r\n    {\r\n      \"servlet-name\": \"cofaxCDS\",\r\n      \"servlet-class\": \"org.cofax.cds.CDSServlet\",\r\n      \"init-param\": {\r\n        \"configGlossary:installationAt\": \"Philadelphia, PA\",\r\n        \"configGlossary:adminEmail\": \"ksm@pobox.com\",\r\n        \"configGlossary:poweredBy\": \"Cofax\",\r\n        \"configGlossary:poweredByIcon\": \"/images/cofax.gif\",\r\n        \"configGlossary:staticPath\": \"/content/static\",\r\n        \"templateProcessorClass\": \"org.cofax.WysiwygTemplate\",\r\n        \"templateLoaderClass\": \"org.cofax.FilesTemplateLoader\",\r\n        \"templatePath\": \"templates\",\r\n        \"templateOverridePath\": \"\",\r\n        \"defaultListTemplate\": \"listTemplate.htm\",\r\n        \"defaultFileTemplate\": \"articleTemplate.htm\",\r\n        \"useJSP\": false,\r\n        \"jspListTemplate\": \"listTemplate.jsp\",\r\n        \"jspFileTemplate\": \"articleTemplate.jsp\",\r\n        \"cachePackageTagsTrack\": 200,\r\n        \"cachePackageTagsStore\": 200,\r\n        \"cachePackageTagsRefresh\": 60,\r\n        \"cacheTemplatesTrack\": 100,\r\n        \"cacheTemplatesStore\": 50,\r\n        \"cacheTemplatesRefresh\": 15,\r\n        \"cachePagesTrack\": 200,\r\n        \"cachePagesStore\": 100,\r\n        \"cachePagesRefresh\": 10,\r\n        \"cachePagesDirtyRead\": 10,\r\n        \"searchEngineListTemplate\": \"forSearchEnginesList.htm\",\r\n        \"searchEngineFileTemplate\": \"forSearchEngines.htm\",\r\n        \"searchEngineRobotsDb\": \"WEB-INF/robots.db\",\r\n        \"useDataStore\": true,\r\n        \"dataStoreClass\": \"org.cofax.SqlDataStore\",\r\n        \"redirectionClass\": \"org.cofax.SqlRedirection\",\r\n        \"dataStoreName\": \"cofax\",\r\n        \"dataStoreDriver\": \"com.microsoft.jdbc.sqlserver.SQLServerDriver\",\r\n        \"dataStoreUrl\": \"jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon\",\r\n        \"dataStoreUser\": \"sa\",\r\n        \"dataStorePassword\": \"dataStoreTestQuery\",\r\n        \"dataStoreTestQuery\": \"SET NOCOUNT ON;select test='test';\",\r\n        \"dataStoreLogFile\": \"/usr/local/tomcat/logs/datastore.log\",\r\n        \"dataStoreInitConns\": 10,\r\n        \"dataStoreMaxConns\": 100,\r\n        \"dataStoreConnUsageLimit\": 100,\r\n        \"dataStoreLogLevel\": \"debug\",\r\n        \"maxUrlLength\": 500}},\r\n    {\r\n      \"servlet-name\": \"cofaxEmail\",\r\n      \"servlet-class\": \"org.cofax.cds.EmailServlet\",\r\n      \"init-param\": {\r\n      \"mailHost\": \"mail1\",\r\n      \"mailHostOverride\": \"mail2\"}},\r\n    {\r\n      \"servlet-name\": \"cofaxAdmin\",\r\n      \"servlet-class\": \"org.cofax.cds.AdminServlet\"},\r\n \r\n    {\r\n      \"servlet-name\": \"fileServlet\",\r\n      \"servlet-class\": \"org.cofax.cds.FileServlet\"},\r\n    {\r\n      \"servlet-name\": \"cofaxTools\",\r\n      \"servlet-class\": \"org.cofax.cms.CofaxToolsServlet\",\r\n      \"init-param\": {\r\n        \"templatePath\": \"toolstemplates/\",\r\n        \"log\": 1,\r\n        \"logLocation\": \"/usr/local/tomcat/logs/CofaxTools.log\",\r\n        \"logMaxSize\": \"\",\r\n        \"dataLog\": 1,\r\n        \"dataLogLocation\": \"/usr/local/tomcat/logs/dataLog.log\",\r\n        \"dataLogMaxSize\": \"\",\r\n        \"removePageCache\": \"/content/admin/remove?cache=pages&id=\",\r\n        \"removeTemplateCache\": \"/content/admin/remove?cache=templates&id=\",\r\n        \"fileTransferFolder\": \"/usr/local/tomcat/webapps/content/fileTransferFolder\",\r\n        \"lookInContext\": 1,\r\n        \"adminGroupID\": 4,\r\n        \"betaServer\": true}}],\r\n  \"servlet-mapping\": {\r\n    \"cofaxCDS\": \"/\",\r\n    \"cofaxEmail\": \"/cofaxutil/aemail/*\",\r\n    \"cofaxAdmin\": \"/admin/*\",\r\n    \"fileServlet\": \"/static/*\",\r\n    \"cofaxTools\": \"/tools/*\"},\r\n \r\n  \"taglib\": {\r\n    \"taglib-uri\": \"cofax.tld\",\r\n    \"taglib-location\": \"/WEB-INF/tlds/cofax.tld\"}}}"
  },
  {
    "path": "ext/rapidjson/bin/data/widget.json",
    "content": "{\"widget\": {\r\n    \"debug\": \"on\",\r\n    \"window\": {\r\n        \"title\": \"Sample Konfabulator Widget\",\r\n        \"name\": \"main_window\",\r\n        \"width\": 500,\r\n        \"height\": 500\r\n    },\r\n    \"image\": { \r\n        \"src\": \"Images/Sun.png\",\r\n        \"name\": \"sun1\",\r\n        \"hOffset\": 250,\r\n        \"vOffset\": 250,\r\n        \"alignment\": \"center\"\r\n    },\r\n    \"text\": {\r\n        \"data\": \"Click Here\",\r\n        \"size\": 36,\r\n        \"style\": \"bold\",\r\n        \"name\": \"text1\",\r\n        \"hOffset\": 250,\r\n        \"vOffset\": 100,\r\n        \"alignment\": \"center\",\r\n        \"onMouseUp\": \"sun1.opacity = (sun1.opacity / 100) * 90;\"\r\n    }\r\n}}"
  },
  {
    "path": "ext/rapidjson/bin/encodings/utf8.json",
    "content": "{\r\n\t\"en\":\"I can eat glass and it doesn't hurt me.\",\r\n\t\"zh-Hant\":\"我能吞下玻璃而不傷身體。\",\r\n\t\"zh-Hans\":\"我能吞下玻璃而不伤身体。\",\r\n\t\"ja\":\"私はガラスを食べられます。それは私を傷つけません。\",\r\n\t\"ko\":\"나는 유리를 먹을 수 있어요. 그래도 아프지 않아요\"\r\n}"
  },
  {
    "path": "ext/rapidjson/bin/encodings/utf8bom.json",
    "content": "﻿{\r\n\t\"en\":\"I can eat glass and it doesn't hurt me.\",\r\n\t\"zh-Hant\":\"我能吞下玻璃而不傷身體。\",\r\n\t\"zh-Hans\":\"我能吞下玻璃而不伤身体。\",\r\n\t\"ja\":\"私はガラスを食べられます。それは私を傷つけません。\",\r\n\t\"ko\":\"나는 유리를 먹을 수 있어요. 그래도 아프지 않아요\"\r\n}"
  },
  {
    "path": "ext/rapidjson/bin/types/booleans.json",
    "content": "[\n  true,\n  true,\n  false,\n  false,\n  true,\n  true,\n  true,\n  false,\n  false,\n  true,\n  false,\n  false,\n  true,\n  false,\n  false,\n  false,\n  true,\n  false,\n  false,\n  true,\n  true,\n  false,\n  true,\n  true,\n  true,\n  false,\n  false,\n  false,\n  true,\n  false,\n  true,\n  false,\n  false,\n  true,\n  true,\n  true,\n  true,\n  true,\n  true,\n  false,\n  false,\n  true,\n  false,\n  false,\n  false,\n  true,\n  true,\n  false,\n  true,\n  true,\n  false,\n  true,\n  false,\n  true,\n  true,\n  true,\n  false,\n  false,\n  false,\n  true,\n  false,\n  false,\n  false,\n  true,\n  true,\n  false,\n  true,\n  true,\n  true,\n  true,\n  true,\n  true,\n  true,\n  true,\n  false,\n  false,\n  false,\n  false,\n  false,\n  true,\n  true,\n  true,\n  true,\n  true,\n  true,\n  true,\n  false,\n  false,\n  false,\n  true,\n  false,\n  false,\n  false,\n  true,\n  true,\n  true,\n  false,\n  false,\n  true,\n  false\n]"
  },
  {
    "path": "ext/rapidjson/bin/types/floats.json",
    "content": "[\n  135.747111636,\n  123.377054008,\n  140.527504552,\n  -72.299143906,\n  -23.851678949,\n  73.586193519,\n  -158.299382442,\n  177.477876032,\n  32.268518982,\n  -139.560009969,\n  115.203105183,\n  -106.025823607,\n  167.224138231,\n  103.378383732,\n  -97.498486285,\n  18.184723416,\n  69.137075711,\n  33.849002681,\n  -120.185228215,\n  -20.841408615,\n  -172.659492727,\n  -2.691464061,\n  22.426164066,\n  -98.416909437,\n  -31.603082708,\n  -85.072296561,\n  108.620987395,\n  -43.127078238,\n  -126.473562057,\n  -158.595489097,\n  -57.890678254,\n  -13.254016573,\n  -85.024504709,\n  171.663552644,\n  -146.495558248,\n  -10.606748276,\n  -118.786969354,\n  153.352057804,\n  -45.215545083,\n  37.038725288,\n  106.344071897,\n  -64.607402031,\n  85.148030911,\n  28.897784566,\n  39.51082061,\n  20.450382102,\n  -113.174943618,\n  71.60785784,\n  -168.202648062,\n  -157.338200017,\n  10.879588527,\n  -114.261694831,\n  -5.622927072,\n  -173.330830616,\n  -29.47002003,\n  -39.829034201,\n  50.031545162,\n  82.815735508,\n  -119.188760828,\n  -48.455928081,\n  163.964263034,\n  46.30378861,\n  -26.248889762,\n  -47.354615322,\n  155.388677633,\n  -166.710356904,\n  42.987233558,\n  144.275297374,\n  37.394383186,\n  -122.550388725,\n  177.469945914,\n  101.104677413,\n  109.429869885,\n  -104.919625624,\n  147.522756541,\n  -81.294703727,\n  122.744731363,\n  81.803603684,\n  26.321556167,\n  147.045441354,\n  147.256895816,\n  -174.211095908,\n  52.518769316,\n  -78.58250334,\n  -173.356685435,\n  -107.728209264,\n  -69.982325771,\n  -113.776095893,\n  -35.785267074,\n  -105.748545976,\n  -30.206523864,\n  -76.185311723,\n  -126.400112781,\n  -26.864958639,\n  56.840053629,\n  93.781553535,\n  -116.002949803,\n  -46.617140948,\n  176.846840093,\n  -144.24821335\n]\n"
  },
  {
    "path": "ext/rapidjson/bin/types/guids.json",
    "content": "[\n  \"d35bf0d4-8d8f-4e17-a5c3-ad9bfd675266\",\n  \"db402774-eeb6-463b-9986-c458c44d8b5a\",\n  \"2a2e4101-b5f2-40b8-8750-e03f01661e60\",\n  \"76787cfa-f4eb-4d62-aaad-e1d588d00ad5\",\n  \"fd73894b-b500-4a7c-888c-06b5bd9cec65\",\n  \"cce1862a-cf31-4ef2-9e23-f1d23b4e6163\",\n  \"00a98bb0-2b6e-4368-8512-71c21aa87db7\",\n  \"ab9a8d69-cec7-4550-bd35-3ed678e22782\",\n  \"f18b48e1-5114-4fbe-9652-579e8d66950e\",\n  \"4efe3baa-7ac5-4d6a-a839-6b9cfe825764\",\n  \"b4aec119-5b0a-434c-b388-109816c482a5\",\n  \"e0ef0cbb-127a-4a28-9831-5741b4295275\",\n  \"d50286a5-cb7b-4c9e-be99-f214439bae8c\",\n  \"a981094c-f1ac-42ed-a9fa-86404c7210ff\",\n  \"2a34ee57-5815-4829-b77b-eeebaa8fe340\",\n  \"a0530d44-48f8-4eff-b9ea-8810c4308351\",\n  \"c6f91509-83e1-4ea1-9680-e667fbfd56ee\",\n  \"cab11402-dcdd-4454-b190-6da124947395\",\n  \"283d159c-2b18-4856-b4c7-5059252eaa15\",\n  \"146157c6-72a8-4051-9991-cb6ea6743d81\",\n  \"aef6f269-7306-4bd2-83f7-6d5605b5dc9a\",\n  \"37fe6027-d638-4017-80a9-e7b0567b278e\",\n  \"5003d731-33fb-4159-af61-d76348a44079\",\n  \"e0e06979-5f80-4713-9fe0-8a4d60dc89f8\",\n  \"7e85bdc3-0345-4cb6-9398-ccab06e79976\",\n  \"f2ebf5af-6568-4ffe-a46d-403863fd4b66\",\n  \"e0b5bb1c-b4dd-4535-9a9e-3c73f1167d46\",\n  \"c852d20b-6bcb-4b12-bd57-308296c64c5a\",\n  \"7ac3ae82-1818-49cd-a8a4-5ac77dfafd46\",\n  \"138004a9-76e2-4ad7-bd42-e74dabdbb803\",\n  \"ab25b5be-96be-45b0-b765-947b40ec36a6\",\n  \"08404734-fd57-499e-a4cf-71e9ec782ede\",\n  \"8dfdeb16-248b-4a21-bf89-2e22b11a4101\",\n  \"a0e44ef0-3b09-41e8-ad5d-ed8e6a1a2a67\",\n  \"a7981e49-188d-414a-9779-b1ad91e599d1\",\n  \"329186c0-bf27-4208-baf7-c0a0a5a2d5b7\",\n  \"cb5f3381-d33e-4b30-b1a9-f482623cad33\",\n  \"15031262-ca73-4e3c-bd0a-fcf89bdf0caf\",\n  \"6d7333d1-2e8c-4d78-bfde-5be47e70eb13\",\n  \"acaa160c-670a-4e8f-ac45-49416e77d5f9\",\n  \"228f87eb-cde4-4106-808b-2dbf3c7b6d2e\",\n  \"2ff830a3-5445-4d8e-b161-bddd30666697\",\n  \"f488bedd-ff6e-4108-b9a7-07f6da62f476\",\n  \"2e12b846-0a34-478e-adf7-a438493803e6\",\n  \"6686b8ef-7446-4d86-bd8c-df24119e3bfe\",\n  \"e474a5c5-5793-4d41-b4ab-5423acc56ef1\",\n  \"ac046573-e718-44dc-a0dc-9037eeaba6a9\",\n  \"6b0e9099-cf53-4d5a-8a71-977528628fcf\",\n  \"d51a3f22-0ff9-4087-ba9b-fcee2a2d8ade\",\n  \"bdc01286-3511-4d22-bfb8-76d01203d366\",\n  \"ca44eb84-17ff-4f27-8f1e-1bd25f4e8725\",\n  \"4e9a8c2f-be0b-4913-92d2-c801b9a50d04\",\n  \"7685d231-dadd-4041-9165-898397438ab7\",\n  \"86f0bf26-d66a-44d8-99f5-d6768addae3b\",\n  \"2ca1167c-72ba-45a0-aa42-faf033db0d0b\",\n  \"199a1182-ea55-49ff-ba51-71c29cdd0aac\",\n  \"be6a4dd2-c821-4aa0-8b83-d64d6644b5b2\",\n  \"4c5f4781-7f80-4daa-9c20-76b183000514\",\n  \"513b31bd-54fb-4d12-a427-42a7c13ff8e1\",\n  \"8e211bcb-d76c-4012-83ad-74dd7d23b687\",\n  \"44d5807e-0501-4f66-8779-e244d4fdca0a\",\n  \"db8cd555-0563-4b7b-b00c-eada300a7065\",\n  \"cb14d0c9-46cc-4797-bd3a-752b05629f07\",\n  \"4f68b3ef-ac9b-47a0-b6d7-57f398a5c6a5\",\n  \"77221aae-1bcf-471c-be45-7f31f733f9d6\",\n  \"42a7cac8-9e80-4c45-8c71-511d863c98ea\",\n  \"f9018d22-b82c-468c-bdb5-8864d5964801\",\n  \"75f4e9b8-62a2-4f21-ad8a-e19eff0419bc\",\n  \"9b7385c8-8653-4184-951c-b0ac1b36b42e\",\n  \"571018aa-ffbf-4b42-a16d-07b57a7f5f0e\",\n  \"35de4a2f-6bf1-45aa-b820-2a27ea833e44\",\n  \"0b8edb20-3bb4-4cb4-b089-31957466dbab\",\n  \"97da4778-9a7b-4140-a545-968148c81fb7\",\n  \"969f326c-8f2a-47c5-b41c-d9c2f06c9b9d\",\n  \"ae211037-8b53-4b17-bfc8-c06fc7774409\",\n  \"12c5c3c4-0bd5-45d3-bc1d-d04a3c65d3e6\",\n  \"ec02024f-ce43-4dd3-8169-a59f7baee043\",\n  \"5b6afe77-ce48-47ca-90a0-25cd10ca5ffd\",\n  \"2e3a61d4-6b8f-4d2f-ba86-878b4012efd8\",\n  \"19a88a67-a5d3-4647-898f-1cde07bce040\",\n  \"6db6f420-b5c8-48b9-bbb2-8864fe6fed65\",\n  \"5a45dbde-7b53-4f6b-b864-e3b63be3708a\",\n  \"c878321b-8a02-4239-9981-15760c2e7d15\",\n  \"4e36687f-8bf6-4b12-b496-3a8e382d067e\",\n  \"a59a63cd-43c0-4c6e-b208-6dbca86f8176\",\n  \"303308c4-2e4a-45b5-8bf3-3e66e9ad05a1\",\n  \"8b58fdf1-43a6-4c98-9547-6361b50791af\",\n  \"a3563591-72ed-42b5-8e41-bac1d76d70cf\",\n  \"38db8c78-3739-4f6e-8313-de4138082114\",\n  \"86615bea-7e73-4daf-95da-ae6b9eee1bbb\",\n  \"35d38e3e-076e-40dd-9aa8-05be2603bd59\",\n  \"9f84c62d-b454-4ba3-8c19-a01878985cdc\",\n  \"6721bbae-d765-4a06-8289-6fe46a1bf943\",\n  \"0837796f-d0dd-4e50-9b7c-1983e6cc7c48\",\n  \"021eb7d7-e869-49b9-80c3-9dd16ce2d981\",\n  \"819c56f8-e040-475d-aad5-c6d5e98b20aa\",\n  \"3a61ef02-735e-4229-937d-b3777a3f4e1f\",\n  \"79dfab84-12e6-4ec8-bfc8-460ae71e4eca\",\n  \"a106fabf-e149-476c-8053-b62388b6eb57\",\n  \"9a3900a5-bfb4-4de0-baa5-253a8bd0b634\"\n]"
  },
  {
    "path": "ext/rapidjson/bin/types/integers.json",
    "content": "[\n  8125686,\n  8958709,\n  5976222,\n  1889524,\n  7968493,\n  1357486,\n  118415,\n  7081097,\n  4635968,\n  7555332,\n  2270233,\n  3428352,\n  8699968,\n  2087333,\n  7861337,\n  7554440,\n  2017031,\n  7981692,\n  6060687,\n  1877715,\n  3297474,\n  8373177,\n  6158629,\n  7853641,\n  3004441,\n  9650406,\n  2695251,\n  1180761,\n  4988426,\n  6043805,\n  8063373,\n  6103218,\n  2848339,\n  8188690,\n  9235573,\n  5949816,\n  6116081,\n  6471138,\n  3354531,\n  4787414,\n  9660600,\n  942529,\n  7278535,\n  7967399,\n  554292,\n  1436493,\n  267319,\n  2606657,\n  7900601,\n  4276634,\n  7996757,\n  8544466,\n  7266469,\n  3301373,\n  4005350,\n  6437652,\n  7717672,\n  7126292,\n  8588394,\n  2127902,\n  7410190,\n  1517806,\n  4583602,\n  3123440,\n  7747613,\n  5029464,\n  9834390,\n  3087227,\n  4913822,\n  7550487,\n  4518144,\n  5862588,\n  1778599,\n  9493290,\n  5588455,\n  3638706,\n  7394293,\n  4294719,\n  3837830,\n  6381878,\n  7175866,\n  8575492,\n  1415229,\n  1453733,\n  6972404,\n  9782571,\n  4234063,\n  7117418,\n  7293130,\n  8057071,\n  9345285,\n  7626648,\n  3358911,\n  4574537,\n  9371826,\n  7627107,\n  6154093,\n  5392367,\n  5398105,\n  6956377\n]"
  },
  {
    "path": "ext/rapidjson/bin/types/mixed.json",
    "content": "[\n  {\n    \"favoriteFruit\": \"banana\",\n    \"greeting\": \"Hello, Kim! You have 10 unread messages.\",\n    \"friends\": [\n      {\n        \"name\": \"Higgins Rodriquez\",\n        \"id\": 0\n      },\n      {\n        \"name\": \"James Floyd\",\n        \"id\": 1\n      },\n      {\n        \"name\": \"Gay Stewart\",\n        \"id\": 2\n      }\n    ],\n    \"range\": [\n      0,\n      1,\n      2,\n      3,\n      4,\n      5,\n      6,\n      7,\n      8,\n      9\n    ],\n    \"tags\": [\n      \"pariatur\",\n      \"ad\",\n      \"eiusmod\",\n      \"sit\",\n      \"et\",\n      \"velit\",\n      \"culpa\"\n    ],\n    \"longitude\": -57.919246,\n    \"latitude\": -36.022812,\n    \"registered\": \"Friday, March 21, 2014 9:13 PM\",\n    \"about\": \"Laborum nulla aliquip ullamco proident excepteur est officia ipsum. Eiusmod exercitation minim ex do labore reprehenderit aliqua minim qui excepteur reprehenderit cupidatat. Sint enim exercitation duis id consequat nisi enim magna. Commodo aliqua id ipsum sit magna enim. Veniam officia in labore fugiat veniam ea laboris ex veniam duis.\\r\\n\",\n    \"address\": \"323 Pulaski Street, Ronco, North Carolina, 7701\",\n    \"phone\": \"+1 (919) 438-2678\",\n    \"email\": \"kim.griffith@cipromox.biz\",\n    \"company\": \"CIPROMOX\",\n    \"name\": {\n      \"last\": \"Griffith\",\n      \"first\": \"Kim\"\n    },\n    \"eyeColor\": \"green\",\n    \"age\": 26,\n    \"picture\": \"http://placehold.it/32x32\",\n    \"balance\": \"$1,283.55\",\n    \"isActive\": false,\n    \"guid\": \"10ab0392-c5e2-48a3-9473-aa725bad892d\",\n    \"index\": 0,\n    \"_id\": \"551b91198238a0bcf9a41133\"\n  },\n  {\n    \"favoriteFruit\": \"banana\",\n    \"greeting\": \"Hello, Skinner! You have 9 unread messages.\",\n    \"friends\": [\n      {\n        \"name\": \"Rhonda Justice\",\n        \"id\": 0\n      },\n      {\n        \"name\": \"Audra Castaneda\",\n        \"id\": 1\n      },\n      {\n        \"name\": \"Vicky Chavez\",\n        \"id\": 2\n      }\n    ],\n    \"range\": [\n      0,\n      1,\n      2,\n      3,\n      4,\n      5,\n      6,\n      7,\n      8,\n      9\n    ],\n    \"tags\": [\n      \"dolore\",\n      \"enim\",\n      \"sit\",\n      \"non\",\n      \"exercitation\",\n      \"fugiat\",\n      \"adipisicing\"\n    ],\n    \"longitude\": -60.291407,\n    \"latitude\": -84.619318,\n    \"registered\": \"Friday, February 7, 2014 3:17 AM\",\n    \"about\": \"Consectetur eiusmod laboris dolore est ullamco nulla in velit quis esse Lorem. Amet aliqua sunt aute occaecat veniam officia in duis proident aliqua cupidatat mollit. Sint eu qui anim duis ut anim duis eu cillum. Cillum nostrud adipisicing tempor Lorem commodo sit in ad qui non et irure qui. Labore eu aliquip id duis eiusmod veniam.\\r\\n\",\n    \"address\": \"347 Autumn Avenue, Fidelis, Puerto Rico, 543\",\n    \"phone\": \"+1 (889) 457-2319\",\n    \"email\": \"skinner.maddox@moltonic.co.uk\",\n    \"company\": \"MOLTONIC\",\n    \"name\": {\n      \"last\": \"Maddox\",\n      \"first\": \"Skinner\"\n    },\n    \"eyeColor\": \"green\",\n    \"age\": 22,\n    \"picture\": \"http://placehold.it/32x32\",\n    \"balance\": \"$3,553.10\",\n    \"isActive\": false,\n    \"guid\": \"cfbc2fb6-2641-4388-b06d-ec0212cfac1e\",\n    \"index\": 1,\n    \"_id\": \"551b91197e0abe92d6642700\"\n  },\n  {\n    \"favoriteFruit\": \"strawberry\",\n    \"greeting\": \"Hello, Reynolds! You have 5 unread messages.\",\n    \"friends\": [\n      {\n        \"name\": \"Brady Valdez\",\n        \"id\": 0\n      },\n      {\n        \"name\": \"Boyer Golden\",\n        \"id\": 1\n      },\n      {\n        \"name\": \"Gladys Knapp\",\n        \"id\": 2\n      }\n    ],\n    \"range\": [\n      0,\n      1,\n      2,\n      3,\n      4,\n      5,\n      6,\n      7,\n      8,\n      9\n    ],\n    \"tags\": [\n      \"commodo\",\n      \"eiusmod\",\n      \"cupidatat\",\n      \"et\",\n      \"occaecat\",\n      \"proident\",\n      \"Lorem\"\n    ],\n    \"longitude\": 140.866287,\n    \"latitude\": 1.401032,\n    \"registered\": \"Monday, October 20, 2014 8:01 AM\",\n    \"about\": \"Deserunt elit consequat ea dolor pariatur aute consectetur et nulla ipsum ad. Laboris occaecat ipsum ad duis et esse ea ut voluptate. Ex magna consequat pariatur amet. Quis excepteur non mollit dolore cillum dolor ex esse veniam esse deserunt non occaecat veniam. Sit amet proident proident amet. Nisi est id ut ut adipisicing esse fugiat non dolor aute.\\r\\n\",\n    \"address\": \"872 Montague Terrace, Haena, Montana, 3106\",\n    \"phone\": \"+1 (974) 410-2655\",\n    \"email\": \"reynolds.sanford@combot.biz\",\n    \"company\": \"COMBOT\",\n    \"name\": {\n      \"last\": \"Sanford\",\n      \"first\": \"Reynolds\"\n    },\n    \"eyeColor\": \"green\",\n    \"age\": 21,\n    \"picture\": \"http://placehold.it/32x32\",\n    \"balance\": \"$3,664.47\",\n    \"isActive\": true,\n    \"guid\": \"f9933a9c-c41a-412f-a18d-e727c569870b\",\n    \"index\": 2,\n    \"_id\": \"551b91197f170b65413a06e3\"\n  },\n  {\n    \"favoriteFruit\": \"banana\",\n    \"greeting\": \"Hello, Neva! You have 7 unread messages.\",\n    \"friends\": [\n      {\n        \"name\": \"Clara Cotton\",\n        \"id\": 0\n      },\n      {\n        \"name\": \"Ray Gates\",\n        \"id\": 1\n      },\n      {\n        \"name\": \"Jacobs Reese\",\n        \"id\": 2\n      }\n    ],\n    \"range\": [\n      0,\n      1,\n      2,\n      3,\n      4,\n      5,\n      6,\n      7,\n      8,\n      9\n    ],\n    \"tags\": [\n      \"magna\",\n      \"labore\",\n      \"incididunt\",\n      \"velit\",\n      \"ea\",\n      \"et\",\n      \"eiusmod\"\n    ],\n    \"longitude\": -133.058479,\n    \"latitude\": 87.803677,\n    \"registered\": \"Friday, May 9, 2014 5:41 PM\",\n    \"about\": \"Do duis occaecat ut officia occaecat officia nostrud reprehenderit ex excepteur aute anim in reprehenderit. Cupidatat nulla eiusmod nulla non minim veniam aute nulla deserunt adipisicing consectetur veniam. Sit consequat ex laboris aliqua labore consectetur tempor proident consequat est. Fugiat quis esse culpa aliquip. Excepteur laborum aliquip sunt eu cupidatat magna eiusmod amet nisi labore aliquip. Ut consectetur esse aliquip exercitation nulla ex occaecat elit do ex eiusmod deserunt. Ex eu voluptate minim deserunt fugiat minim est occaecat ad Lorem nisi.\\r\\n\",\n    \"address\": \"480 Eagle Street, Fostoria, Oklahoma, 2614\",\n    \"phone\": \"+1 (983) 439-3000\",\n    \"email\": \"neva.barker@pushcart.us\",\n    \"company\": \"PUSHCART\",\n    \"name\": {\n      \"last\": \"Barker\",\n      \"first\": \"Neva\"\n    },\n    \"eyeColor\": \"brown\",\n    \"age\": 36,\n    \"picture\": \"http://placehold.it/32x32\",\n    \"balance\": \"$3,182.24\",\n    \"isActive\": true,\n    \"guid\": \"52489849-78e1-4b27-8b86-e3e5ab2b7dc8\",\n    \"index\": 3,\n    \"_id\": \"551b9119a13061c083c878d5\"\n  },\n  {\n    \"favoriteFruit\": \"banana\",\n    \"greeting\": \"Hello, Rodgers! You have 6 unread messages.\",\n    \"friends\": [\n      {\n        \"name\": \"Marguerite Conway\",\n        \"id\": 0\n      },\n      {\n        \"name\": \"Margarita Cunningham\",\n        \"id\": 1\n      },\n      {\n        \"name\": \"Carmela Gallagher\",\n        \"id\": 2\n      }\n    ],\n    \"range\": [\n      0,\n      1,\n      2,\n      3,\n      4,\n      5,\n      6,\n      7,\n      8,\n      9\n    ],\n    \"tags\": [\n      \"ipsum\",\n      \"magna\",\n      \"amet\",\n      \"elit\",\n      \"sit\",\n      \"occaecat\",\n      \"elit\"\n    ],\n    \"longitude\": -125.436981,\n    \"latitude\": 19.868524,\n    \"registered\": \"Tuesday, July 8, 2014 8:09 PM\",\n    \"about\": \"In cillum esse tempor do magna id ad excepteur ex nostrud mollit deserunt aliqua. Minim aliqua commodo commodo consectetur exercitation nulla nisi dolore aliqua in. Incididunt deserunt mollit nostrud excepteur. Ipsum fugiat anim deserunt Lorem aliquip nisi consequat eu minim in ex duis.\\r\\n\",\n    \"address\": \"989 Varanda Place, Duryea, Palau, 3972\",\n    \"phone\": \"+1 (968) 578-2974\",\n    \"email\": \"rodgers.conner@frenex.net\",\n    \"company\": \"FRENEX\",\n    \"name\": {\n      \"last\": \"Conner\",\n      \"first\": \"Rodgers\"\n    },\n    \"eyeColor\": \"blue\",\n    \"age\": 23,\n    \"picture\": \"http://placehold.it/32x32\",\n    \"balance\": \"$1,665.17\",\n    \"isActive\": true,\n    \"guid\": \"ed3b2374-5afe-4fca-9325-8a7bbc9f81a0\",\n    \"index\": 4,\n    \"_id\": \"551b91197bcedb1b56a241ce\"\n  },\n  {\n    \"favoriteFruit\": \"strawberry\",\n    \"greeting\": \"Hello, Mari! You have 10 unread messages.\",\n    \"friends\": [\n      {\n        \"name\": \"Irwin Boyd\",\n        \"id\": 0\n      },\n      {\n        \"name\": \"Dejesus Flores\",\n        \"id\": 1\n      },\n      {\n        \"name\": \"Lane Mcmahon\",\n        \"id\": 2\n      }\n    ],\n    \"range\": [\n      0,\n      1,\n      2,\n      3,\n      4,\n      5,\n      6,\n      7,\n      8,\n      9\n    ],\n    \"tags\": [\n      \"esse\",\n      \"aliquip\",\n      \"excepteur\",\n      \"dolor\",\n      \"ex\",\n      \"commodo\",\n      \"anim\"\n    ],\n    \"longitude\": -17.038176,\n    \"latitude\": 17.154663,\n    \"registered\": \"Sunday, April 6, 2014 4:46 AM\",\n    \"about\": \"Excepteur veniam occaecat sint nulla magna in in officia elit. Eiusmod qui dolor fugiat tempor in minim esse officia minim consequat. Lorem ullamco labore proident ipsum id pariatur fugiat consectetur anim cupidatat qui proident non ipsum.\\r\\n\",\n    \"address\": \"563 Hendrickson Street, Westwood, South Dakota, 4959\",\n    \"phone\": \"+1 (980) 434-3976\",\n    \"email\": \"mari.fleming@beadzza.org\",\n    \"company\": \"BEADZZA\",\n    \"name\": {\n      \"last\": \"Fleming\",\n      \"first\": \"Mari\"\n    },\n    \"eyeColor\": \"blue\",\n    \"age\": 21,\n    \"picture\": \"http://placehold.it/32x32\",\n    \"balance\": \"$1,948.04\",\n    \"isActive\": true,\n    \"guid\": \"6bd02166-3b1f-4ed8-84c9-ed96cbf12abc\",\n    \"index\": 5,\n    \"_id\": \"551b9119b359ff6d24846f77\"\n  },\n  {\n    \"favoriteFruit\": \"strawberry\",\n    \"greeting\": \"Hello, Maxine! You have 7 unread messages.\",\n    \"friends\": [\n      {\n        \"name\": \"Sullivan Stark\",\n        \"id\": 0\n      },\n      {\n        \"name\": \"Underwood Mclaughlin\",\n        \"id\": 1\n      },\n      {\n        \"name\": \"Kristy Carlson\",\n        \"id\": 2\n      }\n    ],\n    \"range\": [\n      0,\n      1,\n      2,\n      3,\n      4,\n      5,\n      6,\n      7,\n      8,\n      9\n    ],\n    \"tags\": [\n      \"commodo\",\n      \"ipsum\",\n      \"quis\",\n      \"non\",\n      \"est\",\n      \"mollit\",\n      \"exercitation\"\n    ],\n    \"longitude\": -105.40635,\n    \"latitude\": 37.197993,\n    \"registered\": \"Tuesday, January 20, 2015 12:30 AM\",\n    \"about\": \"Proident ullamco Lorem est consequat consectetur non eiusmod esse nostrud pariatur eiusmod enim exercitation eiusmod. Consequat duis elit elit minim ullamco et dolor eu minim do tempor esse consequat excepteur. Mollit dolor do voluptate nostrud quis anim cillum velit tempor eiusmod adipisicing tempor do culpa. Eu magna dolor sit amet nisi do laborum dolore nisi. Deserunt ipsum et deserunt non nisi.\\r\\n\",\n    \"address\": \"252 Boulevard Court, Brenton, Tennessee, 9444\",\n    \"phone\": \"+1 (950) 466-3377\",\n    \"email\": \"maxine.moreno@zentia.tv\",\n    \"company\": \"ZENTIA\",\n    \"name\": {\n      \"last\": \"Moreno\",\n      \"first\": \"Maxine\"\n    },\n    \"eyeColor\": \"brown\",\n    \"age\": 24,\n    \"picture\": \"http://placehold.it/32x32\",\n    \"balance\": \"$1,200.24\",\n    \"isActive\": false,\n    \"guid\": \"ce307a37-ca1f-43f5-b637-dca2605712be\",\n    \"index\": 6,\n    \"_id\": \"551b91195a6164b2e35f6dc8\"\n  },\n  {\n    \"favoriteFruit\": \"strawberry\",\n    \"greeting\": \"Hello, Helga! You have 5 unread messages.\",\n    \"friends\": [\n      {\n        \"name\": \"Alicia Vance\",\n        \"id\": 0\n      },\n      {\n        \"name\": \"Vinson Phelps\",\n        \"id\": 1\n      },\n      {\n        \"name\": \"Francisca Kelley\",\n        \"id\": 2\n      }\n    ],\n    \"range\": [\n      0,\n      1,\n      2,\n      3,\n      4,\n      5,\n      6,\n      7,\n      8,\n      9\n    ],\n    \"tags\": [\n      \"nostrud\",\n      \"eiusmod\",\n      \"dolore\",\n      \"officia\",\n      \"sint\",\n      \"non\",\n      \"qui\"\n    ],\n    \"longitude\": -7.275151,\n    \"latitude\": 75.54202,\n    \"registered\": \"Wednesday, October 1, 2014 6:35 PM\",\n    \"about\": \"Quis duis ullamco velit qui. Consectetur non adipisicing id magna anim. Deserunt est officia qui esse. Et do pariatur incididunt anim ad mollit non. Et eiusmod sunt fugiat elit mollit ad excepteur anim nisi laboris eiusmod aliquip aliquip.\\r\\n\",\n    \"address\": \"981 Bush Street, Beaulieu, Vermont, 3775\",\n    \"phone\": \"+1 (956) 506-3807\",\n    \"email\": \"helga.burch@synkgen.name\",\n    \"company\": \"SYNKGEN\",\n    \"name\": {\n      \"last\": \"Burch\",\n      \"first\": \"Helga\"\n    },\n    \"eyeColor\": \"blue\",\n    \"age\": 22,\n    \"picture\": \"http://placehold.it/32x32\",\n    \"balance\": \"$3,827.89\",\n    \"isActive\": false,\n    \"guid\": \"ff5dfea0-1052-4ef2-8b66-4dc1aad0a4fb\",\n    \"index\": 7,\n    \"_id\": \"551b911946be8358ae40e90e\"\n  },\n  {\n    \"favoriteFruit\": \"banana\",\n    \"greeting\": \"Hello, Shaw! You have 5 unread messages.\",\n    \"friends\": [\n      {\n        \"name\": \"Christian Cardenas\",\n        \"id\": 0\n      },\n      {\n        \"name\": \"Cohen Pennington\",\n        \"id\": 1\n      },\n      {\n        \"name\": \"Mary Lindsay\",\n        \"id\": 2\n      }\n    ],\n    \"range\": [\n      0,\n      1,\n      2,\n      3,\n      4,\n      5,\n      6,\n      7,\n      8,\n      9\n    ],\n    \"tags\": [\n      \"occaecat\",\n      \"ut\",\n      \"occaecat\",\n      \"magna\",\n      \"exercitation\",\n      \"incididunt\",\n      \"irure\"\n    ],\n    \"longitude\": -89.102972,\n    \"latitude\": 89.489596,\n    \"registered\": \"Thursday, August 21, 2014 5:00 PM\",\n    \"about\": \"Amet cupidatat quis velit aute Lorem consequat pariatur mollit deserunt et sint culpa excepteur duis. Enim proident duis qui ex tempor sunt nostrud occaecat. Officia sit veniam mollit eiusmod minim do aute eiusmod fugiat qui anim adipisicing in laboris. Do tempor reprehenderit sunt laborum esse irure dolor ad consectetur aute sit id ipsum. Commodo et voluptate anim consequat do. Minim laborum ad veniam ad minim incididunt excepteur excepteur aliqua.\\r\\n\",\n    \"address\": \"237 Pierrepont Street, Herbster, New York, 3490\",\n    \"phone\": \"+1 (976) 455-2880\",\n    \"email\": \"shaw.zamora@shadease.me\",\n    \"company\": \"SHADEASE\",\n    \"name\": {\n      \"last\": \"Zamora\",\n      \"first\": \"Shaw\"\n    },\n    \"eyeColor\": \"blue\",\n    \"age\": 38,\n    \"picture\": \"http://placehold.it/32x32\",\n    \"balance\": \"$3,440.82\",\n    \"isActive\": false,\n    \"guid\": \"ac5fdb0e-e1fb-427e-881d-da461be0d1ca\",\n    \"index\": 8,\n    \"_id\": \"551b9119af0077bc28a2de25\"\n  },\n  {\n    \"favoriteFruit\": \"apple\",\n    \"greeting\": \"Hello, Melissa! You have 5 unread messages.\",\n    \"friends\": [\n      {\n        \"name\": \"Marion Villarreal\",\n        \"id\": 0\n      },\n      {\n        \"name\": \"Kate Rose\",\n        \"id\": 1\n      },\n      {\n        \"name\": \"Hines Simon\",\n        \"id\": 2\n      }\n    ],\n    \"range\": [\n      0,\n      1,\n      2,\n      3,\n      4,\n      5,\n      6,\n      7,\n      8,\n      9\n    ],\n    \"tags\": [\n      \"amet\",\n      \"veniam\",\n      \"mollit\",\n      \"ad\",\n      \"cupidatat\",\n      \"deserunt\",\n      \"Lorem\"\n    ],\n    \"longitude\": -52.735052,\n    \"latitude\": 16.258838,\n    \"registered\": \"Wednesday, April 16, 2014 7:56 PM\",\n    \"about\": \"Aute ut culpa eiusmod tempor duis dolor tempor incididunt. Nisi non proident excepteur eiusmod incididunt nisi minim irure sit. In veniam commodo deserunt proident reprehenderit et consectetur ullamco quis nulla cupidatat.\\r\\n\",\n    \"address\": \"642 Halsey Street, Blandburg, Kansas, 6761\",\n    \"phone\": \"+1 (941) 539-3851\",\n    \"email\": \"melissa.vaughn@memora.io\",\n    \"company\": \"MEMORA\",\n    \"name\": {\n      \"last\": \"Vaughn\",\n      \"first\": \"Melissa\"\n    },\n    \"eyeColor\": \"brown\",\n    \"age\": 24,\n    \"picture\": \"http://placehold.it/32x32\",\n    \"balance\": \"$2,399.44\",\n    \"isActive\": true,\n    \"guid\": \"1769f022-a7f1-4a69-bf4c-f5a5ebeab2d1\",\n    \"index\": 9,\n    \"_id\": \"551b9119b607c09c7ffc3b8a\"\n  }\n]"
  },
  {
    "path": "ext/rapidjson/bin/types/nulls.json",
    "content": "[\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null,\n  null\n]"
  },
  {
    "path": "ext/rapidjson/bin/types/paragraphs.json",
    "content": "[\n  \"Commodo ullamco cupidatat nisi sit proident ex. Cillum pariatur occaecat in officia do commodo nisi cillum tempor minim. Ad dolor ut et aliquip fugiat eu officia cupidatat occaecat consectetur eiusmod veniam enim officia.\\r\\n\",\n  \"Adipisicing cillum laborum nisi irure. Cillum dolor proident duis nulla qui mollit dolore reprehenderit mollit. Irure nulla dolor ipsum irure nulla quis laboris do.\\r\\n\",\n  \"Est adipisicing consectetur incididunt in. Occaecat ea magna ex consequat irure sit laborum cillum officia magna sunt do exercitation aliquip. Laboris id aute in dolore reprehenderit voluptate non deserunt laborum.\\r\\n\",\n  \"Consectetur eu aute est est occaecat adipisicing sint enim dolor eu. Tempor amet id non mollit eu consectetur cillum duis. Eu labore velit nulla ipsum commodo consequat aliquip. Cupidatat commodo dolore mollit enim sit excepteur nisi duis laboris deserunt esse.\\r\\n\",\n  \"Incididunt ullamco est fugiat enim fugiat. Do sit mollit anim ad excepteur eu laboris exercitation officia labore nulla ut. Voluptate non voluptate cillum sit et voluptate anim duis velit consequat aliquip dolor. Elit et et esse laboris consectetur officia eiusmod aliquip nisi est. Qui labore dolore ad dolor.\\r\\n\",\n  \"Anim adipisicing est irure proident sit officia ullamco voluptate sunt consectetur duis mollit excepteur veniam. Nostrud ut duis aute exercitation officia et quis elit commodo elit tempor aute aliquip enim. Est officia non cillum consequat voluptate ipsum sit voluptate nulla id.\\r\\n\",\n  \"Ipsum enim consectetur aliquip nulla commodo ut ex aliqua elit duis do. Officia et sunt aliqua dolor minim voluptate veniam esse elit enim. Adipisicing reprehenderit duis ex magna non in fugiat sunt ipsum nostrud fugiat aliquip. Labore voluptate id officia voluptate eu. Magna do nostrud excepteur sunt aliqua adipisicing qui.\\r\\n\",\n  \"Est occaecat non non cupidatat laborum qui. Veniam sit est voluptate labore sit irure consectetur fugiat. Anim enim enim fugiat exercitation anim ad proident esse in aliqua. Laboris ut aute culpa ullamco.\\r\\n\",\n  \"Sit et aliquip cupidatat deserunt eiusmod sint aliquip occaecat nostrud aliqua elit commodo ut magna. Amet sit est deserunt id duis in officia pariatur cupidatat ex. Mollit duis est consequat nulla aute velit ipsum sit consectetur pariatur ut non ex ipsum. Tempor esse velit pariatur reprehenderit et nostrud commodo laborum mollit labore.\\r\\n\",\n  \"Aliquip irure quis esse aliquip. Ex non deserunt culpa aliqua ad anim occaecat ad. Lorem consectetur mollit eu consectetur est non nisi non ipsum. Qui veniam ullamco officia est ut excepteur. Nulla elit dolore cupidatat aliqua enim Lorem elit consequat eiusmod non aliqua eu in. Pariatur in culpa labore sint ipsum consectetur occaecat ad ex ipsum laboris aliquip officia. Non officia eiusmod nisi officia id id laboris deserunt sunt enim magna mollit sit.\\r\\n\",\n  \"Mollit velit laboris laborum nulla aliquip consequat Lorem non incididunt irure. Eu voluptate sint do consectetur tempor sit Lorem in. Laborum eiusmod nisi Lorem ipsum dolore do aute laborum occaecat aute sunt. Sit laborum in ea do ipsum officia irure cillum irure nisi laboris. Ad anim deserunt excepteur ea veniam eiusmod culpa velit veniam. Commodo incididunt ea Lorem eu enim esse nisi incididunt mollit.\\r\\n\",\n  \"Velit proident sunt aute dolore reprehenderit culpa. Pariatur reprehenderit commodo ad ea voluptate anim nulla ipsum eu irure fugiat aliqua et. Adipisicing incididunt anim excepteur voluptate minim qui culpa. Sunt veniam enim reprehenderit magna magna. Sit ad amet deserunt ut aute dolore ad minim.\\r\\n\",\n  \"Esse ullamco sunt mollit mollit. Eu enim dolore laboris cupidatat. Cupidatat adipisicing non aute exercitation fugiat. Non ut cillum labore fugiat aliquip ex duis quis consectetur ut nisi Lorem amet qui. Proident veniam amet qui reprehenderit duis qui. Nisi culpa sit occaecat ullamco occaecat laborum fugiat ut. Non duis deserunt culpa duis.\\r\\n\",\n  \"Id ipsum eiusmod laboris non est ipsum deserunt labore duis reprehenderit deserunt. Sint tempor fugiat eiusmod nostrud in ut laborum esse in nostrud sit deserunt nostrud reprehenderit. Cupidatat aliqua qui anim consequat eu quis consequat consequat elit ipsum pariatur. Cupidatat in dolore velit quis. Exercitation cillum ullamco ex consectetur commodo tempor incididunt exercitation labore ad dolore. Minim incididunt consequat adipisicing esse eu eu voluptate.\\r\\n\",\n  \"Anim sint eiusmod nisi anim do deserunt voluptate ut cillum eiusmod esse ex reprehenderit laborum. Dolore nulla excepteur duis excepteur. Magna nisi nostrud duis non commodo velit esse ipsum Lorem incididunt. Nulla enim consequat ad aliqua. Incididunt irure culpa nostrud ea aute ex sit non ad esse.\\r\\n\",\n  \"Ullamco nostrud cupidatat adipisicing anim fugiat mollit eu. Et ut eu in nulla consequat. Sunt do pariatur culpa non est.\\r\\n\",\n  \"Pariatur incididunt reprehenderit non qui excepteur cillum exercitation nisi occaecat ad. Lorem aliquip laborum commodo reprehenderit sint. Laboris qui ut veniam magna quis et et ullamco voluptate. Tempor reprehenderit deserunt consequat nisi. Esse duis sint in tempor. Amet aute cupidatat in sint et.\\r\\n\",\n  \"Est officia nisi dolore consequat irure et excepteur. Sit qui elit tempor magna qui cillum anim amet proident exercitation proident. Eu cupidatat laborum consectetur duis ullamco irure nulla. Adipisicing culpa non reprehenderit anim aute.\\r\\n\",\n  \"Eu est laborum culpa velit dolore non sunt. Tempor magna veniam ea sit non qui Lorem qui exercitation aliqua aliqua et excepteur eiusmod. Culpa aute anim proident culpa adipisicing duis tempor elit aliquip elit nulla laboris esse dolore. Sit adipisicing non dolor eiusmod occaecat cupidatat.\\r\\n\",\n  \"Culpa velit eu esse sunt. Laborum irure aliqua reprehenderit velit ipsum fugiat officia dolor ut aute officia deserunt. Ipsum sit quis fugiat nostrud aliqua cupidatat ex pariatur et. Cillum proident est irure nisi dolor aliqua deserunt esse occaecat velit dolor.\\r\\n\",\n  \"Exercitation nulla officia sit eiusmod cillum eu incididunt officia exercitation qui Lorem deserunt. Voluptate Lorem minim commodo laborum esse in duis excepteur do duis aliquip nisi voluptate consectetur. Amet tempor officia enim ex esse minim reprehenderit.\\r\\n\",\n  \"Laboris sint deserunt ad aute incididunt. Anim officia sunt elit qui laborum labore commodo irure non. Mollit adipisicing ullamco do aute nulla eu laborum et quis sint aute adipisicing amet. Aliqua officia irure nostrud duis ex.\\r\\n\",\n  \"Eiusmod ipsum aliqua reprehenderit esse est non aute id veniam eiusmod. Elit consequat ad sit tempor elit eu incididunt quis irure ad. Eu incididunt veniam consequat Lorem nostrud cillum officia ea consequat ad cillum. Non nisi irure cupidatat incididunt pariatur incididunt. Duis velit officia ad cillum qui. Aliquip consequat sint aute nisi cillum. Officia commodo nisi incididunt laborum nisi voluptate aliquip Lorem cupidatat anim consequat sit laboris.\\r\\n\",\n  \"Veniam cupidatat et incididunt mollit do ex voluptate veniam nostrud labore esse. Eiusmod irure sint fugiat esse. Aute irure consectetur ut mollit nulla sint esse. Lorem ut quis ex proident nostrud mollit nostrud ea duis duis in magna anim consectetur.\\r\\n\",\n  \"Irure culpa esse qui do dolor fugiat veniam ad. Elit commodo aute elit magna incididunt tempor pariatur velit irure pariatur cillum et ea ad. Ad consequat ea et ad minim ut sunt qui commodo voluptate. Laboris est aliquip anim reprehenderit eu officia et exercitation. Occaecat laboris cupidatat Lorem ullamco in nostrud commodo ipsum in quis esse ex.\\r\\n\",\n  \"Incididunt officia quis voluptate eiusmod esse nisi ipsum quis commodo. Eiusmod dolore tempor occaecat sit exercitation aliqua minim consequat minim mollit qui ad nisi. Aute quis irure adipisicing veniam nisi nisi velit deserunt incididunt anim nostrud.\\r\\n\",\n  \"Voluptate exercitation exercitation id minim excepteur excepteur mollit. Fugiat aute proident nulla ullamco ea. Nisi ea culpa duis dolore veniam anim tempor officia in dolore exercitation exercitation. Dolore quis cillum adipisicing sunt do nulla esse proident ad sint.\\r\\n\",\n  \"Laborum ut mollit sint commodo nulla laborum deserunt Lorem magna commodo mollit tempor deserunt ut. Qui aliquip commodo ea id. Consectetur dolor fugiat dolor excepteur eiusmod. Eu excepteur ex aute ex ex elit ex esse officia cillum exercitation. Duis ut labore ea nostrud excepteur. Reprehenderit labore aute sunt nisi quis Lorem officia. Ad aliquip cupidatat voluptate exercitation voluptate ad irure magna quis.\\r\\n\",\n  \"Tempor velit veniam sit labore elit minim do elit cillum eiusmod sunt excepteur nisi. Aliquip est deserunt excepteur duis fugiat incididunt veniam fugiat. Pariatur sit irure labore et minim non. Cillum quis aute anim sint laboris laboris ullamco exercitation nostrud. Nulla pariatur id laborum minim nisi est adipisicing irure.\\r\\n\",\n  \"Irure exercitation laboris nostrud in do consectetur ad. Magna aliqua Lorem culpa exercitation sint do culpa incididunt mollit eu exercitation. Elit tempor Lorem dolore enim deserunt. Anim et ullamco sint ullamco mollit cillum officia et. Proident incididunt laboris aliquip laborum sint veniam deserunt eu consequat deserunt voluptate laboris. Anim Lorem non laborum exercitation voluptate. Cupidatat reprehenderit culpa Lorem fugiat enim minim consectetur tempor quis ad reprehenderit laboris irure.\\r\\n\",\n  \"Deserunt elit mollit nostrud occaecat labore reprehenderit laboris ex. Esse reprehenderit adipisicing cillum minim in esse aliquip excepteur ex et nisi cillum quis. Cillum labore ut ex sunt. Occaecat proident et mollit magna consequat irure esse. Dolor do enim esse nisi ad.\\r\\n\",\n  \"Pariatur est anim cillum minim elit magna adipisicing quis tempor proident nisi laboris incididunt cupidatat. Nulla est adipisicing sit adipisicing id nostrud amet qui consequat eiusmod tempor voluptate ad. Adipisicing non magna sit occaecat magna mollit ad ex nulla velit ea pariatur. Irure labore ad ea exercitation ex cillum.\\r\\n\",\n  \"Lorem fugiat eu eu cillum nulla tempor sint. Lorem id officia nulla velit labore ut duis ad tempor non. Excepteur quis aute adipisicing nisi nisi consectetur aliquip enim Lorem id ullamco cillum sint voluptate. Qui aliquip incididunt tempor aliqua voluptate labore reprehenderit. Veniam eiusmod elit occaecat voluptate tempor culpa consectetur ea ut exercitation eiusmod exercitation qui.\\r\\n\",\n  \"Aliqua esse pariatur nulla veniam velit ea. Aliquip consectetur tempor ex magna sit aliquip exercitation veniam. Dolor ullamco minim commodo pariatur. Et amet reprehenderit dolore proident elit tempor eiusmod eu incididunt enim ullamco. Adipisicing id officia incididunt esse dolor sunt cupidatat do deserunt mollit do non. Magna ut officia fugiat adipisicing quis ea cillum laborum dolore ad nostrud magna minim est. Dolor voluptate officia proident enim ea deserunt eu voluptate dolore proident laborum officia ea.\\r\\n\",\n  \"Culpa aute consequat esse fugiat cupidatat minim voluptate voluptate eiusmod irure anim elit. Do eiusmod culpa laboris consequat incididunt minim nostrud eiusmod commodo velit ea ullamco proident. Culpa pariatur magna ut mollit nisi. Ea officia do magna deserunt minim nisi tempor ea deserunt veniam cillum exercitation esse.\\r\\n\",\n  \"Anim ullamco nostrud commodo Lorem. Do sunt laborum exercitation proident proident magna. Lorem officia laborum laborum dolor sunt duis commodo Lorem. Officia aute adipisicing ea cupidatat ea dolore. Aliquip adipisicing pariatur consectetur aliqua sit amet officia reprehenderit laborum culpa. Occaecat Lorem eu nisi do Lorem occaecat enim eiusmod laboris id quis. Ad mollit adipisicing sunt adipisicing esse.\\r\\n\",\n  \"Laborum quis sit adipisicing cupidatat. Veniam Lorem eiusmod esse esse sint nisi labore elit et. Deserunt aliqua mollit ut commodo aliqua non incididunt ipsum reprehenderit consectetur. Eiusmod nulla minim laboris Lorem ea Lorem aute tempor pariatur in sit. Incididunt culpa ut do irure amet irure cupidatat est anim anim culpa occaecat. Est velit consectetur eiusmod veniam reprehenderit officia sunt occaecat eiusmod ut sunt occaecat amet.\\r\\n\",\n  \"Elit minim aute fugiat nulla ex quis. Labore fugiat sint nostrud amet quis culpa excepteur in. Consectetur exercitation cupidatat laborum sit. Aute nisi eu aliqua est deserunt eiusmod commodo dolor id. Mollit laborum esse sint ipsum voluptate reprehenderit velit et. Veniam aliquip enim in veniam Lorem voluptate quis deserunt consequat qui commodo ut excepteur aute.\\r\\n\",\n  \"Dolore deserunt veniam aute nisi labore sunt et voluptate irure nisi anim ea. Magna nisi quis anim mollit nisi est dolor do ex aliquip elit aliquip ipsum minim. Dolore est officia nostrud eiusmod ex laborum ea amet est. Officia culpa non est et tempor consectetur exercitation tempor eiusmod enim. Ea tempor laboris qui amet ex nisi culpa dolore consectetur incididunt sunt sunt. Lorem aliquip incididunt magna do et ullamco ex elit aliqua eiusmod qui. Commodo amet dolor sint incididunt ex veniam non Lorem fugiat.\\r\\n\",\n  \"Officia culpa enim voluptate dolore commodo. Minim commodo aliqua minim ex sint excepteur cupidatat adipisicing eu irure. Anim magna deserunt anim Lorem non.\\r\\n\",\n  \"Cupidatat aliquip nulla excepteur sunt cupidatat cupidatat laborum cupidatat exercitation. Laboris minim ex cupidatat culpa elit. Amet enim reprehenderit aliqua laborum est tempor exercitation cupidatat ex dolore do. Do incididunt labore fugiat commodo consectetur nisi incididunt irure sit culpa sit. Elit aute occaecat qui excepteur velit proident cillum qui aliqua ex do ex. Dolore irure ex excepteur veniam id proident mollit Lorem.\\r\\n\",\n  \"Ad commodo cillum duis deserunt elit officia consectetur veniam eiusmod. Reprehenderit et veniam ad commodo reprehenderit magna elit laboris sunt non quis. Adipisicing dolor aute proident ea magna sunt et proident in consectetur.\\r\\n\",\n  \"Veniam exercitation esse esse veniam est nisi. Minim velit incididunt sint aute dolor anim. Fugiat cupidatat id ad nisi in voluptate dolor culpa eiusmod magna eiusmod amet id. Duis aliquip labore et ex amet amet aliquip laborum eiusmod ipsum. Quis qui ut duis duis. Minim in voluptate reprehenderit aliqua.\\r\\n\",\n  \"Elit ut pariatur dolor veniam ipsum consequat. Voluptate Lorem mollit et esse dolore mollit Lorem ad. Elit nostrud eu Lorem labore mollit minim cupidatat officia quis minim dolore incididunt. In cillum aute cillum ut.\\r\\n\",\n  \"Commodo laborum deserunt ut cupidatat pariatur ullamco in esse anim exercitation cillum duis. Consectetur incididunt sit esse Lorem in aute. Eiusmod mollit Lorem consequat minim reprehenderit laborum enim excepteur irure nisi elit. Laborum esse proident aute aute proident adipisicing laborum. Pariatur tempor duis incididunt qui velit pariatur ut officia ea mollit labore dolore. Cillum pariatur minim ullamco sunt incididunt culpa id ullamco exercitation consectetur. Ea exercitation consequat reprehenderit ut ullamco velit eu ad velit magna excepteur eiusmod.\\r\\n\",\n  \"Eu deserunt magna laboris laborum laborum in consequat dolore. Officia proident consectetur proident do occaecat minim pariatur officia ipsum sit non velit officia cillum. Laborum excepteur labore eu minim eiusmod. Sit anim dolore cillum ad do minim culpa sit est ad.\\r\\n\",\n  \"Cupidatat dolor nostrud Lorem sint consequat quis. Quis labore sint incididunt officia tempor. Fugiat nostrud in elit reprehenderit dolor. Nisi sit enim officia minim est adipisicing nulla aute labore nulla nostrud cupidatat est. Deserunt dolore qui irure Lorem esse voluptate velit qui nostrud.\\r\\n\",\n  \"Fugiat Lorem amet nulla nisi qui amet laboris enim cillum. Dolore occaecat exercitation id labore velit do commodo ut cupidatat laborum velit fugiat mollit. Ut et aliqua pariatur occaecat. Lorem occaecat dolore quis esse enim cupidatat exercitation ut tempor sit laboris fugiat adipisicing. Est tempor ex irure consectetur ipsum magna labore. Lorem non quis qui minim nisi magna amet aliquip ex cillum fugiat tempor.\\r\\n\",\n  \"Aliquip eiusmod laborum ipsum deserunt velit esse do magna excepteur consectetur exercitation sit. Minim ullamco reprehenderit commodo nostrud exercitation id irure ex qui ullamco sit esse laboris. Nulla cillum non minim qui cillum nisi aute proident. Dolor anim culpa elit quis excepteur aliqua eiusmod. Elit ea est excepteur consectetur sunt eiusmod enim id commodo irure amet et pariatur laboris. Voluptate magna ad magna dolore cillum cillum irure laboris ipsum officia id Lorem veniam.\\r\\n\",\n  \"Esse sunt elit est aliquip cupidatat commodo deserunt. Deserunt pariatur ipsum qui ad esse esse magna qui cillum laborum. Exercitation veniam pariatur elit amet enim.\\r\\n\",\n  \"Esse quis in id elit nulla occaecat incididunt. Et amet Lorem mollit in veniam do. Velit mollit Lorem consequat commodo Lorem aliquip cupidatat. Minim consequat nostrud nulla in nostrud.\\r\\n\",\n  \"Cillum nulla et eu est nostrud quis elit cupidatat dolor enim excepteur exercitation nisi voluptate. Nulla dolore non ex velit et qui tempor proident id deserunt nisi eu. Tempor ad Lorem ipsum reprehenderit in anim. Anim dolore ullamco enim deserunt quis ex id exercitation velit. Magna exercitation fugiat mollit pariatur ipsum ex consectetur nostrud. Id dolore officia nostrud excepteur laborum. Magna incididunt elit ipsum pariatur adipisicing enim duis est qui commodo velit aute.\\r\\n\",\n  \"Quis esse ex qui nisi dolor. Ullamco laborum dolor esse laboris eiusmod ea magna laboris ea esse ut. Dolore ipsum pariatur veniam sint mollit. Lorem ea proident fugiat ullamco ut nisi culpa eu exercitation exercitation aliquip veniam laborum consectetur.\\r\\n\",\n  \"Pariatur veniam laboris sit aliquip pariatur tempor aute sunt id et ut. Laboris excepteur eiusmod nisi qui quis elit enim ut cupidatat. Et et laborum in fugiat veniam consectetur ipsum laboris duis excepteur ullamco aliqua dolor Lorem. Aliqua ex amet sint anim cupidatat nisi ipsum anim et sunt deserunt. Occaecat culpa ut tempor cillum pariatur ex tempor.\\r\\n\",\n  \"Dolor deserunt eiusmod magna do officia voluptate excepteur est cupidatat. Veniam qui cupidatat amet anim est qui consectetur sit commodo commodo ea ad. Enim ad adipisicing qui nostrud. Non nulla esse ullamco nulla et ex.\\r\\n\",\n  \"Id ullamco ea consectetur est incididunt deserunt et esse. Elit nostrud voluptate eiusmod ut. Excepteur adipisicing qui cupidatat consequat labore id. Qui dolor aliqua do dolore do cupidatat labore ex consectetur ea sit cillum. Sint veniam eiusmod in consectetur consequat fugiat et mollit ut fugiat esse dolor adipisicing.\\r\\n\",\n  \"Ea magna proident labore duis pariatur. Esse cillum aliquip dolor duis fugiat ea ex officia ea irure. Sint elit nisi pariatur sunt nostrud exercitation ullamco culpa magna do.\\r\\n\",\n  \"Minim aliqua voluptate dolor consequat sint tempor deserunt amet magna excepteur. Irure do voluptate magna velit. Nostrud in reprehenderit magna officia nostrud. Cupidatat nulla irure laboris non fugiat ex ex est cupidatat excepteur officia aute velit duis. Sit voluptate id ea exercitation deserunt culpa voluptate nostrud est adipisicing incididunt. Amet proident laborum commodo magna ipsum quis.\\r\\n\",\n  \"Ipsum consectetur consectetur excepteur tempor eiusmod ea fugiat aute velit magna in officia sunt. Sit ut sunt dolore cupidatat dolor adipisicing. Veniam nisi adipisicing esse reprehenderit amet aliqua voluptate ex commodo occaecat est voluptate mollit sunt. Pariatur aliqua qui qui in dolor. Fugiat reprehenderit sit nostrud do sint esse. Tempor sit irure adipisicing ea pariatur duis est sit est incididunt laboris quis do. Et voluptate anim minim aliquip excepteur consequat nisi anim pariatur aliquip ut ipsum dolor magna.\\r\\n\",\n  \"Cillum sit labore excepteur magna id aliqua exercitation consequat laborum Lorem id pariatur nostrud. Lorem qui est labore sint cupidatat sint excepteur nulla in eu aliqua et. Adipisicing velit do enim occaecat laboris quis excepteur ipsum dolor occaecat Lorem dolore id exercitation.\\r\\n\",\n  \"Incididunt in laborum reprehenderit eiusmod irure ex. Elit duis consequat minim magna. Esse consectetur aliquip cillum excepteur excepteur fugiat. Sint tempor consequat minim reprehenderit consectetur adipisicing dolor id Lorem elit non. Occaecat esse quis mollit ea et sint aute fugiat qui tempor. Adipisicing tempor duis non dolore irure elit deserunt qui do.\\r\\n\",\n  \"Labore fugiat eiusmod sint laborum sit duis occaecat. Magna in laborum non cillum excepteur nostrud sit proident pariatur voluptate voluptate adipisicing exercitation occaecat. Ad non dolor aute ex sint do do minim exercitation veniam laborum irure magna ea. Magna do non quis sit consequat Lorem aliquip.\\r\\n\",\n  \"Velit anim do laborum laboris laborum Lorem. Sunt do Lorem amet ipsum est sint velit sit do voluptate mollit veniam enim. Commodo do deserunt in pariatur ut elit sint elit deserunt ea. Ad dolor anim consequat aliquip ut mollit nostrud tempor sunt mollit elit. Reprehenderit laboris labore excepteur occaecat veniam adipisicing cupidatat esse. Ad enim aliquip ea minim excepteur magna. Sint velit veniam pariatur qui dolor est adipisicing ex laboris.\\r\\n\",\n  \"Ea cupidatat ex nulla in sunt est sit dolor enim ad. Eu tempor consequat cupidatat consequat ex incididunt sint culpa. Est Lorem Lorem non cupidatat sunt ut aliqua non nostrud do ullamco. Reprehenderit ad ad nulla nostrud do nulla in. Ipsum adipisicing commodo mollit ipsum exercitation. Aliqua ea anim anim est elit. Ea incididunt consequat minim ad sunt eu cillum.\\r\\n\",\n  \"Tempor quis excepteur eiusmod cupidatat ipsum occaecat id et occaecat. Eiusmod magna aliquip excepteur id amet elit. Ullamco dolore amet anim dolor enim ea magna magna elit. Occaecat magna pariatur in deserunt consectetur officia aliquip ullamco ex aute anim. Minim laborum eu sit elit officia esse do irure pariatur tempor et reprehenderit ullamco labore.\\r\\n\",\n  \"Sit tempor eu minim dolore velit pariatur magna duis reprehenderit ea nulla in. Amet est do consectetur commodo do adipisicing adipisicing in amet. Cillum id ut commodo do pariatur duis aliqua nisi sint ad irure officia reprehenderit. Mollit labore id enim fugiat ullamco irure mollit cupidatat. Quis nisi amet labore eu dolor occaecat commodo aliqua laboris deserunt excepteur deserunt officia. Aliqua non ut sit ad. Laborum veniam ad velit minim dolore ea id magna dolor qui in.\\r\\n\",\n  \"Dolore nostrud ipsum aliqua pariatur id reprehenderit enim ad eiusmod qui. Deserunt anim commodo pariatur excepteur velit eu irure nulla ex labore ipsum aliqua minim aute. Id consequat amet tempor aliquip ex elit adipisicing est do. Eu enim Lorem consectetur minim id irure nulla culpa. Consectetur do consequat aute tempor anim. Qui ad non elit dolor est adipisicing nisi amet cillum sunt quis anim laboris incididunt. Incididunt proident adipisicing labore Lorem.\\r\\n\",\n  \"Et reprehenderit ea officia veniam. Aliquip ullamco consequat elit nisi magna mollit id elit. Amet amet sint velit labore ad nisi. Consectetur tempor id dolor aliqua esse deserunt amet. Qui laborum enim proident voluptate aute eu aute aute sit sit incididunt eu. Sunt ullamco nisi nostrud labore commodo non consectetur quis do duis minim irure. Tempor sint dolor sint aliquip dolore nostrud fugiat.\\r\\n\",\n  \"Aute ullamco quis nisi ut excepteur nostrud duis elit. Veniam ex ad incididunt veniam voluptate. Commodo dolore ullamco sit sint adipisicing proident amet aute duis deserunt.\\r\\n\",\n  \"Labore velit eu cillum nisi. Laboris do cupidatat et non duis cillum. Ullamco dolor tempor cupidatat voluptate laborum ullamco ea duis.\\r\\n\",\n  \"Deserunt consequat aliqua duis aliquip nostrud nostrud dolore nisi. Culpa do sint laborum consectetur ipsum quis laborum laborum pariatur eiusmod. Consectetur laboris ad ad ut quis. Ullamco laboris qui velit id laborum voluptate qui aute nostrud aliquip ea.\\r\\n\",\n  \"Ad cillum anim ex est consectetur mollit id in. Non enim aliquip consequat qui deserunt commodo cillum ad laborum fugiat. Dolor deserunt amet laborum tempor adipisicing voluptate dolor pariatur dolor cillum. Eu mollit ex sunt officia veniam qui est sunt proident. Non aliqua qui elit eu cupidatat ex enim ex proident. Lorem sit minim ullamco officia cupidatat duis minim. Exercitation laborum deserunt voluptate culpa tempor quis nulla id pariatur.\\r\\n\",\n  \"Nostrud quis consectetur ut aliqua excepteur elit consectetur occaecat. Occaecat voluptate Lorem pariatur consequat ullamco fugiat minim. Anim voluptate eu eu cillum tempor dolore aliquip aliqua. Fugiat incididunt ut tempor amet minim. Voluptate nostrud minim pariatur non excepteur ullamco.\\r\\n\",\n  \"Dolore nulla velit officia exercitation irure laboris incididunt anim in laborum in fugiat ut proident. Fugiat aute id consequat fugiat officia ut. Labore sint amet proident amet sint nisi laboris amet id ullamco culpa quis consequat proident. Magna do fugiat veniam dolore elit irure minim. Esse ullamco excepteur labore tempor labore fugiat dolore nisi cupidatat irure dolor pariatur. Magna excepteur laboris nisi eiusmod sit pariatur mollit.\\r\\n\",\n  \"In enim aliquip officia ea ad exercitation cillum culpa occaecat dolore Lorem. Irure cillum commodo adipisicing sunt pariatur ea duis fugiat exercitation laboris culpa ullamco aute. Ut voluptate exercitation qui dolor. Irure et duis elit consequat deserunt proident.\\r\\n\",\n  \"Officia ea Lorem sunt culpa id et tempor excepteur enim deserunt proident. Dolore aliquip dolor laboris cillum proident velit. Et culpa occaecat exercitation cupidatat irure sint adipisicing excepteur pariatur incididunt ad occaecat. Qui proident ipsum cillum minim. Quis ut culpa irure aliqua minim fugiat. In voluptate cupidatat fugiat est laborum dolor esse in pariatur voluptate.\\r\\n\",\n  \"Voluptate enim ipsum officia aute ea adipisicing nisi ut ex do aliquip amet. Reprehenderit enim voluptate tempor ex adipisicing culpa. Culpa occaecat voluptate dolor mollit ipsum exercitation labore et tempor sit ea consectetur aliqua. Elit elit sit minim ea ea commodo do tempor cupidatat irure dolore. Occaecat esse adipisicing anim eiusmod commodo fugiat mollit amet. Incididunt tempor tempor qui occaecat cupidatat in.\\r\\n\",\n  \"Ut qui anim velit enim aliquip do ut nulla labore. Mollit ut commodo ut eiusmod consectetur laboris aliqua qui voluptate culpa fugiat incididunt elit. Lorem ullamco esse elit elit. Labore amet incididunt ea nulla aliquip eiusmod. Sit nulla est voluptate officia ipsum aute aute cillum tempor deserunt. Laboris commodo eiusmod labore sunt aute excepteur ea consectetur reprehenderit veniam nisi. Culpa nisi sint sunt sint tempor laboris dolore cupidatat.\\r\\n\",\n  \"Duis cillum qui nisi duis amet velit ad cillum ut elit aute sint ad. Amet laboris pariatur excepteur ipsum Lorem aliqua veniam Lorem quis mollit cupidatat aliqua exercitation. Pariatur ex ullamco sit commodo cillum eiusmod ut proident elit cillum. Commodo ut ipsum excepteur occaecat sint elit consequat ex dolor adipisicing consectetur id ut ad. Velit sit eiusmod est esse tempor incididunt consectetur eiusmod duis commodo veniam.\\r\\n\",\n  \"Ut sunt qui officia anim laboris exercitation Lorem quis laborum do eiusmod officia. Enim consectetur occaecat fugiat cillum cillum. Dolore dolore nostrud in commodo fugiat mollit consequat occaecat non et et elit ullamco. Sit voluptate minim ut est culpa velit nulla fugiat reprehenderit eu aliquip adipisicing labore. Sit minim minim do dolor dolor. Lorem Lorem labore exercitation magna veniam eiusmod do.\\r\\n\",\n  \"Fugiat dolor adipisicing quis aliquip aute dolore. Qui proident anim elit veniam ex aliquip eiusmod ipsum sunt pariatur est. Non fugiat duis do est officia adipisicing.\\r\\n\",\n  \"Nulla deserunt do laboris cupidatat veniam do consectetur ipsum elit veniam in mollit eu. Ea in consequat cupidatat laboris sint fugiat irure. In commodo esse reprehenderit deserunt minim velit ullamco enim eu cupidatat tempor ex. Ullamco in non id culpa amet occaecat culpa nostrud id. Non occaecat culpa magna incididunt.\\r\\n\",\n  \"Enim laboris ex mollit reprehenderit eiusmod exercitation magna. Exercitation Lorem ex mollit non non culpa labore enim. Adipisicing labore dolore incididunt do amet aliquip excepteur ad et nostrud officia aute veniam voluptate. Fugiat enim eiusmod Lorem esse. Minim ullamco commodo consequat ex commodo aliqua eu nulla eu. Veniam non enim nulla ut Lorem nostrud minim sint duis.\\r\\n\",\n  \"Enim duis consectetur in ullamco cillum veniam nulla amet. Exercitation nisi sunt sunt duis in culpa nisi magna ex id ipsum laboris reprehenderit qui. Officia pariatur qui ex fugiat veniam et sunt sit nostrud. Veniam ullamco tempor fugiat minim Lorem proident velit in eiusmod elit. Enim minim excepteur aute aliquip ex magna commodo dolore qui et labore. Proident eu aliquip cillum dolor. Nostrud ipsum ut irure consequat fugiat nulla proident occaecat laborum.\\r\\n\",\n  \"Amet duis eiusmod sunt adipisicing esse ex nostrud consectetur voluptate cillum. Ipsum occaecat sit et anim velit irure ea incididunt cupidatat ullamco in nisi quis. Esse officia ipsum commodo qui quis qui do. Commodo aliquip amet aute sit sit ut cupidatat elit nostrud.\\r\\n\",\n  \"Laboris laboris sit mollit cillum nulla deserunt commodo culpa est commodo anim id anim sit. Officia id consectetur velit incididunt est dolor sunt ipsum magna aliqua consectetur. Eiusmod pariatur minim deserunt cupidatat veniam Lorem aliquip sunt proident eu Lorem sit dolor fugiat. Proident qui ut ex in incididunt nulla nulla dolor ex laboris ea ad.\\r\\n\",\n  \"Ex incididunt enim labore nulla cupidatat elit. Quis ut incididunt incididunt non irure commodo do mollit cillum anim excepteur. Qui consequat laborum dolore elit tempor aute ut nulla pariatur eu ullamco veniam. Nisi non velit labore in commodo excepteur culpa nulla tempor cillum. Ipsum qui sit sint reprehenderit ut labore incididunt dolor aliquip sunt. Reprehenderit occaecat tempor nisi laborum.\\r\\n\",\n  \"Lorem officia ullamco eu occaecat in magna eiusmod consectetur nisi aliqua mollit esse. Ullamco ex aute nostrud pariatur do enim cillum sint do fugiat nostrud culpa tempor. Do aliquip excepteur nostrud culpa eu pariatur eiusmod cillum excepteur do. Est sunt non quis cillum voluptate ex.\\r\\n\",\n  \"Deserunt consectetur tempor irure mollit qui tempor et. Labore enim eu irure laboris in. Nisi in tempor ex occaecat amet cupidatat laboris occaecat amet minim ut magna incididunt id. Consequat cillum laborum commodo mollit. Et magna culpa sunt dolore consequat laboris et sit. Deserunt qui voluptate excepteur dolor. Eu qui amet est proident.\\r\\n\",\n  \"Eu elit minim eiusmod occaecat eu nostrud dolor qui ut elit. Sunt dolore proident ea eu do eiusmod fugiat incididunt pariatur duis amet Lorem nisi ut. Adipisicing quis veniam cupidatat Lorem sint culpa sunt veniam sint. Excepteur eu exercitation est magna pariatur veniam dolore qui fugiat labore proident eiusmod cillum. Commodo reprehenderit elit proident duis sint magna.\\r\\n\",\n  \"Ut aliquip pariatur deserunt nostrud commodo ad proident est exercitation. Sit minim do ea enim sint officia nisi incididunt laborum. Ex amet duis commodo fugiat. Ut aute tempor deserunt irure occaecat aliquip voluptate cillum aute elit qui nostrud.\\r\\n\",\n  \"Irure et quis consectetur sit est do sunt aliquip eu. Cupidatat pariatur consequat dolore consectetur. Adipisicing magna velit mollit occaecat do id. Nisi pariatur cupidatat cillum incididunt excepteur consectetur excepteur do laborum deserunt irure pariatur cillum.\\r\\n\",\n  \"Adipisicing esse incididunt cillum est irure consequat irure ad aute voluptate. Incididunt do occaecat nostrud do ipsum pariatur Lorem qui laboris et pariatur. Est exercitation dolor culpa ad velit ut et.\\r\\n\",\n  \"Sit eiusmod id enim ad ex dolor pariatur do. Ullamco occaecat quis dolor minim non elit labore amet est. Commodo velit eu nulla eiusmod ullamco. Incididunt anim pariatur aute eiusmod veniam tempor enim officia elit id. Elit Lorem est commodo dolore nostrud. Labore et consectetur do exercitation veniam laboris incididunt aliqua proident dolore ea officia cupidatat. Velit laboris aliquip deserunt labore commodo.\\r\\n\",\n  \"Proident nostrud labore eu nostrud. Excepteur ut in velit labore ea proident labore ea sint cillum. Incididunt ipsum consectetur officia irure sit pariatur veniam id velit officia mollit. Adipisicing magna voluptate velit excepteur enim consectetur incididunt voluptate tempor occaecat fugiat velit excepteur labore. Do do incididunt qui nisi voluptate enim. Laboris aute sit voluptate cillum pariatur minim excepteur ullamco mollit deserunt.\\r\\n\",\n  \"Excepteur laborum adipisicing nisi elit fugiat tempor. Elit laboris qui enim labore duis. Proident tempor in consectetur proident excepteur do ex laboris sit.\\r\\n\",\n  \"Dolore do ea incididunt do duis dolore eu labore nisi cupidatat voluptate amet incididunt minim. Nulla pariatur mollit cupidatat adipisicing nulla et. Dolor aliquip in ex magna excepteur. Nulla consequat minim consequat ullamco dolor laboris ullamco eu reprehenderit duis nostrud pariatur.\\r\\n\",\n  \"Id nisi labore duis qui. Incididunt laboris tempor aute do sit. Occaecat excepteur est mollit ea in mollit ullamco est amet reprehenderit.\\r\\n\",\n  \"Aute labore ipsum velit non voluptate eiusmod et reprehenderit cupidatat occaecat. Lorem tempor tempor consectetur exercitation qui nostrud sunt cillum quis ut non dolore. Reprehenderit consequat reprehenderit laborum qui pariatur anim et officia est cupidatat enim velit velit.\\r\\n\",\n  \"Commodo ex et fugiat cupidatat non adipisicing commodo. Minim ad dolore fugiat mollit cupidatat aliqua sunt dolor sit. Labore esse labore velit aute enim. Nulla duis incididunt est aliquip consectetur elit qui incididunt minim minim labore amet sit cillum.\\r\\n\"\n]"
  },
  {
    "path": "ext/rapidjson/bin/types/readme.txt",
    "content": "Test data obtained from https://github.com/xpol/lua-rapidjson/tree/master/performance\n"
  },
  {
    "path": "ext/rapidjson/doc/CMakeLists.txt",
    "content": "find_package(Doxygen)\n\nIF(NOT DOXYGEN_FOUND)\n    MESSAGE(STATUS \"No Doxygen found. Documentation won't be built\")\nELSE()\n    file(GLOB SOURCES ${CMAKE_CURRENT_LIST_DIR}/../include/*)\n    file(GLOB MARKDOWN_DOC ${CMAKE_CURRENT_LIST_DIR}/../doc/*.md)\n    list(APPEND MARKDOWN_DOC ${CMAKE_CURRENT_LIST_DIR}/../readme.md)\n\n    CONFIGURE_FILE(Doxyfile.in Doxyfile @ONLY)\n    CONFIGURE_FILE(Doxyfile.zh-cn.in Doxyfile.zh-cn @ONLY)\n\n    add_custom_command(OUTPUT html\n        COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile\n        COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.zh-cn\n        COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/html\n        DEPENDS ${MARKDOWN_DOC} ${SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile*\n        WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../\n        )\n\n    add_custom_target(doc ALL DEPENDS html)\n    install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html\n        DESTINATION ${DOC_INSTALL_DIR}\n        COMPONENT doc)\nENDIF()\n"
  },
  {
    "path": "ext/rapidjson/doc/Doxyfile.in",
    "content": "# Doxyfile 1.8.7\n\n# This file describes the settings to be used by the documentation system\n# doxygen (www.doxygen.org) for a project.\n#\n# All text after a double hash (##) is considered a comment and is placed in\n# front of the TAG it is preceding.\n#\n# All text after a single hash (#) is considered a comment and will be ignored.\n# The format is:\n# TAG = value [value, ...]\n# For lists, items can also be appended using:\n# TAG += value [value, ...]\n# Values that contain spaces should be placed between quotes (\\\" \\\").\n\n#---------------------------------------------------------------------------\n# Project related configuration options\n#---------------------------------------------------------------------------\n\n# This tag specifies the encoding used for all characters in the config file\n# that follow. The default is UTF-8 which is also the encoding used for all text\n# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv\n# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv\n# for the list of possible encodings.\n# The default value is: UTF-8.\n\nDOXYFILE_ENCODING      = UTF-8\n\n# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by\n# double-quotes, unless you are using Doxywizard) that should identify the\n# project for which the documentation is generated. This name is used in the\n# title of most generated pages and in a few other places.\n# The default value is: My Project.\n\nPROJECT_NAME           = RapidJSON\n\n# The PROJECT_NUMBER tag can be used to enter a project or revision number. This\n# could be handy for archiving the generated documentation or if some version\n# control system is used.\n\nPROJECT_NUMBER         =\n\n# Using the PROJECT_BRIEF tag one can provide an optional one line description\n# for a project that appears at the top of each page and should give viewer a\n# quick idea about the purpose of the project. Keep the description short.\n\nPROJECT_BRIEF          = \"A fast JSON parser/generator for C++ with both SAX/DOM style API\"\n\n# With the PROJECT_LOGO tag one can specify an logo or icon that is included in\n# the documentation. The maximum height of the logo should not exceed 55 pixels\n# and the maximum width should not exceed 200 pixels. Doxygen will copy the logo\n# to the output directory.\n\nPROJECT_LOGO           =\n\n# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path\n# into which the generated documentation will be written. If a relative path is\n# entered, it will be relative to the location where doxygen was started. If\n# left blank the current directory will be used.\n\nOUTPUT_DIRECTORY       = @CMAKE_CURRENT_BINARY_DIR@\n\n# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub-\n# directories (in 2 levels) under the output directory of each output format and\n# will distribute the generated files over these directories. Enabling this\n# option can be useful when feeding doxygen a huge amount of source files, where\n# putting all generated files in the same directory would otherwise causes\n# performance problems for the file system.\n# The default value is: NO.\n\nCREATE_SUBDIRS         = NO\n\n# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII\n# characters to appear in the names of generated files. If set to NO, non-ASCII\n# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode\n# U+3044.\n# The default value is: NO.\n\nALLOW_UNICODE_NAMES    = NO\n\n# The OUTPUT_LANGUAGE tag is used to specify the language in which all\n# documentation generated by doxygen is written. Doxygen will use this\n# information to generate all constant output in the proper language.\n# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese,\n# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States),\n# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian,\n# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages),\n# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian,\n# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian,\n# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish,\n# Ukrainian and Vietnamese.\n# The default value is: English.\n\nOUTPUT_LANGUAGE        = English\n\n# If the BRIEF_MEMBER_DESC tag is set to YES doxygen will include brief member\n# descriptions after the members that are listed in the file and class\n# documentation (similar to Javadoc). Set to NO to disable this.\n# The default value is: YES.\n\nBRIEF_MEMBER_DESC      = YES\n\n# If the REPEAT_BRIEF tag is set to YES doxygen will prepend the brief\n# description of a member or function before the detailed description\n#\n# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the\n# brief descriptions will be completely suppressed.\n# The default value is: YES.\n\nREPEAT_BRIEF           = YES\n\n# This tag implements a quasi-intelligent brief description abbreviator that is\n# used to form the text in various listings. Each string in this list, if found\n# as the leading text of the brief description, will be stripped from the text\n# and the result, after processing the whole list, is used as the annotated\n# text. Otherwise, the brief description is used as-is. If left blank, the\n# following values are used ($name is automatically replaced with the name of\n# the entity):The $name class, The $name widget, The $name file, is, provides,\n# specifies, contains, represents, a, an and the.\n\nABBREVIATE_BRIEF       = \"The $name class\" \\\n                         \"The $name widget\" \\\n                         \"The $name file\" \\\n                         is \\\n                         provides \\\n                         specifies \\\n                         contains \\\n                         represents \\\n                         a \\\n                         an \\\n                         the\n\n# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then\n# doxygen will generate a detailed section even if there is only a brief\n# description.\n# The default value is: NO.\n\nALWAYS_DETAILED_SEC    = NO\n\n# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all\n# inherited members of a class in the documentation of that class as if those\n# members were ordinary class members. Constructors, destructors and assignment\n# operators of the base classes will not be shown.\n# The default value is: NO.\n\nINLINE_INHERITED_MEMB  = NO\n\n# If the FULL_PATH_NAMES tag is set to YES doxygen will prepend the full path\n# before files name in the file list and in the header files. If set to NO the\n# shortest path that makes the file name unique will be used\n# The default value is: YES.\n\nFULL_PATH_NAMES        = YES\n\n# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.\n# Stripping is only done if one of the specified strings matches the left-hand\n# part of the path. The tag can be used to show relative paths in the file list.\n# If left blank the directory from which doxygen is run is used as the path to\n# strip.\n#\n# Note that you can specify absolute paths here, but also relative paths, which\n# will be relative from the directory where doxygen is started.\n# This tag requires that the tag FULL_PATH_NAMES is set to YES.\n\nSTRIP_FROM_PATH        =\n\n# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the\n# path mentioned in the documentation of a class, which tells the reader which\n# header file to include in order to use a class. If left blank only the name of\n# the header file containing the class definition is used. Otherwise one should\n# specify the list of include paths that are normally passed to the compiler\n# using the -I flag.\n\nSTRIP_FROM_INC_PATH    =\n\n# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but\n# less readable) file names. This can be useful is your file systems doesn't\n# support long names like on DOS, Mac, or CD-ROM.\n# The default value is: NO.\n\nSHORT_NAMES            = NO\n\n# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the\n# first line (until the first dot) of a Javadoc-style comment as the brief\n# description. If set to NO, the Javadoc-style will behave just like regular Qt-\n# style comments (thus requiring an explicit @brief command for a brief\n# description.)\n# The default value is: NO.\n\nJAVADOC_AUTOBRIEF      = NO\n\n# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first\n# line (until the first dot) of a Qt-style comment as the brief description. If\n# set to NO, the Qt-style will behave just like regular Qt-style comments (thus\n# requiring an explicit \\brief command for a brief description.)\n# The default value is: NO.\n\nQT_AUTOBRIEF           = NO\n\n# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a\n# multi-line C++ special comment block (i.e. a block of //! or /// comments) as\n# a brief description. This used to be the default behavior. The new default is\n# to treat a multi-line C++ comment block as a detailed description. Set this\n# tag to YES if you prefer the old behavior instead.\n#\n# Note that setting this tag to YES also means that rational rose comments are\n# not recognized any more.\n# The default value is: NO.\n\nMULTILINE_CPP_IS_BRIEF = NO\n\n# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the\n# documentation from any documented member that it re-implements.\n# The default value is: YES.\n\nINHERIT_DOCS           = YES\n\n# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce a\n# new page for each member. If set to NO, the documentation of a member will be\n# part of the file/class/namespace that contains it.\n# The default value is: NO.\n\nSEPARATE_MEMBER_PAGES  = NO\n\n# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen\n# uses this value to replace tabs by spaces in code fragments.\n# Minimum value: 1, maximum value: 16, default value: 4.\n\nTAB_SIZE               = 4\n\n# This tag can be used to specify a number of aliases that act as commands in\n# the documentation. An alias has the form:\n# name=value\n# For example adding\n# \"sideeffect=@par Side Effects:\\n\"\n# will allow you to put the command \\sideeffect (or @sideeffect) in the\n# documentation, which will result in a user-defined paragraph with heading\n# \"Side Effects:\". You can put \\n's in the value part of an alias to insert\n# newlines.\n\nALIASES                =\n\n# This tag can be used to specify a number of word-keyword mappings (TCL only).\n# A mapping has the form \"name=value\". For example adding \"class=itcl::class\"\n# will allow you to use the command class in the itcl::class meaning.\n\nTCL_SUBST              =\n\n# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources\n# only. Doxygen will then generate output that is more tailored for C. For\n# instance, some of the names that are used will be different. The list of all\n# members will be omitted, etc.\n# The default value is: NO.\n\nOPTIMIZE_OUTPUT_FOR_C  = NO\n\n# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or\n# Python sources only. Doxygen will then generate output that is more tailored\n# for that language. For instance, namespaces will be presented as packages,\n# qualified scopes will look different, etc.\n# The default value is: NO.\n\nOPTIMIZE_OUTPUT_JAVA   = NO\n\n# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran\n# sources. Doxygen will then generate output that is tailored for Fortran.\n# The default value is: NO.\n\nOPTIMIZE_FOR_FORTRAN   = NO\n\n# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL\n# sources. Doxygen will then generate output that is tailored for VHDL.\n# The default value is: NO.\n\nOPTIMIZE_OUTPUT_VHDL   = NO\n\n# Doxygen selects the parser to use depending on the extension of the files it\n# parses. With this tag you can assign which parser to use for a given\n# extension. Doxygen has a built-in mapping, but you can override or extend it\n# using this tag. The format is ext=language, where ext is a file extension, and\n# language is one of the parsers supported by doxygen: IDL, Java, Javascript,\n# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran:\n# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran:\n# Fortran. In the later case the parser tries to guess whether the code is fixed\n# or free formatted code, this is the default for Fortran type files), VHDL. For\n# instance to make doxygen treat .inc files as Fortran files (default is PHP),\n# and .f files as C (default is Fortran), use: inc=Fortran f=C.\n#\n# Note For files without extension you can use no_extension as a placeholder.\n#\n# Note that for custom extensions you also need to set FILE_PATTERNS otherwise\n# the files are not read by doxygen.\n\nEXTENSION_MAPPING      =\n\n# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments\n# according to the Markdown format, which allows for more readable\n# documentation. See http://daringfireball.net/projects/markdown/ for details.\n# The output of markdown processing is further processed by doxygen, so you can\n# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in\n# case of backward compatibilities issues.\n# The default value is: YES.\n\nMARKDOWN_SUPPORT       = YES\n\n# When enabled doxygen tries to link words that correspond to documented\n# classes, or namespaces to their corresponding documentation. Such a link can\n# be prevented in individual cases by by putting a % sign in front of the word\n# or globally by setting AUTOLINK_SUPPORT to NO.\n# The default value is: YES.\n\nAUTOLINK_SUPPORT       = YES\n\n# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want\n# to include (a tag file for) the STL sources as input, then you should set this\n# tag to YES in order to let doxygen match functions declarations and\n# definitions whose arguments contain STL classes (e.g. func(std::string);\n# versus func(std::string) {}). This also make the inheritance and collaboration\n# diagrams that involve STL classes more complete and accurate.\n# The default value is: NO.\n\nBUILTIN_STL_SUPPORT    = NO\n\n# If you use Microsoft's C++/CLI language, you should set this option to YES to\n# enable parsing support.\n# The default value is: NO.\n\nCPP_CLI_SUPPORT        = NO\n\n# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:\n# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen\n# will parse them like normal C++ but will assume all classes use public instead\n# of private inheritance when no explicit protection keyword is present.\n# The default value is: NO.\n\nSIP_SUPPORT            = NO\n\n# For Microsoft's IDL there are propget and propput attributes to indicate\n# getter and setter methods for a property. Setting this option to YES will make\n# doxygen to replace the get and set methods by a property in the documentation.\n# This will only work if the methods are indeed getting or setting a simple\n# type. If this is not the case, or you want to show the methods anyway, you\n# should set this option to NO.\n# The default value is: YES.\n\nIDL_PROPERTY_SUPPORT   = YES\n\n# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC\n# tag is set to YES, then doxygen will reuse the documentation of the first\n# member in the group (if any) for the other members of the group. By default\n# all members of a group must be documented explicitly.\n# The default value is: NO.\n\nDISTRIBUTE_GROUP_DOC   = NO\n\n# Set the SUBGROUPING tag to YES to allow class member groups of the same type\n# (for instance a group of public functions) to be put as a subgroup of that\n# type (e.g. under the Public Functions section). Set it to NO to prevent\n# subgrouping. Alternatively, this can be done per class using the\n# \\nosubgrouping command.\n# The default value is: YES.\n\nSUBGROUPING            = YES\n\n# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions\n# are shown inside the group in which they are included (e.g. using \\ingroup)\n# instead of on a separate page (for HTML and Man pages) or section (for LaTeX\n# and RTF).\n#\n# Note that this feature does not work in combination with\n# SEPARATE_MEMBER_PAGES.\n# The default value is: NO.\n\nINLINE_GROUPED_CLASSES = YES\n\n# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions\n# with only public data fields or simple typedef fields will be shown inline in\n# the documentation of the scope in which they are defined (i.e. file,\n# namespace, or group documentation), provided this scope is documented. If set\n# to NO, structs, classes, and unions are shown on a separate page (for HTML and\n# Man pages) or section (for LaTeX and RTF).\n# The default value is: NO.\n\nINLINE_SIMPLE_STRUCTS  = NO\n\n# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or\n# enum is documented as struct, union, or enum with the name of the typedef. So\n# typedef struct TypeS {} TypeT, will appear in the documentation as a struct\n# with name TypeT. When disabled the typedef will appear as a member of a file,\n# namespace, or class. And the struct will be named TypeS. This can typically be\n# useful for C code in case the coding convention dictates that all compound\n# types are typedef'ed and only the typedef is referenced, never the tag name.\n# The default value is: NO.\n\nTYPEDEF_HIDES_STRUCT   = NO\n\n# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This\n# cache is used to resolve symbols given their name and scope. Since this can be\n# an expensive process and often the same symbol appears multiple times in the\n# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small\n# doxygen will become slower. If the cache is too large, memory is wasted. The\n# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range\n# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536\n# symbols. At the end of a run doxygen will report the cache usage and suggest\n# the optimal cache size from a speed point of view.\n# Minimum value: 0, maximum value: 9, default value: 0.\n\nLOOKUP_CACHE_SIZE      = 0\n\n#---------------------------------------------------------------------------\n# Build related configuration options\n#---------------------------------------------------------------------------\n\n# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in\n# documentation are documented, even if no documentation was available. Private\n# class members and static file members will be hidden unless the\n# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES.\n# Note: This will also disable the warnings about undocumented members that are\n# normally produced when WARNINGS is set to YES.\n# The default value is: NO.\n\nEXTRACT_ALL            = NO\n\n# If the EXTRACT_PRIVATE tag is set to YES all private members of a class will\n# be included in the documentation.\n# The default value is: NO.\n\nEXTRACT_PRIVATE        = NO\n\n# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal\n# scope will be included in the documentation.\n# The default value is: NO.\n\nEXTRACT_PACKAGE        = NO\n\n# If the EXTRACT_STATIC tag is set to YES all static members of a file will be\n# included in the documentation.\n# The default value is: NO.\n\nEXTRACT_STATIC         = NO\n\n# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) defined\n# locally in source files will be included in the documentation. If set to NO\n# only classes defined in header files are included. Does not have any effect\n# for Java sources.\n# The default value is: YES.\n\nEXTRACT_LOCAL_CLASSES  = YES\n\n# This flag is only useful for Objective-C code. When set to YES local methods,\n# which are defined in the implementation section but not in the interface are\n# included in the documentation. If set to NO only methods in the interface are\n# included.\n# The default value is: NO.\n\nEXTRACT_LOCAL_METHODS  = NO\n\n# If this flag is set to YES, the members of anonymous namespaces will be\n# extracted and appear in the documentation as a namespace called\n# 'anonymous_namespace{file}', where file will be replaced with the base name of\n# the file that contains the anonymous namespace. By default anonymous namespace\n# are hidden.\n# The default value is: NO.\n\nEXTRACT_ANON_NSPACES   = NO\n\n# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all\n# undocumented members inside documented classes or files. If set to NO these\n# members will be included in the various overviews, but no documentation\n# section is generated. This option has no effect if EXTRACT_ALL is enabled.\n# The default value is: NO.\n\nHIDE_UNDOC_MEMBERS     = NO\n\n# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all\n# undocumented classes that are normally visible in the class hierarchy. If set\n# to NO these classes will be included in the various overviews. This option has\n# no effect if EXTRACT_ALL is enabled.\n# The default value is: NO.\n\nHIDE_UNDOC_CLASSES     = NO\n\n# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend\n# (class|struct|union) declarations. If set to NO these declarations will be\n# included in the documentation.\n# The default value is: NO.\n\nHIDE_FRIEND_COMPOUNDS  = NO\n\n# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any\n# documentation blocks found inside the body of a function. If set to NO these\n# blocks will be appended to the function's detailed documentation block.\n# The default value is: NO.\n\nHIDE_IN_BODY_DOCS      = NO\n\n# The INTERNAL_DOCS tag determines if documentation that is typed after a\n# \\internal command is included. If the tag is set to NO then the documentation\n# will be excluded. Set it to YES to include the internal documentation.\n# The default value is: NO.\n\nINTERNAL_DOCS          = NO\n\n# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file\n# names in lower-case letters. If set to YES upper-case letters are also\n# allowed. This is useful if you have classes or files whose names only differ\n# in case and if your file system supports case sensitive file names. Windows\n# and Mac users are advised to set this option to NO.\n# The default value is: system dependent.\n\nCASE_SENSE_NAMES       = NO\n\n# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with\n# their full class and namespace scopes in the documentation. If set to YES the\n# scope will be hidden.\n# The default value is: NO.\n\nHIDE_SCOPE_NAMES       = NO\n\n# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of\n# the files that are included by a file in the documentation of that file.\n# The default value is: YES.\n\nSHOW_INCLUDE_FILES     = YES\n\n# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each\n# grouped member an include statement to the documentation, telling the reader\n# which file to include in order to use the member.\n# The default value is: NO.\n\nSHOW_GROUPED_MEMB_INC  = NO\n\n# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include\n# files with double quotes in the documentation rather than with sharp brackets.\n# The default value is: NO.\n\nFORCE_LOCAL_INCLUDES   = NO\n\n# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the\n# documentation for inline members.\n# The default value is: YES.\n\nINLINE_INFO            = YES\n\n# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the\n# (detailed) documentation of file and class members alphabetically by member\n# name. If set to NO the members will appear in declaration order.\n# The default value is: YES.\n\nSORT_MEMBER_DOCS       = YES\n\n# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief\n# descriptions of file, namespace and class members alphabetically by member\n# name. If set to NO the members will appear in declaration order. Note that\n# this will also influence the order of the classes in the class list.\n# The default value is: NO.\n\nSORT_BRIEF_DOCS        = NO\n\n# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the\n# (brief and detailed) documentation of class members so that constructors and\n# destructors are listed first. If set to NO the constructors will appear in the\n# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS.\n# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief\n# member documentation.\n# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting\n# detailed member documentation.\n# The default value is: NO.\n\nSORT_MEMBERS_CTORS_1ST = NO\n\n# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy\n# of group names into alphabetical order. If set to NO the group names will\n# appear in their defined order.\n# The default value is: NO.\n\nSORT_GROUP_NAMES       = NO\n\n# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by\n# fully-qualified names, including namespaces. If set to NO, the class list will\n# be sorted only by class name, not including the namespace part.\n# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.\n# Note: This option applies only to the class list, not to the alphabetical\n# list.\n# The default value is: NO.\n\nSORT_BY_SCOPE_NAME     = NO\n\n# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper\n# type resolution of all parameters of a function it will reject a match between\n# the prototype and the implementation of a member function even if there is\n# only one candidate or it is obvious which candidate to choose by doing a\n# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still\n# accept a match between prototype and implementation in such cases.\n# The default value is: NO.\n\nSTRICT_PROTO_MATCHING  = NO\n\n# The GENERATE_TODOLIST tag can be used to enable ( YES) or disable ( NO) the\n# todo list. This list is created by putting \\todo commands in the\n# documentation.\n# The default value is: YES.\n\nGENERATE_TODOLIST      = YES\n\n# The GENERATE_TESTLIST tag can be used to enable ( YES) or disable ( NO) the\n# test list. This list is created by putting \\test commands in the\n# documentation.\n# The default value is: YES.\n\nGENERATE_TESTLIST      = YES\n\n# The GENERATE_BUGLIST tag can be used to enable ( YES) or disable ( NO) the bug\n# list. This list is created by putting \\bug commands in the documentation.\n# The default value is: YES.\n\nGENERATE_BUGLIST       = YES\n\n# The GENERATE_DEPRECATEDLIST tag can be used to enable ( YES) or disable ( NO)\n# the deprecated list. This list is created by putting \\deprecated commands in\n# the documentation.\n# The default value is: YES.\n\nGENERATE_DEPRECATEDLIST= YES\n\n# The ENABLED_SECTIONS tag can be used to enable conditional documentation\n# sections, marked by \\if <section_label> ... \\endif and \\cond <section_label>\n# ... \\endcond blocks.\n\nENABLED_SECTIONS       = $(RAPIDJSON_SECTIONS)\n\n# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the\n# initial value of a variable or macro / define can have for it to appear in the\n# documentation. If the initializer consists of more lines than specified here\n# it will be hidden. Use a value of 0 to hide initializers completely. The\n# appearance of the value of individual variables and macros / defines can be\n# controlled using \\showinitializer or \\hideinitializer command in the\n# documentation regardless of this setting.\n# Minimum value: 0, maximum value: 10000, default value: 30.\n\nMAX_INITIALIZER_LINES  = 30\n\n# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at\n# the bottom of the documentation of classes and structs. If set to YES the list\n# will mention the files that were used to generate the documentation.\n# The default value is: YES.\n\nSHOW_USED_FILES        = YES\n\n# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This\n# will remove the Files entry from the Quick Index and from the Folder Tree View\n# (if specified).\n# The default value is: YES.\n\nSHOW_FILES             = YES\n\n# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces\n# page. This will remove the Namespaces entry from the Quick Index and from the\n# Folder Tree View (if specified).\n# The default value is: YES.\n\nSHOW_NAMESPACES        = NO\n\n# The FILE_VERSION_FILTER tag can be used to specify a program or script that\n# doxygen should invoke to get the current version for each file (typically from\n# the version control system). Doxygen will invoke the program by executing (via\n# popen()) the command command input-file, where command is the value of the\n# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided\n# by doxygen. Whatever the program writes to standard output is used as the file\n# version. For an example see the documentation.\n\nFILE_VERSION_FILTER    =\n\n# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed\n# by doxygen. The layout file controls the global structure of the generated\n# output files in an output format independent way. To create the layout file\n# that represents doxygen's defaults, run doxygen with the -l option. You can\n# optionally specify a file name after the option, if omitted DoxygenLayout.xml\n# will be used as the name of the layout file.\n#\n# Note that if you run doxygen from a directory containing a file called\n# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE\n# tag is left empty.\n\nLAYOUT_FILE            =\n\n# The CITE_BIB_FILES tag can be used to specify one or more bib files containing\n# the reference definitions. This must be a list of .bib files. The .bib\n# extension is automatically appended if omitted. This requires the bibtex tool\n# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info.\n# For LaTeX the style of the bibliography can be controlled using\n# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the\n# search path. Do not use file names with spaces, bibtex cannot handle them. See\n# also \\cite for info how to create references.\n\nCITE_BIB_FILES         =\n\n#---------------------------------------------------------------------------\n# Configuration options related to warning and progress messages\n#---------------------------------------------------------------------------\n\n# The QUIET tag can be used to turn on/off the messages that are generated to\n# standard output by doxygen. If QUIET is set to YES this implies that the\n# messages are off.\n# The default value is: NO.\n\nQUIET                  = NO\n\n# The WARNINGS tag can be used to turn on/off the warning messages that are\n# generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES\n# this implies that the warnings are on.\n#\n# Tip: Turn warnings on while writing the documentation.\n# The default value is: YES.\n\nWARNINGS               = YES\n\n# If the WARN_IF_UNDOCUMENTED tag is set to YES, then doxygen will generate\n# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag\n# will automatically be disabled.\n# The default value is: YES.\n\nWARN_IF_UNDOCUMENTED   = YES\n\n# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for\n# potential errors in the documentation, such as not documenting some parameters\n# in a documented function, or documenting parameters that don't exist or using\n# markup commands wrongly.\n# The default value is: YES.\n\nWARN_IF_DOC_ERROR      = YES\n\n# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that\n# are documented, but have no documentation for their parameters or return\n# value. If set to NO doxygen will only warn about wrong or incomplete parameter\n# documentation, but not about the absence of documentation.\n# The default value is: NO.\n\nWARN_NO_PARAMDOC       = NO\n\n# The WARN_FORMAT tag determines the format of the warning messages that doxygen\n# can produce. The string should contain the $file, $line, and $text tags, which\n# will be replaced by the file and line number from which the warning originated\n# and the warning text. Optionally the format may contain $version, which will\n# be replaced by the version of the file (if it could be obtained via\n# FILE_VERSION_FILTER)\n# The default value is: $file:$line: $text.\n\nWARN_FORMAT            = \"$file:$line: $text\"\n\n# The WARN_LOGFILE tag can be used to specify a file to which warning and error\n# messages should be written. If left blank the output is written to standard\n# error (stderr).\n\nWARN_LOGFILE           =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the input files\n#---------------------------------------------------------------------------\n\n# The INPUT tag is used to specify the files and/or directories that contain\n# documented source files. You may enter file names like myfile.cpp or\n# directories like /usr/src/myproject. Separate the files or directories with\n# spaces.\n# Note: If this tag is empty the current directory is searched.\n\nINPUT                  = readme.md \\\n                         CHANGELOG.md \\\n                         include/rapidjson/rapidjson.h \\\n                         include/ \\\n                         doc/features.md \\\n                         doc/tutorial.md \\\n                         doc/pointer.md \\\n                         doc/stream.md \\\n                         doc/encoding.md \\\n                         doc/dom.md \\\n                         doc/sax.md \\\n                         doc/schema.md \\\n                         doc/performance.md \\\n                         doc/internals.md \\\n                         doc/faq.md\n\n# This tag can be used to specify the character encoding of the source files\n# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses\n# libiconv (or the iconv built into libc) for the transcoding. See the libiconv\n# documentation (see: http://www.gnu.org/software/libiconv) for the list of\n# possible encodings.\n# The default value is: UTF-8.\n\nINPUT_ENCODING         = UTF-8\n\n# If the value of the INPUT tag contains directories, you can use the\n# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and\n# *.h) to filter out the source-files in the directories. If left blank the\n# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii,\n# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp,\n# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown,\n# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf,\n# *.qsf, *.as and *.js.\n\nFILE_PATTERNS          = *.c \\\n                         *.cc \\\n                         *.cxx \\\n                         *.cpp \\\n                         *.h \\\n                         *.hh \\\n                         *.hxx \\\n                         *.hpp \\\n                         *.inc \\\n                         *.md\n\n# The RECURSIVE tag can be used to specify whether or not subdirectories should\n# be searched for input files as well.\n# The default value is: NO.\n\nRECURSIVE              = YES\n\n# The EXCLUDE tag can be used to specify files and/or directories that should be\n# excluded from the INPUT source files. This way you can easily exclude a\n# subdirectory from a directory tree whose root is specified with the INPUT tag.\n#\n# Note that relative paths are relative to the directory from which doxygen is\n# run.\n\nEXCLUDE                = ./include/rapidjson/msinttypes/\n\n# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or\n# directories that are symbolic links (a Unix file system feature) are excluded\n# from the input.\n# The default value is: NO.\n\nEXCLUDE_SYMLINKS       = NO\n\n# If the value of the INPUT tag contains directories, you can use the\n# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude\n# certain files from those directories.\n#\n# Note that the wildcards are matched against the file with absolute path, so to\n# exclude all test directories for example use the pattern */test/*\n\nEXCLUDE_PATTERNS       =\n\n# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names\n# (namespaces, classes, functions, etc.) that should be excluded from the\n# output. The symbol name can be a fully qualified name, a word, or if the\n# wildcard * is used, a substring. Examples: ANamespace, AClass,\n# AClass::ANamespace, ANamespace::*Test\n#\n# Note that the wildcards are matched against the file with absolute path, so to\n# exclude all test directories use the pattern */test/*\n\nEXCLUDE_SYMBOLS        = internal\n\n# The EXAMPLE_PATH tag can be used to specify one or more files or directories\n# that contain example code fragments that are included (see the \\include\n# command).\n\nEXAMPLE_PATH           =\n\n# If the value of the EXAMPLE_PATH tag contains directories, you can use the\n# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and\n# *.h) to filter out the source-files in the directories. If left blank all\n# files are included.\n\nEXAMPLE_PATTERNS       = *\n\n# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be\n# searched for input files to be used with the \\include or \\dontinclude commands\n# irrespective of the value of the RECURSIVE tag.\n# The default value is: NO.\n\nEXAMPLE_RECURSIVE      = NO\n\n# The IMAGE_PATH tag can be used to specify one or more files or directories\n# that contain images that are to be included in the documentation (see the\n# \\image command).\n\nIMAGE_PATH             = ./doc\n\n# The INPUT_FILTER tag can be used to specify a program that doxygen should\n# invoke to filter for each input file. Doxygen will invoke the filter program\n# by executing (via popen()) the command:\n#\n# <filter> <input-file>\n#\n# where <filter> is the value of the INPUT_FILTER tag, and <input-file> is the\n# name of an input file. Doxygen will then use the output that the filter\n# program writes to standard output. If FILTER_PATTERNS is specified, this tag\n# will be ignored.\n#\n# Note that the filter must not add or remove lines; it is applied before the\n# code is scanned, but not when the output code is generated. If lines are added\n# or removed, the anchors will not be placed correctly.\n\nINPUT_FILTER           =\n\n# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern\n# basis. Doxygen will compare the file name with each pattern and apply the\n# filter if there is a match. The filters are a list of the form: pattern=filter\n# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how\n# filters are used. If the FILTER_PATTERNS tag is empty or if none of the\n# patterns match the file name, INPUT_FILTER is applied.\n\nFILTER_PATTERNS        =\n\n# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using\n# INPUT_FILTER ) will also be used to filter the input files that are used for\n# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES).\n# The default value is: NO.\n\nFILTER_SOURCE_FILES    = NO\n\n# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file\n# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and\n# it is also possible to disable source filtering for a specific pattern using\n# *.ext= (so without naming a filter).\n# This tag requires that the tag FILTER_SOURCE_FILES is set to YES.\n\nFILTER_SOURCE_PATTERNS =\n\n# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that\n# is part of the input, its contents will be placed on the main page\n# (index.html). This can be useful if you have a project on for instance GitHub\n# and want to reuse the introduction page also for the doxygen output.\n\nUSE_MDFILE_AS_MAINPAGE = readme.md\n\n#---------------------------------------------------------------------------\n# Configuration options related to source browsing\n#---------------------------------------------------------------------------\n\n# If the SOURCE_BROWSER tag is set to YES then a list of source files will be\n# generated. Documented entities will be cross-referenced with these sources.\n#\n# Note: To get rid of all source code in the generated output, make sure that\n# also VERBATIM_HEADERS is set to NO.\n# The default value is: NO.\n\nSOURCE_BROWSER         = NO\n\n# Setting the INLINE_SOURCES tag to YES will include the body of functions,\n# classes and enums directly into the documentation.\n# The default value is: NO.\n\nINLINE_SOURCES         = NO\n\n# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any\n# special comment blocks from generated source code fragments. Normal C, C++ and\n# Fortran comments will always remain visible.\n# The default value is: YES.\n\nSTRIP_CODE_COMMENTS    = NO\n\n# If the REFERENCED_BY_RELATION tag is set to YES then for each documented\n# function all documented functions referencing it will be listed.\n# The default value is: NO.\n\nREFERENCED_BY_RELATION = NO\n\n# If the REFERENCES_RELATION tag is set to YES then for each documented function\n# all documented entities called/used by that function will be listed.\n# The default value is: NO.\n\nREFERENCES_RELATION    = NO\n\n# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set\n# to YES, then the hyperlinks from functions in REFERENCES_RELATION and\n# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will\n# link to the documentation.\n# The default value is: YES.\n\nREFERENCES_LINK_SOURCE = YES\n\n# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the\n# source code will show a tooltip with additional information such as prototype,\n# brief description and links to the definition and documentation. Since this\n# will make the HTML file larger and loading of large files a bit slower, you\n# can opt to disable this feature.\n# The default value is: YES.\n# This tag requires that the tag SOURCE_BROWSER is set to YES.\n\nSOURCE_TOOLTIPS        = YES\n\n# If the USE_HTAGS tag is set to YES then the references to source code will\n# point to the HTML generated by the htags(1) tool instead of doxygen built-in\n# source browser. The htags tool is part of GNU's global source tagging system\n# (see http://www.gnu.org/software/global/global.html). You will need version\n# 4.8.6 or higher.\n#\n# To use it do the following:\n# - Install the latest version of global\n# - Enable SOURCE_BROWSER and USE_HTAGS in the config file\n# - Make sure the INPUT points to the root of the source tree\n# - Run doxygen as normal\n#\n# Doxygen will invoke htags (and that will in turn invoke gtags), so these\n# tools must be available from the command line (i.e. in the search path).\n#\n# The result: instead of the source browser generated by doxygen, the links to\n# source code will now point to the output of htags.\n# The default value is: NO.\n# This tag requires that the tag SOURCE_BROWSER is set to YES.\n\nUSE_HTAGS              = NO\n\n# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a\n# verbatim copy of the header file for each class for which an include is\n# specified. Set to NO to disable this.\n# See also: Section \\class.\n# The default value is: YES.\n\nVERBATIM_HEADERS       = YES\n\n# If the CLANG_ASSISTED_PARSING tag is set to YES, then doxygen will use the\n# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the\n# cost of reduced performance. This can be particularly helpful with template\n# rich C++ code for which doxygen's built-in parser lacks the necessary type\n# information.\n# Note: The availability of this option depends on whether or not doxygen was\n# compiled with the --with-libclang option.\n# The default value is: NO.\n\nCLANG_ASSISTED_PARSING = NO\n\n# If clang assisted parsing is enabled you can provide the compiler with command\n# line options that you would normally use when invoking the compiler. Note that\n# the include paths will already be set by doxygen for the files and directories\n# specified with INPUT and INCLUDE_PATH.\n# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES.\n\nCLANG_OPTIONS          =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the alphabetical class index\n#---------------------------------------------------------------------------\n\n# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all\n# compounds will be generated. Enable this if the project contains a lot of\n# classes, structs, unions or interfaces.\n# The default value is: YES.\n\nALPHABETICAL_INDEX     = NO\n\n# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in\n# which the alphabetical index list will be split.\n# Minimum value: 1, maximum value: 20, default value: 5.\n# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.\n\nCOLS_IN_ALPHA_INDEX    = 5\n\n# In case all classes in a project start with a common prefix, all classes will\n# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag\n# can be used to specify a prefix (or a list of prefixes) that should be ignored\n# while generating the index headers.\n# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.\n\nIGNORE_PREFIX          =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the HTML output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_HTML tag is set to YES doxygen will generate HTML output\n# The default value is: YES.\n\nGENERATE_HTML          = YES\n\n# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: html.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_OUTPUT            = html\n\n# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each\n# generated HTML page (for example: .htm, .php, .asp).\n# The default value is: .html.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_FILE_EXTENSION    = .html\n\n# The HTML_HEADER tag can be used to specify a user-defined HTML header file for\n# each generated HTML page. If the tag is left blank doxygen will generate a\n# standard header.\n#\n# To get valid HTML the header file that includes any scripts and style sheets\n# that doxygen needs, which is dependent on the configuration options used (e.g.\n# the setting GENERATE_TREEVIEW). It is highly recommended to start with a\n# default header using\n# doxygen -w html new_header.html new_footer.html new_stylesheet.css\n# YourConfigFile\n# and then modify the file new_header.html. See also section \"Doxygen usage\"\n# for information on how to generate the default header that doxygen normally\n# uses.\n# Note: The header is subject to change so you typically have to regenerate the\n# default header when upgrading to a newer version of doxygen. For a description\n# of the possible markers and block names see the documentation.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_HEADER            = ./doc/misc/header.html\n\n# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each\n# generated HTML page. If the tag is left blank doxygen will generate a standard\n# footer. See HTML_HEADER for more information on how to generate a default\n# footer and what special commands can be used inside the footer. See also\n# section \"Doxygen usage\" for information on how to generate the default footer\n# that doxygen normally uses.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_FOOTER            = ./doc/misc/footer.html\n\n# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style\n# sheet that is used by each HTML page. It can be used to fine-tune the look of\n# the HTML output. If left blank doxygen will generate a default style sheet.\n# See also section \"Doxygen usage\" for information on how to generate the style\n# sheet that doxygen normally uses.\n# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as\n# it is more robust and this tag (HTML_STYLESHEET) will in the future become\n# obsolete.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_STYLESHEET        =\n\n# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional user-\n# defined cascading style sheet that is included after the standard style sheets\n# created by doxygen. Using this option one can overrule certain style aspects.\n# This is preferred over using HTML_STYLESHEET since it does not replace the\n# standard style sheet and is therefor more robust against future updates.\n# Doxygen will copy the style sheet file to the output directory. For an example\n# see the documentation.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_EXTRA_STYLESHEET  = ./doc/misc/doxygenextra.css\n\n# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or\n# other source files which should be copied to the HTML output directory. Note\n# that these files will be copied to the base HTML output directory. Use the\n# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these\n# files. In the HTML_STYLESHEET file, use the file name only. Also note that the\n# files will be copied as-is; there are no commands or markers available.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_EXTRA_FILES       =\n\n# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen\n# will adjust the colors in the stylesheet and background images according to\n# this color. Hue is specified as an angle on a colorwheel, see\n# http://en.wikipedia.org/wiki/Hue for more information. For instance the value\n# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300\n# purple, and 360 is red again.\n# Minimum value: 0, maximum value: 359, default value: 220.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_COLORSTYLE_HUE    = 220\n\n# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors\n# in the HTML output. For a value of 0 the output will use grayscales only. A\n# value of 255 will produce the most vivid colors.\n# Minimum value: 0, maximum value: 255, default value: 100.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_COLORSTYLE_SAT    = 100\n\n# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the\n# luminance component of the colors in the HTML output. Values below 100\n# gradually make the output lighter, whereas values above 100 make the output\n# darker. The value divided by 100 is the actual gamma applied, so 80 represents\n# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not\n# change the gamma.\n# Minimum value: 40, maximum value: 240, default value: 80.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_COLORSTYLE_GAMMA  = 80\n\n# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML\n# page will contain the date and time when the page was generated. Setting this\n# to NO can help when comparing the output of multiple runs.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_TIMESTAMP         = YES\n\n# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML\n# documentation will contain sections that can be hidden and shown after the\n# page has loaded.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_DYNAMIC_SECTIONS  = NO\n\n# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries\n# shown in the various tree structured indices initially; the user can expand\n# and collapse entries dynamically later on. Doxygen will expand the tree to\n# such a level that at most the specified number of entries are visible (unless\n# a fully collapsed tree already exceeds this amount). So setting the number of\n# entries 1 will produce a full collapsed tree by default. 0 is a special value\n# representing an infinite number of entries and will result in a full expanded\n# tree by default.\n# Minimum value: 0, maximum value: 9999, default value: 100.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_INDEX_NUM_ENTRIES = 100\n\n# If the GENERATE_DOCSET tag is set to YES, additional index files will be\n# generated that can be used as input for Apple's Xcode 3 integrated development\n# environment (see: http://developer.apple.com/tools/xcode/), introduced with\n# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a\n# Makefile in the HTML output directory. Running make will produce the docset in\n# that directory and running make install will install the docset in\n# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at\n# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html\n# for more information.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_DOCSET        = NO\n\n# This tag determines the name of the docset feed. A documentation feed provides\n# an umbrella under which multiple documentation sets from a single provider\n# (such as a company or product suite) can be grouped.\n# The default value is: Doxygen generated docs.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_FEEDNAME        = \"Doxygen generated docs\"\n\n# This tag specifies a string that should uniquely identify the documentation\n# set bundle. This should be a reverse domain-name style string, e.g.\n# com.mycompany.MyDocSet. Doxygen will append .docset to the name.\n# The default value is: org.doxygen.Project.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_BUNDLE_ID       = org.doxygen.Project\n\n# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify\n# the documentation publisher. This should be a reverse domain-name style\n# string, e.g. com.mycompany.MyDocSet.documentation.\n# The default value is: org.doxygen.Publisher.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_PUBLISHER_ID    = org.doxygen.Publisher\n\n# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher.\n# The default value is: Publisher.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_PUBLISHER_NAME  = Publisher\n\n# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three\n# additional HTML index files: index.hhp, index.hhc, and index.hhk. The\n# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop\n# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on\n# Windows.\n#\n# The HTML Help Workshop contains a compiler that can convert all HTML output\n# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML\n# files are now used as the Windows 98 help format, and will replace the old\n# Windows help format (.hlp) on all Windows platforms in the future. Compressed\n# HTML files also contain an index, a table of contents, and you can search for\n# words in the documentation. The HTML workshop also contains a viewer for\n# compressed HTML files.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_HTMLHELP      = NO\n\n# The CHM_FILE tag can be used to specify the file name of the resulting .chm\n# file. You can add a path in front of the file if the result should not be\n# written to the html output directory.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nCHM_FILE               =\n\n# The HHC_LOCATION tag can be used to specify the location (absolute path\n# including file name) of the HTML help compiler ( hhc.exe). If non-empty\n# doxygen will try to run the HTML help compiler on the generated index.hhp.\n# The file has to be specified with full path.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nHHC_LOCATION           =\n\n# The GENERATE_CHI flag controls if a separate .chi index file is generated (\n# YES) or that it should be included in the master .chm file ( NO).\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nGENERATE_CHI           = NO\n\n# The CHM_INDEX_ENCODING is used to encode HtmlHelp index ( hhk), content ( hhc)\n# and project file content.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nCHM_INDEX_ENCODING     =\n\n# The BINARY_TOC flag controls whether a binary table of contents is generated (\n# YES) or a normal table of contents ( NO) in the .chm file. Furthermore it\n# enables the Previous and Next buttons.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nBINARY_TOC             = NO\n\n# The TOC_EXPAND flag can be set to YES to add extra items for group members to\n# the table of contents of the HTML help documentation and to the tree view.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nTOC_EXPAND             = NO\n\n# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and\n# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that\n# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help\n# (.qch) of the generated HTML documentation.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_QHP           = NO\n\n# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify\n# the file name of the resulting .qch file. The path specified is relative to\n# the HTML output folder.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQCH_FILE               =\n\n# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help\n# Project output. For more information please see Qt Help Project / Namespace\n# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace).\n# The default value is: org.doxygen.Project.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_NAMESPACE          = org.doxygen.Project\n\n# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt\n# Help Project output. For more information please see Qt Help Project / Virtual\n# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual-\n# folders).\n# The default value is: doc.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_VIRTUAL_FOLDER     = doc\n\n# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom\n# filter to add. For more information please see Qt Help Project / Custom\n# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-\n# filters).\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_CUST_FILTER_NAME   =\n\n# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the\n# custom filter to add. For more information please see Qt Help Project / Custom\n# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-\n# filters).\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_CUST_FILTER_ATTRS  =\n\n# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this\n# project's filter section matches. Qt Help Project / Filter Attributes (see:\n# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes).\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_SECT_FILTER_ATTRS  =\n\n# The QHG_LOCATION tag can be used to specify the location of Qt's\n# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the\n# generated .qhp file.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHG_LOCATION           =\n\n# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be\n# generated, together with the HTML files, they form an Eclipse help plugin. To\n# install this plugin and make it available under the help contents menu in\n# Eclipse, the contents of the directory containing the HTML and XML files needs\n# to be copied into the plugins directory of eclipse. The name of the directory\n# within the plugins directory should be the same as the ECLIPSE_DOC_ID value.\n# After copying Eclipse needs to be restarted before the help appears.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_ECLIPSEHELP   = NO\n\n# A unique identifier for the Eclipse help plugin. When installing the plugin\n# the directory name containing the HTML and XML files should also have this\n# name. Each documentation set should have its own identifier.\n# The default value is: org.doxygen.Project.\n# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES.\n\nECLIPSE_DOC_ID         = org.doxygen.Project\n\n# If you want full control over the layout of the generated HTML pages it might\n# be necessary to disable the index and replace it with your own. The\n# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top\n# of each HTML page. A value of NO enables the index and the value YES disables\n# it. Since the tabs in the index contain the same information as the navigation\n# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nDISABLE_INDEX          = YES\n\n# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index\n# structure should be generated to display hierarchical information. If the tag\n# value is set to YES, a side panel will be generated containing a tree-like\n# index structure (just like the one that is generated for HTML Help). For this\n# to work a browser that supports JavaScript, DHTML, CSS and frames is required\n# (i.e. any modern browser). Windows users are probably better off using the\n# HTML help feature. Via custom stylesheets (see HTML_EXTRA_STYLESHEET) one can\n# further fine-tune the look of the index. As an example, the default style\n# sheet generated by doxygen has an example that shows how to put an image at\n# the root of the tree instead of the PROJECT_NAME. Since the tree basically has\n# the same information as the tab index, you could consider setting\n# DISABLE_INDEX to YES when enabling this option.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_TREEVIEW      = YES\n\n# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that\n# doxygen will group on one line in the generated HTML documentation.\n#\n# Note that a value of 0 will completely suppress the enum values from appearing\n# in the overview section.\n# Minimum value: 0, maximum value: 20, default value: 4.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nENUM_VALUES_PER_LINE   = 4\n\n# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used\n# to set the initial width (in pixels) of the frame in which the tree is shown.\n# Minimum value: 0, maximum value: 1500, default value: 250.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nTREEVIEW_WIDTH         = 250\n\n# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open links to\n# external symbols imported via tag files in a separate window.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nEXT_LINKS_IN_WINDOW    = NO\n\n# Use this tag to change the font size of LaTeX formulas included as images in\n# the HTML documentation. When you change the font size after a successful\n# doxygen run you need to manually remove any form_*.png images from the HTML\n# output directory to force them to be regenerated.\n# Minimum value: 8, maximum value: 50, default value: 10.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nFORMULA_FONTSIZE       = 10\n\n# Use the FORMULA_TRANPARENT tag to determine whether or not the images\n# generated for formulas are transparent PNGs. Transparent PNGs are not\n# supported properly for IE 6.0, but are supported on all modern browsers.\n#\n# Note that when changing this option you need to delete any form_*.png files in\n# the HTML output directory before the changes have effect.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nFORMULA_TRANSPARENT    = YES\n\n# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see\n# http://www.mathjax.org) which uses client side Javascript for the rendering\n# instead of using prerendered bitmaps. Use this if you do not have LaTeX\n# installed or if you want to formulas look prettier in the HTML output. When\n# enabled you may also need to install MathJax separately and configure the path\n# to it using the MATHJAX_RELPATH option.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nUSE_MATHJAX            = NO\n\n# When MathJax is enabled you can set the default output format to be used for\n# the MathJax output. See the MathJax site (see:\n# http://docs.mathjax.org/en/latest/output.html) for more details.\n# Possible values are: HTML-CSS (which is slower, but has the best\n# compatibility), NativeMML (i.e. MathML) and SVG.\n# The default value is: HTML-CSS.\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_FORMAT         = HTML-CSS\n\n# When MathJax is enabled you need to specify the location relative to the HTML\n# output directory using the MATHJAX_RELPATH option. The destination directory\n# should contain the MathJax.js script. For instance, if the mathjax directory\n# is located at the same level as the HTML output directory, then\n# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax\n# Content Delivery Network so you can quickly see the result without installing\n# MathJax. However, it is strongly recommended to install a local copy of\n# MathJax from http://www.mathjax.org before deployment.\n# The default value is: http://cdn.mathjax.org/mathjax/latest.\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_RELPATH        = http://www.mathjax.org/mathjax\n\n# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax\n# extension names that should be enabled during MathJax rendering. For example\n# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_EXTENSIONS     =\n\n# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces\n# of code that will be used on startup of the MathJax code. See the MathJax site\n# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an\n# example see the documentation.\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_CODEFILE       =\n\n# When the SEARCHENGINE tag is enabled doxygen will generate a search box for\n# the HTML output. The underlying search engine uses javascript and DHTML and\n# should work on any modern browser. Note that when using HTML help\n# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET)\n# there is already a search function so this one should typically be disabled.\n# For large projects the javascript based search engine can be slow, then\n# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to\n# search using the keyboard; to jump to the search box use <access key> + S\n# (what the <access key> is depends on the OS and browser, but it is typically\n# <CTRL>, <ALT>/<option>, or both). Inside the search box use the <cursor down\n# key> to jump into the search results window, the results can be navigated\n# using the <cursor keys>. Press <Enter> to select an item or <escape> to cancel\n# the search. The filter options can be selected when the cursor is inside the\n# search box by pressing <Shift>+<cursor down>. Also here use the <cursor keys>\n# to select a filter and <Enter> or <escape> to activate or cancel the filter\n# option.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nSEARCHENGINE           = YES\n\n# When the SERVER_BASED_SEARCH tag is enabled the search engine will be\n# implemented using a web server instead of a web client using Javascript. There\n# are two flavors of web server based searching depending on the EXTERNAL_SEARCH\n# setting. When disabled, doxygen will generate a PHP script for searching and\n# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing\n# and searching needs to be provided by external tools. See the section\n# \"External Indexing and Searching\" for details.\n# The default value is: NO.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nSERVER_BASED_SEARCH    = NO\n\n# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP\n# script for searching. Instead the search results are written to an XML file\n# which needs to be processed by an external indexer. Doxygen will invoke an\n# external search engine pointed to by the SEARCHENGINE_URL option to obtain the\n# search results.\n#\n# Doxygen ships with an example indexer ( doxyindexer) and search engine\n# (doxysearch.cgi) which are based on the open source search engine library\n# Xapian (see: http://xapian.org/).\n#\n# See the section \"External Indexing and Searching\" for details.\n# The default value is: NO.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nEXTERNAL_SEARCH        = NO\n\n# The SEARCHENGINE_URL should point to a search engine hosted by a web server\n# which will return the search results when EXTERNAL_SEARCH is enabled.\n#\n# Doxygen ships with an example indexer ( doxyindexer) and search engine\n# (doxysearch.cgi) which are based on the open source search engine library\n# Xapian (see: http://xapian.org/). See the section \"External Indexing and\n# Searching\" for details.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nSEARCHENGINE_URL       =\n\n# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed\n# search data is written to a file for indexing by an external tool. With the\n# SEARCHDATA_FILE tag the name of this file can be specified.\n# The default file is: searchdata.xml.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nSEARCHDATA_FILE        = searchdata.xml\n\n# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the\n# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is\n# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple\n# projects and redirect the results back to the right project.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nEXTERNAL_SEARCH_ID     =\n\n# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen\n# projects other than the one defined by this configuration file, but that are\n# all added to the same external search index. Each project needs to have a\n# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of\n# to a relative location where the documentation can be found. The format is:\n# EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ...\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nEXTRA_SEARCH_MAPPINGS  =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the LaTeX output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_LATEX tag is set to YES doxygen will generate LaTeX output.\n# The default value is: YES.\n\nGENERATE_LATEX         = NO\n\n# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: latex.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_OUTPUT           = latex\n\n# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be\n# invoked.\n#\n# Note that when enabling USE_PDFLATEX this option is only used for generating\n# bitmaps for formulas in the HTML output, but not in the Makefile that is\n# written to the output directory.\n# The default file is: latex.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_CMD_NAME         = latex\n\n# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate\n# index for LaTeX.\n# The default file is: makeindex.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nMAKEINDEX_CMD_NAME     = makeindex\n\n# If the COMPACT_LATEX tag is set to YES doxygen generates more compact LaTeX\n# documents. This may be useful for small projects and may help to save some\n# trees in general.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nCOMPACT_LATEX          = NO\n\n# The PAPER_TYPE tag can be used to set the paper type that is used by the\n# printer.\n# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x\n# 14 inches) and executive (7.25 x 10.5 inches).\n# The default value is: a4.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nPAPER_TYPE             = a4\n\n# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names\n# that should be included in the LaTeX output. To get the times font for\n# instance you can specify\n# EXTRA_PACKAGES=times\n# If left blank no extra packages will be included.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nEXTRA_PACKAGES         =\n\n# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the\n# generated LaTeX document. The header should contain everything until the first\n# chapter. If it is left blank doxygen will generate a standard header. See\n# section \"Doxygen usage\" for information on how to let doxygen write the\n# default header to a separate file.\n#\n# Note: Only use a user-defined header if you know what you are doing! The\n# following commands have a special meaning inside the header: $title,\n# $datetime, $date, $doxygenversion, $projectname, $projectnumber. Doxygen will\n# replace them by respectively the title of the page, the current date and time,\n# only the current date, the version number of doxygen, the project name (see\n# PROJECT_NAME), or the project number (see PROJECT_NUMBER).\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_HEADER           =\n\n# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the\n# generated LaTeX document. The footer should contain everything after the last\n# chapter. If it is left blank doxygen will generate a standard footer.\n#\n# Note: Only use a user-defined footer if you know what you are doing!\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_FOOTER           =\n\n# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or\n# other source files which should be copied to the LATEX_OUTPUT output\n# directory. Note that the files will be copied as-is; there are no commands or\n# markers available.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_EXTRA_FILES      =\n\n# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is\n# prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will\n# contain links (just like the HTML output) instead of page references. This\n# makes the output suitable for online browsing using a PDF viewer.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nPDF_HYPERLINKS         = YES\n\n# If the LATEX_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate\n# the PDF file directly from the LaTeX files. Set this option to YES to get a\n# higher quality PDF documentation.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nUSE_PDFLATEX           = YES\n\n# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode\n# command to the generated LaTeX files. This will instruct LaTeX to keep running\n# if errors occur, instead of asking the user for help. This option is also used\n# when generating formulas in HTML.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_BATCHMODE        = NO\n\n# If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the\n# index chapters (such as File Index, Compound Index, etc.) in the output.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_HIDE_INDICES     = NO\n\n# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source\n# code with syntax highlighting in the LaTeX output.\n#\n# Note that which sources are shown also depends on other settings such as\n# SOURCE_BROWSER.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_SOURCE_CODE      = NO\n\n# The LATEX_BIB_STYLE tag can be used to specify the style to use for the\n# bibliography, e.g. plainnat, or ieeetr. See\n# http://en.wikipedia.org/wiki/BibTeX and \\cite for more info.\n# The default value is: plain.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_BIB_STYLE        = plain\n\n#---------------------------------------------------------------------------\n# Configuration options related to the RTF output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_RTF tag is set to YES doxygen will generate RTF output. The\n# RTF output is optimized for Word 97 and may not look too pretty with other RTF\n# readers/editors.\n# The default value is: NO.\n\nGENERATE_RTF           = NO\n\n# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: rtf.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_OUTPUT             = rtf\n\n# If the COMPACT_RTF tag is set to YES doxygen generates more compact RTF\n# documents. This may be useful for small projects and may help to save some\n# trees in general.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nCOMPACT_RTF            = NO\n\n# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will\n# contain hyperlink fields. The RTF file will contain links (just like the HTML\n# output) instead of page references. This makes the output suitable for online\n# browsing using Word or some other Word compatible readers that support those\n# fields.\n#\n# Note: WordPad (write) and others do not support links.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_HYPERLINKS         = NO\n\n# Load stylesheet definitions from file. Syntax is similar to doxygen's config\n# file, i.e. a series of assignments. You only have to provide replacements,\n# missing definitions are set to their default value.\n#\n# See also section \"Doxygen usage\" for information on how to generate the\n# default style sheet that doxygen normally uses.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_STYLESHEET_FILE    =\n\n# Set optional variables used in the generation of an RTF document. Syntax is\n# similar to doxygen's config file. A template extensions file can be generated\n# using doxygen -e rtf extensionFile.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_EXTENSIONS_FILE    =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the man page output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_MAN tag is set to YES doxygen will generate man pages for\n# classes and files.\n# The default value is: NO.\n\nGENERATE_MAN           = NO\n\n# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it. A directory man3 will be created inside the directory specified by\n# MAN_OUTPUT.\n# The default directory is: man.\n# This tag requires that the tag GENERATE_MAN is set to YES.\n\nMAN_OUTPUT             = man\n\n# The MAN_EXTENSION tag determines the extension that is added to the generated\n# man pages. In case the manual section does not start with a number, the number\n# 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is\n# optional.\n# The default value is: .3.\n# This tag requires that the tag GENERATE_MAN is set to YES.\n\nMAN_EXTENSION          = .3\n\n# The MAN_SUBDIR tag determines the name of the directory created within\n# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by\n# MAN_EXTENSION with the initial . removed.\n# This tag requires that the tag GENERATE_MAN is set to YES.\n\nMAN_SUBDIR             =\n\n# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it\n# will generate one additional man file for each entity documented in the real\n# man page(s). These additional files only source the real man page, but without\n# them the man command would be unable to find the correct page.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_MAN is set to YES.\n\nMAN_LINKS              = NO\n\n#---------------------------------------------------------------------------\n# Configuration options related to the XML output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_XML tag is set to YES doxygen will generate an XML file that\n# captures the structure of the code including all documentation.\n# The default value is: NO.\n\nGENERATE_XML           = NO\n\n# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: xml.\n# This tag requires that the tag GENERATE_XML is set to YES.\n\nXML_OUTPUT             = xml\n\n# If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program\n# listings (including syntax highlighting and cross-referencing information) to\n# the XML output. Note that enabling this will significantly increase the size\n# of the XML output.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_XML is set to YES.\n\nXML_PROGRAMLISTING     = YES\n\n#---------------------------------------------------------------------------\n# Configuration options related to the DOCBOOK output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_DOCBOOK tag is set to YES doxygen will generate Docbook files\n# that can be used to generate PDF.\n# The default value is: NO.\n\nGENERATE_DOCBOOK       = NO\n\n# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put.\n# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in\n# front of it.\n# The default directory is: docbook.\n# This tag requires that the tag GENERATE_DOCBOOK is set to YES.\n\nDOCBOOK_OUTPUT         = docbook\n\n#---------------------------------------------------------------------------\n# Configuration options for the AutoGen Definitions output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_AUTOGEN_DEF tag is set to YES doxygen will generate an AutoGen\n# Definitions (see http://autogen.sf.net) file that captures the structure of\n# the code including all documentation. Note that this feature is still\n# experimental and incomplete at the moment.\n# The default value is: NO.\n\nGENERATE_AUTOGEN_DEF   = NO\n\n#---------------------------------------------------------------------------\n# Configuration options related to the Perl module output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_PERLMOD tag is set to YES doxygen will generate a Perl module\n# file that captures the structure of the code including all documentation.\n#\n# Note that this feature is still experimental and incomplete at the moment.\n# The default value is: NO.\n\nGENERATE_PERLMOD       = NO\n\n# If the PERLMOD_LATEX tag is set to YES doxygen will generate the necessary\n# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI\n# output from the Perl module output.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_PERLMOD is set to YES.\n\nPERLMOD_LATEX          = NO\n\n# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be nicely\n# formatted so it can be parsed by a human reader. This is useful if you want to\n# understand what is going on. On the other hand, if this tag is set to NO the\n# size of the Perl module output will be much smaller and Perl will parse it\n# just the same.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_PERLMOD is set to YES.\n\nPERLMOD_PRETTY         = YES\n\n# The names of the make variables in the generated doxyrules.make file are\n# prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful\n# so different doxyrules.make files included by the same Makefile don't\n# overwrite each other's variables.\n# This tag requires that the tag GENERATE_PERLMOD is set to YES.\n\nPERLMOD_MAKEVAR_PREFIX =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the preprocessor\n#---------------------------------------------------------------------------\n\n# If the ENABLE_PREPROCESSING tag is set to YES doxygen will evaluate all\n# C-preprocessor directives found in the sources and include files.\n# The default value is: YES.\n\nENABLE_PREPROCESSING   = YES\n\n# If the MACRO_EXPANSION tag is set to YES doxygen will expand all macro names\n# in the source code. If set to NO only conditional compilation will be\n# performed. Macro expansion can be done in a controlled way by setting\n# EXPAND_ONLY_PREDEF to YES.\n# The default value is: NO.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nMACRO_EXPANSION        = YES\n\n# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then\n# the macro expansion is limited to the macros specified with the PREDEFINED and\n# EXPAND_AS_DEFINED tags.\n# The default value is: NO.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nEXPAND_ONLY_PREDEF     = YES\n\n# If the SEARCH_INCLUDES tag is set to YES the includes files in the\n# INCLUDE_PATH will be searched if a #include is found.\n# The default value is: YES.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nSEARCH_INCLUDES        = YES\n\n# The INCLUDE_PATH tag can be used to specify one or more directories that\n# contain include files that are not input files but should be processed by the\n# preprocessor.\n# This tag requires that the tag SEARCH_INCLUDES is set to YES.\n\nINCLUDE_PATH           =\n\n# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard\n# patterns (like *.h and *.hpp) to filter out the header-files in the\n# directories. If left blank, the patterns specified with FILE_PATTERNS will be\n# used.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nINCLUDE_FILE_PATTERNS  =\n\n# The PREDEFINED tag can be used to specify one or more macro names that are\n# defined before the preprocessor is started (similar to the -D option of e.g.\n# gcc). The argument of the tag is a list of macros of the form: name or\n# name=definition (no spaces). If the definition and the \"=\" are omitted, \"=1\"\n# is assumed. To prevent a macro definition from being undefined via #undef or\n# recursively expanded use the := operator instead of the = operator.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nPREDEFINED             = \\\n\tRAPIDJSON_DOXYGEN_RUNNING \\\n\tRAPIDJSON_NAMESPACE_BEGIN=\"namespace rapidjson {\" \\\n\tRAPIDJSON_NAMESPACE_END=\"}\" \\\n\tRAPIDJSON_REMOVEFPTR_(x)=x \\\n\tRAPIDJSON_ENABLEIF_RETURN(cond,returntype)=\"RAPIDJSON_REMOVEFPTR_ returntype\" \\\n\tRAPIDJSON_DISABLEIF_RETURN(cond,returntype)=\"RAPIDJSON_REMOVEFPTR_ returntype\"\n\n# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this\n# tag can be used to specify a list of macro names that should be expanded. The\n# macro definition that is found in the sources will be used. Use the PREDEFINED\n# tag if you want to use a different macro definition that overrules the\n# definition found in the source code.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nEXPAND_AS_DEFINED      = \\\n\tRAPIDJSON_NOEXCEPT\n\n# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will\n# remove all references to function-like macros that are alone on a line, have\n# an all uppercase name, and do not end with a semicolon. Such function macros\n# are typically used for boiler-plate code, and will confuse the parser if not\n# removed.\n# The default value is: YES.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nSKIP_FUNCTION_MACROS   = YES\n\n#---------------------------------------------------------------------------\n# Configuration options related to external references\n#---------------------------------------------------------------------------\n\n# The TAGFILES tag can be used to specify one or more tag files. For each tag\n# file the location of the external documentation should be added. The format of\n# a tag file without this location is as follows:\n# TAGFILES = file1 file2 ...\n# Adding location for the tag files is done as follows:\n# TAGFILES = file1=loc1 \"file2 = loc2\" ...\n# where loc1 and loc2 can be relative or absolute paths or URLs. See the\n# section \"Linking to external documentation\" for more information about the use\n# of tag files.\n# Note: Each tag file must have a unique name (where the name does NOT include\n# the path). If a tag file is not located in the directory in which doxygen is\n# run, you must also specify the path to the tagfile here.\n\nTAGFILES               =\n\n# When a file name is specified after GENERATE_TAGFILE, doxygen will create a\n# tag file that is based on the input files it reads. See section \"Linking to\n# external documentation\" for more information about the usage of tag files.\n\nGENERATE_TAGFILE       =\n\n# If the ALLEXTERNALS tag is set to YES all external class will be listed in the\n# class index. If set to NO only the inherited external classes will be listed.\n# The default value is: NO.\n\nALLEXTERNALS           = NO\n\n# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed in\n# the modules index. If set to NO, only the current project's groups will be\n# listed.\n# The default value is: YES.\n\nEXTERNAL_GROUPS        = YES\n\n# If the EXTERNAL_PAGES tag is set to YES all external pages will be listed in\n# the related pages index. If set to NO, only the current project's pages will\n# be listed.\n# The default value is: YES.\n\nEXTERNAL_PAGES         = YES\n\n# The PERL_PATH should be the absolute path and name of the perl script\n# interpreter (i.e. the result of 'which perl').\n# The default file (with absolute path) is: /usr/bin/perl.\n\nPERL_PATH              = /usr/bin/perl\n\n#---------------------------------------------------------------------------\n# Configuration options related to the dot tool\n#---------------------------------------------------------------------------\n\n# If the CLASS_DIAGRAMS tag is set to YES doxygen will generate a class diagram\n# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to\n# NO turns the diagrams off. Note that this option also works with HAVE_DOT\n# disabled, but it is recommended to install and use dot, since it yields more\n# powerful graphs.\n# The default value is: YES.\n\nCLASS_DIAGRAMS         = YES\n\n# You can define message sequence charts within doxygen comments using the \\msc\n# command. Doxygen will then run the mscgen tool (see:\n# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the\n# documentation. The MSCGEN_PATH tag allows you to specify the directory where\n# the mscgen tool resides. If left empty the tool is assumed to be found in the\n# default search path.\n\nMSCGEN_PATH            =\n\n# You can include diagrams made with dia in doxygen documentation. Doxygen will\n# then run dia to produce the diagram and insert it in the documentation. The\n# DIA_PATH tag allows you to specify the directory where the dia binary resides.\n# If left empty dia is assumed to be found in the default search path.\n\nDIA_PATH               =\n\n# If set to YES, the inheritance and collaboration graphs will hide inheritance\n# and usage relations if the target is undocumented or is not a class.\n# The default value is: YES.\n\nHIDE_UNDOC_RELATIONS   = YES\n\n# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is\n# available from the path. This tool is part of Graphviz (see:\n# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent\n# Bell Labs. The other options in this section have no effect if this option is\n# set to NO\n# The default value is: NO.\n\nHAVE_DOT               = NO\n\n# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed\n# to run in parallel. When set to 0 doxygen will base this on the number of\n# processors available in the system. You can set it explicitly to a value\n# larger than 0 to get control over the balance between CPU load and processing\n# speed.\n# Minimum value: 0, maximum value: 32, default value: 0.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_NUM_THREADS        = 0\n\n# When you want a differently looking font n the dot files that doxygen\n# generates you can specify the font name using DOT_FONTNAME. You need to make\n# sure dot is able to find the font, which can be done by putting it in a\n# standard location or by setting the DOTFONTPATH environment variable or by\n# setting DOT_FONTPATH to the directory containing the font.\n# The default value is: Helvetica.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_FONTNAME           = Helvetica\n\n# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of\n# dot graphs.\n# Minimum value: 4, maximum value: 24, default value: 10.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_FONTSIZE           = 10\n\n# By default doxygen will tell dot to use the default font as specified with\n# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set\n# the path where dot can find it using this tag.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_FONTPATH           =\n\n# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for\n# each documented class showing the direct and indirect inheritance relations.\n# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCLASS_GRAPH            = YES\n\n# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a\n# graph for each documented class showing the direct and indirect implementation\n# dependencies (inheritance, containment, and class references variables) of the\n# class with other documented classes.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCOLLABORATION_GRAPH    = YES\n\n# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for\n# groups, showing the direct groups dependencies.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nGROUP_GRAPHS           = YES\n\n# If the UML_LOOK tag is set to YES doxygen will generate inheritance and\n# collaboration diagrams in a style similar to the OMG's Unified Modeling\n# Language.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nUML_LOOK               = NO\n\n# If the UML_LOOK tag is enabled, the fields and methods are shown inside the\n# class node. If there are many fields or methods and many nodes the graph may\n# become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the\n# number of items for each type to make the size more manageable. Set this to 0\n# for no limit. Note that the threshold may be exceeded by 50% before the limit\n# is enforced. So when you set the threshold to 10, up to 15 fields may appear,\n# but if the number exceeds 15, the total amount of fields shown is limited to\n# 10.\n# Minimum value: 0, maximum value: 100, default value: 10.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nUML_LIMIT_NUM_FIELDS   = 10\n\n# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and\n# collaboration graphs will show the relations between templates and their\n# instances.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nTEMPLATE_RELATIONS     = NO\n\n# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to\n# YES then doxygen will generate a graph for each documented file showing the\n# direct and indirect include dependencies of the file with other documented\n# files.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nINCLUDE_GRAPH          = YES\n\n# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are\n# set to YES then doxygen will generate a graph for each documented file showing\n# the direct and indirect include dependencies of the file with other documented\n# files.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nINCLUDED_BY_GRAPH      = YES\n\n# If the CALL_GRAPH tag is set to YES then doxygen will generate a call\n# dependency graph for every global function or class method.\n#\n# Note that enabling this option will significantly increase the time of a run.\n# So in most cases it will be better to enable call graphs for selected\n# functions only using the \\callgraph command.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCALL_GRAPH             = NO\n\n# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller\n# dependency graph for every global function or class method.\n#\n# Note that enabling this option will significantly increase the time of a run.\n# So in most cases it will be better to enable caller graphs for selected\n# functions only using the \\callergraph command.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCALLER_GRAPH           = NO\n\n# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical\n# hierarchy of all classes instead of a textual one.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nGRAPHICAL_HIERARCHY    = YES\n\n# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the\n# dependencies a directory has on other directories in a graphical way. The\n# dependency relations are determined by the #include relations between the\n# files in the directories.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDIRECTORY_GRAPH        = YES\n\n# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images\n# generated by dot.\n# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order\n# to make the SVG files visible in IE 9+ (other browsers do not have this\n# requirement).\n# Possible values are: png, jpg, gif and svg.\n# The default value is: png.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_IMAGE_FORMAT       = png\n\n# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to\n# enable generation of interactive SVG images that allow zooming and panning.\n#\n# Note that this requires a modern browser other than Internet Explorer. Tested\n# and working are Firefox, Chrome, Safari, and Opera.\n# Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make\n# the SVG files visible. Older versions of IE do not have SVG support.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nINTERACTIVE_SVG        = NO\n\n# The DOT_PATH tag can be used to specify the path where the dot tool can be\n# found. If left blank, it is assumed the dot tool can be found in the path.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_PATH               =\n\n# The DOTFILE_DIRS tag can be used to specify one or more directories that\n# contain dot files that are included in the documentation (see the \\dotfile\n# command).\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOTFILE_DIRS           =\n\n# The MSCFILE_DIRS tag can be used to specify one or more directories that\n# contain msc files that are included in the documentation (see the \\mscfile\n# command).\n\nMSCFILE_DIRS           =\n\n# The DIAFILE_DIRS tag can be used to specify one or more directories that\n# contain dia files that are included in the documentation (see the \\diafile\n# command).\n\nDIAFILE_DIRS           =\n\n# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes\n# that will be shown in the graph. If the number of nodes in a graph becomes\n# larger than this value, doxygen will truncate the graph, which is visualized\n# by representing a node as a red box. Note that doxygen if the number of direct\n# children of the root node in a graph is already larger than\n# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that\n# the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.\n# Minimum value: 0, maximum value: 10000, default value: 50.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_GRAPH_MAX_NODES    = 50\n\n# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs\n# generated by dot. A depth value of 3 means that only nodes reachable from the\n# root by following a path via at most 3 edges will be shown. Nodes that lay\n# further from the root node will be omitted. Note that setting this option to 1\n# or 2 may greatly reduce the computation time needed for large code bases. Also\n# note that the size of a graph can be further restricted by\n# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.\n# Minimum value: 0, maximum value: 1000, default value: 0.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nMAX_DOT_GRAPH_DEPTH    = 0\n\n# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent\n# background. This is disabled by default, because dot on Windows does not seem\n# to support this out of the box.\n#\n# Warning: Depending on the platform used, enabling this option may lead to\n# badly anti-aliased labels on the edges of a graph (i.e. they become hard to\n# read).\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_TRANSPARENT        = NO\n\n# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output\n# files in one run (i.e. multiple -o and -T options on the command line). This\n# makes dot run faster, but since only newer versions of dot (>1.8.10) support\n# this, this feature is disabled by default.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_MULTI_TARGETS      = NO\n\n# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page\n# explaining the meaning of the various boxes and arrows in the dot generated\n# graphs.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nGENERATE_LEGEND        = YES\n\n# If the DOT_CLEANUP tag is set to YES doxygen will remove the intermediate dot\n# files that are used to generate the various graphs.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_CLEANUP            = YES\n"
  },
  {
    "path": "ext/rapidjson/doc/Doxyfile.zh-cn.in",
    "content": "# Doxyfile 1.8.7\n\n# This file describes the settings to be used by the documentation system\n# doxygen (www.doxygen.org) for a project.\n#\n# All text after a double hash (##) is considered a comment and is placed in\n# front of the TAG it is preceding.\n#\n# All text after a single hash (#) is considered a comment and will be ignored.\n# The format is:\n# TAG = value [value, ...]\n# For lists, items can also be appended using:\n# TAG += value [value, ...]\n# Values that contain spaces should be placed between quotes (\\\" \\\").\n\n#---------------------------------------------------------------------------\n# Project related configuration options\n#---------------------------------------------------------------------------\n\n# This tag specifies the encoding used for all characters in the config file\n# that follow. The default is UTF-8 which is also the encoding used for all text\n# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv\n# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv\n# for the list of possible encodings.\n# The default value is: UTF-8.\n\nDOXYFILE_ENCODING      = UTF-8\n\n# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by\n# double-quotes, unless you are using Doxywizard) that should identify the\n# project for which the documentation is generated. This name is used in the\n# title of most generated pages and in a few other places.\n# The default value is: My Project.\n\nPROJECT_NAME           = RapidJSON\n\n# The PROJECT_NUMBER tag can be used to enter a project or revision number. This\n# could be handy for archiving the generated documentation or if some version\n# control system is used.\n\nPROJECT_NUMBER         =\n\n# Using the PROJECT_BRIEF tag one can provide an optional one line description\n# for a project that appears at the top of each page and should give viewer a\n# quick idea about the purpose of the project. Keep the description short.\n\nPROJECT_BRIEF          = \"一个C++快速JSON解析器及生成器，包含SAX/DOM风格API\"\n\n# With the PROJECT_LOGO tag one can specify an logo or icon that is included in\n# the documentation. The maximum height of the logo should not exceed 55 pixels\n# and the maximum width should not exceed 200 pixels. Doxygen will copy the logo\n# to the output directory.\n\nPROJECT_LOGO           =\n\n# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path\n# into which the generated documentation will be written. If a relative path is\n# entered, it will be relative to the location where doxygen was started. If\n# left blank the current directory will be used.\n\nOUTPUT_DIRECTORY       = @CMAKE_CURRENT_BINARY_DIR@\n\n# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub-\n# directories (in 2 levels) under the output directory of each output format and\n# will distribute the generated files over these directories. Enabling this\n# option can be useful when feeding doxygen a huge amount of source files, where\n# putting all generated files in the same directory would otherwise causes\n# performance problems for the file system.\n# The default value is: NO.\n\nCREATE_SUBDIRS         = NO\n\n# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII\n# characters to appear in the names of generated files. If set to NO, non-ASCII\n# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode\n# U+3044.\n# The default value is: NO.\n\nALLOW_UNICODE_NAMES    = NO\n\n# The OUTPUT_LANGUAGE tag is used to specify the language in which all\n# documentation generated by doxygen is written. Doxygen will use this\n# information to generate all constant output in the proper language.\n# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese,\n# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States),\n# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian,\n# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages),\n# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian,\n# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian,\n# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish,\n# Ukrainian and Vietnamese.\n# The default value is: English.\n\nOUTPUT_LANGUAGE        = Chinese\n\n# If the BRIEF_MEMBER_DESC tag is set to YES doxygen will include brief member\n# descriptions after the members that are listed in the file and class\n# documentation (similar to Javadoc). Set to NO to disable this.\n# The default value is: YES.\n\nBRIEF_MEMBER_DESC      = YES\n\n# If the REPEAT_BRIEF tag is set to YES doxygen will prepend the brief\n# description of a member or function before the detailed description\n#\n# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the\n# brief descriptions will be completely suppressed.\n# The default value is: YES.\n\nREPEAT_BRIEF           = YES\n\n# This tag implements a quasi-intelligent brief description abbreviator that is\n# used to form the text in various listings. Each string in this list, if found\n# as the leading text of the brief description, will be stripped from the text\n# and the result, after processing the whole list, is used as the annotated\n# text. Otherwise, the brief description is used as-is. If left blank, the\n# following values are used ($name is automatically replaced with the name of\n# the entity):The $name class, The $name widget, The $name file, is, provides,\n# specifies, contains, represents, a, an and the.\n\nABBREVIATE_BRIEF       = \"The $name class\" \\\n                         \"The $name widget\" \\\n                         \"The $name file\" \\\n                         is \\\n                         provides \\\n                         specifies \\\n                         contains \\\n                         represents \\\n                         a \\\n                         an \\\n                         the\n\n# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then\n# doxygen will generate a detailed section even if there is only a brief\n# description.\n# The default value is: NO.\n\nALWAYS_DETAILED_SEC    = NO\n\n# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all\n# inherited members of a class in the documentation of that class as if those\n# members were ordinary class members. Constructors, destructors and assignment\n# operators of the base classes will not be shown.\n# The default value is: NO.\n\nINLINE_INHERITED_MEMB  = NO\n\n# If the FULL_PATH_NAMES tag is set to YES doxygen will prepend the full path\n# before files name in the file list and in the header files. If set to NO the\n# shortest path that makes the file name unique will be used\n# The default value is: YES.\n\nFULL_PATH_NAMES        = YES\n\n# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.\n# Stripping is only done if one of the specified strings matches the left-hand\n# part of the path. The tag can be used to show relative paths in the file list.\n# If left blank the directory from which doxygen is run is used as the path to\n# strip.\n#\n# Note that you can specify absolute paths here, but also relative paths, which\n# will be relative from the directory where doxygen is started.\n# This tag requires that the tag FULL_PATH_NAMES is set to YES.\n\nSTRIP_FROM_PATH        =\n\n# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the\n# path mentioned in the documentation of a class, which tells the reader which\n# header file to include in order to use a class. If left blank only the name of\n# the header file containing the class definition is used. Otherwise one should\n# specify the list of include paths that are normally passed to the compiler\n# using the -I flag.\n\nSTRIP_FROM_INC_PATH    =\n\n# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but\n# less readable) file names. This can be useful is your file systems doesn't\n# support long names like on DOS, Mac, or CD-ROM.\n# The default value is: NO.\n\nSHORT_NAMES            = NO\n\n# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the\n# first line (until the first dot) of a Javadoc-style comment as the brief\n# description. If set to NO, the Javadoc-style will behave just like regular Qt-\n# style comments (thus requiring an explicit @brief command for a brief\n# description.)\n# The default value is: NO.\n\nJAVADOC_AUTOBRIEF      = NO\n\n# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first\n# line (until the first dot) of a Qt-style comment as the brief description. If\n# set to NO, the Qt-style will behave just like regular Qt-style comments (thus\n# requiring an explicit \\brief command for a brief description.)\n# The default value is: NO.\n\nQT_AUTOBRIEF           = NO\n\n# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a\n# multi-line C++ special comment block (i.e. a block of //! or /// comments) as\n# a brief description. This used to be the default behavior. The new default is\n# to treat a multi-line C++ comment block as a detailed description. Set this\n# tag to YES if you prefer the old behavior instead.\n#\n# Note that setting this tag to YES also means that rational rose comments are\n# not recognized any more.\n# The default value is: NO.\n\nMULTILINE_CPP_IS_BRIEF = NO\n\n# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the\n# documentation from any documented member that it re-implements.\n# The default value is: YES.\n\nINHERIT_DOCS           = YES\n\n# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce a\n# new page for each member. If set to NO, the documentation of a member will be\n# part of the file/class/namespace that contains it.\n# The default value is: NO.\n\nSEPARATE_MEMBER_PAGES  = NO\n\n# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen\n# uses this value to replace tabs by spaces in code fragments.\n# Minimum value: 1, maximum value: 16, default value: 4.\n\nTAB_SIZE               = 4\n\n# This tag can be used to specify a number of aliases that act as commands in\n# the documentation. An alias has the form:\n# name=value\n# For example adding\n# \"sideeffect=@par Side Effects:\\n\"\n# will allow you to put the command \\sideeffect (or @sideeffect) in the\n# documentation, which will result in a user-defined paragraph with heading\n# \"Side Effects:\". You can put \\n's in the value part of an alias to insert\n# newlines.\n\nALIASES                =\n\n# This tag can be used to specify a number of word-keyword mappings (TCL only).\n# A mapping has the form \"name=value\". For example adding \"class=itcl::class\"\n# will allow you to use the command class in the itcl::class meaning.\n\nTCL_SUBST              =\n\n# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources\n# only. Doxygen will then generate output that is more tailored for C. For\n# instance, some of the names that are used will be different. The list of all\n# members will be omitted, etc.\n# The default value is: NO.\n\nOPTIMIZE_OUTPUT_FOR_C  = NO\n\n# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or\n# Python sources only. Doxygen will then generate output that is more tailored\n# for that language. For instance, namespaces will be presented as packages,\n# qualified scopes will look different, etc.\n# The default value is: NO.\n\nOPTIMIZE_OUTPUT_JAVA   = NO\n\n# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran\n# sources. Doxygen will then generate output that is tailored for Fortran.\n# The default value is: NO.\n\nOPTIMIZE_FOR_FORTRAN   = NO\n\n# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL\n# sources. Doxygen will then generate output that is tailored for VHDL.\n# The default value is: NO.\n\nOPTIMIZE_OUTPUT_VHDL   = NO\n\n# Doxygen selects the parser to use depending on the extension of the files it\n# parses. With this tag you can assign which parser to use for a given\n# extension. Doxygen has a built-in mapping, but you can override or extend it\n# using this tag. The format is ext=language, where ext is a file extension, and\n# language is one of the parsers supported by doxygen: IDL, Java, Javascript,\n# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran:\n# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran:\n# Fortran. In the later case the parser tries to guess whether the code is fixed\n# or free formatted code, this is the default for Fortran type files), VHDL. For\n# instance to make doxygen treat .inc files as Fortran files (default is PHP),\n# and .f files as C (default is Fortran), use: inc=Fortran f=C.\n#\n# Note For files without extension you can use no_extension as a placeholder.\n#\n# Note that for custom extensions you also need to set FILE_PATTERNS otherwise\n# the files are not read by doxygen.\n\nEXTENSION_MAPPING      =\n\n# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments\n# according to the Markdown format, which allows for more readable\n# documentation. See http://daringfireball.net/projects/markdown/ for details.\n# The output of markdown processing is further processed by doxygen, so you can\n# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in\n# case of backward compatibilities issues.\n# The default value is: YES.\n\nMARKDOWN_SUPPORT       = YES\n\n# When enabled doxygen tries to link words that correspond to documented\n# classes, or namespaces to their corresponding documentation. Such a link can\n# be prevented in individual cases by by putting a % sign in front of the word\n# or globally by setting AUTOLINK_SUPPORT to NO.\n# The default value is: YES.\n\nAUTOLINK_SUPPORT       = YES\n\n# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want\n# to include (a tag file for) the STL sources as input, then you should set this\n# tag to YES in order to let doxygen match functions declarations and\n# definitions whose arguments contain STL classes (e.g. func(std::string);\n# versus func(std::string) {}). This also make the inheritance and collaboration\n# diagrams that involve STL classes more complete and accurate.\n# The default value is: NO.\n\nBUILTIN_STL_SUPPORT    = NO\n\n# If you use Microsoft's C++/CLI language, you should set this option to YES to\n# enable parsing support.\n# The default value is: NO.\n\nCPP_CLI_SUPPORT        = NO\n\n# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:\n# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen\n# will parse them like normal C++ but will assume all classes use public instead\n# of private inheritance when no explicit protection keyword is present.\n# The default value is: NO.\n\nSIP_SUPPORT            = NO\n\n# For Microsoft's IDL there are propget and propput attributes to indicate\n# getter and setter methods for a property. Setting this option to YES will make\n# doxygen to replace the get and set methods by a property in the documentation.\n# This will only work if the methods are indeed getting or setting a simple\n# type. If this is not the case, or you want to show the methods anyway, you\n# should set this option to NO.\n# The default value is: YES.\n\nIDL_PROPERTY_SUPPORT   = YES\n\n# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC\n# tag is set to YES, then doxygen will reuse the documentation of the first\n# member in the group (if any) for the other members of the group. By default\n# all members of a group must be documented explicitly.\n# The default value is: NO.\n\nDISTRIBUTE_GROUP_DOC   = NO\n\n# Set the SUBGROUPING tag to YES to allow class member groups of the same type\n# (for instance a group of public functions) to be put as a subgroup of that\n# type (e.g. under the Public Functions section). Set it to NO to prevent\n# subgrouping. Alternatively, this can be done per class using the\n# \\nosubgrouping command.\n# The default value is: YES.\n\nSUBGROUPING            = YES\n\n# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions\n# are shown inside the group in which they are included (e.g. using \\ingroup)\n# instead of on a separate page (for HTML and Man pages) or section (for LaTeX\n# and RTF).\n#\n# Note that this feature does not work in combination with\n# SEPARATE_MEMBER_PAGES.\n# The default value is: NO.\n\nINLINE_GROUPED_CLASSES = YES\n\n# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions\n# with only public data fields or simple typedef fields will be shown inline in\n# the documentation of the scope in which they are defined (i.e. file,\n# namespace, or group documentation), provided this scope is documented. If set\n# to NO, structs, classes, and unions are shown on a separate page (for HTML and\n# Man pages) or section (for LaTeX and RTF).\n# The default value is: NO.\n\nINLINE_SIMPLE_STRUCTS  = NO\n\n# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or\n# enum is documented as struct, union, or enum with the name of the typedef. So\n# typedef struct TypeS {} TypeT, will appear in the documentation as a struct\n# with name TypeT. When disabled the typedef will appear as a member of a file,\n# namespace, or class. And the struct will be named TypeS. This can typically be\n# useful for C code in case the coding convention dictates that all compound\n# types are typedef'ed and only the typedef is referenced, never the tag name.\n# The default value is: NO.\n\nTYPEDEF_HIDES_STRUCT   = NO\n\n# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This\n# cache is used to resolve symbols given their name and scope. Since this can be\n# an expensive process and often the same symbol appears multiple times in the\n# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small\n# doxygen will become slower. If the cache is too large, memory is wasted. The\n# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range\n# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536\n# symbols. At the end of a run doxygen will report the cache usage and suggest\n# the optimal cache size from a speed point of view.\n# Minimum value: 0, maximum value: 9, default value: 0.\n\nLOOKUP_CACHE_SIZE      = 0\n\n#---------------------------------------------------------------------------\n# Build related configuration options\n#---------------------------------------------------------------------------\n\n# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in\n# documentation are documented, even if no documentation was available. Private\n# class members and static file members will be hidden unless the\n# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES.\n# Note: This will also disable the warnings about undocumented members that are\n# normally produced when WARNINGS is set to YES.\n# The default value is: NO.\n\nEXTRACT_ALL            = NO\n\n# If the EXTRACT_PRIVATE tag is set to YES all private members of a class will\n# be included in the documentation.\n# The default value is: NO.\n\nEXTRACT_PRIVATE        = NO\n\n# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal\n# scope will be included in the documentation.\n# The default value is: NO.\n\nEXTRACT_PACKAGE        = NO\n\n# If the EXTRACT_STATIC tag is set to YES all static members of a file will be\n# included in the documentation.\n# The default value is: NO.\n\nEXTRACT_STATIC         = NO\n\n# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) defined\n# locally in source files will be included in the documentation. If set to NO\n# only classes defined in header files are included. Does not have any effect\n# for Java sources.\n# The default value is: YES.\n\nEXTRACT_LOCAL_CLASSES  = YES\n\n# This flag is only useful for Objective-C code. When set to YES local methods,\n# which are defined in the implementation section but not in the interface are\n# included in the documentation. If set to NO only methods in the interface are\n# included.\n# The default value is: NO.\n\nEXTRACT_LOCAL_METHODS  = NO\n\n# If this flag is set to YES, the members of anonymous namespaces will be\n# extracted and appear in the documentation as a namespace called\n# 'anonymous_namespace{file}', where file will be replaced with the base name of\n# the file that contains the anonymous namespace. By default anonymous namespace\n# are hidden.\n# The default value is: NO.\n\nEXTRACT_ANON_NSPACES   = NO\n\n# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all\n# undocumented members inside documented classes or files. If set to NO these\n# members will be included in the various overviews, but no documentation\n# section is generated. This option has no effect if EXTRACT_ALL is enabled.\n# The default value is: NO.\n\nHIDE_UNDOC_MEMBERS     = NO\n\n# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all\n# undocumented classes that are normally visible in the class hierarchy. If set\n# to NO these classes will be included in the various overviews. This option has\n# no effect if EXTRACT_ALL is enabled.\n# The default value is: NO.\n\nHIDE_UNDOC_CLASSES     = NO\n\n# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend\n# (class|struct|union) declarations. If set to NO these declarations will be\n# included in the documentation.\n# The default value is: NO.\n\nHIDE_FRIEND_COMPOUNDS  = NO\n\n# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any\n# documentation blocks found inside the body of a function. If set to NO these\n# blocks will be appended to the function's detailed documentation block.\n# The default value is: NO.\n\nHIDE_IN_BODY_DOCS      = NO\n\n# The INTERNAL_DOCS tag determines if documentation that is typed after a\n# \\internal command is included. If the tag is set to NO then the documentation\n# will be excluded. Set it to YES to include the internal documentation.\n# The default value is: NO.\n\nINTERNAL_DOCS          = NO\n\n# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file\n# names in lower-case letters. If set to YES upper-case letters are also\n# allowed. This is useful if you have classes or files whose names only differ\n# in case and if your file system supports case sensitive file names. Windows\n# and Mac users are advised to set this option to NO.\n# The default value is: system dependent.\n\nCASE_SENSE_NAMES       = NO\n\n# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with\n# their full class and namespace scopes in the documentation. If set to YES the\n# scope will be hidden.\n# The default value is: NO.\n\nHIDE_SCOPE_NAMES       = NO\n\n# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of\n# the files that are included by a file in the documentation of that file.\n# The default value is: YES.\n\nSHOW_INCLUDE_FILES     = YES\n\n# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each\n# grouped member an include statement to the documentation, telling the reader\n# which file to include in order to use the member.\n# The default value is: NO.\n\nSHOW_GROUPED_MEMB_INC  = NO\n\n# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include\n# files with double quotes in the documentation rather than with sharp brackets.\n# The default value is: NO.\n\nFORCE_LOCAL_INCLUDES   = NO\n\n# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the\n# documentation for inline members.\n# The default value is: YES.\n\nINLINE_INFO            = YES\n\n# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the\n# (detailed) documentation of file and class members alphabetically by member\n# name. If set to NO the members will appear in declaration order.\n# The default value is: YES.\n\nSORT_MEMBER_DOCS       = YES\n\n# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief\n# descriptions of file, namespace and class members alphabetically by member\n# name. If set to NO the members will appear in declaration order. Note that\n# this will also influence the order of the classes in the class list.\n# The default value is: NO.\n\nSORT_BRIEF_DOCS        = NO\n\n# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the\n# (brief and detailed) documentation of class members so that constructors and\n# destructors are listed first. If set to NO the constructors will appear in the\n# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS.\n# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief\n# member documentation.\n# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting\n# detailed member documentation.\n# The default value is: NO.\n\nSORT_MEMBERS_CTORS_1ST = NO\n\n# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy\n# of group names into alphabetical order. If set to NO the group names will\n# appear in their defined order.\n# The default value is: NO.\n\nSORT_GROUP_NAMES       = NO\n\n# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by\n# fully-qualified names, including namespaces. If set to NO, the class list will\n# be sorted only by class name, not including the namespace part.\n# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.\n# Note: This option applies only to the class list, not to the alphabetical\n# list.\n# The default value is: NO.\n\nSORT_BY_SCOPE_NAME     = NO\n\n# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper\n# type resolution of all parameters of a function it will reject a match between\n# the prototype and the implementation of a member function even if there is\n# only one candidate or it is obvious which candidate to choose by doing a\n# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still\n# accept a match between prototype and implementation in such cases.\n# The default value is: NO.\n\nSTRICT_PROTO_MATCHING  = NO\n\n# The GENERATE_TODOLIST tag can be used to enable ( YES) or disable ( NO) the\n# todo list. This list is created by putting \\todo commands in the\n# documentation.\n# The default value is: YES.\n\nGENERATE_TODOLIST      = YES\n\n# The GENERATE_TESTLIST tag can be used to enable ( YES) or disable ( NO) the\n# test list. This list is created by putting \\test commands in the\n# documentation.\n# The default value is: YES.\n\nGENERATE_TESTLIST      = YES\n\n# The GENERATE_BUGLIST tag can be used to enable ( YES) or disable ( NO) the bug\n# list. This list is created by putting \\bug commands in the documentation.\n# The default value is: YES.\n\nGENERATE_BUGLIST       = YES\n\n# The GENERATE_DEPRECATEDLIST tag can be used to enable ( YES) or disable ( NO)\n# the deprecated list. This list is created by putting \\deprecated commands in\n# the documentation.\n# The default value is: YES.\n\nGENERATE_DEPRECATEDLIST= YES\n\n# The ENABLED_SECTIONS tag can be used to enable conditional documentation\n# sections, marked by \\if <section_label> ... \\endif and \\cond <section_label>\n# ... \\endcond blocks.\n\nENABLED_SECTIONS       = $(RAPIDJSON_SECTIONS)\n\n# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the\n# initial value of a variable or macro / define can have for it to appear in the\n# documentation. If the initializer consists of more lines than specified here\n# it will be hidden. Use a value of 0 to hide initializers completely. The\n# appearance of the value of individual variables and macros / defines can be\n# controlled using \\showinitializer or \\hideinitializer command in the\n# documentation regardless of this setting.\n# Minimum value: 0, maximum value: 10000, default value: 30.\n\nMAX_INITIALIZER_LINES  = 30\n\n# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at\n# the bottom of the documentation of classes and structs. If set to YES the list\n# will mention the files that were used to generate the documentation.\n# The default value is: YES.\n\nSHOW_USED_FILES        = YES\n\n# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This\n# will remove the Files entry from the Quick Index and from the Folder Tree View\n# (if specified).\n# The default value is: YES.\n\nSHOW_FILES             = YES\n\n# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces\n# page. This will remove the Namespaces entry from the Quick Index and from the\n# Folder Tree View (if specified).\n# The default value is: YES.\n\nSHOW_NAMESPACES        = NO\n\n# The FILE_VERSION_FILTER tag can be used to specify a program or script that\n# doxygen should invoke to get the current version for each file (typically from\n# the version control system). Doxygen will invoke the program by executing (via\n# popen()) the command command input-file, where command is the value of the\n# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided\n# by doxygen. Whatever the program writes to standard output is used as the file\n# version. For an example see the documentation.\n\nFILE_VERSION_FILTER    =\n\n# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed\n# by doxygen. The layout file controls the global structure of the generated\n# output files in an output format independent way. To create the layout file\n# that represents doxygen's defaults, run doxygen with the -l option. You can\n# optionally specify a file name after the option, if omitted DoxygenLayout.xml\n# will be used as the name of the layout file.\n#\n# Note that if you run doxygen from a directory containing a file called\n# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE\n# tag is left empty.\n\nLAYOUT_FILE            =\n\n# The CITE_BIB_FILES tag can be used to specify one or more bib files containing\n# the reference definitions. This must be a list of .bib files. The .bib\n# extension is automatically appended if omitted. This requires the bibtex tool\n# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info.\n# For LaTeX the style of the bibliography can be controlled using\n# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the\n# search path. Do not use file names with spaces, bibtex cannot handle them. See\n# also \\cite for info how to create references.\n\nCITE_BIB_FILES         =\n\n#---------------------------------------------------------------------------\n# Configuration options related to warning and progress messages\n#---------------------------------------------------------------------------\n\n# The QUIET tag can be used to turn on/off the messages that are generated to\n# standard output by doxygen. If QUIET is set to YES this implies that the\n# messages are off.\n# The default value is: NO.\n\nQUIET                  = NO\n\n# The WARNINGS tag can be used to turn on/off the warning messages that are\n# generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES\n# this implies that the warnings are on.\n#\n# Tip: Turn warnings on while writing the documentation.\n# The default value is: YES.\n\nWARNINGS               = YES\n\n# If the WARN_IF_UNDOCUMENTED tag is set to YES, then doxygen will generate\n# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag\n# will automatically be disabled.\n# The default value is: YES.\n\nWARN_IF_UNDOCUMENTED   = YES\n\n# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for\n# potential errors in the documentation, such as not documenting some parameters\n# in a documented function, or documenting parameters that don't exist or using\n# markup commands wrongly.\n# The default value is: YES.\n\nWARN_IF_DOC_ERROR      = YES\n\n# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that\n# are documented, but have no documentation for their parameters or return\n# value. If set to NO doxygen will only warn about wrong or incomplete parameter\n# documentation, but not about the absence of documentation.\n# The default value is: NO.\n\nWARN_NO_PARAMDOC       = NO\n\n# The WARN_FORMAT tag determines the format of the warning messages that doxygen\n# can produce. The string should contain the $file, $line, and $text tags, which\n# will be replaced by the file and line number from which the warning originated\n# and the warning text. Optionally the format may contain $version, which will\n# be replaced by the version of the file (if it could be obtained via\n# FILE_VERSION_FILTER)\n# The default value is: $file:$line: $text.\n\nWARN_FORMAT            = \"$file:$line: $text\"\n\n# The WARN_LOGFILE tag can be used to specify a file to which warning and error\n# messages should be written. If left blank the output is written to standard\n# error (stderr).\n\nWARN_LOGFILE           =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the input files\n#---------------------------------------------------------------------------\n\n# The INPUT tag is used to specify the files and/or directories that contain\n# documented source files. You may enter file names like myfile.cpp or\n# directories like /usr/src/myproject. Separate the files or directories with\n# spaces.\n# Note: If this tag is empty the current directory is searched.\n\nINPUT                  = readme.zh-cn.md \\\n                         CHANGELOG.md \\\n                         include/rapidjson/rapidjson.h \\\n                         include/ \\\n                         doc/features.zh-cn.md \\\n                         doc/tutorial.zh-cn.md \\\n                         doc/pointer.zh-cn.md \\\n                         doc/stream.zh-cn.md \\\n                         doc/encoding.zh-cn.md \\\n                         doc/dom.zh-cn.md \\\n                         doc/sax.zh-cn.md \\\n                         doc/schema.zh-cn.md \\\n                         doc/performance.zh-cn.md \\\n                         doc/internals.md \\\n                         doc/faq.zh-cn.md\n\n# This tag can be used to specify the character encoding of the source files\n# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses\n# libiconv (or the iconv built into libc) for the transcoding. See the libiconv\n# documentation (see: http://www.gnu.org/software/libiconv) for the list of\n# possible encodings.\n# The default value is: UTF-8.\n\nINPUT_ENCODING         = UTF-8\n\n# If the value of the INPUT tag contains directories, you can use the\n# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and\n# *.h) to filter out the source-files in the directories. If left blank the\n# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii,\n# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp,\n# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown,\n# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf,\n# *.qsf, *.as and *.js.\n\nFILE_PATTERNS          = *.c \\\n                         *.cc \\\n                         *.cxx \\\n                         *.cpp \\\n                         *.h \\\n                         *.hh \\\n                         *.hxx \\\n                         *.hpp \\\n                         *.inc \\\n                         *.md\n\n# The RECURSIVE tag can be used to specify whether or not subdirectories should\n# be searched for input files as well.\n# The default value is: NO.\n\nRECURSIVE              = YES\n\n# The EXCLUDE tag can be used to specify files and/or directories that should be\n# excluded from the INPUT source files. This way you can easily exclude a\n# subdirectory from a directory tree whose root is specified with the INPUT tag.\n#\n# Note that relative paths are relative to the directory from which doxygen is\n# run.\n\nEXCLUDE                = ./include/rapidjson/msinttypes/\n\n# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or\n# directories that are symbolic links (a Unix file system feature) are excluded\n# from the input.\n# The default value is: NO.\n\nEXCLUDE_SYMLINKS       = NO\n\n# If the value of the INPUT tag contains directories, you can use the\n# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude\n# certain files from those directories.\n#\n# Note that the wildcards are matched against the file with absolute path, so to\n# exclude all test directories for example use the pattern */test/*\n\nEXCLUDE_PATTERNS       =\n\n# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names\n# (namespaces, classes, functions, etc.) that should be excluded from the\n# output. The symbol name can be a fully qualified name, a word, or if the\n# wildcard * is used, a substring. Examples: ANamespace, AClass,\n# AClass::ANamespace, ANamespace::*Test\n#\n# Note that the wildcards are matched against the file with absolute path, so to\n# exclude all test directories use the pattern */test/*\n\nEXCLUDE_SYMBOLS        = internal\n\n# The EXAMPLE_PATH tag can be used to specify one or more files or directories\n# that contain example code fragments that are included (see the \\include\n# command).\n\nEXAMPLE_PATH           =\n\n# If the value of the EXAMPLE_PATH tag contains directories, you can use the\n# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and\n# *.h) to filter out the source-files in the directories. If left blank all\n# files are included.\n\nEXAMPLE_PATTERNS       = *\n\n# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be\n# searched for input files to be used with the \\include or \\dontinclude commands\n# irrespective of the value of the RECURSIVE tag.\n# The default value is: NO.\n\nEXAMPLE_RECURSIVE      = NO\n\n# The IMAGE_PATH tag can be used to specify one or more files or directories\n# that contain images that are to be included in the documentation (see the\n# \\image command).\n\nIMAGE_PATH             = ./doc\n\n# The INPUT_FILTER tag can be used to specify a program that doxygen should\n# invoke to filter for each input file. Doxygen will invoke the filter program\n# by executing (via popen()) the command:\n#\n# <filter> <input-file>\n#\n# where <filter> is the value of the INPUT_FILTER tag, and <input-file> is the\n# name of an input file. Doxygen will then use the output that the filter\n# program writes to standard output. If FILTER_PATTERNS is specified, this tag\n# will be ignored.\n#\n# Note that the filter must not add or remove lines; it is applied before the\n# code is scanned, but not when the output code is generated. If lines are added\n# or removed, the anchors will not be placed correctly.\n\nINPUT_FILTER           =\n\n# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern\n# basis. Doxygen will compare the file name with each pattern and apply the\n# filter if there is a match. The filters are a list of the form: pattern=filter\n# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how\n# filters are used. If the FILTER_PATTERNS tag is empty or if none of the\n# patterns match the file name, INPUT_FILTER is applied.\n\nFILTER_PATTERNS        =\n\n# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using\n# INPUT_FILTER ) will also be used to filter the input files that are used for\n# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES).\n# The default value is: NO.\n\nFILTER_SOURCE_FILES    = NO\n\n# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file\n# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and\n# it is also possible to disable source filtering for a specific pattern using\n# *.ext= (so without naming a filter).\n# This tag requires that the tag FILTER_SOURCE_FILES is set to YES.\n\nFILTER_SOURCE_PATTERNS =\n\n# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that\n# is part of the input, its contents will be placed on the main page\n# (index.html). This can be useful if you have a project on for instance GitHub\n# and want to reuse the introduction page also for the doxygen output.\n\nUSE_MDFILE_AS_MAINPAGE = readme.zh-cn.md\n\n#---------------------------------------------------------------------------\n# Configuration options related to source browsing\n#---------------------------------------------------------------------------\n\n# If the SOURCE_BROWSER tag is set to YES then a list of source files will be\n# generated. Documented entities will be cross-referenced with these sources.\n#\n# Note: To get rid of all source code in the generated output, make sure that\n# also VERBATIM_HEADERS is set to NO.\n# The default value is: NO.\n\nSOURCE_BROWSER         = NO\n\n# Setting the INLINE_SOURCES tag to YES will include the body of functions,\n# classes and enums directly into the documentation.\n# The default value is: NO.\n\nINLINE_SOURCES         = NO\n\n# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any\n# special comment blocks from generated source code fragments. Normal C, C++ and\n# Fortran comments will always remain visible.\n# The default value is: YES.\n\nSTRIP_CODE_COMMENTS    = NO\n\n# If the REFERENCED_BY_RELATION tag is set to YES then for each documented\n# function all documented functions referencing it will be listed.\n# The default value is: NO.\n\nREFERENCED_BY_RELATION = NO\n\n# If the REFERENCES_RELATION tag is set to YES then for each documented function\n# all documented entities called/used by that function will be listed.\n# The default value is: NO.\n\nREFERENCES_RELATION    = NO\n\n# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set\n# to YES, then the hyperlinks from functions in REFERENCES_RELATION and\n# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will\n# link to the documentation.\n# The default value is: YES.\n\nREFERENCES_LINK_SOURCE = YES\n\n# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the\n# source code will show a tooltip with additional information such as prototype,\n# brief description and links to the definition and documentation. Since this\n# will make the HTML file larger and loading of large files a bit slower, you\n# can opt to disable this feature.\n# The default value is: YES.\n# This tag requires that the tag SOURCE_BROWSER is set to YES.\n\nSOURCE_TOOLTIPS        = YES\n\n# If the USE_HTAGS tag is set to YES then the references to source code will\n# point to the HTML generated by the htags(1) tool instead of doxygen built-in\n# source browser. The htags tool is part of GNU's global source tagging system\n# (see http://www.gnu.org/software/global/global.html). You will need version\n# 4.8.6 or higher.\n#\n# To use it do the following:\n# - Install the latest version of global\n# - Enable SOURCE_BROWSER and USE_HTAGS in the config file\n# - Make sure the INPUT points to the root of the source tree\n# - Run doxygen as normal\n#\n# Doxygen will invoke htags (and that will in turn invoke gtags), so these\n# tools must be available from the command line (i.e. in the search path).\n#\n# The result: instead of the source browser generated by doxygen, the links to\n# source code will now point to the output of htags.\n# The default value is: NO.\n# This tag requires that the tag SOURCE_BROWSER is set to YES.\n\nUSE_HTAGS              = NO\n\n# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a\n# verbatim copy of the header file for each class for which an include is\n# specified. Set to NO to disable this.\n# See also: Section \\class.\n# The default value is: YES.\n\nVERBATIM_HEADERS       = YES\n\n# If the CLANG_ASSISTED_PARSING tag is set to YES, then doxygen will use the\n# clang parser (see: http://clang.llvm.org/) for more accurate parsing at the\n# cost of reduced performance. This can be particularly helpful with template\n# rich C++ code for which doxygen's built-in parser lacks the necessary type\n# information.\n# Note: The availability of this option depends on whether or not doxygen was\n# compiled with the --with-libclang option.\n# The default value is: NO.\n\nCLANG_ASSISTED_PARSING = NO\n\n# If clang assisted parsing is enabled you can provide the compiler with command\n# line options that you would normally use when invoking the compiler. Note that\n# the include paths will already be set by doxygen for the files and directories\n# specified with INPUT and INCLUDE_PATH.\n# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES.\n\nCLANG_OPTIONS          =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the alphabetical class index\n#---------------------------------------------------------------------------\n\n# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all\n# compounds will be generated. Enable this if the project contains a lot of\n# classes, structs, unions or interfaces.\n# The default value is: YES.\n\nALPHABETICAL_INDEX     = NO\n\n# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in\n# which the alphabetical index list will be split.\n# Minimum value: 1, maximum value: 20, default value: 5.\n# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.\n\nCOLS_IN_ALPHA_INDEX    = 5\n\n# In case all classes in a project start with a common prefix, all classes will\n# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag\n# can be used to specify a prefix (or a list of prefixes) that should be ignored\n# while generating the index headers.\n# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.\n\nIGNORE_PREFIX          =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the HTML output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_HTML tag is set to YES doxygen will generate HTML output\n# The default value is: YES.\n\nGENERATE_HTML          = YES\n\n# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: html.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_OUTPUT            = html/zh-cn\n\n# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each\n# generated HTML page (for example: .htm, .php, .asp).\n# The default value is: .html.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_FILE_EXTENSION    = .html\n\n# The HTML_HEADER tag can be used to specify a user-defined HTML header file for\n# each generated HTML page. If the tag is left blank doxygen will generate a\n# standard header.\n#\n# To get valid HTML the header file that includes any scripts and style sheets\n# that doxygen needs, which is dependent on the configuration options used (e.g.\n# the setting GENERATE_TREEVIEW). It is highly recommended to start with a\n# default header using\n# doxygen -w html new_header.html new_footer.html new_stylesheet.css\n# YourConfigFile\n# and then modify the file new_header.html. See also section \"Doxygen usage\"\n# for information on how to generate the default header that doxygen normally\n# uses.\n# Note: The header is subject to change so you typically have to regenerate the\n# default header when upgrading to a newer version of doxygen. For a description\n# of the possible markers and block names see the documentation.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_HEADER            = ./doc/misc/header.html\n\n# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each\n# generated HTML page. If the tag is left blank doxygen will generate a standard\n# footer. See HTML_HEADER for more information on how to generate a default\n# footer and what special commands can be used inside the footer. See also\n# section \"Doxygen usage\" for information on how to generate the default footer\n# that doxygen normally uses.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_FOOTER            = ./doc/misc/footer.html\n\n# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style\n# sheet that is used by each HTML page. It can be used to fine-tune the look of\n# the HTML output. If left blank doxygen will generate a default style sheet.\n# See also section \"Doxygen usage\" for information on how to generate the style\n# sheet that doxygen normally uses.\n# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as\n# it is more robust and this tag (HTML_STYLESHEET) will in the future become\n# obsolete.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_STYLESHEET        =\n\n# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional user-\n# defined cascading style sheet that is included after the standard style sheets\n# created by doxygen. Using this option one can overrule certain style aspects.\n# This is preferred over using HTML_STYLESHEET since it does not replace the\n# standard style sheet and is therefor more robust against future updates.\n# Doxygen will copy the style sheet file to the output directory. For an example\n# see the documentation.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_EXTRA_STYLESHEET  = ./doc/misc/doxygenextra.css\n\n# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or\n# other source files which should be copied to the HTML output directory. Note\n# that these files will be copied to the base HTML output directory. Use the\n# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these\n# files. In the HTML_STYLESHEET file, use the file name only. Also note that the\n# files will be copied as-is; there are no commands or markers available.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_EXTRA_FILES       =\n\n# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen\n# will adjust the colors in the stylesheet and background images according to\n# this color. Hue is specified as an angle on a colorwheel, see\n# http://en.wikipedia.org/wiki/Hue for more information. For instance the value\n# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300\n# purple, and 360 is red again.\n# Minimum value: 0, maximum value: 359, default value: 220.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_COLORSTYLE_HUE    = 220\n\n# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors\n# in the HTML output. For a value of 0 the output will use grayscales only. A\n# value of 255 will produce the most vivid colors.\n# Minimum value: 0, maximum value: 255, default value: 100.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_COLORSTYLE_SAT    = 100\n\n# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the\n# luminance component of the colors in the HTML output. Values below 100\n# gradually make the output lighter, whereas values above 100 make the output\n# darker. The value divided by 100 is the actual gamma applied, so 80 represents\n# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not\n# change the gamma.\n# Minimum value: 40, maximum value: 240, default value: 80.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_COLORSTYLE_GAMMA  = 80\n\n# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML\n# page will contain the date and time when the page was generated. Setting this\n# to NO can help when comparing the output of multiple runs.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_TIMESTAMP         = YES\n\n# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML\n# documentation will contain sections that can be hidden and shown after the\n# page has loaded.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_DYNAMIC_SECTIONS  = NO\n\n# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries\n# shown in the various tree structured indices initially; the user can expand\n# and collapse entries dynamically later on. Doxygen will expand the tree to\n# such a level that at most the specified number of entries are visible (unless\n# a fully collapsed tree already exceeds this amount). So setting the number of\n# entries 1 will produce a full collapsed tree by default. 0 is a special value\n# representing an infinite number of entries and will result in a full expanded\n# tree by default.\n# Minimum value: 0, maximum value: 9999, default value: 100.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_INDEX_NUM_ENTRIES = 100\n\n# If the GENERATE_DOCSET tag is set to YES, additional index files will be\n# generated that can be used as input for Apple's Xcode 3 integrated development\n# environment (see: http://developer.apple.com/tools/xcode/), introduced with\n# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a\n# Makefile in the HTML output directory. Running make will produce the docset in\n# that directory and running make install will install the docset in\n# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at\n# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html\n# for more information.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_DOCSET        = NO\n\n# This tag determines the name of the docset feed. A documentation feed provides\n# an umbrella under which multiple documentation sets from a single provider\n# (such as a company or product suite) can be grouped.\n# The default value is: Doxygen generated docs.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_FEEDNAME        = \"Doxygen generated docs\"\n\n# This tag specifies a string that should uniquely identify the documentation\n# set bundle. This should be a reverse domain-name style string, e.g.\n# com.mycompany.MyDocSet. Doxygen will append .docset to the name.\n# The default value is: org.doxygen.Project.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_BUNDLE_ID       = org.doxygen.Project\n\n# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify\n# the documentation publisher. This should be a reverse domain-name style\n# string, e.g. com.mycompany.MyDocSet.documentation.\n# The default value is: org.doxygen.Publisher.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_PUBLISHER_ID    = org.doxygen.Publisher\n\n# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher.\n# The default value is: Publisher.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_PUBLISHER_NAME  = Publisher\n\n# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three\n# additional HTML index files: index.hhp, index.hhc, and index.hhk. The\n# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop\n# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on\n# Windows.\n#\n# The HTML Help Workshop contains a compiler that can convert all HTML output\n# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML\n# files are now used as the Windows 98 help format, and will replace the old\n# Windows help format (.hlp) on all Windows platforms in the future. Compressed\n# HTML files also contain an index, a table of contents, and you can search for\n# words in the documentation. The HTML workshop also contains a viewer for\n# compressed HTML files.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_HTMLHELP      = NO\n\n# The CHM_FILE tag can be used to specify the file name of the resulting .chm\n# file. You can add a path in front of the file if the result should not be\n# written to the html output directory.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nCHM_FILE               =\n\n# The HHC_LOCATION tag can be used to specify the location (absolute path\n# including file name) of the HTML help compiler ( hhc.exe). If non-empty\n# doxygen will try to run the HTML help compiler on the generated index.hhp.\n# The file has to be specified with full path.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nHHC_LOCATION           =\n\n# The GENERATE_CHI flag controls if a separate .chi index file is generated (\n# YES) or that it should be included in the master .chm file ( NO).\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nGENERATE_CHI           = NO\n\n# The CHM_INDEX_ENCODING is used to encode HtmlHelp index ( hhk), content ( hhc)\n# and project file content.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nCHM_INDEX_ENCODING     =\n\n# The BINARY_TOC flag controls whether a binary table of contents is generated (\n# YES) or a normal table of contents ( NO) in the .chm file. Furthermore it\n# enables the Previous and Next buttons.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nBINARY_TOC             = NO\n\n# The TOC_EXPAND flag can be set to YES to add extra items for group members to\n# the table of contents of the HTML help documentation and to the tree view.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nTOC_EXPAND             = NO\n\n# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and\n# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that\n# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help\n# (.qch) of the generated HTML documentation.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_QHP           = NO\n\n# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify\n# the file name of the resulting .qch file. The path specified is relative to\n# the HTML output folder.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQCH_FILE               =\n\n# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help\n# Project output. For more information please see Qt Help Project / Namespace\n# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace).\n# The default value is: org.doxygen.Project.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_NAMESPACE          = org.doxygen.Project\n\n# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt\n# Help Project output. For more information please see Qt Help Project / Virtual\n# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual-\n# folders).\n# The default value is: doc.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_VIRTUAL_FOLDER     = doc\n\n# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom\n# filter to add. For more information please see Qt Help Project / Custom\n# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-\n# filters).\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_CUST_FILTER_NAME   =\n\n# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the\n# custom filter to add. For more information please see Qt Help Project / Custom\n# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-\n# filters).\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_CUST_FILTER_ATTRS  =\n\n# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this\n# project's filter section matches. Qt Help Project / Filter Attributes (see:\n# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes).\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_SECT_FILTER_ATTRS  =\n\n# The QHG_LOCATION tag can be used to specify the location of Qt's\n# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the\n# generated .qhp file.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHG_LOCATION           =\n\n# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be\n# generated, together with the HTML files, they form an Eclipse help plugin. To\n# install this plugin and make it available under the help contents menu in\n# Eclipse, the contents of the directory containing the HTML and XML files needs\n# to be copied into the plugins directory of eclipse. The name of the directory\n# within the plugins directory should be the same as the ECLIPSE_DOC_ID value.\n# After copying Eclipse needs to be restarted before the help appears.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_ECLIPSEHELP   = NO\n\n# A unique identifier for the Eclipse help plugin. When installing the plugin\n# the directory name containing the HTML and XML files should also have this\n# name. Each documentation set should have its own identifier.\n# The default value is: org.doxygen.Project.\n# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES.\n\nECLIPSE_DOC_ID         = org.doxygen.Project\n\n# If you want full control over the layout of the generated HTML pages it might\n# be necessary to disable the index and replace it with your own. The\n# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top\n# of each HTML page. A value of NO enables the index and the value YES disables\n# it. Since the tabs in the index contain the same information as the navigation\n# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nDISABLE_INDEX          = YES\n\n# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index\n# structure should be generated to display hierarchical information. If the tag\n# value is set to YES, a side panel will be generated containing a tree-like\n# index structure (just like the one that is generated for HTML Help). For this\n# to work a browser that supports JavaScript, DHTML, CSS and frames is required\n# (i.e. any modern browser). Windows users are probably better off using the\n# HTML help feature. Via custom stylesheets (see HTML_EXTRA_STYLESHEET) one can\n# further fine-tune the look of the index. As an example, the default style\n# sheet generated by doxygen has an example that shows how to put an image at\n# the root of the tree instead of the PROJECT_NAME. Since the tree basically has\n# the same information as the tab index, you could consider setting\n# DISABLE_INDEX to YES when enabling this option.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_TREEVIEW      = YES\n\n# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that\n# doxygen will group on one line in the generated HTML documentation.\n#\n# Note that a value of 0 will completely suppress the enum values from appearing\n# in the overview section.\n# Minimum value: 0, maximum value: 20, default value: 4.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nENUM_VALUES_PER_LINE   = 4\n\n# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used\n# to set the initial width (in pixels) of the frame in which the tree is shown.\n# Minimum value: 0, maximum value: 1500, default value: 250.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nTREEVIEW_WIDTH         = 250\n\n# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open links to\n# external symbols imported via tag files in a separate window.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nEXT_LINKS_IN_WINDOW    = NO\n\n# Use this tag to change the font size of LaTeX formulas included as images in\n# the HTML documentation. When you change the font size after a successful\n# doxygen run you need to manually remove any form_*.png images from the HTML\n# output directory to force them to be regenerated.\n# Minimum value: 8, maximum value: 50, default value: 10.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nFORMULA_FONTSIZE       = 10\n\n# Use the FORMULA_TRANPARENT tag to determine whether or not the images\n# generated for formulas are transparent PNGs. Transparent PNGs are not\n# supported properly for IE 6.0, but are supported on all modern browsers.\n#\n# Note that when changing this option you need to delete any form_*.png files in\n# the HTML output directory before the changes have effect.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nFORMULA_TRANSPARENT    = YES\n\n# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see\n# http://www.mathjax.org) which uses client side Javascript for the rendering\n# instead of using prerendered bitmaps. Use this if you do not have LaTeX\n# installed or if you want to formulas look prettier in the HTML output. When\n# enabled you may also need to install MathJax separately and configure the path\n# to it using the MATHJAX_RELPATH option.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nUSE_MATHJAX            = NO\n\n# When MathJax is enabled you can set the default output format to be used for\n# the MathJax output. See the MathJax site (see:\n# http://docs.mathjax.org/en/latest/output.html) for more details.\n# Possible values are: HTML-CSS (which is slower, but has the best\n# compatibility), NativeMML (i.e. MathML) and SVG.\n# The default value is: HTML-CSS.\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_FORMAT         = HTML-CSS\n\n# When MathJax is enabled you need to specify the location relative to the HTML\n# output directory using the MATHJAX_RELPATH option. The destination directory\n# should contain the MathJax.js script. For instance, if the mathjax directory\n# is located at the same level as the HTML output directory, then\n# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax\n# Content Delivery Network so you can quickly see the result without installing\n# MathJax. However, it is strongly recommended to install a local copy of\n# MathJax from http://www.mathjax.org before deployment.\n# The default value is: http://cdn.mathjax.org/mathjax/latest.\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_RELPATH        = http://www.mathjax.org/mathjax\n\n# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax\n# extension names that should be enabled during MathJax rendering. For example\n# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_EXTENSIONS     =\n\n# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces\n# of code that will be used on startup of the MathJax code. See the MathJax site\n# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an\n# example see the documentation.\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_CODEFILE       =\n\n# When the SEARCHENGINE tag is enabled doxygen will generate a search box for\n# the HTML output. The underlying search engine uses javascript and DHTML and\n# should work on any modern browser. Note that when using HTML help\n# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET)\n# there is already a search function so this one should typically be disabled.\n# For large projects the javascript based search engine can be slow, then\n# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to\n# search using the keyboard; to jump to the search box use <access key> + S\n# (what the <access key> is depends on the OS and browser, but it is typically\n# <CTRL>, <ALT>/<option>, or both). Inside the search box use the <cursor down\n# key> to jump into the search results window, the results can be navigated\n# using the <cursor keys>. Press <Enter> to select an item or <escape> to cancel\n# the search. The filter options can be selected when the cursor is inside the\n# search box by pressing <Shift>+<cursor down>. Also here use the <cursor keys>\n# to select a filter and <Enter> or <escape> to activate or cancel the filter\n# option.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nSEARCHENGINE           = YES\n\n# When the SERVER_BASED_SEARCH tag is enabled the search engine will be\n# implemented using a web server instead of a web client using Javascript. There\n# are two flavors of web server based searching depending on the EXTERNAL_SEARCH\n# setting. When disabled, doxygen will generate a PHP script for searching and\n# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing\n# and searching needs to be provided by external tools. See the section\n# \"External Indexing and Searching\" for details.\n# The default value is: NO.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nSERVER_BASED_SEARCH    = NO\n\n# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP\n# script for searching. Instead the search results are written to an XML file\n# which needs to be processed by an external indexer. Doxygen will invoke an\n# external search engine pointed to by the SEARCHENGINE_URL option to obtain the\n# search results.\n#\n# Doxygen ships with an example indexer ( doxyindexer) and search engine\n# (doxysearch.cgi) which are based on the open source search engine library\n# Xapian (see: http://xapian.org/).\n#\n# See the section \"External Indexing and Searching\" for details.\n# The default value is: NO.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nEXTERNAL_SEARCH        = NO\n\n# The SEARCHENGINE_URL should point to a search engine hosted by a web server\n# which will return the search results when EXTERNAL_SEARCH is enabled.\n#\n# Doxygen ships with an example indexer ( doxyindexer) and search engine\n# (doxysearch.cgi) which are based on the open source search engine library\n# Xapian (see: http://xapian.org/). See the section \"External Indexing and\n# Searching\" for details.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nSEARCHENGINE_URL       =\n\n# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed\n# search data is written to a file for indexing by an external tool. With the\n# SEARCHDATA_FILE tag the name of this file can be specified.\n# The default file is: searchdata.xml.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nSEARCHDATA_FILE        = searchdata.xml\n\n# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the\n# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is\n# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple\n# projects and redirect the results back to the right project.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nEXTERNAL_SEARCH_ID     =\n\n# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen\n# projects other than the one defined by this configuration file, but that are\n# all added to the same external search index. Each project needs to have a\n# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of\n# to a relative location where the documentation can be found. The format is:\n# EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ...\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nEXTRA_SEARCH_MAPPINGS  =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the LaTeX output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_LATEX tag is set to YES doxygen will generate LaTeX output.\n# The default value is: YES.\n\nGENERATE_LATEX         = NO\n\n# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: latex.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_OUTPUT           = latex\n\n# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be\n# invoked.\n#\n# Note that when enabling USE_PDFLATEX this option is only used for generating\n# bitmaps for formulas in the HTML output, but not in the Makefile that is\n# written to the output directory.\n# The default file is: latex.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_CMD_NAME         = latex\n\n# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate\n# index for LaTeX.\n# The default file is: makeindex.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nMAKEINDEX_CMD_NAME     = makeindex\n\n# If the COMPACT_LATEX tag is set to YES doxygen generates more compact LaTeX\n# documents. This may be useful for small projects and may help to save some\n# trees in general.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nCOMPACT_LATEX          = NO\n\n# The PAPER_TYPE tag can be used to set the paper type that is used by the\n# printer.\n# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x\n# 14 inches) and executive (7.25 x 10.5 inches).\n# The default value is: a4.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nPAPER_TYPE             = a4\n\n# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names\n# that should be included in the LaTeX output. To get the times font for\n# instance you can specify\n# EXTRA_PACKAGES=times\n# If left blank no extra packages will be included.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nEXTRA_PACKAGES         =\n\n# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the\n# generated LaTeX document. The header should contain everything until the first\n# chapter. If it is left blank doxygen will generate a standard header. See\n# section \"Doxygen usage\" for information on how to let doxygen write the\n# default header to a separate file.\n#\n# Note: Only use a user-defined header if you know what you are doing! The\n# following commands have a special meaning inside the header: $title,\n# $datetime, $date, $doxygenversion, $projectname, $projectnumber. Doxygen will\n# replace them by respectively the title of the page, the current date and time,\n# only the current date, the version number of doxygen, the project name (see\n# PROJECT_NAME), or the project number (see PROJECT_NUMBER).\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_HEADER           =\n\n# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the\n# generated LaTeX document. The footer should contain everything after the last\n# chapter. If it is left blank doxygen will generate a standard footer.\n#\n# Note: Only use a user-defined footer if you know what you are doing!\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_FOOTER           =\n\n# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or\n# other source files which should be copied to the LATEX_OUTPUT output\n# directory. Note that the files will be copied as-is; there are no commands or\n# markers available.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_EXTRA_FILES      =\n\n# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is\n# prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will\n# contain links (just like the HTML output) instead of page references. This\n# makes the output suitable for online browsing using a PDF viewer.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nPDF_HYPERLINKS         = YES\n\n# If the LATEX_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate\n# the PDF file directly from the LaTeX files. Set this option to YES to get a\n# higher quality PDF documentation.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nUSE_PDFLATEX           = YES\n\n# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode\n# command to the generated LaTeX files. This will instruct LaTeX to keep running\n# if errors occur, instead of asking the user for help. This option is also used\n# when generating formulas in HTML.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_BATCHMODE        = NO\n\n# If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the\n# index chapters (such as File Index, Compound Index, etc.) in the output.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_HIDE_INDICES     = NO\n\n# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source\n# code with syntax highlighting in the LaTeX output.\n#\n# Note that which sources are shown also depends on other settings such as\n# SOURCE_BROWSER.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_SOURCE_CODE      = NO\n\n# The LATEX_BIB_STYLE tag can be used to specify the style to use for the\n# bibliography, e.g. plainnat, or ieeetr. See\n# http://en.wikipedia.org/wiki/BibTeX and \\cite for more info.\n# The default value is: plain.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_BIB_STYLE        = plain\n\n#---------------------------------------------------------------------------\n# Configuration options related to the RTF output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_RTF tag is set to YES doxygen will generate RTF output. The\n# RTF output is optimized for Word 97 and may not look too pretty with other RTF\n# readers/editors.\n# The default value is: NO.\n\nGENERATE_RTF           = NO\n\n# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: rtf.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_OUTPUT             = rtf\n\n# If the COMPACT_RTF tag is set to YES doxygen generates more compact RTF\n# documents. This may be useful for small projects and may help to save some\n# trees in general.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nCOMPACT_RTF            = NO\n\n# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will\n# contain hyperlink fields. The RTF file will contain links (just like the HTML\n# output) instead of page references. This makes the output suitable for online\n# browsing using Word or some other Word compatible readers that support those\n# fields.\n#\n# Note: WordPad (write) and others do not support links.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_HYPERLINKS         = NO\n\n# Load stylesheet definitions from file. Syntax is similar to doxygen's config\n# file, i.e. a series of assignments. You only have to provide replacements,\n# missing definitions are set to their default value.\n#\n# See also section \"Doxygen usage\" for information on how to generate the\n# default style sheet that doxygen normally uses.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_STYLESHEET_FILE    =\n\n# Set optional variables used in the generation of an RTF document. Syntax is\n# similar to doxygen's config file. A template extensions file can be generated\n# using doxygen -e rtf extensionFile.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_EXTENSIONS_FILE    =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the man page output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_MAN tag is set to YES doxygen will generate man pages for\n# classes and files.\n# The default value is: NO.\n\nGENERATE_MAN           = NO\n\n# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it. A directory man3 will be created inside the directory specified by\n# MAN_OUTPUT.\n# The default directory is: man.\n# This tag requires that the tag GENERATE_MAN is set to YES.\n\nMAN_OUTPUT             = man\n\n# The MAN_EXTENSION tag determines the extension that is added to the generated\n# man pages. In case the manual section does not start with a number, the number\n# 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is\n# optional.\n# The default value is: .3.\n# This tag requires that the tag GENERATE_MAN is set to YES.\n\nMAN_EXTENSION          = .3\n\n# The MAN_SUBDIR tag determines the name of the directory created within\n# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by\n# MAN_EXTENSION with the initial . removed.\n# This tag requires that the tag GENERATE_MAN is set to YES.\n\nMAN_SUBDIR             =\n\n# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it\n# will generate one additional man file for each entity documented in the real\n# man page(s). These additional files only source the real man page, but without\n# them the man command would be unable to find the correct page.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_MAN is set to YES.\n\nMAN_LINKS              = NO\n\n#---------------------------------------------------------------------------\n# Configuration options related to the XML output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_XML tag is set to YES doxygen will generate an XML file that\n# captures the structure of the code including all documentation.\n# The default value is: NO.\n\nGENERATE_XML           = NO\n\n# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: xml.\n# This tag requires that the tag GENERATE_XML is set to YES.\n\nXML_OUTPUT             = xml\n\n# If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program\n# listings (including syntax highlighting and cross-referencing information) to\n# the XML output. Note that enabling this will significantly increase the size\n# of the XML output.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_XML is set to YES.\n\nXML_PROGRAMLISTING     = YES\n\n#---------------------------------------------------------------------------\n# Configuration options related to the DOCBOOK output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_DOCBOOK tag is set to YES doxygen will generate Docbook files\n# that can be used to generate PDF.\n# The default value is: NO.\n\nGENERATE_DOCBOOK       = NO\n\n# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put.\n# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in\n# front of it.\n# The default directory is: docbook.\n# This tag requires that the tag GENERATE_DOCBOOK is set to YES.\n\nDOCBOOK_OUTPUT         = docbook\n\n#---------------------------------------------------------------------------\n# Configuration options for the AutoGen Definitions output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_AUTOGEN_DEF tag is set to YES doxygen will generate an AutoGen\n# Definitions (see http://autogen.sf.net) file that captures the structure of\n# the code including all documentation. Note that this feature is still\n# experimental and incomplete at the moment.\n# The default value is: NO.\n\nGENERATE_AUTOGEN_DEF   = NO\n\n#---------------------------------------------------------------------------\n# Configuration options related to the Perl module output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_PERLMOD tag is set to YES doxygen will generate a Perl module\n# file that captures the structure of the code including all documentation.\n#\n# Note that this feature is still experimental and incomplete at the moment.\n# The default value is: NO.\n\nGENERATE_PERLMOD       = NO\n\n# If the PERLMOD_LATEX tag is set to YES doxygen will generate the necessary\n# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI\n# output from the Perl module output.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_PERLMOD is set to YES.\n\nPERLMOD_LATEX          = NO\n\n# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be nicely\n# formatted so it can be parsed by a human reader. This is useful if you want to\n# understand what is going on. On the other hand, if this tag is set to NO the\n# size of the Perl module output will be much smaller and Perl will parse it\n# just the same.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_PERLMOD is set to YES.\n\nPERLMOD_PRETTY         = YES\n\n# The names of the make variables in the generated doxyrules.make file are\n# prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful\n# so different doxyrules.make files included by the same Makefile don't\n# overwrite each other's variables.\n# This tag requires that the tag GENERATE_PERLMOD is set to YES.\n\nPERLMOD_MAKEVAR_PREFIX =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the preprocessor\n#---------------------------------------------------------------------------\n\n# If the ENABLE_PREPROCESSING tag is set to YES doxygen will evaluate all\n# C-preprocessor directives found in the sources and include files.\n# The default value is: YES.\n\nENABLE_PREPROCESSING   = YES\n\n# If the MACRO_EXPANSION tag is set to YES doxygen will expand all macro names\n# in the source code. If set to NO only conditional compilation will be\n# performed. Macro expansion can be done in a controlled way by setting\n# EXPAND_ONLY_PREDEF to YES.\n# The default value is: NO.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nMACRO_EXPANSION        = YES\n\n# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then\n# the macro expansion is limited to the macros specified with the PREDEFINED and\n# EXPAND_AS_DEFINED tags.\n# The default value is: NO.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nEXPAND_ONLY_PREDEF     = YES\n\n# If the SEARCH_INCLUDES tag is set to YES the includes files in the\n# INCLUDE_PATH will be searched if a #include is found.\n# The default value is: YES.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nSEARCH_INCLUDES        = YES\n\n# The INCLUDE_PATH tag can be used to specify one or more directories that\n# contain include files that are not input files but should be processed by the\n# preprocessor.\n# This tag requires that the tag SEARCH_INCLUDES is set to YES.\n\nINCLUDE_PATH           =\n\n# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard\n# patterns (like *.h and *.hpp) to filter out the header-files in the\n# directories. If left blank, the patterns specified with FILE_PATTERNS will be\n# used.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nINCLUDE_FILE_PATTERNS  =\n\n# The PREDEFINED tag can be used to specify one or more macro names that are\n# defined before the preprocessor is started (similar to the -D option of e.g.\n# gcc). The argument of the tag is a list of macros of the form: name or\n# name=definition (no spaces). If the definition and the \"=\" are omitted, \"=1\"\n# is assumed. To prevent a macro definition from being undefined via #undef or\n# recursively expanded use the := operator instead of the = operator.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nPREDEFINED             = \\\n\tRAPIDJSON_DOXYGEN_RUNNING \\\n\tRAPIDJSON_NAMESPACE_BEGIN=\"namespace rapidjson {\" \\\n\tRAPIDJSON_NAMESPACE_END=\"}\" \\\n\tRAPIDJSON_REMOVEFPTR_(x)=x \\\n\tRAPIDJSON_ENABLEIF_RETURN(cond,returntype)=\"RAPIDJSON_REMOVEFPTR_ returntype\" \\\n\tRAPIDJSON_DISABLEIF_RETURN(cond,returntype)=\"RAPIDJSON_REMOVEFPTR_ returntype\"\n\n# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this\n# tag can be used to specify a list of macro names that should be expanded. The\n# macro definition that is found in the sources will be used. Use the PREDEFINED\n# tag if you want to use a different macro definition that overrules the\n# definition found in the source code.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nEXPAND_AS_DEFINED      = \\\n\tRAPIDJSON_NOEXCEPT\n\n# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will\n# remove all references to function-like macros that are alone on a line, have\n# an all uppercase name, and do not end with a semicolon. Such function macros\n# are typically used for boiler-plate code, and will confuse the parser if not\n# removed.\n# The default value is: YES.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nSKIP_FUNCTION_MACROS   = YES\n\n#---------------------------------------------------------------------------\n# Configuration options related to external references\n#---------------------------------------------------------------------------\n\n# The TAGFILES tag can be used to specify one or more tag files. For each tag\n# file the location of the external documentation should be added. The format of\n# a tag file without this location is as follows:\n# TAGFILES = file1 file2 ...\n# Adding location for the tag files is done as follows:\n# TAGFILES = file1=loc1 \"file2 = loc2\" ...\n# where loc1 and loc2 can be relative or absolute paths or URLs. See the\n# section \"Linking to external documentation\" for more information about the use\n# of tag files.\n# Note: Each tag file must have a unique name (where the name does NOT include\n# the path). If a tag file is not located in the directory in which doxygen is\n# run, you must also specify the path to the tagfile here.\n\nTAGFILES               =\n\n# When a file name is specified after GENERATE_TAGFILE, doxygen will create a\n# tag file that is based on the input files it reads. See section \"Linking to\n# external documentation\" for more information about the usage of tag files.\n\nGENERATE_TAGFILE       =\n\n# If the ALLEXTERNALS tag is set to YES all external class will be listed in the\n# class index. If set to NO only the inherited external classes will be listed.\n# The default value is: NO.\n\nALLEXTERNALS           = NO\n\n# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed in\n# the modules index. If set to NO, only the current project's groups will be\n# listed.\n# The default value is: YES.\n\nEXTERNAL_GROUPS        = YES\n\n# If the EXTERNAL_PAGES tag is set to YES all external pages will be listed in\n# the related pages index. If set to NO, only the current project's pages will\n# be listed.\n# The default value is: YES.\n\nEXTERNAL_PAGES         = YES\n\n# The PERL_PATH should be the absolute path and name of the perl script\n# interpreter (i.e. the result of 'which perl').\n# The default file (with absolute path) is: /usr/bin/perl.\n\nPERL_PATH              = /usr/bin/perl\n\n#---------------------------------------------------------------------------\n# Configuration options related to the dot tool\n#---------------------------------------------------------------------------\n\n# If the CLASS_DIAGRAMS tag is set to YES doxygen will generate a class diagram\n# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to\n# NO turns the diagrams off. Note that this option also works with HAVE_DOT\n# disabled, but it is recommended to install and use dot, since it yields more\n# powerful graphs.\n# The default value is: YES.\n\nCLASS_DIAGRAMS         = YES\n\n# You can define message sequence charts within doxygen comments using the \\msc\n# command. Doxygen will then run the mscgen tool (see:\n# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the\n# documentation. The MSCGEN_PATH tag allows you to specify the directory where\n# the mscgen tool resides. If left empty the tool is assumed to be found in the\n# default search path.\n\nMSCGEN_PATH            =\n\n# You can include diagrams made with dia in doxygen documentation. Doxygen will\n# then run dia to produce the diagram and insert it in the documentation. The\n# DIA_PATH tag allows you to specify the directory where the dia binary resides.\n# If left empty dia is assumed to be found in the default search path.\n\nDIA_PATH               =\n\n# If set to YES, the inheritance and collaboration graphs will hide inheritance\n# and usage relations if the target is undocumented or is not a class.\n# The default value is: YES.\n\nHIDE_UNDOC_RELATIONS   = YES\n\n# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is\n# available from the path. This tool is part of Graphviz (see:\n# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent\n# Bell Labs. The other options in this section have no effect if this option is\n# set to NO\n# The default value is: NO.\n\nHAVE_DOT               = NO\n\n# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed\n# to run in parallel. When set to 0 doxygen will base this on the number of\n# processors available in the system. You can set it explicitly to a value\n# larger than 0 to get control over the balance between CPU load and processing\n# speed.\n# Minimum value: 0, maximum value: 32, default value: 0.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_NUM_THREADS        = 0\n\n# When you want a differently looking font n the dot files that doxygen\n# generates you can specify the font name using DOT_FONTNAME. You need to make\n# sure dot is able to find the font, which can be done by putting it in a\n# standard location or by setting the DOTFONTPATH environment variable or by\n# setting DOT_FONTPATH to the directory containing the font.\n# The default value is: Helvetica.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_FONTNAME           = Helvetica\n\n# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of\n# dot graphs.\n# Minimum value: 4, maximum value: 24, default value: 10.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_FONTSIZE           = 10\n\n# By default doxygen will tell dot to use the default font as specified with\n# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set\n# the path where dot can find it using this tag.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_FONTPATH           =\n\n# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for\n# each documented class showing the direct and indirect inheritance relations.\n# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCLASS_GRAPH            = YES\n\n# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a\n# graph for each documented class showing the direct and indirect implementation\n# dependencies (inheritance, containment, and class references variables) of the\n# class with other documented classes.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCOLLABORATION_GRAPH    = YES\n\n# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for\n# groups, showing the direct groups dependencies.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nGROUP_GRAPHS           = YES\n\n# If the UML_LOOK tag is set to YES doxygen will generate inheritance and\n# collaboration diagrams in a style similar to the OMG's Unified Modeling\n# Language.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nUML_LOOK               = NO\n\n# If the UML_LOOK tag is enabled, the fields and methods are shown inside the\n# class node. If there are many fields or methods and many nodes the graph may\n# become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the\n# number of items for each type to make the size more manageable. Set this to 0\n# for no limit. Note that the threshold may be exceeded by 50% before the limit\n# is enforced. So when you set the threshold to 10, up to 15 fields may appear,\n# but if the number exceeds 15, the total amount of fields shown is limited to\n# 10.\n# Minimum value: 0, maximum value: 100, default value: 10.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nUML_LIMIT_NUM_FIELDS   = 10\n\n# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and\n# collaboration graphs will show the relations between templates and their\n# instances.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nTEMPLATE_RELATIONS     = NO\n\n# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to\n# YES then doxygen will generate a graph for each documented file showing the\n# direct and indirect include dependencies of the file with other documented\n# files.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nINCLUDE_GRAPH          = YES\n\n# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are\n# set to YES then doxygen will generate a graph for each documented file showing\n# the direct and indirect include dependencies of the file with other documented\n# files.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nINCLUDED_BY_GRAPH      = YES\n\n# If the CALL_GRAPH tag is set to YES then doxygen will generate a call\n# dependency graph for every global function or class method.\n#\n# Note that enabling this option will significantly increase the time of a run.\n# So in most cases it will be better to enable call graphs for selected\n# functions only using the \\callgraph command.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCALL_GRAPH             = NO\n\n# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller\n# dependency graph for every global function or class method.\n#\n# Note that enabling this option will significantly increase the time of a run.\n# So in most cases it will be better to enable caller graphs for selected\n# functions only using the \\callergraph command.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCALLER_GRAPH           = NO\n\n# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical\n# hierarchy of all classes instead of a textual one.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nGRAPHICAL_HIERARCHY    = YES\n\n# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the\n# dependencies a directory has on other directories in a graphical way. The\n# dependency relations are determined by the #include relations between the\n# files in the directories.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDIRECTORY_GRAPH        = YES\n\n# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images\n# generated by dot.\n# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order\n# to make the SVG files visible in IE 9+ (other browsers do not have this\n# requirement).\n# Possible values are: png, jpg, gif and svg.\n# The default value is: png.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_IMAGE_FORMAT       = png\n\n# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to\n# enable generation of interactive SVG images that allow zooming and panning.\n#\n# Note that this requires a modern browser other than Internet Explorer. Tested\n# and working are Firefox, Chrome, Safari, and Opera.\n# Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make\n# the SVG files visible. Older versions of IE do not have SVG support.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nINTERACTIVE_SVG        = NO\n\n# The DOT_PATH tag can be used to specify the path where the dot tool can be\n# found. If left blank, it is assumed the dot tool can be found in the path.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_PATH               =\n\n# The DOTFILE_DIRS tag can be used to specify one or more directories that\n# contain dot files that are included in the documentation (see the \\dotfile\n# command).\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOTFILE_DIRS           =\n\n# The MSCFILE_DIRS tag can be used to specify one or more directories that\n# contain msc files that are included in the documentation (see the \\mscfile\n# command).\n\nMSCFILE_DIRS           =\n\n# The DIAFILE_DIRS tag can be used to specify one or more directories that\n# contain dia files that are included in the documentation (see the \\diafile\n# command).\n\nDIAFILE_DIRS           =\n\n# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes\n# that will be shown in the graph. If the number of nodes in a graph becomes\n# larger than this value, doxygen will truncate the graph, which is visualized\n# by representing a node as a red box. Note that doxygen if the number of direct\n# children of the root node in a graph is already larger than\n# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that\n# the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.\n# Minimum value: 0, maximum value: 10000, default value: 50.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_GRAPH_MAX_NODES    = 50\n\n# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs\n# generated by dot. A depth value of 3 means that only nodes reachable from the\n# root by following a path via at most 3 edges will be shown. Nodes that lay\n# further from the root node will be omitted. Note that setting this option to 1\n# or 2 may greatly reduce the computation time needed for large code bases. Also\n# note that the size of a graph can be further restricted by\n# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.\n# Minimum value: 0, maximum value: 1000, default value: 0.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nMAX_DOT_GRAPH_DEPTH    = 0\n\n# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent\n# background. This is disabled by default, because dot on Windows does not seem\n# to support this out of the box.\n#\n# Warning: Depending on the platform used, enabling this option may lead to\n# badly anti-aliased labels on the edges of a graph (i.e. they become hard to\n# read).\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_TRANSPARENT        = NO\n\n# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output\n# files in one run (i.e. multiple -o and -T options on the command line). This\n# makes dot run faster, but since only newer versions of dot (>1.8.10) support\n# this, this feature is disabled by default.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_MULTI_TARGETS      = NO\n\n# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page\n# explaining the meaning of the various boxes and arrows in the dot generated\n# graphs.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nGENERATE_LEGEND        = YES\n\n# If the DOT_CLEANUP tag is set to YES doxygen will remove the intermediate dot\n# files that are used to generate the various graphs.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_CLEANUP            = YES\n"
  },
  {
    "path": "ext/rapidjson/doc/diagram/architecture.dot",
    "content": "digraph {\n\tcompound=true\n\tfontname=\"Inconsolata, Consolas\"\n\tfontsize=10\n\tmargin=\"0,0\"\n\tranksep=0.2\n\tnodesep=0.5\n\tpenwidth=0.5\n\tcolorscheme=spectral7\n\t\n\tnode [shape=box, fontname=\"Inconsolata, Consolas\", fontsize=10, penwidth=0.5, style=filled, fillcolor=white]\n\tedge [fontname=\"Inconsolata, Consolas\", fontsize=10, penwidth=0.5]\n\n\tsubgraph cluster1 {\n\t\tmargin=\"10,10\"\n\t\tlabeljust=\"left\"\n\t\tlabel = \"SAX\"\n\t\tstyle=filled\n\t\tfillcolor=6\n\n\t\tReader -> Writer [style=invis]\n\t}\n\n\tsubgraph cluster2 {\n\t\tmargin=\"10,10\"\n\t\tlabeljust=\"left\"\n\t\tlabel = \"DOM\"\n\t\tstyle=filled\n\t\tfillcolor=7\n\n\t\tValue\n\t\tDocument\n\t}\n\n\tHandler [label=\"<<concept>>\\nHandler\"]\n\n\t{\n\t\tedge [arrowtail=onormal, dir=back]\n\t\tValue -> Document\n\t\tHandler -> Document\n\t\tHandler -> Writer\n\t}\n\n\t{\n\t\tedge [arrowhead=vee, style=dashed, constraint=false]\n\t\tReader -> Handler [label=\"calls\"]\n\t\tValue -> Handler [label=\"calls\"]\n\t\tDocument -> Reader [label=\"uses\"]\n\t}\n}"
  },
  {
    "path": "ext/rapidjson/doc/diagram/insituparsing.dot",
    "content": "digraph {\n\tcompound=true\n\tfontname=\"Inconsolata, Consolas\"\n\tfontsize=10\n\tmargin=\"0,0\"\n\tranksep=0.2\n\tpenwidth=0.5\n\t\n\tnode [fontname=\"Inconsolata, Consolas\", fontsize=10, penwidth=0.5]\n\tedge [fontname=\"Inconsolata, Consolas\", fontsize=10, arrowhead=normal]\n\n\t{\n\t\tnode [shape=record, fontsize=\"8\", margin=\"0.04\", height=0.2, color=gray]\n\t\toldjson [label=\"\\{|\\\"|m|s|g|\\\"|:|\\\"|H|e|l|l|o|\\\\|n|W|o|r|l|d|!|\\\"|,|\\\"|\\\\|u|0|0|7|3|t|a|r|s|\\\"|:|1|0|\\}\", xlabel=\"Before Parsing\"]\n\t\t//newjson [label=\"\\{|\\\"|<a>m|s|g|\\\\0|:|\\\"|<b>H|e|l|l|o|\\\\n|W|o|r|l|d|!|\\\\0|\\\"|,|\\\"|<c>s|t|a|r|s|\\\\0|t|a|r|s|:|1|0|\\}\", xlabel=\"After Parsing\"]\n\t\tnewjson [shape=plaintext, label=<\n<table BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\" CELLPADDING=\"2\"><tr>\n<td>{</td>\n<td>\"</td><td port=\"a\">m</td><td>s</td><td>g</td><td bgcolor=\"yellow\">\\\\0</td>\n<td>:</td>\n<td>\"</td><td port=\"b\">H</td><td>e</td><td>l</td><td>l</td><td>o</td><td bgcolor=\"yellow\">\\\\n</td><td bgcolor=\"yellow\">W</td><td bgcolor=\"yellow\">o</td><td bgcolor=\"yellow\">r</td><td bgcolor=\"yellow\">l</td><td bgcolor=\"yellow\">d</td><td bgcolor=\"yellow\">!</td><td bgcolor=\"yellow\">\\\\0</td><td>\"</td>\n<td>,</td>\n<td>\"</td><td port=\"c\" bgcolor=\"yellow\">s</td><td bgcolor=\"yellow\">t</td><td bgcolor=\"yellow\">a</td><td bgcolor=\"yellow\">r</td><td bgcolor=\"yellow\">s</td><td bgcolor=\"yellow\">\\\\0</td><td>t</td><td>a</td><td>r</td><td>s</td>\n<td>:</td>\n<td>1</td><td>0</td>\n<td>}</td>\n</tr></table>\n>, xlabel=\"After Parsing\"]\n\t}\n\n\tsubgraph cluster1 {\n\t\tmargin=\"10,10\"\n\t\tlabeljust=\"left\"\n\t\tlabel = \"Document by In situ Parsing\"\n\t\tstyle=filled\n\t\tfillcolor=gray95\n\t\tnode [shape=Mrecord, style=filled, colorscheme=spectral7]\n\t\t\n\t\troot [label=\"{object|}\", fillcolor=3]\n\n\t\t{\t\t\t\n\t\t\tmsg [label=\"{string|<a>}\", fillcolor=5]\n\t\t\thelloworld [label=\"{string|<a>}\", fillcolor=5]\n\t\t\tstars [label=\"{string|<a>}\", fillcolor=5]\n\t\t\tten [label=\"{number|10}\", fillcolor=6]\n\t\t}\n\t}\n\n\toldjson -> root [label=\" ParseInsitu()\" lhead=\"cluster1\"]\n\tedge [arrowhead=vee]\n\troot -> { msg; stars }\n\n\tedge [arrowhead=\"none\"]\n\tmsg  -> helloworld\n\tstars -> ten\n\n\t{\n\t\tedge [arrowhead=vee, arrowtail=dot, arrowsize=0.5, dir=both, tailclip=false]\n\t\tmsg:a:c -> newjson:a\n\t\thelloworld:a:c -> newjson:b\n\t\tstars:a:c -> newjson:c\n\t}\n\n\t//oldjson -> newjson [style=invis]\n}"
  },
  {
    "path": "ext/rapidjson/doc/diagram/iterative-parser-states-diagram.dot",
    "content": "digraph {\n    fontname=\"Inconsolata, Consolas\"\n    fontsize=10\n    margin=\"0,0\"\n    penwidth=0.0\n    \n    node [fontname=\"Inconsolata, Consolas\", fontsize=10, penwidth=0.5]\n    edge [fontname=\"Inconsolata, Consolas\", fontsize=10, penwidth=0.5]\n\n    node [shape = doublecircle]; Start; Finish;\n    node [shape = box; style = \"rounded, filled\"; fillcolor=white ];\n\n    Start -> ArrayInitial [label=\" [\"];\n    Start -> ObjectInitial [label=\" {\"];\n\n    subgraph clusterArray {\n        margin=\"10,10\"\n        style=filled\n        fillcolor=gray95\n        label = \"Array\"\n        \n        ArrayInitial; Element; ElementDelimiter; ArrayFinish;\n    }\n\n    subgraph clusterObject {\n        margin=\"10,10\"\n        style=filled\n        fillcolor=gray95\n        label = \"Object\"\n\n        ObjectInitial; MemberKey; KeyValueDelimiter; MemberValue; MemberDelimiter; ObjectFinish;\n    }\n\n    ArrayInitial -> ArrayInitial [label=\"[\"];\n    ArrayInitial -> ArrayFinish [label=\" ]\"];\n    ArrayInitial -> ObjectInitial [label=\"{\", constraint=false];\n    ArrayInitial -> Element [label=\"string\\nfalse\\ntrue\\nnull\\nnumber\"];\n\n    Element -> ArrayFinish [label=\"]\"];\n    Element -> ElementDelimiter [label=\",\"];\n\n    ElementDelimiter -> ArrayInitial [label=\" [\"];\n    ElementDelimiter -> ObjectInitial [label=\"{\"];\n    ElementDelimiter -> Element [label=\"string\\nfalse\\ntrue\\nnull\\nnumber\"];\n\n    ObjectInitial -> ObjectFinish [label=\" }\"];\n    ObjectInitial -> MemberKey [label=\" string \"];\n\n    MemberKey -> KeyValueDelimiter [label=\":\"];\n\n    KeyValueDelimiter -> ArrayInitial [label=\"[\"];\n    KeyValueDelimiter -> ObjectInitial [label=\" {\"];\n    KeyValueDelimiter -> MemberValue [label=\" string\\n false\\n true\\n null\\n number\"];\n\n    MemberValue -> ObjectFinish [label=\"}\"];\n    MemberValue -> MemberDelimiter [label=\",\"];\n\n    MemberDelimiter -> MemberKey [label=\" string \"];\n\n    ArrayFinish -> Finish;\n    ObjectFinish -> Finish;\n}\n"
  },
  {
    "path": "ext/rapidjson/doc/diagram/makefile",
    "content": "%.pdf: %.dot\n\tdot $< -Tpdf -o $@\n\n%.png: %.dot\n\tdot $< -Tpng -o $@\n\nDOTFILES = $(basename $(wildcard *.dot))\nall: $(addsuffix .png, $(DOTFILES)) $(addsuffix .pdf, $(DOTFILES))\n"
  },
  {
    "path": "ext/rapidjson/doc/diagram/move1.dot",
    "content": "digraph {\n\tcompound=true\n\tfontname=\"Inconsolata, Consolas\"\n\tfontsize=10\n\tmargin=\"0,0\"\n\tranksep=0.2\n\tpenwidth=0.5\n\n\tnode [fontname=\"Inconsolata, Consolas\", fontsize=10, penwidth=0.5]\n\tedge [fontname=\"Inconsolata, Consolas\", fontsize=10, arrowhead=normal]\n\n\tsubgraph cluster1 {\n\t\tmargin=\"10,10\"\n\t\tlabeljust=\"left\"\n\t\tlabel = \"Before\"\n\t\tstyle=filled\n\t\tfillcolor=gray95\n\n\t\tnode [shape=Mrecord, style=filled, colorscheme=spectral7]\n\n\t\t{\n\t\t\trank = same\n\t\t\tb1 [label=\"{b:number|456}\", fillcolor=6]\n\t\t\ta1 [label=\"{a:number|123}\", fillcolor=6]\n\t\t}\n\n\t\ta1 -> b1 [style=\"dashed\", label=\"Move\", dir=back]\n\t}\n\n\tsubgraph cluster2 {\n\t\tmargin=\"10,10\"\n\t\tlabeljust=\"left\"\n\t\tlabel = \"After\"\n\t\tstyle=filled\n\t\tfillcolor=gray95\n\n\t\tnode [shape=Mrecord, style=filled, colorscheme=spectral7]\n\n\t\t{\n\t\t\trank = same\n\t\t\tb2 [label=\"{b:null|}\", fillcolor=1]\n\t\t\ta2 [label=\"{a:number|456}\", fillcolor=6]\n\t\t}\n\t\ta2 -> b2 [style=invis, dir=back]\n\t}\n\tb1 -> b2 [style=invis]\n}"
  },
  {
    "path": "ext/rapidjson/doc/diagram/move2.dot",
    "content": "digraph {\n\tcompound=true\n\tfontname=\"Inconsolata, Consolas\"\n\tfontsize=10\n\tmargin=\"0,0\"\n\tranksep=0.2\n\tpenwidth=0.5\n\n\tnode [fontname=\"Inconsolata, Consolas\", fontsize=10, penwidth=0.5]\n\tedge [fontname=\"Inconsolata, Consolas\", fontsize=10, arrowhead=normal]\n\n\tsubgraph cluster1 {\n\t\tmargin=\"10,10\"\n\t\tlabeljust=\"left\"\n\t\tlabel = \"Before Copying (Hypothetic)\"\n\t\tstyle=filled\n\t\tfillcolor=gray95\n\n\t\tnode [shape=Mrecord, style=filled, colorscheme=spectral7]\n\n\t\tc1 [label=\"{contact:array|}\", fillcolor=4]\n\t\tc11 [label=\"{|}\"]\n\t\tc12 [label=\"{|}\"]\n\t\tc13 [shape=\"none\", label=\"...\", style=\"solid\"]\n\t\to1 [label=\"{o:object|}\", fillcolor=3]\n\t\tghost [label=\"{o:object|}\", style=invis]\n\n\t\tc1 -> o1 [style=\"dashed\", label=\"AddMember\", constraint=false]\n\n\t\tedge [arrowhead=vee]\n\t\tc1 -> { c11; c12; c13 }\n\t\to1 -> ghost [style=invis]\n\t}\n\n\tsubgraph cluster2 {\n\t\tmargin=\"10,10\"\n\t\tlabeljust=\"left\"\n\t\tlabel = \"After Copying (Hypothetic)\"\n\t\tstyle=filled\n\t\tfillcolor=gray95\n\n\t\tnode [shape=Mrecord, style=filled, colorscheme=spectral7]\n\n\t\tc2 [label=\"{contact:array|}\", fillcolor=4]\n\t\tc3 [label=\"{array|}\", fillcolor=4]\n\t\tc21 [label=\"{|}\"]\n\t\tc22 [label=\"{|}\"]\n\t\tc23 [shape=none, label=\"...\", style=\"solid\"]\n\t\to2 [label=\"{o:object|}\", fillcolor=3]\n\t\tcs [label=\"{string|\\\"contact\\\"}\", fillcolor=5]\n\t\tc31 [label=\"{|}\"]\n\t\tc32 [label=\"{|}\"]\n\t\tc33 [shape=\"none\", label=\"...\", style=\"solid\"]\n\n\t\tedge [arrowhead=vee]\n\t\tc2 -> { c21; c22; c23 }\n\t\to2 -> cs\n\t\tcs -> c3 [arrowhead=none]\n\t\tc3 -> { c31; c32; c33 }\n\t}\n\tghost -> o2 [style=invis]\n}"
  },
  {
    "path": "ext/rapidjson/doc/diagram/move3.dot",
    "content": "digraph {\n\tcompound=true\n\tfontname=\"Inconsolata, Consolas\"\n\tfontsize=10\n\tmargin=\"0,0\"\n\tranksep=0.2\n\tpenwidth=0.5\n\tforcelabels=true\n\n\tnode [fontname=\"Inconsolata, Consolas\", fontsize=10, penwidth=0.5]\n\tedge [fontname=\"Inconsolata, Consolas\", fontsize=10, arrowhead=normal]\n\n\tsubgraph cluster1 {\n\t\tmargin=\"10,10\"\n\t\tlabeljust=\"left\"\n\t\tlabel = \"Before Moving\"\n\t\tstyle=filled\n\t\tfillcolor=gray95\n\n\t\tnode [shape=Mrecord, style=filled, colorscheme=spectral7]\n\n\t\tc1 [label=\"{contact:array|}\", fillcolor=4]\n\t\tc11 [label=\"{|}\"]\n\t\tc12 [label=\"{|}\"]\n\t\tc13 [shape=none, label=\"...\", style=\"solid\"]\n\t\to1 [label=\"{o:object|}\", fillcolor=3]\n\t\tghost [label=\"{o:object|}\", style=invis]\n\n\t\tc1 -> o1 [style=\"dashed\", constraint=false, label=\"AddMember\"]\n\n\t\tedge [arrowhead=vee]\n\t\tc1 -> { c11; c12; c13 }\n\t\to1 -> ghost [style=invis]\n\t}\n\n\tsubgraph cluster2 {\n\t\tmargin=\"10,10\"\n\t\tlabeljust=\"left\"\n\t\tlabel = \"After Moving\"\n\t\tstyle=filled\n\t\tfillcolor=gray95\n\n\t\tnode [shape=Mrecord, style=filled, colorscheme=spectral7]\n\n\t\tc2 [label=\"{contact:null|}\", fillcolor=1]\n\t\tc3 [label=\"{array|}\", fillcolor=4]\n\t\tc21 [label=\"{|}\"]\n\t\tc22 [label=\"{|}\"]\n\t\tc23 [shape=\"none\", label=\"...\", style=\"solid\"]\n\t\to2 [label=\"{o:object|}\", fillcolor=3]\n\t\tcs [label=\"{string|\\\"contact\\\"}\", fillcolor=5]\n\t\tc2 -> o2 [style=\"dashed\", constraint=false, label=\"AddMember\", style=invis]\n\n\t\tedge [arrowhead=vee]\n\t\tc3 -> { c21; c22; c23 }\n\t\to2 -> cs\n\t\tcs -> c3 [arrowhead=none]\n\t}\n\tghost -> o2 [style=invis]\n}"
  },
  {
    "path": "ext/rapidjson/doc/diagram/normalparsing.dot",
    "content": "digraph {\n\tcompound=true\n\tfontname=\"Inconsolata, Consolas\"\n\tfontsize=10\n\tmargin=\"0,0\"\n\tranksep=0.2\n\tpenwidth=0.5\n\t\n\tnode [fontname=\"Inconsolata, Consolas\", fontsize=10, penwidth=0.5]\n\tedge [fontname=\"Inconsolata, Consolas\", fontsize=10, arrowhead=normal]\n\n\t{\n\t\tnode [shape=record, fontsize=\"8\", margin=\"0.04\", height=0.2, color=gray]\n\t\tnormaljson [label=\"\\{|\\\"|m|s|g|\\\"|:|\\\"|H|e|l|l|o|\\\\|n|W|o|r|l|d|!|\\\"|,|\\\"|\\\\|u|0|0|7|3|t|a|r|s\\\"|:|1|0|\\}\"]\n\n\t\t{\n\t\t\trank = same\n\t\t\tmsgstring  [label=\"m|s|g|\\\\0\"]\n\t\t\thelloworldstring  [label=\"H|e|l|l|o|\\\\n|W|o|r|l|d|!|\\\\0\"]\n\t\t\tstarsstring [label=\"s|t|a|r|s\\\\0\"]\n\t\t}\n\t}\n\n\tsubgraph cluster1 {\n\t\tmargin=\"10,10\"\n\t\tlabeljust=\"left\"\n\t\tlabel = \"Document by Normal Parsing\"\n\t\tstyle=filled\n\t\tfillcolor=gray95\n\t\tnode [shape=Mrecord, style=filled, colorscheme=spectral7]\n\t\t\n\t\troot [label=\"{object|}\", fillcolor=3]\n\n\t\t{\t\t\t\n\t\t\tmsg [label=\"{string|<a>}\", fillcolor=5]\n\t\t\thelloworld [label=\"{string|<a>}\", fillcolor=5]\n\t\t\tstars [label=\"{string|<a>}\", fillcolor=5]\n\t\t\tten [label=\"{number|10}\", fillcolor=6]\n\t\t}\n\t}\n\n\tnormaljson -> root [label=\" Parse()\" lhead=\"cluster1\"]\n\tedge [arrowhead=vee]\n\troot -> { msg; stars }\n\n\tedge [arrowhead=\"none\"]\n\tmsg  -> helloworld\n\tstars -> ten\n\n\tedge [arrowhead=vee, arrowtail=dot, arrowsize=0.5, dir=both, tailclip=false]\n\tmsg:a:c -> msgstring:w\n\thelloworld:a:c -> helloworldstring:w\n\tstars:a:c -> starsstring:w\n\n\tmsgstring -> helloworldstring -> starsstring [style=invis]\n}"
  },
  {
    "path": "ext/rapidjson/doc/diagram/simpledom.dot",
    "content": "digraph {\n\tcompound=true\n\tfontname=\"Inconsolata, Consolas\"\n\tfontsize=10\n\tmargin=\"0,0\"\n\tranksep=0.2\n\tpenwidth=0.5\n\t\n\tnode [fontname=\"Inconsolata, Consolas\", fontsize=10, penwidth=0.5]\n\tedge [fontname=\"Inconsolata, Consolas\", fontsize=10, arrowhead=normal]\n\n\t{\n\t\tnode [shape=record, fontsize=\"8\", margin=\"0.04\", height=0.2, color=gray]\n\t\tsrcjson [label=\"\\{|\\\"|p|r|o|j|e|c|t|\\\"|:|\\\"|r|a|p|i|d|j|s|o|n|\\\"|,|\\\"|s|t|a|r|s|\\\"|:|1|0|\\}\"]\n\t\tdstjson [label=\"\\{|\\\"|p|r|o|j|e|c|t|\\\"|:|\\\"|r|a|p|i|d|j|s|o|n|\\\"|,|\\\"|s|t|a|r|s|\\\"|:|1|1|\\}\"]\n\t}\n\n\t{\n\t\tnode [shape=\"box\", style=\"filled\", fillcolor=\"gray95\"]\n\t\tDocument2 [label=\"(Modified) Document\"]\n\t\tWriter\n\t}\n\n\tsubgraph cluster1 {\n\t\tmargin=\"10,10\"\n\t\tlabeljust=\"left\"\n\t\tlabel = \"Document\"\n\t\tstyle=filled\n\t\tfillcolor=gray95\n\t\tnode [shape=Mrecord, style=filled, colorscheme=spectral7]\n\t\t\n\t\troot [label=\"{object|}\", fillcolor=3]\n\n\t\t{\t\t\t\n\t\t\tproject [label=\"{string|\\\"project\\\"}\", fillcolor=5]\n\t\t\trapidjson [label=\"{string|\\\"rapidjson\\\"}\", fillcolor=5]\n\t\t\tstars [label=\"{string|\\\"stars\\\"}\", fillcolor=5]\n\t\t\tten [label=\"{number|10}\", fillcolor=6]\n\t\t}\n\n\t\tedge [arrowhead=vee]\n\t\troot -> { project; stars }\n\n\t\tedge [arrowhead=\"none\"]\n\t\tproject -> rapidjson\n\t\tstars -> ten\n\t}\n\n\tsrcjson -> root [label=\" Parse()\", lhead=\"cluster1\"]\n\n\tten -> Document2 [label=\" Increase \\\"stars\\\"\", ltail=\"cluster1\" ]\n\tDocument2  -> Writer [label=\" Traverse DOM by Accept()\"]\n\tWriter -> dstjson [label=\" Output to StringBuffer\"]\n}"
  },
  {
    "path": "ext/rapidjson/doc/diagram/tutorial.dot",
    "content": "digraph {\n\tcompound=true\n\tfontname=\"Inconsolata, Consolas\"\n\tfontsize=10\n\tmargin=\"0,0\"\n\tranksep=0.2\n\tpenwidth=0.5\n\t\n\tnode [fontname=\"Inconsolata, Consolas\", fontsize=10, penwidth=0.5]\n\tedge [fontname=\"Inconsolata, Consolas\", fontsize=10]\n\n\tsubgraph cluster1 {\n\t\tmargin=\"10,10\"\n\t\tlabeljust=\"left\"\n\t\tlabel = \"Document\"\n\t\tstyle=filled\n\t\tfillcolor=gray95\n\t\tnode [shape=Mrecord, style=filled, colorscheme=spectral7]\n\t\t\n\t\troot [label=\"{object|}\", fillcolor=3]\n\n\t\t{\t\t\t\n\t\t\thello [label=\"{string|\\\"hello\\\"}\", fillcolor=5]\n\t\t\tt [label=\"{string|\\\"t\\\"}\", fillcolor=5]\n\t\t\tf [label=\"{string|\\\"f\\\"}\", fillcolor=5]\n\t\t\tn [label=\"{string|\\\"n\\\"}\", fillcolor=5]\n\t\t\ti [label=\"{string|\\\"i\\\"}\", fillcolor=5]\n\t\t\tpi [label=\"{string|\\\"pi\\\"}\", fillcolor=5]\n\t\t\ta [label=\"{string|\\\"a\\\"}\", fillcolor=5]\n\n\t\t\tworld [label=\"{string|\\\"world\\\"}\", fillcolor=5]\n\t\t\ttrue [label=\"{true|}\", fillcolor=7]\n\t\t\tfalse [label=\"{false|}\", fillcolor=2]\n\t\t\tnull [label=\"{null|}\", fillcolor=1]\n\t\t\ti1 [label=\"{number|123}\", fillcolor=6]\n\t\t\tpi1 [label=\"{number|3.1416}\", fillcolor=6]\n\t\t\tarray [label=\"{array|size=4}\", fillcolor=4]\n\n\t\t\ta1 [label=\"{number|1}\", fillcolor=6]\n\t\t\ta2 [label=\"{number|2}\", fillcolor=6]\n\t\t\ta3 [label=\"{number|3}\", fillcolor=6]\n\t\t\ta4 [label=\"{number|4}\", fillcolor=6]\n\t\t}\n\n\t\tedge [arrowhead=vee]\n\t\troot -> { hello; t; f; n; i; pi; a }\t\t\n\t\tarray -> { a1; a2; a3; a4 }\n\n\t\tedge [arrowhead=none]\n\t\thello -> world\n\t\tt -> true\n\t\tf -> false\n\t\tn -> null\n\t\ti -> i1\n\t\tpi -> pi1\n\t\ta -> array\n\t}\n}"
  },
  {
    "path": "ext/rapidjson/doc/diagram/utilityclass.dot",
    "content": "digraph {\n\trankdir=LR\n\tcompound=true\n\tfontname=\"Inconsolata, Consolas\"\n\tfontsize=10\n\tmargin=\"0,0\"\n\tranksep=0.3\n\tnodesep=0.15\n\tpenwidth=0.5\n\tcolorscheme=spectral7\n\t\n\tnode [shape=box, fontname=\"Inconsolata, Consolas\", fontsize=10, penwidth=0.5, style=filled, fillcolor=white]\n\tedge [fontname=\"Inconsolata, Consolas\", fontsize=10, penwidth=0.5]\n\n\tsubgraph cluster0 {\n\t\tstyle=filled\n\t\tfillcolor=4\n\n\t\tEncoding [label=\"<<concept>>\\nEncoding\"]\n\n\t\tedge [arrowtail=onormal, dir=back]\n\t\tEncoding -> { UTF8; UTF16; UTF32; ASCII; AutoUTF }\n\t\tUTF16 -> { UTF16LE; UTF16BE }\n\t\tUTF32 -> { UTF32LE; UTF32BE }\n\t}\n\n\tsubgraph cluster1 {\n\t\tstyle=filled\n\t\tfillcolor=5\n\n\t\tStream [label=\"<<concept>>\\nStream\"]\n\t\tInputByteStream [label=\"<<concept>>\\nInputByteStream\"]\n\t\tOutputByteStream [label=\"<<concept>>\\nOutputByteStream\"]\n\n\t\tedge [arrowtail=onormal, dir=back]\n\t\tStream -> { \n\t\t\tStringStream; InsituStringStream; StringBuffer; \n\t\t\tEncodedInputStream; EncodedOutputStream; \n\t\t\tAutoUTFInputStream; AutoUTFOutputStream \n\t\t\tInputByteStream; OutputByteStream\n\t\t}\n\n\t\tInputByteStream ->\t{ MemoryStream; FlieReadStream }\n\t\tOutputByteStream -> { MemoryBuffer; FileWriteStream } \n\t}\n\n\tsubgraph cluster2 {\n\t\tstyle=filled\n\t\tfillcolor=3\n\n\t\tAllocator [label=\"<<concept>>\\nAllocator\"]\n\n\t\tedge [arrowtail=onormal, dir=back]\n\t\tAllocator -> { CrtAllocator; MemoryPoolAllocator }\n\t}\n\n\t{\n\t\tedge [arrowtail=odiamond, arrowhead=vee, dir=both]\n\t\tEncodedInputStream -> InputByteStream\n\t\tEncodedOutputStream -> OutputByteStream\n\t\tAutoUTFInputStream -> InputByteStream\n\t\tAutoUTFOutputStream -> OutputByteStream\n\t\tMemoryPoolAllocator -> Allocator [label=\"base\", tailport=s]\n\t}\n\n\t{\n\t\tedge [arrowhead=vee, style=dashed]\n\t\tAutoUTFInputStream -> AutoUTF\n\t\tAutoUTFOutputStream -> AutoUTF\n\t}\n\n\t//UTF32LE -> Stream [style=invis]\n}"
  },
  {
    "path": "ext/rapidjson/doc/dom.md",
    "content": "# DOM\n\nDocument Object Model(DOM) is an in-memory representation of JSON for query and manipulation. The basic usage of DOM is described in [Tutorial](doc/tutorial.md). This section will describe some details and more advanced usages.\n\n[TOC]\n\n# Template {#Template}\n\nIn the tutorial,  `Value` and `Document` was used. Similarly to `std::string`, these are actually `typedef` of template classes:\n\n~~~~~~~~~~cpp\nnamespace rapidjson {\n\ntemplate <typename Encoding, typename Allocator = MemoryPoolAllocator<> >\nclass GenericValue {\n    // ...\n};\n\ntemplate <typename Encoding, typename Allocator = MemoryPoolAllocator<> >\nclass GenericDocument : public GenericValue<Encoding, Allocator> {\n    // ...\n};\n\ntypedef GenericValue<UTF8<> > Value;\ntypedef GenericDocument<UTF8<> > Document;\n\n} // namespace rapidjson\n~~~~~~~~~~\n\nUser can customize these template parameters.\n\n## Encoding {#Encoding}\n\nThe `Encoding` parameter specifies the encoding of JSON String value in memory. Possible options are `UTF8`, `UTF16`, `UTF32`. Note that, these 3 types are also template class. `UTF8<>` is `UTF8<char>`, which means using char to store the characters. You may refer to [Encoding](doc/encoding.md) for details.\n\nSuppose a Windows application would query localization strings stored in JSON files. Unicode-enabled functions in Windows use UTF-16 (wide character) encoding. No matter what encoding was used in JSON files, we can store the strings in UTF-16 in memory.\n\n~~~~~~~~~~cpp\nusing namespace rapidjson;\n\ntypedef GenericDocument<UTF16<> > WDocument;\ntypedef GenericValue<UTF16<> > WValue;\n\nFILE* fp = fopen(\"localization.json\", \"rb\"); // non-Windows use \"r\"\n\nchar readBuffer[256];\nFileReadStream bis(fp, readBuffer, sizeof(readBuffer));\n\nAutoUTFInputStream<unsigned, FileReadStream> eis(bis);  // wraps bis into eis\n\nWDocument d;\nd.ParseStream<0, AutoUTF<unsigned> >(eis);\n\nconst WValue locale(L\"ja\"); // Japanese\n\nMessageBoxW(hWnd, d[locale].GetString(), L\"Test\", MB_OK);\n~~~~~~~~~~\n\n## Allocator {#Allocator}\n\nThe `Allocator` defines which allocator class is used when allocating/deallocating memory for `Document`/`Value`. `Document` owns, or references to an `Allocator` instance. On the other hand, `Value` does not do so, in order to reduce memory consumption.\n\nThe default allocator used in `GenericDocument` is `MemoryPoolAllocator`. This allocator actually allocate memory sequentially, and cannot deallocate one by one. This is very suitable when parsing a JSON into a DOM tree.\n\nAnother allocator is `CrtAllocator`, of which CRT is short for C RunTime library. This allocator simply calls the standard `malloc()`/`realloc()`/`free()`. When there is a lot of add and remove operations, this allocator may be preferred. But this allocator is far less efficient than `MemoryPoolAllocator`.\n\n# Parsing {#Parsing}\n\n`Document` provides several functions for parsing. In below, (1) is the fundamental function, while the others are helpers which call (1).\n\n~~~~~~~~~~cpp\nusing namespace rapidjson;\n\n// (1) Fundamental\ntemplate <unsigned parseFlags, typename SourceEncoding, typename InputStream>\nGenericDocument& GenericDocument::ParseStream(InputStream& is);\n\n// (2) Using the same Encoding for stream\ntemplate <unsigned parseFlags, typename InputStream>\nGenericDocument& GenericDocument::ParseStream(InputStream& is);\n\n// (3) Using default parse flags\ntemplate <typename InputStream>\nGenericDocument& GenericDocument::ParseStream(InputStream& is);\n\n// (4) In situ parsing\ntemplate <unsigned parseFlags>\nGenericDocument& GenericDocument::ParseInsitu(Ch* str);\n\n// (5) In situ parsing, using default parse flags\nGenericDocument& GenericDocument::ParseInsitu(Ch* str);\n\n// (6) Normal parsing of a string\ntemplate <unsigned parseFlags, typename SourceEncoding>\nGenericDocument& GenericDocument::Parse(const Ch* str);\n\n// (7) Normal parsing of a string, using same Encoding of Document\ntemplate <unsigned parseFlags>\nGenericDocument& GenericDocument::Parse(const Ch* str);\n\n// (8) Normal parsing of a string, using default parse flags\nGenericDocument& GenericDocument::Parse(const Ch* str);\n~~~~~~~~~~\n\nThe examples of [tutorial](doc/tutorial.md) uses (8) for normal parsing of string. The examples of [stream](doc/stream.md) uses the first three. *In situ* parsing will be described soon.\n\nThe `parseFlags` are combination of the following bit-flags:\n\nParse flags                   | Meaning\n------------------------------|-----------------------------------\n`kParseNoFlags`               | No flag is set.\n`kParseDefaultFlags`          | Default parse flags. It is equal to macro `RAPIDJSON_PARSE_DEFAULT_FLAGS`, which is defined as `kParseNoFlags`.\n`kParseInsituFlag`            | In-situ(destructive) parsing.\n`kParseValidateEncodingFlag`  | Validate encoding of JSON strings.\n`kParseIterativeFlag`         | Iterative(constant complexity in terms of function call stack size) parsing.\n`kParseStopWhenDoneFlag`      | After parsing a complete JSON root from stream, stop further processing the rest of stream. When this flag is used, parser will not generate `kParseErrorDocumentRootNotSingular` error. Using this flag for parsing multiple JSONs in the same stream.\n`kParseFullPrecisionFlag`     | Parse number in full precision (slower). If this flag is not set, the normal precision (faster) is used. Normal precision has maximum 3 [ULP](http://en.wikipedia.org/wiki/Unit_in_the_last_place) error.\n`kParseCommentsFlag`          | Allow one-line `// ...` and multi-line `/* ... */` comments (relaxed JSON syntax).\n`kParseNumbersAsStringsFlag`  | Parse numerical type values as strings.\n`kParseTrailingCommasFlag`    | Allow trailing commas at the end of objects and arrays (relaxed JSON syntax).\n`kParseNanAndInfFlag`         | Allow parsing `NaN`, `Inf`, `Infinity`, `-Inf` and `-Infinity` as `double` values (relaxed JSON syntax).\n\nBy using a non-type template parameter, instead of a function parameter, C++ compiler can generate code which is optimized for specified combinations, improving speed, and reducing code size (if only using a single specialization). The downside is the flags needed to be determined in compile-time.\n\nThe `SourceEncoding` parameter defines what encoding is in the stream. This can be differed to the `Encoding` of the `Document`. See [Transcoding and Validation](#TranscodingAndValidation) section for details.\n\nAnd the `InputStream` is type of input stream.\n\n## Parse Error {#ParseError}\n\nWhen the parse processing succeeded, the `Document` contains the parse results. When there is an error, the original DOM is *unchanged*. And the error state of parsing can be obtained by `bool HasParseError()`,  `ParseErrorCode GetParseError()` and `size_t GetParseOffset()`.\n\nParse Error Code                            | Description\n--------------------------------------------|---------------------------------------------------\n`kParseErrorNone`                           | No error.\n`kParseErrorDocumentEmpty`                  | The document is empty.\n`kParseErrorDocumentRootNotSingular`        | The document root must not follow by other values.\n`kParseErrorValueInvalid`                   | Invalid value.\n`kParseErrorObjectMissName`                 | Missing a name for object member.\n`kParseErrorObjectMissColon`                | Missing a colon after a name of object member.\n`kParseErrorObjectMissCommaOrCurlyBracket`  | Missing a comma or `}` after an object member.\n`kParseErrorArrayMissCommaOrSquareBracket`  | Missing a comma or `]` after an array element.\n`kParseErrorStringUnicodeEscapeInvalidHex`  | Incorrect hex digit after `\\\\u` escape in string.\n`kParseErrorStringUnicodeSurrogateInvalid`  | The surrogate pair in string is invalid.\n`kParseErrorStringEscapeInvalid`            | Invalid escape character in string.\n`kParseErrorStringMissQuotationMark`        | Missing a closing quotation mark in string.\n`kParseErrorStringInvalidEncoding`          | Invalid encoding in string.\n`kParseErrorNumberTooBig`                   | Number too big to be stored in `double`.\n`kParseErrorNumberMissFraction`             | Miss fraction part in number.\n`kParseErrorNumberMissExponent`             | Miss exponent in number.\n\nThe offset of error is defined as the character number from beginning of stream. Currently RapidJSON does not keep track of line number.\n\nTo get an error message, RapidJSON provided a English messages in `rapidjson/error/en.h`. User can customize it for other locales, or use a custom localization system.\n\nHere shows an example of parse error handling.\n\n~~~~~~~~~~cpp\n#include \"rapidjson/document.h\"\n#include \"rapidjson/error/en.h\"\n\n// ...\nDocument d;\nif (d.Parse(json).HasParseError()) {\n    fprintf(stderr, \"\\nError(offset %u): %s\\n\", \n        (unsigned)d.GetErrorOffset(),\n        GetParseError_En(d.GetParseError()));\n    // ...\n}\n~~~~~~~~~~\n\n## In Situ Parsing {#InSituParsing}\n\nFrom [Wikipedia](http://en.wikipedia.org/wiki/In_situ):\n\n> *In situ* ... is a Latin phrase that translates literally to \"on site\" or \"in position\". It means \"locally\", \"on site\", \"on the premises\" or \"in place\" to describe an event where it takes place, and is used in many different contexts.\n> ...\n> (In computer science) An algorithm is said to be an in situ algorithm, or in-place algorithm, if the extra amount of memory required to execute the algorithm is O(1), that is, does not exceed a constant no matter how large the input. For example, heapsort is an in situ sorting algorithm.\n\nIn normal parsing process, a large overhead is to decode JSON strings and copy them to other buffers. *In situ* parsing decodes those JSON string at the place where it is stored. It is possible in JSON because the length of decoded string is always shorter than or equal to the one in JSON. In this context, decoding a JSON string means to process the escapes, such as `\"\\n\"`, `\"\\u1234\"`, etc., and add a null terminator (`'\\0'`)at the end of string.\n\nThe following diagrams compare normal and *in situ* parsing. The JSON string values contain pointers to the decoded string.\n\n![normal parsing](diagram/normalparsing.png)\n\nIn normal parsing, the decoded string are copied to freshly allocated buffers. `\"\\\\n\"` (2 characters) is decoded as `\"\\n\"` (1 character). `\"\\\\u0073\"` (6 characters) is decoded as `\"s\"` (1 character).\n\n![instiu parsing](diagram/insituparsing.png)\n\n*In situ* parsing just modified the original JSON. Updated characters are highlighted in the diagram. If the JSON string does not contain escape character, such as `\"msg\"`, the parsing process merely replace the closing double quotation mark with a null character.\n\nSince *in situ* parsing modify the input, the parsing API needs `char*` instead of `const char*`.\n\n~~~~~~~~~~cpp\n// Read whole file into a buffer\nFILE* fp = fopen(\"test.json\", \"r\");\nfseek(fp, 0, SEEK_END);\nsize_t filesize = (size_t)ftell(fp);\nfseek(fp, 0, SEEK_SET);\nchar* buffer = (char*)malloc(filesize + 1);\nsize_t readLength = fread(buffer, 1, filesize, fp);\nbuffer[readLength] = '\\0';\nfclose(fp);\n\n// In situ parsing the buffer into d, buffer will also be modified\nDocument d;\nd.ParseInsitu(buffer);\n\n// Query/manipulate the DOM here...\n\nfree(buffer);\n// Note: At this point, d may have dangling pointers pointed to the deallocated buffer.\n~~~~~~~~~~\n\nThe JSON strings are marked as const-string. But they may not be really \"constant\". The life cycle of it depends on the JSON buffer.\n\nIn situ parsing minimizes allocation overheads and memory copying. Generally this improves cache coherence, which is an important factor of performance in modern computer.\n\nThere are some limitations of *in situ* parsing:\n\n1. The whole JSON is in memory.\n2. The source encoding in stream and target encoding in document must be the same.\n3. The buffer need to be retained until the document is no longer used.\n4. If the DOM need to be used for long period after parsing, and there are few JSON strings in the DOM, retaining the buffer may be a memory waste.\n\n*In situ* parsing is mostly suitable for short-term JSON that only need to be processed once, and then be released from memory. In practice, these situation is very common, for example, deserializing JSON to C++ objects, processing web requests represented in JSON, etc.\n\n## Transcoding and Validation {#TranscodingAndValidation}\n\nRapidJSON supports conversion between Unicode formats (officially termed UCS Transformation Format) internally. During DOM parsing, the source encoding of the stream can be different from the encoding of the DOM. For example, the source stream contains a UTF-8 JSON, while the DOM is using UTF-16 encoding. There is an example code in [EncodedInputStream](doc/stream.md).\n\nWhen writing a JSON from DOM to output stream, transcoding can also be used. An example is in [EncodedOutputStream](doc/stream.md).\n\nDuring transcoding, the source string is decoded to into Unicode code points, and then the code points are encoded in the target format. During decoding, it will validate the byte sequence in the source string. If it is not a valid sequence, the parser will be stopped with `kParseErrorStringInvalidEncoding` error.\n\nWhen the source encoding of stream is the same as encoding of DOM, by default, the parser will *not* validate the sequence. User may use `kParseValidateEncodingFlag` to force validation.\n\n# Techniques {#Techniques}\n\nSome techniques about using DOM API is discussed here.\n\n## DOM as SAX Event Publisher\n\nIn RapidJSON, stringifying a DOM with `Writer` may be look a little bit weired.\n\n~~~~~~~~~~cpp\n// ...\nWriter<StringBuffer> writer(buffer);\nd.Accept(writer);\n~~~~~~~~~~\n\nActually, `Value::Accept()` is responsible for publishing SAX events about the value to the handler. With this design, `Value` and `Writer` are decoupled. `Value` can generate SAX events, and `Writer` can handle those events.\n\nUser may create custom handlers for transforming the DOM into other formats. For example, a handler which converts the DOM into XML.\n\nFor more about SAX events and handler, please refer to [SAX](doc/sax.md).\n\n## User Buffer {#UserBuffer}\n\nSome applications may try to avoid memory allocations whenever possible.\n\n`MemoryPoolAllocator` can support this by letting user to provide a buffer. The buffer can be on the program stack, or a \"scratch buffer\" which is statically allocated (a static/global array) for storing temporary data.\n\n`MemoryPoolAllocator` will use the user buffer to satisfy allocations. When the user buffer is used up, it will allocate a chunk of memory from the base allocator (by default the `CrtAllocator`).\n\nHere is an example of using stack memory. The first allocator is for storing values, while the second allocator is for storing temporary data during parsing.\n\n~~~~~~~~~~cpp\ntypedef GenericDocument<UTF8<>, MemoryPoolAllocator<>, MemoryPoolAllocator<>> DocumentType;\nchar valueBuffer[4096];\nchar parseBuffer[1024];\nMemoryPoolAllocator<> valueAllocator(valueBuffer, sizeof(valueBuffer));\nMemoryPoolAllocator<> parseAllocator(parseBuffer, sizeof(parseBuffer));\nDocumentType d(&valueAllocator, sizeof(parseBuffer), &parseAllocator);\nd.Parse(json);\n~~~~~~~~~~\n\nIf the total size of allocation is less than 4096+1024 bytes during parsing, this code does not invoke any heap allocation (via `new` or `malloc()`) at all.\n\nUser can query the current memory consumption in bytes via `MemoryPoolAllocator::Size()`. And then user can determine a suitable size of user buffer.\n"
  },
  {
    "path": "ext/rapidjson/doc/dom.zh-cn.md",
    "content": "# DOM\n\n文档对象模型（Document Object Model, DOM）是一种罝于内存中的 JSON 表示方式，以供查询及操作。我们己于 [教程](doc/tutorial.zh-cn.md) 中介绍了 DOM 的基本用法，本节将讲述一些细节及高级用法。\n\n[TOC]\n\n# 模板 {#Template}\n\n教程中使用了 `Value` 和 `Document` 类型。与 `std::string` 相似，这些类型其实是两个模板类的 `typedef`：\n\n~~~~~~~~~~cpp\nnamespace rapidjson {\n\ntemplate <typename Encoding, typename Allocator = MemoryPoolAllocator<> >\nclass GenericValue {\n    // ...\n};\n\ntemplate <typename Encoding, typename Allocator = MemoryPoolAllocator<> >\nclass GenericDocument : public GenericValue<Encoding, Allocator> {\n    // ...\n};\n\ntypedef GenericValue<UTF8<> > Value;\ntypedef GenericDocument<UTF8<> > Document;\n\n} // namespace rapidjson\n~~~~~~~~~~\n\n使用者可以自定义这些模板参数。\n\n## 编码 {#Encoding}\n\n`Encoding` 参数指明在内存中的 JSON String 使用哪种编码。可行的选项有 `UTF8`、`UTF16`、`UTF32`。要注意这 3 个类型其实也是模板类。`UTF8<>` 等同 `UTF8<char>`，这代表它使用 `char` 来存储字符串。更多细节可以参考 [编码](doc/encoding.zh-cn.md)。\n\n这里是一个例子。假设一个 Windows 应用软件希望查询存储于 JSON 中的本地化字符串。Windows 中含 Unicode 的函数使用 UTF-16（宽字符）编码。无论 JSON 文件使用哪种编码，我们都可以把字符串以 UTF-16 形式存储在内存。\n\n~~~~~~~~~~cpp\nusing namespace rapidjson;\n\ntypedef GenericDocument<UTF16<> > WDocument;\ntypedef GenericValue<UTF16<> > WValue;\n\nFILE* fp = fopen(\"localization.json\", \"rb\"); // 非 Windows 平台使用 \"r\"\n\nchar readBuffer[256];\nFileReadStream bis(fp, readBuffer, sizeof(readBuffer));\n\nAutoUTFInputStream<unsigned, FileReadStream> eis(bis);  // 包装 bis 成 eis\n\nWDocument d;\nd.ParseStream<0, AutoUTF<unsigned> >(eis);\n\nconst WValue locale(L\"ja\"); // Japanese\n\nMessageBoxW(hWnd, d[locale].GetString(), L\"Test\", MB_OK);\n~~~~~~~~~~\n\n## 分配器 {#Allocator}\n\n`Allocator` 定义当 `Document`/`Value` 分配或释放内存时使用那个分配类。`Document` 拥有或引用到一个 `Allocator` 实例。而为了节省内存，`Value` 没有这么做。\n\n`GenericDocument` 的缺省分配器是 `MemoryPoolAllocator`。此分配器实际上会顺序地分配内存，并且不能逐一释放。当要解析一个 JSON 并生成 DOM，这种分配器是非常合适的。\n\nRapidJSON 还提供另一个分配器 `CrtAllocator`，当中 CRT 是 C 运行库（C RunTime library）的缩写。此分配器简单地读用标准的 `malloc()`/`realloc()`/`free()`。当我们需要许多增减操作，这种分配器会更为适合。然而这种分配器远远比 `MemoryPoolAllocator` 低效。\n\n# 解析 {#Parsing}\n\n`Document` 提供几个解析函数。以下的 (1) 是根本的函数，其他都是调用 (1) 的协助函数。\n\n~~~~~~~~~~cpp\nusing namespace rapidjson;\n\n// (1) 根本\ntemplate <unsigned parseFlags, typename SourceEncoding, typename InputStream>\nGenericDocument& GenericDocument::ParseStream(InputStream& is);\n\n// (2) 使用流的编码\ntemplate <unsigned parseFlags, typename InputStream>\nGenericDocument& GenericDocument::ParseStream(InputStream& is);\n\n// (3) 使用缺省标志\ntemplate <typename InputStream>\nGenericDocument& GenericDocument::ParseStream(InputStream& is);\n\n// (4) 原位解析\ntemplate <unsigned parseFlags>\nGenericDocument& GenericDocument::ParseInsitu(Ch* str);\n\n// (5) 原位解析，使用缺省标志\nGenericDocument& GenericDocument::ParseInsitu(Ch* str);\n\n// (6) 正常解析一个字符串\ntemplate <unsigned parseFlags, typename SourceEncoding>\nGenericDocument& GenericDocument::Parse(const Ch* str);\n\n// (7) 正常解析一个字符串，使用 Document 的编码\ntemplate <unsigned parseFlags>\nGenericDocument& GenericDocument::Parse(const Ch* str);\n\n// (8) 正常解析一个字符串，使用缺省标志\nGenericDocument& GenericDocument::Parse(const Ch* str);\n~~~~~~~~~~\n\n[教程](doc/tutorial.zh-cn.md) 中的例使用 (8) 去正常解析字符串。而 [流](doc/stream.zh-cn.md) 的例子使用前 3 个函数。我们将稍后介绍原位（*In situ*） 解析。\n\n`parseFlags` 是以下位标置的组合：\n\n解析位标志                    | 意义\n------------------------------|-----------------------------------\n`kParseNoFlags`               | 没有任何标志。\n`kParseDefaultFlags`          | 缺省的解析选项。它等于 `RAPIDJSON_PARSE_DEFAULT_FLAGS` 宏，此宏定义为 `kParseNoFlags`。\n`kParseInsituFlag`            | 原位（破坏性）解析。\n`kParseValidateEncodingFlag`  | 校验 JSON 字符串的编码。\n`kParseIterativeFlag`         | 迭代式（调用堆栈大小为常数复杂度）解析。\n`kParseStopWhenDoneFlag`      | 当从流解析了一个完整的 JSON 根节点之后，停止继续处理余下的流。当使用了此标志，解析器便不会产生 `kParseErrorDocumentRootNotSingular` 错误。可使用本标志去解析同一个流里的多个 JSON。\n`kParseFullPrecisionFlag`     | 使用完整的精确度去解析数字（较慢）。如不设置此标节，则会使用正常的精确度（较快）。正常精确度会有最多 3 个 [ULP](http://en.wikipedia.org/wiki/Unit_in_the_last_place) 的误差。\n`kParseCommentsFlag`          | 容许单行 `// ...` 及多行 `/* ... */` 注释（放宽的 JSON 语法）。\n`kParseNumbersAsStringsFlag`  | 把数字类型解析成字符串。\n`kParseTrailingCommasFlag`    | 容许在对象和数组结束前含有逗号（放宽的 JSON 语法）。\n`kParseNanAndInfFlag`         | 容许 `NaN`、`Inf`、`Infinity`、`-Inf` 及 `-Infinity` 作为 `double` 值（放宽的 JSON 语法）。\n\n由于使用了非类型模板参数，而不是函数参数，C++ 编译器能为个别组合生成代码，以改善性能及减少代码尺寸（当只用单种特化）。缺点是需要在编译期决定标志。\n\n`SourceEncoding` 参数定义流使用了什么编码。这与 `Document` 的 `Encoding` 不相同。细节可参考 [转码和校验](#TranscodingAndValidation) 一节。\n\n此外 `InputStream` 是输入流的类型。\n\n## 解析错误 {#ParseError}\n\n当解析过程顺利完成，`Document` 便会含有解析结果。当过程出现错误，原来的 DOM 会 * 维持不便 *。可使用 `bool HasParseError()`、`ParseErrorCode GetParseError()` 及 `size_t GetParseOffset()` 获取解析的错误状态。\n\n解析错误代号                                | 描述\n--------------------------------------------|---------------------------------------------------\n`kParseErrorNone`                           | 无错误。\n`kParseErrorDocumentEmpty`                  | 文档是空的。\n`kParseErrorDocumentRootNotSingular`        | 文档的根后面不能有其它值。\n`kParseErrorValueInvalid`                   | 不合法的值。\n`kParseErrorObjectMissName`                 | Object 成员缺少名字。\n`kParseErrorObjectMissColon`                | Object 成员名字后缺少冒号。\n`kParseErrorObjectMissCommaOrCurlyBracket`  | Object 成员后缺少逗号或 `}`。\n`kParseErrorArrayMissCommaOrSquareBracket`  | Array 元素后缺少逗号或 `]` 。\n`kParseErrorStringUnicodeEscapeInvalidHex`  | String 中的 `\\\\u` 转义符后含非十六进位数字。\n`kParseErrorStringUnicodeSurrogateInvalid`  | String 中的代理对（surrogate pair）不合法。\n`kParseErrorStringEscapeInvalid`            | String 含非法转义字符。\n`kParseErrorStringMissQuotationMark`        | String 缺少关闭引号。\n`kParseErrorStringInvalidEncoding`          | String 含非法编码。\n`kParseErrorNumberTooBig`                   | Number 的值太大，不能存储于 `double`。\n`kParseErrorNumberMissFraction`             | Number 缺少了小数部分。\n`kParseErrorNumberMissExponent`             | Number 缺少了指数。\n\n错误的偏移量定义为从流开始至错误处的字符数量。目前 RapidJSON 不记录错误行号。\n\n要取得错误讯息，RapidJSON 在 `rapidjson/error/en.h` 中提供了英文错误讯息。使用者可以修改它用于其他语言环境，或使用一个自定义的本地化系统。\n\n以下是一个处理错误的例子。\n\n~~~~~~~~~~cpp\n#include \"rapidjson/document.h\"\n#include \"rapidjson/error/en.h\"\n\n// ...\nDocument d;\nif (d.Parse(json).HasParseError()) {\n    fprintf(stderr, \"\\nError(offset %u): %s\\n\", \n        (unsigned)d.GetErrorOffset(),\n        GetParseError_En(d.GetParseErrorCode()));\n    // ...\n}\n~~~~~~~~~~\n\n## 原位解析 {#InSituParsing}\n\n根据 [维基百科](http://en.wikipedia.org/wiki/In_situ):\n\n> *In situ* ... is a Latin phrase that translates literally to \"on site\" or \"in position\". It means \"locally\", \"on site\", \"on the premises\" or \"in place\" to describe an event where it takes place, and is used in many different contexts.\n> ...\n> (In computer science) An algorithm is said to be an in situ algorithm, or in-place algorithm, if the extra amount of memory required to execute the algorithm is O(1), that is, does not exceed a constant no matter how large the input. For example, heapsort is an in situ sorting algorithm.\n\n> 翻译：*In situ*……是一个拉丁文片语，字面上的意思是指「现场」、「在位置」。在许多不同语境中，它描述一个事件发生的位置，意指「本地」、「现场」、「在处所」、「就位」。\n> ……\n> （在计算机科学中）一个算法若称为原位算法，或在位算法，是指执行该算法所需的额外内存空间是 O(1) 的，换句话说，无论输入大小都只需要常数空间。例如，堆排序是一个原位排序算法。\n\n在正常的解析过程中，对 JSON string 解码并复制至其他缓冲区是一个很大的开销。原位解析（*in situ* parsing）把这些 JSON string 直接解码于它原来存储的地方。由于解码后的 string 长度总是短于或等于原来储存于 JSON 的 string，所以这是可行的。在这个语境下，对 JSON string 进行解码是指处理转义符，如 `\"\\n\"`、`\"\\u1234\"` 等，以及在 string 末端加入空终止符号 (`'\\0'`)。\n\n以下的图比较正常及原位解析。JSON string 值包含指向解码后的字符串。\n\n![正常解析](diagram/normalparsing.png)\n\n在正常解析中，解码后的字符串被复制至全新分配的缓冲区中。`\"\\\\n\"`（2 个字符）被解码成 `\"\\n\"`（1 个字符）。`\"\\\\u0073\"`（6 个字符）被解码成 `\"s\"`（1 个字符）。\n\n![原位解析](diagram/insituparsing.png)\n\n原位解析直接修改了原来的 JSON。图中高亮了被更新的字符。若 JSON string 不含转义符，例如 `\"msg\"`，那么解析过程仅仅是以空字符代替结束双引号。\n\n由于原位解析修改了输入，其解析 API 需要 `char*` 而非 `const char*`。\n\n~~~~~~~~~~cpp\n// 把整个文件读入 buffer\nFILE* fp = fopen(\"test.json\", \"r\");\nfseek(fp, 0, SEEK_END);\nsize_t filesize = (size_t)ftell(fp);\nfseek(fp, 0, SEEK_SET);\nchar* buffer = (char*)malloc(filesize + 1);\nsize_t readLength = fread(buffer, 1, filesize, fp);\nbuffer[readLength] = '\\0';\nfclose(fp);\n\n// 原位解析 buffer 至 d，buffer 内容会被修改。\nDocument d;\nd.ParseInsitu(buffer);\n\n// 在此查询、修改 DOM……\n\nfree(buffer);\n// 注意：在这个位置，d 可能含有指向已被释放的 buffer 的悬空指针\n~~~~~~~~~~\n\nJSON string 会被打上 const-string 的标志。但它们可能并非真正的「常数」。它的生命周期取决于存储 JSON 的缓冲区。\n\n原位解析把分配开销及内存复制减至最小。通常这样做能改善缓存一致性，而这对现代计算机来说是一个重要的性能因素。\n\n原位解析有以下限制：\n\n1. 整个 JSON 须存储在内存之中。\n2. 流的来源缓码与文档的目标编码必须相同。\n3. 需要保留缓冲区，直至文档不再被使用。\n4. 若 DOM 需要在解析后被长期使用，而 DOM 内只有很少 JSON string，保留缓冲区可能造成内存浪费。\n\n原位解析最适合用于短期的、用完即弃的 JSON。实际应用中，这些场合是非常普遍的，例如反序列化 JSON 至 C++ 对象、处理以 JSON 表示的 web 请求等。\n\n## 转码与校验 {#TranscodingAndValidation}\n\nRapidJSON 内部支持不同 Unicode 格式（正式的术语是 UCS 变换格式）间的转换。在 DOM 解析时，流的来源编码与 DOM 的编码可以不同。例如，来源流可能含有 UTF-8 的 JSON，而 DOM 则使用 UTF-16 编码。在 [EncodedInputStream](doc/stream.zh-cn.md) 一节里有一个例子。\n\n当从 DOM 输出一个 JSON 至输出流之时，也可以使用转码功能。在 [EncodedOutputStream](doc/stream.zh-cn.md) 一节里有一个例子。\n\n在转码过程中，会把来源 string 解码成 Unicode 码点，然后把码点编码成目标格式。在解码时，它会校验来源 string 的字节序列是否合法。若遇上非合法序列，解析器会停止并返回 `kParseErrorStringInvalidEncoding` 错误。\n\n当来源编码与 DOM 的编码相同，解析器缺省地 * 不会 * 校验序列。使用者可开启 `kParseValidateEncodingFlag` 去强制校验。\n\n# 技巧 {#Techniques}\n\n这里讨论一些 DOM API 的使用技巧。\n\n## 把 DOM 作为 SAX 事件发表者\n\n在 RapidJSON 中，利用 `Writer` 把 DOM 生成 JSON 的做法，看来有点奇怪。\n\n~~~~~~~~~~cpp\n// ...\nWriter<StringBuffer> writer(buffer);\nd.Accept(writer);\n~~~~~~~~~~\n\n实际上，`Value::Accept()` 是负责发布该值相关的 SAX 事件至处理器的。通过这个设计，`Value` 及 `Writer` 解除了偶合。`Value` 可生成 SAX 事件，而 `Writer` 则可以处理这些事件。\n\n使用者可以创建自定义的处理器，去把 DOM 转换成其它格式。例如，一个把 DOM 转换成 XML 的处理器。\n\n要知道更多关于 SAX 事件与处理器，可参阅 [SAX](doc/sax.zh-cn.md)。\n\n## 使用者缓冲区 {#UserBuffer}\n\n许多应用软件可能需要尽量减少内存分配。\n\n`MemoryPoolAllocator` 可以帮助这方面，它容许使用者提供一个缓冲区。该缓冲区可能置于程序堆栈，或是一个静态分配的「草稿缓冲区（scratch buffer）」（一个静态／全局的数组），用于储存临时数据。\n\n`MemoryPoolAllocator` 会先用使用者缓冲区去解决分配请求。当使用者缓冲区用完，就会从基础分配器（缺省为 `CrtAllocator`）分配一块内存。\n\n以下是使用堆栈内存的例子，第一个分配器用于存储值，第二个用于解析时的临时缓冲。\n\n~~~~~~~~~~cpp\ntypedef GenericDocument<UTF8<>, MemoryPoolAllocator<>, MemoryPoolAllocator<>> DocumentType;\nchar valueBuffer[4096];\nchar parseBuffer[1024];\nMemoryPoolAllocator<> valueAllocator(valueBuffer, sizeof(valueBuffer));\nMemoryPoolAllocator<> parseAllocator(parseBuffer, sizeof(parseBuffer));\nDocumentType d(&valueAllocator, sizeof(parseBuffer), &parseAllocator);\nd.Parse(json);\n~~~~~~~~~~\n\n若解析时分配总量少于 4096+1024 字节时，这段代码不会造成任何堆内存分配（经 `new` 或 `malloc()`）。\n\n使用者可以通过 `MemoryPoolAllocator::Size()` 查询当前已分的内存大小。那么使用者可以拟定使用者缓冲区的合适大小。\n"
  },
  {
    "path": "ext/rapidjson/doc/encoding.md",
    "content": "# Encoding\n\nAccording to [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf),\n\n> (in Introduction) JSON text is a sequence of Unicode code points.\n\nThe earlier [RFC4627](http://www.ietf.org/rfc/rfc4627.txt) stated that,\n\n> (in §3) JSON text SHALL be encoded in Unicode.  The default encoding is UTF-8.\n\n> (in §6) JSON may be represented using UTF-8, UTF-16, or UTF-32. When JSON is written in UTF-8, JSON is 8bit compatible.  When JSON is written in UTF-16 or UTF-32, the binary content-transfer-encoding must be used.\n\nRapidJSON supports various encodings. It can also validate the encodings of JSON, and transconding JSON among encodings. All these features are implemented internally, without the need for external libraries (e.g. [ICU](http://site.icu-project.org/)).\n\n[TOC]\n\n# Unicode {#Unicode}\nFrom [Unicode's official website](http://www.unicode.org/standard/WhatIsUnicode.html):\n> Unicode provides a unique number for every character, \n> no matter what the platform,\n> no matter what the program,\n> no matter what the language.\n\nThose unique numbers are called code points, which is in the range `0x0` to `0x10FFFF`.\n\n## Unicode Transformation Format {#UTF}\n\nThere are various encodings for storing Unicode code points. These are called Unicode Transformation Format (UTF). RapidJSON supports the most commonly used UTFs, including\n\n* UTF-8: 8-bit variable-width encoding. It maps a code point to 1–4 bytes.\n* UTF-16: 16-bit variable-width encoding. It maps a code point to 1–2 16-bit code units (i.e., 2–4 bytes).\n* UTF-32: 32-bit fixed-width encoding. It directly maps a code point to a single 32-bit code unit (i.e. 4 bytes).\n\nFor UTF-16 and UTF-32, the byte order (endianness) does matter. Within computer memory, they are often stored in the computer's endianness. However, when it is stored in file or transferred over network, we need to state the byte order of the byte sequence, either little-endian (LE) or big-endian (BE). \n\nRapidJSON provide these encodings via the structs in `rapidjson/encodings.h`:\n\n~~~~~~~~~~cpp\nnamespace rapidjson {\n\ntemplate<typename CharType = char>\nstruct UTF8;\n\ntemplate<typename CharType = wchar_t>\nstruct UTF16;\n\ntemplate<typename CharType = wchar_t>\nstruct UTF16LE;\n\ntemplate<typename CharType = wchar_t>\nstruct UTF16BE;\n\ntemplate<typename CharType = unsigned>\nstruct UTF32;\n\ntemplate<typename CharType = unsigned>\nstruct UTF32LE;\n\ntemplate<typename CharType = unsigned>\nstruct UTF32BE;\n\n} // namespace rapidjson\n~~~~~~~~~~\n\nFor processing text in memory, we normally use `UTF8`, `UTF16` or `UTF32`. For processing text via I/O, we may use `UTF8`, `UTF16LE`, `UTF16BE`, `UTF32LE` or `UTF32BE`.\n\nWhen using the DOM-style API, the `Encoding` template parameter in `GenericValue<Encoding>` and `GenericDocument<Encoding>` indicates the encoding to be used to represent JSON string in memory. So normally we will use `UTF8`, `UTF16` or `UTF32` for this template parameter. The choice depends on operating systems and other libraries that the application is using. For example, Windows API represents Unicode characters in UTF-16, while most Linux distributions and applications prefer UTF-8.\n\nExample of UTF-16 DOM declaration:\n\n~~~~~~~~~~cpp\ntypedef GenericDocument<UTF16<> > WDocument;\ntypedef GenericValue<UTF16<> > WValue;\n~~~~~~~~~~\n\nFor a detail example, please check the example in [DOM's Encoding](doc/stream.md) section.\n\n## Character Type {#CharacterType}\n\nAs shown in the declaration, each encoding has a `CharType` template parameter. Actually, it may be a little bit confusing, but each `CharType` stores a code unit, not a character (code point). As mentioned in previous section, a code point may be encoded to 1–4 code units for UTF-8.\n\nFor `UTF16(LE|BE)`, `UTF32(LE|BE)`, the `CharType` must be integer type of at least 2 and 4 bytes  respectively.\n\nNote that C++11 introduces `char16_t` and `char32_t`, which can be used for `UTF16` and `UTF32` respectively.\n\n## AutoUTF {#AutoUTF}\n\nPrevious encodings are statically bound in compile-time. In other words, user must know exactly which encodings will be used in the memory or streams. However, sometimes we may need to read/write files of different encodings. The encoding needed to be decided in runtime.\n\n`AutoUTF` is an encoding designed for this purpose. It chooses which encoding to be used according to the input or output stream. Currently, it should be used with `EncodedInputStream` and `EncodedOutputStream`.\n\n## ASCII {#ASCII}\n\nAlthough the JSON standards did not mention about [ASCII](http://en.wikipedia.org/wiki/ASCII), sometimes we would like to write 7-bit ASCII JSON for applications that cannot handle UTF-8. Since any JSON can represent unicode characters in escaped sequence `\\uXXXX`, JSON can always be encoded in ASCII.\n\nHere is an example for writing a UTF-8 DOM into ASCII:\n\n~~~~~~~~~~cpp\nusing namespace rapidjson;\nDocument d; // UTF8<>\n// ...\nStringBuffer buffer;\nWriter<StringBuffer, Document::EncodingType, ASCII<> > writer(buffer);\nd.Accept(writer);\nstd::cout << buffer.GetString();\n~~~~~~~~~~\n\nASCII can be used in input stream. If the input stream contains bytes with values above 127, it will cause `kParseErrorStringInvalidEncoding` error.\n\nASCII *cannot* be used in memory (encoding of `Document` or target encoding of `Reader`), as it cannot represent Unicode code points.\n\n# Validation & Transcoding {#ValidationTranscoding}\n\nWhen RapidJSON parses a JSON, it can validate the input JSON, whether it is a valid sequence of a specified encoding. This option can be turned on by adding `kParseValidateEncodingFlag` in `parseFlags` template parameter.\n\nIf the input encoding and output encoding is different, `Reader` and `Writer` will automatically transcode (convert) the text. In this case, `kParseValidateEncodingFlag` is not necessary, as it must decode the input sequence. And if the sequence was unable to be decoded, it must be invalid.\n\n## Transcoder {#Transcoder}\n\nAlthough the encoding functions in RapidJSON are designed for JSON parsing/generation, user may abuse them for transcoding of non-JSON strings.\n\nHere is an example for transcoding a string from UTF-8 to UTF-16:\n\n~~~~~~~~~~cpp\n#include \"rapidjson/encodings.h\"\n\nusing namespace rapidjson;\n\nconst char* s = \"...\"; // UTF-8 string\nStringStream source(s);\nGenericStringBuffer<UTF16<> > target;\n\nbool hasError = false;\nwhile (source.Peek() != '\\0')\n    if (!Transcoder<UTF8<>, UTF16<> >::Transcode(source, target)) {\n        hasError = true;\n        break;\n    }\n\nif (!hasError) {\n    const wchar_t* t = target.GetString();\n    // ...\n}\n~~~~~~~~~~\n\nYou may also use `AutoUTF` and the associated streams for setting source/target encoding in runtime.\n"
  },
  {
    "path": "ext/rapidjson/doc/encoding.zh-cn.md",
    "content": "# 编码\n\n根据 [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf)：\n\n> (in Introduction) JSON text is a sequence of Unicode code points.\n> \n> 翻译：JSON 文本是 Unicode 码点的序列。\n\n较早的 [RFC4627](http://www.ietf.org/rfc/rfc4627.txt) 申明：\n\n> (in §3) JSON text SHALL be encoded in Unicode.  The default encoding is UTF-8.\n> \n> 翻译：JSON 文本应该以 Unicode 编码。缺省的编码为 UTF-8。\n\n> (in §6) JSON may be represented using UTF-8, UTF-16, or UTF-32. When JSON is written in UTF-8, JSON is 8bit compatible.  When JSON is written in UTF-16 or UTF-32, the binary content-transfer-encoding must be used.\n> \n> 翻译：JSON 可使用 UTF-8、UTF-16 或 UTF-18 表示。当 JSON 以 UTF-8 写入，该 JSON 是 8 位兼容的。当 JSON 以 UTF-16 或 UTF-32 写入，就必须使用二进制的内容传送编码。\n\nRapidJSON 支持多种编码。它也能检查 JSON 的编码，以及在不同编码中进行转码。所有这些功能都是在内部实现，无需使用外部的程序库（如 [ICU](http://site.icu-project.org/)）。\n\n[TOC]\n\n# Unicode {#Unicode}\n根据 [Unicode 的官方网站](http://www.unicode.org/standard/translations/t-chinese.html)：\n>Unicode 给每个字符提供了一个唯一的数字，\n不论是什么平台、\n不论是什么程序、\n不论是什么语言。\n\n这些唯一数字称为码点（code point），其范围介乎 `0x0` 至 `0x10FFFF` 之间。\n\n## Unicode 转换格式 {#UTF}\n\n存储 Unicode 码点有多种编码方式。这些称为 Unicode 转换格式（Unicode Transformation Format, UTF）。RapidJSON 支持最常用的 UTF，包括：\n\n* UTF-8：8 位可变长度编码。它把一个码点映射至 1 至 4 个字节。\n* UTF-16：16 位可变长度编码。它把一个码点映射至 1 至 2 个 16 位编码单元（即 2 至 4 个字节）。\n* UTF-32：32 位固定长度编码。它直接把码点映射至单个 32 位编码单元（即 4 字节）。\n\n对于 UTF-16 及 UTF-32 来说，字节序（endianness）是有影响的。在内存中，它们通常都是以该计算机的字节序来存储。然而，当要储存在文件中或在网上传输，我们需要指明字节序列的字节序，是小端（little endian, LE）还是大端（big-endian, BE）。 \n\nRapidJSON 通过 `rapidjson/encodings.h` 中的 struct 去提供各种编码：\n\n~~~~~~~~~~cpp\nnamespace rapidjson {\n\ntemplate<typename CharType = char>\nstruct UTF8;\n\ntemplate<typename CharType = wchar_t>\nstruct UTF16;\n\ntemplate<typename CharType = wchar_t>\nstruct UTF16LE;\n\ntemplate<typename CharType = wchar_t>\nstruct UTF16BE;\n\ntemplate<typename CharType = unsigned>\nstruct UTF32;\n\ntemplate<typename CharType = unsigned>\nstruct UTF32LE;\n\ntemplate<typename CharType = unsigned>\nstruct UTF32BE;\n\n} // namespace rapidjson\n~~~~~~~~~~\n\n对于在内存中的文本，我们正常会使用 `UTF8`、`UTF16` 或 `UTF32`。对于处理经过 I/O 的文本，我们可使用 `UTF8`、`UTF16LE`、`UTF16BE`、`UTF32LE` 或 `UTF32BE`。\n\n当使用 DOM 风格的 API，`GenericValue<Encoding>` 及 `GenericDocument<Encoding>` 里的 `Encoding` 模板参数是用于指明内存中存储的 JSON 字符串使用哪种编码。因此通常我们会在此参数中使用 `UTF8`、`UTF16` 或 `UTF32`。如何选择，视乎应用软件所使用的操作系统及其他程序库。例如，Windows API 使用 UTF-16 表示 Unicode 字符，而多数的 Linux 发行版本及应用软件则更喜欢 UTF-8。\n\n使用 UTF-16 的 DOM 声明例子：\n\n~~~~~~~~~~cpp\ntypedef GenericDocument<UTF16<> > WDocument;\ntypedef GenericValue<UTF16<> > WValue;\n~~~~~~~~~~\n\n可以在 [DOM's Encoding](doc/stream.zh-cn.md) 一节看到更详细的使用例子。\n\n## 字符类型 {#CharacterType}\n\n从之前的声明中可以看到，每个编码都有一个 `CharType` 模板参数。这可能比较容易混淆，实际上，每个 `CharType` 存储一个编码单元，而不是一个字符（码点）。如之前所谈及，在 UTF-8 中一个码点可能会编码成 1 至 4 个编码单元。\n\n对于 `UTF16(LE|BE)` 及 `UTF32(LE|BE)` 来说，`CharType` 必须分别是一个至少 2 及 4 字节的整数类型。\n\n注意 C++11 新添了 `char16_t` 及 `char32_t` 类型，也可分别用于 `UTF16` 及 `UTF32`。\n\n## AutoUTF {#AutoUTF}\n\n上述所介绍的编码都是在编译期静态挷定的。换句话说，使用者必须知道内存或流之中使用了哪种编码。然而，有时候我们可能需要读写不同编码的文件，而且这些编码需要在运行时才能决定。\n\n`AutoUTF` 是为此而设计的编码。它根据输入或输出流来选择使用哪种编码。目前它应该与 `EncodedInputStream` 及 `EncodedOutputStream` 结合使用。\n\n## ASCII {#ASCII}\n\n虽然 JSON 标准并未提及 [ASCII](http://en.wikipedia.org/wiki/ASCII)，有时候我们希望写入 7 位的 ASCII JSON，以供未能处理 UTF-8 的应用程序使用。由于任 JSON 都可以把 Unicode 字符表示为 `\\uXXXX` 转义序列，JSON 总是可用 ASCII 来编码。\n\n以下的例子把 UTF-8 的 DOM 写成 ASCII 的 JSON：\n\n~~~~~~~~~~cpp\nusing namespace rapidjson;\nDocument d; // UTF8<>\n// ...\nStringBuffer buffer;\nWriter<StringBuffer, Document::EncodingType, ASCII<> > writer(buffer);\nd.Accept(writer);\nstd::cout << buffer.GetString();\n~~~~~~~~~~\n\nASCII 可用于输入流。当输入流包含大于 127 的字节，就会导致 `kParseErrorStringInvalidEncoding` 错误。\n\nASCII * 不能 * 用于内存（`Document` 的编码，或 `Reader` 的目标编码)，因为它不能表示 Unicode 码点。\n\n# 校验及转码 {#ValidationTranscoding}\n\n当 RapidJSON 解析一个 JSON 时，它能校验输入 JSON，判断它是否所标明编码的合法序列。要开启此选项，请把 `kParseValidateEncodingFlag` 加入 `parseFlags` 模板参数。\n\n若输入编码和输出编码并不相同，`Reader` 及 `Writer` 会算把文本转码。在这种情况下，并不需要 `kParseValidateEncodingFlag`，因为它必须解码输入序列。若序列不能被解码，它必然是不合法的。\n\n## 转码器 {#Transcoder}\n\n虽然 RapidJSON 的编码功能是为 JSON 解析／生成而设计，使用者也可以“滥用”它们来为非 JSON 字符串转码。\n\n以下的例子把 UTF-8 字符串转码成 UTF-16：\n\n~~~~~~~~~~cpp\n#include \"rapidjson/encodings.h\"\n\nusing namespace rapidjson;\n\nconst char* s = \"...\"; // UTF-8 string\nStringStream source(s);\nGenericStringBuffer<UTF16<> > target;\n\nbool hasError = false;\nwhile (source.Peek() != '\\0')\n    if (!Transcoder<UTF8<>, UTF16<> >::Transcode(source, target)) {\n        hasError = true;\n        break;\n    }\n\nif (!hasError) {\n    const wchar_t* t = target.GetString();\n    // ...\n}\n~~~~~~~~~~\n\n你也可以用 `AutoUTF` 及对应的流来在运行时设置内源／目的之编码。\n"
  },
  {
    "path": "ext/rapidjson/doc/faq.md",
    "content": "# FAQ\n\n[TOC]\n\n## General\n\n1. What is RapidJSON?\n\n   RapidJSON is a C++ library for parsing and generating JSON. You may check all [features](doc/features.md) of it.\n\n2. Why is RapidJSON named so?\n\n   It is inspired by [RapidXML](http://rapidxml.sourceforge.net/), which is a fast XML DOM parser.\n\n3. Is RapidJSON similar to RapidXML?\n\n   RapidJSON borrowed some designs of RapidXML, including *in situ* parsing, header-only library. But the two APIs are completely different. Also RapidJSON provide many features that are not in RapidXML.\n\n4. Is RapidJSON free?\n\n   Yes, it is free under MIT license. It can be used in commercial applications. Please check the details in [license.txt](https://github.com/miloyip/rapidjson/blob/master/license.txt).\n\n5. Is RapidJSON small? What are its dependencies? \n\n   Yes. A simple executable which parses a JSON and prints its statistics is less than 30KB on Windows.\n\n   RapidJSON depends on C++ standard library only.\n\n6. How to install RapidJSON?\n\n   Check [Installation section](https://miloyip.github.io/rapidjson/).\n\n7. Can RapidJSON run on my platform?\n\n   RapidJSON has been tested in many combinations of operating systems, compilers and CPU architecture by the community. But we cannot ensure that it can be run on your particular platform. Building and running the unit test suite will give you the answer.\n\n8. Does RapidJSON support C++03? C++11?\n\n   RapidJSON was firstly implemented for C++03. Later it added optional support of some C++11 features (e.g., move constructor, `noexcept`). RapidJSON shall be compatible with C++03 or C++11 compliant compilers.\n\n9. Does RapidJSON really work in real applications?\n\n   Yes. It is deployed in both client and server real applications. A community member reported that RapidJSON in their system parses 50 million JSONs daily.\n\n10. How RapidJSON is tested?\n\n   RapidJSON contains a unit test suite for automatic testing. [Travis](https://travis-ci.org/miloyip/rapidjson/)(for Linux) and [AppVeyor](https://ci.appveyor.com/project/miloyip/rapidjson/)(for Windows) will compile and run the unit test suite for all modifications. The test process also uses Valgrind (in Linux) to detect memory leaks.\n\n11. Is RapidJSON well documented?\n\n   RapidJSON provides user guide and API documentationn.\n\n12. Are there alternatives?\n\n   Yes, there are a lot alternatives. For example, [nativejson-benchmark](https://github.com/miloyip/nativejson-benchmark) has a listing of open-source C/C++ JSON libraries. [json.org](http://www.json.org/) also has a list.\n\n## JSON\n\n1. What is JSON?\n\n   JSON (JavaScript Object Notation) is a lightweight data-interchange format. It uses human readable text format. More details of JSON can be referred to [RFC7159](http://www.ietf.org/rfc/rfc7159.txt) and [ECMA-404](http://www.ecma-international.org/publications/standards/Ecma-404.htm).\n\n2. What are applications of JSON?\n\n   JSON are commonly used in web applications for transferring structured data. It is also used as a file format for data persistence.\n\n2. Does RapidJSON conform to the JSON standard?\n\n   Yes. RapidJSON is fully compliance with [RFC7159](http://www.ietf.org/rfc/rfc7159.txt) and [ECMA-404](http://www.ecma-international.org/publications/standards/Ecma-404.htm). It can handle corner cases, such as supporting null character and surrogate pairs in JSON strings.\n\n3. Does RapidJSON support relaxed syntax?\n\n   Currently no. RapidJSON only support the strict standardized format. Support on related syntax is under discussion in this [issue](https://github.com/miloyip/rapidjson/issues/36).\n\n## DOM and SAX\n\n1. What is DOM style API?\n\n   Document Object Model (DOM) is an in-memory representation of JSON for query and manipulation.\n\n2. What is SAX style API?\n\n   SAX is an event-driven API for parsing and generation.\n\n3. Should I choose DOM or SAX?\n\n   DOM is easy for query and manipulation. SAX is very fast and memory-saving but often more difficult to be applied.\n\n4. What is *in situ* parsing?\n\n   *in situ* parsing decodes the JSON strings directly into the input JSON. This is an optimization which can reduce memory consumption and improve performance, but the input JSON will be modified. Check [in-situ parsing](doc/dom.md) for details.\n\n5. When does parsing generate an error?\n\n   The parser generates an error when the input JSON contains invalid syntax, or a value can not be represented (a number is too big), or the handler of parsers terminate the parsing. Check [parse error](doc/dom.md) for details.\n\n6. What error information is provided? \n\n   The error is stored in `ParseResult`, which includes the error code and offset (number of characters from the beginning of JSON). The error code can be translated into human-readable error message.\n\n7. Why not just using `double` to represent JSON number?\n\n   Some applications use 64-bit unsigned/signed integers. And these integers cannot be converted into `double` without loss of precision. So the parsers detects whether a JSON number is convertible to different types of integers and/or `double`.\n\n8. How to clear-and-minimize a document or value?\n\n   Call one of the `SetXXX()` methods - they call destructor which deallocates DOM data:\n\n   ~~~~~~~~~~cpp\n   Document d;\n   ...\n   d.SetObject();  // clear and minimize\n   ~~~~~~~~~~\n\n   Alternatively, use equivalent of the [C++ swap with temporary idiom](https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Clear-and-minimize):\n   ~~~~~~~~~~cpp\n   Value(kObjectType).Swap(d);\n   ~~~~~~~~~~\n   or equivalent, but sightly longer to type:\n   ~~~~~~~~~~cpp\n   d.Swap(Value(kObjectType).Move()); \n   ~~~~~~~~~~\n\n9. How to insert a document node into another document?\n\n   Let's take the following two DOM trees represented as JSON documents:\n   ~~~~~~~~~~cpp\n   Document person;\n   person.Parse(\"{\\\"person\\\":{\\\"name\\\":{\\\"first\\\":\\\"Adam\\\",\\\"last\\\":\\\"Thomas\\\"}}}\");\n   \n   Document address;\n   address.Parse(\"{\\\"address\\\":{\\\"city\\\":\\\"Moscow\\\",\\\"street\\\":\\\"Quiet\\\"}}\");\n   ~~~~~~~~~~\n   Let's assume we want to merge them in such way that the whole `address` document becomes a node of the `person`:\n   ~~~~~~~~~~js\n   { \"person\": {\n      \"name\": { \"first\": \"Adam\", \"last\": \"Thomas\" },\n      \"address\": { \"city\": \"Moscow\", \"street\": \"Quiet\" }\n      }\n   }\n   ~~~~~~~~~~\n\n   The most important requirement to take care of document and value life-cycle as well as consistent memory managent using the right allocator during the value transfer.\n   \n   Simple yet most efficient way to achieve that is to modify the `address` definition above to initialize it with allocator of the `person` document, then we just add the root member of the value:\n   ~~~~~~~~~~cpp\n   Documnet address(person.GetAllocator());\n   ...\n   person[\"person\"].AddMember(\"address\", address[\"address\"], person.GetAllocator());\n   ~~~~~~~~~~\nAlternatively, if we don't want to explicitly refer to the root value of `address` by name, we can refer to it via iterator:\n   ~~~~~~~~~~cpp\n   auto addressRoot = address.MemberBegin();\n   person[\"person\"].AddMember(addressRoot->name, addressRoot->value, person.GetAllocator());\n   ~~~~~~~~~~\n   \n   Second way is to deep-clone the value from the address document:\n   ~~~~~~~~~~cpp\n   Value addressValue = Value(address[\"address\"], person.GetAllocator());\n   person[\"person\"].AddMember(\"address\", addressValue, person.GetAllocator());\n   ~~~~~~~~~~\n\n## Document/Value (DOM)\n\n1. What is move semantics? Why?\n\n   Instead of copy semantics, move semantics is used in `Value`. That means, when assigning a source value to a target value, the ownership of source value is moved to the target value.\n\n   Since moving is faster than copying, this design decision forces user to aware of the copying overhead.\n\n2. How to copy a value?\n\n   There are two APIs: constructor with allocator, and `CopyFrom()`. See [Deep Copy Value](doc/tutorial.md) for an example.\n\n3. Why do I need to provide the length of string?\n\n   Since C string is null-terminated, the length of string needs to be computed via `strlen()`, with linear runtime complexity. This incurs an unncessary overhead of many operations, if the user already knows the length of string.\n\n   Also, RapidJSON can handle `\\u0000` (null character) within a string. If a string contains null characters, `strlen()` cannot return the true length of it. In such case user must provide the length of string explicitly.\n\n4. Why do I need to provide allocator parameter in many DOM manipulation API?\n\n   Since the APIs are member functions of `Value`, we do not want to save an allocator pointer in every `Value`.\n\n5. Does it convert between numerical types?\n\n   When using `GetInt()`, `GetUint()`, ... conversion may occur. For integer-to-integer conversion, it only convert when it is safe (otherwise it will assert). However, when converting a 64-bit signed/unsigned integer to double, it will convert but be aware that it may lose precision. A number with fraction, or an integer larger than 64-bit, can only be obtained by `GetDouble()`.\n\n## Reader/Writer (SAX)\n\n1. Why don't we just `printf` a JSON? Why do we need a `Writer`? \n\n   Most importantly, `Writer` will ensure the output JSON is well-formed. Calling SAX events incorrectly (e.g. `StartObject()` pairing with `EndArray()`) will assert. Besides, `Writer` will escapes strings (e.g., `\\n`). Finally, the numeric output of `printf()` may not be a valid JSON number, especially in some locale with digit delimiters. And the number-to-string conversion in `Writer` is implemented with very fast algorithms, which outperforms than `printf()` or `iostream`.\n\n2. Can I pause the parsing process and resume it later?\n\n   This is not directly supported in the current version due to performance consideration. However, if the execution environment supports multi-threading, user can parse a JSON in a separate thread, and pause it by blocking in the input stream.\n\n## Unicode\n\n1. Does it support UTF-8, UTF-16 and other format?\n\n   Yes. It fully support UTF-8, UTF-16 (LE/BE), UTF-32 (LE/BE) and ASCII. \n\n2. Can it validate the encoding?\n\n   Yes, just pass `kParseValidateEncodingFlag` to `Parse()`. If there is invalid encoding in the stream, it wil generate `kParseErrorStringInvalidEncoding` error.\n\n3. What is surrogate pair? Does RapidJSON support it?\n\n   JSON uses UTF-16 encoding when escaping unicode character, e.g. `\\u5927` representing Chinese character \"big\". To handle characters other than those in basic multilingual plane (BMP), UTF-16 encodes those characters with two 16-bit values, which is called UTF-16 surrogate pair. For example, the Emoji character U+1F602 can be encoded as `\\uD83D\\uDE02` in JSON.\n\n   RapidJSON fully support parsing/generating UTF-16 surrogates. \n\n4. Can it handle `\\u0000` (null character) in JSON string?\n\n   Yes. RapidJSON fully support null character in JSON string. However, user need to be aware of it and using `GetStringLength()` and related APIs to obtain the true length of string.\n\n5. Can I output `\\uxxxx` for all non-ASCII character?\n\n   Yes, use `ASCII<>` as output encoding template parameter in `Writer` can enforce escaping those characters.\n\n## Stream\n\n1. I have a big JSON file. Should I load the whole file to memory?\n\n   User can use `FileReadStream` to read the file chunk-by-chunk. But for *in situ* parsing, the whole file must be loaded.\n\n2. Can I parse JSON while it is streamed from network?\n\n   Yes. User can implement a custom stream for this. Please refer to the implementation of `FileReadStream`.\n\n3. I don't know what encoding will the JSON be. How to handle them?\n\n   You may use `AutoUTFInputStream` which detects the encoding of input stream automatically. However, it will incur some performance overhead.\n\n4. What is BOM? How RapidJSON handle it?\n\n   [Byte order mark (BOM)](http://en.wikipedia.org/wiki/Byte_order_mark) sometimes reside at the beginning of file/stream to indiciate the UTF encoding type of it.\n\n   RapidJSON's `EncodedInputStream` can detect/consume BOM. `EncodedOutputStream` can optionally write a BOM. See [Encoded Streams](doc/stream.md) for example.\n\n5. Why little/big endian is related?\n\n   little/big endian of stream is an issue for UTF-16 and UTF-32 streams, but not UTF-8 stream.\n\n## Performance\n\n1. Is RapidJSON really fast?\n\n   Yes. It may be the fastest open source JSON library. There is a [benchmark](https://github.com/miloyip/nativejson-benchmark) for evaluating performance of C/C++ JSON libaries.\n\n2. Why is it fast?\n\n   Many design decisions of RapidJSON is aimed at time/space performance. These may reduce user-friendliness of APIs. Besides, it also employs low-level optimizations (intrinsics, SIMD) and special algorithms (custom double-to-string, string-to-double conversions).\n\n3. What is SIMD? How it is applied in RapidJSON?\n\n   [SIMD](http://en.wikipedia.org/wiki/SIMD) instructions can perform parallel computation in modern CPUs. RapidJSON support Intel's SSE2/SSE4.2 to accelerate whitespace skipping. This improves performance of parsing indent formatted JSON. Define `RAPIDJSON_SSE2` or `RAPIDJSON_SSE42` macro to enable this feature. However, running the executable on a machine without such instruction set support will make it crash.\n\n4. Does it consume a lot of memory?\n\n   The design of RapidJSON aims at reducing memory footprint.\n\n   In the SAX API, `Reader` consumes memory portional to maximum depth of JSON tree, plus maximum length of JSON string.\n\n   In the DOM API, each `Value` consumes exactly 16/24 bytes for 32/64-bit architecture respectively. RapidJSON also uses a special memory allocator to minimize overhead of allocations.\n\n5. What is the purpose of being high performance?\n\n   Some applications need to process very large JSON files. Some server-side applications need to process huge amount of JSONs. Being high performance can improve both latency and throuput. In a broad sense, it will also save energy.\n\n## Gossip\n\n1. Who are the developers of RapidJSON?\n\n   Milo Yip ([miloyip](https://github.com/miloyip)) is the original author of RapidJSON. Many contributors from the world have improved RapidJSON.  Philipp A. Hartmann ([pah](https://github.com/pah)) has implemented a lot of improvements, setting up automatic testing and also involves in a lot of discussions for the community. Don Ding ([thebusytypist](https://github.com/thebusytypist)) implemented the iterative parser. Andrii Senkovych ([jollyroger](https://github.com/jollyroger)) completed the CMake migration. Kosta ([Kosta-Github](https://github.com/Kosta-Github)) provided a very neat short-string optimization. Thank you for all other contributors and community members as well.\n\n2. Why do you develop RapidJSON?\n\n   It was just a hobby project initially in 2011. Milo Yip is a game programmer and he just knew about JSON at that time and would like to apply JSON in future projects. As JSON seems very simple he would like to write a header-only and fast library.\n\n3. Why there is a long empty period of development?\n\n   It is basically due to personal issues, such as getting new family members. Also, Milo Yip has spent a lot of spare time on translating \"Game Engine Architecture\" by Jason Gregory into Chinese.\n\n4. Why did the repository move from Google Code to GitHub?\n\n   This is the trend. And GitHub is much more powerful and convenient.\n"
  },
  {
    "path": "ext/rapidjson/doc/faq.zh-cn.md",
    "content": "# 常见问题\n\n[TOC]\n\n## 一般问题\n\n1. RapidJSON 是什么？\n\n   RapidJSON 是一个 C++ 库，用于解析及生成 JSON。读者可参考它的所有 [特点](doc/features.zh-cn.md)。\n\n2. 为什么称作 RapidJSON？\n\n   它的灵感来自于 [RapidXML](http://rapidxml.sourceforge.net/)，RapidXML 是一个高速的 XML DOM 解析器。\n\n3. RapidJSON 与 RapidXML 相似么？\n\n   RapidJSON 借镜了 RapidXML 的一些设计, 包括原位（*in situ*）解析、只有头文件的库。但两者的 API 是完全不同的。此外 RapidJSON 也提供许多 RapidXML 没有的特点。\n\n4. RapidJSON 是免费的么？\n\n   是的，它在 MIT 特許條款下免费。它可用于商业软件。详情请参看 [license.txt](https://github.com/miloyip/rapidjson/blob/master/license.txt)。\n\n5. RapidJSON 很小么？它有何依赖？\n\n   是的。在 Windows 上，一个解析 JSON 并打印出统计的可执行文件少于 30KB。\n\n   RapidJSON 仅依赖于 C++ 标准库。\n\n6. 怎样安装 RapidJSON？\n\n   见 [安装一节](../readme.zh-cn.md#安装)。\n\n7. RapidJSON 能否运行于我的平台？\n\n   社区已在多个操作系统／编译器／CPU 架构的组合上测试 RapidJSON。但我们无法确保它能运行于你特定的平台上。只需要生成及执行单元测试便能获取答案。\n\n8. RapidJSON 支持 C++03 么？C++11 呢？\n\n   RapidJSON 开始时在 C++03 上实现。后来加入了可选的 C++11 特性支持（如转移构造函数、`noexcept`）。RapidJSON 应该兼容所有遵从 C++03 或 C++11 的编译器。\n\n9. RapidJSON 是否真的用于实际应用？\n\n   是的。它被配置于前台及后台的真实应用中。一个社区成员说 RapidJSON 在他们的系统中每日解析 5 千万个 JSON。\n\n10. RapidJSON 是如何被测试的？\n\n   RapidJSON 包含一组单元测试去执行自动测试。[Travis](https://travis-ci.org/miloyip/rapidjson/)（供 Linux 平台）及 [AppVeyor](https://ci.appveyor.com/project/miloyip/rapidjson/)（供 Windows 平台）会对所有修改进行编译及执行单元测试。在 Linux 下还会使用 Valgrind 去检测内存泄漏。\n\n11. RapidJSON 是否有完整的文档？\n\n   RapidJSON 提供了使用手册及 API 说明文档。\n\n12. 有没有其他替代品？\n\n   有许多替代品。例如 [nativejson-benchmark](https://github.com/miloyip/nativejson-benchmark) 列出了一些开源的 C/C++ JSON 库。[json.org](http://www.json.org/) 也有一个列表。\n\n## JSON\n\n1. 什么是 JSON？\n\n   JSON (JavaScript Object Notation) 是一个轻量的数据交换格式。它使用人类可读的文本格式。更多关于 JSON 的细节可考 [RFC7159](http://www.ietf.org/rfc/rfc7159.txt) 及 [ECMA-404](http://www.ecma-international.org/publications/standards/Ecma-404.htm)。\n\n2. JSON 有什么应用场合？\n\n   JSON 常用于网页应用程序，以传送结构化数据。它也可作为文件格式用于数据持久化。\n\n2. RapidJSON 是否符合 JSON 标准？\n\n   是。RapidJSON 完全符合 [RFC7159](http://www.ietf.org/rfc/rfc7159.txt) 及 [ECMA-404](http://www.ecma-international.org/publications/standards/Ecma-404.htm)。它能处理一些特殊情况，例如支持 JSON 字符串中含有空字符及代理对（surrogate pair）。\n\n3. RapidJSON 是否支持宽松的语法？\n\n   现时不支持。RapidJSON 只支持严格的标准格式。宽松语法现时在这 [issue](https://github.com/miloyip/rapidjson/issues/36) 中进行讨论。\n\n## DOM 与 SAX\n\n1. 什么是 DOM 风格 API？\n\n   Document Object Model（DOM）是一个储存于内存的 JSON 表示方式，用于查询及修改 JSON。\n\n2. 什么是 SAX 风格 API?\n\n   SAX 是一个事件驱动的 API，用于解析及生成 JSON。\n\n3. 我应用 DOM 还是 SAX？\n\n   DOM 易于查询及修改。SAX 则是非常快及省内存的，但通常较难使用。\n\n4. 什么是原位（*in situ*）解析？\n\n   原位解析会把 JSON 字符串直接解码至输入的 JSON 中。这是一个优化，可减少内存消耗及提升性能，但输入的 JSON 会被更改。进一步细节请参考 [原位解析](doc/dom.zh-cn.md) 。\n\n5. 什么时候会产生解析错误？\n\n   当输入的 JSON 包含非法语法，或不能表示一个值（如 Number 太大），或解析器的处理器中断解析过程，解析器都会产生一个错误。详情请参考 [解析错误](doc/dom.zh-cn.md)。\n\n6. 有什么错误信息？\n\n   错误信息存储在 `ParseResult`，它包含错误代号及偏移值（从 JSON 开始至错误处的字符数目）。可以把错误代号翻译为人类可读的错误讯息。\n\n7. 为何不只使用 `double` 去表示 JSON number？\n\n   一些应用需要使用 64 位无号／有号整数。这些整数不能无损地转换成 `double`。因此解析器会检测一个 JSON number 是否能转换至各种整数类型及 `double`。\n\n8. 如何清空并最小化 `document` 或 `value` 的容量？\n\n   调用 `SetXXX()` 方法 - 这些方法会调用析构函数，并重建空的 Object 或 Array:\n\n   ~~~~~~~~~~cpp\n   Document d;\n   ...\n   d.SetObject();  // clear and minimize\n   ~~~~~~~~~~\n\n   另外，也可以参考在 [C++ swap with temporary idiom](https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Clear-and-minimize) 中的一种等价的方法:\n   ~~~~~~~~~~cpp\n   Value(kObjectType).Swap(d);\n   ~~~~~~~~~~\n   或者，使用这个稍微长一点的代码也能完成同样的事情:\n   ~~~~~~~~~~cpp\n   d.Swap(Value(kObjectType).Move()); \n   ~~~~~~~~~~\n\n9. 如何将一个 `document` 节点插入到另一个 `document` 中？\n\n   比如有以下两个 document(DOM):\n   ~~~~~~~~~~cpp\n   Document person;\n   person.Parse(\"{\\\"person\\\":{\\\"name\\\":{\\\"first\\\":\\\"Adam\\\",\\\"last\\\":\\\"Thomas\\\"}}}\");\n   \n   Document address;\n   address.Parse(\"{\\\"address\\\":{\\\"city\\\":\\\"Moscow\\\",\\\"street\\\":\\\"Quiet\\\"}}\");\n   ~~~~~~~~~~\n   假设我们希望将整个 `address` 插入到 `person` 中，作为其的一个子节点:\n   ~~~~~~~~~~js\n   { \"person\": {\n      \"name\": { \"first\": \"Adam\", \"last\": \"Thomas\" },\n      \"address\": { \"city\": \"Moscow\", \"street\": \"Quiet\" }\n      }\n   }\n   ~~~~~~~~~~\n\n   在插入节点的过程中需要注意 `document` 和 `value` 的生命周期并且正确地使用 allocator 进行内存分配和管理。\n\n   一个简单有效的方法就是修改上述 `address` 变量的定义，让其使用 `person` 的 allocator 初始化，然后将其添加到根节点。\n\n   ~~~~~~~~~~cpp\n   Documnet address(person.GetAllocator());\n   ...\n   person[\"person\"].AddMember(\"address\", address[\"address\"], person.GetAllocator());\n   ~~~~~~~~~~\n   当然，如果你不想通过显式地写出 `address` 的 key 来得到其值，可以使用迭代器来实现:\n   ~~~~~~~~~~cpp\n   auto addressRoot = address.MemberBegin();\n   person[\"person\"].AddMember(addressRoot->name, addressRoot->value, person.GetAllocator());\n   ~~~~~~~~~~\n   \n   此外，还可以通过深拷贝 address document 来实现:\n   ~~~~~~~~~~cpp\n   Value addressValue = Value(address[\"address\"], person.GetAllocator());\n   person[\"person\"].AddMember(\"address\", addressValue, person.GetAllocator());\n   ~~~~~~~~~~\n\n## Document/Value (DOM)\n\n1. 什么是转移语意？为什么？\n\n   `Value` 不用复制语意，而使用了转移语意。这是指，当把来源值赋值于目标值时，来源值的所有权会转移至目标值。\n\n   由于转移快于复制，此设计决定强迫使用者注意到复制的消耗。\n\n2. 怎样去复制一个值？\n\n   有两个 API 可用：含 allocator 的构造函数，以及 `CopyFrom()`。可参考 [深复制 Value](doc/tutorial.zh-cn.md) 里的用例。\n\n3. 为什么我需要提供字符串的长度？\n\n   由于 C 字符串是空字符结尾的，需要使用 `strlen()` 去计算其长度，这是线性复杂度的操作。若使用者已知字符串的长度，对很多操作来说会造成不必要的消耗。\n\n   此外，RapidJSON 可处理含有 `\\u0000`（空字符）的字符串。若一个字符串含有空字符，`strlen()` 便不能返回真正的字符串长度。在这种情况下使用者必须明确地提供字符串长度。\n\n4. 为什么在许多 DOM 操作 API 中要提供分配器作为参数？\n\n   由于这些 API 是 `Value` 的成员函数，我们不希望为每个 `Value` 储存一个分配器指针。\n\n5. 它会转换各种数值类型么？\n\n   当使用 `GetInt()`、`GetUint()` 等 API 时，可能会发生转换。对于整数至整数转换，仅当保证转换安全才会转换（否则会断言失败）。然而，当把一个 64 位有号／无号整数转换至 double 时，它会转换，但有可能会损失精度。含有小数的数字、或大于 64 位的整数，都只能使用 `GetDouble()` 获取其值。\n\n## Reader/Writer (SAX)\n\n1. 为什么不仅仅用 `printf` 输出一个 JSON？为什么需要 `Writer`？\n\n   最重要的是，`Writer` 能确保输出的 JSON 是格式正确的。错误地调用 SAX 事件（如 `StartObject()` 错配 `EndArray()`）会造成断言失败。此外，`Writer` 会把字符串进行转义（如 `\\n`）。最后，`printf()` 的数值输出可能并不是一个合法的 JSON number，特别是某些 locale 会有数字分隔符。而且 `Writer` 的数值字符串转换是使用非常快的算法来实现的，胜过 `printf()` 及 `iostream`。\n\n2. 我能否暂停解析过程，并在稍后继续？\n\n   基于性能考虑，目前版本并不直接支持此功能。然而，若执行环境支持多线程，使用者可以在另一线程解析 JSON，并通过阻塞输入流去暂停。\n\n## Unicode\n\n1. 它是否支持 UTF-8、UTF-16 及其他格式？\n\n   是。它完全支持 UTF-8、UTF-16（大端／小端）、UTF-32（大端／小端）及 ASCII。\n\n2. 它能否检测编码的合法性？\n\n   能。只需把 `kParseValidateEncodingFlag` 参考传给 `Parse()`。若发现在输入流中有非法的编码，它就会产生 `kParseErrorStringInvalidEncoding` 错误。\n\n3. 什么是代理对（surrogate pair)？RapidJSON 是否支持？\n\n   JSON 使用 UTF-16 编码去转义 Unicode 字符，例如 `\\u5927` 表示中文字“大”。要处理基本多文种平面（basic multilingual plane，BMP）以外的字符时，UTF-16 会把那些字符编码成两个 16 位值，这称为 UTF-16 代理对。例如，绘文字字符 U+1F602 在 JSON 中可被编码成 `\\uD83D\\uDE02`。\n\n   RapidJSON 完全支持解析及生成 UTF-16 代理对。 \n\n4. 它能否处理 JSON 字符串中的 `\\u0000`（空字符）？\n\n   能。RapidJSON 完全支持 JSON 字符串中的空字符。然而，使用者需要注意到这件事，并使用 `GetStringLength()` 及相关 API 去取得字符串真正长度。\n\n5. 能否对所有非 ASCII 字符输出成 `\\uxxxx` 形式？\n\n   可以。只要在 `Writer` 中使用 `ASCII<>` 作为输出编码参数，就可以强逼转义那些字符。\n\n## 流\n\n1. 我有一个很大的 JSON 文件。我应否把它整个载入内存中？\n\n   使用者可使用 `FileReadStream` 去逐块读入文件。但若使用于原位解析，必须载入整个文件。\n\n2. 我能否解析一个从网络上串流进来的 JSON？\n\n   可以。使用者可根据 `FileReadStream` 的实现，去实现一个自定义的流。\n\n3. 我不知道一些 JSON 将会使用哪种编码。怎样处理它们？\n\n   你可以使用 `AutoUTFInputStream`，它能自动检测输入流的编码。然而，它会带来一些性能开销。\n\n4. 什么是 BOM？RapidJSON 怎样处理它？\n\n   [字节顺序标记（byte order mark, BOM）](http://en.wikipedia.org/wiki/Byte_order_mark) 有时会出现于文件／流的开始，以表示其 UTF 编码类型。\n\n   RapidJSON 的 `EncodedInputStream` 可检测／跳过 BOM。`EncodedOutputStream` 可选择是否写入 BOM。可参考 [编码流](doc/stream.zh-cn.md) 中的例子。\n\n5. 为什么会涉及大端／小端？\n\n   流的大端／小端是 UTF-16 及 UTF-32 流要处理的问题，而 UTF-8 不需要处理。\n\n## 性能\n\n1. RapidJSON 是否真的快？\n\n   是。它可能是最快的开源 JSON 库。有一个 [评测](https://github.com/miloyip/nativejson-benchmark) 评估 C/C++ JSON 库的性能。\n\n2. 为什么它会快？\n\n   RapidJSON 的许多设计是针对时间／空间性能来设计的，这些决定可能会影响 API 的易用性。此外，它也使用了许多底层优化（内部函数／intrinsic、SIMD）及特别的算法（自定义的 double 至字符串转换、字符串至 double 的转换）。\n\n3. 什是是 SIMD？它如何用于 RapidJSON？\n\n   [SIMD](http://en.wikipedia.org/wiki/SIMD) 指令可以在现代 CPU 中执行并行运算。RapidJSON 支持了 Intel 的 SSE2/SSE4.2 去加速跳过空白字符。在解析含缩进的 JSON 时，这能提升性能。只要定义名为 `RAPIDJSON_SSE2` 或 `RAPIDJSON_SSE42` 的宏，就能启动这个功能。然而，若在不支持这些指令集的机器上执行这些可执行文件，会导致崩溃。\n\n4. 它会消耗许多内存么？\n\n   RapidJSON 的设计目标是减低内存占用。\n\n   在 SAX API 中，`Reader` 消耗的内存与 JSON 树深度加上最长 JSON 字符成正比。\n\n   在 DOM API 中，每个 `Value` 在 32/64 位架构下分别消耗 16/24 字节。RapidJSON 也使用一个特殊的内存分配器去减少分配的额外开销。\n\n5. 高性能的意义何在？\n\n   有些应用程序需要处理非常大的 JSON 文件。而有些后台应用程序需要处理大量的 JSON。达到高性能同时改善延时及吞吐量。更广义来说，这也可以节省能源。\n\n## 八挂\n\n1. 谁是 RapidJSON 的开发者？\n\n   叶劲峰（Milo Yip，[miloyip](https://github.com/miloyip)）是 RapidJSON 的原作者。全世界许多贡献者一直在改善 RapidJSON。Philipp A. Hartmann（[pah](https://github.com/pah)）实现了许多改进，也设置了自动化测试，而且还参与许多社区讨论。丁欧南（Don Ding，[thebusytypist](https://github.com/thebusytypist)）实现了迭代式解析器。Andrii Senkovych（[jollyroger](https://github.com/jollyroger)）完成了向 CMake 的迁移。Kosta（[Kosta-Github](https://github.com/Kosta-Github)）提供了一个非常灵巧的短字符串优化。也需要感谢其他献者及社区成员。\n\n2. 为何你要开发 RapidJSON？\n\n   在 2011 年开始这项目是，它仅一个兴趣项目。Milo Yip 是一个游戏程序员，他在那时候认识到 JSON 并希望在未来的项目中使用。由于 JSON 好像很简单，他希望写一个仅有头文件并且快速的程序库。\n\n3. 为什么开发中段有一段长期空档？\n\n   主要是个人因素，例如加入新家庭成员。另外，Milo Yip 也花了许多业馀时间去翻译 Jason Gregory 的《Game Engine Architecture》至中文版《游戏引擎架构》。\n\n4. 为什么这个项目从 Google Code 搬到 GitHub？\n\n   这是大势所趋，而且 GitHub 更为强大及方便。\n"
  },
  {
    "path": "ext/rapidjson/doc/features.md",
    "content": "# Features\n\n## General\n\n* Cross-platform\n * Compilers: Visual Studio, gcc, clang, etc.\n * Architectures: x86, x64, ARM, etc.\n * Operating systems: Windows, Mac OS X, Linux, iOS, Android, etc.\n* Easy installation\n * Header files only library. Just copy the headers to your project.\n* Self-contained, minimal dependences\n * No STL, BOOST, etc.\n * Only included `<cstdio>`, `<cstdlib>`, `<cstring>`, `<inttypes.h>`, `<new>`, `<stdint.h>`. \n* Without C++ exception, RTTI\n* High performance\n * Use template and inline functions to reduce function call overheads.\n * Internal optimized Grisu2 and floating point parsing implementations.\n * Optional SSE2/SSE4.2 support.\n\n## Standard compliance\n\n* RapidJSON should be fully RFC4627/ECMA-404 compliance.\n* Support JSON Pointer (RFC6901).\n* Support JSON Schema Draft v4.\n* Support Unicode surrogate.\n* Support null character (`\"\\u0000\"`)\n * For example, `[\"Hello\\u0000World\"]` can be parsed and handled gracefully. There is API for getting/setting lengths of string.\n* Support optional relaxed syntax.\n * Single line (`// ...`) and multiple line (`/* ... */`) comments (`kParseCommentsFlag`). \n * Trailing commas at the end of objects and arrays (`kParseTrailingCommasFlag`).\n * `NaN`, `Inf`, `Infinity`, `-Inf` and `-Infinity` as `double` values (`kParseNanAndInfFlag`)\n* [NPM compliant](http://github.com/miloyip/rapidjson/blob/master/doc/npm.md).\n\n## Unicode\n\n* Support UTF-8, UTF-16, UTF-32 encodings, including little endian and big endian.\n * These encodings are used in input/output streams and in-memory representation.\n* Support automatic detection of encodings in input stream.\n* Support transcoding between encodings internally.\n * For example, you can read a UTF-8 file and let RapidJSON transcode the JSON strings into UTF-16 in the DOM.\n* Support encoding validation internally.\n * For example, you can read a UTF-8 file, and let RapidJSON check whether all JSON strings are valid UTF-8 byte sequence.\n* Support custom character types.\n * By default the character types are `char` for UTF8, `wchar_t` for UTF16, `uint32_t` for UTF32.\n* Support custom encodings.\n\n## API styles\n\n* SAX (Simple API for XML) style API\n * Similar to [SAX](http://en.wikipedia.org/wiki/Simple_API_for_XML), RapidJSON provides a event sequential access parser API (`rapidjson::GenericReader`). It also provides a generator API (`rapidjson::Writer`) which consumes the same set of events.\n* DOM (Document Object Model) style API\n * Similar to [DOM](http://en.wikipedia.org/wiki/Document_Object_Model) for HTML/XML, RapidJSON can parse JSON into a DOM representation (`rapidjson::GenericDocument`), for easy manipulation, and finally stringify back to JSON if needed.\n * The DOM style API (`rapidjson::GenericDocument`) is actually implemented with SAX style API (`rapidjson::GenericReader`). SAX is faster but sometimes DOM is easier. Users can pick their choices according to scenarios.\n\n## Parsing\n\n* Recursive (default) and iterative parser\n * Recursive parser is faster but prone to stack overflow in extreme cases.\n * Iterative parser use custom stack to keep parsing state.\n* Support *in situ* parsing.\n * Parse JSON string values in-place at the source JSON, and then the DOM points to addresses of those strings.\n * Faster than convention parsing: no allocation for strings, no copy (if string does not contain escapes), cache-friendly.\n* Support 32-bit/64-bit signed/unsigned integer and `double` for JSON number type.\n* Support parsing multiple JSONs in input stream (`kParseStopWhenDoneFlag`).\n* Error Handling\n * Support comprehensive error code if parsing failed.\n * Support error message localization.\n\n## DOM (Document)\n\n* RapidJSON checks range of numerical values for conversions.\n* Optimization for string literal\n * Only store pointer instead of copying\n* Optimization for \"short\" strings\n * Store short string in `Value` internally without additional allocation.\n * For UTF-8 string: maximum 11 characters in 32-bit, 21 characters in 64-bit (13 characters in x86-64).\n* Optionally support `std::string` (define `RAPIDJSON_HAS_STDSTRING=1`)\n\n## Generation\n\n* Support `rapidjson::PrettyWriter` for adding newlines and indentations.\n\n## Stream\n\n* Support `rapidjson::GenericStringBuffer` for storing the output JSON as string.\n* Support `rapidjson::FileReadStream` and `rapidjson::FileWriteStream` for input/output `FILE` object.\n* Support custom streams.\n\n## Memory\n\n* Minimize memory overheads for DOM.\n * Each JSON value occupies exactly 16/20 bytes for most 32/64-bit machines (excluding text string).\n* Support fast default allocator.\n * A stack-based allocator (allocate sequentially, prohibit to free individual allocations, suitable for parsing).\n * User can provide a pre-allocated buffer. (Possible to parse a number of JSONs without any CRT allocation)\n* Support standard CRT(C-runtime) allocator.\n* Support custom allocators.\n\n## Miscellaneous\n\n* Some C++11 support (optional)\n * Rvalue reference\n * `noexcept` specifier\n * Range-based for loop\n"
  },
  {
    "path": "ext/rapidjson/doc/features.zh-cn.md",
    "content": "# 特点\n\n## 总体\n\n* 跨平台\n * 编译器：Visual Studio、gcc、clang 等\n * 架构：x86、x64、ARM 等\n * 操作系统：Windows、Mac OS X、Linux、iOS、Android 等\n* 容易安装\n * 只有头文件的库。只需把头文件复制至你的项目中。\n* 独立、最小依赖\n * 不需依赖 STL、BOOST 等。\n * 只包含 `<cstdio>`, `<cstdlib>`, `<cstring>`, `<inttypes.h>`, `<new>`, `<stdint.h>`。 \n* 没使用 C++ 异常、RTTI\n* 高性能\n * 使用模版及内联函数去降低函数调用开销。\n * 内部经优化的 Grisu2 及浮点数解析实现。\n * 可选的 SSE2/SSE4.2 支持。\n\n## 符合标准\n\n* RapidJSON 应完全符合 RFC4627/ECMA-404 标准。\n* 支持 JSON Pointer (RFC6901).\n* 支持 JSON Schema Draft v4.\n* 支持 Unicod 代理对（surrogate pair）。\n* 支持空字符（`\"\\u0000\"`）。\n * 例如，可以优雅地解析及处理 `[\"Hello\\u0000World\"]`。含读写字符串长度的 API。\n* 支持可选的放宽语法\n * 单行（`// ...`）及多行（`/* ... */`） 注释 (`kParseCommentsFlag`)。\n * 在对象和数组结束前含逗号 (`kParseTrailingCommasFlag`)。\n * `NaN`、`Inf`、`Infinity`、`-Inf` 及 `-Infinity` 作为 `double` 值 (`kParseNanAndInfFlag`)\n* [NPM 兼容](https://github.com/miloyip/rapidjson/blob/master/doc/npm.md).\n\n## Unicode\n\n* 支持 UTF-8、UTF-16、UTF-32 编码，包括小端序和大端序。\n * 这些编码用于输入输出流，以及内存中的表示。\n* 支持从输入流自动检测编码。\n* 内部支持编码的转换。\n * 例如，你可以读取一个 UTF-8 文件，让 RapidJSON 把 JSON 字符串转换至 UTF-16 的 DOM。\n* 内部支持编码校验。\n * 例如，你可以读取一个 UTF-8 文件，让 RapidJSON 检查是否所有 JSON 字符串是合法的 UTF-8 字节序列。\n* 支持自定义的字符类型。\n * 预设的字符类型是：UTF-8 为 `char`，UTF-16 为 `wchar_t`，UTF32 为 `uint32_t`。\n* 支持自定义的编码。\n\n## API 风格\n\n* SAX（Simple API for XML）风格 API\n * 类似于 [SAX](http://en.wikipedia.org/wiki/Simple_API_for_XML), RapidJSON 提供一个事件循序访问的解析器 API（`rapidjson::GenericReader`）。RapidJSON 也提供一个生成器 API（`rapidjson::Writer`），可以处理相同的事件集合。\n* DOM（Document Object Model）风格 API\n * 类似于 HTML／XML 的 [DOM](http://en.wikipedia.org/wiki/Document_Object_Model)，RapidJSON 可把 JSON 解析至一个 DOM 表示方式（`rapidjson::GenericDocument`），以方便操作。如有需要，可把 DOM 转换（stringify）回 JSON。\n * DOM 风格 API（`rapidjson::GenericDocument`）实际上是由 SAX 风格 API（`rapidjson::GenericReader`）实现的。SAX 更快，但有时 DOM 更易用。用户可根据情况作出选择。\n\n## 解析\n\n* 递归式（预设）及迭代式解析器\n * 递归式解析器较快，但在极端情况下可出现堆栈溢出。\n * 迭代式解析器使用自定义的堆栈去维持解析状态。\n* 支持原位（*in situ*）解析。\n * 把 JSON 字符串的值解析至原 JSON 之中，然后让 DOM 指向那些字符串。\n * 比常规分析更快：不需字符串的内存分配、不需复制（如字符串不含转义符）、缓存友好。\n* 对于 JSON 数字类型，支持 32-bit/64-bit 的有号／无号整数，以及 `double`。\n* 错误处理\n * 支持详尽的解析错误代号。\n * 支持本地化错误信息。\n\n## DOM (Document)\n\n* RapidJSON 在类型转换时会检查数值的范围。\n* 字符串字面量的优化\n * 只储存指针，不作复制\n* 优化“短”字符串\n * 在 `Value` 内储存短字符串，无需额外分配。\n * 对 UTF-8 字符串来说，32 位架构下可存储最多 11 字符，64 位下 21 字符（x86-64 下 13 字符）。\n* 可选地支持 `std::string`（定义 `RAPIDJSON_HAS_STDSTRING=1`）\n\n## 生成\n\n* 支持 `rapidjson::PrettyWriter` 去加入换行及缩进。\n\n## 输入输出流\n\n* 支持 `rapidjson::GenericStringBuffer`，把输出的 JSON 储存于字符串内。\n* 支持 `rapidjson::FileReadStream` 及 `rapidjson::FileWriteStream`，使用 `FILE` 对象作输入输出。\n* 支持自定义输入输出流。\n\n## 内存\n\n* 最小化 DOM 的内存开销。\n * 对大部分 32／64 位机器而言，每个 JSON 值只占 16 或 20 字节（不包含字符串）。\n* 支持快速的预设分配器。\n * 它是一个堆栈形式的分配器（顺序分配，不容许单独释放，适合解析过程之用）。\n * 使用者也可提供一个预分配的缓冲区。（有可能达至无需 CRT 分配就能解析多个 JSON）\n* 支持标准 CRT（C-runtime）分配器。\n* 支持自定义分配器。\n\n## 其他\n\n* 一些 C++11 的支持（可选）\n * 右值引用（rvalue reference）\n * `noexcept` 修饰符\n * 范围 for 循环\n"
  },
  {
    "path": "ext/rapidjson/doc/internals.md",
    "content": "# Internals\n\nThis section records some design and implementation details.\n\n[TOC]\n\n# Architecture {#Architecture}\n\n## SAX and DOM\n\nThe basic relationships of SAX and DOM is shown in the following UML diagram.\n\n![Architecture UML class diagram](diagram/architecture.png)\n\nThe core of the relationship is the `Handler` concept. From the SAX side, `Reader` parses a JSON from a stream and publish events to a `Handler`. `Writer` implements the `Handler` concept to handle the same set of events. From the DOM side, `Document` implements the `Handler` concept to build a DOM according to the events. `Value` supports a `Value::Accept(Handler&)` function, which traverses the DOM to publish events.\n\nWith this design, SAX is not dependent on DOM. Even `Reader` and `Writer` have no dependencies between them. This provides flexibility to chain event publisher and handlers. Besides, `Value` does not depends on SAX as well. So, in addition to stringify a DOM to JSON, user may also stringify it to a XML writer, or do anything else.\n\n## Utility Classes\n\nBoth SAX and DOM APIs depends on 3 additional concepts: `Allocator`, `Encoding` and `Stream`. Their inheritance hierarchy is shown as below.\n\n![Utility classes UML class diagram](diagram/utilityclass.png)\n\n# Value {#Value}\n\n`Value` (actually a typedef of `GenericValue<UTF8<>>`) is the core of DOM API. This section describes the design of it.\n\n## Data Layout {#DataLayout}\n\n`Value` is a [variant type](http://en.wikipedia.org/wiki/Variant_type). In RapidJSON's context, an instance of `Value` can contain 1 of 6 JSON value types. This is possible by using `union`. Each `Value` contains two members: `union Data data_` and a`unsigned flags_`. The `flags_` indiciates the JSON type, and also additional information. \n\nThe following tables show the data layout of each type. The 32-bit/64-bit columns indicates the size of the field in bytes.\n\n| Null              |                                  |32-bit|64-bit|\n|-------------------|----------------------------------|:----:|:----:|\n| (unused)          |                                  |4     |8     | \n| (unused)          |                                  |4     |4     |\n| (unused)          |                                  |4     |4     |\n| `unsigned flags_` | `kNullType kNullFlag`            |4     |4     |\n\n| Bool              |                                                    |32-bit|64-bit|\n|-------------------|----------------------------------------------------|:----:|:----:|\n| (unused)          |                                                    |4     |8     | \n| (unused)          |                                                    |4     |4     |\n| (unused)          |                                                    |4     |4     |\n| `unsigned flags_` | `kBoolType` (either `kTrueFlag` or `kFalseFlag`) |4     |4     |\n\n| String              |                                     |32-bit|64-bit|\n|---------------------|-------------------------------------|:----:|:----:|\n| `Ch* str`           | Pointer to the string (may own)     |4     |8     | \n| `SizeType length`   | Length of string                    |4     |4     |\n| (unused)            |                                     |4     |4     |\n| `unsigned flags_`   | `kStringType kStringFlag ...`       |4     |4     |\n\n| Object              |                                     |32-bit|64-bit|\n|---------------------|-------------------------------------|:----:|:----:|\n| `Member* members`   | Pointer to array of members (owned) |4     |8     | \n| `SizeType size`     | Number of members                   |4     |4     |\n| `SizeType capacity` | Capacity of members                 |4     |4     |\n| `unsigned flags_`   | `kObjectType kObjectFlag`           |4     |4     |\n\n| Array               |                                     |32-bit|64-bit|\n|---------------------|-------------------------------------|:----:|:----:|\n| `Value* values`     | Pointer to array of values (owned)  |4     |8     | \n| `SizeType size`     | Number of values                    |4     |4     |\n| `SizeType capacity` | Capacity of values                  |4     |4     |\n| `unsigned flags_`   | `kArrayType kArrayFlag`             |4     |4     |\n\n| Number (Int)        |                                     |32-bit|64-bit|\n|---------------------|-------------------------------------|:----:|:----:|\n| `int i`             | 32-bit signed integer               |4     |4     | \n| (zero padding)      | 0                                   |4     |4     |\n| (unused)            |                                     |4     |8     |\n| `unsigned flags_`   | `kNumberType kNumberFlag kIntFlag kInt64Flag ...` |4     |4     |\n\n| Number (UInt)       |                                     |32-bit|64-bit|\n|---------------------|-------------------------------------|:----:|:----:|\n| `unsigned u`        | 32-bit unsigned integer             |4     |4     | \n| (zero padding)      | 0                                   |4     |4     |\n| (unused)            |                                     |4     |8     |\n| `unsigned flags_`   | `kNumberType kNumberFlag kUIntFlag kUInt64Flag ...` |4     |4     |\n\n| Number (Int64)      |                                     |32-bit|64-bit|\n|---------------------|-------------------------------------|:----:|:----:|\n| `int64_t i64`       | 64-bit signed integer               |8     |8     | \n| (unused)            |                                     |4     |8     |\n| `unsigned flags_`   | `kNumberType kNumberFlag kInt64Flag ...`          |4     |4     |\n\n| Number (Uint64)     |                                     |32-bit|64-bit|\n|---------------------|-------------------------------------|:----:|:----:|\n| `uint64_t i64`      | 64-bit unsigned integer             |8     |8     | \n| (unused)            |                                     |4     |8     |\n| `unsigned flags_`   | `kNumberType kNumberFlag kInt64Flag ...`          |4     |4     |\n\n| Number (Double)     |                                     |32-bit|64-bit|\n|---------------------|-------------------------------------|:----:|:----:|\n| `uint64_t i64`      | Double precision floating-point     |8     |8     | \n| (unused)            |                                     |4     |8     |\n| `unsigned flags_`   | `kNumberType kNumberFlag kDoubleFlag` |4     |4     |\n\nHere are some notes:\n* To reduce memory consumption for 64-bit architecture, `SizeType` is typedef as `unsigned` instead of `size_t`.\n* Zero padding for 32-bit number may be placed after or before the actual type, according to the endianess. This makes possible for interpreting a 32-bit integer as a 64-bit integer, without any conversion.\n* An `Int` is always an `Int64`, but the converse is not always true.\n\n## Flags {#Flags}\n\nThe 32-bit `flags_` contains both JSON type and other additional information. As shown in the above tables, each JSON type contains redundant `kXXXType` and `kXXXFlag`. This design is for optimizing the operation of testing bit-flags (`IsNumber()`) and obtaining a sequential number for each type (`GetType()`).\n\nString has two optional flags. `kCopyFlag` means that the string owns a copy of the string. `kInlineStrFlag` means using [Short-String Optimization](#ShortString).\n\nNumber is a bit more complicated. For normal integer values, it can contains `kIntFlag`, `kUintFlag`,  `kInt64Flag` and/or `kUint64Flag`, according to the range of the integer. For numbers with fraction, and integers larger than 64-bit range, they will be stored as `double` with `kDoubleFlag`.\n\n## Short-String Optimization {#ShortString}\n\n [Kosta](https://github.com/Kosta-Github) provided a very neat short-string optimization. The optimization idea is given as follow. Excluding the `flags_`, a `Value` has 12 or 16 bytes (32-bit or 64-bit) for storing actual data. Instead of storing a pointer to a string, it is possible to store short strings in these space internally. For encoding with 1-byte character type (e.g. `char`), it can store maximum 11 or 15 characters string inside the `Value` type.\n\n| ShortString (Ch=char) |                                   |32-bit|64-bit|\n|---------------------|-------------------------------------|:----:|:----:|\n| `Ch str[MaxChars]`  | String buffer                       |11    |15    | \n| `Ch invLength`      | MaxChars - Length                   |1     |1     |\n| `unsigned flags_`   | `kStringType kStringFlag ...`       |4     |4     |\n\nA special technique is applied. Instead of storing the length of string directly, it stores (MaxChars - length). This make it possible to store 11 characters with trailing `\\0`.\n\nThis optimization can reduce memory usage for copy-string. It can also improve cache-coherence thus improve runtime performance.\n\n# Allocator {#InternalAllocator}\n\n`Allocator` is a concept in RapidJSON:\n~~~cpp\nconcept Allocator {\n    static const bool kNeedFree;    //!< Whether this allocator needs to call Free().\n\n    // Allocate a memory block.\n    // \\param size of the memory block in bytes.\n    // \\returns pointer to the memory block.\n    void* Malloc(size_t size);\n\n    // Resize a memory block.\n    // \\param originalPtr The pointer to current memory block. Null pointer is permitted.\n    // \\param originalSize The current size in bytes. (Design issue: since some allocator may not book-keep this, explicitly pass to it can save memory.)\n    // \\param newSize the new size in bytes.\n    void* Realloc(void* originalPtr, size_t originalSize, size_t newSize);\n\n    // Free a memory block.\n    // \\param pointer to the memory block. Null pointer is permitted.\n    static void Free(void *ptr);\n};\n~~~\n\nNote that `Malloc()` and `Realloc()` are member functions but `Free()` is static member function.\n\n## MemoryPoolAllocator {#MemoryPoolAllocator}\n\n`MemoryPoolAllocator` is the default allocator for DOM. It allocate but do not free memory. This is suitable for building a DOM tree.\n\nInternally, it allocates chunks of memory from the base allocator (by default `CrtAllocator`) and stores the chunks as a singly linked list. When user requests an allocation, it allocates memory from the following order:\n\n1. User supplied buffer if it is available. (See [User Buffer section in DOM](doc/dom.md))\n2. If user supplied buffer is full, use the current memory chunk.\n3. If the current block is full, allocate a new block of memory.\n\n# Parsing Optimization {#ParsingOptimization}\n\n## Skip Whitespaces with SIMD {#SkipwhitespaceWithSIMD}\n\nWhen parsing JSON from a stream, the parser need to skip 4 whitespace characters:\n\n1. Space (`U+0020`)\n2. Character Tabulation (`U+000B`)\n3. Line Feed (`U+000A`)\n4. Carriage Return (`U+000D`)\n\nA simple implementation will be simply:\n~~~cpp\nvoid SkipWhitespace(InputStream& s) {\n    while (s.Peek() == ' ' || s.Peek() == '\\n' || s.Peek() == '\\r' || s.Peek() == '\\t')\n        s.Take();\n}\n~~~\n\nHowever, this requires 4 comparisons and a few branching for each character. This was found to be a hot spot.\n\nTo accelerate this process, SIMD was applied to compare 16 characters with 4 white spaces for each iteration. Currently RapidJSON only supports SSE2 and SSE4.2 instructions for this. And it is only activated for UTF-8 memory streams, including string stream or *in situ* parsing. \n\nTo enable this optimization, need to define `RAPIDJSON_SSE2` or `RAPIDJSON_SSE42` before including `rapidjson.h`. Some compilers can detect the setting, as in `perftest.h`:\n\n~~~cpp\n// __SSE2__ and __SSE4_2__ are recognized by gcc, clang, and the Intel compiler.\n// We use -march=native with gmake to enable -msse2 and -msse4.2, if supported.\n#if defined(__SSE4_2__)\n#  define RAPIDJSON_SSE42\n#elif defined(__SSE2__)\n#  define RAPIDJSON_SSE2\n#endif\n~~~\n\nNote that, these are compile-time settings. Running the executable on a machine without such instruction set support will make it crash.\n\n### Page boundary issue\n\nIn an early version of RapidJSON, [an issue](https://code.google.com/archive/p/rapidjson/issues/104) reported that the `SkipWhitespace_SIMD()` causes crash very rarely (around 1 in 500,000). After investigation, it is suspected that `_mm_loadu_si128()` accessed bytes after `'\\0'`, and across a protected page boundary.\n\nIn [Intel® 64 and IA-32 Architectures Optimization Reference Manual\n](http://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-optimization-manual.html), section 10.2.1:\n\n> To support algorithms requiring unaligned 128-bit SIMD memory accesses, memory buffer allocation by a caller function should consider adding some pad space so that a callee function can safely use the address pointer safely with unaligned 128-bit SIMD memory operations.\n> The minimal padding size should be the width of the SIMD register that might be used in conjunction with unaligned SIMD memory access.\n\nThis is not feasible as RapidJSON should not enforce such requirement.\n\nTo fix this issue, currently the routine process bytes up to the next aligned address. After tha, use aligned read to perform SIMD processing. Also see [#85](https://github.com/miloyip/rapidjson/issues/85).\n\n## Local Stream Copy {#LocalStreamCopy}\n\nDuring optimization, it is found that some compilers cannot localize some member data access of streams into local variables or registers. Experimental results show that for some stream types, making a copy of the stream and used it in inner-loop can improve performance. For example, the actual (non-SIMD) implementation of `SkipWhitespace()` is implemented as:\n\n~~~cpp\ntemplate<typename InputStream>\nvoid SkipWhitespace(InputStream& is) {\n    internal::StreamLocalCopy<InputStream> copy(is);\n    InputStream& s(copy.s);\n\n    while (s.Peek() == ' ' || s.Peek() == '\\n' || s.Peek() == '\\r' || s.Peek() == '\\t')\n        s.Take();\n}\n~~~\n\nDepending on the traits of stream, `StreamLocalCopy` will make (or not make) a copy of the stream object, use it locally and copy the states of stream back to the original stream.\n\n## Parsing to Double {#ParsingDouble}\n\nParsing string into `double` is difficult. The standard library function `strtod()` can do the job but it is slow. By default, the parsers use normal precision setting. This has has maximum 3 [ULP](http://en.wikipedia.org/wiki/Unit_in_the_last_place) error and implemented in `internal::StrtodNormalPrecision()`.\n\nWhen using `kParseFullPrecisionFlag`, the parsers calls `internal::StrtodFullPrecision()` instead, and this function actually implemented 3 versions of conversion methods.\n1. [Fast-Path](http://www.exploringbinary.com/fast-path-decimal-to-floating-point-conversion/).\n2. Custom DIY-FP implementation as in [double-conversion](https://github.com/floitsch/double-conversion).\n3. Big Integer Method as in (Clinger, William D. How to read floating point numbers accurately. Vol. 25. No. 6. ACM, 1990).\n\nIf the first conversion methods fail, it will try the second, and so on.\n\n# Generation Optimization {#GenerationOptimization}\n\n## Integer-to-String conversion {#itoa}\n\nThe naive algorithm for integer-to-string conversion involves division per each decimal digit. We have implemented various implementations and evaluated them in [itoa-benchmark](https://github.com/miloyip/itoa-benchmark).\n\nAlthough SSE2 version is the fastest but the difference is minor by comparing to the first running-up `branchlut`. And `branchlut` is pure C++ implementation so we adopt `branchlut` in RapidJSON.\n\n## Double-to-String conversion {#dtoa}\n\nOriginally RapidJSON uses `snprintf(..., ..., \"%g\")`  to achieve double-to-string conversion. This is not accurate as the default precision is 6. Later we also find that this is slow and there is an alternative.\n\nGoogle's V8 [double-conversion](https://github.com/floitsch/double-conversion\n) implemented a newer, fast algorithm called Grisu3 (Loitsch, Florian. \"Printing floating-point numbers quickly and accurately with integers.\" ACM Sigplan Notices 45.6 (2010): 233-243.).\n\nHowever, since it is not header-only so that we implemented a header-only version of Grisu2. This algorithm guarantees that the result is always accurate. And in most of cases it produces the shortest (optimal) string representation.\n\nThe header-only conversion function has been evaluated in [dtoa-benchmark](https://github.com/miloyip/dtoa-benchmark).\n\n# Parser {#Parser}\n\n## Iterative Parser {#IterativeParser}\n\nThe iterative parser is a recursive descent LL(1) parser\nimplemented in a non-recursive manner.\n\n### Grammar {#IterativeParserGrammar}\n\nThe grammar used for this parser is based on strict JSON syntax:\n~~~~~~~~~~\nS -> array | object\narray -> [ values ]\nobject -> { members }\nvalues -> non-empty-values | ε\nnon-empty-values -> value addition-values\naddition-values -> ε | , non-empty-values\nmembers -> non-empty-members | ε\nnon-empty-members -> member addition-members\naddition-members -> ε | , non-empty-members\nmember -> STRING : value\nvalue -> STRING | NUMBER | NULL | BOOLEAN | object | array\n~~~~~~~~~~\n\nNote that left factoring is applied to non-terminals `values` and `members`\nto make the grammar be LL(1).\n\n### Parsing Table {#IterativeParserParsingTable}\n\nBased on the grammar, we can construct the FIRST and FOLLOW set.\n\nThe FIRST set of non-terminals is listed below:\n\n|    NON-TERMINAL   |               FIRST              |\n|:-----------------:|:--------------------------------:|\n|       array       |                 [                |\n|       object      |                 {                |\n|       values      | ε STRING NUMBER NULL BOOLEAN { [ |\n|  addition-values  |              ε COMMA             |\n|      members      |             ε STRING             |\n|  addition-members |              ε COMMA             |\n|       member      |              STRING              |\n|       value       |  STRING NUMBER NULL BOOLEAN { [  |\n|         S         |                [ {               |\n| non-empty-members |              STRING              |\n|  non-empty-values |  STRING NUMBER NULL BOOLEAN { [  |\n\nThe FOLLOW set is listed below:\n\n|    NON-TERMINAL   |  FOLLOW |\n|:-----------------:|:-------:|\n|         S         |    $    |\n|       array       | , $ } ] |\n|       object      | , $ } ] |\n|       values      |    ]    |\n|  non-empty-values |    ]    |\n|  addition-values  |    ]    |\n|      members      |    }    |\n| non-empty-members |    }    |\n|  addition-members |    }    |\n|       member      |   , }   |\n|       value       |  , } ]  |\n\nFinally the parsing table can be constructed from FIRST and FOLLOW set:\n\n|    NON-TERMINAL   |           [           |           {           |          ,          | : | ] | } |          STRING         |         NUMBER        |          NULL         |        BOOLEAN        |\n|:-----------------:|:---------------------:|:---------------------:|:-------------------:|:-:|:-:|:-:|:-----------------------:|:---------------------:|:---------------------:|:---------------------:|\n|         S         |         array         |         object        |                     |   |   |   |                         |                       |                       |                       |\n|       array       |       [ values ]      |                       |                     |   |   |   |                         |                       |                       |                       |\n|       object      |                       |      { members }      |                     |   |   |   |                         |                       |                       |                       |\n|       values      |    non-empty-values   |    non-empty-values   |                     |   | ε |   |     non-empty-values    |    non-empty-values   |    non-empty-values   |    non-empty-values   |\n|  non-empty-values | value addition-values | value addition-values |                     |   |   |   |  value addition-values  | value addition-values | value addition-values | value addition-values |\n|  addition-values  |                       |                       |  , non-empty-values |   | ε |   |                         |                       |                       |                       |\n|      members      |                       |                       |                     |   |   | ε |    non-empty-members    |                       |                       |                       |\n| non-empty-members |                       |                       |                     |   |   |   | member addition-members |                       |                       |                       |\n|  addition-members |                       |                       | , non-empty-members |   |   | ε |                         |                       |                       |                       |\n|       member      |                       |                       |                     |   |   |   |      STRING : value     |                       |                       |                       |\n|       value       |         array         |         object        |                     |   |   |   |          STRING         |         NUMBER        |          NULL         |        BOOLEAN        |\n\nThere is a great [tool](http://hackingoff.com/compilers/predict-first-follow-set) for above grammar analysis.\n\n### Implementation {#IterativeParserImplementation}\n\nBased on the parsing table, a direct(or conventional) implementation\nthat pushes the production body in reverse order\nwhile generating a production could work.\n\nIn RapidJSON, several modifications(or adaptations to current design) are made to a direct implementation.\n\nFirst, the parsing table is encoded in a state machine in RapidJSON.\nStates are constructed by the head and body of production.\nState transitions are constructed by production rules.\nBesides, extra states are added for productions involved with `array` and `object`.\nIn this way the generation of array values or object members would be a single state transition,\nrather than several pop/push operations in the direct implementation.\nThis also makes the estimation of stack size more easier.\n\nThe state diagram is shown as follows:\n\n![State Diagram](diagram/iterative-parser-states-diagram.png)\n\nSecond, the iterative parser also keeps track of array's value count and object's member count\nin its internal stack, which may be different from a conventional implementation.\n"
  },
  {
    "path": "ext/rapidjson/doc/misc/DoxygenLayout.xml",
    "content": "<doxygenlayout version=\"1.0\">\n  <!-- Generated by doxygen 1.8.7 -->\n  <!-- Navigation index tabs for HTML output -->\n  <navindex>\n    <tab type=\"mainpage\" visible=\"yes\" title=\"\"/>\n    <tab type=\"pages\" visible=\"yes\" title=\"\" intro=\"\"/>\n    <tab type=\"modules\" visible=\"yes\" title=\"\" intro=\"\"/>\n    <tab type=\"namespaces\" visible=\"yes\" title=\"\">\n      <tab type=\"namespacelist\" visible=\"yes\" title=\"\" intro=\"\"/>\n      <tab type=\"namespacemembers\" visible=\"yes\" title=\"\" intro=\"\"/>\n    </tab>\n    <tab type=\"classes\" visible=\"yes\" title=\"\">\n      <tab type=\"classlist\" visible=\"yes\" title=\"\" intro=\"\"/>\n      <tab type=\"classindex\" visible=\"$ALPHABETICAL_INDEX\" title=\"\"/> \n      <tab type=\"hierarchy\" visible=\"yes\" title=\"\" intro=\"\"/>\n      <tab type=\"classmembers\" visible=\"yes\" title=\"\" intro=\"\"/>\n    </tab>\n    <tab type=\"files\" visible=\"yes\" title=\"\">\n      <tab type=\"filelist\" visible=\"yes\" title=\"\" intro=\"\"/>\n      <tab type=\"globals\" visible=\"yes\" title=\"\" intro=\"\"/>\n    </tab>\n    <tab type=\"examples\" visible=\"yes\" title=\"\" intro=\"\"/>  \n  </navindex>\n\n  <!-- Layout definition for a class page -->\n  <class>\n    <briefdescription visible=\"yes\"/>\n    <includes visible=\"$SHOW_INCLUDE_FILES\"/>\n    <inheritancegraph visible=\"$CLASS_GRAPH\"/>\n    <collaborationgraph visible=\"$COLLABORATION_GRAPH\"/>\n    <memberdecl>\n      <nestedclasses visible=\"yes\" title=\"\"/>\n      <publictypes title=\"\"/>\n      <services title=\"\"/>\n      <interfaces title=\"\"/>\n      <publicslots title=\"\"/>\n      <signals title=\"\"/>\n      <publicmethods title=\"\"/>\n      <publicstaticmethods title=\"\"/>\n      <publicattributes title=\"\"/>\n      <publicstaticattributes title=\"\"/>\n      <protectedtypes title=\"\"/>\n      <protectedslots title=\"\"/>\n      <protectedmethods title=\"\"/>\n      <protectedstaticmethods title=\"\"/>\n      <protectedattributes title=\"\"/>\n      <protectedstaticattributes title=\"\"/>\n      <packagetypes title=\"\"/>\n      <packagemethods title=\"\"/>\n      <packagestaticmethods title=\"\"/>\n      <packageattributes title=\"\"/>\n      <packagestaticattributes title=\"\"/>\n      <properties title=\"\"/>\n      <events title=\"\"/>\n      <privatetypes title=\"\"/>\n      <privateslots title=\"\"/>\n      <privatemethods title=\"\"/>\n      <privatestaticmethods title=\"\"/>\n      <privateattributes title=\"\"/>\n      <privatestaticattributes title=\"\"/>\n      <friends title=\"\"/>\n      <related title=\"\" subtitle=\"\"/>\n      <membergroups visible=\"yes\"/>\n    </memberdecl>\n    <detaileddescription title=\"\"/>\n    <memberdef>\n      <inlineclasses title=\"\"/>\n      <typedefs title=\"\"/>\n      <enums title=\"\"/>\n      <services title=\"\"/>\n      <interfaces title=\"\"/>\n      <constructors title=\"\"/>\n      <functions title=\"\"/>\n      <related title=\"\"/>\n      <variables title=\"\"/>\n      <properties title=\"\"/>\n      <events title=\"\"/>\n    </memberdef>\n    <allmemberslink visible=\"yes\"/>\n    <usedfiles visible=\"$SHOW_USED_FILES\"/>\n    <authorsection visible=\"yes\"/>\n  </class>\n\n  <!-- Layout definition for a namespace page -->\n  <namespace>\n    <briefdescription visible=\"yes\"/>\n    <memberdecl>\n      <nestednamespaces visible=\"yes\" title=\"\"/>\n      <constantgroups visible=\"yes\" title=\"\"/>\n      <classes visible=\"yes\" title=\"\"/>\n      <typedefs title=\"\"/>\n      <enums title=\"\"/>\n      <functions title=\"\"/>\n      <variables title=\"\"/>\n      <membergroups visible=\"yes\"/>\n    </memberdecl>\n    <detaileddescription title=\"\"/>\n    <memberdef>\n      <inlineclasses title=\"\"/>\n      <typedefs title=\"\"/>\n      <enums title=\"\"/>\n      <functions title=\"\"/>\n      <variables title=\"\"/>\n    </memberdef>\n    <authorsection visible=\"yes\"/>\n  </namespace>\n\n  <!-- Layout definition for a file page -->\n  <file>\n    <briefdescription visible=\"yes\"/>\n    <includes visible=\"$SHOW_INCLUDE_FILES\"/>\n    <includegraph visible=\"$INCLUDE_GRAPH\"/>\n    <includedbygraph visible=\"$INCLUDED_BY_GRAPH\"/>\n    <sourcelink visible=\"yes\"/>\n    <memberdecl>\n      <classes visible=\"yes\" title=\"\"/>\n      <namespaces visible=\"yes\" title=\"\"/>\n      <constantgroups visible=\"yes\" title=\"\"/>\n      <defines title=\"\"/>\n      <typedefs title=\"\"/>\n      <enums title=\"\"/>\n      <functions title=\"\"/>\n      <variables title=\"\"/>\n      <membergroups visible=\"yes\"/>\n    </memberdecl>\n    <detaileddescription title=\"\"/>\n    <memberdef>\n      <inlineclasses title=\"\"/>\n      <defines title=\"\"/>\n      <typedefs title=\"\"/>\n      <enums title=\"\"/>\n      <functions title=\"\"/>\n      <variables title=\"\"/>\n    </memberdef>\n    <authorsection/>\n  </file>\n\n  <!-- Layout definition for a group page -->\n  <group>\n    <briefdescription visible=\"yes\"/>\n    <groupgraph visible=\"$GROUP_GRAPHS\"/>\n    <memberdecl>\n      <nestedgroups visible=\"yes\" title=\"\"/>\n      <dirs visible=\"yes\" title=\"\"/>\n      <files visible=\"yes\" title=\"\"/>\n      <namespaces visible=\"yes\" title=\"\"/>\n      <classes visible=\"yes\" title=\"\"/>\n      <defines title=\"\"/>\n      <typedefs title=\"\"/>\n      <enums title=\"\"/>\n      <enumvalues title=\"\"/>\n      <functions title=\"\"/>\n      <variables title=\"\"/>\n      <signals title=\"\"/>\n      <publicslots title=\"\"/>\n      <protectedslots title=\"\"/>\n      <privateslots title=\"\"/>\n      <events title=\"\"/>\n      <properties title=\"\"/>\n      <friends title=\"\"/>\n      <membergroups visible=\"yes\"/>\n    </memberdecl>\n    <detaileddescription title=\"\"/>\n    <memberdef>\n      <pagedocs/>\n      <inlineclasses title=\"\"/>\n      <defines title=\"\"/>\n      <typedefs title=\"\"/>\n      <enums title=\"\"/>\n      <enumvalues title=\"\"/>\n      <functions title=\"\"/>\n      <variables title=\"\"/>\n      <signals title=\"\"/>\n      <publicslots title=\"\"/>\n      <protectedslots title=\"\"/>\n      <privateslots title=\"\"/>\n      <events title=\"\"/>\n      <properties title=\"\"/>\n      <friends title=\"\"/>\n    </memberdef>\n    <authorsection visible=\"yes\"/>\n  </group>\n\n  <!-- Layout definition for a directory page -->\n  <directory>\n    <briefdescription visible=\"yes\"/>\n    <directorygraph visible=\"yes\"/>\n    <memberdecl>\n      <dirs visible=\"yes\"/>\n      <files visible=\"yes\"/>\n    </memberdecl>\n    <detaileddescription title=\"\"/>\n  </directory>\n</doxygenlayout>\n"
  },
  {
    "path": "ext/rapidjson/doc/misc/doxygenextra.css",
    "content": "body code {\n\tmargin: 0;\n\tborder: 1px solid #ddd;\n\tbackground-color: #f8f8f8;\n\tborder-radius: 3px;\n\tpadding: 0;\n}\n\na {\n\tcolor: #4183c4;\n}\n\na.el {\n\tfont-weight: normal;\n}\n\nbody, table, div, p, dl {\n\tcolor: #333333;\n\tfont-family: Helvetica, arial, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol';\n\tfont-size: 15px;\n\tfont-style: normal;\n\tfont-variant: normal;\n\tfont-weight: normal;\n\tline-height: 25.5px;\n}\n\nbody {\n\tbackground-color: #eee;\n}\n\ndiv.header {\n\tbackground-image: none;\n\tbackground-color: white;\n\tmargin: 0px;\n\tborder: 0px;\n}\n\ndiv.headertitle {\n\twidth: 858px;\n\tmargin: 30px;\n\tpadding: 0px;\n}\n\ndiv.toc {\n\tbackground-color: #f8f8f8;\n\tborder-color: #ddd;\n\tmargin-right: 10px;\n\tmargin-left: 20px;\n}\ndiv.toc h3 {\n\tcolor: #333333;\n\tfont-family: Helvetica, arial, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol';\n\tfont-size: 18px;\n\tfont-style: normal;\n\tfont-variant: normal;\n\tfont-weight: normal;\n}\ndiv.toc li {\n\tcolor: #333333;\n\tfont-family: Helvetica, arial, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol';\n\tfont-size: 12px;\n\tfont-style: normal;\n\tfont-variant: normal;\n\tfont-weight: normal;\n}\n\n.title {\n\tfont-size: 2.5em;\n\tline-height: 63.75px;\n\tborder-bottom: 1px solid #ddd;\n\tmargin-bottom: 15px;\n\tmargin-left: 0px;\n\tmargin-right: 0px;\n\tmargin-top: 0px;\n}\n\n.summary {\n\tfloat: none !important;\n\twidth: auto !important;\n\tpadding-top: 10px;\n\tpadding-right: 10px !important;\n}\n\n.summary + .headertitle .title {\n\tfont-size: 1.5em;\n\tline-height: 2.0em;\n}\n\nbody h1 {\n\tfont-size: 2em;\n\tline-height: 1.7;\n\tborder-bottom: 1px solid #eee;\n\tmargin: 1em 0 15px;\n\tpadding: 0;\n\toverflow: hidden;\n}\n\nbody h2 {\n\tfont-size: 1.5em;\n\tline-height: 1.7;\n\tmargin: 1em 0 15px;\n\tpadding: 0;\n}\n\npre.fragment {\n\tfont-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;\n\tfont-size: 13px;\n\tfont-style: normal;\n\tfont-variant: normal;\n\tfont-weight: normal;\n\tline-height: 19px;\n}\n\ntable.doxtable th {\n\tbackground-color: #f8f8f8;\n\tcolor: #333333;\n\tfont-size: 15px;\n}\n\ntable.doxtable td, table.doxtable th {\n\tborder: 1px solid #ddd;\n}\n\n#doc-content {\n\tbackground-color: #fff;\n\twidth: 918px;\n\theight: auto !important;\n\tmargin-left: 270px !important;\n}\n\ndiv.contents {\n\twidth: 858px;\n\tmargin: 30px;\n}\n\ndiv.line {\n\tfont-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;\n\tfont-size: 13px;\n\tfont-style: normal;\n\tfont-variant: normal;\n\tfont-weight: normal;\n\tline-height: 19px;\t\n}\n\ntt, code, pre {\n\tfont-family: Consolas, \"Liberation Mono\", Menlo, Courier, monospace;\n\tfont-size: 12px;\n}\n\ndiv.fragment {\n\tbackground-color: #f8f8f8;\n\tborder: 1px solid #ddd;\n\tfont-size: 13px;\n\tline-height: 19px;\n\toverflow: auto;\n\tpadding: 6px 10px;\n\tborder-radius: 3px;\n}\n\n#topbanner {\n\tposition: fixed;\n\tmargin: 15px;\n\tz-index: 101;\n}\n\n#projectname\n{\n\tfont-family: Helvetica, arial, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol';\n\tfont-size: 38px;\n\tfont-weight: bold;\n\tline-height: 63.75px;\n\tmargin: 0px;\n\tpadding: 2px 0px;\n}\n    \n#projectbrief\n{\n\tfont-family: Helvetica, arial, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol';\n\tfont-size: 16px;\n\tline-height: 22.4px;\n\tmargin: 0px 0px 13px 0px;\n\tpadding: 2px;\n}\n\n/* side bar and search */\n\n#side-nav\n{\n\tpadding: 10px 0px 20px 20px;\n\tborder-top: 60px solid #2980b9;\n\tbackground-color: #343131;\n\twidth: 250px !important;\n\theight: 100% !important;\n\tposition: fixed;\n}\n\n#nav-tree\n{\n\tbackground-color: transparent;\n\tbackground-image: none;\n\theight: 100% !important;\n}\n\n#nav-tree .label\n{\n\tfont-family: Helvetica, arial, freesans, clean, sans-serif, 'Segoe UI Emoji', 'Segoe UI Symbol';\n\tline-height: 25.5px;\t\n\tfont-size: 15px;\n}\n\n#nav-tree\n{\n\tcolor: #b3b3b3;\n}\n\n#nav-tree .selected {\n\tbackground-image: none;\n}\n\n#nav-tree a\n{\n\tcolor: #b3b3b3;\n}\n\n#github\n{\n\tposition: fixed;\n\tleft: auto;\n\tright: auto;\n\twidth: 250px;\n}\n\n#MSearchBox\n{\n\tmargin: 20px;\n\tleft: 40px;\n\tright: auto;\n\tposition: fixed;\n\twidth: 180px;\n}\n\n#MSearchField\n{\n\twidth: 121px;\n}\n\n#MSearchResultsWindow\n{\n\tleft: 45px !important;\n}\n\n#nav-sync\n{\n\tdisplay: none;\n}\n\n.ui-resizable .ui-resizable-handle\n{\n\twidth: 0px;\n}\n\n#nav-path\n{\n\tdisplay: none;\n}\n\n/* external link icon */\ndiv.contents a[href ^= \"http\"]:after {\n     content: \" \" url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAVklEQVR4Xn3PgQkAMQhDUXfqTu7kTtkpd5RA8AInfArtQ2iRXFWT2QedAfttj2FsPIOE1eCOlEuoWWjgzYaB/IkeGOrxXhqB+uA9Bfcm0lAZuh+YIeAD+cAqSz4kCMUAAAAASUVORK5CYII=);\n}\n\n.githublogo {\n\tcontent: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDIxIDc5LjE1NDkxMSwgMjAxMy8xMC8yOS0xMTo0NzoxNiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RERCMUIwOUY4NkNFMTFFM0FBNTJFRTMzNTJEMUJDNDYiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RERCMUIwOUU4NkNFMTFFM0FBNTJFRTMzNTJEMUJDNDYiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkU1MTc4QTJBOTlBMDExRTI5QTE1QkMxMDQ2QTg5MDREIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkU1MTc4QTJCOTlBMDExRTI5QTE1QkMxMDQ2QTg5MDREIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+jUqS1wAAApVJREFUeNq0l89rE1EQx3e3gVJoSPzZeNEWPKgHoa0HBak0iHiy/4C3WvDmoZ56qJ7txVsPQu8qlqqHIhRKJZceesmhioQEfxTEtsoSpdJg1u/ABJ7Pmc1m8zLwgWTmzcw3L+/te+tHUeQltONgCkyCi2AEDHLsJ6iBMlgHL8FeoqokoA2j4CloRMmtwTmj7erHBXPgCWhG6a3JNXKdCiDl1cidVbXZkJoXQRi5t5BrxwoY71FzU8S4JuAIqFkJ2+BFSlEh525b/hr3+k/AklDkNsf6wTT4yv46KIMNpsy+iMdMc47HNWxbsgVcUn7FmLAzzoFAWDsBx+wVP6bUpp5ewI+DOeUx0Wd9D8F70BTGNjkWtqnhmT1JQAHcUgZd8Lo3rQb1LAT8eJVUfgGvHQigGp+V2Z0iAUUl8QH47kAA1XioxIo+bRN8OG8F/oBjwv+Z1nJgX5jpdzQDw0LCjsPmrcW7I/iHScCAEDj03FtD8A0EyuChHgg4KTlJQF3wZ7WELppnBX+dBFSVpJsOBWi1qiRgSwnOgoyD5hmuJdkWCVhTgnTvW3AgYIFrSbZGh0UW/Io5Vp+DQoK7o80pztWMemZbgxeNwCNwDbw1fIfgGZjhU6xPaJgBV8BdsMw5cbZoHsenwYFxkZzl83xTSKTiviCAfCsJLysH3POfC8m8NegyGAGfLP/VmGmfSChgXroR0RSWjEFv2J/nG84cuKFMf4sTCZqXuJd4KaXFVjEG3+tw4eXbNK/YC9oXXs3O8NY8y99L4BXY5cvLY/Bb2VZ58EOJVcB18DHJq9lRsKr8inyKGVjlmh29mtHs3AHfuhCwy1vXT/Nu2GKQt+UHsGdctyX6eQyNvc+5sfX9Dl7Pe2J/BRgAl2CpwmrsHR0AAAAASUVORK5CYII=);\n}"
  },
  {
    "path": "ext/rapidjson/doc/misc/footer.html",
    "content": "<!-- HTML footer for doxygen 1.8.7-->\n<!-- start footer part -->\n<!--BEGIN GENERATE_TREEVIEW-->\n<div id=\"nav-path\" class=\"navpath\"><!-- id is needed for treeview function! -->\n  <ul>\n    $navpath\n  </ul>\n</div>\n<!--END GENERATE_TREEVIEW-->\n</body>\n</html>\n"
  },
  {
    "path": "ext/rapidjson/doc/misc/header.html",
    "content": "<!-- HTML header for doxygen 1.8.7-->\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/xhtml;charset=UTF-8\"/>\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=9\"/>\n<meta name=\"generator\" content=\"Doxygen $doxygenversion\"/>\n<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME-->\n<!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME-->\n<link href=\"$relpath^tabs.css\" rel=\"stylesheet\" type=\"text/css\"/>\n<script type=\"text/javascript\" src=\"$relpath^jquery.js\"></script>\n<script type=\"text/javascript\" src=\"$relpath^dynsections.js\"></script>\n$treeview\n$search\n$mathjax\n<link href=\"$relpath^$stylesheet\" rel=\"stylesheet\" type=\"text/css\" />\n$extrastylesheet\n</head>\n<body>\n<div id=\"top\"><!-- do not remove this div, it is closed by doxygen! -->\n<div id=\"topbanner\"><a href=\"https://github.com/miloyip/rapidjson\" title=\"RapidJSON GitHub\"><i class=\"githublogo\"></i></a></div>\n$searchbox\n<!--END TITLEAREA-->\n<!-- end header part -->\n"
  },
  {
    "path": "ext/rapidjson/doc/npm.md",
    "content": "## NPM\n\n# package.json {#package}\n\n~~~~~~~~~~js\n{\n  ...\n  \"dependencies\": {\n    ...\n    \"rapidjson\": \"git@github.com:miloyip/rapidjson.git\"\n  },\n  ...\n  \"gypfile\": true\n}\n~~~~~~~~~~\n\n# binding.gyp {#binding}\n\n~~~~~~~~~~js\n{\n  ...\n  'targets': [\n    {\n      ...\n      'include_dirs': [\n        '<!(node -e \\'require(\"rapidjson\")\\')'\n      ]\n    }\n  ]\n}\n~~~~~~~~~~\n"
  },
  {
    "path": "ext/rapidjson/doc/performance.md",
    "content": "# Performance\n\nThere is a [native JSON benchmark collection] [1] which evaluates speed, memory usage and code size of various operations among 37 JSON libaries.\n\n[1]: https://github.com/miloyip/nativejson-benchmark\n\nThe old performance article for RapidJSON 0.1 is provided [here](https://code.google.com/p/rapidjson/wiki/Performance).\n\nAdditionally, you may refer to the following third-party benchmarks.\n\n## Third-party benchmarks\n\n* [Basic benchmarks for miscellaneous C++ JSON parsers and generators](https://github.com/mloskot/json_benchmark) by Mateusz Loskot (Jun 2013)\n * [casablanca](https://casablanca.codeplex.com/)\n * [json_spirit](https://github.com/cierelabs/json_spirit)\n * [jsoncpp](http://jsoncpp.sourceforge.net/)\n * [libjson](http://sourceforge.net/projects/libjson/)\n * [rapidjson](https://github.com/miloyip/rapidjson/)\n * [QJsonDocument](http://qt-project.org/doc/qt-5.0/qtcore/qjsondocument.html)\n \n* [JSON Parser Benchmarking](http://chadaustin.me/2013/01/json-parser-benchmarking/) by Chad Austin (Jan 2013)\n * [sajson](https://github.com/chadaustin/sajson)\n * [rapidjson](https://github.com/miloyip/rapidjson/)\n * [vjson](https://code.google.com/p/vjson/)\n * [YAJL](http://lloyd.github.com/yajl/)\n * [Jansson](http://www.digip.org/jansson/)\n"
  },
  {
    "path": "ext/rapidjson/doc/performance.zh-cn.md",
    "content": "# 性能\n\n有一个 [native JSON benchmark collection][1] 项目，能评估 37 个 JSON 库在不同操作下的速度、內存用量及代码大小。\n\n[1]: https://github.com/miloyip/nativejson-benchmark\n\nRapidJSON 0.1 版本的性能测试文章位于 [这里](https://code.google.com/p/rapidjson/wiki/Performance).\n\n此外，你也可以参考以下这些第三方的评测。\n\n## 第三方评测\n\n* [Basic benchmarks for miscellaneous C++ JSON parsers and generators](https://github.com/mloskot/json_benchmark) by Mateusz Loskot (Jun 2013)\n * [casablanca](https://casablanca.codeplex.com/)\n * [json_spirit](https://github.com/cierelabs/json_spirit)\n * [jsoncpp](http://jsoncpp.sourceforge.net/)\n * [libjson](http://sourceforge.net/projects/libjson/)\n * [rapidjson](https://github.com/miloyip/rapidjson/)\n * [QJsonDocument](http://qt-project.org/doc/qt-5.0/qtcore/qjsondocument.html)\n \n* [JSON Parser Benchmarking](http://chadaustin.me/2013/01/json-parser-benchmarking/) by Chad Austin (Jan 2013)\n * [sajson](https://github.com/chadaustin/sajson)\n * [rapidjson](https://github.com/miloyip/rapidjson/)\n * [vjson](https://code.google.com/p/vjson/)\n * [YAJL](http://lloyd.github.com/yajl/)\n * [Jansson](http://www.digip.org/jansson/)\n"
  },
  {
    "path": "ext/rapidjson/doc/pointer.md",
    "content": "# Pointer\n\n(This feature was released in v1.1.0)\n\nJSON Pointer is a standardized ([RFC6901]) way to select a value inside a JSON Document (DOM). This can be analogous to XPath for XML document. However, JSON Pointer is much simpler, and a single JSON Pointer only pointed to a single value.\n\nUsing RapidJSON's implementation of JSON Pointer can simplify some manipulations of the DOM.\n\n[TOC]\n\n# JSON Pointer {#JsonPointer}\n\nA JSON Pointer is a list of zero-to-many tokens, each prefixed by `/`. Each token can be a string or a number. For example, given a JSON:\n~~~javascript\n{\n    \"foo\" : [\"bar\", \"baz\"],\n    \"pi\" : 3.1416\n}\n~~~\n\nThe following JSON Pointers resolve this JSON as:\n\n1. `\"/foo\"` → `[ \"bar\", \"baz\" ]`\n2. `\"/foo/0\"` → `\"bar\"`\n3. `\"/foo/1\"` → `\"baz\"`\n4. `\"/pi\"` → `3.1416`\n\nNote that, an empty JSON Pointer `\"\"` (zero token) resolves to the whole JSON.\n\n# Basic Usage {#BasicUsage}\n\nThe following example code is self-explanatory.\n\n~~~cpp\n#include \"rapidjson/pointer.h\"\n\n// ...\nDocument d;\n\n// Create DOM by Set()\nPointer(\"/project\").Set(d, \"RapidJSON\");\nPointer(\"/stars\").Set(d, 10);\n\n// { \"project\" : \"RapidJSON\", \"stars\" : 10 }\n\n// Access DOM by Get(). It return nullptr if the value does not exist.\nif (Value* stars = Pointer(\"/stars\").Get(d))\n    stars->SetInt(stars->GetInt() + 1);\n\n// { \"project\" : \"RapidJSON\", \"stars\" : 11 }\n\n// Set() and Create() automatically generate parents if not exist.\nPointer(\"/a/b/0\").Create(d);\n\n// { \"project\" : \"RapidJSON\", \"stars\" : 11, \"a\" : { \"b\" : [ null ] } }\n\n// GetWithDefault() returns reference. And it deep clones the default value.\nValue& hello = Pointer(\"/hello\").GetWithDefault(d, \"world\");\n\n// { \"project\" : \"RapidJSON\", \"stars\" : 11, \"a\" : { \"b\" : [ null ] }, \"hello\" : \"world\" }\n\n// Swap() is similar to Set()\nValue x(\"C++\");\nPointer(\"/hello\").Swap(d, x);\n\n// { \"project\" : \"RapidJSON\", \"stars\" : 11, \"a\" : { \"b\" : [ null ] }, \"hello\" : \"C++\" }\n// x becomes \"world\"\n\n// Erase a member or element, return true if the value exists\nbool success = Pointer(\"/a\").Erase(d);\nassert(success);\n\n// { \"project\" : \"RapidJSON\", \"stars\" : 10 }\n~~~\n\n# Helper Functions {#HelperFunctions}\n\nSince object-oriented calling convention may be non-intuitive, RapidJSON also provides helper functions, which just wrap the member functions with free-functions.\n\nThe following example does exactly the same as the above one.\n\n~~~cpp\nDocument d;\n\nSetValueByPointer(d, \"/project\", \"RapidJSON\");\nSetValueByPointer(d, \"/stars\", 10);\n\nif (Value* stars = GetValueByPointer(d, \"/stars\"))\n    stars->SetInt(stars->GetInt() + 1);\n\nCreateValueByPointer(d, \"/a/b/0\");\n\nValue& hello = GetValueByPointerWithDefault(d, \"/hello\", \"world\");\n\nValue x(\"C++\");\nSwapValueByPointer(d, \"/hello\", x);\n\nbool success = EraseValueByPointer(d, \"/a\");\nassert(success);\n~~~\n\nThe conventions are shown here for comparison:\n\n1. `Pointer(source).<Method>(root, ...)`\n2. `<Method>ValueByPointer(root, Pointer(source), ...)`\n3. `<Method>ValueByPointer(root, source, ...)`\n\n# Resolving Pointer {#ResolvingPointer}\n\n`Pointer::Get()` or `GetValueByPointer()` function does not modify the DOM. If the tokens cannot match a value in the DOM, it returns `nullptr`. User can use this to check whether a value exists.\n\nNote that, numerical tokens can represent an array index or member name. The resolving process will match the values according to the types of value.\n\n~~~javascript\n{\n    \"0\" : 123,\n    \"1\" : [456]\n}\n~~~\n\n1. `\"/0\"` → `123`\n2. `\"/1/0\"` → `456`\n\nThe token `\"0\"` is treated as member name in the first pointer. It is treated as an array index in the second pointer.\n\nThe other functions, including `Create()`, `GetWithDefault()`, `Set()` and `Swap()`, will change the DOM. These functions will always succeed. They will create the parent values if they do not exist. If the parent values do not match the tokens, they will also be forced to change their type. Changing the type also mean fully removal of that DOM subtree.\n\nParsing the above JSON into `d`, \n\n~~~cpp\nSetValueByPointer(d, \"1/a\", 789); // { \"0\" : 123, \"1\" : { \"a\" : 789 } }\n~~~\n\n## Resolving Minus Sign Token\n\nBesides, [RFC6901] defines a special token `-` (single minus sign), which represents the pass-the-end element of an array. `Get()` only treats this token as a member name '\"-\"'. Yet the other functions can resolve this for array, equivalent to calling `Value::PushBack()` to the array.\n\n~~~cpp\nDocument d;\nd.Parse(\"{\\\"foo\\\":[123]}\");\nSetValueByPointer(d, \"/foo/-\", 456); // { \"foo\" : [123, 456] }\nSetValueByPointer(d, \"/-\", 789);    // { \"foo\" : [123, 456], \"-\" : 789 }\n~~~\n\n## Resolving Document and Value\n\nWhen using `p.Get(root)` or `GetValueByPointer(root, p)`, `root` is a (const) `Value&`. That means, it can be a subtree of the DOM.\n\nThe other functions have two groups of signature. One group uses `Document& document` as parameter, another one uses `Value& root`. The first group uses `document.GetAllocator()` for creating values. And the second group needs user to supply an allocator, like the functions in DOM.\n\nAll examples above do not require an allocator parameter, because the first parameter is a `Document&`. But if you want to resolve a pointer to a subtree, you need to supply the allocator as in the following example:\n\n~~~cpp\nclass Person {\npublic:\n    Person() {\n        document_ = new Document();\n        // CreateValueByPointer() here no need allocator\n        SetLocation(CreateValueByPointer(*document_, \"/residence\"), ...);\n        SetLocation(CreateValueByPointer(*document_, \"/office\"), ...);\n    };\n\nprivate:\n    void SetLocation(Value& location, const char* country, const char* addresses[2]) {\n        Value::Allocator& a = document_->GetAllocator();\n        // SetValueByPointer() here need allocator\n        SetValueByPointer(location, \"/country\", country, a);\n        SetValueByPointer(location, \"/address/0\", address[0], a);\n        SetValueByPointer(location, \"/address/1\", address[1], a);\n    }\n\n    // ...\n\n    Document* document_;\n};\n~~~\n\n`Erase()` or `EraseValueByPointer()` does not need allocator. And they return `true` if the value is erased successfully.\n\n# Error Handling {#ErrorHandling}\n\nA `Pointer` parses a source string in its constructor. If there is parsing error, `Pointer::IsValid()` returns `false`. And you can use `Pointer::GetParseErrorCode()` and `GetParseErrorOffset()` to retrieve the error information.\n\nNote that, all resolving functions assumes valid pointer. Resolving with an invalid pointer causes assertion failure.\n\n# URI Fragment Representation {#URIFragment}\n\nIn addition to the string representation of JSON pointer that we are using till now, [RFC6901] also defines the URI fragment representation of JSON pointer. URI fragment is specified in [RFC3986] \"Uniform Resource Identifier (URI): Generic Syntax\".\n\nThe main differences are that a the URI fragment always has a `#` (pound sign) in the beginning, and some characters are encoded by percent-encoding in UTF-8 sequence. For example, the following table shows different C/C++ string literals of different representations.\n\nString Representation | URI Fragment Representation | Pointer Tokens (UTF-8)\n----------------------|-----------------------------|------------------------\n`\"/foo/0\"`            | `\"#/foo/0\"`                 | `{\"foo\", 0}`\n`\"/a~1b\"`             | `\"#/a~1b\"`                  | `{\"a/b\"}`\n`\"/m~0n\"`             | `\"#/m~0n\"`                  | `{\"m~n\"}`\n`\"/ \"`                | `\"#/%20\"`                   | `{\" \"}`\n`\"/\\0\"`               | `\"#/%00\"`                   | `{\"\\0\"}`\n`\"/€\"`                | `\"#/%E2%82%AC\"`             | `{\"€\"}`\n\nRapidJSON fully support URI fragment representation. It automatically detects the pound sign during parsing.\n\n# Stringify\n\nYou may also stringify a `Pointer` to a string or other output streams. This can be done by:\n\n~~~\nPointer p(...);\nStringBuffer sb;\np.Stringify(sb);\nstd::cout << sb.GetString() << std::endl;\n~~~\n\nIt can also stringify to URI fragment reprsentation by `StringifyUriFragment()`.\n\n# User-Supplied Tokens {#UserSuppliedTokens}\n\nIf a pointer will be resolved multiple times, it should be constructed once, and then apply it to different DOMs or in different times. This reduce time and memory allocation for constructing `Pointer` multiple times.\n\nWe can go one step further, to completely eliminate the parsing process and dynamic memory allocation, we can establish the token array directly:\n\n~~~cpp\n#define NAME(s) { s, sizeof(s) / sizeof(s[0]) - 1, kPointerInvalidIndex }\n#define INDEX(i) { #i, sizeof(#i) - 1, i }\n\nstatic const Pointer::Token kTokens[] = { NAME(\"foo\"), INDEX(123) };\nstatic const Pointer p(kTokens, sizeof(kTokens) / sizeof(kTokens[0]));\n// Equivalent to static const Pointer p(\"/foo/123\");\n~~~\n\nThis may be useful for memory constrained systems.\n\n[RFC3986]: https://tools.ietf.org/html/rfc3986\n[RFC6901]: https://tools.ietf.org/html/rfc6901\n"
  },
  {
    "path": "ext/rapidjson/doc/pointer.zh-cn.md",
    "content": "# Pointer\n\n（本功能于 v1.1.0 发布）\n\nJSON Pointer 是一个标准化（[RFC6901]）的方式去选取一个 JSON Document（DOM）中的值。这类似于 XML 的 XPath。然而，JSON Pointer 简单得多，而且每个 JSON Pointer 仅指向单个值。\n\n使用 RapidJSON 的 JSON Pointer 实现能简化一些 DOM 的操作。\n\n[TOC]\n\n# JSON Pointer {#JsonPointer}\n\n一个 JSON Pointer 由一串（零至多个）token 所组成，每个 token 都有 `/` 前缀。每个 token 可以是一个字符串或数字。例如，给定一个 JSON：\n~~~javascript\n{\n    \"foo\" : [\"bar\", \"baz\"],\n    \"pi\" : 3.1416\n}\n~~~\n\n以下的 JSON Pointer 解析为：\n\n1. `\"/foo\"` → `[ \"bar\", \"baz\" ]`\n2. `\"/foo/0\"` → `\"bar\"`\n3. `\"/foo/1\"` → `\"baz\"`\n4. `\"/pi\"` → `3.1416`\n\n要注意，一个空 JSON Pointer `\"\"` （零个 token）解析为整个 JSON。\n\n# 基本使用方法 {#BasicUsage}\n\n以下的代码范例不解自明。\n\n~~~cpp\n#include \"rapidjson/pointer.h\"\n\n// ...\nDocument d;\n\n// 使用 Set() 创建 DOM\nPointer(\"/project\").Set(d, \"RapidJSON\");\nPointer(\"/stars\").Set(d, 10);\n\n// { \"project\" : \"RapidJSON\", \"stars\" : 10 }\n\n// 使用 Get() 访问 DOM。若该值不存在则返回 nullptr。\nif (Value* stars = Pointer(\"/stars\").Get(d))\n    stars->SetInt(stars->GetInt() + 1);\n\n// { \"project\" : \"RapidJSON\", \"stars\" : 11 }\n\n// Set() 和 Create() 自动生成父值（如果它们不存在）。\nPointer(\"/a/b/0\").Create(d);\n\n// { \"project\" : \"RapidJSON\", \"stars\" : 11, \"a\" : { \"b\" : [ null ] } }\n\n// GetWithDefault() 返回引用。若该值不存在则会深拷贝缺省值。\nValue& hello = Pointer(\"/hello\").GetWithDefault(d, \"world\");\n\n// { \"project\" : \"RapidJSON\", \"stars\" : 11, \"a\" : { \"b\" : [ null ] }, \"hello\" : \"world\" }\n\n// Swap() 和 Set() 相似\nValue x(\"C++\");\nPointer(\"/hello\").Swap(d, x);\n\n// { \"project\" : \"RapidJSON\", \"stars\" : 11, \"a\" : { \"b\" : [ null ] }, \"hello\" : \"C++\" }\n// x 变成 \"world\"\n\n// 删去一个成员或元素，若值存在返回 true\nbool success = Pointer(\"/a\").Erase(d);\nassert(success);\n\n// { \"project\" : \"RapidJSON\", \"stars\" : 10 }\n~~~\n\n# 辅助函数 {#HelperFunctions}\n\n由于面向对象的调用习惯可能不符直觉，RapidJSON 也提供了一些辅助函数，它们把成员函数包装成自由函数。\n\n以下的例子与上面例子所做的事情完全相同。\n\n~~~cpp\nDocument d;\n\nSetValueByPointer(d, \"/project\", \"RapidJSON\");\nSetValueByPointer(d, \"/stars\", 10);\n\nif (Value* stars = GetValueByPointer(d, \"/stars\"))\n    stars->SetInt(stars->GetInt() + 1);\n\nCreateValueByPointer(d, \"/a/b/0\");\n\nValue& hello = GetValueByPointerWithDefault(d, \"/hello\", \"world\");\n\nValue x(\"C++\");\nSwapValueByPointer(d, \"/hello\", x);\n\nbool success = EraseValueByPointer(d, \"/a\");\nassert(success);\n~~~\n\n以下对比 3 种调用方式：\n\n1. `Pointer(source).<Method>(root, ...)`\n2. `<Method>ValueByPointer(root, Pointer(source), ...)`\n3. `<Method>ValueByPointer(root, source, ...)`\n\n# 解析 Pointer {#ResolvingPointer}\n\n`Pointer::Get()` 或 `GetValueByPointer()` 函数并不修改 DOM。若那些 token 不能匹配 DOM 里的值，这些函数便返回 `nullptr`。使用者可利用这个方法来检查一个值是否存在。\n\n注意，数值 token 可表示数组索引或成员名字。解析过程中会按值的类型来匹配。\n\n~~~javascript\n{\n    \"0\" : 123,\n    \"1\" : [456]\n}\n~~~\n\n1. `\"/0\"` → `123`\n2. `\"/1/0\"` → `456`\n\nToken `\"0\"` 在第一个 pointer 中被当作成员名字。它在第二个 pointer 中被当作成数组索引。\n\n其他函数会改变 DOM，包括 `Create()`、`GetWithDefault()`、`Set()`、`Swap()`。这些函数总是成功的。若一些父值不存在，就会创建它们。若父值类型不匹配 token，也会强行改变其类型。改变类型也意味着完全移除其 DOM 子树的内容。\n\n例如，把上面的 JSON 解译至 `d` 之后，\n\n~~~cpp\nSetValueByPointer(d, \"1/a\", 789); // { \"0\" : 123, \"1\" : { \"a\" : 789 } }\n~~~\n\n## 解析负号 token\n\n另外，[RFC6901] 定义了一个特殊 token `-` （单个负号），用于表示数组最后元素的下一个元素。 `Get()` 只会把此 token 当作成员名字 '\"-\"'。而其他函数则会以此解析数组，等同于对数组调用 `Value::PushBack()` 。\n\n~~~cpp\nDocument d;\nd.Parse(\"{\\\"foo\\\":[123]}\");\nSetValueByPointer(d, \"/foo/-\", 456); // { \"foo\" : [123, 456] }\nSetValueByPointer(d, \"/-\", 789);    // { \"foo\" : [123, 456], \"-\" : 789 }\n~~~\n\n## 解析 Document 及 Value\n\n当使用 `p.Get(root)` 或 `GetValueByPointer(root, p)`，`root` 是一个（常数） `Value&`。这意味着，它也可以是 DOM 里的一个子树。\n\n其他函数有两组签名。一组使用 `Document& document` 作为参数，另一组使用 `Value& root`。第一组使用 `document.GetAllocator()` 去创建值，而第二组则需要使用者提供一个 allocator，如同 DOM 里的函数。\n\n以上例子都不需要 allocator 参数，因为它的第一个参数是 `Document&`。但如果你需要对一个子树进行解析，就需要如下面的例子般提供 allocator：\n\n~~~cpp\nclass Person {\npublic:\n    Person() {\n        document_ = new Document();\n        // CreateValueByPointer() here no need allocator\n        SetLocation(CreateValueByPointer(*document_, \"/residence\"), ...);\n        SetLocation(CreateValueByPointer(*document_, \"/office\"), ...);\n    };\n\nprivate:\n    void SetLocation(Value& location, const char* country, const char* addresses[2]) {\n        Value::Allocator& a = document_->GetAllocator();\n        // SetValueByPointer() here need allocator\n        SetValueByPointer(location, \"/country\", country, a);\n        SetValueByPointer(location, \"/address/0\", address[0], a);\n        SetValueByPointer(location, \"/address/1\", address[1], a);\n    }\n\n    // ...\n\n    Document* document_;\n};\n~~~\n\n`Erase()` 或 `EraseValueByPointer()` 不需要 allocator。而且它们成功删除值之后会返回 `true`。\n\n# 错误处理 {#ErrorHandling}\n\n`Pointer` 在其建构函数里会解译源字符串。若有解析错误，`Pointer::IsValid()` 返回 `false`。你可使用 `Pointer::GetParseErrorCode()` 和 `GetParseErrorOffset()` 去获取错信息。\n\n要注意的是，所有解析函数都假设 pointer 是合法的。对一个非法 pointer 解析会做成断言失败。\n\n# URI 片段表示方式 {#URIFragment}\n\n除了我们一直在使用的字符串方式表示 JSON pointer，[RFC6901] 也定义了一个 JSON Pointer 的 URI 片段（fragment）表示方式。URI 片段是定义于 [RFC3986] \"Uniform Resource Identifier (URI): Generic Syntax\"。\n\nURI 片段的主要分别是必然以 `#` （pound sign）开头，而一些字符也会以百分比编码成 UTF-8 序列。例如，以下的表展示了不同表示法下的 C/C++ 字符串常数。\n\n字符串表示方式 | URI 片段表示方式 | Pointer Tokens （UTF-8）\n----------------------|-----------------------------|------------------------\n`\"/foo/0\"`            | `\"#/foo/0\"`                 | `{\"foo\", 0}`\n`\"/a~1b\"`             | `\"#/a~1b\"`                  | `{\"a/b\"}`\n`\"/m~0n\"`             | `\"#/m~0n\"`                  | `{\"m~n\"}`\n`\"/ \"`                | `\"#/%20\"`                   | `{\" \"}`\n`\"/\\0\"`               | `\"#/%00\"`                   | `{\"\\0\"}`\n`\"/€\"`                | `\"#/%E2%82%AC\"`             | `{\"€\"}`\n\nRapidJSON 完全支持 URI 片段表示方式。它在解译时会自动检测 `#` 号。\n\n# 字符串化\n\n你也可以把一个 `Pointer` 字符串化，储存于字符串或其他输出流。例如：\n\n~~~\nPointer p(...);\nStringBuffer sb;\np.Stringify(sb);\nstd::cout << sb.GetString() << std::endl;\n~~~\n\n使用 `StringifyUriFragment()` 可以把 pointer 字符串化为 URI 片段表示法。\n\n# 使用者提供的 tokens {#UserSuppliedTokens}\n\n若一个 pointer 会用于多次解析，它应该只被创建一次，然后再施于不同的 DOM ，或在不同时间做解析。这样可以避免多次创键 `Pointer`，节省时间和内存分配。\n\n我们甚至可以再更进一步，完全消去解析过程及动态内存分配。我们可以直接生成 token 数组：\n\n~~~cpp\n#define NAME(s) { s, sizeof(s) / sizeof(s[0]) - 1, kPointerInvalidIndex }\n#define INDEX(i) { #i, sizeof(#i) - 1, i }\n\nstatic const Pointer::Token kTokens[] = { NAME(\"foo\"), INDEX(123) };\nstatic const Pointer p(kTokens, sizeof(kTokens) / sizeof(kTokens[0]));\n// Equivalent to static const Pointer p(\"/foo/123\");\n~~~\n\n这种做法可能适合内存受限的系统。\n\n[RFC3986]: https://tools.ietf.org/html/rfc3986\n[RFC6901]: https://tools.ietf.org/html/rfc6901\n"
  },
  {
    "path": "ext/rapidjson/doc/sax.md",
    "content": "# SAX\n\nThe term \"SAX\" originated from [Simple API for XML](http://en.wikipedia.org/wiki/Simple_API_for_XML). We borrowed this term for JSON parsing and generation.\n\nIn RapidJSON, `Reader` (typedef of `GenericReader<...>`) is the SAX-style parser for JSON, and `Writer` (typedef of `GenericWriter<...>`) is the SAX-style generator for JSON.\n\n[TOC]\n\n# Reader {#Reader}\n\n`Reader` parses a JSON from a stream. While it reads characters from the stream, it analyze the characters according to the syntax of JSON, and publish events to a handler.\n\nFor example, here is a JSON.\n\n~~~~~~~~~~js\n{\n    \"hello\": \"world\",\n    \"t\": true ,\n    \"f\": false,\n    \"n\": null,\n    \"i\": 123,\n    \"pi\": 3.1416,\n    \"a\": [1, 2, 3, 4]\n}\n~~~~~~~~~~\n\nWhile a `Reader` parses this JSON, it publishes the following events to the handler sequentially:\n\n~~~~~~~~~~\nStartObject()\nKey(\"hello\", 5, true)\nString(\"world\", 5, true)\nKey(\"t\", 1, true)\nBool(true)\nKey(\"f\", 1, true)\nBool(false)\nKey(\"n\", 1, true)\nNull()\nKey(\"i\")\nUInt(123)\nKey(\"pi\")\nDouble(3.1416)\nKey(\"a\")\nStartArray()\nUint(1)\nUint(2)\nUint(3)\nUint(4)\nEndArray(4)\nEndObject(7)\n~~~~~~~~~~\n\nThese events can be easily matched with the JSON, except some event parameters need further explanation. Let's see the `simplereader` example which produces exactly the same output as above:\n\n~~~~~~~~~~cpp\n#include \"rapidjson/reader.h\"\n#include <iostream>\n\nusing namespace rapidjson;\nusing namespace std;\n\nstruct MyHandler : public BaseReaderHandler<UTF8<>, MyHandler> {\n    bool Null() { cout << \"Null()\" << endl; return true; }\n    bool Bool(bool b) { cout << \"Bool(\" << boolalpha << b << \")\" << endl; return true; }\n    bool Int(int i) { cout << \"Int(\" << i << \")\" << endl; return true; }\n    bool Uint(unsigned u) { cout << \"Uint(\" << u << \")\" << endl; return true; }\n    bool Int64(int64_t i) { cout << \"Int64(\" << i << \")\" << endl; return true; }\n    bool Uint64(uint64_t u) { cout << \"Uint64(\" << u << \")\" << endl; return true; }\n    bool Double(double d) { cout << \"Double(\" << d << \")\" << endl; return true; }\n    bool String(const char* str, SizeType length, bool copy) { \n        cout << \"String(\" << str << \", \" << length << \", \" << boolalpha << copy << \")\" << endl;\n        return true;\n    }\n    bool StartObject() { cout << \"StartObject()\" << endl; return true; }\n    bool Key(const char* str, SizeType length, bool copy) { \n        cout << \"Key(\" << str << \", \" << length << \", \" << boolalpha << copy << \")\" << endl;\n        return true;\n    }\n    bool EndObject(SizeType memberCount) { cout << \"EndObject(\" << memberCount << \")\" << endl; return true; }\n    bool StartArray() { cout << \"StartArray()\" << endl; return true; }\n    bool EndArray(SizeType elementCount) { cout << \"EndArray(\" << elementCount << \")\" << endl; return true; }\n};\n\nvoid main() {\n    const char json[] = \" { \\\"hello\\\" : \\\"world\\\", \\\"t\\\" : true , \\\"f\\\" : false, \\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3, 4] } \";\n\n    MyHandler handler;\n    Reader reader;\n    StringStream ss(json);\n    reader.Parse(ss, handler);\n}\n~~~~~~~~~~\n\nNote that, RapidJSON uses template to statically bind the `Reader` type and the handler type, instead of using class with virtual functions. This paradigm can improve the performance by inlining functions.\n\n## Handler {#Handler}\n\nAs the previous example showed, user needs to implement a handler, which consumes the events (function calls) from `Reader`. The handler must contain the following member functions.\n\n~~~~~~~~~~cpp\nclass Handler {\n    bool Null();\n    bool Bool(bool b);\n    bool Int(int i);\n    bool Uint(unsigned i);\n    bool Int64(int64_t i);\n    bool Uint64(uint64_t i);\n    bool Double(double d);\n    bool RawNumber(const Ch* str, SizeType length, bool copy);\n    bool String(const Ch* str, SizeType length, bool copy);\n    bool StartObject();\n    bool Key(const Ch* str, SizeType length, bool copy);\n    bool EndObject(SizeType memberCount);\n    bool StartArray();\n    bool EndArray(SizeType elementCount);\n};\n~~~~~~~~~~\n\n`Null()` is called when the `Reader` encounters a JSON null value.\n\n`Bool(bool)` is called when the `Reader` encounters a JSON true or false value.\n\nWhen the `Reader` encounters a JSON number, it chooses a suitable C++ type mapping. And then it calls *one* function out of `Int(int)`, `Uint(unsigned)`, `Int64(int64_t)`, `Uint64(uint64_t)` and `Double(double)`. If `kParseNumbersAsStrings` is enabled, `Reader` will always calls `RawNumber()` instead.\n\n`String(const char* str, SizeType length, bool copy)` is called when the `Reader` encounters a string. The first parameter is pointer to the string. The second parameter is the length of the string (excluding the null terminator). Note that RapidJSON supports null character `'\\0'` inside a string. If such situation happens, `strlen(str) < length`. The last `copy` indicates whether the handler needs to make a copy of the string. For normal parsing, `copy = true`. Only when *insitu* parsing is used, `copy = false`. And beware that, the character type depends on the target encoding, which will be explained later.\n\nWhen the `Reader` encounters the beginning of an object, it calls `StartObject()`. An object in JSON is a set of name-value pairs. If the object contains members it first calls `Key()` for the name of member, and then calls functions depending on the type of the value. These calls of name-value pairs repeats until calling `EndObject(SizeType memberCount)`. Note that the `memberCount` parameter is just an aid for the handler, user may not need this parameter.\n\nArray is similar to object but simpler. At the beginning of an array, the `Reader` calls `BeginArary()`. If there is elements, it calls functions according to the types of element. Similarly, in the last call `EndArray(SizeType elementCount)`, the parameter `elementCount` is just an aid for the handler.\n\nEvery handler functions returns a `bool`. Normally it should returns `true`. If the handler encounters an error, it can return `false` to notify event publisher to stop further processing.\n\nFor example, when we parse a JSON with `Reader` and the handler detected that the JSON does not conform to the required schema, then the handler can return `false` and let the `Reader` stop further parsing. And the `Reader` will be in error state with error code `kParseErrorTermination`.\n\n## GenericReader {#GenericReader}\n\nAs mentioned before, `Reader` is a typedef of a template class `GenericReader`:\n\n~~~~~~~~~~cpp\nnamespace rapidjson {\n\ntemplate <typename SourceEncoding, typename TargetEncoding, typename Allocator = MemoryPoolAllocator<> >\nclass GenericReader {\n    // ...\n};\n\ntypedef GenericReader<UTF8<>, UTF8<> > Reader;\n\n} // namespace rapidjson\n~~~~~~~~~~\n\nThe `Reader` uses UTF-8 as both source and target encoding. The source encoding means the encoding in the JSON stream. The target encoding means the encoding of the `str` parameter in `String()` calls. For example, to parse a UTF-8 stream and outputs UTF-16 string events, you can define a reader by:\n\n~~~~~~~~~~cpp\nGenericReader<UTF8<>, UTF16<> > reader;\n~~~~~~~~~~\n\nNote that, the default character type of `UTF16` is `wchar_t`. So this `reader`needs to call `String(const wchar_t*, SizeType, bool)` of the handler.\n\nThe third template parameter `Allocator` is the allocator type for internal data structure (actually a stack).\n\n## Parsing {#SaxParsing}\n\nThe one and only one function of `Reader` is to parse JSON. \n\n~~~~~~~~~~cpp\ntemplate <unsigned parseFlags, typename InputStream, typename Handler>\nbool Parse(InputStream& is, Handler& handler);\n\n// with parseFlags = kDefaultParseFlags\ntemplate <typename InputStream, typename Handler>\nbool Parse(InputStream& is, Handler& handler);\n~~~~~~~~~~\n\nIf an error occurs during parsing, it will return `false`. User can also calls `bool HasParseEror()`, `ParseErrorCode GetParseErrorCode()` and `size_t GetErrorOffset()` to obtain the error states. Actually `Document` uses these `Reader` functions to obtain parse errors. Please refer to [DOM](doc/dom.md) for details about parse error.\n\n# Writer {#Writer}\n\n`Reader` converts (parses) JSON into events. `Writer` does exactly the opposite. It converts events into JSON. \n\n`Writer` is very easy to use. If your application only need to converts some data into JSON, it may be a good choice to use `Writer` directly, instead of building a `Document` and then stringifying it with a `Writer`.\n\nIn `simplewriter` example, we do exactly the reverse of `simplereader`.\n\n~~~~~~~~~~cpp\n#include \"rapidjson/writer.h\"\n#include \"rapidjson/stringbuffer.h\"\n#include <iostream>\n\nusing namespace rapidjson;\nusing namespace std;\n\nvoid main() {\n    StringBuffer s;\n    Writer<StringBuffer> writer(s);\n    \n    writer.StartObject();\n    writer.Key(\"hello\");\n    writer.String(\"world\");\n    writer.Key(\"t\");\n    writer.Bool(true);\n    writer.Key(\"f\");\n    writer.Bool(false);\n    writer.Key(\"n\");\n    writer.Null();\n    writer.Key(\"i\");\n    writer.Uint(123);\n    writer.Key(\"pi\");\n    writer.Double(3.1416);\n    writer.Key(\"a\");\n    writer.StartArray();\n    for (unsigned i = 0; i < 4; i++)\n        writer.Uint(i);\n    writer.EndArray();\n    writer.EndObject();\n\n    cout << s.GetString() << endl;\n}\n~~~~~~~~~~\n\n~~~~~~~~~~\n{\"hello\":\"world\",\"t\":true,\"f\":false,\"n\":null,\"i\":123,\"pi\":3.1416,\"a\":[0,1,2,3]}\n~~~~~~~~~~\n\nThere are two `String()` and `Key()` overloads. One is the same as defined in handler concept with 3 parameters. It can handle string with null characters. Another one is the simpler version used in the above example.\n\nNote that, the example code does not pass any parameters in `EndArray()` and `EndObject()`. An `SizeType` can be passed but it will be simply ignored by `Writer`.\n\nYou may doubt that, why not just using `sprintf()` or `std::stringstream` to build a JSON?\n\nThere are various reasons:\n1. `Writer` must output a well-formed JSON. If there is incorrect event sequence (e.g. `Int()` just after `StartObject()`), it generates assertion fail in debug mode.\n2. `Writer::String()` can handle string escaping (e.g. converting code point `U+000A` to `\\n`) and Unicode transcoding.\n3. `Writer` handles number output consistently.\n4. `Writer` implements the event handler concept. It can be used to handle events from `Reader`, `Document` or other event publisher.\n5. `Writer` can be optimized for different platforms.\n\nAnyway, using `Writer` API is even simpler than generating a JSON by ad hoc methods.\n\n## Template {#WriterTemplate}\n\n`Writer` has a minor design difference to `Reader`. `Writer` is a template class, not a typedef. There is no `GenericWriter`. The following is the declaration.\n\n~~~~~~~~~~cpp\nnamespace rapidjson {\n\ntemplate<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename Allocator = CrtAllocator<>, unsigned writeFlags = kWriteDefaultFlags>\nclass Writer {\npublic:\n    Writer(OutputStream& os, Allocator* allocator = 0, size_t levelDepth = kDefaultLevelDepth)\n// ...\n};\n\n} // namespace rapidjson\n~~~~~~~~~~\n\nThe `OutputStream` template parameter is the type of output stream. It cannot be deduced and must be specified by user.\n\nThe `SourceEncoding` template parameter specifies the encoding to be used in `String(const Ch*, ...)`.\n\nThe `TargetEncoding` template parameter specifies the encoding in the output stream.\n\nThe `Allocator` is the type of allocator, which is used for allocating internal data structure (a stack).\n\nThe `writeFlags` are combination of the following bit-flags:\n\nParse flags                   | Meaning\n------------------------------|-----------------------------------\n`kWriteNoFlags`               | No flag is set.\n`kWriteDefaultFlags`          | Default write flags. It is equal to macro `RAPIDJSON_WRITE_DEFAULT_FLAGS`, which is defined as `kWriteNoFlags`.\n`kWriteValidateEncodingFlag`  | Validate encoding of JSON strings.\n`kWriteNanAndInfFlag`         | Allow writing of `Infinity`, `-Infinity` and `NaN`.\n\nBesides, the constructor of `Writer` has a `levelDepth` parameter. This parameter affects the initial memory allocated for storing information per hierarchy level.\n\n## PrettyWriter {#PrettyWriter}\n\nWhile the output of `Writer` is the most condensed JSON without white-spaces, suitable for network transfer or storage, it is not easily readable by human.\n\nTherefore, RapidJSON provides a `PrettyWriter`, which adds indentation and line feeds in the output.\n\nThe usage of `PrettyWriter` is exactly the same as `Writer`, expect that `PrettyWriter` provides a `SetIndent(Ch indentChar, unsigned indentCharCount)` function. The default is 4 spaces.\n\n## Completeness and Reset {#CompletenessReset}\n\nA `Writer` can only output a single JSON, which can be any JSON type at the root. Once the singular event for root (e.g. `String()`), or the last matching `EndObject()` or `EndArray()` event, is handled, the output JSON is well-formed and complete. User can detect this state by calling `Writer::IsComplete()`.\n\nWhen a JSON is complete, the `Writer` cannot accept any new events. Otherwise the output will be invalid (i.e. having more than one root). To reuse the `Writer` object, user can call `Writer::Reset(OutputStream& os)` to reset all internal states of the `Writer` with a new output stream.\n\n# Techniques {#SaxTechniques}\n\n## Parsing JSON to Custom Data Structure {#CustomDataStructure}\n\n`Document`'s parsing capability is completely based on `Reader`. Actually `Document` is a handler which receives events from a reader to build a DOM during parsing.\n\nUser may uses `Reader` to build other data structures directly. This eliminates building of DOM, thus reducing memory and improving performance.\n\nIn the following `messagereader` example, `ParseMessages()` parses a JSON which should be an object with key-string pairs.\n\n~~~~~~~~~~cpp\n#include \"rapidjson/reader.h\"\n#include \"rapidjson/error/en.h\"\n#include <iostream>\n#include <string>\n#include <map>\n\nusing namespace std;\nusing namespace rapidjson;\n\ntypedef map<string, string> MessageMap;\n\nstruct MessageHandler\n    : public BaseReaderHandler<UTF8<>, MessageHandler> {\n    MessageHandler() : state_(kExpectObjectStart) {\n    }\n\n    bool StartObject() {\n        switch (state_) {\n        case kExpectObjectStart:\n            state_ = kExpectNameOrObjectEnd;\n            return true;\n        default:\n            return false;\n        }\n    }\n\n    bool String(const char* str, SizeType length, bool) {\n        switch (state_) {\n        case kExpectNameOrObjectEnd:\n            name_ = string(str, length);\n            state_ = kExpectValue;\n            return true;\n        case kExpectValue:\n            messages_.insert(MessageMap::value_type(name_, string(str, length)));\n            state_ = kExpectNameOrObjectEnd;\n            return true;\n        default:\n            return false;\n        }\n    }\n\n    bool EndObject(SizeType) { return state_ == kExpectNameOrObjectEnd; }\n\n    bool Default() { return false; } // All other events are invalid.\n\n    MessageMap messages_;\n    enum State {\n        kExpectObjectStart,\n        kExpectNameOrObjectEnd,\n        kExpectValue,\n    }state_;\n    std::string name_;\n};\n\nvoid ParseMessages(const char* json, MessageMap& messages) {\n    Reader reader;\n    MessageHandler handler;\n    StringStream ss(json);\n    if (reader.Parse(ss, handler))\n        messages.swap(handler.messages_);   // Only change it if success.\n    else {\n        ParseErrorCode e = reader.GetParseErrorCode();\n        size_t o = reader.GetErrorOffset();\n        cout << \"Error: \" << GetParseError_En(e) << endl;;\n        cout << \" at offset \" << o << \" near '\" << string(json).substr(o, 10) << \"...'\" << endl;\n    }\n}\n\nint main() {\n    MessageMap messages;\n\n    const char* json1 = \"{ \\\"greeting\\\" : \\\"Hello!\\\", \\\"farewell\\\" : \\\"bye-bye!\\\" }\";\n    cout << json1 << endl;\n    ParseMessages(json1, messages);\n\n    for (MessageMap::const_iterator itr = messages.begin(); itr != messages.end(); ++itr)\n        cout << itr->first << \": \" << itr->second << endl;\n\n    cout << endl << \"Parse a JSON with invalid schema.\" << endl;\n    const char* json2 = \"{ \\\"greeting\\\" : \\\"Hello!\\\", \\\"farewell\\\" : \\\"bye-bye!\\\", \\\"foo\\\" : {} }\";\n    cout << json2 << endl;\n    ParseMessages(json2, messages);\n\n    return 0;\n}\n~~~~~~~~~~\n\n~~~~~~~~~~\n{ \"greeting\" : \"Hello!\", \"farewell\" : \"bye-bye!\" }\nfarewell: bye-bye!\ngreeting: Hello!\n\nParse a JSON with invalid schema.\n{ \"greeting\" : \"Hello!\", \"farewell\" : \"bye-bye!\", \"foo\" : {} }\nError: Terminate parsing due to Handler error.\n at offset 59 near '} }...'\n~~~~~~~~~~\n\nThe first JSON (`json1`) was successfully parsed into `MessageMap`. Since `MessageMap` is a `std::map`, the printing order are sorted by the key. This order is different from the JSON's order.\n\nIn the second JSON (`json2`), `foo`'s value is an empty object. As it is an object, `MessageHandler::StartObject()` will be called. However, at that moment `state_ = kExpectValue`, so that function returns `false` and cause the parsing process be terminated. The error code is `kParseErrorTermination`.\n\n## Filtering of JSON {#Filtering}\n\nAs mentioned earlier, `Writer` can handle the events published by `Reader`. `condense` example simply set a `Writer` as handler of a `Reader`, so it can remove all white-spaces in JSON. `pretty` example uses the same relationship, but replacing `Writer` by `PrettyWriter`. So `pretty` can be used to reformat a JSON with indentation and line feed.\n\nActually, we can add intermediate layer(s) to filter the contents of JSON via these SAX-style API. For example, `capitalize` example capitalize all strings in a JSON.\n\n~~~~~~~~~~cpp\n#include \"rapidjson/reader.h\"\n#include \"rapidjson/writer.h\"\n#include \"rapidjson/filereadstream.h\"\n#include \"rapidjson/filewritestream.h\"\n#include \"rapidjson/error/en.h\"\n#include <vector>\n#include <cctype>\n\nusing namespace rapidjson;\n\ntemplate<typename OutputHandler>\nstruct CapitalizeFilter {\n    CapitalizeFilter(OutputHandler& out) : out_(out), buffer_() {\n    }\n\n    bool Null() { return out_.Null(); }\n    bool Bool(bool b) { return out_.Bool(b); }\n    bool Int(int i) { return out_.Int(i); }\n    bool Uint(unsigned u) { return out_.Uint(u); }\n    bool Int64(int64_t i) { return out_.Int64(i); }\n    bool Uint64(uint64_t u) { return out_.Uint64(u); }\n    bool Double(double d) { return out_.Double(d); }\n    bool RawNumber(const char* str, SizeType length, bool copy) { return out_.RawNumber(str, length, copy); }\n    bool String(const char* str, SizeType length, bool) { \n        buffer_.clear();\n        for (SizeType i = 0; i < length; i++)\n            buffer_.push_back(std::toupper(str[i]));\n        return out_.String(&buffer_.front(), length, true); // true = output handler need to copy the string\n    }\n    bool StartObject() { return out_.StartObject(); }\n    bool Key(const char* str, SizeType length, bool copy) { return String(str, length, copy); }\n    bool EndObject(SizeType memberCount) { return out_.EndObject(memberCount); }\n    bool StartArray() { return out_.StartArray(); }\n    bool EndArray(SizeType elementCount) { return out_.EndArray(elementCount); }\n\n    OutputHandler& out_;\n    std::vector<char> buffer_;\n};\n\nint main(int, char*[]) {\n    // Prepare JSON reader and input stream.\n    Reader reader;\n    char readBuffer[65536];\n    FileReadStream is(stdin, readBuffer, sizeof(readBuffer));\n\n    // Prepare JSON writer and output stream.\n    char writeBuffer[65536];\n    FileWriteStream os(stdout, writeBuffer, sizeof(writeBuffer));\n    Writer<FileWriteStream> writer(os);\n\n    // JSON reader parse from the input stream and let writer generate the output.\n    CapitalizeFilter<Writer<FileWriteStream> > filter(writer);\n    if (!reader.Parse(is, filter)) {\n        fprintf(stderr, \"\\nError(%u): %s\\n\", (unsigned)reader.GetErrorOffset(), GetParseError_En(reader.GetParseErrorCode()));\n        return 1;\n    }\n\n    return 0;\n}\n~~~~~~~~~~\n\nNote that, it is incorrect to simply capitalize the JSON as a string. For example:\n~~~~~~~~~~\n[\"Hello\\nWorld\"]\n~~~~~~~~~~\n\nSimply capitalizing the whole JSON would contain incorrect escape character:\n~~~~~~~~~~\n[\"HELLO\\NWORLD\"]\n~~~~~~~~~~\n\nThe correct result by `capitalize`:\n~~~~~~~~~~\n[\"HELLO\\nWORLD\"]\n~~~~~~~~~~\n\nMore complicated filters can be developed. However, since SAX-style API can only provide information about a single event at a time, user may need to book-keeping the contextual information (e.g. the path from root value, storage of other related values). Some processing may be easier to be implemented in DOM than SAX.\n"
  },
  {
    "path": "ext/rapidjson/doc/sax.zh-cn.md",
    "content": "# SAX\n\n\"SAX\" 此术语源于 [Simple API for XML](http://en.wikipedia.org/wiki/Simple_API_for_XML)。我们借了此术语去套用在 JSON 的解析及生成。\n\n在 RapidJSON 中，`Reader`（`GenericReader<...>` 的 typedef）是 JSON 的 SAX 风格解析器，而 `Writer`（`GenericWriter<...>` 的 typedef）则是 JSON 的 SAX 风格生成器。\n\n[TOC]\n\n# Reader {#Reader}\n\n`Reader` 从输入流解析一个 JSON。当它从流中读取字符时，它会基于 JSON 的语法去分析字符，并向处理器发送事件。\n\n例如，以下是一个 JSON。\n\n~~~~~~~~~~js\n{\n    \"hello\": \"world\",\n    \"t\": true ,\n    \"f\": false,\n    \"n\": null,\n    \"i\": 123,\n    \"pi\": 3.1416,\n    \"a\": [1, 2, 3, 4]\n}\n~~~~~~~~~~\n\n当一个 `Reader` 解析此 JSON 时，它会顺序地向处理器发送以下的事件：\n\n~~~~~~~~~~\nStartObject()\nKey(\"hello\", 5, true)\nString(\"world\", 5, true)\nKey(\"t\", 1, true)\nBool(true)\nKey(\"f\", 1, true)\nBool(false)\nKey(\"n\", 1, true)\nNull()\nKey(\"i\")\nUInt(123)\nKey(\"pi\")\nDouble(3.1416)\nKey(\"a\")\nStartArray()\nUint(1)\nUint(2)\nUint(3)\nUint(4)\nEndArray(4)\nEndObject(7)\n~~~~~~~~~~\n\n除了一些事件参数需要再作解释，这些事件可以轻松地与 JSON 对上。我们可以看看 `simplereader` 例子怎样产生和以上完全相同的结果：\n\n~~~~~~~~~~cpp\n#include \"rapidjson/reader.h\"\n#include <iostream>\n\nusing namespace rapidjson;\nusing namespace std;\n\nstruct MyHandler : public BaseReaderHandler<UTF8<>, MyHandler> {\n    bool Null() { cout << \"Null()\" << endl; return true; }\n    bool Bool(bool b) { cout << \"Bool(\" << boolalpha << b << \")\" << endl; return true; }\n    bool Int(int i) { cout << \"Int(\" << i << \")\" << endl; return true; }\n    bool Uint(unsigned u) { cout << \"Uint(\" << u << \")\" << endl; return true; }\n    bool Int64(int64_t i) { cout << \"Int64(\" << i << \")\" << endl; return true; }\n    bool Uint64(uint64_t u) { cout << \"Uint64(\" << u << \")\" << endl; return true; }\n    bool Double(double d) { cout << \"Double(\" << d << \")\" << endl; return true; }\n    bool String(const char* str, SizeType length, bool copy) { \n        cout << \"String(\" << str << \", \" << length << \", \" << boolalpha << copy << \")\" << endl;\n        return true;\n    }\n    bool StartObject() { cout << \"StartObject()\" << endl; return true; }\n    bool Key(const char* str, SizeType length, bool copy) { \n        cout << \"Key(\" << str << \", \" << length << \", \" << boolalpha << copy << \")\" << endl;\n        return true;\n    }\n    bool EndObject(SizeType memberCount) { cout << \"EndObject(\" << memberCount << \")\" << endl; return true; }\n    bool StartArray() { cout << \"StartArray()\" << endl; return true; }\n    bool EndArray(SizeType elementCount) { cout << \"EndArray(\" << elementCount << \")\" << endl; return true; }\n};\n\nvoid main() {\n    const char json[] = \" { \\\"hello\\\" : \\\"world\\\", \\\"t\\\" : true , \\\"f\\\" : false, \\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3, 4] } \";\n\n    MyHandler handler;\n    Reader reader;\n    StringStream ss(json);\n    reader.Parse(ss, handler);\n}\n~~~~~~~~~~\n\n注意 RapidJSON 使用模板去静态挷定 `Reader` 类型及处理器的类形，而不是使用含虚函数的类。这个范式可以通过把函数内联而改善性能。\n\n## 处理器 {#Handler}\n\n如前例所示，使用者需要实现一个处理器（handler），用于处理来自 `Reader` 的事件（函数调用）。处理器必须包含以下的成员函数。\n\n~~~~~~~~~~cpp\nclass Handler {\n    bool Null();\n    bool Bool(bool b);\n    bool Int(int i);\n    bool Uint(unsigned i);\n    bool Int64(int64_t i);\n    bool Uint64(uint64_t i);\n    bool Double(double d);\n    bool RawNumber(const Ch* str, SizeType length, bool copy);\n    bool String(const Ch* str, SizeType length, bool copy);\n    bool StartObject();\n    bool Key(const Ch* str, SizeType length, bool copy);\n    bool EndObject(SizeType memberCount);\n    bool StartArray();\n    bool EndArray(SizeType elementCount);\n};\n~~~~~~~~~~\n\n当 `Reader` 遇到 JSON null 值时会调用 `Null()`。\n\n当 `Reader` 遇到 JSON true 或 false 值时会调用 `Bool(bool)`。\n\n当 `Reader` 遇到 JSON number，它会选择一个合适的 C++ 类型映射，然后调用 `Int(int)`、`Uint(unsigned)`、`Int64(int64_t)`、`Uint64(uint64_t)` 及 `Double(double)` 的 * 其中之一个 *。 若开启了 `kParseNumbersAsStrings` 选项，`Reader` 便会改为调用 `RawNumber()`。\n\n当 `Reader` 遇到 JSON string，它会调用 `String(const char* str, SizeType length, bool copy)`。第一个参数是字符串的指针。第二个参数是字符串的长度（不包含空终止符号）。注意 RapidJSON 支持字串中含有空字符 `'\\0'`。若出现这种情况，便会有 `strlen(str) < length`。最后的 `copy` 参数表示处理器是否需要复制该字符串。在正常解析时，`copy = true`。仅当使用原位解析时，`copy = false`。此外，还要注意字符的类型与目标编码相关，我们稍后会再谈这一点。\n\n当 `Reader` 遇到 JSON object 的开始之时，它会调用 `StartObject()`。JSON 的 object 是一个键值对（成员）的集合。若 object 包含成员，它会先为成员的名字调用 `Key()`，然后再按值的类型调用函数。它不断调用这些键值对，直至最终调用 `EndObject(SizeType memberCount)`。注意 `memberCount` 参数对处理器来说只是协助性质，使用者可能不需要此参数。\n\nJSON array 与 object 相似，但更简单。在 array 开始时，`Reader` 会调用 `BeginArary()`。若 array 含有元素，它会按元素的类型来读用函数。相似地，最后它会调用 `EndArray(SizeType elementCount)`，其中 `elementCount` 参数对处理器来说只是协助性质。\n\n每个处理器函数都返回一个 `bool`。正常它们应返回 `true`。若处理器遇到错误，它可以返回 `false` 去通知事件发送方停止继续处理。\n\n例如，当我们用 `Reader` 解析一个 JSON 时，处理器检测到该 JSON 并不符合所需的 schema，那么处理器可以返回 `false`，令 `Reader` 停止之后的解析工作。而 `Reader` 会进入一个错误状态，并以 `kParseErrorTermination` 错误码标识。\n\n## GenericReader {#GenericReader}\n\n前面提及，`Reader` 是 `GenericReader` 模板类的 typedef：\n\n~~~~~~~~~~cpp\nnamespace rapidjson {\n\ntemplate <typename SourceEncoding, typename TargetEncoding, typename Allocator = MemoryPoolAllocator<> >\nclass GenericReader {\n    // ...\n};\n\ntypedef GenericReader<UTF8<>, UTF8<> > Reader;\n\n} // namespace rapidjson\n~~~~~~~~~~\n\n`Reader` 使用 UTF-8 作为来源及目标编码。来源编码是指 JSON 流的编码。目标编码是指 `String()` 的 `str` 参数所用的编码。例如，要解析一个 UTF-8 流并输出至 UTF-16 string 事件，你需要这么定义一个 reader：\n\n~~~~~~~~~~cpp\nGenericReader<UTF8<>, UTF16<> > reader;\n~~~~~~~~~~\n\n注意到 `UTF16` 的缺省类型是 `wchar_t`。因此这个 `reader` 需要调用处理器的 `String(const wchar_t*, SizeType, bool)`。\n\n第三个模板参数 `Allocator` 是内部数据结构（实际上是一个堆栈）的分配器类型。\n\n## 解析 {#SaxParsing}\n\n`Reader` 的唯一功能就是解析 JSON。 \n\n~~~~~~~~~~cpp\ntemplate <unsigned parseFlags, typename InputStream, typename Handler>\nbool Parse(InputStream& is, Handler& handler);\n\n// 使用 parseFlags = kDefaultParseFlags\ntemplate <typename InputStream, typename Handler>\nbool Parse(InputStream& is, Handler& handler);\n~~~~~~~~~~\n\n若在解析中出现错误，它会返回 `false`。使用者可调用 `bool HasParseEror()`, `ParseErrorCode GetParseErrorCode()` 及 `size_t GetErrorOffset()` 获取错误状态。实际上 `Document` 使用这些 `Reader` 函数去获取解析错误。请参考 [DOM](doc/dom.zh-cn.md) 去了解有关解析错误的细节。\n\n# Writer {#Writer}\n\n`Reader` 把 JSON 转换（解析）成为事件。`Writer` 做完全相反的事情。它把事件转换成 JSON。\n\n`Writer` 是非常容易使用的。若你的应用程序只需把一些数据转换成 JSON，可能直接使用 `Writer`，会比建立一个 `Document` 然后用 `Writer` 把它转换成 JSON 更加方便。\n\n在 `simplewriter` 例子里，我们做 `simplereader` 完全相反的事情。\n\n~~~~~~~~~~cpp\n#include \"rapidjson/writer.h\"\n#include \"rapidjson/stringbuffer.h\"\n#include <iostream>\n\nusing namespace rapidjson;\nusing namespace std;\n\nvoid main() {\n    StringBuffer s;\n    Writer<StringBuffer> writer(s);\n    \n    writer.StartObject();\n    writer.Key(\"hello\");\n    writer.String(\"world\");\n    writer.Key(\"t\");\n    writer.Bool(true);\n    writer.Key(\"f\");\n    writer.Bool(false);\n    writer.Key(\"n\");\n    writer.Null();\n    writer.Key(\"i\");\n    writer.Uint(123);\n    writer.Key(\"pi\");\n    writer.Double(3.1416);\n    writer.Key(\"a\");\n    writer.StartArray();\n    for (unsigned i = 0; i < 4; i++)\n        writer.Uint(i);\n    writer.EndArray();\n    writer.EndObject();\n\n    cout << s.GetString() << endl;\n}\n~~~~~~~~~~\n\n~~~~~~~~~~\n{\"hello\":\"world\",\"t\":true,\"f\":false,\"n\":null,\"i\":123,\"pi\":3.1416,\"a\":[0,1,2,3]}\n~~~~~~~~~~\n\n`String()` 及 `Key()` 各有两个重载。一个是如处理器 concept 般，有 3 个参数。它能处理含空字符的字符串。另一个是如上中使用的较简单版本。\n\n注意到，例子代码中的 `EndArray()` 及 `EndObject()` 并没有参数。可以传递一个 `SizeType` 的参数，但它会被 `Writer` 忽略。\n\n你可能会怀疑，为什么不使用 `sprintf()` 或 `std::stringstream` 去建立一个 JSON？\n\n这有几个原因：\n1. `Writer` 必然会输出一个结构良好（well-formed）的 JSON。若然有错误的事件次序（如 `Int()` 紧随 `StartObject()` 出现），它会在调试模式中产生断言失败。\n2. `Writer::String()` 可处理字符串转义（如把码点 `U+000A` 转换成 `\\n`）及进行 Unicode 转码。\n3. `Writer` 一致地处理 number 的输出。\n4. `Writer` 实现了事件处理器 concept。可用于处理来自 `Reader`、`Document` 或其他事件发生器。\n5. `Writer` 可对不同平台进行优化。\n\n无论如何，使用 `Writer` API 去生成 JSON 甚至乎比这些临时方法更简单。\n\n## 模板 {#WriterTemplate}\n\n`Writer` 与 `Reader` 有少许设计区别。`Writer` 是一个模板类，而不是一个 typedef。 并没有 `GenericWriter`。以下是 `Writer` 的声明。\n\n~~~~~~~~~~cpp\nnamespace rapidjson {\n\ntemplate<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename Allocator = CrtAllocator<> >\nclass Writer {\npublic:\n    Writer(OutputStream& os, Allocator* allocator = 0, size_t levelDepth = kDefaultLevelDepth)\n// ...\n};\n\n} // namespace rapidjson\n~~~~~~~~~~\n\n`OutputStream` 模板参数是输出流的类型。它的类型不可以被自动推断，必须由使用者提供。\n\n`SourceEncoding` 模板参数指定了 `String(const Ch*, ...)` 的编码。\n\n`TargetEncoding` 模板参数指定输出流的编码。\n\n`Allocator` 是分配器的类型，用于分配内部数据结构（一个堆栈）。\n\n`writeFlags` 是以下位标志的组合：\n\n写入位标志                     | 意义\n------------------------------|-----------------------------------\n`kWriteNoFlags`               | 没有任何标志。\n`kWriteDefaultFlags`          | 缺省的解析选项。它等于 `RAPIDJSON_WRITE_DEFAULT_FLAGS` 宏，此宏定义为  `kWriteNoFlags`。\n`kWriteValidateEncodingFlag`  | 校验 JSON 字符串的编码。\n`kWriteNanAndInfFlag`         | 容许写入 `Infinity`, `-Infinity` 及 `NaN`。\n\n此外，`Writer` 的构造函数有一 `levelDepth` 参数。存储每层阶信息的初始内存分配量受此参数影响。\n\n## PrettyWriter {#PrettyWriter}\n\n`Writer` 所输出的是没有空格字符的最紧凑 JSON，适合网络传输或储存，但不适合人类阅读。\n\n因此，RapidJSON 提供了一个 `PrettyWriter`，它在输出中加入缩进及换行。\n\n`PrettyWriter` 的用法与 `Writer` 几乎一样，不同之处是 `PrettyWriter` 提供了一个 `SetIndent(Ch indentChar, unsigned indentCharCount)` 函数。缺省的缩进是 4 个空格。\n\n## 完整性及重置 {#CompletenessReset}\n\n一个 `Writer` 只可输出单个 JSON，其根节点可以是任何 JSON 类型。当处理完单个根节点事件（如 `String()`），或匹配的最后 `EndObject()` 或 `EndArray()` 事件，输出的 JSON 是结构完整（well-formed）及完整的。使用者可调用 `Writer::IsComplete()` 去检测完整性。\n\n当 JSON 完整时，`Writer` 不能再接受新的事件。不然其输出便会是不合法的（例如有超过一个根节点）。为了重新利用 `Writer` 对象，使用者可调用 `Writer::Reset(OutputStream& os)` 去重置其所有内部状态及设置新的输出流。\n\n# 技巧 {#SaxTechniques}\n\n## 解析 JSON 至自定义结构 {#CustomDataStructure}\n\n`Document` 的解析功能完全依靠 `Reader`。实际上 `Document` 是一个处理器，在解析 JSON 时接收事件去建立一个 DOM。\n\n使用者可以直接使用 `Reader` 去建立其他数据结构。这消除了建立 DOM 的步骤，从而减少了内存开销并改善性能。\n\n在以下的 `messagereader` 例子中，`ParseMessages()` 解析一个 JSON，该 JSON 应该是一个含键值对的 object。\n\n~~~~~~~~~~cpp\n#include \"rapidjson/reader.h\"\n#include \"rapidjson/error/en.h\"\n#include <iostream>\n#include <string>\n#include <map>\n\nusing namespace std;\nusing namespace rapidjson;\n\ntypedef map<string, string> MessageMap;\n\nstruct MessageHandler\n    : public BaseReaderHandler<UTF8<>, MessageHandler> {\n    MessageHandler() : state_(kExpectObjectStart) {\n    }\n\n    bool StartObject() {\n        switch (state_) {\n        case kExpectObjectStart:\n            state_ = kExpectNameOrObjectEnd;\n            return true;\n        default:\n            return false;\n        }\n    }\n\n    bool String(const char* str, SizeType length, bool) {\n        switch (state_) {\n        case kExpectNameOrObjectEnd:\n            name_ = string(str, length);\n            state_ = kExpectValue;\n            return true;\n        case kExpectValue:\n            messages_.insert(MessageMap::value_type(name_, string(str, length)));\n            state_ = kExpectNameOrObjectEnd;\n            return true;\n        default:\n            return false;\n        }\n    }\n\n    bool EndObject(SizeType) { return state_ == kExpectNameOrObjectEnd; }\n\n    bool Default() { return false; } // All other events are invalid.\n\n    MessageMap messages_;\n    enum State {\n        kExpectObjectStart,\n        kExpectNameOrObjectEnd,\n        kExpectValue,\n    }state_;\n    std::string name_;\n};\n\nvoid ParseMessages(const char* json, MessageMap& messages) {\n    Reader reader;\n    MessageHandler handler;\n    StringStream ss(json);\n    if (reader.Parse(ss, handler))\n        messages.swap(handler.messages_);   // Only change it if success.\n    else {\n        ParseErrorCode e = reader.GetParseErrorCode();\n        size_t o = reader.GetErrorOffset();\n        cout << \"Error: \" << GetParseError_En(e) << endl;;\n        cout << \" at offset \" << o << \" near '\" << string(json).substr(o, 10) << \"...'\" << endl;\n    }\n}\n\nint main() {\n    MessageMap messages;\n\n    const char* json1 = \"{ \\\"greeting\\\" : \\\"Hello!\\\", \\\"farewell\\\" : \\\"bye-bye!\\\" }\";\n    cout << json1 << endl;\n    ParseMessages(json1, messages);\n\n    for (MessageMap::const_iterator itr = messages.begin(); itr != messages.end(); ++itr)\n        cout << itr->first << \": \" << itr->second << endl;\n\n    cout << endl << \"Parse a JSON with invalid schema.\" << endl;\n    const char* json2 = \"{ \\\"greeting\\\" : \\\"Hello!\\\", \\\"farewell\\\" : \\\"bye-bye!\\\", \\\"foo\\\" : {} }\";\n    cout << json2 << endl;\n    ParseMessages(json2, messages);\n\n    return 0;\n}\n~~~~~~~~~~\n\n~~~~~~~~~~\n{ \"greeting\" : \"Hello!\", \"farewell\" : \"bye-bye!\" }\nfarewell: bye-bye!\ngreeting: Hello!\n\nParse a JSON with invalid schema.\n{ \"greeting\" : \"Hello!\", \"farewell\" : \"bye-bye!\", \"foo\" : {} }\nError: Terminate parsing due to Handler error.\n at offset 59 near '} }...'\n~~~~~~~~~~\n\n第一个 JSON（`json1`）被成功地解析至 `MessageMap`。由于 `MessageMap` 是一个 `std::map`，打印次序按键值排序。此次序与 JSON 中的次序不同。\n\n在第二个 JSON（`json2`）中，`foo` 的值是一个空 object。由于它是一个 object，`MessageHandler::StartObject()` 会被调用。然而，在 `state_ = kExpectValue` 的情况下，该函数会返回 `false`，并导致解析过程终止。错误代码是 `kParseErrorTermination`。\n\n## 过滤 JSON {#Filtering}\n\n如前面提及过，`Writer` 可处理 `Reader` 发出的事件。`example/condense/condense.cpp` 例子简单地设置 `Writer` 作为一个 `Reader` 的处理器，因此它能移除 JSON 中的所有空白字符。`example/pretty/pretty.cpp` 例子使用同样的关系，只是以 `PrettyWriter` 取代 `Writer`。因此 `pretty` 能够重新格式化 JSON，加入缩进及换行。\n\n实际上，我们可以使用 SAX 风格 API 去加入（多个）中间层去过滤 JSON 的内容。例如 `capitalize` 例子可以把所有 JSON string 改为大写。\n\n~~~~~~~~~~cpp\n#include \"rapidjson/reader.h\"\n#include \"rapidjson/writer.h\"\n#include \"rapidjson/filereadstream.h\"\n#include \"rapidjson/filewritestream.h\"\n#include \"rapidjson/error/en.h\"\n#include <vector>\n#include <cctype>\n\nusing namespace rapidjson;\n\ntemplate<typename OutputHandler>\nstruct CapitalizeFilter {\n    CapitalizeFilter(OutputHandler& out) : out_(out), buffer_() {\n    }\n\n    bool Null() { return out_.Null(); }\n    bool Bool(bool b) { return out_.Bool(b); }\n    bool Int(int i) { return out_.Int(i); }\n    bool Uint(unsigned u) { return out_.Uint(u); }\n    bool Int64(int64_t i) { return out_.Int64(i); }\n    bool Uint64(uint64_t u) { return out_.Uint64(u); }\n    bool Double(double d) { return out_.Double(d); }\n    bool RawNumber(const char* str, SizeType length, bool copy) { return out_.RawNumber(str, length, copy); }\n    bool String(const char* str, SizeType length, bool) { \n        buffer_.clear();\n        for (SizeType i = 0; i < length; i++)\n            buffer_.push_back(std::toupper(str[i]));\n        return out_.String(&buffer_.front(), length, true); // true = output handler need to copy the string\n    }\n    bool StartObject() { return out_.StartObject(); }\n    bool Key(const char* str, SizeType length, bool copy) { return String(str, length, copy); }\n    bool EndObject(SizeType memberCount) { return out_.EndObject(memberCount); }\n    bool StartArray() { return out_.StartArray(); }\n    bool EndArray(SizeType elementCount) { return out_.EndArray(elementCount); }\n\n    OutputHandler& out_;\n    std::vector<char> buffer_;\n};\n\nint main(int, char*[]) {\n    // Prepare JSON reader and input stream.\n    Reader reader;\n    char readBuffer[65536];\n    FileReadStream is(stdin, readBuffer, sizeof(readBuffer));\n\n    // Prepare JSON writer and output stream.\n    char writeBuffer[65536];\n    FileWriteStream os(stdout, writeBuffer, sizeof(writeBuffer));\n    Writer<FileWriteStream> writer(os);\n\n    // JSON reader parse from the input stream and let writer generate the output.\n    CapitalizeFilter<Writer<FileWriteStream> > filter(writer);\n    if (!reader.Parse(is, filter)) {\n        fprintf(stderr, \"\\nError(%u): %s\\n\", (unsigned)reader.GetErrorOffset(), GetParseError_En(reader.GetParseErrorCode()));\n        return 1;\n    }\n\n    return 0;\n}\n~~~~~~~~~~\n\n注意到，不可简单地把 JSON 当作字符串去改为大写。例如：\n~~~~~~~~~~\n[\"Hello\\nWorld\"]\n~~~~~~~~~~\n\n简单地把整个 JSON 转为大写的话会产生错误的转义符：\n~~~~~~~~~~\n[\"HELLO\\NWORLD\"]\n~~~~~~~~~~\n\n而 `capitalize` 就会产生正确的结果：\n~~~~~~~~~~\n[\"HELLO\\nWORLD\"]\n~~~~~~~~~~\n\n我们还可以开发更复杂的过滤器。然而，由于 SAX 风格 API 在某一时间点只能提供单一事件的信息，使用者需要自行记录一些上下文信息（例如从根节点起的路径、储存其他相关值）。对于处理某些情况，用 DOM 会比 SAX 更容易实现。\n\n"
  },
  {
    "path": "ext/rapidjson/doc/schema.md",
    "content": "# Schema\n\n(This feature was released in v1.1.0)\n\nJSON Schema is a draft standard for describing the format of JSON data. The schema itself is also JSON data. By validating a JSON structure with JSON Schema, your code can safely access the DOM without manually checking types, or whether a key exists, etc. It can also ensure that the serialized JSON conform to a specified schema.\n\nRapidJSON implemented a JSON Schema validator for [JSON Schema Draft v4](http://json-schema.org/documentation.html). If you are not familiar with JSON Schema, you may refer to [Understanding JSON Schema](http://spacetelescope.github.io/understanding-json-schema/).\n\n[TOC]\n\n## Basic Usage\n\nFirst of all, you need to parse a JSON Schema into `Document`, and then compile the `Document` into a `SchemaDocument`.\n\nSecondly, construct a `SchemaValidator` with the `SchemaDocument`. It is similar to a `Writer` in the sense of handling SAX events. So, you can use `document.Accept(validator)` to validate a document, and then check the validity.\n\n~~~cpp\n#include \"rapidjson/schema.h\"\n\n// ...\n\nDocument sd;\nif (!sd.Parse(schemaJson).HasParseError()) {\n    // the schema is not a valid JSON.\n    // ...       \n}\nSchemaDocument schema(sd); // Compile a Document to SchemaDocument\n// sd is no longer needed here.\n\nDocument d;\nif (!d.Parse(inputJson).HasParseError()) {\n    // the input is not a valid JSON.\n    // ...       \n}\n\nSchemaValidator validator(schema);\nif (!d.Accept(validator)) {\n    // Input JSON is invalid according to the schema\n    // Output diagnostic information\n    StringBuffer sb;\n    validator.GetInvalidSchemaPointer().StringifyUriFragment(sb);\n    printf(\"Invalid schema: %s\\n\", sb.GetString());\n    printf(\"Invalid keyword: %s\\n\", validator.GetInvalidSchemaKeyword());\n    sb.Clear();\n    validator.GetInvalidDocumentPointer().StringifyUriFragment(sb);\n    printf(\"Invalid document: %s\\n\", sb.GetString());\n}\n~~~\n\nSome notes:\n\n* One `SchemaDocment` can be referenced by multiple `SchemaValidator`s. It will not be modified by `SchemaValidator`s.\n* A `SchemaValidator` may be reused to validate multiple documents. To run it for other documents, call `validator.Reset()` first.\n\n## Validation during parsing/serialization\n\nUnlike most JSON Schema validator implementations, RapidJSON provides a SAX-based schema validator. Therefore, you can parse a JSON from a stream while validating it on the fly. If the validator encounters a JSON value that invalidates the supplied schema, the parsing will be terminated immediately. This design is especially useful for parsing large JSON files.\n\n### DOM parsing\n\nFor using DOM in parsing, `Document` needs some preparation and finalizing tasks, in addition to receiving SAX events, thus it needs some work to route the reader, validator and the document. `SchemaValidatingReader` is a helper class that doing such work.\n\n~~~cpp\n#include \"rapidjson/filereadstream.h\"\n\n// ...\nSchemaDocument schema(sd); // Compile a Document to SchemaDocument\n\n// Use reader to parse the JSON\nFILE* fp = fopen(\"big.json\", \"r\");\nFileReadStream is(fp, buffer, sizeof(buffer));\n\n// Parse JSON from reader, validate the SAX events, and store in d.\nDocument d;\nSchemaValidatingReader<kParseDefaultFlags, FileReadStream, UTF8<> > reader(is, schema);\nd.Populate(reader);\n\nif (!reader.GetParseResult()) {\n    // Not a valid JSON\n    // When reader.GetParseResult().Code() == kParseErrorTermination,\n    // it may be terminated by:\n    // (1) the validator found that the JSON is invalid according to schema; or\n    // (2) the input stream has I/O error.\n\n    // Check the validation result\n    if (!reader.IsValid()) {\n        // Input JSON is invalid according to the schema\n        // Output diagnostic information\n        StringBuffer sb;\n        reader.GetInvalidSchemaPointer().StringifyUriFragment(sb);\n        printf(\"Invalid schema: %s\\n\", sb.GetString());\n        printf(\"Invalid keyword: %s\\n\", reader.GetInvalidSchemaKeyword());\n        sb.Clear();\n        reader.GetInvalidDocumentPointer().StringifyUriFragment(sb);\n        printf(\"Invalid document: %s\\n\", sb.GetString());\n    }\n}\n~~~\n\n### SAX parsing\n\nFor using SAX in parsing, it is much simpler. If it only need to validate the JSON without further processing, it is simply:\n\n~~~\nSchemaValidator validator(schema);\nReader reader;\nif (!reader.Parse(stream, validator)) {\n    if (!validator.IsValid()) {\n        // ...    \n    }\n}\n~~~\n\nThis is exactly the method used in the [schemavalidator](example/schemavalidator/schemavalidator.cpp) example. The distinct advantage is low memory usage, no matter how big the JSON was (the memory usage depends on the complexity of the schema).\n\nIf you need to handle the SAX events further, then you need to use the template class `GenericSchemaValidator` to set the output handler of the validator:\n\n~~~\nMyHandler handler;\nGenericSchemaValidator<SchemaDocument, MyHandler> validator(schema, handler);\nReader reader;\nif (!reader.Parse(ss, validator)) {\n    if (!validator.IsValid()) {\n        // ...    \n    }\n}\n~~~\n\n### Serialization\n\nIt is also possible to do validation during serializing. This can ensure the result JSON is valid according to the JSON schema.\n\n~~~\nStringBuffer sb;\nWriter<StringBuffer> writer(sb);\nGenericSchemaValidator<SchemaDocument, Writer<StringBuffer> > validator(s, writer);\nif (!d.Accept(validator)) {\n    // Some problem during Accept(), it may be validation or encoding issues.\n    if (!validator.IsValid()) {\n        // ...\n    }\n}\n~~~\n\nOf course, if your application only needs SAX-style serialization, it can simply send SAX events to `SchemaValidator` instead of `Writer`.\n\n## Remote Schema\n\nJSON Schema supports [`$ref` keyword](http://spacetelescope.github.io/understanding-json-schema/structuring.html), which is a [JSON pointer](doc/pointer.md) referencing to a local or remote schema. Local pointer is prefixed with `#`, while remote pointer is an relative or absolute URI. For example:\n\n~~~js\n{ \"$ref\": \"definitions.json#/address\" }\n~~~\n\nAs `SchemaDocument` does not know how to resolve such URI, it needs a user-provided `IRemoteSchemaDocumentProvider` instance to do so.\n\n~~~\nclass MyRemoteSchemaDocumentProvider : public IRemoteSchemaDocumentProvider {\npublic:\n    virtual const SchemaDocument* GetRemoteDocument(const char* uri, SizeTyp length) {\n        // Resolve the uri and returns a pointer to that schema.\n    }\n};\n\n// ...\n\nMyRemoteSchemaDocumentProvider provider;\nSchemaDocument schema(sd, &provider);\n~~~\n\n## Conformance\n\nRapidJSON passed 262 out of 263 tests in [JSON Schema Test Suite](https://github.com/json-schema/JSON-Schema-Test-Suite) (Json Schema draft 4).\n\nThe failed test is \"changed scope ref invalid\" of \"change resolution scope\" in `refRemote.json`. It is due to that `id` schema keyword and URI combining function are not implemented.\n\nBesides, the `format` schema keyword for string values is ignored, since it is not required by the specification.\n\n### Regular Expression\n\nThe schema keyword `pattern` and `patternProperties` uses regular expression to match the required pattern.\n\nRapidJSON implemented a simple NFA regular expression engine, which is used by default. It supports the following syntax.\n\n|Syntax|Description|\n|------|-----------|\n|`ab`    | Concatenation |\n|`a|b`   | Alternation |\n|`a?`    | Zero or one |\n|`a*`    | Zero or more |\n|`a+`    | One or more |\n|`a{3}`  | Exactly 3 times |\n|`a{3,}` | At least 3 times |\n|`a{3,5}`| 3 to 5 times |\n|`(ab)`  | Grouping |\n|`^a`    | At the beginning |\n|`a$`    | At the end |\n|`.`     | Any character |\n|`[abc]` | Character classes |\n|`[a-c]` | Character class range |\n|`[a-z0-9_]` | Character class combination |\n|`[^abc]` | Negated character classes |\n|`[^a-c]` | Negated character class range |\n|`[\\b]`   | Backspace (U+0008) |\n|`\\|`, `\\\\`, ...  | Escape characters |\n|`\\f` | Form feed (U+000C) |\n|`\\n` | Line feed (U+000A) |\n|`\\r` | Carriage return (U+000D) |\n|`\\t` | Tab (U+0009) |\n|`\\v` | Vertical tab (U+000B) |\n\nFor C++11 compiler, it is also possible to use the `std::regex` by defining `RAPIDJSON_SCHEMA_USE_INTERNALREGEX=0` and `RAPIDJSON_SCHEMA_USE_STDREGEX=1`. If your schemas do not need `pattern` and `patternProperties`, you can set both macros to zero to disable this feature, which will reduce some code size.\n\n## Performance\n\nMost C++ JSON libraries do not yet support JSON Schema. So we tried to evaluate the performance of RapidJSON's JSON Schema validator according to [json-schema-benchmark](https://github.com/ebdrup/json-schema-benchmark), which tests 11 JavaScript libraries running on Node.js.\n\nThat benchmark runs validations on [JSON Schema Test Suite](https://github.com/json-schema/JSON-Schema-Test-Suite), in which some test suites and tests are excluded. We made the same benchmarking procedure in [`schematest.cpp`](test/perftest/schematest.cpp).\n\nOn a Mac Book Pro (2.8 GHz Intel Core i7), the following results are collected.\n\n|Validator|Relative speed|Number of test runs per second|\n|---------|:------------:|:----------------------------:|\n|RapidJSON|155%|30682|\n|[`ajv`](https://github.com/epoberezkin/ajv)|100%|19770 (± 1.31%)|\n|[`is-my-json-valid`](https://github.com/mafintosh/is-my-json-valid)|70%|13835 (± 2.84%)|\n|[`jsen`](https://github.com/bugventure/jsen)|57.7%|11411 (± 1.27%)|\n|[`schemasaurus`](https://github.com/AlexeyGrishin/schemasaurus)|26%|5145 (± 1.62%)|\n|[`themis`](https://github.com/playlyfe/themis)|19.9%|3935 (± 2.69%)|\n|[`z-schema`](https://github.com/zaggino/z-schema)|7%|1388 (± 0.84%)|\n|[`jsck`](https://github.com/pandastrike/jsck#readme)|3.1%|606 (± 2.84%)|\n|[`jsonschema`](https://github.com/tdegrunt/jsonschema#readme)|0.9%|185 (± 1.01%)|\n|[`skeemas`](https://github.com/Prestaul/skeemas#readme)|0.8%|154 (± 0.79%)|\n|tv4|0.5%|93 (± 0.94%)|\n|[`jayschema`](https://github.com/natesilva/jayschema)|0.1%|21 (± 1.14%)|\n\nThat is, RapidJSON is about 1.5x faster than the fastest JavaScript library (ajv). And 1400x faster than the slowest one.\n"
  },
  {
    "path": "ext/rapidjson/doc/schema.zh-cn.md",
    "content": "# Schema\n\n（本功能于 v1.1.0 发布）\n\nJSON Schema 是描述 JSON 格式的一个标准草案。一个 schema 本身也是一个 JSON。使用 JSON Schema 去校验 JSON，可以让你的代码安全地访问 DOM，而无须检查类型或键值是否存在等。这也能确保输出的 JSON 是符合指定的 schema。\n\nRapidJSON 实现了一个 [JSON Schema Draft v4](http://json-schema.org/documentation.html) 的校验器。若你不熟悉 JSON Schema，可以参考 [Understanding JSON Schema](http://spacetelescope.github.io/understanding-json-schema/)。\n\n[TOC]\n\n## 基本用法\n\n首先，你要把 JSON Schema 解析成 `Document`，再把它编译成一个 `SchemaDocument`。\n\n然后，利用该 `SchemaDocument` 创建一个 `SchemaValidator`。它与 `Writer` 相似，都是能够处理 SAX 事件的。因此，你可以用 `document.Accept(validator)` 去校验一个 JSON，然后再获取校验结果。\n\n~~~cpp\n#include \"rapidjson/schema.h\"\n\n// ...\n\nDocument sd;\nif (!sd.Parse(schemaJson).HasParseError()) {\n    // 此 schema 不是合法的 JSON\n    // ...       \n}\nSchemaDocument schema(sd); // 把一个 Document 编译至 SchemaDocument\n// 之后不再需要 sd\n\nDocument d;\nif (!d.Parse(inputJson).HasParseError()) {\n    // 输入不是一个合法的 JSON\n    // ...       \n}\n\nSchemaValidator validator(schema);\nif (!d.Accept(validator)) {\n    // 输入的 JSON 不合乎 schema\n    // 打印诊断信息\n    StringBuffer sb;\n    validator.GetInvalidSchemaPointer().StringifyUriFragment(sb);\n    printf(\"Invalid schema: %s\\n\", sb.GetString());\n    printf(\"Invalid keyword: %s\\n\", validator.GetInvalidSchemaKeyword());\n    sb.Clear();\n    validator.GetInvalidDocumentPointer().StringifyUriFragment(sb);\n    printf(\"Invalid document: %s\\n\", sb.GetString());\n}\n~~~\n\n一些注意点：\n\n* 一个 `SchemaDocment` 能被多个 `SchemaValidator` 引用。它不会被 `SchemaValidator` 修改。\n* 可以重复使用一个 `SchemaValidator` 来校验多个文件。在校验其他文件前，须先调用 `validator.Reset()`。\n\n## 在解析／生成时进行校验\n\n与大部分 JSON Schema 校验器有所不同，RapidJSON 提供了一个基于 SAX 的 schema 校验器实现。因此，你可以在输入流解析 JSON 的同时进行校验。若校验器遇到一个与 schema 不符的值，就会立即终止解析。这设计对于解析大型 JSON 文件时特别有用。\n\n### DOM 解析\n\n在使用 DOM 进行解析时，`Document` 除了接收 SAX 事件外，还需做一些准备及结束工作，因此，为了连接 `Reader`、`SchemaValidator` 和 `Document` 要做多一点事情。`SchemaValidatingReader` 是一个辅助类去做那些工作。\n\n~~~cpp\n#include \"rapidjson/filereadstream.h\"\n\n// ...\nSchemaDocument schema(sd); // 把一个 Document 编译至 SchemaDocument\n\n// 使用 reader 解析 JSON\nFILE* fp = fopen(\"big.json\", \"r\");\nFileReadStream is(fp, buffer, sizeof(buffer));\n\n// 用 reader 解析 JSON，校验它的 SAX 事件，并存储至 d\nDocument d;\nSchemaValidatingReader<kParseDefaultFlags, FileReadStream, UTF8<> > reader(is, schema);\nd.Populate(reader);\n\nif (!reader.GetParseResult()) {\n    // 不是一个合法的 JSON\n    // 当 reader.GetParseResult().Code() == kParseErrorTermination,\n    // 它可能是被以下原因中止：\n    // (1) 校验器发现 JSON 不合乎 schema；或\n    // (2) 输入流有 I/O 错误。\n\n    // 检查校验结果\n    if (!reader.IsValid()) {\n        // 输入的 JSON 不合乎 schema\n        // 打印诊断信息\n        StringBuffer sb;\n        reader.GetInvalidSchemaPointer().StringifyUriFragment(sb);\n        printf(\"Invalid schema: %s\\n\", sb.GetString());\n        printf(\"Invalid keyword: %s\\n\", reader.GetInvalidSchemaKeyword());\n        sb.Clear();\n        reader.GetInvalidDocumentPointer().StringifyUriFragment(sb);\n        printf(\"Invalid document: %s\\n\", sb.GetString());\n    }\n}\n~~~\n\n### SAX 解析\n\n使用 SAX 解析时，情况就简单得多。若只需要校验 JSON 而无需进一步处理，那么仅需要：\n\n~~~\nSchemaValidator validator(schema);\nReader reader;\nif (!reader.Parse(stream, validator)) {\n    if (!validator.IsValid()) {\n        // ...    \n    }\n}\n~~~\n\n这种方式和 [schemavalidator](example/schemavalidator/schemavalidator.cpp) 例子完全相同。这带来的独特优势是，无论 JSON 多巨大，永远维持低内存用量（内存用量只与 Schema 的复杂度相关）。\n\n若你需要进一步处理 SAX 事件，便可使用模板类 `GenericSchemaValidator` 去设置校验器的输出 `Handler`：\n\n~~~\nMyHandler handler;\nGenericSchemaValidator<SchemaDocument, MyHandler> validator(schema, handler);\nReader reader;\nif (!reader.Parse(ss, validator)) {\n    if (!validator.IsValid()) {\n        // ...    \n    }\n}\n~~~\n\n### 生成\n\n我们也可以在生成（serialization）的时候进行校验。这能确保输出的 JSON 符合一个 JSON Schema。\n\n~~~\nStringBuffer sb;\nWriter<StringBuffer> writer(sb);\nGenericSchemaValidator<SchemaDocument, Writer<StringBuffer> > validator(s, writer);\nif (!d.Accept(validator)) {\n    // Some problem during Accept(), it may be validation or encoding issues.\n    if (!validator.IsValid()) {\n        // ...\n    }\n}\n~~~\n\n当然，如果你的应用仅需要 SAX 风格的生成，那么只需要把 SAX 事件由原来发送到 `Writer`，改为发送到 `SchemaValidator`。\n\n## 远程 Schema\n\nJSON Schema 支持 [`$ref` 关键字](http://spacetelescope.github.io/understanding-json-schema/structuring.html)，它是一个 [JSON pointer](doc/pointer.zh-cn.md) 引用至一个本地（local）或远程（remote） schema。本地指针的首字符是 `#`，而远程指针是一个相对或绝对 URI。例如：\n\n~~~js\n{ \"$ref\": \"definitions.json#/address\" }\n~~~\n\n由于 `SchemaDocument` 并不知道如何处理那些 URI，它需要使用者提供一个 `IRemoteSchemaDocumentProvider` 的实例去处理。\n\n~~~\nclass MyRemoteSchemaDocumentProvider : public IRemoteSchemaDocumentProvider {\npublic:\n    virtual const SchemaDocument* GetRemoteDocument(const char* uri, SizeTyp length) {\n        // Resolve the uri and returns a pointer to that schema.\n    }\n};\n\n// ...\n\nMyRemoteSchemaDocumentProvider provider;\nSchemaDocument schema(sd, &provider);\n~~~\n\n## 标准的符合程度\n\nRapidJSON 通过了 [JSON Schema Test Suite](https://github.com/json-schema/JSON-Schema-Test-Suite) (Json Schema draft 4) 中 263 个测试的 262 个。\n\n没通过的测试是 `refRemote.json` 中的 \"change resolution scope\" - \"changed scope ref invalid\"。这是由于未实现 `id` schema 关键字及 URI 合并功能。\n\n除此以外，关于字符串类型的 `format` schema 关键字也会被忽略，因为标准中并没需求必须实现。\n\n### 正则表达式\n\n`pattern` 及 `patternProperties` 这两个 schema 关键字使用了正则表达式去匹配所需的模式。\n\nRapidJSON 实现了一个简单的 NFA 正则表达式引擎，并预设使用。它支持以下语法。\n\n|语法|描述|\n|------|-----------|\n|`ab`    | 串联 |\n|`a|b`   | 交替 |\n|`a?`    | 零或一次 |\n|`a*`    | 零或多次 |\n|`a+`    | 一或多次 |\n|`a{3}`  | 刚好 3 次 |\n|`a{3,}` | 至少 3 次 |\n|`a{3,5}`| 3 至 5 次 |\n|`(ab)`  | 分组 |\n|`^a`    | 在开始处 |\n|`a$`    | 在结束处 |\n|`.`     | 任何字符 |\n|`[abc]` | 字符组 |\n|`[a-c]` | 字符组范围 |\n|`[a-z0-9_]` | 字符组组合 |\n|`[^abc]` | 字符组取反 |\n|`[^a-c]` | 字符组范围取反 |\n|`[\\b]`   | 退格符 (U+0008) |\n|`\\|`, `\\\\`, ...  | 转义字符 |\n|`\\f` | 馈页 (U+000C) |\n|`\\n` | 馈行 (U+000A) |\n|`\\r` | 回车 (U+000D) |\n|`\\t` | 制表 (U+0009) |\n|`\\v` | 垂直制表 (U+000B) |\n\n对于使用 C++11 编译器的使用者，也可使用 `std::regex`，只需定义 `RAPIDJSON_SCHEMA_USE_INTERNALREGEX=0` 及 `RAPIDJSON_SCHEMA_USE_STDREGEX=1`。若你的 schema 无需使用 `pattern` 或 `patternProperties`，可以把两个宏都设为零，以禁用此功能，这样做可节省一些代码体积。\n\n## 性能\n\n大部分 C++ JSON 库都未支持 JSON Schema。因此我们尝试按照 [json-schema-benchmark](https://github.com/ebdrup/json-schema-benchmark) 去评估 RapidJSON 的 JSON Schema 校验器。该评测测试了 11 个运行在 node.js 上的 JavaScript 库。\n\n该评测校验 [JSON Schema Test Suite](https://github.com/json-schema/JSON-Schema-Test-Suite) 中的测试，当中排除了一些测试套件及个别测试。我们在 [`schematest.cpp`](test/perftest/schematest.cpp) 实现了相同的评测。\n\n在 MacBook Pro (2.8 GHz Intel Core i7) 上收集到以下结果。\n\n|校验器|相对速度|每秒执行的测试数目|\n|---------|:------------:|:----------------------------:|\n|RapidJSON|155%|30682|\n|[`ajv`](https://github.com/epoberezkin/ajv)|100%|19770 (± 1.31%)|\n|[`is-my-json-valid`](https://github.com/mafintosh/is-my-json-valid)|70%|13835 (± 2.84%)|\n|[`jsen`](https://github.com/bugventure/jsen)|57.7%|11411 (± 1.27%)|\n|[`schemasaurus`](https://github.com/AlexeyGrishin/schemasaurus)|26%|5145 (± 1.62%)|\n|[`themis`](https://github.com/playlyfe/themis)|19.9%|3935 (± 2.69%)|\n|[`z-schema`](https://github.com/zaggino/z-schema)|7%|1388 (± 0.84%)|\n|[`jsck`](https://github.com/pandastrike/jsck#readme)|3.1%|606 (± 2.84%)|\n|[`jsonschema`](https://github.com/tdegrunt/jsonschema#readme)|0.9%|185 (± 1.01%)|\n|[`skeemas`](https://github.com/Prestaul/skeemas#readme)|0.8%|154 (± 0.79%)|\n|tv4|0.5%|93 (± 0.94%)|\n|[`jayschema`](https://github.com/natesilva/jayschema)|0.1%|21 (± 1.14%)|\n\n换言之，RapidJSON 比最快的 JavaScript 库（ajv）快约 1.5x。比最慢的快 1400x。\n"
  },
  {
    "path": "ext/rapidjson/doc/stream.md",
    "content": "# Stream\n\nIn RapidJSON, `rapidjson::Stream` is a concept for reading/writing JSON. Here we first show how to use streams provided. And then see how to create a custom stream.\n\n[TOC]\n\n# Memory Streams {#MemoryStreams}\n\nMemory streams store JSON in memory.\n\n## StringStream (Input) {#StringStream}\n\n`StringStream` is the most basic input stream. It represents a complete, read-only JSON stored in memory. It is defined in `rapidjson/rapidjson.h`.\n\n~~~~~~~~~~cpp\n#include \"rapidjson/document.h\" // will include \"rapidjson/rapidjson.h\"\n\nusing namespace rapidjson;\n\n// ...\nconst char json[] = \"[1, 2, 3, 4]\";\nStringStream s(json);\n\nDocument d;\nd.ParseStream(s);\n~~~~~~~~~~\n\nSince this is very common usage, `Document::Parse(const char*)` is provided to do exactly the same as above:\n\n~~~~~~~~~~cpp\n// ...\nconst char json[] = \"[1, 2, 3, 4]\";\nDocument d;\nd.Parse(json);\n~~~~~~~~~~\n\nNote that, `StringStream` is a typedef of `GenericStringStream<UTF8<> >`, user may use another encodings to represent the character set of the stream.\n\n## StringBuffer (Output) {#StringBuffer}\n\n`StringBuffer` is a simple output stream. It allocates a memory buffer for writing the whole JSON. Use `GetString()` to obtain the buffer.\n\n~~~~~~~~~~cpp\n#include \"rapidjson/stringbuffer.h\"\n\nStringBuffer buffer;\nWriter<StringBuffer> writer(buffer);\nd.Accept(writer);\n\nconst char* output = buffer.GetString();\n~~~~~~~~~~\n\nWhen the buffer is full, it will increases the capacity automatically. The default capacity is 256 characters (256 bytes for UTF8, 512 bytes for UTF16, etc.). User can provide an allocator and a initial capacity.\n\n~~~~~~~~~~cpp\nStringBuffer buffer1(0, 1024); // Use its allocator, initial size = 1024\nStringBuffer buffer2(allocator, 1024);\n~~~~~~~~~~\n\nBy default, `StringBuffer` will instantiate an internal allocator.\n\nSimilarly, `StringBuffer` is a typedef of `GenericStringBuffer<UTF8<> >`.\n\n# File Streams {#FileStreams}\n\nWhen parsing a JSON from file, you may read the whole JSON into memory and use ``StringStream`` above.\n\nHowever, if the JSON is big, or memory is limited, you can use `FileReadStream`. It only read a part of JSON from file into buffer, and then let the part be parsed. If it runs out of characters in the buffer, it will read the next part from file.\n\n## FileReadStream (Input) {#FileReadStream}\n\n`FileReadStream` reads the file via a `FILE` pointer. And user need to provide a buffer.\n\n~~~~~~~~~~cpp\n#include \"rapidjson/filereadstream.h\"\n#include <cstdio>\n\nusing namespace rapidjson;\n\nFILE* fp = fopen(\"big.json\", \"rb\"); // non-Windows use \"r\"\n\nchar readBuffer[65536];\nFileReadStream is(fp, readBuffer, sizeof(readBuffer));\n\nDocument d;\nd.ParseStream(is);\n\nfclose(fp);\n~~~~~~~~~~\n\nDifferent from string streams, `FileReadStream` is byte stream. It does not handle encodings. If the file is not UTF-8, the byte stream can be wrapped in a `EncodedInputStream`. It will be discussed very soon.\n\nApart from reading file, user can also use `FileReadStream` to read `stdin`.\n\n## FileWriteStream (Output) {#FileWriteStream}\n\n`FileWriteStream` is buffered output stream. Its usage is very similar to `FileReadStream`.\n\n~~~~~~~~~~cpp\n#include \"rapidjson/filewritestream.h\"\n#include <cstdio>\n\nusing namespace rapidjson;\n\nDocument d;\nd.Parse(json);\n// ...\n\nFILE* fp = fopen(\"output.json\", \"wb\"); // non-Windows use \"w\"\n\nchar writeBuffer[65536];\nFileWriteStream os(fp, writeBuffer, sizeof(writeBuffer));\n\nWriter<FileWriteStream> writer(os);\nd.Accept(writer);\n\nfclose(fp);\n~~~~~~~~~~\n\nIt can also directs the output to `stdout`.\n\n# iostream Wrapper {#iostreamWrapper}\n\nDue to users' requests, RapidJSON provided official wrappers for `std::basic_istream` and `std::basic_ostream`. However, please note that the performance will be much lower than the other streams above.\n\n## IStreamWrapper {#IStreamWrapper}\n\n`IStreamWrapper` wraps any class drived from `std::istream`, such as `std::istringstream`, `std::stringstream`, `std::ifstream`, `std::fstream`, into RapidJSON's input stream.\n\n~~~cpp\n#include <rapidjson/document.h>\n#include <rapidjson/istreamwrapper.h>\n#include <fstream>\n\nusing namespace rapidjson;\nusing namespace std;\n\nifstream ifs(\"test.json\");\nIStreamWrapper isw(ifs);\n\nDocument d;\nd.ParseStream(isw);\n~~~\n\nFor classes derived from `std::wistream`, use `WIStreamWrapper`.\n\n## OStreamWrapper {#OStreamWrapper}\n\nSimilarly, `OStreamWrapper` wraps any class derived from `std::ostream`, such as `std::ostringstream`, `std::stringstream`, `std::ofstream`, `std::fstream`, into RapidJSON's input stream.\n\n~~~cpp\n#include <rapidjson/document.h>\n#include <rapidjson/ostreamwrapper.h>\n#include <rapidjson/writer.h>\n#include <fstream>\n\nusing namespace rapidjson;\nusing namespace std;\n\nDocument d;\nd.Parse(json);\n\n// ...\n\nofstream ofs(\"output.json\");\nOStreamWrapper osw(ofs);\n\nWriter<OStreamWrapper> writer(osw);\nd.Accept(writer);\n~~~\n\nFor classes derived from `std::wostream`, use `WOStreamWrapper`.\n\n# Encoded Streams {#EncodedStreams}\n\nEncoded streams do not contain JSON itself, but they wrap byte streams to provide basic encoding/decoding function.\n\nAs mentioned above, UTF-8 byte streams can be read directly. However, UTF-16 and UTF-32 have endian issue. To handle endian correctly, it needs to convert bytes into characters (e.g. `wchar_t` for UTF-16) while reading, and characters into bytes while writing.\n\nBesides, it also need to handle [byte order mark (BOM)](http://en.wikipedia.org/wiki/Byte_order_mark). When reading from a byte stream, it is needed to detect or just consume the BOM if exists. When writing to a byte stream, it can optionally write BOM.\n\nIf the encoding of stream is known in compile-time, you may use `EncodedInputStream` and `EncodedOutputStream`. If the stream can be UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF-32BE JSON, and it is only known in runtime, you may use `AutoUTFInputStream` and `AutoUTFOutputStream`. These streams are defined in `rapidjson/encodedstream.h`.\n\nNote that, these encoded streams can be applied to streams other than file. For example, you may have a file in memory, or a custom byte stream, be wrapped in encoded streams.\n\n## EncodedInputStream {#EncodedInputStream}\n\n`EncodedInputStream` has two template parameters. The first one is a `Encoding` class, such as `UTF8`, `UTF16LE`, defined in `rapidjson/encodings.h`. The second one is the class of stream to be wrapped.\n\n~~~~~~~~~~cpp\n#include \"rapidjson/document.h\"\n#include \"rapidjson/filereadstream.h\"   // FileReadStream\n#include \"rapidjson/encodedstream.h\"    // EncodedInputStream\n#include <cstdio>\n\nusing namespace rapidjson;\n\nFILE* fp = fopen(\"utf16le.json\", \"rb\"); // non-Windows use \"r\"\n\nchar readBuffer[256];\nFileReadStream bis(fp, readBuffer, sizeof(readBuffer));\n\nEncodedInputStream<UTF16LE<>, FileReadStream> eis(bis);  // wraps bis into eis\n\nDocument d; // Document is GenericDocument<UTF8<> > \nd.ParseStream<0, UTF16LE<> >(eis);  // Parses UTF-16LE file into UTF-8 in memory\n\nfclose(fp);\n~~~~~~~~~~\n\n## EncodedOutputStream {#EncodedOutputStream}\n\n`EncodedOutputStream` is similar but it has a `bool putBOM` parameter in the constructor, controlling whether to write BOM into output byte stream.\n\n~~~~~~~~~~cpp\n#include \"rapidjson/filewritestream.h\"  // FileWriteStream\n#include \"rapidjson/encodedstream.h\"    // EncodedOutputStream\n#include <cstdio>\n\nDocument d;         // Document is GenericDocument<UTF8<> > \n// ...\n\nFILE* fp = fopen(\"output_utf32le.json\", \"wb\"); // non-Windows use \"w\"\n\nchar writeBuffer[256];\nFileWriteStream bos(fp, writeBuffer, sizeof(writeBuffer));\n\ntypedef EncodedOutputStream<UTF32LE<>, FileWriteStream> OutputStream;\nOutputStream eos(bos, true);   // Write BOM\n\nWriter<OutputStream, UTF32LE<>, UTF8<>> writer(eos);\nd.Accept(writer);   // This generates UTF32-LE file from UTF-8 in memory\n\nfclose(fp);\n~~~~~~~~~~\n\n## AutoUTFInputStream {#AutoUTFInputStream}\n\nSometimes an application may want to handle all supported JSON encoding. `AutoUTFInputStream` will detection encoding by BOM first. If BOM is unavailable, it will use  characteristics of valid JSON to make detection. If neither method success, it falls back to the UTF type provided in constructor.\n\nSince the characters (code units) may be 8-bit, 16-bit or 32-bit. `AutoUTFInputStream` requires a character type which can hold at least 32-bit. We may use `unsigned`, as in the template parameter:\n\n~~~~~~~~~~cpp\n#include \"rapidjson/document.h\"\n#include \"rapidjson/filereadstream.h\"   // FileReadStream\n#include \"rapidjson/encodedstream.h\"    // AutoUTFInputStream\n#include <cstdio>\n\nusing namespace rapidjson;\n\nFILE* fp = fopen(\"any.json\", \"rb\"); // non-Windows use \"r\"\n\nchar readBuffer[256];\nFileReadStream bis(fp, readBuffer, sizeof(readBuffer));\n\nAutoUTFInputStream<unsigned, FileReadStream> eis(bis);  // wraps bis into eis\n\nDocument d;         // Document is GenericDocument<UTF8<> > \nd.ParseStream<0, AutoUTF<unsigned> >(eis); // This parses any UTF file into UTF-8 in memory\n\nfclose(fp);\n~~~~~~~~~~\n\nWhen specifying the encoding of stream, uses `AutoUTF<CharType>` as in `ParseStream()` above.\n\nYou can obtain the type of UTF via `UTFType GetType()`. And check whether a BOM is found by `HasBOM()`\n\n## AutoUTFOutputStream {#AutoUTFOutputStream}\n\nSimilarly, to choose encoding for output during runtime, we can use `AutoUTFOutputStream`. This class is not automatic *per se*. You need to specify the UTF type and whether to write BOM in runtime.\n\n~~~~~~~~~~cpp\nusing namespace rapidjson;\n\nvoid WriteJSONFile(FILE* fp, UTFType type, bool putBOM, const Document& d) {\n    char writeBuffer[256];\n    FileWriteStream bos(fp, writeBuffer, sizeof(writeBuffer));\n\n    typedef AutoUTFOutputStream<unsigned, FileWriteStream> OutputStream;\n    OutputStream eos(bos, type, putBOM);\n    \n    Writer<OutputStream, UTF8<>, AutoUTF<> > writer;\n    d.Accept(writer);\n}\n~~~~~~~~~~\n\n`AutoUTFInputStream` and `AutoUTFOutputStream` is more convenient than `EncodedInputStream` and `EncodedOutputStream`. They just incur a little bit runtime overheads.\n\n# Custom Stream {#CustomStream}\n\nIn addition to memory/file streams, user can create their own stream classes which fits RapidJSON's API. For example, you may create network stream, stream from compressed file, etc.\n\nRapidJSON combines different types using templates. A class containing all required interface can be a stream. The Stream interface is defined in comments of `rapidjson/rapidjson.h`:\n\n~~~~~~~~~~cpp\nconcept Stream {\n    typename Ch;    //!< Character type of the stream.\n\n    //! Read the current character from stream without moving the read cursor.\n    Ch Peek() const;\n\n    //! Read the current character from stream and moving the read cursor to next character.\n    Ch Take();\n\n    //! Get the current read cursor.\n    //! \\return Number of characters read from start.\n    size_t Tell();\n\n    //! Begin writing operation at the current read pointer.\n    //! \\return The begin writer pointer.\n    Ch* PutBegin();\n\n    //! Write a character.\n    void Put(Ch c);\n\n    //! Flush the buffer.\n    void Flush();\n\n    //! End the writing operation.\n    //! \\param begin The begin write pointer returned by PutBegin().\n    //! \\return Number of characters written.\n    size_t PutEnd(Ch* begin);\n}\n~~~~~~~~~~\n\nFor input stream, they must implement `Peek()`, `Take()` and `Tell()`.\nFor output stream, they must implement `Put()` and `Flush()`. \nThere are two special interface, `PutBegin()` and `PutEnd()`, which are only for *in situ* parsing. Normal streams do not implement them. However, if the interface is not needed for a particular stream, it is still need to a dummy implementation, otherwise will generate compilation error.\n\n## Example: istream wrapper {#ExampleIStreamWrapper}\n\nThe following example is a simple wrapper of `std::istream`, which only implements 3 functions.\n\n~~~~~~~~~~cpp\nclass MyIStreamWrapper {\npublic:\n    typedef char Ch;\n\n    MyIStreamWrapper(std::istream& is) : is_(is) {\n    }\n\n    Ch Peek() const { // 1\n        int c = is_.peek();\n        return c == std::char_traits<char>::eof() ? '\\0' : (Ch)c;\n    }\n\n    Ch Take() { // 2\n        int c = is_.get();\n        return c == std::char_traits<char>::eof() ? '\\0' : (Ch)c;\n    }\n\n    size_t Tell() const { return (size_t)is_.tellg(); } // 3\n\n    Ch* PutBegin() { assert(false); return 0; }\n    void Put(Ch) { assert(false); }\n    void Flush() { assert(false); }\n    size_t PutEnd(Ch*) { assert(false); return 0; }\n\nprivate:\n    MyIStreamWrapper(const MyIStreamWrapper&);\n    MyIStreamWrapper& operator=(const MyIStreamWrapper&);\n\n    std::istream& is_;\n};\n~~~~~~~~~~\n\nUser can use it to wrap instances of `std::stringstream`, `std::ifstream`.\n\n~~~~~~~~~~cpp\nconst char* json = \"[1,2,3,4]\";\nstd::stringstream ss(json);\nMyIStreamWrapper is(ss);\n\nDocument d;\nd.ParseStream(is);\n~~~~~~~~~~\n\nNote that, this implementation may not be as efficient as RapidJSON's memory or file streams, due to internal overheads of the standard library.\n\n## Example: ostream wrapper {#ExampleOStreamWrapper}\n\nThe following example is a simple wrapper of `std::istream`, which only implements 2 functions.\n\n~~~~~~~~~~cpp\nclass MyOStreamWrapper {\npublic:\n    typedef char Ch;\n\n    MyOStreamWrapper(std::ostream& os) : os_(os) {\n    }\n\n    Ch Peek() const { assert(false); return '\\0'; }\n    Ch Take() { assert(false); return '\\0'; }\n    size_t Tell() const {  }\n\n    Ch* PutBegin() { assert(false); return 0; }\n    void Put(Ch c) { os_.put(c); }                  // 1\n    void Flush() { os_.flush(); }                   // 2\n    size_t PutEnd(Ch*) { assert(false); return 0; }\n\nprivate:\n    MyOStreamWrapper(const MyOStreamWrapper&);\n    MyOStreamWrapper& operator=(const MyOStreamWrapper&);\n\n    std::ostream& os_;\n};\n~~~~~~~~~~\n\nUser can use it to wrap instances of `std::stringstream`, `std::ofstream`.\n\n~~~~~~~~~~cpp\nDocument d;\n// ...\n\nstd::stringstream ss;\nMyOStreamWrapper os(ss);\n\nWriter<MyOStreamWrapper> writer(os);\nd.Accept(writer);\n~~~~~~~~~~\n\nNote that, this implementation may not be as efficient as RapidJSON's memory or file streams, due to internal overheads of the standard library.\n\n# Summary {#Summary}\n\nThis section describes stream classes available in RapidJSON. Memory streams are simple. File stream can reduce the memory required during JSON parsing and generation, if the JSON is stored in file system. Encoded streams converts between byte streams and character streams. Finally, user may create custom streams using a simple interface.\n"
  },
  {
    "path": "ext/rapidjson/doc/stream.zh-cn.md",
    "content": "# 流\n\n在 RapidJSON 中，`rapidjson::Stream` 是用於读写 JSON 的概念（概念是指 C++ 的 concept）。在这里我们先介绍如何使用 RapidJSON 提供的各种流。然后再看看如何自行定义流。\n\n[TOC]\n\n# 内存流 {#MemoryStreams}\n\n内存流把 JSON 存储在内存之中。\n\n## StringStream（输入）{#StringStream}\n\n`StringStream` 是最基本的输入流，它表示一个完整的、只读的、存储于内存的 JSON。它在 `rapidjson/rapidjson.h` 中定义。\n\n~~~~~~~~~~cpp\n#include \"rapidjson/document.h\" // 会包含 \"rapidjson/rapidjson.h\"\n\nusing namespace rapidjson;\n\n// ...\nconst char json[] = \"[1, 2, 3, 4]\";\nStringStream s(json);\n\nDocument d;\nd.ParseStream(s);\n~~~~~~~~~~\n\n由于这是非常常用的用法，RapidJSON 提供 `Document::Parse(const char*)` 去做完全相同的事情：\n\n~~~~~~~~~~cpp\n// ...\nconst char json[] = \"[1, 2, 3, 4]\";\nDocument d;\nd.Parse(json);\n~~~~~~~~~~\n\n需要注意，`StringStream` 是 `GenericStringStream<UTF8<> >` 的 typedef，使用者可用其他编码类去代表流所使用的字符集。\n\n## StringBuffer（输出）{#StringBuffer}\n\n`StringBuffer` 是一个简单的输出流。它分配一个内存缓冲区，供写入整个 JSON。可使用 `GetString()` 来获取该缓冲区。\n\n~~~~~~~~~~cpp\n#include \"rapidjson/stringbuffer.h\"\n\nStringBuffer buffer;\nWriter<StringBuffer> writer(buffer);\nd.Accept(writer);\n\nconst char* output = buffer.GetString();\n~~~~~~~~~~\n\n当缓冲区满溢，它将自动增加容量。缺省容量是 256 个字符（UTF8 是 256 字节，UTF16 是 512 字节等）。使用者能自行提供分配器及初始容量。\n\n~~~~~~~~~~cpp\nStringBuffer buffer1(0, 1024); // 使用它的分配器，初始大小 = 1024\nStringBuffer buffer2(allocator, 1024);\n~~~~~~~~~~\n\n如无设置分配器，`StringBuffer` 会自行实例化一个内部分配器。\n\n相似地，`StringBuffer` 是 `GenericStringBuffer<UTF8<> >` 的 typedef。\n\n# 文件流 {#FileStreams}\n\n当要从文件解析一个 JSON，你可以把整个 JSON 读入内存并使用上述的 `StringStream`。\n\n然而，若 JSON 很大，或是内存有限，你可以改用 `FileReadStream`。它只会从文件读取一部分至缓冲区，然后让那部分被解析。若缓冲区的字符都被读完，它会再从文件读取下一部分。\n\n## FileReadStream（输入） {#FileReadStream}\n\n`FileReadStream` 通过 `FILE` 指针读取文件。使用者需要提供一个缓冲区。\n\n~~~~~~~~~~cpp\n#include \"rapidjson/filereadstream.h\"\n#include <cstdio>\n\nusing namespace rapidjson;\n\nFILE* fp = fopen(\"big.json\", \"rb\"); // 非 Windows 平台使用 \"r\"\n\nchar readBuffer[65536];\nFileReadStream is(fp, readBuffer, sizeof(readBuffer));\n\nDocument d;\nd.ParseStream(is);\n\nfclose(fp);\n~~~~~~~~~~\n\n与 `StringStreams` 不一样，`FileReadStream` 是一个字节流。它不处理编码。若文件并非 UTF-8 编码，可以把字节流用 `EncodedInputStream` 包装。我们很快会讨论这个问题。\n\n除了读取文件，使用者也可以使用 `FileReadStream` 来读取 `stdin`。\n\n## FileWriteStream（输出）{#FileWriteStream}\n\n`FileWriteStream` 是一个含缓冲功能的输出流。它的用法与 `FileReadStream` 非常相似。\n\n~~~~~~~~~~cpp\n#include \"rapidjson/filewritestream.h\"\n#include <cstdio>\n\nusing namespace rapidjson;\n\nDocument d;\nd.Parse(json);\n// ...\n\nFILE* fp = fopen(\"output.json\", \"wb\"); // 非 Windows 平台使用 \"w\"\n\nchar writeBuffer[65536];\nFileWriteStream os(fp, writeBuffer, sizeof(writeBuffer));\n\nWriter<FileWriteStream> writer(os);\nd.Accept(writer);\n\nfclose(fp);\n~~~~~~~~~~\n\n它也可以把输出导向 `stdout`。\n\n# iostream 包装类 {#iostreamWrapper}\n\n基于用户的要求，RapidJSON 提供了正式的 `std::basic_istream` 和 `std::basic_ostream` 包装类。然而，请注意其性能会大大低于以上的其他流。\n\n## IStreamWrapper {#IStreamWrapper}\n\n`IStreamWrapper` 把任何继承自 `std::istream` 的类（如 `std::istringstream`、`std::stringstream`、`std::ifstream`、`std::fstream`）包装成 RapidJSON 的输入流。\n\n~~~cpp\n#include <rapidjson/document.h>\n#include <rapidjson/istreamwrapper.h>\n#include <fstream>\n\nusing namespace rapidjson;\nusing namespace std;\n\nifstream ifs(\"test.json\");\nIStreamWrapper isw(ifs);\n\nDocument d;\nd.ParseStream(isw);\n~~~\n\n对于继承自 `std::wistream` 的类，则使用 `WIStreamWrapper`。\n\n## OStreamWrapper {#OStreamWrapper}\n\n相似地，`OStreamWrapper` 把任何继承自 `std::ostream` 的类（如 `std::ostringstream`、`std::stringstream`、`std::ofstream`、`std::fstream`）包装成 RapidJSON 的输出流。\n\n~~~cpp\n#include <rapidjson/document.h>\n#include <rapidjson/ostreamwrapper.h>\n#include <rapidjson/writer.h>\n#include <fstream>\n\nusing namespace rapidjson;\nusing namespace std;\n\nDocument d;\nd.Parse(json);\n\n// ...\n\nofstream ofs(\"output.json\");\nOStreamWrapper osw(ofs);\n\nWriter<OStreamWrapper> writer(osw);\nd.Accept(writer);\n~~~\n\n对于继承自 `std::wistream` 的类，则使用 `WIStreamWrapper`。\n\n# 编码流 {#EncodedStreams}\n\n编码流（encoded streams）本身不存储 JSON，它们是通过包装字节流来提供基本的编码／解码功能。\n\n如上所述，我们可以直接读入 UTF-8 字节流。然而，UTF-16 及 UTF-32 有字节序（endian）问题。要正确地处理字节序，需要在读取时把字节转换成字符（如对 UTF-16 使用 `wchar_t`），以及在写入时把字符转换为字节。\n\n除此以外，我们也需要处理 [字节顺序标记（byte order mark, BOM）](http://en.wikipedia.org/wiki/Byte_order_mark)。当从一个字节流读取时，需要检测 BOM，或者仅仅是把存在的 BOM 消去。当把 JSON 写入字节流时，也可选择写入 BOM。\n\n若一个流的编码在编译期已知，你可使用 `EncodedInputStream` 及 `EncodedOutputStream`。若一个流可能存储 UTF-8、UTF-16LE、UTF-16BE、UTF-32LE、UTF-32BE 的 JSON，并且编码只能在运行时得知，你便可以使用 `AutoUTFInputStream` 及 `AutoUTFOutputStream`。这些流定义在 `rapidjson/encodedstream.h`。\n\n注意到，这些编码流可以施于文件以外的流。例如，你可以用编码流包装内存中的文件或自定义的字节流。\n\n## EncodedInputStream {#EncodedInputStream}\n\n`EncodedInputStream` 含两个模板参数。第一个是 `Encoding` 类型，例如定义于 `rapidjson/encodings.h` 的 `UTF8`、`UTF16LE`。第二个参数是被包装的流的类型。\n\n~~~~~~~~~~cpp\n#include \"rapidjson/document.h\"\n#include \"rapidjson/filereadstream.h\"   // FileReadStream\n#include \"rapidjson/encodedstream.h\"    // EncodedInputStream\n#include <cstdio>\n\nusing namespace rapidjson;\n\nFILE* fp = fopen(\"utf16le.json\", \"rb\"); // 非 Windows 平台使用 \"r\"\n\nchar readBuffer[256];\nFileReadStream bis(fp, readBuffer, sizeof(readBuffer));\n\nEncodedInputStream<UTF16LE<>, FileReadStream> eis(bis);  // 用 eis 包装 bis\n\nDocument d; // Document 为 GenericDocument<UTF8<> > \nd.ParseStream<0, UTF16LE<> >(eis);  // 把 UTF-16LE 文件解析至内存中的 UTF-8\n\nfclose(fp);\n~~~~~~~~~~\n\n## EncodedOutputStream {#EncodedOutputStream}\n\n`EncodedOutputStream` 也是相似的，但它的构造函数有一个 `bool putBOM` 参数，用于控制是否在输出字节流写入 BOM。\n\n~~~~~~~~~~cpp\n#include \"rapidjson/filewritestream.h\"  // FileWriteStream\n#include \"rapidjson/encodedstream.h\"    // EncodedOutputStream\n#include <cstdio>\n\nDocument d;         // Document 为 GenericDocument<UTF8<> > \n// ...\n\nFILE* fp = fopen(\"output_utf32le.json\", \"wb\"); // 非 Windows 平台使用 \"w\"\n\nchar writeBuffer[256];\nFileWriteStream bos(fp, writeBuffer, sizeof(writeBuffer));\n\ntypedef EncodedOutputStream<UTF32LE<>, FileWriteStream> OutputStream;\nOutputStream eos(bos, true);   // 写入 BOM\n\nWriter<OutputStream, UTF32LE<>, UTF8<>> writer(eos);\nd.Accept(writer);   // 这里从内存的 UTF-8 生成 UTF32-LE 文件\n\nfclose(fp);\n~~~~~~~~~~\n\n## AutoUTFInputStream {#AutoUTFInputStream}\n\n有时候，应用软件可能需要㲃理所有可支持的 JSON 编码。`AutoUTFInputStream` 会先使用 BOM 来检测编码。若 BOM 不存在，它便会使用合法 JSON 的特性来检测。若两种方法都失败，它就会倒退至构造函数提供的 UTF 类型。\n\n由于字符（编码单元／code unit）可能是 8 位、16 位或 32 位，`AutoUTFInputStream` 需要一个能至少储存 32 位的字符类型。我们可以使用 `unsigned` 作为模板参数：\n\n~~~~~~~~~~cpp\n#include \"rapidjson/document.h\"\n#include \"rapidjson/filereadstream.h\"   // FileReadStream\n#include \"rapidjson/encodedstream.h\"    // AutoUTFInputStream\n#include <cstdio>\n\nusing namespace rapidjson;\n\nFILE* fp = fopen(\"any.json\", \"rb\"); // 非 Windows 平台使用 \"r\"\n\nchar readBuffer[256];\nFileReadStream bis(fp, readBuffer, sizeof(readBuffer));\n\nAutoUTFInputStream<unsigned, FileReadStream> eis(bis);  // 用 eis 包装 bis\n\nDocument d;         // Document 为 GenericDocument<UTF8<> > \nd.ParseStream<0, AutoUTF<unsigned> >(eis); // 把任何 UTF 编码的文件解析至内存中的 UTF-8\n\nfclose(fp);\n~~~~~~~~~~\n\n当要指定流的编码，可使用上面例子中 `ParseStream()` 的参数 `AutoUTF<CharType>`。\n\n你可以使用 `UTFType GetType()` 去获取 UTF 类型，并且用 `HasBOM()` 检测输入流是否含有 BOM。\n\n## AutoUTFOutputStream {#AutoUTFOutputStream}\n\n相似地，要在运行时选择输出的编码，我们可使用 `AutoUTFOutputStream`。这个类本身并非「自动」。你需要在运行时指定 UTF 类型，以及是否写入 BOM。\n\n~~~~~~~~~~cpp\nusing namespace rapidjson;\n\nvoid WriteJSONFile(FILE* fp, UTFType type, bool putBOM, const Document& d) {\n    char writeBuffer[256];\n    FileWriteStream bos(fp, writeBuffer, sizeof(writeBuffer));\n\n    typedef AutoUTFOutputStream<unsigned, FileWriteStream> OutputStream;\n    OutputStream eos(bos, type, putBOM);\n    \n    Writer<OutputStream, UTF8<>, AutoUTF<> > writer;\n    d.Accept(writer);\n}\n~~~~~~~~~~\n\n`AutoUTFInputStream`／`AutoUTFOutputStream` 是比 `EncodedInputStream`／`EncodedOutputStream` 方便。但前者会产生一点运行期额外开销。\n\n# 自定义流 {#CustomStream}\n\n除了内存／文件流，使用者可创建自行定义适配 RapidJSON API 的流类。例如，你可以创建网络流、从压缩文件读取的流等等。\n\nRapidJSON 利用模板结合不同的类型。只要一个类包含所有所需的接口，就可以作为一个流。流的接合定义在 `rapidjson/rapidjson.h` 的注释里：\n\n~~~~~~~~~~cpp\nconcept Stream {\n    typename Ch;    //!< 流的字符类型\n\n    //! 从流读取当前字符，不移动读取指针（read cursor）\n    Ch Peek() const;\n\n    //! 从流读取当前字符，移动读取指针至下一字符。\n    Ch Take();\n\n    //! 获取读取指针。\n    //! \\return 从开始以来所读过的字符数量。\n    size_t Tell();\n\n    //! 从当前读取指针开始写入操作。\n    //! \\return 返回开始写入的指针。\n    Ch* PutBegin();\n\n    //! 写入一个字符。\n    void Put(Ch c);\n\n    //! 清空缓冲区。\n    void Flush();\n\n    //! 完成写作操作。\n    //! \\param begin PutBegin() 返回的开始写入指针。\n    //! \\return 已写入的字符数量。\n    size_t PutEnd(Ch* begin);\n}\n~~~~~~~~~~\n\n输入流必须实现 `Peek()`、`Take()` 及 `Tell()`。\n输出流必须实现 `Put()` 及 `Flush()`。\n`PutBegin()` 及 `PutEnd()` 是特殊的接口，仅用于原位（*in situ*）解析。一般的流不需实现它们。然而，即使接口不需用于某些流，仍然需要提供空实现，否则会产生编译错误。\n\n## 例子：istream 的包装类 {#ExampleIStreamWrapper}\n\n以下的简单例子是 `std::istream` 的包装类，它只需现 3 个函数。\n\n~~~~~~~~~~cpp\nclass MyIStreamWrapper {\npublic:\n    typedef char Ch;\n\n    MyIStreamWrapper(std::istream& is) : is_(is) {\n    }\n\n    Ch Peek() const { // 1\n        int c = is_.peek();\n        return c == std::char_traits<char>::eof() ? '\\0' : (Ch)c;\n    }\n\n    Ch Take() { // 2\n        int c = is_.get();\n        return c == std::char_traits<char>::eof() ? '\\0' : (Ch)c;\n    }\n\n    size_t Tell() const { return (size_t)is_.tellg(); } // 3\n\n    Ch* PutBegin() { assert(false); return 0; }\n    void Put(Ch) { assert(false); }\n    void Flush() { assert(false); }\n    size_t PutEnd(Ch*) { assert(false); return 0; }\n\nprivate:\n    MyIStreamWrapper(const MyIStreamWrapper&);\n    MyIStreamWrapper& operator=(const MyIStreamWrapper&);\n\n    std::istream& is_;\n};\n~~~~~~~~~~\n\n使用者能用它来包装 `std::stringstream`、`std::ifstream` 的实例。\n\n~~~~~~~~~~cpp\nconst char* json = \"[1,2,3,4]\";\nstd::stringstream ss(json);\nMyIStreamWrapper is(ss);\n\nDocument d;\nd.ParseStream(is);\n~~~~~~~~~~\n\n但要注意，由于标准库的内部开销问，此实现的性能可能不如 RapidJSON 的内存／文件流。\n\n## 例子：ostream 的包装类 {#ExampleOStreamWrapper}\n\n以下的例子是 `std::istream` 的包装类，它只需实现 2 个函数。\n\n~~~~~~~~~~cpp\nclass MyOStreamWrapper {\npublic:\n    typedef char Ch;\n\n    OStreamWrapper(std::ostream& os) : os_(os) {\n    }\n\n    Ch Peek() const { assert(false); return '\\0'; }\n    Ch Take() { assert(false); return '\\0'; }\n    size_t Tell() const {  }\n\n    Ch* PutBegin() { assert(false); return 0; }\n    void Put(Ch c) { os_.put(c); }                  // 1\n    void Flush() { os_.flush(); }                   // 2\n    size_t PutEnd(Ch*) { assert(false); return 0; }\n\nprivate:\n    MyOStreamWrapper(const MyOStreamWrapper&);\n    MyOStreamWrapper& operator=(const MyOStreamWrapper&);\n\n    std::ostream& os_;\n};\n~~~~~~~~~~\n\n使用者能用它来包装 `std::stringstream`、`std::ofstream` 的实例。\n\n~~~~~~~~~~cpp\nDocument d;\n// ...\n\nstd::stringstream ss;\nMyOStreamWrapper os(ss);\n\nWriter<MyOStreamWrapper> writer(os);\nd.Accept(writer);\n~~~~~~~~~~\n\n但要注意，由于标准库的内部开销问，此实现的性能可能不如 RapidJSON 的内存／文件流。\n\n# 总结 {#Summary}\n\n本节描述了 RapidJSON 提供的各种流的类。内存流很简单。若 JSON 存储在文件中，文件流可减少 JSON 解析及生成所需的内存量。编码流在字节流和字符流之间作转换。最后，使用者可使用一个简单接口创建自定义的流。\n"
  },
  {
    "path": "ext/rapidjson/doc/tutorial.md",
    "content": "# Tutorial\n\nThis tutorial introduces the basics of the Document Object Model(DOM) API.\n\nAs shown in [Usage at a glance](@ref index), a JSON can be parsed into DOM, and then the DOM can be queried and modified easily, and finally be converted back to JSON.\n\n[TOC]\n\n# Value & Document {#ValueDocument}\n\nEach JSON value is stored in a type called `Value`. A `Document`, representing the DOM, contains the root `Value` of the DOM tree. All public types and functions of RapidJSON are defined in the `rapidjson` namespace.\n\n# Query Value {#QueryValue}\n\nIn this section, we will use excerpt of `example/tutorial/tutorial.cpp`.\n\nAssumes we have a JSON stored in a C string (`const char* json`):\n~~~~~~~~~~js\n{\n    \"hello\": \"world\",\n    \"t\": true ,\n    \"f\": false,\n    \"n\": null,\n    \"i\": 123,\n    \"pi\": 3.1416,\n    \"a\": [1, 2, 3, 4]\n}\n~~~~~~~~~~\n\nParse it into a `Document`:\n~~~~~~~~~~cpp\n#include \"rapidjson/document.h\"\n\nusing namespace rapidjson;\n\n// ...\nDocument document;\ndocument.Parse(json);\n~~~~~~~~~~\n\nThe JSON is now parsed into `document` as a *DOM tree*:\n\n![DOM in the tutorial](diagram/tutorial.png)\n\nSince the update to RFC 7159, the root of a conforming JSON document can be any JSON value.  In earlier RFC 4627, only objects or arrays were allowed as root values. In this case, the root is an object.\n~~~~~~~~~~cpp\nassert(document.IsObject());\n~~~~~~~~~~\n\nLet's query whether a `\"hello\"` member exists in the root object. Since a `Value` can contain different types of value, we may need to verify its type and use suitable API to obtain the value. In this example, `\"hello\"` member associates with a JSON string.\n~~~~~~~~~~cpp\nassert(document.HasMember(\"hello\"));\nassert(document[\"hello\"].IsString());\nprintf(\"hello = %s\\n\", document[\"hello\"].GetString());\n~~~~~~~~~~\n\n~~~~~~~~~~\nworld\n~~~~~~~~~~\n\nJSON true/false values are represented as `bool`.\n~~~~~~~~~~cpp\nassert(document[\"t\"].IsBool());\nprintf(\"t = %s\\n\", document[\"t\"].GetBool() ? \"true\" : \"false\");\n~~~~~~~~~~\n\n~~~~~~~~~~\ntrue\n~~~~~~~~~~\n\nJSON null can be queryed by `IsNull()`.\n~~~~~~~~~~cpp\nprintf(\"n = %s\\n\", document[\"n\"].IsNull() ? \"null\" : \"?\");\n~~~~~~~~~~\n\n~~~~~~~~~~\nnull\n~~~~~~~~~~\n\nJSON number type represents all numeric values. However, C++ needs more specific type for manipulation.\n\n~~~~~~~~~~cpp\nassert(document[\"i\"].IsNumber());\n\n// In this case, IsUint()/IsInt64()/IsUInt64() also return true.\nassert(document[\"i\"].IsInt());          \nprintf(\"i = %d\\n\", document[\"i\"].GetInt());\n// Alternative (int)document[\"i\"]\n\nassert(document[\"pi\"].IsNumber());\nassert(document[\"pi\"].IsDouble());\nprintf(\"pi = %g\\n\", document[\"pi\"].GetDouble());\n~~~~~~~~~~\n\n~~~~~~~~~~\ni = 123\npi = 3.1416\n~~~~~~~~~~\n\nJSON array contains a number of elements.\n~~~~~~~~~~cpp\n// Using a reference for consecutive access is handy and faster.\nconst Value& a = document[\"a\"];\nassert(a.IsArray());\nfor (SizeType i = 0; i < a.Size(); i++) // Uses SizeType instead of size_t\n        printf(\"a[%d] = %d\\n\", i, a[i].GetInt());\n~~~~~~~~~~\n\n~~~~~~~~~~\na[0] = 1\na[1] = 2\na[2] = 3\na[3] = 4\n~~~~~~~~~~\n\nNote that, RapidJSON does not automatically convert values between JSON types. If a value is a string, it is invalid to call `GetInt()`, for example. In debug mode it will fail an assertion. In release mode, the behavior is undefined.\n\nIn the following, details about querying individual types are discussed.\n\n## Query Array {#QueryArray}\n\nBy default, `SizeType` is typedef of `unsigned`. In most systems, array is limited to store up to 2^32-1 elements.\n\nYou may access the elements in array by integer literal, for example, `a[0]`, `a[1]`, `a[2]`.\n\nArray is similar to `std::vector`, instead of using indices, you may also use iterator to access all the elements.\n~~~~~~~~~~cpp\nfor (Value::ConstValueIterator itr = a.Begin(); itr != a.End(); ++itr)\n    printf(\"%d \", itr->GetInt());\n~~~~~~~~~~\n\nAnd other familiar query functions:\n* `SizeType Capacity() const`\n* `bool Empty() const`\n\n### Range-based For Loop (New in v1.1.0)\n\nWhen C++11 is enabled, you can use range-based for loop to access all elements in an array.\n\n~~~~~~~~~~cpp\nfor (auto& v : a.GetArray())\n    printf(\"%d \", v.GetInt());\n~~~~~~~~~~\n\n## Query Object {#QueryObject}\n\nSimilar to array, we can access all object members by iterator:\n\n~~~~~~~~~~cpp\nstatic const char* kTypeNames[] = \n    { \"Null\", \"False\", \"True\", \"Object\", \"Array\", \"String\", \"Number\" };\n\nfor (Value::ConstMemberIterator itr = document.MemberBegin();\n    itr != document.MemberEnd(); ++itr)\n{\n    printf(\"Type of member %s is %s\\n\",\n        itr->name.GetString(), kTypeNames[itr->value.GetType()]);\n}\n~~~~~~~~~~\n\n~~~~~~~~~~\nType of member hello is String\nType of member t is True\nType of member f is False\nType of member n is Null\nType of member i is Number\nType of member pi is Number\nType of member a is Array\n~~~~~~~~~~\n\nNote that, when `operator[](const char*)` cannot find the member, it will fail an assertion.\n\nIf we are unsure whether a member exists, we need to call `HasMember()` before calling `operator[](const char*)`. However, this incurs two lookup. A better way is to call `FindMember()`, which can check the existence of member and obtain its value at once:\n\n~~~~~~~~~~cpp\nValue::ConstMemberIterator itr = document.FindMember(\"hello\");\nif (itr != document.MemberEnd())\n    printf(\"%s\\n\", itr->value.GetString());\n~~~~~~~~~~\n\n### Range-based For Loop (New in v1.1.0)\n\nWhen C++11 is enabled, you can use range-based for loop to access all members in an object.\n\n~~~~~~~~~~cpp\nfor (auto& m : document.GetObject())\n    printf(\"Type of member %s is %s\\n\",\n        m.name.GetString(), kTypeNames[m.value.GetType()]);\n~~~~~~~~~~\n\n## Querying Number {#QueryNumber}\n\nJSON provide a single numerical type called Number. Number can be integer or real numbers. RFC 4627 says the range of Number is specified by parser.\n\nAs C++ provides several integer and floating point number types, the DOM tries to handle these with widest possible range and good performance.\n\nWhen a Number is parsed, it is stored in the DOM as either one of the following type:\n\nType       | Description\n-----------|---------------------------------------\n`unsigned` | 32-bit unsigned integer\n`int`      | 32-bit signed integer\n`uint64_t` | 64-bit unsigned integer\n`int64_t`  | 64-bit signed integer\n`double`   | 64-bit double precision floating point\n\nWhen querying a number, you can check whether the number can be obtained as target type:\n\nChecking          | Obtaining\n------------------|---------------------\n`bool IsNumber()` | N/A\n`bool IsUint()`   | `unsigned GetUint()`\n`bool IsInt()`    | `int GetInt()`\n`bool IsUint64()` | `uint64_t GetUint64()`\n`bool IsInt64()`  | `int64_t GetInt64()`\n`bool IsDouble()` | `double GetDouble()`\n\nNote that, an integer value may be obtained in various ways without conversion. For example, A value `x` containing 123 will make `x.IsInt() == x.IsUint() == x.IsInt64() == x.IsUint64() == true`. But a value `y` containing -3000000000 will only makes `x.IsInt64() == true`.\n\nWhen obtaining the numeric values, `GetDouble()` will convert internal integer representation to a `double`. Note that, `int` and `unsigned` can be safely convert to `double`, but `int64_t` and `uint64_t` may lose precision (since mantissa of `double` is only 52-bits).\n\n## Query String {#QueryString}\n\nIn addition to `GetString()`, the `Value` class also contains `GetStringLength()`. Here explains why.\n\nAccording to RFC 4627, JSON strings can contain Unicode character `U+0000`, which must be escaped as `\"\\u0000\"`. The problem is that, C/C++ often uses null-terminated string, which treats ``\\0'` as the terminator symbol.\n\nTo conform RFC 4627, RapidJSON supports string containing `U+0000`. If you need to handle this, you can use `GetStringLength()` API to obtain the correct length of string.\n\nFor example, after parsing a the following JSON to `Document d`:\n\n~~~~~~~~~~js\n{ \"s\" :  \"a\\u0000b\" }\n~~~~~~~~~~\nThe correct length of the value `\"a\\u0000b\"` is 3. But `strlen()` returns 1.\n\n`GetStringLength()` can also improve performance, as user may often need to call `strlen()` for allocating buffer.\n\nBesides, `std::string` also support a constructor:\n\n~~~~~~~~~~cpp\nstring(const char* s, size_t count);\n~~~~~~~~~~\n\nwhich accepts the length of string as parameter. This constructor supports storing null character within the string, and should also provide better performance.\n\n## Comparing values\n\nYou can use `==` and `!=` to compare values. Two values are equal if and only if they are have same type and contents. You can also compare values with primitive types. Here is an example.\n\n~~~~~~~~~~cpp\nif (document[\"hello\"] == document[\"n\"]) /*...*/;    // Compare values\nif (document[\"hello\"] == \"world\") /*...*/;          // Compare value with literal string\nif (document[\"i\"] != 123) /*...*/;                  // Compare with integers\nif (document[\"pi\"] != 3.14) /*...*/;                // Compare with double.\n~~~~~~~~~~\n\nArray/object compares their elements/members in order. They are equal if and only if their whole subtrees are equal.\n\nNote that, currently if an object contains duplicated named member, comparing equality with any object is always `false`.\n\n# Create/Modify Values {#CreateModifyValues}\n\nThere are several ways to create values. After a DOM tree is created and/or modified, it can be saved as JSON again using `Writer`.\n\n## Change Value Type {#ChangeValueType}\nWhen creating a Value or Document by default constructor, its type is Null. To change its type, call `SetXXX()` or assignment operator, for example:\n\n~~~~~~~~~~cpp\nDocument d; // Null\nd.SetObject();\n\nValue v;    // Null\nv.SetInt(10);\nv = 10;     // Shortcut, same as above\n~~~~~~~~~~\n\n### Overloaded Constructors\nThere are also overloaded constructors for several types:\n\n~~~~~~~~~~cpp\nValue b(true);    // calls Value(bool)\nValue i(-123);    // calls Value(int)\nValue u(123u);    // calls Value(unsigned)\nValue d(1.5);     // calls Value(double)\n~~~~~~~~~~\n\nTo create empty object or array, you may use `SetObject()`/`SetArray()` after default constructor, or using the `Value(Type)` in one shot:\n\n~~~~~~~~~~cpp\nValue o(kObjectType);\nValue a(kArrayType);\n~~~~~~~~~~\n\n## Move Semantics {#MoveSemantics}\n\nA very special decision during design of RapidJSON is that, assignment of value does not copy the source value to destination value. Instead, the value from source is moved to the destination. For example,\n\n~~~~~~~~~~cpp\nValue a(123);\nValue b(456);\nb = a;         // a becomes a Null value, b becomes number 123.\n~~~~~~~~~~\n\n![Assignment with move semantics.](diagram/move1.png)\n\nWhy? What is the advantage of this semantics?\n\nThe simple answer is performance. For fixed size JSON types (Number, True, False, Null), copying them is fast and easy. However, For variable size JSON types (String, Array, Object), copying them will incur a lot of overheads. And these overheads are often unnoticed. Especially when we need to create temporary object, copy it to another variable, and then destruct it.\n\nFor example, if normal *copy* semantics was used:\n\n~~~~~~~~~~cpp\nDocument d;\nValue o(kObjectType);\n{\n    Value contacts(kArrayType);\n    // adding elements to contacts array.\n    // ...\n    o.AddMember(\"contacts\", contacts, d.GetAllocator());  // deep clone contacts (may be with lots of allocations)\n    // destruct contacts.\n}\n~~~~~~~~~~\n\n![Copy semantics makes a lots of copy operations.](diagram/move2.png)\n\nThe object `o` needs to allocate a buffer of same size as contacts, makes a deep clone of it, and then finally contacts is destructed. This will incur a lot of unnecessary allocations/deallocations and memory copying.\n\nThere are solutions to prevent actual copying these data, such as reference counting and garbage collection(GC).\n\nTo make RapidJSON simple and fast, we chose to use *move* semantics for assignment. It is similar to `std::auto_ptr` which transfer ownership during assignment. Move is much faster and simpler, it just destructs the original value, `memcpy()` the source to destination, and finally sets the source as Null type.\n\nSo, with move semantics, the above example becomes:\n\n~~~~~~~~~~cpp\nDocument d;\nValue o(kObjectType);\n{\n    Value contacts(kArrayType);\n    // adding elements to contacts array.\n    o.AddMember(\"contacts\", contacts, d.GetAllocator());  // just memcpy() of contacts itself to the value of new member (16 bytes)\n    // contacts became Null here. Its destruction is trivial.\n}\n~~~~~~~~~~\n\n![Move semantics makes no copying.](diagram/move3.png)\n\nThis is called move assignment operator in C++11. As RapidJSON supports C++03, it adopts move semantics using assignment operator, and all other modifying function like `AddMember()`, `PushBack()`.\n\n### Move semantics and temporary values {#TemporaryValues}\n\nSometimes, it is convenient to construct a Value in place, before passing it to one of the \"moving\" functions, like `PushBack()` or `AddMember()`.  As temporary objects can't be converted to proper Value references, the convenience function `Move()` is available:\n\n~~~~~~~~~~cpp\nValue a(kArrayType);\nDocument::AllocatorType& allocator = document.GetAllocator();\n// a.PushBack(Value(42), allocator);       // will not compile\na.PushBack(Value().SetInt(42), allocator); // fluent API\na.PushBack(Value(42).Move(), allocator);   // same as above\n~~~~~~~~~~\n\n## Create String {#CreateString}\nRapidJSON provide two strategies for storing string.\n\n1. copy-string: allocates a buffer, and then copy the source data into it.\n2. const-string: simply store a pointer of string.\n\nCopy-string is always safe because it owns a copy of the data. Const-string can be used for storing string literal, and in-situ parsing which we will mentioned in Document section.\n\nTo make memory allocation customizable, RapidJSON requires user to pass an instance of allocator, whenever an operation may require allocation. This design is needed to prevent storing a allocator (or Document) pointer per Value.\n\nTherefore, when we assign a copy-string, we call this overloaded `SetString()` with allocator:\n\n~~~~~~~~~~cpp\nDocument document;\nValue author;\nchar buffer[10];\nint len = sprintf(buffer, \"%s %s\", \"Milo\", \"Yip\"); // dynamically created string.\nauthor.SetString(buffer, len, document.GetAllocator());\nmemset(buffer, 0, sizeof(buffer));\n// author.GetString() still contains \"Milo Yip\" after buffer is destroyed\n~~~~~~~~~~\n\nIn this example, we get the allocator from a `Document` instance. This is a common idiom when using RapidJSON. But you may use other instances of allocator.\n\nBesides, the above `SetString()` requires length. This can handle null characters within a string. There is another `SetString()` overloaded function without the length parameter. And it assumes the input is null-terminated and calls a `strlen()`-like function to obtain the length.\n\nFinally, for string literal or string with safe life-cycle can use const-string version of `SetString()`, which lacks allocator parameter.  For string literals (or constant character arrays), simply passing the literal as parameter is safe and efficient:\n\n~~~~~~~~~~cpp\nValue s;\ns.SetString(\"rapidjson\");    // can contain null character, length derived at compile time\ns = \"rapidjson\";             // shortcut, same as above\n~~~~~~~~~~\n\nFor character pointer, the RapidJSON requires to mark it as safe before using it without copying. This can be achieved by using the `StringRef` function:\n\n~~~~~~~~~cpp\nconst char * cstr = getenv(\"USER\");\nsize_t cstr_len = ...;                 // in case length is available\nValue s;\n// s.SetString(cstr);                  // will not compile\ns.SetString(StringRef(cstr));          // ok, assume safe lifetime, null-terminated\ns = StringRef(cstr);                   // shortcut, same as above\ns.SetString(StringRef(cstr,cstr_len)); // faster, can contain null character\ns = StringRef(cstr,cstr_len);          // shortcut, same as above\n\n~~~~~~~~~\n\n## Modify Array {#ModifyArray}\nValue with array type provides similar APIs as `std::vector`.\n\n* `Clear()`\n* `Reserve(SizeType, Allocator&)`\n* `Value& PushBack(Value&, Allocator&)`\n* `template <typename T> GenericValue& PushBack(T, Allocator&)`\n* `Value& PopBack()`\n* `ValueIterator Erase(ConstValueIterator pos)`\n* `ValueIterator Erase(ConstValueIterator first, ConstValueIterator last)`\n\nNote that, `Reserve(...)` and `PushBack(...)` may allocate memory for the array elements, therefore require an allocator.\n\nHere is an example of `PushBack()`:\n\n~~~~~~~~~~cpp\nValue a(kArrayType);\nDocument::AllocatorType& allocator = document.GetAllocator();\n\nfor (int i = 5; i <= 10; i++)\n    a.PushBack(i, allocator);   // allocator is needed for potential realloc().\n\n// Fluent interface\na.PushBack(\"Lua\", allocator).PushBack(\"Mio\", allocator);\n~~~~~~~~~~\n\nDiffers from STL, `PushBack()`/`PopBack()` returns the array reference itself. This is called _fluent interface_.\n\nIf you want to add a non-constant string or a string without sufficient lifetime (see [Create String](#CreateString)) to the array, you need to create a string Value by using the copy-string API.  To avoid the need for an intermediate variable, you can use a [temporary value](#TemporaryValues) in place:\n\n~~~~~~~~~~cpp\n// in-place Value parameter\ncontact.PushBack(Value(\"copy\", document.GetAllocator()).Move(), // copy string\n                 document.GetAllocator());\n\n// explicit parameters\nValue val(\"key\", document.GetAllocator()); // copy string\ncontact.PushBack(val, document.GetAllocator());\n~~~~~~~~~~\n\n## Modify Object {#ModifyObject}\nObject is a collection of key-value pairs (members). Each key must be a string value. To modify an object, either add or remove members. THe following APIs are for adding members:\n\n* `Value& AddMember(Value&, Value&, Allocator& allocator)`\n* `Value& AddMember(StringRefType, Value&, Allocator&)`\n* `template <typename T> Value& AddMember(StringRefType, T value, Allocator&)`\n\nHere is an example.\n\n~~~~~~~~~~cpp\nValue contact(kObject);\ncontact.AddMember(\"name\", \"Milo\", document.GetAllocator());\ncontact.AddMember(\"married\", true, document.GetAllocator());\n~~~~~~~~~~\n\nThe name parameter with `StringRefType` is similar to the interface of `SetString` function for string values. These overloads are used to avoid the need for copying the `name` string, as constant key names are very common in JSON objects.\n\nIf you need to create a name from a non-constant string or a string without sufficient lifetime (see [Create String](#CreateString)), you need to create a string Value by using the copy-string API.  To avoid the need for an intermediate variable, you can use a [temporary value](#TemporaryValues) in place:\n\n~~~~~~~~~~cpp\n// in-place Value parameter\ncontact.AddMember(Value(\"copy\", document.GetAllocator()).Move(), // copy string\n                  Value().Move(),                                // null value\n                  document.GetAllocator());\n\n// explicit parameters\nValue key(\"key\", document.GetAllocator()); // copy string name\nValue val(42);                             // some value\ncontact.AddMember(key, val, document.GetAllocator());\n~~~~~~~~~~\n\nFor removing members, there are several choices: \n\n* `bool RemoveMember(const Ch* name)`: Remove a member by search its name (linear time complexity).\n* `bool RemoveMember(const Value& name)`: same as above but `name` is a Value.\n* `MemberIterator RemoveMember(MemberIterator)`: Remove a member by iterator (_constant_ time complexity).\n* `MemberIterator EraseMember(MemberIterator)`: similar to the above but it preserves order of members (linear time complexity).\n* `MemberIterator EraseMember(MemberIterator first, MemberIterator last)`: remove a range of members, preserves order (linear time complexity).\n\n`MemberIterator RemoveMember(MemberIterator)` uses a \"move-last\" trick to achieve constant time complexity. Basically the member at iterator is destructed, and then the last element is moved to that position. So the order of the remaining members are changed.\n\n## Deep Copy Value {#DeepCopyValue}\nIf we really need to copy a DOM tree, we can use two APIs for deep copy: constructor with allocator, and `CopyFrom()`.\n\n~~~~~~~~~~cpp\nDocument d;\nDocument::AllocatorType& a = d.GetAllocator();\nValue v1(\"foo\");\n// Value v2(v1); // not allowed\n\nValue v2(v1, a);                      // make a copy\nassert(v1.IsString());                // v1 untouched\nd.SetArray().PushBack(v1, a).PushBack(v2, a);\nassert(v1.IsNull() && v2.IsNull());   // both moved to d\n\nv2.CopyFrom(d, a);                    // copy whole document to v2\nassert(d.IsArray() && d.Size() == 2); // d untouched\nv1.SetObject().AddMember(\"array\", v2, a);\nd.PushBack(v1, a);\n~~~~~~~~~~\n\n## Swap Values {#SwapValues}\n\n`Swap()` is also provided.\n\n~~~~~~~~~~cpp\nValue a(123);\nValue b(\"Hello\");\na.Swap(b);\nassert(a.IsString());\nassert(b.IsInt());\n~~~~~~~~~~\n\nSwapping two DOM trees is fast (constant time), despite the complexity of the trees.\n\n# What's next {#WhatsNext}\n\nThis tutorial shows the basics of DOM tree query and manipulation. There are several important concepts in RapidJSON:\n\n1. [Streams](doc/stream.md) are channels for reading/writing JSON, which can be a in-memory string, or file stream, etc. User can also create their streams.\n2. [Encoding](doc/encoding.md) defines which character encoding is used in streams and memory. RapidJSON also provide Unicode conversion/validation internally.\n3. [DOM](doc/dom.md)'s basics are already covered in this tutorial. Uncover more advanced features such as *in situ* parsing, other parsing options and advanced usages.\n4. [SAX](doc/sax.md) is the foundation of parsing/generating facility in RapidJSON. Learn how to use `Reader`/`Writer` to implement even faster applications. Also try `PrettyWriter` to format the JSON.\n5. [Performance](doc/performance.md) shows some in-house and third-party benchmarks.\n6. [Internals](doc/internals.md) describes some internal designs and techniques of RapidJSON.\n\nYou may also refer to the [FAQ](doc/faq.md), API documentation, examples and unit tests.\n"
  },
  {
    "path": "ext/rapidjson/doc/tutorial.zh-cn.md",
    "content": "# 教程\n\n本教程简介文件对象模型（Document Object Model, DOM）API。\n\n如 [用法一览](../readme.zh-cn.md#用法一览) 中所示，可以解析一个 JSON 至 DOM，然后就可以轻松查询及修改 DOM，并最终转换回 JSON。\n\n[TOC]\n\n# Value 及 Document {#ValueDocument}\n\n每个 JSON 值都储存为 `Value` 类，而 `Document` 类则表示整个 DOM，它存储了一个 DOM 树的根 `Value`。RapidJSON 的所有公开类型及函数都在 `rapidjson` 命名空间中。\n\n# 查询 Value {#QueryValue}\n\n在本节中，我们会使用到 `example/tutorial/tutorial.cpp` 中的代码片段。\n\n假设我们用 C 语言的字符串储存一个 JSON（`const char* json`）：\n~~~~~~~~~~js\n{\n    \"hello\": \"world\",\n    \"t\": true ,\n    \"f\": false,\n    \"n\": null,\n    \"i\": 123,\n    \"pi\": 3.1416,\n    \"a\": [1, 2, 3, 4]\n}\n~~~~~~~~~~\n\n把它解析至一个 `Document`：\n~~~~~~~~~~cpp\n#include \"rapidjson/document.h\"\n\nusing namespace rapidjson;\n\n// ...\nDocument document;\ndocument.Parse(json);\n~~~~~~~~~~\n\n那么现在该 JSON 就会被解析至 `document` 中，成为一棵 *DOM 树 *:\n\n![教程中的 DOM](diagram/tutorial.png)\n\n自从 RFC 7159 作出更新，合法 JSON 文件的根可以是任何类型的 JSON 值。而在较早的 RFC 4627 中，根值只允许是 Object 或 Array。而在上述例子中，根是一个 Object。\n~~~~~~~~~~cpp\nassert(document.IsObject());\n~~~~~~~~~~\n\n让我们查询一下根 Object 中有没有 `\"hello\"` 成员。由于一个 `Value` 可包含不同类型的值，我们可能需要验证它的类型，并使用合适的 API 去获取其值。在此例中，`\"hello\"` 成员关联到一个 JSON String。\n~~~~~~~~~~cpp\nassert(document.HasMember(\"hello\"));\nassert(document[\"hello\"].IsString());\nprintf(\"hello = %s\\n\", document[\"hello\"].GetString());\n~~~~~~~~~~\n\n~~~~~~~~~~\nworld\n~~~~~~~~~~\n\nJSON True/False 值是以 `bool` 表示的。\n~~~~~~~~~~cpp\nassert(document[\"t\"].IsBool());\nprintf(\"t = %s\\n\", document[\"t\"].GetBool() ? \"true\" : \"false\");\n~~~~~~~~~~\n\n~~~~~~~~~~\ntrue\n~~~~~~~~~~\n\nJSON Null 值可用 `IsNull()` 查询。\n~~~~~~~~~~cpp\nprintf(\"n = %s\\n\", document[\"n\"].IsNull() ? \"null\" : \"?\");\n~~~~~~~~~~\n\n~~~~~~~~~~\nnull\n~~~~~~~~~~\n\nJSON Number 类型表示所有数值。然而，C++ 需要使用更专门的类型。\n\n~~~~~~~~~~cpp\nassert(document[\"i\"].IsNumber());\n\n// 在此情况下，IsUint()/IsInt64()/IsUInt64() 也会返回 true\nassert(document[\"i\"].IsInt());          \nprintf(\"i = %d\\n\", document[\"i\"].GetInt());\n// 另一种用法： (int)document[\"i\"]\n\nassert(document[\"pi\"].IsNumber());\nassert(document[\"pi\"].IsDouble());\nprintf(\"pi = %g\\n\", document[\"pi\"].GetDouble());\n~~~~~~~~~~\n\n~~~~~~~~~~\ni = 123\npi = 3.1416\n~~~~~~~~~~\n\nJSON Array 包含一些元素。\n~~~~~~~~~~cpp\n// 使用引用来连续访问，方便之余还更高效。\nconst Value& a = document[\"a\"];\nassert(a.IsArray());\nfor (SizeType i = 0; i < a.Size(); i++) // 使用 SizeType 而不是 size_t\n        printf(\"a[%d] = %d\\n\", i, a[i].GetInt());\n~~~~~~~~~~\n\n~~~~~~~~~~\na[0] = 1\na[1] = 2\na[2] = 3\na[3] = 4\n~~~~~~~~~~\n\n注意，RapidJSON 并不自动转换各种 JSON 类型。例如，对一个 String 的 Value 调用 `GetInt()` 是非法的。在调试模式下，它会被断言失败。在发布模式下，其行为是未定义的。\n\n以下将会讨论有关查询各类型的细节。\n\n## 查询 Array {#QueryArray}\n\n缺省情况下，`SizeType` 是 `unsigned` 的 typedef。在多数系统中，Array 最多能存储 2^32-1 个元素。\n\n你可以用整数字面量访问元素，如 `a[0]`、`a[1]`、`a[2]`。\n\nArray 与 `std::vector` 相似，除了使用索引，也可使用迭代器来访问所有元素。\n~~~~~~~~~~cpp\nfor (Value::ConstValueIterator itr = a.Begin(); itr != a.End(); ++itr)\n    printf(\"%d \", itr->GetInt());\n~~~~~~~~~~\n\n还有一些熟悉的查询函数：\n* `SizeType Capacity() const`\n* `bool Empty() const`\n\n### 范围 for 循环 (v1.1.0 中的新功能)\n\n当使用 C++11 功能时，你可使用范围 for 循环去访问 Array 内的所有元素。\n\n~~~~~~~~~~cpp\nfor (auto& v : a.GetArray())\n    printf(\"%d \", v.GetInt());\n~~~~~~~~~~\n\n## 查询 Object {#QueryObject}\n\n和 Array 相似，我们可以用迭代器去访问所有 Object 成员：\n\n~~~~~~~~~~cpp\nstatic const char* kTypeNames[] = \n    { \"Null\", \"False\", \"True\", \"Object\", \"Array\", \"String\", \"Number\" };\n\nfor (Value::ConstMemberIterator itr = document.MemberBegin();\n    itr != document.MemberEnd(); ++itr)\n{\n    printf(\"Type of member %s is %s\\n\",\n        itr->name.GetString(), kTypeNames[itr->value.GetType()]);\n}\n~~~~~~~~~~\n\n~~~~~~~~~~\nType of member hello is String\nType of member t is True\nType of member f is False\nType of member n is Null\nType of member i is Number\nType of member pi is Number\nType of member a is Array\n~~~~~~~~~~\n\n注意，当 `operator[](const char*)` 找不到成员，它会断言失败。\n\n若我们不确定一个成员是否存在，便需要在调用 `operator[](const char*)` 前先调用 `HasMember()`。然而，这会导致两次查找。更好的做法是调用 `FindMember()`，它能同时检查成员是否存在并返回它的 Value：\n\n~~~~~~~~~~cpp\nValue::ConstMemberIterator itr = document.FindMember(\"hello\");\nif (itr != document.MemberEnd())\n    printf(\"%s\\n\", itr->value.GetString());\n~~~~~~~~~~\n\n### 范围 for 循环 (v1.1.0 中的新功能)\n\n当使用 C++11 功能时，你可使用范围 for 循环去访问 Object 内的所有成员。\n\n~~~~~~~~~~cpp\nfor (auto& m : document.GetObject())\n    printf(\"Type of member %s is %s\\n\",\n        m.name.GetString(), kTypeNames[m.value.GetType()]);\n~~~~~~~~~~\n\n## 查询 Number {#QueryNumber}\n\nJSON 只提供一种数值类型──Number。数字可以是整数或实数。RFC 4627 规定数字的范围由解析器指定。\n\n由于 C++ 提供多种整数及浮点数类型，DOM 尝试尽量提供最广的范围及良好性能。\n\n当解析一个 Number 时, 它会被存储在 DOM 之中，成为下列其中一个类型：\n\n类型       | 描述\n-----------|---------------------------------------\n`unsigned` | 32 位无号整数\n`int`      | 32 位有号整数\n`uint64_t` | 64 位无号整数\n`int64_t`  | 64 位有号整数\n`double`   | 64 位双精度浮点数\n\n当查询一个 Number 时, 你可以检查该数字是否能以目标类型来提取：\n\n查检              | 提取\n------------------|---------------------\n`bool IsNumber()` | 不适用\n`bool IsUint()`   | `unsigned GetUint()`\n`bool IsInt()`    | `int GetInt()`\n`bool IsUint64()` | `uint64_t GetUint64()`\n`bool IsInt64()`  | `int64_t GetInt64()`\n`bool IsDouble()` | `double GetDouble()`\n\n注意，一个整数可能用几种类型来提取，而无需转换。例如，一个名为 `x` 的 Value 包含 123，那么 `x.IsInt() == x.IsUint() == x.IsInt64() == x.IsUint64() == true`。但如果一个名为 `y` 的 Value 包含 -3000000000，那么仅会令 `x.IsInt64() == true`。\n\n当要提取 Number 类型，`GetDouble()` 是会把内部整数的表示转换成 `double`。注意 `int` 和 `unsigned` 可以安全地转换至 `double`，但 `int64_t` 及 `uint64_t` 可能会丧失精度（因为 `double` 的尾数只有 52 位）。\n\n## 查询 String {#QueryString}\n\n除了 `GetString()`，`Value` 类也有一个 `GetStringLength()`。这里会解释个中原因。\n\n根据 RFC 4627，JSON String 可包含 Unicode 字符 `U+0000`，在 JSON 中会表示为 `\"\\u0000\"`。问题是，C/C++ 通常使用空字符结尾字符串（null-terminated string），这种字符串把 ``\\0'` 作为结束符号。\n\n为了符合 RFC 4627，RapidJSON 支持包含 `U+0000` 的 String。若你需要处理这些 String，便可使用 `GetStringLength()` 去获得正确的字符串长度。\n\n例如，当解析以下的 JSON 至 `Document d` 之后：\n\n~~~~~~~~~~js\n{ \"s\" :  \"a\\u0000b\" }\n~~~~~~~~~~\n`\"a\\u0000b\"` 值的正确长度应该是 3。但 `strlen()` 会返回 1。\n\n`GetStringLength()` 也可以提高性能，因为用户可能需要调用 `strlen()` 去分配缓冲。\n\n此外，`std::string` 也支持这个构造函数：\n\n~~~~~~~~~~cpp\nstring(const char* s, size_t count);\n~~~~~~~~~~\n\n此构造函数接受字符串长度作为参数。它支持在字符串中存储空字符，也应该会有更好的性能。\n\n## 比较两个 Value\n\n你可使用 `==` 及 `!=` 去比较两个 Value。当且仅当两个 Value 的类型及内容相同，它们才当作相等。你也可以比较 Value 和它的原生类型值。以下是一个例子。\n\n~~~~~~~~~~cpp\nif (document[\"hello\"] == document[\"n\"]) /*...*/;    // 比较两个值\nif (document[\"hello\"] == \"world\") /*...*/;          // 与字符串家面量作比较\nif (document[\"i\"] != 123) /*...*/;                  // 与整数作比较\nif (document[\"pi\"] != 3.14) /*...*/;                // 与 double 作比较\n~~~~~~~~~~\n\nArray／Object 顺序以它们的元素／成员作比较。当且仅当它们的整个子树相等，它们才当作相等。\n\n注意，现时若一个 Object 含有重复命名的成员，它与任何 Object 作比较都总会返回 `false`。\n\n# 创建／修改值 {#CreateModifyValues}\n\n有多种方法去创建值。 当一个 DOM 树被创建或修改后，可使用 `Writer` 再次存储为 JSON。\n\n## 改变 Value 类型 {#ChangeValueType}\n当使用默认构造函数创建一个 Value 或 Document，它的类型便会是 Null。要改变其类型，需调用 `SetXXX()` 或赋值操作，例如：\n\n~~~~~~~~~~cpp\nDocument d; // Null\nd.SetObject();\n\nValue v;    // Null\nv.SetInt(10);\nv = 10;     // 简写，和上面的相同\n~~~~~~~~~~\n\n### 构造函数的各个重载\n几个类型也有重载构造函数：\n\n~~~~~~~~~~cpp\nValue b(true);    // 调用 Value(bool)\nValue i(-123);    // 调用 Value(int)\nValue u(123u);    // 调用 Value(unsigned)\nValue d(1.5);     // 调用 Value(double)\n~~~~~~~~~~\n\n要重建空 Object 或 Array，可在默认构造函数后使用 `SetObject()`/`SetArray()`，或一次性使用 `Value(Type)`：\n\n~~~~~~~~~~cpp\nValue o(kObjectType);\nValue a(kArrayType);\n~~~~~~~~~~\n\n## 转移语意（Move Semantics） {#MoveSemantics}\n\n在设计 RapidJSON 时有一个非常特别的决定，就是 Value 赋值并不是把来源 Value 复制至目的 Value，而是把把来源 Value 转移（move）至目的 Value。例如：\n\n~~~~~~~~~~cpp\nValue a(123);\nValue b(456);\nb = a;         // a 变成 Null，b 变成数字 123。\n~~~~~~~~~~\n\n![使用移动语意赋值。](diagram/move1.png)\n\n为什么？此语意有何优点？\n\n最简单的答案就是性能。对于固定大小的 JSON 类型（Number、True、False、Null），复制它们是简单快捷。然而，对于可变大小的 JSON 类型（String、Array、Object），复制它们会产生大量开销，而且这些开销常常不被察觉。尤其是当我们需要创建临时 Object，把它复制至另一变量，然后再析构它。\n\n例如，若使用正常 * 复制 * 语意：\n\n~~~~~~~~~~cpp\nValue o(kObjectType);\n{\n    Value contacts(kArrayType);\n    // 把元素加进 contacts 数组。\n    // ...\n    o.AddMember(\"contacts\", contacts, d.GetAllocator());  // 深度复制 contacts （可能有大量内存分配）\n    // 析构 contacts。\n}\n~~~~~~~~~~\n\n![复制语意产生大量的复制操作。](diagram/move2.png)\n\n那个 `o` Object 需要分配一个和 contacts 相同大小的缓冲区，对 conacts 做深度复制，并最终要析构 contacts。这样会产生大量无必要的内存分配／释放，以及内存复制。\n\n有一些方案可避免实质地复制这些数据，例如引用计数（reference counting）、垃圾回收（garbage collection, GC）。\n\n为了使 RapidJSON 简单及快速，我们选择了对赋值采用 * 转移 * 语意。这方法与 `std::auto_ptr` 相似，都是在赋值时转移拥有权。转移快得多简单得多，只需要析构原来的 Value，把来源 `memcpy()` 至目标，最后把来源设置为 Null 类型。\n\n因此，使用转移语意后，上面的例子变成：\n\n~~~~~~~~~~cpp\nValue o(kObjectType);\n{\n    Value contacts(kArrayType);\n    // adding elements to contacts array.\n    o.AddMember(\"contacts\", contacts, d.GetAllocator());  // 只需 memcpy() contacts 本身至新成员的 Value（16 字节）\n    // contacts 在这里变成 Null。它的析构是平凡的。\n}\n~~~~~~~~~~\n\n![转移语意不需复制。](diagram/move3.png)\n\n在 C++11 中这称为转移赋值操作（move assignment operator）。由于 RapidJSON 支持 C++03，它在赋值操作采用转移语意，其它修改形函数如 `AddMember()`, `PushBack()` 也采用转移语意。\n\n### 转移语意及临时值 {#TemporaryValues}\n\n有时候，我们想直接构造一个 Value 并传递给一个“转移”函数（如 `PushBack()`、`AddMember()`）。由于临时对象是不能转换为正常的 Value 引用，我们加入了一个方便的 `Move()` 函数：\n\n~~~~~~~~~~cpp\nValue a(kArrayType);\nDocument::AllocatorType& allocator = document.GetAllocator();\n// a.PushBack(Value(42), allocator);       // 不能通过编译\na.PushBack(Value().SetInt(42), allocator); // fluent API\na.PushBack(Value(42).Move(), allocator);   // 和上一行相同\n~~~~~~~~~~\n\n## 创建 String {#CreateString}\nRapidJSON 提供两个 String 的存储策略。\n\n1. copy-string: 分配缓冲区，然后把来源数据复制至它。\n2. const-string: 简单地储存字符串的指针。\n\nCopy-string 总是安全的，因为它拥有数据的克隆。Const-string 可用于存储字符串字面量，以及用于在 DOM 一节中将会提到的 in-situ 解析中。\n\n为了让用户自定义内存分配方式，当一个操作可能需要内存分配时，RapidJSON 要求用户传递一个 allocator 实例作为 API 参数。此设计避免了在每个 Value 存储 allocator（或 document）的指针。\n\n因此，当我们把一个 copy-string 赋值时, 调用含有 allocator 的 `SetString()` 重载函数：\n\n~~~~~~~~~~cpp\nDocument document;\nValue author;\nchar buffer[10];\nint len = sprintf(buffer, \"%s %s\", \"Milo\", \"Yip\"); // 动态创建的字符串。\nauthor.SetString(buffer, len, document.GetAllocator());\nmemset(buffer, 0, sizeof(buffer));\n// 清空 buffer 后 author.GetString() 仍然包含 \"Milo Yip\"\n~~~~~~~~~~\n\n在此例子中，我们使用 `Document` 实例的 allocator。这是使用 RapidJSON 时常用的惯用法。但你也可以用其他 allocator 实例。\n\n另外，上面的 `SetString()` 需要长度参数。这个 API 能处理含有空字符的字符串。另一个 `SetString()` 重载函数没有长度参数，它假设输入是空字符结尾的，并会调用类似 `strlen()` 的函数去获取长度。\n\n最后，对于字符串字面量或有安全生命周期的字符串，可以使用 const-string 版本的 `SetString()`，它没有 allocator 参数。对于字符串家面量（或字符数组常量），只需简单地传递字面量，又安全又高效：\n\n~~~~~~~~~~cpp\nValue s;\ns.SetString(\"rapidjson\");    // 可包含空字符，长度在编译萁推导\ns = \"rapidjson\";             // 上行的缩写\n~~~~~~~~~~\n\n对于字符指针，RapidJSON 需要作一个标记，代表它不复制也是安全的。可以使用 `StringRef` 函数：\n\n~~~~~~~~~cpp\nconst char * cstr = getenv(\"USER\");\nsize_t cstr_len = ...;                 // 如果有长度\nValue s;\n// s.SetString(cstr);                  // 这不能通过编译\ns.SetString(StringRef(cstr));          // 可以，假设它的生命周期安全，并且是以空字符结尾的\ns = StringRef(cstr);                   // 上行的缩写\ns.SetString(StringRef(cstr, cstr_len));// 更快，可处理空字符\ns = StringRef(cstr, cstr_len);         // 上行的缩写\n\n~~~~~~~~~\n\n## 修改 Array {#ModifyArray}\nArray 类型的 Value 提供与 `std::vector` 相似的 API。\n\n* `Clear()`\n* `Reserve(SizeType, Allocator&)`\n* `Value& PushBack(Value&, Allocator&)`\n* `template <typename T> GenericValue& PushBack(T, Allocator&)`\n* `Value& PopBack()`\n* `ValueIterator Erase(ConstValueIterator pos)`\n* `ValueIterator Erase(ConstValueIterator first, ConstValueIterator last)`\n\n注意，`Reserve(...)` 及 `PushBack(...)` 可能会为数组元素分配内存，所以需要一个 allocator。\n\n以下是 `PushBack()` 的例子：\n\n~~~~~~~~~~cpp\nValue a(kArrayType);\nDocument::AllocatorType& allocator = document.GetAllocator();\n\nfor (int i = 5; i <= 10; i++)\n    a.PushBack(i, allocator);   // 可能需要调用 realloc() 所以需要 allocator\n\n// 流畅接口（Fluent interface）\na.PushBack(\"Lua\", allocator).PushBack(\"Mio\", allocator);\n~~~~~~~~~~\n\n与 STL 不一样的是，`PushBack()`/`PopBack()` 返回 Array 本身的引用。这称为流畅接口（_fluent interface_）。\n\n如果你想在 Array 中加入一个非常量字符串，或是一个没有足够生命周期的字符串（见 [Create String](#CreateString)），你需要使用 copy-string API 去创建一个 String。为了避免加入中间变量，可以就地使用一个 [临时值](#TemporaryValues)：\n\n~~~~~~~~~~cpp\n// 就地 Value 参数\ncontact.PushBack(Value(\"copy\", document.GetAllocator()).Move(), // copy string\n                 document.GetAllocator());\n\n// 显式 Value 参数\nValue val(\"key\", document.GetAllocator()); // copy string\ncontact.PushBack(val, document.GetAllocator());\n~~~~~~~~~~\n\n## 修改 Object {#ModifyObject}\nObject 是键值对的集合。每个键必须为 String。要修改 Object，方法是增加或移除成员。以下的 API 用来增加城员：\n\n* `Value& AddMember(Value&, Value&, Allocator& allocator)`\n* `Value& AddMember(StringRefType, Value&, Allocator&)`\n* `template <typename T> Value& AddMember(StringRefType, T value, Allocator&)`\n\n以下是一个例子。\n\n~~~~~~~~~~cpp\nValue contact(kObject);\ncontact.AddMember(\"name\", \"Milo\", document.GetAllocator());\ncontact.AddMember(\"married\", true, document.GetAllocator());\n~~~~~~~~~~\n\n使用 `StringRefType` 作为 name 参数的重载版本与字符串的 `SetString` 的接口相似。 这些重载是为了避免复制 `name` 字符串，因为 JSON object 中经常会使用常数键名。\n\n如果你需要从非常数字符串或生命周期不足的字符串创建键名（见 [创建 String](#CreateString)），你需要使用 copy-string API。为了避免中间变量，可以就地使用 [临时值](#TemporaryValues)：\n\n~~~~~~~~~~cpp\n// 就地 Value 参数\ncontact.AddMember(Value(\"copy\", document.GetAllocator()).Move(), // copy string\n                  Value().Move(),                                // null value\n                  document.GetAllocator());\n\n// 显式参数\nValue key(\"key\", document.GetAllocator()); // copy string name\nValue val(42);                             // 某 Value\ncontact.AddMember(key, val, document.GetAllocator());\n~~~~~~~~~~\n\n移除成员有几个选择：\n\n* `bool RemoveMember(const Ch* name)`：使用键名来移除成员（线性时间复杂度）。\n* `bool RemoveMember(const Value& name)`：除了 `name` 是一个 Value，和上一行相同。\n* `MemberIterator RemoveMember(MemberIterator)`：使用迭代器移除成员（_ 常数 _ 时间复杂度）。\n* `MemberIterator EraseMember(MemberIterator)`：和上行相似但维持成员次序（线性时间复杂度）。\n* `MemberIterator EraseMember(MemberIterator first, MemberIterator last)`：移除一个范围内的成员，维持次序（线性时间复杂度）。\n\n`MemberIterator RemoveMember(MemberIterator)` 使用了“转移最后”手法来达成常数时间复杂度。基本上就是析构迭代器位置的成员，然后把最后的成员转移至迭代器位置。因此，成员的次序会被改变。\n\n## 深复制 Value {#DeepCopyValue}\n若我们真的要复制一个 DOM 树，我们可使用两个 APIs 作深复制：含 allocator 的构造函数及 `CopyFrom()`。\n\n~~~~~~~~~~cpp\nDocument d;\nDocument::AllocatorType& a = d.GetAllocator();\nValue v1(\"foo\");\n// Value v2(v1); // 不容许\n\nValue v2(v1, a);                      // 制造一个克隆\nassert(v1.IsString());                // v1 不变\nd.SetArray().PushBack(v1, a).PushBack(v2, a);\nassert(v1.IsNull() && v2.IsNull());   // 两个都转移动 d\n\nv2.CopyFrom(d, a);                    // 把整个 document 复制至 v2\nassert(d.IsArray() && d.Size() == 2); // d 不变\nv1.SetObject().AddMember(\"array\", v2, a);\nd.PushBack(v1, a);\n~~~~~~~~~~\n\n## 交换 Value {#SwapValues}\n\nRapidJSON 也提供 `Swap()`。\n\n~~~~~~~~~~cpp\nValue a(123);\nValue b(\"Hello\");\na.Swap(b);\nassert(a.IsString());\nassert(b.IsInt());\n~~~~~~~~~~\n\n无论两棵 DOM 树有多复杂，交换是很快的（常数时间）。\n\n# 下一部分 {#WhatsNext}\n\n本教程展示了如何询查及修改 DOM 树。RapidJSON 还有一个重要概念：\n\n1. [流](doc/stream.zh-cn.md) 是读写 JSON 的通道。流可以是内存字符串、文件流等。用户也可以自定义流。\n2. [编码](doc/encoding.zh-cn.md) 定义在流或内存中使用的字符编码。RapidJSON 也在内部提供 Unicode 转换及校验功能。\n3. [DOM](doc/dom.zh-cn.md) 的基本功能已在本教程里介绍。还有更高级的功能，如原位（*in situ*）解析、其他解析选项及高级用法。\n4. [SAX](doc/sax.zh-cn.md) 是 RapidJSON 解析／生成功能的基础。学习使用 `Reader`/`Writer` 去实现更高性能的应用程序。也可以使用 `PrettyWriter` 去格式化 JSON。\n5. [性能](doc/performance.zh-cn.md) 展示一些我们做的及第三方的性能测试。\n6. [技术内幕](doc/internals.md) 讲述一些 RapidJSON 内部的设计及技术。\n\n你也可以参考 [常见问题](doc/faq.zh-cn.md)、API 文档、例子及单元测试。\n"
  },
  {
    "path": "ext/rapidjson/docker/debian/Dockerfile",
    "content": "# BUILD:  docker build -t rapidjson-debian .\n# RUN:    docker run -it -v \"$PWD\"/../..:/rapidjson rapidjson-debian\n\nFROM debian:jessie\n\nRUN apt-get update && apt-get install -y g++ cmake doxygen valgrind\n\nENTRYPOINT [\"/bin/bash\"]\n"
  },
  {
    "path": "ext/rapidjson/example/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 2.8)\n\nif(POLICY CMP0054)\n  cmake_policy(SET CMP0054 NEW)\nendif()\n\nset(EXAMPLES\n    capitalize\n    condense\n    filterkey\n    filterkeydom\n    jsonx\n    messagereader\n    parsebyparts\n    pretty\n    prettyauto\n    schemavalidator\n    serialize\n    simpledom\n    simplereader\n    simplewriter\n    tutorial)\n    \ninclude_directories(\"../include/\")\n\nadd_definitions(-D__STDC_FORMAT_MACROS)\n\nif (\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"GNU\")\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -pthread -Werror -Wall -Wextra -Weffc++ -Wswitch-default\")\nelseif (CMAKE_CXX_COMPILER_ID MATCHES \"Clang\")\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Weffc++ -Wswitch-default -Wfloat-equal -Wimplicit-fallthrough -Weverything\")\nendif()\n\nforeach (example ${EXAMPLES})\n    add_executable(${example} ${example}/${example}.cpp)\nendforeach()\n\nif (CMAKE_CXX_COMPILER_ID MATCHES \"Clang\")\n    target_link_libraries(parsebyparts pthread)\nendif()\n\nadd_custom_target(examples ALL DEPENDS ${EXAMPLES})\n"
  },
  {
    "path": "ext/rapidjson/example/capitalize/capitalize.cpp",
    "content": "// JSON condenser example\n\n// This example parses JSON from stdin with validation, \n// and re-output the JSON content to stdout with all string capitalized, and without whitespace.\n\n#include \"rapidjson/reader.h\"\n#include \"rapidjson/writer.h\"\n#include \"rapidjson/filereadstream.h\"\n#include \"rapidjson/filewritestream.h\"\n#include \"rapidjson/error/en.h\"\n#include <vector>\n#include <cctype>\n\nusing namespace rapidjson;\n\ntemplate<typename OutputHandler>\nstruct CapitalizeFilter {\n    CapitalizeFilter(OutputHandler& out) : out_(out), buffer_() {}\n\n    bool Null() { return out_.Null(); }\n    bool Bool(bool b) { return out_.Bool(b); }\n    bool Int(int i) { return out_.Int(i); }\n    bool Uint(unsigned u) { return out_.Uint(u); }\n    bool Int64(int64_t i) { return out_.Int64(i); }\n    bool Uint64(uint64_t u) { return out_.Uint64(u); }\n    bool Double(double d) { return out_.Double(d); }\n    bool RawNumber(const char* str, SizeType length, bool copy) { return out_.RawNumber(str, length, copy); }\n    bool String(const char* str, SizeType length, bool) {\n        buffer_.clear();\n        for (SizeType i = 0; i < length; i++)\n            buffer_.push_back(static_cast<char>(std::toupper(str[i])));\n        return out_.String(&buffer_.front(), length, true); // true = output handler need to copy the string\n    }\n    bool StartObject() { return out_.StartObject(); }\n    bool Key(const char* str, SizeType length, bool copy) { return String(str, length, copy); }\n    bool EndObject(SizeType memberCount) { return out_.EndObject(memberCount); }\n    bool StartArray() { return out_.StartArray(); }\n    bool EndArray(SizeType elementCount) { return out_.EndArray(elementCount); }\n\n    OutputHandler& out_;\n    std::vector<char> buffer_;\n\nprivate:\n    CapitalizeFilter(const CapitalizeFilter&);\n    CapitalizeFilter& operator=(const CapitalizeFilter&);\n};\n\nint main(int, char*[]) {\n    // Prepare JSON reader and input stream.\n    Reader reader;\n    char readBuffer[65536];\n    FileReadStream is(stdin, readBuffer, sizeof(readBuffer));\n\n    // Prepare JSON writer and output stream.\n    char writeBuffer[65536];\n    FileWriteStream os(stdout, writeBuffer, sizeof(writeBuffer));\n    Writer<FileWriteStream> writer(os);\n\n    // JSON reader parse from the input stream and let writer generate the output.\n    CapitalizeFilter<Writer<FileWriteStream> > filter(writer);\n    if (!reader.Parse(is, filter)) {\n        fprintf(stderr, \"\\nError(%u): %s\\n\", static_cast<unsigned>(reader.GetErrorOffset()), GetParseError_En(reader.GetParseErrorCode()));\n        return 1;\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "ext/rapidjson/example/condense/condense.cpp",
    "content": "// JSON condenser example\n\n// This example parses JSON text from stdin with validation, \n// and re-output the JSON content to stdout without whitespace.\n\n#include \"rapidjson/reader.h\"\n#include \"rapidjson/writer.h\"\n#include \"rapidjson/filereadstream.h\"\n#include \"rapidjson/filewritestream.h\"\n#include \"rapidjson/error/en.h\"\n\nusing namespace rapidjson;\n\nint main(int, char*[]) {\n    // Prepare JSON reader and input stream.\n    Reader reader;\n    char readBuffer[65536];\n    FileReadStream is(stdin, readBuffer, sizeof(readBuffer));\n\n    // Prepare JSON writer and output stream.\n    char writeBuffer[65536];\n    FileWriteStream os(stdout, writeBuffer, sizeof(writeBuffer));\n    Writer<FileWriteStream> writer(os);\n\n    // JSON reader parse from the input stream and let writer generate the output.\n    if (!reader.Parse(is, writer)) {\n        fprintf(stderr, \"\\nError(%u): %s\\n\", static_cast<unsigned>(reader.GetErrorOffset()), GetParseError_En(reader.GetParseErrorCode()));\n        return 1;\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "ext/rapidjson/example/filterkey/filterkey.cpp",
    "content": "// JSON filterkey example with SAX-style API.\n\n// This example parses JSON text from stdin with validation.\n// During parsing, specified key will be filtered using a SAX handler.\n// It re-output the JSON content to stdout without whitespace.\n\n#include \"rapidjson/reader.h\"\n#include \"rapidjson/writer.h\"\n#include \"rapidjson/filereadstream.h\"\n#include \"rapidjson/filewritestream.h\"\n#include \"rapidjson/error/en.h\"\n#include <stack>\n\nusing namespace rapidjson;\n\n// This handler forwards event into an output handler, with filtering the descendent events of specified key.\ntemplate <typename OutputHandler>\nclass FilterKeyHandler {\npublic:\n    typedef char Ch;\n\n    FilterKeyHandler(OutputHandler& outputHandler, const Ch* keyString, SizeType keyLength) : \n        outputHandler_(outputHandler), keyString_(keyString), keyLength_(keyLength), filterValueDepth_(), filteredKeyCount_()\n    {}\n\n    bool Null()             { return filterValueDepth_ > 0 ? EndValue() : outputHandler_.Null()    && EndValue(); }\n    bool Bool(bool b)       { return filterValueDepth_ > 0 ? EndValue() : outputHandler_.Bool(b)   && EndValue(); }\n    bool Int(int i)         { return filterValueDepth_ > 0 ? EndValue() : outputHandler_.Int(i)    && EndValue(); }\n    bool Uint(unsigned u)   { return filterValueDepth_ > 0 ? EndValue() : outputHandler_.Uint(u)   && EndValue(); }\n    bool Int64(int64_t i)   { return filterValueDepth_ > 0 ? EndValue() : outputHandler_.Int64(i)  && EndValue(); }\n    bool Uint64(uint64_t u) { return filterValueDepth_ > 0 ? EndValue() : outputHandler_.Uint64(u) && EndValue(); }\n    bool Double(double d)   { return filterValueDepth_ > 0 ? EndValue() : outputHandler_.Double(d) && EndValue(); }\n    bool RawNumber(const Ch* str, SizeType len, bool copy) { return filterValueDepth_ > 0 ? EndValue() : outputHandler_.RawNumber(str, len, copy) && EndValue(); }\n    bool String   (const Ch* str, SizeType len, bool copy) { return filterValueDepth_ > 0 ? EndValue() : outputHandler_.String   (str, len, copy) && EndValue(); }\n    \n    bool StartObject() { \n        if (filterValueDepth_ > 0) {\n            filterValueDepth_++;\n            return true;\n        }\n        else {\n            filteredKeyCount_.push(0);\n            return outputHandler_.StartObject();\n        }\n    }\n    \n    bool Key(const Ch* str, SizeType len, bool copy) { \n        if (filterValueDepth_ > 0) \n            return true;\n        else if (len == keyLength_ && std::memcmp(str, keyString_, len) == 0) {\n            filterValueDepth_ = 1;\n            return true;\n        }\n        else {\n            ++filteredKeyCount_.top();\n            return outputHandler_.Key(str, len, copy);\n        }\n    }\n\n    bool EndObject(SizeType) {\n        if (filterValueDepth_ > 0) {\n            filterValueDepth_--;\n            return EndValue();\n        }\n        else {\n            // Use our own filtered memberCount\n            SizeType memberCount = filteredKeyCount_.top();\n            filteredKeyCount_.pop();\n            return outputHandler_.EndObject(memberCount) && EndValue();\n        }\n    }\n\n    bool StartArray() {\n        if (filterValueDepth_ > 0) {\n            filterValueDepth_++;\n            return true;\n        }\n        else\n            return outputHandler_.StartArray();\n    }\n\n    bool EndArray(SizeType elementCount) {\n        if (filterValueDepth_ > 0) {\n            filterValueDepth_--;\n            return EndValue();\n        }\n        else\n            return outputHandler_.EndArray(elementCount) && EndValue();\n    }\n\nprivate:\n    FilterKeyHandler(const FilterKeyHandler&);\n    FilterKeyHandler& operator=(const FilterKeyHandler&);\n\n    bool EndValue() {\n        if (filterValueDepth_ == 1) // Just at the end of value after filtered key\n            filterValueDepth_ = 0;\n        return true;\n    }\n    \n    OutputHandler& outputHandler_;\n    const char* keyString_;\n    const SizeType keyLength_;\n    unsigned filterValueDepth_;\n    std::stack<SizeType> filteredKeyCount_;\n};\n\nint main(int argc, char* argv[]) {\n    if (argc != 2) {\n        fprintf(stderr, \"filterkey key < input.json > output.json\\n\");\n        return 1;\n    }\n\n    // Prepare JSON reader and input stream.\n    Reader reader;\n    char readBuffer[65536];\n    FileReadStream is(stdin, readBuffer, sizeof(readBuffer));\n\n    // Prepare JSON writer and output stream.\n    char writeBuffer[65536];\n    FileWriteStream os(stdout, writeBuffer, sizeof(writeBuffer));\n    Writer<FileWriteStream> writer(os);\n\n    // Prepare Filter\n    FilterKeyHandler<Writer<FileWriteStream> > filter(writer, argv[1], static_cast<SizeType>(strlen(argv[1])));\n\n    // JSON reader parse from the input stream, filter handler filters the events, and forward to writer.\n    // i.e. the events flow is: reader -> filter -> writer\n    if (!reader.Parse(is, filter)) {\n        fprintf(stderr, \"\\nError(%u): %s\\n\", static_cast<unsigned>(reader.GetErrorOffset()), GetParseError_En(reader.GetParseErrorCode()));\n        return 1;\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "ext/rapidjson/example/filterkeydom/filterkeydom.cpp",
    "content": "// JSON filterkey example which populates filtered SAX events into a Document.\n\n// This example parses JSON text from stdin with validation.\n// During parsing, specified key will be filtered using a SAX handler.\n// And finally the filtered events are used to populate a Document.\n// As an example, the document is written to standard output.\n\n#include \"rapidjson/document.h\"\n#include \"rapidjson/writer.h\"\n#include \"rapidjson/filereadstream.h\"\n#include \"rapidjson/filewritestream.h\"\n#include \"rapidjson/error/en.h\"\n#include <stack>\n\nusing namespace rapidjson;\n\n// This handler forwards event into an output handler, with filtering the descendent events of specified key.\ntemplate <typename OutputHandler>\nclass FilterKeyHandler {\npublic:\n    typedef char Ch;\n\n    FilterKeyHandler(OutputHandler& outputHandler, const Ch* keyString, SizeType keyLength) : \n        outputHandler_(outputHandler), keyString_(keyString), keyLength_(keyLength), filterValueDepth_(), filteredKeyCount_()\n    {}\n\n    bool Null()             { return filterValueDepth_ > 0 ? EndValue() : outputHandler_.Null()    && EndValue(); }\n    bool Bool(bool b)       { return filterValueDepth_ > 0 ? EndValue() : outputHandler_.Bool(b)   && EndValue(); }\n    bool Int(int i)         { return filterValueDepth_ > 0 ? EndValue() : outputHandler_.Int(i)    && EndValue(); }\n    bool Uint(unsigned u)   { return filterValueDepth_ > 0 ? EndValue() : outputHandler_.Uint(u)   && EndValue(); }\n    bool Int64(int64_t i)   { return filterValueDepth_ > 0 ? EndValue() : outputHandler_.Int64(i)  && EndValue(); }\n    bool Uint64(uint64_t u) { return filterValueDepth_ > 0 ? EndValue() : outputHandler_.Uint64(u) && EndValue(); }\n    bool Double(double d)   { return filterValueDepth_ > 0 ? EndValue() : outputHandler_.Double(d) && EndValue(); }\n    bool RawNumber(const Ch* str, SizeType len, bool copy) { return filterValueDepth_ > 0 ? EndValue() : outputHandler_.RawNumber(str, len, copy) && EndValue(); }\n    bool String   (const Ch* str, SizeType len, bool copy) { return filterValueDepth_ > 0 ? EndValue() : outputHandler_.String   (str, len, copy) && EndValue(); }\n    \n    bool StartObject() { \n        if (filterValueDepth_ > 0) {\n            filterValueDepth_++;\n            return true;\n        }\n        else {\n            filteredKeyCount_.push(0);\n            return outputHandler_.StartObject();\n        }\n    }\n    \n    bool Key(const Ch* str, SizeType len, bool copy) { \n        if (filterValueDepth_ > 0) \n            return true;\n        else if (len == keyLength_ && std::memcmp(str, keyString_, len) == 0) {\n            filterValueDepth_ = 1;\n            return true;\n        }\n        else {\n            ++filteredKeyCount_.top();\n            return outputHandler_.Key(str, len, copy);\n        }\n    }\n\n    bool EndObject(SizeType) {\n        if (filterValueDepth_ > 0) {\n            filterValueDepth_--;\n            return EndValue();\n        }\n        else {\n            // Use our own filtered memberCount\n            SizeType memberCount = filteredKeyCount_.top();\n            filteredKeyCount_.pop();\n            return outputHandler_.EndObject(memberCount) && EndValue();\n        }\n    }\n\n    bool StartArray() {\n        if (filterValueDepth_ > 0) {\n            filterValueDepth_++;\n            return true;\n        }\n        else\n            return outputHandler_.StartArray();\n    }\n\n    bool EndArray(SizeType elementCount) {\n        if (filterValueDepth_ > 0) {\n            filterValueDepth_--;\n            return EndValue();\n        }\n        else\n            return outputHandler_.EndArray(elementCount) && EndValue();\n    }\n\nprivate:\n    FilterKeyHandler(const FilterKeyHandler&);\n    FilterKeyHandler& operator=(const FilterKeyHandler&);\n\n    bool EndValue() {\n        if (filterValueDepth_ == 1) // Just at the end of value after filtered key\n            filterValueDepth_ = 0;\n        return true;\n    }\n\n    OutputHandler& outputHandler_;\n    const char* keyString_;\n    const SizeType keyLength_;\n    unsigned filterValueDepth_;\n    std::stack<SizeType> filteredKeyCount_;\n};\n\n// Implements a generator for Document::Populate()\ntemplate <typename InputStream>\nclass FilterKeyReader {\npublic:\n    typedef char Ch;\n\n    FilterKeyReader(InputStream& is, const Ch* keyString, SizeType keyLength) : \n        is_(is), keyString_(keyString), keyLength_(keyLength), parseResult_()\n    {}\n\n    // SAX event flow: reader -> filter -> handler\n    template <typename Handler>\n    bool operator()(Handler& handler) {\n        FilterKeyHandler<Handler> filter(handler, keyString_, keyLength_);\n        Reader reader;\n        parseResult_ = reader.Parse(is_, filter);\n        return parseResult_;\n    }\n\n    const ParseResult& GetParseResult() const { return parseResult_; }\n\nprivate:\n    FilterKeyReader(const FilterKeyReader&);\n    FilterKeyReader& operator=(const FilterKeyReader&);\n\n    InputStream& is_;\n    const char* keyString_;\n    const SizeType keyLength_;\n    ParseResult parseResult_;\n};\n\nint main(int argc, char* argv[]) {\n    if (argc != 2) {\n        fprintf(stderr, \"filterkeydom key < input.json > output.json\\n\");\n        return 1;\n    }\n\n    // Prepare input stream.\n    char readBuffer[65536];\n    FileReadStream is(stdin, readBuffer, sizeof(readBuffer));\n\n    // Prepare Filter\n    FilterKeyReader<FileReadStream> reader(is, argv[1], static_cast<SizeType>(strlen(argv[1])));\n\n    // Populates the filtered events from reader\n    Document document;\n    document.Populate(reader);\n    ParseResult pr = reader.GetParseResult();\n    if (!pr) {\n        fprintf(stderr, \"\\nError(%u): %s\\n\", static_cast<unsigned>(pr.Offset()), GetParseError_En(pr.Code()));\n        return 1;\n    }\n\n    // Prepare JSON writer and output stream.\n    char writeBuffer[65536];\n    FileWriteStream os(stdout, writeBuffer, sizeof(writeBuffer));\n    Writer<FileWriteStream> writer(os);\n\n    // Write the document to standard output\n    document.Accept(writer);\n    return 0;\n}\n"
  },
  {
    "path": "ext/rapidjson/example/jsonx/jsonx.cpp",
    "content": "// JSON to JSONx conversion exmaple, using SAX API.\n// JSONx is an IBM standard format to represent JSON as XML.\n// https://www-01.ibm.com/support/knowledgecenter/SS9H2Y_7.1.0/com.ibm.dp.doc/json_jsonx.html\n// This example parses JSON text from stdin with validation, \n// and convert to JSONx format to stdout.\n// Need compile with -D__STDC_FORMAT_MACROS for defining PRId64 and PRIu64 macros.\n\n#include \"rapidjson/reader.h\"\n#include \"rapidjson/stringbuffer.h\"\n#include \"rapidjson/filereadstream.h\"\n#include \"rapidjson/filewritestream.h\"\n#include \"rapidjson/error/en.h\"\n#include <cstdio>\n\nusing namespace rapidjson;\n\n// For simplicity, this example only read/write in UTF-8 encoding\ntemplate <typename OutputStream>\nclass JsonxWriter {\npublic:\n    JsonxWriter(OutputStream& os) : os_(os), name_(), level_(0), hasName_(false) {\n    }\n\n    bool Null() {\n        return WriteStartElement(\"null\", true);\n    }\n    \n    bool Bool(bool b) {\n        return \n            WriteStartElement(\"boolean\") &&\n            WriteString(b ? \"true\" : \"false\") &&\n            WriteEndElement(\"boolean\");\n    }\n    \n    bool Int(int i) {\n        char buffer[12];\n        return WriteNumberElement(buffer, sprintf(buffer, \"%d\", i));\n    }\n    \n    bool Uint(unsigned i) {\n        char buffer[11];\n        return WriteNumberElement(buffer, sprintf(buffer, \"%u\", i));\n    }\n    \n    bool Int64(int64_t i) {\n        char buffer[21];\n        return WriteNumberElement(buffer, sprintf(buffer, \"%\" PRId64, i));\n    }\n    \n    bool Uint64(uint64_t i) {\n        char buffer[21];\n        return WriteNumberElement(buffer, sprintf(buffer, \"%\" PRIu64, i));\n    }\n    \n    bool Double(double d) {\n        char buffer[30];\n        return WriteNumberElement(buffer, sprintf(buffer, \"%.17g\", d));\n    }\n\n    bool RawNumber(const char* str, SizeType length, bool) {\n        return\n            WriteStartElement(\"number\") &&\n            WriteEscapedText(str, length) &&\n            WriteEndElement(\"number\");\n    }\n\n    bool String(const char* str, SizeType length, bool) {\n        return\n            WriteStartElement(\"string\") &&\n            WriteEscapedText(str, length) &&\n            WriteEndElement(\"string\");\n    }\n\n    bool StartObject() {\n        return WriteStartElement(\"object\");\n    }\n\n    bool Key(const char* str, SizeType length, bool) {\n        // backup key to name_\n        name_.Clear();\n        for (SizeType i = 0; i < length; i++)\n            name_.Put(str[i]);\n        hasName_ = true;\n        return true;\n    }\n\n    bool EndObject(SizeType) {\n        return WriteEndElement(\"object\");\n    }\n\n    bool StartArray() {\n        return WriteStartElement(\"array\");\n    }\n\n    bool EndArray(SizeType) {\n        return WriteEndElement(\"array\");\n    }\n\nprivate:\n    bool WriteString(const char* s) {\n        while (*s)\n            os_.Put(*s++);\n        return true;\n    }\n\n    bool WriteEscapedAttributeValue(const char* s, size_t length) {\n        for (size_t i = 0; i < length; i++) {\n            switch (s[i]) {\n                case '&': WriteString(\"&amp;\"); break;\n                case '<': WriteString(\"&lt;\"); break;\n                case '\"': WriteString(\"&quot;\"); break;\n                default: os_.Put(s[i]); break;\n            }\n        }\n        return true;\n    }\n\n    bool WriteEscapedText(const char* s, size_t length) {\n        for (size_t i = 0; i < length; i++) {\n            switch (s[i]) {\n                case '&': WriteString(\"&amp;\"); break;\n                case '<': WriteString(\"&lt;\"); break;\n                default: os_.Put(s[i]); break;\n            }\n        }\n        return true;\n    }\n\n    bool WriteStartElement(const char* type, bool emptyElement = false) {\n        if (level_ == 0)\n            if (!WriteString(\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\"))\n                return false;\n\n        if (!WriteString(\"<json:\") || !WriteString(type))\n            return false;\n\n        // For root element, need to add declarations\n        if (level_ == 0) {\n            if (!WriteString(\n                \" xsi:schemaLocation=\\\"http://www.datapower.com/schemas/json jsonx.xsd\\\"\"\n                \" xmlns:xsi=\\\"http://www.w3.org/2001/XMLSchema-instance\\\"\"\n                \" xmlns:json=\\\"http://www.ibm.com/xmlns/prod/2009/jsonx\\\"\"))\n                return false;\n        }\n\n        if (hasName_) {\n            hasName_ = false;\n            if (!WriteString(\" name=\\\"\") ||\n                !WriteEscapedAttributeValue(name_.GetString(), name_.GetSize()) ||\n                !WriteString(\"\\\"\"))\n                return false;\n        }\n\n        if (emptyElement)\n            return WriteString(\"/>\");\n        else {\n            level_++;\n            return WriteString(\">\");\n        }\n    }\n\n    bool WriteEndElement(const char* type) {\n        if (!WriteString(\"</json:\") ||\n            !WriteString(type) ||\n            !WriteString(\">\"))\n            return false;\n\n        // For the last end tag, flush the output stream.\n        if (--level_ == 0)\n            os_.Flush();\n\n        return true;\n    }\n\n    bool WriteNumberElement(const char* buffer, int length) {\n        if (!WriteStartElement(\"number\"))\n            return false;\n        for (int j = 0; j < length; j++)\n            os_.Put(buffer[j]);\n        return WriteEndElement(\"number\");\n    }\n\n    OutputStream& os_;\n    StringBuffer name_;\n    unsigned level_;\n    bool hasName_;\n};\n\nint main(int, char*[]) {\n    // Prepare JSON reader and input stream.\n    Reader reader;\n    char readBuffer[65536];\n    FileReadStream is(stdin, readBuffer, sizeof(readBuffer));\n\n    // Prepare JSON writer and output stream.\n    char writeBuffer[65536];\n    FileWriteStream os(stdout, writeBuffer, sizeof(writeBuffer));\n    JsonxWriter<FileWriteStream> writer(os);\n\n    // JSON reader parse from the input stream and let writer generate the output.\n    if (!reader.Parse(is, writer)) {\n        fprintf(stderr, \"\\nError(%u): %s\\n\", static_cast<unsigned>(reader.GetErrorOffset()), GetParseError_En(reader.GetParseErrorCode()));\n        return 1;\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "ext/rapidjson/example/messagereader/messagereader.cpp",
    "content": "// Reading a message JSON with Reader (SAX-style API).\n// The JSON should be an object with key-string pairs.\n\n#include \"rapidjson/reader.h\"\n#include \"rapidjson/error/en.h\"\n#include <iostream>\n#include <string>\n#include <map>\n\nusing namespace std;\nusing namespace rapidjson;\n\ntypedef map<string, string> MessageMap;\n\n#if defined(__GNUC__)\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(effc++)\n#endif\n\n#ifdef __clang__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(switch-enum)\n#endif\n\nstruct MessageHandler\n    : public BaseReaderHandler<UTF8<>, MessageHandler> {\n    MessageHandler() : messages_(), state_(kExpectObjectStart), name_() {}\n\n    bool StartObject() {\n        switch (state_) {\n        case kExpectObjectStart:\n            state_ = kExpectNameOrObjectEnd;\n            return true;\n        default:\n            return false;\n        }\n    }\n\n    bool String(const char* str, SizeType length, bool) {\n        switch (state_) {\n        case kExpectNameOrObjectEnd:\n            name_ = string(str, length);\n            state_ = kExpectValue;\n            return true;\n        case kExpectValue:\n            messages_.insert(MessageMap::value_type(name_, string(str, length)));\n            state_ = kExpectNameOrObjectEnd;\n            return true;\n        default:\n            return false;\n        }\n    }\n\n    bool EndObject(SizeType) { return state_ == kExpectNameOrObjectEnd; }\n\n    bool Default() { return false; } // All other events are invalid.\n\n    MessageMap messages_;\n    enum State {\n        kExpectObjectStart,\n        kExpectNameOrObjectEnd,\n        kExpectValue\n    }state_;\n    std::string name_;\n};\n\n#if defined(__GNUC__)\nRAPIDJSON_DIAG_POP\n#endif\n\n#ifdef __clang__\nRAPIDJSON_DIAG_POP\n#endif\n\nstatic void ParseMessages(const char* json, MessageMap& messages) {\n    Reader reader;\n    MessageHandler handler;\n    StringStream ss(json);\n    if (reader.Parse(ss, handler))\n        messages.swap(handler.messages_);   // Only change it if success.\n    else {\n        ParseErrorCode e = reader.GetParseErrorCode();\n        size_t o = reader.GetErrorOffset();\n        cout << \"Error: \" << GetParseError_En(e) << endl;;\n        cout << \" at offset \" << o << \" near '\" << string(json).substr(o, 10) << \"...'\" << endl;\n    }\n}\n\nint main() {\n    MessageMap messages;\n\n    const char* json1 = \"{ \\\"greeting\\\" : \\\"Hello!\\\", \\\"farewell\\\" : \\\"bye-bye!\\\" }\";\n    cout << json1 << endl;\n    ParseMessages(json1, messages);\n\n    for (MessageMap::const_iterator itr = messages.begin(); itr != messages.end(); ++itr)\n        cout << itr->first << \": \" << itr->second << endl;\n\n    cout << endl << \"Parse a JSON with invalid schema.\" << endl;\n    const char* json2 = \"{ \\\"greeting\\\" : \\\"Hello!\\\", \\\"farewell\\\" : \\\"bye-bye!\\\", \\\"foo\\\" : {} }\";\n    cout << json2 << endl;\n    ParseMessages(json2, messages);\n\n    return 0;\n}\n"
  },
  {
    "path": "ext/rapidjson/example/parsebyparts/parsebyparts.cpp",
    "content": "// Example of parsing JSON to document by parts.\n\n// Using C++11 threads\n// Temporarily disable for clang (older version) due to incompatibility with libstdc++\n#if (__cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1700)) && !defined(__clang__)\n\n#include \"rapidjson/document.h\"\n#include \"rapidjson/error/en.h\"\n#include \"rapidjson/writer.h\"\n#include \"rapidjson/ostreamwrapper.h\"\n#include <condition_variable>\n#include <iostream>\n#include <mutex>\n#include <thread>\n\nusing namespace rapidjson;\n\ntemplate<unsigned parseFlags = kParseDefaultFlags>\nclass AsyncDocumentParser {\npublic:\n    AsyncDocumentParser(Document& d)\n        : stream_(*this)\n        , d_(d)\n        , parseThread_(&AsyncDocumentParser::Parse, this)\n        , mutex_()\n        , notEmpty_()\n        , finish_()\n        , completed_()\n    {}\n\n    ~AsyncDocumentParser() {\n        if (!parseThread_.joinable())\n            return;\n\n        {        \n            std::unique_lock<std::mutex> lock(mutex_);\n\n            // Wait until the buffer is read up (or parsing is completed)\n            while (!stream_.Empty() && !completed_)\n                finish_.wait(lock);\n\n            // Automatically append '\\0' as the terminator in the stream.\n            static const char terminator[] = \"\";\n            stream_.src_ = terminator;\n            stream_.end_ = terminator + 1;\n            notEmpty_.notify_one(); // unblock the AsyncStringStream\n        }\n\n        parseThread_.join();\n    }\n\n    void ParsePart(const char* buffer, size_t length) {\n        std::unique_lock<std::mutex> lock(mutex_);\n        \n        // Wait until the buffer is read up (or parsing is completed)\n        while (!stream_.Empty() && !completed_)\n            finish_.wait(lock);\n\n        // Stop further parsing if the parsing process is completed.\n        if (completed_)\n            return;\n\n        // Set the buffer to stream and unblock the AsyncStringStream\n        stream_.src_ = buffer;\n        stream_.end_ = buffer + length;\n        notEmpty_.notify_one();\n    }\n\nprivate:\n    void Parse() {\n        d_.ParseStream<parseFlags>(stream_);\n\n        // The stream may not be fully read, notify finish anyway to unblock ParsePart()\n        std::unique_lock<std::mutex> lock(mutex_);\n        completed_ = true;      // Parsing process is completed\n        finish_.notify_one();   // Unblock ParsePart() or destructor if they are waiting.\n    }\n\n    struct AsyncStringStream {\n        typedef char Ch;\n\n        AsyncStringStream(AsyncDocumentParser& parser) : parser_(parser), src_(), end_(), count_() {}\n\n        char Peek() const {\n            std::unique_lock<std::mutex> lock(parser_.mutex_);\n\n            // If nothing in stream, block to wait.\n            while (Empty())\n                parser_.notEmpty_.wait(lock);\n\n            return *src_;\n        }\n\n        char Take() {\n            std::unique_lock<std::mutex> lock(parser_.mutex_);\n\n            // If nothing in stream, block to wait.\n            while (Empty())\n                parser_.notEmpty_.wait(lock);\n\n            count_++;\n            char c = *src_++;\n\n            // If all stream is read up, notify that the stream is finish.\n            if (Empty())\n                parser_.finish_.notify_one();\n\n            return c;\n        }\n\n        size_t Tell() const { return count_; }\n\n        // Not implemented\n        char* PutBegin() { return 0; }\n        void Put(char) {}\n        void Flush() {}\n        size_t PutEnd(char*) { return 0; }\n\n        bool Empty() const { return src_ == end_; }\n\n        AsyncDocumentParser& parser_;\n        const char* src_;     //!< Current read position.\n        const char* end_;     //!< End of buffer\n        size_t count_;        //!< Number of characters taken so far.\n    };\n\n    AsyncStringStream stream_;\n    Document& d_;\n    std::thread parseThread_;\n    std::mutex mutex_;\n    std::condition_variable notEmpty_;\n    std::condition_variable finish_;\n    bool completed_;\n};\n\nint main() {\n    Document d;\n\n    {\n        AsyncDocumentParser<> parser(d);\n\n        const char json1[] = \" { \\\"hello\\\" : \\\"world\\\", \\\"t\\\" : tr\";\n        //const char json1[] = \" { \\\"hello\\\" : \\\"world\\\", \\\"t\\\" : trX\"; // Fot test parsing error\n        const char json2[] = \"ue, \\\"f\\\" : false, \\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.14\";\n        const char json3[] = \"16, \\\"a\\\":[1, 2, 3, 4] } \";\n\n        parser.ParsePart(json1, sizeof(json1) - 1);\n        parser.ParsePart(json2, sizeof(json2) - 1);\n        parser.ParsePart(json3, sizeof(json3) - 1);\n    }\n\n    if (d.HasParseError()) {\n        std::cout << \"Error at offset \" << d.GetErrorOffset() << \": \" << GetParseError_En(d.GetParseError()) << std::endl;\n        return EXIT_FAILURE;\n    }\n    \n    // Stringify the JSON to cout\n    OStreamWrapper os(std::cout);\n    Writer<OStreamWrapper> writer(os);\n    d.Accept(writer);\n    std::cout << std::endl;\n\n    return EXIT_SUCCESS;\n}\n\n#else // Not supporting C++11 \n\n#include <iostream>\nint main() {\n    std::cout << \"This example requires C++11 compiler\" << std::endl;\n}\n\n#endif\n"
  },
  {
    "path": "ext/rapidjson/example/pretty/pretty.cpp",
    "content": "// JSON pretty formatting example\n// This example can only handle UTF-8. For handling other encodings, see prettyauto example.\n\n#include \"rapidjson/reader.h\"\n#include \"rapidjson/prettywriter.h\"\n#include \"rapidjson/filereadstream.h\"\n#include \"rapidjson/filewritestream.h\"\n#include \"rapidjson/error/en.h\"\n\nusing namespace rapidjson;\n\nint main(int, char*[]) {\n    // Prepare reader and input stream.\n    Reader reader;\n    char readBuffer[65536];\n    FileReadStream is(stdin, readBuffer, sizeof(readBuffer));\n\n    // Prepare writer and output stream.\n    char writeBuffer[65536];\n    FileWriteStream os(stdout, writeBuffer, sizeof(writeBuffer));\n    PrettyWriter<FileWriteStream> writer(os);\n\n    // JSON reader parse from the input stream and let writer generate the output.\n    if (!reader.Parse<kParseValidateEncodingFlag>(is, writer)) {\n        fprintf(stderr, \"\\nError(%u): %s\\n\", static_cast<unsigned>(reader.GetErrorOffset()), GetParseError_En(reader.GetParseErrorCode()));\n        return 1;\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "ext/rapidjson/example/prettyauto/prettyauto.cpp",
    "content": "// JSON pretty formatting example\n// This example can handle UTF-8/UTF-16LE/UTF-16BE/UTF-32LE/UTF-32BE.\n// The input firstly convert to UTF8, and then write to the original encoding with pretty formatting.\n\n#include \"rapidjson/reader.h\"\n#include \"rapidjson/prettywriter.h\"\n#include \"rapidjson/filereadstream.h\"\n#include \"rapidjson/filewritestream.h\"\n#include \"rapidjson/encodedstream.h\"    // NEW\n#include \"rapidjson/error/en.h\"\n#ifdef _WIN32\n#include <fcntl.h>\n#include <io.h>\n#endif\n\nusing namespace rapidjson;\n\nint main(int, char*[]) {\n#ifdef _WIN32\n    // Prevent Windows converting between CR+LF and LF\n    _setmode(_fileno(stdin), _O_BINARY);    // NEW\n    _setmode(_fileno(stdout), _O_BINARY);   // NEW\n#endif\n\n    // Prepare reader and input stream.\n    //Reader reader;\n    GenericReader<AutoUTF<unsigned>, UTF8<> > reader;       // CHANGED\n    char readBuffer[65536];\n    FileReadStream is(stdin, readBuffer, sizeof(readBuffer));\n    AutoUTFInputStream<unsigned, FileReadStream> eis(is);   // NEW\n\n    // Prepare writer and output stream.\n    char writeBuffer[65536];\n    FileWriteStream os(stdout, writeBuffer, sizeof(writeBuffer));\n\n#if 1\n    // Use the same Encoding of the input. Also use BOM according to input.\n    typedef AutoUTFOutputStream<unsigned, FileWriteStream> OutputStream;    // NEW\n    OutputStream eos(os, eis.GetType(), eis.HasBOM());                      // NEW\n    PrettyWriter<OutputStream, UTF8<>, AutoUTF<unsigned> > writer(eos);     // CHANGED\n#else\n    // You may also use static bound encoding type, such as output to UTF-16LE with BOM\n    typedef EncodedOutputStream<UTF16LE<>,FileWriteStream> OutputStream;    // NEW\n    OutputStream eos(os, true);                                             // NEW\n    PrettyWriter<OutputStream, UTF8<>, UTF16LE<> > writer(eos);             // CHANGED\n#endif\n\n    // JSON reader parse from the input stream and let writer generate the output.\n    //if (!reader.Parse<kParseValidateEncodingFlag>(is, writer)) {\n    if (!reader.Parse<kParseValidateEncodingFlag>(eis, writer)) {   // CHANGED\n        fprintf(stderr, \"\\nError(%u): %s\\n\", static_cast<unsigned>(reader.GetErrorOffset()), GetParseError_En(reader.GetParseErrorCode()));\n        return 1;\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "ext/rapidjson/example/schemavalidator/schemavalidator.cpp",
    "content": "// Schema Validator example\n\n// The example validates JSON text from stdin with a JSON schema specified in the argument.\n\n#include \"rapidjson/error/en.h\"\n#include \"rapidjson/filereadstream.h\"\n#include \"rapidjson/schema.h\"\n#include \"rapidjson/stringbuffer.h\"\n\nusing namespace rapidjson;\n\nint main(int argc, char *argv[]) {\n    if (argc != 2) {\n        fprintf(stderr, \"Usage: schemavalidator schema.json < input.json\\n\");\n        return EXIT_FAILURE;\n    }\n\n    // Read a JSON schema from file into Document\n    Document d;\n    char buffer[4096];\n\n    {\n        FILE *fp = fopen(argv[1], \"r\");\n        if (!fp) {\n            printf(\"Schema file '%s' not found\\n\", argv[1]);\n            return -1;\n        }\n        FileReadStream fs(fp, buffer, sizeof(buffer));\n        d.ParseStream(fs);\n        if (d.HasParseError()) {\n            fprintf(stderr, \"Schema file '%s' is not a valid JSON\\n\", argv[1]);\n            fprintf(stderr, \"Error(offset %u): %s\\n\",\n                static_cast<unsigned>(d.GetErrorOffset()),\n                GetParseError_En(d.GetParseError()));\n            fclose(fp);\n            return EXIT_FAILURE;\n        }\n        fclose(fp);\n    }\n    \n    // Then convert the Document into SchemaDocument\n    SchemaDocument sd(d);\n\n    // Use reader to parse the JSON in stdin, and forward SAX events to validator\n    SchemaValidator validator(sd);\n    Reader reader;\n    FileReadStream is(stdin, buffer, sizeof(buffer));\n    if (!reader.Parse(is, validator) && reader.GetParseErrorCode() != kParseErrorTermination) {\n        // Schema validator error would cause kParseErrorTermination, which will handle it in next step.\n        fprintf(stderr, \"Input is not a valid JSON\\n\");\n        fprintf(stderr, \"Error(offset %u): %s\\n\",\n            static_cast<unsigned>(reader.GetErrorOffset()),\n            GetParseError_En(reader.GetParseErrorCode()));\n    }\n\n    // Check the validation result\n    if (validator.IsValid()) {\n        printf(\"Input JSON is valid.\\n\");\n        return EXIT_SUCCESS;\n    }\n    else {\n        printf(\"Input JSON is invalid.\\n\");\n        StringBuffer sb;\n        validator.GetInvalidSchemaPointer().StringifyUriFragment(sb);\n        fprintf(stderr, \"Invalid schema: %s\\n\", sb.GetString());\n        fprintf(stderr, \"Invalid keyword: %s\\n\", validator.GetInvalidSchemaKeyword());\n        sb.Clear();\n        validator.GetInvalidDocumentPointer().StringifyUriFragment(sb);\n        fprintf(stderr, \"Invalid document: %s\\n\", sb.GetString());\n        return EXIT_FAILURE;\n    }\n}\n"
  },
  {
    "path": "ext/rapidjson/example/serialize/serialize.cpp",
    "content": "// Serialize example\n// This example shows writing JSON string with writer directly.\n\n#include \"rapidjson/prettywriter.h\" // for stringify JSON\n#include <cstdio>\n#include <string>\n#include <vector>\n\nusing namespace rapidjson;\n\nclass Person {\npublic:\n    Person(const std::string& name, unsigned age) : name_(name), age_(age) {}\n    Person(const Person& rhs) : name_(rhs.name_), age_(rhs.age_) {}\n    virtual ~Person();\n\n    Person& operator=(const Person& rhs) {\n        name_ = rhs.name_;\n        age_ = rhs.age_;\n        return *this;\n    }\n\nprotected:\n    template <typename Writer>\n    void Serialize(Writer& writer) const {\n        // This base class just write out name-value pairs, without wrapping within an object.\n        writer.String(\"name\");\n#if RAPIDJSON_HAS_STDSTRING\n        writer.String(name_);\n#else\n        writer.String(name_.c_str(), static_cast<SizeType>(name_.length())); // Supplying length of string is faster.\n#endif\n        writer.String(\"age\");\n        writer.Uint(age_);\n    }\n\nprivate:\n    std::string name_;\n    unsigned age_;\n};\n\nPerson::~Person() {\n}\n\nclass Education {\npublic:\n    Education(const std::string& school, double GPA) : school_(school), GPA_(GPA) {}\n    Education(const Education& rhs) : school_(rhs.school_), GPA_(rhs.GPA_) {}\n\n    template <typename Writer>\n    void Serialize(Writer& writer) const {\n        writer.StartObject();\n        \n        writer.String(\"school\");\n#if RAPIDJSON_HAS_STDSTRING\n        writer.String(school_);\n#else\n        writer.String(school_.c_str(), static_cast<SizeType>(school_.length()));\n#endif\n\n        writer.String(\"GPA\");\n        writer.Double(GPA_);\n\n        writer.EndObject();\n    }\n\nprivate:\n    std::string school_;\n    double GPA_;\n};\n\nclass Dependent : public Person {\npublic:\n    Dependent(const std::string& name, unsigned age, Education* education = 0) : Person(name, age), education_(education) {}\n    Dependent(const Dependent& rhs) : Person(rhs), education_(0) { education_ = (rhs.education_ == 0) ? 0 : new Education(*rhs.education_); }\n    virtual ~Dependent();\n\n    Dependent& operator=(const Dependent& rhs) {\n        if (this == &rhs)\n            return *this;\n        delete education_;\n        education_ = (rhs.education_ == 0) ? 0 : new Education(*rhs.education_);\n        return *this;\n    }\n\n    template <typename Writer>\n    void Serialize(Writer& writer) const {\n        writer.StartObject();\n\n        Person::Serialize(writer);\n\n        writer.String(\"education\");\n        if (education_)\n            education_->Serialize(writer);\n        else\n            writer.Null();\n\n        writer.EndObject();\n    }\n\nprivate:\n\n    Education *education_;\n};\n\nDependent::~Dependent() {\n    delete education_; \n}\n\nclass Employee : public Person {\npublic:\n    Employee(const std::string& name, unsigned age, bool married) : Person(name, age), dependents_(), married_(married) {}\n    Employee(const Employee& rhs) : Person(rhs), dependents_(rhs.dependents_), married_(rhs.married_) {}\n    virtual ~Employee();\n\n    Employee& operator=(const Employee& rhs) {\n        static_cast<Person&>(*this) = rhs;\n        dependents_ = rhs.dependents_;\n        married_ = rhs.married_;\n        return *this;\n    }\n\n    void AddDependent(const Dependent& dependent) {\n        dependents_.push_back(dependent);\n    }\n\n    template <typename Writer>\n    void Serialize(Writer& writer) const {\n        writer.StartObject();\n\n        Person::Serialize(writer);\n\n        writer.String(\"married\");\n        writer.Bool(married_);\n\n        writer.String((\"dependents\"));\n        writer.StartArray();\n        for (std::vector<Dependent>::const_iterator dependentItr = dependents_.begin(); dependentItr != dependents_.end(); ++dependentItr)\n            dependentItr->Serialize(writer);\n        writer.EndArray();\n\n        writer.EndObject();\n    }\n\nprivate:\n    std::vector<Dependent> dependents_;\n    bool married_;\n};\n\nEmployee::~Employee() {\n}\n\nint main(int, char*[]) {\n    std::vector<Employee> employees;\n\n    employees.push_back(Employee(\"Milo YIP\", 34, true));\n    employees.back().AddDependent(Dependent(\"Lua YIP\", 3, new Education(\"Happy Kindergarten\", 3.5)));\n    employees.back().AddDependent(Dependent(\"Mio YIP\", 1));\n\n    employees.push_back(Employee(\"Percy TSE\", 30, false));\n\n    StringBuffer sb;\n    PrettyWriter<StringBuffer> writer(sb);\n\n    writer.StartArray();\n    for (std::vector<Employee>::const_iterator employeeItr = employees.begin(); employeeItr != employees.end(); ++employeeItr)\n        employeeItr->Serialize(writer);\n    writer.EndArray();\n\n    puts(sb.GetString());\n\n    return 0;\n}\n"
  },
  {
    "path": "ext/rapidjson/example/simpledom/simpledom.cpp",
    "content": "// JSON simple example\n// This example does not handle errors.\n\n#include \"rapidjson/document.h\"\n#include \"rapidjson/writer.h\"\n#include \"rapidjson/stringbuffer.h\"\n#include <iostream>\n\nusing namespace rapidjson;\n\nint main() {\n    // 1. Parse a JSON string into DOM.\n    const char* json = \"{\\\"project\\\":\\\"rapidjson\\\",\\\"stars\\\":10}\";\n    Document d;\n    d.Parse(json);\n\n    // 2. Modify it by DOM.\n    Value& s = d[\"stars\"];\n    s.SetInt(s.GetInt() + 1);\n\n    // 3. Stringify the DOM\n    StringBuffer buffer;\n    Writer<StringBuffer> writer(buffer);\n    d.Accept(writer);\n\n    // Output {\"project\":\"rapidjson\",\"stars\":11}\n    std::cout << buffer.GetString() << std::endl;\n    return 0;\n}\n"
  },
  {
    "path": "ext/rapidjson/example/simplereader/simplereader.cpp",
    "content": "#include \"rapidjson/reader.h\"\n#include <iostream>\n\nusing namespace rapidjson;\nusing namespace std;\n\nstruct MyHandler {\n    bool Null() { cout << \"Null()\" << endl; return true; }\n    bool Bool(bool b) { cout << \"Bool(\" << boolalpha << b << \")\" << endl; return true; }\n    bool Int(int i) { cout << \"Int(\" << i << \")\" << endl; return true; }\n    bool Uint(unsigned u) { cout << \"Uint(\" << u << \")\" << endl; return true; }\n    bool Int64(int64_t i) { cout << \"Int64(\" << i << \")\" << endl; return true; }\n    bool Uint64(uint64_t u) { cout << \"Uint64(\" << u << \")\" << endl; return true; }\n    bool Double(double d) { cout << \"Double(\" << d << \")\" << endl; return true; }\n    bool RawNumber(const char* str, SizeType length, bool copy) { \n        cout << \"Number(\" << str << \", \" << length << \", \" << boolalpha << copy << \")\" << endl;\n        return true;\n    }\n    bool String(const char* str, SizeType length, bool copy) { \n        cout << \"String(\" << str << \", \" << length << \", \" << boolalpha << copy << \")\" << endl;\n        return true;\n    }\n    bool StartObject() { cout << \"StartObject()\" << endl; return true; }\n    bool Key(const char* str, SizeType length, bool copy) {\n        cout << \"Key(\" << str << \", \" << length << \", \" << boolalpha << copy << \")\" << endl;\n        return true;\n    }\n    bool EndObject(SizeType memberCount) { cout << \"EndObject(\" << memberCount << \")\" << endl; return true; }\n    bool StartArray() { cout << \"StartArray()\" << endl; return true; }\n    bool EndArray(SizeType elementCount) { cout << \"EndArray(\" << elementCount << \")\" << endl; return true; }\n};\n\nint main() {\n    const char json[] = \" { \\\"hello\\\" : \\\"world\\\", \\\"t\\\" : true , \\\"f\\\" : false, \\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3, 4] } \";\n\n    MyHandler handler;\n    Reader reader;\n    StringStream ss(json);\n    reader.Parse(ss, handler);\n\n    return 0;\n}\n"
  },
  {
    "path": "ext/rapidjson/example/simplewriter/simplewriter.cpp",
    "content": "#include \"rapidjson/writer.h\"\n#include \"rapidjson/stringbuffer.h\"\n#include <iostream>\n\nusing namespace rapidjson;\nusing namespace std;\n\nint main() {\n    StringBuffer s;\n    Writer<StringBuffer> writer(s);\n    \n    writer.StartObject();               // Between StartObject()/EndObject(), \n    writer.Key(\"hello\");                // output a key,\n    writer.String(\"world\");             // follow by a value.\n    writer.Key(\"t\");\n    writer.Bool(true);\n    writer.Key(\"f\");\n    writer.Bool(false);\n    writer.Key(\"n\");\n    writer.Null();\n    writer.Key(\"i\");\n    writer.Uint(123);\n    writer.Key(\"pi\");\n    writer.Double(3.1416);\n    writer.Key(\"a\");\n    writer.StartArray();                // Between StartArray()/EndArray(),\n    for (unsigned i = 0; i < 4; i++)\n        writer.Uint(i);                 // all values are elements of the array.\n    writer.EndArray();\n    writer.EndObject();\n\n    // {\"hello\":\"world\",\"t\":true,\"f\":false,\"n\":null,\"i\":123,\"pi\":3.1416,\"a\":[0,1,2,3]}\n    cout << s.GetString() << endl;\n\n    return 0;\n}\n"
  },
  {
    "path": "ext/rapidjson/example/tutorial/tutorial.cpp",
    "content": "// Hello World example\n// This example shows basic usage of DOM-style API.\n\n#include \"rapidjson/document.h\"     // rapidjson's DOM-style API\n#include \"rapidjson/prettywriter.h\" // for stringify JSON\n#include <cstdio>\n\nusing namespace rapidjson;\nusing namespace std;\n\nint main(int, char*[]) {\n    ////////////////////////////////////////////////////////////////////////////\n    // 1. Parse a JSON text string to a document.\n\n    const char json[] = \" { \\\"hello\\\" : \\\"world\\\", \\\"t\\\" : true , \\\"f\\\" : false, \\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3, 4] } \";\n    printf(\"Original JSON:\\n %s\\n\", json);\n\n    Document document;  // Default template parameter uses UTF8 and MemoryPoolAllocator.\n\n#if 0\n    // \"normal\" parsing, decode strings to new buffers. Can use other input stream via ParseStream().\n    if (document.Parse(json).HasParseError())\n        return 1;\n#else\n    // In-situ parsing, decode strings directly in the source string. Source must be string.\n    char buffer[sizeof(json)];\n    memcpy(buffer, json, sizeof(json));\n    if (document.ParseInsitu(buffer).HasParseError())\n        return 1;\n#endif\n\n    printf(\"\\nParsing to document succeeded.\\n\");\n\n    ////////////////////////////////////////////////////////////////////////////\n    // 2. Access values in document. \n\n    printf(\"\\nAccess values in document:\\n\");\n    assert(document.IsObject());    // Document is a JSON value represents the root of DOM. Root can be either an object or array.\n\n    assert(document.HasMember(\"hello\"));\n    assert(document[\"hello\"].IsString());\n    printf(\"hello = %s\\n\", document[\"hello\"].GetString());\n\n    // Since version 0.2, you can use single lookup to check the existing of member and its value:\n    Value::MemberIterator hello = document.FindMember(\"hello\");\n    assert(hello != document.MemberEnd());\n    assert(hello->value.IsString());\n    assert(strcmp(\"world\", hello->value.GetString()) == 0);\n    (void)hello;\n\n    assert(document[\"t\"].IsBool());     // JSON true/false are bool. Can also uses more specific function IsTrue().\n    printf(\"t = %s\\n\", document[\"t\"].GetBool() ? \"true\" : \"false\");\n\n    assert(document[\"f\"].IsBool());\n    printf(\"f = %s\\n\", document[\"f\"].GetBool() ? \"true\" : \"false\");\n\n    printf(\"n = %s\\n\", document[\"n\"].IsNull() ? \"null\" : \"?\");\n\n    assert(document[\"i\"].IsNumber());   // Number is a JSON type, but C++ needs more specific type.\n    assert(document[\"i\"].IsInt());      // In this case, IsUint()/IsInt64()/IsUInt64() also return true.\n    printf(\"i = %d\\n\", document[\"i\"].GetInt()); // Alternative (int)document[\"i\"]\n\n    assert(document[\"pi\"].IsNumber());\n    assert(document[\"pi\"].IsDouble());\n    printf(\"pi = %g\\n\", document[\"pi\"].GetDouble());\n\n    {\n        const Value& a = document[\"a\"]; // Using a reference for consecutive access is handy and faster.\n        assert(a.IsArray());\n        for (SizeType i = 0; i < a.Size(); i++) // rapidjson uses SizeType instead of size_t.\n            printf(\"a[%d] = %d\\n\", i, a[i].GetInt());\n        \n        int y = a[0].GetInt();\n        (void)y;\n\n        // Iterating array with iterators\n        printf(\"a = \");\n        for (Value::ConstValueIterator itr = a.Begin(); itr != a.End(); ++itr)\n            printf(\"%d \", itr->GetInt());\n        printf(\"\\n\");\n    }\n\n    // Iterating object members\n    static const char* kTypeNames[] = { \"Null\", \"False\", \"True\", \"Object\", \"Array\", \"String\", \"Number\" };\n    for (Value::ConstMemberIterator itr = document.MemberBegin(); itr != document.MemberEnd(); ++itr)\n        printf(\"Type of member %s is %s\\n\", itr->name.GetString(), kTypeNames[itr->value.GetType()]);\n\n    ////////////////////////////////////////////////////////////////////////////\n    // 3. Modify values in document.\n\n    // Change i to a bigger number\n    {\n        uint64_t f20 = 1;   // compute factorial of 20\n        for (uint64_t j = 1; j <= 20; j++)\n            f20 *= j;\n        document[\"i\"] = f20;    // Alternate form: document[\"i\"].SetUint64(f20)\n        assert(!document[\"i\"].IsInt()); // No longer can be cast as int or uint.\n    }\n\n    // Adding values to array.\n    {\n        Value& a = document[\"a\"];   // This time we uses non-const reference.\n        Document::AllocatorType& allocator = document.GetAllocator();\n        for (int i = 5; i <= 10; i++)\n            a.PushBack(i, allocator);   // May look a bit strange, allocator is needed for potentially realloc. We normally uses the document's.\n\n        // Fluent API\n        a.PushBack(\"Lua\", allocator).PushBack(\"Mio\", allocator);\n    }\n\n    // Making string values.\n\n    // This version of SetString() just store the pointer to the string.\n    // So it is for literal and string that exists within value's life-cycle.\n    {\n        document[\"hello\"] = \"rapidjson\";    // This will invoke strlen()\n        // Faster version:\n        // document[\"hello\"].SetString(\"rapidjson\", 9);\n    }\n\n    // This version of SetString() needs an allocator, which means it will allocate a new buffer and copy the the string into the buffer.\n    Value author;\n    {\n        char buffer2[10];\n        int len = sprintf(buffer2, \"%s %s\", \"Milo\", \"Yip\");  // synthetic example of dynamically created string.\n\n        author.SetString(buffer2, static_cast<SizeType>(len), document.GetAllocator());\n        // Shorter but slower version:\n        // document[\"hello\"].SetString(buffer, document.GetAllocator());\n\n        // Constructor version: \n        // Value author(buffer, len, document.GetAllocator());\n        // Value author(buffer, document.GetAllocator());\n        memset(buffer2, 0, sizeof(buffer2)); // For demonstration purpose.\n    }\n    // Variable 'buffer' is unusable now but 'author' has already made a copy.\n    document.AddMember(\"author\", author, document.GetAllocator());\n\n    assert(author.IsNull());        // Move semantic for assignment. After this variable is assigned as a member, the variable becomes null.\n\n    ////////////////////////////////////////////////////////////////////////////\n    // 4. Stringify JSON\n\n    printf(\"\\nModified JSON with reformatting:\\n\");\n    StringBuffer sb;\n    PrettyWriter<StringBuffer> writer(sb);\n    document.Accept(writer);    // Accept() traverses the DOM and generates Handler events.\n    puts(sb.GetString());\n\n    return 0;\n}\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/allocators.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_ALLOCATORS_H_\n#define RAPIDJSON_ALLOCATORS_H_\n\n#include \"rapidjson.h\"\n\nRAPIDJSON_NAMESPACE_BEGIN\n\n///////////////////////////////////////////////////////////////////////////////\n// Allocator\n\n/*! \\class rapidjson::Allocator\n    \\brief Concept for allocating, resizing and freeing memory block.\n    \n    Note that Malloc() and Realloc() are non-static but Free() is static.\n    \n    So if an allocator need to support Free(), it needs to put its pointer in \n    the header of memory block.\n\n\\code\nconcept Allocator {\n    static const bool kNeedFree;    //!< Whether this allocator needs to call Free().\n\n    // Allocate a memory block.\n    // \\param size of the memory block in bytes.\n    // \\returns pointer to the memory block.\n    void* Malloc(size_t size);\n\n    // Resize a memory block.\n    // \\param originalPtr The pointer to current memory block. Null pointer is permitted.\n    // \\param originalSize The current size in bytes. (Design issue: since some allocator may not book-keep this, explicitly pass to it can save memory.)\n    // \\param newSize the new size in bytes.\n    void* Realloc(void* originalPtr, size_t originalSize, size_t newSize);\n\n    // Free a memory block.\n    // \\param pointer to the memory block. Null pointer is permitted.\n    static void Free(void *ptr);\n};\n\\endcode\n*/\n\n///////////////////////////////////////////////////////////////////////////////\n// CrtAllocator\n\n//! C-runtime library allocator.\n/*! This class is just wrapper for standard C library memory routines.\n    \\note implements Allocator concept\n*/\nclass CrtAllocator {\npublic:\n    static const bool kNeedFree = true;\n    void* Malloc(size_t size) { \n        if (size) //  behavior of malloc(0) is implementation defined.\n            return std::malloc(size);\n        else\n            return NULL; // standardize to returning NULL.\n    }\n    void* Realloc(void* originalPtr, size_t originalSize, size_t newSize) {\n        (void)originalSize;\n        if (newSize == 0) {\n            std::free(originalPtr);\n            return NULL;\n        }\n        return std::realloc(originalPtr, newSize);\n    }\n    static void Free(void *ptr) { std::free(ptr); }\n};\n\n///////////////////////////////////////////////////////////////////////////////\n// MemoryPoolAllocator\n\n//! Default memory allocator used by the parser and DOM.\n/*! This allocator allocate memory blocks from pre-allocated memory chunks. \n\n    It does not free memory blocks. And Realloc() only allocate new memory.\n\n    The memory chunks are allocated by BaseAllocator, which is CrtAllocator by default.\n\n    User may also supply a buffer as the first chunk.\n\n    If the user-buffer is full then additional chunks are allocated by BaseAllocator.\n\n    The user-buffer is not deallocated by this allocator.\n\n    \\tparam BaseAllocator the allocator type for allocating memory chunks. Default is CrtAllocator.\n    \\note implements Allocator concept\n*/\ntemplate <typename BaseAllocator = CrtAllocator>\nclass MemoryPoolAllocator {\npublic:\n    static const bool kNeedFree = false;    //!< Tell users that no need to call Free() with this allocator. (concept Allocator)\n\n    //! Constructor with chunkSize.\n    /*! \\param chunkSize The size of memory chunk. The default is kDefaultChunkSize.\n        \\param baseAllocator The allocator for allocating memory chunks.\n    */\n    MemoryPoolAllocator(size_t chunkSize = kDefaultChunkCapacity, BaseAllocator* baseAllocator = 0) : \n        chunkHead_(0), chunk_capacity_(chunkSize), userBuffer_(0), baseAllocator_(baseAllocator), ownBaseAllocator_(0)\n    {\n    }\n\n    //! Constructor with user-supplied buffer.\n    /*! The user buffer will be used firstly. When it is full, memory pool allocates new chunk with chunk size.\n\n        The user buffer will not be deallocated when this allocator is destructed.\n\n        \\param buffer User supplied buffer.\n        \\param size Size of the buffer in bytes. It must at least larger than sizeof(ChunkHeader).\n        \\param chunkSize The size of memory chunk. The default is kDefaultChunkSize.\n        \\param baseAllocator The allocator for allocating memory chunks.\n    */\n    MemoryPoolAllocator(void *buffer, size_t size, size_t chunkSize = kDefaultChunkCapacity, BaseAllocator* baseAllocator = 0) :\n        chunkHead_(0), chunk_capacity_(chunkSize), userBuffer_(buffer), baseAllocator_(baseAllocator), ownBaseAllocator_(0)\n    {\n        RAPIDJSON_ASSERT(buffer != 0);\n        RAPIDJSON_ASSERT(size > sizeof(ChunkHeader));\n        chunkHead_ = reinterpret_cast<ChunkHeader*>(buffer);\n        chunkHead_->capacity = size - sizeof(ChunkHeader);\n        chunkHead_->size = 0;\n        chunkHead_->next = 0;\n    }\n\n    //! Destructor.\n    /*! This deallocates all memory chunks, excluding the user-supplied buffer.\n    */\n    ~MemoryPoolAllocator() {\n        Clear();\n        RAPIDJSON_DELETE(ownBaseAllocator_);\n    }\n\n    //! Deallocates all memory chunks, excluding the user-supplied buffer.\n    void Clear() {\n        while (chunkHead_ && chunkHead_ != userBuffer_) {\n            ChunkHeader* next = chunkHead_->next;\n            baseAllocator_->Free(chunkHead_);\n            chunkHead_ = next;\n        }\n        if (chunkHead_ && chunkHead_ == userBuffer_)\n            chunkHead_->size = 0; // Clear user buffer\n    }\n\n    //! Computes the total capacity of allocated memory chunks.\n    /*! \\return total capacity in bytes.\n    */\n    size_t Capacity() const {\n        size_t capacity = 0;\n        for (ChunkHeader* c = chunkHead_; c != 0; c = c->next)\n            capacity += c->capacity;\n        return capacity;\n    }\n\n    //! Computes the memory blocks allocated.\n    /*! \\return total used bytes.\n    */\n    size_t Size() const {\n        size_t size = 0;\n        for (ChunkHeader* c = chunkHead_; c != 0; c = c->next)\n            size += c->size;\n        return size;\n    }\n\n    //! Allocates a memory block. (concept Allocator)\n    void* Malloc(size_t size) {\n        if (!size)\n            return NULL;\n\n        size = RAPIDJSON_ALIGN(size);\n        if (chunkHead_ == 0 || chunkHead_->size + size > chunkHead_->capacity)\n            if (!AddChunk(chunk_capacity_ > size ? chunk_capacity_ : size))\n                return NULL;\n\n        void *buffer = reinterpret_cast<char *>(chunkHead_) + RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + chunkHead_->size;\n        chunkHead_->size += size;\n        return buffer;\n    }\n\n    //! Resizes a memory block (concept Allocator)\n    void* Realloc(void* originalPtr, size_t originalSize, size_t newSize) {\n        if (originalPtr == 0)\n            return Malloc(newSize);\n\n        if (newSize == 0)\n            return NULL;\n\n        originalSize = RAPIDJSON_ALIGN(originalSize);\n        newSize = RAPIDJSON_ALIGN(newSize);\n\n        // Do not shrink if new size is smaller than original\n        if (originalSize >= newSize)\n            return originalPtr;\n\n        // Simply expand it if it is the last allocation and there is sufficient space\n        if (originalPtr == reinterpret_cast<char *>(chunkHead_) + RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + chunkHead_->size - originalSize) {\n            size_t increment = static_cast<size_t>(newSize - originalSize);\n            if (chunkHead_->size + increment <= chunkHead_->capacity) {\n                chunkHead_->size += increment;\n                return originalPtr;\n            }\n        }\n\n        // Realloc process: allocate and copy memory, do not free original buffer.\n        if (void* newBuffer = Malloc(newSize)) {\n            if (originalSize)\n                std::memcpy(newBuffer, originalPtr, originalSize);\n            return newBuffer;\n        }\n        else\n            return NULL;\n    }\n\n    //! Frees a memory block (concept Allocator)\n    static void Free(void *ptr) { (void)ptr; } // Do nothing\n\nprivate:\n    //! Copy constructor is not permitted.\n    MemoryPoolAllocator(const MemoryPoolAllocator& rhs) /* = delete */;\n    //! Copy assignment operator is not permitted.\n    MemoryPoolAllocator& operator=(const MemoryPoolAllocator& rhs) /* = delete */;\n\n    //! Creates a new chunk.\n    /*! \\param capacity Capacity of the chunk in bytes.\n        \\return true if success.\n    */\n    bool AddChunk(size_t capacity) {\n        if (!baseAllocator_)\n            ownBaseAllocator_ = baseAllocator_ = RAPIDJSON_NEW(BaseAllocator());\n        if (ChunkHeader* chunk = reinterpret_cast<ChunkHeader*>(baseAllocator_->Malloc(RAPIDJSON_ALIGN(sizeof(ChunkHeader)) + capacity))) {\n            chunk->capacity = capacity;\n            chunk->size = 0;\n            chunk->next = chunkHead_;\n            chunkHead_ =  chunk;\n            return true;\n        }\n        else\n            return false;\n    }\n\n    static const int kDefaultChunkCapacity = 64 * 1024; //!< Default chunk capacity.\n\n    //! Chunk header for perpending to each chunk.\n    /*! Chunks are stored as a singly linked list.\n    */\n    struct ChunkHeader {\n        size_t capacity;    //!< Capacity of the chunk in bytes (excluding the header itself).\n        size_t size;        //!< Current size of allocated memory in bytes.\n        ChunkHeader *next;  //!< Next chunk in the linked list.\n    };\n\n    ChunkHeader *chunkHead_;    //!< Head of the chunk linked-list. Only the head chunk serves allocation.\n    size_t chunk_capacity_;     //!< The minimum capacity of chunk when they are allocated.\n    void *userBuffer_;          //!< User supplied buffer.\n    BaseAllocator* baseAllocator_;  //!< base allocator for allocating memory chunks.\n    BaseAllocator* ownBaseAllocator_;   //!< base allocator created by this object.\n};\n\nRAPIDJSON_NAMESPACE_END\n\n#endif // RAPIDJSON_ENCODINGS_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/document.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_DOCUMENT_H_\n#define RAPIDJSON_DOCUMENT_H_\n\n/*! \\file document.h */\n\n#include \"reader.h\"\n#include \"internal/meta.h\"\n#include \"internal/strfunc.h\"\n#include \"memorystream.h\"\n#include \"encodedstream.h\"\n#include <new>      // placement new\n#include <limits>\n\nRAPIDJSON_DIAG_PUSH\n#ifdef _MSC_VER\nRAPIDJSON_DIAG_OFF(4127) // conditional expression is constant\nRAPIDJSON_DIAG_OFF(4244) // conversion from kXxxFlags to 'uint16_t', possible loss of data\n#endif\n\n#ifdef __clang__\nRAPIDJSON_DIAG_OFF(padded)\nRAPIDJSON_DIAG_OFF(switch-enum)\nRAPIDJSON_DIAG_OFF(c++98-compat)\n#endif\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_OFF(effc++)\n#if __GNUC__ >= 6\nRAPIDJSON_DIAG_OFF(terminate) // ignore throwing RAPIDJSON_ASSERT in RAPIDJSON_NOEXCEPT functions\n#endif\n#endif // __GNUC__\n\n#ifndef RAPIDJSON_NOMEMBERITERATORCLASS\n#include <iterator> // std::iterator, std::random_access_iterator_tag\n#endif\n\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\n#include <utility> // std::move\n#endif\n\nRAPIDJSON_NAMESPACE_BEGIN\n\n// Forward declaration.\ntemplate <typename Encoding, typename Allocator>\nclass GenericValue;\n\ntemplate <typename Encoding, typename Allocator, typename StackAllocator>\nclass GenericDocument;\n\n//! Name-value pair in a JSON object value.\n/*!\n    This class was internal to GenericValue. It used to be a inner struct.\n    But a compiler (IBM XL C/C++ for AIX) have reported to have problem with that so it moved as a namespace scope struct.\n    https://code.google.com/p/rapidjson/issues/detail?id=64\n*/\ntemplate <typename Encoding, typename Allocator> \nstruct GenericMember { \n    GenericValue<Encoding, Allocator> name;     //!< name of member (must be a string)\n    GenericValue<Encoding, Allocator> value;    //!< value of member.\n};\n\n///////////////////////////////////////////////////////////////////////////////\n// GenericMemberIterator\n\n#ifndef RAPIDJSON_NOMEMBERITERATORCLASS\n\n//! (Constant) member iterator for a JSON object value\n/*!\n    \\tparam Const Is this a constant iterator?\n    \\tparam Encoding    Encoding of the value. (Even non-string values need to have the same encoding in a document)\n    \\tparam Allocator   Allocator type for allocating memory of object, array and string.\n\n    This class implements a Random Access Iterator for GenericMember elements\n    of a GenericValue, see ISO/IEC 14882:2003(E) C++ standard, 24.1 [lib.iterator.requirements].\n\n    \\note This iterator implementation is mainly intended to avoid implicit\n        conversions from iterator values to \\c NULL,\n        e.g. from GenericValue::FindMember.\n\n    \\note Define \\c RAPIDJSON_NOMEMBERITERATORCLASS to fall back to a\n        pointer-based implementation, if your platform doesn't provide\n        the C++ <iterator> header.\n\n    \\see GenericMember, GenericValue::MemberIterator, GenericValue::ConstMemberIterator\n */\ntemplate <bool Const, typename Encoding, typename Allocator>\nclass GenericMemberIterator\n    : public std::iterator<std::random_access_iterator_tag\n        , typename internal::MaybeAddConst<Const,GenericMember<Encoding,Allocator> >::Type> {\n\n    friend class GenericValue<Encoding,Allocator>;\n    template <bool, typename, typename> friend class GenericMemberIterator;\n\n    typedef GenericMember<Encoding,Allocator> PlainType;\n    typedef typename internal::MaybeAddConst<Const,PlainType>::Type ValueType;\n    typedef std::iterator<std::random_access_iterator_tag,ValueType> BaseType;\n\npublic:\n    //! Iterator type itself\n    typedef GenericMemberIterator Iterator;\n    //! Constant iterator type\n    typedef GenericMemberIterator<true,Encoding,Allocator>  ConstIterator;\n    //! Non-constant iterator type\n    typedef GenericMemberIterator<false,Encoding,Allocator> NonConstIterator;\n\n    //! Pointer to (const) GenericMember\n    typedef typename BaseType::pointer         Pointer;\n    //! Reference to (const) GenericMember\n    typedef typename BaseType::reference       Reference;\n    //! Signed integer type (e.g. \\c ptrdiff_t)\n    typedef typename BaseType::difference_type DifferenceType;\n\n    //! Default constructor (singular value)\n    /*! Creates an iterator pointing to no element.\n        \\note All operations, except for comparisons, are undefined on such values.\n     */\n    GenericMemberIterator() : ptr_() {}\n\n    //! Iterator conversions to more const\n    /*!\n        \\param it (Non-const) iterator to copy from\n\n        Allows the creation of an iterator from another GenericMemberIterator\n        that is \"less const\".  Especially, creating a non-constant iterator\n        from a constant iterator are disabled:\n        \\li const -> non-const (not ok)\n        \\li const -> const (ok)\n        \\li non-const -> const (ok)\n        \\li non-const -> non-const (ok)\n\n        \\note If the \\c Const template parameter is already \\c false, this\n            constructor effectively defines a regular copy-constructor.\n            Otherwise, the copy constructor is implicitly defined.\n    */\n    GenericMemberIterator(const NonConstIterator & it) : ptr_(it.ptr_) {}\n    Iterator& operator=(const NonConstIterator & it) { ptr_ = it.ptr_; return *this; }\n\n    //! @name stepping\n    //@{\n    Iterator& operator++(){ ++ptr_; return *this; }\n    Iterator& operator--(){ --ptr_; return *this; }\n    Iterator  operator++(int){ Iterator old(*this); ++ptr_; return old; }\n    Iterator  operator--(int){ Iterator old(*this); --ptr_; return old; }\n    //@}\n\n    //! @name increment/decrement\n    //@{\n    Iterator operator+(DifferenceType n) const { return Iterator(ptr_+n); }\n    Iterator operator-(DifferenceType n) const { return Iterator(ptr_-n); }\n\n    Iterator& operator+=(DifferenceType n) { ptr_+=n; return *this; }\n    Iterator& operator-=(DifferenceType n) { ptr_-=n; return *this; }\n    //@}\n\n    //! @name relations\n    //@{\n    bool operator==(ConstIterator that) const { return ptr_ == that.ptr_; }\n    bool operator!=(ConstIterator that) const { return ptr_ != that.ptr_; }\n    bool operator<=(ConstIterator that) const { return ptr_ <= that.ptr_; }\n    bool operator>=(ConstIterator that) const { return ptr_ >= that.ptr_; }\n    bool operator< (ConstIterator that) const { return ptr_ < that.ptr_; }\n    bool operator> (ConstIterator that) const { return ptr_ > that.ptr_; }\n    //@}\n\n    //! @name dereference\n    //@{\n    Reference operator*() const { return *ptr_; }\n    Pointer   operator->() const { return ptr_; }\n    Reference operator[](DifferenceType n) const { return ptr_[n]; }\n    //@}\n\n    //! Distance\n    DifferenceType operator-(ConstIterator that) const { return ptr_-that.ptr_; }\n\nprivate:\n    //! Internal constructor from plain pointer\n    explicit GenericMemberIterator(Pointer p) : ptr_(p) {}\n\n    Pointer ptr_; //!< raw pointer\n};\n\n#else // RAPIDJSON_NOMEMBERITERATORCLASS\n\n// class-based member iterator implementation disabled, use plain pointers\n\ntemplate <bool Const, typename Encoding, typename Allocator>\nstruct GenericMemberIterator;\n\n//! non-const GenericMemberIterator\ntemplate <typename Encoding, typename Allocator>\nstruct GenericMemberIterator<false,Encoding,Allocator> {\n    //! use plain pointer as iterator type\n    typedef GenericMember<Encoding,Allocator>* Iterator;\n};\n//! const GenericMemberIterator\ntemplate <typename Encoding, typename Allocator>\nstruct GenericMemberIterator<true,Encoding,Allocator> {\n    //! use plain const pointer as iterator type\n    typedef const GenericMember<Encoding,Allocator>* Iterator;\n};\n\n#endif // RAPIDJSON_NOMEMBERITERATORCLASS\n\n///////////////////////////////////////////////////////////////////////////////\n// GenericStringRef\n\n//! Reference to a constant string (not taking a copy)\n/*!\n    \\tparam CharType character type of the string\n\n    This helper class is used to automatically infer constant string\n    references for string literals, especially from \\c const \\b (!)\n    character arrays.\n\n    The main use is for creating JSON string values without copying the\n    source string via an \\ref Allocator.  This requires that the referenced\n    string pointers have a sufficient lifetime, which exceeds the lifetime\n    of the associated GenericValue.\n\n    \\b Example\n    \\code\n    Value v(\"foo\");   // ok, no need to copy & calculate length\n    const char foo[] = \"foo\";\n    v.SetString(foo); // ok\n\n    const char* bar = foo;\n    // Value x(bar); // not ok, can't rely on bar's lifetime\n    Value x(StringRef(bar)); // lifetime explicitly guaranteed by user\n    Value y(StringRef(bar, 3));  // ok, explicitly pass length\n    \\endcode\n\n    \\see StringRef, GenericValue::SetString\n*/\ntemplate<typename CharType>\nstruct GenericStringRef {\n    typedef CharType Ch; //!< character type of the string\n\n    //! Create string reference from \\c const character array\n#ifndef __clang__ // -Wdocumentation\n    /*!\n        This constructor implicitly creates a constant string reference from\n        a \\c const character array.  It has better performance than\n        \\ref StringRef(const CharType*) by inferring the string \\ref length\n        from the array length, and also supports strings containing null\n        characters.\n\n        \\tparam N length of the string, automatically inferred\n\n        \\param str Constant character array, lifetime assumed to be longer\n            than the use of the string in e.g. a GenericValue\n\n        \\post \\ref s == str\n\n        \\note Constant complexity.\n        \\note There is a hidden, private overload to disallow references to\n            non-const character arrays to be created via this constructor.\n            By this, e.g. function-scope arrays used to be filled via\n            \\c snprintf are excluded from consideration.\n            In such cases, the referenced string should be \\b copied to the\n            GenericValue instead.\n     */\n#endif\n    template<SizeType N>\n    GenericStringRef(const CharType (&str)[N]) RAPIDJSON_NOEXCEPT\n        : s(str), length(N-1) {}\n\n    //! Explicitly create string reference from \\c const character pointer\n#ifndef __clang__ // -Wdocumentation\n    /*!\n        This constructor can be used to \\b explicitly  create a reference to\n        a constant string pointer.\n\n        \\see StringRef(const CharType*)\n\n        \\param str Constant character pointer, lifetime assumed to be longer\n            than the use of the string in e.g. a GenericValue\n\n        \\post \\ref s == str\n\n        \\note There is a hidden, private overload to disallow references to\n            non-const character arrays to be created via this constructor.\n            By this, e.g. function-scope arrays used to be filled via\n            \\c snprintf are excluded from consideration.\n            In such cases, the referenced string should be \\b copied to the\n            GenericValue instead.\n     */\n#endif\n    explicit GenericStringRef(const CharType* str)\n        : s(str), length(internal::StrLen(str)){ RAPIDJSON_ASSERT(s != 0); }\n\n    //! Create constant string reference from pointer and length\n#ifndef __clang__ // -Wdocumentation\n    /*! \\param str constant string, lifetime assumed to be longer than the use of the string in e.g. a GenericValue\n        \\param len length of the string, excluding the trailing NULL terminator\n\n        \\post \\ref s == str && \\ref length == len\n        \\note Constant complexity.\n     */\n#endif\n    GenericStringRef(const CharType* str, SizeType len)\n        : s(str), length(len) { RAPIDJSON_ASSERT(s != 0); }\n\n    GenericStringRef(const GenericStringRef& rhs) : s(rhs.s), length(rhs.length) {}\n\n    GenericStringRef& operator=(const GenericStringRef& rhs) { s = rhs.s; length = rhs.length; }\n\n    //! implicit conversion to plain CharType pointer\n    operator const Ch *() const { return s; }\n\n    const Ch* const s; //!< plain CharType pointer\n    const SizeType length; //!< length of the string (excluding the trailing NULL terminator)\n\nprivate:\n    //! Disallow construction from non-const array\n    template<SizeType N>\n    GenericStringRef(CharType (&str)[N]) /* = delete */;\n};\n\n//! Mark a character pointer as constant string\n/*! Mark a plain character pointer as a \"string literal\".  This function\n    can be used to avoid copying a character string to be referenced as a\n    value in a JSON GenericValue object, if the string's lifetime is known\n    to be valid long enough.\n    \\tparam CharType Character type of the string\n    \\param str Constant string, lifetime assumed to be longer than the use of the string in e.g. a GenericValue\n    \\return GenericStringRef string reference object\n    \\relatesalso GenericStringRef\n\n    \\see GenericValue::GenericValue(StringRefType), GenericValue::operator=(StringRefType), GenericValue::SetString(StringRefType), GenericValue::PushBack(StringRefType, Allocator&), GenericValue::AddMember\n*/\ntemplate<typename CharType>\ninline GenericStringRef<CharType> StringRef(const CharType* str) {\n    return GenericStringRef<CharType>(str, internal::StrLen(str));\n}\n\n//! Mark a character pointer as constant string\n/*! Mark a plain character pointer as a \"string literal\".  This function\n    can be used to avoid copying a character string to be referenced as a\n    value in a JSON GenericValue object, if the string's lifetime is known\n    to be valid long enough.\n\n    This version has better performance with supplied length, and also\n    supports string containing null characters.\n\n    \\tparam CharType character type of the string\n    \\param str Constant string, lifetime assumed to be longer than the use of the string in e.g. a GenericValue\n    \\param length The length of source string.\n    \\return GenericStringRef string reference object\n    \\relatesalso GenericStringRef\n*/\ntemplate<typename CharType>\ninline GenericStringRef<CharType> StringRef(const CharType* str, size_t length) {\n    return GenericStringRef<CharType>(str, SizeType(length));\n}\n\n#if RAPIDJSON_HAS_STDSTRING\n//! Mark a string object as constant string\n/*! Mark a string object (e.g. \\c std::string) as a \"string literal\".\n    This function can be used to avoid copying a string to be referenced as a\n    value in a JSON GenericValue object, if the string's lifetime is known\n    to be valid long enough.\n\n    \\tparam CharType character type of the string\n    \\param str Constant string, lifetime assumed to be longer than the use of the string in e.g. a GenericValue\n    \\return GenericStringRef string reference object\n    \\relatesalso GenericStringRef\n    \\note Requires the definition of the preprocessor symbol \\ref RAPIDJSON_HAS_STDSTRING.\n*/\ntemplate<typename CharType>\ninline GenericStringRef<CharType> StringRef(const std::basic_string<CharType>& str) {\n    return GenericStringRef<CharType>(str.data(), SizeType(str.size()));\n}\n#endif\n\n///////////////////////////////////////////////////////////////////////////////\n// GenericValue type traits\nnamespace internal {\n\ntemplate <typename T, typename Encoding = void, typename Allocator = void>\nstruct IsGenericValueImpl : FalseType {};\n\n// select candidates according to nested encoding and allocator types\ntemplate <typename T> struct IsGenericValueImpl<T, typename Void<typename T::EncodingType>::Type, typename Void<typename T::AllocatorType>::Type>\n    : IsBaseOf<GenericValue<typename T::EncodingType, typename T::AllocatorType>, T>::Type {};\n\n// helper to match arbitrary GenericValue instantiations, including derived classes\ntemplate <typename T> struct IsGenericValue : IsGenericValueImpl<T>::Type {};\n\n} // namespace internal\n\n///////////////////////////////////////////////////////////////////////////////\n// TypeHelper\n\nnamespace internal {\n\ntemplate <typename ValueType, typename T>\nstruct TypeHelper {};\n\ntemplate<typename ValueType> \nstruct TypeHelper<ValueType, bool> {\n    static bool Is(const ValueType& v) { return v.IsBool(); }\n    static bool Get(const ValueType& v) { return v.GetBool(); }\n    static ValueType& Set(ValueType& v, bool data) { return v.SetBool(data); }\n    static ValueType& Set(ValueType& v, bool data, typename ValueType::AllocatorType&) { return v.SetBool(data); }\n};\n\ntemplate<typename ValueType> \nstruct TypeHelper<ValueType, int> {\n    static bool Is(const ValueType& v) { return v.IsInt(); }\n    static int Get(const ValueType& v) { return v.GetInt(); }\n    static ValueType& Set(ValueType& v, int data) { return v.SetInt(data); }\n    static ValueType& Set(ValueType& v, int data, typename ValueType::AllocatorType&) { return v.SetInt(data); }\n};\n\ntemplate<typename ValueType> \nstruct TypeHelper<ValueType, unsigned> {\n    static bool Is(const ValueType& v) { return v.IsUint(); }\n    static unsigned Get(const ValueType& v) { return v.GetUint(); }\n    static ValueType& Set(ValueType& v, unsigned data) { return v.SetUint(data); }\n    static ValueType& Set(ValueType& v, unsigned data, typename ValueType::AllocatorType&) { return v.SetUint(data); }\n};\n\ntemplate<typename ValueType> \nstruct TypeHelper<ValueType, int64_t> {\n    static bool Is(const ValueType& v) { return v.IsInt64(); }\n    static int64_t Get(const ValueType& v) { return v.GetInt64(); }\n    static ValueType& Set(ValueType& v, int64_t data) { return v.SetInt64(data); }\n    static ValueType& Set(ValueType& v, int64_t data, typename ValueType::AllocatorType&) { return v.SetInt64(data); }\n};\n\ntemplate<typename ValueType> \nstruct TypeHelper<ValueType, uint64_t> {\n    static bool Is(const ValueType& v) { return v.IsUint64(); }\n    static uint64_t Get(const ValueType& v) { return v.GetUint64(); }\n    static ValueType& Set(ValueType& v, uint64_t data) { return v.SetUint64(data); }\n    static ValueType& Set(ValueType& v, uint64_t data, typename ValueType::AllocatorType&) { return v.SetUint64(data); }\n};\n\ntemplate<typename ValueType> \nstruct TypeHelper<ValueType, double> {\n    static bool Is(const ValueType& v) { return v.IsDouble(); }\n    static double Get(const ValueType& v) { return v.GetDouble(); }\n    static ValueType& Set(ValueType& v, double data) { return v.SetDouble(data); }\n    static ValueType& Set(ValueType& v, double data, typename ValueType::AllocatorType&) { return v.SetDouble(data); }\n};\n\ntemplate<typename ValueType> \nstruct TypeHelper<ValueType, float> {\n    static bool Is(const ValueType& v) { return v.IsFloat(); }\n    static float Get(const ValueType& v) { return v.GetFloat(); }\n    static ValueType& Set(ValueType& v, float data) { return v.SetFloat(data); }\n    static ValueType& Set(ValueType& v, float data, typename ValueType::AllocatorType&) { return v.SetFloat(data); }\n};\n\ntemplate<typename ValueType> \nstruct TypeHelper<ValueType, const typename ValueType::Ch*> {\n    typedef const typename ValueType::Ch* StringType;\n    static bool Is(const ValueType& v) { return v.IsString(); }\n    static StringType Get(const ValueType& v) { return v.GetString(); }\n    static ValueType& Set(ValueType& v, const StringType data) { return v.SetString(typename ValueType::StringRefType(data)); }\n    static ValueType& Set(ValueType& v, const StringType data, typename ValueType::AllocatorType& a) { return v.SetString(data, a); }\n};\n\n#if RAPIDJSON_HAS_STDSTRING\ntemplate<typename ValueType> \nstruct TypeHelper<ValueType, std::basic_string<typename ValueType::Ch> > {\n    typedef std::basic_string<typename ValueType::Ch> StringType;\n    static bool Is(const ValueType& v) { return v.IsString(); }\n    static StringType Get(const ValueType& v) { return StringType(v.GetString(), v.GetStringLength()); }\n    static ValueType& Set(ValueType& v, const StringType& data, typename ValueType::AllocatorType& a) { return v.SetString(data, a); }\n};\n#endif\n\ntemplate<typename ValueType> \nstruct TypeHelper<ValueType, typename ValueType::Array> {\n    typedef typename ValueType::Array ArrayType;\n    static bool Is(const ValueType& v) { return v.IsArray(); }\n    static ArrayType Get(ValueType& v) { return v.GetArray(); }\n    static ValueType& Set(ValueType& v, ArrayType data) { return v = data; }\n    static ValueType& Set(ValueType& v, ArrayType data, typename ValueType::AllocatorType&) { return v = data; }\n};\n\ntemplate<typename ValueType> \nstruct TypeHelper<ValueType, typename ValueType::ConstArray> {\n    typedef typename ValueType::ConstArray ArrayType;\n    static bool Is(const ValueType& v) { return v.IsArray(); }\n    static ArrayType Get(const ValueType& v) { return v.GetArray(); }\n};\n\ntemplate<typename ValueType> \nstruct TypeHelper<ValueType, typename ValueType::Object> {\n    typedef typename ValueType::Object ObjectType;\n    static bool Is(const ValueType& v) { return v.IsObject(); }\n    static ObjectType Get(ValueType& v) { return v.GetObject(); }\n    static ValueType& Set(ValueType& v, ObjectType data) { return v = data; }\n    static ValueType& Set(ValueType& v, ObjectType data, typename ValueType::AllocatorType&) { v = data; }\n};\n\ntemplate<typename ValueType> \nstruct TypeHelper<ValueType, typename ValueType::ConstObject> {\n    typedef typename ValueType::ConstObject ObjectType;\n    static bool Is(const ValueType& v) { return v.IsObject(); }\n    static ObjectType Get(const ValueType& v) { return v.GetObject(); }\n};\n\n} // namespace internal\n\n// Forward declarations\ntemplate <bool, typename> class GenericArray;\ntemplate <bool, typename> class GenericObject;\n\n///////////////////////////////////////////////////////////////////////////////\n// GenericValue\n\n//! Represents a JSON value. Use Value for UTF8 encoding and default allocator.\n/*!\n    A JSON value can be one of 7 types. This class is a variant type supporting\n    these types.\n\n    Use the Value if UTF8 and default allocator\n\n    \\tparam Encoding    Encoding of the value. (Even non-string values need to have the same encoding in a document)\n    \\tparam Allocator   Allocator type for allocating memory of object, array and string.\n*/\ntemplate <typename Encoding, typename Allocator = MemoryPoolAllocator<> > \nclass GenericValue {\npublic:\n    //! Name-value pair in an object.\n    typedef GenericMember<Encoding, Allocator> Member;\n    typedef Encoding EncodingType;                  //!< Encoding type from template parameter.\n    typedef Allocator AllocatorType;                //!< Allocator type from template parameter.\n    typedef typename Encoding::Ch Ch;               //!< Character type derived from Encoding.\n    typedef GenericStringRef<Ch> StringRefType;     //!< Reference to a constant string\n    typedef typename GenericMemberIterator<false,Encoding,Allocator>::Iterator MemberIterator;  //!< Member iterator for iterating in object.\n    typedef typename GenericMemberIterator<true,Encoding,Allocator>::Iterator ConstMemberIterator;  //!< Constant member iterator for iterating in object.\n    typedef GenericValue* ValueIterator;            //!< Value iterator for iterating in array.\n    typedef const GenericValue* ConstValueIterator; //!< Constant value iterator for iterating in array.\n    typedef GenericValue<Encoding, Allocator> ValueType;    //!< Value type of itself.\n    typedef GenericArray<false, ValueType> Array;\n    typedef GenericArray<true, ValueType> ConstArray;\n    typedef GenericObject<false, ValueType> Object;\n    typedef GenericObject<true, ValueType> ConstObject;\n\n    //!@name Constructors and destructor.\n    //@{\n\n    //! Default constructor creates a null value.\n    GenericValue() RAPIDJSON_NOEXCEPT : data_() { data_.f.flags = kNullFlag; }\n\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\n    //! Move constructor in C++11\n    GenericValue(GenericValue&& rhs) RAPIDJSON_NOEXCEPT : data_(rhs.data_) {\n        rhs.data_.f.flags = kNullFlag; // give up contents\n    }\n#endif\n\nprivate:\n    //! Copy constructor is not permitted.\n    GenericValue(const GenericValue& rhs);\n\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\n    //! Moving from a GenericDocument is not permitted.\n    template <typename StackAllocator>\n    GenericValue(GenericDocument<Encoding,Allocator,StackAllocator>&& rhs);\n\n    //! Move assignment from a GenericDocument is not permitted.\n    template <typename StackAllocator>\n    GenericValue& operator=(GenericDocument<Encoding,Allocator,StackAllocator>&& rhs);\n#endif\n\npublic:\n\n    //! Constructor with JSON value type.\n    /*! This creates a Value of specified type with default content.\n        \\param type Type of the value.\n        \\note Default content for number is zero.\n    */\n    explicit GenericValue(Type type) RAPIDJSON_NOEXCEPT : data_() {\n        static const uint16_t defaultFlags[7] = {\n            kNullFlag, kFalseFlag, kTrueFlag, kObjectFlag, kArrayFlag, kShortStringFlag,\n            kNumberAnyFlag\n        };\n        RAPIDJSON_ASSERT(type <= kNumberType);\n        data_.f.flags = defaultFlags[type];\n\n        // Use ShortString to store empty string.\n        if (type == kStringType)\n            data_.ss.SetLength(0);\n    }\n\n    //! Explicit copy constructor (with allocator)\n    /*! Creates a copy of a Value by using the given Allocator\n        \\tparam SourceAllocator allocator of \\c rhs\n        \\param rhs Value to copy from (read-only)\n        \\param allocator Allocator for allocating copied elements and buffers. Commonly use GenericDocument::GetAllocator().\n        \\see CopyFrom()\n    */\n    template< typename SourceAllocator >\n    GenericValue(const GenericValue<Encoding, SourceAllocator>& rhs, Allocator & allocator);\n\n    //! Constructor for boolean value.\n    /*! \\param b Boolean value\n        \\note This constructor is limited to \\em real boolean values and rejects\n            implicitly converted types like arbitrary pointers.  Use an explicit cast\n            to \\c bool, if you want to construct a boolean JSON value in such cases.\n     */\n#ifndef RAPIDJSON_DOXYGEN_RUNNING // hide SFINAE from Doxygen\n    template <typename T>\n    explicit GenericValue(T b, RAPIDJSON_ENABLEIF((internal::IsSame<bool, T>))) RAPIDJSON_NOEXCEPT  // See #472\n#else\n    explicit GenericValue(bool b) RAPIDJSON_NOEXCEPT\n#endif\n        : data_() {\n            // safe-guard against failing SFINAE\n            RAPIDJSON_STATIC_ASSERT((internal::IsSame<bool,T>::Value));\n            data_.f.flags = b ? kTrueFlag : kFalseFlag;\n    }\n\n    //! Constructor for int value.\n    explicit GenericValue(int i) RAPIDJSON_NOEXCEPT : data_() {\n        data_.n.i64 = i;\n        data_.f.flags = (i >= 0) ? (kNumberIntFlag | kUintFlag | kUint64Flag) : kNumberIntFlag;\n    }\n\n    //! Constructor for unsigned value.\n    explicit GenericValue(unsigned u) RAPIDJSON_NOEXCEPT : data_() {\n        data_.n.u64 = u; \n        data_.f.flags = (u & 0x80000000) ? kNumberUintFlag : (kNumberUintFlag | kIntFlag | kInt64Flag);\n    }\n\n    //! Constructor for int64_t value.\n    explicit GenericValue(int64_t i64) RAPIDJSON_NOEXCEPT : data_() {\n        data_.n.i64 = i64;\n        data_.f.flags = kNumberInt64Flag;\n        if (i64 >= 0) {\n            data_.f.flags |= kNumberUint64Flag;\n            if (!(static_cast<uint64_t>(i64) & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x00000000)))\n                data_.f.flags |= kUintFlag;\n            if (!(static_cast<uint64_t>(i64) & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x80000000)))\n                data_.f.flags |= kIntFlag;\n        }\n        else if (i64 >= static_cast<int64_t>(RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x80000000)))\n            data_.f.flags |= kIntFlag;\n    }\n\n    //! Constructor for uint64_t value.\n    explicit GenericValue(uint64_t u64) RAPIDJSON_NOEXCEPT : data_() {\n        data_.n.u64 = u64;\n        data_.f.flags = kNumberUint64Flag;\n        if (!(u64 & RAPIDJSON_UINT64_C2(0x80000000, 0x00000000)))\n            data_.f.flags |= kInt64Flag;\n        if (!(u64 & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x00000000)))\n            data_.f.flags |= kUintFlag;\n        if (!(u64 & RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x80000000)))\n            data_.f.flags |= kIntFlag;\n    }\n\n    //! Constructor for double value.\n    explicit GenericValue(double d) RAPIDJSON_NOEXCEPT : data_() { data_.n.d = d; data_.f.flags = kNumberDoubleFlag; }\n\n    //! Constructor for constant string (i.e. do not make a copy of string)\n    GenericValue(const Ch* s, SizeType length) RAPIDJSON_NOEXCEPT : data_() { SetStringRaw(StringRef(s, length)); }\n\n    //! Constructor for constant string (i.e. do not make a copy of string)\n    explicit GenericValue(StringRefType s) RAPIDJSON_NOEXCEPT : data_() { SetStringRaw(s); }\n\n    //! Constructor for copy-string (i.e. do make a copy of string)\n    GenericValue(const Ch* s, SizeType length, Allocator& allocator) : data_() { SetStringRaw(StringRef(s, length), allocator); }\n\n    //! Constructor for copy-string (i.e. do make a copy of string)\n    GenericValue(const Ch*s, Allocator& allocator) : data_() { SetStringRaw(StringRef(s), allocator); }\n\n#if RAPIDJSON_HAS_STDSTRING\n    //! Constructor for copy-string from a string object (i.e. do make a copy of string)\n    /*! \\note Requires the definition of the preprocessor symbol \\ref RAPIDJSON_HAS_STDSTRING.\n     */\n    GenericValue(const std::basic_string<Ch>& s, Allocator& allocator) : data_() { SetStringRaw(StringRef(s), allocator); }\n#endif\n\n    //! Constructor for Array.\n    /*!\n        \\param a An array obtained by \\c GetArray().\n        \\note \\c Array is always pass-by-value.\n        \\note the source array is moved into this value and the sourec array becomes empty.\n    */\n    GenericValue(Array a) RAPIDJSON_NOEXCEPT : data_(a.value_.data_) {\n        a.value_.data_ = Data();\n        a.value_.data_.f.flags = kArrayFlag;\n    }\n\n    //! Constructor for Object.\n    /*!\n        \\param o An object obtained by \\c GetObject().\n        \\note \\c Object is always pass-by-value.\n        \\note the source object is moved into this value and the sourec object becomes empty.\n    */\n    GenericValue(Object o) RAPIDJSON_NOEXCEPT : data_(o.value_.data_) {\n        o.value_.data_ = Data();\n        o.value_.data_.f.flags = kObjectFlag;\n    }\n\n    //! Destructor.\n    /*! Need to destruct elements of array, members of object, or copy-string.\n    */\n    ~GenericValue() {\n        if (Allocator::kNeedFree) { // Shortcut by Allocator's trait\n            switch(data_.f.flags) {\n            case kArrayFlag:\n                {\n                    GenericValue* e = GetElementsPointer();\n                    for (GenericValue* v = e; v != e + data_.a.size; ++v)\n                        v->~GenericValue();\n                    Allocator::Free(e);\n                }\n                break;\n\n            case kObjectFlag:\n                for (MemberIterator m = MemberBegin(); m != MemberEnd(); ++m)\n                    m->~Member();\n                Allocator::Free(GetMembersPointer());\n                break;\n\n            case kCopyStringFlag:\n                Allocator::Free(const_cast<Ch*>(GetStringPointer()));\n                break;\n\n            default:\n                break;  // Do nothing for other types.\n            }\n        }\n    }\n\n    //@}\n\n    //!@name Assignment operators\n    //@{\n\n    //! Assignment with move semantics.\n    /*! \\param rhs Source of the assignment. It will become a null value after assignment.\n    */\n    GenericValue& operator=(GenericValue& rhs) RAPIDJSON_NOEXCEPT {\n        RAPIDJSON_ASSERT(this != &rhs);\n        this->~GenericValue();\n        RawAssign(rhs);\n        return *this;\n    }\n\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\n    //! Move assignment in C++11\n    GenericValue& operator=(GenericValue&& rhs) RAPIDJSON_NOEXCEPT {\n        return *this = rhs.Move();\n    }\n#endif\n\n    //! Assignment of constant string reference (no copy)\n    /*! \\param str Constant string reference to be assigned\n        \\note This overload is needed to avoid clashes with the generic primitive type assignment overload below.\n        \\see GenericStringRef, operator=(T)\n    */\n    GenericValue& operator=(StringRefType str) RAPIDJSON_NOEXCEPT {\n        GenericValue s(str);\n        return *this = s;\n    }\n\n    //! Assignment with primitive types.\n    /*! \\tparam T Either \\ref Type, \\c int, \\c unsigned, \\c int64_t, \\c uint64_t\n        \\param value The value to be assigned.\n\n        \\note The source type \\c T explicitly disallows all pointer types,\n            especially (\\c const) \\ref Ch*.  This helps avoiding implicitly\n            referencing character strings with insufficient lifetime, use\n            \\ref SetString(const Ch*, Allocator&) (for copying) or\n            \\ref StringRef() (to explicitly mark the pointer as constant) instead.\n            All other pointer types would implicitly convert to \\c bool,\n            use \\ref SetBool() instead.\n    */\n    template <typename T>\n    RAPIDJSON_DISABLEIF_RETURN((internal::IsPointer<T>), (GenericValue&))\n    operator=(T value) {\n        GenericValue v(value);\n        return *this = v;\n    }\n\n    //! Deep-copy assignment from Value\n    /*! Assigns a \\b copy of the Value to the current Value object\n        \\tparam SourceAllocator Allocator type of \\c rhs\n        \\param rhs Value to copy from (read-only)\n        \\param allocator Allocator to use for copying\n     */\n    template <typename SourceAllocator>\n    GenericValue& CopyFrom(const GenericValue<Encoding, SourceAllocator>& rhs, Allocator& allocator) {\n        RAPIDJSON_ASSERT(static_cast<void*>(this) != static_cast<void const*>(&rhs));\n        this->~GenericValue();\n        new (this) GenericValue(rhs, allocator);\n        return *this;\n    }\n\n    //! Exchange the contents of this value with those of other.\n    /*!\n        \\param other Another value.\n        \\note Constant complexity.\n    */\n    GenericValue& Swap(GenericValue& other) RAPIDJSON_NOEXCEPT {\n        GenericValue temp;\n        temp.RawAssign(*this);\n        RawAssign(other);\n        other.RawAssign(temp);\n        return *this;\n    }\n\n    //! free-standing swap function helper\n    /*!\n        Helper function to enable support for common swap implementation pattern based on \\c std::swap:\n        \\code\n        void swap(MyClass& a, MyClass& b) {\n            using std::swap;\n            swap(a.value, b.value);\n            // ...\n        }\n        \\endcode\n        \\see Swap()\n     */\n    friend inline void swap(GenericValue& a, GenericValue& b) RAPIDJSON_NOEXCEPT { a.Swap(b); }\n\n    //! Prepare Value for move semantics\n    /*! \\return *this */\n    GenericValue& Move() RAPIDJSON_NOEXCEPT { return *this; }\n    //@}\n\n    //!@name Equal-to and not-equal-to operators\n    //@{\n    //! Equal-to operator\n    /*!\n        \\note If an object contains duplicated named member, comparing equality with any object is always \\c false.\n        \\note Linear time complexity (number of all values in the subtree and total lengths of all strings).\n    */\n    template <typename SourceAllocator>\n    bool operator==(const GenericValue<Encoding, SourceAllocator>& rhs) const {\n        typedef GenericValue<Encoding, SourceAllocator> RhsType;\n        if (GetType() != rhs.GetType())\n            return false;\n\n        switch (GetType()) {\n        case kObjectType: // Warning: O(n^2) inner-loop\n            if (data_.o.size != rhs.data_.o.size)\n                return false;           \n            for (ConstMemberIterator lhsMemberItr = MemberBegin(); lhsMemberItr != MemberEnd(); ++lhsMemberItr) {\n                typename RhsType::ConstMemberIterator rhsMemberItr = rhs.FindMember(lhsMemberItr->name);\n                if (rhsMemberItr == rhs.MemberEnd() || lhsMemberItr->value != rhsMemberItr->value)\n                    return false;\n            }\n            return true;\n            \n        case kArrayType:\n            if (data_.a.size != rhs.data_.a.size)\n                return false;\n            for (SizeType i = 0; i < data_.a.size; i++)\n                if ((*this)[i] != rhs[i])\n                    return false;\n            return true;\n\n        case kStringType:\n            return StringEqual(rhs);\n\n        case kNumberType:\n            if (IsDouble() || rhs.IsDouble()) {\n                double a = GetDouble();     // May convert from integer to double.\n                double b = rhs.GetDouble(); // Ditto\n                return a >= b && a <= b;    // Prevent -Wfloat-equal\n            }\n            else\n                return data_.n.u64 == rhs.data_.n.u64;\n\n        default:\n            return true;\n        }\n    }\n\n    //! Equal-to operator with const C-string pointer\n    bool operator==(const Ch* rhs) const { return *this == GenericValue(StringRef(rhs)); }\n\n#if RAPIDJSON_HAS_STDSTRING\n    //! Equal-to operator with string object\n    /*! \\note Requires the definition of the preprocessor symbol \\ref RAPIDJSON_HAS_STDSTRING.\n     */\n    bool operator==(const std::basic_string<Ch>& rhs) const { return *this == GenericValue(StringRef(rhs)); }\n#endif\n\n    //! Equal-to operator with primitive types\n    /*! \\tparam T Either \\ref Type, \\c int, \\c unsigned, \\c int64_t, \\c uint64_t, \\c double, \\c true, \\c false\n    */\n    template <typename T> RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>,internal::IsGenericValue<T> >), (bool)) operator==(const T& rhs) const { return *this == GenericValue(rhs); }\n\n    //! Not-equal-to operator\n    /*! \\return !(*this == rhs)\n     */\n    template <typename SourceAllocator>\n    bool operator!=(const GenericValue<Encoding, SourceAllocator>& rhs) const { return !(*this == rhs); }\n\n    //! Not-equal-to operator with const C-string pointer\n    bool operator!=(const Ch* rhs) const { return !(*this == rhs); }\n\n    //! Not-equal-to operator with arbitrary types\n    /*! \\return !(*this == rhs)\n     */\n    template <typename T> RAPIDJSON_DISABLEIF_RETURN((internal::IsGenericValue<T>), (bool)) operator!=(const T& rhs) const { return !(*this == rhs); }\n\n    //! Equal-to operator with arbitrary types (symmetric version)\n    /*! \\return (rhs == lhs)\n     */\n    template <typename T> friend RAPIDJSON_DISABLEIF_RETURN((internal::IsGenericValue<T>), (bool)) operator==(const T& lhs, const GenericValue& rhs) { return rhs == lhs; }\n\n    //! Not-Equal-to operator with arbitrary types (symmetric version)\n    /*! \\return !(rhs == lhs)\n     */\n    template <typename T> friend RAPIDJSON_DISABLEIF_RETURN((internal::IsGenericValue<T>), (bool)) operator!=(const T& lhs, const GenericValue& rhs) { return !(rhs == lhs); }\n    //@}\n\n    //!@name Type\n    //@{\n\n    Type GetType()  const { return static_cast<Type>(data_.f.flags & kTypeMask); }\n    bool IsNull()   const { return data_.f.flags == kNullFlag; }\n    bool IsFalse()  const { return data_.f.flags == kFalseFlag; }\n    bool IsTrue()   const { return data_.f.flags == kTrueFlag; }\n    bool IsBool()   const { return (data_.f.flags & kBoolFlag) != 0; }\n    bool IsObject() const { return data_.f.flags == kObjectFlag; }\n    bool IsArray()  const { return data_.f.flags == kArrayFlag; }\n    bool IsNumber() const { return (data_.f.flags & kNumberFlag) != 0; }\n    bool IsInt()    const { return (data_.f.flags & kIntFlag) != 0; }\n    bool IsUint()   const { return (data_.f.flags & kUintFlag) != 0; }\n    bool IsInt64()  const { return (data_.f.flags & kInt64Flag) != 0; }\n    bool IsUint64() const { return (data_.f.flags & kUint64Flag) != 0; }\n    bool IsDouble() const { return (data_.f.flags & kDoubleFlag) != 0; }\n    bool IsString() const { return (data_.f.flags & kStringFlag) != 0; }\n\n    // Checks whether a number can be losslessly converted to a double.\n    bool IsLosslessDouble() const {\n        if (!IsNumber()) return false;\n        if (IsUint64()) {\n            uint64_t u = GetUint64();\n            volatile double d = static_cast<double>(u);\n            return (d >= 0.0)\n                && (d < static_cast<double>(std::numeric_limits<uint64_t>::max()))\n                && (u == static_cast<uint64_t>(d));\n        }\n        if (IsInt64()) {\n            int64_t i = GetInt64();\n            volatile double d = static_cast<double>(i);\n            return (d >= static_cast<double>(std::numeric_limits<int64_t>::min()))\n                && (d < static_cast<double>(std::numeric_limits<int64_t>::max()))\n                && (i == static_cast<int64_t>(d));\n        }\n        return true; // double, int, uint are always lossless\n    }\n\n    // Checks whether a number is a float (possible lossy).\n    bool IsFloat() const  {\n        if ((data_.f.flags & kDoubleFlag) == 0)\n            return false;\n        double d = GetDouble();\n        return d >= -3.4028234e38 && d <= 3.4028234e38;\n    }\n    // Checks whether a number can be losslessly converted to a float.\n    bool IsLosslessFloat() const {\n        if (!IsNumber()) return false;\n        double a = GetDouble();\n        if (a < static_cast<double>(-std::numeric_limits<float>::max())\n                || a > static_cast<double>(std::numeric_limits<float>::max()))\n            return false;\n        double b = static_cast<double>(static_cast<float>(a));\n        return a >= b && a <= b;    // Prevent -Wfloat-equal\n    }\n\n    //@}\n\n    //!@name Null\n    //@{\n\n    GenericValue& SetNull() { this->~GenericValue(); new (this) GenericValue(); return *this; }\n\n    //@}\n\n    //!@name Bool\n    //@{\n\n    bool GetBool() const { RAPIDJSON_ASSERT(IsBool()); return data_.f.flags == kTrueFlag; }\n    //!< Set boolean value\n    /*! \\post IsBool() == true */\n    GenericValue& SetBool(bool b) { this->~GenericValue(); new (this) GenericValue(b); return *this; }\n\n    //@}\n\n    //!@name Object\n    //@{\n\n    //! Set this value as an empty object.\n    /*! \\post IsObject() == true */\n    GenericValue& SetObject() { this->~GenericValue(); new (this) GenericValue(kObjectType); return *this; }\n\n    //! Get the number of members in the object.\n    SizeType MemberCount() const { RAPIDJSON_ASSERT(IsObject()); return data_.o.size; }\n\n    //! Check whether the object is empty.\n    bool ObjectEmpty() const { RAPIDJSON_ASSERT(IsObject()); return data_.o.size == 0; }\n\n    //! Get a value from an object associated with the name.\n    /*! \\pre IsObject() == true\n        \\tparam T Either \\c Ch or \\c const \\c Ch (template used for disambiguation with \\ref operator[](SizeType))\n        \\note In version 0.1x, if the member is not found, this function returns a null value. This makes issue 7.\n        Since 0.2, if the name is not correct, it will assert.\n        If user is unsure whether a member exists, user should use HasMember() first.\n        A better approach is to use FindMember().\n        \\note Linear time complexity.\n    */\n    template <typename T>\n    RAPIDJSON_DISABLEIF_RETURN((internal::NotExpr<internal::IsSame<typename internal::RemoveConst<T>::Type, Ch> >),(GenericValue&)) operator[](T* name) {\n        GenericValue n(StringRef(name));\n        return (*this)[n];\n    }\n    template <typename T>\n    RAPIDJSON_DISABLEIF_RETURN((internal::NotExpr<internal::IsSame<typename internal::RemoveConst<T>::Type, Ch> >),(const GenericValue&)) operator[](T* name) const { return const_cast<GenericValue&>(*this)[name]; }\n\n    //! Get a value from an object associated with the name.\n    /*! \\pre IsObject() == true\n        \\tparam SourceAllocator Allocator of the \\c name value\n\n        \\note Compared to \\ref operator[](T*), this version is faster because it does not need a StrLen().\n        And it can also handle strings with embedded null characters.\n\n        \\note Linear time complexity.\n    */\n    template <typename SourceAllocator>\n    GenericValue& operator[](const GenericValue<Encoding, SourceAllocator>& name) {\n        MemberIterator member = FindMember(name);\n        if (member != MemberEnd())\n            return member->value;\n        else {\n            RAPIDJSON_ASSERT(false);    // see above note\n\n            // This will generate -Wexit-time-destructors in clang\n            // static GenericValue NullValue;\n            // return NullValue;\n\n            // Use static buffer and placement-new to prevent destruction\n            static char buffer[sizeof(GenericValue)];\n            return *new (buffer) GenericValue();\n        }\n    }\n    template <typename SourceAllocator>\n    const GenericValue& operator[](const GenericValue<Encoding, SourceAllocator>& name) const { return const_cast<GenericValue&>(*this)[name]; }\n\n#if RAPIDJSON_HAS_STDSTRING\n    //! Get a value from an object associated with name (string object).\n    GenericValue& operator[](const std::basic_string<Ch>& name) { return (*this)[GenericValue(StringRef(name))]; }\n    const GenericValue& operator[](const std::basic_string<Ch>& name) const { return (*this)[GenericValue(StringRef(name))]; }\n#endif\n\n    //! Const member iterator\n    /*! \\pre IsObject() == true */\n    ConstMemberIterator MemberBegin() const { RAPIDJSON_ASSERT(IsObject()); return ConstMemberIterator(GetMembersPointer()); }\n    //! Const \\em past-the-end member iterator\n    /*! \\pre IsObject() == true */\n    ConstMemberIterator MemberEnd() const   { RAPIDJSON_ASSERT(IsObject()); return ConstMemberIterator(GetMembersPointer() + data_.o.size); }\n    //! Member iterator\n    /*! \\pre IsObject() == true */\n    MemberIterator MemberBegin()            { RAPIDJSON_ASSERT(IsObject()); return MemberIterator(GetMembersPointer()); }\n    //! \\em Past-the-end member iterator\n    /*! \\pre IsObject() == true */\n    MemberIterator MemberEnd()              { RAPIDJSON_ASSERT(IsObject()); return MemberIterator(GetMembersPointer() + data_.o.size); }\n\n    //! Check whether a member exists in the object.\n    /*!\n        \\param name Member name to be searched.\n        \\pre IsObject() == true\n        \\return Whether a member with that name exists.\n        \\note It is better to use FindMember() directly if you need the obtain the value as well.\n        \\note Linear time complexity.\n    */\n    bool HasMember(const Ch* name) const { return FindMember(name) != MemberEnd(); }\n\n#if RAPIDJSON_HAS_STDSTRING\n    //! Check whether a member exists in the object with string object.\n    /*!\n        \\param name Member name to be searched.\n        \\pre IsObject() == true\n        \\return Whether a member with that name exists.\n        \\note It is better to use FindMember() directly if you need the obtain the value as well.\n        \\note Linear time complexity.\n    */\n    bool HasMember(const std::basic_string<Ch>& name) const { return FindMember(name) != MemberEnd(); }\n#endif\n\n    //! Check whether a member exists in the object with GenericValue name.\n    /*!\n        This version is faster because it does not need a StrLen(). It can also handle string with null character.\n        \\param name Member name to be searched.\n        \\pre IsObject() == true\n        \\return Whether a member with that name exists.\n        \\note It is better to use FindMember() directly if you need the obtain the value as well.\n        \\note Linear time complexity.\n    */\n    template <typename SourceAllocator>\n    bool HasMember(const GenericValue<Encoding, SourceAllocator>& name) const { return FindMember(name) != MemberEnd(); }\n\n    //! Find member by name.\n    /*!\n        \\param name Member name to be searched.\n        \\pre IsObject() == true\n        \\return Iterator to member, if it exists.\n            Otherwise returns \\ref MemberEnd().\n\n        \\note Earlier versions of Rapidjson returned a \\c NULL pointer, in case\n            the requested member doesn't exist. For consistency with e.g.\n            \\c std::map, this has been changed to MemberEnd() now.\n        \\note Linear time complexity.\n    */\n    MemberIterator FindMember(const Ch* name) {\n        GenericValue n(StringRef(name));\n        return FindMember(n);\n    }\n\n    ConstMemberIterator FindMember(const Ch* name) const { return const_cast<GenericValue&>(*this).FindMember(name); }\n\n    //! Find member by name.\n    /*!\n        This version is faster because it does not need a StrLen(). It can also handle string with null character.\n        \\param name Member name to be searched.\n        \\pre IsObject() == true\n        \\return Iterator to member, if it exists.\n            Otherwise returns \\ref MemberEnd().\n\n        \\note Earlier versions of Rapidjson returned a \\c NULL pointer, in case\n            the requested member doesn't exist. For consistency with e.g.\n            \\c std::map, this has been changed to MemberEnd() now.\n        \\note Linear time complexity.\n    */\n    template <typename SourceAllocator>\n    MemberIterator FindMember(const GenericValue<Encoding, SourceAllocator>& name) {\n        RAPIDJSON_ASSERT(IsObject());\n        RAPIDJSON_ASSERT(name.IsString());\n        MemberIterator member = MemberBegin();\n        for ( ; member != MemberEnd(); ++member)\n            if (name.StringEqual(member->name))\n                break;\n        return member;\n    }\n    template <typename SourceAllocator> ConstMemberIterator FindMember(const GenericValue<Encoding, SourceAllocator>& name) const { return const_cast<GenericValue&>(*this).FindMember(name); }\n\n#if RAPIDJSON_HAS_STDSTRING\n    //! Find member by string object name.\n    /*!\n        \\param name Member name to be searched.\n        \\pre IsObject() == true\n        \\return Iterator to member, if it exists.\n            Otherwise returns \\ref MemberEnd().\n    */\n    MemberIterator FindMember(const std::basic_string<Ch>& name) { return FindMember(GenericValue(StringRef(name))); }\n    ConstMemberIterator FindMember(const std::basic_string<Ch>& name) const { return FindMember(GenericValue(StringRef(name))); }\n#endif\n\n    //! Add a member (name-value pair) to the object.\n    /*! \\param name A string value as name of member.\n        \\param value Value of any type.\n        \\param allocator    Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator().\n        \\return The value itself for fluent API.\n        \\note The ownership of \\c name and \\c value will be transferred to this object on success.\n        \\pre  IsObject() && name.IsString()\n        \\post name.IsNull() && value.IsNull()\n        \\note Amortized Constant time complexity.\n    */\n    GenericValue& AddMember(GenericValue& name, GenericValue& value, Allocator& allocator) {\n        RAPIDJSON_ASSERT(IsObject());\n        RAPIDJSON_ASSERT(name.IsString());\n\n        ObjectData& o = data_.o;\n        if (o.size >= o.capacity) {\n            if (o.capacity == 0) {\n                o.capacity = kDefaultObjectCapacity;\n                SetMembersPointer(reinterpret_cast<Member*>(allocator.Malloc(o.capacity * sizeof(Member))));\n            }\n            else {\n                SizeType oldCapacity = o.capacity;\n                o.capacity += (oldCapacity + 1) / 2; // grow by factor 1.5\n                SetMembersPointer(reinterpret_cast<Member*>(allocator.Realloc(GetMembersPointer(), oldCapacity * sizeof(Member), o.capacity * sizeof(Member))));\n            }\n        }\n        Member* members = GetMembersPointer();\n        members[o.size].name.RawAssign(name);\n        members[o.size].value.RawAssign(value);\n        o.size++;\n        return *this;\n    }\n\n    //! Add a constant string value as member (name-value pair) to the object.\n    /*! \\param name A string value as name of member.\n        \\param value constant string reference as value of member.\n        \\param allocator    Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator().\n        \\return The value itself for fluent API.\n        \\pre  IsObject()\n        \\note This overload is needed to avoid clashes with the generic primitive type AddMember(GenericValue&,T,Allocator&) overload below.\n        \\note Amortized Constant time complexity.\n    */\n    GenericValue& AddMember(GenericValue& name, StringRefType value, Allocator& allocator) {\n        GenericValue v(value);\n        return AddMember(name, v, allocator);\n    }\n\n#if RAPIDJSON_HAS_STDSTRING\n    //! Add a string object as member (name-value pair) to the object.\n    /*! \\param name A string value as name of member.\n        \\param value constant string reference as value of member.\n        \\param allocator    Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator().\n        \\return The value itself for fluent API.\n        \\pre  IsObject()\n        \\note This overload is needed to avoid clashes with the generic primitive type AddMember(GenericValue&,T,Allocator&) overload below.\n        \\note Amortized Constant time complexity.\n    */\n    GenericValue& AddMember(GenericValue& name, std::basic_string<Ch>& value, Allocator& allocator) {\n        GenericValue v(value, allocator);\n        return AddMember(name, v, allocator);\n    }\n#endif\n\n    //! Add any primitive value as member (name-value pair) to the object.\n    /*! \\tparam T Either \\ref Type, \\c int, \\c unsigned, \\c int64_t, \\c uint64_t\n        \\param name A string value as name of member.\n        \\param value Value of primitive type \\c T as value of member\n        \\param allocator Allocator for reallocating memory. Commonly use GenericDocument::GetAllocator().\n        \\return The value itself for fluent API.\n        \\pre  IsObject()\n\n        \\note The source type \\c T explicitly disallows all pointer types,\n            especially (\\c const) \\ref Ch*.  This helps avoiding implicitly\n            referencing character strings with insufficient lifetime, use\n            \\ref AddMember(StringRefType, GenericValue&, Allocator&) or \\ref\n            AddMember(StringRefType, StringRefType, Allocator&).\n            All other pointer types would implicitly convert to \\c bool,\n            use an explicit cast instead, if needed.\n        \\note Amortized Constant time complexity.\n    */\n    template <typename T>\n    RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T> >), (GenericValue&))\n    AddMember(GenericValue& name, T value, Allocator& allocator) {\n        GenericValue v(value);\n        return AddMember(name, v, allocator);\n    }\n\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\n    GenericValue& AddMember(GenericValue&& name, GenericValue&& value, Allocator& allocator) {\n        return AddMember(name, value, allocator);\n    }\n    GenericValue& AddMember(GenericValue&& name, GenericValue& value, Allocator& allocator) {\n        return AddMember(name, value, allocator);\n    }\n    GenericValue& AddMember(GenericValue& name, GenericValue&& value, Allocator& allocator) {\n        return AddMember(name, value, allocator);\n    }\n    GenericValue& AddMember(StringRefType name, GenericValue&& value, Allocator& allocator) {\n        GenericValue n(name);\n        return AddMember(n, value, allocator);\n    }\n#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS\n\n\n    //! Add a member (name-value pair) to the object.\n    /*! \\param name A constant string reference as name of member.\n        \\param value Value of any type.\n        \\param allocator    Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator().\n        \\return The value itself for fluent API.\n        \\note The ownership of \\c value will be transferred to this object on success.\n        \\pre  IsObject()\n        \\post value.IsNull()\n        \\note Amortized Constant time complexity.\n    */\n    GenericValue& AddMember(StringRefType name, GenericValue& value, Allocator& allocator) {\n        GenericValue n(name);\n        return AddMember(n, value, allocator);\n    }\n\n    //! Add a constant string value as member (name-value pair) to the object.\n    /*! \\param name A constant string reference as name of member.\n        \\param value constant string reference as value of member.\n        \\param allocator    Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator().\n        \\return The value itself for fluent API.\n        \\pre  IsObject()\n        \\note This overload is needed to avoid clashes with the generic primitive type AddMember(StringRefType,T,Allocator&) overload below.\n        \\note Amortized Constant time complexity.\n    */\n    GenericValue& AddMember(StringRefType name, StringRefType value, Allocator& allocator) {\n        GenericValue v(value);\n        return AddMember(name, v, allocator);\n    }\n\n    //! Add any primitive value as member (name-value pair) to the object.\n    /*! \\tparam T Either \\ref Type, \\c int, \\c unsigned, \\c int64_t, \\c uint64_t\n        \\param name A constant string reference as name of member.\n        \\param value Value of primitive type \\c T as value of member\n        \\param allocator Allocator for reallocating memory. Commonly use GenericDocument::GetAllocator().\n        \\return The value itself for fluent API.\n        \\pre  IsObject()\n\n        \\note The source type \\c T explicitly disallows all pointer types,\n            especially (\\c const) \\ref Ch*.  This helps avoiding implicitly\n            referencing character strings with insufficient lifetime, use\n            \\ref AddMember(StringRefType, GenericValue&, Allocator&) or \\ref\n            AddMember(StringRefType, StringRefType, Allocator&).\n            All other pointer types would implicitly convert to \\c bool,\n            use an explicit cast instead, if needed.\n        \\note Amortized Constant time complexity.\n    */\n    template <typename T>\n    RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T> >), (GenericValue&))\n    AddMember(StringRefType name, T value, Allocator& allocator) {\n        GenericValue n(name);\n        return AddMember(n, value, allocator);\n    }\n\n    //! Remove all members in the object.\n    /*! This function do not deallocate memory in the object, i.e. the capacity is unchanged.\n        \\note Linear time complexity.\n    */\n    void RemoveAllMembers() {\n        RAPIDJSON_ASSERT(IsObject()); \n        for (MemberIterator m = MemberBegin(); m != MemberEnd(); ++m)\n            m->~Member();\n        data_.o.size = 0;\n    }\n\n    //! Remove a member in object by its name.\n    /*! \\param name Name of member to be removed.\n        \\return Whether the member existed.\n        \\note This function may reorder the object members. Use \\ref\n            EraseMember(ConstMemberIterator) if you need to preserve the\n            relative order of the remaining members.\n        \\note Linear time complexity.\n    */\n    bool RemoveMember(const Ch* name) {\n        GenericValue n(StringRef(name));\n        return RemoveMember(n);\n    }\n\n#if RAPIDJSON_HAS_STDSTRING\n    bool RemoveMember(const std::basic_string<Ch>& name) { return RemoveMember(GenericValue(StringRef(name))); }\n#endif\n\n    template <typename SourceAllocator>\n    bool RemoveMember(const GenericValue<Encoding, SourceAllocator>& name) {\n        MemberIterator m = FindMember(name);\n        if (m != MemberEnd()) {\n            RemoveMember(m);\n            return true;\n        }\n        else\n            return false;\n    }\n\n    //! Remove a member in object by iterator.\n    /*! \\param m member iterator (obtained by FindMember() or MemberBegin()).\n        \\return the new iterator after removal.\n        \\note This function may reorder the object members. Use \\ref\n            EraseMember(ConstMemberIterator) if you need to preserve the\n            relative order of the remaining members.\n        \\note Constant time complexity.\n    */\n    MemberIterator RemoveMember(MemberIterator m) {\n        RAPIDJSON_ASSERT(IsObject());\n        RAPIDJSON_ASSERT(data_.o.size > 0);\n        RAPIDJSON_ASSERT(GetMembersPointer() != 0);\n        RAPIDJSON_ASSERT(m >= MemberBegin() && m < MemberEnd());\n\n        MemberIterator last(GetMembersPointer() + (data_.o.size - 1));\n        if (data_.o.size > 1 && m != last)\n            *m = *last; // Move the last one to this place\n        else\n            m->~Member(); // Only one left, just destroy\n        --data_.o.size;\n        return m;\n    }\n\n    //! Remove a member from an object by iterator.\n    /*! \\param pos iterator to the member to remove\n        \\pre IsObject() == true && \\ref MemberBegin() <= \\c pos < \\ref MemberEnd()\n        \\return Iterator following the removed element.\n            If the iterator \\c pos refers to the last element, the \\ref MemberEnd() iterator is returned.\n        \\note This function preserves the relative order of the remaining object\n            members. If you do not need this, use the more efficient \\ref RemoveMember(MemberIterator).\n        \\note Linear time complexity.\n    */\n    MemberIterator EraseMember(ConstMemberIterator pos) {\n        return EraseMember(pos, pos +1);\n    }\n\n    //! Remove members in the range [first, last) from an object.\n    /*! \\param first iterator to the first member to remove\n        \\param last  iterator following the last member to remove\n        \\pre IsObject() == true && \\ref MemberBegin() <= \\c first <= \\c last <= \\ref MemberEnd()\n        \\return Iterator following the last removed element.\n        \\note This function preserves the relative order of the remaining object\n            members.\n        \\note Linear time complexity.\n    */\n    MemberIterator EraseMember(ConstMemberIterator first, ConstMemberIterator last) {\n        RAPIDJSON_ASSERT(IsObject());\n        RAPIDJSON_ASSERT(data_.o.size > 0);\n        RAPIDJSON_ASSERT(GetMembersPointer() != 0);\n        RAPIDJSON_ASSERT(first >= MemberBegin());\n        RAPIDJSON_ASSERT(first <= last);\n        RAPIDJSON_ASSERT(last <= MemberEnd());\n\n        MemberIterator pos = MemberBegin() + (first - MemberBegin());\n        for (MemberIterator itr = pos; itr != last; ++itr)\n            itr->~Member();\n        std::memmove(&*pos, &*last, static_cast<size_t>(MemberEnd() - last) * sizeof(Member));\n        data_.o.size -= static_cast<SizeType>(last - first);\n        return pos;\n    }\n\n    //! Erase a member in object by its name.\n    /*! \\param name Name of member to be removed.\n        \\return Whether the member existed.\n        \\note Linear time complexity.\n    */\n    bool EraseMember(const Ch* name) {\n        GenericValue n(StringRef(name));\n        return EraseMember(n);\n    }\n\n#if RAPIDJSON_HAS_STDSTRING\n    bool EraseMember(const std::basic_string<Ch>& name) { return EraseMember(GenericValue(StringRef(name))); }\n#endif\n\n    template <typename SourceAllocator>\n    bool EraseMember(const GenericValue<Encoding, SourceAllocator>& name) {\n        MemberIterator m = FindMember(name);\n        if (m != MemberEnd()) {\n            EraseMember(m);\n            return true;\n        }\n        else\n            return false;\n    }\n\n    Object GetObject() { RAPIDJSON_ASSERT(IsObject()); return Object(*this); }\n    ConstObject GetObject() const { RAPIDJSON_ASSERT(IsObject()); return ConstObject(*this); }\n\n    //@}\n\n    //!@name Array\n    //@{\n\n    //! Set this value as an empty array.\n    /*! \\post IsArray == true */\n    GenericValue& SetArray() { this->~GenericValue(); new (this) GenericValue(kArrayType); return *this; }\n\n    //! Get the number of elements in array.\n    SizeType Size() const { RAPIDJSON_ASSERT(IsArray()); return data_.a.size; }\n\n    //! Get the capacity of array.\n    SizeType Capacity() const { RAPIDJSON_ASSERT(IsArray()); return data_.a.capacity; }\n\n    //! Check whether the array is empty.\n    bool Empty() const { RAPIDJSON_ASSERT(IsArray()); return data_.a.size == 0; }\n\n    //! Remove all elements in the array.\n    /*! This function do not deallocate memory in the array, i.e. the capacity is unchanged.\n        \\note Linear time complexity.\n    */\n    void Clear() {\n        RAPIDJSON_ASSERT(IsArray()); \n        GenericValue* e = GetElementsPointer();\n        for (GenericValue* v = e; v != e + data_.a.size; ++v)\n            v->~GenericValue();\n        data_.a.size = 0;\n    }\n\n    //! Get an element from array by index.\n    /*! \\pre IsArray() == true\n        \\param index Zero-based index of element.\n        \\see operator[](T*)\n    */\n    GenericValue& operator[](SizeType index) {\n        RAPIDJSON_ASSERT(IsArray());\n        RAPIDJSON_ASSERT(index < data_.a.size);\n        return GetElementsPointer()[index];\n    }\n    const GenericValue& operator[](SizeType index) const { return const_cast<GenericValue&>(*this)[index]; }\n\n    //! Element iterator\n    /*! \\pre IsArray() == true */\n    ValueIterator Begin() { RAPIDJSON_ASSERT(IsArray()); return GetElementsPointer(); }\n    //! \\em Past-the-end element iterator\n    /*! \\pre IsArray() == true */\n    ValueIterator End() { RAPIDJSON_ASSERT(IsArray()); return GetElementsPointer() + data_.a.size; }\n    //! Constant element iterator\n    /*! \\pre IsArray() == true */\n    ConstValueIterator Begin() const { return const_cast<GenericValue&>(*this).Begin(); }\n    //! Constant \\em past-the-end element iterator\n    /*! \\pre IsArray() == true */\n    ConstValueIterator End() const { return const_cast<GenericValue&>(*this).End(); }\n\n    //! Request the array to have enough capacity to store elements.\n    /*! \\param newCapacity  The capacity that the array at least need to have.\n        \\param allocator    Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator().\n        \\return The value itself for fluent API.\n        \\note Linear time complexity.\n    */\n    GenericValue& Reserve(SizeType newCapacity, Allocator &allocator) {\n        RAPIDJSON_ASSERT(IsArray());\n        if (newCapacity > data_.a.capacity) {\n            SetElementsPointer(reinterpret_cast<GenericValue*>(allocator.Realloc(GetElementsPointer(), data_.a.capacity * sizeof(GenericValue), newCapacity * sizeof(GenericValue))));\n            data_.a.capacity = newCapacity;\n        }\n        return *this;\n    }\n\n    //! Append a GenericValue at the end of the array.\n    /*! \\param value        Value to be appended.\n        \\param allocator    Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator().\n        \\pre IsArray() == true\n        \\post value.IsNull() == true\n        \\return The value itself for fluent API.\n        \\note The ownership of \\c value will be transferred to this array on success.\n        \\note If the number of elements to be appended is known, calls Reserve() once first may be more efficient.\n        \\note Amortized constant time complexity.\n    */\n    GenericValue& PushBack(GenericValue& value, Allocator& allocator) {\n        RAPIDJSON_ASSERT(IsArray());\n        if (data_.a.size >= data_.a.capacity)\n            Reserve(data_.a.capacity == 0 ? kDefaultArrayCapacity : (data_.a.capacity + (data_.a.capacity + 1) / 2), allocator);\n        GetElementsPointer()[data_.a.size++].RawAssign(value);\n        return *this;\n    }\n\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\n    GenericValue& PushBack(GenericValue&& value, Allocator& allocator) {\n        return PushBack(value, allocator);\n    }\n#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS\n\n    //! Append a constant string reference at the end of the array.\n    /*! \\param value        Constant string reference to be appended.\n        \\param allocator    Allocator for reallocating memory. It must be the same one used previously. Commonly use GenericDocument::GetAllocator().\n        \\pre IsArray() == true\n        \\return The value itself for fluent API.\n        \\note If the number of elements to be appended is known, calls Reserve() once first may be more efficient.\n        \\note Amortized constant time complexity.\n        \\see GenericStringRef\n    */\n    GenericValue& PushBack(StringRefType value, Allocator& allocator) {\n        return (*this).template PushBack<StringRefType>(value, allocator);\n    }\n\n    //! Append a primitive value at the end of the array.\n    /*! \\tparam T Either \\ref Type, \\c int, \\c unsigned, \\c int64_t, \\c uint64_t\n        \\param value Value of primitive type T to be appended.\n        \\param allocator    Allocator for reallocating memory. It must be the same one as used before. Commonly use GenericDocument::GetAllocator().\n        \\pre IsArray() == true\n        \\return The value itself for fluent API.\n        \\note If the number of elements to be appended is known, calls Reserve() once first may be more efficient.\n\n        \\note The source type \\c T explicitly disallows all pointer types,\n            especially (\\c const) \\ref Ch*.  This helps avoiding implicitly\n            referencing character strings with insufficient lifetime, use\n            \\ref PushBack(GenericValue&, Allocator&) or \\ref\n            PushBack(StringRefType, Allocator&).\n            All other pointer types would implicitly convert to \\c bool,\n            use an explicit cast instead, if needed.\n        \\note Amortized constant time complexity.\n    */\n    template <typename T>\n    RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T> >), (GenericValue&))\n    PushBack(T value, Allocator& allocator) {\n        GenericValue v(value);\n        return PushBack(v, allocator);\n    }\n\n    //! Remove the last element in the array.\n    /*!\n        \\note Constant time complexity.\n    */\n    GenericValue& PopBack() {\n        RAPIDJSON_ASSERT(IsArray());\n        RAPIDJSON_ASSERT(!Empty());\n        GetElementsPointer()[--data_.a.size].~GenericValue();\n        return *this;\n    }\n\n    //! Remove an element of array by iterator.\n    /*!\n        \\param pos iterator to the element to remove\n        \\pre IsArray() == true && \\ref Begin() <= \\c pos < \\ref End()\n        \\return Iterator following the removed element. If the iterator pos refers to the last element, the End() iterator is returned.\n        \\note Linear time complexity.\n    */\n    ValueIterator Erase(ConstValueIterator pos) {\n        return Erase(pos, pos + 1);\n    }\n\n    //! Remove elements in the range [first, last) of the array.\n    /*!\n        \\param first iterator to the first element to remove\n        \\param last  iterator following the last element to remove\n        \\pre IsArray() == true && \\ref Begin() <= \\c first <= \\c last <= \\ref End()\n        \\return Iterator following the last removed element.\n        \\note Linear time complexity.\n    */\n    ValueIterator Erase(ConstValueIterator first, ConstValueIterator last) {\n        RAPIDJSON_ASSERT(IsArray());\n        RAPIDJSON_ASSERT(data_.a.size > 0);\n        RAPIDJSON_ASSERT(GetElementsPointer() != 0);\n        RAPIDJSON_ASSERT(first >= Begin());\n        RAPIDJSON_ASSERT(first <= last);\n        RAPIDJSON_ASSERT(last <= End());\n        ValueIterator pos = Begin() + (first - Begin());\n        for (ValueIterator itr = pos; itr != last; ++itr)\n            itr->~GenericValue();       \n        std::memmove(pos, last, static_cast<size_t>(End() - last) * sizeof(GenericValue));\n        data_.a.size -= static_cast<SizeType>(last - first);\n        return pos;\n    }\n\n    Array GetArray() { RAPIDJSON_ASSERT(IsArray()); return Array(*this); }\n    ConstArray GetArray() const { RAPIDJSON_ASSERT(IsArray()); return ConstArray(*this); }\n\n    //@}\n\n    //!@name Number\n    //@{\n\n    int GetInt() const          { RAPIDJSON_ASSERT(data_.f.flags & kIntFlag);   return data_.n.i.i;   }\n    unsigned GetUint() const    { RAPIDJSON_ASSERT(data_.f.flags & kUintFlag);  return data_.n.u.u;   }\n    int64_t GetInt64() const    { RAPIDJSON_ASSERT(data_.f.flags & kInt64Flag); return data_.n.i64; }\n    uint64_t GetUint64() const  { RAPIDJSON_ASSERT(data_.f.flags & kUint64Flag); return data_.n.u64; }\n\n    //! Get the value as double type.\n    /*! \\note If the value is 64-bit integer type, it may lose precision. Use \\c IsLosslessDouble() to check whether the converison is lossless.\n    */\n    double GetDouble() const {\n        RAPIDJSON_ASSERT(IsNumber());\n        if ((data_.f.flags & kDoubleFlag) != 0)                return data_.n.d;   // exact type, no conversion.\n        if ((data_.f.flags & kIntFlag) != 0)                   return data_.n.i.i; // int -> double\n        if ((data_.f.flags & kUintFlag) != 0)                  return data_.n.u.u; // unsigned -> double\n        if ((data_.f.flags & kInt64Flag) != 0)                 return static_cast<double>(data_.n.i64); // int64_t -> double (may lose precision)\n        RAPIDJSON_ASSERT((data_.f.flags & kUint64Flag) != 0);  return static_cast<double>(data_.n.u64); // uint64_t -> double (may lose precision)\n    }\n\n    //! Get the value as float type.\n    /*! \\note If the value is 64-bit integer type, it may lose precision. Use \\c IsLosslessFloat() to check whether the converison is lossless.\n    */\n    float GetFloat() const {\n        return static_cast<float>(GetDouble());\n    }\n\n    GenericValue& SetInt(int i)             { this->~GenericValue(); new (this) GenericValue(i);    return *this; }\n    GenericValue& SetUint(unsigned u)       { this->~GenericValue(); new (this) GenericValue(u);    return *this; }\n    GenericValue& SetInt64(int64_t i64)     { this->~GenericValue(); new (this) GenericValue(i64);  return *this; }\n    GenericValue& SetUint64(uint64_t u64)   { this->~GenericValue(); new (this) GenericValue(u64);  return *this; }\n    GenericValue& SetDouble(double d)       { this->~GenericValue(); new (this) GenericValue(d);    return *this; }\n    GenericValue& SetFloat(float f)         { this->~GenericValue(); new (this) GenericValue(f);    return *this; }\n\n    //@}\n\n    //!@name String\n    //@{\n\n    const Ch* GetString() const { RAPIDJSON_ASSERT(IsString()); return (data_.f.flags & kInlineStrFlag) ? data_.ss.str : GetStringPointer(); }\n\n    //! Get the length of string.\n    /*! Since rapidjson permits \"\\\\u0000\" in the json string, strlen(v.GetString()) may not equal to v.GetStringLength().\n    */\n    SizeType GetStringLength() const { RAPIDJSON_ASSERT(IsString()); return ((data_.f.flags & kInlineStrFlag) ? (data_.ss.GetLength()) : data_.s.length); }\n\n    //! Set this value as a string without copying source string.\n    /*! This version has better performance with supplied length, and also support string containing null character.\n        \\param s source string pointer. \n        \\param length The length of source string, excluding the trailing null terminator.\n        \\return The value itself for fluent API.\n        \\post IsString() == true && GetString() == s && GetStringLength() == length\n        \\see SetString(StringRefType)\n    */\n    GenericValue& SetString(const Ch* s, SizeType length) { return SetString(StringRef(s, length)); }\n\n    //! Set this value as a string without copying source string.\n    /*! \\param s source string reference\n        \\return The value itself for fluent API.\n        \\post IsString() == true && GetString() == s && GetStringLength() == s.length\n    */\n    GenericValue& SetString(StringRefType s) { this->~GenericValue(); SetStringRaw(s); return *this; }\n\n    //! Set this value as a string by copying from source string.\n    /*! This version has better performance with supplied length, and also support string containing null character.\n        \\param s source string. \n        \\param length The length of source string, excluding the trailing null terminator.\n        \\param allocator Allocator for allocating copied buffer. Commonly use GenericDocument::GetAllocator().\n        \\return The value itself for fluent API.\n        \\post IsString() == true && GetString() != s && strcmp(GetString(),s) == 0 && GetStringLength() == length\n    */\n    GenericValue& SetString(const Ch* s, SizeType length, Allocator& allocator) { this->~GenericValue(); SetStringRaw(StringRef(s, length), allocator); return *this; }\n\n    //! Set this value as a string by copying from source string.\n    /*! \\param s source string. \n        \\param allocator Allocator for allocating copied buffer. Commonly use GenericDocument::GetAllocator().\n        \\return The value itself for fluent API.\n        \\post IsString() == true && GetString() != s && strcmp(GetString(),s) == 0 && GetStringLength() == length\n    */\n    GenericValue& SetString(const Ch* s, Allocator& allocator) { return SetString(s, internal::StrLen(s), allocator); }\n\n#if RAPIDJSON_HAS_STDSTRING\n    //! Set this value as a string by copying from source string.\n    /*! \\param s source string.\n        \\param allocator Allocator for allocating copied buffer. Commonly use GenericDocument::GetAllocator().\n        \\return The value itself for fluent API.\n        \\post IsString() == true && GetString() != s.data() && strcmp(GetString(),s.data() == 0 && GetStringLength() == s.size()\n        \\note Requires the definition of the preprocessor symbol \\ref RAPIDJSON_HAS_STDSTRING.\n    */\n    GenericValue& SetString(const std::basic_string<Ch>& s, Allocator& allocator) { return SetString(s.data(), SizeType(s.size()), allocator); }\n#endif\n\n    //@}\n\n    //!@name Array\n    //@{\n\n    //! Templated version for checking whether this value is type T.\n    /*!\n        \\tparam T Either \\c bool, \\c int, \\c unsigned, \\c int64_t, \\c uint64_t, \\c double, \\c float, \\c const \\c char*, \\c std::basic_string<Ch>\n    */\n    template <typename T>\n    bool Is() const { return internal::TypeHelper<ValueType, T>::Is(*this); }\n\n    template <typename T>\n    T Get() const { return internal::TypeHelper<ValueType, T>::Get(*this); }\n\n    template <typename T>\n    T Get() { return internal::TypeHelper<ValueType, T>::Get(*this); }\n\n    template<typename T>\n    ValueType& Set(const T& data) { return internal::TypeHelper<ValueType, T>::Set(*this, data); }\n\n    template<typename T>\n    ValueType& Set(const T& data, AllocatorType& allocator) { return internal::TypeHelper<ValueType, T>::Set(*this, data, allocator); }\n\n    //@}\n\n    //! Generate events of this value to a Handler.\n    /*! This function adopts the GoF visitor pattern.\n        Typical usage is to output this JSON value as JSON text via Writer, which is a Handler.\n        It can also be used to deep clone this value via GenericDocument, which is also a Handler.\n        \\tparam Handler type of handler.\n        \\param handler An object implementing concept Handler.\n    */\n    template <typename Handler>\n    bool Accept(Handler& handler) const {\n        switch(GetType()) {\n        case kNullType:     return handler.Null();\n        case kFalseType:    return handler.Bool(false);\n        case kTrueType:     return handler.Bool(true);\n\n        case kObjectType:\n            if (RAPIDJSON_UNLIKELY(!handler.StartObject()))\n                return false;\n            for (ConstMemberIterator m = MemberBegin(); m != MemberEnd(); ++m) {\n                RAPIDJSON_ASSERT(m->name.IsString()); // User may change the type of name by MemberIterator.\n                if (RAPIDJSON_UNLIKELY(!handler.Key(m->name.GetString(), m->name.GetStringLength(), (m->name.data_.f.flags & kCopyFlag) != 0)))\n                    return false;\n                if (RAPIDJSON_UNLIKELY(!m->value.Accept(handler)))\n                    return false;\n            }\n            return handler.EndObject(data_.o.size);\n\n        case kArrayType:\n            if (RAPIDJSON_UNLIKELY(!handler.StartArray()))\n                return false;\n            for (const GenericValue* v = Begin(); v != End(); ++v)\n                if (RAPIDJSON_UNLIKELY(!v->Accept(handler)))\n                    return false;\n            return handler.EndArray(data_.a.size);\n    \n        case kStringType:\n            return handler.String(GetString(), GetStringLength(), (data_.f.flags & kCopyFlag) != 0);\n    \n        default:\n            RAPIDJSON_ASSERT(GetType() == kNumberType);\n            if (IsDouble())         return handler.Double(data_.n.d);\n            else if (IsInt())       return handler.Int(data_.n.i.i);\n            else if (IsUint())      return handler.Uint(data_.n.u.u);\n            else if (IsInt64())     return handler.Int64(data_.n.i64);\n            else                    return handler.Uint64(data_.n.u64);\n        }\n    }\n\nprivate:\n    template <typename, typename> friend class GenericValue;\n    template <typename, typename, typename> friend class GenericDocument;\n\n    enum {\n        kBoolFlag       = 0x0008,\n        kNumberFlag     = 0x0010,\n        kIntFlag        = 0x0020,\n        kUintFlag       = 0x0040,\n        kInt64Flag      = 0x0080,\n        kUint64Flag     = 0x0100,\n        kDoubleFlag     = 0x0200,\n        kStringFlag     = 0x0400,\n        kCopyFlag       = 0x0800,\n        kInlineStrFlag  = 0x1000,\n\n        // Initial flags of different types.\n        kNullFlag = kNullType,\n        kTrueFlag = kTrueType | kBoolFlag,\n        kFalseFlag = kFalseType | kBoolFlag,\n        kNumberIntFlag = kNumberType | kNumberFlag | kIntFlag | kInt64Flag,\n        kNumberUintFlag = kNumberType | kNumberFlag | kUintFlag | kUint64Flag | kInt64Flag,\n        kNumberInt64Flag = kNumberType | kNumberFlag | kInt64Flag,\n        kNumberUint64Flag = kNumberType | kNumberFlag | kUint64Flag,\n        kNumberDoubleFlag = kNumberType | kNumberFlag | kDoubleFlag,\n        kNumberAnyFlag = kNumberType | kNumberFlag | kIntFlag | kInt64Flag | kUintFlag | kUint64Flag | kDoubleFlag,\n        kConstStringFlag = kStringType | kStringFlag,\n        kCopyStringFlag = kStringType | kStringFlag | kCopyFlag,\n        kShortStringFlag = kStringType | kStringFlag | kCopyFlag | kInlineStrFlag,\n        kObjectFlag = kObjectType,\n        kArrayFlag = kArrayType,\n\n        kTypeMask = 0x07\n    };\n\n    static const SizeType kDefaultArrayCapacity = 16;\n    static const SizeType kDefaultObjectCapacity = 16;\n\n    struct Flag {\n#if RAPIDJSON_48BITPOINTER_OPTIMIZATION\n        char payload[sizeof(SizeType) * 2 + 6];     // 2 x SizeType + lower 48-bit pointer\n#elif RAPIDJSON_64BIT\n        char payload[sizeof(SizeType) * 2 + sizeof(void*) + 6]; // 6 padding bytes\n#else\n        char payload[sizeof(SizeType) * 2 + sizeof(void*) + 2]; // 2 padding bytes\n#endif\n        uint16_t flags;\n    };\n\n    struct String {\n        SizeType length;\n        SizeType hashcode;  //!< reserved\n        const Ch* str;\n    };  // 12 bytes in 32-bit mode, 16 bytes in 64-bit mode\n\n    // implementation detail: ShortString can represent zero-terminated strings up to MaxSize chars\n    // (excluding the terminating zero) and store a value to determine the length of the contained\n    // string in the last character str[LenPos] by storing \"MaxSize - length\" there. If the string\n    // to store has the maximal length of MaxSize then str[LenPos] will be 0 and therefore act as\n    // the string terminator as well. For getting the string length back from that value just use\n    // \"MaxSize - str[LenPos]\".\n    // This allows to store 13-chars strings in 32-bit mode, 21-chars strings in 64-bit mode,\n    // 13-chars strings for RAPIDJSON_48BITPOINTER_OPTIMIZATION=1 inline (for `UTF8`-encoded strings).\n    struct ShortString {\n        enum { MaxChars = sizeof(static_cast<Flag*>(0)->payload) / sizeof(Ch), MaxSize = MaxChars - 1, LenPos = MaxSize };\n        Ch str[MaxChars];\n\n        inline static bool Usable(SizeType len) { return                       (MaxSize >= len); }\n        inline void     SetLength(SizeType len) { str[LenPos] = static_cast<Ch>(MaxSize -  len); }\n        inline SizeType GetLength() const       { return  static_cast<SizeType>(MaxSize -  str[LenPos]); }\n    };  // at most as many bytes as \"String\" above => 12 bytes in 32-bit mode, 16 bytes in 64-bit mode\n\n    // By using proper binary layout, retrieval of different integer types do not need conversions.\n    union Number {\n#if RAPIDJSON_ENDIAN == RAPIDJSON_LITTLEENDIAN\n        struct I {\n            int i;\n            char padding[4];\n        }i;\n        struct U {\n            unsigned u;\n            char padding2[4];\n        }u;\n#else\n        struct I {\n            char padding[4];\n            int i;\n        }i;\n        struct U {\n            char padding2[4];\n            unsigned u;\n        }u;\n#endif\n        int64_t i64;\n        uint64_t u64;\n        double d;\n    };  // 8 bytes\n\n    struct ObjectData {\n        SizeType size;\n        SizeType capacity;\n        Member* members;\n    };  // 12 bytes in 32-bit mode, 16 bytes in 64-bit mode\n\n    struct ArrayData {\n        SizeType size;\n        SizeType capacity;\n        GenericValue* elements;\n    };  // 12 bytes in 32-bit mode, 16 bytes in 64-bit mode\n\n    union Data {\n        String s;\n        ShortString ss;\n        Number n;\n        ObjectData o;\n        ArrayData a;\n        Flag f;\n    };  // 16 bytes in 32-bit mode, 24 bytes in 64-bit mode, 16 bytes in 64-bit with RAPIDJSON_48BITPOINTER_OPTIMIZATION\n\n    RAPIDJSON_FORCEINLINE const Ch* GetStringPointer() const { return RAPIDJSON_GETPOINTER(Ch, data_.s.str); }\n    RAPIDJSON_FORCEINLINE const Ch* SetStringPointer(const Ch* str) { return RAPIDJSON_SETPOINTER(Ch, data_.s.str, str); }\n    RAPIDJSON_FORCEINLINE GenericValue* GetElementsPointer() const { return RAPIDJSON_GETPOINTER(GenericValue, data_.a.elements); }\n    RAPIDJSON_FORCEINLINE GenericValue* SetElementsPointer(GenericValue* elements) { return RAPIDJSON_SETPOINTER(GenericValue, data_.a.elements, elements); }\n    RAPIDJSON_FORCEINLINE Member* GetMembersPointer() const { return RAPIDJSON_GETPOINTER(Member, data_.o.members); }\n    RAPIDJSON_FORCEINLINE Member* SetMembersPointer(Member* members) { return RAPIDJSON_SETPOINTER(Member, data_.o.members, members); }\n\n    // Initialize this value as array with initial data, without calling destructor.\n    void SetArrayRaw(GenericValue* values, SizeType count, Allocator& allocator) {\n        data_.f.flags = kArrayFlag;\n        if (count) {\n            GenericValue* e = static_cast<GenericValue*>(allocator.Malloc(count * sizeof(GenericValue)));\n            SetElementsPointer(e);\nRAPIDJSON_DIAG_PUSH\n#if defined(__GNUC__) && __GNUC__ >= 8\nRAPIDJSON_DIAG_OFF(class-memaccess) // ignore complains from gcc that no trivial copy constructor exists.\n#endif\n            std::memcpy(e, values, count * sizeof(GenericValue));\nRAPIDJSON_DIAG_POP\n        }\n        else\n            SetElementsPointer(0);\n        data_.a.size = data_.a.capacity = count;\n    }\n\n    //! Initialize this value as object with initial data, without calling destructor.\n    void SetObjectRaw(Member* members, SizeType count, Allocator& allocator) {\n        data_.f.flags = kObjectFlag;\n        if (count) {\n            Member* m = static_cast<Member*>(allocator.Malloc(count * sizeof(Member)));\n            SetMembersPointer(m);\nRAPIDJSON_DIAG_PUSH\n#if defined(__GNUC__) && __GNUC__ >= 8\nRAPIDJSON_DIAG_OFF(class-memaccess) // ignore complains from gcc that no trivial copy constructor exists.\n#endif\n            std::memcpy(m, members, count * sizeof(Member));\nRAPIDJSON_DIAG_POP\n        }\n        else\n            SetMembersPointer(0);\n        data_.o.size = data_.o.capacity = count;\n    }\n\n    //! Initialize this value as constant string, without calling destructor.\n    void SetStringRaw(StringRefType s) RAPIDJSON_NOEXCEPT {\n        data_.f.flags = kConstStringFlag;\n        SetStringPointer(s);\n        data_.s.length = s.length;\n    }\n\n    //! Initialize this value as copy string with initial data, without calling destructor.\n    void SetStringRaw(StringRefType s, Allocator& allocator) {\n        Ch* str = 0;\n        if (ShortString::Usable(s.length)) {\n            data_.f.flags = kShortStringFlag;\n            data_.ss.SetLength(s.length);\n            str = data_.ss.str;\n        } else {\n            data_.f.flags = kCopyStringFlag;\n            data_.s.length = s.length;\n            str = static_cast<Ch *>(allocator.Malloc((s.length + 1) * sizeof(Ch)));\n            SetStringPointer(str);\n        }\n        std::memcpy(str, s, s.length * sizeof(Ch));\n        str[s.length] = '\\0';\n    }\n\n    //! Assignment without calling destructor\n    void RawAssign(GenericValue& rhs) RAPIDJSON_NOEXCEPT {\n        data_ = rhs.data_;\n        // data_.f.flags = rhs.data_.f.flags;\n        rhs.data_.f.flags = kNullFlag;\n    }\n\n    template <typename SourceAllocator>\n    bool StringEqual(const GenericValue<Encoding, SourceAllocator>& rhs) const {\n        RAPIDJSON_ASSERT(IsString());\n        RAPIDJSON_ASSERT(rhs.IsString());\n\n        const SizeType len1 = GetStringLength();\n        const SizeType len2 = rhs.GetStringLength();\n        if(len1 != len2) { return false; }\n\n        const Ch* const str1 = GetString();\n        const Ch* const str2 = rhs.GetString();\n        if(str1 == str2) { return true; } // fast path for constant string\n\n        return (std::memcmp(str1, str2, sizeof(Ch) * len1) == 0);\n    }\n\n    Data data_;\n};\n\n//! GenericValue with UTF8 encoding\ntypedef GenericValue<UTF8<> > Value;\n\n///////////////////////////////////////////////////////////////////////////////\n// GenericDocument \n\n//! A document for parsing JSON text as DOM.\n/*!\n    \\note implements Handler concept\n    \\tparam Encoding Encoding for both parsing and string storage.\n    \\tparam Allocator Allocator for allocating memory for the DOM\n    \\tparam StackAllocator Allocator for allocating memory for stack during parsing.\n    \\warning Although GenericDocument inherits from GenericValue, the API does \\b not provide any virtual functions, especially no virtual destructor.  To avoid memory leaks, do not \\c delete a GenericDocument object via a pointer to a GenericValue.\n*/\ntemplate <typename Encoding, typename Allocator = MemoryPoolAllocator<>, typename StackAllocator = CrtAllocator>\nclass GenericDocument : public GenericValue<Encoding, Allocator> {\npublic:\n    typedef typename Encoding::Ch Ch;                       //!< Character type derived from Encoding.\n    typedef GenericValue<Encoding, Allocator> ValueType;    //!< Value type of the document.\n    typedef Allocator AllocatorType;                        //!< Allocator type from template parameter.\n\n    //! Constructor\n    /*! Creates an empty document of specified type.\n        \\param type             Mandatory type of object to create.\n        \\param allocator        Optional allocator for allocating memory.\n        \\param stackCapacity    Optional initial capacity of stack in bytes.\n        \\param stackAllocator   Optional allocator for allocating memory for stack.\n    */\n    explicit GenericDocument(Type type, Allocator* allocator = 0, size_t stackCapacity = kDefaultStackCapacity, StackAllocator* stackAllocator = 0) :\n        GenericValue<Encoding, Allocator>(type),  allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()\n    {\n        if (!allocator_)\n            ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator());\n    }\n\n    //! Constructor\n    /*! Creates an empty document which type is Null. \n        \\param allocator        Optional allocator for allocating memory.\n        \\param stackCapacity    Optional initial capacity of stack in bytes.\n        \\param stackAllocator   Optional allocator for allocating memory for stack.\n    */\n    GenericDocument(Allocator* allocator = 0, size_t stackCapacity = kDefaultStackCapacity, StackAllocator* stackAllocator = 0) : \n        allocator_(allocator), ownAllocator_(0), stack_(stackAllocator, stackCapacity), parseResult_()\n    {\n        if (!allocator_)\n            ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator());\n    }\n\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\n    //! Move constructor in C++11\n    GenericDocument(GenericDocument&& rhs) RAPIDJSON_NOEXCEPT\n        : ValueType(std::forward<ValueType>(rhs)), // explicit cast to avoid prohibited move from Document\n          allocator_(rhs.allocator_),\n          ownAllocator_(rhs.ownAllocator_),\n          stack_(std::move(rhs.stack_)),\n          parseResult_(rhs.parseResult_)\n    {\n        rhs.allocator_ = 0;\n        rhs.ownAllocator_ = 0;\n        rhs.parseResult_ = ParseResult();\n    }\n#endif\n\n    ~GenericDocument() {\n        Destroy();\n    }\n\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\n    //! Move assignment in C++11\n    GenericDocument& operator=(GenericDocument&& rhs) RAPIDJSON_NOEXCEPT\n    {\n        // The cast to ValueType is necessary here, because otherwise it would\n        // attempt to call GenericValue's templated assignment operator.\n        ValueType::operator=(std::forward<ValueType>(rhs));\n\n        // Calling the destructor here would prematurely call stack_'s destructor\n        Destroy();\n\n        allocator_ = rhs.allocator_;\n        ownAllocator_ = rhs.ownAllocator_;\n        stack_ = std::move(rhs.stack_);\n        parseResult_ = rhs.parseResult_;\n\n        rhs.allocator_ = 0;\n        rhs.ownAllocator_ = 0;\n        rhs.parseResult_ = ParseResult();\n\n        return *this;\n    }\n#endif\n\n    //! Exchange the contents of this document with those of another.\n    /*!\n        \\param rhs Another document.\n        \\note Constant complexity.\n        \\see GenericValue::Swap\n    */\n    GenericDocument& Swap(GenericDocument& rhs) RAPIDJSON_NOEXCEPT {\n        ValueType::Swap(rhs);\n        stack_.Swap(rhs.stack_);\n        internal::Swap(allocator_, rhs.allocator_);\n        internal::Swap(ownAllocator_, rhs.ownAllocator_);\n        internal::Swap(parseResult_, rhs.parseResult_);\n        return *this;\n    }\n\n    //! free-standing swap function helper\n    /*!\n        Helper function to enable support for common swap implementation pattern based on \\c std::swap:\n        \\code\n        void swap(MyClass& a, MyClass& b) {\n            using std::swap;\n            swap(a.doc, b.doc);\n            // ...\n        }\n        \\endcode\n        \\see Swap()\n     */\n    friend inline void swap(GenericDocument& a, GenericDocument& b) RAPIDJSON_NOEXCEPT { a.Swap(b); }\n\n    //! Populate this document by a generator which produces SAX events.\n    /*! \\tparam Generator A functor with <tt>bool f(Handler)</tt> prototype.\n        \\param g Generator functor which sends SAX events to the parameter.\n        \\return The document itself for fluent API.\n    */\n    template <typename Generator>\n    GenericDocument& Populate(Generator& g) {\n        ClearStackOnExit scope(*this);\n        if (g(*this)) {\n            RAPIDJSON_ASSERT(stack_.GetSize() == sizeof(ValueType)); // Got one and only one root object\n            ValueType::operator=(*stack_.template Pop<ValueType>(1));// Move value from stack to document\n        }\n        return *this;\n    }\n\n    //!@name Parse from stream\n    //!@{\n\n    //! Parse JSON text from an input stream (with Encoding conversion)\n    /*! \\tparam parseFlags Combination of \\ref ParseFlag.\n        \\tparam SourceEncoding Encoding of input stream\n        \\tparam InputStream Type of input stream, implementing Stream concept\n        \\param is Input stream to be parsed.\n        \\return The document itself for fluent API.\n    */\n    template <unsigned parseFlags, typename SourceEncoding, typename InputStream>\n    GenericDocument& ParseStream(InputStream& is) {\n        GenericReader<SourceEncoding, Encoding, StackAllocator> reader(\n            stack_.HasAllocator() ? &stack_.GetAllocator() : 0);\n        ClearStackOnExit scope(*this);\n        parseResult_ = reader.template Parse<parseFlags>(is, *this);\n        if (parseResult_) {\n            RAPIDJSON_ASSERT(stack_.GetSize() == sizeof(ValueType)); // Got one and only one root object\n            ValueType::operator=(*stack_.template Pop<ValueType>(1));// Move value from stack to document\n        }\n        return *this;\n    }\n\n    //! Parse JSON text from an input stream\n    /*! \\tparam parseFlags Combination of \\ref ParseFlag.\n        \\tparam InputStream Type of input stream, implementing Stream concept\n        \\param is Input stream to be parsed.\n        \\return The document itself for fluent API.\n    */\n    template <unsigned parseFlags, typename InputStream>\n    GenericDocument& ParseStream(InputStream& is) {\n        return ParseStream<parseFlags, Encoding, InputStream>(is);\n    }\n\n    //! Parse JSON text from an input stream (with \\ref kParseDefaultFlags)\n    /*! \\tparam InputStream Type of input stream, implementing Stream concept\n        \\param is Input stream to be parsed.\n        \\return The document itself for fluent API.\n    */\n    template <typename InputStream>\n    GenericDocument& ParseStream(InputStream& is) {\n        return ParseStream<kParseDefaultFlags, Encoding, InputStream>(is);\n    }\n    //!@}\n\n    //!@name Parse in-place from mutable string\n    //!@{\n\n    //! Parse JSON text from a mutable string\n    /*! \\tparam parseFlags Combination of \\ref ParseFlag.\n        \\param str Mutable zero-terminated string to be parsed.\n        \\return The document itself for fluent API.\n    */\n    template <unsigned parseFlags>\n    GenericDocument& ParseInsitu(Ch* str) {\n        GenericInsituStringStream<Encoding> s(str);\n        return ParseStream<parseFlags | kParseInsituFlag>(s);\n    }\n\n    //! Parse JSON text from a mutable string (with \\ref kParseDefaultFlags)\n    /*! \\param str Mutable zero-terminated string to be parsed.\n        \\return The document itself for fluent API.\n    */\n    GenericDocument& ParseInsitu(Ch* str) {\n        return ParseInsitu<kParseDefaultFlags>(str);\n    }\n    //!@}\n\n    //!@name Parse from read-only string\n    //!@{\n\n    //! Parse JSON text from a read-only string (with Encoding conversion)\n    /*! \\tparam parseFlags Combination of \\ref ParseFlag (must not contain \\ref kParseInsituFlag).\n        \\tparam SourceEncoding Transcoding from input Encoding\n        \\param str Read-only zero-terminated string to be parsed.\n    */\n    template <unsigned parseFlags, typename SourceEncoding>\n    GenericDocument& Parse(const typename SourceEncoding::Ch* str) {\n        RAPIDJSON_ASSERT(!(parseFlags & kParseInsituFlag));\n        GenericStringStream<SourceEncoding> s(str);\n        return ParseStream<parseFlags, SourceEncoding>(s);\n    }\n\n    //! Parse JSON text from a read-only string\n    /*! \\tparam parseFlags Combination of \\ref ParseFlag (must not contain \\ref kParseInsituFlag).\n        \\param str Read-only zero-terminated string to be parsed.\n    */\n    template <unsigned parseFlags>\n    GenericDocument& Parse(const Ch* str) {\n        return Parse<parseFlags, Encoding>(str);\n    }\n\n    //! Parse JSON text from a read-only string (with \\ref kParseDefaultFlags)\n    /*! \\param str Read-only zero-terminated string to be parsed.\n    */\n    GenericDocument& Parse(const Ch* str) {\n        return Parse<kParseDefaultFlags>(str);\n    }\n\n    template <unsigned parseFlags, typename SourceEncoding>\n    GenericDocument& Parse(const typename SourceEncoding::Ch* str, size_t length) {\n        RAPIDJSON_ASSERT(!(parseFlags & kParseInsituFlag));\n        MemoryStream ms(static_cast<const char*>(str), length * sizeof(typename SourceEncoding::Ch));\n        EncodedInputStream<SourceEncoding, MemoryStream> is(ms);\n        ParseStream<parseFlags, SourceEncoding>(is);\n        return *this;\n    }\n\n    template <unsigned parseFlags>\n    GenericDocument& Parse(const Ch* str, size_t length) {\n        return Parse<parseFlags, Encoding>(str, length);\n    }\n    \n    GenericDocument& Parse(const Ch* str, size_t length) {\n        return Parse<kParseDefaultFlags>(str, length);\n    }\n\n#if RAPIDJSON_HAS_STDSTRING\n    template <unsigned parseFlags, typename SourceEncoding>\n    GenericDocument& Parse(const std::basic_string<typename SourceEncoding::Ch>& str) {\n        // c_str() is constant complexity according to standard. Should be faster than Parse(const char*, size_t)\n        return Parse<parseFlags, SourceEncoding>(str.c_str());\n    }\n\n    template <unsigned parseFlags>\n    GenericDocument& Parse(const std::basic_string<Ch>& str) {\n        return Parse<parseFlags, Encoding>(str.c_str());\n    }\n\n    GenericDocument& Parse(const std::basic_string<Ch>& str) {\n        return Parse<kParseDefaultFlags>(str);\n    }\n#endif // RAPIDJSON_HAS_STDSTRING    \n\n    //!@}\n\n    //!@name Handling parse errors\n    //!@{\n\n    //! Whether a parse error has occured in the last parsing.\n    bool HasParseError() const { return parseResult_.IsError(); }\n\n    //! Get the \\ref ParseErrorCode of last parsing.\n    ParseErrorCode GetParseError() const { return parseResult_.Code(); }\n\n    //! Get the position of last parsing error in input, 0 otherwise.\n    size_t GetErrorOffset() const { return parseResult_.Offset(); }\n\n    //! Implicit conversion to get the last parse result\n#ifndef __clang // -Wdocumentation\n    /*! \\return \\ref ParseResult of the last parse operation\n\n        \\code\n          Document doc;\n          ParseResult ok = doc.Parse(json);\n          if (!ok)\n            printf( \"JSON parse error: %s (%u)\\n\", GetParseError_En(ok.Code()), ok.Offset());\n        \\endcode\n     */\n#endif\n    operator ParseResult() const { return parseResult_; }\n    //!@}\n\n    //! Get the allocator of this document.\n    Allocator& GetAllocator() {\n        RAPIDJSON_ASSERT(allocator_);\n        return *allocator_;\n    }\n\n    //! Get the capacity of stack in bytes.\n    size_t GetStackCapacity() const { return stack_.GetCapacity(); }\n\nprivate:\n    // clear stack on any exit from ParseStream, e.g. due to exception\n    struct ClearStackOnExit {\n        explicit ClearStackOnExit(GenericDocument& d) : d_(d) {}\n        ~ClearStackOnExit() { d_.ClearStack(); }\n    private:\n        ClearStackOnExit(const ClearStackOnExit&);\n        ClearStackOnExit& operator=(const ClearStackOnExit&);\n        GenericDocument& d_;\n    };\n\n    // callers of the following private Handler functions\n    // template <typename,typename,typename> friend class GenericReader; // for parsing\n    template <typename, typename> friend class GenericValue; // for deep copying\n\npublic:\n    // Implementation of Handler\n    bool Null() { new (stack_.template Push<ValueType>()) ValueType(); return true; }\n    bool Bool(bool b) { new (stack_.template Push<ValueType>()) ValueType(b); return true; }\n    bool Int(int i) { new (stack_.template Push<ValueType>()) ValueType(i); return true; }\n    bool Uint(unsigned i) { new (stack_.template Push<ValueType>()) ValueType(i); return true; }\n    bool Int64(int64_t i) { new (stack_.template Push<ValueType>()) ValueType(i); return true; }\n    bool Uint64(uint64_t i) { new (stack_.template Push<ValueType>()) ValueType(i); return true; }\n    bool Double(double d) { new (stack_.template Push<ValueType>()) ValueType(d); return true; }\n\n    bool RawNumber(const Ch* str, SizeType length, bool copy) { \n        if (copy) \n            new (stack_.template Push<ValueType>()) ValueType(str, length, GetAllocator());\n        else\n            new (stack_.template Push<ValueType>()) ValueType(str, length);\n        return true;\n    }\n\n    bool String(const Ch* str, SizeType length, bool copy) { \n        if (copy) \n            new (stack_.template Push<ValueType>()) ValueType(str, length, GetAllocator());\n        else\n            new (stack_.template Push<ValueType>()) ValueType(str, length);\n        return true;\n    }\n\n    bool StartObject() { new (stack_.template Push<ValueType>()) ValueType(kObjectType); return true; }\n    \n    bool Key(const Ch* str, SizeType length, bool copy) { return String(str, length, copy); }\n\n    bool EndObject(SizeType memberCount) {\n        typename ValueType::Member* members = stack_.template Pop<typename ValueType::Member>(memberCount);\n        stack_.template Top<ValueType>()->SetObjectRaw(members, memberCount, GetAllocator());\n        return true;\n    }\n\n    bool StartArray() { new (stack_.template Push<ValueType>()) ValueType(kArrayType); return true; }\n    \n    bool EndArray(SizeType elementCount) {\n        ValueType* elements = stack_.template Pop<ValueType>(elementCount);\n        stack_.template Top<ValueType>()->SetArrayRaw(elements, elementCount, GetAllocator());\n        return true;\n    }\n\nprivate:\n    //! Prohibit copying\n    GenericDocument(const GenericDocument&);\n    //! Prohibit assignment\n    GenericDocument& operator=(const GenericDocument&);\n\n    void ClearStack() {\n        if (Allocator::kNeedFree)\n            while (stack_.GetSize() > 0)    // Here assumes all elements in stack array are GenericValue (Member is actually 2 GenericValue objects)\n                (stack_.template Pop<ValueType>(1))->~ValueType();\n        else\n            stack_.Clear();\n        stack_.ShrinkToFit();\n    }\n\n    void Destroy() {\n        RAPIDJSON_DELETE(ownAllocator_);\n    }\n\n    static const size_t kDefaultStackCapacity = 1024;\n    Allocator* allocator_;\n    Allocator* ownAllocator_;\n    internal::Stack<StackAllocator> stack_;\n    ParseResult parseResult_;\n};\n\n//! GenericDocument with UTF8 encoding\ntypedef GenericDocument<UTF8<> > Document;\n\n// defined here due to the dependency on GenericDocument\ntemplate <typename Encoding, typename Allocator>\ntemplate <typename SourceAllocator>\ninline\nGenericValue<Encoding,Allocator>::GenericValue(const GenericValue<Encoding,SourceAllocator>& rhs, Allocator& allocator)\n{\n    switch (rhs.GetType()) {\n    case kObjectType:\n    case kArrayType: { // perform deep copy via SAX Handler\n            GenericDocument<Encoding,Allocator> d(&allocator);\n            rhs.Accept(d);\n            RawAssign(*d.stack_.template Pop<GenericValue>(1));\n        }\n        break;\n    case kStringType:\n        if (rhs.data_.f.flags == kConstStringFlag) {\n            data_.f.flags = rhs.data_.f.flags;\n            data_  = *reinterpret_cast<const Data*>(&rhs.data_);\n        } else {\n            SetStringRaw(StringRef(rhs.GetString(), rhs.GetStringLength()), allocator);\n        }\n        break;\n    default:\n        data_.f.flags = rhs.data_.f.flags;\n        data_  = *reinterpret_cast<const Data*>(&rhs.data_);\n        break;\n    }\n}\n\n//! Helper class for accessing Value of array type.\n/*!\n    Instance of this helper class is obtained by \\c GenericValue::GetArray().\n    In addition to all APIs for array type, it provides range-based for loop if \\c RAPIDJSON_HAS_CXX11_RANGE_FOR=1.\n*/\ntemplate <bool Const, typename ValueT>\nclass GenericArray {\npublic:\n    typedef GenericArray<true, ValueT> ConstArray;\n    typedef GenericArray<false, ValueT> Array;\n    typedef ValueT PlainType;\n    typedef typename internal::MaybeAddConst<Const,PlainType>::Type ValueType;\n    typedef ValueType* ValueIterator;  // This may be const or non-const iterator\n    typedef const ValueT* ConstValueIterator;\n    typedef typename ValueType::AllocatorType AllocatorType;\n    typedef typename ValueType::StringRefType StringRefType;\n\n    template <typename, typename>\n    friend class GenericValue;\n\n    GenericArray(const GenericArray& rhs) : value_(rhs.value_) {}\n    GenericArray& operator=(const GenericArray& rhs) { value_ = rhs.value_; return *this; }\n    ~GenericArray() {}\n\n    SizeType Size() const { return value_.Size(); }\n    SizeType Capacity() const { return value_.Capacity(); }\n    bool Empty() const { return value_.Empty(); }\n    void Clear() const { value_.Clear(); }\n    ValueType& operator[](SizeType index) const {  return value_[index]; }\n    ValueIterator Begin() const { return value_.Begin(); }\n    ValueIterator End() const { return value_.End(); }\n    GenericArray Reserve(SizeType newCapacity, AllocatorType &allocator) const { value_.Reserve(newCapacity, allocator); return *this; }\n    GenericArray PushBack(ValueType& value, AllocatorType& allocator) const { value_.PushBack(value, allocator); return *this; }\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\n    GenericArray PushBack(ValueType&& value, AllocatorType& allocator) const { value_.PushBack(value, allocator); return *this; }\n#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS\n    GenericArray PushBack(StringRefType value, AllocatorType& allocator) const { value_.PushBack(value, allocator); return *this; }\n    template <typename T> RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T> >), (const GenericArray&)) PushBack(T value, AllocatorType& allocator) const { value_.PushBack(value, allocator); return *this; }\n    GenericArray PopBack() const { value_.PopBack(); return *this; }\n    ValueIterator Erase(ConstValueIterator pos) const { return value_.Erase(pos); }\n    ValueIterator Erase(ConstValueIterator first, ConstValueIterator last) const { return value_.Erase(first, last); }\n\n#if RAPIDJSON_HAS_CXX11_RANGE_FOR\n    ValueIterator begin() const { return value_.Begin(); }\n    ValueIterator end() const { return value_.End(); }\n#endif\n\nprivate:\n    GenericArray();\n    GenericArray(ValueType& value) : value_(value) {}\n    ValueType& value_;\n};\n\n//! Helper class for accessing Value of object type.\n/*!\n    Instance of this helper class is obtained by \\c GenericValue::GetObject().\n    In addition to all APIs for array type, it provides range-based for loop if \\c RAPIDJSON_HAS_CXX11_RANGE_FOR=1.\n*/\ntemplate <bool Const, typename ValueT>\nclass GenericObject {\npublic:\n    typedef GenericObject<true, ValueT> ConstObject;\n    typedef GenericObject<false, ValueT> Object;\n    typedef ValueT PlainType;\n    typedef typename internal::MaybeAddConst<Const,PlainType>::Type ValueType;\n    typedef GenericMemberIterator<Const, typename ValueT::EncodingType, typename ValueT::AllocatorType> MemberIterator;  // This may be const or non-const iterator\n    typedef GenericMemberIterator<true, typename ValueT::EncodingType, typename ValueT::AllocatorType> ConstMemberIterator;\n    typedef typename ValueType::AllocatorType AllocatorType;\n    typedef typename ValueType::StringRefType StringRefType;\n    typedef typename ValueType::EncodingType EncodingType;\n    typedef typename ValueType::Ch Ch;\n\n    template <typename, typename>\n    friend class GenericValue;\n\n    GenericObject(const GenericObject& rhs) : value_(rhs.value_) {}\n    GenericObject& operator=(const GenericObject& rhs) { value_ = rhs.value_; return *this; }\n    ~GenericObject() {}\n\n    SizeType MemberCount() const { return value_.MemberCount(); }\n    bool ObjectEmpty() const { return value_.ObjectEmpty(); }\n    template <typename T> ValueType& operator[](T* name) const { return value_[name]; }\n    template <typename SourceAllocator> ValueType& operator[](const GenericValue<EncodingType, SourceAllocator>& name) const { return value_[name]; }\n#if RAPIDJSON_HAS_STDSTRING\n    ValueType& operator[](const std::basic_string<Ch>& name) const { return value_[name]; }\n#endif\n    MemberIterator MemberBegin() const { return value_.MemberBegin(); }\n    MemberIterator MemberEnd() const { return value_.MemberEnd(); }\n    bool HasMember(const Ch* name) const { return value_.HasMember(name); }\n#if RAPIDJSON_HAS_STDSTRING\n    bool HasMember(const std::basic_string<Ch>& name) const { return value_.HasMember(name); }\n#endif\n    template <typename SourceAllocator> bool HasMember(const GenericValue<EncodingType, SourceAllocator>& name) const { return value_.HasMember(name); }\n    MemberIterator FindMember(const Ch* name) const { return value_.FindMember(name); }\n    template <typename SourceAllocator> MemberIterator FindMember(const GenericValue<EncodingType, SourceAllocator>& name) const { return value_.FindMember(name); }\n#if RAPIDJSON_HAS_STDSTRING\n    MemberIterator FindMember(const std::basic_string<Ch>& name) const { return value_.FindMember(name); }\n#endif\n    GenericObject AddMember(ValueType& name, ValueType& value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; }\n    GenericObject AddMember(ValueType& name, StringRefType value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; }\n#if RAPIDJSON_HAS_STDSTRING\n    GenericObject AddMember(ValueType& name, std::basic_string<Ch>& value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; }\n#endif\n    template <typename T> RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T> >), (ValueType&)) AddMember(ValueType& name, T value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; }\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\n    GenericObject AddMember(ValueType&& name, ValueType&& value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; }\n    GenericObject AddMember(ValueType&& name, ValueType& value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; }\n    GenericObject AddMember(ValueType& name, ValueType&& value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; }\n    GenericObject AddMember(StringRefType name, ValueType&& value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; }\n#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS\n    GenericObject AddMember(StringRefType name, ValueType& value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; }\n    GenericObject AddMember(StringRefType name, StringRefType value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; }\n    template <typename T> RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T> >), (GenericObject)) AddMember(StringRefType name, T value, AllocatorType& allocator) const { value_.AddMember(name, value, allocator); return *this; }\n    void RemoveAllMembers() { return value_.RemoveAllMembers(); }\n    bool RemoveMember(const Ch* name) const { return value_.RemoveMember(name); }\n#if RAPIDJSON_HAS_STDSTRING\n    bool RemoveMember(const std::basic_string<Ch>& name) const { return value_.RemoveMember(name); }\n#endif\n    template <typename SourceAllocator> bool RemoveMember(const GenericValue<EncodingType, SourceAllocator>& name) const { return value_.RemoveMember(name); }\n    MemberIterator RemoveMember(MemberIterator m) const { return value_.RemoveMember(m); }\n    MemberIterator EraseMember(ConstMemberIterator pos) const { return value_.EraseMember(pos); }\n    MemberIterator EraseMember(ConstMemberIterator first, ConstMemberIterator last) const { return value_.EraseMember(first, last); }\n    bool EraseMember(const Ch* name) const { return value_.EraseMember(name); }\n#if RAPIDJSON_HAS_STDSTRING\n    bool EraseMember(const std::basic_string<Ch>& name) const { return EraseMember(ValueType(StringRef(name))); }\n#endif\n    template <typename SourceAllocator> bool EraseMember(const GenericValue<EncodingType, SourceAllocator>& name) const { return value_.EraseMember(name); }\n\n#if RAPIDJSON_HAS_CXX11_RANGE_FOR\n    MemberIterator begin() const { return value_.MemberBegin(); }\n    MemberIterator end() const { return value_.MemberEnd(); }\n#endif\n\nprivate:\n    GenericObject();\n    GenericObject(ValueType& value) : value_(value) {}\n    ValueType& value_;\n};\n\nRAPIDJSON_NAMESPACE_END\nRAPIDJSON_DIAG_POP\n\n#endif // RAPIDJSON_DOCUMENT_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/encodedstream.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_ENCODEDSTREAM_H_\n#define RAPIDJSON_ENCODEDSTREAM_H_\n\n#include \"stream.h\"\n#include \"memorystream.h\"\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(effc++)\n#endif\n\n#ifdef __clang__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(padded)\n#endif\n\nRAPIDJSON_NAMESPACE_BEGIN\n\n//! Input byte stream wrapper with a statically bound encoding.\n/*!\n    \\tparam Encoding The interpretation of encoding of the stream. Either UTF8, UTF16LE, UTF16BE, UTF32LE, UTF32BE.\n    \\tparam InputByteStream Type of input byte stream. For example, FileReadStream.\n*/\ntemplate <typename Encoding, typename InputByteStream>\nclass EncodedInputStream {\n    RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1);\npublic:\n    typedef typename Encoding::Ch Ch;\n\n    EncodedInputStream(InputByteStream& is) : is_(is) { \n        current_ = Encoding::TakeBOM(is_);\n    }\n\n    Ch Peek() const { return current_; }\n    Ch Take() { Ch c = current_; current_ = Encoding::Take(is_); return c; }\n    size_t Tell() const { return is_.Tell(); }\n\n    // Not implemented\n    void Put(Ch) { RAPIDJSON_ASSERT(false); }\n    void Flush() { RAPIDJSON_ASSERT(false); } \n    Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }\n    size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }\n\nprivate:\n    EncodedInputStream(const EncodedInputStream&);\n    EncodedInputStream& operator=(const EncodedInputStream&);\n\n    InputByteStream& is_;\n    Ch current_;\n};\n\n//! Specialized for UTF8 MemoryStream.\ntemplate <>\nclass EncodedInputStream<UTF8<>, MemoryStream> {\npublic:\n    typedef UTF8<>::Ch Ch;\n\n    EncodedInputStream(MemoryStream& is) : is_(is) {\n        if (static_cast<unsigned char>(is_.Peek()) == 0xEFu) is_.Take();\n        if (static_cast<unsigned char>(is_.Peek()) == 0xBBu) is_.Take();\n        if (static_cast<unsigned char>(is_.Peek()) == 0xBFu) is_.Take();\n    }\n    Ch Peek() const { return is_.Peek(); }\n    Ch Take() { return is_.Take(); }\n    size_t Tell() const { return is_.Tell(); }\n\n    // Not implemented\n    void Put(Ch) {}\n    void Flush() {} \n    Ch* PutBegin() { return 0; }\n    size_t PutEnd(Ch*) { return 0; }\n\n    MemoryStream& is_;\n\nprivate:\n    EncodedInputStream(const EncodedInputStream&);\n    EncodedInputStream& operator=(const EncodedInputStream&);\n};\n\n//! Output byte stream wrapper with statically bound encoding.\n/*!\n    \\tparam Encoding The interpretation of encoding of the stream. Either UTF8, UTF16LE, UTF16BE, UTF32LE, UTF32BE.\n    \\tparam OutputByteStream Type of input byte stream. For example, FileWriteStream.\n*/\ntemplate <typename Encoding, typename OutputByteStream>\nclass EncodedOutputStream {\n    RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1);\npublic:\n    typedef typename Encoding::Ch Ch;\n\n    EncodedOutputStream(OutputByteStream& os, bool putBOM = true) : os_(os) { \n        if (putBOM)\n            Encoding::PutBOM(os_);\n    }\n\n    void Put(Ch c) { Encoding::Put(os_, c);  }\n    void Flush() { os_.Flush(); }\n\n    // Not implemented\n    Ch Peek() const { RAPIDJSON_ASSERT(false); return 0;}\n    Ch Take() { RAPIDJSON_ASSERT(false); return 0;}\n    size_t Tell() const { RAPIDJSON_ASSERT(false);  return 0; }\n    Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }\n    size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }\n\nprivate:\n    EncodedOutputStream(const EncodedOutputStream&);\n    EncodedOutputStream& operator=(const EncodedOutputStream&);\n\n    OutputByteStream& os_;\n};\n\n#define RAPIDJSON_ENCODINGS_FUNC(x) UTF8<Ch>::x, UTF16LE<Ch>::x, UTF16BE<Ch>::x, UTF32LE<Ch>::x, UTF32BE<Ch>::x\n\n//! Input stream wrapper with dynamically bound encoding and automatic encoding detection.\n/*!\n    \\tparam CharType Type of character for reading.\n    \\tparam InputByteStream type of input byte stream to be wrapped.\n*/\ntemplate <typename CharType, typename InputByteStream>\nclass AutoUTFInputStream {\n    RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1);\npublic:\n    typedef CharType Ch;\n\n    //! Constructor.\n    /*!\n        \\param is input stream to be wrapped.\n        \\param type UTF encoding type if it is not detected from the stream.\n    */\n    AutoUTFInputStream(InputByteStream& is, UTFType type = kUTF8) : is_(&is), type_(type), hasBOM_(false) {\n        RAPIDJSON_ASSERT(type >= kUTF8 && type <= kUTF32BE);        \n        DetectType();\n        static const TakeFunc f[] = { RAPIDJSON_ENCODINGS_FUNC(Take) };\n        takeFunc_ = f[type_];\n        current_ = takeFunc_(*is_);\n    }\n\n    UTFType GetType() const { return type_; }\n    bool HasBOM() const { return hasBOM_; }\n\n    Ch Peek() const { return current_; }\n    Ch Take() { Ch c = current_; current_ = takeFunc_(*is_); return c; }\n    size_t Tell() const { return is_->Tell(); }\n\n    // Not implemented\n    void Put(Ch) { RAPIDJSON_ASSERT(false); }\n    void Flush() { RAPIDJSON_ASSERT(false); } \n    Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }\n    size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }\n\nprivate:\n    AutoUTFInputStream(const AutoUTFInputStream&);\n    AutoUTFInputStream& operator=(const AutoUTFInputStream&);\n\n    // Detect encoding type with BOM or RFC 4627\n    void DetectType() {\n        // BOM (Byte Order Mark):\n        // 00 00 FE FF  UTF-32BE\n        // FF FE 00 00  UTF-32LE\n        // FE FF        UTF-16BE\n        // FF FE        UTF-16LE\n        // EF BB BF     UTF-8\n\n        const unsigned char* c = reinterpret_cast<const unsigned char *>(is_->Peek4());\n        if (!c)\n            return;\n\n        unsigned bom = static_cast<unsigned>(c[0] | (c[1] << 8) | (c[2] << 16) | (c[3] << 24));\n        hasBOM_ = false;\n        if (bom == 0xFFFE0000)                  { type_ = kUTF32BE; hasBOM_ = true; is_->Take(); is_->Take(); is_->Take(); is_->Take(); }\n        else if (bom == 0x0000FEFF)             { type_ = kUTF32LE; hasBOM_ = true; is_->Take(); is_->Take(); is_->Take(); is_->Take(); }\n        else if ((bom & 0xFFFF) == 0xFFFE)      { type_ = kUTF16BE; hasBOM_ = true; is_->Take(); is_->Take();                           }\n        else if ((bom & 0xFFFF) == 0xFEFF)      { type_ = kUTF16LE; hasBOM_ = true; is_->Take(); is_->Take();                           }\n        else if ((bom & 0xFFFFFF) == 0xBFBBEF)  { type_ = kUTF8;    hasBOM_ = true; is_->Take(); is_->Take(); is_->Take();              }\n\n        // RFC 4627: Section 3\n        // \"Since the first two characters of a JSON text will always be ASCII\n        // characters [RFC0020], it is possible to determine whether an octet\n        // stream is UTF-8, UTF-16 (BE or LE), or UTF-32 (BE or LE) by looking\n        // at the pattern of nulls in the first four octets.\"\n        // 00 00 00 xx  UTF-32BE\n        // 00 xx 00 xx  UTF-16BE\n        // xx 00 00 00  UTF-32LE\n        // xx 00 xx 00  UTF-16LE\n        // xx xx xx xx  UTF-8\n\n        if (!hasBOM_) {\n            unsigned pattern = (c[0] ? 1 : 0) | (c[1] ? 2 : 0) | (c[2] ? 4 : 0) | (c[3] ? 8 : 0);\n            switch (pattern) {\n            case 0x08: type_ = kUTF32BE; break;\n            case 0x0A: type_ = kUTF16BE; break;\n            case 0x01: type_ = kUTF32LE; break;\n            case 0x05: type_ = kUTF16LE; break;\n            case 0x0F: type_ = kUTF8;    break;\n            default: break; // Use type defined by user.\n            }\n        }\n\n        // Runtime check whether the size of character type is sufficient. It only perform checks with assertion.\n        if (type_ == kUTF16LE || type_ == kUTF16BE) RAPIDJSON_ASSERT(sizeof(Ch) >= 2);\n        if (type_ == kUTF32LE || type_ == kUTF32BE) RAPIDJSON_ASSERT(sizeof(Ch) >= 4);\n    }\n\n    typedef Ch (*TakeFunc)(InputByteStream& is);\n    InputByteStream* is_;\n    UTFType type_;\n    Ch current_;\n    TakeFunc takeFunc_;\n    bool hasBOM_;\n};\n\n//! Output stream wrapper with dynamically bound encoding and automatic encoding detection.\n/*!\n    \\tparam CharType Type of character for writing.\n    \\tparam OutputByteStream type of output byte stream to be wrapped.\n*/\ntemplate <typename CharType, typename OutputByteStream>\nclass AutoUTFOutputStream {\n    RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1);\npublic:\n    typedef CharType Ch;\n\n    //! Constructor.\n    /*!\n        \\param os output stream to be wrapped.\n        \\param type UTF encoding type.\n        \\param putBOM Whether to write BOM at the beginning of the stream.\n    */\n    AutoUTFOutputStream(OutputByteStream& os, UTFType type, bool putBOM) : os_(&os), type_(type) {\n        RAPIDJSON_ASSERT(type >= kUTF8 && type <= kUTF32BE);\n\n        // Runtime check whether the size of character type is sufficient. It only perform checks with assertion.\n        if (type_ == kUTF16LE || type_ == kUTF16BE) RAPIDJSON_ASSERT(sizeof(Ch) >= 2);\n        if (type_ == kUTF32LE || type_ == kUTF32BE) RAPIDJSON_ASSERT(sizeof(Ch) >= 4);\n\n        static const PutFunc f[] = { RAPIDJSON_ENCODINGS_FUNC(Put) };\n        putFunc_ = f[type_];\n\n        if (putBOM)\n            PutBOM();\n    }\n\n    UTFType GetType() const { return type_; }\n\n    void Put(Ch c) { putFunc_(*os_, c); }\n    void Flush() { os_->Flush(); } \n\n    // Not implemented\n    Ch Peek() const { RAPIDJSON_ASSERT(false); return 0;}\n    Ch Take() { RAPIDJSON_ASSERT(false); return 0;}\n    size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; }\n    Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }\n    size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }\n\nprivate:\n    AutoUTFOutputStream(const AutoUTFOutputStream&);\n    AutoUTFOutputStream& operator=(const AutoUTFOutputStream&);\n\n    void PutBOM() { \n        typedef void (*PutBOMFunc)(OutputByteStream&);\n        static const PutBOMFunc f[] = { RAPIDJSON_ENCODINGS_FUNC(PutBOM) };\n        f[type_](*os_);\n    }\n\n    typedef void (*PutFunc)(OutputByteStream&, Ch);\n\n    OutputByteStream* os_;\n    UTFType type_;\n    PutFunc putFunc_;\n};\n\n#undef RAPIDJSON_ENCODINGS_FUNC\n\nRAPIDJSON_NAMESPACE_END\n\n#ifdef __clang__\nRAPIDJSON_DIAG_POP\n#endif\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_POP\n#endif\n\n#endif // RAPIDJSON_FILESTREAM_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/encodings.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_ENCODINGS_H_\n#define RAPIDJSON_ENCODINGS_H_\n\n#include \"rapidjson.h\"\n\n#ifdef _MSC_VER\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(4244) // conversion from 'type1' to 'type2', possible loss of data\nRAPIDJSON_DIAG_OFF(4702)  // unreachable code\n#elif defined(__GNUC__)\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(effc++)\nRAPIDJSON_DIAG_OFF(overflow)\n#endif\n\nRAPIDJSON_NAMESPACE_BEGIN\n\n///////////////////////////////////////////////////////////////////////////////\n// Encoding\n\n/*! \\class rapidjson::Encoding\n    \\brief Concept for encoding of Unicode characters.\n\n\\code\nconcept Encoding {\n    typename Ch;    //! Type of character. A \"character\" is actually a code unit in unicode's definition.\n\n    enum { supportUnicode = 1 }; // or 0 if not supporting unicode\n\n    //! \\brief Encode a Unicode codepoint to an output stream.\n    //! \\param os Output stream.\n    //! \\param codepoint An unicode codepoint, ranging from 0x0 to 0x10FFFF inclusively.\n    template<typename OutputStream>\n    static void Encode(OutputStream& os, unsigned codepoint);\n\n    //! \\brief Decode a Unicode codepoint from an input stream.\n    //! \\param is Input stream.\n    //! \\param codepoint Output of the unicode codepoint.\n    //! \\return true if a valid codepoint can be decoded from the stream.\n    template <typename InputStream>\n    static bool Decode(InputStream& is, unsigned* codepoint);\n\n    //! \\brief Validate one Unicode codepoint from an encoded stream.\n    //! \\param is Input stream to obtain codepoint.\n    //! \\param os Output for copying one codepoint.\n    //! \\return true if it is valid.\n    //! \\note This function just validating and copying the codepoint without actually decode it.\n    template <typename InputStream, typename OutputStream>\n    static bool Validate(InputStream& is, OutputStream& os);\n\n    // The following functions are deal with byte streams.\n\n    //! Take a character from input byte stream, skip BOM if exist.\n    template <typename InputByteStream>\n    static CharType TakeBOM(InputByteStream& is);\n\n    //! Take a character from input byte stream.\n    template <typename InputByteStream>\n    static Ch Take(InputByteStream& is);\n\n    //! Put BOM to output byte stream.\n    template <typename OutputByteStream>\n    static void PutBOM(OutputByteStream& os);\n\n    //! Put a character to output byte stream.\n    template <typename OutputByteStream>\n    static void Put(OutputByteStream& os, Ch c);\n};\n\\endcode\n*/\n\n///////////////////////////////////////////////////////////////////////////////\n// UTF8\n\n//! UTF-8 encoding.\n/*! http://en.wikipedia.org/wiki/UTF-8\n    http://tools.ietf.org/html/rfc3629\n    \\tparam CharType Code unit for storing 8-bit UTF-8 data. Default is char.\n    \\note implements Encoding concept\n*/\ntemplate<typename CharType = char>\nstruct UTF8 {\n    typedef CharType Ch;\n\n    enum { supportUnicode = 1 };\n\n    template<typename OutputStream>\n    static void Encode(OutputStream& os, unsigned codepoint) {\n        if (codepoint <= 0x7F) \n            os.Put(static_cast<Ch>(codepoint & 0xFF));\n        else if (codepoint <= 0x7FF) {\n            os.Put(static_cast<Ch>(0xC0 | ((codepoint >> 6) & 0xFF)));\n            os.Put(static_cast<Ch>(0x80 | ((codepoint & 0x3F))));\n        }\n        else if (codepoint <= 0xFFFF) {\n            os.Put(static_cast<Ch>(0xE0 | ((codepoint >> 12) & 0xFF)));\n            os.Put(static_cast<Ch>(0x80 | ((codepoint >> 6) & 0x3F)));\n            os.Put(static_cast<Ch>(0x80 | (codepoint & 0x3F)));\n        }\n        else {\n            RAPIDJSON_ASSERT(codepoint <= 0x10FFFF);\n            os.Put(static_cast<Ch>(0xF0 | ((codepoint >> 18) & 0xFF)));\n            os.Put(static_cast<Ch>(0x80 | ((codepoint >> 12) & 0x3F)));\n            os.Put(static_cast<Ch>(0x80 | ((codepoint >> 6) & 0x3F)));\n            os.Put(static_cast<Ch>(0x80 | (codepoint & 0x3F)));\n        }\n    }\n\n    template<typename OutputStream>\n    static void EncodeUnsafe(OutputStream& os, unsigned codepoint) {\n        if (codepoint <= 0x7F) \n            PutUnsafe(os, static_cast<Ch>(codepoint & 0xFF));\n        else if (codepoint <= 0x7FF) {\n            PutUnsafe(os, static_cast<Ch>(0xC0 | ((codepoint >> 6) & 0xFF)));\n            PutUnsafe(os, static_cast<Ch>(0x80 | ((codepoint & 0x3F))));\n        }\n        else if (codepoint <= 0xFFFF) {\n            PutUnsafe(os, static_cast<Ch>(0xE0 | ((codepoint >> 12) & 0xFF)));\n            PutUnsafe(os, static_cast<Ch>(0x80 | ((codepoint >> 6) & 0x3F)));\n            PutUnsafe(os, static_cast<Ch>(0x80 | (codepoint & 0x3F)));\n        }\n        else {\n            RAPIDJSON_ASSERT(codepoint <= 0x10FFFF);\n            PutUnsafe(os, static_cast<Ch>(0xF0 | ((codepoint >> 18) & 0xFF)));\n            PutUnsafe(os, static_cast<Ch>(0x80 | ((codepoint >> 12) & 0x3F)));\n            PutUnsafe(os, static_cast<Ch>(0x80 | ((codepoint >> 6) & 0x3F)));\n            PutUnsafe(os, static_cast<Ch>(0x80 | (codepoint & 0x3F)));\n        }\n    }\n\n    template <typename InputStream>\n    static bool Decode(InputStream& is, unsigned* codepoint) {\n#define COPY() c = is.Take(); *codepoint = (*codepoint << 6) | (static_cast<unsigned char>(c) & 0x3Fu)\n#define TRANS(mask) result &= ((GetRange(static_cast<unsigned char>(c)) & mask) != 0)\n#define TAIL() COPY(); TRANS(0x70)\n        typename InputStream::Ch c = is.Take();\n        if (!(c & 0x80)) {\n            *codepoint = static_cast<unsigned char>(c);\n            return true;\n        }\n\n        unsigned char type = GetRange(static_cast<unsigned char>(c));\n        if (type >= 32) {\n            *codepoint = 0;\n        } else {\n            *codepoint = (0xFF >> type) & static_cast<unsigned char>(c);\n        }\n        bool result = true;\n        switch (type) {\n        case 2: TAIL(); return result;\n        case 3: TAIL(); TAIL(); return result;\n        case 4: COPY(); TRANS(0x50); TAIL(); return result;\n        case 5: COPY(); TRANS(0x10); TAIL(); TAIL(); return result;\n        case 6: TAIL(); TAIL(); TAIL(); return result;\n        case 10: COPY(); TRANS(0x20); TAIL(); return result;\n        case 11: COPY(); TRANS(0x60); TAIL(); TAIL(); return result;\n        default: return false;\n        }\n#undef COPY\n#undef TRANS\n#undef TAIL\n    }\n\n    template <typename InputStream, typename OutputStream>\n    static bool Validate(InputStream& is, OutputStream& os) {\n#define COPY() os.Put(c = is.Take())\n#define TRANS(mask) result &= ((GetRange(static_cast<unsigned char>(c)) & mask) != 0)\n#define TAIL() COPY(); TRANS(0x70)\n        Ch c;\n        COPY();\n        if (!(c & 0x80))\n            return true;\n\n        bool result = true;\n        switch (GetRange(static_cast<unsigned char>(c))) {\n        case 2: TAIL(); return result;\n        case 3: TAIL(); TAIL(); return result;\n        case 4: COPY(); TRANS(0x50); TAIL(); return result;\n        case 5: COPY(); TRANS(0x10); TAIL(); TAIL(); return result;\n        case 6: TAIL(); TAIL(); TAIL(); return result;\n        case 10: COPY(); TRANS(0x20); TAIL(); return result;\n        case 11: COPY(); TRANS(0x60); TAIL(); TAIL(); return result;\n        default: return false;\n        }\n#undef COPY\n#undef TRANS\n#undef TAIL\n    }\n\n    static unsigned char GetRange(unsigned char c) {\n        // Referring to DFA of http://bjoern.hoehrmann.de/utf-8/decoder/dfa/\n        // With new mapping 1 -> 0x10, 7 -> 0x20, 9 -> 0x40, such that AND operation can test multiple types.\n        static const unsigned char type[] = {\n            0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n            0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n            0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n            0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n            0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,\n            0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,\n            0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\n            0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,\n            8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2,  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,\n            10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8,\n        };\n        return type[c];\n    }\n\n    template <typename InputByteStream>\n    static CharType TakeBOM(InputByteStream& is) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1);\n        typename InputByteStream::Ch c = Take(is);\n        if (static_cast<unsigned char>(c) != 0xEFu) return c;\n        c = is.Take();\n        if (static_cast<unsigned char>(c) != 0xBBu) return c;\n        c = is.Take();\n        if (static_cast<unsigned char>(c) != 0xBFu) return c;\n        c = is.Take();\n        return c;\n    }\n\n    template <typename InputByteStream>\n    static Ch Take(InputByteStream& is) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1);\n        return static_cast<Ch>(is.Take());\n    }\n\n    template <typename OutputByteStream>\n    static void PutBOM(OutputByteStream& os) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1);\n        os.Put(static_cast<typename OutputByteStream::Ch>(0xEFu));\n        os.Put(static_cast<typename OutputByteStream::Ch>(0xBBu));\n        os.Put(static_cast<typename OutputByteStream::Ch>(0xBFu));\n    }\n\n    template <typename OutputByteStream>\n    static void Put(OutputByteStream& os, Ch c) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1);\n        os.Put(static_cast<typename OutputByteStream::Ch>(c));\n    }\n};\n\n///////////////////////////////////////////////////////////////////////////////\n// UTF16\n\n//! UTF-16 encoding.\n/*! http://en.wikipedia.org/wiki/UTF-16\n    http://tools.ietf.org/html/rfc2781\n    \\tparam CharType Type for storing 16-bit UTF-16 data. Default is wchar_t. C++11 may use char16_t instead.\n    \\note implements Encoding concept\n\n    \\note For in-memory access, no need to concern endianness. The code units and code points are represented by CPU's endianness.\n    For streaming, use UTF16LE and UTF16BE, which handle endianness.\n*/\ntemplate<typename CharType = wchar_t>\nstruct UTF16 {\n    typedef CharType Ch;\n    RAPIDJSON_STATIC_ASSERT(sizeof(Ch) >= 2);\n\n    enum { supportUnicode = 1 };\n\n    template<typename OutputStream>\n    static void Encode(OutputStream& os, unsigned codepoint) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputStream::Ch) >= 2);\n        if (codepoint <= 0xFFFF) {\n            RAPIDJSON_ASSERT(codepoint < 0xD800 || codepoint > 0xDFFF); // Code point itself cannot be surrogate pair \n            os.Put(static_cast<typename OutputStream::Ch>(codepoint));\n        }\n        else {\n            RAPIDJSON_ASSERT(codepoint <= 0x10FFFF);\n            unsigned v = codepoint - 0x10000;\n            os.Put(static_cast<typename OutputStream::Ch>((v >> 10) | 0xD800));\n            os.Put((v & 0x3FF) | 0xDC00);\n        }\n    }\n\n\n    template<typename OutputStream>\n    static void EncodeUnsafe(OutputStream& os, unsigned codepoint) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputStream::Ch) >= 2);\n        if (codepoint <= 0xFFFF) {\n            RAPIDJSON_ASSERT(codepoint < 0xD800 || codepoint > 0xDFFF); // Code point itself cannot be surrogate pair \n            PutUnsafe(os, static_cast<typename OutputStream::Ch>(codepoint));\n        }\n        else {\n            RAPIDJSON_ASSERT(codepoint <= 0x10FFFF);\n            unsigned v = codepoint - 0x10000;\n            PutUnsafe(os, static_cast<typename OutputStream::Ch>((v >> 10) | 0xD800));\n            PutUnsafe(os, (v & 0x3FF) | 0xDC00);\n        }\n    }\n\n    template <typename InputStream>\n    static bool Decode(InputStream& is, unsigned* codepoint) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename InputStream::Ch) >= 2);\n        typename InputStream::Ch c = is.Take();\n        if (c < 0xD800 || c > 0xDFFF) {\n            *codepoint = static_cast<unsigned>(c);\n            return true;\n        }\n        else if (c <= 0xDBFF) {\n            *codepoint = (static_cast<unsigned>(c) & 0x3FF) << 10;\n            c = is.Take();\n            *codepoint |= (static_cast<unsigned>(c) & 0x3FF);\n            *codepoint += 0x10000;\n            return c >= 0xDC00 && c <= 0xDFFF;\n        }\n        return false;\n    }\n\n    template <typename InputStream, typename OutputStream>\n    static bool Validate(InputStream& is, OutputStream& os) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename InputStream::Ch) >= 2);\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputStream::Ch) >= 2);\n        typename InputStream::Ch c;\n        os.Put(static_cast<typename OutputStream::Ch>(c = is.Take()));\n        if (c < 0xD800 || c > 0xDFFF)\n            return true;\n        else if (c <= 0xDBFF) {\n            os.Put(c = is.Take());\n            return c >= 0xDC00 && c <= 0xDFFF;\n        }\n        return false;\n    }\n};\n\n//! UTF-16 little endian encoding.\ntemplate<typename CharType = wchar_t>\nstruct UTF16LE : UTF16<CharType> {\n    template <typename InputByteStream>\n    static CharType TakeBOM(InputByteStream& is) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1);\n        CharType c = Take(is);\n        return static_cast<uint16_t>(c) == 0xFEFFu ? Take(is) : c;\n    }\n\n    template <typename InputByteStream>\n    static CharType Take(InputByteStream& is) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1);\n        unsigned c = static_cast<uint8_t>(is.Take());\n        c |= static_cast<unsigned>(static_cast<uint8_t>(is.Take())) << 8;\n        return static_cast<CharType>(c);\n    }\n\n    template <typename OutputByteStream>\n    static void PutBOM(OutputByteStream& os) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1);\n        os.Put(static_cast<typename OutputByteStream::Ch>(0xFFu));\n        os.Put(static_cast<typename OutputByteStream::Ch>(0xFEu));\n    }\n\n    template <typename OutputByteStream>\n    static void Put(OutputByteStream& os, CharType c) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1);\n        os.Put(static_cast<typename OutputByteStream::Ch>(static_cast<unsigned>(c) & 0xFFu));\n        os.Put(static_cast<typename OutputByteStream::Ch>((static_cast<unsigned>(c) >> 8) & 0xFFu));\n    }\n};\n\n//! UTF-16 big endian encoding.\ntemplate<typename CharType = wchar_t>\nstruct UTF16BE : UTF16<CharType> {\n    template <typename InputByteStream>\n    static CharType TakeBOM(InputByteStream& is) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1);\n        CharType c = Take(is);\n        return static_cast<uint16_t>(c) == 0xFEFFu ? Take(is) : c;\n    }\n\n    template <typename InputByteStream>\n    static CharType Take(InputByteStream& is) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1);\n        unsigned c = static_cast<unsigned>(static_cast<uint8_t>(is.Take())) << 8;\n        c |= static_cast<uint8_t>(is.Take());\n        return static_cast<CharType>(c);\n    }\n\n    template <typename OutputByteStream>\n    static void PutBOM(OutputByteStream& os) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1);\n        os.Put(static_cast<typename OutputByteStream::Ch>(0xFEu));\n        os.Put(static_cast<typename OutputByteStream::Ch>(0xFFu));\n    }\n\n    template <typename OutputByteStream>\n    static void Put(OutputByteStream& os, CharType c) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1);\n        os.Put(static_cast<typename OutputByteStream::Ch>((static_cast<unsigned>(c) >> 8) & 0xFFu));\n        os.Put(static_cast<typename OutputByteStream::Ch>(static_cast<unsigned>(c) & 0xFFu));\n    }\n};\n\n///////////////////////////////////////////////////////////////////////////////\n// UTF32\n\n//! UTF-32 encoding. \n/*! http://en.wikipedia.org/wiki/UTF-32\n    \\tparam CharType Type for storing 32-bit UTF-32 data. Default is unsigned. C++11 may use char32_t instead.\n    \\note implements Encoding concept\n\n    \\note For in-memory access, no need to concern endianness. The code units and code points are represented by CPU's endianness.\n    For streaming, use UTF32LE and UTF32BE, which handle endianness.\n*/\ntemplate<typename CharType = unsigned>\nstruct UTF32 {\n    typedef CharType Ch;\n    RAPIDJSON_STATIC_ASSERT(sizeof(Ch) >= 4);\n\n    enum { supportUnicode = 1 };\n\n    template<typename OutputStream>\n    static void Encode(OutputStream& os, unsigned codepoint) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputStream::Ch) >= 4);\n        RAPIDJSON_ASSERT(codepoint <= 0x10FFFF);\n        os.Put(codepoint);\n    }\n\n    template<typename OutputStream>\n    static void EncodeUnsafe(OutputStream& os, unsigned codepoint) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputStream::Ch) >= 4);\n        RAPIDJSON_ASSERT(codepoint <= 0x10FFFF);\n        PutUnsafe(os, codepoint);\n    }\n\n    template <typename InputStream>\n    static bool Decode(InputStream& is, unsigned* codepoint) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename InputStream::Ch) >= 4);\n        Ch c = is.Take();\n        *codepoint = c;\n        return c <= 0x10FFFF;\n    }\n\n    template <typename InputStream, typename OutputStream>\n    static bool Validate(InputStream& is, OutputStream& os) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename InputStream::Ch) >= 4);\n        Ch c;\n        os.Put(c = is.Take());\n        return c <= 0x10FFFF;\n    }\n};\n\n//! UTF-32 little endian enocoding.\ntemplate<typename CharType = unsigned>\nstruct UTF32LE : UTF32<CharType> {\n    template <typename InputByteStream>\n    static CharType TakeBOM(InputByteStream& is) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1);\n        CharType c = Take(is);\n        return static_cast<uint32_t>(c) == 0x0000FEFFu ? Take(is) : c;\n    }\n\n    template <typename InputByteStream>\n    static CharType Take(InputByteStream& is) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1);\n        unsigned c = static_cast<uint8_t>(is.Take());\n        c |= static_cast<unsigned>(static_cast<uint8_t>(is.Take())) << 8;\n        c |= static_cast<unsigned>(static_cast<uint8_t>(is.Take())) << 16;\n        c |= static_cast<unsigned>(static_cast<uint8_t>(is.Take())) << 24;\n        return static_cast<CharType>(c);\n    }\n\n    template <typename OutputByteStream>\n    static void PutBOM(OutputByteStream& os) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1);\n        os.Put(static_cast<typename OutputByteStream::Ch>(0xFFu));\n        os.Put(static_cast<typename OutputByteStream::Ch>(0xFEu));\n        os.Put(static_cast<typename OutputByteStream::Ch>(0x00u));\n        os.Put(static_cast<typename OutputByteStream::Ch>(0x00u));\n    }\n\n    template <typename OutputByteStream>\n    static void Put(OutputByteStream& os, CharType c) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1);\n        os.Put(static_cast<typename OutputByteStream::Ch>(c & 0xFFu));\n        os.Put(static_cast<typename OutputByteStream::Ch>((c >> 8) & 0xFFu));\n        os.Put(static_cast<typename OutputByteStream::Ch>((c >> 16) & 0xFFu));\n        os.Put(static_cast<typename OutputByteStream::Ch>((c >> 24) & 0xFFu));\n    }\n};\n\n//! UTF-32 big endian encoding.\ntemplate<typename CharType = unsigned>\nstruct UTF32BE : UTF32<CharType> {\n    template <typename InputByteStream>\n    static CharType TakeBOM(InputByteStream& is) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1);\n        CharType c = Take(is);\n        return static_cast<uint32_t>(c) == 0x0000FEFFu ? Take(is) : c; \n    }\n\n    template <typename InputByteStream>\n    static CharType Take(InputByteStream& is) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1);\n        unsigned c = static_cast<unsigned>(static_cast<uint8_t>(is.Take())) << 24;\n        c |= static_cast<unsigned>(static_cast<uint8_t>(is.Take())) << 16;\n        c |= static_cast<unsigned>(static_cast<uint8_t>(is.Take())) << 8;\n        c |= static_cast<unsigned>(static_cast<uint8_t>(is.Take()));\n        return static_cast<CharType>(c);\n    }\n\n    template <typename OutputByteStream>\n    static void PutBOM(OutputByteStream& os) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1);\n        os.Put(static_cast<typename OutputByteStream::Ch>(0x00u));\n        os.Put(static_cast<typename OutputByteStream::Ch>(0x00u));\n        os.Put(static_cast<typename OutputByteStream::Ch>(0xFEu));\n        os.Put(static_cast<typename OutputByteStream::Ch>(0xFFu));\n    }\n\n    template <typename OutputByteStream>\n    static void Put(OutputByteStream& os, CharType c) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1);\n        os.Put(static_cast<typename OutputByteStream::Ch>((c >> 24) & 0xFFu));\n        os.Put(static_cast<typename OutputByteStream::Ch>((c >> 16) & 0xFFu));\n        os.Put(static_cast<typename OutputByteStream::Ch>((c >> 8) & 0xFFu));\n        os.Put(static_cast<typename OutputByteStream::Ch>(c & 0xFFu));\n    }\n};\n\n///////////////////////////////////////////////////////////////////////////////\n// ASCII\n\n//! ASCII encoding.\n/*! http://en.wikipedia.org/wiki/ASCII\n    \\tparam CharType Code unit for storing 7-bit ASCII data. Default is char.\n    \\note implements Encoding concept\n*/\ntemplate<typename CharType = char>\nstruct ASCII {\n    typedef CharType Ch;\n\n    enum { supportUnicode = 0 };\n\n    template<typename OutputStream>\n    static void Encode(OutputStream& os, unsigned codepoint) {\n        RAPIDJSON_ASSERT(codepoint <= 0x7F);\n        os.Put(static_cast<Ch>(codepoint & 0xFF));\n    }\n\n    template<typename OutputStream>\n    static void EncodeUnsafe(OutputStream& os, unsigned codepoint) {\n        RAPIDJSON_ASSERT(codepoint <= 0x7F);\n        PutUnsafe(os, static_cast<Ch>(codepoint & 0xFF));\n    }\n\n    template <typename InputStream>\n    static bool Decode(InputStream& is, unsigned* codepoint) {\n        uint8_t c = static_cast<uint8_t>(is.Take());\n        *codepoint = c;\n        return c <= 0X7F;\n    }\n\n    template <typename InputStream, typename OutputStream>\n    static bool Validate(InputStream& is, OutputStream& os) {\n        uint8_t c = static_cast<uint8_t>(is.Take());\n        os.Put(static_cast<typename OutputStream::Ch>(c));\n        return c <= 0x7F;\n    }\n\n    template <typename InputByteStream>\n    static CharType TakeBOM(InputByteStream& is) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1);\n        uint8_t c = static_cast<uint8_t>(Take(is));\n        return static_cast<Ch>(c);\n    }\n\n    template <typename InputByteStream>\n    static Ch Take(InputByteStream& is) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename InputByteStream::Ch) == 1);\n        return static_cast<Ch>(is.Take());\n    }\n\n    template <typename OutputByteStream>\n    static void PutBOM(OutputByteStream& os) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1);\n        (void)os;\n    }\n\n    template <typename OutputByteStream>\n    static void Put(OutputByteStream& os, Ch c) {\n        RAPIDJSON_STATIC_ASSERT(sizeof(typename OutputByteStream::Ch) == 1);\n        os.Put(static_cast<typename OutputByteStream::Ch>(c));\n    }\n};\n\n///////////////////////////////////////////////////////////////////////////////\n// AutoUTF\n\n//! Runtime-specified UTF encoding type of a stream.\nenum UTFType {\n    kUTF8 = 0,      //!< UTF-8.\n    kUTF16LE = 1,   //!< UTF-16 little endian.\n    kUTF16BE = 2,   //!< UTF-16 big endian.\n    kUTF32LE = 3,   //!< UTF-32 little endian.\n    kUTF32BE = 4    //!< UTF-32 big endian.\n};\n\n//! Dynamically select encoding according to stream's runtime-specified UTF encoding type.\n/*! \\note This class can be used with AutoUTFInputtStream and AutoUTFOutputStream, which provides GetType().\n*/\ntemplate<typename CharType>\nstruct AutoUTF {\n    typedef CharType Ch;\n\n    enum { supportUnicode = 1 };\n\n#define RAPIDJSON_ENCODINGS_FUNC(x) UTF8<Ch>::x, UTF16LE<Ch>::x, UTF16BE<Ch>::x, UTF32LE<Ch>::x, UTF32BE<Ch>::x\n\n    template<typename OutputStream>\n    RAPIDJSON_FORCEINLINE static void Encode(OutputStream& os, unsigned codepoint) {\n        typedef void (*EncodeFunc)(OutputStream&, unsigned);\n        static const EncodeFunc f[] = { RAPIDJSON_ENCODINGS_FUNC(Encode) };\n        (*f[os.GetType()])(os, codepoint);\n    }\n\n    template<typename OutputStream>\n    RAPIDJSON_FORCEINLINE static void EncodeUnsafe(OutputStream& os, unsigned codepoint) {\n        typedef void (*EncodeFunc)(OutputStream&, unsigned);\n        static const EncodeFunc f[] = { RAPIDJSON_ENCODINGS_FUNC(EncodeUnsafe) };\n        (*f[os.GetType()])(os, codepoint);\n    }\n\n    template <typename InputStream>\n    RAPIDJSON_FORCEINLINE static bool Decode(InputStream& is, unsigned* codepoint) {\n        typedef bool (*DecodeFunc)(InputStream&, unsigned*);\n        static const DecodeFunc f[] = { RAPIDJSON_ENCODINGS_FUNC(Decode) };\n        return (*f[is.GetType()])(is, codepoint);\n    }\n\n    template <typename InputStream, typename OutputStream>\n    RAPIDJSON_FORCEINLINE static bool Validate(InputStream& is, OutputStream& os) {\n        typedef bool (*ValidateFunc)(InputStream&, OutputStream&);\n        static const ValidateFunc f[] = { RAPIDJSON_ENCODINGS_FUNC(Validate) };\n        return (*f[is.GetType()])(is, os);\n    }\n\n#undef RAPIDJSON_ENCODINGS_FUNC\n};\n\n///////////////////////////////////////////////////////////////////////////////\n// Transcoder\n\n//! Encoding conversion.\ntemplate<typename SourceEncoding, typename TargetEncoding>\nstruct Transcoder {\n    //! Take one Unicode codepoint from source encoding, convert it to target encoding and put it to the output stream.\n    template<typename InputStream, typename OutputStream>\n    RAPIDJSON_FORCEINLINE static bool Transcode(InputStream& is, OutputStream& os) {\n        unsigned codepoint;\n        if (!SourceEncoding::Decode(is, &codepoint))\n            return false;\n        TargetEncoding::Encode(os, codepoint);\n        return true;\n    }\n\n    template<typename InputStream, typename OutputStream>\n    RAPIDJSON_FORCEINLINE static bool TranscodeUnsafe(InputStream& is, OutputStream& os) {\n        unsigned codepoint;\n        if (!SourceEncoding::Decode(is, &codepoint))\n            return false;\n        TargetEncoding::EncodeUnsafe(os, codepoint);\n        return true;\n    }\n\n    //! Validate one Unicode codepoint from an encoded stream.\n    template<typename InputStream, typename OutputStream>\n    RAPIDJSON_FORCEINLINE static bool Validate(InputStream& is, OutputStream& os) {\n        return Transcode(is, os);   // Since source/target encoding is different, must transcode.\n    }\n};\n\n// Forward declaration.\ntemplate<typename Stream>\ninline void PutUnsafe(Stream& stream, typename Stream::Ch c);\n\n//! Specialization of Transcoder with same source and target encoding.\ntemplate<typename Encoding>\nstruct Transcoder<Encoding, Encoding> {\n    template<typename InputStream, typename OutputStream>\n    RAPIDJSON_FORCEINLINE static bool Transcode(InputStream& is, OutputStream& os) {\n        os.Put(is.Take());  // Just copy one code unit. This semantic is different from primary template class.\n        return true;\n    }\n    \n    template<typename InputStream, typename OutputStream>\n    RAPIDJSON_FORCEINLINE static bool TranscodeUnsafe(InputStream& is, OutputStream& os) {\n        PutUnsafe(os, is.Take());  // Just copy one code unit. This semantic is different from primary template class.\n        return true;\n    }\n    \n    template<typename InputStream, typename OutputStream>\n    RAPIDJSON_FORCEINLINE static bool Validate(InputStream& is, OutputStream& os) {\n        return Encoding::Validate(is, os);  // source/target encoding are the same\n    }\n};\n\nRAPIDJSON_NAMESPACE_END\n\n#if defined(__GNUC__) || defined(_MSC_VER)\nRAPIDJSON_DIAG_POP\n#endif\n\n#endif // RAPIDJSON_ENCODINGS_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/error/en.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_ERROR_EN_H_\n#define RAPIDJSON_ERROR_EN_H_\n\n#include \"error.h\"\n\n#ifdef __clang__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(switch-enum)\nRAPIDJSON_DIAG_OFF(covered-switch-default)\n#endif\n\nRAPIDJSON_NAMESPACE_BEGIN\n\n//! Maps error code of parsing into error message.\n/*!\n    \\ingroup RAPIDJSON_ERRORS\n    \\param parseErrorCode Error code obtained in parsing.\n    \\return the error message.\n    \\note User can make a copy of this function for localization.\n        Using switch-case is safer for future modification of error codes.\n*/\ninline const RAPIDJSON_ERROR_CHARTYPE* GetParseError_En(ParseErrorCode parseErrorCode) {\n    switch (parseErrorCode) {\n        case kParseErrorNone:                           return RAPIDJSON_ERROR_STRING(\"No error.\");\n\n        case kParseErrorDocumentEmpty:                  return RAPIDJSON_ERROR_STRING(\"The document is empty.\");\n        case kParseErrorDocumentRootNotSingular:        return RAPIDJSON_ERROR_STRING(\"The document root must not be followed by other values.\");\n    \n        case kParseErrorValueInvalid:                   return RAPIDJSON_ERROR_STRING(\"Invalid value.\");\n    \n        case kParseErrorObjectMissName:                 return RAPIDJSON_ERROR_STRING(\"Missing a name for object member.\");\n        case kParseErrorObjectMissColon:                return RAPIDJSON_ERROR_STRING(\"Missing a colon after a name of object member.\");\n        case kParseErrorObjectMissCommaOrCurlyBracket:  return RAPIDJSON_ERROR_STRING(\"Missing a comma or '}' after an object member.\");\n    \n        case kParseErrorArrayMissCommaOrSquareBracket:  return RAPIDJSON_ERROR_STRING(\"Missing a comma or ']' after an array element.\");\n\n        case kParseErrorStringUnicodeEscapeInvalidHex:  return RAPIDJSON_ERROR_STRING(\"Incorrect hex digit after \\\\u escape in string.\");\n        case kParseErrorStringUnicodeSurrogateInvalid:  return RAPIDJSON_ERROR_STRING(\"The surrogate pair in string is invalid.\");\n        case kParseErrorStringEscapeInvalid:            return RAPIDJSON_ERROR_STRING(\"Invalid escape character in string.\");\n        case kParseErrorStringMissQuotationMark:        return RAPIDJSON_ERROR_STRING(\"Missing a closing quotation mark in string.\");\n        case kParseErrorStringInvalidEncoding:          return RAPIDJSON_ERROR_STRING(\"Invalid encoding in string.\");\n\n        case kParseErrorNumberTooBig:                   return RAPIDJSON_ERROR_STRING(\"Number too big to be stored in double.\");\n        case kParseErrorNumberMissFraction:             return RAPIDJSON_ERROR_STRING(\"Miss fraction part in number.\");\n        case kParseErrorNumberMissExponent:             return RAPIDJSON_ERROR_STRING(\"Miss exponent in number.\");\n\n        case kParseErrorTermination:                    return RAPIDJSON_ERROR_STRING(\"Terminate parsing due to Handler error.\");\n        case kParseErrorUnspecificSyntaxError:          return RAPIDJSON_ERROR_STRING(\"Unspecific syntax error.\");\n\n        default:                                        return RAPIDJSON_ERROR_STRING(\"Unknown error.\");\n    }\n}\n\nRAPIDJSON_NAMESPACE_END\n\n#ifdef __clang__\nRAPIDJSON_DIAG_POP\n#endif\n\n#endif // RAPIDJSON_ERROR_EN_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/error/error.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_ERROR_ERROR_H_\n#define RAPIDJSON_ERROR_ERROR_H_\n\n#include \"../rapidjson.h\"\n\n#ifdef __clang__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(padded)\n#endif\n\n/*! \\file error.h */\n\n/*! \\defgroup RAPIDJSON_ERRORS RapidJSON error handling */\n\n///////////////////////////////////////////////////////////////////////////////\n// RAPIDJSON_ERROR_CHARTYPE\n\n//! Character type of error messages.\n/*! \\ingroup RAPIDJSON_ERRORS\n    The default character type is \\c char.\n    On Windows, user can define this macro as \\c TCHAR for supporting both\n    unicode/non-unicode settings.\n*/\n#ifndef RAPIDJSON_ERROR_CHARTYPE\n#define RAPIDJSON_ERROR_CHARTYPE char\n#endif\n\n///////////////////////////////////////////////////////////////////////////////\n// RAPIDJSON_ERROR_STRING\n\n//! Macro for converting string literial to \\ref RAPIDJSON_ERROR_CHARTYPE[].\n/*! \\ingroup RAPIDJSON_ERRORS\n    By default this conversion macro does nothing.\n    On Windows, user can define this macro as \\c _T(x) for supporting both\n    unicode/non-unicode settings.\n*/\n#ifndef RAPIDJSON_ERROR_STRING\n#define RAPIDJSON_ERROR_STRING(x) x\n#endif\n\nRAPIDJSON_NAMESPACE_BEGIN\n\n///////////////////////////////////////////////////////////////////////////////\n// ParseErrorCode\n\n//! Error code of parsing.\n/*! \\ingroup RAPIDJSON_ERRORS\n    \\see GenericReader::Parse, GenericReader::GetParseErrorCode\n*/\nenum ParseErrorCode {\n    kParseErrorNone = 0,                        //!< No error.\n\n    kParseErrorDocumentEmpty,                   //!< The document is empty.\n    kParseErrorDocumentRootNotSingular,         //!< The document root must not follow by other values.\n\n    kParseErrorValueInvalid,                    //!< Invalid value.\n\n    kParseErrorObjectMissName,                  //!< Missing a name for object member.\n    kParseErrorObjectMissColon,                 //!< Missing a colon after a name of object member.\n    kParseErrorObjectMissCommaOrCurlyBracket,   //!< Missing a comma or '}' after an object member.\n\n    kParseErrorArrayMissCommaOrSquareBracket,   //!< Missing a comma or ']' after an array element.\n\n    kParseErrorStringUnicodeEscapeInvalidHex,   //!< Incorrect hex digit after \\\\u escape in string.\n    kParseErrorStringUnicodeSurrogateInvalid,   //!< The surrogate pair in string is invalid.\n    kParseErrorStringEscapeInvalid,             //!< Invalid escape character in string.\n    kParseErrorStringMissQuotationMark,         //!< Missing a closing quotation mark in string.\n    kParseErrorStringInvalidEncoding,           //!< Invalid encoding in string.\n\n    kParseErrorNumberTooBig,                    //!< Number too big to be stored in double.\n    kParseErrorNumberMissFraction,              //!< Miss fraction part in number.\n    kParseErrorNumberMissExponent,              //!< Miss exponent in number.\n\n    kParseErrorTermination,                     //!< Parsing was terminated.\n    kParseErrorUnspecificSyntaxError            //!< Unspecific syntax error.\n};\n\n//! Result of parsing (wraps ParseErrorCode)\n/*!\n    \\ingroup RAPIDJSON_ERRORS\n    \\code\n        Document doc;\n        ParseResult ok = doc.Parse(\"[42]\");\n        if (!ok) {\n            fprintf(stderr, \"JSON parse error: %s (%u)\",\n                    GetParseError_En(ok.Code()), ok.Offset());\n            exit(EXIT_FAILURE);\n        }\n    \\endcode\n    \\see GenericReader::Parse, GenericDocument::Parse\n*/\nstruct ParseResult {\npublic:\n    //! Default constructor, no error.\n    ParseResult() : code_(kParseErrorNone), offset_(0) {}\n    //! Constructor to set an error.\n    ParseResult(ParseErrorCode code, size_t offset) : code_(code), offset_(offset) {}\n\n    //! Get the error code.\n    ParseErrorCode Code() const { return code_; }\n    //! Get the error offset, if \\ref IsError(), 0 otherwise.\n    size_t Offset() const { return offset_; }\n\n    //! Conversion to \\c bool, returns \\c true, iff !\\ref IsError().\n    operator bool() const { return !IsError(); }\n    //! Whether the result is an error.\n    bool IsError() const { return code_ != kParseErrorNone; }\n\n    bool operator==(const ParseResult& that) const { return code_ == that.code_; }\n    bool operator==(ParseErrorCode code) const { return code_ == code; }\n    friend bool operator==(ParseErrorCode code, const ParseResult & err) { return code == err.code_; }\n\n    //! Reset error code.\n    void Clear() { Set(kParseErrorNone); }\n    //! Update error code and offset.\n    void Set(ParseErrorCode code, size_t offset = 0) { code_ = code; offset_ = offset; }\n\nprivate:\n    ParseErrorCode code_;\n    size_t offset_;\n};\n\n//! Function pointer type of GetParseError().\n/*! \\ingroup RAPIDJSON_ERRORS\n\n    This is the prototype for \\c GetParseError_X(), where \\c X is a locale.\n    User can dynamically change locale in runtime, e.g.:\n\\code\n    GetParseErrorFunc GetParseError = GetParseError_En; // or whatever\n    const RAPIDJSON_ERROR_CHARTYPE* s = GetParseError(document.GetParseErrorCode());\n\\endcode\n*/\ntypedef const RAPIDJSON_ERROR_CHARTYPE* (*GetParseErrorFunc)(ParseErrorCode);\n\nRAPIDJSON_NAMESPACE_END\n\n#ifdef __clang__\nRAPIDJSON_DIAG_POP\n#endif\n\n#endif // RAPIDJSON_ERROR_ERROR_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/filereadstream.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_FILEREADSTREAM_H_\n#define RAPIDJSON_FILEREADSTREAM_H_\n\n#include \"stream.h\"\n#include <cstdio>\n\n#ifdef __clang__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(padded)\nRAPIDJSON_DIAG_OFF(unreachable-code)\nRAPIDJSON_DIAG_OFF(missing-noreturn)\n#endif\n\nRAPIDJSON_NAMESPACE_BEGIN\n\n//! File byte stream for input using fread().\n/*!\n    \\note implements Stream concept\n*/\nclass FileReadStream {\npublic:\n    typedef char Ch;    //!< Character type (byte).\n\n    //! Constructor.\n    /*!\n        \\param fp File pointer opened for read.\n        \\param buffer user-supplied buffer.\n        \\param bufferSize size of buffer in bytes. Must >=4 bytes.\n    */\n    FileReadStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferSize_(bufferSize), bufferLast_(0), current_(buffer_), readCount_(0), count_(0), eof_(false) { \n        RAPIDJSON_ASSERT(fp_ != 0);\n        RAPIDJSON_ASSERT(bufferSize >= 4);\n        Read();\n    }\n\n    Ch Peek() const { return *current_; }\n    Ch Take() { Ch c = *current_; Read(); return c; }\n    size_t Tell() const { return count_ + static_cast<size_t>(current_ - buffer_); }\n\n    // Not implemented\n    void Put(Ch) { RAPIDJSON_ASSERT(false); }\n    void Flush() { RAPIDJSON_ASSERT(false); } \n    Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }\n    size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }\n\n    // For encoding detection only.\n    const Ch* Peek4() const {\n        return (current_ + 4 <= bufferLast_) ? current_ : 0;\n    }\n\nprivate:\n    void Read() {\n        if (current_ < bufferLast_)\n            ++current_;\n        else if (!eof_) {\n            count_ += readCount_;\n            readCount_ = fread(buffer_, 1, bufferSize_, fp_);\n            bufferLast_ = buffer_ + readCount_ - 1;\n            current_ = buffer_;\n\n            if (readCount_ < bufferSize_) {\n                buffer_[readCount_] = '\\0';\n                ++bufferLast_;\n                eof_ = true;\n            }\n        }\n    }\n\n    std::FILE* fp_;\n    Ch *buffer_;\n    size_t bufferSize_;\n    Ch *bufferLast_;\n    Ch *current_;\n    size_t readCount_;\n    size_t count_;  //!< Number of characters read\n    bool eof_;\n};\n\nRAPIDJSON_NAMESPACE_END\n\n#ifdef __clang__\nRAPIDJSON_DIAG_POP\n#endif\n\n#endif // RAPIDJSON_FILESTREAM_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/filewritestream.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_FILEWRITESTREAM_H_\n#define RAPIDJSON_FILEWRITESTREAM_H_\n\n#include \"stream.h\"\n#include <cstdio>\n\n#ifdef __clang__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(unreachable-code)\n#endif\n\nRAPIDJSON_NAMESPACE_BEGIN\n\n//! Wrapper of C file stream for input using fread().\n/*!\n    \\note implements Stream concept\n*/\nclass FileWriteStream {\npublic:\n    typedef char Ch;    //!< Character type. Only support char.\n\n    FileWriteStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferEnd_(buffer + bufferSize), current_(buffer_) { \n        RAPIDJSON_ASSERT(fp_ != 0);\n    }\n\n    void Put(char c) { \n        if (current_ >= bufferEnd_)\n            Flush();\n\n        *current_++ = c;\n    }\n\n    void PutN(char c, size_t n) {\n        size_t avail = static_cast<size_t>(bufferEnd_ - current_);\n        while (n > avail) {\n            std::memset(current_, c, avail);\n            current_ += avail;\n            Flush();\n            n -= avail;\n            avail = static_cast<size_t>(bufferEnd_ - current_);\n        }\n\n        if (n > 0) {\n            std::memset(current_, c, n);\n            current_ += n;\n        }\n    }\n\n    void Flush() {\n        if (current_ != buffer_) {\n            size_t result = fwrite(buffer_, 1, static_cast<size_t>(current_ - buffer_), fp_);\n            if (result < static_cast<size_t>(current_ - buffer_)) {\n                // failure deliberately ignored at this time\n                // added to avoid warn_unused_result build errors\n            }\n            current_ = buffer_;\n        }\n    }\n\n    // Not implemented\n    char Peek() const { RAPIDJSON_ASSERT(false); return 0; }\n    char Take() { RAPIDJSON_ASSERT(false); return 0; }\n    size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; }\n    char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }\n    size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; }\n\nprivate:\n    // Prohibit copy constructor & assignment operator.\n    FileWriteStream(const FileWriteStream&);\n    FileWriteStream& operator=(const FileWriteStream&);\n\n    std::FILE* fp_;\n    char *buffer_;\n    char *bufferEnd_;\n    char *current_;\n};\n\n//! Implement specialized version of PutN() with memset() for better performance.\ntemplate<>\ninline void PutN(FileWriteStream& stream, char c, size_t n) {\n    stream.PutN(c, n);\n}\n\nRAPIDJSON_NAMESPACE_END\n\n#ifdef __clang__\nRAPIDJSON_DIAG_POP\n#endif\n\n#endif // RAPIDJSON_FILESTREAM_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/fwd.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_FWD_H_\n#define RAPIDJSON_FWD_H_\n\n#include \"rapidjson.h\"\n\nRAPIDJSON_NAMESPACE_BEGIN\n\n// encodings.h\n\ntemplate<typename CharType> struct UTF8;\ntemplate<typename CharType> struct UTF16;\ntemplate<typename CharType> struct UTF16BE;\ntemplate<typename CharType> struct UTF16LE;\ntemplate<typename CharType> struct UTF32;\ntemplate<typename CharType> struct UTF32BE;\ntemplate<typename CharType> struct UTF32LE;\ntemplate<typename CharType> struct ASCII;\ntemplate<typename CharType> struct AutoUTF;\n\ntemplate<typename SourceEncoding, typename TargetEncoding>\nstruct Transcoder;\n\n// allocators.h\n\nclass CrtAllocator;\n\ntemplate <typename BaseAllocator>\nclass MemoryPoolAllocator;\n\n// stream.h\n\ntemplate <typename Encoding>\nstruct GenericStringStream;\n\ntypedef GenericStringStream<UTF8<char> > StringStream;\n\ntemplate <typename Encoding>\nstruct GenericInsituStringStream;\n\ntypedef GenericInsituStringStream<UTF8<char> > InsituStringStream;\n\n// stringbuffer.h\n\ntemplate <typename Encoding, typename Allocator>\nclass GenericStringBuffer;\n\ntypedef GenericStringBuffer<UTF8<char>, CrtAllocator> StringBuffer;\n\n// filereadstream.h\n\nclass FileReadStream;\n\n// filewritestream.h\n\nclass FileWriteStream;\n\n// memorybuffer.h\n\ntemplate <typename Allocator>\nstruct GenericMemoryBuffer;\n\ntypedef GenericMemoryBuffer<CrtAllocator> MemoryBuffer;\n\n// memorystream.h\n\nstruct MemoryStream;\n\n// reader.h\n\ntemplate<typename Encoding, typename Derived>\nstruct BaseReaderHandler;\n\ntemplate <typename SourceEncoding, typename TargetEncoding, typename StackAllocator>\nclass GenericReader;\n\ntypedef GenericReader<UTF8<char>, UTF8<char>, CrtAllocator> Reader;\n\n// writer.h\n\ntemplate<typename OutputStream, typename SourceEncoding, typename TargetEncoding, typename StackAllocator, unsigned writeFlags>\nclass Writer;\n\n// prettywriter.h\n\ntemplate<typename OutputStream, typename SourceEncoding, typename TargetEncoding, typename StackAllocator, unsigned writeFlags>\nclass PrettyWriter;\n\n// document.h\n\ntemplate <typename Encoding, typename Allocator> \nstruct GenericMember;\n\ntemplate <bool Const, typename Encoding, typename Allocator>\nclass GenericMemberIterator;\n\ntemplate<typename CharType>\nstruct GenericStringRef;\n\ntemplate <typename Encoding, typename Allocator> \nclass GenericValue;\n\ntypedef GenericValue<UTF8<char>, MemoryPoolAllocator<CrtAllocator> > Value;\n\ntemplate <typename Encoding, typename Allocator, typename StackAllocator>\nclass GenericDocument;\n\ntypedef GenericDocument<UTF8<char>, MemoryPoolAllocator<CrtAllocator>, CrtAllocator> Document;\n\n// pointer.h\n\ntemplate <typename ValueType, typename Allocator>\nclass GenericPointer;\n\ntypedef GenericPointer<Value, CrtAllocator> Pointer;\n\n// schema.h\n\ntemplate <typename SchemaDocumentType>\nclass IGenericRemoteSchemaDocumentProvider;\n\ntemplate <typename ValueT, typename Allocator>\nclass GenericSchemaDocument;\n\ntypedef GenericSchemaDocument<Value, CrtAllocator> SchemaDocument;\ntypedef IGenericRemoteSchemaDocumentProvider<SchemaDocument> IRemoteSchemaDocumentProvider;\n\ntemplate <\n    typename SchemaDocumentType,\n    typename OutputHandler,\n    typename StateAllocator>\nclass GenericSchemaValidator;\n\ntypedef GenericSchemaValidator<SchemaDocument, BaseReaderHandler<UTF8<char>, void>, CrtAllocator> SchemaValidator;\n\nRAPIDJSON_NAMESPACE_END\n\n#endif // RAPIDJSON_RAPIDJSONFWD_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/internal/biginteger.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_BIGINTEGER_H_\n#define RAPIDJSON_BIGINTEGER_H_\n\n#include \"../rapidjson.h\"\n\n#if defined(_MSC_VER) && defined(_M_AMD64)\n#include <intrin.h> // for _umul128\n#pragma intrinsic(_umul128)\n#endif\n\nRAPIDJSON_NAMESPACE_BEGIN\nnamespace internal {\n\nclass BigInteger {\npublic:\n    typedef uint64_t Type;\n\n    BigInteger(const BigInteger& rhs) : count_(rhs.count_) {\n        std::memcpy(digits_, rhs.digits_, count_ * sizeof(Type));\n    }\n\n    explicit BigInteger(uint64_t u) : count_(1) {\n        digits_[0] = u;\n    }\n\n    BigInteger(const char* decimals, size_t length) : count_(1) {\n        RAPIDJSON_ASSERT(length > 0);\n        digits_[0] = 0;\n        size_t i = 0;\n        const size_t kMaxDigitPerIteration = 19;  // 2^64 = 18446744073709551616 > 10^19\n        while (length >= kMaxDigitPerIteration) {\n            AppendDecimal64(decimals + i, decimals + i + kMaxDigitPerIteration);\n            length -= kMaxDigitPerIteration;\n            i += kMaxDigitPerIteration;\n        }\n\n        if (length > 0)\n            AppendDecimal64(decimals + i, decimals + i + length);\n    }\n    \n    BigInteger& operator=(const BigInteger &rhs)\n    {\n        if (this != &rhs) {\n            count_ = rhs.count_;\n            std::memcpy(digits_, rhs.digits_, count_ * sizeof(Type));\n        }\n        return *this;\n    }\n    \n    BigInteger& operator=(uint64_t u) {\n        digits_[0] = u;            \n        count_ = 1;\n        return *this;\n    }\n\n    BigInteger& operator+=(uint64_t u) {\n        Type backup = digits_[0];\n        digits_[0] += u;\n        for (size_t i = 0; i < count_ - 1; i++) {\n            if (digits_[i] >= backup)\n                return *this; // no carry\n            backup = digits_[i + 1];\n            digits_[i + 1] += 1;\n        }\n\n        // Last carry\n        if (digits_[count_ - 1] < backup)\n            PushBack(1);\n\n        return *this;\n    }\n\n    BigInteger& operator*=(uint64_t u) {\n        if (u == 0) return *this = 0;\n        if (u == 1) return *this;\n        if (*this == 1) return *this = u;\n\n        uint64_t k = 0;\n        for (size_t i = 0; i < count_; i++) {\n            uint64_t hi;\n            digits_[i] = MulAdd64(digits_[i], u, k, &hi);\n            k = hi;\n        }\n        \n        if (k > 0)\n            PushBack(k);\n\n        return *this;\n    }\n\n    BigInteger& operator*=(uint32_t u) {\n        if (u == 0) return *this = 0;\n        if (u == 1) return *this;\n        if (*this == 1) return *this = u;\n\n        uint64_t k = 0;\n        for (size_t i = 0; i < count_; i++) {\n            const uint64_t c = digits_[i] >> 32;\n            const uint64_t d = digits_[i] & 0xFFFFFFFF;\n            const uint64_t uc = u * c;\n            const uint64_t ud = u * d;\n            const uint64_t p0 = ud + k;\n            const uint64_t p1 = uc + (p0 >> 32);\n            digits_[i] = (p0 & 0xFFFFFFFF) | (p1 << 32);\n            k = p1 >> 32;\n        }\n        \n        if (k > 0)\n            PushBack(k);\n\n        return *this;\n    }\n\n    BigInteger& operator<<=(size_t shift) {\n        if (IsZero() || shift == 0) return *this;\n\n        size_t offset = shift / kTypeBit;\n        size_t interShift = shift % kTypeBit;\n        RAPIDJSON_ASSERT(count_ + offset <= kCapacity);\n\n        if (interShift == 0) {\n            std::memmove(&digits_[count_ - 1 + offset], &digits_[count_ - 1], count_ * sizeof(Type));\n            count_ += offset;\n        }\n        else {\n            digits_[count_] = 0;\n            for (size_t i = count_; i > 0; i--)\n                digits_[i + offset] = (digits_[i] << interShift) | (digits_[i - 1] >> (kTypeBit - interShift));\n            digits_[offset] = digits_[0] << interShift;\n            count_ += offset;\n            if (digits_[count_])\n                count_++;\n        }\n\n        std::memset(digits_, 0, offset * sizeof(Type));\n\n        return *this;\n    }\n\n    bool operator==(const BigInteger& rhs) const {\n        return count_ == rhs.count_ && std::memcmp(digits_, rhs.digits_, count_ * sizeof(Type)) == 0;\n    }\n\n    bool operator==(const Type rhs) const {\n        return count_ == 1 && digits_[0] == rhs;\n    }\n\n    BigInteger& MultiplyPow5(unsigned exp) {\n        static const uint32_t kPow5[12] = {\n            5,\n            5 * 5,\n            5 * 5 * 5,\n            5 * 5 * 5 * 5,\n            5 * 5 * 5 * 5 * 5,\n            5 * 5 * 5 * 5 * 5 * 5,\n            5 * 5 * 5 * 5 * 5 * 5 * 5,\n            5 * 5 * 5 * 5 * 5 * 5 * 5 * 5,\n            5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5,\n            5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5,\n            5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5,\n            5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5\n        };\n        if (exp == 0) return *this;\n        for (; exp >= 27; exp -= 27) *this *= RAPIDJSON_UINT64_C2(0X6765C793, 0XFA10079D); // 5^27\n        for (; exp >= 13; exp -= 13) *this *= static_cast<uint32_t>(1220703125u); // 5^13\n        if (exp > 0)                 *this *= kPow5[exp - 1];\n        return *this;\n    }\n\n    // Compute absolute difference of this and rhs.\n    // Assume this != rhs\n    bool Difference(const BigInteger& rhs, BigInteger* out) const {\n        int cmp = Compare(rhs);\n        RAPIDJSON_ASSERT(cmp != 0);\n        const BigInteger *a, *b;  // Makes a > b\n        bool ret;\n        if (cmp < 0) { a = &rhs; b = this; ret = true; }\n        else         { a = this; b = &rhs; ret = false; }\n\n        Type borrow = 0;\n        for (size_t i = 0; i < a->count_; i++) {\n            Type d = a->digits_[i] - borrow;\n            if (i < b->count_)\n                d -= b->digits_[i];\n            borrow = (d > a->digits_[i]) ? 1 : 0;\n            out->digits_[i] = d;\n            if (d != 0)\n                out->count_ = i + 1;\n        }\n\n        return ret;\n    }\n\n    int Compare(const BigInteger& rhs) const {\n        if (count_ != rhs.count_)\n            return count_ < rhs.count_ ? -1 : 1;\n\n        for (size_t i = count_; i-- > 0;)\n            if (digits_[i] != rhs.digits_[i])\n                return digits_[i] < rhs.digits_[i] ? -1 : 1;\n\n        return 0;\n    }\n\n    size_t GetCount() const { return count_; }\n    Type GetDigit(size_t index) const { RAPIDJSON_ASSERT(index < count_); return digits_[index]; }\n    bool IsZero() const { return count_ == 1 && digits_[0] == 0; }\n\nprivate:\n    void AppendDecimal64(const char* begin, const char* end) {\n        uint64_t u = ParseUint64(begin, end);\n        if (IsZero())\n            *this = u;\n        else {\n            unsigned exp = static_cast<unsigned>(end - begin);\n            (MultiplyPow5(exp) <<= exp) += u;   // *this = *this * 10^exp + u\n        }\n    }\n\n    void PushBack(Type digit) {\n        RAPIDJSON_ASSERT(count_ < kCapacity);\n        digits_[count_++] = digit;\n    }\n\n    static uint64_t ParseUint64(const char* begin, const char* end) {\n        uint64_t r = 0;\n        for (const char* p = begin; p != end; ++p) {\n            RAPIDJSON_ASSERT(*p >= '0' && *p <= '9');\n            r = r * 10u + static_cast<unsigned>(*p - '0');\n        }\n        return r;\n    }\n\n    // Assume a * b + k < 2^128\n    static uint64_t MulAdd64(uint64_t a, uint64_t b, uint64_t k, uint64_t* outHigh) {\n#if defined(_MSC_VER) && defined(_M_AMD64)\n        uint64_t low = _umul128(a, b, outHigh) + k;\n        if (low < k)\n            (*outHigh)++;\n        return low;\n#elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__x86_64__)\n        __extension__ typedef unsigned __int128 uint128;\n        uint128 p = static_cast<uint128>(a) * static_cast<uint128>(b);\n        p += k;\n        *outHigh = static_cast<uint64_t>(p >> 64);\n        return static_cast<uint64_t>(p);\n#else\n        const uint64_t a0 = a & 0xFFFFFFFF, a1 = a >> 32, b0 = b & 0xFFFFFFFF, b1 = b >> 32;\n        uint64_t x0 = a0 * b0, x1 = a0 * b1, x2 = a1 * b0, x3 = a1 * b1;\n        x1 += (x0 >> 32); // can't give carry\n        x1 += x2;\n        if (x1 < x2)\n            x3 += (static_cast<uint64_t>(1) << 32);\n        uint64_t lo = (x1 << 32) + (x0 & 0xFFFFFFFF);\n        uint64_t hi = x3 + (x1 >> 32);\n\n        lo += k;\n        if (lo < k)\n            hi++;\n        *outHigh = hi;\n        return lo;\n#endif\n    }\n\n    static const size_t kBitCount = 3328;  // 64bit * 54 > 10^1000\n    static const size_t kCapacity = kBitCount / sizeof(Type);\n    static const size_t kTypeBit = sizeof(Type) * 8;\n\n    Type digits_[kCapacity];\n    size_t count_;\n};\n\n} // namespace internal\nRAPIDJSON_NAMESPACE_END\n\n#endif // RAPIDJSON_BIGINTEGER_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/internal/diyfp.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n// This is a C++ header-only implementation of Grisu2 algorithm from the publication:\n// Loitsch, Florian. \"Printing floating-point numbers quickly and accurately with\n// integers.\" ACM Sigplan Notices 45.6 (2010): 233-243.\n\n#ifndef RAPIDJSON_DIYFP_H_\n#define RAPIDJSON_DIYFP_H_\n\n#include \"../rapidjson.h\"\n\n#if defined(_MSC_VER) && defined(_M_AMD64)\n#include <intrin.h>\n#pragma intrinsic(_BitScanReverse64)\n#pragma intrinsic(_umul128)\n#endif\n\nRAPIDJSON_NAMESPACE_BEGIN\nnamespace internal {\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(effc++)\n#endif\n\n#ifdef __clang__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(padded)\n#endif\n\nstruct DiyFp {\n    DiyFp() : f(), e() {}\n\n    DiyFp(uint64_t fp, int exp) : f(fp), e(exp) {}\n\n    explicit DiyFp(double d) {\n        union {\n            double d;\n            uint64_t u64;\n        } u = { d };\n\n        int biased_e = static_cast<int>((u.u64 & kDpExponentMask) >> kDpSignificandSize);\n        uint64_t significand = (u.u64 & kDpSignificandMask);\n        if (biased_e != 0) {\n            f = significand + kDpHiddenBit;\n            e = biased_e - kDpExponentBias;\n        } \n        else {\n            f = significand;\n            e = kDpMinExponent + 1;\n        }\n    }\n\n    DiyFp operator-(const DiyFp& rhs) const {\n        return DiyFp(f - rhs.f, e);\n    }\n\n    DiyFp operator*(const DiyFp& rhs) const {\n#if defined(_MSC_VER) && defined(_M_AMD64)\n        uint64_t h;\n        uint64_t l = _umul128(f, rhs.f, &h);\n        if (l & (uint64_t(1) << 63)) // rounding\n            h++;\n        return DiyFp(h, e + rhs.e + 64);\n#elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) && defined(__x86_64__)\n        __extension__ typedef unsigned __int128 uint128;\n        uint128 p = static_cast<uint128>(f) * static_cast<uint128>(rhs.f);\n        uint64_t h = static_cast<uint64_t>(p >> 64);\n        uint64_t l = static_cast<uint64_t>(p);\n        if (l & (uint64_t(1) << 63)) // rounding\n            h++;\n        return DiyFp(h, e + rhs.e + 64);\n#else\n        const uint64_t M32 = 0xFFFFFFFF;\n        const uint64_t a = f >> 32;\n        const uint64_t b = f & M32;\n        const uint64_t c = rhs.f >> 32;\n        const uint64_t d = rhs.f & M32;\n        const uint64_t ac = a * c;\n        const uint64_t bc = b * c;\n        const uint64_t ad = a * d;\n        const uint64_t bd = b * d;\n        uint64_t tmp = (bd >> 32) + (ad & M32) + (bc & M32);\n        tmp += 1U << 31;  /// mult_round\n        return DiyFp(ac + (ad >> 32) + (bc >> 32) + (tmp >> 32), e + rhs.e + 64);\n#endif\n    }\n\n    DiyFp Normalize() const {\n#if defined(_MSC_VER) && defined(_M_AMD64)\n        unsigned long index;\n        _BitScanReverse64(&index, f);\n        return DiyFp(f << (63 - index), e - (63 - index));\n#elif defined(__GNUC__) && __GNUC__ >= 4\n        int s = __builtin_clzll(f);\n        return DiyFp(f << s, e - s);\n#else\n        DiyFp res = *this;\n        while (!(res.f & (static_cast<uint64_t>(1) << 63))) {\n            res.f <<= 1;\n            res.e--;\n        }\n        return res;\n#endif\n    }\n\n    DiyFp NormalizeBoundary() const {\n        DiyFp res = *this;\n        while (!(res.f & (kDpHiddenBit << 1))) {\n            res.f <<= 1;\n            res.e--;\n        }\n        res.f <<= (kDiySignificandSize - kDpSignificandSize - 2);\n        res.e = res.e - (kDiySignificandSize - kDpSignificandSize - 2);\n        return res;\n    }\n\n    void NormalizedBoundaries(DiyFp* minus, DiyFp* plus) const {\n        DiyFp pl = DiyFp((f << 1) + 1, e - 1).NormalizeBoundary();\n        DiyFp mi = (f == kDpHiddenBit) ? DiyFp((f << 2) - 1, e - 2) : DiyFp((f << 1) - 1, e - 1);\n        mi.f <<= mi.e - pl.e;\n        mi.e = pl.e;\n        *plus = pl;\n        *minus = mi;\n    }\n\n    double ToDouble() const {\n        union {\n            double d;\n            uint64_t u64;\n        }u;\n        const uint64_t be = (e == kDpDenormalExponent && (f & kDpHiddenBit) == 0) ? 0 : \n            static_cast<uint64_t>(e + kDpExponentBias);\n        u.u64 = (f & kDpSignificandMask) | (be << kDpSignificandSize);\n        return u.d;\n    }\n\n    static const int kDiySignificandSize = 64;\n    static const int kDpSignificandSize = 52;\n    static const int kDpExponentBias = 0x3FF + kDpSignificandSize;\n    static const int kDpMaxExponent = 0x7FF - kDpExponentBias;\n    static const int kDpMinExponent = -kDpExponentBias;\n    static const int kDpDenormalExponent = -kDpExponentBias + 1;\n    static const uint64_t kDpExponentMask = RAPIDJSON_UINT64_C2(0x7FF00000, 0x00000000);\n    static const uint64_t kDpSignificandMask = RAPIDJSON_UINT64_C2(0x000FFFFF, 0xFFFFFFFF);\n    static const uint64_t kDpHiddenBit = RAPIDJSON_UINT64_C2(0x00100000, 0x00000000);\n\n    uint64_t f;\n    int e;\n};\n\ninline DiyFp GetCachedPowerByIndex(size_t index) {\n    // 10^-348, 10^-340, ..., 10^340\n    static const uint64_t kCachedPowers_F[] = {\n        RAPIDJSON_UINT64_C2(0xfa8fd5a0, 0x081c0288), RAPIDJSON_UINT64_C2(0xbaaee17f, 0xa23ebf76),\n        RAPIDJSON_UINT64_C2(0x8b16fb20, 0x3055ac76), RAPIDJSON_UINT64_C2(0xcf42894a, 0x5dce35ea),\n        RAPIDJSON_UINT64_C2(0x9a6bb0aa, 0x55653b2d), RAPIDJSON_UINT64_C2(0xe61acf03, 0x3d1a45df),\n        RAPIDJSON_UINT64_C2(0xab70fe17, 0xc79ac6ca), RAPIDJSON_UINT64_C2(0xff77b1fc, 0xbebcdc4f),\n        RAPIDJSON_UINT64_C2(0xbe5691ef, 0x416bd60c), RAPIDJSON_UINT64_C2(0x8dd01fad, 0x907ffc3c),\n        RAPIDJSON_UINT64_C2(0xd3515c28, 0x31559a83), RAPIDJSON_UINT64_C2(0x9d71ac8f, 0xada6c9b5),\n        RAPIDJSON_UINT64_C2(0xea9c2277, 0x23ee8bcb), RAPIDJSON_UINT64_C2(0xaecc4991, 0x4078536d),\n        RAPIDJSON_UINT64_C2(0x823c1279, 0x5db6ce57), RAPIDJSON_UINT64_C2(0xc2109436, 0x4dfb5637),\n        RAPIDJSON_UINT64_C2(0x9096ea6f, 0x3848984f), RAPIDJSON_UINT64_C2(0xd77485cb, 0x25823ac7),\n        RAPIDJSON_UINT64_C2(0xa086cfcd, 0x97bf97f4), RAPIDJSON_UINT64_C2(0xef340a98, 0x172aace5),\n        RAPIDJSON_UINT64_C2(0xb23867fb, 0x2a35b28e), RAPIDJSON_UINT64_C2(0x84c8d4df, 0xd2c63f3b),\n        RAPIDJSON_UINT64_C2(0xc5dd4427, 0x1ad3cdba), RAPIDJSON_UINT64_C2(0x936b9fce, 0xbb25c996),\n        RAPIDJSON_UINT64_C2(0xdbac6c24, 0x7d62a584), RAPIDJSON_UINT64_C2(0xa3ab6658, 0x0d5fdaf6),\n        RAPIDJSON_UINT64_C2(0xf3e2f893, 0xdec3f126), RAPIDJSON_UINT64_C2(0xb5b5ada8, 0xaaff80b8),\n        RAPIDJSON_UINT64_C2(0x87625f05, 0x6c7c4a8b), RAPIDJSON_UINT64_C2(0xc9bcff60, 0x34c13053),\n        RAPIDJSON_UINT64_C2(0x964e858c, 0x91ba2655), RAPIDJSON_UINT64_C2(0xdff97724, 0x70297ebd),\n        RAPIDJSON_UINT64_C2(0xa6dfbd9f, 0xb8e5b88f), RAPIDJSON_UINT64_C2(0xf8a95fcf, 0x88747d94),\n        RAPIDJSON_UINT64_C2(0xb9447093, 0x8fa89bcf), RAPIDJSON_UINT64_C2(0x8a08f0f8, 0xbf0f156b),\n        RAPIDJSON_UINT64_C2(0xcdb02555, 0x653131b6), RAPIDJSON_UINT64_C2(0x993fe2c6, 0xd07b7fac),\n        RAPIDJSON_UINT64_C2(0xe45c10c4, 0x2a2b3b06), RAPIDJSON_UINT64_C2(0xaa242499, 0x697392d3),\n        RAPIDJSON_UINT64_C2(0xfd87b5f2, 0x8300ca0e), RAPIDJSON_UINT64_C2(0xbce50864, 0x92111aeb),\n        RAPIDJSON_UINT64_C2(0x8cbccc09, 0x6f5088cc), RAPIDJSON_UINT64_C2(0xd1b71758, 0xe219652c),\n        RAPIDJSON_UINT64_C2(0x9c400000, 0x00000000), RAPIDJSON_UINT64_C2(0xe8d4a510, 0x00000000),\n        RAPIDJSON_UINT64_C2(0xad78ebc5, 0xac620000), RAPIDJSON_UINT64_C2(0x813f3978, 0xf8940984),\n        RAPIDJSON_UINT64_C2(0xc097ce7b, 0xc90715b3), RAPIDJSON_UINT64_C2(0x8f7e32ce, 0x7bea5c70),\n        RAPIDJSON_UINT64_C2(0xd5d238a4, 0xabe98068), RAPIDJSON_UINT64_C2(0x9f4f2726, 0x179a2245),\n        RAPIDJSON_UINT64_C2(0xed63a231, 0xd4c4fb27), RAPIDJSON_UINT64_C2(0xb0de6538, 0x8cc8ada8),\n        RAPIDJSON_UINT64_C2(0x83c7088e, 0x1aab65db), RAPIDJSON_UINT64_C2(0xc45d1df9, 0x42711d9a),\n        RAPIDJSON_UINT64_C2(0x924d692c, 0xa61be758), RAPIDJSON_UINT64_C2(0xda01ee64, 0x1a708dea),\n        RAPIDJSON_UINT64_C2(0xa26da399, 0x9aef774a), RAPIDJSON_UINT64_C2(0xf209787b, 0xb47d6b85),\n        RAPIDJSON_UINT64_C2(0xb454e4a1, 0x79dd1877), RAPIDJSON_UINT64_C2(0x865b8692, 0x5b9bc5c2),\n        RAPIDJSON_UINT64_C2(0xc83553c5, 0xc8965d3d), RAPIDJSON_UINT64_C2(0x952ab45c, 0xfa97a0b3),\n        RAPIDJSON_UINT64_C2(0xde469fbd, 0x99a05fe3), RAPIDJSON_UINT64_C2(0xa59bc234, 0xdb398c25),\n        RAPIDJSON_UINT64_C2(0xf6c69a72, 0xa3989f5c), RAPIDJSON_UINT64_C2(0xb7dcbf53, 0x54e9bece),\n        RAPIDJSON_UINT64_C2(0x88fcf317, 0xf22241e2), RAPIDJSON_UINT64_C2(0xcc20ce9b, 0xd35c78a5),\n        RAPIDJSON_UINT64_C2(0x98165af3, 0x7b2153df), RAPIDJSON_UINT64_C2(0xe2a0b5dc, 0x971f303a),\n        RAPIDJSON_UINT64_C2(0xa8d9d153, 0x5ce3b396), RAPIDJSON_UINT64_C2(0xfb9b7cd9, 0xa4a7443c),\n        RAPIDJSON_UINT64_C2(0xbb764c4c, 0xa7a44410), RAPIDJSON_UINT64_C2(0x8bab8eef, 0xb6409c1a),\n        RAPIDJSON_UINT64_C2(0xd01fef10, 0xa657842c), RAPIDJSON_UINT64_C2(0x9b10a4e5, 0xe9913129),\n        RAPIDJSON_UINT64_C2(0xe7109bfb, 0xa19c0c9d), RAPIDJSON_UINT64_C2(0xac2820d9, 0x623bf429),\n        RAPIDJSON_UINT64_C2(0x80444b5e, 0x7aa7cf85), RAPIDJSON_UINT64_C2(0xbf21e440, 0x03acdd2d),\n        RAPIDJSON_UINT64_C2(0x8e679c2f, 0x5e44ff8f), RAPIDJSON_UINT64_C2(0xd433179d, 0x9c8cb841),\n        RAPIDJSON_UINT64_C2(0x9e19db92, 0xb4e31ba9), RAPIDJSON_UINT64_C2(0xeb96bf6e, 0xbadf77d9),\n        RAPIDJSON_UINT64_C2(0xaf87023b, 0x9bf0ee6b)\n    };\n    static const int16_t kCachedPowers_E[] = {\n        -1220, -1193, -1166, -1140, -1113, -1087, -1060, -1034, -1007,  -980,\n        -954,  -927,  -901,  -874,  -847,  -821,  -794,  -768,  -741,  -715,\n        -688,  -661,  -635,  -608,  -582,  -555,  -529,  -502,  -475,  -449,\n        -422,  -396,  -369,  -343,  -316,  -289,  -263,  -236,  -210,  -183,\n        -157,  -130,  -103,   -77,   -50,   -24,     3,    30,    56,    83,\n        109,   136,   162,   189,   216,   242,   269,   295,   322,   348,\n        375,   402,   428,   455,   481,   508,   534,   561,   588,   614,\n        641,   667,   694,   720,   747,   774,   800,   827,   853,   880,\n        907,   933,   960,   986,  1013,  1039,  1066\n    };\n    return DiyFp(kCachedPowers_F[index], kCachedPowers_E[index]);\n}\n    \ninline DiyFp GetCachedPower(int e, int* K) {\n\n    //int k = static_cast<int>(ceil((-61 - e) * 0.30102999566398114)) + 374;\n    double dk = (-61 - e) * 0.30102999566398114 + 347;  // dk must be positive, so can do ceiling in positive\n    int k = static_cast<int>(dk);\n    if (dk - k > 0.0)\n        k++;\n\n    unsigned index = static_cast<unsigned>((k >> 3) + 1);\n    *K = -(-348 + static_cast<int>(index << 3));    // decimal exponent no need lookup table\n\n    return GetCachedPowerByIndex(index);\n}\n\ninline DiyFp GetCachedPower10(int exp, int *outExp) {\n     unsigned index = (static_cast<unsigned>(exp) + 348u) / 8u;\n     *outExp = -348 + static_cast<int>(index) * 8;\n     return GetCachedPowerByIndex(index);\n }\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_POP\n#endif\n\n#ifdef __clang__\nRAPIDJSON_DIAG_POP\nRAPIDJSON_DIAG_OFF(padded)\n#endif\n\n} // namespace internal\nRAPIDJSON_NAMESPACE_END\n\n#endif // RAPIDJSON_DIYFP_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/internal/dtoa.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n// This is a C++ header-only implementation of Grisu2 algorithm from the publication:\n// Loitsch, Florian. \"Printing floating-point numbers quickly and accurately with\n// integers.\" ACM Sigplan Notices 45.6 (2010): 233-243.\n\n#ifndef RAPIDJSON_DTOA_\n#define RAPIDJSON_DTOA_\n\n#include \"itoa.h\" // GetDigitsLut()\n#include \"diyfp.h\"\n#include \"ieee754.h\"\n\nRAPIDJSON_NAMESPACE_BEGIN\nnamespace internal {\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(effc++)\nRAPIDJSON_DIAG_OFF(array-bounds) // some gcc versions generate wrong warnings https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59124\n#endif\n\ninline void GrisuRound(char* buffer, int len, uint64_t delta, uint64_t rest, uint64_t ten_kappa, uint64_t wp_w) {\n    while (rest < wp_w && delta - rest >= ten_kappa &&\n           (rest + ten_kappa < wp_w ||  /// closer\n            wp_w - rest > rest + ten_kappa - wp_w)) {\n        buffer[len - 1]--;\n        rest += ten_kappa;\n    }\n}\n\ninline unsigned CountDecimalDigit32(uint32_t n) {\n    // Simple pure C++ implementation was faster than __builtin_clz version in this situation.\n    if (n < 10) return 1;\n    if (n < 100) return 2;\n    if (n < 1000) return 3;\n    if (n < 10000) return 4;\n    if (n < 100000) return 5;\n    if (n < 1000000) return 6;\n    if (n < 10000000) return 7;\n    if (n < 100000000) return 8;\n    // Will not reach 10 digits in DigitGen()\n    //if (n < 1000000000) return 9;\n    //return 10;\n    return 9;\n}\n\ninline void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, char* buffer, int* len, int* K) {\n    static const uint32_t kPow10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 };\n    const DiyFp one(uint64_t(1) << -Mp.e, Mp.e);\n    const DiyFp wp_w = Mp - W;\n    uint32_t p1 = static_cast<uint32_t>(Mp.f >> -one.e);\n    uint64_t p2 = Mp.f & (one.f - 1);\n    unsigned kappa = CountDecimalDigit32(p1); // kappa in [0, 9]\n    *len = 0;\n\n    while (kappa > 0) {\n        uint32_t d = 0;\n        switch (kappa) {\n            case  9: d = p1 /  100000000; p1 %=  100000000; break;\n            case  8: d = p1 /   10000000; p1 %=   10000000; break;\n            case  7: d = p1 /    1000000; p1 %=    1000000; break;\n            case  6: d = p1 /     100000; p1 %=     100000; break;\n            case  5: d = p1 /      10000; p1 %=      10000; break;\n            case  4: d = p1 /       1000; p1 %=       1000; break;\n            case  3: d = p1 /        100; p1 %=        100; break;\n            case  2: d = p1 /         10; p1 %=         10; break;\n            case  1: d = p1;              p1 =           0; break;\n            default:;\n        }\n        if (d || *len)\n            buffer[(*len)++] = static_cast<char>('0' + static_cast<char>(d));\n        kappa--;\n        uint64_t tmp = (static_cast<uint64_t>(p1) << -one.e) + p2;\n        if (tmp <= delta) {\n            *K += kappa;\n            GrisuRound(buffer, *len, delta, tmp, static_cast<uint64_t>(kPow10[kappa]) << -one.e, wp_w.f);\n            return;\n        }\n    }\n\n    // kappa = 0\n    for (;;) {\n        p2 *= 10;\n        delta *= 10;\n        char d = static_cast<char>(p2 >> -one.e);\n        if (d || *len)\n            buffer[(*len)++] = static_cast<char>('0' + d);\n        p2 &= one.f - 1;\n        kappa--;\n        if (p2 < delta) {\n            *K += kappa;\n            int index = -static_cast<int>(kappa);\n            GrisuRound(buffer, *len, delta, p2, one.f, wp_w.f * (index < 9 ? kPow10[-static_cast<int>(kappa)] : 0));\n            return;\n        }\n    }\n}\n\ninline void Grisu2(double value, char* buffer, int* length, int* K) {\n    const DiyFp v(value);\n    DiyFp w_m, w_p;\n    v.NormalizedBoundaries(&w_m, &w_p);\n\n    const DiyFp c_mk = GetCachedPower(w_p.e, K);\n    const DiyFp W = v.Normalize() * c_mk;\n    DiyFp Wp = w_p * c_mk;\n    DiyFp Wm = w_m * c_mk;\n    Wm.f++;\n    Wp.f--;\n    DigitGen(W, Wp, Wp.f - Wm.f, buffer, length, K);\n}\n\ninline char* WriteExponent(int K, char* buffer) {\n    if (K < 0) {\n        *buffer++ = '-';\n        K = -K;\n    }\n\n    if (K >= 100) {\n        *buffer++ = static_cast<char>('0' + static_cast<char>(K / 100));\n        K %= 100;\n        const char* d = GetDigitsLut() + K * 2;\n        *buffer++ = d[0];\n        *buffer++ = d[1];\n    }\n    else if (K >= 10) {\n        const char* d = GetDigitsLut() + K * 2;\n        *buffer++ = d[0];\n        *buffer++ = d[1];\n    }\n    else\n        *buffer++ = static_cast<char>('0' + static_cast<char>(K));\n\n    return buffer;\n}\n\ninline char* Prettify(char* buffer, int length, int k, int maxDecimalPlaces) {\n    const int kk = length + k;  // 10^(kk-1) <= v < 10^kk\n\n    if (0 <= k && kk <= 21) {\n        // 1234e7 -> 12340000000\n        for (int i = length; i < kk; i++)\n            buffer[i] = '0';\n        buffer[kk] = '.';\n        buffer[kk + 1] = '0';\n        return &buffer[kk + 2];\n    }\n    else if (0 < kk && kk <= 21) {\n        // 1234e-2 -> 12.34\n        std::memmove(&buffer[kk + 1], &buffer[kk], static_cast<size_t>(length - kk));\n        buffer[kk] = '.';\n        if (0 > k + maxDecimalPlaces) {\n            // When maxDecimalPlaces = 2, 1.2345 -> 1.23, 1.102 -> 1.1\n            // Remove extra trailing zeros (at least one) after truncation.\n            for (int i = kk + maxDecimalPlaces; i > kk + 1; i--)\n                if (buffer[i] != '0')\n                    return &buffer[i + 1];\n            return &buffer[kk + 2]; // Reserve one zero\n        }\n        else\n            return &buffer[length + 1];\n    }\n    else if (-6 < kk && kk <= 0) {\n        // 1234e-6 -> 0.001234\n        const int offset = 2 - kk;\n        std::memmove(&buffer[offset], &buffer[0], static_cast<size_t>(length));\n        buffer[0] = '0';\n        buffer[1] = '.';\n        for (int i = 2; i < offset; i++)\n            buffer[i] = '0';\n        if (length - kk > maxDecimalPlaces) {\n            // When maxDecimalPlaces = 2, 0.123 -> 0.12, 0.102 -> 0.1\n            // Remove extra trailing zeros (at least one) after truncation.\n            for (int i = maxDecimalPlaces + 1; i > 2; i--)\n                if (buffer[i] != '0')\n                    return &buffer[i + 1];\n            return &buffer[3]; // Reserve one zero\n        }\n        else\n            return &buffer[length + offset];\n    }\n    else if (kk < -maxDecimalPlaces) {\n        // Truncate to zero\n        buffer[0] = '0';\n        buffer[1] = '.';\n        buffer[2] = '0';\n        return &buffer[3];\n    }\n    else if (length == 1) {\n        // 1e30\n        buffer[1] = 'e';\n        return WriteExponent(kk - 1, &buffer[2]);\n    }\n    else {\n        // 1234e30 -> 1.234e33\n        std::memmove(&buffer[2], &buffer[1], static_cast<size_t>(length - 1));\n        buffer[1] = '.';\n        buffer[length + 1] = 'e';\n        return WriteExponent(kk - 1, &buffer[0 + length + 2]);\n    }\n}\n\ninline char* dtoa(double value, char* buffer, int maxDecimalPlaces = 324) {\n    RAPIDJSON_ASSERT(maxDecimalPlaces >= 1);\n    Double d(value);\n    if (d.IsZero()) {\n        if (d.Sign())\n            *buffer++ = '-';     // -0.0, Issue #289\n        buffer[0] = '0';\n        buffer[1] = '.';\n        buffer[2] = '0';\n        return &buffer[3];\n    }\n    else {\n        if (value < 0) {\n            *buffer++ = '-';\n            value = -value;\n        }\n        int length, K;\n        Grisu2(value, buffer, &length, &K);\n        return Prettify(buffer, length, K, maxDecimalPlaces);\n    }\n}\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_POP\n#endif\n\n} // namespace internal\nRAPIDJSON_NAMESPACE_END\n\n#endif // RAPIDJSON_DTOA_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/internal/ieee754.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_IEEE754_\n#define RAPIDJSON_IEEE754_\n\n#include \"../rapidjson.h\"\n\nRAPIDJSON_NAMESPACE_BEGIN\nnamespace internal {\n\nclass Double {\npublic:\n    Double() {}\n    Double(double d) : d_(d) {}\n    Double(uint64_t u) : u_(u) {}\n\n    double Value() const { return d_; }\n    uint64_t Uint64Value() const { return u_; }\n\n    double NextPositiveDouble() const {\n        RAPIDJSON_ASSERT(!Sign());\n        return Double(u_ + 1).Value();\n    }\n\n    bool Sign() const { return (u_ & kSignMask) != 0; }\n    uint64_t Significand() const { return u_ & kSignificandMask; }\n    int Exponent() const { return static_cast<int>(((u_ & kExponentMask) >> kSignificandSize) - kExponentBias); }\n\n    bool IsNan() const { return (u_ & kExponentMask) == kExponentMask && Significand() != 0; }\n    bool IsInf() const { return (u_ & kExponentMask) == kExponentMask && Significand() == 0; }\n    bool IsNanOrInf() const { return (u_ & kExponentMask) == kExponentMask; }\n    bool IsNormal() const { return (u_ & kExponentMask) != 0 || Significand() == 0; }\n    bool IsZero() const { return (u_ & (kExponentMask | kSignificandMask)) == 0; }\n\n    uint64_t IntegerSignificand() const { return IsNormal() ? Significand() | kHiddenBit : Significand(); }\n    int IntegerExponent() const { return (IsNormal() ? Exponent() : kDenormalExponent) - kSignificandSize; }\n    uint64_t ToBias() const { return (u_ & kSignMask) ? ~u_ + 1 : u_ | kSignMask; }\n\n    static unsigned EffectiveSignificandSize(int order) {\n        if (order >= -1021)\n            return 53;\n        else if (order <= -1074)\n            return 0;\n        else\n            return static_cast<unsigned>(order) + 1074;\n    }\n\nprivate:\n    static const int kSignificandSize = 52;\n    static const int kExponentBias = 0x3FF;\n    static const int kDenormalExponent = 1 - kExponentBias;\n    static const uint64_t kSignMask = RAPIDJSON_UINT64_C2(0x80000000, 0x00000000);\n    static const uint64_t kExponentMask = RAPIDJSON_UINT64_C2(0x7FF00000, 0x00000000);\n    static const uint64_t kSignificandMask = RAPIDJSON_UINT64_C2(0x000FFFFF, 0xFFFFFFFF);\n    static const uint64_t kHiddenBit = RAPIDJSON_UINT64_C2(0x00100000, 0x00000000);\n\n    union {\n        double d_;\n        uint64_t u_;\n    };\n};\n\n} // namespace internal\nRAPIDJSON_NAMESPACE_END\n\n#endif // RAPIDJSON_IEEE754_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/internal/itoa.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_ITOA_\n#define RAPIDJSON_ITOA_\n\n#include \"../rapidjson.h\"\n\nRAPIDJSON_NAMESPACE_BEGIN\nnamespace internal {\n\ninline const char* GetDigitsLut() {\n    static const char cDigitsLut[200] = {\n        '0','0','0','1','0','2','0','3','0','4','0','5','0','6','0','7','0','8','0','9',\n        '1','0','1','1','1','2','1','3','1','4','1','5','1','6','1','7','1','8','1','9',\n        '2','0','2','1','2','2','2','3','2','4','2','5','2','6','2','7','2','8','2','9',\n        '3','0','3','1','3','2','3','3','3','4','3','5','3','6','3','7','3','8','3','9',\n        '4','0','4','1','4','2','4','3','4','4','4','5','4','6','4','7','4','8','4','9',\n        '5','0','5','1','5','2','5','3','5','4','5','5','5','6','5','7','5','8','5','9',\n        '6','0','6','1','6','2','6','3','6','4','6','5','6','6','6','7','6','8','6','9',\n        '7','0','7','1','7','2','7','3','7','4','7','5','7','6','7','7','7','8','7','9',\n        '8','0','8','1','8','2','8','3','8','4','8','5','8','6','8','7','8','8','8','9',\n        '9','0','9','1','9','2','9','3','9','4','9','5','9','6','9','7','9','8','9','9'\n    };\n    return cDigitsLut;\n}\n\ninline char* u32toa(uint32_t value, char* buffer) {\n    const char* cDigitsLut = GetDigitsLut();\n\n    if (value < 10000) {\n        const uint32_t d1 = (value / 100) << 1;\n        const uint32_t d2 = (value % 100) << 1;\n        \n        if (value >= 1000)\n            *buffer++ = cDigitsLut[d1];\n        if (value >= 100)\n            *buffer++ = cDigitsLut[d1 + 1];\n        if (value >= 10)\n            *buffer++ = cDigitsLut[d2];\n        *buffer++ = cDigitsLut[d2 + 1];\n    }\n    else if (value < 100000000) {\n        // value = bbbbcccc\n        const uint32_t b = value / 10000;\n        const uint32_t c = value % 10000;\n        \n        const uint32_t d1 = (b / 100) << 1;\n        const uint32_t d2 = (b % 100) << 1;\n        \n        const uint32_t d3 = (c / 100) << 1;\n        const uint32_t d4 = (c % 100) << 1;\n        \n        if (value >= 10000000)\n            *buffer++ = cDigitsLut[d1];\n        if (value >= 1000000)\n            *buffer++ = cDigitsLut[d1 + 1];\n        if (value >= 100000)\n            *buffer++ = cDigitsLut[d2];\n        *buffer++ = cDigitsLut[d2 + 1];\n        \n        *buffer++ = cDigitsLut[d3];\n        *buffer++ = cDigitsLut[d3 + 1];\n        *buffer++ = cDigitsLut[d4];\n        *buffer++ = cDigitsLut[d4 + 1];\n    }\n    else {\n        // value = aabbbbcccc in decimal\n        \n        const uint32_t a = value / 100000000; // 1 to 42\n        value %= 100000000;\n        \n        if (a >= 10) {\n            const unsigned i = a << 1;\n            *buffer++ = cDigitsLut[i];\n            *buffer++ = cDigitsLut[i + 1];\n        }\n        else\n            *buffer++ = static_cast<char>('0' + static_cast<char>(a));\n\n        const uint32_t b = value / 10000; // 0 to 9999\n        const uint32_t c = value % 10000; // 0 to 9999\n        \n        const uint32_t d1 = (b / 100) << 1;\n        const uint32_t d2 = (b % 100) << 1;\n        \n        const uint32_t d3 = (c / 100) << 1;\n        const uint32_t d4 = (c % 100) << 1;\n        \n        *buffer++ = cDigitsLut[d1];\n        *buffer++ = cDigitsLut[d1 + 1];\n        *buffer++ = cDigitsLut[d2];\n        *buffer++ = cDigitsLut[d2 + 1];\n        *buffer++ = cDigitsLut[d3];\n        *buffer++ = cDigitsLut[d3 + 1];\n        *buffer++ = cDigitsLut[d4];\n        *buffer++ = cDigitsLut[d4 + 1];\n    }\n    return buffer;\n}\n\ninline char* i32toa(int32_t value, char* buffer) {\n    uint32_t u = static_cast<uint32_t>(value);\n    if (value < 0) {\n        *buffer++ = '-';\n        u = ~u + 1;\n    }\n\n    return u32toa(u, buffer);\n}\n\ninline char* u64toa(uint64_t value, char* buffer) {\n    const char* cDigitsLut = GetDigitsLut();\n    const uint64_t  kTen8 = 100000000;\n    const uint64_t  kTen9 = kTen8 * 10;\n    const uint64_t kTen10 = kTen8 * 100;\n    const uint64_t kTen11 = kTen8 * 1000;\n    const uint64_t kTen12 = kTen8 * 10000;\n    const uint64_t kTen13 = kTen8 * 100000;\n    const uint64_t kTen14 = kTen8 * 1000000;\n    const uint64_t kTen15 = kTen8 * 10000000;\n    const uint64_t kTen16 = kTen8 * kTen8;\n    \n    if (value < kTen8) {\n        uint32_t v = static_cast<uint32_t>(value);\n        if (v < 10000) {\n            const uint32_t d1 = (v / 100) << 1;\n            const uint32_t d2 = (v % 100) << 1;\n            \n            if (v >= 1000)\n                *buffer++ = cDigitsLut[d1];\n            if (v >= 100)\n                *buffer++ = cDigitsLut[d1 + 1];\n            if (v >= 10)\n                *buffer++ = cDigitsLut[d2];\n            *buffer++ = cDigitsLut[d2 + 1];\n        }\n        else {\n            // value = bbbbcccc\n            const uint32_t b = v / 10000;\n            const uint32_t c = v % 10000;\n            \n            const uint32_t d1 = (b / 100) << 1;\n            const uint32_t d2 = (b % 100) << 1;\n            \n            const uint32_t d3 = (c / 100) << 1;\n            const uint32_t d4 = (c % 100) << 1;\n            \n            if (value >= 10000000)\n                *buffer++ = cDigitsLut[d1];\n            if (value >= 1000000)\n                *buffer++ = cDigitsLut[d1 + 1];\n            if (value >= 100000)\n                *buffer++ = cDigitsLut[d2];\n            *buffer++ = cDigitsLut[d2 + 1];\n            \n            *buffer++ = cDigitsLut[d3];\n            *buffer++ = cDigitsLut[d3 + 1];\n            *buffer++ = cDigitsLut[d4];\n            *buffer++ = cDigitsLut[d4 + 1];\n        }\n    }\n    else if (value < kTen16) {\n        const uint32_t v0 = static_cast<uint32_t>(value / kTen8);\n        const uint32_t v1 = static_cast<uint32_t>(value % kTen8);\n        \n        const uint32_t b0 = v0 / 10000;\n        const uint32_t c0 = v0 % 10000;\n        \n        const uint32_t d1 = (b0 / 100) << 1;\n        const uint32_t d2 = (b0 % 100) << 1;\n        \n        const uint32_t d3 = (c0 / 100) << 1;\n        const uint32_t d4 = (c0 % 100) << 1;\n\n        const uint32_t b1 = v1 / 10000;\n        const uint32_t c1 = v1 % 10000;\n        \n        const uint32_t d5 = (b1 / 100) << 1;\n        const uint32_t d6 = (b1 % 100) << 1;\n        \n        const uint32_t d7 = (c1 / 100) << 1;\n        const uint32_t d8 = (c1 % 100) << 1;\n\n        if (value >= kTen15)\n            *buffer++ = cDigitsLut[d1];\n        if (value >= kTen14)\n            *buffer++ = cDigitsLut[d1 + 1];\n        if (value >= kTen13)\n            *buffer++ = cDigitsLut[d2];\n        if (value >= kTen12)\n            *buffer++ = cDigitsLut[d2 + 1];\n        if (value >= kTen11)\n            *buffer++ = cDigitsLut[d3];\n        if (value >= kTen10)\n            *buffer++ = cDigitsLut[d3 + 1];\n        if (value >= kTen9)\n            *buffer++ = cDigitsLut[d4];\n        if (value >= kTen8)\n            *buffer++ = cDigitsLut[d4 + 1];\n        \n        *buffer++ = cDigitsLut[d5];\n        *buffer++ = cDigitsLut[d5 + 1];\n        *buffer++ = cDigitsLut[d6];\n        *buffer++ = cDigitsLut[d6 + 1];\n        *buffer++ = cDigitsLut[d7];\n        *buffer++ = cDigitsLut[d7 + 1];\n        *buffer++ = cDigitsLut[d8];\n        *buffer++ = cDigitsLut[d8 + 1];\n    }\n    else {\n        const uint32_t a = static_cast<uint32_t>(value / kTen16); // 1 to 1844\n        value %= kTen16;\n        \n        if (a < 10)\n            *buffer++ = static_cast<char>('0' + static_cast<char>(a));\n        else if (a < 100) {\n            const uint32_t i = a << 1;\n            *buffer++ = cDigitsLut[i];\n            *buffer++ = cDigitsLut[i + 1];\n        }\n        else if (a < 1000) {\n            *buffer++ = static_cast<char>('0' + static_cast<char>(a / 100));\n            \n            const uint32_t i = (a % 100) << 1;\n            *buffer++ = cDigitsLut[i];\n            *buffer++ = cDigitsLut[i + 1];\n        }\n        else {\n            const uint32_t i = (a / 100) << 1;\n            const uint32_t j = (a % 100) << 1;\n            *buffer++ = cDigitsLut[i];\n            *buffer++ = cDigitsLut[i + 1];\n            *buffer++ = cDigitsLut[j];\n            *buffer++ = cDigitsLut[j + 1];\n        }\n        \n        const uint32_t v0 = static_cast<uint32_t>(value / kTen8);\n        const uint32_t v1 = static_cast<uint32_t>(value % kTen8);\n        \n        const uint32_t b0 = v0 / 10000;\n        const uint32_t c0 = v0 % 10000;\n        \n        const uint32_t d1 = (b0 / 100) << 1;\n        const uint32_t d2 = (b0 % 100) << 1;\n        \n        const uint32_t d3 = (c0 / 100) << 1;\n        const uint32_t d4 = (c0 % 100) << 1;\n        \n        const uint32_t b1 = v1 / 10000;\n        const uint32_t c1 = v1 % 10000;\n        \n        const uint32_t d5 = (b1 / 100) << 1;\n        const uint32_t d6 = (b1 % 100) << 1;\n        \n        const uint32_t d7 = (c1 / 100) << 1;\n        const uint32_t d8 = (c1 % 100) << 1;\n        \n        *buffer++ = cDigitsLut[d1];\n        *buffer++ = cDigitsLut[d1 + 1];\n        *buffer++ = cDigitsLut[d2];\n        *buffer++ = cDigitsLut[d2 + 1];\n        *buffer++ = cDigitsLut[d3];\n        *buffer++ = cDigitsLut[d3 + 1];\n        *buffer++ = cDigitsLut[d4];\n        *buffer++ = cDigitsLut[d4 + 1];\n        *buffer++ = cDigitsLut[d5];\n        *buffer++ = cDigitsLut[d5 + 1];\n        *buffer++ = cDigitsLut[d6];\n        *buffer++ = cDigitsLut[d6 + 1];\n        *buffer++ = cDigitsLut[d7];\n        *buffer++ = cDigitsLut[d7 + 1];\n        *buffer++ = cDigitsLut[d8];\n        *buffer++ = cDigitsLut[d8 + 1];\n    }\n    \n    return buffer;\n}\n\ninline char* i64toa(int64_t value, char* buffer) {\n    uint64_t u = static_cast<uint64_t>(value);\n    if (value < 0) {\n        *buffer++ = '-';\n        u = ~u + 1;\n    }\n\n    return u64toa(u, buffer);\n}\n\n} // namespace internal\nRAPIDJSON_NAMESPACE_END\n\n#endif // RAPIDJSON_ITOA_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/internal/meta.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_INTERNAL_META_H_\n#define RAPIDJSON_INTERNAL_META_H_\n\n#include \"../rapidjson.h\"\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(effc++)\n#endif\n#if defined(_MSC_VER)\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(6334)\n#endif\n\n#if RAPIDJSON_HAS_CXX11_TYPETRAITS\n#include <type_traits>\n#endif\n\n//@cond RAPIDJSON_INTERNAL\nRAPIDJSON_NAMESPACE_BEGIN\nnamespace internal {\n\n// Helper to wrap/convert arbitrary types to void, useful for arbitrary type matching\ntemplate <typename T> struct Void { typedef void Type; };\n\n///////////////////////////////////////////////////////////////////////////////\n// BoolType, TrueType, FalseType\n//\ntemplate <bool Cond> struct BoolType {\n    static const bool Value = Cond;\n    typedef BoolType Type;\n};\ntypedef BoolType<true> TrueType;\ntypedef BoolType<false> FalseType;\n\n\n///////////////////////////////////////////////////////////////////////////////\n// SelectIf, BoolExpr, NotExpr, AndExpr, OrExpr\n//\n\ntemplate <bool C> struct SelectIfImpl { template <typename T1, typename T2> struct Apply { typedef T1 Type; }; };\ntemplate <> struct SelectIfImpl<false> { template <typename T1, typename T2> struct Apply { typedef T2 Type; }; };\ntemplate <bool C, typename T1, typename T2> struct SelectIfCond : SelectIfImpl<C>::template Apply<T1,T2> {};\ntemplate <typename C, typename T1, typename T2> struct SelectIf : SelectIfCond<C::Value, T1, T2> {};\n\ntemplate <bool Cond1, bool Cond2> struct AndExprCond : FalseType {};\ntemplate <> struct AndExprCond<true, true> : TrueType {};\ntemplate <bool Cond1, bool Cond2> struct OrExprCond : TrueType {};\ntemplate <> struct OrExprCond<false, false> : FalseType {};\n\ntemplate <typename C> struct BoolExpr : SelectIf<C,TrueType,FalseType>::Type {};\ntemplate <typename C> struct NotExpr  : SelectIf<C,FalseType,TrueType>::Type {};\ntemplate <typename C1, typename C2> struct AndExpr : AndExprCond<C1::Value, C2::Value>::Type {};\ntemplate <typename C1, typename C2> struct OrExpr  : OrExprCond<C1::Value, C2::Value>::Type {};\n\n\n///////////////////////////////////////////////////////////////////////////////\n// AddConst, MaybeAddConst, RemoveConst\ntemplate <typename T> struct AddConst { typedef const T Type; };\ntemplate <bool Constify, typename T> struct MaybeAddConst : SelectIfCond<Constify, const T, T> {};\ntemplate <typename T> struct RemoveConst { typedef T Type; };\ntemplate <typename T> struct RemoveConst<const T> { typedef T Type; };\n\n\n///////////////////////////////////////////////////////////////////////////////\n// IsSame, IsConst, IsMoreConst, IsPointer\n//\ntemplate <typename T, typename U> struct IsSame : FalseType {};\ntemplate <typename T> struct IsSame<T, T> : TrueType {};\n\ntemplate <typename T> struct IsConst : FalseType {};\ntemplate <typename T> struct IsConst<const T> : TrueType {};\n\ntemplate <typename CT, typename T>\nstruct IsMoreConst\n    : AndExpr<IsSame<typename RemoveConst<CT>::Type, typename RemoveConst<T>::Type>,\n              BoolType<IsConst<CT>::Value >= IsConst<T>::Value> >::Type {};\n\ntemplate <typename T> struct IsPointer : FalseType {};\ntemplate <typename T> struct IsPointer<T*> : TrueType {};\n\n///////////////////////////////////////////////////////////////////////////////\n// IsBaseOf\n//\n#if RAPIDJSON_HAS_CXX11_TYPETRAITS\n\ntemplate <typename B, typename D> struct IsBaseOf\n    : BoolType< ::std::is_base_of<B,D>::value> {};\n\n#else // simplified version adopted from Boost\n\ntemplate<typename B, typename D> struct IsBaseOfImpl {\n    RAPIDJSON_STATIC_ASSERT(sizeof(B) != 0);\n    RAPIDJSON_STATIC_ASSERT(sizeof(D) != 0);\n\n    typedef char (&Yes)[1];\n    typedef char (&No) [2];\n\n    template <typename T>\n    static Yes Check(const D*, T);\n    static No  Check(const B*, int);\n\n    struct Host {\n        operator const B*() const;\n        operator const D*();\n    };\n\n    enum { Value = (sizeof(Check(Host(), 0)) == sizeof(Yes)) };\n};\n\ntemplate <typename B, typename D> struct IsBaseOf\n    : OrExpr<IsSame<B, D>, BoolExpr<IsBaseOfImpl<B, D> > >::Type {};\n\n#endif // RAPIDJSON_HAS_CXX11_TYPETRAITS\n\n\n//////////////////////////////////////////////////////////////////////////\n// EnableIf / DisableIf\n//\ntemplate <bool Condition, typename T = void> struct EnableIfCond  { typedef T Type; };\ntemplate <typename T> struct EnableIfCond<false, T> { /* empty */ };\n\ntemplate <bool Condition, typename T = void> struct DisableIfCond { typedef T Type; };\ntemplate <typename T> struct DisableIfCond<true, T> { /* empty */ };\n\ntemplate <typename Condition, typename T = void>\nstruct EnableIf : EnableIfCond<Condition::Value, T> {};\n\ntemplate <typename Condition, typename T = void>\nstruct DisableIf : DisableIfCond<Condition::Value, T> {};\n\n// SFINAE helpers\nstruct SfinaeTag {};\ntemplate <typename T> struct RemoveSfinaeTag;\ntemplate <typename T> struct RemoveSfinaeTag<SfinaeTag&(*)(T)> { typedef T Type; };\n\n#define RAPIDJSON_REMOVEFPTR_(type) \\\n    typename ::RAPIDJSON_NAMESPACE::internal::RemoveSfinaeTag \\\n        < ::RAPIDJSON_NAMESPACE::internal::SfinaeTag&(*) type>::Type\n\n#define RAPIDJSON_ENABLEIF(cond) \\\n    typename ::RAPIDJSON_NAMESPACE::internal::EnableIf \\\n        <RAPIDJSON_REMOVEFPTR_(cond)>::Type * = NULL\n\n#define RAPIDJSON_DISABLEIF(cond) \\\n    typename ::RAPIDJSON_NAMESPACE::internal::DisableIf \\\n        <RAPIDJSON_REMOVEFPTR_(cond)>::Type * = NULL\n\n#define RAPIDJSON_ENABLEIF_RETURN(cond,returntype) \\\n    typename ::RAPIDJSON_NAMESPACE::internal::EnableIf \\\n        <RAPIDJSON_REMOVEFPTR_(cond), \\\n         RAPIDJSON_REMOVEFPTR_(returntype)>::Type\n\n#define RAPIDJSON_DISABLEIF_RETURN(cond,returntype) \\\n    typename ::RAPIDJSON_NAMESPACE::internal::DisableIf \\\n        <RAPIDJSON_REMOVEFPTR_(cond), \\\n         RAPIDJSON_REMOVEFPTR_(returntype)>::Type\n\n} // namespace internal\nRAPIDJSON_NAMESPACE_END\n//@endcond\n\n#if defined(__GNUC__) || defined(_MSC_VER)\nRAPIDJSON_DIAG_POP\n#endif\n\n#endif // RAPIDJSON_INTERNAL_META_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/internal/pow10.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_POW10_\n#define RAPIDJSON_POW10_\n\n#include \"../rapidjson.h\"\n\nRAPIDJSON_NAMESPACE_BEGIN\nnamespace internal {\n\n//! Computes integer powers of 10 in double (10.0^n).\n/*! This function uses lookup table for fast and accurate results.\n    \\param n non-negative exponent. Must <= 308.\n    \\return 10.0^n\n*/\ninline double Pow10(int n) {\n    static const double e[] = { // 1e-0...1e308: 309 * 8 bytes = 2472 bytes\n        1e+0,  \n        1e+1,  1e+2,  1e+3,  1e+4,  1e+5,  1e+6,  1e+7,  1e+8,  1e+9,  1e+10, 1e+11, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16, 1e+17, 1e+18, 1e+19, 1e+20, \n        1e+21, 1e+22, 1e+23, 1e+24, 1e+25, 1e+26, 1e+27, 1e+28, 1e+29, 1e+30, 1e+31, 1e+32, 1e+33, 1e+34, 1e+35, 1e+36, 1e+37, 1e+38, 1e+39, 1e+40,\n        1e+41, 1e+42, 1e+43, 1e+44, 1e+45, 1e+46, 1e+47, 1e+48, 1e+49, 1e+50, 1e+51, 1e+52, 1e+53, 1e+54, 1e+55, 1e+56, 1e+57, 1e+58, 1e+59, 1e+60,\n        1e+61, 1e+62, 1e+63, 1e+64, 1e+65, 1e+66, 1e+67, 1e+68, 1e+69, 1e+70, 1e+71, 1e+72, 1e+73, 1e+74, 1e+75, 1e+76, 1e+77, 1e+78, 1e+79, 1e+80,\n        1e+81, 1e+82, 1e+83, 1e+84, 1e+85, 1e+86, 1e+87, 1e+88, 1e+89, 1e+90, 1e+91, 1e+92, 1e+93, 1e+94, 1e+95, 1e+96, 1e+97, 1e+98, 1e+99, 1e+100,\n        1e+101,1e+102,1e+103,1e+104,1e+105,1e+106,1e+107,1e+108,1e+109,1e+110,1e+111,1e+112,1e+113,1e+114,1e+115,1e+116,1e+117,1e+118,1e+119,1e+120,\n        1e+121,1e+122,1e+123,1e+124,1e+125,1e+126,1e+127,1e+128,1e+129,1e+130,1e+131,1e+132,1e+133,1e+134,1e+135,1e+136,1e+137,1e+138,1e+139,1e+140,\n        1e+141,1e+142,1e+143,1e+144,1e+145,1e+146,1e+147,1e+148,1e+149,1e+150,1e+151,1e+152,1e+153,1e+154,1e+155,1e+156,1e+157,1e+158,1e+159,1e+160,\n        1e+161,1e+162,1e+163,1e+164,1e+165,1e+166,1e+167,1e+168,1e+169,1e+170,1e+171,1e+172,1e+173,1e+174,1e+175,1e+176,1e+177,1e+178,1e+179,1e+180,\n        1e+181,1e+182,1e+183,1e+184,1e+185,1e+186,1e+187,1e+188,1e+189,1e+190,1e+191,1e+192,1e+193,1e+194,1e+195,1e+196,1e+197,1e+198,1e+199,1e+200,\n        1e+201,1e+202,1e+203,1e+204,1e+205,1e+206,1e+207,1e+208,1e+209,1e+210,1e+211,1e+212,1e+213,1e+214,1e+215,1e+216,1e+217,1e+218,1e+219,1e+220,\n        1e+221,1e+222,1e+223,1e+224,1e+225,1e+226,1e+227,1e+228,1e+229,1e+230,1e+231,1e+232,1e+233,1e+234,1e+235,1e+236,1e+237,1e+238,1e+239,1e+240,\n        1e+241,1e+242,1e+243,1e+244,1e+245,1e+246,1e+247,1e+248,1e+249,1e+250,1e+251,1e+252,1e+253,1e+254,1e+255,1e+256,1e+257,1e+258,1e+259,1e+260,\n        1e+261,1e+262,1e+263,1e+264,1e+265,1e+266,1e+267,1e+268,1e+269,1e+270,1e+271,1e+272,1e+273,1e+274,1e+275,1e+276,1e+277,1e+278,1e+279,1e+280,\n        1e+281,1e+282,1e+283,1e+284,1e+285,1e+286,1e+287,1e+288,1e+289,1e+290,1e+291,1e+292,1e+293,1e+294,1e+295,1e+296,1e+297,1e+298,1e+299,1e+300,\n        1e+301,1e+302,1e+303,1e+304,1e+305,1e+306,1e+307,1e+308\n    };\n    RAPIDJSON_ASSERT(n >= 0 && n <= 308);\n    return e[n];\n}\n\n} // namespace internal\nRAPIDJSON_NAMESPACE_END\n\n#endif // RAPIDJSON_POW10_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/internal/regex.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_INTERNAL_REGEX_H_\n#define RAPIDJSON_INTERNAL_REGEX_H_\n\n#include \"../allocators.h\"\n#include \"../stream.h\"\n#include \"stack.h\"\n\n#ifdef __clang__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(padded)\nRAPIDJSON_DIAG_OFF(switch-enum)\nRAPIDJSON_DIAG_OFF(implicit-fallthrough)\n#endif\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(effc++)\n#endif\n\n#ifdef _MSC_VER\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated\n#endif\n\n#ifndef RAPIDJSON_REGEX_VERBOSE\n#define RAPIDJSON_REGEX_VERBOSE 0\n#endif\n\nRAPIDJSON_NAMESPACE_BEGIN\nnamespace internal {\n\n///////////////////////////////////////////////////////////////////////////////\n// GenericRegex\n\nstatic const SizeType kRegexInvalidState = ~SizeType(0);  //!< Represents an invalid index in GenericRegex::State::out, out1\nstatic const SizeType kRegexInvalidRange = ~SizeType(0);\n\n//! Regular expression engine with subset of ECMAscript grammar.\n/*!\n    Supported regular expression syntax:\n    - \\c ab     Concatenation\n    - \\c a|b    Alternation\n    - \\c a?     Zero or one\n    - \\c a*     Zero or more\n    - \\c a+     One or more\n    - \\c a{3}   Exactly 3 times\n    - \\c a{3,}  At least 3 times\n    - \\c a{3,5} 3 to 5 times\n    - \\c (ab)   Grouping\n    - \\c ^a     At the beginning\n    - \\c a$     At the end\n    - \\c .      Any character\n    - \\c [abc]  Character classes\n    - \\c [a-c]  Character class range\n    - \\c [a-z0-9_] Character class combination\n    - \\c [^abc] Negated character classes\n    - \\c [^a-c] Negated character class range\n    - \\c [\\b]   Backspace (U+0008)\n    - \\c \\\\| \\\\\\\\ ...  Escape characters\n    - \\c \\\\f Form feed (U+000C)\n    - \\c \\\\n Line feed (U+000A)\n    - \\c \\\\r Carriage return (U+000D)\n    - \\c \\\\t Tab (U+0009)\n    - \\c \\\\v Vertical tab (U+000B)\n\n    \\note This is a Thompson NFA engine, implemented with reference to \n        Cox, Russ. \"Regular Expression Matching Can Be Simple And Fast (but is slow in Java, Perl, PHP, Python, Ruby,...).\", \n        https://swtch.com/~rsc/regexp/regexp1.html \n*/\ntemplate <typename Encoding, typename Allocator = CrtAllocator>\nclass GenericRegex {\npublic:\n    typedef typename Encoding::Ch Ch;\n\n    GenericRegex(const Ch* source, Allocator* allocator = 0) : \n        states_(allocator, 256), ranges_(allocator, 256), root_(kRegexInvalidState), stateCount_(), rangeCount_(), \n        stateSet_(), state0_(allocator, 0), state1_(allocator, 0), anchorBegin_(), anchorEnd_()\n    {\n        GenericStringStream<Encoding> ss(source);\n        DecodedStream<GenericStringStream<Encoding> > ds(ss);\n        Parse(ds);\n    }\n\n    ~GenericRegex() {\n        Allocator::Free(stateSet_);\n    }\n\n    bool IsValid() const {\n        return root_ != kRegexInvalidState;\n    }\n\n    template <typename InputStream>\n    bool Match(InputStream& is) const {\n        return SearchWithAnchoring(is, true, true);\n    }\n\n    bool Match(const Ch* s) const {\n        GenericStringStream<Encoding> is(s);\n        return Match(is);\n    }\n\n    template <typename InputStream>\n    bool Search(InputStream& is) const {\n        return SearchWithAnchoring(is, anchorBegin_, anchorEnd_);\n    }\n\n    bool Search(const Ch* s) const {\n        GenericStringStream<Encoding> is(s);\n        return Search(is);\n    }\n\nprivate:\n    enum Operator {\n        kZeroOrOne,\n        kZeroOrMore,\n        kOneOrMore,\n        kConcatenation,\n        kAlternation,\n        kLeftParenthesis\n    };\n\n    static const unsigned kAnyCharacterClass = 0xFFFFFFFF;   //!< For '.'\n    static const unsigned kRangeCharacterClass = 0xFFFFFFFE;\n    static const unsigned kRangeNegationFlag = 0x80000000;\n\n    struct Range {\n        unsigned start; // \n        unsigned end;\n        SizeType next;\n    };\n\n    struct State {\n        SizeType out;     //!< Equals to kInvalid for matching state\n        SizeType out1;    //!< Equals to non-kInvalid for split\n        SizeType rangeStart;\n        unsigned codepoint;\n    };\n\n    struct Frag {\n        Frag(SizeType s, SizeType o, SizeType m) : start(s), out(o), minIndex(m) {}\n        SizeType start;\n        SizeType out; //!< link-list of all output states\n        SizeType minIndex;\n    };\n\n    template <typename SourceStream>\n    class DecodedStream {\n    public:\n        DecodedStream(SourceStream& ss) : ss_(ss), codepoint_() { Decode(); }\n        unsigned Peek() { return codepoint_; }\n        unsigned Take() {\n            unsigned c = codepoint_;\n            if (c) // No further decoding when '\\0'\n                Decode();\n            return c;\n        }\n\n    private:\n        void Decode() {\n            if (!Encoding::Decode(ss_, &codepoint_))\n                codepoint_ = 0;\n        }\n\n        SourceStream& ss_;\n        unsigned codepoint_;\n    };\n\n    State& GetState(SizeType index) {\n        RAPIDJSON_ASSERT(index < stateCount_);\n        return states_.template Bottom<State>()[index];\n    }\n\n    const State& GetState(SizeType index) const {\n        RAPIDJSON_ASSERT(index < stateCount_);\n        return states_.template Bottom<State>()[index];\n    }\n\n    Range& GetRange(SizeType index) {\n        RAPIDJSON_ASSERT(index < rangeCount_);\n        return ranges_.template Bottom<Range>()[index];\n    }\n\n    const Range& GetRange(SizeType index) const {\n        RAPIDJSON_ASSERT(index < rangeCount_);\n        return ranges_.template Bottom<Range>()[index];\n    }\n\n    template <typename InputStream>\n    void Parse(DecodedStream<InputStream>& ds) {\n        Allocator allocator;\n        Stack<Allocator> operandStack(&allocator, 256);     // Frag\n        Stack<Allocator> operatorStack(&allocator, 256);    // Operator\n        Stack<Allocator> atomCountStack(&allocator, 256);   // unsigned (Atom per parenthesis)\n\n        *atomCountStack.template Push<unsigned>() = 0;\n\n        unsigned codepoint;\n        while (ds.Peek() != 0) {\n            switch (codepoint = ds.Take()) {\n                case '^':\n                    anchorBegin_ = true;\n                    break;\n\n                case '$':\n                    anchorEnd_ = true;\n                    break;\n\n                case '|':\n                    while (!operatorStack.Empty() && *operatorStack.template Top<Operator>() < kAlternation)\n                        if (!Eval(operandStack, *operatorStack.template Pop<Operator>(1)))\n                            return;\n                    *operatorStack.template Push<Operator>() = kAlternation;\n                    *atomCountStack.template Top<unsigned>() = 0;\n                    break;\n\n                case '(':\n                    *operatorStack.template Push<Operator>() = kLeftParenthesis;\n                    *atomCountStack.template Push<unsigned>() = 0;\n                    break;\n\n                case ')':\n                    while (!operatorStack.Empty() && *operatorStack.template Top<Operator>() != kLeftParenthesis)\n                        if (!Eval(operandStack, *operatorStack.template Pop<Operator>(1)))\n                            return;\n                    if (operatorStack.Empty())\n                        return;\n                    operatorStack.template Pop<Operator>(1);\n                    atomCountStack.template Pop<unsigned>(1);\n                    ImplicitConcatenation(atomCountStack, operatorStack);\n                    break;\n\n                case '?':\n                    if (!Eval(operandStack, kZeroOrOne))\n                        return;\n                    break;\n\n                case '*':\n                    if (!Eval(operandStack, kZeroOrMore))\n                        return;\n                    break;\n\n                case '+':\n                    if (!Eval(operandStack, kOneOrMore))\n                        return;\n                    break;\n\n                case '{':\n                    {\n                        unsigned n, m;\n                        if (!ParseUnsigned(ds, &n))\n                            return;\n\n                        if (ds.Peek() == ',') {\n                            ds.Take();\n                            if (ds.Peek() == '}')\n                                m = kInfinityQuantifier;\n                            else if (!ParseUnsigned(ds, &m) || m < n)\n                                return;\n                        }\n                        else\n                            m = n;\n\n                        if (!EvalQuantifier(operandStack, n, m) || ds.Peek() != '}')\n                            return;\n                        ds.Take();\n                    }\n                    break;\n\n                case '.':\n                    PushOperand(operandStack, kAnyCharacterClass);\n                    ImplicitConcatenation(atomCountStack, operatorStack);\n                    break;\n\n                case '[':\n                    {\n                        SizeType range;\n                        if (!ParseRange(ds, &range))\n                            return;\n                        SizeType s = NewState(kRegexInvalidState, kRegexInvalidState, kRangeCharacterClass);\n                        GetState(s).rangeStart = range;\n                        *operandStack.template Push<Frag>() = Frag(s, s, s);\n                    }\n                    ImplicitConcatenation(atomCountStack, operatorStack);\n                    break;\n\n                case '\\\\': // Escape character\n                    if (!CharacterEscape(ds, &codepoint))\n                        return; // Unsupported escape character\n                    // fall through to default\n\n                default: // Pattern character\n                    PushOperand(operandStack, codepoint);\n                    ImplicitConcatenation(atomCountStack, operatorStack);\n            }\n        }\n\n        while (!operatorStack.Empty())\n            if (!Eval(operandStack, *operatorStack.template Pop<Operator>(1)))\n                return;\n\n        // Link the operand to matching state.\n        if (operandStack.GetSize() == sizeof(Frag)) {\n            Frag* e = operandStack.template Pop<Frag>(1);\n            Patch(e->out, NewState(kRegexInvalidState, kRegexInvalidState, 0));\n            root_ = e->start;\n\n#if RAPIDJSON_REGEX_VERBOSE\n            printf(\"root: %d\\n\", root_);\n            for (SizeType i = 0; i < stateCount_ ; i++) {\n                State& s = GetState(i);\n                printf(\"[%2d] out: %2d out1: %2d c: '%c'\\n\", i, s.out, s.out1, (char)s.codepoint);\n            }\n            printf(\"\\n\");\n#endif\n        }\n\n        // Preallocate buffer for SearchWithAnchoring()\n        RAPIDJSON_ASSERT(stateSet_ == 0);\n        if (stateCount_ > 0) {\n            stateSet_ = static_cast<unsigned*>(states_.GetAllocator().Malloc(GetStateSetSize()));\n            state0_.template Reserve<SizeType>(stateCount_);\n            state1_.template Reserve<SizeType>(stateCount_);\n        }\n    }\n\n    SizeType NewState(SizeType out, SizeType out1, unsigned codepoint) {\n        State* s = states_.template Push<State>();\n        s->out = out;\n        s->out1 = out1;\n        s->codepoint = codepoint;\n        s->rangeStart = kRegexInvalidRange;\n        return stateCount_++;\n    }\n\n    void PushOperand(Stack<Allocator>& operandStack, unsigned codepoint) {\n        SizeType s = NewState(kRegexInvalidState, kRegexInvalidState, codepoint);\n        *operandStack.template Push<Frag>() = Frag(s, s, s);\n    }\n\n    void ImplicitConcatenation(Stack<Allocator>& atomCountStack, Stack<Allocator>& operatorStack) {\n        if (*atomCountStack.template Top<unsigned>())\n            *operatorStack.template Push<Operator>() = kConcatenation;\n        (*atomCountStack.template Top<unsigned>())++;\n    }\n\n    SizeType Append(SizeType l1, SizeType l2) {\n        SizeType old = l1;\n        while (GetState(l1).out != kRegexInvalidState)\n            l1 = GetState(l1).out;\n        GetState(l1).out = l2;\n        return old;\n    }\n\n    void Patch(SizeType l, SizeType s) {\n        for (SizeType next; l != kRegexInvalidState; l = next) {\n            next = GetState(l).out;\n            GetState(l).out = s;\n        }\n    }\n\n    bool Eval(Stack<Allocator>& operandStack, Operator op) {\n        switch (op) {\n            case kConcatenation:\n                RAPIDJSON_ASSERT(operandStack.GetSize() >= sizeof(Frag) * 2);\n                {\n                    Frag e2 = *operandStack.template Pop<Frag>(1);\n                    Frag e1 = *operandStack.template Pop<Frag>(1);\n                    Patch(e1.out, e2.start);\n                    *operandStack.template Push<Frag>() = Frag(e1.start, e2.out, Min(e1.minIndex, e2.minIndex));\n                }\n                return true;\n\n            case kAlternation:\n                if (operandStack.GetSize() >= sizeof(Frag) * 2) {\n                    Frag e2 = *operandStack.template Pop<Frag>(1);\n                    Frag e1 = *operandStack.template Pop<Frag>(1);\n                    SizeType s = NewState(e1.start, e2.start, 0);\n                    *operandStack.template Push<Frag>() = Frag(s, Append(e1.out, e2.out), Min(e1.minIndex, e2.minIndex));\n                    return true;\n                }\n                return false;\n\n            case kZeroOrOne:\n                if (operandStack.GetSize() >= sizeof(Frag)) {\n                    Frag e = *operandStack.template Pop<Frag>(1);\n                    SizeType s = NewState(kRegexInvalidState, e.start, 0);\n                    *operandStack.template Push<Frag>() = Frag(s, Append(e.out, s), e.minIndex);\n                    return true;\n                }\n                return false;\n\n            case kZeroOrMore:\n                if (operandStack.GetSize() >= sizeof(Frag)) {\n                    Frag e = *operandStack.template Pop<Frag>(1);\n                    SizeType s = NewState(kRegexInvalidState, e.start, 0);\n                    Patch(e.out, s);\n                    *operandStack.template Push<Frag>() = Frag(s, s, e.minIndex);\n                    return true;\n                }\n                return false;\n\n            default: \n                RAPIDJSON_ASSERT(op == kOneOrMore);\n                if (operandStack.GetSize() >= sizeof(Frag)) {\n                    Frag e = *operandStack.template Pop<Frag>(1);\n                    SizeType s = NewState(kRegexInvalidState, e.start, 0);\n                    Patch(e.out, s);\n                    *operandStack.template Push<Frag>() = Frag(e.start, s, e.minIndex);\n                    return true;\n                }\n                return false;\n        }\n    }\n\n    bool EvalQuantifier(Stack<Allocator>& operandStack, unsigned n, unsigned m) {\n        RAPIDJSON_ASSERT(n <= m);\n        RAPIDJSON_ASSERT(operandStack.GetSize() >= sizeof(Frag));\n\n        if (n == 0) {\n            if (m == 0)                             // a{0} not support\n                return false;\n            else if (m == kInfinityQuantifier)\n                Eval(operandStack, kZeroOrMore);    // a{0,} -> a*\n            else {\n                Eval(operandStack, kZeroOrOne);         // a{0,5} -> a?\n                for (unsigned i = 0; i < m - 1; i++)\n                    CloneTopOperand(operandStack);      // a{0,5} -> a? a? a? a? a?\n                for (unsigned i = 0; i < m - 1; i++)\n                    Eval(operandStack, kConcatenation); // a{0,5} -> a?a?a?a?a?\n            }\n            return true;\n        }\n\n        for (unsigned i = 0; i < n - 1; i++)        // a{3} -> a a a\n            CloneTopOperand(operandStack);\n\n        if (m == kInfinityQuantifier)\n            Eval(operandStack, kOneOrMore);         // a{3,} -> a a a+\n        else if (m > n) {\n            CloneTopOperand(operandStack);          // a{3,5} -> a a a a\n            Eval(operandStack, kZeroOrOne);         // a{3,5} -> a a a a?\n            for (unsigned i = n; i < m - 1; i++)\n                CloneTopOperand(operandStack);      // a{3,5} -> a a a a? a?\n            for (unsigned i = n; i < m; i++)\n                Eval(operandStack, kConcatenation); // a{3,5} -> a a aa?a?\n        }\n\n        for (unsigned i = 0; i < n - 1; i++)\n            Eval(operandStack, kConcatenation);     // a{3} -> aaa, a{3,} -> aaa+, a{3.5} -> aaaa?a?\n\n        return true;\n    }\n\n    static SizeType Min(SizeType a, SizeType b) { return a < b ? a : b; }\n\n    void CloneTopOperand(Stack<Allocator>& operandStack) {\n        const Frag src = *operandStack.template Top<Frag>(); // Copy constructor to prevent invalidation\n        SizeType count = stateCount_ - src.minIndex; // Assumes top operand contains states in [src->minIndex, stateCount_)\n        State* s = states_.template Push<State>(count);\n        memcpy(s, &GetState(src.minIndex), count * sizeof(State));\n        for (SizeType j = 0; j < count; j++) {\n            if (s[j].out != kRegexInvalidState)\n                s[j].out += count;\n            if (s[j].out1 != kRegexInvalidState)\n                s[j].out1 += count;\n        }\n        *operandStack.template Push<Frag>() = Frag(src.start + count, src.out + count, src.minIndex + count);\n        stateCount_ += count;\n    }\n\n    template <typename InputStream>\n    bool ParseUnsigned(DecodedStream<InputStream>& ds, unsigned* u) {\n        unsigned r = 0;\n        if (ds.Peek() < '0' || ds.Peek() > '9')\n            return false;\n        while (ds.Peek() >= '0' && ds.Peek() <= '9') {\n            if (r >= 429496729 && ds.Peek() > '5') // 2^32 - 1 = 4294967295\n                return false; // overflow\n            r = r * 10 + (ds.Take() - '0');\n        }\n        *u = r;\n        return true;\n    }\n\n    template <typename InputStream>\n    bool ParseRange(DecodedStream<InputStream>& ds, SizeType* range) {\n        bool isBegin = true;\n        bool negate = false;\n        int step = 0;\n        SizeType start = kRegexInvalidRange;\n        SizeType current = kRegexInvalidRange;\n        unsigned codepoint;\n        while ((codepoint = ds.Take()) != 0) {\n            if (isBegin) {\n                isBegin = false;\n                if (codepoint == '^') {\n                    negate = true;\n                    continue;\n                }\n            }\n\n            switch (codepoint) {\n            case ']':\n                if (start == kRegexInvalidRange)\n                    return false;   // Error: nothing inside []\n                if (step == 2) { // Add trailing '-'\n                    SizeType r = NewRange('-');\n                    RAPIDJSON_ASSERT(current != kRegexInvalidRange);\n                    GetRange(current).next = r;\n                }\n                if (negate)\n                    GetRange(start).start |= kRangeNegationFlag;\n                *range = start;\n                return true;\n\n            case '\\\\':\n                if (ds.Peek() == 'b') {\n                    ds.Take();\n                    codepoint = 0x0008; // Escape backspace character\n                }\n                else if (!CharacterEscape(ds, &codepoint))\n                    return false;\n                // fall through to default\n\n            default:\n                switch (step) {\n                case 1:\n                    if (codepoint == '-') {\n                        step++;\n                        break;\n                    }\n                    // fall through to step 0 for other characters\n\n                case 0:\n                    {\n                        SizeType r = NewRange(codepoint);\n                        if (current != kRegexInvalidRange)\n                            GetRange(current).next = r;\n                        if (start == kRegexInvalidRange)\n                            start = r;\n                        current = r;\n                    }\n                    step = 1;\n                    break;\n\n                default:\n                    RAPIDJSON_ASSERT(step == 2);\n                    GetRange(current).end = codepoint;\n                    step = 0;\n                }\n            }\n        }\n        return false;\n    }\n    \n    SizeType NewRange(unsigned codepoint) {\n        Range* r = ranges_.template Push<Range>();\n        r->start = r->end = codepoint;\n        r->next = kRegexInvalidRange;\n        return rangeCount_++;\n    }\n\n    template <typename InputStream>\n    bool CharacterEscape(DecodedStream<InputStream>& ds, unsigned* escapedCodepoint) {\n        unsigned codepoint;\n        switch (codepoint = ds.Take()) {\n            case '^':\n            case '$':\n            case '|':\n            case '(':\n            case ')':\n            case '?':\n            case '*':\n            case '+':\n            case '.':\n            case '[':\n            case ']':\n            case '{':\n            case '}':\n            case '\\\\':\n                *escapedCodepoint = codepoint; return true;\n            case 'f': *escapedCodepoint = 0x000C; return true;\n            case 'n': *escapedCodepoint = 0x000A; return true;\n            case 'r': *escapedCodepoint = 0x000D; return true;\n            case 't': *escapedCodepoint = 0x0009; return true;\n            case 'v': *escapedCodepoint = 0x000B; return true;\n            default:\n                return false; // Unsupported escape character\n        }\n    }\n\n    template <typename InputStream>\n    bool SearchWithAnchoring(InputStream& is, bool anchorBegin, bool anchorEnd) const {\n        RAPIDJSON_ASSERT(IsValid());\n        DecodedStream<InputStream> ds(is);\n\n        state0_.Clear();\n        Stack<Allocator> *current = &state0_, *next = &state1_;\n        const size_t stateSetSize = GetStateSetSize();\n        std::memset(stateSet_, 0, stateSetSize);\n\n        bool matched = AddState(*current, root_);\n        unsigned codepoint;\n        while (!current->Empty() && (codepoint = ds.Take()) != 0) {\n            std::memset(stateSet_, 0, stateSetSize);\n            next->Clear();\n            matched = false;\n            for (const SizeType* s = current->template Bottom<SizeType>(); s != current->template End<SizeType>(); ++s) {\n                const State& sr = GetState(*s);\n                if (sr.codepoint == codepoint ||\n                    sr.codepoint == kAnyCharacterClass || \n                    (sr.codepoint == kRangeCharacterClass && MatchRange(sr.rangeStart, codepoint)))\n                {\n                    matched = AddState(*next, sr.out) || matched;\n                    if (!anchorEnd && matched)\n                        return true;\n                }\n                if (!anchorBegin)\n                    AddState(*next, root_);\n            }\n            internal::Swap(current, next);\n        }\n\n        return matched;\n    }\n\n    size_t GetStateSetSize() const {\n        return (stateCount_ + 31) / 32 * 4;\n    }\n\n    // Return whether the added states is a match state\n    bool AddState(Stack<Allocator>& l, SizeType index) const {\n        RAPIDJSON_ASSERT(index != kRegexInvalidState);\n\n        const State& s = GetState(index);\n        if (s.out1 != kRegexInvalidState) { // Split\n            bool matched = AddState(l, s.out);\n            return AddState(l, s.out1) || matched;\n        }\n        else if (!(stateSet_[index >> 5] & (1 << (index & 31)))) {\n            stateSet_[index >> 5] |= (1 << (index & 31));\n            *l.template PushUnsafe<SizeType>() = index;\n        }\n        return s.out == kRegexInvalidState; // by using PushUnsafe() above, we can ensure s is not validated due to reallocation.\n    }\n\n    bool MatchRange(SizeType rangeIndex, unsigned codepoint) const {\n        bool yes = (GetRange(rangeIndex).start & kRangeNegationFlag) == 0;\n        while (rangeIndex != kRegexInvalidRange) {\n            const Range& r = GetRange(rangeIndex);\n            if (codepoint >= (r.start & ~kRangeNegationFlag) && codepoint <= r.end)\n                return yes;\n            rangeIndex = r.next;\n        }\n        return !yes;\n    }\n\n    Stack<Allocator> states_;\n    Stack<Allocator> ranges_;\n    SizeType root_;\n    SizeType stateCount_;\n    SizeType rangeCount_;\n\n    static const unsigned kInfinityQuantifier = ~0u;\n\n    // For SearchWithAnchoring()\n    uint32_t* stateSet_;        // allocated by states_.GetAllocator()\n    mutable Stack<Allocator> state0_;\n    mutable Stack<Allocator> state1_;\n    bool anchorBegin_;\n    bool anchorEnd_;\n};\n\ntypedef GenericRegex<UTF8<> > Regex;\n\n} // namespace internal\nRAPIDJSON_NAMESPACE_END\n\n#ifdef __clang__\nRAPIDJSON_DIAG_POP\n#endif\n\n#ifdef _MSC_VER\nRAPIDJSON_DIAG_POP\n#endif\n\n#endif // RAPIDJSON_INTERNAL_REGEX_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/internal/stack.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_INTERNAL_STACK_H_\n#define RAPIDJSON_INTERNAL_STACK_H_\n\n#include \"../allocators.h\"\n#include \"swap.h\"\n\n#if defined(__clang__)\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(c++98-compat)\n#endif\n\nRAPIDJSON_NAMESPACE_BEGIN\nnamespace internal {\n\n///////////////////////////////////////////////////////////////////////////////\n// Stack\n\n//! A type-unsafe stack for storing different types of data.\n/*! \\tparam Allocator Allocator for allocating stack memory.\n*/\ntemplate <typename Allocator>\nclass Stack {\npublic:\n    // Optimization note: Do not allocate memory for stack_ in constructor.\n    // Do it lazily when first Push() -> Expand() -> Resize().\n    Stack(Allocator* allocator, size_t stackCapacity) : allocator_(allocator), ownAllocator_(0), stack_(0), stackTop_(0), stackEnd_(0), initialCapacity_(stackCapacity) {\n    }\n\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\n    Stack(Stack&& rhs)\n        : allocator_(rhs.allocator_),\n          ownAllocator_(rhs.ownAllocator_),\n          stack_(rhs.stack_),\n          stackTop_(rhs.stackTop_),\n          stackEnd_(rhs.stackEnd_),\n          initialCapacity_(rhs.initialCapacity_)\n    {\n        rhs.allocator_ = 0;\n        rhs.ownAllocator_ = 0;\n        rhs.stack_ = 0;\n        rhs.stackTop_ = 0;\n        rhs.stackEnd_ = 0;\n        rhs.initialCapacity_ = 0;\n    }\n#endif\n\n    ~Stack() {\n        Destroy();\n    }\n\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\n    Stack& operator=(Stack&& rhs) {\n        if (&rhs != this)\n        {\n            Destroy();\n\n            allocator_ = rhs.allocator_;\n            ownAllocator_ = rhs.ownAllocator_;\n            stack_ = rhs.stack_;\n            stackTop_ = rhs.stackTop_;\n            stackEnd_ = rhs.stackEnd_;\n            initialCapacity_ = rhs.initialCapacity_;\n\n            rhs.allocator_ = 0;\n            rhs.ownAllocator_ = 0;\n            rhs.stack_ = 0;\n            rhs.stackTop_ = 0;\n            rhs.stackEnd_ = 0;\n            rhs.initialCapacity_ = 0;\n        }\n        return *this;\n    }\n#endif\n\n    void Swap(Stack& rhs) RAPIDJSON_NOEXCEPT {\n        internal::Swap(allocator_, rhs.allocator_);\n        internal::Swap(ownAllocator_, rhs.ownAllocator_);\n        internal::Swap(stack_, rhs.stack_);\n        internal::Swap(stackTop_, rhs.stackTop_);\n        internal::Swap(stackEnd_, rhs.stackEnd_);\n        internal::Swap(initialCapacity_, rhs.initialCapacity_);\n    }\n\n    void Clear() { stackTop_ = stack_; }\n\n    void ShrinkToFit() { \n        if (Empty()) {\n            // If the stack is empty, completely deallocate the memory.\n            Allocator::Free(stack_);\n            stack_ = 0;\n            stackTop_ = 0;\n            stackEnd_ = 0;\n        }\n        else\n            Resize(GetSize());\n    }\n\n    // Optimization note: try to minimize the size of this function for force inline.\n    // Expansion is run very infrequently, so it is moved to another (probably non-inline) function.\n    template<typename T>\n    RAPIDJSON_FORCEINLINE void Reserve(size_t count = 1) {\n         // Expand the stack if needed\n        if (RAPIDJSON_UNLIKELY(stackTop_ + sizeof(T) * count > stackEnd_))\n            Expand<T>(count);\n    }\n\n    template<typename T>\n    RAPIDJSON_FORCEINLINE T* Push(size_t count = 1) {\n        Reserve<T>(count);\n        return PushUnsafe<T>(count);\n    }\n\n    template<typename T>\n    RAPIDJSON_FORCEINLINE T* PushUnsafe(size_t count = 1) {\n        RAPIDJSON_ASSERT(stackTop_ + sizeof(T) * count <= stackEnd_);\n        T* ret = reinterpret_cast<T*>(stackTop_);\n        stackTop_ += sizeof(T) * count;\n        return ret;\n    }\n\n    template<typename T>\n    T* Pop(size_t count) {\n        RAPIDJSON_ASSERT(GetSize() >= count * sizeof(T));\n        stackTop_ -= count * sizeof(T);\n        return reinterpret_cast<T*>(stackTop_);\n    }\n\n    template<typename T>\n    T* Top() { \n        RAPIDJSON_ASSERT(GetSize() >= sizeof(T));\n        return reinterpret_cast<T*>(stackTop_ - sizeof(T));\n    }\n\n    template<typename T>\n    const T* Top() const {\n        RAPIDJSON_ASSERT(GetSize() >= sizeof(T));\n        return reinterpret_cast<T*>(stackTop_ - sizeof(T));\n    }\n\n    template<typename T>\n    T* End() { return reinterpret_cast<T*>(stackTop_); }\n\n    template<typename T>\n    const T* End() const { return reinterpret_cast<T*>(stackTop_); }\n\n    template<typename T>\n    T* Bottom() { return reinterpret_cast<T*>(stack_); }\n\n    template<typename T>\n    const T* Bottom() const { return reinterpret_cast<T*>(stack_); }\n\n    bool HasAllocator() const {\n        return allocator_ != 0;\n    }\n\n    Allocator& GetAllocator() {\n        RAPIDJSON_ASSERT(allocator_);\n        return *allocator_;\n    }\n\n    bool Empty() const { return stackTop_ == stack_; }\n    size_t GetSize() const { return static_cast<size_t>(stackTop_ - stack_); }\n    size_t GetCapacity() const { return static_cast<size_t>(stackEnd_ - stack_); }\n\nprivate:\n    template<typename T>\n    void Expand(size_t count) {\n        // Only expand the capacity if the current stack exists. Otherwise just create a stack with initial capacity.\n        size_t newCapacity;\n        if (stack_ == 0) {\n            if (!allocator_)\n                ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator());\n            newCapacity = initialCapacity_;\n        } else {\n            newCapacity = GetCapacity();\n            newCapacity += (newCapacity + 1) / 2;\n        }\n        size_t newSize = GetSize() + sizeof(T) * count;\n        if (newCapacity < newSize)\n            newCapacity = newSize;\n\n        Resize(newCapacity);\n    }\n\n    void Resize(size_t newCapacity) {\n        const size_t size = GetSize();  // Backup the current size\n        stack_ = static_cast<char*>(allocator_->Realloc(stack_, GetCapacity(), newCapacity));\n        stackTop_ = stack_ + size;\n        stackEnd_ = stack_ + newCapacity;\n    }\n\n    void Destroy() {\n        Allocator::Free(stack_);\n        RAPIDJSON_DELETE(ownAllocator_); // Only delete if it is owned by the stack\n    }\n\n    // Prohibit copy constructor & assignment operator.\n    Stack(const Stack&);\n    Stack& operator=(const Stack&);\n\n    Allocator* allocator_;\n    Allocator* ownAllocator_;\n    char *stack_;\n    char *stackTop_;\n    char *stackEnd_;\n    size_t initialCapacity_;\n};\n\n} // namespace internal\nRAPIDJSON_NAMESPACE_END\n\n#if defined(__clang__)\nRAPIDJSON_DIAG_POP\n#endif\n\n#endif // RAPIDJSON_STACK_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/internal/strfunc.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_INTERNAL_STRFUNC_H_\n#define RAPIDJSON_INTERNAL_STRFUNC_H_\n\n#include \"../stream.h\"\n\nRAPIDJSON_NAMESPACE_BEGIN\nnamespace internal {\n\n//! Custom strlen() which works on different character types.\n/*! \\tparam Ch Character type (e.g. char, wchar_t, short)\n    \\param s Null-terminated input string.\n    \\return Number of characters in the string. \n    \\note This has the same semantics as strlen(), the return value is not number of Unicode codepoints.\n*/\ntemplate <typename Ch>\ninline SizeType StrLen(const Ch* s) {\n    const Ch* p = s;\n    while (*p) ++p;\n    return SizeType(p - s);\n}\n\n//! Returns number of code points in a encoded string.\ntemplate<typename Encoding>\nbool CountStringCodePoint(const typename Encoding::Ch* s, SizeType length, SizeType* outCount) {\n    GenericStringStream<Encoding> is(s);\n    const typename Encoding::Ch* end = s + length;\n    SizeType count = 0;\n    while (is.src_ < end) {\n        unsigned codepoint;\n        if (!Encoding::Decode(is, &codepoint))\n            return false;\n        count++;\n    }\n    *outCount = count;\n    return true;\n}\n\n} // namespace internal\nRAPIDJSON_NAMESPACE_END\n\n#endif // RAPIDJSON_INTERNAL_STRFUNC_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/internal/strtod.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_STRTOD_\n#define RAPIDJSON_STRTOD_\n\n#include \"ieee754.h\"\n#include \"biginteger.h\"\n#include \"diyfp.h\"\n#include \"pow10.h\"\n\nRAPIDJSON_NAMESPACE_BEGIN\nnamespace internal {\n\ninline double FastPath(double significand, int exp) {\n    if (exp < -308)\n        return 0.0;\n    else if (exp >= 0)\n        return significand * internal::Pow10(exp);\n    else\n        return significand / internal::Pow10(-exp);\n}\n\ninline double StrtodNormalPrecision(double d, int p) {\n    if (p < -308) {\n        // Prevent expSum < -308, making Pow10(p) = 0\n        d = FastPath(d, -308);\n        d = FastPath(d, p + 308);\n    }\n    else\n        d = FastPath(d, p);\n    return d;\n}\n\ntemplate <typename T>\ninline T Min3(T a, T b, T c) {\n    T m = a;\n    if (m > b) m = b;\n    if (m > c) m = c;\n    return m;\n}\n\ninline int CheckWithinHalfULP(double b, const BigInteger& d, int dExp) {\n    const Double db(b);\n    const uint64_t bInt = db.IntegerSignificand();\n    const int bExp = db.IntegerExponent();\n    const int hExp = bExp - 1;\n\n    int dS_Exp2 = 0, dS_Exp5 = 0, bS_Exp2 = 0, bS_Exp5 = 0, hS_Exp2 = 0, hS_Exp5 = 0;\n\n    // Adjust for decimal exponent\n    if (dExp >= 0) {\n        dS_Exp2 += dExp;\n        dS_Exp5 += dExp;\n    }\n    else {\n        bS_Exp2 -= dExp;\n        bS_Exp5 -= dExp;\n        hS_Exp2 -= dExp;\n        hS_Exp5 -= dExp;\n    }\n\n    // Adjust for binary exponent\n    if (bExp >= 0)\n        bS_Exp2 += bExp;\n    else {\n        dS_Exp2 -= bExp;\n        hS_Exp2 -= bExp;\n    }\n\n    // Adjust for half ulp exponent\n    if (hExp >= 0)\n        hS_Exp2 += hExp;\n    else {\n        dS_Exp2 -= hExp;\n        bS_Exp2 -= hExp;\n    }\n\n    // Remove common power of two factor from all three scaled values\n    int common_Exp2 = Min3(dS_Exp2, bS_Exp2, hS_Exp2);\n    dS_Exp2 -= common_Exp2;\n    bS_Exp2 -= common_Exp2;\n    hS_Exp2 -= common_Exp2;\n\n    BigInteger dS = d;\n    dS.MultiplyPow5(static_cast<unsigned>(dS_Exp5)) <<= static_cast<unsigned>(dS_Exp2);\n\n    BigInteger bS(bInt);\n    bS.MultiplyPow5(static_cast<unsigned>(bS_Exp5)) <<= static_cast<unsigned>(bS_Exp2);\n\n    BigInteger hS(1);\n    hS.MultiplyPow5(static_cast<unsigned>(hS_Exp5)) <<= static_cast<unsigned>(hS_Exp2);\n\n    BigInteger delta(0);\n    dS.Difference(bS, &delta);\n\n    return delta.Compare(hS);\n}\n\ninline bool StrtodFast(double d, int p, double* result) {\n    // Use fast path for string-to-double conversion if possible\n    // see http://www.exploringbinary.com/fast-path-decimal-to-floating-point-conversion/\n    if (p > 22  && p < 22 + 16) {\n        // Fast Path Cases In Disguise\n        d *= internal::Pow10(p - 22);\n        p = 22;\n    }\n\n    if (p >= -22 && p <= 22 && d <= 9007199254740991.0) { // 2^53 - 1\n        *result = FastPath(d, p);\n        return true;\n    }\n    else\n        return false;\n}\n\n// Compute an approximation and see if it is within 1/2 ULP\ninline bool StrtodDiyFp(const char* decimals, size_t length, size_t decimalPosition, int exp, double* result) {\n    uint64_t significand = 0;\n    size_t i = 0;   // 2^64 - 1 = 18446744073709551615, 1844674407370955161 = 0x1999999999999999    \n    for (; i < length; i++) {\n        if (significand  >  RAPIDJSON_UINT64_C2(0x19999999, 0x99999999) ||\n            (significand == RAPIDJSON_UINT64_C2(0x19999999, 0x99999999) && decimals[i] > '5'))\n            break;\n        significand = significand * 10u + static_cast<unsigned>(decimals[i] - '0');\n    }\n    \n    if (i < length && decimals[i] >= '5') // Rounding\n        significand++;\n\n    size_t remaining = length - i;\n    const unsigned kUlpShift = 3;\n    const unsigned kUlp = 1 << kUlpShift;\n    int64_t error = (remaining == 0) ? 0 : kUlp / 2;\n\n    DiyFp v(significand, 0);\n    v = v.Normalize();\n    error <<= -v.e;\n\n    const int dExp = static_cast<int>(decimalPosition) - static_cast<int>(i) + exp;\n\n    int actualExp;\n    DiyFp cachedPower = GetCachedPower10(dExp, &actualExp);\n    if (actualExp != dExp) {\n        static const DiyFp kPow10[] = {\n            DiyFp(RAPIDJSON_UINT64_C2(0xa0000000, 00000000), -60),  // 10^1\n            DiyFp(RAPIDJSON_UINT64_C2(0xc8000000, 00000000), -57),  // 10^2\n            DiyFp(RAPIDJSON_UINT64_C2(0xfa000000, 00000000), -54),  // 10^3\n            DiyFp(RAPIDJSON_UINT64_C2(0x9c400000, 00000000), -50),  // 10^4\n            DiyFp(RAPIDJSON_UINT64_C2(0xc3500000, 00000000), -47),  // 10^5\n            DiyFp(RAPIDJSON_UINT64_C2(0xf4240000, 00000000), -44),  // 10^6\n            DiyFp(RAPIDJSON_UINT64_C2(0x98968000, 00000000), -40)   // 10^7\n        };\n        int  adjustment = dExp - actualExp - 1;\n        RAPIDJSON_ASSERT(adjustment >= 0 && adjustment < 7);\n        v = v * kPow10[adjustment];\n        if (length + static_cast<unsigned>(adjustment)> 19u) // has more digits than decimal digits in 64-bit\n            error += kUlp / 2;\n    }\n\n    v = v * cachedPower;\n\n    error += kUlp + (error == 0 ? 0 : 1);\n\n    const int oldExp = v.e;\n    v = v.Normalize();\n    error <<= oldExp - v.e;\n\n    const unsigned effectiveSignificandSize = Double::EffectiveSignificandSize(64 + v.e);\n    unsigned precisionSize = 64 - effectiveSignificandSize;\n    if (precisionSize + kUlpShift >= 64) {\n        unsigned scaleExp = (precisionSize + kUlpShift) - 63;\n        v.f >>= scaleExp;\n        v.e += scaleExp; \n        error = (error >> scaleExp) + 1 + static_cast<int>(kUlp);\n        precisionSize -= scaleExp;\n    }\n\n    DiyFp rounded(v.f >> precisionSize, v.e + static_cast<int>(precisionSize));\n    const uint64_t precisionBits = (v.f & ((uint64_t(1) << precisionSize) - 1)) * kUlp;\n    const uint64_t halfWay = (uint64_t(1) << (precisionSize - 1)) * kUlp;\n    if (precisionBits >= halfWay + static_cast<unsigned>(error)) {\n        rounded.f++;\n        if (rounded.f & (DiyFp::kDpHiddenBit << 1)) { // rounding overflows mantissa (issue #340)\n            rounded.f >>= 1;\n            rounded.e++;\n        }\n    }\n\n    *result = rounded.ToDouble();\n\n    return halfWay - static_cast<unsigned>(error) >= precisionBits || precisionBits >= halfWay + static_cast<unsigned>(error);\n}\n\ninline double StrtodBigInteger(double approx, const char* decimals, size_t length, size_t decimalPosition, int exp) {\n    const BigInteger dInt(decimals, length);\n    const int dExp = static_cast<int>(decimalPosition) - static_cast<int>(length) + exp;\n    Double a(approx);\n    int cmp = CheckWithinHalfULP(a.Value(), dInt, dExp);\n    if (cmp < 0)\n        return a.Value();  // within half ULP\n    else if (cmp == 0) {\n        // Round towards even\n        if (a.Significand() & 1)\n            return a.NextPositiveDouble();\n        else\n            return a.Value();\n    }\n    else // adjustment\n        return a.NextPositiveDouble();\n}\n\ninline double StrtodFullPrecision(double d, int p, const char* decimals, size_t length, size_t decimalPosition, int exp) {\n    RAPIDJSON_ASSERT(d >= 0.0);\n    RAPIDJSON_ASSERT(length >= 1);\n\n    double result;\n    if (StrtodFast(d, p, &result))\n        return result;\n\n    // Trim leading zeros\n    while (*decimals == '0' && length > 1) {\n        length--;\n        decimals++;\n        decimalPosition--;\n    }\n\n    // Trim trailing zeros\n    while (decimals[length - 1] == '0' && length > 1) {\n        length--;\n        decimalPosition--;\n        exp++;\n    }\n\n    // Trim right-most digits\n    const int kMaxDecimalDigit = 780;\n    if (static_cast<int>(length) > kMaxDecimalDigit) {\n        int delta = (static_cast<int>(length) - kMaxDecimalDigit);\n        exp += delta;\n        decimalPosition -= static_cast<unsigned>(delta);\n        length = kMaxDecimalDigit;\n    }\n\n    // If too small, underflow to zero\n    if (int(length) + exp < -324)\n        return 0.0;\n\n    if (StrtodDiyFp(decimals, length, decimalPosition, exp, &result))\n        return result;\n\n    // Use approximation from StrtodDiyFp and make adjustment with BigInteger comparison\n    return StrtodBigInteger(result, decimals, length, decimalPosition, exp);\n}\n\n} // namespace internal\nRAPIDJSON_NAMESPACE_END\n\n#endif // RAPIDJSON_STRTOD_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/internal/swap.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n//\n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed\n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_INTERNAL_SWAP_H_\n#define RAPIDJSON_INTERNAL_SWAP_H_\n\n#include \"../rapidjson.h\"\n\n#if defined(__clang__)\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(c++98-compat)\n#endif\n\nRAPIDJSON_NAMESPACE_BEGIN\nnamespace internal {\n\n//! Custom swap() to avoid dependency on C++ <algorithm> header\n/*! \\tparam T Type of the arguments to swap, should be instantiated with primitive C++ types only.\n    \\note This has the same semantics as std::swap().\n*/\ntemplate <typename T>\ninline void Swap(T& a, T& b) RAPIDJSON_NOEXCEPT {\n    T tmp = a;\n        a = b;\n        b = tmp;\n}\n\n} // namespace internal\nRAPIDJSON_NAMESPACE_END\n\n#if defined(__clang__)\nRAPIDJSON_DIAG_POP\n#endif\n\n#endif // RAPIDJSON_INTERNAL_SWAP_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/istreamwrapper.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_ISTREAMWRAPPER_H_\n#define RAPIDJSON_ISTREAMWRAPPER_H_\n\n#include \"stream.h\"\n#include <iosfwd>\n\n#ifdef __clang__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(padded)\n#endif\n\n#ifdef _MSC_VER\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(4351) // new behavior: elements of array 'array' will be default initialized\n#endif\n\nRAPIDJSON_NAMESPACE_BEGIN\n\n//! Wrapper of \\c std::basic_istream into RapidJSON's Stream concept.\n/*!\n    The classes can be wrapped including but not limited to:\n\n    - \\c std::istringstream\n    - \\c std::stringstream\n    - \\c std::wistringstream\n    - \\c std::wstringstream\n    - \\c std::ifstream\n    - \\c std::fstream\n    - \\c std::wifstream\n    - \\c std::wfstream\n\n    \\tparam StreamType Class derived from \\c std::basic_istream.\n*/\n   \ntemplate <typename StreamType>\nclass BasicIStreamWrapper {\npublic:\n    typedef typename StreamType::char_type Ch;\n    BasicIStreamWrapper(StreamType& stream) : stream_(stream), count_(), peekBuffer_() {}\n\n    Ch Peek() const { \n        typename StreamType::int_type c = stream_.peek();\n        return RAPIDJSON_LIKELY(c != StreamType::traits_type::eof()) ? static_cast<Ch>(c) : '\\0';\n    }\n\n    Ch Take() { \n        typename StreamType::int_type c = stream_.get();\n        if (RAPIDJSON_LIKELY(c != StreamType::traits_type::eof())) {\n            count_++;\n            return static_cast<Ch>(c);\n        }\n        else\n            return '\\0';\n    }\n\n    // tellg() may return -1 when failed. So we count by ourself.\n    size_t Tell() const { return count_; }\n\n    Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }\n    void Put(Ch) { RAPIDJSON_ASSERT(false); }\n    void Flush() { RAPIDJSON_ASSERT(false); }\n    size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }\n\n    // For encoding detection only.\n    const Ch* Peek4() const {\n        RAPIDJSON_ASSERT(sizeof(Ch) == 1); // Only usable for byte stream.\n        int i;\n        bool hasError = false;\n        for (i = 0; i < 4; ++i) {\n            typename StreamType::int_type c = stream_.get();\n            if (c == StreamType::traits_type::eof()) {\n                hasError = true;\n                stream_.clear();\n                break;\n            }\n            peekBuffer_[i] = static_cast<Ch>(c);\n        }\n        for (--i; i >= 0; --i)\n            stream_.putback(peekBuffer_[i]);\n        return !hasError ? peekBuffer_ : 0;\n    }\n\nprivate:\n    BasicIStreamWrapper(const BasicIStreamWrapper&);\n    BasicIStreamWrapper& operator=(const BasicIStreamWrapper&);\n\n    StreamType& stream_;\n    size_t count_;  //!< Number of characters read. Note:\n    mutable Ch peekBuffer_[4];\n};\n\ntypedef BasicIStreamWrapper<std::istream> IStreamWrapper;\ntypedef BasicIStreamWrapper<std::wistream> WIStreamWrapper;\n\n#if defined(__clang__) || defined(_MSC_VER)\nRAPIDJSON_DIAG_POP\n#endif\n\nRAPIDJSON_NAMESPACE_END\n\n#endif // RAPIDJSON_ISTREAMWRAPPER_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/memorybuffer.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_MEMORYBUFFER_H_\n#define RAPIDJSON_MEMORYBUFFER_H_\n\n#include \"stream.h\"\n#include \"internal/stack.h\"\n\nRAPIDJSON_NAMESPACE_BEGIN\n\n//! Represents an in-memory output byte stream.\n/*!\n    This class is mainly for being wrapped by EncodedOutputStream or AutoUTFOutputStream.\n\n    It is similar to FileWriteBuffer but the destination is an in-memory buffer instead of a file.\n\n    Differences between MemoryBuffer and StringBuffer:\n    1. StringBuffer has Encoding but MemoryBuffer is only a byte buffer. \n    2. StringBuffer::GetString() returns a null-terminated string. MemoryBuffer::GetBuffer() returns a buffer without terminator.\n\n    \\tparam Allocator type for allocating memory buffer.\n    \\note implements Stream concept\n*/\ntemplate <typename Allocator = CrtAllocator>\nstruct GenericMemoryBuffer {\n    typedef char Ch; // byte\n\n    GenericMemoryBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {}\n\n    void Put(Ch c) { *stack_.template Push<Ch>() = c; }\n    void Flush() {}\n\n    void Clear() { stack_.Clear(); }\n    void ShrinkToFit() { stack_.ShrinkToFit(); }\n    Ch* Push(size_t count) { return stack_.template Push<Ch>(count); }\n    void Pop(size_t count) { stack_.template Pop<Ch>(count); }\n\n    const Ch* GetBuffer() const {\n        return stack_.template Bottom<Ch>();\n    }\n\n    size_t GetSize() const { return stack_.GetSize(); }\n\n    static const size_t kDefaultCapacity = 256;\n    mutable internal::Stack<Allocator> stack_;\n};\n\ntypedef GenericMemoryBuffer<> MemoryBuffer;\n\n//! Implement specialized version of PutN() with memset() for better performance.\ntemplate<>\ninline void PutN(MemoryBuffer& memoryBuffer, char c, size_t n) {\n    std::memset(memoryBuffer.stack_.Push<char>(n), c, n * sizeof(c));\n}\n\nRAPIDJSON_NAMESPACE_END\n\n#endif // RAPIDJSON_MEMORYBUFFER_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/memorystream.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_MEMORYSTREAM_H_\n#define RAPIDJSON_MEMORYSTREAM_H_\n\n#include \"stream.h\"\n\n#ifdef __clang__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(unreachable-code)\nRAPIDJSON_DIAG_OFF(missing-noreturn)\n#endif\n\nRAPIDJSON_NAMESPACE_BEGIN\n\n//! Represents an in-memory input byte stream.\n/*!\n    This class is mainly for being wrapped by EncodedInputStream or AutoUTFInputStream.\n\n    It is similar to FileReadBuffer but the source is an in-memory buffer instead of a file.\n\n    Differences between MemoryStream and StringStream:\n    1. StringStream has encoding but MemoryStream is a byte stream.\n    2. MemoryStream needs size of the source buffer and the buffer don't need to be null terminated. StringStream assume null-terminated string as source.\n    3. MemoryStream supports Peek4() for encoding detection. StringStream is specified with an encoding so it should not have Peek4().\n    \\note implements Stream concept\n*/\nstruct MemoryStream {\n    typedef char Ch; // byte\n\n    MemoryStream(const Ch *src, size_t size) : src_(src), begin_(src), end_(src + size), size_(size) {}\n\n    Ch Peek() const { return RAPIDJSON_UNLIKELY(src_ == end_) ? '\\0' : *src_; }\n    Ch Take() { return RAPIDJSON_UNLIKELY(src_ == end_) ? '\\0' : *src_++; }\n    size_t Tell() const { return static_cast<size_t>(src_ - begin_); }\n\n    Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }\n    void Put(Ch) { RAPIDJSON_ASSERT(false); }\n    void Flush() { RAPIDJSON_ASSERT(false); }\n    size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }\n\n    // For encoding detection only.\n    const Ch* Peek4() const {\n        return Tell() + 4 <= size_ ? src_ : 0;\n    }\n\n    const Ch* src_;     //!< Current read position.\n    const Ch* begin_;   //!< Original head of the string.\n    const Ch* end_;     //!< End of stream.\n    size_t size_;       //!< Size of the stream.\n};\n\nRAPIDJSON_NAMESPACE_END\n\n#ifdef __clang__\nRAPIDJSON_DIAG_POP\n#endif\n\n#endif // RAPIDJSON_MEMORYBUFFER_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/msinttypes/inttypes.h",
    "content": "// ISO C9x  compliant inttypes.h for Microsoft Visual Studio\n// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 \n// \n//  Copyright (c) 2006-2013 Alexander Chemeris\n// \n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are met:\n// \n//   1. Redistributions of source code must retain the above copyright notice,\n//      this list of conditions and the following disclaimer.\n// \n//   2. Redistributions in binary form must reproduce the above copyright\n//      notice, this list of conditions and the following disclaimer in the\n//      documentation and/or other materials provided with the distribution.\n// \n//   3. Neither the name of the product nor the names of its contributors may\n//      be used to endorse or promote products derived from this software\n//      without specific prior written permission.\n// \n// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED\n// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO\n// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\n// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \n// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\n// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n// \n///////////////////////////////////////////////////////////////////////////////\n\n// The above software in this distribution may have been modified by \n// THL A29 Limited (\"Tencent Modifications\"). \n// All Tencent Modifications are Copyright (C) 2015 THL A29 Limited.\n\n#ifndef _MSC_VER // [\n#error \"Use this header only with Microsoft Visual C++ compilers!\"\n#endif // _MSC_VER ]\n\n#ifndef _MSC_INTTYPES_H_ // [\n#define _MSC_INTTYPES_H_\n\n#if _MSC_VER > 1000\n#pragma once\n#endif\n\n#include \"stdint.h\"\n\n// miloyip: VC supports inttypes.h since VC2013\n#if _MSC_VER >= 1800\n#include <inttypes.h>\n#else\n\n// 7.8 Format conversion of integer types\n\ntypedef struct {\n   intmax_t quot;\n   intmax_t rem;\n} imaxdiv_t;\n\n// 7.8.1 Macros for format specifiers\n\n#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [   See footnote 185 at page 198\n\n// The fprintf macros for signed integers are:\n#define PRId8       \"d\"\n#define PRIi8       \"i\"\n#define PRIdLEAST8  \"d\"\n#define PRIiLEAST8  \"i\"\n#define PRIdFAST8   \"d\"\n#define PRIiFAST8   \"i\"\n\n#define PRId16       \"hd\"\n#define PRIi16       \"hi\"\n#define PRIdLEAST16  \"hd\"\n#define PRIiLEAST16  \"hi\"\n#define PRIdFAST16   \"hd\"\n#define PRIiFAST16   \"hi\"\n\n#define PRId32       \"I32d\"\n#define PRIi32       \"I32i\"\n#define PRIdLEAST32  \"I32d\"\n#define PRIiLEAST32  \"I32i\"\n#define PRIdFAST32   \"I32d\"\n#define PRIiFAST32   \"I32i\"\n\n#define PRId64       \"I64d\"\n#define PRIi64       \"I64i\"\n#define PRIdLEAST64  \"I64d\"\n#define PRIiLEAST64  \"I64i\"\n#define PRIdFAST64   \"I64d\"\n#define PRIiFAST64   \"I64i\"\n\n#define PRIdMAX     \"I64d\"\n#define PRIiMAX     \"I64i\"\n\n#define PRIdPTR     \"Id\"\n#define PRIiPTR     \"Ii\"\n\n// The fprintf macros for unsigned integers are:\n#define PRIo8       \"o\"\n#define PRIu8       \"u\"\n#define PRIx8       \"x\"\n#define PRIX8       \"X\"\n#define PRIoLEAST8  \"o\"\n#define PRIuLEAST8  \"u\"\n#define PRIxLEAST8  \"x\"\n#define PRIXLEAST8  \"X\"\n#define PRIoFAST8   \"o\"\n#define PRIuFAST8   \"u\"\n#define PRIxFAST8   \"x\"\n#define PRIXFAST8   \"X\"\n\n#define PRIo16       \"ho\"\n#define PRIu16       \"hu\"\n#define PRIx16       \"hx\"\n#define PRIX16       \"hX\"\n#define PRIoLEAST16  \"ho\"\n#define PRIuLEAST16  \"hu\"\n#define PRIxLEAST16  \"hx\"\n#define PRIXLEAST16  \"hX\"\n#define PRIoFAST16   \"ho\"\n#define PRIuFAST16   \"hu\"\n#define PRIxFAST16   \"hx\"\n#define PRIXFAST16   \"hX\"\n\n#define PRIo32       \"I32o\"\n#define PRIu32       \"I32u\"\n#define PRIx32       \"I32x\"\n#define PRIX32       \"I32X\"\n#define PRIoLEAST32  \"I32o\"\n#define PRIuLEAST32  \"I32u\"\n#define PRIxLEAST32  \"I32x\"\n#define PRIXLEAST32  \"I32X\"\n#define PRIoFAST32   \"I32o\"\n#define PRIuFAST32   \"I32u\"\n#define PRIxFAST32   \"I32x\"\n#define PRIXFAST32   \"I32X\"\n\n#define PRIo64       \"I64o\"\n#define PRIu64       \"I64u\"\n#define PRIx64       \"I64x\"\n#define PRIX64       \"I64X\"\n#define PRIoLEAST64  \"I64o\"\n#define PRIuLEAST64  \"I64u\"\n#define PRIxLEAST64  \"I64x\"\n#define PRIXLEAST64  \"I64X\"\n#define PRIoFAST64   \"I64o\"\n#define PRIuFAST64   \"I64u\"\n#define PRIxFAST64   \"I64x\"\n#define PRIXFAST64   \"I64X\"\n\n#define PRIoMAX     \"I64o\"\n#define PRIuMAX     \"I64u\"\n#define PRIxMAX     \"I64x\"\n#define PRIXMAX     \"I64X\"\n\n#define PRIoPTR     \"Io\"\n#define PRIuPTR     \"Iu\"\n#define PRIxPTR     \"Ix\"\n#define PRIXPTR     \"IX\"\n\n// The fscanf macros for signed integers are:\n#define SCNd8       \"d\"\n#define SCNi8       \"i\"\n#define SCNdLEAST8  \"d\"\n#define SCNiLEAST8  \"i\"\n#define SCNdFAST8   \"d\"\n#define SCNiFAST8   \"i\"\n\n#define SCNd16       \"hd\"\n#define SCNi16       \"hi\"\n#define SCNdLEAST16  \"hd\"\n#define SCNiLEAST16  \"hi\"\n#define SCNdFAST16   \"hd\"\n#define SCNiFAST16   \"hi\"\n\n#define SCNd32       \"ld\"\n#define SCNi32       \"li\"\n#define SCNdLEAST32  \"ld\"\n#define SCNiLEAST32  \"li\"\n#define SCNdFAST32   \"ld\"\n#define SCNiFAST32   \"li\"\n\n#define SCNd64       \"I64d\"\n#define SCNi64       \"I64i\"\n#define SCNdLEAST64  \"I64d\"\n#define SCNiLEAST64  \"I64i\"\n#define SCNdFAST64   \"I64d\"\n#define SCNiFAST64   \"I64i\"\n\n#define SCNdMAX     \"I64d\"\n#define SCNiMAX     \"I64i\"\n\n#ifdef _WIN64 // [\n#  define SCNdPTR     \"I64d\"\n#  define SCNiPTR     \"I64i\"\n#else  // _WIN64 ][\n#  define SCNdPTR     \"ld\"\n#  define SCNiPTR     \"li\"\n#endif  // _WIN64 ]\n\n// The fscanf macros for unsigned integers are:\n#define SCNo8       \"o\"\n#define SCNu8       \"u\"\n#define SCNx8       \"x\"\n#define SCNX8       \"X\"\n#define SCNoLEAST8  \"o\"\n#define SCNuLEAST8  \"u\"\n#define SCNxLEAST8  \"x\"\n#define SCNXLEAST8  \"X\"\n#define SCNoFAST8   \"o\"\n#define SCNuFAST8   \"u\"\n#define SCNxFAST8   \"x\"\n#define SCNXFAST8   \"X\"\n\n#define SCNo16       \"ho\"\n#define SCNu16       \"hu\"\n#define SCNx16       \"hx\"\n#define SCNX16       \"hX\"\n#define SCNoLEAST16  \"ho\"\n#define SCNuLEAST16  \"hu\"\n#define SCNxLEAST16  \"hx\"\n#define SCNXLEAST16  \"hX\"\n#define SCNoFAST16   \"ho\"\n#define SCNuFAST16   \"hu\"\n#define SCNxFAST16   \"hx\"\n#define SCNXFAST16   \"hX\"\n\n#define SCNo32       \"lo\"\n#define SCNu32       \"lu\"\n#define SCNx32       \"lx\"\n#define SCNX32       \"lX\"\n#define SCNoLEAST32  \"lo\"\n#define SCNuLEAST32  \"lu\"\n#define SCNxLEAST32  \"lx\"\n#define SCNXLEAST32  \"lX\"\n#define SCNoFAST32   \"lo\"\n#define SCNuFAST32   \"lu\"\n#define SCNxFAST32   \"lx\"\n#define SCNXFAST32   \"lX\"\n\n#define SCNo64       \"I64o\"\n#define SCNu64       \"I64u\"\n#define SCNx64       \"I64x\"\n#define SCNX64       \"I64X\"\n#define SCNoLEAST64  \"I64o\"\n#define SCNuLEAST64  \"I64u\"\n#define SCNxLEAST64  \"I64x\"\n#define SCNXLEAST64  \"I64X\"\n#define SCNoFAST64   \"I64o\"\n#define SCNuFAST64   \"I64u\"\n#define SCNxFAST64   \"I64x\"\n#define SCNXFAST64   \"I64X\"\n\n#define SCNoMAX     \"I64o\"\n#define SCNuMAX     \"I64u\"\n#define SCNxMAX     \"I64x\"\n#define SCNXMAX     \"I64X\"\n\n#ifdef _WIN64 // [\n#  define SCNoPTR     \"I64o\"\n#  define SCNuPTR     \"I64u\"\n#  define SCNxPTR     \"I64x\"\n#  define SCNXPTR     \"I64X\"\n#else  // _WIN64 ][\n#  define SCNoPTR     \"lo\"\n#  define SCNuPTR     \"lu\"\n#  define SCNxPTR     \"lx\"\n#  define SCNXPTR     \"lX\"\n#endif  // _WIN64 ]\n\n#endif // __STDC_FORMAT_MACROS ]\n\n// 7.8.2 Functions for greatest-width integer types\n\n// 7.8.2.1 The imaxabs function\n#define imaxabs _abs64\n\n// 7.8.2.2 The imaxdiv function\n\n// This is modified version of div() function from Microsoft's div.c found\n// in %MSVC.NET%\\crt\\src\\div.c\n#ifdef STATIC_IMAXDIV // [\nstatic\n#else // STATIC_IMAXDIV ][\n_inline\n#endif // STATIC_IMAXDIV ]\nimaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)\n{\n   imaxdiv_t result;\n\n   result.quot = numer / denom;\n   result.rem = numer % denom;\n\n   if (numer < 0 && result.rem > 0) {\n      // did division wrong; must fix up\n      ++result.quot;\n      result.rem -= denom;\n   }\n\n   return result;\n}\n\n// 7.8.2.3 The strtoimax and strtoumax functions\n#define strtoimax _strtoi64\n#define strtoumax _strtoui64\n\n// 7.8.2.4 The wcstoimax and wcstoumax functions\n#define wcstoimax _wcstoi64\n#define wcstoumax _wcstoui64\n\n#endif // _MSC_VER >= 1800\n\n#endif // _MSC_INTTYPES_H_ ]\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/msinttypes/stdint.h",
    "content": "// ISO C9x  compliant stdint.h for Microsoft Visual Studio\n// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 \n// \n//  Copyright (c) 2006-2013 Alexander Chemeris\n// \n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are met:\n// \n//   1. Redistributions of source code must retain the above copyright notice,\n//      this list of conditions and the following disclaimer.\n// \n//   2. Redistributions in binary form must reproduce the above copyright\n//      notice, this list of conditions and the following disclaimer in the\n//      documentation and/or other materials provided with the distribution.\n// \n//   3. Neither the name of the product nor the names of its contributors may\n//      be used to endorse or promote products derived from this software\n//      without specific prior written permission.\n// \n// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED\n// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO\n// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\n// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, \n// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\n// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF\n// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n// \n///////////////////////////////////////////////////////////////////////////////\n\n// The above software in this distribution may have been modified by \n// THL A29 Limited (\"Tencent Modifications\"). \n// All Tencent Modifications are Copyright (C) 2015 THL A29 Limited.\n\n#ifndef _MSC_VER // [\n#error \"Use this header only with Microsoft Visual C++ compilers!\"\n#endif // _MSC_VER ]\n\n#ifndef _MSC_STDINT_H_ // [\n#define _MSC_STDINT_H_\n\n#if _MSC_VER > 1000\n#pragma once\n#endif\n\n// miloyip: Originally Visual Studio 2010 uses its own stdint.h. However it generates warning with INT64_C(), so change to use this file for vs2010.\n#if _MSC_VER >= 1600 // [\n#include <stdint.h>\n\n#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [   See footnote 224 at page 260\n\n#undef INT8_C\n#undef INT16_C\n#undef INT32_C\n#undef INT64_C\n#undef UINT8_C\n#undef UINT16_C\n#undef UINT32_C\n#undef UINT64_C\n\n// 7.18.4.1 Macros for minimum-width integer constants\n\n#define INT8_C(val)  val##i8\n#define INT16_C(val) val##i16\n#define INT32_C(val) val##i32\n#define INT64_C(val) val##i64\n\n#define UINT8_C(val)  val##ui8\n#define UINT16_C(val) val##ui16\n#define UINT32_C(val) val##ui32\n#define UINT64_C(val) val##ui64\n\n// 7.18.4.2 Macros for greatest-width integer constants\n// These #ifndef's are needed to prevent collisions with <boost/cstdint.hpp>.\n// Check out Issue 9 for the details.\n#ifndef INTMAX_C //   [\n#  define INTMAX_C   INT64_C\n#endif // INTMAX_C    ]\n#ifndef UINTMAX_C //  [\n#  define UINTMAX_C  UINT64_C\n#endif // UINTMAX_C   ]\n\n#endif // __STDC_CONSTANT_MACROS ]\n\n#else // ] _MSC_VER >= 1700 [\n\n#include <limits.h>\n\n// For Visual Studio 6 in C++ mode and for many Visual Studio versions when\n// compiling for ARM we have to wrap <wchar.h> include with 'extern \"C++\" {}'\n// or compiler would give many errors like this:\n//   error C2733: second C linkage of overloaded function 'wmemchr' not allowed\n#if defined(__cplusplus) && !defined(_M_ARM)\nextern \"C\" {\n#endif\n#  include <wchar.h>\n#if defined(__cplusplus) && !defined(_M_ARM)\n}\n#endif\n\n// Define _W64 macros to mark types changing their size, like intptr_t.\n#ifndef _W64\n#  if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300\n#     define _W64 __w64\n#  else\n#     define _W64\n#  endif\n#endif\n\n\n// 7.18.1 Integer types\n\n// 7.18.1.1 Exact-width integer types\n\n// Visual Studio 6 and Embedded Visual C++ 4 doesn't\n// realize that, e.g. char has the same size as __int8\n// so we give up on __intX for them.\n#if (_MSC_VER < 1300)\n   typedef signed char       int8_t;\n   typedef signed short      int16_t;\n   typedef signed int        int32_t;\n   typedef unsigned char     uint8_t;\n   typedef unsigned short    uint16_t;\n   typedef unsigned int      uint32_t;\n#else\n   typedef signed __int8     int8_t;\n   typedef signed __int16    int16_t;\n   typedef signed __int32    int32_t;\n   typedef unsigned __int8   uint8_t;\n   typedef unsigned __int16  uint16_t;\n   typedef unsigned __int32  uint32_t;\n#endif\ntypedef signed __int64       int64_t;\ntypedef unsigned __int64     uint64_t;\n\n\n// 7.18.1.2 Minimum-width integer types\ntypedef int8_t    int_least8_t;\ntypedef int16_t   int_least16_t;\ntypedef int32_t   int_least32_t;\ntypedef int64_t   int_least64_t;\ntypedef uint8_t   uint_least8_t;\ntypedef uint16_t  uint_least16_t;\ntypedef uint32_t  uint_least32_t;\ntypedef uint64_t  uint_least64_t;\n\n// 7.18.1.3 Fastest minimum-width integer types\ntypedef int8_t    int_fast8_t;\ntypedef int16_t   int_fast16_t;\ntypedef int32_t   int_fast32_t;\ntypedef int64_t   int_fast64_t;\ntypedef uint8_t   uint_fast8_t;\ntypedef uint16_t  uint_fast16_t;\ntypedef uint32_t  uint_fast32_t;\ntypedef uint64_t  uint_fast64_t;\n\n// 7.18.1.4 Integer types capable of holding object pointers\n#ifdef _WIN64 // [\n   typedef signed __int64    intptr_t;\n   typedef unsigned __int64  uintptr_t;\n#else // _WIN64 ][\n   typedef _W64 signed int   intptr_t;\n   typedef _W64 unsigned int uintptr_t;\n#endif // _WIN64 ]\n\n// 7.18.1.5 Greatest-width integer types\ntypedef int64_t   intmax_t;\ntypedef uint64_t  uintmax_t;\n\n\n// 7.18.2 Limits of specified-width integer types\n\n#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [   See footnote 220 at page 257 and footnote 221 at page 259\n\n// 7.18.2.1 Limits of exact-width integer types\n#define INT8_MIN     ((int8_t)_I8_MIN)\n#define INT8_MAX     _I8_MAX\n#define INT16_MIN    ((int16_t)_I16_MIN)\n#define INT16_MAX    _I16_MAX\n#define INT32_MIN    ((int32_t)_I32_MIN)\n#define INT32_MAX    _I32_MAX\n#define INT64_MIN    ((int64_t)_I64_MIN)\n#define INT64_MAX    _I64_MAX\n#define UINT8_MAX    _UI8_MAX\n#define UINT16_MAX   _UI16_MAX\n#define UINT32_MAX   _UI32_MAX\n#define UINT64_MAX   _UI64_MAX\n\n// 7.18.2.2 Limits of minimum-width integer types\n#define INT_LEAST8_MIN    INT8_MIN\n#define INT_LEAST8_MAX    INT8_MAX\n#define INT_LEAST16_MIN   INT16_MIN\n#define INT_LEAST16_MAX   INT16_MAX\n#define INT_LEAST32_MIN   INT32_MIN\n#define INT_LEAST32_MAX   INT32_MAX\n#define INT_LEAST64_MIN   INT64_MIN\n#define INT_LEAST64_MAX   INT64_MAX\n#define UINT_LEAST8_MAX   UINT8_MAX\n#define UINT_LEAST16_MAX  UINT16_MAX\n#define UINT_LEAST32_MAX  UINT32_MAX\n#define UINT_LEAST64_MAX  UINT64_MAX\n\n// 7.18.2.3 Limits of fastest minimum-width integer types\n#define INT_FAST8_MIN    INT8_MIN\n#define INT_FAST8_MAX    INT8_MAX\n#define INT_FAST16_MIN   INT16_MIN\n#define INT_FAST16_MAX   INT16_MAX\n#define INT_FAST32_MIN   INT32_MIN\n#define INT_FAST32_MAX   INT32_MAX\n#define INT_FAST64_MIN   INT64_MIN\n#define INT_FAST64_MAX   INT64_MAX\n#define UINT_FAST8_MAX   UINT8_MAX\n#define UINT_FAST16_MAX  UINT16_MAX\n#define UINT_FAST32_MAX  UINT32_MAX\n#define UINT_FAST64_MAX  UINT64_MAX\n\n// 7.18.2.4 Limits of integer types capable of holding object pointers\n#ifdef _WIN64 // [\n#  define INTPTR_MIN   INT64_MIN\n#  define INTPTR_MAX   INT64_MAX\n#  define UINTPTR_MAX  UINT64_MAX\n#else // _WIN64 ][\n#  define INTPTR_MIN   INT32_MIN\n#  define INTPTR_MAX   INT32_MAX\n#  define UINTPTR_MAX  UINT32_MAX\n#endif // _WIN64 ]\n\n// 7.18.2.5 Limits of greatest-width integer types\n#define INTMAX_MIN   INT64_MIN\n#define INTMAX_MAX   INT64_MAX\n#define UINTMAX_MAX  UINT64_MAX\n\n// 7.18.3 Limits of other integer types\n\n#ifdef _WIN64 // [\n#  define PTRDIFF_MIN  _I64_MIN\n#  define PTRDIFF_MAX  _I64_MAX\n#else  // _WIN64 ][\n#  define PTRDIFF_MIN  _I32_MIN\n#  define PTRDIFF_MAX  _I32_MAX\n#endif  // _WIN64 ]\n\n#define SIG_ATOMIC_MIN  INT_MIN\n#define SIG_ATOMIC_MAX  INT_MAX\n\n#ifndef SIZE_MAX // [\n#  ifdef _WIN64 // [\n#     define SIZE_MAX  _UI64_MAX\n#  else // _WIN64 ][\n#     define SIZE_MAX  _UI32_MAX\n#  endif // _WIN64 ]\n#endif // SIZE_MAX ]\n\n// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h>\n#ifndef WCHAR_MIN // [\n#  define WCHAR_MIN  0\n#endif  // WCHAR_MIN ]\n#ifndef WCHAR_MAX // [\n#  define WCHAR_MAX  _UI16_MAX\n#endif  // WCHAR_MAX ]\n\n#define WINT_MIN  0\n#define WINT_MAX  _UI16_MAX\n\n#endif // __STDC_LIMIT_MACROS ]\n\n\n// 7.18.4 Limits of other integer types\n\n#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [   See footnote 224 at page 260\n\n// 7.18.4.1 Macros for minimum-width integer constants\n\n#define INT8_C(val)  val##i8\n#define INT16_C(val) val##i16\n#define INT32_C(val) val##i32\n#define INT64_C(val) val##i64\n\n#define UINT8_C(val)  val##ui8\n#define UINT16_C(val) val##ui16\n#define UINT32_C(val) val##ui32\n#define UINT64_C(val) val##ui64\n\n// 7.18.4.2 Macros for greatest-width integer constants\n// These #ifndef's are needed to prevent collisions with <boost/cstdint.hpp>.\n// Check out Issue 9 for the details.\n#ifndef INTMAX_C //   [\n#  define INTMAX_C   INT64_C\n#endif // INTMAX_C    ]\n#ifndef UINTMAX_C //  [\n#  define UINTMAX_C  UINT64_C\n#endif // UINTMAX_C   ]\n\n#endif // __STDC_CONSTANT_MACROS ]\n\n#endif // _MSC_VER >= 1600 ]\n\n#endif // _MSC_STDINT_H_ ]\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/ostreamwrapper.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_OSTREAMWRAPPER_H_\n#define RAPIDJSON_OSTREAMWRAPPER_H_\n\n#include \"stream.h\"\n#include <iosfwd>\n\n#ifdef __clang__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(padded)\n#endif\n\nRAPIDJSON_NAMESPACE_BEGIN\n\n//! Wrapper of \\c std::basic_ostream into RapidJSON's Stream concept.\n/*!\n    The classes can be wrapped including but not limited to:\n\n    - \\c std::ostringstream\n    - \\c std::stringstream\n    - \\c std::wpstringstream\n    - \\c std::wstringstream\n    - \\c std::ifstream\n    - \\c std::fstream\n    - \\c std::wofstream\n    - \\c std::wfstream\n\n    \\tparam StreamType Class derived from \\c std::basic_ostream.\n*/\n   \ntemplate <typename StreamType>\nclass BasicOStreamWrapper {\npublic:\n    typedef typename StreamType::char_type Ch;\n    BasicOStreamWrapper(StreamType& stream) : stream_(stream) {}\n\n    void Put(Ch c) {\n        stream_.put(c);\n    }\n\n    void Flush() {\n        stream_.flush();\n    }\n\n    // Not implemented\n    char Peek() const { RAPIDJSON_ASSERT(false); return 0; }\n    char Take() { RAPIDJSON_ASSERT(false); return 0; }\n    size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; }\n    char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }\n    size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; }\n\nprivate:\n    BasicOStreamWrapper(const BasicOStreamWrapper&);\n    BasicOStreamWrapper& operator=(const BasicOStreamWrapper&);\n\n    StreamType& stream_;\n};\n\ntypedef BasicOStreamWrapper<std::ostream> OStreamWrapper;\ntypedef BasicOStreamWrapper<std::wostream> WOStreamWrapper;\n\n#ifdef __clang__\nRAPIDJSON_DIAG_POP\n#endif\n\nRAPIDJSON_NAMESPACE_END\n\n#endif // RAPIDJSON_OSTREAMWRAPPER_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/pointer.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_POINTER_H_\n#define RAPIDJSON_POINTER_H_\n\n#include \"document.h\"\n#include \"internal/itoa.h\"\n\n#ifdef __clang__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(switch-enum)\n#endif\n\n#ifdef _MSC_VER\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated\n#endif\n\nRAPIDJSON_NAMESPACE_BEGIN\n\nstatic const SizeType kPointerInvalidIndex = ~SizeType(0);  //!< Represents an invalid index in GenericPointer::Token\n\n//! Error code of parsing.\n/*! \\ingroup RAPIDJSON_ERRORS\n    \\see GenericPointer::GenericPointer, GenericPointer::GetParseErrorCode\n*/\nenum PointerParseErrorCode {\n    kPointerParseErrorNone = 0,                     //!< The parse is successful\n\n    kPointerParseErrorTokenMustBeginWithSolidus,    //!< A token must begin with a '/'\n    kPointerParseErrorInvalidEscape,                //!< Invalid escape\n    kPointerParseErrorInvalidPercentEncoding,       //!< Invalid percent encoding in URI fragment\n    kPointerParseErrorCharacterMustPercentEncode    //!< A character must percent encoded in URI fragment\n};\n\n///////////////////////////////////////////////////////////////////////////////\n// GenericPointer\n\n//! Represents a JSON Pointer. Use Pointer for UTF8 encoding and default allocator.\n/*!\n    This class implements RFC 6901 \"JavaScript Object Notation (JSON) Pointer\" \n    (https://tools.ietf.org/html/rfc6901).\n\n    A JSON pointer is for identifying a specific value in a JSON document\n    (GenericDocument). It can simplify coding of DOM tree manipulation, because it\n    can access multiple-level depth of DOM tree with single API call.\n\n    After it parses a string representation (e.g. \"/foo/0\" or URI fragment \n    representation (e.g. \"#/foo/0\") into its internal representation (tokens),\n    it can be used to resolve a specific value in multiple documents, or sub-tree \n    of documents.\n\n    Contrary to GenericValue, Pointer can be copy constructed and copy assigned.\n    Apart from assignment, a Pointer cannot be modified after construction.\n\n    Although Pointer is very convenient, please aware that constructing Pointer\n    involves parsing and dynamic memory allocation. A special constructor with user-\n    supplied tokens eliminates these.\n\n    GenericPointer depends on GenericDocument and GenericValue.\n    \n    \\tparam ValueType The value type of the DOM tree. E.g. GenericValue<UTF8<> >\n    \\tparam Allocator The allocator type for allocating memory for internal representation.\n    \n    \\note GenericPointer uses same encoding of ValueType.\n    However, Allocator of GenericPointer is independent of Allocator of Value.\n*/\ntemplate <typename ValueType, typename Allocator = CrtAllocator>\nclass GenericPointer {\npublic:\n    typedef typename ValueType::EncodingType EncodingType;  //!< Encoding type from Value\n    typedef typename ValueType::Ch Ch;                      //!< Character type from Value\n\n    //! A token is the basic units of internal representation.\n    /*!\n        A JSON pointer string representation \"/foo/123\" is parsed to two tokens: \n        \"foo\" and 123. 123 will be represented in both numeric form and string form.\n        They are resolved according to the actual value type (object or array).\n\n        For token that are not numbers, or the numeric value is out of bound\n        (greater than limits of SizeType), they are only treated as string form\n        (i.e. the token's index will be equal to kPointerInvalidIndex).\n\n        This struct is public so that user can create a Pointer without parsing and \n        allocation, using a special constructor.\n    */\n    struct Token {\n        const Ch* name;             //!< Name of the token. It has null character at the end but it can contain null character.\n        SizeType length;            //!< Length of the name.\n        SizeType index;             //!< A valid array index, if it is not equal to kPointerInvalidIndex.\n    };\n\n    //!@name Constructors and destructor.\n    //@{\n\n    //! Default constructor.\n    GenericPointer(Allocator* allocator = 0) : allocator_(allocator), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {}\n\n    //! Constructor that parses a string or URI fragment representation.\n    /*!\n        \\param source A null-terminated, string or URI fragment representation of JSON pointer.\n        \\param allocator User supplied allocator for this pointer. If no allocator is provided, it creates a self-owned one.\n    */\n    explicit GenericPointer(const Ch* source, Allocator* allocator = 0) : allocator_(allocator), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {\n        Parse(source, internal::StrLen(source));\n    }\n\n#if RAPIDJSON_HAS_STDSTRING\n    //! Constructor that parses a string or URI fragment representation.\n    /*!\n        \\param source A string or URI fragment representation of JSON pointer.\n        \\param allocator User supplied allocator for this pointer. If no allocator is provided, it creates a self-owned one.\n        \\note Requires the definition of the preprocessor symbol \\ref RAPIDJSON_HAS_STDSTRING.\n    */\n    explicit GenericPointer(const std::basic_string<Ch>& source, Allocator* allocator = 0) : allocator_(allocator), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {\n        Parse(source.c_str(), source.size());\n    }\n#endif\n\n    //! Constructor that parses a string or URI fragment representation, with length of the source string.\n    /*!\n        \\param source A string or URI fragment representation of JSON pointer.\n        \\param length Length of source.\n        \\param allocator User supplied allocator for this pointer. If no allocator is provided, it creates a self-owned one.\n        \\note Slightly faster than the overload without length.\n    */\n    GenericPointer(const Ch* source, size_t length, Allocator* allocator = 0) : allocator_(allocator), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {\n        Parse(source, length);\n    }\n\n    //! Constructor with user-supplied tokens.\n    /*!\n        This constructor let user supplies const array of tokens.\n        This prevents the parsing process and eliminates allocation.\n        This is preferred for memory constrained environments.\n\n        \\param tokens An constant array of tokens representing the JSON pointer.\n        \\param tokenCount Number of tokens.\n\n        \\b Example\n        \\code\n        #define NAME(s) { s, sizeof(s) / sizeof(s[0]) - 1, kPointerInvalidIndex }\n        #define INDEX(i) { #i, sizeof(#i) - 1, i }\n\n        static const Pointer::Token kTokens[] = { NAME(\"foo\"), INDEX(123) };\n        static const Pointer p(kTokens, sizeof(kTokens) / sizeof(kTokens[0]));\n        // Equivalent to static const Pointer p(\"/foo/123\");\n\n        #undef NAME\n        #undef INDEX\n        \\endcode\n    */\n    GenericPointer(const Token* tokens, size_t tokenCount) : allocator_(), ownAllocator_(), nameBuffer_(), tokens_(const_cast<Token*>(tokens)), tokenCount_(tokenCount), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {}\n\n    //! Copy constructor.\n    GenericPointer(const GenericPointer& rhs, Allocator* allocator = 0) : allocator_(allocator), ownAllocator_(), nameBuffer_(), tokens_(), tokenCount_(), parseErrorOffset_(), parseErrorCode_(kPointerParseErrorNone) {\n        *this = rhs;\n    }\n\n    //! Destructor.\n    ~GenericPointer() {\n        if (nameBuffer_)    // If user-supplied tokens constructor is used, nameBuffer_ is nullptr and tokens_ are not deallocated.\n            Allocator::Free(tokens_);\n        RAPIDJSON_DELETE(ownAllocator_);\n    }\n\n    //! Assignment operator.\n    GenericPointer& operator=(const GenericPointer& rhs) {\n        if (this != &rhs) {\n            // Do not delete ownAllcator\n            if (nameBuffer_)\n                Allocator::Free(tokens_);\n\n            tokenCount_ = rhs.tokenCount_;\n            parseErrorOffset_ = rhs.parseErrorOffset_;\n            parseErrorCode_ = rhs.parseErrorCode_;\n\n            if (rhs.nameBuffer_)\n                CopyFromRaw(rhs); // Normally parsed tokens.\n            else {\n                tokens_ = rhs.tokens_; // User supplied const tokens.\n                nameBuffer_ = 0;\n            }\n        }\n        return *this;\n    }\n\n    //@}\n\n    //!@name Append token\n    //@{\n\n    //! Append a token and return a new Pointer\n    /*!\n        \\param token Token to be appended.\n        \\param allocator Allocator for the newly return Pointer.\n        \\return A new Pointer with appended token.\n    */\n    GenericPointer Append(const Token& token, Allocator* allocator = 0) const {\n        GenericPointer r;\n        r.allocator_ = allocator;\n        Ch *p = r.CopyFromRaw(*this, 1, token.length + 1);\n        std::memcpy(p, token.name, (token.length + 1) * sizeof(Ch));\n        r.tokens_[tokenCount_].name = p;\n        r.tokens_[tokenCount_].length = token.length;\n        r.tokens_[tokenCount_].index = token.index;\n        return r;\n    }\n\n    //! Append a name token with length, and return a new Pointer\n    /*!\n        \\param name Name to be appended.\n        \\param length Length of name.\n        \\param allocator Allocator for the newly return Pointer.\n        \\return A new Pointer with appended token.\n    */\n    GenericPointer Append(const Ch* name, SizeType length, Allocator* allocator = 0) const {\n        Token token = { name, length, kPointerInvalidIndex };\n        return Append(token, allocator);\n    }\n\n    //! Append a name token without length, and return a new Pointer\n    /*!\n        \\param name Name (const Ch*) to be appended.\n        \\param allocator Allocator for the newly return Pointer.\n        \\return A new Pointer with appended token.\n    */\n    template <typename T>\n    RAPIDJSON_DISABLEIF_RETURN((internal::NotExpr<internal::IsSame<typename internal::RemoveConst<T>::Type, Ch> >), (GenericPointer))\n    Append(T* name, Allocator* allocator = 0) const {\n        return Append(name, StrLen(name), allocator);\n    }\n\n#if RAPIDJSON_HAS_STDSTRING\n    //! Append a name token, and return a new Pointer\n    /*!\n        \\param name Name to be appended.\n        \\param allocator Allocator for the newly return Pointer.\n        \\return A new Pointer with appended token.\n    */\n    GenericPointer Append(const std::basic_string<Ch>& name, Allocator* allocator = 0) const {\n        return Append(name.c_str(), static_cast<SizeType>(name.size()), allocator);\n    }\n#endif\n\n    //! Append a index token, and return a new Pointer\n    /*!\n        \\param index Index to be appended.\n        \\param allocator Allocator for the newly return Pointer.\n        \\return A new Pointer with appended token.\n    */\n    GenericPointer Append(SizeType index, Allocator* allocator = 0) const {\n        char buffer[21];\n        char* end = sizeof(SizeType) == 4 ? internal::u32toa(index, buffer) : internal::u64toa(index, buffer);\n        SizeType length = static_cast<SizeType>(end - buffer);\n        buffer[length] = '\\0';\n\n        if (sizeof(Ch) == 1) {\n            Token token = { reinterpret_cast<Ch*>(buffer), length, index };\n            return Append(token, allocator);\n        }\n        else {\n            Ch name[21];\n            for (size_t i = 0; i <= length; i++)\n                name[i] = buffer[i];\n            Token token = { name, length, index };\n            return Append(token, allocator);\n        }\n    }\n\n    //! Append a token by value, and return a new Pointer\n    /*!\n        \\param token token to be appended.\n        \\param allocator Allocator for the newly return Pointer.\n        \\return A new Pointer with appended token.\n    */\n    GenericPointer Append(const ValueType& token, Allocator* allocator = 0) const {\n        if (token.IsString())\n            return Append(token.GetString(), token.GetStringLength(), allocator);\n        else {\n            RAPIDJSON_ASSERT(token.IsUint64());\n            RAPIDJSON_ASSERT(token.GetUint64() <= SizeType(~0));\n            return Append(static_cast<SizeType>(token.GetUint64()), allocator);\n        }\n    }\n\n    //!@name Handling Parse Error\n    //@{\n\n    //! Check whether this is a valid pointer.\n    bool IsValid() const { return parseErrorCode_ == kPointerParseErrorNone; }\n\n    //! Get the parsing error offset in code unit.\n    size_t GetParseErrorOffset() const { return parseErrorOffset_; }\n\n    //! Get the parsing error code.\n    PointerParseErrorCode GetParseErrorCode() const { return parseErrorCode_; }\n\n    //@}\n\n    //! Get the allocator of this pointer.\n    Allocator& GetAllocator() { return *allocator_; }\n\n    //!@name Tokens\n    //@{\n\n    //! Get the token array (const version only).\n    const Token* GetTokens() const { return tokens_; }\n\n    //! Get the number of tokens.\n    size_t GetTokenCount() const { return tokenCount_; }\n\n    //@}\n\n    //!@name Equality/inequality operators\n    //@{\n\n    //! Equality operator.\n    /*!\n        \\note When any pointers are invalid, always returns false.\n    */\n    bool operator==(const GenericPointer& rhs) const {\n        if (!IsValid() || !rhs.IsValid() || tokenCount_ != rhs.tokenCount_)\n            return false;\n\n        for (size_t i = 0; i < tokenCount_; i++) {\n            if (tokens_[i].index != rhs.tokens_[i].index ||\n                tokens_[i].length != rhs.tokens_[i].length || \n                (tokens_[i].length != 0 && std::memcmp(tokens_[i].name, rhs.tokens_[i].name, sizeof(Ch)* tokens_[i].length) != 0))\n            {\n                return false;\n            }\n        }\n\n        return true;\n    }\n\n    //! Inequality operator.\n    /*!\n        \\note When any pointers are invalid, always returns true.\n    */\n    bool operator!=(const GenericPointer& rhs) const { return !(*this == rhs); }\n\n    //@}\n\n    //!@name Stringify\n    //@{\n\n    //! Stringify the pointer into string representation.\n    /*!\n        \\tparam OutputStream Type of output stream.\n        \\param os The output stream.\n    */\n    template<typename OutputStream>\n    bool Stringify(OutputStream& os) const {\n        return Stringify<false, OutputStream>(os);\n    }\n\n    //! Stringify the pointer into URI fragment representation.\n    /*!\n        \\tparam OutputStream Type of output stream.\n        \\param os The output stream.\n    */\n    template<typename OutputStream>\n    bool StringifyUriFragment(OutputStream& os) const {\n        return Stringify<true, OutputStream>(os);\n    }\n\n    //@}\n\n    //!@name Create value\n    //@{\n\n    //! Create a value in a subtree.\n    /*!\n        If the value is not exist, it creates all parent values and a JSON Null value.\n        So it always succeed and return the newly created or existing value.\n\n        Remind that it may change types of parents according to tokens, so it \n        potentially removes previously stored values. For example, if a document \n        was an array, and \"/foo\" is used to create a value, then the document \n        will be changed to an object, and all existing array elements are lost.\n\n        \\param root Root value of a DOM subtree to be resolved. It can be any value other than document root.\n        \\param allocator Allocator for creating the values if the specified value or its parents are not exist.\n        \\param alreadyExist If non-null, it stores whether the resolved value is already exist.\n        \\return The resolved newly created (a JSON Null value), or already exists value.\n    */\n    ValueType& Create(ValueType& root, typename ValueType::AllocatorType& allocator, bool* alreadyExist = 0) const {\n        RAPIDJSON_ASSERT(IsValid());\n        ValueType* v = &root;\n        bool exist = true;\n        for (const Token *t = tokens_; t != tokens_ + tokenCount_; ++t) {\n            if (v->IsArray() && t->name[0] == '-' && t->length == 1) {\n                v->PushBack(ValueType().Move(), allocator);\n                v = &((*v)[v->Size() - 1]);\n                exist = false;\n            }\n            else {\n                if (t->index == kPointerInvalidIndex) { // must be object name\n                    if (!v->IsObject())\n                        v->SetObject(); // Change to Object\n                }\n                else { // object name or array index\n                    if (!v->IsArray() && !v->IsObject())\n                        v->SetArray(); // Change to Array\n                }\n\n                if (v->IsArray()) {\n                    if (t->index >= v->Size()) {\n                        v->Reserve(t->index + 1, allocator);\n                        while (t->index >= v->Size())\n                            v->PushBack(ValueType().Move(), allocator);\n                        exist = false;\n                    }\n                    v = &((*v)[t->index]);\n                }\n                else {\n                    typename ValueType::MemberIterator m = v->FindMember(GenericStringRef<Ch>(t->name, t->length));\n                    if (m == v->MemberEnd()) {\n                        v->AddMember(ValueType(t->name, t->length, allocator).Move(), ValueType().Move(), allocator);\n                        v = &(--v->MemberEnd())->value; // Assumes AddMember() appends at the end\n                        exist = false;\n                    }\n                    else\n                        v = &m->value;\n                }\n            }\n        }\n\n        if (alreadyExist)\n            *alreadyExist = exist;\n\n        return *v;\n    }\n\n    //! Creates a value in a document.\n    /*!\n        \\param document A document to be resolved.\n        \\param alreadyExist If non-null, it stores whether the resolved value is already exist.\n        \\return The resolved newly created, or already exists value.\n    */\n    template <typename stackAllocator>\n    ValueType& Create(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, bool* alreadyExist = 0) const {\n        return Create(document, document.GetAllocator(), alreadyExist);\n    }\n\n    //@}\n\n    //!@name Query value\n    //@{\n\n    //! Query a value in a subtree.\n    /*!\n        \\param root Root value of a DOM sub-tree to be resolved. It can be any value other than document root.\n        \\param unresolvedTokenIndex If the pointer cannot resolve a token in the pointer, this parameter can obtain the index of unresolved token.\n        \\return Pointer to the value if it can be resolved. Otherwise null.\n\n        \\note\n        There are only 3 situations when a value cannot be resolved:\n        1. A value in the path is not an array nor object.\n        2. An object value does not contain the token.\n        3. A token is out of range of an array value.\n\n        Use unresolvedTokenIndex to retrieve the token index.\n    */\n    ValueType* Get(ValueType& root, size_t* unresolvedTokenIndex = 0) const {\n        RAPIDJSON_ASSERT(IsValid());\n        ValueType* v = &root;\n        for (const Token *t = tokens_; t != tokens_ + tokenCount_; ++t) {\n            switch (v->GetType()) {\n            case kObjectType:\n                {\n                    typename ValueType::MemberIterator m = v->FindMember(GenericStringRef<Ch>(t->name, t->length));\n                    if (m == v->MemberEnd())\n                        break;\n                    v = &m->value;\n                }\n                continue;\n            case kArrayType:\n                if (t->index == kPointerInvalidIndex || t->index >= v->Size())\n                    break;\n                v = &((*v)[t->index]);\n                continue;\n            default:\n                break;\n            }\n\n            // Error: unresolved token\n            if (unresolvedTokenIndex)\n                *unresolvedTokenIndex = static_cast<size_t>(t - tokens_);\n            return 0;\n        }\n        return v;\n    }\n\n    //! Query a const value in a const subtree.\n    /*!\n        \\param root Root value of a DOM sub-tree to be resolved. It can be any value other than document root.\n        \\return Pointer to the value if it can be resolved. Otherwise null.\n    */\n    const ValueType* Get(const ValueType& root, size_t* unresolvedTokenIndex = 0) const { \n        return Get(const_cast<ValueType&>(root), unresolvedTokenIndex);\n    }\n\n    //@}\n\n    //!@name Query a value with default\n    //@{\n\n    //! Query a value in a subtree with default value.\n    /*!\n        Similar to Get(), but if the specified value do not exists, it creates all parents and clone the default value.\n        So that this function always succeed.\n\n        \\param root Root value of a DOM sub-tree to be resolved. It can be any value other than document root.\n        \\param defaultValue Default value to be cloned if the value was not exists.\n        \\param allocator Allocator for creating the values if the specified value or its parents are not exist.\n        \\see Create()\n    */\n    ValueType& GetWithDefault(ValueType& root, const ValueType& defaultValue, typename ValueType::AllocatorType& allocator) const {\n        bool alreadyExist;\n        Value& v = Create(root, allocator, &alreadyExist);\n        return alreadyExist ? v : v.CopyFrom(defaultValue, allocator);\n    }\n\n    //! Query a value in a subtree with default null-terminated string.\n    ValueType& GetWithDefault(ValueType& root, const Ch* defaultValue, typename ValueType::AllocatorType& allocator) const {\n        bool alreadyExist;\n        Value& v = Create(root, allocator, &alreadyExist);\n        return alreadyExist ? v : v.SetString(defaultValue, allocator);\n    }\n\n#if RAPIDJSON_HAS_STDSTRING\n    //! Query a value in a subtree with default std::basic_string.\n    ValueType& GetWithDefault(ValueType& root, const std::basic_string<Ch>& defaultValue, typename ValueType::AllocatorType& allocator) const {\n        bool alreadyExist;\n        Value& v = Create(root, allocator, &alreadyExist);\n        return alreadyExist ? v : v.SetString(defaultValue, allocator);\n    }\n#endif\n\n    //! Query a value in a subtree with default primitive value.\n    /*!\n        \\tparam T Either \\ref Type, \\c int, \\c unsigned, \\c int64_t, \\c uint64_t, \\c bool\n    */\n    template <typename T>\n    RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T> >), (ValueType&))\n    GetWithDefault(ValueType& root, T defaultValue, typename ValueType::AllocatorType& allocator) const {\n        return GetWithDefault(root, ValueType(defaultValue).Move(), allocator);\n    }\n\n    //! Query a value in a document with default value.\n    template <typename stackAllocator>\n    ValueType& GetWithDefault(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, const ValueType& defaultValue) const {\n        return GetWithDefault(document, defaultValue, document.GetAllocator());\n    }\n\n    //! Query a value in a document with default null-terminated string.\n    template <typename stackAllocator>\n    ValueType& GetWithDefault(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, const Ch* defaultValue) const {\n        return GetWithDefault(document, defaultValue, document.GetAllocator());\n    }\n    \n#if RAPIDJSON_HAS_STDSTRING\n    //! Query a value in a document with default std::basic_string.\n    template <typename stackAllocator>\n    ValueType& GetWithDefault(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, const std::basic_string<Ch>& defaultValue) const {\n        return GetWithDefault(document, defaultValue, document.GetAllocator());\n    }\n#endif\n\n    //! Query a value in a document with default primitive value.\n    /*!\n        \\tparam T Either \\ref Type, \\c int, \\c unsigned, \\c int64_t, \\c uint64_t, \\c bool\n    */\n    template <typename T, typename stackAllocator>\n    RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T> >), (ValueType&))\n    GetWithDefault(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, T defaultValue) const {\n        return GetWithDefault(document, defaultValue, document.GetAllocator());\n    }\n\n    //@}\n\n    //!@name Set a value\n    //@{\n\n    //! Set a value in a subtree, with move semantics.\n    /*!\n        It creates all parents if they are not exist or types are different to the tokens.\n        So this function always succeeds but potentially remove existing values.\n\n        \\param root Root value of a DOM sub-tree to be resolved. It can be any value other than document root.\n        \\param value Value to be set.\n        \\param allocator Allocator for creating the values if the specified value or its parents are not exist.\n        \\see Create()\n    */\n    ValueType& Set(ValueType& root, ValueType& value, typename ValueType::AllocatorType& allocator) const {\n        return Create(root, allocator) = value;\n    }\n\n    //! Set a value in a subtree, with copy semantics.\n    ValueType& Set(ValueType& root, const ValueType& value, typename ValueType::AllocatorType& allocator) const {\n        return Create(root, allocator).CopyFrom(value, allocator);\n    }\n\n    //! Set a null-terminated string in a subtree.\n    ValueType& Set(ValueType& root, const Ch* value, typename ValueType::AllocatorType& allocator) const {\n        return Create(root, allocator) = ValueType(value, allocator).Move();\n    }\n\n#if RAPIDJSON_HAS_STDSTRING\n    //! Set a std::basic_string in a subtree.\n    ValueType& Set(ValueType& root, const std::basic_string<Ch>& value, typename ValueType::AllocatorType& allocator) const {\n        return Create(root, allocator) = ValueType(value, allocator).Move();\n    }\n#endif\n\n    //! Set a primitive value in a subtree.\n    /*!\n        \\tparam T Either \\ref Type, \\c int, \\c unsigned, \\c int64_t, \\c uint64_t, \\c bool\n    */\n    template <typename T>\n    RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T> >), (ValueType&))\n    Set(ValueType& root, T value, typename ValueType::AllocatorType& allocator) const {\n        return Create(root, allocator) = ValueType(value).Move();\n    }\n\n    //! Set a value in a document, with move semantics.\n    template <typename stackAllocator>\n    ValueType& Set(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, ValueType& value) const {\n        return Create(document) = value;\n    }\n\n    //! Set a value in a document, with copy semantics.\n    template <typename stackAllocator>\n    ValueType& Set(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, const ValueType& value) const {\n        return Create(document).CopyFrom(value, document.GetAllocator());\n    }\n\n    //! Set a null-terminated string in a document.\n    template <typename stackAllocator>\n    ValueType& Set(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, const Ch* value) const {\n        return Create(document) = ValueType(value, document.GetAllocator()).Move();\n    }\n\n#if RAPIDJSON_HAS_STDSTRING\n    //! Sets a std::basic_string in a document.\n    template <typename stackAllocator>\n    ValueType& Set(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, const std::basic_string<Ch>& value) const {\n        return Create(document) = ValueType(value, document.GetAllocator()).Move();\n    }\n#endif\n\n    //! Set a primitive value in a document.\n    /*!\n    \\tparam T Either \\ref Type, \\c int, \\c unsigned, \\c int64_t, \\c uint64_t, \\c bool\n    */\n    template <typename T, typename stackAllocator>\n    RAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T>, internal::IsGenericValue<T> >), (ValueType&))\n        Set(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, T value) const {\n            return Create(document) = value;\n    }\n\n    //@}\n\n    //!@name Swap a value\n    //@{\n\n    //! Swap a value with a value in a subtree.\n    /*!\n        It creates all parents if they are not exist or types are different to the tokens.\n        So this function always succeeds but potentially remove existing values.\n\n        \\param root Root value of a DOM sub-tree to be resolved. It can be any value other than document root.\n        \\param value Value to be swapped.\n        \\param allocator Allocator for creating the values if the specified value or its parents are not exist.\n        \\see Create()\n    */\n    ValueType& Swap(ValueType& root, ValueType& value, typename ValueType::AllocatorType& allocator) const {\n        return Create(root, allocator).Swap(value);\n    }\n\n    //! Swap a value with a value in a document.\n    template <typename stackAllocator>\n    ValueType& Swap(GenericDocument<EncodingType, typename ValueType::AllocatorType, stackAllocator>& document, ValueType& value) const {\n        return Create(document).Swap(value);\n    }\n\n    //@}\n\n    //! Erase a value in a subtree.\n    /*!\n        \\param root Root value of a DOM sub-tree to be resolved. It can be any value other than document root.\n        \\return Whether the resolved value is found and erased.\n\n        \\note Erasing with an empty pointer \\c Pointer(\"\"), i.e. the root, always fail and return false.\n    */\n    bool Erase(ValueType& root) const {\n        RAPIDJSON_ASSERT(IsValid());\n        if (tokenCount_ == 0) // Cannot erase the root\n            return false;\n\n        ValueType* v = &root;\n        const Token* last = tokens_ + (tokenCount_ - 1);\n        for (const Token *t = tokens_; t != last; ++t) {\n            switch (v->GetType()) {\n            case kObjectType:\n                {\n                    typename ValueType::MemberIterator m = v->FindMember(GenericStringRef<Ch>(t->name, t->length));\n                    if (m == v->MemberEnd())\n                        return false;\n                    v = &m->value;\n                }\n                break;\n            case kArrayType:\n                if (t->index == kPointerInvalidIndex || t->index >= v->Size())\n                    return false;\n                v = &((*v)[t->index]);\n                break;\n            default:\n                return false;\n            }\n        }\n\n        switch (v->GetType()) {\n        case kObjectType:\n            return v->EraseMember(GenericStringRef<Ch>(last->name, last->length));\n        case kArrayType:\n            if (last->index == kPointerInvalidIndex || last->index >= v->Size())\n                return false;\n            v->Erase(v->Begin() + last->index);\n            return true;\n        default:\n            return false;\n        }\n    }\n\nprivate:\n    //! Clone the content from rhs to this.\n    /*!\n        \\param rhs Source pointer.\n        \\param extraToken Extra tokens to be allocated.\n        \\param extraNameBufferSize Extra name buffer size (in number of Ch) to be allocated.\n        \\return Start of non-occupied name buffer, for storing extra names.\n    */\n    Ch* CopyFromRaw(const GenericPointer& rhs, size_t extraToken = 0, size_t extraNameBufferSize = 0) {\n        if (!allocator_) // allocator is independently owned.\n            ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator());\n\n        size_t nameBufferSize = rhs.tokenCount_; // null terminators for tokens\n        for (Token *t = rhs.tokens_; t != rhs.tokens_ + rhs.tokenCount_; ++t)\n            nameBufferSize += t->length;\n\n        tokenCount_ = rhs.tokenCount_ + extraToken;\n        tokens_ = static_cast<Token *>(allocator_->Malloc(tokenCount_ * sizeof(Token) + (nameBufferSize + extraNameBufferSize) * sizeof(Ch)));\n        nameBuffer_ = reinterpret_cast<Ch *>(tokens_ + tokenCount_);\n        if (rhs.tokenCount_ > 0) {\n            std::memcpy(tokens_, rhs.tokens_, rhs.tokenCount_ * sizeof(Token));\n        }\n        if (nameBufferSize > 0) {\n            std::memcpy(nameBuffer_, rhs.nameBuffer_, nameBufferSize * sizeof(Ch));\n        }\n\n        // Adjust pointers to name buffer\n        std::ptrdiff_t diff = nameBuffer_ - rhs.nameBuffer_;\n        for (Token *t = tokens_; t != tokens_ + rhs.tokenCount_; ++t)\n            t->name += diff;\n\n        return nameBuffer_ + nameBufferSize;\n    }\n\n    //! Check whether a character should be percent-encoded.\n    /*!\n        According to RFC 3986 2.3 Unreserved Characters.\n        \\param c The character (code unit) to be tested.\n    */\n    bool NeedPercentEncode(Ch c) const {\n        return !((c >= '0' && c <= '9') || (c >= 'A' && c <='Z') || (c >= 'a' && c <= 'z') || c == '-' || c == '.' || c == '_' || c =='~');\n    }\n\n    //! Parse a JSON String or its URI fragment representation into tokens.\n#ifndef __clang__ // -Wdocumentation\n    /*!\n        \\param source Either a JSON Pointer string, or its URI fragment representation. Not need to be null terminated.\n        \\param length Length of the source string.\n        \\note Source cannot be JSON String Representation of JSON Pointer, e.g. In \"/\\u0000\", \\u0000 will not be unescaped.\n    */\n#endif\n    void Parse(const Ch* source, size_t length) {\n        RAPIDJSON_ASSERT(source != NULL);\n        RAPIDJSON_ASSERT(nameBuffer_ == 0);\n        RAPIDJSON_ASSERT(tokens_ == 0);\n\n        // Create own allocator if user did not supply.\n        if (!allocator_)\n            ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator());\n\n        // Count number of '/' as tokenCount\n        tokenCount_ = 0;\n        for (const Ch* s = source; s != source + length; s++) \n            if (*s == '/')\n                tokenCount_++;\n\n        Token* token = tokens_ = static_cast<Token *>(allocator_->Malloc(tokenCount_ * sizeof(Token) + length * sizeof(Ch)));\n        Ch* name = nameBuffer_ = reinterpret_cast<Ch *>(tokens_ + tokenCount_);\n        size_t i = 0;\n\n        // Detect if it is a URI fragment\n        bool uriFragment = false;\n        if (source[i] == '#') {\n            uriFragment = true;\n            i++;\n        }\n\n        if (i != length && source[i] != '/') {\n            parseErrorCode_ = kPointerParseErrorTokenMustBeginWithSolidus;\n            goto error;\n        }\n\n        while (i < length) {\n            RAPIDJSON_ASSERT(source[i] == '/');\n            i++; // consumes '/'\n\n            token->name = name;\n            bool isNumber = true;\n\n            while (i < length && source[i] != '/') {\n                Ch c = source[i];\n                if (uriFragment) {\n                    // Decoding percent-encoding for URI fragment\n                    if (c == '%') {\n                        PercentDecodeStream is(&source[i], source + length);\n                        GenericInsituStringStream<EncodingType> os(name);\n                        Ch* begin = os.PutBegin();\n                        if (!Transcoder<UTF8<>, EncodingType>().Validate(is, os) || !is.IsValid()) {\n                            parseErrorCode_ = kPointerParseErrorInvalidPercentEncoding;\n                            goto error;\n                        }\n                        size_t len = os.PutEnd(begin);\n                        i += is.Tell() - 1;\n                        if (len == 1)\n                            c = *name;\n                        else {\n                            name += len;\n                            isNumber = false;\n                            i++;\n                            continue;\n                        }\n                    }\n                    else if (NeedPercentEncode(c)) {\n                        parseErrorCode_ = kPointerParseErrorCharacterMustPercentEncode;\n                        goto error;\n                    }\n                }\n\n                i++;\n                \n                // Escaping \"~0\" -> '~', \"~1\" -> '/'\n                if (c == '~') {\n                    if (i < length) {\n                        c = source[i];\n                        if (c == '0')       c = '~';\n                        else if (c == '1')  c = '/';\n                        else {\n                            parseErrorCode_ = kPointerParseErrorInvalidEscape;\n                            goto error;\n                        }\n                        i++;\n                    }\n                    else {\n                        parseErrorCode_ = kPointerParseErrorInvalidEscape;\n                        goto error;\n                    }\n                }\n\n                // First check for index: all of characters are digit\n                if (c < '0' || c > '9')\n                    isNumber = false;\n\n                *name++ = c;\n            }\n            token->length = static_cast<SizeType>(name - token->name);\n            if (token->length == 0)\n                isNumber = false;\n            *name++ = '\\0'; // Null terminator\n\n            // Second check for index: more than one digit cannot have leading zero\n            if (isNumber && token->length > 1 && token->name[0] == '0')\n                isNumber = false;\n\n            // String to SizeType conversion\n            SizeType n = 0;\n            if (isNumber) {\n                for (size_t j = 0; j < token->length; j++) {\n                    SizeType m = n * 10 + static_cast<SizeType>(token->name[j] - '0');\n                    if (m < n) {   // overflow detection\n                        isNumber = false;\n                        break;\n                    }\n                    n = m;\n                }\n            }\n\n            token->index = isNumber ? n : kPointerInvalidIndex;\n            token++;\n        }\n\n        RAPIDJSON_ASSERT(name <= nameBuffer_ + length); // Should not overflow buffer\n        parseErrorCode_ = kPointerParseErrorNone;\n        return;\n\n    error:\n        Allocator::Free(tokens_);\n        nameBuffer_ = 0;\n        tokens_ = 0;\n        tokenCount_ = 0;\n        parseErrorOffset_ = i;\n        return;\n    }\n\n    //! Stringify to string or URI fragment representation.\n    /*!\n        \\tparam uriFragment True for stringifying to URI fragment representation. False for string representation.\n        \\tparam OutputStream type of output stream.\n        \\param os The output stream.\n    */\n    template<bool uriFragment, typename OutputStream>\n    bool Stringify(OutputStream& os) const {\n        RAPIDJSON_ASSERT(IsValid());\n\n        if (uriFragment)\n            os.Put('#');\n\n        for (Token *t = tokens_; t != tokens_ + tokenCount_; ++t) {\n            os.Put('/');\n            for (size_t j = 0; j < t->length; j++) {\n                Ch c = t->name[j];\n                if (c == '~') {\n                    os.Put('~');\n                    os.Put('0');\n                }\n                else if (c == '/') {\n                    os.Put('~');\n                    os.Put('1');\n                }\n                else if (uriFragment && NeedPercentEncode(c)) { \n                    // Transcode to UTF8 sequence\n                    GenericStringStream<typename ValueType::EncodingType> source(&t->name[j]);\n                    PercentEncodeStream<OutputStream> target(os);\n                    if (!Transcoder<EncodingType, UTF8<> >().Validate(source, target))\n                        return false;\n                    j += source.Tell() - 1;\n                }\n                else\n                    os.Put(c);\n            }\n        }\n        return true;\n    }\n\n    //! A helper stream for decoding a percent-encoded sequence into code unit.\n    /*!\n        This stream decodes %XY triplet into code unit (0-255).\n        If it encounters invalid characters, it sets output code unit as 0 and \n        mark invalid, and to be checked by IsValid().\n    */\n    class PercentDecodeStream {\n    public:\n        typedef typename ValueType::Ch Ch;\n\n        //! Constructor\n        /*!\n            \\param source Start of the stream\n            \\param end Past-the-end of the stream.\n        */\n        PercentDecodeStream(const Ch* source, const Ch* end) : src_(source), head_(source), end_(end), valid_(true) {}\n\n        Ch Take() {\n            if (*src_ != '%' || src_ + 3 > end_) { // %XY triplet\n                valid_ = false;\n                return 0;\n            }\n            src_++;\n            Ch c = 0;\n            for (int j = 0; j < 2; j++) {\n                c = static_cast<Ch>(c << 4);\n                Ch h = *src_;\n                if      (h >= '0' && h <= '9') c = static_cast<Ch>(c + h - '0');\n                else if (h >= 'A' && h <= 'F') c = static_cast<Ch>(c + h - 'A' + 10);\n                else if (h >= 'a' && h <= 'f') c = static_cast<Ch>(c + h - 'a' + 10);\n                else {\n                    valid_ = false;\n                    return 0;\n                }\n                src_++;\n            }\n            return c;\n        }\n\n        size_t Tell() const { return static_cast<size_t>(src_ - head_); }\n        bool IsValid() const { return valid_; }\n\n    private:\n        const Ch* src_;     //!< Current read position.\n        const Ch* head_;    //!< Original head of the string.\n        const Ch* end_;     //!< Past-the-end position.\n        bool valid_;        //!< Whether the parsing is valid.\n    };\n\n    //! A helper stream to encode character (UTF-8 code unit) into percent-encoded sequence.\n    template <typename OutputStream>\n    class PercentEncodeStream {\n    public:\n        PercentEncodeStream(OutputStream& os) : os_(os) {}\n        void Put(char c) { // UTF-8 must be byte\n            unsigned char u = static_cast<unsigned char>(c);\n            static const char hexDigits[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };\n            os_.Put('%');\n            os_.Put(hexDigits[u >> 4]);\n            os_.Put(hexDigits[u & 15]);\n        }\n    private:\n        OutputStream& os_;\n    };\n\n    Allocator* allocator_;                  //!< The current allocator. It is either user-supplied or equal to ownAllocator_.\n    Allocator* ownAllocator_;               //!< Allocator owned by this Pointer.\n    Ch* nameBuffer_;                        //!< A buffer containing all names in tokens.\n    Token* tokens_;                         //!< A list of tokens.\n    size_t tokenCount_;                     //!< Number of tokens in tokens_.\n    size_t parseErrorOffset_;               //!< Offset in code unit when parsing fail.\n    PointerParseErrorCode parseErrorCode_;  //!< Parsing error code.\n};\n\n//! GenericPointer for Value (UTF-8, default allocator).\ntypedef GenericPointer<Value> Pointer;\n\n//!@name Helper functions for GenericPointer\n//@{\n\n//////////////////////////////////////////////////////////////////////////////\n\ntemplate <typename T>\ntypename T::ValueType& CreateValueByPointer(T& root, const GenericPointer<typename T::ValueType>& pointer, typename T::AllocatorType& a) {\n    return pointer.Create(root, a);\n}\n\ntemplate <typename T, typename CharType, size_t N>\ntypename T::ValueType& CreateValueByPointer(T& root, const CharType(&source)[N], typename T::AllocatorType& a) {\n    return GenericPointer<typename T::ValueType>(source, N - 1).Create(root, a);\n}\n\n// No allocator parameter\n\ntemplate <typename DocumentType>\ntypename DocumentType::ValueType& CreateValueByPointer(DocumentType& document, const GenericPointer<typename DocumentType::ValueType>& pointer) {\n    return pointer.Create(document);\n}\n\ntemplate <typename DocumentType, typename CharType, size_t N>\ntypename DocumentType::ValueType& CreateValueByPointer(DocumentType& document, const CharType(&source)[N]) {\n    return GenericPointer<typename DocumentType::ValueType>(source, N - 1).Create(document);\n}\n\n//////////////////////////////////////////////////////////////////////////////\n\ntemplate <typename T>\ntypename T::ValueType* GetValueByPointer(T& root, const GenericPointer<typename T::ValueType>& pointer, size_t* unresolvedTokenIndex = 0) {\n    return pointer.Get(root, unresolvedTokenIndex);\n}\n\ntemplate <typename T>\nconst typename T::ValueType* GetValueByPointer(const T& root, const GenericPointer<typename T::ValueType>& pointer, size_t* unresolvedTokenIndex = 0) {\n    return pointer.Get(root, unresolvedTokenIndex);\n}\n\ntemplate <typename T, typename CharType, size_t N>\ntypename T::ValueType* GetValueByPointer(T& root, const CharType (&source)[N], size_t* unresolvedTokenIndex = 0) {\n    return GenericPointer<typename T::ValueType>(source, N - 1).Get(root, unresolvedTokenIndex);\n}\n\ntemplate <typename T, typename CharType, size_t N>\nconst typename T::ValueType* GetValueByPointer(const T& root, const CharType(&source)[N], size_t* unresolvedTokenIndex = 0) {\n    return GenericPointer<typename T::ValueType>(source, N - 1).Get(root, unresolvedTokenIndex);\n}\n\n//////////////////////////////////////////////////////////////////////////////\n\ntemplate <typename T>\ntypename T::ValueType& GetValueByPointerWithDefault(T& root, const GenericPointer<typename T::ValueType>& pointer, const typename T::ValueType& defaultValue, typename T::AllocatorType& a) {\n    return pointer.GetWithDefault(root, defaultValue, a);\n}\n\ntemplate <typename T>\ntypename T::ValueType& GetValueByPointerWithDefault(T& root, const GenericPointer<typename T::ValueType>& pointer, const typename T::Ch* defaultValue, typename T::AllocatorType& a) {\n    return pointer.GetWithDefault(root, defaultValue, a);\n}\n\n#if RAPIDJSON_HAS_STDSTRING\ntemplate <typename T>\ntypename T::ValueType& GetValueByPointerWithDefault(T& root, const GenericPointer<typename T::ValueType>& pointer, const std::basic_string<typename T::Ch>& defaultValue, typename T::AllocatorType& a) {\n    return pointer.GetWithDefault(root, defaultValue, a);\n}\n#endif\n\ntemplate <typename T, typename T2>\nRAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T2>, internal::IsGenericValue<T2> >), (typename T::ValueType&))\nGetValueByPointerWithDefault(T& root, const GenericPointer<typename T::ValueType>& pointer, T2 defaultValue, typename T::AllocatorType& a) {\n    return pointer.GetWithDefault(root, defaultValue, a);\n}\n\ntemplate <typename T, typename CharType, size_t N>\ntypename T::ValueType& GetValueByPointerWithDefault(T& root, const CharType(&source)[N], const typename T::ValueType& defaultValue, typename T::AllocatorType& a) {\n    return GenericPointer<typename T::ValueType>(source, N - 1).GetWithDefault(root, defaultValue, a);\n}\n\ntemplate <typename T, typename CharType, size_t N>\ntypename T::ValueType& GetValueByPointerWithDefault(T& root, const CharType(&source)[N], const typename T::Ch* defaultValue, typename T::AllocatorType& a) {\n    return GenericPointer<typename T::ValueType>(source, N - 1).GetWithDefault(root, defaultValue, a);\n}\n\n#if RAPIDJSON_HAS_STDSTRING\ntemplate <typename T, typename CharType, size_t N>\ntypename T::ValueType& GetValueByPointerWithDefault(T& root, const CharType(&source)[N], const std::basic_string<typename T::Ch>& defaultValue, typename T::AllocatorType& a) {\n    return GenericPointer<typename T::ValueType>(source, N - 1).GetWithDefault(root, defaultValue, a);\n}\n#endif\n\ntemplate <typename T, typename CharType, size_t N, typename T2>\nRAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T2>, internal::IsGenericValue<T2> >), (typename T::ValueType&))\nGetValueByPointerWithDefault(T& root, const CharType(&source)[N], T2 defaultValue, typename T::AllocatorType& a) {\n    return GenericPointer<typename T::ValueType>(source, N - 1).GetWithDefault(root, defaultValue, a);\n}\n\n// No allocator parameter\n\ntemplate <typename DocumentType>\ntypename DocumentType::ValueType& GetValueByPointerWithDefault(DocumentType& document, const GenericPointer<typename DocumentType::ValueType>& pointer, const typename DocumentType::ValueType& defaultValue) {\n    return pointer.GetWithDefault(document, defaultValue);\n}\n\ntemplate <typename DocumentType>\ntypename DocumentType::ValueType& GetValueByPointerWithDefault(DocumentType& document, const GenericPointer<typename DocumentType::ValueType>& pointer, const typename DocumentType::Ch* defaultValue) {\n    return pointer.GetWithDefault(document, defaultValue);\n}\n\n#if RAPIDJSON_HAS_STDSTRING\ntemplate <typename DocumentType>\ntypename DocumentType::ValueType& GetValueByPointerWithDefault(DocumentType& document, const GenericPointer<typename DocumentType::ValueType>& pointer, const std::basic_string<typename DocumentType::Ch>& defaultValue) {\n    return pointer.GetWithDefault(document, defaultValue);\n}\n#endif\n\ntemplate <typename DocumentType, typename T2>\nRAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T2>, internal::IsGenericValue<T2> >), (typename DocumentType::ValueType&))\nGetValueByPointerWithDefault(DocumentType& document, const GenericPointer<typename DocumentType::ValueType>& pointer, T2 defaultValue) {\n    return pointer.GetWithDefault(document, defaultValue);\n}\n\ntemplate <typename DocumentType, typename CharType, size_t N>\ntypename DocumentType::ValueType& GetValueByPointerWithDefault(DocumentType& document, const CharType(&source)[N], const typename DocumentType::ValueType& defaultValue) {\n    return GenericPointer<typename DocumentType::ValueType>(source, N - 1).GetWithDefault(document, defaultValue);\n}\n\ntemplate <typename DocumentType, typename CharType, size_t N>\ntypename DocumentType::ValueType& GetValueByPointerWithDefault(DocumentType& document, const CharType(&source)[N], const typename DocumentType::Ch* defaultValue) {\n    return GenericPointer<typename DocumentType::ValueType>(source, N - 1).GetWithDefault(document, defaultValue);\n}\n\n#if RAPIDJSON_HAS_STDSTRING\ntemplate <typename DocumentType, typename CharType, size_t N>\ntypename DocumentType::ValueType& GetValueByPointerWithDefault(DocumentType& document, const CharType(&source)[N], const std::basic_string<typename DocumentType::Ch>& defaultValue) {\n    return GenericPointer<typename DocumentType::ValueType>(source, N - 1).GetWithDefault(document, defaultValue);\n}\n#endif\n\ntemplate <typename DocumentType, typename CharType, size_t N, typename T2>\nRAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T2>, internal::IsGenericValue<T2> >), (typename DocumentType::ValueType&))\nGetValueByPointerWithDefault(DocumentType& document, const CharType(&source)[N], T2 defaultValue) {\n    return GenericPointer<typename DocumentType::ValueType>(source, N - 1).GetWithDefault(document, defaultValue);\n}\n\n//////////////////////////////////////////////////////////////////////////////\n\ntemplate <typename T>\ntypename T::ValueType& SetValueByPointer(T& root, const GenericPointer<typename T::ValueType>& pointer, typename T::ValueType& value, typename T::AllocatorType& a) {\n    return pointer.Set(root, value, a);\n}\n\ntemplate <typename T>\ntypename T::ValueType& SetValueByPointer(T& root, const GenericPointer<typename T::ValueType>& pointer, const typename T::ValueType& value, typename T::AllocatorType& a) {\n    return pointer.Set(root, value, a);\n}\n\ntemplate <typename T>\ntypename T::ValueType& SetValueByPointer(T& root, const GenericPointer<typename T::ValueType>& pointer, const typename T::Ch* value, typename T::AllocatorType& a) {\n    return pointer.Set(root, value, a);\n}\n\n#if RAPIDJSON_HAS_STDSTRING\ntemplate <typename T>\ntypename T::ValueType& SetValueByPointer(T& root, const GenericPointer<typename T::ValueType>& pointer, const std::basic_string<typename T::Ch>& value, typename T::AllocatorType& a) {\n    return pointer.Set(root, value, a);\n}\n#endif\n\ntemplate <typename T, typename T2>\nRAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T2>, internal::IsGenericValue<T2> >), (typename T::ValueType&))\nSetValueByPointer(T& root, const GenericPointer<typename T::ValueType>& pointer, T2 value, typename T::AllocatorType& a) {\n    return pointer.Set(root, value, a);\n}\n\ntemplate <typename T, typename CharType, size_t N>\ntypename T::ValueType& SetValueByPointer(T& root, const CharType(&source)[N], typename T::ValueType& value, typename T::AllocatorType& a) {\n    return GenericPointer<typename T::ValueType>(source, N - 1).Set(root, value, a);\n}\n\ntemplate <typename T, typename CharType, size_t N>\ntypename T::ValueType& SetValueByPointer(T& root, const CharType(&source)[N], const typename T::ValueType& value, typename T::AllocatorType& a) {\n    return GenericPointer<typename T::ValueType>(source, N - 1).Set(root, value, a);\n}\n\ntemplate <typename T, typename CharType, size_t N>\ntypename T::ValueType& SetValueByPointer(T& root, const CharType(&source)[N], const typename T::Ch* value, typename T::AllocatorType& a) {\n    return GenericPointer<typename T::ValueType>(source, N - 1).Set(root, value, a);\n}\n\n#if RAPIDJSON_HAS_STDSTRING\ntemplate <typename T, typename CharType, size_t N>\ntypename T::ValueType& SetValueByPointer(T& root, const CharType(&source)[N], const std::basic_string<typename T::Ch>& value, typename T::AllocatorType& a) {\n    return GenericPointer<typename T::ValueType>(source, N - 1).Set(root, value, a);\n}\n#endif\n\ntemplate <typename T, typename CharType, size_t N, typename T2>\nRAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T2>, internal::IsGenericValue<T2> >), (typename T::ValueType&))\nSetValueByPointer(T& root, const CharType(&source)[N], T2 value, typename T::AllocatorType& a) {\n    return GenericPointer<typename T::ValueType>(source, N - 1).Set(root, value, a);\n}\n\n// No allocator parameter\n\ntemplate <typename DocumentType>\ntypename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const GenericPointer<typename DocumentType::ValueType>& pointer, typename DocumentType::ValueType& value) {\n    return pointer.Set(document, value);\n}\n\ntemplate <typename DocumentType>\ntypename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const GenericPointer<typename DocumentType::ValueType>& pointer, const typename DocumentType::ValueType& value) {\n    return pointer.Set(document, value);\n}\n\ntemplate <typename DocumentType>\ntypename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const GenericPointer<typename DocumentType::ValueType>& pointer, const typename DocumentType::Ch* value) {\n    return pointer.Set(document, value);\n}\n\n#if RAPIDJSON_HAS_STDSTRING\ntemplate <typename DocumentType>\ntypename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const GenericPointer<typename DocumentType::ValueType>& pointer, const std::basic_string<typename DocumentType::Ch>& value) {\n    return pointer.Set(document, value);\n}\n#endif\n\ntemplate <typename DocumentType, typename T2>\nRAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T2>, internal::IsGenericValue<T2> >), (typename DocumentType::ValueType&))\nSetValueByPointer(DocumentType& document, const GenericPointer<typename DocumentType::ValueType>& pointer, T2 value) {\n    return pointer.Set(document, value);\n}\n\ntemplate <typename DocumentType, typename CharType, size_t N>\ntypename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const CharType(&source)[N], typename DocumentType::ValueType& value) {\n    return GenericPointer<typename DocumentType::ValueType>(source, N - 1).Set(document, value);\n}\n\ntemplate <typename DocumentType, typename CharType, size_t N>\ntypename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const CharType(&source)[N], const typename DocumentType::ValueType& value) {\n    return GenericPointer<typename DocumentType::ValueType>(source, N - 1).Set(document, value);\n}\n\ntemplate <typename DocumentType, typename CharType, size_t N>\ntypename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const CharType(&source)[N], const typename DocumentType::Ch* value) {\n    return GenericPointer<typename DocumentType::ValueType>(source, N - 1).Set(document, value);\n}\n\n#if RAPIDJSON_HAS_STDSTRING\ntemplate <typename DocumentType, typename CharType, size_t N>\ntypename DocumentType::ValueType& SetValueByPointer(DocumentType& document, const CharType(&source)[N], const std::basic_string<typename DocumentType::Ch>& value) {\n    return GenericPointer<typename DocumentType::ValueType>(source, N - 1).Set(document, value);\n}\n#endif\n\ntemplate <typename DocumentType, typename CharType, size_t N, typename T2>\nRAPIDJSON_DISABLEIF_RETURN((internal::OrExpr<internal::IsPointer<T2>, internal::IsGenericValue<T2> >), (typename DocumentType::ValueType&))\nSetValueByPointer(DocumentType& document, const CharType(&source)[N], T2 value) {\n    return GenericPointer<typename DocumentType::ValueType>(source, N - 1).Set(document, value);\n}\n\n//////////////////////////////////////////////////////////////////////////////\n\ntemplate <typename T>\ntypename T::ValueType& SwapValueByPointer(T& root, const GenericPointer<typename T::ValueType>& pointer, typename T::ValueType& value, typename T::AllocatorType& a) {\n    return pointer.Swap(root, value, a);\n}\n\ntemplate <typename T, typename CharType, size_t N>\ntypename T::ValueType& SwapValueByPointer(T& root, const CharType(&source)[N], typename T::ValueType& value, typename T::AllocatorType& a) {\n    return GenericPointer<typename T::ValueType>(source, N - 1).Swap(root, value, a);\n}\n\ntemplate <typename DocumentType>\ntypename DocumentType::ValueType& SwapValueByPointer(DocumentType& document, const GenericPointer<typename DocumentType::ValueType>& pointer, typename DocumentType::ValueType& value) {\n    return pointer.Swap(document, value);\n}\n\ntemplate <typename DocumentType, typename CharType, size_t N>\ntypename DocumentType::ValueType& SwapValueByPointer(DocumentType& document, const CharType(&source)[N], typename DocumentType::ValueType& value) {\n    return GenericPointer<typename DocumentType::ValueType>(source, N - 1).Swap(document, value);\n}\n\n//////////////////////////////////////////////////////////////////////////////\n\ntemplate <typename T>\nbool EraseValueByPointer(T& root, const GenericPointer<typename T::ValueType>& pointer) {\n    return pointer.Erase(root);\n}\n\ntemplate <typename T, typename CharType, size_t N>\nbool EraseValueByPointer(T& root, const CharType(&source)[N]) {\n    return GenericPointer<typename T::ValueType>(source, N - 1).Erase(root);\n}\n\n//@}\n\nRAPIDJSON_NAMESPACE_END\n\n#ifdef __clang__\nRAPIDJSON_DIAG_POP\n#endif\n\n#ifdef _MSC_VER\nRAPIDJSON_DIAG_POP\n#endif\n\n#endif // RAPIDJSON_POINTER_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/prettywriter.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_PRETTYWRITER_H_\n#define RAPIDJSON_PRETTYWRITER_H_\n\n#include \"writer.h\"\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(effc++)\n#endif\n\nRAPIDJSON_NAMESPACE_BEGIN\n\n//! Combination of PrettyWriter format flags.\n/*! \\see PrettyWriter::SetFormatOptions\n */\nenum PrettyFormatOptions {\n    kFormatDefault = 0,         //!< Default pretty formatting.\n    kFormatSingleLineArray = 1  //!< Format arrays on a single line.\n};\n\n//! Writer with indentation and spacing.\n/*!\n    \\tparam OutputStream Type of ouptut os.\n    \\tparam SourceEncoding Encoding of source string.\n    \\tparam TargetEncoding Encoding of output stream.\n    \\tparam StackAllocator Type of allocator for allocating memory of stack.\n*/\ntemplate<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>\nclass PrettyWriter : public Writer<OutputStream, SourceEncoding, TargetEncoding, StackAllocator, writeFlags> {\npublic:\n    typedef Writer<OutputStream, SourceEncoding, TargetEncoding, StackAllocator> Base;\n    typedef typename Base::Ch Ch;\n\n    //! Constructor\n    /*! \\param os Output stream.\n        \\param allocator User supplied allocator. If it is null, it will create a private one.\n        \\param levelDepth Initial capacity of stack.\n    */\n    explicit PrettyWriter(OutputStream& os, StackAllocator* allocator = 0, size_t levelDepth = Base::kDefaultLevelDepth) : \n        Base(os, allocator, levelDepth), indentChar_(' '), indentCharCount_(4), formatOptions_(kFormatDefault) {}\n\n\n    explicit PrettyWriter(StackAllocator* allocator = 0, size_t levelDepth = Base::kDefaultLevelDepth) : \n        Base(allocator, levelDepth), indentChar_(' '), indentCharCount_(4) {}\n\n    //! Set custom indentation.\n    /*! \\param indentChar       Character for indentation. Must be whitespace character (' ', '\\\\t', '\\\\n', '\\\\r').\n        \\param indentCharCount  Number of indent characters for each indentation level.\n        \\note The default indentation is 4 spaces.\n    */\n    PrettyWriter& SetIndent(Ch indentChar, unsigned indentCharCount) {\n        RAPIDJSON_ASSERT(indentChar == ' ' || indentChar == '\\t' || indentChar == '\\n' || indentChar == '\\r');\n        indentChar_ = indentChar;\n        indentCharCount_ = indentCharCount;\n        return *this;\n    }\n\n    //! Set pretty writer formatting options.\n    /*! \\param options Formatting options.\n    */\n    PrettyWriter& SetFormatOptions(PrettyFormatOptions options) {\n        formatOptions_ = options;\n        return *this;\n    }\n\n    /*! @name Implementation of Handler\n        \\see Handler\n    */\n    //@{\n\n    bool Null()                 { PrettyPrefix(kNullType);   return Base::WriteNull(); }\n    bool Bool(bool b)           { PrettyPrefix(b ? kTrueType : kFalseType); return Base::WriteBool(b); }\n    bool Int(int i)             { PrettyPrefix(kNumberType); return Base::WriteInt(i); }\n    bool Uint(unsigned u)       { PrettyPrefix(kNumberType); return Base::WriteUint(u); }\n    bool Int64(int64_t i64)     { PrettyPrefix(kNumberType); return Base::WriteInt64(i64); }\n    bool Uint64(uint64_t u64)   { PrettyPrefix(kNumberType); return Base::WriteUint64(u64);  }\n    bool Double(double d)       { PrettyPrefix(kNumberType); return Base::WriteDouble(d); }\n\n    bool RawNumber(const Ch* str, SizeType length, bool copy = false) {\n        (void)copy;\n        PrettyPrefix(kNumberType);\n        return Base::WriteString(str, length);\n    }\n\n    bool String(const Ch* str, SizeType length, bool copy = false) {\n        (void)copy;\n        PrettyPrefix(kStringType);\n        return Base::WriteString(str, length);\n    }\n\n#if RAPIDJSON_HAS_STDSTRING\n    bool String(const std::basic_string<Ch>& str) {\n        return String(str.data(), SizeType(str.size()));\n    }\n#endif\n\n    bool StartObject() {\n        PrettyPrefix(kObjectType);\n        new (Base::level_stack_.template Push<typename Base::Level>()) typename Base::Level(false);\n        return Base::WriteStartObject();\n    }\n\n    bool Key(const Ch* str, SizeType length, bool copy = false) { return String(str, length, copy); }\n\n#if RAPIDJSON_HAS_STDSTRING\n    bool Key(const std::basic_string<Ch>& str) {\n        return Key(str.data(), SizeType(str.size()));\n    }\n#endif\n\t\n    bool EndObject(SizeType memberCount = 0) {\n        (void)memberCount;\n        RAPIDJSON_ASSERT(Base::level_stack_.GetSize() >= sizeof(typename Base::Level));\n        RAPIDJSON_ASSERT(!Base::level_stack_.template Top<typename Base::Level>()->inArray);\n        bool empty = Base::level_stack_.template Pop<typename Base::Level>(1)->valueCount == 0;\n\n        if (!empty) {\n            Base::os_->Put('\\n');\n            WriteIndent();\n        }\n        bool ret = Base::WriteEndObject();\n        (void)ret;\n        RAPIDJSON_ASSERT(ret == true);\n        if (Base::level_stack_.Empty()) // end of json text\n            Base::os_->Flush();\n        return true;\n    }\n\n    bool StartArray() {\n        PrettyPrefix(kArrayType);\n        new (Base::level_stack_.template Push<typename Base::Level>()) typename Base::Level(true);\n        return Base::WriteStartArray();\n    }\n\n    bool EndArray(SizeType memberCount = 0) {\n        (void)memberCount;\n        RAPIDJSON_ASSERT(Base::level_stack_.GetSize() >= sizeof(typename Base::Level));\n        RAPIDJSON_ASSERT(Base::level_stack_.template Top<typename Base::Level>()->inArray);\n        bool empty = Base::level_stack_.template Pop<typename Base::Level>(1)->valueCount == 0;\n\n        if (!empty && !(formatOptions_ & kFormatSingleLineArray)) {\n            Base::os_->Put('\\n');\n            WriteIndent();\n        }\n        bool ret = Base::WriteEndArray();\n        (void)ret;\n        RAPIDJSON_ASSERT(ret == true);\n        if (Base::level_stack_.Empty()) // end of json text\n            Base::os_->Flush();\n        return true;\n    }\n\n    //@}\n\n    /*! @name Convenience extensions */\n    //@{\n\n    //! Simpler but slower overload.\n    bool String(const Ch* str) { return String(str, internal::StrLen(str)); }\n    bool Key(const Ch* str) { return Key(str, internal::StrLen(str)); }\n\n    //@}\n\n    //! Write a raw JSON value.\n    /*!\n        For user to write a stringified JSON as a value.\n\n        \\param json A well-formed JSON value. It should not contain null character within [0, length - 1] range.\n        \\param length Length of the json.\n        \\param type Type of the root of json.\n        \\note When using PrettyWriter::RawValue(), the result json may not be indented correctly.\n    */\n    bool RawValue(const Ch* json, size_t length, Type type) { PrettyPrefix(type); return Base::WriteRawValue(json, length); }\n\nprotected:\n    void PrettyPrefix(Type type) {\n        (void)type;\n        if (Base::level_stack_.GetSize() != 0) { // this value is not at root\n            typename Base::Level* level = Base::level_stack_.template Top<typename Base::Level>();\n\n            if (level->inArray) {\n                if (level->valueCount > 0) {\n                    Base::os_->Put(','); // add comma if it is not the first element in array\n                    if (formatOptions_ & kFormatSingleLineArray)\n                        Base::os_->Put(' ');\n                }\n\n                if (!(formatOptions_ & kFormatSingleLineArray)) {\n                    Base::os_->Put('\\n');\n                    WriteIndent();\n                }\n            }\n            else {  // in object\n                if (level->valueCount > 0) {\n                    if (level->valueCount % 2 == 0) {\n                        Base::os_->Put(',');\n                        Base::os_->Put('\\n');\n                    }\n                    else {\n                        Base::os_->Put(':');\n                        Base::os_->Put(' ');\n                    }\n                }\n                else\n                    Base::os_->Put('\\n');\n\n                if (level->valueCount % 2 == 0)\n                    WriteIndent();\n            }\n            if (!level->inArray && level->valueCount % 2 == 0)\n                RAPIDJSON_ASSERT(type == kStringType);  // if it's in object, then even number should be a name\n            level->valueCount++;\n        }\n        else {\n            RAPIDJSON_ASSERT(!Base::hasRoot_);  // Should only has one and only one root.\n            Base::hasRoot_ = true;\n        }\n    }\n\n    void WriteIndent()  {\n        size_t count = (Base::level_stack_.GetSize() / sizeof(typename Base::Level)) * indentCharCount_;\n        PutN(*Base::os_, static_cast<typename TargetEncoding::Ch>(indentChar_), count);\n    }\n\n    Ch indentChar_;\n    unsigned indentCharCount_;\n    PrettyFormatOptions formatOptions_;\n\nprivate:\n    // Prohibit copy constructor & assignment operator.\n    PrettyWriter(const PrettyWriter&);\n    PrettyWriter& operator=(const PrettyWriter&);\n};\n\nRAPIDJSON_NAMESPACE_END\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_POP\n#endif\n\n#endif // RAPIDJSON_RAPIDJSON_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/rapidjson.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_RAPIDJSON_H_\n#define RAPIDJSON_RAPIDJSON_H_\n\n/*!\\file rapidjson.h\n    \\brief common definitions and configuration\n    \n    \\see RAPIDJSON_CONFIG\n */\n\n/*! \\defgroup RAPIDJSON_CONFIG RapidJSON configuration\n    \\brief Configuration macros for library features\n\n    Some RapidJSON features are configurable to adapt the library to a wide\n    variety of platforms, environments and usage scenarios.  Most of the\n    features can be configured in terms of overriden or predefined\n    preprocessor macros at compile-time.\n\n    Some additional customization is available in the \\ref RAPIDJSON_ERRORS APIs.\n\n    \\note These macros should be given on the compiler command-line\n          (where applicable)  to avoid inconsistent values when compiling\n          different translation units of a single application.\n */\n\n#include <cstdlib>  // malloc(), realloc(), free(), size_t\n#include <cstring>  // memset(), memcpy(), memmove(), memcmp()\n\n///////////////////////////////////////////////////////////////////////////////\n// RAPIDJSON_VERSION_STRING\n//\n// ALWAYS synchronize the following 3 macros with corresponding variables in /CMakeLists.txt.\n//\n\n//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN\n// token stringification\n#define RAPIDJSON_STRINGIFY(x) RAPIDJSON_DO_STRINGIFY(x)\n#define RAPIDJSON_DO_STRINGIFY(x) #x\n//!@endcond\n\n/*! \\def RAPIDJSON_MAJOR_VERSION\n    \\ingroup RAPIDJSON_CONFIG\n    \\brief Major version of RapidJSON in integer.\n*/\n/*! \\def RAPIDJSON_MINOR_VERSION\n    \\ingroup RAPIDJSON_CONFIG\n    \\brief Minor version of RapidJSON in integer.\n*/\n/*! \\def RAPIDJSON_PATCH_VERSION\n    \\ingroup RAPIDJSON_CONFIG\n    \\brief Patch version of RapidJSON in integer.\n*/\n/*! \\def RAPIDJSON_VERSION_STRING\n    \\ingroup RAPIDJSON_CONFIG\n    \\brief Version of RapidJSON in \"<major>.<minor>.<patch>\" string format.\n*/\n#define RAPIDJSON_MAJOR_VERSION 1\n#define RAPIDJSON_MINOR_VERSION 1\n#define RAPIDJSON_PATCH_VERSION 0\n#define RAPIDJSON_VERSION_STRING \\\n    RAPIDJSON_STRINGIFY(RAPIDJSON_MAJOR_VERSION.RAPIDJSON_MINOR_VERSION.RAPIDJSON_PATCH_VERSION)\n\n///////////////////////////////////////////////////////////////////////////////\n// RAPIDJSON_NAMESPACE_(BEGIN|END)\n/*! \\def RAPIDJSON_NAMESPACE\n    \\ingroup RAPIDJSON_CONFIG\n    \\brief   provide custom rapidjson namespace\n\n    In order to avoid symbol clashes and/or \"One Definition Rule\" errors\n    between multiple inclusions of (different versions of) RapidJSON in\n    a single binary, users can customize the name of the main RapidJSON\n    namespace.\n\n    In case of a single nesting level, defining \\c RAPIDJSON_NAMESPACE\n    to a custom name (e.g. \\c MyRapidJSON) is sufficient.  If multiple\n    levels are needed, both \\ref RAPIDJSON_NAMESPACE_BEGIN and \\ref\n    RAPIDJSON_NAMESPACE_END need to be defined as well:\n\n    \\code\n    // in some .cpp file\n    #define RAPIDJSON_NAMESPACE my::rapidjson\n    #define RAPIDJSON_NAMESPACE_BEGIN namespace my { namespace rapidjson {\n    #define RAPIDJSON_NAMESPACE_END   } }\n    #include \"rapidjson/...\"\n    \\endcode\n\n    \\see rapidjson\n */\n/*! \\def RAPIDJSON_NAMESPACE_BEGIN\n    \\ingroup RAPIDJSON_CONFIG\n    \\brief   provide custom rapidjson namespace (opening expression)\n    \\see RAPIDJSON_NAMESPACE\n*/\n/*! \\def RAPIDJSON_NAMESPACE_END\n    \\ingroup RAPIDJSON_CONFIG\n    \\brief   provide custom rapidjson namespace (closing expression)\n    \\see RAPIDJSON_NAMESPACE\n*/\n#ifndef RAPIDJSON_NAMESPACE\n#define RAPIDJSON_NAMESPACE rapidjson\n#endif\n#ifndef RAPIDJSON_NAMESPACE_BEGIN\n#define RAPIDJSON_NAMESPACE_BEGIN namespace RAPIDJSON_NAMESPACE {\n#endif\n#ifndef RAPIDJSON_NAMESPACE_END\n#define RAPIDJSON_NAMESPACE_END }\n#endif\n\n///////////////////////////////////////////////////////////////////////////////\n// RAPIDJSON_HAS_STDSTRING\n\n#ifndef RAPIDJSON_HAS_STDSTRING\n#ifdef RAPIDJSON_DOXYGEN_RUNNING\n#define RAPIDJSON_HAS_STDSTRING 1 // force generation of documentation\n#else\n#define RAPIDJSON_HAS_STDSTRING 0 // no std::string support by default\n#endif\n/*! \\def RAPIDJSON_HAS_STDSTRING\n    \\ingroup RAPIDJSON_CONFIG\n    \\brief Enable RapidJSON support for \\c std::string\n\n    By defining this preprocessor symbol to \\c 1, several convenience functions for using\n    \\ref rapidjson::GenericValue with \\c std::string are enabled, especially\n    for construction and comparison.\n\n    \\hideinitializer\n*/\n#endif // !defined(RAPIDJSON_HAS_STDSTRING)\n\n#if RAPIDJSON_HAS_STDSTRING\n#include <string>\n#endif // RAPIDJSON_HAS_STDSTRING\n\n///////////////////////////////////////////////////////////////////////////////\n// RAPIDJSON_NO_INT64DEFINE\n\n/*! \\def RAPIDJSON_NO_INT64DEFINE\n    \\ingroup RAPIDJSON_CONFIG\n    \\brief Use external 64-bit integer types.\n\n    RapidJSON requires the 64-bit integer types \\c int64_t and  \\c uint64_t types\n    to be available at global scope.\n\n    If users have their own definition, define RAPIDJSON_NO_INT64DEFINE to\n    prevent RapidJSON from defining its own types.\n*/\n#ifndef RAPIDJSON_NO_INT64DEFINE\n//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN\n#if defined(_MSC_VER) && (_MSC_VER < 1800)\t// Visual Studio 2013\n#include \"msinttypes/stdint.h\"\n#include \"msinttypes/inttypes.h\"\n#else\n// Other compilers should have this.\n#include <stdint.h>\n#include <inttypes.h>\n#endif\n//!@endcond\n#ifdef RAPIDJSON_DOXYGEN_RUNNING\n#define RAPIDJSON_NO_INT64DEFINE\n#endif\n#endif // RAPIDJSON_NO_INT64TYPEDEF\n\n///////////////////////////////////////////////////////////////////////////////\n// RAPIDJSON_FORCEINLINE\n\n#ifndef RAPIDJSON_FORCEINLINE\n//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN\n#if defined(_MSC_VER) && defined(NDEBUG)\n#define RAPIDJSON_FORCEINLINE __forceinline\n#elif defined(__GNUC__) && __GNUC__ >= 4 && defined(NDEBUG)\n#define RAPIDJSON_FORCEINLINE __attribute__((always_inline))\n#else\n#define RAPIDJSON_FORCEINLINE\n#endif\n//!@endcond\n#endif // RAPIDJSON_FORCEINLINE\n\n///////////////////////////////////////////////////////////////////////////////\n// RAPIDJSON_ENDIAN\n#define RAPIDJSON_LITTLEENDIAN  0   //!< Little endian machine\n#define RAPIDJSON_BIGENDIAN     1   //!< Big endian machine\n\n//! Endianness of the machine.\n/*!\n    \\def RAPIDJSON_ENDIAN\n    \\ingroup RAPIDJSON_CONFIG\n\n    GCC 4.6 provided macro for detecting endianness of the target machine. But other\n    compilers may not have this. User can define RAPIDJSON_ENDIAN to either\n    \\ref RAPIDJSON_LITTLEENDIAN or \\ref RAPIDJSON_BIGENDIAN.\n\n    Default detection implemented with reference to\n    \\li https://gcc.gnu.org/onlinedocs/gcc-4.6.0/cpp/Common-Predefined-Macros.html\n    \\li http://www.boost.org/doc/libs/1_42_0/boost/detail/endian.hpp\n*/\n#ifndef RAPIDJSON_ENDIAN\n// Detect with GCC 4.6's macro\n#  ifdef __BYTE_ORDER__\n#    if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__\n#      define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN\n#    elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__\n#      define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN\n#    else\n#      error Unknown machine endianess detected. User needs to define RAPIDJSON_ENDIAN.\n#    endif // __BYTE_ORDER__\n// Detect with GLIBC's endian.h\n#  elif defined(__GLIBC__)\n#    include <endian.h>\n#    if (__BYTE_ORDER == __LITTLE_ENDIAN)\n#      define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN\n#    elif (__BYTE_ORDER == __BIG_ENDIAN)\n#      define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN\n#    else\n#      error Unknown machine endianess detected. User needs to define RAPIDJSON_ENDIAN.\n#   endif // __GLIBC__\n// Detect with _LITTLE_ENDIAN and _BIG_ENDIAN macro\n#  elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)\n#    define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN\n#  elif defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)\n#    define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN\n// Detect with architecture macros\n#  elif defined(__sparc) || defined(__sparc__) || defined(_POWER) || defined(__powerpc__) || defined(__ppc__) || defined(__hpux) || defined(__hppa) || defined(_MIPSEB) || defined(_POWER) || defined(__s390__)\n#    define RAPIDJSON_ENDIAN RAPIDJSON_BIGENDIAN\n#  elif defined(__i386__) || defined(__alpha__) || defined(__ia64) || defined(__ia64__) || defined(_M_IX86) || defined(_M_IA64) || defined(_M_ALPHA) || defined(__amd64) || defined(__amd64__) || defined(_M_AMD64) || defined(__x86_64) || defined(__x86_64__) || defined(_M_X64) || defined(__bfin__)\n#    define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN\n#  elif defined(_MSC_VER) && defined(_M_ARM)\n#    define RAPIDJSON_ENDIAN RAPIDJSON_LITTLEENDIAN\n#  elif defined(RAPIDJSON_DOXYGEN_RUNNING)\n#    define RAPIDJSON_ENDIAN\n#  else\n#    error Unknown machine endianess detected. User needs to define RAPIDJSON_ENDIAN.   \n#  endif\n#endif // RAPIDJSON_ENDIAN\n\n///////////////////////////////////////////////////////////////////////////////\n// RAPIDJSON_64BIT\n\n//! Whether using 64-bit architecture\n#ifndef RAPIDJSON_64BIT\n#if defined(__LP64__) || (defined(__x86_64__) && defined(__ILP32__)) || defined(_WIN64) || defined(__EMSCRIPTEN__)\n#define RAPIDJSON_64BIT 1\n#else\n#define RAPIDJSON_64BIT 0\n#endif\n#endif // RAPIDJSON_64BIT\n\n///////////////////////////////////////////////////////////////////////////////\n// RAPIDJSON_ALIGN\n\n//! Data alignment of the machine.\n/*! \\ingroup RAPIDJSON_CONFIG\n    \\param x pointer to align\n\n    Some machines require strict data alignment. Currently the default uses 4 bytes\n    alignment on 32-bit platforms and 8 bytes alignment for 64-bit platforms.\n    User can customize by defining the RAPIDJSON_ALIGN function macro.\n*/\n#ifndef RAPIDJSON_ALIGN\n#if RAPIDJSON_64BIT == 1\n#define RAPIDJSON_ALIGN(x) (((x) + static_cast<uint64_t>(7u)) & ~static_cast<uint64_t>(7u))\n#else\n#define RAPIDJSON_ALIGN(x) (((x) + 3u) & ~3u)\n#endif\n#endif\n\n///////////////////////////////////////////////////////////////////////////////\n// RAPIDJSON_UINT64_C2\n\n//! Construct a 64-bit literal by a pair of 32-bit integer.\n/*!\n    64-bit literal with or without ULL suffix is prone to compiler warnings.\n    UINT64_C() is C macro which cause compilation problems.\n    Use this macro to define 64-bit constants by a pair of 32-bit integer.\n*/\n#ifndef RAPIDJSON_UINT64_C2\n#define RAPIDJSON_UINT64_C2(high32, low32) ((static_cast<uint64_t>(high32) << 32) | static_cast<uint64_t>(low32))\n#endif\n\n///////////////////////////////////////////////////////////////////////////////\n// RAPIDJSON_48BITPOINTER_OPTIMIZATION\n\n//! Use only lower 48-bit address for some pointers.\n/*!\n    \\ingroup RAPIDJSON_CONFIG\n\n    This optimization uses the fact that current X86-64 architecture only implement lower 48-bit virtual address.\n    The higher 16-bit can be used for storing other data.\n    \\c GenericValue uses this optimization to reduce its size form 24 bytes to 16 bytes in 64-bit architecture.\n*/\n#ifndef RAPIDJSON_48BITPOINTER_OPTIMIZATION\n#if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)\n#define RAPIDJSON_48BITPOINTER_OPTIMIZATION 1\n#else\n#define RAPIDJSON_48BITPOINTER_OPTIMIZATION 0\n#endif\n#endif // RAPIDJSON_48BITPOINTER_OPTIMIZATION\n\n#if RAPIDJSON_48BITPOINTER_OPTIMIZATION == 1\n#if RAPIDJSON_64BIT != 1\n#error RAPIDJSON_48BITPOINTER_OPTIMIZATION can only be set to 1 when RAPIDJSON_64BIT=1\n#endif\n#define RAPIDJSON_SETPOINTER(type, p, x) (p = reinterpret_cast<type *>((reinterpret_cast<uintptr_t>(p) & static_cast<uintptr_t>(RAPIDJSON_UINT64_C2(0xFFFF0000, 0x00000000))) | reinterpret_cast<uintptr_t>(reinterpret_cast<const void*>(x))))\n#define RAPIDJSON_GETPOINTER(type, p) (reinterpret_cast<type *>(reinterpret_cast<uintptr_t>(p) & static_cast<uintptr_t>(RAPIDJSON_UINT64_C2(0x0000FFFF, 0xFFFFFFFF))))\n#else\n#define RAPIDJSON_SETPOINTER(type, p, x) (p = (x))\n#define RAPIDJSON_GETPOINTER(type, p) (p)\n#endif\n\n///////////////////////////////////////////////////////////////////////////////\n// RAPIDJSON_SSE2/RAPIDJSON_SSE42/RAPIDJSON_SIMD\n\n/*! \\def RAPIDJSON_SIMD\n    \\ingroup RAPIDJSON_CONFIG\n    \\brief Enable SSE2/SSE4.2 optimization.\n\n    RapidJSON supports optimized implementations for some parsing operations\n    based on the SSE2 or SSE4.2 SIMD extensions on modern Intel-compatible\n    processors.\n\n    To enable these optimizations, two different symbols can be defined;\n    \\code\n    // Enable SSE2 optimization.\n    #define RAPIDJSON_SSE2\n\n    // Enable SSE4.2 optimization.\n    #define RAPIDJSON_SSE42\n    \\endcode\n\n    \\c RAPIDJSON_SSE42 takes precedence, if both are defined.\n\n    If any of these symbols is defined, RapidJSON defines the macro\n    \\c RAPIDJSON_SIMD to indicate the availability of the optimized code.\n*/\n#if defined(RAPIDJSON_SSE2) || defined(RAPIDJSON_SSE42) \\\n    || defined(RAPIDJSON_DOXYGEN_RUNNING)\n#define RAPIDJSON_SIMD\n#endif\n\n///////////////////////////////////////////////////////////////////////////////\n// RAPIDJSON_NO_SIZETYPEDEFINE\n\n#ifndef RAPIDJSON_NO_SIZETYPEDEFINE\n/*! \\def RAPIDJSON_NO_SIZETYPEDEFINE\n    \\ingroup RAPIDJSON_CONFIG\n    \\brief User-provided \\c SizeType definition.\n\n    In order to avoid using 32-bit size types for indexing strings and arrays,\n    define this preprocessor symbol and provide the type rapidjson::SizeType\n    before including RapidJSON:\n    \\code\n    #define RAPIDJSON_NO_SIZETYPEDEFINE\n    namespace rapidjson { typedef ::std::size_t SizeType; }\n    #include \"rapidjson/...\"\n    \\endcode\n\n    \\see rapidjson::SizeType\n*/\n#ifdef RAPIDJSON_DOXYGEN_RUNNING\n#define RAPIDJSON_NO_SIZETYPEDEFINE\n#endif\nRAPIDJSON_NAMESPACE_BEGIN\n//! Size type (for string lengths, array sizes, etc.)\n/*! RapidJSON uses 32-bit array/string indices even on 64-bit platforms,\n    instead of using \\c size_t. Users may override the SizeType by defining\n    \\ref RAPIDJSON_NO_SIZETYPEDEFINE.\n*/\ntypedef unsigned SizeType;\nRAPIDJSON_NAMESPACE_END\n#endif\n\n// always import std::size_t to rapidjson namespace\nRAPIDJSON_NAMESPACE_BEGIN\nusing std::size_t;\nRAPIDJSON_NAMESPACE_END\n\n///////////////////////////////////////////////////////////////////////////////\n// RAPIDJSON_ASSERT\n\n//! Assertion.\n/*! \\ingroup RAPIDJSON_CONFIG\n    By default, rapidjson uses C \\c assert() for internal assertions.\n    User can override it by defining RAPIDJSON_ASSERT(x) macro.\n\n    \\note Parsing errors are handled and can be customized by the\n          \\ref RAPIDJSON_ERRORS APIs.\n*/\n#ifndef RAPIDJSON_ASSERT\n#include <cassert>\n#define RAPIDJSON_ASSERT(x) assert(x)\n#endif // RAPIDJSON_ASSERT\n\n///////////////////////////////////////////////////////////////////////////////\n// RAPIDJSON_STATIC_ASSERT\n\n// Adopt from boost\n#ifndef RAPIDJSON_STATIC_ASSERT\n#ifndef __clang__\n//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN\n#endif\nRAPIDJSON_NAMESPACE_BEGIN\ntemplate <bool x> struct STATIC_ASSERTION_FAILURE;\ntemplate <> struct STATIC_ASSERTION_FAILURE<true> { enum { value = 1 }; };\ntemplate<int x> struct StaticAssertTest {};\nRAPIDJSON_NAMESPACE_END\n\n#define RAPIDJSON_JOIN(X, Y) RAPIDJSON_DO_JOIN(X, Y)\n#define RAPIDJSON_DO_JOIN(X, Y) RAPIDJSON_DO_JOIN2(X, Y)\n#define RAPIDJSON_DO_JOIN2(X, Y) X##Y\n\n#if defined(__GNUC__)\n#define RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE __attribute__((unused))\n#else\n#define RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE \n#endif\n#ifndef __clang__\n//!@endcond\n#endif\n\n/*! \\def RAPIDJSON_STATIC_ASSERT\n    \\brief (Internal) macro to check for conditions at compile-time\n    \\param x compile-time condition\n    \\hideinitializer\n */\n#define RAPIDJSON_STATIC_ASSERT(x) \\\n    typedef ::RAPIDJSON_NAMESPACE::StaticAssertTest< \\\n      sizeof(::RAPIDJSON_NAMESPACE::STATIC_ASSERTION_FAILURE<bool(x) >)> \\\n    RAPIDJSON_JOIN(StaticAssertTypedef, __LINE__) RAPIDJSON_STATIC_ASSERT_UNUSED_ATTRIBUTE\n#endif\n\n///////////////////////////////////////////////////////////////////////////////\n// RAPIDJSON_LIKELY, RAPIDJSON_UNLIKELY\n\n//! Compiler branching hint for expression with high probability to be true.\n/*!\n    \\ingroup RAPIDJSON_CONFIG\n    \\param x Boolean expression likely to be true.\n*/\n#ifndef RAPIDJSON_LIKELY\n#if defined(__GNUC__) || defined(__clang__)\n#define RAPIDJSON_LIKELY(x) __builtin_expect(!!(x), 1)\n#else\n#define RAPIDJSON_LIKELY(x) (x)\n#endif\n#endif\n\n//! Compiler branching hint for expression with low probability to be true.\n/*!\n    \\ingroup RAPIDJSON_CONFIG\n    \\param x Boolean expression unlikely to be true.\n*/\n#ifndef RAPIDJSON_UNLIKELY\n#if defined(__GNUC__) || defined(__clang__)\n#define RAPIDJSON_UNLIKELY(x) __builtin_expect(!!(x), 0)\n#else\n#define RAPIDJSON_UNLIKELY(x) (x)\n#endif\n#endif\n\n///////////////////////////////////////////////////////////////////////////////\n// Helpers\n\n//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN\n\n#define RAPIDJSON_MULTILINEMACRO_BEGIN do {  \n#define RAPIDJSON_MULTILINEMACRO_END \\\n} while((void)0, 0)\n\n// adopted from Boost\n#define RAPIDJSON_VERSION_CODE(x,y,z) \\\n  (((x)*100000) + ((y)*100) + (z))\n\n///////////////////////////////////////////////////////////////////////////////\n// RAPIDJSON_DIAG_PUSH/POP, RAPIDJSON_DIAG_OFF\n\n#if defined(__GNUC__)\n#define RAPIDJSON_GNUC \\\n    RAPIDJSON_VERSION_CODE(__GNUC__,__GNUC_MINOR__,__GNUC_PATCHLEVEL__)\n#endif\n\n#if defined(__clang__) || (defined(RAPIDJSON_GNUC) && RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4,2,0))\n\n#define RAPIDJSON_PRAGMA(x) _Pragma(RAPIDJSON_STRINGIFY(x))\n#define RAPIDJSON_DIAG_PRAGMA(x) RAPIDJSON_PRAGMA(GCC diagnostic x)\n#define RAPIDJSON_DIAG_OFF(x) \\\n    RAPIDJSON_DIAG_PRAGMA(ignored RAPIDJSON_STRINGIFY(RAPIDJSON_JOIN(-W,x)))\n\n// push/pop support in Clang and GCC>=4.6\n#if defined(__clang__) || (defined(RAPIDJSON_GNUC) && RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4,6,0))\n#define RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_PRAGMA(push)\n#define RAPIDJSON_DIAG_POP  RAPIDJSON_DIAG_PRAGMA(pop)\n#else // GCC >= 4.2, < 4.6\n#define RAPIDJSON_DIAG_PUSH /* ignored */\n#define RAPIDJSON_DIAG_POP /* ignored */\n#endif\n\n#elif defined(_MSC_VER)\n\n// pragma (MSVC specific)\n#define RAPIDJSON_PRAGMA(x) __pragma(x)\n#define RAPIDJSON_DIAG_PRAGMA(x) RAPIDJSON_PRAGMA(warning(x))\n\n#define RAPIDJSON_DIAG_OFF(x) RAPIDJSON_DIAG_PRAGMA(disable: x)\n#define RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_PRAGMA(push)\n#define RAPIDJSON_DIAG_POP  RAPIDJSON_DIAG_PRAGMA(pop)\n\n#else\n\n#define RAPIDJSON_DIAG_OFF(x) /* ignored */\n#define RAPIDJSON_DIAG_PUSH   /* ignored */\n#define RAPIDJSON_DIAG_POP    /* ignored */\n\n#endif // RAPIDJSON_DIAG_*\n\n///////////////////////////////////////////////////////////////////////////////\n// C++11 features\n\n#ifndef RAPIDJSON_HAS_CXX11_RVALUE_REFS\n#if defined(__clang__)\n#if __has_feature(cxx_rvalue_references) && \\\n    (defined(_LIBCPP_VERSION) || defined(__GLIBCXX__) && __GLIBCXX__ >= 20080306)\n#define RAPIDJSON_HAS_CXX11_RVALUE_REFS 1\n#else\n#define RAPIDJSON_HAS_CXX11_RVALUE_REFS 0\n#endif\n#elif (defined(RAPIDJSON_GNUC) && (RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4,3,0)) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || \\\n      (defined(_MSC_VER) && _MSC_VER >= 1600)\n\n#define RAPIDJSON_HAS_CXX11_RVALUE_REFS 1\n#else\n#define RAPIDJSON_HAS_CXX11_RVALUE_REFS 0\n#endif\n#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS\n\n#ifndef RAPIDJSON_HAS_CXX11_NOEXCEPT\n#if defined(__clang__)\n#define RAPIDJSON_HAS_CXX11_NOEXCEPT __has_feature(cxx_noexcept)\n#elif (defined(RAPIDJSON_GNUC) && (RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4,6,0)) && defined(__GXX_EXPERIMENTAL_CXX0X__))\n//    (defined(_MSC_VER) && _MSC_VER >= ????) // not yet supported\n#define RAPIDJSON_HAS_CXX11_NOEXCEPT 1\n#else\n#define RAPIDJSON_HAS_CXX11_NOEXCEPT 0\n#endif\n#endif\n#if RAPIDJSON_HAS_CXX11_NOEXCEPT\n#define RAPIDJSON_NOEXCEPT noexcept\n#else\n#define RAPIDJSON_NOEXCEPT /* noexcept */\n#endif // RAPIDJSON_HAS_CXX11_NOEXCEPT\n\n// no automatic detection, yet\n#ifndef RAPIDJSON_HAS_CXX11_TYPETRAITS\n#define RAPIDJSON_HAS_CXX11_TYPETRAITS 0\n#endif\n\n#ifndef RAPIDJSON_HAS_CXX11_RANGE_FOR\n#if defined(__clang__)\n#define RAPIDJSON_HAS_CXX11_RANGE_FOR __has_feature(cxx_range_for)\n#elif (defined(RAPIDJSON_GNUC) && (RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4,3,0)) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || \\\n      (defined(_MSC_VER) && _MSC_VER >= 1700)\n#define RAPIDJSON_HAS_CXX11_RANGE_FOR 1\n#else\n#define RAPIDJSON_HAS_CXX11_RANGE_FOR 0\n#endif\n#endif // RAPIDJSON_HAS_CXX11_RANGE_FOR\n\n//!@endcond\n\n///////////////////////////////////////////////////////////////////////////////\n// new/delete\n\n#ifndef RAPIDJSON_NEW\n///! customization point for global \\c new\n#define RAPIDJSON_NEW(x) new x\n#endif\n#ifndef RAPIDJSON_DELETE\n///! customization point for global \\c delete\n#define RAPIDJSON_DELETE(x) delete x\n#endif\n\n///////////////////////////////////////////////////////////////////////////////\n// Type\n\n/*! \\namespace rapidjson\n    \\brief main RapidJSON namespace\n    \\see RAPIDJSON_NAMESPACE\n*/\nRAPIDJSON_NAMESPACE_BEGIN\n\n//! Type of JSON value\nenum Type {\n    kNullType = 0,      //!< null\n    kFalseType = 1,     //!< false\n    kTrueType = 2,      //!< true\n    kObjectType = 3,    //!< object\n    kArrayType = 4,     //!< array \n    kStringType = 5,    //!< string\n    kNumberType = 6     //!< number\n};\n\nRAPIDJSON_NAMESPACE_END\n\n#endif // RAPIDJSON_RAPIDJSON_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/reader.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n//\n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed\n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_READER_H_\n#define RAPIDJSON_READER_H_\n\n/*! \\file reader.h */\n\n#include \"allocators.h\"\n#include \"stream.h\"\n#include \"encodedstream.h\"\n#include \"internal/meta.h\"\n#include \"internal/stack.h\"\n#include \"internal/strtod.h\"\n#include <limits>\n\n#if defined(RAPIDJSON_SIMD) && defined(_MSC_VER)\n#include <intrin.h>\n#pragma intrinsic(_BitScanForward)\n#endif\n#ifdef RAPIDJSON_SSE42\n#include <nmmintrin.h>\n#elif defined(RAPIDJSON_SSE2)\n#include <emmintrin.h>\n#endif\n\n#ifdef _MSC_VER\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(4127)  // conditional expression is constant\nRAPIDJSON_DIAG_OFF(4702)  // unreachable code\n#endif\n\n#ifdef __clang__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(old-style-cast)\nRAPIDJSON_DIAG_OFF(padded)\nRAPIDJSON_DIAG_OFF(switch-enum)\n#endif\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(effc++)\n#endif\n\n//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN\n#define RAPIDJSON_NOTHING /* deliberately empty */\n#ifndef RAPIDJSON_PARSE_ERROR_EARLY_RETURN\n#define RAPIDJSON_PARSE_ERROR_EARLY_RETURN(value) \\\n    RAPIDJSON_MULTILINEMACRO_BEGIN \\\n    if (RAPIDJSON_UNLIKELY(HasParseError())) { return value; } \\\n    RAPIDJSON_MULTILINEMACRO_END\n#endif\n#define RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID \\\n    RAPIDJSON_PARSE_ERROR_EARLY_RETURN(RAPIDJSON_NOTHING)\n//!@endcond\n\n/*! \\def RAPIDJSON_PARSE_ERROR_NORETURN\n    \\ingroup RAPIDJSON_ERRORS\n    \\brief Macro to indicate a parse error.\n    \\param parseErrorCode \\ref rapidjson::ParseErrorCode of the error\n    \\param offset  position of the error in JSON input (\\c size_t)\n\n    This macros can be used as a customization point for the internal\n    error handling mechanism of RapidJSON.\n\n    A common usage model is to throw an exception instead of requiring the\n    caller to explicitly check the \\ref rapidjson::GenericReader::Parse's\n    return value:\n\n    \\code\n    #define RAPIDJSON_PARSE_ERROR_NORETURN(parseErrorCode,offset) \\\n       throw ParseException(parseErrorCode, #parseErrorCode, offset)\n\n    #include <stdexcept>               // std::runtime_error\n    #include \"rapidjson/error/error.h\" // rapidjson::ParseResult\n\n    struct ParseException : std::runtime_error, rapidjson::ParseResult {\n      ParseException(rapidjson::ParseErrorCode code, const char* msg, size_t offset)\n        : std::runtime_error(msg), ParseResult(code, offset) {}\n    };\n\n    #include \"rapidjson/reader.h\"\n    \\endcode\n\n    \\see RAPIDJSON_PARSE_ERROR, rapidjson::GenericReader::Parse\n */\n#ifndef RAPIDJSON_PARSE_ERROR_NORETURN\n#define RAPIDJSON_PARSE_ERROR_NORETURN(parseErrorCode, offset) \\\n    RAPIDJSON_MULTILINEMACRO_BEGIN \\\n    RAPIDJSON_ASSERT(!HasParseError()); /* Error can only be assigned once */ \\\n    SetParseError(parseErrorCode, offset); \\\n    RAPIDJSON_MULTILINEMACRO_END\n#endif\n\n/*! \\def RAPIDJSON_PARSE_ERROR\n    \\ingroup RAPIDJSON_ERRORS\n    \\brief (Internal) macro to indicate and handle a parse error.\n    \\param parseErrorCode \\ref rapidjson::ParseErrorCode of the error\n    \\param offset  position of the error in JSON input (\\c size_t)\n\n    Invokes RAPIDJSON_PARSE_ERROR_NORETURN and stops the parsing.\n\n    \\see RAPIDJSON_PARSE_ERROR_NORETURN\n    \\hideinitializer\n */\n#ifndef RAPIDJSON_PARSE_ERROR\n#define RAPIDJSON_PARSE_ERROR(parseErrorCode, offset) \\\n    RAPIDJSON_MULTILINEMACRO_BEGIN \\\n    RAPIDJSON_PARSE_ERROR_NORETURN(parseErrorCode, offset); \\\n    RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID; \\\n    RAPIDJSON_MULTILINEMACRO_END\n#endif\n\n#include \"error/error.h\" // ParseErrorCode, ParseResult\n\nRAPIDJSON_NAMESPACE_BEGIN\n\n///////////////////////////////////////////////////////////////////////////////\n// ParseFlag\n\n/*! \\def RAPIDJSON_PARSE_DEFAULT_FLAGS\n    \\ingroup RAPIDJSON_CONFIG\n    \\brief User-defined kParseDefaultFlags definition.\n\n    User can define this as any \\c ParseFlag combinations.\n*/\n#ifndef RAPIDJSON_PARSE_DEFAULT_FLAGS\n#define RAPIDJSON_PARSE_DEFAULT_FLAGS kParseNoFlags\n#endif\n\n//! Combination of parseFlags\n/*! \\see Reader::Parse, Document::Parse, Document::ParseInsitu, Document::ParseStream\n */\nenum ParseFlag {\n    kParseNoFlags = 0,              //!< No flags are set.\n    kParseInsituFlag = 1,           //!< In-situ(destructive) parsing.\n    kParseValidateEncodingFlag = 2, //!< Validate encoding of JSON strings.\n    kParseIterativeFlag = 4,        //!< Iterative(constant complexity in terms of function call stack size) parsing.\n    kParseStopWhenDoneFlag = 8,     //!< After parsing a complete JSON root from stream, stop further processing the rest of stream. When this flag is used, parser will not generate kParseErrorDocumentRootNotSingular error.\n    kParseFullPrecisionFlag = 16,   //!< Parse number in full precision (but slower).\n    kParseCommentsFlag = 32,        //!< Allow one-line (//) and multi-line (/**/) comments.\n    kParseNumbersAsStringsFlag = 64,    //!< Parse all numbers (ints/doubles) as strings.\n    kParseTrailingCommasFlag = 128, //!< Allow trailing commas at the end of objects and arrays.\n    kParseNanAndInfFlag = 256,      //!< Allow parsing NaN, Inf, Infinity, -Inf and -Infinity as doubles.\n    kParseDefaultFlags = RAPIDJSON_PARSE_DEFAULT_FLAGS  //!< Default parse flags. Can be customized by defining RAPIDJSON_PARSE_DEFAULT_FLAGS\n};\n\n///////////////////////////////////////////////////////////////////////////////\n// Handler\n\n/*! \\class rapidjson::Handler\n    \\brief Concept for receiving events from GenericReader upon parsing.\n    The functions return true if no error occurs. If they return false,\n    the event publisher should terminate the process.\n\\code\nconcept Handler {\n    typename Ch;\n\n    bool Null();\n    bool Bool(bool b);\n    bool Int(int i);\n    bool Uint(unsigned i);\n    bool Int64(int64_t i);\n    bool Uint64(uint64_t i);\n    bool Double(double d);\n    /// enabled via kParseNumbersAsStringsFlag, string is not null-terminated (use length)\n    bool RawNumber(const Ch* str, SizeType length, bool copy);\n    bool String(const Ch* str, SizeType length, bool copy);\n    bool StartObject();\n    bool Key(const Ch* str, SizeType length, bool copy);\n    bool EndObject(SizeType memberCount);\n    bool StartArray();\n    bool EndArray(SizeType elementCount);\n};\n\\endcode\n*/\n///////////////////////////////////////////////////////////////////////////////\n// BaseReaderHandler\n\n//! Default implementation of Handler.\n/*! This can be used as base class of any reader handler.\n    \\note implements Handler concept\n*/\ntemplate<typename Encoding = UTF8<>, typename Derived = void>\nstruct BaseReaderHandler {\n    typedef typename Encoding::Ch Ch;\n\n    typedef typename internal::SelectIf<internal::IsSame<Derived, void>, BaseReaderHandler, Derived>::Type Override;\n\n    bool Default() { return true; }\n    bool Null() { return static_cast<Override&>(*this).Default(); }\n    bool Bool(bool) { return static_cast<Override&>(*this).Default(); }\n    bool Int(int) { return static_cast<Override&>(*this).Default(); }\n    bool Uint(unsigned) { return static_cast<Override&>(*this).Default(); }\n    bool Int64(int64_t) { return static_cast<Override&>(*this).Default(); }\n    bool Uint64(uint64_t) { return static_cast<Override&>(*this).Default(); }\n    bool Double(double) { return static_cast<Override&>(*this).Default(); }\n    /// enabled via kParseNumbersAsStringsFlag, string is not null-terminated (use length)\n    bool RawNumber(const Ch* str, SizeType len, bool copy) { return static_cast<Override&>(*this).String(str, len, copy); }\n    bool String(const Ch*, SizeType, bool) { return static_cast<Override&>(*this).Default(); }\n    bool StartObject() { return static_cast<Override&>(*this).Default(); }\n    bool Key(const Ch* str, SizeType len, bool copy) { return static_cast<Override&>(*this).String(str, len, copy); }\n    bool EndObject(SizeType) { return static_cast<Override&>(*this).Default(); }\n    bool StartArray() { return static_cast<Override&>(*this).Default(); }\n    bool EndArray(SizeType) { return static_cast<Override&>(*this).Default(); }\n};\n\n///////////////////////////////////////////////////////////////////////////////\n// StreamLocalCopy\n\nnamespace internal {\n\ntemplate<typename Stream, int = StreamTraits<Stream>::copyOptimization>\nclass StreamLocalCopy;\n\n//! Do copy optimization.\ntemplate<typename Stream>\nclass StreamLocalCopy<Stream, 1> {\npublic:\n    StreamLocalCopy(Stream& original) : s(original), original_(original) {}\n    ~StreamLocalCopy() { original_ = s; }\n\n    Stream s;\n\nprivate:\n    StreamLocalCopy& operator=(const StreamLocalCopy&) /* = delete */;\n\n    Stream& original_;\n};\n\n//! Keep reference.\ntemplate<typename Stream>\nclass StreamLocalCopy<Stream, 0> {\npublic:\n    StreamLocalCopy(Stream& original) : s(original) {}\n\n    Stream& s;\n\nprivate:\n    StreamLocalCopy& operator=(const StreamLocalCopy&) /* = delete */;\n};\n\n} // namespace internal\n\n///////////////////////////////////////////////////////////////////////////////\n// SkipWhitespace\n\n//! Skip the JSON white spaces in a stream.\n/*! \\param is A input stream for skipping white spaces.\n    \\note This function has SSE2/SSE4.2 specialization.\n*/\ntemplate<typename InputStream>\nvoid SkipWhitespace(InputStream& is) {\n    internal::StreamLocalCopy<InputStream> copy(is);\n    InputStream& s(copy.s);\n\n    typename InputStream::Ch c;\n    while ((c = s.Peek()) == ' ' || c == '\\n' || c == '\\r' || c == '\\t')\n        s.Take();\n}\n\ninline const char* SkipWhitespace(const char* p, const char* end) {\n    while (p != end && (*p == ' ' || *p == '\\n' || *p == '\\r' || *p == '\\t'))\n        ++p;\n    return p;\n}\n\n#ifdef RAPIDJSON_SSE42\n//! Skip whitespace with SSE 4.2 pcmpistrm instruction, testing 16 8-byte characters at once.\ninline const char *SkipWhitespace_SIMD(const char* p) {\n    // Fast return for single non-whitespace\n    if (*p == ' ' || *p == '\\n' || *p == '\\r' || *p == '\\t')\n        ++p;\n    else\n        return p;\n\n    // 16-byte align to the next boundary\n    const char* nextAligned = reinterpret_cast<const char*>((reinterpret_cast<size_t>(p) + 15) & static_cast<size_t>(~15));\n    while (p != nextAligned)\n        if (*p == ' ' || *p == '\\n' || *p == '\\r' || *p == '\\t')\n            ++p;\n        else\n            return p;\n\n    // The rest of string using SIMD\n    static const char whitespace[16] = \" \\n\\r\\t\";\n    const __m128i w = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&whitespace[0]));\n\n    for (;; p += 16) {\n        const __m128i s = _mm_load_si128(reinterpret_cast<const __m128i *>(p));\n        const int r = _mm_cvtsi128_si32(_mm_cmpistrm(w, s, _SIDD_UBYTE_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK | _SIDD_NEGATIVE_POLARITY));\n        if (r != 0) {   // some of characters is non-whitespace\n#ifdef _MSC_VER         // Find the index of first non-whitespace\n            unsigned long offset;\n            _BitScanForward(&offset, r);\n            return p + offset;\n#else\n            return p + __builtin_ffs(r) - 1;\n#endif\n        }\n    }\n}\n\ninline const char *SkipWhitespace_SIMD(const char* p, const char* end) {\n    // Fast return for single non-whitespace\n    if (p != end && (*p == ' ' || *p == '\\n' || *p == '\\r' || *p == '\\t'))\n        ++p;\n    else\n        return p;\n\n    // The middle of string using SIMD\n    static const char whitespace[16] = \" \\n\\r\\t\";\n    const __m128i w = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&whitespace[0]));\n\n    for (; p <= end - 16; p += 16) {\n        const __m128i s = _mm_loadu_si128(reinterpret_cast<const __m128i *>(p));\n        const int r = _mm_cvtsi128_si32(_mm_cmpistrm(w, s, _SIDD_UBYTE_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_BIT_MASK | _SIDD_NEGATIVE_POLARITY));\n        if (r != 0) {   // some of characters is non-whitespace\n#ifdef _MSC_VER         // Find the index of first non-whitespace\n            unsigned long offset;\n            _BitScanForward(&offset, r);\n            return p + offset;\n#else\n            return p + __builtin_ffs(r) - 1;\n#endif\n        }\n    }\n\n    return SkipWhitespace(p, end);\n}\n\n#elif defined(RAPIDJSON_SSE2)\n\n//! Skip whitespace with SSE2 instructions, testing 16 8-byte characters at once.\ninline const char *SkipWhitespace_SIMD(const char* p) {\n    // Fast return for single non-whitespace\n    if (*p == ' ' || *p == '\\n' || *p == '\\r' || *p == '\\t')\n        ++p;\n    else\n        return p;\n\n    // 16-byte align to the next boundary\n    const char* nextAligned = reinterpret_cast<const char*>((reinterpret_cast<size_t>(p) + 15) & static_cast<size_t>(~15));\n    while (p != nextAligned)\n        if (*p == ' ' || *p == '\\n' || *p == '\\r' || *p == '\\t')\n            ++p;\n        else\n            return p;\n\n    // The rest of string\n    #define C16(c) { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c }\n    static const char whitespaces[4][16] = { C16(' '), C16('\\n'), C16('\\r'), C16('\\t') };\n    #undef C16\n\n    const __m128i w0 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&whitespaces[0][0]));\n    const __m128i w1 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&whitespaces[1][0]));\n    const __m128i w2 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&whitespaces[2][0]));\n    const __m128i w3 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&whitespaces[3][0]));\n\n    for (;; p += 16) {\n        const __m128i s = _mm_load_si128(reinterpret_cast<const __m128i *>(p));\n        __m128i x = _mm_cmpeq_epi8(s, w0);\n        x = _mm_or_si128(x, _mm_cmpeq_epi8(s, w1));\n        x = _mm_or_si128(x, _mm_cmpeq_epi8(s, w2));\n        x = _mm_or_si128(x, _mm_cmpeq_epi8(s, w3));\n        unsigned short r = static_cast<unsigned short>(~_mm_movemask_epi8(x));\n        if (r != 0) {   // some of characters may be non-whitespace\n#ifdef _MSC_VER         // Find the index of first non-whitespace\n            unsigned long offset;\n            _BitScanForward(&offset, r);\n            return p + offset;\n#else\n            return p + __builtin_ffs(r) - 1;\n#endif\n        }\n    }\n}\n\ninline const char *SkipWhitespace_SIMD(const char* p, const char* end) {\n    // Fast return for single non-whitespace\n    if (p != end && (*p == ' ' || *p == '\\n' || *p == '\\r' || *p == '\\t'))\n        ++p;\n    else\n        return p;\n\n    // The rest of string\n    #define C16(c) { c, c, c, c, c, c, c, c, c, c, c, c, c, c, c, c }\n    static const char whitespaces[4][16] = { C16(' '), C16('\\n'), C16('\\r'), C16('\\t') };\n    #undef C16\n\n    const __m128i w0 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&whitespaces[0][0]));\n    const __m128i w1 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&whitespaces[1][0]));\n    const __m128i w2 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&whitespaces[2][0]));\n    const __m128i w3 = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&whitespaces[3][0]));\n\n    for (; p <= end - 16; p += 16) {\n        const __m128i s = _mm_loadu_si128(reinterpret_cast<const __m128i *>(p));\n        __m128i x = _mm_cmpeq_epi8(s, w0);\n        x = _mm_or_si128(x, _mm_cmpeq_epi8(s, w1));\n        x = _mm_or_si128(x, _mm_cmpeq_epi8(s, w2));\n        x = _mm_or_si128(x, _mm_cmpeq_epi8(s, w3));\n        unsigned short r = static_cast<unsigned short>(~_mm_movemask_epi8(x));\n        if (r != 0) {   // some of characters may be non-whitespace\n#ifdef _MSC_VER         // Find the index of first non-whitespace\n            unsigned long offset;\n            _BitScanForward(&offset, r);\n            return p + offset;\n#else\n            return p + __builtin_ffs(r) - 1;\n#endif\n        }\n    }\n\n    return SkipWhitespace(p, end);\n}\n\n#endif // RAPIDJSON_SSE2\n\n#ifdef RAPIDJSON_SIMD\n//! Template function specialization for InsituStringStream\ntemplate<> inline void SkipWhitespace(InsituStringStream& is) {\n    is.src_ = const_cast<char*>(SkipWhitespace_SIMD(is.src_));\n}\n\n//! Template function specialization for StringStream\ntemplate<> inline void SkipWhitespace(StringStream& is) {\n    is.src_ = SkipWhitespace_SIMD(is.src_);\n}\n\ntemplate<> inline void SkipWhitespace(EncodedInputStream<UTF8<>, MemoryStream>& is) {\n    is.is_.src_ = SkipWhitespace_SIMD(is.is_.src_, is.is_.end_);\n}\n#endif // RAPIDJSON_SIMD\n\n///////////////////////////////////////////////////////////////////////////////\n// GenericReader\n\n//! SAX-style JSON parser. Use \\ref Reader for UTF8 encoding and default allocator.\n/*! GenericReader parses JSON text from a stream, and send events synchronously to an\n    object implementing Handler concept.\n\n    It needs to allocate a stack for storing a single decoded string during\n    non-destructive parsing.\n\n    For in-situ parsing, the decoded string is directly written to the source\n    text string, no temporary buffer is required.\n\n    A GenericReader object can be reused for parsing multiple JSON text.\n\n    \\tparam SourceEncoding Encoding of the input stream.\n    \\tparam TargetEncoding Encoding of the parse output.\n    \\tparam StackAllocator Allocator type for stack.\n*/\ntemplate <typename SourceEncoding, typename TargetEncoding, typename StackAllocator = CrtAllocator>\nclass GenericReader {\npublic:\n    typedef typename SourceEncoding::Ch Ch; //!< SourceEncoding character type\n\n    //! Constructor.\n    /*! \\param stackAllocator Optional allocator for allocating stack memory. (Only use for non-destructive parsing)\n        \\param stackCapacity stack capacity in bytes for storing a single decoded string.  (Only use for non-destructive parsing)\n    */\n    GenericReader(StackAllocator* stackAllocator = 0, size_t stackCapacity = kDefaultStackCapacity) : stack_(stackAllocator, stackCapacity), parseResult_() {}\n\n    //! Parse JSON text.\n    /*! \\tparam parseFlags Combination of \\ref ParseFlag.\n        \\tparam InputStream Type of input stream, implementing Stream concept.\n        \\tparam Handler Type of handler, implementing Handler concept.\n        \\param is Input stream to be parsed.\n        \\param handler The handler to receive events.\n        \\return Whether the parsing is successful.\n    */\n    template <unsigned parseFlags, typename InputStream, typename Handler>\n    ParseResult Parse(InputStream& is, Handler& handler) {\n        if (parseFlags & kParseIterativeFlag)\n            return IterativeParse<parseFlags>(is, handler);\n\n        parseResult_.Clear();\n\n        ClearStackOnExit scope(*this);\n\n        SkipWhitespaceAndComments<parseFlags>(is);\n        RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_);\n\n        if (RAPIDJSON_UNLIKELY(is.Peek() == '\\0')) {\n            RAPIDJSON_PARSE_ERROR_NORETURN(kParseErrorDocumentEmpty, is.Tell());\n            RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_);\n        }\n        else {\n            ParseValue<parseFlags>(is, handler);\n            RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_);\n\n            if (!(parseFlags & kParseStopWhenDoneFlag)) {\n                SkipWhitespaceAndComments<parseFlags>(is);\n                RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_);\n\n                if (RAPIDJSON_UNLIKELY(is.Peek() != '\\0')) {\n                    RAPIDJSON_PARSE_ERROR_NORETURN(kParseErrorDocumentRootNotSingular, is.Tell());\n                    RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_);\n                }\n            }\n        }\n\n        return parseResult_;\n    }\n\n    //! Parse JSON text (with \\ref kParseDefaultFlags)\n    /*! \\tparam InputStream Type of input stream, implementing Stream concept\n        \\tparam Handler Type of handler, implementing Handler concept.\n        \\param is Input stream to be parsed.\n        \\param handler The handler to receive events.\n        \\return Whether the parsing is successful.\n    */\n    template <typename InputStream, typename Handler>\n    ParseResult Parse(InputStream& is, Handler& handler) {\n        return Parse<kParseDefaultFlags>(is, handler);\n    }\n\n    //! Whether a parse error has occured in the last parsing.\n    bool HasParseError() const { return parseResult_.IsError(); }\n\n    //! Get the \\ref ParseErrorCode of last parsing.\n    ParseErrorCode GetParseErrorCode() const { return parseResult_.Code(); }\n\n    //! Get the position of last parsing error in input, 0 otherwise.\n    size_t GetErrorOffset() const { return parseResult_.Offset(); }\n\nprotected:\n    void SetParseError(ParseErrorCode code, size_t offset) { parseResult_.Set(code, offset); }\n\nprivate:\n    // Prohibit copy constructor & assignment operator.\n    GenericReader(const GenericReader&);\n    GenericReader& operator=(const GenericReader&);\n\n    void ClearStack() { stack_.Clear(); }\n\n    // clear stack on any exit from ParseStream, e.g. due to exception\n    struct ClearStackOnExit {\n        explicit ClearStackOnExit(GenericReader& r) : r_(r) {}\n        ~ClearStackOnExit() { r_.ClearStack(); }\n    private:\n        GenericReader& r_;\n        ClearStackOnExit(const ClearStackOnExit&);\n        ClearStackOnExit& operator=(const ClearStackOnExit&);\n    };\n\n    template<unsigned parseFlags, typename InputStream>\n    void SkipWhitespaceAndComments(InputStream& is) {\n        SkipWhitespace(is);\n\n        if (parseFlags & kParseCommentsFlag) {\n            while (RAPIDJSON_UNLIKELY(Consume(is, '/'))) {\n                if (Consume(is, '*')) {\n                    while (true) {\n                        if (RAPIDJSON_UNLIKELY(is.Peek() == '\\0'))\n                            RAPIDJSON_PARSE_ERROR(kParseErrorUnspecificSyntaxError, is.Tell());\n                        else if (Consume(is, '*')) {\n                            if (Consume(is, '/'))\n                                break;\n                        }\n                        else\n                            is.Take();\n                    }\n                }\n                else if (RAPIDJSON_LIKELY(Consume(is, '/')))\n                    while (is.Peek() != '\\0' && is.Take() != '\\n');\n                else\n                    RAPIDJSON_PARSE_ERROR(kParseErrorUnspecificSyntaxError, is.Tell());\n\n                SkipWhitespace(is);\n            }\n        }\n    }\n\n    // Parse object: { string : value, ... }\n    template<unsigned parseFlags, typename InputStream, typename Handler>\n    void ParseObject(InputStream& is, Handler& handler) {\n        RAPIDJSON_ASSERT(is.Peek() == '{');\n        is.Take();  // Skip '{'\n\n        if (RAPIDJSON_UNLIKELY(!handler.StartObject()))\n            RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell());\n\n        SkipWhitespaceAndComments<parseFlags>(is);\n        RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;\n\n        if (Consume(is, '}')) {\n            if (RAPIDJSON_UNLIKELY(!handler.EndObject(0)))  // empty object\n                RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell());\n            return;\n        }\n\n        for (SizeType memberCount = 0;;) {\n            if (RAPIDJSON_UNLIKELY(is.Peek() != '\"'))\n                RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissName, is.Tell());\n\n            ParseString<parseFlags>(is, handler, true);\n            RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;\n\n            SkipWhitespaceAndComments<parseFlags>(is);\n            RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;\n\n            if (RAPIDJSON_UNLIKELY(!Consume(is, ':')))\n                RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissColon, is.Tell());\n\n            SkipWhitespaceAndComments<parseFlags>(is);\n            RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;\n\n            ParseValue<parseFlags>(is, handler);\n            RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;\n\n            SkipWhitespaceAndComments<parseFlags>(is);\n            RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;\n\n            ++memberCount;\n\n            switch (is.Peek()) {\n                case ',':\n                    is.Take();\n                    SkipWhitespaceAndComments<parseFlags>(is);\n                    RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;\n                    break;\n                case '}':\n                    is.Take();\n                    if (RAPIDJSON_UNLIKELY(!handler.EndObject(memberCount)))\n                        RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell());\n                    return;\n                default:\n                    RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissCommaOrCurlyBracket, is.Tell()); break; // This useless break is only for making warning and coverage happy\n            }\n\n            if (parseFlags & kParseTrailingCommasFlag) {\n                if (is.Peek() == '}') {\n                    if (RAPIDJSON_UNLIKELY(!handler.EndObject(memberCount)))\n                        RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell());\n                    is.Take();\n                    return;\n                }\n            }\n        }\n    }\n\n    // Parse array: [ value, ... ]\n    template<unsigned parseFlags, typename InputStream, typename Handler>\n    void ParseArray(InputStream& is, Handler& handler) {\n        RAPIDJSON_ASSERT(is.Peek() == '[');\n        is.Take();  // Skip '['\n\n        if (RAPIDJSON_UNLIKELY(!handler.StartArray()))\n            RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell());\n\n        SkipWhitespaceAndComments<parseFlags>(is);\n        RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;\n\n        if (Consume(is, ']')) {\n            if (RAPIDJSON_UNLIKELY(!handler.EndArray(0))) // empty array\n                RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell());\n            return;\n        }\n\n        for (SizeType elementCount = 0;;) {\n            ParseValue<parseFlags>(is, handler);\n            RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;\n\n            ++elementCount;\n            SkipWhitespaceAndComments<parseFlags>(is);\n            RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;\n\n            if (Consume(is, ',')) {\n                SkipWhitespaceAndComments<parseFlags>(is);\n                RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;\n            }\n            else if (Consume(is, ']')) {\n                if (RAPIDJSON_UNLIKELY(!handler.EndArray(elementCount)))\n                    RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell());\n                return;\n            }\n            else\n                RAPIDJSON_PARSE_ERROR(kParseErrorArrayMissCommaOrSquareBracket, is.Tell());\n\n            if (parseFlags & kParseTrailingCommasFlag) {\n                if (is.Peek() == ']') {\n                    if (RAPIDJSON_UNLIKELY(!handler.EndArray(elementCount)))\n                        RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell());\n                    is.Take();\n                    return;\n                }\n            }\n        }\n    }\n\n    template<unsigned parseFlags, typename InputStream, typename Handler>\n    void ParseNull(InputStream& is, Handler& handler) {\n        RAPIDJSON_ASSERT(is.Peek() == 'n');\n        is.Take();\n\n        if (RAPIDJSON_LIKELY(Consume(is, 'u') && Consume(is, 'l') && Consume(is, 'l'))) {\n            if (RAPIDJSON_UNLIKELY(!handler.Null()))\n                RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell());\n        }\n        else\n            RAPIDJSON_PARSE_ERROR(kParseErrorValueInvalid, is.Tell());\n    }\n\n    template<unsigned parseFlags, typename InputStream, typename Handler>\n    void ParseTrue(InputStream& is, Handler& handler) {\n        RAPIDJSON_ASSERT(is.Peek() == 't');\n        is.Take();\n\n        if (RAPIDJSON_LIKELY(Consume(is, 'r') && Consume(is, 'u') && Consume(is, 'e'))) {\n            if (RAPIDJSON_UNLIKELY(!handler.Bool(true)))\n                RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell());\n        }\n        else\n            RAPIDJSON_PARSE_ERROR(kParseErrorValueInvalid, is.Tell());\n    }\n\n    template<unsigned parseFlags, typename InputStream, typename Handler>\n    void ParseFalse(InputStream& is, Handler& handler) {\n        RAPIDJSON_ASSERT(is.Peek() == 'f');\n        is.Take();\n\n        if (RAPIDJSON_LIKELY(Consume(is, 'a') && Consume(is, 'l') && Consume(is, 's') && Consume(is, 'e'))) {\n            if (RAPIDJSON_UNLIKELY(!handler.Bool(false)))\n                RAPIDJSON_PARSE_ERROR(kParseErrorTermination, is.Tell());\n        }\n        else\n            RAPIDJSON_PARSE_ERROR(kParseErrorValueInvalid, is.Tell());\n    }\n\n    template<typename InputStream>\n    RAPIDJSON_FORCEINLINE static bool Consume(InputStream& is, typename InputStream::Ch expect) {\n        if (RAPIDJSON_LIKELY(is.Peek() == expect)) {\n            is.Take();\n            return true;\n        }\n        else\n            return false;\n    }\n\n    // Helper function to parse four hexidecimal digits in \\uXXXX in ParseString().\n    template<typename InputStream>\n    unsigned ParseHex4(InputStream& is, size_t escapeOffset) {\n        unsigned codepoint = 0;\n        for (int i = 0; i < 4; i++) {\n            Ch c = is.Peek();\n            codepoint <<= 4;\n            codepoint += static_cast<unsigned>(c);\n            if (c >= '0' && c <= '9')\n                codepoint -= '0';\n            else if (c >= 'A' && c <= 'F')\n                codepoint -= 'A' - 10;\n            else if (c >= 'a' && c <= 'f')\n                codepoint -= 'a' - 10;\n            else {\n                RAPIDJSON_PARSE_ERROR_NORETURN(kParseErrorStringUnicodeEscapeInvalidHex, escapeOffset);\n                RAPIDJSON_PARSE_ERROR_EARLY_RETURN(0);\n            }\n            is.Take();\n        }\n        return codepoint;\n    }\n\n    template <typename CharType>\n    class StackStream {\n    public:\n        typedef CharType Ch;\n\n        StackStream(internal::Stack<StackAllocator>& stack) : stack_(stack), length_(0) {}\n        RAPIDJSON_FORCEINLINE void Put(Ch c) {\n            *stack_.template Push<Ch>() = c;\n            ++length_;\n        }\n\n        RAPIDJSON_FORCEINLINE void* Push(SizeType count) {\n            length_ += count;\n            return stack_.template Push<Ch>(count);\n        }\n\n        size_t Length() const { return length_; }\n\n        Ch* Pop() {\n            return stack_.template Pop<Ch>(length_);\n        }\n\n    private:\n        StackStream(const StackStream&);\n        StackStream& operator=(const StackStream&);\n\n        internal::Stack<StackAllocator>& stack_;\n        SizeType length_;\n    };\n\n    // Parse string and generate String event. Different code paths for kParseInsituFlag.\n    template<unsigned parseFlags, typename InputStream, typename Handler>\n    void ParseString(InputStream& is, Handler& handler, bool isKey = false) {\n        internal::StreamLocalCopy<InputStream> copy(is);\n        InputStream& s(copy.s);\n\n        RAPIDJSON_ASSERT(s.Peek() == '\\\"');\n        s.Take();  // Skip '\\\"'\n\n        bool success = false;\n        if (parseFlags & kParseInsituFlag) {\n            typename InputStream::Ch *head = s.PutBegin();\n            ParseStringToStream<parseFlags, SourceEncoding, SourceEncoding>(s, s);\n            RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;\n            size_t length = s.PutEnd(head) - 1;\n            RAPIDJSON_ASSERT(length <= 0xFFFFFFFF);\n            const typename TargetEncoding::Ch* const str = reinterpret_cast<typename TargetEncoding::Ch*>(head);\n            success = (isKey ? handler.Key(str, SizeType(length), false) : handler.String(str, SizeType(length), false));\n        }\n        else {\n            StackStream<typename TargetEncoding::Ch> stackStream(stack_);\n            ParseStringToStream<parseFlags, SourceEncoding, TargetEncoding>(s, stackStream);\n            RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;\n            SizeType length = static_cast<SizeType>(stackStream.Length()) - 1;\n            const typename TargetEncoding::Ch* const str = stackStream.Pop();\n            success = (isKey ? handler.Key(str, length, true) : handler.String(str, length, true));\n        }\n        if (RAPIDJSON_UNLIKELY(!success))\n            RAPIDJSON_PARSE_ERROR(kParseErrorTermination, s.Tell());\n    }\n\n    // Parse string to an output is\n    // This function handles the prefix/suffix double quotes, escaping, and optional encoding validation.\n    template<unsigned parseFlags, typename SEncoding, typename TEncoding, typename InputStream, typename OutputStream>\n    RAPIDJSON_FORCEINLINE void ParseStringToStream(InputStream& is, OutputStream& os) {\n//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN\n#define Z16 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n        static const char escape[256] = {\n            Z16, Z16, 0, 0,'\\\"', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'/',\n            Z16, Z16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,'\\\\', 0, 0, 0,\n            0, 0,'\\b', 0, 0, 0,'\\f', 0, 0, 0, 0, 0, 0, 0,'\\n', 0,\n            0, 0,'\\r', 0,'\\t', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n            Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16\n        };\n#undef Z16\n//!@endcond\n\n        for (;;) {\n            // Scan and copy string before \"\\\\\\\"\" or < 0x20. This is an optional optimzation.\n            if (!(parseFlags & kParseValidateEncodingFlag))\n                ScanCopyUnescapedString(is, os);\n\n            Ch c = is.Peek();\n            if (RAPIDJSON_UNLIKELY(c == '\\\\')) {    // Escape\n                size_t escapeOffset = is.Tell();    // For invalid escaping, report the inital '\\\\' as error offset\n                is.Take();\n                Ch e = is.Peek();\n                if ((sizeof(Ch) == 1 || unsigned(e) < 256) && RAPIDJSON_LIKELY(escape[static_cast<unsigned char>(e)])) {\n                    is.Take();\n                    os.Put(static_cast<typename TEncoding::Ch>(escape[static_cast<unsigned char>(e)]));\n                }\n                else if (RAPIDJSON_LIKELY(e == 'u')) {    // Unicode\n                    is.Take();\n                    unsigned codepoint = ParseHex4(is, escapeOffset);\n                    RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;\n                    if (RAPIDJSON_UNLIKELY(codepoint >= 0xD800 && codepoint <= 0xDBFF)) {\n                        // Handle UTF-16 surrogate pair\n                        if (RAPIDJSON_UNLIKELY(!Consume(is, '\\\\') || !Consume(is, 'u')))\n                            RAPIDJSON_PARSE_ERROR(kParseErrorStringUnicodeSurrogateInvalid, escapeOffset);\n                        unsigned codepoint2 = ParseHex4(is, escapeOffset);\n                        RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID;\n                        if (RAPIDJSON_UNLIKELY(codepoint2 < 0xDC00 || codepoint2 > 0xDFFF))\n                            RAPIDJSON_PARSE_ERROR(kParseErrorStringUnicodeSurrogateInvalid, escapeOffset);\n                        codepoint = (((codepoint - 0xD800) << 10) | (codepoint2 - 0xDC00)) + 0x10000;\n                    }\n                    TEncoding::Encode(os, codepoint);\n                }\n                else\n                    RAPIDJSON_PARSE_ERROR(kParseErrorStringEscapeInvalid, escapeOffset);\n            }\n            else if (RAPIDJSON_UNLIKELY(c == '\"')) {    // Closing double quote\n                is.Take();\n                os.Put('\\0');   // null-terminate the string\n                return;\n            }\n            else if (RAPIDJSON_UNLIKELY(static_cast<unsigned>(c) < 0x20)) { // RFC 4627: unescaped = %x20-21 / %x23-5B / %x5D-10FFFF\n                if (c == '\\0')\n                    RAPIDJSON_PARSE_ERROR(kParseErrorStringMissQuotationMark, is.Tell());\n                else\n                    RAPIDJSON_PARSE_ERROR(kParseErrorStringEscapeInvalid, is.Tell());\n            }\n            else {\n                size_t offset = is.Tell();\n                if (RAPIDJSON_UNLIKELY((parseFlags & kParseValidateEncodingFlag ?\n                    !Transcoder<SEncoding, TEncoding>::Validate(is, os) :\n                    !Transcoder<SEncoding, TEncoding>::Transcode(is, os))))\n                    RAPIDJSON_PARSE_ERROR(kParseErrorStringInvalidEncoding, offset);\n            }\n        }\n    }\n\n    template<typename InputStream, typename OutputStream>\n    static RAPIDJSON_FORCEINLINE void ScanCopyUnescapedString(InputStream&, OutputStream&) {\n            // Do nothing for generic version\n    }\n\n#if defined(RAPIDJSON_SSE2) || defined(RAPIDJSON_SSE42)\n    // StringStream -> StackStream<char>\n    static RAPIDJSON_FORCEINLINE void ScanCopyUnescapedString(StringStream& is, StackStream<char>& os) {\n        const char* p = is.src_;\n\n        // Scan one by one until alignment (unaligned load may cross page boundary and cause crash)\n        const char* nextAligned = reinterpret_cast<const char*>((reinterpret_cast<size_t>(p) + 15) & static_cast<size_t>(~15));\n        while (p != nextAligned)\n            if (RAPIDJSON_UNLIKELY(*p == '\\\"') || RAPIDJSON_UNLIKELY(*p == '\\\\') || RAPIDJSON_UNLIKELY(static_cast<unsigned>(*p) < 0x20)) {\n                is.src_ = p;\n                return;\n            }\n            else\n                os.Put(*p++);\n\n        // The rest of string using SIMD\n        static const char dquote[16] = { '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"' };\n        static const char bslash[16] = { '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\' };\n        static const char space[16]  = { 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19 };\n        const __m128i dq = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&dquote[0]));\n        const __m128i bs = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&bslash[0]));\n        const __m128i sp = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&space[0]));\n\n        for (;; p += 16) {\n            const __m128i s = _mm_load_si128(reinterpret_cast<const __m128i *>(p));\n            const __m128i t1 = _mm_cmpeq_epi8(s, dq);\n            const __m128i t2 = _mm_cmpeq_epi8(s, bs);\n            const __m128i t3 = _mm_cmpeq_epi8(_mm_max_epu8(s, sp), sp); // s < 0x20 <=> max(s, 0x19) == 0x19\n            const __m128i x = _mm_or_si128(_mm_or_si128(t1, t2), t3);\n            unsigned short r = static_cast<unsigned short>(_mm_movemask_epi8(x));\n            if (RAPIDJSON_UNLIKELY(r != 0)) {   // some of characters is escaped\n                SizeType length;\n    #ifdef _MSC_VER         // Find the index of first escaped\n                unsigned long offset;\n                _BitScanForward(&offset, r);\n                length = offset;\n    #else\n                length = static_cast<SizeType>(__builtin_ffs(r) - 1);\n    #endif\n                char* q = reinterpret_cast<char*>(os.Push(length));\n                for (size_t i = 0; i < length; i++)\n                    q[i] = p[i];\n\n                p += length;\n                break;\n            }\n            _mm_storeu_si128(reinterpret_cast<__m128i *>(os.Push(16)), s);\n        }\n\n        is.src_ = p;\n    }\n\n    // InsituStringStream -> InsituStringStream\n    static RAPIDJSON_FORCEINLINE void ScanCopyUnescapedString(InsituStringStream& is, InsituStringStream& os) {\n        RAPIDJSON_ASSERT(&is == &os);\n        (void)os;\n\n        if (is.src_ == is.dst_) {\n            SkipUnescapedString(is);\n            return;\n        }\n\n        char* p = is.src_;\n        char *q = is.dst_;\n\n        // Scan one by one until alignment (unaligned load may cross page boundary and cause crash)\n        const char* nextAligned = reinterpret_cast<const char*>((reinterpret_cast<size_t>(p) + 15) & static_cast<size_t>(~15));\n        while (p != nextAligned)\n            if (RAPIDJSON_UNLIKELY(*p == '\\\"') || RAPIDJSON_UNLIKELY(*p == '\\\\') || RAPIDJSON_UNLIKELY(static_cast<unsigned>(*p) < 0x20)) {\n                is.src_ = p;\n                is.dst_ = q;\n                return;\n            }\n            else\n                *q++ = *p++;\n\n        // The rest of string using SIMD\n        static const char dquote[16] = { '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"' };\n        static const char bslash[16] = { '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\' };\n        static const char space[16] = { 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19 };\n        const __m128i dq = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&dquote[0]));\n        const __m128i bs = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&bslash[0]));\n        const __m128i sp = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&space[0]));\n\n        for (;; p += 16, q += 16) {\n            const __m128i s = _mm_load_si128(reinterpret_cast<const __m128i *>(p));\n            const __m128i t1 = _mm_cmpeq_epi8(s, dq);\n            const __m128i t2 = _mm_cmpeq_epi8(s, bs);\n            const __m128i t3 = _mm_cmpeq_epi8(_mm_max_epu8(s, sp), sp); // s < 0x20 <=> max(s, 0x19) == 0x19\n            const __m128i x = _mm_or_si128(_mm_or_si128(t1, t2), t3);\n            unsigned short r = static_cast<unsigned short>(_mm_movemask_epi8(x));\n            if (RAPIDJSON_UNLIKELY(r != 0)) {   // some of characters is escaped\n                size_t length;\n#ifdef _MSC_VER         // Find the index of first escaped\n                unsigned long offset;\n                _BitScanForward(&offset, r);\n                length = offset;\n#else\n                length = static_cast<size_t>(__builtin_ffs(r) - 1);\n#endif\n                for (const char* pend = p + length; p != pend; )\n                    *q++ = *p++;\n                break;\n            }\n            _mm_storeu_si128(reinterpret_cast<__m128i *>(q), s);\n        }\n\n        is.src_ = p;\n        is.dst_ = q;\n    }\n\n    // When read/write pointers are the same for insitu stream, just skip unescaped characters\n    static RAPIDJSON_FORCEINLINE void SkipUnescapedString(InsituStringStream& is) {\n        RAPIDJSON_ASSERT(is.src_ == is.dst_);\n        char* p = is.src_;\n\n        // Scan one by one until alignment (unaligned load may cross page boundary and cause crash)\n        const char* nextAligned = reinterpret_cast<const char*>((reinterpret_cast<size_t>(p) + 15) & static_cast<size_t>(~15));\n        for (; p != nextAligned; p++)\n            if (RAPIDJSON_UNLIKELY(*p == '\\\"') || RAPIDJSON_UNLIKELY(*p == '\\\\') || RAPIDJSON_UNLIKELY(static_cast<unsigned>(*p) < 0x20)) {\n                is.src_ = is.dst_ = p;\n                return;\n            }\n\n        // The rest of string using SIMD\n        static const char dquote[16] = { '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"' };\n        static const char bslash[16] = { '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\' };\n        static const char space[16] = { 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19 };\n        const __m128i dq = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&dquote[0]));\n        const __m128i bs = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&bslash[0]));\n        const __m128i sp = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&space[0]));\n\n        for (;; p += 16) {\n            const __m128i s = _mm_load_si128(reinterpret_cast<const __m128i *>(p));\n            const __m128i t1 = _mm_cmpeq_epi8(s, dq);\n            const __m128i t2 = _mm_cmpeq_epi8(s, bs);\n            const __m128i t3 = _mm_cmpeq_epi8(_mm_max_epu8(s, sp), sp); // s < 0x20 <=> max(s, 0x19) == 0x19\n            const __m128i x = _mm_or_si128(_mm_or_si128(t1, t2), t3);\n            unsigned short r = static_cast<unsigned short>(_mm_movemask_epi8(x));\n            if (RAPIDJSON_UNLIKELY(r != 0)) {   // some of characters is escaped\n                size_t length;\n#ifdef _MSC_VER         // Find the index of first escaped\n                unsigned long offset;\n                _BitScanForward(&offset, r);\n                length = offset;\n#else\n                length = static_cast<size_t>(__builtin_ffs(r) - 1);\n#endif\n                p += length;\n                break;\n            }\n        }\n\n        is.src_ = is.dst_ = p;\n    }\n#endif\n\n    template<typename InputStream, bool backup, bool pushOnTake>\n    class NumberStream;\n\n    template<typename InputStream>\n    class NumberStream<InputStream, false, false> {\n    public:\n        typedef typename InputStream::Ch Ch;\n\n        NumberStream(GenericReader& reader, InputStream& s) : is(s) { (void)reader;  }\n        ~NumberStream() {}\n\n        RAPIDJSON_FORCEINLINE Ch Peek() const { return is.Peek(); }\n        RAPIDJSON_FORCEINLINE Ch TakePush() { return is.Take(); }\n        RAPIDJSON_FORCEINLINE Ch Take() { return is.Take(); }\n\t\t  RAPIDJSON_FORCEINLINE void Push(char) {}\n\n        size_t Tell() { return is.Tell(); }\n        size_t Length() { return 0; }\n        const char* Pop() { return 0; }\n\n    protected:\n        NumberStream& operator=(const NumberStream&);\n\n        InputStream& is;\n    };\n\n    template<typename InputStream>\n    class NumberStream<InputStream, true, false> : public NumberStream<InputStream, false, false> {\n        typedef NumberStream<InputStream, false, false> Base;\n    public:\n        NumberStream(GenericReader& reader, InputStream& is) : Base(reader, is), stackStream(reader.stack_) {}\n        ~NumberStream() {}\n\n        RAPIDJSON_FORCEINLINE Ch TakePush() {\n            stackStream.Put(static_cast<char>(Base::is.Peek()));\n            return Base::is.Take();\n        }\n\n        RAPIDJSON_FORCEINLINE void Push(char c) {\n            stackStream.Put(c);\n        }\n\n        size_t Length() { return stackStream.Length(); }\n\n        const char* Pop() {\n            stackStream.Put('\\0');\n            return stackStream.Pop();\n        }\n\n    private:\n        StackStream<char> stackStream;\n    };\n\n    template<typename InputStream>\n    class NumberStream<InputStream, true, true> : public NumberStream<InputStream, true, false> {\n        typedef NumberStream<InputStream, true, false> Base;\n    public:\n        NumberStream(GenericReader& reader, InputStream& is) : Base(reader, is) {}\n        ~NumberStream() {}\n\n        RAPIDJSON_FORCEINLINE Ch Take() { return Base::TakePush(); }\n    };\n\n    template<unsigned parseFlags, typename InputStream, typename Handler>\n    void ParseNumber(InputStream& is, Handler& handler) {\n        internal::StreamLocalCopy<InputStream> copy(is);\n        NumberStream<InputStream,\n            ((parseFlags & kParseNumbersAsStringsFlag) != 0) ?\n                ((parseFlags & kParseInsituFlag) == 0) :\n                ((parseFlags & kParseFullPrecisionFlag) != 0),\n            (parseFlags & kParseNumbersAsStringsFlag) != 0 &&\n                (parseFlags & kParseInsituFlag) == 0> s(*this, copy.s);\n\n        size_t startOffset = s.Tell();\n        double d = 0.0;\n        bool useNanOrInf = false;\n\n        // Parse minus\n        bool minus = Consume(s, '-');\n\n        // Parse int: zero / ( digit1-9 *DIGIT )\n        unsigned i = 0;\n        uint64_t i64 = 0;\n        bool use64bit = false;\n        int significandDigit = 0;\n        if (RAPIDJSON_UNLIKELY(s.Peek() == '0')) {\n            i = 0;\n            s.TakePush();\n        }\n        else if (RAPIDJSON_LIKELY(s.Peek() >= '1' && s.Peek() <= '9')) {\n            i = static_cast<unsigned>(s.TakePush() - '0');\n\n            if (minus)\n                while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {\n                    if (RAPIDJSON_UNLIKELY(i >= 214748364)) { // 2^31 = 2147483648\n                        if (RAPIDJSON_LIKELY(i != 214748364 || s.Peek() > '8')) {\n                            i64 = i;\n                            use64bit = true;\n                            break;\n                        }\n                    }\n                    i = i * 10 + static_cast<unsigned>(s.TakePush() - '0');\n                    significandDigit++;\n                }\n            else\n                while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {\n                    if (RAPIDJSON_UNLIKELY(i >= 429496729)) { // 2^32 - 1 = 4294967295\n                        if (RAPIDJSON_LIKELY(i != 429496729 || s.Peek() > '5')) {\n                            i64 = i;\n                            use64bit = true;\n                            break;\n                        }\n                    }\n                    i = i * 10 + static_cast<unsigned>(s.TakePush() - '0');\n                    significandDigit++;\n                }\n        }\n        // Parse NaN or Infinity here\n        else if ((parseFlags & kParseNanAndInfFlag) && RAPIDJSON_LIKELY((s.Peek() == 'I' || s.Peek() == 'N'))) {\n            useNanOrInf = true;\n            if (RAPIDJSON_LIKELY(Consume(s, 'N') && Consume(s, 'a') && Consume(s, 'N'))) {\n                d = std::numeric_limits<double>::quiet_NaN();\n            }\n            else if (RAPIDJSON_LIKELY(Consume(s, 'I') && Consume(s, 'n') && Consume(s, 'f'))) {\n                d = (minus ? -std::numeric_limits<double>::infinity() : std::numeric_limits<double>::infinity());\n                if (RAPIDJSON_UNLIKELY(s.Peek() == 'i' && !(Consume(s, 'i') && Consume(s, 'n')\n                                                            && Consume(s, 'i') && Consume(s, 't') && Consume(s, 'y'))))\n                    RAPIDJSON_PARSE_ERROR(kParseErrorValueInvalid, s.Tell());\n            }\n            else\n                RAPIDJSON_PARSE_ERROR(kParseErrorValueInvalid, s.Tell());\n        }\n        else\n            RAPIDJSON_PARSE_ERROR(kParseErrorValueInvalid, s.Tell());\n\n        // Parse 64bit int\n        bool useDouble = false;\n        if (use64bit) {\n            if (minus)\n                while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {\n                     if (RAPIDJSON_UNLIKELY(i64 >= RAPIDJSON_UINT64_C2(0x0CCCCCCC, 0xCCCCCCCC))) // 2^63 = 9223372036854775808\n                        if (RAPIDJSON_LIKELY(i64 != RAPIDJSON_UINT64_C2(0x0CCCCCCC, 0xCCCCCCCC) || s.Peek() > '8')) {\n                            d = static_cast<double>(i64);\n                            useDouble = true;\n                            break;\n                        }\n                    i64 = i64 * 10 + static_cast<unsigned>(s.TakePush() - '0');\n                    significandDigit++;\n                }\n            else\n                while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {\n                    if (RAPIDJSON_UNLIKELY(i64 >= RAPIDJSON_UINT64_C2(0x19999999, 0x99999999))) // 2^64 - 1 = 18446744073709551615\n                        if (RAPIDJSON_LIKELY(i64 != RAPIDJSON_UINT64_C2(0x19999999, 0x99999999) || s.Peek() > '5')) {\n                            d = static_cast<double>(i64);\n                            useDouble = true;\n                            break;\n                        }\n                    i64 = i64 * 10 + static_cast<unsigned>(s.TakePush() - '0');\n                    significandDigit++;\n                }\n        }\n\n        // Force double for big integer\n        if (useDouble) {\n            while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {\n                if (RAPIDJSON_UNLIKELY(d >= 1.7976931348623157e307)) // DBL_MAX / 10.0\n                    RAPIDJSON_PARSE_ERROR(kParseErrorNumberTooBig, startOffset);\n                d = d * 10 + (s.TakePush() - '0');\n            }\n        }\n\n        // Parse frac = decimal-point 1*DIGIT\n        int expFrac = 0;\n        size_t decimalPosition;\n        if (Consume(s, '.')) {\n            decimalPosition = s.Length();\n\n            if (RAPIDJSON_UNLIKELY(!(s.Peek() >= '0' && s.Peek() <= '9')))\n                RAPIDJSON_PARSE_ERROR(kParseErrorNumberMissFraction, s.Tell());\n\n            if (!useDouble) {\n#if RAPIDJSON_64BIT\n                // Use i64 to store significand in 64-bit architecture\n                if (!use64bit)\n                    i64 = i;\n\n                while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {\n                    if (i64 > RAPIDJSON_UINT64_C2(0x1FFFFF, 0xFFFFFFFF)) // 2^53 - 1 for fast path\n                        break;\n                    else {\n                        i64 = i64 * 10 + static_cast<unsigned>(s.TakePush() - '0');\n                        --expFrac;\n                        if (i64 != 0)\n                            significandDigit++;\n                    }\n                }\n\n                d = static_cast<double>(i64);\n#else\n                // Use double to store significand in 32-bit architecture\n                d = static_cast<double>(use64bit ? i64 : i);\n#endif\n                useDouble = true;\n            }\n\n            while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {\n                if (significandDigit < 17) {\n                    d = d * 10.0 + (s.TakePush() - '0');\n                    --expFrac;\n                    if (RAPIDJSON_LIKELY(d > 0.0))\n                        significandDigit++;\n                }\n                else\n                    s.TakePush();\n            }\n        }\n        else\n            decimalPosition = s.Length(); // decimal position at the end of integer.\n\n        // Parse exp = e [ minus / plus ] 1*DIGIT\n        int exp = 0;\n        if (Consume(s, 'e') || Consume(s, 'E')) {\n            if (!useDouble) {\n                d = static_cast<double>(use64bit ? i64 : i);\n                useDouble = true;\n            }\n\n            bool expMinus = false;\n            if (Consume(s, '+'))\n                ;\n            else if (Consume(s, '-'))\n                expMinus = true;\n\n            if (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {\n                exp = static_cast<int>(s.Take() - '0');\n                if (expMinus) {\n                    while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {\n                        exp = exp * 10 + static_cast<int>(s.Take() - '0');\n                        if (exp >= 214748364) {                         // Issue #313: prevent overflow exponent\n                            while (RAPIDJSON_UNLIKELY(s.Peek() >= '0' && s.Peek() <= '9'))  // Consume the rest of exponent\n                                s.Take();\n                        }\n                    }\n                }\n                else {  // positive exp\n                    int maxExp = 308 - expFrac;\n                    while (RAPIDJSON_LIKELY(s.Peek() >= '0' && s.Peek() <= '9')) {\n                        exp = exp * 10 + static_cast<int>(s.Take() - '0');\n                        if (RAPIDJSON_UNLIKELY(exp > maxExp))\n                            RAPIDJSON_PARSE_ERROR(kParseErrorNumberTooBig, startOffset);\n                    }\n                }\n            }\n            else\n                RAPIDJSON_PARSE_ERROR(kParseErrorNumberMissExponent, s.Tell());\n\n            if (expMinus)\n                exp = -exp;\n        }\n\n        // Finish parsing, call event according to the type of number.\n        bool cont = true;\n\n        if (parseFlags & kParseNumbersAsStringsFlag) {\n            if (parseFlags & kParseInsituFlag) {\n                s.Pop();  // Pop stack no matter if it will be used or not.\n                typename InputStream::Ch* head = is.PutBegin();\n                const size_t length = s.Tell() - startOffset;\n                RAPIDJSON_ASSERT(length <= 0xFFFFFFFF);\n                // unable to insert the \\0 character here, it will erase the comma after this number\n                const typename TargetEncoding::Ch* const str = reinterpret_cast<typename TargetEncoding::Ch*>(head);\n                cont = handler.RawNumber(str, SizeType(length), false);\n            }\n            else {\n                SizeType numCharsToCopy = static_cast<SizeType>(s.Length());\n                StringStream srcStream(s.Pop());\n                StackStream<typename TargetEncoding::Ch> dstStream(stack_);\n                while (numCharsToCopy--) {\n                    Transcoder<UTF8<>, TargetEncoding>::Transcode(srcStream, dstStream);\n                }\n                dstStream.Put('\\0');\n                const typename TargetEncoding::Ch* str = dstStream.Pop();\n                const SizeType length = static_cast<SizeType>(dstStream.Length()) - 1;\n                cont = handler.RawNumber(str, SizeType(length), true);\n            }\n        }\n        else {\n           size_t length = s.Length();\n           const char* decimal = s.Pop();  // Pop stack no matter if it will be used or not.\n\n           if (useDouble) {\n               int p = exp + expFrac;\n               if (parseFlags & kParseFullPrecisionFlag)\n                   d = internal::StrtodFullPrecision(d, p, decimal, length, decimalPosition, exp);\n               else\n                   d = internal::StrtodNormalPrecision(d, p);\n\n               cont = handler.Double(minus ? -d : d);\n           }\n           else if (useNanOrInf) {\n               cont = handler.Double(d);\n           }\n           else {\n               if (use64bit) {\n                   if (minus)\n                       cont = handler.Int64(static_cast<int64_t>(~i64 + 1));\n                   else\n                       cont = handler.Uint64(i64);\n               }\n               else {\n                   if (minus)\n                       cont = handler.Int(static_cast<int32_t>(~i + 1));\n                   else\n                       cont = handler.Uint(i);\n               }\n           }\n        }\n        if (RAPIDJSON_UNLIKELY(!cont))\n            RAPIDJSON_PARSE_ERROR(kParseErrorTermination, startOffset);\n    }\n\n    // Parse any JSON value\n    template<unsigned parseFlags, typename InputStream, typename Handler>\n    void ParseValue(InputStream& is, Handler& handler) {\n        switch (is.Peek()) {\n            case 'n': ParseNull  <parseFlags>(is, handler); break;\n            case 't': ParseTrue  <parseFlags>(is, handler); break;\n            case 'f': ParseFalse <parseFlags>(is, handler); break;\n            case '\"': ParseString<parseFlags>(is, handler); break;\n            case '{': ParseObject<parseFlags>(is, handler); break;\n            case '[': ParseArray <parseFlags>(is, handler); break;\n            default :\n                      ParseNumber<parseFlags>(is, handler);\n                      break;\n\n        }\n    }\n\n    // Iterative Parsing\n\n    // States\n    enum IterativeParsingState {\n        IterativeParsingStartState = 0,\n        IterativeParsingFinishState,\n        IterativeParsingErrorState,\n\n        // Object states\n        IterativeParsingObjectInitialState,\n        IterativeParsingMemberKeyState,\n        IterativeParsingKeyValueDelimiterState,\n        IterativeParsingMemberValueState,\n        IterativeParsingMemberDelimiterState,\n        IterativeParsingObjectFinishState,\n\n        // Array states\n        IterativeParsingArrayInitialState,\n        IterativeParsingElementState,\n        IterativeParsingElementDelimiterState,\n        IterativeParsingArrayFinishState,\n\n        // Single value state\n        IterativeParsingValueState\n    };\n\n    enum { cIterativeParsingStateCount = IterativeParsingValueState + 1 };\n\n    // Tokens\n    enum Token {\n        LeftBracketToken = 0,\n        RightBracketToken,\n\n        LeftCurlyBracketToken,\n        RightCurlyBracketToken,\n\n        CommaToken,\n        ColonToken,\n\n        StringToken,\n        FalseToken,\n        TrueToken,\n        NullToken,\n        NumberToken,\n\n        kTokenCount\n    };\n\n    RAPIDJSON_FORCEINLINE Token Tokenize(Ch c) {\n\n//!@cond RAPIDJSON_HIDDEN_FROM_DOXYGEN\n#define N NumberToken\n#define N16 N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N\n        // Maps from ASCII to Token\n        static const unsigned char tokenMap[256] = {\n            N16, // 00~0F\n            N16, // 10~1F\n            N, N, StringToken, N, N, N, N, N, N, N, N, N, CommaToken, N, N, N, // 20~2F\n            N, N, N, N, N, N, N, N, N, N, ColonToken, N, N, N, N, N, // 30~3F\n            N16, // 40~4F\n            N, N, N, N, N, N, N, N, N, N, N, LeftBracketToken, N, RightBracketToken, N, N, // 50~5F\n            N, N, N, N, N, N, FalseToken, N, N, N, N, N, N, N, NullToken, N, // 60~6F\n            N, N, N, N, TrueToken, N, N, N, N, N, N, LeftCurlyBracketToken, N, RightCurlyBracketToken, N, N, // 70~7F\n            N16, N16, N16, N16, N16, N16, N16, N16 // 80~FF\n        };\n#undef N\n#undef N16\n//!@endcond\n\n        if (sizeof(Ch) == 1 || static_cast<unsigned>(c) < 256)\n            return static_cast<Token>(tokenMap[static_cast<unsigned char>(c)]);\n        else\n            return NumberToken;\n    }\n\n    RAPIDJSON_FORCEINLINE IterativeParsingState Predict(IterativeParsingState state, Token token) {\n        // current state x one lookahead token -> new state\n        static const char G[cIterativeParsingStateCount][kTokenCount] = {\n            // Start\n            {\n                IterativeParsingArrayInitialState,  // Left bracket\n                IterativeParsingErrorState,         // Right bracket\n                IterativeParsingObjectInitialState, // Left curly bracket\n                IterativeParsingErrorState,         // Right curly bracket\n                IterativeParsingErrorState,         // Comma\n                IterativeParsingErrorState,         // Colon\n                IterativeParsingValueState,         // String\n                IterativeParsingValueState,         // False\n                IterativeParsingValueState,         // True\n                IterativeParsingValueState,         // Null\n                IterativeParsingValueState          // Number\n            },\n            // Finish(sink state)\n            {\n                IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState,\n                IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState,\n                IterativeParsingErrorState\n            },\n            // Error(sink state)\n            {\n                IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState,\n                IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState,\n                IterativeParsingErrorState\n            },\n            // ObjectInitial\n            {\n                IterativeParsingErrorState,         // Left bracket\n                IterativeParsingErrorState,         // Right bracket\n                IterativeParsingErrorState,         // Left curly bracket\n                IterativeParsingObjectFinishState,  // Right curly bracket\n                IterativeParsingErrorState,         // Comma\n                IterativeParsingErrorState,         // Colon\n                IterativeParsingMemberKeyState,     // String\n                IterativeParsingErrorState,         // False\n                IterativeParsingErrorState,         // True\n                IterativeParsingErrorState,         // Null\n                IterativeParsingErrorState          // Number\n            },\n            // MemberKey\n            {\n                IterativeParsingErrorState,             // Left bracket\n                IterativeParsingErrorState,             // Right bracket\n                IterativeParsingErrorState,             // Left curly bracket\n                IterativeParsingErrorState,             // Right curly bracket\n                IterativeParsingErrorState,             // Comma\n                IterativeParsingKeyValueDelimiterState, // Colon\n                IterativeParsingErrorState,             // String\n                IterativeParsingErrorState,             // False\n                IterativeParsingErrorState,             // True\n                IterativeParsingErrorState,             // Null\n                IterativeParsingErrorState              // Number\n            },\n            // KeyValueDelimiter\n            {\n                IterativeParsingArrayInitialState,      // Left bracket(push MemberValue state)\n                IterativeParsingErrorState,             // Right bracket\n                IterativeParsingObjectInitialState,     // Left curly bracket(push MemberValue state)\n                IterativeParsingErrorState,             // Right curly bracket\n                IterativeParsingErrorState,             // Comma\n                IterativeParsingErrorState,             // Colon\n                IterativeParsingMemberValueState,       // String\n                IterativeParsingMemberValueState,       // False\n                IterativeParsingMemberValueState,       // True\n                IterativeParsingMemberValueState,       // Null\n                IterativeParsingMemberValueState        // Number\n            },\n            // MemberValue\n            {\n                IterativeParsingErrorState,             // Left bracket\n                IterativeParsingErrorState,             // Right bracket\n                IterativeParsingErrorState,             // Left curly bracket\n                IterativeParsingObjectFinishState,      // Right curly bracket\n                IterativeParsingMemberDelimiterState,   // Comma\n                IterativeParsingErrorState,             // Colon\n                IterativeParsingErrorState,             // String\n                IterativeParsingErrorState,             // False\n                IterativeParsingErrorState,             // True\n                IterativeParsingErrorState,             // Null\n                IterativeParsingErrorState              // Number\n            },\n            // MemberDelimiter\n            {\n                IterativeParsingErrorState,         // Left bracket\n                IterativeParsingErrorState,         // Right bracket\n                IterativeParsingErrorState,         // Left curly bracket\n                IterativeParsingObjectFinishState,  // Right curly bracket\n                IterativeParsingErrorState,         // Comma\n                IterativeParsingErrorState,         // Colon\n                IterativeParsingMemberKeyState,     // String\n                IterativeParsingErrorState,         // False\n                IterativeParsingErrorState,         // True\n                IterativeParsingErrorState,         // Null\n                IterativeParsingErrorState          // Number\n            },\n            // ObjectFinish(sink state)\n            {\n                IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState,\n                IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState,\n                IterativeParsingErrorState\n            },\n            // ArrayInitial\n            {\n                IterativeParsingArrayInitialState,      // Left bracket(push Element state)\n                IterativeParsingArrayFinishState,       // Right bracket\n                IterativeParsingObjectInitialState,     // Left curly bracket(push Element state)\n                IterativeParsingErrorState,             // Right curly bracket\n                IterativeParsingErrorState,             // Comma\n                IterativeParsingErrorState,             // Colon\n                IterativeParsingElementState,           // String\n                IterativeParsingElementState,           // False\n                IterativeParsingElementState,           // True\n                IterativeParsingElementState,           // Null\n                IterativeParsingElementState            // Number\n            },\n            // Element\n            {\n                IterativeParsingErrorState,             // Left bracket\n                IterativeParsingArrayFinishState,       // Right bracket\n                IterativeParsingErrorState,             // Left curly bracket\n                IterativeParsingErrorState,             // Right curly bracket\n                IterativeParsingElementDelimiterState,  // Comma\n                IterativeParsingErrorState,             // Colon\n                IterativeParsingErrorState,             // String\n                IterativeParsingErrorState,             // False\n                IterativeParsingErrorState,             // True\n                IterativeParsingErrorState,             // Null\n                IterativeParsingErrorState              // Number\n            },\n            // ElementDelimiter\n            {\n                IterativeParsingArrayInitialState,      // Left bracket(push Element state)\n                IterativeParsingArrayFinishState,       // Right bracket\n                IterativeParsingObjectInitialState,     // Left curly bracket(push Element state)\n                IterativeParsingErrorState,             // Right curly bracket\n                IterativeParsingErrorState,             // Comma\n                IterativeParsingErrorState,             // Colon\n                IterativeParsingElementState,           // String\n                IterativeParsingElementState,           // False\n                IterativeParsingElementState,           // True\n                IterativeParsingElementState,           // Null\n                IterativeParsingElementState            // Number\n            },\n            // ArrayFinish(sink state)\n            {\n                IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState,\n                IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState,\n                IterativeParsingErrorState\n            },\n            // Single Value (sink state)\n            {\n                IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState,\n                IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState,\n                IterativeParsingErrorState\n            }\n        }; // End of G\n\n        return static_cast<IterativeParsingState>(G[state][token]);\n    }\n\n    // Make an advance in the token stream and state based on the candidate destination state which was returned by Transit().\n    // May return a new state on state pop.\n    template <unsigned parseFlags, typename InputStream, typename Handler>\n    RAPIDJSON_FORCEINLINE IterativeParsingState Transit(IterativeParsingState src, Token token, IterativeParsingState dst, InputStream& is, Handler& handler) {\n        (void)token;\n\n        switch (dst) {\n        case IterativeParsingErrorState:\n            return dst;\n\n        case IterativeParsingObjectInitialState:\n        case IterativeParsingArrayInitialState:\n        {\n            // Push the state(Element or MemeberValue) if we are nested in another array or value of member.\n            // In this way we can get the correct state on ObjectFinish or ArrayFinish by frame pop.\n            IterativeParsingState n = src;\n            if (src == IterativeParsingArrayInitialState || src == IterativeParsingElementDelimiterState)\n                n = IterativeParsingElementState;\n            else if (src == IterativeParsingKeyValueDelimiterState)\n                n = IterativeParsingMemberValueState;\n            // Push current state.\n            *stack_.template Push<SizeType>(1) = n;\n            // Initialize and push the member/element count.\n            *stack_.template Push<SizeType>(1) = 0;\n            // Call handler\n            bool hr = (dst == IterativeParsingObjectInitialState) ? handler.StartObject() : handler.StartArray();\n            // On handler short circuits the parsing.\n            if (!hr) {\n                RAPIDJSON_PARSE_ERROR_NORETURN(kParseErrorTermination, is.Tell());\n                return IterativeParsingErrorState;\n            }\n            else {\n                is.Take();\n                return dst;\n            }\n        }\n\n        case IterativeParsingMemberKeyState:\n            ParseString<parseFlags>(is, handler, true);\n            if (HasParseError())\n                return IterativeParsingErrorState;\n            else\n                return dst;\n\n        case IterativeParsingKeyValueDelimiterState:\n            RAPIDJSON_ASSERT(token == ColonToken);\n            is.Take();\n            return dst;\n\n        case IterativeParsingMemberValueState:\n            // Must be non-compound value. Or it would be ObjectInitial or ArrayInitial state.\n            ParseValue<parseFlags>(is, handler);\n            if (HasParseError()) {\n                return IterativeParsingErrorState;\n            }\n            return dst;\n\n        case IterativeParsingElementState:\n            // Must be non-compound value. Or it would be ObjectInitial or ArrayInitial state.\n            ParseValue<parseFlags>(is, handler);\n            if (HasParseError()) {\n                return IterativeParsingErrorState;\n            }\n            return dst;\n\n        case IterativeParsingMemberDelimiterState:\n        case IterativeParsingElementDelimiterState:\n            is.Take();\n            // Update member/element count.\n            *stack_.template Top<SizeType>() = *stack_.template Top<SizeType>() + 1;\n            return dst;\n\n        case IterativeParsingObjectFinishState:\n        {\n            // Transit from delimiter is only allowed when trailing commas are enabled\n            if (!(parseFlags & kParseTrailingCommasFlag) && src == IterativeParsingMemberDelimiterState) {\n                RAPIDJSON_PARSE_ERROR_NORETURN(kParseErrorObjectMissName, is.Tell());\n                return IterativeParsingErrorState;\n            }\n            // Get member count.\n            SizeType c = *stack_.template Pop<SizeType>(1);\n            // If the object is not empty, count the last member.\n            if (src == IterativeParsingMemberValueState)\n                ++c;\n            // Restore the state.\n            IterativeParsingState n = static_cast<IterativeParsingState>(*stack_.template Pop<SizeType>(1));\n            // Transit to Finish state if this is the topmost scope.\n            if (n == IterativeParsingStartState)\n                n = IterativeParsingFinishState;\n            // Call handler\n            bool hr = handler.EndObject(c);\n            // On handler short circuits the parsing.\n            if (!hr) {\n                RAPIDJSON_PARSE_ERROR_NORETURN(kParseErrorTermination, is.Tell());\n                return IterativeParsingErrorState;\n            }\n            else {\n                is.Take();\n                return n;\n            }\n        }\n\n        case IterativeParsingArrayFinishState:\n        {\n            // Transit from delimiter is only allowed when trailing commas are enabled\n            if (!(parseFlags & kParseTrailingCommasFlag) && src == IterativeParsingElementDelimiterState) {\n                RAPIDJSON_PARSE_ERROR_NORETURN(kParseErrorValueInvalid, is.Tell());\n                return IterativeParsingErrorState;\n            }\n            // Get element count.\n            SizeType c = *stack_.template Pop<SizeType>(1);\n            // If the array is not empty, count the last element.\n            if (src == IterativeParsingElementState)\n                ++c;\n            // Restore the state.\n            IterativeParsingState n = static_cast<IterativeParsingState>(*stack_.template Pop<SizeType>(1));\n            // Transit to Finish state if this is the topmost scope.\n            if (n == IterativeParsingStartState)\n                n = IterativeParsingFinishState;\n            // Call handler\n            bool hr = handler.EndArray(c);\n            // On handler short circuits the parsing.\n            if (!hr) {\n                RAPIDJSON_PARSE_ERROR_NORETURN(kParseErrorTermination, is.Tell());\n                return IterativeParsingErrorState;\n            }\n            else {\n                is.Take();\n                return n;\n            }\n        }\n\n        default:\n            // This branch is for IterativeParsingValueState actually.\n            // Use `default:` rather than\n            // `case IterativeParsingValueState:` is for code coverage.\n\n            // The IterativeParsingStartState is not enumerated in this switch-case.\n            // It is impossible for that case. And it can be caught by following assertion.\n\n            // The IterativeParsingFinishState is not enumerated in this switch-case either.\n            // It is a \"derivative\" state which cannot triggered from Predict() directly.\n            // Therefore it cannot happen here. And it can be caught by following assertion.\n            RAPIDJSON_ASSERT(dst == IterativeParsingValueState);\n\n            // Must be non-compound value. Or it would be ObjectInitial or ArrayInitial state.\n            ParseValue<parseFlags>(is, handler);\n            if (HasParseError()) {\n                return IterativeParsingErrorState;\n            }\n            return IterativeParsingFinishState;\n        }\n    }\n\n    template <typename InputStream>\n    void HandleError(IterativeParsingState src, InputStream& is) {\n        if (HasParseError()) {\n            // Error flag has been set.\n            return;\n        }\n\n        switch (src) {\n        case IterativeParsingStartState:            RAPIDJSON_PARSE_ERROR(kParseErrorDocumentEmpty, is.Tell()); return;\n        case IterativeParsingFinishState:           RAPIDJSON_PARSE_ERROR(kParseErrorDocumentRootNotSingular, is.Tell()); return;\n        case IterativeParsingObjectInitialState:\n        case IterativeParsingMemberDelimiterState:  RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissName, is.Tell()); return;\n        case IterativeParsingMemberKeyState:        RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissColon, is.Tell()); return;\n        case IterativeParsingMemberValueState:      RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissCommaOrCurlyBracket, is.Tell()); return;\n        case IterativeParsingKeyValueDelimiterState:\n        case IterativeParsingArrayInitialState:\n        case IterativeParsingElementDelimiterState: RAPIDJSON_PARSE_ERROR(kParseErrorValueInvalid, is.Tell()); return;\n        default: RAPIDJSON_ASSERT(src == IterativeParsingElementState); RAPIDJSON_PARSE_ERROR(kParseErrorArrayMissCommaOrSquareBracket, is.Tell()); return;\n        }\n    }\n\n    template <unsigned parseFlags, typename InputStream, typename Handler>\n    ParseResult IterativeParse(InputStream& is, Handler& handler) {\n        parseResult_.Clear();\n        ClearStackOnExit scope(*this);\n        IterativeParsingState state = IterativeParsingStartState;\n\n        SkipWhitespaceAndComments<parseFlags>(is);\n        RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_);\n        while (is.Peek() != '\\0') {\n            Token t = Tokenize(is.Peek());\n            IterativeParsingState n = Predict(state, t);\n            IterativeParsingState d = Transit<parseFlags>(state, t, n, is, handler);\n\n            if (d == IterativeParsingErrorState) {\n                HandleError(state, is);\n                break;\n            }\n\n            state = d;\n\n            // Do not further consume streams if a root JSON has been parsed.\n            if ((parseFlags & kParseStopWhenDoneFlag) && state == IterativeParsingFinishState)\n                break;\n\n            SkipWhitespaceAndComments<parseFlags>(is);\n            RAPIDJSON_PARSE_ERROR_EARLY_RETURN(parseResult_);\n        }\n\n        // Handle the end of file.\n        if (state != IterativeParsingFinishState)\n            HandleError(state, is);\n\n        return parseResult_;\n    }\n\n    static const size_t kDefaultStackCapacity = 256;    //!< Default stack capacity in bytes for storing a single decoded string.\n    internal::Stack<StackAllocator> stack_;  //!< A stack for storing decoded string temporarily during non-destructive parsing.\n    ParseResult parseResult_;\n}; // class GenericReader\n\n//! Reader with UTF8 encoding and default allocator.\ntypedef GenericReader<UTF8<>, UTF8<> > Reader;\n\nRAPIDJSON_NAMESPACE_END\n\n#ifdef __clang__\nRAPIDJSON_DIAG_POP\n#endif\n\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_POP\n#endif\n\n#ifdef _MSC_VER\nRAPIDJSON_DIAG_POP\n#endif\n\n#endif // RAPIDJSON_READER_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/schema.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available->\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip-> All rights reserved->\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License-> You may obtain a copy of the License at\n//\n// http://opensource->org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied-> See the License for the \n// specific language governing permissions and limitations under the License->\n\n#ifndef RAPIDJSON_SCHEMA_H_\n#define RAPIDJSON_SCHEMA_H_\n\n#include \"document.h\"\n#include \"pointer.h\"\n#include <cmath> // abs, floor\n\n#if !defined(RAPIDJSON_SCHEMA_USE_INTERNALREGEX)\n#define RAPIDJSON_SCHEMA_USE_INTERNALREGEX 1\n#else\n#define RAPIDJSON_SCHEMA_USE_INTERNALREGEX 0\n#endif\n\n#if !RAPIDJSON_SCHEMA_USE_INTERNALREGEX && !defined(RAPIDJSON_SCHEMA_USE_STDREGEX) && (__cplusplus >=201103L || (defined(_MSC_VER) && _MSC_VER >= 1800))\n#define RAPIDJSON_SCHEMA_USE_STDREGEX 1\n#else\n#define RAPIDJSON_SCHEMA_USE_STDREGEX 0\n#endif\n\n#if RAPIDJSON_SCHEMA_USE_INTERNALREGEX\n#include \"internal/regex.h\"\n#elif RAPIDJSON_SCHEMA_USE_STDREGEX\n#include <regex>\n#endif\n\n#if RAPIDJSON_SCHEMA_USE_INTERNALREGEX || RAPIDJSON_SCHEMA_USE_STDREGEX\n#define RAPIDJSON_SCHEMA_HAS_REGEX 1\n#else\n#define RAPIDJSON_SCHEMA_HAS_REGEX 0\n#endif\n\n#ifndef RAPIDJSON_SCHEMA_VERBOSE\n#define RAPIDJSON_SCHEMA_VERBOSE 0\n#endif\n\n#if RAPIDJSON_SCHEMA_VERBOSE\n#include \"stringbuffer.h\"\n#endif\n\nRAPIDJSON_DIAG_PUSH\n\n#if defined(__GNUC__)\nRAPIDJSON_DIAG_OFF(effc++)\n#endif\n\n#ifdef __clang__\nRAPIDJSON_DIAG_OFF(weak-vtables)\nRAPIDJSON_DIAG_OFF(exit-time-destructors)\nRAPIDJSON_DIAG_OFF(c++98-compat-pedantic)\nRAPIDJSON_DIAG_OFF(variadic-macros)\n#endif\n\n#ifdef _MSC_VER\nRAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated\n#endif\n\nRAPIDJSON_NAMESPACE_BEGIN\n\n///////////////////////////////////////////////////////////////////////////////\n// Verbose Utilities\n\n#if RAPIDJSON_SCHEMA_VERBOSE\n\nnamespace internal {\n\ninline void PrintInvalidKeyword(const char* keyword) {\n    printf(\"Fail keyword: %s\\n\", keyword);\n}\n\ninline void PrintInvalidKeyword(const wchar_t* keyword) {\n    wprintf(L\"Fail keyword: %ls\\n\", keyword);\n}\n\ninline void PrintInvalidDocument(const char* document) {\n    printf(\"Fail document: %s\\n\\n\", document);\n}\n\ninline void PrintInvalidDocument(const wchar_t* document) {\n    wprintf(L\"Fail document: %ls\\n\\n\", document);\n}\n\ninline void PrintValidatorPointers(unsigned depth, const char* s, const char* d) {\n    printf(\"S: %*s%s\\nD: %*s%s\\n\\n\", depth * 4, \" \", s, depth * 4, \" \", d);\n}\n\ninline void PrintValidatorPointers(unsigned depth, const wchar_t* s, const wchar_t* d) {\n    wprintf(L\"S: %*ls%ls\\nD: %*ls%ls\\n\\n\", depth * 4, L\" \", s, depth * 4, L\" \", d);\n}\n\n} // namespace internal\n\n#endif // RAPIDJSON_SCHEMA_VERBOSE\n\n///////////////////////////////////////////////////////////////////////////////\n// RAPIDJSON_INVALID_KEYWORD_RETURN\n\n#if RAPIDJSON_SCHEMA_VERBOSE\n#define RAPIDJSON_INVALID_KEYWORD_VERBOSE(keyword) internal::PrintInvalidKeyword(keyword)\n#else\n#define RAPIDJSON_INVALID_KEYWORD_VERBOSE(keyword)\n#endif\n\n#define RAPIDJSON_INVALID_KEYWORD_RETURN(keyword)\\\nRAPIDJSON_MULTILINEMACRO_BEGIN\\\n    context.invalidKeyword = keyword.GetString();\\\n    RAPIDJSON_INVALID_KEYWORD_VERBOSE(keyword.GetString());\\\n    return false;\\\nRAPIDJSON_MULTILINEMACRO_END\n\n///////////////////////////////////////////////////////////////////////////////\n// Forward declarations\n\ntemplate <typename ValueType, typename Allocator>\nclass GenericSchemaDocument;\n\nnamespace internal {\n\ntemplate <typename SchemaDocumentType>\nclass Schema;\n\n///////////////////////////////////////////////////////////////////////////////\n// ISchemaValidator\n\nclass ISchemaValidator {\npublic:\n    virtual ~ISchemaValidator() {}\n    virtual bool IsValid() const = 0;\n};\n\n///////////////////////////////////////////////////////////////////////////////\n// ISchemaStateFactory\n\ntemplate <typename SchemaType>\nclass ISchemaStateFactory {\npublic:\n    virtual ~ISchemaStateFactory() {}\n    virtual ISchemaValidator* CreateSchemaValidator(const SchemaType&) = 0;\n    virtual void DestroySchemaValidator(ISchemaValidator* validator) = 0;\n    virtual void* CreateHasher() = 0;\n    virtual uint64_t GetHashCode(void* hasher) = 0;\n    virtual void DestroryHasher(void* hasher) = 0;\n    virtual void* MallocState(size_t size) = 0;\n    virtual void FreeState(void* p) = 0;\n};\n\n///////////////////////////////////////////////////////////////////////////////\n// Hasher\n\n// For comparison of compound value\ntemplate<typename Encoding, typename Allocator>\nclass Hasher {\npublic:\n    typedef typename Encoding::Ch Ch;\n\n    Hasher(Allocator* allocator = 0, size_t stackCapacity = kDefaultSize) : stack_(allocator, stackCapacity) {}\n\n    bool Null() { return WriteType(kNullType); }\n    bool Bool(bool b) { return WriteType(b ? kTrueType : kFalseType); }\n    bool Int(int i) { Number n; n.u.i = i; n.d = static_cast<double>(i); return WriteNumber(n); }\n    bool Uint(unsigned u) { Number n; n.u.u = u; n.d = static_cast<double>(u); return WriteNumber(n); }\n    bool Int64(int64_t i) { Number n; n.u.i = i; n.d = static_cast<double>(i); return WriteNumber(n); }\n    bool Uint64(uint64_t u) { Number n; n.u.u = u; n.d = static_cast<double>(u); return WriteNumber(n); }\n    bool Double(double d) { \n        Number n; \n        if (d < 0) n.u.i = static_cast<int64_t>(d);\n        else       n.u.u = static_cast<uint64_t>(d); \n        n.d = d;\n        return WriteNumber(n);\n    }\n\n    bool RawNumber(const Ch* str, SizeType len, bool) {\n        WriteBuffer(kNumberType, str, len * sizeof(Ch));\n        return true;\n    }\n\n    bool String(const Ch* str, SizeType len, bool) {\n        WriteBuffer(kStringType, str, len * sizeof(Ch));\n        return true;\n    }\n\n    bool StartObject() { return true; }\n    bool Key(const Ch* str, SizeType len, bool copy) { return String(str, len, copy); }\n    bool EndObject(SizeType memberCount) { \n        uint64_t h = Hash(0, kObjectType);\n        uint64_t* kv = stack_.template Pop<uint64_t>(memberCount * 2);\n        for (SizeType i = 0; i < memberCount; i++)\n            h ^= Hash(kv[i * 2], kv[i * 2 + 1]);  // Use xor to achieve member order insensitive\n        *stack_.template Push<uint64_t>() = h;\n        return true;\n    }\n    \n    bool StartArray() { return true; }\n    bool EndArray(SizeType elementCount) { \n        uint64_t h = Hash(0, kArrayType);\n        uint64_t* e = stack_.template Pop<uint64_t>(elementCount);\n        for (SizeType i = 0; i < elementCount; i++)\n            h = Hash(h, e[i]); // Use hash to achieve element order sensitive\n        *stack_.template Push<uint64_t>() = h;\n        return true;\n    }\n\n    bool IsValid() const { return stack_.GetSize() == sizeof(uint64_t); }\n\n    uint64_t GetHashCode() const {\n        RAPIDJSON_ASSERT(IsValid());\n        return *stack_.template Top<uint64_t>();\n    }\n\nprivate:\n    static const size_t kDefaultSize = 256;\n    struct Number {\n        union U {\n            uint64_t u;\n            int64_t i;\n        }u;\n        double d;\n    };\n\n    bool WriteType(Type type) { return WriteBuffer(type, 0, 0); }\n    \n    bool WriteNumber(const Number& n) { return WriteBuffer(kNumberType, &n, sizeof(n)); }\n    \n    bool WriteBuffer(Type type, const void* data, size_t len) {\n        // FNV-1a from http://isthe.com/chongo/tech/comp/fnv/\n        uint64_t h = Hash(RAPIDJSON_UINT64_C2(0x84222325, 0xcbf29ce4), type);\n        const unsigned char* d = static_cast<const unsigned char*>(data);\n        for (size_t i = 0; i < len; i++)\n            h = Hash(h, d[i]);\n        *stack_.template Push<uint64_t>() = h;\n        return true;\n    }\n\n    static uint64_t Hash(uint64_t h, uint64_t d) {\n        static const uint64_t kPrime = RAPIDJSON_UINT64_C2(0x00000100, 0x000001b3);\n        h ^= d;\n        h *= kPrime;\n        return h;\n    }\n\n    Stack<Allocator> stack_;\n};\n\n///////////////////////////////////////////////////////////////////////////////\n// SchemaValidationContext\n\ntemplate <typename SchemaDocumentType>\nstruct SchemaValidationContext {\n    typedef Schema<SchemaDocumentType> SchemaType;\n    typedef ISchemaStateFactory<SchemaType> SchemaValidatorFactoryType;\n    typedef typename SchemaType::ValueType ValueType;\n    typedef typename ValueType::Ch Ch;\n\n    enum PatternValidatorType {\n        kPatternValidatorOnly,\n        kPatternValidatorWithProperty,\n        kPatternValidatorWithAdditionalProperty\n    };\n\n    SchemaValidationContext(SchemaValidatorFactoryType& f, const SchemaType* s) :\n        factory(f),\n        schema(s),\n        valueSchema(),\n        invalidKeyword(),\n        hasher(),\n        arrayElementHashCodes(),\n        validators(),\n        validatorCount(),\n        patternPropertiesValidators(),\n        patternPropertiesValidatorCount(),\n        patternPropertiesSchemas(),\n        patternPropertiesSchemaCount(),\n        valuePatternValidatorType(kPatternValidatorOnly),\n        propertyExist(),\n        inArray(false),\n        valueUniqueness(false),\n        arrayUniqueness(false)\n    {\n    }\n\n    ~SchemaValidationContext() {\n        if (hasher)\n            factory.DestroryHasher(hasher);\n        if (validators) {\n            for (SizeType i = 0; i < validatorCount; i++)\n                factory.DestroySchemaValidator(validators[i]);\n            factory.FreeState(validators);\n        }\n        if (patternPropertiesValidators) {\n            for (SizeType i = 0; i < patternPropertiesValidatorCount; i++)\n                factory.DestroySchemaValidator(patternPropertiesValidators[i]);\n            factory.FreeState(patternPropertiesValidators);\n        }\n        if (patternPropertiesSchemas)\n            factory.FreeState(patternPropertiesSchemas);\n        if (propertyExist)\n            factory.FreeState(propertyExist);\n    }\n\n    SchemaValidatorFactoryType& factory;\n    const SchemaType* schema;\n    const SchemaType* valueSchema;\n    const Ch* invalidKeyword;\n    void* hasher; // Only validator access\n    void* arrayElementHashCodes; // Only validator access this\n    ISchemaValidator** validators;\n    SizeType validatorCount;\n    ISchemaValidator** patternPropertiesValidators;\n    SizeType patternPropertiesValidatorCount;\n    const SchemaType** patternPropertiesSchemas;\n    SizeType patternPropertiesSchemaCount;\n    PatternValidatorType valuePatternValidatorType;\n    PatternValidatorType objectPatternValidatorType;\n    SizeType arrayElementIndex;\n    bool* propertyExist;\n    bool inArray;\n    bool valueUniqueness;\n    bool arrayUniqueness;\n};\n\n///////////////////////////////////////////////////////////////////////////////\n// Schema\n\ntemplate <typename SchemaDocumentType>\nclass Schema {\npublic:\n    typedef typename SchemaDocumentType::ValueType ValueType;\n    typedef typename SchemaDocumentType::AllocatorType AllocatorType;\n    typedef typename SchemaDocumentType::PointerType PointerType;\n    typedef typename ValueType::EncodingType EncodingType;\n    typedef typename EncodingType::Ch Ch;\n    typedef SchemaValidationContext<SchemaDocumentType> Context;\n    typedef Schema<SchemaDocumentType> SchemaType;\n    typedef GenericValue<EncodingType, AllocatorType> SValue;\n    friend class GenericSchemaDocument<ValueType, AllocatorType>;\n\n    Schema(SchemaDocumentType* schemaDocument, const PointerType& p, const ValueType& value, const ValueType& document, AllocatorType* allocator) :\n        allocator_(allocator),\n        enum_(),\n        enumCount_(),\n        not_(),\n        type_((1 << kTotalSchemaType) - 1), // typeless\n        validatorCount_(),\n        properties_(),\n        additionalPropertiesSchema_(),\n        patternProperties_(),\n        patternPropertyCount_(),\n        propertyCount_(),\n        minProperties_(),\n        maxProperties_(SizeType(~0)),\n        additionalProperties_(true),\n        hasDependencies_(),\n        hasRequired_(),\n        hasSchemaDependencies_(),\n        additionalItemsSchema_(),\n        itemsList_(),\n        itemsTuple_(),\n        itemsTupleCount_(),\n        minItems_(),\n        maxItems_(SizeType(~0)),\n        additionalItems_(true),\n        uniqueItems_(false),\n        pattern_(),\n        minLength_(0),\n        maxLength_(~SizeType(0)),\n        exclusiveMinimum_(false),\n        exclusiveMaximum_(false)\n    {\n        typedef typename SchemaDocumentType::ValueType ValueType;\n        typedef typename ValueType::ConstValueIterator ConstValueIterator;\n        typedef typename ValueType::ConstMemberIterator ConstMemberIterator;\n\n        if (!value.IsObject())\n            return;\n\n        if (const ValueType* v = GetMember(value, GetTypeString())) {\n            type_ = 0;\n            if (v->IsString())\n                AddType(*v);\n            else if (v->IsArray())\n                for (ConstValueIterator itr = v->Begin(); itr != v->End(); ++itr)\n                    AddType(*itr);\n        }\n\n        if (const ValueType* v = GetMember(value, GetEnumString()))\n            if (v->IsArray() && v->Size() > 0) {\n                enum_ = static_cast<uint64_t*>(allocator_->Malloc(sizeof(uint64_t) * v->Size()));\n                for (ConstValueIterator itr = v->Begin(); itr != v->End(); ++itr) {\n                    typedef Hasher<EncodingType, MemoryPoolAllocator<> > EnumHasherType;\n                    char buffer[256 + 24];\n                    MemoryPoolAllocator<> hasherAllocator(buffer, sizeof(buffer));\n                    EnumHasherType h(&hasherAllocator, 256);\n                    itr->Accept(h);\n                    enum_[enumCount_++] = h.GetHashCode();\n                }\n            }\n\n        if (schemaDocument) {\n            AssignIfExist(allOf_, *schemaDocument, p, value, GetAllOfString(), document);\n            AssignIfExist(anyOf_, *schemaDocument, p, value, GetAnyOfString(), document);\n            AssignIfExist(oneOf_, *schemaDocument, p, value, GetOneOfString(), document);\n        }\n\n        if (const ValueType* v = GetMember(value, GetNotString())) {\n            schemaDocument->CreateSchema(&not_, p.Append(GetNotString(), allocator_), *v, document);\n            notValidatorIndex_ = validatorCount_;\n            validatorCount_++;\n        }\n\n        // Object\n\n        const ValueType* properties = GetMember(value, GetPropertiesString());\n        const ValueType* required = GetMember(value, GetRequiredString());\n        const ValueType* dependencies = GetMember(value, GetDependenciesString());\n        {\n            // Gather properties from properties/required/dependencies\n            SValue allProperties(kArrayType);\n\n            if (properties && properties->IsObject())\n                for (ConstMemberIterator itr = properties->MemberBegin(); itr != properties->MemberEnd(); ++itr)\n                    AddUniqueElement(allProperties, itr->name);\n            \n            if (required && required->IsArray())\n                for (ConstValueIterator itr = required->Begin(); itr != required->End(); ++itr)\n                    if (itr->IsString())\n                        AddUniqueElement(allProperties, *itr);\n\n            if (dependencies && dependencies->IsObject())\n                for (ConstMemberIterator itr = dependencies->MemberBegin(); itr != dependencies->MemberEnd(); ++itr) {\n                    AddUniqueElement(allProperties, itr->name);\n                    if (itr->value.IsArray())\n                        for (ConstValueIterator i = itr->value.Begin(); i != itr->value.End(); ++i)\n                            if (i->IsString())\n                                AddUniqueElement(allProperties, *i);\n                }\n\n            if (allProperties.Size() > 0) {\n                propertyCount_ = allProperties.Size();\n                properties_ = static_cast<Property*>(allocator_->Malloc(sizeof(Property) * propertyCount_));\n                for (SizeType i = 0; i < propertyCount_; i++) {\n                    new (&properties_[i]) Property();\n                    properties_[i].name = allProperties[i];\n                    properties_[i].schema = GetTypeless();\n                }\n            }\n        }\n\n        if (properties && properties->IsObject()) {\n            PointerType q = p.Append(GetPropertiesString(), allocator_);\n            for (ConstMemberIterator itr = properties->MemberBegin(); itr != properties->MemberEnd(); ++itr) {\n                SizeType index;\n                if (FindPropertyIndex(itr->name, &index))\n                    schemaDocument->CreateSchema(&properties_[index].schema, q.Append(itr->name, allocator_), itr->value, document);\n            }\n        }\n\n        if (const ValueType* v = GetMember(value, GetPatternPropertiesString())) {\n            PointerType q = p.Append(GetPatternPropertiesString(), allocator_);\n            patternProperties_ = static_cast<PatternProperty*>(allocator_->Malloc(sizeof(PatternProperty) * v->MemberCount()));\n            patternPropertyCount_ = 0;\n\n            for (ConstMemberIterator itr = v->MemberBegin(); itr != v->MemberEnd(); ++itr) {\n                new (&patternProperties_[patternPropertyCount_]) PatternProperty();\n                patternProperties_[patternPropertyCount_].pattern = CreatePattern(itr->name);\n                schemaDocument->CreateSchema(&patternProperties_[patternPropertyCount_].schema, q.Append(itr->name, allocator_), itr->value, document);\n                patternPropertyCount_++;\n            }\n        }\n\n        if (required && required->IsArray())\n            for (ConstValueIterator itr = required->Begin(); itr != required->End(); ++itr)\n                if (itr->IsString()) {\n                    SizeType index;\n                    if (FindPropertyIndex(*itr, &index)) {\n                        properties_[index].required = true;\n                        hasRequired_ = true;\n                    }\n                }\n\n        if (dependencies && dependencies->IsObject()) {\n            PointerType q = p.Append(GetDependenciesString(), allocator_);\n            hasDependencies_ = true;\n            for (ConstMemberIterator itr = dependencies->MemberBegin(); itr != dependencies->MemberEnd(); ++itr) {\n                SizeType sourceIndex;\n                if (FindPropertyIndex(itr->name, &sourceIndex)) {\n                    if (itr->value.IsArray()) {\n                        properties_[sourceIndex].dependencies = static_cast<bool*>(allocator_->Malloc(sizeof(bool) * propertyCount_));\n                        std::memset(properties_[sourceIndex].dependencies, 0, sizeof(bool)* propertyCount_);\n                        for (ConstValueIterator targetItr = itr->value.Begin(); targetItr != itr->value.End(); ++targetItr) {\n                            SizeType targetIndex;\n                            if (FindPropertyIndex(*targetItr, &targetIndex))\n                                properties_[sourceIndex].dependencies[targetIndex] = true;\n                        }\n                    }\n                    else if (itr->value.IsObject()) {\n                        hasSchemaDependencies_ = true;\n                        schemaDocument->CreateSchema(&properties_[sourceIndex].dependenciesSchema, q.Append(itr->name, allocator_), itr->value, document);\n                        properties_[sourceIndex].dependenciesValidatorIndex = validatorCount_;\n                        validatorCount_++;\n                    }\n                }\n            }\n        }\n\n        if (const ValueType* v = GetMember(value, GetAdditionalPropertiesString())) {\n            if (v->IsBool())\n                additionalProperties_ = v->GetBool();\n            else if (v->IsObject())\n                schemaDocument->CreateSchema(&additionalPropertiesSchema_, p.Append(GetAdditionalPropertiesString(), allocator_), *v, document);\n        }\n\n        AssignIfExist(minProperties_, value, GetMinPropertiesString());\n        AssignIfExist(maxProperties_, value, GetMaxPropertiesString());\n\n        // Array\n        if (const ValueType* v = GetMember(value, GetItemsString())) {\n            PointerType q = p.Append(GetItemsString(), allocator_);\n            if (v->IsObject()) // List validation\n                schemaDocument->CreateSchema(&itemsList_, q, *v, document);\n            else if (v->IsArray()) { // Tuple validation\n                itemsTuple_ = static_cast<const Schema**>(allocator_->Malloc(sizeof(const Schema*) * v->Size()));\n                SizeType index = 0;\n                for (ConstValueIterator itr = v->Begin(); itr != v->End(); ++itr, index++)\n                    schemaDocument->CreateSchema(&itemsTuple_[itemsTupleCount_++], q.Append(index, allocator_), *itr, document);\n            }\n        }\n\n        AssignIfExist(minItems_, value, GetMinItemsString());\n        AssignIfExist(maxItems_, value, GetMaxItemsString());\n\n        if (const ValueType* v = GetMember(value, GetAdditionalItemsString())) {\n            if (v->IsBool())\n                additionalItems_ = v->GetBool();\n            else if (v->IsObject())\n                schemaDocument->CreateSchema(&additionalItemsSchema_, p.Append(GetAdditionalItemsString(), allocator_), *v, document);\n        }\n\n        AssignIfExist(uniqueItems_, value, GetUniqueItemsString());\n\n        // String\n        AssignIfExist(minLength_, value, GetMinLengthString());\n        AssignIfExist(maxLength_, value, GetMaxLengthString());\n\n        if (const ValueType* v = GetMember(value, GetPatternString()))\n            pattern_ = CreatePattern(*v);\n\n        // Number\n        if (const ValueType* v = GetMember(value, GetMinimumString()))\n            if (v->IsNumber())\n                minimum_.CopyFrom(*v, *allocator_);\n\n        if (const ValueType* v = GetMember(value, GetMaximumString()))\n            if (v->IsNumber())\n                maximum_.CopyFrom(*v, *allocator_);\n\n        AssignIfExist(exclusiveMinimum_, value, GetExclusiveMinimumString());\n        AssignIfExist(exclusiveMaximum_, value, GetExclusiveMaximumString());\n\n        if (const ValueType* v = GetMember(value, GetMultipleOfString()))\n            if (v->IsNumber() && v->GetDouble() > 0.0)\n                multipleOf_.CopyFrom(*v, *allocator_);\n    }\n\n    ~Schema() {\n        if (allocator_) {\n            allocator_->Free(enum_);\n        }\n        if (properties_) {\n            for (SizeType i = 0; i < propertyCount_; i++)\n                properties_[i].~Property();\n            AllocatorType::Free(properties_);\n        }\n        if (patternProperties_) {\n            for (SizeType i = 0; i < patternPropertyCount_; i++)\n                patternProperties_[i].~PatternProperty();\n            AllocatorType::Free(patternProperties_);\n        }\n        AllocatorType::Free(itemsTuple_);\n#if RAPIDJSON_SCHEMA_HAS_REGEX\n        if (pattern_) {\n            pattern_->~RegexType();\n            allocator_->Free(pattern_);\n        }\n#endif\n    }\n\n    bool BeginValue(Context& context) const {\n        if (context.inArray) {\n            if (uniqueItems_)\n                context.valueUniqueness = true;\n\n            if (itemsList_)\n                context.valueSchema = itemsList_;\n            else if (itemsTuple_) {\n                if (context.arrayElementIndex < itemsTupleCount_)\n                    context.valueSchema = itemsTuple_[context.arrayElementIndex];\n                else if (additionalItemsSchema_)\n                    context.valueSchema = additionalItemsSchema_;\n                else if (additionalItems_)\n                    context.valueSchema = GetTypeless();\n                else\n                    RAPIDJSON_INVALID_KEYWORD_RETURN(GetItemsString());\n            }\n            else\n                context.valueSchema = GetTypeless();\n\n            context.arrayElementIndex++;\n        }\n        return true;\n    }\n\n    RAPIDJSON_FORCEINLINE bool EndValue(Context& context) const {\n        if (context.patternPropertiesValidatorCount > 0) {\n            bool otherValid = false;\n            SizeType count = context.patternPropertiesValidatorCount;\n            if (context.objectPatternValidatorType != Context::kPatternValidatorOnly)\n                otherValid = context.patternPropertiesValidators[--count]->IsValid();\n\n            bool patternValid = true;\n            for (SizeType i = 0; i < count; i++)\n                if (!context.patternPropertiesValidators[i]->IsValid()) {\n                    patternValid = false;\n                    break;\n                }\n\n            if (context.objectPatternValidatorType == Context::kPatternValidatorOnly) {\n                if (!patternValid)\n                    RAPIDJSON_INVALID_KEYWORD_RETURN(GetPatternPropertiesString());\n            }\n            else if (context.objectPatternValidatorType == Context::kPatternValidatorWithProperty) {\n                if (!patternValid || !otherValid)\n                    RAPIDJSON_INVALID_KEYWORD_RETURN(GetPatternPropertiesString());\n            }\n            else if (!patternValid && !otherValid) // kPatternValidatorWithAdditionalProperty)\n                RAPIDJSON_INVALID_KEYWORD_RETURN(GetPatternPropertiesString());\n        }\n\n        if (enum_) {\n            const uint64_t h = context.factory.GetHashCode(context.hasher);\n            for (SizeType i = 0; i < enumCount_; i++)\n                if (enum_[i] == h)\n                    goto foundEnum;\n            RAPIDJSON_INVALID_KEYWORD_RETURN(GetEnumString());\n            foundEnum:;\n        }\n\n        if (allOf_.schemas)\n            for (SizeType i = allOf_.begin; i < allOf_.begin + allOf_.count; i++)\n                if (!context.validators[i]->IsValid())\n                    RAPIDJSON_INVALID_KEYWORD_RETURN(GetAllOfString());\n        \n        if (anyOf_.schemas) {\n            for (SizeType i = anyOf_.begin; i < anyOf_.begin + anyOf_.count; i++)\n                if (context.validators[i]->IsValid())\n                    goto foundAny;\n            RAPIDJSON_INVALID_KEYWORD_RETURN(GetAnyOfString());\n            foundAny:;\n        }\n\n        if (oneOf_.schemas) {\n            bool oneValid = false;\n            for (SizeType i = oneOf_.begin; i < oneOf_.begin + oneOf_.count; i++)\n                if (context.validators[i]->IsValid()) {\n                    if (oneValid)\n                        RAPIDJSON_INVALID_KEYWORD_RETURN(GetOneOfString());\n                    else\n                        oneValid = true;\n                }\n            if (!oneValid)\n                RAPIDJSON_INVALID_KEYWORD_RETURN(GetOneOfString());\n        }\n\n        if (not_ && context.validators[notValidatorIndex_]->IsValid())\n            RAPIDJSON_INVALID_KEYWORD_RETURN(GetNotString());\n\n        return true;\n    }\n\n    bool Null(Context& context) const { \n        if (!(type_ & (1 << kNullSchemaType)))\n            RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString());\n        return CreateParallelValidator(context);\n    }\n    \n    bool Bool(Context& context, bool) const { \n        if (!(type_ & (1 << kBooleanSchemaType)))\n            RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString());\n        return CreateParallelValidator(context);\n    }\n\n    bool Int(Context& context, int i) const {\n        if (!CheckInt(context, i))\n            return false;\n        return CreateParallelValidator(context);\n    }\n\n    bool Uint(Context& context, unsigned u) const {\n        if (!CheckUint(context, u))\n            return false;\n        return CreateParallelValidator(context);\n    }\n\n    bool Int64(Context& context, int64_t i) const {\n        if (!CheckInt(context, i))\n            return false;\n        return CreateParallelValidator(context);\n    }\n\n    bool Uint64(Context& context, uint64_t u) const {\n        if (!CheckUint(context, u))\n            return false;\n        return CreateParallelValidator(context);\n    }\n\n    bool Double(Context& context, double d) const {\n        if (!(type_ & (1 << kNumberSchemaType)))\n            RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString());\n\n        if (!minimum_.IsNull() && !CheckDoubleMinimum(context, d))\n            return false;\n\n        if (!maximum_.IsNull() && !CheckDoubleMaximum(context, d))\n            return false;\n        \n        if (!multipleOf_.IsNull() && !CheckDoubleMultipleOf(context, d))\n            return false;\n        \n        return CreateParallelValidator(context);\n    }\n    \n    bool String(Context& context, const Ch* str, SizeType length, bool) const {\n        if (!(type_ & (1 << kStringSchemaType)))\n            RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString());\n\n        if (minLength_ != 0 || maxLength_ != SizeType(~0)) {\n            SizeType count;\n            if (internal::CountStringCodePoint<EncodingType>(str, length, &count)) {\n                if (count < minLength_)\n                    RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinLengthString());\n                if (count > maxLength_)\n                    RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaxLengthString());\n            }\n        }\n\n        if (pattern_ && !IsPatternMatch(pattern_, str, length))\n            RAPIDJSON_INVALID_KEYWORD_RETURN(GetPatternString());\n\n        return CreateParallelValidator(context);\n    }\n\n    bool StartObject(Context& context) const { \n        if (!(type_ & (1 << kObjectSchemaType)))\n            RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString());\n\n        if (hasDependencies_ || hasRequired_) {\n            context.propertyExist = static_cast<bool*>(context.factory.MallocState(sizeof(bool) * propertyCount_));\n            std::memset(context.propertyExist, 0, sizeof(bool) * propertyCount_);\n        }\n\n        if (patternProperties_) { // pre-allocate schema array\n            SizeType count = patternPropertyCount_ + 1; // extra for valuePatternValidatorType\n            context.patternPropertiesSchemas = static_cast<const SchemaType**>(context.factory.MallocState(sizeof(const SchemaType*) * count));\n            context.patternPropertiesSchemaCount = 0;\n            std::memset(context.patternPropertiesSchemas, 0, sizeof(SchemaType*) * count);\n        }\n\n        return CreateParallelValidator(context);\n    }\n    \n    bool Key(Context& context, const Ch* str, SizeType len, bool) const {\n        if (patternProperties_) {\n            context.patternPropertiesSchemaCount = 0;\n            for (SizeType i = 0; i < patternPropertyCount_; i++)\n                if (patternProperties_[i].pattern && IsPatternMatch(patternProperties_[i].pattern, str, len))\n                    context.patternPropertiesSchemas[context.patternPropertiesSchemaCount++] = patternProperties_[i].schema;\n        }\n\n        SizeType index;\n        if (FindPropertyIndex(ValueType(str, len).Move(), &index)) {\n            if (context.patternPropertiesSchemaCount > 0) {\n                context.patternPropertiesSchemas[context.patternPropertiesSchemaCount++] = properties_[index].schema;\n                context.valueSchema = GetTypeless();\n                context.valuePatternValidatorType = Context::kPatternValidatorWithProperty;\n            }\n            else\n                context.valueSchema = properties_[index].schema;\n\n            if (context.propertyExist)\n                context.propertyExist[index] = true;\n\n            return true;\n        }\n\n        if (additionalPropertiesSchema_) {\n            if (additionalPropertiesSchema_ && context.patternPropertiesSchemaCount > 0) {\n                context.patternPropertiesSchemas[context.patternPropertiesSchemaCount++] = additionalPropertiesSchema_;\n                context.valueSchema = GetTypeless();\n                context.valuePatternValidatorType = Context::kPatternValidatorWithAdditionalProperty;\n            }\n            else\n                context.valueSchema = additionalPropertiesSchema_;\n            return true;\n        }\n        else if (additionalProperties_) {\n            context.valueSchema = GetTypeless();\n            return true;\n        }\n\n        if (context.patternPropertiesSchemaCount == 0) // patternProperties are not additional properties\n            RAPIDJSON_INVALID_KEYWORD_RETURN(GetAdditionalPropertiesString());\n\n        return true;\n    }\n\n    bool EndObject(Context& context, SizeType memberCount) const {\n        if (hasRequired_)\n            for (SizeType index = 0; index < propertyCount_; index++)\n                if (properties_[index].required)\n                    if (!context.propertyExist[index])\n                        RAPIDJSON_INVALID_KEYWORD_RETURN(GetRequiredString());\n\n        if (memberCount < minProperties_)\n            RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinPropertiesString());\n\n        if (memberCount > maxProperties_)\n            RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaxPropertiesString());\n\n        if (hasDependencies_) {\n            for (SizeType sourceIndex = 0; sourceIndex < propertyCount_; sourceIndex++)\n                if (context.propertyExist[sourceIndex]) {\n                    if (properties_[sourceIndex].dependencies) {\n                        for (SizeType targetIndex = 0; targetIndex < propertyCount_; targetIndex++)\n                            if (properties_[sourceIndex].dependencies[targetIndex] && !context.propertyExist[targetIndex])\n                                RAPIDJSON_INVALID_KEYWORD_RETURN(GetDependenciesString());\n                    }\n                    else if (properties_[sourceIndex].dependenciesSchema)\n                        if (!context.validators[properties_[sourceIndex].dependenciesValidatorIndex]->IsValid())\n                            RAPIDJSON_INVALID_KEYWORD_RETURN(GetDependenciesString());\n                }\n        }\n\n        return true;\n    }\n\n    bool StartArray(Context& context) const { \n        if (!(type_ & (1 << kArraySchemaType)))\n            RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString());\n\n        context.arrayElementIndex = 0;\n        context.inArray = true;\n\n        return CreateParallelValidator(context);\n    }\n\n    bool EndArray(Context& context, SizeType elementCount) const { \n        context.inArray = false;\n        \n        if (elementCount < minItems_)\n            RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinItemsString());\n        \n        if (elementCount > maxItems_)\n            RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaxItemsString());\n\n        return true;\n    }\n\n    // Generate functions for string literal according to Ch\n#define RAPIDJSON_STRING_(name, ...) \\\n    static const ValueType& Get##name##String() {\\\n        static const Ch s[] = { __VA_ARGS__, '\\0' };\\\n        static const ValueType v(s, sizeof(s) / sizeof(Ch) - 1);\\\n        return v;\\\n    }\n\n    RAPIDJSON_STRING_(Null, 'n', 'u', 'l', 'l')\n    RAPIDJSON_STRING_(Boolean, 'b', 'o', 'o', 'l', 'e', 'a', 'n')\n    RAPIDJSON_STRING_(Object, 'o', 'b', 'j', 'e', 'c', 't')\n    RAPIDJSON_STRING_(Array, 'a', 'r', 'r', 'a', 'y')\n    RAPIDJSON_STRING_(String, 's', 't', 'r', 'i', 'n', 'g')\n    RAPIDJSON_STRING_(Number, 'n', 'u', 'm', 'b', 'e', 'r')\n    RAPIDJSON_STRING_(Integer, 'i', 'n', 't', 'e', 'g', 'e', 'r')\n    RAPIDJSON_STRING_(Type, 't', 'y', 'p', 'e')\n    RAPIDJSON_STRING_(Enum, 'e', 'n', 'u', 'm')\n    RAPIDJSON_STRING_(AllOf, 'a', 'l', 'l', 'O', 'f')\n    RAPIDJSON_STRING_(AnyOf, 'a', 'n', 'y', 'O', 'f')\n    RAPIDJSON_STRING_(OneOf, 'o', 'n', 'e', 'O', 'f')\n    RAPIDJSON_STRING_(Not, 'n', 'o', 't')\n    RAPIDJSON_STRING_(Properties, 'p', 'r', 'o', 'p', 'e', 'r', 't', 'i', 'e', 's')\n    RAPIDJSON_STRING_(Required, 'r', 'e', 'q', 'u', 'i', 'r', 'e', 'd')\n    RAPIDJSON_STRING_(Dependencies, 'd', 'e', 'p', 'e', 'n', 'd', 'e', 'n', 'c', 'i', 'e', 's')\n    RAPIDJSON_STRING_(PatternProperties, 'p', 'a', 't', 't', 'e', 'r', 'n', 'P', 'r', 'o', 'p', 'e', 'r', 't', 'i', 'e', 's')\n    RAPIDJSON_STRING_(AdditionalProperties, 'a', 'd', 'd', 'i', 't', 'i', 'o', 'n', 'a', 'l', 'P', 'r', 'o', 'p', 'e', 'r', 't', 'i', 'e', 's')\n    RAPIDJSON_STRING_(MinProperties, 'm', 'i', 'n', 'P', 'r', 'o', 'p', 'e', 'r', 't', 'i', 'e', 's')\n    RAPIDJSON_STRING_(MaxProperties, 'm', 'a', 'x', 'P', 'r', 'o', 'p', 'e', 'r', 't', 'i', 'e', 's')\n    RAPIDJSON_STRING_(Items, 'i', 't', 'e', 'm', 's')\n    RAPIDJSON_STRING_(MinItems, 'm', 'i', 'n', 'I', 't', 'e', 'm', 's')\n    RAPIDJSON_STRING_(MaxItems, 'm', 'a', 'x', 'I', 't', 'e', 'm', 's')\n    RAPIDJSON_STRING_(AdditionalItems, 'a', 'd', 'd', 'i', 't', 'i', 'o', 'n', 'a', 'l', 'I', 't', 'e', 'm', 's')\n    RAPIDJSON_STRING_(UniqueItems, 'u', 'n', 'i', 'q', 'u', 'e', 'I', 't', 'e', 'm', 's')\n    RAPIDJSON_STRING_(MinLength, 'm', 'i', 'n', 'L', 'e', 'n', 'g', 't', 'h')\n    RAPIDJSON_STRING_(MaxLength, 'm', 'a', 'x', 'L', 'e', 'n', 'g', 't', 'h')\n    RAPIDJSON_STRING_(Pattern, 'p', 'a', 't', 't', 'e', 'r', 'n')\n    RAPIDJSON_STRING_(Minimum, 'm', 'i', 'n', 'i', 'm', 'u', 'm')\n    RAPIDJSON_STRING_(Maximum, 'm', 'a', 'x', 'i', 'm', 'u', 'm')\n    RAPIDJSON_STRING_(ExclusiveMinimum, 'e', 'x', 'c', 'l', 'u', 's', 'i', 'v', 'e', 'M', 'i', 'n', 'i', 'm', 'u', 'm')\n    RAPIDJSON_STRING_(ExclusiveMaximum, 'e', 'x', 'c', 'l', 'u', 's', 'i', 'v', 'e', 'M', 'a', 'x', 'i', 'm', 'u', 'm')\n    RAPIDJSON_STRING_(MultipleOf, 'm', 'u', 'l', 't', 'i', 'p', 'l', 'e', 'O', 'f')\n\n#undef RAPIDJSON_STRING_\n\nprivate:\n    enum SchemaValueType {\n        kNullSchemaType,\n        kBooleanSchemaType,\n        kObjectSchemaType,\n        kArraySchemaType,\n        kStringSchemaType,\n        kNumberSchemaType,\n        kIntegerSchemaType,\n        kTotalSchemaType\n    };\n\n#if RAPIDJSON_SCHEMA_USE_INTERNALREGEX\n        typedef internal::GenericRegex<EncodingType> RegexType;\n#elif RAPIDJSON_SCHEMA_USE_STDREGEX\n        typedef std::basic_regex<Ch> RegexType;\n#else\n        typedef char RegexType;\n#endif\n\n    struct SchemaArray {\n        SchemaArray() : schemas(), count() {}\n        ~SchemaArray() { AllocatorType::Free(schemas); }\n        const SchemaType** schemas;\n        SizeType begin; // begin index of context.validators\n        SizeType count;\n    };\n\n    static const SchemaType* GetTypeless() {\n        static SchemaType typeless(0, PointerType(), ValueType(kObjectType).Move(), ValueType(kObjectType).Move(), 0);\n        return &typeless;\n    }\n\n    template <typename V1, typename V2>\n    void AddUniqueElement(V1& a, const V2& v) {\n        for (typename V1::ConstValueIterator itr = a.Begin(); itr != a.End(); ++itr)\n            if (*itr == v)\n                return;\n        V1 c(v, *allocator_);\n        a.PushBack(c, *allocator_);\n    }\n\n    static const ValueType* GetMember(const ValueType& value, const ValueType& name) {\n        typename ValueType::ConstMemberIterator itr = value.FindMember(name);\n        return itr != value.MemberEnd() ? &(itr->value) : 0;\n    }\n\n    static void AssignIfExist(bool& out, const ValueType& value, const ValueType& name) {\n        if (const ValueType* v = GetMember(value, name))\n            if (v->IsBool())\n                out = v->GetBool();\n    }\n\n    static void AssignIfExist(SizeType& out, const ValueType& value, const ValueType& name) {\n        if (const ValueType* v = GetMember(value, name))\n            if (v->IsUint64() && v->GetUint64() <= SizeType(~0))\n                out = static_cast<SizeType>(v->GetUint64());\n    }\n\n    void AssignIfExist(SchemaArray& out, SchemaDocumentType& schemaDocument, const PointerType& p, const ValueType& value, const ValueType& name, const ValueType& document) {\n        if (const ValueType* v = GetMember(value, name)) {\n            if (v->IsArray() && v->Size() > 0) {\n                PointerType q = p.Append(name, allocator_);\n                out.count = v->Size();\n                out.schemas = static_cast<const Schema**>(allocator_->Malloc(out.count * sizeof(const Schema*)));\n                memset(out.schemas, 0, sizeof(Schema*)* out.count);\n                for (SizeType i = 0; i < out.count; i++)\n                    schemaDocument.CreateSchema(&out.schemas[i], q.Append(i, allocator_), (*v)[i], document);\n                out.begin = validatorCount_;\n                validatorCount_ += out.count;\n            }\n        }\n    }\n\n#if RAPIDJSON_SCHEMA_USE_INTERNALREGEX\n    template <typename ValueType>\n    RegexType* CreatePattern(const ValueType& value) {\n        if (value.IsString()) {\n            RegexType* r = new (allocator_->Malloc(sizeof(RegexType))) RegexType(value.GetString());\n            if (!r->IsValid()) {\n                r->~RegexType();\n                AllocatorType::Free(r);\n                r = 0;\n            }\n            return r;\n        }\n        return 0;\n    }\n\n    static bool IsPatternMatch(const RegexType* pattern, const Ch *str, SizeType) {\n        return pattern->Search(str);\n    }\n#elif RAPIDJSON_SCHEMA_USE_STDREGEX\n    template <typename ValueType>\n    RegexType* CreatePattern(const ValueType& value) {\n        if (value.IsString())\n            try {\n                return new (allocator_->Malloc(sizeof(RegexType))) RegexType(value.GetString(), std::size_t(value.GetStringLength()), std::regex_constants::ECMAScript);\n            }\n            catch (const std::regex_error&) {\n            }\n        return 0;\n    }\n\n    static bool IsPatternMatch(const RegexType* pattern, const Ch *str, SizeType length) {\n        std::match_results<const Ch*> r;\n        return std::regex_search(str, str + length, r, *pattern);\n    }\n#else\n    template <typename ValueType>\n    RegexType* CreatePattern(const ValueType&) { return 0; }\n\n    static bool IsPatternMatch(const RegexType*, const Ch *, SizeType) { return true; }\n#endif // RAPIDJSON_SCHEMA_USE_STDREGEX\n\n    void AddType(const ValueType& type) {\n        if      (type == GetNullString()   ) type_ |= 1 << kNullSchemaType;\n        else if (type == GetBooleanString()) type_ |= 1 << kBooleanSchemaType;\n        else if (type == GetObjectString() ) type_ |= 1 << kObjectSchemaType;\n        else if (type == GetArrayString()  ) type_ |= 1 << kArraySchemaType;\n        else if (type == GetStringString() ) type_ |= 1 << kStringSchemaType;\n        else if (type == GetIntegerString()) type_ |= 1 << kIntegerSchemaType;\n        else if (type == GetNumberString() ) type_ |= (1 << kNumberSchemaType) | (1 << kIntegerSchemaType);\n    }\n\n    bool CreateParallelValidator(Context& context) const {\n        if (enum_ || context.arrayUniqueness)\n            context.hasher = context.factory.CreateHasher();\n\n        if (validatorCount_) {\n            RAPIDJSON_ASSERT(context.validators == 0);\n            context.validators = static_cast<ISchemaValidator**>(context.factory.MallocState(sizeof(ISchemaValidator*) * validatorCount_));\n            context.validatorCount = validatorCount_;\n\n            if (allOf_.schemas)\n                CreateSchemaValidators(context, allOf_);\n\n            if (anyOf_.schemas)\n                CreateSchemaValidators(context, anyOf_);\n            \n            if (oneOf_.schemas)\n                CreateSchemaValidators(context, oneOf_);\n            \n            if (not_)\n                context.validators[notValidatorIndex_] = context.factory.CreateSchemaValidator(*not_);\n            \n            if (hasSchemaDependencies_) {\n                for (SizeType i = 0; i < propertyCount_; i++)\n                    if (properties_[i].dependenciesSchema)\n                        context.validators[properties_[i].dependenciesValidatorIndex] = context.factory.CreateSchemaValidator(*properties_[i].dependenciesSchema);\n            }\n        }\n\n        return true;\n    }\n\n    void CreateSchemaValidators(Context& context, const SchemaArray& schemas) const {\n        for (SizeType i = 0; i < schemas.count; i++)\n            context.validators[schemas.begin + i] = context.factory.CreateSchemaValidator(*schemas.schemas[i]);\n    }\n\n    // O(n)\n    bool FindPropertyIndex(const ValueType& name, SizeType* outIndex) const {\n        SizeType len = name.GetStringLength();\n        const Ch* str = name.GetString();\n        for (SizeType index = 0; index < propertyCount_; index++)\n            if (properties_[index].name.GetStringLength() == len && \n                (std::memcmp(properties_[index].name.GetString(), str, sizeof(Ch) * len) == 0))\n            {\n                *outIndex = index;\n                return true;\n            }\n        return false;\n    }\n\n    bool CheckInt(Context& context, int64_t i) const {\n        if (!(type_ & ((1 << kIntegerSchemaType) | (1 << kNumberSchemaType))))\n            RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString());\n\n        if (!minimum_.IsNull()) {\n            if (minimum_.IsInt64()) {\n                if (exclusiveMinimum_ ? i <= minimum_.GetInt64() : i < minimum_.GetInt64())\n                    RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinimumString());\n            }\n            else if (minimum_.IsUint64()) {\n                RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinimumString()); // i <= max(int64_t) < minimum.GetUint64()\n            }\n            else if (!CheckDoubleMinimum(context, static_cast<double>(i)))\n                return false;\n        }\n\n        if (!maximum_.IsNull()) {\n            if (maximum_.IsInt64()) {\n                if (exclusiveMaximum_ ? i >= maximum_.GetInt64() : i > maximum_.GetInt64())\n                    RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaximumString());\n            }\n            else if (maximum_.IsUint64())\n                /* do nothing */; // i <= max(int64_t) < maximum_.GetUint64()\n            else if (!CheckDoubleMaximum(context, static_cast<double>(i)))\n                return false;\n        }\n\n        if (!multipleOf_.IsNull()) {\n            if (multipleOf_.IsUint64()) {\n                if (static_cast<uint64_t>(i >= 0 ? i : -i) % multipleOf_.GetUint64() != 0)\n                    RAPIDJSON_INVALID_KEYWORD_RETURN(GetMultipleOfString());\n            }\n            else if (!CheckDoubleMultipleOf(context, static_cast<double>(i)))\n                return false;\n        }\n\n        return true;\n    }\n\n    bool CheckUint(Context& context, uint64_t i) const {\n        if (!(type_ & ((1 << kIntegerSchemaType) | (1 << kNumberSchemaType))))\n            RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString());\n\n        if (!minimum_.IsNull()) {\n            if (minimum_.IsUint64()) {\n                if (exclusiveMinimum_ ? i <= minimum_.GetUint64() : i < minimum_.GetUint64())\n                    RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinimumString());\n            }\n            else if (minimum_.IsInt64())\n                /* do nothing */; // i >= 0 > minimum.Getint64()\n            else if (!CheckDoubleMinimum(context, static_cast<double>(i)))\n                return false;\n        }\n\n        if (!maximum_.IsNull()) {\n            if (maximum_.IsUint64()) {\n                if (exclusiveMaximum_ ? i >= maximum_.GetUint64() : i > maximum_.GetUint64())\n                    RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaximumString());\n            }\n            else if (maximum_.IsInt64())\n                RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaximumString()); // i >= 0 > maximum_\n            else if (!CheckDoubleMaximum(context, static_cast<double>(i)))\n                return false;\n        }\n\n        if (!multipleOf_.IsNull()) {\n            if (multipleOf_.IsUint64()) {\n                if (i % multipleOf_.GetUint64() != 0)\n                    RAPIDJSON_INVALID_KEYWORD_RETURN(GetMultipleOfString());\n            }\n            else if (!CheckDoubleMultipleOf(context, static_cast<double>(i)))\n                return false;\n        }\n\n        return true;\n    }\n\n    bool CheckDoubleMinimum(Context& context, double d) const {\n        if (exclusiveMinimum_ ? d <= minimum_.GetDouble() : d < minimum_.GetDouble())\n            RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinimumString());\n        return true;\n    }\n\n    bool CheckDoubleMaximum(Context& context, double d) const {\n        if (exclusiveMaximum_ ? d >= maximum_.GetDouble() : d > maximum_.GetDouble())\n            RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaximumString());\n        return true;\n    }\n\n    bool CheckDoubleMultipleOf(Context& context, double d) const {\n        double a = std::abs(d), b = std::abs(multipleOf_.GetDouble());\n        double q = std::floor(a / b);\n        double r = a - q * b;\n        if (r > 0.0)\n            RAPIDJSON_INVALID_KEYWORD_RETURN(GetMultipleOfString());\n        return true;\n    }\n\n    struct Property {\n        Property() : schema(), dependenciesSchema(), dependenciesValidatorIndex(), dependencies(), required(false) {}\n        ~Property() { AllocatorType::Free(dependencies); }\n        SValue name;\n        const SchemaType* schema;\n        const SchemaType* dependenciesSchema;\n        SizeType dependenciesValidatorIndex;\n        bool* dependencies;\n        bool required;\n    };\n\n    struct PatternProperty {\n        PatternProperty() : schema(), pattern() {}\n        ~PatternProperty() { \n            if (pattern) {\n                pattern->~RegexType();\n                AllocatorType::Free(pattern);\n            }\n        }\n        const SchemaType* schema;\n        RegexType* pattern;\n    };\n\n    AllocatorType* allocator_;\n    uint64_t* enum_;\n    SizeType enumCount_;\n    SchemaArray allOf_;\n    SchemaArray anyOf_;\n    SchemaArray oneOf_;\n    const SchemaType* not_;\n    unsigned type_; // bitmask of kSchemaType\n    SizeType validatorCount_;\n    SizeType notValidatorIndex_;\n\n    Property* properties_;\n    const SchemaType* additionalPropertiesSchema_;\n    PatternProperty* patternProperties_;\n    SizeType patternPropertyCount_;\n    SizeType propertyCount_;\n    SizeType minProperties_;\n    SizeType maxProperties_;\n    bool additionalProperties_;\n    bool hasDependencies_;\n    bool hasRequired_;\n    bool hasSchemaDependencies_;\n\n    const SchemaType* additionalItemsSchema_;\n    const SchemaType* itemsList_;\n    const SchemaType** itemsTuple_;\n    SizeType itemsTupleCount_;\n    SizeType minItems_;\n    SizeType maxItems_;\n    bool additionalItems_;\n    bool uniqueItems_;\n\n    RegexType* pattern_;\n    SizeType minLength_;\n    SizeType maxLength_;\n\n    SValue minimum_;\n    SValue maximum_;\n    SValue multipleOf_;\n    bool exclusiveMinimum_;\n    bool exclusiveMaximum_;\n};\n\ntemplate<typename Stack, typename Ch>\nstruct TokenHelper {\n    RAPIDJSON_FORCEINLINE static void AppendIndexToken(Stack& documentStack, SizeType index) {\n        *documentStack.template Push<Ch>() = '/';\n        char buffer[21];\n        size_t length = static_cast<size_t>((sizeof(SizeType) == 4 ? u32toa(index, buffer) : u64toa(index, buffer)) - buffer);\n        for (size_t i = 0; i < length; i++)\n            *documentStack.template Push<Ch>() = buffer[i];\n    }\n};\n\n// Partial specialized version for char to prevent buffer copying.\ntemplate <typename Stack>\nstruct TokenHelper<Stack, char> {\n    RAPIDJSON_FORCEINLINE static void AppendIndexToken(Stack& documentStack, SizeType index) {\n        if (sizeof(SizeType) == 4) {\n            char *buffer = documentStack.template Push<char>(1 + 10); // '/' + uint\n            *buffer++ = '/';\n            const char* end = internal::u32toa(index, buffer);\n             documentStack.template Pop<char>(static_cast<size_t>(10 - (end - buffer)));\n        }\n        else {\n            char *buffer = documentStack.template Push<char>(1 + 20); // '/' + uint64\n            *buffer++ = '/';\n            const char* end = internal::u64toa(index, buffer);\n            documentStack.template Pop<char>(static_cast<size_t>(20 - (end - buffer)));\n        }\n    }\n};\n\n} // namespace internal\n\n///////////////////////////////////////////////////////////////////////////////\n// IGenericRemoteSchemaDocumentProvider\n\ntemplate <typename SchemaDocumentType>\nclass IGenericRemoteSchemaDocumentProvider {\npublic:\n    typedef typename SchemaDocumentType::Ch Ch;\n\n    virtual ~IGenericRemoteSchemaDocumentProvider() {}\n    virtual const SchemaDocumentType* GetRemoteDocument(const Ch* uri, SizeType length) = 0;\n};\n\n///////////////////////////////////////////////////////////////////////////////\n// GenericSchemaDocument\n\n//! JSON schema document.\n/*!\n    A JSON schema document is a compiled version of a JSON schema.\n    It is basically a tree of internal::Schema.\n\n    \\note This is an immutable class (i.e. its instance cannot be modified after construction).\n    \\tparam ValueT Type of JSON value (e.g. \\c Value ), which also determine the encoding.\n    \\tparam Allocator Allocator type for allocating memory of this document.\n*/\ntemplate <typename ValueT, typename Allocator = CrtAllocator>\nclass GenericSchemaDocument {\npublic:\n    typedef ValueT ValueType;\n    typedef IGenericRemoteSchemaDocumentProvider<GenericSchemaDocument> IRemoteSchemaDocumentProviderType;\n    typedef Allocator AllocatorType;\n    typedef typename ValueType::EncodingType EncodingType;\n    typedef typename EncodingType::Ch Ch;\n    typedef internal::Schema<GenericSchemaDocument> SchemaType;\n    typedef GenericPointer<ValueType, Allocator> PointerType;\n    friend class internal::Schema<GenericSchemaDocument>;\n    template <typename, typename, typename>\n    friend class GenericSchemaValidator;\n\n    //! Constructor.\n    /*!\n        Compile a JSON document into schema document.\n\n        \\param document A JSON document as source.\n        \\param remoteProvider An optional remote schema document provider for resolving remote reference. Can be null.\n        \\param allocator An optional allocator instance for allocating memory. Can be null.\n    */\n    explicit GenericSchemaDocument(const ValueType& document, IRemoteSchemaDocumentProviderType* remoteProvider = 0, Allocator* allocator = 0) :\n        remoteProvider_(remoteProvider),\n        allocator_(allocator),\n        ownAllocator_(),\n        root_(),\n        schemaMap_(allocator, kInitialSchemaMapSize),\n        schemaRef_(allocator, kInitialSchemaRefSize)\n    {\n        if (!allocator_)\n            ownAllocator_ = allocator_ = RAPIDJSON_NEW(Allocator());\n\n        // Generate root schema, it will call CreateSchema() to create sub-schemas,\n        // And call AddRefSchema() if there are $ref.\n        CreateSchemaRecursive(&root_, PointerType(), document, document);\n\n        // Resolve $ref\n        while (!schemaRef_.Empty()) {\n            SchemaRefEntry* refEntry = schemaRef_.template Pop<SchemaRefEntry>(1);\n            if (const SchemaType* s = GetSchema(refEntry->target)) {\n                if (refEntry->schema)\n                    *refEntry->schema = s;\n\n                // Create entry in map if not exist\n                if (!GetSchema(refEntry->source)) {\n                    new (schemaMap_.template Push<SchemaEntry>()) SchemaEntry(refEntry->source, const_cast<SchemaType*>(s), false, allocator_);\n                }\n            }\n            refEntry->~SchemaRefEntry();\n        }\n\n        RAPIDJSON_ASSERT(root_ != 0);\n\n        schemaRef_.ShrinkToFit(); // Deallocate all memory for ref\n    }\n\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\n    //! Move constructor in C++11\n    GenericSchemaDocument(GenericSchemaDocument&& rhs) RAPIDJSON_NOEXCEPT :\n        remoteProvider_(rhs.remoteProvider_),\n        allocator_(rhs.allocator_),\n        ownAllocator_(rhs.ownAllocator_),\n        root_(rhs.root_),\n        schemaMap_(std::move(rhs.schemaMap_)),\n        schemaRef_(std::move(rhs.schemaRef_))\n    {\n        rhs.remoteProvider_ = 0;\n        rhs.allocator_ = 0;\n        rhs.ownAllocator_ = 0;\n    }\n#endif\n\n    //! Destructor\n    ~GenericSchemaDocument() {\n        while (!schemaMap_.Empty())\n            schemaMap_.template Pop<SchemaEntry>(1)->~SchemaEntry();\n\n        RAPIDJSON_DELETE(ownAllocator_);\n    }\n\n    //! Get the root schema.\n    const SchemaType& GetRoot() const { return *root_; }\n\nprivate:\n    //! Prohibit copying\n    GenericSchemaDocument(const GenericSchemaDocument&);\n    //! Prohibit assignment\n    GenericSchemaDocument& operator=(const GenericSchemaDocument&);\n\n    struct SchemaRefEntry {\n        SchemaRefEntry(const PointerType& s, const PointerType& t, const SchemaType** outSchema, Allocator *allocator) : source(s, allocator), target(t, allocator), schema(outSchema) {}\n        PointerType source;\n        PointerType target;\n        const SchemaType** schema;\n    };\n\n    struct SchemaEntry {\n        SchemaEntry(const PointerType& p, SchemaType* s, bool o, Allocator* allocator) : pointer(p, allocator), schema(s), owned(o) {}\n        ~SchemaEntry() {\n            if (owned) {\n                schema->~SchemaType();\n                Allocator::Free(schema);\n            }\n        }\n        PointerType pointer;\n        SchemaType* schema;\n        bool owned;\n    };\n\n    void CreateSchemaRecursive(const SchemaType** schema, const PointerType& pointer, const ValueType& v, const ValueType& document) {\n        if (schema)\n            *schema = SchemaType::GetTypeless();\n\n        if (v.GetType() == kObjectType) {\n            const SchemaType* s = GetSchema(pointer);\n            if (!s)\n                CreateSchema(schema, pointer, v, document);\n\n            for (typename ValueType::ConstMemberIterator itr = v.MemberBegin(); itr != v.MemberEnd(); ++itr)\n                CreateSchemaRecursive(0, pointer.Append(itr->name, allocator_), itr->value, document);\n        }\n        else if (v.GetType() == kArrayType)\n            for (SizeType i = 0; i < v.Size(); i++)\n                CreateSchemaRecursive(0, pointer.Append(i, allocator_), v[i], document);\n    }\n\n    void CreateSchema(const SchemaType** schema, const PointerType& pointer, const ValueType& v, const ValueType& document) {\n        RAPIDJSON_ASSERT(pointer.IsValid());\n        if (v.IsObject()) {\n            if (!HandleRefSchema(pointer, schema, v, document)) {\n                SchemaType* s = new (allocator_->Malloc(sizeof(SchemaType))) SchemaType(this, pointer, v, document, allocator_);\n                new (schemaMap_.template Push<SchemaEntry>()) SchemaEntry(pointer, s, true, allocator_);\n                if (schema)\n                    *schema = s;\n            }\n        }\n    }\n\n    bool HandleRefSchema(const PointerType& source, const SchemaType** schema, const ValueType& v, const ValueType& document) {\n        static const Ch kRefString[] = { '$', 'r', 'e', 'f', '\\0' };\n        static const ValueType kRefValue(kRefString, 4);\n\n        typename ValueType::ConstMemberIterator itr = v.FindMember(kRefValue);\n        if (itr == v.MemberEnd())\n            return false;\n\n        if (itr->value.IsString()) {\n            SizeType len = itr->value.GetStringLength();\n            if (len > 0) {\n                const Ch* s = itr->value.GetString();\n                SizeType i = 0;\n                while (i < len && s[i] != '#') // Find the first #\n                    i++;\n\n                if (i > 0) { // Remote reference, resolve immediately\n                    if (remoteProvider_) {\n                        if (const GenericSchemaDocument* remoteDocument = remoteProvider_->GetRemoteDocument(s, i - 1)) {\n                            PointerType pointer(&s[i], len - i, allocator_);\n                            if (pointer.IsValid()) {\n                                if (const SchemaType* sc = remoteDocument->GetSchema(pointer)) {\n                                    if (schema)\n                                        *schema = sc;\n                                    return true;\n                                }\n                            }\n                        }\n                    }\n                }\n                else if (s[i] == '#') { // Local reference, defer resolution\n                    PointerType pointer(&s[i], len - i, allocator_);\n                    if (pointer.IsValid()) {\n                        if (const ValueType* nv = pointer.Get(document))\n                            if (HandleRefSchema(source, schema, *nv, document))\n                                return true;\n\n                        new (schemaRef_.template Push<SchemaRefEntry>()) SchemaRefEntry(source, pointer, schema, allocator_);\n                        return true;\n                    }\n                }\n            }\n        }\n        return false;\n    }\n\n    const SchemaType* GetSchema(const PointerType& pointer) const {\n        for (const SchemaEntry* target = schemaMap_.template Bottom<SchemaEntry>(); target != schemaMap_.template End<SchemaEntry>(); ++target)\n            if (pointer == target->pointer)\n                return target->schema;\n        return 0;\n    }\n\n    PointerType GetPointer(const SchemaType* schema) const {\n        for (const SchemaEntry* target = schemaMap_.template Bottom<SchemaEntry>(); target != schemaMap_.template End<SchemaEntry>(); ++target)\n            if (schema == target->schema)\n                return target->pointer;\n        return PointerType();\n    }\n\n    static const size_t kInitialSchemaMapSize = 64;\n    static const size_t kInitialSchemaRefSize = 64;\n\n    IRemoteSchemaDocumentProviderType* remoteProvider_;\n    Allocator *allocator_;\n    Allocator *ownAllocator_;\n    const SchemaType* root_;                //!< Root schema.\n    internal::Stack<Allocator> schemaMap_;  // Stores created Pointer -> Schemas\n    internal::Stack<Allocator> schemaRef_;  // Stores Pointer from $ref and schema which holds the $ref\n};\n\n//! GenericSchemaDocument using Value type.\ntypedef GenericSchemaDocument<Value> SchemaDocument;\n//! IGenericRemoteSchemaDocumentProvider using SchemaDocument.\ntypedef IGenericRemoteSchemaDocumentProvider<SchemaDocument> IRemoteSchemaDocumentProvider;\n\n///////////////////////////////////////////////////////////////////////////////\n// GenericSchemaValidator\n\n//! JSON Schema Validator.\n/*!\n    A SAX style JSON schema validator.\n    It uses a \\c GenericSchemaDocument to validate SAX events.\n    It delegates the incoming SAX events to an output handler.\n    The default output handler does nothing.\n    It can be reused multiple times by calling \\c Reset().\n\n    \\tparam SchemaDocumentType Type of schema document.\n    \\tparam OutputHandler Type of output handler. Default handler does nothing.\n    \\tparam StateAllocator Allocator for storing the internal validation states.\n*/\ntemplate <\n    typename SchemaDocumentType,\n    typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>,\n    typename StateAllocator = CrtAllocator>\nclass GenericSchemaValidator :\n    public internal::ISchemaStateFactory<typename SchemaDocumentType::SchemaType>, \n    public internal::ISchemaValidator\n{\npublic:\n    typedef typename SchemaDocumentType::SchemaType SchemaType;\n    typedef typename SchemaDocumentType::PointerType PointerType;\n    typedef typename SchemaType::EncodingType EncodingType;\n    typedef typename EncodingType::Ch Ch;\n\n    //! Constructor without output handler.\n    /*!\n        \\param schemaDocument The schema document to conform to.\n        \\param allocator Optional allocator for storing internal validation states.\n        \\param schemaStackCapacity Optional initial capacity of schema path stack.\n        \\param documentStackCapacity Optional initial capacity of document path stack.\n    */\n    GenericSchemaValidator(\n        const SchemaDocumentType& schemaDocument,\n        StateAllocator* allocator = 0, \n        size_t schemaStackCapacity = kDefaultSchemaStackCapacity,\n        size_t documentStackCapacity = kDefaultDocumentStackCapacity)\n        :\n        schemaDocument_(&schemaDocument),\n        root_(schemaDocument.GetRoot()),\n        outputHandler_(GetNullHandler()),\n        stateAllocator_(allocator),\n        ownStateAllocator_(0),\n        schemaStack_(allocator, schemaStackCapacity),\n        documentStack_(allocator, documentStackCapacity),\n        valid_(true)\n#if RAPIDJSON_SCHEMA_VERBOSE\n        , depth_(0)\n#endif\n    {\n    }\n\n    //! Constructor with output handler.\n    /*!\n        \\param schemaDocument The schema document to conform to.\n        \\param allocator Optional allocator for storing internal validation states.\n        \\param schemaStackCapacity Optional initial capacity of schema path stack.\n        \\param documentStackCapacity Optional initial capacity of document path stack.\n    */\n    GenericSchemaValidator(\n        const SchemaDocumentType& schemaDocument,\n        OutputHandler& outputHandler,\n        StateAllocator* allocator = 0, \n        size_t schemaStackCapacity = kDefaultSchemaStackCapacity,\n        size_t documentStackCapacity = kDefaultDocumentStackCapacity)\n        :\n        schemaDocument_(&schemaDocument),\n        root_(schemaDocument.GetRoot()),\n        outputHandler_(outputHandler),\n        stateAllocator_(allocator),\n        ownStateAllocator_(0),\n        schemaStack_(allocator, schemaStackCapacity),\n        documentStack_(allocator, documentStackCapacity),\n        valid_(true)\n#if RAPIDJSON_SCHEMA_VERBOSE\n        , depth_(0)\n#endif\n    {\n    }\n\n    //! Destructor.\n    ~GenericSchemaValidator() {\n        Reset();\n        RAPIDJSON_DELETE(ownStateAllocator_);\n    }\n\n    //! Reset the internal states.\n    void Reset() {\n        while (!schemaStack_.Empty())\n            PopSchema();\n        documentStack_.Clear();\n        valid_ = true;\n    }\n\n    //! Checks whether the current state is valid.\n    // Implementation of ISchemaValidator\n    virtual bool IsValid() const { return valid_; }\n\n    //! Gets the JSON pointer pointed to the invalid schema.\n    PointerType GetInvalidSchemaPointer() const {\n        return schemaStack_.Empty() ? PointerType() : schemaDocument_->GetPointer(&CurrentSchema());\n    }\n\n    //! Gets the keyword of invalid schema.\n    const Ch* GetInvalidSchemaKeyword() const {\n        return schemaStack_.Empty() ? 0 : CurrentContext().invalidKeyword;\n    }\n\n    //! Gets the JSON pointer pointed to the invalid value.\n    PointerType GetInvalidDocumentPointer() const {\n        return documentStack_.Empty() ? PointerType() : PointerType(documentStack_.template Bottom<Ch>(), documentStack_.GetSize() / sizeof(Ch));\n    }\n\n#if RAPIDJSON_SCHEMA_VERBOSE\n#define RAPIDJSON_SCHEMA_HANDLE_BEGIN_VERBOSE_() \\\nRAPIDJSON_MULTILINEMACRO_BEGIN\\\n    *documentStack_.template Push<Ch>() = '\\0';\\\n    documentStack_.template Pop<Ch>(1);\\\n    internal::PrintInvalidDocument(documentStack_.template Bottom<Ch>());\\\nRAPIDJSON_MULTILINEMACRO_END\n#else\n#define RAPIDJSON_SCHEMA_HANDLE_BEGIN_VERBOSE_()\n#endif\n\n#define RAPIDJSON_SCHEMA_HANDLE_BEGIN_(method, arg1)\\\n    if (!valid_) return false; \\\n    if (!BeginValue() || !CurrentSchema().method arg1) {\\\n        RAPIDJSON_SCHEMA_HANDLE_BEGIN_VERBOSE_();\\\n        return valid_ = false;\\\n    }\n\n#define RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(method, arg2)\\\n    for (Context* context = schemaStack_.template Bottom<Context>(); context != schemaStack_.template End<Context>(); context++) {\\\n        if (context->hasher)\\\n            static_cast<HasherType*>(context->hasher)->method arg2;\\\n        if (context->validators)\\\n            for (SizeType i_ = 0; i_ < context->validatorCount; i_++)\\\n                static_cast<GenericSchemaValidator*>(context->validators[i_])->method arg2;\\\n        if (context->patternPropertiesValidators)\\\n            for (SizeType i_ = 0; i_ < context->patternPropertiesValidatorCount; i_++)\\\n                static_cast<GenericSchemaValidator*>(context->patternPropertiesValidators[i_])->method arg2;\\\n    }\n\n#define RAPIDJSON_SCHEMA_HANDLE_END_(method, arg2)\\\n    return valid_ = EndValue() && outputHandler_.method arg2\n\n#define RAPIDJSON_SCHEMA_HANDLE_VALUE_(method, arg1, arg2) \\\n    RAPIDJSON_SCHEMA_HANDLE_BEGIN_   (method, arg1);\\\n    RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(method, arg2);\\\n    RAPIDJSON_SCHEMA_HANDLE_END_     (method, arg2)\n\n    bool Null()             { RAPIDJSON_SCHEMA_HANDLE_VALUE_(Null,   (CurrentContext()   ), ( )); }\n    bool Bool(bool b)       { RAPIDJSON_SCHEMA_HANDLE_VALUE_(Bool,   (CurrentContext(), b), (b)); }\n    bool Int(int i)         { RAPIDJSON_SCHEMA_HANDLE_VALUE_(Int,    (CurrentContext(), i), (i)); }\n    bool Uint(unsigned u)   { RAPIDJSON_SCHEMA_HANDLE_VALUE_(Uint,   (CurrentContext(), u), (u)); }\n    bool Int64(int64_t i)   { RAPIDJSON_SCHEMA_HANDLE_VALUE_(Int64,  (CurrentContext(), i), (i)); }\n    bool Uint64(uint64_t u) { RAPIDJSON_SCHEMA_HANDLE_VALUE_(Uint64, (CurrentContext(), u), (u)); }\n    bool Double(double d)   { RAPIDJSON_SCHEMA_HANDLE_VALUE_(Double, (CurrentContext(), d), (d)); }\n    bool RawNumber(const Ch* str, SizeType length, bool copy)\n                                    { RAPIDJSON_SCHEMA_HANDLE_VALUE_(String, (CurrentContext(), str, length, copy), (str, length, copy)); }\n    bool String(const Ch* str, SizeType length, bool copy)\n                                    { RAPIDJSON_SCHEMA_HANDLE_VALUE_(String, (CurrentContext(), str, length, copy), (str, length, copy)); }\n\n    bool StartObject() {\n        RAPIDJSON_SCHEMA_HANDLE_BEGIN_(StartObject, (CurrentContext()));\n        RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(StartObject, ());\n        return valid_ = outputHandler_.StartObject();\n    }\n    \n    bool Key(const Ch* str, SizeType len, bool copy) {\n        if (!valid_) return false;\n        AppendToken(str, len);\n        if (!CurrentSchema().Key(CurrentContext(), str, len, copy)) return valid_ = false;\n        RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(Key, (str, len, copy));\n        return valid_ = outputHandler_.Key(str, len, copy);\n    }\n    \n    bool EndObject(SizeType memberCount) { \n        if (!valid_) return false;\n        RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(EndObject, (memberCount));\n        if (!CurrentSchema().EndObject(CurrentContext(), memberCount)) return valid_ = false;\n        RAPIDJSON_SCHEMA_HANDLE_END_(EndObject, (memberCount));\n    }\n\n    bool StartArray() {\n        RAPIDJSON_SCHEMA_HANDLE_BEGIN_(StartArray, (CurrentContext()));\n        RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(StartArray, ());\n        return valid_ = outputHandler_.StartArray();\n    }\n    \n    bool EndArray(SizeType elementCount) {\n        if (!valid_) return false;\n        RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(EndArray, (elementCount));\n        if (!CurrentSchema().EndArray(CurrentContext(), elementCount)) return valid_ = false;\n        RAPIDJSON_SCHEMA_HANDLE_END_(EndArray, (elementCount));\n    }\n\n#undef RAPIDJSON_SCHEMA_HANDLE_BEGIN_VERBOSE_\n#undef RAPIDJSON_SCHEMA_HANDLE_BEGIN_\n#undef RAPIDJSON_SCHEMA_HANDLE_PARALLEL_\n#undef RAPIDJSON_SCHEMA_HANDLE_VALUE_\n\n    // Implementation of ISchemaStateFactory<SchemaType>\n    virtual ISchemaValidator* CreateSchemaValidator(const SchemaType& root) {\n        return new (GetStateAllocator().Malloc(sizeof(GenericSchemaValidator))) GenericSchemaValidator(*schemaDocument_, root,\n#if RAPIDJSON_SCHEMA_VERBOSE\n        depth_ + 1,\n#endif\n        &GetStateAllocator());\n    }\n\n    virtual void DestroySchemaValidator(ISchemaValidator* validator) {\n        GenericSchemaValidator* v = static_cast<GenericSchemaValidator*>(validator);\n        v->~GenericSchemaValidator();\n        StateAllocator::Free(v);\n    }\n\n    virtual void* CreateHasher() {\n        return new (GetStateAllocator().Malloc(sizeof(HasherType))) HasherType(&GetStateAllocator());\n    }\n\n    virtual uint64_t GetHashCode(void* hasher) {\n        return static_cast<HasherType*>(hasher)->GetHashCode();\n    }\n\n    virtual void DestroryHasher(void* hasher) {\n        HasherType* h = static_cast<HasherType*>(hasher);\n        h->~HasherType();\n        StateAllocator::Free(h);\n    }\n\n    virtual void* MallocState(size_t size) {\n        return GetStateAllocator().Malloc(size);\n    }\n\n    virtual void FreeState(void* p) {\n        return StateAllocator::Free(p);\n    }\n\nprivate:\n    typedef typename SchemaType::Context Context;\n    typedef GenericValue<UTF8<>, StateAllocator> HashCodeArray;\n    typedef internal::Hasher<EncodingType, StateAllocator> HasherType;\n\n    GenericSchemaValidator( \n        const SchemaDocumentType& schemaDocument,\n        const SchemaType& root,\n#if RAPIDJSON_SCHEMA_VERBOSE\n        unsigned depth,\n#endif\n        StateAllocator* allocator = 0,\n        size_t schemaStackCapacity = kDefaultSchemaStackCapacity,\n        size_t documentStackCapacity = kDefaultDocumentStackCapacity)\n        :\n        schemaDocument_(&schemaDocument),\n        root_(root),\n        outputHandler_(GetNullHandler()),\n        stateAllocator_(allocator),\n        ownStateAllocator_(0),\n        schemaStack_(allocator, schemaStackCapacity),\n        documentStack_(allocator, documentStackCapacity),\n        valid_(true)\n#if RAPIDJSON_SCHEMA_VERBOSE\n        , depth_(depth)\n#endif\n    {\n    }\n\n    StateAllocator& GetStateAllocator() {\n        if (!stateAllocator_)\n            stateAllocator_ = ownStateAllocator_ = RAPIDJSON_NEW(StateAllocator());\n        return *stateAllocator_;\n    }\n\n    bool BeginValue() {\n        if (schemaStack_.Empty())\n            PushSchema(root_);\n        else {\n            if (CurrentContext().inArray)\n                internal::TokenHelper<internal::Stack<StateAllocator>, Ch>::AppendIndexToken(documentStack_, CurrentContext().arrayElementIndex);\n\n            if (!CurrentSchema().BeginValue(CurrentContext()))\n                return false;\n\n            SizeType count = CurrentContext().patternPropertiesSchemaCount;\n            const SchemaType** sa = CurrentContext().patternPropertiesSchemas;\n            typename Context::PatternValidatorType patternValidatorType = CurrentContext().valuePatternValidatorType;\n            bool valueUniqueness = CurrentContext().valueUniqueness;\n            if (CurrentContext().valueSchema)\n                PushSchema(*CurrentContext().valueSchema);\n\n            if (count > 0) {\n                CurrentContext().objectPatternValidatorType = patternValidatorType;\n                ISchemaValidator**& va = CurrentContext().patternPropertiesValidators;\n                SizeType& validatorCount = CurrentContext().patternPropertiesValidatorCount;\n                va = static_cast<ISchemaValidator**>(MallocState(sizeof(ISchemaValidator*) * count));\n                for (SizeType i = 0; i < count; i++)\n                    va[validatorCount++] = CreateSchemaValidator(*sa[i]);\n            }\n\n            CurrentContext().arrayUniqueness = valueUniqueness;\n        }\n        return true;\n    }\n\n    bool EndValue() {\n        if (!CurrentSchema().EndValue(CurrentContext()))\n            return false;\n\n#if RAPIDJSON_SCHEMA_VERBOSE\n        GenericStringBuffer<EncodingType> sb;\n        schemaDocument_->GetPointer(&CurrentSchema()).Stringify(sb);\n\n        *documentStack_.template Push<Ch>() = '\\0';\n        documentStack_.template Pop<Ch>(1);\n        internal::PrintValidatorPointers(depth_, sb.GetString(), documentStack_.template Bottom<Ch>());\n#endif\n\n        uint64_t h = CurrentContext().arrayUniqueness ? static_cast<HasherType*>(CurrentContext().hasher)->GetHashCode() : 0;\n        \n        PopSchema();\n\n        if (!schemaStack_.Empty()) {\n            Context& context = CurrentContext();\n            if (context.valueUniqueness) {\n                HashCodeArray* a = static_cast<HashCodeArray*>(context.arrayElementHashCodes);\n                if (!a)\n                    CurrentContext().arrayElementHashCodes = a = new (GetStateAllocator().Malloc(sizeof(HashCodeArray))) HashCodeArray(kArrayType);\n                for (typename HashCodeArray::ConstValueIterator itr = a->Begin(); itr != a->End(); ++itr)\n                    if (itr->GetUint64() == h)\n                        RAPIDJSON_INVALID_KEYWORD_RETURN(SchemaType::GetUniqueItemsString());\n                a->PushBack(h, GetStateAllocator());\n            }\n        }\n\n        // Remove the last token of document pointer\n        while (!documentStack_.Empty() && *documentStack_.template Pop<Ch>(1) != '/')\n            ;\n\n        return true;\n    }\n\n    void AppendToken(const Ch* str, SizeType len) {\n        documentStack_.template Reserve<Ch>(1 + len * 2); // worst case all characters are escaped as two characters\n        *documentStack_.template PushUnsafe<Ch>() = '/';\n        for (SizeType i = 0; i < len; i++) {\n            if (str[i] == '~') {\n                *documentStack_.template PushUnsafe<Ch>() = '~';\n                *documentStack_.template PushUnsafe<Ch>() = '0';\n            }\n            else if (str[i] == '/') {\n                *documentStack_.template PushUnsafe<Ch>() = '~';\n                *documentStack_.template PushUnsafe<Ch>() = '1';\n            }\n            else\n                *documentStack_.template PushUnsafe<Ch>() = str[i];\n        }\n    }\n\n    RAPIDJSON_FORCEINLINE void PushSchema(const SchemaType& schema) { new (schemaStack_.template Push<Context>()) Context(*this, &schema); }\n    \n    RAPIDJSON_FORCEINLINE void PopSchema() {\n        Context* c = schemaStack_.template Pop<Context>(1);\n        if (HashCodeArray* a = static_cast<HashCodeArray*>(c->arrayElementHashCodes)) {\n            a->~HashCodeArray();\n            StateAllocator::Free(a);\n        }\n        c->~Context();\n    }\n\n    const SchemaType& CurrentSchema() const { return *schemaStack_.template Top<Context>()->schema; }\n    Context& CurrentContext() { return *schemaStack_.template Top<Context>(); }\n    const Context& CurrentContext() const { return *schemaStack_.template Top<Context>(); }\n\n    static OutputHandler& GetNullHandler() {\n        static OutputHandler nullHandler;\n        return nullHandler;\n    }\n\n    static const size_t kDefaultSchemaStackCapacity = 1024;\n    static const size_t kDefaultDocumentStackCapacity = 256;\n    const SchemaDocumentType* schemaDocument_;\n    const SchemaType& root_;\n    OutputHandler& outputHandler_;\n    StateAllocator* stateAllocator_;\n    StateAllocator* ownStateAllocator_;\n    internal::Stack<StateAllocator> schemaStack_;    //!< stack to store the current path of schema (BaseSchemaType *)\n    internal::Stack<StateAllocator> documentStack_;  //!< stack to store the current path of validating document (Ch)\n    bool valid_;\n#if RAPIDJSON_SCHEMA_VERBOSE\n    unsigned depth_;\n#endif\n};\n\ntypedef GenericSchemaValidator<SchemaDocument> SchemaValidator;\n\n///////////////////////////////////////////////////////////////////////////////\n// SchemaValidatingReader\n\n//! A helper class for parsing with validation.\n/*!\n    This helper class is a functor, designed as a parameter of \\ref GenericDocument::Populate().\n\n    \\tparam parseFlags Combination of \\ref ParseFlag.\n    \\tparam InputStream Type of input stream, implementing Stream concept.\n    \\tparam SourceEncoding Encoding of the input stream.\n    \\tparam SchemaDocumentType Type of schema document.\n    \\tparam StackAllocator Allocator type for stack.\n*/\ntemplate <\n    unsigned parseFlags,\n    typename InputStream,\n    typename SourceEncoding,\n    typename SchemaDocumentType = SchemaDocument,\n    typename StackAllocator = CrtAllocator>\nclass SchemaValidatingReader {\npublic:\n    typedef typename SchemaDocumentType::PointerType PointerType;\n    typedef typename InputStream::Ch Ch;\n\n    //! Constructor\n    /*!\n        \\param is Input stream.\n        \\param sd Schema document.\n    */\n    SchemaValidatingReader(InputStream& is, const SchemaDocumentType& sd) : is_(is), sd_(sd), invalidSchemaKeyword_(), isValid_(true) {}\n\n    template <typename Handler>\n    bool operator()(Handler& handler) {\n        GenericReader<SourceEncoding, typename SchemaDocumentType::EncodingType, StackAllocator> reader;\n        GenericSchemaValidator<SchemaDocumentType, Handler> validator(sd_, handler);\n        parseResult_ = reader.template Parse<parseFlags>(is_, validator);\n\n        isValid_ = validator.IsValid();\n        if (isValid_) {\n            invalidSchemaPointer_ = PointerType();\n            invalidSchemaKeyword_ = 0;\n            invalidDocumentPointer_ = PointerType();\n        }\n        else {\n            invalidSchemaPointer_ = validator.GetInvalidSchemaPointer();\n            invalidSchemaKeyword_ = validator.GetInvalidSchemaKeyword();\n            invalidDocumentPointer_ = validator.GetInvalidDocumentPointer();\n        }\n\n        return parseResult_;\n    }\n\n    const ParseResult& GetParseResult() const { return parseResult_; }\n    bool IsValid() const { return isValid_; }\n    const PointerType& GetInvalidSchemaPointer() const { return invalidSchemaPointer_; }\n    const Ch* GetInvalidSchemaKeyword() const { return invalidSchemaKeyword_; }\n    const PointerType& GetInvalidDocumentPointer() const { return invalidDocumentPointer_; }\n\nprivate:\n    InputStream& is_;\n    const SchemaDocumentType& sd_;\n\n    ParseResult parseResult_;\n    PointerType invalidSchemaPointer_;\n    const Ch* invalidSchemaKeyword_;\n    PointerType invalidDocumentPointer_;\n    bool isValid_;\n};\n\nRAPIDJSON_NAMESPACE_END\nRAPIDJSON_DIAG_POP\n\n#endif // RAPIDJSON_SCHEMA_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/stream.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"rapidjson.h\"\n\n#ifndef RAPIDJSON_STREAM_H_\n#define RAPIDJSON_STREAM_H_\n\n#include \"encodings.h\"\n\nRAPIDJSON_NAMESPACE_BEGIN\n\n///////////////////////////////////////////////////////////////////////////////\n//  Stream\n\n/*! \\class rapidjson::Stream\n    \\brief Concept for reading and writing characters.\n\n    For read-only stream, no need to implement PutBegin(), Put(), Flush() and PutEnd().\n\n    For write-only stream, only need to implement Put() and Flush().\n\n\\code\nconcept Stream {\n    typename Ch;    //!< Character type of the stream.\n\n    //! Read the current character from stream without moving the read cursor.\n    Ch Peek() const;\n\n    //! Read the current character from stream and moving the read cursor to next character.\n    Ch Take();\n\n    //! Get the current read cursor.\n    //! \\return Number of characters read from start.\n    size_t Tell();\n\n    //! Begin writing operation at the current read pointer.\n    //! \\return The begin writer pointer.\n    Ch* PutBegin();\n\n    //! Write a character.\n    void Put(Ch c);\n\n    //! Flush the buffer.\n    void Flush();\n\n    //! End the writing operation.\n    //! \\param begin The begin write pointer returned by PutBegin().\n    //! \\return Number of characters written.\n    size_t PutEnd(Ch* begin);\n}\n\\endcode\n*/\n\n//! Provides additional information for stream.\n/*!\n    By using traits pattern, this type provides a default configuration for stream.\n    For custom stream, this type can be specialized for other configuration.\n    See TEST(Reader, CustomStringStream) in readertest.cpp for example.\n*/\ntemplate<typename Stream>\nstruct StreamTraits {\n    //! Whether to make local copy of stream for optimization during parsing.\n    /*!\n        By default, for safety, streams do not use local copy optimization.\n        Stream that can be copied fast should specialize this, like StreamTraits<StringStream>.\n    */\n    enum { copyOptimization = 0 };\n};\n\n//! Reserve n characters for writing to a stream.\ntemplate<typename Stream>\ninline void PutReserve(Stream& stream, size_t count) {\n    (void)stream;\n    (void)count;\n}\n\n//! Write character to a stream, presuming buffer is reserved.\ntemplate<typename Stream>\ninline void PutUnsafe(Stream& stream, typename Stream::Ch c) {\n    stream.Put(c);\n}\n\n//! Put N copies of a character to a stream.\ntemplate<typename Stream, typename Ch>\ninline void PutN(Stream& stream, Ch c, size_t n) {\n    PutReserve(stream, n);\n    for (size_t i = 0; i < n; i++)\n        PutUnsafe(stream, c);\n}\n\n///////////////////////////////////////////////////////////////////////////////\n// StringStream\n\n//! Read-only string stream.\n/*! \\note implements Stream concept\n*/\ntemplate <typename Encoding>\nstruct GenericStringStream {\n    typedef typename Encoding::Ch Ch;\n\n    GenericStringStream(const Ch *src) : src_(src), head_(src) {}\n\n    Ch Peek() const { return *src_; }\n    Ch Take() { return *src_++; }\n    size_t Tell() const { return static_cast<size_t>(src_ - head_); }\n\n    Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }\n    void Put(Ch) { RAPIDJSON_ASSERT(false); }\n    void Flush() { RAPIDJSON_ASSERT(false); }\n    size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }\n\n    const Ch* src_;     //!< Current read position.\n    const Ch* head_;    //!< Original head of the string.\n};\n\ntemplate <typename Encoding>\nstruct StreamTraits<GenericStringStream<Encoding> > {\n    enum { copyOptimization = 1 };\n};\n\n//! String stream with UTF8 encoding.\ntypedef GenericStringStream<UTF8<> > StringStream;\n\n///////////////////////////////////////////////////////////////////////////////\n// InsituStringStream\n\n//! A read-write string stream.\n/*! This string stream is particularly designed for in-situ parsing.\n    \\note implements Stream concept\n*/\ntemplate <typename Encoding>\nstruct GenericInsituStringStream {\n    typedef typename Encoding::Ch Ch;\n\n    GenericInsituStringStream(Ch *src) : src_(src), dst_(0), head_(src) {}\n\n    // Read\n    Ch Peek() { return *src_; }\n    Ch Take() { return *src_++; }\n    size_t Tell() { return static_cast<size_t>(src_ - head_); }\n\n    // Write\n    void Put(Ch c) { RAPIDJSON_ASSERT(dst_ != 0); *dst_++ = c; }\n\n    Ch* PutBegin() { return dst_ = src_; }\n    size_t PutEnd(Ch* begin) { return static_cast<size_t>(dst_ - begin); }\n    void Flush() {}\n\n    Ch* Push(size_t count) { Ch* begin = dst_; dst_ += count; return begin; }\n    void Pop(size_t count) { dst_ -= count; }\n\n    Ch* src_;\n    Ch* dst_;\n    Ch* head_;\n};\n\ntemplate <typename Encoding>\nstruct StreamTraits<GenericInsituStringStream<Encoding> > {\n    enum { copyOptimization = 1 };\n};\n\n//! Insitu string stream with UTF8 encoding.\ntypedef GenericInsituStringStream<UTF8<> > InsituStringStream;\n\nRAPIDJSON_NAMESPACE_END\n\n#endif // RAPIDJSON_STREAM_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/stringbuffer.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_STRINGBUFFER_H_\n#define RAPIDJSON_STRINGBUFFER_H_\n\n#include \"stream.h\"\n#include \"internal/stack.h\"\n\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\n#include <utility> // std::move\n#endif\n\n#include \"internal/stack.h\"\n\n#if defined(__clang__)\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(c++98-compat)\n#endif\n\nRAPIDJSON_NAMESPACE_BEGIN\n\n//! Represents an in-memory output stream.\n/*!\n    \\tparam Encoding Encoding of the stream.\n    \\tparam Allocator type for allocating memory buffer.\n    \\note implements Stream concept\n*/\ntemplate <typename Encoding, typename Allocator = CrtAllocator>\nclass GenericStringBuffer {\npublic:\n    typedef typename Encoding::Ch Ch;\n\n    GenericStringBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {}\n\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\n    GenericStringBuffer(GenericStringBuffer&& rhs) : stack_(std::move(rhs.stack_)) {}\n    GenericStringBuffer& operator=(GenericStringBuffer&& rhs) {\n        if (&rhs != this)\n            stack_ = std::move(rhs.stack_);\n        return *this;\n    }\n#endif\n\n    void Put(Ch c) { *stack_.template Push<Ch>() = c; }\n    void PutUnsafe(Ch c) { *stack_.template PushUnsafe<Ch>() = c; }\n    void Flush() {}\n\n    void Clear() { stack_.Clear(); }\n    void ShrinkToFit() {\n        // Push and pop a null terminator. This is safe.\n        *stack_.template Push<Ch>() = '\\0';\n        stack_.ShrinkToFit();\n        stack_.template Pop<Ch>(1);\n    }\n\n    void Reserve(size_t count) { stack_.template Reserve<Ch>(count); }\n    Ch* Push(size_t count) { return stack_.template Push<Ch>(count); }\n    Ch* PushUnsafe(size_t count) { return stack_.template PushUnsafe<Ch>(count); }\n    void Pop(size_t count) { stack_.template Pop<Ch>(count); }\n\n    const Ch* GetString() const {\n        // Push and pop a null terminator. This is safe.\n        *stack_.template Push<Ch>() = '\\0';\n        stack_.template Pop<Ch>(1);\n\n        return stack_.template Bottom<Ch>();\n    }\n\n    size_t GetSize() const { return stack_.GetSize(); }\n\n    static const size_t kDefaultCapacity = 256;\n    mutable internal::Stack<Allocator> stack_;\n\nprivate:\n    // Prohibit copy constructor & assignment operator.\n    GenericStringBuffer(const GenericStringBuffer&);\n    GenericStringBuffer& operator=(const GenericStringBuffer&);\n};\n\n//! String buffer with UTF8 encoding\ntypedef GenericStringBuffer<UTF8<> > StringBuffer;\n\ntemplate<typename Encoding, typename Allocator>\ninline void PutReserve(GenericStringBuffer<Encoding, Allocator>& stream, size_t count) {\n    stream.Reserve(count);\n}\n\ntemplate<typename Encoding, typename Allocator>\ninline void PutUnsafe(GenericStringBuffer<Encoding, Allocator>& stream, typename Encoding::Ch c) {\n    stream.PutUnsafe(c);\n}\n\n//! Implement specialized version of PutN() with memset() for better performance.\ntemplate<>\ninline void PutN(GenericStringBuffer<UTF8<> >& stream, char c, size_t n) {\n    std::memset(stream.stack_.Push<char>(n), c, n * sizeof(c));\n}\n\nRAPIDJSON_NAMESPACE_END\n\n#if defined(__clang__)\nRAPIDJSON_DIAG_POP\n#endif\n\n#endif // RAPIDJSON_STRINGBUFFER_H_\n"
  },
  {
    "path": "ext/rapidjson/include/rapidjson/writer.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef RAPIDJSON_WRITER_H_\n#define RAPIDJSON_WRITER_H_\n\n#include \"stream.h\"\n#include \"internal/stack.h\"\n#include \"internal/strfunc.h\"\n#include \"internal/dtoa.h\"\n#include \"internal/itoa.h\"\n#include \"stringbuffer.h\"\n#include <new>      // placement new\n\n#if defined(RAPIDJSON_SIMD) && defined(_MSC_VER)\n#include <intrin.h>\n#pragma intrinsic(_BitScanForward)\n#endif\n#ifdef RAPIDJSON_SSE42\n#include <nmmintrin.h>\n#elif defined(RAPIDJSON_SSE2)\n#include <emmintrin.h>\n#endif\n\n#ifdef _MSC_VER\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(4127) // conditional expression is constant\n#endif\n\n#ifdef __clang__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(padded)\nRAPIDJSON_DIAG_OFF(unreachable-code)\n#endif\n\nRAPIDJSON_NAMESPACE_BEGIN\n\n///////////////////////////////////////////////////////////////////////////////\n// WriteFlag\n\n/*! \\def RAPIDJSON_WRITE_DEFAULT_FLAGS \n    \\ingroup RAPIDJSON_CONFIG\n    \\brief User-defined kWriteDefaultFlags definition.\n\n    User can define this as any \\c WriteFlag combinations.\n*/\n#ifndef RAPIDJSON_WRITE_DEFAULT_FLAGS\n#define RAPIDJSON_WRITE_DEFAULT_FLAGS kWriteNoFlags\n#endif\n\n//! Combination of writeFlags\nenum WriteFlag {\n    kWriteNoFlags = 0,              //!< No flags are set.\n    kWriteValidateEncodingFlag = 1, //!< Validate encoding of JSON strings.\n    kWriteNanAndInfFlag = 2,        //!< Allow writing of Infinity, -Infinity and NaN.\n    kWriteDefaultFlags = RAPIDJSON_WRITE_DEFAULT_FLAGS  //!< Default write flags. Can be customized by defining RAPIDJSON_WRITE_DEFAULT_FLAGS\n};\n\n//! JSON writer\n/*! Writer implements the concept Handler.\n    It generates JSON text by events to an output os.\n\n    User may programmatically calls the functions of a writer to generate JSON text.\n\n    On the other side, a writer can also be passed to objects that generates events, \n\n    for example Reader::Parse() and Document::Accept().\n\n    \\tparam OutputStream Type of output stream.\n    \\tparam SourceEncoding Encoding of source string.\n    \\tparam TargetEncoding Encoding of output stream.\n    \\tparam StackAllocator Type of allocator for allocating memory of stack.\n    \\note implements Handler concept\n*/\ntemplate<typename OutputStream, typename SourceEncoding = UTF8<>, typename TargetEncoding = UTF8<>, typename StackAllocator = CrtAllocator, unsigned writeFlags = kWriteDefaultFlags>\nclass Writer {\npublic:\n    typedef typename SourceEncoding::Ch Ch;\n\n    static const int kDefaultMaxDecimalPlaces = 324;\n\n    //! Constructor\n    /*! \\param os Output stream.\n        \\param stackAllocator User supplied allocator. If it is null, it will create a private one.\n        \\param levelDepth Initial capacity of stack.\n    */\n    explicit\n    Writer(OutputStream& os, StackAllocator* stackAllocator = 0, size_t levelDepth = kDefaultLevelDepth) : \n        os_(&os), level_stack_(stackAllocator, levelDepth * sizeof(Level)), maxDecimalPlaces_(kDefaultMaxDecimalPlaces), hasRoot_(false) {}\n\n    explicit\n    Writer(StackAllocator* allocator = 0, size_t levelDepth = kDefaultLevelDepth) :\n        os_(0), level_stack_(allocator, levelDepth * sizeof(Level)), maxDecimalPlaces_(kDefaultMaxDecimalPlaces), hasRoot_(false) {}\n\n    //! Reset the writer with a new stream.\n    /*!\n        This function reset the writer with a new stream and default settings,\n        in order to make a Writer object reusable for output multiple JSONs.\n\n        \\param os New output stream.\n        \\code\n        Writer<OutputStream> writer(os1);\n        writer.StartObject();\n        // ...\n        writer.EndObject();\n\n        writer.Reset(os2);\n        writer.StartObject();\n        // ...\n        writer.EndObject();\n        \\endcode\n    */\n    void Reset(OutputStream& os) {\n        os_ = &os;\n        hasRoot_ = false;\n        level_stack_.Clear();\n    }\n\n    //! Checks whether the output is a complete JSON.\n    /*!\n        A complete JSON has a complete root object or array.\n    */\n    bool IsComplete() const {\n        return hasRoot_ && level_stack_.Empty();\n    }\n\n    int GetMaxDecimalPlaces() const {\n        return maxDecimalPlaces_;\n    }\n\n    //! Sets the maximum number of decimal places for double output.\n    /*!\n        This setting truncates the output with specified number of decimal places.\n\n        For example, \n\n        \\code\n        writer.SetMaxDecimalPlaces(3);\n        writer.StartArray();\n        writer.Double(0.12345);                 // \"0.123\"\n        writer.Double(0.0001);                  // \"0.0\"\n        writer.Double(1.234567890123456e30);    // \"1.234567890123456e30\" (do not truncate significand for positive exponent)\n        writer.Double(1.23e-4);                 // \"0.0\"                  (do truncate significand for negative exponent)\n        writer.EndArray();\n        \\endcode\n\n        The default setting does not truncate any decimal places. You can restore to this setting by calling\n        \\code\n        writer.SetMaxDecimalPlaces(Writer::kDefaultMaxDecimalPlaces);\n        \\endcode\n    */\n    void SetMaxDecimalPlaces(int maxDecimalPlaces) {\n        maxDecimalPlaces_ = maxDecimalPlaces;\n    }\n\n    /*!@name Implementation of Handler\n        \\see Handler\n    */\n    //@{\n\n    bool Null()                 { Prefix(kNullType);   return EndValue(WriteNull()); }\n    bool Bool(bool b)           { Prefix(b ? kTrueType : kFalseType); return EndValue(WriteBool(b)); }\n    bool Int(int i)             { Prefix(kNumberType); return EndValue(WriteInt(i)); }\n    bool Uint(unsigned u)       { Prefix(kNumberType); return EndValue(WriteUint(u)); }\n    bool Int64(int64_t i64)     { Prefix(kNumberType); return EndValue(WriteInt64(i64)); }\n    bool Uint64(uint64_t u64)   { Prefix(kNumberType); return EndValue(WriteUint64(u64)); }\n\n    //! Writes the given \\c double value to the stream\n    /*!\n        \\param d The value to be written.\n        \\return Whether it is succeed.\n    */\n    bool Double(double d)       { Prefix(kNumberType); return EndValue(WriteDouble(d)); }\n\n    bool RawNumber(const Ch* str, SizeType length, bool copy = false) {\n        (void)copy;\n        Prefix(kNumberType);\n        return EndValue(WriteString(str, length));\n    }\n\n    bool String(const Ch* str, SizeType length, bool copy = false) {\n        (void)copy;\n        Prefix(kStringType);\n        return EndValue(WriteString(str, length));\n    }\n\n#if RAPIDJSON_HAS_STDSTRING\n    bool String(const std::basic_string<Ch>& str) {\n        return String(str.data(), SizeType(str.size()));\n    }\n#endif\n\n    bool StartObject() {\n        Prefix(kObjectType);\n        new (level_stack_.template Push<Level>()) Level(false);\n        return WriteStartObject();\n    }\n\n    bool Key(const Ch* str, SizeType length, bool copy = false) { return String(str, length, copy); }\n\n    bool EndObject(SizeType memberCount = 0) {\n        (void)memberCount;\n        RAPIDJSON_ASSERT(level_stack_.GetSize() >= sizeof(Level));\n        RAPIDJSON_ASSERT(!level_stack_.template Top<Level>()->inArray);\n        level_stack_.template Pop<Level>(1);\n        return EndValue(WriteEndObject());\n    }\n\n    bool StartArray() {\n        Prefix(kArrayType);\n        new (level_stack_.template Push<Level>()) Level(true);\n        return WriteStartArray();\n    }\n\n    bool EndArray(SizeType elementCount = 0) {\n        (void)elementCount;\n        RAPIDJSON_ASSERT(level_stack_.GetSize() >= sizeof(Level));\n        RAPIDJSON_ASSERT(level_stack_.template Top<Level>()->inArray);\n        level_stack_.template Pop<Level>(1);\n        return EndValue(WriteEndArray());\n    }\n    //@}\n\n    /*! @name Convenience extensions */\n    //@{\n\n    //! Simpler but slower overload.\n    bool String(const Ch* str) { return String(str, internal::StrLen(str)); }\n    bool Key(const Ch* str) { return Key(str, internal::StrLen(str)); }\n\n    //@}\n\n    //! Write a raw JSON value.\n    /*!\n        For user to write a stringified JSON as a value.\n\n        \\param json A well-formed JSON value. It should not contain null character within [0, length - 1] range.\n        \\param length Length of the json.\n        \\param type Type of the root of json.\n    */\n    bool RawValue(const Ch* json, size_t length, Type type) { Prefix(type); return EndValue(WriteRawValue(json, length)); }\n\nprotected:\n    //! Information for each nested level\n    struct Level {\n        Level(bool inArray_) : valueCount(0), inArray(inArray_) {}\n        size_t valueCount;  //!< number of values in this level\n        bool inArray;       //!< true if in array, otherwise in object\n    };\n\n    static const size_t kDefaultLevelDepth = 32;\n\n    bool WriteNull()  {\n        PutReserve(*os_, 4);\n        PutUnsafe(*os_, 'n'); PutUnsafe(*os_, 'u'); PutUnsafe(*os_, 'l'); PutUnsafe(*os_, 'l'); return true;\n    }\n\n    bool WriteBool(bool b)  {\n        if (b) {\n            PutReserve(*os_, 4);\n            PutUnsafe(*os_, 't'); PutUnsafe(*os_, 'r'); PutUnsafe(*os_, 'u'); PutUnsafe(*os_, 'e');\n        }\n        else {\n            PutReserve(*os_, 5);\n            PutUnsafe(*os_, 'f'); PutUnsafe(*os_, 'a'); PutUnsafe(*os_, 'l'); PutUnsafe(*os_, 's'); PutUnsafe(*os_, 'e');\n        }\n        return true;\n    }\n\n    bool WriteInt(int i) {\n        char buffer[11];\n        const char* end = internal::i32toa(i, buffer);\n        PutReserve(*os_, static_cast<size_t>(end - buffer));\n        for (const char* p = buffer; p != end; ++p)\n            PutUnsafe(*os_, static_cast<typename TargetEncoding::Ch>(*p));\n        return true;\n    }\n\n    bool WriteUint(unsigned u) {\n        char buffer[10];\n        const char* end = internal::u32toa(u, buffer);\n        PutReserve(*os_, static_cast<size_t>(end - buffer));\n        for (const char* p = buffer; p != end; ++p)\n            PutUnsafe(*os_, static_cast<typename TargetEncoding::Ch>(*p));\n        return true;\n    }\n\n    bool WriteInt64(int64_t i64) {\n        char buffer[21];\n        const char* end = internal::i64toa(i64, buffer);\n        PutReserve(*os_, static_cast<size_t>(end - buffer));\n        for (const char* p = buffer; p != end; ++p)\n            PutUnsafe(*os_, static_cast<typename TargetEncoding::Ch>(*p));\n        return true;\n    }\n\n    bool WriteUint64(uint64_t u64) {\n        char buffer[20];\n        char* end = internal::u64toa(u64, buffer);\n        PutReserve(*os_, static_cast<size_t>(end - buffer));\n        for (char* p = buffer; p != end; ++p)\n            PutUnsafe(*os_, static_cast<typename TargetEncoding::Ch>(*p));\n        return true;\n    }\n\n    bool WriteDouble(double d) {\n        if (internal::Double(d).IsNanOrInf()) {\n            if (!(writeFlags & kWriteNanAndInfFlag))\n                return false;\n            if (internal::Double(d).IsNan()) {\n                PutReserve(*os_, 3);\n                PutUnsafe(*os_, 'N'); PutUnsafe(*os_, 'a'); PutUnsafe(*os_, 'N');\n                return true;\n            }\n            if (internal::Double(d).Sign()) {\n                PutReserve(*os_, 9);\n                PutUnsafe(*os_, '-');\n            }\n            else\n                PutReserve(*os_, 8);\n            PutUnsafe(*os_, 'I'); PutUnsafe(*os_, 'n'); PutUnsafe(*os_, 'f');\n            PutUnsafe(*os_, 'i'); PutUnsafe(*os_, 'n'); PutUnsafe(*os_, 'i'); PutUnsafe(*os_, 't'); PutUnsafe(*os_, 'y');\n            return true;\n        }\n\n        char buffer[25];\n        char* end = internal::dtoa(d, buffer, maxDecimalPlaces_);\n        PutReserve(*os_, static_cast<size_t>(end - buffer));\n        for (char* p = buffer; p != end; ++p)\n            PutUnsafe(*os_, static_cast<typename TargetEncoding::Ch>(*p));\n        return true;\n    }\n\n    bool WriteString(const Ch* str, SizeType length)  {\n        static const typename TargetEncoding::Ch hexDigits[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };\n        static const char escape[256] = {\n#define Z16 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\n            //0    1    2    3    4    5    6    7    8    9    A    B    C    D    E    F\n            'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'b', 't', 'n', 'u', 'f', 'r', 'u', 'u', // 00\n            'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', // 10\n              0,   0, '\"',   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, // 20\n            Z16, Z16,                                                                       // 30~4F\n              0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,'\\\\',   0,   0,   0, // 50\n            Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16, Z16                                // 60~FF\n#undef Z16\n        };\n\n        if (TargetEncoding::supportUnicode)\n            PutReserve(*os_, 2 + length * 6); // \"\\uxxxx...\"\n        else\n            PutReserve(*os_, 2 + length * 12);  // \"\\uxxxx\\uyyyy...\"\n\n        PutUnsafe(*os_, '\\\"');\n        GenericStringStream<SourceEncoding> is(str);\n        while (ScanWriteUnescapedString(is, length)) {\n            const Ch c = is.Peek();\n            if (!TargetEncoding::supportUnicode && static_cast<unsigned>(c) >= 0x80) {\n                // Unicode escaping\n                unsigned codepoint;\n                if (RAPIDJSON_UNLIKELY(!SourceEncoding::Decode(is, &codepoint)))\n                    return false;\n                PutUnsafe(*os_, '\\\\');\n                PutUnsafe(*os_, 'u');\n                if (codepoint <= 0xD7FF || (codepoint >= 0xE000 && codepoint <= 0xFFFF)) {\n                    PutUnsafe(*os_, hexDigits[(codepoint >> 12) & 15]);\n                    PutUnsafe(*os_, hexDigits[(codepoint >>  8) & 15]);\n                    PutUnsafe(*os_, hexDigits[(codepoint >>  4) & 15]);\n                    PutUnsafe(*os_, hexDigits[(codepoint      ) & 15]);\n                }\n                else {\n                    RAPIDJSON_ASSERT(codepoint >= 0x010000 && codepoint <= 0x10FFFF);\n                    // Surrogate pair\n                    unsigned s = codepoint - 0x010000;\n                    unsigned lead = (s >> 10) + 0xD800;\n                    unsigned trail = (s & 0x3FF) + 0xDC00;\n                    PutUnsafe(*os_, hexDigits[(lead >> 12) & 15]);\n                    PutUnsafe(*os_, hexDigits[(lead >>  8) & 15]);\n                    PutUnsafe(*os_, hexDigits[(lead >>  4) & 15]);\n                    PutUnsafe(*os_, hexDigits[(lead      ) & 15]);\n                    PutUnsafe(*os_, '\\\\');\n                    PutUnsafe(*os_, 'u');\n                    PutUnsafe(*os_, hexDigits[(trail >> 12) & 15]);\n                    PutUnsafe(*os_, hexDigits[(trail >>  8) & 15]);\n                    PutUnsafe(*os_, hexDigits[(trail >>  4) & 15]);\n                    PutUnsafe(*os_, hexDigits[(trail      ) & 15]);                    \n                }\n            }\n            else if ((sizeof(Ch) == 1 || static_cast<unsigned>(c) < 256) && RAPIDJSON_UNLIKELY(escape[static_cast<unsigned char>(c)]))  {\n                is.Take();\n                PutUnsafe(*os_, '\\\\');\n                PutUnsafe(*os_, static_cast<typename TargetEncoding::Ch>(escape[static_cast<unsigned char>(c)]));\n                if (escape[static_cast<unsigned char>(c)] == 'u') {\n                    PutUnsafe(*os_, '0');\n                    PutUnsafe(*os_, '0');\n                    PutUnsafe(*os_, hexDigits[static_cast<unsigned char>(c) >> 4]);\n                    PutUnsafe(*os_, hexDigits[static_cast<unsigned char>(c) & 0xF]);\n                }\n            }\n            else if (RAPIDJSON_UNLIKELY(!(writeFlags & kWriteValidateEncodingFlag ? \n                Transcoder<SourceEncoding, TargetEncoding>::Validate(is, *os_) :\n                Transcoder<SourceEncoding, TargetEncoding>::TranscodeUnsafe(is, *os_))))\n                return false;\n        }\n        PutUnsafe(*os_, '\\\"');\n        return true;\n    }\n\n    bool ScanWriteUnescapedString(GenericStringStream<SourceEncoding>& is, size_t length) {\n        return RAPIDJSON_LIKELY(is.Tell() < length);\n    }\n\n    bool WriteStartObject() { os_->Put('{'); return true; }\n    bool WriteEndObject()   { os_->Put('}'); return true; }\n    bool WriteStartArray()  { os_->Put('['); return true; }\n    bool WriteEndArray()    { os_->Put(']'); return true; }\n\n    bool WriteRawValue(const Ch* json, size_t length) {\n        PutReserve(*os_, length);\n        for (size_t i = 0; i < length; i++) {\n            RAPIDJSON_ASSERT(json[i] != '\\0');\n            PutUnsafe(*os_, json[i]);\n        }\n        return true;\n    }\n\n    void Prefix(Type type) {\n        (void)type;\n        if (RAPIDJSON_LIKELY(level_stack_.GetSize() != 0)) { // this value is not at root\n            Level* level = level_stack_.template Top<Level>();\n            if (level->valueCount > 0) {\n                if (level->inArray) \n                    os_->Put(','); // add comma if it is not the first element in array\n                else  // in object\n                    os_->Put((level->valueCount % 2 == 0) ? ',' : ':');\n            }\n            if (!level->inArray && level->valueCount % 2 == 0)\n                RAPIDJSON_ASSERT(type == kStringType);  // if it's in object, then even number should be a name\n            level->valueCount++;\n        }\n        else {\n            RAPIDJSON_ASSERT(!hasRoot_);    // Should only has one and only one root.\n            hasRoot_ = true;\n        }\n    }\n\n    // Flush the value if it is the top level one.\n    bool EndValue(bool ret) {\n        if (RAPIDJSON_UNLIKELY(level_stack_.Empty()))   // end of json text\n            os_->Flush();\n        return ret;\n    }\n\n    OutputStream* os_;\n    internal::Stack<StackAllocator> level_stack_;\n    int maxDecimalPlaces_;\n    bool hasRoot_;\n\nprivate:\n    // Prohibit copy constructor & assignment operator.\n    Writer(const Writer&);\n    Writer& operator=(const Writer&);\n};\n\n// Full specialization for StringStream to prevent memory copying\n\ntemplate<>\ninline bool Writer<StringBuffer>::WriteInt(int i) {\n    char *buffer = os_->Push(11);\n    const char* end = internal::i32toa(i, buffer);\n    os_->Pop(static_cast<size_t>(11 - (end - buffer)));\n    return true;\n}\n\ntemplate<>\ninline bool Writer<StringBuffer>::WriteUint(unsigned u) {\n    char *buffer = os_->Push(10);\n    const char* end = internal::u32toa(u, buffer);\n    os_->Pop(static_cast<size_t>(10 - (end - buffer)));\n    return true;\n}\n\ntemplate<>\ninline bool Writer<StringBuffer>::WriteInt64(int64_t i64) {\n    char *buffer = os_->Push(21);\n    const char* end = internal::i64toa(i64, buffer);\n    os_->Pop(static_cast<size_t>(21 - (end - buffer)));\n    return true;\n}\n\ntemplate<>\ninline bool Writer<StringBuffer>::WriteUint64(uint64_t u) {\n    char *buffer = os_->Push(20);\n    const char* end = internal::u64toa(u, buffer);\n    os_->Pop(static_cast<size_t>(20 - (end - buffer)));\n    return true;\n}\n\ntemplate<>\ninline bool Writer<StringBuffer>::WriteDouble(double d) {\n    if (internal::Double(d).IsNanOrInf()) {\n        // Note: This code path can only be reached if (RAPIDJSON_WRITE_DEFAULT_FLAGS & kWriteNanAndInfFlag).\n        if (!(kWriteDefaultFlags & kWriteNanAndInfFlag))\n            return false;\n        if (internal::Double(d).IsNan()) {\n            PutReserve(*os_, 3);\n            PutUnsafe(*os_, 'N'); PutUnsafe(*os_, 'a'); PutUnsafe(*os_, 'N');\n            return true;\n        }\n        if (internal::Double(d).Sign()) {\n            PutReserve(*os_, 9);\n            PutUnsafe(*os_, '-');\n        }\n        else\n            PutReserve(*os_, 8);\n        PutUnsafe(*os_, 'I'); PutUnsafe(*os_, 'n'); PutUnsafe(*os_, 'f');\n        PutUnsafe(*os_, 'i'); PutUnsafe(*os_, 'n'); PutUnsafe(*os_, 'i'); PutUnsafe(*os_, 't'); PutUnsafe(*os_, 'y');\n        return true;\n    }\n    \n    char *buffer = os_->Push(25);\n    char* end = internal::dtoa(d, buffer, maxDecimalPlaces_);\n    os_->Pop(static_cast<size_t>(25 - (end - buffer)));\n    return true;\n}\n\n#if defined(RAPIDJSON_SSE2) || defined(RAPIDJSON_SSE42)\ntemplate<>\ninline bool Writer<StringBuffer>::ScanWriteUnescapedString(StringStream& is, size_t length) {\n    if (length < 16)\n        return RAPIDJSON_LIKELY(is.Tell() < length);\n\n    if (!RAPIDJSON_LIKELY(is.Tell() < length))\n        return false;\n\n    const char* p = is.src_;\n    const char* end = is.head_ + length;\n    const char* nextAligned = reinterpret_cast<const char*>((reinterpret_cast<size_t>(p) + 15) & static_cast<size_t>(~15));\n    const char* endAligned = reinterpret_cast<const char*>(reinterpret_cast<size_t>(end) & static_cast<size_t>(~15));\n    if (nextAligned > end)\n        return true;\n\n    while (p != nextAligned)\n        if (*p < 0x20 || *p == '\\\"' || *p == '\\\\') {\n            is.src_ = p;\n            return RAPIDJSON_LIKELY(is.Tell() < length);\n        }\n        else\n            os_->PutUnsafe(*p++);\n\n    // The rest of string using SIMD\n    static const char dquote[16] = { '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"', '\\\"' };\n    static const char bslash[16] = { '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\', '\\\\' };\n    static const char space[16]  = { 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19 };\n    const __m128i dq = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&dquote[0]));\n    const __m128i bs = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&bslash[0]));\n    const __m128i sp = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&space[0]));\n\n    for (; p != endAligned; p += 16) {\n        const __m128i s = _mm_load_si128(reinterpret_cast<const __m128i *>(p));\n        const __m128i t1 = _mm_cmpeq_epi8(s, dq);\n        const __m128i t2 = _mm_cmpeq_epi8(s, bs);\n        const __m128i t3 = _mm_cmpeq_epi8(_mm_max_epu8(s, sp), sp); // s < 0x20 <=> max(s, 0x19) == 0x19\n        const __m128i x = _mm_or_si128(_mm_or_si128(t1, t2), t3);\n        unsigned short r = static_cast<unsigned short>(_mm_movemask_epi8(x));\n        if (RAPIDJSON_UNLIKELY(r != 0)) {   // some of characters is escaped\n            SizeType len;\n#ifdef _MSC_VER         // Find the index of first escaped\n            unsigned long offset;\n            _BitScanForward(&offset, r);\n            len = offset;\n#else\n            len = static_cast<SizeType>(__builtin_ffs(r) - 1);\n#endif\n            char* q = reinterpret_cast<char*>(os_->PushUnsafe(len));\n            for (size_t i = 0; i < len; i++)\n                q[i] = p[i];\n\n            p += len;\n            break;\n        }\n        _mm_storeu_si128(reinterpret_cast<__m128i *>(os_->PushUnsafe(16)), s);\n    }\n\n    is.src_ = p;\n    return RAPIDJSON_LIKELY(is.Tell() < length);\n}\n#endif // defined(RAPIDJSON_SSE2) || defined(RAPIDJSON_SSE42)\n\nRAPIDJSON_NAMESPACE_END\n\n#ifdef _MSC_VER\nRAPIDJSON_DIAG_POP\n#endif\n\n#ifdef __clang__\nRAPIDJSON_DIAG_POP\n#endif\n\n#endif // RAPIDJSON_RAPIDJSON_H_\n"
  },
  {
    "path": "ext/rapidjson/include_dirs.js",
    "content": "var path = require('path');\nconsole.log(path.join(path.relative('.', __dirname), 'include'));\n"
  },
  {
    "path": "ext/rapidjson/library.json",
    "content": "{\n  \"name\": \"RapidJSON\",\n  \"keywords\": \"json, sax, dom, parser, generator\",\n  \"description\": \"A fast JSON parser/generator for C++ with both SAX/DOM style API\",\n  \"include\": \"include\",\n  \"examples\": \"example/*/*.cpp\",\n  \"repository\":\n  {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/miloyip/rapidjson\"\n  }\n}\n"
  },
  {
    "path": "ext/rapidjson/license.txt",
    "content": "Tencent is pleased to support the open source community by making RapidJSON available. \n \nCopyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip.  All rights reserved.\n\nIf you have downloaded a copy of the RapidJSON binary from Tencent, please note that the RapidJSON binary is licensed under the MIT License.\nIf you have downloaded a copy of the RapidJSON source code from Tencent, please note that RapidJSON source code is licensed under the MIT License, except for the third-party components listed below which are subject to different license terms.  Your integration of RapidJSON into your own projects may require compliance with the MIT License, as well as the other licenses applicable to the third-party components included within RapidJSON. To avoid the problematic JSON license in your own projects, it's sufficient to exclude the bin/jsonchecker/ directory, as it's the only code under the JSON license.\nA copy of the MIT License is included in this file.\n\nOther dependencies and licenses:\n\nOpen Source Software Licensed Under the BSD License:\n--------------------------------------------------------------------\n\nThe msinttypes r29 \nCopyright (c) 2006-2013 Alexander Chemeris \nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. \n* 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.\n* Neither the name of  copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS AND 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.\n\nOpen Source Software Licensed Under the JSON License:\n--------------------------------------------------------------------\n\njson.org \nCopyright (c) 2002 JSON.org\nAll Rights Reserved.\n\nJSON_checker\nCopyright (c) 2002 JSON.org\nAll Rights Reserved.\n\n\t\nTerms of the JSON License:\n---------------------------------------------------\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nThe Software shall be used for Good, not Evil.\n\nTHE SOFTWARE IS 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\nTerms of the MIT License:\n--------------------------------------------------------------------\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS 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 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n"
  },
  {
    "path": "ext/rapidjson/license_readme-oracle.txt",
    "content": "Further information regarding RapidJSON files included with\nthis Oracle package:\n\nThe license file for rapidjson states the following:\n \"To avoid the problematic JSON license in your own projects,\n  it's sufficient to exclude the bin/jsonchecker/ directory,\n  as it's the only code under the JSON license.\"\n\nWe have removed the bin/jsonchecker/ directory, and we have\nthus no code under the JSON license included.\n"
  },
  {
    "path": "ext/rapidjson/package.json",
    "content": "{\n  \"name\": \"rapidjson\",\n  \"version\": \"1.0.4\",\n  \"description\": \"![](doc/logo/rapidjson.png)\",\n  \"main\": \"include_dirs.js\",\n  \"directories\": {\n    \"doc\": \"doc\",\n    \"example\": \"example\",\n    \"test\": \"test\"\n  },\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/miloyip/rapidjson.git\"\n  },\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"bugs\": {\n    \"url\": \"https://github.com/miloyip/rapidjson/issues\"\n  },\n  \"homepage\": \"https://github.com/miloyip/rapidjson#readme\"\n}\n"
  },
  {
    "path": "ext/rapidjson/rapidjson.autopkg",
    "content": "nuget {\n\t//Usage:  Write-NuGetPackage rapidjson.autopkg -defines:MYVERSION=1.1.0\n\t//Be sure you are running Powershell 3.0 and have the CoApp powershell extensions installed properly.\n\tnuspec {\n\t\tid = rapidjson;\n\t\tversion : ${MYVERSION};\n\t\ttitle: \"rapidjson\";\n\t\tauthors: {\"https://github.com/miloyip/rapidjson/releases/tag/v1.1.0\"};\n\t\towners: {\"@lsantos (github)\"};\n\t\tlicenseUrl: \"https://github.com/miloyip/rapidjson/blob/master/license.txt\";\n\t\tprojectUrl: \"https://github.com/miloyip/rapidjson/\";\n\t\ticonUrl: \"https://cdn1.iconfinder.com/data/icons/fatcow/32x32/json.png\";\n\t\trequireLicenseAcceptance:false;\n\t\tsummary: @\"A fast JSON parser/generator for C++ with both SAX/DOM style API\";\n\t\t\n\t\t// if you need to span several lines you can prefix a string with an @ symbol (exactly like c# does).\n\t\tdescription: @\"Rapidjson is an attempt to create the fastest JSON parser and generator.\n\n              - Small but complete. Supports both SAX and DOM style API. SAX parser only a few hundred lines of code.\n              - Fast. In the order of magnitude of strlen(). Optionally supports SSE2/SSE4.2 for acceleration.\n              - Self-contained. Minimal dependency on standard libraries. No BOOST, not even STL.\n              - Compact. Each JSON value is 16 or 20 bytes for 32 or 64-bit machines respectively (excluding text string storage). With the custom memory allocator, parser allocates memory compactly during parsing.\n              - Full  RFC4627 compliance. Supports UTF-8, UTF-16 and UTF-32.\n              - Support both in-situ parsing (directly decode strings into the source JSON text) and non-destructive parsing (decode strings into new buffers).\n              - Parse number to int/unsigned/int64_t/uint64_t/double depending on input\n              - Support custom memory allocation. Also, the default memory pool allocator can also be supplied with a user buffer (such as a buffer allocated on user's heap or - programme stack) to minimize allocation.\n\n              As the name implies, rapidjson is inspired by rapidxml.\";\n\t\t\n\t\treleaseNotes: @\"\nAdded\n\tAdd Value::XXXMember(...) overloads for std::string (#335)\n\nFixed\n\tInclude rapidjson.h for all internal/error headers.\n\tParsing some numbers incorrectly in full-precision mode (kFullPrecisionParseFlag) (#342)\n\tFix alignment of 64bit platforms (#328)\n\tFix MemoryPoolAllocator::Clear() to clear user-buffer (0691502)\n\nChanged\n\tCMakeLists for include as a thirdparty in projects (#334, #337)\n\tChange Document::ParseStream() to use stack allocator for Reader (ffbe386)\";\n\n\t\tcopyright: \"Copyright 2015\";\n\t\ttags: { native, coapp, JSON, nativepackage };\n\t\tlanguage: en-US;\n\t};\n\t\n\tdependencies {\n\t\tpackages : {\n\t\t\t//TODO:  Add dependecies here in [pkg.name]/[version] form per newline\t\t\n\t\t\t//zlib/[1.2.8],\t\t\t\n\t\t};\n\t}\n\t\n\t// the files that go into the content folders\n\tfiles {\t\n\t\t#defines {\n\t\t\tSDK_ROOT \t = .\\;\t\t\t\n\t\t}\n\n\t\t// grab all the files in the include folder\n\t\t// the folder that contains all the .h files will \n\t\t// automatically get added to the Includes path.\n\t\tnestedinclude += {\n\t\t\t#destination = ${d_include}rapidjson;\n\t\t\t\"${SDK_ROOT}include\\rapidjson\\**\\*.h\"\n\t\t};\n\t};\n\t\n\ttargets {\n\t\t// We're trying to be standard about these sorts of thing. (Will help with config.h later :D)\n\t\t//Defines += HAS_EQCORE;\n\t};\n}"
  },
  {
    "path": "ext/rapidjson/readme.md",
    "content": "![](doc/logo/rapidjson.png)\n\n![](https://img.shields.io/badge/release-v1.1.0-blue.png)\n\n## A fast JSON parser/generator for C++ with both SAX/DOM style API \n\nTencent is pleased to support the open source community by making RapidJSON available.\n\nCopyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n\n* [RapidJSON GitHub](https://github.com/miloyip/rapidjson/)\n* RapidJSON Documentation\n  * [English](http://rapidjson.org/)\n  * [简体中文](http://rapidjson.org/zh-cn/)\n  * [GitBook](https://www.gitbook.com/book/miloyip/rapidjson/) with downloadable PDF/EPUB/MOBI, without API reference.\n\n## Build status\n\n| [Linux][lin-link] | [Windows][win-link] | [Coveralls][cov-link] |\n| :---------------: | :-----------------: | :-------------------: |\n| ![lin-badge]      | ![win-badge]        | ![cov-badge]          |\n\n[lin-badge]: https://travis-ci.org/miloyip/rapidjson.png?branch=master \"Travis build status\"\n[lin-link]:  https://travis-ci.org/miloyip/rapidjson \"Travis build status\"\n[win-badge]: https://ci.appveyor.com/api/projects/status/u658dcuwxo14a8m9/branch/master \"AppVeyor build status\"\n[win-link]:  https://ci.appveyor.com/project/miloyip/rapidjson/branch/master \"AppVeyor build status\"\n[cov-badge]: https://coveralls.io/repos/miloyip/rapidjson/badge.png?branch=master\n[cov-link]:  https://coveralls.io/r/miloyip/rapidjson?branch=master\n\n## Introduction\n\nRapidJSON is a JSON parser and generator for C++. It was inspired by [RapidXml](http://rapidxml.sourceforge.net/).\n\n* RapidJSON is **small** but **complete**. It supports both SAX and DOM style API. The SAX parser is only a half thousand lines of code.\n\n* RapidJSON is **fast**. Its performance can be comparable to `strlen()`. It also optionally supports SSE2/SSE4.2 for acceleration.\n\n* RapidJSON is **self-contained** and **header-only**. It does not depend on external libraries such as BOOST. It even does not depend on STL.\n\n* RapidJSON is **memory-friendly**. Each JSON value occupies exactly 16 bytes for most 32/64-bit machines (excluding text string). By default it uses a fast memory allocator, and the parser allocates memory compactly during parsing.\n\n* RapidJSON is **Unicode-friendly**. It supports UTF-8, UTF-16, UTF-32 (LE & BE), and their detection, validation and transcoding internally. For example, you can read a UTF-8 file and let RapidJSON transcode the JSON strings into UTF-16 in the DOM. It also supports surrogates and \"\\u0000\" (null character).\n\nMore features can be read [here](doc/features.md).\n\nJSON(JavaScript Object Notation) is a light-weight data exchange format. RapidJSON should be in fully compliance with RFC7159/ECMA-404, with optional support of relaxed syntax. More information about JSON can be obtained at\n* [Introducing JSON](http://json.org/)\n* [RFC7159: The JavaScript Object Notation (JSON) Data Interchange Format](http://www.ietf.org/rfc/rfc7159.txt)\n* [Standard ECMA-404: The JSON Data Interchange Format](http://www.ecma-international.org/publications/standards/Ecma-404.htm)\n\n## Highlights in v1.1 (2016-8-25)\n\n* Added [JSON Pointer](doc/pointer.md)\n* Added [JSON Schema](doc/schema.md)\n* Added [relaxed JSON syntax](doc/dom.md) (comment, trailing comma, NaN/Infinity)\n* Iterating array/object with [C++11 Range-based for loop](doc/tutorial.md)\n* Reduce memory overhead of each `Value` from 24 bytes to 16 bytes in x86-64 architecture.\n\nFor other changes please refer to [change log](CHANGELOG.md).\n\n## Compatibility\n\nRapidJSON is cross-platform. Some platform/compiler combinations which have been tested are shown as follows.\n* Visual C++ 2008/2010/2013 on Windows (32/64-bit)\n* GNU C++ 3.8.x on Cygwin\n* Clang 3.4 on Mac OS X (32/64-bit) and iOS\n* Clang 3.4 on Android NDK\n\nUsers can build and run the unit tests on their platform/compiler.\n\n## Installation\n\nRapidJSON is a header-only C++ library. Just copy the `include/rapidjson` folder to system or project's include path.\n\nRapidJSON uses following software as its dependencies:\n* [CMake](https://cmake.org/) as a general build tool\n* (optional)[Doxygen](http://www.doxygen.org) to build documentation\n* (optional)[googletest](https://github.com/google/googletest) for unit and performance testing\n\nTo generate user documentation and run tests please proceed with the steps below:\n\n1. Execute `git submodule update --init` to get the files of thirdparty submodules (google test).\n2. Create directory called `build` in rapidjson source directory.\n3. Change to `build` directory and run `cmake ..` command to configure your build. Windows users can do the same with cmake-gui application.\n4. On Windows, build the solution found in the build directory. On Linux, run `make` from the build directory.\n\nOn successfull build you will find compiled test and example binaries in `bin`\ndirectory. The generated documentation will be available in `doc/html`\ndirectory of the build tree. To run tests after finished build please run `make\ntest` or `ctest` from your build tree. You can get detailed output using `ctest\n-V` command.\n\nIt is possible to install library system-wide by running `make install` command\nfrom the build tree with administrative privileges. This will install all files\naccording to system preferences.  Once RapidJSON is installed, it is possible\nto use it from other CMake projects by adding `find_package(RapidJSON)` line to\nyour CMakeLists.txt.\n\n## Usage at a glance\n\nThis simple example parses a JSON string into a document (DOM), make a simple modification of the DOM, and finally stringify the DOM to a JSON string.\n\n~~~~~~~~~~cpp\n// rapidjson/example/simpledom/simpledom.cpp`\n#include \"rapidjson/document.h\"\n#include \"rapidjson/writer.h\"\n#include \"rapidjson/stringbuffer.h\"\n#include <iostream>\n\nusing namespace rapidjson;\n\nint main() {\n    // 1. Parse a JSON string into DOM.\n    const char* json = \"{\\\"project\\\":\\\"rapidjson\\\",\\\"stars\\\":10}\";\n    Document d;\n    d.Parse(json);\n\n    // 2. Modify it by DOM.\n    Value& s = d[\"stars\"];\n    s.SetInt(s.GetInt() + 1);\n\n    // 3. Stringify the DOM\n    StringBuffer buffer;\n    Writer<StringBuffer> writer(buffer);\n    d.Accept(writer);\n\n    // Output {\"project\":\"rapidjson\",\"stars\":11}\n    std::cout << buffer.GetString() << std::endl;\n    return 0;\n}\n~~~~~~~~~~\n\nNote that this example did not handle potential errors.\n\nThe following diagram shows the process.\n\n![simpledom](doc/diagram/simpledom.png)\n\nMore [examples](https://github.com/miloyip/rapidjson/tree/master/example) are available:\n\n* DOM API\n * [tutorial](https://github.com/miloyip/rapidjson/blob/master/example/tutorial/tutorial.cpp): Basic usage of DOM API.\n\n* SAX API\n * [simplereader](https://github.com/miloyip/rapidjson/blob/master/example/simplereader/simplereader.cpp): Dumps all SAX events while parsing a JSON by `Reader`.\n * [condense](https://github.com/miloyip/rapidjson/blob/master/example/condense/condense.cpp): A command line tool to rewrite a JSON, with all whitespaces removed.\n * [pretty](https://github.com/miloyip/rapidjson/blob/master/example/pretty/pretty.cpp): A command line tool to rewrite a JSON with indents and newlines by `PrettyWriter`.\n * [capitalize](https://github.com/miloyip/rapidjson/blob/master/example/capitalize/capitalize.cpp): A command line tool to capitalize strings in JSON.\n * [messagereader](https://github.com/miloyip/rapidjson/blob/master/example/messagereader/messagereader.cpp): Parse a JSON message with SAX API.\n * [serialize](https://github.com/miloyip/rapidjson/blob/master/example/serialize/serialize.cpp): Serialize a C++ object into JSON with SAX API.\n * [jsonx](https://github.com/miloyip/rapidjson/blob/master/example/jsonx/jsonx.cpp): Implements a `JsonxWriter` which stringify SAX events into [JSONx](https://www-01.ibm.com/support/knowledgecenter/SS9H2Y_7.1.0/com.ibm.dp.doc/json_jsonx.html) (a kind of XML) format. The example is a command line tool which converts input JSON into JSONx format.\n\n* Schema\n * [schemavalidator](https://github.com/miloyip/rapidjson/blob/master/example/schemavalidator/schemavalidator.cpp) : A command line tool to validate a JSON with a JSON schema.\n \n* Advanced\n * [prettyauto](https://github.com/miloyip/rapidjson/blob/master/example/prettyauto/prettyauto.cpp): A modified version of [pretty](https://github.com/miloyip/rapidjson/blob/master/example/pretty/pretty.cpp) to automatically handle JSON with any UTF encodings.\n * [parsebyparts](https://github.com/miloyip/rapidjson/blob/master/example/parsebyparts/parsebyparts.cpp): Implements an `AsyncDocumentParser` which can parse JSON in parts, using C++11 thread.\n * [filterkey](https://github.com/miloyip/rapidjson/blob/master/example/filterkey/filterkey.cpp): A command line tool to remove all values with user-specified key.\n * [filterkeydom](https://github.com/miloyip/rapidjson/blob/master/example/filterkeydom/filterkeydom.cpp): Same tool as above, but it demonstrates how to use a generator to populate a `Document`.\n"
  },
  {
    "path": "ext/rapidjson/readme.zh-cn.md",
    "content": "![](doc/logo/rapidjson.png)\n\n![](https://img.shields.io/badge/release-v1.1.0-blue.png)\n\n## 高效的 C++ JSON 解析／生成器，提供 SAX 及 DOM 风格 API\n\nTencent is pleased to support the open source community by making RapidJSON available.\n\nCopyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n\n* [RapidJSON GitHub](https://github.com/miloyip/rapidjson/)\n* RapidJSON 文档\n  * [English](http://rapidjson.org/)\n  * [简体中文](http://rapidjson.org/zh-cn/)\n  * [GitBook](https://www.gitbook.com/book/miloyip/rapidjson/) 可下载 PDF/EPUB/MOBI，但不含 API 参考手册。\n\n## Build 状态\n\n| [Linux][lin-link] | [Windows][win-link] | [Coveralls][cov-link] |\n| :---------------: | :-----------------: | :-------------------: |\n| ![lin-badge]      | ![win-badge]        | ![cov-badge]          |\n\n[lin-badge]: https://travis-ci.org/miloyip/rapidjson.png?branch=master \"Travis build status\"\n[lin-link]:  https://travis-ci.org/miloyip/rapidjson \"Travis build status\"\n[win-badge]: https://ci.appveyor.com/api/projects/status/u658dcuwxo14a8m9/branch/master \"AppVeyor build status\"\n[win-link]:  https://ci.appveyor.com/project/miloyip/rapidjson/branch/master \"AppVeyor build status\"\n[cov-badge]: https://coveralls.io/repos/miloyip/rapidjson/badge.png?branch=master\n[cov-link]:  https://coveralls.io/r/miloyip/rapidjson?branch=master\n\n## 简介\n\nRapidJSON 是一个 C++ 的 JSON 解析器及生成器。它的灵感来自 [RapidXml](http://rapidxml.sourceforge.net/)。\n\n* RapidJSON 小而全。它同时支持 SAX 和 DOM 风格的 API。SAX 解析器只有约 500 行代码。\n\n* RapidJSON 快。它的性能可与 `strlen()` 相比。可支持 SSE2/SSE4.2 加速。\n\n* RapidJSON 独立。它不依赖于 BOOST 等外部库。它甚至不依赖于 STL。\n\n* RapidJSON 对内存友好。在大部分 32/64 位机器上，每个 JSON 值只占 16 字节（除字符串外）。它预设使用一个快速的内存分配器，令分析器可以紧凑地分配内存。\n\n* RapidJSON 对 Unicode 友好。它支持 UTF-8、UTF-16、UTF-32 (大端序／小端序)，并内部支持这些编码的检测、校验及转码。例如，RapidJSON 可以在分析一个 UTF-8 文件至 DOM 时，把当中的 JSON 字符串转码至 UTF-16。它也支持代理对（surrogate pair）及 `\"\\u0000\"`（空字符）。\n\n在 [这里](doc/features.zh-cn.md) 可读取更多特点。\n\nJSON（JavaScript Object Notation）是一个轻量的数据交换格式。RapidJSON 应该完全遵从 RFC7159/ECMA-404，并支持可选的放宽语法。 关于 JSON 的更多信息可参考：\n* [Introducing JSON](http://json.org/)\n* [RFC7159: The JavaScript Object Notation (JSON) Data Interchange Format](http://www.ietf.org/rfc/rfc7159.txt)\n* [Standard ECMA-404: The JSON Data Interchange Format](http://www.ecma-international.org/publications/standards/Ecma-404.htm)\n\n## v1.1 中的亮点 (2016-8-25)\n\n* 加入 [JSON Pointer](doc/pointer.zh-cn.md) 功能，可更简单地访问及更改 DOM。\n* 加入 [JSON Schema](doc/schema.zh-cn.md) 功能，可在解析或生成 JSON 时进行校验。\n* 加入 [放宽的 JSON 语法](doc/dom.zh-cn.md) （注释、尾随逗号、NaN/Infinity）\n* 使用 [C++11 范围 for 循环](doc/tutorial.zh-cn.md) 去遍历 array 和 object。\n* 在 x86-64 架构下，缩减每个 `Value` 的内存开销从 24 字节至 16 字节。\n\n其他改动请参考 [change log](CHANGELOG.md).\n\n## 兼容性\n\nRapidJSON 是跨平台的。以下是一些曾测试的平台／编译器组合：\n* Visual C++ 2008/2010/2013 在 Windows (32/64-bit)\n* GNU C++ 3.8.x 在 Cygwin\n* Clang 3.4 在 Mac OS X (32/64-bit) 及 iOS\n* Clang 3.4 在 Android NDK\n\n用户也可以在他们的平台上生成及执行单元测试。\n\n## 安装\n\nRapidJSON 是只有头文件的 C++ 库。只需把 `include/rapidjson` 目录复制至系统或项目的 include 目录中。\n\nRapidJSON 依赖于以下软件：\n* [CMake](http://www.cmake.org) 作为通用生成工具\n* (optional)[Doxygen](http://www.doxygen.org) 用于生成文档\n* (optional)[googletest](https://code.google.com/p/googletest/) 用于单元及性能测试\n\n生成测试及例子的步骤：\n\n1. 执行 `git submodule update --init` 去获取 thirdparty submodules (google test)。\n2. 在 rapidjson 目渌下，建立一个 `build` 目录。\n3. 在 `build` 目录下执行 `cmake ..` 命令以设置生成。Windows 用户可使用 cmake-gui 应用程序。\n4. 在 Windows 下，编译生成在 build 目录中的 solution。在 Linux 下，于 build 目录运行 `make`。\n\n成功生成后，你会在 `bin` 的目录下找到编译后的测试及例子可执行文件。而生成的文档将位于 build 下的 `doc/html` 目录。要执行测试，请在 build 下执行 `make test` 或 `ctest`。使用 `ctest -V` 命令可获取详细的输出。\n\n我们也可以把程序库安装至全系统中，只要在具管理權限下从 build 目录执行 `make install` 命令。这样会按系统的偏好设置安装所有文件。当安装 RapidJSON 后，其他的 CMake 项目需要使用它时，可以通过在 `CMakeLists.txt` 加入一句 `find_package(RapidJSON)`。\n\n## 用法一览\n\n此简单例子解析一个 JSON 字符串至一个 document (DOM)，对 DOM 作出简单修改，最终把 DOM 转换（stringify）至 JSON 字符串。\n\n~~~~~~~~~~cpp\n// rapidjson/example/simpledom/simpledom.cpp`\n#include \"rapidjson/document.h\"\n#include \"rapidjson/writer.h\"\n#include \"rapidjson/stringbuffer.h\"\n#include <iostream>\n\nusing namespace rapidjson;\n\nint main() {\n    // 1. 把 JSON 解析至 DOM。\n    const char* json = \"{\\\"project\\\":\\\"rapidjson\\\",\\\"stars\\\":10}\";\n    Document d;\n    d.Parse(json);\n\n    // 2. 利用 DOM 作出修改。\n    Value& s = d[\"stars\"];\n    s.SetInt(s.GetInt() + 1);\n\n    // 3. 把 DOM 转换（stringify）成 JSON。\n    StringBuffer buffer;\n    Writer<StringBuffer> writer(buffer);\n    d.Accept(writer);\n\n    // Output {\"project\":\"rapidjson\",\"stars\":11}\n    std::cout << buffer.GetString() << std::endl;\n    return 0;\n}\n~~~~~~~~~~\n\n注意此例子并没有处理潜在错误。\n\n下图展示执行过程。\n\n![simpledom](doc/diagram/simpledom.png)\n\n还有许多 [例子](https://github.com/miloyip/rapidjson/tree/master/example) 可供参考：\n\n* DOM API\n * [tutorial](https://github.com/miloyip/rapidjson/blob/master/example/tutorial/tutorial.cpp): DOM API 的基本使用方法。\n\n* SAX API\n * [simplereader](https://github.com/miloyip/rapidjson/blob/master/example/simplereader/simplereader.cpp): 使用 `Reader` 解析 JSON 时，打印所有 SAX 事件。\n * [condense](https://github.com/miloyip/rapidjson/blob/master/example/condense/condense.cpp): 移除 JSON 中所有空白符的命令行工具。\n * [pretty](https://github.com/miloyip/rapidjson/blob/master/example/pretty/pretty.cpp): 为 JSON 加入缩进与换行的命令行工具，当中使用了 `PrettyWriter`。\n * [capitalize](https://github.com/miloyip/rapidjson/blob/master/example/capitalize/capitalize.cpp): 把 JSON 中所有字符串改为大写的命令行工具。\n * [messagereader](https://github.com/miloyip/rapidjson/blob/master/example/messagereader/messagereader.cpp): 使用 SAX API 去解析一个 JSON 报文。\n * [serialize](https://github.com/miloyip/rapidjson/blob/master/example/serialize/serialize.cpp): 使用 SAX API 去序列化 C++ 对象，生成 JSON。\n * [jsonx](https://github.com/miloyip/rapidjson/blob/master/example/jsonx/jsonx.cpp): 实现了一个 `JsonxWriter`，它能把 SAX 事件写成 [JSONx](https://www-01.ibm.com/support/knowledgecenter/SS9H2Y_7.1.0/com.ibm.dp.doc/json_jsonx.html)（一种 XML）格式。这个例子是把 JSON 输入转换成 JSONx 格式的命令行工具。\n\n* Schema API\n * [schemavalidator](https://github.com/miloyip/rapidjson/blob/master/example/schemavalidator/schemavalidator.cpp): 使用 JSON Schema 去校验 JSON 的命令行工具。\n \n* 进阶\n * [prettyauto](https://github.com/miloyip/rapidjson/blob/master/example/prettyauto/prettyauto.cpp): [pretty](https://github.com/miloyip/rapidjson/blob/master/example/pretty/pretty.cpp) 的修改版本，可自动处理任何 UTF 编码的 JSON。\n * [parsebyparts](https://github.com/miloyip/rapidjson/blob/master/example/parsebyparts/parsebyparts.cpp): 这例子中的 `AsyncDocumentParser` 类使用 C++ 线程来逐段解析 JSON。\n * [filterkey](https://github.com/miloyip/rapidjson/blob/master/example/filterkey/filterkey.cpp): 移取使用者指定的键值的命令行工具。\n * [filterkeydom](https://github.com/miloyip/rapidjson/blob/master/example/filterkey/filterkey.cpp): 如上的工具，但展示如何使用生成器（generator）去填充一个 `Document`。"
  },
  {
    "path": "ext/rapidjson/test/CMakeLists.txt",
    "content": "find_package(GTestSrc)\n\nIF(GTESTSRC_FOUND)\n    enable_testing()\n\n    if (WIN32 AND (NOT CYGWIN) AND (NOT MINGW))\n        set(gtest_disable_pthreads ON)\n        set(gtest_force_shared_crt ON)\n    endif()\n\n    add_subdirectory(${GTEST_SOURCE_DIR} ${CMAKE_BINARY_DIR}/googletest)\n    include_directories(SYSTEM ${GTEST_INCLUDE_DIR})\n\n    set(TEST_LIBRARIES gtest gtest_main)\n\n    add_custom_target(tests ALL)\n    add_subdirectory(perftest)\n    add_subdirectory(unittest)\n\nENDIF(GTESTSRC_FOUND)\n"
  },
  {
    "path": "ext/rapidjson/test/perftest/CMakeLists.txt",
    "content": "set(PERFTEST_SOURCES\n    misctest.cpp\n    perftest.cpp\n    platformtest.cpp\n    rapidjsontest.cpp\n    schematest.cpp)\n\nadd_executable(perftest ${PERFTEST_SOURCES})\ntarget_link_libraries(perftest ${TEST_LIBRARIES})\n\nadd_dependencies(tests perftest)\n\nfind_program(CCACHE_FOUND ccache)\nif(CCACHE_FOUND)\n    set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)\n    set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)\n    if (CMAKE_CXX_COMPILER_ID MATCHES \"Clang\")\n        set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics\")\n    endif()\nendif(CCACHE_FOUND)\n\nIF(NOT (CMAKE_BUILD_TYPE STREQUAL \"Debug\"))\nadd_test(NAME perftest\n    COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/perftest\n    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)\nENDIF()\n"
  },
  {
    "path": "ext/rapidjson/test/perftest/misctest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"perftest.h\"\n\n#if TEST_MISC\n\n#define __STDC_FORMAT_MACROS\n#include \"rapidjson/stringbuffer.h\"\n\n#define protected public\n#include \"rapidjson/writer.h\"\n#undef private\n\nclass Misc : public PerfTest {\n};\n\n// Copyright (c) 2008-2010 Bjoern Hoehrmann <bjoern@hoehrmann.de>\n// See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.\n\n#define UTF8_ACCEPT 0\n#define UTF8_REJECT 12\n\nstatic const unsigned char utf8d[] = {\n    // The first part of the table maps bytes to character classes that\n    // to reduce the size of the transition table and create bitmasks.\n    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,  9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,\n    7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,  7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,\n    8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2,  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,\n    10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8,\n\n    // The second part is a transition table that maps a combination\n    // of a state of the automaton and a character class to a state.\n    0,12,24,36,60,96,84,12,12,12,48,72, 12,12,12,12,12,12,12,12,12,12,12,12,\n    12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24,12,12,\n    12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12,\n    12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12,\n    12,36,12,12,12,12,12,12,12,12,12,12, \n};\n\nstatic unsigned inline decode(unsigned* state, unsigned* codep, unsigned byte) {\n    unsigned type = utf8d[byte];\n\n    *codep = (*state != UTF8_ACCEPT) ?\n        (byte & 0x3fu) | (*codep << 6) :\n    (0xff >> type) & (byte);\n\n    *state = utf8d[256 + *state + type];\n    return *state;\n}\n\nstatic bool IsUTF8(unsigned char* s) {\n    unsigned codepoint, state = 0;\n\n    while (*s)\n        decode(&state, &codepoint, *s++);\n\n    return state == UTF8_ACCEPT;\n}\n\nTEST_F(Misc, Hoehrmann_IsUTF8) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        EXPECT_TRUE(IsUTF8((unsigned char*)json_));\n    }\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// CountDecimalDigit: Count number of decimal places\n\ninline unsigned CountDecimalDigit_naive(unsigned n) {\n    unsigned count = 1;\n    while (n >= 10) {\n        n /= 10;\n        count++;\n    }\n    return count;\n}\n\ninline unsigned CountDecimalDigit_enroll4(unsigned n) {\n    unsigned count = 1;\n    while (n >= 10000) {\n        n /= 10000u;\n        count += 4;\n    }\n    if (n < 10) return count;\n    if (n < 100) return count + 1;\n    if (n < 1000) return count + 2;\n    return count + 3;\n}\n\ninline unsigned CountDecimalDigit64_enroll4(uint64_t n) {\n    unsigned count = 1;\n    while (n >= 10000) {\n        n /= 10000u;\n        count += 4;\n    }\n    if (n < 10) return count;\n    if (n < 100) return count + 1;\n    if (n < 1000) return count + 2;\n    return count + 3;\n}\n\ninline unsigned CountDecimalDigit_fast(unsigned n) {\n    static const uint32_t powers_of_10[] = {\n        0,\n        10,\n        100,\n        1000,\n        10000,\n        100000,\n        1000000,\n        10000000,\n        100000000,\n        1000000000\n    };\n\n#if defined(_M_IX86) || defined(_M_X64)\n    unsigned long i = 0;\n    _BitScanReverse(&i, n | 1);\n    uint32_t t = (i + 1) * 1233 >> 12;\n#elif defined(__GNUC__)\n    uint32_t t = (32 - __builtin_clz(n | 1)) * 1233 >> 12;\n#else\n#error\n#endif\n    return t - (n < powers_of_10[t]) + 1;\n}\n\ninline unsigned CountDecimalDigit64_fast(uint64_t n) {\n    static const uint64_t powers_of_10[] = {\n        0,\n        10,\n        100,\n        1000,\n        10000,\n        100000,\n        1000000,\n        10000000,\n        100000000,\n        1000000000,\n        10000000000,\n        100000000000,\n        1000000000000,\n        10000000000000,\n        100000000000000,\n        1000000000000000,\n        10000000000000000,\n        100000000000000000,\n        1000000000000000000,\n        10000000000000000000U\n    };\n\n#if defined(_M_IX86)\n    uint64_t m = n | 1;\n    unsigned long i = 0;\n    if (_BitScanReverse(&i, m >> 32))\n        i += 32;\n    else\n        _BitScanReverse(&i, m & 0xFFFFFFFF);\n    uint32_t t = (i + 1) * 1233 >> 12;\n#elif defined(_M_X64)\n    unsigned long i = 0;\n    _BitScanReverse64(&i, n | 1);\n    uint32_t t = (i + 1) * 1233 >> 12;\n#elif defined(__GNUC__)\n    uint32_t t = (64 - __builtin_clzll(n | 1)) * 1233 >> 12;\n#else\n#error\n#endif\n\n    return t - (n < powers_of_10[t]) + 1;\n}\n\n#if 0\n// Exhaustive, very slow\nTEST_F(Misc, CountDecimalDigit_Verify) {\n    unsigned i = 0;\n    do {\n        if (i % (65536 * 256) == 0)\n            printf(\"%u\\n\", i);\n        ASSERT_EQ(CountDecimalDigit_enroll4(i), CountDecimalDigit_fast(i));\n        i++;\n    } while (i != 0);\n}\n\nstatic const unsigned kDigits10Trial = 1000000000u;\nTEST_F(Misc, CountDecimalDigit_naive) {\n    unsigned sum = 0;\n    for (unsigned i = 0; i < kDigits10Trial; i++)\n        sum += CountDecimalDigit_naive(i);\n    printf(\"%u\\n\", sum);\n}\n\nTEST_F(Misc, CountDecimalDigit_enroll4) {\n    unsigned sum = 0;\n    for (unsigned i = 0; i < kDigits10Trial; i++)\n        sum += CountDecimalDigit_enroll4(i);\n    printf(\"%u\\n\", sum);\n}\n\nTEST_F(Misc, CountDecimalDigit_fast) {\n    unsigned sum = 0;\n    for (unsigned i = 0; i < kDigits10Trial; i++)\n        sum += CountDecimalDigit_fast(i);\n    printf(\"%u\\n\", sum);\n}\n#endif\n\nTEST_F(Misc, CountDecimalDigit64_VerifyFast) {\n    uint64_t i = 1, j;\n    do {\n        //printf(\"%\" PRIu64 \"\\n\", i);\n        ASSERT_EQ(CountDecimalDigit64_enroll4(i), CountDecimalDigit64_fast(i));\n        j = i;\n        i *= 3;\n    } while (j < i);\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// integer-to-string conversion\n\n// https://gist.github.com/anonymous/7179097\nstatic const int randval[] ={\n     936116,  369532,  453755,  -72860,  209713,  268347,  435278, -360266, -416287, -182064,\n    -644712,  944969,  640463, -366588,  471577,  -69401, -744294, -505829,  923883,  831785,\n    -601136, -636767, -437054,  591718,  100758,  231907, -719038,  973540, -605220,  506659,\n    -871653,  462533,  764843, -919138,  404305, -630931, -288711, -751454, -173726, -718208,\n     432689, -281157,  360737,  659827,   19174, -376450,  769984, -858198,  439127,  734703,\n    -683426,       7,  386135,  186997, -643900, -744422, -604708, -629545,   42313, -933592,\n    -635566,  182308,  439024, -367219,  -73924, -516649,  421935, -470515,  413507,  -78952,\n    -427917, -561158,  737176,   94538,  572322,  405217,  709266, -357278, -908099, -425447,\n     601119,  750712, -862285, -177869,  900102,  384877,  157859, -641680,  503738, -702558,\n     278225,  463290,  268378, -212840,  580090,  347346, -473985, -950968, -114547, -839893,\n    -738032, -789424,  409540,  493495,  432099,  119755,  905004, -174834,  338266,  234298,\n      74641, -965136, -754593,  685273,  466924,  920560,  385062,  796402,  -67229,  994864,\n     376974,  299869, -647540, -128724,  469890, -163167, -547803, -743363,  486463, -621028,\n     612288,   27459, -514224,  126342,  -66612,  803409, -777155, -336453, -284002,  472451,\n     342390, -163630,  908356, -456147, -825607,  268092, -974715,  287227,  227890, -524101,\n     616370, -782456,  922098, -624001, -813690,  171605, -192962,  796151,  707183,  -95696,\n     -23163, -721260,  508892,  430715,  791331,  482048, -996102,  863274,  275406,   -8279,\n    -556239, -902076,  268647, -818565,  260069, -798232, -172924, -566311, -806503, -885992,\n     813969,  -78468,  956632,  304288,  494867, -508784,  381751,  151264,  762953,   76352,\n     594902,  375424,  271700, -743062,  390176,  924237,  772574,  676610,  435752, -153847,\n       3959, -971937, -294181, -538049, -344620, -170136,   19120, -703157,  868152, -657961,\n    -818631,  219015, -872729, -940001, -956570,  880727, -345910,  942913, -942271, -788115,\n     225294,  701108, -517736, -416071,  281940,  488730,  942698,  711494,  838382, -892302,\n    -533028,  103052,  528823,  901515,  949577,  159364,  718227, -241814, -733661, -462928,\n    -495829,  165170,  513580, -629188, -509571, -459083,  198437,   77198, -644612,  811276,\n    -422298, -860842,  -52584,  920369,  686424, -530667, -243476,   49763,  345866, -411960,\n    -114863,  470810, -302860,  683007, -509080,       2, -174981, -772163,  -48697,  447770,\n    -268246,  213268,  269215,   78810, -236340, -639140, -864323,  505113, -986569, -325215,\n     541859,  163070, -819998, -645161, -583336,  573414,  696417, -132375,       3, -294501,\n     320435,  682591,  840008,  351740,  426951,  609354,  898154, -943254,  227321, -859793,\n    -727993,   44137, -497965, -782239,   14955, -746080, -243366,    9837, -233083,  606507,\n    -995864, -615287, -994307,  602715,  770771, -315040,  610860,  446102, -307120,  710728,\n    -590392, -230474, -762625, -637525,  134963, -202700, -766902, -985541,  218163,  682009,\n     926051,  525156,  -61195,  403211, -810098,  245539, -431733,  179998, -806533,  745943,\n     447597,  131973, -187130,  826019,  286107, -937230, -577419,   20254,  681802, -340500,\n     323080,  266283, -667617,  309656,  416386,  611863,  759991, -534257,  523112, -634892,\n    -169913, -204905, -909867, -882185, -944908,  741811, -717675,  967007, -317396,  407230,\n    -412805,  792905,  994873,  744793, -456797,  713493,  355232,  116900, -945199,  880539,\n     342505, -580824, -262273,  982968, -349497, -735488,  311767, -455191,  570918,  389734,\n    -958386,   10262,  -99267,  155481,  304210,  204724,  704367, -144893, -233664, -671441,\n     896849,  408613,  762236,  322697,  981321,  688476,   13663, -970704, -379507,  896412,\n     977084,  348869,  875948,  341348,  318710,  512081,    6163,  669044,  833295,  811883,\n     708756, -802534, -536057,  608413, -389625, -694603,  541106, -110037,  720322, -540581,\n     645420,   32980,   62442,  510157, -981870,  -87093, -325960, -500494, -718291,  -67889,\n     991501,  374804,  769026, -978869,  294747,  714623,  413327, -199164,  671368,  804789,\n    -362507,  798196, -170790, -568895, -869379,   62020, -316693, -837793,  644994,  -39341,\n    -417504, -243068, -957756,   99072,  622234, -739992,  225668,    8863, -505910,   82483,\n    -559244,  241572,    1315,  -36175,  -54990,  376813,     -11,  162647, -688204, -486163,\n     -54934, -197470,  744223, -762707,  732540,  996618,  351561, -445933, -898491,  486531,\n     456151,   15276,  290186, -817110,  -52995,  313046, -452533,  -96267,   94470, -500176,\n    -818026, -398071, -810548, -143325, -819741,    1338, -897676, -101577, -855445,   37309,\n     285742,  953804, -777927, -926962, -811217, -936744, -952245, -802300, -490188, -964953,\n    -552279,  329142, -570048, -505756,  682898, -381089,  -14352,  175138,  152390, -582268,\n    -485137,  717035,  805329,  239572, -730409,  209643, -184403, -385864,  675086,  819648,\n     629058, -527109, -488666, -171981,  532788,  552441,  174666,  984921,  766514,  758787,\n     716309,  338801, -978004, -412163,  876079, -734212,  789557, -160491, -522719,   56644,\n       -991, -286038,  -53983,  663740,  809812,  919889, -717502, -137704,  220511,  184396,\n    -825740, -588447,  430870,  124309,  135956,  558662, -307087, -788055, -451328,  812260,\n     931601,  324347, -482989, -117858, -278861,  189068, -172774,  929057,  293787,  198161,\n    -342386,  -47173,  906555, -759955,  -12779,  777604,  -97869,  899320,  927486,  -25284,\n    -848550,  259450, -485856,  -17820,      88,  171400,  235492, -326783, -340793,  886886,\n     112428, -246280,    5979,  648444, -114982,  991013,  -56489,   -9497,  419706,  632820,\n    -341664,  393926, -848977,  -22538,  257307,  773731, -905319,  491153,  734883, -868212,\n    -951053,  644458, -580758,  764735,  584316,  297077,   28852, -397710, -953669,  201772,\n     879050, -198237, -588468,  448102, -116837,  770007, -231812,  642906, -582166, -885828,\n          9,  305082, -996577,  303559,   75008, -772956, -447960,  599825, -295552,  870739,\n    -386278, -950300,  485359, -457081,  629461, -850276,  550496, -451755, -620841,  -11766,\n    -950137,  832337,   28711, -273398, -507197,   91921, -271360, -705991, -753220, -388968,\n     967945,  340434, -320883, -662793, -554617, -574568,  477946,   -6148, -129519,  689217,\n     920020, -656315, -974523, -212525,   80921, -612532,  645096,  545655,  655713, -591631,\n    -307385, -816688, -618823, -113713,  526430,  673063,  735916, -809095, -850417,  639004,\n     432281, -388185,  270708,  860146,  -39902, -786157, -258180, -246169, -966720, -264957,\n     548072, -306010,  -57367, -635665,  933824,   70553, -989936, -488741,   72411, -452509,\n     529831,  956277,  449019, -577850, -360986, -803418,   48833,  296073,  203430,  609591,\n     715483,  470964,  658106, -718254,  -96424,  790163,  334739,  181070, -373578,       5,\n    -435088,  329841,  330939, -256602,  394355,  912412,  231910,  927278, -661933,  788539,\n    -769664, -893274,  -96856,  298205,  901043, -608122, -527430,  183618, -553963,  -35246,\n    -393924,  948832, -483198,  594501,   35460, -407007,   93494, -336881, -634072,  984205,\n    -812161,  944664,  -31062,  753872,  823933,  -69566,   50445,  290147,   85134,   34706,\n     551902,  405202, -991246,  -84642,  154341,  316432, -695101, -651588,   -5030,  137564,\n    -294665,  332541,  528307,  -90572, -344923,  523766, -758498, -968047,  339028,  494578,\n     593129, -725773,   31834, -718406, -208638,  159665,   -2043,  673344, -442767,   75816,\n     755442,  769257, -158730, -410272,  691688,  589550, -878398, -184121,  460679,  346312,\n     294163, -544602,  653308,  254167, -276979,   52073, -892684,  887653,  -41222,  983065,\n     -68258, -408799,  -99069, -674069, -863635,  -32890,  622757, -743862,   40872,   -4837,\n    -967228,  522370, -903951, -818669,  524459,  514702,  925801,   20007, -299229,  579348,\n     626021,  430089,  348139, -562692, -607728, -130606, -928451, -424793, -458647, -448892,\n    -312230,  143337,  109746,  880042, -339658, -785614,  938995,  540916,  118429,  661351,\n    -402967,  404729,  -40918, -976535,  743230,  713110,  440182, -381314, -499252,   74613,\n     193652,  912717,  491323,  583633,  324691,  459397,  281253,  195540,   -2764, -888651,\n     892449,  132663, -478373, -430002, -314551,  527826,  247165,  557966,  554778,  481531,\n    -946634,  431685, -769059, -348371,  174046,  184597, -354867,  584422,  227390, -850397,\n    -542924, -849093, -737769,  325359,  736314,  269101,  767940,  674809,   81413, -447458,\n     445076,  189072,  906218,  502688, -718476, -863827, -731381,  100660,  623249,  710008,\n     572060,  922203,  685740,   55096,  263394, -243695, -353910, -516788,  388471,  455165,\n     844103, -643772,  363976,  268875, -899450,  104470,  104029, -238874, -274659,  732969,\n    -676443,  953291, -916289, -861849, -242344,  958083, -479593, -970395,  799831,  277841,\n    -243236, -283462, -201510,  166263, -259105, -575706,  878926,  891064,  895297,  655262,\n     -34807, -809833,  -89281,  342585,  554920,       1,  902141, -333425,  139703,  852318,\n    -618438,  329498, -932596, -692836, -513372,  733656, -523411,   85779,  500478, -682697,\n    -502836,  138776,  156341, -420037, -557964, -556378,  710993,  -50383, -877159,  916334,\n     132996,  583516, -603392, -111615,  -12288, -780214,  476780,  123327,  137607,  519956,\n     745837,   17358, -158581,  -53490\n};\nstatic const size_t randvalCount = sizeof(randval) / sizeof(randval[0]);\nstatic const size_t kItoaTrialCount = 10000;\n\nstatic const char digits[201] =\n\"0001020304050607080910111213141516171819\"\n\"2021222324252627282930313233343536373839\"\n\"4041424344454647484950515253545556575859\"\n\"6061626364656667686970717273747576777879\"\n\"8081828384858687888990919293949596979899\";\n\n// Prevent code being optimized out\n//#define OUTPUT_LENGTH(length) printf(\"\", length)\n#define OUTPUT_LENGTH(length) printf(\"%u\\n\", (unsigned)length)\n\ntemplate<typename OutputStream>\nclass Writer1 {\npublic:\n    Writer1() : os_() {}\n    Writer1(OutputStream& os) : os_(&os) {}\n\n    void Reset(OutputStream& os) {\n        os_ = &os;\n    }\n\n    bool WriteInt(int i) {\n        if (i < 0) {\n            os_->Put('-');\n            i = -i;\n        }\n        return WriteUint((unsigned)i);\n    }\n\n    bool WriteUint(unsigned u) {\n        char buffer[10];\n        char *p = buffer;\n        do {\n            *p++ = char(u % 10) + '0';\n            u /= 10;\n        } while (u > 0);\n\n        do {\n            --p;\n            os_->Put(*p);\n        } while (p != buffer);\n        return true;\n    }\n\n    bool WriteInt64(int64_t i64) {\n        if (i64 < 0) {\n            os_->Put('-');\n            i64 = -i64;\n        }\n        WriteUint64((uint64_t)i64);\n        return true;\n    }\n\n    bool WriteUint64(uint64_t u64) {\n        char buffer[20];\n        char *p = buffer;\n        do {\n            *p++ = char(u64 % 10) + '0';\n            u64 /= 10;\n        } while (u64 > 0);\n\n        do {\n            --p;\n            os_->Put(*p);\n        } while (p != buffer);\n        return true;\n    }\n\nprivate:\n    OutputStream* os_;\n};\n\ntemplate<>\nbool Writer1<rapidjson::StringBuffer>::WriteUint(unsigned u) {\n    char buffer[10];\n    char* p = buffer;\n    do {\n        *p++ = char(u % 10) + '0';\n        u /= 10;\n    } while (u > 0);\n\n    char* d = os_->Push(p - buffer);\n    do {\n        --p;\n        *d++ = *p;\n    } while (p != buffer);\n    return true;\n}\n\n// Using digits LUT to reduce divsion/modulo\ntemplate<typename OutputStream>\nclass Writer2 {\npublic:\n    Writer2() : os_() {}\n    Writer2(OutputStream& os) : os_(&os) {}\n\n    void Reset(OutputStream& os) {\n        os_ = &os;\n    }\n\n    bool WriteInt(int i) {\n        if (i < 0) {\n            os_->Put('-');\n            i = -i;\n        }\n        return WriteUint((unsigned)i);\n    }\n\n    bool WriteUint(unsigned u) {\n        char buffer[10];\n        char* p = buffer;\n        while (u >= 100) {\n            const unsigned i = (u % 100) << 1;\n            u /= 100;\n            *p++ = digits[i + 1];\n            *p++ = digits[i];\n        }\n        if (u < 10)\n            *p++ = char(u) + '0';\n        else {\n            const unsigned i = u << 1;\n            *p++ = digits[i + 1];\n            *p++ = digits[i];\n        }\n\n        do {\n            --p;\n            os_->Put(*p);\n        } while (p != buffer);\n        return true;\n    }\n\n    bool WriteInt64(int64_t i64) {\n        if (i64 < 0) {\n            os_->Put('-');\n            i64 = -i64;\n        }\n        WriteUint64((uint64_t)i64);\n        return true;\n    }\n\n    bool WriteUint64(uint64_t u64) {\n        char buffer[20];\n        char* p = buffer;\n        while (u64 >= 100) {\n            const unsigned i = static_cast<unsigned>(u64 % 100) << 1;\n            u64 /= 100;\n            *p++ = digits[i + 1];\n            *p++ = digits[i];\n        }\n        if (u64 < 10)\n            *p++ = char(u64) + '0';\n        else {\n            const unsigned i = static_cast<unsigned>(u64) << 1;\n            *p++ = digits[i + 1];\n            *p++ = digits[i];\n        }\n\n        do {\n            --p;\n            os_->Put(*p);\n        } while (p != buffer);\n        return true;\n    }\n\nprivate:\n    OutputStream* os_;\n};\n\n// First pass to count digits\ntemplate<typename OutputStream>\nclass Writer3 {\npublic:\n    Writer3() : os_() {}\n    Writer3(OutputStream& os) : os_(&os) {}\n\n    void Reset(OutputStream& os) {\n        os_ = &os;\n    }\n\n    bool WriteInt(int i) {\n        if (i < 0) {\n            os_->Put('-');\n            i = -i;\n        }\n        return WriteUint((unsigned)i);\n    }\n\n    bool WriteUint(unsigned u) {\n        char buffer[10];\n        char *p = buffer;\n        do {\n            *p++ = char(u % 10) + '0';\n            u /= 10;\n        } while (u > 0);\n\n        do {\n            --p;\n            os_->Put(*p);\n        } while (p != buffer);\n        return true;\n    }\n\n    bool WriteInt64(int64_t i64) {\n        if (i64 < 0) {\n            os_->Put('-');\n            i64 = -i64;\n        }\n        WriteUint64((uint64_t)i64);\n        return true;\n    }\n\n    bool WriteUint64(uint64_t u64) {\n        char buffer[20];\n        char *p = buffer;\n        do {\n            *p++ = char(u64 % 10) + '0';\n            u64 /= 10;\n        } while (u64 > 0);\n\n        do {\n            --p;\n            os_->Put(*p);\n        } while (p != buffer);\n        return true;\n    }\n\nprivate:\n    void WriteUintReverse(char* d, unsigned u) {\n        do {\n            *--d = char(u % 10) + '0';\n            u /= 10;\n        } while (u > 0);\n    }\n\n    void WriteUint64Reverse(char* d, uint64_t u) {\n        do {\n            *--d = char(u % 10) + '0';\n            u /= 10;\n        } while (u > 0);\n    }\n\n    OutputStream* os_;\n};\n\ntemplate<>\ninline bool Writer3<rapidjson::StringBuffer>::WriteUint(unsigned u) {\n    unsigned digit = CountDecimalDigit_fast(u);\n    WriteUintReverse(os_->Push(digit) + digit, u);\n    return true;\n}\n\ntemplate<>\ninline bool Writer3<rapidjson::InsituStringStream>::WriteUint(unsigned u) {\n    unsigned digit = CountDecimalDigit_fast(u);\n    WriteUintReverse(os_->Push(digit) + digit, u);\n    return true;\n}\n\ntemplate<>\ninline bool Writer3<rapidjson::StringBuffer>::WriteUint64(uint64_t u) {\n    unsigned digit = CountDecimalDigit64_fast(u);\n    WriteUint64Reverse(os_->Push(digit) + digit, u);\n    return true;\n}\n\ntemplate<>\ninline bool Writer3<rapidjson::InsituStringStream>::WriteUint64(uint64_t u) {\n    unsigned digit = CountDecimalDigit64_fast(u);\n    WriteUint64Reverse(os_->Push(digit) + digit, u);\n    return true;\n}\n\n// Using digits LUT to reduce divsion/modulo, two passes\ntemplate<typename OutputStream>\nclass Writer4 {\npublic:\n    Writer4() : os_() {}\n    Writer4(OutputStream& os) : os_(&os) {}\n\n    void Reset(OutputStream& os) {\n        os_ = &os;\n    }\n\n    bool WriteInt(int i) {\n        if (i < 0) {\n            os_->Put('-');\n            i = -i;\n        }\n        return WriteUint((unsigned)i);\n    }\n\n    bool WriteUint(unsigned u) {\n        char buffer[10];\n        char* p = buffer;\n        while (u >= 100) {\n            const unsigned i = (u % 100) << 1;\n            u /= 100;\n            *p++ = digits[i + 1];\n            *p++ = digits[i];\n        }\n        if (u < 10)\n            *p++ = char(u) + '0';\n        else {\n            const unsigned i = u << 1;\n            *p++ = digits[i + 1];\n            *p++ = digits[i];\n        }\n\n        do {\n            --p;\n            os_->Put(*p);\n        } while (p != buffer);\n        return true;\n    }\n\n    bool WriteInt64(int64_t i64) {\n        if (i64 < 0) {\n            os_->Put('-');\n            i64 = -i64;\n        }\n        WriteUint64((uint64_t)i64);\n        return true;\n    }\n\n    bool WriteUint64(uint64_t u64) {\n        char buffer[20];\n        char* p = buffer;\n        while (u64 >= 100) {\n            const unsigned i = static_cast<unsigned>(u64 % 100) << 1;\n            u64 /= 100;\n            *p++ = digits[i + 1];\n            *p++ = digits[i];\n        }\n        if (u64 < 10)\n            *p++ = char(u64) + '0';\n        else {\n            const unsigned i = static_cast<unsigned>(u64) << 1;\n            *p++ = digits[i + 1];\n            *p++ = digits[i];\n        }\n\n        do {\n            --p;\n            os_->Put(*p);\n        } while (p != buffer);\n        return true;\n    }\n\nprivate:\n    void WriteUintReverse(char* d, unsigned u) {\n        while (u >= 100) {\n            const unsigned i = (u % 100) << 1;\n            u /= 100;\n            *--d = digits[i + 1];\n            *--d = digits[i];\n        }\n        if (u < 10) {\n            *--d = char(u) + '0';\n        }\n        else {\n            const unsigned i = u << 1;\n            *--d = digits[i + 1];\n            *--d = digits[i];\n        }\n    }\n\n    void WriteUint64Reverse(char* d, uint64_t u) {\n        while (u >= 100) {\n            const unsigned i = (u % 100) << 1;\n            u /= 100;\n            *--d = digits[i + 1];\n            *--d = digits[i];\n        }\n        if (u < 10) {\n            *--d = char(u) + '0';\n        }\n        else {\n            const unsigned i = u << 1;\n            *--d = digits[i + 1];\n            *--d = digits[i];\n        }\n    }\n\n    OutputStream* os_;\n};\n\ntemplate<>\ninline bool Writer4<rapidjson::StringBuffer>::WriteUint(unsigned u) {\n    unsigned digit = CountDecimalDigit_fast(u);\n    WriteUintReverse(os_->Push(digit) + digit, u);\n    return true;\n}\n\ntemplate<>\ninline bool Writer4<rapidjson::InsituStringStream>::WriteUint(unsigned u) {\n    unsigned digit = CountDecimalDigit_fast(u);\n    WriteUintReverse(os_->Push(digit) + digit, u);\n    return true;\n}\n\ntemplate<>\ninline bool Writer4<rapidjson::StringBuffer>::WriteUint64(uint64_t u) {\n    unsigned digit = CountDecimalDigit64_fast(u);\n    WriteUint64Reverse(os_->Push(digit) + digit, u);\n    return true;\n}\n\ntemplate<>\ninline bool Writer4<rapidjson::InsituStringStream>::WriteUint64(uint64_t u) {\n    unsigned digit = CountDecimalDigit64_fast(u);\n    WriteUint64Reverse(os_->Push(digit) + digit, u);\n    return true;\n}\n\ntemplate <typename Writer>\nvoid itoa_Writer_StringBufferVerify() {\n    rapidjson::StringBuffer sb;\n    Writer writer(sb);\n    for (size_t j = 0; j < randvalCount; j++) {\n        char buffer[32];\n        sprintf(buffer, \"%d\", randval[j]);\n        writer.WriteInt(randval[j]);\n        ASSERT_STREQ(buffer, sb.GetString());\n        sb.Clear();\n    }\n}\n\ntemplate <typename Writer>\nvoid itoa_Writer_InsituStringStreamVerify() {\n    Writer writer;\n    for (size_t j = 0; j < randvalCount; j++) {\n        char buffer[32];\n        sprintf(buffer, \"%d\", randval[j]);\n        char buffer2[32];\n        rapidjson::InsituStringStream ss(buffer2);\n        writer.Reset(ss);\n        char* begin = ss.PutBegin();\n        writer.WriteInt(randval[j]);\n        ss.Put('\\0');\n        ss.PutEnd(begin);\n        ASSERT_STREQ(buffer, buffer2);\n    }\n}\n\ntemplate <typename Writer>\nvoid itoa_Writer_StringBuffer() {\n    size_t length = 0;\n\n    rapidjson::StringBuffer sb;\n    Writer writer(sb);\n\n    for (size_t i = 0; i < kItoaTrialCount; i++) {\n        for (size_t j = 0; j < randvalCount; j++) {\n            writer.WriteInt(randval[j]);\n            length += sb.GetSize();\n            sb.Clear();\n        }\n    }\n    OUTPUT_LENGTH(length);\n}\n\ntemplate <typename Writer>\nvoid itoa_Writer_InsituStringStream() {\n    size_t length = 0;\n\n    char buffer[32];\n    Writer writer;\n    for (size_t i = 0; i < kItoaTrialCount; i++) {\n        for (size_t j = 0; j < randvalCount; j++) {\n            rapidjson::InsituStringStream ss(buffer);\n            writer.Reset(ss);\n            char* begin = ss.PutBegin();\n            writer.WriteInt(randval[j]);\n            length += ss.PutEnd(begin);\n        }\n    }\n    OUTPUT_LENGTH(length);\n};\n\ntemplate <typename Writer>\nvoid itoa64_Writer_StringBufferVerify() {\n    rapidjson::StringBuffer sb;\n    Writer writer(sb);\n    for (size_t j = 0; j < randvalCount; j++) {\n        char buffer[32];\n        int64_t x = randval[j] * randval[j];\n        sprintf(buffer, \"%\" PRIi64, x);\n        writer.WriteInt64(x);\n        ASSERT_STREQ(buffer, sb.GetString());\n        sb.Clear();\n    }\n}\n\ntemplate <typename Writer>\nvoid itoa64_Writer_InsituStringStreamVerify() {\n    Writer writer;\n    for (size_t j = 0; j < randvalCount; j++) {\n        char buffer[32];\n        int64_t x = randval[j] * randval[j];\n        sprintf(buffer, \"%\" PRIi64, x);\n        char buffer2[32];\n        rapidjson::InsituStringStream ss(buffer2);\n        writer.Reset(ss);\n        char* begin = ss.PutBegin();\n        writer.WriteInt64(x);\n        ss.Put('\\0');\n        ss.PutEnd(begin);\n        ASSERT_STREQ(buffer, buffer2);\n    }\n}\n\ntemplate <typename Writer>\nvoid itoa64_Writer_StringBuffer() {\n    size_t length = 0;\n\n    rapidjson::StringBuffer sb;\n    Writer writer(sb);\n\n    for (size_t i = 0; i < kItoaTrialCount; i++) {\n        for (size_t j = 0; j < randvalCount; j++) {\n            writer.WriteInt64(randval[j] * randval[j]);\n            length += sb.GetSize();\n            sb.Clear();\n        }\n    }\n    OUTPUT_LENGTH(length);\n}\n\ntemplate <typename Writer>\nvoid itoa64_Writer_InsituStringStream() {\n    size_t length = 0;\n\n    char buffer[32];\n    Writer writer;\n    for (size_t i = 0; i < kItoaTrialCount; i++) {\n        for (size_t j = 0; j < randvalCount; j++) {\n            rapidjson::InsituStringStream ss(buffer);\n            writer.Reset(ss);\n            char* begin = ss.PutBegin();\n            writer.WriteInt64(randval[j] * randval[j]);\n            length += ss.PutEnd(begin);\n        }\n    }\n    OUTPUT_LENGTH(length);\n};\n\n// Full specialization for InsituStringStream to prevent memory copying \n// (normally we will not use InsituStringStream for writing, just for testing)\n\nnamespace rapidjson {\n\ntemplate<>\nbool rapidjson::Writer<InsituStringStream>::WriteInt(int i) {\n    char *buffer = os_->Push(11);\n    const char* end = internal::i32toa(i, buffer);\n    os_->Pop(11 - (end - buffer));\n    return true;\n}\n\ntemplate<>\nbool Writer<InsituStringStream>::WriteUint(unsigned u) {\n    char *buffer = os_->Push(10);\n    const char* end = internal::u32toa(u, buffer);\n    os_->Pop(10 - (end - buffer));\n    return true;\n}\n\ntemplate<>\nbool Writer<InsituStringStream>::WriteInt64(int64_t i64) {\n    char *buffer = os_->Push(21);\n    const char* end = internal::i64toa(i64, buffer);\n    os_->Pop(21 - (end - buffer));\n    return true;\n}\n\ntemplate<>\nbool Writer<InsituStringStream>::WriteUint64(uint64_t u) {\n    char *buffer = os_->Push(20);\n    const char* end = internal::u64toa(u, buffer);\n    os_->Pop(20 - (end - buffer));\n    return true;\n}\n\n} // namespace rapidjson\n\nTEST_F(Misc, itoa_Writer_StringBufferVerify) { itoa_Writer_StringBufferVerify<rapidjson::Writer<rapidjson::StringBuffer> >(); }\nTEST_F(Misc, itoa_Writer1_StringBufferVerify) { itoa_Writer_StringBufferVerify<Writer1<rapidjson::StringBuffer> >(); }\nTEST_F(Misc, itoa_Writer2_StringBufferVerify) { itoa_Writer_StringBufferVerify<Writer2<rapidjson::StringBuffer> >(); }\nTEST_F(Misc, itoa_Writer3_StringBufferVerify) { itoa_Writer_StringBufferVerify<Writer3<rapidjson::StringBuffer> >(); }\nTEST_F(Misc, itoa_Writer4_StringBufferVerify) { itoa_Writer_StringBufferVerify<Writer4<rapidjson::StringBuffer> >(); }\nTEST_F(Misc, itoa_Writer_InsituStringStreamVerify) { itoa_Writer_InsituStringStreamVerify<rapidjson::Writer<rapidjson::InsituStringStream> >(); }\nTEST_F(Misc, itoa_Writer1_InsituStringStreamVerify) { itoa_Writer_InsituStringStreamVerify<Writer1<rapidjson::InsituStringStream> >(); }\nTEST_F(Misc, itoa_Writer2_InsituStringStreamVerify) { itoa_Writer_InsituStringStreamVerify<Writer2<rapidjson::InsituStringStream> >(); }\nTEST_F(Misc, itoa_Writer3_InsituStringStreamVerify) { itoa_Writer_InsituStringStreamVerify<Writer3<rapidjson::InsituStringStream> >(); }\nTEST_F(Misc, itoa_Writer4_InsituStringStreamVerify) { itoa_Writer_InsituStringStreamVerify<Writer4<rapidjson::InsituStringStream> >(); }\nTEST_F(Misc, itoa_Writer_StringBuffer) { itoa_Writer_StringBuffer<rapidjson::Writer<rapidjson::StringBuffer> >(); }\nTEST_F(Misc, itoa_Writer1_StringBuffer) { itoa_Writer_StringBuffer<Writer1<rapidjson::StringBuffer> >(); }\nTEST_F(Misc, itoa_Writer2_StringBuffer) { itoa_Writer_StringBuffer<Writer2<rapidjson::StringBuffer> >(); }\nTEST_F(Misc, itoa_Writer3_StringBuffer) { itoa_Writer_StringBuffer<Writer3<rapidjson::StringBuffer> >(); }\nTEST_F(Misc, itoa_Writer4_StringBuffer) { itoa_Writer_StringBuffer<Writer4<rapidjson::StringBuffer> >(); }\nTEST_F(Misc, itoa_Writer_InsituStringStream) { itoa_Writer_InsituStringStream<rapidjson::Writer<rapidjson::InsituStringStream> >(); }\nTEST_F(Misc, itoa_Writer1_InsituStringStream) { itoa_Writer_InsituStringStream<Writer1<rapidjson::InsituStringStream> >(); }\nTEST_F(Misc, itoa_Writer2_InsituStringStream) { itoa_Writer_InsituStringStream<Writer2<rapidjson::InsituStringStream> >(); }\nTEST_F(Misc, itoa_Writer3_InsituStringStream) { itoa_Writer_InsituStringStream<Writer3<rapidjson::InsituStringStream> >(); }\nTEST_F(Misc, itoa_Writer4_InsituStringStream) { itoa_Writer_InsituStringStream<Writer4<rapidjson::InsituStringStream> >(); }\n\nTEST_F(Misc, itoa64_Writer_StringBufferVerify) { itoa64_Writer_StringBufferVerify<rapidjson::Writer<rapidjson::StringBuffer> >(); }\nTEST_F(Misc, itoa64_Writer1_StringBufferVerify) { itoa64_Writer_StringBufferVerify<Writer1<rapidjson::StringBuffer> >(); }\nTEST_F(Misc, itoa64_Writer2_StringBufferVerify) { itoa64_Writer_StringBufferVerify<Writer2<rapidjson::StringBuffer> >(); }\nTEST_F(Misc, itoa64_Writer3_StringBufferVerify) { itoa64_Writer_StringBufferVerify<Writer3<rapidjson::StringBuffer> >(); }\nTEST_F(Misc, itoa64_Writer4_StringBufferVerify) { itoa64_Writer_StringBufferVerify<Writer4<rapidjson::StringBuffer> >(); }\nTEST_F(Misc, itoa64_Writer_InsituStringStreamVerify) { itoa64_Writer_InsituStringStreamVerify<rapidjson::Writer<rapidjson::InsituStringStream> >(); }\nTEST_F(Misc, itoa64_Writer1_InsituStringStreamVerify) { itoa64_Writer_InsituStringStreamVerify<Writer1<rapidjson::InsituStringStream> >(); }\nTEST_F(Misc, itoa64_Writer2_InsituStringStreamVerify) { itoa64_Writer_InsituStringStreamVerify<Writer2<rapidjson::InsituStringStream> >(); }\nTEST_F(Misc, itoa64_Writer3_InsituStringStreamVerify) { itoa64_Writer_InsituStringStreamVerify<Writer3<rapidjson::InsituStringStream> >(); }\nTEST_F(Misc, itoa64_Writer4_InsituStringStreamVerify) { itoa64_Writer_InsituStringStreamVerify<Writer4<rapidjson::InsituStringStream> >(); }\nTEST_F(Misc, itoa64_Writer_StringBuffer) { itoa64_Writer_StringBuffer<rapidjson::Writer<rapidjson::StringBuffer> >(); }\nTEST_F(Misc, itoa64_Writer1_StringBuffer) { itoa64_Writer_StringBuffer<Writer1<rapidjson::StringBuffer> >(); }\nTEST_F(Misc, itoa64_Writer2_StringBuffer) { itoa64_Writer_StringBuffer<Writer2<rapidjson::StringBuffer> >(); }\nTEST_F(Misc, itoa64_Writer3_StringBuffer) { itoa64_Writer_StringBuffer<Writer3<rapidjson::StringBuffer> >(); }\nTEST_F(Misc, itoa64_Writer4_StringBuffer) { itoa64_Writer_StringBuffer<Writer4<rapidjson::StringBuffer> >(); }\nTEST_F(Misc, itoa64_Writer_InsituStringStream) { itoa64_Writer_InsituStringStream<rapidjson::Writer<rapidjson::InsituStringStream> >(); }\nTEST_F(Misc, itoa64_Writer1_InsituStringStream) { itoa64_Writer_InsituStringStream<Writer1<rapidjson::InsituStringStream> >(); }\nTEST_F(Misc, itoa64_Writer2_InsituStringStream) { itoa64_Writer_InsituStringStream<Writer2<rapidjson::InsituStringStream> >(); }\nTEST_F(Misc, itoa64_Writer3_InsituStringStream) { itoa64_Writer_InsituStringStream<Writer3<rapidjson::InsituStringStream> >(); }\nTEST_F(Misc, itoa64_Writer4_InsituStringStream) { itoa64_Writer_InsituStringStream<Writer4<rapidjson::InsituStringStream> >(); }\n\n#endif // TEST_MISC\n"
  },
  {
    "path": "ext/rapidjson/test/perftest/perftest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"perftest.h\"\n\nint main(int argc, char **argv) {\n#if _MSC_VER\n    _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );\n    //void *testWhetherMemoryLeakDetectionWorks = malloc(1);\n#endif\n    ::testing::InitGoogleTest(&argc, argv);\n    return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "ext/rapidjson/test/perftest/perftest.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef PERFTEST_H_\n#define PERFTEST_H_\n\n#define TEST_RAPIDJSON  1\n#define TEST_PLATFORM   0\n#define TEST_MISC       0\n\n#define TEST_VERSION_CODE(x,y,z) \\\n  (((x)*100000) + ((y)*100) + (z))\n\n// __SSE2__ and __SSE4_2__ are recognized by gcc, clang, and the Intel compiler.\n// We use -march=native with gmake to enable -msse2 and -msse4.2, if supported.\n#if defined(__SSE4_2__)\n#  define RAPIDJSON_SSE42\n#elif defined(__SSE2__)\n#  define RAPIDJSON_SSE2\n#endif\n\n#define RAPIDJSON_HAS_STDSTRING 1\n\n////////////////////////////////////////////////////////////////////////////////\n// Google Test\n\n#ifdef __cplusplus\n\n// gtest indirectly included inttypes.h, without __STDC_CONSTANT_MACROS.\n#ifndef __STDC_CONSTANT_MACROS\n#  define __STDC_CONSTANT_MACROS 1 // required by C++ standard\n#endif\n\n#if defined(__clang__) || defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))\n#if defined(__clang__) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))\n#pragma GCC diagnostic push\n#endif\n#pragma GCC diagnostic ignored \"-Weffc++\"\n#endif\n\n#include \"gtest/gtest.h\"\n\n#if defined(__clang__) || defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))\n#pragma GCC diagnostic pop\n#endif\n\n#ifdef _MSC_VER\n#define _CRTDBG_MAP_ALLOC\n#include <crtdbg.h>\n#pragma warning(disable : 4996) // 'function': was declared deprecated\n#endif\n\n//! Base class for all performance tests\nclass PerfTest : public ::testing::Test {\npublic:\n    PerfTest() : filename_(), json_(), length_(), whitespace_(), whitespace_length_() {}\n\n    virtual void SetUp() {\n        {\n            const char *paths[] = {\n                \"data/sample.json\",\n                \"bin/data/sample.json\",\n                \"../bin/data/sample.json\",\n                \"../../bin/data/sample.json\",\n                \"../../../bin/data/sample.json\"\n            };\n\n            FILE *fp = 0;\n            for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); i++) {\n                fp = fopen(filename_ = paths[i], \"rb\");\n                if (fp)\n                    break;\n            }\n            ASSERT_TRUE(fp != 0);\n\n            fseek(fp, 0, SEEK_END);\n            length_ = (size_t)ftell(fp);\n            fseek(fp, 0, SEEK_SET);\n            json_ = (char*)malloc(length_ + 1);\n            ASSERT_EQ(length_, fread(json_, 1, length_, fp));\n            json_[length_] = '\\0';\n            fclose(fp);\n        }\n\n        // whitespace test\n        {\n            whitespace_length_ = 1024 * 1024;\n            whitespace_ = (char *)malloc(whitespace_length_  + 4);\n            char *p = whitespace_;\n            for (size_t i = 0; i < whitespace_length_; i += 4) {\n                *p++ = ' ';\n                *p++ = '\\n';\n                *p++ = '\\r';\n                *p++ = '\\t';\n            }\n            *p++ = '[';\n            *p++ = '0';\n            *p++ = ']';\n            *p++ = '\\0';\n        }\n\n        // types test\n        {\n            const char *typespaths[] = {\n                \"data/types\",\n                \"bin/types\",\n                \"../bin/types\",\n                \"../../bin/types/\",\n                \"../../../bin/types\"\n            };\n\n            const char* typesfilenames[] = {\n                \"booleans.json\",\n                \"floats.json\",\n                \"guids.json\",\n                \"integers.json\",\n                \"mixed.json\",\n                \"nulls.json\",\n                \"paragraphs.json\"\n            };\n\n            for (size_t j = 0; j < sizeof(typesfilenames) / sizeof(typesfilenames[0]); j++) {\n                types_[j] = 0;\n                for (size_t i = 0; i < sizeof(typespaths) / sizeof(typespaths[0]); i++) {\n                    char filename[256];\n                    sprintf(filename, \"%s/%s\", typespaths[i], typesfilenames[j]);\n                    if (FILE* fp = fopen(filename, \"rb\")) {\n                        fseek(fp, 0, SEEK_END);\n                        typesLength_[j] = (size_t)ftell(fp);\n                        fseek(fp, 0, SEEK_SET);\n                        types_[j] = (char*)malloc(typesLength_[j] + 1);\n                        ASSERT_EQ(typesLength_[j], fread(types_[j], 1, typesLength_[j], fp));\n                        types_[j][typesLength_[j]] = '\\0';\n                        fclose(fp);\n                        break;\n                    }\n                }\n            }\n        }\n    }\n\n    virtual void TearDown() {\n        free(json_);\n        free(whitespace_);\n        json_ = 0;\n        whitespace_ = 0;\n        for (size_t i = 0; i < 7; i++) {\n            free(types_[i]);\n            types_[i] = 0;\n        }\n    }\n\nprivate:\n    PerfTest(const PerfTest&);\n    PerfTest& operator=(const PerfTest&);\n\nprotected:\n    const char* filename_;\n    char *json_;\n    size_t length_;\n    char *whitespace_;\n    size_t whitespace_length_;\n    char *types_[7];\n    size_t typesLength_[7];\n\n    static const size_t kTrialCount = 1000;\n};\n\n#endif // __cplusplus\n\n#endif // PERFTEST_H_\n"
  },
  {
    "path": "ext/rapidjson/test/perftest/platformtest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"perftest.h\"\n\n// This file is for giving the performance characteristics of the platform (compiler/OS/CPU).\n\n#if TEST_PLATFORM\n\n#include <cmath>\n#include <fcntl.h>\n\n// Windows\n#ifdef _WIN32\n#include <windows.h>\n#endif\n\n// UNIX\n#if defined(unix) || defined(__unix__) || defined(__unix)\n#include <unistd.h>\n#ifdef _POSIX_MAPPED_FILES\n#include <sys/mman.h>\n#endif\n#endif\n\nclass Platform : public PerfTest {\npublic:\n    virtual void SetUp() {\n        PerfTest::SetUp();\n\n        // temp buffer for testing\n        temp_ = (char *)malloc(length_ + 1);\n        memcpy(temp_, json_, length_);\n        checkSum_ = CheckSum();\n    }\n\n    char CheckSum() {\n        char c = 0;\n        for (size_t i = 0; i < length_; ++i)\n            c += temp_[i];\n        return c;\n    }\n\n    virtual void TearDown() {\n        PerfTest::TearDown();\n        free(temp_);\n    }\n\nprotected:\n    char *temp_;\n    char checkSum_;\n};\n\nTEST_F(Platform, CheckSum) {\n    for (int i = 0; i < kTrialCount; i++)\n        EXPECT_EQ(checkSum_, CheckSum());\n}\n\nTEST_F(Platform, strlen) {\n    for (int i = 0; i < kTrialCount; i++) {\n        size_t l = strlen(json_);\n        EXPECT_EQ(length_, l);\n    }\n}\n\nTEST_F(Platform, memcmp) {\n    for (int i = 0; i < kTrialCount; i++) {\n        EXPECT_EQ(0, memcmp(temp_, json_, length_));\n    }\n}\n\nTEST_F(Platform, pow) {\n    double sum = 0;\n    for (int i = 0; i < kTrialCount * kTrialCount; i++)\n        sum += pow(10.0, i & 255);\n    EXPECT_GT(sum, 0.0);\n}\n\nTEST_F(Platform, Whitespace_strlen) {\n    for (int i = 0; i < kTrialCount; i++) {\n        size_t l = strlen(whitespace_);\n        EXPECT_GT(l, whitespace_length_);\n    }       \n}\n\nTEST_F(Platform, Whitespace_strspn) {\n    for (int i = 0; i < kTrialCount; i++) {\n        size_t l = strspn(whitespace_, \" \\n\\r\\t\");\n        EXPECT_EQ(whitespace_length_, l);\n    }       \n}\n\nTEST_F(Platform, fread) {\n    for (int i = 0; i < kTrialCount; i++) {\n        FILE *fp = fopen(filename_, \"rb\");\n        ASSERT_EQ(length_, fread(temp_, 1, length_, fp));\n        EXPECT_EQ(checkSum_, CheckSum());\n        fclose(fp);\n    }\n}\n\n#ifdef _MSC_VER\nTEST_F(Platform, read) {\n    for (int i = 0; i < kTrialCount; i++) {\n        int fd = _open(filename_, _O_BINARY | _O_RDONLY);\n        ASSERT_NE(-1, fd);\n        ASSERT_EQ(length_, _read(fd, temp_, length_));\n        EXPECT_EQ(checkSum_, CheckSum());\n        _close(fd);\n    }\n}\n#else\nTEST_F(Platform, read) {\n    for (int i = 0; i < kTrialCount; i++) {\n        int fd = open(filename_, O_RDONLY);\n        ASSERT_NE(-1, fd);\n        ASSERT_EQ(length_, read(fd, temp_, length_));\n        EXPECT_EQ(checkSum_, CheckSum());\n        close(fd);\n    }\n}\n#endif\n\n#ifdef _WIN32\nTEST_F(Platform, MapViewOfFile) {\n    for (int i = 0; i < kTrialCount; i++) {\n        HANDLE file = CreateFile(filename_, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);\n        ASSERT_NE(INVALID_HANDLE_VALUE, file);\n        HANDLE mapObject = CreateFileMapping(file, NULL, PAGE_READONLY, 0, length_, NULL);\n        ASSERT_NE(INVALID_HANDLE_VALUE, mapObject);\n        void *p = MapViewOfFile(mapObject, FILE_MAP_READ, 0, 0, length_);\n        ASSERT_TRUE(p != NULL);\n        EXPECT_EQ(checkSum_, CheckSum());\n        ASSERT_TRUE(UnmapViewOfFile(p) == TRUE);\n        ASSERT_TRUE(CloseHandle(mapObject) == TRUE);\n        ASSERT_TRUE(CloseHandle(file) == TRUE);\n    }\n}\n#endif\n\n#ifdef _POSIX_MAPPED_FILES\nTEST_F(Platform, mmap) {\n    for (int i = 0; i < kTrialCount; i++) {\n        int fd = open(filename_, O_RDONLY);\n        ASSERT_NE(-1, fd);\n        void *p = mmap(NULL, length_, PROT_READ, MAP_PRIVATE, fd, 0);\n        ASSERT_TRUE(p != NULL);\n        EXPECT_EQ(checkSum_, CheckSum());\n        munmap(p, length_);\n        close(fd);\n    }\n}\n#endif\n\n#endif // TEST_PLATFORM\n"
  },
  {
    "path": "ext/rapidjson/test/perftest/rapidjsontest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"perftest.h\"\n\n#if TEST_RAPIDJSON\n\n#include \"rapidjson/rapidjson.h\"\n#include \"rapidjson/document.h\"\n#include \"rapidjson/prettywriter.h\"\n#include \"rapidjson/stringbuffer.h\"\n#include \"rapidjson/filereadstream.h\"\n#include \"rapidjson/encodedstream.h\"\n#include \"rapidjson/memorystream.h\"\n\n#ifdef RAPIDJSON_SSE2\n#define SIMD_SUFFIX(name) name##_SSE2\n#elif defined(RAPIDJSON_SSE42)\n#define SIMD_SUFFIX(name) name##_SSE42\n#else\n#define SIMD_SUFFIX(name) name\n#endif\n\nusing namespace rapidjson;\n\nclass RapidJson : public PerfTest {\npublic:\n    RapidJson() : temp_(), doc_() {}\n\n    virtual void SetUp() {\n        PerfTest::SetUp();\n\n        // temp buffer for insitu parsing.\n        temp_ = (char *)malloc(length_ + 1);\n\n        // Parse as a document\n        EXPECT_FALSE(doc_.Parse(json_).HasParseError());\n\n        for (size_t i = 0; i < 7; i++)\n            EXPECT_FALSE(typesDoc_[i].Parse(types_[i]).HasParseError());\n    }\n\n    virtual void TearDown() {\n        PerfTest::TearDown();\n        free(temp_);\n    }\n\nprivate:\n    RapidJson(const RapidJson&);\n    RapidJson& operator=(const RapidJson&);\n\nprotected:\n    char *temp_;\n    Document doc_;\n    Document typesDoc_[7];\n};\n\nTEST_F(RapidJson, SIMD_SUFFIX(ReaderParseInsitu_DummyHandler)) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        memcpy(temp_, json_, length_ + 1);\n        InsituStringStream s(temp_);\n        BaseReaderHandler<> h;\n        Reader reader;\n        EXPECT_TRUE(reader.Parse<kParseInsituFlag>(s, h));\n    }\n}\n\nTEST_F(RapidJson, SIMD_SUFFIX(ReaderParseInsitu_DummyHandler_ValidateEncoding)) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        memcpy(temp_, json_, length_ + 1);\n        InsituStringStream s(temp_);\n        BaseReaderHandler<> h;\n        Reader reader;\n        EXPECT_TRUE(reader.Parse<kParseInsituFlag | kParseValidateEncodingFlag>(s, h));\n    }\n}\n\nTEST_F(RapidJson, SIMD_SUFFIX(ReaderParse_DummyHandler)) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        StringStream s(json_);\n        BaseReaderHandler<> h;\n        Reader reader;\n        EXPECT_TRUE(reader.Parse(s, h));\n    }\n}\n\n#define TEST_TYPED(index, Name)\\\nTEST_F(RapidJson, SIMD_SUFFIX(ReaderParse_DummyHandler_##Name)) {\\\n    for (size_t i = 0; i < kTrialCount * 10; i++) {\\\n        StringStream s(types_[index]);\\\n        BaseReaderHandler<> h;\\\n        Reader reader;\\\n        EXPECT_TRUE(reader.Parse(s, h));\\\n    }\\\n}\\\nTEST_F(RapidJson, SIMD_SUFFIX(ReaderParseInsitu_DummyHandler_##Name)) {\\\n    for (size_t i = 0; i < kTrialCount * 10; i++) {\\\n        memcpy(temp_, types_[index], typesLength_[index] + 1);\\\n        InsituStringStream s(temp_);\\\n        BaseReaderHandler<> h;\\\n        Reader reader;\\\n        EXPECT_TRUE(reader.Parse<kParseInsituFlag>(s, h));\\\n    }\\\n}\n\nTEST_TYPED(0, Booleans)\nTEST_TYPED(1, Floats)\nTEST_TYPED(2, Guids)\nTEST_TYPED(3, Integers)\nTEST_TYPED(4, Mixed)\nTEST_TYPED(5, Nulls)\nTEST_TYPED(6, Paragraphs)\n\n#undef TEST_TYPED\n\nTEST_F(RapidJson, SIMD_SUFFIX(ReaderParse_DummyHandler_FullPrecision)) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        StringStream s(json_);\n        BaseReaderHandler<> h;\n        Reader reader;\n        EXPECT_TRUE(reader.Parse<kParseFullPrecisionFlag>(s, h));\n    }\n}\n\nTEST_F(RapidJson, SIMD_SUFFIX(ReaderParseIterative_DummyHandler)) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        StringStream s(json_);\n        BaseReaderHandler<> h;\n        Reader reader;\n        EXPECT_TRUE(reader.Parse<kParseIterativeFlag>(s, h));\n    }\n}\n\nTEST_F(RapidJson, SIMD_SUFFIX(ReaderParseIterativeInsitu_DummyHandler)) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        memcpy(temp_, json_, length_ + 1);\n        InsituStringStream s(temp_);\n        BaseReaderHandler<> h;\n        Reader reader;\n        EXPECT_TRUE(reader.Parse<kParseIterativeFlag|kParseInsituFlag>(s, h));\n    }\n}\n\nTEST_F(RapidJson, SIMD_SUFFIX(ReaderParse_DummyHandler_ValidateEncoding)) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        StringStream s(json_);\n        BaseReaderHandler<> h;\n        Reader reader;\n        EXPECT_TRUE(reader.Parse<kParseValidateEncodingFlag>(s, h));\n    }\n}\n\nTEST_F(RapidJson, SIMD_SUFFIX(DocumentParseInsitu_MemoryPoolAllocator)) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        memcpy(temp_, json_, length_ + 1);\n        Document doc;\n        doc.ParseInsitu(temp_);\n        ASSERT_TRUE(doc.IsObject());\n    }\n}\n\nTEST_F(RapidJson, SIMD_SUFFIX(DocumentParseIterativeInsitu_MemoryPoolAllocator)) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        memcpy(temp_, json_, length_ + 1);\n        Document doc;\n        doc.ParseInsitu<kParseIterativeFlag>(temp_);\n        ASSERT_TRUE(doc.IsObject());\n    }\n}\n\nTEST_F(RapidJson, SIMD_SUFFIX(DocumentParse_MemoryPoolAllocator)) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        Document doc;\n        doc.Parse(json_);\n        ASSERT_TRUE(doc.IsObject());\n    }\n}\n\nTEST_F(RapidJson, SIMD_SUFFIX(DocumentParseLength_MemoryPoolAllocator)) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        Document doc;\n        doc.Parse(json_, length_);\n        ASSERT_TRUE(doc.IsObject());\n    }\n}\n\n#if RAPIDJSON_HAS_STDSTRING\nTEST_F(RapidJson, SIMD_SUFFIX(DocumentParseStdString_MemoryPoolAllocator)) {\n    const std::string s(json_, length_);\n    for (size_t i = 0; i < kTrialCount; i++) {\n        Document doc;\n        doc.Parse(s);\n        ASSERT_TRUE(doc.IsObject());\n    }\n}\n#endif\n\nTEST_F(RapidJson, SIMD_SUFFIX(DocumentParseIterative_MemoryPoolAllocator)) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        Document doc;\n        doc.Parse<kParseIterativeFlag>(json_);\n        ASSERT_TRUE(doc.IsObject());\n    }\n}\n\nTEST_F(RapidJson, SIMD_SUFFIX(DocumentParse_CrtAllocator)) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        memcpy(temp_, json_, length_ + 1);\n        GenericDocument<UTF8<>, CrtAllocator> doc;\n        doc.Parse(temp_);\n        ASSERT_TRUE(doc.IsObject());\n    }\n}\n\nTEST_F(RapidJson, SIMD_SUFFIX(DocumentParseEncodedInputStream_MemoryStream)) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        MemoryStream ms(json_, length_);\n        EncodedInputStream<UTF8<>, MemoryStream> is(ms);\n        Document doc;\n        doc.ParseStream<0, UTF8<> >(is);\n        ASSERT_TRUE(doc.IsObject());\n    }\n}\n\nTEST_F(RapidJson, SIMD_SUFFIX(DocumentParseAutoUTFInputStream_MemoryStream)) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        MemoryStream ms(json_, length_);\n        AutoUTFInputStream<unsigned, MemoryStream> is(ms);\n        Document doc;\n        doc.ParseStream<0, AutoUTF<unsigned> >(is);\n        ASSERT_TRUE(doc.IsObject());\n    }\n}\n\ntemplate<typename T>\nsize_t Traverse(const T& value) {\n    size_t count = 1;\n    switch(value.GetType()) {\n        case kObjectType:\n            for (typename T::ConstMemberIterator itr = value.MemberBegin(); itr != value.MemberEnd(); ++itr) {\n                count++;    // name\n                count += Traverse(itr->value);\n            }\n            break;\n\n        case kArrayType:\n            for (typename T::ConstValueIterator itr = value.Begin(); itr != value.End(); ++itr)\n                count += Traverse(*itr);\n            break;\n\n        default:\n            // Do nothing.\n            break;\n    }\n    return count;\n}\n\nTEST_F(RapidJson, DocumentTraverse) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        size_t count = Traverse(doc_);\n        EXPECT_EQ(4339u, count);\n        //if (i == 0)\n        //  std::cout << count << std::endl;\n    }\n}\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(effc++)\n#endif\n\nstruct ValueCounter : public BaseReaderHandler<> {\n    ValueCounter() : count_(1) {}   // root\n\n    bool EndObject(SizeType memberCount) { count_ += memberCount * 2; return true; }\n    bool EndArray(SizeType elementCount) { count_ += elementCount; return true; }\n\n    SizeType count_;\n};\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_POP\n#endif\n\nTEST_F(RapidJson, DocumentAccept) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        ValueCounter counter;\n        doc_.Accept(counter);\n        EXPECT_EQ(4339u, counter.count_);\n    }\n}\n\nstruct NullStream {\n    typedef char Ch;\n\n    NullStream() /*: length_(0)*/ {}\n    void Put(Ch) { /*++length_;*/ }\n    void Flush() {}\n    //size_t length_;\n};\n\nTEST_F(RapidJson, Writer_NullStream) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        NullStream s;\n        Writer<NullStream> writer(s);\n        doc_.Accept(writer);\n        //if (i == 0)\n        //  std::cout << s.length_ << std::endl;\n    }\n}\n\nTEST_F(RapidJson, SIMD_SUFFIX(Writer_StringBuffer)) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        StringBuffer s(0, 1024 * 1024);\n        Writer<StringBuffer> writer(s);\n        doc_.Accept(writer);\n        const char* str = s.GetString();\n        (void)str;\n        //if (i == 0)\n        //  std::cout << strlen(str) << std::endl;\n    }\n}\n\n#define TEST_TYPED(index, Name)\\\nTEST_F(RapidJson, SIMD_SUFFIX(Writer_StringBuffer_##Name)) {\\\n    for (size_t i = 0; i < kTrialCount * 10; i++) {\\\n        StringBuffer s(0, 1024 * 1024);\\\n        Writer<StringBuffer> writer(s);\\\n        typesDoc_[index].Accept(writer);\\\n        const char* str = s.GetString();\\\n        (void)str;\\\n    }\\\n}\n\nTEST_TYPED(0, Booleans)\nTEST_TYPED(1, Floats)\nTEST_TYPED(2, Guids)\nTEST_TYPED(3, Integers)\nTEST_TYPED(4, Mixed)\nTEST_TYPED(5, Nulls)\nTEST_TYPED(6, Paragraphs)\n\n#undef TEST_TYPED\n\nTEST_F(RapidJson, SIMD_SUFFIX(PrettyWriter_StringBuffer)) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        StringBuffer s(0, 2048 * 1024);\n        PrettyWriter<StringBuffer> writer(s);\n        writer.SetIndent(' ', 1);\n        doc_.Accept(writer);\n        const char* str = s.GetString();\n        (void)str;\n        //if (i == 0)\n        //  std::cout << strlen(str) << std::endl;\n    }\n}\n\nTEST_F(RapidJson, internal_Pow10) {\n    double sum = 0;\n    for (size_t i = 0; i < kTrialCount * kTrialCount; i++)\n        sum += internal::Pow10(int(i & 255));\n    EXPECT_GT(sum, 0.0);\n}\n\nTEST_F(RapidJson, SkipWhitespace_Basic) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        rapidjson::StringStream s(whitespace_);\n        while (s.Peek() == ' ' || s.Peek() == '\\n' || s.Peek() == '\\r' || s.Peek() == '\\t')\n            s.Take();\n        ASSERT_EQ('[', s.Peek());\n    }\n}\n\nTEST_F(RapidJson, SIMD_SUFFIX(SkipWhitespace)) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        rapidjson::StringStream s(whitespace_);\n        rapidjson::SkipWhitespace(s);\n        ASSERT_EQ('[', s.Peek());\n    }\n}\n\nTEST_F(RapidJson, SkipWhitespace_strspn) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        const char* s = whitespace_ + std::strspn(whitespace_, \" \\t\\r\\n\");\n        ASSERT_EQ('[', *s);\n    }\n}\n\nTEST_F(RapidJson, UTF8_Validate) {\n    NullStream os;\n\n    for (size_t i = 0; i < kTrialCount; i++) {\n        StringStream is(json_);\n        bool result = true;\n        while (is.Peek() != '\\0')\n            result &= UTF8<>::Validate(is, os);\n        EXPECT_TRUE(result);\n    }\n}\n\nTEST_F(RapidJson, FileReadStream) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        FILE *fp = fopen(filename_, \"rb\");\n        char buffer[65536];\n        FileReadStream s(fp, buffer, sizeof(buffer));\n        while (s.Take() != '\\0')\n            ;\n        fclose(fp);\n    }\n}\n\nTEST_F(RapidJson, SIMD_SUFFIX(ReaderParse_DummyHandler_FileReadStream)) {\n    for (size_t i = 0; i < kTrialCount; i++) {\n        FILE *fp = fopen(filename_, \"rb\");\n        char buffer[65536];\n        FileReadStream s(fp, buffer, sizeof(buffer));\n        BaseReaderHandler<> h;\n        Reader reader;\n        reader.Parse(s, h);\n        fclose(fp);\n    }\n}\n\nTEST_F(RapidJson, StringBuffer) {\n    StringBuffer sb;\n    for (int i = 0; i < 32 * 1024 * 1024; i++)\n        sb.Put(i & 0x7f);\n}\n\n#endif // TEST_RAPIDJSON\n"
  },
  {
    "path": "ext/rapidjson/test/perftest/schematest.cpp",
    "content": "#include \"perftest.h\"\n\n#if TEST_RAPIDJSON\n\n#include \"rapidjson/schema.h\"\n#include <ctime>\n#include <string>\n#include <vector>\n\n#define ARRAY_SIZE(a) sizeof(a) / sizeof(a[0])\n\nusing namespace rapidjson;\n\ntemplate <typename Allocator>\nstatic char* ReadFile(const char* filename, Allocator& allocator) {\n    const char *paths[] = {\n        \"\",\n        \"bin/\",\n        \"../bin/\",\n        \"../../bin/\",\n        \"../../../bin/\"\n    };\n    char buffer[1024];\n    FILE *fp = 0;\n    for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); i++) {\n        sprintf(buffer, \"%s%s\", paths[i], filename);\n        fp = fopen(buffer, \"rb\");\n        if (fp)\n            break;\n    }\n\n    if (!fp)\n        return 0;\n\n    fseek(fp, 0, SEEK_END);\n    size_t length = static_cast<size_t>(ftell(fp));\n    fseek(fp, 0, SEEK_SET);\n    char* json = reinterpret_cast<char*>(allocator.Malloc(length + 1));\n    size_t readLength = fread(json, 1, length, fp);\n    json[readLength] = '\\0';\n    fclose(fp);\n    return json;\n}\n\nclass Schema : public PerfTest {\npublic:\n    Schema() {}\n\n    virtual void SetUp() {\n        PerfTest::SetUp();\n\n        const char* filenames[] = {\n            \"additionalItems.json\",\n            \"additionalProperties.json\",\n            \"allOf.json\",\n            \"anyOf.json\",\n            \"default.json\",\n            \"definitions.json\",\n            \"dependencies.json\",\n            \"enum.json\",\n            \"items.json\",\n            \"maximum.json\",\n            \"maxItems.json\",\n            \"maxLength.json\",\n            \"maxProperties.json\",\n            \"minimum.json\",\n            \"minItems.json\",\n            \"minLength.json\",\n            \"minProperties.json\",\n            \"multipleOf.json\",\n            \"not.json\",\n            \"oneOf.json\",\n            \"pattern.json\",\n            \"patternProperties.json\",\n            \"properties.json\",\n            \"ref.json\",\n            \"refRemote.json\",\n            \"required.json\",\n            \"type.json\",\n            \"uniqueItems.json\"\n        };\n\n        char jsonBuffer[65536];\n        MemoryPoolAllocator<> jsonAllocator(jsonBuffer, sizeof(jsonBuffer));\n\n        for (size_t i = 0; i < ARRAY_SIZE(filenames); i++) {\n            char filename[FILENAME_MAX];\n            sprintf(filename, \"jsonschema/tests/draft4/%s\", filenames[i]);\n            char* json = ReadFile(filename, jsonAllocator);\n            if (!json) {\n                printf(\"json test suite file %s not found\", filename);\n                return;\n            }\n\n            Document d;\n            d.Parse(json);\n            if (d.HasParseError()) {\n                printf(\"json test suite file %s has parse error\", filename);\n                return;\n            }\n\n            for (Value::ConstValueIterator schemaItr = d.Begin(); schemaItr != d.End(); ++schemaItr) {\n                std::string schemaDescription = (*schemaItr)[\"description\"].GetString();\n                if (IsExcludeTestSuite(schemaDescription))\n                    continue;\n\n                TestSuite* ts = new TestSuite;\n                ts->schema = new SchemaDocument((*schemaItr)[\"schema\"]);\n\n                const Value& tests = (*schemaItr)[\"tests\"];\n                for (Value::ConstValueIterator testItr = tests.Begin(); testItr != tests.End(); ++testItr) {\n                    if (IsExcludeTest(schemaDescription + \", \" + (*testItr)[\"description\"].GetString()))\n                        continue;\n\n                    Document* d2 = new Document;\n                    d2->CopyFrom((*testItr)[\"data\"], d2->GetAllocator());\n                    ts->tests.push_back(d2);\n                }\n                testSuites.push_back(ts);\n            }\n        }\n    }\n\n    virtual void TearDown() {\n        PerfTest::TearDown();\n        for (TestSuiteList::const_iterator itr = testSuites.begin(); itr != testSuites.end(); ++itr)\n            delete *itr;\n        testSuites.clear();\n    }\n\nprivate:\n    // Using the same exclusion in https://github.com/json-schema/JSON-Schema-Test-Suite\n    static bool IsExcludeTestSuite(const std::string& description) {\n        const char* excludeTestSuites[] = {\n            //lost failing these tests\n            \"remote ref\",\n            \"remote ref, containing refs itself\",\n            \"fragment within remote ref\",\n            \"ref within remote ref\",\n            \"change resolution scope\",\n            // these below were added to get jsck in the benchmarks)\n            \"uniqueItems validation\",\n            \"valid definition\",\n            \"invalid definition\"\n        };\n\n        for (size_t i = 0; i < ARRAY_SIZE(excludeTestSuites); i++)\n            if (excludeTestSuites[i] == description)\n                return true;\n        return false;\n    }\n\n    // Using the same exclusion in https://github.com/json-schema/JSON-Schema-Test-Suite\n    static bool IsExcludeTest(const std::string& description) {\n        const char* excludeTests[] = {\n            //lots of validators fail these\n            \"invalid definition, invalid definition schema\",\n            \"maxLength validation, two supplementary Unicode code points is long enough\",\n            \"minLength validation, one supplementary Unicode code point is not long enough\",\n            //this is to get tv4 in the benchmarks\n            \"heterogeneous enum validation, something else is invalid\"\n        };\n\n        for (size_t i = 0; i < ARRAY_SIZE(excludeTests); i++)\n            if (excludeTests[i] == description)\n                return true;\n        return false;\n    }\n\n    Schema(const Schema&);\n    Schema& operator=(const Schema&);\n\nprotected:\n    typedef std::vector<Document*> DocumentList;\n\n    struct TestSuite {\n        TestSuite() : schema() {}\n        ~TestSuite() {\n            delete schema;\n            for (DocumentList::iterator itr = tests.begin(); itr != tests.end(); ++itr)\n                delete *itr;\n        }\n        SchemaDocument* schema;\n        DocumentList tests;\n    };\n\n    typedef std::vector<TestSuite* > TestSuiteList;\n    TestSuiteList testSuites;\n};\n\nTEST_F(Schema, TestSuite) {\n    char validatorBuffer[65536];\n    MemoryPoolAllocator<> validatorAllocator(validatorBuffer, sizeof(validatorBuffer));\n\n    const int trialCount = 100000;\n    int testCount = 0;\n    clock_t start = clock();\n    for (int i = 0; i < trialCount; i++) {\n        for (TestSuiteList::const_iterator itr = testSuites.begin(); itr != testSuites.end(); ++itr) {\n            const TestSuite& ts = **itr;\n            GenericSchemaValidator<SchemaDocument, BaseReaderHandler<UTF8<> >, MemoryPoolAllocator<> >  validator(*ts.schema, &validatorAllocator);\n            for (DocumentList::const_iterator testItr = ts.tests.begin(); testItr != ts.tests.end(); ++testItr) {\n                validator.Reset();\n                (*testItr)->Accept(validator);\n                testCount++;\n            }\n            validatorAllocator.Clear();\n        }\n    }\n    clock_t end = clock();\n    double duration = double(end - start) / CLOCKS_PER_SEC;\n    printf(\"%d trials in %f s -> %f trials per sec\\n\", trialCount, duration, trialCount / duration);\n    printf(\"%d tests per trial\\n\", testCount / trialCount);\n}\n\n#endif\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/CMakeLists.txt",
    "content": "include(CheckCXXCompilerFlag)\n\nset(UNITTEST_SOURCES\n\tallocatorstest.cpp\n    bigintegertest.cpp\n    documenttest.cpp\n    dtoatest.cpp\n    encodedstreamtest.cpp\n    encodingstest.cpp\n    fwdtest.cpp\n    filestreamtest.cpp\n    itoatest.cpp\n    istreamwrappertest.cpp\n    jsoncheckertest.cpp\n    namespacetest.cpp\n    pointertest.cpp\n    prettywritertest.cpp\n    ostreamwrappertest.cpp\n    readertest.cpp\n    regextest.cpp\n\tschematest.cpp\n\tsimdtest.cpp\n    strfunctest.cpp\n    stringbuffertest.cpp\n    strtodtest.cpp\n    unittest.cpp\n    valuetest.cpp\n    writertest.cpp)\n\nfind_program(CCACHE_FOUND ccache)\nif(CCACHE_FOUND)\n    set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)\n    set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)\n    if (CMAKE_CXX_COMPILER_ID MATCHES \"Clang\")\n        set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Qunused-arguments -fcolor-diagnostics\")\n\t\tendif()\nendif(CCACHE_FOUND)\n\nif (\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"GNU\")\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Weffc++ -Wswitch-default -Wfloat-equal\")\nelseif (CMAKE_CXX_COMPILER_ID MATCHES \"Clang\")\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Weffc++ -Wswitch-default -Wfloat-equal -Wimplicit-fallthrough -Weverything\")\n    # If the user is running a newer version of Clang that includes the\n    # -Wdouble-promotion, we will ignore that warning.\n    if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.7)\n        CHECK_CXX_COMPILER_FLAG(\"-Wno-double-promotion\" HAS_NO_DOUBLE_PROMOTION)\n        if (HAS_NO_DOUBLE_PROMOTION)\n            set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-double-promotion\")\n        endif()\n    endif()\nelseif (\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"MSVC\")\n    # Force to always compile with /W4\n    if(CMAKE_CXX_FLAGS MATCHES \"/W[0-4]\")\n        string(REGEX REPLACE \"/W[0-4]\" \"/W4\" CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS}\")\n    else()\n        set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} /W4\")\n    endif()\n\n    # Force to always compile with /WX\n    if(CMAKE_CXX_FLAGS MATCHES \"/WX-\")\n        string(REGEX REPLACE \"/WX-\" \"/WX\" CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS}\")\n    else()\n        set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} /WX\")\n    endif()\nendif()\n\nset(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -DRAPIDJSON_HAS_STDSTRING=1\")\n\nadd_library(namespacetest STATIC namespacetest.cpp)\n\nadd_executable(unittest ${UNITTEST_SOURCES})\ntarget_link_libraries(unittest ${TEST_LIBRARIES} namespacetest)\n\nadd_dependencies(tests unittest)\n\nadd_test(NAME unittest\n    COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittest\n    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)\n\nif(NOT MSVC)\n    # Not running SIMD.* unit test cases for Valgrind\n    add_test(NAME valgrind_unittest\n        COMMAND valgrind --leak-check=full --error-exitcode=1 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/unittest --gtest_filter=-SIMD.*\n        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)\n\n    if(CMAKE_BUILD_TYPE STREQUAL \"Debug\")\n        add_test(NAME symbol_check\n        COMMAND sh -c \"objdump -t -C libnamespacetest.a | grep rapidjson ; test $? -ne 0\"\n        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})\n    endif(CMAKE_BUILD_TYPE STREQUAL \"Debug\")\n\nendif(NOT MSVC)\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/allocatorstest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n\n#include \"rapidjson/allocators.h\"\n\nusing namespace rapidjson;\n\ntemplate <typename Allocator>\nvoid TestAllocator(Allocator& a) {\n    EXPECT_TRUE(a.Malloc(0) == 0);\n\n    uint8_t* p = static_cast<uint8_t*>(a.Malloc(100));\n    EXPECT_TRUE(p != 0);\n    for (size_t i = 0; i < 100; i++)\n        p[i] = static_cast<uint8_t>(i);\n\n    // Expand\n    uint8_t* q = static_cast<uint8_t*>(a.Realloc(p, 100, 200));\n    EXPECT_TRUE(q != 0);\n    for (size_t i = 0; i < 100; i++)\n        EXPECT_EQ(i, q[i]);\n    for (size_t i = 100; i < 200; i++)\n        q[i] = static_cast<uint8_t>(i);\n\n    // Shrink\n    uint8_t *r = static_cast<uint8_t*>(a.Realloc(q, 200, 150));\n    EXPECT_TRUE(r != 0);\n    for (size_t i = 0; i < 150; i++)\n        EXPECT_EQ(i, r[i]);\n\n    Allocator::Free(r);\n\n    // Realloc to zero size\n    EXPECT_TRUE(a.Realloc(a.Malloc(1), 1, 0) == 0);\n}\n\nTEST(Allocator, CrtAllocator) {\n    CrtAllocator a;\n    TestAllocator(a);\n}\n\nTEST(Allocator, MemoryPoolAllocator) {\n    MemoryPoolAllocator<> a;\n    TestAllocator(a);\n\n    for (size_t i = 1; i < 1000; i++) {\n        EXPECT_TRUE(a.Malloc(i) != 0);\n        EXPECT_LE(a.Size(), a.Capacity());\n    }\n}\n\nTEST(Allocator, Alignment) {\n#if RAPIDJSON_64BIT == 1\n    EXPECT_EQ(RAPIDJSON_UINT64_C2(0x00000000, 0x00000000), RAPIDJSON_ALIGN(0));\n    for (uint64_t i = 1; i < 8; i++) {\n        EXPECT_EQ(RAPIDJSON_UINT64_C2(0x00000000, 0x00000008), RAPIDJSON_ALIGN(i));\n        EXPECT_EQ(RAPIDJSON_UINT64_C2(0x00000000, 0x00000010), RAPIDJSON_ALIGN(RAPIDJSON_UINT64_C2(0x00000000, 0x00000008) + i));\n        EXPECT_EQ(RAPIDJSON_UINT64_C2(0x00000001, 0x00000000), RAPIDJSON_ALIGN(RAPIDJSON_UINT64_C2(0x00000000, 0xFFFFFFF8) + i));\n        EXPECT_EQ(RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0xFFFFFFF8), RAPIDJSON_ALIGN(RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0xFFFFFFF0) + i));\n    }\n#else\n    EXPECT_EQ(0u, RAPIDJSON_ALIGN(0u));\n    for (uint32_t i = 1; i < 4; i++) {\n        EXPECT_EQ(4u, RAPIDJSON_ALIGN(i));\n        EXPECT_EQ(8u, RAPIDJSON_ALIGN(4u + i));\n        EXPECT_EQ(0xFFFFFFF8u, RAPIDJSON_ALIGN(0xFFFFFFF4u + i));\n        EXPECT_EQ(0xFFFFFFFCu, RAPIDJSON_ALIGN(0xFFFFFFF8u + i));\n    }\n#endif\n}\n\nTEST(Allocator, Issue399) {\n    MemoryPoolAllocator<> a;\n    void* p = a.Malloc(100);\n    void* q = a.Realloc(p, 100, 200);\n    EXPECT_EQ(p, q);\n\n    // exhuasive testing\n    for (size_t j = 1; j < 32; j++) {\n        a.Clear();\n        a.Malloc(j); // some unaligned size\n        p = a.Malloc(1);\n        for (size_t i = 1; i < 1024; i++) {\n            q = a.Realloc(p, i, i + 1);\n            EXPECT_EQ(p, q);\n            p = q;\n        }\n    }\n}\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/bigintegertest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n\n#include \"rapidjson/internal/biginteger.h\"\n\nusing namespace rapidjson::internal;\n\n#define BIGINTEGER_LITERAL(s) BigInteger(s, sizeof(s) - 1)\n\nstatic const BigInteger kZero(0);\nstatic const BigInteger kOne(1);\nstatic const BigInteger kUint64Max = BIGINTEGER_LITERAL(\"18446744073709551615\");\nstatic const BigInteger kTwo64 = BIGINTEGER_LITERAL(\"18446744073709551616\");\n\nTEST(BigInteger, Constructor) {\n    EXPECT_TRUE(kZero.IsZero());\n    EXPECT_TRUE(kZero == kZero);\n    EXPECT_TRUE(kZero == BIGINTEGER_LITERAL(\"0\"));\n    EXPECT_TRUE(kZero == BIGINTEGER_LITERAL(\"00\"));\n\n    const BigInteger a(123);\n    EXPECT_TRUE(a == a);\n    EXPECT_TRUE(a == BIGINTEGER_LITERAL(\"123\"));\n    EXPECT_TRUE(a == BIGINTEGER_LITERAL(\"0123\"));\n\n    EXPECT_EQ(2u, kTwo64.GetCount());\n    EXPECT_EQ(0u, kTwo64.GetDigit(0));\n    EXPECT_EQ(1u, kTwo64.GetDigit(1));\n}\n\nTEST(BigInteger, AddUint64) {\n    BigInteger a = kZero;\n    a += 0u;\n    EXPECT_TRUE(kZero == a);\n\n    a += 1u;\n    EXPECT_TRUE(kOne == a);\n\n    a += 1u;\n    EXPECT_TRUE(BigInteger(2) == a);\n\n    EXPECT_TRUE(BigInteger(RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0xFFFFFFFF)) == kUint64Max);\n    BigInteger b = kUint64Max;\n    b += 1u;\n    EXPECT_TRUE(kTwo64 == b);\n    b += RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0xFFFFFFFF);\n    EXPECT_TRUE(BIGINTEGER_LITERAL(\"36893488147419103231\") == b);\n}\n\nTEST(BigInteger, MultiplyUint64) {\n    BigInteger a = kZero;\n    a *= static_cast <uint64_t>(0);\n    EXPECT_TRUE(kZero == a);\n    a *= static_cast <uint64_t>(123);\n    EXPECT_TRUE(kZero == a);\n\n    BigInteger b = kOne;\n    b *= static_cast<uint64_t>(1);\n    EXPECT_TRUE(kOne == b);\n    b *= static_cast<uint64_t>(0);\n    EXPECT_TRUE(kZero == b);\n\n    BigInteger c(123);\n    c *= static_cast<uint64_t>(456u);\n    EXPECT_TRUE(BigInteger(123u * 456u) == c);\n    c *= RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0xFFFFFFFF);\n    EXPECT_TRUE(BIGINTEGER_LITERAL(\"1034640981606221330982120\") == c);\n    c *= RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0xFFFFFFFF);\n    EXPECT_TRUE(BIGINTEGER_LITERAL(\"19085757395861596536664473018420572782123800\") == c);\n}\n\nTEST(BigInteger, MultiplyUint32) {\n    BigInteger a = kZero;\n    a *= static_cast <uint32_t>(0);\n    EXPECT_TRUE(kZero == a);\n    a *= static_cast <uint32_t>(123);\n    EXPECT_TRUE(kZero == a);\n\n    BigInteger b = kOne;\n    b *= static_cast<uint32_t>(1);\n    EXPECT_TRUE(kOne == b);\n    b *= static_cast<uint32_t>(0);\n    EXPECT_TRUE(kZero == b);\n\n    BigInteger c(123);\n    c *= static_cast<uint32_t>(456u);\n    EXPECT_TRUE(BigInteger(123u * 456u) == c);\n    c *= 0xFFFFFFFFu;\n    EXPECT_TRUE(BIGINTEGER_LITERAL(\"240896125641960\") == c);\n    c *= 0xFFFFFFFFu;\n    EXPECT_TRUE(BIGINTEGER_LITERAL(\"1034640981124429079698200\") == c);\n}\n\nTEST(BigInteger, LeftShift) {\n    BigInteger a = kZero;\n    a <<= 1;\n    EXPECT_TRUE(kZero == a);\n    a <<= 64;\n    EXPECT_TRUE(kZero == a);\n\n    a = BigInteger(123);\n    a <<= 0;\n    EXPECT_TRUE(BigInteger(123) == a);\n    a <<= 1;\n    EXPECT_TRUE(BigInteger(246) == a);\n    a <<= 64;\n    EXPECT_TRUE(BIGINTEGER_LITERAL(\"4537899042132549697536\") == a);\n    a <<= 99;\n    EXPECT_TRUE(BIGINTEGER_LITERAL(\"2876235222267216943024851750785644982682875244576768\") == a);\n}\n\nTEST(BigInteger, Compare) {\n    EXPECT_EQ(0, kZero.Compare(kZero));\n    EXPECT_EQ(1, kOne.Compare(kZero));\n    EXPECT_EQ(-1, kZero.Compare(kOne));\n    EXPECT_EQ(0, kUint64Max.Compare(kUint64Max));\n    EXPECT_EQ(0, kTwo64.Compare(kTwo64));\n    EXPECT_EQ(-1, kUint64Max.Compare(kTwo64));\n    EXPECT_EQ(1, kTwo64.Compare(kUint64Max));\n}\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/documenttest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n#include \"rapidjson/document.h\"\n#include \"rapidjson/writer.h\"\n#include \"rapidjson/filereadstream.h\"\n#include \"rapidjson/encodedstream.h\"\n#include \"rapidjson/stringbuffer.h\"\n#include <sstream>\n#include <algorithm>\n\n#ifdef __clang__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(c++98-compat)\nRAPIDJSON_DIAG_OFF(missing-variable-declarations)\n#endif\n\nusing namespace rapidjson;\n\ntemplate <typename DocumentType>\nvoid ParseCheck(DocumentType& doc) {\n    typedef typename DocumentType::ValueType ValueType;\n\n    EXPECT_FALSE(doc.HasParseError());\n    if (doc.HasParseError())\n        printf(\"Error: %d at %zu\\n\", static_cast<int>(doc.GetParseError()), doc.GetErrorOffset());\n    EXPECT_TRUE(static_cast<ParseResult>(doc));\n\n    EXPECT_TRUE(doc.IsObject());\n\n    EXPECT_TRUE(doc.HasMember(\"hello\"));\n    const ValueType& hello = doc[\"hello\"];\n    EXPECT_TRUE(hello.IsString());\n    EXPECT_STREQ(\"world\", hello.GetString());\n\n    EXPECT_TRUE(doc.HasMember(\"t\"));\n    const ValueType& t = doc[\"t\"];\n    EXPECT_TRUE(t.IsTrue());\n\n    EXPECT_TRUE(doc.HasMember(\"f\"));\n    const ValueType& f = doc[\"f\"];\n    EXPECT_TRUE(f.IsFalse());\n\n    EXPECT_TRUE(doc.HasMember(\"n\"));\n    const ValueType& n = doc[\"n\"];\n    EXPECT_TRUE(n.IsNull());\n\n    EXPECT_TRUE(doc.HasMember(\"i\"));\n    const ValueType& i = doc[\"i\"];\n    EXPECT_TRUE(i.IsNumber());\n    EXPECT_EQ(123, i.GetInt());\n\n    EXPECT_TRUE(doc.HasMember(\"pi\"));\n    const ValueType& pi = doc[\"pi\"];\n    EXPECT_TRUE(pi.IsNumber());\n    EXPECT_DOUBLE_EQ(3.1416, pi.GetDouble());\n\n    EXPECT_TRUE(doc.HasMember(\"a\"));\n    const ValueType& a = doc[\"a\"];\n    EXPECT_TRUE(a.IsArray());\n    EXPECT_EQ(4u, a.Size());\n    for (SizeType j = 0; j < 4; j++)\n        EXPECT_EQ(j + 1, a[j].GetUint());\n}\n\ntemplate <typename Allocator, typename StackAllocator>\nvoid ParseTest() {\n    typedef GenericDocument<UTF8<>, Allocator, StackAllocator> DocumentType;\n    DocumentType doc;\n\n    const char* json = \" { \\\"hello\\\" : \\\"world\\\", \\\"t\\\" : true , \\\"f\\\" : false, \\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3, 4] } \";\n\n    doc.Parse(json);\n    ParseCheck(doc);\n\n    doc.SetNull();\n    StringStream s(json);\n    doc.template ParseStream<0>(s);\n    ParseCheck(doc);\n\n    doc.SetNull();\n    char *buffer = strdup(json);\n    doc.ParseInsitu(buffer);\n    ParseCheck(doc);\n    free(buffer);\n\n    // Parse(const Ch*, size_t)\n    size_t length = strlen(json);\n    buffer = reinterpret_cast<char*>(malloc(length * 2));\n    memcpy(buffer, json, length);\n    memset(buffer + length, 'X', length);\n#if RAPIDJSON_HAS_STDSTRING\n    std::string s2(buffer, length); // backup buffer\n#endif\n    doc.SetNull();\n    doc.Parse(buffer, length);\n    free(buffer);\n    ParseCheck(doc);\n\n#if RAPIDJSON_HAS_STDSTRING\n    // Parse(std::string)\n    doc.SetNull();\n    doc.Parse(s2);\n    ParseCheck(doc);\n#endif\n}\n\nTEST(Document, Parse) {\n    ParseTest<MemoryPoolAllocator<>, CrtAllocator>();\n    ParseTest<MemoryPoolAllocator<>, MemoryPoolAllocator<> >();\n    ParseTest<CrtAllocator, MemoryPoolAllocator<> >();\n    ParseTest<CrtAllocator, CrtAllocator>();\n}\n\nTEST(Document, UnchangedOnParseError) {\n    Document doc;\n    doc.SetArray().PushBack(0, doc.GetAllocator());\n\n    ParseResult err = doc.Parse(\"{]\");\n    EXPECT_TRUE(doc.HasParseError());\n    EXPECT_EQ(err.Code(), doc.GetParseError());\n    EXPECT_EQ(err.Offset(), doc.GetErrorOffset());\n    EXPECT_TRUE(doc.IsArray());\n    EXPECT_EQ(doc.Size(), 1u);\n\n    err = doc.Parse(\"{}\");\n    EXPECT_FALSE(doc.HasParseError());\n    EXPECT_FALSE(err.IsError());\n    EXPECT_EQ(err.Code(), doc.GetParseError());\n    EXPECT_EQ(err.Offset(), doc.GetErrorOffset());\n    EXPECT_TRUE(doc.IsObject());\n    EXPECT_EQ(doc.MemberCount(), 0u);\n}\n\nstatic FILE* OpenEncodedFile(const char* filename) {\n    const char *paths[] = {\n        \"encodings\",\n        \"bin/encodings\",\n        \"../bin/encodings\",\n        \"../../bin/encodings\",\n        \"../../../bin/encodings\"\n    };\n    char buffer[1024];\n    for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); i++) {\n        sprintf(buffer, \"%s/%s\", paths[i], filename);\n        FILE *fp = fopen(buffer, \"rb\");\n        if (fp)\n            return fp;\n    }\n    return 0;\n}\n\nTEST(Document, Parse_Encoding) {\n    const char* json = \" { \\\"hello\\\" : \\\"world\\\", \\\"t\\\" : true , \\\"f\\\" : false, \\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3, 4] } \";\n\n    typedef GenericDocument<UTF16<> > DocumentType;\n    DocumentType doc;\n    \n    // Parse<unsigned, SourceEncoding>(const SourceEncoding::Ch*)\n    // doc.Parse<kParseDefaultFlags, UTF8<> >(json);\n    // EXPECT_FALSE(doc.HasParseError());\n    // EXPECT_EQ(0, StrCmp(doc[L\"hello\"].GetString(), L\"world\"));\n\n    // Parse<unsigned, SourceEncoding>(const SourceEncoding::Ch*, size_t)\n    size_t length = strlen(json);\n    char* buffer = reinterpret_cast<char*>(malloc(length * 2));\n    memcpy(buffer, json, length);\n    memset(buffer + length, 'X', length);\n#if RAPIDJSON_HAS_STDSTRING\n    std::string s2(buffer, length); // backup buffer\n#endif\n    doc.SetNull();\n    doc.Parse<kParseDefaultFlags, UTF8<> >(buffer, length);\n    free(buffer);\n    EXPECT_FALSE(doc.HasParseError());\n    if (doc.HasParseError())\n        printf(\"Error: %d at %zu\\n\", static_cast<int>(doc.GetParseError()), doc.GetErrorOffset());\n    EXPECT_EQ(0, StrCmp(doc[L\"hello\"].GetString(), L\"world\"));\n\n#if RAPIDJSON_HAS_STDSTRING\n    // Parse<unsigned, SourceEncoding>(std::string)\n    doc.SetNull();\n\n#if defined(_MSC_VER) && _MSC_VER < 1800\n    doc.Parse<kParseDefaultFlags, UTF8<> >(s2.c_str()); // VS2010 or below cannot handle templated function overloading. Use const char* instead.\n#else\n    doc.Parse<kParseDefaultFlags, UTF8<> >(s2);\n#endif\n    EXPECT_FALSE(doc.HasParseError());\n    EXPECT_EQ(0, StrCmp(doc[L\"hello\"].GetString(), L\"world\"));\n#endif\n}\n\nTEST(Document, ParseStream_EncodedInputStream) {\n    // UTF8 -> UTF16\n    FILE* fp = OpenEncodedFile(\"utf8.json\");\n    char buffer[256];\n    FileReadStream bis(fp, buffer, sizeof(buffer));\n    EncodedInputStream<UTF8<>, FileReadStream> eis(bis);\n\n    GenericDocument<UTF16<> > d;\n    d.ParseStream<0, UTF8<> >(eis);\n    EXPECT_FALSE(d.HasParseError());\n\n    fclose(fp);\n\n    wchar_t expected[] = L\"I can eat glass and it doesn't hurt me.\";\n    GenericValue<UTF16<> >& v = d[L\"en\"];\n    EXPECT_TRUE(v.IsString());\n    EXPECT_EQ(sizeof(expected) / sizeof(wchar_t) - 1, v.GetStringLength());\n    EXPECT_EQ(0, StrCmp(expected, v.GetString()));\n\n    // UTF16 -> UTF8 in memory\n    StringBuffer bos;\n    typedef EncodedOutputStream<UTF8<>, StringBuffer> OutputStream;\n    OutputStream eos(bos, false);   // Not writing BOM\n    {\n        Writer<OutputStream, UTF16<>, UTF8<> > writer(eos);\n        d.Accept(writer);\n    }\n\n    // Condense the original file and compare.\n    fp = OpenEncodedFile(\"utf8.json\");\n    FileReadStream is(fp, buffer, sizeof(buffer));\n    Reader reader;\n    StringBuffer bos2;\n    Writer<StringBuffer> writer2(bos2);\n    reader.Parse(is, writer2);\n    fclose(fp);\n\n    EXPECT_EQ(bos.GetSize(), bos2.GetSize());\n    EXPECT_EQ(0, memcmp(bos.GetString(), bos2.GetString(), bos2.GetSize()));\n}\n\nTEST(Document, ParseStream_AutoUTFInputStream) {\n    // Any -> UTF8\n    FILE* fp = OpenEncodedFile(\"utf32be.json\");\n    char buffer[256];\n    FileReadStream bis(fp, buffer, sizeof(buffer));\n    AutoUTFInputStream<unsigned, FileReadStream> eis(bis);\n\n    Document d;\n    d.ParseStream<0, AutoUTF<unsigned> >(eis);\n    EXPECT_FALSE(d.HasParseError());\n\n    fclose(fp);\n\n    char expected[] = \"I can eat glass and it doesn't hurt me.\";\n    Value& v = d[\"en\"];\n    EXPECT_TRUE(v.IsString());\n    EXPECT_EQ(sizeof(expected) - 1, v.GetStringLength());\n    EXPECT_EQ(0, StrCmp(expected, v.GetString()));\n\n    // UTF8 -> UTF8 in memory\n    StringBuffer bos;\n    Writer<StringBuffer> writer(bos);\n    d.Accept(writer);\n\n    // Condense the original file and compare.\n    fp = OpenEncodedFile(\"utf8.json\");\n    FileReadStream is(fp, buffer, sizeof(buffer));\n    Reader reader;\n    StringBuffer bos2;\n    Writer<StringBuffer> writer2(bos2);\n    reader.Parse(is, writer2);\n    fclose(fp);\n\n    EXPECT_EQ(bos.GetSize(), bos2.GetSize());\n    EXPECT_EQ(0, memcmp(bos.GetString(), bos2.GetString(), bos2.GetSize()));\n}\n\nTEST(Document, Swap) {\n    Document d1;\n    Document::AllocatorType& a = d1.GetAllocator();\n\n    d1.SetArray().PushBack(1, a).PushBack(2, a);\n\n    Value o;\n    o.SetObject().AddMember(\"a\", 1, a);\n\n    // Swap between Document and Value\n    // d1.Swap(o); // doesn't compile\n    o.Swap(d1);\n    EXPECT_TRUE(d1.IsObject());\n    EXPECT_TRUE(o.IsArray());\n\n    // Swap between Document and Document\n    Document d2;\n    d2.SetArray().PushBack(3, a);\n    d1.Swap(d2);\n    EXPECT_TRUE(d1.IsArray());\n    EXPECT_TRUE(d2.IsObject());\n    EXPECT_EQ(&d2.GetAllocator(), &a);\n\n    // reset value\n    Value().Swap(d1);\n    EXPECT_TRUE(d1.IsNull());\n\n    // reset document, including allocator\n    Document().Swap(d2);\n    EXPECT_TRUE(d2.IsNull());\n    EXPECT_NE(&d2.GetAllocator(), &a);\n\n    // testing std::swap compatibility\n    d1.SetBool(true);\n    using std::swap;\n    swap(d1, d2);\n    EXPECT_TRUE(d1.IsNull());\n    EXPECT_TRUE(d2.IsTrue());\n\n    swap(o, d2);\n    EXPECT_TRUE(o.IsTrue());\n    EXPECT_TRUE(d2.IsArray());\n}\n\n\n// This should be slow due to assignment in inner-loop.\nstruct OutputStringStream : public std::ostringstream {\n    typedef char Ch;\n\n    virtual ~OutputStringStream();\n\n    void Put(char c) {\n        put(c);\n    }\n    void Flush() {}\n};\n\nOutputStringStream::~OutputStringStream() {}\n\nTEST(Document, AcceptWriter) {\n    Document doc;\n    doc.Parse(\" { \\\"hello\\\" : \\\"world\\\", \\\"t\\\" : true , \\\"f\\\" : false, \\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3, 4] } \");\n\n    OutputStringStream os;\n    Writer<OutputStringStream> writer(os);\n    doc.Accept(writer);\n\n    EXPECT_EQ(\"{\\\"hello\\\":\\\"world\\\",\\\"t\\\":true,\\\"f\\\":false,\\\"n\\\":null,\\\"i\\\":123,\\\"pi\\\":3.1416,\\\"a\\\":[1,2,3,4]}\", os.str());\n}\n\nTEST(Document, UserBuffer) {\n    typedef GenericDocument<UTF8<>, MemoryPoolAllocator<>, MemoryPoolAllocator<> > DocumentType;\n    char valueBuffer[4096];\n    char parseBuffer[1024];\n    MemoryPoolAllocator<> valueAllocator(valueBuffer, sizeof(valueBuffer));\n    MemoryPoolAllocator<> parseAllocator(parseBuffer, sizeof(parseBuffer));\n    DocumentType doc(&valueAllocator, sizeof(parseBuffer) / 2, &parseAllocator);\n    doc.Parse(\" { \\\"hello\\\" : \\\"world\\\", \\\"t\\\" : true , \\\"f\\\" : false, \\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3, 4] } \");\n    EXPECT_FALSE(doc.HasParseError());\n    EXPECT_LE(valueAllocator.Size(), sizeof(valueBuffer));\n    EXPECT_LE(parseAllocator.Size(), sizeof(parseBuffer));\n\n    // Cover MemoryPoolAllocator::Capacity()\n    EXPECT_LE(valueAllocator.Size(), valueAllocator.Capacity());\n    EXPECT_LE(parseAllocator.Size(), parseAllocator.Capacity());\n}\n\n// Issue 226: Value of string type should not point to NULL\nTEST(Document, AssertAcceptInvalidNameType) {\n    Document doc;\n    doc.SetObject();\n    doc.AddMember(\"a\", 0, doc.GetAllocator());\n    doc.FindMember(\"a\")->name.SetNull(); // Change name to non-string type.\n\n    OutputStringStream os;\n    Writer<OutputStringStream> writer(os);\n    ASSERT_THROW(doc.Accept(writer), AssertException);\n}\n\n// Issue 44:    SetStringRaw doesn't work with wchar_t\nTEST(Document, UTF16_Document) {\n    GenericDocument< UTF16<> > json;\n    json.Parse<kParseValidateEncodingFlag>(L\"[{\\\"created_at\\\":\\\"Wed Oct 30 17:13:20 +0000 2012\\\"}]\");\n\n    ASSERT_TRUE(json.IsArray());\n    GenericValue< UTF16<> >& v = json[0];\n    ASSERT_TRUE(v.IsObject());\n\n    GenericValue< UTF16<> >& s = v[L\"created_at\"];\n    ASSERT_TRUE(s.IsString());\n\n    EXPECT_EQ(0, memcmp(L\"Wed Oct 30 17:13:20 +0000 2012\", s.GetString(), (s.GetStringLength() + 1) * sizeof(wchar_t)));\n}\n\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\n\n#if 0 // Many old compiler does not support these. Turn it off temporaily.\n\n#include <type_traits>\n\nTEST(Document, Traits) {\n    static_assert(std::is_constructible<Document>::value, \"\");\n    static_assert(std::is_default_constructible<Document>::value, \"\");\n#ifndef _MSC_VER\n    static_assert(!std::is_copy_constructible<Document>::value, \"\");\n#endif\n    static_assert(std::is_move_constructible<Document>::value, \"\");\n\n    static_assert(!std::is_nothrow_constructible<Document>::value, \"\");\n    static_assert(!std::is_nothrow_default_constructible<Document>::value, \"\");\n#ifndef _MSC_VER\n    static_assert(!std::is_nothrow_copy_constructible<Document>::value, \"\");\n    static_assert(std::is_nothrow_move_constructible<Document>::value, \"\");\n#endif\n\n    static_assert(std::is_assignable<Document,Document>::value, \"\");\n#ifndef _MSC_VER\n  static_assert(!std::is_copy_assignable<Document>::value, \"\");\n#endif\n    static_assert(std::is_move_assignable<Document>::value, \"\");\n\n#ifndef _MSC_VER\n    static_assert(std::is_nothrow_assignable<Document, Document>::value, \"\");\n#endif\n    static_assert(!std::is_nothrow_copy_assignable<Document>::value, \"\");\n#ifndef _MSC_VER\n    static_assert(std::is_nothrow_move_assignable<Document>::value, \"\");\n#endif\n\n    static_assert( std::is_destructible<Document>::value, \"\");\n#ifndef _MSC_VER\n    static_assert(std::is_nothrow_destructible<Document>::value, \"\");\n#endif\n}\n\n#endif\n\ntemplate <typename Allocator>\nstruct DocumentMove: public ::testing::Test {\n};\n\ntypedef ::testing::Types< CrtAllocator, MemoryPoolAllocator<> > MoveAllocatorTypes;\nTYPED_TEST_CASE(DocumentMove, MoveAllocatorTypes);\n\nTYPED_TEST(DocumentMove, MoveConstructor) {\n    typedef TypeParam Allocator;\n    typedef GenericDocument<UTF8<>, Allocator> D;\n    Allocator allocator;\n\n    D a(&allocator);\n    a.Parse(\"[\\\"one\\\", \\\"two\\\", \\\"three\\\"]\");\n    EXPECT_FALSE(a.HasParseError());\n    EXPECT_TRUE(a.IsArray());\n    EXPECT_EQ(3u, a.Size());\n    EXPECT_EQ(&a.GetAllocator(), &allocator);\n\n    // Document b(a); // does not compile (!is_copy_constructible)\n    D b(std::move(a));\n    EXPECT_TRUE(a.IsNull());\n    EXPECT_TRUE(b.IsArray());\n    EXPECT_EQ(3u, b.Size());\n    EXPECT_THROW(a.GetAllocator(), AssertException);\n    EXPECT_EQ(&b.GetAllocator(), &allocator);\n\n    b.Parse(\"{\\\"Foo\\\": \\\"Bar\\\", \\\"Baz\\\": 42}\");\n    EXPECT_FALSE(b.HasParseError());\n    EXPECT_TRUE(b.IsObject());\n    EXPECT_EQ(2u, b.MemberCount());\n\n    // Document c = a; // does not compile (!is_copy_constructible)\n    D c = std::move(b);\n    EXPECT_TRUE(b.IsNull());\n    EXPECT_TRUE(c.IsObject());\n    EXPECT_EQ(2u, c.MemberCount());\n    EXPECT_THROW(b.GetAllocator(), AssertException);\n    EXPECT_EQ(&c.GetAllocator(), &allocator);\n}\n\nTYPED_TEST(DocumentMove, MoveConstructorParseError) {\n    typedef TypeParam Allocator;\n    typedef GenericDocument<UTF8<>, Allocator> D;\n\n    ParseResult noError;\n    D a;\n    a.Parse(\"{ 4 = 4]\");\n    ParseResult error(a.GetParseError(), a.GetErrorOffset());\n    EXPECT_TRUE(a.HasParseError());\n    EXPECT_NE(error.Code(), noError.Code());\n    EXPECT_NE(error.Offset(), noError.Offset());\n\n    D b(std::move(a));\n    EXPECT_FALSE(a.HasParseError());\n    EXPECT_TRUE(b.HasParseError());\n    EXPECT_EQ(a.GetParseError(), noError.Code());\n    EXPECT_EQ(b.GetParseError(), error.Code());\n    EXPECT_EQ(a.GetErrorOffset(), noError.Offset());\n    EXPECT_EQ(b.GetErrorOffset(), error.Offset());\n\n    D c(std::move(b));\n    EXPECT_FALSE(b.HasParseError());\n    EXPECT_TRUE(c.HasParseError());\n    EXPECT_EQ(b.GetParseError(), noError.Code());\n    EXPECT_EQ(c.GetParseError(), error.Code());\n    EXPECT_EQ(b.GetErrorOffset(), noError.Offset());\n    EXPECT_EQ(c.GetErrorOffset(), error.Offset());\n}\n\n// This test does not properly use parsing, just for testing.\n// It must call ClearStack() explicitly to prevent memory leak.\n// But here we cannot as ClearStack() is private.\n#if 0\nTYPED_TEST(DocumentMove, MoveConstructorStack) {\n    typedef TypeParam Allocator;\n    typedef UTF8<> Encoding;\n    typedef GenericDocument<Encoding, Allocator> Document;\n\n    Document a;\n    size_t defaultCapacity = a.GetStackCapacity();\n\n    // Trick Document into getting GetStackCapacity() to return non-zero\n    typedef GenericReader<Encoding, Encoding, Allocator> Reader;\n    Reader reader(&a.GetAllocator());\n    GenericStringStream<Encoding> is(\"[\\\"one\\\", \\\"two\\\", \\\"three\\\"]\");\n    reader.template Parse<kParseDefaultFlags>(is, a);\n    size_t capacity = a.GetStackCapacity();\n    EXPECT_GT(capacity, 0u);\n\n    Document b(std::move(a));\n    EXPECT_EQ(a.GetStackCapacity(), defaultCapacity);\n    EXPECT_EQ(b.GetStackCapacity(), capacity);\n\n    Document c = std::move(b);\n    EXPECT_EQ(b.GetStackCapacity(), defaultCapacity);\n    EXPECT_EQ(c.GetStackCapacity(), capacity);\n}\n#endif\n\nTYPED_TEST(DocumentMove, MoveAssignment) {\n    typedef TypeParam Allocator;\n    typedef GenericDocument<UTF8<>, Allocator> D;\n    Allocator allocator;\n\n    D a(&allocator);\n    a.Parse(\"[\\\"one\\\", \\\"two\\\", \\\"three\\\"]\");\n    EXPECT_FALSE(a.HasParseError());\n    EXPECT_TRUE(a.IsArray());\n    EXPECT_EQ(3u, a.Size());\n    EXPECT_EQ(&a.GetAllocator(), &allocator);\n\n    // Document b; b = a; // does not compile (!is_copy_assignable)\n    D b;\n    b = std::move(a);\n    EXPECT_TRUE(a.IsNull());\n    EXPECT_TRUE(b.IsArray());\n    EXPECT_EQ(3u, b.Size());\n    EXPECT_THROW(a.GetAllocator(), AssertException);\n    EXPECT_EQ(&b.GetAllocator(), &allocator);\n\n    b.Parse(\"{\\\"Foo\\\": \\\"Bar\\\", \\\"Baz\\\": 42}\");\n    EXPECT_FALSE(b.HasParseError());\n    EXPECT_TRUE(b.IsObject());\n    EXPECT_EQ(2u, b.MemberCount());\n\n    // Document c; c = a; // does not compile (see static_assert)\n    D c;\n    c = std::move(b);\n    EXPECT_TRUE(b.IsNull());\n    EXPECT_TRUE(c.IsObject());\n    EXPECT_EQ(2u, c.MemberCount());\n    EXPECT_THROW(b.GetAllocator(), AssertException);\n    EXPECT_EQ(&c.GetAllocator(), &allocator);\n}\n\nTYPED_TEST(DocumentMove, MoveAssignmentParseError) {\n    typedef TypeParam Allocator;\n    typedef GenericDocument<UTF8<>, Allocator> D;\n\n    ParseResult noError;\n    D a;\n    a.Parse(\"{ 4 = 4]\");\n    ParseResult error(a.GetParseError(), a.GetErrorOffset());\n    EXPECT_TRUE(a.HasParseError());\n    EXPECT_NE(error.Code(), noError.Code());\n    EXPECT_NE(error.Offset(), noError.Offset());\n\n    D b;\n    b = std::move(a);\n    EXPECT_FALSE(a.HasParseError());\n    EXPECT_TRUE(b.HasParseError());\n    EXPECT_EQ(a.GetParseError(), noError.Code());\n    EXPECT_EQ(b.GetParseError(), error.Code());\n    EXPECT_EQ(a.GetErrorOffset(), noError.Offset());\n    EXPECT_EQ(b.GetErrorOffset(), error.Offset());\n\n    D c;\n    c = std::move(b);\n    EXPECT_FALSE(b.HasParseError());\n    EXPECT_TRUE(c.HasParseError());\n    EXPECT_EQ(b.GetParseError(), noError.Code());\n    EXPECT_EQ(c.GetParseError(), error.Code());\n    EXPECT_EQ(b.GetErrorOffset(), noError.Offset());\n    EXPECT_EQ(c.GetErrorOffset(), error.Offset());\n}\n\n// This test does not properly use parsing, just for testing.\n// It must call ClearStack() explicitly to prevent memory leak.\n// But here we cannot as ClearStack() is private.\n#if 0\nTYPED_TEST(DocumentMove, MoveAssignmentStack) {\n    typedef TypeParam Allocator;\n    typedef UTF8<> Encoding;\n    typedef GenericDocument<Encoding, Allocator> D;\n\n    D a;\n    size_t defaultCapacity = a.GetStackCapacity();\n\n    // Trick Document into getting GetStackCapacity() to return non-zero\n    typedef GenericReader<Encoding, Encoding, Allocator> Reader;\n    Reader reader(&a.GetAllocator());\n    GenericStringStream<Encoding> is(\"[\\\"one\\\", \\\"two\\\", \\\"three\\\"]\");\n    reader.template Parse<kParseDefaultFlags>(is, a);\n    size_t capacity = a.GetStackCapacity();\n    EXPECT_GT(capacity, 0u);\n\n    D b;\n    b = std::move(a);\n    EXPECT_EQ(a.GetStackCapacity(), defaultCapacity);\n    EXPECT_EQ(b.GetStackCapacity(), capacity);\n\n    D c;\n    c = std::move(b);\n    EXPECT_EQ(b.GetStackCapacity(), defaultCapacity);\n    EXPECT_EQ(c.GetStackCapacity(), capacity);\n}\n#endif\n\n#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS\n\n// Issue 22: Memory corruption via operator=\n// Fixed by making unimplemented assignment operator private.\n//TEST(Document, Assignment) {\n//  Document d1;\n//  Document d2;\n//  d1 = d2;\n//}\n\n#ifdef __clang__\nRAPIDJSON_DIAG_POP\n#endif\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/dtoatest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n#include \"rapidjson/internal/dtoa.h\"\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(type-limits)\n#endif\n\nusing namespace rapidjson::internal;\n\nTEST(dtoa, normal) {\n    char buffer[30];\n\n#define TEST_DTOA(d, a)\\\n    *dtoa(d, buffer) = '\\0';\\\n    EXPECT_STREQ(a, buffer)\n\n    TEST_DTOA(0.0, \"0.0\");\n    TEST_DTOA(-0.0, \"-0.0\");\n    TEST_DTOA(1.0, \"1.0\");\n    TEST_DTOA(-1.0, \"-1.0\");\n    TEST_DTOA(1.2345, \"1.2345\");\n    TEST_DTOA(1.2345678, \"1.2345678\");\n    TEST_DTOA(0.123456789012, \"0.123456789012\");\n    TEST_DTOA(1234567.8, \"1234567.8\");\n    TEST_DTOA(-79.39773355813419, \"-79.39773355813419\");\n    TEST_DTOA(0.000001, \"0.000001\");\n    TEST_DTOA(0.0000001, \"1e-7\");\n    TEST_DTOA(1e30, \"1e30\");\n    TEST_DTOA(1.234567890123456e30, \"1.234567890123456e30\");\n    TEST_DTOA(5e-324, \"5e-324\"); // Min subnormal positive double\n    TEST_DTOA(2.225073858507201e-308, \"2.225073858507201e-308\"); // Max subnormal positive double\n    TEST_DTOA(2.2250738585072014e-308, \"2.2250738585072014e-308\"); // Min normal positive double\n    TEST_DTOA(1.7976931348623157e308, \"1.7976931348623157e308\"); // Max double\n\n#undef TEST_DTOA\n}\n\nTEST(dtoa, maxDecimalPlaces) {\n    char buffer[30];\n\n#define TEST_DTOA(m, d, a)\\\n    *dtoa(d, buffer, m) = '\\0';\\\n    EXPECT_STREQ(a, buffer)\n\n    TEST_DTOA(3, 0.0, \"0.0\");\n    TEST_DTOA(1, 0.0, \"0.0\");\n    TEST_DTOA(3, -0.0, \"-0.0\");\n    TEST_DTOA(3, 1.0, \"1.0\");\n    TEST_DTOA(3, -1.0, \"-1.0\");\n    TEST_DTOA(3, 1.2345, \"1.234\");\n    TEST_DTOA(2, 1.2345, \"1.23\");\n    TEST_DTOA(1, 1.2345, \"1.2\");\n    TEST_DTOA(3, 1.2345678, \"1.234\");\n    TEST_DTOA(3, 1.0001, \"1.0\");\n    TEST_DTOA(2, 1.0001, \"1.0\");\n    TEST_DTOA(1, 1.0001, \"1.0\");\n    TEST_DTOA(3, 0.123456789012, \"0.123\");\n    TEST_DTOA(2, 0.123456789012, \"0.12\");\n    TEST_DTOA(1, 0.123456789012, \"0.1\");\n    TEST_DTOA(4, 0.0001, \"0.0001\");\n    TEST_DTOA(3, 0.0001, \"0.0\");\n    TEST_DTOA(2, 0.0001, \"0.0\");\n    TEST_DTOA(1, 0.0001, \"0.0\");\n    TEST_DTOA(3, 1234567.8, \"1234567.8\");\n    TEST_DTOA(3, 1e30, \"1e30\");\n    TEST_DTOA(3, 5e-324, \"0.0\"); // Min subnormal positive double\n    TEST_DTOA(3, 2.225073858507201e-308, \"0.0\"); // Max subnormal positive double\n    TEST_DTOA(3, 2.2250738585072014e-308, \"0.0\"); // Min normal positive double\n    TEST_DTOA(3, 1.7976931348623157e308, \"1.7976931348623157e308\"); // Max double\n    TEST_DTOA(5, -0.14000000000000001, \"-0.14\");\n    TEST_DTOA(4, -0.14000000000000001, \"-0.14\");\n    TEST_DTOA(3, -0.14000000000000001, \"-0.14\");\n    TEST_DTOA(3, -0.10000000000000001, \"-0.1\");\n    TEST_DTOA(2, -0.10000000000000001, \"-0.1\");\n    TEST_DTOA(1, -0.10000000000000001, \"-0.1\");\n\n#undef TEST_DTOA\n}\n\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_POP\n#endif\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/encodedstreamtest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n#include \"rapidjson/filereadstream.h\"\n#include \"rapidjson/filewritestream.h\"\n#include \"rapidjson/encodedstream.h\"\n#include \"rapidjson/stringbuffer.h\"\n#include \"rapidjson/memorystream.h\"\n#include \"rapidjson/memorybuffer.h\"\n\nusing namespace rapidjson;\n\nclass EncodedStreamTest : public ::testing::Test {\npublic:\n    EncodedStreamTest() : json_(), length_() {}\n    virtual ~EncodedStreamTest();\n\n    virtual void SetUp() {\n        json_ = ReadFile(\"utf8.json\", true, &length_);\n    }\n\n    virtual void TearDown() {\n        free(json_);\n        json_ = 0;\n    }\n\nprivate:\n    EncodedStreamTest(const EncodedStreamTest&);\n    EncodedStreamTest& operator=(const EncodedStreamTest&);\n    \nprotected:\n    static FILE* Open(const char* filename) {\n        const char *paths[] = {\n            \"encodings\",\n            \"bin/encodings\",\n            \"../bin/encodings\",\n            \"../../bin/encodings\",\n            \"../../../bin/encodings\"\n        };\n        char buffer[1024];\n        for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); i++) {\n            sprintf(buffer, \"%s/%s\", paths[i], filename);\n            FILE *fp = fopen(buffer, \"rb\");\n            if (fp)\n                return fp;\n        }\n        return 0;\n    }\n\n    static char *ReadFile(const char* filename, bool appendPath, size_t* outLength) {\n        FILE *fp = appendPath ? Open(filename) : fopen(filename, \"rb\");\n\n        if (!fp) {\n            *outLength = 0;\n            return 0;\n        }\n\n        fseek(fp, 0, SEEK_END);\n        *outLength = static_cast<size_t>(ftell(fp));\n        fseek(fp, 0, SEEK_SET);\n        char* buffer = static_cast<char*>(malloc(*outLength + 1));\n        size_t readLength = fread(buffer, 1, *outLength, fp);\n        buffer[readLength] = '\\0';\n        fclose(fp);\n        return buffer;\n    }\n\n    template <typename FileEncoding, typename MemoryEncoding>\n    void TestEncodedInputStream(const char* filename) {\n        // Test FileReadStream\n        {\n            char buffer[16];\n            FILE *fp = Open(filename);\n            ASSERT_TRUE(fp != 0);\n            FileReadStream fs(fp, buffer, sizeof(buffer));\n            EncodedInputStream<FileEncoding, FileReadStream> eis(fs);\n            StringStream s(json_);\n\n            while (eis.Peek() != '\\0') {\n                unsigned expected, actual;\n                EXPECT_TRUE(UTF8<>::Decode(s, &expected));\n                EXPECT_TRUE(MemoryEncoding::Decode(eis, &actual));\n                EXPECT_EQ(expected, actual);\n            }\n            EXPECT_EQ('\\0', s.Peek());\n            fclose(fp);\n        }\n\n        // Test MemoryStream\n        {\n            size_t size;\n            char* data = ReadFile(filename, true, &size);\n            MemoryStream ms(data, size);\n            EncodedInputStream<FileEncoding, MemoryStream> eis(ms);\n            StringStream s(json_);\n\n            while (eis.Peek() != '\\0') {\n                unsigned expected, actual;\n                EXPECT_TRUE(UTF8<>::Decode(s, &expected));\n                EXPECT_TRUE(MemoryEncoding::Decode(eis, &actual));\n                EXPECT_EQ(expected, actual);\n            }\n            EXPECT_EQ('\\0', s.Peek());\n            free(data);\n            EXPECT_EQ(size, eis.Tell());\n        }\n    }\n\n    void TestAutoUTFInputStream(const char *filename, bool expectHasBOM) {\n        // Test FileReadStream\n        {\n            char buffer[16];\n            FILE *fp = Open(filename);\n            ASSERT_TRUE(fp != 0);\n            FileReadStream fs(fp, buffer, sizeof(buffer));\n            AutoUTFInputStream<unsigned, FileReadStream> eis(fs);\n            EXPECT_EQ(expectHasBOM, eis.HasBOM());\n            StringStream s(json_);\n            while (eis.Peek() != '\\0') {\n                unsigned expected, actual;\n                EXPECT_TRUE(UTF8<>::Decode(s, &expected));\n                EXPECT_TRUE(AutoUTF<unsigned>::Decode(eis, &actual));\n                EXPECT_EQ(expected, actual);\n            }\n            EXPECT_EQ('\\0', s.Peek());\n            fclose(fp);\n        }\n\n        // Test MemoryStream\n        {\n            size_t size;\n            char* data = ReadFile(filename, true, &size);\n            MemoryStream ms(data, size);\n            AutoUTFInputStream<unsigned, MemoryStream> eis(ms);\n            EXPECT_EQ(expectHasBOM, eis.HasBOM());\n            StringStream s(json_);\n\n            while (eis.Peek() != '\\0') {\n                unsigned expected, actual;\n                EXPECT_TRUE(UTF8<>::Decode(s, &expected));\n                EXPECT_TRUE(AutoUTF<unsigned>::Decode(eis, &actual));\n                EXPECT_EQ(expected, actual);\n            }\n            EXPECT_EQ('\\0', s.Peek());\n            free(data);\n            EXPECT_EQ(size, eis.Tell());\n        }\n    }\n\n    template <typename FileEncoding, typename MemoryEncoding>\n    void TestEncodedOutputStream(const char* expectedFilename, bool putBOM) {\n        // Test FileWriteStream\n        {\n            char filename[L_tmpnam];\n            FILE* fp = TempFile(filename);\n            char buffer[16];\n            FileWriteStream os(fp, buffer, sizeof(buffer));\n            EncodedOutputStream<FileEncoding, FileWriteStream> eos(os, putBOM);\n            StringStream s(json_);\n            while (s.Peek() != '\\0') {\n                bool success = Transcoder<UTF8<>, MemoryEncoding>::Transcode(s, eos);\n                EXPECT_TRUE(success);\n            }\n            eos.Flush();\n            fclose(fp);\n            EXPECT_TRUE(CompareFile(filename, expectedFilename));\n            remove(filename);\n        }\n\n        // Test MemoryBuffer\n        {\n            MemoryBuffer mb;\n            EncodedOutputStream<FileEncoding, MemoryBuffer> eos(mb, putBOM);\n            StringStream s(json_);\n            while (s.Peek() != '\\0') {\n                bool success = Transcoder<UTF8<>, MemoryEncoding>::Transcode(s, eos);\n                EXPECT_TRUE(success);\n            }\n            eos.Flush();\n            EXPECT_TRUE(CompareBufferFile(mb.GetBuffer(), mb.GetSize(), expectedFilename));\n        }\n    }\n\n    void TestAutoUTFOutputStream(UTFType type, bool putBOM, const char *expectedFilename) {\n        // Test FileWriteStream\n        {\n            char filename[L_tmpnam];\n            FILE* fp = TempFile(filename);\n\n            char buffer[16];\n            FileWriteStream os(fp, buffer, sizeof(buffer));\n            AutoUTFOutputStream<unsigned, FileWriteStream> eos(os, type, putBOM);\n            StringStream s(json_);\n            while (s.Peek() != '\\0') {\n                bool success = Transcoder<UTF8<>, AutoUTF<unsigned> >::Transcode(s, eos);\n                EXPECT_TRUE(success);\n            }\n            eos.Flush();\n            fclose(fp);\n            EXPECT_TRUE(CompareFile(filename, expectedFilename));\n            remove(filename);\n        }\n\n        // Test MemoryBuffer\n        {\n            MemoryBuffer mb;\n            AutoUTFOutputStream<unsigned, MemoryBuffer> eos(mb, type, putBOM);\n            StringStream s(json_);\n            while (s.Peek() != '\\0') {\n                bool success = Transcoder<UTF8<>, AutoUTF<unsigned> >::Transcode(s, eos);\n                EXPECT_TRUE(success);\n            }\n            eos.Flush();\n            EXPECT_TRUE(CompareBufferFile(mb.GetBuffer(), mb.GetSize(), expectedFilename));\n        }\n    }\n\n    bool CompareFile(const char* filename, const char* expectedFilename) {\n        size_t actualLength, expectedLength;\n        char* actualBuffer = ReadFile(filename, false, &actualLength);\n        char* expectedBuffer = ReadFile(expectedFilename, true, &expectedLength);\n        bool ret = (expectedLength == actualLength) && memcmp(expectedBuffer, actualBuffer, actualLength) == 0;\n        free(actualBuffer);\n        free(expectedBuffer);\n        return ret;\n    }\n\n    bool CompareBufferFile(const char* actualBuffer, size_t actualLength, const char* expectedFilename) {\n        size_t expectedLength;\n        char* expectedBuffer = ReadFile(expectedFilename, true, &expectedLength);\n        bool ret = (expectedLength == actualLength) && memcmp(expectedBuffer, actualBuffer, actualLength) == 0;\n        free(expectedBuffer);\n        return ret;\n    }\n\n    char *json_;\n    size_t length_;\n};\n\nEncodedStreamTest::~EncodedStreamTest() {}\n\nTEST_F(EncodedStreamTest, EncodedInputStream) {\n    TestEncodedInputStream<UTF8<>,    UTF8<>  >(\"utf8.json\");\n    TestEncodedInputStream<UTF8<>,    UTF8<>  >(\"utf8bom.json\");\n    TestEncodedInputStream<UTF16LE<>, UTF16<> >(\"utf16le.json\");\n    TestEncodedInputStream<UTF16LE<>, UTF16<> >(\"utf16lebom.json\");\n    TestEncodedInputStream<UTF16BE<>, UTF16<> >(\"utf16be.json\");\n    TestEncodedInputStream<UTF16BE<>, UTF16<> >(\"utf16bebom.json\");\n    TestEncodedInputStream<UTF32LE<>, UTF32<> >(\"utf32le.json\");\n    TestEncodedInputStream<UTF32LE<>, UTF32<> >(\"utf32lebom.json\");\n    TestEncodedInputStream<UTF32BE<>, UTF32<> >(\"utf32be.json\");\n    TestEncodedInputStream<UTF32BE<>, UTF32<> >(\"utf32bebom.json\");\n}\n\nTEST_F(EncodedStreamTest, AutoUTFInputStream) {\n    TestAutoUTFInputStream(\"utf8.json\",      false);\n    TestAutoUTFInputStream(\"utf8bom.json\",   true);\n    TestAutoUTFInputStream(\"utf16le.json\",   false);\n    TestAutoUTFInputStream(\"utf16lebom.json\",true);\n    TestAutoUTFInputStream(\"utf16be.json\",   false);\n    TestAutoUTFInputStream(\"utf16bebom.json\",true);\n    TestAutoUTFInputStream(\"utf32le.json\",   false);\n    TestAutoUTFInputStream(\"utf32lebom.json\",true);\n    TestAutoUTFInputStream(\"utf32be.json\",   false);\n    TestAutoUTFInputStream(\"utf32bebom.json\", true);\n\n    {\n        // Auto detection fail, use user defined UTF type\n        const char json[] = \"{ }\";\n        MemoryStream ms(json, sizeof(json));\n        AutoUTFInputStream<unsigned, MemoryStream> eis(ms, kUTF8);\n        EXPECT_FALSE(eis.HasBOM());\n        EXPECT_EQ(kUTF8, eis.GetType());\n    }\n}\n\nTEST_F(EncodedStreamTest, EncodedOutputStream) {\n    TestEncodedOutputStream<UTF8<>,     UTF8<>  >(\"utf8.json\",      false);\n    TestEncodedOutputStream<UTF8<>,     UTF8<>  >(\"utf8bom.json\",   true);\n    TestEncodedOutputStream<UTF16LE<>,  UTF16<> >(\"utf16le.json\",   false);\n    TestEncodedOutputStream<UTF16LE<>,  UTF16<> >(\"utf16lebom.json\",true);\n    TestEncodedOutputStream<UTF16BE<>,  UTF16<> >(\"utf16be.json\",   false);\n    TestEncodedOutputStream<UTF16BE<>,  UTF16<> >(\"utf16bebom.json\",true);\n    TestEncodedOutputStream<UTF32LE<>,  UTF32<> >(\"utf32le.json\",   false);\n    TestEncodedOutputStream<UTF32LE<>,  UTF32<> >(\"utf32lebom.json\",true);\n    TestEncodedOutputStream<UTF32BE<>,  UTF32<> >(\"utf32be.json\",   false);\n    TestEncodedOutputStream<UTF32BE<>,  UTF32<> >(\"utf32bebom.json\",true);\n}\n\nTEST_F(EncodedStreamTest, AutoUTFOutputStream) {\n    TestAutoUTFOutputStream(kUTF8,      false,  \"utf8.json\");\n    TestAutoUTFOutputStream(kUTF8,      true,   \"utf8bom.json\");\n    TestAutoUTFOutputStream(kUTF16LE,   false,  \"utf16le.json\");\n    TestAutoUTFOutputStream(kUTF16LE,   true,   \"utf16lebom.json\");\n    TestAutoUTFOutputStream(kUTF16BE,   false,  \"utf16be.json\");\n    TestAutoUTFOutputStream(kUTF16BE,   true,   \"utf16bebom.json\");\n    TestAutoUTFOutputStream(kUTF32LE,   false,  \"utf32le.json\");\n    TestAutoUTFOutputStream(kUTF32LE,   true,   \"utf32lebom.json\");\n    TestAutoUTFOutputStream(kUTF32BE,   false,  \"utf32be.json\");\n    TestAutoUTFOutputStream(kUTF32BE,   true,   \"utf32bebom.json\");\n}\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/encodingstest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n#include \"rapidjson/filereadstream.h\"\n#include \"rapidjson/filewritestream.h\"\n#include \"rapidjson/encodedstream.h\"\n#include \"rapidjson/stringbuffer.h\"\n\nusing namespace rapidjson;\n\n// Verification of encoders/decoders with Hoehrmann's UTF8 decoder\n\n// http://www.unicode.org/Public/UNIDATA/Blocks.txt\nstatic const unsigned kCodepointRanges[] = {\n    0x0000,     0x007F,     // Basic Latin\n    0x0080,     0x00FF,     // Latin-1 Supplement\n    0x0100,     0x017F,     // Latin Extended-A\n    0x0180,     0x024F,     // Latin Extended-B\n    0x0250,     0x02AF,     // IPA Extensions\n    0x02B0,     0x02FF,     // Spacing Modifier Letters\n    0x0300,     0x036F,     // Combining Diacritical Marks\n    0x0370,     0x03FF,     // Greek and Coptic\n    0x0400,     0x04FF,     // Cyrillic\n    0x0500,     0x052F,     // Cyrillic Supplement\n    0x0530,     0x058F,     // Armenian\n    0x0590,     0x05FF,     // Hebrew\n    0x0600,     0x06FF,     // Arabic\n    0x0700,     0x074F,     // Syriac\n    0x0750,     0x077F,     // Arabic Supplement\n    0x0780,     0x07BF,     // Thaana\n    0x07C0,     0x07FF,     // NKo\n    0x0800,     0x083F,     // Samaritan\n    0x0840,     0x085F,     // Mandaic\n    0x0900,     0x097F,     // Devanagari\n    0x0980,     0x09FF,     // Bengali\n    0x0A00,     0x0A7F,     // Gurmukhi\n    0x0A80,     0x0AFF,     // Gujarati\n    0x0B00,     0x0B7F,     // Oriya\n    0x0B80,     0x0BFF,     // Tamil\n    0x0C00,     0x0C7F,     // Telugu\n    0x0C80,     0x0CFF,     // Kannada\n    0x0D00,     0x0D7F,     // Malayalam\n    0x0D80,     0x0DFF,     // Sinhala\n    0x0E00,     0x0E7F,     // Thai\n    0x0E80,     0x0EFF,     // Lao\n    0x0F00,     0x0FFF,     // Tibetan\n    0x1000,     0x109F,     // Myanmar\n    0x10A0,     0x10FF,     // Georgian\n    0x1100,     0x11FF,     // Hangul Jamo\n    0x1200,     0x137F,     // Ethiopic\n    0x1380,     0x139F,     // Ethiopic Supplement\n    0x13A0,     0x13FF,     // Cherokee\n    0x1400,     0x167F,     // Unified Canadian Aboriginal Syllabics\n    0x1680,     0x169F,     // Ogham\n    0x16A0,     0x16FF,     // Runic\n    0x1700,     0x171F,     // Tagalog\n    0x1720,     0x173F,     // Hanunoo\n    0x1740,     0x175F,     // Buhid\n    0x1760,     0x177F,     // Tagbanwa\n    0x1780,     0x17FF,     // Khmer\n    0x1800,     0x18AF,     // Mongolian\n    0x18B0,     0x18FF,     // Unified Canadian Aboriginal Syllabics Extended\n    0x1900,     0x194F,     // Limbu\n    0x1950,     0x197F,     // Tai Le\n    0x1980,     0x19DF,     // New Tai Lue\n    0x19E0,     0x19FF,     // Khmer Symbols\n    0x1A00,     0x1A1F,     // Buginese\n    0x1A20,     0x1AAF,     // Tai Tham\n    0x1B00,     0x1B7F,     // Balinese\n    0x1B80,     0x1BBF,     // Sundanese\n    0x1BC0,     0x1BFF,     // Batak\n    0x1C00,     0x1C4F,     // Lepcha\n    0x1C50,     0x1C7F,     // Ol Chiki\n    0x1CD0,     0x1CFF,     // Vedic Extensions\n    0x1D00,     0x1D7F,     // Phonetic Extensions\n    0x1D80,     0x1DBF,     // Phonetic Extensions Supplement\n    0x1DC0,     0x1DFF,     // Combining Diacritical Marks Supplement\n    0x1E00,     0x1EFF,     // Latin Extended Additional\n    0x1F00,     0x1FFF,     // Greek Extended\n    0x2000,     0x206F,     // General Punctuation\n    0x2070,     0x209F,     // Superscripts and Subscripts\n    0x20A0,     0x20CF,     // Currency Symbols\n    0x20D0,     0x20FF,     // Combining Diacritical Marks for Symbols\n    0x2100,     0x214F,     // Letterlike Symbols\n    0x2150,     0x218F,     // Number Forms\n    0x2190,     0x21FF,     // Arrows\n    0x2200,     0x22FF,     // Mathematical Operators\n    0x2300,     0x23FF,     // Miscellaneous Technical\n    0x2400,     0x243F,     // Control Pictures\n    0x2440,     0x245F,     // Optical Character Recognition\n    0x2460,     0x24FF,     // Enclosed Alphanumerics\n    0x2500,     0x257F,     // Box Drawing\n    0x2580,     0x259F,     // Block Elements\n    0x25A0,     0x25FF,     // Geometric Shapes\n    0x2600,     0x26FF,     // Miscellaneous Symbols\n    0x2700,     0x27BF,     // Dingbats\n    0x27C0,     0x27EF,     // Miscellaneous Mathematical Symbols-A\n    0x27F0,     0x27FF,     // Supplemental Arrows-A\n    0x2800,     0x28FF,     // Braille Patterns\n    0x2900,     0x297F,     // Supplemental Arrows-B\n    0x2980,     0x29FF,     // Miscellaneous Mathematical Symbols-B\n    0x2A00,     0x2AFF,     // Supplemental Mathematical Operators\n    0x2B00,     0x2BFF,     // Miscellaneous Symbols and Arrows\n    0x2C00,     0x2C5F,     // Glagolitic\n    0x2C60,     0x2C7F,     // Latin Extended-C\n    0x2C80,     0x2CFF,     // Coptic\n    0x2D00,     0x2D2F,     // Georgian Supplement\n    0x2D30,     0x2D7F,     // Tifinagh\n    0x2D80,     0x2DDF,     // Ethiopic Extended\n    0x2DE0,     0x2DFF,     // Cyrillic Extended-A\n    0x2E00,     0x2E7F,     // Supplemental Punctuation\n    0x2E80,     0x2EFF,     // CJK Radicals Supplement\n    0x2F00,     0x2FDF,     // Kangxi Radicals\n    0x2FF0,     0x2FFF,     // Ideographic Description Characters\n    0x3000,     0x303F,     // CJK Symbols and Punctuation\n    0x3040,     0x309F,     // Hiragana\n    0x30A0,     0x30FF,     // Katakana\n    0x3100,     0x312F,     // Bopomofo\n    0x3130,     0x318F,     // Hangul Compatibility Jamo\n    0x3190,     0x319F,     // Kanbun\n    0x31A0,     0x31BF,     // Bopomofo Extended\n    0x31C0,     0x31EF,     // CJK Strokes\n    0x31F0,     0x31FF,     // Katakana Phonetic Extensions\n    0x3200,     0x32FF,     // Enclosed CJK Letters and Months\n    0x3300,     0x33FF,     // CJK Compatibility\n    0x3400,     0x4DBF,     // CJK Unified Ideographs Extension A\n    0x4DC0,     0x4DFF,     // Yijing Hexagram Symbols\n    0x4E00,     0x9FFF,     // CJK Unified Ideographs\n    0xA000,     0xA48F,     // Yi Syllables\n    0xA490,     0xA4CF,     // Yi Radicals\n    0xA4D0,     0xA4FF,     // Lisu\n    0xA500,     0xA63F,     // Vai\n    0xA640,     0xA69F,     // Cyrillic Extended-B\n    0xA6A0,     0xA6FF,     // Bamum\n    0xA700,     0xA71F,     // Modifier Tone Letters\n    0xA720,     0xA7FF,     // Latin Extended-D\n    0xA800,     0xA82F,     // Syloti Nagri\n    0xA830,     0xA83F,     // Common Indic Number Forms\n    0xA840,     0xA87F,     // Phags-pa\n    0xA880,     0xA8DF,     // Saurashtra\n    0xA8E0,     0xA8FF,     // Devanagari Extended\n    0xA900,     0xA92F,     // Kayah Li\n    0xA930,     0xA95F,     // Rejang\n    0xA960,     0xA97F,     // Hangul Jamo Extended-A\n    0xA980,     0xA9DF,     // Javanese\n    0xAA00,     0xAA5F,     // Cham\n    0xAA60,     0xAA7F,     // Myanmar Extended-A\n    0xAA80,     0xAADF,     // Tai Viet\n    0xAB00,     0xAB2F,     // Ethiopic Extended-A\n    0xABC0,     0xABFF,     // Meetei Mayek\n    0xAC00,     0xD7AF,     // Hangul Syllables\n    0xD7B0,     0xD7FF,     // Hangul Jamo Extended-B\n    //0xD800,       0xDB7F,     // High Surrogates\n    //0xDB80,       0xDBFF,     // High Private Use Surrogates\n    //0xDC00,       0xDFFF,     // Low Surrogates\n    0xE000,     0xF8FF,     // Private Use Area\n    0xF900,     0xFAFF,     // CJK Compatibility Ideographs\n    0xFB00,     0xFB4F,     // Alphabetic Presentation Forms\n    0xFB50,     0xFDFF,     // Arabic Presentation Forms-A\n    0xFE00,     0xFE0F,     // Variation Selectors\n    0xFE10,     0xFE1F,     // Vertical Forms\n    0xFE20,     0xFE2F,     // Combining Half Marks\n    0xFE30,     0xFE4F,     // CJK Compatibility Forms\n    0xFE50,     0xFE6F,     // Small Form Variants\n    0xFE70,     0xFEFF,     // Arabic Presentation Forms-B\n    0xFF00,     0xFFEF,     // Halfwidth and Fullwidth Forms\n    0xFFF0,     0xFFFF,     // Specials\n    0x10000,    0x1007F,    // Linear B Syllabary\n    0x10080,    0x100FF,    // Linear B Ideograms\n    0x10100,    0x1013F,    // Aegean Numbers\n    0x10140,    0x1018F,    // Ancient Greek Numbers\n    0x10190,    0x101CF,    // Ancient Symbols\n    0x101D0,    0x101FF,    // Phaistos Disc\n    0x10280,    0x1029F,    // Lycian\n    0x102A0,    0x102DF,    // Carian\n    0x10300,    0x1032F,    // Old Italic\n    0x10330,    0x1034F,    // Gothic\n    0x10380,    0x1039F,    // Ugaritic\n    0x103A0,    0x103DF,    // Old Persian\n    0x10400,    0x1044F,    // Deseret\n    0x10450,    0x1047F,    // Shavian\n    0x10480,    0x104AF,    // Osmanya\n    0x10800,    0x1083F,    // Cypriot Syllabary\n    0x10840,    0x1085F,    // Imperial Aramaic\n    0x10900,    0x1091F,    // Phoenician\n    0x10920,    0x1093F,    // Lydian\n    0x10A00,    0x10A5F,    // Kharoshthi\n    0x10A60,    0x10A7F,    // Old South Arabian\n    0x10B00,    0x10B3F,    // Avestan\n    0x10B40,    0x10B5F,    // Inscriptional Parthian\n    0x10B60,    0x10B7F,    // Inscriptional Pahlavi\n    0x10C00,    0x10C4F,    // Old Turkic\n    0x10E60,    0x10E7F,    // Rumi Numeral Symbols\n    0x11000,    0x1107F,    // Brahmi\n    0x11080,    0x110CF,    // Kaithi\n    0x12000,    0x123FF,    // Cuneiform\n    0x12400,    0x1247F,    // Cuneiform Numbers and Punctuation\n    0x13000,    0x1342F,    // Egyptian Hieroglyphs\n    0x16800,    0x16A3F,    // Bamum Supplement\n    0x1B000,    0x1B0FF,    // Kana Supplement\n    0x1D000,    0x1D0FF,    // Byzantine Musical Symbols\n    0x1D100,    0x1D1FF,    // Musical Symbols\n    0x1D200,    0x1D24F,    // Ancient Greek Musical Notation\n    0x1D300,    0x1D35F,    // Tai Xuan Jing Symbols\n    0x1D360,    0x1D37F,    // Counting Rod Numerals\n    0x1D400,    0x1D7FF,    // Mathematical Alphanumeric Symbols\n    0x1F000,    0x1F02F,    // Mahjong Tiles\n    0x1F030,    0x1F09F,    // Domino Tiles\n    0x1F0A0,    0x1F0FF,    // Playing Cards\n    0x1F100,    0x1F1FF,    // Enclosed Alphanumeric Supplement\n    0x1F200,    0x1F2FF,    // Enclosed Ideographic Supplement\n    0x1F300,    0x1F5FF,    // Miscellaneous Symbols And Pictographs\n    0x1F600,    0x1F64F,    // Emoticons\n    0x1F680,    0x1F6FF,    // Transport And Map Symbols\n    0x1F700,    0x1F77F,    // Alchemical Symbols\n    0x20000,    0x2A6DF,    // CJK Unified Ideographs Extension B\n    0x2A700,    0x2B73F,    // CJK Unified Ideographs Extension C\n    0x2B740,    0x2B81F,    // CJK Unified Ideographs Extension D\n    0x2F800,    0x2FA1F,    // CJK Compatibility Ideographs Supplement\n    0xE0000,    0xE007F,    // Tags\n    0xE0100,    0xE01EF,    // Variation Selectors Supplement\n    0xF0000,    0xFFFFF,    // Supplementary Private Use Area-A\n    0x100000,   0x10FFFF,   // Supplementary Private Use Area-B\n    0xFFFFFFFF\n};\n\n// Copyright (c) 2008-2010 Bjoern Hoehrmann <bjoern@hoehrmann.de>\n// See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.\n\n#define UTF8_ACCEPT 0u\n\nstatic const unsigned char utf8d[] = {\n    // The first part of the table maps bytes to character classes that\n    // to reduce the size of the transition table and create bitmasks.\n    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,\n    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,  9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,\n    7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,  7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,\n    8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2,  2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,\n    10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8,\n\n    // The second part is a transition table that maps a combination\n    // of a state of the automaton and a character class to a state.\n    0,12,24,36,60,96,84,12,12,12,48,72, 12,12,12,12,12,12,12,12,12,12,12,12,\n    12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24,12,12,\n    12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12,\n    12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12,\n    12,36,12,12,12,12,12,12,12,12,12,12, \n};\n\nstatic unsigned inline decode(unsigned* state, unsigned* codep, unsigned byte) {\n    unsigned type = utf8d[byte];\n\n    *codep = (*state != UTF8_ACCEPT) ?\n        (byte & 0x3fu) | (*codep << 6) :\n    (0xff >> type) & (byte);\n\n    *state = utf8d[256 + *state + type];\n    return *state;\n}\n\n//static bool IsUTF8(unsigned char* s) {\n//  unsigned codepoint, state = 0;\n//\n//  while (*s)\n//      decode(&state, &codepoint, *s++);\n//\n//  return state == UTF8_ACCEPT;\n//}\n\nTEST(EncodingsTest, UTF8) {\n    StringBuffer os, os2;\n    for (const unsigned* range = kCodepointRanges; *range != 0xFFFFFFFF; range += 2) {\n        for (unsigned codepoint = range[0]; codepoint <= range[1]; ++codepoint) {\n            os.Clear();\n            UTF8<>::Encode(os, codepoint);\n            const char* encodedStr = os.GetString();\n\n            // Decode with Hoehrmann\n            {\n                unsigned decodedCodepoint = 0;\n                unsigned state = 0;\n\n                unsigned decodedCount = 0;\n                for (const char* s = encodedStr; *s; ++s)\n                    if (!decode(&state, &decodedCodepoint, static_cast<unsigned char>(*s))) {\n                        EXPECT_EQ(codepoint, decodedCodepoint);\n                        decodedCount++;\n                    }\n\n                if (*encodedStr) {                  // This decoder cannot handle U+0000\n                    EXPECT_EQ(1u, decodedCount);    // Should only contain one code point\n                }\n\n                EXPECT_EQ(UTF8_ACCEPT, state);\n                if (UTF8_ACCEPT != state)\n                    std::cout << std::hex << codepoint << \" \" << decodedCodepoint << std::endl;\n            }\n\n            // Decode\n            {\n                StringStream is(encodedStr);\n                unsigned decodedCodepoint;\n                bool result = UTF8<>::Decode(is, &decodedCodepoint);\n                EXPECT_TRUE(result);\n                EXPECT_EQ(codepoint, decodedCodepoint);\n                if (!result || codepoint != decodedCodepoint)\n                    std::cout << std::hex << codepoint << \" \" << decodedCodepoint << std::endl;\n            }\n\n            // Validate\n            {\n                StringStream is(encodedStr);\n                os2.Clear();\n                bool result = UTF8<>::Validate(is, os2);\n                EXPECT_TRUE(result);\n                EXPECT_EQ(0, StrCmp(encodedStr, os2.GetString()));\n            }\n        }\n    }\n}\n\nTEST(EncodingsTest, UTF16) {\n    GenericStringBuffer<UTF16<> > os, os2;\n    GenericStringBuffer<UTF8<> > utf8os;\n    for (const unsigned* range = kCodepointRanges; *range != 0xFFFFFFFF; range += 2) {\n        for (unsigned codepoint = range[0]; codepoint <= range[1]; ++codepoint) {\n            os.Clear();\n            UTF16<>::Encode(os, codepoint);\n            const UTF16<>::Ch* encodedStr = os.GetString();\n\n            // Encode with Hoehrmann's code\n            if (codepoint != 0) // cannot handle U+0000\n            {\n                // encode with UTF8<> first\n                utf8os.Clear();\n                UTF8<>::Encode(utf8os, codepoint);\n\n                // transcode from UTF8 to UTF16 with Hoehrmann's code\n                unsigned decodedCodepoint = 0;\n                unsigned state = 0;\n                UTF16<>::Ch buffer[3], *p = &buffer[0];\n                for (const char* s = utf8os.GetString(); *s; ++s) {\n                    if (!decode(&state, &decodedCodepoint, static_cast<unsigned char>(*s)))\n                        break;\n                }\n\n                if (codepoint <= 0xFFFF)\n                    *p++ = static_cast<UTF16<>::Ch>(decodedCodepoint);\n                else {\n                    // Encode code points above U+FFFF as surrogate pair.\n                    *p++ = static_cast<UTF16<>::Ch>(0xD7C0 + (decodedCodepoint >> 10));\n                    *p++ = static_cast<UTF16<>::Ch>(0xDC00 + (decodedCodepoint & 0x3FF));\n                }\n                *p++ = '\\0';\n\n                EXPECT_EQ(0, StrCmp(buffer, encodedStr));\n            }\n\n            // Decode\n            {\n                GenericStringStream<UTF16<> > is(encodedStr);\n                unsigned decodedCodepoint;\n                bool result = UTF16<>::Decode(is, &decodedCodepoint);\n                EXPECT_TRUE(result);\n                EXPECT_EQ(codepoint, decodedCodepoint);         \n                if (!result || codepoint != decodedCodepoint)\n                    std::cout << std::hex << codepoint << \" \" << decodedCodepoint << std::endl;\n            }\n\n            // Validate\n            {\n                GenericStringStream<UTF16<> > is(encodedStr);\n                os2.Clear();\n                bool result = UTF16<>::Validate(is, os2);\n                EXPECT_TRUE(result);\n                EXPECT_EQ(0, StrCmp(encodedStr, os2.GetString()));\n            }\n        }\n    }\n}\n\nTEST(EncodingsTest, UTF32) {\n    GenericStringBuffer<UTF32<> > os, os2;\n    for (const unsigned* range = kCodepointRanges; *range != 0xFFFFFFFF; range += 2) {\n        for (unsigned codepoint = range[0]; codepoint <= range[1]; ++codepoint) {\n            os.Clear();\n            UTF32<>::Encode(os, codepoint);\n            const UTF32<>::Ch* encodedStr = os.GetString();\n\n            // Decode\n            {\n                GenericStringStream<UTF32<> > is(encodedStr);\n                unsigned decodedCodepoint;\n                bool result = UTF32<>::Decode(is, &decodedCodepoint);\n                EXPECT_TRUE(result);\n                EXPECT_EQ(codepoint, decodedCodepoint);         \n                if (!result || codepoint != decodedCodepoint)\n                    std::cout << std::hex << codepoint << \" \" << decodedCodepoint << std::endl;\n            }\n\n            // Validate\n            {\n                GenericStringStream<UTF32<> > is(encodedStr);\n                os2.Clear();\n                bool result = UTF32<>::Validate(is, os2);\n                EXPECT_TRUE(result);\n                EXPECT_EQ(0, StrCmp(encodedStr, os2.GetString()));\n            }\n        }\n    }\n}\n\nTEST(EncodingsTest, ASCII) {\n    StringBuffer os, os2;\n    for (unsigned codepoint = 0; codepoint < 128; codepoint++) {\n        os.Clear();\n        ASCII<>::Encode(os, codepoint);\n        const ASCII<>::Ch* encodedStr = os.GetString();\n        {\n            StringStream is(encodedStr);\n            unsigned decodedCodepoint;\n            bool result = ASCII<>::Decode(is, &decodedCodepoint);\n            if (!result || codepoint != decodedCodepoint)\n                std::cout << std::hex << codepoint << \" \" << decodedCodepoint << std::endl;\n        }\n\n        // Validate\n        {\n            StringStream is(encodedStr);\n            os2.Clear();\n            bool result = ASCII<>::Validate(is, os2);\n            EXPECT_TRUE(result);\n            EXPECT_EQ(0, StrCmp(encodedStr, os2.GetString()));\n        }\n    }\n}\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/filestreamtest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n#include \"rapidjson/filereadstream.h\"\n#include \"rapidjson/filewritestream.h\"\n#include \"rapidjson/encodedstream.h\"\n\nusing namespace rapidjson;\n\nclass FileStreamTest : public ::testing::Test {\npublic:\n    FileStreamTest() : filename_(), json_(), length_() {}\n    virtual ~FileStreamTest();\n\n    virtual void SetUp() {\n        const char *paths[] = {\n            \"data/sample.json\",\n            \"bin/data/sample.json\",\n            \"../bin/data/sample.json\",\n            \"../../bin/data/sample.json\",\n            \"../../../bin/data/sample.json\"\n        };\n        FILE* fp = 0;\n        for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); i++) {\n            fp = fopen(paths[i], \"rb\");\n            if (fp) {\n                filename_ = paths[i];\n                break;\n            }\n        }\n        ASSERT_TRUE(fp != 0);\n\n        fseek(fp, 0, SEEK_END);\n        length_ = static_cast<size_t>(ftell(fp));\n        fseek(fp, 0, SEEK_SET);\n        json_ = static_cast<char*>(malloc(length_ + 1));\n        size_t readLength = fread(json_, 1, length_, fp);\n        json_[readLength] = '\\0';\n        fclose(fp);\n    }\n\n    virtual void TearDown() {\n        free(json_);\n        json_ = 0;\n    }\n\nprivate:\n    FileStreamTest(const FileStreamTest&);\n    FileStreamTest& operator=(const FileStreamTest&);\n    \nprotected:\n    const char* filename_;\n    char *json_;\n    size_t length_;\n};\n\nFileStreamTest::~FileStreamTest() {}\n\nTEST_F(FileStreamTest, FileReadStream) {\n    FILE *fp = fopen(filename_, \"rb\");\n    ASSERT_TRUE(fp != 0);\n    char buffer[65536];\n    FileReadStream s(fp, buffer, sizeof(buffer));\n\n    for (size_t i = 0; i < length_; i++) {\n        EXPECT_EQ(json_[i], s.Peek());\n        EXPECT_EQ(json_[i], s.Peek());  // 2nd time should be the same\n        EXPECT_EQ(json_[i], s.Take());\n    }\n\n    EXPECT_EQ(length_, s.Tell());\n    EXPECT_EQ('\\0', s.Peek());\n\n    fclose(fp);\n}\n\nTEST_F(FileStreamTest, FileWriteStream) {\n    char filename[L_tmpnam];\n    FILE* fp = TempFile(filename);\n\n    char buffer[65536];\n    FileWriteStream os(fp, buffer, sizeof(buffer));\n    for (size_t i = 0; i < length_; i++)\n        os.Put(json_[i]);\n    os.Flush();\n    fclose(fp);\n\n    // Read it back to verify\n    fp = fopen(filename, \"rb\");\n    FileReadStream is(fp, buffer, sizeof(buffer));\n\n    for (size_t i = 0; i < length_; i++)\n        EXPECT_EQ(json_[i], is.Take());\n\n    EXPECT_EQ(length_, is.Tell());\n    fclose(fp);\n\n    //std::cout << filename << std::endl;\n    remove(filename);\n}\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/fwdtest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n\n// Using forward declared types here.\n\n#include \"rapidjson/fwd.h\"\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(effc++)\n#endif\n\nusing namespace rapidjson;\n\nstruct Foo {\n    Foo();\n    ~Foo();\n\n    // encodings.h\n    UTF8<char>* utf8;\n    UTF16<wchar_t>* utf16;\n    UTF16BE<wchar_t>* utf16be;\n    UTF16LE<wchar_t>* utf16le;\n    UTF32<unsigned>* utf32;\n    UTF32BE<unsigned>* utf32be;\n    UTF32LE<unsigned>* utf32le;\n    ASCII<char>* ascii;\n    AutoUTF<unsigned>* autoutf;\n    Transcoder<UTF8<char>, UTF8<char> >* transcoder;\n\n    // allocators.h\n    CrtAllocator* crtallocator;\n    MemoryPoolAllocator<CrtAllocator>* memorypoolallocator;\n\n    // stream.h\n    StringStream* stringstream;\n    InsituStringStream* insitustringstream;\n\n    // stringbuffer.h\n    StringBuffer* stringbuffer;\n\n    // // filereadstream.h\n    // FileReadStream* filereadstream;\n\n    // // filewritestream.h\n    // FileWriteStream* filewritestream;\n\n    // memorybuffer.h\n    MemoryBuffer* memorybuffer;\n\n    // memorystream.h\n    MemoryStream* memorystream;\n\n    // reader.h\n    BaseReaderHandler<UTF8<char>, void>* basereaderhandler;\n    Reader* reader;\n\n    // writer.h\n    Writer<StringBuffer, UTF8<char>, UTF8<char>, CrtAllocator, 0>* writer;\n\n    // prettywriter.h\n    PrettyWriter<StringBuffer, UTF8<char>, UTF8<char>, CrtAllocator, 0>* prettywriter;\n\n    // document.h\n    Value* value;\n    Document* document;\n\n    // pointer.h\n    Pointer* pointer;\n\n    // schema.h\n    SchemaDocument* schemadocument;\n    SchemaValidator* schemavalidator;\n\n    // char buffer[16];\n};\n\n// Using type definitions here.\n\n#include \"rapidjson/stringbuffer.h\"\n#include \"rapidjson/filereadstream.h\"\n#include \"rapidjson/filewritestream.h\"\n#include \"rapidjson/memorybuffer.h\"\n#include \"rapidjson/memorystream.h\"\n#include \"rapidjson/document.h\" // -> reader.h\n#include \"rapidjson/writer.h\"\n#include \"rapidjson/prettywriter.h\"\n#include \"rapidjson/schema.h\"   // -> pointer.h\n\nFoo::Foo() : \n    // encodings.h\n    utf8(RAPIDJSON_NEW(UTF8<>)),\n    utf16(RAPIDJSON_NEW(UTF16<>)),\n    utf16be(RAPIDJSON_NEW(UTF16BE<>)),\n    utf16le(RAPIDJSON_NEW(UTF16LE<>)),\n    utf32(RAPIDJSON_NEW(UTF32<>)),\n    utf32be(RAPIDJSON_NEW(UTF32BE<>)),\n    utf32le(RAPIDJSON_NEW(UTF32LE<>)),\n    ascii(RAPIDJSON_NEW(ASCII<>)),\n    autoutf(RAPIDJSON_NEW(AutoUTF<unsigned>)),\n    transcoder(RAPIDJSON_NEW((Transcoder<UTF8<>, UTF8<> >))),\n\n    // allocators.h\n    crtallocator(RAPIDJSON_NEW(CrtAllocator)),\n    memorypoolallocator(RAPIDJSON_NEW(MemoryPoolAllocator<>)),\n\n    // stream.h\n    stringstream(RAPIDJSON_NEW(StringStream(0))),\n    insitustringstream(RAPIDJSON_NEW(InsituStringStream(0))),\n\n    // stringbuffer.h\n    stringbuffer(RAPIDJSON_NEW(StringBuffer)),\n\n    // // filereadstream.h\n    // filereadstream(RAPIDJSON_NEW(FileReadStream(stdout, buffer, sizeof(buffer)))),\n\n    // // filewritestream.h\n    // filewritestream(RAPIDJSON_NEW(FileWriteStream(stdout, buffer, sizeof(buffer)))),\n\n    // memorybuffer.h\n    memorybuffer(RAPIDJSON_NEW(MemoryBuffer)),\n\n    // memorystream.h\n    memorystream(RAPIDJSON_NEW(MemoryStream(0, 0))),\n\n    // reader.h\n    basereaderhandler(RAPIDJSON_NEW((BaseReaderHandler<UTF8<>, void>))),\n    reader(RAPIDJSON_NEW(Reader)),\n\n    // writer.h\n    writer(RAPIDJSON_NEW((Writer<StringBuffer>))),\n\n    // prettywriter.h\n    prettywriter(RAPIDJSON_NEW((PrettyWriter<StringBuffer>))),\n\n    // document.h\n    value(RAPIDJSON_NEW(Value)),\n    document(RAPIDJSON_NEW(Document)),\n\n    // pointer.h\n    pointer(RAPIDJSON_NEW(Pointer)),\n\n    // schema.h\n    schemadocument(RAPIDJSON_NEW(SchemaDocument(*document))),\n    schemavalidator(RAPIDJSON_NEW(SchemaValidator(*schemadocument)))\n{\n\n}\n\nFoo::~Foo() {\n    // encodings.h\n    RAPIDJSON_DELETE(utf8);\n    RAPIDJSON_DELETE(utf16);\n    RAPIDJSON_DELETE(utf16be);\n    RAPIDJSON_DELETE(utf16le);\n    RAPIDJSON_DELETE(utf32);\n    RAPIDJSON_DELETE(utf32be);\n    RAPIDJSON_DELETE(utf32le);\n    RAPIDJSON_DELETE(ascii);\n    RAPIDJSON_DELETE(autoutf);\n    RAPIDJSON_DELETE(transcoder);\n\n    // allocators.h\n    RAPIDJSON_DELETE(crtallocator);\n    RAPIDJSON_DELETE(memorypoolallocator);\n\n    // stream.h\n    RAPIDJSON_DELETE(stringstream);\n    RAPIDJSON_DELETE(insitustringstream);\n\n    // stringbuffer.h\n    RAPIDJSON_DELETE(stringbuffer);\n\n    // // filereadstream.h\n    // RAPIDJSON_DELETE(filereadstream);\n\n    // // filewritestream.h\n    // RAPIDJSON_DELETE(filewritestream);\n\n    // memorybuffer.h\n    RAPIDJSON_DELETE(memorybuffer);\n\n    // memorystream.h\n    RAPIDJSON_DELETE(memorystream);\n\n    // reader.h\n    RAPIDJSON_DELETE(basereaderhandler);\n    RAPIDJSON_DELETE(reader);\n\n    // writer.h\n    RAPIDJSON_DELETE(writer);\n\n    // prettywriter.h\n    RAPIDJSON_DELETE(prettywriter);\n\n    // document.h\n    RAPIDJSON_DELETE(value);\n    RAPIDJSON_DELETE(document);\n\n    // pointer.h\n    RAPIDJSON_DELETE(pointer);\n\n    // schema.h\n    RAPIDJSON_DELETE(schemadocument);\n    RAPIDJSON_DELETE(schemavalidator);\n}\n\nTEST(Fwd, Fwd) {\n    Foo f;\n}\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_POP\n#endif\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/istreamwrappertest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n\n#include \"rapidjson/istreamwrapper.h\"\n#include \"rapidjson/encodedstream.h\"\n#include \"rapidjson/document.h\"\n#include <sstream>\n#include <fstream>\n\n#ifdef _MSC_VER\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(4702) // unreachable code\n#endif\n\nusing namespace rapidjson;\nusing namespace std;\n\ntemplate <typename StringStreamType>\nstatic void TestStringStream() {\n    typedef typename StringStreamType::char_type Ch;\n\n    {\n        StringStreamType iss;\n        BasicIStreamWrapper<StringStreamType> is(iss);\n        EXPECT_EQ(0, is.Tell());\n        if (sizeof(Ch) == 1) {\n            EXPECT_EQ(0, is.Peek4());\n            EXPECT_EQ(0, is.Tell());\n        }\n        EXPECT_EQ(0, is.Peek());\n        EXPECT_EQ(0, is.Take());\n        EXPECT_EQ(0, is.Tell());\n    }\n\n    {\n        Ch s[] = { 'A', 'B', 'C', '\\0' };\n        StringStreamType iss(s);\n        BasicIStreamWrapper<StringStreamType> is(iss);\n        EXPECT_EQ(0, is.Tell());\n        if (sizeof(Ch) == 1) {\n            EXPECT_EQ(0, is.Peek4()); // less than 4 bytes\n        }\n        for (int i = 0; i < 3; i++) {\n            EXPECT_EQ(static_cast<size_t>(i), is.Tell());\n            EXPECT_EQ('A' + i, is.Peek());\n            EXPECT_EQ('A' + i, is.Peek());\n            EXPECT_EQ('A' + i, is.Take());\n        }\n        EXPECT_EQ(3, is.Tell());\n        EXPECT_EQ(0, is.Peek());\n        EXPECT_EQ(0, is.Take());\n    }\n\n    {\n        Ch s[] = { 'A', 'B', 'C', 'D', 'E', '\\0' };\n        StringStreamType iss(s);\n        BasicIStreamWrapper<StringStreamType> is(iss);\n        if (sizeof(Ch) == 1) {\n            const Ch* c = is.Peek4();\n            for (int i = 0; i < 4; i++)\n                EXPECT_EQ('A' + i, c[i]);\n            EXPECT_EQ(0, is.Tell());\n        }\n        for (int i = 0; i < 5; i++) {\n            EXPECT_EQ(static_cast<size_t>(i), is.Tell());\n            EXPECT_EQ('A' + i, is.Peek());\n            EXPECT_EQ('A' + i, is.Peek());\n            EXPECT_EQ('A' + i, is.Take());\n        }\n        EXPECT_EQ(5, is.Tell());\n        EXPECT_EQ(0, is.Peek());\n        EXPECT_EQ(0, is.Take());\n    }\n}\n\nTEST(IStreamWrapper, istringstream) {\n    TestStringStream<istringstream>();\n}\n\nTEST(IStreamWrapper, stringstream) {\n    TestStringStream<stringstream>();\n}\n\nTEST(IStreamWrapper, wistringstream) {\n    TestStringStream<wistringstream>();\n}\n\nTEST(IStreamWrapper, wstringstream) {\n    TestStringStream<wstringstream>();\n}\n\ntemplate <typename FileStreamType>\nstatic bool Open(FileStreamType& fs, const char* filename) {\n    const char *paths[] = {\n        \"encodings\",\n        \"bin/encodings\",\n        \"../bin/encodings\",\n        \"../../bin/encodings\",\n        \"../../../bin/encodings\"\n    };\n    char buffer[1024];\n    for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); i++) {\n        sprintf(buffer, \"%s/%s\", paths[i], filename);\n        fs.open(buffer, ios_base::in | ios_base::binary);\n        if (fs.is_open())\n            return true;\n    }\n    return false;\n}\n\nTEST(IStreamWrapper, ifstream) {\n    ifstream ifs;\n    ASSERT_TRUE(Open(ifs, \"utf8bom.json\"));\n    IStreamWrapper isw(ifs);\n    EncodedInputStream<UTF8<>, IStreamWrapper> eis(isw);\n    Document d;\n    EXPECT_TRUE(!d.ParseStream(eis).HasParseError());\n    EXPECT_TRUE(d.IsObject());\n    EXPECT_EQ(5, d.MemberCount());\n}\n\nTEST(IStreamWrapper, fstream) {\n    fstream fs;\n    ASSERT_TRUE(Open(fs, \"utf8bom.json\"));\n    IStreamWrapper isw(fs);\n    EncodedInputStream<UTF8<>, IStreamWrapper> eis(isw);\n    Document d;\n    EXPECT_TRUE(!d.ParseStream(eis).HasParseError());\n    EXPECT_TRUE(d.IsObject());\n    EXPECT_EQ(5, d.MemberCount());\n}\n\n// wifstream/wfstream only works on C++11 with codecvt_utf16\n// But many C++11 library still not have it.\n#if 0\n#include <codecvt>\n\nTEST(IStreamWrapper, wifstream) {\n    wifstream ifs;\n    ASSERT_TRUE(Open(ifs, \"utf16bebom.json\"));\n    ifs.imbue(std::locale(ifs.getloc(),\n       new std::codecvt_utf16<wchar_t, 0x10ffff, std::consume_header>));\n    WIStreamWrapper isw(ifs);\n    GenericDocument<UTF16<> > d;\n    d.ParseStream<kParseDefaultFlags, UTF16<>, WIStreamWrapper>(isw);\n    EXPECT_TRUE(!d.HasParseError());\n    EXPECT_TRUE(d.IsObject());\n    EXPECT_EQ(5, d.MemberCount());\n}\n\nTEST(IStreamWrapper, wfstream) {\n    wfstream fs;\n    ASSERT_TRUE(Open(fs, \"utf16bebom.json\"));\n    fs.imbue(std::locale(fs.getloc(),\n       new std::codecvt_utf16<wchar_t, 0x10ffff, std::consume_header>));\n    WIStreamWrapper isw(fs);\n    GenericDocument<UTF16<> > d;\n    d.ParseStream<kParseDefaultFlags, UTF16<>, WIStreamWrapper>(isw);\n    EXPECT_TRUE(!d.HasParseError());\n    EXPECT_TRUE(d.IsObject());\n    EXPECT_EQ(5, d.MemberCount());\n}\n\n#endif\n\n#ifdef _MSC_VER\nRAPIDJSON_DIAG_POP\n#endif\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/itoatest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n#include \"rapidjson/internal/itoa.h\"\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(type-limits)\n#endif\n\nusing namespace rapidjson::internal;\n\ntemplate <typename T>\nstruct Traits {\n};\n\ntemplate <>\nstruct Traits<uint32_t> {\n    enum { kBufferSize = 11 };\n    enum { kMaxDigit = 10 };\n    static uint32_t Negate(uint32_t x) { return x; }\n};\n\ntemplate <>\nstruct Traits<int32_t> {\n    enum { kBufferSize = 12 };\n    enum { kMaxDigit = 10 };\n    static int32_t Negate(int32_t x) { return -x; }\n};\n\ntemplate <>\nstruct Traits<uint64_t> {\n    enum { kBufferSize = 21 };\n    enum { kMaxDigit = 20 };\n    static uint64_t Negate(uint64_t x) { return x; }\n};\n\ntemplate <>\nstruct Traits<int64_t> {\n    enum { kBufferSize = 22 };\n    enum { kMaxDigit = 20 };\n    static int64_t Negate(int64_t x) { return -x; }\n};\n\ntemplate <typename T>\nstatic void VerifyValue(T value, void(*f)(T, char*), char* (*g)(T, char*)) {\n    char buffer1[Traits<T>::kBufferSize];\n    char buffer2[Traits<T>::kBufferSize];\n\n    f(value, buffer1);\n    *g(value, buffer2) = '\\0';\n    \n\n    EXPECT_STREQ(buffer1, buffer2);\n}\n\ntemplate <typename T>\nstatic void Verify(void(*f)(T, char*), char* (*g)(T, char*)) {\n    // Boundary cases\n    VerifyValue<T>(0, f, g);\n    VerifyValue<T>(std::numeric_limits<T>::min(), f, g);\n    VerifyValue<T>(std::numeric_limits<T>::max(), f, g);\n\n    // 2^n - 1, 2^n, 10^n - 1, 10^n until overflow\n    for (uint32_t power = 2; power <= 10; power += 8) {\n        T i = 1, last;\n        do {\n            VerifyValue<T>(i - 1, f, g);\n            VerifyValue<T>(i, f, g);\n            if (std::numeric_limits<T>::min() < 0) {\n                VerifyValue<T>(Traits<T>::Negate(i), f, g);\n                VerifyValue<T>(Traits<T>::Negate(i + 1), f, g);\n            }\n            last = i;\n            if (i > static_cast<T>(std::numeric_limits<T>::max() / static_cast<T>(power)))\n                break;\n            i *= power;\n        } while (last < i);\n    }\n}\n\nstatic void u32toa_naive(uint32_t value, char* buffer) {\n    char temp[10];\n    char *p = temp;\n    do {\n        *p++ = static_cast<char>(char(value % 10) + '0');\n        value /= 10;\n    } while (value > 0);\n\n    do {\n        *buffer++ = *--p;\n    } while (p != temp);\n\n    *buffer = '\\0';\n}\n\nstatic void i32toa_naive(int32_t value, char* buffer) {\n    uint32_t u = static_cast<uint32_t>(value);\n    if (value < 0) {\n        *buffer++ = '-';\n        u = ~u + 1;\n    }\n    u32toa_naive(u, buffer);\n}\n\nstatic void u64toa_naive(uint64_t value, char* buffer) {\n    char temp[20];\n    char *p = temp;\n    do {\n        *p++ = static_cast<char>(char(value % 10) + '0');\n        value /= 10;\n    } while (value > 0);\n\n    do {\n        *buffer++ = *--p;\n    } while (p != temp);\n\n    *buffer = '\\0';\n}\n\nstatic void i64toa_naive(int64_t value, char* buffer) {\n    uint64_t u = static_cast<uint64_t>(value);\n    if (value < 0) {\n        *buffer++ = '-';\n        u = ~u + 1;\n    }\n    u64toa_naive(u, buffer);\n}\n\nTEST(itoa, u32toa) {\n    Verify(u32toa_naive, u32toa);\n}\n\nTEST(itoa, i32toa) {\n    Verify(i32toa_naive, i32toa);\n}\n\nTEST(itoa, u64toa) {\n    Verify(u64toa_naive, u64toa);\n}\n\nTEST(itoa, i64toa) {\n    Verify(i64toa_naive, i64toa);\n}\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_POP\n#endif\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/jsoncheckertest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n\n#include \"rapidjson/document.h\"\n\nusing namespace rapidjson;\n\nstatic char* ReadFile(const char* filename, size_t& length) {\n    const char *paths[] = {\n        \"jsonchecker\",\n        \"bin/jsonchecker\",\n        \"../bin/jsonchecker\",\n        \"../../bin/jsonchecker\",\n        \"../../../bin/jsonchecker\"\n    };\n    char buffer[1024];\n    FILE *fp = 0;\n    for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); i++) {\n        sprintf(buffer, \"%s/%s\", paths[i], filename);\n        fp = fopen(buffer, \"rb\");\n        if (fp)\n            break;\n    }\n\n    if (!fp)\n        return 0;\n\n    fseek(fp, 0, SEEK_END);\n    length = static_cast<size_t>(ftell(fp));\n    fseek(fp, 0, SEEK_SET);\n    char* json = static_cast<char*>(malloc(length + 1));\n    size_t readLength = fread(json, 1, length, fp);\n    json[readLength] = '\\0';\n    fclose(fp);\n    return json;\n}\n\nTEST(JsonChecker, Reader) {\n    char filename[256];\n\n    // jsonchecker/failXX.json\n    for (int i = 1; i <= 33; i++) {\n        if (i == 1) // fail1.json is valid in rapidjson, which has no limitation on type of root element (RFC 7159).\n            continue;\n        if (i == 18)    // fail18.json is valid in rapidjson, which has no limitation on depth of nesting.\n            continue;\n\n        sprintf(filename, \"fail%d.json\", i);\n        size_t length;\n        char* json = ReadFile(filename, length);\n        if (!json) {\n            printf(\"jsonchecker file %s not found\", filename);\n            ADD_FAILURE();\n            continue;\n        }\n\n        GenericDocument<UTF8<>, CrtAllocator> document; // Use Crt allocator to check exception-safety (no memory leak)\n        document.Parse(json);\n        EXPECT_TRUE(document.HasParseError());\n\n        document.Parse<kParseIterativeFlag>(json);\n        EXPECT_TRUE(document.HasParseError());\n\n        free(json);\n    }\n\n    // passX.json\n    for (int i = 1; i <= 3; i++) {\n        sprintf(filename, \"pass%d.json\", i);\n        size_t length;\n        char* json = ReadFile(filename, length);\n        if (!json) {\n            printf(\"jsonchecker file %s not found\", filename);\n            continue;\n        }\n\n        GenericDocument<UTF8<>, CrtAllocator> document; // Use Crt allocator to check exception-safety (no memory leak)\n        document.Parse(json);\n        EXPECT_FALSE(document.HasParseError());\n\n        document.Parse<kParseIterativeFlag>(json);\n        EXPECT_FALSE(document.HasParseError());\n\n        free(json);\n    }\n}\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/namespacetest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n\n// test another instantiation of RapidJSON in a different namespace \n\n#define RAPIDJSON_NAMESPACE my::rapid::json\n#define RAPIDJSON_NAMESPACE_BEGIN namespace my { namespace rapid { namespace json {\n#define RAPIDJSON_NAMESPACE_END } } }\n\n// include lots of RapidJSON files\n\n#include \"rapidjson/document.h\"\n#include \"rapidjson/writer.h\"\n#include \"rapidjson/filereadstream.h\"\n#include \"rapidjson/filewritestream.h\"\n#include \"rapidjson/encodedstream.h\"\n#include \"rapidjson/stringbuffer.h\"\n\nstatic const char json[] = \"{\\\"hello\\\":\\\"world\\\",\\\"t\\\":true,\\\"f\\\":false,\\\"n\\\":null,\\\"i\\\":123,\\\"pi\\\":3.1416,\\\"a\\\":[1,2,3,4]}\";\n\nTEST(NamespaceTest,Using) {\n    using namespace RAPIDJSON_NAMESPACE;\n    typedef GenericDocument<UTF8<>, CrtAllocator> DocumentType;\n    DocumentType doc;\n\n    doc.Parse(json);\n    EXPECT_TRUE(!doc.HasParseError());\n}\n\nTEST(NamespaceTest,Direct) {\n    typedef RAPIDJSON_NAMESPACE::Document Document;\n    typedef RAPIDJSON_NAMESPACE::Reader Reader;\n    typedef RAPIDJSON_NAMESPACE::StringStream StringStream;\n    typedef RAPIDJSON_NAMESPACE::StringBuffer StringBuffer;\n    typedef RAPIDJSON_NAMESPACE::Writer<StringBuffer> WriterType;\n\n    StringStream s(json);\n    StringBuffer buffer;\n    WriterType writer(buffer);\n    buffer.ShrinkToFit();\n    Reader reader;\n    reader.Parse(s, writer);\n\n    EXPECT_STREQ(json, buffer.GetString());\n    EXPECT_EQ(sizeof(json)-1, buffer.GetSize());\n    EXPECT_TRUE(writer.IsComplete());\n\n    Document doc;\n    doc.Parse(buffer.GetString());\n    EXPECT_TRUE(!doc.HasParseError());\n\n    buffer.Clear();\n    writer.Reset(buffer);\n    doc.Accept(writer);\n    EXPECT_STREQ(json, buffer.GetString());\n    EXPECT_TRUE(writer.IsComplete());\n}\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/ostreamwrappertest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n\n#include \"rapidjson/ostreamwrapper.h\"\n#include \"rapidjson/encodedstream.h\"\n#include \"rapidjson/document.h\"\n#include <sstream>\n#include <fstream>\n\nusing namespace rapidjson;\nusing namespace std;\n\ntemplate <typename StringStreamType>\nstatic void TestStringStream() {\n    typedef typename StringStreamType::char_type Ch;\n\n    Ch s[] = { 'A', 'B', 'C', '\\0' };\n    StringStreamType oss(s);\n    BasicOStreamWrapper<StringStreamType> os(oss);\n    for (size_t i = 0; i < 3; i++)\n        os.Put(s[i]);\n    os.Flush();\n    for (size_t i = 0; i < 3; i++)\n        EXPECT_EQ(s[i], oss.str()[i]);\n}\n\nTEST(OStreamWrapper, ostringstream) {\n    TestStringStream<ostringstream>();\n}\n\nTEST(OStreamWrapper, stringstream) {\n    TestStringStream<stringstream>();\n}\n\nTEST(OStreamWrapper, wostringstream) {\n    TestStringStream<wostringstream>();\n}\n\nTEST(OStreamWrapper, wstringstream) {\n    TestStringStream<wstringstream>();\n}\n\nTEST(OStreamWrapper, cout) {\n    OStreamWrapper os(cout);\n    const char* s = \"Hello World!\\n\";\n    while (*s)\n        os.Put(*s++);\n    os.Flush();\n}\n\ntemplate <typename FileStreamType>\nstatic void TestFileStream() {\n    char filename[L_tmpnam];\n    FILE* fp = TempFile(filename);\n    fclose(fp);\n\n    const char* s = \"Hello World!\\n\";\n    {\n        ofstream ofs(filename, ios::out | ios::binary);\n        BasicOStreamWrapper<ofstream> osw(ofs);\n        for (const char* p = s; *p; p++)\n            osw.Put(*p);\n        osw.Flush();\n    }\n\n    fp = fopen(filename, \"r\");\n    for (const char* p = s; *p; p++)\n        EXPECT_EQ(*p, static_cast<char>(fgetc(fp)));\n    fclose(fp);\n}\n\nTEST(OStreamWrapper, ofstream) {\n    TestFileStream<ofstream>();\n}\n\nTEST(OStreamWrapper, fstream) {\n    TestFileStream<fstream>();\n}\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/pointertest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n#include \"rapidjson/pointer.h\"\n#include \"rapidjson/stringbuffer.h\"\n#include <sstream>\n\nusing namespace rapidjson;\n\nstatic const char kJson[] = \"{\\n\"\n\"    \\\"foo\\\":[\\\"bar\\\", \\\"baz\\\"],\\n\"\n\"    \\\"\\\" : 0,\\n\"\n\"    \\\"a/b\\\" : 1,\\n\"\n\"    \\\"c%d\\\" : 2,\\n\"\n\"    \\\"e^f\\\" : 3,\\n\"\n\"    \\\"g|h\\\" : 4,\\n\"\n\"    \\\"i\\\\\\\\j\\\" : 5,\\n\"\n\"    \\\"k\\\\\\\"l\\\" : 6,\\n\"\n\"    \\\" \\\" : 7,\\n\"\n\"    \\\"m~n\\\" : 8\\n\"\n\"}\";\n\nTEST(Pointer, DefaultConstructor) {\n    Pointer p;\n    EXPECT_TRUE(p.IsValid());\n    EXPECT_EQ(0u, p.GetTokenCount());\n}\n\nTEST(Pointer, Parse) {\n    {\n        Pointer p(\"\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(0u, p.GetTokenCount());\n    }\n\n    {\n        Pointer p(\"/\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(1u, p.GetTokenCount());\n        EXPECT_EQ(0u, p.GetTokens()[0].length);\n        EXPECT_STREQ(\"\", p.GetTokens()[0].name);\n        EXPECT_EQ(kPointerInvalidIndex, p.GetTokens()[0].index);\n    }\n\n    {\n        Pointer p(\"/foo\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(1u, p.GetTokenCount());\n        EXPECT_EQ(3u, p.GetTokens()[0].length);\n        EXPECT_STREQ(\"foo\", p.GetTokens()[0].name);\n        EXPECT_EQ(kPointerInvalidIndex, p.GetTokens()[0].index);\n    }\n\n    #if RAPIDJSON_HAS_STDSTRING\n    {\n        Pointer p(std::string(\"/foo\"));\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(1u, p.GetTokenCount());\n        EXPECT_EQ(3u, p.GetTokens()[0].length);\n        EXPECT_STREQ(\"foo\", p.GetTokens()[0].name);\n        EXPECT_EQ(kPointerInvalidIndex, p.GetTokens()[0].index);\n    }\n    #endif\n\n    {\n        Pointer p(\"/foo/0\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(2u, p.GetTokenCount());\n        EXPECT_EQ(3u, p.GetTokens()[0].length);\n        EXPECT_STREQ(\"foo\", p.GetTokens()[0].name);\n        EXPECT_EQ(kPointerInvalidIndex, p.GetTokens()[0].index);\n        EXPECT_EQ(1u, p.GetTokens()[1].length);\n        EXPECT_STREQ(\"0\", p.GetTokens()[1].name);\n        EXPECT_EQ(0u, p.GetTokens()[1].index);\n    }\n\n    {\n        // Unescape ~1\n        Pointer p(\"/a~1b\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(1u, p.GetTokenCount());\n        EXPECT_EQ(3u, p.GetTokens()[0].length);\n        EXPECT_STREQ(\"a/b\", p.GetTokens()[0].name);\n    }\n\n    {\n        // Unescape ~0\n        Pointer p(\"/m~0n\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(1u, p.GetTokenCount());\n        EXPECT_EQ(3u, p.GetTokens()[0].length);\n        EXPECT_STREQ(\"m~n\", p.GetTokens()[0].name);\n    }\n\n    {\n        // empty name\n        Pointer p(\"/\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(1u, p.GetTokenCount());\n        EXPECT_EQ(0u, p.GetTokens()[0].length);\n        EXPECT_STREQ(\"\", p.GetTokens()[0].name);\n    }\n\n    {\n        // empty and non-empty name\n        Pointer p(\"//a\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(2u, p.GetTokenCount());\n        EXPECT_EQ(0u, p.GetTokens()[0].length);\n        EXPECT_STREQ(\"\", p.GetTokens()[0].name);\n        EXPECT_EQ(1u, p.GetTokens()[1].length);\n        EXPECT_STREQ(\"a\", p.GetTokens()[1].name);\n    }\n\n    {\n        // Null characters\n        Pointer p(\"/\\0\\0\", 3);\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(1u, p.GetTokenCount());\n        EXPECT_EQ(2u, p.GetTokens()[0].length);\n        EXPECT_EQ('\\0', p.GetTokens()[0].name[0]);\n        EXPECT_EQ('\\0', p.GetTokens()[0].name[1]);\n        EXPECT_EQ('\\0', p.GetTokens()[0].name[2]);\n    }\n\n    {\n        // Valid index\n        Pointer p(\"/123\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(1u, p.GetTokenCount());\n        EXPECT_STREQ(\"123\", p.GetTokens()[0].name);\n        EXPECT_EQ(123u, p.GetTokens()[0].index);\n    }\n\n    {\n        // Invalid index (with leading zero)\n        Pointer p(\"/01\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(1u, p.GetTokenCount());\n        EXPECT_STREQ(\"01\", p.GetTokens()[0].name);\n        EXPECT_EQ(kPointerInvalidIndex, p.GetTokens()[0].index);\n    }\n\n    if (sizeof(SizeType) == 4) {\n        // Invalid index (overflow)\n        Pointer p(\"/4294967296\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(1u, p.GetTokenCount());\n        EXPECT_STREQ(\"4294967296\", p.GetTokens()[0].name);\n        EXPECT_EQ(kPointerInvalidIndex, p.GetTokens()[0].index);\n    }\n\n    {\n        // kPointerParseErrorTokenMustBeginWithSolidus\n        Pointer p(\" \");\n        EXPECT_FALSE(p.IsValid());\n        EXPECT_EQ(kPointerParseErrorTokenMustBeginWithSolidus, p.GetParseErrorCode());\n        EXPECT_EQ(0u, p.GetParseErrorOffset());\n    }\n\n    {\n        // kPointerParseErrorInvalidEscape\n        Pointer p(\"/~\");\n        EXPECT_FALSE(p.IsValid());\n        EXPECT_EQ(kPointerParseErrorInvalidEscape, p.GetParseErrorCode());\n        EXPECT_EQ(2u, p.GetParseErrorOffset());\n    }\n\n    {\n        // kPointerParseErrorInvalidEscape\n        Pointer p(\"/~2\");\n        EXPECT_FALSE(p.IsValid());\n        EXPECT_EQ(kPointerParseErrorInvalidEscape, p.GetParseErrorCode());\n        EXPECT_EQ(2u, p.GetParseErrorOffset());\n    }\n}\n\nTEST(Pointer, Parse_URIFragment) {\n    {\n        Pointer p(\"#\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(0u, p.GetTokenCount());\n    }\n\n    {\n        Pointer p(\"#/foo\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(1u, p.GetTokenCount());\n        EXPECT_EQ(3u, p.GetTokens()[0].length);\n        EXPECT_STREQ(\"foo\", p.GetTokens()[0].name);\n    }\n\n    {\n        Pointer p(\"#/foo/0\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(2u, p.GetTokenCount());\n        EXPECT_EQ(3u, p.GetTokens()[0].length);\n        EXPECT_STREQ(\"foo\", p.GetTokens()[0].name);\n        EXPECT_EQ(1u, p.GetTokens()[1].length);\n        EXPECT_STREQ(\"0\", p.GetTokens()[1].name);\n        EXPECT_EQ(0u, p.GetTokens()[1].index);\n    }\n\n    {\n        // Unescape ~1\n        Pointer p(\"#/a~1b\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(1u, p.GetTokenCount());\n        EXPECT_EQ(3u, p.GetTokens()[0].length);\n        EXPECT_STREQ(\"a/b\", p.GetTokens()[0].name);\n    }\n\n    {\n        // Unescape ~0\n        Pointer p(\"#/m~0n\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(1u, p.GetTokenCount());\n        EXPECT_EQ(3u, p.GetTokens()[0].length);\n        EXPECT_STREQ(\"m~n\", p.GetTokens()[0].name);\n    }\n\n    {\n        // empty name\n        Pointer p(\"#/\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(1u, p.GetTokenCount());\n        EXPECT_EQ(0u, p.GetTokens()[0].length);\n        EXPECT_STREQ(\"\", p.GetTokens()[0].name);\n    }\n\n    {\n        // empty and non-empty name\n        Pointer p(\"#//a\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(2u, p.GetTokenCount());\n        EXPECT_EQ(0u, p.GetTokens()[0].length);\n        EXPECT_STREQ(\"\", p.GetTokens()[0].name);\n        EXPECT_EQ(1u, p.GetTokens()[1].length);\n        EXPECT_STREQ(\"a\", p.GetTokens()[1].name);\n    }\n\n    {\n        // Null characters\n        Pointer p(\"#/%00%00\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(1u, p.GetTokenCount());\n        EXPECT_EQ(2u, p.GetTokens()[0].length);\n        EXPECT_EQ('\\0', p.GetTokens()[0].name[0]);\n        EXPECT_EQ('\\0', p.GetTokens()[0].name[1]);\n        EXPECT_EQ('\\0', p.GetTokens()[0].name[2]);\n    }\n\n    {\n        // Percentage Escapes\n        EXPECT_STREQ(\"c%d\", Pointer(\"#/c%25d\").GetTokens()[0].name);\n        EXPECT_STREQ(\"e^f\", Pointer(\"#/e%5Ef\").GetTokens()[0].name);\n        EXPECT_STREQ(\"g|h\", Pointer(\"#/g%7Ch\").GetTokens()[0].name);\n        EXPECT_STREQ(\"i\\\\j\", Pointer(\"#/i%5Cj\").GetTokens()[0].name);\n        EXPECT_STREQ(\"k\\\"l\", Pointer(\"#/k%22l\").GetTokens()[0].name);\n        EXPECT_STREQ(\" \", Pointer(\"#/%20\").GetTokens()[0].name);\n    }\n\n    {\n        // Valid index\n        Pointer p(\"#/123\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(1u, p.GetTokenCount());\n        EXPECT_STREQ(\"123\", p.GetTokens()[0].name);\n        EXPECT_EQ(123u, p.GetTokens()[0].index);\n    }\n\n    {\n        // Invalid index (with leading zero)\n        Pointer p(\"#/01\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(1u, p.GetTokenCount());\n        EXPECT_STREQ(\"01\", p.GetTokens()[0].name);\n        EXPECT_EQ(kPointerInvalidIndex, p.GetTokens()[0].index);\n    }\n\n    if (sizeof(SizeType) == 4) {\n        // Invalid index (overflow)\n        Pointer p(\"#/4294967296\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(1u, p.GetTokenCount());\n        EXPECT_STREQ(\"4294967296\", p.GetTokens()[0].name);\n        EXPECT_EQ(kPointerInvalidIndex, p.GetTokens()[0].index);\n    }\n\n    {\n        // Decode UTF-8 perecent encoding to UTF-8\n        Pointer p(\"#/%C2%A2\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(1u, p.GetTokenCount());\n        EXPECT_STREQ(\"\\xC2\\xA2\", p.GetTokens()[0].name);\n    }\n\n    {\n        // Decode UTF-8 perecent encoding to UTF-16\n        GenericPointer<GenericValue<UTF16<> > > p(L\"#/%C2%A2\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(1u, p.GetTokenCount());\n        EXPECT_EQ(static_cast<UTF16<>::Ch>(0x00A2), p.GetTokens()[0].name[0]);\n        EXPECT_EQ(1u, p.GetTokens()[0].length);\n    }\n\n    {\n        // Decode UTF-8 perecent encoding to UTF-16\n        GenericPointer<GenericValue<UTF16<> > > p(L\"#/%E2%82%AC\");\n        EXPECT_TRUE(p.IsValid());\n        EXPECT_EQ(1u, p.GetTokenCount());\n        EXPECT_EQ(static_cast<UTF16<>::Ch>(0x20AC), p.GetTokens()[0].name[0]);\n        EXPECT_EQ(1u, p.GetTokens()[0].length);\n    }\n\n    {\n        // kPointerParseErrorTokenMustBeginWithSolidus\n        Pointer p(\"# \");\n        EXPECT_FALSE(p.IsValid());\n        EXPECT_EQ(kPointerParseErrorTokenMustBeginWithSolidus, p.GetParseErrorCode());\n        EXPECT_EQ(1u, p.GetParseErrorOffset());\n    }\n\n    {\n        // kPointerParseErrorInvalidEscape\n        Pointer p(\"#/~\");\n        EXPECT_FALSE(p.IsValid());\n        EXPECT_EQ(kPointerParseErrorInvalidEscape, p.GetParseErrorCode());\n        EXPECT_EQ(3u, p.GetParseErrorOffset());\n    }\n\n    {\n        // kPointerParseErrorInvalidEscape\n        Pointer p(\"#/~2\");\n        EXPECT_FALSE(p.IsValid());\n        EXPECT_EQ(kPointerParseErrorInvalidEscape, p.GetParseErrorCode());\n        EXPECT_EQ(3u, p.GetParseErrorOffset());\n    }\n\n    {\n        // kPointerParseErrorInvalidPercentEncoding\n        Pointer p(\"#/%\");\n        EXPECT_FALSE(p.IsValid());\n        EXPECT_EQ(kPointerParseErrorInvalidPercentEncoding, p.GetParseErrorCode());\n        EXPECT_EQ(2u, p.GetParseErrorOffset());\n    }\n\n    {\n        // kPointerParseErrorInvalidPercentEncoding (invalid hex)\n        Pointer p(\"#/%g0\");\n        EXPECT_FALSE(p.IsValid());\n        EXPECT_EQ(kPointerParseErrorInvalidPercentEncoding, p.GetParseErrorCode());\n        EXPECT_EQ(2u, p.GetParseErrorOffset());\n    }\n\n    {\n        // kPointerParseErrorInvalidPercentEncoding (invalid hex)\n        Pointer p(\"#/%0g\");\n        EXPECT_FALSE(p.IsValid());\n        EXPECT_EQ(kPointerParseErrorInvalidPercentEncoding, p.GetParseErrorCode());\n        EXPECT_EQ(2u, p.GetParseErrorOffset());\n    }\n\n    {\n        // kPointerParseErrorInvalidPercentEncoding (incomplete UTF-8 sequence)\n        Pointer p(\"#/%C2\");\n        EXPECT_FALSE(p.IsValid());\n        EXPECT_EQ(kPointerParseErrorInvalidPercentEncoding, p.GetParseErrorCode());\n        EXPECT_EQ(2u, p.GetParseErrorOffset());\n    }\n\n    {\n        // kPointerParseErrorCharacterMustPercentEncode\n        Pointer p(\"#/ \");\n        EXPECT_FALSE(p.IsValid());\n        EXPECT_EQ(kPointerParseErrorCharacterMustPercentEncode, p.GetParseErrorCode());\n        EXPECT_EQ(2u, p.GetParseErrorOffset());\n    }\n\n    {\n        // kPointerParseErrorCharacterMustPercentEncode\n        Pointer p(\"#/\\n\");\n        EXPECT_FALSE(p.IsValid());\n        EXPECT_EQ(kPointerParseErrorCharacterMustPercentEncode, p.GetParseErrorCode());\n        EXPECT_EQ(2u, p.GetParseErrorOffset());\n    }\n}\n\nTEST(Pointer, Stringify) {\n    // Test by roundtrip\n    const char* sources[] = {\n        \"\",\n        \"/foo\",\n        \"/foo/0\",\n        \"/\",\n        \"/a~1b\",\n        \"/c%d\",\n        \"/e^f\",\n        \"/g|h\",\n        \"/i\\\\j\",\n        \"/k\\\"l\",\n        \"/ \",\n        \"/m~0n\",\n        \"/\\xC2\\xA2\",\n        \"/\\xE2\\x82\\xAC\",\n        \"/\\xF0\\x9D\\x84\\x9E\"\n    };\n\n    for (size_t i = 0; i < sizeof(sources) / sizeof(sources[0]); i++) {\n        Pointer p(sources[i]);\n        StringBuffer s;\n        EXPECT_TRUE(p.Stringify(s));\n        EXPECT_STREQ(sources[i], s.GetString());\n\n        // Stringify to URI fragment\n        StringBuffer s2;\n        EXPECT_TRUE(p.StringifyUriFragment(s2));\n        Pointer p2(s2.GetString(), s2.GetSize());\n        EXPECT_TRUE(p2.IsValid());\n        EXPECT_TRUE(p == p2);\n    }\n\n    {\n        // Strigify to URI fragment with an invalid UTF-8 sequence\n        Pointer p(\"/\\xC2\");\n        StringBuffer s;\n        EXPECT_FALSE(p.StringifyUriFragment(s));\n    }\n}\n\n// Construct a Pointer with static tokens, no dynamic allocation involved.\n#define NAME(s) { s, sizeof(s) / sizeof(s[0]) - 1, kPointerInvalidIndex }\n#define INDEX(i) { #i, sizeof(#i) - 1, i }\n\nstatic const Pointer::Token kTokens[] = { NAME(\"foo\"), INDEX(0) }; // equivalent to \"/foo/0\"\n\n#undef NAME\n#undef INDEX\n\nTEST(Pointer, ConstructorWithToken) {\n    Pointer p(kTokens, sizeof(kTokens) / sizeof(kTokens[0]));\n    EXPECT_TRUE(p.IsValid());\n    EXPECT_EQ(2u, p.GetTokenCount());\n    EXPECT_EQ(3u, p.GetTokens()[0].length);\n    EXPECT_STREQ(\"foo\", p.GetTokens()[0].name);\n    EXPECT_EQ(1u, p.GetTokens()[1].length);\n    EXPECT_STREQ(\"0\", p.GetTokens()[1].name);\n    EXPECT_EQ(0u, p.GetTokens()[1].index);\n}\n\nTEST(Pointer, CopyConstructor) {\n    {\n        Pointer p(\"/foo/0\");\n        Pointer q(p);\n        EXPECT_TRUE(q.IsValid());\n        EXPECT_EQ(2u, q.GetTokenCount());\n        EXPECT_EQ(3u, q.GetTokens()[0].length);\n        EXPECT_STREQ(\"foo\", q.GetTokens()[0].name);\n        EXPECT_EQ(1u, q.GetTokens()[1].length);\n        EXPECT_STREQ(\"0\", q.GetTokens()[1].name);\n        EXPECT_EQ(0u, q.GetTokens()[1].index);\n    }\n\n    // Static tokens\n    {\n        Pointer p(kTokens, sizeof(kTokens) / sizeof(kTokens[0]));\n        Pointer q(p);\n        EXPECT_TRUE(q.IsValid());\n        EXPECT_EQ(2u, q.GetTokenCount());\n        EXPECT_EQ(3u, q.GetTokens()[0].length);\n        EXPECT_STREQ(\"foo\", q.GetTokens()[0].name);\n        EXPECT_EQ(1u, q.GetTokens()[1].length);\n        EXPECT_STREQ(\"0\", q.GetTokens()[1].name);\n        EXPECT_EQ(0u, q.GetTokens()[1].index);\n    }\n}\n\nTEST(Pointer, Assignment) {\n    {\n        Pointer p(\"/foo/0\");\n        Pointer q;\n        q = p;\n        EXPECT_TRUE(q.IsValid());\n        EXPECT_EQ(2u, q.GetTokenCount());\n        EXPECT_EQ(3u, q.GetTokens()[0].length);\n        EXPECT_STREQ(\"foo\", q.GetTokens()[0].name);\n        EXPECT_EQ(1u, q.GetTokens()[1].length);\n        EXPECT_STREQ(\"0\", q.GetTokens()[1].name);\n        EXPECT_EQ(0u, q.GetTokens()[1].index);\n        q = q;\n        EXPECT_TRUE(q.IsValid());\n        EXPECT_EQ(2u, q.GetTokenCount());\n        EXPECT_EQ(3u, q.GetTokens()[0].length);\n        EXPECT_STREQ(\"foo\", q.GetTokens()[0].name);\n        EXPECT_EQ(1u, q.GetTokens()[1].length);\n        EXPECT_STREQ(\"0\", q.GetTokens()[1].name);\n        EXPECT_EQ(0u, q.GetTokens()[1].index);\n    }\n\n    // Static tokens\n    {\n        Pointer p(kTokens, sizeof(kTokens) / sizeof(kTokens[0]));\n        Pointer q;\n        q = p;\n        EXPECT_TRUE(q.IsValid());\n        EXPECT_EQ(2u, q.GetTokenCount());\n        EXPECT_EQ(3u, q.GetTokens()[0].length);\n        EXPECT_STREQ(\"foo\", q.GetTokens()[0].name);\n        EXPECT_EQ(1u, q.GetTokens()[1].length);\n        EXPECT_STREQ(\"0\", q.GetTokens()[1].name);\n        EXPECT_EQ(0u, q.GetTokens()[1].index);\n    }\n}\n\nTEST(Pointer, Append) {\n    {\n        Pointer p;\n        Pointer q = p.Append(\"foo\");\n        EXPECT_TRUE(Pointer(\"/foo\") == q);\n        q = q.Append(1234);\n        EXPECT_TRUE(Pointer(\"/foo/1234\") == q);\n        q = q.Append(\"\");\n        EXPECT_TRUE(Pointer(\"/foo/1234/\") == q);\n    }\n\n    {\n        Pointer p;\n        Pointer q = p.Append(Value(\"foo\").Move());\n        EXPECT_TRUE(Pointer(\"/foo\") == q);\n        q = q.Append(Value(1234).Move());\n        EXPECT_TRUE(Pointer(\"/foo/1234\") == q);\n        q = q.Append(Value(kStringType).Move());\n        EXPECT_TRUE(Pointer(\"/foo/1234/\") == q);\n    }\n\n#if RAPIDJSON_HAS_STDSTRING\n    {\n        Pointer p;\n        Pointer q = p.Append(std::string(\"foo\"));\n        EXPECT_TRUE(Pointer(\"/foo\") == q);\n    }\n#endif\n}\n\nTEST(Pointer, Equality) {\n    EXPECT_TRUE(Pointer(\"/foo/0\") == Pointer(\"/foo/0\"));\n    EXPECT_FALSE(Pointer(\"/foo/0\") == Pointer(\"/foo/1\"));\n    EXPECT_FALSE(Pointer(\"/foo/0\") == Pointer(\"/foo/0/1\"));\n    EXPECT_FALSE(Pointer(\"/foo/0\") == Pointer(\"a\"));\n    EXPECT_FALSE(Pointer(\"a\") == Pointer(\"a\")); // Invalid always not equal\n}\n\nTEST(Pointer, Inequality) {\n    EXPECT_FALSE(Pointer(\"/foo/0\") != Pointer(\"/foo/0\"));\n    EXPECT_TRUE(Pointer(\"/foo/0\") != Pointer(\"/foo/1\"));\n    EXPECT_TRUE(Pointer(\"/foo/0\") != Pointer(\"/foo/0/1\"));\n    EXPECT_TRUE(Pointer(\"/foo/0\") != Pointer(\"a\"));\n    EXPECT_TRUE(Pointer(\"a\") != Pointer(\"a\")); // Invalid always not equal\n}\n\nTEST(Pointer, Create) {\n    Document d;\n    {\n        Value* v = &Pointer(\"\").Create(d, d.GetAllocator());\n        EXPECT_EQ(&d, v);\n    }\n    {\n        Value* v = &Pointer(\"/foo\").Create(d, d.GetAllocator());\n        EXPECT_EQ(&d[\"foo\"], v);\n    }\n    {\n        Value* v = &Pointer(\"/foo/0\").Create(d, d.GetAllocator());\n        EXPECT_EQ(&d[\"foo\"][0], v);\n    }\n    {\n        Value* v = &Pointer(\"/foo/-\").Create(d, d.GetAllocator());\n        EXPECT_EQ(&d[\"foo\"][1], v);\n    }\n\n    {\n        Value* v = &Pointer(\"/foo/-/-\").Create(d, d.GetAllocator());\n        // \"foo/-\" is a newly created null value x.\n        // \"foo/-/-\" finds that x is not an array, it converts x to empty object\n        // and treats - as \"-\" member name\n        EXPECT_EQ(&d[\"foo\"][2][\"-\"], v);\n    }\n\n    {\n        // Document with no allocator\n        Value* v = &Pointer(\"/foo/-\").Create(d);\n        EXPECT_EQ(&d[\"foo\"][3], v);\n    }\n\n    {\n        // Value (not document) must give allocator\n        Value* v = &Pointer(\"/-\").Create(d[\"foo\"], d.GetAllocator());\n        EXPECT_EQ(&d[\"foo\"][4], v);\n    }\n}\n\nTEST(Pointer, Get) {\n    Document d;\n    d.Parse(kJson);\n\n    EXPECT_EQ(&d, Pointer(\"\").Get(d));\n    EXPECT_EQ(&d[\"foo\"], Pointer(\"/foo\").Get(d));\n    EXPECT_EQ(&d[\"foo\"][0], Pointer(\"/foo/0\").Get(d));\n    EXPECT_EQ(&d[\"\"], Pointer(\"/\").Get(d));\n    EXPECT_EQ(&d[\"a/b\"], Pointer(\"/a~1b\").Get(d));\n    EXPECT_EQ(&d[\"c%d\"], Pointer(\"/c%d\").Get(d));\n    EXPECT_EQ(&d[\"e^f\"], Pointer(\"/e^f\").Get(d));\n    EXPECT_EQ(&d[\"g|h\"], Pointer(\"/g|h\").Get(d));\n    EXPECT_EQ(&d[\"i\\\\j\"], Pointer(\"/i\\\\j\").Get(d));\n    EXPECT_EQ(&d[\"k\\\"l\"], Pointer(\"/k\\\"l\").Get(d));\n    EXPECT_EQ(&d[\" \"], Pointer(\"/ \").Get(d));\n    EXPECT_EQ(&d[\"m~n\"], Pointer(\"/m~0n\").Get(d));\n    EXPECT_TRUE(Pointer(\"/abc\").Get(d) == 0);\n    size_t unresolvedTokenIndex;\n    EXPECT_TRUE(Pointer(\"/foo/2\").Get(d, &unresolvedTokenIndex) == 0); // Out of boundary\n    EXPECT_EQ(1, unresolvedTokenIndex);\n    EXPECT_TRUE(Pointer(\"/foo/a\").Get(d, &unresolvedTokenIndex) == 0); // \"/foo\" is an array, cannot query by \"a\"\n    EXPECT_EQ(1, unresolvedTokenIndex);\n    EXPECT_TRUE(Pointer(\"/foo/0/0\").Get(d, &unresolvedTokenIndex) == 0); // \"/foo/0\" is an string, cannot further query\n    EXPECT_EQ(2, unresolvedTokenIndex);\n    EXPECT_TRUE(Pointer(\"/foo/0/a\").Get(d, &unresolvedTokenIndex) == 0); // \"/foo/0\" is an string, cannot further query\n    EXPECT_EQ(2, unresolvedTokenIndex);\n}\n\nTEST(Pointer, GetWithDefault) {\n    Document d;\n    d.Parse(kJson);\n\n    // Value version\n    Document::AllocatorType& a = d.GetAllocator();\n    const Value v(\"qux\");\n    EXPECT_TRUE(Value(\"bar\") == Pointer(\"/foo/0\").GetWithDefault(d, v, a));\n    EXPECT_TRUE(Value(\"baz\") == Pointer(\"/foo/1\").GetWithDefault(d, v, a));\n    EXPECT_TRUE(Value(\"qux\") == Pointer(\"/foo/2\").GetWithDefault(d, v, a));\n    EXPECT_TRUE(Value(\"last\") == Pointer(\"/foo/-\").GetWithDefault(d, Value(\"last\").Move(), a));\n    EXPECT_STREQ(\"last\", d[\"foo\"][3].GetString());\n\n    EXPECT_TRUE(Pointer(\"/foo/null\").GetWithDefault(d, Value().Move(), a).IsNull());\n    EXPECT_TRUE(Pointer(\"/foo/null\").GetWithDefault(d, \"x\", a).IsNull());\n\n    // Generic version\n    EXPECT_EQ(-1, Pointer(\"/foo/int\").GetWithDefault(d, -1, a).GetInt());\n    EXPECT_EQ(-1, Pointer(\"/foo/int\").GetWithDefault(d, -2, a).GetInt());\n    EXPECT_EQ(0x87654321, Pointer(\"/foo/uint\").GetWithDefault(d, 0x87654321, a).GetUint());\n    EXPECT_EQ(0x87654321, Pointer(\"/foo/uint\").GetWithDefault(d, 0x12345678, a).GetUint());\n\n    const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));\n    EXPECT_EQ(i64, Pointer(\"/foo/int64\").GetWithDefault(d, i64, a).GetInt64());\n    EXPECT_EQ(i64, Pointer(\"/foo/int64\").GetWithDefault(d, i64 + 1, a).GetInt64());\n\n    const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);\n    EXPECT_EQ(u64, Pointer(\"/foo/uint64\").GetWithDefault(d, u64, a).GetUint64());\n    EXPECT_EQ(u64, Pointer(\"/foo/uint64\").GetWithDefault(d, u64 - 1, a).GetUint64());\n\n    EXPECT_TRUE(Pointer(\"/foo/true\").GetWithDefault(d, true, a).IsTrue());\n    EXPECT_TRUE(Pointer(\"/foo/true\").GetWithDefault(d, false, a).IsTrue());\n\n    EXPECT_TRUE(Pointer(\"/foo/false\").GetWithDefault(d, false, a).IsFalse());\n    EXPECT_TRUE(Pointer(\"/foo/false\").GetWithDefault(d, true, a).IsFalse());\n\n    // StringRef version\n    EXPECT_STREQ(\"Hello\", Pointer(\"/foo/hello\").GetWithDefault(d, \"Hello\", a).GetString());\n\n    // Copy string version\n    {\n        char buffer[256];\n        strcpy(buffer, \"World\");\n        EXPECT_STREQ(\"World\", Pointer(\"/foo/world\").GetWithDefault(d, buffer, a).GetString());\n        memset(buffer, 0, sizeof(buffer));\n    }\n    EXPECT_STREQ(\"World\", GetValueByPointer(d, \"/foo/world\")->GetString());\n\n#if RAPIDJSON_HAS_STDSTRING\n    EXPECT_STREQ(\"C++\", Pointer(\"/foo/C++\").GetWithDefault(d, std::string(\"C++\"), a).GetString());\n#endif\n}\n\nTEST(Pointer, GetWithDefault_NoAllocator) {\n    Document d;\n    d.Parse(kJson);\n\n    // Value version\n    const Value v(\"qux\");\n    EXPECT_TRUE(Value(\"bar\") == Pointer(\"/foo/0\").GetWithDefault(d, v));\n    EXPECT_TRUE(Value(\"baz\") == Pointer(\"/foo/1\").GetWithDefault(d, v));\n    EXPECT_TRUE(Value(\"qux\") == Pointer(\"/foo/2\").GetWithDefault(d, v));\n    EXPECT_TRUE(Value(\"last\") == Pointer(\"/foo/-\").GetWithDefault(d, Value(\"last\").Move()));\n    EXPECT_STREQ(\"last\", d[\"foo\"][3].GetString());\n\n    EXPECT_TRUE(Pointer(\"/foo/null\").GetWithDefault(d, Value().Move()).IsNull());\n    EXPECT_TRUE(Pointer(\"/foo/null\").GetWithDefault(d, \"x\").IsNull());\n\n    // Generic version\n    EXPECT_EQ(-1, Pointer(\"/foo/int\").GetWithDefault(d, -1).GetInt());\n    EXPECT_EQ(-1, Pointer(\"/foo/int\").GetWithDefault(d, -2).GetInt());\n    EXPECT_EQ(0x87654321, Pointer(\"/foo/uint\").GetWithDefault(d, 0x87654321).GetUint());\n    EXPECT_EQ(0x87654321, Pointer(\"/foo/uint\").GetWithDefault(d, 0x12345678).GetUint());\n\n    const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));\n    EXPECT_EQ(i64, Pointer(\"/foo/int64\").GetWithDefault(d, i64).GetInt64());\n    EXPECT_EQ(i64, Pointer(\"/foo/int64\").GetWithDefault(d, i64 + 1).GetInt64());\n\n    const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);\n    EXPECT_EQ(u64, Pointer(\"/foo/uint64\").GetWithDefault(d, u64).GetUint64());\n    EXPECT_EQ(u64, Pointer(\"/foo/uint64\").GetWithDefault(d, u64 - 1).GetUint64());\n\n    EXPECT_TRUE(Pointer(\"/foo/true\").GetWithDefault(d, true).IsTrue());\n    EXPECT_TRUE(Pointer(\"/foo/true\").GetWithDefault(d, false).IsTrue());\n\n    EXPECT_TRUE(Pointer(\"/foo/false\").GetWithDefault(d, false).IsFalse());\n    EXPECT_TRUE(Pointer(\"/foo/false\").GetWithDefault(d, true).IsFalse());\n\n    // StringRef version\n    EXPECT_STREQ(\"Hello\", Pointer(\"/foo/hello\").GetWithDefault(d, \"Hello\").GetString());\n\n    // Copy string version\n    {\n        char buffer[256];\n        strcpy(buffer, \"World\");\n        EXPECT_STREQ(\"World\", Pointer(\"/foo/world\").GetWithDefault(d, buffer).GetString());\n        memset(buffer, 0, sizeof(buffer));\n    }\n    EXPECT_STREQ(\"World\", GetValueByPointer(d, \"/foo/world\")->GetString());\n\n#if RAPIDJSON_HAS_STDSTRING\n    EXPECT_STREQ(\"C++\", Pointer(\"/foo/C++\").GetWithDefault(d, std::string(\"C++\")).GetString());\n#endif\n}\n\nTEST(Pointer, Set) {\n    Document d;\n    d.Parse(kJson);\n    Document::AllocatorType& a = d.GetAllocator();\n    \n    // Value version\n    Pointer(\"/foo/0\").Set(d, Value(123).Move(), a);\n    EXPECT_EQ(123, d[\"foo\"][0].GetInt());\n\n    Pointer(\"/foo/-\").Set(d, Value(456).Move(), a);\n    EXPECT_EQ(456, d[\"foo\"][2].GetInt());\n\n    Pointer(\"/foo/null\").Set(d, Value().Move(), a);\n    EXPECT_TRUE(GetValueByPointer(d, \"/foo/null\")->IsNull());\n\n    // Const Value version\n    const Value foo(d[\"foo\"], a);\n    Pointer(\"/clone\").Set(d, foo, a);\n    EXPECT_EQ(foo, *GetValueByPointer(d, \"/clone\"));\n\n    // Generic version\n    Pointer(\"/foo/int\").Set(d, -1, a);\n    EXPECT_EQ(-1, GetValueByPointer(d, \"/foo/int\")->GetInt());\n\n    Pointer(\"/foo/uint\").Set(d, 0x87654321, a);\n    EXPECT_EQ(0x87654321, GetValueByPointer(d, \"/foo/uint\")->GetUint());\n\n    const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));\n    Pointer(\"/foo/int64\").Set(d, i64, a);\n    EXPECT_EQ(i64, GetValueByPointer(d, \"/foo/int64\")->GetInt64());\n\n    const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);\n    Pointer(\"/foo/uint64\").Set(d, u64, a);\n    EXPECT_EQ(u64, GetValueByPointer(d, \"/foo/uint64\")->GetUint64());\n\n    Pointer(\"/foo/true\").Set(d, true, a);\n    EXPECT_TRUE(GetValueByPointer(d, \"/foo/true\")->IsTrue());\n\n    Pointer(\"/foo/false\").Set(d, false, a);\n    EXPECT_TRUE(GetValueByPointer(d, \"/foo/false\")->IsFalse());\n\n    // StringRef version\n    Pointer(\"/foo/hello\").Set(d, \"Hello\", a);\n    EXPECT_STREQ(\"Hello\", GetValueByPointer(d, \"/foo/hello\")->GetString());\n\n    // Copy string version\n    {\n        char buffer[256];\n        strcpy(buffer, \"World\");\n        Pointer(\"/foo/world\").Set(d, buffer, a);\n        memset(buffer, 0, sizeof(buffer));\n    }\n    EXPECT_STREQ(\"World\", GetValueByPointer(d, \"/foo/world\")->GetString());\n\n#if RAPIDJSON_HAS_STDSTRING\n    Pointer(\"/foo/c++\").Set(d, std::string(\"C++\"), a);\n    EXPECT_STREQ(\"C++\", GetValueByPointer(d, \"/foo/c++\")->GetString());\n#endif\n}\n\nTEST(Pointer, Set_NoAllocator) {\n    Document d;\n    d.Parse(kJson);\n    \n    // Value version\n    Pointer(\"/foo/0\").Set(d, Value(123).Move());\n    EXPECT_EQ(123, d[\"foo\"][0].GetInt());\n\n    Pointer(\"/foo/-\").Set(d, Value(456).Move());\n    EXPECT_EQ(456, d[\"foo\"][2].GetInt());\n\n    Pointer(\"/foo/null\").Set(d, Value().Move());\n    EXPECT_TRUE(GetValueByPointer(d, \"/foo/null\")->IsNull());\n\n    // Const Value version\n    const Value foo(d[\"foo\"], d.GetAllocator());\n    Pointer(\"/clone\").Set(d, foo);\n    EXPECT_EQ(foo, *GetValueByPointer(d, \"/clone\"));\n\n    // Generic version\n    Pointer(\"/foo/int\").Set(d, -1);\n    EXPECT_EQ(-1, GetValueByPointer(d, \"/foo/int\")->GetInt());\n\n    Pointer(\"/foo/uint\").Set(d, 0x87654321);\n    EXPECT_EQ(0x87654321, GetValueByPointer(d, \"/foo/uint\")->GetUint());\n\n    const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));\n    Pointer(\"/foo/int64\").Set(d, i64);\n    EXPECT_EQ(i64, GetValueByPointer(d, \"/foo/int64\")->GetInt64());\n\n    const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);\n    Pointer(\"/foo/uint64\").Set(d, u64);\n    EXPECT_EQ(u64, GetValueByPointer(d, \"/foo/uint64\")->GetUint64());\n\n    Pointer(\"/foo/true\").Set(d, true);\n    EXPECT_TRUE(GetValueByPointer(d, \"/foo/true\")->IsTrue());\n\n    Pointer(\"/foo/false\").Set(d, false);\n    EXPECT_TRUE(GetValueByPointer(d, \"/foo/false\")->IsFalse());\n\n    // StringRef version\n    Pointer(\"/foo/hello\").Set(d, \"Hello\");\n    EXPECT_STREQ(\"Hello\", GetValueByPointer(d, \"/foo/hello\")->GetString());\n\n    // Copy string version\n    {\n        char buffer[256];\n        strcpy(buffer, \"World\");\n        Pointer(\"/foo/world\").Set(d, buffer);\n        memset(buffer, 0, sizeof(buffer));\n    }\n    EXPECT_STREQ(\"World\", GetValueByPointer(d, \"/foo/world\")->GetString());\n\n#if RAPIDJSON_HAS_STDSTRING\n    Pointer(\"/foo/c++\").Set(d, std::string(\"C++\"));\n    EXPECT_STREQ(\"C++\", GetValueByPointer(d, \"/foo/c++\")->GetString());\n#endif\n}\n\nTEST(Pointer, Swap) {\n    Document d;\n    d.Parse(kJson);\n    Document::AllocatorType& a = d.GetAllocator();\n    Pointer(\"/foo/0\").Swap(d, *Pointer(\"/foo/1\").Get(d), a);\n    EXPECT_STREQ(\"baz\", d[\"foo\"][0].GetString());\n    EXPECT_STREQ(\"bar\", d[\"foo\"][1].GetString());\n}\n\nTEST(Pointer, Swap_NoAllocator) {\n    Document d;\n    d.Parse(kJson);\n    Pointer(\"/foo/0\").Swap(d, *Pointer(\"/foo/1\").Get(d));\n    EXPECT_STREQ(\"baz\", d[\"foo\"][0].GetString());\n    EXPECT_STREQ(\"bar\", d[\"foo\"][1].GetString());\n}\n\nTEST(Pointer, Erase) {\n    Document d;\n    d.Parse(kJson);\n\n    EXPECT_FALSE(Pointer(\"\").Erase(d));\n    EXPECT_FALSE(Pointer(\"/nonexist\").Erase(d));\n    EXPECT_FALSE(Pointer(\"/nonexist/nonexist\").Erase(d));\n    EXPECT_FALSE(Pointer(\"/foo/nonexist\").Erase(d));\n    EXPECT_FALSE(Pointer(\"/foo/nonexist/nonexist\").Erase(d));\n    EXPECT_FALSE(Pointer(\"/foo/0/nonexist\").Erase(d));\n    EXPECT_FALSE(Pointer(\"/foo/0/nonexist/nonexist\").Erase(d));\n    EXPECT_FALSE(Pointer(\"/foo/2/nonexist\").Erase(d));\n    EXPECT_TRUE(Pointer(\"/foo/0\").Erase(d));\n    EXPECT_EQ(1u, d[\"foo\"].Size());\n    EXPECT_STREQ(\"baz\", d[\"foo\"][0].GetString());\n    EXPECT_TRUE(Pointer(\"/foo/0\").Erase(d));\n    EXPECT_TRUE(d[\"foo\"].Empty());\n    EXPECT_TRUE(Pointer(\"/foo\").Erase(d));\n    EXPECT_TRUE(Pointer(\"/foo\").Get(d) == 0);\n\n    Pointer(\"/a/0/b/0\").Create(d);\n\n    EXPECT_TRUE(Pointer(\"/a/0/b/0\").Get(d) != 0);\n    EXPECT_TRUE(Pointer(\"/a/0/b/0\").Erase(d));\n    EXPECT_TRUE(Pointer(\"/a/0/b/0\").Get(d) == 0);\n\n    EXPECT_TRUE(Pointer(\"/a/0/b\").Get(d) != 0);\n    EXPECT_TRUE(Pointer(\"/a/0/b\").Erase(d));\n    EXPECT_TRUE(Pointer(\"/a/0/b\").Get(d) == 0);\n\n    EXPECT_TRUE(Pointer(\"/a/0\").Get(d) != 0);\n    EXPECT_TRUE(Pointer(\"/a/0\").Erase(d));\n    EXPECT_TRUE(Pointer(\"/a/0\").Get(d) == 0);\n\n    EXPECT_TRUE(Pointer(\"/a\").Get(d) != 0);\n    EXPECT_TRUE(Pointer(\"/a\").Erase(d));\n    EXPECT_TRUE(Pointer(\"/a\").Get(d) == 0);\n}\n\nTEST(Pointer, CreateValueByPointer) {\n    Document d;\n    Document::AllocatorType& a = d.GetAllocator();\n\n    {\n        Value& v = CreateValueByPointer(d, Pointer(\"/foo/0\"), a);\n        EXPECT_EQ(&d[\"foo\"][0], &v);\n    }\n    {\n        Value& v = CreateValueByPointer(d, \"/foo/1\", a);\n        EXPECT_EQ(&d[\"foo\"][1], &v);\n    }\n}\n\nTEST(Pointer, CreateValueByPointer_NoAllocator) {\n    Document d;\n\n    {\n        Value& v = CreateValueByPointer(d, Pointer(\"/foo/0\"));\n        EXPECT_EQ(&d[\"foo\"][0], &v);\n    }\n    {\n        Value& v = CreateValueByPointer(d, \"/foo/1\");\n        EXPECT_EQ(&d[\"foo\"][1], &v);\n    }\n}\n\nTEST(Pointer, GetValueByPointer) {\n    Document d;\n    d.Parse(kJson);\n\n    EXPECT_EQ(&d[\"foo\"][0], GetValueByPointer(d, Pointer(\"/foo/0\")));\n    EXPECT_EQ(&d[\"foo\"][0], GetValueByPointer(d, \"/foo/0\"));\n\n    size_t unresolvedTokenIndex;\n    EXPECT_TRUE(GetValueByPointer(d, \"/foo/2\", &unresolvedTokenIndex) == 0); // Out of boundary\n    EXPECT_EQ(1, unresolvedTokenIndex);\n    EXPECT_TRUE(GetValueByPointer(d, \"/foo/a\", &unresolvedTokenIndex) == 0); // \"/foo\" is an array, cannot query by \"a\"\n    EXPECT_EQ(1, unresolvedTokenIndex);\n    EXPECT_TRUE(GetValueByPointer(d, \"/foo/0/0\", &unresolvedTokenIndex) == 0); // \"/foo/0\" is an string, cannot further query\n    EXPECT_EQ(2, unresolvedTokenIndex);\n    EXPECT_TRUE(GetValueByPointer(d, \"/foo/0/a\", &unresolvedTokenIndex) == 0); // \"/foo/0\" is an string, cannot further query\n    EXPECT_EQ(2, unresolvedTokenIndex);\n\n    // const version\n    const Value& v = d;\n    EXPECT_EQ(&d[\"foo\"][0], GetValueByPointer(v, Pointer(\"/foo/0\")));\n    EXPECT_EQ(&d[\"foo\"][0], GetValueByPointer(v, \"/foo/0\"));\n\n    EXPECT_TRUE(GetValueByPointer(v, \"/foo/2\", &unresolvedTokenIndex) == 0); // Out of boundary\n    EXPECT_EQ(1, unresolvedTokenIndex);\n    EXPECT_TRUE(GetValueByPointer(v, \"/foo/a\", &unresolvedTokenIndex) == 0); // \"/foo\" is an array, cannot query by \"a\"\n    EXPECT_EQ(1, unresolvedTokenIndex);\n    EXPECT_TRUE(GetValueByPointer(v, \"/foo/0/0\", &unresolvedTokenIndex) == 0); // \"/foo/0\" is an string, cannot further query\n    EXPECT_EQ(2, unresolvedTokenIndex);\n    EXPECT_TRUE(GetValueByPointer(v, \"/foo/0/a\", &unresolvedTokenIndex) == 0); // \"/foo/0\" is an string, cannot further query\n    EXPECT_EQ(2, unresolvedTokenIndex);\n\n}\n\nTEST(Pointer, GetValueByPointerWithDefault_Pointer) {\n    Document d;\n    d.Parse(kJson);\n\n    Document::AllocatorType& a = d.GetAllocator();\n    const Value v(\"qux\");\n    EXPECT_TRUE(Value(\"bar\") == GetValueByPointerWithDefault(d, Pointer(\"/foo/0\"), v, a));\n    EXPECT_TRUE(Value(\"bar\") == GetValueByPointerWithDefault(d, Pointer(\"/foo/0\"), v, a));\n    EXPECT_TRUE(Value(\"baz\") == GetValueByPointerWithDefault(d, Pointer(\"/foo/1\"), v, a));\n    EXPECT_TRUE(Value(\"qux\") == GetValueByPointerWithDefault(d, Pointer(\"/foo/2\"), v, a));\n    EXPECT_TRUE(Value(\"last\") == GetValueByPointerWithDefault(d, Pointer(\"/foo/-\"), Value(\"last\").Move(), a));\n    EXPECT_STREQ(\"last\", d[\"foo\"][3].GetString());\n\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer(\"/foo/null\"), Value().Move(), a).IsNull());\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer(\"/foo/null\"), \"x\", a).IsNull());\n\n    // Generic version\n    EXPECT_EQ(-1, GetValueByPointerWithDefault(d, Pointer(\"/foo/int\"), -1, a).GetInt());\n    EXPECT_EQ(-1, GetValueByPointerWithDefault(d, Pointer(\"/foo/int\"), -2, a).GetInt());\n    EXPECT_EQ(0x87654321, GetValueByPointerWithDefault(d, Pointer(\"/foo/uint\"), 0x87654321, a).GetUint());\n    EXPECT_EQ(0x87654321, GetValueByPointerWithDefault(d, Pointer(\"/foo/uint\"), 0x12345678, a).GetUint());\n\n    const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));\n    EXPECT_EQ(i64, GetValueByPointerWithDefault(d, Pointer(\"/foo/int64\"), i64, a).GetInt64());\n    EXPECT_EQ(i64, GetValueByPointerWithDefault(d, Pointer(\"/foo/int64\"), i64 + 1, a).GetInt64());\n\n    const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);\n    EXPECT_EQ(u64, GetValueByPointerWithDefault(d, Pointer(\"/foo/uint64\"), u64, a).GetUint64());\n    EXPECT_EQ(u64, GetValueByPointerWithDefault(d, Pointer(\"/foo/uint64\"), u64 - 1, a).GetUint64());\n\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer(\"/foo/true\"), true, a).IsTrue());\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer(\"/foo/true\"), false, a).IsTrue());\n\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer(\"/foo/false\"), false, a).IsFalse());\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer(\"/foo/false\"), true, a).IsFalse());\n\n    // StringRef version\n    EXPECT_STREQ(\"Hello\", GetValueByPointerWithDefault(d, Pointer(\"/foo/hello\"), \"Hello\", a).GetString());\n\n    // Copy string version\n    {\n        char buffer[256];\n        strcpy(buffer, \"World\");\n        EXPECT_STREQ(\"World\", GetValueByPointerWithDefault(d, Pointer(\"/foo/world\"), buffer, a).GetString());\n        memset(buffer, 0, sizeof(buffer));\n    }\n    EXPECT_STREQ(\"World\", GetValueByPointer(d, Pointer(\"/foo/world\"))->GetString());\n\n#if RAPIDJSON_HAS_STDSTRING\n    EXPECT_STREQ(\"C++\", GetValueByPointerWithDefault(d, Pointer(\"/foo/C++\"), std::string(\"C++\"), a).GetString());\n#endif\n}\n\nTEST(Pointer, GetValueByPointerWithDefault_String) {\n    Document d;\n    d.Parse(kJson);\n\n    Document::AllocatorType& a = d.GetAllocator();\n    const Value v(\"qux\");\n    EXPECT_TRUE(Value(\"bar\") == GetValueByPointerWithDefault(d, \"/foo/0\", v, a));\n    EXPECT_TRUE(Value(\"bar\") == GetValueByPointerWithDefault(d, \"/foo/0\", v, a));\n    EXPECT_TRUE(Value(\"baz\") == GetValueByPointerWithDefault(d, \"/foo/1\", v, a));\n    EXPECT_TRUE(Value(\"qux\") == GetValueByPointerWithDefault(d, \"/foo/2\", v, a));\n    EXPECT_TRUE(Value(\"last\") == GetValueByPointerWithDefault(d, \"/foo/-\", Value(\"last\").Move(), a));\n    EXPECT_STREQ(\"last\", d[\"foo\"][3].GetString());\n\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, \"/foo/null\", Value().Move(), a).IsNull());\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, \"/foo/null\", \"x\", a).IsNull());\n\n    // Generic version\n    EXPECT_EQ(-1, GetValueByPointerWithDefault(d, \"/foo/int\", -1, a).GetInt());\n    EXPECT_EQ(-1, GetValueByPointerWithDefault(d, \"/foo/int\", -2, a).GetInt());\n    EXPECT_EQ(0x87654321, GetValueByPointerWithDefault(d, \"/foo/uint\", 0x87654321, a).GetUint());\n    EXPECT_EQ(0x87654321, GetValueByPointerWithDefault(d, \"/foo/uint\", 0x12345678, a).GetUint());\n\n    const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));\n    EXPECT_EQ(i64, GetValueByPointerWithDefault(d, \"/foo/int64\", i64, a).GetInt64());\n    EXPECT_EQ(i64, GetValueByPointerWithDefault(d, \"/foo/int64\", i64 + 1, a).GetInt64());\n\n    const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);\n    EXPECT_EQ(u64, GetValueByPointerWithDefault(d, \"/foo/uint64\", u64, a).GetUint64());\n    EXPECT_EQ(u64, GetValueByPointerWithDefault(d, \"/foo/uint64\", u64 - 1, a).GetUint64());\n\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, \"/foo/true\", true, a).IsTrue());\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, \"/foo/true\", false, a).IsTrue());\n\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, \"/foo/false\", false, a).IsFalse());\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, \"/foo/false\", true, a).IsFalse());\n\n    // StringRef version\n    EXPECT_STREQ(\"Hello\", GetValueByPointerWithDefault(d, \"/foo/hello\", \"Hello\", a).GetString());\n\n    // Copy string version\n    {\n        char buffer[256];\n        strcpy(buffer, \"World\");\n        EXPECT_STREQ(\"World\", GetValueByPointerWithDefault(d, \"/foo/world\", buffer, a).GetString());\n        memset(buffer, 0, sizeof(buffer));\n    }\n    EXPECT_STREQ(\"World\", GetValueByPointer(d, \"/foo/world\")->GetString());\n\n#if RAPIDJSON_HAS_STDSTRING\n    EXPECT_STREQ(\"C++\", GetValueByPointerWithDefault(d, \"/foo/C++\", std::string(\"C++\"), a).GetString());\n#endif\n}\n\nTEST(Pointer, GetValueByPointerWithDefault_Pointer_NoAllocator) {\n    Document d;\n    d.Parse(kJson);\n\n    const Value v(\"qux\");\n    EXPECT_TRUE(Value(\"bar\") == GetValueByPointerWithDefault(d, Pointer(\"/foo/0\"), v));\n    EXPECT_TRUE(Value(\"bar\") == GetValueByPointerWithDefault(d, Pointer(\"/foo/0\"), v));\n    EXPECT_TRUE(Value(\"baz\") == GetValueByPointerWithDefault(d, Pointer(\"/foo/1\"), v));\n    EXPECT_TRUE(Value(\"qux\") == GetValueByPointerWithDefault(d, Pointer(\"/foo/2\"), v));\n    EXPECT_TRUE(Value(\"last\") == GetValueByPointerWithDefault(d, Pointer(\"/foo/-\"), Value(\"last\").Move()));\n    EXPECT_STREQ(\"last\", d[\"foo\"][3].GetString());\n\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer(\"/foo/null\"), Value().Move()).IsNull());\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer(\"/foo/null\"), \"x\").IsNull());\n\n    // Generic version\n    EXPECT_EQ(-1, GetValueByPointerWithDefault(d, Pointer(\"/foo/int\"), -1).GetInt());\n    EXPECT_EQ(-1, GetValueByPointerWithDefault(d, Pointer(\"/foo/int\"), -2).GetInt());\n    EXPECT_EQ(0x87654321, GetValueByPointerWithDefault(d, Pointer(\"/foo/uint\"), 0x87654321).GetUint());\n    EXPECT_EQ(0x87654321, GetValueByPointerWithDefault(d, Pointer(\"/foo/uint\"), 0x12345678).GetUint());\n\n    const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));\n    EXPECT_EQ(i64, GetValueByPointerWithDefault(d, Pointer(\"/foo/int64\"), i64).GetInt64());\n    EXPECT_EQ(i64, GetValueByPointerWithDefault(d, Pointer(\"/foo/int64\"), i64 + 1).GetInt64());\n\n    const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);\n    EXPECT_EQ(u64, GetValueByPointerWithDefault(d, Pointer(\"/foo/uint64\"), u64).GetUint64());\n    EXPECT_EQ(u64, GetValueByPointerWithDefault(d, Pointer(\"/foo/uint64\"), u64 - 1).GetUint64());\n\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer(\"/foo/true\"), true).IsTrue());\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer(\"/foo/true\"), false).IsTrue());\n\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer(\"/foo/false\"), false).IsFalse());\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, Pointer(\"/foo/false\"), true).IsFalse());\n\n    // StringRef version\n    EXPECT_STREQ(\"Hello\", GetValueByPointerWithDefault(d, Pointer(\"/foo/hello\"), \"Hello\").GetString());\n\n    // Copy string version\n    {\n        char buffer[256];\n        strcpy(buffer, \"World\");\n        EXPECT_STREQ(\"World\", GetValueByPointerWithDefault(d, Pointer(\"/foo/world\"), buffer).GetString());\n        memset(buffer, 0, sizeof(buffer));\n    }\n    EXPECT_STREQ(\"World\", GetValueByPointer(d, Pointer(\"/foo/world\"))->GetString());\n\n#if RAPIDJSON_HAS_STDSTRING\n    EXPECT_STREQ(\"C++\", GetValueByPointerWithDefault(d, Pointer(\"/foo/C++\"), std::string(\"C++\")).GetString());\n#endif\n}\n\nTEST(Pointer, GetValueByPointerWithDefault_String_NoAllocator) {\n    Document d;\n    d.Parse(kJson);\n\n    const Value v(\"qux\");\n    EXPECT_TRUE(Value(\"bar\") == GetValueByPointerWithDefault(d, \"/foo/0\", v));\n    EXPECT_TRUE(Value(\"bar\") == GetValueByPointerWithDefault(d, \"/foo/0\", v));\n    EXPECT_TRUE(Value(\"baz\") == GetValueByPointerWithDefault(d, \"/foo/1\", v));\n    EXPECT_TRUE(Value(\"qux\") == GetValueByPointerWithDefault(d, \"/foo/2\", v));\n    EXPECT_TRUE(Value(\"last\") == GetValueByPointerWithDefault(d, \"/foo/-\", Value(\"last\").Move()));\n    EXPECT_STREQ(\"last\", d[\"foo\"][3].GetString());\n\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, \"/foo/null\", Value().Move()).IsNull());\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, \"/foo/null\", \"x\").IsNull());\n\n    // Generic version\n    EXPECT_EQ(-1, GetValueByPointerWithDefault(d, \"/foo/int\", -1).GetInt());\n    EXPECT_EQ(-1, GetValueByPointerWithDefault(d, \"/foo/int\", -2).GetInt());\n    EXPECT_EQ(0x87654321, GetValueByPointerWithDefault(d, \"/foo/uint\", 0x87654321).GetUint());\n    EXPECT_EQ(0x87654321, GetValueByPointerWithDefault(d, \"/foo/uint\", 0x12345678).GetUint());\n\n    const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));\n    EXPECT_EQ(i64, GetValueByPointerWithDefault(d, \"/foo/int64\", i64).GetInt64());\n    EXPECT_EQ(i64, GetValueByPointerWithDefault(d, \"/foo/int64\", i64 + 1).GetInt64());\n\n    const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);\n    EXPECT_EQ(u64, GetValueByPointerWithDefault(d, \"/foo/uint64\", u64).GetUint64());\n    EXPECT_EQ(u64, GetValueByPointerWithDefault(d, \"/foo/uint64\", u64 - 1).GetUint64());\n\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, \"/foo/true\", true).IsTrue());\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, \"/foo/true\", false).IsTrue());\n\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, \"/foo/false\", false).IsFalse());\n    EXPECT_TRUE(GetValueByPointerWithDefault(d, \"/foo/false\", true).IsFalse());\n\n    // StringRef version\n    EXPECT_STREQ(\"Hello\", GetValueByPointerWithDefault(d, \"/foo/hello\", \"Hello\").GetString());\n\n    // Copy string version\n    {\n        char buffer[256];\n        strcpy(buffer, \"World\");\n        EXPECT_STREQ(\"World\", GetValueByPointerWithDefault(d, \"/foo/world\", buffer).GetString());\n        memset(buffer, 0, sizeof(buffer));\n    }\n    EXPECT_STREQ(\"World\", GetValueByPointer(d, \"/foo/world\")->GetString());\n\n#if RAPIDJSON_HAS_STDSTRING\n    EXPECT_STREQ(\"C++\", GetValueByPointerWithDefault(d, Pointer(\"/foo/C++\"), std::string(\"C++\")).GetString());\n#endif\n}\n\nTEST(Pointer, SetValueByPointer_Pointer) {\n    Document d;\n    d.Parse(kJson);\n    Document::AllocatorType& a = d.GetAllocator();\n\n    // Value version\n    SetValueByPointer(d, Pointer(\"/foo/0\"), Value(123).Move(), a);\n    EXPECT_EQ(123, d[\"foo\"][0].GetInt());\n\n    SetValueByPointer(d, Pointer(\"/foo/null\"), Value().Move(), a);\n    EXPECT_TRUE(GetValueByPointer(d, \"/foo/null\")->IsNull());\n\n    // Const Value version\n    const Value foo(d[\"foo\"], d.GetAllocator());\n    SetValueByPointer(d, Pointer(\"/clone\"), foo, a);\n    EXPECT_EQ(foo, *GetValueByPointer(d, \"/clone\"));\n\n    // Generic version\n    SetValueByPointer(d, Pointer(\"/foo/int\"), -1, a);\n    EXPECT_EQ(-1, GetValueByPointer(d, \"/foo/int\")->GetInt());\n\n    SetValueByPointer(d, Pointer(\"/foo/uint\"), 0x87654321, a);\n    EXPECT_EQ(0x87654321, GetValueByPointer(d, \"/foo/uint\")->GetUint());\n\n    const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));\n    SetValueByPointer(d, Pointer(\"/foo/int64\"), i64, a);\n    EXPECT_EQ(i64, GetValueByPointer(d, \"/foo/int64\")->GetInt64());\n\n    const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);\n    SetValueByPointer(d, Pointer(\"/foo/uint64\"), u64, a);\n    EXPECT_EQ(u64, GetValueByPointer(d, \"/foo/uint64\")->GetUint64());\n\n    SetValueByPointer(d, Pointer(\"/foo/true\"), true, a);\n    EXPECT_TRUE(GetValueByPointer(d, \"/foo/true\")->IsTrue());\n\n    SetValueByPointer(d, Pointer(\"/foo/false\"), false, a);\n    EXPECT_TRUE(GetValueByPointer(d, \"/foo/false\")->IsFalse());\n\n    // StringRef version\n    SetValueByPointer(d, Pointer(\"/foo/hello\"), \"Hello\", a);\n    EXPECT_STREQ(\"Hello\", GetValueByPointer(d, \"/foo/hello\")->GetString());\n\n    // Copy string version\n    {\n        char buffer[256];\n        strcpy(buffer, \"World\");\n        SetValueByPointer(d, Pointer(\"/foo/world\"), buffer, a);\n        memset(buffer, 0, sizeof(buffer));\n    }\n    EXPECT_STREQ(\"World\", GetValueByPointer(d, \"/foo/world\")->GetString());\n\n#if RAPIDJSON_HAS_STDSTRING\n    SetValueByPointer(d, Pointer(\"/foo/c++\"), std::string(\"C++\"), a);\n    EXPECT_STREQ(\"C++\", GetValueByPointer(d, \"/foo/c++\")->GetString());\n#endif\n}\n\nTEST(Pointer, SetValueByPointer_String) {\n    Document d;\n    d.Parse(kJson);\n    Document::AllocatorType& a = d.GetAllocator();\n\n    // Value version\n    SetValueByPointer(d, \"/foo/0\", Value(123).Move(), a);\n    EXPECT_EQ(123, d[\"foo\"][0].GetInt());\n\n    SetValueByPointer(d, \"/foo/null\", Value().Move(), a);\n    EXPECT_TRUE(GetValueByPointer(d, \"/foo/null\")->IsNull());\n\n    // Const Value version\n    const Value foo(d[\"foo\"], d.GetAllocator());\n    SetValueByPointer(d, \"/clone\", foo, a);\n    EXPECT_EQ(foo, *GetValueByPointer(d, \"/clone\"));\n\n    // Generic version\n    SetValueByPointer(d, \"/foo/int\", -1, a);\n    EXPECT_EQ(-1, GetValueByPointer(d, \"/foo/int\")->GetInt());\n\n    SetValueByPointer(d, \"/foo/uint\", 0x87654321, a);\n    EXPECT_EQ(0x87654321, GetValueByPointer(d, \"/foo/uint\")->GetUint());\n\n    const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));\n    SetValueByPointer(d, \"/foo/int64\", i64, a);\n    EXPECT_EQ(i64, GetValueByPointer(d, \"/foo/int64\")->GetInt64());\n\n    const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);\n    SetValueByPointer(d, \"/foo/uint64\", u64, a);\n    EXPECT_EQ(u64, GetValueByPointer(d, \"/foo/uint64\")->GetUint64());\n\n    SetValueByPointer(d, \"/foo/true\", true, a);\n    EXPECT_TRUE(GetValueByPointer(d, \"/foo/true\")->IsTrue());\n\n    SetValueByPointer(d, \"/foo/false\", false, a);\n    EXPECT_TRUE(GetValueByPointer(d, \"/foo/false\")->IsFalse());\n\n    // StringRef version\n    SetValueByPointer(d, \"/foo/hello\", \"Hello\", a);\n    EXPECT_STREQ(\"Hello\", GetValueByPointer(d, \"/foo/hello\")->GetString());\n\n    // Copy string version\n    {\n        char buffer[256];\n        strcpy(buffer, \"World\");\n        SetValueByPointer(d, \"/foo/world\", buffer, a);\n        memset(buffer, 0, sizeof(buffer));\n    }\n    EXPECT_STREQ(\"World\", GetValueByPointer(d, \"/foo/world\")->GetString());\n\n#if RAPIDJSON_HAS_STDSTRING\n    SetValueByPointer(d, \"/foo/c++\", std::string(\"C++\"), a);\n    EXPECT_STREQ(\"C++\", GetValueByPointer(d, \"/foo/c++\")->GetString());\n#endif\n}\n\nTEST(Pointer, SetValueByPointer_Pointer_NoAllocator) {\n    Document d;\n    d.Parse(kJson);\n\n    // Value version\n    SetValueByPointer(d, Pointer(\"/foo/0\"), Value(123).Move());\n    EXPECT_EQ(123, d[\"foo\"][0].GetInt());\n\n    SetValueByPointer(d, Pointer(\"/foo/null\"), Value().Move());\n    EXPECT_TRUE(GetValueByPointer(d, \"/foo/null\")->IsNull());\n\n    // Const Value version\n    const Value foo(d[\"foo\"], d.GetAllocator());\n    SetValueByPointer(d, Pointer(\"/clone\"), foo);\n    EXPECT_EQ(foo, *GetValueByPointer(d, \"/clone\"));\n\n    // Generic version\n    SetValueByPointer(d, Pointer(\"/foo/int\"), -1);\n    EXPECT_EQ(-1, GetValueByPointer(d, \"/foo/int\")->GetInt());\n\n    SetValueByPointer(d, Pointer(\"/foo/uint\"), 0x87654321);\n    EXPECT_EQ(0x87654321, GetValueByPointer(d, \"/foo/uint\")->GetUint());\n\n    const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));\n    SetValueByPointer(d, Pointer(\"/foo/int64\"), i64);\n    EXPECT_EQ(i64, GetValueByPointer(d, \"/foo/int64\")->GetInt64());\n\n    const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);\n    SetValueByPointer(d, Pointer(\"/foo/uint64\"), u64);\n    EXPECT_EQ(u64, GetValueByPointer(d, \"/foo/uint64\")->GetUint64());\n\n    SetValueByPointer(d, Pointer(\"/foo/true\"), true);\n    EXPECT_TRUE(GetValueByPointer(d, \"/foo/true\")->IsTrue());\n\n    SetValueByPointer(d, Pointer(\"/foo/false\"), false);\n    EXPECT_TRUE(GetValueByPointer(d, \"/foo/false\")->IsFalse());\n\n    // StringRef version\n    SetValueByPointer(d, Pointer(\"/foo/hello\"), \"Hello\");\n    EXPECT_STREQ(\"Hello\", GetValueByPointer(d, \"/foo/hello\")->GetString());\n\n    // Copy string version\n    {\n        char buffer[256];\n        strcpy(buffer, \"World\");\n        SetValueByPointer(d, Pointer(\"/foo/world\"), buffer);\n        memset(buffer, 0, sizeof(buffer));\n    }\n    EXPECT_STREQ(\"World\", GetValueByPointer(d, \"/foo/world\")->GetString());\n\n#if RAPIDJSON_HAS_STDSTRING\n    SetValueByPointer(d, Pointer(\"/foo/c++\"), std::string(\"C++\"));\n    EXPECT_STREQ(\"C++\", GetValueByPointer(d, \"/foo/c++\")->GetString());\n#endif\n}\n\nTEST(Pointer, SetValueByPointer_String_NoAllocator) {\n    Document d;\n    d.Parse(kJson);\n\n    // Value version\n    SetValueByPointer(d, \"/foo/0\", Value(123).Move());\n    EXPECT_EQ(123, d[\"foo\"][0].GetInt());\n\n    SetValueByPointer(d, \"/foo/null\", Value().Move());\n    EXPECT_TRUE(GetValueByPointer(d, \"/foo/null\")->IsNull());\n\n    // Const Value version\n    const Value foo(d[\"foo\"], d.GetAllocator());\n    SetValueByPointer(d, \"/clone\", foo);\n    EXPECT_EQ(foo, *GetValueByPointer(d, \"/clone\"));\n\n    // Generic version\n    SetValueByPointer(d, \"/foo/int\", -1);\n    EXPECT_EQ(-1, GetValueByPointer(d, \"/foo/int\")->GetInt());\n\n    SetValueByPointer(d, \"/foo/uint\", 0x87654321);\n    EXPECT_EQ(0x87654321, GetValueByPointer(d, \"/foo/uint\")->GetUint());\n\n    const int64_t i64 = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0));\n    SetValueByPointer(d, \"/foo/int64\", i64);\n    EXPECT_EQ(i64, GetValueByPointer(d, \"/foo/int64\")->GetInt64());\n\n    const uint64_t u64 = RAPIDJSON_UINT64_C2(0xFFFFFFFFF, 0xFFFFFFFFF);\n    SetValueByPointer(d, \"/foo/uint64\", u64);\n    EXPECT_EQ(u64, GetValueByPointer(d, \"/foo/uint64\")->GetUint64());\n\n    SetValueByPointer(d, \"/foo/true\", true);\n    EXPECT_TRUE(GetValueByPointer(d, \"/foo/true\")->IsTrue());\n\n    SetValueByPointer(d, \"/foo/false\", false);\n    EXPECT_TRUE(GetValueByPointer(d, \"/foo/false\")->IsFalse());\n\n    // StringRef version\n    SetValueByPointer(d, \"/foo/hello\", \"Hello\");\n    EXPECT_STREQ(\"Hello\", GetValueByPointer(d, \"/foo/hello\")->GetString());\n\n    // Copy string version\n    {\n        char buffer[256];\n        strcpy(buffer, \"World\");\n        SetValueByPointer(d, \"/foo/world\", buffer);\n        memset(buffer, 0, sizeof(buffer));\n    }\n    EXPECT_STREQ(\"World\", GetValueByPointer(d, \"/foo/world\")->GetString());\n\n#if RAPIDJSON_HAS_STDSTRING\n    SetValueByPointer(d, \"/foo/c++\", std::string(\"C++\"));\n    EXPECT_STREQ(\"C++\", GetValueByPointer(d, \"/foo/c++\")->GetString());\n#endif\n}\n\nTEST(Pointer, SwapValueByPointer) {\n    Document d;\n    d.Parse(kJson);\n    Document::AllocatorType& a = d.GetAllocator();\n    SwapValueByPointer(d, Pointer(\"/foo/0\"), *GetValueByPointer(d, \"/foo/1\"), a);\n    EXPECT_STREQ(\"baz\", d[\"foo\"][0].GetString());\n    EXPECT_STREQ(\"bar\", d[\"foo\"][1].GetString());\n\n    SwapValueByPointer(d, \"/foo/0\", *GetValueByPointer(d, \"/foo/1\"), a);\n    EXPECT_STREQ(\"bar\", d[\"foo\"][0].GetString());\n    EXPECT_STREQ(\"baz\", d[\"foo\"][1].GetString());\n}\n\nTEST(Pointer, SwapValueByPointer_NoAllocator) {\n    Document d;\n    d.Parse(kJson);\n    SwapValueByPointer(d, Pointer(\"/foo/0\"), *GetValueByPointer(d, \"/foo/1\"));\n    EXPECT_STREQ(\"baz\", d[\"foo\"][0].GetString());\n    EXPECT_STREQ(\"bar\", d[\"foo\"][1].GetString());\n\n    SwapValueByPointer(d, \"/foo/0\", *GetValueByPointer(d, \"/foo/1\"));\n    EXPECT_STREQ(\"bar\", d[\"foo\"][0].GetString());\n    EXPECT_STREQ(\"baz\", d[\"foo\"][1].GetString());\n}\n\nTEST(Pointer, EraseValueByPointer_Pointer) {\n    Document d;\n    d.Parse(kJson);\n\n    EXPECT_FALSE(EraseValueByPointer(d, Pointer(\"\")));\n    EXPECT_FALSE(Pointer(\"/foo/nonexist\").Erase(d));\n    EXPECT_TRUE(EraseValueByPointer(d, Pointer(\"/foo/0\")));\n    EXPECT_EQ(1u, d[\"foo\"].Size());\n    EXPECT_STREQ(\"baz\", d[\"foo\"][0].GetString());\n    EXPECT_TRUE(EraseValueByPointer(d, Pointer(\"/foo/0\")));\n    EXPECT_TRUE(d[\"foo\"].Empty());\n    EXPECT_TRUE(EraseValueByPointer(d, Pointer(\"/foo\")));\n    EXPECT_TRUE(Pointer(\"/foo\").Get(d) == 0);\n}\n\nTEST(Pointer, EraseValueByPointer_String) {\n    Document d;\n    d.Parse(kJson);\n\n    EXPECT_FALSE(EraseValueByPointer(d, \"\"));\n    EXPECT_FALSE(Pointer(\"/foo/nonexist\").Erase(d));\n    EXPECT_TRUE(EraseValueByPointer(d, \"/foo/0\"));\n    EXPECT_EQ(1u, d[\"foo\"].Size());\n    EXPECT_STREQ(\"baz\", d[\"foo\"][0].GetString());\n    EXPECT_TRUE(EraseValueByPointer(d, \"/foo/0\"));\n    EXPECT_TRUE(d[\"foo\"].Empty());\n    EXPECT_TRUE(EraseValueByPointer(d, \"/foo\"));\n    EXPECT_TRUE(Pointer(\"/foo\").Get(d) == 0);\n}\n\nTEST(Pointer, Ambiguity) {\n    {\n        Document d;\n        d.Parse(\"{\\\"0\\\" : [123]}\");\n        EXPECT_EQ(123, Pointer(\"/0/0\").Get(d)->GetInt());\n        Pointer(\"/0/a\").Set(d, 456);    // Change array [123] to object {456}\n        EXPECT_EQ(456, Pointer(\"/0/a\").Get(d)->GetInt());\n    }\n\n    {\n        Document d;\n        EXPECT_FALSE(d.Parse(\"[{\\\"0\\\": 123}]\").HasParseError());\n        EXPECT_EQ(123, Pointer(\"/0/0\").Get(d)->GetInt());\n        Pointer(\"/0/1\").Set(d, 456); // 1 is treated as \"1\" to index object\n        EXPECT_EQ(123, Pointer(\"/0/0\").Get(d)->GetInt());\n        EXPECT_EQ(456, Pointer(\"/0/1\").Get(d)->GetInt());\n    }\n}\n\n// https://github.com/miloyip/rapidjson/issues/483\nnamespace myjson {\n\nclass MyAllocator\n{\npublic:\n    static const bool kNeedFree = true;\n    void * Malloc(size_t _size) { return malloc(_size); }\n    void * Realloc(void *_org_p, size_t _org_size, size_t _new_size) { (void)_org_size; return realloc(_org_p, _new_size); }\n    static void Free(void *_p) { return free(_p); }\n};\n\ntypedef rapidjson::GenericDocument<\n            rapidjson::UTF8<>,\n            rapidjson::MemoryPoolAllocator< MyAllocator >,\n            MyAllocator\n        > Document;\n\ntypedef rapidjson::GenericPointer<\n            ::myjson::Document::ValueType,\n            MyAllocator\n        > Pointer;\n\ntypedef ::myjson::Document::ValueType Value;\n\n}\n\nTEST(Pointer, Issue483) {\n    std::string mystr, path;\n    myjson::Document document;\n    myjson::Value value(rapidjson::kStringType);\n    value.SetString(mystr.c_str(), static_cast<SizeType>(mystr.length()), document.GetAllocator());\n    myjson::Pointer(path.c_str()).Set(document, value, document.GetAllocator());\n}\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/prettywritertest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n#include \"rapidjson/reader.h\"\n#include \"rapidjson/prettywriter.h\"\n#include \"rapidjson/stringbuffer.h\"\n#include \"rapidjson/filewritestream.h\"\n\nusing namespace rapidjson;\n\nstatic const char kJson[] = \"{\\\"hello\\\":\\\"world\\\",\\\"t\\\":true,\\\"f\\\":false,\\\"n\\\":null,\\\"i\\\":123,\\\"pi\\\":3.1416,\\\"a\\\":[1,2,3,-1],\\\"u64\\\":1234567890123456789,\\\"i64\\\":-1234567890123456789}\";\nstatic const char kPrettyJson[] =\n\"{\\n\"\n\"    \\\"hello\\\": \\\"world\\\",\\n\"\n\"    \\\"t\\\": true,\\n\"\n\"    \\\"f\\\": false,\\n\"\n\"    \\\"n\\\": null,\\n\"\n\"    \\\"i\\\": 123,\\n\"\n\"    \\\"pi\\\": 3.1416,\\n\"\n\"    \\\"a\\\": [\\n\"\n\"        1,\\n\"\n\"        2,\\n\"\n\"        3,\\n\"\n\"        -1\\n\"\n\"    ],\\n\"\n\"    \\\"u64\\\": 1234567890123456789,\\n\"\n\"    \\\"i64\\\": -1234567890123456789\\n\"\n\"}\";\n\nstatic const char kPrettyJson_FormatOptions_SLA[] =\n\"{\\n\"\n\"    \\\"hello\\\": \\\"world\\\",\\n\"\n\"    \\\"t\\\": true,\\n\"\n\"    \\\"f\\\": false,\\n\"\n\"    \\\"n\\\": null,\\n\"\n\"    \\\"i\\\": 123,\\n\"\n\"    \\\"pi\\\": 3.1416,\\n\"\n\"    \\\"a\\\": [1, 2, 3, -1],\\n\"\n\"    \\\"u64\\\": 1234567890123456789,\\n\"\n\"    \\\"i64\\\": -1234567890123456789\\n\"\n\"}\";\n\nTEST(PrettyWriter, Basic) {\n    StringBuffer buffer;\n    PrettyWriter<StringBuffer> writer(buffer);\n    Reader reader;\n    StringStream s(kJson);\n    reader.Parse(s, writer);\n    EXPECT_STREQ(kPrettyJson, buffer.GetString());\n}\n\nTEST(PrettyWriter, FormatOptions) {\n    StringBuffer buffer;\n    PrettyWriter<StringBuffer> writer(buffer);\n    writer.SetFormatOptions(kFormatSingleLineArray);\n    Reader reader;\n    StringStream s(kJson);\n    reader.Parse(s, writer);\n    EXPECT_STREQ(kPrettyJson_FormatOptions_SLA, buffer.GetString());\n}\n\nTEST(PrettyWriter, SetIndent) {\n    StringBuffer buffer;\n    PrettyWriter<StringBuffer> writer(buffer);\n    writer.SetIndent('\\t', 1);\n    Reader reader;\n    StringStream s(kJson);\n    reader.Parse(s, writer);\n    EXPECT_STREQ(\n        \"{\\n\"\n        \"\\t\\\"hello\\\": \\\"world\\\",\\n\"\n        \"\\t\\\"t\\\": true,\\n\"\n        \"\\t\\\"f\\\": false,\\n\"\n        \"\\t\\\"n\\\": null,\\n\"\n        \"\\t\\\"i\\\": 123,\\n\"\n        \"\\t\\\"pi\\\": 3.1416,\\n\"\n        \"\\t\\\"a\\\": [\\n\"\n        \"\\t\\t1,\\n\"\n        \"\\t\\t2,\\n\"\n        \"\\t\\t3,\\n\"\n        \"\\t\\t-1\\n\"\n        \"\\t],\\n\"\n        \"\\t\\\"u64\\\": 1234567890123456789,\\n\"\n        \"\\t\\\"i64\\\": -1234567890123456789\\n\"\n        \"}\",\n        buffer.GetString());\n}\n\nTEST(PrettyWriter, String) {\n    StringBuffer buffer;\n    PrettyWriter<StringBuffer> writer(buffer);\n    EXPECT_TRUE(writer.StartArray());\n    EXPECT_TRUE(writer.String(\"Hello\\n\"));\n    EXPECT_TRUE(writer.EndArray());\n    EXPECT_STREQ(\"[\\n    \\\"Hello\\\\n\\\"\\n]\", buffer.GetString());\n}\n\n#if RAPIDJSON_HAS_STDSTRING\nTEST(PrettyWriter, String_STDSTRING) {\n    StringBuffer buffer;\n    PrettyWriter<StringBuffer> writer(buffer);\n    EXPECT_TRUE(writer.StartArray());\n    EXPECT_TRUE(writer.String(std::string(\"Hello\\n\")));\n    EXPECT_TRUE(writer.EndArray());\n    EXPECT_STREQ(\"[\\n    \\\"Hello\\\\n\\\"\\n]\", buffer.GetString());\n}\n#endif\n\n#include <sstream>\n\nclass OStreamWrapper {\npublic:\n    typedef char Ch;\n\n    OStreamWrapper(std::ostream& os) : os_(os) {}\n\n    Ch Peek() const { assert(false); return '\\0'; }\n    Ch Take() { assert(false); return '\\0'; }\n    size_t Tell() const { return 0; }\n\n    Ch* PutBegin() { assert(false); return 0; }\n    void Put(Ch c) { os_.put(c); }\n    void Flush() { os_.flush(); }\n    size_t PutEnd(Ch*) { assert(false); return 0; }\n\nprivate:\n    OStreamWrapper(const OStreamWrapper&);\n    OStreamWrapper& operator=(const OStreamWrapper&);\n\n    std::ostream& os_;\n};\n\n// For covering PutN() generic version\nTEST(PrettyWriter, OStreamWrapper) {\n    StringStream s(kJson);\n    \n    std::stringstream ss;\n    OStreamWrapper os(ss);\n    \n    PrettyWriter<OStreamWrapper> writer(os);\n\n    Reader reader;\n    reader.Parse(s, writer);\n    \n    std::string actual = ss.str();\n    EXPECT_STREQ(kPrettyJson, actual.c_str());\n}\n\n// For covering FileWriteStream::PutN()\nTEST(PrettyWriter, FileWriteStream) {\n    char filename[L_tmpnam];\n    FILE* fp = TempFile(filename);\n    char buffer[16];\n    FileWriteStream os(fp, buffer, sizeof(buffer));\n    PrettyWriter<FileWriteStream> writer(os);\n    Reader reader;\n    StringStream s(kJson);\n    reader.Parse(s, writer);\n    fclose(fp);\n\n    fp = fopen(filename, \"rb\");\n    fseek(fp, 0, SEEK_END);\n    size_t size = static_cast<size_t>(ftell(fp));\n    fseek(fp, 0, SEEK_SET);\n    char* json = static_cast<char*>(malloc(size + 1));\n    size_t readLength = fread(json, 1, size, fp);\n    json[readLength] = '\\0';\n    fclose(fp);\n    remove(filename);\n    EXPECT_STREQ(kPrettyJson, json);\n    free(json);\n}\n\nTEST(PrettyWriter, RawValue) {\n    StringBuffer buffer;\n    PrettyWriter<StringBuffer> writer(buffer);\n    writer.StartObject();\n    writer.Key(\"a\");\n    writer.Int(1);\n    writer.Key(\"raw\");\n    const char json[] = \"[\\\"Hello\\\\nWorld\\\", 123.456]\";\n    writer.RawValue(json, strlen(json), kArrayType);\n    writer.EndObject();\n    EXPECT_TRUE(writer.IsComplete());\n    EXPECT_STREQ(\n        \"{\\n\"\n        \"    \\\"a\\\": 1,\\n\"\n        \"    \\\"raw\\\": [\\\"Hello\\\\nWorld\\\", 123.456]\\n\" // no indentation within raw value\n        \"}\",\n        buffer.GetString());\n}\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/readertest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n//\n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed\n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n// CONDITIONS OF ANY KIND, either express or implied. See the License for the\n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n\n#include \"rapidjson/reader.h\"\n#include \"rapidjson/internal/dtoa.h\"\n#include \"rapidjson/internal/itoa.h\"\n#include \"rapidjson/memorystream.h\"\n\n#include <limits>\n\nusing namespace rapidjson;\n\nRAPIDJSON_DIAG_PUSH\n#ifdef __GNUC__\nRAPIDJSON_DIAG_OFF(effc++)\nRAPIDJSON_DIAG_OFF(float-equal)\nRAPIDJSON_DIAG_OFF(missing-noreturn)\n#if __GNUC__ >= 7\nRAPIDJSON_DIAG_OFF(dangling-else)\n#endif\n#endif // __GNUC__\n\n#ifdef __clang__\nRAPIDJSON_DIAG_OFF(variadic-macros)\nRAPIDJSON_DIAG_OFF(c++98-compat-pedantic)\n#endif\n\ntemplate<bool expect>\nstruct ParseBoolHandler : BaseReaderHandler<UTF8<>, ParseBoolHandler<expect> > {\n    ParseBoolHandler() : step_(0) {}\n    bool Default() { ADD_FAILURE(); return false; }\n    // gcc 4.8.x generates warning in EXPECT_EQ(bool, bool) on this gtest version.\n    // Workaround with EXPECT_TRUE().\n    bool Bool(bool b) { /*EXPECT_EQ(expect, b); */EXPECT_TRUE(expect == b);  ++step_; return true; }\n\n    unsigned step_;\n};\n\nTEST(Reader, ParseTrue) {\n    StringStream s(\"true\");\n    ParseBoolHandler<true> h;\n    Reader reader;\n    reader.Parse(s, h);\n    EXPECT_EQ(1u, h.step_);\n}\n\nTEST(Reader, ParseFalse) {\n    StringStream s(\"false\");\n    ParseBoolHandler<false> h;\n    Reader reader;\n    reader.Parse(s, h);\n    EXPECT_EQ(1u, h.step_);\n}\n\nstruct ParseIntHandler : BaseReaderHandler<UTF8<>, ParseIntHandler> {\n    ParseIntHandler() : step_(0), actual_() {}\n    bool Default() { ADD_FAILURE(); return false; }\n    bool Int(int i) { actual_ = i; step_++; return true; }\n\n    unsigned step_;\n    int actual_;\n};\n\nstruct ParseUintHandler : BaseReaderHandler<UTF8<>, ParseUintHandler> {\n    ParseUintHandler() : step_(0), actual_() {}\n    bool Default() { ADD_FAILURE(); return false; }\n    bool Uint(unsigned i) { actual_ = i; step_++; return true; }\n\n    unsigned step_;\n    unsigned actual_;\n};\n\nstruct ParseInt64Handler : BaseReaderHandler<UTF8<>, ParseInt64Handler> {\n    ParseInt64Handler() : step_(0), actual_() {}\n    bool Default() { ADD_FAILURE(); return false; }\n    bool Int64(int64_t i) { actual_ = i; step_++; return true; }\n\n    unsigned step_;\n    int64_t actual_;\n};\n\nstruct ParseUint64Handler : BaseReaderHandler<UTF8<>, ParseUint64Handler> {\n    ParseUint64Handler() : step_(0), actual_() {}\n    bool Default() { ADD_FAILURE(); return false; }\n    bool Uint64(uint64_t i) { actual_ = i; step_++; return true; }\n\n    unsigned step_;\n    uint64_t actual_;\n};\n\nstruct ParseDoubleHandler : BaseReaderHandler<UTF8<>, ParseDoubleHandler> {\n    ParseDoubleHandler() : step_(0), actual_() {}\n    bool Default() { ADD_FAILURE(); return false; }\n    bool Double(double d) { actual_ = d; step_++; return true; }\n\n    unsigned step_;\n    double actual_;\n};\n\nTEST(Reader, ParseNumber_Integer) {\n#define TEST_INTEGER(Handler, str, x) \\\n    { \\\n        StringStream s(str); \\\n        Handler h; \\\n        Reader reader; \\\n        reader.Parse(s, h); \\\n        EXPECT_EQ(1u, h.step_); \\\n        EXPECT_EQ(x, h.actual_); \\\n    }\n\n    TEST_INTEGER(ParseUintHandler, \"0\", 0u);\n    TEST_INTEGER(ParseUintHandler, \"123\", 123u);\n    TEST_INTEGER(ParseUintHandler, \"2147483648\", 2147483648u);       // 2^31 - 1 (cannot be stored in int)\n    TEST_INTEGER(ParseUintHandler, \"4294967295\", 4294967295u);\n\n    TEST_INTEGER(ParseIntHandler, \"-123\", -123);\n    TEST_INTEGER(ParseIntHandler, \"-2147483648\", static_cast<int32_t>(0x80000000));     // -2^31 (min of int)\n\n    TEST_INTEGER(ParseUint64Handler, \"4294967296\", RAPIDJSON_UINT64_C2(1, 0));   // 2^32 (max of unsigned + 1, force to use uint64_t)\n    TEST_INTEGER(ParseUint64Handler, \"18446744073709551615\", RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0xFFFFFFFF));   // 2^64 - 1 (max of uint64_t)\n\n    TEST_INTEGER(ParseInt64Handler, \"-2147483649\", static_cast<int64_t>(RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0x7FFFFFFF)));   // -2^31 -1 (min of int - 1, force to use int64_t)\n    TEST_INTEGER(ParseInt64Handler, \"-9223372036854775808\", static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 0x00000000)));       // -2^63 (min of int64_t)\n\n    // Random test for uint32_t/int32_t\n    {\n        union {\n            uint32_t u;\n            int32_t i;\n        }u;\n        Random r;\n\n        for (unsigned i = 0; i < 100000; i++) {\n            u.u = r();\n\n            char buffer[32];\n            *internal::u32toa(u.u, buffer) = '\\0';\n            TEST_INTEGER(ParseUintHandler, buffer, u.u);\n\n            if (u.i < 0) {\n                *internal::i32toa(u.i, buffer) = '\\0';\n                TEST_INTEGER(ParseIntHandler, buffer, u.i);\n            }\n        }\n    }\n\n    // Random test for uint64_t/int64_t\n    {\n        union {\n            uint64_t u;\n            int64_t i;\n        }u;\n        Random r;\n\n        for (unsigned i = 0; i < 100000; i++) {\n            u.u = uint64_t(r()) << 32;\n            u.u |= r();\n\n            char buffer[32];\n            if (u.u > uint64_t(4294967295u)) {\n                *internal::u64toa(u.u, buffer) = '\\0';\n                TEST_INTEGER(ParseUint64Handler, buffer, u.u);\n            }\n\n            if (u.i < -int64_t(2147483648u)) {\n                *internal::i64toa(u.i, buffer) = '\\0';\n                TEST_INTEGER(ParseInt64Handler, buffer, u.i);\n            }\n        }\n    }\n#undef TEST_INTEGER\n}\n\ntemplate<bool fullPrecision>\nstatic void TestParseDouble() {\n#define TEST_DOUBLE(fullPrecision, str, x) \\\n    { \\\n        StringStream s(str); \\\n        ParseDoubleHandler h; \\\n        Reader reader; \\\n        ASSERT_EQ(kParseErrorNone, reader.Parse<fullPrecision ? kParseFullPrecisionFlag : 0>(s, h).Code()); \\\n        EXPECT_EQ(1u, h.step_); \\\n        internal::Double e(x), a(h.actual_); \\\n        if (fullPrecision) { \\\n            EXPECT_EQ(e.Uint64Value(), a.Uint64Value()); \\\n            if (e.Uint64Value() != a.Uint64Value()) \\\n                printf(\"  String: %s\\n  Actual: %.17g\\nExpected: %.17g\\n\", str, h.actual_, x); \\\n        } \\\n        else { \\\n            EXPECT_EQ(e.Sign(), a.Sign()); /* for 0.0 != -0.0 */ \\\n            EXPECT_DOUBLE_EQ(x, h.actual_); \\\n        } \\\n    }\n\n    TEST_DOUBLE(fullPrecision, \"0.0\", 0.0);\n    TEST_DOUBLE(fullPrecision, \"-0.0\", -0.0); // For checking issue #289\n    TEST_DOUBLE(fullPrecision, \"1.0\", 1.0);\n    TEST_DOUBLE(fullPrecision, \"-1.0\", -1.0);\n    TEST_DOUBLE(fullPrecision, \"1.5\", 1.5);\n    TEST_DOUBLE(fullPrecision, \"-1.5\", -1.5);\n    TEST_DOUBLE(fullPrecision, \"3.1416\", 3.1416);\n    TEST_DOUBLE(fullPrecision, \"1E10\", 1E10);\n    TEST_DOUBLE(fullPrecision, \"1e10\", 1e10);\n    TEST_DOUBLE(fullPrecision, \"1E+10\", 1E+10);\n    TEST_DOUBLE(fullPrecision, \"1E-10\", 1E-10);\n    TEST_DOUBLE(fullPrecision, \"-1E10\", -1E10);\n    TEST_DOUBLE(fullPrecision, \"-1e10\", -1e10);\n    TEST_DOUBLE(fullPrecision, \"-1E+10\", -1E+10);\n    TEST_DOUBLE(fullPrecision, \"-1E-10\", -1E-10);\n    TEST_DOUBLE(fullPrecision, \"1.234E+10\", 1.234E+10);\n    TEST_DOUBLE(fullPrecision, \"1.234E-10\", 1.234E-10);\n    TEST_DOUBLE(fullPrecision, \"1.79769e+308\", 1.79769e+308);\n    TEST_DOUBLE(fullPrecision, \"2.22507e-308\", 2.22507e-308);\n    TEST_DOUBLE(fullPrecision, \"-1.79769e+308\", -1.79769e+308);\n    TEST_DOUBLE(fullPrecision, \"-2.22507e-308\", -2.22507e-308);\n    TEST_DOUBLE(fullPrecision, \"4.9406564584124654e-324\", 4.9406564584124654e-324); // minimum denormal\n    TEST_DOUBLE(fullPrecision, \"2.2250738585072009e-308\", 2.2250738585072009e-308); // Max subnormal double\n    TEST_DOUBLE(fullPrecision, \"2.2250738585072014e-308\", 2.2250738585072014e-308); // Min normal positive double\n    TEST_DOUBLE(fullPrecision, \"1.7976931348623157e+308\", 1.7976931348623157e+308); // Max double\n    TEST_DOUBLE(fullPrecision, \"1e-10000\", 0.0);                                    // must underflow\n    TEST_DOUBLE(fullPrecision, \"18446744073709551616\", 18446744073709551616.0);     // 2^64 (max of uint64_t + 1, force to use double)\n    TEST_DOUBLE(fullPrecision, \"-9223372036854775809\", -9223372036854775809.0);     // -2^63 - 1(min of int64_t + 1, force to use double)\n    TEST_DOUBLE(fullPrecision, \"0.9868011474609375\", 0.9868011474609375);           // https://github.com/miloyip/rapidjson/issues/120\n    TEST_DOUBLE(fullPrecision, \"123e34\", 123e34);                                   // Fast Path Cases In Disguise\n    TEST_DOUBLE(fullPrecision, \"45913141877270640000.0\", 45913141877270640000.0);\n    TEST_DOUBLE(fullPrecision, \"2.2250738585072011e-308\", 2.2250738585072011e-308); // http://www.exploringbinary.com/php-hangs-on-numeric-value-2-2250738585072011e-308/\n    TEST_DOUBLE(fullPrecision, \"1e-00011111111111\", 0.0);                           // Issue #313\n    TEST_DOUBLE(fullPrecision, \"-1e-00011111111111\", -0.0);\n    TEST_DOUBLE(fullPrecision, \"1e-214748363\", 0.0);                                  // Maximum supported negative exponent\n    TEST_DOUBLE(fullPrecision, \"1e-214748364\", 0.0);\n    TEST_DOUBLE(fullPrecision, \"1e-21474836311\", 0.0);\n    TEST_DOUBLE(fullPrecision, \"0.017976931348623157e+310\", 1.7976931348623157e+308); // Max double in another form\n\n    // Since\n    // abs((2^-1022 - 2^-1074) - 2.2250738585072012e-308) = 3.109754131239141401123495768877590405345064751974375599... �� 10^-324\n    // abs((2^-1022) - 2.2250738585072012e-308) = 1.830902327173324040642192159804623318305533274168872044... �� 10 ^ -324\n    // So 2.2250738585072012e-308 should round to 2^-1022 = 2.2250738585072014e-308\n    TEST_DOUBLE(fullPrecision, \"2.2250738585072012e-308\", 2.2250738585072014e-308); // http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/\n\n    // More closer to normal/subnormal boundary\n    // boundary = 2^-1022 - 2^-1075 = 2.225073858507201136057409796709131975934819546351645648... �� 10^-308\n    TEST_DOUBLE(fullPrecision, \"2.22507385850720113605740979670913197593481954635164564e-308\", 2.2250738585072009e-308);\n    TEST_DOUBLE(fullPrecision, \"2.22507385850720113605740979670913197593481954635164565e-308\", 2.2250738585072014e-308);\n\n    // 1.0 is in (1.0 - 2^-54, 1.0 + 2^-53)\n    // 1.0 - 2^-54 = 0.999999999999999944488848768742172978818416595458984375\n    TEST_DOUBLE(fullPrecision, \"0.999999999999999944488848768742172978818416595458984375\", 1.0); // round to even\n    TEST_DOUBLE(fullPrecision, \"0.999999999999999944488848768742172978818416595458984374\", 0.99999999999999989); // previous double\n    TEST_DOUBLE(fullPrecision, \"0.999999999999999944488848768742172978818416595458984376\", 1.0); // next double\n    // 1.0 + 2^-53 = 1.00000000000000011102230246251565404236316680908203125\n    TEST_DOUBLE(fullPrecision, \"1.00000000000000011102230246251565404236316680908203125\", 1.0); // round to even\n    TEST_DOUBLE(fullPrecision, \"1.00000000000000011102230246251565404236316680908203124\", 1.0); // previous double\n    TEST_DOUBLE(fullPrecision, \"1.00000000000000011102230246251565404236316680908203126\", 1.00000000000000022); // next double\n\n    // Numbers from https://github.com/floitsch/double-conversion/blob/master/test/cctest/test-strtod.cc\n\n    TEST_DOUBLE(fullPrecision, \"72057594037927928.0\", 72057594037927928.0);\n    TEST_DOUBLE(fullPrecision, \"72057594037927936.0\", 72057594037927936.0);\n    TEST_DOUBLE(fullPrecision, \"72057594037927932.0\", 72057594037927936.0);\n    TEST_DOUBLE(fullPrecision, \"7205759403792793199999e-5\", 72057594037927928.0);\n    TEST_DOUBLE(fullPrecision, \"7205759403792793200001e-5\", 72057594037927936.0);\n\n    TEST_DOUBLE(fullPrecision, \"9223372036854774784.0\", 9223372036854774784.0);\n    TEST_DOUBLE(fullPrecision, \"9223372036854775808.0\", 9223372036854775808.0);\n    TEST_DOUBLE(fullPrecision, \"9223372036854775296.0\", 9223372036854775808.0);\n    TEST_DOUBLE(fullPrecision, \"922337203685477529599999e-5\", 9223372036854774784.0);\n    TEST_DOUBLE(fullPrecision, \"922337203685477529600001e-5\", 9223372036854775808.0);\n\n    TEST_DOUBLE(fullPrecision, \"10141204801825834086073718800384\", 10141204801825834086073718800384.0);\n    TEST_DOUBLE(fullPrecision, \"10141204801825835211973625643008\", 10141204801825835211973625643008.0);\n    TEST_DOUBLE(fullPrecision, \"10141204801825834649023672221696\", 10141204801825835211973625643008.0);\n    TEST_DOUBLE(fullPrecision, \"1014120480182583464902367222169599999e-5\", 10141204801825834086073718800384.0);\n    TEST_DOUBLE(fullPrecision, \"1014120480182583464902367222169600001e-5\", 10141204801825835211973625643008.0);\n\n    TEST_DOUBLE(fullPrecision, \"5708990770823838890407843763683279797179383808\", 5708990770823838890407843763683279797179383808.0);\n    TEST_DOUBLE(fullPrecision, \"5708990770823839524233143877797980545530986496\", 5708990770823839524233143877797980545530986496.0);\n    TEST_DOUBLE(fullPrecision, \"5708990770823839207320493820740630171355185152\", 5708990770823839524233143877797980545530986496.0);\n    TEST_DOUBLE(fullPrecision, \"5708990770823839207320493820740630171355185151999e-3\", 5708990770823838890407843763683279797179383808.0);\n    TEST_DOUBLE(fullPrecision, \"5708990770823839207320493820740630171355185152001e-3\", 5708990770823839524233143877797980545530986496.0);\n\n    {\n        char n1e308[310];   // '1' followed by 308 '0'\n        n1e308[0] = '1';\n        for (int i = 1; i < 309; i++)\n            n1e308[i] = '0';\n        n1e308[309] = '\\0';\n        TEST_DOUBLE(fullPrecision, n1e308, 1E308);\n    }\n\n    // Cover trimming\n    TEST_DOUBLE(fullPrecision,\n\"2.22507385850720113605740979670913197593481954635164564802342610972482222202107694551652952390813508\"\n\"7914149158913039621106870086438694594645527657207407820621743379988141063267329253552286881372149012\"\n\"9811224514518898490572223072852551331557550159143974763979834118019993239625482890171070818506906306\"\n\"6665599493827577257201576306269066333264756530000924588831643303777979186961204949739037782970490505\"\n\"1080609940730262937128958950003583799967207254304360284078895771796150945516748243471030702609144621\"\n\"5722898802581825451803257070188608721131280795122334262883686223215037756666225039825343359745688844\"\n\"2390026549819838548794829220689472168983109969836584681402285424333066033985088644580400103493397042\"\n\"7567186443383770486037861622771738545623065874679014086723327636718751234567890123456789012345678901\"\n\"e-308\",\n    2.2250738585072014e-308);\n\n    {\n        static const unsigned count = 100; // Tested with 1000000 locally\n        Random r;\n        Reader reader; // Reusing reader to prevent heap allocation\n\n        // Exhaustively test different exponents with random significant\n        for (uint64_t exp = 0; exp < 2047; exp++) {\n            ;\n            for (unsigned i = 0; i < count; i++) {\n                // Need to call r() in two statements for cross-platform coherent sequence.\n                uint64_t u = (exp << 52) | uint64_t(r() & 0x000FFFFF) << 32;\n                u |= uint64_t(r());\n                internal::Double d = internal::Double(u);\n\n                char buffer[32];\n                *internal::dtoa(d.Value(), buffer) = '\\0';\n\n                StringStream s(buffer);\n                ParseDoubleHandler h;\n                ASSERT_EQ(kParseErrorNone, reader.Parse<fullPrecision ? kParseFullPrecisionFlag : 0>(s, h).Code());\n                EXPECT_EQ(1u, h.step_);\n                internal::Double a(h.actual_);\n                if (fullPrecision) {\n                    EXPECT_EQ(d.Uint64Value(), a.Uint64Value());\n                    if (d.Uint64Value() != a.Uint64Value())\n                        printf(\"  String: %s\\n  Actual: %.17g\\nExpected: %.17g\\n\", buffer, h.actual_, d.Value());\n                }\n                else {\n                    EXPECT_EQ(d.Sign(), a.Sign()); // for 0.0 != -0.0\n                    EXPECT_DOUBLE_EQ(d.Value(), h.actual_);\n                }\n            }\n        }\n    }\n\n    // Issue #340\n    TEST_DOUBLE(fullPrecision, \"7.450580596923828e-9\", 7.450580596923828e-9);\n    {\n        internal::Double d(1.0);\n        for (int i = 0; i < 324; i++) {\n            char buffer[32];\n            *internal::dtoa(d.Value(), buffer) = '\\0';\n\n            StringStream s(buffer);\n            ParseDoubleHandler h;\n            Reader reader;\n            ASSERT_EQ(kParseErrorNone, reader.Parse<fullPrecision ? kParseFullPrecisionFlag : 0>(s, h).Code());\n            EXPECT_EQ(1u, h.step_);\n            internal::Double a(h.actual_);\n            if (fullPrecision) {\n                EXPECT_EQ(d.Uint64Value(), a.Uint64Value());\n                if (d.Uint64Value() != a.Uint64Value())\n                    printf(\"  String: %s\\n  Actual: %.17g\\nExpected: %.17g\\n\", buffer, h.actual_, d.Value());\n            }\n            else {\n                EXPECT_EQ(d.Sign(), a.Sign()); // for 0.0 != -0.0\n                EXPECT_DOUBLE_EQ(d.Value(), h.actual_);\n            }\n\n\n            d = d.Value() * 0.5;\n        }\n    }\n#undef TEST_DOUBLE\n}\n\nTEST(Reader, ParseNumber_NormalPrecisionDouble) {\n    TestParseDouble<false>();\n}\n\nTEST(Reader, ParseNumber_FullPrecisionDouble) {\n    TestParseDouble<true>();\n}\n\nTEST(Reader, ParseNumber_NormalPrecisionError) {\n    static unsigned count = 1000000;\n    Random r;\n\n    double ulpSum = 0.0;\n    double ulpMax = 0.0;\n    for (unsigned i = 0; i < count; i++) {\n        internal::Double e, a;\n        do {\n            // Need to call r() in two statements for cross-platform coherent sequence.\n            uint64_t u = uint64_t(r()) << 32;\n            u |= uint64_t(r());\n            e = u;\n        } while (e.IsNan() || e.IsInf() || !e.IsNormal());\n\n        char buffer[32];\n        *internal::dtoa(e.Value(), buffer) = '\\0';\n\n        StringStream s(buffer);\n        ParseDoubleHandler h;\n        Reader reader;\n        ASSERT_EQ(kParseErrorNone, reader.Parse(s, h).Code());\n        EXPECT_EQ(1u, h.step_);\n\n        a = h.actual_;\n        uint64_t bias1 = e.ToBias();\n        uint64_t bias2 = a.ToBias();\n        double ulp = static_cast<double>(bias1 >= bias2 ? bias1 - bias2 : bias2 - bias1);\n        ulpMax = std::max(ulpMax, ulp);\n        ulpSum += ulp;\n    }\n    printf(\"ULP Average = %g, Max = %g \\n\", ulpSum / count, ulpMax);\n}\n\nTEST(Reader, ParseNumber_Error) {\n#define TEST_NUMBER_ERROR(errorCode, str, errorOffset, streamPos) \\\n    { \\\n        char buffer[1001]; \\\n        sprintf(buffer, \"%s\", str); \\\n        InsituStringStream s(buffer); \\\n        BaseReaderHandler<> h; \\\n        Reader reader; \\\n        EXPECT_FALSE(reader.Parse(s, h)); \\\n        EXPECT_EQ(errorCode, reader.GetParseErrorCode());\\\n        EXPECT_EQ(errorOffset, reader.GetErrorOffset());\\\n        EXPECT_EQ(streamPos, s.Tell());\\\n    }\n\n    // Number too big to be stored in double.\n    {\n        char n1e309[311];   // '1' followed by 309 '0'\n        n1e309[0] = '1';\n        for (int i = 1; i < 310; i++)\n            n1e309[i] = '0';\n        n1e309[310] = '\\0';\n        TEST_NUMBER_ERROR(kParseErrorNumberTooBig, n1e309, 0, 309);\n    }\n    TEST_NUMBER_ERROR(kParseErrorNumberTooBig, \"1e309\", 0, 5);\n\n    // Miss fraction part in number.\n    TEST_NUMBER_ERROR(kParseErrorNumberMissFraction, \"1.\", 2, 2);\n    TEST_NUMBER_ERROR(kParseErrorNumberMissFraction, \"1.a\", 2, 2);\n\n    // Miss exponent in number.\n    TEST_NUMBER_ERROR(kParseErrorNumberMissExponent, \"1e\", 2, 2);\n    TEST_NUMBER_ERROR(kParseErrorNumberMissExponent, \"1e_\", 2, 2);\n\n#undef TEST_NUMBER_ERROR\n}\n\ntemplate <typename Encoding>\nstruct ParseStringHandler : BaseReaderHandler<Encoding, ParseStringHandler<Encoding> > {\n    ParseStringHandler() : str_(0), length_(0), copy_() {}\n    ~ParseStringHandler() { EXPECT_TRUE(str_ != 0); if (copy_) free(const_cast<typename Encoding::Ch*>(str_)); }\n\n    ParseStringHandler(const ParseStringHandler&);\n    ParseStringHandler& operator=(const ParseStringHandler&);\n\n    bool Default() { ADD_FAILURE(); return false; }\n    bool String(const typename Encoding::Ch* str, size_t length, bool copy) {\n        EXPECT_EQ(0, str_);\n        if (copy) {\n            str_ = static_cast<typename Encoding::Ch*>(malloc((length + 1) * sizeof(typename Encoding::Ch)));\n            memcpy(const_cast<typename Encoding::Ch*>(str_), str, (length + 1) * sizeof(typename Encoding::Ch));\n        }\n        else\n            str_ = str;\n        length_ = length;\n        copy_ = copy;\n        return true;\n    }\n\n    const typename Encoding::Ch* str_;\n    size_t length_;\n    bool copy_;\n};\n\nTEST(Reader, ParseString) {\n#define TEST_STRING(Encoding, e, x) \\\n    { \\\n        Encoding::Ch* buffer = StrDup(x); \\\n        GenericInsituStringStream<Encoding> is(buffer); \\\n        ParseStringHandler<Encoding> h; \\\n        GenericReader<Encoding, Encoding> reader; \\\n        reader.Parse<kParseInsituFlag | kParseValidateEncodingFlag>(is, h); \\\n        EXPECT_EQ(0, StrCmp<Encoding::Ch>(e, h.str_)); \\\n        EXPECT_EQ(StrLen(e), h.length_); \\\n        free(buffer); \\\n        GenericStringStream<Encoding> s(x); \\\n        ParseStringHandler<Encoding> h2; \\\n        GenericReader<Encoding, Encoding> reader2; \\\n        reader2.Parse(s, h2); \\\n        EXPECT_EQ(0, StrCmp<Encoding::Ch>(e, h2.str_)); \\\n        EXPECT_EQ(StrLen(e), h2.length_); \\\n    }\n\n    // String constant L\"\\xXX\" can only specify character code in bytes, which is not endianness-neutral.\n    // And old compiler does not support u\"\" and U\"\" string literal. So here specify string literal by array of Ch.\n    // In addition, GCC 4.8 generates -Wnarrowing warnings when character code >= 128 are assigned to signed integer types.\n    // Therefore, utype is added for declaring unsigned array, and then cast it to Encoding::Ch.\n#define ARRAY(...) { __VA_ARGS__ }\n#define TEST_STRINGARRAY(Encoding, utype, array, x) \\\n    { \\\n        static const utype ue[] = array; \\\n        static const Encoding::Ch* e = reinterpret_cast<const Encoding::Ch *>(&ue[0]); \\\n        TEST_STRING(Encoding, e, x); \\\n    }\n\n#define TEST_STRINGARRAY2(Encoding, utype, earray, xarray) \\\n    { \\\n        static const utype ue[] = earray; \\\n        static const utype xe[] = xarray; \\\n        static const Encoding::Ch* e = reinterpret_cast<const Encoding::Ch *>(&ue[0]); \\\n        static const Encoding::Ch* x = reinterpret_cast<const Encoding::Ch *>(&xe[0]); \\\n        TEST_STRING(Encoding, e, x); \\\n    }\n\n    TEST_STRING(UTF8<>, \"\", \"\\\"\\\"\");\n    TEST_STRING(UTF8<>, \"Hello\", \"\\\"Hello\\\"\");\n    TEST_STRING(UTF8<>, \"Hello\\nWorld\", \"\\\"Hello\\\\nWorld\\\"\");\n    TEST_STRING(UTF8<>, \"\\\"\\\\/\\b\\f\\n\\r\\t\", \"\\\"\\\\\\\"\\\\\\\\/\\\\b\\\\f\\\\n\\\\r\\\\t\\\"\");\n    TEST_STRING(UTF8<>, \"\\x24\", \"\\\"\\\\u0024\\\"\");         // Dollar sign U+0024\n    TEST_STRING(UTF8<>, \"\\xC2\\xA2\", \"\\\"\\\\u00A2\\\"\");     // Cents sign U+00A2\n    TEST_STRING(UTF8<>, \"\\xE2\\x82\\xAC\", \"\\\"\\\\u20AC\\\"\"); // Euro sign U+20AC\n    TEST_STRING(UTF8<>, \"\\xF0\\x9D\\x84\\x9E\", \"\\\"\\\\uD834\\\\uDD1E\\\"\");  // G clef sign U+1D11E\n\n    // UTF16\n    TEST_STRING(UTF16<>, L\"\", L\"\\\"\\\"\");\n    TEST_STRING(UTF16<>, L\"Hello\", L\"\\\"Hello\\\"\");\n    TEST_STRING(UTF16<>, L\"Hello\\nWorld\", L\"\\\"Hello\\\\nWorld\\\"\");\n    TEST_STRING(UTF16<>, L\"\\\"\\\\/\\b\\f\\n\\r\\t\", L\"\\\"\\\\\\\"\\\\\\\\/\\\\b\\\\f\\\\n\\\\r\\\\t\\\"\");\n    TEST_STRINGARRAY(UTF16<>, wchar_t, ARRAY(0x0024, 0x0000), L\"\\\"\\\\u0024\\\"\");\n    TEST_STRINGARRAY(UTF16<>, wchar_t, ARRAY(0x00A2, 0x0000), L\"\\\"\\\\u00A2\\\"\");  // Cents sign U+00A2\n    TEST_STRINGARRAY(UTF16<>, wchar_t, ARRAY(0x20AC, 0x0000), L\"\\\"\\\\u20AC\\\"\");  // Euro sign U+20AC\n    TEST_STRINGARRAY(UTF16<>, wchar_t, ARRAY(0xD834, 0xDD1E, 0x0000), L\"\\\"\\\\uD834\\\\uDD1E\\\"\");   // G clef sign U+1D11E\n\n    // UTF32\n    TEST_STRINGARRAY2(UTF32<>, unsigned, ARRAY('\\0'), ARRAY('\\\"', '\\\"', '\\0'));\n    TEST_STRINGARRAY2(UTF32<>, unsigned, ARRAY('H', 'e', 'l', 'l', 'o', '\\0'), ARRAY('\\\"', 'H', 'e', 'l', 'l', 'o', '\\\"', '\\0'));\n    TEST_STRINGARRAY2(UTF32<>, unsigned, ARRAY('H', 'e', 'l', 'l', 'o', '\\n', 'W', 'o', 'r', 'l', 'd', '\\0'), ARRAY('\\\"', 'H', 'e', 'l', 'l', 'o', '\\\\', 'n', 'W', 'o', 'r', 'l', 'd', '\\\"', '\\0'));\n    TEST_STRINGARRAY2(UTF32<>, unsigned, ARRAY('\\\"', '\\\\', '/', '\\b', '\\f', '\\n', '\\r', '\\t', '\\0'), ARRAY('\\\"', '\\\\', '\\\"', '\\\\', '\\\\', '/', '\\\\', 'b', '\\\\', 'f', '\\\\', 'n', '\\\\', 'r', '\\\\', 't', '\\\"', '\\0'));\n    TEST_STRINGARRAY2(UTF32<>, unsigned, ARRAY(0x00024, 0x0000), ARRAY('\\\"', '\\\\', 'u', '0', '0', '2', '4', '\\\"', '\\0'));\n    TEST_STRINGARRAY2(UTF32<>, unsigned, ARRAY(0x000A2, 0x0000), ARRAY('\\\"', '\\\\', 'u', '0', '0', 'A', '2', '\\\"', '\\0'));   // Cents sign U+00A2\n    TEST_STRINGARRAY2(UTF32<>, unsigned, ARRAY(0x020AC, 0x0000), ARRAY('\\\"', '\\\\', 'u', '2', '0', 'A', 'C', '\\\"', '\\0'));   // Euro sign U+20AC\n    TEST_STRINGARRAY2(UTF32<>, unsigned, ARRAY(0x1D11E, 0x0000), ARRAY('\\\"', '\\\\', 'u', 'D', '8', '3', '4', '\\\\', 'u', 'D', 'D', '1', 'E', '\\\"', '\\0'));    // G clef sign U+1D11E\n\n#undef TEST_STRINGARRAY\n#undef ARRAY\n#undef TEST_STRING\n\n    // Support of null character in string\n    {\n        StringStream s(\"\\\"Hello\\\\u0000World\\\"\");\n        const char e[] = \"Hello\\0World\";\n        ParseStringHandler<UTF8<> > h;\n        Reader reader;\n        reader.Parse(s, h);\n        EXPECT_EQ(0, memcmp(e, h.str_, h.length_ + 1));\n        EXPECT_EQ(11u, h.length_);\n    }\n}\n\nTEST(Reader, ParseString_Transcoding) {\n    const char* x = \"\\\"Hello\\\"\";\n    const wchar_t* e = L\"Hello\";\n    GenericStringStream<UTF8<> > is(x);\n    GenericReader<UTF8<>, UTF16<> > reader;\n    ParseStringHandler<UTF16<> > h;\n    reader.Parse(is, h);\n    EXPECT_EQ(0, StrCmp<UTF16<>::Ch>(e, h.str_));\n    EXPECT_EQ(StrLen(e), h.length_);\n}\n\nTEST(Reader, ParseString_TranscodingWithValidation) {\n    const char* x = \"\\\"Hello\\\"\";\n    const wchar_t* e = L\"Hello\";\n    GenericStringStream<UTF8<> > is(x);\n    GenericReader<UTF8<>, UTF16<> > reader;\n    ParseStringHandler<UTF16<> > h;\n    reader.Parse<kParseValidateEncodingFlag>(is, h);\n    EXPECT_EQ(0, StrCmp<UTF16<>::Ch>(e, h.str_));\n    EXPECT_EQ(StrLen(e), h.length_);\n}\n\nTEST(Reader, ParseString_NonDestructive) {\n    StringStream s(\"\\\"Hello\\\\nWorld\\\"\");\n    ParseStringHandler<UTF8<> > h;\n    Reader reader;\n    reader.Parse(s, h);\n    EXPECT_EQ(0, StrCmp(\"Hello\\nWorld\", h.str_));\n    EXPECT_EQ(11u, h.length_);\n}\n\ntemplate <typename Encoding>\nParseErrorCode TestString(const typename Encoding::Ch* str) {\n    GenericStringStream<Encoding> s(str);\n    BaseReaderHandler<Encoding> h;\n    GenericReader<Encoding, Encoding> reader;\n    reader.template Parse<kParseValidateEncodingFlag>(s, h);\n    return reader.GetParseErrorCode();\n}\n\nTEST(Reader, ParseString_Error) {\n#define TEST_STRING_ERROR(errorCode, str, errorOffset, streamPos)\\\n{\\\n    GenericStringStream<UTF8<> > s(str);\\\n    BaseReaderHandler<UTF8<> > h;\\\n    GenericReader<UTF8<> , UTF8<> > reader;\\\n    reader.Parse<kParseValidateEncodingFlag>(s, h);\\\n    EXPECT_EQ(errorCode, reader.GetParseErrorCode());\\\n    EXPECT_EQ(errorOffset, reader.GetErrorOffset());\\\n    EXPECT_EQ(streamPos, s.Tell());\\\n}\n\n#define ARRAY(...) { __VA_ARGS__ }\n#define TEST_STRINGENCODING_ERROR(Encoding, TargetEncoding, utype, array) \\\n    { \\\n        static const utype ue[] = array; \\\n        static const Encoding::Ch* e = reinterpret_cast<const Encoding::Ch *>(&ue[0]); \\\n        EXPECT_EQ(kParseErrorStringInvalidEncoding, TestString<Encoding>(e));\\\n        /* decode error */\\\n        GenericStringStream<Encoding> s(e);\\\n        BaseReaderHandler<TargetEncoding> h;\\\n        GenericReader<Encoding, TargetEncoding> reader;\\\n        reader.Parse(s, h);\\\n        EXPECT_EQ(kParseErrorStringInvalidEncoding, reader.GetParseErrorCode());\\\n    }\n\n    // Invalid escape character in string.\n    TEST_STRING_ERROR(kParseErrorStringEscapeInvalid, \"[\\\"\\\\a\\\"]\", 2, 3);\n\n    // Incorrect hex digit after \\\\u escape in string.\n    TEST_STRING_ERROR(kParseErrorStringUnicodeEscapeInvalidHex, \"[\\\"\\\\uABCG\\\"]\", 2, 7);\n\n    // Quotation in \\\\u escape in string (Issue #288)\n    TEST_STRING_ERROR(kParseErrorStringUnicodeEscapeInvalidHex, \"[\\\"\\\\uaaa\\\"]\", 2, 7);\n    TEST_STRING_ERROR(kParseErrorStringUnicodeEscapeInvalidHex, \"[\\\"\\\\uD800\\\\uFFF\\\"]\", 2, 13);\n\n    // The surrogate pair in string is invalid.\n    TEST_STRING_ERROR(kParseErrorStringUnicodeSurrogateInvalid, \"[\\\"\\\\uD800X\\\"]\", 2, 8);\n    TEST_STRING_ERROR(kParseErrorStringUnicodeSurrogateInvalid, \"[\\\"\\\\uD800\\\\uFFFF\\\"]\", 2, 14);\n\n    // Missing a closing quotation mark in string.\n    TEST_STRING_ERROR(kParseErrorStringMissQuotationMark, \"[\\\"Test]\", 7, 7);\n\n    // http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt\n\n    // 3  Malformed sequences\n\n    // 3.1 Unexpected continuation bytes\n    {\n         char e[] = { '[', '\\\"', 0, '\\\"', ']', '\\0' };\n         for (unsigned char c = 0x80u; c <= 0xBFu; c++) {\n            e[2] = static_cast<char>(c);\n            ParseErrorCode error = TestString<UTF8<> >(e);\n            EXPECT_EQ(kParseErrorStringInvalidEncoding, error);\n            if (error != kParseErrorStringInvalidEncoding)\n                std::cout << static_cast<unsigned>(c) << std::endl;\n         }\n    }\n\n    // 3.2 Lonely start characters, 3.5 Impossible bytes\n    {\n        char e[] = { '[', '\\\"', 0, ' ', '\\\"', ']', '\\0' };\n        for (unsigned c = 0xC0u; c <= 0xFFu; c++) {\n            e[2] = static_cast<char>(c);\n            int streamPos;\n            if (c <= 0xC1u)\n                streamPos = 3; // 0xC0 - 0xC1\n            else if (c <= 0xDFu)\n                streamPos = 4; // 0xC2 - 0xDF\n            else if (c <= 0xEFu)\n                streamPos = 5; // 0xE0 - 0xEF\n            else if (c <= 0xF4u)\n                streamPos = 6; // 0xF0 - 0xF4\n            else\n                streamPos = 3; // 0xF5 - 0xFF\n            TEST_STRING_ERROR(kParseErrorStringInvalidEncoding, e, 2, streamPos);\n        }\n    }\n\n    // 4  Overlong sequences\n\n    // 4.1  Examples of an overlong ASCII character\n    TEST_STRINGENCODING_ERROR(UTF8<>, UTF16<>, unsigned char, ARRAY('[', '\\\"', 0xC0u, 0xAFu, '\\\"', ']', '\\0'));\n    TEST_STRINGENCODING_ERROR(UTF8<>, UTF16<>, unsigned char, ARRAY('[', '\\\"', 0xE0u, 0x80u, 0xAFu, '\\\"', ']', '\\0'));\n    TEST_STRINGENCODING_ERROR(UTF8<>, UTF16<>, unsigned char, ARRAY('[', '\\\"', 0xF0u, 0x80u, 0x80u, 0xAFu, '\\\"', ']', '\\0'));\n\n    // 4.2  Maximum overlong sequences\n    TEST_STRINGENCODING_ERROR(UTF8<>, UTF16<>, unsigned char, ARRAY('[', '\\\"', 0xC1u, 0xBFu, '\\\"', ']', '\\0'));\n    TEST_STRINGENCODING_ERROR(UTF8<>, UTF16<>, unsigned char, ARRAY('[', '\\\"', 0xE0u, 0x9Fu, 0xBFu, '\\\"', ']', '\\0'));\n    TEST_STRINGENCODING_ERROR(UTF8<>, UTF16<>, unsigned char, ARRAY('[', '\\\"', 0xF0u, 0x8Fu, 0xBFu, 0xBFu, '\\\"', ']', '\\0'));\n\n    // 4.3  Overlong representation of the NUL character\n    TEST_STRINGENCODING_ERROR(UTF8<>, UTF16<>, unsigned char, ARRAY('[', '\\\"', 0xC0u, 0x80u, '\\\"', ']', '\\0'));\n    TEST_STRINGENCODING_ERROR(UTF8<>, UTF16<>, unsigned char, ARRAY('[', '\\\"', 0xE0u, 0x80u, 0x80u, '\\\"', ']', '\\0'));\n    TEST_STRINGENCODING_ERROR(UTF8<>, UTF16<>, unsigned char, ARRAY('[', '\\\"', 0xF0u, 0x80u, 0x80u, 0x80u, '\\\"', ']', '\\0'));\n\n    // 5  Illegal code positions\n\n    // 5.1 Single UTF-16 surrogates\n    TEST_STRINGENCODING_ERROR(UTF8<>, UTF16<>, unsigned char, ARRAY('[', '\\\"', 0xEDu, 0xA0u, 0x80u, '\\\"', ']', '\\0'));\n    TEST_STRINGENCODING_ERROR(UTF8<>, UTF16<>, unsigned char, ARRAY('[', '\\\"', 0xEDu, 0xADu, 0xBFu, '\\\"', ']', '\\0'));\n    TEST_STRINGENCODING_ERROR(UTF8<>, UTF16<>, unsigned char, ARRAY('[', '\\\"', 0xEDu, 0xAEu, 0x80u, '\\\"', ']', '\\0'));\n    TEST_STRINGENCODING_ERROR(UTF8<>, UTF16<>, unsigned char, ARRAY('[', '\\\"', 0xEDu, 0xAFu, 0xBFu, '\\\"', ']', '\\0'));\n    TEST_STRINGENCODING_ERROR(UTF8<>, UTF16<>, unsigned char, ARRAY('[', '\\\"', 0xEDu, 0xB0u, 0x80u, '\\\"', ']', '\\0'));\n    TEST_STRINGENCODING_ERROR(UTF8<>, UTF16<>, unsigned char, ARRAY('[', '\\\"', 0xEDu, 0xBEu, 0x80u, '\\\"', ']', '\\0'));\n    TEST_STRINGENCODING_ERROR(UTF8<>, UTF16<>, unsigned char, ARRAY('[', '\\\"', 0xEDu, 0xBFu, 0xBFu, '\\\"', ']', '\\0'));\n\n    // Malform UTF-16 sequences\n    TEST_STRINGENCODING_ERROR(UTF16<>, UTF8<>, wchar_t, ARRAY('[', '\\\"', 0xDC00, 0xDC00, '\\\"', ']', '\\0'));\n    TEST_STRINGENCODING_ERROR(UTF16<>, UTF8<>, wchar_t, ARRAY('[', '\\\"', 0xD800, 0xD800, '\\\"', ']', '\\0'));\n\n    // Malform UTF-32 sequence\n    TEST_STRINGENCODING_ERROR(UTF32<>, UTF8<>, unsigned, ARRAY('[', '\\\"', 0x110000, '\\\"', ']', '\\0'));\n\n    // Malform ASCII sequence\n    TEST_STRINGENCODING_ERROR(ASCII<>, UTF8<>, char, ARRAY('[', '\\\"', char(0x80u), '\\\"', ']', '\\0'));\n\n#undef ARRAY\n#undef TEST_STRINGARRAY_ERROR\n}\n\ntemplate <unsigned count>\nstruct ParseArrayHandler : BaseReaderHandler<UTF8<>, ParseArrayHandler<count> > {\n    ParseArrayHandler() : step_(0) {}\n\n    bool Default() { ADD_FAILURE(); return false; }\n    bool Uint(unsigned i) { EXPECT_EQ(step_, i); step_++; return true; }\n    bool StartArray() { EXPECT_EQ(0u, step_); step_++; return true; }\n    bool EndArray(SizeType) { step_++; return true; }\n\n    unsigned step_;\n};\n\nTEST(Reader, ParseEmptyArray) {\n    char *json = StrDup(\"[ ] \");\n    InsituStringStream s(json);\n    ParseArrayHandler<0> h;\n    Reader reader;\n    reader.Parse(s, h);\n    EXPECT_EQ(2u, h.step_);\n    free(json);\n}\n\nTEST(Reader, ParseArray) {\n    char *json = StrDup(\"[1, 2, 3, 4]\");\n    InsituStringStream s(json);\n    ParseArrayHandler<4> h;\n    Reader reader;\n    reader.Parse(s, h);\n    EXPECT_EQ(6u, h.step_);\n    free(json);\n}\n\nTEST(Reader, ParseArray_Error) {\n#define TEST_ARRAY_ERROR(errorCode, str, errorOffset) \\\n    { \\\n        int streamPos = errorOffset; \\\n        char buffer[1001]; \\\n        strncpy(buffer, str, 1000); \\\n        InsituStringStream s(buffer); \\\n        BaseReaderHandler<> h; \\\n        GenericReader<UTF8<>, UTF8<>, CrtAllocator> reader; \\\n        EXPECT_FALSE(reader.Parse(s, h)); \\\n        EXPECT_EQ(errorCode, reader.GetParseErrorCode());\\\n        EXPECT_EQ(errorOffset, reader.GetErrorOffset());\\\n        EXPECT_EQ(streamPos, s.Tell());\\\n    }\n\n    // Missing a comma or ']' after an array element.\n    TEST_ARRAY_ERROR(kParseErrorArrayMissCommaOrSquareBracket, \"[1\", 2);\n    TEST_ARRAY_ERROR(kParseErrorArrayMissCommaOrSquareBracket, \"[1}\", 2);\n    TEST_ARRAY_ERROR(kParseErrorArrayMissCommaOrSquareBracket, \"[1 2]\", 3);\n\n    // Array cannot have a trailing comma (without kParseTrailingCommasFlag);\n    // a value must follow a comma\n    TEST_ARRAY_ERROR(kParseErrorValueInvalid, \"[1,]\", 3);\n\n#undef TEST_ARRAY_ERROR\n}\n\nstruct ParseObjectHandler : BaseReaderHandler<UTF8<>, ParseObjectHandler> {\n    ParseObjectHandler() : step_(0) {}\n\n    bool Default() { ADD_FAILURE(); return false; }\n    bool Null() { EXPECT_EQ(8u, step_); step_++; return true; }\n    bool Bool(bool b) {\n        switch(step_) {\n            case 4: EXPECT_TRUE(b); step_++; return true;\n            case 6: EXPECT_FALSE(b); step_++; return true;\n            default: ADD_FAILURE(); return false;\n        }\n    }\n    bool Int(int i) {\n        switch(step_) {\n            case 10: EXPECT_EQ(123, i); step_++; return true;\n            case 15: EXPECT_EQ(1, i); step_++; return true;\n            case 16: EXPECT_EQ(2, i); step_++; return true;\n            case 17: EXPECT_EQ(3, i); step_++; return true;\n            default: ADD_FAILURE(); return false;\n        }\n    }\n    bool Uint(unsigned i) { return Int(static_cast<int>(i)); }\n    bool Double(double d) { EXPECT_EQ(12u, step_); EXPECT_DOUBLE_EQ(3.1416, d); step_++; return true; }\n    bool String(const char* str, size_t, bool) {\n        switch(step_) {\n            case 1: EXPECT_STREQ(\"hello\", str); step_++; return true;\n            case 2: EXPECT_STREQ(\"world\", str); step_++; return true;\n            case 3: EXPECT_STREQ(\"t\", str); step_++; return true;\n            case 5: EXPECT_STREQ(\"f\", str); step_++; return true;\n            case 7: EXPECT_STREQ(\"n\", str); step_++; return true;\n            case 9: EXPECT_STREQ(\"i\", str); step_++; return true;\n            case 11: EXPECT_STREQ(\"pi\", str); step_++; return true;\n            case 13: EXPECT_STREQ(\"a\", str); step_++; return true;\n            default: ADD_FAILURE(); return false;\n        }\n    }\n    bool StartObject() { EXPECT_EQ(0u, step_); step_++; return true; }\n    bool EndObject(SizeType memberCount) { EXPECT_EQ(19u, step_); EXPECT_EQ(7u, memberCount); step_++; return true; }\n    bool StartArray() { EXPECT_EQ(14u, step_); step_++; return true; }\n    bool EndArray(SizeType elementCount) { EXPECT_EQ(18u, step_); EXPECT_EQ(3u, elementCount); step_++; return true; }\n\n    unsigned step_;\n};\n\nTEST(Reader, ParseObject) {\n    const char* json = \"{ \\\"hello\\\" : \\\"world\\\", \\\"t\\\" : true , \\\"f\\\" : false, \\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3] } \";\n\n    // Insitu\n    {\n        char* json2 = StrDup(json);\n        InsituStringStream s(json2);\n        ParseObjectHandler h;\n        Reader reader;\n        reader.Parse<kParseInsituFlag>(s, h);\n        EXPECT_EQ(20u, h.step_);\n        free(json2);\n    }\n\n    // Normal\n    {\n        StringStream s(json);\n        ParseObjectHandler h;\n        Reader reader;\n        reader.Parse(s, h);\n        EXPECT_EQ(20u, h.step_);\n    }\n}\n\nstruct ParseEmptyObjectHandler : BaseReaderHandler<UTF8<>, ParseEmptyObjectHandler> {\n    ParseEmptyObjectHandler() : step_(0) {}\n\n    bool Default() { ADD_FAILURE(); return false; }\n    bool StartObject() { EXPECT_EQ(0u, step_); step_++; return true; }\n    bool EndObject(SizeType) { EXPECT_EQ(1u, step_); step_++; return true; }\n\n    unsigned step_;\n};\n\nTEST(Reader, Parse_EmptyObject) {\n    StringStream s(\"{ } \");\n    ParseEmptyObjectHandler h;\n    Reader reader;\n    reader.Parse(s, h);\n    EXPECT_EQ(2u, h.step_);\n}\n\nstruct ParseMultipleRootHandler : BaseReaderHandler<UTF8<>, ParseMultipleRootHandler> {\n    ParseMultipleRootHandler() : step_(0) {}\n\n    bool Default() { ADD_FAILURE(); return false; }\n    bool StartObject() { EXPECT_EQ(0u, step_); step_++; return true; }\n    bool EndObject(SizeType) { EXPECT_EQ(1u, step_); step_++; return true; }\n    bool StartArray() { EXPECT_EQ(2u, step_); step_++; return true; }\n    bool EndArray(SizeType) { EXPECT_EQ(3u, step_); step_++; return true; }\n\n    unsigned step_;\n};\n\ntemplate <unsigned parseFlags>\nvoid TestMultipleRoot() {\n    StringStream s(\"{}[] a\");\n    ParseMultipleRootHandler h;\n    Reader reader;\n    EXPECT_TRUE(reader.Parse<parseFlags>(s, h));\n    EXPECT_EQ(2u, h.step_);\n    EXPECT_TRUE(reader.Parse<parseFlags>(s, h));\n    EXPECT_EQ(4u, h.step_);\n    EXPECT_EQ(' ', s.Take());\n    EXPECT_EQ('a', s.Take());\n}\n\nTEST(Reader, Parse_MultipleRoot) {\n    TestMultipleRoot<kParseStopWhenDoneFlag>();\n}\n\nTEST(Reader, ParseIterative_MultipleRoot) {\n    TestMultipleRoot<kParseIterativeFlag | kParseStopWhenDoneFlag>();\n}\n\ntemplate <unsigned parseFlags>\nvoid TestInsituMultipleRoot() {\n    char* buffer = strdup(\"{}[] a\");\n    InsituStringStream s(buffer);\n    ParseMultipleRootHandler h;\n    Reader reader;\n    EXPECT_TRUE(reader.Parse<kParseInsituFlag | parseFlags>(s, h));\n    EXPECT_EQ(2u, h.step_);\n    EXPECT_TRUE(reader.Parse<kParseInsituFlag | parseFlags>(s, h));\n    EXPECT_EQ(4u, h.step_);\n    EXPECT_EQ(' ', s.Take());\n    EXPECT_EQ('a', s.Take());\n    free(buffer);\n}\n\nTEST(Reader, ParseInsitu_MultipleRoot) {\n    TestInsituMultipleRoot<kParseStopWhenDoneFlag>();\n}\n\nTEST(Reader, ParseInsituIterative_MultipleRoot) {\n    TestInsituMultipleRoot<kParseIterativeFlag | kParseStopWhenDoneFlag>();\n}\n\n#define TEST_ERROR(errorCode, str, errorOffset) \\\n    { \\\n        int streamPos = errorOffset; \\\n        char buffer[1001]; \\\n        strncpy(buffer, str, 1000); \\\n        InsituStringStream s(buffer); \\\n        BaseReaderHandler<> h; \\\n        Reader reader; \\\n        EXPECT_FALSE(reader.Parse(s, h)); \\\n        EXPECT_EQ(errorCode, reader.GetParseErrorCode());\\\n        EXPECT_EQ(errorOffset, reader.GetErrorOffset());\\\n        EXPECT_EQ(streamPos, s.Tell());\\\n    }\n\nTEST(Reader, ParseDocument_Error) {\n    // The document is empty.\n    TEST_ERROR(kParseErrorDocumentEmpty, \"\", 0);\n    TEST_ERROR(kParseErrorDocumentEmpty, \" \", 1);\n    TEST_ERROR(kParseErrorDocumentEmpty, \" \\n\", 2);\n\n    // The document root must not follow by other values.\n    TEST_ERROR(kParseErrorDocumentRootNotSingular, \"[] 0\", 3);\n    TEST_ERROR(kParseErrorDocumentRootNotSingular, \"{} 0\", 3);\n    TEST_ERROR(kParseErrorDocumentRootNotSingular, \"null []\", 5);\n    TEST_ERROR(kParseErrorDocumentRootNotSingular, \"0 {}\", 2);\n}\n\nTEST(Reader, ParseValue_Error) {\n    // Invalid value.\n    TEST_ERROR(kParseErrorValueInvalid, \"nulL\", 3);\n    TEST_ERROR(kParseErrorValueInvalid, \"truE\", 3);\n    TEST_ERROR(kParseErrorValueInvalid, \"falsE\", 4);\n    TEST_ERROR(kParseErrorValueInvalid, \"a]\", 0);\n    TEST_ERROR(kParseErrorValueInvalid, \".1\", 0);\n}\n\nTEST(Reader, ParseObject_Error) {\n    // Missing a name for object member.\n    TEST_ERROR(kParseErrorObjectMissName, \"{1}\", 1);\n    TEST_ERROR(kParseErrorObjectMissName, \"{:1}\", 1);\n    TEST_ERROR(kParseErrorObjectMissName, \"{null:1}\", 1);\n    TEST_ERROR(kParseErrorObjectMissName, \"{true:1}\", 1);\n    TEST_ERROR(kParseErrorObjectMissName, \"{false:1}\", 1);\n    TEST_ERROR(kParseErrorObjectMissName, \"{1:1}\", 1);\n    TEST_ERROR(kParseErrorObjectMissName, \"{[]:1}\", 1);\n    TEST_ERROR(kParseErrorObjectMissName, \"{{}:1}\", 1);\n    TEST_ERROR(kParseErrorObjectMissName, \"{xyz:1}\", 1);\n\n    // Missing a colon after a name of object member.\n    TEST_ERROR(kParseErrorObjectMissColon, \"{\\\"a\\\" 1}\", 5);\n    TEST_ERROR(kParseErrorObjectMissColon, \"{\\\"a\\\",1}\", 4);\n\n    // Must be a comma or '}' after an object member\n    TEST_ERROR(kParseErrorObjectMissCommaOrCurlyBracket, \"{\\\"a\\\":1]\", 6);\n\n    // Object cannot have a trailing comma (without kParseTrailingCommasFlag);\n    // an object member name must follow a comma\n    TEST_ERROR(kParseErrorObjectMissName, \"{\\\"a\\\":1,}\", 7);\n\n    // This tests that MemoryStream is checking the length in Peek().\n    {\n        MemoryStream ms(\"{\\\"a\\\"\", 1);\n        BaseReaderHandler<> h;\n        Reader reader;\n        EXPECT_FALSE(reader.Parse<kParseStopWhenDoneFlag>(ms, h));\n        EXPECT_EQ(kParseErrorObjectMissName, reader.GetParseErrorCode());\n    }\n}\n\n#undef TEST_ERROR\n\nTEST(Reader, SkipWhitespace) {\n    StringStream ss(\" A \\t\\tB\\n \\n\\nC\\r\\r \\rD \\t\\n\\r E\");\n    const char* expected = \"ABCDE\";\n    for (size_t i = 0; i < 5; i++) {\n        SkipWhitespace(ss);\n        EXPECT_EQ(expected[i], ss.Take());\n    }\n}\n\n// Test implementing a stream without copy stream optimization.\n// Clone from GenericStringStream except that copy constructor is disabled.\ntemplate <typename Encoding>\nclass CustomStringStream {\npublic:\n    typedef typename Encoding::Ch Ch;\n\n    CustomStringStream(const Ch *src) : src_(src), head_(src) {}\n\n    Ch Peek() const { return *src_; }\n    Ch Take() { return *src_++; }\n    size_t Tell() const { return static_cast<size_t>(src_ - head_); }\n\n    Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }\n    void Put(Ch) { RAPIDJSON_ASSERT(false); }\n    void Flush() { RAPIDJSON_ASSERT(false); }\n    size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }\n\nprivate:\n    // Prohibit copy constructor & assignment operator.\n    CustomStringStream(const CustomStringStream&);\n    CustomStringStream& operator=(const CustomStringStream&);\n\n    const Ch* src_;     //!< Current read position.\n    const Ch* head_;    //!< Original head of the string.\n};\n\n// If the following code is compiled, it should generate compilation error as predicted.\n// Because CustomStringStream<> is not copyable via making copy constructor private.\n#if 0\nnamespace rapidjson {\n\ntemplate <typename Encoding>\nstruct StreamTraits<CustomStringStream<Encoding> > {\n    enum { copyOptimization = 1 };\n};\n\n} // namespace rapidjson\n#endif\n\nTEST(Reader, CustomStringStream) {\n    const char* json = \"{ \\\"hello\\\" : \\\"world\\\", \\\"t\\\" : true , \\\"f\\\" : false, \\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3] } \";\n    CustomStringStream<UTF8<char> > s(json);\n    ParseObjectHandler h;\n    Reader reader;\n    reader.Parse(s, h);\n    EXPECT_EQ(20u, h.step_);\n}\n\n#include <sstream>\n\nclass IStreamWrapper {\npublic:\n    typedef char Ch;\n\n    IStreamWrapper(std::istream& is) : is_(is) {}\n\n    Ch Peek() const {\n        int c = is_.peek();\n        return c == std::char_traits<char>::eof() ? '\\0' : static_cast<Ch>(c);\n    }\n\n    Ch Take() {\n        int c = is_.get();\n        return c == std::char_traits<char>::eof() ? '\\0' : static_cast<Ch>(c);\n    }\n\n    size_t Tell() const { return static_cast<size_t>(is_.tellg()); }\n\n    Ch* PutBegin() { assert(false); return 0; }\n    void Put(Ch) { assert(false); }\n    void Flush() { assert(false); }\n    size_t PutEnd(Ch*) { assert(false); return 0; }\n\nprivate:\n    IStreamWrapper(const IStreamWrapper&);\n    IStreamWrapper& operator=(const IStreamWrapper&);\n\n    std::istream& is_;\n};\n\nTEST(Reader, Parse_IStreamWrapper_StringStream) {\n    const char* json = \"[1,2,3,4]\";\n\n    std::stringstream ss(json);\n    IStreamWrapper is(ss);\n\n    Reader reader;\n    ParseArrayHandler<4> h;\n    reader.Parse(is, h);\n    EXPECT_FALSE(reader.HasParseError());\n}\n\n// Test iterative parsing.\n\n#define TESTERRORHANDLING(text, errorCode, offset)\\\n{\\\n    int streamPos = offset; \\\n    StringStream json(text); \\\n    BaseReaderHandler<> handler; \\\n    Reader reader; \\\n    reader.Parse<kParseIterativeFlag>(json, handler); \\\n    EXPECT_TRUE(reader.HasParseError()); \\\n    EXPECT_EQ(errorCode, reader.GetParseErrorCode()); \\\n    EXPECT_EQ(offset, reader.GetErrorOffset()); \\\n    EXPECT_EQ(streamPos, json.Tell()); \\\n}\n\nTEST(Reader, IterativeParsing_ErrorHandling) {\n    TESTERRORHANDLING(\"{\\\"a\\\": a}\", kParseErrorValueInvalid, 6u);\n\n    TESTERRORHANDLING(\"\", kParseErrorDocumentEmpty, 0u);\n    TESTERRORHANDLING(\"{}{}\", kParseErrorDocumentRootNotSingular, 2u);\n\n    TESTERRORHANDLING(\"{1}\", kParseErrorObjectMissName, 1u);\n    TESTERRORHANDLING(\"{\\\"a\\\", 1}\", kParseErrorObjectMissColon, 4u);\n    TESTERRORHANDLING(\"{\\\"a\\\"}\", kParseErrorObjectMissColon, 4u);\n    TESTERRORHANDLING(\"{\\\"a\\\": 1\", kParseErrorObjectMissCommaOrCurlyBracket, 7u);\n    TESTERRORHANDLING(\"[1 2 3]\", kParseErrorArrayMissCommaOrSquareBracket, 3u);\n    TESTERRORHANDLING(\"{\\\"a: 1\", kParseErrorStringMissQuotationMark, 6u);\n    TESTERRORHANDLING(\"{\\\"a\\\":}\", kParseErrorValueInvalid, 5u);\n    TESTERRORHANDLING(\"{\\\"a\\\":]\", kParseErrorValueInvalid, 5u);\n    TESTERRORHANDLING(\"[1,2,}\", kParseErrorValueInvalid, 5u);\n    TESTERRORHANDLING(\"[}]\", kParseErrorValueInvalid, 1u);\n    TESTERRORHANDLING(\"[,]\", kParseErrorValueInvalid, 1u);\n    TESTERRORHANDLING(\"[1,,]\", kParseErrorValueInvalid, 3u);\n\n    // Trailing commas are not allowed without kParseTrailingCommasFlag\n    TESTERRORHANDLING(\"{\\\"a\\\": 1,}\", kParseErrorObjectMissName, 8u);\n    TESTERRORHANDLING(\"[1,2,3,]\", kParseErrorValueInvalid, 7u);\n\n    // Any JSON value can be a valid root element in RFC7159.\n    TESTERRORHANDLING(\"\\\"ab\", kParseErrorStringMissQuotationMark, 3u);\n    TESTERRORHANDLING(\"truE\", kParseErrorValueInvalid, 3u);\n    TESTERRORHANDLING(\"False\", kParseErrorValueInvalid, 0u);\n    TESTERRORHANDLING(\"true, false\", kParseErrorDocumentRootNotSingular, 4u);\n    TESTERRORHANDLING(\"false, false\", kParseErrorDocumentRootNotSingular, 5u);\n    TESTERRORHANDLING(\"nulL\", kParseErrorValueInvalid, 3u);\n    TESTERRORHANDLING(\"null , null\", kParseErrorDocumentRootNotSingular, 5u);\n    TESTERRORHANDLING(\"1a\", kParseErrorDocumentRootNotSingular, 1u);\n}\n\ntemplate<typename Encoding = UTF8<> >\nstruct IterativeParsingReaderHandler {\n    typedef typename Encoding::Ch Ch;\n\n    const static int LOG_NULL = -1;\n    const static int LOG_BOOL = -2;\n    const static int LOG_INT = -3;\n    const static int LOG_UINT = -4;\n    const static int LOG_INT64 = -5;\n    const static int LOG_UINT64 = -6;\n    const static int LOG_DOUBLE = -7;\n    const static int LOG_STRING = -8;\n    const static int LOG_STARTOBJECT = -9;\n    const static int LOG_KEY = -10;\n    const static int LOG_ENDOBJECT = -11;\n    const static int LOG_STARTARRAY = -12;\n    const static int LOG_ENDARRAY = -13;\n\n    const static size_t LogCapacity = 256;\n    int Logs[LogCapacity];\n    size_t LogCount;\n\n    IterativeParsingReaderHandler() : LogCount(0) {\n    }\n\n    bool Null() { RAPIDJSON_ASSERT(LogCount < LogCapacity); Logs[LogCount++] = LOG_NULL; return true; }\n\n    bool Bool(bool) { RAPIDJSON_ASSERT(LogCount < LogCapacity); Logs[LogCount++] = LOG_BOOL; return true; }\n\n    bool Int(int) { RAPIDJSON_ASSERT(LogCount < LogCapacity); Logs[LogCount++] = LOG_INT; return true; }\n\n    bool Uint(unsigned) { RAPIDJSON_ASSERT(LogCount < LogCapacity); Logs[LogCount++] = LOG_INT; return true; }\n\n    bool Int64(int64_t) { RAPIDJSON_ASSERT(LogCount < LogCapacity); Logs[LogCount++] = LOG_INT64; return true; }\n\n    bool Uint64(uint64_t) { RAPIDJSON_ASSERT(LogCount < LogCapacity); Logs[LogCount++] = LOG_UINT64; return true; }\n\n    bool Double(double) { RAPIDJSON_ASSERT(LogCount < LogCapacity); Logs[LogCount++] = LOG_DOUBLE; return true; }\n\n    bool RawNumber(const Ch*, SizeType, bool) { RAPIDJSON_ASSERT(LogCount < LogCapacity); Logs[LogCount++] = LOG_STRING; return true; }\n\n    bool String(const Ch*, SizeType, bool) { RAPIDJSON_ASSERT(LogCount < LogCapacity); Logs[LogCount++] = LOG_STRING; return true; }\n\n    bool StartObject() { RAPIDJSON_ASSERT(LogCount < LogCapacity); Logs[LogCount++] = LOG_STARTOBJECT; return true; }\n\n    bool Key (const Ch*, SizeType, bool) { RAPIDJSON_ASSERT(LogCount < LogCapacity); Logs[LogCount++] = LOG_KEY; return true; }\n\n    bool EndObject(SizeType c) {\n        RAPIDJSON_ASSERT(LogCount < LogCapacity);\n        Logs[LogCount++] = LOG_ENDOBJECT;\n        Logs[LogCount++] = static_cast<int>(c);\n        return true;\n    }\n\n    bool StartArray() { RAPIDJSON_ASSERT(LogCount < LogCapacity); Logs[LogCount++] = LOG_STARTARRAY; return true; }\n\n    bool EndArray(SizeType c) {\n        RAPIDJSON_ASSERT(LogCount < LogCapacity);\n        Logs[LogCount++] = LOG_ENDARRAY;\n        Logs[LogCount++] = static_cast<int>(c);\n        return true;\n    }\n};\n\nTEST(Reader, IterativeParsing_General) {\n    {\n        StringStream is(\"[1, {\\\"k\\\": [1, 2]}, null, false, true, \\\"string\\\", 1.2]\");\n        Reader reader;\n        IterativeParsingReaderHandler<> handler;\n\n        ParseResult r = reader.Parse<kParseIterativeFlag>(is, handler);\n\n        EXPECT_FALSE(r.IsError());\n        EXPECT_FALSE(reader.HasParseError());\n\n        int e[] = {\n            handler.LOG_STARTARRAY,\n            handler.LOG_INT,\n            handler.LOG_STARTOBJECT,\n            handler.LOG_KEY,\n            handler.LOG_STARTARRAY,\n            handler.LOG_INT,\n            handler.LOG_INT,\n            handler.LOG_ENDARRAY, 2,\n            handler.LOG_ENDOBJECT, 1,\n            handler.LOG_NULL,\n            handler.LOG_BOOL,\n            handler.LOG_BOOL,\n            handler.LOG_STRING,\n            handler.LOG_DOUBLE,\n            handler.LOG_ENDARRAY, 7\n        };\n\n        EXPECT_EQ(sizeof(e) / sizeof(int), handler.LogCount);\n\n        for (size_t i = 0; i < handler.LogCount; ++i) {\n            EXPECT_EQ(e[i], handler.Logs[i]) << \"i = \" << i;\n        }\n    }\n}\n\nTEST(Reader, IterativeParsing_Count) {\n    {\n        StringStream is(\"[{}, {\\\"k\\\": 1}, [1], []]\");\n        Reader reader;\n        IterativeParsingReaderHandler<> handler;\n\n        ParseResult r = reader.Parse<kParseIterativeFlag>(is, handler);\n\n        EXPECT_FALSE(r.IsError());\n        EXPECT_FALSE(reader.HasParseError());\n\n        int e[] = {\n            handler.LOG_STARTARRAY,\n            handler.LOG_STARTOBJECT,\n            handler.LOG_ENDOBJECT, 0,\n            handler.LOG_STARTOBJECT,\n            handler.LOG_KEY,\n            handler.LOG_INT,\n            handler.LOG_ENDOBJECT, 1,\n            handler.LOG_STARTARRAY,\n            handler.LOG_INT,\n            handler.LOG_ENDARRAY, 1,\n            handler.LOG_STARTARRAY,\n            handler.LOG_ENDARRAY, 0,\n            handler.LOG_ENDARRAY, 4\n        };\n\n        EXPECT_EQ(sizeof(e) / sizeof(int), handler.LogCount);\n\n        for (size_t i = 0; i < handler.LogCount; ++i) {\n            EXPECT_EQ(e[i], handler.Logs[i]) << \"i = \" << i;\n        }\n    }\n}\n\n// Test iterative parsing on kParseErrorTermination.\nstruct HandlerTerminateAtStartObject : public IterativeParsingReaderHandler<> {\n    bool StartObject() { return false; }\n};\n\nstruct HandlerTerminateAtStartArray : public IterativeParsingReaderHandler<> {\n    bool StartArray() { return false; }\n};\n\nstruct HandlerTerminateAtEndObject : public IterativeParsingReaderHandler<> {\n    bool EndObject(SizeType) { return false; }\n};\n\nstruct HandlerTerminateAtEndArray : public IterativeParsingReaderHandler<> {\n    bool EndArray(SizeType) { return false; }\n};\n\nTEST(Reader, IterativeParsing_ShortCircuit) {\n    {\n        HandlerTerminateAtStartObject handler;\n        Reader reader;\n        StringStream is(\"[1, {}]\");\n\n        ParseResult r = reader.Parse<kParseIterativeFlag>(is, handler);\n\n        EXPECT_TRUE(reader.HasParseError());\n        EXPECT_EQ(kParseErrorTermination, r.Code());\n        EXPECT_EQ(4u, r.Offset());\n    }\n\n    {\n        HandlerTerminateAtStartArray handler;\n        Reader reader;\n        StringStream is(\"{\\\"a\\\": []}\");\n\n        ParseResult r = reader.Parse<kParseIterativeFlag>(is, handler);\n\n        EXPECT_TRUE(reader.HasParseError());\n        EXPECT_EQ(kParseErrorTermination, r.Code());\n        EXPECT_EQ(6u, r.Offset());\n    }\n\n    {\n        HandlerTerminateAtEndObject handler;\n        Reader reader;\n        StringStream is(\"[1, {}]\");\n\n        ParseResult r = reader.Parse<kParseIterativeFlag>(is, handler);\n\n        EXPECT_TRUE(reader.HasParseError());\n        EXPECT_EQ(kParseErrorTermination, r.Code());\n        EXPECT_EQ(5u, r.Offset());\n    }\n\n    {\n        HandlerTerminateAtEndArray handler;\n        Reader reader;\n        StringStream is(\"{\\\"a\\\": []}\");\n\n        ParseResult r = reader.Parse<kParseIterativeFlag>(is, handler);\n\n        EXPECT_TRUE(reader.HasParseError());\n        EXPECT_EQ(kParseErrorTermination, r.Code());\n        EXPECT_EQ(7u, r.Offset());\n    }\n}\n\n// For covering BaseReaderHandler default functions\nTEST(Reader, BaseReaderHandler_Default) {\n    BaseReaderHandler<> h;\n    Reader reader;\n    StringStream is(\"[null, true, -1, 1, -1234567890123456789, 1234567890123456789, 3.14, \\\"s\\\", { \\\"a\\\" : 1 }]\");\n    EXPECT_TRUE(reader.Parse(is, h));\n}\n\ntemplate <int e>\nstruct TerminateHandler {\n    bool Null() { return e != 0; }\n    bool Bool(bool) { return e != 1; }\n    bool Int(int) { return e != 2; }\n    bool Uint(unsigned) { return e != 3; }\n    bool Int64(int64_t) { return e != 4; }\n    bool Uint64(uint64_t) { return e != 5;  }\n    bool Double(double) { return e != 6; }\n    bool RawNumber(const char*, SizeType, bool) { return e != 7; }\n    bool String(const char*, SizeType, bool) { return e != 8; }\n    bool StartObject() { return e != 9; }\n    bool Key(const char*, SizeType, bool)  { return e != 10; }\n    bool EndObject(SizeType) { return e != 11; }\n    bool StartArray() { return e != 12; }\n    bool EndArray(SizeType) { return e != 13; }\n};\n\n#define TEST_TERMINATION(e, json)\\\n{\\\n    Reader reader;\\\n    TerminateHandler<e> h;\\\n    StringStream is(json);\\\n    EXPECT_FALSE(reader.Parse(is, h));\\\n    EXPECT_EQ(kParseErrorTermination, reader.GetParseErrorCode());\\\n}\n\nTEST(Reader, ParseTerminationByHandler) {\n    TEST_TERMINATION(0, \"[null\");\n    TEST_TERMINATION(1, \"[true\");\n    TEST_TERMINATION(1, \"[false\");\n    TEST_TERMINATION(2, \"[-1\");\n    TEST_TERMINATION(3, \"[1\");\n    TEST_TERMINATION(4, \"[-1234567890123456789\");\n    TEST_TERMINATION(5, \"[1234567890123456789\");\n    TEST_TERMINATION(6, \"[0.5]\");\n    // RawNumber() is never called\n    TEST_TERMINATION(8, \"[\\\"a\\\"\");\n    TEST_TERMINATION(9, \"[{\");\n    TEST_TERMINATION(10, \"[{\\\"a\\\"\");\n    TEST_TERMINATION(11, \"[{}\");\n    TEST_TERMINATION(11, \"[{\\\"a\\\":1}\"); // non-empty object\n    TEST_TERMINATION(12, \"{\\\"a\\\":[\");\n    TEST_TERMINATION(13, \"{\\\"a\\\":[]\");\n    TEST_TERMINATION(13, \"{\\\"a\\\":[1]\"); // non-empty array\n}\n\nTEST(Reader, ParseComments) {\n    const char* json =\n    \"// Here is a one-line comment.\\n\"\n    \"{// And here's another one\\n\"\n    \"   /*And here's an in-line one.*/\\\"hello\\\" : \\\"world\\\",\"\n    \"   \\\"t\\\" :/* And one with '*' symbol*/true ,\"\n    \"/* A multiline comment\\n\"\n    \"   goes here*/\"\n    \"   \\\"f\\\" : false, \\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3]\"\n    \"}/*And the last one to be sure */\";\n\n    StringStream s(json);\n    ParseObjectHandler h;\n    Reader reader;\n    EXPECT_TRUE(reader.Parse<kParseCommentsFlag>(s, h));\n    EXPECT_EQ(20u, h.step_);\n}\n\nTEST(Reader, ParseEmptyInlineComment) {\n    const char* json = \"{/**/\\\"hello\\\" : \\\"world\\\", \\\"t\\\" : true, \\\"f\\\" : false, \\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3] }\";\n\n    StringStream s(json);\n    ParseObjectHandler h;\n    Reader reader;\n    EXPECT_TRUE(reader.Parse<kParseCommentsFlag>(s, h));\n    EXPECT_EQ(20u, h.step_);\n}\n\nTEST(Reader, ParseEmptyOnelineComment) {\n    const char* json = \"{//\\n\\\"hello\\\" : \\\"world\\\", \\\"t\\\" : true, \\\"f\\\" : false, \\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3] }\";\n\n    StringStream s(json);\n    ParseObjectHandler h;\n    Reader reader;\n    EXPECT_TRUE(reader.Parse<kParseCommentsFlag>(s, h));\n    EXPECT_EQ(20u, h.step_);\n}\n\nTEST(Reader, ParseMultipleCommentsInARow) {\n    const char* json =\n    \"{/* first comment *//* second */\\n\"\n    \"/* third */ /*fourth*/// last one\\n\"\n    \"\\\"hello\\\" : \\\"world\\\", \\\"t\\\" : true, \\\"f\\\" : false, \\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3] }\";\n\n    StringStream s(json);\n    ParseObjectHandler h;\n    Reader reader;\n    EXPECT_TRUE(reader.Parse<kParseCommentsFlag>(s, h));\n    EXPECT_EQ(20u, h.step_);\n}\n\nTEST(Reader, InlineCommentsAreDisabledByDefault) {\n    {\n        const char* json = \"{/* Inline comment. */\\\"hello\\\" : \\\"world\\\", \\\"t\\\" : true, \\\"f\\\" : false, \\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3] }\";\n\n        StringStream s(json);\n        ParseObjectHandler h;\n        Reader reader;\n        EXPECT_FALSE(reader.Parse<kParseDefaultFlags>(s, h));\n    }\n\n    {\n        const char* json =\n        \"{\\\"hello\\\" : /* Multiline comment starts here\\n\"\n        \" continues here\\n\"\n        \" and ends here */\\\"world\\\", \\\"t\\\" :true , \\\"f\\\" : false, \\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3] }\";\n\n        StringStream s(json);\n        ParseObjectHandler h;\n        Reader reader;\n        EXPECT_FALSE(reader.Parse<kParseDefaultFlags>(s, h));\n    }\n}\n\nTEST(Reader, OnelineCommentsAreDisabledByDefault) {\n    const char* json = \"{// One-line comment\\n\\\"hello\\\" : \\\"world\\\", \\\"t\\\" : true , \\\"f\\\" : false, \\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3] }\";\n\n    StringStream s(json);\n    ParseObjectHandler h;\n    Reader reader;\n    EXPECT_FALSE(reader.Parse<kParseDefaultFlags>(s, h));\n}\n\nTEST(Reader, EofAfterOneLineComment) {\n    const char* json = \"{\\\"hello\\\" : \\\"world\\\" // EOF is here -->\\0 \\n}\";\n\n    StringStream s(json);\n    ParseObjectHandler h;\n    Reader reader;\n    EXPECT_FALSE(reader.Parse<kParseCommentsFlag>(s, h));\n    EXPECT_EQ(kParseErrorObjectMissCommaOrCurlyBracket, reader.GetParseErrorCode());\n}\n\nTEST(Reader, IncompleteMultilineComment) {\n    const char* json = \"{\\\"hello\\\" : \\\"world\\\" /* EOF is here -->\\0 */}\";\n\n    StringStream s(json);\n    ParseObjectHandler h;\n    Reader reader;\n    EXPECT_FALSE(reader.Parse<kParseCommentsFlag>(s, h));\n    EXPECT_EQ(kParseErrorUnspecificSyntaxError, reader.GetParseErrorCode());\n}\n\nTEST(Reader, IncompleteMultilineComment2) {\n    const char* json = \"{\\\"hello\\\" : \\\"world\\\" /* *\\0 */}\";\n\n    StringStream s(json);\n    ParseObjectHandler h;\n    Reader reader;\n    EXPECT_FALSE(reader.Parse<kParseCommentsFlag>(s, h));\n    EXPECT_EQ(kParseErrorUnspecificSyntaxError, reader.GetParseErrorCode());\n}\n\nTEST(Reader, UnrecognizedComment) {\n    const char* json = \"{\\\"hello\\\" : \\\"world\\\" /! }\";\n\n    StringStream s(json);\n    ParseObjectHandler h;\n    Reader reader;\n    EXPECT_FALSE(reader.Parse<kParseCommentsFlag>(s, h));\n    EXPECT_EQ(kParseErrorUnspecificSyntaxError, reader.GetParseErrorCode());\n}\n\nstruct NumbersAsStringsHandler {\n    bool Null() { return true; }\n    bool Bool(bool) { return true; }\n    bool Int(int) { return true; }\n    bool Uint(unsigned) { return true; }\n    bool Int64(int64_t) { return true; }\n    bool Uint64(uint64_t) { return true;  }\n    bool Double(double) { return true; }\n    // 'str' is not null-terminated\n    bool RawNumber(const char* str, SizeType length, bool) {\n        EXPECT_TRUE(str != 0);\n        EXPECT_TRUE(expected_len_ == length);\n        EXPECT_TRUE(strncmp(str, expected_, length) == 0);\n        return true;\n    }\n    bool String(const char*, SizeType, bool) { return true; }\n    bool StartObject() { return true; }\n    bool Key(const char*, SizeType, bool) { return true; }\n    bool EndObject(SizeType) { return true; }\n    bool StartArray() { return true; }\n    bool EndArray(SizeType) { return true; }\n\n    NumbersAsStringsHandler(const char* expected)\n        : expected_(expected)\n        , expected_len_(strlen(expected)) {}\n\n    const char* expected_;\n    size_t expected_len_;\n};\n\nTEST(Reader, NumbersAsStrings) {\n    {\n        const char* json = \"{ \\\"pi\\\": 3.1416 } \";\n        StringStream s(json);\n        NumbersAsStringsHandler h(\"3.1416\");\n        Reader reader;\n        EXPECT_TRUE(reader.Parse<kParseNumbersAsStringsFlag>(s, h));\n    }\n    {\n        char* json = StrDup(\"{ \\\"pi\\\": 3.1416 } \");\n        InsituStringStream s(json);\n        NumbersAsStringsHandler h(\"3.1416\");\n        Reader reader;\n        EXPECT_TRUE(reader.Parse<kParseInsituFlag|kParseNumbersAsStringsFlag>(s, h));\n        free(json);\n    }\n    {\n        const char* json = \"{ \\\"gigabyte\\\": 1.0e9 } \";\n        StringStream s(json);\n        NumbersAsStringsHandler h(\"1.0e9\");\n        Reader reader;\n        EXPECT_TRUE(reader.Parse<kParseNumbersAsStringsFlag>(s, h));\n    }\n    {\n        char* json = StrDup(\"{ \\\"gigabyte\\\": 1.0e9 } \");\n        InsituStringStream s(json);\n        NumbersAsStringsHandler h(\"1.0e9\");\n        Reader reader;\n        EXPECT_TRUE(reader.Parse<kParseInsituFlag|kParseNumbersAsStringsFlag>(s, h));\n        free(json);\n    }\n    {\n        const char* json = \"{ \\\"pi\\\": 314.159e-2 } \";\n        StringStream s(json);\n        NumbersAsStringsHandler h(\"314.159e-2\");\n        Reader reader;\n        EXPECT_TRUE(reader.Parse<kParseNumbersAsStringsFlag>(s, h));\n    }\n    {\n        char* json = StrDup(\"{ \\\"gigabyte\\\": 314.159e-2 } \");\n        InsituStringStream s(json);\n        NumbersAsStringsHandler h(\"314.159e-2\");\n        Reader reader;\n        EXPECT_TRUE(reader.Parse<kParseInsituFlag|kParseNumbersAsStringsFlag>(s, h));\n        free(json);\n    }\n    {\n        const char* json = \"{ \\\"negative\\\": -1.54321 } \";\n        StringStream s(json);\n        NumbersAsStringsHandler h(\"-1.54321\");\n        Reader reader;\n        EXPECT_TRUE(reader.Parse<kParseNumbersAsStringsFlag>(s, h));\n    }\n    {\n        char* json = StrDup(\"{ \\\"negative\\\": -1.54321 } \");\n        InsituStringStream s(json);\n        NumbersAsStringsHandler h(\"-1.54321\");\n        Reader reader;\n        EXPECT_TRUE(reader.Parse<kParseInsituFlag|kParseNumbersAsStringsFlag>(s, h));\n        free(json);\n    }\n    {\n        const char* json = \"{ \\\"pi\\\": 314.159e-2 } \";\n        std::stringstream ss(json);\n        IStreamWrapper s(ss);\n        NumbersAsStringsHandler h(\"314.159e-2\");\n        Reader reader;\n        EXPECT_TRUE(reader.Parse<kParseNumbersAsStringsFlag>(s, h));\n    }\n}\n\ntemplate <unsigned extraFlags>\nvoid TestTrailingCommas() {\n    {\n        StringStream s(\"[1,2,3,]\");\n        ParseArrayHandler<3> h;\n        Reader reader;\n        EXPECT_TRUE(reader.Parse<extraFlags|kParseTrailingCommasFlag>(s, h));\n        EXPECT_EQ(5u, h.step_);\n    }\n    {\n        const char* json = \"{ \\\"hello\\\" : \\\"world\\\", \\\"t\\\" : true , \\\"f\\\" : false,\"\n                \"\\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3],}\";\n        StringStream s(json);\n        ParseObjectHandler h;\n        Reader reader;\n        EXPECT_TRUE(reader.Parse<extraFlags|kParseTrailingCommasFlag>(s, h));\n        EXPECT_EQ(20u, h.step_);\n    }\n    {\n        // whitespace around trailing commas\n        const char* json = \"{ \\\"hello\\\" : \\\"world\\\", \\\"t\\\" : true , \\\"f\\\" : false,\"\n                \"\\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3\\n,\\n]\\n,\\n} \";\n        StringStream s(json);\n        ParseObjectHandler h;\n        Reader reader;\n        EXPECT_TRUE(reader.Parse<extraFlags|kParseTrailingCommasFlag>(s, h));\n        EXPECT_EQ(20u, h.step_);\n    }\n    {\n        // comments around trailing commas\n        const char* json = \"{ \\\"hello\\\" : \\\"world\\\", \\\"t\\\" : true , \\\"f\\\" : false, \\\"n\\\": null,\"\n                \"\\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3/*test*/,/*test*/]/*test*/,/*test*/}\";\n        StringStream s(json);\n        ParseObjectHandler h;\n        Reader reader;\n        EXPECT_TRUE(reader.Parse<extraFlags|kParseTrailingCommasFlag|kParseCommentsFlag>(s, h));\n        EXPECT_EQ(20u, h.step_);\n    }\n}\n\nTEST(Reader, TrailingCommas) {\n    TestTrailingCommas<kParseNoFlags>();\n}\n\nTEST(Reader, TrailingCommasIterative) {\n    TestTrailingCommas<kParseIterativeFlag>();\n}\n\ntemplate <unsigned extraFlags>\nvoid TestMultipleTrailingCommaErrors() {\n    // only a single trailing comma is allowed.\n    {\n        StringStream s(\"[1,2,3,,]\");\n        ParseArrayHandler<3> h;\n        Reader reader;\n        ParseResult r = reader.Parse<extraFlags|kParseTrailingCommasFlag>(s, h);\n        EXPECT_TRUE(reader.HasParseError());\n        EXPECT_EQ(kParseErrorValueInvalid, r.Code());\n        EXPECT_EQ(7u, r.Offset());\n    }\n    {\n        const char* json = \"{ \\\"hello\\\" : \\\"world\\\", \\\"t\\\" : true , \\\"f\\\" : false,\"\n                \"\\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3,],,}\";\n        StringStream s(json);\n        ParseObjectHandler h;\n        Reader reader;\n        ParseResult r = reader.Parse<extraFlags|kParseTrailingCommasFlag>(s, h);\n        EXPECT_TRUE(reader.HasParseError());\n        EXPECT_EQ(kParseErrorObjectMissName, r.Code());\n        EXPECT_EQ(95u, r.Offset());\n    }\n}\n\nTEST(Reader, MultipleTrailingCommaErrors) {\n    TestMultipleTrailingCommaErrors<kParseNoFlags>();\n}\n\nTEST(Reader, MultipleTrailingCommaErrorsIterative) {\n    TestMultipleTrailingCommaErrors<kParseIterativeFlag>();\n}\n\ntemplate <unsigned extraFlags>\nvoid TestEmptyExceptForCommaErrors() {\n    // not allowed even with trailing commas enabled; the\n    // trailing comma must follow a value.\n    {\n        StringStream s(\"[,]\");\n        ParseArrayHandler<3> h;\n        Reader reader;\n        ParseResult r = reader.Parse<extraFlags|kParseTrailingCommasFlag>(s, h);\n        EXPECT_TRUE(reader.HasParseError());\n        EXPECT_EQ(kParseErrorValueInvalid, r.Code());\n        EXPECT_EQ(1u, r.Offset());\n    }\n    {\n        StringStream s(\"{,}\");\n        ParseObjectHandler h;\n        Reader reader;\n        ParseResult r = reader.Parse<extraFlags|kParseTrailingCommasFlag>(s, h);\n        EXPECT_TRUE(reader.HasParseError());\n        EXPECT_EQ(kParseErrorObjectMissName, r.Code());\n        EXPECT_EQ(1u, r.Offset());\n    }\n}\n\nTEST(Reader, EmptyExceptForCommaErrors) {\n    TestEmptyExceptForCommaErrors<kParseNoFlags>();\n}\n\nTEST(Reader, EmptyExceptForCommaErrorsIterative) {\n    TestEmptyExceptForCommaErrors<kParseIterativeFlag>();\n}\n\ntemplate <unsigned extraFlags>\nvoid TestTrailingCommaHandlerTermination() {\n    {\n        HandlerTerminateAtEndArray h;\n        Reader reader;\n        StringStream s(\"[1,2,3,]\");\n        ParseResult r = reader.Parse<extraFlags|kParseTrailingCommasFlag>(s, h);\n        EXPECT_TRUE(reader.HasParseError());\n        EXPECT_EQ(kParseErrorTermination, r.Code());\n        EXPECT_EQ(7u, r.Offset());\n    }\n    {\n        HandlerTerminateAtEndObject h;\n        Reader reader;\n        StringStream s(\"{\\\"t\\\": true, \\\"f\\\": false,}\");\n        ParseResult r = reader.Parse<extraFlags|kParseTrailingCommasFlag>(s, h);\n        EXPECT_TRUE(reader.HasParseError());\n        EXPECT_EQ(kParseErrorTermination, r.Code());\n        EXPECT_EQ(23u, r.Offset());\n    }\n}\n\nTEST(Reader, TrailingCommaHandlerTermination) {\n    TestTrailingCommaHandlerTermination<kParseNoFlags>();\n}\n\nTEST(Reader, TrailingCommaHandlerTerminationIterative) {\n    TestTrailingCommaHandlerTermination<kParseIterativeFlag>();\n}\n\nTEST(Reader, ParseNanAndInfinity) {\n#define TEST_NAN_INF(str, x) \\\n    { \\\n        { \\\n            StringStream s(str); \\\n            ParseDoubleHandler h; \\\n            Reader reader; \\\n            ASSERT_EQ(kParseErrorNone, reader.Parse<kParseNanAndInfFlag>(s, h).Code()); \\\n            EXPECT_EQ(1u, h.step_); \\\n            internal::Double e(x), a(h.actual_); \\\n            EXPECT_EQ(e.IsNan(), a.IsNan()); \\\n            EXPECT_EQ(e.IsInf(), a.IsInf()); \\\n            if (!e.IsNan()) \\\n                EXPECT_EQ(e.Sign(), a.Sign()); \\\n        } \\\n        { \\\n            const char* json = \"{ \\\"naninfdouble\\\": \" str \" } \"; \\\n            StringStream s(json); \\\n            NumbersAsStringsHandler h(str); \\\n            Reader reader; \\\n            EXPECT_TRUE(reader.Parse<kParseNumbersAsStringsFlag|kParseNanAndInfFlag>(s, h)); \\\n        } \\\n        { \\\n            char* json = StrDup(\"{ \\\"naninfdouble\\\": \" str \" } \"); \\\n            InsituStringStream s(json); \\\n            NumbersAsStringsHandler h(str); \\\n            Reader reader; \\\n            EXPECT_TRUE(reader.Parse<kParseInsituFlag|kParseNumbersAsStringsFlag|kParseNanAndInfFlag>(s, h)); \\\n            free(json); \\\n        } \\\n    }\n#define TEST_NAN_INF_ERROR(errorCode, str, errorOffset) \\\n    { \\\n        int streamPos = errorOffset; \\\n        char buffer[1001]; \\\n        strncpy(buffer, str, 1000); \\\n        InsituStringStream s(buffer); \\\n        BaseReaderHandler<> h; \\\n        Reader reader; \\\n        EXPECT_FALSE(reader.Parse<kParseNanAndInfFlag>(s, h)); \\\n        EXPECT_EQ(errorCode, reader.GetParseErrorCode());\\\n        EXPECT_EQ(errorOffset, reader.GetErrorOffset());\\\n        EXPECT_EQ(streamPos, s.Tell());\\\n    }\n\n    double nan = std::numeric_limits<double>::quiet_NaN();\n    double inf = std::numeric_limits<double>::infinity();\n\n    TEST_NAN_INF(\"NaN\", nan);\n    TEST_NAN_INF(\"-NaN\", nan);\n    TEST_NAN_INF(\"Inf\", inf);\n    TEST_NAN_INF(\"Infinity\", inf);\n    TEST_NAN_INF(\"-Inf\", -inf);\n    TEST_NAN_INF(\"-Infinity\", -inf);\n    TEST_NAN_INF_ERROR(kParseErrorValueInvalid, \"nan\", 1);\n    TEST_NAN_INF_ERROR(kParseErrorValueInvalid, \"-nan\", 1);\n    TEST_NAN_INF_ERROR(kParseErrorValueInvalid, \"NAN\", 1);\n    TEST_NAN_INF_ERROR(kParseErrorValueInvalid, \"-Infinty\", 6);\n\n#undef TEST_NAN_INF_ERROR\n#undef TEST_NAN_INF\n}\n\nRAPIDJSON_DIAG_POP\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/regextest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n#include \"rapidjson/internal/regex.h\"\n\nusing namespace rapidjson::internal;\n\nTEST(Regex, Single) {\n    Regex re(\"a\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"a\"));\n    EXPECT_FALSE(re.Match(\"\"));\n    EXPECT_FALSE(re.Match(\"b\"));\n}\n\nTEST(Regex, Concatenation) {\n    Regex re(\"abc\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"abc\"));\n    EXPECT_FALSE(re.Match(\"\"));\n    EXPECT_FALSE(re.Match(\"a\"));\n    EXPECT_FALSE(re.Match(\"b\"));\n    EXPECT_FALSE(re.Match(\"ab\"));\n    EXPECT_FALSE(re.Match(\"abcd\"));\n}\n\nTEST(Regex, Alternation1) {\n    Regex re(\"abab|abbb\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"abab\"));\n    EXPECT_TRUE(re.Match(\"abbb\"));\n    EXPECT_FALSE(re.Match(\"\"));\n    EXPECT_FALSE(re.Match(\"ab\"));\n    EXPECT_FALSE(re.Match(\"ababa\"));\n    EXPECT_FALSE(re.Match(\"abb\"));\n    EXPECT_FALSE(re.Match(\"abbbb\"));\n}\n\nTEST(Regex, Alternation2) {\n    Regex re(\"a|b|c\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"a\"));\n    EXPECT_TRUE(re.Match(\"b\"));\n    EXPECT_TRUE(re.Match(\"c\"));\n    EXPECT_FALSE(re.Match(\"\"));\n    EXPECT_FALSE(re.Match(\"aa\"));\n    EXPECT_FALSE(re.Match(\"ab\"));\n}\n\nTEST(Regex, Parenthesis1) {\n    Regex re(\"(ab)c\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"abc\"));\n    EXPECT_FALSE(re.Match(\"\"));\n    EXPECT_FALSE(re.Match(\"a\"));\n    EXPECT_FALSE(re.Match(\"b\"));\n    EXPECT_FALSE(re.Match(\"ab\"));\n    EXPECT_FALSE(re.Match(\"abcd\"));\n}\n\nTEST(Regex, Parenthesis2) {\n    Regex re(\"a(bc)\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"abc\"));\n    EXPECT_FALSE(re.Match(\"\"));\n    EXPECT_FALSE(re.Match(\"a\"));\n    EXPECT_FALSE(re.Match(\"b\"));\n    EXPECT_FALSE(re.Match(\"ab\"));\n    EXPECT_FALSE(re.Match(\"abcd\"));\n}\n\nTEST(Regex, Parenthesis3) {\n    Regex re(\"(a|b)(c|d)\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"ac\"));\n    EXPECT_TRUE(re.Match(\"ad\"));\n    EXPECT_TRUE(re.Match(\"bc\"));\n    EXPECT_TRUE(re.Match(\"bd\"));\n    EXPECT_FALSE(re.Match(\"\"));\n    EXPECT_FALSE(re.Match(\"ab\"));\n    EXPECT_FALSE(re.Match(\"cd\"));\n}\n\nTEST(Regex, ZeroOrOne1) {\n    Regex re(\"a?\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"\"));\n    EXPECT_TRUE(re.Match(\"a\"));\n    EXPECT_FALSE(re.Match(\"aa\"));\n}\n\nTEST(Regex, ZeroOrOne2) {\n    Regex re(\"a?b\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"b\"));\n    EXPECT_TRUE(re.Match(\"ab\"));\n    EXPECT_FALSE(re.Match(\"a\"));\n    EXPECT_FALSE(re.Match(\"aa\"));\n    EXPECT_FALSE(re.Match(\"bb\"));\n    EXPECT_FALSE(re.Match(\"ba\"));\n}\n\nTEST(Regex, ZeroOrOne3) {\n    Regex re(\"ab?\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"a\"));\n    EXPECT_TRUE(re.Match(\"ab\"));\n    EXPECT_FALSE(re.Match(\"b\"));\n    EXPECT_FALSE(re.Match(\"aa\"));\n    EXPECT_FALSE(re.Match(\"bb\"));\n    EXPECT_FALSE(re.Match(\"ba\"));\n}\n\nTEST(Regex, ZeroOrOne4) {\n    Regex re(\"a?b?\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"\"));\n    EXPECT_TRUE(re.Match(\"a\"));\n    EXPECT_TRUE(re.Match(\"b\"));\n    EXPECT_TRUE(re.Match(\"ab\"));\n    EXPECT_FALSE(re.Match(\"aa\"));\n    EXPECT_FALSE(re.Match(\"bb\"));\n    EXPECT_FALSE(re.Match(\"ba\"));\n    EXPECT_FALSE(re.Match(\"abc\"));\n}\n\nTEST(Regex, ZeroOrOne5) {\n    Regex re(\"a(ab)?b\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"ab\"));\n    EXPECT_TRUE(re.Match(\"aabb\"));\n    EXPECT_FALSE(re.Match(\"aab\"));\n    EXPECT_FALSE(re.Match(\"abb\"));\n}\n\nTEST(Regex, ZeroOrMore1) {\n    Regex re(\"a*\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"\"));\n    EXPECT_TRUE(re.Match(\"a\"));\n    EXPECT_TRUE(re.Match(\"aa\"));\n    EXPECT_FALSE(re.Match(\"b\"));\n    EXPECT_FALSE(re.Match(\"ab\"));\n}\n\nTEST(Regex, ZeroOrMore2) {\n    Regex re(\"a*b\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"b\"));\n    EXPECT_TRUE(re.Match(\"ab\"));\n    EXPECT_TRUE(re.Match(\"aab\"));\n    EXPECT_FALSE(re.Match(\"\"));\n    EXPECT_FALSE(re.Match(\"bb\"));\n}\n\nTEST(Regex, ZeroOrMore3) {\n    Regex re(\"a*b*\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"\"));\n    EXPECT_TRUE(re.Match(\"a\"));\n    EXPECT_TRUE(re.Match(\"aa\"));\n    EXPECT_TRUE(re.Match(\"b\"));\n    EXPECT_TRUE(re.Match(\"bb\"));\n    EXPECT_TRUE(re.Match(\"ab\"));\n    EXPECT_TRUE(re.Match(\"aabb\"));\n    EXPECT_FALSE(re.Match(\"ba\"));\n}\n\nTEST(Regex, ZeroOrMore4) {\n    Regex re(\"a(ab)*b\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"ab\"));\n    EXPECT_TRUE(re.Match(\"aabb\"));\n    EXPECT_TRUE(re.Match(\"aababb\"));\n    EXPECT_FALSE(re.Match(\"\"));\n    EXPECT_FALSE(re.Match(\"aa\"));\n}\n\nTEST(Regex, OneOrMore1) {\n    Regex re(\"a+\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"a\"));\n    EXPECT_TRUE(re.Match(\"aa\"));\n    EXPECT_FALSE(re.Match(\"\"));\n    EXPECT_FALSE(re.Match(\"b\"));\n    EXPECT_FALSE(re.Match(\"ab\"));\n}\n\nTEST(Regex, OneOrMore2) {\n    Regex re(\"a+b\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"ab\"));\n    EXPECT_TRUE(re.Match(\"aab\"));\n    EXPECT_FALSE(re.Match(\"\"));\n    EXPECT_FALSE(re.Match(\"b\"));\n}\n\nTEST(Regex, OneOrMore3) {\n    Regex re(\"a+b+\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"ab\"));\n    EXPECT_TRUE(re.Match(\"aab\"));\n    EXPECT_TRUE(re.Match(\"abb\"));\n    EXPECT_TRUE(re.Match(\"aabb\"));\n    EXPECT_FALSE(re.Match(\"\"));\n    EXPECT_FALSE(re.Match(\"b\"));\n    EXPECT_FALSE(re.Match(\"ba\"));\n}\n\nTEST(Regex, OneOrMore4) {\n    Regex re(\"a(ab)+b\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"aabb\"));\n    EXPECT_TRUE(re.Match(\"aababb\"));\n    EXPECT_FALSE(re.Match(\"\"));\n    EXPECT_FALSE(re.Match(\"ab\"));\n}\n\nTEST(Regex, QuantifierExact1) {\n    Regex re(\"ab{3}c\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"abbbc\"));\n    EXPECT_FALSE(re.Match(\"ac\"));\n    EXPECT_FALSE(re.Match(\"abc\"));\n    EXPECT_FALSE(re.Match(\"abbc\"));\n    EXPECT_FALSE(re.Match(\"abbbbc\"));\n}\n\nTEST(Regex, QuantifierExact2) {\n    Regex re(\"a(bc){3}d\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"abcbcbcd\"));\n    EXPECT_FALSE(re.Match(\"ad\"));\n    EXPECT_FALSE(re.Match(\"abcd\"));\n    EXPECT_FALSE(re.Match(\"abcbcd\"));\n    EXPECT_FALSE(re.Match(\"abcbcbcbcd\"));\n}\n\nTEST(Regex, QuantifierExact3) {\n    Regex re(\"a(b|c){3}d\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"abbbd\"));\n    EXPECT_TRUE(re.Match(\"acccd\"));\n    EXPECT_TRUE(re.Match(\"abcbd\"));\n    EXPECT_FALSE(re.Match(\"ad\"));\n    EXPECT_FALSE(re.Match(\"abbd\"));\n    EXPECT_FALSE(re.Match(\"accccd\"));\n    EXPECT_FALSE(re.Match(\"abbbbd\"));\n}\n\nTEST(Regex, QuantifierMin1) {\n    Regex re(\"ab{3,}c\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"abbbc\"));\n    EXPECT_TRUE(re.Match(\"abbbbc\"));\n    EXPECT_TRUE(re.Match(\"abbbbbc\"));\n    EXPECT_FALSE(re.Match(\"ac\"));\n    EXPECT_FALSE(re.Match(\"abc\"));\n    EXPECT_FALSE(re.Match(\"abbc\"));\n}\n\nTEST(Regex, QuantifierMin2) {\n    Regex re(\"a(bc){3,}d\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"abcbcbcd\"));\n    EXPECT_TRUE(re.Match(\"abcbcbcbcd\"));\n    EXPECT_FALSE(re.Match(\"ad\"));\n    EXPECT_FALSE(re.Match(\"abcd\"));\n    EXPECT_FALSE(re.Match(\"abcbcd\"));\n}\n\nTEST(Regex, QuantifierMin3) {\n    Regex re(\"a(b|c){3,}d\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"abbbd\"));\n    EXPECT_TRUE(re.Match(\"acccd\"));\n    EXPECT_TRUE(re.Match(\"abcbd\"));\n    EXPECT_TRUE(re.Match(\"accccd\"));\n    EXPECT_TRUE(re.Match(\"abbbbd\"));\n    EXPECT_FALSE(re.Match(\"ad\"));\n    EXPECT_FALSE(re.Match(\"abbd\"));\n}\n\nTEST(Regex, QuantifierMinMax1) {\n    Regex re(\"ab{3,5}c\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"abbbc\"));\n    EXPECT_TRUE(re.Match(\"abbbbc\"));\n    EXPECT_TRUE(re.Match(\"abbbbbc\"));\n    EXPECT_FALSE(re.Match(\"ac\"));\n    EXPECT_FALSE(re.Match(\"abc\"));\n    EXPECT_FALSE(re.Match(\"abbc\"));\n    EXPECT_FALSE(re.Match(\"abbbbbbc\"));\n}\n\nTEST(Regex, QuantifierMinMax2) {\n    Regex re(\"a(bc){3,5}d\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"abcbcbcd\"));\n    EXPECT_TRUE(re.Match(\"abcbcbcbcd\"));\n    EXPECT_TRUE(re.Match(\"abcbcbcbcbcd\"));\n    EXPECT_FALSE(re.Match(\"ad\"));\n    EXPECT_FALSE(re.Match(\"abcd\"));\n    EXPECT_FALSE(re.Match(\"abcbcd\"));\n    EXPECT_FALSE(re.Match(\"abcbcbcbcbcbcd\"));\n}\n\nTEST(Regex, QuantifierMinMax3) {\n    Regex re(\"a(b|c){3,5}d\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"abbbd\"));\n    EXPECT_TRUE(re.Match(\"acccd\"));\n    EXPECT_TRUE(re.Match(\"abcbd\"));\n    EXPECT_TRUE(re.Match(\"accccd\"));\n    EXPECT_TRUE(re.Match(\"abbbbd\"));\n    EXPECT_TRUE(re.Match(\"acccccd\"));\n    EXPECT_TRUE(re.Match(\"abbbbbd\"));\n    EXPECT_FALSE(re.Match(\"ad\"));\n    EXPECT_FALSE(re.Match(\"abbd\"));\n    EXPECT_FALSE(re.Match(\"accccccd\"));\n    EXPECT_FALSE(re.Match(\"abbbbbbd\"));\n}\n\n// Issue538\nTEST(Regex, QuantifierMinMax4) {\n    Regex re(\"a(b|c){0,3}d\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"ad\"));\n    EXPECT_TRUE(re.Match(\"abd\"));\n    EXPECT_TRUE(re.Match(\"acd\"));\n    EXPECT_TRUE(re.Match(\"abbd\"));\n    EXPECT_TRUE(re.Match(\"accd\"));\n    EXPECT_TRUE(re.Match(\"abcd\"));\n    EXPECT_TRUE(re.Match(\"abbbd\"));\n    EXPECT_TRUE(re.Match(\"acccd\"));\n    EXPECT_FALSE(re.Match(\"abbbbd\"));\n    EXPECT_FALSE(re.Match(\"add\"));\n    EXPECT_FALSE(re.Match(\"accccd\"));\n    EXPECT_FALSE(re.Match(\"abcbcd\"));\n}\n\n// Issue538\nTEST(Regex, QuantifierMinMax5) {\n    Regex re(\"a(b|c){0,}d\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"ad\"));\n    EXPECT_TRUE(re.Match(\"abd\"));\n    EXPECT_TRUE(re.Match(\"acd\"));\n    EXPECT_TRUE(re.Match(\"abbd\"));\n    EXPECT_TRUE(re.Match(\"accd\"));\n    EXPECT_TRUE(re.Match(\"abcd\"));\n    EXPECT_TRUE(re.Match(\"abbbd\"));\n    EXPECT_TRUE(re.Match(\"acccd\"));\n    EXPECT_TRUE(re.Match(\"abbbbd\"));\n    EXPECT_TRUE(re.Match(\"accccd\"));\n    EXPECT_TRUE(re.Match(\"abcbcd\"));\n    EXPECT_FALSE(re.Match(\"add\"));\n    EXPECT_FALSE(re.Match(\"aad\"));\n}\n\n#define EURO \"\\xE2\\x82\\xAC\" // \"\\xE2\\x82\\xAC\" is UTF-8 sequence of Euro sign U+20AC\n\nTEST(Regex, Unicode) {\n    Regex re(\"a\" EURO \"+b\"); \n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"a\" EURO \"b\"));\n    EXPECT_TRUE(re.Match(\"a\" EURO EURO \"b\"));\n    EXPECT_FALSE(re.Match(\"a?b\"));\n    EXPECT_FALSE(re.Match(\"a\" EURO \"\\xAC\" \"b\")); // unaware of UTF-8 will match\n}\n\nTEST(Regex, AnyCharacter) {\n    Regex re(\".\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"a\"));\n    EXPECT_TRUE(re.Match(\"b\"));\n    EXPECT_TRUE(re.Match(EURO));\n    EXPECT_FALSE(re.Match(\"\"));\n    EXPECT_FALSE(re.Match(\"aa\"));\n}\n\nTEST(Regex, CharacterRange1) {\n    Regex re(\"[abc]\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"a\"));\n    EXPECT_TRUE(re.Match(\"b\"));\n    EXPECT_TRUE(re.Match(\"c\"));\n    EXPECT_FALSE(re.Match(\"\"));\n    EXPECT_FALSE(re.Match(\"`\"));\n    EXPECT_FALSE(re.Match(\"d\"));\n    EXPECT_FALSE(re.Match(\"aa\"));\n}\n\nTEST(Regex, CharacterRange2) {\n    Regex re(\"[^abc]\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"`\"));\n    EXPECT_TRUE(re.Match(\"d\"));\n    EXPECT_FALSE(re.Match(\"a\"));\n    EXPECT_FALSE(re.Match(\"b\"));\n    EXPECT_FALSE(re.Match(\"c\"));\n    EXPECT_FALSE(re.Match(\"\"));\n    EXPECT_FALSE(re.Match(\"aa\"));\n}\n\nTEST(Regex, CharacterRange3) {\n    Regex re(\"[a-c]\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"a\"));\n    EXPECT_TRUE(re.Match(\"b\"));\n    EXPECT_TRUE(re.Match(\"c\"));\n    EXPECT_FALSE(re.Match(\"\"));\n    EXPECT_FALSE(re.Match(\"`\"));\n    EXPECT_FALSE(re.Match(\"d\"));\n    EXPECT_FALSE(re.Match(\"aa\"));\n}\n\nTEST(Regex, CharacterRange4) {\n    Regex re(\"[^a-c]\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"`\"));\n    EXPECT_TRUE(re.Match(\"d\"));\n    EXPECT_FALSE(re.Match(\"a\"));\n    EXPECT_FALSE(re.Match(\"b\"));\n    EXPECT_FALSE(re.Match(\"c\"));\n    EXPECT_FALSE(re.Match(\"\"));\n    EXPECT_FALSE(re.Match(\"aa\"));\n}\n\nTEST(Regex, CharacterRange5) {\n    Regex re(\"[-]\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"-\"));\n    EXPECT_FALSE(re.Match(\"\"));\n    EXPECT_FALSE(re.Match(\"a\"));\n}\n\nTEST(Regex, CharacterRange6) {\n    Regex re(\"[a-]\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"a\"));\n    EXPECT_TRUE(re.Match(\"-\"));\n    EXPECT_FALSE(re.Match(\"\"));\n    EXPECT_FALSE(re.Match(\"`\"));\n    EXPECT_FALSE(re.Match(\"b\"));\n}\n\nTEST(Regex, CharacterRange7) {\n    Regex re(\"[-a]\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"a\"));\n    EXPECT_TRUE(re.Match(\"-\"));\n    EXPECT_FALSE(re.Match(\"\"));\n    EXPECT_FALSE(re.Match(\"`\"));\n    EXPECT_FALSE(re.Match(\"b\"));\n}\n\nTEST(Regex, CharacterRange8) {\n    Regex re(\"[a-zA-Z0-9]*\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"Milo\"));\n    EXPECT_TRUE(re.Match(\"MT19937\"));\n    EXPECT_TRUE(re.Match(\"43\"));\n    EXPECT_FALSE(re.Match(\"a_b\"));\n    EXPECT_FALSE(re.Match(\"!\"));\n}\n\nTEST(Regex, Search) {\n    Regex re(\"abc\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Search(\"abc\"));\n    EXPECT_TRUE(re.Search(\"_abc\"));\n    EXPECT_TRUE(re.Search(\"abc_\"));\n    EXPECT_TRUE(re.Search(\"_abc_\"));\n    EXPECT_TRUE(re.Search(\"__abc__\"));\n    EXPECT_TRUE(re.Search(\"abcabc\"));\n    EXPECT_FALSE(re.Search(\"a\"));\n    EXPECT_FALSE(re.Search(\"ab\"));\n    EXPECT_FALSE(re.Search(\"bc\"));\n    EXPECT_FALSE(re.Search(\"cba\"));\n}\n\nTEST(Regex, Search_BeginAnchor) {\n    Regex re(\"^abc\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Search(\"abc\"));\n    EXPECT_TRUE(re.Search(\"abc_\"));\n    EXPECT_TRUE(re.Search(\"abcabc\"));\n    EXPECT_FALSE(re.Search(\"_abc\"));\n    EXPECT_FALSE(re.Search(\"_abc_\"));\n    EXPECT_FALSE(re.Search(\"a\"));\n    EXPECT_FALSE(re.Search(\"ab\"));\n    EXPECT_FALSE(re.Search(\"bc\"));\n    EXPECT_FALSE(re.Search(\"cba\"));\n}\n\nTEST(Regex, Search_EndAnchor) {\n    Regex re(\"abc$\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Search(\"abc\"));\n    EXPECT_TRUE(re.Search(\"_abc\"));\n    EXPECT_TRUE(re.Search(\"abcabc\"));\n    EXPECT_FALSE(re.Search(\"abc_\"));\n    EXPECT_FALSE(re.Search(\"_abc_\"));\n    EXPECT_FALSE(re.Search(\"a\"));\n    EXPECT_FALSE(re.Search(\"ab\"));\n    EXPECT_FALSE(re.Search(\"bc\"));\n    EXPECT_FALSE(re.Search(\"cba\"));\n}\n\nTEST(Regex, Search_BothAnchor) {\n    Regex re(\"^abc$\");\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Search(\"abc\"));\n    EXPECT_FALSE(re.Search(\"\"));\n    EXPECT_FALSE(re.Search(\"a\"));\n    EXPECT_FALSE(re.Search(\"b\"));\n    EXPECT_FALSE(re.Search(\"ab\"));\n    EXPECT_FALSE(re.Search(\"abcd\"));\n}\n\nTEST(Regex, Escape) {\n    const char* s = \"\\\\^\\\\$\\\\|\\\\(\\\\)\\\\?\\\\*\\\\+\\\\.\\\\[\\\\]\\\\{\\\\}\\\\\\\\\\\\f\\\\n\\\\r\\\\t\\\\v[\\\\b][\\\\[][\\\\]]\";\n    Regex re(s);\n    ASSERT_TRUE(re.IsValid());\n    EXPECT_TRUE(re.Match(\"^$|()?*+.[]{}\\\\\\x0C\\n\\r\\t\\x0B\\b[]\"));\n    EXPECT_FALSE(re.Match(s)); // Not escaping\n}\n\nTEST(Regex, Invalid) {\n#define TEST_INVALID(s) \\\n    {\\\n        Regex re(s);\\\n        EXPECT_FALSE(re.IsValid());\\\n    }\n\n    TEST_INVALID(\"\");\n    TEST_INVALID(\"a|\");\n    TEST_INVALID(\"()\");\n    TEST_INVALID(\")\");\n    TEST_INVALID(\"(a))\");\n    TEST_INVALID(\"(a|)\");\n    TEST_INVALID(\"(a||b)\");\n    TEST_INVALID(\"(|b)\");\n    TEST_INVALID(\"?\");\n    TEST_INVALID(\"*\");\n    TEST_INVALID(\"+\");\n    TEST_INVALID(\"{\");\n    TEST_INVALID(\"{}\");\n    TEST_INVALID(\"a{a}\");\n    TEST_INVALID(\"a{0}\");\n    TEST_INVALID(\"a{-1}\");\n    TEST_INVALID(\"a{}\");\n    // TEST_INVALID(\"a{0,}\");   // Support now\n    TEST_INVALID(\"a{,0}\");\n    TEST_INVALID(\"a{1,0}\");\n    TEST_INVALID(\"a{-1,0}\");\n    TEST_INVALID(\"a{-1,1}\");\n    TEST_INVALID(\"a{4294967296}\"); // overflow of unsigned\n    TEST_INVALID(\"a{1a}\");\n    TEST_INVALID(\"[\");\n    TEST_INVALID(\"[]\");\n    TEST_INVALID(\"[^]\");\n    TEST_INVALID(\"[\\\\a]\");\n    TEST_INVALID(\"\\\\a\");\n\n#undef TEST_INVALID\n}\n\nTEST(Regex, Issue538) {\n    Regex re(\"^[0-9]+(\\\\\\\\.[0-9]+){0,2}\");\n    EXPECT_TRUE(re.IsValid());\n}\n\nTEST(Regex, Issue583) {\n    Regex re(\"[0-9]{99999}\");\n    ASSERT_TRUE(re.IsValid());\n}\n\n#undef EURO\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/schematest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n#include \"rapidjson/schema.h\"\n#include \"rapidjson/stringbuffer.h\"\n#include \"rapidjson/writer.h\"\n\n#ifdef __clang__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(variadic-macros)\n#endif\n\nusing namespace rapidjson;\n\n#define TEST_HASHER(json1, json2, expected) \\\n{\\\n    Document d1, d2;\\\n    d1.Parse(json1);\\\n    ASSERT_FALSE(d1.HasParseError());\\\n    d2.Parse(json2);\\\n    ASSERT_FALSE(d2.HasParseError());\\\n    internal::Hasher<Value, CrtAllocator> h1, h2;\\\n    d1.Accept(h1);\\\n    d2.Accept(h2);\\\n    ASSERT_TRUE(h1.IsValid());\\\n    ASSERT_TRUE(h2.IsValid());\\\n    /*printf(\"%s: 0x%016llx\\n%s: 0x%016llx\\n\\n\", json1, h1.GetHashCode(), json2, h2.GetHashCode());*/\\\n    EXPECT_TRUE(expected == (h1.GetHashCode() == h2.GetHashCode()));\\\n}\n\nTEST(SchemaValidator, Hasher) {\n    TEST_HASHER(\"null\", \"null\", true);\n\n    TEST_HASHER(\"true\", \"true\", true);\n    TEST_HASHER(\"false\", \"false\", true);\n    TEST_HASHER(\"true\", \"false\", false);\n    TEST_HASHER(\"false\", \"true\", false);\n    TEST_HASHER(\"true\", \"null\", false);\n    TEST_HASHER(\"false\", \"null\", false);\n\n    TEST_HASHER(\"1\", \"1\", true);\n    TEST_HASHER(\"2147483648\", \"2147483648\", true); // 2^31 can only be fit in unsigned\n    TEST_HASHER(\"-2147483649\", \"-2147483649\", true); // -2^31 - 1 can only be fit in int64_t\n    TEST_HASHER(\"2147483648\", \"2147483648\", true); // 2^31 can only be fit in unsigned\n    TEST_HASHER(\"4294967296\", \"4294967296\", true); // 2^32 can only be fit in int64_t\n    TEST_HASHER(\"9223372036854775808\", \"9223372036854775808\", true); // 2^63 can only be fit in uint64_t\n    TEST_HASHER(\"1.5\", \"1.5\", true);\n    TEST_HASHER(\"1\", \"1.0\", true);\n    TEST_HASHER(\"1\", \"-1\", false);\n    TEST_HASHER(\"0.0\", \"-0.0\", false);\n    TEST_HASHER(\"1\", \"true\", false);\n    TEST_HASHER(\"0\", \"false\", false);\n    TEST_HASHER(\"0\", \"null\", false);\n\n    TEST_HASHER(\"\\\"\\\"\", \"\\\"\\\"\", true);\n    TEST_HASHER(\"\\\"\\\"\", \"\\\"\\\\u0000\\\"\", false);\n    TEST_HASHER(\"\\\"Hello\\\"\", \"\\\"Hello\\\"\", true);\n    TEST_HASHER(\"\\\"Hello\\\"\", \"\\\"World\\\"\", false);\n    TEST_HASHER(\"\\\"Hello\\\"\", \"null\", false);\n    TEST_HASHER(\"\\\"Hello\\\\u0000\\\"\", \"\\\"Hello\\\"\", false);\n    TEST_HASHER(\"\\\"\\\"\", \"null\", false);\n    TEST_HASHER(\"\\\"\\\"\", \"true\", false);\n    TEST_HASHER(\"\\\"\\\"\", \"false\", false);\n\n    TEST_HASHER(\"[]\", \"[ ]\", true);\n    TEST_HASHER(\"[1, true, false]\", \"[1, true, false]\", true);\n    TEST_HASHER(\"[1, true, false]\", \"[1, true]\", false);\n    TEST_HASHER(\"[1, 2]\", \"[2, 1]\", false);\n    TEST_HASHER(\"[[1], 2]\", \"[[1, 2]]\", false);\n    TEST_HASHER(\"[1, 2]\", \"[1, [2]]\", false);\n    TEST_HASHER(\"[]\", \"null\", false);\n    TEST_HASHER(\"[]\", \"true\", false);\n    TEST_HASHER(\"[]\", \"false\", false);\n    TEST_HASHER(\"[]\", \"0\", false);\n    TEST_HASHER(\"[]\", \"0.0\", false);\n    TEST_HASHER(\"[]\", \"\\\"\\\"\", false);\n\n    TEST_HASHER(\"{}\", \"{ }\", true);\n    TEST_HASHER(\"{\\\"a\\\":1}\", \"{\\\"a\\\":1}\", true);\n    TEST_HASHER(\"{\\\"a\\\":1}\", \"{\\\"b\\\":1}\", false);\n    TEST_HASHER(\"{\\\"a\\\":1}\", \"{\\\"a\\\":2}\", false);\n    TEST_HASHER(\"{\\\"a\\\":1, \\\"b\\\":2}\", \"{\\\"b\\\":2, \\\"a\\\":1}\", true); // Member order insensitive\n    TEST_HASHER(\"{}\", \"null\", false);\n    TEST_HASHER(\"{}\", \"false\", false);\n    TEST_HASHER(\"{}\", \"true\", false);\n    TEST_HASHER(\"{}\", \"0\", false);\n    TEST_HASHER(\"{}\", \"0.0\", false);\n    TEST_HASHER(\"{}\", \"\\\"\\\"\", false);\n}\n\n// Test cases following http://spacetelescope.github.io/understanding-json-schema\n\n#define VALIDATE(schema, json, expected) \\\n{\\\n    SchemaValidator validator(schema);\\\n    Document d;\\\n    /*printf(\"\\n%s\\n\", json);*/\\\n    d.Parse(json);\\\n    EXPECT_FALSE(d.HasParseError());\\\n    EXPECT_TRUE(expected == d.Accept(validator));\\\n    EXPECT_TRUE(expected == validator.IsValid());\\\n    if ((expected) && !validator.IsValid()) {\\\n        StringBuffer sb;\\\n        validator.GetInvalidSchemaPointer().StringifyUriFragment(sb);\\\n        printf(\"Invalid schema: %s\\n\", sb.GetString());\\\n        printf(\"Invalid keyword: %s\\n\", validator.GetInvalidSchemaKeyword());\\\n        sb.Clear();\\\n        validator.GetInvalidDocumentPointer().StringifyUriFragment(sb);\\\n        printf(\"Invalid document: %s\\n\", sb.GetString());\\\n    }\\\n}\n\n#define INVALIDATE(schema, json, invalidSchemaPointer, invalidSchemaKeyword, invalidDocumentPointer) \\\n{\\\n    SchemaValidator validator(schema);\\\n    Document d;\\\n    /*printf(\"\\n%s\\n\", json);*/\\\n    d.Parse(json);\\\n    EXPECT_FALSE(d.HasParseError());\\\n    EXPECT_FALSE(d.Accept(validator));\\\n    EXPECT_FALSE(validator.IsValid());\\\n    if (validator.GetInvalidSchemaPointer() != Pointer(invalidSchemaPointer)) {\\\n        StringBuffer sb;\\\n        validator.GetInvalidSchemaPointer().Stringify(sb);\\\n        printf(\"GetInvalidSchemaPointer() Expected: %s Actual: %s\\n\", invalidSchemaPointer, sb.GetString());\\\n        ADD_FAILURE();\\\n    }\\\n    ASSERT_TRUE(validator.GetInvalidSchemaKeyword() != 0);\\\n    if (strcmp(validator.GetInvalidSchemaKeyword(), invalidSchemaKeyword) != 0) {\\\n        printf(\"GetInvalidSchemaKeyword() Expected: %s Actual %s\\n\", invalidSchemaKeyword, validator.GetInvalidSchemaKeyword());\\\n        ADD_FAILURE();\\\n    }\\\n    if (validator.GetInvalidDocumentPointer() != Pointer(invalidDocumentPointer)) {\\\n        StringBuffer sb;\\\n        validator.GetInvalidDocumentPointer().Stringify(sb);\\\n        printf(\"GetInvalidDocumentPointer() Expected: %s Actual: %s\\n\", invalidDocumentPointer, sb.GetString());\\\n        ADD_FAILURE();\\\n    }\\\n}\n\nTEST(SchemaValidator, Typeless) {\n    Document sd;\n    sd.Parse(\"{}\");\n    SchemaDocument s(sd);\n    \n    VALIDATE(s, \"42\", true);\n    VALIDATE(s, \"\\\"I'm a string\\\"\", true);\n    VALIDATE(s, \"{ \\\"an\\\": [ \\\"arbitrarily\\\", \\\"nested\\\" ], \\\"data\\\": \\\"structure\\\" }\", true);\n}\n\nTEST(SchemaValidator, MultiType) {\n    Document sd;\n    sd.Parse(\"{ \\\"type\\\": [\\\"number\\\", \\\"string\\\"] }\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"42\", true);\n    VALIDATE(s, \"\\\"Life, the universe, and everything\\\"\", true);\n    INVALIDATE(s, \"[\\\"Life\\\", \\\"the universe\\\", \\\"and everything\\\"]\", \"\", \"type\", \"\");\n}\n\nTEST(SchemaValidator, Enum_Typed) {\n    Document sd;\n    sd.Parse(\"{ \\\"type\\\": \\\"string\\\", \\\"enum\\\" : [\\\"red\\\", \\\"amber\\\", \\\"green\\\"] }\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"\\\"red\\\"\", true);\n    INVALIDATE(s, \"\\\"blue\\\"\", \"\", \"enum\", \"\");\n}\n\nTEST(SchemaValidator, Enum_Typless) {\n    Document sd;\n    sd.Parse(\"{  \\\"enum\\\": [\\\"red\\\", \\\"amber\\\", \\\"green\\\", null, 42] }\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"\\\"red\\\"\", true);\n    VALIDATE(s, \"null\", true);\n    VALIDATE(s, \"42\", true);\n    INVALIDATE(s, \"0\", \"\", \"enum\", \"\");\n}\n\nTEST(SchemaValidator, Enum_InvalidType) {\n    Document sd;\n    sd.Parse(\"{ \\\"type\\\": \\\"string\\\", \\\"enum\\\": [\\\"red\\\", \\\"amber\\\", \\\"green\\\", null] }\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"\\\"red\\\"\", true);\n    INVALIDATE(s, \"null\", \"\", \"type\", \"\");\n}\n\nTEST(SchemaValidator, AllOf) {\n    {\n        Document sd;\n        sd.Parse(\"{\\\"allOf\\\": [{ \\\"type\\\": \\\"string\\\" }, { \\\"type\\\": \\\"string\\\", \\\"maxLength\\\": 5 }]}\");\n        SchemaDocument s(sd);\n\n        VALIDATE(s, \"\\\"ok\\\"\", true);\n        INVALIDATE(s, \"\\\"too long\\\"\", \"\", \"allOf\", \"\");\n    }\n    {\n        Document sd;\n        sd.Parse(\"{\\\"allOf\\\": [{ \\\"type\\\": \\\"string\\\" }, { \\\"type\\\": \\\"number\\\" } ] }\");\n        SchemaDocument s(sd);\n\n        VALIDATE(s, \"\\\"No way\\\"\", false);\n        INVALIDATE(s, \"-1\", \"\", \"allOf\", \"\");\n    }\n}\n\nTEST(SchemaValidator, AnyOf) {\n    Document sd;\n    sd.Parse(\"{\\\"anyOf\\\": [{ \\\"type\\\": \\\"string\\\" }, { \\\"type\\\": \\\"number\\\" } ] }\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"\\\"Yes\\\"\", true);\n    VALIDATE(s, \"42\", true);\n    INVALIDATE(s, \"{ \\\"Not a\\\": \\\"string or number\\\" }\", \"\", \"anyOf\", \"\");\n}\n\nTEST(SchemaValidator, OneOf) {\n    Document sd;\n    sd.Parse(\"{\\\"oneOf\\\": [{ \\\"type\\\": \\\"number\\\", \\\"multipleOf\\\": 5 }, { \\\"type\\\": \\\"number\\\", \\\"multipleOf\\\": 3 } ] }\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"10\", true);\n    VALIDATE(s, \"9\", true);\n    INVALIDATE(s, \"2\", \"\", \"oneOf\", \"\");\n    INVALIDATE(s, \"15\", \"\", \"oneOf\", \"\");\n}\n\nTEST(SchemaValidator, Not) {\n    Document sd;\n    sd.Parse(\"{\\\"not\\\":{ \\\"type\\\": \\\"string\\\"}}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"42\", true);\n    VALIDATE(s, \"{ \\\"key\\\": \\\"value\\\" }\", true);\n    INVALIDATE(s, \"\\\"I am a string\\\"\", \"\", \"not\", \"\");\n}\n\nTEST(SchemaValidator, Ref) {\n    Document sd;\n    sd.Parse(\n        \"{\"\n        \"  \\\"$schema\\\": \\\"http://json-schema.org/draft-04/schema#\\\",\"\n        \"\"\n        \"  \\\"definitions\\\": {\"\n        \"    \\\"address\\\": {\"\n        \"      \\\"type\\\": \\\"object\\\",\"\n        \"      \\\"properties\\\": {\"\n        \"        \\\"street_address\\\": { \\\"type\\\": \\\"string\\\" },\"\n        \"        \\\"city\\\":           { \\\"type\\\": \\\"string\\\" },\"\n        \"        \\\"state\\\":          { \\\"type\\\": \\\"string\\\" }\"\n        \"      },\"\n        \"      \\\"required\\\": [\\\"street_address\\\", \\\"city\\\", \\\"state\\\"]\"\n        \"    }\"\n        \"  },\"\n        \"  \\\"type\\\": \\\"object\\\",\"\n        \"  \\\"properties\\\": {\"\n        \"    \\\"billing_address\\\": { \\\"$ref\\\": \\\"#/definitions/address\\\" },\"\n        \"    \\\"shipping_address\\\": { \\\"$ref\\\": \\\"#/definitions/address\\\" }\"\n        \"  }\"\n        \"}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"{\\\"shipping_address\\\": {\\\"street_address\\\": \\\"1600 Pennsylvania Avenue NW\\\", \\\"city\\\": \\\"Washington\\\", \\\"state\\\": \\\"DC\\\"}, \\\"billing_address\\\": {\\\"street_address\\\": \\\"1st Street SE\\\", \\\"city\\\": \\\"Washington\\\", \\\"state\\\": \\\"DC\\\"} }\", true);\n}\n\nTEST(SchemaValidator, Ref_AllOf) {\n    Document sd;\n    sd.Parse(\n        \"{\"\n        \"  \\\"$schema\\\": \\\"http://json-schema.org/draft-04/schema#\\\",\"\n        \"\"\n        \"  \\\"definitions\\\": {\"\n        \"    \\\"address\\\": {\"\n        \"      \\\"type\\\": \\\"object\\\",\"\n        \"      \\\"properties\\\": {\"\n        \"        \\\"street_address\\\": { \\\"type\\\": \\\"string\\\" },\"\n        \"        \\\"city\\\":           { \\\"type\\\": \\\"string\\\" },\"\n        \"        \\\"state\\\":          { \\\"type\\\": \\\"string\\\" }\"\n        \"      },\"\n        \"      \\\"required\\\": [\\\"street_address\\\", \\\"city\\\", \\\"state\\\"]\"\n        \"    }\"\n        \"  },\"\n        \"  \\\"type\\\": \\\"object\\\",\"\n        \"  \\\"properties\\\": {\"\n        \"    \\\"billing_address\\\": { \\\"$ref\\\": \\\"#/definitions/address\\\" },\"\n        \"    \\\"shipping_address\\\": {\"\n        \"      \\\"allOf\\\": [\"\n        \"        { \\\"$ref\\\": \\\"#/definitions/address\\\" },\"\n        \"        { \\\"properties\\\":\"\n        \"          { \\\"type\\\": { \\\"enum\\\": [ \\\"residential\\\", \\\"business\\\" ] } },\"\n        \"          \\\"required\\\": [\\\"type\\\"]\"\n        \"        }\"\n        \"      ]\"\n        \"    }\"\n        \"  }\"\n        \"}\");\n    SchemaDocument s(sd);\n\n    INVALIDATE(s, \"{\\\"shipping_address\\\": {\\\"street_address\\\": \\\"1600 Pennsylvania Avenue NW\\\", \\\"city\\\": \\\"Washington\\\", \\\"state\\\": \\\"DC\\\"} }\", \"/properties/shipping_address\", \"allOf\", \"/shipping_address\");\n    VALIDATE(s, \"{\\\"shipping_address\\\": {\\\"street_address\\\": \\\"1600 Pennsylvania Avenue NW\\\", \\\"city\\\": \\\"Washington\\\", \\\"state\\\": \\\"DC\\\", \\\"type\\\": \\\"business\\\"} }\", true);\n}\n\nTEST(SchemaValidator, String) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"string\\\"}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"\\\"I'm a string\\\"\", true);\n    INVALIDATE(s, \"42\", \"\", \"type\", \"\");\n    INVALIDATE(s, \"2147483648\", \"\", \"type\", \"\"); // 2^31 can only be fit in unsigned\n    INVALIDATE(s, \"-2147483649\", \"\", \"type\", \"\"); // -2^31 - 1 can only be fit in int64_t\n    INVALIDATE(s, \"4294967296\", \"\", \"type\", \"\"); // 2^32 can only be fit in int64_t\n    INVALIDATE(s, \"3.1415926\", \"\", \"type\", \"\");\n}\n\nTEST(SchemaValidator, String_LengthRange) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"string\\\",\\\"minLength\\\":2,\\\"maxLength\\\":3}\");\n    SchemaDocument s(sd);\n\n    INVALIDATE(s, \"\\\"A\\\"\", \"\", \"minLength\", \"\");\n    VALIDATE(s, \"\\\"AB\\\"\", true);\n    VALIDATE(s, \"\\\"ABC\\\"\", true);\n    INVALIDATE(s, \"\\\"ABCD\\\"\", \"\", \"maxLength\", \"\");\n}\n\n#if RAPIDJSON_SCHEMA_HAS_REGEX\nTEST(SchemaValidator, String_Pattern) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"string\\\",\\\"pattern\\\":\\\"^(\\\\\\\\([0-9]{3}\\\\\\\\))?[0-9]{3}-[0-9]{4}$\\\"}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"\\\"555-1212\\\"\", true);\n    VALIDATE(s, \"\\\"(888)555-1212\\\"\", true);\n    INVALIDATE(s, \"\\\"(888)555-1212 ext. 532\\\"\", \"\", \"pattern\", \"\");\n    INVALIDATE(s, \"\\\"(800)FLOWERS\\\"\", \"\", \"pattern\", \"\");\n}\n\nTEST(SchemaValidator, String_Pattern_Invalid) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"string\\\",\\\"pattern\\\":\\\"a{0}\\\"}\"); // TODO: report regex is invalid somehow\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"\\\"\\\"\", true);\n    VALIDATE(s, \"\\\"a\\\"\", true);\n    VALIDATE(s, \"\\\"aa\\\"\", true);\n}\n#endif\n\nTEST(SchemaValidator, Integer) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"integer\\\"}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"42\", true);\n    VALIDATE(s, \"-1\", true);\n    VALIDATE(s, \"2147483648\", true); // 2^31 can only be fit in unsigned\n    VALIDATE(s, \"-2147483649\", true); // -2^31 - 1 can only be fit in int64_t\n    VALIDATE(s, \"2147483648\", true); // 2^31 can only be fit in unsigned\n    VALIDATE(s, \"4294967296\", true); // 2^32 can only be fit in int64_t\n    INVALIDATE(s, \"3.1415926\", \"\", \"type\", \"\");\n    INVALIDATE(s, \"\\\"42\\\"\", \"\", \"type\", \"\");\n}\n\nTEST(SchemaValidator, Integer_Range) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"integer\\\",\\\"minimum\\\":0,\\\"maximum\\\":100,\\\"exclusiveMaximum\\\":true}\");\n    SchemaDocument s(sd);\n\n    INVALIDATE(s, \"-1\", \"\", \"minimum\", \"\");\n    VALIDATE(s, \"0\", true);\n    VALIDATE(s, \"10\", true);\n    VALIDATE(s, \"99\", true);\n    INVALIDATE(s, \"100\", \"\", \"maximum\", \"\");\n    INVALIDATE(s, \"101\", \"\", \"maximum\", \"\");\n}\n\nTEST(SchemaValidator, Integer_Range64Boundary) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"integer\\\",\\\"minimum\\\":-9223372036854775807,\\\"maximum\\\":9223372036854775806}\");\n    SchemaDocument s(sd);\n\n    INVALIDATE(s, \"-9223372036854775808\", \"\", \"minimum\", \"\");\n    VALIDATE(s, \"-9223372036854775807\", true);\n    VALIDATE(s, \"-2147483648\", true); // int min\n    VALIDATE(s, \"0\", true);\n    VALIDATE(s, \"2147483647\", true);  // int max\n    VALIDATE(s, \"2147483648\", true);  // unsigned first\n    VALIDATE(s, \"4294967295\", true);  // unsigned max\n    VALIDATE(s, \"9223372036854775806\", true);\n    INVALIDATE(s, \"9223372036854775807\", \"\", \"maximum\", \"\");\n    INVALIDATE(s, \"18446744073709551615\", \"\", \"maximum\", \"\");   // uint64_t max\n}\n\nTEST(SchemaValidator, Integer_RangeU64Boundary) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"integer\\\",\\\"minimum\\\":9223372036854775808,\\\"maximum\\\":18446744073709551614}\");\n    SchemaDocument s(sd);\n\n    INVALIDATE(s, \"-9223372036854775808\", \"\", \"minimum\", \"\");\n    INVALIDATE(s, \"9223372036854775807\", \"\", \"minimum\", \"\");\n    INVALIDATE(s, \"-2147483648\", \"\", \"minimum\", \"\"); // int min\n    INVALIDATE(s, \"0\", \"\", \"minimum\", \"\");\n    INVALIDATE(s, \"2147483647\", \"\", \"minimum\", \"\");  // int max\n    INVALIDATE(s, \"2147483648\", \"\", \"minimum\", \"\");  // unsigned first\n    INVALIDATE(s, \"4294967295\", \"\", \"minimum\", \"\");  // unsigned max\n    VALIDATE(s, \"9223372036854775808\", true);\n    VALIDATE(s, \"18446744073709551614\", true);\n    INVALIDATE(s, \"18446744073709551615\", \"\", \"maximum\", \"\");\n}\n\nTEST(SchemaValidator, Integer_Range64BoundaryExclusive) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"integer\\\",\\\"minimum\\\":-9223372036854775808,\\\"maximum\\\":18446744073709551615,\\\"exclusiveMinimum\\\":true,\\\"exclusiveMaximum\\\":true}\");\n    SchemaDocument s(sd);\n\n    INVALIDATE(s, \"-9223372036854775808\", \"\", \"minimum\", \"\");\n    VALIDATE(s, \"-9223372036854775807\", true);\n    VALIDATE(s, \"18446744073709551614\", true);\n    INVALIDATE(s, \"18446744073709551615\", \"\", \"maximum\", \"\");\n}\n\nTEST(SchemaValidator, Integer_MultipleOf) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"integer\\\",\\\"multipleOf\\\":10}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"0\", true);\n    VALIDATE(s, \"10\", true);\n    VALIDATE(s, \"-10\", true);\n    VALIDATE(s, \"20\", true);\n    INVALIDATE(s, \"23\", \"\", \"multipleOf\", \"\");\n    INVALIDATE(s, \"-23\", \"\", \"multipleOf\", \"\");\n}\n\nTEST(SchemaValidator, Integer_MultipleOf64Boundary) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"integer\\\",\\\"multipleOf\\\":18446744073709551615}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"0\", true);\n    VALIDATE(s, \"18446744073709551615\", true);\n    INVALIDATE(s, \"18446744073709551614\", \"\", \"multipleOf\", \"\");\n}\n\nTEST(SchemaValidator, Number_Range) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"number\\\",\\\"minimum\\\":0,\\\"maximum\\\":100,\\\"exclusiveMaximum\\\":true}\");\n    SchemaDocument s(sd);\n\n    INVALIDATE(s, \"-1\", \"\", \"minimum\", \"\");\n    VALIDATE(s, \"0\", true);\n    VALIDATE(s, \"0.1\", true);\n    VALIDATE(s, \"10\", true);\n    VALIDATE(s, \"99\", true);\n    VALIDATE(s, \"99.9\", true);\n    INVALIDATE(s, \"100\", \"\", \"maximum\", \"\");\n    INVALIDATE(s, \"100.0\", \"\", \"maximum\", \"\");\n    INVALIDATE(s, \"101.5\", \"\", \"maximum\", \"\");\n}\n\nTEST(SchemaValidator, Number_RangeInt) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"number\\\",\\\"minimum\\\":-100,\\\"maximum\\\":-1,\\\"exclusiveMaximum\\\":true}\");\n    SchemaDocument s(sd);\n\n    INVALIDATE(s, \"-101\", \"\", \"minimum\", \"\");\n    INVALIDATE(s, \"-100.1\", \"\", \"minimum\", \"\");\n    VALIDATE(s, \"-100\", true);\n    VALIDATE(s, \"-2\", true);\n    INVALIDATE(s, \"-1\", \"\", \"maximum\", \"\");\n    INVALIDATE(s, \"-0.9\", \"\", \"maximum\", \"\");\n    INVALIDATE(s, \"0\", \"\", \"maximum\", \"\");\n    INVALIDATE(s, \"2147483647\", \"\", \"maximum\", \"\");  // int max\n    INVALIDATE(s, \"2147483648\", \"\", \"maximum\", \"\");  // unsigned first\n    INVALIDATE(s, \"4294967295\", \"\", \"maximum\", \"\");  // unsigned max\n    INVALIDATE(s, \"9223372036854775808\", \"\", \"maximum\", \"\");\n    INVALIDATE(s, \"18446744073709551614\", \"\", \"maximum\", \"\");\n    INVALIDATE(s, \"18446744073709551615\", \"\", \"maximum\", \"\");\n}\n\nTEST(SchemaValidator, Number_RangeDouble) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"number\\\",\\\"minimum\\\":0.1,\\\"maximum\\\":100.1,\\\"exclusiveMaximum\\\":true}\");\n    SchemaDocument s(sd);\n\n    INVALIDATE(s, \"-9223372036854775808\", \"\", \"minimum\", \"\");\n    INVALIDATE(s, \"-2147483648\", \"\", \"minimum\", \"\"); // int min\n    INVALIDATE(s, \"-1\", \"\", \"minimum\", \"\");\n    VALIDATE(s, \"0.1\", true);\n    VALIDATE(s, \"10\", true);\n    VALIDATE(s, \"99\", true);\n    VALIDATE(s, \"100\", true);\n    INVALIDATE(s, \"101\", \"\", \"maximum\", \"\");\n    INVALIDATE(s, \"101.5\", \"\", \"maximum\", \"\");\n    INVALIDATE(s, \"18446744073709551614\", \"\", \"maximum\", \"\");\n    INVALIDATE(s, \"18446744073709551615\", \"\", \"maximum\", \"\");\n    INVALIDATE(s, \"2147483647\", \"\", \"maximum\", \"\");  // int max\n    INVALIDATE(s, \"2147483648\", \"\", \"maximum\", \"\");  // unsigned first\n    INVALIDATE(s, \"4294967295\", \"\", \"maximum\", \"\");  // unsigned max\n    INVALIDATE(s, \"9223372036854775808\", \"\", \"maximum\", \"\");\n    INVALIDATE(s, \"18446744073709551614\", \"\", \"maximum\", \"\");\n    INVALIDATE(s, \"18446744073709551615\", \"\", \"maximum\", \"\");\n}\n\nTEST(SchemaValidator, Number_RangeDoubleU64Boundary) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"number\\\",\\\"minimum\\\":9223372036854775808.0,\\\"maximum\\\":18446744073709550000.0}\");\n    SchemaDocument s(sd);\n\n    INVALIDATE(s, \"-9223372036854775808\", \"\", \"minimum\", \"\");\n    INVALIDATE(s, \"-2147483648\", \"\", \"minimum\", \"\"); // int min\n    INVALIDATE(s, \"0\", \"\", \"minimum\", \"\");\n    INVALIDATE(s, \"2147483647\", \"\", \"minimum\", \"\");  // int max\n    INVALIDATE(s, \"2147483648\", \"\", \"minimum\", \"\");  // unsigned first\n    INVALIDATE(s, \"4294967295\", \"\", \"minimum\", \"\");  // unsigned max\n    VALIDATE(s, \"9223372036854775808\", true);\n    VALIDATE(s, \"18446744073709540000\", true);\n    INVALIDATE(s, \"18446744073709551615\", \"\", \"maximum\", \"\");\n}\n\nTEST(SchemaValidator, Number_MultipleOf) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"number\\\",\\\"multipleOf\\\":10.0}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"0\", true);\n    VALIDATE(s, \"10\", true);\n    VALIDATE(s, \"-10\", true);\n    VALIDATE(s, \"20\", true);\n    INVALIDATE(s, \"23\", \"\", \"multipleOf\", \"\");\n    INVALIDATE(s, \"-2147483648\", \"\", \"multipleOf\", \"\");  // int min\n    VALIDATE(s, \"-2147483640\", true);\n    INVALIDATE(s, \"2147483647\", \"\", \"multipleOf\", \"\");  // int max\n    INVALIDATE(s, \"2147483648\", \"\", \"multipleOf\", \"\");  // unsigned first\n    VALIDATE(s, \"2147483650\", true);\n    INVALIDATE(s, \"4294967295\", \"\", \"multipleOf\", \"\");  // unsigned max\n    VALIDATE(s, \"4294967300\", true);\n}\n\nTEST(SchemaValidator, Number_MultipleOfOne) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"number\\\",\\\"multipleOf\\\":1}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"42\", true);\n    VALIDATE(s, \"42.0\", true);\n    INVALIDATE(s, \"3.1415926\", \"\", \"multipleOf\", \"\");\n}\n\nTEST(SchemaValidator, Object) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"object\\\"}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"{\\\"key\\\":\\\"value\\\",\\\"another_key\\\":\\\"another_value\\\"}\", true);\n    VALIDATE(s, \"{\\\"Sun\\\":1.9891e30,\\\"Jupiter\\\":1.8986e27,\\\"Saturn\\\":5.6846e26,\\\"Neptune\\\":10.243e25,\\\"Uranus\\\":8.6810e25,\\\"Earth\\\":5.9736e24,\\\"Venus\\\":4.8685e24,\\\"Mars\\\":6.4185e23,\\\"Mercury\\\":3.3022e23,\\\"Moon\\\":7.349e22,\\\"Pluto\\\":1.25e22}\", true);    \n    INVALIDATE(s, \"[\\\"An\\\", \\\"array\\\", \\\"not\\\", \\\"an\\\", \\\"object\\\"]\", \"\", \"type\", \"\");\n    INVALIDATE(s, \"\\\"Not an object\\\"\", \"\", \"type\", \"\");\n}\n\nTEST(SchemaValidator, Object_Properties) {\n    Document sd;\n    sd.Parse(\n        \"{\"\n        \"    \\\"type\\\": \\\"object\\\",\"\n        \"    \\\"properties\\\" : {\"\n        \"        \\\"number\\\": { \\\"type\\\": \\\"number\\\" },\"\n        \"        \\\"street_name\\\" : { \\\"type\\\": \\\"string\\\" },\"\n        \"        \\\"street_type\\\" : { \\\"type\\\": \\\"string\\\", \\\"enum\\\" : [\\\"Street\\\", \\\"Avenue\\\", \\\"Boulevard\\\"] }\"\n        \"    }\"\n        \"}\");\n\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"{ \\\"number\\\": 1600, \\\"street_name\\\": \\\"Pennsylvania\\\", \\\"street_type\\\": \\\"Avenue\\\" }\", true);\n    INVALIDATE(s, \"{ \\\"number\\\": \\\"1600\\\", \\\"street_name\\\": \\\"Pennsylvania\\\", \\\"street_type\\\": \\\"Avenue\\\" }\", \"/properties/number\", \"type\", \"/number\");\n    VALIDATE(s, \"{ \\\"number\\\": 1600, \\\"street_name\\\": \\\"Pennsylvania\\\" }\", true);\n    VALIDATE(s, \"{}\", true);\n    VALIDATE(s, \"{ \\\"number\\\": 1600, \\\"street_name\\\": \\\"Pennsylvania\\\", \\\"street_type\\\": \\\"Avenue\\\", \\\"direction\\\": \\\"NW\\\" }\", true);\n}\n\nTEST(SchemaValidator, Object_AdditionalPropertiesBoolean) {\n    Document sd;\n    sd.Parse(\n        \"{\"\n        \"    \\\"type\\\": \\\"object\\\",\"\n        \"        \\\"properties\\\" : {\"\n        \"        \\\"number\\\": { \\\"type\\\": \\\"number\\\" },\"\n        \"            \\\"street_name\\\" : { \\\"type\\\": \\\"string\\\" },\"\n        \"            \\\"street_type\\\" : { \\\"type\\\": \\\"string\\\",\"\n        \"            \\\"enum\\\" : [\\\"Street\\\", \\\"Avenue\\\", \\\"Boulevard\\\"]\"\n        \"        }\"\n        \"    },\"\n        \"    \\\"additionalProperties\\\": false\"\n        \"}\");\n\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"{ \\\"number\\\": 1600, \\\"street_name\\\": \\\"Pennsylvania\\\", \\\"street_type\\\": \\\"Avenue\\\" }\", true);\n    INVALIDATE(s, \"{ \\\"number\\\": 1600, \\\"street_name\\\": \\\"Pennsylvania\\\", \\\"street_type\\\": \\\"Avenue\\\", \\\"direction\\\": \\\"NW\\\" }\", \"\", \"additionalProperties\", \"/direction\");\n}\n\nTEST(SchemaValidator, Object_AdditionalPropertiesObject) {\n    Document sd;\n    sd.Parse(\n        \"{\"\n        \"    \\\"type\\\": \\\"object\\\",\"\n        \"    \\\"properties\\\" : {\"\n        \"        \\\"number\\\": { \\\"type\\\": \\\"number\\\" },\"\n        \"        \\\"street_name\\\" : { \\\"type\\\": \\\"string\\\" },\"\n        \"        \\\"street_type\\\" : { \\\"type\\\": \\\"string\\\",\"\n        \"            \\\"enum\\\" : [\\\"Street\\\", \\\"Avenue\\\", \\\"Boulevard\\\"]\"\n        \"        }\"\n        \"    },\"\n        \"    \\\"additionalProperties\\\": { \\\"type\\\": \\\"string\\\" }\"\n        \"}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"{ \\\"number\\\": 1600, \\\"street_name\\\": \\\"Pennsylvania\\\", \\\"street_type\\\": \\\"Avenue\\\" }\", true);\n    VALIDATE(s, \"{ \\\"number\\\": 1600, \\\"street_name\\\": \\\"Pennsylvania\\\", \\\"street_type\\\": \\\"Avenue\\\", \\\"direction\\\": \\\"NW\\\" }\", true);\n    INVALIDATE(s, \"{ \\\"number\\\": 1600, \\\"street_name\\\": \\\"Pennsylvania\\\", \\\"street_type\\\": \\\"Avenue\\\", \\\"office_number\\\": 201 }\", \"/additionalProperties\", \"type\", \"/office_number\");\n}\n\nTEST(SchemaValidator, Object_Required) {\n    Document sd;\n    sd.Parse(\n        \"{\"\n        \"    \\\"type\\\": \\\"object\\\",\"\n        \"    \\\"properties\\\" : {\"\n        \"        \\\"name\\\":      { \\\"type\\\": \\\"string\\\" },\"\n        \"        \\\"email\\\" : { \\\"type\\\": \\\"string\\\" },\"\n        \"        \\\"address\\\" : { \\\"type\\\": \\\"string\\\" },\"\n        \"        \\\"telephone\\\" : { \\\"type\\\": \\\"string\\\" }\"\n        \"    },\"\n        \"    \\\"required\\\":[\\\"name\\\", \\\"email\\\"]\"\n        \"}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"{ \\\"name\\\": \\\"William Shakespeare\\\", \\\"email\\\" : \\\"bill@stratford-upon-avon.co.uk\\\" }\", true);\n    VALIDATE(s, \"{ \\\"name\\\": \\\"William Shakespeare\\\", \\\"email\\\" : \\\"bill@stratford-upon-avon.co.uk\\\", \\\"address\\\" : \\\"Henley Street, Stratford-upon-Avon, Warwickshire, England\\\", \\\"authorship\\\" : \\\"in question\\\"}\", true);\n    INVALIDATE(s, \"{ \\\"name\\\": \\\"William Shakespeare\\\", \\\"address\\\" : \\\"Henley Street, Stratford-upon-Avon, Warwickshire, England\\\" }\", \"\", \"required\", \"\");\n}\n\n\nTEST(SchemaValidator, Object_PropertiesRange) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"object\\\", \\\"minProperties\\\":2, \\\"maxProperties\\\":3}\");\n    SchemaDocument s(sd);\n\n    INVALIDATE(s, \"{}\", \"\", \"minProperties\", \"\");\n    INVALIDATE(s, \"{\\\"a\\\":0}\", \"\", \"minProperties\", \"\");\n    VALIDATE(s, \"{\\\"a\\\":0,\\\"b\\\":1}\", true);\n    VALIDATE(s, \"{\\\"a\\\":0,\\\"b\\\":1,\\\"c\\\":2}\", true);\n    INVALIDATE(s, \"{\\\"a\\\":0,\\\"b\\\":1,\\\"c\\\":2,\\\"d\\\":3}\", \"\", \"maxProperties\", \"\");\n}\n\nTEST(SchemaValidator, Object_PropertyDependencies) {\n    Document sd;\n    sd.Parse(\n        \"{\"\n        \"  \\\"type\\\": \\\"object\\\",\"\n        \"  \\\"properties\\\": {\"\n        \"    \\\"name\\\": { \\\"type\\\": \\\"string\\\" },\"\n        \"    \\\"credit_card\\\": { \\\"type\\\": \\\"number\\\" },\"\n        \"    \\\"billing_address\\\": { \\\"type\\\": \\\"string\\\" }\"\n        \"  },\"\n        \"  \\\"required\\\": [\\\"name\\\"],\"\n        \"  \\\"dependencies\\\": {\"\n        \"    \\\"credit_card\\\": [\\\"billing_address\\\"]\"\n        \"  }\"\n        \"}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"{ \\\"name\\\": \\\"John Doe\\\", \\\"credit_card\\\": 5555555555555555, \\\"billing_address\\\": \\\"555 Debtor's Lane\\\" }\", true);\n    INVALIDATE(s, \"{ \\\"name\\\": \\\"John Doe\\\", \\\"credit_card\\\": 5555555555555555 }\", \"\", \"dependencies\", \"\");\n    VALIDATE(s, \"{ \\\"name\\\": \\\"John Doe\\\"}\", true);\n    VALIDATE(s, \"{ \\\"name\\\": \\\"John Doe\\\", \\\"billing_address\\\": \\\"555 Debtor's Lane\\\" }\", true);\n}\n\nTEST(SchemaValidator, Object_SchemaDependencies) {\n    Document sd;\n    sd.Parse(\n        \"{\"\n        \"    \\\"type\\\": \\\"object\\\",\"\n        \"    \\\"properties\\\" : {\"\n        \"        \\\"name\\\": { \\\"type\\\": \\\"string\\\" },\"\n        \"        \\\"credit_card\\\" : { \\\"type\\\": \\\"number\\\" }\"\n        \"    },\"\n        \"    \\\"required\\\" : [\\\"name\\\"],\"\n        \"    \\\"dependencies\\\" : {\"\n        \"        \\\"credit_card\\\": {\"\n        \"            \\\"properties\\\": {\"\n        \"                \\\"billing_address\\\": { \\\"type\\\": \\\"string\\\" }\"\n        \"            },\"\n        \"            \\\"required\\\" : [\\\"billing_address\\\"]\"\n        \"        }\"\n        \"    }\"\n        \"}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"{\\\"name\\\": \\\"John Doe\\\", \\\"credit_card\\\" : 5555555555555555,\\\"billing_address\\\" : \\\"555 Debtor's Lane\\\"}\", true);\n    INVALIDATE(s, \"{\\\"name\\\": \\\"John Doe\\\", \\\"credit_card\\\" : 5555555555555555 }\", \"\", \"dependencies\", \"\");\n    VALIDATE(s, \"{\\\"name\\\": \\\"John Doe\\\", \\\"billing_address\\\" : \\\"555 Debtor's Lane\\\"}\", true);\n}\n\n#if RAPIDJSON_SCHEMA_HAS_REGEX\nTEST(SchemaValidator, Object_PatternProperties) {\n    Document sd;\n    sd.Parse(\n        \"{\"\n        \"  \\\"type\\\": \\\"object\\\",\"\n        \"  \\\"patternProperties\\\": {\"\n        \"    \\\"^S_\\\": { \\\"type\\\": \\\"string\\\" },\"\n        \"    \\\"^I_\\\": { \\\"type\\\": \\\"integer\\\" }\"\n        \"  }\"\n        \"}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"{ \\\"S_25\\\": \\\"This is a string\\\" }\", true);\n    VALIDATE(s, \"{ \\\"I_0\\\": 42 }\", true);\n    INVALIDATE(s, \"{ \\\"S_0\\\": 42 }\", \"\", \"patternProperties\", \"/S_0\");\n    INVALIDATE(s, \"{ \\\"I_42\\\": \\\"This is a string\\\" }\", \"\", \"patternProperties\", \"/I_42\");\n    VALIDATE(s, \"{ \\\"keyword\\\": \\\"value\\\" }\", true);\n}\n\nTEST(SchemaValidator, Object_PatternProperties_AdditionalProperties) {\n    Document sd;\n    sd.Parse(\n        \"{\"\n        \"  \\\"type\\\": \\\"object\\\",\"\n        \"  \\\"properties\\\": {\"\n        \"    \\\"builtin\\\": { \\\"type\\\": \\\"number\\\" }\"\n        \"  },\"\n        \"  \\\"patternProperties\\\": {\"\n        \"    \\\"^S_\\\": { \\\"type\\\": \\\"string\\\" },\"\n        \"    \\\"^I_\\\": { \\\"type\\\": \\\"integer\\\" }\"\n        \"  },\"\n        \"  \\\"additionalProperties\\\": { \\\"type\\\": \\\"string\\\" }\"\n        \"}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"{ \\\"builtin\\\": 42 }\", true);\n    VALIDATE(s, \"{ \\\"keyword\\\": \\\"value\\\" }\", true);\n    INVALIDATE(s, \"{ \\\"keyword\\\": 42 }\", \"/additionalProperties\", \"type\", \"/keyword\");\n}\n#endif\n\nTEST(SchemaValidator, Array) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"array\\\"}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"[1, 2, 3, 4, 5]\", true);\n    VALIDATE(s, \"[3, \\\"different\\\", { \\\"types\\\" : \\\"of values\\\" }]\", true);\n    INVALIDATE(s, \"{\\\"Not\\\": \\\"an array\\\"}\", \"\", \"type\", \"\");\n}\n\nTEST(SchemaValidator, Array_ItemsList) {\n    Document sd;\n    sd.Parse(\n        \"{\"\n        \"    \\\"type\\\": \\\"array\\\",\"\n        \"    \\\"items\\\" : {\"\n        \"        \\\"type\\\": \\\"number\\\"\"\n        \"    }\"\n        \"}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"[1, 2, 3, 4, 5]\", true);\n    INVALIDATE(s, \"[1, 2, \\\"3\\\", 4, 5]\", \"/items\", \"type\", \"/2\");\n    VALIDATE(s, \"[]\", true);\n}\n\nTEST(SchemaValidator, Array_ItemsTuple) {\n    Document sd;\n    sd.Parse(\n        \"{\"\n        \"  \\\"type\\\": \\\"array\\\",\"\n        \"  \\\"items\\\": [\"\n        \"    {\"\n        \"      \\\"type\\\": \\\"number\\\"\"\n        \"    },\"\n        \"    {\"\n        \"      \\\"type\\\": \\\"string\\\"\"\n        \"    },\"\n        \"    {\"\n        \"      \\\"type\\\": \\\"string\\\",\"\n        \"      \\\"enum\\\": [\\\"Street\\\", \\\"Avenue\\\", \\\"Boulevard\\\"]\"\n        \"    },\"\n        \"    {\"\n        \"      \\\"type\\\": \\\"string\\\",\"\n        \"      \\\"enum\\\": [\\\"NW\\\", \\\"NE\\\", \\\"SW\\\", \\\"SE\\\"]\"\n        \"    }\"\n        \"  ]\"\n        \"}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"[1600, \\\"Pennsylvania\\\", \\\"Avenue\\\", \\\"NW\\\"]\", true);\n    INVALIDATE(s, \"[24, \\\"Sussex\\\", \\\"Drive\\\"]\", \"/items/2\", \"enum\", \"/2\");\n    INVALIDATE(s, \"[\\\"Palais de l'Elysee\\\"]\", \"/items/0\", \"type\", \"/0\");\n    VALIDATE(s, \"[10, \\\"Downing\\\", \\\"Street\\\"]\", true);\n    VALIDATE(s, \"[1600, \\\"Pennsylvania\\\", \\\"Avenue\\\", \\\"NW\\\", \\\"Washington\\\"]\", true);\n}\n\nTEST(SchemaValidator, Array_AdditionalItmes) {\n    Document sd;\n    sd.Parse(\n        \"{\"\n        \"  \\\"type\\\": \\\"array\\\",\"\n        \"  \\\"items\\\": [\"\n        \"    {\"\n        \"      \\\"type\\\": \\\"number\\\"\"\n        \"    },\"\n        \"    {\"\n        \"      \\\"type\\\": \\\"string\\\"\"\n        \"    },\"\n        \"    {\"\n        \"      \\\"type\\\": \\\"string\\\",\"\n        \"      \\\"enum\\\": [\\\"Street\\\", \\\"Avenue\\\", \\\"Boulevard\\\"]\"\n        \"    },\"\n        \"    {\"\n        \"      \\\"type\\\": \\\"string\\\",\"\n        \"      \\\"enum\\\": [\\\"NW\\\", \\\"NE\\\", \\\"SW\\\", \\\"SE\\\"]\"\n        \"    }\"\n        \"  ],\"\n        \"  \\\"additionalItems\\\": false\"\n        \"}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"[1600, \\\"Pennsylvania\\\", \\\"Avenue\\\", \\\"NW\\\"]\", true);\n    VALIDATE(s, \"[1600, \\\"Pennsylvania\\\", \\\"Avenue\\\"]\", true);\n    INVALIDATE(s, \"[1600, \\\"Pennsylvania\\\", \\\"Avenue\\\", \\\"NW\\\", \\\"Washington\\\"]\", \"\", \"items\", \"/4\");\n}\n\nTEST(SchemaValidator, Array_ItemsRange) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\": \\\"array\\\",\\\"minItems\\\": 2,\\\"maxItems\\\" : 3}\");\n    SchemaDocument s(sd);\n\n    INVALIDATE(s, \"[]\", \"\", \"minItems\", \"\");\n    INVALIDATE(s, \"[1]\", \"\", \"minItems\", \"\");\n    VALIDATE(s, \"[1, 2]\", true);\n    VALIDATE(s, \"[1, 2, 3]\", true);\n    INVALIDATE(s, \"[1, 2, 3, 4]\", \"\", \"maxItems\", \"\");\n}\n\nTEST(SchemaValidator, Array_UniqueItems) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\": \\\"array\\\", \\\"uniqueItems\\\": true}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"[1, 2, 3, 4, 5]\", true);\n    INVALIDATE(s, \"[1, 2, 3, 3, 4]\", \"\", \"uniqueItems\", \"/3\");\n    VALIDATE(s, \"[]\", true);\n}\n\nTEST(SchemaValidator, Boolean) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"boolean\\\"}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"true\", true);\n    VALIDATE(s, \"false\", true);\n    INVALIDATE(s, \"\\\"true\\\"\", \"\", \"type\", \"\");\n    INVALIDATE(s, \"0\", \"\", \"type\", \"\");\n}\n\nTEST(SchemaValidator, Null) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"null\\\"}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"null\", true);\n    INVALIDATE(s, \"false\", \"\", \"type\", \"\");\n    INVALIDATE(s, \"0\", \"\", \"type\", \"\");\n    INVALIDATE(s, \"\\\"\\\"\", \"\", \"type\", \"\");\n}\n\n// Additional tests\n\nTEST(SchemaValidator, ObjectInArray) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"array\\\", \\\"items\\\": { \\\"type\\\":\\\"string\\\" }}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"[\\\"a\\\"]\", true);\n    INVALIDATE(s, \"[1]\", \"/items\", \"type\", \"/0\");\n    INVALIDATE(s, \"[{}]\", \"/items\", \"type\", \"/0\");\n}\n\nTEST(SchemaValidator, MultiTypeInObject) {\n    Document sd;\n    sd.Parse(\n        \"{\"\n        \"    \\\"type\\\":\\\"object\\\",\"\n        \"    \\\"properties\\\": {\"\n        \"        \\\"tel\\\" : {\"\n        \"            \\\"type\\\":[\\\"integer\\\", \\\"string\\\"]\"\n        \"        }\"\n        \"    }\"\n        \"}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"{ \\\"tel\\\": 999 }\", true);\n    VALIDATE(s, \"{ \\\"tel\\\": \\\"123-456\\\" }\", true);\n    INVALIDATE(s, \"{ \\\"tel\\\": true }\", \"/properties/tel\", \"type\", \"/tel\");\n}\n\nTEST(SchemaValidator, MultiTypeWithObject) {\n    Document sd;\n    sd.Parse(\n        \"{\"\n        \"    \\\"type\\\": [\\\"object\\\",\\\"string\\\"],\"\n        \"    \\\"properties\\\": {\"\n        \"        \\\"tel\\\" : {\"\n        \"            \\\"type\\\": \\\"integer\\\"\"\n        \"        }\"\n        \"    }\"\n        \"}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"\\\"Hello\\\"\", true);\n    VALIDATE(s, \"{ \\\"tel\\\": 999 }\", true);\n    INVALIDATE(s, \"{ \\\"tel\\\": \\\"fail\\\" }\", \"/properties/tel\", \"type\", \"/tel\");\n}\n\nTEST(SchemaValidator, AllOf_Nested) {\n    Document sd;\n    sd.Parse(\n    \"{\"\n    \"    \\\"allOf\\\": [\"\n    \"        { \\\"type\\\": \\\"string\\\", \\\"minLength\\\": 2 },\"\n    \"        { \\\"type\\\": \\\"string\\\", \\\"maxLength\\\": 5 },\"\n    \"        { \\\"allOf\\\": [ { \\\"enum\\\" : [\\\"ok\\\", \\\"okay\\\", \\\"OK\\\", \\\"o\\\"] }, { \\\"enum\\\" : [\\\"ok\\\", \\\"OK\\\", \\\"o\\\"]} ] }\"\n    \"    ]\"\n    \"}\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"\\\"ok\\\"\", true);\n    VALIDATE(s, \"\\\"OK\\\"\", true);\n    INVALIDATE(s, \"\\\"okay\\\"\", \"\", \"allOf\", \"\");\n    INVALIDATE(s, \"\\\"o\\\"\", \"\", \"allOf\", \"\");\n    INVALIDATE(s, \"\\\"n\\\"\", \"\", \"allOf\", \"\");\n    INVALIDATE(s, \"\\\"too long\\\"\", \"\", \"allOf\", \"\");\n    INVALIDATE(s, \"123\", \"\", \"allOf\", \"\");\n}\n\nTEST(SchemaValidator, EscapedPointer) {\n    Document sd;\n    sd.Parse(\n        \"{\"\n        \"  \\\"type\\\": \\\"object\\\",\"\n        \"  \\\"properties\\\": {\"\n        \"    \\\"~/\\\": { \\\"type\\\": \\\"number\\\" }\"\n        \"  }\"\n        \"}\");\n    SchemaDocument s(sd);\n    INVALIDATE(s, \"{\\\"~/\\\":true}\", \"/properties/~0~1\", \"type\", \"/~0~1\");\n}\n\ntemplate <typename Allocator>\nstatic char* ReadFile(const char* filename, Allocator& allocator) {\n    const char *paths[] = {\n        \"\",\n        \"bin/\",\n        \"../bin/\",\n        \"../../bin/\",\n        \"../../../bin/\"\n    };\n    char buffer[1024];\n    FILE *fp = 0;\n    for (size_t i = 0; i < sizeof(paths) / sizeof(paths[0]); i++) {\n        sprintf(buffer, \"%s%s\", paths[i], filename);\n        fp = fopen(buffer, \"rb\");\n        if (fp)\n            break;\n    }\n\n    if (!fp)\n        return 0;\n\n    fseek(fp, 0, SEEK_END);\n    size_t length = static_cast<size_t>(ftell(fp));\n    fseek(fp, 0, SEEK_SET);\n    char* json = reinterpret_cast<char*>(allocator.Malloc(length + 1));\n    size_t readLength = fread(json, 1, length, fp);\n    json[readLength] = '\\0';\n    fclose(fp);\n    return json;\n}\n\nTEST(SchemaValidator, ValidateMetaSchema) {\n    CrtAllocator allocator;\n    char* json = ReadFile(\"draft-04/schema\", allocator);\n    Document d;\n    d.Parse(json);\n    ASSERT_FALSE(d.HasParseError());\n    SchemaDocument sd(d);\n    SchemaValidator validator(sd);\n    if (!d.Accept(validator)) {\n        StringBuffer sb;\n        validator.GetInvalidSchemaPointer().StringifyUriFragment(sb);\n        printf(\"Invalid schema: %s\\n\", sb.GetString());\n        printf(\"Invalid keyword: %s\\n\", validator.GetInvalidSchemaKeyword());\n        sb.Clear();\n        validator.GetInvalidDocumentPointer().StringifyUriFragment(sb);\n        printf(\"Invalid document: %s\\n\", sb.GetString());\n        ADD_FAILURE();\n    }\n    CrtAllocator::Free(json);\n}\n\nTEST(SchemaValidator, ValidateMetaSchema_UTF16) {\n    typedef GenericDocument<UTF16<> > D;\n    typedef GenericSchemaDocument<D::ValueType> SD;\n    typedef GenericSchemaValidator<SD> SV;\n\n    CrtAllocator allocator;\n    char* json = ReadFile(\"draft-04/schema\", allocator);\n\n    D d;\n    StringStream ss(json);\n    d.ParseStream<0, UTF8<> >(ss);\n    ASSERT_FALSE(d.HasParseError());\n    SD sd(d);\n    SV validator(sd);\n    if (!d.Accept(validator)) {\n        GenericStringBuffer<UTF16<> > sb;\n        validator.GetInvalidSchemaPointer().StringifyUriFragment(sb);\n        wprintf(L\"Invalid schema: %ls\\n\", sb.GetString());\n        wprintf(L\"Invalid keyword: %ls\\n\", validator.GetInvalidSchemaKeyword());\n        sb.Clear();\n        validator.GetInvalidDocumentPointer().StringifyUriFragment(sb);\n        wprintf(L\"Invalid document: %ls\\n\", sb.GetString());\n        ADD_FAILURE();\n    }\n    CrtAllocator::Free(json);\n}\n\ntemplate <typename SchemaDocumentType = SchemaDocument>\nclass RemoteSchemaDocumentProvider : public IGenericRemoteSchemaDocumentProvider<SchemaDocumentType> {\npublic:\n    RemoteSchemaDocumentProvider() : \n        documentAllocator_(documentBuffer_, sizeof(documentBuffer_)), \n        schemaAllocator_(schemaBuffer_, sizeof(schemaBuffer_)) \n    {\n        const char* filenames[kCount] = {\n            \"jsonschema/remotes/integer.json\",\n            \"jsonschema/remotes/subSchemas.json\",\n            \"jsonschema/remotes/folder/folderInteger.json\",\n            \"draft-04/schema\"\n        };\n\n        for (size_t i = 0; i < kCount; i++) {\n            sd_[i] = 0;\n\n            char jsonBuffer[8192];\n            MemoryPoolAllocator<> jsonAllocator(jsonBuffer, sizeof(jsonBuffer));\n            char* json = ReadFile(filenames[i], jsonAllocator);\n            if (!json) {\n                printf(\"json remote file %s not found\", filenames[i]);\n                ADD_FAILURE();\n            }\n            else {\n                char stackBuffer[4096];\n                MemoryPoolAllocator<> stackAllocator(stackBuffer, sizeof(stackBuffer));\n                DocumentType d(&documentAllocator_, 1024, &stackAllocator);\n                d.Parse(json);\n                sd_[i] = new SchemaDocumentType(d, 0, &schemaAllocator_);\n                MemoryPoolAllocator<>::Free(json);\n            }\n        };\n    }\n\n    ~RemoteSchemaDocumentProvider() {\n        for (size_t i = 0; i < kCount; i++)\n            delete sd_[i];\n    }\n\n    virtual const SchemaDocumentType* GetRemoteDocument(const char* uri, SizeType length) {\n        const char* uris[kCount] = {\n            \"http://localhost:1234/integer.json\",\n            \"http://localhost:1234/subSchemas.json\",\n            \"http://localhost:1234/folder/folderInteger.json\",\n            \"http://json-schema.org/draft-04/schema\"\n        };\n\n        for (size_t i = 0; i < kCount; i++)\n            if (strncmp(uri, uris[i], length) == 0)\n                return sd_[i];\n        return 0;\n    }\n\nprivate:\n    typedef GenericDocument<typename SchemaDocumentType::EncodingType, MemoryPoolAllocator<>, MemoryPoolAllocator<> > DocumentType;\n\n    RemoteSchemaDocumentProvider(const RemoteSchemaDocumentProvider&);\n    RemoteSchemaDocumentProvider& operator=(const RemoteSchemaDocumentProvider&);\n\n    static const size_t kCount = 4;\n    SchemaDocumentType* sd_[kCount];\n    typename DocumentType::AllocatorType documentAllocator_;\n    typename SchemaDocumentType::AllocatorType schemaAllocator_;\n    char documentBuffer_[16384];\n    char schemaBuffer_[128 * 1024];\n};\n\nTEST(SchemaValidator, TestSuite) {\n    const char* filenames[] = {\n        \"additionalItems.json\",\n        \"additionalProperties.json\",\n        \"allOf.json\",\n        \"anyOf.json\",\n        \"default.json\",\n        \"definitions.json\",\n        \"dependencies.json\",\n        \"enum.json\",\n        \"items.json\",\n        \"maximum.json\",\n        \"maxItems.json\",\n        \"maxLength.json\",\n        \"maxProperties.json\",\n        \"minimum.json\",\n        \"minItems.json\",\n        \"minLength.json\",\n        \"minProperties.json\",\n        \"multipleOf.json\",\n        \"not.json\",\n        \"oneOf.json\",\n        \"pattern.json\",\n        \"patternProperties.json\",\n        \"properties.json\",\n        \"ref.json\",\n        \"refRemote.json\",\n        \"required.json\",\n        \"type.json\",\n        \"uniqueItems.json\"\n    };\n\n    const char* onlyRunDescription = 0;\n    //const char* onlyRunDescription = \"a string is a string\";\n\n    unsigned testCount = 0;\n    unsigned passCount = 0;\n\n    typedef GenericSchemaDocument<Value, MemoryPoolAllocator<> > SchemaDocumentType;\n    RemoteSchemaDocumentProvider<SchemaDocumentType> provider;\n\n    char jsonBuffer[65536];\n    char documentBuffer[65536];\n    char documentStackBuffer[65536];\n    char schemaBuffer[65536];\n    char validatorBuffer[65536];\n    MemoryPoolAllocator<> jsonAllocator(jsonBuffer, sizeof(jsonBuffer));\n    MemoryPoolAllocator<> documentAllocator(documentBuffer, sizeof(documentBuffer));\n    MemoryPoolAllocator<> documentStackAllocator(documentStackBuffer, sizeof(documentStackBuffer));\n    MemoryPoolAllocator<> schemaAllocator(schemaBuffer, sizeof(schemaBuffer));\n    MemoryPoolAllocator<> validatorAllocator(validatorBuffer, sizeof(validatorBuffer));\n\n    for (size_t i = 0; i < sizeof(filenames) / sizeof(filenames[0]); i++) {\n        char filename[FILENAME_MAX];\n        sprintf(filename, \"jsonschema/tests/draft4/%s\", filenames[i]);\n        char* json = ReadFile(filename, jsonAllocator);\n        if (!json) {\n            printf(\"json test suite file %s not found\", filename);\n            ADD_FAILURE();\n        }\n        else {\n            GenericDocument<UTF8<>, MemoryPoolAllocator<>, MemoryPoolAllocator<> > d(&documentAllocator, 1024, &documentStackAllocator);\n            d.Parse(json);\n            if (d.HasParseError()) {\n                printf(\"json test suite file %s has parse error\", filename);\n                ADD_FAILURE();\n            }\n            else {\n                for (Value::ConstValueIterator schemaItr = d.Begin(); schemaItr != d.End(); ++schemaItr) {\n                    {\n                        SchemaDocumentType schema((*schemaItr)[\"schema\"], &provider, &schemaAllocator);\n                        GenericSchemaValidator<SchemaDocumentType, BaseReaderHandler<UTF8<> >, MemoryPoolAllocator<> > validator(schema, &validatorAllocator);\n                        const char* description1 = (*schemaItr)[\"description\"].GetString();\n                        const Value& tests = (*schemaItr)[\"tests\"];\n                        for (Value::ConstValueIterator testItr = tests.Begin(); testItr != tests.End(); ++testItr) {\n                            const char* description2 = (*testItr)[\"description\"].GetString();\n                            if (!onlyRunDescription || strcmp(description2, onlyRunDescription) == 0) {\n                                const Value& data = (*testItr)[\"data\"];\n                                bool expected = (*testItr)[\"valid\"].GetBool();\n                                testCount++;\n                                validator.Reset();\n                                bool actual = data.Accept(validator);\n                                if (expected != actual)\n                                    printf(\"Fail: %30s \\\"%s\\\" \\\"%s\\\"\\n\", filename, description1, description2);\n                                else\n                                    passCount++;\n                            }\n                        }\n                        //printf(\"%zu %zu %zu\\n\", documentAllocator.Size(), schemaAllocator.Size(), validatorAllocator.Size());\n                    }\n                    schemaAllocator.Clear();\n                    validatorAllocator.Clear();\n                }\n            }\n        }\n        documentAllocator.Clear();\n        MemoryPoolAllocator<>::Free(json);\n        jsonAllocator.Clear();\n    }\n    printf(\"%d / %d passed (%2d%%)\\n\", passCount, testCount, passCount * 100 / testCount);\n    // if (passCount != testCount)\n    //     ADD_FAILURE();\n}\n\nTEST(SchemaValidatingReader, Simple) {\n    Document sd;\n    sd.Parse(\"{ \\\"type\\\": \\\"string\\\", \\\"enum\\\" : [\\\"red\\\", \\\"amber\\\", \\\"green\\\"] }\");\n    SchemaDocument s(sd);\n\n    Document d;\n    StringStream ss(\"\\\"red\\\"\");\n    SchemaValidatingReader<kParseDefaultFlags, StringStream, UTF8<> > reader(ss, s);\n    d.Populate(reader);\n    EXPECT_TRUE(reader.GetParseResult());\n    EXPECT_TRUE(reader.IsValid());\n    EXPECT_TRUE(d.IsString());\n    EXPECT_STREQ(\"red\", d.GetString());\n}\n\nTEST(SchemaValidatingReader, Invalid) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"string\\\",\\\"minLength\\\":2,\\\"maxLength\\\":3}\");\n    SchemaDocument s(sd);\n\n    Document d;\n    StringStream ss(\"\\\"ABCD\\\"\");\n    SchemaValidatingReader<kParseDefaultFlags, StringStream, UTF8<> > reader(ss, s);\n    d.Populate(reader);\n    EXPECT_FALSE(reader.GetParseResult());\n    EXPECT_FALSE(reader.IsValid());\n    EXPECT_EQ(kParseErrorTermination, reader.GetParseResult().Code());\n    EXPECT_STREQ(\"maxLength\", reader.GetInvalidSchemaKeyword());\n    EXPECT_TRUE(reader.GetInvalidSchemaPointer() == SchemaDocument::PointerType(\"\"));\n    EXPECT_TRUE(reader.GetInvalidDocumentPointer() == SchemaDocument::PointerType(\"\"));\n    EXPECT_TRUE(d.IsNull());\n}\n\nTEST(SchemaValidatingWriter, Simple) {\n    Document sd;\n    sd.Parse(\"{\\\"type\\\":\\\"string\\\",\\\"minLength\\\":2,\\\"maxLength\\\":3}\");\n    SchemaDocument s(sd);\n\n    Document d;\n    StringBuffer sb;\n    Writer<StringBuffer> writer(sb);\n    GenericSchemaValidator<SchemaDocument, Writer<StringBuffer> > validator(s, writer);\n\n    d.Parse(\"\\\"red\\\"\");\n    EXPECT_TRUE(d.Accept(validator));\n    EXPECT_TRUE(validator.IsValid());\n    EXPECT_STREQ(\"\\\"red\\\"\", sb.GetString());\n\n    sb.Clear();\n    validator.Reset();\n    d.Parse(\"\\\"ABCD\\\"\");\n    EXPECT_FALSE(d.Accept(validator));\n    EXPECT_FALSE(validator.IsValid());\n    EXPECT_TRUE(validator.GetInvalidSchemaPointer() == SchemaDocument::PointerType(\"\"));\n    EXPECT_TRUE(validator.GetInvalidDocumentPointer() == SchemaDocument::PointerType(\"\"));\n}\n\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\n\nstatic SchemaDocument ReturnSchemaDocument() {\n    Document sd;\n    sd.Parse(\"{ \\\"type\\\": [\\\"number\\\", \\\"string\\\"] }\");\n    SchemaDocument s(sd);\n    return s;\n}\n\nTEST(Schema, Issue552) {\n    SchemaDocument s = ReturnSchemaDocument();\n    VALIDATE(s, \"42\", true);\n    VALIDATE(s, \"\\\"Life, the universe, and everything\\\"\", true);\n    INVALIDATE(s, \"[\\\"Life\\\", \\\"the universe\\\", \\\"and everything\\\"]\", \"\", \"type\", \"\");\n}\n\n#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS\n\nTEST(SchemaValidator, Issue608) {\n    Document sd;\n    sd.Parse(\"{\\\"required\\\": [\\\"a\\\", \\\"b\\\"] }\");\n    SchemaDocument s(sd);\n\n    VALIDATE(s, \"{\\\"a\\\" : null, \\\"b\\\": null}\", true);\n    INVALIDATE(s, \"{\\\"a\\\" : null, \\\"a\\\" : null}\", \"\", \"required\", \"\");\n}\n\n#ifdef __clang__\nRAPIDJSON_DIAG_POP\n#endif\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/simdtest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n// Since Travis CI installs old Valgrind 3.7.0, which fails with some SSE4.2\n// The unit tests prefix with SIMD should be skipped by Valgrind test\n\n// __SSE2__ and __SSE4_2__ are recognized by gcc, clang, and the Intel compiler.\n// We use -march=native with gmake to enable -msse2 and -msse4.2, if supported.\n#if defined(__SSE4_2__)\n#  define RAPIDJSON_SSE42\n#elif defined(__SSE2__)\n#  define RAPIDJSON_SSE2\n#endif\n\n#define RAPIDJSON_NAMESPACE rapidjson_simd\n\n#include \"unittest.h\"\n\n#include \"rapidjson/reader.h\"\n#include \"rapidjson/writer.h\"\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(effc++)\n#endif\n\nusing namespace rapidjson_simd;\n\n#ifdef RAPIDJSON_SSE2\n#define SIMD_SUFFIX(name) name##_SSE2\n#elif defined(RAPIDJSON_SSE42)\n#define SIMD_SUFFIX(name) name##_SSE42\n#else\n#define SIMD_SUFFIX(name) name\n#endif\n\ntemplate <typename StreamType>\nvoid TestSkipWhitespace() {\n    for (size_t step = 1; step < 32; step++) {\n        char buffer[1025];\n        for (size_t i = 0; i < 1024; i++)\n            buffer[i] = \" \\t\\r\\n\"[i % 4];\n        for (size_t i = 0; i < 1024; i += step)\n            buffer[i] = 'X';\n        buffer[1024] = '\\0';\n\n        StreamType s(buffer);\n        size_t i = 0;\n        for (;;) {\n            SkipWhitespace(s);\n            if (s.Peek() == '\\0')\n                break;\n            EXPECT_EQ(i, s.Tell());\n            EXPECT_EQ('X', s.Take());\n            i += step;\n        }\n    }\n}\n\nTEST(SIMD, SIMD_SUFFIX(SkipWhitespace)) {\n    TestSkipWhitespace<StringStream>();\n    TestSkipWhitespace<InsituStringStream>();\n}\n\nTEST(SIMD, SIMD_SUFFIX(SkipWhitespace_EncodedMemoryStream)) {\n    for (size_t step = 1; step < 32; step++) {\n        char buffer[1024];\n        for (size_t i = 0; i < 1024; i++)\n            buffer[i] = \" \\t\\r\\n\"[i % 4];\n        for (size_t i = 0; i < 1024; i += step)\n            buffer[i] = 'X';\n\n        MemoryStream ms(buffer, 1024);\n        EncodedInputStream<UTF8<>, MemoryStream> s(ms);\n        size_t i = 0;\n        for (;;) {\n            SkipWhitespace(s);\n            if (s.Peek() == '\\0')\n                break;\n            //EXPECT_EQ(i, s.Tell());\n            EXPECT_EQ('X', s.Take());\n            i += step;\n        }\n    }\n}\n\nstruct ScanCopyUnescapedStringHandler : BaseReaderHandler<UTF8<>, ScanCopyUnescapedStringHandler> {\n    bool String(const char* str, size_t length, bool) {\n        memcpy(buffer, str, length + 1);\n        return true;\n    }\n    char buffer[1024 + 5 + 32];\n};\n\ntemplate <unsigned parseFlags, typename StreamType>\nvoid TestScanCopyUnescapedString() {\n    char buffer[1024 + 5 + 32];\n    char backup[1024 + 5 + 32];\n\n    // Test \"ABCDABCD...\\\\\"\n    for (size_t offset = 0; offset < 32; offset++) {\n        for (size_t step = 0; step < 1024; step++) {\n            char* json = buffer + offset;\n            char *p = json;\n            *p++ = '\\\"';\n            for (size_t i = 0; i < step; i++)\n                *p++ = \"ABCD\"[i % 4];\n            *p++ = '\\\\';\n            *p++ = '\\\\';\n            *p++ = '\\\"';\n            *p++ = '\\0';\n            strcpy(backup, json); // insitu parsing will overwrite buffer, so need to backup first\n\n            StreamType s(json);\n            Reader reader;\n            ScanCopyUnescapedStringHandler h;\n            reader.Parse<parseFlags>(s, h);\n            EXPECT_TRUE(memcmp(h.buffer, backup + 1, step) == 0);\n            EXPECT_EQ('\\\\', h.buffer[step]);    // escaped\n            EXPECT_EQ('\\0', h.buffer[step + 1]);\n        }\n    }\n\n    // Test \"\\\\ABCDABCD...\"\n    for (size_t offset = 0; offset < 32; offset++) {\n        for (size_t step = 0; step < 1024; step++) {\n            char* json = buffer + offset;\n            char *p = json;\n            *p++ = '\\\"';\n            *p++ = '\\\\';\n            *p++ = '\\\\';\n            for (size_t i = 0; i < step; i++)\n                *p++ = \"ABCD\"[i % 4];\n            *p++ = '\\\"';\n            *p++ = '\\0';\n            strcpy(backup, json); // insitu parsing will overwrite buffer, so need to backup first\n\n            StreamType s(json);\n            Reader reader;\n            ScanCopyUnescapedStringHandler h;\n            reader.Parse<parseFlags>(s, h);\n            EXPECT_TRUE(memcmp(h.buffer + 1, backup + 3, step) == 0);\n            EXPECT_EQ('\\\\', h.buffer[0]);    // escaped\n            EXPECT_EQ('\\0', h.buffer[step + 1]);\n        }\n    }\n}\n\nTEST(SIMD, SIMD_SUFFIX(ScanCopyUnescapedString)) {\n    TestScanCopyUnescapedString<kParseDefaultFlags, StringStream>();\n    TestScanCopyUnescapedString<kParseInsituFlag, InsituStringStream>();\n}\n\nTEST(SIMD, SIMD_SUFFIX(ScanWriteUnescapedString)) {\n    char buffer[2048 + 1 + 32];\n    for (size_t offset = 0; offset < 32; offset++) {\n        for (size_t step = 0; step < 1024; step++) {\n            char* s = buffer + offset;\n            char* p = s;\n            for (size_t i = 0; i < step; i++)\n                *p++ = \"ABCD\"[i % 4];\n            char escape = \"\\0\\n\\\\\\\"\"[step % 4];\n            *p++ = escape;\n            for (size_t i = 0; i < step; i++)\n                *p++ = \"ABCD\"[i % 4];\n\n            StringBuffer sb;\n            Writer<StringBuffer> writer(sb);\n            writer.String(s, SizeType(step * 2 + 1));\n            const char* q = sb.GetString();\n            EXPECT_EQ('\\\"', *q++);\n            for (size_t i = 0; i < step; i++)\n                EXPECT_EQ(\"ABCD\"[i % 4], *q++);\n            if (escape == '\\0') {\n                EXPECT_EQ('\\\\', *q++);\n                EXPECT_EQ('u', *q++);\n                EXPECT_EQ('0', *q++);\n                EXPECT_EQ('0', *q++);\n                EXPECT_EQ('0', *q++);\n                EXPECT_EQ('0', *q++);\n            }\n            else if (escape == '\\n') {\n                EXPECT_EQ('\\\\', *q++);\n                EXPECT_EQ('n', *q++);\n            }\n            else if (escape == '\\\\') {\n                EXPECT_EQ('\\\\', *q++);\n                EXPECT_EQ('\\\\', *q++);\n            }\n            else if (escape == '\\\"') {\n                EXPECT_EQ('\\\\', *q++);\n                EXPECT_EQ('\\\"', *q++);\n            }\n            for (size_t i = 0; i < step; i++)\n                EXPECT_EQ(\"ABCD\"[i % 4], *q++);\n            EXPECT_EQ('\\\"', *q++);\n            EXPECT_EQ('\\0', *q++);\n        }\n    }\n}\n\n#ifdef __GNUC__\nRAPIDJSON_DIAG_POP\n#endif\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/strfunctest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n#include \"rapidjson/internal/strfunc.h\"\n\nusing namespace rapidjson;\nusing namespace rapidjson::internal;\n\nTEST(StrFunc, CountStringCodePoint) {\n    SizeType count;\n    EXPECT_TRUE(CountStringCodePoint<UTF8<> >(\"\", 0, &count));\n    EXPECT_EQ(0u, count);\n    EXPECT_TRUE(CountStringCodePoint<UTF8<> >(\"Hello\", 5, &count));\n    EXPECT_EQ(5u, count);\n    EXPECT_TRUE(CountStringCodePoint<UTF8<> >(\"\\xC2\\xA2\\xE2\\x82\\xAC\\xF0\\x9D\\x84\\x9E\", 9, &count)); // cents euro G-clef\n    EXPECT_EQ(3u, count);\n    EXPECT_FALSE(CountStringCodePoint<UTF8<> >(\"\\xC2\\xA2\\xE2\\x82\\xAC\\xF0\\x9D\\x84\\x9E\\x80\", 10, &count));\n}\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/stringbuffertest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n#include \"rapidjson/stringbuffer.h\"\n#include \"rapidjson/writer.h\"\n\n#ifdef __clang__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(c++98-compat)\n#endif\n\nusing namespace rapidjson;\n\nTEST(StringBuffer, InitialSize) {\n    StringBuffer buffer;\n    EXPECT_EQ(0u, buffer.GetSize());\n    EXPECT_STREQ(\"\", buffer.GetString());\n}\n\nTEST(StringBuffer, Put) {\n    StringBuffer buffer;\n    buffer.Put('A');\n\n    EXPECT_EQ(1u, buffer.GetSize());\n    EXPECT_STREQ(\"A\", buffer.GetString());\n}\n\nTEST(StringBuffer, PutN_Issue672) {\n    GenericStringBuffer<UTF8<>, MemoryPoolAllocator<> > buffer;\n    EXPECT_EQ(0, buffer.GetSize());\n    rapidjson::PutN(buffer, ' ', 1);\n    EXPECT_EQ(1, buffer.GetSize());\n}\n\nTEST(StringBuffer, Clear) {\n    StringBuffer buffer;\n    buffer.Put('A');\n    buffer.Put('B');\n    buffer.Put('C');\n    buffer.Clear();\n\n    EXPECT_EQ(0u, buffer.GetSize());\n    EXPECT_STREQ(\"\", buffer.GetString());\n}\n\nTEST(StringBuffer, Push) {\n    StringBuffer buffer;\n    buffer.Push(5);\n\n    EXPECT_EQ(5u, buffer.GetSize());\n\n    // Causes sudden expansion to make the stack's capacity equal to size\n    buffer.Push(65536u);\n    EXPECT_EQ(5u + 65536u, buffer.GetSize());\n}\n\nTEST(StringBuffer, Pop) {\n    StringBuffer buffer;\n    buffer.Put('A');\n    buffer.Put('B');\n    buffer.Put('C');\n    buffer.Put('D');\n    buffer.Put('E');\n    buffer.Pop(3);\n\n    EXPECT_EQ(2u, buffer.GetSize());\n    EXPECT_STREQ(\"AB\", buffer.GetString());\n}\n\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\n\n#if 0 // Many old compiler does not support these. Turn it off temporaily.\n\n#include <type_traits>\n\nTEST(StringBuffer, Traits) {\n    static_assert( std::is_constructible<StringBuffer>::value, \"\");\n    static_assert( std::is_default_constructible<StringBuffer>::value, \"\");\n#ifndef _MSC_VER\n    static_assert(!std::is_copy_constructible<StringBuffer>::value, \"\");\n#endif\n    static_assert( std::is_move_constructible<StringBuffer>::value, \"\");\n\n    static_assert(!std::is_nothrow_constructible<StringBuffer>::value, \"\");\n    static_assert(!std::is_nothrow_default_constructible<StringBuffer>::value, \"\");\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1800\n    static_assert(!std::is_nothrow_copy_constructible<StringBuffer>::value, \"\");\n    static_assert(!std::is_nothrow_move_constructible<StringBuffer>::value, \"\");\n#endif\n\n    static_assert( std::is_assignable<StringBuffer,StringBuffer>::value, \"\");\n#ifndef _MSC_VER\n    static_assert(!std::is_copy_assignable<StringBuffer>::value, \"\");\n#endif\n    static_assert( std::is_move_assignable<StringBuffer>::value, \"\");\n\n#if !defined(_MSC_VER) || _MSC_VER >= 1800\n    static_assert(!std::is_nothrow_assignable<StringBuffer, StringBuffer>::value, \"\");\n#endif\n\n    static_assert(!std::is_nothrow_copy_assignable<StringBuffer>::value, \"\");\n    static_assert(!std::is_nothrow_move_assignable<StringBuffer>::value, \"\");\n\n    static_assert( std::is_destructible<StringBuffer>::value, \"\");\n#ifndef _MSC_VER\n    static_assert(std::is_nothrow_destructible<StringBuffer>::value, \"\");\n#endif\n}\n\n#endif\n\nTEST(StringBuffer, MoveConstructor) {\n    StringBuffer x;\n    x.Put('A');\n    x.Put('B');\n    x.Put('C');\n    x.Put('D');\n\n    EXPECT_EQ(4u, x.GetSize());\n    EXPECT_STREQ(\"ABCD\", x.GetString());\n\n    // StringBuffer y(x); // does not compile (!is_copy_constructible)\n    StringBuffer y(std::move(x));\n    EXPECT_EQ(0u, x.GetSize());\n    EXPECT_EQ(4u, y.GetSize());\n    EXPECT_STREQ(\"ABCD\", y.GetString());\n\n    // StringBuffer z = y; // does not compile (!is_copy_assignable)\n    StringBuffer z = std::move(y);\n    EXPECT_EQ(0u, y.GetSize());\n    EXPECT_EQ(4u, z.GetSize());\n    EXPECT_STREQ(\"ABCD\", z.GetString());\n}\n\nTEST(StringBuffer, MoveAssignment) {\n    StringBuffer x;\n    x.Put('A');\n    x.Put('B');\n    x.Put('C');\n    x.Put('D');\n\n    EXPECT_EQ(4u, x.GetSize());\n    EXPECT_STREQ(\"ABCD\", x.GetString());\n\n    StringBuffer y;\n    // y = x; // does not compile (!is_copy_assignable)\n    y = std::move(x);\n    EXPECT_EQ(0u, x.GetSize());\n    EXPECT_EQ(4u, y.GetSize());\n    EXPECT_STREQ(\"ABCD\", y.GetString());\n}\n\n#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS\n\n#ifdef __clang__\nRAPIDJSON_DIAG_POP\n#endif\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/strtodtest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n\n#include \"rapidjson/internal/strtod.h\"\n\n#ifdef __clang__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(unreachable-code)\n#endif\n\n#define BIGINTEGER_LITERAL(s) BigInteger(s, sizeof(s) - 1)\n\nusing namespace rapidjson::internal;\n\nTEST(Strtod, CheckApproximationCase) {\n    static const int kSignificandSize = 52;\n    static const int kExponentBias = 0x3FF;\n    static const uint64_t kExponentMask = RAPIDJSON_UINT64_C2(0x7FF00000, 0x00000000);\n    static const uint64_t kSignificandMask = RAPIDJSON_UINT64_C2(0x000FFFFF, 0xFFFFFFFF);\n    static const uint64_t kHiddenBit = RAPIDJSON_UINT64_C2(0x00100000, 0x00000000);\n\n    // http://www.exploringbinary.com/using-integers-to-check-a-floating-point-approximation/\n    // Let b = 0x1.465a72e467d88p-149\n    //       = 5741268244528520 x 2^-201\n    union {\n        double d;\n        uint64_t u;\n    }u;\n    u.u = 0x465a72e467d88 | ((static_cast<uint64_t>(-149 + kExponentBias)) << kSignificandSize);\n    const double b = u.d;\n    const uint64_t bInt = (u.u & kSignificandMask) | kHiddenBit;\n    const int bExp = static_cast<int>(((u.u & kExponentMask) >> kSignificandSize) - kExponentBias - kSignificandSize);\n    EXPECT_DOUBLE_EQ(1.7864e-45, b);\n    EXPECT_EQ(RAPIDJSON_UINT64_C2(0x001465a7, 0x2e467d88), bInt);\n    EXPECT_EQ(-201, bExp);\n\n    // Let d = 17864 x 10-49\n    const char dInt[] = \"17864\";\n    const int dExp = -49;\n\n    // Let h = 2^(bExp-1)\n    const int hExp = bExp - 1;\n    EXPECT_EQ(-202, hExp);\n\n    int dS_Exp2 = 0;\n    int dS_Exp5 = 0;\n    int bS_Exp2 = 0;\n    int bS_Exp5 = 0;\n    int hS_Exp2 = 0;\n    int hS_Exp5 = 0;\n\n    // Adjust for decimal exponent\n    if (dExp >= 0) {\n        dS_Exp2 += dExp;\n        dS_Exp5 += dExp;\n    }\n    else {\n        bS_Exp2 -= dExp;\n        bS_Exp5 -= dExp;\n        hS_Exp2 -= dExp;\n        hS_Exp5 -= dExp;\n    }\n\n    // Adjust for binary exponent\n    if (bExp >= 0)\n        bS_Exp2 += bExp;\n    else {\n        dS_Exp2 -= bExp;\n        hS_Exp2 -= bExp;\n    }\n\n    // Adjust for half ulp exponent\n    if (hExp >= 0)\n        hS_Exp2 += hExp;\n    else {\n        dS_Exp2 -= hExp;\n        bS_Exp2 -= hExp;\n    }\n\n    // Remove common power of two factor from all three scaled values\n    int common_Exp2 = std::min(dS_Exp2, std::min(bS_Exp2, hS_Exp2));\n    dS_Exp2 -= common_Exp2;\n    bS_Exp2 -= common_Exp2;\n    hS_Exp2 -= common_Exp2;\n\n    EXPECT_EQ(153, dS_Exp2);\n    EXPECT_EQ(0, dS_Exp5);\n    EXPECT_EQ(1, bS_Exp2);\n    EXPECT_EQ(49, bS_Exp5);\n    EXPECT_EQ(0, hS_Exp2);\n    EXPECT_EQ(49, hS_Exp5);\n\n    BigInteger dS = BIGINTEGER_LITERAL(dInt);\n    dS.MultiplyPow5(static_cast<unsigned>(dS_Exp5)) <<= static_cast<size_t>(dS_Exp2);\n\n    BigInteger bS(bInt);\n    bS.MultiplyPow5(static_cast<unsigned>(bS_Exp5)) <<= static_cast<size_t>(bS_Exp2);\n\n    BigInteger hS(1);\n    hS.MultiplyPow5(static_cast<unsigned>(hS_Exp5)) <<= static_cast<size_t>(hS_Exp2);\n\n    EXPECT_TRUE(BIGINTEGER_LITERAL(\"203970822259994138521801764465966248930731085529088\") == dS);\n    EXPECT_TRUE(BIGINTEGER_LITERAL(\"203970822259994122305215569213032722473144531250000\") == bS);\n    EXPECT_TRUE(BIGINTEGER_LITERAL(\"17763568394002504646778106689453125\") == hS);\n\n    EXPECT_EQ(1, dS.Compare(bS));\n    \n    BigInteger delta(0);\n    EXPECT_FALSE(dS.Difference(bS, &delta));\n    EXPECT_TRUE(BIGINTEGER_LITERAL(\"16216586195252933526457586554279088\") == delta);\n    EXPECT_TRUE(bS.Difference(dS, &delta));\n    EXPECT_TRUE(BIGINTEGER_LITERAL(\"16216586195252933526457586554279088\") == delta);\n\n    EXPECT_EQ(-1, delta.Compare(hS));\n}\n\n#ifdef __clang__\nRAPIDJSON_DIAG_POP\n#endif\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/unittest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n#include \"rapidjson/rapidjson.h\"\n\n#ifdef __clang__\n#pragma GCC diagnostic push\n#if __has_warning(\"-Wdeprecated\")\n#pragma GCC diagnostic ignored \"-Wdeprecated\"\n#endif\n#endif\n\nAssertException::~AssertException() throw() {}\n\n#ifdef __clang__\n#pragma GCC diagnostic pop\n#endif\n\nint main(int argc, char **argv) {\n    ::testing::InitGoogleTest(&argc, argv);\n\n    std::cout << \"RapidJSON v\" << RAPIDJSON_VERSION_STRING << std::endl;\n\n#ifdef _MSC_VER\n    _CrtMemState memoryState = { 0 };\n    (void)memoryState;\n    _CrtMemCheckpoint(&memoryState);\n    //_CrtSetBreakAlloc(X);\n    //void *testWhetherMemoryLeakDetectionWorks = malloc(1);\n#endif\n\n    int ret = RUN_ALL_TESTS();\n\n#ifdef _MSC_VER\n    // Current gtest constantly leak 2 blocks at exit\n    _CrtMemDumpAllObjectsSince(&memoryState);\n#endif\n    return ret;\n}\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/unittest.h",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#ifndef UNITTEST_H_\n#define UNITTEST_H_\n\n// gtest indirectly included inttypes.h, without __STDC_CONSTANT_MACROS.\n#ifndef __STDC_CONSTANT_MACROS\n#ifdef __clang__\n#pragma GCC diagnostic push\n#if __has_warning(\"-Wreserved-id-macro\")\n#pragma GCC diagnostic ignored \"-Wreserved-id-macro\"\n#endif\n#endif\n\n#  define __STDC_CONSTANT_MACROS 1 // required by C++ standard\n\n#ifdef __clang__\n#pragma GCC diagnostic pop\n#endif\n#endif\n\n#ifdef _MSC_VER\n#define _CRTDBG_MAP_ALLOC\n#include <crtdbg.h>\n#pragma warning(disable : 4996) // 'function': was declared deprecated\n#endif\n\n#if defined(__clang__) || defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2))\n#if defined(__clang__) || (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))\n#pragma GCC diagnostic push\n#endif\n#pragma GCC diagnostic ignored \"-Weffc++\"\n#endif\n\n#include \"gtest/gtest.h\"\n#include <stdexcept>\n\n#if defined(__clang__) || defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))\n#pragma GCC diagnostic pop\n#endif\n\n#ifdef __clang__\n// All TEST() macro generated this warning, disable globally\n#pragma GCC diagnostic ignored \"-Wglobal-constructors\"\n#endif\n\ntemplate <typename Ch>\ninline unsigned StrLen(const Ch* s) {\n    const Ch* p = s;\n    while (*p) p++;\n    return unsigned(p - s);\n}\n\ntemplate<typename Ch>\ninline int StrCmp(const Ch* s1, const Ch* s2) {\n    while(*s1 && (*s1 == *s2)) { s1++; s2++; }\n    return static_cast<unsigned>(*s1) < static_cast<unsigned>(*s2) ? -1 : static_cast<unsigned>(*s1) > static_cast<unsigned>(*s2);\n}\n\ntemplate <typename Ch>\ninline Ch* StrDup(const Ch* str) {\n    size_t bufferSize = sizeof(Ch) * (StrLen(str) + 1);\n    Ch* buffer = static_cast<Ch*>(malloc(bufferSize));\n    memcpy(buffer, str, bufferSize);\n    return buffer;\n}\n\ninline FILE* TempFile(char *filename) {\n#ifdef _MSC_VER\n    filename = tmpnam(filename);\n\n    // For Visual Studio, tmpnam() adds a backslash in front. Remove it.\n    if (filename[0] == '\\\\')\n        for (int i = 0; filename[i] != '\\0'; i++)\n            filename[i] = filename[i + 1];\n        \n    return fopen(filename, \"wb\");\n#else\n    strcpy(filename, \"/tmp/fileXXXXXX\");\n    int fd = mkstemp(filename);\n    return fdopen(fd, \"w\");\n#endif\n}\n\n// Use exception for catching assert\n#ifdef _MSC_VER\n#pragma warning(disable : 4127)\n#endif\n\n#ifdef __clang__\n#pragma GCC diagnostic push\n#if __has_warning(\"-Wdeprecated\")\n#pragma GCC diagnostic ignored \"-Wdeprecated\"\n#endif\n#endif\n\nclass AssertException : public std::logic_error {\npublic:\n    AssertException(const char* w) : std::logic_error(w) {}\n    AssertException(const AssertException& rhs) : std::logic_error(rhs) {}\n    virtual ~AssertException() throw();\n};\n\n#ifdef __clang__\n#pragma GCC diagnostic pop\n#endif\n\n#define RAPIDJSON_ASSERT(x) if (!(x)) throw AssertException(RAPIDJSON_STRINGIFY(x))\n\nclass Random {\npublic:\n    Random(unsigned seed = 0) : mSeed(seed) {}\n\n    unsigned operator()() {\n        mSeed = 214013 * mSeed + 2531011;\n        return mSeed;\n    }\n\nprivate:\n    unsigned mSeed;\n};\n\n#endif // UNITTEST_H_\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/valuetest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n#include \"rapidjson/document.h\"\n#include <algorithm>\n\n#ifdef __clang__\nRAPIDJSON_DIAG_PUSH\nRAPIDJSON_DIAG_OFF(c++98-compat)\n#endif\n\nusing namespace rapidjson;\n\nTEST(Value, Size) {\n    if (sizeof(SizeType) == 4) {\n#if RAPIDJSON_48BITPOINTER_OPTIMIZATION\n        EXPECT_EQ(16, sizeof(Value));\n#elif RAPIDJSON_64BIT\n        EXPECT_EQ(24, sizeof(Value));\n#else\n        EXPECT_EQ(16, sizeof(Value));\n#endif\n    }\n}\n\nTEST(Value, DefaultConstructor) {\n    Value x;\n    EXPECT_EQ(kNullType, x.GetType());\n    EXPECT_TRUE(x.IsNull());\n\n    //std::cout << \"sizeof(Value): \" << sizeof(x) << std::endl;\n}\n\n// Should not pass compilation\n//TEST(Value, copy_constructor) {\n//  Value x(1234);\n//  Value y = x;\n//}\n\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\n\n#if 0 // Many old compiler does not support these. Turn it off temporaily.\n\n#include <type_traits>\n\nTEST(Value, Traits) {\n    typedef GenericValue<UTF8<>, CrtAllocator> Value;\n    static_assert(std::is_constructible<Value>::value, \"\");\n    static_assert(std::is_default_constructible<Value>::value, \"\");\n#ifndef _MSC_VER\n    static_assert(!std::is_copy_constructible<Value>::value, \"\");\n#endif\n    static_assert(std::is_move_constructible<Value>::value, \"\");\n\n#ifndef _MSC_VER\n    static_assert(std::is_nothrow_constructible<Value>::value, \"\");\n    static_assert(std::is_nothrow_default_constructible<Value>::value, \"\");\n    static_assert(!std::is_nothrow_copy_constructible<Value>::value, \"\");\n    static_assert(std::is_nothrow_move_constructible<Value>::value, \"\");\n#endif\n\n    static_assert(std::is_assignable<Value,Value>::value, \"\");\n#ifndef _MSC_VER\n    static_assert(!std::is_copy_assignable<Value>::value, \"\");\n#endif\n    static_assert(std::is_move_assignable<Value>::value, \"\");\n\n#ifndef _MSC_VER\n    static_assert(std::is_nothrow_assignable<Value, Value>::value, \"\");\n#endif\n    static_assert(!std::is_nothrow_copy_assignable<Value>::value, \"\");\n#ifndef _MSC_VER\n    static_assert(std::is_nothrow_move_assignable<Value>::value, \"\");\n#endif\n\n    static_assert(std::is_destructible<Value>::value, \"\");\n#ifndef _MSC_VER\n    static_assert(std::is_nothrow_destructible<Value>::value, \"\");\n#endif\n}\n\n#endif\n\nTEST(Value, MoveConstructor) {\n    typedef GenericValue<UTF8<>, CrtAllocator> V;\n    V::AllocatorType allocator;\n\n    V x((V(kArrayType)));\n    x.Reserve(4u, allocator);\n    x.PushBack(1, allocator).PushBack(2, allocator).PushBack(3, allocator).PushBack(4, allocator);\n    EXPECT_TRUE(x.IsArray());\n    EXPECT_EQ(4u, x.Size());\n\n    // Value y(x); // does not compile (!is_copy_constructible)\n    V y(std::move(x));\n    EXPECT_TRUE(x.IsNull());\n    EXPECT_TRUE(y.IsArray());\n    EXPECT_EQ(4u, y.Size());\n\n    // Value z = y; // does not compile (!is_copy_assignable)\n    V z = std::move(y);\n    EXPECT_TRUE(y.IsNull());\n    EXPECT_TRUE(z.IsArray());\n    EXPECT_EQ(4u, z.Size());\n}\n\n#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS\n\nTEST(Value, AssignmentOperator) {\n    Value x(1234);\n    Value y;\n    y = x;\n    EXPECT_TRUE(x.IsNull());    // move semantic\n    EXPECT_EQ(1234, y.GetInt());\n\n    y = 5678;\n    EXPECT_TRUE(y.IsInt());\n    EXPECT_EQ(5678, y.GetInt());\n\n    x = \"Hello\";\n    EXPECT_TRUE(x.IsString());\n    EXPECT_STREQ(x.GetString(),\"Hello\");\n\n    y = StringRef(x.GetString(),x.GetStringLength());\n    EXPECT_TRUE(y.IsString());\n    EXPECT_EQ(y.GetString(),x.GetString());\n    EXPECT_EQ(y.GetStringLength(),x.GetStringLength());\n\n    static char mstr[] = \"mutable\";\n    // y = mstr; // should not compile\n    y = StringRef(mstr);\n    EXPECT_TRUE(y.IsString());\n    EXPECT_EQ(y.GetString(),mstr);\n\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\n    // C++11 move assignment\n    x = Value(\"World\");\n    EXPECT_TRUE(x.IsString());\n    EXPECT_STREQ(\"World\", x.GetString());\n\n    x = std::move(y);\n    EXPECT_TRUE(y.IsNull());\n    EXPECT_TRUE(x.IsString());\n    EXPECT_EQ(x.GetString(), mstr);\n\n    y = std::move(Value().SetInt(1234));\n    EXPECT_TRUE(y.IsInt());\n    EXPECT_EQ(1234, y);\n#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS\n}\n\ntemplate <typename A, typename B> \nvoid TestEqual(const A& a, const B& b) {\n    EXPECT_TRUE (a == b);\n    EXPECT_FALSE(a != b);\n    EXPECT_TRUE (b == a);\n    EXPECT_FALSE(b != a);\n}\n\ntemplate <typename A, typename B> \nvoid TestUnequal(const A& a, const B& b) {\n    EXPECT_FALSE(a == b);\n    EXPECT_TRUE (a != b);\n    EXPECT_FALSE(b == a);\n    EXPECT_TRUE (b != a);\n}\n\nTEST(Value, EqualtoOperator) {\n    Value::AllocatorType allocator;\n    Value x(kObjectType);\n    x.AddMember(\"hello\", \"world\", allocator)\n        .AddMember(\"t\", Value(true).Move(), allocator)\n        .AddMember(\"f\", Value(false).Move(), allocator)\n        .AddMember(\"n\", Value(kNullType).Move(), allocator)\n        .AddMember(\"i\", 123, allocator)\n        .AddMember(\"pi\", 3.14, allocator)\n        .AddMember(\"a\", Value(kArrayType).Move().PushBack(1, allocator).PushBack(2, allocator).PushBack(3, allocator), allocator);\n\n    // Test templated operator==() and operator!=()\n    TestEqual(x[\"hello\"], \"world\");\n    const char* cc = \"world\";\n    TestEqual(x[\"hello\"], cc);\n    char* c = strdup(\"world\");\n    TestEqual(x[\"hello\"], c);\n    free(c);\n\n    TestEqual(x[\"t\"], true);\n    TestEqual(x[\"f\"], false);\n    TestEqual(x[\"i\"], 123);\n    TestEqual(x[\"pi\"], 3.14);\n\n    // Test operator==() (including different allocators)\n    CrtAllocator crtAllocator;\n    GenericValue<UTF8<>, CrtAllocator> y;\n    GenericDocument<UTF8<>, CrtAllocator> z(&crtAllocator);\n    y.CopyFrom(x, crtAllocator);\n    z.CopyFrom(y, z.GetAllocator());\n    TestEqual(x, y);\n    TestEqual(y, z);\n    TestEqual(z, x);\n\n    // Swapping member order should be fine.\n    EXPECT_TRUE(y.RemoveMember(\"t\"));\n    TestUnequal(x, y);\n    TestUnequal(z, y);\n    EXPECT_TRUE(z.RemoveMember(\"t\"));\n    TestUnequal(x, z);\n    TestEqual(y, z);\n    y.AddMember(\"t\", false, crtAllocator);\n    z.AddMember(\"t\", false, z.GetAllocator());\n    TestUnequal(x, y);\n    TestUnequal(z, x);\n    y[\"t\"] = true;\n    z[\"t\"] = true;\n    TestEqual(x, y);\n    TestEqual(y, z);\n    TestEqual(z, x);\n\n    // Swapping element order is not OK\n    x[\"a\"][0].Swap(x[\"a\"][1]);\n    TestUnequal(x, y);\n    x[\"a\"][0].Swap(x[\"a\"][1]);\n    TestEqual(x, y);\n\n    // Array of different size\n    x[\"a\"].PushBack(4, allocator);\n    TestUnequal(x, y);\n    x[\"a\"].PopBack();\n    TestEqual(x, y);\n\n    // Issue #129: compare Uint64\n    x.SetUint64(RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0xFFFFFFF0));\n    y.SetUint64(RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0xFFFFFFFF));\n    TestUnequal(x, y);\n}\n\ntemplate <typename Value>\nvoid TestCopyFrom() {\n    typename Value::AllocatorType a;\n    Value v1(1234);\n    Value v2(v1, a); // deep copy constructor\n    EXPECT_TRUE(v1.GetType() == v2.GetType());\n    EXPECT_EQ(v1.GetInt(), v2.GetInt());\n\n    v1.SetString(\"foo\");\n    v2.CopyFrom(v1, a);\n    EXPECT_TRUE(v1.GetType() == v2.GetType());\n    EXPECT_STREQ(v1.GetString(), v2.GetString());\n    EXPECT_EQ(v1.GetString(), v2.GetString()); // string NOT copied\n\n    v1.SetString(\"bar\", a); // copy string\n    v2.CopyFrom(v1, a);\n    EXPECT_TRUE(v1.GetType() == v2.GetType());\n    EXPECT_STREQ(v1.GetString(), v2.GetString());\n    EXPECT_NE(v1.GetString(), v2.GetString()); // string copied\n\n\n    v1.SetArray().PushBack(1234, a);\n    v2.CopyFrom(v1, a);\n    EXPECT_TRUE(v2.IsArray());\n    EXPECT_EQ(v1.Size(), v2.Size());\n\n    v1.PushBack(Value().SetString(\"foo\", a), a); // push string copy\n    EXPECT_TRUE(v1.Size() != v2.Size());\n    v2.CopyFrom(v1, a);\n    EXPECT_TRUE(v1.Size() == v2.Size());\n    EXPECT_STREQ(v1[1].GetString(), v2[1].GetString());\n    EXPECT_NE(v1[1].GetString(), v2[1].GetString()); // string got copied\n}\n\nTEST(Value, CopyFrom) {\n    TestCopyFrom<Value>();\n    TestCopyFrom<GenericValue<UTF8<>, CrtAllocator> >();\n}\n\nTEST(Value, Swap) {\n    Value v1(1234);\n    Value v2(kObjectType);\n\n    EXPECT_EQ(&v1, &v1.Swap(v2));\n    EXPECT_TRUE(v1.IsObject());\n    EXPECT_TRUE(v2.IsInt());\n    EXPECT_EQ(1234, v2.GetInt());\n\n    // testing std::swap compatibility\n    using std::swap;\n    swap(v1, v2);\n    EXPECT_TRUE(v1.IsInt());\n    EXPECT_TRUE(v2.IsObject());\n}\n\nTEST(Value, Null) {\n    // Default constructor\n    Value x;\n    EXPECT_EQ(kNullType, x.GetType());\n    EXPECT_TRUE(x.IsNull());\n\n    EXPECT_FALSE(x.IsTrue());\n    EXPECT_FALSE(x.IsFalse());\n    EXPECT_FALSE(x.IsNumber());\n    EXPECT_FALSE(x.IsString());\n    EXPECT_FALSE(x.IsObject());\n    EXPECT_FALSE(x.IsArray());\n\n    // Constructor with type\n    Value y(kNullType);\n    EXPECT_TRUE(y.IsNull());\n\n    // SetNull();\n    Value z(true);\n    z.SetNull();\n    EXPECT_TRUE(z.IsNull());\n}\n\nTEST(Value, True) {\n    // Constructor with bool\n    Value x(true);\n    EXPECT_EQ(kTrueType, x.GetType());\n    EXPECT_TRUE(x.GetBool());\n    EXPECT_TRUE(x.IsBool());\n    EXPECT_TRUE(x.IsTrue());\n\n    EXPECT_FALSE(x.IsNull());\n    EXPECT_FALSE(x.IsFalse());\n    EXPECT_FALSE(x.IsNumber());\n    EXPECT_FALSE(x.IsString());\n    EXPECT_FALSE(x.IsObject());\n    EXPECT_FALSE(x.IsArray());\n\n    // Constructor with type\n    Value y(kTrueType);\n    EXPECT_TRUE(y.IsTrue());\n\n    // SetBool()\n    Value z;\n    z.SetBool(true);\n    EXPECT_TRUE(z.IsTrue());\n\n    // Templated functions\n    EXPECT_TRUE(z.Is<bool>());\n    EXPECT_TRUE(z.Get<bool>());\n    EXPECT_FALSE(z.Set<bool>(false).Get<bool>());\n    EXPECT_TRUE(z.Set(true).Get<bool>());\n}\n\nTEST(Value, False) {\n    // Constructor with bool\n    Value x(false);\n    EXPECT_EQ(kFalseType, x.GetType());\n    EXPECT_TRUE(x.IsBool());\n    EXPECT_TRUE(x.IsFalse());\n\n    EXPECT_FALSE(x.IsNull());\n    EXPECT_FALSE(x.IsTrue());\n    EXPECT_FALSE(x.GetBool());\n    //EXPECT_FALSE((bool)x);\n    EXPECT_FALSE(x.IsNumber());\n    EXPECT_FALSE(x.IsString());\n    EXPECT_FALSE(x.IsObject());\n    EXPECT_FALSE(x.IsArray());\n\n    // Constructor with type\n    Value y(kFalseType);\n    EXPECT_TRUE(y.IsFalse());\n\n    // SetBool()\n    Value z;\n    z.SetBool(false);\n    EXPECT_TRUE(z.IsFalse());\n}\n\nTEST(Value, Int) {\n    // Constructor with int\n    Value x(1234);\n    EXPECT_EQ(kNumberType, x.GetType());\n    EXPECT_EQ(1234, x.GetInt());\n    EXPECT_EQ(1234u, x.GetUint());\n    EXPECT_EQ(1234, x.GetInt64());\n    EXPECT_EQ(1234u, x.GetUint64());\n    EXPECT_NEAR(1234.0, x.GetDouble(), 0.0);\n    //EXPECT_EQ(1234, (int)x);\n    //EXPECT_EQ(1234, (unsigned)x);\n    //EXPECT_EQ(1234, (int64_t)x);\n    //EXPECT_EQ(1234, (uint64_t)x);\n    //EXPECT_EQ(1234, (double)x);\n    EXPECT_TRUE(x.IsNumber());\n    EXPECT_TRUE(x.IsInt());\n    EXPECT_TRUE(x.IsUint());\n    EXPECT_TRUE(x.IsInt64());\n    EXPECT_TRUE(x.IsUint64());\n\n    EXPECT_FALSE(x.IsDouble());\n    EXPECT_FALSE(x.IsFloat());\n    EXPECT_FALSE(x.IsNull());\n    EXPECT_FALSE(x.IsBool());\n    EXPECT_FALSE(x.IsFalse());\n    EXPECT_FALSE(x.IsTrue());\n    EXPECT_FALSE(x.IsString());\n    EXPECT_FALSE(x.IsObject());\n    EXPECT_FALSE(x.IsArray());\n\n    Value nx(-1234);\n    EXPECT_EQ(-1234, nx.GetInt());\n    EXPECT_EQ(-1234, nx.GetInt64());\n    EXPECT_TRUE(nx.IsInt());\n    EXPECT_TRUE(nx.IsInt64());\n    EXPECT_FALSE(nx.IsUint());\n    EXPECT_FALSE(nx.IsUint64());\n\n    // Constructor with type\n    Value y(kNumberType);\n    EXPECT_TRUE(y.IsNumber());\n    EXPECT_TRUE(y.IsInt());\n    EXPECT_EQ(0, y.GetInt());\n\n    // SetInt()\n    Value z;\n    z.SetInt(1234);\n    EXPECT_EQ(1234, z.GetInt());\n\n    // operator=(int)\n    z = 5678;\n    EXPECT_EQ(5678, z.GetInt());\n\n    // Templated functions\n    EXPECT_TRUE(z.Is<int>());\n    EXPECT_EQ(5678, z.Get<int>());\n    EXPECT_EQ(5679, z.Set(5679).Get<int>());\n    EXPECT_EQ(5680, z.Set<int>(5680).Get<int>());\n}\n\nTEST(Value, Uint) {\n    // Constructor with int\n    Value x(1234u);\n    EXPECT_EQ(kNumberType, x.GetType());\n    EXPECT_EQ(1234, x.GetInt());\n    EXPECT_EQ(1234u, x.GetUint());\n    EXPECT_EQ(1234, x.GetInt64());\n    EXPECT_EQ(1234u, x.GetUint64());\n    EXPECT_TRUE(x.IsNumber());\n    EXPECT_TRUE(x.IsInt());\n    EXPECT_TRUE(x.IsUint());\n    EXPECT_TRUE(x.IsInt64());\n    EXPECT_TRUE(x.IsUint64());\n    EXPECT_NEAR(1234.0, x.GetDouble(), 0.0);   // Number can always be cast as double but !IsDouble().\n\n    EXPECT_FALSE(x.IsDouble());\n    EXPECT_FALSE(x.IsFloat());\n    EXPECT_FALSE(x.IsNull());\n    EXPECT_FALSE(x.IsBool());\n    EXPECT_FALSE(x.IsFalse());\n    EXPECT_FALSE(x.IsTrue());\n    EXPECT_FALSE(x.IsString());\n    EXPECT_FALSE(x.IsObject());\n    EXPECT_FALSE(x.IsArray());\n\n    // SetUint()\n    Value z;\n    z.SetUint(1234);\n    EXPECT_EQ(1234u, z.GetUint());\n\n    // operator=(unsigned)\n    z = 5678u;\n    EXPECT_EQ(5678u, z.GetUint());\n\n    z = 2147483648u;    // 2^31, cannot cast as int\n    EXPECT_EQ(2147483648u, z.GetUint());\n    EXPECT_FALSE(z.IsInt());\n    EXPECT_TRUE(z.IsInt64());   // Issue 41: Incorrect parsing of unsigned int number types\n\n    // Templated functions\n    EXPECT_TRUE(z.Is<unsigned>());\n    EXPECT_EQ(2147483648u, z.Get<unsigned>());\n    EXPECT_EQ(2147483649u, z.Set(2147483649u).Get<unsigned>());\n    EXPECT_EQ(2147483650u, z.Set<unsigned>(2147483650u).Get<unsigned>());\n}\n\nTEST(Value, Int64) {\n    // Constructor with int\n    Value x(int64_t(1234));\n    EXPECT_EQ(kNumberType, x.GetType());\n    EXPECT_EQ(1234, x.GetInt());\n    EXPECT_EQ(1234u, x.GetUint());\n    EXPECT_EQ(1234, x.GetInt64());\n    EXPECT_EQ(1234u, x.GetUint64());\n    EXPECT_TRUE(x.IsNumber());\n    EXPECT_TRUE(x.IsInt());\n    EXPECT_TRUE(x.IsUint());\n    EXPECT_TRUE(x.IsInt64());\n    EXPECT_TRUE(x.IsUint64());\n\n    EXPECT_FALSE(x.IsDouble());\n    EXPECT_FALSE(x.IsFloat());\n    EXPECT_FALSE(x.IsNull());\n    EXPECT_FALSE(x.IsBool());\n    EXPECT_FALSE(x.IsFalse());\n    EXPECT_FALSE(x.IsTrue());\n    EXPECT_FALSE(x.IsString());\n    EXPECT_FALSE(x.IsObject());\n    EXPECT_FALSE(x.IsArray());\n\n    Value nx(int64_t(-1234));\n    EXPECT_EQ(-1234, nx.GetInt());\n    EXPECT_EQ(-1234, nx.GetInt64());\n    EXPECT_TRUE(nx.IsInt());\n    EXPECT_TRUE(nx.IsInt64());\n    EXPECT_FALSE(nx.IsUint());\n    EXPECT_FALSE(nx.IsUint64());\n\n    // SetInt64()\n    Value z;\n    z.SetInt64(1234);\n    EXPECT_EQ(1234, z.GetInt64());\n\n    z.SetInt64(2147483648u);   // 2^31, cannot cast as int\n    EXPECT_FALSE(z.IsInt());\n    EXPECT_TRUE(z.IsUint());\n    EXPECT_NEAR(2147483648.0, z.GetDouble(), 0.0);\n\n    z.SetInt64(int64_t(4294967295u) + 1);   // 2^32, cannot cast as uint\n    EXPECT_FALSE(z.IsInt());\n    EXPECT_FALSE(z.IsUint());\n    EXPECT_NEAR(4294967296.0, z.GetDouble(), 0.0);\n\n    z.SetInt64(-int64_t(2147483648u) - 1);   // -2^31-1, cannot cast as int\n    EXPECT_FALSE(z.IsInt());\n    EXPECT_NEAR(-2147483649.0, z.GetDouble(), 0.0);\n\n    int64_t i = static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x80000000, 00000000));\n    z.SetInt64(i);\n    EXPECT_DOUBLE_EQ(-9223372036854775808.0, z.GetDouble());\n\n    // Templated functions\n    EXPECT_TRUE(z.Is<int64_t>());\n    EXPECT_EQ(i, z.Get<int64_t>());\n#if 0 // signed integer underflow is undefined behaviour\n    EXPECT_EQ(i - 1, z.Set(i - 1).Get<int64_t>());\n    EXPECT_EQ(i - 2, z.Set<int64_t>(i - 2).Get<int64_t>());\n#endif\n}\n\nTEST(Value, Uint64) {\n    // Constructor with int\n    Value x(uint64_t(1234));\n    EXPECT_EQ(kNumberType, x.GetType());\n    EXPECT_EQ(1234, x.GetInt());\n    EXPECT_EQ(1234u, x.GetUint());\n    EXPECT_EQ(1234, x.GetInt64());\n    EXPECT_EQ(1234u, x.GetUint64());\n    EXPECT_TRUE(x.IsNumber());\n    EXPECT_TRUE(x.IsInt());\n    EXPECT_TRUE(x.IsUint());\n    EXPECT_TRUE(x.IsInt64());\n    EXPECT_TRUE(x.IsUint64());\n\n    EXPECT_FALSE(x.IsDouble());\n    EXPECT_FALSE(x.IsFloat());\n    EXPECT_FALSE(x.IsNull());\n    EXPECT_FALSE(x.IsBool());\n    EXPECT_FALSE(x.IsFalse());\n    EXPECT_FALSE(x.IsTrue());\n    EXPECT_FALSE(x.IsString());\n    EXPECT_FALSE(x.IsObject());\n    EXPECT_FALSE(x.IsArray());\n\n    // SetUint64()\n    Value z;\n    z.SetUint64(1234);\n    EXPECT_EQ(1234u, z.GetUint64());\n\n    z.SetUint64(uint64_t(2147483648u));  // 2^31, cannot cast as int\n    EXPECT_FALSE(z.IsInt());\n    EXPECT_TRUE(z.IsUint());\n    EXPECT_TRUE(z.IsInt64());\n\n    z.SetUint64(uint64_t(4294967295u) + 1);  // 2^32, cannot cast as uint\n    EXPECT_FALSE(z.IsInt());\n    EXPECT_FALSE(z.IsUint());\n    EXPECT_TRUE(z.IsInt64());\n\n    uint64_t u = RAPIDJSON_UINT64_C2(0x80000000, 0x00000000);\n    z.SetUint64(u);    // 2^63 cannot cast as int64\n    EXPECT_FALSE(z.IsInt64());\n    EXPECT_EQ(u, z.GetUint64()); // Issue 48\n    EXPECT_DOUBLE_EQ(9223372036854775808.0, z.GetDouble());\n\n    // Templated functions\n    EXPECT_TRUE(z.Is<uint64_t>());\n    EXPECT_EQ(u, z.Get<uint64_t>());\n    EXPECT_EQ(u + 1, z.Set(u + 1).Get<uint64_t>());\n    EXPECT_EQ(u + 2, z.Set<uint64_t>(u + 2).Get<uint64_t>());\n}\n\nTEST(Value, Double) {\n    // Constructor with double\n    Value x(12.34);\n    EXPECT_EQ(kNumberType, x.GetType());\n    EXPECT_NEAR(12.34, x.GetDouble(), 0.0);\n    EXPECT_TRUE(x.IsNumber());\n    EXPECT_TRUE(x.IsDouble());\n\n    EXPECT_FALSE(x.IsInt());\n    EXPECT_FALSE(x.IsNull());\n    EXPECT_FALSE(x.IsBool());\n    EXPECT_FALSE(x.IsFalse());\n    EXPECT_FALSE(x.IsTrue());\n    EXPECT_FALSE(x.IsString());\n    EXPECT_FALSE(x.IsObject());\n    EXPECT_FALSE(x.IsArray());\n\n    // SetDouble()\n    Value z;\n    z.SetDouble(12.34);\n    EXPECT_NEAR(12.34, z.GetDouble(), 0.0);\n\n    z = 56.78;\n    EXPECT_NEAR(56.78, z.GetDouble(), 0.0);\n\n    // Templated functions\n    EXPECT_TRUE(z.Is<double>());\n    EXPECT_EQ(56.78, z.Get<double>());\n    EXPECT_EQ(57.78, z.Set(57.78).Get<double>());\n    EXPECT_EQ(58.78, z.Set<double>(58.78).Get<double>());\n}\n\nTEST(Value, Float) {\n    // Constructor with double\n    Value x(12.34f);\n    EXPECT_EQ(kNumberType, x.GetType());\n    EXPECT_NEAR(12.34f, x.GetFloat(), 0.0);\n    EXPECT_TRUE(x.IsNumber());\n    EXPECT_TRUE(x.IsDouble());\n    EXPECT_TRUE(x.IsFloat());\n\n    EXPECT_FALSE(x.IsInt());\n    EXPECT_FALSE(x.IsNull());\n    EXPECT_FALSE(x.IsBool());\n    EXPECT_FALSE(x.IsFalse());\n    EXPECT_FALSE(x.IsTrue());\n    EXPECT_FALSE(x.IsString());\n    EXPECT_FALSE(x.IsObject());\n    EXPECT_FALSE(x.IsArray());\n\n    // SetFloat()\n    Value z;\n    z.SetFloat(12.34f);\n    EXPECT_NEAR(12.34f, z.GetFloat(), 0.0f);\n\n    // Issue 573\n    z.SetInt(0);\n    EXPECT_EQ(0.0f, z.GetFloat());\n\n    z = 56.78f;\n    EXPECT_NEAR(56.78f, z.GetFloat(), 0.0f);\n\n    // Templated functions\n    EXPECT_TRUE(z.Is<float>());\n    EXPECT_EQ(56.78f, z.Get<float>());\n    EXPECT_EQ(57.78f, z.Set(57.78f).Get<float>());\n    EXPECT_EQ(58.78f, z.Set<float>(58.78f).Get<float>());\n}\n\nTEST(Value, IsLosslessDouble) {\n    EXPECT_TRUE(Value(0.0).IsLosslessDouble());\n    EXPECT_TRUE(Value(12.34).IsLosslessDouble());\n    EXPECT_TRUE(Value(-123).IsLosslessDouble());\n    EXPECT_TRUE(Value(2147483648u).IsLosslessDouble());\n    EXPECT_TRUE(Value(-static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x40000000, 0x00000000))).IsLosslessDouble());\n#if !(defined(_MSC_VER) && _MSC_VER < 1800) // VC2010 has problem\n    EXPECT_TRUE(Value(RAPIDJSON_UINT64_C2(0xA0000000, 0x00000000)).IsLosslessDouble());\n#endif\n\n    EXPECT_FALSE(Value(static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x7FFFFFFF, 0xFFFFFFFF))).IsLosslessDouble()); // INT64_MAX\n    EXPECT_FALSE(Value(-static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x7FFFFFFF, 0xFFFFFFFF))).IsLosslessDouble()); // -INT64_MAX\n    EXPECT_TRUE(Value(-static_cast<int64_t>(RAPIDJSON_UINT64_C2(0x7FFFFFFF, 0xFFFFFFFF)) - 1).IsLosslessDouble()); // INT64_MIN\n    EXPECT_FALSE(Value(RAPIDJSON_UINT64_C2(0xFFFFFFFF, 0xFFFFFFFF)).IsLosslessDouble()); // UINT64_MAX\n\n    EXPECT_TRUE(Value(3.4028234e38f).IsLosslessDouble()); // FLT_MAX\n    EXPECT_TRUE(Value(-3.4028234e38f).IsLosslessDouble()); // -FLT_MAX\n    EXPECT_TRUE(Value(1.17549435e-38f).IsLosslessDouble()); // FLT_MIN\n    EXPECT_TRUE(Value(-1.17549435e-38f).IsLosslessDouble()); // -FLT_MIN\n    EXPECT_TRUE(Value(1.7976931348623157e+308).IsLosslessDouble()); // DBL_MAX\n    EXPECT_TRUE(Value(-1.7976931348623157e+308).IsLosslessDouble()); // -DBL_MAX\n    EXPECT_TRUE(Value(2.2250738585072014e-308).IsLosslessDouble()); // DBL_MIN\n    EXPECT_TRUE(Value(-2.2250738585072014e-308).IsLosslessDouble()); // -DBL_MIN\n}\n\nTEST(Value, IsLosslessFloat) {\n    EXPECT_TRUE(Value(12.25).IsLosslessFloat());\n    EXPECT_TRUE(Value(-123).IsLosslessFloat());\n    EXPECT_TRUE(Value(2147483648u).IsLosslessFloat());\n    EXPECT_TRUE(Value(3.4028234e38f).IsLosslessFloat());\n    EXPECT_TRUE(Value(-3.4028234e38f).IsLosslessFloat());\n    EXPECT_FALSE(Value(3.4028235e38).IsLosslessFloat());\n    EXPECT_FALSE(Value(0.3).IsLosslessFloat());\n}\n\nTEST(Value, String) {\n    // Construction with const string\n    Value x(\"Hello\", 5); // literal\n    EXPECT_EQ(kStringType, x.GetType());\n    EXPECT_TRUE(x.IsString());\n    EXPECT_STREQ(\"Hello\", x.GetString());\n    EXPECT_EQ(5u, x.GetStringLength());\n\n    EXPECT_FALSE(x.IsNumber());\n    EXPECT_FALSE(x.IsNull());\n    EXPECT_FALSE(x.IsBool());\n    EXPECT_FALSE(x.IsFalse());\n    EXPECT_FALSE(x.IsTrue());\n    EXPECT_FALSE(x.IsObject());\n    EXPECT_FALSE(x.IsArray());\n\n    static const char cstr[] = \"World\"; // const array\n    Value(cstr).Swap(x);\n    EXPECT_TRUE(x.IsString());\n    EXPECT_EQ(x.GetString(), cstr);\n    EXPECT_EQ(x.GetStringLength(), sizeof(cstr)-1);\n\n    static char mstr[] = \"Howdy\"; // non-const array\n    // Value(mstr).Swap(x); // should not compile\n    Value(StringRef(mstr)).Swap(x);\n    EXPECT_TRUE(x.IsString());\n    EXPECT_EQ(x.GetString(), mstr);\n    EXPECT_EQ(x.GetStringLength(), sizeof(mstr)-1);\n    strncpy(mstr,\"Hello\", sizeof(mstr));\n    EXPECT_STREQ(x.GetString(), \"Hello\");\n\n    const char* pstr = cstr;\n    //Value(pstr).Swap(x); // should not compile\n    Value(StringRef(pstr)).Swap(x);\n    EXPECT_TRUE(x.IsString());\n    EXPECT_EQ(x.GetString(), cstr);\n    EXPECT_EQ(x.GetStringLength(), sizeof(cstr)-1);\n\n    char* mpstr = mstr;\n    Value(StringRef(mpstr,sizeof(mstr)-1)).Swap(x);\n    EXPECT_TRUE(x.IsString());\n    EXPECT_EQ(x.GetString(), mstr);\n    EXPECT_EQ(x.GetStringLength(), 5u);\n    EXPECT_STREQ(x.GetString(), \"Hello\");\n\n    // Constructor with copy string\n    MemoryPoolAllocator<> allocator;\n    Value c(x.GetString(), x.GetStringLength(), allocator);\n    EXPECT_NE(x.GetString(), c.GetString());\n    EXPECT_EQ(x.GetStringLength(), c.GetStringLength());\n    EXPECT_STREQ(x.GetString(), c.GetString());\n    //x.SetString(\"World\");\n    x.SetString(\"World\", 5);\n    EXPECT_STREQ(\"Hello\", c.GetString());\n    EXPECT_EQ(5u, c.GetStringLength());\n\n    // Constructor with type\n    Value y(kStringType);\n    EXPECT_TRUE(y.IsString());\n    EXPECT_STREQ(\"\", y.GetString());    // Empty string should be \"\" instead of 0 (issue 226)\n    EXPECT_EQ(0u, y.GetStringLength());\n\n    // SetConsttring()\n    Value z;\n    z.SetString(\"Hello\");\n    EXPECT_TRUE(x.IsString());\n    z.SetString(\"Hello\", 5);\n    EXPECT_STREQ(\"Hello\", z.GetString());\n    EXPECT_STREQ(\"Hello\", z.GetString());\n    EXPECT_EQ(5u, z.GetStringLength());\n\n    z.SetString(\"Hello\");\n    EXPECT_TRUE(z.IsString());\n    EXPECT_STREQ(\"Hello\", z.GetString());\n\n    //z.SetString(mstr); // should not compile\n    //z.SetString(pstr); // should not compile\n    z.SetString(StringRef(mstr));\n    EXPECT_TRUE(z.IsString());\n    EXPECT_STREQ(z.GetString(), mstr);\n\n    z.SetString(cstr);\n    EXPECT_TRUE(z.IsString());\n    EXPECT_EQ(cstr, z.GetString());\n\n    z = cstr;\n    EXPECT_TRUE(z.IsString());\n    EXPECT_EQ(cstr, z.GetString());\n\n    // SetString()\n    char s[] = \"World\";\n    Value w;\n    w.SetString(s, static_cast<SizeType>(strlen(s)), allocator);\n    s[0] = '\\0';\n    EXPECT_STREQ(\"World\", w.GetString());\n    EXPECT_EQ(5u, w.GetStringLength());\n\n    // templated functions\n    EXPECT_TRUE(z.Is<const char*>());\n    EXPECT_STREQ(cstr, z.Get<const char*>());\n    EXPECT_STREQ(\"Apple\", z.Set<const char*>(\"Apple\").Get<const char*>());\n\n#if RAPIDJSON_HAS_STDSTRING\n    {\n        std::string str = \"Hello World\";\n        str[5] = '\\0';\n        EXPECT_STREQ(str.data(),\"Hello\"); // embedded '\\0'\n        EXPECT_EQ(str.size(), 11u);\n\n        // no copy\n        Value vs0(StringRef(str));\n        EXPECT_TRUE(vs0.IsString());\n        EXPECT_EQ(vs0.GetString(), str.data());\n        EXPECT_EQ(vs0.GetStringLength(), str.size());\n        TestEqual(vs0, str);\n\n        // do copy\n        Value vs1(str, allocator);\n        EXPECT_TRUE(vs1.IsString());\n        EXPECT_NE(vs1.GetString(), str.data());\n        EXPECT_NE(vs1.GetString(), str); // not equal due to embedded '\\0'\n        EXPECT_EQ(vs1.GetStringLength(), str.size());\n        TestEqual(vs1, str);\n\n        // SetString\n        str = \"World\";\n        vs0.SetNull().SetString(str, allocator);\n        EXPECT_TRUE(vs0.IsString());\n        EXPECT_STREQ(vs0.GetString(), str.c_str());\n        EXPECT_EQ(vs0.GetStringLength(), str.size());\n        TestEqual(str, vs0);\n        TestUnequal(str, vs1);\n\n        // vs1 = str; // should not compile\n        vs1 = StringRef(str);\n        TestEqual(str, vs1);\n        TestEqual(vs0, vs1);\n\n        // Templated function.\n        EXPECT_TRUE(vs0.Is<std::string>());\n        EXPECT_EQ(str, vs0.Get<std::string>());\n        vs0.Set<std::string>(std::string(\"Apple\"), allocator);\n        EXPECT_EQ(std::string(\"Apple\"), vs0.Get<std::string>());\n        vs0.Set(std::string(\"Orange\"), allocator);\n        EXPECT_EQ(std::string(\"Orange\"), vs0.Get<std::string>());\n    }\n#endif // RAPIDJSON_HAS_STDSTRING\n}\n\n// Issue 226: Value of string type should not point to NULL\nTEST(Value, SetStringNullException) {\n    Value v;\n    EXPECT_THROW(v.SetString(0, 0), AssertException);\n}\n\ntemplate <typename T, typename Allocator>\nstatic void TestArray(T& x, Allocator& allocator) {\n    const T& y = x;\n\n    // PushBack()\n    Value v;\n    x.PushBack(v, allocator);\n    v.SetBool(true);\n    x.PushBack(v, allocator);\n    v.SetBool(false);\n    x.PushBack(v, allocator);\n    v.SetInt(123);\n    x.PushBack(v, allocator);\n    //x.PushBack((const char*)\"foo\", allocator); // should not compile\n    x.PushBack(\"foo\", allocator);\n\n    EXPECT_FALSE(x.Empty());\n    EXPECT_EQ(5u, x.Size());\n    EXPECT_FALSE(y.Empty());\n    EXPECT_EQ(5u, y.Size());\n    EXPECT_TRUE(x[SizeType(0)].IsNull());\n    EXPECT_TRUE(x[1].IsTrue());\n    EXPECT_TRUE(x[2].IsFalse());\n    EXPECT_TRUE(x[3].IsInt());\n    EXPECT_EQ(123, x[3].GetInt());\n    EXPECT_TRUE(y[SizeType(0)].IsNull());\n    EXPECT_TRUE(y[1].IsTrue());\n    EXPECT_TRUE(y[2].IsFalse());\n    EXPECT_TRUE(y[3].IsInt());\n    EXPECT_EQ(123, y[3].GetInt());\n    EXPECT_TRUE(y[4].IsString());\n    EXPECT_STREQ(\"foo\", y[4].GetString());\n\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\n    // PushBack(GenericValue&&, Allocator&);\n    {\n        Value y2(kArrayType);\n        y2.PushBack(Value(true), allocator);\n        y2.PushBack(std::move(Value(kArrayType).PushBack(Value(1), allocator).PushBack(\"foo\", allocator)), allocator);\n        EXPECT_EQ(2u, y2.Size());\n        EXPECT_TRUE(y2[0].IsTrue());\n        EXPECT_TRUE(y2[1].IsArray());\n        EXPECT_EQ(2u, y2[1].Size());\n        EXPECT_TRUE(y2[1][0].IsInt());\n        EXPECT_TRUE(y2[1][1].IsString());\n    }\n#endif\n\n    // iterator\n    typename T::ValueIterator itr = x.Begin();\n    EXPECT_TRUE(itr != x.End());\n    EXPECT_TRUE(itr->IsNull());\n    ++itr;\n    EXPECT_TRUE(itr != x.End());\n    EXPECT_TRUE(itr->IsTrue());\n    ++itr;\n    EXPECT_TRUE(itr != x.End());\n    EXPECT_TRUE(itr->IsFalse());\n    ++itr;\n    EXPECT_TRUE(itr != x.End());\n    EXPECT_TRUE(itr->IsInt());\n    EXPECT_EQ(123, itr->GetInt());\n    ++itr;\n    EXPECT_TRUE(itr != x.End());\n    EXPECT_TRUE(itr->IsString());\n    EXPECT_STREQ(\"foo\", itr->GetString());\n\n    // const iterator\n    typename T::ConstValueIterator citr = y.Begin();\n    EXPECT_TRUE(citr != y.End());\n    EXPECT_TRUE(citr->IsNull());\n    ++citr;\n    EXPECT_TRUE(citr != y.End());\n    EXPECT_TRUE(citr->IsTrue());\n    ++citr;\n    EXPECT_TRUE(citr != y.End());\n    EXPECT_TRUE(citr->IsFalse());\n    ++citr;\n    EXPECT_TRUE(citr != y.End());\n    EXPECT_TRUE(citr->IsInt());\n    EXPECT_EQ(123, citr->GetInt());\n    ++citr;\n    EXPECT_TRUE(citr != y.End());\n    EXPECT_TRUE(citr->IsString());\n    EXPECT_STREQ(\"foo\", citr->GetString());\n\n    // PopBack()\n    x.PopBack();\n    EXPECT_EQ(4u, x.Size());\n    EXPECT_TRUE(y[SizeType(0)].IsNull());\n    EXPECT_TRUE(y[1].IsTrue());\n    EXPECT_TRUE(y[2].IsFalse());\n    EXPECT_TRUE(y[3].IsInt());\n\n    // Clear()\n    x.Clear();\n    EXPECT_TRUE(x.Empty());\n    EXPECT_EQ(0u, x.Size());\n    EXPECT_TRUE(y.Empty());\n    EXPECT_EQ(0u, y.Size());\n\n    // Erase(ValueIterator)\n\n    // Use array of array to ensure removed elements' destructor is called.\n    // [[0],[1],[2],...]\n    for (int i = 0; i < 10; i++)\n        x.PushBack(Value(kArrayType).PushBack(i, allocator).Move(), allocator);\n\n    // Erase the first\n    itr = x.Erase(x.Begin());\n    EXPECT_EQ(x.Begin(), itr);\n    EXPECT_EQ(9u, x.Size());\n    for (int i = 0; i < 9; i++)\n        EXPECT_EQ(i + 1, x[static_cast<SizeType>(i)][0].GetInt());\n\n    // Ease the last\n    itr = x.Erase(x.End() - 1);\n    EXPECT_EQ(x.End(), itr);\n    EXPECT_EQ(8u, x.Size());\n    for (int i = 0; i < 8; i++)\n        EXPECT_EQ(i + 1, x[static_cast<SizeType>(i)][0].GetInt());\n\n    // Erase the middle\n    itr = x.Erase(x.Begin() + 4);\n    EXPECT_EQ(x.Begin() + 4, itr);\n    EXPECT_EQ(7u, x.Size());\n    for (int i = 0; i < 4; i++)\n        EXPECT_EQ(i + 1, x[static_cast<SizeType>(i)][0].GetInt());\n    for (int i = 4; i < 7; i++)\n        EXPECT_EQ(i + 2, x[static_cast<SizeType>(i)][0].GetInt());\n\n    // Erase(ValueIterator, ValueIterator)\n    // Exhaustive test with all 0 <= first < n, first <= last <= n cases\n    const unsigned n = 10;\n    for (unsigned first = 0; first < n; first++) {\n        for (unsigned last = first; last <= n; last++) {\n            x.Clear();\n            for (unsigned i = 0; i < n; i++)\n                x.PushBack(Value(kArrayType).PushBack(i, allocator).Move(), allocator);\n            \n            itr = x.Erase(x.Begin() + first, x.Begin() + last);\n            if (last == n)\n                EXPECT_EQ(x.End(), itr);\n            else\n                EXPECT_EQ(x.Begin() + first, itr);\n\n            size_t removeCount = last - first;\n            EXPECT_EQ(n - removeCount, x.Size());\n            for (unsigned i = 0; i < first; i++)\n                EXPECT_EQ(i, x[i][0].GetUint());\n            for (unsigned i = first; i < n - removeCount; i++)\n                EXPECT_EQ(i + removeCount, x[static_cast<SizeType>(i)][0].GetUint());\n        }\n    }\n}\n\nTEST(Value, Array) {\n    Value x(kArrayType);\n    const Value& y = x;\n    Value::AllocatorType allocator;\n\n    EXPECT_EQ(kArrayType, x.GetType());\n    EXPECT_TRUE(x.IsArray());\n    EXPECT_TRUE(x.Empty());\n    EXPECT_EQ(0u, x.Size());\n    EXPECT_TRUE(y.IsArray());\n    EXPECT_TRUE(y.Empty());\n    EXPECT_EQ(0u, y.Size());\n\n    EXPECT_FALSE(x.IsNull());\n    EXPECT_FALSE(x.IsBool());\n    EXPECT_FALSE(x.IsFalse());\n    EXPECT_FALSE(x.IsTrue());\n    EXPECT_FALSE(x.IsString());\n    EXPECT_FALSE(x.IsObject());\n\n    TestArray(x, allocator);\n\n    // Working in gcc without C++11, but VS2013 cannot compile. To be diagnosed.\n    // http://en.wikipedia.org/wiki/Erase-remove_idiom\n    x.Clear();\n    for (int i = 0; i < 10; i++)\n        if (i % 2 == 0)\n            x.PushBack(i, allocator);\n        else\n            x.PushBack(Value(kNullType).Move(), allocator);\n\n    const Value null(kNullType);\n    x.Erase(std::remove(x.Begin(), x.End(), null), x.End());\n    EXPECT_EQ(5u, x.Size());\n    for (int i = 0; i < 5; i++)\n        EXPECT_EQ(i * 2, x[static_cast<SizeType>(i)]);\n\n    // SetArray()\n    Value z;\n    z.SetArray();\n    EXPECT_TRUE(z.IsArray());\n    EXPECT_TRUE(z.Empty());\n}\n\nTEST(Value, ArrayHelper) {\n    Value::AllocatorType allocator;\n    {\n        Value x(kArrayType);\n        Value::Array a = x.GetArray();\n        TestArray(a, allocator);\n    }\n\n    {\n        Value x(kArrayType);\n        Value::Array a = x.GetArray();\n        a.PushBack(1, allocator);\n\n        Value::Array a2(a); // copy constructor\n        EXPECT_EQ(1, a2.Size());\n\n        Value::Array a3 = a;\n        EXPECT_EQ(1, a3.Size());\n\n        Value::ConstArray y = static_cast<const Value&>(x).GetArray();\n        (void)y;\n        // y.PushBack(1, allocator); // should not compile\n\n        // Templated functions\n        x.Clear();\n        EXPECT_TRUE(x.Is<Value::Array>());\n        EXPECT_TRUE(x.Is<Value::ConstArray>());\n        a.PushBack(1, allocator);\n        EXPECT_EQ(1, x.Get<Value::Array>()[0].GetInt());\n        EXPECT_EQ(1, x.Get<Value::ConstArray>()[0].GetInt());\n\n        Value x2;\n        x2.Set<Value::Array>(a);\n        EXPECT_TRUE(x.IsArray());   // IsArray() is invariant after moving.\n        EXPECT_EQ(1, x2.Get<Value::Array>()[0].GetInt());\n    }\n\n    {\n        Value y(kArrayType);\n        y.PushBack(123, allocator);\n\n        Value x(y.GetArray());      // Construct value form array.\n        EXPECT_TRUE(x.IsArray());\n        EXPECT_EQ(123, x[0].GetInt());\n        EXPECT_TRUE(y.IsArray());   // Invariant\n        EXPECT_TRUE(y.Empty());\n    }\n\n    {\n        Value x(kArrayType);\n        Value y(kArrayType);\n        y.PushBack(123, allocator);\n        x.PushBack(y.GetArray(), allocator);    // Implicit constructor to convert Array to GenericValue\n\n        EXPECT_EQ(1, x.Size());\n        EXPECT_EQ(123, x[0][0].GetInt());\n        EXPECT_TRUE(y.IsArray());\n        EXPECT_TRUE(y.Empty());\n    }\n}\n\n#if RAPIDJSON_HAS_CXX11_RANGE_FOR\nTEST(Value, ArrayHelperRangeFor) {\n    Value::AllocatorType allocator;\n    Value x(kArrayType);\n\n    for (int i = 0; i < 10; i++)\n        x.PushBack(i, allocator);\n\n    {\n        int i = 0;\n        for (auto& v : x.GetArray()) {\n            EXPECT_EQ(i, v.GetInt());\n            i++;\n        }\n        EXPECT_EQ(i, 10);\n    }\n    {\n        int i = 0;\n        for (const auto& v : const_cast<const Value&>(x).GetArray()) {\n            EXPECT_EQ(i, v.GetInt());\n            i++;\n        }\n        EXPECT_EQ(i, 10);\n    }\n\n    // Array a = x.GetArray();\n    // Array ca = const_cast<const Value&>(x).GetArray();\n}\n#endif\n\ntemplate <typename T, typename Allocator>\nstatic void TestObject(T& x, Allocator& allocator) {\n    const T& y = x; // const version\n\n    // AddMember()\n    x.AddMember(\"A\", \"Apple\", allocator);\n    EXPECT_FALSE(x.ObjectEmpty());\n    EXPECT_EQ(1u, x.MemberCount());\n\n    Value value(\"Banana\", 6);\n    x.AddMember(\"B\", \"Banana\", allocator);\n    EXPECT_EQ(2u, x.MemberCount());\n\n    // AddMember<T>(StringRefType, T, Allocator)\n    {\n        Value o(kObjectType);\n        o.AddMember(\"true\", true, allocator);\n        o.AddMember(\"false\", false, allocator);\n        o.AddMember(\"int\", -1, allocator);\n        o.AddMember(\"uint\", 1u, allocator);\n        o.AddMember(\"int64\", int64_t(-4294967296), allocator);\n        o.AddMember(\"uint64\", uint64_t(4294967296), allocator);\n        o.AddMember(\"double\", 3.14, allocator);\n        o.AddMember(\"string\", \"Jelly\", allocator);\n\n        EXPECT_TRUE(o[\"true\"].GetBool());\n        EXPECT_FALSE(o[\"false\"].GetBool());\n        EXPECT_EQ(-1, o[\"int\"].GetInt());\n        EXPECT_EQ(1u, o[\"uint\"].GetUint());\n        EXPECT_EQ(int64_t(-4294967296), o[\"int64\"].GetInt64());\n        EXPECT_EQ(uint64_t(4294967296), o[\"uint64\"].GetUint64());\n        EXPECT_STREQ(\"Jelly\",o[\"string\"].GetString());\n        EXPECT_EQ(8u, o.MemberCount());\n    }\n\n    // AddMember<T>(Value&, T, Allocator)\n    {\n        Value o(kObjectType);\n\n        Value n(\"s\");\n        o.AddMember(n, \"string\", allocator);\n        EXPECT_EQ(1u, o.MemberCount());\n\n        Value count(\"#\");\n        o.AddMember(count, o.MemberCount(), allocator);\n        EXPECT_EQ(2u, o.MemberCount());\n    }\n\n#if RAPIDJSON_HAS_STDSTRING\n    {\n        // AddMember(StringRefType, const std::string&, Allocator)\n        Value o(kObjectType);\n        o.AddMember(\"b\", std::string(\"Banana\"), allocator);\n        EXPECT_STREQ(\"Banana\", o[\"b\"].GetString());\n\n        // RemoveMember(const std::string&)\n        o.RemoveMember(std::string(\"b\"));\n        EXPECT_TRUE(o.ObjectEmpty());\n    }\n#endif\n\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\n    // AddMember(GenericValue&&, ...) variants\n    {\n        Value o(kObjectType);\n        o.AddMember(Value(\"true\"), Value(true), allocator);\n        o.AddMember(Value(\"false\"), Value(false).Move(), allocator);    // value is lvalue ref\n        o.AddMember(Value(\"int\").Move(), Value(-1), allocator);         // name is lvalue ref\n        o.AddMember(\"uint\", std::move(Value().SetUint(1u)), allocator); // name is literal, value is rvalue\n        EXPECT_TRUE(o[\"true\"].GetBool());\n        EXPECT_FALSE(o[\"false\"].GetBool());\n        EXPECT_EQ(-1, o[\"int\"].GetInt());\n        EXPECT_EQ(1u, o[\"uint\"].GetUint());\n        EXPECT_EQ(4u, o.MemberCount());\n    }\n#endif\n\n    // Tests a member with null character\n    Value name;\n    const Value C0D(\"C\\0D\", 3);\n    name.SetString(C0D.GetString(), 3);\n    value.SetString(\"CherryD\", 7);\n    x.AddMember(name, value, allocator);\n\n    // HasMember()\n    EXPECT_TRUE(x.HasMember(\"A\"));\n    EXPECT_TRUE(x.HasMember(\"B\"));\n    EXPECT_TRUE(y.HasMember(\"A\"));\n    EXPECT_TRUE(y.HasMember(\"B\"));\n\n#if RAPIDJSON_HAS_STDSTRING\n    EXPECT_TRUE(x.HasMember(std::string(\"A\")));\n#endif\n\n    name.SetString(\"C\\0D\");\n    EXPECT_TRUE(x.HasMember(name));\n    EXPECT_TRUE(y.HasMember(name));\n\n    GenericValue<UTF8<>, CrtAllocator> othername(\"A\");\n    EXPECT_TRUE(x.HasMember(othername));\n    EXPECT_TRUE(y.HasMember(othername));\n    othername.SetString(\"C\\0D\");\n    EXPECT_TRUE(x.HasMember(othername));\n    EXPECT_TRUE(y.HasMember(othername));\n\n    // operator[]\n    EXPECT_STREQ(\"Apple\", x[\"A\"].GetString());\n    EXPECT_STREQ(\"Banana\", x[\"B\"].GetString());\n    EXPECT_STREQ(\"CherryD\", x[C0D].GetString());\n    EXPECT_STREQ(\"CherryD\", x[othername].GetString());\n    EXPECT_THROW(x[\"nonexist\"], AssertException);\n\n    // const operator[]\n    EXPECT_STREQ(\"Apple\", y[\"A\"].GetString());\n    EXPECT_STREQ(\"Banana\", y[\"B\"].GetString());\n    EXPECT_STREQ(\"CherryD\", y[C0D].GetString());\n\n#if RAPIDJSON_HAS_STDSTRING\n    EXPECT_STREQ(\"Apple\", x[\"A\"].GetString());\n    EXPECT_STREQ(\"Apple\", y[std::string(\"A\")].GetString());\n#endif\n\n    // member iterator\n    Value::MemberIterator itr = x.MemberBegin(); \n    EXPECT_TRUE(itr != x.MemberEnd());\n    EXPECT_STREQ(\"A\", itr->name.GetString());\n    EXPECT_STREQ(\"Apple\", itr->value.GetString());\n    ++itr;\n    EXPECT_TRUE(itr != x.MemberEnd());\n    EXPECT_STREQ(\"B\", itr->name.GetString());\n    EXPECT_STREQ(\"Banana\", itr->value.GetString());\n    ++itr;\n    EXPECT_TRUE(itr != x.MemberEnd());\n    EXPECT_TRUE(memcmp(itr->name.GetString(), \"C\\0D\", 4) == 0);\n    EXPECT_STREQ(\"CherryD\", itr->value.GetString());\n    ++itr;\n    EXPECT_FALSE(itr != x.MemberEnd());\n\n    // const member iterator\n    Value::ConstMemberIterator citr = y.MemberBegin(); \n    EXPECT_TRUE(citr != y.MemberEnd());\n    EXPECT_STREQ(\"A\", citr->name.GetString());\n    EXPECT_STREQ(\"Apple\", citr->value.GetString());\n    ++citr;\n    EXPECT_TRUE(citr != y.MemberEnd());\n    EXPECT_STREQ(\"B\", citr->name.GetString());\n    EXPECT_STREQ(\"Banana\", citr->value.GetString());\n    ++citr;\n    EXPECT_TRUE(citr != y.MemberEnd());\n    EXPECT_TRUE(memcmp(citr->name.GetString(), \"C\\0D\", 4) == 0);\n    EXPECT_STREQ(\"CherryD\", citr->value.GetString());\n    ++citr;\n    EXPECT_FALSE(citr != y.MemberEnd());\n\n    // member iterator conversions/relations\n    itr  = x.MemberBegin();\n    citr = x.MemberBegin(); // const conversion\n    TestEqual(itr, citr);\n    EXPECT_TRUE(itr < x.MemberEnd());\n    EXPECT_FALSE(itr > y.MemberEnd());\n    EXPECT_TRUE(citr < x.MemberEnd());\n    EXPECT_FALSE(citr > y.MemberEnd());\n    ++citr;\n    TestUnequal(itr, citr);\n    EXPECT_FALSE(itr < itr);\n    EXPECT_TRUE(itr < citr);\n    EXPECT_FALSE(itr > itr);\n    EXPECT_TRUE(citr > itr);\n    EXPECT_EQ(1, citr - x.MemberBegin());\n    EXPECT_EQ(0, itr - y.MemberBegin());\n    itr += citr - x.MemberBegin();\n    EXPECT_EQ(1, itr - y.MemberBegin());\n    TestEqual(citr, itr);\n    EXPECT_TRUE(itr <= citr);\n    EXPECT_TRUE(citr <= itr);\n    itr++;\n    EXPECT_TRUE(itr >= citr);\n    EXPECT_FALSE(citr >= itr);\n\n    // RemoveMember()\n    EXPECT_TRUE(x.RemoveMember(\"A\"));\n    EXPECT_FALSE(x.HasMember(\"A\"));\n\n    EXPECT_TRUE(x.RemoveMember(\"B\"));\n    EXPECT_FALSE(x.HasMember(\"B\"));\n\n    EXPECT_FALSE(x.RemoveMember(\"nonexist\"));\n\n    EXPECT_TRUE(x.RemoveMember(othername));\n    EXPECT_FALSE(x.HasMember(name));\n\n    EXPECT_TRUE(x.MemberBegin() == x.MemberEnd());\n\n    // EraseMember(ConstMemberIterator)\n\n    // Use array members to ensure removed elements' destructor is called.\n    // { \"a\": [0], \"b\": [1],[2],...]\n    const char keys[][2] = { \"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\" };\n    for (int i = 0; i < 10; i++)\n        x.AddMember(keys[i], Value(kArrayType).PushBack(i, allocator), allocator);\n\n    // MemberCount, iterator difference\n    EXPECT_EQ(x.MemberCount(), SizeType(x.MemberEnd() - x.MemberBegin()));\n\n    // Erase the first\n    itr = x.EraseMember(x.MemberBegin());\n    EXPECT_FALSE(x.HasMember(keys[0]));\n    EXPECT_EQ(x.MemberBegin(), itr);\n    EXPECT_EQ(9u, x.MemberCount());\n    for (; itr != x.MemberEnd(); ++itr) {\n        size_t i = static_cast<size_t>((itr - x.MemberBegin())) + 1;\n        EXPECT_STREQ(itr->name.GetString(), keys[i]);\n        EXPECT_EQ(i, itr->value[0].GetInt());\n    }\n\n    // Erase the last\n    itr = x.EraseMember(x.MemberEnd() - 1);\n    EXPECT_FALSE(x.HasMember(keys[9]));\n    EXPECT_EQ(x.MemberEnd(), itr);\n    EXPECT_EQ(8u, x.MemberCount());\n    for (; itr != x.MemberEnd(); ++itr) {\n        size_t i = static_cast<size_t>(itr - x.MemberBegin()) + 1;\n        EXPECT_STREQ(itr->name.GetString(), keys[i]);\n        EXPECT_EQ(i, itr->value[0].GetInt());\n    }\n\n    // Erase the middle\n    itr = x.EraseMember(x.MemberBegin() + 4);\n    EXPECT_FALSE(x.HasMember(keys[5]));\n    EXPECT_EQ(x.MemberBegin() + 4, itr);\n    EXPECT_EQ(7u, x.MemberCount());\n    for (; itr != x.MemberEnd(); ++itr) {\n        size_t i = static_cast<size_t>(itr - x.MemberBegin());\n        i += (i < 4) ? 1 : 2;\n        EXPECT_STREQ(itr->name.GetString(), keys[i]);\n        EXPECT_EQ(i, itr->value[0].GetInt());\n    }\n\n    // EraseMember(ConstMemberIterator, ConstMemberIterator)\n    // Exhaustive test with all 0 <= first < n, first <= last <= n cases\n    const unsigned n = 10;\n    for (unsigned first = 0; first < n; first++) {\n        for (unsigned last = first; last <= n; last++) {\n            x.RemoveAllMembers();\n            for (unsigned i = 0; i < n; i++)\n                x.AddMember(keys[i], Value(kArrayType).PushBack(i, allocator), allocator);\n\n            itr = x.EraseMember(x.MemberBegin() + static_cast<int>(first), x.MemberBegin() + static_cast<int>(last));\n            if (last == n)\n                EXPECT_EQ(x.MemberEnd(), itr);\n            else\n                EXPECT_EQ(x.MemberBegin() + static_cast<int>(first), itr);\n\n            size_t removeCount = last - first;\n            EXPECT_EQ(n - removeCount, x.MemberCount());\n            for (unsigned i = 0; i < first; i++)\n                EXPECT_EQ(i, x[keys[i]][0].GetUint());\n            for (unsigned i = first; i < n - removeCount; i++)\n                EXPECT_EQ(i + removeCount, x[keys[i+removeCount]][0].GetUint());\n        }\n    }\n\n    // RemoveAllMembers()\n    x.RemoveAllMembers();\n    EXPECT_TRUE(x.ObjectEmpty());\n    EXPECT_EQ(0u, x.MemberCount());\n}\n\nTEST(Value, Object) {\n    Value x(kObjectType);\n    const Value& y = x; // const version\n    Value::AllocatorType allocator;\n\n    EXPECT_EQ(kObjectType, x.GetType());\n    EXPECT_TRUE(x.IsObject());\n    EXPECT_TRUE(x.ObjectEmpty());\n    EXPECT_EQ(0u, x.MemberCount());\n    EXPECT_EQ(kObjectType, y.GetType());\n    EXPECT_TRUE(y.IsObject());\n    EXPECT_TRUE(y.ObjectEmpty());\n    EXPECT_EQ(0u, y.MemberCount());\n\n    TestObject(x, allocator);\n\n    // SetObject()\n    Value z;\n    z.SetObject();\n    EXPECT_TRUE(z.IsObject());\n}\n\nTEST(Value, ObjectHelper) {\n    Value::AllocatorType allocator;\n    {\n        Value x(kObjectType);\n        Value::Object o = x.GetObject();\n        TestObject(o, allocator);\n    }\n\n    {\n        Value x(kObjectType);\n        Value::Object o = x.GetObject();\n        o.AddMember(\"1\", 1, allocator);\n\n        Value::Object o2(o); // copy constructor\n        EXPECT_EQ(1, o2.MemberCount());\n\n        Value::Object o3 = o;\n        EXPECT_EQ(1, o3.MemberCount());\n\n        Value::ConstObject y = static_cast<const Value&>(x).GetObject();\n        (void)y;\n        // y.AddMember(\"1\", 1, allocator); // should not compile\n\n        // Templated functions\n        x.RemoveAllMembers();\n        EXPECT_TRUE(x.Is<Value::Object>());\n        EXPECT_TRUE(x.Is<Value::ConstObject>());\n        o.AddMember(\"1\", 1, allocator);\n        EXPECT_EQ(1, x.Get<Value::Object>()[\"1\"].GetInt());\n        EXPECT_EQ(1, x.Get<Value::ConstObject>()[\"1\"].GetInt());\n\n        Value x2;\n        x2.Set<Value::Object>(o);\n        EXPECT_TRUE(x.IsObject());   // IsObject() is invariant after moving\n        EXPECT_EQ(1, x2.Get<Value::Object>()[\"1\"].GetInt());\n    }\n\n    {\n        Value x(kObjectType);\n        x.AddMember(\"a\", \"apple\", allocator);\n        Value y(x.GetObject());\n        EXPECT_STREQ(\"apple\", y[\"a\"].GetString());\n        EXPECT_TRUE(x.IsObject());  // Invariant\n    }\n    \n    {\n        Value x(kObjectType);\n        x.AddMember(\"a\", \"apple\", allocator);\n        Value y(kObjectType);\n        y.AddMember(\"fruits\", x.GetObject(), allocator);\n        EXPECT_STREQ(\"apple\", y[\"fruits\"][\"a\"].GetString());\n        EXPECT_TRUE(x.IsObject());  // Invariant\n    }\n}\n\n#if RAPIDJSON_HAS_CXX11_RANGE_FOR\nTEST(Value, ObjectHelperRangeFor) {\n    Value::AllocatorType allocator;\n    Value x(kObjectType);\n\n    for (int i = 0; i < 10; i++) {\n        char name[10];\n        Value n(name, static_cast<SizeType>(sprintf(name, \"%d\", i)), allocator);\n        x.AddMember(n, i, allocator);\n    }\n\n    {\n        int i = 0;\n        for (auto& m : x.GetObject()) {\n            char name[10];\n            sprintf(name, \"%d\", i);\n            EXPECT_STREQ(name, m.name.GetString());\n            EXPECT_EQ(i, m.value.GetInt());\n            i++;\n        }\n        EXPECT_EQ(i, 10);\n    }\n    {\n        int i = 0;\n        for (const auto& m : const_cast<const Value&>(x).GetObject()) {\n            char name[10];\n            sprintf(name, \"%d\", i);\n            EXPECT_STREQ(name, m.name.GetString());\n            EXPECT_EQ(i, m.value.GetInt());\n            i++;\n        }\n        EXPECT_EQ(i, 10);\n    }\n\n    // Object a = x.GetObject();\n    // Object ca = const_cast<const Value&>(x).GetObject();\n}\n#endif\n\nTEST(Value, EraseMember_String) {\n    Value::AllocatorType allocator;\n    Value x(kObjectType);\n    x.AddMember(\"A\", \"Apple\", allocator);\n    x.AddMember(\"B\", \"Banana\", allocator);\n\n    EXPECT_TRUE(x.EraseMember(\"B\"));\n    EXPECT_FALSE(x.HasMember(\"B\"));\n\n    EXPECT_FALSE(x.EraseMember(\"nonexist\"));\n\n    GenericValue<UTF8<>, CrtAllocator> othername(\"A\");\n    EXPECT_TRUE(x.EraseMember(othername));\n    EXPECT_FALSE(x.HasMember(\"A\"));\n\n    EXPECT_TRUE(x.MemberBegin() == x.MemberEnd());\n}\n\nTEST(Value, BigNestedArray) {\n    MemoryPoolAllocator<> allocator;\n    Value x(kArrayType);\n    static const SizeType  n = 200;\n\n    for (SizeType i = 0; i < n; i++) {\n        Value y(kArrayType);\n        for (SizeType  j = 0; j < n; j++) {\n            Value number(static_cast<int>(i * n + j));\n            y.PushBack(number, allocator);\n        }\n        x.PushBack(y, allocator);\n    }\n\n    for (SizeType i = 0; i < n; i++)\n        for (SizeType j = 0; j < n; j++) {\n            EXPECT_TRUE(x[i][j].IsInt());\n            EXPECT_EQ(static_cast<int>(i * n + j), x[i][j].GetInt());\n        }\n}\n\nTEST(Value, BigNestedObject) {\n    MemoryPoolAllocator<> allocator;\n    Value x(kObjectType);\n    static const SizeType n = 200;\n\n    for (SizeType i = 0; i < n; i++) {\n        char name1[10];\n        sprintf(name1, \"%d\", i);\n\n        // Value name(name1); // should not compile\n        Value name(name1, static_cast<SizeType>(strlen(name1)), allocator);\n        Value object(kObjectType);\n\n        for (SizeType j = 0; j < n; j++) {\n            char name2[10];\n            sprintf(name2, \"%d\", j);\n\n            Value name3(name2, static_cast<SizeType>(strlen(name2)), allocator);\n            Value number(static_cast<int>(i * n + j));\n            object.AddMember(name3, number, allocator);\n        }\n\n        // x.AddMember(name1, object, allocator); // should not compile\n        x.AddMember(name, object, allocator);\n    }\n\n    for (SizeType i = 0; i < n; i++) {\n        char name1[10];\n        sprintf(name1, \"%d\", i);\n        \n        for (SizeType j = 0; j < n; j++) {\n            char name2[10];\n            sprintf(name2, \"%d\", j);\n            x[name1];\n            EXPECT_EQ(static_cast<int>(i * n + j), x[name1][name2].GetInt());\n        }\n    }\n}\n\n// Issue 18: Error removing last element of object\n// http://code.google.com/p/rapidjson/issues/detail?id=18\nTEST(Value, RemoveLastElement) {\n    rapidjson::Document doc;\n    rapidjson::Document::AllocatorType& allocator = doc.GetAllocator();\n    rapidjson::Value objVal(rapidjson::kObjectType);        \n    objVal.AddMember(\"var1\", 123, allocator);       \n    objVal.AddMember(\"var2\", \"444\", allocator);\n    objVal.AddMember(\"var3\", 555, allocator);\n    EXPECT_TRUE(objVal.HasMember(\"var3\"));\n    objVal.RemoveMember(\"var3\");    // Assertion here in r61\n    EXPECT_FALSE(objVal.HasMember(\"var3\"));\n}\n\n// Issue 38:    Segmentation fault with CrtAllocator\nTEST(Document, CrtAllocator) {\n    typedef GenericValue<UTF8<>, CrtAllocator> V;\n\n    V::AllocatorType allocator;\n    V o(kObjectType);\n    o.AddMember(\"x\", 1, allocator); // Should not call destructor on uninitialized name/value of newly allocated members.\n\n    V a(kArrayType);\n    a.PushBack(1, allocator);   // Should not call destructor on uninitialized Value of newly allocated elements.\n}\n\nstatic void TestShortStringOptimization(const char* str) {\n    const rapidjson::SizeType len = static_cast<rapidjson::SizeType>(strlen(str));\n\t\n    rapidjson::Document doc;\n    rapidjson::Value val;\n    val.SetString(str, len, doc.GetAllocator());\n\t\n\tEXPECT_EQ(val.GetStringLength(), len);\n\tEXPECT_STREQ(val.GetString(), str);\n}\n\nTEST(Value, AllocateShortString) {\n\tTestShortStringOptimization(\"\");                 // edge case: empty string\n\tTestShortStringOptimization(\"12345678\");         // regular case for short strings: 8 chars\n\tTestShortStringOptimization(\"12345678901\");      // edge case: 11 chars in 32-bit mode (=> short string)\n\tTestShortStringOptimization(\"123456789012\");     // edge case: 12 chars in 32-bit mode (=> regular string)\n\tTestShortStringOptimization(\"123456789012345\");  // edge case: 15 chars in 64-bit mode (=> short string)\n\tTestShortStringOptimization(\"1234567890123456\"); // edge case: 16 chars in 64-bit mode (=> regular string)\n}\n\ntemplate <int e>\nstruct TerminateHandler {\n    bool Null() { return e != 0; }\n    bool Bool(bool) { return e != 1; }\n    bool Int(int) { return e != 2; }\n    bool Uint(unsigned) { return e != 3; }\n    bool Int64(int64_t) { return e != 4; }\n    bool Uint64(uint64_t) { return e != 5; }\n    bool Double(double) { return e != 6; }\n    bool RawNumber(const char*, SizeType, bool) { return e != 7; }\n    bool String(const char*, SizeType, bool) { return e != 8; }\n    bool StartObject() { return e != 9; }\n    bool Key(const char*, SizeType, bool)  { return e != 10; }\n    bool EndObject(SizeType) { return e != 11; }\n    bool StartArray() { return e != 12; }\n    bool EndArray(SizeType) { return e != 13; }\n};\n\n#define TEST_TERMINATION(e, json)\\\n{\\\n    Document d; \\\n    EXPECT_FALSE(d.Parse(json).HasParseError()); \\\n    Reader reader; \\\n    TerminateHandler<e> h;\\\n    EXPECT_FALSE(d.Accept(h));\\\n}\n\nTEST(Value, AcceptTerminationByHandler) {\n    TEST_TERMINATION(0, \"[null]\");\n    TEST_TERMINATION(1, \"[true]\");\n    TEST_TERMINATION(1, \"[false]\");\n    TEST_TERMINATION(2, \"[-1]\");\n    TEST_TERMINATION(3, \"[2147483648]\");\n    TEST_TERMINATION(4, \"[-1234567890123456789]\");\n    TEST_TERMINATION(5, \"[9223372036854775808]\");\n    TEST_TERMINATION(6, \"[0.5]\");\n    // RawNumber() is never called\n    TEST_TERMINATION(8, \"[\\\"a\\\"]\");\n    TEST_TERMINATION(9, \"[{}]\");\n    TEST_TERMINATION(10, \"[{\\\"a\\\":1}]\");\n    TEST_TERMINATION(11, \"[{}]\");\n    TEST_TERMINATION(12, \"{\\\"a\\\":[]}\");\n    TEST_TERMINATION(13, \"{\\\"a\\\":[]}\");\n}\n\nstruct ValueIntComparer {\n    bool operator()(const Value& lhs, const Value& rhs) const {\n        return lhs.GetInt() < rhs.GetInt();\n    }\n};\n\n#if RAPIDJSON_HAS_CXX11_RVALUE_REFS\nTEST(Value, Sorting) {\n    Value::AllocatorType allocator;\n    Value a(kArrayType);\n    a.PushBack(5, allocator);\n    a.PushBack(1, allocator);\n    a.PushBack(3, allocator);\n    std::sort(a.Begin(), a.End(), ValueIntComparer());\n    EXPECT_EQ(1, a[0].GetInt());\n    EXPECT_EQ(3, a[1].GetInt());\n    EXPECT_EQ(5, a[2].GetInt());\n}\n#endif\n\n// http://stackoverflow.com/questions/35222230/\n\nstatic void MergeDuplicateKey(Value& v, Value::AllocatorType& a) {\n    if (v.IsObject()) {\n        // Convert all key:value into key:[value]\n        for (Value::MemberIterator itr = v.MemberBegin(); itr != v.MemberEnd(); ++itr)\n            itr->value = Value(kArrayType).Move().PushBack(itr->value, a);\n        \n        // Merge arrays if key is duplicated\n        for (Value::MemberIterator itr = v.MemberBegin(); itr != v.MemberEnd();) {\n            Value::MemberIterator itr2 = v.FindMember(itr->name);\n            if (itr != itr2) {\n                itr2->value.PushBack(itr->value[0], a);\n                itr = v.EraseMember(itr);\n            }\n            else\n                ++itr;\n        }\n\n        // Convert key:[values] back to key:value if there is only one value\n        for (Value::MemberIterator itr = v.MemberBegin(); itr != v.MemberEnd(); ++itr) {\n            if (itr->value.Size() == 1)\n                itr->value = itr->value[0];\n            MergeDuplicateKey(itr->value, a); // Recursion on the value\n        }\n    }\n    else if (v.IsArray())\n        for (Value::ValueIterator itr = v.Begin(); itr != v.End(); ++itr)\n            MergeDuplicateKey(*itr, a);\n}\n\nTEST(Value, MergeDuplicateKey) {\n    Document d;\n    d.Parse(\n        \"{\"\n        \"    \\\"key1\\\": {\"\n        \"        \\\"a\\\": \\\"asdf\\\",\"\n        \"        \\\"b\\\": \\\"foo\\\",\"\n        \"        \\\"b\\\": \\\"bar\\\",\"\n        \"        \\\"c\\\": \\\"fdas\\\"\"\n        \"    }\"\n        \"}\");\n\n    Document d2;\n    d2.Parse(\n        \"{\"\n        \"    \\\"key1\\\": {\"\n        \"        \\\"a\\\": \\\"asdf\\\",\"\n        \"        \\\"b\\\": [\"\n        \"            \\\"foo\\\",\"\n        \"            \\\"bar\\\"\"\n        \"        ],\"\n        \"        \\\"c\\\": \\\"fdas\\\"\"\n        \"    }\"\n        \"}\");\n\n    EXPECT_NE(d2, d);\n    MergeDuplicateKey(d, d.GetAllocator());\n    EXPECT_EQ(d2, d);\n}\n\n#ifdef __clang__\nRAPIDJSON_DIAG_POP\n#endif\n"
  },
  {
    "path": "ext/rapidjson/test/unittest/writertest.cpp",
    "content": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved.\n//\n// Licensed under the MIT License (the \"License\"); you may not use this file except\n// in compliance with the License. You may obtain a copy of the License at\n//\n// http://opensource.org/licenses/MIT\n//\n// Unless required by applicable law or agreed to in writing, software distributed \n// under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR \n// CONDITIONS OF ANY KIND, either express or implied. See the License for the \n// specific language governing permissions and limitations under the License.\n\n#include \"unittest.h\"\n\n#include \"rapidjson/document.h\"\n#include \"rapidjson/reader.h\"\n#include \"rapidjson/writer.h\"\n#include \"rapidjson/stringbuffer.h\"\n#include \"rapidjson/memorybuffer.h\"\n\nusing namespace rapidjson;\n\nTEST(Writer, Compact) {\n    StringStream s(\"{ \\\"hello\\\" : \\\"world\\\", \\\"t\\\" : true , \\\"f\\\" : false, \\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3] } \");\n    StringBuffer buffer;\n    Writer<StringBuffer> writer(buffer);\n    buffer.ShrinkToFit();\n    Reader reader;\n    reader.Parse<0>(s, writer);\n    EXPECT_STREQ(\"{\\\"hello\\\":\\\"world\\\",\\\"t\\\":true,\\\"f\\\":false,\\\"n\\\":null,\\\"i\\\":123,\\\"pi\\\":3.1416,\\\"a\\\":[1,2,3]}\", buffer.GetString());\n    EXPECT_EQ(77u, buffer.GetSize());\n    EXPECT_TRUE(writer.IsComplete());\n}\n\n// json -> parse -> writer -> json\n#define TEST_ROUNDTRIP(json) \\\n    { \\\n        StringStream s(json); \\\n        StringBuffer buffer; \\\n        Writer<StringBuffer> writer(buffer); \\\n        Reader reader; \\\n        reader.Parse<kParseFullPrecisionFlag>(s, writer); \\\n        EXPECT_STREQ(json, buffer.GetString()); \\\n        EXPECT_TRUE(writer.IsComplete()); \\\n    }\n\nTEST(Writer, Root) {\n    TEST_ROUNDTRIP(\"null\");\n    TEST_ROUNDTRIP(\"true\");\n    TEST_ROUNDTRIP(\"false\");\n    TEST_ROUNDTRIP(\"0\");\n    TEST_ROUNDTRIP(\"\\\"foo\\\"\");\n    TEST_ROUNDTRIP(\"[]\");\n    TEST_ROUNDTRIP(\"{}\");\n}\n\nTEST(Writer, Int) {\n    TEST_ROUNDTRIP(\"[-1]\");\n    TEST_ROUNDTRIP(\"[-123]\");\n    TEST_ROUNDTRIP(\"[-2147483648]\");\n}\n\nTEST(Writer, UInt) {\n    TEST_ROUNDTRIP(\"[0]\");\n    TEST_ROUNDTRIP(\"[1]\");\n    TEST_ROUNDTRIP(\"[123]\");\n    TEST_ROUNDTRIP(\"[2147483647]\");\n    TEST_ROUNDTRIP(\"[4294967295]\");\n}\n\nTEST(Writer, Int64) {\n    TEST_ROUNDTRIP(\"[-1234567890123456789]\");\n    TEST_ROUNDTRIP(\"[-9223372036854775808]\");\n}\n\nTEST(Writer, Uint64) {\n    TEST_ROUNDTRIP(\"[1234567890123456789]\");\n    TEST_ROUNDTRIP(\"[9223372036854775807]\");\n}\n\nTEST(Writer, String) {\n    TEST_ROUNDTRIP(\"[\\\"Hello\\\"]\");\n    TEST_ROUNDTRIP(\"[\\\"Hello\\\\u0000World\\\"]\");\n    TEST_ROUNDTRIP(\"[\\\"\\\\\\\"\\\\\\\\/\\\\b\\\\f\\\\n\\\\r\\\\t\\\"]\");\n\n#if RAPIDJSON_HAS_STDSTRING\n    {\n        StringBuffer buffer;\n        Writer<StringBuffer> writer(buffer);\n        writer.String(std::string(\"Hello\\n\"));\n        EXPECT_STREQ(\"\\\"Hello\\\\n\\\"\", buffer.GetString());\n    }\n#endif\n}\n\nTEST(Writer, ScanWriteUnescapedString) {\n    const char json[] = \"[\\\" \\\\\\\"0123456789ABCDEF\\\"]\";\n    //                       ^ scanning stops here.\n    char buffer2[sizeof(json) + 32];\n\n    // Use different offset to test different alignments\n    for (int i = 0; i < 32; i++) {\n        char* p = buffer2 + i;\n        memcpy(p, json, sizeof(json));\n        TEST_ROUNDTRIP(p);\n    }\n}\n\nTEST(Writer, Double) {\n    TEST_ROUNDTRIP(\"[1.2345,1.2345678,0.123456789012,1234567.8]\");\n    TEST_ROUNDTRIP(\"0.0\");\n    TEST_ROUNDTRIP(\"-0.0\"); // Issue #289\n    TEST_ROUNDTRIP(\"1e30\");\n    TEST_ROUNDTRIP(\"1.0\");\n    TEST_ROUNDTRIP(\"5e-324\"); // Min subnormal positive double\n    TEST_ROUNDTRIP(\"2.225073858507201e-308\"); // Max subnormal positive double\n    TEST_ROUNDTRIP(\"2.2250738585072014e-308\"); // Min normal positive double\n    TEST_ROUNDTRIP(\"1.7976931348623157e308\"); // Max double\n\n}\n\n// UTF8 -> TargetEncoding -> UTF8\ntemplate <typename TargetEncoding>\nvoid TestTranscode(const char* json) {\n    StringStream s(json);\n    GenericStringBuffer<TargetEncoding> buffer;\n    Writer<GenericStringBuffer<TargetEncoding>, UTF8<>, TargetEncoding> writer(buffer);\n    Reader reader;\n    reader.Parse(s, writer);\n\n    StringBuffer buffer2;\n    Writer<StringBuffer> writer2(buffer2);\n    GenericReader<TargetEncoding, UTF8<> > reader2;\n    GenericStringStream<TargetEncoding> s2(buffer.GetString());\n    reader2.Parse(s2, writer2);\n\n    EXPECT_STREQ(json, buffer2.GetString());\n}\n\nTEST(Writer, Transcode) {\n    const char json[] = \"{\\\"hello\\\":\\\"world\\\",\\\"t\\\":true,\\\"f\\\":false,\\\"n\\\":null,\\\"i\\\":123,\\\"pi\\\":3.1416,\\\"a\\\":[1,2,3],\\\"dollar\\\":\\\"\\x24\\\",\\\"cents\\\":\\\"\\xC2\\xA2\\\",\\\"euro\\\":\\\"\\xE2\\x82\\xAC\\\",\\\"gclef\\\":\\\"\\xF0\\x9D\\x84\\x9E\\\"}\";\n\n    // UTF8 -> UTF16 -> UTF8\n    TestTranscode<UTF8<> >(json);\n\n    // UTF8 -> ASCII -> UTF8\n    TestTranscode<ASCII<> >(json);\n\n    // UTF8 -> UTF16 -> UTF8\n    TestTranscode<UTF16<> >(json);\n\n    // UTF8 -> UTF32 -> UTF8\n    TestTranscode<UTF32<> >(json);\n\n    // UTF8 -> AutoUTF -> UTF8\n    UTFType types[] = { kUTF8, kUTF16LE , kUTF16BE, kUTF32LE , kUTF32BE };\n    for (size_t i = 0; i < 5; i++) {\n        StringStream s(json);\n        MemoryBuffer buffer;\n        AutoUTFOutputStream<unsigned, MemoryBuffer> os(buffer, types[i], true);\n        Writer<AutoUTFOutputStream<unsigned, MemoryBuffer>, UTF8<>, AutoUTF<unsigned> > writer(os);\n        Reader reader;\n        reader.Parse(s, writer);\n\n        StringBuffer buffer2;\n        Writer<StringBuffer> writer2(buffer2);\n        GenericReader<AutoUTF<unsigned>, UTF8<> > reader2;\n        MemoryStream s2(buffer.GetBuffer(), buffer.GetSize());\n        AutoUTFInputStream<unsigned, MemoryStream> is(s2);\n        reader2.Parse(is, writer2);\n\n        EXPECT_STREQ(json, buffer2.GetString());\n    }\n\n}\n\n#include <sstream>\n\nclass OStreamWrapper {\npublic:\n    typedef char Ch;\n\n    OStreamWrapper(std::ostream& os) : os_(os) {}\n\n    Ch Peek() const { assert(false); return '\\0'; }\n    Ch Take() { assert(false); return '\\0'; }\n    size_t Tell() const { return 0; }\n\n    Ch* PutBegin() { assert(false); return 0; }\n    void Put(Ch c) { os_.put(c); }\n    void Flush() { os_.flush(); }\n    size_t PutEnd(Ch*) { assert(false); return 0; }\n\nprivate:\n    OStreamWrapper(const OStreamWrapper&);\n    OStreamWrapper& operator=(const OStreamWrapper&);\n\n    std::ostream& os_;\n};\n\nTEST(Writer, OStreamWrapper) {\n    StringStream s(\"{ \\\"hello\\\" : \\\"world\\\", \\\"t\\\" : true , \\\"f\\\" : false, \\\"n\\\": null, \\\"i\\\":123, \\\"pi\\\": 3.1416, \\\"a\\\":[1, 2, 3], \\\"u64\\\": 1234567890123456789, \\\"i64\\\":-1234567890123456789 } \");\n    \n    std::stringstream ss;\n    OStreamWrapper os(ss);\n    \n    Writer<OStreamWrapper> writer(os);\n\n    Reader reader;\n    reader.Parse<0>(s, writer);\n    \n    std::string actual = ss.str();\n    EXPECT_STREQ(\"{\\\"hello\\\":\\\"world\\\",\\\"t\\\":true,\\\"f\\\":false,\\\"n\\\":null,\\\"i\\\":123,\\\"pi\\\":3.1416,\\\"a\\\":[1,2,3],\\\"u64\\\":1234567890123456789,\\\"i64\\\":-1234567890123456789}\", actual.c_str());\n}\n\nTEST(Writer, AssertRootMayBeAnyValue) {\n#define T(x)\\\n    {\\\n        StringBuffer buffer;\\\n        Writer<StringBuffer> writer(buffer);\\\n        EXPECT_TRUE(x);\\\n    }\n    T(writer.Bool(false));\n    T(writer.Bool(true));\n    T(writer.Null());\n    T(writer.Int(0));\n    T(writer.Uint(0));\n    T(writer.Int64(0));\n    T(writer.Uint64(0));\n    T(writer.Double(0));\n    T(writer.String(\"foo\"));\n#undef T\n}\n\nTEST(Writer, AssertIncorrectObjectLevel) {\n    StringBuffer buffer;\n    Writer<StringBuffer> writer(buffer);\n    writer.StartObject();\n    writer.EndObject();\n    ASSERT_THROW(writer.EndObject(), AssertException);\n}\n\nTEST(Writer, AssertIncorrectArrayLevel) {\n    StringBuffer buffer;\n    Writer<StringBuffer> writer(buffer);\n    writer.StartArray();\n    writer.EndArray();\n    ASSERT_THROW(writer.EndArray(), AssertException);\n}\n\nTEST(Writer, AssertIncorrectEndObject) {\n    StringBuffer buffer;\n    Writer<StringBuffer> writer(buffer);\n    writer.StartObject();\n    ASSERT_THROW(writer.EndArray(), AssertException);\n}\n\nTEST(Writer, AssertIncorrectEndArray) {\n    StringBuffer buffer;\n    Writer<StringBuffer> writer(buffer);\n    writer.StartObject();\n    ASSERT_THROW(writer.EndArray(), AssertException);\n}\n\nTEST(Writer, AssertObjectKeyNotString) {\n#define T(x)\\\n    {\\\n        StringBuffer buffer;\\\n        Writer<StringBuffer> writer(buffer);\\\n        writer.StartObject();\\\n        ASSERT_THROW(x, AssertException); \\\n    }\n    T(writer.Bool(false));\n    T(writer.Bool(true));\n    T(writer.Null());\n    T(writer.Int(0));\n    T(writer.Uint(0));\n    T(writer.Int64(0));\n    T(writer.Uint64(0));\n    T(writer.Double(0));\n    T(writer.StartObject());\n    T(writer.StartArray());\n#undef T\n}\n\nTEST(Writer, AssertMultipleRoot) {\n    StringBuffer buffer;\n    Writer<StringBuffer> writer(buffer);\n\n    writer.StartObject();\n    writer.EndObject();\n    ASSERT_THROW(writer.StartObject(), AssertException);\n\n    writer.Reset(buffer);\n    writer.Null();\n    ASSERT_THROW(writer.Int(0), AssertException);\n\n    writer.Reset(buffer);\n    writer.String(\"foo\");\n    ASSERT_THROW(writer.StartArray(), AssertException);\n\n    writer.Reset(buffer);\n    writer.StartArray();\n    writer.EndArray();\n    //ASSERT_THROW(writer.Double(3.14), AssertException);\n}\n\nTEST(Writer, RootObjectIsComplete) {\n    StringBuffer buffer;\n    Writer<StringBuffer> writer(buffer);\n    EXPECT_FALSE(writer.IsComplete());\n    writer.StartObject();\n    EXPECT_FALSE(writer.IsComplete());\n    writer.String(\"foo\");\n    EXPECT_FALSE(writer.IsComplete());\n    writer.Int(1);\n    EXPECT_FALSE(writer.IsComplete());\n    writer.EndObject();\n    EXPECT_TRUE(writer.IsComplete());\n}\n\nTEST(Writer, RootArrayIsComplete) {\n    StringBuffer buffer;\n    Writer<StringBuffer> writer(buffer);\n    EXPECT_FALSE(writer.IsComplete());\n    writer.StartArray();\n    EXPECT_FALSE(writer.IsComplete());\n    writer.String(\"foo\");\n    EXPECT_FALSE(writer.IsComplete());\n    writer.Int(1);\n    EXPECT_FALSE(writer.IsComplete());\n    writer.EndArray();\n    EXPECT_TRUE(writer.IsComplete());\n}\n\nTEST(Writer, RootValueIsComplete) {\n#define T(x)\\\n    {\\\n        StringBuffer buffer;\\\n        Writer<StringBuffer> writer(buffer);\\\n        EXPECT_FALSE(writer.IsComplete()); \\\n        x; \\\n        EXPECT_TRUE(writer.IsComplete()); \\\n    }\n    T(writer.Null());\n    T(writer.Bool(true));\n    T(writer.Bool(false));\n    T(writer.Int(0));\n    T(writer.Uint(0));\n    T(writer.Int64(0));\n    T(writer.Uint64(0));\n    T(writer.Double(0));\n    T(writer.String(\"\"));\n#undef T\n}\n\nTEST(Writer, InvalidEncoding) {\n    // Fail in decoding invalid UTF-8 sequence http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt\n    {\n        GenericStringBuffer<UTF16<> > buffer;\n        Writer<GenericStringBuffer<UTF16<> >, UTF8<>, UTF16<> > writer(buffer);\n        writer.StartArray();\n        EXPECT_FALSE(writer.String(\"\\xfe\"));\n        EXPECT_FALSE(writer.String(\"\\xff\"));\n        EXPECT_FALSE(writer.String(\"\\xfe\\xfe\\xff\\xff\"));\n        writer.EndArray();\n    }\n\n    // Fail in encoding\n    {\n        StringBuffer buffer;\n        Writer<StringBuffer, UTF32<> > writer(buffer);\n        static const UTF32<>::Ch s[] = { 0x110000, 0 }; // Out of U+0000 to U+10FFFF\n        EXPECT_FALSE(writer.String(s));\n    }\n\n    // Fail in unicode escaping in ASCII output\n    {\n        StringBuffer buffer;\n        Writer<StringBuffer, UTF32<>, ASCII<> > writer(buffer);\n        static const UTF32<>::Ch s[] = { 0x110000, 0 }; // Out of U+0000 to U+10FFFF\n        EXPECT_FALSE(writer.String(s));\n    }\n}\n\nTEST(Writer, ValidateEncoding) {\n    {\n        StringBuffer buffer;\n        Writer<StringBuffer, UTF8<>, UTF8<>, CrtAllocator, kWriteValidateEncodingFlag> writer(buffer);\n        writer.StartArray();\n        EXPECT_TRUE(writer.String(\"\\x24\"));             // Dollar sign U+0024\n        EXPECT_TRUE(writer.String(\"\\xC2\\xA2\"));         // Cents sign U+00A2\n        EXPECT_TRUE(writer.String(\"\\xE2\\x82\\xAC\"));     // Euro sign U+20AC\n        EXPECT_TRUE(writer.String(\"\\xF0\\x9D\\x84\\x9E\")); // G clef sign U+1D11E\n        writer.EndArray();\n        EXPECT_STREQ(\"[\\\"\\x24\\\",\\\"\\xC2\\xA2\\\",\\\"\\xE2\\x82\\xAC\\\",\\\"\\xF0\\x9D\\x84\\x9E\\\"]\", buffer.GetString());\n    }\n\n    // Fail in decoding invalid UTF-8 sequence http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt\n    {\n        StringBuffer buffer;\n        Writer<StringBuffer, UTF8<>, UTF8<>, CrtAllocator, kWriteValidateEncodingFlag> writer(buffer);\n        writer.StartArray();\n        EXPECT_FALSE(writer.String(\"\\xfe\"));\n        EXPECT_FALSE(writer.String(\"\\xff\"));\n        EXPECT_FALSE(writer.String(\"\\xfe\\xfe\\xff\\xff\"));\n        writer.EndArray();\n    }\n}\n\nTEST(Writer, InvalidEventSequence) {\n    // {]\n    {\n        StringBuffer buffer;\n        Writer<StringBuffer> writer(buffer);\n        writer.StartObject();\n        EXPECT_THROW(writer.EndArray(), AssertException);\n        EXPECT_FALSE(writer.IsComplete());\n    }\n\n    // [}\n    {\n        StringBuffer buffer;\n        Writer<StringBuffer> writer(buffer);\n        writer.StartArray();\n        EXPECT_THROW(writer.EndObject(), AssertException);\n        EXPECT_FALSE(writer.IsComplete());\n    }\n\n    // { 1: \n    {\n        StringBuffer buffer;\n        Writer<StringBuffer> writer(buffer);\n        writer.StartObject();\n        EXPECT_THROW(writer.Int(1), AssertException);\n        EXPECT_FALSE(writer.IsComplete());\n    }\n}\n\nTEST(Writer, NaN) {\n    double nan = std::numeric_limits<double>::quiet_NaN();\n\n    EXPECT_TRUE(internal::Double(nan).IsNan());\n    StringBuffer buffer;\n    {\n        Writer<StringBuffer> writer(buffer);\n        EXPECT_FALSE(writer.Double(nan));\n    }\n    {\n        Writer<StringBuffer, UTF8<>, UTF8<>, CrtAllocator, kWriteNanAndInfFlag> writer(buffer);\n        EXPECT_TRUE(writer.Double(nan));\n        EXPECT_STREQ(\"NaN\", buffer.GetString());\n    }\n    GenericStringBuffer<UTF16<> > buffer2;\n    Writer<GenericStringBuffer<UTF16<> > > writer2(buffer2);\n    EXPECT_FALSE(writer2.Double(nan));\n}\n\nTEST(Writer, Inf) {\n    double inf = std::numeric_limits<double>::infinity();\n\n    EXPECT_TRUE(internal::Double(inf).IsInf());\n    StringBuffer buffer;\n    {\n        Writer<StringBuffer> writer(buffer);\n        EXPECT_FALSE(writer.Double(inf));\n    }\n    {\n        Writer<StringBuffer> writer(buffer);\n        EXPECT_FALSE(writer.Double(-inf));\n    }\n    {\n        Writer<StringBuffer, UTF8<>, UTF8<>, CrtAllocator, kWriteNanAndInfFlag> writer(buffer);\n        EXPECT_TRUE(writer.Double(inf));\n    }\n    {\n        Writer<StringBuffer, UTF8<>, UTF8<>, CrtAllocator, kWriteNanAndInfFlag> writer(buffer);\n        EXPECT_TRUE(writer.Double(-inf));\n    }\n    EXPECT_STREQ(\"Infinity-Infinity\", buffer.GetString());\n}\n\nTEST(Writer, RawValue) {\n    StringBuffer buffer;\n    Writer<StringBuffer> writer(buffer);\n    writer.StartObject();\n    writer.Key(\"a\");\n    writer.Int(1);\n    writer.Key(\"raw\");\n    const char json[] = \"[\\\"Hello\\\\nWorld\\\", 123.456]\";\n    writer.RawValue(json, strlen(json), kArrayType);\n    writer.EndObject();\n    EXPECT_TRUE(writer.IsComplete());\n    EXPECT_STREQ(\"{\\\"a\\\":1,\\\"raw\\\":[\\\"Hello\\\\nWorld\\\", 123.456]}\", buffer.GetString());\n}\n"
  },
  {
    "path": "ext/rapidjson/travis-doxygen.sh",
    "content": "#!/bin/bash\n# Update Doxygen documentation after push to 'master'.\n# Author: @pah\n\nset -e\n\nDOXYGEN_VER=doxygen-1.8.7\nDOXYGEN_TAR=${DOXYGEN_VER}.linux.bin.tar.gz\nDOXYGEN_URL=\"http://ftp.stack.nl/pub/users/dimitri/${DOXYGEN_TAR}\"\nDOXYGEN_BIN=\"/usr/local/bin/doxygen\"\n\n: ${GITHUB_REPO:=\"miloyip/rapidjson\"}\nGITHUB_HOST=\"github.com\"\nGITHUB_CLONE=\"git://${GITHUB_HOST}/${GITHUB_REPO}\"\nGITHUB_URL=\"https://${GITHUB_HOST}/${GITHUB_PUSH-${GITHUB_REPO}}\"\n\n# if not set, ignore password\n#GIT_ASKPASS=\"${TRAVIS_BUILD_DIR}/gh_ignore_askpass.sh\"\n\nskip() {\n\techo \"$@\" 1>&2\n\techo \"Exiting...\" 1>&2\n\texit 0\n}\n\nabort() {\n\techo \"Error: $@\" 1>&2\n\techo \"Exiting...\" 1>&2\n\texit 1\n}\n\n# TRAVIS_BUILD_DIR not set, exiting\n[ -d \"${TRAVIS_BUILD_DIR-/nonexistent}\" ] || \\\n\tabort '${TRAVIS_BUILD_DIR} not set or nonexistent.'\n\n# check for pull-requests\n[ \"${TRAVIS_PULL_REQUEST}\" = \"false\" ] || \\\n\tskip \"Not running Doxygen for pull-requests.\"\n\n# check for branch name\n[ \"${TRAVIS_BRANCH}\" = \"master\" ] || \\\n\tskip \"Running Doxygen only for updates on 'master' branch (current: ${TRAVIS_BRANCH}).\"\n\n# check for job number\n# [ \"${TRAVIS_JOB_NUMBER}\" = \"${TRAVIS_BUILD_NUMBER}.1\" ] || \\\n# \tskip \"Running Doxygen only on first job of build ${TRAVIS_BUILD_NUMBER} (current: ${TRAVIS_JOB_NUMBER}).\"\n\n# install doxygen binary distribution\ndoxygen_install()\n{\n\twget -O - \"${DOXYGEN_URL}\" | \\\n\t\ttar xz -C ${TMPDIR-/tmp} ${DOXYGEN_VER}/bin/doxygen\n    export PATH=\"${TMPDIR-/tmp}/${DOXYGEN_VER}/bin:$PATH\"\n}\n\ndoxygen_run()\n{\n\tcd \"${TRAVIS_BUILD_DIR}\";\n\tdoxygen ${TRAVIS_BUILD_DIR}/build/doc/Doxyfile;\n\tdoxygen ${TRAVIS_BUILD_DIR}/build/doc/Doxyfile.zh-cn;\n}\n\ngh_pages_prepare()\n{\n\tcd \"${TRAVIS_BUILD_DIR}/build/doc\";\n\t[ ! -d \"html\" ] || \\\n\t\tabort \"Doxygen target directory already exists.\"\n\tgit --version\n\tgit clone -b gh-pages \"${GITHUB_CLONE}\" html\n\tcd html\n\t# setup git config (with defaults)\n\tgit config user.name \"${GIT_NAME-travis}\"\n\tgit config user.email \"${GIT_EMAIL-\"travis@localhost\"}\"\n\t# clean working dir\n\trm -f .git/index\n\tgit clean -df\n}\n\ngh_pages_commit() {\n\tcd \"${TRAVIS_BUILD_DIR}/build/doc/html\";\n\techo \"rapidjson.org\" > CNAME\n\tgit add --all;\n\tgit diff-index --quiet HEAD || git commit -m \"Automatic doxygen build\";\n}\n\ngh_setup_askpass() {\n\tcat > ${GIT_ASKPASS} <<EOF\n#!/bin/bash\necho\nexit 0\nEOF\n\tchmod a+x \"$GIT_ASKPASS\"\n}\n\ngh_pages_push() {\n\t# check for secure variables\n\t[ \"${TRAVIS_SECURE_ENV_VARS}\" = \"true\" ] || \\\n\t\tskip \"Secure variables not available, not updating GitHub pages.\"\n\t# check for GitHub access token\n\t[ \"${GH_TOKEN+set}\" = set ] || \\\n\t\tskip \"GitHub access token not available, not updating GitHub pages.\"\n\t[ \"${#GH_TOKEN}\" -eq 40 ] || \\\n\t\tabort \"GitHub token invalid: found ${#GH_TOKEN} characters, expected 40.\"\n\n\tcd \"${TRAVIS_BUILD_DIR}/build/doc/html\";\n\t# setup credentials (hide in \"set -x\" mode)\n\tgit remote set-url --push origin \"${GITHUB_URL}\"\n\tgit config credential.helper 'store'\n\t# ( set +x ; git config credential.username \"${GH_TOKEN}\" )\n\t( set +x ; [ -f ${HOME}/.git-credentials ] || \\\n\t\t\t( echo \"https://${GH_TOKEN}:@${GITHUB_HOST}\" > ${HOME}/.git-credentials ; \\\n\t\t\t chmod go-rw ${HOME}/.git-credentials ) )\n\t# push to GitHub\n\tgit push origin gh-pages\n}\n\ndoxygen_install\ngh_pages_prepare\ndoxygen_run\ngh_pages_commit\ngh_pages_push\n\n"
  },
  {
    "path": "ext/yassl/AUTHORS",
    "content": ""
  },
  {
    "path": "ext/yassl/CMakeLists.txt",
    "content": "# Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA\n\nINCLUDE(${PROJECT_SOURCE_DIR}/cmake/libutils.cmake)\n\nINCLUDE_DIRECTORIES(\n  ${MySQLRouter_BINARY_DIR}\n  ${MySQLRouter_BINARY_DIR}/include\n  ${CMAKE_CURRENT_SOURCE_DIR}/include\n  ${CMAKE_CURRENT_SOURCE_DIR}/taocrypt/include\n  ${CMAKE_CURRENT_SOURCE_DIR}/taocrypt/mySTL)\n\nADD_DEFINITIONS(${SSL_DEFINES})\n\n# Speed up build process excluding unused header files\nADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN -DNOGDI)\n\n# We want to use std::min/std::max, not the windows.h macros\nADD_DEFINITIONS(-DNOMINMAX)\n\n# rename get_tty_password to avoid collisions with the main binary\nADD_DEFINITIONS(-Dget_tty_password_ext=yassl_mysql_get_tty_password_ext)\nADD_DEFINITIONS(-Dget_tty_password=yassl_mysql_get_tty_password)\n\nINCLUDE(TestBigEndian)\nTEST_BIG_ENDIAN(WORDS_BIGENDIAN)\n\nINCLUDE (CheckTypeSize)\nCHECK_TYPE_SIZE(\"long\"      SIZEOF_LONG)\nCHECK_TYPE_SIZE(\"long long\" SIZEOF_LONG_LONG)\n\nenable_language(CXX)\ninclude(CheckCXXCompilerFlag)\n\nADD_DEFINITIONS(-DSIZEOF_LONG=${SIZEOF_LONG} -DSIZEOF_LONG_LONG=${SIZEOF_LONG_LONG})\nIF(WORDS_BIGENDIAN)\n  ADD_DEFINITIONS(-DWORDS_BIGENDIAN=${WORDS_BIGENDIAN})\nENDIF()\n\nCHECK_CXX_COMPILER_FLAG(\"-Wno-sign-conversion\" HAVE_NO_SIGN_CONVERSION)\nIF(HAVE_NO_SIGN_CONVERSION)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-sign-conversion\")\nENDIF()\n\nCHECK_CXX_COMPILER_FLAG(\"-Wno-unused-const-variable\" HAVE_NO_UNUSED_CONST)\nIF(HAVE_NO_UNUSED_CONST)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-unused-const-variable\")\nENDIF()\n\nCHECK_CXX_COMPILER_FLAG(\"-Wunused-parameter\" HAVE_UNUSED)\nIF(HAVE_UNUSED)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-unused-parameter\")\nENDIF()\n\nCHECK_CXX_COMPILER_FLAG(\"-Wno-unused-but-set-variable\"\n                           HAVE_UNUSED_BUT_SET_VARIABLE)\nIF(HAVE_UNUSED_BUT_SET_VARIABLE)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-unused-but-set-variable\")\nENDIF()\n\nCHECK_CXX_COMPILER_FLAG(\"-Wshadow\" HAVE_SHADOW)\nIF(HAVE_SHADOW)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-shadow\")\nENDIF()\n\nCHECK_CXX_COMPILER_FLAG(\"-Wconversion\" HAVE_CONVERSION)\nIF(HAVE_CONVERSION)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-conversion\")\nENDIF()\n\nCHECK_CXX_COMPILER_FLAG(\"-Werror\" HAVE_ERROR)\nIF(HAVE_ERROR)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-error\")\nENDIF()\n\nSET(YASSL_SOURCES  src/buffer.cpp src/cert_wrapper.cpp src/crypto_wrapper.cpp src/handshake.cpp src/lock.cpp\n\t\t\t\tsrc/log.cpp src/socket_wrapper.cpp src/ssl.cpp src/timer.cpp src/yassl_error.cpp\n\t\t\t\tsrc/yassl_imp.cpp src/yassl_int.cpp)\n\nADD_CONVENIENCE_LIBRARY(router_yassl ${YASSL_SOURCES})\n\nADD_SUBDIRECTORY(taocrypt)\n"
  },
  {
    "path": "ext/yassl/COPYING",
    "content": "\t\t    GNU GENERAL PUBLIC LICENSE\n\t\t       Version 2, June 1991\n\n Copyright (C) 1989, 1991 Free Software Foundation, Inc.\n 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n\t\t\t    Preamble\n\n  The licenses for most software are designed to take away your\nfreedom to share and change it.  By contrast, the GNU General Public\nLicense is intended to guarantee your freedom to share and change free\nsoftware--to make sure the software is free for all its users.  This\nGeneral Public License applies to most of the Free Software\nFoundation's software and to any other program whose authors commit to\nusing it.  (Some other Free Software Foundation software is covered by\nthe GNU Library General Public License instead.)  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthis service if you wish), that you receive source code or can get it\nif you want it, that you can change the software or use pieces of it\nin new free programs; and that you know you can do these things.\n\n  To protect your rights, we need to make restrictions that forbid\nanyone to deny you these rights or to ask you to surrender the rights.\nThese restrictions translate to certain responsibilities for you if you\ndistribute copies of the software, or if you modify it.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must give the recipients all the rights that\nyou have.  You must make sure that they, too, receive or can get the\nsource code.  And you must show them these terms so they know their\nrights.\n\n  We protect your rights with two steps: (1) copyright the software, and\n(2) offer you this license which gives you legal permission to copy,\ndistribute and/or modify the software.\n\n  Also, for each author's protection and ours, we want to make certain\nthat everyone understands that there is no warranty for this free\nsoftware.  If the software is modified by someone else and passed on, we\nwant its recipients to know that what they have is not the original, so\nthat any problems introduced by others will not reflect on the original\nauthors' reputations.\n\n  Finally, any free program is threatened constantly by software\npatents.  We wish to avoid the danger that redistributors of a free\nprogram will individually obtain patent licenses, in effect making the\nprogram proprietary.  To prevent this, we have made it clear that any\npatent must be licensed for everyone's free use or not licensed at all.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\f\n\t\t    GNU GENERAL PUBLIC LICENSE\n   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n  0. This License applies to any program or other work which contains\na notice placed by the copyright holder saying it may be distributed\nunder the terms of this General Public License.  The \"Program\", below,\nrefers to any such program or work, and a \"work based on the Program\"\nmeans either the Program or any derivative work under copyright law:\nthat is to say, a work containing the Program or a portion of it,\neither verbatim or with modifications and/or translated into another\nlanguage.  (Hereinafter, translation is included without limitation in\nthe term \"modification\".)  Each licensee is addressed as \"you\".\n\nActivities other than copying, distribution and modification are not\ncovered by this License; they are outside its scope.  The act of\nrunning the Program is not restricted, and the output from the Program\nis covered only if its contents constitute a work based on the\nProgram (independent of having been made by running the Program).\nWhether that is true depends on what the Program does.\n\n  1. You may copy and distribute verbatim copies of the Program's\nsource code as you receive it, in any medium, provided that you\nconspicuously and appropriately publish on each copy an appropriate\ncopyright notice and disclaimer of warranty; keep intact all the\nnotices that refer to this License and to the absence of any warranty;\nand give any other recipients of the Program a copy of this License\nalong with the Program.\n\nYou may charge a fee for the physical act of transferring a copy, and\nyou may at your option offer warranty protection in exchange for a fee.\n\n  2. You may modify your copy or copies of the Program or any portion\nof it, thus forming a work based on the Program, and copy and\ndistribute such modifications or work under the terms of Section 1\nabove, provided that you also meet all of these conditions:\n\n    a) You must cause the modified files to carry prominent notices\n    stating that you changed the files and the date of any change.\n\n    b) You must cause any work that you distribute or publish, that in\n    whole or in part contains or is derived from the Program or any\n    part thereof, to be licensed as a whole at no charge to all third\n    parties under the terms of this License.\n\n    c) If the modified program normally reads commands interactively\n    when run, you must cause it, when started running for such\n    interactive use in the most ordinary way, to print or display an\n    announcement including an appropriate copyright notice and a\n    notice that there is no warranty (or else, saying that you provide\n    a warranty) and that users may redistribute the program under\n    these conditions, and telling the user how to view a copy of this\n    License.  (Exception: if the Program itself is interactive but\n    does not normally print such an announcement, your work based on\n    the Program is not required to print an announcement.)\n\f\nThese requirements apply to the modified work as a whole.  If\nidentifiable sections of that work are not derived from the Program,\nand can be reasonably considered independent and separate works in\nthemselves, then this License, and its terms, do not apply to those\nsections when you distribute them as separate works.  But when you\ndistribute the same sections as part of a whole which is a work based\non the Program, the distribution of the whole must be on the terms of\nthis License, whose permissions for other licensees extend to the\nentire whole, and thus to each and every part regardless of who wrote it.\n\nThus, it is not the intent of this section to claim rights or contest\nyour rights to work written entirely by you; rather, the intent is to\nexercise the right to control the distribution of derivative or\ncollective works based on the Program.\n\nIn addition, mere aggregation of another work not based on the Program\nwith the Program (or with a work based on the Program) on a volume of\na storage or distribution medium does not bring the other work under\nthe scope of this License.\n\n  3. You may copy and distribute the Program (or a work based on it,\nunder Section 2) in object code or executable form under the terms of\nSections 1 and 2 above provided that you also do one of the following:\n\n    a) Accompany it with the complete corresponding machine-readable\n    source code, which must be distributed under the terms of Sections\n    1 and 2 above on a medium customarily used for software interchange; or,\n\n    b) Accompany it with a written offer, valid for at least three\n    years, to give any third party, for a charge no more than your\n    cost of physically performing source distribution, a complete\n    machine-readable copy of the corresponding source code, to be\n    distributed under the terms of Sections 1 and 2 above on a medium\n    customarily used for software interchange; or,\n\n    c) Accompany it with the information you received as to the offer\n    to distribute corresponding source code.  (This alternative is\n    allowed only for noncommercial distribution and only if you\n    received the program in object code or executable form with such\n    an offer, in accord with Subsection b above.)\n\nThe source code for a work means the preferred form of the work for\nmaking modifications to it.  For an executable work, complete source\ncode means all the source code for all modules it contains, plus any\nassociated interface definition files, plus the scripts used to\ncontrol compilation and installation of the executable.  However, as a\nspecial exception, the source code distributed need not include\nanything that is normally distributed (in either source or binary\nform) with the major components (compiler, kernel, and so on) of the\noperating system on which the executable runs, unless that component\nitself accompanies the executable.\n\nIf distribution of executable or object code is made by offering\naccess to copy from a designated place, then offering equivalent\naccess to copy the source code from the same place counts as\ndistribution of the source code, even though third parties are not\ncompelled to copy the source along with the object code.\n\f\n  4. You may not copy, modify, sublicense, or distribute the Program\nexcept as expressly provided under this License.  Any attempt\notherwise to copy, modify, sublicense or distribute the Program is\nvoid, and will automatically terminate your rights under this License.\nHowever, parties who have received copies, or rights, from you under\nthis License will not have their licenses terminated so long as such\nparties remain in full compliance.\n\n  5. You are not required to accept this License, since you have not\nsigned it.  However, nothing else grants you permission to modify or\ndistribute the Program or its derivative works.  These actions are\nprohibited by law if you do not accept this License.  Therefore, by\nmodifying or distributing the Program (or any work based on the\nProgram), you indicate your acceptance of this License to do so, and\nall its terms and conditions for copying, distributing or modifying\nthe Program or works based on it.\n\n  6. Each time you redistribute the Program (or any work based on the\nProgram), the recipient automatically receives a license from the\noriginal licensor to copy, distribute or modify the Program subject to\nthese terms and conditions.  You may not impose any further\nrestrictions on the recipients' exercise of the rights granted herein.\nYou are not responsible for enforcing compliance by third parties to\nthis License.\n\n  7. If, as a consequence of a court judgment or allegation of patent\ninfringement or for any other reason (not limited to patent issues),\nconditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot\ndistribute so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you\nmay not distribute the Program at all.  For example, if a patent\nlicense would not permit royalty-free redistribution of the Program by\nall those who receive copies directly or indirectly through you, then\nthe only way you could satisfy both it and this License would be to\nrefrain entirely from distribution of the Program.\n\nIf any portion of this section is held invalid or unenforceable under\nany particular circumstance, the balance of the section is intended to\napply and the section as a whole is intended to apply in other\ncircumstances.\n\nIt is not the purpose of this section to induce you to infringe any\npatents or other property right claims or to contest validity of any\nsuch claims; this section has the sole purpose of protecting the\nintegrity of the free software distribution system, which is\nimplemented by public license practices.  Many people have made\ngenerous contributions to the wide range of software distributed\nthrough that system in reliance on consistent application of that\nsystem; it is up to the author/donor to decide if he or she is willing\nto distribute software through any other system and a licensee cannot\nimpose that choice.\n\nThis section is intended to make thoroughly clear what is believed to\nbe a consequence of the rest of this License.\n\f\n  8. If the distribution and/or use of the Program is restricted in\ncertain countries either by patents or by copyrighted interfaces, the\noriginal copyright holder who places the Program under this License\nmay add an explicit geographical distribution limitation excluding\nthose countries, so that distribution is permitted only in or among\ncountries not thus excluded.  In such case, this License incorporates\nthe limitation as if written in the body of this License.\n\n  9. The Free Software Foundation may publish revised and/or new versions\nof the General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\nEach version is given a distinguishing version number.  If the Program\nspecifies a version number of this License which applies to it and \"any\nlater version\", you have the option of following the terms and conditions\neither of that version or of any later version published by the Free\nSoftware Foundation.  If the Program does not specify a version number of\nthis License, you may choose any version ever published by the Free Software\nFoundation.\n\n  10. If you wish to incorporate parts of the Program into other free\nprograms whose distribution conditions are different, write to the author\nto ask for permission.  For software which is copyrighted by the Free\nSoftware Foundation, write to the Free Software Foundation; we sometimes\nmake exceptions for this.  Our decision will be guided by the two goals\nof preserving the free status of all derivatives of our free software and\nof promoting the sharing and reuse of software generally.\n\n\t\t\t    NO WARRANTY\n\n  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\nFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN\nOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\nPROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\nOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS\nTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE\nPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\nREPAIR OR CORRECTION.\n\n  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\nREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\nINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\nOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\nTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\nYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\nPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGES.\n\n\t\t     END OF TERMS AND CONDITIONS\n\f\n\t    How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nconvey the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software; you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation; either version 2 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program; if not, write to the Free Software\n    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\n\n\nAlso add information on how to contact you by electronic and paper mail.\n\nIf the program is interactive, make it output a short notice like this\nwhen it starts in an interactive mode:\n\n    Gnomovision version 69, Copyright (C) year  name of author\n    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, the commands you use may\nbe called something other than `show w' and `show c'; they could even be\nmouse-clicks or menu items--whatever suits your program.\n\nYou should also get your employer (if you work as a programmer) or your\nschool, if any, to sign a \"copyright disclaimer\" for the program, if\nnecessary.  Here is a sample; alter the names:\n\n  Yoyodyne, Inc., hereby disclaims all copyright interest in the program\n  `Gnomovision' (which makes passes at compilers) written by James Hacker.\n\n  <signature of Ty Coon>, 1 April 1989\n  Ty Coon, President of Vice\n\nThis General Public License does not permit incorporating your program into\nproprietary programs.  If your program is a subroutine library, you may\nconsider it more useful to permit linking proprietary applications with the\nlibrary.  If this is what you want to do, use the GNU Library General\nPublic License instead of this License.\n"
  },
  {
    "path": "ext/yassl/ChangeLog",
    "content": ""
  },
  {
    "path": "ext/yassl/FLOSS-EXCEPTIONS",
    "content": "yaSSL FLOSS License Exception\n****************************************\n\nVersion 0.2, 31 August 2006\n\nThe Sawtooth Consulting Ltd. Exception for Free/Libre and Open Source\nSoftware-only Applications Using yaSSL Libraries (the \"FLOSS Exception\").\n\n*Exception Intent*\n\nWe want specified Free/Libre and Open Source Software (\"FLOSS\")\napplications to be able to use specified GPL-licensed yaSSL\nlibraries (the \"Program\") despite the fact that not all FLOSS\nlicenses are compatible with version 2 of the GNU General Public\nLicense (the \"GPL\").\n\n*Legal Terms and Conditions*\n\nAs a special exception to the terms and conditions of version 2.0 of\nthe GPL:\n\n  1.     You are free to distribute a Derivative Work that is formed\n     entirely from the Program and one or more works (each, a \"FLOSS\n     Work\") licensed under one or more of the licenses listed below\n     in section 1, as long as:\n\n       1.      You obey the GPL in all respects for the Program and the\n          Derivative Work, except for identifiable sections of the\n          Derivative Work which are not derived from the Program,\n          and which can reasonably be considered independent and\n          separate works in themselves,\n\n       2.      all identifiable sections of the Derivative Work which\n          are not derived from the Program, and which can reasonably be\n          considered independent and separate works in themselves,\n\n             *       i\n\n               are distributed subject to one of the FLOSS licenses\n               listed below, and\n\n             *       ii\n\n               the object code or executable form of those sections are\n               accompanied by the complete corresponding machine-readable\n               source code for those sections on the same medium and under\n               the same FLOSS license as the corresponding object code or\n               executable forms of those sections, and\n\n\n       3.      any works which are aggregated with the Program or with\n          a Derivative Work on a volume of a storage or distribution\n          medium in accordance with the GPL, can reasonably be considered\n          independent and separate works in themselves which are not\n          derivatives of either the Program, a Derivative Work or a FLOSS\n          Work.\n\n\n     If the above conditions are not met, then the Program may only be\n     copied, modified, distributed or used under the terms and\n     conditions of the GPL or another valid licensing option from\n     Sawtooth Consulting Ltd.\n\n  2.     FLOSS License List\n\n     *License name*                            *Version(s)/Copyright Date*\n     Academic Free License                              2.0\n     Apache Software License                            1.0/1.1/2.0\n     Apple Public Source License                        2.0\n     Artistic license                                   From Perl 5.8.0\n     BSD license                                        \"July 22 1999\"\n     Common Development and Distribution License (CDDL) 1.0\n     Common Public License                              1.0\n     GNU Library or \"Lesser\" General Public             2.0/2.1\n     License (LGPL)                           \n     Jabber Open Source License                         1.0\n     MIT license                                        -\n     Mozilla Public License (MPL)                       1.0/1.1\n     Open Software License                              2.0\n     PHP License                                        3.0\n     Python license (CNRI Python License)               -\n     Python Software Foundation License                 2.1.1\n     Sleepycat License                                  \"1999\"\n     University of Illinois/NCSA Open Source License    -\n     W3C License                                        \"2001\"\n     X11 License                                        \"2001\"\n     Zlib/libpng License                                -\n     Zope Public License                                2.0\n\n     Due to the many variants of some of the above licenses, we require\n     that any version follow the 2003 version of the Free Software\n     Foundation's Free Software Definition\n     (http://www.gnu.org/philosophy/free-sw.html\n     (http://www.gnu.org/philosophy/free-sw.html))    or version 1.9 of\n     the Open Source Definition by the Open Source    Initiative\n     (http://www.opensource.org/docs/definition.php\n     (http://www.opensource.org/docs/definition.php)).\n\n  3.     Definitions\n\n       1.      Terms used, but not defined, herein shall have the\n          meaning provided in the GPL.\n\n       2.      Derivative Work means a derivative work under copyright\n          law.\n\n\n  4.     Applicability This FLOSS Exception applies to all Programs that\n     contain a notice placed by Sawtooth Consulting Ltd. saying that the\n     Program may be distributed under the terms of this FLOSS Exception.\n     If you create or distribute a work which is a Derivative Work of\n     both the Program and any other work licensed under the GPL, then\n     this FLOSS Exception is not available for that work; thus, you\n     must remove the FLOSS Exception notice from that work and\n     comply with the GPL in all respects, including by retaining all\n     GPL notices. You may choose to redistribute a copy of the\n     Program exclusively under the terms of the GPL by removing the\n     FLOSS Exception notice from that copy of the Program, provided\n     that the copy has never been modified by you or any third party.\n\n\n"
  },
  {
    "path": "ext/yassl/INSTALL",
    "content": "Installation Instructions\n*************************\n\nCopyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,\n2006 Free Software Foundation, Inc.\n\nThis file is free documentation; the Free Software Foundation gives\nunlimited permission to copy, distribute and modify it.\n\nBasic Installation\n==================\n\nBriefly, the shell commands `./configure; make; make install' should\nconfigure, build, and install this package.  The following\nmore-detailed instructions are generic; see the `README' file for\ninstructions specific to this package.\n\n   The `configure' shell script attempts to guess correct values for\nvarious system-dependent variables used during compilation.  It uses\nthose values to create a `Makefile' in each directory of the package.\nIt may also create one or more `.h' files containing system-dependent\ndefinitions.  Finally, it creates a shell script `config.status' that\nyou can run in the future to recreate the current configuration, and a\nfile `config.log' containing compiler output (useful mainly for\ndebugging `configure').\n\n   It can also use an optional file (typically called `config.cache'\nand enabled with `--cache-file=config.cache' or simply `-C') that saves\nthe results of its tests to speed up reconfiguring.  Caching is\ndisabled by default to prevent problems with accidental use of stale\ncache files.\n\n   If you need to do unusual things to compile the package, please try\nto figure out how `configure' could check whether to do them, and mail\ndiffs or instructions to the address given in the `README' so they can\nbe considered for the next release.  If you are using the cache, and at\nsome point `config.cache' contains results you don't want to keep, you\nmay remove or edit it.\n\n   The file `configure.ac' (or `configure.in') is used to create\n`configure' by a program called `autoconf'.  You need `configure.ac' if\nyou want to change it or regenerate `configure' using a newer version\nof `autoconf'.\n\nThe simplest way to compile this package is:\n\n  1. `cd' to the directory containing the package's source code and type\n     `./configure' to configure the package for your system.\n\n     Running `configure' might take a while.  While running, it prints\n     some messages telling which features it is checking for.\n\n  2. Type `make' to compile the package.\n\n  3. Optionally, type `make check' to run any self-tests that come with\n     the package.\n\n  4. Type `make install' to install the programs and any data files and\n     documentation.\n\n  5. You can remove the program binaries and object files from the\n     source code directory by typing `make clean'.  To also remove the\n     files that `configure' created (so you can compile the package for\n     a different kind of computer), type `make distclean'.  There is\n     also a `make maintainer-clean' target, but that is intended mainly\n     for the package's developers.  If you use it, you may have to get\n     all sorts of other programs in order to regenerate files that came\n     with the distribution.\n\nCompilers and Options\n=====================\n\nSome systems require unusual options for compilation or linking that the\n`configure' script does not know about.  Run `./configure --help' for\ndetails on some of the pertinent environment variables.\n\n   You can give `configure' initial values for configuration parameters\nby setting variables in the command line or in the environment.  Here\nis an example:\n\n     ./configure CC=c99 CFLAGS=-g LIBS=-lposix\n\n   *Note Defining Variables::, for more details.\n\nCompiling For Multiple Architectures\n====================================\n\nYou can compile the package for more than one kind of computer at the\nsame time, by placing the object files for each architecture in their\nown directory.  To do this, you can use GNU `make'.  `cd' to the\ndirectory where you want the object files and executables to go and run\nthe `configure' script.  `configure' automatically checks for the\nsource code in the directory that `configure' is in and in `..'.\n\n   With a non-GNU `make', it is safer to compile the package for one\narchitecture at a time in the source code directory.  After you have\ninstalled the package for one architecture, use `make distclean' before\nreconfiguring for another architecture.\n\nInstallation Names\n==================\n\nBy default, `make install' installs the package's commands under\n`/usr/local/bin', include files under `/usr/local/include', etc.  You\ncan specify an installation prefix other than `/usr/local' by giving\n`configure' the option `--prefix=PREFIX'.\n\n   You can specify separate installation prefixes for\narchitecture-specific files and architecture-independent files.  If you\npass the option `--exec-prefix=PREFIX' to `configure', the package uses\nPREFIX as the prefix for installing programs and libraries.\nDocumentation and other data files still use the regular prefix.\n\n   In addition, if you use an unusual directory layout you can give\noptions like `--bindir=DIR' to specify different values for particular\nkinds of files.  Run `configure --help' for a list of the directories\nyou can set and what kinds of files go in them.\n\n   If the package supports it, you can cause programs to be installed\nwith an extra prefix or suffix on their names by giving `configure' the\noption `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.\n\nOptional Features\n=================\n\nSome packages pay attention to `--enable-FEATURE' options to\n`configure', where FEATURE indicates an optional part of the package.\nThey may also pay attention to `--with-PACKAGE' options, where PACKAGE\nis something like `gnu-as' or `x' (for the X Window System).  The\n`README' should mention any `--enable-' and `--with-' options that the\npackage recognizes.\n\n   For packages that use the X Window System, `configure' can usually\nfind the X include and library files automatically, but if it doesn't,\nyou can use the `configure' options `--x-includes=DIR' and\n`--x-libraries=DIR' to specify their locations.\n\nSpecifying the System Type\n==========================\n\nThere may be some features `configure' cannot figure out automatically,\nbut needs to determine by the type of machine the package will run on.\nUsually, assuming the package is built to be run on the _same_\narchitectures, `configure' can figure that out, but if it prints a\nmessage saying it cannot guess the machine type, give it the\n`--build=TYPE' option.  TYPE can either be a short name for the system\ntype, such as `sun4', or a canonical name which has the form:\n\n     CPU-COMPANY-SYSTEM\n\nwhere SYSTEM can have one of these forms:\n\n     OS KERNEL-OS\n\n   See the file `config.sub' for the possible values of each field.  If\n`config.sub' isn't included in this package, then this package doesn't\nneed to know the machine type.\n\n   If you are _building_ compiler tools for cross-compiling, you should\nuse the option `--target=TYPE' to select the type of system they will\nproduce code for.\n\n   If you want to _use_ a cross compiler, that generates code for a\nplatform different from the build platform, you should specify the\n\"host\" platform (i.e., that on which the generated programs will\neventually be run) with `--host=TYPE'.\n\nSharing Defaults\n================\n\nIf you want to set default values for `configure' scripts to share, you\ncan create a site shell script called `config.site' that gives default\nvalues for variables like `CC', `cache_file', and `prefix'.\n`configure' looks for `PREFIX/share/config.site' if it exists, then\n`PREFIX/etc/config.site' if it exists.  Or, you can set the\n`CONFIG_SITE' environment variable to the location of the site script.\nA warning: not all `configure' scripts look for a site script.\n\nDefining Variables\n==================\n\nVariables not defined in a site shell script can be set in the\nenvironment passed to `configure'.  However, some packages may run\nconfigure again during the build, and the customized values of these\nvariables may be lost.  In order to avoid this problem, you should set\nthem in the `configure' command line, using `VAR=value'.  For example:\n\n     ./configure CC=/usr/local2/bin/gcc\n\ncauses the specified `gcc' to be used as the C compiler (unless it is\noverridden in the site shell script).\n\nUnfortunately, this technique does not work for `CONFIG_SHELL' due to\nan Autoconf bug.  Until the bug is fixed you can use this workaround:\n\n     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash\n\n`configure' Invocation\n======================\n\n`configure' recognizes the following options to control how it operates.\n\n`--help'\n`-h'\n     Print a summary of the options to `configure', and exit.\n\n`--version'\n`-V'\n     Print the version of Autoconf used to generate the `configure'\n     script, and exit.\n\n`--cache-file=FILE'\n     Enable the cache: use and save the results of the tests in FILE,\n     traditionally `config.cache'.  FILE defaults to `/dev/null' to\n     disable caching.\n\n`--config-cache'\n`-C'\n     Alias for `--cache-file=config.cache'.\n\n`--quiet'\n`--silent'\n`-q'\n     Do not print messages saying which checks are being made.  To\n     suppress all normal output, redirect it to `/dev/null' (any error\n     messages will still be shown).\n\n`--srcdir=DIR'\n     Look for the package's source code in directory DIR.  Usually\n     `configure' can determine that directory automatically.\n\n`configure' also accepts some other, not widely useful, options.  Run\n`configure --help' for more details.\n\n"
  },
  {
    "path": "ext/yassl/NEWS",
    "content": ""
  },
  {
    "path": "ext/yassl/README",
    "content": "*** Note, Please read ***\n\nyaSSL takes a different approach to certificate verification than OpenSSL does.\nThe default policy for the client is to verify the server, this means that if\nyou don't load CAs to verify the server you'll get a connect error, unable to \nverify.  It you want to mimic OpenSSL behavior of not verifying the server and\nreducing security you can do this by calling:\n\nSSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, 0);\n\nbefore calling SSL_new();\n\n*** end Note ***\n\nyaSSL Patch notes, version 2.3.7b (3/18/2015)\n    This release of yaSSL fixes a potential crash with corrupted private keys.\n    Also detects bad keys earlier for user.\n\nyaSSL Release notes, version 2.3.7 (12/10/2014)\n    This release of yaSSL fixes the potential to process duplicate handshake\n    messages by explicitly marking/checking received handshake messages.\n\nyaSSL Release notes, version 2.3.6 (11/25/2014)\n\n    This release of yaSSL fixes some valgrind warnings/errors including\n    uninitialized reads and off by one index errors induced from fuzzing\n    the handshake.  These were reported by Oracle. \n\nyaSSL Release notes, version 2.3.5 (9/29/2014)\n\n    This release of yaSSL fixes an RSA Padding check vulnerability reported by\n    Intel Security Advanced Threat Research team\n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0 and note in 1.5.8.\n\n\nyaSSL Release notes, version 2.3.4 (8/15/2014)\n\n    This release of yaSSL adds checking to the input_buffer class itself.\n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0 and note in 1.5.8.\n\n\nyaSSL Release notes, version 2.3.2 (7/25/2014)\n\n    This release of yaSSL updates test certs.\n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0 and note in 1.5.8.\n\n\n*****************yaSSL Release notes, version 2.3.0 (12/5/2013)\n\n    This release of yaSSL updates asm for newer GCC versions.\n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0 and note in 1.5.8.\n\n\n*****************yaSSL Release notes, version 2.2.3 (4/23/2013)\n\n    This release of yaSSL updates the test certificates as they were expired\n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0 and note in 1.5.8.\n\n\n*****************yaSSL Release notes, version 2.2.2d (2/5/2013)\n\n    This release of yaSSL contains countermeasuers for the Lucky 13 TLS 1.1\n    CBC timing padding attack identified by Nadhem AlFardan and Kenneth Paterson\n    see: http://www.isg.rhul.ac.uk/tls/\n\n    It also adds SHA2 certificate verification and better checks for malicious\n    input.\n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0 and note in 1.5.8.\n\n\n*****************yaSSL Release notes, version 2.2.2 (7/5/2012)\n\n    This release of yaSSL contains bug fixes and more security checks around\n    malicious certificates.\n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0 and note in 1.5.8.\n\n\n*****************yaSSL Release notes, version 2.1.2 (9/2/2011)\n\n    This release of yaSSL contains bug fixes, better non-blocking support with\n    SSL_write, and OpenSSL RSA public key format support.\n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0 and note in 1.5.8.\n\n\n*****************yaSSL Release notes, version 2.0.0 (7/6/2010)\n\n    This release of yaSSL contains bug fixes, new testing certs,\n    and a security patch for a potential heap overflow on forged application\n    data processing.  Vulnerability discovered by Matthieu Bonetti from VUPEN\n    Security http://www.vupen.com.\n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0 and note in 1.5.8.\n\n\n*****************yaSSL Release notes, version 1.9.9 (1/26/2010)\n\n    This release of yaSSL contains bug fixes, the removal of assert() s and\n    a security patch for a buffer overflow possibility in certificate name\n    processing. \n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0 and note in 1.5.8.\n\n\n*****************yaSSL Release notes, version 1.9.8 (10/14/09)\n\n    This release of yaSSL contains bug fixes and adds new stream ciphers\n    Rabbit and HC-128\n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0 and note in 1.5.8.\n\n\n*****************yaSSL Release notes, version 1.9.6 (11/13/08)\n\n    This release of yaSSL contains bug fixes, adds autconf shared library\n    support and has better server suite detection based on certficate and\n    private key.\n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0 and note in 1.5.8.\n\n\n*****************yaSSL Release notes, version 1.9.2 (9/24/08)\n\n    This release of yaSSL contains bug fixes and improved certificate verify\n    callback support. \n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0 and note in 1.5.8.\n\n\n*****************yaSSL Release notes, version 1.8.8 (5/7/08)\n\n    This release of yaSSL contains bug fixes, and better socket handling. \n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0 and note in 1.5.8.\n\n\n*****************yaSSL Release notes, version 1.8.6 (1/31/08)\n\n    This release of yaSSL contains bug fixes, and fixes security problems\n    associated with using SSL 2.0 client hellos and improper input handling.\n    Please upgrade to this version if you are using a previous one. \n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0 and note in 1.5.8.\n\n\n*****************yaSSL Release notes, version 1.7.5 (10/15/07)\n\n    This release of yaSSL contains bug fixes, adds MSVC 2005 project support,\n    GCC 4.2 support, IPV6 support and test, and new test certificates. \n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0 and note in 1.5.8.\n\n\n*****************yaSSL Release notes, version 1.7.2 (8/20/07)\n\n    This release of yaSSL contains bug fixes and adds initial OpenVPN support.\n    Just configure at this point and beginning of build. \n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0 and note in 1.5.8.\n\n\n*****************yaSSL Release notes, version 1.6.8 (4/16/07)\n\n    This release of yaSSL contains bug fixes and adds SHA-256, SHA-512, SHA-224,\n    and SHA-384.\n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0 and note in 1.5.8.\n\n\n*****************yaSSL Release notes, version 1.6.0 (2/22/07)\n\n    This release of yaSSL contains bug fixes, portability enhancements, and\n    better X509 support.\n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0 and note in 1.5.8.\n\n*****************yaSSL Release notes, version 1.5.8 (1/10/07)\n\n    This release of yaSSL contains bug fixes, portability enhancements, and\n    support for GCC 4.1.1 and vs2005 sp1.\n\n\n\n    Since yaSSL now supports zlib, as does libcurl, the libcurl build test can\n    fail if yaSSL is built with zlib support since the zlib library isn't \n    passed.  You can do two things to fix this: \n\n        1) build yaSSL w/o zlib --without-zlib\n        2) or add flags to curl configure LDFLAGS=\"-lm -lz\"\n\n\n\n*****************yaSSL Release notes, version 1.5.0 (11/09/06)\n\n    This release of yaSSL contains bug fixes, portability enhancements,\n    and full TLS 1.1 support.  Use the functions:\n\n        SSL_METHOD *TLSv1_1_server_method(void);\n        SSL_METHOD *TLSv1_1_client_method(void);\n    \n    or the SSLv23 versions (even though yaSSL doesn't support SSL 2.0 the v23\n    means to pick the highest of SSL 3.0, TLS 1.0, or TLS 1.1).\n\n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0.\n\n\n\n****************yaSSL Release notes, version 1.4.5 (10/15/06)\n\n\n    This release of yaSSL contains bug fixes, portability enhancements,\n    zlib compression support, removal of assembly instructions at runtime if\n    not supported, and initial TLS 1.1 support.\n\n\n    Compression Notes:  yaSSL uses zlib for compression and the compression\n    should only be used if yaSSL is at both ends because the implementation\n    details aren't yet standard.  If you'd like to turn compression on use\n    the SSL_set_compression() function on the client before calling\n    SSL_connect().  If both the client and server were built with zlib support\n    then the connection will use compression.  If the client isn't built with\n    support then SSL_set_compression() will return an error (-1).\n\n    To build yaSSL with zlib support on Unix simply have zlib support on your\n    system and configure will find it if it's in the standard locations.  If\n    it's somewhere else use the option ./configure --with-zlib=DIR.  If you'd\n    like to disable compression support in yaSSL use ./configure --without-zlib.\n\n    To build yaSSL with zlib support on Windows:\n\n        1) download zlib from http://www.zlib.net/\n        2) follow the instructions in zlib from projects/visualc6/README.txt\n           for how to add the zlib project into the yaSSL workspace noting that\n           you'll need to add configuration support for \"Win32 Debug\" and\n           \"Win32 Release\" in note 3 under \"To use:\". \n        3) define HAVE_LIBZ when building yaSSL\n\n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0.\n\n\n********************yaSSL Release notes, version 1.4.0 (08/13/06)\n\n\n    This release of yaSSL contains bug fixes, portability enhancements,\n    nonblocking connect and accept, better OpenSSL error mapping, and \n    certificate caching for session resumption.\n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0.\n\n\n********************yaSSL Release notes, version 1.3.7 (06/26/06)\n\n\n    This release of yaSSL contains bug fixes, portability enhancements,\n    and libcurl 7.15.4 support (any newer versions may not build). \n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0.\n\n\n********************yaSSL Release notes, version 1.3.5 (06/01/06)\n\n\n    This release of yaSSL contains bug fixes, portability enhancements,\n    better libcurl support, and improved non-blocking I/O.\n\nSee normal  build instructions below under 1.0.6.\nSee libcurl build instructions below under 1.3.0.\n\n\n********************yaSSL Release notes, version 1.3.0 (04/26/06)\n\n\n    This release of yaSSL contains minor bug fixes, portability enhancements,\n    and libcurl support.\n\nSee normal build instructions below under 1.0.6.\n\n\n--To build for libcurl on Linux, Solaris, *BSD, Mac OS X, or Cygwin:\n\n  To build for libcurl the library needs to be built without C++ globals since\n  the linker will be called in a C context, also libcurl configure will expect\n  OpenSSL library names so some symbolic links are created.\n\n    ./configure --enable-pure-c\n    make\n    make openssl-links\n\n    (then go to your libcurl home and tell libcurl about yaSSL build dir)\n    ./configure --with-ssl=/yaSSL-BuildDir LDFLAGS=-lm\n    make\n\n\n--To build for libcurl on Win32:\n\n    Simply add the yaSSL project as a dependency to libcurl, add \n    yaSSL-Home\\include and yaSSL-Home\\include\\openssl to the include list, and\n    define USE_SSLEAY and USE_OPENSSL\n\n    please email todd@yassl.com if you have any questions.\n    \n\n*******************yaSSL Release notes, version 1.2.2 (03/27/06)\n\n\n    This release of yaSSL contains minor bug fixes and portability enhancements.\n\nSee build instructions below under 1.0.6:\n\n\n\n*******************yaSSL Release notes, version 1.2.0\n\n\n    This release of yaSSL contains minor bug fixes, portability enhancements,\n    Diffie-Hellman compatibility fixes for other servers and client,\n    optimization improvements, and x86 ASM changes.\n\nSee build instructions below under 1.0.6:\n\n\n\n*****************yaSSL Release notes, version 1.1.5\n\n    This release of yaSSL contains minor bug fixes, portability enhancements,\n    and user requested changes including the ability to add all certificates in\n    a directory, more robust socket handling, no new overloading unless\n    requested, and an SSL_VERIFY_NONE option.\n\n\nSee build instructions below under 1.0.6:\n\n\n\n******************yaSSL Release notes, version 1.0.6\n\nThis release of yaSSL contains minor bug fixes, portability enhancements,\nx86 assembly for ARC4, SHA, MD5, and RIPEMD, --enable-ia32-asm configure\noption, and a security patch for certificate chain processing.\n\n--To build on Linux, Solaris, *BSD, Mac OS X, or Cygwin:\n\n    ./configure\n    make\n\n    run testsuite from yaSSL-Home/testsuite to test the build\n\nto make a release build:\n\n    ./configure --disable-debug\n    make\n\n    run testsuite from yaSSL-Home/testsuite to test the build\n\n\n--To build on Win32\n\nChoose (Re)Build All from the project workspace\n\nrun Debug\\testsuite.exe from yaSSL-Home\\testsuite to test the build\n\n\n\n***************** yaSSL Release notes, version 1.0.5\n\nThis release of yaSSL contains minor bug fixes, portability enhancements,\nx86 assembly for AES, 3DES, BLOWFISH, and TWOFISH, --without-debug configure\noption, and --enable-kernel-mode configure option for using TaoCrypt with\nkernel modules.\n\n--To build on Linux, Solaris, *BSD, Mac OS X, or Cygwin:\n\n    ./configure\n    make\n\n    run testsuite from yaSSL-Home/testsuite to test the build\n\nto make a release build:\n\n    ./configure --without-debug\n    make\n\n    run testsuite from yaSSL-Home/testsuite to test the build\n\n\n--To build on Win32\n\nChoose (Re)Build All from the project workspace\n\nrun Debug\\testsuite.exe from yaSSL-Home\\testsuite to test the build\n\n\n******************yaSSL Release notes, version 1.0.1\n\nThis release of yaSSL contains minor bug fixes, portability enhancements,\nGCC 3.4.4 support, MSVC 2003 support, and more documentation.\n\nPlease see build instructions in the release notes for 0.9.6 below.\n\n\n******************yaSSL Release notes, version 1.0\n\nThis release of yaSSL contains minor bug fixes, portability enhancements,\nGCC 4.0 support, testsuite, improvements, and API additions.\n\nPlease see build instructions in the release notes for 0.9.6 below.\n\n\n******************yaSSL Release notes, version 0.9.9\n\nThis release of yaSSL contains minor bug fixes, portability enchancements,\nMSVC 7 support, memory improvements, and API additions.\n\nPlease see build instructions in the release notes for 0.9.6 below.\n\n\n******************yaSSL Release notes, version 0.9.8\n\nThis release of yaSSL contains minor bug fixes and portability enchancements.\n\nPlease see build instructions in the release notes for 0.9.6 below.\n\n\n******************yaSSL Release notes, version 0.9.6\n\nThis release of yaSSL contains minor bug fixes, removal of STL support, and\nremoval of exceptions and rtti so that the library can be linked without the\nstd c++ library.\n\n--To build on Linux, Solaris, FreeBSD, Mac OS X, or Cygwin\n\n./configure\nmake\n\nrun testsuite from yaSSL-Home/testsuite to test the build\n\n\n--To build on Win32\n\nChoose (Re)Build All from the project workspace\n\nrun Debug\\testsuite.exe from yaSSL-Home\\testsuite to test the build\n\n\n\n******************yaSSL Release notes, version 0.9.2\n\nThis release of yaSSL contains minor bug fixes, expanded certificate\nverification and chaining, and improved documentation.\n\nPlease see build instructions in release notes 0.3.0.\n\n\n\n******************yaSSL Release notes, version 0.9.0\n\nThis release of yaSSL contains minor bug fixes, client verification handling,\nhex and base64 encoing/decoding, and an improved test suite.\n\nPlease see build instructions in release notes 0.3.0.\n\n\n******************yaSSL Release notes, version 0.8.0\n\nThis release of yaSSL contains minor bug fixes, and initial porting effort to\n64bit, BigEndian, and more UNIX systems.\n\nPlease see build instructions in release notes 0.3.0.\n\n\n******************yaSSL Release notes, version 0.6.0\n\nThis release of yaSSL contains minor bug fixes, source cleanup, and binary beta\n(1) of the yaSSL libraries.\n\nPlease see build instructions in release notes 0.3.0.\n\n\n\n******************yaSSL Release notes, version 0.5.0\n\nThis release of yaSSL contains minor bug fixes, full session resumption\nsupport, and initial testing suite support.\n\n\n\nPlease see build instructions in release notes 0.3.0.\n\n\n\n******************yaSSL Release notes, version 0.4.0\n\nThis release of yaSSL contains minor bug fixes, an optional memory tracker,\nan echo client and server with input/output redirection for load testing, \nand initial session caching support. \n\n\nPlease see build instructions in release notes 0.3.0.\n\n\n******************yaSSL Release notes, version 0.3.5\n\nThis release of yaSSL contains minor bug fixes and extensions to the crypto\nlibrary including a full test suite.\n\n\n*******************yaSSL Release notes, version 0.3.0\n\nThis release of yaSSL contains minor bug fixes and extensions to the crypto\nlibrary including AES and an improved random number generator.  GNU autoconf\nand automake are now used to simplify the build process on Linux.\n\n*** Linux Build process\n\n./configure\nmake\n\n*** Windows Build process\n\nopen the yassl workspace and build the project\n\n\n*******************yaSSL Release notes, version 0.2.9\n\nThis release of yaSSL contains minor bug fixes and extensions to the crypto\nlibrary.\n\nSee the notes at the bottom of this page for build instructions.\n\n\n*******************yaSSL Release notes, version 0.2.5\n\nThis release of yaSSL contains minor bug fixes and a beta binary of the yaSSL\nlibraries for win32 and linux.\n\nSee the notes at the bottom of this page for build instructions.\n\n\n\n*******************yaSSL Release notes, version 0.2.0\n\nThis release of yaSSL contains minor bug fixes and initial alternate crypto\nfunctionality. \n\n*** Complete Build ***\n\nSee the notes in Readme.txt for build instructions.\n\n*** Update Build ***\n\nIf you have already done a complete build of yaSSL as described in the release\n0.0.1 - 0.1.0 notes and downloaded the update to 0.2.0, place the update file\nyassl-update-0.2.0.tar.gz in the yaSSL home directory and issue the command:\n\ngzip -cd yassl-update-0.2.0.tar.gz | tar xvf -\n\nto update the previous release.\n\nThen issue the make command on linux or rebuild the yaSSL project on Windows. \n\n*******************yaSSL Release notes, version 0.1.0\n\nThis release of yaSSL contains minor bug fixes, full client and server TLSv1\nsupport including full ephemeral Diffie-Hellman support, SSL type RSA and DSS\nsigning and verification, and initial stunnel 4.05 build support.\n\n\n\n*********************yaSSL Release notes, version 0.0.3\n\nThe third release of yaSSL contains minor bug fixes, client certificate\nenhancements, and initial ephemeral Diffie-Hellman integration:\n\n\n\n*********************\n\nyaSSL Release notes, version 0.0.2\n\nThe second release of yaSSL contains minor bug fixes, client certificate\nenhancements, session resumption, and improved TLS support including:\n\n- HMAC for MD5 and SHA-1\n- PRF (pseudo random function)\n- Master Secret and Key derivation routines\n- Record Authentication codes\n- Finish verify data check\n\nOnce ephemeral RSA and DH are added yaSSL will be fully complaint with TLS.\n\n\n\n**********************\n\nyassl Release notes, version 0.0.1\n\nThe first release of yassl supports normal RSA mode SSLv3 connections with\nsupport for SHA-1 and MD5 digests.  Ciphers include DES, 3DES, and RC4.\n\nyassl uses the CryptoPP library for cryptography, the source is available at\nwww.cryptopp.com .\n\nyassl uses CML (the Certificate Management Library) for x509 support.  More\nfeatures will be in future versions.  The CML source is available for download\nfrom www.digitalnet.com/knowledge/cml_home.htm .\n\nThe next release of yassl will support the 3 lesser-used SSL connection modes;\nHandShake resumption, Ephemeral RSA (or DH), and Client Authentication as well\nas full support for TLS.  Backwards support for SSLv2 is not planned at this\ntime.\n\n\n**********************\n\nBuilding yassl on linux:\n\nuse the ./buildall script to build everything.\n\nbuildall will configure and build CML, CryptoPP, and yassl.  Testing was \npreformed with gcc version 3.3.2 on kernel 2.4.22.\n\n\n**********************\n\nBuilding yassl on Windows:\n\nTesting was preformed on Windows 2000 with Visual C++ 6 sp5.\n\n1) decompress esnacc_r16.tgz in place, see buildall for syntax if unsure\n\n2) decompress smp_r23.tgz in place\n\n3) unzip cryptopp51/crypto51.zip in place\n\n4) Build SNACC (part of CML) using snacc_builds.dsw in the SNACC directory\n\n5) Build SMP (part of CMP) using smp.dsw in the smp directory\n\n6) Build yassl using yassl.dsw\n\n\n**********************\n\nexamples, server and client:\n\nPlease see the server and client examples in both versions to see how to link\nto yassl and the support libraries.  On linux do 'make server' and 'make\nclient' to build them. On Windows you will find the example projects in the\nmain workspace, yassl.dsw.\n\nThe example server and client are compatible with openssl.\n\n\n**********************\n\nBuilding yassl into mysql on linux:\n\nTesting was done using mysql version 4.0.17.\n\nalter openssl_libs in the configure file, line 21056. Change '-lssl -lcrypto'\nto '-lyassl -lcryptopp -lcmapi -lcmlasn -lctil -lc++asn1'.\n\nsee build/config_command for the configure command used to configure mysql\nplease change /home/touska/ to the relevant directory of course.\n\nadd yassl/lib to the LD_LIBRARY_PATH because libmysql/conf_to_src does not\nuse the ssl lib directory though it does use the ssl libraries.\n\nmake\n\nmake install\n\n\n*********************\n\nLicense:  yassl is currently under the GPL, please see license information\nin the source and include files.\n\n\n*********************\n\nContact: please send comments or questions to Todd A Ouska at todd@yassl.com\nand/or Larry Stefonic at larry@yassl.com.\n\n\n\n"
  },
  {
    "path": "ext/yassl/certs/ca-cert.pem",
    "content": "-----BEGIN CERTIFICATE-----\nMIIEqjCCA5KgAwIBAgIJAJpBR82hFGKMMA0GCSqGSIb3DQEBBQUAMIGUMQswCQYD\nVQQGEwJVUzEQMA4GA1UECAwHTW9udGFuYTEQMA4GA1UEBwwHQm96ZW1hbjERMA8G\nA1UECgwIU2F3dG9vdGgxEzARBgNVBAsMCkNvbnN1bHRpbmcxGDAWBgNVBAMMD3d3\ndy53b2xmc3NsLmNvbTEfMB0GCSqGSIb3DQEJARYQaW5mb0B3b2xmc3NsLmNvbTAe\nFw0xNDA3MTEwMzIwMDhaFw0xNzA0MDYwMzIwMDhaMIGUMQswCQYDVQQGEwJVUzEQ\nMA4GA1UECAwHTW9udGFuYTEQMA4GA1UEBwwHQm96ZW1hbjERMA8GA1UECgwIU2F3\ndG9vdGgxEzARBgNVBAsMCkNvbnN1bHRpbmcxGDAWBgNVBAMMD3d3dy53b2xmc3Ns\nLmNvbTEfMB0GCSqGSIb3DQEJARYQaW5mb0B3b2xmc3NsLmNvbTCCASIwDQYJKoZI\nhvcNAQEBBQADggEPADCCAQoCggEBAL8Myi0Ush6EQlvNOB9K8k11EPG2NZ/fyn0D\nmNOs3gNm7irx2LB9bgdUCxCYIU2AyxIg58xP3kV9yXJ3MurKkLtpUhADL6jzlcXx\ni2JWG+9nb6QQQZWtCpvjpcCw0nB2UDBbqOgILHztp6J6jTgpHKzH7fJ8lbCVgn1J\nXDjNdyXvvYB1U5Q8PcpjW58VtdMdEy8Z0TzbdjrMuH3J5cLX2kBv2CHccxtCLVOc\n/hr8fat6Nj+Y3oR8BWfOahQ4h6nxjLVoy2h/cSAr9aBj9VYvoybSt2+xWhfXOJkI\n/pNYb/7DE0kIFgunTWcAUjFnI06Y7VFFHbkE2Qvs2CizS73tNnkCAwEAAaOB/DCB\n+TAdBgNVHQ4EFgQUJ45nEXTDJh0/7TNjs6TYHTDl6NUwgckGA1UdIwSBwTCBvoAU\nJ45nEXTDJh0/7TNjs6TYHTDl6NWhgZqkgZcwgZQxCzAJBgNVBAYTAlVTMRAwDgYD\nVQQIDAdNb250YW5hMRAwDgYDVQQHDAdCb3plbWFuMREwDwYDVQQKDAhTYXd0b290\naDETMBEGA1UECwwKQ29uc3VsdGluZzEYMBYGA1UEAwwPd3d3LndvbGZzc2wuY29t\nMR8wHQYJKoZIhvcNAQkBFhBpbmZvQHdvbGZzc2wuY29tggkAmkFHzaEUYowwDAYD\nVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAeXgMbXmIkfw6FZz5J2IW8CEf\n+n0/oqgyHvfyEal0FnRe3BjK8AAq1QMGJjDxR4P9Mm787apPfQxjYDEvfAy/mWaH\n7ScIhi3EM+iYIxz+o9uaSU78WkLvccM/rdxKqNKjHQmsMwR7hvNtAFmjyNvRPHP2\nDpDWXkngvzZjCHulsI81O1aMETVJBBzQ57pWxQ0KkY3Wt2IZNBJSTNJtfMU9DxiB\nVMv2POWE0tZxFewaNAvwoCF0Q8ijsN/ZZ9rirZNI+KCHvXkU4GIK3/cxLjF70TIq\nCv5dFO/ZZFDkg5G8cA3XiI3ZvIQOxRqzv2QCTlGRpKKFFYOv8FubKElfsrMD2A==\n-----END CERTIFICATE-----\nCertificate:\n    Data:\n        Version: 3 (0x2)\n        Serial Number:\n            9a:41:47:cd:a1:14:62:8c\n    Signature Algorithm: sha1WithRSAEncryption\n        Issuer: C=US, ST=Montana, L=Bozeman, O=Sawtooth, OU=Consulting, CN=www.wolfssl.com/emailAddress=info@wolfssl.com\n        Validity\n            Not Before: Jul 11 03:20:08 2014 GMT\n            Not After : Apr  6 03:20:08 2017 GMT\n        Subject: C=US, ST=Montana, L=Bozeman, O=Sawtooth, OU=Consulting, CN=www.wolfssl.com/emailAddress=info@wolfssl.com\n        Subject Public Key Info:\n            Public Key Algorithm: rsaEncryption\n                Public-Key: (2048 bit)\n                Modulus:\n                    00:bf:0c:ca:2d:14:b2:1e:84:42:5b:cd:38:1f:4a:\n                    f2:4d:75:10:f1:b6:35:9f:df:ca:7d:03:98:d3:ac:\n                    de:03:66:ee:2a:f1:d8:b0:7d:6e:07:54:0b:10:98:\n                    21:4d:80:cb:12:20:e7:cc:4f:de:45:7d:c9:72:77:\n                    32:ea:ca:90:bb:69:52:10:03:2f:a8:f3:95:c5:f1:\n                    8b:62:56:1b:ef:67:6f:a4:10:41:95:ad:0a:9b:e3:\n                    a5:c0:b0:d2:70:76:50:30:5b:a8:e8:08:2c:7c:ed:\n                    a7:a2:7a:8d:38:29:1c:ac:c7:ed:f2:7c:95:b0:95:\n                    82:7d:49:5c:38:cd:77:25:ef:bd:80:75:53:94:3c:\n                    3d:ca:63:5b:9f:15:b5:d3:1d:13:2f:19:d1:3c:db:\n                    76:3a:cc:b8:7d:c9:e5:c2:d7:da:40:6f:d8:21:dc:\n                    73:1b:42:2d:53:9c:fe:1a:fc:7d:ab:7a:36:3f:98:\n                    de:84:7c:05:67:ce:6a:14:38:87:a9:f1:8c:b5:68:\n                    cb:68:7f:71:20:2b:f5:a0:63:f5:56:2f:a3:26:d2:\n                    b7:6f:b1:5a:17:d7:38:99:08:fe:93:58:6f:fe:c3:\n                    13:49:08:16:0b:a7:4d:67:00:52:31:67:23:4e:98:\n                    ed:51:45:1d:b9:04:d9:0b:ec:d8:28:b3:4b:bd:ed:\n                    36:79\n                Exponent: 65537 (0x10001)\n        X509v3 extensions:\n            X509v3 Subject Key Identifier: \n                27:8E:67:11:74:C3:26:1D:3F:ED:33:63:B3:A4:D8:1D:30:E5:E8:D5\n            X509v3 Authority Key Identifier: \n                keyid:27:8E:67:11:74:C3:26:1D:3F:ED:33:63:B3:A4:D8:1D:30:E5:E8:D5\n                DirName:/C=US/ST=Montana/L=Bozeman/O=Sawtooth/OU=Consulting/CN=www.wolfssl.com/emailAddress=info@wolfssl.com\n                serial:9A:41:47:CD:A1:14:62:8C\n\n            X509v3 Basic Constraints: \n                CA:TRUE\n    Signature Algorithm: sha1WithRSAEncryption\n         79:78:0c:6d:79:88:91:fc:3a:15:9c:f9:27:62:16:f0:21:1f:\n         fa:7d:3f:a2:a8:32:1e:f7:f2:11:a9:74:16:74:5e:dc:18:ca:\n         f0:00:2a:d5:03:06:26:30:f1:47:83:fd:32:6e:fc:ed:aa:4f:\n         7d:0c:63:60:31:2f:7c:0c:bf:99:66:87:ed:27:08:86:2d:c4:\n         33:e8:98:23:1c:fe:a3:db:9a:49:4e:fc:5a:42:ef:71:c3:3f:\n         ad:dc:4a:a8:d2:a3:1d:09:ac:33:04:7b:86:f3:6d:00:59:a3:\n         c8:db:d1:3c:73:f6:0e:90:d6:5e:49:e0:bf:36:63:08:7b:a5:\n         b0:8f:35:3b:56:8c:11:35:49:04:1c:d0:e7:ba:56:c5:0d:0a:\n         91:8d:d6:b7:62:19:34:12:52:4c:d2:6d:7c:c5:3d:0f:18:81:\n         54:cb:f6:3c:e5:84:d2:d6:71:15:ec:1a:34:0b:f0:a0:21:74:\n         43:c8:a3:b0:df:d9:67:da:e2:ad:93:48:f8:a0:87:bd:79:14:\n         e0:62:0a:df:f7:31:2e:31:7b:d1:32:2a:0a:fe:5d:14:ef:d9:\n         64:50:e4:83:91:bc:70:0d:d7:88:8d:d9:bc:84:0e:c5:1a:b3:\n         bf:64:02:4e:51:91:a4:a2:85:15:83:af:f0:5b:9b:28:49:5f:\n         b2:b3:03:d8\n"
  },
  {
    "path": "ext/yassl/certs/ca-key.pem",
    "content": "-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEAvwzKLRSyHoRCW804H0ryTXUQ8bY1n9/KfQOY06zeA2buKvHY\nsH1uB1QLEJghTYDLEiDnzE/eRX3Jcncy6sqQu2lSEAMvqPOVxfGLYlYb72dvpBBB\nla0Km+OlwLDScHZQMFuo6AgsfO2nonqNOCkcrMft8nyVsJWCfUlcOM13Je+9gHVT\nlDw9ymNbnxW10x0TLxnRPNt2Osy4fcnlwtfaQG/YIdxzG0ItU5z+Gvx9q3o2P5je\nhHwFZ85qFDiHqfGMtWjLaH9xICv1oGP1Vi+jJtK3b7FaF9c4mQj+k1hv/sMTSQgW\nC6dNZwBSMWcjTpjtUUUduQTZC+zYKLNLve02eQIDAQABAoIBAD1uTmAahH+dhXzh\nSwd84NaZKt6d+TY0DncOPgjqT+UGJtT2OPffDQ8cLgai9CponGNy4zXmBJGRtcGx\npFSs18b7QaDWdW+9C06/sVLoX0kmmFZHx97p6jxgAb8o3DG/SV+TSYd6gVuWS03K\nXDhPt+Gy08ch2jwShwfkG9xD7OjsVGHn9u2mCy7134J/xh9hGZykgznfIYWJb3ev\nhhUyCKJaCyZh+3AMypw4fbwi7uujqBYA+YqAHgCEqEpB+IQDZy8jWy+baybDBzSU\nowM7ctWfcuCtzDSrvcfV9SYwhQ8wIzlS/zzLmSFNiKWr7mK5x+C7R4fBac9z8zC+\nzjkEnOUCgYEA4XZFgFm200nfCu8S1g/wt8sqN7+n+LVN9TE1reSjlKHb8ZattQVk\nhYP8G1spqr74Jj92fq0c8MvXJrQbBY5Whn4IYiHBhtZHeT63XaTGOtexdCD2UJdB\nBFPtPybWb5H6aCbsKtya8efc+3PweUMbIaNZBGNSB8nX5tEbXV6W+lMCgYEA2O1O\nZGFrkQxhAbUPu0RnUx7cB8Qkfp5shCORDOQSBBZNeJjMlj0gTg9Fmrb4s5MNsqIb\nKfImecjF0nh+XnPy13Bhu0DOYQX+aR6CKeYUuKHnltAjPwWTAPLhTX7tt5Zs9/Dk\n0c8BmE/cdFSqbV5aQTH+/5q2oAXdqRBU+GvQqoMCgYAh0wSKROtQt3xmv4cr5ihO\n6oPi6TXh8hFH/6H1/J8t5TqB/AEDb1OtVCe2Uu7lVtETq+GzD3WQCoS0ocCMDNae\nRrorPrUx7WO7pNUNj3LN0R4mNeu+G3L9mzm0h7cT9eqDRZOYuo/kSsy0TKh/CLpB\nSahJKD1ePcHONwDL+SzdUQKBgQChV58+udavg22DP4/70NyozgMJI7GhG2PKxElW\nNSvRLmVglQVVmRE1/dXfRMeliHJfsoJRqHFFkzbPXB9hUQwFgOivxXu6XiLjPHXD\nhAVVbdY6LYSJkzPLONqqMQXNzmwt3VXTVwvwpTVqsK4xukOWygDHS+MZEkPTQvpv\n6oDA0QKBgQC524kgNCdwYjTqXyViEvOdgb9I7poOwY0Q/2WanS0aipRayMClpYRh\nntQkue+pncl3C8dwZj26yFTf0jPh9X/5J2G+V0Xdt0UXJPUj5DgOkSfu4yDYFMiU\nR3dAd0UYng3OeT9XMVYJSWe+lFhP9sSr4onj44rABVUsJMBKlwQnmg==\n-----END RSA PRIVATE KEY-----\n"
  },
  {
    "path": "ext/yassl/certs/client-cert.pem",
    "content": "Certificate:\n    Data:\n        Version: 3 (0x2)\n        Serial Number:\n            b6:63:af:8f:5d:62:57:a0\n    Signature Algorithm: sha1WithRSAEncryption\n        Issuer: C=US, ST=Montana, L=Bozeman, O=wolfSSL, OU=Programming, CN=www.wolfssl.com/emailAddress=info@wolfssl.com\n        Validity\n            Not Before: Jul 11 17:39:44 2014 GMT\n            Not After : Apr  6 17:39:44 2017 GMT\n        Subject: C=US, ST=Montana, L=Bozeman, O=wolfSSL, OU=Programming, CN=www.wolfssl.com/emailAddress=info@wolfssl.com\n        Subject Public Key Info:\n            Public Key Algorithm: rsaEncryption\n                Public-Key: (2048 bit)\n                Modulus:\n                    00:c3:03:d1:2b:fe:39:a4:32:45:3b:53:c8:84:2b:\n                    2a:7c:74:9a:bd:aa:2a:52:07:47:d6:a6:36:b2:07:\n                    32:8e:d0:ba:69:7b:c6:c3:44:9e:d4:81:48:fd:2d:\n                    68:a2:8b:67:bb:a1:75:c8:36:2c:4a:d2:1b:f7:8b:\n                    ba:cf:0d:f9:ef:ec:f1:81:1e:7b:9b:03:47:9a:bf:\n                    65:cc:7f:65:24:69:a6:e8:14:89:5b:e4:34:f7:c5:\n                    b0:14:93:f5:67:7b:3a:7a:78:e1:01:56:56:91:a6:\n                    13:42:8d:d2:3c:40:9c:4c:ef:d1:86:df:37:51:1b:\n                    0c:a1:3b:f5:f1:a3:4a:35:e4:e1:ce:96:df:1b:7e:\n                    bf:4e:97:d0:10:e8:a8:08:30:81:af:20:0b:43:14:\n                    c5:74:67:b4:32:82:6f:8d:86:c2:88:40:99:36:83:\n                    ba:1e:40:72:22:17:d7:52:65:24:73:b0:ce:ef:19:\n                    cd:ae:ff:78:6c:7b:c0:12:03:d4:4e:72:0d:50:6d:\n                    3b:a3:3b:a3:99:5e:9d:c8:d9:0c:85:b3:d9:8a:d9:\n                    54:26:db:6d:fa:ac:bb:ff:25:4c:c4:d1:79:f4:71:\n                    d3:86:40:18:13:b0:63:b5:72:4e:30:c4:97:84:86:\n                    2d:56:2f:d7:15:f7:7f:c0:ae:f5:fc:5b:e5:fb:a1:\n                    ba:d3\n                Exponent: 65537 (0x10001)\n        X509v3 extensions:\n            X509v3 Subject Key Identifier: \n                33:D8:45:66:D7:68:87:18:7E:54:0D:70:27:91:C7:26:D7:85:65:C0\n            X509v3 Authority Key Identifier: \n                keyid:33:D8:45:66:D7:68:87:18:7E:54:0D:70:27:91:C7:26:D7:85:65:C0\n                DirName:/C=US/ST=Montana/L=Bozeman/O=wolfSSL/OU=Programming/CN=www.wolfssl.com/emailAddress=info@wolfssl.com\n                serial:B6:63:AF:8F:5D:62:57:A0\n\n            X509v3 Basic Constraints: \n                CA:TRUE\n    Signature Algorithm: sha1WithRSAEncryption\n         85:10:90:c5:5d:de:25:8c:f2:57:7b:2d:14:1c:05:f9:71:63:\n         40:b0:e3:c1:c1:2e:13:2a:7a:b7:d6:24:58:87:eb:03:fb:0d:\n         af:e0:f4:d0:c8:bc:51:36:10:4f:79:cc:4f:66:7d:af:99:cb:\n         7b:ce:68:94:c6:36:aa:42:6e:8c:78:5b:b2:85:ca:d1:e1:a8:\n         31:d1:81:d9:f9:c1:a3:9e:34:43:ef:0a:79:7d:3e:83:61:fc:\n         14:5c:d1:dd:bc:0e:d7:51:b7:71:6e:41:7e:8b:2c:5a:9a:cb:\n         77:4b:6a:f5:06:ff:02:af:1e:e6:63:4f:bc:44:d9:3f:56:9e:\n         09:9c:43:f9:55:21:32:46:82:09:86:a9:7b:74:1c:9e:5a:2a:\n         bf:03:79:91:cb:f2:29:7f:c9:15:82:89:b9:53:cd:7e:07:90:\n         a9:5d:76:e1:19:5e:0d:58:b8:59:d5:0d:df:23:ab:6b:63:76:\n         19:9e:9c:df:b0:57:49:6c:d0:86:97:c3:6c:3c:fa:e0:56:c2:\n         1b:e3:a1:42:1a:58:62:85:9d:74:19:83:08:af:59:90:f8:99:\n         bd:67:d3:4a:ea:0e:c9:ca:61:8a:0d:8a:42:cc:90:e9:2e:c2:\n         54:73:7f:5e:af:8d:e2:32:cb:45:20:d6:19:4d:5b:77:31:cc:\n         0f:2d:c0:7e\n-----BEGIN CERTIFICATE-----\nMIIEqjCCA5KgAwIBAgIJALZjr49dYlegMA0GCSqGSIb3DQEBBQUAMIGUMQswCQYD\nVQQGEwJVUzEQMA4GA1UECAwHTW9udGFuYTEQMA4GA1UEBwwHQm96ZW1hbjEQMA4G\nA1UECgwHd29sZlNTTDEUMBIGA1UECwwLUHJvZ3JhbW1pbmcxGDAWBgNVBAMMD3d3\ndy53b2xmc3NsLmNvbTEfMB0GCSqGSIb3DQEJARYQaW5mb0B3b2xmc3NsLmNvbTAe\nFw0xNDA3MTExNzM5NDRaFw0xNzA0MDYxNzM5NDRaMIGUMQswCQYDVQQGEwJVUzEQ\nMA4GA1UECAwHTW9udGFuYTEQMA4GA1UEBwwHQm96ZW1hbjEQMA4GA1UECgwHd29s\nZlNTTDEUMBIGA1UECwwLUHJvZ3JhbW1pbmcxGDAWBgNVBAMMD3d3dy53b2xmc3Ns\nLmNvbTEfMB0GCSqGSIb3DQEJARYQaW5mb0B3b2xmc3NsLmNvbTCCASIwDQYJKoZI\nhvcNAQEBBQADggEPADCCAQoCggEBAMMD0Sv+OaQyRTtTyIQrKnx0mr2qKlIHR9am\nNrIHMo7Quml7xsNEntSBSP0taKKLZ7uhdcg2LErSG/eLus8N+e/s8YEee5sDR5q/\nZcx/ZSRppugUiVvkNPfFsBST9Wd7Onp44QFWVpGmE0KN0jxAnEzv0YbfN1EbDKE7\n9fGjSjXk4c6W3xt+v06X0BDoqAgwga8gC0MUxXRntDKCb42GwohAmTaDuh5AciIX\n11JlJHOwzu8Zza7/eGx7wBID1E5yDVBtO6M7o5lencjZDIWz2YrZVCbbbfqsu/8l\nTMTRefRx04ZAGBOwY7VyTjDEl4SGLVYv1xX3f8Cu9fxb5fuhutMCAwEAAaOB/DCB\n+TAdBgNVHQ4EFgQUM9hFZtdohxh+VA1wJ5HHJteFZcAwgckGA1UdIwSBwTCBvoAU\nM9hFZtdohxh+VA1wJ5HHJteFZcChgZqkgZcwgZQxCzAJBgNVBAYTAlVTMRAwDgYD\nVQQIDAdNb250YW5hMRAwDgYDVQQHDAdCb3plbWFuMRAwDgYDVQQKDAd3b2xmU1NM\nMRQwEgYDVQQLDAtQcm9ncmFtbWluZzEYMBYGA1UEAwwPd3d3LndvbGZzc2wuY29t\nMR8wHQYJKoZIhvcNAQkBFhBpbmZvQHdvbGZzc2wuY29tggkAtmOvj11iV6AwDAYD\nVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAhRCQxV3eJYzyV3stFBwF+XFj\nQLDjwcEuEyp6t9YkWIfrA/sNr+D00Mi8UTYQT3nMT2Z9r5nLe85olMY2qkJujHhb\nsoXK0eGoMdGB2fnBo540Q+8KeX0+g2H8FFzR3bwO11G3cW5BfossWprLd0tq9Qb/\nAq8e5mNPvETZP1aeCZxD+VUhMkaCCYape3QcnloqvwN5kcvyKX/JFYKJuVPNfgeQ\nqV124RleDVi4WdUN3yOra2N2GZ6c37BXSWzQhpfDbDz64FbCG+OhQhpYYoWddBmD\nCK9ZkPiZvWfTSuoOycphig2KQsyQ6S7CVHN/Xq+N4jLLRSDWGU1bdzHMDy3Afg==\n-----END CERTIFICATE-----\n"
  },
  {
    "path": "ext/yassl/certs/client-key.pem",
    "content": "-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEAwwPRK/45pDJFO1PIhCsqfHSavaoqUgdH1qY2sgcyjtC6aXvG\nw0Se1IFI/S1oootnu6F1yDYsStIb94u6zw357+zxgR57mwNHmr9lzH9lJGmm6BSJ\nW+Q098WwFJP1Z3s6enjhAVZWkaYTQo3SPECcTO/Rht83URsMoTv18aNKNeThzpbf\nG36/TpfQEOioCDCBryALQxTFdGe0MoJvjYbCiECZNoO6HkByIhfXUmUkc7DO7xnN\nrv94bHvAEgPUTnINUG07ozujmV6dyNkMhbPZitlUJttt+qy7/yVMxNF59HHThkAY\nE7BjtXJOMMSXhIYtVi/XFfd/wK71/Fvl+6G60wIDAQABAoIBAQCi5thfEHFkCJ4u\nbdFtHoXSCrGMR84sUWqgEp5T3pFMHW3qWXvyd6rZxtmKq9jhFuRjJv+1bBNZuOOl\nyHIXLgyfb+VZP3ZvSbERwlouFikN3reO3EDVou7gHqH0vpfbhmOWFM2YCWAtMHac\nPM3miO5HknkLWgDiXl8RfH35CLcgBokqXf0AqyLh8LO8JKleJg4fAC3+IZpTW23T\nK6uUgmhDNtj2L8Yi/LVBXQ0zYOqkfX7oS1WRVtNcV48flBcvqt7pnqj0z4pMjqDk\nVnOyz0+GxWk88yQgi1yWDPprEjuaZ8HfxpaypdWSDZsJQmgkEEXUUOQXOUjQNYuU\nbRHej8pZAoGBAOokp/lpM+lx3FJ9iCEoL0neunIW6cxHeogNlFeEWBY6gbA/os+m\nbB6wBikAj+d3dqzbysfZXps/JpBSrvw4kAAUu7QPWJTnL2p+HE9BIdQxWR9OihqN\np1dsItjl9H4yphDLZKVVA4emJwWMw9e2J7JNujDaR49U0z2LhI2UmFilAoGBANU4\nG8OPxZMMRwtvNZLFsI1GyJIYj/WACvfvof6AubUqusoYsF2lB9CTjdicBBzUYo6m\nJoEB/86KKmM0NUCqbYDeiSNqV02ebq2TTlaQC22dc4sMric93k7wqsVseGdslFKc\nN2dsLe+7r9+mkDzER8+Nlp6YqbSfxaZQ3LPw+3QXAoGAXoMJYr26fKK/QnT1fBzS\nackEDYV+Pj0kEsMYe/Mp818OdmxZdeRBhGmdMvPNIquwNbpKsjzl2Vi2Yk9d3uWe\nCspTsiz3nrNrClt5ZexukU6SIPb8/Bbt03YM4ux/smkTa3gOWkZktF63JaBadTpL\n78c8Pvf9JrggxJkKmnO+wxkCgYEAukSTFKw0GTtfkWCs97TWgQU2UVM96GXcry7c\nYT7Jfbh/h/A7mwOCKTfOck4R1bHBDAegmZFKjX/sec/xObXphexi99p9vGRNIjwO\n8tZR9YfYmcARIF0PKf1b4q7ZHNkhVm38hNBf7RAVHBgh58Q9S9fQnmqVzyLJA3ue\n42AB/C8CgYAR0EvPG2e5nxB1R4ZlrjHCxjCsWQZQ2Q+1cAb38NPIYnyo2m72IT/T\nf1/qiqs/2Spe81HSwjA34y2jdQ0eTSE01VdwXIm/cuxKbmjVzRh0M06MOkWP5pZA\n62P5GYY6Ud2JS7Dz+Z9dKJU4vjWrylznk1M0oUVdEzllQkahn831vw==\n-----END RSA PRIVATE KEY-----\n"
  },
  {
    "path": "ext/yassl/certs/client-keyEnc.pem",
    "content": "-----BEGIN RSA PRIVATE KEY-----\nProc-Type: 4,ENCRYPTED\nDEK-Info: DES-EDE3-CBC,BDE979D13CCC0ABD\n\nN7yz2JV13EmQ7MZPL5wamid5+G1V1gp8FKqMemAC5JDxonS/W9oViMLUcxbfPTDx\nFznKdYSVTIQ7vv3ofmDG4MEyV/2C568N2kdtAw+jTfrZFN+IU9CI+W+In/nacirF\n02sAcvDMofustnooKNOO7/iyb5+3vRvEt5vSSRQn5WuSQ9sUKjuzoLs/lbf7fyAt\n4NeqfI3rYBZXxiUOLITOGXzGNRuFoY+o2uDCfelLAJ8uhiVG6ME3LeJEo1dT5lZ8\nCSJOLPasKg0iG4V7olM4j9FvAfZr48RRsSfUen756Jo2HpI4bad8LKhFYIdNs2Au\nWwKLmjpo6QB9hBmRshR04rEXPdrgTqLBExCE08PyaGYnWU8ggWritCeBzDQFj/n4\nsI+NO0Mymuvg98e5RpO52lg3Xnqv9RIK3guLFOmI6aEHC0PS4WwOEQ==\n-----END RSA PRIVATE KEY-----\n"
  },
  {
    "path": "ext/yassl/certs/client-keyEnc3.pem",
    "content": "-----BEGIN RSA PRIVATE KEY-----\nProc-Type: 4,ENCRYPTED\nDEK-Info: DES-EDE3-CBC,BDE979D13CCC0ABD\n\nN7yz2JV13EmQ7MZPL5wamid5+G1V1gp8FKqMemAC5JDxonS/W9oViMLUcxbfPTDx\nFznKdYSVTIQ7vv3ofmDG4MEyV/2C568N2kdtAw+jTfrZFN+IU9CI+W+In/nacirF\n02sAcvDMofustnooKNOO7/iyb5+3vRvEt5vSSRQn5WuSQ9sUKjuzoLs/lbf7fyAt\n4NeqfI3rYBZXxiUOLITOGXzGNRuFoY+o2uDCfelLAJ8uhiVG6ME3LeJEo1dT5lZ8\nCSJOLPasKg0iG4V7olM4j9FvAfZr48RRsSfUen756Jo2HpI4bad8LKhFYIdNs2Au\nWwKLmjpo6QB9hBmRshR04rEXPdrgTqLBExCE08PyaGYnWU8ggWritCeBzDQFj/n4\nsI+NO0Mymuvg98e5RpO52lg3Xnqv9RIK3guLFOmI6aEHC0PS4WwOEQ==\n-----END RSA PRIVATE KEY-----\n"
  },
  {
    "path": "ext/yassl/certs/dsa-cert.pem",
    "content": "-----BEGIN CERTIFICATE-----\nMIIDqzCCA2ugAwIBAgIJAMGqrgDU6DyhMAkGByqGSM44BAMwgY4xCzAJBgNVBAYT\nAlVTMQ8wDQYDVQQIDAZPcmVnb24xETAPBgNVBAcMCFBvcnRsYW5kMRAwDgYDVQQK\nDAd3b2xmU1NMMRAwDgYDVQQLDAd0ZXN0aW5nMRYwFAYDVQQDDA13d3cueWFzc2wu\nY29tMR8wHQYJKoZIhvcNAQkBFhBpbmZvQHdvbGZzc2wuY29tMB4XDTEzMDQyMjIw\nMDk0NFoXDTE2MDExNzIwMDk0NFowgY4xCzAJBgNVBAYTAlVTMQ8wDQYDVQQIDAZP\ncmVnb24xETAPBgNVBAcMCFBvcnRsYW5kMRAwDgYDVQQKDAd3b2xmU1NMMRAwDgYD\nVQQLDAd0ZXN0aW5nMRYwFAYDVQQDDA13d3cueWFzc2wuY29tMR8wHQYJKoZIhvcN\nAQkBFhBpbmZvQHdvbGZzc2wuY29tMIIBuDCCASwGByqGSM44BAEwggEfAoGBAL1R\n7koy4IrH6sbh6nDEUUPPKgfhxxLCWCVexF2+qzANEr+hC9M002haJXFOfeS9DyoO\nWFbL0qMZOuqv+22CaHnoUWl7q3PjJOAI3JH0P54ZyUPuU1909RzgTdIDp5+ikbr7\nKYjnltL73FQVMbjTZQKthIpPn3MjYcF+4jp2W2zFAhUAkcntYND6MGf+eYzIJDN2\nL7SonHUCgYEAklpxErfqznIZjVvqqHFaq+mgAL5J8QrKVmdhYZh/Y8z4jCjoCA8o\nTDoFKxf7s2ZzgaPKvglaEKiYqLqic9qY78DYJswzQMLFvjsF4sFZ+pYCBdWPQI4N\nPgxCiznK6Ce+JH9ikSBvMvG+tevjr2UpawDIHX3+AWYaZBZwKADAaboDgYUAAoGB\nAJ3LY89yHyvQ/TsQ6zlYbovjbk/ogndsMqPdNUvL4RuPTgJP/caaDDa0XJ7ak6A7\nTJ+QheLNwOXoZPYJC4EGFSDAXpYniGhbWIrVTCGe6lmZDfnx40WXS0kk3m/DHaC0\n3ElLAiybxVGxyqoUfbT3Zv1JwftWMuiqHH5uADhdXuXVo1AwTjAdBgNVHQ4EFgQU\nIJjk416o4v8qpH9LBtXlR9v8gccwHwYDVR0jBBgwFoAUIJjk416o4v8qpH9LBtXl\nR9v8gccwDAYDVR0TBAUwAwEB/zAJBgcqhkjOOAQDAy8AMCwCFCjGKIdOSV12LcTu\nk08owGM6YkO1AhQe+K173VuaO/OsDNsxZlKpyH8+1g==\n-----END CERTIFICATE-----\n"
  },
  {
    "path": "ext/yassl/certs/dsa1024.pem",
    "content": "-----BEGIN DSA PRIVATE KEY-----\nMIIBvAIBAAKBgQC9Ue5KMuCKx+rG4epwxFFDzyoH4ccSwlglXsRdvqswDRK/oQvT\nNNNoWiVxTn3kvQ8qDlhWy9KjGTrqr/ttgmh56FFpe6tz4yTgCNyR9D+eGclD7lNf\ndPUc4E3SA6efopG6+ymI55bS+9xUFTG402UCrYSKT59zI2HBfuI6dltsxQIVAJHJ\n7WDQ+jBn/nmMyCQzdi+0qJx1AoGBAJJacRK36s5yGY1b6qhxWqvpoAC+SfEKylZn\nYWGYf2PM+Iwo6AgPKEw6BSsX+7Nmc4Gjyr4JWhComKi6onPamO/A2CbMM0DCxb47\nBeLBWfqWAgXVj0CODT4MQos5yugnviR/YpEgbzLxvrXr469lKWsAyB19/gFmGmQW\ncCgAwGm6AoGBAJ3LY89yHyvQ/TsQ6zlYbovjbk/ogndsMqPdNUvL4RuPTgJP/caa\nDDa0XJ7ak6A7TJ+QheLNwOXoZPYJC4EGFSDAXpYniGhbWIrVTCGe6lmZDfnx40WX\nS0kk3m/DHaC03ElLAiybxVGxyqoUfbT3Zv1JwftWMuiqHH5uADhdXuXVAhQ01VXa\nRr8IPem35lKghVKnq/kGQw==\n-----END DSA PRIVATE KEY-----\n"
  },
  {
    "path": "ext/yassl/certs/server-cert.pem",
    "content": "Certificate:\n    Data:\n        Version: 3 (0x2)\n        Serial Number: 1 (0x1)\n    Signature Algorithm: sha1WithRSAEncryption\n        Issuer: C=US, ST=Montana, L=Bozeman, O=Sawtooth, OU=Consulting, CN=www.wolfssl.com/emailAddress=info@wolfssl.com\n        Validity\n            Not Before: Jul 11 17:20:14 2014 GMT\n            Not After : Apr  6 17:20:14 2017 GMT\n        Subject: C=US, ST=Montana, L=Bozeman, O=wolfSSL, OU=Support, CN=www.wolfssl.com/emailAddress=info@wolfssl.com\n        Subject Public Key Info:\n            Public Key Algorithm: rsaEncryption\n                Public-Key: (2048 bit)\n                Modulus:\n                    00:c0:95:08:e1:57:41:f2:71:6d:b7:d2:45:41:27:\n                    01:65:c6:45:ae:f2:bc:24:30:b8:95:ce:2f:4e:d6:\n                    f6:1c:88:bc:7c:9f:fb:a8:67:7f:fe:5c:9c:51:75:\n                    f7:8a:ca:07:e7:35:2f:8f:e1:bd:7b:c0:2f:7c:ab:\n                    64:a8:17:fc:ca:5d:7b:ba:e0:21:e5:72:2e:6f:2e:\n                    86:d8:95:73:da:ac:1b:53:b9:5f:3f:d7:19:0d:25:\n                    4f:e1:63:63:51:8b:0b:64:3f:ad:43:b8:a5:1c:5c:\n                    34:b3:ae:00:a0:63:c5:f6:7f:0b:59:68:78:73:a6:\n                    8c:18:a9:02:6d:af:c3:19:01:2e:b8:10:e3:c6:cc:\n                    40:b4:69:a3:46:33:69:87:6e:c4:bb:17:a6:f3:e8:\n                    dd:ad:73:bc:7b:2f:21:b5:fd:66:51:0c:bd:54:b3:\n                    e1:6d:5f:1c:bc:23:73:d1:09:03:89:14:d2:10:b9:\n                    64:c3:2a:d0:a1:96:4a:bc:e1:d4:1a:5b:c7:a0:c0:\n                    c1:63:78:0f:44:37:30:32:96:80:32:23:95:a1:77:\n                    ba:13:d2:97:73:e2:5d:25:c9:6a:0d:c3:39:60:a4:\n                    b4:b0:69:42:42:09:e9:d8:08:bc:33:20:b3:58:22:\n                    a7:aa:eb:c4:e1:e6:61:83:c5:d2:96:df:d9:d0:4f:\n                    ad:d7\n                Exponent: 65537 (0x10001)\n        X509v3 extensions:\n            X509v3 Subject Key Identifier: \n                B3:11:32:C9:92:98:84:E2:C9:F8:D0:3B:6E:03:42:CA:1F:0E:8E:3C\n            X509v3 Authority Key Identifier: \n                keyid:27:8E:67:11:74:C3:26:1D:3F:ED:33:63:B3:A4:D8:1D:30:E5:E8:D5\n                DirName:/C=US/ST=Montana/L=Bozeman/O=Sawtooth/OU=Consulting/CN=www.wolfssl.com/emailAddress=info@wolfssl.com\n                serial:9A:41:47:CD:A1:14:62:8C\n\n            X509v3 Basic Constraints: \n                CA:TRUE\n    Signature Algorithm: sha1WithRSAEncryption\n         3d:8c:70:05:5b:62:4b:bf:6c:b6:48:61:01:10:1d:5e:05:ba:\n         55:94:2c:ae:59:6f:97:80:5d:6c:86:ec:9a:eb:15:45:44:e4:\n         56:f8:75:ca:8a:45:32:f4:c7:e1:fa:f2:98:1c:91:d3:3f:e8:\n         0e:c9:1b:fa:e1:79:99:67:0e:0d:6b:8a:ec:1a:2c:59:c4:34:\n         04:8d:39:77:cd:b5:e9:60:5b:82:bf:34:ce:ed:c6:4f:3f:b4:\n         5c:4d:8a:b4:f4:0a:04:12:a0:56:c1:e1:33:37:a1:54:87:48:\n         e9:81:c2:0f:8f:6f:d3:52:4c:4c:32:4c:6b:9f:3a:04:8f:77:\n         5d:ad:dc:3d:2b:f2:c9:df:3c:60:5d:d8:fc:86:72:7c:3d:d0:\n         84:4b:8c:df:26:43:fe:c0:cc:5b:e1:36:b3:3d:32:28:a3:ef:\n         0c:20:d6:b1:50:39:d6:67:a9:8b:84:bc:92:34:eb:19:23:e8:\n         10:8f:ea:bd:18:8c:93:27:3c:74:75:8e:58:04:fa:2a:74:44:\n         7d:fc:4d:39:df:54:17:ba:78:e1:5d:6a:70:d3:7c:a2:80:81:\n         e6:19:51:91:c3:44:51:ec:bb:88:a9:53:e1:d7:a9:8c:28:f4:\n         21:1c:42:51:09:b4:12:6d:a0:d6:25:09:85:c6:2a:0c:af:a7:\n         58:e6:52:8b\n-----BEGIN CERTIFICATE-----\nMIIEnjCCA4agAwIBAgIBATANBgkqhkiG9w0BAQUFADCBlDELMAkGA1UEBhMCVVMx\nEDAOBgNVBAgMB01vbnRhbmExEDAOBgNVBAcMB0JvemVtYW4xETAPBgNVBAoMCFNh\nd3Rvb3RoMRMwEQYDVQQLDApDb25zdWx0aW5nMRgwFgYDVQQDDA93d3cud29sZnNz\nbC5jb20xHzAdBgkqhkiG9w0BCQEWEGluZm9Ad29sZnNzbC5jb20wHhcNMTQwNzEx\nMTcyMDE0WhcNMTcwNDA2MTcyMDE0WjCBkDELMAkGA1UEBhMCVVMxEDAOBgNVBAgM\nB01vbnRhbmExEDAOBgNVBAcMB0JvemVtYW4xEDAOBgNVBAoMB3dvbGZTU0wxEDAO\nBgNVBAsMB1N1cHBvcnQxGDAWBgNVBAMMD3d3dy53b2xmc3NsLmNvbTEfMB0GCSqG\nSIb3DQEJARYQaW5mb0B3b2xmc3NsLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEP\nADCCAQoCggEBAMCVCOFXQfJxbbfSRUEnAWXGRa7yvCQwuJXOL07W9hyIvHyf+6hn\nf/5cnFF194rKB+c1L4/hvXvAL3yrZKgX/Mpde7rgIeVyLm8uhtiVc9qsG1O5Xz/X\nGQ0lT+FjY1GLC2Q/rUO4pRxcNLOuAKBjxfZ/C1loeHOmjBipAm2vwxkBLrgQ48bM\nQLRpo0YzaYduxLsXpvPo3a1zvHsvIbX9ZlEMvVSz4W1fHLwjc9EJA4kU0hC5ZMMq\n0KGWSrzh1Bpbx6DAwWN4D0Q3MDKWgDIjlaF3uhPSl3PiXSXJag3DOWCktLBpQkIJ\n6dgIvDMgs1gip6rrxOHmYYPF0pbf2dBPrdcCAwEAAaOB/DCB+TAdBgNVHQ4EFgQU\nsxEyyZKYhOLJ+NA7bgNCyh8OjjwwgckGA1UdIwSBwTCBvoAUJ45nEXTDJh0/7TNj\ns6TYHTDl6NWhgZqkgZcwgZQxCzAJBgNVBAYTAlVTMRAwDgYDVQQIDAdNb250YW5h\nMRAwDgYDVQQHDAdCb3plbWFuMREwDwYDVQQKDAhTYXd0b290aDETMBEGA1UECwwK\nQ29uc3VsdGluZzEYMBYGA1UEAwwPd3d3LndvbGZzc2wuY29tMR8wHQYJKoZIhvcN\nAQkBFhBpbmZvQHdvbGZzc2wuY29tggkAmkFHzaEUYowwDAYDVR0TBAUwAwEB/zAN\nBgkqhkiG9w0BAQUFAAOCAQEAPYxwBVtiS79stkhhARAdXgW6VZQsrllvl4BdbIbs\nmusVRUTkVvh1yopFMvTH4frymByR0z/oDskb+uF5mWcODWuK7BosWcQ0BI05d821\n6WBbgr80zu3GTz+0XE2KtPQKBBKgVsHhMzehVIdI6YHCD49v01JMTDJMa586BI93\nXa3cPSvyyd88YF3Y/IZyfD3QhEuM3yZD/sDMW+E2sz0yKKPvDCDWsVA51mepi4S8\nkjTrGSPoEI/qvRiMkyc8dHWOWAT6KnREffxNOd9UF7p44V1qcNN8ooCB5hlRkcNE\nUey7iKlT4depjCj0IRxCUQm0Em2g1iUJhcYqDK+nWOZSiw==\n-----END CERTIFICATE-----\nCertificate:\n    Data:\n        Version: 3 (0x2)\n        Serial Number:\n            9a:41:47:cd:a1:14:62:8c\n    Signature Algorithm: sha1WithRSAEncryption\n        Issuer: C=US, ST=Montana, L=Bozeman, O=Sawtooth, OU=Consulting, CN=www.wolfssl.com/emailAddress=info@wolfssl.com\n        Validity\n            Not Before: Jul 11 03:20:08 2014 GMT\n            Not After : Apr  6 03:20:08 2017 GMT\n        Subject: C=US, ST=Montana, L=Bozeman, O=Sawtooth, OU=Consulting, CN=www.wolfssl.com/emailAddress=info@wolfssl.com\n        Subject Public Key Info:\n            Public Key Algorithm: rsaEncryption\n                Public-Key: (2048 bit)\n                Modulus:\n                    00:bf:0c:ca:2d:14:b2:1e:84:42:5b:cd:38:1f:4a:\n                    f2:4d:75:10:f1:b6:35:9f:df:ca:7d:03:98:d3:ac:\n                    de:03:66:ee:2a:f1:d8:b0:7d:6e:07:54:0b:10:98:\n                    21:4d:80:cb:12:20:e7:cc:4f:de:45:7d:c9:72:77:\n                    32:ea:ca:90:bb:69:52:10:03:2f:a8:f3:95:c5:f1:\n                    8b:62:56:1b:ef:67:6f:a4:10:41:95:ad:0a:9b:e3:\n                    a5:c0:b0:d2:70:76:50:30:5b:a8:e8:08:2c:7c:ed:\n                    a7:a2:7a:8d:38:29:1c:ac:c7:ed:f2:7c:95:b0:95:\n                    82:7d:49:5c:38:cd:77:25:ef:bd:80:75:53:94:3c:\n                    3d:ca:63:5b:9f:15:b5:d3:1d:13:2f:19:d1:3c:db:\n                    76:3a:cc:b8:7d:c9:e5:c2:d7:da:40:6f:d8:21:dc:\n                    73:1b:42:2d:53:9c:fe:1a:fc:7d:ab:7a:36:3f:98:\n                    de:84:7c:05:67:ce:6a:14:38:87:a9:f1:8c:b5:68:\n                    cb:68:7f:71:20:2b:f5:a0:63:f5:56:2f:a3:26:d2:\n                    b7:6f:b1:5a:17:d7:38:99:08:fe:93:58:6f:fe:c3:\n                    13:49:08:16:0b:a7:4d:67:00:52:31:67:23:4e:98:\n                    ed:51:45:1d:b9:04:d9:0b:ec:d8:28:b3:4b:bd:ed:\n                    36:79\n                Exponent: 65537 (0x10001)\n        X509v3 extensions:\n            X509v3 Subject Key Identifier: \n                27:8E:67:11:74:C3:26:1D:3F:ED:33:63:B3:A4:D8:1D:30:E5:E8:D5\n            X509v3 Authority Key Identifier: \n                keyid:27:8E:67:11:74:C3:26:1D:3F:ED:33:63:B3:A4:D8:1D:30:E5:E8:D5\n                DirName:/C=US/ST=Montana/L=Bozeman/O=Sawtooth/OU=Consulting/CN=www.wolfssl.com/emailAddress=info@wolfssl.com\n                serial:9A:41:47:CD:A1:14:62:8C\n\n            X509v3 Basic Constraints: \n                CA:TRUE\n    Signature Algorithm: sha1WithRSAEncryption\n         79:78:0c:6d:79:88:91:fc:3a:15:9c:f9:27:62:16:f0:21:1f:\n         fa:7d:3f:a2:a8:32:1e:f7:f2:11:a9:74:16:74:5e:dc:18:ca:\n         f0:00:2a:d5:03:06:26:30:f1:47:83:fd:32:6e:fc:ed:aa:4f:\n         7d:0c:63:60:31:2f:7c:0c:bf:99:66:87:ed:27:08:86:2d:c4:\n         33:e8:98:23:1c:fe:a3:db:9a:49:4e:fc:5a:42:ef:71:c3:3f:\n         ad:dc:4a:a8:d2:a3:1d:09:ac:33:04:7b:86:f3:6d:00:59:a3:\n         c8:db:d1:3c:73:f6:0e:90:d6:5e:49:e0:bf:36:63:08:7b:a5:\n         b0:8f:35:3b:56:8c:11:35:49:04:1c:d0:e7:ba:56:c5:0d:0a:\n         91:8d:d6:b7:62:19:34:12:52:4c:d2:6d:7c:c5:3d:0f:18:81:\n         54:cb:f6:3c:e5:84:d2:d6:71:15:ec:1a:34:0b:f0:a0:21:74:\n         43:c8:a3:b0:df:d9:67:da:e2:ad:93:48:f8:a0:87:bd:79:14:\n         e0:62:0a:df:f7:31:2e:31:7b:d1:32:2a:0a:fe:5d:14:ef:d9:\n         64:50:e4:83:91:bc:70:0d:d7:88:8d:d9:bc:84:0e:c5:1a:b3:\n         bf:64:02:4e:51:91:a4:a2:85:15:83:af:f0:5b:9b:28:49:5f:\n         b2:b3:03:d8\n-----BEGIN CERTIFICATE-----\nMIIEqjCCA5KgAwIBAgIJAJpBR82hFGKMMA0GCSqGSIb3DQEBBQUAMIGUMQswCQYD\nVQQGEwJVUzEQMA4GA1UECAwHTW9udGFuYTEQMA4GA1UEBwwHQm96ZW1hbjERMA8G\nA1UECgwIU2F3dG9vdGgxEzARBgNVBAsMCkNvbnN1bHRpbmcxGDAWBgNVBAMMD3d3\ndy53b2xmc3NsLmNvbTEfMB0GCSqGSIb3DQEJARYQaW5mb0B3b2xmc3NsLmNvbTAe\nFw0xNDA3MTEwMzIwMDhaFw0xNzA0MDYwMzIwMDhaMIGUMQswCQYDVQQGEwJVUzEQ\nMA4GA1UECAwHTW9udGFuYTEQMA4GA1UEBwwHQm96ZW1hbjERMA8GA1UECgwIU2F3\ndG9vdGgxEzARBgNVBAsMCkNvbnN1bHRpbmcxGDAWBgNVBAMMD3d3dy53b2xmc3Ns\nLmNvbTEfMB0GCSqGSIb3DQEJARYQaW5mb0B3b2xmc3NsLmNvbTCCASIwDQYJKoZI\nhvcNAQEBBQADggEPADCCAQoCggEBAL8Myi0Ush6EQlvNOB9K8k11EPG2NZ/fyn0D\nmNOs3gNm7irx2LB9bgdUCxCYIU2AyxIg58xP3kV9yXJ3MurKkLtpUhADL6jzlcXx\ni2JWG+9nb6QQQZWtCpvjpcCw0nB2UDBbqOgILHztp6J6jTgpHKzH7fJ8lbCVgn1J\nXDjNdyXvvYB1U5Q8PcpjW58VtdMdEy8Z0TzbdjrMuH3J5cLX2kBv2CHccxtCLVOc\n/hr8fat6Nj+Y3oR8BWfOahQ4h6nxjLVoy2h/cSAr9aBj9VYvoybSt2+xWhfXOJkI\n/pNYb/7DE0kIFgunTWcAUjFnI06Y7VFFHbkE2Qvs2CizS73tNnkCAwEAAaOB/DCB\n+TAdBgNVHQ4EFgQUJ45nEXTDJh0/7TNjs6TYHTDl6NUwgckGA1UdIwSBwTCBvoAU\nJ45nEXTDJh0/7TNjs6TYHTDl6NWhgZqkgZcwgZQxCzAJBgNVBAYTAlVTMRAwDgYD\nVQQIDAdNb250YW5hMRAwDgYDVQQHDAdCb3plbWFuMREwDwYDVQQKDAhTYXd0b290\naDETMBEGA1UECwwKQ29uc3VsdGluZzEYMBYGA1UEAwwPd3d3LndvbGZzc2wuY29t\nMR8wHQYJKoZIhvcNAQkBFhBpbmZvQHdvbGZzc2wuY29tggkAmkFHzaEUYowwDAYD\nVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAeXgMbXmIkfw6FZz5J2IW8CEf\n+n0/oqgyHvfyEal0FnRe3BjK8AAq1QMGJjDxR4P9Mm787apPfQxjYDEvfAy/mWaH\n7ScIhi3EM+iYIxz+o9uaSU78WkLvccM/rdxKqNKjHQmsMwR7hvNtAFmjyNvRPHP2\nDpDWXkngvzZjCHulsI81O1aMETVJBBzQ57pWxQ0KkY3Wt2IZNBJSTNJtfMU9DxiB\nVMv2POWE0tZxFewaNAvwoCF0Q8ijsN/ZZ9rirZNI+KCHvXkU4GIK3/cxLjF70TIq\nCv5dFO/ZZFDkg5G8cA3XiI3ZvIQOxRqzv2QCTlGRpKKFFYOv8FubKElfsrMD2A==\n-----END CERTIFICATE-----\n"
  },
  {
    "path": "ext/yassl/certs/server-key.pem",
    "content": "-----BEGIN RSA PRIVATE KEY-----\nMIIEpQIBAAKCAQEAwJUI4VdB8nFtt9JFQScBZcZFrvK8JDC4lc4vTtb2HIi8fJ/7\nqGd//lycUXX3isoH5zUvj+G9e8AvfKtkqBf8yl17uuAh5XIuby6G2JVz2qwbU7lf\nP9cZDSVP4WNjUYsLZD+tQ7ilHFw0s64AoGPF9n8LWWh4c6aMGKkCba/DGQEuuBDj\nxsxAtGmjRjNph27Euxem8+jdrXO8ey8htf1mUQy9VLPhbV8cvCNz0QkDiRTSELlk\nwyrQoZZKvOHUGlvHoMDBY3gPRDcwMpaAMiOVoXe6E9KXc+JdJclqDcM5YKS0sGlC\nQgnp2Ai8MyCzWCKnquvE4eZhg8XSlt/Z0E+t1wIDAQABAoIBAQCa0DQPUmIFUAHv\nn+1kbsLE2hryhNeSEEiSxOlq64t1bMZ5OPLJckqGZFSVd8vDmp231B2kAMieTuTd\nx7pnFsF0vKnWlI8rMBr77d8hBSPZSjm9mGtlmrjcxH3upkMVLj2+HSJgKnMw1T7Y\noqyGQy7E9WReP4l1DxHYUSVOn9iqo85gs+KK2X4b8GTKmlsFC1uqy+XjP24yIgXz\n0PrvdFKB4l90073/MYNFdfpjepcu1rYZxpIm5CgGUFAOeC6peA0Ul7QS2DFAq6EB\nQcIw+AdfFuRhd9Jg8p+N6PS662PeKpeB70xs5lU0USsoNPRTHMRYCj+7r7X3SoVD\nLTzxWFiBAoGBAPIsVHY5I2PJEDK3k62vvhl1loFk5rW4iUJB0W3QHBv4G6xpyzY8\nZH3c9Bm4w2CxV0hfUk9ZOlV/MsAZQ1A/rs5vF/MOn0DKTq0VO8l56cBZOHNwnAp8\nyTpIMqfYSXUKhcLC/RVz2pkJKmmanwpxv7AEpox6Wm9IWlQ7xrFTF9/nAoGBAMuT\n3ncVXbdcXHzYkKmYLdZpDmOzo9ymzItqpKISjI57SCyySzfcBhh96v52odSh6T8N\nzRtfr1+elltbD6F8r7ObkNtXczrtsCNErkFPHwdCEyNMy/r0FKTV9542fFufqDzB\nhV900jkt/9CE3/uzIHoumxeu5roLrl9TpFLtG8SRAoGBAOyY2rvV/vlSSn0CVUlv\nVW5SL4SjK7OGYrNU0mNS2uOIdqDvixWl0xgUcndex6MEH54ZYrUbG57D8rUy+UzB\nqusMJn3UX0pRXKRFBnBEp1bA1CIUdp7YY1CJkNPiv4GVkjFBhzkaQwsYpVMfORpf\nH0O8h2rfbtMiAP4imHBOGhkpAoGBAIpBVihRnl/Ungs7mKNU8mxW1KrpaTOFJAza\n1AwtxL9PAmk4fNTm3Ezt1xYRwz4A58MmwFEC3rt1nG9WnHrzju/PisUr0toGakTJ\nc/5umYf4W77xfOZltU9s8MnF/xbKixsX4lg9ojerAby/QM5TjI7t7+5ZneBj5nxe\n9Y5L8TvBAoGATUX5QIzFW/QqGoq08hysa+kMVja3TnKW1eWK0uL/8fEYEz2GCbjY\ndqfJHHFSlDBD4PF4dP1hG0wJzOZoKnGtHN9DvFbbpaS+NXCkXs9P/ABVmTo9I89n\nWvUi+LUp0EQR6zUuRr79jhiyX6i/GTKh9dwD5nyaHwx8qbAOITc78bA=\n-----END RSA PRIVATE KEY-----\n"
  },
  {
    "path": "ext/yassl/certs/server-keyEnc.pem",
    "content": "-----BEGIN RSA PRIVATE KEY-----\nProc-Type: 4,ENCRYPTED\nDEK-Info: DES-CBC,136C7D8A69656668\n\njvNTyPaztxPIoAzbdmZnD0Zw2+60tMxNc0GMHNmeOyG25aHP/dT+TWiKFpFVkkkY\nuoCIhYUyw7gmpw+CnRJwWd+ans4nrvAjwy5oWJvarvsyUpjqvnPoIlAqd+d4TDKN\neESzcI76+gHdisAtCrQD+fGqgTZhli5TgDbnpasL/QnY2qDlutvakkVw7gPXe156\n2Phy8WN+efr65J6wt3K/dj7Datl9u4JeHQK81gYyWBVX+EagEjPGDzkFQCj9Z0q7\n8K3iB5GW1JAqJS0IfZPB40AnSTF/n1TL1SN3qfU3l7hTGNrx9o7580bgDEoAR7pI\nF8eZlS15KHtZmh11AnU1KTKZ6kmgnNqeMTGMN6N0ct2wMKW1dV87eTDlF0oiR2ol\nXwtFgKmrIjfpmzkdWjbJmWnGMjD56KdiFZga/ZyKMsPrVoYLgfJEpn36iQspfygx\nHCGNTf0PjIsjEWU0WyQiF86t+c45W3wNFsv/AxVyfMl+su02yrd6u2ecuQDir3Cs\nb2k8IKtQgVe/NIpEWLKuiHG5oedIPPQyDYK5uq+gHxCGeOoKnWlsWFEHZRiza4X5\ntbgTrJB8Sw0ENWrvVGGmQZN4pSImlsMwzQ2qik5CQ00N1b3+56/obn0z75I3bUSb\ntC5g8DRjl6oclAenNgh/MYMT287y5W2dD4npxHcekX4O3J2CDXNfg4vV2j5GRxtg\nLVJdYE2p7bpYePCDHrYng8b9ubBprx0CrEnkIvvtUjzNPf6VDL0+MBKl+XgR2/nz\niRqTuZnlGGOyM+KYDwXpgwfs/HfvFGksxTAlO/40GkGh+WGPaIoNyCK0SgQKhyb4\nJIkR0vd2/yLg3lWMJrGwh7A0Gm07Z/781oURP3uWd+PaCOgGcd5ipcAjcEyuxNly\nAthipWqmQWUcbf6Z2N9j3OA22Hv2Uzk8HSfi9VOZtL9svdEEZ0NnOekJgnc6stQp\nbXiknlK/T5WdrWxSyCfgUq68Vf6DFfIRAVuFdJ3WHT2wVXHrDfft6D+Ne/XCxPoE\n8zGmkyusaph33UHQ1oNyUbLbwcDCDSmOo8gYoedD3IwxtMA3wJRugomqosItwV8X\nvkgmcy8eSE/+gZUxJEN2gnLcfKFhCkC80J6oFhmoDD6vuUnPHcFdKZgVPw2rzPk5\nVb1kX+gpORplYmKpq1vz/ujscL4T0TmYLz02hkIS4edpW55ncTTv7JWefpRiTB1J\nRB3td3me4htqR+YIDWJ+emrOmqsCG2WvpAS+MTw2mj1jYk9LL/ZYobTjSCEWmuwT\nyVK6m303irR7HQDauxhslRFgoK21w63viOyj5NKIU1gQtaAANGDxcgORC1XLjjgt\noNutSQA+7P42vfHSHK4cnTBXl6V32H/GyVpdHQOZqSrqIjgLmUZodSmRPROxosZF\na46B1O7m/rJFxkiKW4vod+/WqjoE0Hhfrb8rRrkRjzGeCqqSSnQ3vrunVkvF8hlA\nb6FOv4ZBJL4piC1GKH+rscqke9NEiDqXN8C3iYz86jbck/Ha21yUS8T3X7N52sg+\nB3AmOGnLK6BebYeto9vZxQjacChJZSixSxLV+l9/nVQ0+mW42azHdzk0ru59TGAj\n-----END RSA PRIVATE KEY-----\n"
  },
  {
    "path": "ext/yassl/certs/taoCert.txt",
    "content": "\n***** Create a self signed cert ************\n\n1) openssl genrsa 512 > client-key.pem\n\n2) openssl req -new -x509 -nodes -md5 -days 1000 -key client-key.pem > client-cert.pem\n\n-- adding metadata to beginning\n\n3) openssl x509 -in client-cert.pem -text > tmp.pem\n\n4) mv tmp.pem client-cert.pem\n\n\n***** Create a CA, signing authority **********\n\nsame as self signed, use ca prefix instead of client\n\n\n***** Create a cert signed by CA **************\n\n1) openssl req -newkey rsa:512 -md5 -days 1000 -nodes -keyout server-key.pem > server-req.pem\n\n2) copy ca-key.pem ca-cert.srl   (why ????)\n\n3) openssl x509 -req -in server-req.pem -days 1000 -md5 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 > server-cert.pem\n\n\n\n***** To create a dsa cert ********************\n\n1) openssl dsaparam 512 > dsa512.param       # creates group params\n\n2) openssl gendsa dsa512.param > dsa512.pem  # creates private key\n\n3) openssl req -new -x509 -nodes -days 1000 -key dsa512.pem > dsa-cert.pem \n\n\n\n\n***** To convert from PEM to DER **************\n\na) openssl x509 -in cert.pem -inform PEM -out cert.der -outform DER\n\nto convert rsa private PEM to DER :\n\nb) openssl rsa -in key.pem -outform DER -out key.der\n\n\n**** To encrypt rsa key already in pem **********\n\na) openssl rsa <server-key.pem.bak -des >server-keyEnc.pem\n\nnote location of des, pass = yassl123\n\n\n*** To make a public key from a private key ******\n\n\nopenssl rsa -in 1024rsa.priv -pubout -out 1024rsa.pub\n\n\n"
  },
  {
    "path": "ext/yassl/examples/client/client.cpp",
    "content": "/*\n   Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* client.cpp  */\n\n// takes an optional command line argument of cipher list to make scripting\n// easier\n\n\n#include \"../../testsuite/test.hpp\"\n\n//#define TEST_RESUME\n\n\nvoid ClientError(SSL_CTX* ctx, SSL* ssl, SOCKET_T& sockfd, const char* msg)\n{\n    SSL_CTX_free(ctx);\n    SSL_free(ssl);\n    tcp_close(sockfd);\n    err_sys(msg);\n}\n\n\n#ifdef NON_BLOCKING\n    void NonBlockingSSL_Connect(SSL* ssl, SSL_CTX* ctx, SOCKET_T& sockfd)\n    {\n        int ret = SSL_connect(ssl);\n        int err = SSL_get_error(ssl, 0);\n        while (ret != SSL_SUCCESS && (err == SSL_ERROR_WANT_READ ||\n                                      err == SSL_ERROR_WANT_WRITE)) {\n            if (err == SSL_ERROR_WANT_READ)\n                printf(\"... client would read block\\n\");\n            else\n                printf(\"... client would write block\\n\");\n            #ifdef _WIN32\n                Sleep(1000);\n            #else\n                sleep(1);\n            #endif\n            ret = SSL_connect(ssl);\n            err = SSL_get_error(ssl, 0);\n        }\n        if (ret != SSL_SUCCESS)\n            ClientError(ctx, ssl, sockfd, \"SSL_connect failed\");\n    }\n#endif\n\n\nvoid client_test(void* args)\n{\n#ifdef _WIN32\n    WSADATA wsd;\n    WSAStartup(0x0002, &wsd);\n#endif\n\n    SOCKET_T sockfd = 0;\n    int      argc = 0;\n    char**   argv = 0;\n\n    set_args(argc, argv, *static_cast<func_args*>(args));\n    tcp_connect(sockfd);\n#ifdef NON_BLOCKING\n    tcp_set_nonblocking(sockfd);\n#endif\n    SSL_METHOD* method = TLSv1_client_method();\n    SSL_CTX*    ctx = SSL_CTX_new(method);\n\n    set_certs(ctx);\n    if (argc >= 2) {\n        printf(\"setting cipher list to %s\\n\", argv[1]);\n        if (SSL_CTX_set_cipher_list(ctx, argv[1]) != SSL_SUCCESS) {\n            ClientError(ctx, NULL, sockfd, \"set_cipher_list error\\n\");\n        }\n    }\n    SSL* ssl = SSL_new(ctx);\n\n    SSL_set_fd(ssl, sockfd);\n\n\n#ifdef NON_BLOCKING\n    NonBlockingSSL_Connect(ssl, ctx, sockfd);\n#else\n    // if you get an error here see note at top of README\n    if (SSL_connect(ssl) != SSL_SUCCESS)   \n        ClientError(ctx, ssl, sockfd, \"SSL_connect failed\");\n#endif\n    showPeer(ssl);\n\n    const char* cipher = 0;\n    int index = 0;\n    char list[1024];\n    strncpy(list, \"cipherlist\", 11);\n    while ( (cipher = SSL_get_cipher_list(ssl, index++)) ) {\n        strncat(list, \":\", 2);\n        strncat(list, cipher, strlen(cipher) + 1);\n    }\n    printf(\"%s\\n\", list);\n    printf(\"Using Cipher Suite: %s\\n\", SSL_get_cipher(ssl));\n\n    char msg[] = \"hello yassl!\";\n    if (SSL_write(ssl, msg, sizeof(msg)) != sizeof(msg))\n        ClientError(ctx, ssl, sockfd, \"SSL_write failed\");\n\n    char reply[1024];\n    int input = SSL_read(ssl, reply, sizeof(reply));\n    if (input > 0) {\n        reply[input] = 0;\n        printf(\"Server response: %s\\n\", reply);\n    }\n\n#ifdef TEST_RESUME\n    SSL_SESSION* session   = SSL_get_session(ssl);\n    SSL*         sslResume = SSL_new(ctx);\n#endif\n\n    SSL_shutdown(ssl);\n    SSL_free(ssl);\n    tcp_close(sockfd);\n\n#ifdef TEST_RESUME\n    tcp_connect(sockfd);\n    SSL_set_fd(sslResume, sockfd);\n    SSL_set_session(sslResume, session);\n\n    if (SSL_connect(sslResume) != SSL_SUCCESS)\n        ClientError(ctx, sslResume, sockfd, \"SSL_resume failed\");\n    showPeer(sslResume);\n\n    if (SSL_write(sslResume, msg, sizeof(msg)) != sizeof(msg))\n        ClientError(ctx, sslResume, sockfd, \"SSL_write failed\");\n\n    input = SSL_read(sslResume, reply, sizeof(reply));\n    if (input > 0) {\n        reply[input] = 0;\n        printf(\"Server response: %s\\n\", reply);\n    }\n\n    SSL_shutdown(sslResume);\n    SSL_free(sslResume);\n    tcp_close(sockfd);\n#endif // TEST_RESUME\n\n    SSL_CTX_free(ctx);\n    ((func_args*)args)->return_code = 0;\n}\n\n\n#ifndef NO_MAIN_DRIVER\n\n    int main(int argc, char** argv)\n    {\n        func_args args;\n\n        args.argc = argc;\n        args.argv = argv;\n\n        client_test(&args);\n        yaSSL_CleanUp();\n\n        return args.return_code;\n    }\n\n#endif // NO_MAIN_DRIVER\n\n"
  },
  {
    "path": "ext/yassl/examples/client/client.dsp",
    "content": "# Microsoft Developer Studio Project File - Name=\"client\" - Package Owner=<4>\n# Microsoft Developer Studio Generated Build File, Format Version 6.00\n# ** DO NOT EDIT **\n\n# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\n\nCFG=client - Win32 Debug\n!MESSAGE This is not a valid makefile. To build this project using NMAKE,\n!MESSAGE use the Export Makefile command and run\n!MESSAGE \n!MESSAGE NMAKE /f \"client.mak\".\n!MESSAGE \n!MESSAGE You can specify a configuration when running NMAKE\n!MESSAGE by defining the macro CFG on the command line. For example:\n!MESSAGE \n!MESSAGE NMAKE /f \"client.mak\" CFG=\"client - Win32 Debug\"\n!MESSAGE \n!MESSAGE Possible choices for configuration are:\n!MESSAGE \n!MESSAGE \"client - Win32 Release\" (based on \"Win32 (x86) Console Application\")\n!MESSAGE \"client - Win32 Debug\" (based on \"Win32 (x86) Console Application\")\n!MESSAGE \n\n# Begin Project\n# PROP AllowPerConfigDependencies 0\n# PROP Scc_ProjName \"\"\n# PROP Scc_LocalPath \"\"\nCPP=cl.exe\nRSC=rc.exe\n\n!IF  \"$(CFG)\" == \"client - Win32 Release\"\n\n# PROP BASE Use_MFC 0\n# PROP BASE Use_Debug_Libraries 0\n# PROP BASE Output_Dir \"Release\"\n# PROP BASE Intermediate_Dir \"Release\"\n# PROP BASE Target_Dir \"\"\n# PROP Use_MFC 0\n# PROP Use_Debug_Libraries 0\n# PROP Output_Dir \"Release\"\n# PROP Intermediate_Dir \"Release\"\n# PROP Ignore_Export_Lib 0\n# PROP Target_Dir \"\"\n# ADD BASE CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n# ADD CPP /nologo /MT /W3 /O2 /I \"..\\..\\taocrypt\\include\" /I \"..\\..\\include\" /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n# ADD BASE RSC /l 0x409 /d \"NDEBUG\"\n# ADD RSC /l 0x409 /d \"NDEBUG\"\nBSC32=bscmake.exe\n# ADD BASE BSC32 /nologo\n# ADD BSC32 /nologo\nLINK32=link.exe\n# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\n# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /machine:I386\n\n!ELSEIF  \"$(CFG)\" == \"client - Win32 Debug\"\n\n# PROP BASE Use_MFC 0\n# PROP BASE Use_Debug_Libraries 1\n# PROP BASE Output_Dir \"Debug\"\n# PROP BASE Intermediate_Dir \"Debug\"\n# PROP BASE Target_Dir \"\"\n# PROP Use_MFC 0\n# PROP Use_Debug_Libraries 1\n# PROP Output_Dir \"Debug\"\n# PROP Intermediate_Dir \"Debug\"\n# PROP Ignore_Export_Lib 0\n# PROP Target_Dir \"\"\n# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ /c\n# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I \"..\\..\\include\" /I \"..\\..\\taocrypt\\include\" /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /FR /YX /FD /GZ /c\n# ADD BASE RSC /l 0x409 /d \"_DEBUG\"\n# ADD RSC /l 0x409 /d \"_DEBUG\"\nBSC32=bscmake.exe\n# ADD BASE BSC32 /nologo\n# ADD BSC32 /nologo\nLINK32=link.exe\n# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\n# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\n\n!ENDIF \n\n# Begin Target\n\n# Name \"client - Win32 Release\"\n# Name \"client - Win32 Debug\"\n# Begin Group \"Source Files\"\n\n# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\n# Begin Source File\n\nSOURCE=.\\client.cpp\n# End Source File\n# End Group\n# Begin Group \"Header Files\"\n\n# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\n# End Group\n# Begin Group \"Resource Files\"\n\n# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\n# End Group\n# End Target\n# End Project\n"
  },
  {
    "path": "ext/yassl/examples/echoclient/echoclient.cpp",
    "content": "/*\n   Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* echoclient.cpp  */\n\n#include \"../../testsuite/test.hpp\"\n\n\nvoid EchoClientError(SSL_CTX* ctx, SSL* ssl, SOCKET_T& sockfd, const char* msg)\n{\n    SSL_CTX_free(ctx);\n    SSL_free(ssl);\n    tcp_close(sockfd);\n    err_sys(msg);\n}\n\n\nvoid echoclient_test(void* args)\n{\n#ifdef _WIN32\n    WSADATA wsd;\n    WSAStartup(0x0002, &wsd);\n#endif\n\n    SOCKET_T sockfd = 0;\n    int      argc = 0;\n    char**   argv = 0;\n\n    FILE* fin  = stdin;\n    FILE* fout = stdout;\n\n    bool inCreated  = false;\n    bool outCreated = false;\n\n    set_args(argc, argv, *static_cast<func_args*>(args));\n    if (argc >= 2) {\n        fin  = fopen(argv[1], \"r\"); \n        inCreated = true;\n    }\n    if (argc >= 3) {\n        fout = fopen(argv[2], \"w\");\n        outCreated = true;\n    }\n\n    if (!fin)  err_sys(\"can't open input file\");\n    if (!fout) err_sys(\"can't open output file\");\n\n    tcp_connect(sockfd);\n\n    SSL_METHOD* method = SSLv23_client_method();\n    SSL_CTX*    ctx = SSL_CTX_new(method);\n    set_certs(ctx);\n    SSL*        ssl = SSL_new(ctx);\n\n    SSL_set_fd(ssl, sockfd);\n\n    if (SSL_connect(ssl) != SSL_SUCCESS)\n        EchoClientError(ctx, ssl, sockfd, \"SSL_connect failed\");\n\n    char send[1024];\n    char reply[1024];\n\n    while (fgets(send, sizeof(send), fin)) {\n\n        int sendSz = (int)strlen(send) + 1;\n        if (SSL_write(ssl, send, sendSz) != sendSz)\n            EchoClientError(ctx, ssl, sockfd, \"SSL_write failed\");\n\n        if (strncmp(send, \"quit\", 4) == 0) {\n            fputs(\"sending server shutdown command: quit!\\n\", fout);\n            break;\n        }\n\n        if (SSL_read(ssl, reply, sizeof(reply)) > 0)\n            fputs(reply, fout);\n    }\n\n    SSL_CTX_free(ctx);\n    SSL_free(ssl);\n    tcp_close(sockfd);\n\n    fflush(fout);\n    if (inCreated)  fclose(fin);\n    if (outCreated) fclose(fout);\n\n    ((func_args*)args)->return_code = 0;\n}\n\n\n#ifndef NO_MAIN_DRIVER\n\n    int main(int argc, char** argv)\n    {\n        func_args args;\n\n        args.argc = argc;\n        args.argv = argv;\n\n        echoclient_test(&args);\n        yaSSL_CleanUp();\n\n        return args.return_code;\n    }\n\n#endif // NO_MAIN_DRIVER\n"
  },
  {
    "path": "ext/yassl/examples/echoclient/echoclient.dsp",
    "content": "# Microsoft Developer Studio Project File - Name=\"echoclient\" - Package Owner=<4>\n# Microsoft Developer Studio Generated Build File, Format Version 6.00\n# ** DO NOT EDIT **\n\n# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\n\nCFG=echoclient - Win32 Debug\n!MESSAGE This is not a valid makefile. To build this project using NMAKE,\n!MESSAGE use the Export Makefile command and run\n!MESSAGE \n!MESSAGE NMAKE /f \"echoclient.mak\".\n!MESSAGE \n!MESSAGE You can specify a configuration when running NMAKE\n!MESSAGE by defining the macro CFG on the command line. For example:\n!MESSAGE \n!MESSAGE NMAKE /f \"echoclient.mak\" CFG=\"echoclient - Win32 Debug\"\n!MESSAGE \n!MESSAGE Possible choices for configuration are:\n!MESSAGE \n!MESSAGE \"echoclient - Win32 Release\" (based on \"Win32 (x86) Console Application\")\n!MESSAGE \"echoclient - Win32 Debug\" (based on \"Win32 (x86) Console Application\")\n!MESSAGE \n\n# Begin Project\n# PROP AllowPerConfigDependencies 0\n# PROP Scc_ProjName \"\"\n# PROP Scc_LocalPath \"\"\nCPP=cl.exe\nRSC=rc.exe\n\n!IF  \"$(CFG)\" == \"echoclient - Win32 Release\"\n\n# PROP BASE Use_MFC 0\n# PROP BASE Use_Debug_Libraries 0\n# PROP BASE Output_Dir \"Release\"\n# PROP BASE Intermediate_Dir \"Release\"\n# PROP BASE Target_Dir \"\"\n# PROP Use_MFC 0\n# PROP Use_Debug_Libraries 0\n# PROP Output_Dir \"Release\"\n# PROP Intermediate_Dir \"Release\"\n# PROP Ignore_Export_Lib 0\n# PROP Target_Dir \"\"\n# ADD BASE CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n# ADD CPP /nologo /MT /W3 /O2 /I \"..\\..\\include\" /I \"..\\..\\taocrypt\\include\" /D \"NDEBUG\" /D \"WIN32\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n# ADD BASE RSC /l 0x409 /d \"NDEBUG\"\n# ADD RSC /l 0x409 /d \"NDEBUG\"\nBSC32=bscmake.exe\n# ADD BASE BSC32 /nologo\n# ADD BSC32 /nologo\nLINK32=link.exe\n# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\n# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /machine:I386\n\n!ELSEIF  \"$(CFG)\" == \"echoclient - Win32 Debug\"\n\n# PROP BASE Use_MFC 0\n# PROP BASE Use_Debug_Libraries 1\n# PROP BASE Output_Dir \"Debug\"\n# PROP BASE Intermediate_Dir \"Debug\"\n# PROP BASE Target_Dir \"\"\n# PROP Use_MFC 0\n# PROP Use_Debug_Libraries 1\n# PROP Output_Dir \"Debug\"\n# PROP Intermediate_Dir \"Debug\"\n# PROP Ignore_Export_Lib 0\n# PROP Target_Dir \"\"\n# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ /c\n# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I \"..\\..\\include\" /I \"..\\..\\taocrypt\\include\" /D \"_DEBUG\" /D \"WIN32\" /D \"_CONSOLE\" /D \"_MBCS\" /FR /YX /FD /GZ /c\n# ADD BASE RSC /l 0x409 /d \"_DEBUG\"\n# ADD RSC /l 0x409 /d \"_DEBUG\"\nBSC32=bscmake.exe\n# ADD BASE BSC32 /nologo\n# ADD BSC32 /nologo\nLINK32=link.exe\n# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\n# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\n\n!ENDIF \n\n# Begin Target\n\n# Name \"echoclient - Win32 Release\"\n# Name \"echoclient - Win32 Debug\"\n# Begin Group \"Source Files\"\n\n# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\n# Begin Source File\n\nSOURCE=.\\echoclient.cpp\n# End Source File\n# End Group\n# Begin Group \"Header Files\"\n\n# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\n# End Group\n# Begin Group \"Resource Files\"\n\n# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\n# End Group\n# End Target\n# End Project\n"
  },
  {
    "path": "ext/yassl/examples/echoclient/input",
    "content": "/* echoclient.cpp  */\n\n#include \"openssl/ssl.h\"  /* openssl compatibility test */\n#include <stdio.h>\n#include <stdlib.h>\n\n\n#ifdef WIN32\n    #include <winsock2.h>\n#else\n    #include <string.h>\n    #include <unistd.h>\n    #include <netinet/in.h>\n    #include <arpa/inet.h>\n    #include <sys/ioctl.h>\n    #include <sys/time.h>\n    #include <sys/types.h>\n    #include <sys/socket.h>\n#endif /* WIN32 */\n\n\nvoid err_sys(const char* msg)\n{\n    fputs(\"yassl client error: \", stderr);\n    fputs(msg, stderr);\n    exit(EXIT_FAILURE);\n}\n\nconst char* loopback  = \"127.0.0.1\";\nconst short yasslPort = 11111;\n\nusing namespace yaSSL;\n\n\nint main(int argc, char** argv)\n{\n#ifdef WIN32\n    WSADATA wsd;\n    WSAStartup(0x0002, &wsd);\n    int sockfd;\n#else\n    unsigned int sockfd;\n#endif /* WIN32  */\n\n    FILE* fin  = stdin;\n    FILE* fout = stdout;\n\n    if (argc >= 2) fin  = fopen(argv[1], \"r\");\n    if (argc >= 3) fout = fopen(argv[2], \"w\");\n\n    if (!fin)  err_sys(\"can't open input file\");\n    if (!fout) err_sys(\"can't open output file\");\n\n    sockfd = socket(AF_INET, SOCK_STREAM, 0);\n    sockaddr_in servaddr;\n    memset(&servaddr, 0, sizeof(servaddr));\n    servaddr.sin_family = AF_INET;\n\n    servaddr.sin_port = htons(yasslPort);\n    servaddr.sin_addr.s_addr = inet_addr(loopback);\n    if (connect(sockfd, (const sockaddr*)&servaddr, sizeof(servaddr)) != 0)\n        err_sys(\"tcp connect failed\");\n\n    SSL_METHOD* method = TLSv1_client_method();\n    SSL_CTX*    ctx = SSL_CTX_new(method);\n    SSL*        ssl = SSL_new(ctx);\n\n    SSL_set_fd(ssl, sockfd);\n    if (SSL_connect(ssl) != SSL_SUCCESS) err_sys(\"SSL_connect failed\");\n\n    char send[1024];\n    char reply[1024];\n \n    while (fgets(send, sizeof(send), fin)) {\n\n        int sendSz = strlen(send) + 1;\n        if (SSL_write(ssl, send, sendSz) != sendSz)\n            err_sys(\"SSL_write failed\");\n\n        if (strncmp(send, \"quit\", 4) == 0) {\n            fputs(\"sending server shutdown command: quit!\", fout);\n            break;\n        }\n\n        if (SSL_read(ssl, reply, sizeof(reply)) > 0) \n            fputs(reply, fout);\n    }\n\n    SSL_CTX_free(ctx);\n    SSL_free(ssl);\n\n    return 0;\n}\n"
  },
  {
    "path": "ext/yassl/examples/echoclient/quit",
    "content": "quit\n\n"
  },
  {
    "path": "ext/yassl/examples/echoserver/echoserver.cpp",
    "content": "/*\n   Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* echoserver.cpp */\n\n#include \"../../testsuite/test.hpp\"\n\n\n#ifndef NO_MAIN_DRIVER\n    #define ECHO_OUT\n\n    THREAD_RETURN YASSL_API echoserver_test(void*);\n    int main(int argc, char** argv)\n    {\n        func_args args;\n\n        args.argc = argc;\n        args.argv = argv;\n\n        echoserver_test(&args);\n        yaSSL_CleanUp();\n\n        return args.return_code;\n    }\n\n#endif // NO_MAIN_DRIVER\n\n\n\nvoid EchoError(SSL_CTX* ctx, SSL* ssl, SOCKET_T& s1, SOCKET_T& s2,\n               const char* msg)\n{\n    SSL_CTX_free(ctx);\n    SSL_free(ssl);\n    tcp_close(s1);\n    tcp_close(s2);\n    err_sys(msg);\n}\n\n\nTHREAD_RETURN YASSL_API echoserver_test(void* args)\n{\n#ifdef _WIN32\n    WSADATA wsd;\n    WSAStartup(0x0002, &wsd);\n#endif\n\n    SOCKET_T sockfd = 0;\n    int      argc = 0;\n    char**   argv = 0;\n\n    set_args(argc, argv, *static_cast<func_args*>(args));\n\n#ifdef ECHO_OUT\n    FILE* fout = stdout;\n    if (argc >= 2) fout = fopen(argv[1], \"w\");\n    if (!fout) err_sys(\"can't open output file\");\n#endif\n\n    tcp_listen(sockfd);\n\n    SSL_METHOD* method = SSLv23_server_method();\n    SSL_CTX*    ctx    = SSL_CTX_new(method);\n\n    set_serverCerts(ctx);\n    DH* dh = set_tmpDH(ctx);\n\n    bool shutdown(false);\n\n#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER)\n    // signal ready to tcp_accept\n    func_args& server_args = *((func_args*)args);\n    tcp_ready& ready = *server_args.signal_;\n    pthread_mutex_lock(&ready.mutex_);\n    ready.ready_ = true;\n    pthread_cond_signal(&ready.cond_);\n    pthread_mutex_unlock(&ready.mutex_);\n#endif\n\n    while (!shutdown) {\n        SOCKADDR_IN_T client;\n        socklen_t   client_len = sizeof(client);\n        SOCKET_T    clientfd   = accept(sockfd, (sockaddr*)&client,\n                                      (ACCEPT_THIRD_T)&client_len);\n        if (clientfd == (SOCKET_T) -1) {\n            SSL_CTX_free(ctx);\n            tcp_close(sockfd);\n            err_sys(\"tcp accept failed\");\n        }\n\n        SSL* ssl = SSL_new(ctx);\n        SSL_set_fd(ssl, clientfd);\n        if (SSL_accept(ssl) != SSL_SUCCESS) {\n            printf(\"SSL_accept failed\\n\");\n            SSL_free(ssl);\n            tcp_close(clientfd);\n            continue; \n        }\n       \n        char command[1024];\n        int echoSz(0);\n        while ( (echoSz = SSL_read(ssl, command, sizeof(command))) > 0) {\n\n            if ( strncmp(command, \"quit\", 4) == 0) {\n                printf(\"client sent quit command: shutting down!\\n\");\n                shutdown = true;\n                break;\n            }\n            else if ( strncmp(command, \"GET\", 3) == 0) {\n                char type[]   = \"HTTP/1.0 200 ok\\r\\nContent-type:\"\n                                \" text/html\\r\\n\\r\\n\";\n                char header[] = \"<html><body BGCOLOR=\\\"#ffffff\\\">\\n<pre>\\n\";\n                char body[]   = \"greetings from yaSSL\\n\";\n                char footer[] = \"</body></html>\\r\\n\\r\\n\";\n\n                strncpy(command, type, sizeof(type));\n                echoSz = sizeof(type) - 1;\n\n                strncpy(&command[echoSz], header, sizeof(header));\n                echoSz += sizeof(header) - 1;\n                strncpy(&command[echoSz], body, sizeof(body));\n                echoSz += sizeof(body) - 1;\n                strncpy(&command[echoSz], footer, sizeof(footer));\n                echoSz += sizeof(footer);\n\n                if (SSL_write(ssl, command, echoSz) != echoSz)\n                    EchoError(ctx, ssl, sockfd, clientfd, \"SSL_write failed\");\n               \n                break;\n            }\n            command[echoSz] = 0;\n\n        #ifdef ECHO_OUT\n            fputs(command, fout);\n        #endif\n\n            if (SSL_write(ssl, command, echoSz) != echoSz)\n                EchoError(ctx, ssl, sockfd, clientfd, \"SSL_write failed\");\n        }\n        SSL_shutdown(ssl);\n        SSL_free(ssl);\n        tcp_close(clientfd);\n    }\n\n    tcp_close(sockfd);\n\n    DH_free(dh);\n    SSL_CTX_free(ctx);\n\n    ((func_args*)args)->return_code = 0;\n    return 0;\n}\n"
  },
  {
    "path": "ext/yassl/examples/echoserver/echoserver.dsp",
    "content": "# Microsoft Developer Studio Project File - Name=\"echoserver\" - Package Owner=<4>\n# Microsoft Developer Studio Generated Build File, Format Version 6.00\n# ** DO NOT EDIT **\n\n# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\n\nCFG=echoserver - Win32 Debug\n!MESSAGE This is not a valid makefile. To build this project using NMAKE,\n!MESSAGE use the Export Makefile command and run\n!MESSAGE \n!MESSAGE NMAKE /f \"echoserver.mak\".\n!MESSAGE \n!MESSAGE You can specify a configuration when running NMAKE\n!MESSAGE by defining the macro CFG on the command line. For example:\n!MESSAGE \n!MESSAGE NMAKE /f \"echoserver.mak\" CFG=\"echoserver - Win32 Debug\"\n!MESSAGE \n!MESSAGE Possible choices for configuration are:\n!MESSAGE \n!MESSAGE \"echoserver - Win32 Release\" (based on \"Win32 (x86) Console Application\")\n!MESSAGE \"echoserver - Win32 Debug\" (based on \"Win32 (x86) Console Application\")\n!MESSAGE \n\n# Begin Project\n# PROP AllowPerConfigDependencies 0\n# PROP Scc_ProjName \"\"\n# PROP Scc_LocalPath \"\"\nCPP=cl.exe\nRSC=rc.exe\n\n!IF  \"$(CFG)\" == \"echoserver - Win32 Release\"\n\n# PROP BASE Use_MFC 0\n# PROP BASE Use_Debug_Libraries 0\n# PROP BASE Output_Dir \"Release\"\n# PROP BASE Intermediate_Dir \"Release\"\n# PROP BASE Target_Dir \"\"\n# PROP Use_MFC 0\n# PROP Use_Debug_Libraries 0\n# PROP Output_Dir \"Release\"\n# PROP Intermediate_Dir \"Release\"\n# PROP Ignore_Export_Lib 0\n# PROP Target_Dir \"\"\n# ADD BASE CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n# ADD CPP /nologo /G6 /MT /W3 /O2 /I \"..\\..\\include\" /I \"..\\..\\taocrypt\\include\" /D \"NDEBUG\" /D \"WIN32\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n# ADD BASE RSC /l 0x409 /d \"NDEBUG\"\n# ADD RSC /l 0x409 /d \"NDEBUG\"\nBSC32=bscmake.exe\n# ADD BASE BSC32 /nologo\n# ADD BSC32 /nologo\nLINK32=link.exe\n# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\n# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /machine:I386\n\n!ELSEIF  \"$(CFG)\" == \"echoserver - Win32 Debug\"\n\n# PROP BASE Use_MFC 0\n# PROP BASE Use_Debug_Libraries 1\n# PROP BASE Output_Dir \"Debug\"\n# PROP BASE Intermediate_Dir \"Debug\"\n# PROP BASE Target_Dir \"\"\n# PROP Use_MFC 0\n# PROP Use_Debug_Libraries 1\n# PROP Output_Dir \"Debug\"\n# PROP Intermediate_Dir \"Debug\"\n# PROP Ignore_Export_Lib 0\n# PROP Target_Dir \"\"\n# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ /c\n# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I \"..\\..\\include\" /I \"..\\..\\taocrypt\\include\" /D \"_DEBUG\" /D \"WIN32\" /D \"_CONSOLE\" /D \"_MBCS\" /FR /YX /FD /GZ /c\n# ADD BASE RSC /l 0x409 /d \"_DEBUG\"\n# ADD RSC /l 0x409 /d \"_DEBUG\"\nBSC32=bscmake.exe\n# ADD BASE BSC32 /nologo\n# ADD BSC32 /nologo\nLINK32=link.exe\n# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\n# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\n\n!ENDIF \n\n# Begin Target\n\n# Name \"echoserver - Win32 Release\"\n# Name \"echoserver - Win32 Debug\"\n# Begin Group \"Source Files\"\n\n# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\n# Begin Source File\n\nSOURCE=.\\echoserver.cpp\n# End Source File\n# End Group\n# Begin Group \"Header Files\"\n\n# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\n# End Group\n# Begin Group \"Resource Files\"\n\n# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\n# End Group\n# End Target\n# End Project\n"
  },
  {
    "path": "ext/yassl/examples/server/server.cpp",
    "content": "/*\n   Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* server.cpp */\n\n// takes 2 optional command line argument to make scripting\n// if the first  command line argument is 'n' client auth is disabled\n// if the second command line argument is 'd' DSA certs are used instead of RSA\n\n#include \"../../testsuite/test.hpp\"\n\n\nvoid ServerError(SSL_CTX* ctx, SSL* ssl, SOCKET_T& sockfd, const char* msg)\n{\n    SSL_CTX_free(ctx);\n    SSL_free(ssl);\n    tcp_close(sockfd);\n    err_sys(msg);\n}\n\n\n#ifdef NON_BLOCKING\n    void NonBlockingSSL_Accept(SSL* ssl, SSL_CTX* ctx, SOCKET_T& clientfd)\n    {\n        int ret = SSL_accept(ssl);\n        int err = SSL_get_error(ssl, 0);\n        while (ret != SSL_SUCCESS && (err == SSL_ERROR_WANT_READ ||\n                                      err == SSL_ERROR_WANT_WRITE)) {\n            if (err == SSL_ERROR_WANT_READ)\n                printf(\"... server would read block\\n\");\n            else\n                printf(\"... server would write block\\n\");\n            #ifdef _WIN32\n                Sleep(1000);\n            #else\n                sleep(1);\n            #endif\n            ret = SSL_accept(ssl);\n            err = SSL_get_error(ssl, 0);\n        }\n        if (ret != SSL_SUCCESS)\n            ServerError(ctx, ssl, clientfd, \"SSL_accept failed\");\n    }\n#endif\n\n\nTHREAD_RETURN YASSL_API server_test(void* args)\n{\n#ifdef _WIN32\n    WSADATA wsd;\n    WSAStartup(0x0002, &wsd);\n#endif\n\n    SOCKET_T sockfd   = 0;\n    SOCKET_T clientfd = 0;\n    int      argc     = 0;\n    char**   argv     = 0;\n\n    set_args(argc, argv, *static_cast<func_args*>(args));\n#ifdef SERVER_READY_FILE\n    set_file_ready(\"server_ready\", *static_cast<func_args*>(args));\n#endif\n    tcp_accept(sockfd, clientfd, *static_cast<func_args*>(args));\n\n    tcp_close(sockfd);\n\n    SSL_METHOD* method = TLSv1_server_method();\n    SSL_CTX*    ctx = SSL_CTX_new(method);\n\n    //SSL_CTX_set_cipher_list(ctx, \"RC4-SHA:RC4-MD5\");\n    \n    // should we disable client auth\n    if (argc >= 2 && argv[1][0] == 'n')\n        printf(\"disabling client auth\\n\");\n    else\n        SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, 0);\n\n    // are we using DSA certs\n    if (argc >= 3 && argv[2][0] == 'd') {\n        printf(\"using DSA certs\\n\");\n        set_dsaServerCerts(ctx);\n    }\n    else {\n        set_serverCerts(ctx);\n    }\n    DH* dh = set_tmpDH(ctx);\n\n    SSL* ssl = SSL_new(ctx);\n    SSL_set_fd(ssl, clientfd);\n\n#ifdef NON_BLOCKING\n    NonBlockingSSL_Accept(ssl, ctx, clientfd);\n#else\n    if (SSL_accept(ssl) != SSL_SUCCESS)\n        ServerError(ctx, ssl, clientfd, \"SSL_accept failed\");\n#endif\n     \n    showPeer(ssl);\n    printf(\"Using Cipher Suite: %s\\n\", SSL_get_cipher(ssl));\n\n    char command[1024];\n    int input = SSL_read(ssl, command, sizeof(command));\n    if (input > 0) {\n        command[input] = 0;\n        printf(\"First client command: %s\\n\", command);\n    }\n\n    char msg[] = \"I hear you, fa shizzle!\";\n    if (SSL_write(ssl, msg, sizeof(msg)) != sizeof(msg))\n        ServerError(ctx, ssl, clientfd, \"SSL_write failed\");\n\n    DH_free(dh);\n    SSL_CTX_free(ctx);\n    SSL_shutdown(ssl);\n    SSL_free(ssl);\n\n    tcp_close(clientfd);\n\n    ((func_args*)args)->return_code = 0;\n    return 0;\n}\n\n\n#ifndef NO_MAIN_DRIVER\n\n    int main(int argc, char** argv)\n    {\n        func_args args;\n\n        args.argc = argc;\n        args.argv = argv;\n\n        server_test(&args);\n        yaSSL_CleanUp();\n\n        return args.return_code;\n    }\n\n#endif // NO_MAIN_DRIVER\n\n"
  },
  {
    "path": "ext/yassl/examples/server/server.dsp",
    "content": "# Microsoft Developer Studio Project File - Name=\"server\" - Package Owner=<4>\n# Microsoft Developer Studio Generated Build File, Format Version 6.00\n# ** DO NOT EDIT **\n\n# TARGTYPE \"Win32 (x86) Application\" 0x0101\n\nCFG=server - Win32 Debug\n!MESSAGE This is not a valid makefile. To build this project using NMAKE,\n!MESSAGE use the Export Makefile command and run\n!MESSAGE \n!MESSAGE NMAKE /f \"server.mak\".\n!MESSAGE \n!MESSAGE You can specify a configuration when running NMAKE\n!MESSAGE by defining the macro CFG on the command line. For example:\n!MESSAGE \n!MESSAGE NMAKE /f \"server.mak\" CFG=\"server - Win32 Debug\"\n!MESSAGE \n!MESSAGE Possible choices for configuration are:\n!MESSAGE \n!MESSAGE \"server - Win32 Release\" (based on \"Win32 (x86) Application\")\n!MESSAGE \"server - Win32 Debug\" (based on \"Win32 (x86) Application\")\n!MESSAGE \n\n# Begin Project\n# PROP AllowPerConfigDependencies 0\n# PROP Scc_ProjName \"\"\n# PROP Scc_LocalPath \"\"\nCPP=cl.exe\nMTL=midl.exe\nRSC=rc.exe\n\n!IF  \"$(CFG)\" == \"server - Win32 Release\"\n\n# PROP BASE Use_MFC 0\n# PROP BASE Use_Debug_Libraries 0\n# PROP BASE Output_Dir \"Release\"\n# PROP BASE Intermediate_Dir \"Release\"\n# PROP BASE Target_Dir \"\"\n# PROP Use_MFC 0\n# PROP Use_Debug_Libraries 0\n# PROP Output_Dir \"Release\"\n# PROP Intermediate_Dir \"Release\"\n# PROP Ignore_Export_Lib 0\n# PROP Target_Dir \"\"\n# ADD BASE CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\n# ADD CPP /nologo /MT /W3 /O2 /I \"..\\..\\include\" /I \"..\\..\\taocrypt\\include\" /D \"WIN32\" /D \"NDEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /c\n# ADD BASE MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\n# ADD MTL /nologo /D \"NDEBUG\" /mktyplib203 /win32\n# ADD BASE RSC /l 0x409 /d \"NDEBUG\"\n# ADD RSC /l 0x409 /d \"NDEBUG\"\nBSC32=bscmake.exe\n# ADD BASE BSC32 /nologo\n# ADD BSC32 /nologo\nLINK32=link.exe\n# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386\n# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /machine:I386\n# SUBTRACT LINK32 /pdb:none\n\n!ELSEIF  \"$(CFG)\" == \"server - Win32 Debug\"\n\n# PROP BASE Use_MFC 0\n# PROP BASE Use_Debug_Libraries 1\n# PROP BASE Output_Dir \"Debug\"\n# PROP BASE Intermediate_Dir \"Debug\"\n# PROP BASE Target_Dir \"\"\n# PROP Use_MFC 0\n# PROP Use_Debug_Libraries 1\n# PROP Output_Dir \"Debug\"\n# PROP Intermediate_Dir \"Debug\"\n# PROP Ignore_Export_Lib 0\n# PROP Target_Dir \"\"\n# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /YX /FD /GZ /c\n# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I \"..\\..\\include\" /I \"..\\..\\taocrypt\\include\" /D \"WIN32\" /D \"_DEBUG\" /D \"_WINDOWS\" /D \"_MBCS\" /FR /YX /FD /GZ /c\n# ADD BASE MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\n# ADD MTL /nologo /D \"_DEBUG\" /mktyplib203 /win32\n# ADD BASE RSC /l 0x409 /d \"_DEBUG\"\n# ADD RSC /l 0x409 /d \"_DEBUG\"\nBSC32=bscmake.exe\n# ADD BASE BSC32 /nologo\n# ADD BSC32 /nologo\nLINK32=link.exe\n# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept\n# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\n# SUBTRACT LINK32 /pdb:none /nodefaultlib\n\n!ENDIF \n\n# Begin Target\n\n# Name \"server - Win32 Release\"\n# Name \"server - Win32 Debug\"\n# Begin Group \"Source Files\"\n\n# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\n# Begin Source File\n\nSOURCE=.\\server.cpp\n# End Source File\n# End Group\n# Begin Group \"Header Files\"\n\n# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\n# End Group\n# Begin Group \"Resource Files\"\n\n# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\n# End Group\n# End Target\n# End Project\n"
  },
  {
    "path": "ext/yassl/include/buffer.hpp",
    "content": "/*\n   Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* yaSSL buffer header defines input and output buffers to simulate streaming\n * with SSL types and sockets\n */\n\n#ifndef yaSSL_BUFFER_HPP\n#define yaSSL_BUFFER_HPP\n\n#include <assert.h>             // assert\n#include \"yassl_types.hpp\"      // ysDelete\n#include \"memory.hpp\"           // mySTL::auto_ptr\n#include STL_ALGORITHM_FILE\n\n\nnamespace STL = STL_NAMESPACE;\n\n\n#ifdef _MSC_VER\n    // disable truncated debug symbols\n    #pragma warning(disable:4786)\n#endif\n\n\nnamespace yaSSL {\n\ntypedef unsigned char byte;\ntypedef unsigned int  uint;\nconst uint AUTO = 0xFEEDBEEF;\n\n\n\nstruct NoCheck {\n    int check(uint, uint);\n};\n\nstruct Check {\n    int check(uint, uint);\n};\n\n/* input_buffer operates like a smart c style array with a checking option, \n * meant to be read from through [] with AUTO index or read().\n * Should only write to at/near construction with assign() or raw (e.g., recv)\n * followed by add_size with the number of elements added by raw write.\n *\n * Not using vector because need checked []access, offset, and the ability to\n * write to the buffer bulk wise and have the correct size\n */\n\nclass input_buffer : public Check {\n    uint   size_;                // number of elements in buffer\n    uint   current_;             // current offset position in buffer\n    byte*  buffer_;              // storage for buffer\n    byte*  end_;                 // end of storage marker\n    int    error_;               // error number\n    byte   zero_;                // for returning const reference to zero byte\npublic:\n    input_buffer();\n\n    explicit input_buffer(uint s);\n                          \n    // with assign\n    input_buffer(uint s, const byte* t, uint len);\n    \n    ~input_buffer();\n\n    // users can pass defualt zero length buffer and then allocate\n    void allocate(uint s);\n\n    // for passing to raw writing functions at beginning, then use add_size\n    byte* get_buffer() const;\n\n    // after a raw write user can set new size\n    // if you know the size before the write use assign()\n    void add_size(uint i);\n\n    uint get_capacity()  const;\n\n    uint get_current()   const;\n\n    uint get_size()      const;\n\n    uint get_remaining() const;\n\n    int  get_error()     const;\n\n    void set_error();\n\n    void set_current(uint i);\n\n    // read only access through [], advance current\n    // user passes in AUTO index for ease of use\n    const byte& operator[](uint i);\n    \n    // end of input test\n    bool eof();\n\n    // peek ahead\n    byte peek();\n\n    // write function, should use at/near construction\n    void assign(const byte* t, uint s);\n    \n    // use read to query input, adjusts current\n    void read(byte* dst, uint length);\n\nprivate:\n    input_buffer(const input_buffer&);              // hide copy\n    input_buffer& operator=(const input_buffer&);   // and assign\n};\n\n\n/* output_buffer operates like a smart c style array with a checking option.\n * Meant to be written to through [] with AUTO index or write().\n * Size (current) counter increases when written to. Can be constructed with \n * zero length buffer but be sure to allocate before first use. \n * Don't use add write for a couple bytes, use [] instead, way less overhead.\n * \n * Not using vector because need checked []access and the ability to\n * write to the buffer bulk wise and retain correct size\n */\nclass output_buffer : public NoCheck {\n    uint    current_;                // current offset and elements in buffer\n    byte*   buffer_;                 // storage for buffer\n    byte*   end_;                    // end of storage marker\npublic:\n    // default\n    output_buffer();\n\n    // with allocate\n    explicit output_buffer(uint s);\n\n    // with assign\n    output_buffer(uint s, const byte* t, uint len);\n\n    ~output_buffer();\n\n    uint get_size() const;\n\n    uint get_capacity() const;\n\n    void set_current(uint c);\n\n    // users can pass defualt zero length buffer and then allocate\n    void allocate(uint s);\n\n    // for passing to reading functions when finished\n    const byte* get_buffer() const;\n\n    // allow write access through [], update current\n    // user passes in AUTO as index for ease of use\n    byte& operator[](uint i);\n    \n    // end of output test\n    bool eof();\n\n    void write(const byte* t, uint s);\n\nprivate:\n    output_buffer(const output_buffer&);              // hide copy\n    output_buffer& operator=(const output_buffer&);   // and assign\n};\n\n\n\n\n// turn delete an incomplete type into comipler error instead of warning\ntemplate <typename T>\ninline void checked_delete(T* p)\n{\n    typedef char complete_type[sizeof(T) ? 1 : -1];\n    (void)sizeof(complete_type);\n    ysDelete(p);\n}\n\n\n// checked delete functor increases effeciency, no indirection on function call\n// sets pointer to zero so safe for std conatiners\nstruct del_ptr_zero\n{\n    template <typename T>\n    void operator()(T*& p) const\n    {\n        T* tmp = 0;\n        STL::swap(tmp, p);\n        checked_delete(tmp); \n    }\n};\n\n\n\n} // naemspace\n\n#endif // yaSSL_BUUFER_HPP\n"
  },
  {
    "path": "ext/yassl/include/cert_wrapper.hpp",
    "content": "/*\n   Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n */\n\n\n/*  The certificate wrapper header defines certificate management functions\n *\n */\n\n\n#ifndef yaSSL_CERT_WRAPPER_HPP\n#define yaSSL_CERT_WRAPPER_HPP\n\n#ifdef _MSC_VER\n    // disable truncated debug symbols\n    #pragma warning(disable:4786)\n#endif\n\n\n#include \"yassl_types.hpp\"  // SignatureAlgorithm\n#include \"buffer.hpp\"       // input_buffer\n#include \"asn.hpp\"          // SignerList\n#include \"openssl/ssl.h\"    // internal and external use\n#include STL_LIST_FILE\n#include STL_ALGORITHM_FILE\n\n\nnamespace STL = STL_NAMESPACE;\n\n\nnamespace yaSSL {\n   \ntypedef unsigned char opaque;\nclass X509;                     // forward openSSL type\n\nusing TaoCrypt::SignerList;\n\n// an x509 version 3 certificate\nclass x509 {\n    uint    length_;\n    opaque* buffer_;\npublic:\n    explicit x509(uint sz);\n    ~x509();\n\n    uint          get_length() const;\n    const opaque* get_buffer() const;\n    opaque*       use_buffer();\n\n    x509(const x509&);\n    x509& operator=(const x509&);\nprivate:\n    void Swap(x509&);\n};\n\n\n// Certificate Manager keeps a list of the cert chain and public key\nclass CertManager {\n    typedef STL::list<x509*> CertList;\n\n    CertList     list_;                 // self      \n    input_buffer privateKey_;\n\n    CertList     peerList_;             // peer\n    input_buffer peerPublicKey_;\n    X509*        peerX509_;             // peer's openSSL X509\n    X509*        selfX509_;             // our own openSSL X509\n\n    SignatureAlgorithm keyType_;        // self   key type\n    SignatureAlgorithm peerKeyType_;    // peer's key type\n\n    SignerList   signers_;              // decoded CA keys and names\n                                        //    plus verified chained certs\n    bool verifyPeer_;\n    bool verifyNone_;                   // no error if verify fails\n    bool failNoCert_;\n    bool sendVerify_;\n    bool sendBlankCert_;\n    VerifyCallback verifyCallback_;     // user verify callback\npublic:\n    CertManager();\n    ~CertManager();\n\n    void AddPeerCert(x509* x);      // take ownership\n    void CopySelfCert(const x509* x);\n    int  CopyCaCert(const x509* x);\n    int  Validate();\n\n    int SetPrivateKey(const x509&);\n\n    const x509*        get_cert()        const;\n    const opaque*      get_peerKey()     const;\n    const opaque*      get_privateKey()  const;\n          X509*        get_peerX509()    const;\n          X509*        get_selfX509()    const;\n    SignatureAlgorithm get_keyType()     const;\n    SignatureAlgorithm get_peerKeyType() const;\n\n    uint get_peerKeyLength()       const;\n    uint get_privateKeyLength()    const;\n\n    bool verifyPeer() const;\n    bool verifyNone() const;\n    bool failNoCert() const;\n    bool sendVerify() const;\n    bool sendBlankCert() const;\n\n    void setVerifyPeer();\n    void setVerifyNone();\n    void setFailNoCert();\n    void setSendVerify();\n    void setSendBlankCert();\n    void setPeerX509(X509*);\n    void setVerifyCallback(VerifyCallback);\nprivate:\n    CertManager(const CertManager&);            // hide copy\n    CertManager& operator=(const CertManager&); // and assigin\n};\n\n\n} // naemspace\n\n#endif // yaSSL_CERT_WRAPPER_HPP\n"
  },
  {
    "path": "ext/yassl/include/crypto_wrapper.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/*  The crypto wrapper header is used to define policies for the cipher \n *  components used by SSL.  There are 3 policies to consider:\n *\n *  1) MAC, the Message Authentication Code used for each Message\n *  2) Bulk Cipher, the Cipher used to encrypt/decrypt each Message\n *  3) Atuhentication, the Digitial Signing/Verifiaction scheme used\n *\n *  This header doesn't rely on a specific crypto libraries internals,\n *  only the implementation should.\n */\n\n\n#ifndef yaSSL_CRYPTO_WRAPPER_HPP\n#define yaSSL_CRYPTO_WRAPPER_HPP\n\n#include \"yassl_types.hpp\"\n#include <stdio.h>   // FILE\n\n\nnamespace yaSSL {\n\n\n// Digest policy should implement a get_digest, update, and get sizes for pad\n// and  digest\nstruct Digest : public virtual_base {\n    virtual void   get_digest(byte*) = 0;\n    virtual void   get_digest(byte*, const byte*, unsigned int) = 0;\n    virtual void   update(const byte*, unsigned int) = 0;\n    virtual uint   get_digestSize() const = 0;\n    virtual uint   get_padSize() const = 0;\n    virtual ~Digest() {}\n};\n\n\n// For use with NULL Digests\nstruct NO_MAC : public Digest {\n    void   get_digest(byte*);\n    void   get_digest(byte*, const byte*, unsigned int);\n    void   update(const byte*, unsigned int);\n    uint   get_digestSize() const;\n    uint   get_padSize()    const;\n};\n\n\n// MD5 Digest\nclass MD5 : public Digest {\npublic:\n    void   get_digest(byte*);\n    void   get_digest(byte*, const byte*, unsigned int);\n    void   update(const byte*, unsigned int);\n    uint   get_digestSize() const;\n    uint   get_padSize()    const;\n    MD5();\n    ~MD5();\n    MD5(const MD5&);\n    MD5& operator=(const MD5&);\nprivate:\n    struct MD5Impl;\n    MD5Impl* pimpl_;\n};\n\n\n// SHA-1 Digest\nclass SHA : public Digest {\npublic:\n    void   get_digest(byte*);\n    void   get_digest(byte*, const byte*, unsigned int);\n    void   update(const byte*, unsigned int);\n    uint   get_digestSize() const;\n    uint   get_padSize()    const;\n    SHA();\n    ~SHA();\n    SHA(const SHA&);\n    SHA& operator=(const SHA&);\nprivate:\n    struct SHAImpl;\n    SHAImpl* pimpl_;\n\n};\n\n\n// RIPEMD-160 Digest\nclass RMD : public Digest {\npublic:\n    void   get_digest(byte*);\n    void   get_digest(byte*, const byte*, unsigned int);\n    void   update(const byte*, unsigned int);\n    uint   get_digestSize() const;\n    uint   get_padSize()    const;\n    RMD();\n    ~RMD();\n    RMD(const RMD&);\n    RMD& operator=(const RMD&);\nprivate:\n    struct RMDImpl;\n    RMDImpl* pimpl_;\n\n};\n\n\n// HMAC_MD5\nclass HMAC_MD5 : public Digest {\npublic:\n    void   get_digest(byte*);\n    void   get_digest(byte*, const byte*, unsigned int);\n    void   update(const byte*, unsigned int);\n    uint   get_digestSize() const;\n    uint   get_padSize()    const;\n    HMAC_MD5(const byte*, unsigned int);\n    ~HMAC_MD5();\nprivate:\n    struct HMAC_MD5Impl;\n    HMAC_MD5Impl* pimpl_;\n\n    HMAC_MD5(const HMAC_MD5&);\n    HMAC_MD5& operator=(const HMAC_MD5&);\n};\n\n\n// HMAC_SHA-1\nclass HMAC_SHA : public Digest {\npublic:\n    void   get_digest(byte*);\n    void   get_digest(byte*, const byte*, unsigned int);\n    void   update(const byte*, unsigned int);\n    uint   get_digestSize() const;\n    uint   get_padSize()    const;\n    HMAC_SHA(const byte*, unsigned int);\n    ~HMAC_SHA();\nprivate:\n    struct HMAC_SHAImpl;\n    HMAC_SHAImpl* pimpl_;\n\n    HMAC_SHA(const HMAC_SHA&);\n    HMAC_SHA& operator=(const HMAC_SHA&);\n};\n\n\n// HMAC_RMD\nclass HMAC_RMD : public Digest {\npublic:\n    void   get_digest(byte*);\n    void   get_digest(byte*, const byte*, unsigned int);\n    void   update(const byte*, unsigned int);\n    uint   get_digestSize() const;\n    uint   get_padSize()    const;\n    HMAC_RMD(const byte*, unsigned int);\n    ~HMAC_RMD();\nprivate:\n    struct HMAC_RMDImpl;\n    HMAC_RMDImpl* pimpl_;\n\n    HMAC_RMD(const HMAC_RMD&);\n    HMAC_RMD& operator=(const HMAC_RMD&);\n};\n\n\n// BulkCipher policy should implement encrypt, decrypt, get block size, \n// and set keys for encrypt and decrypt\nstruct BulkCipher : public virtual_base {\n    virtual void   encrypt(byte*, const byte*, unsigned int) = 0;\n    virtual void   decrypt(byte*, const byte*, unsigned int) = 0;\n    virtual void   set_encryptKey(const byte*, const byte* = 0) = 0;\n    virtual void   set_decryptKey(const byte*, const byte* = 0) = 0;\n    virtual uint   get_blockSize() const = 0;\n    virtual int    get_keySize()   const = 0;\n    virtual int    get_ivSize()    const = 0;\n    virtual ~BulkCipher() {}\n};\n\n\n// For use with NULL Ciphers\nstruct NO_Cipher : public BulkCipher {\n    void   encrypt(byte*, const byte*, unsigned int) {}\n    void   decrypt(byte*, const byte*, unsigned int) {}\n    void   set_encryptKey(const byte*, const byte*)  {}\n    void   set_decryptKey(const byte*, const byte*)  {}\n    uint   get_blockSize() const { return 0; }\n    int    get_keySize()   const { return 0; }\n    int    get_ivSize()    const { return 0; }\n};\n\n\n// SSLv3 and TLSv1 always use DES in CBC mode so IV is required\nclass DES : public BulkCipher {\npublic:\n    void   encrypt(byte*, const byte*, unsigned int);\n    void   decrypt(byte*, const byte*, unsigned int);\n    void   set_encryptKey(const byte*, const byte*);\n    void   set_decryptKey(const byte*, const byte*);\n    uint   get_blockSize() const { return DES_BLOCK; }\n    int    get_keySize()   const { return DES_KEY_SZ; }\n    int    get_ivSize()    const { return DES_IV_SZ; }\n    DES();\n    ~DES();\nprivate:\n    struct DESImpl;\n    DESImpl* pimpl_;\n\n    DES(const DES&);                // hide copy\n    DES& operator=(const DES&);     // & assign\n};\n\n\n// 3DES Encrypt-Decrypt-Encrypt in CBC mode\nclass DES_EDE : public BulkCipher {\npublic:\n    void   encrypt(byte*, const byte*, unsigned int);\n    void   decrypt(byte*, const byte*, unsigned int);\n    void   set_encryptKey(const byte*, const byte*);\n    void   set_decryptKey(const byte*, const byte*);\n    uint   get_blockSize() const { return DES_BLOCK; }\n    int    get_keySize()   const { return DES_EDE_KEY_SZ; }\n    int    get_ivSize()    const { return DES_IV_SZ; }\n    DES_EDE();\n    ~DES_EDE();\nprivate:\n    struct DES_EDEImpl;\n    DES_EDEImpl* pimpl_;\n\n    DES_EDE(const DES_EDE&);            // hide copy\n    DES_EDE& operator=(const DES_EDE&); // & assign\n};\n\n\n// Alledged RC4\nclass RC4 : public BulkCipher {\npublic:\n    void encrypt(byte*, const byte*, unsigned int);\n    void decrypt(byte*, const byte*, unsigned int);\n    void set_encryptKey(const byte*, const byte*);\n    void set_decryptKey(const byte*, const byte*);\n    uint get_blockSize() const { return 0; }\n    int  get_keySize()   const { return RC4_KEY_SZ; }\n    int  get_ivSize()    const { return 0; }\n    RC4();\n    ~RC4();\nprivate:\n    struct RC4Impl;\n    RC4Impl* pimpl_;\n\n    RC4(const RC4&);             // hide copy\n    RC4& operator=(const RC4&);  // & assign\n};\n\n\n// AES\nclass AES : public BulkCipher {\npublic:\n    void encrypt(byte*, const byte*, unsigned int);\n    void decrypt(byte*, const byte*, unsigned int);\n    void set_encryptKey(const byte*, const byte*);\n    void set_decryptKey(const byte*, const byte*);\n    uint get_blockSize() const { return AES_BLOCK_SZ; }\n    int  get_keySize()   const;\n    int  get_ivSize()    const { return AES_IV_SZ; }\n    explicit AES(unsigned int = AES_128_KEY_SZ);\n    ~AES();\nprivate:\n    struct AESImpl;\n    AESImpl* pimpl_;\n\n    AES(const AES&);             // hide copy\n    AES& operator=(const AES&);  // & assign\n};\n\n\n// Random number generator\nclass RandomPool {\npublic:\n    void Fill(opaque* dst, uint sz) const;\n    RandomPool();\n    ~RandomPool();\n\n    int GetError() const;\n\n    friend class RSA;\n    friend class DSS;\n    friend class DiffieHellman;\nprivate:\n    struct RandomImpl;\n    RandomImpl* pimpl_;\n\n    RandomPool(const RandomPool&);              // hide copy\n    RandomPool& operator=(const RandomPool&);   // & assign\n};\n\n\n// Authentication policy should implement sign, and verify\nstruct Auth : public virtual_base {\n    virtual void sign(byte*, const byte*, unsigned int, const RandomPool&) = 0;\n    virtual bool verify(const byte*, unsigned int, const byte*,\n                        unsigned int) = 0;\n    virtual uint get_signatureLength() const = 0;\n    virtual ~Auth() {}\n};\n\n\n// For use with NULL Authentication schemes\nstruct NO_Auth : public Auth {\n    void   sign(byte*, const byte*, unsigned int, const RandomPool&) {}\n    bool   verify(const byte*, unsigned int, const byte*, unsigned int) \n                    { return true; }\n};\n\n\n// Digitial Signature Standard scheme\nclass DSS : public Auth {\npublic:\n    void sign(byte*, const byte*, unsigned int, const RandomPool&);\n    bool verify(const byte*, unsigned int, const byte*, unsigned int);\n    uint get_signatureLength() const;\n    DSS(const byte*, unsigned int, bool publicKey = true);\n    ~DSS();\nprivate:\n    struct DSSImpl;\n    DSSImpl* pimpl_;\n\n    DSS(const DSS&);\n    DSS& operator=(const DSS&);\n};\n\n\n// RSA Authentication and exchange\nclass RSA : public Auth {\npublic:\n    void   sign(byte*, const byte*, unsigned int, const RandomPool&);\n    bool   verify(const byte*, unsigned int, const byte*, unsigned int);\n    void   encrypt(byte*, const byte*, unsigned int, const RandomPool&);\n    void   decrypt(byte*, const byte*, unsigned int, const RandomPool&);\n    uint   get_signatureLength() const;\n    uint   get_cipherLength() const;\n    RSA(const byte*, unsigned int, bool publicKey = true);\n    ~RSA();\nprivate:\n    struct RSAImpl;\n    RSAImpl* pimpl_;\n\n    RSA(const RSA&);            // hide copy\n    RSA& operator=(const RSA&); // & assing\n};\n\n\nclass Integer;\n\n// Diffie-Hellman agreement\n// hide for now TODO: figure out a way to give access to C clients p and g args\nclass DiffieHellman  {\npublic:\n    DiffieHellman(const byte*, unsigned int, const byte*, unsigned int,\n                  const byte*, unsigned int, const RandomPool& random);\n    //DiffieHellman(const char*, const RandomPool&);\n    DiffieHellman(const Integer&, const Integer&, const RandomPool&);\n    ~DiffieHellman();\n\n    DiffieHellman(const DiffieHellman&);  \n    DiffieHellman& operator=(const DiffieHellman&);\n\n    uint        get_agreedKeyLength() const;\n    const byte* get_agreedKey()       const;\n    const byte* get_publicKey()       const;\n    void        makeAgreement(const byte*, unsigned int);\n\n    void        set_sizes(int&, int&, int&) const;\n    void        get_parms(byte*, byte*, byte*) const;\nprivate:\n    struct DHImpl;\n    DHImpl* pimpl_;\n};\n\n\n// Lagrge Integer\nclass Integer {\npublic:\n    Integer();\n    ~Integer();\n\n    Integer(const Integer&);\n    Integer& operator=(const Integer&);\n\n    void assign(const byte*, unsigned int);\n\n    friend class DiffieHellman;\nprivate:\n    struct IntegerImpl;\n    IntegerImpl* pimpl_;\n};\n\n\nclass x509;\n\n\nstruct EncryptedInfo {\n    enum { IV_SZ = 32, NAME_SZ = 80 };\n    char  name[NAME_SZ]; // max one line\n    byte  iv[IV_SZ];     // in base16 rep\n    uint  ivSz;\n    bool  set;\n\n    EncryptedInfo() : ivSz(0), set(false) {}\n};\n\nx509* PemToDer(FILE*, CertType, EncryptedInfo* info = 0);\n\n\n} // naemspace\n\n#endif  // yaSSL_CRYPTO_WRAPPER_HPP\n"
  },
  {
    "path": "ext/yassl/include/factory.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/*  The factory header defines an Object Factory, used by SSL message and\n *  handshake types.\n *\n *  See Desgin Pattern in GoF and Alexandrescu's chapter in Modern C++ Design,\n *  page 208\n */\n\n\n\n#ifndef yaSSL_FACTORY_HPP\n#define yaSSL_FACTORY_HPP\n\n#include STL_VECTOR_FILE\n#include STL_PAIR_FILE\n\n\nnamespace STL = STL_NAMESPACE;\n\n\n\n\n\nnamespace yaSSL {\n\n\n// Factory uses its callback map to create objects by id,\n// returning an abstract base pointer\ntemplate<class    AbstractProduct, \n         typename IdentifierType = int, \n         typename ProductCreator = AbstractProduct* (*)()\n        >\nclass Factory {                                             \n    typedef STL::pair<IdentifierType, ProductCreator> CallBack;\n    typedef STL::vector<CallBack> CallBackVector;\n\n    CallBackVector callbacks_;\npublic:\n    // pass function pointer to register all callbacks upon creation\n    explicit Factory(void (*init)(Factory<AbstractProduct, IdentifierType,\n                                  ProductCreator>&))\n    { \n        init(*this); \n    }\n\n    // reserve place in vector before registering, used by init funcion\n    void Reserve(size_t sz)\n    {\n        callbacks_.reserve(sz);\n    }\n\n    // register callback\n    void Register(const IdentifierType& id, ProductCreator pc)\n    {\n        callbacks_.push_back(STL::make_pair(id, pc));\n    }\n\n    // THE Creator, returns a new object of the proper type or 0\n    AbstractProduct* CreateObject(const IdentifierType& id) const\n    {\n        typedef typename STL::vector<CallBack>::const_iterator cIter;\n        \n        cIter first = callbacks_.begin();\n        cIter last  = callbacks_.end();\n\n        while (first != last) {\n            if (first->first == id)\n                break;\n            ++first;\n        }\n\n        if (first == callbacks_.end())\n            return 0;\n        return (first->second)();\n    }\nprivate:\n    Factory(const Factory&);            // hide copy\n    Factory& operator=(const Factory&); // and assign\n};\n\n\n} // naemspace\n\n#endif // yaSSL_FACTORY_HPP\n"
  },
  {
    "path": "ext/yassl/include/handshake.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* The handshake header declares function prototypes for creating and reading\n * the various handshake messages.\n */\n\n\n\n#ifndef yaSSL_HANDSHAKE_HPP\n#define yaSSL_HANDSHAKE_HPP\n\n#include \"yassl_types.hpp\"\n\n\nnamespace yaSSL {\n\n// forward decls\nclass  SSL;\nclass  Finished;\nclass  Data;\nclass  Alert;\nstruct Hashes;\n\nenum BufferOutput { buffered, unbuffered };\n\nvoid sendClientHello(SSL&);\nvoid sendServerHello(SSL&, BufferOutput = buffered);\nvoid sendServerHelloDone(SSL&, BufferOutput = buffered);\nvoid sendClientKeyExchange(SSL&, BufferOutput = buffered);\nvoid sendServerKeyExchange(SSL&, BufferOutput = buffered);\nvoid sendChangeCipher(SSL&, BufferOutput = buffered);\nvoid sendFinished(SSL&, ConnectionEnd, BufferOutput = buffered);\nvoid sendCertificate(SSL&, BufferOutput = buffered);\nvoid sendCertificateRequest(SSL&, BufferOutput = buffered);\nvoid sendCertificateVerify(SSL&, BufferOutput = buffered);\nint  sendData(SSL&, const void*, int);\nint  sendAlert(SSL& ssl, const Alert& alert);\n\nint  receiveData(SSL&, Data&, bool peek = false); \nvoid processReply(SSL&);\n\nvoid buildFinished(SSL&, Finished&, const opaque*);\nvoid build_certHashes(SSL&, Hashes&);\n\nvoid hmac(SSL&, byte*, const byte*, uint, ContentType, bool verify = false);\nvoid TLS_hmac(SSL&, byte*, const byte*, uint, ContentType,\n              bool verify = false);\nvoid PRF(byte* digest, uint digLen, const byte* secret, uint secLen,\n         const byte* label, uint labLen, const byte* seed, uint seedLen);\n\n} // naemspace\n\n#endif // yaSSL_HANDSHAKE_HPP\n"
  },
  {
    "path": "ext/yassl/include/lock.hpp",
    "content": "/*\n   Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* lock.hpp provides an os specific Lock, locks mutex on entry and unlocks\n * automatically upon exit, no-ops provided for Single Threaded\n*/\n\n#ifndef yaSSL_LOCK_HPP\n#define yaSSL_LOCK_HPP\n\n/*\n  Visual Studio Source Annotations header (sourceannotations.h) fails\n  to compile if outside of the global namespace.\n*/\n#ifdef MULTI_THREADED\n#ifdef _WIN32\n#include <windows.h>\n#endif\n#endif\n\nnamespace yaSSL {\n\n\n#ifdef MULTI_THREADED\n    #ifdef _WIN32\n        #include <windows.h>\n\n        class Mutex {\n            CRITICAL_SECTION cs_;\n        public:\n            Mutex();\n            ~Mutex();\n\n            class Lock;\n            friend class Lock;\n    \n            class Lock {\n                Mutex& mutex_;\n            public:\n                explicit Lock(Mutex& lm);\n                ~Lock();\n            };\n        };\n    #else  // _WIN32\n        #include <pthread.h>\n\n        class Mutex {\n            pthread_mutex_t mutex_;\n        public:\n\n            Mutex();\n            ~Mutex();\n\n            class Lock;\n            friend class Lock;\n\n            class Lock {\n                Mutex& mutex_;\n            public:\n                explicit Lock(Mutex& lm);\n                ~Lock();\n            };\n        };\n\n    #endif // _WIN32\n#else  // MULTI_THREADED (WE'RE SINGLE)\n\n    class Mutex {\n    public:\n        class Lock {\n        public:\n            explicit Lock(Mutex&) {}\n        };\n    };\n\n#endif // MULTI_THREADED\n\n\n\n} // namespace\n#endif // yaSSL_LOCK_HPP\n"
  },
  {
    "path": "ext/yassl/include/log.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* yaSSL log interface\n *\n */\n\n#ifndef yaSSL_LOG_HPP\n#define yaSSL_LOG_HPP\n\n#include \"socket_wrapper.hpp\"\n\n#ifdef YASSL_LOG\n#include <stdio.h>\n#endif\n\nnamespace yaSSL {\n\ntypedef unsigned int uint;\n\n\n// Debug logger\nclass Log {\n#ifdef YASSL_LOG\n    FILE* log_;\n#endif\npublic:\n    explicit Log(const char* str = \"yaSSL.log\");\n    ~Log();\n\n    void Trace(const char*);\n    void ShowTCP(socket_t, bool ended = false);\n    void ShowData(uint, bool sent = false);\n};\n\n\n} // naemspace\n\n#endif // yaSSL_LOG_HPP\n"
  },
  {
    "path": "ext/yassl/include/openssl/crypto.h",
    "content": "/* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; if not, write to the Free Software\n   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */\n\n/* crypto.h for openSSL */\n\n#ifndef yaSSL_crypto_h__\n#define yaSSL_crypto_h__\n\n#ifdef YASSL_PREFIX\n#include \"prefix_crypto.h\"\n#endif\n\nconst char* SSLeay_version(int type);\n\n#define SSLEAY_NUMBER_DEFINED\n#define SSLEAY_VERSION 0x0900L\n#define SSLEAY_VERSION_NUMBER SSLEAY_VERSION\n\n\n#endif /* yaSSL_crypto_h__ */\n\n"
  },
  {
    "path": "ext/yassl/include/openssl/des.h",
    "content": "/*\n   Copyright (C) 2005 MySQL AB\n   Use is subject to license terms\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* des.h  for openssl */\n"
  },
  {
    "path": "ext/yassl/include/openssl/des_old.h",
    "content": "/*\n   Copyright (C) 2007 MySQL AB\n   Use is subject to license terms\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* des_old.h  for openvn */\n"
  },
  {
    "path": "ext/yassl/include/openssl/engine.h",
    "content": "/*\n   Copyright (C) 2006 MySQL AB\n   Use is subject to license terms\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* engine.h for libcurl */\n\n#undef HAVE_OPENSSL_ENGINE_H\n\n\n"
  },
  {
    "path": "ext/yassl/include/openssl/err.h",
    "content": "/*\n   Copyright (C) 2005, 2006 MySQL AB\n   Use is subject to license terms\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* err.h for openssl */\n\n#ifndef yaSSL_err_h__\n#define yaSSL_err_h__\n\n\n\n#endif /* yaSSL_err_h__ */\n"
  },
  {
    "path": "ext/yassl/include/openssl/evp.h",
    "content": "/*\n   Copyright (C) 2007 MySQL AB\n   Use is subject to license terms\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* evp.h for openSSL */\n\n#ifndef SSLEAY_NUMBER_DEFINED\n#define SSLEAY_NUMBER_DEFINED\n\n/* for OpenVPN */\n#define SSLEAY_VERSION_NUMBER 0x0090700f\n\n\n#endif /* SSLEAY_NUMBER_DEFINED */\n"
  },
  {
    "path": "ext/yassl/include/openssl/generate_prefix_files.pl",
    "content": "#!/usr/bin/perl\n\n# Copyright (C) 2006 MySQL AB\n# Use is subject to license terms\n# \n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n# \n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n# \n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\n\n#\n# This script generates defines for all functions\n# in yassl/include/openssl/ so they are renamed to\n# ya<old_function_name>. Hopefully that is unique enough.\n#\n# The script is to be run manually when we import\n# a new version of yaSSL\n#\n\n\n\n# Find all functions in \"input\" and add macros\n# to prefix/rename them into \"output\nsub generate_prefix($$)\n{\n  my $input= shift;\n  my $output= shift;\n  open(IN, $input)\n      or die(\"Can't open input file $input: $!\");\n  open(OUT, \">\", $output)\n    or mtr_error(\"Can't open output file $output: $!\");\n\n  while (<IN>)\n  {\n    chomp;\n\n    if ( /typedef/ )\n    {\n      next;\n    }\n\n    if ( /^\\s*[a-zA-Z0-9*_ ]+\\s+\\*?([_a-zA-Z0-9]+)\\s*\\(/ )\n    {\n      print OUT \"#define $1 ya$1\\n\";\n    }\n  }\n\n  close OUT;\n  close IN;\n}\n\ngenerate_prefix(\"ssl.h\", \"prefix_ssl.h\");\ngenerate_prefix(\"crypto.h\", \"prefix_crypto.h\");\n\n"
  },
  {
    "path": "ext/yassl/include/openssl/hmac.h",
    "content": "/*\n   Copyright (C) 2007 MySQL AB\n   Use is subject to license terms\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* hmac.h  for openvpn */\n"
  },
  {
    "path": "ext/yassl/include/openssl/lhash.h",
    "content": "/*\n   Copyright (C) 2005 MySQL AB\n   Use is subject to license terms\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* lhash.h for openSSL */\n\n"
  },
  {
    "path": "ext/yassl/include/openssl/md4.h",
    "content": "/*\n   Copyright (C) 2006 MySQL AB\n   Use is subject to license terms\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* md4.h for libcurl */\n"
  },
  {
    "path": "ext/yassl/include/openssl/md5.h",
    "content": "/*\n   Copyright (C) 2005, 2006 MySQL AB\n   Use is subject to license terms\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* md5.h for openssl */\n\n#include \"ssl.h\"   /* in there for now */\n\n"
  },
  {
    "path": "ext/yassl/include/openssl/objects.h",
    "content": "/*\n   Copyright (C) 2007 MySQL AB\n   Use is subject to license terms\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* objects.h  for openvpn */\n"
  },
  {
    "path": "ext/yassl/include/openssl/opensslv.h",
    "content": "/*\n   Copyright (C) 2005 MySQL AB\n   Use is subject to license terms\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* opensslv.h compatibility */\n\n#ifndef yaSSL_opensslv_h__\n#define yaSSL_opensslv_h__\n\n\n/* api version compatibility */\n#define OPENSSL_VERSION_NUMBER 0x0090700f\n\n\n#endif /* yaSSLopensslv_h__ */\n\n"
  },
  {
    "path": "ext/yassl/include/openssl/pem.h",
    "content": "/*\n   Copyright (C) 2006 MySQL AB\n   Use is subject to license terms\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* pem.h  for libcurl */\n"
  },
  {
    "path": "ext/yassl/include/openssl/pkcs12.h",
    "content": "/*\n   Copyright (C) 2006 MySQL AB\n   Use is subject to license terms\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* pkcs12.h for libcurl */\n\n\n#undef HAVE_OPENSSL_PKCS12_H\n\n"
  },
  {
    "path": "ext/yassl/include/openssl/prefix_crypto.h",
    "content": "/*\n   Copyright (C) 2006 MySQL AB\n   Use is subject to license terms\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n#define SSLeay_version yaSSLeay_version\n"
  },
  {
    "path": "ext/yassl/include/openssl/prefix_ssl.h",
    "content": "/*\n   Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n#define Copyright yaCopyright\n#define yaSSL_CleanUp yayaSSL_CleanUp\n#define BN_bin2bn yaBN_bin2bn\n#define DH_new yaDH_new\n#define DH_free yaDH_free\n#define RSA_free yaRSA_free\n#define RSA_generate_key yaRSA_generate_key\n#define X509_free yaX509_free\n#define X509_STORE_CTX_get_current_cert yaX509_STORE_CTX_get_current_cert\n#define X509_STORE_CTX_get_error yaX509_STORE_CTX_get_error\n#define X509_STORE_CTX_get_error_depth yaX509_STORE_CTX_get_error_depth\n#define X509_NAME_oneline yaX509_NAME_oneline\n#define X509_get_issuer_name yaX509_get_issuer_name\n#define X509_get_subject_name yaX509_get_subject_name\n#define X509_verify_cert_error_string yaX509_verify_cert_error_string\n#define X509_LOOKUP_add_dir yaX509_LOOKUP_add_dir\n#define X509_LOOKUP_load_file yaX509_LOOKUP_load_file\n#define X509_LOOKUP_hash_dir yaX509_LOOKUP_hash_dir\n#define X509_LOOKUP_file yaX509_LOOKUP_file\n#define X509_STORE_add_lookup yaX509_STORE_add_lookup\n#define X509_STORE_new yaX509_STORE_new\n#define X509_STORE_get_by_subject yaX509_STORE_get_by_subject\n#define ERR_get_error_line_data yaERR_get_error_line_data\n#define ERR_print_errors_fp yaERR_print_errors_fp\n#define ERR_error_string yaERR_error_string\n#define ERR_remove_state yaERR_remove_state\n#define ERR_get_error yaERR_get_error\n#define ERR_peek_error yaERR_peek_error\n#define ERR_GET_REASON yaERR_GET_REASON\n#define SSL_CTX_new yaSSL_CTX_new\n#define SSL_new yaSSL_new\n#define SSL_set_fd yaSSL_set_fd\n#define SSL_get_fd yaSSL_get_fd\n#define SSL_connect yaSSL_connect\n#define SSL_write yaSSL_write\n#define SSL_read yaSSL_read\n#define SSL_accept yaSSL_accept\n#define SSL_CTX_free yaSSL_CTX_free\n#define SSL_free yaSSL_free\n#define SSL_clear yaSSL_clear\n#define SSL_shutdown yaSSL_shutdown\n#define SSL_set_connect_state yaSSL_set_connect_state\n#define SSL_set_accept_state yaSSL_set_accept_state\n#define SSL_do_handshake yaSSL_do_handshake\n#define SSL_get_cipher yaSSL_get_cipher\n#define SSL_get_cipher_name yaSSL_get_cipher_name\n#define SSL_get_shared_ciphers yaSSL_get_shared_ciphers\n#define SSL_get_cipher_list yaSSL_get_cipher_list\n#define SSL_get_version yaSSL_get_version\n#define SSLeay_version yaSSLeay_version\n#define SSL_get_error yaSSL_get_error\n#define SSL_load_error_strings yaSSL_load_error_strings\n#define SSL_set_session yaSSL_set_session\n#define SSL_get_session yaSSL_get_session\n#define SSL_flush_sessions yaSSL_flush_sessions\n#define SSL_SESSION_set_timeout yaSSL_SESSION_set_timeout\n#define SSL_CTX_set_session_cache_mode yaSSL_CTX_set_session_cache_mode\n#define SSL_get_peer_certificate yaSSL_get_peer_certificate\n#define SSL_get_verify_result yaSSL_get_verify_result\n#define SSL_CTX_set_verify yaSSL_CTX_set_verify\n#define SSL_CTX_load_verify_locations yaSSL_CTX_load_verify_locations\n#define SSL_CTX_set_default_verify_paths yaSSL_CTX_set_default_verify_paths\n#define SSL_CTX_check_private_key yaSSL_CTX_check_private_key\n#define SSL_CTX_set_session_id_context yaSSL_CTX_set_session_id_context\n#define SSL_CTX_set_tmp_rsa_callback yaSSL_CTX_set_tmp_rsa_callback\n#define SSL_CTX_set_options yaSSL_CTX_set_options\n#define SSL_CTX_set_session_cache_mode yaSSL_CTX_set_session_cache_mode\n#define SSL_CTX_set_timeout yaSSL_CTX_set_timeout\n#define SSL_CTX_use_certificate_chain_file yaSSL_CTX_use_certificate_chain_file\n#define SSL_CTX_set_default_passwd_cb yaSSL_CTX_set_default_passwd_cb\n#define SSL_CTX_use_RSAPrivateKey_file yaSSL_CTX_use_RSAPrivateKey_file\n#define SSL_CTX_set_info_callback yaSSL_CTX_set_info_callback\n#define SSL_CTX_sess_accept yaSSL_CTX_sess_accept\n#define SSL_CTX_sess_connect yaSSL_CTX_sess_connect\n#define SSL_CTX_sess_accept_good yaSSL_CTX_sess_accept_good\n#define SSL_CTX_sess_connect_good yaSSL_CTX_sess_connect_good\n#define SSL_CTX_sess_accept_renegotiate yaSSL_CTX_sess_accept_renegotiate\n#define SSL_CTX_sess_connect_renegotiate yaSSL_CTX_sess_connect_renegotiate\n#define SSL_CTX_sess_hits yaSSL_CTX_sess_hits\n#define SSL_CTX_sess_cb_hits yaSSL_CTX_sess_cb_hits\n#define SSL_CTX_sess_cache_full yaSSL_CTX_sess_cache_full\n#define SSL_CTX_sess_misses yaSSL_CTX_sess_misses\n#define SSL_CTX_sess_timeouts yaSSL_CTX_sess_timeouts\n#define SSL_CTX_sess_number yaSSL_CTX_sess_number\n#define SSL_CTX_sess_get_cache_size yaSSL_CTX_sess_get_cache_size\n#define SSL_CTX_get_verify_mode yaSSL_CTX_get_verify_mode\n#define SSL_get_verify_mode yaSSL_get_verify_mode\n#define SSL_CTX_get_verify_depth yaSSL_CTX_get_verify_depth\n#define SSL_get_verify_depth yaSSL_get_verify_depth\n#define SSL_get_default_timeout yaSSL_get_default_timeout\n#define SSL_CTX_get_session_cache_mode yaSSL_CTX_get_session_cache_mode\n#define SSL_session_reused yaSSL_session_reused\n#define SSL_set_rfd yaSSL_set_rfd\n#define SSL_set_wfd yaSSL_set_wfd\n#define SSL_set_shutdown yaSSL_set_shutdown\n#define SSL_set_quiet_shutdown yaSSL_set_quiet_shutdown\n#define SSL_get_quiet_shutdown yaSSL_get_quiet_shutdown\n#define SSL_want_read yaSSL_want_read\n#define SSL_want_write yaSSL_want_write\n#define SSL_pending yaSSL_pending\n#define SSLv3_method yaSSLv3_method\n#define SSLv3_server_method yaSSLv3_server_method\n#define SSLv3_client_method yaSSLv3_client_method\n#define TLSv1_server_method yaTLSv1_server_method\n#define TLSv1_client_method yaTLSv1_client_method\n#define TLSv1_1_server_method yaTLSv1_1_server_method\n#define TLSv1_1_client_method yaTLSv1_1_client_method\n#define SSLv23_server_method yaSSLv23_server_method\n#define SSL_CTX_use_certificate_file yaSSL_CTX_use_certificate_file\n#define SSL_CTX_use_PrivateKey_file yaSSL_CTX_use_PrivateKey_file\n#define SSL_CTX_set_cipher_list yaSSL_CTX_set_cipher_list\n#define SSL_CTX_sess_set_cache_size yaSSL_CTX_sess_set_cache_size\n#define SSL_CTX_set_tmp_dh yaSSL_CTX_set_tmp_dh\n#define OpenSSL_add_all_algorithms yaOpenSSL_add_all_algorithms\n#define SSL_library_init yaSSL_library_init\n#define SSLeay_add_ssl_algorithms yaSSLeay_add_ssl_algorithms\n#define SSL_get_current_cipher yaSSL_get_current_cipher\n#define SSL_CIPHER_description yaSSL_CIPHER_description\n#define SSL_alert_type_string_long yaSSL_alert_type_string_long\n#define SSL_alert_desc_string_long yaSSL_alert_desc_string_long\n#define SSL_state_string_long yaSSL_state_string_long\n#define EVP_md5 yaEVP_md5\n#define EVP_des_ede3_cbc yaEVP_des_ede3_cbc\n#define EVP_BytesToKey yaEVP_BytesToKey\n#define DES_set_key_unchecked yaDES_set_key_unchecked\n#define DES_ede3_cbc_encrypt yaDES_ede3_cbc_encrypt\n#define RAND_screen yaRAND_screen\n#define RAND_file_name yaRAND_file_name\n#define RAND_write_file yaRAND_write_file\n#define RAND_load_file yaRAND_load_file\n#define RAND_status yaRAND_status\n#define RAND_bytes yaRAND_bytes\n#define DES_set_key yaDES_set_key\n#define DES_set_odd_parity yaDES_set_odd_parity\n#define DES_ecb_encrypt yaDES_ecb_encrypt\n#define SSL_CTX_set_default_passwd_cb_userdata yaSSL_CTX_set_default_passwd_cb_userdata\n#define SSL_SESSION_free yaSSL_SESSION_free\n#define SSL_peek yaSSL_peek\n#define SSL_get_certificate yaSSL_get_certificate\n#define SSL_get_privatekey yaSSL_get_privatekey\n#define X509_get_pubkey yaX509_get_pubkey\n#define EVP_PKEY_copy_parameters yaEVP_PKEY_copy_parameters\n#define EVP_PKEY_free yaEVP_PKEY_free\n#define ERR_error_string_n yaERR_error_string_n\n#define ERR_free_strings yaERR_free_strings\n#define EVP_cleanup yaEVP_cleanup\n#define X509_get_ext_d2i yaX509_get_ext_d2i\n#define GENERAL_NAMES_free yaGENERAL_NAMES_free\n#define sk_GENERAL_NAME_num yask_GENERAL_NAME_num\n#define sk_GENERAL_NAME_value yask_GENERAL_NAME_value\n#define ASN1_STRING_data yaASN1_STRING_data\n#define ASN1_STRING_length yaASN1_STRING_length\n#define ASN1_STRING_type yaASN1_STRING_type\n#define X509_NAME_get_index_by_NID yaX509_NAME_get_index_by_NID\n#define X509_NAME_ENTRY_get_data yaX509_NAME_ENTRY_get_data\n#define X509_NAME_get_entry yaX509_NAME_get_entry\n#define ASN1_STRING_to_UTF8 yaASN1_STRING_to_UTF8\n#define SSLv23_client_method yaSSLv23_client_method\n#define SSLv2_client_method yaSSLv2_client_method\n#define SSL_get1_session yaSSL_get1_session\n#define X509_get_notBefore yaX509_get_notBefore\n#define X509_get_notAfter yaX509_get_notAfter\n#define yaSSL_ASN1_TIME_to_string ya_SSL_ASN1_TIME_to_string\n#define MD4_Init yaMD4_Init\n#define MD4_Update yaMD4_Update\n#define MD4_Final yaMD4_Final\n#define MD5_Init yaMD5_Init\n#define MD5_Update yaMD5_Update\n#define MD5_Final yaMD5_Final\n#define SSL_set_compression yaSSL_set_compression\n#define PEM_read_X509 yaSSL_PEM_read_X509\n"
  },
  {
    "path": "ext/yassl/include/openssl/rand.h",
    "content": "/*\n   Copyright (C) 2005 MySQL AB\n   Use is subject to license terms\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* rand.h for openSSL */\n\n"
  },
  {
    "path": "ext/yassl/include/openssl/rsa.h",
    "content": "/*\n   Copyright (C) 2005, 2006 MySQL AB\n   Use is subject to license terms\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* rsa.h for openSSL */\n\n\n#ifndef yaSSL_rsa_h__\n#define yaSSL_rsa_h__\n\nenum { RSA_F4 = 1 };\n\n\n#endif /* yaSSL_rsa_h__ */\n"
  },
  {
    "path": "ext/yassl/include/openssl/sha.h",
    "content": "/*\n   Copyright (C) 2007 MySQL AB\n   Use is subject to license terms\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* sha.h  for openvpn */\n"
  },
  {
    "path": "ext/yassl/include/openssl/ssl.h",
    "content": "/*\n   Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n */\n\n/*  ssl.h defines openssl compatibility layer \n *\n */\n\n\n\n#ifndef yaSSL_openssl_h__\n#define yaSSL_openssl_h__\n\n#ifdef YASSL_PREFIX\n#include \"prefix_ssl.h\"\n#endif\n\n#include <stdio.h>    /* ERR_print fp */\n#include \"opensslv.h\" /* for version number */\n#include \"rsa.h\"\n\n\n#define YASSL_VERSION \"2.3.7b\"\n\n\n#if defined(__cplusplus)\nextern \"C\" {\n#endif\n\n void yaSSL_CleanUp();   /* call once at end of application use to\n                            free static singleton memory holders,\n                            not a leak per se, but helpful when\n                            looking for them                      */\n\n#if defined(__cplusplus)\n} // extern\n#endif\n\n#if defined(__cplusplus) && !defined(YASSL_MYSQL_COMPATIBLE)\nnamespace yaSSL {\nextern \"C\" {\n#endif\n\n#undef X509_NAME   /* wincrypt.h clash */\n\n#if defined(__cplusplus) && !defined(YASSL_MYSQL_COMPATIBLE)\n    class SSL;\n    class SSL_SESSION;\n    class SSL_METHOD;\n    class SSL_CTX;\n    class SSL_CIPHER;\n\n    class RSA;\n\n    class X509;\n    class X509_NAME;\n#else\n    typedef struct SSL          SSL;          \n    typedef struct SSL_SESSION  SSL_SESSION;\n    typedef struct SSL_METHOD   SSL_METHOD;\n    typedef struct SSL_CTX      SSL_CTX;\n    typedef struct SSL_CIPHER   SSL_CIPHER;\n\n    typedef struct RSA RSA;\n\n    typedef struct X509       X509;\n    typedef struct X509_NAME  X509_NAME;\n#endif\n\n\n/* Big Number stuff, different file? */\ntypedef struct BIGNUM BIGNUM;\n\nBIGNUM *BN_bin2bn(const unsigned char*, int, BIGNUM*);\n\n\n/* Diffie-Hellman stuff, different file? */\n/* mySQL deferences to set group parameters */\ntypedef struct DH {\n    BIGNUM* p;\n    BIGNUM* g;\n} DH;\n\nDH*  DH_new(void);\nvoid DH_free(DH*);\n\n/* RSA stuff */\n\nvoid RSA_free(RSA*);\nRSA* RSA_generate_key(int, unsigned long, void(*)(int, int, void*), void*);\n\n\n/* X509 stuff, different file? */\n\n/* because mySQL dereferences to use error and current_cert, even after calling\n * get functions for local references */\ntypedef struct X509_STORE_CTX {\n    int   error;\n    int   error_depth;\n    X509* current_cert;\n} X509_STORE_CTX;\n\n\ntypedef struct X509_STORE         X509_STORE;\ntypedef struct X509_LOOKUP        X509_LOOKUP;\ntypedef struct X509_OBJECT { char c; } X509_OBJECT;\ntypedef struct X509_CRL           X509_CRL;\ntypedef struct X509_REVOKED       X509_REVOKED;\ntypedef struct X509_LOOKUP_METHOD X509_LOOKUP_METHOD;\n\n\nvoid X509_free(X509*);\n\n\n/* bio stuff */\ntypedef struct BIO BIO;\n\n/* ASN stuff */\n\n\n\nX509* X509_STORE_CTX_get_current_cert(X509_STORE_CTX*);\nint   X509_STORE_CTX_get_error(X509_STORE_CTX*);\nint   X509_STORE_CTX_get_error_depth(X509_STORE_CTX*);\n\nchar*       X509_NAME_oneline(X509_NAME*, char*, int);\nX509_NAME*  X509_get_issuer_name(X509*);\nX509_NAME*  X509_get_subject_name(X509*);\nconst char* X509_verify_cert_error_string(long);\n\nint                 X509_LOOKUP_add_dir(X509_LOOKUP*, const char*, long);\nint                 X509_LOOKUP_load_file(X509_LOOKUP*, const char*, long);\nX509_LOOKUP_METHOD* X509_LOOKUP_hash_dir(void);\nX509_LOOKUP_METHOD* X509_LOOKUP_file(void);\n\nX509_LOOKUP* X509_STORE_add_lookup(X509_STORE*, X509_LOOKUP_METHOD*);\nX509_STORE*  X509_STORE_new(void);\nint          X509_STORE_get_by_subject(X509_STORE_CTX*, int, X509_NAME*,\n                                       X509_OBJECT*);\n\n\n\n\nenum { /* X509 Constants */\n    X509_V_OK                                 =  0,\n    X509_V_ERR_CERT_CHAIN_TOO_LONG            =  1,\n    X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT      =  2,\n    X509_V_ERR_CERT_NOT_YET_VALID             =  3,\n    X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD =  4,\n    X509_V_ERR_CERT_HAS_EXPIRED               =  5,\n    X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD  =  6,\n    X509_FILETYPE_PEM                         =  7,\n    X509_LU_X509                              =  8,\n    X509_LU_CRL                               =  9,\n    X509_V_ERR_CRL_SIGNATURE_FAILURE          = 10,\n    X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD = 11,\n    X509_V_ERR_CRL_HAS_EXPIRED                = 12,\n    X509_V_ERR_CERT_REVOKED                   = 13,\n    X509_V_FLAG_CRL_CHECK                     = 14,\n    X509_V_FLAG_CRL_CHECK_ALL                 = 15\n};\n\n\n/* Error stuff, could move to yassl_error */\nunsigned long ERR_get_error_line_data(const char**, int*, const char**, int *);\nvoid          ERR_print_errors_fp(FILE*);\nchar*         ERR_error_string(unsigned long,char*);\nvoid          ERR_remove_state(unsigned long);\nunsigned long ERR_get_error(void);\nunsigned long ERR_peek_error(void);\nint           ERR_GET_REASON(int);\n\n\nenum {  /* ERR Constants */\n    ERR_TXT_STRING = 1,\n    EVP_R_BAD_DECRYPT = 2\n};\n\n/*\n  Allow type used by SSL_set_fd to be changed, default to int\n  in order to be compatible with OpenSSL\n */\n#ifndef YASSL_SOCKET_T_DEFINED\ntypedef int YASSL_SOCKET_T;\n#endif\n\nSSL_CTX* SSL_CTX_new(SSL_METHOD*);\nSSL* SSL_new(SSL_CTX*);\nint  SSL_set_fd (SSL*, YASSL_SOCKET_T);\nYASSL_SOCKET_T SSL_get_fd(const SSL*);\nint  SSL_connect(SSL*);                    /* if you get an error from connect\n                                              see note at top of README       */\nint  SSL_write(SSL*, const void*, int);\nint  SSL_read(SSL*, void*, int);\nint  SSL_accept(SSL*);\nvoid SSL_CTX_free(SSL_CTX*);\nvoid SSL_free(SSL*);\nint  SSL_clear(SSL*);\nint  SSL_shutdown(SSL*);\n\nvoid SSL_set_connect_state(SSL*);\nvoid SSL_set_accept_state(SSL*);\nint  SSL_do_handshake(SSL*);\n\nconst char* SSL_get_cipher(SSL*);\nconst char* SSL_get_cipher_name(SSL*);\t           /* uses SSL_get_cipher */\nchar*       SSL_get_shared_ciphers(SSL*, char*, int);\nconst char* SSL_get_cipher_list(SSL*, int);\nconst char* SSL_get_version(SSL*);\nconst char* SSLeay_version(int);\n\nint  SSL_get_error(SSL*, int);\nvoid SSL_load_error_strings(void);\n\nint          SSL_set_session(SSL *ssl, SSL_SESSION *session);\nSSL_SESSION* SSL_get_session(SSL* ssl);\nvoid         SSL_flush_sessions(SSL_CTX *ctx, long tm);\nlong         SSL_SESSION_set_timeout(SSL_SESSION*, long);\nlong         SSL_CTX_set_session_cache_mode(SSL_CTX* ctx, long mode);\nX509*        SSL_get_peer_certificate(SSL*);\nlong         SSL_get_verify_result(SSL*);\n\n\ntypedef int (*VerifyCallback)(int, X509_STORE_CTX*);\ntypedef int (*pem_password_cb)(char*, int, int, void*);\nint default_password_callback(char * buffer, int size_arg, int rwflag,\n                              void * u);\n\nvoid SSL_CTX_set_verify(SSL_CTX*, int, VerifyCallback verify_callback);\nint  SSL_CTX_load_verify_locations(SSL_CTX*, const char*, const char*);\nint  SSL_CTX_set_default_verify_paths(SSL_CTX*);\nint  SSL_CTX_check_private_key(SSL_CTX*);\nint  SSL_CTX_set_session_id_context(SSL_CTX*, const unsigned char*,\n                                    unsigned int);\n\nvoid SSL_CTX_set_tmp_rsa_callback(SSL_CTX*, RSA*(*)(SSL*, int, int));\nlong SSL_CTX_set_options(SSL_CTX*, long);\nlong SSL_CTX_set_session_cache_mode(SSL_CTX*, long);\nlong SSL_CTX_set_timeout(SSL_CTX*, long);\nint  SSL_CTX_use_certificate_chain_file(SSL_CTX*, const char*);\nvoid SSL_CTX_set_default_passwd_cb(SSL_CTX*, pem_password_cb);\nint  SSL_CTX_use_RSAPrivateKey_file(SSL_CTX*, const char*, int);\nvoid SSL_CTX_set_info_callback(SSL_CTX*, void (*)());\n\nlong SSL_CTX_sess_accept(SSL_CTX*);\nlong SSL_CTX_sess_connect(SSL_CTX*);\nlong SSL_CTX_sess_accept_good(SSL_CTX*);\nlong SSL_CTX_sess_connect_good(SSL_CTX*);\nlong SSL_CTX_sess_accept_renegotiate(SSL_CTX*);\nlong SSL_CTX_sess_connect_renegotiate(SSL_CTX*);\nlong SSL_CTX_sess_hits(SSL_CTX*);\nlong SSL_CTX_sess_cb_hits(SSL_CTX*);\nlong SSL_CTX_sess_cache_full(SSL_CTX*);\nlong SSL_CTX_sess_misses(SSL_CTX*);\nlong SSL_CTX_sess_timeouts(SSL_CTX*);\nlong SSL_CTX_sess_number(SSL_CTX*);\nlong SSL_CTX_sess_get_cache_size(SSL_CTX*);\n\nint SSL_CTX_get_verify_mode(SSL_CTX*);\nint SSL_get_verify_mode(SSL*);\nint SSL_CTX_get_verify_depth(SSL_CTX*);\nint SSL_get_verify_depth(SSL*);\n\nlong SSL_get_default_timeout(SSL*);\nlong SSL_CTX_get_session_cache_mode(SSL_CTX*);\nint  SSL_session_reused(SSL*);\n\nint  SSL_set_rfd(SSL*, int);\nint  SSL_set_wfd(SSL*, int);\nvoid SSL_set_shutdown(SSL*, int);\nvoid SSL_set_quiet_shutdown(SSL *ssl,int mode);\nint SSL_get_quiet_shutdown(SSL *ssl);\n\nint SSL_want_read(SSL*);\nint SSL_want_write(SSL*);\n\nint SSL_pending(SSL*);\n\n\nenum { /* ssl Constants */\n    SSL_WOULD_BLOCK     = -8,\n    SSL_BAD_STAT        = -7,\n    SSL_BAD_PATH        = -6,\n    SSL_BAD_FILETYPE    = -5,\n    SSL_BAD_FILE        = -4,\n    SSL_NOT_IMPLEMENTED = -3,\n    SSL_UNKNOWN         = -2,\n    SSL_FATAL_ERROR     = -1,\n    SSL_NORMAL_SHUTDOWN =  0,\n    SSL_ERROR_NONE      =  0,   /* for most functions */\n    SSL_FAILURE         =  0,   /* for some functions */\n    SSL_SUCCESS\t        =  1,\n\n    SSL_FILETYPE_ASN1    = 10,\n    SSL_FILETYPE_PEM     = 11,\n    SSL_FILETYPE_DEFAULT = 10, /* ASN1 */\n\n    SSL_VERIFY_NONE                 = 0,\n    SSL_VERIFY_PEER                 = 1,\n    SSL_VERIFY_FAIL_IF_NO_PEER_CERT = 2,\n    SSL_VERIFY_CLIENT_ONCE          = 4,\n\n    SSL_SESS_CACHE_OFF                = 30,\n    SSL_SESS_CACHE_CLIENT             = 31,\n    SSL_SESS_CACHE_SERVER             = 32,\n    SSL_SESS_CACHE_BOTH               = 33,\n    SSL_SESS_CACHE_NO_AUTO_CLEAR      = 34,\n    SSL_SESS_CACHE_NO_INTERNAL_LOOKUP = 35,\n\n    SSL_OP_MICROSOFT_SESS_ID_BUG            = 50,\n    SSL_OP_NETSCAPE_CHALLENGE_BUG           = 51,\n    SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG = 52,\n    SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG      = 53,\n    SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER       = 54,\n    SSL_OP_MSIE_SSLV2_RSA_PADDING           = 55,\n    SSL_OP_SSLEAY_080_CLIENT_DH_BUG         = 56,\n    SSL_OP_TLS_D5_BUG                       = 57,\n    SSL_OP_TLS_BLOCK_PADDING_BUG            = 58,\n    SSL_OP_TLS_ROLLBACK_BUG                 = 59,\n    SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS      = 60,\n    SSL_OP_ALL                              = 61,\n    SSL_OP_SINGLE_DH_USE                    = 62,\n    SSL_OP_EPHEMERAL_RSA                    = 63,\n    SSL_OP_NO_SSLv2                         = 64,\n    SSL_OP_NO_SSLv3                         = 65,\n    SSL_OP_NO_TLSv1                         = 66,\n    SSL_OP_PKCS1_CHECK_1                    = 67,\n    SSL_OP_PKCS1_CHECK_2                    = 68,\n    SSL_OP_NETSCAPE_CA_DN_BUG               = 69,\n    SSL_OP_NON_EXPORT_FIRST                 = 70,\n    SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG  = 71,\n\n    SSL_ERROR_WANT_READ        = 80,\n    SSL_ERROR_WANT_WRITE       = 81,\n    SSL_ERROR_SYSCALL          = 82,\n    SSL_ERROR_WANT_X509_LOOKUP = 83,\n    SSL_ERROR_ZERO_RETURN      = 84,\n    SSL_ERROR_SSL              = 85,\n\n    SSL_ST_CONNECT        = 90,\n    SSL_ST_ACCEPT         = 91,\n    SSL_CB_LOOP           = 92,\n    SSL_SENT_SHUTDOWN     = 93,\n    SSL_RECEIVED_SHUTDOWN = 94,\n    SSL_CB_ALERT          = 95,\n    SSL_CB_READ           = 96,\n    SSL_CB_HANDSHAKE_DONE = 97\n\n};\n\n\nSSL_METHOD *SSLv3_method(void);\nSSL_METHOD *SSLv3_server_method(void);\nSSL_METHOD *SSLv3_client_method(void);\nSSL_METHOD *TLSv1_server_method(void);\nSSL_METHOD *TLSv1_client_method(void);\nSSL_METHOD *TLSv1_1_server_method(void);\nSSL_METHOD *TLSv1_1_client_method(void);\nSSL_METHOD *SSLv23_server_method(void);\n\nint SSL_CTX_use_certificate_file(SSL_CTX*, const char*, int);\nint SSL_CTX_use_PrivateKey_file(SSL_CTX*, const char*, int);\nint SSL_CTX_set_cipher_list(SSL_CTX*, const char*);\n\nlong SSL_CTX_sess_set_cache_size(SSL_CTX*, long);\nlong SSL_CTX_set_tmp_dh(SSL_CTX*, DH*);\n\nvoid OpenSSL_add_all_algorithms(void);\nint  SSL_library_init();\nint  SSLeay_add_ssl_algorithms(void);\n\n\nSSL_CIPHER* SSL_get_current_cipher(SSL*);\nchar*       SSL_CIPHER_description(SSL_CIPHER*, char*, int);\n\n\nchar* SSL_alert_type_string_long(int);\nchar* SSL_alert_desc_string_long(int);\nchar* SSL_state_string_long(SSL*);\n\nX509* PEM_read_X509(FILE *fp, X509 *x, pem_password_cb cb, void *u);\n/* EVP stuff, des and md5, different file? */\ntypedef char EVP_MD;\n\ntypedef char EVP_CIPHER;\n\ntypedef struct EVP_PKEY EVP_PKEY;\n\ntypedef unsigned char DES_cblock[8];\ntypedef const  DES_cblock const_DES_cblock;\ntypedef DES_cblock DES_key_schedule;\n                                                          \nenum {\n    DES_ENCRYPT = 1,\n    DES_DECRYPT = 0\n};\n                                                             \nconst EVP_MD*     EVP_md5(void);\nconst EVP_CIPHER* EVP_des_ede3_cbc(void);\n\ntypedef unsigned char opaque;\n\nint EVP_BytesToKey(const EVP_CIPHER*, const EVP_MD*, const opaque*,\n                   const opaque*, int, int, opaque*, opaque*);\n\nvoid DES_set_key_unchecked(const_DES_cblock*, DES_key_schedule*);\nvoid DES_ede3_cbc_encrypt(const opaque*, opaque*, long, DES_key_schedule*,\n                        DES_key_schedule*, DES_key_schedule*, DES_cblock*, int);\n\n\n/* RAND stuff */\nvoid        RAND_screen(void);\nconst char* RAND_file_name(char*, size_t);\nint         RAND_write_file(const char*);\nint         RAND_load_file(const char*, long);\n\n\n/* for libcurl */\nint  RAND_status(void);\nint  RAND_bytes(unsigned char* buf, int num);\n\nint  DES_set_key(const_DES_cblock*, DES_key_schedule*);\nvoid DES_set_odd_parity(DES_cblock*);\nvoid DES_ecb_encrypt(DES_cblock*, DES_cblock*, DES_key_schedule*, int);\n\nvoid SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX*, void* userdata);\nvoid SSL_SESSION_free(SSL_SESSION* session);\nint  SSL_peek(SSL* ssl, void* buf, int num);\n\nX509*     SSL_get_certificate(SSL* ssl);\nEVP_PKEY* SSL_get_privatekey(SSL* ssl);\nEVP_PKEY* X509_get_pubkey(X509* x);\n\nint  EVP_PKEY_copy_parameters(EVP_PKEY* to, const EVP_PKEY* from);\nvoid EVP_PKEY_free(EVP_PKEY* pkey);\nvoid ERR_error_string_n(unsigned long e, char *buf, size_t len);\nvoid ERR_free_strings(void);\nvoid EVP_cleanup(void);\n\nvoid* X509_get_ext_d2i(X509* x, int nid, int* crit, int* idx);\n\n#define GEN_IPADD 7\n#define NID_subject_alt_name 85\n#define STACK_OF(x) x\n\n\n/* defined here because libcurl dereferences */\ntypedef struct ASN1_STRING {\n    int type;\n    int length;\n    unsigned char* data;\n} ASN1_STRING;\n\n\ntypedef struct GENERAL_NAME {\n    int type;\n    union {\n        ASN1_STRING* ia5;\n    } d;\n} GENERAL_NAME;\n\nvoid GENERAL_NAMES_free(STACK_OF(GENERAL_NAME) *x);\n\nint           sk_GENERAL_NAME_num(STACK_OF(GENERAL_NAME) *x);\nGENERAL_NAME* sk_GENERAL_NAME_value(STACK_OF(GENERAL_NAME) *x, int i);\n\n\nunsigned char* ASN1_STRING_data(ASN1_STRING* x);\nint            ASN1_STRING_length(ASN1_STRING* x);\nint            ASN1_STRING_type(ASN1_STRING *x);\n\ntypedef ASN1_STRING X509_NAME_ENTRY;\n\nint X509_NAME_get_index_by_NID(X509_NAME* name,int nid, int lastpos);\n\nASN1_STRING* X509_NAME_ENTRY_get_data(X509_NAME_ENTRY* ne);\nX509_NAME_ENTRY* X509_NAME_get_entry(X509_NAME* name, int loc);\n\n#define OPENSSL_malloc(x) malloc(x)\n#define OPENSSL_free(x)   free(x)\n\nint ASN1_STRING_to_UTF8(unsigned char** out, ASN1_STRING* in);\n\nSSL_METHOD* SSLv23_client_method(void);  /* doesn't actually roll back */\nSSL_METHOD* SSLv2_client_method(void);   /* will never work, no v 2    */\n\n\nSSL_SESSION* SSL_get1_session(SSL* ssl);  /* what's ref count */\n\n\n#define CRYPTO_free(x) free(x)\n#define ASN1_TIME ASN1_STRING\n\nASN1_TIME* X509_get_notBefore(X509* x);\nASN1_TIME* X509_get_notAfter(X509* x);\n\n\n#define ASN1_UTCTIME ASN1_STRING\n#define NID_commonName    13\n#define V_ASN1_UTF8STRING 12\n#define GEN_DNS            2\n\n#define CERTFICATE_ERROR 0x14090086  /* SSLv3 error */\n\n\ntypedef struct MD4_CTX {\n    int buffer[32];      /* big enough to hold, check size in Init */\n} MD4_CTX;\n\nvoid MD4_Init(MD4_CTX*);\nvoid MD4_Update(MD4_CTX*, const void*, unsigned long);\nvoid MD4_Final(unsigned char*, MD4_CTX*);\n\n\ntypedef struct MD5_CTX {\n    int buffer[32];       /* big enough to hold, check size in Init */\n} MD5_CTX;\n\nvoid MD5_Init(MD5_CTX*);\nvoid MD5_Update(MD5_CTX*, const void*, unsigned long);\nvoid MD5_Final(unsigned char*, MD5_CTX*);\n\n#define MD5_DIGEST_LENGTH 16\n\n\n#define SSL_DEFAULT_CIPHER_LIST \"\"   /* default all */\n\n\n/* yaSSL extensions */\nint SSL_set_compression(SSL*);   /* turn on yaSSL zlib compression */\nchar *yaSSL_ASN1_TIME_to_string(ASN1_TIME *time, char *buf, size_t len);\n\n#include \"transport_types.h\"\n\n/*\n  Set functions for yaSSL to use in order to send and receive data.\n\n  These hooks are offered in order to enable non-blocking I/O. If\n  not set, yaSSL defaults to using send() and recv().\n\n  @todo Remove hooks and accompanying code when yaSSL is fixed.\n*/\nvoid yaSSL_transport_set_ptr(SSL *, void *);\nvoid yaSSL_transport_set_recv_function(SSL *, yaSSL_recv_func_t);\nvoid yaSSL_transport_set_send_function(SSL *, yaSSL_send_func_t);\n\n#if defined(__cplusplus) && !defined(YASSL_MYSQL_COMPATIBLE)\n}      /* namespace  */\n}      /* extern \"C\" */\n#endif\n\n\n#endif /* yaSSL_openssl_h__ */\n"
  },
  {
    "path": "ext/yassl/include/openssl/transport_types.h",
    "content": "/*\n   Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA 02110-1301  USA.\n*/\n\n#ifndef yaSSL_transport_types_h__\n#define yaSSL_transport_types_h__\n\n/* Type of transport functions used for sending and receiving data. */\ntypedef long (*yaSSL_recv_func_t) (void *, void *, size_t);\ntypedef long (*yaSSL_send_func_t) (void *, const void *, size_t);\n\n#endif\n"
  },
  {
    "path": "ext/yassl/include/openssl/x509.h",
    "content": "/*\n   Copyright (C) 2006 MySQL AB\n   Use is subject to license terms\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* x509.h  for libcurl */\n"
  },
  {
    "path": "ext/yassl/include/openssl/x509v3.h",
    "content": "/*\n   Copyright (C) 2006 MySQL AB\n   Use is subject to license terms\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* x509v3.h  for libcurl */\n"
  },
  {
    "path": "ext/yassl/include/socket_wrapper.hpp",
    "content": "/*\n   Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n */\n\n\n/* The socket wrapper header defines a Socket class that hides the differences\n * between Berkely style sockets and Windows sockets, allowing transparent TCP\n * access.\n */\n\n\n#ifndef yaSSL_SOCKET_WRAPPER_HPP\n#define yaSSL_SOCKET_WRAPPER_HPP\n\n\n#ifdef _WIN32\n    #include <winsock2.h>\n#else \n    #include <sys/time.h>\n    #include <sys/types.h>\n    #include <sys/socket.h>\n    #include <unistd.h>\n    #include <netinet/in.h>\n    #include <arpa/inet.h>\n#endif\n\n\nnamespace yaSSL {\n\ntypedef unsigned int uint;\n\n#ifdef _WIN32\n    typedef SOCKET socket_t;\n#else\n    typedef int socket_t;\n    const socket_t INVALID_SOCKET = -1;\n    const int SD_RECEIVE   = 0;\n    const int SD_SEND      = 1;\n    const int SD_BOTH      = 2;\n    const int SOCKET_ERROR = -1;\n#endif\n\n  extern \"C\" {\n    #include \"openssl/transport_types.h\"\n  }\n\ntypedef unsigned char byte;\n\n\n// Wraps Windows Sockets and BSD Sockets\nclass Socket {\n    socket_t socket_;                    // underlying socket descriptor\n    bool     wouldBlock_;                // if non-blocking data, for last read \n    bool     nonBlocking_;               // is option set\n    void     *ptr_;                      // Argument to transport function\n    yaSSL_send_func_t send_func_;        // Function to send data\n    yaSSL_recv_func_t recv_func_;        // Function to receive data\npublic:\n    explicit Socket(socket_t s = INVALID_SOCKET);\n    ~Socket();\n\n    void     set_fd(socket_t s);\n    uint     get_ready() const;\n    socket_t get_fd()    const;\n\n    void set_transport_ptr(void *ptr);\n    void set_transport_recv_function(yaSSL_recv_func_t recv_func);\n    void set_transport_send_function(yaSSL_send_func_t send_func);\n\n    uint send(const byte* buf, unsigned int len, unsigned int& sent);\n    uint receive(byte* buf, unsigned int len);\n\n    bool wait();\n    bool WouldBlock() const;\n    bool IsNonBlocking() const;\n\n    void closeSocket();\n    void shutDown(int how = SD_SEND);\n\n    static int  get_lastError();\n    static void set_lastError(int error);\nprivate:\n    Socket(const Socket&);              // hide copy\n    Socket& operator= (const Socket&);  // and assign\n};\n\n\n} // naemspace\n\n#endif // yaSSL_SOCKET_WRAPPER_HPP\n"
  },
  {
    "path": "ext/yassl/include/timer.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* timer.hpp provides a high res and low res timers\n *\n*/\n\n\n#ifndef yaSSL_TIMER_HPP\n#define yaSSL_TIMER_HPP\n\nnamespace yaSSL {\n\ntypedef double       timer_d;\ntypedef unsigned int uint;\n\n\n\ntimer_d timer();\nuint    lowResTimer();\n\n\n\n} // namespace\n#endif // yaSSL_TIMER_HPP\n"
  },
  {
    "path": "ext/yassl/include/yassl.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* yaSSL externel header defines yaSSL API\n */\n\n\n#ifndef yaSSL_EXT_HPP\n#define yaSSL_EXT_HPP\n\n\nnamespace yaSSL {\n\n\n#ifdef _WIN32\n    typedef unsigned int SOCKET_T;\n#else\n    typedef int          SOCKET_T;\n#endif\n\n\nclass Client {\npublic:\n    Client();\n    ~Client();\n\n    // basics\n    int Connect(SOCKET_T);\n    int Write(const void*, int);\n    int Read(void*, int);\n\n    // options\n    void SetCA(const char*);\n    void SetCert(const char*);\n    void SetKey(const char*);\nprivate:\n    struct ClientImpl;\n    ClientImpl* pimpl_;\n\n    Client(const Client&);              // hide copy\n    Client& operator=(const Client&);   // and assign  \n};\n\n\nclass Server {\npublic:\n    Server();\n    ~Server();\n\n    // basics\n    int Accept(SOCKET_T);\n    int Write(const void*, int);\n    int Read(void*, int);\n\n    // options\n    void SetCA(const char*);\n    void SetCert(const char*);\n    void SetKey(const char*);\nprivate:\n    struct ServerImpl;\n    ServerImpl* pimpl_;\n\n    Server(const Server&);              // hide copy\n    Server& operator=(const Server&);   // and assign\n};\n\n\n} // namespace yaSSL\n#endif // yaSSL_EXT_HPP\n"
  },
  {
    "path": "ext/yassl/include/yassl_error.hpp",
    "content": "/*\n   Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* yaSSL error header defines error codes and an exception class\n */\n\n#ifndef yaSSL_ERROR_HPP\n#define yaSSL_ERROR_HPP\n\n\n\nnamespace yaSSL {\n\n\nenum YasslError {\n    no_error            = 0,\n\n    // 10 - 47 from AlertDescription, 0 also close_notify\n\n    range_error         = 101,\n    realloc_error       = 102,\n    factory_error       = 103,\n    unknown_cipher      = 104,\n    prefix_error        = 105,\n    record_layer        = 106,\n    handshake_layer     = 107,\n    out_of_order        = 108,\n    bad_input           = 109,\n    match_error         = 110,\n    no_key_file         = 111,\n    verify_error        = 112,\n    send_error          = 113,\n    receive_error       = 114,\n    certificate_error   = 115,\n    privateKey_error    = 116,\n    badVersion_error    = 117,\n    compress_error      = 118,\n    decompress_error    = 119,\n    pms_version_error   = 120,\n    sanityCipher_error  = 121\n\n    // !!!! add error message to .cpp !!!!\n\n    // 1000+ from TaoCrypt error.hpp\n\n};\n\n\nenum Library { yaSSL_Lib = 0, CryptoLib, SocketLib };\nenum { MAX_ERROR_SZ = 80 };\n\nvoid SetErrorString(YasslError, char*);\n\n/* remove for now, if go back to exceptions use this wrapper\n// Base class for all yaSSL exceptions\nclass Error : public mySTL::runtime_error {\n    YasslError  error_;\n    Library     lib_;\npublic:\n    explicit Error(const char* s = \"\", YasslError e = no_error,\n                   Library l = yaSSL_Lib);\n\n    YasslError  get_number() const;\n    Library     get_lib()    const;\n};\n*/\n\n\n} // naemspace\n\n#endif // yaSSL_ERROR_HPP\n"
  },
  {
    "path": "ext/yassl/include/yassl_imp.hpp",
    "content": "/*\n   Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/*  yaSSL implementation header defines all strucutres from the SSL.v3 \n *  specification \"draft-freier-ssl-version3-02.txt\"\n *  all page citations refer to this document unless otherwise noted.\n */\n\n\n#ifndef yaSSL_IMP_HPP\n#define yaSSL_IMP_HPP\n\n#ifdef _MSC_VER\n    // disable truncated debug symbols\n    #pragma warning(disable:4786)\n#endif\n\n#include \"yassl_types.hpp\"\n#include \"factory.hpp\"\n#include STL_LIST_FILE\n\n\nnamespace STL = STL_NAMESPACE;\n\n\nnamespace yaSSL {\n\n\nclass SSL;              // forward decls\nclass input_buffer;\nclass output_buffer;\n\n\nstruct ProtocolVersion {\n    uint8 major_;\n    uint8 minor_;     // major and minor SSL/TLS version numbers\n\n    ProtocolVersion(uint8 maj = 3, uint8 min = 0);\n};\n\n\n// Record Layer Header for PlainText, Compressed, and CipherText\nstruct RecordLayerHeader {\n    ContentType     type_;\n    ProtocolVersion version_;\n    uint16          length_;             // should not exceed 2^14\n};\n\n\n// base for all messages\nstruct Message : public virtual_base {\n    virtual input_buffer& set(input_buffer&) =0;   \n    virtual output_buffer& get(output_buffer&) const =0;\n\n    virtual void Process(input_buffer&, SSL&) =0;\n    virtual ContentType get_type() const =0;\n    virtual uint16      get_length() const =0;\n\n    virtual ~Message() {}\n};\n\n\nclass ChangeCipherSpec : public Message {\n    CipherChoice type_;\npublic:\n    ChangeCipherSpec();\n\n    friend input_buffer& operator>>(input_buffer&, ChangeCipherSpec&);\n    friend output_buffer& operator<<(output_buffer&, const ChangeCipherSpec&);\n\n    input_buffer& set(input_buffer& in);\n    output_buffer& get(output_buffer& out) const;\n\n    ContentType get_type()   const;\n    uint16      get_length() const;\n    void Process(input_buffer&, SSL&);\nprivate:\n    ChangeCipherSpec(const ChangeCipherSpec&);            // hide copy\n    ChangeCipherSpec& operator=(const ChangeCipherSpec&); // and assign\n};\n\n\n\nclass Alert : public Message {\n    AlertLevel       level_;\n    AlertDescription description_;\npublic:\n    Alert() {}\n    Alert(AlertLevel al, AlertDescription ad);\n\n    ContentType get_type()   const;\n    uint16      get_length() const;\n    void Process(input_buffer&, SSL&);\n\n    friend input_buffer& operator>>(input_buffer&, Alert&);\n    friend output_buffer& operator<<(output_buffer&, const Alert&);\n   \n    input_buffer& set(input_buffer& in);\n    output_buffer& get(output_buffer& out) const;\nprivate:\n    Alert(const Alert&);            // hide copy\n    Alert& operator=(const Alert&); // and assign\n};\n\n\nclass Data : public Message {\n    uint16        length_;\n    opaque*       buffer_;         // read  buffer used by fillData input\n    const opaque* write_buffer_;   // write buffer used by output operator\npublic:\n    Data();\n    Data(uint16 len, opaque* b);\n\n    friend output_buffer& operator<<(output_buffer&, const Data&);\n\n    input_buffer& set(input_buffer& in);\n    output_buffer& get(output_buffer& out) const;\n\n    ContentType   get_type()     const;\n    uint16        get_length()   const;\n    void          set_length(uint16 l);\n    opaque*       set_buffer();\n    void          SetData(uint16, const opaque*);\n    void Process(input_buffer&, SSL&);\nprivate:\n    Data(const Data&);            // hide copy\n    Data& operator=(const Data&); // and assign\n};\n\n\nuint32 c24to32(const uint24);       // forward form internal header\nvoid   c32to24(uint32, uint24&);\n\n\n// HandShake header, same for each message type from page 20/21\nclass HandShakeHeader : public Message {\n    HandShakeType      type_;\n    uint24             length_;      // length of message\npublic:\n    HandShakeHeader() {}\n\n    ContentType   get_type()   const;\n    uint16        get_length() const;\n    HandShakeType get_handshakeType() const;\n    void Process(input_buffer&, SSL&);\n\n    void set_type(HandShakeType hst);\n    void set_length(uint32 u32);\n\n    friend input_buffer& operator>>(input_buffer&, HandShakeHeader&);\n    friend output_buffer& operator<<(output_buffer&, const HandShakeHeader&);\n\n    input_buffer& set(input_buffer& in);\n    output_buffer& get(output_buffer& out) const;\nprivate:\n    HandShakeHeader(const HandShakeHeader&);            // hide copy\n    HandShakeHeader& operator=(const HandShakeHeader&); // and assign\n};\n\n\n// Base Class for all handshake messages\nclass HandShakeBase : public virtual_base {\n    int     length_;\npublic:\n    int     get_length() const;\n    void    set_length(int);\n\n    // for building buffer's type field\n    virtual HandShakeType get_type() const =0;                \n\n    // handles dispactch of proper >>\n    virtual input_buffer&  set(input_buffer& in) =0;\n    virtual output_buffer& get(output_buffer& out) const =0;\n\n    virtual void Process(input_buffer&, SSL&) =0;\n\n    virtual ~HandShakeBase() {}\n};\n\n\nstruct HelloRequest : public HandShakeBase {\n    input_buffer&  set(input_buffer& in);\n    output_buffer& get(output_buffer& out) const;\n\n    void Process(input_buffer&, SSL&);\n\n    HandShakeType get_type() const;\n};\n\n\n// The Client's Hello Message from page 23\nclass ClientHello : public HandShakeBase {\n    ProtocolVersion     client_version_;\n    Random              random_;\n    uint8               id_len_;                         // session id length\n    opaque              session_id_[ID_LEN];\n    uint16              suite_len_;                      // cipher suite length\n    opaque              cipher_suites_[MAX_SUITE_SZ];\n    uint8               comp_len_;                       // compression length\n    CompressionMethod   compression_methods_;  \npublic:\n    friend input_buffer&  operator>>(input_buffer&, ClientHello&);\n    friend output_buffer& operator<<(output_buffer&, const ClientHello&);\n  \n    input_buffer&  set(input_buffer& in);\n    output_buffer& get(output_buffer& out) const;\n\n    HandShakeType  get_type() const;\n    void Process(input_buffer&, SSL&);\n\n    const opaque* get_random() const;\n    friend void buildClientHello(SSL&, ClientHello&);\n    friend void ProcessOldClientHello(input_buffer& input, SSL& ssl);\n\n    ClientHello();\n    ClientHello(ProtocolVersion pv, bool useCompression);\nprivate:\n    ClientHello(const ClientHello&);            // hide copy\n    ClientHello& operator=(const ClientHello&); // and assign\n};\n\n\n\n// The Server's Hello Message from page 24\nclass ServerHello : public HandShakeBase {\n    ProtocolVersion     server_version_;\n    Random              random_;\n    uint8               id_len_;                 // session id length\n    opaque              session_id_[ID_LEN];\n    opaque              cipher_suite_[SUITE_LEN];\n    CompressionMethod   compression_method_;\npublic:\n    ServerHello(ProtocolVersion pv, bool useCompression);\n    ServerHello();\n          \n    friend input_buffer&  operator>>(input_buffer&, ServerHello&);\n    friend output_buffer& operator<<(output_buffer&, const ServerHello&);\n   \n    input_buffer&  set(input_buffer& in);\n    output_buffer& get(output_buffer& out) const;\n\n    HandShakeType  get_type() const;\n    void Process(input_buffer&, SSL&);\n\n    const opaque* get_random() const;\n    friend void buildServerHello(SSL&, ServerHello&);\nprivate:\n    ServerHello(const ServerHello&);            // hide copy\n    ServerHello& operator=(const ServerHello&); // and assign\n};\n\n\nclass x509;  \n\n// Certificate could be a chain\nclass Certificate : public HandShakeBase {\n    const x509* cert_;\npublic:\n    Certificate();\n    explicit Certificate(const x509* cert); \n    friend output_buffer& operator<<(output_buffer&, const Certificate&);\n\n    const opaque* get_buffer() const;\n  \n    // Process handles input, needs SSL\n    input_buffer&  set(input_buffer& in);\n    output_buffer& get(output_buffer& out) const;\n\n    HandShakeType get_type() const;\n    void Process(input_buffer&, SSL&);\nprivate:\n    Certificate(const Certificate&);            // hide copy\n    Certificate& operator=(const Certificate&); // and assign\n};\n\n\n\n// RSA Public Key\nstruct ServerRSAParams {\n    opaque* rsa_modulus_;\n    opaque* rsa_exponent_;\n};\n\n\n// Ephemeral Diffie-Hellman Parameters\nclass ServerDHParams {\n    int pSz_;\n    int gSz_;\n    int pubSz_;\n    opaque* p_;\n    opaque* g_;\n    opaque* Ys_;\npublic:\n    ServerDHParams();\n    ~ServerDHParams();\n\n    int get_pSize()   const;\n    int get_gSize()   const;\n    int get_pubSize() const;\n\n    const opaque* get_p()   const;\n    const opaque* get_g()   const;\n    const opaque* get_pub() const;\n\n    opaque* alloc_p(int sz);\n    opaque* alloc_g(int sz);\n    opaque* alloc_pub(int sz);\nprivate:\n    ServerDHParams(const ServerDHParams&);            // hide copy\n    ServerDHParams& operator=(const ServerDHParams&); // and assign\n};\n\n\nstruct ServerKeyBase : public virtual_base {\n    virtual ~ServerKeyBase() {}\n    virtual void build(SSL&) {}\n    virtual void read(SSL&, input_buffer&) {}\n    virtual int  get_length() const;     \n    virtual opaque* get_serverKey() const;\n};\n\n\n// Server random number for FORTEZZA KEA\nstruct Fortezza_Server : public ServerKeyBase {\n    opaque r_s_[FORTEZZA_MAX];\n};\n\n\nstruct SignatureBase : public virtual_base {\n    virtual ~SignatureBase() {}\n};\n\nstruct anonymous_sa : public SignatureBase {};\n\n\nstruct Hashes {\n    uint8 md5_[MD5_LEN];\n    uint8 sha_[SHA_LEN];\n};\n    \n\nstruct rsa_sa : public SignatureBase {\n    Hashes hashes_;\n};\n\n\nstruct dsa_sa : public SignatureBase {\n    uint8 sha_[SHA_LEN];\n};\n\n\n// Server's Diffie-Hellman exchange\nclass DH_Server : public ServerKeyBase {\n    ServerDHParams  parms_;\n    opaque*         signature_;\n\n    int             length_;                // total length of message\n    opaque*         keyMessage_;            // total exchange message\npublic:\n    DH_Server();\n    ~DH_Server();\n\n    void build(SSL&);\n    void read(SSL&, input_buffer&);\n    int  get_length() const;\n    opaque* get_serverKey() const;\nprivate:\n    DH_Server(const DH_Server&);            // hide copy\n    DH_Server& operator=(const DH_Server&); // and assign\n};\n\n\n// Server's RSA exchange\nstruct RSA_Server : public ServerKeyBase {\n    ServerRSAParams params_;\n    opaque*         signature_;   // signed rsa_sa hashes\n};\n\n\nclass ServerKeyExchange : public HandShakeBase {\n    ServerKeyBase* server_key_;\npublic:\n    explicit ServerKeyExchange(SSL&);\n    ServerKeyExchange();\n    ~ServerKeyExchange();\n\n    void createKey(SSL&);\n    void build(SSL& ssl);\n   \n    const opaque* getKey()       const;\n    int           getKeyLength() const;\n\n    input_buffer&  set(input_buffer& in);\n    output_buffer& get(output_buffer& out) const;\n\n    friend output_buffer& operator<<(output_buffer&, const ServerKeyExchange&);\n\n    void Process(input_buffer&, SSL&);\n    HandShakeType get_type() const;\nprivate:\n    ServerKeyExchange(const ServerKeyExchange&);            // hide copy\n    ServerKeyExchange& operator=(const ServerKeyExchange&); // and assign\n};\n\n\n\nclass CertificateRequest : public HandShakeBase  {\n    ClientCertificateType         certificate_types_[CERT_TYPES];\n    int                           typeTotal_;\n    STL::list<DistinguishedName>  certificate_authorities_;\npublic:\n    CertificateRequest();\n    ~CertificateRequest();\n\n    input_buffer&  set(input_buffer& in);\n    output_buffer& get(output_buffer& out) const;\n\n    friend input_buffer&  operator>>(input_buffer&, CertificateRequest&);\n    friend output_buffer& operator<<(output_buffer&,\n                                     const CertificateRequest&);\n\n    void Process(input_buffer&, SSL&);\n    HandShakeType get_type() const;\n\n    void Build();\nprivate:\n    CertificateRequest(const CertificateRequest&);              // hide copy\n    CertificateRequest& operator=(const CertificateRequest&);   // and assign\n};\n\n\nstruct ServerHelloDone : public HandShakeBase {\n    ServerHelloDone();\n    input_buffer&  set(input_buffer& in);\n    output_buffer& get(output_buffer& out) const;\n\n    void Process(input_buffer& input, SSL& ssl);\n\n    HandShakeType get_type() const;\n};\n\n\nstruct PreMasterSecret {\n    opaque  random_[SECRET_LEN];     // first two bytes Protocol Version\n};\n\n\nstruct ClientKeyBase : public virtual_base {\n    virtual ~ClientKeyBase() {}\n    virtual void build(SSL&) {}\n    virtual void read(SSL&, input_buffer&) {}\n    virtual int  get_length() const;\n    virtual opaque* get_clientKey() const;\n};\n\n\nclass EncryptedPreMasterSecret : public ClientKeyBase {\n    opaque* secret_;\n    int     length_;\npublic:\n    EncryptedPreMasterSecret();\n    ~EncryptedPreMasterSecret();\n\n    void    build(SSL&);\n    void    read(SSL&, input_buffer&);\n    int     get_length()    const;\n    opaque* get_clientKey() const;\n    void    alloc(int sz);\nprivate:\n    // hide copy and assign\n    EncryptedPreMasterSecret(const EncryptedPreMasterSecret&);           \n    EncryptedPreMasterSecret& operator=(const EncryptedPreMasterSecret&);\n};\n\n\n// Fortezza Key Parameters from page 29\n// hard code lengths cause only used here\nstruct FortezzaKeys : public ClientKeyBase {\n    opaque  y_c_                      [128];    // client's Yc, public value\n    opaque  r_c_                      [128];    // client's Rc\n    opaque  y_signature_              [40];     // DSS signed public key\n    opaque  wrapped_client_write_key_ [12];     // wrapped by the TEK\n    opaque  wrapped_server_write_key_ [12];     // wrapped by the TEK\n    opaque  client_write_iv_          [24];      \n    opaque  server_write_iv_          [24];\n    opaque  master_secret_iv_         [24];     // IV used to encrypt preMaster\n    opaque  encrypted_preMasterSecret_[48];     // random & crypted by the TEK\n};\n\n\n\n// Diffie-Hellman public key from page 40/41\nclass  ClientDiffieHellmanPublic : public ClientKeyBase {\n    PublicValueEncoding public_value_encoding_;\n    int     length_;    // includes two byte length for message\n    opaque* Yc_;        // length + Yc_\n    // dh_Yc only if explicit, otherwise sent in certificate\n    enum { KEY_OFFSET = 2 };\npublic:\n    ClientDiffieHellmanPublic();\n    ~ClientDiffieHellmanPublic();\n\n    void    build(SSL&);\n    void    read(SSL&, input_buffer&);\n    int     get_length()    const;\n    opaque* get_clientKey() const;\n    void    alloc(int sz, bool offset = false);\nprivate:\n    // hide copy and assign\n    ClientDiffieHellmanPublic(const ClientDiffieHellmanPublic&);\n    ClientDiffieHellmanPublic& operator=(const ClientDiffieHellmanPublic&);\n};\n\n\nclass ClientKeyExchange : public HandShakeBase {\n    ClientKeyBase*  client_key_;\npublic:\n    explicit ClientKeyExchange(SSL& ssl);\n    ClientKeyExchange();\n    ~ClientKeyExchange();\n\n    void createKey(SSL&);\n    void build(SSL& ssl);\n   \n    const opaque* getKey()       const;\n    int           getKeyLength() const;\n\n    friend output_buffer& operator<<(output_buffer&, const ClientKeyExchange&);\n   \n    input_buffer&  set(input_buffer& in);\n    output_buffer& get(output_buffer& out) const;\n\n    HandShakeType  get_type() const;\n    void Process(input_buffer&, SSL&);\nprivate:\n    ClientKeyExchange(const ClientKeyExchange&);            // hide copy\n    ClientKeyExchange& operator=(const ClientKeyExchange&); // and assign\n};\n\n\nclass CertificateVerify : public HandShakeBase {\n    Hashes             hashes_;\n    byte*              signature_;  // owns\npublic:\n    CertificateVerify();\n    ~CertificateVerify();\n\n    input_buffer&  set(input_buffer& in);\n    output_buffer& get(output_buffer& out) const;\n\n    friend input_buffer&  operator>>(input_buffer&, CertificateVerify&);\n    friend output_buffer& operator<<(output_buffer&, const CertificateVerify&);\n\n    void Process(input_buffer&, SSL&);\n    HandShakeType get_type() const;\n\n    void Build(SSL&);\nprivate:\n    CertificateVerify(const CertificateVerify&);              // hide copy\n    CertificateVerify& operator=(const CertificateVerify&);   // and assign\n};\n\n\nclass Finished : public HandShakeBase {\n    Hashes hashes_;\npublic:\n    Finished();\n\n    uint8* set_md5();\n    uint8* set_sha();\n\n    friend input_buffer& operator>>(input_buffer&, Finished&);\n    friend output_buffer& operator<<(output_buffer&, const Finished&);\n\n    input_buffer&  set(input_buffer& in);\n    output_buffer& get(output_buffer& out) const;\n\n    void Process(input_buffer&, SSL&);\n\n    HandShakeType get_type() const;\nprivate:\n    Finished(const Finished&);            // hide copy\n    Finished& operator=(const Finished&); // and assign\n};\n\n\nclass RandomPool;  // forward for connection\n\n\n// SSL Connection defined on page 11\nstruct Connection {\n    opaque          *pre_master_secret_;\n    opaque          master_secret_[SECRET_LEN];\n    opaque          client_random_[RAN_LEN];\n    opaque          server_random_[RAN_LEN];\n    opaque          sessionID_[ID_LEN];\n    opaque          client_write_MAC_secret_[SHA_LEN]; // sha  is max size\n    opaque          server_write_MAC_secret_[SHA_LEN];\n    opaque          client_write_key_[AES_256_KEY_SZ]; // aes 256bit is max sz\n    opaque          server_write_key_[AES_256_KEY_SZ];\n    opaque          client_write_IV_[AES_IV_SZ];       // aes is max size\n    opaque          server_write_IV_[AES_IV_SZ];\n    uint32          sequence_number_;\n    uint32          peer_sequence_number_;\n    uint32          pre_secret_len_;                   // pre master length\n    bool            send_server_key_;                  // server key exchange?\n    bool            master_clean_;                     // master secret clean?\n    bool            TLS_;                              // TLSv1 or greater\n    bool            TLSv1_1_;                          // TLSv1.1 or greater\n    bool            sessionID_Set_;                    // do we have a session\n    bool            compression_;                      // zlib compression?\n    ProtocolVersion version_;                          // negotiated version\n    ProtocolVersion chVersion_;                        // client hello version\n    RandomPool&     random_;\n\n    Connection(ProtocolVersion v, RandomPool& ran);\n    ~Connection();\n\n    void AllocPreSecret(uint sz);\n    void CleanPreMaster();\n    void CleanMaster();\n    void TurnOffTLS();\n    void TurnOffTLS1_1();\nprivate:\n    Connection(const Connection&);              // hide copy\n    Connection& operator=(const Connection&);   // and assign\n};\n\n\nstruct Ciphers;   // forward\n\n\n// TLSv1 Security Spec, defined on page 56 of RFC 2246\nstruct Parameters {\n    ConnectionEnd        entity_;\n    BulkCipherAlgorithm  bulk_cipher_algorithm_;\n    CipherType           cipher_type_;\n    uint8                key_size_;\n    uint8                iv_size_;\n    IsExportable         is_exportable_;\n    MACAlgorithm         mac_algorithm_;\n    uint8                hash_size_;\n    CompressionMethod    compression_algorithm_;\n    KeyExchangeAlgorithm kea_;                        // yassl additions\n    SignatureAlgorithm   sig_algo_;                   // signature auth type\n    SignatureAlgorithm   verify_algo_;                // cert verify auth type\n    bool                 pending_;                  \n    bool                 resumable_;                  // new conns by session\n    uint16               encrypt_size_;               // current msg encrypt sz\n    Cipher               suite_[SUITE_LEN];           // choosen suite\n    uint8                suites_size_;\n    Cipher               suites_[MAX_SUITE_SZ];\n    char                 cipher_name_[MAX_SUITE_NAME];\n    char                 cipher_list_[MAX_CIPHERS][MAX_SUITE_NAME];\n    bool                 removeDH_;                   // for server's later use\n\n    Parameters(ConnectionEnd, const Ciphers&, ProtocolVersion, bool haveDH);\n\n    void SetSuites(ProtocolVersion pv, bool removeDH = false,\n                   bool removeRSA = false, bool removeDSA = false);\n    void SetCipherNames();\nprivate:\n    Parameters(const Parameters&);              // hide copy\n    Parameters& operator=(const Parameters&);   // and assing\n};\n\n\ninput_buffer&  operator>>(input_buffer&,  RecordLayerHeader&);\noutput_buffer& operator<<(output_buffer&, const RecordLayerHeader&);\n\ninput_buffer&  operator>>(input_buffer&,  Message&);\noutput_buffer& operator<<(output_buffer&, const Message&);\n\ninput_buffer&  operator>>(input_buffer&,  HandShakeBase&);\noutput_buffer& operator<<(output_buffer&, const HandShakeBase&);\n\n\n// Message Factory definition\n// uses the ContentType enumeration for unique id\ntypedef Factory<Message> MessageFactory;\nvoid    InitMessageFactory(MessageFactory&);     // registers derived classes\n\n// HandShake Factory definition\n// uses the HandShakeType enumeration for unique id\ntypedef Factory<HandShakeBase> HandShakeFactory;  \nvoid    InitHandShakeFactory(HandShakeFactory&); // registers derived classes\n\n// ServerKey Factory definition\n// uses KeyExchangeAlgorithm enumeration for unique  id\ntypedef Factory<ServerKeyBase> ServerKeyFactory;\nvoid    InitServerKeyFactory(ServerKeyFactory&);\n\n// ClientKey Factory definition\n// uses KeyExchangeAlgorithm enumeration for unique  id\ntypedef Factory<ClientKeyBase> ClientKeyFactory;\nvoid    InitClientKeyFactory(ClientKeyFactory&);\n\n\n// Message Creators\nMessage* CreateHandShake();\nMessage* CreateCipherSpec();\nMessage* CreateAlert();\nMessage* CreateData();\n\n\n// HandShake Creators\nHandShakeBase* CreateCertificate();\nHandShakeBase* CreateHelloRequest();\nHandShakeBase* CreateClientHello();\nHandShakeBase* CreateServerHello();\nHandShakeBase* CreateServerKeyExchange();\nHandShakeBase* CreateCertificateRequest();\nHandShakeBase* CreateServerHelloDone();\nHandShakeBase* CreateClientKeyExchange();\nHandShakeBase* CreateCertificateVerify();\nHandShakeBase* CreateFinished();\n\n\n// ServerKey Exchange Creators\nServerKeyBase* CreateRSAServerKEA();\nServerKeyBase* CreateDHServerKEA();\nServerKeyBase* CreateFortezzaServerKEA();\n\n// ClientKey Exchange Creators\nClientKeyBase* CreateRSAClient();\nClientKeyBase* CreateDHClient();\nClientKeyBase* CreateFortezzaClient();\n\n\n\n} // naemspace\n\n#endif // yaSSL_IMP_HPP\n"
  },
  {
    "path": "ext/yassl/include/yassl_int.hpp",
    "content": "/*\n   Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* yaSSL internal header defines SSL supporting types not specified in the\n * draft along with type conversion functions and openssl compatibility\n */\n\n\n#ifndef yaSSL_INT_HPP\n#define yaSSL_INT_HPP\n\n#include \"yassl_imp.hpp\"\n#include \"yassl_error.hpp\"\n#include \"crypto_wrapper.hpp\"\n#include \"cert_wrapper.hpp\"\n#include \"log.hpp\"\n#include \"lock.hpp\"\n#include \"openssl/ssl.h\"  // ASN1_STRING and DH\n\n// Check if _POSIX_THREADS should be forced\n#if !defined(_POSIX_THREADS) && defined(__hpux)\n// HPUX does not define _POSIX_THREADS as it's not _fully_ implemented\n#define _POSIX_THREADS\n#endif\n\n#ifdef _POSIX_THREADS\n    #include <pthread.h>\n#endif\n\n\nnamespace STL = STL_NAMESPACE;\n\n\nnamespace yaSSL {\n\n\n// State Machine for Record Layer Protocol\nenum RecordLayerState {\n    recordNotReady = 0,         // fatal error, no more processing\n    recordReady\n};\n\n\n// State Machine for HandShake Protocol\nenum HandShakeState {\n    handShakeNotReady = 0,      // fatal error, no more processing\n    preHandshake,               // initial state\n    inHandshake,                // handshake started\n    handShakeReady              // handshake done\n};\n\n\n// client input HandShake state, use if HandShakeState == inHandShake\nenum ClientState {\n    serverNull = 0,\n    serverHelloComplete,\n    serverCertComplete,\n    serverKeyExchangeComplete,\n    serverHelloDoneComplete,\n    serverFinishedComplete\t\n};\n\n\n// server input HandShake state, use if HandShakeState == inHandShake\nenum ServerState {\n    clientNull = 0,\n    clientHelloComplete,\n    clientKeyExchangeComplete,\n    clientFinishedComplete        \n};\n\n\n// client connect state for nonblocking restart\nenum ConnectState {\n    CONNECT_BEGIN = 0,\n    CLIENT_HELLO_SENT,\n    FIRST_REPLY_DONE,\n    FINISHED_DONE,\n    SECOND_REPLY_DONE\n};\n\n\n// server accpet state for nonblocking restart\nenum AcceptState {\n    ACCEPT_BEGIN = 0,\n    ACCEPT_FIRST_REPLY_DONE,\n    SERVER_HELLO_DONE,\n    ACCEPT_SECOND_REPLY_DONE,\n    ACCEPT_FINISHED_DONE,\n    ACCEPT_THIRD_REPLY_DONE\n};\n\n\n// track received messages to explicitly disallow duplicate messages\nstruct RecvdMessages {\n    uint8 gotClientHello_;\n    uint8 gotServerHello_;\n    uint8 gotCert_;\n    uint8 gotServerKeyExchange_;\n    uint8 gotCertRequest_;\n    uint8 gotServerHelloDone_;\n    uint8 gotCertVerify_;\n    uint8 gotClientKeyExchange_;\n    uint8 gotFinished_;\n    RecvdMessages() : gotClientHello_(0), gotServerHello_(0), gotCert_(0),\n                      gotServerKeyExchange_(0), gotCertRequest_(0),\n                      gotServerHelloDone_(0), gotCertVerify_(0),\n                      gotClientKeyExchange_(0), gotFinished_(0)\n                    {} \n};\n\n\n// combines all states\nclass States {\n    RecordLayerState recordLayer_;\n    HandShakeState   handshakeLayer_;\n    ClientState      clientState_;\n    ServerState      serverState_;\n    ConnectState     connectState_;\n    AcceptState      acceptState_;\n    RecvdMessages    recvdMessages_;\n    char             errorString_[MAX_ERROR_SZ];\n    YasslError       what_;\npublic:\n    States();\n\n    const RecordLayerState& getRecord()    const;\n    const HandShakeState&   getHandShake() const;\n    const ClientState&      getClient()    const;\n    const ServerState&      getServer()    const;\n    const ConnectState&     GetConnect()   const;\n    const AcceptState&      GetAccept()    const;\n    const char*             getString()    const;\n          YasslError        What()         const;\n\n    RecordLayerState& useRecord();\n    HandShakeState&   useHandShake();\n    ClientState&      useClient();\n    ServerState&      useServer();\n    ConnectState&     UseConnect();\n    AcceptState&      UseAccept();\n    char*             useString();\n    void              SetError(YasslError);\n    int               SetMessageRecvd(HandShakeType);\nprivate:\n    States(const States&);              // hide copy\n    States& operator=(const States&);   // and assign\n};\n\n\n// holds all factories\nclass sslFactory {\n    MessageFactory      messageFactory_;        // creates new messages by type\n    HandShakeFactory    handShakeFactory_;      // creates new handshake types\n    ServerKeyFactory    serverKeyFactory_;      // creates new server key types\n    ClientKeyFactory    clientKeyFactory_;      // creates new client key types\n\n    sslFactory();                               // only GetSSL_Factory creates\npublic:\n    const MessageFactory&   getMessage()   const;\n    const HandShakeFactory& getHandShake() const;\n    const ServerKeyFactory& getServerKey() const;\n    const ClientKeyFactory& getClientKey() const;\n\n    friend sslFactory& GetSSL_Factory();        // singleton creator\nprivate:\n    sslFactory(const sslFactory&);              // hide copy\n    sslFactory& operator=(const sslFactory&);   // and assign   \n};\n\n\n#undef X509_NAME  // wincrypt.h clash\n\n// openSSL X509 names\nclass X509_NAME {\n    char*       name_;\n    size_t      sz_;\n    ASN1_STRING entry_;\npublic:\n    X509_NAME(const char*, size_t sz);\n    ~X509_NAME();\n\n    const char*  GetName() const;\n    ASN1_STRING* GetEntry(int i);\n    size_t       GetLength() const;\nprivate:\n    X509_NAME(const X509_NAME&);                // hide copy\n    X509_NAME& operator=(const X509_NAME&);     // and assign\n};\n\n\nclass StringHolder {\n    ASN1_STRING  asnString_;\npublic:\n    StringHolder(const char* str, int sz, byte type= 0);\n    ~StringHolder();\n\n    ASN1_STRING* GetString();\nprivate:\n    StringHolder(const StringHolder&);                // hide copy\n    StringHolder& operator=(const StringHolder&);     // and assign\n};\n\n\n// openSSL X509\nclass X509 {\n    X509_NAME issuer_;\n    X509_NAME subject_;\n    StringHolder beforeDate_;   // not valid before\n    StringHolder afterDate_;    // not valid after\npublic:\n    X509(const char* i, size_t, const char* s, size_t,\n         ASN1_STRING *b, ASN1_STRING *a);\n    ~X509() {}\n\n    X509_NAME* GetIssuer();\n    X509_NAME* GetSubject();\n\n    ASN1_STRING* GetBefore();\n    ASN1_STRING* GetAfter();\n\nprivate:\n    X509(const X509&);              // hide copy\n    X509& operator=(const X509&);   // and assign\n};\n\n\n// openSSL bignum\nstruct BIGNUM {\n    /*\n      gcc 2.96 fix: because of two Integer classes (yaSSL::Integer and\n      TaoCrypt::Integer), we need to explicitly state the namespace\n      here to let gcc 2.96 deduce the correct type.\n    */\n    yaSSL::Integer int_;\n    void assign(const byte* b, uint s) { int_.assign(b,s); }\n};\n\n\n// openSSL session\nclass SSL_SESSION {\n    opaque      sessionID_[ID_LEN];\n    opaque      master_secret_[SECRET_LEN];\n    Cipher      suite_[SUITE_LEN];\n    uint        bornOn_;                        // create time in seconds\n    uint        timeout_;                       // timeout in seconds\n    RandomPool& random_;                        // will clean master secret\n    X509*       peerX509_;\npublic:\n    explicit SSL_SESSION(RandomPool&);\n    SSL_SESSION(const SSL&, RandomPool&);\n    ~SSL_SESSION();\n\n    const opaque* GetID()       const;\n    const opaque* GetSecret()   const;\n    const Cipher* GetSuite()    const;\n          uint    GetBornOn()   const;\n          uint    GetTimeOut()  const;\n          X509*   GetPeerX509() const;\n          void    SetTimeOut(uint);\n\n    SSL_SESSION& operator=(const SSL_SESSION&); // allow assign for resumption\nprivate:\n    SSL_SESSION(const SSL_SESSION&);            // hide copy\n\n    void CopyX509(X509*);\n};\n\n\n// holds all sessions\nclass Sessions {\n    STL::list<SSL_SESSION*> list_;\n    RandomPool random_;                 // for session cleaning\n    Mutex      mutex_;                  // no-op for single threaded\n    int        count_;                  // flush counter\n\n    Sessions() : count_(0) {}           // only GetSessions can create\npublic: \n    SSL_SESSION* lookup(const opaque*, SSL_SESSION* copy = 0);\n    void         add(const SSL&);\n    void         remove(const opaque*);\n    void         Flush();\n\n    ~Sessions();\n\n    friend void Session_initialize();\n    friend Sessions& GetSessions(); // singleton creator\nprivate:\n    Sessions(const Sessions&);              // hide copy\n    Sessions& operator=(const Sessions&);   // and assign\n};\n\n\n#ifdef _POSIX_THREADS\n    typedef pthread_t THREAD_ID_T;\n#else\n    typedef DWORD     THREAD_ID_T;\n#endif\n\n// thread error data\nstruct ThreadError {\n    THREAD_ID_T threadID_;\n    int         errorID_;\n};\n\n\n// holds all errors\nclass Errors {\n    STL::list<ThreadError> list_;\n    Mutex                  mutex_;\n\n    Errors() {}                         // only GetErrors can create\npublic:\n    int  Lookup(bool peek);             // self lookup\n    void Add(int);              \n    void Remove();                      // remove self\n\n    ~Errors() {}\n\n    friend Errors& GetErrors(); // singleton creator\nprivate:\n    Errors(const Errors&);              // hide copy\n    Errors& operator=(const Errors);    // and assign\n};\n\n\nSessions&   GetSessions();      // forward singletons\nsslFactory& GetSSL_Factory();\nErrors&     GetErrors();\n\n\n// openSSL method and context types\nclass SSL_METHOD {\n    ProtocolVersion version_;\n    ConnectionEnd   side_;\n    bool            verifyPeer_;    // request or send certificate\n    bool            verifyNone_;    // whether to verify certificate\n    bool            failNoCert_;\n    bool            multipleProtocol_;  // for SSLv23 compatibility\npublic:\n    SSL_METHOD(ConnectionEnd ce, ProtocolVersion pv,\n               bool multipleProtocol = false);\n\n    ProtocolVersion getVersion() const;\n    ConnectionEnd   getSide()    const;\n\n    void setVerifyPeer();\n    void setVerifyNone();\n    void setFailNoCert();\n\n    bool verifyPeer() const;\n    bool verifyNone() const;\n    bool failNoCert() const;\n    bool multipleProtocol() const;\nprivate:\n    SSL_METHOD(const SSL_METHOD&);              // hide copy\n    SSL_METHOD& operator=(const SSL_METHOD&);   // and assign\n};\n\n\nstruct Ciphers {\n    bool        setSuites_;             // user set suites from default\n    byte        suites_[MAX_SUITE_SZ];  // new suites\n    int         suiteSz_;               // suite length in bytes\n\n    Ciphers() : setSuites_(false), suiteSz_(0) {}\n};\n\n\nstruct DH;  // forward\n\n\n// save for SSL construction\nstruct DH_Parms {\n    Integer p_;\n    Integer g_;\n    bool set_;   // if set by user\n\n    DH_Parms() : set_(false) {}\n};\n\n\nenum StatsField { \n    Accept, Connect, AcceptGood, ConnectGood, AcceptRenegotiate,\n    ConnectRenegotiate, Hits, CbHits, CacheFull, Misses, Timeouts, Number,\n    GetCacheSize, VerifyMode, VerifyDepth \n};\n\n\n// SSL stats\nstruct Stats {\n    long accept_;\n    long connect_;\n    long acceptGood_;\n    long connectGood_;\n    long acceptRenegotiate_;\n    long connectRenegotiate_;\n\n    long hits_;\n    long cbHits_;\n    long cacheFull_;\n    long misses_;\n    long timeouts_;\n    long number_;\n    long getCacheSize_;\n\n    int verifyMode_;\n    int verifyDepth_;\npublic:\n    Stats() : accept_(0), connect_(0), acceptGood_(0), connectGood_(0),\n        acceptRenegotiate_(0), connectRenegotiate_(0), hits_(0), cbHits_(0),\n        cacheFull_(0), misses_(0), timeouts_(0), number_(0), getCacheSize_(0),\n        verifyMode_(0), verifyDepth_(0)\n    {}\nprivate:\n    Stats(const Stats&);            // hide copy\n    Stats& operator=(const Stats&); // and assign\n};\n\n\n// the SSL context\nclass SSL_CTX {\npublic:\n    typedef STL::list<x509*> CertList;\nprivate:\n    SSL_METHOD*     method_;\n    x509*           certificate_;\n    x509*           privateKey_;\n    CertList        caList_;\n    Ciphers         ciphers_;\n    DH_Parms        dhParms_;\n    pem_password_cb passwordCb_;\n    void*           userData_;\n    bool            sessionCacheOff_;\n    bool            sessionCacheFlushOff_;\n    Stats           stats_;\n    Mutex           mutex_;         // for Stats\n    VerifyCallback  verifyCallback_;\npublic:\n    explicit SSL_CTX(SSL_METHOD* meth);\n    ~SSL_CTX();\n\n    const x509*       getCert()       const;\n    const x509*       getKey()        const;\n    const SSL_METHOD* getMethod()     const;\n    const Ciphers&    GetCiphers()    const;\n    const DH_Parms&   GetDH_Parms()   const;\n    const Stats&      GetStats()      const;\n    VerifyCallback    getVerifyCallback() const;\n    pem_password_cb   GetPasswordCb() const;\n          void*       GetUserData()   const;\n          bool        GetSessionCacheOff()      const;\n          bool        GetSessionCacheFlushOff() const;\n\n    void setVerifyPeer();\n    void setVerifyNone();\n    void setFailNoCert();\n    void setVerifyCallback(VerifyCallback);\n    bool SetCipherList(const char*);\n    bool SetDH(const DH&);\n    void SetPasswordCb(pem_password_cb cb);\n    void SetUserData(void*);\n    void SetSessionCacheOff();\n    void SetSessionCacheFlushOff();\n   \n    void            IncrementStats(StatsField);\n    void            AddCA(x509* ca);\n    const CertList& GetCA_List() const;\n\n    friend int read_file(SSL_CTX*, const char*, int, CertType);\nprivate:\n    SSL_CTX(const SSL_CTX&);            // hide copy\n    SSL_CTX& operator=(const SSL_CTX&); // and assign\n};\n\n\n// holds all cryptographic types\nclass Crypto {\n    Digest*             digest_;                // agreed upon digest\n    BulkCipher*         cipher_;                // agreed upon cipher\n    DiffieHellman*      dh_;                    // dh parms\n    RandomPool          random_;                // random number generator\n    CertManager         cert_;                  // manages certificates\npublic:\n    explicit Crypto();\n    ~Crypto();\n\n    const Digest&        get_digest()      const;\n    const BulkCipher&    get_cipher()      const;\n    const DiffieHellman& get_dh()          const;\n    const RandomPool&    get_random()      const;\n    const CertManager&   get_certManager() const;\n          \n    Digest&        use_digest();\n    BulkCipher&    use_cipher();\n    DiffieHellman& use_dh();\n    RandomPool&    use_random();\n    CertManager&   use_certManager();\n\n    void SetDH(DiffieHellman*);\n    void SetDH(const DH_Parms&);\n    void setDigest(Digest*);\n    void setCipher(BulkCipher*);\n\n    bool DhSet();\nprivate:\n    Crypto(const Crypto&);              // hide copy\n    Crypto& operator=(const Crypto&);   // and assign\n};\n\n\n// holds all handshake and verify hashes\nclass sslHashes {\n    MD5       md5HandShake_;          // md5 handshake hash\n    SHA       shaHandShake_;          // sha handshake hash\n    Finished  verify_;                // peer's verify hash\n    Hashes    certVerify_;            // peer's cert verify hash\npublic:\n    sslHashes() {}\n\n    const MD5&      get_MD5()        const;\n    const SHA&      get_SHA()        const;\n    const Finished& get_verify()     const;\n    const Hashes&   get_certVerify() const;\n\n    MD5&      use_MD5();\n    SHA&      use_SHA();\n    Finished& use_verify();\n    Hashes&   use_certVerify();\nprivate:\n    sslHashes(const sslHashes&);             // hide copy\n    sslHashes& operator=(const sslHashes&); // and assign\n};\n\n\n// holds input and output buffers\nclass Buffers {\npublic: \n    typedef STL::list<input_buffer*>  inputList;\n    typedef STL::list<output_buffer*> outputList;\n    int prevSent;     // previous plain text bytes sent when got WANT_WRITE\n    int plainSz;      // plain text bytes in buffer to send when got WANT_WRITE \nprivate:\n    inputList      dataList_;             // list of users app data / handshake\n    outputList     handShakeList_;        // buffered handshake msgs\n    input_buffer*  rawInput_;             // buffered raw input yet to process\n    output_buffer* output_;               // WANT_WRITE buffered output \npublic:\n    Buffers();\n    ~Buffers();\n\n    const inputList&  getData()      const;\n    const outputList& getHandShake() const;\n\n    inputList&  useData();\n    outputList& useHandShake();\n\n    void           SetRawInput(input_buffer*);  // takes ownership\n    input_buffer*  TakeRawInput();              // takes ownership \n    void           SetOutput(output_buffer*);   // takes ownership\n    output_buffer* TakeOutput();                // takes ownership \nprivate:\n    Buffers(const Buffers&);             // hide copy\n    Buffers& operator=(const Buffers&);  // and assign   \n};\n\n\n// wraps security parameters\nclass Security {\n    Connection    conn_;                          // connection information\n    Parameters    parms_;                         // may be pending\n    SSL_SESSION   resumeSession_;                 // if resuming\n    SSL_CTX*      ctx_;                           // context used to init\n    bool          resuming_;                      // trying to resume\npublic:\n    Security(ProtocolVersion, RandomPool&, ConnectionEnd, const Ciphers&,\n             SSL_CTX*, bool);\n\n    const SSL_CTX*     GetContext()     const;\n    const Connection&  get_connection() const;\n    const Parameters&  get_parms()      const;\n    const SSL_SESSION& get_resume()     const;\n          bool         get_resuming()   const;\n\n    Connection&  use_connection();\n    Parameters&  use_parms();\n    SSL_SESSION& use_resume();\n\n    void set_resuming(bool b);\nprivate:\n    Security(const Security&);              // hide copy\n    Security& operator=(const Security&);   // and assign\n};\n\n\n// THE SSL type\nclass SSL {\n    Crypto              crypto_;                // agreed crypto agents\n    Security            secure_;                // Connection and Session parms\n    States              states_;                // Record and HandShake states\n    sslHashes           hashes_;                // handshake, finished hashes\n    Socket              socket_;                // socket wrapper\n    Buffers             buffers_;               // buffered handshakes and data\n    Log                 log_;                   // logger\n    bool                quietShutdown_;\n\n    // optimization variables\n    bool                has_data_;              // buffered data ready?\npublic:\n    SSL(SSL_CTX* ctx);\n\n    // gets and uses\n    const Crypto&     getCrypto()   const;\n    const Security&   getSecurity() const;\n    const States&     getStates()   const;\n    const sslHashes&  getHashes()   const;\n    const sslFactory& getFactory()  const;\n    const Socket&     getSocket()   const;\n          YasslError  GetError()    const;\n          bool        GetMultiProtocol() const;\n          bool        CompressionOn()    const;\n\n    Crypto&    useCrypto();\n    Security&  useSecurity();\n    States&    useStates();\n    sslHashes& useHashes();\n    Socket&    useSocket();\n    Log&       useLog();\n    Buffers&   useBuffers();\n\n    bool       HasData() const;\n    bool       GetQuietShutdown() const;\n\n    // sets\n    void set_pending(Cipher suite);\n    void set_random(const opaque*, ConnectionEnd);\n    void set_sessionID(const opaque*);\n    void set_session(SSL_SESSION*);\n    void set_preMaster(const opaque*, uint);\n    void set_masterSecret(const opaque*);\n    void SetError(YasslError);\n    int  SetCompression();\n    void UnSetCompression();\n    void SetQuietShutdown(bool mode);\n\n    // helpers\n    bool isTLS() const;\n    bool isTLSv1_1() const;\n    void order_error();\n    void makeMasterSecret();\n    void makeTLSMasterSecret();\n    void addData(input_buffer* data);\n    void fillData(Data&);\n    void PeekData(Data&);\n    void addBuffer(output_buffer* b);\n    void flushBuffer();\n    void verifyState(const RecordLayerHeader&);\n    void verifyState(const HandShakeHeader&);\n    void verifyState(ClientState);\n    void verifyState(ServerState);\n    void verfiyHandShakeComplete();\n    void matchSuite(const opaque*, uint length);\n    void deriveKeys();\n    void deriveTLSKeys();\n    void Send(const byte*, uint);\n    void SendWriteBuffered();\n\n    uint bufferedData();\n    uint get_SEQIncrement(bool);\n\n    const  byte*  get_macSecret(bool);\nprivate:\n    void storeKeys(const opaque*);\n    void setKeys();\n    void verifyClientState(HandShakeType);\n    void verifyServerState(HandShakeType);\n\n    SSL(const SSL&);                    // hide copy\n    const SSL& operator=(const SSL&);   // and assign\n};\n\n\n// compression\nint Compress(const byte*, int, input_buffer&);\nint DeCompress(input_buffer&, int, input_buffer&);\n\n\n// conversion functions\nvoid c32to24(uint32, uint24&);\nvoid c24to32(const uint24, uint32&);\n\nuint32 c24to32(const uint24);\n\nvoid ato16(const opaque*, uint16&);\nvoid ato24(const opaque*, uint24&);\n\nvoid c16toa(uint16, opaque*);\nvoid c24toa(const uint24, opaque*);\nvoid c32toa(uint32 u32, opaque*);\n\n\n} // naemspace\n\n#endif // yaSSL_INT_HPP\n"
  },
  {
    "path": "ext/yassl/include/yassl_types.hpp",
    "content": "/*\n   Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/*  yaSSL types  header defines all constants, enums, and typedefs\n *  from the SSL.v3 specification \"draft-freier-ssl-version3-02.txt\"\n */\n\n\n#ifndef yaSSL_TYPES_HPP\n#define yaSSL_TYPES_HPP\n\n#include <stddef.h>\n#include \"type_traits.hpp\"\n\n\n#ifdef _MSC_VER\n    // disable conversion warning\n    // 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy\n    #pragma warning(disable:4244 4996)\n#endif\n\n\n#ifdef _MSC_VER\n    // disable conversion warning\n    // 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy\n    #pragma warning(disable:4244 4996)\n#endif\n\n\nnamespace yaSSL {\n\n#define YASSL_LIB\n\n\n#ifdef YASSL_PURE_C\n\n    // library allocation\n    struct new_t {};      // yaSSL New type\n    extern new_t ys;      // pass in parameter\n\n    } // namespace yaSSL\n\n    void* operator new  (size_t, yaSSL::new_t);\n    void* operator new[](size_t, yaSSL::new_t);\n\n    void operator delete  (void*, yaSSL::new_t);\n    void operator delete[](void*, yaSSL::new_t);\n\n\n    namespace yaSSL {\n\n\n    template<typename T>\n    void ysDelete(T* ptr)\n    {\n        if (ptr) ptr->~T();\n        ::operator delete(ptr, yaSSL::ys);\n    }\n\n    template<typename T>\n    void ysArrayDelete(T* ptr)\n    {\n        // can't do array placement destruction since not tracking size in\n        // allocation, only allow builtins to use array placement since they\n        // don't need destructors called\n        typedef char builtin[TaoCrypt::IsFundamentalType<T>::Yes ? 1 : -1];\n        (void)sizeof(builtin);\n\n        ::operator delete[](ptr, yaSSL::ys);\n    }\n\n    #define NEW_YS new (yaSSL::ys)\n\n    // to resolve compiler generated operator delete on base classes with\n    // virtual destructors (when on stack)\n    class virtual_base {\n    public:\n        static void operator delete(void*) { }\n    };\n\n\n#else   // YASSL_PURE_C\n\n\n    template<typename T>\n    void ysDelete(T* ptr)\n    {\n        delete ptr;\n    }\n\n    template<typename T>\n    void ysArrayDelete(T* ptr)\n    {\n        delete[] ptr;\n    }\n\n    #define NEW_YS new\n\n    class virtual_base {};\n\n\n\n#endif // YASSL_PURE_C\n\n\ntypedef unsigned char  uint8;\ntypedef unsigned short uint16;\ntypedef unsigned int   uint32;\ntypedef uint8          uint24[3];\ntypedef uint32         uint64[2];\n\ntypedef uint8  opaque;\ntypedef opaque byte;\n\ntypedef unsigned int uint;\n\n\n#ifdef USE_SYS_STL\n    // use system STL\n    #define STL_VECTOR_FILE    <vector>\n    #define STL_LIST_FILE      <list>\n    #define STL_ALGORITHM_FILE <algorithm>\n    #define STL_MEMORY_FILE    <memory>\n    #define STL_PAIR_FILE      <utility>\n    \n    #define STL_NAMESPACE       std\n#else\n    // use mySTL\n    #define STL_VECTOR_FILE    \"vector.hpp\"\n    #define STL_LIST_FILE      \"list.hpp\"\n    #define STL_ALGORITHM_FILE \"algorithm.hpp\"\n    #define STL_MEMORY_FILE    \"memory.hpp\"\n    #define STL_PAIR_FILE      \"pair.hpp\"\n\n    #define STL_NAMESPACE       mySTL\n#endif\n\n\n#ifdef min\n    #undef min\n#endif \n\ntemplate <typename T>\nT min(T a, T b)\n{\n    return a < b ? a : b;\n}\n\n\n \n// all length constants in bytes\nconst int ID_LEN            =  32;  // session id length\nconst int SUITE_LEN         =   2;  // cipher suite length\nconst int SECRET_LEN        =  48;  // pre RSA and all master secret length\nconst int MASTER_ROUNDS     =   3;  // master secret derivation rounds\nconst int RAN_LEN           =  32;  // client and server random length\nconst int MAC_BLOCK_SZ      =  64;  // MAC block size, & padding\nconst int MD5_LEN           =  16;  // MD5 digest length\nconst int SHA_LEN           =  20;  // SHA digest length\nconst int RMD_LEN           =  20;  // RIPEMD-160 digest length\nconst int PREFIX            =   3;  // up to 3 prefix letters for secret rounds\nconst int KEY_PREFIX        =   7;  // up to 7 prefix letters for key rounds\nconst int FORTEZZA_MAX      = 128;  // Maximum Fortezza Key length\nconst int MAX_SUITE_SZ      = 128;  // 64 max suites * sizeof(suite)\nconst int MAX_SUITE_NAME    =  48;  // max length of suite name\nconst int MAX_CIPHERS       =  32;  // max supported ciphers for cipher list\nconst int SIZEOF_ENUM       =   1;  // SSL considers an enum 1 byte, not 4\nconst int SIZEOF_SENDER     =   4;  // Sender constant, for finished generation\nconst int PAD_MD5           =  48;  // pad length 1 and 2 for md5 finished\nconst int PAD_SHA           =  40;  // should be 44, specd wrong by netscape\nconst int PAD_RMD           =  44;  // pad length for RIPEMD-160, some use 40??\nconst int CERT_HEADER       =   3;  // always use 3 bytes for certificate\nconst int CERT_TYPES        =   7;  // certificate request types\nconst int REQUEST_HEADER    =   2;  // request uses 2 bytes\nconst int VERIFY_HEADER     =   2;  // verify length field\nconst int MIN_CERT_TYPES    =   1;  // minimum certificate request types\nconst int MIN_DIS_NAMES     =   3;  // minimum distinguished names\nconst int MIN_DIS_SIZE      =   1;  // minimum distinguished name size\nconst int RECORD_HEADER     =   5;  // type + version + length(2)\nconst int HANDSHAKE_HEADER  =   4;  // type + length(3)\nconst int FINISHED_SZ       = MD5_LEN + SHA_LEN; // sizeof finished data\nconst int TLS_FINISHED_SZ   =  12;  // TLS verify data size\nconst int SEQ_SZ            =   8;  // 64 bit sequence number\nconst int LENGTH_SZ         =   2;  // length field for HMAC, data only\nconst int VERSION_SZ        = SIZEOF_ENUM * 2;  // SSL/TLS length of version\nconst int DES_KEY_SZ        =   8;  // DES Key length\nconst int DES_EDE_KEY_SZ    =  24;  // DES EDE Key length\nconst int DES_BLOCK         =   8;  // DES is always fixed block size 8\nconst int DES_IV_SZ         = DES_BLOCK;    // Init Vector length for DES\nconst int RC4_KEY_SZ        =  16;  // RC4 Key length\nconst int AES_128_KEY_SZ    =  16;  // AES 128bit Key length\nconst int AES_192_KEY_SZ    =  24;  // AES 192bit Key length\nconst int AES_256_KEY_SZ    =  32;  // AES 256bit Key length\nconst int AES_BLOCK_SZ      =  16;  // AES 128bit block size, rfc 3268\nconst int AES_IV_SZ         = AES_BLOCK_SZ; // AES Init Vector length\nconst int DSS_SIG_SZ        =  40;  // two 20 byte high byte first Integers\nconst int DSS_ENCODED_EXTRA =   6;  // seqID + len(1) + (intID + len(1)) * 2\nconst int EVP_SALT_SZ       =   8;\nconst int MASTER_LABEL_SZ   =  13;  // TLS master secret label size\nconst int KEY_LABEL_SZ      =  13;  // TLS key block expansion size\nconst int FINISHED_LABEL_SZ =  15;  // TLS finished lable length\nconst int SEED_LEN          = RAN_LEN * 2; // TLS seed, client + server random\nconst int DEFAULT_TIMEOUT   = 500;  // Default Session timeout in seconds\nconst int MAX_RECORD_SIZE   = 16384; // 2^14, max size by standard\nconst int COMPRESS_EXTRA    = 1024;  // extra compression possible addition\nconst int SESSION_FLUSH_COUNT = 256;  // when to flush session cache\nconst int MAX_PAD_SIZE        = 256;  // max TLS padding size\nconst int COMPRESS_CONSTANT   =  13;  // compression calculation constant\nconst int COMPRESS_UPPER      =  55;  // compression calculation numerator\nconst int COMPRESS_LOWER      =  64;  // compression calculation denominator\nconst int COMPRESS_DUMMY_SIZE =  64;  // compression dummy round size \n\ntypedef uint8 Cipher;             // first byte is always 0x00 for SSLv3 & TLS\n\ntypedef opaque Random[RAN_LEN];\n\ntypedef opaque* DistinguishedName;\n\ntypedef bool IsExportable;\n\n\nenum CompressionMethod { no_compression = 0, zlib = 221 };\n\nenum CipherType { stream, block };\n\nenum CipherChoice { change_cipher_spec_choice = 1 };\n\nenum PublicValueEncoding { implicit_encoding, explicit_encoding };\n\nenum ConnectionEnd { server_end, client_end };\n\nenum AlertLevel { warning = 1, fatal = 2 };\n\n\n\n// Record Layer Header identifier from page 12\nenum ContentType {\n    no_type            = 0,\n    change_cipher_spec = 20, \n    alert              = 21, \n    handshake          = 22, \n    application_data   = 23 \n};\n\n\n// HandShake Layer Header identifier from page 20\nenum HandShakeType {\n    no_shake            = -1,\n    hello_request       = 0, \n    client_hello        = 1, \n    server_hello        = 2,\n    certificate         = 11, \n    server_key_exchange = 12,\n    certificate_request = 13, \n    server_hello_done   = 14,\n    certificate_verify  = 15, \n    client_key_exchange = 16,\n    finished            = 20\n};\n\n\n// Valid Alert types from page 16/17\nenum AlertDescription {\n    close_notify            = 0,\n    unexpected_message      = 10,\n    bad_record_mac          = 20,\n    decompression_failure   = 30,\n    handshake_failure       = 40,\n    no_certificate          = 41,\n    bad_certificate         = 42,\n    unsupported_certificate = 43,\n    certificate_revoked     = 44,\n    certificate_expired     = 45,\n    certificate_unknown     = 46,\n    illegal_parameter       = 47\n};\n\n\n// Supported Key Exchange Protocols\nenum KeyExchangeAlgorithm { \n    no_kea = 0,\n    rsa_kea, \n    diffie_hellman_kea, \n    fortezza_kea \n};\n\n\n// Supported Authentication Schemes\nenum SignatureAlgorithm { \n    anonymous_sa_algo = 0, \n    rsa_sa_algo, \n    dsa_sa_algo \n};\n\n\n// Valid client certificate request types from page 27\nenum ClientCertificateType {    \n    rsa_sign            = 1, \n    dss_sign            = 2,\n    rsa_fixed_dh        = 3,\n    dss_fixed_dh        = 4,\n    rsa_ephemeral_dh    = 5,\n    dss_ephemeral_dh    = 6,\n    fortezza_kea_cert   = 20\n};\n\n\n// Supported Ciphers from page 43\nenum BulkCipherAlgorithm { \n    cipher_null,\n    rc4,\n    rc2,\n    des,\n    triple_des,             // leading 3 (3des) not valid identifier\n    des40,\n    idea,\n    aes\n};\n\n\n// Supported Message Authentication Codes from page 43\nenum MACAlgorithm { \n    no_mac,\n    md5,\n    sha,\n    rmd\n};\n\n\n// Certificate file Type\nenum CertType { Cert = 0, PrivateKey, CA };\n\n\n// all Cipher Suites from pages 41/42\nconst Cipher SSL_NULL_WITH_NULL_NULL                =  0; // { 0x00, 0x00 }\nconst Cipher SSL_RSA_WITH_NULL_MD5                  =  1; // { 0x00, 0x01 }\nconst Cipher SSL_RSA_WITH_NULL_SHA                  =  2; // { 0x00, 0x02 }\nconst Cipher SSL_RSA_EXPORT_WITH_RC4_40_MD5         =  3; // { 0x00, 0x03 }\nconst Cipher SSL_RSA_WITH_RC4_128_MD5               =  4; // { 0x00, 0x04 }\nconst Cipher SSL_RSA_WITH_RC4_128_SHA               =  5; // { 0x00, 0x05 }\nconst Cipher SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5     =  6; // { 0x00, 0x06 }\nconst Cipher SSL_RSA_WITH_IDEA_CBC_SHA              =  7; // { 0x00, 0x07 }\nconst Cipher SSL_RSA_EXPORT_WITH_DES40_CBC_SHA      =  8; // { 0x00, 0x08 }\nconst Cipher SSL_RSA_WITH_DES_CBC_SHA               =  9; // { 0x00, 0x09 }\nconst Cipher SSL_RSA_WITH_3DES_EDE_CBC_SHA          = 10; // { 0x00, 0x0A }\nconst Cipher SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA   = 11; // { 0x00, 0x0B }\nconst Cipher SSL_DH_DSS_WITH_DES_CBC_SHA            = 12; // { 0x00, 0x0C }\nconst Cipher SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA       = 13; // { 0x00, 0x0D }\nconst Cipher SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA   = 14; // { 0x00, 0x0E }\nconst Cipher SSL_DH_RSA_WITH_DES_CBC_SHA            = 15; // { 0x00, 0x0F }\nconst Cipher SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA       = 16; // { 0x00, 0x10 }\nconst Cipher SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA  = 17; // { 0x00, 0x11 }\nconst Cipher SSL_DHE_DSS_WITH_DES_CBC_SHA           = 18; // { 0x00, 0x12 }\nconst Cipher SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA      = 19; // { 0x00, 0x13 }\nconst Cipher SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA  = 20; // { 0x00, 0x14 }\nconst Cipher SSL_DHE_RSA_WITH_DES_CBC_SHA           = 21; // { 0x00, 0x15 }\nconst Cipher SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA      = 22; // { 0x00, 0x16 }\nconst Cipher SSL_DH_anon_EXPORT_WITH_RC4_40_MD5     = 23; // { 0x00, 0x17 }\nconst Cipher SSL_DH_anon_WITH_RC4_128_MD5           = 24; // { 0x00, 0x18 }\nconst Cipher SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA  = 25; // { 0x00, 0x19 }\nconst Cipher SSL_DH_anon_WITH_DES_CBC_SHA           = 26; // { 0x00, 0x1A }\nconst Cipher SSL_DH_anon_WITH_3DES_EDE_CBC_SHA      = 27; // { 0x00, 0x1B }\nconst Cipher SSL_FORTEZZA_KEA_WITH_NULL_SHA         = 28; // { 0x00, 0x1C }\nconst Cipher SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA = 29; // { 0x00, 0x1D }\nconst Cipher SSL_FORTEZZA_KEA_WITH_RC4_128_SHA      = 30; // { 0x00, 0x1E }\n\n// .. to 0x2B uses Kerberos Authentication\n\n\n// TLS AES extensions\nconst Cipher TLS_RSA_WITH_AES_128_CBC_SHA      = 47; // { 0x00, 0x2F }\nconst Cipher TLS_DH_DSS_WITH_AES_128_CBC_SHA   = 48; // { 0x00, 0x30 }\nconst Cipher TLS_DH_RSA_WITH_AES_128_CBC_SHA   = 49; // { 0x00, 0x31 }\nconst Cipher TLS_DHE_DSS_WITH_AES_128_CBC_SHA  = 50; // { 0x00, 0x32 }\nconst Cipher TLS_DHE_RSA_WITH_AES_128_CBC_SHA  = 51; // { 0x00, 0x33 }\nconst Cipher TLS_DH_anon_WITH_AES_128_CBC_SHA  = 52; // { 0x00, 0x34 }\n\nconst Cipher TLS_RSA_WITH_AES_256_CBC_SHA      = 53; // { 0x00, 0x35 }\nconst Cipher TLS_DH_DSS_WITH_AES_256_CBC_SHA   = 54; // { 0x00, 0x36 }\nconst Cipher TLS_DH_RSA_WITH_AES_256_CBC_SHA   = 55; // { 0x00, 0x37 }\nconst Cipher TLS_DHE_DSS_WITH_AES_256_CBC_SHA  = 56; // { 0x00, 0x38 }\nconst Cipher TLS_DHE_RSA_WITH_AES_256_CBC_SHA  = 57; // { 0x00, 0x39 }\nconst Cipher TLS_DH_anon_WITH_AES_256_CBC_SHA  = 58; // { 0x00, 0x3A }\n\n\n// OpenPGP extensions\n\nconst Cipher TLS_DHE_DSS_WITH_3DES_EDE_CBC_RMD160 = 114; // { 0x00, 0x72 };\nconst Cipher TLS_DHE_DSS_WITH_AES_128_CBC_RMD160  = 115; // { 0x00, 0x73 };\nconst Cipher TLS_DHE_DSS_WITH_AES_256_CBC_RMD160  = 116; // { 0x00, 0x74 };\nconst Cipher TLS_DHE_RSA_WITH_3DES_EDE_CBC_RMD160 = 119; // { 0x00, 0x77 };\nconst Cipher TLS_DHE_RSA_WITH_AES_128_CBC_RMD160  = 120; // { 0x00, 0x78 };\nconst Cipher TLS_DHE_RSA_WITH_AES_256_CBC_RMD160  = 121; // { 0x00, 0x79 };\nconst Cipher TLS_RSA_WITH_3DES_EDE_CBC_RMD160     = 124; // { 0x00, 0x7C };\nconst Cipher TLS_RSA_WITH_AES_128_CBC_RMD160      = 125; // { 0x00, 0x7D };\nconst Cipher TLS_RSA_WITH_AES_256_CBC_RMD160      = 126; // { 0x00, 0x7E };\n\n\nconst char* const null_str = \"\";\n\nconst char* const cipher_names[128] =\n{\n    null_str, // SSL_NULL_WITH_NULL_NULL                =  0\n    null_str, // SSL_RSA_WITH_NULL_MD5                  =  1\n    null_str, // SSL_RSA_WITH_NULL_SHA                  =  2\n    null_str, // SSL_RSA_EXPORT_WITH_RC4_40_MD5         =  3\n    \"RC4-MD5\",  // SSL_RSA_WITH_RC4_128_MD5               =  4\n    \"RC4-SHA\",  // SSL_RSA_WITH_RC4_128_SHA               =  5\n    null_str, // SSL_RSA_EXPORT_WITH_RC2_CBC_40_MD5     =  6\n    null_str, // SSL_RSA_WITH_IDEA_CBC_SHA              =  7\n    null_str, // SSL_RSA_EXPORT_WITH_DES40_CBC_SHA      =  8\n    \"DES-CBC-SHA\",  // SSL_RSA_WITH_DES_CBC_SHA               =  9\n    \"DES-CBC3-SHA\", // SSL_RSA_WITH_3DES_EDE_CBC_SHA          = 10\n\n    null_str, // SSL_DH_DSS_EXPORT_WITH_DES40_CBC_SHA   = 11\n    null_str, // SSL_DH_DSS_WITH_DES_CBC_SHA            = 12\n    null_str, // SSL_DH_DSS_WITH_3DES_EDE_CBC_SHA       = 13\n    null_str, // SSL_DH_RSA_EXPORT_WITH_DES40_CBC_SHA   = 14\n    null_str, // SSL_DH_RSA_WITH_DES_CBC_SHA            = 15\n    null_str, // SSL_DH_RSA_WITH_3DES_EDE_CBC_SHA       = 16\n    null_str, // SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA  = 17\n    \"EDH-DSS-DES-CBC-SHA\",  // SSL_DHE_DSS_WITH_DES_CBC_SHA           = 18\n    \"EDH-DSS-DES-CBC3-SHA\", // SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA      = 19\n    null_str, // SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA  = 20\n\n    \"EDH-RSA-DES-CBC-SHA\",  // SSL_DHE_RSA_WITH_DES_CBC_SHA           = 21\n    \"EDH-RSA-DES-CBC3-SHA\", // SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA      = 22\n    null_str, // SSL_DH_anon_EXPORT_WITH_RC4_40_MD5     = 23\n    null_str, // SSL_DH_anon_WITH_RC4_128_MD5           = 24\n    null_str, // SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA  = 25\n    null_str, // SSL_DH_anon_WITH_DES_CBC_SHA           = 26\n    null_str, // SSL_DH_anon_WITH_3DES_EDE_CBC_SHA      = 27\n    null_str, // SSL_FORTEZZA_KEA_WITH_NULL_SHA         = 28\n    null_str, // SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA = 29\n    null_str, // SSL_FORTEZZA_KEA_WITH_RC4_128_SHA      = 30\n\n    null_str, null_str, null_str, null_str, null_str, // 31 - 35\n    null_str, null_str, null_str, null_str, null_str, // 36 - 40\n    null_str, null_str, null_str, null_str, null_str, // 41 - 45\n    null_str, // 46\n\n    // TLS AES extensions\n    \"AES128-SHA\", // TLS_RSA_WITH_AES_128_CBC_SHA      = 47\n    null_str, // TLS_DH_DSS_WITH_AES_128_CBC_SHA   = 48\n    null_str, // TLS_DH_RSA_WITH_AES_128_CBC_SHA   = 49\n    \"DHE-DSS-AES128-SHA\", // TLS_DHE_DSS_WITH_AES_128_CBC_SHA  = 50\n    \"DHE-RSA-AES128-SHA\", // TLS_DHE_RSA_WITH_AES_128_CBC_SHA  = 51\n    null_str, // TLS_DH_anon_WITH_AES_128_CBC_SHA  = 52\n\n    \"AES256-SHA\", // TLS_RSA_WITH_AES_256_CBC_SHA      = 53\n    null_str, // TLS_DH_DSS_WITH_AES_256_CBC_SHA   = 54\n    null_str, // TLS_DH_RSA_WITH_AES_256_CBC_SHA   = 55\n    \"DHE-DSS-AES256-SHA\", // TLS_DHE_DSS_WITH_AES_256_CBC_SHA  = 56\n    \"DHE-RSA-AES256-SHA\", // TLS_DHE_RSA_WITH_AES_256_CBC_SHA  = 57\n    null_str, // TLS_DH_anon_WITH_AES_256_CBC_SHA  = 58\n    \n    null_str, // 59\n    null_str, // 60\n    null_str, null_str, null_str, null_str, null_str, // 61 - 65\n    null_str, null_str, null_str, null_str, null_str, // 66 - 70\n    null_str, null_str, null_str, null_str, null_str, // 71 - 75\n    null_str, null_str, null_str, null_str, null_str, // 76 - 80\n    null_str, null_str, null_str, null_str, null_str, // 81 - 85\n    null_str, null_str, null_str, null_str, null_str, // 86 - 90\n    null_str, null_str, null_str, null_str, null_str, // 91 - 95\n    null_str, null_str, null_str, null_str, null_str, // 96 - 100\n    null_str, null_str, null_str, null_str, null_str, // 101 - 105\n    null_str, null_str, null_str, null_str, null_str, // 106 - 110\n    null_str, null_str, null_str,                     // 111 - 113\n\n    \"DHE-DSS-DES-CBC3-RMD\", //  TLS_DHE_DSS_WITH_3DES_EDE_CBC_RMD160 = 114\n    \"DHE-DSS-AES128-RMD\",   //  TLS_DHE_DSS_WITH_AES_128_CBC_RMD160  = 115\n    \"DHE-DSS-AES256-RMD\",   //  TLS_DHE_DSS_WITH_AES_256_CBC_RMD160  = 116\n    null_str, // 117\n    null_str, // 118\n    \"DHE-RSA-DES-CBC3-RMD\", //  TLS_DHE_RSA_WITH_3DES_EDE_CBC_RMD160 = 119\n    \"DHE-RSA-AES128-RMD\",   //  TLS_DHE_RSA_WITH_AES_128_CBC_RMD160  = 120\n    \"DHE-RSA-AES256-RMD\",   //  TLS_DHE_RSA_WITH_AES_256_CBC_RMD160  = 121\n    null_str, // 122\n    null_str, // 123\n    \"DES-CBC3-RMD\", //  TLS_RSA_WITH_3DES_EDE_CBC_RMD160     = 124\n    \"AES128-RMD\",   //  TLS_RSA_WITH_AES_128_CBC_RMD160      = 125\n    \"AES256-RMD\",   //  TLS_RSA_WITH_AES_256_CBC_RMD160      = 126\n    null_str // 127\n};\n\n// fill with MD5 pad size since biggest required\nconst opaque PAD1[PAD_MD5] =  { 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,\n                                0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,\n                                0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,\n                                0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,\n                                0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36,\n                                0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36\n                              };\nconst opaque PAD2[PAD_MD5] =  { 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,\n                                0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,\n                                0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,\n                                0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,\n                                0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c,\n                                0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c, 0x5c\n                              };\n\nconst opaque client[SIZEOF_SENDER] = { 0x43, 0x4C, 0x4E, 0x54 };\nconst opaque server[SIZEOF_SENDER] = { 0x53, 0x52, 0x56, 0x52 };\n\nconst opaque tls_client[FINISHED_LABEL_SZ + 1] = \"client finished\";\nconst opaque tls_server[FINISHED_LABEL_SZ + 1] = \"server finished\";\n\nconst opaque master_label[MASTER_LABEL_SZ + 1] = \"master secret\";\nconst opaque key_label   [KEY_LABEL_SZ + 1]    = \"key expansion\";\n\n\n} // naemspace\n\n#if __GNUC__ == 2 && __GNUC_MINOR__ <= 96\n/*\n  gcc 2.96 bails out because of two declarations of byte: yaSSL::byte and\n  TaoCrypt::byte. TODO: define global types.hpp and move the declaration of\n  'byte' there.\n*/\nusing yaSSL::byte;\n#endif\n\n\n#endif // yaSSL_TYPES_HPP\n"
  },
  {
    "path": "ext/yassl/lib/dummy",
    "content": "// this is a dummy file\n"
  },
  {
    "path": "ext/yassl/src/buffer.cpp",
    "content": "/*\n   Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* yaSSL buffer header implements input/output buffers to simulate streaming\n * with SSL types and sockets\n */\n\n\n// First include (the generated) my_config.h, to get correct platform defines.\n#include \"router_config.h\"\n#include <string.h>             // memcpy\n#include \"runtime.hpp\"\n#include \"buffer.hpp\"\n#include \"yassl_types.hpp\"\n\nnamespace yaSSL {\n\n\n\n\n/* return 0 on check success, always true for NoCheck policy */\nint NoCheck::check(uint, uint) \n{\n    return 0;\n}\n\n/* return 0 on check success */\nint Check::check(uint i, uint max) \n{\n    if (i < max)\n        return 0;\n\n    return -1;\n}\n\n\n/* input_buffer operates like a smart c style array with a checking option, \n * meant to be read from through [] with AUTO index or read().\n * Should only write to at/near construction with assign() or raw (e.g., recv)\n * followed by add_size with the number of elements added by raw write.\n *\n * Not using vector because need checked []access, offset, and the ability to\n * write to the buffer bulk wise and have the correct size\n */\n\n\ninput_buffer::input_buffer() \n    : size_(0), current_(0), buffer_(0), end_(0), error_(0), zero_(0)\n{}\n\n\ninput_buffer::input_buffer(uint s) \n    : size_(0), current_(0), buffer_(NEW_YS byte[s]), end_(buffer_ + s),\n      error_(0), zero_(0)\n{}\n\n\n// with assign\ninput_buffer::input_buffer(uint s, const byte* t, uint len) \n    : size_(0), current_(0), buffer_(NEW_YS byte[s]), end_(buffer_ + s),\n      error_(0), zero_(0)\n{ \n    assign(t, len); \n}\n\n\ninput_buffer::~input_buffer() \n{ \n    ysArrayDelete(buffer_); \n}\n\n\n// users can pass defualt zero length buffer and then allocate\nvoid input_buffer::allocate(uint s) \n{ \n    if (error_ == 0) {\n        buffer_ = NEW_YS byte[s];\n        end_ = buffer_ + s;\n    }\n}\n\n\n// for passing to raw writing functions at beginning, then use add_size\nbyte* input_buffer::get_buffer() const \n{ \n    return buffer_; \n}\n\n\n// after a raw write user can set NEW_YS size\n// if you know the size before the write use assign()\nvoid input_buffer::add_size(uint i) \n{ \n    if (error_ == 0 && check(size_ + i-1, get_capacity()) == 0)\n        size_ += i;\n    else\n        error_ = -1;\n}\n\n\nuint input_buffer::get_capacity()  const \n{ \n    if (error_ == 0)\n        return end_ - buffer_;\n\n    return 0;\n}\n\n\nuint input_buffer::get_current()   const \n{ \n    if (error_ == 0)\n        return current_;\n\n    return 0;\n}\n\n\nuint input_buffer::get_size()      const \n{ \n    if (error_ == 0)\n        return size_;\n\n    return 0;\n}\n\n\nuint input_buffer::get_remaining() const \n{ \n    if (error_ == 0)\n        return size_ - current_;\n\n    return 0;\n}\n\n\nint input_buffer::get_error() const \n{ \n    return error_;\n}\n\n\nvoid input_buffer::set_error()\n{ \n    error_ = -1;\n}\n\n\nvoid input_buffer::set_current(uint i) \n{\n    if (error_ == 0 && i && check(i - 1, size_) == 0)\n        current_ = i;\n    else\n        error_ = -1;\n}\n\n\n// read only access through [], advance current\n// user passes in AUTO index for ease of use\nconst byte& input_buffer::operator[](uint i) \n{\n    if (error_ == 0 && check(current_, size_) == 0)\n        return buffer_[current_++];\n\n    error_ = -1;\n    return zero_;\n}\n\n\n// end of input test\nbool input_buffer::eof() \n{ \n    if (error_ != 0)\n        return true;\n\n    return current_ >= size_; \n}\n\n\n// peek ahead\nbyte input_buffer::peek()\n{\n    if (error_ == 0 && check(current_, size_) == 0)\n        return buffer_[current_];\n\n    error_ = -1;\n    return 0;\n}\n\n\n// write function, should use at/near construction\nvoid input_buffer::assign(const byte* t, uint s)\n{\n    if (t && error_ == 0 && check(current_, get_capacity()) == 0) {\n        add_size(s);\n        if (error_ == 0) {\n            memcpy(&buffer_[current_], t, s);\n            return;  // success\n        }\n    }\n\n    error_ = -1;\n}\n\n\n// use read to query input, adjusts current\nvoid input_buffer::read(byte* dst, uint length)\n{\n    if (dst && error_ == 0 && check(current_ + length - 1, size_) == 0) {\n        memcpy(dst, &buffer_[current_], length);\n        current_ += length;\n    } else {\n        error_ = -1;\n    }\n}\n\n\n\n/* output_buffer operates like a smart c style array with a checking option.\n * Meant to be written to through [] with AUTO index or write().\n * Size (current) counter increases when written to. Can be constructed with \n * zero length buffer but be sure to allocate before first use. \n * Don't use add write for a couple bytes, use [] instead, way less overhead.\n * \n * Not using vector because need checked []access and the ability to\n * write to the buffer bulk wise and retain correct size\n */\n\n\noutput_buffer::output_buffer() \n    : current_(0), buffer_(0), end_(0) \n{}\n\n\n// with allocate\noutput_buffer::output_buffer(uint s) \n    : current_(0), buffer_(NEW_YS byte[s]), end_(buffer_ + s) \n{}\n\n\n// with assign\noutput_buffer::output_buffer(uint s, const byte* t, uint len) \n    : current_(0), buffer_(NEW_YS byte[s]), end_(buffer_+ s) \n{ \n    write(t, len); \n}\n\n\noutput_buffer::~output_buffer() \n{ \n    ysArrayDelete(buffer_); \n}\n\n\nuint output_buffer::get_size() const \n{ \n    return current_; \n}\n\n\nuint output_buffer::get_capacity() const \n{ \n    return (uint) (end_ - buffer_); \n}\n\n\nvoid output_buffer::set_current(uint c) \n{ \n    check(c, get_capacity()); \n    current_ = c; \n}\n\n\n// users can pass defualt zero length buffer and then allocate\nvoid output_buffer::allocate(uint s) \n{ \n    buffer_ = NEW_YS byte[s]; end_ = buffer_ + s; \n}\n\n\n// for passing to reading functions when finished\nconst byte* output_buffer::get_buffer() const \n{ \n    return buffer_; \n}\n\n\n// allow write access through [], update current\n// user passes in AUTO as index for ease of use\nbyte& output_buffer::operator[](uint i) \n{\n    check(current_, get_capacity());\n    return buffer_[current_++];\n}\n\n\n// end of output test\nbool output_buffer::eof() \n{ \n    return current_ >= get_capacity(); \n}\n\n\nvoid output_buffer::write(const byte* t, uint s)\n{\n    check(current_ + s - 1, get_capacity()); \n    memcpy(&buffer_[current_], t, s);\n    current_ += s;\n}\n\n\n\n} // naemspace\n\n"
  },
  {
    "path": "ext/yassl/src/cert_wrapper.cpp",
    "content": "/*\n   Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/*  The certificate wrapper source implements certificate management functions\n *\n */\n\n#include \"runtime.hpp\"\n#include \"cert_wrapper.hpp\"\n#include \"yassl_int.hpp\"\n#include \"error.hpp\"\n\n#if defined(USE_CML_LIB)\n    #include \"cmapi_cpp.h\"\n#else\n    #include \"asn.hpp\"\n    #include \"file.hpp\"\n#endif // USE_CML_LIB\n\n\nnamespace yaSSL {\n\n\nx509::x509(uint sz) : length_(sz), buffer_(NEW_YS opaque[sz]) \n{\n}\n\n\nx509::~x509() \n{ \n    ysArrayDelete(buffer_); \n}\n\n\nx509::x509(const x509& that) : length_(that.length_),\n                               buffer_(NEW_YS opaque[length_])\n{\n    memcpy(buffer_, that.buffer_, length_);\n}\n\n\nvoid x509::Swap(x509& that)\n{\n    STL::swap(length_, that.length_);\n    STL::swap(buffer_, that.buffer_);\n}\n\n\nx509& x509::operator=(const x509& that)\n{\n    x509 temp(that);\n    Swap(temp);\n    return *this;\n}\n\n\nuint x509::get_length() const\n{ \n    return length_; \n}\n\n\nconst opaque* x509::get_buffer() const\n{ \n    return buffer_; \n}\n\n\nopaque* x509::use_buffer()\n{ \n    return buffer_; \n}\n\n\n//CertManager\nCertManager::CertManager()\n    : peerX509_(0), selfX509_(0), verifyPeer_(false), verifyNone_(false), failNoCert_(false),\n      sendVerify_(false), sendBlankCert_(false), verifyCallback_(0)\n{}\n\n\nCertManager::~CertManager()\n{\n    ysDelete(peerX509_);\n    ysDelete(selfX509_);\n\n    STL::for_each(signers_.begin(), signers_.end(), del_ptr_zero()) ;\n\n    STL::for_each(peerList_.begin(), peerList_.end(), del_ptr_zero()) ;\n\n    STL::for_each(list_.begin(), list_.end(), del_ptr_zero()) ;\n}\n\n\nbool CertManager::verifyPeer() const\n{\n    return verifyPeer_;\n}\n\n\nbool CertManager::verifyNone() const\n{\n    return verifyNone_;\n}\n\n\nbool CertManager::failNoCert() const\n{\n    return failNoCert_;\n}\n\n\nbool CertManager::sendVerify() const\n{\n    return sendVerify_;\n}\n\n\nvoid CertManager::setVerifyPeer()\n{\n    verifyPeer_ = true;\n}\n\n\nvoid CertManager::setVerifyNone()\n{\n    verifyNone_ = true;\n}\n\nbool CertManager::sendBlankCert() const\n{\n  return sendBlankCert_;\n}\n\n\nvoid CertManager::setFailNoCert()\n{\n    failNoCert_ = true;\n}\n\n\nvoid CertManager::setSendVerify()\n{\n    sendVerify_ = true;\n}\n\nvoid CertManager::setSendBlankCert()\n{\n  sendBlankCert_ = true;\n}\n\n\nvoid CertManager::setVerifyCallback(VerifyCallback vc)\n{\n    verifyCallback_ = vc;\n}\n\n\nvoid CertManager::AddPeerCert(x509* x)\n{ \n    peerList_.push_back(x);  // take ownership\n}\n\n\nvoid CertManager::CopySelfCert(const x509* x)\n{\n    if (x)\n        list_.push_back(NEW_YS x509(*x));\n}\n\n\n// add to signers\nint CertManager::CopyCaCert(const x509* x)\n{\n    TaoCrypt::Source source(x->get_buffer(), x->get_length());\n    TaoCrypt::CertDecoder cert(source, true, &signers_, verifyNone_,\n                               TaoCrypt::CertDecoder::CA);\n\n    if (!cert.GetError().What()) {\n        const TaoCrypt::PublicKey& key = cert.GetPublicKey();\n        signers_.push_back(NEW_YS TaoCrypt::Signer(key.GetKey(), key.size(),\n                                        cert.GetCommonName(), cert.GetHash()));\n    }\n    // just don't add, not an error return cert.GetError().What();\n    return 0;\n}\n\n\nconst x509* CertManager::get_cert() const\n{ \n    return list_.front();\n}\n\n\nconst opaque* CertManager::get_peerKey() const\n{ \n    return peerPublicKey_.get_buffer();\n}\n\n\nX509* CertManager::get_peerX509() const\n{\n    return peerX509_;\n}\n\n\nX509* CertManager::get_selfX509() const\n{\n    return selfX509_;\n}\n\n\nSignatureAlgorithm CertManager::get_peerKeyType() const\n{\n    return peerKeyType_;\n}\n\n\nSignatureAlgorithm CertManager::get_keyType() const\n{\n    return keyType_;\n}\n\n\nuint CertManager::get_peerKeyLength() const\n{ \n    return peerPublicKey_.get_size();\n}\n\n\nconst opaque* CertManager::get_privateKey() const\n{ \n    return privateKey_.get_buffer();\n}\n\n\nuint CertManager::get_privateKeyLength() const\n{ \n    return privateKey_.get_size();\n}\n\n\n// Validate the peer's certificate list, from root to peer (last to first)\nint CertManager::Validate()\n{\n    CertList::reverse_iterator last = peerList_.rbegin();\n    size_t count = peerList_.size();\n\n    while ( count > 1 ) {\n        TaoCrypt::Source source((*last)->get_buffer(), (*last)->get_length());\n        TaoCrypt::CertDecoder cert(source, true, &signers_, verifyNone_);\n\n        if (int err = cert.GetError().What())\n            return err;\n\n        const TaoCrypt::PublicKey& key = cert.GetPublicKey();\n        signers_.push_back(NEW_YS TaoCrypt::Signer(key.GetKey(), key.size(),\n                                        cert.GetCommonName(), cert.GetHash()));\n        ++last;\n        --count;\n    }\n\n    if (count) {\n        // peer's is at the front\n        TaoCrypt::Source source((*last)->get_buffer(), (*last)->get_length());\n        TaoCrypt::CertDecoder cert(source, true, &signers_, verifyNone_);\n\n        int err = cert.GetError().What();\n        if ( err && err != TaoCrypt::SIG_OTHER_E)\n            return err;\n\n        uint sz = cert.GetPublicKey().size();\n        peerPublicKey_.allocate(sz);\n        peerPublicKey_.assign(cert.GetPublicKey().GetKey(), sz);\n\n        if (cert.GetKeyType() == TaoCrypt::RSAk)\n            peerKeyType_ = rsa_sa_algo;\n        else\n            peerKeyType_ = dsa_sa_algo;\n\n        size_t iSz = strlen(cert.GetIssuer()) + 1;\n        size_t sSz = strlen(cert.GetCommonName()) + 1;\n        ASN1_STRING beforeDate, afterDate;\n        beforeDate.data= (unsigned char *) cert.GetBeforeDate();\n        beforeDate.type= cert.GetBeforeDateType();\n        beforeDate.length= strlen((char *) beforeDate.data) + 1;\n        afterDate.data= (unsigned char *) cert.GetAfterDate();\n        afterDate.type= cert.GetAfterDateType();\n        afterDate.length= strlen((char *) afterDate.data) + 1;\n        peerX509_ = NEW_YS X509(cert.GetIssuer(), iSz, cert.GetCommonName(),\n                                sSz, &beforeDate, &afterDate);\n\n        if (err == TaoCrypt::SIG_OTHER_E && verifyCallback_) {\n            X509_STORE_CTX store;\n            store.error = err;\n            store.error_depth = static_cast<int>(count) - 1;\n            store.current_cert = peerX509_;\n\n            int ok = verifyCallback_(0, &store);\n            if (ok) return 0;\n        }\n\n        if (err == TaoCrypt::SIG_OTHER_E) return err;\n    }\n    return 0;\n}\n\n\n// Set the private key\nint CertManager::SetPrivateKey(const x509& key)\n{\n    privateKey_.allocate(key.get_length());\n    privateKey_.assign(key.get_buffer(), key.get_length());\n\n    // set key type\n    if (x509* cert = list_.front()) {\n        TaoCrypt::Source source(cert->get_buffer(), cert->get_length());\n        TaoCrypt::CertDecoder cd(source, false);\n        cd.DecodeToKey();\n        if (int err = cd.GetError().What())\n            return err;\n        if (cd.GetKeyType() == TaoCrypt::RSAk)\n            keyType_ = rsa_sa_algo;\n        else\n            keyType_ = dsa_sa_algo;\n\n        size_t iSz = strlen(cd.GetIssuer()) + 1;\n        size_t sSz = strlen(cd.GetCommonName()) + 1;\n        ASN1_STRING beforeDate, afterDate;\n        beforeDate.data= (unsigned char *) cd.GetBeforeDate();\n        beforeDate.type= cd.GetBeforeDateType();\n        beforeDate.length= strlen((char *) beforeDate.data) + 1;\n        afterDate.data= (unsigned char *) cd.GetAfterDate();\n        afterDate.type= cd.GetAfterDateType();\n        afterDate.length= strlen((char *) afterDate.data) + 1;\n        selfX509_ = NEW_YS X509(cd.GetIssuer(), iSz, cd.GetCommonName(),\n                                sSz, &beforeDate, &afterDate);\n    }\n    return 0;\n}\n\n\n// Store OpenSSL type peer's cert\nvoid CertManager::setPeerX509(X509* x)\n{\n    if (x == 0) return;\n\n    X509_NAME* issuer   = x->GetIssuer();\n    X509_NAME* subject  = x->GetSubject();\n    ASN1_STRING* before = x->GetBefore();\n    ASN1_STRING* after  = x->GetAfter();\n\n    peerX509_ = NEW_YS X509(issuer->GetName(), issuer->GetLength(),\n        subject->GetName(), subject->GetLength(), before, after);\n}\n\n\n#if defined(USE_CML_LIB)\n\n// Get the peer's certificate, extract and save public key\nvoid CertManager::SetPeerKey()\n{\n    // first cert is the peer's\n    x509* main = peerList_.front();\n\n    Bytes_struct cert;\n    cert.num  = main->get_length();\n    cert.data = main->set_buffer();\n\n    CML::Certificate cm(cert);\n    const CML::ASN::Cert& raw = cm.base();\n    CTIL::CSM_Buffer key = raw.pubKeyInfo.key;\n\n    uint sz;\n    opaque* key_buffer = reinterpret_cast<opaque*>(key.Get(sz));\n    peerPublicKey_.allocate(sz);\n    peerPublicKey_.assign(key_buffer, sz);\n}\n\n\n#endif // USE_CML_LIB\n\n\n\n} // namespace\n"
  },
  {
    "path": "ext/yassl/src/crypto_wrapper.cpp",
    "content": "/* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; if not, write to the Free Software\n   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */\n\n/*  The crypto wrapper source implements the policies for the cipher\n *  components used by SSL.\n *\n *  The implementation relies on a specfic library, taoCrypt.\n */\n\n#if !defined(USE_CRYPTOPP_LIB)\n\n#include \"runtime.hpp\"\n#include \"crypto_wrapper.hpp\"\n#include \"cert_wrapper.hpp\"\n\n#include \"md5.hpp\"\n#include \"sha.hpp\"\n#include \"ripemd.hpp\"\n#include \"hmac.hpp\"\n#include \"modes.hpp\"\n#include \"des.hpp\"\n#include \"arc4.hpp\"\n#include \"aes.hpp\"\n#include \"rsa.hpp\"\n#include \"dsa.hpp\"\n#include \"dh.hpp\"\n#include \"random.hpp\"\n#include \"file.hpp\"\n#include \"coding.hpp\"\n\n\nnamespace yaSSL {\n\n\n// MD5 Implementation\nstruct MD5::MD5Impl {\n    TaoCrypt::MD5 md5_;\n    MD5Impl() {}\n    explicit MD5Impl(const TaoCrypt::MD5& md5) : md5_(md5) {}\n};\n\n\nMD5::MD5() : pimpl_(NEW_YS MD5Impl) {}\n\n\nMD5::~MD5() { ysDelete(pimpl_); }\n\n\nMD5::MD5(const MD5& that) : Digest(), pimpl_(NEW_YS \n                                             MD5Impl(that.pimpl_->md5_)) {}\n\n\nMD5& MD5::operator=(const MD5& that)\n{\n    pimpl_->md5_ = that.pimpl_->md5_;\n    return *this;\n}\n\n\nuint MD5::get_digestSize() const\n{\n    return MD5_LEN;\n}\n\n\nuint MD5::get_padSize() const\n{\n    return PAD_MD5;\n}\n\n\n// Fill out with MD5 digest from in that is sz bytes, out must be >= digest sz\nvoid MD5::get_digest(byte* out, const byte* in, unsigned int sz)\n{\n    pimpl_->md5_.Update(in, sz);\n    pimpl_->md5_.Final(out);\n}\n\n// Fill out with MD5 digest from previous updates\nvoid MD5::get_digest(byte* out)\n{\n    pimpl_->md5_.Final(out);\n}\n\n\n// Update the current digest\nvoid MD5::update(const byte* in, unsigned int sz)\n{\n    pimpl_->md5_.Update(in, sz);\n}\n\n\n// SHA Implementation\nstruct SHA::SHAImpl {\n    TaoCrypt::SHA sha_;\n    SHAImpl() {}\n    explicit SHAImpl(const TaoCrypt::SHA& sha) : sha_(sha) {}\n};\n\n\nSHA::SHA() : pimpl_(NEW_YS SHAImpl) {}\n\n\nSHA::~SHA() { ysDelete(pimpl_); }\n\n\nSHA::SHA(const SHA& that) : Digest(), pimpl_(NEW_YS SHAImpl(that.pimpl_->sha_)) {}\n\nSHA& SHA::operator=(const SHA& that)\n{\n    pimpl_->sha_ = that.pimpl_->sha_;\n    return *this;\n}\n\n\nuint SHA::get_digestSize() const\n{\n    return SHA_LEN;\n}\n\n\nuint SHA::get_padSize() const\n{\n    return PAD_SHA;\n}\n\n\n// Fill out with SHA digest from in that is sz bytes, out must be >= digest sz\nvoid SHA::get_digest(byte* out, const byte* in, unsigned int sz)\n{\n    pimpl_->sha_.Update(in, sz);\n    pimpl_->sha_.Final(out);\n}\n\n\n// Fill out with SHA digest from previous updates\nvoid SHA::get_digest(byte* out)\n{\n    pimpl_->sha_.Final(out);\n}\n\n\n// Update the current digest\nvoid SHA::update(const byte* in, unsigned int sz)\n{\n    pimpl_->sha_.Update(in, sz);\n}\n\n\n// RMD-160 Implementation\nstruct RMD::RMDImpl {\n    TaoCrypt::RIPEMD160 rmd_;\n    RMDImpl() {}\n    explicit RMDImpl(const TaoCrypt::RIPEMD160& rmd) : rmd_(rmd) {}\n};\n\n\nRMD::RMD() : pimpl_(NEW_YS RMDImpl) {}\n\n\nRMD::~RMD() { ysDelete(pimpl_); }\n\n\nRMD::RMD(const RMD& that) : Digest(), pimpl_(NEW_YS RMDImpl(that.pimpl_->rmd_)) {}\n\nRMD& RMD::operator=(const RMD& that)\n{\n    pimpl_->rmd_ = that.pimpl_->rmd_;\n    return *this;\n}\n\n\nuint RMD::get_digestSize() const\n{\n    return RMD_LEN;\n}\n\n\nuint RMD::get_padSize() const\n{\n    return PAD_RMD;\n}\n\n\n// Fill out with RMD digest from in that is sz bytes, out must be >= digest sz\nvoid RMD::get_digest(byte* out, const byte* in, unsigned int sz)\n{\n    pimpl_->rmd_.Update(in, sz);\n    pimpl_->rmd_.Final(out);\n}\n\n\n// Fill out with RMD digest from previous updates\nvoid RMD::get_digest(byte* out)\n{\n    pimpl_->rmd_.Final(out);\n}\n\n\n// Update the current digest\nvoid RMD::update(const byte* in, unsigned int sz)\n{\n    pimpl_->rmd_.Update(in, sz);\n}\n\n\n// HMAC_MD5 Implementation\nstruct HMAC_MD5::HMAC_MD5Impl {\n    TaoCrypt::HMAC<TaoCrypt::MD5> mac_;\n    HMAC_MD5Impl() {}\n};\n\n\nHMAC_MD5::HMAC_MD5(const byte* secret, unsigned int len) \n    : pimpl_(NEW_YS HMAC_MD5Impl) \n{\n    pimpl_->mac_.SetKey(secret, len);\n}\n\n\nHMAC_MD5::~HMAC_MD5() { ysDelete(pimpl_); }\n\n\nuint HMAC_MD5::get_digestSize() const\n{\n    return MD5_LEN;\n}\n\n\nuint HMAC_MD5::get_padSize() const\n{\n    return PAD_MD5;\n}\n\n\n// Fill out with MD5 digest from in that is sz bytes, out must be >= digest sz\nvoid HMAC_MD5::get_digest(byte* out, const byte* in, unsigned int sz)\n{\n    pimpl_->mac_.Update(in, sz);\n    pimpl_->mac_.Final(out);\n}\n\n// Fill out with MD5 digest from previous updates\nvoid HMAC_MD5::get_digest(byte* out)\n{\n    pimpl_->mac_.Final(out);\n}\n\n\n// Update the current digest\nvoid HMAC_MD5::update(const byte* in, unsigned int sz)\n{\n    pimpl_->mac_.Update(in, sz);\n}\n\n\n// HMAC_SHA Implementation\nstruct HMAC_SHA::HMAC_SHAImpl {\n    TaoCrypt::HMAC<TaoCrypt::SHA> mac_;\n    HMAC_SHAImpl() {}\n};\n\n\nHMAC_SHA::HMAC_SHA(const byte* secret, unsigned int len) \n    : pimpl_(NEW_YS HMAC_SHAImpl) \n{\n    pimpl_->mac_.SetKey(secret, len);\n}\n\n\nHMAC_SHA::~HMAC_SHA() { ysDelete(pimpl_); }\n\n\nuint HMAC_SHA::get_digestSize() const\n{\n    return SHA_LEN;\n}\n\n\nuint HMAC_SHA::get_padSize() const\n{\n    return PAD_SHA;\n}\n\n\n// Fill out with SHA digest from in that is sz bytes, out must be >= digest sz\nvoid HMAC_SHA::get_digest(byte* out, const byte* in, unsigned int sz)\n{\n    pimpl_->mac_.Update(in, sz);\n    pimpl_->mac_.Final(out);\n}\n\n// Fill out with SHA digest from previous updates\nvoid HMAC_SHA::get_digest(byte* out)\n{\n    pimpl_->mac_.Final(out);\n}\n\n\n// Update the current digest\nvoid HMAC_SHA::update(const byte* in, unsigned int sz)\n{\n    pimpl_->mac_.Update(in, sz);\n}\n\n\n\n// HMAC_RMD Implementation\nstruct HMAC_RMD::HMAC_RMDImpl {\n    TaoCrypt::HMAC<TaoCrypt::RIPEMD160> mac_;\n    HMAC_RMDImpl() {}\n};\n\n\nHMAC_RMD::HMAC_RMD(const byte* secret, unsigned int len) \n    : pimpl_(NEW_YS HMAC_RMDImpl) \n{\n    pimpl_->mac_.SetKey(secret, len);\n}\n\n\nHMAC_RMD::~HMAC_RMD() { ysDelete(pimpl_); }\n\n\nuint HMAC_RMD::get_digestSize() const\n{\n    return RMD_LEN;\n}\n\n\nuint HMAC_RMD::get_padSize() const\n{\n    return PAD_RMD;\n}\n\n\n// Fill out with RMD digest from in that is sz bytes, out must be >= digest sz\nvoid HMAC_RMD::get_digest(byte* out, const byte* in, unsigned int sz)\n{\n    pimpl_->mac_.Update(in, sz);\n    pimpl_->mac_.Final(out);\n}\n\n// Fill out with RMD digest from previous updates\nvoid HMAC_RMD::get_digest(byte* out)\n{\n    pimpl_->mac_.Final(out);\n}\n\n\n// Update the current digest\nvoid HMAC_RMD::update(const byte* in, unsigned int sz)\n{\n    pimpl_->mac_.Update(in, sz);\n}\n\n\nstruct DES::DESImpl {\n    TaoCrypt::DES_CBC_Encryption encryption;\n    TaoCrypt::DES_CBC_Decryption decryption;\n};\n\n\nDES::DES() : pimpl_(NEW_YS DESImpl) {}\n\nDES::~DES() { ysDelete(pimpl_); }\n\n\nvoid DES::set_encryptKey(const byte* k, const byte* iv)\n{\n    pimpl_->encryption.SetKey(k, DES_KEY_SZ, iv);\n}\n\n\nvoid DES::set_decryptKey(const byte* k, const byte* iv)\n{\n    pimpl_->decryption.SetKey(k, DES_KEY_SZ, iv);\n}\n\n// DES encrypt plain of length sz into cipher\nvoid DES::encrypt(byte* cipher, const byte* plain, unsigned int sz)\n{\n    pimpl_->encryption.Process(cipher, plain, sz);\n}\n\n\n// DES decrypt cipher of length sz into plain\nvoid DES::decrypt(byte* plain, const byte* cipher, unsigned int sz)\n{\n    pimpl_->decryption.Process(plain, cipher, sz);\n}\n\n\nstruct DES_EDE::DES_EDEImpl {\n    TaoCrypt::DES_EDE3_CBC_Encryption encryption;\n    TaoCrypt::DES_EDE3_CBC_Decryption decryption;\n};\n\n\nDES_EDE::DES_EDE() : pimpl_(NEW_YS DES_EDEImpl) {}\n\nDES_EDE::~DES_EDE() { ysDelete(pimpl_); }\n\n\nvoid DES_EDE::set_encryptKey(const byte* k, const byte* iv)\n{\n    pimpl_->encryption.SetKey(k, DES_EDE_KEY_SZ, iv);\n}\n\n\nvoid DES_EDE::set_decryptKey(const byte* k, const byte* iv)\n{\n    pimpl_->decryption.SetKey(k, DES_EDE_KEY_SZ, iv);\n}\n\n\n// 3DES encrypt plain of length sz into cipher\nvoid DES_EDE::encrypt(byte* cipher, const byte* plain, unsigned int sz)\n{\n    pimpl_->encryption.Process(cipher, plain, sz);\n}\n\n\n// 3DES decrypt cipher of length sz into plain\nvoid DES_EDE::decrypt(byte* plain, const byte* cipher, unsigned int sz)\n{\n    pimpl_->decryption.Process(plain, cipher, sz);\n}\n\n\n// Implementation of alledged RC4\nstruct RC4::RC4Impl {\n    TaoCrypt::ARC4::Encryption encryption;\n    TaoCrypt::ARC4::Decryption decryption;\n};\n\n\nRC4::RC4() : pimpl_(NEW_YS RC4Impl) {}\n\nRC4::~RC4() { ysDelete(pimpl_); }\n\n\nvoid RC4::set_encryptKey(const byte* k, const byte*)\n{\n    pimpl_->encryption.SetKey(k, RC4_KEY_SZ);\n}\n\n\nvoid RC4::set_decryptKey(const byte* k, const byte*)\n{\n    pimpl_->decryption.SetKey(k, RC4_KEY_SZ);\n}\n\n\n// RC4 encrypt plain of length sz into cipher\nvoid RC4::encrypt(byte* cipher, const byte* plain, unsigned int sz)\n{\n    pimpl_->encryption.Process(cipher, plain, sz);\n}\n\n\n// RC4 decrypt cipher of length sz into plain\nvoid RC4::decrypt(byte* plain, const byte* cipher, unsigned int sz)\n{\n    pimpl_->decryption.Process(plain, cipher, sz);\n}\n\n\n\n// Implementation of AES\nstruct AES::AESImpl {\n    TaoCrypt::AES_CBC_Encryption encryption;\n    TaoCrypt::AES_CBC_Decryption decryption;\n    unsigned int keySz_;\n\n    AESImpl(unsigned int ks) : keySz_(ks) {}\n};\n\n\nAES::AES(unsigned int ks) : pimpl_(NEW_YS AESImpl(ks)) {}\n\nAES::~AES() { ysDelete(pimpl_); }\n\n\nint AES::get_keySize() const\n{\n    return pimpl_->keySz_;\n}\n\n\nvoid AES::set_encryptKey(const byte* k, const byte* iv)\n{\n    pimpl_->encryption.SetKey(k, pimpl_->keySz_, iv);\n}\n\n\nvoid AES::set_decryptKey(const byte* k, const byte* iv)\n{\n    pimpl_->decryption.SetKey(k, pimpl_->keySz_, iv);\n}\n\n\n// AES encrypt plain of length sz into cipher\nvoid AES::encrypt(byte* cipher, const byte* plain, unsigned int sz)\n{\n    pimpl_->encryption.Process(cipher, plain, sz);\n}\n\n\n// AES decrypt cipher of length sz into plain\nvoid AES::decrypt(byte* plain, const byte* cipher, unsigned int sz)\n{\n    pimpl_->decryption.Process(plain, cipher, sz);\n}\n\n\nstruct RandomPool::RandomImpl {\n    TaoCrypt::RandomNumberGenerator RNG_;\n};\n\nRandomPool::RandomPool() : pimpl_(NEW_YS RandomImpl) {}\n\nRandomPool::~RandomPool() { ysDelete(pimpl_); }\n\nint RandomPool::GetError() const\n{\n    return pimpl_->RNG_.GetError(); \n}\n\nvoid RandomPool::Fill(opaque* dst, uint sz) const\n{\n    pimpl_->RNG_.GenerateBlock(dst, sz);\n}\n\n\n// Implementation of DSS Authentication\nstruct DSS::DSSImpl {\n    void SetPublic (const byte*, unsigned int);\n    void SetPrivate(const byte*, unsigned int);\n    TaoCrypt::DSA_PublicKey publicKey_;\n    TaoCrypt::DSA_PrivateKey privateKey_;\n};\n\n\n// Decode and store the public key\nvoid DSS::DSSImpl::SetPublic(const byte* key, unsigned int sz)\n{\n    TaoCrypt::Source source(key, sz);\n    publicKey_.Initialize(source);\n}\n\n\n// Decode and store the public key\nvoid DSS::DSSImpl::SetPrivate(const byte* key, unsigned int sz)\n{\n    TaoCrypt::Source source(key, sz);\n    privateKey_.Initialize(source);\n    publicKey_ = TaoCrypt::DSA_PublicKey(privateKey_);\n\n}\n\n\n// Set public or private key\nDSS::DSS(const byte* key, unsigned int sz, bool publicKey) \n    : pimpl_(NEW_YS DSSImpl)\n{\n    if (publicKey) \n        pimpl_->SetPublic(key, sz);\n    else\n        pimpl_->SetPrivate(key, sz);\n}\n\n\nDSS::~DSS()\n{\n    ysDelete(pimpl_);\n}\n\n\nuint DSS::get_signatureLength() const\n{\n    return pimpl_->publicKey_.SignatureLength();\n}\n\n\n// DSS Sign message of length sz into sig\nvoid DSS::sign(byte* sig,  const byte* sha_digest, unsigned int /* shaSz */,\n               const RandomPool& random)\n{\n    using namespace TaoCrypt;\n\n    DSA_Signer signer(pimpl_->privateKey_);\n    signer.Sign(sha_digest, sig, random.pimpl_->RNG_);\n}\n\n\n// DSS Verify message of length sz against sig, is it correct?\nbool DSS::verify(const byte* sha_digest, unsigned int /* shaSz */,\n                 const byte* sig, unsigned int /* sigSz */)\n{\n    using namespace TaoCrypt;\n\n    DSA_Verifier ver(pimpl_->publicKey_);\n    return ver.Verify(sha_digest, sig);\n}\n\n\n// Implementation of RSA key interface\nstruct RSA::RSAImpl {\n    void SetPublic (const byte*, unsigned int);\n    void SetPrivate(const byte*, unsigned int);\n    TaoCrypt::RSA_PublicKey publicKey_;\n    TaoCrypt::RSA_PrivateKey privateKey_;\n};\n\n\n// Decode and store the public key\nvoid RSA::RSAImpl::SetPublic(const byte* key, unsigned int sz)\n{\n    TaoCrypt::Source source(key, sz);\n    publicKey_.Initialize(source);\n}\n\n\n// Decode and store the private key\nvoid RSA::RSAImpl::SetPrivate(const byte* key, unsigned int sz)\n{\n    TaoCrypt::Source source(key, sz);\n    privateKey_.Initialize(source);\n    publicKey_ = TaoCrypt::RSA_PublicKey(privateKey_);\n}\n\n\n// Set public or private key\nRSA::RSA(const byte* key, unsigned int sz, bool publicKey) \n    : pimpl_(NEW_YS RSAImpl)\n{\n    if (publicKey) \n        pimpl_->SetPublic(key, sz);\n    else\n        pimpl_->SetPrivate(key, sz);\n}\n\nRSA::~RSA()\n{\n    ysDelete(pimpl_);\n}\n\n\n// get cipher text length, varies on key size\nunsigned int RSA::get_cipherLength() const\n{\n    return pimpl_->publicKey_.FixedCiphertextLength();\n}\n\n\n// get signautre length, varies on key size\nunsigned int RSA::get_signatureLength() const\n{\n    return get_cipherLength();\n}\n\n\n// RSA Sign message of length sz into sig\nvoid RSA::sign(byte* sig,  const byte* message, unsigned int sz,\n               const RandomPool& random)\n{\n    TaoCrypt::RSAES_Decryptor dec(pimpl_->privateKey_);\n    dec.SSL_Sign(message, sz, sig, random.pimpl_->RNG_);\n}\n\n\n// RSA Verify message of length sz against sig\nbool RSA::verify(const byte* message, unsigned int sz, const byte* sig,\n                 unsigned int)\n{\n    TaoCrypt::RSAES_Encryptor enc(pimpl_->publicKey_);\n    return enc.SSL_Verify(message, sz, sig);\n}\n\n\n// RSA public encrypt plain of length sz into cipher\nvoid RSA::encrypt(byte* cipher, const byte* plain, unsigned int sz,\n                  const RandomPool& random)\n{\n  \n    TaoCrypt::RSAES_Encryptor enc(pimpl_->publicKey_);\n    enc.Encrypt(plain, sz, cipher, random.pimpl_->RNG_);\n}\n\n\n// RSA private decrypt cipher of length sz into plain\nvoid RSA::decrypt(byte* plain, const byte* cipher, unsigned int sz,\n                  const RandomPool& random)\n{\n    TaoCrypt::RSAES_Decryptor dec(pimpl_->privateKey_);\n    dec.Decrypt(cipher, sz, plain, random.pimpl_->RNG_);\n}\n\n\nstruct Integer::IntegerImpl {\n    TaoCrypt::Integer int_;\n\n    IntegerImpl() {}\n    explicit IntegerImpl(const TaoCrypt::Integer& i) : int_(i) {}\n};\n\nInteger::Integer() : pimpl_(NEW_YS IntegerImpl) {}\n\nInteger::~Integer() { ysDelete(pimpl_); }\n\n\n\nInteger::Integer(const Integer& other) : pimpl_(NEW_YS \n                                               IntegerImpl(other.pimpl_->int_))\n{}\n\n\nInteger& Integer::operator=(const Integer& that)\n{\n    pimpl_->int_ = that.pimpl_->int_;\n\n    return *this;\n}\n\n\nvoid Integer::assign(const byte* num, unsigned int sz)\n{\n    pimpl_->int_ = TaoCrypt::Integer(num, sz);\n}\n\n\nstruct DiffieHellman::DHImpl {\n    TaoCrypt::DH                     dh_;\n    TaoCrypt::RandomNumberGenerator& ranPool_;\n    byte* publicKey_;\n    byte* privateKey_;\n    byte* agreedKey_;\n\n    DHImpl(TaoCrypt::RandomNumberGenerator& r) : ranPool_(r), publicKey_(0),\n                                               privateKey_(0), agreedKey_(0) {}\n    ~DHImpl() \n    {   \n        ysArrayDelete(agreedKey_); \n        ysArrayDelete(privateKey_); \n        ysArrayDelete(publicKey_);\n    }\n\n    DHImpl(const DHImpl& that) : dh_(that.dh_), ranPool_(that.ranPool_),\n                                 publicKey_(0), privateKey_(0), agreedKey_(0)\n    {\n        uint length = dh_.GetByteLength();\n        AllocKeys(length, length, length);\n    }\n\n    void AllocKeys(unsigned int pubSz, unsigned int privSz, unsigned int agrSz)\n    {\n        publicKey_  = NEW_YS byte[pubSz];\n        privateKey_ = NEW_YS byte[privSz];\n        agreedKey_  = NEW_YS byte[agrSz];\n    }\n};\n\n\n\n/*\n// server Side DH, server's view\nDiffieHellman::DiffieHellman(const char* file, const RandomPool& random)\n    : pimpl_(NEW_YS DHImpl(random.pimpl_->RNG_))\n{\n    using namespace TaoCrypt;\n    Source source;\n    FileSource(file, source);\n    if (source.size() == 0)\n        return; // TODO add error state, and force check\n    HexDecoder hd(source);\n\n    pimpl_->dh_.Initialize(source);\n\n    uint length = pimpl_->dh_.GetByteLength();\n\n    pimpl_->AllocKeys(length, length, length);\n    pimpl_->dh_.GenerateKeyPair(pimpl_->ranPool_, pimpl_->privateKey_,\n                                                  pimpl_->publicKey_);\n}\n*/\n\n\n// server Side DH, client's view\nDiffieHellman::DiffieHellman(const byte* p, unsigned int pSz, const byte* g,\n                             unsigned int gSz, const byte* pub,\n                             unsigned int pubSz, const RandomPool& random)\n    : pimpl_(NEW_YS DHImpl(random.pimpl_->RNG_))\n{\n    using TaoCrypt::Integer;\n\n    pimpl_->dh_.Initialize(Integer(p, pSz).Ref(), Integer(g, gSz).Ref());\n    pimpl_->publicKey_ = NEW_YS opaque[pubSz];\n    memcpy(pimpl_->publicKey_, pub, pubSz);\n}\n\n\n// Server Side DH, server's view\nDiffieHellman::DiffieHellman(const Integer& p, const Integer& g,\n                             const RandomPool& random)\n: pimpl_(NEW_YS DHImpl(random.pimpl_->RNG_))\n{\n    using TaoCrypt::Integer;\n\n    pimpl_->dh_.Initialize(p.pimpl_->int_, g.pimpl_->int_);\n\n    uint length = pimpl_->dh_.GetByteLength();\n\n    pimpl_->AllocKeys(length, length, length);\n    pimpl_->dh_.GenerateKeyPair(pimpl_->ranPool_, pimpl_->privateKey_,\n                                                  pimpl_->publicKey_);\n}\n\nDiffieHellman::~DiffieHellman() { ysDelete(pimpl_); }\n\n\n// Client side and view, use server that for p and g\nDiffieHellman::DiffieHellman(const DiffieHellman& that) \n    : pimpl_(NEW_YS DHImpl(*that.pimpl_))\n{   \n    pimpl_->dh_.GenerateKeyPair(pimpl_->ranPool_, pimpl_->privateKey_,\n                                                  pimpl_->publicKey_);\n}\n\n\nDiffieHellman& DiffieHellman::operator=(const DiffieHellman& that)\n{\n    pimpl_->dh_ = that.pimpl_->dh_;\n    pimpl_->dh_.GenerateKeyPair(pimpl_->ranPool_, pimpl_->privateKey_,\n                                                  pimpl_->publicKey_);\n    return *this;\n}\n\n\nvoid DiffieHellman::makeAgreement(const byte* other, unsigned int otherSz)\n{\n    pimpl_->dh_.Agree(pimpl_->agreedKey_, pimpl_->privateKey_, other, otherSz); \n}\n\n\nuint DiffieHellman::get_agreedKeyLength() const\n{\n    return pimpl_->dh_.GetByteLength();\n}\n\n\nconst byte* DiffieHellman::get_agreedKey() const\n{\n    return pimpl_->agreedKey_;\n}\n\n\nconst byte* DiffieHellman::get_publicKey() const\n{\n    return pimpl_->publicKey_;\n}\n\n\nvoid DiffieHellman::set_sizes(int& pSz, int& gSz, int& pubSz) const\n{\n    using TaoCrypt::Integer;\n    Integer p = pimpl_->dh_.GetP();\n    Integer g = pimpl_->dh_.GetG();\n\n    pSz   = p.ByteCount();\n    gSz   = g.ByteCount();\n    pubSz = pimpl_->dh_.GetByteLength();\n}\n\n\nvoid DiffieHellman::get_parms(byte* bp, byte* bg, byte* bpub) const\n{\n    using TaoCrypt::Integer;\n    Integer p = pimpl_->dh_.GetP();\n    Integer g = pimpl_->dh_.GetG();\n\n    p.Encode(bp, p.ByteCount());\n    g.Encode(bg, g.ByteCount());\n    memcpy(bpub, pimpl_->publicKey_, pimpl_->dh_.GetByteLength());\n}\n\n\n// convert PEM file to DER x509 type\nx509* PemToDer(FILE* file, CertType type, EncryptedInfo* info)\n{\n    using namespace TaoCrypt;\n\n    char header[80];\n    char footer[80];\n\n    if (type == Cert) {\n        strncpy(header, \"-----BEGIN CERTIFICATE-----\", sizeof(header));\n        strncpy(footer, \"-----END CERTIFICATE-----\", sizeof(footer));\n    } else {\n        strncpy(header, \"-----BEGIN RSA PRIVATE KEY-----\", sizeof(header));\n        strncpy(footer, \"-----END RSA PRIVATE KEY-----\", sizeof(header));\n    }\n\n    long begin = -1;\n    long end   = 0;\n    bool foundEnd = false;\n\n    char line[80];\n\n    while(fgets(line, sizeof(line), file))\n        if (strncmp(header, line, strlen(header)) == 0) {\n            begin = ftell(file);\n            break;\n        }\n\n    // remove encrypted header if there\n    if (fgets(line, sizeof(line), file)) {\n        char encHeader[] = \"Proc-Type\";\n        if (strncmp(encHeader, line, strlen(encHeader)) == 0 &&\n            fgets(line,sizeof(line), file)) {\n\n            char* start  = strstr(line, \"DES\");\n            char* finish = strstr(line, \",\");\n            if (!start)\n                start    = strstr(line, \"AES\");\n\n            if (!info) return 0;\n\n            if ( start && finish && (start < finish)) {\n                memcpy(info->name, start, finish - start);\n                info->name[finish - start] = 0;\n                memcpy(info->iv, finish + 1, sizeof(info->iv));\n\n                char* newline = strstr(line, \"\\r\");\n                if (!newline) newline = strstr(line, \"\\n\");\n                if (newline && (newline > finish)) {\n                    info->ivSz = newline - (finish + 1);\n                    info->set = true;\n                }\n            }\n            begin = ftell(file);\n            if (fgets(line,sizeof(line), file)) // get blank line\n              begin = ftell(file);\n        }\n          \n    }\n\n    while(fgets(line, sizeof(line), file))\n        if (strncmp(footer, line, strlen(footer)) == 0) {\n            foundEnd = true;\n            break;\n        }\n        else\n            end = ftell(file);\n\n    if (begin == -1 || !foundEnd)\n        return 0;\n\n    input_buffer tmp(end - begin);\n    fseek(file, begin, SEEK_SET);\n    size_t bytes = fread(tmp.get_buffer(), end - begin, 1, file);\n    if (bytes != 1)\n        return 0;\n    \n    Source der(tmp.get_buffer(), end - begin);\n    Base64Decoder b64Dec(der);\n\n    uint sz = der.size();\n    mySTL::auto_ptr<x509> x(NEW_YS x509(sz));\n    memcpy(x->use_buffer(), der.get_buffer(), sz);\n\n    return x.release();\n}\n\n\n} // namespace\n\n\n#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION\nnamespace yaSSL {\ntemplate void ysDelete<DiffieHellman::DHImpl>(DiffieHellman::DHImpl*);\ntemplate void ysDelete<Integer::IntegerImpl>(Integer::IntegerImpl*);\ntemplate void ysDelete<RSA::RSAImpl>(RSA::RSAImpl*);\ntemplate void ysDelete<DSS::DSSImpl>(DSS::DSSImpl*);\ntemplate void ysDelete<RandomPool::RandomImpl>(RandomPool::RandomImpl*);\ntemplate void ysDelete<AES::AESImpl>(AES::AESImpl*);\ntemplate void ysDelete<RC4::RC4Impl>(RC4::RC4Impl*);\ntemplate void ysDelete<DES_EDE::DES_EDEImpl>(DES_EDE::DES_EDEImpl*);\ntemplate void ysDelete<DES::DESImpl>(DES::DESImpl*);\ntemplate void ysDelete<HMAC_RMD::HMAC_RMDImpl>(HMAC_RMD::HMAC_RMDImpl*);\ntemplate void ysDelete<HMAC_SHA::HMAC_SHAImpl>(HMAC_SHA::HMAC_SHAImpl*);\ntemplate void ysDelete<HMAC_MD5::HMAC_MD5Impl>(HMAC_MD5::HMAC_MD5Impl*);\ntemplate void ysDelete<RMD::RMDImpl>(RMD::RMDImpl*);\ntemplate void ysDelete<SHA::SHAImpl>(SHA::SHAImpl*);\ntemplate void ysDelete<MD5::MD5Impl>(MD5::MD5Impl*);\n}\n#endif // HAVE_EXPLICIT_TEMPLATE_INSTANTIATION\n\n#endif // !USE_CRYPTOPP_LIB\n"
  },
  {
    "path": "ext/yassl/src/dummy.cpp",
    "content": "/*\n  To make libtool always use a C++ linker when compiling with yaSSL we need\n  to add a dummy C++ file to the source list.\n*/\n"
  },
  {
    "path": "ext/yassl/src/handshake.cpp",
    "content": "/*\n   Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* The handshake source implements functions for creating and reading\n * the various handshake messages.\n */\n\n\n\n#include \"runtime.hpp\"\n#include \"handshake.hpp\"\n#include \"yassl_int.hpp\"\n\n\nnamespace yaSSL {\n\n\n\n// Build a client hello message from cipher suites and compression method\nvoid buildClientHello(SSL& ssl, ClientHello& hello)\n{\n    // store for pre master secret\n    ssl.useSecurity().use_connection().chVersion_ = hello.client_version_;\n\n    ssl.getCrypto().get_random().Fill(hello.random_, RAN_LEN);\n    if (ssl.getSecurity().get_resuming()) {\n        hello.id_len_ = ID_LEN;\n        memcpy(hello.session_id_, ssl.getSecurity().get_resume().GetID(),\n               ID_LEN);\n    }\n    else \n        hello.id_len_ = 0;\n    hello.suite_len_ = ssl.getSecurity().get_parms().suites_size_;\n    memcpy(hello.cipher_suites_, ssl.getSecurity().get_parms().suites_,\n           hello.suite_len_);\n    hello.comp_len_ = 1;\n\n    hello.set_length(sizeof(ProtocolVersion) +\n                     RAN_LEN +\n                     hello.id_len_    + sizeof(hello.id_len_) +\n                     hello.suite_len_ + sizeof(hello.suite_len_) +\n                     hello.comp_len_  + sizeof(hello.comp_len_));\n}\n\n\n// Build a server hello message\nvoid buildServerHello(SSL& ssl, ServerHello& hello)\n{\n    if (ssl.getSecurity().get_resuming()) {\n        memcpy(hello.random_,ssl.getSecurity().get_connection().server_random_,\n               RAN_LEN);\n        memcpy(hello.session_id_, ssl.getSecurity().get_resume().GetID(),\n               ID_LEN);\n    }\n    else {\n        ssl.getCrypto().get_random().Fill(hello.random_, RAN_LEN);\n        ssl.getCrypto().get_random().Fill(hello.session_id_, ID_LEN);\n    }\n    hello.id_len_ = ID_LEN;\n    ssl.set_sessionID(hello.session_id_);\n\n    hello.cipher_suite_[0] = ssl.getSecurity().get_parms().suite_[0];\n    hello.cipher_suite_[1] = ssl.getSecurity().get_parms().suite_[1];\n    hello.compression_method_ = hello.compression_method_;\n\n    hello.set_length(sizeof(ProtocolVersion) + RAN_LEN + ID_LEN +\n                     sizeof(hello.id_len_) + SUITE_LEN + SIZEOF_ENUM);\n}\n\n\n// add handshake from buffer into md5 and sha hashes, use handshake header\nvoid hashHandShake(SSL& ssl, const input_buffer& input, uint sz)\n{\n    const opaque* buffer = input.get_buffer() + input.get_current() - \n                           HANDSHAKE_HEADER;\n    sz += HANDSHAKE_HEADER;\n    ssl.useHashes().use_MD5().update(buffer, sz);\n    ssl.useHashes().use_SHA().update(buffer, sz);\n}\n\n\n// locals\nnamespace {\n\n// Write a plaintext record to buffer\nvoid buildOutput(output_buffer& buffer, const RecordLayerHeader& rlHdr, \n                 const Message& msg)\n{\n    buffer.allocate(RECORD_HEADER + rlHdr.length_);\n    buffer << rlHdr << msg;\n}\n\n\n// Write a plaintext record to buffer\nvoid buildOutput(output_buffer& buffer, const RecordLayerHeader& rlHdr, \n                 const HandShakeHeader& hsHdr, const HandShakeBase& shake)\n{\n    buffer.allocate(RECORD_HEADER + rlHdr.length_);\n    buffer << rlHdr << hsHdr << shake;\n}\n\n\n// Build Record Layer header for Message without handshake header\nvoid buildHeader(SSL& ssl, RecordLayerHeader& rlHeader, const Message& msg)\n{\n    ProtocolVersion pv = ssl.getSecurity().get_connection().version_;\n    rlHeader.type_ = msg.get_type();\n    rlHeader.version_.major_ = pv.major_;\n    rlHeader.version_.minor_ = pv.minor_;\n    rlHeader.length_ = msg.get_length();\n}\n\n\n// Build HandShake and RecordLayer Headers for handshake output\nvoid buildHeaders(SSL& ssl, HandShakeHeader& hsHeader,\n                  RecordLayerHeader& rlHeader, const HandShakeBase& shake)\n{\n    int sz = shake.get_length();\n\n    hsHeader.set_type(shake.get_type());\n    hsHeader.set_length(sz);\n\n    ProtocolVersion pv = ssl.getSecurity().get_connection().version_;\n    rlHeader.type_ = handshake;\n    rlHeader.version_.major_ = pv.major_;\n    rlHeader.version_.minor_ = pv.minor_;\n    rlHeader.length_ = sz + HANDSHAKE_HEADER;\n}\n\n\n// add handshake from buffer into md5 and sha hashes, exclude record header\nvoid hashHandShake(SSL& ssl, const output_buffer& output, bool removeIV = false)\n{\n    uint sz = output.get_size() - RECORD_HEADER;\n\n    const opaque* buffer = output.get_buffer() + RECORD_HEADER;\n\n    if (removeIV) {  // TLSv1_1 IV\n        uint blockSz = ssl.getCrypto().get_cipher().get_blockSize();\n        sz     -= blockSz;\n        buffer += blockSz;\n    }\n\n    ssl.useHashes().use_MD5().update(buffer, sz);\n    ssl.useHashes().use_SHA().update(buffer, sz);\n}\n\n\n// calculate MD5 hash for finished\nvoid buildMD5(SSL& ssl, Finished& fin, const opaque* sender)\n{\n\n    opaque md5_result[MD5_LEN];\n    opaque md5_inner[SIZEOF_SENDER + SECRET_LEN + PAD_MD5];\n    opaque md5_outer[SECRET_LEN + PAD_MD5 + MD5_LEN];\n\n    const opaque* master_secret = \n        ssl.getSecurity().get_connection().master_secret_;\n\n    // make md5 inner\n    memcpy(md5_inner, sender, SIZEOF_SENDER);\n    memcpy(&md5_inner[SIZEOF_SENDER], master_secret, SECRET_LEN);\n    memcpy(&md5_inner[SIZEOF_SENDER + SECRET_LEN], PAD1, PAD_MD5);\n\n    ssl.useHashes().use_MD5().get_digest(md5_result, md5_inner,\n                                         sizeof(md5_inner));\n\n    // make md5 outer\n    memcpy(md5_outer, master_secret, SECRET_LEN);\n    memcpy(&md5_outer[SECRET_LEN], PAD2, PAD_MD5);\n    memcpy(&md5_outer[SECRET_LEN + PAD_MD5], md5_result, MD5_LEN);\n\n    ssl.useHashes().use_MD5().get_digest(fin.set_md5(), md5_outer,\n                                         sizeof(md5_outer));\n}\n\n\n// calculate SHA hash for finished\nvoid buildSHA(SSL& ssl, Finished& fin, const opaque* sender)\n{\n    \n    opaque sha_result[SHA_LEN];\n    opaque sha_inner[SIZEOF_SENDER + SECRET_LEN + PAD_SHA];\n    opaque sha_outer[SECRET_LEN + PAD_SHA + SHA_LEN];\n\n    const opaque* master_secret = \n        ssl.getSecurity().get_connection().master_secret_;\n\n     // make sha inner\n    memcpy(sha_inner, sender, SIZEOF_SENDER);\n    memcpy(&sha_inner[SIZEOF_SENDER], master_secret, SECRET_LEN);\n    memcpy(&sha_inner[SIZEOF_SENDER + SECRET_LEN], PAD1, PAD_SHA);\n\n    ssl.useHashes().use_SHA().get_digest(sha_result, sha_inner,\n                                         sizeof(sha_inner));\n\n    // make sha outer\n    memcpy(sha_outer, master_secret, SECRET_LEN);\n    memcpy(&sha_outer[SECRET_LEN], PAD2, PAD_SHA);\n    memcpy(&sha_outer[SECRET_LEN + PAD_SHA], sha_result, SHA_LEN);\n\n    ssl.useHashes().use_SHA().get_digest(fin.set_sha(), sha_outer,\n                                         sizeof(sha_outer));\n}\n\n\n// sanity checks on encrypted message size\nstatic int sanity_check_message(SSL& ssl, uint msgSz)\n{\n    uint minSz = 0;\n\n    if (ssl.getSecurity().get_parms().cipher_type_ == block) {\n        uint blockSz = ssl.getCrypto().get_cipher().get_blockSize();\n        if (msgSz % blockSz)\n            return -1;\n\n        minSz = ssl.getSecurity().get_parms().hash_size_ + 1;  // pad byte too\n        if (blockSz > minSz)\n            minSz = blockSz;\n\n        if (ssl.isTLSv1_1())\n            minSz += blockSz;   // explicit IV\n    }\n    else {      // stream\n        minSz = ssl.getSecurity().get_parms().hash_size_;\n    }\n\n    if (msgSz < minSz)\n        return -1;\n\n    return 0;\n}\n\n\n// decrypt input message in place, store size in case needed later\nvoid decrypt_message(SSL& ssl, input_buffer& input, uint sz)\n{\n    input_buffer plain(sz);\n    opaque*      cipher = input.get_buffer() + input.get_current();\n\n    if (sanity_check_message(ssl, sz) != 0) {\n        ssl.SetError(sanityCipher_error);\n        return;\n    }\n\n    ssl.useCrypto().use_cipher().decrypt(plain.get_buffer(), cipher, sz);\n    memcpy(cipher, plain.get_buffer(), sz);\n    ssl.useSecurity().use_parms().encrypt_size_ = sz;\n\n    if (ssl.isTLSv1_1())  // IV\n        input.set_current(input.get_current() +\n              ssl.getCrypto().get_cipher().get_blockSize());\n}\n\n\n// output operator for input_buffer\noutput_buffer& operator<<(output_buffer& output, const input_buffer& input)\n{\n    output.write(input.get_buffer(), input.get_size());\n    return output;\n}\n\n\n// write headers, handshake hash, mac, pad, and encrypt\nvoid cipherFinished(SSL& ssl, Finished& fin, output_buffer& output)\n{\n    uint digestSz = ssl.getCrypto().get_digest().get_digestSize();\n    uint finishedSz = ssl.isTLS() ? TLS_FINISHED_SZ : FINISHED_SZ;\n    uint sz  = RECORD_HEADER + HANDSHAKE_HEADER + finishedSz + digestSz;\n    uint pad = 0;\n    uint blockSz = ssl.getCrypto().get_cipher().get_blockSize();\n\n    if (ssl.getSecurity().get_parms().cipher_type_ == block) {\n        if (ssl.isTLSv1_1())\n            sz += blockSz;            // IV\n        sz += 1;       // pad byte\n        pad = (sz - RECORD_HEADER) % blockSz;\n        pad = blockSz - pad;\n        sz += pad;\n    }\n\n    RecordLayerHeader rlHeader;\n    HandShakeHeader   hsHeader;\n    buildHeaders(ssl, hsHeader, rlHeader, fin);\n    rlHeader.length_ = sz - RECORD_HEADER;   // record header includes mac\n                                             // and pad, hanshake doesn't\n    input_buffer iv;\n    if (ssl.isTLSv1_1() && ssl.getSecurity().get_parms().cipher_type_== block){\n        iv.allocate(blockSz);\n        ssl.getCrypto().get_random().Fill(iv.get_buffer(), blockSz);\n        iv.add_size(blockSz);\n    }\n    uint ivSz = iv.get_size();\n    output.allocate(sz);\n    output << rlHeader << iv << hsHeader << fin;\n    \n    hashHandShake(ssl, output, ssl.isTLSv1_1() ? true : false);\n    opaque digest[SHA_LEN];                  // max size\n    if (ssl.isTLS())\n        TLS_hmac(ssl, digest, output.get_buffer() + RECORD_HEADER + ivSz,\n                 output.get_size() - RECORD_HEADER - ivSz, handshake);\n    else\n        hmac(ssl, digest, output.get_buffer() + RECORD_HEADER,\n             output.get_size() - RECORD_HEADER, handshake);\n    output.write(digest, digestSz);\n\n    if (ssl.getSecurity().get_parms().cipher_type_ == block)\n        for (uint i = 0; i <= pad; i++) output[AUTO] = pad;   // pad byte gets\n                                                              // pad value too\n    input_buffer cipher(rlHeader.length_);\n    ssl.useCrypto().use_cipher().encrypt(cipher.get_buffer(),\n       output.get_buffer() + RECORD_HEADER, output.get_size() - RECORD_HEADER);\n    output.set_current(RECORD_HEADER);\n    output.write(cipher.get_buffer(), cipher.get_capacity());\n}\n\n\n// build an encrypted data or alert message for output\nvoid buildMessage(SSL& ssl, output_buffer& output, const Message& msg)\n{\n    uint digestSz = ssl.getCrypto().get_digest().get_digestSize();\n    uint sz  = RECORD_HEADER + msg.get_length() + digestSz;                \n    uint pad = 0;\n    uint blockSz = ssl.getCrypto().get_cipher().get_blockSize();\n\n    if (ssl.getSecurity().get_parms().cipher_type_ == block) {\n        if (ssl.isTLSv1_1())  // IV\n            sz += blockSz;\n        sz += 1;       // pad byte\n        pad = (sz - RECORD_HEADER) % blockSz;\n        pad = blockSz - pad;\n        sz += pad;\n    }\n\n    RecordLayerHeader rlHeader;\n    buildHeader(ssl, rlHeader, msg);\n    rlHeader.length_ = sz - RECORD_HEADER;   // record header includes mac\n                                             // and pad, hanshake doesn't\n    input_buffer iv;\n    if (ssl.isTLSv1_1() && ssl.getSecurity().get_parms().cipher_type_== block){\n        iv.allocate(blockSz);\n        ssl.getCrypto().get_random().Fill(iv.get_buffer(), blockSz);\n        iv.add_size(blockSz);\n    }\n    \n    uint ivSz = iv.get_size();\n    output.allocate(sz);\n    output << rlHeader << iv << msg;\n    \n    opaque digest[SHA_LEN];                  // max size\n    if (ssl.isTLS())\n        TLS_hmac(ssl, digest, output.get_buffer() + RECORD_HEADER + ivSz,\n                 output.get_size() - RECORD_HEADER - ivSz, msg.get_type());\n    else\n        hmac(ssl, digest, output.get_buffer() + RECORD_HEADER,\n             output.get_size() - RECORD_HEADER, msg.get_type());\n    output.write(digest, digestSz);\n\n    if (ssl.getSecurity().get_parms().cipher_type_ == block)\n        for (uint i = 0; i <= pad; i++) output[AUTO] = pad; // pad byte gets\n                                                              // pad value too\n    input_buffer cipher(rlHeader.length_);\n    ssl.useCrypto().use_cipher().encrypt(cipher.get_buffer(),\n       output.get_buffer() + RECORD_HEADER, output.get_size() - RECORD_HEADER);\n    output.set_current(RECORD_HEADER);\n    output.write(cipher.get_buffer(), cipher.get_capacity());\n}\n\n\n// build alert message\nvoid buildAlert(SSL& ssl, output_buffer& output, const Alert& alert)\n{\n    if (ssl.getSecurity().get_parms().pending_ == false) // encrypted\n        buildMessage(ssl, output, alert);\n    else {\n        RecordLayerHeader rlHeader;\n        buildHeader(ssl, rlHeader, alert);\n        buildOutput(output, rlHeader, alert);\n    }\n}\n\n\n// build TLS finished message\nvoid buildFinishedTLS(SSL& ssl, Finished& fin, const opaque* sender) \n{\n    opaque handshake_hash[FINISHED_SZ];\n\n    ssl.useHashes().use_MD5().get_digest(handshake_hash);\n    ssl.useHashes().use_SHA().get_digest(&handshake_hash[MD5_LEN]);\n\n    const opaque* side;\n    if ( strncmp((const char*)sender, (const char*)client, SIZEOF_SENDER) == 0)\n        side = tls_client;\n    else\n        side = tls_server;\n\n    PRF(fin.set_md5(), TLS_FINISHED_SZ, \n        ssl.getSecurity().get_connection().master_secret_, SECRET_LEN, \n        side, FINISHED_LABEL_SZ, \n        handshake_hash, FINISHED_SZ);\n\n    fin.set_length(TLS_FINISHED_SZ);  // shorter length for TLS\n}\n\n\n// compute p_hash for MD5 or SHA-1 for TLSv1 PRF\nvoid p_hash(output_buffer& result, const output_buffer& secret,\n            const output_buffer& seed, MACAlgorithm hash)\n{\n    uint   len = hash == md5 ? MD5_LEN : SHA_LEN;\n    uint   times = result.get_capacity() / len;\n    uint   lastLen = result.get_capacity() % len;\n    opaque previous[SHA_LEN];  // max size\n    opaque current[SHA_LEN];   // max size\n    mySTL::auto_ptr<Digest> hmac;\n\n    if (lastLen) times += 1;\n\n    if (hash == md5)\n        hmac.reset(NEW_YS HMAC_MD5(secret.get_buffer(), secret.get_size()));\n    else\n        hmac.reset(NEW_YS HMAC_SHA(secret.get_buffer(), secret.get_size()));\n                                                                   // A0 = seed\n    hmac->get_digest(previous, seed.get_buffer(), seed.get_size());// A1\n    uint lastTime = times - 1;\n\n    for (uint i = 0; i < times; i++) {\n        hmac->update(previous, len);  \n        hmac->get_digest(current, seed.get_buffer(), seed.get_size());\n\n        if (lastLen && (i == lastTime))\n            result.write(current, lastLen);\n        else {\n            result.write(current, len);\n            //memcpy(previous, current, len);\n            hmac->get_digest(previous, previous, len);\n        }\n    }\n}\n\n\n// calculate XOR for TLSv1 PRF\nvoid get_xor(byte *digest, uint digLen, output_buffer& md5,\n             output_buffer& sha)\n{\n    for (uint i = 0; i < digLen; i++) \n        digest[i] = md5[AUTO] ^ sha[AUTO];\n}\n\n\n// build MD5 part of certificate verify\nvoid buildMD5_CertVerify(SSL& ssl, byte* digest)\n{\n    opaque md5_result[MD5_LEN];\n    opaque md5_inner[SECRET_LEN + PAD_MD5];\n    opaque md5_outer[SECRET_LEN + PAD_MD5 + MD5_LEN];\n\n    const opaque* master_secret = \n        ssl.getSecurity().get_connection().master_secret_;\n\n    // make md5 inner\n    memcpy(md5_inner, master_secret, SECRET_LEN);\n    memcpy(&md5_inner[SECRET_LEN], PAD1, PAD_MD5);\n\n    ssl.useHashes().use_MD5().get_digest(md5_result, md5_inner,\n                                         sizeof(md5_inner));\n\n    // make md5 outer\n    memcpy(md5_outer, master_secret, SECRET_LEN);\n    memcpy(&md5_outer[SECRET_LEN], PAD2, PAD_MD5);\n    memcpy(&md5_outer[SECRET_LEN + PAD_MD5], md5_result, MD5_LEN);\n\n    ssl.useHashes().use_MD5().get_digest(digest, md5_outer, sizeof(md5_outer));\n}\n\n\n// build SHA part of certificate verify\nvoid buildSHA_CertVerify(SSL& ssl, byte* digest)\n{\n    opaque sha_result[SHA_LEN];\n    opaque sha_inner[SECRET_LEN + PAD_SHA];\n    opaque sha_outer[SECRET_LEN + PAD_SHA + SHA_LEN];\n\n    const opaque* master_secret = \n        ssl.getSecurity().get_connection().master_secret_;\n\n     // make sha inner\n    memcpy(sha_inner, master_secret, SECRET_LEN);\n    memcpy(&sha_inner[SECRET_LEN], PAD1, PAD_SHA);\n\n    ssl.useHashes().use_SHA().get_digest(sha_result, sha_inner,\n                                         sizeof(sha_inner));\n\n    // make sha outer\n    memcpy(sha_outer, master_secret, SECRET_LEN);\n    memcpy(&sha_outer[SECRET_LEN], PAD2, PAD_SHA);\n    memcpy(&sha_outer[SECRET_LEN + PAD_SHA], sha_result, SHA_LEN);\n\n    ssl.useHashes().use_SHA().get_digest(digest, sha_outer, sizeof(sha_outer));\n}\n\n\n} // namespace for locals\n\n\n// some clients still send sslv2 client hello\nvoid ProcessOldClientHello(input_buffer& input, SSL& ssl)\n{\n    if (input.get_error() || input.get_remaining() < 2) {\n        ssl.SetError(bad_input);\n        return;\n    }\n    byte b0 = input[AUTO];\n    byte b1 = input[AUTO];\n\n    uint16 sz = ((b0 & 0x7f) << 8) | b1;\n\n    if (sz > input.get_remaining()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    // hashHandShake manually\n    const opaque* buffer = input.get_buffer() + input.get_current();\n    ssl.useHashes().use_MD5().update(buffer, sz);\n    ssl.useHashes().use_SHA().update(buffer, sz);\n\n    b1 = input[AUTO];  // does this value mean client_hello?\n\n    ClientHello ch;\n    ch.client_version_.major_ = input[AUTO];\n    ch.client_version_.minor_ = input[AUTO];\n\n    byte len[2];\n\n    len[0] = input[AUTO];\n    len[1] = input[AUTO];\n    ato16(len, ch.suite_len_);\n\n    len[0] = input[AUTO];\n    len[1] = input[AUTO];\n    uint16 sessionLen;\n    ato16(len, sessionLen);\n    ch.id_len_ = sessionLen;\n\n    len[0] = input[AUTO];\n    len[1] = input[AUTO];\n    uint16 randomLen;\n    ato16(len, randomLen);\n\n    if (input.get_error() || ch.suite_len_ > MAX_SUITE_SZ ||\n                             ch.suite_len_ > input.get_remaining() ||\n                             sessionLen > ID_LEN || randomLen > RAN_LEN) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    int j = 0;\n    for (uint16 i = 0; i < ch.suite_len_; i += 3) {    \n        byte first = input[AUTO];\n        if (first)  // sslv2 type\n            input.read(len, SUITE_LEN); // skip\n        else {\n            input.read(&ch.cipher_suites_[j], SUITE_LEN);\n            j += SUITE_LEN;\n        }\n    }\n    ch.suite_len_ = j;\n\n    if (ch.id_len_)\n        input.read(ch.session_id_, ch.id_len_);   // id_len_ from sessionLen\n\n    if (randomLen < RAN_LEN)\n        memset(ch.random_, 0, RAN_LEN - randomLen);\n    input.read(&ch.random_[RAN_LEN - randomLen], randomLen);\n \n    ch.Process(input, ssl);\n}\n\n\n// Build a finished message, see 7.6.9\nvoid buildFinished(SSL& ssl, Finished& fin, const opaque* sender) \n{\n    // store current states, building requires get_digest which resets state\n    MD5 md5(ssl.getHashes().get_MD5());\n    SHA sha(ssl.getHashes().get_SHA());\n\n    if (ssl.isTLS())\n        buildFinishedTLS(ssl, fin, sender);\n    else {\n        buildMD5(ssl, fin, sender);\n        buildSHA(ssl, fin, sender);\n    }\n\n    // restore\n    ssl.useHashes().use_MD5() = md5;\n    ssl.useHashes().use_SHA() = sha;\n}\n\n\n/* compute SSLv3 HMAC into digest see\n * buffer is of sz size and includes HandShake Header but not a Record Header\n * verify means to check peers hmac\n*/\nvoid hmac(SSL& ssl, byte* digest, const byte* buffer, uint sz,\n          ContentType content, bool verify)\n{\n    Digest& mac = ssl.useCrypto().use_digest();\n    opaque inner[SHA_LEN + PAD_MD5 + SEQ_SZ + SIZEOF_ENUM + LENGTH_SZ];\n    opaque outer[SHA_LEN + PAD_MD5 + SHA_LEN]; \n    opaque result[SHA_LEN];                              // max possible sizes\n    uint digestSz = mac.get_digestSize();              // actual sizes\n    uint padSz    = mac.get_padSize();\n    uint innerSz  = digestSz + padSz + SEQ_SZ + SIZEOF_ENUM + LENGTH_SZ;\n    uint outerSz  = digestSz + padSz + digestSz;\n\n    // data\n    const opaque* mac_secret = ssl.get_macSecret(verify);\n    opaque seq[SEQ_SZ] = { 0x00, 0x00, 0x00, 0x00 };\n    opaque length[LENGTH_SZ];\n    c16toa(sz, length);\n    c32toa(ssl.get_SEQIncrement(verify), &seq[sizeof(uint32)]);\n\n    // make inner\n    memcpy(inner, mac_secret, digestSz);\n    memcpy(&inner[digestSz], PAD1, padSz);\n    memcpy(&inner[digestSz + padSz], seq, SEQ_SZ);\n    inner[digestSz + padSz + SEQ_SZ] = content;\n    memcpy(&inner[digestSz + padSz + SEQ_SZ + SIZEOF_ENUM], length, LENGTH_SZ);\n\n    mac.update(inner, innerSz);\n    mac.get_digest(result, buffer, sz);      // append content buffer\n\n    // make outer\n    memcpy(outer, mac_secret, digestSz);\n    memcpy(&outer[digestSz], PAD2, padSz);\n    memcpy(&outer[digestSz + padSz], result, digestSz);\n\n    mac.get_digest(digest, outer, outerSz);\n}\n\n\n// TLS type HAMC\nvoid TLS_hmac(SSL& ssl, byte* digest, const byte* buffer, uint sz,\n              ContentType content, bool verify)\n{\n    mySTL::auto_ptr<Digest> hmac;\n    opaque seq[SEQ_SZ] = { 0x00, 0x00, 0x00, 0x00 };\n    opaque length[LENGTH_SZ];\n    opaque inner[SIZEOF_ENUM + VERSION_SZ + LENGTH_SZ]; // type + version + len\n\n    c16toa(sz, length);\n    c32toa(ssl.get_SEQIncrement(verify), &seq[sizeof(uint32)]);\n\n    MACAlgorithm algo = ssl.getSecurity().get_parms().mac_algorithm_;\n\n    if (algo == sha)\n        hmac.reset(NEW_YS HMAC_SHA(ssl.get_macSecret(verify), SHA_LEN));\n    else if (algo == rmd)\n        hmac.reset(NEW_YS HMAC_RMD(ssl.get_macSecret(verify), RMD_LEN));\n    else\n        hmac.reset(NEW_YS HMAC_MD5(ssl.get_macSecret(verify), MD5_LEN));\n    \n    hmac->update(seq, SEQ_SZ);                                       // seq_num\n    inner[0] = content;                                              // type\n    inner[SIZEOF_ENUM] = ssl.getSecurity().get_connection().version_.major_;  \n    inner[SIZEOF_ENUM + SIZEOF_ENUM] = \n        ssl.getSecurity().get_connection().version_.minor_;          // version\n    memcpy(&inner[SIZEOF_ENUM + VERSION_SZ], length, LENGTH_SZ);     // length\n    hmac->update(inner, sizeof(inner));\n    hmac->get_digest(digest, buffer, sz);                            // content\n}\n\n\n// compute TLSv1 PRF (pseudo random function using HMAC)\nvoid PRF(byte* digest, uint digLen, const byte* secret, uint secLen,\n         const byte* label, uint labLen, const byte* seed, uint seedLen)\n{\n    uint half = (secLen + 1) / 2;\n\n    output_buffer md5_half(half);\n    output_buffer sha_half(half);\n    output_buffer labelSeed(labLen + seedLen);\n\n    md5_half.write(secret, half);\n    sha_half.write(secret + half - secLen % 2, half);\n    labelSeed.write(label, labLen);\n    labelSeed.write(seed, seedLen);\n\n    output_buffer md5_result(digLen);\n    output_buffer sha_result(digLen);\n\n    p_hash(md5_result, md5_half, labelSeed, md5);\n    p_hash(sha_result, sha_half, labelSeed, sha);\n\n    md5_result.set_current(0);\n    sha_result.set_current(0);\n    get_xor(digest, digLen, md5_result, sha_result);\n}\n\n\n// build certificate hashes\nvoid build_certHashes(SSL& ssl, Hashes& hashes)\n{\n    // store current states, building requires get_digest which resets state\n    MD5 md5(ssl.getHashes().get_MD5());\n    SHA sha(ssl.getHashes().get_SHA());\n\n    if (ssl.isTLS()) {\n        ssl.useHashes().use_MD5().get_digest(hashes.md5_);\n        ssl.useHashes().use_SHA().get_digest(hashes.sha_);\n    }\n    else {\n        buildMD5_CertVerify(ssl, hashes.md5_);\n        buildSHA_CertVerify(ssl, hashes.sha_);\n    }\n\n    // restore\n    ssl.useHashes().use_MD5() = md5;\n    ssl.useHashes().use_SHA() = sha;\n}\n\n\n\n// do process input requests, return 0 is done, 1 is call again to complete\nint DoProcessReply(SSL& ssl)\n{\n    uint ready = ssl.getSocket().get_ready();\n    if (!ready)\n      ready= 64;\n\n    // add buffered data if its there\n    input_buffer* buffered = ssl.useBuffers().TakeRawInput();\n    uint buffSz = buffered ? buffered->get_size() : 0;\n    input_buffer buffer(buffSz + ready);\n    if (buffSz) {\n        buffer.assign(buffered->get_buffer(), buffSz);\n        ysDelete(buffered);\n        buffered = 0;\n    }\n\n    // add new data\n    uint read  = ssl.useSocket().receive(buffer.get_buffer() + buffSz, ready);\n    if (read == static_cast<uint>(-1)) {\n        ssl.SetError(receive_error);\n        return 0;\n    }\n    buffer.add_size(read);\n    uint offset = 0;\n    const MessageFactory& mf = ssl.getFactory().getMessage();\n\n    // old style sslv2 client hello?\n    if (ssl.getSecurity().get_parms().entity_ == server_end &&\n                  ssl.getStates().getServer() == clientNull) \n        if (buffer.peek() != handshake) {\n            ProcessOldClientHello(buffer, ssl);\n            if (ssl.GetError())\n                return 0;\n        }\n\n    while(!buffer.eof()) {\n        // each record\n        RecordLayerHeader hdr;\n        bool              needHdr = false;\n\n        if (static_cast<uint>(RECORD_HEADER) > buffer.get_remaining())\n            needHdr = true;\n        else {\n            buffer >> hdr;\n            ssl.verifyState(hdr);\n        }\n\n        if (ssl.GetError())\n            return 0;\n\n        // make sure we have enough input in buffer to process this record\n        if (needHdr || hdr.length_ > buffer.get_remaining()) {\n            // put header in front for next time processing\n            uint extra = needHdr ? 0 : RECORD_HEADER;\n            uint sz = buffer.get_remaining() + extra;\n            ssl.useBuffers().SetRawInput(NEW_YS input_buffer(sz,\n                      buffer.get_buffer() + buffer.get_current() - extra, sz));\n            return 1;\n        }\n\n        while (buffer.get_current() < hdr.length_ + RECORD_HEADER + offset) {\n            // each message in record, can be more than 1 if not encrypted\n            if (ssl.GetError())\n                return 0;\n\n            if (ssl.getSecurity().get_parms().pending_ == false) { // cipher on\n                // sanity check for malicious/corrupted/illegal input\n                if (buffer.get_remaining() < hdr.length_) {\n                    ssl.SetError(bad_input);\n                    return 0;\n                }\n                decrypt_message(ssl, buffer, hdr.length_);\n                if (ssl.GetError())\n                    return 0;\n            }\n                \n            mySTL::auto_ptr<Message> msg(mf.CreateObject(hdr.type_));\n            if (!msg.get()) {\n                ssl.SetError(factory_error);\n                return 0;\n            }\n            buffer >> *msg;\n            msg->Process(buffer, ssl);\n            if (ssl.GetError())\n                return 0;\n        }\n        offset += hdr.length_ + RECORD_HEADER;\n    }\n    return 0;\n}\n\n\n// process input requests\nvoid processReply(SSL& ssl)\n{\n    if (ssl.GetError()) return;\n  \n    if (DoProcessReply(ssl)) {\n        // didn't complete process\n        if (!ssl.getSocket().IsNonBlocking()) {\n            // keep trying now, blocking ok\n            while (!ssl.GetError())\n                if (DoProcessReply(ssl) == 0) break;\n        }\n        else\n            // user will have try again later, non blocking\n            ssl.SetError(YasslError(SSL_ERROR_WANT_READ));\n    }\n}\n\n\n// send client_hello, no buffering\nvoid sendClientHello(SSL& ssl)\n{\n    ssl.verifyState(serverNull);\n    if (ssl.GetError()) return;\n\n    ClientHello       ch(ssl.getSecurity().get_connection().version_,\n                         ssl.getSecurity().get_connection().compression_);\n    RecordLayerHeader rlHeader;\n    HandShakeHeader   hsHeader;\n    output_buffer     out;\n\n    buildClientHello(ssl, ch);\n    ssl.set_random(ch.get_random(), client_end);\n    buildHeaders(ssl, hsHeader, rlHeader, ch);\n    buildOutput(out, rlHeader, hsHeader, ch);\n    hashHandShake(ssl, out);\n\n    ssl.Send(out.get_buffer(), out.get_size());\n}\n\n\n// send client key exchange\nvoid sendClientKeyExchange(SSL& ssl, BufferOutput buffer)\n{\n    ssl.verifyState(serverHelloDoneComplete);\n    if (ssl.GetError()) return;\n\n    ClientKeyExchange ck(ssl);\n    ck.build(ssl);\n    ssl.makeMasterSecret();\n\n    RecordLayerHeader rlHeader;\n    HandShakeHeader   hsHeader;\n    mySTL::auto_ptr<output_buffer> out(NEW_YS output_buffer);\n    buildHeaders(ssl, hsHeader, rlHeader, ck);\n    buildOutput(*out.get(), rlHeader, hsHeader, ck);\n    hashHandShake(ssl, *out.get());\n\n    if (buffer == buffered)\n        ssl.addBuffer(out.release());\n    else\n        ssl.Send(out->get_buffer(), out->get_size());\n}\n\n\n// send server key exchange\nvoid sendServerKeyExchange(SSL& ssl, BufferOutput buffer)\n{\n    if (ssl.GetError()) return;\n    ServerKeyExchange sk(ssl);\n    sk.build(ssl);\n    if (ssl.GetError()) return;\n\n    RecordLayerHeader rlHeader;\n    HandShakeHeader   hsHeader;\n    mySTL::auto_ptr<output_buffer> out(NEW_YS output_buffer);\n    buildHeaders(ssl, hsHeader, rlHeader, sk);\n    buildOutput(*out.get(), rlHeader, hsHeader, sk);\n    hashHandShake(ssl, *out.get());\n\n    if (buffer == buffered)\n        ssl.addBuffer(out.release());\n    else\n        ssl.Send(out->get_buffer(), out->get_size());\n}\n\n\n// send change cipher\nvoid sendChangeCipher(SSL& ssl, BufferOutput buffer)\n{\n    if (ssl.getSecurity().get_parms().entity_ == server_end) {\n        if (ssl.getSecurity().get_resuming())\n            ssl.verifyState(clientKeyExchangeComplete);\n        else\n            ssl.verifyState(clientFinishedComplete);\n    }\n    if (ssl.GetError()) return;\n\n    ChangeCipherSpec ccs;\n    RecordLayerHeader rlHeader;\n    buildHeader(ssl, rlHeader, ccs);\n    mySTL::auto_ptr<output_buffer> out(NEW_YS output_buffer);\n    buildOutput(*out.get(), rlHeader, ccs);\n   \n    if (buffer == buffered)\n        ssl.addBuffer(out.release());\n    else\n        ssl.Send(out->get_buffer(), out->get_size());\n}\n\n\n// send finished\nvoid sendFinished(SSL& ssl, ConnectionEnd side, BufferOutput buffer)\n{\n    if (ssl.GetError()) return;\n\n    Finished fin;\n    buildFinished(ssl, fin, side == client_end ? client : server);\n    mySTL::auto_ptr<output_buffer> out(NEW_YS output_buffer);\n    cipherFinished(ssl, fin, *out.get());                   // hashes handshake\n\n    if (ssl.getSecurity().get_resuming()) {\n        if (side == server_end)\n            buildFinished(ssl, ssl.useHashes().use_verify(), client); // client\n    }\n    else {\n        if (!ssl.getSecurity().GetContext()->GetSessionCacheOff())\n            GetSessions().add(ssl);  // store session\n        if (side == client_end)\n            buildFinished(ssl, ssl.useHashes().use_verify(), server); // server\n    }   \n    ssl.useSecurity().use_connection().CleanMaster();\n\n    if (buffer == buffered)\n        ssl.addBuffer(out.release());\n    else\n        ssl.Send(out->get_buffer(), out->get_size());\n}\n\n\n// send data\nint sendData(SSL& ssl, const void* buffer, int sz)\n{\n    int sent = 0;\n\n    if (ssl.GetError() == YasslError(SSL_ERROR_WANT_READ))\n        ssl.SetError(no_error);\n\n    if (ssl.GetError() == YasslError(SSL_ERROR_WANT_WRITE)) {\n        ssl.SetError(no_error);\n        ssl.SendWriteBuffered();\n        if (!ssl.GetError()) {\n            // advance sent to prvevious sent + plain size just sent\n            sent = ssl.useBuffers().prevSent + ssl.useBuffers().plainSz;\n        }\n    }\n\n    ssl.verfiyHandShakeComplete();\n    if (ssl.GetError()) return -1;\n\n    for (;;) {\n        int len = min(sz - sent, MAX_RECORD_SIZE);\n        output_buffer out;\n        input_buffer tmp;\n\n        Data data;\n\n        if (sent == sz) break;\n\n        if (ssl.CompressionOn()) {\n            if (Compress(static_cast<const opaque*>(buffer) + sent, len,\n                         tmp) == -1) {\n                ssl.SetError(compress_error);\n                return -1;\n            }\n            data.SetData(tmp.get_size(), tmp.get_buffer());\n        }\n        else\n            data.SetData(len, static_cast<const opaque*>(buffer) + sent);\n\n        buildMessage(ssl, out, data);\n        ssl.Send(out.get_buffer(), out.get_size());\n\n        if (ssl.GetError()) {\n            if (ssl.GetError() == YasslError(SSL_ERROR_WANT_WRITE)) {\n                ssl.useBuffers().plainSz  = len;\n                ssl.useBuffers().prevSent = sent;\n            }\n            return -1;\n        }\n        sent += len;\n    }\n    ssl.useLog().ShowData(sent, true);\n    return sent;\n}\n\n\n// send alert\nint sendAlert(SSL& ssl, const Alert& alert)\n{\n    output_buffer out;\n    buildAlert(ssl, out, alert);\n    ssl.Send(out.get_buffer(), out.get_size());\n\n    return alert.get_length();\n}\n\n\n// process input data\nint receiveData(SSL& ssl, Data& data, bool peek)\n{\n    if (ssl.GetError() == YasslError(SSL_ERROR_WANT_READ))\n        ssl.SetError(no_error);\n\n    ssl.verfiyHandShakeComplete();\n    if (ssl.GetError()) return -1;\n\n    if (!ssl.HasData())\n        processReply(ssl);\n\n    if (peek)\n        ssl.PeekData(data);\n    else\n        ssl.fillData(data);\n\n    ssl.useLog().ShowData(data.get_length());\n    if (ssl.GetError()) return -1;\n\n    if (data.get_length() == 0 && ssl.getSocket().WouldBlock()) {\n        ssl.SetError(YasslError(SSL_ERROR_WANT_READ));\n        return SSL_WOULD_BLOCK;\n    }\n    return data.get_length(); \n}\n\n\n// send server hello\nvoid sendServerHello(SSL& ssl, BufferOutput buffer)\n{\n    if (ssl.getSecurity().get_resuming())\n        ssl.verifyState(clientKeyExchangeComplete);\n    else\n        ssl.verifyState(clientHelloComplete);\n    if (ssl.GetError()) return;\n\n    ServerHello       sh(ssl.getSecurity().get_connection().version_,\n                         ssl.getSecurity().get_connection().compression_);\n    RecordLayerHeader rlHeader;\n    HandShakeHeader   hsHeader;\n    mySTL::auto_ptr<output_buffer> out(NEW_YS output_buffer);\n\n    buildServerHello(ssl, sh);\n    ssl.set_random(sh.get_random(), server_end);\n    buildHeaders(ssl, hsHeader, rlHeader, sh);\n    buildOutput(*out.get(), rlHeader, hsHeader, sh);\n    hashHandShake(ssl, *out.get());\n\n    if (buffer == buffered)\n        ssl.addBuffer(out.release());\n    else\n        ssl.Send(out->get_buffer(), out->get_size());\n}\n\n\n// send server hello done\nvoid sendServerHelloDone(SSL& ssl, BufferOutput buffer)\n{\n    if (ssl.GetError()) return;\n\n    ServerHelloDone   shd;\n    RecordLayerHeader rlHeader;\n    HandShakeHeader   hsHeader;\n    mySTL::auto_ptr<output_buffer> out(NEW_YS output_buffer);\n\n    buildHeaders(ssl, hsHeader, rlHeader, shd);\n    buildOutput(*out.get(), rlHeader, hsHeader, shd);\n    hashHandShake(ssl, *out.get());\n\n    if (buffer == buffered)\n        ssl.addBuffer(out.release());\n    else\n        ssl.Send(out->get_buffer(), out->get_size());\n}\n\n\n// send certificate\nvoid sendCertificate(SSL& ssl, BufferOutput buffer)\n{\n    if (ssl.GetError()) return;\n\n    Certificate       cert(ssl.getCrypto().get_certManager().get_cert());\n    RecordLayerHeader rlHeader;\n    HandShakeHeader   hsHeader;\n    mySTL::auto_ptr<output_buffer> out(NEW_YS output_buffer);\n\n    buildHeaders(ssl, hsHeader, rlHeader, cert);\n    buildOutput(*out.get(), rlHeader, hsHeader, cert);\n    hashHandShake(ssl, *out.get());\n\n    if (buffer == buffered)\n        ssl.addBuffer(out.release());\n    else\n        ssl.Send(out->get_buffer(), out->get_size());\n}\n\n\n// send certificate request\nvoid sendCertificateRequest(SSL& ssl, BufferOutput buffer)\n{\n    if (ssl.GetError()) return;\n\n    CertificateRequest request;\n    request.Build();\n    RecordLayerHeader  rlHeader;\n    HandShakeHeader    hsHeader;\n    mySTL::auto_ptr<output_buffer> out(NEW_YS output_buffer);\n\n    buildHeaders(ssl, hsHeader, rlHeader, request);\n    buildOutput(*out.get(), rlHeader, hsHeader, request);\n    hashHandShake(ssl, *out.get());\n\n    if (buffer == buffered)\n        ssl.addBuffer(out.release());\n    else\n        ssl.Send(out->get_buffer(), out->get_size());\n}\n\n\n// send certificate verify\nvoid sendCertificateVerify(SSL& ssl, BufferOutput buffer)\n{\n    if (ssl.GetError()) return;\n\n    if(ssl.getCrypto().get_certManager().sendBlankCert()) return;\n\n    CertificateVerify  verify;\n    verify.Build(ssl);\n    RecordLayerHeader  rlHeader;\n    HandShakeHeader    hsHeader;\n    mySTL::auto_ptr<output_buffer> out(NEW_YS output_buffer);\n\n    buildHeaders(ssl, hsHeader, rlHeader, verify);\n    buildOutput(*out.get(), rlHeader, hsHeader, verify);\n    hashHandShake(ssl, *out.get());\n\n    if (buffer == buffered)\n        ssl.addBuffer(out.release());\n    else\n        ssl.Send(out->get_buffer(), out->get_size());\n}\n\n\n} // namespace\n"
  },
  {
    "path": "ext/yassl/src/lock.cpp",
    "content": "/*\n   Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/*  Locking functions\n */\n\n#include \"runtime.hpp\"\n#include \"lock.hpp\"\n\n\nnamespace yaSSL {\n\n\n#ifdef MULTI_THREADED\n    #ifdef _WIN32\n        \n        Mutex::Mutex()\n        {\n            InitializeCriticalSection(&cs_);\n        }\n\n\n        Mutex::~Mutex()\n        {\n            DeleteCriticalSection(&cs_);\n        }\n\n            \n        Mutex::Lock::Lock(Mutex& lm) : mutex_(lm)\n        {\n            EnterCriticalSection(&mutex_.cs_); \n        }\n\n\n        Mutex::Lock::~Lock()\n        {\n            LeaveCriticalSection(&mutex_.cs_); \n        }\n            \n    #else  // _WIN32\n        \n        Mutex::Mutex()\n        {\n            pthread_mutex_init(&mutex_, 0);\n        }\n\n\n        Mutex::~Mutex()\n        {\n            pthread_mutex_destroy(&mutex_);\n        }\n\n\n        Mutex::Lock::Lock(Mutex& lm) : mutex_(lm)\n        {\n            pthread_mutex_lock(&mutex_.mutex_); \n        }\n\n\n        Mutex::Lock::~Lock()\n        {\n            pthread_mutex_unlock(&mutex_.mutex_); \n        }\n         \n\n    #endif // _WIN32\n#endif // MULTI_THREADED\n\n\n\n} // namespace yaSSL\n\n"
  },
  {
    "path": "ext/yassl/src/log.cpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/*  Debug logging functions\n */\n\n\n#include \"runtime.hpp\"\n#include \"log.hpp\"\n\n#ifdef YASSL_LOG\n    #include <time.h>\n    #include <stdio.h>\n    #include <string.h>\n#endif\n\n\n\nnamespace yaSSL {\n\n\n#ifdef YASSL_LOG\n\n    enum { MAX_MSG = 81 };\n\n    Log::Log(const char* str)\n    {\n        log_ = fopen(str, \"w\");\n        Trace(\"********** Logger Attached **********\");\n    }\n\n\n    Log::~Log()\n    {\n        Trace(\"********** Logger Detached **********\");\n        fclose(log_);\n    }\n\n\n    // Trace a message\n    void Log::Trace(const char* str)\n    {\n        if (!log_) return;\n\n        time_t clicks = time(0);\n        char   timeStr[32];\n\n        // get rid of newline\n        strncpy(timeStr, ctime(&clicks), sizeof(timeStr));\n        unsigned int len = strlen(timeStr);\n        timeStr[len - 1] = 0;\n\n        char msg[MAX_MSG];\n\n        strncpy(msg, timeStr, sizeof(timeStr));\n        strncat(msg, \":\", 1);\n        strncat(msg, str, MAX_MSG - sizeof(timeStr) - 2);\n        strncat(msg, \"\\n\", 1);\n        msg[MAX_MSG - 1] = 0;\n\n        fputs(msg, log_);\n    }\n\n\n    #if defined(_WIN32) || defined(__MACH__) || defined(__hpux__)\n        typedef int socklen_t;\n    #endif\n\n\n    // write tcp address\n    void Log::ShowTCP(socket_t fd, bool ended)\n    {\n        sockaddr_in peeraddr;\n        socklen_t   len = sizeof(peeraddr);\n        if (getpeername(fd, (sockaddr*)&peeraddr, &len) != 0)\n            return;\n\n        const char* p = reinterpret_cast<const char*>(&peeraddr.sin_addr);\n        char msg[MAX_MSG];\n        char number[16];\n    \n        if (ended)\n            strncpy(msg, \"yaSSL conn DONE  w/ peer \", 26);\n        else\n            strncpy(msg, \"yaSSL conn BEGUN w/ peer \", 26);\n        for (int i = 0; i < 4; ++i) {\n            sprintf(number, \"%u\", static_cast<unsigned short>(p[i]));\n            strncat(msg, number, 8);\n            if (i < 3)\n                strncat(msg, \".\", 1);\n        }\n        strncat(msg, \" port \", 8);\n        sprintf(number, \"%d\", htons(peeraddr.sin_port));\n        strncat(msg, number, 8);\n\n        msg[MAX_MSG - 1] = 0;\n        Trace(msg);\n    }\n\n\n    // log processed data\n    void Log::ShowData(uint bytes, bool sent)\n    {\n        char msg[MAX_MSG];\n        char number[16];\n\n        if (sent)\n            strncpy(msg, \"Sent     \", 10); \n        else\n            strncpy(msg, \"Received \", 10);\n        sprintf(number, \"%u\", bytes);\n        strncat(msg, number, 8);\n        strncat(msg, \" bytes of application data\", 27);\n\n        msg[MAX_MSG - 1] = 0;\n        Trace(msg);\n    }\n\n\n#else // no YASSL_LOG\n\n\n    Log::Log(const char*) {}\n    Log::~Log() {}\n    void Log::Trace(const char*) {}\n    void Log::ShowTCP(socket_t, bool) {}\n    void Log::ShowData(uint, bool) {}\n\n\n#endif // YASSL_LOG\n} // namespace\n"
  },
  {
    "path": "ext/yassl/src/make.bat",
    "content": "REM Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.\nREM \nREM This program is free software; you can redistribute it and/or modify\nREM it under the terms of the GNU General Public License as published by\nREM the Free Software Foundation; version 2 of the License.\nREM \nREM This program is distributed in the hope that it will be useful,\nREM but WITHOUT ANY WARRANTY; without even the implied warranty of\nREM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nREM GNU General Public License for more details.\nREM \nREM You should have received a copy of the GNU General Public License\nREM along with this program; if not, write to the Free Software\nREM Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\n\nREM quick and dirty build file for testing different MSDEVs\nsetlocal \n\nset myFLAGS= /I../include /I../taocrypt/mySTL /I../taocrypt/include /W3 /c /ZI\n\ncl %myFLAGS% buffer.cpp\ncl %myFLAGS% cert_wrapper.cpp\ncl %myFLAGS% crypto_wrapper.cpp\ncl %myFLAGS% handshake.cpp\n\ncl %myFLAGS% lock.cpp\ncl %myFLAGS% log.cpp\ncl %myFLAGS% socket_wrapper.cpp\ncl %myFLAGS% ssl.cpp\n\ncl %myFLAGS% template_instnt.cpp\ncl %myFLAGS% timer.cpp\ncl %myFLAGS% yassl.cpp\ncl %myFLAGS% yassl_error.cpp\n\ncl %myFLAGS% yassl_imp.cpp\ncl %myFLAGS% yassl_int.cpp\n\nlink.exe -lib /out:yassl.lib buffer.obj cert_wrapper.obj crypto_wrapper.obj handshake.obj lock.obj log.obj socket_wrapper.obj ssl.obj template_instnt.obj timer.obj yassl.obj yassl_error.obj yassl_imp.obj yassl_int.obj\n\n\n\n"
  },
  {
    "path": "ext/yassl/src/socket_wrapper.cpp",
    "content": "/*\n   Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* The socket wrapper source implements a Socket class that hides the \n * differences between Berkely style sockets and Windows sockets, allowing \n * transparent TCP access.\n */\n\n\n#include \"runtime.hpp\"\n#include \"socket_wrapper.hpp\"\n\n#ifndef _WIN32\n    #include <errno.h>\n    #include <netdb.h>\n    #include <unistd.h>\n    #include <arpa/inet.h>\n    #include <netinet/in.h>\n    #include <sys/ioctl.h>\n    #include <string.h>\n    #include <fcntl.h>\n#endif // _WIN32\n\n#if defined(__sun) || defined(__SCO_VERSION__)\n    #include <sys/filio.h>\n#endif\n\n#ifdef _WIN32\n    const int SOCKET_EINVAL = WSAEINVAL;\n    const int SOCKET_EWOULDBLOCK = WSAEWOULDBLOCK;\n    const int SOCKET_EAGAIN = WSAEWOULDBLOCK;\n#else\n    const int SOCKET_EINVAL = EINVAL;\n    const int SOCKET_EWOULDBLOCK = EWOULDBLOCK;\n    const int SOCKET_EAGAIN = EAGAIN;\n#endif // _WIN32\n\n\nnamespace {\n\n\nextern \"C\" long system_recv(void *ptr, void *buf, size_t count)\n{\n  yaSSL::socket_t *socket = (yaSSL::socket_t *) ptr;\n  return ::recv(*socket, reinterpret_cast<char *>(buf), count, 0);\n}\n\n\nextern \"C\" long system_send(void *ptr, const void *buf, size_t count)\n{\n  yaSSL::socket_t *socket = (yaSSL::socket_t *) ptr;\n  return ::send(*socket, reinterpret_cast<const char *>(buf), count, 0);\n}\n\n\n}\n\n\nnamespace yaSSL {\n\n\nSocket::Socket(socket_t s) \n    : socket_(s), wouldBlock_(false), nonBlocking_(false),\n      ptr_(&socket_), send_func_(system_send), recv_func_(system_recv)\n{}\n\n\nvoid Socket::set_fd(socket_t s)\n{\n    socket_ = s;\n}\n\n\nsocket_t Socket::get_fd() const\n{\n    return socket_;\n}\n\n\nSocket::~Socket()\n{\n    // don't close automatically now\n}\n\n\nvoid Socket::closeSocket()\n{\n    if (socket_ != INVALID_SOCKET) {\n#ifdef _WIN32\n        closesocket(socket_);\n#else\n        close(socket_);\n#endif\n        socket_ = INVALID_SOCKET;\n    }\n}\n\n\nuint Socket::get_ready() const\n{\n#ifdef _WIN32\n    unsigned long ready = 0;\n    ioctlsocket(socket_, FIONREAD, &ready);\n#else\n    /*\n       64-bit Solaris requires the variable passed to\n       FIONREAD be a 32-bit value.\n    */\n    unsigned int ready = 0;\n    ioctl(socket_, FIONREAD, &ready);\n#endif\n\n    return ready;\n}\n\n\nvoid Socket::set_transport_ptr(void *ptr)\n{\n  ptr_ = ptr;\n}\n\n\nvoid Socket::set_transport_recv_function(yaSSL_recv_func_t recv_func)\n{\n  recv_func_ = recv_func;\n}\n\n\nvoid Socket::set_transport_send_function(yaSSL_send_func_t send_func)\n{\n  send_func_ = send_func;\n}\n\n\nuint Socket::send(const byte* buf, unsigned int sz, unsigned int& written)\n{\n    const byte* pos = buf;\n    const byte* end = pos + sz;\n\n    wouldBlock_ = false;\n\n    /* Remove send()/recv() hooks once non-blocking send is implemented. */\n    while (pos != end) {\n        int sent = send_func_(ptr_, pos, static_cast<int>(end - pos));\n        if (sent == -1) {\n            if (get_lastError() == SOCKET_EWOULDBLOCK || \n                get_lastError() == SOCKET_EAGAIN) {\n                wouldBlock_  = true; // would have blocked this time only\n                nonBlocking_ = true; // nonblocking, win32 only way to tell \n                return 0;\n            }\n            return static_cast<uint>(-1);\n        }\n        pos += sent;\n        written += sent;\n    }\n\n    return sz;\n}\n\n\nuint Socket::receive(byte* buf, unsigned int sz)\n{\n    wouldBlock_ = false;\n\n    int recvd = recv_func_(ptr_, buf, sz);\n\n    // idea to seperate error from would block by arnetheduck@gmail.com\n    if (recvd == -1) {\n        if (get_lastError() == SOCKET_EWOULDBLOCK || \n            get_lastError() == SOCKET_EAGAIN) {\n            wouldBlock_  = true; // would have blocked this time only\n            nonBlocking_ = true; // socket nonblocking, win32 only way to tell\n            return 0;\n        }\n    }\n    else if (recvd == 0)\n        return static_cast<uint>(-1);\n\n    return recvd;\n}\n\n\nvoid Socket::shutDown(int how)\n{\n    shutdown(socket_, how);\n}\n\n\nint Socket::get_lastError()\n{\n#ifdef _WIN32\n    return WSAGetLastError();\n#else\n    return errno;\n#endif\n}\n\n\nbool Socket::WouldBlock() const\n{\n    return wouldBlock_;\n}\n\n\nbool Socket::IsNonBlocking() const\n{\n    return nonBlocking_;\n}\n\n\nvoid Socket::set_lastError(int errorCode)\n{\n#ifdef _WIN32\n    WSASetLastError(errorCode);\n#else\n    errno = errorCode;\n#endif\n}\n\n\n} // namespace\n"
  },
  {
    "path": "ext/yassl/src/ssl.cpp",
    "content": "/*\n   Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/*  SSL source implements all openssl compatibility API functions\n *\n *  TODO: notes are mostly api additions to allow compilation with mysql\n *  they don't affect normal modes but should be provided for completeness\n\n *  stunnel functions at end of file\n */\n\n\n\n/*  see man pages for function descriptions */\n\n#include \"runtime.hpp\"\n#include \"openssl/ssl.h\"\n#include \"handshake.hpp\"\n#include \"yassl_int.hpp\"\n#include \"md5.hpp\"              // for TaoCrypt MD5 size assert\n#include \"md4.hpp\"              // for TaoCrypt MD4 size assert\n#include \"file.hpp\"             // for TaoCrypt Source\n#include \"coding.hpp\"           // HexDecoder\n#include \"helpers.hpp\"          // for placement new hack\n#include \"rsa.hpp\"              // for TaoCrypt RSA key decode\n#include \"dsa.hpp\"              // for TaoCrypt DSA key decode\n#include <stdio.h>\n\n#ifdef _WIN32\n    #include <windows.h>    // FindFirstFile etc..\n#else\n    #include <sys/types.h>  // file helper\n    #include <sys/stat.h>   // stat\n    #include <dirent.h>     // opendir\n#endif\n\n\nnamespace yaSSL {\n\n\n\nint read_file(SSL_CTX* ctx, const char* file, int format, CertType type)\n{\n    int ret = SSL_SUCCESS;\n\n    if (format != SSL_FILETYPE_ASN1 && format != SSL_FILETYPE_PEM)\n        return SSL_BAD_FILETYPE;\n\n    if (file == NULL || !file[0])\n      return SSL_BAD_FILE;\n\n    FILE* input = fopen(file, \"rb\");\n    if (!input)\n        return SSL_BAD_FILE;\n\n    if (type == CA) {\n        // may have a bunch of CAs\n        x509* ptr;\n        while ( (ptr = PemToDer(input, Cert)) )\n            ctx->AddCA(ptr);\n\n        if (!feof(input)) {\n            fclose(input);\n            return SSL_BAD_FILE;\n        }\n    }\n    else {\n        x509*& x = (type == Cert) ? ctx->certificate_ : ctx->privateKey_;\n\n        if (format == SSL_FILETYPE_ASN1) {\n            fseek(input, 0, SEEK_END);\n            long sz = ftell(input);\n            rewind(input);\n            x = NEW_YS x509(sz); // takes ownership\n            size_t bytes = fread(x->use_buffer(), sz, 1, input);\n            if (bytes != 1) {\n                fclose(input);\n                return SSL_BAD_FILE;\n            }\n        }\n        else {\n            EncryptedInfo info;\n            x = PemToDer(input, type, &info);\n            if (!x) {\n                fclose(input);\n                return SSL_BAD_FILE;\n            }\n            if (info.set) {\n                // decrypt\n                char password[80];\n                pem_password_cb cb = ctx->GetPasswordCb();\n                if (!cb) {\n                    fclose(input);\n                    return SSL_BAD_FILE;\n                }\n                int passwordSz = cb(password, sizeof(password), 0,\n                                    ctx->GetUserData());\n                byte key[AES_256_KEY_SZ];  // max sizes\n                byte iv[AES_IV_SZ];\n                \n                // use file's salt for key derivation, but not real iv\n                TaoCrypt::Source source(info.iv, info.ivSz);\n                TaoCrypt::HexDecoder dec(source);\n                memcpy(info.iv, source.get_buffer(), min((uint)sizeof(info.iv),\n                                                         source.size()));\n                EVP_BytesToKey(info.name, \"MD5\", info.iv, (byte*)password,\n                               passwordSz, 1, key, iv);\n\n                mySTL::auto_ptr<BulkCipher> cipher;\n                if (strncmp(info.name, \"DES-CBC\", 7) == 0)\n                    cipher.reset(NEW_YS DES);\n                else if (strncmp(info.name, \"DES-EDE3-CBC\", 13) == 0)\n                    cipher.reset(NEW_YS DES_EDE);\n                else if (strncmp(info.name, \"AES-128-CBC\", 13) == 0)\n                    cipher.reset(NEW_YS AES(AES_128_KEY_SZ));\n                else if (strncmp(info.name, \"AES-192-CBC\", 13) == 0)\n                    cipher.reset(NEW_YS AES(AES_192_KEY_SZ));\n                else if (strncmp(info.name, \"AES-256-CBC\", 13) == 0)\n                    cipher.reset(NEW_YS AES(AES_256_KEY_SZ));\n                else {\n                    fclose(input);\n                    return SSL_BAD_FILE;\n                }\n                cipher->set_decryptKey(key, info.iv);\n                mySTL::auto_ptr<x509> newx(NEW_YS x509(x->get_length()));   \n                cipher->decrypt(newx->use_buffer(), x->get_buffer(),\n                                x->get_length());\n                ysDelete(x);\n                x = newx.release();\n            }\n        }\n    }\n\n    if (type == PrivateKey && ctx->privateKey_) {\n        // see if key is valid early\n        TaoCrypt::Source rsaSource(ctx->privateKey_->get_buffer(),\n                                   ctx->privateKey_->get_length());\n        TaoCrypt::RSA_PrivateKey rsaKey;\n        rsaKey.Initialize(rsaSource);\n\n        if (rsaSource.GetError().What()) {\n            // rsa failed see if DSA works\n\n            TaoCrypt::Source dsaSource(ctx->privateKey_->get_buffer(),\n                                       ctx->privateKey_->get_length());\n            TaoCrypt::DSA_PrivateKey dsaKey;\n            dsaKey.Initialize(dsaSource);\n\n            if (rsaSource.GetError().What()) {\n                // neither worked\n                ret = SSL_FAILURE;\n            }\n        }\n    }\n\n    fclose(input);\n    return ret;\n}\n\n\nextern \"C\" {\n\n\nSSL_METHOD* SSLv3_method()\n{\n    return SSLv3_client_method();\n}\n\n\nSSL_METHOD* SSLv3_server_method()\n{\n    return NEW_YS SSL_METHOD(server_end, ProtocolVersion(3,0));\n}\n\n\nSSL_METHOD* SSLv3_client_method()\n{\n    return NEW_YS SSL_METHOD(client_end, ProtocolVersion(3,0));\n}\n\n\nSSL_METHOD* TLSv1_server_method()\n{\n    return NEW_YS SSL_METHOD(server_end, ProtocolVersion(3,1));\n}\n\n\nSSL_METHOD* TLSv1_client_method()\n{\n    return NEW_YS SSL_METHOD(client_end, ProtocolVersion(3,1));\n}\n\n\nSSL_METHOD* TLSv1_1_server_method()\n{\n    return NEW_YS SSL_METHOD(server_end, ProtocolVersion(3,2));\n}\n\n\nSSL_METHOD* TLSv1_1_client_method()\n{\n    return NEW_YS SSL_METHOD(client_end, ProtocolVersion(3,2));\n}\n\n\nSSL_METHOD* SSLv23_server_method()\n{\n    // compatibility only, no version 2 support, but does SSL 3 and TLS 1\n    return NEW_YS SSL_METHOD(server_end, ProtocolVersion(3,2), true);\n}\n\n\nSSL_METHOD* SSLv23_client_method()\n{\n    // compatibility only, no version 2 support, but does SSL 3 and TLS 1\n    // though it sends TLS1 hello not SSLv2 so SSLv3 only servers will decline\n    // TODO: maybe add support to send SSLv2 hello ???\n    return NEW_YS SSL_METHOD(client_end, ProtocolVersion(3,2), true);\n}\n\n\nSSL_CTX* SSL_CTX_new(SSL_METHOD* method)\n{\n    return NEW_YS SSL_CTX(method);\n}\n\n\nvoid SSL_CTX_free(SSL_CTX* ctx)\n{\n    ysDelete(ctx);\n}\n\n\nSSL* SSL_new(SSL_CTX* ctx)\n{\n    return NEW_YS SSL(ctx);\n}\n\n\nvoid SSL_free(SSL* ssl)\n{\n    ysDelete(ssl);\n}\n\n\nint SSL_set_fd(SSL* ssl, YASSL_SOCKET_T fd)\n{\n    ssl->useSocket().set_fd(fd);\n    return SSL_SUCCESS;\n}\n\n\nYASSL_SOCKET_T SSL_get_fd(const SSL* ssl)\n{\n    return ssl->getSocket().get_fd();\n}\n\n\n// if you get an error from connect see note at top of README\nint SSL_connect(SSL* ssl)\n{\n    if (ssl->GetError() == YasslError(SSL_ERROR_WANT_READ))\n        ssl->SetError(no_error);\n\n    if (ssl->GetError() == YasslError(SSL_ERROR_WANT_WRITE)) {\n    \n        ssl->SetError(no_error);\n        ssl->SendWriteBuffered();\n        if (!ssl->GetError())\n            ssl->useStates().UseConnect() =\n                             ConnectState(ssl->getStates().GetConnect() + 1);\n    }\n\n    ClientState neededState;\n\n    switch (ssl->getStates().GetConnect()) {\n\n    case CONNECT_BEGIN :\n        sendClientHello(*ssl);\n        if (!ssl->GetError())\n            ssl->useStates().UseConnect() = CLIENT_HELLO_SENT;\n\n    case CLIENT_HELLO_SENT :\n        neededState = ssl->getSecurity().get_resuming() ?\n                      serverFinishedComplete : serverHelloDoneComplete;\n        while (ssl->getStates().getClient() < neededState) {\n            if (ssl->GetError()) break;\n            processReply(*ssl);\n            // if resumption failed, reset needed state \n            if (neededState == serverFinishedComplete)\n                if (!ssl->getSecurity().get_resuming())\n                    neededState = serverHelloDoneComplete;\n        }\n        if (!ssl->GetError())\n            ssl->useStates().UseConnect() = FIRST_REPLY_DONE;\n\n    case FIRST_REPLY_DONE :\n        if(ssl->getCrypto().get_certManager().sendVerify())\n            sendCertificate(*ssl);\n\n        if (!ssl->getSecurity().get_resuming())\n            sendClientKeyExchange(*ssl);\n\n        if(ssl->getCrypto().get_certManager().sendVerify())\n            sendCertificateVerify(*ssl);\n\n        sendChangeCipher(*ssl);\n        sendFinished(*ssl, client_end);\n        ssl->flushBuffer();\n\n        if (!ssl->GetError())\n            ssl->useStates().UseConnect() = FINISHED_DONE;\n\n    case FINISHED_DONE :\n        if (!ssl->getSecurity().get_resuming())\n            while (ssl->getStates().getClient() < serverFinishedComplete) {\n                if (ssl->GetError()) break;\n                processReply(*ssl);\n            }\n        if (!ssl->GetError())\n            ssl->useStates().UseConnect() = SECOND_REPLY_DONE;\n\n    case SECOND_REPLY_DONE :\n        ssl->verifyState(serverFinishedComplete);\n        ssl->useLog().ShowTCP(ssl->getSocket().get_fd());\n\n        if (ssl->GetError()) {\n            GetErrors().Add(ssl->GetError());\n            return SSL_FATAL_ERROR;\n        }   \n        return SSL_SUCCESS;\n\n    default :\n        return SSL_FATAL_ERROR; // unkown state\n    }\n}\n\n\nint SSL_write(SSL* ssl, const void* buffer, int sz)\n{\n    return sendData(*ssl, buffer, sz);\n}\n\n\nint SSL_read(SSL* ssl, void* buffer, int sz)\n{\n    Data data(min(sz, MAX_RECORD_SIZE), static_cast<opaque*>(buffer));\n    return receiveData(*ssl, data);\n}\n\n\nint SSL_accept(SSL* ssl)\n{\n    if (ssl->GetError() == YasslError(SSL_ERROR_WANT_READ))\n        ssl->SetError(no_error);\n\n    if (ssl->GetError() == YasslError(SSL_ERROR_WANT_WRITE)) {\n    \n        ssl->SetError(no_error);\n        ssl->SendWriteBuffered();\n        if (!ssl->GetError())\n            ssl->useStates().UseAccept() =\n                             AcceptState(ssl->getStates().GetAccept() + 1);\n    }\n\n    switch (ssl->getStates().GetAccept()) {\n\n    case ACCEPT_BEGIN :\n        processReply(*ssl);\n        if (!ssl->GetError())\n            ssl->useStates().UseAccept() = ACCEPT_FIRST_REPLY_DONE;\n\n    case ACCEPT_FIRST_REPLY_DONE :\n        sendServerHello(*ssl);\n\n        if (!ssl->getSecurity().get_resuming()) {\n            sendCertificate(*ssl);\n\n            if (ssl->getSecurity().get_connection().send_server_key_)\n                sendServerKeyExchange(*ssl);\n\n            if(ssl->getCrypto().get_certManager().verifyPeer())\n                sendCertificateRequest(*ssl);\n\n            sendServerHelloDone(*ssl);\n            ssl->flushBuffer();\n        }\n      \n        if (!ssl->GetError())\n            ssl->useStates().UseAccept() = SERVER_HELLO_DONE;\n\n    case SERVER_HELLO_DONE :\n        if (!ssl->getSecurity().get_resuming()) {\n            while (ssl->getStates().getServer() < clientFinishedComplete) {\n                if (ssl->GetError()) break;\n                processReply(*ssl);\n            }\n        }\n        if (!ssl->GetError())\n            ssl->useStates().UseAccept() = ACCEPT_SECOND_REPLY_DONE;\n\n    case ACCEPT_SECOND_REPLY_DONE :\n        sendChangeCipher(*ssl);\n        sendFinished(*ssl, server_end);\n        ssl->flushBuffer();\n\n        if (!ssl->GetError())\n            ssl->useStates().UseAccept() = ACCEPT_FINISHED_DONE;\n\n    case ACCEPT_FINISHED_DONE :\n        if (ssl->getSecurity().get_resuming()) {\n            while (ssl->getStates().getServer() < clientFinishedComplete) {\n                if (ssl->GetError()) break;\n                processReply(*ssl);\n            }\n        }\n        if (!ssl->GetError())\n            ssl->useStates().UseAccept() = ACCEPT_THIRD_REPLY_DONE;\n\n    case ACCEPT_THIRD_REPLY_DONE :\n        ssl->useLog().ShowTCP(ssl->getSocket().get_fd());\n\n        if (ssl->GetError()) {\n            GetErrors().Add(ssl->GetError());\n            return SSL_FATAL_ERROR;\n        }\n        return SSL_SUCCESS;\n\n    default:\n        return SSL_FATAL_ERROR; // unknown state\n    }\n}\n\n\nint SSL_do_handshake(SSL* ssl)\n{\n    if (ssl->getSecurity().get_parms().entity_ == client_end)\n        return SSL_connect(ssl);\n    else\n        return SSL_accept(ssl);\n}\n\n\nint SSL_clear(SSL* ssl)\n{\n    GetErrors().Remove();\n\n    return SSL_SUCCESS;\n}\n\n\nint SSL_shutdown(SSL* ssl)\n{\n    if (!ssl->GetQuietShutdown()) {\n      Alert alert(warning, close_notify);\n      sendAlert(*ssl, alert);\n    }\n    ssl->useLog().ShowTCP(ssl->getSocket().get_fd(), true);\n\n    GetErrors().Remove();\n\n    return SSL_SUCCESS;\n}\n\n\nvoid SSL_set_quiet_shutdown(SSL *ssl,int mode)\n{\n    ssl->SetQuietShutdown(mode != 0);\n}\n\n\nint SSL_get_quiet_shutdown(SSL *ssl)\n{\n    return ssl->GetQuietShutdown();\n}\n\n\n/* on by default but allow user to turn off */\nlong SSL_CTX_set_session_cache_mode(SSL_CTX* ctx, long mode)\n{\n    if (mode == SSL_SESS_CACHE_OFF)\n        ctx->SetSessionCacheOff();\n\n    if (mode == SSL_SESS_CACHE_NO_AUTO_CLEAR)\n        ctx->SetSessionCacheFlushOff();\n\n    return SSL_SUCCESS;\n}\n\n\nSSL_SESSION* SSL_get_session(SSL* ssl)\n{\n    if (ssl->getSecurity().GetContext()->GetSessionCacheOff())\n        return 0;\n\n    return GetSessions().lookup(\n        ssl->getSecurity().get_connection().sessionID_);\n}\n\n\nint SSL_set_session(SSL* ssl, SSL_SESSION* session)\n{\n    if (ssl->getSecurity().GetContext()->GetSessionCacheOff())\n        return SSL_FAILURE;\n\n    ssl->set_session(session);\n    return SSL_SUCCESS;\n}\n\n\nint SSL_session_reused(SSL* ssl)\n{\n    return ssl->getSecurity().get_resuming();\n}\n\n\nlong SSL_SESSION_set_timeout(SSL_SESSION* sess, long t)\n{\n    if (!sess)\n        return SSL_ERROR_NONE;\n\n    sess->SetTimeOut(t);\n    return SSL_SUCCESS;\n}\n\n\nlong SSL_get_default_timeout(SSL* /*ssl*/)\n{\n    return DEFAULT_TIMEOUT;\n}\n\n\nvoid SSL_flush_sessions(SSL_CTX *ctx, long /* tm */)\n{\n    if (ctx->GetSessionCacheOff())\n        return;\n\n    GetSessions().Flush();\n}\n\n\nconst char* SSL_get_cipher_name(SSL* ssl)\n{ \n    return SSL_get_cipher(ssl); \n}\n\n\nconst char* SSL_get_cipher(SSL* ssl)\n{\n    return ssl->getSecurity().get_parms().cipher_name_;\n}\n\n\n// SSLv2 only, not implemented\nchar* SSL_get_shared_ciphers(SSL* /*ssl*/, char* buf, int len)\n{\n    return strncpy(buf, \"Not Implemented, SSLv2 only\", len);\n}\n\n\nconst char* SSL_get_cipher_list(SSL* ssl, int priority)\n{\n    if (priority < 0 || priority >= MAX_CIPHERS)\n        return 0;\n\n    if (ssl->getSecurity().get_parms().cipher_list_[priority][0])\n        return ssl->getSecurity().get_parms().cipher_list_[priority];\n\n    return 0;\n}\n\n\nint SSL_CTX_set_cipher_list(SSL_CTX* ctx, const char* list)\n{\n    if (ctx->SetCipherList(list))\n        return SSL_SUCCESS;\n    else\n        return SSL_FAILURE;\n}\n\n\nconst char* SSL_get_version(SSL* ssl)\n{\n    static const char* version3 =  \"SSLv3\";\n    static const char* version31 = \"TLSv1\";\n\n    return ssl->isTLS() ? version31 : version3;\n}\n\nconst char* SSLeay_version(int)\n{\n    static const char* version = \"SSLeay yaSSL compatibility\";\n    return version;\n}\n\n\nint SSL_get_error(SSL* ssl, int /*previous*/)\n{\n    return ssl->getStates().What();\n}\n\n\n\n/* turn on yaSSL zlib compression\n   returns 0 for success, else error (not built in)\n   only need to turn on for client, becuase server on by default if built in\n   but calling for server will tell you whether it's available or not\n*/\nint SSL_set_compression(SSL* ssl)   /* Chad didn't rename to ya~ because it is prob. bug. */\n{\n    return ssl->SetCompression();\n}\n\n\n\nX509* X509_Copy(X509 *x)\n{\n    if (x == 0) return NULL;\n\n    X509_NAME* issuer   = x->GetIssuer();\n    X509_NAME* subject  = x->GetSubject();\n    ASN1_TIME* before = x->GetBefore();\n    ASN1_TIME* after  = x->GetAfter();\n\n    X509 *newX509 = NEW_YS X509(issuer->GetName(), issuer->GetLength(),\n        subject->GetName(), subject->GetLength(),\n        before, after);\n\n    return newX509;\n}\n\nX509* SSL_get_peer_certificate(SSL* ssl)\n{\n    return X509_Copy(ssl->getCrypto().get_certManager().get_peerX509());\n}\n\n\nvoid X509_free(X509* x)\n{\n    ysDelete(x);\n}\n\n\nX509* X509_STORE_CTX_get_current_cert(X509_STORE_CTX* ctx)\n{\n    return ctx->current_cert;\n}\n\n\nint X509_STORE_CTX_get_error(X509_STORE_CTX* ctx)\n{\n    return ctx->error;\n}\n\n\nint X509_STORE_CTX_get_error_depth(X509_STORE_CTX* ctx)\n{\n    return ctx->error_depth;\n}\n\nX509* PEM_read_X509(FILE *fp, X509 *x,\n                    pem_password_cb cb,\n                    void *u)\n{\n  if (fp == NULL)\n    return NULL;\n\n  // Get x509 handle and encryption information\n  x509* ptr = PemToDer(fp, Cert);\n  if (!ptr)\n      return NULL;\n\n  // Now decode x509 object.\n  TaoCrypt::SignerList signers;\n  TaoCrypt::Source source(ptr->get_buffer(), ptr->get_length());\n  TaoCrypt::CertDecoder cert(source, true, &signers, true, TaoCrypt::CertDecoder::CA);\n\n  if (cert.GetError().What()) {\n      ysDelete(ptr);\n      return NULL;\n  }\n\n  // Ok. Now create X509 object.\n  size_t iSz = strlen(cert.GetIssuer()) + 1;\n  size_t sSz = strlen(cert.GetCommonName()) + 1;\n  ASN1_STRING beforeDate, afterDate;\n  beforeDate.data = (unsigned char *) cert.GetBeforeDate();\n  beforeDate.type = cert.GetBeforeDateType();\n  beforeDate.length = strlen((char *) beforeDate.data) + 1;\n  afterDate.data = (unsigned char *) cert.GetAfterDate();\n  afterDate.type = cert.GetAfterDateType();\n  afterDate.length = strlen((char *) afterDate.data) + 1;\n\n  X509 *thisX509 = NEW_YS X509(cert.GetIssuer(), iSz, cert.GetCommonName(),\n                               sSz, &beforeDate, &afterDate);\n\n  ysDelete(ptr);\n  return thisX509;\n}\n\n// copy name into buffer, at most sz bytes, if buffer is null\n// will malloc buffer, caller responsible for freeing\nchar* X509_NAME_oneline(X509_NAME* name, char* buffer, int sz)\n{\n    if (!name->GetName()) return buffer;\n\n    int len    = (int)strlen(name->GetName()) + 1;\n    int copySz = min(len, sz);\n\n    if (!buffer) {\n        buffer = (char*)malloc(len);\n        if (!buffer) return buffer;\n        copySz = len;\n    }\n\n    if (copySz == 0)\n        return buffer;\n\n    memcpy(buffer, name->GetName(), copySz - 1);\n    buffer[copySz - 1] = 0;\n\n    return buffer;\n}\n\n\nX509_NAME* X509_get_issuer_name(X509* x)\n{\n    return  x->GetIssuer();\n}\n\n\nX509_NAME* X509_get_subject_name(X509* x)\n{\n    return x->GetSubject();\n}\n\n\nvoid SSL_load_error_strings()   // compatibility only \n{}\n\n\nvoid SSL_set_connect_state(SSL*)\n{\n    // already a client by default\n}\n\n\nvoid SSL_set_accept_state(SSL* ssl)\n{\n    ssl->useSecurity().use_parms().entity_ = server_end;\n}\n\n\nlong SSL_get_verify_result(SSL*)\n{\n    // won't get here if not OK\n    return X509_V_OK;\n}\n\n\nlong SSL_CTX_sess_set_cache_size(SSL_CTX* /*ctx*/, long /*sz*/)\n{\n    // unlimited size, can't set for now\n    return 0;\n}\n\n\nlong SSL_CTX_get_session_cache_mode(SSL_CTX*)\n{\n    // always 0, unlimited size for now\n    return 0;\n}\n\n\nlong SSL_CTX_set_tmp_dh(SSL_CTX* ctx, DH* dh)\n{\n    if (ctx->SetDH(*dh))\n        return SSL_SUCCESS;\n    else\n        return SSL_FAILURE;\n}\n\n\nint SSL_CTX_use_certificate_file(SSL_CTX* ctx, const char* file, int format)\n{\n    return read_file(ctx, file, format, Cert);\n}\n\n\nint SSL_CTX_use_PrivateKey_file(SSL_CTX* ctx, const char* file, int format)\n{\n    return read_file(ctx, file, format, PrivateKey);\n}\n\n\nvoid SSL_CTX_set_verify(SSL_CTX* ctx, int mode, VerifyCallback vc)\n{\n    if (mode & SSL_VERIFY_PEER)\n        ctx->setVerifyPeer();\n\n    if (mode == SSL_VERIFY_NONE)\n        ctx->setVerifyNone();\n\n    if (mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)\n        ctx->setFailNoCert();\n\n    ctx->setVerifyCallback(vc);\n}\n\n\nint SSL_CTX_load_verify_locations(SSL_CTX* ctx, const char* file,\n                                  const char* path)\n{\n    int       ret = SSL_FAILURE;\n    const int HALF_PATH = 128;\n\n    if (file) ret = read_file(ctx, file, SSL_FILETYPE_PEM, CA);\n\n    if (ret == SSL_SUCCESS && path) {\n        // call read_file for each reqular file in path\n#ifdef _WIN32\n\n        WIN32_FIND_DATA FindFileData;\n        HANDLE hFind;\n\n        char name[MAX_PATH + 1];  // directory specification\n        strncpy(name, path, MAX_PATH - 3);\n        strncat(name, \"\\\\*\", 3);\n\n        hFind = FindFirstFile(name, &FindFileData);\n        if (hFind == INVALID_HANDLE_VALUE) return SSL_BAD_PATH;\n\n        do {\n            if (FindFileData.dwFileAttributes != FILE_ATTRIBUTE_DIRECTORY) {\n                strncpy(name, path, MAX_PATH - 2 - HALF_PATH);\n                strncat(name, \"\\\\\", 2);\n                strncat(name, FindFileData.cFileName, HALF_PATH);\n                ret = read_file(ctx, name, SSL_FILETYPE_PEM, CA);\n            }\n        } while (ret == SSL_SUCCESS && FindNextFile(hFind, &FindFileData));\n\n        FindClose(hFind);\n\n#else   // _WIN32\n\n        const int MAX_PATH = 260;\n\n        DIR* dir = opendir(path);\n        if (!dir) return SSL_BAD_PATH;\n\n        struct dirent* entry;\n        struct stat    buf;\n        char           name[MAX_PATH + 1];\n\n        while (ret == SSL_SUCCESS && (entry = readdir(dir))) {\n            strncpy(name, path, MAX_PATH - 1 - HALF_PATH);\n            strncat(name, \"/\", 1);\n            strncat(name, entry->d_name, HALF_PATH);\n            if (stat(name, &buf) < 0) {\n                closedir(dir);\n                return SSL_BAD_STAT;\n            }\n     \n            if (S_ISREG(buf.st_mode))\n                ret = read_file(ctx, name, SSL_FILETYPE_PEM, CA);\n        }\n\n        closedir(dir);\n\n#endif\n    }\n\n    return ret;\n}\n\n\nint SSL_CTX_set_default_verify_paths(SSL_CTX* /*ctx*/)\n{\n    // TODO: figure out way to set/store default path, then call load_verify\n    return SSL_NOT_IMPLEMENTED;\n}\n\n\nint SSL_CTX_set_session_id_context(SSL_CTX*, const unsigned char*,\n                                    unsigned int)\n{\n    // No application specific context needed for yaSSL\n    return SSL_SUCCESS;\n}\n\n\nint SSL_CTX_check_private_key(SSL_CTX* /*ctx*/)\n{\n    // TODO: check private against public for RSA match\n    return SSL_NOT_IMPLEMENTED;\n}\n\n\n// TODO: all session stats\nlong SSL_CTX_sess_accept(SSL_CTX* ctx)\n{\n    return ctx->GetStats().accept_;\n}\n\n\nlong SSL_CTX_sess_connect(SSL_CTX* ctx)\n{\n    return ctx->GetStats().connect_;\n}\n\n\nlong SSL_CTX_sess_accept_good(SSL_CTX* ctx)\n{\n    return ctx->GetStats().acceptGood_;\n}\n\n\nlong SSL_CTX_sess_connect_good(SSL_CTX* ctx)\n{\n    return ctx->GetStats().connectGood_;\n}\n\n\nlong SSL_CTX_sess_accept_renegotiate(SSL_CTX* ctx)\n{\n    return ctx->GetStats().acceptRenegotiate_;\n}\n\n\nlong SSL_CTX_sess_connect_renegotiate(SSL_CTX* ctx)\n{\n    return ctx->GetStats().connectRenegotiate_;\n}\n\n\nlong SSL_CTX_sess_hits(SSL_CTX* ctx)\n{\n    return ctx->GetStats().hits_;\n}\n\n\nlong SSL_CTX_sess_cb_hits(SSL_CTX* ctx)\n{\n    return ctx->GetStats().cbHits_;\n}\n\n\nlong SSL_CTX_sess_cache_full(SSL_CTX* ctx)\n{\n    return ctx->GetStats().cacheFull_;\n}\n\n\nlong SSL_CTX_sess_misses(SSL_CTX* ctx)\n{\n    return ctx->GetStats().misses_;\n}\n\n\nlong SSL_CTX_sess_timeouts(SSL_CTX* ctx)\n{\n    return ctx->GetStats().timeouts_;\n}\n\n\nlong SSL_CTX_sess_number(SSL_CTX* ctx)\n{\n    return ctx->GetStats().number_;\n}\n\n\nlong SSL_CTX_sess_get_cache_size(SSL_CTX* ctx)\n{\n    return ctx->GetStats().getCacheSize_;\n}\n// end session stats TODO:\n\n\nint SSL_CTX_get_verify_mode(SSL_CTX* ctx)\n{\n    return ctx->GetStats().verifyMode_;\n}\n\n\nint SSL_get_verify_mode(SSL* ssl)\n{\n    return ssl->getSecurity().GetContext()->GetStats().verifyMode_;\n}\n\n\nint SSL_CTX_get_verify_depth(SSL_CTX* ctx)\n{\n    return ctx->GetStats().verifyDepth_;\n}\n\n\nint SSL_get_verify_depth(SSL* ssl)\n{\n    return ssl->getSecurity().GetContext()->GetStats().verifyDepth_;\n}\n\n\nlong SSL_CTX_set_options(SSL_CTX*, long)\n{\n    // TDOD:\n    return SSL_SUCCESS;\n}\n\n\nvoid SSL_CTX_set_info_callback(SSL_CTX*, void (*)())\n{\n    // TDOD:\n}\n\n\nvoid OpenSSL_add_all_algorithms()  // compatibility only\n{}\n\n\nint SSL_library_init()  // compatiblity only\n{\n    return 1;\n}\n\n\nDH* DH_new(void)\n{\n    DH* dh = NEW_YS DH;\n    if (dh)\n        dh->p = dh->g = 0;\n    return dh;\n}\n\n\nvoid DH_free(DH* dh)\n{\n    ysDelete(dh->g);\n    ysDelete(dh->p);\n    ysDelete(dh);\n}\n\n\n// convert positive big-endian num of length sz into retVal, which may need to \n// be created\nBIGNUM* BN_bin2bn(const unsigned char* num, int sz, BIGNUM* retVal)\n{\n    bool created = false;\n    mySTL::auto_ptr<BIGNUM> bn;\n\n    if (!retVal) {\n        created = true;\n        bn.reset(NEW_YS BIGNUM);\n        retVal = bn.get();\n    }\n\n    retVal->assign(num, sz);\n\n    if (created)\n        return bn.release();\n    else\n        return retVal;\n}\n\n\nunsigned long ERR_get_error_line_data(const char**, int*, const char**, int *)\n{\n    //return SSL_NOT_IMPLEMENTED;\n    return 0;\n}\n\n\nvoid ERR_print_errors_fp(FILE* /*fp*/)\n{\n    // need ssl access to implement TODO:\n    //fprintf(fp, \"%s\", ssl.get_states().errorString_.c_str());\n}\n\n\nchar* ERR_error_string(unsigned long errNumber, char* buffer)\n{\n  static char* msg = (char*)\"Please supply a buffer for error string\";\n\n    if (buffer) {\n        SetErrorString(YasslError(errNumber), buffer);\n        return buffer;\n    }\n\n    return msg;\n}\n\n\nconst char* X509_verify_cert_error_string(long /* error */)\n{\n    // TODO:\n    static const char* msg = \"Not Implemented\";\n    return msg;\n}\n\n\nconst EVP_MD* EVP_md5(void)\n{\n    static const char* type = \"MD5\";\n    return type;\n}\n\n\nconst EVP_CIPHER* EVP_des_ede3_cbc(void)\n{\n    static const char* type = \"DES-EDE3-CBC\";\n    return type;\n}\n\n\nint EVP_BytesToKey(const EVP_CIPHER* type, const EVP_MD* md, const byte* salt,\n                   const byte* data, int sz, int count, byte* key, byte* iv)\n{\n    // only support MD5 for now\n    if (strncmp(md, \"MD5\", 3)) return 0;\n\n    int keyLen = 0;\n    int ivLen  = 0;\n\n    // only support CBC DES and AES for now\n    if (strncmp(type, \"DES-CBC\", 7) == 0) {\n        keyLen = DES_KEY_SZ;\n        ivLen  = DES_IV_SZ;\n    }\n    else if (strncmp(type, \"DES-EDE3-CBC\", 12) == 0) {\n        keyLen = DES_EDE_KEY_SZ;\n        ivLen  = DES_IV_SZ;\n    }\n    else if (strncmp(type, \"AES-128-CBC\", 11) == 0) {\n        keyLen = AES_128_KEY_SZ;\n        ivLen  = AES_IV_SZ;\n    }\n    else if (strncmp(type, \"AES-192-CBC\", 11) == 0) {\n        keyLen = AES_192_KEY_SZ;\n        ivLen  = AES_IV_SZ;\n    }\n    else if (strncmp(type, \"AES-256-CBC\", 11) == 0) {\n        keyLen = AES_256_KEY_SZ;\n        ivLen  = AES_IV_SZ;\n    }\n    else\n        return 0;\n\n    yaSSL::MD5 myMD;\n    uint digestSz = myMD.get_digestSize();\n    byte digest[SHA_LEN];                   // max size\n\n    int keyLeft   = keyLen;\n    int ivLeft    = ivLen;\n    int keyOutput = 0;\n\n    while (keyOutput < (keyLen + ivLen)) {\n        int digestLeft = digestSz;\n        // D_(i - 1)\n        if (keyOutput)                      // first time D_0 is empty\n            myMD.update(digest, digestSz);\n        // data\n        myMD.update(data, sz);\n        // salt\n        if (salt)\n            myMD.update(salt, EVP_SALT_SZ);\n        myMD.get_digest(digest);\n        // count\n        for (int j = 1; j < count; j++) {\n            myMD.update(digest, digestSz);\n            myMD.get_digest(digest);\n        }\n\n        if (keyLeft) {\n            int store = min(keyLeft, static_cast<int>(digestSz));\n            memcpy(&key[keyLen - keyLeft], digest, store);\n\n            keyOutput  += store;\n            keyLeft    -= store;\n            digestLeft -= store;\n        }\n\n        if (ivLeft && digestLeft) {\n            int store = min(ivLeft, digestLeft);\n            memcpy(&iv[ivLen - ivLeft], &digest[digestSz - digestLeft], store);\n\n            keyOutput += store;\n            ivLeft    -= store;\n        }\n    }\n    return keyOutput;\n}\n\n\n\nvoid DES_set_key_unchecked(const_DES_cblock* key, DES_key_schedule* schedule)\n{\n    memcpy(schedule, key, sizeof(const_DES_cblock));\n}\n\n\nvoid DES_ede3_cbc_encrypt(const byte* input, byte* output, long sz,\n                          DES_key_schedule* ks1, DES_key_schedule* ks2,\n                          DES_key_schedule* ks3, DES_cblock* ivec, int enc)\n{\n    DES_EDE des;\n    byte key[DES_EDE_KEY_SZ];\n\n    memcpy(key, *ks1, DES_BLOCK);\n    memcpy(&key[DES_BLOCK], *ks2, DES_BLOCK);\n    memcpy(&key[DES_BLOCK * 2], *ks3, DES_BLOCK);\n\n    if (enc) {\n        des.set_encryptKey(key, *ivec);\n        des.encrypt(output, input, sz);\n    }\n    else {\n        des.set_decryptKey(key, *ivec);\n        des.decrypt(output, input, sz);\n    }\n}\n\n\n// functions for libcurl\nint RAND_status()\n{\n    return 1;  /* TaoCrypt provides enough seed */\n}\n\n\nint DES_set_key(const_DES_cblock* key, DES_key_schedule* schedule)\n{\n    memcpy(schedule, key, sizeof(const_DES_cblock));\n    return 1;\n}\n\n\nvoid DES_set_odd_parity(DES_cblock* key)\n{\n    // not needed now for TaoCrypt\n}\n\n\nvoid DES_ecb_encrypt(DES_cblock* input, DES_cblock* output,\n                     DES_key_schedule* key, int enc)\n{\n    DES  des;\n\n    if (enc) {\n        des.set_encryptKey(*key, 0);\n        des.encrypt(*output, *input, DES_BLOCK);\n    }\n    else {\n        des.set_decryptKey(*key, 0);\n        des.decrypt(*output, *input, DES_BLOCK);\n    }\n}\n\n\nvoid SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX* ctx, void* userdata)\n{\n    ctx->SetUserData(userdata);\n}\n\n\nX509* SSL_get_certificate(SSL* ssl)\n{\n    return ssl->getCrypto().get_certManager().get_selfX509();\n}\n\n\nEVP_PKEY* SSL_get_privatekey(SSL* ssl)\n{\n    // only called, not used\n    return 0;\n}\n\n\nvoid SSL_SESSION_free(SSL_SESSION* session)\n{\n    // managed by singleton\n}\n\n\n\nEVP_PKEY* X509_get_pubkey(X509* x)\n{\n    // called, not used though\n    return 0;\n}\n\n\nint EVP_PKEY_copy_parameters(EVP_PKEY* to, const EVP_PKEY* from)\n{\n    // called, not used though\n    return 0;\n}\n\n\nvoid EVP_PKEY_free(EVP_PKEY* pkey)\n{\n    // never allocated from above\n}\n\n\nvoid ERR_error_string_n(unsigned long e, char *buf, size_t len)\n{\n    if (len) ERR_error_string(e, buf);\n}\n\n\nvoid ERR_free_strings(void)\n{\n    // handled internally\n}\n\n\nvoid EVP_cleanup(void)\n{\n    // nothing to do yet\n}\n\n\nASN1_TIME* X509_get_notBefore(X509* x)\n{\n    if (x) return x->GetBefore();\n    return 0;\n}\n\n\nASN1_TIME* X509_get_notAfter(X509* x)\n{\n    if (x) return x->GetAfter();\n    return 0;\n}\n\n\nSSL_METHOD* SSLv2_client_method(void)   /* will never work, no v 2    */\n{\n    return 0;\n}\n\n\nSSL_SESSION* SSL_get1_session(SSL* ssl)  /* what's ref count */\n{\n    return SSL_get_session(ssl);\n}\n\n\nvoid GENERAL_NAMES_free(STACK_OF(GENERAL_NAME) *x)\n{\n    // no extension names supported yet\n}\n\n\nint sk_GENERAL_NAME_num(STACK_OF(GENERAL_NAME) *x)\n{\n    // no extension names supported yet\n    return 0;\n}\n\n\nGENERAL_NAME* sk_GENERAL_NAME_value(STACK_OF(GENERAL_NAME) *x, int i)\n{\n    // no extension names supported yet\n    return 0;\n}\n\n\nunsigned char* ASN1_STRING_data(ASN1_STRING* x)\n{\n    if (x) return x->data;\n    return 0;\n}\n\n\nint ASN1_STRING_length(ASN1_STRING* x)\n{\n    if (x) return x->length;\n    return 0;\n}\n\n\nint ASN1_STRING_type(ASN1_STRING *x)\n{\n    if (x) return x->type;\n    return 0;\n}\n\n\nint X509_NAME_get_index_by_NID(X509_NAME* name,int nid, int lastpos)\n{\n    int idx = -1;  // not found\n    const char* start = &name->GetName()[lastpos + 1];\n\n    switch (nid) {\n    case NID_commonName:\n        const char* found = strstr(start, \"/CN=\");\n        if (found) {\n            found += 4;  // advance to str\n            idx = found - start + lastpos + 1;\n        }\n        break;\n    }\n\n    return idx;\n}\n\n\nASN1_STRING* X509_NAME_ENTRY_get_data(X509_NAME_ENTRY* ne)\n{\n    // the same in yaSSL\n    return ne;\n}\n\n\nX509_NAME_ENTRY* X509_NAME_get_entry(X509_NAME* name, int loc)\n{\n    return name->GetEntry(loc);\n}\n\n\n// already formatted, caller responsible for freeing *out\nint ASN1_STRING_to_UTF8(unsigned char** out, ASN1_STRING* in)\n{\n    if (!in) return 0;\n\n    *out = (unsigned char*)malloc(in->length + 1);\n    if (*out) {\n        memcpy(*out, in->data, in->length);\n        (*out)[in->length] = 0;\n    }\n    return in->length;\n}\n\n\nvoid* X509_get_ext_d2i(X509* x, int nid, int* crit, int* idx)\n{\n    // no extensions supported yet\n    return 0;\n}\n\n\nvoid MD4_Init(MD4_CTX* md4)\n{\n    // make sure we have a big enough buffer\n    typedef char ok[sizeof(md4->buffer) >= sizeof(TaoCrypt::MD4) ? 1 : -1];\n    (void) sizeof(ok);\n\n    // using TaoCrypt since no dynamic memory allocated\n    // and no destructor will be called\n    new (reinterpret_cast<yassl_pointer>(md4->buffer)) TaoCrypt::MD4();\n}\n\n\nvoid MD4_Update(MD4_CTX* md4, const void* data, unsigned long sz)\n{\n    reinterpret_cast<TaoCrypt::MD4*>(md4->buffer)->Update(\n                static_cast<const byte*>(data), static_cast<unsigned int>(sz));\n}\n\n\nvoid MD4_Final(unsigned char* hash, MD4_CTX* md4)\n{\n    reinterpret_cast<TaoCrypt::MD4*>(md4->buffer)->Final(hash);\n}\n\n\nvoid MD5_Init(MD5_CTX* md5)\n{\n    // make sure we have a big enough buffer\n    typedef char ok[sizeof(md5->buffer) >= sizeof(TaoCrypt::MD5) ? 1 : -1];\n    (void) sizeof(ok);\n\n    // using TaoCrypt since no dynamic memory allocated\n    // and no destructor will be called\n    new (reinterpret_cast<yassl_pointer>(md5->buffer)) TaoCrypt::MD5();\n}\n\n\nvoid MD5_Update(MD5_CTX* md5, const void* data, unsigned long sz)\n{\n    reinterpret_cast<TaoCrypt::MD5*>(md5->buffer)->Update(\n                static_cast<const byte*>(data), static_cast<unsigned int>(sz));\n}\n\n\nvoid MD5_Final(unsigned char* hash, MD5_CTX* md5)\n{\n    reinterpret_cast<TaoCrypt::MD5*>(md5->buffer)->Final(hash);\n}\n\n\nint RAND_bytes(unsigned char* buf, int num)\n{\n    RandomPool ran;\n\n    if (ran.GetError()) return 0;\n\n    ran.Fill(buf, num);\n    return 1;\n}\n\n\nint SSL_peek(SSL* ssl, void* buffer, int sz)\n{\n    Data data(min(sz, MAX_RECORD_SIZE), static_cast<opaque*>(buffer));\n    return receiveData(*ssl, data, true);\n}\n\n\nint SSL_pending(SSL* ssl)\n{\n    // Just in case there's pending data that hasn't been processed yet...\n    char c;\n    SSL_peek(ssl, &c, 1);\n    \n    return ssl->bufferedData();\n}\n\n\nvoid SSL_CTX_set_default_passwd_cb(SSL_CTX* ctx, pem_password_cb cb)\n{\n    ctx->SetPasswordCb(cb);\n}\n\n\nint SSLeay_add_ssl_algorithms()  // compatibility only\n{\n    return 1;\n}\n\n\nvoid ERR_remove_state(unsigned long)\n{\n    GetErrors().Remove();\n}\n\n\nint ERR_GET_REASON(int l)\n{\n    return l & 0xfff;\n}\n\n\nunsigned long err_helper(bool peek = false)\n{\n    int ysError = GetErrors().Lookup(peek);\n\n    // translate cert error for libcurl, it uses OpenSSL hex code\n    switch (ysError) {\n    case TaoCrypt::SIG_OTHER_E:\n        return CERTFICATE_ERROR;\n        break;\n    default :\n        return 0;\n    }\n\n    return 0;  // shut up compiler\n}\n\n\nunsigned long ERR_peek_error()\n{\n    return err_helper(true);\n}\n\n\nunsigned long ERR_get_error()\n{\n    return err_helper();\n}\n\n\n    // functions for stunnel\n\n    void RAND_screen()\n    {\n        // TODO:\n    }\n\n\n    const char* RAND_file_name(char*, size_t)\n    {\n        // TODO:\n        return 0;\n    }\n\n\n    int RAND_write_file(const char*)\n    {\n        // TODO:\n        return 0;\n    }\n\n\n    int RAND_load_file(const char*, long)\n    {\n        // TODO:\n        return 0;\n    }\n\n\n    void RSA_free(RSA*)\n    {\n        // TODO:\n    }\n\n\n    RSA* RSA_generate_key(int, unsigned long, void(*)(int, int, void*), void*)\n    {\n        //  TODO:\n        return 0;\n    }\n\n\n    int X509_LOOKUP_add_dir(X509_LOOKUP*, const char*, long)\n    {\n        // TODO:\n        return SSL_SUCCESS;\n    }\n\n\n    int X509_LOOKUP_load_file(X509_LOOKUP*, const char*, long)\n    {\n        // TODO:\n        return SSL_SUCCESS;\n    }\n\n\n    X509_LOOKUP_METHOD* X509_LOOKUP_hash_dir(void)\n    {\n        // TODO:\n        return 0;\n    }\n\n\n    X509_LOOKUP_METHOD* X509_LOOKUP_file(void)\n    {\n        // TODO:\n        return 0;\n    }\n\n\n    X509_LOOKUP* X509_STORE_add_lookup(X509_STORE*, X509_LOOKUP_METHOD*)\n    {\n        // TODO:\n        return 0;\n    }\n\n\n    int X509_STORE_get_by_subject(X509_STORE_CTX*, int, X509_NAME*, X509_OBJECT*)\n    {\n        // TODO:\n        return SSL_SUCCESS;\n    }\n\n\n    X509_STORE* X509_STORE_new(void)\n    {\n        // TODO:\n        return 0;\n    }\n\n    char* SSL_alert_type_string_long(int)\n    {\n        // TODO:\n        return 0;\n    }\n\n\n    char* SSL_alert_desc_string_long(int)\n    {\n        // TODO:\n        return 0;\n    }\n\n\n    char* SSL_state_string_long(SSL*)\n    {\n        // TODO:\n        return 0;\n    }\n\n\n    void SSL_CTX_set_tmp_rsa_callback(SSL_CTX*, RSA*(*)(SSL*, int, int))\n    {\n        // TDOD:\n    }\n\n\n    long SSL_CTX_set_timeout(SSL_CTX*, long)\n    {\n        // TDOD:\n        return SSL_SUCCESS;\n    }\n\n\n    int SSL_CTX_use_certificate_chain_file(SSL_CTX*, const char*)\n    {\n        // TDOD:\n        return SSL_SUCCESS;\n    }\n\n\n    int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX*, const char*, int)\n    {\n        // TDOD:\n        return SSL_SUCCESS;\n    }\n\n\n    int SSL_set_rfd(SSL*, int)\n    {\n        return SSL_SUCCESS; // TODO:\n    }\n\n\n    int SSL_set_wfd(SSL*, int)\n    {\n        return SSL_SUCCESS; // TODO:\n    }\n\n\n    int SSL_want_read(SSL*)\n    {\n        return 0; // TODO:\n    }\n\n\n    int SSL_want_write(SSL*)\n    {\n        return 0; // TODO:\n    }\n\n\n    void SSL_set_shutdown(SSL*, int)\n    {\n        // TODO:\n    }\n\n\n    SSL_CIPHER* SSL_get_current_cipher(SSL*)\n    {\n        // TODO:\n        return 0;\n    }\n\n\n    char* SSL_CIPHER_description(SSL_CIPHER*, char*, int)\n    {\n        // TODO:\n        return 0;\n    }\n\n\n\n    // end stunnel needs\n\n    char *yaSSL_ASN1_TIME_to_string(ASN1_TIME *time, char *buf, size_t len)\n    {\n      tm t;\n      static const char *month_names[12]=\n      {\n        \"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\n        \"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"\n      };\n\n      TaoCrypt::ASN1_TIME_extract(time->data, time->type, &t);\n#ifdef _WIN32\n      _snprintf(buf, len, \"%s %2d %02d:%02d:%02d %d GMT\",\n#else\n      snprintf(buf, len, \"%s %2d %02d:%02d:%02d %d GMT\",\n#endif\n               month_names[t.tm_mon], t.tm_mday, t.tm_hour, t.tm_min, \n               t.tm_sec, t.tm_year + 1900);\n      return buf;\n    }\n\n\n    void yaSSL_transport_set_ptr(SSL *ssl, void *ptr)\n    {\n      ssl->useSocket().set_transport_ptr(ptr);\n    }\n\n\n    void yaSSL_transport_set_recv_function(SSL *ssl, yaSSL_recv_func_t func)\n    {\n      ssl->useSocket().set_transport_recv_function(func);\n    }\n\n\n    void yaSSL_transport_set_send_function(SSL *ssl, yaSSL_send_func_t func)\n    {\n      ssl->useSocket().set_transport_send_function(func);\n    }\n\n} // extern \"C\"\n} // namespace\n"
  },
  {
    "path": "ext/yassl/src/template_instnt.cpp",
    "content": "/*\n   Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/*  Explicit template instantiation requests \n */\n\n\n#include \"runtime.hpp\"\n#include \"handshake.hpp\"\n#include \"yassl_int.hpp\"\n#include \"crypto_wrapper.hpp\"\n#include \"hmac.hpp\"\n#include \"md5.hpp\"\n#include \"sha.hpp\"\n#include \"ripemd.hpp\"\n#include \"openssl/ssl.h\"\n\n#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION\n\nnamespace mySTL {\ntemplate class list<unsigned char*>;\ntemplate yaSSL::del_ptr_zero for_each(mySTL::list<unsigned char*>::iterator, mySTL::list<unsigned char*>::iterator, yaSSL::del_ptr_zero);\ntemplate pair<int, yaSSL::Message* (*)()>* uninit_copy<mySTL::pair<int, yaSSL::Message* (*)()>*, mySTL::pair<int, yaSSL::Message* (*)()>*>(mySTL::pair<int, yaSSL::Message* (*)()>*, mySTL::pair<int, yaSSL::Message* (*)()>*, mySTL::pair<int, yaSSL::Message* (*)()>*);\ntemplate pair<int, yaSSL::HandShakeBase* (*)()>* uninit_copy<mySTL::pair<int, yaSSL::HandShakeBase* (*)()>*, mySTL::pair<int, yaSSL::HandShakeBase* (*)()>*>(mySTL::pair<int, yaSSL::HandShakeBase* (*)()>*, mySTL::pair<int, yaSSL::HandShakeBase* (*)()>*, mySTL::pair<int, yaSSL::HandShakeBase* (*)()>*);\ntemplate void destroy<mySTL::pair<int, yaSSL::Message* (*)()>*>(mySTL::pair<int, yaSSL::Message* (*)()>*, mySTL::pair<int, yaSSL::Message* (*)()>*);\ntemplate void destroy<mySTL::pair<int, yaSSL::HandShakeBase* (*)()>*>(mySTL::pair<int, yaSSL::HandShakeBase* (*)()>*, mySTL::pair<int, yaSSL::HandShakeBase* (*)()>*);\ntemplate pair<int, yaSSL::ServerKeyBase* (*)()>* uninit_copy<mySTL::pair<int, yaSSL::ServerKeyBase* (*)()>*, mySTL::pair<int, yaSSL::ServerKeyBase* (*)()>*>(mySTL::pair<int, yaSSL::ServerKeyBase* (*)()>*, mySTL::pair<int, yaSSL::ServerKeyBase* (*)()>*, mySTL::pair<int, yaSSL::ServerKeyBase* (*)()>*);\ntemplate void destroy<mySTL::pair<int, yaSSL::ServerKeyBase* (*)()>*>(mySTL::pair<int, yaSSL::ServerKeyBase* (*)()>*, mySTL::pair<int, yaSSL::ServerKeyBase* (*)()>*);\ntemplate pair<int, yaSSL::ClientKeyBase* (*)()>* uninit_copy<mySTL::pair<int, yaSSL::ClientKeyBase* (*)()>*, mySTL::pair<int, yaSSL::ClientKeyBase* (*)()>*>(mySTL::pair<int, yaSSL::ClientKeyBase* (*)()>*, mySTL::pair<int, yaSSL::ClientKeyBase* (*)()>*, mySTL::pair<int, yaSSL::ClientKeyBase* (*)()>*);\ntemplate class list<TaoCrypt::Signer*>;\ntemplate class list<yaSSL::SSL_SESSION*>;\ntemplate class list<yaSSL::input_buffer*>;\ntemplate class list<yaSSL::output_buffer*>;\ntemplate class list<yaSSL::x509*>;\ntemplate class list<yaSSL::Digest*>;\ntemplate class list<yaSSL::BulkCipher*>;\ntemplate void destroy<mySTL::pair<int, yaSSL::ClientKeyBase* (*)()>*>(mySTL::pair<int, yaSSL::ClientKeyBase* (*)()>*, mySTL::pair<int, yaSSL::ClientKeyBase* (*)()>*);\ntemplate yaSSL::del_ptr_zero for_each<mySTL::list<TaoCrypt::Signer*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<TaoCrypt::Signer*>::iterator, mySTL::list<TaoCrypt::Signer*>::iterator, yaSSL::del_ptr_zero);\ntemplate yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::SSL_SESSION*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::SSL_SESSION*>::iterator, mySTL::list<yaSSL::SSL_SESSION*>::iterator, yaSSL::del_ptr_zero);\ntemplate yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::input_buffer*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::input_buffer*>::iterator, mySTL::list<yaSSL::input_buffer*>::iterator, yaSSL::del_ptr_zero);\ntemplate yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::output_buffer*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::output_buffer*>::iterator, mySTL::list<yaSSL::output_buffer*>::iterator, yaSSL::del_ptr_zero);\ntemplate yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::x509*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::x509*>::iterator, mySTL::list<yaSSL::x509*>::iterator, yaSSL::del_ptr_zero);\ntemplate yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::Digest*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::Digest*>::iterator, mySTL::list<yaSSL::Digest*>::iterator, yaSSL::del_ptr_zero);\ntemplate yaSSL::del_ptr_zero for_each<mySTL::list<yaSSL::BulkCipher*>::iterator, yaSSL::del_ptr_zero>(mySTL::list<yaSSL::BulkCipher*>::iterator, mySTL::list<yaSSL::BulkCipher*>::iterator, yaSSL::del_ptr_zero);\ntemplate bool list<yaSSL::ThreadError>::erase(list<yaSSL::ThreadError>::iterator);\ntemplate void list<yaSSL::ThreadError>::push_back(yaSSL::ThreadError);\ntemplate void list<yaSSL::ThreadError>::pop_front();\ntemplate void list<yaSSL::ThreadError>::pop_back();\ntemplate list<yaSSL::ThreadError>::~list();\ntemplate pair<int, yaSSL::Message* (*)()>* GetArrayMemory<pair<int, yaSSL::Message* (*)()> >(size_t);\ntemplate void FreeArrayMemory<pair<int, yaSSL::Message* (*)()> >(pair<int, yaSSL::Message* (*)()>*);\ntemplate pair<int, yaSSL::HandShakeBase* (*)()>* GetArrayMemory<pair<int, yaSSL::HandShakeBase* (*)()> >(size_t);\ntemplate void FreeArrayMemory<pair<int, yaSSL::HandShakeBase* (*)()> >(pair<int, yaSSL::HandShakeBase* (*)()>*);\ntemplate pair<int, yaSSL::ServerKeyBase* (*)()>* GetArrayMemory<pair<int, yaSSL::ServerKeyBase* (*)()> >(size_t);\ntemplate void FreeArrayMemory<pair<int, yaSSL::ServerKeyBase* (*)()> >(pair<int, yaSSL::ServerKeyBase* (*)()>*);\ntemplate pair<int, yaSSL::ClientKeyBase* (*)()>* GetArrayMemory<pair<int, yaSSL::ClientKeyBase* (*)()> >(size_t);\ntemplate void FreeArrayMemory<pair<int, yaSSL::ClientKeyBase* (*)()> >(pair<int, yaSSL::ClientKeyBase* (*)()>*);\n}\n\nnamespace yaSSL {\ntemplate void ysDelete<SSL_CTX>(yaSSL::SSL_CTX*);\ntemplate void ysDelete<SSL>(yaSSL::SSL*);\ntemplate void ysDelete<BIGNUM>(yaSSL::BIGNUM*);\ntemplate void ysDelete<unsigned char>(unsigned char*);\ntemplate void ysDelete<DH>(yaSSL::DH*);\ntemplate void ysDelete<TaoCrypt::Signer>(TaoCrypt::Signer*);\ntemplate void ysDelete<SSL_SESSION>(yaSSL::SSL_SESSION*);\ntemplate void ysDelete<input_buffer>(input_buffer*);\ntemplate void ysDelete<output_buffer>(output_buffer*);\ntemplate void ysDelete<x509>(x509*);\ntemplate void ysDelete<Auth>(Auth*);\ntemplate void ysDelete<HandShakeBase>(HandShakeBase*);\ntemplate void ysDelete<ServerKeyBase>(ServerKeyBase*);\ntemplate void ysDelete<ClientKeyBase>(ClientKeyBase*);\ntemplate void ysDelete<SSL_METHOD>(SSL_METHOD*);\ntemplate void ysDelete<DiffieHellman>(DiffieHellman*);\ntemplate void ysDelete<BulkCipher>(BulkCipher*);\ntemplate void ysDelete<Digest>(Digest*);\ntemplate void ysDelete<X509>(X509*);\ntemplate void ysDelete<Message>(Message*);\ntemplate void ysDelete<sslFactory>(sslFactory*);\ntemplate void ysDelete<Sessions>(Sessions*);\ntemplate void ysDelete<Errors>(Errors*);\ntemplate void ysArrayDelete<unsigned char>(unsigned char*);\ntemplate void ysArrayDelete<char>(char*);\n\ntemplate int min<int>(int, int);\ntemplate uint16 min<uint16>(uint16, uint16);\ntemplate unsigned int min<unsigned int>(unsigned int, unsigned int);\ntemplate unsigned long min<unsigned long>(unsigned long, unsigned long);\n}\n\n#endif // HAVE_EXPLICIT_TEMPLATE_INSTANTIATION\n\n"
  },
  {
    "path": "ext/yassl/src/timer.cpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* timer.cpp implements a high res and low res timer\n *\n*/\n\n#include \"runtime.hpp\"\n#include \"timer.hpp\"\n\n#ifdef _WIN32\n#include <windows.h>\n#else\n#include <sys/time.h>\n#endif\n\nnamespace yaSSL {\n\n#ifdef _WIN32\n\n    timer_d timer()\n    {\n        static bool          init(false);\n        static LARGE_INTEGER freq;\n    \n        if (!init) {\n            QueryPerformanceFrequency(&freq);\n            init = true;\n        }\n\n        LARGE_INTEGER count;\n        QueryPerformanceCounter(&count);\n\n        return static_cast<double>(count.QuadPart) / freq.QuadPart;\n    }\n\n\n    uint lowResTimer()\n    {\n        return static_cast<uint>(timer());\n    }\n\n#else // _WIN32\n\n    timer_d timer()\n    {\n        struct timeval tv;\n        gettimeofday(&tv, 0);\n\n        return static_cast<double>(tv.tv_sec) \n             + static_cast<double>(tv.tv_usec) / 1000000;\n    }\n\n\n    uint lowResTimer()\n    {\n        struct timeval tv;\n        gettimeofday(&tv, 0);\n\n        return tv.tv_sec; \n    }\n\n\n#endif // _WIN32\n} // namespace yaSSL\n"
  },
  {
    "path": "ext/yassl/src/yassl.cpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* yaSSL implements external API\n */\n\n#include \"runtime.hpp\"\n#include \"yassl.hpp\"\n#include \"yassl_int.hpp\"\n#include \"handshake.hpp\"\n#include <stdio.h>\n\n#include \"openssl/ssl.h\"  // get rid of this\n\n\n\nnamespace yaSSL {\n\n\n\nstruct Base {\n    SSL_METHOD* method_;\n    SSL_CTX*    ctx_;\n    SSL*        ssl_;\n\n    char*       ca_;\n    char*       cert_;\n    char*       key_;\n\n    DH*         dh_;\n\n    Base() : method_(0), ctx_(0), ssl_(0), ca_(0), cert_(0), key_(0), dh_(0)\n    {}\n\n    ~Base()\n    {\n        if (dh_) DH_free(dh_);\n        delete[] key_;\n        delete[] cert_;\n        delete[] ca_;\n        SSL_CTX_free(ctx_);   // frees method_ too\n        SSL_free(ssl_);\n    }\n};\n\n\nvoid SetDH(Base&);\n\nvoid SetUpBase(Base& base, ConnectionEnd end, SOCKET_T s)\n{\n    base.method_ = new SSL_METHOD(end, ProtocolVersion(3,1));\n    base.ctx_ =    new SSL_CTX(base.method_);\n\n    if (base.ca_)\n        if (SSL_CTX_load_verify_locations(base.ctx_,\n            base.ca_, 0) != SSL_SUCCESS) throw(0);\n    if (base.cert_)\n        if (SSL_CTX_use_certificate_file(base.ctx_,\n            base.cert_, SSL_FILETYPE_PEM) != SSL_SUCCESS) throw(0);\n    if (base.key_)\n        if (SSL_CTX_use_PrivateKey_file(base.ctx_, base.key_,\n            SSL_FILETYPE_PEM) != SSL_SUCCESS) throw(0);\n\n    if (end == server_end) SetDH(base);\n\n    base.ssl_ = new SSL(base.ctx_);\n    base.ssl_->useSocket().set_fd(s);\n}\n\n\nvoid SetDH(Base& base)\n{\n    static unsigned char dh512_p[] =\n    {\n      0xDA,0x58,0x3C,0x16,0xD9,0x85,0x22,0x89,0xD0,0xE4,0xAF,0x75,\n      0x6F,0x4C,0xCA,0x92,0xDD,0x4B,0xE5,0x33,0xB8,0x04,0xFB,0x0F,\n      0xED,0x94,0xEF,0x9C,0x8A,0x44,0x03,0xED,0x57,0x46,0x50,0xD3,\n      0x69,0x99,0xDB,0x29,0xD7,0x76,0x27,0x6B,0xA2,0xD3,0xD4,0x12,\n      0xE2,0x18,0xF4,0xDD,0x1E,0x08,0x4C,0xF6,0xD8,0x00,0x3E,0x7C,\n      0x47,0x74,0xE8,0x33,\n    };\n\n    static unsigned char dh512_g[] =\n    {\n      0x02,\n    };\n\n    if ( (base.dh_ = DH_new()) ) {\n        base.dh_->p = BN_bin2bn(dh512_p, sizeof(dh512_p), 0);\n        base.dh_->g = BN_bin2bn(dh512_g, sizeof(dh512_g), 0);\n    }\n    if (!base.dh_->p || !base.dh_->g) {\n        DH_free(base.dh_);\n        base.dh_ = 0;\n    }\n    SSL_CTX_set_tmp_dh(base.ctx_, base.dh_);\n}\n\n\nvoid NewCopy(char*& dst, const char* src)\n{\n    size_t len = strlen(src) + 1;\n    dst = new char[len];\n\n    strncpy(dst, src, len);\n}\n\n\n// Client Implementation\nstruct Client::ClientImpl {\n    Base base_;\n};\n\n\nClient::Client() : pimpl_(new ClientImpl)\n{}\n\n\nClient::~Client() { delete pimpl_; }\n\n\nint Client::Connect(SOCKET_T s)\n{\n    SetUpBase(pimpl_->base_, client_end, s);\n    return SSL_connect(pimpl_->base_.ssl_);\n}\n\n\nint Client::Write(const void* buffer, int sz)\n{\n    return sendData(*pimpl_->base_.ssl_, buffer, sz);\n}\n\n\nint Client::Read(void* buffer, int sz)\n{\n    Data data(min(sz, MAX_RECORD_SIZE), static_cast<opaque*>(buffer));\n    return receiveData(*pimpl_->base_.ssl_, data);\n}\n\n\nvoid Client::SetCA(const char* name)\n{\n    NewCopy(pimpl_->base_.ca_, name);\n}\n\n\nvoid Client::SetCert(const char* name)\n{\n    NewCopy(pimpl_->base_.cert_, name);\n}\n\n\nvoid Client::SetKey(const char* name)\n{\n    NewCopy(pimpl_->base_.key_, name);\n}\n\n\n\n// Server Implementation\nstruct Server::ServerImpl {\n    Base base_;\n};\n\n\nServer::Server() : pimpl_(new ServerImpl)\n{}\n\n\nServer::~Server() { delete pimpl_; }\n\n\nint Server::Accept(SOCKET_T s)\n{\n    SetUpBase(pimpl_->base_, server_end, s);\n    return SSL_accept(pimpl_->base_.ssl_);\n}\n\n\nint Server::Write(const void* buffer, int sz)\n{\n    return sendData(*pimpl_->base_.ssl_, buffer, sz);\n}\n\n\nint Server::Read(void* buffer, int sz)\n{\n    Data data(min(sz, MAX_RECORD_SIZE), static_cast<opaque*>(buffer));\n    return receiveData(*pimpl_->base_.ssl_, data);\n}\n\n\nvoid Server::SetCA(const char* name)\n{\n    NewCopy(pimpl_->base_.ca_, name);\n}\n\n\nvoid Server::SetCert(const char* name)\n{\n    NewCopy(pimpl_->base_.cert_, name);\n}\n\n\nvoid Server::SetKey(const char* name)\n{\n    NewCopy(pimpl_->base_.key_, name);\n}\n\n\n\n} // namespace yaSSL\n"
  },
  {
    "path": "ext/yassl/src/yassl_error.cpp",
    "content": "/*\n   Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* yaSSL error implements and an exception class\n */\n\n#include \"runtime.hpp\"\n#include \"yassl_error.hpp\"\n#include \"error.hpp\"        // TaoCrypt error numbers\n#include \"openssl/ssl.h\"    // SSL_ERROR_WANT_READ\n#include <string.h>         // strncpy\n\n#ifdef _MSC_VER\n    // 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy\n    #pragma warning(disable: 4996)\n#endif\n\nnamespace yaSSL {\n\n\n/* may bring back in future\nError::Error(const char* s, YasslError e, Library l) \n    : mySTL::runtime_error(s), error_(e), lib_(l) \n{\n}\n\n\nYasslError Error::get_number() const\n{\n    return error_;\n}\n\n\nLibrary Error::get_lib() const\n{\n\n    return lib_;\n}\n*/\n\n\nvoid SetErrorString(YasslError error, char* buffer)\n{\n    using namespace TaoCrypt;\n    const int max = MAX_ERROR_SZ;  // shorthand\n    int localError = error;        // errors from a few enums \n\n    switch (localError) {\n\n        // yaSSL proper errors\n    case range_error :\n        strncpy(buffer, \"buffer index error, out of range\", max);\n        break; \n\n    case realloc_error :\n        strncpy(buffer, \"trying to realloc a fixed buffer\", max);\n        break; \n\n    case factory_error : \n        strncpy(buffer, \"unknown factory create request\", max);\n        break; \n\n    case unknown_cipher :\n        strncpy(buffer, \"trying to use an unknown cipher\", max);\n        break; \n\n    case prefix_error : \n        strncpy(buffer, \"bad master secret derivation, prefix too big\", max);\n        break; \n\n    case record_layer : \n        strncpy(buffer, \"record layer not ready yet\", max);\n        break; \n        \n    case handshake_layer :\n        strncpy(buffer, \"handshake layer not ready yet\", max);\n        break; \n\n    case out_of_order :\n        strncpy(buffer, \"handshake message received in wrong order\", max);\n        break; \n\n    case bad_input : \n        strncpy(buffer, \"bad cipher suite input\", max);\n        break; \n\n    case match_error :\n        strncpy(buffer, \"unable to match a supported cipher suite\", max);\n        break; \n\n    case no_key_file : \n        strncpy(buffer, \"the server needs a private key file\", max);\n        break; \n\n    case verify_error :\n        strncpy(buffer, \"unable to verify peer checksum\", max);\n        break; \n\n    case send_error :\n        strncpy(buffer, \"socket layer send error\", max);\n        break; \n\n    case receive_error :\n        strncpy(buffer, \"socket layer receive error\", max);\n        break; \n\n    case certificate_error :\n        strncpy(buffer, \"unable to proccess cerificate\", max);\n        break;\n\n    case privateKey_error :\n        strncpy(buffer, \"unable to proccess private key, bad format\", max);\n        break;\n\n    case badVersion_error :\n        strncpy(buffer, \"protocol version mismatch\", max);\n        break;\n\n    case compress_error :\n        strncpy(buffer, \"compression error\", max);\n        break;\n\n    case decompress_error :\n        strncpy(buffer, \"decompression error\", max);\n        break;\n\n    case pms_version_error :\n        strncpy(buffer, \"bad PreMasterSecret version error\", max);\n        break;\n\n    case sanityCipher_error :\n        strncpy(buffer, \"sanity check on cipher text size error\", max);\n        break;\n\n        // openssl errors\n    case SSL_ERROR_WANT_READ :\n        strncpy(buffer, \"the read operation would block\", max);\n        break;\n\n    case SSL_ERROR_WANT_WRITE :\n        strncpy(buffer, \"the write operation would block\", max);\n        break;\n\n    case CERTFICATE_ERROR :\n        strncpy(buffer, \"Unable to verify certificate\", max);\n        break;\n\n        // TaoCrypt errors\n    case NO_ERROR_E :\n        strncpy(buffer, \"not in error state\", max);\n        break;\n\n    case WINCRYPT_E :\n        strncpy(buffer, \"bad wincrypt acquire\", max);\n        break;\n\n    case CRYPTGEN_E :\n        strncpy(buffer, \"CryptGenRandom error\", max);\n        break;\n\n    case OPEN_RAN_E :\n        strncpy(buffer, \"unable to use random device\", max);\n        break;\n\n    case READ_RAN_E :\n        strncpy(buffer, \"unable to use random device\", max);\n        break;\n\n    case INTEGER_E :\n        strncpy(buffer, \"ASN: bad DER Integer Header\", max);\n        break;\n\n    case SEQUENCE_E :\n        strncpy(buffer, \"ASN: bad Sequence Header\", max);\n        break;\n\n    case SET_E :\n        strncpy(buffer, \"ASN: bad Set Header\", max);\n        break;\n\n    case VERSION_E :\n        strncpy(buffer, \"ASN: version length not 1\", max);\n        break;\n\n    case SIG_OID_E :\n        strncpy(buffer, \"ASN: signature OID mismatch\", max);\n        break;\n\n    case BIT_STR_E :\n        strncpy(buffer, \"ASN: bad BitString Header\", max);\n        break;\n\n    case UNKNOWN_OID_E :\n        strncpy(buffer, \"ASN: unknown key OID type\", max);\n        break;\n\n    case OBJECT_ID_E :\n        strncpy(buffer, \"ASN: bad Ojbect ID Header\", max);\n        break;\n\n    case TAG_NULL_E :\n        strncpy(buffer, \"ASN: expected TAG NULL\", max);\n        break;\n\n    case EXPECT_0_E :\n        strncpy(buffer, \"ASN: expected 0\", max);\n        break;\n\n    case OCTET_STR_E :\n        strncpy(buffer, \"ASN: bad Octet String Header\", max);\n        break;\n\n    case TIME_E :\n        strncpy(buffer, \"ASN: bad TIME\", max);\n        break;\n\n    case DATE_SZ_E :\n        strncpy(buffer, \"ASN: bad Date Size\", max);\n        break;\n\n    case SIG_LEN_E :\n        strncpy(buffer, \"ASN: bad Signature Length\", max);\n        break;\n\n    case UNKOWN_SIG_E :\n        strncpy(buffer, \"ASN: unknown signature OID\", max);\n        break;\n\n    case UNKOWN_HASH_E :\n        strncpy(buffer, \"ASN: unknown hash OID\", max);\n        break;\n\n    case DSA_SZ_E :\n        strncpy(buffer, \"ASN: bad DSA r or s size\", max);\n        break;\n\n    case BEFORE_DATE_E :\n        strncpy(buffer, \"ASN: before date in the future\", max);\n        break;\n\n    case AFTER_DATE_E :\n        strncpy(buffer, \"ASN: after date in the past\", max);\n        break;\n\n    case SIG_CONFIRM_E :\n        strncpy(buffer, \"ASN: bad self signature confirmation\", max);\n        break;\n\n    case SIG_OTHER_E :\n        strncpy(buffer, \"ASN: bad other signature confirmation\", max);\n        break;\n\n    case CONTENT_E :\n        strncpy(buffer, \"bad content processing\", max);\n        break;\n\n    case PEM_E :\n        strncpy(buffer, \"bad PEM format processing\", max);\n        break;\n\n    default :\n        strncpy(buffer, \"unknown error number\", max);\n    }\n}\n\n\n\n}  // namespace yaSSL\n"
  },
  {
    "path": "ext/yassl/src/yassl_imp.cpp",
    "content": "/*\n   Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/*  yaSSL source implements all SSL.v3 secification structures.\n */\n\n#include \"runtime.hpp\"\n#include \"yassl_int.hpp\"\n#include \"handshake.hpp\"\n\n#include \"asn.hpp\"  // provide crypto wrapper??\n\n\n\nnamespace yaSSL {\n\n\nnamespace { // locals\n\nbool isTLS(ProtocolVersion pv)\n{\n    if (pv.major_ >= 3 && pv.minor_ >= 1)\n        return true;\n\n    return false;\n}\n\n\n}  // namespace (locals)\n\n\nvoid hashHandShake(SSL&, const input_buffer&, uint);\n\n\nProtocolVersion::ProtocolVersion(uint8 maj, uint8 min) \n    : major_(maj), minor_(min) \n{}\n\n\n// construct key exchange with known ssl parms\nvoid ClientKeyExchange::createKey(SSL& ssl)\n{\n    const ClientKeyFactory& ckf = ssl.getFactory().getClientKey();\n    client_key_ = ckf.CreateObject(ssl.getSecurity().get_parms().kea_);\n\n    if (!client_key_)\n        ssl.SetError(factory_error);\n}\n\n\n// construct key exchange with known ssl parms\nvoid ServerKeyExchange::createKey(SSL& ssl)\n{\n    const ServerKeyFactory& skf = ssl.getFactory().getServerKey();\n    server_key_ = skf.CreateObject(ssl.getSecurity().get_parms().kea_);\n\n    if (!server_key_)\n        ssl.SetError(factory_error);\n}\n\n\n// build/set PreMaster secret and encrypt, client side\nvoid EncryptedPreMasterSecret::build(SSL& ssl)\n{\n    opaque tmp[SECRET_LEN];\n    memset(tmp, 0, sizeof(tmp));\n    ssl.getCrypto().get_random().Fill(tmp, SECRET_LEN);\n    ProtocolVersion pv = ssl.getSecurity().get_connection().chVersion_;\n    tmp[0] = pv.major_;\n    tmp[1] = pv.minor_;\n    ssl.set_preMaster(tmp, SECRET_LEN);\n\n    const CertManager& cert = ssl.getCrypto().get_certManager();\n    RSA rsa(cert.get_peerKey(), cert.get_peerKeyLength());\n    bool tls = ssl.isTLS();     // if TLS, put length for encrypted data\n    alloc(rsa.get_cipherLength() + (tls ? 2 : 0));\n    byte* holder = secret_;\n    if (tls) {\n        byte len[2];\n        c16toa(rsa.get_cipherLength(), len);\n        memcpy(secret_, len, sizeof(len));\n        holder += 2;\n    }\n    rsa.encrypt(holder, tmp, SECRET_LEN, ssl.getCrypto().get_random());\n}\n\n\n// build/set premaster and Client Public key, client side\nvoid ClientDiffieHellmanPublic::build(SSL& ssl)\n{\n    DiffieHellman& dhServer = ssl.useCrypto().use_dh();\n    DiffieHellman  dhClient(dhServer);\n\n    uint keyLength = dhClient.get_agreedKeyLength(); // pub and agree same\n\n    alloc(keyLength, true);\n    dhClient.makeAgreement(dhServer.get_publicKey(), keyLength);\n    c16toa(keyLength, Yc_);\n    memcpy(Yc_ + KEY_OFFSET, dhClient.get_publicKey(), keyLength);\n\n    // because of encoding first byte might be zero, don't use it for preMaster\n    if (*dhClient.get_agreedKey() == 0) \n        ssl.set_preMaster(dhClient.get_agreedKey() + 1, keyLength - 1);\n    else\n        ssl.set_preMaster(dhClient.get_agreedKey(), keyLength);\n}\n\n\n// build server exhange, server side\nvoid DH_Server::build(SSL& ssl)\n{\n    DiffieHellman& dhServer = ssl.useCrypto().use_dh();\n\n    int pSz, gSz, pubSz;\n    dhServer.set_sizes(pSz, gSz, pubSz);\n    dhServer.get_parms(parms_.alloc_p(pSz), parms_.alloc_g(gSz),\n                       parms_.alloc_pub(pubSz));\n\n    short sigSz = 0;\n    mySTL::auto_ptr<Auth> auth;\n    const CertManager& cert = ssl.getCrypto().get_certManager();\n    \n    if (ssl.getSecurity().get_parms().sig_algo_ == rsa_sa_algo) {\n        if (cert.get_keyType() != rsa_sa_algo) {\n            ssl.SetError(privateKey_error);\n            return;\n        }\n        auth.reset(NEW_YS RSA(cert.get_privateKey(),\n                   cert.get_privateKeyLength(), false));\n    }\n    else {\n        if (cert.get_keyType() != dsa_sa_algo) {\n            ssl.SetError(privateKey_error);\n            return;\n        }\n        auth.reset(NEW_YS DSS(cert.get_privateKey(),\n                   cert.get_privateKeyLength(), false));\n        sigSz += DSS_ENCODED_EXTRA;\n    }\n    \n    sigSz += auth->get_signatureLength();\n    if (!sigSz) {\n        ssl.SetError(privateKey_error);\n        return;\n    }\n\n    length_ = 8; // pLen + gLen + YsLen + SigLen\n    length_ += pSz + gSz + pubSz + sigSz;\n\n    output_buffer tmp(length_);\n    byte len[2];\n    // P\n    c16toa(pSz, len);\n    tmp.write(len, sizeof(len));\n    tmp.write(parms_.get_p(), pSz);\n    // G\n    c16toa(gSz, len);\n    tmp.write(len, sizeof(len));\n    tmp.write(parms_.get_g(), gSz);\n    // Ys\n    c16toa(pubSz, len);\n    tmp.write(len, sizeof(len));\n    tmp.write(parms_.get_pub(), pubSz);\n\n    // Sig\n    byte hash[FINISHED_SZ];\n    MD5  md5;\n    SHA  sha;\n    signature_ = NEW_YS byte[sigSz];\n\n    const Connection& conn = ssl.getSecurity().get_connection();\n    // md5\n    md5.update(conn.client_random_, RAN_LEN);\n    md5.update(conn.server_random_, RAN_LEN);\n    md5.update(tmp.get_buffer(), tmp.get_size());\n    md5.get_digest(hash);\n\n    // sha\n    sha.update(conn.client_random_, RAN_LEN);\n    sha.update(conn.server_random_, RAN_LEN);\n    sha.update(tmp.get_buffer(), tmp.get_size());\n    sha.get_digest(&hash[MD5_LEN]);\n\n    if (ssl.getSecurity().get_parms().sig_algo_ == rsa_sa_algo)\n        auth->sign(signature_, hash, sizeof(hash),\n                   ssl.getCrypto().get_random());\n    else {\n        auth->sign(signature_, &hash[MD5_LEN], SHA_LEN,\n                   ssl.getCrypto().get_random());\n        byte encoded[DSS_SIG_SZ + DSS_ENCODED_EXTRA];\n        TaoCrypt::EncodeDSA_Signature(signature_, encoded);\n        memcpy(signature_, encoded, sizeof(encoded));\n    }\n\n    c16toa(sigSz, len);\n    tmp.write(len, sizeof(len));\n    tmp.write(signature_, sigSz);\n\n    // key message\n    keyMessage_ = NEW_YS opaque[length_];\n    memcpy(keyMessage_, tmp.get_buffer(), tmp.get_size());\n}\n\n\n// read PreMaster secret and decrypt, server side\nvoid EncryptedPreMasterSecret::read(SSL& ssl, input_buffer& input)\n{\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    const CertManager& cert = ssl.getCrypto().get_certManager();\n    RSA rsa(cert.get_privateKey(), cert.get_privateKeyLength(), false);\n    uint16 cipherLen = rsa.get_cipherLength();\n    if (ssl.isTLS()) {\n        byte len[2];\n        len[0] = input[AUTO];\n        len[1] = input[AUTO];\n        ato16(len, cipherLen);\n    }\n    alloc(cipherLen);\n    input.read(secret_, length_);\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    opaque preMasterSecret[SECRET_LEN];\n    memset(preMasterSecret, 0, sizeof(preMasterSecret));\n    rsa.decrypt(preMasterSecret, secret_, length_, \n                ssl.getCrypto().get_random());\n\n    ProtocolVersion pv = ssl.getSecurity().get_connection().chVersion_;\n    if (pv.major_ != preMasterSecret[0] || pv.minor_ != preMasterSecret[1])\n        ssl.SetError(pms_version_error); // continue deriving for timing attack\n\n    ssl.set_preMaster(preMasterSecret, SECRET_LEN);\n    ssl.makeMasterSecret();\n}\n\n\nEncryptedPreMasterSecret::EncryptedPreMasterSecret()\n    : secret_(0), length_(0)\n{}\n\n\nEncryptedPreMasterSecret::~EncryptedPreMasterSecret()\n{\n    ysArrayDelete(secret_);\n}\n\n\nint EncryptedPreMasterSecret::get_length() const\n{\n    return length_;\n}\n\n\nopaque* EncryptedPreMasterSecret::get_clientKey() const\n{\n    return secret_;\n}\n\n\nvoid EncryptedPreMasterSecret::alloc(int sz)\n{\n    length_ = sz;\n    secret_ = NEW_YS opaque[sz];\n}\n\n\n// read client's public key, server side\nvoid ClientDiffieHellmanPublic::read(SSL& ssl, input_buffer& input)\n{\n    if (input.get_error() || input.get_remaining() < (uint)LENGTH_SZ) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    DiffieHellman& dh = ssl.useCrypto().use_dh();\n\n    uint16 keyLength;\n    byte tmp[2];\n    tmp[0] = input[AUTO];\n    tmp[1] = input[AUTO];\n    ato16(tmp, keyLength);\n\n    if (keyLength < dh.get_agreedKeyLength()/2) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    alloc(keyLength);\n    input.read(Yc_, keyLength);\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n    dh.makeAgreement(Yc_, keyLength); \n\n    // because of encoding, first byte might be 0, don't use for preMaster \n    if (*dh.get_agreedKey() == 0) \n        ssl.set_preMaster(dh.get_agreedKey() + 1, dh.get_agreedKeyLength() - 1);\n    else\n        ssl.set_preMaster(dh.get_agreedKey(), dh.get_agreedKeyLength());\n    ssl.makeMasterSecret();\n}\n\n\nClientDiffieHellmanPublic::ClientDiffieHellmanPublic()\n    : length_(0), Yc_(0)\n{}\n\n\nClientDiffieHellmanPublic::~ClientDiffieHellmanPublic()\n{\n    ysArrayDelete(Yc_);\n}\n\n\nint ClientDiffieHellmanPublic::get_length() const\n{\n    return length_;\n}\n\n\nopaque* ClientDiffieHellmanPublic::get_clientKey() const\n{\n    return Yc_;\n}\n\n\nvoid ClientDiffieHellmanPublic::alloc(int sz, bool offset) \n{\n    length_ = sz + (offset ? KEY_OFFSET : 0); \n    Yc_ = NEW_YS opaque[length_];\n}\n\n\n// read server's p, g, public key and sig, client side\nvoid DH_Server::read(SSL& ssl, input_buffer& input)\n{\n    if (input.get_error() || input.get_remaining() < (uint)LENGTH_SZ) {\n        ssl.SetError(bad_input);\n        return;\n    }\n    uint16 length, messageTotal = 6; // pSz + gSz + pubSz\n    byte tmp[2];\n\n    // p\n    tmp[0] = input[AUTO];\n    tmp[1] = input[AUTO];\n    ato16(tmp, length);\n    messageTotal += length;\n\n    input.read(parms_.alloc_p(length), length);\n    if (input.get_error() || input.get_remaining() < (uint)LENGTH_SZ) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    // g\n    tmp[0] = input[AUTO];\n    tmp[1] = input[AUTO];\n    ato16(tmp, length);\n    messageTotal += length;\n\n    input.read(parms_.alloc_g(length), length);\n    if (input.get_error() || input.get_remaining() < (uint)LENGTH_SZ) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    // pub\n    tmp[0] = input[AUTO];\n    tmp[1] = input[AUTO];\n    ato16(tmp, length);\n    messageTotal += length;\n\n    input.read(parms_.alloc_pub(length), length);\n    if (input.get_error() || input.get_remaining() < (uint)LENGTH_SZ) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    // save message for hash verify\n    input_buffer message(messageTotal);\n    input.set_current(input.get_current() - messageTotal);\n    input.read(message.get_buffer(), messageTotal);\n    message.add_size(messageTotal);\n    if (input.get_error() || input.get_remaining() < (uint)LENGTH_SZ) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    // signature\n    tmp[0] = input[AUTO];\n    tmp[1] = input[AUTO];\n    ato16(tmp, length);\n\n    if (length == 0) {\n        ssl.SetError(bad_input);\n        return;\n    }\n    signature_ = NEW_YS byte[length];\n    input.read(signature_, length);\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    // verify signature\n    byte hash[FINISHED_SZ];\n    MD5  md5;\n    SHA  sha;\n\n    const Connection& conn = ssl.getSecurity().get_connection();\n    // md5\n    md5.update(conn.client_random_, RAN_LEN);\n    md5.update(conn.server_random_, RAN_LEN);\n    md5.update(message.get_buffer(), message.get_size());\n    md5.get_digest(hash);\n\n    // sha\n    sha.update(conn.client_random_, RAN_LEN);\n    sha.update(conn.server_random_, RAN_LEN);\n    sha.update(message.get_buffer(), message.get_size());\n    sha.get_digest(&hash[MD5_LEN]);\n\n    const CertManager& cert = ssl.getCrypto().get_certManager();\n    \n    if (ssl.getSecurity().get_parms().sig_algo_ == rsa_sa_algo) {\n        RSA rsa(cert.get_peerKey(), cert.get_peerKeyLength());\n        if (!rsa.verify(hash, sizeof(hash), signature_, length))\n            ssl.SetError(verify_error);\n    }\n    else {\n        byte decodedSig[DSS_SIG_SZ];\n        length = TaoCrypt::DecodeDSA_Signature(decodedSig, signature_, length);\n        \n        DSS dss(cert.get_peerKey(), cert.get_peerKeyLength());\n        if (!dss.verify(&hash[MD5_LEN], SHA_LEN, decodedSig, length))\n            ssl.SetError(verify_error);\n    }\n\n    // save input\n    ssl.useCrypto().SetDH(NEW_YS DiffieHellman(parms_.get_p(),\n               parms_.get_pSize(), parms_.get_g(), parms_.get_gSize(),\n               parms_.get_pub(), parms_.get_pubSize(),\n               ssl.getCrypto().get_random()));\n}\n\n\nDH_Server::DH_Server()\n    : signature_(0), length_(0), keyMessage_(0)\n{}\n\n\nDH_Server::~DH_Server()\n{\n    ysArrayDelete(keyMessage_);\n    ysArrayDelete(signature_);\n}\n\n\nint DH_Server::get_length() const\n{\n    return length_;\n}\n\n\nopaque* DH_Server::get_serverKey() const\n{\n    return keyMessage_;\n}\n\n\n// set available suites\nParameters::Parameters(ConnectionEnd ce, const Ciphers& ciphers, \n                       ProtocolVersion pv, bool haveDH) : entity_(ce)\n{\n    pending_ = true;\t// suite not set yet\n    strncpy(cipher_name_, \"NONE\", 5);\n\n    removeDH_ = !haveDH;   // only use on server side for set suites\n\n    if (ciphers.setSuites_) {   // use user set list\n        suites_size_ = ciphers.suiteSz_;\n        memcpy(suites_, ciphers.suites_, ciphers.suiteSz_);\n        SetCipherNames();\n    }\n    else \n        SetSuites(pv, ce == server_end && removeDH_);  // defaults\n\n}\n\n\nvoid Parameters::SetSuites(ProtocolVersion pv, bool removeDH, bool removeRSA,\n                           bool removeDSA)\n{\n    int i = 0;\n    // available suites, best first\n    // when adding more, make sure cipher_names is updated and\n    //      MAX_CIPHERS is big enough\n\n    if (isTLS(pv)) {\n        if (!removeDH) {\n            if (!removeRSA) {\n                suites_[i++] = 0x00;\n                suites_[i++] = TLS_DHE_RSA_WITH_AES_256_CBC_SHA;\n            }\n            if (!removeDSA) {\n                suites_[i++] = 0x00;\n                suites_[i++] = TLS_DHE_DSS_WITH_AES_256_CBC_SHA;\n            }\n        }\n        if (!removeRSA) {\n            suites_[i++] = 0x00;\n            suites_[i++] = TLS_RSA_WITH_AES_256_CBC_SHA;\n        }\n        if (!removeDH) {\n            if (!removeRSA) {\n                suites_[i++] = 0x00;\n                suites_[i++] = TLS_DHE_RSA_WITH_AES_128_CBC_SHA;\n            }\n            if (!removeDSA) {\n                suites_[i++] = 0x00;\n                suites_[i++] = TLS_DHE_DSS_WITH_AES_128_CBC_SHA;\n            }\n        }\n        if (!removeRSA) {\n            suites_[i++] = 0x00;\n            suites_[i++] = TLS_RSA_WITH_AES_128_CBC_SHA;\n            suites_[i++] = 0x00;\n            suites_[i++] = TLS_RSA_WITH_AES_256_CBC_RMD160;\n            suites_[i++] = 0x00;\n            suites_[i++] = TLS_RSA_WITH_AES_128_CBC_RMD160;\n            suites_[i++] = 0x00;\n            suites_[i++] = TLS_RSA_WITH_3DES_EDE_CBC_RMD160;\n        }\n        if (!removeDH) {\n            if (!removeRSA) {\n                suites_[i++] = 0x00;\n                suites_[i++] = TLS_DHE_RSA_WITH_AES_256_CBC_RMD160;\n                suites_[i++] = 0x00;\n                suites_[i++] = TLS_DHE_RSA_WITH_AES_128_CBC_RMD160;\n                suites_[i++] = 0x00;\n                suites_[i++] = TLS_DHE_RSA_WITH_3DES_EDE_CBC_RMD160;\n            }\n            if (!removeDSA) {\n                suites_[i++] = 0x00;\n                suites_[i++] = TLS_DHE_DSS_WITH_AES_256_CBC_RMD160;\n                suites_[i++] = 0x00;\n                suites_[i++] = TLS_DHE_DSS_WITH_AES_128_CBC_RMD160;\n                suites_[i++] = 0x00;\n                suites_[i++] = TLS_DHE_DSS_WITH_3DES_EDE_CBC_RMD160;\n            }\n        }\n    }\n\n    if (!removeRSA) {\n        suites_[i++] = 0x00;\n        suites_[i++] = SSL_RSA_WITH_RC4_128_SHA;  \n        suites_[i++] = 0x00;\n        suites_[i++] = SSL_RSA_WITH_RC4_128_MD5;\n\n        suites_[i++] = 0x00;\n        suites_[i++] = SSL_RSA_WITH_3DES_EDE_CBC_SHA;\n        suites_[i++] = 0x00;\n        suites_[i++] = SSL_RSA_WITH_DES_CBC_SHA;\n    }\n    if (!removeDH) {\n        if (!removeRSA) {\n            suites_[i++] = 0x00;\n            suites_[i++] = SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA;\n        }\n        if (!removeDSA) {\n            suites_[i++] = 0x00;\n            suites_[i++] = SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA;\n        }\n        if (!removeRSA) {\n            suites_[i++] = 0x00;\n            suites_[i++] = SSL_DHE_RSA_WITH_DES_CBC_SHA;\n        }\n        if (!removeDSA) {\n            suites_[i++] = 0x00;\n            suites_[i++] = SSL_DHE_DSS_WITH_DES_CBC_SHA;\n        }\n    }\n\n    suites_size_ = i;\n\n    SetCipherNames();\n}\n\n\nvoid Parameters::SetCipherNames()\n{\n    const int suites = suites_size_ / 2;\n    int pos = 0;\n\n    for (int j = 0; j < suites; j++) {\n        int index = suites_[j*2 + 1];  // every other suite is suite id\n        size_t len = strlen(cipher_names[index]) + 1;\n        strncpy(cipher_list_[pos++], cipher_names[index], len);\n    }\n    cipher_list_[pos][0] = 0;\n}\n\n\n// input operator for RecordLayerHeader, adjust stream\ninput_buffer& operator>>(input_buffer& input, RecordLayerHeader& hdr)\n{\n    hdr.type_ = ContentType(input[AUTO]);\n    hdr.version_.major_ = input[AUTO];\n    hdr.version_.minor_ = input[AUTO];\n\n    // length\n    byte tmp[2];\n    tmp[0] = input[AUTO];\n    tmp[1] = input[AUTO];\n    ato16(tmp, hdr.length_);\n\n    return input;\n}\n\n\n// output operator for RecordLayerHeader\noutput_buffer& operator<<(output_buffer& output, const RecordLayerHeader& hdr)\n{\n    output[AUTO] = hdr.type_;\n    output[AUTO] = hdr.version_.major_;\n    output[AUTO] = hdr.version_.minor_;\n    \n    // length\n    byte tmp[2];\n    c16toa(hdr.length_, tmp);\n    output[AUTO] = tmp[0];\n    output[AUTO] = tmp[1];\n\n    return output;\n}\n\n\n// virtual input operator for Messages\ninput_buffer& operator>>(input_buffer& input, Message& msg)\n{\n    return msg.set(input);\n}\n\n// virtual output operator for Messages\noutput_buffer& operator<<(output_buffer& output, const Message& msg)\n{\n    return msg.get(output);\n}\n\n\n// input operator for HandShakeHeader\ninput_buffer& operator>>(input_buffer& input, HandShakeHeader& hs)\n{\n    hs.type_ = HandShakeType(input[AUTO]);\n\n    hs.length_[0] = input[AUTO];\n    hs.length_[1] = input[AUTO];\n    hs.length_[2] = input[AUTO];\n    \n    return input;\n}\n\n\n// output operator for HandShakeHeader\noutput_buffer& operator<<(output_buffer& output, const HandShakeHeader& hdr)\n{\n    output[AUTO] = hdr.type_;\n    output.write(hdr.length_, sizeof(hdr.length_));\n    return output;\n}\n\n\n// HandShake Header Processing function\nvoid HandShakeHeader::Process(input_buffer& input, SSL& ssl)\n{\n    ssl.verifyState(*this);\n    if (ssl.GetError()) return;\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n    const HandShakeFactory& hsf = ssl.getFactory().getHandShake();\n    mySTL::auto_ptr<HandShakeBase> hs(hsf.CreateObject(type_));\n    if (!hs.get()) {\n        ssl.SetError(factory_error);\n        return;\n    }\n\n    uint len = c24to32(length_);\n    if (len > input.get_remaining()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n    hashHandShake(ssl, input, len);\n\n    hs->set_length(len);\n    input >> *hs;\n    hs->Process(input, ssl);\n}\n\n\nContentType HandShakeHeader::get_type() const\n{\n    return handshake;\n}\n\n\nuint16 HandShakeHeader::get_length() const\n{\n    return c24to32(length_);\n}\n\n\nHandShakeType HandShakeHeader::get_handshakeType() const\n{\n    return type_;\n}\n\n\nvoid HandShakeHeader::set_type(HandShakeType hst)\n{\n    type_ = hst;\n}\n\n\nvoid HandShakeHeader::set_length(uint32 u32)\n{\n    c32to24(u32, length_);\n}\n\n\ninput_buffer& HandShakeHeader::set(input_buffer& in)\n{\n    return in >> *this;\n}\n\n\noutput_buffer& HandShakeHeader::get(output_buffer& out) const\n{\n    return out << *this;\n}\n\n\n\nint HandShakeBase::get_length() const\n{\n    return length_;\n}\n\n\nvoid HandShakeBase::set_length(int l)\n{\n    length_ = l;\n}\n\n\n// for building buffer's type field\nHandShakeType HandShakeBase::get_type() const\n{\n    return no_shake;\n}\n\n\ninput_buffer& HandShakeBase::set(input_buffer& in)\n{\n    return in;\n}\n\n \noutput_buffer& HandShakeBase::get(output_buffer& out) const\n{\n    return out;\n}\n\n\nvoid HandShakeBase::Process(input_buffer&, SSL&) \n{}\n\n\ninput_buffer& HelloRequest::set(input_buffer& in)\n{\n    return in;\n}\n\n\noutput_buffer& HelloRequest::get(output_buffer& out) const\n{\n    return out;\n}\n\n\nvoid HelloRequest::Process(input_buffer&, SSL&)\n{}\n\n\nHandShakeType HelloRequest::get_type() const\n{\n    return hello_request;\n}\n\n\n// input operator for CipherSpec\ninput_buffer& operator>>(input_buffer& input, ChangeCipherSpec& cs)\n{\n    cs.type_ = CipherChoice(input[AUTO]);\n    return input; \n}\n\n// output operator for CipherSpec\noutput_buffer& operator<<(output_buffer& output, const ChangeCipherSpec& cs)\n{\n    output[AUTO] = cs.type_;\n    return output;\n}\n\n\nChangeCipherSpec::ChangeCipherSpec() \n    : type_(change_cipher_spec_choice)\n{}\n\n\ninput_buffer& ChangeCipherSpec::set(input_buffer& in)\n{\n    return in >> *this;\n}\n\n\noutput_buffer& ChangeCipherSpec::get(output_buffer& out) const\n{\n    return out << *this;\n}\n\n\nContentType ChangeCipherSpec::get_type() const\n{\n    return change_cipher_spec;\n}\n\n\nuint16 ChangeCipherSpec::get_length() const\n{\n    return SIZEOF_ENUM;\n}\n\n\n// CipherSpec processing handler\nvoid ChangeCipherSpec::Process(input_buffer& input, SSL& ssl)\n{\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    // detect duplicate change_cipher\n    if (ssl.getSecurity().get_parms().pending_ == false) {\n        ssl.order_error();\n        return;\n    }\n\n    ssl.useSecurity().use_parms().pending_ = false;\n    if (ssl.getSecurity().get_resuming()) {\n        if (ssl.getSecurity().get_parms().entity_ == client_end)\n            buildFinished(ssl, ssl.useHashes().use_verify(), server); // server\n    }\n    else if (ssl.getSecurity().get_parms().entity_ == server_end)\n        buildFinished(ssl, ssl.useHashes().use_verify(), client);     // client\n}\n\n\nAlert::Alert(AlertLevel al, AlertDescription ad)\n    : level_(al), description_(ad)\n{}\n\n\nContentType Alert::get_type() const\n{\n    return alert;\n}\n\n\nuint16 Alert::get_length() const\n{\n    return SIZEOF_ENUM * 2;\n}\n\n\ninput_buffer& Alert::set(input_buffer& in)\n{\n    return in >> *this;\n}\n\n\noutput_buffer& Alert::get(output_buffer& out) const\n{\n    return out << *this;\n}\n\n\n// input operator for Alert\ninput_buffer& operator>>(input_buffer& input, Alert& a)\n{\n    a.level_ = AlertLevel(input[AUTO]);\n    a.description_ = AlertDescription(input[AUTO]);\n \n    return input;\n}\n\n\n// output operator for Alert\noutput_buffer& operator<<(output_buffer& output, const Alert& a)\n{\n    output[AUTO] = a.level_;\n    output[AUTO] = a.description_;\n    return output;\n}\n\n\n// Alert processing handler\nvoid Alert::Process(input_buffer& input, SSL& ssl)\n{\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    if (ssl.getSecurity().get_parms().pending_ == false)  { // encrypted alert\n        int            aSz = get_length();  // alert size already read on input\n        opaque         verify[SHA_LEN];\n        const  opaque* data = input.get_buffer() + input.get_current() - aSz;\n\n        if (ssl.isTLS())\n            TLS_hmac(ssl, verify, data, aSz, alert, true);\n        else\n            hmac(ssl, verify, data, aSz, alert, true);\n\n        // read mac and skip fill\n        int    digestSz = ssl.getCrypto().get_digest().get_digestSize();\n        opaque mac[SHA_LEN];\n        input.read(mac, digestSz);\n\n        if (ssl.getSecurity().get_parms().cipher_type_ == block) {\n            int    ivExtra = 0;\n            opaque fill;\n\n            if (ssl.isTLSv1_1())\n                ivExtra = ssl.getCrypto().get_cipher().get_blockSize();\n            int padSz = ssl.getSecurity().get_parms().encrypt_size_ - ivExtra -\n                        aSz - digestSz;\n            for (int i = 0; i < padSz; i++) \n                fill = input[AUTO];\n        }\n\n        if (input.get_error()) {\n            ssl.SetError(bad_input);\n            return;\n        }\n\n        // verify\n        if (memcmp(mac, verify, digestSz)) {\n            ssl.SetError(verify_error);\n            return;\n        }\n    }\n    if (level_ == fatal) {\n        ssl.useStates().useRecord()    = recordNotReady;\n        ssl.useStates().useHandShake() = handShakeNotReady;\n        ssl.SetError(YasslError(description_));\n    }\n}\n\n\nData::Data()\n    : length_(0), buffer_(0), write_buffer_(0)\n{}\n\n\nData::Data(uint16 len, opaque* b)\n    : length_(len), buffer_(b), write_buffer_(0)\n{}\n\n\nvoid Data::SetData(uint16 len, const opaque* buffer)\n{\n    length_ = len;\n    write_buffer_ = buffer;\n}\n\ninput_buffer& Data::set(input_buffer& in)\n{\n    return in;\n}\n\n\noutput_buffer& Data::get(output_buffer& out) const\n{\n    return out << *this;\n}\n\n\nContentType Data::get_type() const\n{\n    return application_data;\n}\n\n\nuint16 Data::get_length() const\n{\n    return length_;\n}\n\n\nvoid Data::set_length(uint16 l)\n{\n    length_ = l;\n}\n\n\nopaque* Data::set_buffer()\n{\n    return buffer_;\n}\n\n\n// output operator for Data\noutput_buffer& operator<<(output_buffer& output, const Data& data)\n{\n    output.write(data.write_buffer_, data.length_);\n    return output;\n}\n\n\n// check all bytes for equality \nstatic int constant_compare(const byte* a, const byte* b, int len)\n{\n    int good = 0;\n    int bad  = 0;\n\n    for (int i = 0; i < len; i++) {\n        if (a[i] == b[i])\n            good++;\n        else\n            bad++;\n    }\n\n    if (good == len)\n        return 0;\n    else\n        return 0 - bad;  // failure\n}\n\n\n// check bytes for pad value\nstatic int pad_check(const byte* input, byte pad, int len)\n{\n    int good = 0;\n    int bad  = 0;\n\n    for (int i = 0; i < len; i++) {\n        if (input[i] == pad)\n            good++;\n        else\n            bad++;\n    }\n\n    if (good == len)\n        return 0;\n    else\n        return 0 - bad;  // failure\n}\n\n\n// get number of compression rounds\nstatic inline int get_rounds(int pLen, int padLen, int t)\n{\n    int  roundL1 = 1;  // round ups \n    int  roundL2 = 1;\n\n    int L1 = COMPRESS_CONSTANT + pLen - t;\n    int L2 = COMPRESS_CONSTANT + pLen - padLen - 1 - t;\n\n    L1 -= COMPRESS_UPPER;\n    L2 -= COMPRESS_UPPER;\n\n    if ( (L1 % COMPRESS_LOWER) == 0)\n        roundL1 = 0;\n    if ( (L2 % COMPRESS_LOWER) == 0)\n        roundL2 = 0;\n\n    L1 /= COMPRESS_LOWER;\n    L2 /= COMPRESS_LOWER;\n\n    L1 += roundL1;\n    L2 += roundL2;\n\n    return L1 - L2;\n}\n\n\n// do compression rounds on dummy data\nstatic inline void compress_rounds(SSL& ssl, int rounds, const byte* dummy)\n{\n    if (rounds) {\n        Digest* digest = NULL;\n\n        MACAlgorithm ma = ssl.getSecurity().get_parms().mac_algorithm_;\n        if (ma == sha) \n            digest = NEW_YS SHA;\n        else if (ma == md5)\n            digest = NEW_YS MD5;\n        else if (ma == rmd)\n            digest = NEW_YS RMD;\n        else\n            return;\n\n        for (int i = 0; i < rounds; i++)\n            digest->update(dummy, COMPRESS_LOWER);\n\n        ysDelete(digest);    \n    }\n}\n\n\n// timing resistant pad verification\nstatic int timing_verify(SSL& ssl, const byte* input, int padLen, int t,\n                         int pLen)\n{\n    byte verify[SHA_LEN];\n    byte dummy[MAX_PAD_SIZE];\n\n    memset(dummy, 1, sizeof(dummy));\n\n    if ( (t + padLen + 1) > pLen) {\n        pad_check(dummy, (byte)padLen, MAX_PAD_SIZE);\n        if (ssl.isTLS())\n            TLS_hmac(ssl, verify, input, pLen - t, application_data, 1);\n        else\n            hmac(ssl, verify, input, pLen - t, application_data, 1);\n        constant_compare(verify, input + pLen - t, t);\n\n        return -1;\n    }\n\n    if (pad_check(input + pLen - (padLen + 1), (byte)padLen, padLen + 1) != 0) {\n        pad_check(dummy, (byte)padLen, MAX_PAD_SIZE - padLen - 1);\n        if (ssl.isTLS())\n            TLS_hmac(ssl, verify, input, pLen - t, application_data, 1);\n        else\n            hmac(ssl, verify, input, pLen - t, application_data, 1);\n        constant_compare(verify, input + pLen - t, t);\n\n        return -1;\n    }\n\n    pad_check(dummy, (byte)padLen, MAX_PAD_SIZE - padLen - 1);\n    if (ssl.isTLS())\n        TLS_hmac(ssl, verify, input, pLen - padLen - 1 - t, application_data,1);\n    else\n        hmac(ssl, verify, input, pLen - padLen - 1 - t, application_data, 1);\n\n    compress_rounds(ssl, get_rounds(pLen, padLen, t), dummy);\n\n    if (constant_compare(verify, input + (pLen - padLen - 1 - t), t) != 0)\n        return -1;\n\n    return 0;\n}\n\n\n// Process handler for Data\nvoid Data::Process(input_buffer& input, SSL& ssl)\n{\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    int msgSz = ssl.getSecurity().get_parms().encrypt_size_;\n    int pad   = 0, padSz = 0;\n    int ivExtra = 0;\n    int digestSz = ssl.getCrypto().get_digest().get_digestSize();\n    const byte* rawData = input.get_buffer() + input.get_current();\n    opaque verify[SHA_LEN];\n\n    if (ssl.getSecurity().get_parms().cipher_type_ == block) {\n        if (ssl.isTLSv1_1())  // IV\n            ivExtra = ssl.getCrypto().get_cipher().get_blockSize();\n        pad = *(input.get_buffer() + input.get_current() + msgSz -ivExtra - 1);\n        padSz = 1;\n\n        if (ssl.isTLS()) {\n            if (timing_verify(ssl, rawData, pad,digestSz, msgSz-ivExtra) != 0) {\n                ssl.SetError(verify_error);\n                return;\n            }\n        }\n        else {   // SSLv3, some don't do this padding right\n            int sz3 = msgSz - digestSz - pad - 1; \n            hmac(ssl, verify, rawData, sz3, application_data, true);\n            if (constant_compare(verify, rawData + sz3, digestSz) != 0) {\n                ssl.SetError(verify_error);\n                return;\n            }\n        } \n    }\n    else {  // stream\n        int streamSz = msgSz - digestSz; \n        if (ssl.isTLS())\n            TLS_hmac(ssl, verify, rawData, streamSz, application_data, true);\n        else\n            hmac(ssl, verify, rawData, streamSz, application_data, true);\n        if (constant_compare(verify, rawData + streamSz, digestSz) != 0) {\n            ssl.SetError(verify_error);\n            return;\n        }\n    }\n\n    int dataSz = msgSz - ivExtra - digestSz - pad - padSz;\n\n    if (dataSz < 0 || dataSz > (MAX_RECORD_SIZE + COMPRESS_EXTRA)) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    // read data\n    if (dataSz) {                               // could be compressed\n        if (ssl.CompressionOn()) {\n            input_buffer tmp;\n            if (DeCompress(input, dataSz, tmp) == -1) {\n                ssl.SetError(decompress_error);\n                return;\n            }\n            ssl.addData(NEW_YS input_buffer(tmp.get_size(),\n                                            tmp.get_buffer(), tmp.get_size()));\n        }\n        else {\n            input_buffer* data;\n            ssl.addData(data = NEW_YS input_buffer(dataSz));\n            input.read(data->get_buffer(), dataSz);\n            data->add_size(dataSz);\n        }\n    }\n\n    // advance past mac and fill\n    input.set_current(input.get_current() + digestSz + pad + padSz);\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n}\n\n\n// virtual input operator for HandShakes\ninput_buffer& operator>>(input_buffer& input, HandShakeBase& hs)\n{\n    return hs.set(input);\n}\n\n\n// virtual output operator for HandShakes\noutput_buffer& operator<<(output_buffer& output, const HandShakeBase& hs)\n{\n    return hs.get(output);\n}\n\n\nCertificate::Certificate(const x509* cert) : cert_(cert) \n{\n    if (cert)\n      set_length(cert_->get_length() + 2 * CERT_HEADER); // list and cert size\n    else\n      set_length(CERT_HEADER); // total blank cert size, just list header\n}\n\n\nconst opaque* Certificate::get_buffer() const\n{\n    if (cert_)\n      return cert_->get_buffer();\n\n    return NULL;\n}\n\n\n// output operator for Certificate\noutput_buffer& operator<<(output_buffer& output, const Certificate& cert)\n{\n    uint sz = cert.get_length();\n    opaque tmp[CERT_HEADER];\n\n    if ((int)sz > CERT_HEADER)\n      sz -= 2 * CERT_HEADER;  // actual cert, not including headers\n    else {\n      sz = 0;                 // blank cert case\n      c32to24(sz, tmp);\n      output.write(tmp, CERT_HEADER);\n\n      return output;\n    }\n\n    c32to24(sz + CERT_HEADER, tmp);\n    output.write(tmp, CERT_HEADER);\n    c32to24(sz, tmp);\n    output.write(tmp, CERT_HEADER);\n    output.write(cert.get_buffer(), sz);\n\n    return output;\n}\n\n\n// certificate processing handler\nvoid Certificate::Process(input_buffer& input, SSL& ssl)\n{\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    CertManager& cm = ssl.useCrypto().use_certManager();\n  \n    uint32 list_sz;\n    byte   tmp[3];\n\n    if (input.get_remaining() < sizeof(tmp)) {\n        ssl.SetError(YasslError(bad_input));\n        return;\n    }\n    tmp[0] = input[AUTO];\n    tmp[1] = input[AUTO];\n    tmp[2] = input[AUTO];\n    c24to32(tmp, list_sz);\n\n    if (list_sz > (uint)MAX_RECORD_SIZE) { // sanity check\n        ssl.SetError(YasslError(bad_input));\n        return;\n    }\n    \n    while (list_sz) {\n        // cert size\n        uint32 cert_sz;\n\n        if (input.get_remaining() < sizeof(tmp)) {\n            ssl.SetError(YasslError(bad_input));\n            return;\n        }\n        tmp[0] = input[AUTO];\n        tmp[1] = input[AUTO];\n        tmp[2] = input[AUTO];\n        c24to32(tmp, cert_sz);\n        \n        if (cert_sz > (uint)MAX_RECORD_SIZE || input.get_remaining() < cert_sz){\n            ssl.SetError(YasslError(bad_input));\n            return;\n        }\n        if (cert_sz) {\n          x509* myCert;\n          cm.AddPeerCert(myCert = NEW_YS x509(cert_sz));\n          input.read(myCert->use_buffer(), myCert->get_length());\n        }\n\n        list_sz -= cert_sz + CERT_HEADER;\n    }\n    if (int err = cm.Validate())\n        ssl.SetError(YasslError(err));\n    else if (ssl.getSecurity().get_parms().entity_ == client_end)\n        ssl.useStates().useClient() = serverCertComplete;\n}\n\n\nCertificate::Certificate()\n    : cert_(0)\n{}\n\n\ninput_buffer& Certificate::set(input_buffer& in)\n{\n    return in;\n}\n\n\noutput_buffer& Certificate::get(output_buffer& out) const\n{\n    return out << *this;\n}\n\n\nHandShakeType Certificate::get_type() const\n{\n    return certificate;\n}\n\n\nServerDHParams::ServerDHParams()\n    : pSz_(0), gSz_(0), pubSz_(0), p_(0), g_(0), Ys_(0)\n{}\n\n\nServerDHParams::~ServerDHParams()\n{\n    ysArrayDelete(Ys_);\n    ysArrayDelete(g_);\n    ysArrayDelete(p_);\n}\n\n\nint ServerDHParams::get_pSize() const\n{\n    return pSz_;\n}\n\n\nint ServerDHParams::get_gSize() const\n{\n    return gSz_;\n}\n\n\nint ServerDHParams::get_pubSize() const\n{\n    return pubSz_;\n}\n\n\nconst opaque* ServerDHParams::get_p() const\n{\n    return p_;\n}\n\n\nconst opaque* ServerDHParams::get_g() const\n{\n    return g_;\n}\n\n\nconst opaque* ServerDHParams::get_pub() const\n{\n    return Ys_;\n}\n\n\nopaque* ServerDHParams::alloc_p(int sz)\n{\n    p_ = NEW_YS opaque[pSz_ = sz];\n    return p_;\n}\n\n\nopaque* ServerDHParams::alloc_g(int sz)\n{\n    g_ = NEW_YS opaque[gSz_ = sz];\n    return g_;\n}\n\n\nopaque* ServerDHParams::alloc_pub(int sz)\n{\n    Ys_ = NEW_YS opaque[pubSz_ = sz];\n    return Ys_;\n}\n\n\nint ServerKeyBase::get_length() const\n{\n    return 0;\n}\n\n\nopaque* ServerKeyBase::get_serverKey() const\n{\n    return 0;\n}\n\n\n// input operator for ServerHello\ninput_buffer& operator>>(input_buffer& input, ServerHello& hello)\n{ \n    // Protocol\n    hello.server_version_.major_ = input[AUTO];\n    hello.server_version_.minor_ = input[AUTO];\n   \n    // Random\n    input.read(hello.random_, RAN_LEN);\n    \n    // Session\n    hello.id_len_ = input[AUTO];\n    if (hello.id_len_ > ID_LEN) {\n        input.set_error(); \n        return input;\n    }\n    if (hello.id_len_)\n        input.read(hello.session_id_, hello.id_len_);\n \n    // Suites\n    hello.cipher_suite_[0] = input[AUTO];\n    hello.cipher_suite_[1] = input[AUTO];\n   \n    // Compression\n    hello.compression_method_ = CompressionMethod(input[AUTO]);\n\n    return input;\n}\n\n\n// output operator for ServerHello\noutput_buffer& operator<<(output_buffer& output, const ServerHello& hello)\n{\n    // Protocol\n    output[AUTO] = hello.server_version_.major_;\n    output[AUTO] = hello.server_version_.minor_;\n\n    // Random\n    output.write(hello.random_, RAN_LEN);\n\n    // Session\n    output[AUTO] = hello.id_len_;\n    output.write(hello.session_id_, ID_LEN);\n\n    // Suites\n    output[AUTO] = hello.cipher_suite_[0];\n    output[AUTO] = hello.cipher_suite_[1];\n\n    // Compression\n    output[AUTO] = hello.compression_method_;\n\n    return output;\n}\n\n\n// Server Hello processing handler\nvoid ServerHello::Process(input_buffer& input, SSL& ssl)\n{\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    if (ssl.GetMultiProtocol()) {   // SSLv23 support\n        if (ssl.isTLS() && server_version_.minor_ < 1)\n            // downgrade to SSLv3\n            ssl.useSecurity().use_connection().TurnOffTLS();\n        else if (ssl.isTLSv1_1() && server_version_.minor_ == 1)\n            // downdrage to TLSv1\n            ssl.useSecurity().use_connection().TurnOffTLS1_1();\n    }\n    else if (ssl.isTLSv1_1() && server_version_.minor_ < 2) {\n        ssl.SetError(badVersion_error);\n        return;\n    }\n    else if (ssl.isTLS() && server_version_.minor_ < 1) {\n        ssl.SetError(badVersion_error);\n        return;\n    }\n    else if (!ssl.isTLS() && (server_version_.major_ == 3 &&\n                              server_version_.minor_ >= 1)) {\n        ssl.SetError(badVersion_error);\n        return;\n    }\n    ssl.set_pending(cipher_suite_[1]);\n    ssl.set_random(random_, server_end);\n    if (id_len_)\n        ssl.set_sessionID(session_id_);\n    else\n        ssl.useSecurity().use_connection().sessionID_Set_ = false;\n\n    if (ssl.getSecurity().get_resuming()) {\n        if (memcmp(session_id_, ssl.getSecurity().get_resume().GetID(),\n                   ID_LEN) == 0) {\n            ssl.set_masterSecret(ssl.getSecurity().get_resume().GetSecret());\n            if (ssl.isTLS())\n                ssl.deriveTLSKeys();\n            else\n                ssl.deriveKeys();\n            ssl.useStates().useClient() = serverHelloDoneComplete;\n            return;\n        }\n        else {\n            ssl.useSecurity().set_resuming(false);\n            ssl.useLog().Trace(\"server denied resumption\");\n        }\n    }\n\n    if (ssl.CompressionOn() && !compression_method_)\n        ssl.UnSetCompression(); // server isn't supporting yaSSL zlib request\n\n    ssl.useStates().useClient() = serverHelloComplete;\n}\n\n\nServerHello::ServerHello()\n{\n    memset(random_, 0, RAN_LEN);\n    memset(session_id_, 0, ID_LEN);\n}\n\n\nServerHello::ServerHello(ProtocolVersion pv, bool useCompression)\n    : server_version_(pv),\n      compression_method_(useCompression ? zlib : no_compression)\n{\n    memset(random_, 0, RAN_LEN);\n    memset(session_id_, 0, ID_LEN);\n}\n\n\ninput_buffer& ServerHello::set(input_buffer& in)\n{\n    return in  >> *this;\n}\n\n\noutput_buffer& ServerHello::get(output_buffer& out) const\n{\n    return out << *this;\n}\n\n\nHandShakeType ServerHello::get_type() const\n{\n    return server_hello;\n}\n\n\nconst opaque* ServerHello::get_random() const\n{\n    return random_;\n}\n\n\n// Server Hello Done processing handler\nvoid ServerHelloDone::Process(input_buffer& input, SSL& ssl)\n{\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n    ssl.useStates().useClient() = serverHelloDoneComplete;\n}\n\n\nServerHelloDone::ServerHelloDone()\n{\n    set_length(0);\n}\n\n\ninput_buffer& ServerHelloDone::set(input_buffer& in)\n{\n    return in;\n}\n\n\noutput_buffer& ServerHelloDone::get(output_buffer& out) const\n{\n    return out;\n}\n\n\nHandShakeType ServerHelloDone::get_type() const\n{\n    return server_hello_done;\n}\n\n\nint ClientKeyBase::get_length() const\n{\n    return 0;\n}\n\n\nopaque* ClientKeyBase::get_clientKey() const\n{\n    return 0;\n}\n\n\n// input operator for Client Hello\ninput_buffer& operator>>(input_buffer& input, ClientHello& hello)\n{\n    uint begin = input.get_current();  // could have extensions at end\n\n    // Protocol\n    hello.client_version_.major_ = input[AUTO];\n    hello.client_version_.minor_ = input[AUTO];\n\n    // Random\n    input.read(hello.random_, RAN_LEN);\n\n    // Session\n    hello.id_len_ = input[AUTO];\n    if (hello.id_len_) input.read(hello.session_id_, ID_LEN);\n    \n    // Suites\n    byte   tmp[2];\n    uint16 len;\n    tmp[0] = input[AUTO];\n    tmp[1] = input[AUTO];\n    ato16(tmp, len);\n\n    hello.suite_len_ = min(len, static_cast<uint16>(MAX_SUITE_SZ));\n    input.read(hello.cipher_suites_, hello.suite_len_);\n    if (len > hello.suite_len_)  // ignore extra suites\n        input.set_current(input.get_current() + len - hello.suite_len_);\n\n    // Compression\n    hello.comp_len_ = input[AUTO];\n    hello.compression_methods_ = no_compression;\n    while (hello.comp_len_--) {\n        CompressionMethod cm = CompressionMethod(input[AUTO]);\n        if (cm == zlib)\n            hello.compression_methods_ = zlib;\n    }\n\n    uint read = input.get_current() - begin;\n    uint expected = hello.get_length();\n\n    // ignore client hello extensions for now\n    if (read < expected)\n        input.set_current(input.get_current() + expected - read);\n\n    return input;\n}\n\n\n// output operaotr for Client Hello\noutput_buffer& operator<<(output_buffer& output, const ClientHello& hello)\n{ \n    // Protocol\n    output[AUTO] = hello.client_version_.major_;\n    output[AUTO] = hello.client_version_.minor_;\n\n    // Random\n    output.write(hello.random_, RAN_LEN);\n\n    // Session\n    output[AUTO] = hello.id_len_;\n    if (hello.id_len_) output.write(hello.session_id_, ID_LEN);\n\n    // Suites\n    byte tmp[2];\n    c16toa(hello.suite_len_, tmp);\n    output[AUTO] = tmp[0];\n    output[AUTO] = tmp[1];\n    output.write(hello.cipher_suites_, hello.suite_len_);\n  \n    // Compression\n    output[AUTO] = hello.comp_len_;\n    output[AUTO] = hello.compression_methods_;\n\n    return output;\n}\n\n\n// Client Hello processing handler\nvoid ClientHello::Process(input_buffer& input, SSL& ssl)\n{\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    // store version for pre master secret\n    ssl.useSecurity().use_connection().chVersion_ = client_version_;\n\n    if (client_version_.major_ != 3) {\n        ssl.SetError(badVersion_error);\n        return;\n    }\n    if (ssl.GetMultiProtocol()) {   // SSLv23 support\n        if (ssl.isTLS() && client_version_.minor_ < 1) {\n            // downgrade to SSLv3\n            ssl.useSecurity().use_connection().TurnOffTLS();\n            \n            ProtocolVersion pv = ssl.getSecurity().get_connection().version_;\n            bool removeDH  = ssl.getSecurity().get_parms().removeDH_;\n            bool removeRSA = false;\n            bool removeDSA = false;\n            \n            const CertManager& cm = ssl.getCrypto().get_certManager();\n            if (cm.get_keyType() == rsa_sa_algo)\n                removeDSA = true;\n            else\n                removeRSA = true;\n            \n            // reset w/ SSL suites\n            ssl.useSecurity().use_parms().SetSuites(pv, removeDH, removeRSA,\n                                                    removeDSA);\n        }\n        else if (ssl.isTLSv1_1() && client_version_.minor_ == 1)\n            // downgrade to TLSv1, but use same suites\n            ssl.useSecurity().use_connection().TurnOffTLS1_1();\n    }\n    else if (ssl.isTLSv1_1() && client_version_.minor_ < 2) {\n        ssl.SetError(badVersion_error);\n        return;\n    }\n    else if (ssl.isTLS() && client_version_.minor_ < 1) {\n        ssl.SetError(badVersion_error);\n        return;\n    }\n    else if (!ssl.isTLS() && client_version_.minor_ >= 1) {\n        ssl.SetError(badVersion_error);\n        return;\n    }\n\n    ssl.set_random(random_, client_end);\n\n    while (id_len_) {  // trying to resume\n        SSL_SESSION* session = 0;\n        if (!ssl.getSecurity().GetContext()->GetSessionCacheOff())\n            session = GetSessions().lookup(session_id_);\n        if (!session)  {\n            ssl.useLog().Trace(\"session lookup failed\");\n            break;\n        }\n        ssl.set_session(session);\n        ssl.useSecurity().set_resuming(true);\n        ssl.matchSuite(session->GetSuite(), SUITE_LEN);\n        if (ssl.GetError()) return;\n        ssl.set_pending(ssl.getSecurity().get_parms().suite_[1]);\n        ssl.set_masterSecret(session->GetSecret());\n\n        opaque serverRandom[RAN_LEN];\n        ssl.getCrypto().get_random().Fill(serverRandom, sizeof(serverRandom));\n        ssl.set_random(serverRandom, server_end);\n        if (ssl.isTLS())\n            ssl.deriveTLSKeys();\n        else\n            ssl.deriveKeys();\n        ssl.useStates().useServer() = clientKeyExchangeComplete;\n        return;\n    }\n    ssl.matchSuite(cipher_suites_, suite_len_);\n    if (ssl.GetError()) return;\n    ssl.set_pending(ssl.getSecurity().get_parms().suite_[1]);\n\n    if (compression_methods_ == zlib)\n        ssl.SetCompression();\n\n    ssl.useStates().useServer() = clientHelloComplete;\n}\n\n\ninput_buffer& ClientHello::set(input_buffer& in)\n{\n    return in  >> *this;\n}\n\n\noutput_buffer& ClientHello::get(output_buffer& out) const\n{\n    return out << *this;\n}\n\n\nHandShakeType ClientHello::get_type() const\n{\n    return client_hello;\n}\n\n\nconst opaque* ClientHello::get_random() const\n{\n    return random_;\n}\n\n\nClientHello::ClientHello()\n{\n    memset(random_, 0, RAN_LEN);\n}\n\n\nClientHello::ClientHello(ProtocolVersion pv, bool useCompression)\n    : client_version_(pv),\n      compression_methods_(useCompression ? zlib : no_compression)\n{\n    memset(random_, 0, RAN_LEN);\n}\n\n\n// output operator for ServerKeyExchange\noutput_buffer& operator<<(output_buffer& output, const ServerKeyExchange& sk)\n{\n    output.write(sk.getKey(), sk.getKeyLength());\n    return output;\n}\n\n\n// Server Key Exchange processing handler\nvoid ServerKeyExchange::Process(input_buffer& input, SSL& ssl)\n{\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n    createKey(ssl);\n    if (ssl.GetError()) return;\n    server_key_->read(ssl, input);\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    ssl.useStates().useClient() = serverKeyExchangeComplete;\n}\n\n\nServerKeyExchange::ServerKeyExchange(SSL& ssl)\n{\n    createKey(ssl);\n}\n\n\nServerKeyExchange::ServerKeyExchange()\n    : server_key_(0)\n{}\n\n\nServerKeyExchange::~ServerKeyExchange()\n{\n    ysDelete(server_key_);\n}\n\n\nvoid ServerKeyExchange::build(SSL& ssl) \n{ \n    server_key_->build(ssl); \n    set_length(server_key_->get_length());\n}\n\n\nconst opaque* ServerKeyExchange::getKey() const\n{\n    return server_key_->get_serverKey();\n}\n\n\nint ServerKeyExchange::getKeyLength() const\n{\n    return server_key_->get_length();\n}\n\n\ninput_buffer& ServerKeyExchange::set(input_buffer& in)\n{\n    return in;      // process does\n}\n\n\noutput_buffer& ServerKeyExchange::get(output_buffer& out) const\n{\n    return out << *this;\n}\n\n\nHandShakeType ServerKeyExchange::get_type() const\n{\n    return server_key_exchange;\n}\n\n\n// CertificateRequest \nCertificateRequest::CertificateRequest()\n    : typeTotal_(0)\n{\n    memset(certificate_types_, 0, sizeof(certificate_types_));\n}\n\n\nCertificateRequest::~CertificateRequest()\n{\n\n    STL::for_each(certificate_authorities_.begin(),\n                  certificate_authorities_.end(),\n                  del_ptr_zero()) ;\n}\n\n\nvoid CertificateRequest::Build()\n{\n    certificate_types_[0] = rsa_sign;\n    certificate_types_[1] = dss_sign;\n\n    typeTotal_ = 2;\n\n    uint16 authCount = 0;\n    uint16 authSz = 0;\n  \n    for (int j = 0; j < authCount; j++) {\n        int sz = REQUEST_HEADER + MIN_DIS_SIZE;\n        DistinguishedName dn;\n        certificate_authorities_.push_back(dn = NEW_YS byte[sz]);\n\n        opaque tmp[REQUEST_HEADER];\n        c16toa(MIN_DIS_SIZE, tmp);\n        memcpy(dn, tmp, sizeof(tmp));\n  \n        // fill w/ junk for now\n        memcpy(dn, tmp, MIN_DIS_SIZE);\n        authSz += sz;\n    }\n\n    set_length(SIZEOF_ENUM + typeTotal_ + REQUEST_HEADER + authSz);\n}\n\n\ninput_buffer& CertificateRequest::set(input_buffer& in)\n{\n    return in >> *this;\n}\n\n\noutput_buffer& CertificateRequest::get(output_buffer& out) const\n{\n    return out << *this;\n}\n\n\n// input operator for CertificateRequest\ninput_buffer& operator>>(input_buffer& input, CertificateRequest& request)\n{\n    // types\n    request.typeTotal_ = input[AUTO];\n    if (request.typeTotal_ > CERT_TYPES) {\n        input.set_error();\n        return input;\n    }\n    for (int i = 0; i < request.typeTotal_; i++)\n        request.certificate_types_[i] = ClientCertificateType(input[AUTO]);\n\n    byte tmp[2];\n    tmp[0] = input[AUTO];\n    tmp[1] = input[AUTO];\n    uint16 sz;\n    ato16(tmp, sz);\n\n    // authorities\n    while (sz) {\n        uint16 dnSz;\n        tmp[0] = input[AUTO];\n        tmp[1] = input[AUTO];\n        ato16(tmp, dnSz);\n       \n        input.set_current(input.get_current() + dnSz);\n\n        sz -= dnSz + REQUEST_HEADER;\n\n        if (input.get_error())\n            break;\n    }\n\n    return input;\n}\n\n\n// output operator for CertificateRequest\noutput_buffer& operator<<(output_buffer& output,\n                          const CertificateRequest& request)\n{\n    // types\n    output[AUTO] = request.typeTotal_;\n    for (int i = 0; i < request.typeTotal_; i++)\n        output[AUTO] = request.certificate_types_[i];\n\n    // authorities\n    opaque tmp[REQUEST_HEADER];\n    c16toa(request.get_length() - SIZEOF_ENUM -\n           request.typeTotal_ - REQUEST_HEADER, tmp);\n    output.write(tmp, sizeof(tmp));\n\n    STL::list<DistinguishedName>::const_iterator first =\n                                    request.certificate_authorities_.begin();\n    STL::list<DistinguishedName>::const_iterator last =\n                                    request.certificate_authorities_.end();\n    while (first != last) {\n        uint16 sz;\n        ato16(*first, sz);\n        output.write(*first, sz + REQUEST_HEADER);\n\n        ++first;\n    }\n\n    return output;\n}\n\n\n// CertificateRequest processing handler\nvoid CertificateRequest::Process(input_buffer& input, SSL& ssl)\n{\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n    CertManager& cm = ssl.useCrypto().use_certManager();\n\n    cm.setSendVerify();\n    if (cm.get_cert() == NULL || cm.get_privateKey() == NULL)\n      cm.setSendBlankCert();  // send blank cert, OpenSSL requires now\n}\n\n\nHandShakeType CertificateRequest::get_type() const\n{\n    return certificate_request;\n}\n\n\n// CertificateVerify \nCertificateVerify::CertificateVerify() : signature_(0)\n{}\n\n\nCertificateVerify::~CertificateVerify()\n{\n    ysArrayDelete(signature_);\n}\n\n\nvoid CertificateVerify::Build(SSL& ssl)\n{\n    build_certHashes(ssl, hashes_);\n\n    uint16 sz = 0;\n    byte   len[VERIFY_HEADER];\n    mySTL::auto_array<byte> sig;\n\n    // sign\n    const CertManager& cert = ssl.getCrypto().get_certManager();\n    if (cert.get_keyType() == rsa_sa_algo) {\n        RSA rsa(cert.get_privateKey(), cert.get_privateKeyLength(), false);\n\n        sz = rsa.get_cipherLength() + VERIFY_HEADER;\n        sig.reset(NEW_YS byte[sz]);\n\n        c16toa(sz - VERIFY_HEADER, len);\n        memcpy(sig.get(), len, VERIFY_HEADER);\n        rsa.sign(sig.get() + VERIFY_HEADER, hashes_.md5_, sizeof(Hashes),\n                 ssl.getCrypto().get_random());\n    }\n    else {  // DSA\n        DSS dss(cert.get_privateKey(), cert.get_privateKeyLength(), false);\n\n        sz = DSS_SIG_SZ + DSS_ENCODED_EXTRA + VERIFY_HEADER;\n        sig.reset(NEW_YS byte[sz]);\n\n        c16toa(sz - VERIFY_HEADER, len);\n        memcpy(sig.get(), len, VERIFY_HEADER);\n        dss.sign(sig.get() + VERIFY_HEADER, hashes_.sha_, SHA_LEN,\n                 ssl.getCrypto().get_random());\n\n        byte encoded[DSS_SIG_SZ + DSS_ENCODED_EXTRA];\n        TaoCrypt::EncodeDSA_Signature(sig.get() + VERIFY_HEADER, encoded);\n        memcpy(sig.get() + VERIFY_HEADER, encoded, sizeof(encoded));\n    }\n    set_length(sz);\n    signature_ = sig.release();\n}\n\n\ninput_buffer& CertificateVerify::set(input_buffer& in)\n{\n    return in >> *this;\n}\n\n\noutput_buffer& CertificateVerify::get(output_buffer& out) const\n{\n    return out << *this;\n}\n\n\n// input operator for CertificateVerify\ninput_buffer& operator>>(input_buffer& input, CertificateVerify& request)\n{\n    byte tmp[VERIFY_HEADER];\n    tmp[0] = input[AUTO];\n    tmp[1] = input[AUTO];\n\n    uint16 sz = 0;\n    ato16(tmp, sz);\n    request.set_length(sz);\n\n    if (sz == 0) {\n        input.set_error();\n        return input;\n    }\n\n    request.signature_ = NEW_YS byte[sz];\n    input.read(request.signature_, sz);\n\n    return input;\n}\n\n\n// output operator for CertificateVerify\noutput_buffer& operator<<(output_buffer& output,\n                          const CertificateVerify& verify)\n{\n    output.write(verify.signature_, verify.get_length());\n\n    return output;\n}\n\n\n// CertificateVerify processing handler\nvoid CertificateVerify::Process(input_buffer& input, SSL& ssl)\n{\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    const Hashes&      hashVerify = ssl.getHashes().get_certVerify();\n    const CertManager& cert       = ssl.getCrypto().get_certManager();\n\n    if (cert.get_peerKeyType() == rsa_sa_algo) {\n        RSA rsa(cert.get_peerKey(), cert.get_peerKeyLength());\n\n        if (!rsa.verify(hashVerify.md5_, sizeof(hashVerify), signature_,\n                        get_length()))\n            ssl.SetError(verify_error);\n    }\n    else { // DSA\n        byte decodedSig[DSS_SIG_SZ];\n        TaoCrypt::DecodeDSA_Signature(decodedSig, signature_, get_length());\n        \n        DSS dss(cert.get_peerKey(), cert.get_peerKeyLength());\n        if (!dss.verify(hashVerify.sha_, SHA_LEN, decodedSig, get_length()))\n            ssl.SetError(verify_error);\n    }\n}\n\n\nHandShakeType CertificateVerify::get_type() const\n{\n    return certificate_verify;\n}\n\n\n// output operator for ClientKeyExchange\noutput_buffer& operator<<(output_buffer& output, const ClientKeyExchange& ck)\n{\n    output.write(ck.getKey(), ck.getKeyLength());\n    return output;\n}\n\n\n// Client Key Exchange processing handler\nvoid ClientKeyExchange::Process(input_buffer& input, SSL& ssl)\n{\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n    createKey(ssl);\n    if (ssl.GetError()) return;\n    client_key_->read(ssl, input);\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    if (ssl.getCrypto().get_certManager().verifyPeer())\n        build_certHashes(ssl, ssl.useHashes().use_certVerify());\n\n    ssl.useStates().useServer() = clientKeyExchangeComplete;\n}\n\n\nClientKeyExchange::ClientKeyExchange(SSL& ssl)\n{\n    createKey(ssl);\n}\n\n\nClientKeyExchange::ClientKeyExchange()\n    : client_key_(0)\n{}\n\n\nClientKeyExchange::~ClientKeyExchange()\n{\n    ysDelete(client_key_);\n}\n\n\nvoid ClientKeyExchange::build(SSL& ssl) \n{ \n    client_key_->build(ssl); \n    set_length(client_key_->get_length());\n}\n\nconst opaque* ClientKeyExchange::getKey() const\n{\n    return client_key_->get_clientKey();\n}\n\n\nint ClientKeyExchange::getKeyLength() const\n{\n    return client_key_->get_length();\n}\n\n\ninput_buffer& ClientKeyExchange::set(input_buffer& in)\n{\n    return in;\n}\n\n\noutput_buffer& ClientKeyExchange::get(output_buffer& out) const\n{\n    return out << *this;\n}\n\n\nHandShakeType ClientKeyExchange::get_type() const\n{\n    return client_key_exchange;\n}\n\n\n// input operator for Finished\ninput_buffer& operator>>(input_buffer& input, Finished&)\n{\n    /*  do in process */\n\n    return input; \n}\n\n// output operator for Finished\noutput_buffer& operator<<(output_buffer& output, const Finished& fin)\n{\n    if (fin.get_length() == FINISHED_SZ) {\n        output.write(fin.hashes_.md5_, MD5_LEN);\n        output.write(fin.hashes_.sha_, SHA_LEN);\n    }\n    else    // TLS_FINISHED_SZ\n        output.write(fin.hashes_.md5_, TLS_FINISHED_SZ);\n\n    return output;\n}\n\n\n// Finished processing handler\nvoid Finished::Process(input_buffer& input, SSL& ssl)\n{\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n    // verify hashes\n    const  Finished& verify = ssl.getHashes().get_verify();\n    uint finishedSz = ssl.isTLS() ? TLS_FINISHED_SZ : FINISHED_SZ;\n    \n    input.read(hashes_.md5_, finishedSz);\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    if (memcmp(&hashes_, &verify.hashes_, finishedSz)) {\n        ssl.SetError(verify_error);\n        return;\n    }\n\n    // read verify mac\n    opaque verifyMAC[SHA_LEN];\n    uint macSz = finishedSz + HANDSHAKE_HEADER;\n\n    if (ssl.isTLS())\n        TLS_hmac(ssl, verifyMAC, input.get_buffer() + input.get_current()\n                 - macSz, macSz, handshake, true);\n    else\n        hmac(ssl, verifyMAC, input.get_buffer() + input.get_current() - macSz,\n             macSz, handshake, true);\n\n    // read mac and fill\n    opaque mac[SHA_LEN];   // max size\n    int    digestSz = ssl.getCrypto().get_digest().get_digestSize();\n    input.read(mac, digestSz);\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    uint ivExtra = 0;\n    if (ssl.getSecurity().get_parms().cipher_type_ == block)\n        if (ssl.isTLSv1_1())\n            ivExtra = ssl.getCrypto().get_cipher().get_blockSize();\n\n    opaque fill;\n    int    padSz = ssl.getSecurity().get_parms().encrypt_size_ - ivExtra -\n                     HANDSHAKE_HEADER - finishedSz - digestSz;\n    for (int i = 0; i < padSz; i++) \n        fill = input[AUTO];\n    if (input.get_error()) {\n        ssl.SetError(bad_input);\n        return;\n    }\n\n    // verify mac\n    if (memcmp(mac, verifyMAC, digestSz)) {\n        ssl.SetError(verify_error);\n        return;\n    }\n\n    // update states\n    ssl.useStates().useHandShake() = handShakeReady;\n    if (ssl.getSecurity().get_parms().entity_ == client_end)\n        ssl.useStates().useClient() = serverFinishedComplete;\n    else\n        ssl.useStates().useServer() = clientFinishedComplete;\n}\n\n\nFinished::Finished()\n{\n    set_length(FINISHED_SZ);\n}\n\n\nuint8* Finished::set_md5()\n{\n    return hashes_.md5_;\n}\n\n\nuint8* Finished::set_sha()\n{\n    return hashes_.sha_;\n}\n\n\ninput_buffer& Finished::set(input_buffer& in)\n{\n    return in  >> *this;\n}\n\n\noutput_buffer& Finished::get(output_buffer& out) const\n{\n    return out << *this;\n}\n\n\nHandShakeType Finished::get_type() const\n{\n    return finished;\n}\n\n\nvoid clean(volatile opaque* p, uint sz, RandomPool& ran)\n{\n    uint i(0);\n\n    for (i = 0; i < sz; ++i)\n        p[i] = 0;\n\n    ran.Fill(const_cast<opaque*>(p), sz);\n\n    for (i = 0; i < sz; ++i)\n        p[i] = 0;\n}\n\n\n\nConnection::Connection(ProtocolVersion v, RandomPool& ran)\n    : pre_master_secret_(0), sequence_number_(0), peer_sequence_number_(0),\n      pre_secret_len_(0), send_server_key_(false), master_clean_(false),\n      TLS_(v.major_ >= 3 && v.minor_ >= 1),\n      TLSv1_1_(v.major_ >= 3 && v.minor_ >= 2), compression_(false),\n      version_(v), random_(ran)\n{\n    memset(sessionID_, 0, sizeof(sessionID_));\n}\n\n\nConnection::~Connection() \n{ \n    CleanMaster(); CleanPreMaster(); ysArrayDelete(pre_master_secret_);\n}\n\n\nvoid Connection::AllocPreSecret(uint sz) \n{ \n    pre_master_secret_ = NEW_YS opaque[pre_secret_len_ = sz];\n}\n\n\nvoid Connection::TurnOffTLS()\n{\n    TLS_ = false;\n    version_.minor_ = 0;\n}\n\n\nvoid Connection::TurnOffTLS1_1()\n{\n    TLSv1_1_ = false;\n    version_.minor_ = 1;\n}\n\n\n// wipeout master secret\nvoid Connection::CleanMaster()\n{\n    if (!master_clean_) {\n        volatile opaque* p = master_secret_;\n        clean(p, SECRET_LEN, random_);\n        master_clean_ = true;\n    }\n}\n\n\n// wipeout pre master secret\nvoid Connection::CleanPreMaster()\n{\n    if (pre_master_secret_) {\n        volatile opaque* p = pre_master_secret_;\n        clean(p, pre_secret_len_, random_);\n\n        ysArrayDelete(pre_master_secret_);\n        pre_master_secret_ = 0;\n    }\n}\n\n\n// Create functions for message factory\nMessage* CreateCipherSpec() { return NEW_YS ChangeCipherSpec; }\nMessage* CreateAlert()      { return NEW_YS Alert; }\nMessage* CreateHandShake()  { return NEW_YS HandShakeHeader; }\nMessage* CreateData()       { return NEW_YS Data; }\n\n// Create functions for handshake factory\nHandShakeBase* CreateHelloRequest()       { return NEW_YS HelloRequest; }\nHandShakeBase* CreateClientHello()        { return NEW_YS ClientHello; }\nHandShakeBase* CreateServerHello()        { return NEW_YS ServerHello; }\nHandShakeBase* CreateCertificate()        { return NEW_YS Certificate; }\nHandShakeBase* CreateServerKeyExchange()  { return NEW_YS ServerKeyExchange;}\nHandShakeBase* CreateCertificateRequest() { return NEW_YS \n                                                    CertificateRequest; }\nHandShakeBase* CreateServerHelloDone()    { return NEW_YS ServerHelloDone; }\nHandShakeBase* CreateCertificateVerify()  { return NEW_YS CertificateVerify;}\nHandShakeBase* CreateClientKeyExchange()  { return NEW_YS ClientKeyExchange;}\nHandShakeBase* CreateFinished()           { return NEW_YS Finished; }\n\n// Create functions for server key exchange factory\nServerKeyBase* CreateRSAServerKEA()       { return NEW_YS RSA_Server; }\nServerKeyBase* CreateDHServerKEA()        { return NEW_YS DH_Server; }\nServerKeyBase* CreateFortezzaServerKEA()  { return NEW_YS Fortezza_Server; }\n\n// Create functions for client key exchange factory\nClientKeyBase* CreateRSAClient()      { return NEW_YS \n                                                EncryptedPreMasterSecret; }\nClientKeyBase* CreateDHClient()       { return NEW_YS \n                                                ClientDiffieHellmanPublic; }\nClientKeyBase* CreateFortezzaClient() { return NEW_YS FortezzaKeys; }\n\n\n// Constructor calls this to Register compile time callbacks\nvoid InitMessageFactory(MessageFactory& mf)\n{\n    mf.Reserve(4);\n    mf.Register(alert, CreateAlert);\n    mf.Register(change_cipher_spec, CreateCipherSpec);\n    mf.Register(handshake, CreateHandShake);\n    mf.Register(application_data, CreateData);\n}\n\n\n// Constructor calls this to Register compile time callbacks\nvoid InitHandShakeFactory(HandShakeFactory& hsf)\n{\n    hsf.Reserve(10);\n    hsf.Register(hello_request, CreateHelloRequest);\n    hsf.Register(client_hello, CreateClientHello);\n    hsf.Register(server_hello, CreateServerHello);\n    hsf.Register(certificate, CreateCertificate);\n    hsf.Register(server_key_exchange, CreateServerKeyExchange);\n    hsf.Register(certificate_request, CreateCertificateRequest);\n    hsf.Register(server_hello_done, CreateServerHelloDone);\n    hsf.Register(certificate_verify, CreateCertificateVerify);\n    hsf.Register(client_key_exchange, CreateClientKeyExchange);\n    hsf.Register(finished, CreateFinished);\n}\n\n\n// Constructor calls this to Register compile time callbacks\nvoid InitServerKeyFactory(ServerKeyFactory& skf)\n{\n    skf.Reserve(3);\n    skf.Register(rsa_kea, CreateRSAServerKEA);\n    skf.Register(diffie_hellman_kea, CreateDHServerKEA);\n    skf.Register(fortezza_kea, CreateFortezzaServerKEA);\n}\n\n\n// Constructor calls this to Register compile time callbacks\nvoid InitClientKeyFactory(ClientKeyFactory& ckf)\n{\n    ckf.Reserve(3);\n    ckf.Register(rsa_kea, CreateRSAClient);\n    ckf.Register(diffie_hellman_kea, CreateDHClient);\n    ckf.Register(fortezza_kea, CreateFortezzaClient);\n}\n\n\n} // namespace\n"
  },
  {
    "path": "ext/yassl/src/yassl_int.cpp",
    "content": "/* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; if not, write to the Free Software\n   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */\n\n/* yaSSL internal source implements SSL supporting types not specified in the\n * draft along with type conversion functions.\n */\n\n// First include (the generated) my_config.h, to get correct platform defines.\n#include \"router_config.h\"\n#ifdef _WIN32\n#include<Windows.h>\n#else\n#include <pthread.h>\n#endif\n\n#include \"runtime.hpp\"\n#include \"yassl_int.hpp\"\n#include \"handshake.hpp\"\n#include \"timer.hpp\"\n\n#ifdef HAVE_LIBZ\n    #include \"zlib.h\"\n#endif\n\n\n#ifdef YASSL_PURE_C\n\n    void* operator new(size_t sz, yaSSL::new_t)\n    {\n        void* ptr = malloc(sz ? sz : 1);\n        if (!ptr) abort();\n\n        return ptr;\n    }\n\n\n    void operator delete(void* ptr, yaSSL::new_t)\n    {\n        if (ptr) free(ptr);\n    }\n\n\n    void* operator new[](size_t sz, yaSSL::new_t nt)\n    {\n        return ::operator new(sz, nt);\n    }\n\n\n    void operator delete[](void* ptr, yaSSL::new_t nt)\n    {\n        ::operator delete(ptr, nt);\n    }\n\n    namespace yaSSL {\n\n        new_t ys;   // for yaSSL library new\n\n    }\n\n#endif // YASSL_PURE_C\n\n/* for the definition of get_tty_password() */\n//#include <mysql/get_password.h>\ntypedef char *(* strdup_handler_t)(const char *, int);\nextern char *get_tty_password_ext(const char *opt_message,\n                               strdup_handler_t strdup_function);\n\nnamespace yaSSL {\n\n\n\n\n\n\n// convert a 32 bit integer into a 24 bit one\nvoid c32to24(uint32 u32, uint24& u24)\n{\n    u24[0] = (u32 >> 16) & 0xff;\n    u24[1] = (u32 >>  8) & 0xff;\n    u24[2] =  u32 & 0xff;\n}\n\n\n// convert a 24 bit integer into a 32 bit one\nvoid c24to32(const uint24 u24, uint32& u32)\n{\n    u32 = 0;\n    u32 = (u24[0] << 16) | (u24[1] << 8) | u24[2];\n}\n\n\n// convert with return for ease of use\nuint32 c24to32(const uint24 u24)\n{\n    uint32 ret;\n    c24to32(u24, ret);\n\n    return ret;\n}\n\n\n// using a for opaque since underlying type is unsgined char and o is not a\n// good leading identifier\n\n// convert opaque to 16 bit integer\nvoid ato16(const opaque* c, uint16& u16)\n{\n    u16 = 0;\n    u16 = (c[0] << 8) | (c[1]);\n}\n\n\n// convert (copy) opaque to 24 bit integer\nvoid ato24(const opaque* c, uint24& u24)\n{\n    u24[0] = c[0];\n    u24[1] = c[1];\n    u24[2] = c[2];\n}\n\n\n// convert 16 bit integer to opaque\nvoid c16toa(uint16 u16, opaque* c)\n{\n    c[0] = (u16 >> 8) & 0xff;\n    c[1] =  u16 & 0xff;\n}\n\n\n// convert 24 bit integer to opaque\nvoid c24toa(const uint24 u24, opaque* c)\n{\n    c[0] =  u24[0]; \n    c[1] =  u24[1];\n    c[2] =  u24[2];\n}\n\n\n// convert 32 bit integer to opaque\nvoid c32toa(uint32 u32, opaque* c)\n{\n    c[0] = (u32 >> 24) & 0xff;\n    c[1] = (u32 >> 16) & 0xff;\n    c[2] = (u32 >>  8) & 0xff;\n    c[3] =  u32 & 0xff;\n}\n\n\nStates::States() : recordLayer_(recordReady), handshakeLayer_(preHandshake),\n           clientState_(serverNull),  serverState_(clientNull),\n           connectState_(CONNECT_BEGIN), acceptState_(ACCEPT_BEGIN),\n           what_(no_error) {}\n\nconst RecordLayerState& States::getRecord() const \n{\n    return recordLayer_;\n}\n\n\nconst HandShakeState& States::getHandShake() const\n{\n    return handshakeLayer_;\n}\n\n\nconst ClientState& States::getClient() const\n{\n    return clientState_;\n}\n\n\nconst ServerState& States::getServer() const\n{\n    return serverState_;\n}\n\n\nconst ConnectState& States::GetConnect() const\n{\n    return connectState_;\n}\n\n\nconst AcceptState& States::GetAccept() const\n{\n    return acceptState_;\n}\n\n\nconst char* States::getString() const\n{\n    return errorString_;\n}\n\n\nYasslError States::What() const\n{\n    return what_;\n}\n\n\nRecordLayerState& States::useRecord()\n{\n    return recordLayer_;\n}\n\n\nHandShakeState& States::useHandShake()\n{\n    return handshakeLayer_;\n}\n\n\nClientState& States::useClient()\n{\n    return clientState_;\n}\n\n\nServerState& States::useServer()\n{\n    return serverState_;\n}\n\n\nConnectState& States::UseConnect()\n{\n    return connectState_;\n}\n\n\nAcceptState& States::UseAccept()\n{\n    return acceptState_;\n}\n\n\nchar* States::useString()\n{\n    return errorString_;\n}\n\n\nvoid States::SetError(YasslError ye)\n{\n    what_ = ye;\n}\n\n\n// mark message recvd, check for duplicates, return 0 on success\nint States::SetMessageRecvd(HandShakeType hst)\n{\n    switch (hst) {\n        case hello_request:\n            break;  // could send more than one\n\n        case client_hello:\n            if (recvdMessages_.gotClientHello_)\n                return -1;\n            recvdMessages_.gotClientHello_ = 1;\n            break;\n\n        case server_hello:\n            if (recvdMessages_.gotServerHello_)\n                return -1;\n            recvdMessages_.gotServerHello_ = 1;\n            break;\n\n        case certificate:\n            if (recvdMessages_.gotCert_)\n                return -1;\n            recvdMessages_.gotCert_ = 1;\n            break;\n\n        case server_key_exchange:\n            if (recvdMessages_.gotServerKeyExchange_)\n                return -1;\n            recvdMessages_.gotServerKeyExchange_ = 1;\n            break;\n\n        case certificate_request:\n            if (recvdMessages_.gotCertRequest_)\n                return -1;\n            recvdMessages_.gotCertRequest_ = 1;\n            break;\n\n        case server_hello_done:\n            if (recvdMessages_.gotServerHelloDone_)\n                return -1;\n            recvdMessages_.gotServerHelloDone_ = 1;\n            break;\n\n        case certificate_verify:\n            if (recvdMessages_.gotCertVerify_)\n                return -1;\n            recvdMessages_.gotCertVerify_ = 1;\n            break;\n\n        case client_key_exchange:\n            if (recvdMessages_.gotClientKeyExchange_)\n                return -1;\n            recvdMessages_.gotClientKeyExchange_ = 1;\n            break;\n\n        case finished:\n            if (recvdMessages_.gotFinished_)\n                return -1;\n            recvdMessages_.gotFinished_ = 1;\n            break;\n\n\n        default:\n            return -1;\n\n    }\n\n    return 0;\n}\n\n\nsslFactory::sslFactory() :           \n        messageFactory_(InitMessageFactory),\n        handShakeFactory_(InitHandShakeFactory),\n        serverKeyFactory_(InitServerKeyFactory),\n        clientKeyFactory_(InitClientKeyFactory) \n{}\n\n\nconst MessageFactory& sslFactory::getMessage() const\n{\n    return messageFactory_;\n}\n\n\nconst HandShakeFactory& sslFactory::getHandShake() const\n{\n    return handShakeFactory_;\n}\n\n\nconst ServerKeyFactory& sslFactory::getServerKey() const\n{\n    return serverKeyFactory_;\n}\n\n\nconst ClientKeyFactory& sslFactory::getClientKey() const\n{\n    return clientKeyFactory_;\n}\n\n\n// extract context parameters and store\nSSL::SSL(SSL_CTX* ctx) \n    : secure_(ctx->getMethod()->getVersion(), crypto_.use_random(),\n              ctx->getMethod()->getSide(), ctx->GetCiphers(), ctx,\n              ctx->GetDH_Parms().set_), quietShutdown_(false), has_data_(false)\n{\n    if (int err = crypto_.get_random().GetError()) {\n        SetError(YasslError(err));\n        return;\n    }\n\n    CertManager& cm = crypto_.use_certManager();\n    cm.CopySelfCert(ctx->getCert());\n\n    bool serverSide = secure_.use_parms().entity_ == server_end;\n\n    if (ctx->getKey()) {\n        if (int err = cm.SetPrivateKey(*ctx->getKey())) {\n            SetError(YasslError(err));\n            return;\n        }\n        else if (serverSide && !(ctx->GetCiphers().setSuites_)) {\n            // remove RSA or DSA suites depending on cert key type\n            ProtocolVersion pv = secure_.get_connection().version_;\n            \n            bool removeDH  = secure_.use_parms().removeDH_;\n            bool removeRSA = false;\n            bool removeDSA = false;\n            \n            if (cm.get_keyType() == rsa_sa_algo)\n                removeDSA = true;\n            else\n                removeRSA = true;\n            secure_.use_parms().SetSuites(pv, removeDH, removeRSA, removeDSA);\n        }\n    }\n    else if (serverSide) {\n        SetError(no_key_file);\n        return;\n    }\n\n    if (ctx->getMethod()->verifyPeer())\n        cm.setVerifyPeer();\n    if (ctx->getMethod()->verifyNone())\n        cm.setVerifyNone();\n    if (ctx->getMethod()->failNoCert())\n        cm.setFailNoCert();\n    cm.setVerifyCallback(ctx->getVerifyCallback());\n\n    if (serverSide)\n        crypto_.SetDH(ctx->GetDH_Parms());\n\n    const SSL_CTX::CertList& ca = ctx->GetCA_List();\n    SSL_CTX::CertList::const_iterator first(ca.begin());\n    SSL_CTX::CertList::const_iterator last(ca.end());\n\n    while (first != last) {\n        if (int err = cm.CopyCaCert(*first)) {\n            SetError(YasslError(err));\n            return;\n        }\n        ++first;\n    }\n}\n\n\n// store pending security parameters from Server Hello\nvoid SSL::set_pending(Cipher suite)\n{\n    Parameters& parms = secure_.use_parms();\n\n    switch (suite) {\n\n    case TLS_RSA_WITH_AES_256_CBC_SHA:\n        parms.bulk_cipher_algorithm_ = aes;\n        parms.mac_algorithm_         = sha;\n        parms.kea_                   = rsa_kea;\n        parms.hash_size_ = SHA_LEN;\n        parms.key_size_  = AES_256_KEY_SZ;\n        parms.iv_size_   = AES_BLOCK_SZ;\n        parms.cipher_type_ = block;\n        crypto_.setDigest(NEW_YS SHA);\n        crypto_.setCipher(NEW_YS AES(AES_256_KEY_SZ));\n        strncpy(parms.cipher_name_, cipher_names[TLS_RSA_WITH_AES_256_CBC_SHA],\n                MAX_SUITE_NAME);\n        break;\n\n    case TLS_RSA_WITH_AES_128_CBC_SHA:\n        parms.bulk_cipher_algorithm_ = aes;\n        parms.mac_algorithm_         = sha;\n        parms.kea_                   = rsa_kea;\n        parms.hash_size_ = SHA_LEN;\n        parms.key_size_  = AES_128_KEY_SZ;\n        parms.iv_size_   = AES_BLOCK_SZ;\n        parms.cipher_type_ = block;\n        crypto_.setDigest(NEW_YS SHA);\n        crypto_.setCipher(NEW_YS AES);\n        strncpy(parms.cipher_name_, cipher_names[TLS_RSA_WITH_AES_128_CBC_SHA],\n                MAX_SUITE_NAME);\n        break;\n\n    case SSL_RSA_WITH_3DES_EDE_CBC_SHA:\n        parms.bulk_cipher_algorithm_ = triple_des;\n        parms.mac_algorithm_         = sha;\n        parms.kea_                   = rsa_kea;\n        parms.hash_size_ = SHA_LEN;\n        parms.key_size_  = DES_EDE_KEY_SZ;\n        parms.iv_size_   = DES_IV_SZ;\n        parms.cipher_type_ = block;\n        crypto_.setDigest(NEW_YS SHA);\n        crypto_.setCipher(NEW_YS DES_EDE);\n        strncpy(parms.cipher_name_, cipher_names[SSL_RSA_WITH_3DES_EDE_CBC_SHA]\n                , MAX_SUITE_NAME);\n        break;\n\n    case SSL_RSA_WITH_DES_CBC_SHA:\n        parms.bulk_cipher_algorithm_ = des;\n        parms.mac_algorithm_         = sha;\n        parms.kea_                   = rsa_kea;\n        parms.hash_size_ = SHA_LEN;\n        parms.key_size_  = DES_KEY_SZ;\n        parms.iv_size_   = DES_IV_SZ;\n        parms.cipher_type_ = block;\n        crypto_.setDigest(NEW_YS SHA);\n        crypto_.setCipher(NEW_YS DES);\n        strncpy(parms.cipher_name_, cipher_names[SSL_RSA_WITH_DES_CBC_SHA],\n                MAX_SUITE_NAME);\n        break;\n\n    case SSL_RSA_WITH_RC4_128_SHA:\n        parms.bulk_cipher_algorithm_ = rc4;\n        parms.mac_algorithm_         = sha;\n        parms.kea_                   = rsa_kea;\n        parms.hash_size_ = SHA_LEN;\n        parms.key_size_  = RC4_KEY_SZ;\n        parms.iv_size_   = 0;\n        parms.cipher_type_ = stream;\n        crypto_.setDigest(NEW_YS SHA);\n        crypto_.setCipher(NEW_YS RC4);\n        strncpy(parms.cipher_name_, cipher_names[SSL_RSA_WITH_RC4_128_SHA],\n                MAX_SUITE_NAME);\n        break;\n\n    case SSL_RSA_WITH_RC4_128_MD5:\n        parms.bulk_cipher_algorithm_ = rc4;\n        parms.mac_algorithm_         = md5;\n        parms.kea_                   = rsa_kea;\n        parms.hash_size_ = MD5_LEN;\n        parms.key_size_  = RC4_KEY_SZ;\n        parms.iv_size_   = 0;\n        parms.cipher_type_ = stream;\n        crypto_.setDigest(NEW_YS MD5);\n        crypto_.setCipher(NEW_YS RC4);\n        strncpy(parms.cipher_name_, cipher_names[SSL_RSA_WITH_RC4_128_MD5],\n                MAX_SUITE_NAME);\n        break;\n\n    case SSL_DHE_RSA_WITH_DES_CBC_SHA:\n        parms.bulk_cipher_algorithm_ = des;\n        parms.mac_algorithm_         = sha;\n        parms.kea_                   = diffie_hellman_kea;\n        parms.sig_algo_              = rsa_sa_algo;\n        parms.hash_size_ = SHA_LEN;\n        parms.key_size_  = DES_KEY_SZ;\n        parms.iv_size_   = DES_IV_SZ;\n        parms.cipher_type_ = block;\n        secure_.use_connection().send_server_key_  = true; // eph\n        crypto_.setDigest(NEW_YS SHA);\n        crypto_.setCipher(NEW_YS DES);\n        strncpy(parms.cipher_name_, cipher_names[SSL_DHE_RSA_WITH_DES_CBC_SHA],\n                MAX_SUITE_NAME);\n        break;\n\n    case SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA:\n        parms.bulk_cipher_algorithm_ = triple_des;\n        parms.mac_algorithm_         = sha;\n        parms.kea_                   = diffie_hellman_kea;\n        parms.sig_algo_              = rsa_sa_algo;\n        parms.hash_size_ = SHA_LEN;\n        parms.key_size_  = DES_EDE_KEY_SZ;\n        parms.iv_size_   = DES_IV_SZ;\n        parms.cipher_type_ = block;\n        secure_.use_connection().send_server_key_  = true; // eph\n        crypto_.setDigest(NEW_YS SHA);\n        crypto_.setCipher(NEW_YS DES_EDE);\n        strncpy(parms.cipher_name_,\n              cipher_names[SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA], MAX_SUITE_NAME);\n        break;\n\n    case TLS_DHE_RSA_WITH_AES_256_CBC_SHA:\n        parms.bulk_cipher_algorithm_ = aes;\n        parms.mac_algorithm_         = sha;\n        parms.kea_                   = diffie_hellman_kea;\n        parms.sig_algo_              = rsa_sa_algo;\n        parms.hash_size_ = SHA_LEN;\n        parms.key_size_  = AES_256_KEY_SZ;\n        parms.iv_size_   = AES_BLOCK_SZ;\n        parms.cipher_type_ = block;\n        secure_.use_connection().send_server_key_  = true; // eph\n        crypto_.setDigest(NEW_YS SHA);\n        crypto_.setCipher(NEW_YS AES(AES_256_KEY_SZ));\n        strncpy(parms.cipher_name_,\n               cipher_names[TLS_DHE_RSA_WITH_AES_256_CBC_SHA], MAX_SUITE_NAME);\n        break;\n\n    case TLS_DHE_RSA_WITH_AES_128_CBC_SHA:\n        parms.bulk_cipher_algorithm_ = aes;\n        parms.mac_algorithm_         = sha;\n        parms.kea_                   = diffie_hellman_kea;\n        parms.sig_algo_              = rsa_sa_algo;\n        parms.hash_size_ = SHA_LEN;\n        parms.key_size_  = AES_128_KEY_SZ;\n        parms.iv_size_   = AES_BLOCK_SZ;\n        parms.cipher_type_ = block;\n        secure_.use_connection().send_server_key_  = true; // eph\n        crypto_.setDigest(NEW_YS SHA);\n        crypto_.setCipher(NEW_YS AES);\n        strncpy(parms.cipher_name_,\n               cipher_names[TLS_DHE_RSA_WITH_AES_128_CBC_SHA], MAX_SUITE_NAME);\n        break;\n\n    case SSL_DHE_DSS_WITH_DES_CBC_SHA:\n        parms.bulk_cipher_algorithm_ = des;\n        parms.mac_algorithm_         = sha;\n        parms.kea_                   = diffie_hellman_kea;\n        parms.sig_algo_              = dsa_sa_algo;\n        parms.hash_size_ = SHA_LEN;\n        parms.key_size_  = DES_KEY_SZ;\n        parms.iv_size_   = DES_IV_SZ;\n        parms.cipher_type_ = block;\n        secure_.use_connection().send_server_key_  = true; // eph\n        crypto_.setDigest(NEW_YS SHA);\n        crypto_.setCipher(NEW_YS DES);\n        strncpy(parms.cipher_name_, cipher_names[SSL_DHE_DSS_WITH_DES_CBC_SHA],\n                MAX_SUITE_NAME);\n        break;\n\n    case SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA:\n        parms.bulk_cipher_algorithm_ = triple_des;\n        parms.mac_algorithm_         = sha;\n        parms.kea_                   = diffie_hellman_kea;\n        parms.sig_algo_              = dsa_sa_algo;\n        parms.hash_size_ = SHA_LEN;\n        parms.key_size_  = DES_EDE_KEY_SZ;\n        parms.iv_size_   = DES_IV_SZ;\n        parms.cipher_type_ = block;\n        secure_.use_connection().send_server_key_  = true; // eph\n        crypto_.setDigest(NEW_YS SHA);\n        crypto_.setCipher(NEW_YS DES_EDE);\n        strncpy(parms.cipher_name_,\n              cipher_names[SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA], MAX_SUITE_NAME);\n        break;\n\n    case TLS_DHE_DSS_WITH_AES_256_CBC_SHA:\n        parms.bulk_cipher_algorithm_ = aes;\n        parms.mac_algorithm_         = sha;\n        parms.kea_                   = diffie_hellman_kea;\n        parms.sig_algo_              = dsa_sa_algo;\n        parms.hash_size_ = SHA_LEN;\n        parms.key_size_  = AES_256_KEY_SZ;\n        parms.iv_size_   = AES_BLOCK_SZ;\n        parms.cipher_type_ = block;\n        secure_.use_connection().send_server_key_  = true; // eph\n        crypto_.setDigest(NEW_YS SHA);\n        crypto_.setCipher(NEW_YS AES(AES_256_KEY_SZ));\n        strncpy(parms.cipher_name_,\n               cipher_names[TLS_DHE_DSS_WITH_AES_256_CBC_SHA], MAX_SUITE_NAME);\n        break;\n\n    case TLS_DHE_DSS_WITH_AES_128_CBC_SHA:\n        parms.bulk_cipher_algorithm_ = aes;\n        parms.mac_algorithm_         = sha;\n        parms.kea_                   = diffie_hellman_kea;\n        parms.sig_algo_              = dsa_sa_algo;\n        parms.hash_size_ = SHA_LEN;\n        parms.key_size_  = AES_128_KEY_SZ;\n        parms.iv_size_   = AES_BLOCK_SZ;\n        parms.cipher_type_ = block;\n        secure_.use_connection().send_server_key_  = true; // eph\n        crypto_.setDigest(NEW_YS SHA);\n        crypto_.setCipher(NEW_YS AES);\n        strncpy(parms.cipher_name_,\n               cipher_names[TLS_DHE_DSS_WITH_AES_128_CBC_SHA], MAX_SUITE_NAME);\n        break;\n\n    case TLS_RSA_WITH_AES_256_CBC_RMD160:\n        parms.bulk_cipher_algorithm_ = aes;\n        parms.mac_algorithm_         = rmd;\n        parms.kea_                   = rsa_kea;\n        parms.hash_size_ = RMD_LEN;\n        parms.key_size_  = AES_256_KEY_SZ;\n        parms.iv_size_   = AES_BLOCK_SZ;\n        parms.cipher_type_ = block;\n        crypto_.setDigest(NEW_YS RMD);\n        crypto_.setCipher(NEW_YS AES(AES_256_KEY_SZ));\n        strncpy(parms.cipher_name_,\n                cipher_names[TLS_RSA_WITH_AES_256_CBC_RMD160], MAX_SUITE_NAME);\n        break;\n\n    case TLS_RSA_WITH_AES_128_CBC_RMD160:\n        parms.bulk_cipher_algorithm_ = aes;\n        parms.mac_algorithm_         = rmd;\n        parms.kea_                   = rsa_kea;\n        parms.hash_size_ = RMD_LEN;\n        parms.key_size_  = AES_128_KEY_SZ;\n        parms.iv_size_   = AES_BLOCK_SZ;\n        parms.cipher_type_ = block;\n        crypto_.setDigest(NEW_YS RMD);\n        crypto_.setCipher(NEW_YS AES);\n        strncpy(parms.cipher_name_,\n                cipher_names[TLS_RSA_WITH_AES_128_CBC_RMD160], MAX_SUITE_NAME);\n        break;\n\n    case TLS_RSA_WITH_3DES_EDE_CBC_RMD160:\n        parms.bulk_cipher_algorithm_ = triple_des;\n        parms.mac_algorithm_         = rmd;\n        parms.kea_                   = rsa_kea;\n        parms.hash_size_ = RMD_LEN;\n        parms.key_size_  = DES_EDE_KEY_SZ;\n        parms.iv_size_   = DES_IV_SZ;\n        parms.cipher_type_ = block;\n        crypto_.setDigest(NEW_YS RMD);\n        crypto_.setCipher(NEW_YS DES_EDE);\n        strncpy(parms.cipher_name_,\n               cipher_names[TLS_RSA_WITH_3DES_EDE_CBC_RMD160], MAX_SUITE_NAME);\n        break;\n\n    case TLS_DHE_RSA_WITH_3DES_EDE_CBC_RMD160:\n        parms.bulk_cipher_algorithm_ = triple_des;\n        parms.mac_algorithm_         = rmd;\n        parms.kea_                   = diffie_hellman_kea;\n        parms.sig_algo_              = rsa_sa_algo;\n        parms.hash_size_ = RMD_LEN;\n        parms.key_size_  = DES_EDE_KEY_SZ;\n        parms.iv_size_   = DES_IV_SZ;\n        parms.cipher_type_ = block;\n        secure_.use_connection().send_server_key_  = true; // eph\n        crypto_.setDigest(NEW_YS RMD);\n        crypto_.setCipher(NEW_YS DES_EDE);\n        strncpy(parms.cipher_name_,\n                cipher_names[TLS_DHE_RSA_WITH_3DES_EDE_CBC_RMD160],\n                MAX_SUITE_NAME);\n        break;\n\n    case TLS_DHE_RSA_WITH_AES_256_CBC_RMD160:\n        parms.bulk_cipher_algorithm_ = aes;\n        parms.mac_algorithm_         = rmd;\n        parms.kea_                   = diffie_hellman_kea;\n        parms.sig_algo_              = rsa_sa_algo;\n        parms.hash_size_ = RMD_LEN;\n        parms.key_size_  = AES_256_KEY_SZ;\n        parms.iv_size_   = AES_BLOCK_SZ;\n        parms.cipher_type_ = block;\n        secure_.use_connection().send_server_key_  = true; // eph\n        crypto_.setDigest(NEW_YS RMD);\n        crypto_.setCipher(NEW_YS AES(AES_256_KEY_SZ));\n        strncpy(parms.cipher_name_,\n                cipher_names[TLS_DHE_RSA_WITH_AES_256_CBC_RMD160],\n                MAX_SUITE_NAME);\n        break;\n\n    case TLS_DHE_RSA_WITH_AES_128_CBC_RMD160:\n        parms.bulk_cipher_algorithm_ = aes;\n        parms.mac_algorithm_         = rmd;\n        parms.kea_                   = diffie_hellman_kea;\n        parms.sig_algo_              = rsa_sa_algo;\n        parms.hash_size_ = RMD_LEN;\n        parms.key_size_  = AES_128_KEY_SZ;\n        parms.iv_size_   = AES_BLOCK_SZ;\n        parms.cipher_type_ = block;\n        secure_.use_connection().send_server_key_  = true; // eph\n        crypto_.setDigest(NEW_YS RMD);\n        crypto_.setCipher(NEW_YS AES);\n        strncpy(parms.cipher_name_,\n                cipher_names[TLS_DHE_RSA_WITH_AES_128_CBC_RMD160],\n                MAX_SUITE_NAME);\n        break;\n\n    case TLS_DHE_DSS_WITH_3DES_EDE_CBC_RMD160:\n        parms.bulk_cipher_algorithm_ = triple_des;\n        parms.mac_algorithm_         = rmd;\n        parms.kea_                   = diffie_hellman_kea;\n        parms.sig_algo_              = dsa_sa_algo;\n        parms.hash_size_ = RMD_LEN;\n        parms.key_size_  = DES_EDE_KEY_SZ;\n        parms.iv_size_   = DES_IV_SZ;\n        parms.cipher_type_ = block;\n        secure_.use_connection().send_server_key_  = true; // eph\n        crypto_.setDigest(NEW_YS RMD);\n        crypto_.setCipher(NEW_YS DES_EDE);\n        strncpy(parms.cipher_name_,\n                cipher_names[TLS_DHE_DSS_WITH_3DES_EDE_CBC_RMD160],\n                MAX_SUITE_NAME);\n        break;\n\n    case TLS_DHE_DSS_WITH_AES_256_CBC_RMD160:\n        parms.bulk_cipher_algorithm_ = aes;\n        parms.mac_algorithm_         = rmd;\n        parms.kea_                   = diffie_hellman_kea;\n        parms.sig_algo_              = dsa_sa_algo;\n        parms.hash_size_ = RMD_LEN;\n        parms.key_size_  = AES_256_KEY_SZ;\n        parms.iv_size_   = AES_BLOCK_SZ;\n        parms.cipher_type_ = block;\n        secure_.use_connection().send_server_key_  = true; // eph\n        crypto_.setDigest(NEW_YS RMD);\n        crypto_.setCipher(NEW_YS AES(AES_256_KEY_SZ));\n        strncpy(parms.cipher_name_,\n                cipher_names[TLS_DHE_DSS_WITH_AES_256_CBC_RMD160],\n                MAX_SUITE_NAME);\n        break;\n\n    case TLS_DHE_DSS_WITH_AES_128_CBC_RMD160:\n        parms.bulk_cipher_algorithm_ = aes;\n        parms.mac_algorithm_         = rmd;\n        parms.kea_                   = diffie_hellman_kea;\n        parms.sig_algo_              = dsa_sa_algo;\n        parms.hash_size_ = RMD_LEN;\n        parms.key_size_  = AES_128_KEY_SZ;\n        parms.iv_size_   = AES_BLOCK_SZ;\n        parms.cipher_type_ = block;\n        secure_.use_connection().send_server_key_  = true; // eph\n        crypto_.setDigest(NEW_YS RMD);\n        crypto_.setCipher(NEW_YS AES);\n        strncpy(parms.cipher_name_,\n                cipher_names[TLS_DHE_DSS_WITH_AES_128_CBC_RMD160],\n                MAX_SUITE_NAME);\n        break;\n\n    default:\n        SetError(unknown_cipher);\n    }\n}\n\n#ifdef _WIN32\ntypedef volatile LONG yassl_pthread_once_t;\n#define YASSL_PTHREAD_ONCE_INIT  0\n#define YASSL_PTHREAD_ONCE_INPROGRESS 1\n#define YASSL_PTHREAD_ONCE_DONE 2\n\nint yassl_pthread_once(yassl_pthread_once_t *once_control,\n    void (*init_routine)(void))\n{\n  LONG state;\n\n  /*\n    Do \"dirty\" read to find out if initialization is already done, to\n    save an interlocked operation in common case. Memory barriers are ensured by \n    Visual C++ volatile implementation.\n  */\n  if (*once_control == YASSL_PTHREAD_ONCE_DONE)\n    return 0;\n\n  state= InterlockedCompareExchange(once_control, YASSL_PTHREAD_ONCE_INPROGRESS,\n                                        YASSL_PTHREAD_ONCE_INIT);\n\n  switch(state)\n  {\n  case YASSL_PTHREAD_ONCE_INIT:\n    /* This is initializer thread */\n    (*init_routine)();\n    *once_control= YASSL_PTHREAD_ONCE_DONE;\n    break;\n\n  case YASSL_PTHREAD_ONCE_INPROGRESS:\n    /* init_routine in progress. Wait for its completion */\n    while(*once_control == YASSL_PTHREAD_ONCE_INPROGRESS)\n    {\n      Sleep(1);\n    }\n    break;\n  case YASSL_PTHREAD_ONCE_DONE:\n    /* Nothing to do */\n    break;\n  }\n  return 0;\n}\n#else\n#define yassl_pthread_once_t pthread_once_t\n#if defined(PTHREAD_ONCE_INITIALIZER)\n#define YASSL_PTHREAD_ONCE_INIT PTHREAD_ONCE_INITIALIZER\n#else\n#define YASSL_PTHREAD_ONCE_INIT PTHREAD_ONCE_INIT\n#endif\n#define yassl_pthread_once(C,F) pthread_once(C,F)\n#endif // _WIN32\n\n// store peer's random\nvoid SSL::set_random(const opaque* random, ConnectionEnd sender)\n{\n    if (sender == client_end)\n        memcpy(secure_.use_connection().client_random_, random, RAN_LEN);\n    else\n        memcpy(secure_.use_connection().server_random_, random, RAN_LEN);\n}\n\n\n// store client pre master secret\nvoid SSL::set_preMaster(const opaque* pre, uint sz)\n{\n    secure_.use_connection().AllocPreSecret(sz);\n    memcpy(secure_.use_connection().pre_master_secret_, pre, sz);\n}\n\n\n// set yaSSL zlib type compression\nint SSL::SetCompression()\n{\n#ifdef HAVE_LIBZ\n    secure_.use_connection().compression_ = true;\n    return 0;\n#else\n    return -1;  // not built in\n#endif\n}\n\n\n// unset yaSSL zlib type compression\nvoid SSL::UnSetCompression()\n{\n    secure_.use_connection().compression_ = false;\n}\n\n\n// is yaSSL zlib compression on\nbool SSL::CompressionOn() const\n{\n    return secure_.get_connection().compression_;\n}\n\n\n// store master secret\nvoid SSL::set_masterSecret(const opaque* sec)\n{\n    memcpy(secure_.use_connection().master_secret_, sec, SECRET_LEN);\n}\n\n// store server issued id\nvoid SSL::set_sessionID(const opaque* sessionID)\n{\n    memcpy(secure_.use_connection().sessionID_, sessionID, ID_LEN);\n    secure_.use_connection().sessionID_Set_ = true;\n}\n\n\n// store error \nvoid SSL::SetError(YasslError ye)\n{\n    states_.SetError(ye);\n    //strncpy(states_.useString(), e.what(), mySTL::named_exception::NAME_SIZE);\n    // TODO: add string here\n}\n\n\n// set the quiet shutdown mode (close_nofiy not sent or received on shutdown)\nvoid SSL::SetQuietShutdown(bool mode)\n{\n  quietShutdown_ = mode;\n}\n\n\nBuffers& SSL::useBuffers()\n{\n    return buffers_;\n}\n\n\n// locals\nnamespace {\n\n// DeriveKeys and MasterSecret helper sets prefix letters\nstatic bool setPrefix(opaque* sha_input, int i)\n{\n    switch (i) {\n    case 0:\n        memcpy(sha_input, \"A\", 1);\n        break;\n    case 1:\n        memcpy(sha_input, \"BB\", 2);\n        break;\n    case 2:\n        memcpy(sha_input, \"CCC\", 3);\n        break;\n    case 3:\n        memcpy(sha_input, \"DDDD\", 4);\n        break;\n    case 4:\n        memcpy(sha_input, \"EEEEE\", 5);\n        break;\n    case 5:\n        memcpy(sha_input, \"FFFFFF\", 6);\n        break;\n    case 6:\n        memcpy(sha_input, \"GGGGGGG\", 7);\n        break;\n    default:\n        return false;  // prefix_error\n    }\n    return true;\n}\n\n\nconst char handshake_order[] = \"Out of order HandShake Message!\";\n\n\n} // namespcae for locals\n\n\nvoid SSL::order_error()\n{\n    SetError(out_of_order);\n}\n\n\n// Create and store the master secret see page 32, 6.1\nvoid SSL::makeMasterSecret()\n{\n    if (isTLS())\n        makeTLSMasterSecret();\n    else {\n        opaque sha_output[SHA_LEN];\n\n        const uint& preSz = secure_.get_connection().pre_secret_len_;\n        output_buffer md5_input(preSz + SHA_LEN);\n        output_buffer sha_input(PREFIX + preSz + 2 * RAN_LEN);\n\n        MD5 md5;\n        SHA sha;\n\n        md5_input.write(secure_.get_connection().pre_master_secret_, preSz);\n\n        for (int i = 0; i < MASTER_ROUNDS; ++i) {\n            opaque prefix[PREFIX];\n            if (!setPrefix(prefix, i)) {\n                SetError(prefix_error);\n                return;\n            }\n\n            sha_input.set_current(0);\n            sha_input.write(prefix, i + 1);\n\n            sha_input.write(secure_.get_connection().pre_master_secret_,preSz);\n            sha_input.write(secure_.get_connection().client_random_, RAN_LEN);\n            sha_input.write(secure_.get_connection().server_random_, RAN_LEN);\n            sha.get_digest(sha_output, sha_input.get_buffer(),\n                           sha_input.get_size());\n\n            md5_input.set_current(preSz);\n            md5_input.write(sha_output, SHA_LEN);\n            md5.get_digest(&secure_.use_connection().master_secret_[i*MD5_LEN],\n                           md5_input.get_buffer(), md5_input.get_size());\n        }\n        deriveKeys();\n    }\n    secure_.use_connection().CleanPreMaster();\n}\n\n\n// create TLSv1 master secret\nvoid SSL::makeTLSMasterSecret()\n{\n    opaque seed[SEED_LEN];\n    \n    memcpy(seed, secure_.get_connection().client_random_, RAN_LEN);\n    memcpy(&seed[RAN_LEN], secure_.get_connection().server_random_, RAN_LEN);\n\n    PRF(secure_.use_connection().master_secret_, SECRET_LEN,\n        secure_.get_connection().pre_master_secret_,\n        secure_.get_connection().pre_secret_len_,\n        master_label, MASTER_LABEL_SZ, \n        seed, SEED_LEN);\n\n    deriveTLSKeys();\n}\n\n\n// derive mac, write, and iv keys for server and client, see page 34, 6.2.2\nvoid SSL::deriveKeys()\n{\n    int length = 2 * secure_.get_parms().hash_size_ + \n                 2 * secure_.get_parms().key_size_  +\n                 2 * secure_.get_parms().iv_size_;\n    int rounds = (length + MD5_LEN - 1 ) / MD5_LEN;\n    input_buffer key_data(rounds * MD5_LEN);\n\n    opaque sha_output[SHA_LEN];\n    opaque md5_input[SECRET_LEN + SHA_LEN];\n    opaque sha_input[KEY_PREFIX + SECRET_LEN + 2 * RAN_LEN];\n  \n    MD5 md5;\n    SHA sha;\n\n    memcpy(md5_input, secure_.get_connection().master_secret_, SECRET_LEN);\n\n    for (int i = 0; i < rounds; ++i) {\n        int j = i + 1;\n        if (!setPrefix(sha_input, i)) {\n            SetError(prefix_error);\n            return;\n        }\n\n        memcpy(&sha_input[j], secure_.get_connection().master_secret_,\n               SECRET_LEN);\n        memcpy(&sha_input[j+SECRET_LEN],\n               secure_.get_connection().server_random_, RAN_LEN);\n        memcpy(&sha_input[j + SECRET_LEN + RAN_LEN],\n               secure_.get_connection().client_random_, RAN_LEN);\n        sha.get_digest(sha_output, sha_input,\n                       sizeof(sha_input) - KEY_PREFIX + j);\n\n        memcpy(&md5_input[SECRET_LEN], sha_output, SHA_LEN);\n        md5.get_digest(key_data.get_buffer() + i * MD5_LEN,\n                       md5_input, sizeof(md5_input));\n    }\n    storeKeys(key_data.get_buffer());\n}\n\n\n// derive mac, write, and iv keys for server and client\nvoid SSL::deriveTLSKeys()\n{\n    int length = 2 * secure_.get_parms().hash_size_ + \n                 2 * secure_.get_parms().key_size_  +\n                 2 * secure_.get_parms().iv_size_;\n    opaque       seed[SEED_LEN];\n    input_buffer key_data(length);\n\n    memcpy(seed, secure_.get_connection().server_random_, RAN_LEN);\n    memcpy(&seed[RAN_LEN], secure_.get_connection().client_random_, RAN_LEN);\n\n    PRF(key_data.get_buffer(), length, secure_.get_connection().master_secret_,\n        SECRET_LEN, key_label, KEY_LABEL_SZ, seed, SEED_LEN);\n\n    storeKeys(key_data.get_buffer());\n}\n\n\n// store mac, write, and iv keys for client and server\nvoid SSL::storeKeys(const opaque* key_data)\n{\n    int sz = secure_.get_parms().hash_size_;\n    memcpy(secure_.use_connection().client_write_MAC_secret_, key_data, sz);\n    int i = sz;\n    memcpy(secure_.use_connection().server_write_MAC_secret_,&key_data[i], sz);\n    i += sz;\n\n    sz = secure_.get_parms().key_size_;\n    memcpy(secure_.use_connection().client_write_key_, &key_data[i], sz);\n    i += sz;\n    memcpy(secure_.use_connection().server_write_key_, &key_data[i], sz);\n    i += sz;\n\n    sz = secure_.get_parms().iv_size_;\n    memcpy(secure_.use_connection().client_write_IV_, &key_data[i], sz);\n    i += sz;\n    memcpy(secure_.use_connection().server_write_IV_, &key_data[i], sz);\n\n    setKeys();\n}\n\n\n// set encrypt/decrypt keys and ivs\nvoid SSL::setKeys()\n{\n    Connection& conn = secure_.use_connection();\n\n    if (secure_.get_parms().entity_ == client_end) {\n        crypto_.use_cipher().set_encryptKey(conn.client_write_key_, \n                                            conn.client_write_IV_);\n        crypto_.use_cipher().set_decryptKey(conn.server_write_key_,\n                                            conn.server_write_IV_);\n    }\n    else {\n        crypto_.use_cipher().set_encryptKey(conn.server_write_key_,\n                                            conn.server_write_IV_);\n        crypto_.use_cipher().set_decryptKey(conn.client_write_key_,\n                                            conn.client_write_IV_);\n    }\n}\n\n\n\n// local functors\nnamespace yassl_int_cpp_local1 {  // for explicit templates\n\nstruct SumData {\n    uint total_;\n    SumData() : total_(0) {}\n    void operator()(input_buffer* data) { total_ += data->get_remaining(); }\n};\n\n\nstruct SumBuffer {\n    uint total_;\n    SumBuffer() : total_(0) {}\n    void operator()(output_buffer* buffer) { total_ += buffer->get_size(); }\n};\n\n} // namespace for locals\nusing namespace yassl_int_cpp_local1;\n\n\nuint SSL::bufferedData()\n{\n    return STL::for_each(buffers_.getData().begin(),buffers_.getData().end(),\n                           SumData()).total_;\n}\n\n\n// use input buffer to fill data\nvoid SSL::fillData(Data& data)\n{\n    if (GetError()) return;\n    uint dataSz   = data.get_length();        // input, data size to fill\n    size_t elements = buffers_.getData().size();\n\n    data.set_length(0);                         // output, actual data filled\n    dataSz = min(dataSz, bufferedData());\n\n    for (size_t i = 0; i < elements; i++) {\n        input_buffer* front = buffers_.getData().front();\n        uint frontSz = front->get_remaining();\n        uint readSz  = min(dataSz - data.get_length(), frontSz);\n\n        front->read(data.set_buffer() + data.get_length(), readSz);\n        data.set_length(data.get_length() + readSz);\n\n        if (readSz == frontSz) {\n            buffers_.useData().pop_front();\n            ysDelete(front);\n        }\n        if (data.get_length() == dataSz)\n            break;\n    }\n    \n    if (buffers_.getData().size() == 0) has_data_ = false;  // none left\n}\n\n\n// like Fill but keep data in buffer\nvoid SSL::PeekData(Data& data)\n{\n    if (GetError()) return;\n    uint   dataSz   = data.get_length();        // input, data size to fill\n    size_t elements = buffers_.getData().size();\n\n    data.set_length(0);                         // output, actual data filled\n    dataSz = min(dataSz, bufferedData());\n\n    Buffers::inputList::iterator front = buffers_.useData().begin();\n\n    while (elements) {\n        uint frontSz = (*front)->get_remaining();\n        uint readSz  = min(dataSz - data.get_length(), frontSz);\n        uint before  = (*front)->get_current();\n\n        (*front)->read(data.set_buffer() + data.get_length(), readSz);\n        data.set_length(data.get_length() + readSz);\n        (*front)->set_current(before);\n\n        if (data.get_length() == dataSz)\n            break;\n\n        elements--;\n        front++;\n    }\n}\n\n\n// flush output buffer\nvoid SSL::flushBuffer()\n{\n    if (GetError()) return;\n\n    uint sz = STL::for_each(buffers_.getHandShake().begin(),\n                            buffers_.getHandShake().end(),\n                            SumBuffer()).total_;\n    output_buffer out(sz);\n    size_t elements = buffers_.getHandShake().size();\n\n    for (size_t i = 0; i < elements; i++) {\n        output_buffer* front = buffers_.getHandShake().front();\n        out.write(front->get_buffer(), front->get_size());\n\n        buffers_.useHandShake().pop_front();\n        ysDelete(front);\n    }\n    Send(out.get_buffer(), out.get_size());\n}\n\n\nvoid SSL::Send(const byte* buffer, uint sz)\n{\n    unsigned int sent = 0;\n\n    if (socket_.send(buffer, sz, sent) != sz) {\n        if (socket_.WouldBlock()) {\n            buffers_.SetOutput(NEW_YS output_buffer(sz - sent, buffer + sent,\n                                                    sz - sent));\n            SetError(YasslError(SSL_ERROR_WANT_WRITE));\n        }\n        else\n            SetError(send_error);\n    }\n}\n\n\nvoid SSL::SendWriteBuffered()\n{\n    output_buffer* out = buffers_.TakeOutput();\n\n    if (out) {\n        mySTL::auto_ptr<output_buffer> tmp(out);\n        Send(out->get_buffer(), out->get_size());\n    }\n}\n\n\n// get sequence number, if verify get peer's\nuint SSL::get_SEQIncrement(bool verify) \n{ \n    if (verify)\n        return secure_.use_connection().peer_sequence_number_++; \n    else\n        return secure_.use_connection().sequence_number_++; \n}\n\n\nconst byte* SSL::get_macSecret(bool verify)\n{\n    if ( (secure_.get_parms().entity_ == client_end && !verify) ||\n         (secure_.get_parms().entity_ == server_end &&  verify) )\n        return secure_.get_connection().client_write_MAC_secret_;\n    else\n        return secure_.get_connection().server_write_MAC_secret_;\n}\n\n\nvoid SSL::verifyState(const RecordLayerHeader& rlHeader)\n{\n    if (GetError()) return;\n\n    if (rlHeader.version_.major_ != 3 || rlHeader.version_.minor_ > 2) {\n        SetError(badVersion_error);\n        return;\n    }\n\n    if (states_.getRecord() == recordNotReady || \n            (rlHeader.type_ == application_data &&        // data and handshake\n             states_.getHandShake() != handShakeReady) )  // isn't complete yet\n              SetError(record_layer);\n}\n\n\nvoid SSL::verifyState(const HandShakeHeader& hsHeader)\n{\n    if (GetError()) return;\n\n    if (states_.getHandShake() == handShakeNotReady) {\n        SetError(handshake_layer);\n        return;\n    }\n\n    if (states_.SetMessageRecvd(hsHeader.get_handshakeType()) != 0) {\n        order_error();\n        return;\n    }\n\n    if (secure_.get_parms().entity_ == client_end)\n        verifyClientState(hsHeader.get_handshakeType());\n    else\n        verifyServerState(hsHeader.get_handshakeType());\n}\n\n\nvoid SSL::verifyState(ClientState cs)\n{\n    if (GetError()) return;\n    if (states_.getClient() != cs) order_error();\n}\n\n\nvoid SSL::verifyState(ServerState ss)\n{\n    if (GetError()) return;\n    if (states_.getServer() != ss) order_error();\n}\n\n\nvoid SSL::verfiyHandShakeComplete()\n{\n    if (GetError()) return;\n    if (states_.getHandShake() != handShakeReady) order_error();\n}\n\n\nvoid SSL::verifyClientState(HandShakeType hsType)\n{\n    if (GetError()) return;\n\n    switch(hsType) {\n    case server_hello :\n        if (states_.getClient() != serverNull)\n            order_error();\n        break;\n    case certificate :\n        if (states_.getClient() != serverHelloComplete)\n            order_error();\n        break;\n    case server_key_exchange :\n        if (states_.getClient() != serverCertComplete)\n            order_error();\n        break;\n    case certificate_request :\n        if (states_.getClient() != serverCertComplete &&\n            states_.getClient() != serverKeyExchangeComplete)\n            order_error();\n        break;\n    case server_hello_done :\n        if (states_.getClient() != serverCertComplete &&\n            states_.getClient() != serverKeyExchangeComplete)\n            order_error();\n        break;\n    case finished :\n        if (states_.getClient() != serverHelloDoneComplete || \n            secure_.get_parms().pending_)    // no change\n                order_error();          // cipher yet\n        break;\n    default :\n        order_error();\n    };\n}\n\n\nvoid SSL::verifyServerState(HandShakeType hsType)\n{\n    if (GetError()) return;\n\n    switch(hsType) {\n    case client_hello :\n        if (states_.getServer() != clientNull)\n            order_error();\n        break;\n    case certificate :\n        if (states_.getServer() != clientHelloComplete)\n            order_error();\n        break;\n    case client_key_exchange :\n        if (states_.getServer() != clientHelloComplete)\n            order_error();\n        break;\n    case certificate_verify :\n        if (states_.getServer() != clientKeyExchangeComplete)\n            order_error();\n        break;\n    case finished :\n        if (states_.getServer() != clientKeyExchangeComplete || \n            secure_.get_parms().pending_)    // no change\n                order_error();               // cipher yet\n        break;\n    default :\n        order_error();\n    };\n}\n\n\n// try to find a suite match\nvoid SSL::matchSuite(const opaque* peer, uint length)\n{\n    if (length == 0 || (length % 2) != 0) {\n        SetError(bad_input);\n        return;\n    }\n\n    // start with best, if a match we are good, Ciphers are at odd index\n    // since all SSL and TLS ciphers have 0x00 first byte\n    for (uint i = 1; i < secure_.get_parms().suites_size_; i += 2)\n        for (uint j = 1; j < length; j+= 2)\n            if (secure_.use_parms().suites_[i] == peer[j]) {\n                secure_.use_parms().suite_[0] = 0x00;\n                secure_.use_parms().suite_[1] = peer[j];\n                return;\n            }\n\n    SetError(match_error);\n}\n\n\nvoid SSL::set_session(SSL_SESSION* s) \n{\n    if (getSecurity().GetContext()->GetSessionCacheOff())\n        return;\n\n    if (s && GetSessions().lookup(s->GetID(), &secure_.use_resume())) {\n        secure_.set_resuming(true);\n        crypto_.use_certManager().setPeerX509(s->GetPeerX509());\n    }\n}\n\n\nconst Crypto& SSL::getCrypto() const\n{\n    return crypto_;\n}\n\n\nconst Security& SSL::getSecurity() const\n{\n    return secure_;\n}\n\n\nconst States& SSL::getStates() const\n{\n    return states_;\n}\n\n\nconst sslHashes& SSL::getHashes() const\n{\n    return hashes_;\n}\n\n\nconst sslFactory& SSL::getFactory() const\n{\n    return GetSSL_Factory();\n}\n\n\nconst Socket& SSL::getSocket() const\n{\n    return socket_;\n}\n\n\nYasslError SSL::GetError() const\n{\n    return states_.What();\n}\n\n\nbool SSL::GetQuietShutdown() const\n{\n    return quietShutdown_;\n}\n\n\nbool SSL::GetMultiProtocol() const\n{\n    return secure_.GetContext()->getMethod()->multipleProtocol();\n}\n\n\nCrypto& SSL::useCrypto()\n{\n    return crypto_;\n}\n\n\nSecurity& SSL::useSecurity()\n{\n    return secure_;\n}\n\n\nStates& SSL::useStates()\n{\n    return states_;\n}\n\n\nsslHashes& SSL::useHashes()\n{\n    return hashes_;\n}\n\n\nSocket& SSL::useSocket()\n{\n    return socket_;\n}\n\n\nLog& SSL::useLog()\n{\n    return log_;\n}\n\n\nbool SSL::isTLS() const\n{\n    return secure_.get_connection().TLS_;\n}\n\n\nbool SSL::isTLSv1_1() const\n{\n    return secure_.get_connection().TLSv1_1_;\n}\n\n\n// is there buffered data available, optimization to remove iteration on buffer\nbool SSL::HasData() const\n{ \n    return has_data_;\n}\n\n\nvoid SSL::addData(input_buffer* data)\n{\n    buffers_.useData().push_back(data);\n    if (!has_data_) has_data_ = true;\n}\n\n\nvoid SSL::addBuffer(output_buffer* b)\n{\n    buffers_.useHandShake().push_back(b);\n}\n\n\nvoid SSL_SESSION::CopyX509(X509* x)\n{\n    if (x == 0) return;\n\n    X509_NAME* issuer   = x->GetIssuer();\n    X509_NAME* subject  = x->GetSubject();\n    ASN1_TIME* before = x->GetBefore();\n    ASN1_TIME* after  = x->GetAfter();\n\n    peerX509_ = NEW_YS X509(issuer->GetName(), issuer->GetLength(),\n        subject->GetName(), subject->GetLength(),\n        before, after);\n}\n\n\n// store connection parameters\nSSL_SESSION::SSL_SESSION(const SSL& ssl, RandomPool& ran) \n    : timeout_(DEFAULT_TIMEOUT), random_(ran), peerX509_(0)\n{\n    const Connection& conn = ssl.getSecurity().get_connection();\n\n    memcpy(sessionID_, conn.sessionID_, ID_LEN);\n    memcpy(master_secret_, conn.master_secret_, SECRET_LEN);\n    memcpy(suite_, ssl.getSecurity().get_parms().suite_, SUITE_LEN);\n\n    bornOn_ = lowResTimer();\n\n    CopyX509(ssl.getCrypto().get_certManager().get_peerX509());\n}\n\n\n// for resumption copy in ssl::parameters\nSSL_SESSION::SSL_SESSION(RandomPool& ran) \n    : bornOn_(0), timeout_(0), random_(ran), peerX509_(0)\n{\n    memset(sessionID_, 0, ID_LEN);\n    memset(master_secret_, 0, SECRET_LEN);\n    memset(suite_, 0, SUITE_LEN);\n}\n\n\nSSL_SESSION& SSL_SESSION::operator=(const SSL_SESSION& that)\n{\n    memcpy(sessionID_, that.sessionID_, ID_LEN);\n    memcpy(master_secret_, that.master_secret_, SECRET_LEN);\n    memcpy(suite_, that.suite_, SUITE_LEN);\n    \n    bornOn_  = that.bornOn_;\n    timeout_ = that.timeout_;\n\n    if (peerX509_) {\n        ysDelete(peerX509_);\n        peerX509_ = 0;\n    }\n    CopyX509(that.peerX509_);\n\n    return *this;\n}\n\n\nconst opaque* SSL_SESSION::GetID() const\n{\n    return sessionID_;\n}\n\n\nconst opaque* SSL_SESSION::GetSecret() const\n{\n    return master_secret_;\n}\n\n\nconst Cipher* SSL_SESSION::GetSuite() const\n{\n    return suite_;\n}\n\n\nX509* SSL_SESSION::GetPeerX509() const\n{\n    return peerX509_;\n}\n\n\nuint SSL_SESSION::GetBornOn() const\n{\n    return bornOn_;\n}\n\n\nuint SSL_SESSION::GetTimeOut() const\n{\n    return timeout_;\n}\n\n\nvoid SSL_SESSION::SetTimeOut(uint t)\n{\n    timeout_ = t;\n}\n\n\nextern void clean(volatile opaque*, uint, RandomPool&);\n\n\n// clean up secret data\nSSL_SESSION::~SSL_SESSION()\n{\n    volatile opaque* p = master_secret_;\n    clean(p, SECRET_LEN, random_);\n\n    ysDelete(peerX509_);\n}\n\n\nstatic Sessions* sessionsInstance = 0;\nstatic yassl_pthread_once_t session_created= YASSL_PTHREAD_ONCE_INIT;\n\nvoid Session_initialize()\n{\n    sessionsInstance = NEW_YS Sessions;\n}\n\nextern \"C\"\n{\n  static void c_session_initialize() { Session_initialize(); }\n}\n\n\nSessions& GetSessions()\n{\n    yassl_pthread_once(&session_created, c_session_initialize);\n    return *sessionsInstance;\n}\n\n\nstatic sslFactory* sslFactoryInstance = 0;\n\nsslFactory& GetSSL_Factory()\n{  \n    if (!sslFactoryInstance)\n        sslFactoryInstance = NEW_YS sslFactory;\n    return *sslFactoryInstance;\n}\n\n\nstatic Errors* errorsInstance = 0;\n\nErrors& GetErrors()\n{\n    if (!errorsInstance)\n        errorsInstance = NEW_YS Errors;\n    return *errorsInstance;\n}\n\n\ntypedef Mutex::Lock Lock;\n\n\n \nvoid Sessions::add(const SSL& ssl) \n{\n    if (ssl.getSecurity().get_connection().sessionID_Set_) {\n        Lock guard(mutex_);\n        list_.push_back(NEW_YS SSL_SESSION(ssl, random_));\n        count_++;\n    }\n\n    if (count_ > SESSION_FLUSH_COUNT)\n        if (!ssl.getSecurity().GetContext()->GetSessionCacheFlushOff())\n            Flush();\n}\n\n\nSessions::~Sessions() \n{ \n    STL::for_each(list_.begin(), list_.end(), del_ptr_zero()); \n}\n\n\n// locals\nnamespace yassl_int_cpp_local2 { // for explicit templates\n\ntypedef STL::list<SSL_SESSION*>::iterator sess_iterator;\ntypedef STL::list<ThreadError>::iterator  thr_iterator;\n\nstruct sess_match {\n    const opaque* id_;\n    explicit sess_match(const opaque* p) : id_(p) {}\n\n    bool operator()(SSL_SESSION* sess)\n    {\n        if ( memcmp(sess->GetID(), id_, ID_LEN) == 0)\n            return true;\n        return false;\n    }\n};\n\n\nTHREAD_ID_T GetSelf()\n{\n#ifndef _POSIX_THREADS\n    return GetCurrentThreadId();\n#else\n    return pthread_self();\n#endif\n}\n\nstruct thr_match {\n    THREAD_ID_T id_;\n    explicit thr_match() : id_(GetSelf()) {}\n\n    bool operator()(ThreadError thr)\n    {\n        if (thr.threadID_ == id_)\n            return true;\n        return false;\n    }\n};\n\n\n} // local namespace\nusing namespace yassl_int_cpp_local2;\n\n\n// lookup session by id, return a copy if space provided\nSSL_SESSION* Sessions::lookup(const opaque* id, SSL_SESSION* copy)\n{\n    Lock guard(mutex_);\n    sess_iterator find = STL::find_if(list_.begin(), list_.end(),\n                                        sess_match(id));\n    if (find != list_.end()) {\n        uint current = lowResTimer();\n        if ( ((*find)->GetBornOn() + (*find)->GetTimeOut()) < current) {\n            del_ptr_zero()(*find);\n            list_.erase(find);\n            return 0;\n        }\n        if (copy)\n            *copy = *(*find);\n        return *find;\n    }\n    return 0;\n}\n\n\n// remove a session by id\nvoid Sessions::remove(const opaque* id)\n{\n    Lock guard(mutex_);\n    sess_iterator find = STL::find_if(list_.begin(), list_.end(),\n                                        sess_match(id));\n    if (find != list_.end()) {\n        del_ptr_zero()(*find);\n        list_.erase(find);\n    }\n}\n\n\n// flush expired sessions from cache \nvoid Sessions::Flush()\n{\n    Lock guard(mutex_);\n    sess_iterator next = list_.begin();\n    uint current = lowResTimer();\n\n    while (next != list_.end()) {\n        sess_iterator si = next;\n        ++next;\n        if ( ((*si)->GetBornOn() + (*si)->GetTimeOut()) < current) {\n            del_ptr_zero()(*si);\n            list_.erase(si);\n        }\n    }\n    count_ = 0;  // reset flush counter\n}\n\n\n// remove a self thread error\nvoid Errors::Remove()\n{\n    Lock guard(mutex_);\n    thr_iterator find = STL::find_if(list_.begin(), list_.end(),\n                                       thr_match());\n    if (find != list_.end())\n        list_.erase(find);\n}\n\n\n// lookup self error code\nint Errors::Lookup(bool peek)\n{\n    Lock guard(mutex_);\n    thr_iterator find = STL::find_if(list_.begin(), list_.end(),\n                                       thr_match());\n    if (find != list_.end()) {\n        int ret = find->errorID_;\n        if (!peek)\n            list_.erase(find);\n        return ret;\n    }\n    else\n        return 0;\n}\n\n\n// add a new error code for self\nvoid Errors::Add(int error)\n{\n    ThreadError add;\n    add.errorID_  = error;\n    add.threadID_ = GetSelf();\n\n    Remove();   // may have old error\n\n    Lock guard(mutex_);\n    list_.push_back(add);\n}\n\n\nSSL_METHOD::SSL_METHOD(ConnectionEnd ce, ProtocolVersion pv, bool multiProto) \n    : version_(pv), side_(ce), verifyPeer_(false), verifyNone_(false),\n      failNoCert_(false), multipleProtocol_(multiProto)\n{}\n\n\nProtocolVersion SSL_METHOD::getVersion() const\n{\n    return version_;\n}\n\n\nConnectionEnd SSL_METHOD::getSide() const\n{\n    return side_;\n}\n\n\nvoid SSL_METHOD::setVerifyPeer()\n{\n    verifyPeer_ = true;\n}\n\n\nvoid SSL_METHOD::setVerifyNone()\n{\n    verifyNone_ = true;\n}\n\n\nvoid SSL_METHOD::setFailNoCert()\n{\n    failNoCert_ = true;\n}\n\n\nbool SSL_METHOD::verifyPeer() const\n{\n    return verifyPeer_;\n}\n\n\nbool SSL_METHOD::verifyNone() const\n{\n    return verifyNone_;\n}\n\n\nbool SSL_METHOD::failNoCert() const\n{\n    return failNoCert_;\n}\n\n\nbool SSL_METHOD::multipleProtocol() const\n{\n    return multipleProtocol_;\n}\n\n\n/** Implement a my_strdup replacement, so we can reuse get_password() */\nextern \"C\" char *yassl_mysql_strdup(const char *from, int)\n{\n  return from ? strdup(from) : NULL;\n}\n\n\nextern \"C\"\n{\nint\ndefault_password_callback(char * buffer, int size_arg, int rwflag,\n                          void * /* unused: callback_data */)\n{\n  char *passwd;\n  size_t passwd_len, size= (size_t) size_arg;\n\n  passwd= ::yassl_mysql_get_tty_password_ext(\"Enter PEM pass phrase:\", \n                                             yassl_mysql_strdup);\n\n  if (!passwd)\n    return 0;\n\n  passwd_len= strlen(passwd);\n\n  if (!passwd_len)\n    return 0;\n\n  if (size > 0)\n  {\n    size_t result_len= size - 1 > passwd_len ? \n      passwd_len : size - 1;\n    memcpy(buffer, passwd, result_len);\n    buffer[result_len]= 0;\n  }\n  free(passwd);\n  return passwd_len;\n}\n}\n\nSSL_CTX::SSL_CTX(SSL_METHOD* meth) \n    : method_(meth), certificate_(0), privateKey_(0), \n      passwordCb_(default_password_callback),\n      userData_(0), sessionCacheOff_(false), sessionCacheFlushOff_(false),\n      verifyCallback_(0)\n{}\n\n\nSSL_CTX::~SSL_CTX()\n{\n    ysDelete(method_);\n    ysDelete(certificate_);\n    ysDelete(privateKey_);\n\n    STL::for_each(caList_.begin(), caList_.end(), del_ptr_zero());\n}\n\n\nvoid SSL_CTX::AddCA(x509* ca)\n{\n    caList_.push_back(ca);\n}\n\n\nconst SSL_CTX::CertList& \nSSL_CTX::GetCA_List() const\n{\n    return caList_;\n}\n\n\nVerifyCallback SSL_CTX::getVerifyCallback() const\n{\n    return verifyCallback_;\n}\n\n\nconst x509* SSL_CTX::getCert() const\n{\n    return certificate_;\n}\n\n\nconst x509* SSL_CTX::getKey() const\n{\n    return privateKey_;\n}\n\n\nconst SSL_METHOD* SSL_CTX::getMethod() const\n{\n    return method_;\n}\n\n\nconst Ciphers& SSL_CTX::GetCiphers() const\n{\n    return ciphers_;\n}\n\n\nconst DH_Parms& SSL_CTX::GetDH_Parms() const\n{\n    return dhParms_;\n}\n\n\nconst Stats& SSL_CTX::GetStats() const\n{\n    return stats_;\n}\n\n\npem_password_cb SSL_CTX::GetPasswordCb() const\n{\n    return passwordCb_;\n}\n\n\nvoid SSL_CTX::SetPasswordCb(pem_password_cb cb)\n{\n    passwordCb_ = cb;\n}\n\n\nvoid* SSL_CTX::GetUserData() const\n{\n    return userData_;\n}\n\n\nbool SSL_CTX::GetSessionCacheOff() const\n{\n    return sessionCacheOff_;\n}\n\n\nbool SSL_CTX::GetSessionCacheFlushOff() const\n{\n    return sessionCacheFlushOff_;\n}\n\n\nvoid SSL_CTX::SetUserData(void* data)\n{\n    userData_ = data;\n}\n\n\nvoid SSL_CTX::SetSessionCacheOff()\n{\n    sessionCacheOff_ = true;\n}\n\n\nvoid SSL_CTX::SetSessionCacheFlushOff()\n{\n    sessionCacheFlushOff_ = true;\n}\n\n\nvoid SSL_CTX::setVerifyPeer()\n{\n    method_->setVerifyPeer();\n}\n\n\nvoid SSL_CTX::setVerifyNone()\n{\n    method_->setVerifyNone();\n}\n\n\nvoid SSL_CTX::setFailNoCert()\n{\n    method_->setFailNoCert();\n}\n\n\nvoid SSL_CTX::setVerifyCallback(VerifyCallback vc)\n{\n    verifyCallback_ = vc;\n}\n\n\nbool SSL_CTX::SetDH(const DH& dh)\n{\n    dhParms_.p_ = dh.p->int_;\n    dhParms_.g_ = dh.g->int_;\n\n    return dhParms_.set_ = true;\n}\n\n\nbool SSL_CTX::SetCipherList(const char* list)\n{\n    if (!list)\n        return false;\n\n    bool ret = false;\n    char name[MAX_SUITE_NAME];\n\n    char  needle[] = \":\";\n    char* haystack = const_cast<char*>(list);\n    char* prev;\n\n    const int suiteSz = sizeof(cipher_names) / sizeof(cipher_names[0]);\n    int idx = 0;\n\n    for(;;) {\n        size_t len;\n        prev = haystack;\n        haystack = strstr(haystack, needle);\n\n        if (!haystack)    // last cipher\n            len = min(sizeof(name), strlen(prev));\n        else\n            len = min(sizeof(name), (size_t)(haystack - prev));\n\n        strncpy(name, prev, len);\n        name[(len == sizeof(name)) ? len - 1 : len] = 0;\n\n        for (int i = 0; i < suiteSz; i++)\n            if (strncmp(name, cipher_names[i], sizeof(name)) == 0) {\n\n                ciphers_.suites_[idx++] = 0x00;  // first byte always zero\n                ciphers_.suites_[idx++] = i;\n\n                if (!ret) ret = true;   // found at least one\n                break;\n            }\n        if (!haystack) break;\n        haystack++;\n    }\n\n    if (ret) {\n        ciphers_.setSuites_ = true;\n        ciphers_.suiteSz_ = idx;\n    }\n\n    return ret;\n}\n\n\nvoid SSL_CTX::IncrementStats(StatsField fd)\n{\n\n    Lock guard(mutex_);\n    \n    switch (fd) {\n\n\tcase Accept:\n        ++stats_.accept_;\n        break;\n\n    case Connect:\n        ++stats_.connect_;\n        break;\n\n    case AcceptGood:\n        ++stats_.acceptGood_;\n        break;\n\n    case ConnectGood:\n        ++stats_.connectGood_;\n        break;\n\n    case AcceptRenegotiate:\n        ++stats_.acceptRenegotiate_;\n        break;\n\n    case ConnectRenegotiate:\n        ++stats_.connectRenegotiate_;\n        break;\n\n    case Hits:\n        ++stats_.hits_;\n        break;\n\n    case CbHits:\n        ++stats_.cbHits_;\n        break;\n\n    case CacheFull:\n        ++stats_.cacheFull_;\n        break;\n\n    case Misses:\n        ++stats_.misses_;\n        break;\n\n    case Timeouts:\n        ++stats_.timeouts_;\n        break;\n\n    case Number:\n        ++stats_.number_;\n        break;\n\n    case GetCacheSize:\n        ++stats_.getCacheSize_;\n        break;\n\n    case VerifyMode:\n        ++stats_.verifyMode_;\n        break;\n\n    case VerifyDepth:\n        ++stats_.verifyDepth_;\n        break;\n\n    default:\n        break;\n    }\n}\n\n\nCrypto::Crypto() \n    : digest_(0), cipher_(0), dh_(0) \n{}\n\n\nCrypto::~Crypto()\n{\n    ysDelete(dh_);\n    ysDelete(cipher_);\n    ysDelete(digest_);\n}\n\n\nconst Digest& Crypto::get_digest() const\n{\n    return *digest_;\n}\n\n\nconst BulkCipher& Crypto::get_cipher() const\n{\n    return *cipher_;\n}\n\n\nconst DiffieHellman& Crypto::get_dh() const\n{\n    return *dh_;\n}\n\n\nconst RandomPool& Crypto::get_random() const\n{\n    return random_;\n}\n\n\nconst CertManager& Crypto::get_certManager() const\n{\n    return cert_;\n}\n\n\n      \nDigest& Crypto::use_digest()\n{\n    return *digest_;\n}\n\n\nBulkCipher& Crypto::use_cipher()\n{\n    return *cipher_;\n}\n\n\nDiffieHellman& Crypto::use_dh()\n{\n    return *dh_;\n}\n\n\nRandomPool& Crypto::use_random()\n{\n    return random_;\n}\n\n\nCertManager& Crypto::use_certManager()\n{\n    return cert_;\n}\n\n\n\nvoid Crypto::SetDH(DiffieHellman* dh)\n{\n    dh_ = dh;\n}\n\n\nvoid Crypto::SetDH(const DH_Parms& dh)\n{\n    if (dh.set_)\n        dh_ = NEW_YS DiffieHellman(dh.p_, dh.g_, random_);\n}\n\n\nbool Crypto::DhSet()\n{\n    return dh_ != 0;\n}\n\n\nvoid Crypto::setDigest(Digest* digest)\n{\n    digest_ = digest;\n}\n\n\nvoid Crypto::setCipher(BulkCipher* c)\n{\n    cipher_ = c;\n}\n\n\nconst MD5& sslHashes::get_MD5() const\n{\n    return md5HandShake_;\n}\n\n\nconst SHA& sslHashes::get_SHA() const\n{\n    return shaHandShake_;\n}\n\n\nconst Finished& sslHashes::get_verify() const\n{\n    return verify_;\n}\n\n\nconst Hashes& sslHashes::get_certVerify() const\n{\n    return certVerify_;\n}\n\n\nMD5& sslHashes::use_MD5(){\n    return md5HandShake_;\n}\n\n\nSHA& sslHashes::use_SHA()\n{\n    return shaHandShake_;\n}\n\n\nFinished& sslHashes::use_verify()\n{\n    return verify_;\n}\n\n\nHashes& sslHashes::use_certVerify()\n{\n    return certVerify_;\n}\n\n\nBuffers::Buffers() : prevSent(0), plainSz(0), rawInput_(0), output_(0)\n{}\n\n\nBuffers::~Buffers()\n{\n    STL::for_each(handShakeList_.begin(), handShakeList_.end(),\n                  del_ptr_zero()) ;\n    STL::for_each(dataList_.begin(), dataList_.end(),\n                  del_ptr_zero()) ;\n    ysDelete(rawInput_);\n    ysDelete(output_);\n}\n\n\nvoid Buffers::SetOutput(output_buffer* ob)\n{\n    output_ = ob;\n}\n\n\nvoid Buffers::SetRawInput(input_buffer* ib)\n{\n    rawInput_ = ib;\n}\n\n\ninput_buffer* Buffers::TakeRawInput()\n{\n    input_buffer* ret = rawInput_;\n    rawInput_ = 0;\n\n    return ret;\n}\n\n\noutput_buffer* Buffers::TakeOutput()\n{\n    output_buffer* ret = output_;\n    output_ = 0;\n\n    return ret;\n}\n\n\nconst Buffers::inputList& Buffers::getData() const\n{\n    return dataList_;\n}\n\n\nconst Buffers::outputList& Buffers::getHandShake() const\n{\n    return handShakeList_;\n}\n\n\nBuffers::inputList& Buffers::useData()\n{\n    return dataList_;\n}\n\n\nBuffers::outputList& Buffers::useHandShake()\n{\n    return handShakeList_;\n}\n\n\nSecurity::Security(ProtocolVersion pv, RandomPool& ran, ConnectionEnd ce,\n                   const Ciphers& ciphers, SSL_CTX* ctx, bool haveDH)\n   : conn_(pv, ran), parms_(ce, ciphers, pv, haveDH), resumeSession_(ran),\n     ctx_(ctx), resuming_(false)\n{}\n\n\nconst Connection& Security::get_connection() const\n{\n    return conn_;\n}\n\n\nconst SSL_CTX* Security::GetContext() const\n{\n    return ctx_;\n}\n\n\nconst Parameters& Security::get_parms() const\n{\n    return parms_;\n}\n\n\nconst SSL_SESSION& Security::get_resume() const\n{\n    return resumeSession_;\n}\n\n\nbool Security::get_resuming() const\n{\n    return resuming_;\n}\n\n\nConnection& Security::use_connection()\n{\n    return conn_;\n}\n\n\nParameters& Security::use_parms()\n{\n    return parms_;\n}\n\n\nSSL_SESSION& Security::use_resume()\n{\n    return resumeSession_;\n}\n\n\nvoid Security::set_resuming(bool b)\n{\n    resuming_ = b;\n}\n\n\nX509_NAME::X509_NAME(const char* n, size_t sz)\n    : name_(0), sz_(sz)\n{\n    if (sz) {\n        name_ = NEW_YS char[sz];\n        memcpy(name_, n, sz);\n    }\n    entry_.data = 0;\n}\n\n\nX509_NAME::~X509_NAME()\n{\n    ysArrayDelete(name_);\n    ysArrayDelete(entry_.data);\n}\n\n\nconst char* X509_NAME::GetName() const\n{\n    return name_;\n}\n\n\nsize_t X509_NAME::GetLength() const\n{\n    return sz_;\n}\n\n\nX509::X509(const char* i, size_t iSz, const char* s, size_t sSz,\n           ASN1_STRING *b, ASN1_STRING *a)\n    : issuer_(i, iSz), subject_(s, sSz),\n      beforeDate_((char *) b->data, b->length, b->type),\n      afterDate_((char *) a->data, a->length, a->type)\n{}\n\n\nX509_NAME* X509::GetIssuer()\n{\n    return &issuer_;\n}\n\n\nX509_NAME* X509::GetSubject()\n{\n    return &subject_;\n}\n\n\nASN1_TIME* X509::GetBefore()\n{\n    return beforeDate_.GetString();\n}\n\n\nASN1_TIME* X509::GetAfter()\n{\n    return afterDate_.GetString();\n}\n\n\nASN1_STRING* X509_NAME::GetEntry(int i)\n{\n    if (i < 0 || i >= int(sz_))\n        return 0;\n\n    if (entry_.data)\n        ysArrayDelete(entry_.data);\n    entry_.data = NEW_YS byte[sz_];       // max size;\n\n    memcpy(entry_.data, &name_[i], sz_ - i);\n    if (entry_.data[sz_ -i - 1]) {\n        entry_.data[sz_ - i] = 0;\n        entry_.length = int(sz_) - i;\n    }\n    else\n        entry_.length = int(sz_) - i - 1;\n    entry_.type = 0;\n\n    return &entry_;\n}\n\n\nStringHolder::StringHolder(const char* str, int sz, byte type)\n{\n    asnString_.length = sz;\n    asnString_.data = NEW_YS byte[sz + 1];\n    memcpy(asnString_.data, str, sz);\n    asnString_.type = type;\n}\n\n\nStringHolder::~StringHolder()\n{\n    ysArrayDelete(asnString_.data);\n}\n\n\nASN1_STRING* StringHolder::GetString()\n{\n    return &asnString_;\n}\n\n\n#ifdef HAVE_LIBZ\n\n    void* myAlloc(void* /* opaque */, unsigned int item, unsigned int size)\n    {\n        return NEW_YS unsigned char[item * size];\n    }\n\n\n    void myFree(void* /* opaque */, void* memory)\n    {\n        unsigned char* ptr = static_cast<unsigned char*>(memory);\n        yaSSL::ysArrayDelete(ptr);\n    }\n\n\n    // put size in front of compressed data\n    int Compress(const byte* in, int sz, input_buffer& buffer)\n    {\n        byte     tmp[LENGTH_SZ];\n        z_stream c_stream; /* compression stream */\n\n        buffer.allocate(sz + sizeof(uint16) + COMPRESS_EXTRA);\n\n        c_stream.zalloc = myAlloc;\n        c_stream.zfree  = myFree;\n        c_stream.opaque = (voidpf)0;\n\n        c_stream.next_in   = const_cast<byte*>(in);\n        c_stream.avail_in  = sz;\n        c_stream.next_out  = buffer.get_buffer() + sizeof(tmp);\n        c_stream.avail_out = buffer.get_capacity() - sizeof(tmp);\n\n        if (deflateInit(&c_stream, 8) != Z_OK) return -1;\n        int err = deflate(&c_stream, Z_FINISH);\n        deflateEnd(&c_stream);\n        if (err != Z_OK && err != Z_STREAM_END) return -1;\n\n        c16toa(sz, tmp);\n        memcpy(buffer.get_buffer(), tmp, sizeof(tmp));\n        buffer.add_size(c_stream.total_out + sizeof(tmp));\n\n        return 0;\n    }\n\n\n    // get uncompressed size in front\n    int DeCompress(input_buffer& in, int sz, input_buffer& out)\n    {\n        byte tmp[LENGTH_SZ];\n   \n        tmp[0] = in[AUTO]; \n        tmp[1] = in[AUTO]; \n\n        uint16 len;\n        ato16(tmp, len);\n\n        out.allocate(len);\n\n        z_stream d_stream; /* decompression stream */\n\n        d_stream.zalloc = myAlloc;\n        d_stream.zfree  = myFree;\n        d_stream.opaque = (voidpf)0;\n\n        d_stream.next_in   = in.get_buffer() + in.get_current();\n        d_stream.avail_in  = sz - sizeof(tmp);\n        d_stream.next_out  = out.get_buffer();\n        d_stream.avail_out = out.get_capacity();\n\n        if (inflateInit(&d_stream) != Z_OK) return -1;\n        int err = inflate(&d_stream, Z_FINISH);\n        inflateEnd(&d_stream);\n        if (err != Z_OK && err != Z_STREAM_END) return -1;\n\n        out.add_size(d_stream.total_out);\n        in.set_current(in.get_current() + sz - sizeof(tmp));\n\n        return 0;\n    }\n\n\n#else  // LIBZ\n\n    // these versions should never get called\n    int Compress(const byte* in, int sz, input_buffer& buffer)\n    {\n        return -1;\n    } \n\n\n    int DeCompress(input_buffer& in, int sz, input_buffer& out)\n    {\n        return -1;\n    } \n\n\n#endif // LIBZ\n\n\n} // namespace\n\n\n\nextern \"C\" void yaSSL_CleanUp()\n{\n    TaoCrypt::CleanUp();\n    yaSSL::ysDelete(yaSSL::sslFactoryInstance);\n    yaSSL::ysDelete(yaSSL::sessionsInstance);\n    yaSSL::ysDelete(yaSSL::errorsInstance);\n\n    // In case user calls more than once, prevent seg fault\n    yaSSL::sslFactoryInstance = 0;\n    yaSSL::sessionsInstance = 0;\n    yaSSL::errorsInstance = 0;\n}\n\n\n#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION\nnamespace mySTL {\ntemplate yaSSL::yassl_int_cpp_local1::SumData for_each<mySTL::list<yaSSL::input_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumData>(mySTL::list<yaSSL::input_buffer*>::iterator, mySTL::list<yaSSL::input_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumData);\ntemplate yaSSL::yassl_int_cpp_local1::SumBuffer for_each<mySTL::list<yaSSL::output_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumBuffer>(mySTL::list<yaSSL::output_buffer*>::iterator, mySTL::list<yaSSL::output_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumBuffer);\ntemplate mySTL::list<yaSSL::SSL_SESSION*>::iterator find_if<mySTL::list<yaSSL::SSL_SESSION*>::iterator, yaSSL::yassl_int_cpp_local2::sess_match>(mySTL::list<yaSSL::SSL_SESSION*>::iterator, mySTL::list<yaSSL::SSL_SESSION*>::iterator, yaSSL::yassl_int_cpp_local2::sess_match);\ntemplate mySTL::list<yaSSL::ThreadError>::iterator find_if<mySTL::list<yaSSL::ThreadError>::iterator, yaSSL::yassl_int_cpp_local2::thr_match>(mySTL::list<yaSSL::ThreadError>::iterator, mySTL::list<yaSSL::ThreadError>::iterator, yaSSL::yassl_int_cpp_local2::thr_match);\n}\n#endif\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/CMakeLists.txt",
    "content": "# Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.\n# \n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n# \n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n# \n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA\n\nINCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/mySTL\n                      ${CMAKE_CURRENT_SOURCE_DIR}/include)\n\nINCLUDE_DIRECTORIES(${MySQLRouter_SOURCE_DIR}/include)\n\n# config.h\nINCLUDE_DIRECTORIES(${MySQLRouter_SOURCE_DIR}/)\nADD_DEFINITIONS(${SSL_DEFINES})\nIF(NOT WIN32)\n  ADD_DEFINITIONS(-Wno-error)\nENDIF()\nSET(TAOCRYPT_SOURCES\t\tsrc/aes.cpp src/aestables.cpp src/algebra.cpp src/arc4.cpp src/asn.cpp src/coding.cpp \n\t\t\t\tsrc/des.cpp src/dh.cpp src/dsa.cpp src/file.cpp src/hash.cpp src/integer.cpp src/md2.cpp \n\t\t\t\tsrc/md4.cpp src/md5.cpp src/misc.cpp src/random.cpp src/ripemd.cpp src/rsa.cpp src/sha.cpp \n\t\t\t\tsrc/rabbit.cpp src/hc128.cpp\n\t\t\t\tinclude/aes.hpp include/algebra.hpp include/arc4.hpp include/asn.hpp include/block.hpp \n\t\t\t\tinclude/coding.hpp include/des.hpp include/dh.hpp include/dsa.hpp include/dsa.hpp\n\t\t\t\tinclude/error.hpp include/file.hpp include/hash.hpp include/hmac.hpp include/integer.hpp \n\t\t\t\tinclude/md2.hpp include/md5.hpp include/misc.hpp include/modarith.hpp include/modes.hpp\n\t\t\t\tinclude/random.hpp include/ripemd.hpp include/rsa.hpp include/sha.hpp\n\t\t\t\tinclude/rabbit.hpp include/hc128.hpp)\n\nIF(HAVE_EXPLICIT_TEMPLATE_INSTANTIATION)\n  SET(TAOCRYPT_SOURCES ${TAOCRYPT_SOURCES} src/template_instnt.cpp)\nENDIF()\n\nADD_CONVENIENCE_LIBRARY(router_taocrypt ${TAOCRYPT_SOURCES})\n"
  },
  {
    "path": "ext/yassl/taocrypt/COPYING",
    "content": "\t\t    GNU GENERAL PUBLIC LICENSE\n\t\t       Version 2, June 1991\n\n Copyright (C) 1989, 1991 Free Software Foundation, Inc.\n 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n\t\t\t    Preamble\n\n  The licenses for most software are designed to take away your\nfreedom to share and change it.  By contrast, the GNU General Public\nLicense is intended to guarantee your freedom to share and change free\nsoftware--to make sure the software is free for all its users.  This\nGeneral Public License applies to most of the Free Software\nFoundation's software and to any other program whose authors commit to\nusing it.  (Some other Free Software Foundation software is covered by\nthe GNU Library General Public License instead.)  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthis service if you wish), that you receive source code or can get it\nif you want it, that you can change the software or use pieces of it\nin new free programs; and that you know you can do these things.\n\n  To protect your rights, we need to make restrictions that forbid\nanyone to deny you these rights or to ask you to surrender the rights.\nThese restrictions translate to certain responsibilities for you if you\ndistribute copies of the software, or if you modify it.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must give the recipients all the rights that\nyou have.  You must make sure that they, too, receive or can get the\nsource code.  And you must show them these terms so they know their\nrights.\n\n  We protect your rights with two steps: (1) copyright the software, and\n(2) offer you this license which gives you legal permission to copy,\ndistribute and/or modify the software.\n\n  Also, for each author's protection and ours, we want to make certain\nthat everyone understands that there is no warranty for this free\nsoftware.  If the software is modified by someone else and passed on, we\nwant its recipients to know that what they have is not the original, so\nthat any problems introduced by others will not reflect on the original\nauthors' reputations.\n\n  Finally, any free program is threatened constantly by software\npatents.  We wish to avoid the danger that redistributors of a free\nprogram will individually obtain patent licenses, in effect making the\nprogram proprietary.  To prevent this, we have made it clear that any\npatent must be licensed for everyone's free use or not licensed at all.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\f\n\t\t    GNU GENERAL PUBLIC LICENSE\n   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n  0. This License applies to any program or other work which contains\na notice placed by the copyright holder saying it may be distributed\nunder the terms of this General Public License.  The \"Program\", below,\nrefers to any such program or work, and a \"work based on the Program\"\nmeans either the Program or any derivative work under copyright law:\nthat is to say, a work containing the Program or a portion of it,\neither verbatim or with modifications and/or translated into another\nlanguage.  (Hereinafter, translation is included without limitation in\nthe term \"modification\".)  Each licensee is addressed as \"you\".\n\nActivities other than copying, distribution and modification are not\ncovered by this License; they are outside its scope.  The act of\nrunning the Program is not restricted, and the output from the Program\nis covered only if its contents constitute a work based on the\nProgram (independent of having been made by running the Program).\nWhether that is true depends on what the Program does.\n\n  1. You may copy and distribute verbatim copies of the Program's\nsource code as you receive it, in any medium, provided that you\nconspicuously and appropriately publish on each copy an appropriate\ncopyright notice and disclaimer of warranty; keep intact all the\nnotices that refer to this License and to the absence of any warranty;\nand give any other recipients of the Program a copy of this License\nalong with the Program.\n\nYou may charge a fee for the physical act of transferring a copy, and\nyou may at your option offer warranty protection in exchange for a fee.\n\n  2. You may modify your copy or copies of the Program or any portion\nof it, thus forming a work based on the Program, and copy and\ndistribute such modifications or work under the terms of Section 1\nabove, provided that you also meet all of these conditions:\n\n    a) You must cause the modified files to carry prominent notices\n    stating that you changed the files and the date of any change.\n\n    b) You must cause any work that you distribute or publish, that in\n    whole or in part contains or is derived from the Program or any\n    part thereof, to be licensed as a whole at no charge to all third\n    parties under the terms of this License.\n\n    c) If the modified program normally reads commands interactively\n    when run, you must cause it, when started running for such\n    interactive use in the most ordinary way, to print or display an\n    announcement including an appropriate copyright notice and a\n    notice that there is no warranty (or else, saying that you provide\n    a warranty) and that users may redistribute the program under\n    these conditions, and telling the user how to view a copy of this\n    License.  (Exception: if the Program itself is interactive but\n    does not normally print such an announcement, your work based on\n    the Program is not required to print an announcement.)\n\f\nThese requirements apply to the modified work as a whole.  If\nidentifiable sections of that work are not derived from the Program,\nand can be reasonably considered independent and separate works in\nthemselves, then this License, and its terms, do not apply to those\nsections when you distribute them as separate works.  But when you\ndistribute the same sections as part of a whole which is a work based\non the Program, the distribution of the whole must be on the terms of\nthis License, whose permissions for other licensees extend to the\nentire whole, and thus to each and every part regardless of who wrote it.\n\nThus, it is not the intent of this section to claim rights or contest\nyour rights to work written entirely by you; rather, the intent is to\nexercise the right to control the distribution of derivative or\ncollective works based on the Program.\n\nIn addition, mere aggregation of another work not based on the Program\nwith the Program (or with a work based on the Program) on a volume of\na storage or distribution medium does not bring the other work under\nthe scope of this License.\n\n  3. You may copy and distribute the Program (or a work based on it,\nunder Section 2) in object code or executable form under the terms of\nSections 1 and 2 above provided that you also do one of the following:\n\n    a) Accompany it with the complete corresponding machine-readable\n    source code, which must be distributed under the terms of Sections\n    1 and 2 above on a medium customarily used for software interchange; or,\n\n    b) Accompany it with a written offer, valid for at least three\n    years, to give any third party, for a charge no more than your\n    cost of physically performing source distribution, a complete\n    machine-readable copy of the corresponding source code, to be\n    distributed under the terms of Sections 1 and 2 above on a medium\n    customarily used for software interchange; or,\n\n    c) Accompany it with the information you received as to the offer\n    to distribute corresponding source code.  (This alternative is\n    allowed only for noncommercial distribution and only if you\n    received the program in object code or executable form with such\n    an offer, in accord with Subsection b above.)\n\nThe source code for a work means the preferred form of the work for\nmaking modifications to it.  For an executable work, complete source\ncode means all the source code for all modules it contains, plus any\nassociated interface definition files, plus the scripts used to\ncontrol compilation and installation of the executable.  However, as a\nspecial exception, the source code distributed need not include\nanything that is normally distributed (in either source or binary\nform) with the major components (compiler, kernel, and so on) of the\noperating system on which the executable runs, unless that component\nitself accompanies the executable.\n\nIf distribution of executable or object code is made by offering\naccess to copy from a designated place, then offering equivalent\naccess to copy the source code from the same place counts as\ndistribution of the source code, even though third parties are not\ncompelled to copy the source along with the object code.\n\f\n  4. You may not copy, modify, sublicense, or distribute the Program\nexcept as expressly provided under this License.  Any attempt\notherwise to copy, modify, sublicense or distribute the Program is\nvoid, and will automatically terminate your rights under this License.\nHowever, parties who have received copies, or rights, from you under\nthis License will not have their licenses terminated so long as such\nparties remain in full compliance.\n\n  5. You are not required to accept this License, since you have not\nsigned it.  However, nothing else grants you permission to modify or\ndistribute the Program or its derivative works.  These actions are\nprohibited by law if you do not accept this License.  Therefore, by\nmodifying or distributing the Program (or any work based on the\nProgram), you indicate your acceptance of this License to do so, and\nall its terms and conditions for copying, distributing or modifying\nthe Program or works based on it.\n\n  6. Each time you redistribute the Program (or any work based on the\nProgram), the recipient automatically receives a license from the\noriginal licensor to copy, distribute or modify the Program subject to\nthese terms and conditions.  You may not impose any further\nrestrictions on the recipients' exercise of the rights granted herein.\nYou are not responsible for enforcing compliance by third parties to\nthis License.\n\n  7. If, as a consequence of a court judgment or allegation of patent\ninfringement or for any other reason (not limited to patent issues),\nconditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot\ndistribute so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you\nmay not distribute the Program at all.  For example, if a patent\nlicense would not permit royalty-free redistribution of the Program by\nall those who receive copies directly or indirectly through you, then\nthe only way you could satisfy both it and this License would be to\nrefrain entirely from distribution of the Program.\n\nIf any portion of this section is held invalid or unenforceable under\nany particular circumstance, the balance of the section is intended to\napply and the section as a whole is intended to apply in other\ncircumstances.\n\nIt is not the purpose of this section to induce you to infringe any\npatents or other property right claims or to contest validity of any\nsuch claims; this section has the sole purpose of protecting the\nintegrity of the free software distribution system, which is\nimplemented by public license practices.  Many people have made\ngenerous contributions to the wide range of software distributed\nthrough that system in reliance on consistent application of that\nsystem; it is up to the author/donor to decide if he or she is willing\nto distribute software through any other system and a licensee cannot\nimpose that choice.\n\nThis section is intended to make thoroughly clear what is believed to\nbe a consequence of the rest of this License.\n\f\n  8. If the distribution and/or use of the Program is restricted in\ncertain countries either by patents or by copyrighted interfaces, the\noriginal copyright holder who places the Program under this License\nmay add an explicit geographical distribution limitation excluding\nthose countries, so that distribution is permitted only in or among\ncountries not thus excluded.  In such case, this License incorporates\nthe limitation as if written in the body of this License.\n\n  9. The Free Software Foundation may publish revised and/or new versions\nof the General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\nEach version is given a distinguishing version number.  If the Program\nspecifies a version number of this License which applies to it and \"any\nlater version\", you have the option of following the terms and conditions\neither of that version or of any later version published by the Free\nSoftware Foundation.  If the Program does not specify a version number of\nthis License, you may choose any version ever published by the Free Software\nFoundation.\n\n  10. If you wish to incorporate parts of the Program into other free\nprograms whose distribution conditions are different, write to the author\nto ask for permission.  For software which is copyrighted by the Free\nSoftware Foundation, write to the Free Software Foundation; we sometimes\nmake exceptions for this.  Our decision will be guided by the two goals\nof preserving the free status of all derivatives of our free software and\nof promoting the sharing and reuse of software generally.\n\n\t\t\t    NO WARRANTY\n\n  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\nFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN\nOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\nPROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\nOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS\nTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE\nPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\nREPAIR OR CORRECTION.\n\n  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\nREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\nINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\nOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\nTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\nYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\nPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGES.\n\n\t\t     END OF TERMS AND CONDITIONS\n\f\n\t    How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nconvey the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software; you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation; either version 2 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program; if not, write to the Free Software\n    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\n\n\nAlso add information on how to contact you by electronic and paper mail.\n\nIf the program is interactive, make it output a short notice like this\nwhen it starts in an interactive mode:\n\n    Gnomovision version 69, Copyright (C) year  name of author\n    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, the commands you use may\nbe called something other than `show w' and `show c'; they could even be\nmouse-clicks or menu items--whatever suits your program.\n\nYou should also get your employer (if you work as a programmer) or your\nschool, if any, to sign a \"copyright disclaimer\" for the program, if\nnecessary.  Here is a sample; alter the names:\n\n  Yoyodyne, Inc., hereby disclaims all copyright interest in the program\n  `Gnomovision' (which makes passes at compilers) written by James Hacker.\n\n  <signature of Ty Coon>, 1 April 1989\n  Ty Coon, President of Vice\n\nThis General Public License does not permit incorporating your program into\nproprietary programs.  If your program is a subroutine library, you may\nconsider it more useful to permit linking proprietary applications with the\nlibrary.  If this is what you want to do, use the GNU Library General\nPublic License instead of this License.\n"
  },
  {
    "path": "ext/yassl/taocrypt/INSTALL",
    "content": "Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software\nFoundation, Inc.\n\n   This file is free documentation; the Free Software Foundation gives\nunlimited permission to copy, distribute and modify it.\n\nBasic Installation\n==================\n\n   These are generic installation instructions.\n\n   The `configure' shell script attempts to guess correct values for\nvarious system-dependent variables used during compilation.  It uses\nthose values to create a `Makefile' in each directory of the package.\nIt may also create one or more `.h' files containing system-dependent\ndefinitions.  Finally, it creates a shell script `config.status' that\nyou can run in the future to recreate the current configuration, and a\nfile `config.log' containing compiler output (useful mainly for\ndebugging `configure').\n\n   It can also use an optional file (typically called `config.cache'\nand enabled with `--cache-file=config.cache' or simply `-C') that saves\nthe results of its tests to speed up reconfiguring.  (Caching is\ndisabled by default to prevent problems with accidental use of stale\ncache files.)\n\n   If you need to do unusual things to compile the package, please try\nto figure out how `configure' could check whether to do them, and mail\ndiffs or instructions to the address given in the `README' so they can\nbe considered for the next release.  If you are using the cache, and at\nsome point `config.cache' contains results you don't want to keep, you\nmay remove or edit it.\n\n   The file `configure.ac' (or `configure.in') is used to create\n`configure' by a program called `autoconf'.  You only need\n`configure.ac' if you want to change it or regenerate `configure' using\na newer version of `autoconf'.\n\nThe simplest way to compile this package is:\n\n  1. `cd' to the directory containing the package's source code and type\n     `./configure' to configure the package for your system.  If you're\n     using `csh' on an old version of System V, you might need to type\n     `sh ./configure' instead to prevent `csh' from trying to execute\n     `configure' itself.\n\n     Running `configure' takes awhile.  While running, it prints some\n     messages telling which features it is checking for.\n\n  2. Type `make' to compile the package.\n\n  3. Optionally, type `make check' to run any self-tests that come with\n     the package.\n\n  4. Type `make install' to install the programs and any data files and\n     documentation.\n\n  5. You can remove the program binaries and object files from the\n     source code directory by typing `make clean'.  To also remove the\n     files that `configure' created (so you can compile the package for\n     a different kind of computer), type `make distclean'.  There is\n     also a `make maintainer-clean' target, but that is intended mainly\n     for the package's developers.  If you use it, you may have to get\n     all sorts of other programs in order to regenerate files that came\n     with the distribution.\n\nCompilers and Options\n=====================\n\n   Some systems require unusual options for compilation or linking that\nthe `configure' script does not know about.  Run `./configure --help'\nfor details on some of the pertinent environment variables.\n\n   You can give `configure' initial values for configuration parameters\nby setting variables in the command line or in the environment.  Here\nis an example:\n\n     ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix\n\n   *Note Defining Variables::, for more details.\n\nCompiling For Multiple Architectures\n====================================\n\n   You can compile the package for more than one kind of computer at the\nsame time, by placing the object files for each architecture in their\nown directory.  To do this, you must use a version of `make' that\nsupports the `VPATH' variable, such as GNU `make'.  `cd' to the\ndirectory where you want the object files and executables to go and run\nthe `configure' script.  `configure' automatically checks for the\nsource code in the directory that `configure' is in and in `..'.\n\n   If you have to use a `make' that does not support the `VPATH'\nvariable, you have to compile the package for one architecture at a\ntime in the source code directory.  After you have installed the\npackage for one architecture, use `make distclean' before reconfiguring\nfor another architecture.\n\nInstallation Names\n==================\n\n   By default, `make install' will install the package's files in\n`/usr/local/bin', `/usr/local/man', etc.  You can specify an\ninstallation prefix other than `/usr/local' by giving `configure' the\noption `--prefix=PATH'.\n\n   You can specify separate installation prefixes for\narchitecture-specific files and architecture-independent files.  If you\ngive `configure' the option `--exec-prefix=PATH', the package will use\nPATH as the prefix for installing programs and libraries.\nDocumentation and other data files will still use the regular prefix.\n\n   In addition, if you use an unusual directory layout you can give\noptions like `--bindir=PATH' to specify different values for particular\nkinds of files.  Run `configure --help' for a list of the directories\nyou can set and what kinds of files go in them.\n\n   If the package supports it, you can cause programs to be installed\nwith an extra prefix or suffix on their names by giving `configure' the\noption `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.\n\nOptional Features\n=================\n\n   Some packages pay attention to `--enable-FEATURE' options to\n`configure', where FEATURE indicates an optional part of the package.\nThey may also pay attention to `--with-PACKAGE' options, where PACKAGE\nis something like `gnu-as' or `x' (for the X Window System).  The\n`README' should mention any `--enable-' and `--with-' options that the\npackage recognizes.\n\n   For packages that use the X Window System, `configure' can usually\nfind the X include and library files automatically, but if it doesn't,\nyou can use the `configure' options `--x-includes=DIR' and\n`--x-libraries=DIR' to specify their locations.\n\nSpecifying the System Type\n==========================\n\n   There may be some features `configure' cannot figure out\nautomatically, but needs to determine by the type of machine the package\nwill run on.  Usually, assuming the package is built to be run on the\n_same_ architectures, `configure' can figure that out, but if it prints\na message saying it cannot guess the machine type, give it the\n`--build=TYPE' option.  TYPE can either be a short name for the system\ntype, such as `sun4', or a canonical name which has the form:\n\n     CPU-COMPANY-SYSTEM\n\nwhere SYSTEM can have one of these forms:\n\n     OS KERNEL-OS\n\n   See the file `config.sub' for the possible values of each field.  If\n`config.sub' isn't included in this package, then this package doesn't\nneed to know the machine type.\n\n   If you are _building_ compiler tools for cross-compiling, you should\nuse the `--target=TYPE' option to select the type of system they will\nproduce code for.\n\n   If you want to _use_ a cross compiler, that generates code for a\nplatform different from the build platform, you should specify the\n\"host\" platform (i.e., that on which the generated programs will\neventually be run) with `--host=TYPE'.\n\nSharing Defaults\n================\n\n   If you want to set default values for `configure' scripts to share,\nyou can create a site shell script called `config.site' that gives\ndefault values for variables like `CC', `cache_file', and `prefix'.\n`configure' looks for `PREFIX/share/config.site' if it exists, then\n`PREFIX/etc/config.site' if it exists.  Or, you can set the\n`CONFIG_SITE' environment variable to the location of the site script.\nA warning: not all `configure' scripts look for a site script.\n\nDefining Variables\n==================\n\n   Variables not defined in a site shell script can be set in the\nenvironment passed to `configure'.  However, some packages may run\nconfigure again during the build, and the customized values of these\nvariables may be lost.  In order to avoid this problem, you should set\nthem in the `configure' command line, using `VAR=value'.  For example:\n\n     ./configure CC=/usr/local2/bin/gcc\n\nwill cause the specified gcc to be used as the C compiler (unless it is\noverridden in the site shell script).\n\n`configure' Invocation\n======================\n\n   `configure' recognizes the following options to control how it\noperates.\n\n`--help'\n`-h'\n     Print a summary of the options to `configure', and exit.\n\n`--version'\n`-V'\n     Print the version of Autoconf used to generate the `configure'\n     script, and exit.\n\n`--cache-file=FILE'\n     Enable the cache: use and save the results of the tests in FILE,\n     traditionally `config.cache'.  FILE defaults to `/dev/null' to\n     disable caching.\n\n`--config-cache'\n`-C'\n     Alias for `--cache-file=config.cache'.\n\n`--quiet'\n`--silent'\n`-q'\n     Do not print messages saying which checks are being made.  To\n     suppress all normal output, redirect it to `/dev/null' (any error\n     messages will still be shown).\n\n`--srcdir=DIR'\n     Look for the package's source code in directory DIR.  Usually\n     `configure' can determine that directory automatically.\n\n`configure' also accepts some other, not widely useful, options.  Run\n`configure --help' for more details.\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/README",
    "content": "TaoCrypt release 0.9.2   02/5/2007\n\n\nThis release includes bug fixes, portability enhancements, and some \noptimiations.\n\nSee 0.9.0 for build instructions.\n\n\n\n\n******************TaoCrypt release 0.9.0   09/18/2006\n\nThis is the first release of TaoCrypt, it was previously only included with\nyaSSL. TaoCrypt is highly portable and fast, its features include:\n\nOne way hash functions: SHA-1, MD2, MD4, MD5, RIPEMD-160\nMessage authentication codes: HMAC\nBlock Ciphers: DES, Triple-DES, AES, Blowfish, Twofish\nStream Ciphers: ARC4\nPublic Key Crypto: RSA, DSA, Diffie-Hellman\nPassword based key derivation: PBKDF2 from PKCS #5\nPseudo Random Number Generators\nLarge Integer Support\nBase 16/64 encoding/decoding\nDER encoding/decoding\nX.509 processing\nSSE2 and ia32 asm for the right processors and compilers\n\n\nTo build on Unix\n\n    ./configure\n    make\n\n    To test the build, from the ./test directory run ./test\n\n\nOn Windows\n\n    Open the taocrypt project workspace\n    Choose (Re)Build All\n\n    To test the build, run the test executable\n\n\nPlease send any questions or comments to todd@yassl.com.\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/benchmark/benchmark.cpp",
    "content": "/*\n   Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n// benchmark.cpp\n// TaoCrypt benchmark\n\n#include <string.h>\n#include <stdio.h>\n\n#include \"runtime.hpp\"\n#include \"des.hpp\"\n#include \"aes.hpp\"\n#include \"twofish.hpp\"\n#include \"blowfish.hpp\"\n#include \"arc4.hpp\"\n#include \"md5.hpp\"\n#include \"sha.hpp\"\n#include \"ripemd.hpp\"\n#include \"rsa.hpp\"\n#include \"dh.hpp\"\n#include \"dsa.hpp\"\n\n\nusing namespace TaoCrypt;\n\nvoid bench_aes(bool show);\nvoid bench_des();\nvoid bench_blowfish();\nvoid bench_twofish();\nvoid bench_arc4();\n\nvoid bench_md5();\nvoid bench_sha();\nvoid bench_ripemd();\n\nvoid bench_rsa();\nvoid bench_dh();\nvoid bench_dsa();\n\ndouble current_time();\n\n\n\n\nint main(int argc, char** argv)\n{\n    bench_aes(false);\n    bench_aes(true);\n    bench_blowfish();\n    bench_twofish();\n    bench_arc4();\n    bench_des();\n    \n    printf(\"\\n\");\n\n    bench_md5();\n    bench_sha();\n    bench_ripemd();\n\n    printf(\"\\n\");\n    \n    bench_rsa();\n    bench_dh();\n    bench_dsa();\n\n    return 0;\n}\n\nconst int megs = 5;  // how much to test\n\nconst byte key[] = \n{\n    0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,\n    0xfe,0xde,0xba,0x98,0x76,0x54,0x32,0x10,\n    0x89,0xab,0xcd,0xef,0x01,0x23,0x45,0x67\n};\n\nconst byte iv[] = \n{\n    0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef,\n    0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,\n    0x11,0x21,0x31,0x41,0x51,0x61,0x71,0x81\n    \n};\n\n\nbyte plain [1024*1024];\nbyte cipher[1024*1024];\n\n\nvoid bench_des()\n{\n    DES_EDE3_CBC_Encryption enc;\n    enc.SetKey(key, 16, iv);\n\n    double start = current_time();\n\n    for(int i = 0; i < megs; i++)\n        enc.Process(plain, cipher, sizeof(plain));\n\n    double total = current_time() - start;\n\n    double persec = 1 / total * megs;\n\n    printf(\"3DES     %d megs took %5.3f seconds, %6.2f MB/s\\n\", megs, total,\n                                                             persec);\n}\n\n\nvoid bench_aes(bool show)\n{\n    AES_CBC_Encryption enc;\n    enc.SetKey(key, 16, iv);\n\n    double start = current_time();\n \n    for(int i = 0; i < megs; i++)\n        enc.Process(plain, cipher, sizeof(plain));\n\n    double total = current_time() - start;\n\n    double persec = 1 / total * megs;\n\n    if (show)\n        printf(\"AES      %d megs took %5.3f seconds, %6.2f MB/s\\n\", megs, total,\n                                                                 persec);\n}\n\n\nvoid bench_twofish()\n{\n    Twofish_CBC_Encryption enc;\n    enc.SetKey(key, 16, iv);\n\n    double start = current_time();\n\n    for(int i = 0; i < megs; i++)\n        enc.Process(plain, cipher, sizeof(plain));\n\n    double total = current_time() - start;\n\n    double persec = 1 / total * megs;\n\n    printf(\"Twofish  %d megs took %5.3f seconds, %6.2f MB/s\\n\", megs, total,\n                                                            persec);\n\n}\n\n\nvoid bench_blowfish()\n{\n    Blowfish_CBC_Encryption enc;\n    enc.SetKey(key, 16, iv);\n\n    double start = current_time();\n\n    for(int i = 0; i < megs; i++)\n        enc.Process(plain, cipher, sizeof(plain));\n\n    double total = current_time() - start;\n\n    double persec = 1 / total * megs;\n\n    printf(\"Blowfish %d megs took %5.3f seconds, %6.2f MB/s\\n\", megs, total,\n                                                             persec);\n}\n\n\nvoid bench_arc4()\n{\n    ARC4 enc;\n    enc.SetKey(key, 16);\n\n    double start = current_time();\n\n    for(int i = 0; i < megs; i++)\n        enc.Process(cipher, plain, sizeof(plain));\n\n    double total = current_time() - start;\n\n    double persec = 1 / total * megs;\n\n    printf(\"ARC4     %d megs took %5.3f seconds, %6.2f MB/s\\n\", megs, total,\n                                                             persec);\n}\n\n\nvoid bench_md5()\n{\n    MD5 hash;\n    byte digest[MD5::DIGEST_SIZE];\n\n    double start = current_time();\n\n    \n    for(int i = 0; i < megs; i++)\n        hash.Update(plain, sizeof(plain));\n   \n    hash.Final(digest);\n\n    double total = current_time() - start;\n\n    double persec = 1 / total * megs;\n\n    printf(\"MD5      %d megs took %5.3f seconds, %6.2f MB/s\\n\", megs, total,\n                                                             persec);\n}\n\n\nvoid bench_sha()\n{\n    SHA hash;\n    byte digest[SHA::DIGEST_SIZE];\n\n    double start = current_time();\n\n    \n    for(int i = 0; i < megs; i++)\n        hash.Update(plain, sizeof(plain));\n   \n    hash.Final(digest);\n\n    /*\n    for(int i = 0; i < megs; i++)\n        hash.AsmTransform(plain, 16384);\n    */\n\n\n    double total = current_time() - start;\n\n    double persec = 1 / total * megs;\n\n    printf(\"SHA      %d megs took %5.3f seconds, %6.2f MB/s\\n\", megs, total,\n                                                             persec);\n}\n\n\nvoid bench_ripemd()\n{\n    RIPEMD160 hash;\n    byte digest[RIPEMD160::DIGEST_SIZE];\n\n    double start = current_time();\n\n    \n    for(int i = 0; i < megs; i++)\n        hash.Update(plain, sizeof(plain));\n   \n    hash.Final(digest);\n\n    double total = current_time() - start;\n\n    double persec = 1 / total * megs;\n\n    printf(\"RIPEMD   %d megs took %5.3f seconds, %6.2f MB/s\\n\", megs, total,\n                                                             persec);\n}\n\nRandomNumberGenerator rng;\n\nvoid bench_rsa()\n{\n    const int times = 100;\n\n    Source source;\n    FileSource(\"./rsa1024.der\", source);\n\n    if (source.size() == 0) {\n        printf(\"can't find ./rsa1024.der\\n\");\n        return;\n    }\n    RSA_PrivateKey priv(source);\n    RSAES_Encryptor enc(priv);\n\n    byte      message[] = \"Everyone gets Friday off.\";\n    byte      cipher[128];  // for 1024 bit\n    byte      plain[128];   // for 1024 bit\n    const int len = (word32)strlen((char*)message);\n    \n    int i;    \n    double start = current_time();\n\n    for (i = 0; i < times; i++)\n        enc.Encrypt(message, len, cipher, rng);\n\n    double total = current_time() - start;\n    double each  = total / times;   // per second\n    double milliEach = each * 1000; // milliseconds\n\n    printf(\"RSA 1024 encryption took %6.2f milliseconds, avg over %d\" \n           \" iterations\\n\", milliEach, times);\n\n    RSAES_Decryptor dec(priv);\n\n    start = current_time();\n\n    for (i = 0; i < times; i++)\n        dec.Decrypt(cipher, 128, plain, rng);\n\n    total = current_time() - start;\n    each  = total / times;   // per second\n    milliEach = each * 1000; // milliseconds\n\n    printf(\"RSA 1024 decryption took %6.2f milliseconds, avg over %d\" \n           \" iterations\\n\", milliEach, times);\n}\n\n\nvoid bench_dh()\n{\n    const int times = 100;\n\n    Source source;\n    FileSource(\"./dh1024.der\", source);\n\n    if (source.size() == 0) {\n        printf(\"can't find ./dh1024.der\\n\");\n        return;\n    }\n    DH dh(source);\n\n    byte      pub[128];    // for 1024 bit\n    byte      priv[128];   // for 1024 bit\n    \n    int i;    \n    double start = current_time();\n\n    for (i = 0; i < times; i++)\n        dh.GenerateKeyPair(rng, priv, pub);\n\n    double total = current_time() - start;\n    double each  = total / times;   // per second\n    double milliEach = each * 1000; // milliseconds\n\n    printf(\"DH  1024 key generation  %6.2f milliseconds, avg over %d\" \n           \" iterations\\n\", milliEach, times);\n\n    DH dh2(dh); \n    byte      pub2[128];    // for 1024 bit\n    byte      priv2[128];   // for 1024 bit\n    dh2.GenerateKeyPair(rng, priv2, pub2);\n    unsigned char key[256];\n\n    start = current_time();\n\n    for (i = 0; i < times; i++)\n        dh.Agree(key, priv, pub2);\n\n    total = current_time() - start;\n    each  = total / times;      // per second\n    milliEach = each * 1000;   //  in milliseconds\n\n    printf(\"DH  1024 key agreement   %6.2f milliseconds, avg over %d\"\n           \" iterations\\n\", milliEach, times);\n}\n\nvoid bench_dsa()\n{\n    const int times = 100;\n\n    Source source;\n    FileSource(\"./dsa1024.der\", source);\n\n    if (source.size() == 0) {\n        printf(\"can't find ./dsa1024.der\\n\");\n        return;\n    }\n\n    DSA_PrivateKey key(source);\n    DSA_Signer signer(key);\n\n    SHA sha;\n    byte digest[SHA::DIGEST_SIZE];\n    byte signature[40];\n    const char msg[] = \"this is the message\";\n    sha.Update((byte*)msg, sizeof(msg));\n    sha.Final(digest);\n    \n    int i;    \n    double start = current_time();\n\n    for (i = 0; i < times; i++)\n        signer.Sign(digest, signature, rng); \n\n    double total = current_time() - start;\n    double each  = total / times;   // per second\n    double milliEach = each * 1000; // milliseconds\n\n    printf(\"DSA 1024 sign   took     %6.2f milliseconds, avg over %d\" \n           \" iterations\\n\", milliEach, times);\n\n    DSA_Verifier verifier(key);\n\n    start = current_time();\n\n    for (i = 0; i < times; i++)\n        verifier.Verify(digest, signature); \n\n    total = current_time() - start;\n    each  = total / times;      // per second\n    milliEach = each * 1000;   //  in milliseconds\n\n    printf(\"DSA 1024 verify took     %6.2f milliseconds, avg over %d\"\n           \" iterations\\n\", milliEach, times);\n}\n\n\n\n#ifdef _WIN32\n\n    #define WIN32_LEAN_AND_MEAN\n    #include <windows.h>\n\n    double current_time()\n    {\n        static bool          init(false);\n        static LARGE_INTEGER freq;\n    \n        if (!init) {\n            QueryPerformanceFrequency(&freq);\n            init = true;\n        }\n\n        LARGE_INTEGER count;\n        QueryPerformanceCounter(&count);\n\n        return static_cast<double>(count.QuadPart) / freq.QuadPart;\n    }\n\n#else\n\n    #include <sys/time.h>\n\n    double current_time()\n    {\n        struct timeval tv;\n        gettimeofday(&tv, 0);\n\n        return static_cast<double>(tv.tv_sec) \n             + static_cast<double>(tv.tv_usec) / 1000000;\n    }\n\n#endif // _WIN32\n"
  },
  {
    "path": "ext/yassl/taocrypt/benchmark/benchmark.dsp",
    "content": "# Microsoft Developer Studio Project File - Name=\"benchmark\" - Package Owner=<4>\n# Microsoft Developer Studio Generated Build File, Format Version 6.00\n# ** DO NOT EDIT **\n\n# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\n\nCFG=benchmark - Win32 Debug\n!MESSAGE This is not a valid makefile. To build this project using NMAKE,\n!MESSAGE use the Export Makefile command and run\n!MESSAGE \n!MESSAGE NMAKE /f \"benchmark.mak\".\n!MESSAGE \n!MESSAGE You can specify a configuration when running NMAKE\n!MESSAGE by defining the macro CFG on the command line. For example:\n!MESSAGE \n!MESSAGE NMAKE /f \"benchmark.mak\" CFG=\"benchmark - Win32 Debug\"\n!MESSAGE \n!MESSAGE Possible choices for configuration are:\n!MESSAGE \n!MESSAGE \"benchmark - Win32 Release\" (based on \"Win32 (x86) Console Application\")\n!MESSAGE \"benchmark - Win32 Debug\" (based on \"Win32 (x86) Console Application\")\n!MESSAGE \n\n# Begin Project\n# PROP AllowPerConfigDependencies 0\n# PROP Scc_ProjName \"\"\n# PROP Scc_LocalPath \"\"\nCPP=cl.exe\nRSC=rc.exe\n\n!IF  \"$(CFG)\" == \"benchmark - Win32 Release\"\n\n# PROP BASE Use_MFC 0\n# PROP BASE Use_Debug_Libraries 0\n# PROP BASE Output_Dir \"benchmark___Win32_Release\"\n# PROP BASE Intermediate_Dir \"benchmark___Win32_Release\"\n# PROP BASE Target_Dir \"\"\n# PROP Use_MFC 0\n# PROP Use_Debug_Libraries 0\n# PROP Output_Dir \"Release\"\n# PROP Intermediate_Dir \"Release\"\n# PROP Ignore_Export_Lib 0\n# PROP Target_Dir \"\"\n# ADD BASE CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n# ADD CPP /nologo /MT /W3 /GX /O2 /I \"..\\include\" /I \"..\\mySTL\" /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n# ADD BASE RSC /l 0x409 /d \"NDEBUG\"\n# ADD RSC /l 0x409 /d \"NDEBUG\"\nBSC32=bscmake.exe\n# ADD BASE BSC32 /nologo\n# ADD BSC32 /nologo\nLINK32=link.exe\n# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\n# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\n\n!ELSEIF  \"$(CFG)\" == \"benchmark - Win32 Debug\"\n\n# PROP BASE Use_MFC 0\n# PROP BASE Use_Debug_Libraries 1\n# PROP BASE Output_Dir \"benchmark___Win32_Debug\"\n# PROP BASE Intermediate_Dir \"benchmark___Win32_Debug\"\n# PROP BASE Target_Dir \"\"\n# PROP Use_MFC 0\n# PROP Use_Debug_Libraries 1\n# PROP Output_Dir \"Debug\"\n# PROP Intermediate_Dir \"Debug\"\n# PROP Target_Dir \"\"\n# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ /c\n# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I \"..\\include\" /I \"..\\mySTL\" /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ  /c\n# ADD BASE RSC /l 0x409 /d \"_DEBUG\"\n# ADD RSC /l 0x409 /d \"_DEBUG\"\nBSC32=bscmake.exe\n# ADD BASE BSC32 /nologo\n# ADD BSC32 /nologo\nLINK32=link.exe\n# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\n# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\n\n!ENDIF \n\n# Begin Target\n\n# Name \"benchmark - Win32 Release\"\n# Name \"benchmark - Win32 Debug\"\n# Begin Group \"Source Files\"\n\n# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\n# Begin Source File\n\nSOURCE=.\\benchmark.cpp\n# End Source File\n# End Group\n# Begin Group \"Header Files\"\n\n# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\n# End Group\n# Begin Group \"Resource Files\"\n\n# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\n# End Group\n# End Target\n# End Project\n"
  },
  {
    "path": "ext/yassl/taocrypt/benchmark/make.bat",
    "content": "REM Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.\nREM \nREM This program is free software; you can redistribute it and/or modify\nREM it under the terms of the GNU General Public License as published by\nREM the Free Software Foundation; version 2 of the License.\nREM \nREM This program is distributed in the hope that it will be useful,\nREM but WITHOUT ANY WARRANTY; without even the implied warranty of\nREM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nREM GNU General Public License for more details.\nREM \nREM You should have received a copy of the GNU General Public License\nREM along with this program; if not, write to the Free Software\nREM Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\n\nREM quick and dirty build file for testing different MSDEVs\nsetlocal \n\nset myFLAGS= /I../include /I../mySTL /c /W3 /G6 /O2\n\ncl %myFLAGS% benchmark.cpp\n\nlink.exe  /out:benchmark.exe ../src/taocrypt.lib benchmark.obj advapi32.lib\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/aes.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* aes.hpp defines AES\n*/\n\n\n#ifndef TAO_CRYPT_AES_HPP\n#define TAO_CRYPT_AES_HPP\n\n#include \"misc.hpp\"\n#include \"modes.hpp\"\n\n\n#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)\n    #define DO_AES_ASM\n#endif\n\n\n\nnamespace TaoCrypt {\n\n\nenum { AES_BLOCK_SIZE = 16 };\n\n\n// AES encryption and decryption, see FIPS-197\nclass AES : public Mode_BASE {\npublic:\n    enum { BLOCK_SIZE = AES_BLOCK_SIZE };\n\n    AES(CipherDir DIR, Mode MODE)\n        : Mode_BASE(BLOCK_SIZE, DIR, MODE) {}\n\n#ifdef DO_AES_ASM\n    void Process(byte*, const byte*, word32);\n#endif\n    void SetKey(const byte* key, word32 sz, CipherDir fake = ENCRYPTION);\n    void SetIV(const byte* iv) { memcpy(r_, iv, BLOCK_SIZE); }\nprivate:\n    static const word32 rcon_[];\n\n    word32      rounds_;\n    word32      key_[60];                        // max size\n\n    static const word32 Te[5][256];\n    static const word32 Td[5][256];\n\n    static const word32* Te0;\n    static const word32* Te1;\n    static const word32* Te2;\n    static const word32* Te3;\n    static const word32* Te4;\n\n    static const word32* Td0;\n    static const word32* Td1;\n    static const word32* Td2;\n    static const word32* Td3;\n    static const word32* Td4;\n\n    void encrypt(const byte*, const byte*, byte*) const;\n    void AsmEncrypt(const byte*, byte*, void*) const;\n    void decrypt(const byte*, const byte*, byte*) const;\n    void AsmDecrypt(const byte*, byte*, void*) const;\n\n    void ProcessAndXorBlock(const byte*, const byte*, byte*) const;\n\n    AES(const AES&);            // hide copy\n    AES& operator=(const AES&); // and assign\n};\n\n\ntypedef BlockCipher<ENCRYPTION, AES, ECB> AES_ECB_Encryption;\ntypedef BlockCipher<DECRYPTION, AES, ECB> AES_ECB_Decryption;\n\ntypedef BlockCipher<ENCRYPTION, AES, CBC> AES_CBC_Encryption;\ntypedef BlockCipher<DECRYPTION, AES, CBC> AES_CBC_Decryption;\n\n\n} // naemspace\n\n#endif // TAO_CRYPT_AES_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/algebra.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* based on Wei Dai's algebra.h from CryptoPP */\n\n#ifndef TAO_CRYPT_ALGEBRA_HPP\n#define TAO_CRYPT_ALGEBRA_HPP\n\n#include \"integer.hpp\"\n\nnamespace TaoCrypt {\n\n\n// \"const Element&\" returned by member functions are references\n// to internal data members. Since each object may have only\n// one such data member for holding results, the following code\n// will produce incorrect results:\n// abcd = group.Add(group.Add(a,b), group.Add(c,d));\n// But this should be fine:\n// abcd = group.Add(a, group.Add(b, group.Add(c,d));\n\n// Abstract Group\nclass TAOCRYPT_NO_VTABLE AbstractGroup : public virtual_base\n{\npublic:\n    typedef Integer Element;\n\n    virtual ~AbstractGroup() {}\n\n    virtual bool Equal(const Element &a, const Element &b) const =0;\n    virtual const Element& Identity() const =0;\n    virtual const Element& Add(const Element &a, const Element &b) const =0;\n    virtual const Element& Inverse(const Element &a) const =0;\n    virtual bool InversionIsFast() const {return false;}\n\n    virtual const Element& Double(const Element &a) const;\n    virtual const Element& Subtract(const Element &a, const Element &b) const;\n    virtual Element& Accumulate(Element &a, const Element &b) const;\n    virtual Element& Reduce(Element &a, const Element &b) const;\n\n    virtual Element ScalarMultiply(const Element &a, const Integer &e) const;\n    virtual Element CascadeScalarMultiply(const Element &x, const Integer &e1,\n                                    const Element &y, const Integer &e2) const;\n\n    virtual void SimultaneousMultiply(Element *results, const Element &base,\n                  const Integer *exponents, unsigned int exponentsCount) const;\n};\n\n// Abstract Ring\nclass TAOCRYPT_NO_VTABLE AbstractRing : public AbstractGroup\n{\npublic:\n    typedef Integer Element;\n\n    AbstractRing() : AbstractGroup() {m_mg.m_pRing = this;}\n    AbstractRing(const AbstractRing &source) : AbstractGroup()\n                                                {m_mg.m_pRing = this;}\n    AbstractRing& operator=(const AbstractRing &source) {return *this;}\n\n    virtual bool IsUnit(const Element &a) const =0;\n    virtual const Element& MultiplicativeIdentity() const =0;\n    virtual const Element& Multiply(const Element&, const Element&) const =0;\n    virtual const Element& MultiplicativeInverse(const Element &a) const =0;\n\n    virtual const Element& Square(const Element &a) const;\n    virtual const Element& Divide(const Element &a, const Element &b) const;\n\n    virtual Element Exponentiate(const Element &a, const Integer &e) const;\n    virtual Element CascadeExponentiate(const Element &x, const Integer &e1,\n                                    const Element &y, const Integer &e2) const;\n\n    virtual void SimultaneousExponentiate(Element *results, const Element&,\n                  const Integer *exponents, unsigned int exponentsCount) const;\n\n    virtual const AbstractGroup& MultiplicativeGroup() const\n        {return m_mg;}\n\nprivate:\n    class MultiplicativeGroupT : public AbstractGroup\n    {\n    public:\n        const AbstractRing& GetRing() const\n            {return *m_pRing;}\n\n        bool Equal(const Element &a, const Element &b) const\n            {return GetRing().Equal(a, b);}\n\n        const Element& Identity() const\n            {return GetRing().MultiplicativeIdentity();}\n\n        const Element& Add(const Element &a, const Element &b) const\n            {return GetRing().Multiply(a, b);}\n\n        Element& Accumulate(Element &a, const Element &b) const\n            {return a = GetRing().Multiply(a, b);}\n\n        const Element& Inverse(const Element &a) const\n            {return GetRing().MultiplicativeInverse(a);}\n\n        const Element& Subtract(const Element &a, const Element &b) const\n            {return GetRing().Divide(a, b);}\n\n        Element& Reduce(Element &a, const Element &b) const\n            {return a = GetRing().Divide(a, b);}\n\n        const Element& Double(const Element &a) const\n            {return GetRing().Square(a);}\n\n        Element ScalarMultiply(const Element &a, const Integer &e) const\n            {return GetRing().Exponentiate(a, e);}\n\n        Element CascadeScalarMultiply(const Element &x, const Integer &e1,\n                                     const Element &y, const Integer &e2) const\n            {return GetRing().CascadeExponentiate(x, e1, y, e2);}\n\n        void SimultaneousMultiply(Element *results, const Element &base,\n                   const Integer *exponents, unsigned int exponentsCount) const\n            {GetRing().SimultaneousExponentiate(results, base, exponents,\n                                                exponentsCount);}\n\n        const AbstractRing* m_pRing;\n    };\n\n    MultiplicativeGroupT m_mg;\n};\n\n\n// Abstract Euclidean Domain\nclass TAOCRYPT_NO_VTABLE AbstractEuclideanDomain\n    : public AbstractRing\n{\npublic:\n    typedef Integer Element;\n\n    virtual void DivisionAlgorithm(Element &r, Element &q, const Element &a,\n                                   const Element &d) const =0;\n\n    virtual const Element& Mod(const Element &a, const Element &b) const =0;\n    virtual const Element& Gcd(const Element &a, const Element &b) const;\n\nprotected:\n    mutable Element result;\n};\n\n\n// EuclideanDomainOf\nclass EuclideanDomainOf : public AbstractEuclideanDomain\n{\npublic:\n    typedef Integer Element;\n\n    EuclideanDomainOf() {}\n\n    bool Equal(const Element &a, const Element &b) const\n        {return a==b;}\n\n    const Element& Identity() const\n        {return Element::Zero();}\n\n    const Element& Add(const Element &a, const Element &b) const\n        {return result = a+b;}\n\n    Element& Accumulate(Element &a, const Element &b) const\n        {return a+=b;}\n\n    const Element& Inverse(const Element &a) const\n        {return result = -a;}\n\n    const Element& Subtract(const Element &a, const Element &b) const\n        {return result = a-b;}\n\n    Element& Reduce(Element &a, const Element &b) const\n        {return a-=b;}\n\n    const Element& Double(const Element &a) const\n        {return result = a.Doubled();}\n\n    const Element& MultiplicativeIdentity() const\n        {return Element::One();}\n\n    const Element& Multiply(const Element &a, const Element &b) const\n        {return result = a*b;}\n\n    const Element& Square(const Element &a) const\n        {return result = a.Squared();}\n\n    bool IsUnit(const Element &a) const\n        {return a.IsUnit();}\n\n    const Element& MultiplicativeInverse(const Element &a) const\n        {return result = a.MultiplicativeInverse();}\n\n    const Element& Divide(const Element &a, const Element &b) const\n        {return result = a/b;}\n\n    const Element& Mod(const Element &a, const Element &b) const\n        {return result = a%b;}\n\n    void DivisionAlgorithm(Element &r, Element &q, const Element &a,\n                           const Element &d) const\n        {Element::Divide(r, q, a, d);}\n\nprivate:\n    mutable Element result;\n};\n\n\n\n} // namespace\n\n#endif // TAO_CRYPT_ALGEBRA_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/arc4.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* arc4.hpp defines ARC4\n*/\n\n\n#ifndef TAO_CRYPT_ARC4_HPP\n#define TAO_CRYPT_ARC4_HPP\n\n#include \"misc.hpp\"\n\nnamespace TaoCrypt {\n\n\n// ARC4 encryption and decryption\nclass ARC4 {\npublic:\n    enum { STATE_SIZE = 256 };\n\n    typedef ARC4 Encryption;\n    typedef ARC4 Decryption;\n\n    ARC4() {}\n\n    void Process(byte*, const byte*, word32);\n    void SetKey(const byte*, word32);\nprivate:\n    byte x_;\n    byte y_;\n    byte state_[STATE_SIZE];\n\n    ARC4(const ARC4&);                  // hide copy\n    const ARC4 operator=(const ARC4&);  // and assign\n\n    void AsmProcess(byte*, const byte*, word32);\n};\n\n} // namespace\n\n\n#endif // TAO_CRYPT_ARC4_HPP\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/asn.hpp",
    "content": "/*\n   Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* asn.hpp provides ASN1 BER, PublicKey, and x509v3 decoding \n*/\n\n\n#ifndef TAO_CRYPT_ASN_HPP\n#define TAO_CRYPT_ASN_HPP\n\n\n#include <time.h>\n#include \"misc.hpp\"\n#include \"block.hpp\"\n#include \"error.hpp\"\n#ifdef USE_SYS_STL\n    #include <list>\n#else\n    #include \"list.hpp\"\n#endif\n\n\nnamespace STL = STL_NAMESPACE;\n\n\nnamespace TaoCrypt {\n\n// these tags and flags are not complete\nenum ASNTag\n{\n    BOOLEAN             = 0x01,\n    INTEGER             = 0x02,\n    BIT_STRING          = 0x03,\n    OCTET_STRING        = 0x04,\n    TAG_NULL            = 0x05,\n    OBJECT_IDENTIFIER   = 0x06,\n    OBJECT_DESCRIPTOR   = 0x07,\n    EXTERNAL            = 0x08,\n    REAL                = 0x09,\n    ENUMERATED          = 0x0a,\n    UTF8_STRING         = 0x0c,\n    SEQUENCE            = 0x10,\n    SET                 = 0x11,\n    NUMERIC_STRING      = 0x12,\n    PRINTABLE_STRING    = 0x13,\n    T61_STRING          = 0x14,\n    VIDEOTEXT_STRING    = 0x15,\n    IA5_STRING          = 0x16,\n    UTC_TIME            = 0x17,\n    GENERALIZED_TIME    = 0x18,\n    GRAPHIC_STRING      = 0x19,\n    VISIBLE_STRING      = 0x1a,\n    GENERAL_STRING      = 0x1b,\n    LONG_LENGTH         = 0x80\n};\n\nenum ASNIdFlag\n{\n    UNIVERSAL           = 0x00,\n    DATA                = 0x01,\n    HEADER              = 0x02,\n    CONSTRUCTED         = 0x20,\n    APPLICATION         = 0x40,\n    CONTEXT_SPECIFIC    = 0x80,\n    PRIVATE             = 0xc0\n};\n\n\nenum DNTags\n{\n    COMMON_NAME         = 0x03,  // CN\n    SUR_NAME            = 0x04,  // SN\n    COUNTRY_NAME        = 0x06,  // C\n    LOCALITY_NAME       = 0x07,  // L\n    STATE_NAME          = 0x08,  // ST\n    ORG_NAME            = 0x0a,  // O\n    ORGUNIT_NAME        = 0x0b   // OU\n};\n\n\nenum PCKS12_Tags\n{\n    /* DATA                      = 1, */ // from ASN1\n    SIGNED_DATA               = 2,\n    ENVELOPED_DATA            = 3,\n    SIGNED_AND_ENVELOPED_DATA = 4,\n    DIGESTED_DATA             = 5,\n    ENCRYPTED_DATA            = 6\n};\n\n\nenum Constants\n{\n    MIN_DATE_SZ   = 13,\n    MAX_DATE_SZ   = 16,\n    MAX_ALGO_SZ   = 16,\n    MAX_LENGTH_SZ =  5,    \n    MAX_SEQ_SZ    =  5,    // enum(seq|con) + length(4)\n    MAX_ALGO_SIZE =  9,\n    MAX_DIGEST_SZ = 69,    // SHA512 + enum(Bit or Octet) + length(4)\n    DSA_SIG_SZ    = 40,\n    ASN_NAME_MAX  = 512    // max total of all included names\n};\n\n\nclass Source;\nclass RSA_PublicKey;\nclass RSA_PrivateKey;\nclass DSA_PublicKey;\nclass DSA_PrivateKey;\nclass Integer;\nclass DH;\n\n\n// General BER decoding\nclass BER_Decoder : public virtual_base {\nprotected:\n    Source& source_;\npublic:\n    explicit BER_Decoder(Source& s) : source_(s) {}\n    virtual ~BER_Decoder() {}\n\n    Integer& GetInteger(Integer&);\n    word32   GetSequence();\n    word32   GetSet();\n    word32   GetVersion();\n    word32   GetExplicitVersion();\n\n    Error GetError();\nprivate:\n    virtual void ReadHeader() = 0;\n\n    BER_Decoder(const BER_Decoder&);            // hide copy\n    BER_Decoder& operator=(const BER_Decoder&); // and assign\n};\n\n\n// RSA Private Key BER Decoder\nclass RSA_Private_Decoder : public BER_Decoder {\npublic:\n    explicit RSA_Private_Decoder(Source& s) : BER_Decoder(s) {}\n    void Decode(RSA_PrivateKey&);\nprivate:\n    void ReadHeader();\n};\n\n\n// RSA Public Key BER Decoder\nclass RSA_Public_Decoder : public BER_Decoder {\npublic:\n    explicit RSA_Public_Decoder(Source& s) : BER_Decoder(s) {}\n    void Decode(RSA_PublicKey&);\nprivate:\n    void ReadHeader();\n    void ReadHeaderOpenSSL();\n};\n\n\n// DSA Private Key BER Decoder\nclass DSA_Private_Decoder : public BER_Decoder {\npublic:\n    explicit DSA_Private_Decoder(Source& s) : BER_Decoder(s) {}\n    void Decode(DSA_PrivateKey&);\nprivate:\n    void ReadHeader();\n};\n\n\n// DSA Public Key BER Decoder\nclass DSA_Public_Decoder : public BER_Decoder {\npublic:\n    explicit DSA_Public_Decoder(Source& s) : BER_Decoder(s) {}\n    void Decode(DSA_PublicKey&);\nprivate:\n    void ReadHeader();\n};\n\n\n// DH Key BER Decoder\nclass DH_Decoder : public BER_Decoder {\npublic:\n    explicit DH_Decoder(Source& s) : BER_Decoder(s) {}\n    void Decode(DH&);\nprivate:\n    void ReadHeader();\n};\n\n\n// PKCS12 BER Decoder\nclass PKCS12_Decoder : public BER_Decoder {\npublic:\n    explicit PKCS12_Decoder(Source& s) : BER_Decoder(s) {}\n    void Decode();\nprivate:\n    void ReadHeader();\n};\n\n\n// General PublicKey\nclass PublicKey {\n    byte*  key_;\n    word32 sz_;\npublic:\n    explicit PublicKey(const byte* k = 0, word32 s = 0);\n    ~PublicKey() { tcArrayDelete(key_); }\n\n    const byte* GetKey() const { return key_; }\n    word32      size()   const { return sz_; }\n\n    void SetKey(const byte*);\n    void SetSize(word32 s);\n\n    void AddToEnd(const byte*, word32);\nprivate:\n    PublicKey(const PublicKey&);            // hide copy\n    PublicKey& operator=(const PublicKey&); // and assign\n};\n\n\nenum { SHA_SIZE = 20 };\n\n\n// A Signing Authority\nclass Signer {\n    PublicKey key_;\n    char      name_[ASN_NAME_MAX];\n    byte      hash_[SHA_SIZE];\npublic:\n    Signer(const byte* k, word32 kSz, const char* n, const byte* h);\n    ~Signer();\n\n    const PublicKey& GetPublicKey()  const { return key_; }\n    const char*      GetName()       const { return name_; }\n    const byte*      GetHash()       const { return hash_; }\n\nprivate:\n    Signer(const Signer&);              // hide copy\n    Signer& operator=(const Signer&);   // and assign\n};\n\n\ntypedef STL::list<Signer*> SignerList;\n\n\nenum ContentType { HUH = 651 };\nenum SigType  { SHAwDSA = 517, MD2wRSA = 646, MD5wRSA = 648, SHAwRSA = 649,\n                SHA256wRSA = 655, SHA384wRSA = 656, SHA512wRSA = 657,\n                SHA256wDSA = 416 };\nenum HashType { MD2h = 646, MD5h = 649, SHAh = 88, SHA256h = 414, SHA384h = 415,\n                SHA512h = 416 };\nenum KeyType  { DSAk = 515, RSAk = 645 };     // sums of algo OID\n\n\n// an x509v Certificate BER Decoder\nclass CertDecoder : public BER_Decoder {\npublic:\n    enum DateType { BEFORE, AFTER };   \n    enum NameType { ISSUER, SUBJECT };\n    enum CertType { CA, USER };\n\n    explicit CertDecoder(Source&, bool decode = true, SignerList* sl = 0,\n                         bool noVerify = false, CertType ct = USER);\n    ~CertDecoder();\n\n    const PublicKey& GetPublicKey()  const { return key_; }\n    KeyType          GetKeyType()    const { return KeyType(keyOID_); }\n    const char*      GetIssuer()     const { return issuer_; }\n    const char*      GetCommonName() const { return subject_; }\n    const byte*      GetHash()       const { return subjectHash_; }\n    const char*      GetBeforeDate() const { return beforeDate_; }\n    byte             GetBeforeDateType() const { return beforeDateType_; }\n    const char*      GetAfterDate()  const { return afterDate_; }\n    byte             GetAfterDateType() const { return afterDateType_; }\n\n    void DecodeToKey();\nprivate:\n    PublicKey key_;\n    word32    certBegin_;               // offset to start of cert\n    word32    sigIndex_;                // offset to start of signature\n    word32    sigLength_;               // length of signature\n    word32    signatureOID_;            // sum of algorithm object id\n    word32    keyOID_;                  // sum of key algo  object id\n    byte      subjectHash_[SHA_SIZE];   // hash of all Names\n    byte      issuerHash_[SHA_SIZE];    // hash of all Names\n    byte*     signature_;\n    char      issuer_[ASN_NAME_MAX];    // Names\n    char      subject_[ASN_NAME_MAX];   // Names\n    char      beforeDate_[MAX_DATE_SZ+1]; // valid before date, +null term\n    byte      beforeDateType_;            // beforeDate time type\n    char      afterDate_[MAX_DATE_SZ+1];  // valid after date, +null term\n    byte      afterDateType_;             // afterDate time type\n    bool      verify_;                    // Default to yes, but could be off\n\n    void   ReadHeader();\n    void   Decode(SignerList*, CertType);\n    void   StoreKey();\n    void   AddDSA();\n    bool   ValidateSelfSignature();\n    bool   ValidateSignature(SignerList*);\n    bool   ConfirmSignature(Source&);\n    void   GetKey();\n    char*  AddTag(char*, const char*, const char*, word32, word32);\n    void   GetName(NameType);\n    void   GetValidity();\n    void   GetDate(DateType);\n    void   GetCompareHash(const byte*, word32, byte*, word32);\n    word32 GetAlgoId();\n    word32 GetSignature();\n    word32 GetDigest();\n};\n\n\nword32 GetLength(Source&);\n\nword32 SetLength(word32, byte*);\nword32 SetSequence(word32, byte*);\n\nword32 EncodeDSA_Signature(const byte* signature, byte* output);\nword32 EncodeDSA_Signature(const Integer& r, const Integer& s, byte* output);\nword32 DecodeDSA_Signature(byte* decoded, const byte* encoded, word32 sz);\n\n\n// General DER encoding\nclass DER_Encoder : public virtual_base {\npublic:\n    DER_Encoder() {}\n    virtual ~DER_Encoder() {}\n\n    word32 SetAlgoID(HashType, byte*);\n\n    Error  GetError() const { return error_; }\nprivate:\n    //virtual void WriteHeader() = 0;\n    Error error_;\n\n    DER_Encoder(const DER_Encoder&);            // hide copy\n    DER_Encoder& operator=(const DER_Encoder&); // and assign\n};\n\n\n\nclass Signature_Encoder : public DER_Encoder {\n    const byte* digest_;\n    word32      digestSz_;\n    SigType     digestOID_;\npublic:\n    explicit Signature_Encoder(const byte*, word32, HashType, Source&);\n\nprivate:\n    void   WriteHeader();\n    word32 SetDigest(const byte*, word32, byte*);\n\n    Signature_Encoder(const Signature_Encoder&);            // hide copy\n    Signature_Encoder& operator=(const Signature_Encoder&); // and assign\n};\n\n\n// Get Cert in PEM format from BEGIN to END\nint GetCert(Source&);\n\n// Get Cert in PEM format from pkcs12 file\nint GetPKCS_Cert(const char* password, Source&);\n\nbool ASN1_TIME_extract(const unsigned char* date, unsigned char format,\n                       tm *parsed_time);\n\n} // namespace\n\n\n#endif // TAO_CRYPT_ASN_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/block.hpp",
    "content": "/*\n   Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* block.hpp provides word and byte blocks with configurable allocators\n*/\n\n\n#ifndef TAO_CRYPT_BLOCK_HPP\n#define TAO_CRYPT_BLOCK_HPP\n\n#include \"misc.hpp\"\n#include <string.h>         // memcpy\n#include <stddef.h>         // ptrdiff_t\n\n#ifdef USE_SYS_STL\n    #include <algorithm>\n#else\n    #include \"algorithm.hpp\"\n#endif\n\n\nnamespace STL = STL_NAMESPACE;\n\n\nnamespace TaoCrypt {\n\n\n// a Base class for Allocators\ntemplate<class T>\nclass AllocatorBase\n{\npublic:\n    typedef T         value_type;\n    typedef size_t    size_type;\n    typedef ptrdiff_t difference_type;\n    typedef T*        pointer;\n    typedef const T*  const_pointer;\n    typedef T&        reference;\n    typedef const T&  const_reference;\n\n    pointer       address(reference r) const {return (&r);}\n    const_pointer address(const_reference r) const {return (&r); }\n    void          construct(pointer p, const T& val) {new (p) T(val);}\n    void          destroy(pointer p) {p->~T();}\n    size_type     max_size() const {return ~size_type(0)/sizeof(T);}\nprotected:\n};\n\n\n// General purpose realloc\ntemplate<typename T, class A>\ntypename A::pointer StdReallocate(A& a, T* p, typename A::size_type oldSize,\n                                  typename A::size_type newSize, bool preserve)\n{\n    if (oldSize == newSize)\n        return p;\n\n    if (preserve) {\n        A b = A();\n        typename A::pointer newPointer = b.allocate(newSize, 0);\n        memcpy(newPointer, p, sizeof(T) * min(oldSize, newSize));\n        a.deallocate(p, oldSize);\n        STL::swap(a, b);\n        return newPointer;\n    }\n    else {\n        a.deallocate(p, oldSize);\n        return a.allocate(newSize, 0);\n    }\n}\n\n\n// Allocator that zeros out memory on deletion\ntemplate <class T>\nclass AllocatorWithCleanup : public AllocatorBase<T>\n{\npublic:\n    typedef typename AllocatorBase<T>::pointer   pointer;\n    typedef typename AllocatorBase<T>::size_type size_type;\n\n    pointer allocate(size_type n, const void* = 0)\n    {\n        if (n > this->max_size())\n            return 0;\n        if (n == 0)\n            return 0;\n        return NEW_TC T[n];\n    }\n\n    void deallocate(void* p, size_type n)\n    {\n        memset(p, 0, n * sizeof(T));\n        tcArrayDelete((T*)p);\n    }\n\n    pointer reallocate(T* p, size_type oldSize, size_type newSize,\n                       bool preserve)\n    {\n        return StdReallocate(*this, p, oldSize, newSize, preserve);\n    }\n\n    // VS.NET STL enforces the policy of \"All STL-compliant allocators have to\n    // provide a template class member called rebind\".\n    template <class U> struct rebind { typedef AllocatorWithCleanup<U> other;};\n};\n\n\n// Block class template\ntemplate<typename T, class A = AllocatorWithCleanup<T> >\nclass Block {\npublic:\n    explicit Block(word32 s = 0) : sz_(s), buffer_(allocator_.allocate(sz_)) \n                    { CleanNew(sz_); }\n\n    Block(const T* buff, word32 s) : sz_(s), buffer_(allocator_.allocate(sz_))\n        { memcpy(buffer_, buff, sz_ * sizeof(T)); }\n\n    Block(const Block& that) : sz_(that.sz_), buffer_(allocator_.allocate(sz_))\n        { memcpy(buffer_, that.buffer_, sz_ * sizeof(T)); }\n\n    Block& operator=(const Block& that) {\n        Block tmp(that);\n        Swap(tmp);\n        return *this;\n    }\n\n    T& operator[] (word32 i) { return buffer_[i]; }\n    const T& operator[] (word32 i) const { return buffer_[i]; }\n\n    T* operator+ (word32 i) { return buffer_ + i; }\n    const T* operator+ (word32 i) const { return buffer_ + i; }\n\n    word32 size() const { return sz_; }\n\n    T* get_buffer() const { return buffer_; }\n    T* begin()      const { return get_buffer(); }\n\n    void CleanGrow(word32 newSize)\n    {\n        if (newSize > sz_) {\n            buffer_ = allocator_.reallocate(buffer_, sz_, newSize, true);\n            memset(buffer_ + sz_, 0, (newSize - sz_) * sizeof(T));\n            sz_ = newSize;\n        }\n    }\n\n    void CleanNew(word32 newSize)\n    {\n        New(newSize);\n        memset(buffer_, 0, sz_ * sizeof(T));\n    }\n\n    void New(word32 newSize)\n    {\n        buffer_ = allocator_.reallocate(buffer_, sz_, newSize, false);\n        sz_ = newSize;\n    }\n\n    void resize(word32 newSize)\n    {\n        buffer_ = allocator_.reallocate(buffer_, sz_, newSize, true);\n        sz_ = newSize;\n    }\n\n    void Swap(Block& other) {\n        STL::swap(sz_, other.sz_);\n        STL::swap(buffer_, other.buffer_);\n        STL::swap(allocator_, other.allocator_);\n    }\n\n    ~Block() { allocator_.deallocate(buffer_, sz_); }\nprivate:\n    A      allocator_;\n    word32 sz_;     // size in Ts\n    T*     buffer_;\n};\n\n\ntypedef Block<byte>   ByteBlock;\ntypedef Block<word>   WordBlock;\ntypedef Block<word32> Word32Block;\n\n\n} // namespace\n\n#endif // TAO_CRYPT_BLOCK_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/blowfish.hpp",
    "content": "/*\n   Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* blowfish.hpp defines Blowfish\n*/\n\n\n#ifndef TAO_CRYPT_BLOWFISH_HPP\n#define TAO_CRYPT_BLOWFISH_HPP\n\n#include \"misc.hpp\"\n#include \"modes.hpp\"\n#ifdef USE_SYS_STL\n    #include <algorithm>\n#else\n    #include \"algorithm.hpp\"\n#endif\n\n\nnamespace STL = STL_NAMESPACE;\n\n\n#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)\n    #define DO_BLOWFISH_ASM\n#endif\n\n\nnamespace TaoCrypt {\n\nenum { BLOWFISH_BLOCK_SIZE = 8 };\n\n\n// Blowfish encryption and decryption, see \nclass Blowfish : public Mode_BASE {\npublic:\n    enum { BLOCK_SIZE = BLOWFISH_BLOCK_SIZE, ROUNDS = 16 };\n\n    Blowfish(CipherDir DIR, Mode MODE)\n        : Mode_BASE(BLOCK_SIZE, DIR, MODE), sbox_(pbox_ + ROUNDS + 2) {}\n\n#ifdef DO_BLOWFISH_ASM\n    void Process(byte*, const byte*, word32);\n#endif\n    void SetKey(const byte* key, word32 sz, CipherDir fake = ENCRYPTION);\n    void SetIV(const byte* iv) { memcpy(r_, iv, BLOCK_SIZE); }\nprivate:\n    static const word32 p_init_[ROUNDS + 2];\n    static const word32 s_init_[4 * 256];\n\n    word32 pbox_[ROUNDS + 2 + 4 * 256];\n    word32* sbox_;\n\n    void crypt_block(const word32 in[2], word32 out[2]) const;\n    void AsmProcess(const byte* in, byte* out) const;\n    void ProcessAndXorBlock(const byte*, const byte*, byte*) const;\n\n    Blowfish(const Blowfish&);            // hide copy\n    Blowfish& operator=(const Blowfish&); // and assign\n};\n\n\ntypedef BlockCipher<ENCRYPTION, Blowfish, ECB> Blowfish_ECB_Encryption;\ntypedef BlockCipher<DECRYPTION, Blowfish, ECB> Blowfish_ECB_Decryption;\n\ntypedef BlockCipher<ENCRYPTION, Blowfish, CBC> Blowfish_CBC_Encryption;\ntypedef BlockCipher<DECRYPTION, Blowfish, CBC> Blowfish_CBC_Decryption;\n\n\n\n} // namespace\n\n#endif // TAO_CRYPT_BLOWFISH_HPP\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/coding.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* coding.hpp defines hex and base64 encoding/decoing\n*/\n\n#ifndef TAO_CRYPT_CODING_HPP\n#define TAO_CRYPT_CODING_HPP\n\n#include \"misc.hpp\"\n#include \"block.hpp\"\n\nnamespace TaoCrypt {\n\nclass Source;\n\n\n// Hex Encoding, see RFC 3548\nclass HexEncoder {\n    ByteBlock encoded_;\n    Source&     plain_;\npublic:\n    explicit HexEncoder(Source& s) : plain_(s) { Encode(); }\nprivate:\n    void Encode();\n\n    HexEncoder(const HexEncoder&);              // hide copy\n    HexEncoder& operator=(const HexEncoder&);   // and assign\n};\n\n\n// Hex Decoding, see RFC 3548\nclass HexDecoder {\n    ByteBlock decoded_;\n    Source&     coded_;\npublic:\n    explicit HexDecoder(Source& s) : coded_(s) { Decode(); }\nprivate:\n    void Decode();\n\n    HexDecoder(const HexDecoder&);              // hide copy\n    HexDecoder& operator=(const HexDecoder&);   // and assign\n};\n\n\n// Base 64 encoding, see RFC 3548\nclass Base64Encoder {\n    ByteBlock encoded_;\n    Source&     plain_;\npublic:\n    explicit Base64Encoder(Source& s) : plain_(s) { Encode(); }\nprivate:\n    void Encode();\n\n    Base64Encoder(const Base64Encoder&);              // hide copy\n    Base64Encoder& operator=(const Base64Encoder&);   // and assign\n};\n\n\n// Base 64 decoding, see RFC 3548\nclass Base64Decoder {\n    ByteBlock decoded_;\n    Source&     coded_;\npublic:\n    explicit Base64Decoder(Source& s) : coded_(s) { Decode(); }\nprivate:\n    void Decode();\n\n    Base64Decoder(const Base64Decoder&);              // hide copy\n    Base64Decoder& operator=(const Base64Decoder&);   // and assign\n};\n\n\n}  // namespace\n\n#endif // TAO_CRYPT_CODING_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/des.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* des.hpp defines DES, DES_EDE2, and DES_EDE3\n   see FIPS 46-2 and FIPS 81\n*/\n\n\n#ifndef TAO_CRYPT_DES_HPP\n#define TAO_CRYPT_DES_HPP\n\n#include \"misc.hpp\"\n#include \"modes.hpp\"\n\n\n#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)\n    #define DO_DES_ASM\n#endif\n\n\nnamespace TaoCrypt {\n\n\nenum { DES_BLOCK_SIZE = 8, DES_KEY_SIZE = 32 };\n\n\nclass BasicDES {\npublic:\n    void SetKey(const byte*, word32, CipherDir dir);\n    void RawProcessBlock(word32&, word32&) const;\nprotected:\n    word32 k_[DES_KEY_SIZE];\n};\n\n\n// DES \nclass DES : public Mode_BASE, public BasicDES {\npublic:\n    DES(CipherDir DIR, Mode MODE) \n        : Mode_BASE(DES_BLOCK_SIZE, DIR, MODE) {}\n\nprivate:\n    void ProcessAndXorBlock(const byte*, const byte*, byte*) const;\n\n    DES(const DES&);              // hide copy\n    DES& operator=(const DES&);   // and assign\n};\n\n\n// DES_EDE2\nclass DES_EDE2 : public Mode_BASE {\npublic:\n    DES_EDE2(CipherDir DIR, Mode MODE) \n        : Mode_BASE(DES_BLOCK_SIZE, DIR, MODE) {}\n\n    void SetKey(const byte*, word32, CipherDir dir);\nprivate:\n    BasicDES  des1_;\n    BasicDES  des2_;\n\n    void ProcessAndXorBlock(const byte*, const byte*, byte*) const;\n\n    DES_EDE2(const DES_EDE2&);              // hide copy\n    DES_EDE2& operator=(const DES_EDE2&);   // and assign\n};\n\n\n\n// DES_EDE3\nclass DES_EDE3 : public Mode_BASE {\npublic:\n    DES_EDE3(CipherDir DIR, Mode MODE)\n        : Mode_BASE(DES_BLOCK_SIZE, DIR, MODE) {}\n\n    void SetKey(const byte*, word32, CipherDir dir);\n    void SetIV(const byte* iv) { memcpy(r_, iv, DES_BLOCK_SIZE); }\n#ifdef DO_DES_ASM\n    void Process(byte*, const byte*, word32);\n#endif\nprivate:\n    BasicDES  des1_;\n    BasicDES  des2_;\n    BasicDES  des3_;\n\n    void AsmProcess(const byte* in, byte* out, void* box) const;\n    void ProcessAndXorBlock(const byte*, const byte*, byte*) const;\n\n    DES_EDE3(const DES_EDE3&);              // hide copy\n    DES_EDE3& operator=(const DES_EDE3&);   // and assign\n};\n\n\ntypedef BlockCipher<ENCRYPTION, DES, ECB> DES_ECB_Encryption;\ntypedef BlockCipher<DECRYPTION, DES, ECB> DES_ECB_Decryption;\n\ntypedef BlockCipher<ENCRYPTION, DES, CBC> DES_CBC_Encryption;\ntypedef BlockCipher<DECRYPTION, DES, CBC> DES_CBC_Decryption;\n\ntypedef BlockCipher<ENCRYPTION, DES_EDE2, ECB> DES_EDE2_ECB_Encryption;\ntypedef BlockCipher<DECRYPTION, DES_EDE2, ECB> DES_EDE2_ECB_Decryption;\n\ntypedef BlockCipher<ENCRYPTION, DES_EDE2, CBC> DES_EDE2_CBC_Encryption;\ntypedef BlockCipher<DECRYPTION, DES_EDE2, CBC> DES_EDE2_CBC_Decryption;\n\ntypedef BlockCipher<ENCRYPTION, DES_EDE3, ECB> DES_EDE3_ECB_Encryption;\ntypedef BlockCipher<DECRYPTION, DES_EDE3, ECB> DES_EDE3_ECB_Decryption;\n\ntypedef BlockCipher<ENCRYPTION, DES_EDE3, CBC> DES_EDE3_CBC_Encryption;\ntypedef BlockCipher<DECRYPTION, DES_EDE3, CBC> DES_EDE3_CBC_Decryption;\n\n\n} // namespace\n\n\n#endif // TAO_CRYPT_DES_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/dh.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* dh.hpp provides Diffie-Hellman support\n*/\n\n\n#ifndef TAO_CRYPT_DH_HPP\n#define TAO_CRYPT_DH_HPP\n\n#include \"misc.hpp\"\n#include \"integer.hpp\"\n\nnamespace TaoCrypt {\n\n\nclass Source;\n\n\n// Diffie-Hellman\nclass DH {\npublic:\n    DH() {}\n    DH(Integer& p, Integer& g) : p_(p), g_(g) {}\n    explicit DH(Source&);\n\n    DH(const DH& that) : p_(that.p_), g_(that.g_) {}\n    DH& operator=(const DH& that) \n    {\n        DH tmp(that);\n        Swap(tmp);\n        return *this;\n    }\n\n    void Swap(DH& other)\n    {\n        p_.Swap(other.p_);\n        g_.Swap(other.g_);\n    }\n\n    void Initialize(Source&);\n    void Initialize(Integer& p, Integer& g)\n    {\n        SetP(p);\n        SetG(g);\n    }\n\n    void GenerateKeyPair(RandomNumberGenerator&, byte*, byte*);\n    void Agree(byte*, const byte*, const byte*, word32 otherSz = 0);\n\n    void SetP(const Integer& p) { p_ = p; }\n    void SetG(const Integer& g) { g_ = g; }\n\n    Integer& GetP() { return p_; }\n    Integer& GetG() { return g_; }\n\n    // for p and agree\n    word32 GetByteLength() const { return p_.ByteCount(); }\nprivate:\n    // group parms\n    Integer p_;\n    Integer g_;\n\n    void GeneratePrivate(RandomNumberGenerator&, byte*);\n    void GeneratePublic(const byte*, byte*);    \n};\n\n\n} // namespace\n\n#endif // TAO_CRYPT_DH_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/dsa.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* dsa.hpp provides Digitial Signautre Algorithm see FIPS 186-2\n*/\n\n#ifndef TAO_CRYPT_DSA_HPP\n#define TAO_CRYPT_DSA_HPP\n\n#include \"integer.hpp\"\n\n\nnamespace TaoCrypt {\n\nclass Source;\n\n\nclass DSA_PublicKey {\nprotected:\n    Integer p_;\n    Integer q_;\n    Integer g_;\n    Integer y_;\npublic:\n    DSA_PublicKey() {}\n    explicit DSA_PublicKey(Source&);\n\n    void Initialize(Source&);\n    void Initialize(const Integer& p, const Integer& q, const Integer& g,\n                    const Integer& y);\n    \n    const Integer& GetModulus() const;\n    const Integer& GetSubGroupOrder() const;\n    const Integer& GetSubGroupGenerator() const;\n    const Integer& GetPublicPart() const;\n\n    void SetModulus(const Integer&);\n    void SetSubGroupOrder(const Integer&);\n    void SetSubGroupGenerator(const Integer&);\n    void SetPublicPart(const Integer&);\n\n    word32 SignatureLength() const;\n \n    DSA_PublicKey(const DSA_PublicKey&);\n    DSA_PublicKey& operator=(const DSA_PublicKey&);\n\n    void Swap(DSA_PublicKey& other);\n};\n\n\n\nclass DSA_PrivateKey : public DSA_PublicKey {\n    Integer x_;\npublic:\n    DSA_PrivateKey() {}\n    explicit DSA_PrivateKey(Source&);\n\n    void Initialize(Source&);\n    void Initialize(const Integer& p, const Integer& q, const Integer& g,\n                    const Integer& y, const Integer& x);\n    \n    const Integer& GetPrivatePart() const;\n\n    void SetPrivatePart(const Integer&);\nprivate:\n    DSA_PrivateKey(const DSA_PrivateKey&);            // hide copy\n    DSA_PrivateKey& operator=(const DSA_PrivateKey&); // and assign\n};\n\n\n\nclass DSA_Signer {\n    const DSA_PrivateKey& key_;\n    Integer               r_;\n    Integer               s_;\npublic:\n    explicit DSA_Signer(const DSA_PrivateKey&);\n\n    word32 Sign(const byte* sha_digest, byte* sig, RandomNumberGenerator&);\n\n    const Integer& GetR() const;\n    const Integer& GetS() const;\nprivate:\n    DSA_Signer(const DSA_Signer&);      // hide copy\n    DSA_Signer& operator=(DSA_Signer&); // and assign\n};\n\n\nclass DSA_Verifier {\n    const DSA_PublicKey& key_;\n    Integer              r_;\n    Integer              s_;\npublic:\n    explicit DSA_Verifier(const DSA_PublicKey&);\n\n    bool Verify(const byte* sha_digest, const byte* sig);\n\n    const Integer& GetR() const;\n    const Integer& GetS() const;\nprivate:\n    DSA_Verifier(const DSA_Verifier&);              // hide copy\n    DSA_Verifier& operator=(const DSA_Verifier&);   // and assign\n};\n\n\n\n\n\n} // namespace\n\n#endif // TAO_CRYPT_DSA_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/error.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* error.hpp provides a taocrypt error numbers\n *\n */\n\n\n#ifndef TAO_CRYPT_ERROR_HPP\n#define TAO_CRYPT_ERROR_HPP\n\n\nnamespace TaoCrypt {\n\n\nenum ErrorNumber {\n\nNO_ERROR_E   =    0, // \"not in error state\"\n\n// RandomNumberGenerator\nWINCRYPT_E      = 1001, // \"bad wincrypt acquire\"\nCRYPTGEN_E      = 1002, // \"CryptGenRandom error\"\nOPEN_RAN_E      = 1003, // \"open /dev/urandom error\"\nREAD_RAN_E      = 1004, // \"read /dev/urandom error\"\n\n// Integer\nINTEGER_E       = 1010, // \"bad DER Integer Header\"\n\n\n// ASN.1\nSEQUENCE_E      = 1020, // \"bad Sequence Header\"\nSET_E           = 1021, // \"bad Set Header\"\nVERSION_E       = 1022, // \"version length not 1\"\nSIG_OID_E       = 1023, // \"signature OID mismatch\"\nBIT_STR_E       = 1024, // \"bad BitString Header\"\nUNKNOWN_OID_E   = 1025, // \"unknown key OID type\"\nOBJECT_ID_E     = 1026, // \"bad Ojbect ID Header\"\nTAG_NULL_E      = 1027, // \"expected TAG NULL\"\nEXPECT_0_E      = 1028, // \"expected 0\"\nOCTET_STR_E     = 1029, // \"bad Octet String Header\"\nTIME_E          = 1030, // \"bad TIME\"\n\nDATE_SZ_E       = 1031, // \"bad Date Size\"\nSIG_LEN_E       = 1032, // \"bad Signature Length\"\nUNKOWN_SIG_E    = 1033, // \"unknown signature OID\"\nUNKOWN_HASH_E   = 1034, // \"unknown hash OID\"\nDSA_SZ_E        = 1035, // \"bad DSA r or s size\"\nBEFORE_DATE_E   = 1036, // \"before date in the future\"\nAFTER_DATE_E    = 1037, // \"after date in the past\"\nSIG_CONFIRM_E   = 1038, // \"bad self  signature confirmation\"\nSIG_OTHER_E     = 1039, // \"bad other signature confirmation\"\n\nCONTENT_E       = 1040, // \"bad content processing\"\nPEM_E           = 1041  // \"bad pem format error\"\n\n    //  add error string to yassl/src/yassl_error.cpp !!! \n};\n\n\nstruct Error {\n    ErrorNumber  what_;    // description number, 0 for no error\n\n    explicit Error(ErrorNumber w = NO_ERROR_E) : what_(w) {}\n\n    ErrorNumber What()            const  { return what_; }\n    void        SetError(ErrorNumber w)  { what_ = w; }\n};\n\n\n\n} // namespace TaoCrypt\n\n#endif // TAO_CRYPT_ERROR_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/file.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* file.hpp provies File Sources and Sinks\n*/\n\n\n#ifndef TAO_CRYPT_FILE_HPP\n#define TAO_CRYPT_FILE_HPP\n\n#include \"misc.hpp\"\n#include \"block.hpp\"\n#include \"error.hpp\"\n#include <stdio.h>\n\nnamespace TaoCrypt {\n\n\nclass Source {\n    ByteBlock buffer_;\n    word32    current_;\n    Error     error_;\npublic:\n    explicit Source(word32 sz = 0) : buffer_(sz), current_(0) {}\n    Source(const byte* b, word32 sz) : buffer_(b, sz), current_(0) {}\n\n    word32 remaining()         { if (GetError().What()) return 0;\n                                 else return buffer_.size() - current_; } \n    word32 size() const        { return buffer_.size(); }\n    void   grow(word32 sz)     { buffer_.CleanGrow(sz); }\n\n    bool IsLeft(word32 sz) { if (remaining() >= sz) return true;\n                             else { SetError(CONTENT_E); return false; } }\n   \n    const byte*  get_buffer()  const { return buffer_.get_buffer(); }\n    const byte*  get_current() const { return &buffer_[current_]; }\n    word32       get_index()   const { return current_; }\n    void         set_index(word32 i) { if (i < size()) current_ = i; }\n\n    byte operator[] (word32 i) { current_ = i; return next(); }\n    byte next() { if (IsLeft(1)) return buffer_[current_++]; else return 0; }\n    byte prev() { if (current_)  return buffer_[--current_]; else return 0; }\n\n    void add(const byte* data, word32 len)\n    {\n        if (IsLeft(len)) {\n            memcpy(buffer_.get_buffer() + current_, data, len);\n            current_ += len;\n        }\n    }\n\n    void advance(word32 i) { if (IsLeft(i)) current_ += i; }\n    void reset(ByteBlock&);\n\n    Error  GetError()              { return error_; }\n    void   SetError(ErrorNumber w) { error_.SetError(w); }\n\n    friend class FileSource;  // for get()\n\n    Source(const Source& that)\n        : buffer_(that.buffer_), current_(that.current_) {}\n\n    Source& operator=(const Source& that)\n    {\n        Source tmp(that);\n        Swap(tmp);\n        return *this;\n    }\n\n    void Swap(Source& other) \n    {\n        buffer_.Swap(other.buffer_);\n        STL::swap(current_, other.current_);\n    }\n\n};\n\n\n// File Source\nclass FileSource {\n    FILE* file_;\npublic:\n    FileSource(const char* fname, Source& source);\n    ~FileSource();\n   \n    word32   size(bool use_current = false);\nprivate:\n    word32   get(Source&);\n    word32   size_left();                     \n\n    FileSource(const FileSource&);            // hide\n    FileSource& operator=(const FileSource&); // hide\n};\n\n\n// File Sink\nclass FileSink {\n    FILE* file_;\npublic:\n    FileSink(const char* fname, Source& source);\n    ~FileSink();\n\n    word32 size(bool use_current = false);\nprivate:\n    void put(Source&);\n\n    FileSink(const FileSink&);            // hide\n    FileSink& operator=(const FileSink&); // hide\n};\n\n\n\n} // namespace\n\n#endif // TAO_CRYPT_FILE_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/hash.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* hash.hpp provides a base for digest types\n*/\n\n\n#ifndef TAO_CRYPT_HASH_HPP\n#define TAO_CRYPT_HASH_HPP\n\n#include \"misc.hpp\"\n\nnamespace TaoCrypt {\n\n\n// HASH\nclass HASH : public virtual_base {\npublic:\n    virtual ~HASH() {}\n\n    virtual void Update(const byte*, word32) = 0;\n    virtual void Final(byte*)                = 0;\n\n    virtual void Init() = 0;\n\n    virtual word32 getBlockSize()  const = 0;\n    virtual word32 getDigestSize() const = 0;\n};\n\n\n// HASH with Transform\nclass HASHwithTransform : public HASH {\npublic:\n    HASHwithTransform(word32 digSz, word32 buffSz);\n    virtual ~HASHwithTransform() {}\n    virtual ByteOrder getByteOrder()  const = 0;\n    virtual word32    getPadSize()    const = 0;\n\n    virtual void Update(const byte*, word32);\n    virtual void Final(byte*);\n\n    word32  GetBitCountLo() const { return  loLen_ << 3; }\n    word32  GetBitCountHi() const { return (loLen_ >> (8*sizeof(loLen_) - 3)) +\n                                           (hiLen_ << 3); } \n    enum { MaxDigestSz = 8, MaxBufferSz = 64 };\nprotected:\n    typedef word32 HashLengthType;\n    word32          buffLen_;   // in bytes\n    HashLengthType  loLen_;     // length in bytes\n    HashLengthType  hiLen_;     // length in bytes\n    word32          digest_[MaxDigestSz];\n    word32          buffer_[MaxBufferSz / sizeof(word32)];\n\n    virtual void Transform() = 0;\n\n    void AddLength(word32);\n};\n\n\n#ifdef WORD64_AVAILABLE\n\n// 64-bit HASH with Transform\nclass HASH64withTransform : public HASH {\npublic:\n    HASH64withTransform(word32 digSz, word32 buffSz);\n    virtual ~HASH64withTransform() {}\n    virtual ByteOrder getByteOrder()  const = 0;\n    virtual word32    getPadSize()    const = 0;\n\n    virtual void Update(const byte*, word32);\n    virtual void Final(byte*);\n\n    word32  GetBitCountLo() const { return  loLen_ << 3; }\n    word32  GetBitCountHi() const { return (loLen_ >> (8*sizeof(loLen_) - 3)) +\n                                           (hiLen_ << 3); } \n    enum { MaxDigestSz = 8, MaxBufferSz = 128 };\nprotected:\n    typedef word32 HashLengthType;\n    word32          buffLen_;   // in bytes\n    HashLengthType  loLen_;     // length in bytes\n    HashLengthType  hiLen_;     // length in bytes\n    word64          digest_[MaxDigestSz];\n    word64          buffer_[MaxBufferSz / sizeof(word64)];\n\n    virtual void Transform() = 0;\n\n    void AddLength(word32);\n};\n\n#endif // WORD64_AVAILABLE\n\n\n} // namespace\n\n#endif // TAO_CRYPT_HASH_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/hc128.hpp",
    "content": "/*\n   Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* hc128.hpp defines HC128\n*/\n\n\n#ifndef TAO_CRYPT_HC128_HPP\n#define TAO_CRYPT_HC128_HPP\n\n#include \"misc.hpp\"\n\nnamespace TaoCrypt {\n\n\n// HC128 encryption and decryption\nclass HC128 {\npublic:\n\n    typedef HC128 Encryption;\n    typedef HC128 Decryption;\n\n\n    HC128() {}\n\n    void Process(byte*, const byte*, word32);\n    void SetKey(const byte*, const byte*);\nprivate:\n    word32 T_[1024];             /* P[i] = T[i];  Q[i] = T[1024 + i ]; */\n    word32 X_[16];\n    word32 Y_[16];\n    word32 counter1024_;         /* counter1024 = i mod 1024 at the ith step */\n    word32 key_[8];\n    word32 iv_[8];\n\n    void SetIV(const byte*);\n    void GenerateKeystream(word32*);\n    void SetupUpdate();\n\n    HC128(const HC128&);                  // hide copy\n    const HC128 operator=(const HC128&);  // and assign\n};\n\n} // namespace\n\n\n#endif // TAO_CRYPT_HC128_HPP\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/hmac.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* hamc.hpp implements HMAC, see RFC 2104\n*/\n\n\n#ifndef TAO_CRYPT_HMAC_HPP\n#define TAO_CRYPT_HMAC_HPP\n\n#include \"hash.hpp\"\n\nnamespace TaoCrypt {\n\n\n// HMAC class template\ntemplate <class T>\nclass HMAC {\npublic:\n    enum { IPAD = 0x36, OPAD = 0x5C };\n\n    HMAC() : ipad_(reinterpret_cast<byte*>(&ip_)), \n             opad_(reinterpret_cast<byte*>(&op_)),\n             innerHash_(reinterpret_cast<byte*>(&innerH_)) \n    { \n        Init(); \n    }\n    void Update(const byte*, word32);\n    void Final(byte*);\n    void Init();\n\n    void SetKey(const byte*, word32);\nprivate:\n    byte* ipad_;\n    byte* opad_;\n    byte* innerHash_;\n    bool  innerHashKeyed_;\n    T     mac_;\n\n    // MSVC 6 HACK, gives compiler error if calculated in array\n    enum { HMAC_BSIZE = T::BLOCK_SIZE  / sizeof(word32),\n           HMAC_DSIZE = T::DIGEST_SIZE / sizeof(word32) };\n\n    word32 ip_[HMAC_BSIZE];          // align ipad_ on word32\n    word32 op_[HMAC_BSIZE];          // align opad_ on word32\n    word32 innerH_[HMAC_DSIZE];      // align innerHash_ on word32\n\n    void KeyInnerHash();\n\n    HMAC(const HMAC&);\n    HMAC& operator= (const HMAC&);\n};\n\n\n// Setup\ntemplate <class T>\nvoid HMAC<T>::Init()\n{\n    mac_.Init();\n    innerHashKeyed_ = false;\n}\n\n\n// Key generation\ntemplate <class T>\nvoid HMAC<T>::SetKey(const byte* key, word32 length)\n{\n    Init();\n\n    if (length <= T::BLOCK_SIZE)\n        memcpy(ipad_, key, length);\n    else {\n        mac_.Update(key, length);\n        mac_.Final(ipad_);\n        length = T::DIGEST_SIZE;\n    }\n    memset(ipad_ + length, 0, T::BLOCK_SIZE - length);\n\n    for (word32 i = 0; i < T::BLOCK_SIZE; i++) {\n        opad_[i] = ipad_[i] ^ OPAD;\n        ipad_[i] ^= IPAD;\n    }\n}\n\n\n// Inner Key Hash\ntemplate <class T>\nvoid HMAC<T>::KeyInnerHash()\n{\n    mac_.Update(ipad_, T::BLOCK_SIZE);\n    innerHashKeyed_ = true;\n}\n\n\n// Update\ntemplate <class T>\nvoid HMAC<T>::Update(const byte* msg, word32 length)\n{\n    if (!innerHashKeyed_)\n        KeyInnerHash();\n    mac_.Update(msg, length);\n}\n\n\n// Final\ntemplate <class T>\nvoid HMAC<T>::Final(byte* hash)\n{\n    if (!innerHashKeyed_)\n        KeyInnerHash();\n    mac_.Final(innerHash_);\n\n    mac_.Update(opad_, T::BLOCK_SIZE);\n    mac_.Update(innerHash_, T::DIGEST_SIZE);\n    mac_.Final(hash);\n\n    innerHashKeyed_ = false;\n}\n\n\n} // namespace\n\n#endif // TAO_CRYPT_HMAC_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/integer.hpp",
    "content": "/*\n   Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* based on Wei Dai's integer.h from CryptoPP */\n\n\n#ifndef TAO_CRYPT_INTEGER_HPP\n#define TAO_CRYPT_INTEGER_HPP\n\n\n#ifdef _MSC_VER\n    // 4250: dominance\n    // 4660: explicitly instantiating a class already implicitly instantiated\n    // 4661: no suitable definition provided for explicit template request\n    // 4786: identifer was truncated in debug information\n    // 4355: 'this' : used in base member initializer list\n#   pragma warning(disable: 4250 4660 4661 4786 4355)\n#endif\n\n\n#include \"misc.hpp\"\n#include \"block.hpp\"\n#include \"random.hpp\"\n#include \"file.hpp\"\n#include <string.h>\n#ifdef USE_SYS_STL\n    #include <algorithm>\n#else\n    #include \"algorithm.hpp\"\n#endif\n\n\n#ifdef TAOCRYPT_X86ASM_AVAILABLE\n    #if defined(__GNUC__) && (__GNUC__ >= 4)\n        // GCC 4 or greater optimizes too much inline on recursive for bigint, \n        // -O3 just as fast without asm here anyway\n        #undef TAOCRYPT_X86ASM_AVAILABLE\n    #endif\n#endif\n\n#ifdef TAOCRYPT_X86ASM_AVAILABLE\n\n#ifdef _M_IX86\n    #if (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 500)) || \\\n      (defined(__ICL) && (__ICL >= 500))\n        #define SSE2_INTRINSICS_AVAILABLE\n        #define TAOCRYPT_MM_MALLOC_AVAILABLE\n    #elif defined(_MSC_VER)\n        // _mm_free seems to be the only way to tell if the Processor Pack is\n        //installed or not\n        #include <malloc.h>\n        #if defined(_mm_free)\n            #define SSE2_INTRINSICS_AVAILABLE\n            #define TAOCRYPT_MM_MALLOC_AVAILABLE\n        #endif\n    #endif\n#endif\n\n// SSE2 intrinsics work in GCC 3.3 or later\n#if defined(__SSE2__) && (__GNUC__ == 4 || __GNUC_MAJOR__ > 3 ||  \\\n                          __GNUC_MINOR__ > 2)\n    #define SSE2_INTRINSICS_AVAILABLE\n#endif\n\n#endif  // X86ASM\n\n\n\n\nnamespace TaoCrypt {\n\n#if defined(SSE2_INTRINSICS_AVAILABLE)\n\n    // Allocator handling proper alignment\n    template <class T>\n    class AlignedAllocator : public AllocatorBase<T>\n    {\n    public:\n        typedef typename AllocatorBase<T>::pointer   pointer;\n        typedef typename AllocatorBase<T>::size_type size_type;\n\n        pointer allocate(size_type n, const void* = 0);\n        void deallocate(void* p, size_type n);\n        pointer reallocate(T* p, size_type oldSize, size_type newSize,\n                           bool preserve)\n        {\n            return StdReallocate(*this, p, oldSize, newSize, preserve);\n        }\n\n    #if !(defined(TAOCRYPT_MALLOC_ALIGNMENT_IS_16) || \\\n        defined(TAOCRYPT_MEMALIGN_AVAILABLE) || \\\n        defined(TAOCRYPT_MM_MALLOC_AVAILABLE))\n    #define TAOCRYPT_NO_ALIGNED_ALLOC\n        AlignedAllocator() : m_pBlock(0) {}\n    protected:\n        void *m_pBlock;\n    #endif\n    };\n\n    typedef Block<word, AlignedAllocator<word> > AlignedWordBlock;\n#else\n    typedef WordBlock AlignedWordBlock;\n#endif\n\n\n// general MAX\ntemplate<typename T> inline\nconst T& max(const T& a, const T& b)\n{\n    return a > b ? a : b;\n}\n\n\n// Large Integer class\nclass Integer {\npublic:\n        enum Sign {POSITIVE = 0, NEGATIVE = 1 };\n        enum Signedness { UNSIGNED, SIGNED };\n        enum RandomNumberType { ANY, PRIME };\n\n        class DivideByZero {};\n\n        Integer();\n        Integer(const Integer& t);\n        Integer(signed long value);\n        Integer(Sign s, word highWord, word lowWord);\n\n        // BER Decode Source\n        explicit Integer(Source&);\n\n        Integer(const byte* encodedInteger, unsigned int byteCount,\n                Signedness s = UNSIGNED);\n\n        ~Integer() {}\n      \n        static const Integer& Zero();\n        static const Integer& One();\n\n        Integer& Ref() { return *this; }\n\n        Integer(RandomNumberGenerator& rng, const Integer& min,\n                const Integer& max);\n\n        static Integer Power2(unsigned int e);\n\n        unsigned int MinEncodedSize(Signedness = UNSIGNED) const;\n        unsigned int Encode(byte* output, unsigned int outputLen,\n                            Signedness = UNSIGNED) const;\n\n        void Decode(const byte* input, unsigned int inputLen,\n                    Signedness = UNSIGNED);\n        void Decode(Source&);\n\n        bool  IsConvertableToLong() const;\n        signed long ConvertToLong() const;\n\n        unsigned int BitCount() const;\n        unsigned int ByteCount() const;\n        unsigned int WordCount() const;\n\n        bool GetBit(unsigned int i) const;\n        byte GetByte(unsigned int i) const;\n        unsigned long GetBits(unsigned int i, unsigned int n) const;\n\n        bool IsZero()      const { return !*this; }\n        bool NotZero()     const { return !IsZero(); }\n        bool IsNegative()  const { return sign_ == NEGATIVE; }\n        bool NotNegative() const { return !IsNegative(); }\n        bool IsPositive()  const { return NotNegative() && NotZero(); }\n        bool NotPositive() const { return !IsPositive(); }\n        bool IsEven()      const { return GetBit(0) == 0; }\n        bool IsOdd()       const { return GetBit(0) == 1; }\n\n        Integer&  operator=(const Integer& t);\n        Integer&  operator+=(const Integer& t);\n        Integer&  operator-=(const Integer& t);\n        Integer&  operator*=(const Integer& t)\t{ return *this = Times(t); }\n        Integer&  operator/=(const Integer& t)\t\n                        { return *this = DividedBy(t);}\n        Integer&  operator%=(const Integer& t)\t{ return *this = Modulo(t); }\n        Integer&  operator/=(word t)  { return *this = DividedBy(t); }\n        Integer&  operator%=(word t)  { return *this = Modulo(t); }\n        Integer&  operator<<=(unsigned int);\n        Integer&  operator>>=(unsigned int);\n\n     \n        void Randomize(RandomNumberGenerator &rng, unsigned int bitcount);\n        void Randomize(RandomNumberGenerator &rng, const Integer &min,\n                       const Integer &max);\n\n        void SetBit(unsigned int n, bool value = 1);\n        void SetByte(unsigned int n, byte value);\n\n        void Negate();\t\t\n        void SetPositive() { sign_ = POSITIVE; }\n        void SetNegative() { if (!!(*this)) sign_ = NEGATIVE; }\n        void Swap(Integer& a);\n\n        bool\t    operator!() const;\n        Integer     operator+() const {return *this;}\n        Integer     operator-() const;\n        Integer&    operator++();\n        Integer&    operator--();\n        Integer     operator++(int) \n            { Integer temp = *this; ++*this; return temp; }\n        Integer     operator--(int) \n            { Integer temp = *this; --*this; return temp; }\n\n        int Compare(const Integer& a) const;\n\n        Integer Plus(const Integer &b) const;\n        Integer Minus(const Integer &b) const;\n        Integer Times(const Integer &b) const;\n        Integer DividedBy(const Integer &b) const;\n        Integer Modulo(const Integer &b) const;\n        Integer DividedBy(word b) const;\n        word    Modulo(word b) const;\n\n        Integer operator>>(unsigned int n) const { return Integer(*this)>>=n; }\n        Integer operator<<(unsigned int n) const { return Integer(*this)<<=n; }\n\n        Integer AbsoluteValue() const;\n        Integer Doubled() const { return Plus(*this); }\n        Integer Squared() const { return Times(*this); }\n        Integer SquareRoot() const;\n\n        bool    IsSquare() const;\n        bool    IsUnit() const;\n\n        Integer MultiplicativeInverse() const;\n\n        friend Integer a_times_b_mod_c(const Integer& x, const Integer& y,\n                                       const Integer& m);\n        friend Integer a_exp_b_mod_c(const Integer& x, const Integer& e,\n                                     const Integer& m);\n\n        static void Divide(Integer& r, Integer& q, const Integer& a,\n                           const Integer& d);\n        static void Divide(word& r, Integer& q, const Integer& a, word d);\n        static void DivideByPowerOf2(Integer& r, Integer& q, const Integer& a,\n                                     unsigned int n);\n        static Integer Gcd(const Integer& a, const Integer& n);\n\n        Integer InverseMod(const Integer& n) const;\n        word InverseMod(word n) const;\n\nprivate:\n    friend class ModularArithmetic;\n    friend class MontgomeryRepresentation;\n\n    Integer(word value, unsigned int length);\n    int PositiveCompare(const Integer& t) const;\n\n    friend void PositiveAdd(Integer& sum, const Integer& a, const Integer& b);\n    friend void PositiveSubtract(Integer& diff, const Integer& a,\n                                 const Integer& b);\n    friend void PositiveMultiply(Integer& product, const Integer& a,\n                                 const Integer& b);\n    friend void PositiveDivide(Integer& remainder, Integer& quotient, const\n                               Integer& dividend, const Integer& divisor);\n    AlignedWordBlock reg_;\n    Sign             sign_;\n};\n\ninline bool operator==(const Integer& a, const Integer& b) \n                        {return a.Compare(b)==0;}\ninline bool operator!=(const Integer& a, const Integer& b) \n                        {return a.Compare(b)!=0;}\ninline bool operator> (const Integer& a, const Integer& b) \n                        {return a.Compare(b)> 0;}\ninline bool operator>=(const Integer& a, const Integer& b) \n                        {return a.Compare(b)>=0;}\ninline bool operator< (const Integer& a, const Integer& b) \n                        {return a.Compare(b)< 0;}\ninline bool operator<=(const Integer& a, const Integer& b) \n                        {return a.Compare(b)<=0;}\n\ninline Integer operator+(const Integer &a, const Integer &b) \n                        {return a.Plus(b);}\ninline Integer operator-(const Integer &a, const Integer &b) \n                        {return a.Minus(b);}\ninline Integer operator*(const Integer &a, const Integer &b) \n                        {return a.Times(b);}\ninline Integer operator/(const Integer &a, const Integer &b) \n                        {return a.DividedBy(b);}\ninline Integer operator%(const Integer &a, const Integer &b) \n                        {return a.Modulo(b);}\ninline Integer operator/(const Integer &a, word b) {return a.DividedBy(b);}\ninline word    operator%(const Integer &a, word b) {return a.Modulo(b);}\n\ninline void swap(Integer &a, Integer &b)\n{\n    a.Swap(b);\n}\n\n\nInteger CRT(const Integer& xp, const Integer& p, const Integer& xq,\n            const Integer& q,  const Integer& u);\n\ninline Integer ModularExponentiation(const Integer& a, const Integer& e,\n                                     const Integer& m)\n{\n    return a_exp_b_mod_c(a, e, m);\n}\n\nInteger ModularRoot(const Integer& a, const Integer& dp, const Integer& dq,\n                    const Integer& p, const Integer& q,  const Integer& u);\n\n\n\n}   // namespace\n\n#endif // TAO_CRYPT_INTEGER_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/kernelc.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* kernelc.hpp provides support for C std lib when compiled in kernel mode\n*/\n\n#ifndef TAOCRYPT_KERNELC_HPP\n#define TAOCRYPT_KERNELC_HPP\n\n#include <linux/types.h>   // get right size_t\n\n// system functions that c++ doesn't like headers for \n\nextern \"C\" void* memcpy(void*, const void*, size_t);\nextern \"C\" void* memset(void*, int, size_t);\nextern \"C\" void  printk(char *fmt, ...);\n\n\n#endif // TAOCRYPT_KERNELC_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/md2.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* md2.hpp provides MD2 digest support, see RFC 1319\n*/\n\n#ifndef TAO_CRYPT_MD2_HPP\n#define TAO_CRYPT_MD2_HPP\n\n\n#include \"hash.hpp\"\n#include \"block.hpp\"\n\n\nnamespace TaoCrypt {\n\n\n// MD2 digest\nclass MD2 : public HASH {\npublic:\n    enum { BLOCK_SIZE = 16, DIGEST_SIZE = 16, PAD_SIZE = 16, X_SIZE = 48 };\n    MD2();\n\n    word32 getBlockSize()  const { return BLOCK_SIZE; }\n    word32 getDigestSize() const { return DIGEST_SIZE; }\n\n    void Update(const byte*, word32);\n    void Final(byte*);\n\n    void Init();\n    void Swap(MD2&);\nprivate:\n    ByteBlock X_, C_, buffer_;\n    word32    count_;           // bytes % PAD_SIZE\n\n    MD2(const MD2&);\n    MD2& operator=(const MD2&);\n};\n\ninline void swap(MD2& a, MD2& b)\n{\n    a.Swap(b);\n}\n\n\n} // namespace\n\n#endif // TAO_CRYPT_MD2_HPP\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/md4.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* md4.hpp provides MD4 digest support\n * WANRING: MD4 is considered insecure, only use if you have to, e.g., yaSSL\n * libcurl supports needs this for NTLM authentication\n*/\n\n#ifndef TAO_CRYPT_MD4_HPP\n#define TAO_CRYPT_MD4_HPP\n\n#include \"hash.hpp\"\n\nnamespace TaoCrypt {\n\n\n// MD4 digest\nclass MD4 : public HASHwithTransform {\npublic:\n    enum { BLOCK_SIZE = 64, DIGEST_SIZE = 16, PAD_SIZE = 56,\n           TAO_BYTE_ORDER = LittleEndianOrder };   // in Bytes\n    MD4() : HASHwithTransform(DIGEST_SIZE / sizeof(word32), BLOCK_SIZE) \n                { Init(); }\n    ByteOrder getByteOrder()  const { return ByteOrder(TAO_BYTE_ORDER); }\n    word32    getBlockSize()  const { return BLOCK_SIZE; }\n    word32    getDigestSize() const { return DIGEST_SIZE; }\n    word32    getPadSize()    const { return PAD_SIZE; }\n\n    MD4(const MD4&);\n    MD4& operator= (const MD4&);\n\n    void Init();\n    void Swap(MD4&);\nprivate:\n    void Transform();\n};\n\ninline void swap(MD4& a, MD4& b)\n{\n    a.Swap(b);\n}\n\n\n} // namespace\n\n#endif // TAO_CRYPT_MD4_HPP\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/md5.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* md5.hpp provides MD5 digest support, see RFC 1321\n*/\n\n#ifndef TAO_CRYPT_MD5_HPP\n#define TAO_CRYPT_MD5_HPP\n\n#include \"hash.hpp\"\n\n\n#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)\n    #define DO_MD5_ASM\n#endif\n\nnamespace TaoCrypt {\n\n\n// MD5 digest\nclass MD5 : public HASHwithTransform {\npublic:\n    enum { BLOCK_SIZE = 64, DIGEST_SIZE = 16, PAD_SIZE = 56,\n           TAO_BYTE_ORDER = LittleEndianOrder };   // in Bytes\n    MD5() : HASHwithTransform(DIGEST_SIZE / sizeof(word32), BLOCK_SIZE) \n                { Init(); }\n    ByteOrder getByteOrder()  const { return ByteOrder(TAO_BYTE_ORDER); }\n    word32    getBlockSize()  const { return BLOCK_SIZE; }\n    word32    getDigestSize() const { return DIGEST_SIZE; }\n    word32    getPadSize()    const { return PAD_SIZE; }\n\n    MD5(const MD5&);\n    MD5& operator= (const MD5&);\n\n#ifdef DO_MD5_ASM\n    void Update(const byte*, word32);\n#endif\n\n    void Init();\n    void Swap(MD5&);\nprivate:\n    void Transform();\n    void AsmTransform(const byte* data, word32 times);\n};\n\ninline void swap(MD5& a, MD5& b)\n{\n    a.Swap(b);\n}\n\n\n} // namespace\n\n#endif // TAO_CRYPT_MD5_HPP\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/misc.hpp",
    "content": "/*\n   Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* based on Wei Dai's misc.h from CryptoPP */\n\n#ifndef TAO_CRYPT_MISC_HPP\n#define TAO_CRYPT_MISC_HPP\n\n\n#if !defined(DO_TAOCRYPT_KERNEL_MODE)\n    #include <stdlib.h>\n    #include <string.h>\n#else\n    #include \"kernelc.hpp\"\n#endif\n\n#include \"types.hpp\"\n#include \"type_traits.hpp\"\n\n\n\nnamespace TaoCrypt {\n\n\n// Delete static singleton holders\nvoid CleanUp();\n\n\n#ifdef YASSL_PURE_C\n\n    // library allocation\n    struct new_t {};      // TaoCrypt New type\n    extern new_t tc;      // pass in parameter\n\n    } // namespace TaoCrypt\n\n    void* operator new  (size_t, TaoCrypt::new_t);\n    void* operator new[](size_t, TaoCrypt::new_t);\n\n    void operator delete  (void*, TaoCrypt::new_t);\n    void operator delete[](void*, TaoCrypt::new_t);\n\n\n    namespace TaoCrypt {\n\n    template<typename T>\n    void tcDelete(T* ptr)\n    {\n        if (ptr) ptr->~T();\n        ::operator delete(ptr, TaoCrypt::tc);\n    }\n\n    template<typename T>\n    void tcArrayDelete(T* ptr)\n    {\n        // can't do array placement destruction since not tracking size in\n        // allocation, only allow builtins to use array placement since they\n        // don't need destructors called\n        typedef char builtin[IsFundamentalType<T>::Yes ? 1 : -1];\n        (void)sizeof(builtin);\n\n        ::operator delete[](ptr, TaoCrypt::tc);\n    }\n\n    #define NEW_TC new (TaoCrypt::tc)\n\n\n    // to resolve compiler generated operator delete on base classes with\n    // virtual destructors (when on stack)\n    class virtual_base {\n    public:\n        static void operator delete(void*) { }\n    };\n\n#else // YASSL_PURE_C\n\n\n    template<typename T>\n    void tcDelete(T* ptr)\n    {\n        delete ptr;\n    }\n\n    template<typename T>\n    void tcArrayDelete(T* ptr)\n    {\n        delete[] ptr;\n    }\n\n    #define NEW_TC new\n\n    class virtual_base {};\n   \n \n#endif // YASSL_PURE_C\n\n\n#if defined(_MSC_VER) || defined(__BCPLUSPLUS__)\n\t#define INTEL_INTRINSICS\n\t#define FAST_ROTATE\n#elif defined(__MWERKS__) && TARGET_CPU_PPC\n\t#define PPC_INTRINSICS\n\t#define FAST_ROTATE\n#elif defined(__GNUC__) && defined(__i386__)\n        // GCC does peephole optimizations which should result in using rotate\n        // instructions\n\t#define FAST_ROTATE\n#endif\n\n\n// no gas on these systems ?, disable for now\n#if defined(__sun__)\n    #undef  TAOCRYPT_DISABLE_X86ASM\n    #define TAOCRYPT_DISABLE_X86ASM\n#endif\n\n// icc problem with -03 and integer, disable for now\n#if defined(__INTEL_COMPILER)\n    #undef  TAOCRYPT_DISABLE_X86ASM\n    #define TAOCRYPT_DISABLE_X86ASM\n#endif\n\n// indpedent of build system, unless ia32 asm is enabled disable it\n#if !defined(TAOCRYPT_ENABLE_X86ASM)\n    #undef  TAOCRYPT_DISABLE_X86ASM\n    #define TAOCRYPT_DISABLE_X86ASM\n#endif\n\n// Turn on ia32 ASM for Big Integer\n// CodeWarrior defines _MSC_VER\n#if !defined(TAOCRYPT_DISABLE_X86ASM) && ((defined(_MSC_VER) && \\\n   !defined(__MWERKS__) && defined(_M_IX86)) || \\\n   (defined(__GNUC__) && defined(__i386__)))\n    #define TAOCRYPT_X86ASM_AVAILABLE\n#endif\n\n\n#ifdef TAOCRYPT_X86ASM_AVAILABLE\n    bool HaveCpuId();\n    bool IsPentium();\n    void CpuId(word32 input, word32 *output);\n\n    extern bool isMMX;\n#endif\n\n\n\n\n// Turn on ia32 ASM for Ciphers and Message Digests\n// Seperate define since these are more complex, use member offsets\n// and user may want to turn off while leaving Big Integer optos on \n#if defined(TAOCRYPT_X86ASM_AVAILABLE) && !defined(DISABLE_TAO_ASM)\n    #define TAO_ASM\n#endif\n\n\n//  Extra word in older vtable implementations, for ASM member offset\n#if defined(__GNUC__) && __GNUC__ < 3\n    #define OLD_GCC_OFFSET\n#endif\n\n\n#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)\n#\tdefine TAOCRYPT_MALLOC_ALIGNMENT_IS_16\n#endif\n\n#if defined(__linux__) || defined(__sun__)\n#\tdefine TAOCRYPT_MEMALIGN_AVAILABLE\n#endif\n\n\n#if defined(_WIN32)\n    #define TAOCRYPT_WIN32_AVAILABLE\n#endif\n\n#if defined(__unix__) || defined(__MACH__)\n    #define TAOCRYPT_UNIX_AVAILABLE\n#endif\n\n\n// VC60 workaround: it doesn't allow typename in some places\n#if defined(_MSC_VER) && (_MSC_VER < 1300)\n    #define CPP_TYPENAME\n#else\n    #define CPP_TYPENAME typename\n#endif\n\n\n#ifdef _MSC_VER\n    #define TAOCRYPT_NO_VTABLE __declspec(novtable)\n#else\n    #define TAOCRYPT_NO_VTABLE\n#endif\n\n\n#ifdef USE_SYS_STL\n    // use system STL\n    #define STL_NAMESPACE       std\n#else\n    // use mySTL\n    #define STL_NAMESPACE       mySTL\n#endif\n\n\n// ***************** DLL related ********************\n\n#ifdef TAOCRYPT_WIN32_AVAILABLE\n\n#ifdef TAOCRYPT_EXPORTS\n    #define TAOCRYPT_IS_DLL\n    #define TAOCRYPT_DLL __declspec(dllexport)\n#elif defined(TAOCRYPT_IMPORTS)\n    #define TAOCRYPT_IS_DLL\n    #define TAOCRYPT_DLL __declspec(dllimport)\n#else\n    #define TAOCRYPT_DLL\n#endif  // EXPORTS\n\n#define TAOCRYPT_API __stdcall\n#define TAOCRYPT_CDECL __cdecl\n\n#else\t// TAOCRYPT_WIN32_AVAILABLE\n\n#define TAOCRYPT_DLL\n#define TAOCRYPT_API\n#define TAOCRYPT_CDECL\n\n#endif\t// TAOCRYPT_WIN32_AVAILABLE\n\n\n// ****************** tempalte stuff *******************\n\n\n#if defined(TAOCRYPT_MANUALLY_INSTANTIATE_TEMPLATES) && \\\n  !defined(TAOCRYPT_IMPORTS)\n    #define TAOCRYPT_DLL_TEMPLATE_CLASS template class TAOCRYPT_DLL\n#elif defined(__MWERKS__)\n    #define TAOCRYPT_DLL_TEMPLATE_CLASS extern class TAOCRYPT_DLL\n#else\n    #define TAOCRYPT_DLL_TEMPLATE_CLASS extern template class TAOCRYPT_DLL\n#endif\n\n\n#if defined(TAOCRYPT_MANUALLY_INSTANTIATE_TEMPLATES) && \\\n  !defined(TAOCRYPT_EXPORTS)\n    #define TAOCRYPT_STATIC_TEMPLATE_CLASS template class\n#elif defined(__MWERKS__)\n    #define TAOCRYPT_STATIC_TEMPLATE_CLASS extern class\n#else\n    #define TAOCRYPT_STATIC_TEMPLATE_CLASS extern template class\n#endif\n\n\n// ************** compile-time assertion ***************\n\ntemplate <bool b>\nstruct CompileAssert\n{\n\tstatic char dummy[2*b-1];\n};\n\n#define TAOCRYPT_COMPILE_ASSERT(assertion) \\\n    TAOCRYPT_COMPILE_ASSERT_INSTANCE(assertion, __LINE__)\n\n#if defined(TAOCRYPT_EXPORTS) || defined(TAOCRYPT_IMPORTS)\n    #define TAOCRYPT_COMPILE_ASSERT_INSTANCE(assertion, instance)\n#else\n    #define TAOCRYPT_COMPILE_ASSERT_INSTANCE(assertion, instance) \\\n    (void)sizeof(CompileAssert<(assertion)>)\n#endif\n\n#define TAOCRYPT_ASSERT_JOIN(X, Y) TAOCRYPT_DO_ASSERT_JOIN(X, Y)\n\n#define TAOCRYPT_DO_ASSERT_JOIN(X, Y) X##Y\n\n\n/***************  helpers  *****************************/\n\ninline unsigned int BitsToBytes(unsigned int bitCount)\n{\n    return ((bitCount+7)/(8));\n}\n\ninline unsigned int BytesToWords(unsigned int byteCount)\n{\n    return ((byteCount+WORD_SIZE-1)/WORD_SIZE);\n}\n\ninline unsigned int BitsToWords(unsigned int bitCount)\n{\n    return ((bitCount+WORD_BITS-1)/(WORD_BITS));\n}\n\ninline void CopyWords(word* r, const word* a, word32 n)\n{\n    for (word32 i = 0; i < n; i++)\n        r[i] = a[i];\n}\n\ninline unsigned int CountWords(const word* X, unsigned int N)\n{\n    while (N && X[N-1]==0)\n        N--;\n    return N;\n}\n\ninline void SetWords(word* r, word a, unsigned int n)\n{\n    for (unsigned int i=0; i<n; i++)\n        r[i] = a;\n}\n\nenum ByteOrder { LittleEndianOrder = 0, BigEndianOrder = 1 };\nenum CipherDir {ENCRYPTION,\tDECRYPTION};\n\ninline CipherDir ReverseDir(CipherDir dir)\n{\n    return (dir == ENCRYPTION) ? DECRYPTION : ENCRYPTION;\n}\n\ntemplate <typename ENUM_TYPE, int VALUE>\nstruct EnumToType\n{\n    static ENUM_TYPE ToEnum() { return (ENUM_TYPE)VALUE; }\n};\n\ntypedef EnumToType<ByteOrder, LittleEndianOrder> LittleEndian;\ntypedef EnumToType<ByteOrder, BigEndianOrder>    BigEndian;\n\n\n#ifndef BIG_ENDIAN_ORDER\n    typedef LittleEndian HostByteOrder;\n#else\n    typedef BigEndian    HostByteOrder;\n#endif\n\ninline ByteOrder GetHostByteOrder()\n{\n    return HostByteOrder::ToEnum();\n}\n\ninline bool HostByteOrderIs(ByteOrder order)\n{\n    return order == GetHostByteOrder();\n}\n\n\nvoid xorbuf(byte*, const byte*, unsigned int);\n\n\ntemplate <class T>\ninline bool IsPowerOf2(T n)\n{\n    return n > 0 && (n & (n-1)) == 0;\n}\n\ntemplate <class T1, class T2>\ninline T2 ModPowerOf2(T1 a, T2 b)\n{\n    return T2(a) & (b-1);\n}\n\ntemplate <class T>\ninline T RoundDownToMultipleOf(T n, T m)\n{\n    return n - (IsPowerOf2(m) ? ModPowerOf2(n, m) : (n%m));\n}\n\ntemplate <class T>\ninline T RoundUpToMultipleOf(T n, T m)\n{\n    return RoundDownToMultipleOf(n+m-1, m);\n}\n\ntemplate <class T>\ninline unsigned int GetAlignment(T* dummy = 0)\t// VC60 workaround\n{\n#if defined(_MSC_VER) && (_MSC_VER >= 1300)\n    return __alignof(T);\n#elif defined(__GNUC__)\n    return __alignof__(T);\n#else\n    return sizeof(T);\n#endif\n}\n\ninline bool IsAlignedOn(const void* p, unsigned int alignment)\n{\n    return IsPowerOf2(alignment) ? ModPowerOf2((size_t)p, alignment) == 0\n        : (size_t)p % alignment == 0;\n}\n\ntemplate <class T>\ninline bool IsAligned(const void* p, T* dummy = 0)\t// VC60 workaround\n{\n    return IsAlignedOn(p, GetAlignment<T>());\n}\n\n\ntemplate <class T> inline T rotlFixed(T x, unsigned int y)\n{\n    return (x<<y) | (x>>(sizeof(T)*8-y));\n}\n\ntemplate <class T> inline T rotrFixed(T x, unsigned int y)\n{\n    return (x>>y) | (x<<(sizeof(T)*8-y));\n}\n\n#ifdef INTEL_INTRINSICS\n\n#pragma intrinsic(_lrotl, _lrotr)\n\ntemplate<> inline word32 rotlFixed(word32 x, word32 y)\n{\n    return y ? _lrotl(x, y) : x;\n}\n\ntemplate<> inline word32 rotrFixed(word32 x, word32 y)\n{\n    return y ? _lrotr(x, y) : x;\n}\n\n#endif // INTEL_INTRINSICS\n\n#ifdef min\n#undef min\n#endif \n\n\ntemplate <class T>\ninline const T& min(const T& a, const T& b)\n{\n    return a < b ? a : b;\n}\n\n\ninline word32 ByteReverse(word32 value)\n{\n#ifdef PPC_INTRINSICS\n    // PPC: load reverse indexed instruction\n    return (word32)__lwbrx(&value,0);\n#elif defined(FAST_ROTATE)\n    // 5 instructions with rotate instruction, 9 without\n    return (rotrFixed(value, 8U) & 0xff00ff00) |\n           (rotlFixed(value, 8U) & 0x00ff00ff);\n#else\n    // 6 instructions with rotate instruction, 8 without\n    value = ((value & 0xFF00FF00) >> 8) | ((value & 0x00FF00FF) << 8);\n    return rotlFixed(value, 16U);\n#endif\n}\n\n\n#ifdef WORD64_AVAILABLE\n\ninline word64 ByteReverse(word64 value)\n{\n#ifdef TAOCRYPT_SLOW_WORD64\n\treturn (word64(ByteReverse(word32(value))) << 32) | \n                   ByteReverse(word32(value>>32));\n#else\n\tvalue = ((value & W64LIT(0xFF00FF00FF00FF00)) >> 8) |\n            ((value & W64LIT(0x00FF00FF00FF00FF)) << 8);\n\tvalue = ((value & W64LIT(0xFFFF0000FFFF0000)) >> 16) |\n            ((value & W64LIT(0x0000FFFF0000FFFF)) << 16);\n\treturn rotlFixed(value, 32U);\n#endif\n}\n\n#endif // WORD64_AVAILABLE\n\n\ntemplate <typename T>\ninline void ByteReverse(T* out, const T* in, word32 byteCount)\n{\n    word32 count = byteCount/sizeof(T);\n    for (word32 i=0; i<count; i++)\n        out[i] = ByteReverse(in[i]);\n}\n\ninline void ByteReverse(byte* out, const byte* in, word32 byteCount)\n{\n    word32* o       = reinterpret_cast<word32*>(out);\n    const word32* i = reinterpret_cast<const word32*>(in);\n    ByteReverse(o, i, byteCount);\n}\n\n\ntemplate <class T>\ninline T ByteReverseIf(T value, ByteOrder order)\n{\n    return HostByteOrderIs(order) ? value : ByteReverse(value);\n}\n\n\ntemplate <typename T>\ninline void ByteReverseIf(T* out, const T* in, word32 bc, ByteOrder order)\n{\n    if (!HostByteOrderIs(order)) \n        ByteReverse(out, in, bc);\n    else if (out != in)\n        memcpy(out, in, bc);\n}\n\n\n\n// do Asm Reverse is host is Little and x86asm \n#ifdef LITTLE_ENDIAN_ORDER\n    #ifdef TAOCRYPT_X86ASM_AVAILABLE\n        #define LittleReverse AsmReverse\n    #else\n        #define LittleReverse ByteReverse\n    #endif\n#else\n    #define LittleReverse\n#endif\n\n\n// do Asm Reverse is host is Big and x86asm \n#ifdef BIG_ENDIAN_ORDER\n    #ifdef TAOCRYPT_X86ASM_AVAILABLE\n        #define BigReverse AsmReverse\n    #else\n        #define BigReverse ByteReverse\n    #endif\n#else\n    #define BigReverse\n#endif\n\n\n#ifdef TAOCRYPT_X86ASM_AVAILABLE\n\n    // faster than rotate, use bswap\n\n    inline word32 AsmReverse(word32 wd)\n    {\n    #ifdef __GNUC__\n        __asm__ \n        (\n            \"bswap %1\"\n            : \"=r\"(wd)\n            : \"0\"(wd)\n        );\n    #else\n        __asm \n        {\n            mov   eax, wd\n            bswap eax\n            mov   wd, eax\n        }\n    #endif\n        return wd;\n    }\n\n#endif \n\n\ntemplate <class T>\ninline void GetUserKey(ByteOrder order, T* out, word32 outlen, const byte* in,\n                       word32 inlen)\n{\n    const unsigned int U = sizeof(T);\n    memcpy(out, in, inlen);\n    memset((byte *)out+inlen, 0, outlen*U-inlen);\n    ByteReverseIf(out, out, RoundUpToMultipleOf(inlen, U), order);\n}\n\n\n#ifdef _MSC_VER\n    // disable conversion warning\n    // 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy\n    #pragma warning(disable:4244 4996)\n#endif\n\n\ninline byte UnalignedGetWordNonTemplate(ByteOrder order, const byte *block,\n                                        byte*)\n{\n    return block[0];\n}\n\ninline word16 UnalignedGetWordNonTemplate(ByteOrder order, const byte* block,\n                                          word16*)\n{\n    return (order == BigEndianOrder)\n        ? block[1] | (block[0] << 8)\n        : block[0] | (block[1] << 8);\n}\n\ninline word32 UnalignedGetWordNonTemplate(ByteOrder order, const byte* block,\n                                          word32*)\n{\n    return (order == BigEndianOrder)\n        ? word32(block[3]) | (word32(block[2]) << 8) | (word32(block[1]) << 16)\n            | (word32(block[0]) << 24)\n        : word32(block[0]) | (word32(block[1]) << 8) | (word32(block[2]) << 16)\n            | (word32(block[3]) << 24);\n}\n\ntemplate <class T>\ninline T UnalignedGetWord(ByteOrder order, const byte *block, T* dummy = 0)\n{\n    return UnalignedGetWordNonTemplate(order, block, dummy);\n}\n\ninline void UnalignedPutWord(ByteOrder order, byte *block, byte value,\n                             const byte *xorBlock = 0)\n{\n    block[0] = xorBlock ? (value ^ xorBlock[0]) : value;\n}\n\n#define GETBYTE(x, y) (unsigned int)byte((x)>>(8*(y)))\n\ninline void UnalignedPutWord(ByteOrder order, byte *block, word16 value,\n                             const byte *xorBlock = 0)\n{\n    if (order == BigEndianOrder)\n    {\n        block[0] = GETBYTE(value, 1);\n        block[1] = GETBYTE(value, 0);\n    }\n    else\n    {\n        block[0] = GETBYTE(value, 0);\n        block[1] = GETBYTE(value, 1);\n    }\n\n    if (xorBlock)\n    {\n        block[0] ^= xorBlock[0];\n        block[1] ^= xorBlock[1];\n    }\n}\n\ninline void UnalignedPutWord(ByteOrder order, byte* block, word32 value,\n                             const byte* xorBlock = 0)\n{\n    if (order == BigEndianOrder)\n    {\n        block[0] = GETBYTE(value, 3);\n        block[1] = GETBYTE(value, 2);\n        block[2] = GETBYTE(value, 1);\n        block[3] = GETBYTE(value, 0);\n    }\n    else\n    {\n        block[0] = GETBYTE(value, 0);\n        block[1] = GETBYTE(value, 1);\n        block[2] = GETBYTE(value, 2);\n        block[3] = GETBYTE(value, 3);\n    }\n\n    if (xorBlock)\n    {\n        block[0] ^= xorBlock[0];\n        block[1] ^= xorBlock[1];\n        block[2] ^= xorBlock[2];\n        block[3] ^= xorBlock[3];\n    }\n}\n\n\ntemplate <class T>\ninline T GetWord(bool assumeAligned, ByteOrder order, const byte *block)\n{\n    if (assumeAligned)\n        return ByteReverseIf(*reinterpret_cast<const T *>(block), order);\n    else\n        return UnalignedGetWord<T>(order, block);\n}\n\ntemplate <class T>\ninline void GetWord(bool assumeAligned, ByteOrder order, T &result,\n                    const byte *block)\n{\n    result = GetWord<T>(assumeAligned, order, block);\n}\n\ntemplate <class T>\ninline void PutWord(bool assumeAligned, ByteOrder order, byte* block, T value,\n                    const byte *xorBlock = 0)\n{\n    if (assumeAligned)\n    {\n        if (xorBlock)\n            *reinterpret_cast<T *>(block) = ByteReverseIf(value, order) \n                ^ *reinterpret_cast<const T *>(xorBlock);\n        else\n            *reinterpret_cast<T *>(block) = ByteReverseIf(value, order);\n    }\n    else\n        UnalignedPutWord(order, block, value, xorBlock);\n}\n\ntemplate <class T, class B, bool A=true>\nclass GetBlock\n{\npublic:\n    GetBlock(const void *block)\n        : m_block((const byte *)block) {}\n\n    template <class U>\n    inline GetBlock<T, B, A> & operator()(U &x)\n    {\n        TAOCRYPT_COMPILE_ASSERT(sizeof(U) >= sizeof(T));\n        x = GetWord<T>(A, B::ToEnum(), m_block);\n        m_block += sizeof(T);\n        return *this;\n    }\n\nprivate:\n    const byte *m_block;\n};\n\ntemplate <class T, class B, bool A = true>\nclass PutBlock\n{\npublic:\n    PutBlock(const void *xorBlock, void *block)\n        : m_xorBlock((const byte *)xorBlock), m_block((byte *)block) {}\n\n    template <class U>\n    inline PutBlock<T, B, A> & operator()(U x)\n    {\n        PutWord(A, B::ToEnum(), m_block, (T)x, m_xorBlock);\n        m_block += sizeof(T);\n        if (m_xorBlock)\n            m_xorBlock += sizeof(T);\n        return *this;\n    }\n\nprivate:\n    const byte *m_xorBlock;\n    byte *m_block;\n};\n\n/*\n  XXX MYSQL: Setting A (assumeAligned) to false,\n  keeping it true might trigger segfault on SPARC.\n*/\ntemplate <class T, class B, bool A= false>\nstruct BlockGetAndPut\n{\n    // function needed because of C++ grammatical ambiguity between\n    // expression-statements and declarations\n    static inline GetBlock<T, B, A> Get(const void *block) \n        {return GetBlock<T, B, A>(block);}\n    typedef PutBlock<T, B, A> Put;\n};\n\n\n\ntemplate <bool overflow> struct SafeShifter;\n\ntemplate<> struct SafeShifter<true>\n{\n    template <class T>\n    static inline T RightShift(T value, unsigned int bits)\n    {\n        return 0;\n    }\n\n    template <class T>\n    static inline T LeftShift(T value, unsigned int bits)\n    {\n        return 0;\n    }\n};\n\ntemplate<> struct SafeShifter<false>\n{\n    template <class T>\n    static inline T RightShift(T value, unsigned int bits)\n    {\n        return value >> bits;\n    }\n\n    template <class T>\n    static inline T LeftShift(T value, unsigned int bits)\n    {\n        return value << bits;\n    }\n};\n\ntemplate <unsigned int bits, class T>\ninline T SafeRightShift(T value)\n{\n    return SafeShifter<(bits>=(8*sizeof(T)))>::RightShift(value, bits);\n}\n\ntemplate <unsigned int bits, class T>\ninline T SafeLeftShift(T value)\n{\n    return SafeShifter<(bits>=(8*sizeof(T)))>::LeftShift(value, bits);\n}\n\n\ninline\nword ShiftWordsLeftByBits(word* r, unsigned int n, unsigned int shiftBits)\n{\n    word u, carry=0;\n    if (shiftBits)\n        for (unsigned int i=0; i<n; i++)\n        {\n            u = r[i];\n            r[i] = (u << shiftBits) | carry;\n            carry = u >> (WORD_BITS-shiftBits);\n        }\n    return carry;\n}\n\n\ninline\nword ShiftWordsRightByBits(word* r, unsigned int n, unsigned int shiftBits)\n{\n    word u, carry=0;\n    if (shiftBits)\n        for (int i=n-1; i>=0; i--)\n        {\n            u = r[i];\n            r[i] = (u >> shiftBits) | carry;\n            carry = u << (WORD_BITS-shiftBits);\n        }\n    return carry;\n}\n\n\ninline\nvoid ShiftWordsLeftByWords(word* r, unsigned int n, unsigned int shiftWords)\n{\n    shiftWords = min(shiftWords, n);\n    if (shiftWords)\n    {\n        for (unsigned int i=n-1; i>=shiftWords; i--)\n            r[i] = r[i-shiftWords];\n        SetWords(r, 0, shiftWords);\n    }\n}\n\n\ninline\nvoid ShiftWordsRightByWords(word* r, unsigned int n, unsigned int shiftWords)\n{\n    shiftWords = min(shiftWords, n);\n    if (shiftWords)\n    {\n        for (unsigned int i=0; i+shiftWords<n; i++)\n            r[i] = r[i+shiftWords];\n        SetWords(r+n-shiftWords, 0, shiftWords);\n    }\n}\n\n\ntemplate <class T1, class T2>\ninline T1 SaturatingSubtract(T1 a, T2 b)\n{\n    TAOCRYPT_COMPILE_ASSERT_INSTANCE(T1(-1)>0, 0);  // T1 is unsigned type\n    TAOCRYPT_COMPILE_ASSERT_INSTANCE(T2(-1)>0, 1);  // T2 is unsigned type\n    return T1((a > b) ? (a - b) : 0);\n}\n\n\n// declares\nunsigned int  BytePrecision(word value);\nunsigned int  BitPrecision(word);\nword Crop(word value, unsigned int size);\n\n\n\n} // namespace\n\n#endif // TAO_CRYPT_MISC_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/modarith.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* based on Wei Dai's modarith.h from CryptoPP */\n\n\n#ifndef TAO_CRYPT_MODARITH_HPP\n#define TAO_CRYPT_MODARITH_HPP\n\n#include \"misc.hpp\"\n#include \"algebra.hpp\"\n\nnamespace TaoCrypt {\n\n\n// ModularArithmetic\nclass ModularArithmetic : public AbstractRing\n{\npublic:\n\n    typedef int RandomizationParameter;\n    typedef Integer Element;\n\n    ModularArithmetic(const Integer &modulus = Integer::One())\n        : modulus(modulus), result((word)0, modulus.reg_.size()) {}\n\n    ModularArithmetic(const ModularArithmetic &ma)\n        : AbstractRing(),\n        modulus(ma.modulus), result((word)0, modulus.reg_.size()) {}\n\n    const Integer& GetModulus() const {return modulus;}\n    void SetModulus(const Integer &newModulus) \n    {   \n        modulus = newModulus;\n        result.reg_.resize(modulus.reg_.size());\n    }\n\n    virtual bool IsMontgomeryRepresentation() const {return false;}\n\n    virtual Integer ConvertIn(const Integer &a) const\n        {return a%modulus;}\n\n    virtual Integer ConvertOut(const Integer &a) const\n        {return a;}\n\n    const Integer& Half(const Integer &a) const;\n\n    bool Equal(const Integer &a, const Integer &b) const\n        {return a==b;}\n\n    const Integer& Identity() const\n        {return Integer::Zero();}\n\n    const Integer& Add(const Integer &a, const Integer &b) const;\n\n    Integer& Accumulate(Integer &a, const Integer &b) const;\n\n    const Integer& Inverse(const Integer &a) const;\n\n    const Integer& Subtract(const Integer &a, const Integer &b) const;\n\n    Integer& Reduce(Integer &a, const Integer &b) const;\n\n    const Integer& Double(const Integer &a) const\n        {return Add(a, a);}\n\n    const Integer& MultiplicativeIdentity() const\n        {return Integer::One();}\n\n    const Integer& Multiply(const Integer &a, const Integer &b) const\n        {return result1 = a*b%modulus;}\n\n    const Integer& Square(const Integer &a) const\n        {return result1 = a.Squared()%modulus;}\n\n    bool IsUnit(const Integer &a) const\n        {return Integer::Gcd(a, modulus).IsUnit();}\n\n    const Integer& MultiplicativeInverse(const Integer &a) const\n        {return result1 = a.InverseMod(modulus);}\n\n    const Integer& Divide(const Integer &a, const Integer &b) const\n        {return Multiply(a, MultiplicativeInverse(b));}\n\n    Integer CascadeExponentiate(const Integer &x, const Integer &e1,\n                                const Integer &y, const Integer &e2) const;\n\n    void SimultaneousExponentiate(Element *results, const Element &base,\n                  const Integer *exponents, unsigned int exponentsCount) const;\n\n    unsigned int MaxElementBitLength() const\n        {return (modulus-1).BitCount();}\n\n    unsigned int MaxElementByteLength() const\n        {return (modulus-1).ByteCount();}\n\n\n    static const RandomizationParameter DefaultRandomizationParameter;\n\nprotected:\n    Integer modulus;\n    mutable Integer result, result1;\n\n};\n\n\n\n//! do modular arithmetics in Montgomery representation for increased speed\nclass MontgomeryRepresentation : public ModularArithmetic\n{\npublic:\n    MontgomeryRepresentation(const Integer &modulus);\t// modulus must be odd\n\n    bool IsMontgomeryRepresentation() const {return true;}\n\n    Integer ConvertIn(const Integer &a) const\n        {return (a<<(WORD_BITS*modulus.reg_.size()))%modulus;}\n\n    Integer ConvertOut(const Integer &a) const;\n\n    const Integer& MultiplicativeIdentity() const\n     {return result1 = Integer::Power2(WORD_BITS*modulus.reg_.size())%modulus;}\n\n    const Integer& Multiply(const Integer &a, const Integer &b) const;\n\n    const Integer& Square(const Integer &a) const;\n\n    const Integer& MultiplicativeInverse(const Integer &a) const;\n\n    Integer CascadeExponentiate(const Integer &x, const Integer &e1,\n                                const Integer &y, const Integer &e2) const\n        {return AbstractRing::CascadeExponentiate(x, e1, y, e2);}\n\n    void SimultaneousExponentiate(Element *results, const Element &base,\n            const Integer *exponents, unsigned int exponentsCount) const\n        {AbstractRing::SimultaneousExponentiate(results, base,\n                                                exponents, exponentsCount);}\n\nprivate:\n    Integer u;\n    mutable AlignedWordBlock workspace;\n};\n\n\n\n\n} // namespace\n\n#endif // TAO_CRYPT_MODARITH_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/modes.hpp",
    "content": "/*\n   Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* modes.hpp provides ECB and CBC modes for block cipher encryption/decryption\n*/\n\n\n#ifndef TAO_CRYPT_MODES_HPP\n#define TAO_CRYPT_MODES_HPP\n\n#include \"misc.hpp\"\n\nnamespace TaoCrypt {\n\n\nenum Mode { ECB, CBC };\n\n\n\n// BlockCipher abstraction\ntemplate<CipherDir DIR, class T, Mode MODE>\nclass BlockCipher {\npublic:\n    BlockCipher() : cipher_(DIR, MODE) {}\n\n    void Process(byte* c, const byte* p, word32 sz) \n            { cipher_.Process(c, p, sz); }\n    void SetKey(const byte* k, word32 sz)   \n            { cipher_.SetKey(k, sz, DIR); }\n    void SetKey(const byte* k, word32 sz, const byte* iv)   \n            { cipher_.SetKey(k, sz, DIR); cipher_.SetIV(iv); }\nprivate:\n    T cipher_;\n\n    BlockCipher(const BlockCipher&);            // hide copy\n    BlockCipher& operator=(const BlockCipher&); // and assign\n};\n\n\n// Mode Base for block ciphers, static size\nclass Mode_BASE : public virtual_base {\npublic:\n    enum { MaxBlockSz = 16 };\n\n    explicit Mode_BASE(int sz, CipherDir dir, Mode mode) \n        : blockSz_(sz), reg_(reinterpret_cast<byte*>(r_)),\n          tmp_(reinterpret_cast<byte*>(t_)), dir_(dir), mode_(mode)\n    {}\n    virtual ~Mode_BASE() {}\n\n    virtual void Process(byte*, const byte*, word32);\n\n    void SetIV(const byte* iv) { memcpy(reg_, iv, blockSz_); }\nprotected:\n    int   blockSz_;\n    byte* reg_;\n    byte* tmp_;\n\n    word32 r_[MaxBlockSz / sizeof(word32)];  // align reg_ on word32\n    word32 t_[MaxBlockSz / sizeof(word32)];  // align tmp_ on word32\n\n    CipherDir dir_;\n    Mode      mode_;\n\n    void ECB_Process(byte*, const byte*, word32);\n    void CBC_Encrypt(byte*, const byte*, word32);\n    void CBC_Decrypt(byte*, const byte*, word32);\n\n    Mode_BASE(const Mode_BASE&);            // hide copy\n    Mode_BASE& operator=(const Mode_BASE&); // and assign\n\nprivate:\n    virtual void ProcessAndXorBlock(const byte*, const byte*, byte*) const = 0;\n};\n\n\ninline void Mode_BASE::Process(byte* out, const byte* in, word32 sz)\n{\n    if (mode_ == ECB)\n        ECB_Process(out, in, sz);\n    else if (mode_ == CBC) {\n        if (dir_ == ENCRYPTION)\n            CBC_Encrypt(out, in, sz);\n        else\n            CBC_Decrypt(out, in, sz);\n    }\n}\n\n\n// ECB Process blocks\ninline void Mode_BASE::ECB_Process(byte* out, const byte* in, word32 sz)\n{\n    word32 blocks = sz / blockSz_;\n\n    while (blocks--) {\n        ProcessAndXorBlock(in, 0, out);\n        out += blockSz_;\n        in  += blockSz_;\n    }\n}\n\n\n// CBC Encrypt\ninline void Mode_BASE::CBC_Encrypt(byte* out, const byte* in, word32 sz)\n{\n    word32 blocks = sz / blockSz_;\n\n    while (blocks--) {\n        xorbuf(reg_, in, blockSz_);\n        ProcessAndXorBlock(reg_, 0, reg_);\n        memcpy(out, reg_, blockSz_);\n        out += blockSz_;\n        in  += blockSz_;\n    }\n}\n\n\n// CBC Decrypt\ninline void Mode_BASE::CBC_Decrypt(byte* out, const byte* in, word32 sz)\n{\n    word32 blocks = sz / blockSz_;\n    byte   hold[MaxBlockSz];\n\n    while (blocks--) {\n        memcpy(tmp_, in, blockSz_);\n        ProcessAndXorBlock(tmp_, 0, out);\n        xorbuf(out,  reg_, blockSz_);\n        memcpy(hold, reg_,   blockSz_); // swap reg_ and tmp_\n        memcpy(reg_,   tmp_, blockSz_);\n        memcpy(tmp_, hold, blockSz_);\n        out += blockSz_;\n        in  += blockSz_;\n    }\n}\n\n\n} // namespace\n\n#endif  // TAO_CRYPT_MODES_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/pwdbased.hpp",
    "content": "/*\n   Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* pwdbased.hpp defines PBKDF2 from PKCS #5\n*/\n\n\n#ifndef TAO_CRYPT_PWDBASED_HPP\n#define TAO_CRYPT_PWDBASED_HPP\n\n#include <string.h>\n#include \"misc.hpp\"\n#include \"block.hpp\"\n#include \"hmac.hpp\"\n\nnamespace TaoCrypt {\n\n\n// From PKCS #5, T must be type suitable for HMAC<T> \ntemplate <class T>\nclass PBKDF2_HMAC {\npublic:\n    word32 MaxDerivedKeyLength() const { return 0xFFFFFFFFU;} // avoid overflow\n\n    word32 DeriveKey(byte* derived, word32 dLen, const byte* pwd, word32 pLen,\n                     const byte* salt, word32 sLen, word32 iterations) const;\n}; \n\n\n\ntemplate <class T>\nword32 PBKDF2_HMAC<T>::DeriveKey(byte* derived, word32 dLen, const byte* pwd,\n                                 word32 pLen, const byte* salt, word32 sLen,\n                                 word32 iterations) const\n{\n\tif (dLen > MaxDerivedKeyLength())\n        return 0;\n\n    ByteBlock buffer(T::DIGEST_SIZE);\n\tHMAC<T>   hmac;\n\n    hmac.SetKey(pwd, pLen);\n\n\tword32 i = 1;\n\n\twhile (dLen > 0) {\n\t\thmac.Update(salt, sLen);\n\t\tword32 j;\n\t\tfor (j = 0; j < 4; j++) {\n\t\t\tbyte b = i >> ((3-j)*8);\n\t\t\thmac.Update(&b, 1);\n\t\t}\n\t\thmac.Final(buffer.get_buffer());\n\n\t\tword32 segmentLen = min(dLen, buffer.size());\n\t\tmemcpy(derived, buffer.get_buffer(), segmentLen);\n\n\t\tfor (j = 1; j < iterations; j++) {\n\t\t\thmac.Update(buffer.get_buffer(), buffer.size());\n            hmac.Final(buffer.get_buffer());\n\t\t\txorbuf(derived, buffer.get_buffer(), segmentLen);\n\t\t}\n\t\tderived += segmentLen;\n\t\tdLen    -= segmentLen;\n\t\ti++;\n\t}\n\treturn iterations;\n}\n\n\n\n\n} // naemspace\n\n#endif // TAO_CRYPT_PWDBASED_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/rabbit.hpp",
    "content": "/*\n   Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* rabbit.hpp defines Rabbit\n*/\n\n\n#ifndef TAO_CRYPT_RABBIT_HPP\n#define TAO_CRYPT_RABBIT_HPP\n\n#include \"misc.hpp\"\n\nnamespace TaoCrypt {\n\n\n// Rabbit encryption and decryption\nclass Rabbit {\npublic:\n\n    typedef Rabbit Encryption;\n    typedef Rabbit Decryption;\n\n    enum RabbitCtx { Master = 0, Work = 1 };\n\n    Rabbit() {}\n\n    void Process(byte*, const byte*, word32);\n    void SetKey(const byte*, const byte*);\nprivate:\n    struct Ctx {\n        word32 x[8];\n        word32 c[8];\n        word32 carry;\n    };\n\n    Ctx masterCtx_;\n    Ctx workCtx_;\n\n    void NextState(RabbitCtx);\n    void SetIV(const byte*);\n\n    Rabbit(const Rabbit&);                  // hide copy\n    const Rabbit operator=(const Rabbit&);  // and assign\n};\n\n} // namespace\n\n\n#endif // TAO_CRYPT_RABBIT_HPP\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/random.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* random.hpp provides a crypto secure Random Number Generator using an OS\n   specific seed\n*/\n\n\n#ifndef TAO_CRYPT_RANDOM_HPP\n#define TAO_CRYPT_RANDOM_HPP\n\n#include \"arc4.hpp\"\n#include \"error.hpp\"\n\nnamespace TaoCrypt {\n\n\n// OS specific seeder\nclass OS_Seed {\npublic:\n    OS_Seed();\n    ~OS_Seed();\n\n    void   GenerateSeed(byte*, word32 sz);\n    Error  GetError() const { return error_; }\nprivate:\n#if defined(_WIN32)\n    #if defined(_WIN64)\n        typedef unsigned __int64 ProviderHandle;\n        // type HCRYPTPROV, avoid #include <windows.h>\n    #else\n        typedef unsigned long ProviderHandle;\n    #endif\n    ProviderHandle handle_;\n#else\n    int fd_;\n#endif\n    Error error_;\n\n    OS_Seed(const OS_Seed&);              // hide copy\n    OS_Seed& operator=(const OS_Seed&);   // hide assign\n};\n\n\n// secure Random Nnumber Generator\nclass RandomNumberGenerator {\npublic:\n    RandomNumberGenerator();\n    ~RandomNumberGenerator() {}\n\n    void GenerateBlock(byte*, word32 sz);\n    byte GenerateByte();\n\n    ErrorNumber GetError() const { return seed_.GetError().What(); }\nprivate:\n    OS_Seed seed_;\n    ARC4    cipher_;\n\n    RandomNumberGenerator(const RandomNumberGenerator&);           // hide copy\n    RandomNumberGenerator operator=(const RandomNumberGenerator&); // && assign\n};\n\n\n\n\n}  // namespace\n\n#endif // TAO_CRYPT_RANDOM_HPP\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/ripemd.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* ripemd.hpp provides RIPEMD digest support\n*/\n\n#ifndef TAO_CRYPT_RIPEMD_HPP\n#define TAO_CRYPT_RIPEMD_HPP\n\n#include \"hash.hpp\"\n\n\n#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)\n    #define DO_RIPEMD_ASM\n#endif\n\nnamespace TaoCrypt {\n\n\n// RIPEMD160 digest\nclass RIPEMD160 : public HASHwithTransform {\npublic:\n    enum { BLOCK_SIZE = 64, DIGEST_SIZE = 20, PAD_SIZE = 56,\n           TAO_BYTE_ORDER = LittleEndianOrder };   // in Bytes\n    RIPEMD160() : HASHwithTransform(DIGEST_SIZE / sizeof(word32), BLOCK_SIZE)\n                { Init(); }\n    ByteOrder getByteOrder()  const { return ByteOrder(TAO_BYTE_ORDER); }\n    word32    getBlockSize()  const { return BLOCK_SIZE; }\n    word32    getDigestSize() const { return DIGEST_SIZE; }\n    word32    getPadSize()    const { return PAD_SIZE; }\n\n    RIPEMD160(const RIPEMD160&);\n    RIPEMD160& operator= (const RIPEMD160&);\n\n#ifdef DO_RIPEMD_ASM\n    void Update(const byte*, word32);\n#endif\n    void Init();\n    void Swap(RIPEMD160&);\nprivate:\n    void Transform();\n    void AsmTransform(const byte* data, word32 times);\n};\n\ninline void swap(RIPEMD160& a, RIPEMD160& b)\n{\n    a.Swap(b);\n}\n\n\n} // namespace\n\n#endif // TAO_CRYPT_RIPEMD_HPP\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/rsa.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* rsa.hpp provides RSA ES encrypt/decrypt, SSL (block type 1) sign and verify\n*/\n\n#ifndef TAO_CRYPT_RSA_HPP\n#define TAO_CRYPT_RSA_HPP\n\n#include \"integer.hpp\"\n#include \"random.hpp\"\n\n\nnamespace TaoCrypt {\n\nclass Source;\n\n\n// Public Key Length helper\nclass PK_Lengths {\n    const Integer& image_;\npublic:\n    explicit PK_Lengths(const Integer& i) : image_(i) {}\n\n    word32 PaddedBlockBitLength()  const {return image_.BitCount() - 1;}\n    word32 PaddedBlockByteLength() const \n                {return BitsToBytes(PaddedBlockBitLength());}\n\n    word32 FixedCiphertextLength()   const {return image_.ByteCount();}\n    word32 FixedMaxPlaintextLength() const \n                {return SaturatingSubtract(PaddedBlockBitLength() / 8, 10U); }\n};\n\n\n// RSA Public Key\nclass RSA_PublicKey {\nprotected:\n    Integer n_;\n    Integer e_;\npublic:\n    RSA_PublicKey() {}\n    explicit RSA_PublicKey(Source&);\n\n    void Initialize(const Integer& n, const Integer& e) {n_ = n; e_ = e;}\n    void Initialize(Source&);\n\n    Integer ApplyFunction(const Integer& x) const;\n\n    const Integer& GetModulus() const {return n_;}\n    const Integer& GetPublicExponent() const {return e_;}\n\n    void SetModulus(const Integer& n) {n_ = n;}\n    void SetPublicExponent(const Integer& e) {e_ = e;}\n\n    word32 FixedCiphertextLength()\n    {\n        return PK_Lengths(n_).FixedCiphertextLength();\n    }\n\n    RSA_PublicKey(const RSA_PublicKey& other) : n_(other.n_), e_(other.e_) {}\n    RSA_PublicKey& operator=(const RSA_PublicKey& that)\n    {\n        RSA_PublicKey tmp(that);\n        Swap(tmp);\n        return *this;\n    }\n\n    void Swap(RSA_PublicKey& other)\n    {\n        n_.Swap(other.n_);\n        e_.Swap(other.e_);\n    }\n};\n\n\n// RSA Private Key\nclass RSA_PrivateKey : public RSA_PublicKey {\n    Integer d_;\n    Integer p_;\n    Integer q_;\n    Integer dp_;\n    Integer dq_;\n    Integer u_;\npublic:\n    RSA_PrivateKey() {}\n    explicit RSA_PrivateKey(Source&);\n\n    void Initialize(const Integer& n,  const Integer& e, const Integer& d,\n                    const Integer& p,  const Integer& q, const Integer& dp, \n                    const Integer& dq, const Integer& u)\n        {n_ = n; e_ = e; d_ = d; p_ = p; q_ = q; dp_ = dp; dq_ = dq; u_ = u;}\n    void Initialize(Source&);\n\n    Integer CalculateInverse(RandomNumberGenerator&, const Integer&) const;\n\n    const Integer& GetPrime1() const {return p_;}\n    const Integer& GetPrime2() const {return q_;}\n    const Integer& GetPrivateExponent() const {return d_;}\n    const Integer& GetModPrime1PrivateExponent() const {return dp_;}\n    const Integer& GetModPrime2PrivateExponent() const {return dq_;}\n    const Integer& GetMultiplicativeInverseOfPrime2ModPrime1() const \n                   {return u_;}\n\n    void SetPrime1(const Integer& p) {p_ = p;}\n    void SetPrime2(const Integer& q) {q_ = q;}\n    void SetPrivateExponent(const Integer& d) {d_ = d;}\n    void SetModPrime1PrivateExponent(const Integer& dp) {dp_ = dp;}\n    void SetModPrime2PrivateExponent(const Integer& dq) {dq_ = dq;}\n    void SetMultiplicativeInverseOfPrime2ModPrime1(const Integer& u) {u_ = u;}\nprivate:\n    RSA_PrivateKey(const RSA_PrivateKey&);              // hide copy\n    RSA_PrivateKey& operator=(const RSA_PrivateKey&);   // and assign\n};\n\n\n// block type 2 padding\nclass RSA_BlockType2  {\npublic:\n    void   Pad(const byte*, word32, byte*, word32,\n               RandomNumberGenerator&) const;\n    word32 UnPad(const byte*, word32, byte*) const;\n};\n\n\n// block type 1 padding\nclass RSA_BlockType1  {\npublic:\n    void   Pad(const byte*, word32, byte*, word32, \n               RandomNumberGenerator&) const;\n    word32 UnPad(const byte*, word32, byte*) const;\n};\n\n\n// RSA Encryptor, can use any padding\ntemplate<class Pad = RSA_BlockType2>\nclass RSA_Encryptor {\n    const RSA_PublicKey& key_;\n    Pad                  padding_;\npublic:\n    explicit RSA_Encryptor(const RSA_PublicKey& k) : key_(k) {}\n\n    void Encrypt(const byte*, word32, byte*, RandomNumberGenerator&);\n    bool SSL_Verify(const byte* msg, word32 sz, const byte* sig);\n};\n\n\n// RSA Decryptor, can use any padding\ntemplate<class Pad = RSA_BlockType2>\nclass RSA_Decryptor {\n    const RSA_PrivateKey& key_;\n    Pad                   padding_;\npublic:\n    explicit RSA_Decryptor(const RSA_PrivateKey& k) : key_(k) {}\n\n    word32 Decrypt(const byte*, word32, byte*, RandomNumberGenerator&);\n    void   SSL_Sign(const byte*, word32, byte*, RandomNumberGenerator&);\n};\n\n\n// Public Encrypt\ntemplate<class Pad>\nvoid RSA_Encryptor<Pad>::Encrypt(const byte* plain, word32 sz, byte* cipher,\n                                 RandomNumberGenerator& rng)\n{\n    PK_Lengths lengths(key_.GetModulus());\n    if (sz > lengths.FixedMaxPlaintextLength())\n        return;\n\n    ByteBlock paddedBlock(lengths.PaddedBlockByteLength());\n    padding_.Pad(plain, sz, paddedBlock.get_buffer(),\n                 lengths.PaddedBlockBitLength(), rng);\n\n    key_.ApplyFunction(Integer(paddedBlock.get_buffer(), paddedBlock.size())).\n        Encode(cipher, lengths.FixedCiphertextLength());\n}\n\n\n// Private Decrypt\ntemplate<class Pad>\nword32 RSA_Decryptor<Pad>::Decrypt(const byte* cipher, word32 sz, byte* plain,\n                                   RandomNumberGenerator& rng)\n{\n    PK_Lengths lengths(key_.GetModulus());\n\n    if (sz != lengths.FixedCiphertextLength())\n        return 0;\n       \n    ByteBlock paddedBlock(lengths.PaddedBlockByteLength());\n    Integer x = key_.CalculateInverse(rng, Integer(cipher,\n                                      lengths.FixedCiphertextLength()).Ref());\n    if (x.ByteCount() > paddedBlock.size())\n        x = Integer::Zero();\t// don't return false, prevents timing attack\n    x.Encode(paddedBlock.get_buffer(), paddedBlock.size());\n    return padding_.UnPad(paddedBlock.get_buffer(),\n                          lengths.PaddedBlockBitLength(), plain);\n}\n\n\n// Private SSL type (block 1) Encrypt\ntemplate<class Pad>\nvoid RSA_Decryptor<Pad>::SSL_Sign(const byte* message, word32 sz, byte* sig,\n                                  RandomNumberGenerator& rng)\n{\n    RSA_PublicKey inverse;\n    inverse.Initialize(key_.GetModulus(), key_.GetPrivateExponent());\n    RSA_Encryptor<RSA_BlockType1> enc(inverse); // SSL Type\n    enc.Encrypt(message, sz, sig, rng);\n}\n\n\nword32 SSL_Decrypt(const RSA_PublicKey& key, const byte* sig, byte* plain);\n\n\n// Public SSL type (block 1) Decrypt\ntemplate<class Pad>\nbool RSA_Encryptor<Pad>::SSL_Verify(const byte* message, word32 sz,\n                                    const byte* sig)\n{\n    ByteBlock plain(PK_Lengths(key_.GetModulus()).FixedMaxPlaintextLength());\n    if (SSL_Decrypt(key_, sig, plain.get_buffer()) != sz)\n        return false;   // not right justified or bad padding\n\n    if ( (memcmp(plain.get_buffer(), message, sz)) == 0)\n        return true;\n    return false;\n}\n\n\ntypedef RSA_Encryptor<> RSAES_Encryptor;\ntypedef RSA_Decryptor<> RSAES_Decryptor;\n\n\n} // namespace\n\n#endif // TAO_CRYPT_RSA_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/runtime.hpp",
    "content": "/*\n   Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* runtime.hpp provides C++ runtime support functions when building a pure C\n * version of yaSSL, user must define YASSL_PURE_C\n*/\n\n\n\n#ifndef yaSSL_NEW_HPP\n#define yaSSL_NEW_HPP\n\n#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n\n#ifdef YASSL_PURE_C\n\n#ifdef __sun\n \n\n// Handler for pure virtual functions\nnamespace __Crun {\n    void pure_error(void);\n} // namespace __Crun\n\n#endif // __sun\n\n\n#if defined(__GNUC__) && !(defined(__ICC) || defined(__INTEL_COMPILER))\n\n#if __GNUC__ > 2\n\nextern \"C\" {\n#if defined(DO_TAOCRYPT_KERNEL_MODE)\n    #include \"kernelc.hpp\"\n#endif\n    int __cxa_pure_virtual () __attribute__ ((weak));\n} // extern \"C\"\n\n#endif // __GNUC__ > 2\n#endif // compiler check\n#endif // YASSL_PURE_C\n#endif // yaSSL_NEW_HPP\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/sha.hpp",
    "content": "/*\n   Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* sha.hpp provides SHA-1 digests, see RFC 3174\n*/\n\n#ifndef TAO_CRYPT_SHA_HPP\n#define TAO_CRYPT_SHA_HPP\n\n#include \"hash.hpp\"\n\n\n#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)\n    #define DO_SHA_ASM\n#endif\n\nnamespace TaoCrypt {\n\n\n// SHA-1 digest\nclass SHA : public HASHwithTransform {\npublic:\n    enum { BLOCK_SIZE = 64, DIGEST_SIZE = 20, PAD_SIZE = 56,\n           TAO_BYTE_ORDER = BigEndianOrder};   // in Bytes\n    SHA() : HASHwithTransform(DIGEST_SIZE / sizeof(word32), BLOCK_SIZE)\n                { Init(); }\n    ByteOrder getByteOrder()  const { return ByteOrder(TAO_BYTE_ORDER); }\n    word32    getBlockSize()  const { return BLOCK_SIZE; }\n    word32    getDigestSize() const { return DIGEST_SIZE; }\n    word32    getPadSize()    const { return PAD_SIZE; }\n\n#ifdef DO_SHA_ASM\n    void Update(const byte* data, word32 len);\n#endif\n    void Init();\n\n    SHA(const SHA&);\n    SHA& operator= (const SHA&);\n\n    void Swap(SHA&);\nprivate:\n    void Transform();\n    void AsmTransform(const byte* data, word32 times);\n};\n\n\ninline void swap(SHA& a, SHA& b)\n{\n    a.Swap(b);\n}\n\n// SHA-256 digest\nclass SHA256 : public HASHwithTransform {\npublic:\n    enum { BLOCK_SIZE = 64, DIGEST_SIZE = 32, PAD_SIZE = 56,\n           TAO_BYTE_ORDER = BigEndianOrder};   // in Bytes\n    SHA256() : HASHwithTransform(DIGEST_SIZE / sizeof(word32), BLOCK_SIZE)\n                { Init(); }\n    ByteOrder getByteOrder()  const { return ByteOrder(TAO_BYTE_ORDER); }\n    word32    getBlockSize()  const { return BLOCK_SIZE; }\n    word32    getDigestSize() const { return DIGEST_SIZE; }\n    word32    getPadSize()    const { return PAD_SIZE; }\n\n    void Init();\n\n    SHA256(const SHA256&);\n    SHA256& operator= (const SHA256&);\n\n    void Swap(SHA256&);\nprivate:\n    void Transform();\n};\n\n\n// SHA-224 digest\nclass SHA224 : public HASHwithTransform {\npublic:\n    enum { BLOCK_SIZE = 64, DIGEST_SIZE = 28, PAD_SIZE = 56,\n           TAO_BYTE_ORDER = BigEndianOrder};   // in Bytes\n    SHA224() : HASHwithTransform(SHA256::DIGEST_SIZE /sizeof(word32),BLOCK_SIZE)\n                { Init(); }\n    ByteOrder getByteOrder()  const { return ByteOrder(TAO_BYTE_ORDER); }\n    word32    getBlockSize()  const { return BLOCK_SIZE; }\n    word32    getDigestSize() const { return DIGEST_SIZE; }\n    word32    getPadSize()    const { return PAD_SIZE; }\n\n    void Init();\n\n    SHA224(const SHA224&);\n    SHA224& operator= (const SHA224&);\n\n    void Swap(SHA224&);\nprivate:\n    void Transform();\n};\n\n\n#ifdef WORD64_AVAILABLE\n\n// SHA-512 digest\nclass SHA512 : public HASH64withTransform {\npublic:\n    enum { BLOCK_SIZE = 128, DIGEST_SIZE = 64, PAD_SIZE = 112,\n           TAO_BYTE_ORDER = BigEndianOrder};   // in Bytes\n    SHA512() : HASH64withTransform(DIGEST_SIZE / sizeof(word64), BLOCK_SIZE)\n                { Init(); }\n    ByteOrder getByteOrder()  const { return ByteOrder(TAO_BYTE_ORDER); }\n    word32    getBlockSize()  const { return BLOCK_SIZE; }\n    word32    getDigestSize() const { return DIGEST_SIZE; }\n    word32    getPadSize()    const { return PAD_SIZE; }\n\n    void Init();\n\n    SHA512(const SHA512&);\n    SHA512& operator= (const SHA512&);\n\n    void Swap(SHA512&);\nprivate:\n    void Transform();\n};\n\n\n// SHA-384 digest\nclass SHA384 : public HASH64withTransform {\npublic:\n    enum { BLOCK_SIZE = 128, DIGEST_SIZE = 48, PAD_SIZE = 112,\n           TAO_BYTE_ORDER = BigEndianOrder};   // in Bytes\n    SHA384() : HASH64withTransform(SHA512::DIGEST_SIZE/ sizeof(word64),\n                                   BLOCK_SIZE)\n                { Init(); }\n    ByteOrder getByteOrder()  const { return ByteOrder(TAO_BYTE_ORDER); }\n    word32    getBlockSize()  const { return BLOCK_SIZE; }\n    word32    getDigestSize() const { return DIGEST_SIZE; }\n    word32    getPadSize()    const { return PAD_SIZE; }\n\n    void Init();\n\n    SHA384(const SHA384&);\n    SHA384& operator= (const SHA384&);\n\n    void Swap(SHA384&);\nprivate:\n    void Transform();\n};\n\nenum { MAX_SHA2_DIGEST_SIZE = 64 };   // SHA512\n\n#else\n\nenum { MAX_SHA2_DIGEST_SIZE = 32 };   // SHA256\n\n#endif // WORD64_AVAILABLE\n\n\n} // namespace\n\n\n#endif // TAO_CRYPT_SHA_HPP\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/twofish.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* twofish.hpp defines Twofish\n*/\n\n\n#ifndef TAO_CRYPT_TWOFISH_HPP\n#define TAO_CRYPT_TWOFISH_HPP\n\n#include \"misc.hpp\"\n#include \"modes.hpp\"\n#ifdef USE_SYS_STL\n    #include <algorithm>\n#else\n    #include \"algorithm.hpp\"\n#endif\n\n\nnamespace STL = STL_NAMESPACE;\n\n\n#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)\n    #define DO_TWOFISH_ASM\n#endif\n\nnamespace TaoCrypt {\n\nenum { TWOFISH_BLOCK_SIZE = 16 };\n\n\n// Twofish encryption and decryption, see \nclass Twofish : public Mode_BASE {\npublic:\n    enum { BLOCK_SIZE = TWOFISH_BLOCK_SIZE };\n\n    Twofish(CipherDir DIR, Mode MODE)\n        : Mode_BASE(BLOCK_SIZE, DIR, MODE) {}\n\n#ifdef DO_TWOFISH_ASM\n    void Process(byte*, const byte*, word32);\n#endif\n    void SetKey(const byte* key, word32 sz, CipherDir fake = ENCRYPTION);\n    void SetIV(const byte* iv) { memcpy(r_, iv, BLOCK_SIZE); }\nprivate:\n\tstatic const byte     q_[2][256];\n\tstatic const word32 mds_[4][256];\n\n\tword32 k_[40];\n\tword32 s_[4][256];\n\n\tstatic word32 h0(word32 x, const word32 *key, unsigned int kLen);\n\tstatic word32 h(word32 x, const word32 *key, unsigned int kLen);\n\n    void ProcessAndXorBlock(const byte*, const byte*, byte*) const;\n\n    void encrypt(const byte*, const byte*, byte*) const;\n    void decrypt(const byte*, const byte*, byte*) const;\n\n    void AsmEncrypt(const byte* inBlock, byte* outBlock) const;\n    void AsmDecrypt(const byte* inBlock, byte* outBlock) const;\n\n    Twofish(const Twofish&);            // hide copy\n    Twofish& operator=(const Twofish&); // and assign\n};\n\n\ntypedef BlockCipher<ENCRYPTION, Twofish, ECB> Twofish_ECB_Encryption;\ntypedef BlockCipher<DECRYPTION, Twofish, ECB> Twofish_ECB_Decryption;\n\ntypedef BlockCipher<ENCRYPTION, Twofish, CBC> Twofish_CBC_Encryption;\ntypedef BlockCipher<DECRYPTION, Twofish, CBC> Twofish_CBC_Decryption;\n\n\n\n} // naemspace\n\n#endif // TAO_CRYPT_TWOFISH_HPP\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/type_traits.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* type_traits defines fundamental types\n * see discussion in C++ Templates, $19.1\n*/\n\n\n#ifndef TAO_CRYPT_TYPE_TRAITS_HPP\n#define TAO_CRYPT_TYPE_TRAITS_HPP\n\n#include \"types.hpp\"\n\nnamespace TaoCrypt {\n\n\n// primary template: in general T is not a fundamental type\n\ntemplate <typename T>\nclass IsFundamentalType {\n    public:\n        enum { Yes = 0, No = 1 };\n};\n\n\n// macro to specialize for fundamental types\n#define MK_FUNDAMENTAL_TYPE(T)                  \\\n    template<> class IsFundamentalType<T> {     \\\n        public:                                 \\\n            enum { Yes = 1, No = 0 };           \\\n    };\n\n\nMK_FUNDAMENTAL_TYPE(void)\n\nMK_FUNDAMENTAL_TYPE(bool)\nMK_FUNDAMENTAL_TYPE(         char)\nMK_FUNDAMENTAL_TYPE(signed   char)\nMK_FUNDAMENTAL_TYPE(unsigned char)\n\nMK_FUNDAMENTAL_TYPE(signed   short)\nMK_FUNDAMENTAL_TYPE(unsigned short)\nMK_FUNDAMENTAL_TYPE(signed   int)\nMK_FUNDAMENTAL_TYPE(unsigned int)\nMK_FUNDAMENTAL_TYPE(signed   long)\nMK_FUNDAMENTAL_TYPE(unsigned long)\n\nMK_FUNDAMENTAL_TYPE(float)\nMK_FUNDAMENTAL_TYPE(     double)\nMK_FUNDAMENTAL_TYPE(long double)\n\n#if defined(WORD64_AVAILABLE) && defined(WORD64_IS_DISTINCT_TYPE)\n    MK_FUNDAMENTAL_TYPE(word64)\n#endif\n\n\n#undef MK_FUNDAMENTAL_TYPE\n\n\n} // namespace\n\n#endif // TAO_CRYPT_TYPE_TRAITS_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/include/types.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* based on Wei Dai's misc.h from CryptoPP, basic crypt types */\n\n\n#ifndef TAO_CRYPT_TYPES_HPP\n#define TAO_CRYPT_TYPES_HPP\n\n#ifdef HAVE_CONFIG_H\n#include \"config.h\"\n#endif\n\nnamespace TaoCrypt {\n\n\n#if defined(WORDS_BIGENDIAN) || (defined(__MWERKS__) && !defined(__INTEL__))\n    #define BIG_ENDIAN_ORDER\n#endif\n\n#ifndef BIG_ENDIAN_ORDER\n    #define LITTLE_ENDIAN_ORDER\n#endif\n\n\ntypedef unsigned char  byte;\ntypedef unsigned short word16;\ntypedef unsigned int   word32;\n\n#if defined(_MSC_VER) || defined(__BCPLUSPLUS__)\n    #define WORD64_AVAILABLE\n    #define WORD64_IS_DISTINCT_TYPE\n    typedef unsigned __int64 word64;\n    #define W64LIT(x) x##ui64\n#elif SIZEOF_LONG == 8\n    #define WORD64_AVAILABLE\n    typedef unsigned long word64;\n    #define W64LIT(x) x##LL\n#elif SIZEOF_LONG_LONG == 8 \n    #define WORD64_AVAILABLE\n    #define WORD64_IS_DISTINCT_TYPE\n    typedef unsigned long long word64;\n    #define W64LIT(x) x##LL\n#endif\n\n\n// compilers we've found 64-bit multiply insructions for\n#if defined(__GNUC__) || defined(_MSC_VER) || defined(__DECCXX)\n    #if !(defined(__ICC) || defined(__INTEL_COMPILER))\n        #define HAVE_64_MULTIPLY\n    #endif\n#endif\n\n    \n#if defined(HAVE_64_MULTIPLY) && (defined(__ia64__) \\\n    || defined(_ARCH_PPC64) || defined(__mips64)  || defined(__x86_64__) \\\n    || defined(_M_X64) || defined(_M_IA64)) \n// These platforms have 64-bit CPU registers. Unfortunately most C++ compilers\n// don't allow any way to access the 64-bit by 64-bit multiply instruction\n// without using assembly, so in order to use word64 as word, the assembly\n// instruction must be defined in Dword::Multiply().\n    typedef word32 hword;\n    typedef word64 word;\n#else\n    #define TAOCRYPT_NATIVE_DWORD_AVAILABLE\n    #ifdef WORD64_AVAILABLE\n        #define TAOCRYPT_SLOW_WORD64\n        typedef word16 hword;\n        typedef word32 word;\n        typedef word64 dword;\n    #else\n        typedef byte   hword;\n        typedef word16 word;\n        typedef word32 dword;\n    #endif\n#endif\n\nconst word32 WORD_SIZE = sizeof(word);\nconst word32 WORD_BITS = WORD_SIZE * 8;\n\n\n}  // namespace\n\n#endif // TAO_CRYPT_TYPES_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/mySTL/algorithm.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* mySTL algorithm implements max, min, for_each, swap, find_if, copy,\n * copy_backward, fill\n */\n\n#ifndef mySTL_ALGORITHM_HPP\n#define mySTL_ALGORITHM_HPP\n\n\nnamespace mySTL {\n\n\ntemplate<typename T>\ninline const T& max(const T& a, const T&b)\n{\n    return a < b ? b : a;\n}\n\n\ntemplate<typename T>\ninline const T& min(const T& a, const T&b)\n{\n    return b < a ? b : a;\n}\n\n\ntemplate<typename InIter, typename Func>\nFunc for_each(InIter first, InIter last, Func op)\n{\n    while (first != last) {\n        op(*first);\n        ++first;\n    }\n    return op;\n}\n\n\ntemplate<typename T>\ninline void swap(T& a, T& b)\n{\n    T tmp = a;\n    a = b;\n    b = tmp;\n}\n\n\ntemplate<typename InIter, typename Pred>\nInIter find_if(InIter first, InIter last, Pred pred)\n{\n    while (first != last && !pred(*first))\n        ++first;\n    return first;\n}\n\n\ntemplate<typename InputIter, typename OutputIter>\ninline OutputIter copy(InputIter first, InputIter last, OutputIter place)\n{\n    while (first != last) {\n        *place = *first;\n        ++first;\n        ++place;\n    }\n    return place;\n}\n\n\ntemplate<typename InputIter, typename OutputIter>\ninline OutputIter \ncopy_backward(InputIter first, InputIter last, OutputIter place)\n{\n    while (first != last)\n        *--place = *--last;\n    return place;\n}\n\n\ntemplate<typename InputIter, typename T>\nvoid fill(InputIter first, InputIter last, const T& v)\n{\n    while (first != last) {\n        *first = v;\n        ++first;\n    }\n}\n\n\n}  // namespace mySTL\n\n#endif // mySTL_ALGORITHM_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/mySTL/helpers.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* mySTL helpers implements misc constructs for vector and list\n *\n */\n\n#ifndef mySTL_HELPERS_HPP\n#define mySTL_HELPERS_HPP\n\n#include <stdlib.h>\n#ifdef _MSC_VER\n    #include <new>\n#endif\n\n/*\n      Workaround for the lack of operator new(size_t, void*)\n      in IBM VA C++ 6.0\n      Also used as a workaround to avoid including <new>\n*/\n    struct Dummy {};\n\n    inline void* operator new(size_t size, Dummy* d) \n    { \n        return static_cast<void*>(d);\n    }\n\n    // for compilers that want matching delete\n    inline void operator delete(void* ptr, Dummy* d) \n    { \n    }\n\n    typedef Dummy* yassl_pointer;\n\nnamespace mySTL {\n\n\ntemplate <typename T, typename T2>\ninline void construct(T* p, const T2& value)\n{\n    new (reinterpret_cast<yassl_pointer>(p)) T(value);\n}\n\n\ntemplate <typename T>\ninline void construct(T* p)\n{\n    new (reinterpret_cast<yassl_pointer>(p)) T();\n}\n\n\ntemplate <typename T>\ninline void destroy(T* p)\n{\n    p->~T();\n}\n\n\ntemplate <typename Iter>\nvoid destroy(Iter first, Iter last)\n{\n    while (first != last) {\n        destroy(&*first);\n        ++first;\n    }\n}\n\n\ntemplate <typename Iter, typename PlaceIter>\nPlaceIter uninit_copy(Iter first, Iter last, PlaceIter place)\n{\n    while (first != last) {\n        construct(&*place, *first);\n        ++first;\n        ++place;\n    }\n    return place;\n}\n\n\ntemplate <typename PlaceIter, typename Size, typename T>\nPlaceIter uninit_fill_n(PlaceIter place, Size n, const T& value)\n{\n    while (n) {\n        construct(&*place, value);\n        --n;\n        ++place;\n    }\n    return place;\n}\n\n\ntemplate <typename T>\nT* GetArrayMemory(size_t items)\n{\n    unsigned char* ret;\n\n    #ifdef YASSL_LIB\n        ret = NEW_YS unsigned char[sizeof(T) * items];\n    #else\n        ret = NEW_TC unsigned char[sizeof(T) * items];\n    #endif\n\n    return reinterpret_cast<T*>(ret);\n}\n\n\ntemplate <typename T>\nvoid FreeArrayMemory(T* ptr)\n{\n    unsigned char* p = reinterpret_cast<unsigned char*>(ptr);\n\n    #ifdef YASSL_LIB\n        yaSSL::ysArrayDelete(p);\n    #else\n        TaoCrypt::tcArrayDelete(p);\n    #endif\n}\n\n\n\ninline void* GetMemory(size_t bytes)\n{\n    return GetArrayMemory<unsigned char>(bytes);\n}\n\n\ninline void FreeMemory(void* ptr)\n{\n    FreeArrayMemory(ptr);\n}\n\n\n\n} // namespace mySTL\n\n#endif // mySTL_HELPERS_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/mySTL/list.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* mySTL list implements a simple list\n *\n */\n\n#ifndef mySTL_LIST_HPP\n#define mySTL_LIST_HPP\n\n\n#include \"helpers.hpp\"\n\n\nnamespace mySTL {\n\n\n\ntemplate<typename T> \nclass list {\n\n#ifdef __SUNPRO_CC\n/*\n   Sun Forte 7 C++ v. 5.4 needs class 'node' public to be visible to\n   the nested class 'iterator' (a non-standard behaviour).\n*/\npublic:\n#endif\n\n    struct node {\n        node(T t) : prev_(0), next_(0), value_(t) {}\n\n        node* prev_;\n        node* next_;\n        T     value_;\n    };   \npublic:\n    list() : head_(0), tail_(0), sz_(0) {}\n    ~list();\n\n    void   push_front(T);\n    void   pop_front();\n    T      front() const;\n    void   push_back(T);\n    void   pop_back();\n    T      back() const;\n    bool   remove(T);\n    size_t size()  const { return sz_; }\n    bool   empty() const { return sz_ == 0; }\n\n    class iterator {\n        node* current_;\n    public:\n        explicit iterator(node* p = 0) : current_(p) {}\n\n        T& operator*() const\n        {\n            return current_->value_;\n        }\n\n        T* operator->() const\n        {\n            return &(operator*());\n        }\n\n        iterator& operator++()\n        {\n            current_ = current_->next_;\n            return *this;\n        }\n\n        iterator& operator--()\n        {\n            current_ = current_->prev_;\n            return *this;\n        }\n\n        iterator operator++(int)\n        {\n            iterator tmp = *this;\n            current_ = current_->next_;\n            return tmp;\n        }\n\n        iterator operator--(int)\n        {\n            iterator tmp = *this;\n            current_ = current_->prev_;\n            return tmp;\n        }\n\n        bool operator==(const iterator& other) const\n        { \n            return current_ == other.current_;\n        }\n\n        bool operator!=(const iterator& other) const\n        {\n            return current_ != other.current_;\n        }\n\n        friend class list<T>;\n    };\n\n\n    class reverse_iterator {\n        node* current_;\n    public:\n        explicit reverse_iterator(node* p = 0) : current_(p) {}\n\n        T& operator*() const\n        {\n            return current_->value_;\n        }\n\n        T* operator->() const\n        {\n            return &(operator*());\n        }\n\n        reverse_iterator& operator++()\n        {\n            current_ = current_->prev_;\n            return *this;\n        }\n\n        reverse_iterator& operator--()\n        {\n            current_ = current_->next_;\n            return *this;\n        }\n\n        reverse_iterator operator++(int)\n        {\n            reverse_iterator tmp = *this;\n            current_ = current_->prev_;\n            return tmp;\n        }\n\n        reverse_iterator operator--(int)\n        {\n            reverse_iterator tmp = *this;\n            current_ = current_->next_;\n            return tmp;\n        }\n\n        bool operator==(const reverse_iterator& other) const\n        { \n            return current_ == other.current_;\n        }\n\n        bool operator!=(const reverse_iterator& other) const\n        {\n            return current_ != other.current_;\n        }\n\n        friend class list<T>;\n    };\n\n    bool erase(iterator);\n\n    iterator         begin()  const { return iterator(head_); }\n    reverse_iterator rbegin() const { return reverse_iterator(tail_); }\n    iterator         end()    const { return iterator(); }\n    reverse_iterator rend()   const { return reverse_iterator(); }\n\n    typedef iterator const_iterator;    // for now\n\n    class underflow {};\n    class overflow {}; \nprivate:\n    node*  head_;\n    node*  tail_;\n    size_t sz_;\n\n    node* look_up(T);\n\n    list(const list&);            // hide copy\n    list& operator=(const list&); // and assign\n};\n\n\ntemplate<typename T> \nlist<T>::~list()\n{\n    node* start = head_;\n    node* next_;\n\n    for (; start; start = next_) {\n        next_ = start->next_;\n        destroy(start);\n        FreeMemory(start);\n    }\n}\n\n\ntemplate<typename T> \nvoid list<T>::push_front(T t)\n{\n    void* mem = GetMemory(sizeof(node));\n    node* add = new (reinterpret_cast<yassl_pointer>(mem)) node(t);\n\n    if (head_) {\n        add->next_ = head_;\n        head_->prev_ = add;\n    }\n    else\n        tail_ = add;\n\n    head_ = add;\n    ++sz_; \n}\n\n\ntemplate<typename T> \nvoid list<T>::pop_front()\n{\n    node* front = head_;\n\n    if (head_ == 0)\n        return;\n    else if (head_ == tail_)\n        head_ = tail_ = 0;\n    else {\n        head_ = head_->next_;\n        head_->prev_ = 0;\n    }\n    destroy(front);\n    FreeMemory(front);\n    --sz_;\n}\n\n\ntemplate<typename T> \nT list<T>::front() const\n{\n    if (head_ == 0) return T();\n    return head_->value_;\n}\n\n\ntemplate<typename T> \nvoid list<T>::push_back(T t)\n{\n    void* mem = GetMemory(sizeof(node));\n    node* add = new (reinterpret_cast<yassl_pointer>(mem)) node(t);\n\n    if (tail_) {\n        tail_->next_ = add;\n        add->prev_ = tail_;\n    }\n    else\n        head_ = add;\n\n    tail_ = add;\n    ++sz_;\n}\n\n\ntemplate<typename T> \nvoid list<T>::pop_back()\n{\n    node* rear = tail_;\n\n    if (tail_ == 0)\n        return;\n    else if (tail_ == head_)\n        tail_ = head_ = 0;\n    else {\n        tail_ = tail_->prev_;\n        tail_->next_ = 0;\n    }\n    destroy(rear);\n    FreeMemory(rear);\n    --sz_;\n}\n\n\ntemplate<typename T> \nT list<T>::back() const\n{\n    if (tail_ == 0) return T();\n    return tail_->value_;\n}\n\n\ntemplate<typename T>\ntypename list<T>::node* list<T>::look_up(T t)\n{\n    node* list = head_;\n\n    if (list == 0) return 0;\n\n    for (; list; list = list->next_)\n        if (list->value_ == t)\n            return list;\n\n    return 0;\n}\n\n\ntemplate<typename T> \nbool list<T>::remove(T t)\n{\n    node* del = look_up(t);\n\n    if (del == 0)\n        return false;\n    else if (del == head_)\n        pop_front();\n    else if (del == tail_)\n        pop_back();\n    else {\n        del->prev_->next_ = del->next_;\n        del->next_->prev_ = del->prev_;\n\n        destroy(del);\n        FreeMemory(del);\n        --sz_;\n    }\n    return true;\n}\n\n\ntemplate<typename T> \nbool list<T>::erase(iterator iter)\n{\n    node* del = iter.current_;\n\n    if (del == 0)\n        return false;\n    else if (del == head_)\n        pop_front();\n    else if (del == tail_)\n        pop_back();\n    else {\n        del->prev_->next_ = del->next_;\n        del->next_->prev_ = del->prev_;\n\n        destroy(del);\n        FreeMemory(del);\n        --sz_;\n    }\n    return true;\n}\n\n\n\n} // namespace mySTL\n\n#endif // mySTL_LIST_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/mySTL/memory.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* mySTL memory implements auto_ptr\n *\n */\n\n#ifndef mySTL_MEMORY_HPP\n#define mySTL_MEMORY_HPP\n\n#include \"memory_array.hpp\"   // for auto_array\n\n#ifdef _MSC_VER\n    // disable operator-> warning for builtins\n    #pragma warning(disable:4284)\n#endif\n\n\nnamespace mySTL {\n\n\ntemplate<typename T>\nstruct auto_ptr_ref {\n    T* ptr_;\n    explicit auto_ptr_ref(T* p) : ptr_(p) {}\n};\n\n\ntemplate<typename T>\nclass auto_ptr {\n    T*       ptr_;\n\n    void Destroy()\n    {\n        #ifdef YASSL_LIB\n            yaSSL::ysDelete(ptr_);\n        #else\n            TaoCrypt::tcDelete(ptr_);\n        #endif\n    }\npublic:\n    explicit auto_ptr(T* p = 0) : ptr_(p) {}\n\n    ~auto_ptr() \n    {\n        Destroy();\n    }\n\n\n    auto_ptr(auto_ptr& other) : ptr_(other.release()) {}\n\n    auto_ptr& operator=(auto_ptr& that)\n    {\n        if (this != &that) {\n            Destroy();\n            ptr_ = that.release();\n        }\n        return *this;\n    }\n\n\n    T* operator->() const\n    {\n        return ptr_;\n    }\n\n    T& operator*() const\n    {\n        return *ptr_;\n    }\n\n    T* get() const \n    { \n        return ptr_; \n    }\n\n    T* release()\n    {\n        T* tmp = ptr_;\n        ptr_ = 0;\n        return tmp;\n    }\n\n    void reset(T* p = 0)\n    {\n        if (ptr_ != p) {\n            Destroy();\n            ptr_ = p;\n        }\n    }\n\n    // auto_ptr_ref conversions\n    auto_ptr(auto_ptr_ref<T> ref) : ptr_(ref.ptr_) {}\n\n    auto_ptr& operator=(auto_ptr_ref<T> ref)\n    {\n        if (this->ptr_ != ref.ptr_) {\n            Destroy();\n            ptr_ = ref.ptr_;\n        }\n        return *this;\n    }\n\n    template<typename T2>\n    operator auto_ptr<T2>()\n    {\n        return auto_ptr<T2>(this->release());\n    }\n\n    template<typename T2>\n    operator auto_ptr_ref<T2>()\n    {\n        return auto_ptr_ref<T2>(this->release());\n    }\n};\n\n\n} // namespace mySTL\n\n#endif // mySTL_MEMORY_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/mySTL/memory_array.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* mySTL memory_arry implements auto_array\n *\n */\n\n#ifndef mySTL_MEMORY_ARRAY_HPP\n#define mySTL_MEMORY_ARRAY_HPP\n\n\n#ifdef _MSC_VER\n    // disable operator-> warning for builtins\n    #pragma warning(disable:4284)\n#endif\n\n\nnamespace mySTL {\n\n\ntemplate<typename T>\nstruct auto_array_ref {\n    T* ptr_;\n    explicit auto_array_ref(T* p) : ptr_(p) {}\n};\n\n\ntemplate<typename T>\nclass auto_array {\n    T*       ptr_;\n\n    void Destroy()\n    {\n        #ifdef YASSL_LIB\n            yaSSL::ysArrayDelete(ptr_);\n        #else\n            TaoCrypt::tcArrayDelete(ptr_);\n        #endif\n    }\npublic:\n    explicit auto_array(T* p = 0) : ptr_(p) {}\n\n    ~auto_array() \n    {\n        Destroy();\n    }\n\n\n    auto_array(auto_array& other) : ptr_(other.release()) {}\n\n    auto_array& operator=(auto_array& that)\n    {\n        if (this != &that) {\n            Destroy();\n            ptr_ = that.release();\n        }\n        return *this;\n    }\n\n\n    T* operator->() const\n    {\n        return ptr_;\n    }\n\n    T& operator*() const\n    {\n        return *ptr_;\n    }\n\n    T* get() const \n    { \n        return ptr_; \n    }\n\n    T* release()\n    {\n        T* tmp = ptr_;\n        ptr_ = 0;\n        return tmp;\n    }\n\n    void reset(T* p = 0)\n    {\n        if (ptr_ != p) {\n            Destroy();\n            ptr_ = p;\n        }\n    }\n\n    // auto_array_ref conversions\n    auto_array(auto_array_ref<T> ref) : ptr_(ref.ptr_) {}\n\n    auto_array& operator=(auto_array_ref<T> ref)\n    {\n        if (this->ptr_ != ref.ptr_) {\n            Destroy();\n            ptr_ = ref.ptr_;\n        }\n        return *this;\n    }\n\n    template<typename T2>\n    operator auto_array<T2>()\n    {\n        return auto_array<T2>(this->release());\n    }\n\n    template<typename T2>\n    operator auto_array_ref<T2>()\n    {\n        return auto_array_ref<T2>(this->release());\n    }\n};\n\n\n} // namespace mySTL\n\n#endif // mySTL_MEMORY_ARRAY_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/mySTL/pair.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* mySTL pair implements pair\n *\n */\n\n#ifndef mySTL_PAIR_HPP\n#define mySTL_PAIR_HPP\n\n\n\nnamespace mySTL {\n\n\ntemplate<typename T1, typename T2>\nstruct pair {\n    typedef T1 first_type;\n    typedef T2 second_type;\n\n    first_type  first;\n    second_type second;\n\n    pair() {}\n    pair(const T1& t1, const T2& t2) : first(t1), second(t2) {}\n\n    template<typename U1, typename U2>\n    pair(const pair<U1, U2>& p) : first(p.first), second(p.second) {}\n};\n\n\ntemplate<typename T1, typename T2>\ninline pair<T1, T2> make_pair(const T1& a, const T2& b)\n{\n    return pair<T1, T2>(a, b);\n}\n\n\n\n} // namespace mySTL\n\n#endif // mySTL_PAIR_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/mySTL/stdexcept.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* mySTL memory implements exception, runtime_error\n *\n */\n\n#ifndef mySTL_STDEXCEPT_HPP\n#define mySTL_STDEXCEPT_HPP\n\n\n#include <string.h>  // strncpy\n#include <stdlib.h>  // size_t\n\n\nnamespace mySTL {\n\n\nclass exception {\npublic:\n    exception() {}\n    virtual ~exception() {}   // to shut up compiler warnings\n\n    virtual const char* what() const { return \"\"; }\n\n    // for compiler generated call, never used\n    static void operator delete(void*) { }\nprivate:\n    // don't allow dynamic creation of exceptions\n    static void* operator new(size_t);\n};\n\n\nclass named_exception : public exception {\npublic:\n    enum { NAME_SIZE = 80 };\n\n    explicit named_exception(const char* str) \n    {\n        strncpy(name_, str, NAME_SIZE);\n        name_[NAME_SIZE - 1] = 0;\n    }\n\n    virtual const char* what() const { return name_; }\nprivate:\n    char name_[NAME_SIZE];\n};\n\n\nclass runtime_error : public named_exception {\npublic:\n    explicit runtime_error(const char* str) : named_exception(str) {}\n};\n\n\n\n\n} // namespace mySTL\n\n#endif // mySTL_STDEXCEPT_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/mySTL/vector.hpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* mySTL vector implements simple vector, w/ swap\n *\n */\n\n#ifndef mySTL_VECTOR_HPP\n#define mySTL_VECTOR_HPP\n\n#include \"helpers.hpp\"    // construct, destory, fill, etc.\n#include \"algorithm.hpp\"  // swap\n\n\nnamespace mySTL {\n\n\ntemplate <typename T>\nstruct vector_base {\n    T* start_;\n    T* finish_;\n    T* end_of_storage_;\n\n    vector_base() : start_(0), finish_(0), end_of_storage_(0) {}\n    vector_base(size_t n)\n    {\n        start_ = GetArrayMemory<T>(n);\n        finish_ = start_;\n        end_of_storage_ = start_ + n;\n    }\n\n    ~vector_base() \n    { \n        FreeArrayMemory(start_);\n    }\n\n    void Swap(vector_base& that) \n    {\n        swap(start_, that.start_);\n        swap(finish_, that.finish_);\n        swap(end_of_storage_, that.end_of_storage_);\n    }\n};\n\n\n\ntemplate <typename T>\nclass vector {\npublic:\n    typedef T*       iterator;\n    typedef const T* const_iterator;\n\n    vector() {}\n    explicit vector(size_t n) : vec_(n) \n    { \n        vec_.finish_ = uninit_fill_n(vec_.start_, n, T()); \n    }\n\n    ~vector() { destroy(vec_.start_, vec_.finish_); }\n\n    vector(const vector& other) : vec_(other.size())\n    {\n        vec_.finish_ = uninit_copy(other.vec_.start_, other.vec_.finish_,\n                                   vec_.start_);   \n    }\n\n    size_t capacity() const { return vec_.end_of_storage_ - vec_.start_; }\n\n    size_t size() const { return vec_.finish_ - vec_.start_; }\n\n    T&       operator[](size_t idx)       { return *(vec_.start_ + idx); }\n    const T& operator[](size_t idx) const { return *(vec_.start_ + idx); }\n\n    const T* begin() const { return vec_.start_; }\n    const T* end()   const { return vec_.finish_; }\n\n    void push_back(const T& v)\n    {\n        if (vec_.finish_ != vec_.end_of_storage_) {\n            construct(vec_.finish_, v);\n            ++vec_.finish_;\n        }\n        else {\n            vector tmp(size() * 2 + 1, *this);\n            construct(tmp.vec_.finish_, v);\n            ++tmp.vec_.finish_;\n            Swap(tmp);\n        }  \n    }\n\n    void resize(size_t n, const T& v)\n    {\n        if (n == size()) return;\n\n        if (n < size()) {\n            T* first = vec_.start_ + n;\n            destroy(first, vec_.finish_);\n            vec_.finish_ -= vec_.finish_ - first;\n        }\n        else {\n            vector tmp(n, *this);\n            tmp.vec_.finish_ = uninit_fill_n(tmp.vec_.finish_, n - size(), v);\n            Swap(tmp);\n        }\n    }\n\n    void reserve(size_t n)\n    {\n        if (capacity() < n) {\n            vector tmp(n, *this);\n            Swap(tmp);\n        }\n    }\n\n    void Swap(vector& that)\n    {\n        vec_.Swap(that.vec_);\n    }\nprivate:\n    vector_base<T> vec_;\n\n    vector& operator=(const vector&);   // hide assign\n\n    // for growing, n must be bigger than other size\n    vector(size_t n, const vector& other) : vec_(n)\n    {\n        if (n > other.size())\n            vec_.finish_ = uninit_copy(other.vec_.start_, other.vec_.finish_,\n                                       vec_.start_);\n    }\n};\n\n\n\n} // namespace mySTL\n\n#endif // mySTL_VECTOR_HPP\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/aes.cpp",
    "content": "/*\n   Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* C++ based on Wei Dai's aes.cpp from CryptoPP */\n/* x86 asm original */\n\n#if defined(TAOCRYPT_KERNEL_MODE)\n    #define DO_TAOCRYPT_KERNEL_MODE\n#endif                                  // only some modules now support this\n\n#include \"runtime.hpp\"\n#include \"aes.hpp\"\n\n\nnamespace TaoCrypt {\n\n\n#if defined(DO_AES_ASM)\n\n// ia32 optimized version\nvoid AES::Process(byte* out, const byte* in, word32 sz)\n{\n    if (!isMMX) {\n        Mode_BASE::Process(out, in, sz);\n        return;\n    }\n\n    word32 blocks = sz / BLOCK_SIZE;\n\n    if (mode_ == ECB)\n        while (blocks--) {\n            if (dir_ == ENCRYPTION)\n                AsmEncrypt(in, out, (void*)Te0);\n            else\n                AsmDecrypt(in, out, (void*)Td0);               \n            out += BLOCK_SIZE;\n            in  += BLOCK_SIZE;\n        }\n    else if (mode_ == CBC) {\n        if (dir_ == ENCRYPTION) {\n            while (blocks--) {\n                r_[0] ^= *(word32*)in;\n                r_[1] ^= *(word32*)(in +  4);\n                r_[2] ^= *(word32*)(in +  8);\n                r_[3] ^= *(word32*)(in + 12);\n\n                AsmEncrypt((byte*)r_, (byte*)r_, (void*)Te0);\n\n                memcpy(out, r_, BLOCK_SIZE);\n                out += BLOCK_SIZE;\n                in  += BLOCK_SIZE;\n            }\n        }\n        else {\n            while (blocks--) {\n                AsmDecrypt(in, out, (void*)Td0);\n                \n                *(word32*)out        ^= r_[0];\n                *(word32*)(out +  4) ^= r_[1];\n                *(word32*)(out +  8) ^= r_[2];\n                *(word32*)(out + 12) ^= r_[3];\n\n                memcpy(r_, in, BLOCK_SIZE);\n                out += BLOCK_SIZE;\n                in  += BLOCK_SIZE;\n            }\n        }\n    }\n}\n\n#endif // DO_AES_ASM\n\n\nvoid AES::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/)\n{\n    if (keylen <= 16)\n        keylen = 16;\n    else if (keylen >= 32)\n        keylen = 32;\n    else if (keylen != 24)\n        keylen = 24;\n    \n    rounds_ = keylen/4 + 6;\n\n    word32 temp, *rk = key_;\n    unsigned int i=0;\n\n    GetUserKey(BigEndianOrder, rk, keylen/4, userKey, keylen);\n\n    switch(keylen)\n    {\n    case 16:\n        while (true)\n        {\n            temp  = rk[3];\n            rk[4] = rk[0] ^\n                (Te4[GETBYTE(temp, 2)] & 0xff000000) ^\n                (Te4[GETBYTE(temp, 1)] & 0x00ff0000) ^\n                (Te4[GETBYTE(temp, 0)] & 0x0000ff00) ^\n                (Te4[GETBYTE(temp, 3)] & 0x000000ff) ^\n                rcon_[i];\n            rk[5] = rk[1] ^ rk[4];\n            rk[6] = rk[2] ^ rk[5];\n            rk[7] = rk[3] ^ rk[6];\n            if (++i == 10)\n                break;\n            rk += 4;\n        }\n        break;\n\n    case 24:\n        while (true)    // for (;;) here triggers a bug in VC60 SP4 w/ Pro Pack\n        {\n            temp = rk[ 5];\n            rk[ 6] = rk[ 0] ^\n                (Te4[GETBYTE(temp, 2)] & 0xff000000) ^\n                (Te4[GETBYTE(temp, 1)] & 0x00ff0000) ^\n                (Te4[GETBYTE(temp, 0)] & 0x0000ff00) ^\n                (Te4[GETBYTE(temp, 3)] & 0x000000ff) ^\n                rcon_[i];\n            rk[ 7] = rk[ 1] ^ rk[ 6];\n            rk[ 8] = rk[ 2] ^ rk[ 7];\n            rk[ 9] = rk[ 3] ^ rk[ 8];\n            if (++i == 8)\n                break;\n            rk[10] = rk[ 4] ^ rk[ 9];\n            rk[11] = rk[ 5] ^ rk[10];\n            rk += 6;\n        }\n        break;\n\n    case 32:\n        while (true)\n        {\n            temp = rk[ 7];\n            rk[ 8] = rk[ 0] ^\n                (Te4[GETBYTE(temp, 2)] & 0xff000000) ^\n                (Te4[GETBYTE(temp, 1)] & 0x00ff0000) ^\n                (Te4[GETBYTE(temp, 0)] & 0x0000ff00) ^\n                (Te4[GETBYTE(temp, 3)] & 0x000000ff) ^\n                rcon_[i];\n            rk[ 9] = rk[ 1] ^ rk[ 8];\n            rk[10] = rk[ 2] ^ rk[ 9];\n            rk[11] = rk[ 3] ^ rk[10];\n            if (++i == 7)\n                break;\n            temp = rk[11];\n            rk[12] = rk[ 4] ^\n                (Te4[GETBYTE(temp, 3)] & 0xff000000) ^\n                (Te4[GETBYTE(temp, 2)] & 0x00ff0000) ^\n                (Te4[GETBYTE(temp, 1)] & 0x0000ff00) ^\n                (Te4[GETBYTE(temp, 0)] & 0x000000ff);\n            rk[13] = rk[ 5] ^ rk[12];\n            rk[14] = rk[ 6] ^ rk[13];\n            rk[15] = rk[ 7] ^ rk[14];\n\n            rk += 8;\n        }\n        break;\n    }\n\n    if (dir_ == DECRYPTION)\n    {\n        unsigned int i, j;\n        rk = key_;\n\n        /* invert the order of the round keys: */\n        for (i = 0, j = 4*rounds_; i < j; i += 4, j -= 4) {\n            temp = rk[i    ]; rk[i    ] = rk[j    ]; rk[j    ] = temp;\n            temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp;\n            temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp;\n            temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp;\n        }\n        // apply the inverse MixColumn transform to all round keys but the\n        // first and the last:\n        for (i = 1; i < rounds_; i++) {\n            rk += 4;\n            rk[0] =\n                Td0[Te4[GETBYTE(rk[0], 3)] & 0xff] ^\n                Td1[Te4[GETBYTE(rk[0], 2)] & 0xff] ^\n                Td2[Te4[GETBYTE(rk[0], 1)] & 0xff] ^\n                Td3[Te4[GETBYTE(rk[0], 0)] & 0xff];\n            rk[1] =\n                Td0[Te4[GETBYTE(rk[1], 3)] & 0xff] ^\n                Td1[Te4[GETBYTE(rk[1], 2)] & 0xff] ^\n                Td2[Te4[GETBYTE(rk[1], 1)] & 0xff] ^\n                Td3[Te4[GETBYTE(rk[1], 0)] & 0xff];\n            rk[2] =\n                Td0[Te4[GETBYTE(rk[2], 3)] & 0xff] ^\n                Td1[Te4[GETBYTE(rk[2], 2)] & 0xff] ^\n                Td2[Te4[GETBYTE(rk[2], 1)] & 0xff] ^\n                Td3[Te4[GETBYTE(rk[2], 0)] & 0xff];\n            rk[3] =\n                Td0[Te4[GETBYTE(rk[3], 3)] & 0xff] ^\n                Td1[Te4[GETBYTE(rk[3], 2)] & 0xff] ^\n                Td2[Te4[GETBYTE(rk[3], 1)] & 0xff] ^\n                Td3[Te4[GETBYTE(rk[3], 0)] & 0xff];\n        }\n    }\n}\n\n\nvoid AES::ProcessAndXorBlock(const byte* in, const byte* xOr, byte* out) const\n{\n    if (dir_ == ENCRYPTION)\n        encrypt(in, xOr, out);\n    else\n        decrypt(in, xOr, out);\n}\n\n\ntypedef BlockGetAndPut<word32, BigEndian> gpBlock;\n\n\t\nvoid AES::encrypt(const byte* inBlock, const byte* xorBlock,\n                  byte* outBlock) const\n{\n    word32 s0, s1, s2, s3;\n    word32 t0, t1, t2, t3;\n\n    const word32 *rk = key_;\n    /*\n     * map byte array block to cipher state\n     * and add initial round key:\n     */\n    gpBlock::Get(inBlock)(s0)(s1)(s2)(s3);\n    s0 ^= rk[0];\n    s1 ^= rk[1];\n    s2 ^= rk[2];\n    s3 ^= rk[3];\n   \n    /*\n     * Nr - 1 full rounds:\n     */\n\n    unsigned int r = rounds_ >> 1;\n    for (;;) {\n        t0 =\n            Te0[GETBYTE(s0, 3)] ^\n            Te1[GETBYTE(s1, 2)]  ^\n            Te2[GETBYTE(s2, 1)]  ^\n            Te3[GETBYTE(s3, 0)]  ^\n            rk[4];\n        t1 =\n            Te0[GETBYTE(s1, 3)] ^\n            Te1[GETBYTE(s2, 2)]  ^\n            Te2[GETBYTE(s3, 1)]  ^\n            Te3[GETBYTE(s0, 0)]  ^\n            rk[5];\n        t2 =\n            Te0[GETBYTE(s2, 3)] ^\n            Te1[GETBYTE(s3, 2)]  ^\n            Te2[GETBYTE(s0, 1)]  ^\n            Te3[GETBYTE(s1, 0)]  ^\n            rk[6];\n        t3 =\n            Te0[GETBYTE(s3, 3)] ^\n            Te1[GETBYTE(s0, 2)]  ^\n            Te2[GETBYTE(s1, 1)]  ^\n            Te3[GETBYTE(s2, 0)]  ^\n            rk[7];\n\n        rk += 8;\n        if (--r == 0) {\n            break;\n        }\n        \n        s0 =\n            Te0[GETBYTE(t0, 3)] ^\n            Te1[GETBYTE(t1, 2)] ^\n            Te2[GETBYTE(t2, 1)] ^\n            Te3[GETBYTE(t3, 0)] ^\n            rk[0];\n        s1 =\n            Te0[GETBYTE(t1, 3)] ^\n            Te1[GETBYTE(t2, 2)] ^\n            Te2[GETBYTE(t3, 1)] ^\n            Te3[GETBYTE(t0, 0)] ^\n            rk[1];\n        s2 =\n            Te0[GETBYTE(t2, 3)] ^\n            Te1[GETBYTE(t3, 2)] ^\n            Te2[GETBYTE(t0, 1)] ^\n            Te3[GETBYTE(t1, 0)] ^\n            rk[2];\n        s3 =\n            Te0[GETBYTE(t3, 3)] ^\n            Te1[GETBYTE(t0, 2)] ^\n            Te2[GETBYTE(t1, 1)] ^\n            Te3[GETBYTE(t2, 0)] ^\n            rk[3];\n    }\n\n    /*\n     * apply last round and\n     * map cipher state to byte array block:\n     */\n\n    s0 =\n        (Te4[GETBYTE(t0, 3)] & 0xff000000) ^\n        (Te4[GETBYTE(t1, 2)] & 0x00ff0000) ^\n        (Te4[GETBYTE(t2, 1)] & 0x0000ff00) ^\n        (Te4[GETBYTE(t3, 0)] & 0x000000ff) ^\n        rk[0];\n    s1 =\n        (Te4[GETBYTE(t1, 3)] & 0xff000000) ^\n        (Te4[GETBYTE(t2, 2)] & 0x00ff0000) ^\n        (Te4[GETBYTE(t3, 1)] & 0x0000ff00) ^\n        (Te4[GETBYTE(t0, 0)] & 0x000000ff) ^\n        rk[1];\n    s2 =\n        (Te4[GETBYTE(t2, 3)] & 0xff000000) ^\n        (Te4[GETBYTE(t3, 2)] & 0x00ff0000) ^\n        (Te4[GETBYTE(t0, 1)] & 0x0000ff00) ^\n        (Te4[GETBYTE(t1, 0)] & 0x000000ff) ^\n        rk[2];\n    s3 =\n        (Te4[GETBYTE(t3, 3)] & 0xff000000) ^\n        (Te4[GETBYTE(t0, 2)] & 0x00ff0000) ^\n        (Te4[GETBYTE(t1, 1)] & 0x0000ff00) ^\n        (Te4[GETBYTE(t2, 0)] & 0x000000ff) ^\n        rk[3];\n\n\n    gpBlock::Put(xorBlock, outBlock)(s0)(s1)(s2)(s3);\n}\n\n\nvoid AES::decrypt(const byte* inBlock, const byte* xorBlock,\n                  byte* outBlock) const\n{\n    word32 s0, s1, s2, s3;\n    word32 t0, t1, t2, t3;\n    const word32* rk = key_;\n\n    /*\n     * map byte array block to cipher state\n     * and add initial round key:\n     */\n    gpBlock::Get(inBlock)(s0)(s1)(s2)(s3);\n    s0 ^= rk[0];\n    s1 ^= rk[1];\n    s2 ^= rk[2];\n    s3 ^= rk[3];\n\n    /*\n     * Nr - 1 full rounds:\n     */\n\n    unsigned int r = rounds_ >> 1;\n    for (;;) {\n        t0 =\n            Td0[GETBYTE(s0, 3)] ^\n            Td1[GETBYTE(s3, 2)] ^\n            Td2[GETBYTE(s2, 1)] ^\n            Td3[GETBYTE(s1, 0)] ^\n            rk[4];\n        t1 =\n            Td0[GETBYTE(s1, 3)] ^\n            Td1[GETBYTE(s0, 2)] ^\n            Td2[GETBYTE(s3, 1)] ^\n            Td3[GETBYTE(s2, 0)] ^\n            rk[5];\n        t2 =\n            Td0[GETBYTE(s2, 3)] ^\n            Td1[GETBYTE(s1, 2)] ^\n            Td2[GETBYTE(s0, 1)] ^\n            Td3[GETBYTE(s3, 0)] ^\n            rk[6];\n        t3 =\n            Td0[GETBYTE(s3, 3)] ^\n            Td1[GETBYTE(s2, 2)] ^\n            Td2[GETBYTE(s1, 1)] ^\n            Td3[GETBYTE(s0, 0)] ^\n            rk[7];\n\n        rk += 8;\n        if (--r == 0) {\n            break;\n        }\n\n        s0 =\n            Td0[GETBYTE(t0, 3)] ^\n            Td1[GETBYTE(t3, 2)] ^\n            Td2[GETBYTE(t2, 1)] ^\n            Td3[GETBYTE(t1, 0)] ^\n            rk[0];\n        s1 =\n            Td0[GETBYTE(t1, 3)] ^\n            Td1[GETBYTE(t0, 2)] ^\n            Td2[GETBYTE(t3, 1)] ^\n            Td3[GETBYTE(t2, 0)] ^\n            rk[1];\n        s2 =\n            Td0[GETBYTE(t2, 3)] ^\n            Td1[GETBYTE(t1, 2)] ^\n            Td2[GETBYTE(t0, 1)] ^\n            Td3[GETBYTE(t3, 0)] ^\n            rk[2];\n        s3 =\n            Td0[GETBYTE(t3, 3)] ^\n            Td1[GETBYTE(t2, 2)] ^\n            Td2[GETBYTE(t1, 1)] ^\n            Td3[GETBYTE(t0, 0)] ^\n            rk[3];\n    }\n    /*\n     * apply last round and\n     * map cipher state to byte array block:\n     */\n    s0 =\n        (Td4[GETBYTE(t0, 3)] & 0xff000000) ^\n        (Td4[GETBYTE(t3, 2)] & 0x00ff0000) ^\n        (Td4[GETBYTE(t2, 1)] & 0x0000ff00) ^\n        (Td4[GETBYTE(t1, 0)] & 0x000000ff) ^\n        rk[0];\n    s1 =\n        (Td4[GETBYTE(t1, 3)] & 0xff000000) ^\n        (Td4[GETBYTE(t0, 2)] & 0x00ff0000) ^\n        (Td4[GETBYTE(t3, 1)] & 0x0000ff00) ^\n        (Td4[GETBYTE(t2, 0)] & 0x000000ff) ^\n        rk[1];\n    s2 =\n        (Td4[GETBYTE(t2, 3)] & 0xff000000) ^\n        (Td4[GETBYTE(t1, 2)] & 0x00ff0000) ^\n        (Td4[GETBYTE(t0, 1)] & 0x0000ff00) ^\n        (Td4[GETBYTE(t3, 0)] & 0x000000ff) ^\n        rk[2];\n    s3 =\n        (Td4[GETBYTE(t3, 3)] & 0xff000000) ^\n        (Td4[GETBYTE(t2, 2)] & 0x00ff0000) ^\n        (Td4[GETBYTE(t1, 1)] & 0x0000ff00) ^\n        (Td4[GETBYTE(t0, 0)] & 0x000000ff) ^\n        rk[3];\n\n    gpBlock::Put(xorBlock, outBlock)(s0)(s1)(s2)(s3);\n}\n\n\n#if defined(DO_AES_ASM)\n    #ifdef __GNUC__\n        #define AS1(x)    #x \";\"\n        #define AS2(x, y) #x \", \" #y \";\"\n\n        #define PROLOG()  \\\n        __asm__ __volatile__ \\\n        ( \\\n            \".intel_syntax noprefix;\" \\\n            \"push ebx;\" \\\n            \"push ebp;\" \\\n            \"movd mm7, ebp;\" \\\n            \"movd mm4, eax;\" \\\n            \"mov  ebp, edx;\"  \\\n            \"sub  esp, 4;\" \n        #define EPILOG()  \\\n            \"add esp, 4;\" \\\n            \"pop ebp;\" \\\n            \"pop ebx;\" \\\n       \t    \"emms;\" \\\n       \t    \".att_syntax;\" \\\n                : \\\n                : \"c\" (this), \"S\" (inBlock), \"d\" (boxes), \"a\" (outBlock) \\\n                : \"%edi\", \"memory\", \"cc\" \\\n        );\n\n    #else\n        #define AS1(x)    __asm x\n        #define AS2(x, y) __asm x, y\n\n        #define PROLOG() \\\n            AS1(    push  ebp                           )   \\\n            AS2(    mov   ebp, esp                      )   \\\n            AS2(    movd  mm3, edi                      )   \\\n            AS2(    movd  mm4, ebx                      )   \\\n            AS2(    sub   esp, 4                        )   \\\n            AS2(    movd  mm7, ebp                      )   \\\n            AS2(    mov   [ebp - 4], esi                )   \\\n            AS2(    mov   esi, DWORD PTR [ebp +  8]     )   \\\n            AS2(    mov   ebp, DWORD PTR [ebp + 16]     )\n\n        // ebp is restored at end\n        #define EPILOG()  \\\n            AS2(    mov   esi, [ebp - 4]                )   \\\n            AS2(    movd  ebx, mm4                      )   \\\n            AS2(    movd  edi, mm3                      )   \\\n            AS2(    mov   esp, ebp                      )   \\\n            AS1(    pop   ebp                           )   \\\n            AS1(    emms                                )   \\\n            AS1(    ret   12                            )\n            \n            \n    #endif\n\n\n#ifdef _MSC_VER\n    __declspec(naked) \n#else\n    __attribute__ ((noinline))\n#endif\nvoid AES::AsmEncrypt(const byte* inBlock, byte* outBlock, void* boxes) const\n{\n\n    PROLOG()\n\n    #ifdef OLD_GCC_OFFSET\n        AS2(    mov   edx, DWORD PTR [ecx + 60]     )   // rounds\n        AS2(    lea   edi, [ecx + 64]               )   // rk\n    #else\n        AS2(    mov   edx, DWORD PTR [ecx + 56]     )   // rounds\n        AS2(    lea   edi, [ecx + 60]               )   // rk\n    #endif\n\n    AS1(    dec   edx                           )\n    AS2(    movd  mm6, edi                      )   // save rk\n    AS2(    movd  mm5, edx                      )   // save rounds\n  \n    AS2(    mov   eax, DWORD PTR [esi]                                  )\n    AS2(    mov   ebx, DWORD PTR [esi + 4]                              )\n    AS2(    mov   ecx, DWORD PTR [esi + 8]                              )\n    AS2(    mov   edx, DWORD PTR [esi + 12]                             )\n\n    AS1(    bswap eax                                                   )\n    AS1(    bswap ebx                                                   )\n    AS1(    bswap ecx                                                   )\n    AS1(    bswap edx                                                   )\n\n    AS2(    xor   eax, DWORD PTR [edi]               )   // s0\n    AS2(    xor   ebx, DWORD PTR [edi +  4]          )   // s1\n    AS2(    xor   ecx, DWORD PTR [edi +  8]          )   // s2\n    AS2(    xor   edx, DWORD PTR [edi + 12]          )   // s3\n\n#ifdef _MSC_VER\n    AS1( loop1: )  // loop1\n#else\n    AS1(1:  )      // loop1\n#endif\n            /* Put0 (mm0) =  \n                Te0[get0,rs 24] ^\n                Te1[get1,rs 16] ^\n                Te2[get2,rs  8] ^\n                Te3[get3,rs  0]\n            */\n       \n    AS2(    mov   esi, eax                                              )\n    AS2(    shr   esi, 24                                               )\n    AS2(    mov   esi, DWORD PTR [ebp + esi*4]                          )\n                                                    \n    AS2(    mov   edi, ebx                                              )\n    AS2(    shr   edi, 16                                               )\n    AS2(    and   edi, 255                                              )\n    AS2(    xor   esi, DWORD PTR [ebp + 1024 + edi*4]                   )\n\n    AS2(    movzx edi, ch                                               )\n    AS2(    xor   esi, DWORD PTR [ebp + 2048 + edi*4]                   )\n\n    AS2(    movzx edi, dl                                               )\n    AS2(    xor   esi, DWORD PTR [ebp + 3072 + edi*4]                   )\n\n    AS2(    movd  mm0, esi                                              )\n\n             /* Put1 (mm1) =  \n                Te0[get1,rs 24] ^\n                Te1[get2,rs 16] ^\n                Te2[get3,rs  8] ^\n                Te3[get0,rs  0]\n            */\n\n    AS2(    mov   esi, ebx                                              )\n    AS2(    shr   esi, 24                                               )\n    AS2(    mov   esi, DWORD PTR [ebp + esi*4]                          )\n\n    AS2(    mov   edi, ecx                                              )\n    AS2(    shr   edi, 16                                               )\n    AS2(    and   edi, 255                                              )\n    AS2(    xor   esi, DWORD PTR [ebp + 1024 + edi*4]                   )\n\n    AS2(    movzx edi, dh                                               )\n    AS2(    xor   esi, DWORD PTR [ebp + 2048 + edi*4]                   )\n\n    AS2(    movzx edi, al                                               )\n    AS2(    xor   esi, DWORD PTR [ebp + 3072 + edi*4]                   )\n\n    AS2(    movd  mm1, esi                                              )\n\n\n             /* Put2 (mm2) =  \n                Te0[get2,rs 24] ^\n                Te1[get3,rs 16] ^\n                Te2[get0,rs  8] ^\n                Te3[get1,rs  0] \n            */\n\n    AS2(    mov   esi, ecx                                              )\n    AS2(    shr   esi, 24                                               )\n    AS2(    mov   esi, DWORD PTR [ebp + esi*4]                          )\n\n    AS2(    mov   edi, edx                                              )\n    AS2(    shr   edi, 16                                               )\n    AS2(    and   edi, 255                                              )\n    AS2(    xor   esi, DWORD PTR [ebp + 1024 + edi*4]                   )\n\n    AS2(    movzx edi, ah                                               )\n    AS2(    xor   esi, DWORD PTR [ebp + 2048 + edi*4]                   )\n\n    AS2(    movzx edi, bl                                               )\n    AS2(    xor   esi, DWORD PTR [ebp + 3072 + edi*4]                   )\n\n    AS2(    movd  mm2, esi                                              )\n\n             /* Put3 (edx) =  \n                Te0[get3,rs 24] ^\n                Te1[get0,rs 16] ^\n                Te2[get1,rs  8] ^\n                Te3[get2,rs  0] \n            */\n\n    AS2(    mov   esi, edx                                              )\n    AS2(    shr   esi, 24                                               )\n    AS2(    mov   edx, DWORD PTR [ebp + esi*4]                          )\n\n    AS2(    mov   edi, eax                                              )\n    AS2(    shr   edi, 16                                               )\n    AS2(    and   edi, 255                                              )\n    AS2(    xor   edx, DWORD PTR [ebp + 1024 + edi*4]                   )\n\n    AS2(    movzx esi, bh                                               )\n    AS2(    xor   edx, DWORD PTR [ebp + 2048 + esi*4]                   )\n\n    AS2(    movzx edi, cl                                               )\n    AS2(    xor   edx, DWORD PTR [ebp + 3072 + edi*4]                   )\n\n            // xOr\n\n    AS2(    movd   esi, mm6                      )   //  rk\n\n    AS2(    movd   eax, mm0                                             )\n    AS2(    add    esi, 16                                              )\n    AS2(    movd   ebx, mm1                                             )\n    AS2(    movd   mm6, esi                      )   //  save back\n    AS2(    movd   ecx, mm2                                             )\n\n    AS2(    xor   eax, DWORD PTR [esi]                                  )\n    AS2(    xor   ebx, DWORD PTR [esi +  4]                             )\n    AS2(    movd  edi, mm5                                              )\n    AS2(    xor   ecx, DWORD PTR [esi +  8]                             )\n    AS2(    xor   edx, DWORD PTR [esi + 12]                             )\n\n    AS1(    dec   edi                                                   )\n    AS2(    movd  mm5, edi                                              )\n\n#ifdef _MSC_VER\n    AS1(    jnz   loop1)  // loop1\n#else\n    AS1(    jnz   1b )    // loop1\n#endif\n\n            // last round\n            /*\n            Put0 (mm0) =\n                (Te4[get0, rs24] & 0xff000000) ^  h = 4278190080\n                (Te4[get1, rs16] & 0x00ff0000) ^  h =   16711680\n                (Te4[get2, rs 8] & 0x0000ff00) ^  h =      65280\n                (Te4[get3, rs 0] & 0x000000ff)    h =        255\n            */\n    AS2(    mov   esi, eax                                              )\n    AS2(    shr   esi, 24                                               )\n    AS2(    mov   esi, DWORD PTR [ebp + 4096 + esi*4]                   )\n    AS2(    and   esi, 4278190080                                       )\n\n    AS2(    mov   edi, ebx                                              )\n    AS2(    shr   edi, 16                                               )\n    AS2(    and   edi, 255                                              )\n    AS2(    mov   edi, DWORD PTR [ebp + 4096 + edi*4]                   )\n    AS2(    and   edi, 16711680                                         )\n    AS2(    xor   esi, edi                                              )\n\n    AS2(    movzx edi, ch                                               )\n    AS2(    mov   edi, DWORD PTR [ebp + 4096 + edi*4]                   )\n    AS2(    and   edi, 65280                                            )\n    AS2(    xor   esi, edi                                              )\n\n    AS2(    movzx edi, dl                                               )\n    AS2(    mov   edi, DWORD PTR [ebp + 4096 + edi*4]                   )\n    AS2(    and   edi, 255                                              )\n    AS2(    xor   esi, edi                                              )\n\n    AS2(    movd  mm0, esi                                              )\n\n            /*\n            Put1 (mm1) =\n                (Te4[get1, rs24] & 0xff000000) ^  h = 4278190080\n                (Te4[get2, rs16] & 0x00ff0000) ^  h =   16711680\n                (Te4[get3, rs 8] & 0x0000ff00) ^  h =      65280\n                (Te4[get0, rs 0] & 0x000000ff)    h =        255\n            */\n    AS2(    mov   esi, ebx                                              )\n    AS2(    shr   esi, 24                                               )\n    AS2(    mov   esi, DWORD PTR [ebp + 4096 + esi*4]                   )\n    AS2(    and   esi, 4278190080                                       )\n\n    AS2(    mov   edi, ecx                                              )\n    AS2(    shr   edi, 16                                               )\n    AS2(    and   edi, 255                                              )\n    AS2(    mov   edi, DWORD PTR [ebp + 4096 + edi*4]                   )\n    AS2(    and   edi, 16711680                                         )\n    AS2(    xor   esi, edi                                              )\n\n    AS2(    movzx edi, dh                                               )\n    AS2(    mov   edi, DWORD PTR [ebp + 4096 + edi*4]                   )\n    AS2(    and   edi, 65280                                            )\n    AS2(    xor   esi, edi                                              )\n\n    AS2(    movzx edi, al                                               )\n    AS2(    mov   edi, DWORD PTR [ebp + 4096 + edi*4]                   )\n    AS2(    and   edi, 255                                              )\n    AS2(    xor   esi, edi                                              )\n\n    AS2(    movd  mm1, esi                                              )\n\n            /*\n            Put2 (mm2) =\n                (Te4[get2, rs24] & 0xff000000) ^  h = 4278190080\n                (Te4[get3, rs16] & 0x00ff0000) ^  h =   16711680\n                (Te4[get0, rs 8] & 0x0000ff00) ^  h =      65280\n                (Te4[get1, rs 0] & 0x000000ff)    h =        255\n            */\n    AS2(    mov   esi, ecx                                              )\n    AS2(    shr   esi, 24                                               )\n    AS2(    mov   esi, DWORD PTR [ebp + 4096 + esi*4]                   )\n    AS2(    and   esi, 4278190080                                       )\n\n    AS2(    mov   edi, edx                                              )\n    AS2(    shr   edi, 16                                               )\n    AS2(    and   edi, 255                                              )\n    AS2(    mov   edi, DWORD PTR [ebp + 4096 + edi*4]                   )\n    AS2(    and   edi, 16711680                                         )\n    AS2(    xor   esi, edi                                              )\n\n    AS2(    movzx edi, ah                                               )\n    AS2(    mov   edi, DWORD PTR [ebp + 4096 + edi*4]                   )\n    AS2(    and   edi, 65280                                            )\n    AS2(    xor   esi, edi                                              )\n\n    AS2(    movzx edi, bl                                               )\n    AS2(    mov   edi, DWORD PTR [ebp + 4096 + edi*4]                   )\n    AS2(    and   edi, 255                                              )\n    AS2(    xor   esi, edi                                              )\n\n    AS2(    movd  mm2, esi                                              )\n\n            /*\n            Put3 (edx) =\n                (Te4[get3, rs24] & 0xff000000) ^  h = 4278190080\n                (Te4[get0, rs16] & 0x00ff0000) ^  h =   16711680\n                (Te4[get1, rs 8] & 0x0000ff00) ^  h =      65280\n                (Te4[get2, rs 0] & 0x000000ff)    h =        255\n            */\n    AS2(    mov   esi, edx                                              )\n    AS2(    shr   esi, 24                                               )\n    AS2(    mov   edx, DWORD PTR [ebp + 4096 + esi*4]                   )\n    AS2(    and   edx, 4278190080                                       )\n\n    AS2(    mov   edi, eax                                              )\n    AS2(    shr   edi, 16                                               )\n    AS2(    and   edi, 255                                              )\n    AS2(    mov   esi, DWORD PTR [ebp + 4096 + edi*4]                   )\n    AS2(    and   esi, 16711680                                         )\n    AS2(    xor   edx, esi                                              )\n\n    AS2(    movzx esi, bh                                               )\n    AS2(    mov   edi, DWORD PTR [ebp + 4096 + esi*4]                   )\n    AS2(    and   edi, 65280                                            )\n    AS2(    xor   edx, edi                                              )\n\n    AS2(    movzx edi, cl                                               )\n    AS2(    mov   esi, DWORD PTR [ebp + 4096 + edi*4]                   )\n    AS2(    and   esi, 255                                              )\n    AS2(    xor   edx, esi                                              )\n\n    \n            // xOr\n    AS2(    movd   eax, mm0                                             )\n    AS2(    movd   esi, mm6                      )   //  rk\n    AS2(    movd   ebx, mm1                                             )\n    AS2(    add    esi, 16                                               )\n    AS2(    movd   ecx, mm2                                             )\n\n    AS2(    xor   eax, DWORD PTR [esi]                                  )\n    AS2(    xor   ebx, DWORD PTR [esi +  4]                             )\n    AS2(    xor   ecx, DWORD PTR [esi +  8]                             )\n    AS2(    xor   edx, DWORD PTR [esi + 12]                             )\n\n    // end\n    AS2(    movd  ebp, mm7                                              )\n\n            // swap\n    AS1(    bswap eax                                                   )\n    AS1(    bswap ebx                                                   )\n\n            // store\n    #ifdef __GNUC__\n        AS2(    movd esi, mm4                       )   //  outBlock\n    #else\n        AS2(    mov  esi, DWORD PTR [ebp + 12]      )   //  outBlock\n    #endif\n\n    AS1(    bswap ecx                                                   )\n    AS1(    bswap edx                                                   )\n\n    AS2(    mov DWORD PTR [esi],      eax                               )\n    AS2(    mov DWORD PTR [esi +  4], ebx                               )\n    AS2(    mov DWORD PTR [esi +  8], ecx                               )\n    AS2(    mov DWORD PTR [esi + 12], edx                               )\n\n\n    EPILOG()\n}\n\n\n#ifdef _MSC_VER\n    __declspec(naked) \n#else\n    __attribute__ ((noinline))\n#endif\nvoid AES::AsmDecrypt(const byte* inBlock, byte* outBlock, void* boxes) const\n{\n\n    PROLOG()\n\n    #ifdef OLD_GCC_OFFSET\n        AS2(    mov   edx, DWORD PTR [ecx + 60]     )   // rounds\n        AS2(    lea   edi, [ecx + 64]               )   // rk \n    #else\n        AS2(    mov   edx, DWORD PTR [ecx + 56]     )   // rounds\n        AS2(    lea   edi, [ecx + 60]               )   // rk \n    #endif\n   \n    AS1(    dec   edx                           )\n    AS2(    movd  mm6, edi                      )   // save rk\n    AS2(    movd  mm5, edx                      )   // save rounds\n\n    AS2(    mov   eax, DWORD PTR [esi]                                  )\n    AS2(    mov   ebx, DWORD PTR [esi + 4]                              )\n    AS2(    mov   ecx, DWORD PTR [esi + 8]                              )\n    AS2(    mov   edx, DWORD PTR [esi + 12]                             )\n\n    AS1(    bswap eax                                                   )\n    AS1(    bswap ebx                                                   )\n    AS1(    bswap ecx                                                   )\n    AS1(    bswap edx                                                   )\n\n    AS2(    xor   eax, DWORD PTR [edi]               )   // s0\n    AS2(    xor   ebx, DWORD PTR [edi +  4]          )   // s1\n    AS2(    xor   ecx, DWORD PTR [edi +  8]          )   // s2\n    AS2(    xor   edx, DWORD PTR [edi + 12]          )   // s3\n\n\n#ifdef _MSC_VER\n    AS1( loop2: )  // loop2\n#else\n    AS1(2:  )      // loop2\n#endif\n       /*   Put0 (mm0) =\n            Td0[GETBYTE(get0, rs24)] ^\n            Td1[GETBYTE(get3, rs16)] ^\n            Td2[GETBYTE(get2, rs 8)] ^\n            Td3[GETBYTE(tet1,     )]  \n        */\n    AS2(    mov   esi, eax                                              )\n    AS2(    shr   esi, 24                                               )\n    AS2(    mov   esi, DWORD PTR [ebp + esi*4]                          )\n                                                    \n    AS2(    mov   edi, edx                                              )\n    AS2(    shr   edi, 16                                               )\n    AS2(    and   edi, 255                                              )\n    AS2(    xor   esi, DWORD PTR [ebp + 1024 + edi*4]                   )\n\n    AS2(    movzx edi, ch                                               )\n    AS2(    xor   esi, DWORD PTR [ebp + 2048 + edi*4]                   )\n\n    AS2(    movzx edi, bl                                               )\n    AS2(    xor   esi, DWORD PTR [ebp + 3072 + edi*4]                   )\n\n    AS2(    movd  mm0, esi                                              )\n\n      /*    Put1 (mm1) =\n            Td0[GETBYTE(get1, rs24)] ^\n            Td1[GETBYTE(get0, rs16)] ^\n            Td2[GETBYTE(get3, rs 8)] ^\n            Td3[GETBYTE(tet2,     )]  \n        */\n    AS2(    mov   esi, ebx                                              )\n    AS2(    shr   esi, 24                                               )\n    AS2(    mov   esi, DWORD PTR [ebp + esi*4]                          )\n                                                    \n    AS2(    mov   edi, eax                                              )\n    AS2(    shr   edi, 16                                               )\n    AS2(    and   edi, 255                                              )\n    AS2(    xor   esi, DWORD PTR [ebp + 1024 + edi*4]                   )\n\n    AS2(    movzx edi, dh                                               )\n    AS2(    xor   esi, DWORD PTR [ebp + 2048 + edi*4]                   )\n\n    AS2(    movzx edi, cl                                               )\n    AS2(    xor   esi, DWORD PTR [ebp + 3072 + edi*4]                   )\n\n    AS2(    movd  mm1, esi                                              )\n\n      /*    Put2 (mm2) =\n            Td0[GETBYTE(get2, rs24)] ^\n            Td1[GETBYTE(get1, rs16)] ^\n            Td2[GETBYTE(get0, rs 8)] ^\n            Td3[GETBYTE(tet3,     )]  \n      */\n    AS2(    mov   esi, ecx                                              )\n    AS2(    shr   esi, 24                                               )\n    AS2(    mov   esi, DWORD PTR [ebp + esi*4]                          )\n                                                    \n    AS2(    mov   edi, ebx                                              )\n    AS2(    shr   edi, 16                                               )\n    AS2(    and   edi, 255                                              )\n    AS2(    xor   esi, DWORD PTR [ebp + 1024 + edi*4]                   )\n\n    AS2(    movzx edi, ah                                               )\n    AS2(    xor   esi, DWORD PTR [ebp + 2048 + edi*4]                   )\n\n    AS2(    movzx edi, dl                                               )\n    AS2(    xor   esi, DWORD PTR [ebp + 3072 + edi*4]                   )\n\n    AS2(    movd  mm2, esi                                              )\n\n      /*    Put3 (edx) =\n            Td0[GETBYTE(get3, rs24)] ^\n            Td1[GETBYTE(get2, rs16)] ^\n            Td2[GETBYTE(get1, rs 8)] ^\n            Td3[GETBYTE(tet0,     )]  \n      */\n    AS2(    mov   esi, edx                                              )\n    AS2(    shr   esi, 24                                               )\n    AS2(    mov   edx, DWORD PTR [ebp + esi*4]                          )\n                                                    \n    AS2(    mov   edi, ecx                                              )\n    AS2(    shr   edi, 16                                               )\n    AS2(    and   edi, 255                                              )\n    AS2(    xor   edx, DWORD PTR [ebp + 1024 + edi*4]                   )\n\n    AS2(    movzx esi, bh                                               )\n    AS2(    xor   edx, DWORD PTR [ebp + 2048 + esi*4]                   )\n\n    AS2(    movzx edi, al                                               )\n    AS2(    xor   edx, DWORD PTR [ebp + 3072 + edi*4]                   )\n\n\n            // xOr\n\n    AS2(    movd  esi, mm6                      )   //  rk\n    AS2(    add   esi, 16                                               )\n    AS2(    movd  mm6, esi                      )   //  save back\n\n    AS2(    movd  eax, mm0                                              )\n    AS2(    movd  ebx, mm1                                              )\n    AS2(    movd  ecx, mm2                                              )\n\n    AS2(    xor   eax, DWORD PTR [esi]                                  )\n    AS2(    xor   ebx, DWORD PTR [esi +  4]                             )\n    AS2(    xor   ecx, DWORD PTR [esi +  8]                             )\n    AS2(    xor   edx, DWORD PTR [esi + 12]                             )\n\n    AS2(    movd  edi, mm5                                              )\n    AS1(    dec   edi                                                   )\n    AS2(    movd  mm5, edi                                              )\n\n#ifdef _MSC_VER\n    AS1(    jnz   loop2)  // loop2\n#else\n    AS1(    jnz   2b )    // loop2\n#endif\n\n            // last round\n            /*\n            Put0 (mm0) =\n                (Td4[get0, rs24] & 0xff000000) ^  h = 4278190080\n                (Td4[get3, rs16] & 0x00ff0000) ^  h =   16711680\n                (Td4[get2, rs 8] & 0x0000ff00) ^  h =      65280\n                (Td4[get1, rs 0] & 0x000000ff)    h =        255\n            */\n    AS2(    mov   esi, eax                                              )\n    AS2(    shr   esi, 24                                               )\n    AS2(    mov   esi, DWORD PTR [ebp + 4096 + esi*4]                   )\n    AS2(    and   esi, 4278190080                                       )\n\n    AS2(    mov   edi, edx                                              )\n    AS2(    shr   edi, 16                                               )\n    AS2(    and   edi, 255                                              )\n    AS2(    mov   edi, DWORD PTR [ebp + 4096 + edi*4]                   )\n    AS2(    and   edi, 16711680                                         )\n    AS2(    xor   esi, edi                                              )\n\n    AS2(    movzx edi, ch                                               )\n    AS2(    mov   edi, DWORD PTR [ebp + 4096 + edi*4]                   )\n    AS2(    and   edi, 65280                                            )\n    AS2(    xor   esi, edi                                              )\n\n    AS2(    movzx edi, bl                                               )\n    AS2(    mov   edi, DWORD PTR [ebp + 4096 + edi*4]                   )\n    AS2(    and   edi, 255                                              )\n    AS2(    xor   esi, edi                                              )\n\n    AS2(    movd  mm0, esi                                              )\n\n            /*\n            Put1 (mm1) =\n                (Td4[get1, rs24] & 0xff000000) ^  h = 4278190080\n                (Td4[get0, rs16] & 0x00ff0000) ^  h =   16711680\n                (Td4[get3, rs 8] & 0x0000ff00) ^  h =      65280\n                (Td4[get2, rs 0] & 0x000000ff)    h =        255\n            */\n    AS2(    mov   esi, ebx                                              )\n    AS2(    shr   esi, 24                                               )\n    AS2(    mov   esi, DWORD PTR [ebp + 4096 + esi*4]                   )\n    AS2(    and   esi, 4278190080                                       )\n\n    AS2(    mov   edi, eax                                              )\n    AS2(    shr   edi, 16                                               )\n    AS2(    and   edi, 255                                              )\n    AS2(    mov   edi, DWORD PTR [ebp + 4096 + edi*4]                   )\n    AS2(    and   edi, 16711680                                         )\n    AS2(    xor   esi, edi                                              )\n\n    AS2(    movzx edi, dh                                               )\n    AS2(    mov   edi, DWORD PTR [ebp + 4096 + edi*4]                   )\n    AS2(    and   edi, 65280                                            )\n    AS2(    xor   esi, edi                                              )\n\n    AS2(    movzx edi, cl                                               )\n    AS2(    mov   edi, DWORD PTR [ebp + 4096 + edi*4]                   )\n    AS2(    and   edi, 255                                              )\n    AS2(    xor   esi, edi                                              )\n\n    AS2(    movd  mm1, esi                                              )\n\n            /*\n            Put2 (mm2) =\n                (Td4[get2, rs24] & 0xff000000) ^  h = 4278190080\n                (Td4[get1, rs16] & 0x00ff0000) ^  h =   16711680\n                (Td4[get0, rs 8] & 0x0000ff00) ^  h =      65280\n                (Td4[get3, rs 0] & 0x000000ff)    h =        255\n            */\n    AS2(    mov   esi, ecx                                              )\n    AS2(    shr   esi, 24                                               )\n    AS2(    mov   esi, DWORD PTR [ebp + 4096 + esi*4]                   )\n    AS2(    and   esi, 4278190080                                       )\n\n    AS2(    mov   edi, ebx                                              )\n    AS2(    shr   edi, 16                                               )\n    AS2(    and   edi, 255                                              )\n    AS2(    mov   edi, DWORD PTR [ebp + 4096 + edi*4]                   )\n    AS2(    and   edi, 16711680                                         )\n    AS2(    xor   esi, edi                                              )\n\n    AS2(    movzx edi, ah                                               )\n    AS2(    mov   edi, DWORD PTR [ebp + 4096 + edi*4]                   )\n    AS2(    and   edi, 65280                                            )\n    AS2(    xor   esi, edi                                              )\n\n    AS2(    movzx edi, dl                                               )\n    AS2(    mov   edi, DWORD PTR [ebp + 4096 + edi*4]                   )\n    AS2(    and   edi, 255                                              )\n    AS2(    xor   esi, edi                                              )\n\n    AS2(    movd  mm2, esi                                              )\n\n            /*\n            Put3 (edx) =\n                (Td4[get3, rs24] & 0xff000000) ^  h = 4278190080\n                (Td4[get2, rs16] & 0x00ff0000) ^  h =   16711680\n                (Td4[get1, rs 8] & 0x0000ff00) ^  h =      65280\n                (Td4[get0, rs 0] & 0x000000ff)    h =        255\n            */\n    AS2(    mov   esi, edx                                              )\n    AS2(    shr   esi, 24                                               )\n    AS2(    mov   edx, DWORD PTR [ebp + 4096 + esi*4]                   )\n    AS2(    and   edx, 4278190080                                       )\n\n    AS2(    mov   edi, ecx                                              )\n    AS2(    shr   edi, 16                                               )\n    AS2(    and   edi, 255                                              )\n    AS2(    mov   esi, DWORD PTR [ebp + 4096 + edi*4]                   )\n    AS2(    and   esi, 16711680                                         )\n    AS2(    xor   edx, esi                                              )\n\n    AS2(    movzx esi, bh                                               )\n    AS2(    mov   edi, DWORD PTR [ebp + 4096 + esi*4]                   )\n    AS2(    and   edi, 65280                                            )\n    AS2(    xor   edx, edi                                              )\n\n    AS2(    movzx edi, al                                               )\n    AS2(    mov   esi, DWORD PTR [ebp + 4096 + edi*4]                   )\n    AS2(    and   esi, 255                                              )\n    AS2(    xor   edx, esi                                              )\n\n\n            // xOr\n    AS2(    movd  esi, mm6                      )   //  rk\n    AS2(    add   esi, 16                                               )\n\n    AS2(    movd   eax, mm0                                             )\n    AS2(    movd   ebx, mm1                                             )\n    AS2(    movd   ecx, mm2                                             )\n\n    AS2(    xor   eax, DWORD PTR [esi]                                  )\n    AS2(    xor   ebx, DWORD PTR [esi +  4]                             )\n    AS2(    xor   ecx, DWORD PTR [esi +  8]                             )\n    AS2(    xor   edx, DWORD PTR [esi + 12]                             )\n\n    // end\n    AS2(    movd  ebp, mm7                                              )\n\n            // swap\n    AS1(    bswap eax                                                   )\n    AS1(    bswap ebx                                                   )\n    AS1(    bswap ecx                                                   )\n    AS1(    bswap edx                                                   )\n\n            // store\n    #ifdef __GNUC__\n        AS2(    movd esi, mm4                        )   //  outBlock\n    #else\n        AS2(    mov esi,  DWORD PTR [ebp + 12]       )   //  outBlock\n    #endif\n    AS2(    mov DWORD PTR [esi],      eax                               )\n    AS2(    mov DWORD PTR [esi +  4], ebx                               )\n    AS2(    mov DWORD PTR [esi +  8], ecx                               )\n    AS2(    mov DWORD PTR [esi + 12], edx                               )\n\n\n    EPILOG()\n}\n\n\n\n#endif // defined(DO_AES_ASM)\n\n\n\nconst word32 AES::Te[5][256] = {\n{\n    0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU,\n    0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U,\n    0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU,\n    0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU,\n    0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U,\n    0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU,\n    0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU,\n    0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU,\n    0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU,\n    0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU,\n    0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U,\n    0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU,\n    0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU,\n    0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U,\n    0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU,\n    0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU,\n    0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU,\n    0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU,\n    0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU,\n    0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U,\n    0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU,\n    0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU,\n    0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU,\n    0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU,\n    0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U,\n    0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U,\n    0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U,\n    0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U,\n    0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU,\n    0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U,\n    0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U,\n    0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU,\n    0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU,\n    0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U,\n    0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U,\n    0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U,\n    0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU,\n    0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U,\n    0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU,\n    0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U,\n    0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU,\n    0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U,\n    0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U,\n    0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU,\n    0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U,\n    0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U,\n    0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U,\n    0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U,\n    0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U,\n    0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U,\n    0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U,\n    0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U,\n    0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU,\n    0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U,\n    0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U,\n    0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U,\n    0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U,\n    0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U,\n    0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U,\n    0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU,\n    0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U,\n    0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U,\n    0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U,\n    0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU,\n},\n{\n    0xa5c66363U, 0x84f87c7cU, 0x99ee7777U, 0x8df67b7bU,\n    0x0dfff2f2U, 0xbdd66b6bU, 0xb1de6f6fU, 0x5491c5c5U,\n    0x50603030U, 0x03020101U, 0xa9ce6767U, 0x7d562b2bU,\n    0x19e7fefeU, 0x62b5d7d7U, 0xe64dababU, 0x9aec7676U,\n    0x458fcacaU, 0x9d1f8282U, 0x4089c9c9U, 0x87fa7d7dU,\n    0x15effafaU, 0xebb25959U, 0xc98e4747U, 0x0bfbf0f0U,\n    0xec41adadU, 0x67b3d4d4U, 0xfd5fa2a2U, 0xea45afafU,\n    0xbf239c9cU, 0xf753a4a4U, 0x96e47272U, 0x5b9bc0c0U,\n    0xc275b7b7U, 0x1ce1fdfdU, 0xae3d9393U, 0x6a4c2626U,\n    0x5a6c3636U, 0x417e3f3fU, 0x02f5f7f7U, 0x4f83ccccU,\n    0x5c683434U, 0xf451a5a5U, 0x34d1e5e5U, 0x08f9f1f1U,\n    0x93e27171U, 0x73abd8d8U, 0x53623131U, 0x3f2a1515U,\n    0x0c080404U, 0x5295c7c7U, 0x65462323U, 0x5e9dc3c3U,\n    0x28301818U, 0xa1379696U, 0x0f0a0505U, 0xb52f9a9aU,\n    0x090e0707U, 0x36241212U, 0x9b1b8080U, 0x3ddfe2e2U,\n    0x26cdebebU, 0x694e2727U, 0xcd7fb2b2U, 0x9fea7575U,\n    0x1b120909U, 0x9e1d8383U, 0x74582c2cU, 0x2e341a1aU,\n    0x2d361b1bU, 0xb2dc6e6eU, 0xeeb45a5aU, 0xfb5ba0a0U,\n    0xf6a45252U, 0x4d763b3bU, 0x61b7d6d6U, 0xce7db3b3U,\n    0x7b522929U, 0x3edde3e3U, 0x715e2f2fU, 0x97138484U,\n    0xf5a65353U, 0x68b9d1d1U, 0x00000000U, 0x2cc1ededU,\n    0x60402020U, 0x1fe3fcfcU, 0xc879b1b1U, 0xedb65b5bU,\n    0xbed46a6aU, 0x468dcbcbU, 0xd967bebeU, 0x4b723939U,\n    0xde944a4aU, 0xd4984c4cU, 0xe8b05858U, 0x4a85cfcfU,\n    0x6bbbd0d0U, 0x2ac5efefU, 0xe54faaaaU, 0x16edfbfbU,\n    0xc5864343U, 0xd79a4d4dU, 0x55663333U, 0x94118585U,\n    0xcf8a4545U, 0x10e9f9f9U, 0x06040202U, 0x81fe7f7fU,\n    0xf0a05050U, 0x44783c3cU, 0xba259f9fU, 0xe34ba8a8U,\n    0xf3a25151U, 0xfe5da3a3U, 0xc0804040U, 0x8a058f8fU,\n    0xad3f9292U, 0xbc219d9dU, 0x48703838U, 0x04f1f5f5U,\n    0xdf63bcbcU, 0xc177b6b6U, 0x75afdadaU, 0x63422121U,\n    0x30201010U, 0x1ae5ffffU, 0x0efdf3f3U, 0x6dbfd2d2U,\n    0x4c81cdcdU, 0x14180c0cU, 0x35261313U, 0x2fc3ececU,\n    0xe1be5f5fU, 0xa2359797U, 0xcc884444U, 0x392e1717U,\n    0x5793c4c4U, 0xf255a7a7U, 0x82fc7e7eU, 0x477a3d3dU,\n    0xacc86464U, 0xe7ba5d5dU, 0x2b321919U, 0x95e67373U,\n    0xa0c06060U, 0x98198181U, 0xd19e4f4fU, 0x7fa3dcdcU,\n    0x66442222U, 0x7e542a2aU, 0xab3b9090U, 0x830b8888U,\n    0xca8c4646U, 0x29c7eeeeU, 0xd36bb8b8U, 0x3c281414U,\n    0x79a7dedeU, 0xe2bc5e5eU, 0x1d160b0bU, 0x76addbdbU,\n    0x3bdbe0e0U, 0x56643232U, 0x4e743a3aU, 0x1e140a0aU,\n    0xdb924949U, 0x0a0c0606U, 0x6c482424U, 0xe4b85c5cU,\n    0x5d9fc2c2U, 0x6ebdd3d3U, 0xef43acacU, 0xa6c46262U,\n    0xa8399191U, 0xa4319595U, 0x37d3e4e4U, 0x8bf27979U,\n    0x32d5e7e7U, 0x438bc8c8U, 0x596e3737U, 0xb7da6d6dU,\n    0x8c018d8dU, 0x64b1d5d5U, 0xd29c4e4eU, 0xe049a9a9U,\n    0xb4d86c6cU, 0xfaac5656U, 0x07f3f4f4U, 0x25cfeaeaU,\n    0xafca6565U, 0x8ef47a7aU, 0xe947aeaeU, 0x18100808U,\n    0xd56fbabaU, 0x88f07878U, 0x6f4a2525U, 0x725c2e2eU,\n    0x24381c1cU, 0xf157a6a6U, 0xc773b4b4U, 0x5197c6c6U,\n    0x23cbe8e8U, 0x7ca1ddddU, 0x9ce87474U, 0x213e1f1fU,\n    0xdd964b4bU, 0xdc61bdbdU, 0x860d8b8bU, 0x850f8a8aU,\n    0x90e07070U, 0x427c3e3eU, 0xc471b5b5U, 0xaacc6666U,\n    0xd8904848U, 0x05060303U, 0x01f7f6f6U, 0x121c0e0eU,\n    0xa3c26161U, 0x5f6a3535U, 0xf9ae5757U, 0xd069b9b9U,\n    0x91178686U, 0x5899c1c1U, 0x273a1d1dU, 0xb9279e9eU,\n    0x38d9e1e1U, 0x13ebf8f8U, 0xb32b9898U, 0x33221111U,\n    0xbbd26969U, 0x70a9d9d9U, 0x89078e8eU, 0xa7339494U,\n    0xb62d9b9bU, 0x223c1e1eU, 0x92158787U, 0x20c9e9e9U,\n    0x4987ceceU, 0xffaa5555U, 0x78502828U, 0x7aa5dfdfU,\n    0x8f038c8cU, 0xf859a1a1U, 0x80098989U, 0x171a0d0dU,\n    0xda65bfbfU, 0x31d7e6e6U, 0xc6844242U, 0xb8d06868U,\n    0xc3824141U, 0xb0299999U, 0x775a2d2dU, 0x111e0f0fU,\n    0xcb7bb0b0U, 0xfca85454U, 0xd66dbbbbU, 0x3a2c1616U,\n},\n{\n    0x63a5c663U, 0x7c84f87cU, 0x7799ee77U, 0x7b8df67bU,\n    0xf20dfff2U, 0x6bbdd66bU, 0x6fb1de6fU, 0xc55491c5U,\n    0x30506030U, 0x01030201U, 0x67a9ce67U, 0x2b7d562bU,\n    0xfe19e7feU, 0xd762b5d7U, 0xabe64dabU, 0x769aec76U,\n    0xca458fcaU, 0x829d1f82U, 0xc94089c9U, 0x7d87fa7dU,\n    0xfa15effaU, 0x59ebb259U, 0x47c98e47U, 0xf00bfbf0U,\n    0xadec41adU, 0xd467b3d4U, 0xa2fd5fa2U, 0xafea45afU,\n    0x9cbf239cU, 0xa4f753a4U, 0x7296e472U, 0xc05b9bc0U,\n    0xb7c275b7U, 0xfd1ce1fdU, 0x93ae3d93U, 0x266a4c26U,\n    0x365a6c36U, 0x3f417e3fU, 0xf702f5f7U, 0xcc4f83ccU,\n    0x345c6834U, 0xa5f451a5U, 0xe534d1e5U, 0xf108f9f1U,\n    0x7193e271U, 0xd873abd8U, 0x31536231U, 0x153f2a15U,\n    0x040c0804U, 0xc75295c7U, 0x23654623U, 0xc35e9dc3U,\n    0x18283018U, 0x96a13796U, 0x050f0a05U, 0x9ab52f9aU,\n    0x07090e07U, 0x12362412U, 0x809b1b80U, 0xe23ddfe2U,\n    0xeb26cdebU, 0x27694e27U, 0xb2cd7fb2U, 0x759fea75U,\n    0x091b1209U, 0x839e1d83U, 0x2c74582cU, 0x1a2e341aU,\n    0x1b2d361bU, 0x6eb2dc6eU, 0x5aeeb45aU, 0xa0fb5ba0U,\n    0x52f6a452U, 0x3b4d763bU, 0xd661b7d6U, 0xb3ce7db3U,\n    0x297b5229U, 0xe33edde3U, 0x2f715e2fU, 0x84971384U,\n    0x53f5a653U, 0xd168b9d1U, 0x00000000U, 0xed2cc1edU,\n    0x20604020U, 0xfc1fe3fcU, 0xb1c879b1U, 0x5bedb65bU,\n    0x6abed46aU, 0xcb468dcbU, 0xbed967beU, 0x394b7239U,\n    0x4ade944aU, 0x4cd4984cU, 0x58e8b058U, 0xcf4a85cfU,\n    0xd06bbbd0U, 0xef2ac5efU, 0xaae54faaU, 0xfb16edfbU,\n    0x43c58643U, 0x4dd79a4dU, 0x33556633U, 0x85941185U,\n    0x45cf8a45U, 0xf910e9f9U, 0x02060402U, 0x7f81fe7fU,\n    0x50f0a050U, 0x3c44783cU, 0x9fba259fU, 0xa8e34ba8U,\n    0x51f3a251U, 0xa3fe5da3U, 0x40c08040U, 0x8f8a058fU,\n    0x92ad3f92U, 0x9dbc219dU, 0x38487038U, 0xf504f1f5U,\n    0xbcdf63bcU, 0xb6c177b6U, 0xda75afdaU, 0x21634221U,\n    0x10302010U, 0xff1ae5ffU, 0xf30efdf3U, 0xd26dbfd2U,\n    0xcd4c81cdU, 0x0c14180cU, 0x13352613U, 0xec2fc3ecU,\n    0x5fe1be5fU, 0x97a23597U, 0x44cc8844U, 0x17392e17U,\n    0xc45793c4U, 0xa7f255a7U, 0x7e82fc7eU, 0x3d477a3dU,\n    0x64acc864U, 0x5de7ba5dU, 0x192b3219U, 0x7395e673U,\n    0x60a0c060U, 0x81981981U, 0x4fd19e4fU, 0xdc7fa3dcU,\n    0x22664422U, 0x2a7e542aU, 0x90ab3b90U, 0x88830b88U,\n    0x46ca8c46U, 0xee29c7eeU, 0xb8d36bb8U, 0x143c2814U,\n    0xde79a7deU, 0x5ee2bc5eU, 0x0b1d160bU, 0xdb76addbU,\n    0xe03bdbe0U, 0x32566432U, 0x3a4e743aU, 0x0a1e140aU,\n    0x49db9249U, 0x060a0c06U, 0x246c4824U, 0x5ce4b85cU,\n    0xc25d9fc2U, 0xd36ebdd3U, 0xacef43acU, 0x62a6c462U,\n    0x91a83991U, 0x95a43195U, 0xe437d3e4U, 0x798bf279U,\n    0xe732d5e7U, 0xc8438bc8U, 0x37596e37U, 0x6db7da6dU,\n    0x8d8c018dU, 0xd564b1d5U, 0x4ed29c4eU, 0xa9e049a9U,\n    0x6cb4d86cU, 0x56faac56U, 0xf407f3f4U, 0xea25cfeaU,\n    0x65afca65U, 0x7a8ef47aU, 0xaee947aeU, 0x08181008U,\n    0xbad56fbaU, 0x7888f078U, 0x256f4a25U, 0x2e725c2eU,\n    0x1c24381cU, 0xa6f157a6U, 0xb4c773b4U, 0xc65197c6U,\n    0xe823cbe8U, 0xdd7ca1ddU, 0x749ce874U, 0x1f213e1fU,\n    0x4bdd964bU, 0xbddc61bdU, 0x8b860d8bU, 0x8a850f8aU,\n    0x7090e070U, 0x3e427c3eU, 0xb5c471b5U, 0x66aacc66U,\n    0x48d89048U, 0x03050603U, 0xf601f7f6U, 0x0e121c0eU,\n    0x61a3c261U, 0x355f6a35U, 0x57f9ae57U, 0xb9d069b9U,\n    0x86911786U, 0xc15899c1U, 0x1d273a1dU, 0x9eb9279eU,\n    0xe138d9e1U, 0xf813ebf8U, 0x98b32b98U, 0x11332211U,\n    0x69bbd269U, 0xd970a9d9U, 0x8e89078eU, 0x94a73394U,\n    0x9bb62d9bU, 0x1e223c1eU, 0x87921587U, 0xe920c9e9U,\n    0xce4987ceU, 0x55ffaa55U, 0x28785028U, 0xdf7aa5dfU,\n    0x8c8f038cU, 0xa1f859a1U, 0x89800989U, 0x0d171a0dU,\n    0xbfda65bfU, 0xe631d7e6U, 0x42c68442U, 0x68b8d068U,\n    0x41c38241U, 0x99b02999U, 0x2d775a2dU, 0x0f111e0fU,\n    0xb0cb7bb0U, 0x54fca854U, 0xbbd66dbbU, 0x163a2c16U,\n},\n{\n    0x6363a5c6U, 0x7c7c84f8U, 0x777799eeU, 0x7b7b8df6U,\n    0xf2f20dffU, 0x6b6bbdd6U, 0x6f6fb1deU, 0xc5c55491U,\n    0x30305060U, 0x01010302U, 0x6767a9ceU, 0x2b2b7d56U,\n    0xfefe19e7U, 0xd7d762b5U, 0xababe64dU, 0x76769aecU,\n    0xcaca458fU, 0x82829d1fU, 0xc9c94089U, 0x7d7d87faU,\n    0xfafa15efU, 0x5959ebb2U, 0x4747c98eU, 0xf0f00bfbU,\n    0xadadec41U, 0xd4d467b3U, 0xa2a2fd5fU, 0xafafea45U,\n    0x9c9cbf23U, 0xa4a4f753U, 0x727296e4U, 0xc0c05b9bU,\n    0xb7b7c275U, 0xfdfd1ce1U, 0x9393ae3dU, 0x26266a4cU,\n    0x36365a6cU, 0x3f3f417eU, 0xf7f702f5U, 0xcccc4f83U,\n    0x34345c68U, 0xa5a5f451U, 0xe5e534d1U, 0xf1f108f9U,\n    0x717193e2U, 0xd8d873abU, 0x31315362U, 0x15153f2aU,\n    0x04040c08U, 0xc7c75295U, 0x23236546U, 0xc3c35e9dU,\n    0x18182830U, 0x9696a137U, 0x05050f0aU, 0x9a9ab52fU,\n    0x0707090eU, 0x12123624U, 0x80809b1bU, 0xe2e23ddfU,\n    0xebeb26cdU, 0x2727694eU, 0xb2b2cd7fU, 0x75759feaU,\n    0x09091b12U, 0x83839e1dU, 0x2c2c7458U, 0x1a1a2e34U,\n    0x1b1b2d36U, 0x6e6eb2dcU, 0x5a5aeeb4U, 0xa0a0fb5bU,\n    0x5252f6a4U, 0x3b3b4d76U, 0xd6d661b7U, 0xb3b3ce7dU,\n    0x29297b52U, 0xe3e33eddU, 0x2f2f715eU, 0x84849713U,\n    0x5353f5a6U, 0xd1d168b9U, 0x00000000U, 0xeded2cc1U,\n    0x20206040U, 0xfcfc1fe3U, 0xb1b1c879U, 0x5b5bedb6U,\n    0x6a6abed4U, 0xcbcb468dU, 0xbebed967U, 0x39394b72U,\n    0x4a4ade94U, 0x4c4cd498U, 0x5858e8b0U, 0xcfcf4a85U,\n    0xd0d06bbbU, 0xefef2ac5U, 0xaaaae54fU, 0xfbfb16edU,\n    0x4343c586U, 0x4d4dd79aU, 0x33335566U, 0x85859411U,\n    0x4545cf8aU, 0xf9f910e9U, 0x02020604U, 0x7f7f81feU,\n    0x5050f0a0U, 0x3c3c4478U, 0x9f9fba25U, 0xa8a8e34bU,\n    0x5151f3a2U, 0xa3a3fe5dU, 0x4040c080U, 0x8f8f8a05U,\n    0x9292ad3fU, 0x9d9dbc21U, 0x38384870U, 0xf5f504f1U,\n    0xbcbcdf63U, 0xb6b6c177U, 0xdada75afU, 0x21216342U,\n    0x10103020U, 0xffff1ae5U, 0xf3f30efdU, 0xd2d26dbfU,\n    0xcdcd4c81U, 0x0c0c1418U, 0x13133526U, 0xecec2fc3U,\n    0x5f5fe1beU, 0x9797a235U, 0x4444cc88U, 0x1717392eU,\n    0xc4c45793U, 0xa7a7f255U, 0x7e7e82fcU, 0x3d3d477aU,\n    0x6464acc8U, 0x5d5de7baU, 0x19192b32U, 0x737395e6U,\n    0x6060a0c0U, 0x81819819U, 0x4f4fd19eU, 0xdcdc7fa3U,\n    0x22226644U, 0x2a2a7e54U, 0x9090ab3bU, 0x8888830bU,\n    0x4646ca8cU, 0xeeee29c7U, 0xb8b8d36bU, 0x14143c28U,\n    0xdede79a7U, 0x5e5ee2bcU, 0x0b0b1d16U, 0xdbdb76adU,\n    0xe0e03bdbU, 0x32325664U, 0x3a3a4e74U, 0x0a0a1e14U,\n    0x4949db92U, 0x06060a0cU, 0x24246c48U, 0x5c5ce4b8U,\n    0xc2c25d9fU, 0xd3d36ebdU, 0xacacef43U, 0x6262a6c4U,\n    0x9191a839U, 0x9595a431U, 0xe4e437d3U, 0x79798bf2U,\n    0xe7e732d5U, 0xc8c8438bU, 0x3737596eU, 0x6d6db7daU,\n    0x8d8d8c01U, 0xd5d564b1U, 0x4e4ed29cU, 0xa9a9e049U,\n    0x6c6cb4d8U, 0x5656faacU, 0xf4f407f3U, 0xeaea25cfU,\n    0x6565afcaU, 0x7a7a8ef4U, 0xaeaee947U, 0x08081810U,\n    0xbabad56fU, 0x787888f0U, 0x25256f4aU, 0x2e2e725cU,\n    0x1c1c2438U, 0xa6a6f157U, 0xb4b4c773U, 0xc6c65197U,\n    0xe8e823cbU, 0xdddd7ca1U, 0x74749ce8U, 0x1f1f213eU,\n    0x4b4bdd96U, 0xbdbddc61U, 0x8b8b860dU, 0x8a8a850fU,\n    0x707090e0U, 0x3e3e427cU, 0xb5b5c471U, 0x6666aaccU,\n    0x4848d890U, 0x03030506U, 0xf6f601f7U, 0x0e0e121cU,\n    0x6161a3c2U, 0x35355f6aU, 0x5757f9aeU, 0xb9b9d069U,\n    0x86869117U, 0xc1c15899U, 0x1d1d273aU, 0x9e9eb927U,\n    0xe1e138d9U, 0xf8f813ebU, 0x9898b32bU, 0x11113322U,\n    0x6969bbd2U, 0xd9d970a9U, 0x8e8e8907U, 0x9494a733U,\n    0x9b9bb62dU, 0x1e1e223cU, 0x87879215U, 0xe9e920c9U,\n    0xcece4987U, 0x5555ffaaU, 0x28287850U, 0xdfdf7aa5U,\n    0x8c8c8f03U, 0xa1a1f859U, 0x89898009U, 0x0d0d171aU,\n    0xbfbfda65U, 0xe6e631d7U, 0x4242c684U, 0x6868b8d0U,\n    0x4141c382U, 0x9999b029U, 0x2d2d775aU, 0x0f0f111eU,\n    0xb0b0cb7bU, 0x5454fca8U, 0xbbbbd66dU, 0x16163a2cU,\n},\n{\n    0x63636363U, 0x7c7c7c7cU, 0x77777777U, 0x7b7b7b7bU,\n    0xf2f2f2f2U, 0x6b6b6b6bU, 0x6f6f6f6fU, 0xc5c5c5c5U,\n    0x30303030U, 0x01010101U, 0x67676767U, 0x2b2b2b2bU,\n    0xfefefefeU, 0xd7d7d7d7U, 0xababababU, 0x76767676U,\n    0xcacacacaU, 0x82828282U, 0xc9c9c9c9U, 0x7d7d7d7dU,\n    0xfafafafaU, 0x59595959U, 0x47474747U, 0xf0f0f0f0U,\n    0xadadadadU, 0xd4d4d4d4U, 0xa2a2a2a2U, 0xafafafafU,\n    0x9c9c9c9cU, 0xa4a4a4a4U, 0x72727272U, 0xc0c0c0c0U,\n    0xb7b7b7b7U, 0xfdfdfdfdU, 0x93939393U, 0x26262626U,\n    0x36363636U, 0x3f3f3f3fU, 0xf7f7f7f7U, 0xccccccccU,\n    0x34343434U, 0xa5a5a5a5U, 0xe5e5e5e5U, 0xf1f1f1f1U,\n    0x71717171U, 0xd8d8d8d8U, 0x31313131U, 0x15151515U,\n    0x04040404U, 0xc7c7c7c7U, 0x23232323U, 0xc3c3c3c3U,\n    0x18181818U, 0x96969696U, 0x05050505U, 0x9a9a9a9aU,\n    0x07070707U, 0x12121212U, 0x80808080U, 0xe2e2e2e2U,\n    0xebebebebU, 0x27272727U, 0xb2b2b2b2U, 0x75757575U,\n    0x09090909U, 0x83838383U, 0x2c2c2c2cU, 0x1a1a1a1aU,\n    0x1b1b1b1bU, 0x6e6e6e6eU, 0x5a5a5a5aU, 0xa0a0a0a0U,\n    0x52525252U, 0x3b3b3b3bU, 0xd6d6d6d6U, 0xb3b3b3b3U,\n    0x29292929U, 0xe3e3e3e3U, 0x2f2f2f2fU, 0x84848484U,\n    0x53535353U, 0xd1d1d1d1U, 0x00000000U, 0xededededU,\n    0x20202020U, 0xfcfcfcfcU, 0xb1b1b1b1U, 0x5b5b5b5bU,\n    0x6a6a6a6aU, 0xcbcbcbcbU, 0xbebebebeU, 0x39393939U,\n    0x4a4a4a4aU, 0x4c4c4c4cU, 0x58585858U, 0xcfcfcfcfU,\n    0xd0d0d0d0U, 0xefefefefU, 0xaaaaaaaaU, 0xfbfbfbfbU,\n    0x43434343U, 0x4d4d4d4dU, 0x33333333U, 0x85858585U,\n    0x45454545U, 0xf9f9f9f9U, 0x02020202U, 0x7f7f7f7fU,\n    0x50505050U, 0x3c3c3c3cU, 0x9f9f9f9fU, 0xa8a8a8a8U,\n    0x51515151U, 0xa3a3a3a3U, 0x40404040U, 0x8f8f8f8fU,\n    0x92929292U, 0x9d9d9d9dU, 0x38383838U, 0xf5f5f5f5U,\n    0xbcbcbcbcU, 0xb6b6b6b6U, 0xdadadadaU, 0x21212121U,\n    0x10101010U, 0xffffffffU, 0xf3f3f3f3U, 0xd2d2d2d2U,\n    0xcdcdcdcdU, 0x0c0c0c0cU, 0x13131313U, 0xececececU,\n    0x5f5f5f5fU, 0x97979797U, 0x44444444U, 0x17171717U,\n    0xc4c4c4c4U, 0xa7a7a7a7U, 0x7e7e7e7eU, 0x3d3d3d3dU,\n    0x64646464U, 0x5d5d5d5dU, 0x19191919U, 0x73737373U,\n    0x60606060U, 0x81818181U, 0x4f4f4f4fU, 0xdcdcdcdcU,\n    0x22222222U, 0x2a2a2a2aU, 0x90909090U, 0x88888888U,\n    0x46464646U, 0xeeeeeeeeU, 0xb8b8b8b8U, 0x14141414U,\n    0xdedededeU, 0x5e5e5e5eU, 0x0b0b0b0bU, 0xdbdbdbdbU,\n    0xe0e0e0e0U, 0x32323232U, 0x3a3a3a3aU, 0x0a0a0a0aU,\n    0x49494949U, 0x06060606U, 0x24242424U, 0x5c5c5c5cU,\n    0xc2c2c2c2U, 0xd3d3d3d3U, 0xacacacacU, 0x62626262U,\n    0x91919191U, 0x95959595U, 0xe4e4e4e4U, 0x79797979U,\n    0xe7e7e7e7U, 0xc8c8c8c8U, 0x37373737U, 0x6d6d6d6dU,\n    0x8d8d8d8dU, 0xd5d5d5d5U, 0x4e4e4e4eU, 0xa9a9a9a9U,\n    0x6c6c6c6cU, 0x56565656U, 0xf4f4f4f4U, 0xeaeaeaeaU,\n    0x65656565U, 0x7a7a7a7aU, 0xaeaeaeaeU, 0x08080808U,\n    0xbabababaU, 0x78787878U, 0x25252525U, 0x2e2e2e2eU,\n    0x1c1c1c1cU, 0xa6a6a6a6U, 0xb4b4b4b4U, 0xc6c6c6c6U,\n    0xe8e8e8e8U, 0xddddddddU, 0x74747474U, 0x1f1f1f1fU,\n    0x4b4b4b4bU, 0xbdbdbdbdU, 0x8b8b8b8bU, 0x8a8a8a8aU,\n    0x70707070U, 0x3e3e3e3eU, 0xb5b5b5b5U, 0x66666666U,\n    0x48484848U, 0x03030303U, 0xf6f6f6f6U, 0x0e0e0e0eU,\n    0x61616161U, 0x35353535U, 0x57575757U, 0xb9b9b9b9U,\n    0x86868686U, 0xc1c1c1c1U, 0x1d1d1d1dU, 0x9e9e9e9eU,\n    0xe1e1e1e1U, 0xf8f8f8f8U, 0x98989898U, 0x11111111U,\n    0x69696969U, 0xd9d9d9d9U, 0x8e8e8e8eU, 0x94949494U,\n    0x9b9b9b9bU, 0x1e1e1e1eU, 0x87878787U, 0xe9e9e9e9U,\n    0xcecececeU, 0x55555555U, 0x28282828U, 0xdfdfdfdfU,\n    0x8c8c8c8cU, 0xa1a1a1a1U, 0x89898989U, 0x0d0d0d0dU,\n    0xbfbfbfbfU, 0xe6e6e6e6U, 0x42424242U, 0x68686868U,\n    0x41414141U, 0x99999999U, 0x2d2d2d2dU, 0x0f0f0f0fU,\n    0xb0b0b0b0U, 0x54545454U, 0xbbbbbbbbU, 0x16161616U,\n}\n};\n\n\nconst word32 AES::Td[5][256] = {\n{\n    0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U,\n    0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U,\n    0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U,\n    0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU,\n    0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U,\n    0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U,\n    0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU,\n    0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U,\n    0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU,\n    0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U,\n    0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U,\n    0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U,\n    0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U,\n    0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU,\n    0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U,\n    0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU,\n    0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U,\n    0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU,\n    0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U,\n    0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U,\n    0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U,\n    0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU,\n    0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U,\n    0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU,\n    0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U,\n    0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU,\n    0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U,\n    0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU,\n    0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU,\n    0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U,\n    0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU,\n    0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U,\n    0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU,\n    0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U,\n    0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U,\n    0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U,\n    0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU,\n    0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U,\n    0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U,\n    0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU,\n    0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U,\n    0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U,\n    0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U,\n    0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U,\n    0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U,\n    0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU,\n    0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U,\n    0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U,\n    0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U,\n    0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U,\n    0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U,\n    0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU,\n    0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU,\n    0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU,\n    0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU,\n    0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U,\n    0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U,\n    0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU,\n    0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU,\n    0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U,\n    0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU,\n    0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U,\n    0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U,\n    0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U,\n},\n{\n    0x5051f4a7U, 0x537e4165U, 0xc31a17a4U, 0x963a275eU,\n    0xcb3bab6bU, 0xf11f9d45U, 0xabacfa58U, 0x934be303U,\n    0x552030faU, 0xf6ad766dU, 0x9188cc76U, 0x25f5024cU,\n    0xfc4fe5d7U, 0xd7c52acbU, 0x80263544U, 0x8fb562a3U,\n    0x49deb15aU, 0x6725ba1bU, 0x9845ea0eU, 0xe15dfec0U,\n    0x02c32f75U, 0x12814cf0U, 0xa38d4697U, 0xc66bd3f9U,\n    0xe7038f5fU, 0x9515929cU, 0xebbf6d7aU, 0xda955259U,\n    0x2dd4be83U, 0xd3587421U, 0x2949e069U, 0x448ec9c8U,\n    0x6a75c289U, 0x78f48e79U, 0x6b99583eU, 0xdd27b971U,\n    0xb6bee14fU, 0x17f088adU, 0x66c920acU, 0xb47dce3aU,\n    0x1863df4aU, 0x82e51a31U, 0x60975133U, 0x4562537fU,\n    0xe0b16477U, 0x84bb6baeU, 0x1cfe81a0U, 0x94f9082bU,\n    0x58704868U, 0x198f45fdU, 0x8794de6cU, 0xb7527bf8U,\n    0x23ab73d3U, 0xe2724b02U, 0x57e31f8fU, 0x2a6655abU,\n    0x07b2eb28U, 0x032fb5c2U, 0x9a86c57bU, 0xa5d33708U,\n    0xf2302887U, 0xb223bfa5U, 0xba02036aU, 0x5ced1682U,\n    0x2b8acf1cU, 0x92a779b4U, 0xf0f307f2U, 0xa14e69e2U,\n    0xcd65daf4U, 0xd50605beU, 0x1fd13462U, 0x8ac4a6feU,\n    0x9d342e53U, 0xa0a2f355U, 0x32058ae1U, 0x75a4f6ebU,\n    0x390b83ecU, 0xaa4060efU, 0x065e719fU, 0x51bd6e10U,\n    0xf93e218aU, 0x3d96dd06U, 0xaedd3e05U, 0x464de6bdU,\n    0xb591548dU, 0x0571c45dU, 0x6f0406d4U, 0xff605015U,\n    0x241998fbU, 0x97d6bde9U, 0xcc894043U, 0x7767d99eU,\n    0xbdb0e842U, 0x8807898bU, 0x38e7195bU, 0xdb79c8eeU,\n    0x47a17c0aU, 0xe97c420fU, 0xc9f8841eU, 0x00000000U,\n    0x83098086U, 0x48322bedU, 0xac1e1170U, 0x4e6c5a72U,\n    0xfbfd0effU, 0x560f8538U, 0x1e3daed5U, 0x27362d39U,\n    0x640a0fd9U, 0x21685ca6U, 0xd19b5b54U, 0x3a24362eU,\n    0xb10c0a67U, 0x0f9357e7U, 0xd2b4ee96U, 0x9e1b9b91U,\n    0x4f80c0c5U, 0xa261dc20U, 0x695a774bU, 0x161c121aU,\n    0x0ae293baU, 0xe5c0a02aU, 0x433c22e0U, 0x1d121b17U,\n    0x0b0e090dU, 0xadf28bc7U, 0xb92db6a8U, 0xc8141ea9U,\n    0x8557f119U, 0x4caf7507U, 0xbbee99ddU, 0xfda37f60U,\n    0x9ff70126U, 0xbc5c72f5U, 0xc544663bU, 0x345bfb7eU,\n    0x768b4329U, 0xdccb23c6U, 0x68b6edfcU, 0x63b8e4f1U,\n    0xcad731dcU, 0x10426385U, 0x40139722U, 0x2084c611U,\n    0x7d854a24U, 0xf8d2bb3dU, 0x11aef932U, 0x6dc729a1U,\n    0x4b1d9e2fU, 0xf3dcb230U, 0xec0d8652U, 0xd077c1e3U,\n    0x6c2bb316U, 0x99a970b9U, 0xfa119448U, 0x2247e964U,\n    0xc4a8fc8cU, 0x1aa0f03fU, 0xd8567d2cU, 0xef223390U,\n    0xc787494eU, 0xc1d938d1U, 0xfe8ccaa2U, 0x3698d40bU,\n    0xcfa6f581U, 0x28a57adeU, 0x26dab78eU, 0xa43fadbfU,\n    0xe42c3a9dU, 0x0d507892U, 0x9b6a5fccU, 0x62547e46U,\n    0xc2f68d13U, 0xe890d8b8U, 0x5e2e39f7U, 0xf582c3afU,\n    0xbe9f5d80U, 0x7c69d093U, 0xa96fd52dU, 0xb3cf2512U,\n    0x3bc8ac99U, 0xa710187dU, 0x6ee89c63U, 0x7bdb3bbbU,\n    0x09cd2678U, 0xf46e5918U, 0x01ec9ab7U, 0xa8834f9aU,\n    0x65e6956eU, 0x7eaaffe6U, 0x0821bccfU, 0xe6ef15e8U,\n    0xd9bae79bU, 0xce4a6f36U, 0xd4ea9f09U, 0xd629b07cU,\n    0xaf31a4b2U, 0x312a3f23U, 0x30c6a594U, 0xc035a266U,\n    0x37744ebcU, 0xa6fc82caU, 0xb0e090d0U, 0x1533a7d8U,\n    0x4af10498U, 0xf741ecdaU, 0x0e7fcd50U, 0x2f1791f6U,\n    0x8d764dd6U, 0x4d43efb0U, 0x54ccaa4dU, 0xdfe49604U,\n    0xe39ed1b5U, 0x1b4c6a88U, 0xb8c12c1fU, 0x7f466551U,\n    0x049d5eeaU, 0x5d018c35U, 0x73fa8774U, 0x2efb0b41U,\n    0x5ab3671dU, 0x5292dbd2U, 0x33e91056U, 0x136dd647U,\n    0x8c9ad761U, 0x7a37a10cU, 0x8e59f814U, 0x89eb133cU,\n    0xeecea927U, 0x35b761c9U, 0xede11ce5U, 0x3c7a47b1U,\n    0x599cd2dfU, 0x3f55f273U, 0x791814ceU, 0xbf73c737U,\n    0xea53f7cdU, 0x5b5ffdaaU, 0x14df3d6fU, 0x867844dbU,\n    0x81caaff3U, 0x3eb968c4U, 0x2c382434U, 0x5fc2a340U,\n    0x72161dc3U, 0x0cbce225U, 0x8b283c49U, 0x41ff0d95U,\n    0x7139a801U, 0xde080cb3U, 0x9cd8b4e4U, 0x906456c1U,\n    0x617bcb84U, 0x70d532b6U, 0x74486c5cU, 0x42d0b857U,\n},\n{\n    0xa75051f4U, 0x65537e41U, 0xa4c31a17U, 0x5e963a27U,\n    0x6bcb3babU, 0x45f11f9dU, 0x58abacfaU, 0x03934be3U,\n    0xfa552030U, 0x6df6ad76U, 0x769188ccU, 0x4c25f502U,\n    0xd7fc4fe5U, 0xcbd7c52aU, 0x44802635U, 0xa38fb562U,\n    0x5a49deb1U, 0x1b6725baU, 0x0e9845eaU, 0xc0e15dfeU,\n    0x7502c32fU, 0xf012814cU, 0x97a38d46U, 0xf9c66bd3U,\n    0x5fe7038fU, 0x9c951592U, 0x7aebbf6dU, 0x59da9552U,\n    0x832dd4beU, 0x21d35874U, 0x692949e0U, 0xc8448ec9U,\n    0x896a75c2U, 0x7978f48eU, 0x3e6b9958U, 0x71dd27b9U,\n    0x4fb6bee1U, 0xad17f088U, 0xac66c920U, 0x3ab47dceU,\n    0x4a1863dfU, 0x3182e51aU, 0x33609751U, 0x7f456253U,\n    0x77e0b164U, 0xae84bb6bU, 0xa01cfe81U, 0x2b94f908U,\n    0x68587048U, 0xfd198f45U, 0x6c8794deU, 0xf8b7527bU,\n    0xd323ab73U, 0x02e2724bU, 0x8f57e31fU, 0xab2a6655U,\n    0x2807b2ebU, 0xc2032fb5U, 0x7b9a86c5U, 0x08a5d337U,\n    0x87f23028U, 0xa5b223bfU, 0x6aba0203U, 0x825ced16U,\n    0x1c2b8acfU, 0xb492a779U, 0xf2f0f307U, 0xe2a14e69U,\n    0xf4cd65daU, 0xbed50605U, 0x621fd134U, 0xfe8ac4a6U,\n    0x539d342eU, 0x55a0a2f3U, 0xe132058aU, 0xeb75a4f6U,\n    0xec390b83U, 0xefaa4060U, 0x9f065e71U, 0x1051bd6eU,\n\n    0x8af93e21U, 0x063d96ddU, 0x05aedd3eU, 0xbd464de6U,\n    0x8db59154U, 0x5d0571c4U, 0xd46f0406U, 0x15ff6050U,\n    0xfb241998U, 0xe997d6bdU, 0x43cc8940U, 0x9e7767d9U,\n    0x42bdb0e8U, 0x8b880789U, 0x5b38e719U, 0xeedb79c8U,\n    0x0a47a17cU, 0x0fe97c42U, 0x1ec9f884U, 0x00000000U,\n    0x86830980U, 0xed48322bU, 0x70ac1e11U, 0x724e6c5aU,\n    0xfffbfd0eU, 0x38560f85U, 0xd51e3daeU, 0x3927362dU,\n    0xd9640a0fU, 0xa621685cU, 0x54d19b5bU, 0x2e3a2436U,\n    0x67b10c0aU, 0xe70f9357U, 0x96d2b4eeU, 0x919e1b9bU,\n    0xc54f80c0U, 0x20a261dcU, 0x4b695a77U, 0x1a161c12U,\n    0xba0ae293U, 0x2ae5c0a0U, 0xe0433c22U, 0x171d121bU,\n    0x0d0b0e09U, 0xc7adf28bU, 0xa8b92db6U, 0xa9c8141eU,\n    0x198557f1U, 0x074caf75U, 0xddbbee99U, 0x60fda37fU,\n    0x269ff701U, 0xf5bc5c72U, 0x3bc54466U, 0x7e345bfbU,\n    0x29768b43U, 0xc6dccb23U, 0xfc68b6edU, 0xf163b8e4U,\n    0xdccad731U, 0x85104263U, 0x22401397U, 0x112084c6U,\n    0x247d854aU, 0x3df8d2bbU, 0x3211aef9U, 0xa16dc729U,\n    0x2f4b1d9eU, 0x30f3dcb2U, 0x52ec0d86U, 0xe3d077c1U,\n    0x166c2bb3U, 0xb999a970U, 0x48fa1194U, 0x642247e9U,\n    0x8cc4a8fcU, 0x3f1aa0f0U, 0x2cd8567dU, 0x90ef2233U,\n    0x4ec78749U, 0xd1c1d938U, 0xa2fe8ccaU, 0x0b3698d4U,\n    0x81cfa6f5U, 0xde28a57aU, 0x8e26dab7U, 0xbfa43fadU,\n    0x9de42c3aU, 0x920d5078U, 0xcc9b6a5fU, 0x4662547eU,\n    0x13c2f68dU, 0xb8e890d8U, 0xf75e2e39U, 0xaff582c3U,\n    0x80be9f5dU, 0x937c69d0U, 0x2da96fd5U, 0x12b3cf25U,\n    0x993bc8acU, 0x7da71018U, 0x636ee89cU, 0xbb7bdb3bU,\n    0x7809cd26U, 0x18f46e59U, 0xb701ec9aU, 0x9aa8834fU,\n    0x6e65e695U, 0xe67eaaffU, 0xcf0821bcU, 0xe8e6ef15U,\n    0x9bd9bae7U, 0x36ce4a6fU, 0x09d4ea9fU, 0x7cd629b0U,\n    0xb2af31a4U, 0x23312a3fU, 0x9430c6a5U, 0x66c035a2U,\n    0xbc37744eU, 0xcaa6fc82U, 0xd0b0e090U, 0xd81533a7U,\n    0x984af104U, 0xdaf741ecU, 0x500e7fcdU, 0xf62f1791U,\n    0xd68d764dU, 0xb04d43efU, 0x4d54ccaaU, 0x04dfe496U,\n    0xb5e39ed1U, 0x881b4c6aU, 0x1fb8c12cU, 0x517f4665U,\n    0xea049d5eU, 0x355d018cU, 0x7473fa87U, 0x412efb0bU,\n    0x1d5ab367U, 0xd25292dbU, 0x5633e910U, 0x47136dd6U,\n    0x618c9ad7U, 0x0c7a37a1U, 0x148e59f8U, 0x3c89eb13U,\n    0x27eecea9U, 0xc935b761U, 0xe5ede11cU, 0xb13c7a47U,\n    0xdf599cd2U, 0x733f55f2U, 0xce791814U, 0x37bf73c7U,\n    0xcdea53f7U, 0xaa5b5ffdU, 0x6f14df3dU, 0xdb867844U,\n    0xf381caafU, 0xc43eb968U, 0x342c3824U, 0x405fc2a3U,\n    0xc372161dU, 0x250cbce2U, 0x498b283cU, 0x9541ff0dU,\n    0x017139a8U, 0xb3de080cU, 0xe49cd8b4U, 0xc1906456U,\n    0x84617bcbU, 0xb670d532U, 0x5c74486cU, 0x5742d0b8U,\n},\n{\n    0xf4a75051U, 0x4165537eU, 0x17a4c31aU, 0x275e963aU,\n    0xab6bcb3bU, 0x9d45f11fU, 0xfa58abacU, 0xe303934bU,\n    0x30fa5520U, 0x766df6adU, 0xcc769188U, 0x024c25f5U,\n    0xe5d7fc4fU, 0x2acbd7c5U, 0x35448026U, 0x62a38fb5U,\n    0xb15a49deU, 0xba1b6725U, 0xea0e9845U, 0xfec0e15dU,\n    0x2f7502c3U, 0x4cf01281U, 0x4697a38dU, 0xd3f9c66bU,\n    0x8f5fe703U, 0x929c9515U, 0x6d7aebbfU, 0x5259da95U,\n    0xbe832dd4U, 0x7421d358U, 0xe0692949U, 0xc9c8448eU,\n    0xc2896a75U, 0x8e7978f4U, 0x583e6b99U, 0xb971dd27U,\n    0xe14fb6beU, 0x88ad17f0U, 0x20ac66c9U, 0xce3ab47dU,\n    0xdf4a1863U, 0x1a3182e5U, 0x51336097U, 0x537f4562U,\n    0x6477e0b1U, 0x6bae84bbU, 0x81a01cfeU, 0x082b94f9U,\n    0x48685870U, 0x45fd198fU, 0xde6c8794U, 0x7bf8b752U,\n    0x73d323abU, 0x4b02e272U, 0x1f8f57e3U, 0x55ab2a66U,\n    0xeb2807b2U, 0xb5c2032fU, 0xc57b9a86U, 0x3708a5d3U,\n    0x2887f230U, 0xbfa5b223U, 0x036aba02U, 0x16825cedU,\n    0xcf1c2b8aU, 0x79b492a7U, 0x07f2f0f3U, 0x69e2a14eU,\n    0xdaf4cd65U, 0x05bed506U, 0x34621fd1U, 0xa6fe8ac4U,\n    0x2e539d34U, 0xf355a0a2U, 0x8ae13205U, 0xf6eb75a4U,\n    0x83ec390bU, 0x60efaa40U, 0x719f065eU, 0x6e1051bdU,\n    0x218af93eU, 0xdd063d96U, 0x3e05aeddU, 0xe6bd464dU,\n    0x548db591U, 0xc45d0571U, 0x06d46f04U, 0x5015ff60U,\n    0x98fb2419U, 0xbde997d6U, 0x4043cc89U, 0xd99e7767U,\n    0xe842bdb0U, 0x898b8807U, 0x195b38e7U, 0xc8eedb79U,\n    0x7c0a47a1U, 0x420fe97cU, 0x841ec9f8U, 0x00000000U,\n    0x80868309U, 0x2bed4832U, 0x1170ac1eU, 0x5a724e6cU,\n    0x0efffbfdU, 0x8538560fU, 0xaed51e3dU, 0x2d392736U,\n    0x0fd9640aU, 0x5ca62168U, 0x5b54d19bU, 0x362e3a24U,\n    0x0a67b10cU, 0x57e70f93U, 0xee96d2b4U, 0x9b919e1bU,\n    0xc0c54f80U, 0xdc20a261U, 0x774b695aU, 0x121a161cU,\n    0x93ba0ae2U, 0xa02ae5c0U, 0x22e0433cU, 0x1b171d12U,\n    0x090d0b0eU, 0x8bc7adf2U, 0xb6a8b92dU, 0x1ea9c814U,\n    0xf1198557U, 0x75074cafU, 0x99ddbbeeU, 0x7f60fda3U,\n    0x01269ff7U, 0x72f5bc5cU, 0x663bc544U, 0xfb7e345bU,\n    0x4329768bU, 0x23c6dccbU, 0xedfc68b6U, 0xe4f163b8U,\n    0x31dccad7U, 0x63851042U, 0x97224013U, 0xc6112084U,\n    0x4a247d85U, 0xbb3df8d2U, 0xf93211aeU, 0x29a16dc7U,\n    0x9e2f4b1dU, 0xb230f3dcU, 0x8652ec0dU, 0xc1e3d077U,\n    0xb3166c2bU, 0x70b999a9U, 0x9448fa11U, 0xe9642247U,\n    0xfc8cc4a8U, 0xf03f1aa0U, 0x7d2cd856U, 0x3390ef22U,\n    0x494ec787U, 0x38d1c1d9U, 0xcaa2fe8cU, 0xd40b3698U,\n    0xf581cfa6U, 0x7ade28a5U, 0xb78e26daU, 0xadbfa43fU,\n    0x3a9de42cU, 0x78920d50U, 0x5fcc9b6aU, 0x7e466254U,\n    0x8d13c2f6U, 0xd8b8e890U, 0x39f75e2eU, 0xc3aff582U,\n    0x5d80be9fU, 0xd0937c69U, 0xd52da96fU, 0x2512b3cfU,\n    0xac993bc8U, 0x187da710U, 0x9c636ee8U, 0x3bbb7bdbU,\n    0x267809cdU, 0x5918f46eU, 0x9ab701ecU, 0x4f9aa883U,\n    0x956e65e6U, 0xffe67eaaU, 0xbccf0821U, 0x15e8e6efU,\n    0xe79bd9baU, 0x6f36ce4aU, 0x9f09d4eaU, 0xb07cd629U,\n    0xa4b2af31U, 0x3f23312aU, 0xa59430c6U, 0xa266c035U,\n    0x4ebc3774U, 0x82caa6fcU, 0x90d0b0e0U, 0xa7d81533U,\n    0x04984af1U, 0xecdaf741U, 0xcd500e7fU, 0x91f62f17U,\n    0x4dd68d76U, 0xefb04d43U, 0xaa4d54ccU, 0x9604dfe4U,\n    0xd1b5e39eU, 0x6a881b4cU, 0x2c1fb8c1U, 0x65517f46U,\n    0x5eea049dU, 0x8c355d01U, 0x877473faU, 0x0b412efbU,\n    0x671d5ab3U, 0xdbd25292U, 0x105633e9U, 0xd647136dU,\n    0xd7618c9aU, 0xa10c7a37U, 0xf8148e59U, 0x133c89ebU,\n    0xa927eeceU, 0x61c935b7U, 0x1ce5ede1U, 0x47b13c7aU,\n    0xd2df599cU, 0xf2733f55U, 0x14ce7918U, 0xc737bf73U,\n    0xf7cdea53U, 0xfdaa5b5fU, 0x3d6f14dfU, 0x44db8678U,\n    0xaff381caU, 0x68c43eb9U, 0x24342c38U, 0xa3405fc2U,\n    0x1dc37216U, 0xe2250cbcU, 0x3c498b28U, 0x0d9541ffU,\n    0xa8017139U, 0x0cb3de08U, 0xb4e49cd8U, 0x56c19064U,\n    0xcb84617bU, 0x32b670d5U, 0x6c5c7448U, 0xb85742d0U,\n},\n{\n    0x52525252U, 0x09090909U, 0x6a6a6a6aU, 0xd5d5d5d5U,\n    0x30303030U, 0x36363636U, 0xa5a5a5a5U, 0x38383838U,\n    0xbfbfbfbfU, 0x40404040U, 0xa3a3a3a3U, 0x9e9e9e9eU,\n    0x81818181U, 0xf3f3f3f3U, 0xd7d7d7d7U, 0xfbfbfbfbU,\n    0x7c7c7c7cU, 0xe3e3e3e3U, 0x39393939U, 0x82828282U,\n    0x9b9b9b9bU, 0x2f2f2f2fU, 0xffffffffU, 0x87878787U,\n    0x34343434U, 0x8e8e8e8eU, 0x43434343U, 0x44444444U,\n    0xc4c4c4c4U, 0xdedededeU, 0xe9e9e9e9U, 0xcbcbcbcbU,\n    0x54545454U, 0x7b7b7b7bU, 0x94949494U, 0x32323232U,\n    0xa6a6a6a6U, 0xc2c2c2c2U, 0x23232323U, 0x3d3d3d3dU,\n    0xeeeeeeeeU, 0x4c4c4c4cU, 0x95959595U, 0x0b0b0b0bU,\n    0x42424242U, 0xfafafafaU, 0xc3c3c3c3U, 0x4e4e4e4eU,\n    0x08080808U, 0x2e2e2e2eU, 0xa1a1a1a1U, 0x66666666U,\n    0x28282828U, 0xd9d9d9d9U, 0x24242424U, 0xb2b2b2b2U,\n    0x76767676U, 0x5b5b5b5bU, 0xa2a2a2a2U, 0x49494949U,\n    0x6d6d6d6dU, 0x8b8b8b8bU, 0xd1d1d1d1U, 0x25252525U,\n    0x72727272U, 0xf8f8f8f8U, 0xf6f6f6f6U, 0x64646464U,\n    0x86868686U, 0x68686868U, 0x98989898U, 0x16161616U,\n    0xd4d4d4d4U, 0xa4a4a4a4U, 0x5c5c5c5cU, 0xccccccccU,\n    0x5d5d5d5dU, 0x65656565U, 0xb6b6b6b6U, 0x92929292U,\n    0x6c6c6c6cU, 0x70707070U, 0x48484848U, 0x50505050U,\n    0xfdfdfdfdU, 0xededededU, 0xb9b9b9b9U, 0xdadadadaU,\n    0x5e5e5e5eU, 0x15151515U, 0x46464646U, 0x57575757U,\n    0xa7a7a7a7U, 0x8d8d8d8dU, 0x9d9d9d9dU, 0x84848484U,\n    0x90909090U, 0xd8d8d8d8U, 0xababababU, 0x00000000U,\n    0x8c8c8c8cU, 0xbcbcbcbcU, 0xd3d3d3d3U, 0x0a0a0a0aU,\n    0xf7f7f7f7U, 0xe4e4e4e4U, 0x58585858U, 0x05050505U,\n    0xb8b8b8b8U, 0xb3b3b3b3U, 0x45454545U, 0x06060606U,\n    0xd0d0d0d0U, 0x2c2c2c2cU, 0x1e1e1e1eU, 0x8f8f8f8fU,\n    0xcacacacaU, 0x3f3f3f3fU, 0x0f0f0f0fU, 0x02020202U,\n    0xc1c1c1c1U, 0xafafafafU, 0xbdbdbdbdU, 0x03030303U,\n    0x01010101U, 0x13131313U, 0x8a8a8a8aU, 0x6b6b6b6bU,\n    0x3a3a3a3aU, 0x91919191U, 0x11111111U, 0x41414141U,\n    0x4f4f4f4fU, 0x67676767U, 0xdcdcdcdcU, 0xeaeaeaeaU,\n    0x97979797U, 0xf2f2f2f2U, 0xcfcfcfcfU, 0xcecececeU,\n    0xf0f0f0f0U, 0xb4b4b4b4U, 0xe6e6e6e6U, 0x73737373U,\n    0x96969696U, 0xacacacacU, 0x74747474U, 0x22222222U,\n    0xe7e7e7e7U, 0xadadadadU, 0x35353535U, 0x85858585U,\n    0xe2e2e2e2U, 0xf9f9f9f9U, 0x37373737U, 0xe8e8e8e8U,\n    0x1c1c1c1cU, 0x75757575U, 0xdfdfdfdfU, 0x6e6e6e6eU,\n    0x47474747U, 0xf1f1f1f1U, 0x1a1a1a1aU, 0x71717171U,\n    0x1d1d1d1dU, 0x29292929U, 0xc5c5c5c5U, 0x89898989U,\n    0x6f6f6f6fU, 0xb7b7b7b7U, 0x62626262U, 0x0e0e0e0eU,\n    0xaaaaaaaaU, 0x18181818U, 0xbebebebeU, 0x1b1b1b1bU,\n    0xfcfcfcfcU, 0x56565656U, 0x3e3e3e3eU, 0x4b4b4b4bU,\n    0xc6c6c6c6U, 0xd2d2d2d2U, 0x79797979U, 0x20202020U,\n    0x9a9a9a9aU, 0xdbdbdbdbU, 0xc0c0c0c0U, 0xfefefefeU,\n    0x78787878U, 0xcdcdcdcdU, 0x5a5a5a5aU, 0xf4f4f4f4U,\n    0x1f1f1f1fU, 0xddddddddU, 0xa8a8a8a8U, 0x33333333U,\n    0x88888888U, 0x07070707U, 0xc7c7c7c7U, 0x31313131U,\n    0xb1b1b1b1U, 0x12121212U, 0x10101010U, 0x59595959U,\n    0x27272727U, 0x80808080U, 0xececececU, 0x5f5f5f5fU,\n    0x60606060U, 0x51515151U, 0x7f7f7f7fU, 0xa9a9a9a9U,\n    0x19191919U, 0xb5b5b5b5U, 0x4a4a4a4aU, 0x0d0d0d0dU,\n    0x2d2d2d2dU, 0xe5e5e5e5U, 0x7a7a7a7aU, 0x9f9f9f9fU,\n    0x93939393U, 0xc9c9c9c9U, 0x9c9c9c9cU, 0xefefefefU,\n    0xa0a0a0a0U, 0xe0e0e0e0U, 0x3b3b3b3bU, 0x4d4d4d4dU,\n    0xaeaeaeaeU, 0x2a2a2a2aU, 0xf5f5f5f5U, 0xb0b0b0b0U,\n    0xc8c8c8c8U, 0xebebebebU, 0xbbbbbbbbU, 0x3c3c3c3cU,\n    0x83838383U, 0x53535353U, 0x99999999U, 0x61616161U,\n    0x17171717U, 0x2b2b2b2bU, 0x04040404U, 0x7e7e7e7eU,\n    0xbabababaU, 0x77777777U, 0xd6d6d6d6U, 0x26262626U,\n    0xe1e1e1e1U, 0x69696969U, 0x14141414U, 0x63636363U,\n    0x55555555U, 0x21212121U, 0x0c0c0c0cU, 0x7d7d7d7dU,\n}\n};\n\n\nconst word32* AES::Te0 = AES::Te[0];\nconst word32* AES::Te1 = AES::Te[1];\nconst word32* AES::Te2 = AES::Te[2];\nconst word32* AES::Te3 = AES::Te[3];\nconst word32* AES::Te4 = AES::Te[4];\n\nconst word32* AES::Td0 = AES::Td[0];\nconst word32* AES::Td1 = AES::Td[1];\nconst word32* AES::Td2 = AES::Td[2];\nconst word32* AES::Td3 = AES::Td[3];\nconst word32* AES::Td4 = AES::Td[4];\n\n\n\n} // namespace\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/aestables.cpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* based on Wei Dai's aestables.cpp from CryptoPP */\n\n#include \"runtime.hpp\"\n#include \"aes.hpp\"\n\n\nnamespace TaoCrypt {\n\n\nconst word32 AES::rcon_[] = {\n    0x01000000, 0x02000000, 0x04000000, 0x08000000,\n    0x10000000, 0x20000000, 0x40000000, 0x80000000,\n    0x1B000000, 0x36000000, \n    /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */\n};\n\n\n} // namespace\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/algebra.cpp",
    "content": "/*\n   Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; if not, write to the Free Software\n   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */\n\n/* based on Wei Dai's algebra.cpp from CryptoPP */\n#undef  NDEBUG\n#define DEBUG   // GCC 4.0 bug if NDEBUG and Optimize > 1\n\n#include \"runtime.hpp\"\n#include \"algebra.hpp\"\n#ifdef USE_SYS_STL\n    #include <vector>\n#else\n    #include \"vector.hpp\"\n#endif\n\n\nnamespace STL = STL_NAMESPACE;\n\n\nnamespace TaoCrypt {\n\n\nconst Integer& AbstractGroup::Double(const Element &a) const\n{\n    return Add(a, a);\n}\n\nconst Integer& AbstractGroup::Subtract(const Element &a, const Element &b) const\n{\n    // make copy of a in case Inverse() overwrites it\n    Element a1(a);\n    return Add(a1, Inverse(b));\n}\n\nInteger& AbstractGroup::Accumulate(Element &a, const Element &b) const\n{\n    return a = Add(a, b);\n}\n\nInteger& AbstractGroup::Reduce(Element &a, const Element &b) const\n{\n    return a = Subtract(a, b);\n}\n\nconst Integer& AbstractRing::Square(const Element &a) const\n{\n    return Multiply(a, a);\n}\n\n\nconst Integer& AbstractRing::Divide(const Element &a, const Element &b) const\n{\n    // make copy of a in case MultiplicativeInverse() overwrites it\n    Element a1(a);\n    return Multiply(a1, MultiplicativeInverse(b));\n}\n\n\nconst Integer& AbstractEuclideanDomain::Mod(const Element &a,\n                                            const Element &b) const\n{\n    Element q;\n    DivisionAlgorithm(result, q, a, b);\n    return result;\n}\n\nconst Integer& AbstractEuclideanDomain::Gcd(const Element &a,\n                                            const Element &b) const\n{\n    STL::vector<Element> g(3);\n    g[0]= b;\n    g[1]= a;\n    unsigned int i0=0, i1=1, i2=2;\n\n    while (!Equal(g[i1], this->Identity()))\n    {\n        g[i2] = Mod(g[i0], g[i1]);\n        unsigned int t = i0; i0 = i1; i1 = i2; i2 = t;\n    }\n\n    return result = g[i0];\n}\n\n\nInteger AbstractGroup::ScalarMultiply(const Element &base,\n                                      const Integer &exponent) const\n{\n    Element result;\n    SimultaneousMultiply(&result, base, &exponent, 1);\n    return result;\n}\n\n\nInteger AbstractGroup::CascadeScalarMultiply(const Element &x,\n                  const Integer &e1, const Element &y, const Integer &e2) const\n{\n    const unsigned expLen = max(e1.BitCount(), e2.BitCount());\n    if (expLen==0)\n        return Identity();\n\n    const unsigned w = (expLen <= 46 ? 1 : (expLen <= 260 ? 2 : 3));\n    const unsigned tableSize = 1<<w;\n    STL::vector<Element> powerTable(tableSize << w);\n\n    powerTable[1] = x;\n    powerTable[tableSize] = y;\n    if (w==1)\n        powerTable[3] = Add(x,y);\n    else\n    {\n        powerTable[2] = Double(x);\n        powerTable[2*tableSize] = Double(y);\n\n        unsigned i, j;\n\n        for (i=3; i<tableSize; i+=2)\n            powerTable[i] = Add(powerTable[i-2], powerTable[2]);\n        for (i=1; i<tableSize; i+=2)\n            for (j=i+tableSize; j<(tableSize<<w); j+=tableSize)\n                powerTable[j] = Add(powerTable[j-tableSize], y);\n\n        for (i=3*tableSize; i<(tableSize<<w); i+=2*tableSize)\n            powerTable[i] = Add(powerTable[i-2*tableSize],\n            powerTable[2*tableSize]);\n        for (i=tableSize; i<(tableSize<<w); i+=2*tableSize)\n            for (j=i+2; j<i+tableSize; j+=2)\n                powerTable[j] = Add(powerTable[j-1], x);\n    }\n\n    Element result;\n    unsigned power1 = 0, power2 = 0, prevPosition = expLen-1;\n    bool firstTime = true;\n\n    for (int i = expLen-1; i>=0; i--)\n    {\n        power1 = 2*power1 + e1.GetBit(i);\n        power2 = 2*power2 + e2.GetBit(i);\n\n        if (i==0 || 2*power1 >= tableSize || 2*power2 >= tableSize)\n        {\n            unsigned squaresBefore = prevPosition-i;\n            unsigned squaresAfter = 0;\n            prevPosition = i;\n            while ((power1 || power2) && power1%2 == 0 && power2%2==0)\n            {\n                power1 /= 2;\n                power2 /= 2;\n                squaresBefore--;\n                squaresAfter++;\n            }\n            if (firstTime)\n            {\n                result = powerTable[(power2<<w) + power1];\n                firstTime = false;\n            }\n            else\n            {\n                while (squaresBefore--)\n                result = Double(result);\n                if (power1 || power2)\n                    Accumulate(result, powerTable[(power2<<w) + power1]);\n            }\n            while (squaresAfter--)\n                result = Double(result);\n            power1 = power2 = 0;\n        }\n    }\n    return result;\n}\n\n\nstruct WindowSlider\n{\n    WindowSlider(const Integer &exp, bool fastNegate,\n                 unsigned int windowSizeIn=0)\n        : exp(exp), windowModulus(Integer::One()), windowSize(windowSizeIn),\n          windowBegin(0), fastNegate(fastNegate), firstTime(true),\n          finished(false)\n    {\n        if (windowSize == 0)\n        {\n            unsigned int expLen = exp.BitCount();\n            windowSize = expLen <= 17 ? 1 : (expLen <= 24 ? 2 : \n                (expLen <= 70 ? 3 : (expLen <= 197 ? 4 : (expLen <= 539 ? 5 : \n                (expLen <= 1434 ? 6 : 7)))));\n        }\n        windowModulus <<= windowSize;\n    }\n\n    void FindNextWindow()\n    {\n        unsigned int expLen = exp.WordCount() * WORD_BITS;\n        unsigned int skipCount = firstTime ? 0 : windowSize;\n        firstTime = false;\n        while (!exp.GetBit(skipCount))\n        {\n            if (skipCount >= expLen)\n            {\n                finished = true;\n                return;\n            }\n            skipCount++;\n        }\n\n        exp >>= skipCount;\n        windowBegin += skipCount;\n        expWindow = exp % (1 << windowSize);\n\n        if (fastNegate && exp.GetBit(windowSize))\n        {\n            negateNext = true;\n            expWindow = (1 << windowSize) - expWindow;\n            exp += windowModulus;\n        }\n        else\n            negateNext = false;\n    }\n\n    Integer exp, windowModulus;\n    unsigned int windowSize, windowBegin, expWindow;\n    bool fastNegate, negateNext, firstTime, finished;\n};\n\n\nvoid AbstractGroup::SimultaneousMultiply(Integer *results, const Integer &base,\n                          const Integer *expBegin, unsigned int expCount) const\n{\n    STL::vector<STL::vector<Element> > buckets(expCount);\n    STL::vector<WindowSlider> exponents;\n    exponents.reserve(expCount);\n    unsigned int i;\n\n    for (i=0; i<expCount; i++)\n    {\n        exponents.push_back(WindowSlider(*expBegin++, InversionIsFast(), 0));\n        exponents[i].FindNextWindow();\n        buckets[i].resize(1<<(exponents[i].windowSize-1), Identity());\n    }\n\n    unsigned int expBitPosition = 0;\n    Element g = base;\n    bool notDone = true;\n\n    while (notDone)\n    {\n        notDone = false;\n        for (i=0; i<expCount; i++)\n        {\n            if (!exponents[i].finished && expBitPosition == \n                 exponents[i].windowBegin)\n            {\n                Element &bucket = buckets[i][exponents[i].expWindow/2];\n                if (exponents[i].negateNext)\n                    Accumulate(bucket, Inverse(g));\n                else\n                    Accumulate(bucket, g);\n                exponents[i].FindNextWindow();\n            }\n            notDone = notDone || !exponents[i].finished;\n        }\n\n        if (notDone)\n        {\n            g = Double(g);\n            expBitPosition++;\n        }\n    }\n\n    for (i=0; i<expCount; i++)\n    {\n        Element &r = *results++;\n        r = buckets[i][buckets[i].size()-1];\n        if (buckets[i].size() > 1)\n        {\n            for (size_t j = buckets[i].size()-2; j >= 1; j--)\n            {\n                Accumulate(buckets[i][j], buckets[i][j+1]);\n                Accumulate(r, buckets[i][j]);\n            }\n            Accumulate(buckets[i][0], buckets[i][1]);\n            r = Add(Double(r), buckets[i][0]);\n        }\n    }\n}\n\nInteger AbstractRing::Exponentiate(const Element &base,\n                                   const Integer &exponent) const\n{\n    Element result;\n    SimultaneousExponentiate(&result, base, &exponent, 1);\n    return result;\n}\n\n\nInteger AbstractRing::CascadeExponentiate(const Element &x,\n                  const Integer &e1, const Element &y, const Integer &e2) const\n{\n    return MultiplicativeGroup().AbstractGroup::CascadeScalarMultiply(\n                x, e1, y, e2);\n}\n\n\nvoid AbstractRing::SimultaneousExponentiate(Integer *results,\n                                            const Integer &base,\n                         const Integer *exponents, unsigned int expCount) const\n{\n    MultiplicativeGroup().AbstractGroup::SimultaneousMultiply(results, base,\n                                                          exponents, expCount);\n}\n\n\n} // namespace\n\n\n#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION\nnamespace mySTL {\ntemplate TaoCrypt::WindowSlider* uninit_copy<TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*>(TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*);\ntemplate void destroy<TaoCrypt::WindowSlider*>(TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*);\ntemplate TaoCrypt::WindowSlider* GetArrayMemory<TaoCrypt::WindowSlider>(size_t);\ntemplate void FreeArrayMemory<TaoCrypt::WindowSlider>(TaoCrypt::WindowSlider*);\n}\n#endif\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/arc4.cpp",
    "content": "/*\n   Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* based on Wei Dai's arc4.cpp from CryptoPP */\n\n#include \"runtime.hpp\"\n#include \"arc4.hpp\"\n\n\n#if defined(TAOCRYPT_X86ASM_AVAILABLE) && defined(TAO_ASM)\n    #define DO_ARC4_ASM\n#endif\n\n\nnamespace TaoCrypt {\n\nvoid ARC4::SetKey(const byte* key, word32 length)\n{\n    x_ = 1;\n    y_ = 0;\n\n    word32 i;\n\n    for (i = 0; i < STATE_SIZE; i++)\n        state_[i] = i;\n\n    word32 keyIndex = 0, stateIndex = 0;\n\n    for (i = 0; i < STATE_SIZE; i++) {\n        word32 a = state_[i];\n        stateIndex += key[keyIndex] + a;\n        stateIndex &= 0xFF;\n        state_[i] = state_[stateIndex];\n        state_[stateIndex] = a;\n\n        if (++keyIndex >= length)\n            keyIndex = 0;\n    }\n}\n\n\n// local\nnamespace {\n\ninline unsigned int MakeByte(word32& x, word32& y, byte* s)\n{\n    word32 a = s[x];\n    y = (y+a) & 0xff;\n\n    word32 b = s[y];\n    s[x] = b;\n    s[y] = a;\n    x = (x+1) & 0xff;\n\n    return s[(a+b) & 0xff];\n}\n\n} // namespace\n\n\n\nvoid ARC4::Process(byte* out, const byte* in, word32 length)\n{\n    if (length == 0) return;\n\n#ifdef DO_ARC4_ASM\n    if (isMMX) {\n        AsmProcess(out, in, length);\n        return;\n    } \n#endif\n\n    byte *const s = state_;\n    word32 x = x_;\n    word32 y = y_;\n\n    if (in == out)\n        while (length--)\n            *out++ ^= MakeByte(x, y, s);\n    else\n        while(length--)\n            *out++ = *in++ ^ MakeByte(x, y, s);\n    x_ = x;\n    y_ = y;\n}\n\n\n\n#ifdef DO_ARC4_ASM\n\n#ifdef _MSC_VER\n    __declspec(naked)\n#else\n    __attribute__ ((noinline))\n#endif\nvoid ARC4::AsmProcess(byte* out, const byte* in, word32 length)\n{\n#ifdef __GNUC__\n    #define AS1(x)    #x \";\"\n    #define AS2(x, y) #x \", \" #y \";\"\n\n    #define PROLOG()  \\\n    __asm__ __volatile__ \\\n    ( \\\n        \".intel_syntax noprefix;\" \\\n        \"push ebx;\" \\\n        \"push ebp;\" \\\n        \"mov ebp, eax;\"\n    #define EPILOG()  \\\n        \"pop ebp;\" \\\n        \"pop ebx;\" \\\n       \t\"emms;\" \\\n       \t\".att_syntax;\" \\\n            : \\\n            : \"c\" (this), \"D\" (out), \"S\" (in), \"a\" (length) \\\n            : \"%edx\", \"memory\", \"cc\" \\\n    );\n\n#else\n    #define AS1(x)    __asm x\n    #define AS2(x, y) __asm x, y\n\n    #define PROLOG() \\\n        AS1(    push  ebp                       )   \\\n        AS2(    mov   ebp, esp                  )   \\\n        AS2(    movd  mm3, edi                  )   \\\n        AS2(    movd  mm4, ebx                  )   \\\n        AS2(    movd  mm5, esi                  )   \\\n        AS2(    movd  mm6, ebp                  )   \\\n        AS2(    mov   edi, DWORD PTR [ebp +  8] )   \\\n        AS2(    mov   esi, DWORD PTR [ebp + 12] )   \\\n        AS2(    mov   ebp, DWORD PTR [ebp + 16] )\n\n    #define EPILOG() \\\n        AS2(    movd  ebp, mm6                  )   \\\n        AS2(    movd  esi, mm5                  )   \\\n        AS2(    movd  ebx, mm4                  )   \\\n        AS2(    movd  edi, mm3                  )   \\\n        AS2(    mov   esp, ebp                  )   \\\n        AS1(    pop   ebp                       )   \\\n        AS1(    emms                            )   \\\n        AS1(    ret 12                          )\n        \n#endif\n\n    PROLOG()\n\n    AS2(    sub    esp, 4                   )   // make room \n\n    AS2(    cmp    ebp, 0                   )\n    AS1(    jz     nothing                  )\n\n    AS2(    mov    [esp], ebp               )   // length\n\n    AS2(    movzx  edx, BYTE PTR [ecx + 1]  )   // y\n    AS2(    lea    ebp, [ecx + 2]           )   // state_\n    AS2(    movzx  ecx, BYTE PTR [ecx]      )   // x\n\n    // setup loop\n    // a = s[x];\n    AS2(    movzx  eax, BYTE PTR [ebp + ecx]    )\n\n\n#ifdef _MSC_VER\n    AS1( loopStart: )  // loopStart\n#else\n    AS1( 0: )          // loopStart for some gas (need numeric for jump back \n#endif\n\n    // y = (y+a) & 0xff;\n    AS2(    add    edx, eax                     )\n    AS2(    and    edx, 255                     )\n\n    // b = s[y];\n    AS2(    movzx  ebx, BYTE PTR [ebp + edx]    )\n\n    // s[x] = b;\n    AS2(    mov    [ebp + ecx], bl              )\n\n    // s[y] = a;\n    AS2(    mov    [ebp + edx], al              )\n\n    // x = (x+1) & 0xff;\n    AS1(    inc    ecx                          )\n    AS2(    and    ecx, 255                     )\n\n    //return s[(a+b) & 0xff];\n    AS2(    add    eax, ebx                     )\n    AS2(    and    eax, 255                     )\n    \n    AS2(    movzx  ebx, BYTE PTR [ebp + eax]    )\n\n    // a = s[x];   for next round\n    AS2(    movzx  eax, BYTE PTR [ebp + ecx]    )\n\n    // xOr w/ inByte\n    AS2(    xor    bl,  BYTE PTR [esi]          )\n    AS1(    inc    esi                          )\n\n    // write to outByte\n    AS2(    mov    [edi], bl                    )\n    AS1(    inc    edi                          )\n\n    AS1(    dec    DWORD PTR [esp]              )\n#ifdef _MSC_VER\n    AS1(    jnz   loopStart )  // loopStart\n#else\n    AS1(    jnz   0b )         // loopStart\n#endif\n\n\n    // write back to x_ and y_\n    AS2(    mov    [ebp - 2], cl            )\n    AS2(    mov    [ebp - 1], dl            )\n\n\nAS1( nothing:                           )\n\n    // inline adjust \n    AS2(    add   esp, 4               )   // fix room on stack\n\n    EPILOG()\n}\n\n#endif // DO_ARC4_ASM\n\n\n}  // namespace\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/asn.cpp",
    "content": "/*\n   Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* asn.cpp implements ASN1 BER, PublicKey, and x509v3 decoding \n*/\n\n#include \"runtime.hpp\"\n#include \"asn.hpp\"\n#include \"file.hpp\"\n#include \"integer.hpp\"\n#include \"rsa.hpp\"\n#include \"dsa.hpp\"\n#include \"dh.hpp\"\n#include \"md5.hpp\"\n#include \"md2.hpp\"\n#include \"sha.hpp\"\n#include \"coding.hpp\"\n#include <time.h>     // gmtime();\n#include \"memory.hpp\" // some auto_ptr don't have reset, also need auto_array\n\n\nnamespace TaoCrypt {\n\n// like atoi but only use first byte\nword32 btoi(byte b)\n{\n    return b - 0x30;\n}\n\n\n// two byte date/time, add to value\nvoid GetTime(int *value, const byte* date, int& i)\n{\n    *value += btoi(date[i++]) * 10;\n    *value += btoi(date[i++]);\n}\n\n\nbool ASN1_TIME_extract(const unsigned char* date, unsigned char format,\n                       tm *t)\n{\n  int i = 0;\n  memset(t, 0, sizeof (tm));\n\n  if (format != UTC_TIME && format != GENERALIZED_TIME)\n    return false;\n\n  if (format == UTC_TIME) {\n    if (btoi(date[0]) >= 5)\n      t->tm_year = 1900;\n    else\n      t->tm_year = 2000;\n  }\n  else  { // format == GENERALIZED_TIME\n    t->tm_year += btoi(date[i++]) * 1000;\n    t->tm_year += btoi(date[i++]) * 100;\n  }\n\n  GetTime(&t->tm_year, date, i);     t->tm_year -= 1900; // adjust\n  GetTime(&t->tm_mon,  date, i);     t->tm_mon  -= 1;    // adjust\n  GetTime(&t->tm_mday, date, i);\n  GetTime(&t->tm_hour, date, i);\n  GetTime(&t->tm_min,  date, i);\n  GetTime(&t->tm_sec,  date, i);\n\n  if (date[i] != 'Z')     // only Zulu supported for this profile\n    return false;\n  return true;\n}\n\n\nnamespace { // locals\n\n\n// to the minute\nbool operator>(tm& a, tm& b)\n{\n    if (a.tm_year > b.tm_year)\n        return true;\n\n    if (a.tm_year == b.tm_year && a.tm_mon > b.tm_mon)\n        return true;\n    \n    if (a.tm_year == b.tm_year && a.tm_mon == b.tm_mon && a.tm_mday >b.tm_mday)\n        return true;\n\n    if (a.tm_year == b.tm_year && a.tm_mon == b.tm_mon &&\n        a.tm_mday == b.tm_mday && a.tm_hour > b.tm_hour)\n        return true;\n\n    if (a.tm_year == b.tm_year && a.tm_mon == b.tm_mon &&\n        a.tm_mday == b.tm_mday && a.tm_hour == b.tm_hour &&\n        a.tm_min > b.tm_min)\n        return true;\n\n    return false;\n}\n\n\nbool operator<(tm& a, tm&b)\n{\n    return !(a>b);\n}\n\n\n// Make sure before and after dates are valid\nbool ValidateDate(const byte* date, byte format, CertDecoder::DateType dt)\n{\n    tm certTime;\n\n    if (!ASN1_TIME_extract(date, format, &certTime))\n        return false;\n\n    time_t ltime = time(0);\n    tm* localTime = gmtime(&ltime);\n\n    if (dt == CertDecoder::BEFORE) {\n        if (*localTime < certTime)\n            return false;\n    }\n    else\n        if (*localTime > certTime)\n            return false;\n\n    return true;\n}\n\n\nclass BadCertificate {};\n\n} // local namespace\n\n\n\n// used by Integer as well\nword32 GetLength(Source& source)\n{\n    word32 length = 0;\n\n    byte b = source.next();\n    if (b >= LONG_LENGTH) {        \n        word32 bytes = b & 0x7F;\n\n        if (source.IsLeft(bytes) == false) return 0;\n\n        while (bytes--) {\n            b = source.next();\n            length = (length << 8) | b;\n        }\n    }\n    else\n        length = b;\n\n    if (source.IsLeft(length) == false) return 0;\n\n    return length;\n}\n\n\nword32 SetLength(word32 length, byte* output)\n{\n    word32 i = 0;\n\n    if (length < LONG_LENGTH)\n        output[i++] = length;\n    else {\n        output[i++] = BytePrecision(length) | 0x80;\n      \n        for (int j = BytePrecision(length); j; --j) {\n            output[i] = length >> (j - 1) * 8;\n            i++;\n        }\n    }\n    return i;\n}\n\n\nPublicKey::PublicKey(const byte* k, word32 s) : key_(0), sz_(0)\n{\n    if (s) {\n        SetSize(s);\n        SetKey(k);\n    }\n}\n\n\nvoid PublicKey::SetSize(word32 s)\n{\n    sz_ = s;\n    key_ = NEW_TC byte[sz_];\n}\n\n\nvoid PublicKey::SetKey(const byte* k)\n{\n    memcpy(key_, k, sz_);\n}\n\n\nvoid PublicKey::AddToEnd(const byte* data, word32 len)\n{\n    mySTL::auto_array<byte> tmp(NEW_TC byte[sz_ + len]);\n\n    memcpy(tmp.get(), key_, sz_);\n    memcpy(tmp.get() + sz_, data, len);\n\n    byte* del = 0;\n    STL::swap(del, key_);\n    tcArrayDelete(del);\n\n    key_ = tmp.release();\n    sz_ += len;\n}\n\n\nSigner::Signer(const byte* k, word32 kSz, const char* n, const byte* h)\n    : key_(k, kSz)\n{\n    size_t sz = strlen(n);\n    memcpy(name_, n, sz);\n    name_[sz] = 0;\n\n    memcpy(hash_, h, SHA::DIGEST_SIZE);\n}\n\nSigner::~Signer()\n{\n}\n\n\nError BER_Decoder::GetError()\n{ \n    return source_.GetError(); \n}\n\n\nInteger& BER_Decoder::GetInteger(Integer& integer)\n{\n    if (!source_.GetError().What())\n        integer.Decode(source_);\n    return integer;\n}\n\n  \n// Read a Sequence, return length\nword32 BER_Decoder::GetSequence()\n{\n    if (source_.GetError().What()) return 0;\n\n    byte b = source_.next();\n    if (b != (SEQUENCE | CONSTRUCTED)) {\n        source_.SetError(SEQUENCE_E);\n        return 0;\n    }\n\n    return GetLength(source_);\n}\n\n\n// Read a Sequence, return length\nword32 BER_Decoder::GetSet()\n{\n    if (source_.GetError().What()) return 0;\n\n    byte b = source_.next();\n    if (b != (SET | CONSTRUCTED)) {\n        source_.SetError(SET_E);\n        return 0;\n    }\n\n    return GetLength(source_);\n}\n\n\n// Read Version, return it\nword32 BER_Decoder::GetVersion()\n{\n    if (source_.GetError().What()) return 0;\n\n    byte b = source_.next();\n    if (b != INTEGER) {\n        source_.SetError(INTEGER_E);\n        return 0;\n    }\n\n    b = source_.next();\n    if (b != 0x01) {\n        source_.SetError(VERSION_E);\n        return 0;\n    }\n\n    return source_.next();\n}\n\n\n// Read ExplicitVersion, return it or 0 if not there (not an error)\nword32 BER_Decoder::GetExplicitVersion()\n{\n    if (source_.GetError().What()) return 0;\n\n    byte b = source_.next();\n\n    if (b == (CONTEXT_SPECIFIC | CONSTRUCTED)) { // not an error if not here\n        source_.next();\n        return GetVersion();\n    }\n    else \n        source_.prev(); // put back\n  \n    return 0;\n}\n\n\n// Decode a BER encoded RSA Private Key\nvoid RSA_Private_Decoder::Decode(RSA_PrivateKey& key)\n{\n    ReadHeader();\n    if (source_.GetError().What()) return;\n    // public\n    key.SetModulus(GetInteger(Integer().Ref()));\n    key.SetPublicExponent(GetInteger(Integer().Ref()));\n\n    // private\n    key.SetPrivateExponent(GetInteger(Integer().Ref()));\n    key.SetPrime1(GetInteger(Integer().Ref()));\n    key.SetPrime2(GetInteger(Integer().Ref()));\n    key.SetModPrime1PrivateExponent(GetInteger(Integer().Ref()));\n    key.SetModPrime2PrivateExponent(GetInteger(Integer().Ref()));\n    key.SetMultiplicativeInverseOfPrime2ModPrime1(GetInteger(Integer().Ref()));\n}\n\n\nvoid RSA_Private_Decoder::ReadHeader()\n{\n    GetSequence();\n    GetVersion();\n}\n\n\n// Decode a BER encoded DSA Private Key\nvoid DSA_Private_Decoder::Decode(DSA_PrivateKey& key)\n{\n    ReadHeader();\n    if (source_.GetError().What()) return;\n    // group parameters\n    key.SetModulus(GetInteger(Integer().Ref()));\n    key.SetSubGroupOrder(GetInteger(Integer().Ref()));\n    key.SetSubGroupGenerator(GetInteger(Integer().Ref()));\n\n    // key\n    key.SetPublicPart(GetInteger(Integer().Ref()));\n    key.SetPrivatePart(GetInteger(Integer().Ref()));   \n}\n\n\nvoid DSA_Private_Decoder::ReadHeader()\n{\n    GetSequence();\n    GetVersion();\n}\n\n\n// Decode a BER encoded RSA Public Key\nvoid RSA_Public_Decoder::Decode(RSA_PublicKey& key)\n{\n    ReadHeader();\n    if (source_.GetError().What()) return;\n\n    ReadHeaderOpenSSL();   // may or may not be\n    if (source_.GetError().What()) return;\n\n    // public key\n    key.SetModulus(GetInteger(Integer().Ref()));\n    key.SetPublicExponent(GetInteger(Integer().Ref()));\n}\n\n\n// Read OpenSSL format public header\nvoid RSA_Public_Decoder::ReadHeaderOpenSSL()\n{\n    byte b = source_.next();  // peek\n    source_.prev();\n\n    if (b != INTEGER) { // have OpenSSL public format\n        GetSequence();\n        b = source_.next();\n        if (b != OBJECT_IDENTIFIER) {\n            source_.SetError(OBJECT_ID_E);\n            return;\n        }\n\n        word32 len = GetLength(source_);\n        source_.advance(len);\n\n        b = source_.next();\n        if (b == TAG_NULL) {   // could have NULL tag and 0 terminator, may not \n            b = source_.next();\n            if (b != 0) {\n                source_.SetError(EXPECT_0_E);\n                return; \n            }\n        }\n        else\n            source_.prev();   // put back\n\n        b = source_.next();\n        if (b != BIT_STRING) {   \n            source_.SetError(BIT_STR_E);\n            return; \n        }\n\n        len = GetLength(source_); \n        b = source_.next();\n        if (b != 0)           // could have 0\n            source_.prev();   // put back\n        \n        GetSequence();\n    }\n}\n\n\nvoid RSA_Public_Decoder::ReadHeader()\n{\n    GetSequence();\n}\n\n\n// Decode a BER encoded DSA Public Key\nvoid DSA_Public_Decoder::Decode(DSA_PublicKey& key)\n{\n    ReadHeader();\n    if (source_.GetError().What()) return;\n\n    // group parameters\n    key.SetModulus(GetInteger(Integer().Ref()));\n    key.SetSubGroupOrder(GetInteger(Integer().Ref()));\n    key.SetSubGroupGenerator(GetInteger(Integer().Ref()));\n\n    // key\n    key.SetPublicPart(GetInteger(Integer().Ref()));\n}\n\n\nvoid DSA_Public_Decoder::ReadHeader()\n{\n    GetSequence();\n}\n\n\nvoid DH_Decoder::ReadHeader()\n{\n    GetSequence();\n}\n\n\n// Decode a BER encoded Diffie-Hellman Key\nvoid DH_Decoder::Decode(DH& key)\n{\n    ReadHeader();\n    if (source_.GetError().What()) return;\n\n    // group parms\n    key.SetP(GetInteger(Integer().Ref()));\n    key.SetG(GetInteger(Integer().Ref()));\n}\n\n\nCertDecoder::CertDecoder(Source& s, bool decode, SignerList* signers,\n                         bool noVerify, CertType ct)\n    : BER_Decoder(s), certBegin_(0), sigIndex_(0), sigLength_(0),\n      signature_(0), verify_(!noVerify)\n{\n    issuer_[0] = 0;\n    subject_[0] = 0;\n\n    if (decode)\n        Decode(signers, ct);\n\n}\n\n\nCertDecoder::~CertDecoder()\n{\n    tcArrayDelete(signature_);\n}\n\n\n// process certificate header, set signature offset\nvoid CertDecoder::ReadHeader()\n{\n    if (source_.GetError().What()) return;\n\n    GetSequence();  // total\n    certBegin_ = source_.get_index();\n\n    sigIndex_ = GetSequence();  // this cert\n    sigIndex_ += source_.get_index();\n\n    GetExplicitVersion(); // version\n    GetInteger(Integer().Ref());  // serial number\n}\n\n\n// Decode a x509v3 Certificate\nvoid CertDecoder::Decode(SignerList* signers, CertType ct)\n{\n    if (source_.GetError().What()) return;\n    DecodeToKey();\n    if (source_.GetError().What()) return;\n\n    if (source_.get_index() != sigIndex_)\n        source_.set_index(sigIndex_);\n\n    word32 confirmOID = GetAlgoId();\n    GetSignature();\n    if (source_.GetError().What()) return;\n\n    if ( confirmOID != signatureOID_ ) {\n        source_.SetError(SIG_OID_E);\n        return;\n    }\n    \n    if (ct != CA && verify_ && !ValidateSignature(signers))\n        source_.SetError(SIG_OTHER_E);\n}\n\n\nvoid CertDecoder::DecodeToKey()\n{\n    ReadHeader();\n    signatureOID_ = GetAlgoId();\n    GetName(ISSUER);   \n    GetValidity();\n    GetName(SUBJECT);   \n    GetKey();\n}\n\n\n// Read public key\nvoid CertDecoder::GetKey()\n{\n    if (source_.GetError().What()) return;\n\n    GetSequence();    \n    keyOID_ = GetAlgoId();\n\n    if (keyOID_ == RSAk) {\n        byte b = source_.next();\n        if (b != BIT_STRING) {\n            source_.SetError(BIT_STR_E);\n            return;\n        }\n        b = source_.next();      // length, future\n        b = source_.next(); \n        while(b != 0)\n            b = source_.next();\n    }\n    else if (keyOID_ == DSAk)\n        ;   // do nothing\n    else {\n        source_.SetError(UNKNOWN_OID_E);\n        return;\n    }\n\n    StoreKey();\n    if (keyOID_ == DSAk)\n        AddDSA();\n}\n\n\n// Save public key\nvoid CertDecoder::StoreKey()\n{\n    if (source_.GetError().What()) return;\n\n    word32 read = source_.get_index();\n    word32 length = GetSequence();\n\n    read = source_.get_index() - read;\n    length += read;\n\n    if (source_.GetError().What()) return;\n    while (read--) source_.prev();\n\n    if (source_.IsLeft(length) == false) return;\n    key_.SetSize(length);\n    key_.SetKey(source_.get_current());\n    source_.advance(length);\n}\n\n\n// DSA has public key after group\nvoid CertDecoder::AddDSA()\n{\n    if (source_.GetError().What()) return;\n\n    byte b = source_.next();\n    if (b != BIT_STRING) {\n        source_.SetError(BIT_STR_E);\n        return;\n    }\n    b = source_.next();      // length, future\n    b = source_.next(); \n    while(b != 0)\n        b = source_.next();\n\n    word32 idx = source_.get_index();\n    b = source_.next();\n    if (b != INTEGER) {\n        source_.SetError(INTEGER_E);\n        return;\n    }\n\n    word32 length = GetLength(source_);\n    length += source_.get_index() - idx;\n\n    if (source_.IsLeft(length) == false) return;\n\n    key_.AddToEnd(source_.get_buffer() + idx, length);    \n}\n\n\n// process algo OID by summing, return it\nword32 CertDecoder::GetAlgoId()\n{\n    if (source_.GetError().What()) return 0;\n    word32 length = GetSequence();\n\n    if (source_.GetError().What()) return 0;\n    \n    byte b = source_.next();\n    if (b != OBJECT_IDENTIFIER) {\n        source_.SetError(OBJECT_ID_E);\n        return 0;\n    }\n\n    length = GetLength(source_);\n    if (source_.IsLeft(length) == false) return 0;\n\n    word32 oid = 0;\n    while(length--)\n        oid += source_.next();        // just sum it up for now\n\n    // could have NULL tag and 0 terminator, but may not\n    b = source_.next();\n    if (b == TAG_NULL) {\n        b = source_.next();\n        if (b != 0) {\n            source_.SetError(EXPECT_0_E);\n            return 0;\n        }\n    }\n    else\n        // go back, didn't have it\n        b = source_.prev();\n\n    return oid;\n}\n\n\n// read cert signature, store in signature_\nword32 CertDecoder::GetSignature()\n{\n    if (source_.GetError().What()) return 0;\n    byte b = source_.next();\n\n    if (b != BIT_STRING) {\n        source_.SetError(BIT_STR_E);\n        return 0;\n    }\n\n    sigLength_ = GetLength(source_);\n    if (sigLength_ <= 1 || source_.IsLeft(sigLength_) == false) {\n        source_.SetError(CONTENT_E);\n        return 0;\n    }\n  \n    b = source_.next();\n    if (b != 0) {\n        source_.SetError(EXPECT_0_E);\n        return 0;\n    }\n    sigLength_--;\n\n    signature_ = NEW_TC byte[sigLength_];\n    memcpy(signature_, source_.get_current(), sigLength_);\n    source_.advance(sigLength_);\n\n    return sigLength_;\n}\n\n\n// read cert digest, store in signature_\nword32 CertDecoder::GetDigest()\n{\n    if (source_.GetError().What()) return 0;\n    byte b = source_.next();\n\n    if (b != OCTET_STRING) {\n        source_.SetError(OCTET_STR_E);\n        return 0;\n    }\n\n    sigLength_ = GetLength(source_);\n\n    signature_ = NEW_TC byte[sigLength_];\n    memcpy(signature_, source_.get_current(), sigLength_);\n    source_.advance(sigLength_);\n\n    return sigLength_;\n}\n\n\n// memory length checked add tag to buffer\nchar* CertDecoder::AddTag(char* ptr, const char* buf_end, const char* tag_name,\n                          word32 tag_name_length, word32 tag_value_length)\n{\n    if (ptr + tag_name_length + tag_value_length > buf_end) {\n        source_.SetError(CONTENT_E);\n        return 0;\n    }\n\n    memcpy(ptr, tag_name, tag_name_length);\n    ptr += tag_name_length;\n\n    memcpy(ptr, source_.get_current(), tag_value_length);\n    ptr += tag_value_length;\n\n    return ptr;\n}\n\n\n// process NAME, either issuer or subject\nvoid CertDecoder::GetName(NameType nt)\n{\n    if (source_.GetError().What()) return;\n\n    SHA    sha;\n    word32 length = GetSequence();  // length of all distinguished names\n\n    if (length >= ASN_NAME_MAX)\n        return;\n    if (source_.IsLeft(length) == false) return;\n    length += source_.get_index();\n    \n    char* ptr;\n    char* buf_end;\n\n    if (nt == ISSUER) {\n        ptr = issuer_;\n        buf_end = ptr + sizeof(issuer_) - 1;   // 1 byte for trailing 0\n    }\n    else {\n        ptr = subject_;\n        buf_end = ptr + sizeof(subject_) - 1;  // 1 byte for trailing 0\n    }\n\n    while (source_.get_index() < length) {\n        GetSet();\n        if (source_.GetError().What() == SET_E) {\n            source_.SetError(NO_ERROR_E);  // extensions may only have sequence \n            source_.prev();\n        }\n        GetSequence();\n\n        byte b = source_.next();\n        if (b != OBJECT_IDENTIFIER) {\n            source_.SetError(OBJECT_ID_E);\n            return;\n        }\n\n        word32 oidSz = GetLength(source_);\n        if (source_.IsLeft(oidSz) == false) return;\n\n        byte joint[2];\n        if (source_.IsLeft(sizeof(joint)) == false) return;\n        memcpy(joint, source_.get_current(), sizeof(joint));\n\n        // v1 name types\n        if (joint[0] == 0x55 && joint[1] == 0x04) {\n            source_.advance(2);\n            byte   id      = source_.next();  \n            b              = source_.next();    // strType\n            word32 strLen  = GetLength(source_);\n\n            if (source_.IsLeft(strLen) == false) return;\n\n            switch (id) {\n            case COMMON_NAME:\n                if (!(ptr = AddTag(ptr, buf_end, \"/CN=\", 4, strLen)))\n                    return;\n                break;\n            case SUR_NAME:\n                if (!(ptr = AddTag(ptr, buf_end, \"/SN=\", 4, strLen)))\n                    return;\n                break;\n            case COUNTRY_NAME:\n                if (!(ptr = AddTag(ptr, buf_end, \"/C=\", 3, strLen)))\n                    return;\n                break;\n            case LOCALITY_NAME:\n                if (!(ptr = AddTag(ptr, buf_end, \"/L=\", 3, strLen)))\n                    return;\n                break;\n            case STATE_NAME:\n                if (!(ptr = AddTag(ptr, buf_end, \"/ST=\", 4, strLen)))\n                    return;\n                break;\n            case ORG_NAME:\n                if (!(ptr = AddTag(ptr, buf_end, \"/O=\", 3, strLen)))\n                    return;\n                break;\n            case ORGUNIT_NAME:\n                if (!(ptr = AddTag(ptr, buf_end, \"/OU=\", 4, strLen)))\n                    return;\n                break;\n            }\n\n            sha.Update(source_.get_current(), strLen);\n            source_.advance(strLen);\n        }\n        else { \n            bool email = false;\n            if (joint[0] == 0x2a && joint[1] == 0x86)  // email id hdr\n                email = true;\n\n            source_.advance(oidSz + 1);\n            word32 length = GetLength(source_);\n            if (source_.IsLeft(length) == false) return;\n\n            if (email) {\n                if (!(ptr = AddTag(ptr, buf_end, \"/emailAddress=\", 14, length)))\n                    return; \n            }\n\n            source_.advance(length);\n        }\n    }\n\n    *ptr = 0;\n\n    if (nt == ISSUER)\n        sha.Final(issuerHash_);\n    else\n        sha.Final(subjectHash_);\n}\n\n\n// process a Date, either BEFORE or AFTER\nvoid CertDecoder::GetDate(DateType dt)\n{\n    if (source_.GetError().What()) return;\n\n    byte b = source_.next();\n    if (b != UTC_TIME && b != GENERALIZED_TIME) {\n        source_.SetError(TIME_E);\n        return;\n    }\n\n    word32 length = GetLength(source_);\n    if (source_.IsLeft(length) == false) return;\n\n    byte date[MAX_DATE_SZ];\n    if (length > MAX_DATE_SZ || length < MIN_DATE_SZ) {\n        source_.SetError(DATE_SZ_E);\n        return;\n    }\n\n    memcpy(date, source_.get_current(), length);\n    source_.advance(length);\n\n    if (!ValidateDate(date, b, dt) && verify_) {\n        if (dt == BEFORE)\n            source_.SetError(BEFORE_DATE_E);\n        else\n            source_.SetError(AFTER_DATE_E);\n    }\n\n    // save for later use\n    if (dt == BEFORE) {\n        memcpy(beforeDate_, date, length);\n        beforeDate_[length] = 0;\n        beforeDateType_= b;\n    }\n    else {  // after\n        memcpy(afterDate_, date, length);\n        afterDate_[length] = 0;\n        afterDateType_= b;\n    }       \n}\n\n\nvoid CertDecoder::GetValidity()\n{\n    if (source_.GetError().What()) return;\n\n    GetSequence();\n    GetDate(BEFORE);\n    GetDate(AFTER);\n}\n\n\nbool CertDecoder::ValidateSelfSignature()\n{\n    Source pub(key_.GetKey(), key_.size());\n    return ConfirmSignature(pub);\n}\n\n\n// extract compare signature hash from plain and place into digest\nvoid CertDecoder::GetCompareHash(const byte* plain, word32 sz, byte* digest,\n                                 word32 digSz)\n{\n    if (source_.GetError().What()) return;\n\n    Source s(plain, sz);\n    CertDecoder dec(s, false);\n\n    dec.GetSequence();\n    dec.GetAlgoId();\n    dec.GetDigest();\n\n    if (dec.sigLength_ > digSz) {\n        source_.SetError(SIG_LEN_E);\n        return;\n    }\n\n    memcpy(digest, dec.signature_, dec.sigLength_);\n}\n\n\n// validate signature signed by someone else\nbool CertDecoder::ValidateSignature(SignerList* signers)\n{\n    if (!signers)\n        return false;\n\n    SignerList::iterator first = signers->begin();\n    SignerList::iterator last  = signers->end();\n\n    while (first != last) {\n        if ( memcmp(issuerHash_, (*first)->GetHash(), SHA::DIGEST_SIZE) == 0) {\n      \n            const PublicKey& iKey = (*first)->GetPublicKey();\n            Source pub(iKey.GetKey(), iKey.size());\n            return ConfirmSignature(pub);\n        }   \n        ++first;\n    }\n    return false;\n}\n\n\n// confirm certificate signature\nbool CertDecoder::ConfirmSignature(Source& pub)\n{\n    HashType ht;\n    mySTL::auto_ptr<HASH> hasher;\n\n    if (signatureOID_ == MD5wRSA) {\n        hasher.reset(NEW_TC MD5);\n        ht = MD5h;\n    }\n    else if (signatureOID_ == MD2wRSA) {\n        hasher.reset(NEW_TC MD2);\n        ht = MD2h;\n    }\n    else if (signatureOID_ == SHAwRSA || signatureOID_ == SHAwDSA) {\n        hasher.reset(NEW_TC SHA);\n        ht = SHAh;\n    }\n    else if (signatureOID_ == SHA256wRSA || signatureOID_ == SHA256wDSA) {\n        hasher.reset(NEW_TC SHA256);\n        ht = SHA256h;\n    }\n#ifdef WORD64_AVAILABLE\n    else if (signatureOID_ == SHA384wRSA) {\n        hasher.reset(NEW_TC SHA384);\n        ht = SHA384h;\n    }\n    else if (signatureOID_ == SHA512wRSA) {\n        hasher.reset(NEW_TC SHA512);\n        ht = SHA512h;\n    }\n#endif\n    else {\n        source_.SetError(UNKOWN_SIG_E);\n        return false;\n    }\n\n    byte digest[MAX_SHA2_DIGEST_SIZE];      // largest size\n\n    hasher->Update(source_.get_buffer() + certBegin_, sigIndex_ - certBegin_);\n    hasher->Final(digest);\n\n    if (keyOID_ == RSAk) {\n        // put in ASN.1 signature format\n        Source build;\n        Signature_Encoder(digest, hasher->getDigestSize(), ht, build);\n\n        RSA_PublicKey pubKey(pub);\n        RSAES_Encryptor enc(pubKey);\n\n        if (pubKey.FixedCiphertextLength() != sigLength_) {\n            source_.SetError(SIG_LEN_E);\n            return false;\n        }\n\n        return enc.SSL_Verify(build.get_buffer(), build.size(), signature_);\n    }\n    else  { // DSA\n        // extract r and s from sequence\n        byte seqDecoded[DSA_SIG_SZ];\n        memset(seqDecoded, 0, sizeof(seqDecoded));\n        DecodeDSA_Signature(seqDecoded, signature_, sigLength_);\n\n        DSA_PublicKey pubKey(pub);\n        DSA_Verifier  ver(pubKey);\n\n        return ver.Verify(digest, seqDecoded);\n    }\n}\n\n\nSignature_Encoder::Signature_Encoder(const byte* dig, word32 digSz,\n                                     HashType digOID, Source& source)\n{\n    // build bottom up\n\n    // Digest\n    byte digArray[MAX_DIGEST_SZ];\n    word32 digestSz = SetDigest(dig, digSz, digArray);\n\n    // AlgoID\n    byte algoArray[MAX_ALGO_SZ];\n    word32 algoSz = SetAlgoID(digOID, algoArray);\n\n    // Sequence\n    byte seqArray[MAX_SEQ_SZ];\n    word32 seqSz = SetSequence(digestSz + algoSz, seqArray);\n\n    source.grow(seqSz + algoSz + digestSz);  // make sure enough room\n    source.add(seqArray,  seqSz);\n    source.add(algoArray, algoSz);\n    source.add(digArray,  digestSz);\n}\n\n\n\nword32 Signature_Encoder::SetDigest(const byte* d, word32 dSz, byte* output)\n{\n    output[0] = OCTET_STRING;\n    output[1] = dSz;\n    memcpy(&output[2], d, dSz);\n    \n    return dSz + 2;\n}\n\n\n\nword32 DER_Encoder::SetAlgoID(HashType aOID, byte* output)\n{\n    // adding TAG_NULL and 0 to end\n    static const byte shaAlgoID[] = { 0x2b, 0x0e, 0x03, 0x02, 0x1a,\n                                      0x05, 0x00 };\n    static const byte md5AlgoID[] = { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,\n                                      0x02, 0x05, 0x05, 0x00  };\n    static const byte md2AlgoID[] = { 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d,\n                                      0x02, 0x02, 0x05, 0x00};\n    static const byte sha256AlgoID[] = { 0x60, 0x86, 0x48, 0x01, 0x65, 0x03,\n                                         0x04, 0x02, 0x01, 0x05, 0x00 };\n    static const byte sha384AlgoID[] = { 0x60, 0x86, 0x48, 0x01, 0x65, 0x03,\n                                         0x04, 0x02, 0x02, 0x05, 0x00 };\n    static const byte sha512AlgoID[] = { 0x60, 0x86, 0x48, 0x01, 0x65, 0x03,\n                                         0x04, 0x02, 0x03, 0x05, 0x00 };\n    int algoSz = 0;\n    const byte* algoName = 0;\n\n    switch (aOID) {\n    case SHAh:\n        algoSz = sizeof(shaAlgoID);\n        algoName = shaAlgoID;\n        break;\n\n    case SHA256h:\n        algoSz = sizeof(sha256AlgoID);\n        algoName = sha256AlgoID;\n        break;\n\n    case SHA384h:\n        algoSz = sizeof(sha384AlgoID);\n        algoName = sha384AlgoID;\n        break;\n\n    case SHA512h:\n        algoSz = sizeof(sha512AlgoID);\n        algoName = sha512AlgoID;\n        break;\n\n    case MD2h:\n        algoSz = sizeof(md2AlgoID);\n        algoName = md2AlgoID;\n        break;\n\n    case MD5h:\n        algoSz = sizeof(md5AlgoID);\n        algoName = md5AlgoID;\n        break;\n\n    default:\n        error_.SetError(UNKOWN_HASH_E);\n        return 0;\n    }\n\n\n    byte ID_Length[MAX_LENGTH_SZ];\n    word32 idSz = SetLength(algoSz - 2, ID_Length); // don't include TAG_NULL/0\n\n    byte seqArray[MAX_SEQ_SZ + 1];  // add object_id to end\n    word32 seqSz = SetSequence(idSz + algoSz + 1, seqArray);\n    seqArray[seqSz++] = OBJECT_IDENTIFIER;\n\n    memcpy(output, seqArray, seqSz);\n    memcpy(output + seqSz, ID_Length, idSz);\n    memcpy(output + seqSz + idSz, algoName, algoSz);\n\n    return seqSz + idSz + algoSz;\n}\n\n\nword32 SetSequence(word32 len, byte* output)\n{\n  \n    output[0] = SEQUENCE | CONSTRUCTED;\n    return SetLength(len, output + 1) + 1;\n}\n\n\nword32 EncodeDSA_Signature(const byte* signature, byte* output)\n{\n    Integer r(signature, 20);\n    Integer s(signature + 20, 20);\n\n    return EncodeDSA_Signature(r, s, output);\n}\n\n\nword32 EncodeDSA_Signature(const Integer& r, const Integer& s, byte* output)\n{\n    word32 rSz = r.ByteCount();\n    word32 sSz = s.ByteCount();\n\n    byte rLen[MAX_LENGTH_SZ + 1];\n    byte sLen[MAX_LENGTH_SZ + 1];\n\n    rLen[0] = INTEGER;\n    sLen[0] = INTEGER;\n\n    word32 rLenSz = SetLength(rSz, &rLen[1]) + 1;\n    word32 sLenSz = SetLength(sSz, &sLen[1]) + 1;\n\n    byte seqArray[MAX_SEQ_SZ];\n\n    word32 seqSz = SetSequence(rLenSz + rSz + sLenSz + sSz, seqArray);\n    \n    // seq\n    memcpy(output, seqArray, seqSz);\n    // r\n    memcpy(output + seqSz, rLen, rLenSz);\n    r.Encode(output + seqSz + rLenSz, rSz);\n    // s\n    memcpy(output + seqSz + rLenSz + rSz, sLen, sLenSz);\n    s.Encode(output + seqSz + rLenSz + rSz + sLenSz, sSz);\n\n    return seqSz + rLenSz + rSz + sLenSz + sSz;\n}\n\n\n// put sequence encoded dsa signature into decoded in 2 20 byte integers\nword32 DecodeDSA_Signature(byte* decoded, const byte* encoded, word32 sz)\n{\n    Source source(encoded, sz);\n\n    if (source.next() != (SEQUENCE | CONSTRUCTED)) {\n        source.SetError(SEQUENCE_E);\n        return 0;\n    }\n\n    GetLength(source);  // total\n\n    // r\n    if (source.next() != INTEGER) {\n        source.SetError(INTEGER_E);\n        return 0;\n    }\n    word32 rLen = GetLength(source);\n    if (rLen != 20) {\n        if (rLen == 21) {       // zero at front, eat\n            source.next();\n            --rLen;\n        }\n        else if (rLen == 19) {  // add zero to front so 20 bytes\n            decoded[0] = 0;\n            decoded++;\n        }\n        else {\n            source.SetError(DSA_SZ_E);\n            return 0;\n        }\n    }\n    memcpy(decoded, source.get_buffer() + source.get_index(), rLen);\n    source.advance(rLen);\n\n    // s\n    if (source.next() != INTEGER) {\n        source.SetError(INTEGER_E);\n        return 0;\n    }\n    word32 sLen = GetLength(source);\n    if (sLen != 20) {\n        if (sLen == 21) {\n            source.next();          // zero at front, eat\n            --sLen;\n        }\n        else if (sLen == 19) {\n            decoded[rLen] = 0;      // add zero to front so 20 bytes\n            decoded++;\n        }\n        else {\n            source.SetError(DSA_SZ_E);\n            return 0;\n        }\n    }\n    memcpy(decoded + rLen, source.get_buffer() + source.get_index(), sLen);\n    source.advance(sLen);\n\n    return 40;\n}\n\n\n/*\n// Get Cert in PEM format from BEGIN to END\nint GetCert(Source& source)\n{\n    char header[] = \"-----BEGIN CERTIFICATE-----\";\n    char footer[] = \"-----END CERTIFICATE-----\";\n\n    char* begin = strstr((char*)source.get_buffer(), header);\n    char* end   = strstr((char*)source.get_buffer(), footer);\n\n    if (!begin || !end || begin >= end) return -1;\n\n    end += strlen(footer); \n    if (*end == '\\r') end++;\n\n    Source tmp((byte*)begin, end - begin + 1);\n    source.Swap(tmp);\n\n    return 0;\n}\n\n\n\n// Decode a BER encoded PKCS12 structure\nvoid PKCS12_Decoder::Decode()\n{\n    ReadHeader();\n    if (source_.GetError().What()) return;\n\n    // Get AuthSafe\n\n    GetSequence();\n    \n        // get object id\n    byte obj_id = source_.next();\n    if (obj_id != OBJECT_IDENTIFIER) {\n        source_.SetError(OBJECT_ID_E);\n        return;\n    }\n\n    word32 length = GetLength(source_);\n\n    word32 algo_sum = 0;\n    while (length--)\n        algo_sum += source_.next();\n\n    \n       \n\n\n\n    // Get MacData optional\n    // mac     digestInfo  like certdecoder::getdigest?\n    // macsalt octet string\n    // iter    integer\n    \n}\n\n\nvoid PKCS12_Decoder::ReadHeader()\n{\n    // Gets Version\n    GetSequence();\n    GetVersion();\n}\n\n\n// Get Cert in PEM format from pkcs12 file\nint GetPKCS_Cert(const char* password, Source& source)\n{\n    PKCS12_Decoder pkcs12(source);\n    pkcs12.Decode();\n\n    return 0;\n}\n*/\n\n\n\n} // namespace\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/bftables.cpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* based on Wei Dai's bfinit.cpp from CryptoPP */\n\n#include \"runtime.hpp\"\n#include \"blowfish.hpp\"\n\n\nnamespace TaoCrypt {\n\nconst word32 Blowfish::p_init_[Blowfish::ROUNDS+2] =\n{\n  608135816U, 2242054355U,  320440878U,   57701188U,\n 2752067618U,  698298832U,  137296536U, 3964562569U,\n 1160258022U,  953160567U, 3193202383U,  887688300U,\n 3232508343U, 3380367581U, 1065670069U, 3041331479U,\n 2450970073U, 2306472731U\n} ;\n\n\nconst word32 Blowfish::s_init_[4*256] = {\n 3509652390U, 2564797868U,  805139163U, 3491422135U,\n 3101798381U, 1780907670U, 3128725573U, 4046225305U,\n  614570311U, 3012652279U,  134345442U, 2240740374U,\n 1667834072U, 1901547113U, 2757295779U, 4103290238U,\n  227898511U, 1921955416U, 1904987480U, 2182433518U,\n 2069144605U, 3260701109U, 2620446009U,  720527379U,\n 3318853667U,  677414384U, 3393288472U, 3101374703U,\n 2390351024U, 1614419982U, 1822297739U, 2954791486U,\n 3608508353U, 3174124327U, 2024746970U, 1432378464U,\n 3864339955U, 2857741204U, 1464375394U, 1676153920U,\n 1439316330U,  715854006U, 3033291828U,  289532110U,\n 2706671279U, 2087905683U, 3018724369U, 1668267050U,\n  732546397U, 1947742710U, 3462151702U, 2609353502U,\n 2950085171U, 1814351708U, 2050118529U,  680887927U,\n  999245976U, 1800124847U, 3300911131U, 1713906067U,\n 1641548236U, 4213287313U, 1216130144U, 1575780402U,\n 4018429277U, 3917837745U, 3693486850U, 3949271944U,\n  596196993U, 3549867205U,  258830323U, 2213823033U,\n  772490370U, 2760122372U, 1774776394U, 2652871518U,\n  566650946U, 4142492826U, 1728879713U, 2882767088U,\n 1783734482U, 3629395816U, 2517608232U, 2874225571U,\n 1861159788U,  326777828U, 3124490320U, 2130389656U,\n 2716951837U,  967770486U, 1724537150U, 2185432712U,\n 2364442137U, 1164943284U, 2105845187U,  998989502U,\n 3765401048U, 2244026483U, 1075463327U, 1455516326U,\n 1322494562U,  910128902U,  469688178U, 1117454909U,\n  936433444U, 3490320968U, 3675253459U, 1240580251U,\n  122909385U, 2157517691U,  634681816U, 4142456567U,\n 3825094682U, 3061402683U, 2540495037U,   79693498U,\n 3249098678U, 1084186820U, 1583128258U,  426386531U,\n 1761308591U, 1047286709U,  322548459U,  995290223U,\n 1845252383U, 2603652396U, 3431023940U, 2942221577U,\n 3202600964U, 3727903485U, 1712269319U,  422464435U,\n 3234572375U, 1170764815U, 3523960633U, 3117677531U,\n 1434042557U,  442511882U, 3600875718U, 1076654713U,\n 1738483198U, 4213154764U, 2393238008U, 3677496056U,\n 1014306527U, 4251020053U,  793779912U, 2902807211U,\n  842905082U, 4246964064U, 1395751752U, 1040244610U,\n 2656851899U, 3396308128U,  445077038U, 3742853595U,\n 3577915638U,  679411651U, 2892444358U, 2354009459U,\n 1767581616U, 3150600392U, 3791627101U, 3102740896U,\n  284835224U, 4246832056U, 1258075500U,  768725851U,\n 2589189241U, 3069724005U, 3532540348U, 1274779536U,\n 3789419226U, 2764799539U, 1660621633U, 3471099624U,\n 4011903706U,  913787905U, 3497959166U,  737222580U,\n 2514213453U, 2928710040U, 3937242737U, 1804850592U,\n 3499020752U, 2949064160U, 2386320175U, 2390070455U,\n 2415321851U, 4061277028U, 2290661394U, 2416832540U,\n 1336762016U, 1754252060U, 3520065937U, 3014181293U,\n  791618072U, 3188594551U, 3933548030U, 2332172193U,\n 3852520463U, 3043980520U,  413987798U, 3465142937U,\n 3030929376U, 4245938359U, 2093235073U, 3534596313U,\n  375366246U, 2157278981U, 2479649556U,  555357303U,\n 3870105701U, 2008414854U, 3344188149U, 4221384143U,\n 3956125452U, 2067696032U, 3594591187U, 2921233993U,\n\t2428461U,  544322398U,  577241275U, 1471733935U,\n  610547355U, 4027169054U, 1432588573U, 1507829418U,\n 2025931657U, 3646575487U,  545086370U,   48609733U,\n 2200306550U, 1653985193U,  298326376U, 1316178497U,\n 3007786442U, 2064951626U,  458293330U, 2589141269U,\n 3591329599U, 3164325604U,  727753846U, 2179363840U,\n  146436021U, 1461446943U, 4069977195U,  705550613U,\n 3059967265U, 3887724982U, 4281599278U, 3313849956U,\n 1404054877U, 2845806497U,  146425753U, 1854211946U,\n\n 1266315497U, 3048417604U, 3681880366U, 3289982499U,\n 2909710000U, 1235738493U, 2632868024U, 2414719590U,\n 3970600049U, 1771706367U, 1449415276U, 3266420449U,\n  422970021U, 1963543593U, 2690192192U, 3826793022U,\n 1062508698U, 1531092325U, 1804592342U, 2583117782U,\n 2714934279U, 4024971509U, 1294809318U, 4028980673U,\n 1289560198U, 2221992742U, 1669523910U,   35572830U,\n  157838143U, 1052438473U, 1016535060U, 1802137761U,\n 1753167236U, 1386275462U, 3080475397U, 2857371447U,\n 1040679964U, 2145300060U, 2390574316U, 1461121720U,\n 2956646967U, 4031777805U, 4028374788U,   33600511U,\n 2920084762U, 1018524850U,  629373528U, 3691585981U,\n 3515945977U, 2091462646U, 2486323059U,  586499841U,\n  988145025U,  935516892U, 3367335476U, 2599673255U,\n 2839830854U,  265290510U, 3972581182U, 2759138881U,\n 3795373465U, 1005194799U,  847297441U,  406762289U,\n 1314163512U, 1332590856U, 1866599683U, 4127851711U,\n  750260880U,  613907577U, 1450815602U, 3165620655U,\n 3734664991U, 3650291728U, 3012275730U, 3704569646U,\n 1427272223U,  778793252U, 1343938022U, 2676280711U,\n 2052605720U, 1946737175U, 3164576444U, 3914038668U,\n 3967478842U, 3682934266U, 1661551462U, 3294938066U,\n 4011595847U,  840292616U, 3712170807U,  616741398U,\n  312560963U,  711312465U, 1351876610U,  322626781U,\n 1910503582U,  271666773U, 2175563734U, 1594956187U,\n   70604529U, 3617834859U, 1007753275U, 1495573769U,\n 4069517037U, 2549218298U, 2663038764U,  504708206U,\n 2263041392U, 3941167025U, 2249088522U, 1514023603U,\n 1998579484U, 1312622330U,  694541497U, 2582060303U,\n 2151582166U, 1382467621U,  776784248U, 2618340202U,\n 3323268794U, 2497899128U, 2784771155U,  503983604U,\n 4076293799U,  907881277U,  423175695U,  432175456U,\n 1378068232U, 4145222326U, 3954048622U, 3938656102U,\n 3820766613U, 2793130115U, 2977904593U,   26017576U,\n 3274890735U, 3194772133U, 1700274565U, 1756076034U,\n 4006520079U, 3677328699U,  720338349U, 1533947780U,\n  354530856U,  688349552U, 3973924725U, 1637815568U,\n  332179504U, 3949051286U,   53804574U, 2852348879U,\n 3044236432U, 1282449977U, 3583942155U, 3416972820U,\n 4006381244U, 1617046695U, 2628476075U, 3002303598U,\n 1686838959U,  431878346U, 2686675385U, 1700445008U,\n 1080580658U, 1009431731U,  832498133U, 3223435511U,\n 2605976345U, 2271191193U, 2516031870U, 1648197032U,\n 4164389018U, 2548247927U,  300782431U,  375919233U,\n  238389289U, 3353747414U, 2531188641U, 2019080857U,\n 1475708069U,  455242339U, 2609103871U,  448939670U,\n 3451063019U, 1395535956U, 2413381860U, 1841049896U,\n 1491858159U,  885456874U, 4264095073U, 4001119347U,\n 1565136089U, 3898914787U, 1108368660U,  540939232U,\n 1173283510U, 2745871338U, 3681308437U, 4207628240U,\n 3343053890U, 4016749493U, 1699691293U, 1103962373U,\n 3625875870U, 2256883143U, 3830138730U, 1031889488U,\n 3479347698U, 1535977030U, 4236805024U, 3251091107U,\n 2132092099U, 1774941330U, 1199868427U, 1452454533U,\n  157007616U, 2904115357U,  342012276U,  595725824U,\n 1480756522U,  206960106U,  497939518U,  591360097U,\n  863170706U, 2375253569U, 3596610801U, 1814182875U,\n 2094937945U, 3421402208U, 1082520231U, 3463918190U,\n 2785509508U,  435703966U, 3908032597U, 1641649973U,\n 2842273706U, 3305899714U, 1510255612U, 2148256476U,\n 2655287854U, 3276092548U, 4258621189U,  236887753U,\n 3681803219U,  274041037U, 1734335097U, 3815195456U,\n 3317970021U, 1899903192U, 1026095262U, 4050517792U,\n  356393447U, 2410691914U, 3873677099U, 3682840055U,\n\n 3913112168U, 2491498743U, 4132185628U, 2489919796U,\n 1091903735U, 1979897079U, 3170134830U, 3567386728U,\n 3557303409U,  857797738U, 1136121015U, 1342202287U,\n  507115054U, 2535736646U,  337727348U, 3213592640U,\n 1301675037U, 2528481711U, 1895095763U, 1721773893U,\n 3216771564U,   62756741U, 2142006736U,  835421444U,\n 2531993523U, 1442658625U, 3659876326U, 2882144922U,\n  676362277U, 1392781812U,  170690266U, 3921047035U,\n 1759253602U, 3611846912U, 1745797284U,  664899054U,\n 1329594018U, 3901205900U, 3045908486U, 2062866102U,\n 2865634940U, 3543621612U, 3464012697U, 1080764994U,\n  553557557U, 3656615353U, 3996768171U,  991055499U,\n  499776247U, 1265440854U,  648242737U, 3940784050U,\n  980351604U, 3713745714U, 1749149687U, 3396870395U,\n 4211799374U, 3640570775U, 1161844396U, 3125318951U,\n 1431517754U,  545492359U, 4268468663U, 3499529547U,\n 1437099964U, 2702547544U, 3433638243U, 2581715763U,\n 2787789398U, 1060185593U, 1593081372U, 2418618748U,\n 4260947970U,   69676912U, 2159744348U,   86519011U,\n 2512459080U, 3838209314U, 1220612927U, 3339683548U,\n  133810670U, 1090789135U, 1078426020U, 1569222167U,\n  845107691U, 3583754449U, 4072456591U, 1091646820U,\n  628848692U, 1613405280U, 3757631651U,  526609435U,\n  236106946U,   48312990U, 2942717905U, 3402727701U,\n 1797494240U,  859738849U,  992217954U, 4005476642U,\n 2243076622U, 3870952857U, 3732016268U,  765654824U,\n 3490871365U, 2511836413U, 1685915746U, 3888969200U,\n 1414112111U, 2273134842U, 3281911079U, 4080962846U,\n  172450625U, 2569994100U,  980381355U, 4109958455U,\n 2819808352U, 2716589560U, 2568741196U, 3681446669U,\n 3329971472U, 1835478071U,  660984891U, 3704678404U,\n 4045999559U, 3422617507U, 3040415634U, 1762651403U,\n 1719377915U, 3470491036U, 2693910283U, 3642056355U,\n 3138596744U, 1364962596U, 2073328063U, 1983633131U,\n  926494387U, 3423689081U, 2150032023U, 4096667949U,\n 1749200295U, 3328846651U,  309677260U, 2016342300U,\n 1779581495U, 3079819751U,  111262694U, 1274766160U,\n  443224088U,  298511866U, 1025883608U, 3806446537U,\n 1145181785U,  168956806U, 3641502830U, 3584813610U,\n 1689216846U, 3666258015U, 3200248200U, 1692713982U,\n 2646376535U, 4042768518U, 1618508792U, 1610833997U,\n 3523052358U, 4130873264U, 2001055236U, 3610705100U,\n 2202168115U, 4028541809U, 2961195399U, 1006657119U,\n 2006996926U, 3186142756U, 1430667929U, 3210227297U,\n 1314452623U, 4074634658U, 4101304120U, 2273951170U,\n 1399257539U, 3367210612U, 3027628629U, 1190975929U,\n 2062231137U, 2333990788U, 2221543033U, 2438960610U,\n 1181637006U,  548689776U, 2362791313U, 3372408396U,\n 3104550113U, 3145860560U,  296247880U, 1970579870U,\n 3078560182U, 3769228297U, 1714227617U, 3291629107U,\n 3898220290U,  166772364U, 1251581989U,  493813264U,\n  448347421U,  195405023U, 2709975567U,  677966185U,\n 3703036547U, 1463355134U, 2715995803U, 1338867538U,\n 1343315457U, 2802222074U, 2684532164U,  233230375U,\n 2599980071U, 2000651841U, 3277868038U, 1638401717U,\n 4028070440U, 3237316320U,    6314154U,  819756386U,\n  300326615U,  590932579U, 1405279636U, 3267499572U,\n 3150704214U, 2428286686U, 3959192993U, 3461946742U,\n 1862657033U, 1266418056U,  963775037U, 2089974820U,\n 2263052895U, 1917689273U,  448879540U, 3550394620U,\n 3981727096U,  150775221U, 3627908307U, 1303187396U,\n  508620638U, 2975983352U, 2726630617U, 1817252668U,\n 1876281319U, 1457606340U,  908771278U, 3720792119U,\n 3617206836U, 2455994898U, 1729034894U, 1080033504U,\n\n  976866871U, 3556439503U, 2881648439U, 1522871579U,\n 1555064734U, 1336096578U, 3548522304U, 2579274686U,\n 3574697629U, 3205460757U, 3593280638U, 3338716283U,\n 3079412587U,  564236357U, 2993598910U, 1781952180U,\n 1464380207U, 3163844217U, 3332601554U, 1699332808U,\n 1393555694U, 1183702653U, 3581086237U, 1288719814U,\n  691649499U, 2847557200U, 2895455976U, 3193889540U,\n 2717570544U, 1781354906U, 1676643554U, 2592534050U,\n 3230253752U, 1126444790U, 2770207658U, 2633158820U,\n 2210423226U, 2615765581U, 2414155088U, 3127139286U,\n  673620729U, 2805611233U, 1269405062U, 4015350505U,\n 3341807571U, 4149409754U, 1057255273U, 2012875353U,\n 2162469141U, 2276492801U, 2601117357U,  993977747U,\n 3918593370U, 2654263191U,  753973209U,   36408145U,\n 2530585658U,   25011837U, 3520020182U, 2088578344U,\n  530523599U, 2918365339U, 1524020338U, 1518925132U,\n 3760827505U, 3759777254U, 1202760957U, 3985898139U,\n 3906192525U,  674977740U, 4174734889U, 2031300136U,\n 2019492241U, 3983892565U, 4153806404U, 3822280332U,\n  352677332U, 2297720250U,   60907813U,   90501309U,\n 3286998549U, 1016092578U, 2535922412U, 2839152426U,\n  457141659U,  509813237U, 4120667899U,  652014361U,\n 1966332200U, 2975202805U,   55981186U, 2327461051U,\n  676427537U, 3255491064U, 2882294119U, 3433927263U,\n 1307055953U,  942726286U,  933058658U, 2468411793U,\n 3933900994U, 4215176142U, 1361170020U, 2001714738U,\n 2830558078U, 3274259782U, 1222529897U, 1679025792U,\n 2729314320U, 3714953764U, 1770335741U,  151462246U,\n 3013232138U, 1682292957U, 1483529935U,  471910574U,\n 1539241949U,  458788160U, 3436315007U, 1807016891U,\n 3718408830U,  978976581U, 1043663428U, 3165965781U,\n 1927990952U, 4200891579U, 2372276910U, 3208408903U,\n 3533431907U, 1412390302U, 2931980059U, 4132332400U,\n 1947078029U, 3881505623U, 4168226417U, 2941484381U,\n 1077988104U, 1320477388U,  886195818U,   18198404U,\n 3786409000U, 2509781533U,  112762804U, 3463356488U,\n 1866414978U,  891333506U,   18488651U,  661792760U,\n 1628790961U, 3885187036U, 3141171499U,  876946877U,\n 2693282273U, 1372485963U,  791857591U, 2686433993U,\n 3759982718U, 3167212022U, 3472953795U, 2716379847U,\n  445679433U, 3561995674U, 3504004811U, 3574258232U,\n   54117162U, 3331405415U, 2381918588U, 3769707343U,\n 4154350007U, 1140177722U, 4074052095U,  668550556U,\n 3214352940U,  367459370U,  261225585U, 2610173221U,\n 4209349473U, 3468074219U, 3265815641U,  314222801U,\n 3066103646U, 3808782860U,  282218597U, 3406013506U,\n 3773591054U,  379116347U, 1285071038U,  846784868U,\n 2669647154U, 3771962079U, 3550491691U, 2305946142U,\n  453669953U, 1268987020U, 3317592352U, 3279303384U,\n 3744833421U, 2610507566U, 3859509063U,  266596637U,\n 3847019092U,  517658769U, 3462560207U, 3443424879U,\n  370717030U, 4247526661U, 2224018117U, 4143653529U,\n 4112773975U, 2788324899U, 2477274417U, 1456262402U,\n 2901442914U, 1517677493U, 1846949527U, 2295493580U,\n 3734397586U, 2176403920U, 1280348187U, 1908823572U,\n 3871786941U,  846861322U, 1172426758U, 3287448474U,\n 3383383037U, 1655181056U, 3139813346U,  901632758U,\n 1897031941U, 2986607138U, 3066810236U, 3447102507U,\n 1393639104U,  373351379U,  950779232U,  625454576U,\n 3124240540U, 4148612726U, 2007998917U,  544563296U,\n 2244738638U, 2330496472U, 2058025392U, 1291430526U,\n  424198748U,   50039436U,   29584100U, 3605783033U,\n 2429876329U, 2791104160U, 1057563949U, 3255363231U,\n 3075367218U, 3463963227U, 1469046755U,  985887462U\n};\n\n\n\n\n} // namespace\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/blowfish.cpp",
    "content": "/*\n   Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* C++ code based on Wei Dai's blowfish.cpp from CryptoPP */\n/* x86 asm is original */\n\n\n#if defined(TAOCRYPT_KERNEL_MODE)\n    #define DO_TAOCRYPT_KERNEL_MODE\n#endif                                  // only some modules now support this\n\n\n#include \"runtime.hpp\"\n#include \"blowfish.hpp\"\n\n\n\n\n\nnamespace TaoCrypt {\n\n\n#if defined(DO_BLOWFISH_ASM)\n\n// ia32 optimized version\nvoid Blowfish::Process(byte* out, const byte* in, word32 sz)\n{\n    if (!isMMX) {\n        Mode_BASE::Process(out, in, sz);\n        return;\n    }\n\n    word32 blocks = sz / BLOCK_SIZE;\n\n    if (mode_ == ECB)\n        while (blocks--) {\n            AsmProcess(in, out);\n            out += BLOCK_SIZE;\n            in  += BLOCK_SIZE;\n        }\n    else if (mode_ == CBC) {\n        if (dir_ == ENCRYPTION) {\n            while (blocks--) {\n                r_[0] ^= *(word32*)in;\n                r_[1] ^= *(word32*)(in + 4);\n\n                AsmProcess((byte*)r_, (byte*)r_);\n                \n                memcpy(out, r_, BLOCK_SIZE);\n\n                out += BLOCK_SIZE;\n                in  += BLOCK_SIZE;\n            }\n        }\n        else {\n            while (blocks--) {\n                AsmProcess(in, out);\n                \n                *(word32*)out       ^= r_[0];\n                *(word32*)(out + 4) ^= r_[1];\n\n                memcpy(r_, in, BLOCK_SIZE);\n\n                out += BLOCK_SIZE;\n                in  += BLOCK_SIZE;\n            }\n        }\n    }\n}\n\n#endif // DO_BLOWFISH_ASM\n\n\nvoid Blowfish::SetKey(const byte* key_string, word32 keylength, CipherDir dir)\n{\n    if (keylength < 4)\n        keylength = 4;\n    else if (keylength > 56)\n        keylength = 56;\n\n\tunsigned i, j=0, k;\n\tword32 data, dspace[2] = {0, 0};\n\n\tmemcpy(pbox_, p_init_, sizeof(p_init_));\n\tmemcpy(sbox_, s_init_, sizeof(s_init_));\n\n\t// Xor key string into encryption key vector\n\tfor (i=0 ; i<ROUNDS+2 ; ++i) {\n\t\tdata = 0;\n\t\tfor (k=0 ; k<4 ; ++k )\n\t\t\tdata = (data << 8) | key_string[j++ % keylength];\n\t\tpbox_[i] ^= data;\n\t}\n\n\tcrypt_block(dspace, pbox_);\n\n\tfor (i=0; i<ROUNDS; i+=2)\n\t\tcrypt_block(pbox_ + i, pbox_ + i + 2);\n\n\tcrypt_block(pbox_ + ROUNDS, sbox_);\n\n\tfor (i=0; i < 4*256-2; i+=2)\n\t\tcrypt_block(sbox_ + i, sbox_ + i + 2);\n\n\tif (dir==DECRYPTION)\n\t\tfor (i=0; i<(ROUNDS+2)/2; i++)\n\t\t\tSTL::swap(pbox_[i], pbox_[ROUNDS+1-i]);\n}\n\n\n#define BFBYTE_0(x) ( x     &0xFF)\n#define BFBYTE_1(x) ((x>> 8)&0xFF)\n#define BFBYTE_2(x) ((x>>16)&0xFF)\n#define BFBYTE_3(x) ( x>>24)\n\n\n#define BF_S(Put, Get, I) (\\\n        Put ^= p[I], \\\n\t\ttmp =  p[18 + BFBYTE_3(Get)],  \\\n        tmp += p[274+ BFBYTE_2(Get)],  \\\n        tmp ^= p[530+ BFBYTE_1(Get)],  \\\n        tmp += p[786+ BFBYTE_0(Get)],  \\\n        Put ^= tmp \\\n    )\n\n\n#define BF_ROUNDS           \\\n    BF_S(right, left,  1);  \\\n    BF_S(left,  right, 2);  \\\n    BF_S(right, left,  3);  \\\n    BF_S(left,  right, 4);  \\\n    BF_S(right, left,  5);  \\\n    BF_S(left,  right, 6);  \\\n    BF_S(right, left,  7);  \\\n    BF_S(left,  right, 8);  \\\n    BF_S(right, left,  9);  \\\n    BF_S(left,  right, 10); \\\n    BF_S(right, left,  11); \\\n    BF_S(left,  right, 12); \\\n    BF_S(right, left,  13); \\\n    BF_S(left,  right, 14); \\\n    BF_S(right, left,  15); \\\n    BF_S(left,  right, 16); \n\n#define BF_EXTRA_ROUNDS     \\\n    BF_S(right, left,  17); \\\n    BF_S(left,  right, 18); \\\n    BF_S(right, left,  19); \\\n    BF_S(left,  right, 20);\n\n\n// Used by key setup, no byte swapping\nvoid Blowfish::crypt_block(const word32 in[2], word32 out[2]) const\n{\n\tword32 left  = in[0];\n\tword32 right = in[1];\n\n\tconst word32  *const s = sbox_;\n\tconst word32* p = pbox_;\n\n\tleft ^= p[0];\n\n    // roll back up and use s and p index instead of just p\n    for (unsigned i = 0; i < ROUNDS / 2; i++) {\n        right ^= (((s[GETBYTE(left,3)] + s[256+GETBYTE(left,2)])\n            ^ s[2*256+GETBYTE(left,1)]) + s[3*256+GETBYTE(left,0)])\n            ^ p[2*i+1];\n\n        left ^= (((s[GETBYTE(right,3)] + s[256+GETBYTE(right,2)])\n            ^ s[2*256+GETBYTE(right,1)]) + s[3*256+GETBYTE(right,0)])\n            ^ p[2*i+2];\n    }\n\n\tright ^= p[ROUNDS + 1];\n\n\tout[0] = right;\n\tout[1] = left;\n}\n\n\ntypedef BlockGetAndPut<word32, BigEndian> gpBlock;\n\nvoid Blowfish::ProcessAndXorBlock(const byte* in, const byte* xOr, byte* out)\n    const\n{\n    word32 left, right;\n\tconst word32  *const s = sbox_;\n    const word32* p = pbox_;\n    \n    gpBlock::Get(in)(left)(right);\n\tleft ^= p[0];\n\n    // roll back up and use s and p index instead of just p\n    for (unsigned i = 0; i < ROUNDS / 2; i++) {\n        right ^= (((s[GETBYTE(left,3)] + s[256+GETBYTE(left,2)])\n            ^ s[2*256+GETBYTE(left,1)]) + s[3*256+GETBYTE(left,0)])\n            ^ p[2*i+1];\n\n        left ^= (((s[GETBYTE(right,3)] + s[256+GETBYTE(right,2)])\n            ^ s[2*256+GETBYTE(right,1)]) + s[3*256+GETBYTE(right,0)])\n            ^ p[2*i+2];\n    }\n\n\tright ^= p[ROUNDS + 1];\n\n    gpBlock::Put(xOr, out)(right)(left);\n}\n\n\n#if defined(DO_BLOWFISH_ASM)\n    #ifdef __GNUC__\n        #define AS1(x)    #x \";\"\n        #define AS2(x, y) #x \", \" #y \";\"\n\n        #define PROLOG()  \\\n        __asm__ __volatile__ \\\n        ( \\\n            \".intel_syntax noprefix;\" \\\n            \"push ebx;\" \\\n            \"push ebp;\" \\\n            \"movd mm3, eax;\"\n        #define EPILOG()  \\\n            \"pop ebp;\" \\\n            \"pop ebx;\" \\\n       \t    \"emms;\" \\\n       \t    \".att_syntax;\" \\\n                : \\\n                : \"c\" (this), \"S\" (inBlock), \"a\" (outBlock) \\\n                : \"%edi\", \"%edx\", \"memory\", \"cc\" \\\n        );\n\n    #else\n        #define AS1(x)    __asm x\n        #define AS2(x, y) __asm x, y\n\n        #define PROLOG() \\\n            AS1(    push  ebp                           )   \\\n            AS2(    mov   ebp, esp                      )   \\\n            AS2(    movd  mm3, edi                      )   \\\n            AS2(    movd  mm4, ebx                      )   \\\n            AS2(    movd  mm5, esi                      )   \\\n            AS2(    mov   esi, DWORD PTR [ebp +  8]     )\n\n        #define EPILOG()  \\\n            AS2(    movd esi, mm5                       )   \\\n            AS2(    movd ebx, mm4                       )   \\\n            AS2(    movd edi, mm3                       )   \\\n            AS2(    mov  esp, ebp                       )   \\\n            AS1(    pop  ebp                            )   \\\n            AS1(    emms                                )   \\\n            AS1(    ret 8                               )\n            \n    #endif\n\n\n#define BF_ROUND(P, G, I)   \\\n    /* Put ^= p[I]  */                              \\\n    AS2(    xor   P,   [edi + I*4]              )   \\\n    /* tmp =  p[18 + BFBYTE_3(Get)] */              \\\n    AS2(    mov   ecx, G                        )   \\\n    AS2(    shr   ecx, 16                       )   \\\n    AS2(    movzx edx, ch                       )   \\\n    AS2(    mov   esi, [edi + edx*4 +   72]     )   \\\n    /* tmp += p[274+ BFBYTE_2(Get)] */              \\\n    AS2(    movzx ecx, cl                       )   \\\n    AS2(    add   esi, [edi + ecx*4 + 1096]     )   \\\n    /* tmp ^= p[530+ BFBYTE_1(Get)] */              \\\n    AS2(    mov   ecx, G                        )   \\\n    AS2(    movzx edx, ch                       )   \\\n    AS2(    xor   esi, [edi + edx*4 + 2120]     )   \\\n    /* tmp += p[786+ BFBYTE_0(Get)] */              \\\n    AS2(    movzx ecx, cl                       )   \\\n    AS2(    add   esi, [edi + ecx*4 + 3144]     )   \\\n    /* Put ^= tmp */                                \\\n    AS2(    xor   P,   esi                      )\n\n\n#ifdef _MSC_VER\n    __declspec(naked) \n#else\n    __attribute__ ((noinline))\n#endif\nvoid Blowfish::AsmProcess(const byte* inBlock, byte* outBlock) const\n{\n    PROLOG()\n\n    #ifdef OLD_GCC_OFFSET\n        AS2(    lea   edi, [ecx + 60]                       )   // pbox\n    #else\n        AS2(    lea   edi, [ecx + 56]                       )   // pbox\n    #endif\n\n    AS2(    mov   eax, DWORD PTR [esi]                                  )\n    AS2(    mov   edx, DWORD PTR [edi]                                  )\n    AS1(    bswap eax                                                   )\n\n    AS2(    mov   ebx, DWORD PTR [esi + 4]                              )\n    AS2(    xor   eax, edx                      )   // left\n    AS1(    bswap ebx                           )   // right\n\n\n    BF_ROUND(ebx, eax, 1)\n    BF_ROUND(eax, ebx, 2)\n    BF_ROUND(ebx, eax, 3)\n    BF_ROUND(eax, ebx, 4)\n    BF_ROUND(ebx, eax, 5)\n    BF_ROUND(eax, ebx, 6)\n    BF_ROUND(ebx, eax, 7)\n    BF_ROUND(eax, ebx, 8)\n    BF_ROUND(ebx, eax, 9)\n    BF_ROUND(eax, ebx, 10)\n    BF_ROUND(ebx, eax, 11)\n    BF_ROUND(eax, ebx, 12)\n    BF_ROUND(ebx, eax, 13)\n    BF_ROUND(eax, ebx, 14)\n    BF_ROUND(ebx, eax, 15)\n    BF_ROUND(eax, ebx, 16)\n    #if ROUNDS == 20\n        BF_ROUND(ebx, eax, 17)\n        BF_ROUND(eax, ebx, 18)\n        BF_ROUND(ebx, eax, 19)\n        BF_ROUND(eax, ebx, 20)\n\n        AS2(    xor   ebx, [edi + 84]           )   // 20 + 1 (x4)\n    #else\n        AS2(    xor   ebx, [edi + 68]           )   // 16 + 1 (x4)\n    #endif\n\n    #ifdef __GNUC__\n        AS2(    movd  edi, mm3                  ) // outBlock\n    #else\n        AS2(    mov   edi, [ebp + 12]           ) // outBlock\n    #endif\n\n    AS1(    bswap ebx                           )\n    AS1(    bswap eax                           )\n\n    AS2(    mov   [edi]    , ebx                )\n    AS2(    mov   [edi + 4], eax                )\n\n    EPILOG()\n}\n\n\n#endif  // DO_BLOWFISH_ASM\n\n\n} // namespace\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/coding.cpp",
    "content": "/*\n   Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* coding.cpp implements hex and base64 encoding/decoing\n*/\n\n#include \"runtime.hpp\"\n#include \"coding.hpp\"\n#include \"file.hpp\"\n\n\nnamespace TaoCrypt {\n\n\nnamespace { // locals\n\nconst byte bad = 0xFF;  // invalid encoding\n\nconst byte hexEncode[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',\n                           'A', 'B', 'C', 'D', 'E', 'F'\n                         };\n\nconst byte hexDecode[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n                           bad, bad, bad, bad, bad, bad, bad,\n                           10, 11, 12, 13, 14, 15 \n                         };  // A starts at 0x41 not 0x3A\n\n\nconst byte base64Encode[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',\n                              'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',\n                              'U', 'V', 'W', 'X', 'Y', 'Z',\n                              'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',\n                              'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',\n                              'u', 'v', 'w', 'x', 'y', 'z',\n                              '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',\n                              '+', '/'\n                            };\n\nconst byte base64Decode[] = { 62, bad, bad, bad, 63,   // + starts at 0x2B\n                              52, 53, 54, 55, 56, 57, 58, 59, 60, 61,\n                              bad, bad, bad, bad, bad, bad, bad,\n                              0, 1, 2, 3, 4, 5, 6, 7, 8, 9,\n                              10, 11, 12, 13, 14, 15, 16, 17, 18, 19,\n                              20, 21, 22, 23, 24, 25,\n                              bad, bad, bad, bad, bad, bad,\n                              26, 27, 28, 29, 30, 31, 32, 33, 34, 35,\n                              36, 37, 38, 39, 40, 41, 42, 43, 44, 45,\n                              46, 47, 48, 49, 50, 51\n                            };\n\nconst byte pad = '=';\nconst int pemLineSz = 64;\n\n}  // local namespace\n\n\n// Hex Encode\nvoid HexEncoder::Encode()\n{\n    word32 bytes = plain_.size();\n    encoded_.New(bytes * 2);\n\n    word32 i = 0;\n\n    while (bytes--) {\n        byte p = plain_.next();\n\n        byte b  = p >> 4;\n        byte b2 = p & 0xF;\n\n        encoded_[i++] = hexEncode[b];\n        encoded_[i++] = hexEncode[b2];\n    }\n\n    plain_.reset(encoded_);\n}\n\n\n// Hex Decode\nvoid HexDecoder::Decode()\n{\n    word32 bytes = coded_.size();\n    decoded_.New(bytes / 2);\n\n    word32 i(0);\n\n    while (bytes) {\n        byte b  = coded_.next() - 0x30;  // 0 starts at 0x30\n        byte b2 = coded_.next() - 0x30;\n\n        // sanity checks\n        if (b >= sizeof(hexDecode)/sizeof(hexDecode[0])) {\n            coded_.SetError(PEM_E);\n            return;\n        }\n        if (b2 >= sizeof(hexDecode)/sizeof(hexDecode[0])) {\n            coded_.SetError(PEM_E);\n            return;\n        }\n\n        b  = hexDecode[b];\n        b2 = hexDecode[b2];\n\n        decoded_[i++] = (b << 4) | b2;\n        bytes -= 2;\n    }\n\n    coded_.reset(decoded_);\n}\n\n\n// Base 64 Encode\nvoid Base64Encoder::Encode()\n{\n    word32 bytes = plain_.size();\n    word32 outSz = (bytes + 3 - 1) / 3 * 4;\n\n    outSz += (outSz + pemLineSz - 1) / pemLineSz;  // new lines\n    encoded_.New(outSz);\n\n    word32 i = 0;\n    word32 j = 0;\n    \n    while (bytes > 2) {\n        byte b1 = plain_.next();\n        byte b2 = plain_.next();\n        byte b3 = plain_.next();\n\n        // encoded idx\n        byte e1 = b1 >> 2;\n        byte e2 = ((b1 & 0x3) << 4) | (b2 >> 4);\n        byte e3 = ((b2 & 0xF) << 2) | (b3 >> 6);\n        byte e4 = b3 & 0x3F;\n\n        // store\n        encoded_[i++] = base64Encode[e1];\n        encoded_[i++] = base64Encode[e2];\n        encoded_[i++] = base64Encode[e3];\n        encoded_[i++] = base64Encode[e4];\n\n        bytes -= 3;\n\n        if ((++j % 16) == 0 && bytes)\n            encoded_[i++] = '\\n';\n    }\n\n    // last integral\n    if (bytes) {\n        bool twoBytes = (bytes == 2);\n\n        byte b1 = plain_.next();\n        byte b2 = (twoBytes) ? plain_.next() : 0;\n\n        byte e1 = b1 >> 2;\n        byte e2 = ((b1 & 0x3) << 4) | (b2 >> 4);\n        byte e3 =  (b2 & 0xF) << 2;\n\n        encoded_[i++] = base64Encode[e1];\n        encoded_[i++] = base64Encode[e2];\n        encoded_[i++] = (twoBytes) ? base64Encode[e3] : pad;\n        encoded_[i++] = pad;\n    } \n\n    encoded_[i++] = '\\n';\n    \n    if (i == outSz)\n        plain_.reset(encoded_);\n}\n\n\n// Base 64 Decode\nvoid Base64Decoder::Decode()\n{\n    word32 bytes = coded_.size();\n    word32 plainSz = bytes - ((bytes + (pemLineSz - 1)) / pemLineSz); \n    const  byte maxIdx = (byte)sizeof(base64Decode) + 0x2B - 1;\n    plainSz = ((plainSz * 3) / 4) + 3;\n    decoded_.New(plainSz);\n\n    word32 i = 0;\n    word32 j = 0;\n\n    while (bytes > 3) {\n        byte e1 = coded_.next();\n        byte e2 = coded_.next();\n        byte e3 = coded_.next();\n        byte e4 = coded_.next();\n\n        if (e1 == 0)            // end file 0's\n            break;\n\n        bool pad3 = false;\n        bool pad4 = false;\n        if (e3 == pad)\n            pad3 = true;\n        if (e4 == pad)\n            pad4 = true;\n\n        if (e1 < 0x2B || e2 < 0x2B || e3 < 0x2B || e4 < 0x2B) {\n            coded_.SetError(PEM_E);\n            return;\n        }\n\n        if (e1 > maxIdx || e2 > maxIdx || e3 > maxIdx || e4 > maxIdx) {\n            coded_.SetError(PEM_E);\n            return;\n        }\n\n        e1 = base64Decode[e1 - 0x2B];\n        e2 = base64Decode[e2 - 0x2B];\n        e3 = (e3 == pad) ? 0 : base64Decode[e3 - 0x2B];\n        e4 = (e4 == pad) ? 0 : base64Decode[e4 - 0x2B];\n\n        byte b1 = (e1 << 2) | (e2 >> 4);\n        byte b2 = ((e2 & 0xF) << 4) | (e3 >> 2);\n        byte b3 = ((e3 & 0x3) << 6) | e4;\n\n        decoded_[i++] = b1;\n        if (!pad3)\n            decoded_[i++] = b2;\n        if (!pad4)\n            decoded_[i++] = b3;\n        else\n            break;\n        \n        bytes -= 4;\n        if ((++j % 16) == 0) {\n            byte endLine = coded_.next();\n            bytes--;\n            while (endLine == ' ') {        // remove possible whitespace\n                endLine = coded_.next();\n                bytes--;\n            }\n            if (endLine == '\\r') {\n                endLine = coded_.next();\n                bytes--;\n            }\n            if (endLine != '\\n') {\n                coded_.SetError(PEM_E); \n                return;\n            }\n        }\n    }\n\n    if (i != decoded_.size())\n        decoded_.resize(i);\n    coded_.reset(decoded_);\n}\n\n\n} // namespace\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/des.cpp",
    "content": "/*\n   Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* C++ part based on Wei Dai's des.cpp from CryptoPP */\n/* x86 asm is original */\n\n\n#if defined(TAOCRYPT_KERNEL_MODE)\n    #define DO_TAOCRYPT_KERNEL_MODE\n#endif                                  // only some modules now support this\n\n\n#include \"runtime.hpp\"\n#include \"des.hpp\"\n#ifdef USE_SYS_STL\n    #include <algorithm>\n#else\n    #include \"algorithm.hpp\"\n#endif\n\n\nnamespace STL = STL_NAMESPACE;\n\n\n\nnamespace TaoCrypt {\n\n\n/* permuted choice table (key) */\nstatic const byte pc1[] = {\n       57, 49, 41, 33, 25, 17,  9,\n        1, 58, 50, 42, 34, 26, 18,\n       10,  2, 59, 51, 43, 35, 27,\n       19, 11,  3, 60, 52, 44, 36,\n\n       63, 55, 47, 39, 31, 23, 15,\n        7, 62, 54, 46, 38, 30, 22,\n       14,  6, 61, 53, 45, 37, 29,\n       21, 13,  5, 28, 20, 12,  4\n};\n\n/* number left rotations of pc1 */\nstatic const byte totrot[] = {\n       1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28\n};\n\n/* permuted choice key (table) */\nstatic const byte pc2[] = {\n       14, 17, 11, 24,  1,  5,\n        3, 28, 15,  6, 21, 10,\n       23, 19, 12,  4, 26,  8,\n       16,  7, 27, 20, 13,  2,\n       41, 52, 31, 37, 47, 55,\n       30, 40, 51, 45, 33, 48,\n       44, 49, 39, 56, 34, 53,\n       46, 42, 50, 36, 29, 32\n};\n\n/* End of DES-defined tables */\n\n/* bit 0 is left-most in byte */\nstatic const int bytebit[] = {\n       0200,0100,040,020,010,04,02,01\n};\n\nconst word32 Spbox[8][64] = {\n{\n0x01010400,0x00000000,0x00010000,0x01010404,\n0x01010004,0x00010404,0x00000004,0x00010000,\n0x00000400,0x01010400,0x01010404,0x00000400,\n0x01000404,0x01010004,0x01000000,0x00000004,\n0x00000404,0x01000400,0x01000400,0x00010400,\n0x00010400,0x01010000,0x01010000,0x01000404,\n0x00010004,0x01000004,0x01000004,0x00010004,\n0x00000000,0x00000404,0x00010404,0x01000000,\n0x00010000,0x01010404,0x00000004,0x01010000,\n0x01010400,0x01000000,0x01000000,0x00000400,\n0x01010004,0x00010000,0x00010400,0x01000004,\n0x00000400,0x00000004,0x01000404,0x00010404,\n0x01010404,0x00010004,0x01010000,0x01000404,\n0x01000004,0x00000404,0x00010404,0x01010400,\n0x00000404,0x01000400,0x01000400,0x00000000,\n0x00010004,0x00010400,0x00000000,0x01010004},\n{\n0x80108020,0x80008000,0x00008000,0x00108020,\n0x00100000,0x00000020,0x80100020,0x80008020,\n0x80000020,0x80108020,0x80108000,0x80000000,\n0x80008000,0x00100000,0x00000020,0x80100020,\n0x00108000,0x00100020,0x80008020,0x00000000,\n0x80000000,0x00008000,0x00108020,0x80100000,\n0x00100020,0x80000020,0x00000000,0x00108000,\n0x00008020,0x80108000,0x80100000,0x00008020,\n0x00000000,0x00108020,0x80100020,0x00100000,\n0x80008020,0x80100000,0x80108000,0x00008000,\n0x80100000,0x80008000,0x00000020,0x80108020,\n0x00108020,0x00000020,0x00008000,0x80000000,\n0x00008020,0x80108000,0x00100000,0x80000020,\n0x00100020,0x80008020,0x80000020,0x00100020,\n0x00108000,0x00000000,0x80008000,0x00008020,\n0x80000000,0x80100020,0x80108020,0x00108000},\n{\n0x00000208,0x08020200,0x00000000,0x08020008,\n0x08000200,0x00000000,0x00020208,0x08000200,\n0x00020008,0x08000008,0x08000008,0x00020000,\n0x08020208,0x00020008,0x08020000,0x00000208,\n0x08000000,0x00000008,0x08020200,0x00000200,\n0x00020200,0x08020000,0x08020008,0x00020208,\n0x08000208,0x00020200,0x00020000,0x08000208,\n0x00000008,0x08020208,0x00000200,0x08000000,\n0x08020200,0x08000000,0x00020008,0x00000208,\n0x00020000,0x08020200,0x08000200,0x00000000,\n0x00000200,0x00020008,0x08020208,0x08000200,\n0x08000008,0x00000200,0x00000000,0x08020008,\n0x08000208,0x00020000,0x08000000,0x08020208,\n0x00000008,0x00020208,0x00020200,0x08000008,\n0x08020000,0x08000208,0x00000208,0x08020000,\n0x00020208,0x00000008,0x08020008,0x00020200},\n{\n0x00802001,0x00002081,0x00002081,0x00000080,\n0x00802080,0x00800081,0x00800001,0x00002001,\n0x00000000,0x00802000,0x00802000,0x00802081,\n0x00000081,0x00000000,0x00800080,0x00800001,\n0x00000001,0x00002000,0x00800000,0x00802001,\n0x00000080,0x00800000,0x00002001,0x00002080,\n0x00800081,0x00000001,0x00002080,0x00800080,\n0x00002000,0x00802080,0x00802081,0x00000081,\n0x00800080,0x00800001,0x00802000,0x00802081,\n0x00000081,0x00000000,0x00000000,0x00802000,\n0x00002080,0x00800080,0x00800081,0x00000001,\n0x00802001,0x00002081,0x00002081,0x00000080,\n0x00802081,0x00000081,0x00000001,0x00002000,\n0x00800001,0x00002001,0x00802080,0x00800081,\n0x00002001,0x00002080,0x00800000,0x00802001,\n0x00000080,0x00800000,0x00002000,0x00802080},\n{\n0x00000100,0x02080100,0x02080000,0x42000100,\n0x00080000,0x00000100,0x40000000,0x02080000,\n0x40080100,0x00080000,0x02000100,0x40080100,\n0x42000100,0x42080000,0x00080100,0x40000000,\n0x02000000,0x40080000,0x40080000,0x00000000,\n0x40000100,0x42080100,0x42080100,0x02000100,\n0x42080000,0x40000100,0x00000000,0x42000000,\n0x02080100,0x02000000,0x42000000,0x00080100,\n0x00080000,0x42000100,0x00000100,0x02000000,\n0x40000000,0x02080000,0x42000100,0x40080100,\n0x02000100,0x40000000,0x42080000,0x02080100,\n0x40080100,0x00000100,0x02000000,0x42080000,\n0x42080100,0x00080100,0x42000000,0x42080100,\n0x02080000,0x00000000,0x40080000,0x42000000,\n0x00080100,0x02000100,0x40000100,0x00080000,\n0x00000000,0x40080000,0x02080100,0x40000100},\n{\n0x20000010,0x20400000,0x00004000,0x20404010,\n0x20400000,0x00000010,0x20404010,0x00400000,\n0x20004000,0x00404010,0x00400000,0x20000010,\n0x00400010,0x20004000,0x20000000,0x00004010,\n0x00000000,0x00400010,0x20004010,0x00004000,\n0x00404000,0x20004010,0x00000010,0x20400010,\n0x20400010,0x00000000,0x00404010,0x20404000,\n0x00004010,0x00404000,0x20404000,0x20000000,\n0x20004000,0x00000010,0x20400010,0x00404000,\n0x20404010,0x00400000,0x00004010,0x20000010,\n0x00400000,0x20004000,0x20000000,0x00004010,\n0x20000010,0x20404010,0x00404000,0x20400000,\n0x00404010,0x20404000,0x00000000,0x20400010,\n0x00000010,0x00004000,0x20400000,0x00404010,\n0x00004000,0x00400010,0x20004010,0x00000000,\n0x20404000,0x20000000,0x00400010,0x20004010},\n{\n0x00200000,0x04200002,0x04000802,0x00000000,\n0x00000800,0x04000802,0x00200802,0x04200800,\n0x04200802,0x00200000,0x00000000,0x04000002,\n0x00000002,0x04000000,0x04200002,0x00000802,\n0x04000800,0x00200802,0x00200002,0x04000800,\n0x04000002,0x04200000,0x04200800,0x00200002,\n0x04200000,0x00000800,0x00000802,0x04200802,\n0x00200800,0x00000002,0x04000000,0x00200800,\n0x04000000,0x00200800,0x00200000,0x04000802,\n0x04000802,0x04200002,0x04200002,0x00000002,\n0x00200002,0x04000000,0x04000800,0x00200000,\n0x04200800,0x00000802,0x00200802,0x04200800,\n0x00000802,0x04000002,0x04200802,0x04200000,\n0x00200800,0x00000000,0x00000002,0x04200802,\n0x00000000,0x00200802,0x04200000,0x00000800,\n0x04000002,0x04000800,0x00000800,0x00200002},\n{\n0x10001040,0x00001000,0x00040000,0x10041040,\n0x10000000,0x10001040,0x00000040,0x10000000,\n0x00040040,0x10040000,0x10041040,0x00041000,\n0x10041000,0x00041040,0x00001000,0x00000040,\n0x10040000,0x10000040,0x10001000,0x00001040,\n0x00041000,0x00040040,0x10040040,0x10041000,\n0x00001040,0x00000000,0x00000000,0x10040040,\n0x10000040,0x10001000,0x00041040,0x00040000,\n0x00041040,0x00040000,0x10041000,0x00001000,\n0x00000040,0x10040040,0x00001000,0x00041040,\n0x10001000,0x00000040,0x10000040,0x10040000,\n0x10040040,0x10000000,0x00040000,0x10001040,\n0x00000000,0x10041040,0x00040040,0x10000040,\n0x10040000,0x10001000,0x10001040,0x00000000,\n0x10041040,0x00041000,0x00041000,0x00001040,\n0x00001040,0x00040040,0x10000000,0x10041000}\n};\n\n\nvoid BasicDES::SetKey(const byte* key, word32 /*length*/, CipherDir dir)\n{\n    byte buffer[56+56+8];\n    byte *const pc1m = buffer;                 /* place to modify pc1 into */\n    byte *const pcr = pc1m + 56;               /* place to rotate pc1 into */\n    byte *const ks = pcr + 56;\n    int i,j,l;\n    int m;\n\n    for (j = 0; j < 56; j++) {          /* convert pc1 to bits of key */\n        l = pc1[j] - 1;                 /* integer bit location  */\n        m = l & 07;                     /* find bit              */\n        pc1m[j] = (key[l >> 3] &        /* find which key byte l is in */\n            bytebit[m])                 /* and which bit of that byte */\n            ? 1 : 0;                    /* and store 1-bit result */\n    }\n    for (i = 0; i < 16; i++) {          /* key chunk for each iteration */\n        memset(ks, 0, 8);               /* Clear key schedule */\n        for (j = 0; j < 56; j++)        /* rotate pc1 the right amount */\n            pcr[j] = pc1m[(l = j + totrot[i]) < (j < 28 ? 28 : 56) ? l: l-28];\n        /* rotate left and right halves independently */\n        for (j = 0; j < 48; j++){   /* select bits individually */\n            /* check bit that goes to ks[j] */\n            if (pcr[pc2[j] - 1]){\n                /* mask it in if it's there */\n                l= j % 6;\n                ks[j/6] |= bytebit[l] >> 2;\n            }\n        }\n        /* Now convert to odd/even interleaved form for use in F */\n        k_[2*i] = ((word32)ks[0] << 24)\n            | ((word32)ks[2] << 16)\n            | ((word32)ks[4] << 8)\n            | ((word32)ks[6]);\n        k_[2*i + 1] = ((word32)ks[1] << 24)\n            | ((word32)ks[3] << 16)\n            | ((word32)ks[5] << 8)\n            | ((word32)ks[7]);\n    }\n    \n    // reverse key schedule order\n    if (dir == DECRYPTION)\n        for (i = 0; i < 16; i += 2) {\n            STL::swap(k_[i],   k_[32 - 2 - i]);\n            STL::swap(k_[i+1], k_[32 - 1 - i]);\n        }\n   \n}\n\nstatic inline void IPERM(word32& left, word32& right)\n{\n    word32 work;\n\n    right = rotlFixed(right, 4U);\n    work = (left ^ right) & 0xf0f0f0f0;\n    left ^= work;\n\n    right = rotrFixed(right^work, 20U);\n    work = (left ^ right) & 0xffff0000;\n    left ^= work;\n\n    right = rotrFixed(right^work, 18U);\n    work = (left ^ right) & 0x33333333;\n    left ^= work;\n\n    right = rotrFixed(right^work, 6U);\n    work = (left ^ right) & 0x00ff00ff;\n    left ^= work;\n\n    right = rotlFixed(right^work, 9U);\n    work = (left ^ right) & 0xaaaaaaaa;\n    left = rotlFixed(left^work, 1U);\n    right ^= work;\n}\n\nstatic inline void FPERM(word32& left, word32& right)\n{\n    word32 work;\n\n    right = rotrFixed(right, 1U);\n    work = (left ^ right) & 0xaaaaaaaa;\n    right ^= work;\n    left = rotrFixed(left^work, 9U);\n    work = (left ^ right) & 0x00ff00ff;\n    right ^= work;\n    left = rotlFixed(left^work, 6U);\n    work = (left ^ right) & 0x33333333;\n    right ^= work;\n    left = rotlFixed(left^work, 18U);\n    work = (left ^ right) & 0xffff0000;\n    right ^= work;\n    left = rotlFixed(left^work, 20U);\n    work = (left ^ right) & 0xf0f0f0f0;\n    right ^= work;\n    left = rotrFixed(left^work, 4U);\n}\n\n\nvoid BasicDES::RawProcessBlock(word32& lIn, word32& rIn) const\n{\n    word32 l = lIn, r = rIn;\n    const word32* kptr = k_;\n\n    for (unsigned i=0; i<8; i++)\n    {\n        word32 work = rotrFixed(r, 4U) ^ kptr[4*i+0];\n        l ^= Spbox[6][(work) & 0x3f]\n          ^  Spbox[4][(work >> 8) & 0x3f]\n          ^  Spbox[2][(work >> 16) & 0x3f]\n          ^  Spbox[0][(work >> 24) & 0x3f];\n        work = r ^ kptr[4*i+1];\n        l ^= Spbox[7][(work) & 0x3f]\n          ^  Spbox[5][(work >> 8) & 0x3f]\n          ^  Spbox[3][(work >> 16) & 0x3f]\n          ^  Spbox[1][(work >> 24) & 0x3f];\n\n        work = rotrFixed(l, 4U) ^ kptr[4*i+2];\n        r ^= Spbox[6][(work) & 0x3f]\n          ^  Spbox[4][(work >> 8) & 0x3f]\n          ^  Spbox[2][(work >> 16) & 0x3f]\n          ^  Spbox[0][(work >> 24) & 0x3f];\n        work = l ^ kptr[4*i+3];\n        r ^= Spbox[7][(work) & 0x3f]\n          ^  Spbox[5][(work >> 8) & 0x3f]\n          ^  Spbox[3][(work >> 16) & 0x3f]\n          ^  Spbox[1][(work >> 24) & 0x3f];\n    }\n\n    lIn = l; rIn = r;\n}\n\n\n\ntypedef BlockGetAndPut<word32, BigEndian> Block;\n\n\nvoid DES::ProcessAndXorBlock(const byte* in, const byte* xOr, byte* out) const\n{\n    word32 l,r;\n    Block::Get(in)(l)(r);\n    IPERM(l,r);\n\n    RawProcessBlock(l, r);\n\n    FPERM(l,r);\n    Block::Put(xOr, out)(r)(l);\n}\n\n\nvoid DES_EDE2::SetKey(const byte* key, word32 sz, CipherDir dir)\n{\n    des1_.SetKey(key, sz, dir);\n    des2_.SetKey(key + 8, sz, ReverseDir(dir));\n}\n\n\nvoid DES_EDE2::ProcessAndXorBlock(const byte* in, const byte* xOr,\n                                  byte* out) const\n{\n    word32 l,r;\n    Block::Get(in)(l)(r);\n    IPERM(l,r);\n\n    des1_.RawProcessBlock(l, r);\n    des2_.RawProcessBlock(r, l);\n    des1_.RawProcessBlock(l, r);\n\n    FPERM(l,r);\n    Block::Put(xOr, out)(r)(l);\n}\n\n\nvoid DES_EDE3::SetKey(const byte* key, word32 sz, CipherDir dir)\n{\n    des1_.SetKey(key+(dir==ENCRYPTION?0:2*8), sz, dir);\n    des2_.SetKey(key+8, sz, ReverseDir(dir));\n    des3_.SetKey(key+(dir==DECRYPTION?0:2*8), sz, dir);\n}\n\n\n\n#if defined(DO_DES_ASM)\n\n// ia32 optimized version\nvoid DES_EDE3::Process(byte* out, const byte* in, word32 sz)\n{\n    if (!isMMX) {\n        Mode_BASE::Process(out, in, sz);\n        return;\n    }\n\n    word32 blocks = sz / DES_BLOCK_SIZE;\n\n    if (mode_ == CBC)    \n        if (dir_ == ENCRYPTION)\n            while (blocks--) {\n                r_[0] ^= *(word32*)in;\n                r_[1] ^= *(word32*)(in + 4);\n\n                AsmProcess((byte*)r_, (byte*)r_, (void*)Spbox);\n                \n                memcpy(out, r_, DES_BLOCK_SIZE);\n\n                in  += DES_BLOCK_SIZE;\n                out += DES_BLOCK_SIZE;\n            }\n        else\n            while (blocks--) {\n                AsmProcess(in, out, (void*)Spbox);\n               \n                *(word32*)out       ^= r_[0];\n                *(word32*)(out + 4) ^= r_[1];\n\n                memcpy(r_, in, DES_BLOCK_SIZE);\n\n                out += DES_BLOCK_SIZE;\n                in  += DES_BLOCK_SIZE;\n            }\n    else\n        while (blocks--) {\n            AsmProcess(in, out, (void*)Spbox);\n           \n            out += DES_BLOCK_SIZE;\n            in  += DES_BLOCK_SIZE;\n        }\n}\n\n#endif // DO_DES_ASM\n\n\nvoid DES_EDE3::ProcessAndXorBlock(const byte* in, const byte* xOr,\n                                  byte* out) const\n{\n    word32 l,r;\n    Block::Get(in)(l)(r);\n    IPERM(l,r);\n\n    des1_.RawProcessBlock(l, r);\n    des2_.RawProcessBlock(r, l);\n    des3_.RawProcessBlock(l, r);\n\n    FPERM(l,r);\n    Block::Put(xOr, out)(r)(l);\n}\n\n\n#if defined(DO_DES_ASM)\n\n/* Uses IPERM algorithm from above\n\n   left  is in eax\n   right is in ebx\n\n   uses ecx\n*/\n#define AsmIPERM() \\\n    AS2(    rol   ebx, 4                        )   \\\n    AS2(    mov   ecx, eax                      )   \\\n    AS2(    xor   ecx, ebx                      )   \\\n    AS2(    and   ecx, 0xf0f0f0f0               )   \\\n    AS2(    xor   ebx, ecx                      )   \\\n    AS2(    xor   eax, ecx                      )   \\\n    AS2(    ror   ebx, 20                       )   \\\n    AS2(    mov   ecx, eax                      )   \\\n    AS2(    xor   ecx, ebx                      )   \\\n    AS2(    and   ecx, 0xffff0000               )   \\\n    AS2(    xor   ebx, ecx                      )   \\\n    AS2(    xor   eax, ecx                      )   \\\n    AS2(    ror   ebx, 18                       )   \\\n    AS2(    mov   ecx, eax                      )   \\\n    AS2(    xor   ecx, ebx                      )   \\\n    AS2(    and   ecx, 0x33333333               )   \\\n    AS2(    xor   ebx, ecx                      )   \\\n    AS2(    xor   eax, ecx                      )   \\\n    AS2(    ror   ebx, 6                        )   \\\n    AS2(    mov   ecx, eax                      )   \\\n    AS2(    xor   ecx, ebx                      )   \\\n    AS2(    and   ecx, 0x00ff00ff               )   \\\n    AS2(    xor   ebx, ecx                      )   \\\n    AS2(    xor   eax, ecx                      )   \\\n    AS2(    rol   ebx, 9                        )   \\\n    AS2(    mov   ecx, eax                      )   \\\n    AS2(    xor   ecx, ebx                      )   \\\n    AS2(    and   ecx, 0xaaaaaaaa               )   \\\n    AS2(    xor   eax, ecx                      )   \\\n    AS2(    rol   eax, 1                        )   \\\n    AS2(    xor   ebx, ecx                      )\n\n\n/* Uses FPERM algorithm from above\n\n   left  is in eax\n   right is in ebx\n\n   uses ecx\n*/\n#define AsmFPERM()    \\\n    AS2(    ror  ebx, 1                     )    \\\n    AS2(    mov  ecx, eax                   )    \\\n    AS2(    xor  ecx, ebx                   )    \\\n    AS2(    and  ecx, 0xaaaaaaaa            )    \\\n    AS2(    xor  eax, ecx                   )    \\\n    AS2(    xor  ebx, ecx                   )    \\\n    AS2(    ror  eax, 9                     )    \\\n    AS2(    mov  ecx, ebx                   )    \\\n    AS2(    xor  ecx, eax                   )    \\\n    AS2(    and  ecx, 0x00ff00ff            )    \\\n    AS2(    xor  eax, ecx                   )    \\\n    AS2(    xor  ebx, ecx                   )    \\\n    AS2(    rol  eax, 6                     )    \\\n    AS2(    mov  ecx, ebx                   )    \\\n    AS2(    xor  ecx, eax                   )    \\\n    AS2(    and  ecx, 0x33333333            )    \\\n    AS2(    xor  eax, ecx                   )    \\\n    AS2(    xor  ebx, ecx                   )    \\\n    AS2(    rol  eax, 18                    )    \\\n    AS2(    mov  ecx, ebx                   )    \\\n    AS2(    xor  ecx, eax                   )    \\\n    AS2(    and  ecx, 0xffff0000            )    \\\n    AS2(    xor  eax, ecx                   )    \\\n    AS2(    xor  ebx, ecx                   )    \\\n    AS2(    rol  eax, 20                    )    \\\n    AS2(    mov  ecx, ebx                   )    \\\n    AS2(    xor  ecx, eax                   )    \\\n    AS2(    and  ecx, 0xf0f0f0f0            )    \\\n    AS2(    xor  eax, ecx                   )    \\\n    AS2(    xor  ebx, ecx                   )    \\\n    AS2(    ror  eax, 4                     )\n\n\n\n\n/* DesRound implements this algorithm:\n\n        word32 work = rotrFixed(r, 4U) ^ key[0];\n        l ^= Spbox[6][(work) & 0x3f]\n          ^  Spbox[4][(work >> 8) & 0x3f]\n          ^  Spbox[2][(work >> 16) & 0x3f]\n          ^  Spbox[0][(work >> 24) & 0x3f];\n        work = r ^ key[1];\n        l ^= Spbox[7][(work) & 0x3f]\n          ^  Spbox[5][(work >> 8) & 0x3f]\n          ^  Spbox[3][(work >> 16) & 0x3f]\n          ^  Spbox[1][(work >> 24) & 0x3f];\n\n        work = rotrFixed(l, 4U) ^ key[2];\n        r ^= Spbox[6][(work) & 0x3f]\n          ^  Spbox[4][(work >> 8) & 0x3f]\n          ^  Spbox[2][(work >> 16) & 0x3f]\n          ^  Spbox[0][(work >> 24) & 0x3f];\n        work = l ^ key[3];\n        r ^= Spbox[7][(work) & 0x3f]\n          ^  Spbox[5][(work >> 8) & 0x3f]\n          ^  Spbox[3][(work >> 16) & 0x3f]\n          ^  Spbox[1][(work >> 24) & 0x3f];\n\n   left  is in aex\n   right is in ebx\n   key   is in edx\n\n   edvances key for next round\n\n   uses ecx, esi, and edi\n*/\n#define DesRound() \\\n    AS2(    mov   ecx,  ebx                     )\\\n    AS2(    mov   esi,  DWORD PTR [edx]         )\\\n    AS2(    ror   ecx,  4                       )\\\n    AS2(    xor   ecx,  esi                     )\\\n    AS2(    and   ecx,  0x3f3f3f3f              )\\\n    AS2(    movzx esi,  cl                      )\\\n    AS2(    movzx edi,  ch                      )\\\n    AS2(    xor   eax,  [ebp + esi*4 + 6*256]   )\\\n    AS2(    shr   ecx,  16                      )\\\n    AS2(    xor   eax,  [ebp + edi*4 + 4*256]   )\\\n    AS2(    movzx esi,  cl                      )\\\n    AS2(    movzx edi,  ch                      )\\\n    AS2(    xor   eax,  [ebp + esi*4 + 2*256]   )\\\n    AS2(    mov   esi,  DWORD PTR [edx + 4]     )\\\n    AS2(    xor   eax,  [ebp + edi*4]           )\\\n    AS2(    mov   ecx,  ebx                     )\\\n    AS2(    xor   ecx,  esi                     )\\\n    AS2(    and   ecx,  0x3f3f3f3f              )\\\n    AS2(    movzx esi,  cl                      )\\\n    AS2(    movzx edi,  ch                      )\\\n    AS2(    xor   eax,  [ebp + esi*4 + 7*256]   )\\\n    AS2(    shr   ecx,  16                      )\\\n    AS2(    xor   eax,  [ebp + edi*4 + 5*256]   )\\\n    AS2(    movzx esi,  cl                      )\\\n    AS2(    movzx edi,  ch                      )\\\n    AS2(    xor   eax,  [ebp + esi*4 + 3*256]   )\\\n    AS2(    mov   esi,  DWORD PTR [edx + 8]     )\\\n    AS2(    xor   eax,  [ebp + edi*4 + 1*256]   )\\\n    AS2(    mov   ecx,  eax                     )\\\n    AS2(    ror   ecx,  4                       )\\\n    AS2(    xor   ecx,  esi                     )\\\n    AS2(    and   ecx,  0x3f3f3f3f              )\\\n    AS2(    movzx esi,  cl                      )\\\n    AS2(    movzx edi,  ch                      )\\\n    AS2(    xor   ebx,  [ebp + esi*4 + 6*256]   )\\\n    AS2(    shr   ecx,  16                      )\\\n    AS2(    xor   ebx,  [ebp + edi*4 + 4*256]   )\\\n    AS2(    movzx esi,  cl                      )\\\n    AS2(    movzx edi,  ch                      )\\\n    AS2(    xor   ebx,  [ebp + esi*4 + 2*256]   )\\\n    AS2(    mov   esi,  DWORD PTR [edx + 12]    )\\\n    AS2(    xor   ebx,  [ebp + edi*4]           )\\\n    AS2(    mov   ecx,  eax                     )\\\n    AS2(    xor   ecx,  esi                     )\\\n    AS2(    and   ecx,  0x3f3f3f3f              )\\\n    AS2(    movzx esi,  cl                      )\\\n    AS2(    movzx edi,  ch                      )\\\n    AS2(    xor   ebx,  [ebp + esi*4 + 7*256]   )\\\n    AS2(    shr   ecx,  16                      )\\\n    AS2(    xor   ebx,  [ebp + edi*4 + 5*256]   )\\\n    AS2(    movzx esi,  cl                      )\\\n    AS2(    movzx edi,  ch                      )\\\n    AS2(    xor   ebx,  [ebp + esi*4 + 3*256]   )\\\n    AS2(    add   edx,  16                      )\\\n    AS2(    xor   ebx,  [ebp + edi*4 + 1*256]   )\n\n\n#ifdef _MSC_VER\n    __declspec(naked) \n#else\n    __attribute__ ((noinline))\n#endif\nvoid DES_EDE3::AsmProcess(const byte* in, byte* out, void* box) const\n{\n#ifdef __GNUC__\n    #define AS1(x)    #x \";\"\n    #define AS2(x, y) #x \", \" #y \";\"\n\n    #define PROLOG()  \\\n    __asm__ __volatile__ \\\n    ( \\\n        \".intel_syntax noprefix;\" \\\n        \"push ebx;\" \\\n        \"push ebp;\" \\\n        \"movd mm6, ebp;\" \\\n        \"movd mm7, ecx;\" \\\n        \"mov  ebp, eax;\"\n    #define EPILOG()  \\\n        \"pop ebp;\" \\\n        \"pop ebx;\" \\\n       \t\"emms;\" \\\n       \t\".att_syntax;\" \\\n            :  \\\n            : \"d\" (this), \"S\" (in), \"a\" (box), \"c\" (out) \\\n            : \"%edi\", \"memory\", \"cc\" \\\n    );\n\n#else\n    #define AS1(x)      __asm x\n    #define AS2(x, y)   __asm x, y\n\n    #define PROLOG()  \\\n        AS1(    push  ebp                           )   \\\n        AS2(    mov   ebp, esp                      )   \\\n        AS2(    movd  mm3, edi                      )   \\\n        AS2(    movd  mm4, ebx                      )   \\\n        AS2(    movd  mm5, esi                      )   \\\n        AS2(    movd  mm6, ebp                      )   \\\n        AS2(    mov   esi, DWORD PTR [ebp +  8]     )   \\\n        AS2(    mov   edx, ecx                      )   \\\n        AS2(    mov   ebp, DWORD PTR [ebp + 16]     )\n\n    // ebp restored at end\n    #define EPILOG() \\\n        AS2(    movd  edi, mm3                      )   \\\n        AS2(    movd  ebx, mm4                      )   \\\n        AS2(    movd  esi, mm5                      )   \\\n        AS2(    mov   esp, ebp                      )   \\\n        AS1(    pop   ebp                           )   \\\n        AS1(    emms                                )   \\\n        AS1(    ret 12                              )\n\n#endif\n\n\n    PROLOG()\n\n    AS2(    movd  mm2, edx                      )\n\n    #ifdef OLD_GCC_OFFSET\n        AS2(    add   edx, 60                       )   // des1 = des1 key\n    #else\n        AS2(    add   edx, 56                       )   // des1 = des1 key\n    #endif\n\n    AS2(    mov   eax, DWORD PTR [esi]          )\n    AS2(    mov   ebx, DWORD PTR [esi + 4]      )\n    AS1(    bswap eax                           )    // left\n    AS1(    bswap ebx                           )    // right\n\n    AsmIPERM()\n\n    DesRound() // 1\n    DesRound() // 2\n    DesRound() // 3\n    DesRound() // 4\n    DesRound() // 5\n    DesRound() // 6\n    DesRound() // 7\n    DesRound() // 8\n\n    // swap left and right \n    AS2(    xchg  eax, ebx                      )\n\n    DesRound() // 1\n    DesRound() // 2\n    DesRound() // 3\n    DesRound() // 4\n    DesRound() // 5\n    DesRound() // 6\n    DesRound() // 7\n    DesRound() // 8\n\n    // swap left and right\n    AS2(    xchg  eax, ebx                      )\n\n    DesRound() // 1\n    DesRound() // 2\n    DesRound() // 3\n    DesRound() // 4\n    DesRound() // 5\n    DesRound() // 6\n    DesRound() // 7\n    DesRound() // 8\n\n    AsmFPERM()\n\n    //end\n    AS2(    movd  ebp, mm6                      )\n\n    // swap and write out\n    AS1(    bswap ebx                           )\n    AS1(    bswap eax                           )\n\n#ifdef __GNUC__\n    AS2(    movd  esi, mm7   )   // outBlock\n#else\n    AS2(    mov   esi, DWORD PTR [ebp +  12]    )   // outBlock\n#endif\n\n    AS2(    mov   DWORD PTR [esi],     ebx      )   // right first\n    AS2(    mov   DWORD PTR [esi + 4], eax      )\n    \n\n    EPILOG()\n}\n\n\n\n#endif // defined(DO_DES_ASM)\n\n\n}  // namespace\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/dh.cpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* dh.cpp implements Diffie-Hellman support\n*/\n\n#include \"runtime.hpp\"\n#include \"dh.hpp\"\n#include \"asn.hpp\"\n#include <math.h>\n\nnamespace TaoCrypt {\n\n\nnamespace {  // locals\n\nunsigned int DiscreteLogWorkFactor(unsigned int n)\n{\n    // assuming discrete log takes about the same time as factoring\n    if (n<5)\n        return 0;\n    else\n        return (unsigned int)(2.4 * pow((double)n, 1.0/3.0) *\n                pow(log(double(n)), 2.0/3.0) - 5);\n}\n\n} // namespace locals\n\n\n// Generate a DH Key Pair\nvoid DH::GenerateKeyPair(RandomNumberGenerator& rng, byte* priv, byte* pub)\n{\n    GeneratePrivate(rng, priv);\n    GeneratePublic(priv, pub);\n}\n\n\n// Generate private value\nvoid DH::GeneratePrivate(RandomNumberGenerator& rng, byte* priv)\n{\n    Integer x(rng, Integer::One(), min(p_ - 1,\n        Integer::Power2(2*DiscreteLogWorkFactor(p_.BitCount())) ) );\n    x.Encode(priv, p_.ByteCount());\n}\n\n\n// Generate public value\nvoid DH::GeneratePublic(const byte* priv, byte* pub)\n{\n    const word32 bc(p_.ByteCount());\n    Integer x(priv, bc);\n    Integer y(a_exp_b_mod_c(g_, x, p_));\n    y.Encode(pub, bc);\n}\n\n\n// Generate Agreement\nvoid DH::Agree(byte* agree, const byte* priv, const byte* otherPub, word32\n               otherSz)\n{\n    const word32 bc(p_.ByteCount());\n    Integer x(priv, bc);\n    Integer y;\n    if (otherSz)\n        y.Decode(otherPub, otherSz);\n    else\n        y.Decode(otherPub, bc);\n\n    Integer z(a_exp_b_mod_c(y, x, p_));\n    z.Encode(agree, bc);\n}\n\n\nDH::DH(Source& source)\n{\n    Initialize(source);\n}\n\n\nvoid DH::Initialize(Source& source)\n{\n    DH_Decoder decoder(source);\n    decoder.Decode(*this);\n}\n\n\n} // namespace\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/dsa.cpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n#include \"runtime.hpp\"\n#include \"dsa.hpp\"\n#include \"sha.hpp\"\n#include \"asn.hpp\"\n#include \"modarith.hpp\"\n\n\nnamespace TaoCrypt {\n\n\nvoid DSA_PublicKey::Swap(DSA_PublicKey& other)\n{\n    p_.Swap(other.p_);\n    q_.Swap(other.q_);\n    g_.Swap(other.g_);\n    y_.Swap(other.y_);\n}\n\n\nDSA_PublicKey::DSA_PublicKey(const DSA_PublicKey& other)\n    : p_(other.p_), q_(other.q_), g_(other.g_), y_(other.y_)\n{}\n\n\nDSA_PublicKey& DSA_PublicKey::operator=(const DSA_PublicKey& that)\n{\n    DSA_PublicKey tmp(that);\n    Swap(tmp);\n    return *this;\n}\n\n\nDSA_PublicKey::DSA_PublicKey(Source& source)\n{\n    Initialize(source);\n}\n\n\nvoid DSA_PublicKey::Initialize(Source& source)\n{\n    DSA_Public_Decoder decoder(source);\n    decoder.Decode(*this);\n}\n\n\nvoid DSA_PublicKey::Initialize(const Integer& p, const Integer& q,\n                               const Integer& g, const Integer& y)\n{\n    p_ = p;\n    q_ = q;\n    g_ = g;\n    y_ = y;\n}\n   \n\nconst Integer& DSA_PublicKey::GetModulus() const\n{\n    return p_;\n}\n\nconst Integer& DSA_PublicKey::GetSubGroupOrder() const\n{\n    return q_;\n}\n\n\nconst Integer& DSA_PublicKey::GetSubGroupGenerator() const\n{\n    return g_;\n}\n\n\nconst Integer& DSA_PublicKey::GetPublicPart() const\n{\n    return y_;\n}\n\n\nvoid DSA_PublicKey::SetModulus(const Integer& p)\n{\n    p_ = p;\n}\n\n\nvoid DSA_PublicKey::SetSubGroupOrder(const Integer& q)\n{\n    q_ = q;\n}\n\n\nvoid DSA_PublicKey::SetSubGroupGenerator(const Integer& g)\n{\n    g_ = g;\n}\n\n\nvoid DSA_PublicKey::SetPublicPart(const Integer& y)\n{\n    y_ = y;\n}\n\n\nword32 DSA_PublicKey::SignatureLength() const\n{\n    return GetSubGroupOrder().ByteCount() * 2;  // r and s\n}\n\n\n\nDSA_PrivateKey::DSA_PrivateKey(Source& source)\n{\n    Initialize(source);\n}\n\n\nvoid DSA_PrivateKey::Initialize(Source& source)\n{\n    DSA_Private_Decoder decoder(source);\n    decoder.Decode(*this);\n}\n\n\nvoid DSA_PrivateKey::Initialize(const Integer& p, const Integer& q,\n                                const Integer& g, const Integer& y,\n                                const Integer& x)\n{\n    DSA_PublicKey::Initialize(p, q, g, y);\n    x_ = x;\n}\n\n\nconst Integer& DSA_PrivateKey::GetPrivatePart() const\n{\n    return x_;\n}\n\n\nvoid DSA_PrivateKey::SetPrivatePart(const Integer& x)\n{\n    x_ = x;\n}\n\n\nDSA_Signer::DSA_Signer(const DSA_PrivateKey& key)\n    : key_(key)\n{}\n\n\nword32 DSA_Signer::Sign(const byte* sha_digest, byte* sig,\n                        RandomNumberGenerator& rng)\n{\n    const Integer& p = key_.GetModulus();\n    const Integer& q = key_.GetSubGroupOrder();\n    const Integer& g = key_.GetSubGroupGenerator();\n    const Integer& x = key_.GetPrivatePart();\n\n    Integer k(rng, 1, q - 1);\n\n    r_ =  a_exp_b_mod_c(g, k, p);\n    r_ %= q;\n\n    Integer H(sha_digest, SHA::DIGEST_SIZE);  // sha Hash(m)\n\n    Integer kInv = k.InverseMod(q);\n    s_ = (kInv * (H + x*r_)) % q;\n\n    if (!(!!r_ && !!s_))\n        return -1;\n\n    int rSz = r_.ByteCount();\n\n    if (rSz == 19) {\n        sig[0] = 0;\n        sig++;\n    }\n    \n    r_.Encode(sig,  rSz);\n\n    int sSz = s_.ByteCount();\n\n    if (sSz == 19) {\n        sig[rSz] = 0;\n        sig++;\n    }\n\n    s_.Encode(sig + rSz, sSz);\n\n    return 40;\n}\n\n\nDSA_Verifier::DSA_Verifier(const DSA_PublicKey& key)\n    : key_(key)\n{}\n\n\nbool DSA_Verifier::Verify(const byte* sha_digest, const byte* sig)\n{\n    const Integer& p = key_.GetModulus();\n    const Integer& q = key_.GetSubGroupOrder();\n    const Integer& g = key_.GetSubGroupGenerator();\n    const Integer& y = key_.GetPublicPart();\n\n    int sz = q.ByteCount();\n\n    r_.Decode(sig, sz);\n    s_.Decode(sig + sz, sz);\n\n    if (r_ >= q || r_ < 1 || s_ >= q || s_ < 1)\n        return false;\n\n    Integer H(sha_digest, SHA::DIGEST_SIZE);  // sha Hash(m)\n\n    Integer w = s_.InverseMod(q);\n    Integer u1 = (H  * w) % q;\n    Integer u2 = (r_ * w) % q;\n\n    // verify r == ((g^u1 * y^u2) mod p) mod q\n    ModularArithmetic ma(p);\n    Integer v = ma.CascadeExponentiate(g, u1, y, u2);\n    v %= q;\n\n    return r_ == v;\n}\n\n\n\n\nconst Integer& DSA_Signer::GetR() const\n{\n    return r_;\n}\n\n\nconst Integer& DSA_Signer::GetS() const\n{\n    return s_;\n}\n\n\nconst Integer& DSA_Verifier::GetR() const\n{\n    return r_;\n}\n\n\nconst Integer& DSA_Verifier::GetS() const\n{\n    return s_;\n}\n\n\n} // namespace\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/file.cpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* file.cpp implements File Sources and Sinks\n*/\n\n#include \"runtime.hpp\"\n#include \"file.hpp\"\n\n\nnamespace TaoCrypt {\n\n\nFileSource::FileSource(const char* fname, Source& source)\n{\n    file_ = fopen(fname, \"rb\");\n    if (file_) get(source);\n}\n\n\nFileSource::~FileSource()\n{\n    if (file_)\n        fclose(file_);\n}\n\n\n\n// return size of source from beginning or current position\nword32 FileSource::size(bool use_current)\n{\n    long current = ftell(file_);\n    long begin   = current;\n\n    if (!use_current) {\n        fseek(file_, 0, SEEK_SET);\n        begin = ftell(file_);\n    }\n\n    fseek(file_, 0, SEEK_END);\n    long end = ftell(file_);\n\n    fseek(file_, current, SEEK_SET);\n\n    return end - begin;\n}\n\n\nword32 FileSource::size_left()\n{\n    return size(true);\n}\n\n\n// fill file source from source\nword32 FileSource::get(Source& source)\n{\n    word32 sz(size());\n    if (source.size() < sz)\n        source.grow(sz);\n\n    size_t bytes = fread(source.buffer_.get_buffer(), 1, sz, file_);\n\n    if (bytes == 1)\n        return sz;\n    else\n        return 0;\n}\n\n\nFileSink::FileSink(const char* fname, Source& source)\n{\n    file_ = fopen(fname, \"wb\");\n    if (file_) put(source);\n}\n\n\nFileSink::~FileSink()\n{\n    if (file_)\n        fclose(file_);\n}\n\n\n// fill source from file sink\nvoid FileSink::put(Source& source)\n{\n    fwrite(source.get_buffer(), 1, source.size(), file_);\n}\n\n\n// swap with other and reset to beginning\nvoid Source::reset(ByteBlock& otherBlock)\n{\n    buffer_.Swap(otherBlock);   \n    current_ = 0;\n}\n\n\n}  // namespace\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/hash.cpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* hash.cpp implements a base for digest types\n*/\n\n#include \"runtime.hpp\"\n#include <string.h>\n\n#include \"hash.hpp\"\n\n\nnamespace TaoCrypt {\n\n\nHASHwithTransform::HASHwithTransform(word32 digSz, word32 buffSz)\n{\n}\n\n\nvoid HASHwithTransform::AddLength(word32 len)\n{\n    HashLengthType tmp = loLen_;\n    if ( (loLen_ += len) < tmp)\n        hiLen_++;                       // carry low to high\n    hiLen_ += SafeRightShift<8*sizeof(HashLengthType)>(len);\n}\n\n\n// Update digest with data of size len, do in blocks\nvoid HASHwithTransform::Update(const byte* data, word32 len)\n{\n    // do block size increments\n    word32 blockSz = getBlockSize();\n    byte*  local   = reinterpret_cast<byte*>(buffer_);\n\n    while (len) {\n        word32 add = min(len, blockSz - buffLen_);\n        memcpy(&local[buffLen_], data, add);\n\n        buffLen_ += add;\n        data     += add;\n        len      -= add;\n\n        if (buffLen_ == blockSz) {\n            ByteReverseIf(local, local, blockSz, getByteOrder());\n            Transform();\n            AddLength(blockSz);\n            buffLen_ = 0;\n        }\n    }\n}\n\n\n// Final process, place digest in hash\nvoid HASHwithTransform::Final(byte* hash)\n{\n    word32    blockSz  = getBlockSize();\n    word32    digestSz = getDigestSize();\n    word32    padSz    = getPadSize();\n    ByteOrder order    = getByteOrder();\n\n    AddLength(buffLen_);                        // before adding pads\n    HashLengthType preLoLen = GetBitCountLo();\n    HashLengthType preHiLen = GetBitCountHi();\n    byte*     local         = reinterpret_cast<byte*>(buffer_);\n\n    local[buffLen_++] = 0x80;  // add 1\n\n    // pad with zeros\n    if (buffLen_ > padSz) {\n        memset(&local[buffLen_], 0, blockSz - buffLen_);\n        buffLen_ += blockSz - buffLen_;\n\n        ByteReverseIf(local, local, blockSz, order);\n        Transform();\n        buffLen_ = 0;\n    }\n    memset(&local[buffLen_], 0, padSz - buffLen_);\n   \n    ByteReverseIf(local, local, blockSz, order);\n    \n    memcpy(&local[padSz],   order ? &preHiLen : &preLoLen, sizeof(preLoLen));\n    memcpy(&local[padSz+4], order ? &preLoLen : &preHiLen, sizeof(preLoLen));\n\n    Transform();\n    ByteReverseIf(digest_, digest_, digestSz, order);\n    memcpy(hash, digest_, digestSz);\n\n    Init();  // reset state\n}\n\n\n#ifdef WORD64_AVAILABLE\n\nHASH64withTransform::HASH64withTransform(word32 digSz, word32 buffSz)\n{\n}\n\n\nvoid HASH64withTransform::AddLength(word32 len)\n{\n    HashLengthType tmp = loLen_;\n    if ( (loLen_ += len) < tmp)\n        hiLen_++;                       // carry low to high\n    hiLen_ += SafeRightShift<8*sizeof(HashLengthType)>(len);\n}\n\n\n// Update digest with data of size len, do in blocks\nvoid HASH64withTransform::Update(const byte* data, word32 len)\n{\n    // do block size increments\n    word32 blockSz = getBlockSize();\n    byte*  local   = reinterpret_cast<byte*>(buffer_);\n\n    while (len) {\n        word32 add = min(len, blockSz - buffLen_);\n        memcpy(&local[buffLen_], data, add);\n\n        buffLen_ += add;\n        data     += add;\n        len      -= add;\n\n        if (buffLen_ == blockSz) {\n            ByteReverseIf(buffer_, buffer_, blockSz, getByteOrder());\n            Transform();\n            AddLength(blockSz);\n            buffLen_ = 0;\n        }\n    }\n}\n\n\n// Final process, place digest in hash\nvoid HASH64withTransform::Final(byte* hash)\n{\n    word32    blockSz  = getBlockSize();\n    word32    digestSz = getDigestSize();\n    word32    padSz    = getPadSize();\n    ByteOrder order    = getByteOrder();\n\n    AddLength(buffLen_);                        // before adding pads\n    HashLengthType preLoLen = GetBitCountLo();\n    HashLengthType preHiLen = GetBitCountHi();\n    byte*     local         = reinterpret_cast<byte*>(buffer_);\n\n    local[buffLen_++] = 0x80;  // add 1\n\n    // pad with zeros\n    if (buffLen_ > padSz) {\n        memset(&local[buffLen_], 0, blockSz - buffLen_);\n        buffLen_ += blockSz - buffLen_;\n\n        ByteReverseIf(buffer_, buffer_, blockSz, order);\n        Transform();\n        buffLen_ = 0;\n    }\n    memset(&local[buffLen_], 0, padSz - buffLen_);\n   \n    ByteReverseIf(buffer_, buffer_, padSz, order);\n    \n    buffer_[blockSz / sizeof(word64) - 2] = order ? preHiLen : preLoLen;\n    buffer_[blockSz / sizeof(word64) - 1] = order ? preLoLen : preHiLen;\n\n    Transform();\n    ByteReverseIf(digest_, digest_, digestSz, order);\n    memcpy(hash, digest_, digestSz);\n\n    Init();  // reset state\n}\n\n#endif // WORD64_AVAILABLE\n\n\n} // namespace\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/hc128.cpp",
    "content": "/*\n   Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n#include \"runtime.hpp\"\n#include \"hc128.hpp\"\n\n\n\nnamespace TaoCrypt {\n\n\n\n\n#ifdef BIG_ENDIAN_ORDER\n    #define LITTLE32(x) ByteReverse((word32)x)\n#else\n    #define LITTLE32(x) (x)\n#endif\n\n\n/*h1 function*/\n#define h1(x, y) {                              \\\n     byte a,c;                                  \\\n     a = (byte) (x);                            \\\n     c = (byte) ((x) >> 16);                    \\\n     y = (T_[512+a])+(T_[512+256+c]);           \\\n}\n\n/*h2 function*/\n#define h2(x, y) {                              \\\n     byte a,c;                                  \\\n     a = (byte) (x);                            \\\n     c = (byte) ((x) >> 16);                    \\\n     y = (T_[a])+(T_[256+c]);                   \\\n}\n\n/*one step of HC-128, update P and generate 32 bits keystream*/\n#define step_P(u,v,a,b,c,d,n){                  \\\n     word32 tem0,tem1,tem2,tem3;                \\\n     h1((X_[(d)]),tem3);                        \\\n     tem0 = rotrFixed((T_[(v)]),23);            \\\n     tem1 = rotrFixed((X_[(c)]),10);            \\\n     tem2 = rotrFixed((X_[(b)]),8);             \\\n     (T_[(u)]) += tem2+(tem0 ^ tem1);           \\\n     (X_[(a)]) = (T_[(u)]);                     \\\n     (n) = tem3 ^ (T_[(u)]) ;                   \\\n}       \n\n/*one step of HC-128, update Q and generate 32 bits keystream*/\n#define step_Q(u,v,a,b,c,d,n){                  \\\n     word32 tem0,tem1,tem2,tem3;                \\\n     h2((Y_[(d)]),tem3);                        \\\n     tem0 = rotrFixed((T_[(v)]),(32-23));       \\\n     tem1 = rotrFixed((Y_[(c)]),(32-10));       \\\n     tem2 = rotrFixed((Y_[(b)]),(32-8));        \\\n     (T_[(u)]) += tem2 + (tem0 ^ tem1);         \\\n     (Y_[(a)]) = (T_[(u)]);                     \\\n     (n) = tem3 ^ (T_[(u)]) ;                   \\\n}   \n\n\n/*16 steps of HC-128, generate 512 bits keystream*/\nvoid HC128::GenerateKeystream(word32* keystream)  \n{\n   word32 cc,dd;\n   cc = counter1024_ & 0x1ff;\n   dd = (cc+16)&0x1ff;\n\n   if (counter1024_ < 512)\t\n   {   \t\t\n      counter1024_ = (counter1024_ + 16) & 0x3ff;\n      step_P(cc+0, cc+1, 0, 6, 13,4, keystream[0]);\n      step_P(cc+1, cc+2, 1, 7, 14,5, keystream[1]);\n      step_P(cc+2, cc+3, 2, 8, 15,6, keystream[2]);\n      step_P(cc+3, cc+4, 3, 9, 0, 7, keystream[3]);\n      step_P(cc+4, cc+5, 4, 10,1, 8, keystream[4]);\n      step_P(cc+5, cc+6, 5, 11,2, 9, keystream[5]);\n      step_P(cc+6, cc+7, 6, 12,3, 10,keystream[6]);\n      step_P(cc+7, cc+8, 7, 13,4, 11,keystream[7]);\n      step_P(cc+8, cc+9, 8, 14,5, 12,keystream[8]);\n      step_P(cc+9, cc+10,9, 15,6, 13,keystream[9]);\n      step_P(cc+10,cc+11,10,0, 7, 14,keystream[10]);\n      step_P(cc+11,cc+12,11,1, 8, 15,keystream[11]);\n      step_P(cc+12,cc+13,12,2, 9, 0, keystream[12]);\n      step_P(cc+13,cc+14,13,3, 10,1, keystream[13]);\n      step_P(cc+14,cc+15,14,4, 11,2, keystream[14]);\n      step_P(cc+15,dd+0, 15,5, 12,3, keystream[15]);\n   }\n   else\t\t\t\t    \n   {\n\t  counter1024_ = (counter1024_ + 16) & 0x3ff;\n      step_Q(512+cc+0, 512+cc+1, 0, 6, 13,4, keystream[0]);\n      step_Q(512+cc+1, 512+cc+2, 1, 7, 14,5, keystream[1]);\n      step_Q(512+cc+2, 512+cc+3, 2, 8, 15,6, keystream[2]);\n      step_Q(512+cc+3, 512+cc+4, 3, 9, 0, 7, keystream[3]);\n      step_Q(512+cc+4, 512+cc+5, 4, 10,1, 8, keystream[4]);\n      step_Q(512+cc+5, 512+cc+6, 5, 11,2, 9, keystream[5]);\n      step_Q(512+cc+6, 512+cc+7, 6, 12,3, 10,keystream[6]);\n      step_Q(512+cc+7, 512+cc+8, 7, 13,4, 11,keystream[7]);\n      step_Q(512+cc+8, 512+cc+9, 8, 14,5, 12,keystream[8]);\n      step_Q(512+cc+9, 512+cc+10,9, 15,6, 13,keystream[9]);\n      step_Q(512+cc+10,512+cc+11,10,0, 7, 14,keystream[10]);\n      step_Q(512+cc+11,512+cc+12,11,1, 8, 15,keystream[11]);\n      step_Q(512+cc+12,512+cc+13,12,2, 9, 0, keystream[12]);\n      step_Q(512+cc+13,512+cc+14,13,3, 10,1, keystream[13]);\n      step_Q(512+cc+14,512+cc+15,14,4, 11,2, keystream[14]);\n      step_Q(512+cc+15,512+dd+0, 15,5, 12,3, keystream[15]);\n   }\n}\n\n\n/* The following defines the initialization functions */\n#define f1(x)  (rotrFixed((x),7)  ^ rotrFixed((x),18) ^ ((x) >> 3))\n#define f2(x)  (rotrFixed((x),17) ^ rotrFixed((x),19) ^ ((x) >> 10))\n\n/*update table P*/\n#define update_P(u,v,a,b,c,d){                      \\\n     word32 tem0,tem1,tem2,tem3;                    \\\n     tem0 = rotrFixed((T_[(v)]),23);                \\\n     tem1 = rotrFixed((X_[(c)]),10);                \\\n     tem2 = rotrFixed((X_[(b)]),8);                 \\\n     h1((X_[(d)]),tem3);                            \\\n     (T_[(u)]) = ((T_[(u)]) + tem2+(tem0^tem1)) ^ tem3;     \\\n     (X_[(a)]) = (T_[(u)]);                         \\\n}  \n\n/*update table Q*/\n#define update_Q(u,v,a,b,c,d){                      \\\n     word32 tem0,tem1,tem2,tem3;                    \\\n     tem0 = rotrFixed((T_[(v)]),(32-23));           \\\n     tem1 = rotrFixed((Y_[(c)]),(32-10));           \\\n     tem2 = rotrFixed((Y_[(b)]),(32-8));            \\\n     h2((Y_[(d)]),tem3);                            \\\n     (T_[(u)]) = ((T_[(u)]) + tem2+(tem0^tem1)) ^ tem3;     \\\n     (Y_[(a)]) = (T_[(u)]);                         \\\n}     \n\n/*16 steps of HC-128, without generating keystream, */\n/*but use the outputs to update P and Q*/\nvoid HC128::SetupUpdate()  /*each time 16 steps*/\n{\n   word32 cc,dd;\n   cc = counter1024_ & 0x1ff;\n   dd = (cc+16)&0x1ff;\n\n   if (counter1024_ < 512)\t\n   {   \t\t\n      counter1024_ = (counter1024_ + 16) & 0x3ff;\n      update_P(cc+0, cc+1, 0, 6, 13, 4);\n      update_P(cc+1, cc+2, 1, 7, 14, 5);\n      update_P(cc+2, cc+3, 2, 8, 15, 6);\n      update_P(cc+3, cc+4, 3, 9, 0,  7);\n      update_P(cc+4, cc+5, 4, 10,1,  8);\n      update_P(cc+5, cc+6, 5, 11,2,  9);\n      update_P(cc+6, cc+7, 6, 12,3,  10);\n      update_P(cc+7, cc+8, 7, 13,4,  11);\n      update_P(cc+8, cc+9, 8, 14,5,  12);\n      update_P(cc+9, cc+10,9, 15,6,  13);\n      update_P(cc+10,cc+11,10,0, 7,  14);\n      update_P(cc+11,cc+12,11,1, 8,  15);\n      update_P(cc+12,cc+13,12,2, 9,  0);\n      update_P(cc+13,cc+14,13,3, 10, 1);\n      update_P(cc+14,cc+15,14,4, 11, 2);\n      update_P(cc+15,dd+0, 15,5, 12, 3);   \n   }\n   else\t\t\t\t    \n   {\n      counter1024_ = (counter1024_ + 16) & 0x3ff;\n      update_Q(512+cc+0, 512+cc+1, 0, 6, 13, 4);\n      update_Q(512+cc+1, 512+cc+2, 1, 7, 14, 5);\n      update_Q(512+cc+2, 512+cc+3, 2, 8, 15, 6);\n      update_Q(512+cc+3, 512+cc+4, 3, 9, 0,  7);\n      update_Q(512+cc+4, 512+cc+5, 4, 10,1,  8);\n      update_Q(512+cc+5, 512+cc+6, 5, 11,2,  9);\n      update_Q(512+cc+6, 512+cc+7, 6, 12,3,  10);\n      update_Q(512+cc+7, 512+cc+8, 7, 13,4,  11);\n      update_Q(512+cc+8, 512+cc+9, 8, 14,5,  12);\n      update_Q(512+cc+9, 512+cc+10,9, 15,6,  13);\n      update_Q(512+cc+10,512+cc+11,10,0, 7,  14);\n      update_Q(512+cc+11,512+cc+12,11,1, 8,  15);\n      update_Q(512+cc+12,512+cc+13,12,2, 9,  0);\n      update_Q(512+cc+13,512+cc+14,13,3, 10, 1);\n      update_Q(512+cc+14,512+cc+15,14,4, 11, 2);\n      update_Q(512+cc+15,512+dd+0, 15,5, 12, 3); \n   }       \n}\n\n\n/* for the 128-bit key:  key[0]...key[15]\n*  key[0] is the least significant byte of ctx->key[0] (K_0);\n*  key[3] is the most significant byte of ctx->key[0]  (K_0);\n*  ...\n*  key[12] is the least significant byte of ctx->key[3] (K_3)\n*  key[15] is the most significant byte of ctx->key[3]  (K_3)\n*\n*  for the 128-bit iv:  iv[0]...iv[15]\n*  iv[0] is the least significant byte of ctx->iv[0] (IV_0);\n*  iv[3] is the most significant byte of ctx->iv[0]  (IV_0);\n*  ...\n*  iv[12] is the least significant byte of ctx->iv[3] (IV_3)\n*  iv[15] is the most significant byte of ctx->iv[3]  (IV_3)\n*/\n\n\n\nvoid HC128::SetIV(const byte* iv)\n{ \n    word32 i;\n\t\n\tfor (i = 0; i < (128 >> 5); i++)\n        iv_[i] = LITTLE32(((word32*)iv)[i]);\n\t\n    for (; i < 8; i++) iv_[i] = iv_[i-4];\n  \n    /* expand the key and IV into the table T */ \n    /* (expand the key and IV into the table P and Q) */ \n\t\n\tfor (i = 0; i < 8;  i++)   T_[i] = key_[i];\n\tfor (i = 8; i < 16; i++)   T_[i] = iv_[i-8];\n\n    for (i = 16; i < (256+16); i++) \n\t\tT_[i] = f2(T_[i-2]) + T_[i-7] + f1(T_[i-15]) + T_[i-16]+i;\n    \n\tfor (i = 0; i < 16;  i++)  T_[i] = T_[256+i];\n\n\tfor (i = 16; i < 1024; i++) \n\t\tT_[i] = f2(T_[i-2]) + T_[i-7] + f1(T_[i-15]) + T_[i-16]+256+i;\n    \n    /* initialize counter1024, X and Y */\n\tcounter1024_ = 0;\n\tfor (i = 0; i < 16; i++) X_[i] = T_[512-16+i];\n    for (i = 0; i < 16; i++) Y_[i] = T_[512+512-16+i];\n    \n    /* run the cipher 1024 steps before generating the output */\n\tfor (i = 0; i < 64; i++)  SetupUpdate();  \n}\n\n\nvoid HC128::SetKey(const byte* key, const byte* iv)\n{ \n  word32 i;  \n\n  /* Key size in bits 128 */ \n  for (i = 0; i < (128 >> 5); i++)\n      key_[i] = LITTLE32(((word32*)key)[i]);\n \n  for ( ; i < 8 ; i++) key_[i] = key_[i-4];\n\n  SetIV(iv);\n}\n\n\n/* The following defines the encryption of data stream */\nvoid HC128::Process(byte* output, const byte* input, word32 msglen)\n{\n  word32 i, keystream[16];\n\n  for ( ; msglen >= 64; msglen -= 64, input += 64, output += 64)\n  {\n\t  GenerateKeystream(keystream);\n\n      /* unroll loop */\n\t  ((word32*)output)[0]  = ((word32*)input)[0]  ^ LITTLE32(keystream[0]);\n\t  ((word32*)output)[1]  = ((word32*)input)[1]  ^ LITTLE32(keystream[1]);\n\t  ((word32*)output)[2]  = ((word32*)input)[2]  ^ LITTLE32(keystream[2]);\n\t  ((word32*)output)[3]  = ((word32*)input)[3]  ^ LITTLE32(keystream[3]);\n\t  ((word32*)output)[4]  = ((word32*)input)[4]  ^ LITTLE32(keystream[4]);\n\t  ((word32*)output)[5]  = ((word32*)input)[5]  ^ LITTLE32(keystream[5]);\n\t  ((word32*)output)[6]  = ((word32*)input)[6]  ^ LITTLE32(keystream[6]);\n\t  ((word32*)output)[7]  = ((word32*)input)[7]  ^ LITTLE32(keystream[7]);\n\t  ((word32*)output)[8]  = ((word32*)input)[8]  ^ LITTLE32(keystream[8]);\n\t  ((word32*)output)[9]  = ((word32*)input)[9]  ^ LITTLE32(keystream[9]);\n\t  ((word32*)output)[10] = ((word32*)input)[10] ^ LITTLE32(keystream[10]);\n\t  ((word32*)output)[11] = ((word32*)input)[11] ^ LITTLE32(keystream[11]);\n\t  ((word32*)output)[12] = ((word32*)input)[12] ^ LITTLE32(keystream[12]);\n\t  ((word32*)output)[13] = ((word32*)input)[13] ^ LITTLE32(keystream[13]);\n\t  ((word32*)output)[14] = ((word32*)input)[14] ^ LITTLE32(keystream[14]);\n\t  ((word32*)output)[15] = ((word32*)input)[15] ^ LITTLE32(keystream[15]);\n  }\n\n  if (msglen > 0)\n  {\n      GenerateKeystream(keystream);\n\n#ifdef BIG_ENDIAN_ORDER\n      {\n          word32 wordsLeft = msglen / sizeof(word32);\n          if (msglen % sizeof(word32)) wordsLeft++;\n          \n          ByteReverse(keystream, keystream, wordsLeft * sizeof(word32));\n      }\n#endif\n\n      for (i = 0; i < msglen; i++)\n\t      output[i] = input[i] ^ ((byte*)keystream)[i];\n  }\n\n}\n\n\n}  // namespace\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/integer.cpp",
    "content": "/* Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; if not, write to the Free Software\n   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */\n\n/* based on Wei Dai's integer.cpp from CryptoPP */\n\n#include \"runtime.hpp\"\n#include \"integer.hpp\"\n#include \"modarith.hpp\"\n#include \"asn.hpp\"\n\n\n\n#ifdef __DECCXX\n    #include <c_asm.h>  // for asm overflow assembly\n#endif\n\n#if defined(_M_X64) || defined(_M_IA64)\n    #include <intrin.h> \n#pragma intrinsic(_umul128)\n#endif\n\n\n#ifdef __GNUC__\n    #include <signal.h>\n    #include <setjmp.h>\n#endif\n\n\n#ifdef SSE2_INTRINSICS_AVAILABLE\n    #ifdef __GNUC__\n        #include <xmmintrin.h>\n        #ifdef TAOCRYPT_MEMALIGN_AVAILABLE\n            #include <malloc.h>\n        #else\n            #include <stdlib.h>\n        #endif\n    #else\n        #include <emmintrin.h>\n    #endif\n#elif defined(_MSC_VER) && defined(_M_IX86)\n/*    #pragma message(\"You do not seem to have the Visual C++ Processor Pack \")\n     #pragma message(\"installed, so use of SSE2 intrinsics will be disabled.\")\n*/\n    #pragma message(\"installed, so use of SSE2 intrinsics will be disabled.\")\n#elif defined(__GNUC__) && defined(__i386__)\n/*   #warning You do not have GCC 3.3 or later, or did not specify the -msse2 \\\n             compiler option. Use of SSE2 intrinsics will be disabled.\n*/\n#endif\n\n\nnamespace TaoCrypt {\n\n\n#ifdef SSE2_INTRINSICS_AVAILABLE\n\ntemplate <class T>\nCPP_TYPENAME AlignedAllocator<T>::pointer AlignedAllocator<T>::allocate(\n                                           size_type n, const void *)\n{\n    if (n > this->max_size())\n        return 0;\n    if (n == 0)\n        return 0;\n    if (n >= 4)\n    {\n        void* p;\n    #ifdef TAOCRYPT_MM_MALLOC_AVAILABLE\n        p = _mm_malloc(sizeof(T)*n, 16);\n    #elif defined(TAOCRYPT_MEMALIGN_AVAILABLE)\n        p = memalign(16, sizeof(T)*n);\n    #elif defined(TAOCRYPT_MALLOC_ALIGNMENT_IS_16)\n        p = malloc(sizeof(T)*n);\n    #else\n        p = (byte *)malloc(sizeof(T)*n + 8);\n        // assume malloc alignment is at least 8\n    #endif\n\n    #ifdef TAOCRYPT_NO_ALIGNED_ALLOC\n        m_pBlock = p;\n        if (!IsAlignedOn(p, 16))\n        {\n            p = (byte *)p + 8;\n        }\n    #endif\n\n        return (T*)p;\n    }\n    return NEW_TC T[n];\n}\n\n\ntemplate <class T>\nvoid AlignedAllocator<T>::deallocate(void* p, size_type n)\n{\n    memset(p, 0, n*sizeof(T));\n    if (n >= 4)\n    {\n        #ifdef TAOCRYPT_MM_MALLOC_AVAILABLE\n            _mm_free(p);\n        #elif defined(TAOCRYPT_NO_ALIGNED_ALLOC)\n            free(m_pBlock);\n            m_pBlock = 0;\n        #else\n            free(p);\n        #endif\n    }\n    else\n        tcArrayDelete((T *)p);\n}\n\n#endif  // SSE2\n\n\n// ********  start of integer needs\n\n// start 5.2.1 adds DWord and Word ********\n\n// ********************************************************\n\nclass DWord {\npublic:\nDWord() {}\n\n#ifdef TAOCRYPT_NATIVE_DWORD_AVAILABLE\n    explicit DWord(word low)\n    {\n        whole_ = low;\n    }\n#else\n    explicit DWord(word low)\n    {\n        halfs_.low = low;\n        halfs_.high = 0;\n    }\n#endif\n\n    DWord(word low, word high)\n    {\n        halfs_.low = low;\n        halfs_.high = high;\n    }\n\n    static DWord Multiply(word a, word b)\n    {\n        DWord r;\n\n        #ifdef TAOCRYPT_NATIVE_DWORD_AVAILABLE\n            r.whole_ = (dword)a * b;\n\n        #elif defined(_M_X64) || defined(_M_IA64)\n            r.halfs_.low = _umul128(a, b, &r.halfs_.high);\n\n        #elif defined(__ia64__)\n            r.halfs_.low = a*b;\n            __asm__(\"xmpy.hu %0=%1,%2\" : \"=f\" (r.halfs_.high)\n                : \"f\" (a), \"f\" (b));\n\n        #elif defined(_ARCH_PPC64)\n            r.halfs_.low = a*b;\n            __asm__(\"mulhdu %0,%1,%2\" : \"=r\" (r.halfs_.high)\n                : \"r\" (a), \"r\" (b) : \"cc\");\n\n        #elif defined(__x86_64__)\n            __asm__(\"mulq %3\" : \"=d\" (r.halfs_.high), \"=a\" (r.halfs_.low) :\n                \"a\" (a), \"rm\" (b) : \"cc\");\n\n        #elif defined(__mips64)\n            __asm__(\"dmultu %2,%3\" : \"=h\" (r.halfs_.high), \"=l\" (r.halfs_.low)\n                : \"r\" (a), \"r\" (b));\n\n        #elif defined(_M_IX86)\n            // for testing\n            word64 t = (word64)a * b;\n            r.halfs_.high = ((word32 *)(&t))[1];\n            r.halfs_.low = (word32)t;\n        #else\n            #error can not implement DWord\n        #endif\n\n        return r;\n    }\n\n    static DWord MultiplyAndAdd(word a, word b, word c)\n    {\n        DWord r = Multiply(a, b);\n        return r += c;\n    }\n\n    DWord & operator+=(word a)\n    {\n        #ifdef TAOCRYPT_NATIVE_DWORD_AVAILABLE\n            whole_ = whole_ + a;\n        #else\n            halfs_.low += a;\n            halfs_.high += (halfs_.low < a);\n        #endif\n        return *this;\n    }\n\n    DWord operator+(word a)\n    {\n        DWord r;\n        #ifdef TAOCRYPT_NATIVE_DWORD_AVAILABLE\n            r.whole_ = whole_ + a;\n        #else\n            r.halfs_.low = halfs_.low + a;\n            r.halfs_.high = halfs_.high + (r.halfs_.low < a);\n        #endif\n        return r;\n    }\n\n    DWord operator-(DWord a)\n    {\n        DWord r;\n        #ifdef TAOCRYPT_NATIVE_DWORD_AVAILABLE\n            r.whole_ = whole_ - a.whole_;\n        #else\n            r.halfs_.low = halfs_.low - a.halfs_.low;\n            r.halfs_.high = halfs_.high - a.halfs_.high -\n                             (r.halfs_.low > halfs_.low);\n        #endif\n        return r;\n    }\n\n    DWord operator-(word a)\n    {\n        DWord r;\n        #ifdef TAOCRYPT_NATIVE_DWORD_AVAILABLE\n            r.whole_ = whole_ - a;\n        #else\n            r.halfs_.low = halfs_.low - a;\n            r.halfs_.high = halfs_.high - (r.halfs_.low > halfs_.low);\n        #endif\n        return r;\n    }\n\n    // returns quotient, which must fit in a word\n    word operator/(word divisor);\n\n    word operator%(word a);\n\n    bool operator!() const\n    {\n    #ifdef TAOCRYPT_NATIVE_DWORD_AVAILABLE\n        return !whole_;\n    #else\n        return !halfs_.high && !halfs_.low;\n    #endif\n    }\n\n    word GetLowHalf() const {return halfs_.low;}\n    word GetHighHalf() const {return halfs_.high;}\n    word GetHighHalfAsBorrow() const {return 0-halfs_.high;}\n\nprivate:\n    struct dword_struct\n        {\n        #ifdef LITTLE_ENDIAN_ORDER\n            word low;\n            word high;\n        #else\n            word high;\n            word low;\n        #endif\n    };\n\n    union\n    {\n    #ifdef TAOCRYPT_NATIVE_DWORD_AVAILABLE\n        dword whole_;\n    #endif\n        struct dword_struct halfs_;\n    };\n};\n\n\nclass Word {\npublic:\n    Word() {}\n\n    Word(word value)\n    {\n        whole_ = value;\n    }\n\n    Word(hword low, hword high)\n    {\n        whole_ = low | (word(high) << (WORD_BITS/2));\n    }\n\n    static Word Multiply(hword a, hword b)\n    {\n        Word r;\n        r.whole_ = (word)a * b;\n        return r;\n    }\n\n    Word operator-(Word a)\n    {\n        Word r;\n        r.whole_ = whole_ - a.whole_;\n        return r;\n    }\n\n    Word operator-(hword a)\n    {\n        Word r;\n        r.whole_ = whole_ - a;\n        return r;\n    }\n\n    // returns quotient, which must fit in a word\n    hword operator/(hword divisor)\n    {\n        return hword(whole_ / divisor);\n    }\n\n    bool operator!() const\n    {\n        return !whole_;\n    }\n\n    word GetWhole() const {return whole_;}\n    hword GetLowHalf() const {return hword(whole_);}\n    hword GetHighHalf() const {return hword(whole_>>(WORD_BITS/2));}\n    hword GetHighHalfAsBorrow() const {return 0-hword(whole_>>(WORD_BITS/2));}\n\nprivate:\n    word whole_;\n};\n\n\n// dummy is VC60 compiler bug workaround\n// do a 3 word by 2 word divide, returns quotient and leaves remainder in A\ntemplate <class S, class D>\nS DivideThreeWordsByTwo(S* A, S B0, S B1, D* dummy_VC6_WorkAround = 0)\n{\n    // estimate the quotient: do a 2 S by 1 S divide\n    S Q;\n    if (S(B1+1) == 0)\n        Q = A[2];\n    else\n        Q = D(A[1], A[2]) / S(B1+1);\n\n    // now subtract Q*B from A\n    D p = D::Multiply(B0, Q);\n    D u = (D) A[0] - p.GetLowHalf();\n    A[0] = u.GetLowHalf();\n    u = (D) A[1] - p.GetHighHalf() - u.GetHighHalfAsBorrow() - \n            D::Multiply(B1, Q);\n    A[1] = u.GetLowHalf();\n    A[2] += u.GetHighHalf();\n\n    // Q <= actual quotient, so fix it\n    while (A[2] || A[1] > B1 || (A[1]==B1 && A[0]>=B0))\n    {\n        u = (D) A[0] - B0;\n        A[0] = u.GetLowHalf();\n        u = (D) A[1] - B1 - u.GetHighHalfAsBorrow();\n        A[1] = u.GetLowHalf();\n        A[2] += u.GetHighHalf();\n        Q++;\n    }\n\n    return Q;\n}\n\n\n// do a 4 word by 2 word divide, returns 2 word quotient in Q0 and Q1\ntemplate <class S, class D>\ninline D DivideFourWordsByTwo(S *T, const D &Al, const D &Ah, const D &B)\n{\n    if (!B) // if divisor is 0, we assume divisor==2**(2*WORD_BITS)\n        return D(Ah.GetLowHalf(), Ah.GetHighHalf());\n    else\n    {\n        S Q[2];\n        T[0] = Al.GetLowHalf();\n        T[1] = Al.GetHighHalf(); \n        T[2] = Ah.GetLowHalf();\n        T[3] = Ah.GetHighHalf();\n        Q[1] = DivideThreeWordsByTwo<S, D>(T+1, B.GetLowHalf(),\n                                                B.GetHighHalf());\n        Q[0] = DivideThreeWordsByTwo<S, D>(T, B.GetLowHalf(), B.GetHighHalf());\n        return D(Q[0], Q[1]);\n    }\n}\n\n\n// returns quotient, which must fit in a word\ninline word DWord::operator/(word a)\n{\n    #ifdef TAOCRYPT_NATIVE_DWORD_AVAILABLE\n        return word(whole_ / a);\n    #else\n        hword r[4];\n        return DivideFourWordsByTwo<hword, Word>(r, halfs_.low,\n                                                    halfs_.high, a).GetWhole();\n    #endif\n}\n\ninline word DWord::operator%(word a)\n{\n    #ifdef TAOCRYPT_NATIVE_DWORD_AVAILABLE\n        return word(whole_ % a);\n    #else\n        if (a < (word(1) << (WORD_BITS/2)))\n        {\n            hword h = hword(a);\n            word r = halfs_.high % h;\n            r = ((halfs_.low >> (WORD_BITS/2)) + (r << (WORD_BITS/2))) % h;\n            return hword((hword(halfs_.low) + (r << (WORD_BITS/2))) % h);\n        }\n        else\n        {\n            hword r[4];\n            DivideFourWordsByTwo<hword, Word>(r, halfs_.low, halfs_.high, a);\n            return Word(r[0], r[1]).GetWhole();\n        }\n    #endif\n}\n\n\n\n// end 5.2.1 DWord and Word adds\n\n\n\n\n\nstatic const unsigned int RoundupSizeTable[] = {2, 2, 2, 4, 4, 8, 8, 8, 8};\n\nstatic inline unsigned int RoundupSize(unsigned int n)\n{\n    if (n<=8)\n        return RoundupSizeTable[n];\n    else if (n<=16)\n        return 16;\n    else if (n<=32)\n        return 32;\n    else if (n<=64)\n        return 64;\n    else return 1U << BitPrecision(n-1);\n}\n\n\nstatic int Compare(const word *A, const word *B, unsigned int N)\n{\n    while (N--)\n        if (A[N] > B[N])\n            return 1;\n        else if (A[N] < B[N])\n            return -1;\n\n    return 0;\n}\n\nstatic word Increment(word *A, unsigned int N, word B=1)\n{\n    word t = A[0];\n    A[0] = t+B;\n    if (A[0] >= t)\n        return 0;\n    for (unsigned i=1; i<N; i++)\n        if (++A[i])\n            return 0;\n    return 1;\n}\n\nstatic word Decrement(word *A, unsigned int N, word B=1)\n{\n    word t = A[0];\n    A[0] = t-B;\n    if (A[0] <= t)\n        return 0;\n    for (unsigned i=1; i<N; i++)\n        if (A[i]--)\n            return 0;\n    return 1;\n}\n\nstatic void TwosComplement(word *A, unsigned int N)\n{\n    Decrement(A, N);\n    for (unsigned i=0; i<N; i++)\n        A[i] = ~A[i];\n}\n\n\nstatic word LinearMultiply(word *C, const word *A, word B, unsigned int N)\n{\n    word carry=0;\n    for(unsigned i=0; i<N; i++)\n    {\n        DWord p = DWord::MultiplyAndAdd(A[i], B, carry);\n        C[i] = p.GetLowHalf();\n        carry = p.GetHighHalf();\n    }\n    return carry;\n}\n\n\nstatic word AtomicInverseModPower2(word A)\n{\n    word R=A%8;\n\n    for (unsigned i=3; i<WORD_BITS; i*=2)\n        R = R*(2-R*A);\n\n    return R;\n}\n\n\n// ********************************************************\n\nclass Portable\n{\npublic:\n    static word TAOCRYPT_CDECL Add(word *C, const word *A, const word *B,\n                                   unsigned int N);\n    static word TAOCRYPT_CDECL Subtract(word *C, const word *A, const word*B,\n                                        unsigned int N);\n    static void TAOCRYPT_CDECL Multiply2(word *C, const word *A, const word *B);\n    static word TAOCRYPT_CDECL Multiply2Add(word *C,\n                                            const word *A, const word *B);\n    static void TAOCRYPT_CDECL Multiply4(word *C, const word *A, const word *B);\n    static void TAOCRYPT_CDECL Multiply8(word *C, const word *A, const word *B);\n    static unsigned int TAOCRYPT_CDECL MultiplyRecursionLimit() {return 8;}\n\n    static void TAOCRYPT_CDECL Multiply2Bottom(word *C, const word *A,\n                                               const word *B);\n    static void TAOCRYPT_CDECL Multiply4Bottom(word *C, const word *A,\n                                               const word *B);\n    static void TAOCRYPT_CDECL Multiply8Bottom(word *C, const word *A,\n                                               const word *B);\n    static unsigned int TAOCRYPT_CDECL MultiplyBottomRecursionLimit(){return 8;}\n\n    static void TAOCRYPT_CDECL Square2(word *R, const word *A);\n    static void TAOCRYPT_CDECL Square4(word *R, const word *A);\n    static unsigned int TAOCRYPT_CDECL SquareRecursionLimit() {return 4;}\n};\n\nword Portable::Add(word *C, const word *A, const word *B, unsigned int N)\n{\n    DWord u(0, 0);\n    for (unsigned int i = 0; i < N; i+=2)\n    {\n        u = DWord(A[i]) + B[i] + u.GetHighHalf();\n        C[i] = u.GetLowHalf();\n        u = DWord(A[i+1]) + B[i+1] + u.GetHighHalf();\n        C[i+1] = u.GetLowHalf();\n    }\n    return u.GetHighHalf();\n}\n\nword Portable::Subtract(word *C, const word *A, const word *B, unsigned int N)\n{\n    DWord u(0, 0);\n    for (unsigned int i = 0; i < N; i+=2)\n    {\n        u = (DWord) A[i] - B[i] - u.GetHighHalfAsBorrow();\n        C[i] = u.GetLowHalf();\n        u = (DWord) A[i+1] - B[i+1] - u.GetHighHalfAsBorrow();\n        C[i+1] = u.GetLowHalf();\n    }\n    return 0-u.GetHighHalf();\n}\n\nvoid Portable::Multiply2(word *C, const word *A, const word *B)\n{\n/*\n    word s;\n    dword d;\n\n    if (A1 >= A0)\n        if (B0 >= B1)\n        {\n            s = 0;\n            d = (dword)(A1-A0)*(B0-B1);\n        }\n        else\n        {\n            s = (A1-A0);\n            d = (dword)s*(word)(B0-B1);\n        }\n    else\n        if (B0 > B1)\n        {\n            s = (B0-B1);\n            d = (word)(A1-A0)*(dword)s;\n        }\n        else\n        {\n            s = 0;\n            d = (dword)(A0-A1)*(B1-B0);\n        }\n*/\n    // this segment is the branchless equivalent of above\n    word D[4] = {A[1]-A[0], A[0]-A[1], B[0]-B[1], B[1]-B[0]};\n    unsigned int ai = A[1] < A[0];\n    unsigned int bi = B[0] < B[1];\n    unsigned int di = ai & bi;\n    DWord d = DWord::Multiply(D[di], D[di+2]);\n    D[1] = D[3] = 0;\n    unsigned int si = ai + !bi;\n    word s = D[si];\n\n    DWord A0B0 = DWord::Multiply(A[0], B[0]);\n    C[0] = A0B0.GetLowHalf();\n\n    DWord A1B1 = DWord::Multiply(A[1], B[1]);\n    DWord t = (DWord) A0B0.GetHighHalf() + A0B0.GetLowHalf() + d.GetLowHalf()\n                       + A1B1.GetLowHalf();\n    C[1] = t.GetLowHalf();\n\n    t = A1B1 + t.GetHighHalf() + A0B0.GetHighHalf() + d.GetHighHalf()\n             + A1B1.GetHighHalf() - s;\n    C[2] = t.GetLowHalf();\n    C[3] = t.GetHighHalf();\n}\n\nvoid Portable::Multiply2Bottom(word *C, const word *A, const word *B)\n{\n    DWord t = DWord::Multiply(A[0], B[0]);\n    C[0] = t.GetLowHalf();\n    C[1] = t.GetHighHalf() + A[0]*B[1] + A[1]*B[0];\n}\n\nword Portable::Multiply2Add(word *C, const word *A, const word *B)\n{\n    word D[4] = {A[1]-A[0], A[0]-A[1], B[0]-B[1], B[1]-B[0]};\n    unsigned int ai = A[1] < A[0];\n    unsigned int bi = B[0] < B[1];\n    unsigned int di = ai & bi;\n    DWord d = DWord::Multiply(D[di], D[di+2]);\n    D[1] = D[3] = 0;\n    unsigned int si = ai + !bi;\n    word s = D[si];\n\n    DWord A0B0 = DWord::Multiply(A[0], B[0]);\n    DWord t = A0B0 + C[0];\n    C[0] = t.GetLowHalf();\n\n    DWord A1B1 = DWord::Multiply(A[1], B[1]);\n    t = (DWord) t.GetHighHalf() + A0B0.GetLowHalf() + d.GetLowHalf() +\n        A1B1.GetLowHalf() + C[1];\n    C[1] = t.GetLowHalf();\n\n    t = (DWord) t.GetHighHalf() + A1B1.GetLowHalf() + A0B0.GetHighHalf() +\n        d.GetHighHalf() + A1B1.GetHighHalf() - s + C[2];\n    C[2] = t.GetLowHalf();\n\n    t = (DWord) t.GetHighHalf() + A1B1.GetHighHalf() + C[3];\n    C[3] = t.GetLowHalf();\n    return t.GetHighHalf();\n}\n\n\n#define MulAcc(x, y)                                \\\n    p = DWord::MultiplyAndAdd(A[x], B[y], c);       \\\n    c = p.GetLowHalf();                             \\\n    p = (DWord) d + p.GetHighHalf();                \\\n    d = p.GetLowHalf();                             \\\n    e += p.GetHighHalf();\n\n#define SaveMulAcc(s, x, y)                         \\\n    R[s] = c;                                       \\\n    p = DWord::MultiplyAndAdd(A[x], B[y], d);       \\\n    c = p.GetLowHalf();                             \\\n    p = (DWord) e + p.GetHighHalf();                \\\n    d = p.GetLowHalf();                             \\\n    e = p.GetHighHalf();\n\n#define SquAcc(x, y)                                \\\n    q = DWord::Multiply(A[x], A[y]);                \\\n    p = q + c;                                      \\\n    c = p.GetLowHalf();                             \\\n    p = (DWord) d + p.GetHighHalf();                \\\n    d = p.GetLowHalf();                             \\\n    e += p.GetHighHalf();                           \\\n    p = q + c;                                      \\\n    c = p.GetLowHalf();                             \\\n    p = (DWord) d + p.GetHighHalf();                \\\n    d = p.GetLowHalf();                             \\\n    e += p.GetHighHalf();\n\n#define SaveSquAcc(s, x, y)                         \\\n    R[s] = c;                                       \\\n    q = DWord::Multiply(A[x], A[y]);                \\\n    p = q + d;                                      \\\n    c = p.GetLowHalf();                             \\\n    p = (DWord) e + p.GetHighHalf();                \\\n    d = p.GetLowHalf();                             \\\n    e = p.GetHighHalf();                            \\\n    p = q + c;                                      \\\n    c = p.GetLowHalf();                             \\\n    p = (DWord) d + p.GetHighHalf();                \\\n    d = p.GetLowHalf();                             \\\n    e += p.GetHighHalf();\n\n\nvoid Portable::Multiply4(word *R, const word *A, const word *B)\n{\n    DWord p;\n    word c, d, e;\n\n    p = DWord::Multiply(A[0], B[0]);\n    R[0] = p.GetLowHalf();\n    c = p.GetHighHalf();\n    d = e = 0;\n\n    MulAcc(0, 1);\n    MulAcc(1, 0);\n\n    SaveMulAcc(1, 2, 0);\n    MulAcc(1, 1);\n    MulAcc(0, 2);\n\n    SaveMulAcc(2, 0, 3);\n    MulAcc(1, 2);\n    MulAcc(2, 1);\n    MulAcc(3, 0);\n\n    SaveMulAcc(3, 3, 1);\n    MulAcc(2, 2);\n    MulAcc(1, 3);\n\n    SaveMulAcc(4, 2, 3);\n    MulAcc(3, 2);\n\n    R[5] = c;\n    p = DWord::MultiplyAndAdd(A[3], B[3], d);\n    R[6] = p.GetLowHalf();\n    R[7] = e + p.GetHighHalf();\n}\n\nvoid Portable::Square2(word *R, const word *A)\n{\n    DWord p, q;\n    word c, d, e;\n\n    p = DWord::Multiply(A[0], A[0]);\n    R[0] = p.GetLowHalf();\n    c = p.GetHighHalf();\n    d = e = 0;\n\n    SquAcc(0, 1);\n\n    R[1] = c;\n    p = DWord::MultiplyAndAdd(A[1], A[1], d);\n    R[2] = p.GetLowHalf();\n    R[3] = e + p.GetHighHalf();\n}\n\nvoid Portable::Square4(word *R, const word *A)\n{\n#ifdef _MSC_VER\n    // VC60 workaround: MSVC 6.0 has an optimization bug that makes\n    // (dword)A*B where either A or B has been cast to a dword before\n    // very expensive. Revisit this function when this\n    // bug is fixed.\n    Multiply4(R, A, A);\n#else\n    const word *B = A;\n    DWord p, q;\n    word c, d, e;\n\n    p = DWord::Multiply(A[0], A[0]);\n    R[0] = p.GetLowHalf();\n    c = p.GetHighHalf();\n    d = e = 0;\n\n    SquAcc(0, 1);\n\n    SaveSquAcc(1, 2, 0);\n    MulAcc(1, 1);\n\n    SaveSquAcc(2, 0, 3);\n    SquAcc(1, 2);\n\n    SaveSquAcc(3, 3, 1);\n    MulAcc(2, 2);\n\n    SaveSquAcc(4, 2, 3);\n\n    R[5] = c;\n    p = DWord::MultiplyAndAdd(A[3], A[3], d);\n    R[6] = p.GetLowHalf();\n    R[7] = e + p.GetHighHalf();\n#endif\n}\n\nvoid Portable::Multiply8(word *R, const word *A, const word *B)\n{\n    DWord p;\n    word c, d, e;\n\n    p = DWord::Multiply(A[0], B[0]);\n    R[0] = p.GetLowHalf();\n    c = p.GetHighHalf();\n    d = e = 0;\n\n    MulAcc(0, 1);\n    MulAcc(1, 0);\n\n    SaveMulAcc(1, 2, 0);\n    MulAcc(1, 1);\n    MulAcc(0, 2);\n\n    SaveMulAcc(2, 0, 3);\n    MulAcc(1, 2);\n    MulAcc(2, 1);\n    MulAcc(3, 0);\n\n    SaveMulAcc(3, 0, 4);\n    MulAcc(1, 3);\n    MulAcc(2, 2);\n    MulAcc(3, 1);\n    MulAcc(4, 0);\n\n    SaveMulAcc(4, 0, 5);\n    MulAcc(1, 4);\n    MulAcc(2, 3);\n    MulAcc(3, 2);\n    MulAcc(4, 1);\n    MulAcc(5, 0);\n\n    SaveMulAcc(5, 0, 6);\n    MulAcc(1, 5);\n    MulAcc(2, 4);\n    MulAcc(3, 3);\n    MulAcc(4, 2);\n    MulAcc(5, 1);\n    MulAcc(6, 0);\n\n    SaveMulAcc(6, 0, 7);\n    MulAcc(1, 6);\n    MulAcc(2, 5);\n    MulAcc(3, 4);\n    MulAcc(4, 3);\n    MulAcc(5, 2);\n    MulAcc(6, 1);\n    MulAcc(7, 0);\n\n    SaveMulAcc(7, 1, 7);\n    MulAcc(2, 6);\n    MulAcc(3, 5);\n    MulAcc(4, 4);\n    MulAcc(5, 3);\n    MulAcc(6, 2);\n    MulAcc(7, 1);\n\n    SaveMulAcc(8, 2, 7);\n    MulAcc(3, 6);\n    MulAcc(4, 5);\n    MulAcc(5, 4);\n    MulAcc(6, 3);\n    MulAcc(7, 2);\n\n    SaveMulAcc(9, 3, 7);\n    MulAcc(4, 6);\n    MulAcc(5, 5);\n    MulAcc(6, 4);\n    MulAcc(7, 3);\n\n    SaveMulAcc(10, 4, 7);\n    MulAcc(5, 6);\n    MulAcc(6, 5);\n    MulAcc(7, 4);\n\n    SaveMulAcc(11, 5, 7);\n    MulAcc(6, 6);\n    MulAcc(7, 5);\n\n    SaveMulAcc(12, 6, 7);\n    MulAcc(7, 6);\n\n    R[13] = c;\n    p = DWord::MultiplyAndAdd(A[7], B[7], d);\n    R[14] = p.GetLowHalf();\n    R[15] = e + p.GetHighHalf();\n}\n\nvoid Portable::Multiply4Bottom(word *R, const word *A, const word *B)\n{\n    DWord p;\n    word c, d, e;\n\n    p = DWord::Multiply(A[0], B[0]);\n    R[0] = p.GetLowHalf();\n    c = p.GetHighHalf();\n    d = e = 0;\n\n    MulAcc(0, 1);\n    MulAcc(1, 0);\n\n    SaveMulAcc(1, 2, 0);\n    MulAcc(1, 1);\n    MulAcc(0, 2);\n\n    R[2] = c;\n    R[3] = d + A[0] * B[3] + A[1] * B[2] + A[2] * B[1] + A[3] * B[0];\n}\n\nvoid Portable::Multiply8Bottom(word *R, const word *A, const word *B)\n{\n    DWord p;\n    word c, d, e;\n\n    p = DWord::Multiply(A[0], B[0]);\n    R[0] = p.GetLowHalf();\n    c = p.GetHighHalf();\n    d = e = 0;\n\n    MulAcc(0, 1);\n    MulAcc(1, 0);\n\n    SaveMulAcc(1, 2, 0);\n    MulAcc(1, 1);\n    MulAcc(0, 2);\n\n    SaveMulAcc(2, 0, 3);\n    MulAcc(1, 2);\n    MulAcc(2, 1);\n    MulAcc(3, 0);\n\n    SaveMulAcc(3, 0, 4);\n    MulAcc(1, 3);\n    MulAcc(2, 2);\n    MulAcc(3, 1);\n    MulAcc(4, 0);\n\n    SaveMulAcc(4, 0, 5);\n    MulAcc(1, 4);\n    MulAcc(2, 3);\n    MulAcc(3, 2);\n    MulAcc(4, 1);\n    MulAcc(5, 0);\n\n    SaveMulAcc(5, 0, 6);\n    MulAcc(1, 5);\n    MulAcc(2, 4);\n    MulAcc(3, 3);\n    MulAcc(4, 2);\n    MulAcc(5, 1);\n    MulAcc(6, 0);\n\n    R[6] = c;\n    R[7] = d + A[0] * B[7] + A[1] * B[6] + A[2] * B[5] + A[3] * B[4] +\n               A[4] * B[3] + A[5] * B[2] + A[6] * B[1] + A[7] * B[0];\n}\n\n\n#undef MulAcc\n#undef SaveMulAcc\n#undef SquAcc\n#undef SaveSquAcc\n\n// optimized\n\n#ifdef TAOCRYPT_X86ASM_AVAILABLE\n\n// ************** x86 feature detection ***************\n\n\n#ifdef SSE2_INTRINSICS_AVAILABLE\n\n#ifndef _MSC_VER\n    static jmp_buf s_env;\n    static void SigIllHandler(int)\n    {\n        longjmp(s_env, 1);\n    }\n#endif\n\nstatic bool HasSSE2()\n{\n    if (!IsPentium())\n        return false;\n\n    word32 cpuid[4];\n    CpuId(1, cpuid);\n    if ((cpuid[3] & (1 << 26)) == 0)\n        return false;\n\n#ifdef _MSC_VER\n    __try\n    {\n        __asm xorpd xmm0, xmm0        // executing SSE2 instruction\n    }\n    __except (1)\n    {\n        return false;\n    }\n    return true;\n#else\n    typedef void (*SigHandler)(int);\n\n    SigHandler oldHandler = signal(SIGILL, SigIllHandler);\n    if (oldHandler == SIG_ERR)\n        return false;\n\n    bool result = true;\n    if (setjmp(s_env))\n        result = false;\n    else\n        __asm __volatile (\"xorpd %xmm0, %xmm0\");\n\n    signal(SIGILL, oldHandler);\n    return result;\n#endif\n}\n#endif // SSE2_INTRINSICS_AVAILABLE\n\n\nstatic bool IsP4()\n{\n    if (!IsPentium())\n        return false;\n\n    word32 cpuid[4];\n\n    CpuId(1, cpuid);\n    return ((cpuid[0] >> 8) & 0xf) == 0xf;\n}\n\n// ************** Pentium/P4 optimizations ***************\n\nclass PentiumOptimized : public Portable\n{\npublic:\n    static word TAOCRYPT_CDECL Add(word *C, const word *A, const word *B,\n                                   unsigned int N);\n    static word TAOCRYPT_CDECL Subtract(word *C, const word *A, const word *B,\n                                        unsigned int N);\n    static void TAOCRYPT_CDECL Multiply4(word *C, const word *A,\n                                         const word *B);\n    static void TAOCRYPT_CDECL Multiply8(word *C, const word *A,\n                                         const word *B);\n    static void TAOCRYPT_CDECL Multiply8Bottom(word *C, const word *A,\n                                               const word *B);\n};\n\nclass P4Optimized\n{\npublic:\n    static word TAOCRYPT_CDECL Add(word *C, const word *A, const word *B,\n                                   unsigned int N);\n    static word TAOCRYPT_CDECL Subtract(word *C, const word *A, const word *B,\n                                        unsigned int N);\n#ifdef SSE2_INTRINSICS_AVAILABLE\n    static void TAOCRYPT_CDECL Multiply4(word *C, const word *A,\n                                         const word *B);\n    static void TAOCRYPT_CDECL Multiply8(word *C, const word *A,\n                                         const word *B);\n    static void TAOCRYPT_CDECL Multiply8Bottom(word *C, const word *A,\n                                               const word *B);\n#endif\n};\n\ntypedef word (TAOCRYPT_CDECL * PAddSub)(word *C, const word *A, const word *B,\n                                        unsigned int N);\ntypedef void (TAOCRYPT_CDECL * PMul)(word *C, const word *A, const word *B);\n\nstatic PAddSub s_pAdd, s_pSub;\n#ifdef SSE2_INTRINSICS_AVAILABLE\nstatic PMul s_pMul4, s_pMul8, s_pMul8B;\n#endif\n\nstatic void SetPentiumFunctionPointers()\n{\n    if (!IsPentium())\n    {   \n        s_pAdd = &Portable::Add;\n        s_pSub = &Portable::Subtract;\n    }\n    else if (IsP4())\n    {\n        s_pAdd = &P4Optimized::Add;\n        s_pSub = &P4Optimized::Subtract;\n    }\n    else\n    {\n        s_pAdd = &PentiumOptimized::Add;\n        s_pSub = &PentiumOptimized::Subtract;\n    }\n\n#ifdef SSE2_INTRINSICS_AVAILABLE\n    if (!IsPentium()) \n    {\n        s_pMul4 = &Portable::Multiply4;\n        s_pMul8 = &Portable::Multiply8;\n        s_pMul8B = &Portable::Multiply8Bottom;\n    }\n    else if (HasSSE2())\n    {\n        s_pMul4 = &P4Optimized::Multiply4;\n        s_pMul8 = &P4Optimized::Multiply8;\n        s_pMul8B = &P4Optimized::Multiply8Bottom;\n    }\n    else\n    {\n        s_pMul4 = &PentiumOptimized::Multiply4;\n        s_pMul8 = &PentiumOptimized::Multiply8;\n        s_pMul8B = &PentiumOptimized::Multiply8Bottom;\n    }\n#endif\n}\n\nstatic const char s_RunAtStartupSetPentiumFunctionPointers =\n    (SetPentiumFunctionPointers(), 0);\n\n\nclass LowLevel : public PentiumOptimized\n{\npublic:\n    inline static word Add(word *C, const word *A, const word *B,\n                           unsigned int N)\n        {return s_pAdd(C, A, B, N);}\n    inline static word Subtract(word *C, const word *A, const word *B,\n                                unsigned int N)\n        {return s_pSub(C, A, B, N);}\n    inline static void Square4(word *R, const word *A)\n        {Multiply4(R, A, A);}\n#ifdef SSE2_INTRINSICS_AVAILABLE\n    inline static void Multiply4(word *C, const word *A, const word *B)\n        {s_pMul4(C, A, B);}\n    inline static void Multiply8(word *C, const word *A, const word *B)\n        {s_pMul8(C, A, B);}\n    inline static void Multiply8Bottom(word *C, const word *A, const word *B)\n        {s_pMul8B(C, A, B);}\n#endif\n};\n\n// use some tricks to share assembly code between MSVC and GCC\n#ifdef _MSC_VER\n    #define TAOCRYPT_NAKED __declspec(naked)\n    #define AS1(x) __asm x\n    #define AS2(x, y) __asm x, y\n    #define AddPrologue \\\n        __asm\tpush ebp \\\n        __asm\tpush ebx \\\n        __asm\tpush esi \\\n        __asm\tpush edi \\\n        __asm\tmov\t\tecx, [esp+20] \\\n        __asm\tmov\t\tedx, [esp+24] \\\n        __asm\tmov\t\tebx, [esp+28] \\\n        __asm\tmov\t\tesi, [esp+32]\n    #define AddEpilogue \\\n        __asm\tpop edi \\\n        __asm\tpop esi \\\n        __asm\tpop ebx \\\n        __asm\tpop ebp \\\n        __asm\tret\n    #define MulPrologue \\\n        __asm\tpush ebp \\\n        __asm\tpush ebx \\\n        __asm\tpush esi \\\n        __asm\tpush edi \\\n        __asm\tmov ecx, [esp+28] \\\n        __asm\tmov esi, [esp+24] \\\n        __asm\tpush [esp+20]\n    #define MulEpilogue \\\n        __asm\tadd esp, 4 \\\n        __asm\tpop edi \\\n        __asm\tpop esi \\\n        __asm\tpop ebx \\\n        __asm\tpop ebp \\\n        __asm\tret\n#else\n    #define TAOCRYPT_NAKED\n    #define AS1(x) #x \";\"\n    #define AS2(x, y) #x \", \" #y \";\"\n    #define AddPrologue \\\n        word res; \\\n        __asm__ __volatile__ \\\n        ( \\\n            \"push %%ebx;\"\t/* save this manually, in case of -fPIC */ \\\n            \"mov %3, %%ebx;\" \\\n            \".intel_syntax noprefix;\" \\\n            \"push ebp;\"\n    #define AddEpilogue \\\n            \"pop ebp;\" \\\n            \".att_syntax prefix;\" \\\n            \"pop %%ebx;\" \\\n            \"mov %%eax, %0;\" \\\n                    : \"=g\" (res) \\\n                    : \"c\" (C), \"d\" (A), \"m\" (B), \"S\" (N) \\\n                    : \"%edi\", \"memory\", \"cc\" \\\n        ); \\\n        return res;\n\n    #define MulPrologue \\\n        __asm__ __volatile__ \\\n        ( \\\n            \"push %%ebx;\"\t/* save this manually, in case of -fPIC */ \\\n            \"push %%ebp;\" \\\n            \"push %0;\" \\\n            \".intel_syntax noprefix;\"\n    #define MulEpilogue \\\n            \"add esp, 4;\" \\\n            \"pop ebp;\" \\\n            \"pop ebx;\" \\\n            \".att_syntax prefix;\" \\\n            : \\\n            : \"rm\" (Z), \"S\" (X), \"c\" (Y) \\\n            : \"%eax\", \"%edx\", \"%edi\", \"memory\", \"cc\" \\\n        );\n#endif\n\nTAOCRYPT_NAKED word PentiumOptimized::Add(word *C, const word *A,\n                                          const word *B, unsigned int N)\n{\n    AddPrologue\n\n    // now: ebx = B, ecx = C, edx = A, esi = N\n    AS2(    sub ecx, edx)           // hold the distance between C & A so we\n                                    // can add this to A to get C\n    AS2(    xor eax, eax)           // clear eax\n\n    AS2(    sub eax, esi)           // eax is a negative index from end of B\n    AS2(    lea ebx, [ebx+4*esi])   // ebx is end of B\n\n    AS2(    sar eax, 1)             // unit of eax is now dwords; this also\n                                    // clears the carry flag\n    AS1(    jz  loopendAdd)         // if no dwords then nothing to do\n\n    AS1(loopstartAdd:)\n    AS2(    mov    esi,[edx])           // load lower word of A\n    AS2(    mov    ebp,[edx+4])         // load higher word of A\n\n    AS2(    mov    edi,[ebx+8*eax])     // load lower word of B\n    AS2(    lea    edx,[edx+8])         // advance A and C\n\n    AS2(    adc    esi,edi)             // add lower words\n    AS2(    mov    edi,[ebx+8*eax+4])   // load higher word of B\n\n    AS2(    adc    ebp,edi)             // add higher words\n    AS1(    inc    eax)                 // advance B\n\n    AS2(    mov    [edx+ecx-8],esi)     // store lower word result\n    AS2(    mov    [edx+ecx-4],ebp)     // store higher word result\n\n    AS1(    jnz    loopstartAdd)   // loop until eax overflows and becomes zero\n\n    AS1(loopendAdd:)\n    AS2(    adc eax, 0)     // store carry into eax (return result register)\n\n    AddEpilogue\n}\n\nTAOCRYPT_NAKED word PentiumOptimized::Subtract(word *C, const word *A,\n                                               const word *B, unsigned int N)\n{\n    AddPrologue\n\n    // now: ebx = B, ecx = C, edx = A, esi = N\n    AS2(    sub ecx, edx)           // hold the distance between C & A so we\n                                    // can add this to A to get C\n    AS2(    xor eax, eax)           // clear eax\n\n    AS2(    sub eax, esi)           // eax is a negative index from end of B\n    AS2(    lea ebx, [ebx+4*esi])   // ebx is end of B\n\n    AS2(    sar eax, 1)             // unit of eax is now dwords; this also\n                                    // clears the carry flag\n    AS1(    jz  loopendSub)         // if no dwords then nothing to do\n\n    AS1(loopstartSub:)\n    AS2(    mov    esi,[edx])           // load lower word of A\n    AS2(    mov    ebp,[edx+4])         // load higher word of A\n\n    AS2(    mov    edi,[ebx+8*eax])     // load lower word of B\n    AS2(    lea    edx,[edx+8])         // advance A and C\n\n    AS2(    sbb    esi,edi)             // subtract lower words\n    AS2(    mov    edi,[ebx+8*eax+4])   // load higher word of B\n\n    AS2(    sbb    ebp,edi)             // subtract higher words\n    AS1(    inc    eax)                 // advance B\n\n    AS2(    mov    [edx+ecx-8],esi)     // store lower word result\n    AS2(    mov    [edx+ecx-4],ebp)     // store higher word result\n\n    AS1(    jnz    loopstartSub)   // loop until eax overflows and becomes zero\n\n    AS1(loopendSub:)\n    AS2(    adc eax, 0)     // store carry into eax (return result register)\n\n    AddEpilogue\n}\n\n// On Pentium 4, the adc and sbb instructions are very expensive, so avoid them.\n\nTAOCRYPT_NAKED word P4Optimized::Add(word *C, const word *A, const word *B,\n                                     unsigned int N)\n{\n    AddPrologue\n\n    // now: ebx = B, ecx = C, edx = A, esi = N\n    AS2(    xor     eax, eax)\n    AS1(    neg     esi)\n    AS1(    jz      loopendAddP4)       // if no dwords then nothing to do\n\n    AS2(    mov     edi, [edx])\n    AS2(    mov     ebp, [ebx])\n    AS1(    jmp     carry1AddP4)\n\n    AS1(loopstartAddP4:)\n    AS2(    mov     edi, [edx+8])\n    AS2(    add     ecx, 8)\n    AS2(    add     edx, 8)\n    AS2(    mov     ebp, [ebx])\n    AS2(    add     edi, eax)\n    AS1(    jc      carry1AddP4)\n    AS2(    xor     eax, eax)\n\n    AS1(carry1AddP4:)\n    AS2(    add     edi, ebp)\n    AS2(    mov     ebp, 1)\n    AS2(    mov     [ecx], edi)\n    AS2(    mov     edi, [edx+4])\n    AS2(    cmovc   eax, ebp)\n    AS2(    mov     ebp, [ebx+4])\n    AS2(    add     ebx, 8)\n    AS2(    add     edi, eax)\n    AS1(    jc      carry2AddP4)\n    AS2(    xor     eax, eax)\n\n    AS1(carry2AddP4:)\n    AS2(    add     edi, ebp)\n    AS2(    mov     ebp, 1)\n    AS2(    cmovc   eax, ebp)\n    AS2(    mov     [ecx+4], edi)\n    AS2(    add     esi, 2)\n    AS1(    jnz     loopstartAddP4)\n\n    AS1(loopendAddP4:)\n\n    AddEpilogue\n}\n\nTAOCRYPT_NAKED word P4Optimized::Subtract(word *C, const word *A,\n                                          const word *B, unsigned int N)\n{\n    AddPrologue\n\n    // now: ebx = B, ecx = C, edx = A, esi = N\n    AS2(    xor     eax, eax)\n    AS1(    neg     esi)\n    AS1(    jz      loopendSubP4)       // if no dwords then nothing to do\n\n    AS2(    mov     edi, [edx])\n    AS2(    mov     ebp, [ebx])\n    AS1(    jmp     carry1SubP4)\n\n    AS1(loopstartSubP4:)\n    AS2(    mov     edi, [edx+8])\n    AS2(    add     edx, 8)\n    AS2(    add     ecx, 8)\n    AS2(    mov     ebp, [ebx])\n    AS2(    sub     edi, eax)\n    AS1(    jc      carry1SubP4)\n    AS2(    xor     eax, eax)\n\n    AS1(carry1SubP4:)\n    AS2(    sub     edi, ebp)\n    AS2(    mov     ebp, 1)\n    AS2(    mov     [ecx], edi)\n    AS2(    mov     edi, [edx+4])\n    AS2(    cmovc   eax, ebp)\n    AS2(    mov     ebp, [ebx+4])\n    AS2(    add     ebx, 8)\n    AS2(    sub     edi, eax)\n    AS1(    jc      carry2SubP4)\n    AS2(    xor     eax, eax)\n\n    AS1(carry2SubP4:)\n    AS2(    sub     edi, ebp)\n    AS2(    mov     ebp, 1)\n    AS2(    cmovc   eax, ebp)\n    AS2(    mov     [ecx+4], edi)\n    AS2(    add     esi, 2)\n    AS1(    jnz     loopstartSubP4)\n\n    AS1(loopendSubP4:)\n\n    AddEpilogue\n}\n\n// multiply assembly code originally contributed by Leonard Janke\n\n#define MulStartup \\\n    AS2(xor ebp, ebp) \\\n    AS2(xor edi, edi) \\\n    AS2(xor ebx, ebx) \n\n#define MulShiftCarry \\\n    AS2(mov ebp, edx) \\\n    AS2(mov edi, ebx) \\\n    AS2(xor ebx, ebx)\n\n#define MulAccumulateBottom(i,j) \\\n    AS2(mov eax, [ecx+4*j]) \\\n    AS2(imul eax, dword ptr [esi+4*i]) \\\n    AS2(add ebp, eax)\n\n#define MulAccumulate(i,j) \\\n    AS2(mov eax, [ecx+4*j]) \\\n    AS1(mul dword ptr [esi+4*i]) \\\n    AS2(add ebp, eax) \\\n    AS2(adc edi, edx) \\\n    AS2(adc bl, bh)\n\n#define MulStoreDigit(i)  \\\n    AS2(mov edx, edi) \\\n    AS2(mov edi, [esp]) \\\n    AS2(mov [edi+4*i], ebp)\n\n#define MulLastDiagonal(digits) \\\n    AS2(mov eax, [ecx+4*(digits-1)]) \\\n    AS1(mul dword ptr [esi+4*(digits-1)]) \\\n    AS2(add ebp, eax) \\\n    AS2(adc edx, edi) \\\n    AS2(mov edi, [esp]) \\\n    AS2(mov [edi+4*(2*digits-2)], ebp) \\\n    AS2(mov [edi+4*(2*digits-1)], edx)\n\nTAOCRYPT_NAKED void PentiumOptimized::Multiply4(word* Z, const word* X,\n                                                const word* Y)\n{\n    MulPrologue\n    // now: [esp] = Z, esi = X, ecx = Y\n    MulStartup\n    MulAccumulate(0,0)\n    MulStoreDigit(0)\n    MulShiftCarry\n\n    MulAccumulate(1,0)\n    MulAccumulate(0,1)\n    MulStoreDigit(1)\n    MulShiftCarry\n\n    MulAccumulate(2,0)\n    MulAccumulate(1,1)\n    MulAccumulate(0,2)\n    MulStoreDigit(2)\n    MulShiftCarry\n\n    MulAccumulate(3,0)\n    MulAccumulate(2,1)\n    MulAccumulate(1,2)\n    MulAccumulate(0,3)\n    MulStoreDigit(3)\n    MulShiftCarry\n\n    MulAccumulate(3,1)\n    MulAccumulate(2,2)\n    MulAccumulate(1,3)\n    MulStoreDigit(4)\n    MulShiftCarry\n\n    MulAccumulate(3,2)\n    MulAccumulate(2,3)\n    MulStoreDigit(5)\n    MulShiftCarry\n\n    MulLastDiagonal(4)\n    MulEpilogue\n}\n\nTAOCRYPT_NAKED void PentiumOptimized::Multiply8(word* Z, const word* X,\n                                                const word* Y)\n{\n    MulPrologue\n    // now: [esp] = Z, esi = X, ecx = Y\n    MulStartup\n    MulAccumulate(0,0)\n    MulStoreDigit(0)\n    MulShiftCarry\n\n    MulAccumulate(1,0)\n    MulAccumulate(0,1)\n    MulStoreDigit(1)\n    MulShiftCarry\n\n    MulAccumulate(2,0)\n    MulAccumulate(1,1)\n    MulAccumulate(0,2)\n    MulStoreDigit(2)\n    MulShiftCarry\n\n    MulAccumulate(3,0)\n    MulAccumulate(2,1)\n    MulAccumulate(1,2)\n    MulAccumulate(0,3)\n    MulStoreDigit(3)\n    MulShiftCarry\n\n    MulAccumulate(4,0)\n    MulAccumulate(3,1)\n    MulAccumulate(2,2)\n    MulAccumulate(1,3)\n    MulAccumulate(0,4)\n    MulStoreDigit(4)\n    MulShiftCarry\n\n    MulAccumulate(5,0)\n    MulAccumulate(4,1)\n    MulAccumulate(3,2)\n    MulAccumulate(2,3)\n    MulAccumulate(1,4)\n    MulAccumulate(0,5)\n    MulStoreDigit(5)\n    MulShiftCarry\n\n    MulAccumulate(6,0)\n    MulAccumulate(5,1)\n    MulAccumulate(4,2)\n    MulAccumulate(3,3)\n    MulAccumulate(2,4)\n    MulAccumulate(1,5)\n    MulAccumulate(0,6)\n    MulStoreDigit(6)\n    MulShiftCarry\n\n    MulAccumulate(7,0)\n    MulAccumulate(6,1)\n    MulAccumulate(5,2)\n    MulAccumulate(4,3)\n    MulAccumulate(3,4)\n    MulAccumulate(2,5)\n    MulAccumulate(1,6)\n    MulAccumulate(0,7)\n    MulStoreDigit(7)\n    MulShiftCarry\n\n    MulAccumulate(7,1)\n    MulAccumulate(6,2)\n    MulAccumulate(5,3)\n    MulAccumulate(4,4)\n    MulAccumulate(3,5)\n    MulAccumulate(2,6)\n    MulAccumulate(1,7)\n    MulStoreDigit(8)\n    MulShiftCarry\n\n    MulAccumulate(7,2)\n    MulAccumulate(6,3)\n    MulAccumulate(5,4)\n    MulAccumulate(4,5)\n    MulAccumulate(3,6)\n    MulAccumulate(2,7)\n    MulStoreDigit(9)\n    MulShiftCarry\n\n    MulAccumulate(7,3)\n    MulAccumulate(6,4)\n    MulAccumulate(5,5)\n    MulAccumulate(4,6)\n    MulAccumulate(3,7)\n    MulStoreDigit(10)\n    MulShiftCarry\n\n    MulAccumulate(7,4)\n    MulAccumulate(6,5)\n    MulAccumulate(5,6)\n    MulAccumulate(4,7)\n    MulStoreDigit(11)\n    MulShiftCarry\n\n    MulAccumulate(7,5)\n    MulAccumulate(6,6)\n    MulAccumulate(5,7)\n    MulStoreDigit(12)\n    MulShiftCarry\n\n    MulAccumulate(7,6)\n    MulAccumulate(6,7)\n    MulStoreDigit(13)\n    MulShiftCarry\n\n    MulLastDiagonal(8)\n    MulEpilogue\n}\n\nTAOCRYPT_NAKED void PentiumOptimized::Multiply8Bottom(word* Z, const word* X,\n                                                      const word* Y)\n{\n    MulPrologue\n    // now: [esp] = Z, esi = X, ecx = Y\n    MulStartup\n    MulAccumulate(0,0)\n    MulStoreDigit(0)\n    MulShiftCarry\n\n    MulAccumulate(1,0)\n    MulAccumulate(0,1)\n    MulStoreDigit(1)\n    MulShiftCarry\n\n    MulAccumulate(2,0)\n    MulAccumulate(1,1)\n    MulAccumulate(0,2)\n    MulStoreDigit(2)\n    MulShiftCarry\n\n    MulAccumulate(3,0)\n    MulAccumulate(2,1)\n    MulAccumulate(1,2)\n    MulAccumulate(0,3)\n    MulStoreDigit(3)\n    MulShiftCarry\n\n    MulAccumulate(4,0)\n    MulAccumulate(3,1)\n    MulAccumulate(2,2)\n    MulAccumulate(1,3)\n    MulAccumulate(0,4)\n    MulStoreDigit(4)\n    MulShiftCarry\n\n    MulAccumulate(5,0)\n    MulAccumulate(4,1)\n    MulAccumulate(3,2)\n    MulAccumulate(2,3)\n    MulAccumulate(1,4)\n    MulAccumulate(0,5)\n    MulStoreDigit(5)\n    MulShiftCarry\n\n    MulAccumulate(6,0)\n    MulAccumulate(5,1)\n    MulAccumulate(4,2)\n    MulAccumulate(3,3)\n    MulAccumulate(2,4)\n    MulAccumulate(1,5)\n    MulAccumulate(0,6)\n    MulStoreDigit(6)\n    MulShiftCarry\n\n    MulAccumulateBottom(7,0)\n    MulAccumulateBottom(6,1)\n    MulAccumulateBottom(5,2)\n    MulAccumulateBottom(4,3)\n    MulAccumulateBottom(3,4)\n    MulAccumulateBottom(2,5)\n    MulAccumulateBottom(1,6)\n    MulAccumulateBottom(0,7)\n    MulStoreDigit(7)\n    MulEpilogue\n}\n\n#undef AS1\n#undef AS2\n\n#else\t// not x86 - no processor specific code at this layer\n\ntypedef Portable LowLevel;\n\n#endif\n\n#ifdef SSE2_INTRINSICS_AVAILABLE\n\n#ifdef __GNUC__\n#define TAOCRYPT_FASTCALL\n#else\n#define TAOCRYPT_FASTCALL __fastcall\n#endif\n\nstatic void TAOCRYPT_FASTCALL P4_Mul(__m128i *C, const __m128i *A,\n                                     const __m128i *B)\n{\n    __m128i a3210 = _mm_load_si128(A);\n    __m128i b3210 = _mm_load_si128(B);\n\n    __m128i sum;\n\n    __m128i z = _mm_setzero_si128();\n    __m128i a2b2_a0b0 = _mm_mul_epu32(a3210, b3210);\n    C[0] = a2b2_a0b0;\n\n    __m128i a3120 = _mm_shuffle_epi32(a3210, _MM_SHUFFLE(3, 1, 2, 0));\n    __m128i b3021 = _mm_shuffle_epi32(b3210, _MM_SHUFFLE(3, 0, 2, 1));\n    __m128i a1b0_a0b1 = _mm_mul_epu32(a3120, b3021);\n    __m128i a1b0 = _mm_unpackhi_epi32(a1b0_a0b1, z);\n    __m128i a0b1 = _mm_unpacklo_epi32(a1b0_a0b1, z);\n    C[1] = _mm_add_epi64(a1b0, a0b1);\n\n    __m128i a31 = _mm_srli_epi64(a3210, 32);\n    __m128i b31 = _mm_srli_epi64(b3210, 32);\n    __m128i a3b3_a1b1 = _mm_mul_epu32(a31, b31);\n    C[6] = a3b3_a1b1;\n\n    __m128i a1b1 = _mm_unpacklo_epi32(a3b3_a1b1, z);\n    __m128i b3012 = _mm_shuffle_epi32(b3210, _MM_SHUFFLE(3, 0, 1, 2));\n    __m128i a2b0_a0b2 = _mm_mul_epu32(a3210, b3012);\n    __m128i a0b2 = _mm_unpacklo_epi32(a2b0_a0b2, z);\n    __m128i a2b0 = _mm_unpackhi_epi32(a2b0_a0b2, z);\n    sum = _mm_add_epi64(a1b1, a0b2);\n    C[2] = _mm_add_epi64(sum, a2b0);\n\n    __m128i a2301 = _mm_shuffle_epi32(a3210, _MM_SHUFFLE(2, 3, 0, 1));\n    __m128i b2103 = _mm_shuffle_epi32(b3210, _MM_SHUFFLE(2, 1, 0, 3));\n    __m128i a3b0_a1b2 = _mm_mul_epu32(a2301, b3012);\n    __m128i a2b1_a0b3 = _mm_mul_epu32(a3210, b2103);\n    __m128i a3b0 = _mm_unpackhi_epi32(a3b0_a1b2, z);\n    __m128i a1b2 = _mm_unpacklo_epi32(a3b0_a1b2, z);\n    __m128i a2b1 = _mm_unpackhi_epi32(a2b1_a0b3, z);\n    __m128i a0b3 = _mm_unpacklo_epi32(a2b1_a0b3, z);\n    __m128i sum1 = _mm_add_epi64(a3b0, a1b2);\n    sum = _mm_add_epi64(a2b1, a0b3);\n    C[3] = _mm_add_epi64(sum, sum1);\n\n    __m128i\ta3b1_a1b3 = _mm_mul_epu32(a2301, b2103);\n    __m128i a2b2 = _mm_unpackhi_epi32(a2b2_a0b0, z);\n    __m128i a3b1 = _mm_unpackhi_epi32(a3b1_a1b3, z);\n    __m128i a1b3 = _mm_unpacklo_epi32(a3b1_a1b3, z);\n    sum = _mm_add_epi64(a2b2, a3b1);\n    C[4] = _mm_add_epi64(sum, a1b3);\n\n    __m128i a1302 = _mm_shuffle_epi32(a3210, _MM_SHUFFLE(1, 3, 0, 2));\n    __m128i b1203 = _mm_shuffle_epi32(b3210, _MM_SHUFFLE(1, 2, 0, 3));\n    __m128i a3b2_a2b3 = _mm_mul_epu32(a1302, b1203);\n    __m128i a3b2 = _mm_unpackhi_epi32(a3b2_a2b3, z);\n    __m128i a2b3 = _mm_unpacklo_epi32(a3b2_a2b3, z);\n    C[5] = _mm_add_epi64(a3b2, a2b3);\n}\n\nvoid P4Optimized::Multiply4(word *C, const word *A, const word *B)\n{\n    __m128i temp[7];\n    const word *w = (word *)temp;\n    const __m64 *mw = (__m64 *)w;\n\n    P4_Mul(temp, (__m128i *)A, (__m128i *)B);\n\n    C[0] = w[0];\n\n    __m64 s1, s2;\n\n    __m64 w1 = _mm_cvtsi32_si64(w[1]);\n    __m64 w4 = mw[2];\n    __m64 w6 = mw[3];\n    __m64 w8 = mw[4];\n    __m64 w10 = mw[5];\n    __m64 w12 = mw[6];\n    __m64 w14 = mw[7];\n    __m64 w16 = mw[8];\n    __m64 w18 = mw[9];\n    __m64 w20 = mw[10];\n    __m64 w22 = mw[11];\n    __m64 w26 = _mm_cvtsi32_si64(w[26]);\n\n    s1 = _mm_add_si64(w1, w4);\n    C[1] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s2 = _mm_add_si64(w6, w8);\n    s1 = _mm_add_si64(s1, s2);\n    C[2] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s2 = _mm_add_si64(w10, w12);\n    s1 = _mm_add_si64(s1, s2);\n    C[3] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s2 = _mm_add_si64(w14, w16);\n    s1 = _mm_add_si64(s1, s2);\n    C[4] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s2 = _mm_add_si64(w18, w20);\n    s1 = _mm_add_si64(s1, s2);\n    C[5] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s2 = _mm_add_si64(w22, w26);\n    s1 = _mm_add_si64(s1, s2);\n    C[6] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    C[7] = _mm_cvtsi64_si32(s1) + w[27];\n    _mm_empty();\n}\n\nvoid P4Optimized::Multiply8(word *C, const word *A, const word *B)\n{\n    __m128i temp[28];\n    const word *w = (word *)temp;\n    const __m64 *mw = (__m64 *)w;\n    const word *x = (word *)temp+7*4;\n    const __m64 *mx = (__m64 *)x;\n    const word *y = (word *)temp+7*4*2;\n    const __m64 *my = (__m64 *)y;\n    const word *z = (word *)temp+7*4*3;\n    const __m64 *mz = (__m64 *)z;\n\n    P4_Mul(temp, (__m128i *)A, (__m128i *)B);\n\n    P4_Mul(temp+7, (__m128i *)A+1, (__m128i *)B);\n\n    P4_Mul(temp+14, (__m128i *)A, (__m128i *)B+1);\n\n    P4_Mul(temp+21, (__m128i *)A+1, (__m128i *)B+1);\n\n    C[0] = w[0];\n\n    __m64 s1, s2, s3, s4;\n\n    __m64 w1 = _mm_cvtsi32_si64(w[1]);\n    __m64 w4 = mw[2];\n    __m64 w6 = mw[3];\n    __m64 w8 = mw[4];\n    __m64 w10 = mw[5];\n    __m64 w12 = mw[6];\n    __m64 w14 = mw[7];\n    __m64 w16 = mw[8];\n    __m64 w18 = mw[9];\n    __m64 w20 = mw[10];\n    __m64 w22 = mw[11];\n    __m64 w26 = _mm_cvtsi32_si64(w[26]);\n    __m64 w27 = _mm_cvtsi32_si64(w[27]);\n\n    __m64 x0 = _mm_cvtsi32_si64(x[0]);\n    __m64 x1 = _mm_cvtsi32_si64(x[1]);\n    __m64 x4 = mx[2];\n    __m64 x6 = mx[3];\n    __m64 x8 = mx[4];\n    __m64 x10 = mx[5];\n    __m64 x12 = mx[6];\n    __m64 x14 = mx[7];\n    __m64 x16 = mx[8];\n    __m64 x18 = mx[9];\n    __m64 x20 = mx[10];\n    __m64 x22 = mx[11];\n    __m64 x26 = _mm_cvtsi32_si64(x[26]);\n    __m64 x27 = _mm_cvtsi32_si64(x[27]);\n\n    __m64 y0 = _mm_cvtsi32_si64(y[0]);\n    __m64 y1 = _mm_cvtsi32_si64(y[1]);\n    __m64 y4 = my[2];\n    __m64 y6 = my[3];\n    __m64 y8 = my[4];\n    __m64 y10 = my[5];\n    __m64 y12 = my[6];\n    __m64 y14 = my[7];\n    __m64 y16 = my[8];\n    __m64 y18 = my[9];\n    __m64 y20 = my[10];\n    __m64 y22 = my[11];\n    __m64 y26 = _mm_cvtsi32_si64(y[26]);\n    __m64 y27 = _mm_cvtsi32_si64(y[27]);\n\n    __m64 z0 = _mm_cvtsi32_si64(z[0]);\n    __m64 z1 = _mm_cvtsi32_si64(z[1]);\n    __m64 z4 = mz[2];\n    __m64 z6 = mz[3];\n    __m64 z8 = mz[4];\n    __m64 z10 = mz[5];\n    __m64 z12 = mz[6];\n    __m64 z14 = mz[7];\n    __m64 z16 = mz[8];\n    __m64 z18 = mz[9];\n    __m64 z20 = mz[10];\n    __m64 z22 = mz[11];\n    __m64 z26 = _mm_cvtsi32_si64(z[26]);\n\n    s1 = _mm_add_si64(w1, w4);\n    C[1] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s2 = _mm_add_si64(w6, w8);\n    s1 = _mm_add_si64(s1, s2);\n    C[2] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s2 = _mm_add_si64(w10, w12);\n    s1 = _mm_add_si64(s1, s2);\n    C[3] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s3 = _mm_add_si64(x0, y0);\n    s2 = _mm_add_si64(w14, w16);\n    s1 = _mm_add_si64(s1, s3);\n    s1 = _mm_add_si64(s1, s2);\n    C[4] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s3 = _mm_add_si64(x1, y1);\n    s4 = _mm_add_si64(x4, y4);\n    s1 = _mm_add_si64(s1, w18);\n    s3 = _mm_add_si64(s3, s4);\n    s1 = _mm_add_si64(s1, w20);\n    s1 = _mm_add_si64(s1, s3);\n    C[5] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s3 = _mm_add_si64(x6, y6);\n    s4 = _mm_add_si64(x8, y8);\n    s1 = _mm_add_si64(s1, w22);\n    s3 = _mm_add_si64(s3, s4);\n    s1 = _mm_add_si64(s1, w26);\n    s1 = _mm_add_si64(s1, s3);\n    C[6] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s3 = _mm_add_si64(x10, y10);\n    s4 = _mm_add_si64(x12, y12);\n    s1 = _mm_add_si64(s1, w27);\n    s3 = _mm_add_si64(s3, s4);\n    s1 = _mm_add_si64(s1, s3);\n    C[7] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s3 = _mm_add_si64(x14, y14);\n    s4 = _mm_add_si64(x16, y16);\n    s1 = _mm_add_si64(s1, z0);\n    s3 = _mm_add_si64(s3, s4);\n    s1 = _mm_add_si64(s1, s3);\n    C[8] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s3 = _mm_add_si64(x18, y18);\n    s4 = _mm_add_si64(x20, y20);\n    s1 = _mm_add_si64(s1, z1);\n    s3 = _mm_add_si64(s3, s4);\n    s1 = _mm_add_si64(s1, z4);\n    s1 = _mm_add_si64(s1, s3);\n    C[9] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s3 = _mm_add_si64(x22, y22);\n    s4 = _mm_add_si64(x26, y26);\n    s1 = _mm_add_si64(s1, z6);\n    s3 = _mm_add_si64(s3, s4);\n    s1 = _mm_add_si64(s1, z8);\n    s1 = _mm_add_si64(s1, s3);\n    C[10] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s3 = _mm_add_si64(x27, y27);\n    s1 = _mm_add_si64(s1, z10);\n    s1 = _mm_add_si64(s1, z12);\n    s1 = _mm_add_si64(s1, s3);\n    C[11] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s3 = _mm_add_si64(z14, z16);\n    s1 = _mm_add_si64(s1, s3);\n    C[12] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s3 = _mm_add_si64(z18, z20);\n    s1 = _mm_add_si64(s1, s3);\n    C[13] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s3 = _mm_add_si64(z22, z26);\n    s1 = _mm_add_si64(s1, s3);\n    C[14] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    C[15] = z[27] + _mm_cvtsi64_si32(s1);\n    _mm_empty();\n}\n\nvoid P4Optimized::Multiply8Bottom(word *C, const word *A, const word *B)\n{\n    __m128i temp[21];\n    const word *w = (word *)temp;\n    const __m64 *mw = (__m64 *)w;\n    const word *x = (word *)temp+7*4;\n    const __m64 *mx = (__m64 *)x;\n    const word *y = (word *)temp+7*4*2;\n    const __m64 *my = (__m64 *)y;\n\n    P4_Mul(temp, (__m128i *)A, (__m128i *)B);\n\n    P4_Mul(temp+7, (__m128i *)A+1, (__m128i *)B);\n\n    P4_Mul(temp+14, (__m128i *)A, (__m128i *)B+1);\n\n    C[0] = w[0];\n\n    __m64 s1, s2, s3, s4;\n\n    __m64 w1 = _mm_cvtsi32_si64(w[1]);\n    __m64 w4 = mw[2];\n    __m64 w6 = mw[3];\n    __m64 w8 = mw[4];\n    __m64 w10 = mw[5];\n    __m64 w12 = mw[6];\n    __m64 w14 = mw[7];\n    __m64 w16 = mw[8];\n    __m64 w18 = mw[9];\n    __m64 w20 = mw[10];\n    __m64 w22 = mw[11];\n    __m64 w26 = _mm_cvtsi32_si64(w[26]);\n\n    __m64 x0 = _mm_cvtsi32_si64(x[0]);\n    __m64 x1 = _mm_cvtsi32_si64(x[1]);\n    __m64 x4 = mx[2];\n    __m64 x6 = mx[3];\n    __m64 x8 = mx[4];\n\n    __m64 y0 = _mm_cvtsi32_si64(y[0]);\n    __m64 y1 = _mm_cvtsi32_si64(y[1]);\n    __m64 y4 = my[2];\n    __m64 y6 = my[3];\n    __m64 y8 = my[4];\n\n    s1 = _mm_add_si64(w1, w4);\n    C[1] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s2 = _mm_add_si64(w6, w8);\n    s1 = _mm_add_si64(s1, s2);\n    C[2] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s2 = _mm_add_si64(w10, w12);\n    s1 = _mm_add_si64(s1, s2);\n    C[3] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s3 = _mm_add_si64(x0, y0);\n    s2 = _mm_add_si64(w14, w16);\n    s1 = _mm_add_si64(s1, s3);\n    s1 = _mm_add_si64(s1, s2);\n    C[4] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s3 = _mm_add_si64(x1, y1);\n    s4 = _mm_add_si64(x4, y4);\n    s1 = _mm_add_si64(s1, w18);\n    s3 = _mm_add_si64(s3, s4);\n    s1 = _mm_add_si64(s1, w20);\n    s1 = _mm_add_si64(s1, s3);\n    C[5] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    s3 = _mm_add_si64(x6, y6);\n    s4 = _mm_add_si64(x8, y8);\n    s1 = _mm_add_si64(s1, w22);\n    s3 = _mm_add_si64(s3, s4);\n    s1 = _mm_add_si64(s1, w26);\n    s1 = _mm_add_si64(s1, s3);\n    C[6] = _mm_cvtsi64_si32(s1);\n    s1 = _mm_srli_si64(s1, 32);\n\n    C[7] = _mm_cvtsi64_si32(s1) + w[27] + x[10] + y[10] + x[12] + y[12];\n    _mm_empty();\n}\n\n#endif\t// #ifdef SSE2_INTRINSICS_AVAILABLE\n\n// end optimized\n\n// ********************************************************\n\n#define A0      A\n#define A1      (A+N2)\n#define B0      B\n#define B1      (B+N2)\n\n#define T0      T\n#define T1      (T+N2)\n#define T2      (T+N)\n#define T3      (T+N+N2)\n\n#define R0      R\n#define R1      (R+N2)\n#define R2      (R+N)\n#define R3      (R+N+N2)\n\n//VC60 workaround: compiler bug triggered without the extra dummy parameters\n\n// R[2*N] - result = A*B\n// T[2*N] - temporary work space\n// A[N] --- multiplier\n// B[N] --- multiplicant\n\n\nvoid RecursiveMultiply(word *R, word *T, const word *A, const word *B,\n                       unsigned int N)\n{\n    if (LowLevel::MultiplyRecursionLimit() >= 8 && N==8)\n        LowLevel::Multiply8(R, A, B);\n    else if (LowLevel::MultiplyRecursionLimit() >= 4 && N==4)\n        LowLevel::Multiply4(R, A, B);\n    else if (N==2)\n        LowLevel::Multiply2(R, A, B);\n    else\n    {\n        const unsigned int N2 = N/2;\n        int carry;\n\n        int aComp = Compare(A0, A1, N2);\n        int bComp = Compare(B0, B1, N2);\n\n        switch (2*aComp + aComp + bComp)\n        {\n        case -4:\n            LowLevel::Subtract(R0, A1, A0, N2);\n            LowLevel::Subtract(R1, B0, B1, N2);\n            RecursiveMultiply(T0, T2, R0, R1, N2);\n            LowLevel::Subtract(T1, T1, R0, N2);\n            carry = -1;\n            break;\n        case -2:\n            LowLevel::Subtract(R0, A1, A0, N2);\n            LowLevel::Subtract(R1, B0, B1, N2);\n            RecursiveMultiply(T0, T2, R0, R1, N2);\n            carry = 0;\n            break;\n        case 2:\n            LowLevel::Subtract(R0, A0, A1, N2);\n            LowLevel::Subtract(R1, B1, B0, N2);\n            RecursiveMultiply(T0, T2, R0, R1, N2);\n            carry = 0;\n            break;\n        case 4:\n            LowLevel::Subtract(R0, A1, A0, N2);\n            LowLevel::Subtract(R1, B0, B1, N2);\n            RecursiveMultiply(T0, T2, R0, R1, N2);\n            LowLevel::Subtract(T1, T1, R1, N2);\n            carry = -1;\n            break;\n        default:\n            SetWords(T0, 0, N);\n            carry = 0;\n        }\n\n        RecursiveMultiply(R0, T2, A0, B0, N2);\n        RecursiveMultiply(R2, T2, A1, B1, N2);\n\n        // now T[01] holds (A1-A0)*(B0-B1),R[01] holds A0*B0, R[23] holds A1*B1\n\n        carry += LowLevel::Add(T0, T0, R0, N);\n        carry += LowLevel::Add(T0, T0, R2, N);\n        carry += LowLevel::Add(R1, R1, T0, N);\n\n        Increment(R3, N2, carry);\n    }\n}\n\n\nvoid RecursiveSquare(word *R, word *T, const word *A, unsigned int N)                     \n{\n    if (LowLevel::SquareRecursionLimit() >= 4 && N==4)\n        LowLevel::Square4(R, A);\n    else if (N==2)\n        LowLevel::Square2(R, A);\n    else\n    {\n        const unsigned int N2 = N/2;\n\n        RecursiveSquare(R0, T2, A0, N2);\n        RecursiveSquare(R2, T2, A1, N2);\n        RecursiveMultiply(T0, T2, A0, A1, N2);\n\n        word carry = LowLevel::Add(R1, R1, T0, N);\n        carry += LowLevel::Add(R1, R1, T0, N);\n        Increment(R3, N2, carry);\n    }\n}\n\n\n// R[N] - bottom half of A*B\n// T[N] - temporary work space\n// A[N] - multiplier\n// B[N] - multiplicant\n\n\nvoid RecursiveMultiplyBottom(word *R, word *T, const word *A, const word *B,\n                             unsigned int N)\n{\n    if (LowLevel::MultiplyBottomRecursionLimit() >= 8 && N==8)\n        LowLevel::Multiply8Bottom(R, A, B);\n    else if (LowLevel::MultiplyBottomRecursionLimit() >= 4 && N==4)\n        LowLevel::Multiply4Bottom(R, A, B);\n    else if (N==2)\n        LowLevel::Multiply2Bottom(R, A, B);\n    else\n    {\n        const unsigned int N2 = N/2;\n\n        RecursiveMultiply(R, T, A0, B0, N2);\n        RecursiveMultiplyBottom(T0, T1, A1, B0, N2);\n        LowLevel::Add(R1, R1, T0, N2);\n        RecursiveMultiplyBottom(T0, T1, A0, B1, N2);\n        LowLevel::Add(R1, R1, T0, N2);\n    }\n}\n\n\nvoid RecursiveMultiplyTop(word *R, word *T, const word *L, const word *A,\n                          const word *B, unsigned int N)\n{\n    if (N==4)\n    {\n        LowLevel::Multiply4(T, A, B);\n        memcpy(R, T+4, 4*WORD_SIZE);\n    }\n    else if (N==2)\n    {\n        LowLevel::Multiply2(T, A, B);\n        memcpy(R, T+2, 2*WORD_SIZE);\n    }\n    else\n    {\n        const unsigned int N2 = N/2;\n        int carry;\n\n        int aComp = Compare(A0, A1, N2);\n        int bComp = Compare(B0, B1, N2);\n\n        switch (2*aComp + aComp + bComp)\n        {\n        case -4:\n            LowLevel::Subtract(R0, A1, A0, N2);\n            LowLevel::Subtract(R1, B0, B1, N2);\n            RecursiveMultiply(T0, T2, R0, R1, N2);\n            LowLevel::Subtract(T1, T1, R0, N2);\n            carry = -1;\n            break;\n        case -2:\n            LowLevel::Subtract(R0, A1, A0, N2);\n            LowLevel::Subtract(R1, B0, B1, N2);\n            RecursiveMultiply(T0, T2, R0, R1, N2);\n            carry = 0;\n            break;\n        case 2:\n            LowLevel::Subtract(R0, A0, A1, N2);\n            LowLevel::Subtract(R1, B1, B0, N2);\n            RecursiveMultiply(T0, T2, R0, R1, N2);\n            carry = 0;\n            break;\n        case 4:\n            LowLevel::Subtract(R0, A1, A0, N2);\n            LowLevel::Subtract(R1, B0, B1, N2);\n            RecursiveMultiply(T0, T2, R0, R1, N2);\n            LowLevel::Subtract(T1, T1, R1, N2);\n            carry = -1;\n            break;\n        default:\n            SetWords(T0, 0, N);\n            carry = 0;\n        }\n\n        RecursiveMultiply(T2, R0, A1, B1, N2);\n\n        // now T[01] holds (A1-A0)*(B0-B1), T[23] holds A1*B1\n\n        word c2 = LowLevel::Subtract(R0, L+N2, L, N2);\n        c2 += LowLevel::Subtract(R0, R0, T0, N2);\n        word t = (Compare(R0, T2, N2) == -1);\n\n        carry += t;\n        carry += Increment(R0, N2, c2+t);\n        carry += LowLevel::Add(R0, R0, T1, N2);\n        carry += LowLevel::Add(R0, R0, T3, N2);\n\n        CopyWords(R1, T3, N2);\n        Increment(R1, N2, carry);\n    }\n}\n\n\ninline word Add(word *C, const word *A, const word *B, unsigned int N)\n{\n    return LowLevel::Add(C, A, B, N);\n}\n\ninline word Subtract(word *C, const word *A, const word *B, unsigned int N)\n{\n    return LowLevel::Subtract(C, A, B, N);\n}\n\ninline void Multiply(word *R, word *T, const word *A, const word *B,\n                     unsigned int N)\n{\n    RecursiveMultiply(R, T, A, B, N);\n}\n\ninline void Square(word *R, word *T, const word *A, unsigned int N)\n{\n    RecursiveSquare(R, T, A, N);\n}\n\n\nvoid AsymmetricMultiply(word *R, word *T, const word *A, unsigned int NA,\n                        const word *B, unsigned int NB)\n{\n    if (NA == NB)\n    {\n        if (A == B)\n            Square(R, T, A, NA);\n        else\n            Multiply(R, T, A, B, NA);\n\n        return;\n    }\n\n    if (NA > NB)\n    {\n        STL::swap(A, B);\n        STL::swap(NA, NB);\n    }\n\n    if (NA==2 && !A[1])\n    {\n        switch (A[0])\n        {\n        case 0:\n            SetWords(R, 0, NB+2);\n            return;\n        case 1:\n            CopyWords(R, B, NB);\n            R[NB] = R[NB+1] = 0;\n            return;\n        default:\n            R[NB] = LinearMultiply(R, B, A[0], NB);\n            R[NB+1] = 0;\n            return;\n        }\n    }\n\n    Multiply(R, T, A, B, NA);\n    CopyWords(T+2*NA, R+NA, NA);\n\n    unsigned i;\n\n    for (i=2*NA; i<NB; i+=2*NA)\n        Multiply(T+NA+i, T, A, B+i, NA);\n    for (i=NA; i<NB; i+=2*NA)\n        Multiply(R+i, T, A, B+i, NA);\n\n    if (Add(R+NA, R+NA, T+2*NA, NB-NA))\n        Increment(R+NB, NA);\n}\n\n\nvoid PositiveMultiply(Integer& product, const Integer& a, const Integer& b)\n{\n    unsigned int aSize = RoundupSize(a.WordCount());\n    unsigned int bSize = RoundupSize(b.WordCount());\n\n    product.reg_.CleanNew(RoundupSize(aSize + bSize));\n    product.sign_ = Integer::POSITIVE;\n\n    AlignedWordBlock workspace(aSize + bSize);\n    AsymmetricMultiply(product.reg_.get_buffer(), workspace.get_buffer(),\n                       a.reg_.get_buffer(), aSize, b.reg_.get_buffer(), bSize);\n}\n\nvoid Multiply(Integer &product, const Integer &a, const Integer &b)\n{\n    PositiveMultiply(product, a, b);\n\n    if (a.NotNegative() != b.NotNegative())\n        product.Negate();\n}\n\n\nstatic inline unsigned int EvenWordCount(const word *X, unsigned int N)\n{\n    while (N && X[N-2]==0 && X[N-1]==0)\n        N-=2;\n    return N;\n}\n\n\nunsigned int AlmostInverse(word *R, word *T, const word *A, unsigned int NA,\n                           const word *M, unsigned int N)\n{\n    word *b = T;\n    word *c = T+N;\n    word *f = T+2*N;\n    word *g = T+3*N;\n    unsigned int bcLen=2, fgLen=EvenWordCount(M, N);\n    unsigned int k=0, s=0;\n\n    SetWords(T, 0, 3*N);\n    b[0]=1;\n    CopyWords(f, A, NA);\n    CopyWords(g, M, N);\n\n    while (1)\n    {\n        word t=f[0];\n        while (!t)\n        {\n            if (EvenWordCount(f, fgLen)==0)\n            {\n                SetWords(R, 0, N);\n                return 0;\n            }\n\n            ShiftWordsRightByWords(f, fgLen, 1);\n            if (c[bcLen-1]) bcLen+=2;\n            ShiftWordsLeftByWords(c, bcLen, 1);\n            k+=WORD_BITS;\n            t=f[0];\n        }\n\n        unsigned int i=0;\n        while (t%2 == 0)\n        {\n            t>>=1;\n            i++;\n        }\n        k+=i;\n\n        if (t==1 && f[1]==0 && EvenWordCount(f, fgLen)==2)\n        {\n            if (s%2==0)\n                CopyWords(R, b, N);\n            else\n                Subtract(R, M, b, N);\n            return k;\n        }\n\n        ShiftWordsRightByBits(f, fgLen, i);\n        t=ShiftWordsLeftByBits(c, bcLen, i);\n        if (t)\n        {\n            c[bcLen] = t;\n            bcLen+=2;\n        }\n\n        if (f[fgLen-2]==0 && g[fgLen-2]==0 && f[fgLen-1]==0 && g[fgLen-1]==0)\n            fgLen-=2;\n\n        if (Compare(f, g, fgLen)==-1)\n        {\n            STL::swap(f, g);\n            STL::swap(b, c);\n            s++;\n        }\n\n        Subtract(f, f, g, fgLen);\n\n        if (Add(b, b, c, bcLen))\n        {\n            b[bcLen] = 1;\n            bcLen+=2;\n        }\n    }\n}\n\n// R[N] - result = A/(2^k) mod M\n// A[N] - input\n// M[N] - modulus\n\nvoid DivideByPower2Mod(word *R, const word *A, unsigned int k, const word *M,\n                       unsigned int N)\n{\n    CopyWords(R, A, N);\n\n    while (k--)\n    {\n        if (R[0]%2==0)\n            ShiftWordsRightByBits(R, N, 1);\n        else\n        {\n            word carry = Add(R, R, M, N);\n            ShiftWordsRightByBits(R, N, 1);\n            R[N-1] += carry<<(WORD_BITS-1);\n        }\n    }\n}\n\n// R[N] - result = A*(2^k) mod M\n// A[N] - input\n// M[N] - modulus\n\nvoid MultiplyByPower2Mod(word *R, const word *A, unsigned int k, const word *M,\n                         unsigned int N)\n{\n    CopyWords(R, A, N);\n\n    while (k--)\n        if (ShiftWordsLeftByBits(R, N, 1) || Compare(R, M, N)>=0)\n            Subtract(R, R, M, N);\n}\n\n\n// ********** end of integer needs\n\n\nInteger::Integer()\n    : reg_(2), sign_(POSITIVE)\n{\n    reg_[0] = reg_[1] = 0;\n}\n\n\nInteger::Integer(const Integer& t)\n    : reg_(RoundupSize(t.WordCount())), sign_(t.sign_)\n{\n    CopyWords(reg_.get_buffer(), t.reg_.get_buffer(), reg_.size());\n}\n\n\nInteger::Integer(signed long value)\n    : reg_(2)\n{\n    if (value >= 0)\n        sign_ = POSITIVE;\n    else\n    {\n        sign_ = NEGATIVE;\n        value = -value;\n    }\n    reg_[0] = word(value);\n    reg_[1] = word(SafeRightShift<WORD_BITS, unsigned long>(value));\n}\n\n\nInteger::Integer(Sign s, word high, word low)\n    : reg_(2), sign_(s)\n{\n    reg_[0] = low;\n    reg_[1] = high;\n}\n\n\nInteger::Integer(word value, unsigned int length)\n    : reg_(RoundupSize(length)), sign_(POSITIVE)\n{\n    reg_[0] = value;\n    SetWords(reg_ + 1, 0, reg_.size() - 1);\n}\n\n\nInteger::Integer(const byte *encodedInteger, unsigned int byteCount,\n                 Signedness s)\n{\n    Decode(encodedInteger, byteCount, s);\n}\n\nclass BadBER {};\n\n// BER Decode Source\nInteger::Integer(Source& source)\n    : reg_(2), sign_(POSITIVE)\n{\n    Decode(source);\n}\n\nvoid Integer::Decode(Source& source)\n{\n    byte b = source.next();\n    if (b != INTEGER) {\n        source.SetError(INTEGER_E);\n        return;\n    }\n\n    word32 length = GetLength(source);\n    if (length == 0 || source.GetError().What()) return;\n\n    if ( (b = source.next()) == 0x00)\n        length--;\n    else\n        source.prev();\n\n    if (source.IsLeft(length) == false) return;\n \n    unsigned int words = (length + WORD_SIZE - 1) / WORD_SIZE;\n    words = RoundupSize(words);\n    if (words > reg_.size()) reg_.CleanNew(words);\n\n    for (int j = length; j > 0; j--) {\n        b = source.next();\n        reg_ [(j-1) / WORD_SIZE] |= (word)b << ((j-1) % WORD_SIZE) * 8;\n    }\n}\n\n\nvoid Integer::Decode(const byte* input, unsigned int inputLen, Signedness s)\n{\n    unsigned int idx(0);\n    byte b = 0; \n    if (inputLen>0)\n        b = input[idx];   // peek\n    sign_  = ((s==SIGNED) && (b & 0x80)) ? NEGATIVE : POSITIVE;\n\n    while (inputLen>0 && (sign_==POSITIVE ? b==0 : b==0xff))\n    {\n        idx++;   // skip\n        if (--inputLen>0)\n            b = input[idx];  // peek\n    }\n\n    reg_.CleanNew(RoundupSize(BytesToWords(inputLen)));\n\n    for (unsigned int i=inputLen; i > 0; i--)\n    {\n        b = input[idx++];\n        reg_[(i-1)/WORD_SIZE] |= (word)b << ((i-1)%WORD_SIZE)*8;\n    }\n\n    if (sign_ == NEGATIVE)\n    {\n        for (unsigned i=inputLen; i<reg_.size()*WORD_SIZE; i++)\n            reg_[i/WORD_SIZE] |= (word)0xff << (i%WORD_SIZE)*8;\n        TwosComplement(reg_.get_buffer(), reg_.size());\n    }\n}\n\n\nunsigned int Integer::Encode(byte* output, unsigned int outputLen,\n                       Signedness signedness) const\n{\n    unsigned int idx(0);\n    if (signedness == UNSIGNED || NotNegative())\n    {\n        for (unsigned int i=outputLen; i > 0; i--)\n            output[idx++] = GetByte(i-1);\n    }\n    else\n    {\n        // take two's complement of *this\n        Integer temp = Integer::Power2(8*max(ByteCount(), outputLen)) + *this;\n        for (unsigned i=0; i<outputLen; i++)\n            output[idx++] = temp.GetByte(outputLen-i-1);\n    }\n    return outputLen;\n}\n\n\nstatic Integer* zero = 0;\n\nconst Integer &Integer::Zero()\n{\n    if (!zero)\n        zero = NEW_TC Integer;\n    return *zero;\n}\n\n\nstatic Integer* one = 0;\n\nconst Integer &Integer::One()\n{\n    if (!one)\n        one = NEW_TC Integer(1,2);\n    return *one;\n}\n\n\n// Clean up static singleton holders, not a leak, but helpful to have gone\n// when checking for leaks\nvoid CleanUp()\n{\n    tcDelete(one);\n    tcDelete(zero);\n\n    // In case user calls more than once, prevent seg fault\n    one  = 0;\n    zero = 0;\n}\n\nInteger::Integer(RandomNumberGenerator& rng, const Integer& min,\n                 const Integer& max)\n{\n    Randomize(rng, min, max);\n}\n\n\nvoid Integer::Randomize(RandomNumberGenerator& rng, unsigned int nbits)\n{\n    const unsigned int nbytes = nbits/8 + 1;\n    ByteBlock buf(nbytes);\n    rng.GenerateBlock(buf.get_buffer(), nbytes);\n    if (nbytes)\n        buf[0] = (byte)Crop(buf[0], nbits % 8);\n    Decode(buf.get_buffer(), nbytes, UNSIGNED);\n}\n\nvoid Integer::Randomize(RandomNumberGenerator& rng, const Integer& min,\n                        const Integer& max)\n{\n    Integer range = max - min;\n    const unsigned int nbits = range.BitCount();\n\n    do\n    {\n        Randomize(rng, nbits);\n    }\n    while (*this > range);\n\n    *this += min;\n}\n\n\nInteger Integer::Power2(unsigned int e)\n{\n    Integer r((word)0, BitsToWords(e + 1));\n    r.SetBit(e);\n    return r;\n}\n\n\nvoid Integer::SetBit(unsigned int n, bool value)\n{\n    if (value)\n    {\n        reg_.CleanGrow(RoundupSize(BitsToWords(n + 1)));\n        reg_[n / WORD_BITS] |= (word(1) << (n % WORD_BITS));\n    }\n    else\n    {\n        if (n / WORD_BITS < reg_.size())\n            reg_[n / WORD_BITS] &= ~(word(1) << (n % WORD_BITS));\n    }\n}\n\n\nvoid Integer::SetByte(unsigned int n, byte value)\n{\n    reg_.CleanGrow(RoundupSize(BytesToWords(n+1)));\n    reg_[n/WORD_SIZE] &= ~(word(0xff) << 8*(n%WORD_SIZE));\n    reg_[n/WORD_SIZE] |= (word(value) << 8*(n%WORD_SIZE));\n}\n\n\nvoid Integer::Negate()\n{\n    if (!!(*this))\t// don't flip sign if *this==0\n        sign_ = Sign(1 - sign_);\n}\n\n\nbool Integer::operator!() const\n{\n    return IsNegative() ? false : (reg_[0]==0 && WordCount()==0);\n}\n\n\nInteger& Integer::operator=(const Integer& t)\n{\n    if (this != &t)\n    {\n        reg_.New(RoundupSize(t.WordCount()));\n        CopyWords(reg_.get_buffer(), t.reg_.get_buffer(), reg_.size());\n        sign_ = t.sign_;\n    }\n    return *this;\n}\n\n\nInteger& Integer::operator+=(const Integer& t)\n{\n    reg_.CleanGrow(t.reg_.size());\n    if (NotNegative())\n    {\n        if (t.NotNegative())\n            PositiveAdd(*this, *this, t);\n        else\n            PositiveSubtract(*this, *this, t);\n    }\n    else\n    {\n        if (t.NotNegative())\n            PositiveSubtract(*this, t, *this);\n        else\n        {\n            PositiveAdd(*this, *this, t);\n            sign_ = Integer::NEGATIVE;\n        }\n    }\n    return *this;\n}\n\n\nInteger Integer::operator-() const\n{\n    Integer result(*this);\n    result.Negate();\n    return result;\n}\n\n\nInteger& Integer::operator-=(const Integer& t)\n{\n    reg_.CleanGrow(t.reg_.size());\n    if (NotNegative())\n    {\n        if (t.NotNegative())\n            PositiveSubtract(*this, *this, t);\n        else\n            PositiveAdd(*this, *this, t);\n    }\n    else\n    {\n        if (t.NotNegative())\n        {\n            PositiveAdd(*this, *this, t);\n            sign_ = Integer::NEGATIVE;\n        }\n        else\n            PositiveSubtract(*this, t, *this);\n    }\n    return *this;\n}\n\n\nInteger& Integer::operator++()\n{\n    if (NotNegative())\n    {\n        if (Increment(reg_.get_buffer(), reg_.size()))\n        {\n            reg_.CleanGrow(2*reg_.size());\n            reg_[reg_.size()/2]=1;\n        }\n    }\n    else\n    {\n        word borrow = Decrement(reg_.get_buffer(), reg_.size());\n        (void)borrow;           // shut up compiler\n        if (WordCount()==0)\n            *this = Zero();\n    }\n    return *this;\n}\n\nInteger& Integer::operator--()\n{\n    if (IsNegative())\n    {\n        if (Increment(reg_.get_buffer(), reg_.size()))\n        {\n            reg_.CleanGrow(2*reg_.size());\n            reg_[reg_.size()/2]=1;\n        }\n    }\n    else\n    {\n        if (Decrement(reg_.get_buffer(), reg_.size()))\n            *this = -One();\n    }\n    return *this;\n}\n\n\nInteger& Integer::operator<<=(unsigned int n)\n{\n    const unsigned int wordCount = WordCount();\n    const unsigned int shiftWords = n / WORD_BITS;\n    const unsigned int shiftBits = n % WORD_BITS;\n\n    reg_.CleanGrow(RoundupSize(wordCount+BitsToWords(n)));\n    ShiftWordsLeftByWords(reg_.get_buffer(), wordCount + shiftWords,\n                          shiftWords);\n    ShiftWordsLeftByBits(reg_+shiftWords, wordCount+BitsToWords(shiftBits),\n                         shiftBits);\n    return *this;\n}\n\nInteger& Integer::operator>>=(unsigned int n)\n{\n    const unsigned int wordCount = WordCount();\n    const unsigned int shiftWords = n / WORD_BITS;\n    const unsigned int shiftBits = n % WORD_BITS;\n\n    ShiftWordsRightByWords(reg_.get_buffer(), wordCount, shiftWords);\n    if (wordCount > shiftWords)\n        ShiftWordsRightByBits(reg_.get_buffer(), wordCount-shiftWords,\n                              shiftBits);\n    if (IsNegative() && WordCount()==0)   // avoid -0\n        *this = Zero();\n    return *this;\n}\n\n\nvoid PositiveAdd(Integer& sum, const Integer& a, const Integer& b)\n{\n    word carry;\n    if (a.reg_.size() == b.reg_.size())\n        carry = Add(sum.reg_.get_buffer(), a.reg_.get_buffer(),\n                    b.reg_.get_buffer(), a.reg_.size());\n    else if (a.reg_.size() > b.reg_.size())\n    {\n        carry = Add(sum.reg_.get_buffer(), a.reg_.get_buffer(),\n                    b.reg_.get_buffer(), b.reg_.size());\n        CopyWords(sum.reg_+b.reg_.size(), a.reg_+b.reg_.size(),\n                  a.reg_.size()-b.reg_.size());\n        carry = Increment(sum.reg_+b.reg_.size(), a.reg_.size()-b.reg_.size(),\n                          carry);\n    }\n    else\n    {\n        carry = Add(sum.reg_.get_buffer(), a.reg_.get_buffer(),\n                    b.reg_.get_buffer(), a.reg_.size());\n        CopyWords(sum.reg_+a.reg_.size(), b.reg_+a.reg_.size(),\n                  b.reg_.size()-a.reg_.size());\n        carry = Increment(sum.reg_+a.reg_.size(), b.reg_.size()-a.reg_.size(),\n                          carry);\n    }\n\n    if (carry)\n    {\n        sum.reg_.CleanGrow(2*sum.reg_.size());\n        sum.reg_[sum.reg_.size()/2] = 1;\n    }\n    sum.sign_ = Integer::POSITIVE;\n}\n\nvoid PositiveSubtract(Integer &diff, const Integer &a, const Integer& b)\n{\n    unsigned aSize = a.WordCount();\n    aSize += aSize%2;\n    unsigned bSize = b.WordCount();\n    bSize += bSize%2;\n\n    if (aSize == bSize)\n    {\n        if (Compare(a.reg_.get_buffer(), b.reg_.get_buffer(), aSize) >= 0)\n        {\n            Subtract(diff.reg_.get_buffer(), a.reg_.get_buffer(),\n                     b.reg_.get_buffer(), aSize);\n            diff.sign_ = Integer::POSITIVE;\n        }\n        else\n        {\n            Subtract(diff.reg_.get_buffer(), b.reg_.get_buffer(),\n                     a.reg_.get_buffer(), aSize);\n            diff.sign_ = Integer::NEGATIVE;\n        }\n    }\n    else if (aSize > bSize)\n    {\n        word borrow = Subtract(diff.reg_.get_buffer(), a.reg_.get_buffer(),\n                               b.reg_.get_buffer(), bSize);\n        CopyWords(diff.reg_+bSize, a.reg_+bSize, aSize-bSize);\n        borrow = Decrement(diff.reg_+bSize, aSize-bSize, borrow);\n        diff.sign_ = Integer::POSITIVE;\n    }\n    else\n    {\n        word borrow = Subtract(diff.reg_.get_buffer(), b.reg_.get_buffer(),\n                               a.reg_.get_buffer(), aSize);\n        CopyWords(diff.reg_+aSize, b.reg_+aSize, bSize-aSize);\n        borrow = Decrement(diff.reg_+aSize, bSize-aSize, borrow);\n        diff.sign_ = Integer::NEGATIVE;\n    }\n}\n\n\nunsigned int Integer::MinEncodedSize(Signedness signedness) const\n{\n    unsigned int outputLen = max(1U, ByteCount());\n    if (signedness == UNSIGNED)\n        return outputLen;\n    if (NotNegative() && (GetByte(outputLen-1) & 0x80))\n        outputLen++;\n    if (IsNegative() && *this < -Power2(outputLen*8-1))\n        outputLen++;\n    return outputLen;\n}\n\n\nint Integer::Compare(const Integer& t) const\n{\n    if (NotNegative())\n    {\n        if (t.NotNegative())\n            return PositiveCompare(t);\n        else\n            return 1;\n    }\n    else\n    {\n        if (t.NotNegative())\n            return -1;\n        else\n            return -PositiveCompare(t);\n    }\n}\n\n\nint Integer::PositiveCompare(const Integer& t) const\n{\n    unsigned size = WordCount(), tSize = t.WordCount();\n\n    if (size == tSize)\n        return TaoCrypt::Compare(reg_.get_buffer(), t.reg_.get_buffer(), size);\n    else\n        return size > tSize ? 1 : -1;\n}\n\n\nbool Integer::GetBit(unsigned int n) const\n{\n    if (n/WORD_BITS >= reg_.size())\n        return 0;\n    else\n        return bool((reg_[n/WORD_BITS] >> (n % WORD_BITS)) & 1);\n}\n\n\nunsigned long Integer::GetBits(unsigned int i, unsigned int n) const\n{\n    unsigned long v = 0;\n    for (unsigned int j=0; j<n; j++)\n        v |= GetBit(i+j) << j;\n    return v;\n}\n\n\nbyte Integer::GetByte(unsigned int n) const\n{\n    if (n/WORD_SIZE >= reg_.size())\n        return 0;\n    else\n        return byte(reg_[n/WORD_SIZE] >> ((n%WORD_SIZE)*8));\n}\n\n\nunsigned int Integer::BitCount() const\n{\n    unsigned wordCount = WordCount();\n    if (wordCount)\n        return (wordCount-1)*WORD_BITS + BitPrecision(reg_[wordCount-1]);\n    else\n        return 0;\n}\n\n\nunsigned int Integer::ByteCount() const\n{\n    unsigned wordCount = WordCount();\n    if (wordCount)\n        return (wordCount-1)*WORD_SIZE + BytePrecision(reg_[wordCount-1]);\n    else\n        return 0;\n}\n\n\nunsigned int Integer::WordCount() const\n{\n    return CountWords(reg_.get_buffer(), reg_.size());\n}\n\n\nbool Integer::IsConvertableToLong() const\n{\n    if (ByteCount() > sizeof(long))\n        return false;\n\n    unsigned long value = reg_[0];\n    value += SafeLeftShift<WORD_BITS, unsigned long>(reg_[1]);\n\n    if (sign_ == POSITIVE)\n        return (signed long)value >= 0;\n    else\n        return -(signed long)value < 0;\n}\n\n\nsigned long Integer::ConvertToLong() const\n{\n    unsigned long value = reg_[0];\n    value += SafeLeftShift<WORD_BITS, unsigned long>(reg_[1]);\n    return sign_ == POSITIVE ? value : -(signed long)value;\n}\n\n\nvoid Integer::Swap(Integer& a)\n{\n    reg_.Swap(a.reg_);\n    STL::swap(sign_, a.sign_);\n}\n\n\nInteger Integer::Plus(const Integer& b) const\n{\n    Integer sum((word)0, max(reg_.size(), b.reg_.size()));\n    if (NotNegative())\n    {\n        if (b.NotNegative())\n            PositiveAdd(sum, *this, b);\n        else\n            PositiveSubtract(sum, *this, b);\n    }\n    else\n    {\n        if (b.NotNegative())\n            PositiveSubtract(sum, b, *this);\n        else\n        {\n            PositiveAdd(sum, *this, b);\n            sum.sign_ = Integer::NEGATIVE;\n        }\n    }\n    return sum;\n}\n\n\nInteger Integer::Minus(const Integer& b) const\n{\n    Integer diff((word)0, max(reg_.size(), b.reg_.size()));\n    if (NotNegative())\n    {\n        if (b.NotNegative())\n            PositiveSubtract(diff, *this, b);\n        else\n            PositiveAdd(diff, *this, b);\n    }\n    else\n    {\n        if (b.NotNegative())\n        {\n            PositiveAdd(diff, *this, b);\n            diff.sign_ = Integer::NEGATIVE;\n        }\n        else\n            PositiveSubtract(diff, b, *this);\n    }\n    return diff;\n}\n\n\nInteger Integer::Times(const Integer &b) const\n{\n    Integer product;\n    Multiply(product, *this, b);\n    return product;\n}\n\n\n#undef A0\n#undef A1\n#undef B0\n#undef B1\n\n#undef T0\n#undef T1\n#undef T2\n#undef T3\n\n#undef R0\n#undef R1\n#undef R2\n#undef R3\n\n\nstatic inline void AtomicDivide(word *Q, const word *A, const word *B)\n{\n    word T[4];\n    DWord q = DivideFourWordsByTwo<word, DWord>(T, DWord(A[0], A[1]),\n                                         DWord(A[2], A[3]), DWord(B[0], B[1]));\n    Q[0] = q.GetLowHalf();\n    Q[1] = q.GetHighHalf();\n\n#ifndef NDEBUG\n    if (B[0] || B[1])\n    {\n        // multiply quotient and divisor and add remainder, make sure it \n        // equals dividend\n        word P[4];\n        Portable::Multiply2(P, Q, B);\n        Add(P, P, T, 4);\n    }\n#endif\n}\n\n\n// for use by Divide(), corrects the underestimated quotient {Q1,Q0}\nstatic void CorrectQuotientEstimate(word *R, word *T, word *Q, const word *B,\n                                    unsigned int N)\n{\n    if (Q[1])\n    {\n        T[N] = T[N+1] = 0;\n        unsigned i;\n        for (i=0; i<N; i+=4)\n            LowLevel::Multiply2(T+i, Q, B+i);\n        for (i=2; i<N; i+=4)\n            if (LowLevel::Multiply2Add(T+i, Q, B+i))\n                T[i+5] += (++T[i+4]==0);\n    }\n    else\n    {\n        T[N] = LinearMultiply(T, B, Q[0], N);\n        T[N+1] = 0;\n    }\n\n    word borrow = Subtract(R, R, T, N+2);\n    (void)borrow;       // shut up compiler\n\n    while (R[N] || Compare(R, B, N) >= 0)\n    {\n        R[N] -= Subtract(R, R, B, N);\n        Q[1] += (++Q[0]==0);\n    }\n}\n\n// R[NB] -------- remainder = A%B\n// Q[NA-NB+2] --- quotient\t= A/B\n// T[NA+2*NB+4] - temp work space\n// A[NA] -------- dividend\n// B[NB] -------- divisor\n\n\nvoid Divide(word* R, word* Q, word* T, const word* A, unsigned int NA,\n            const word* B, unsigned int NB)\n{\n    // set up temporary work space\n    word *const TA=T;\n    word *const TB=T+NA+2;\n    word *const TP=T+NA+2+NB;\n\n    // copy B into TB and normalize it so that TB has highest bit set to 1\n    unsigned shiftWords = (B[NB-1]==0);\n    TB[0] = TB[NB-1] = 0;\n    CopyWords(TB+shiftWords, B, NB-shiftWords);\n    unsigned shiftBits = WORD_BITS - BitPrecision(TB[NB-1]);\n    ShiftWordsLeftByBits(TB, NB, shiftBits);\n\n    // copy A into TA and normalize it\n    TA[0] = TA[NA] = TA[NA+1] = 0;\n    CopyWords(TA+shiftWords, A, NA);\n    ShiftWordsLeftByBits(TA, NA+2, shiftBits);\n\n    if (TA[NA+1]==0 && TA[NA] <= 1)\n    {\n        Q[NA-NB+1] = Q[NA-NB] = 0;\n        while (TA[NA] || Compare(TA+NA-NB, TB, NB) >= 0)\n        {\n            TA[NA] -= Subtract(TA+NA-NB, TA+NA-NB, TB, NB);\n            ++Q[NA-NB];\n        }\n    }\n    else\n    {\n        NA+=2;\n    }\n\n    word BT[2];\n    BT[0] = TB[NB-2] + 1;\n    BT[1] = TB[NB-1] + (BT[0]==0);\n\n    // start reducing TA mod TB, 2 words at a time\n    for (unsigned i=NA-2; i>=NB; i-=2)\n    {\n        AtomicDivide(Q+i-NB, TA+i-2, BT);\n        CorrectQuotientEstimate(TA+i-NB, TP, Q+i-NB, TB, NB);\n    }\n\n    // copy TA into R, and denormalize it\n    CopyWords(R, TA+shiftWords, NB);\n    ShiftWordsRightByBits(R, NB, shiftBits);\n}\n\n\nvoid PositiveDivide(Integer& remainder, Integer& quotient,\n                   const Integer& a, const Integer& b)\n{\n    unsigned aSize = a.WordCount();\n    unsigned bSize = b.WordCount();\n\n    if (a.PositiveCompare(b) == -1)\n    {\n        remainder = a;\n        remainder.sign_ = Integer::POSITIVE;\n        quotient = Integer::Zero();\n        return;\n    }\n\n    aSize += aSize%2;\t// round up to next even number\n    bSize += bSize%2;\n\n    remainder.reg_.CleanNew(RoundupSize(bSize));\n    remainder.sign_ = Integer::POSITIVE;\n    quotient.reg_.CleanNew(RoundupSize(aSize-bSize+2));\n    quotient.sign_ = Integer::POSITIVE;\n\n    AlignedWordBlock T(aSize+2*bSize+4);\n    Divide(remainder.reg_.get_buffer(), quotient.reg_.get_buffer(),\n           T.get_buffer(), a.reg_.get_buffer(), aSize, b.reg_.get_buffer(),\n           bSize);\n}\n\nvoid Integer::Divide(Integer &remainder, Integer &quotient,\n                     const Integer &dividend, const Integer &divisor)\n{\n    PositiveDivide(remainder, quotient, dividend, divisor);\n\n    if (dividend.IsNegative())\n    {\n        quotient.Negate();\n        if (remainder.NotZero())\n        {\n            --quotient;\n            remainder = divisor.AbsoluteValue() - remainder;\n        }\n    }\n\n    if (divisor.IsNegative())\n        quotient.Negate();\n}\n\nvoid Integer::DivideByPowerOf2(Integer &r, Integer &q, const Integer &a,\n                               unsigned int n)\n{\n    q = a;\n    q >>= n;\n\n    const unsigned int wordCount = BitsToWords(n);\n    if (wordCount <= a.WordCount())\n    {\n        r.reg_.resize(RoundupSize(wordCount));\n        CopyWords(r.reg_.get_buffer(), a.reg_.get_buffer(), wordCount);\n        SetWords(r.reg_+wordCount, 0, r.reg_.size()-wordCount);\n        if (n % WORD_BITS != 0)\n          r.reg_[wordCount-1] %= (word(1) << (n % WORD_BITS));\n    }\n    else\n    {\n        r.reg_.resize(RoundupSize(a.WordCount()));\n        CopyWords(r.reg_.get_buffer(), a.reg_.get_buffer(), r.reg_.size());\n    }\n    r.sign_ = POSITIVE;\n\n    if (a.IsNegative() && r.NotZero())\n    {\n        --q;\n        r = Power2(n) - r;\n    }\n}\n\nInteger Integer::DividedBy(const Integer &b) const\n{\n    Integer remainder, quotient;\n    Integer::Divide(remainder, quotient, *this, b);\n    return quotient;\n}\n\nInteger Integer::Modulo(const Integer &b) const\n{\n    Integer remainder, quotient;\n    Integer::Divide(remainder, quotient, *this, b);\n    return remainder;\n}\n\nvoid Integer::Divide(word &remainder, Integer &quotient,\n                     const Integer &dividend, word divisor)\n{\n    if ((divisor & (divisor-1)) == 0)\t// divisor is a power of 2\n    {\n        quotient = dividend >> (BitPrecision(divisor)-1);\n        remainder = dividend.reg_[0] & (divisor-1);\n        return;\n    }\n\n    unsigned int i = dividend.WordCount();\n    quotient.reg_.CleanNew(RoundupSize(i));\n    remainder = 0;\n    while (i--)\n    {\n        quotient.reg_[i] = DWord(dividend.reg_[i], remainder) / divisor;\n        remainder = DWord(dividend.reg_[i], remainder) % divisor;\n    }\n\n    if (dividend.NotNegative())\n        quotient.sign_ = POSITIVE;\n    else\n    {\n        quotient.sign_ = NEGATIVE;\n        if (remainder)\n        {\n            --quotient;\n            remainder = divisor - remainder;\n        }\n    }\n}\n\nInteger Integer::DividedBy(word b) const\n{\n    word remainder;\n    Integer quotient;\n    Integer::Divide(remainder, quotient, *this, b);\n    return quotient;\n}\n\nword Integer::Modulo(word divisor) const\n{\n    word remainder;\n\n    if ((divisor & (divisor-1)) == 0)\t// divisor is a power of 2\n        remainder = reg_[0] & (divisor-1);\n    else\n    {\n        unsigned int i = WordCount();\n\n        if (divisor <= 5)\n        {\n            DWord sum(0, 0);\n            while (i--)\n                sum += reg_[i];\n            remainder = sum % divisor;\n        }\n        else\n        {\n            remainder = 0;\n            while (i--)\n                remainder = DWord(reg_[i], remainder) % divisor;\n        }\n    }\n\n    if (IsNegative() && remainder)\n        remainder = divisor - remainder;\n\n    return remainder;\n}\n\n\nInteger Integer::AbsoluteValue() const\n{\n    Integer result(*this);\n    result.sign_ = POSITIVE;\n    return result;\n}\n\n\nInteger Integer::SquareRoot() const\n{\n    if (!IsPositive())\n        return Zero();\n\n    // overestimate square root\n    Integer x, y = Power2((BitCount()+1)/2);\n\n    do\n    {\n        x = y;\n        y = (x + *this/x) >> 1;\n    } while (y<x);\n\n    return x;\n}\n\nbool Integer::IsSquare() const\n{\n    Integer r = SquareRoot();\n    return *this == r.Squared();\n}\n\nbool Integer::IsUnit() const\n{\n    return (WordCount() == 1) && (reg_[0] == 1);\n}\n\nInteger Integer::MultiplicativeInverse() const\n{\n    return IsUnit() ? *this : Zero();\n}\n\nInteger a_times_b_mod_c(const Integer &x, const Integer& y, const Integer& m)\n{\n    return x*y%m;\n}\n\nInteger a_exp_b_mod_c(const Integer &x, const Integer& e, const Integer& m)\n{\n    ModularArithmetic mr(m);\n    return mr.Exponentiate(x, e);\n}\n\nInteger Integer::Gcd(const Integer &a, const Integer &b)\n{\n    return EuclideanDomainOf().Gcd(a, b);\n}\n\nInteger Integer::InverseMod(const Integer &m) const\n{\n    if (IsNegative() || *this>=m)\n        return (*this%m).InverseMod(m);\n\n    if (m.IsEven())\n    {\n        if (!m || IsEven())\n            return Zero();\t// no inverse\n        if (*this == One())\n            return One();\n\n        Integer u = m.InverseMod(*this);\n        return !u ? Zero() : (m*(*this-u)+1)/(*this);\n    }\n\n    AlignedWordBlock T(m.reg_.size() * 4);\n    Integer r((word)0, m.reg_.size());\n    unsigned k = AlmostInverse(r.reg_.get_buffer(), T.get_buffer(),\n                               reg_.get_buffer(), reg_.size(),\n                               m.reg_.get_buffer(), m.reg_.size());\n    DivideByPower2Mod(r.reg_.get_buffer(), r.reg_.get_buffer(), k,\n                      m.reg_.get_buffer(), m.reg_.size());\n    return r;\n}\n\nword Integer::InverseMod(const word mod) const\n{\n    word g0 = mod, g1 = *this % mod;\n    word v0 = 0, v1 = 1;\n    word y;\n\n    while (g1)\n    {\n        if (g1 == 1)\n            return v1;\n        y = g0 / g1;\n        g0 = g0 % g1;\n        v0 += y * v1;\n\n        if (!g0)\n            break;\n        if (g0 == 1)\n            return mod-v0;\n        y = g1 / g0;\n        g1 = g1 % g0;\n        v1 += y * v0;\n    }\n    return 0;\n}\n\n// ********* ModArith stuff\n\nconst Integer& ModularArithmetic::Half(const Integer &a) const\n{\n    if (a.reg_.size()==modulus.reg_.size())\n    {\n        TaoCrypt::DivideByPower2Mod(result.reg_.begin(), a.reg_.begin(), 1,\n                                    modulus.reg_.begin(), a.reg_.size());\n        return result;\n    }\n    else\n        return result1 = (a.IsEven() ? (a >> 1) : ((a+modulus) >> 1));\n}\n\nconst Integer& ModularArithmetic::Add(const Integer &a, const Integer &b) const\n{\n    if (a.reg_.size()==modulus.reg_.size() && \n        b.reg_.size()==modulus.reg_.size())\n    {\n        if (TaoCrypt::Add(result.reg_.begin(), a.reg_.begin(), b.reg_.begin(),\n                          a.reg_.size())\n            || Compare(result.reg_.get_buffer(), modulus.reg_.get_buffer(),\n                       a.reg_.size()) >= 0)\n        {\n            TaoCrypt::Subtract(result.reg_.begin(), result.reg_.begin(),\n                               modulus.reg_.begin(), a.reg_.size());\n        }\n        return result;\n    }\n    else\n    {\n        result1 = a+b;\n        if (result1 >= modulus)\n            result1 -= modulus;\n        return result1;\n    }\n}\n\nInteger& ModularArithmetic::Accumulate(Integer &a, const Integer &b) const\n{\n    if (a.reg_.size()==modulus.reg_.size() && \n        b.reg_.size()==modulus.reg_.size())\n    {\n        if (TaoCrypt::Add(a.reg_.get_buffer(), a.reg_.get_buffer(),\n                          b.reg_.get_buffer(), a.reg_.size())\n            || Compare(a.reg_.get_buffer(), modulus.reg_.get_buffer(),\n                       a.reg_.size()) >= 0)\n        {\n            TaoCrypt::Subtract(a.reg_.get_buffer(), a.reg_.get_buffer(),\n                               modulus.reg_.get_buffer(), a.reg_.size());\n        }\n    }\n    else\n    {\n        a+=b;\n        if (a>=modulus)\n            a-=modulus;\n    }\n\n    return a;\n}\n\nconst Integer& ModularArithmetic::Subtract(const Integer &a,\n                                           const Integer &b) const\n{\n    if (a.reg_.size()==modulus.reg_.size() && \n        b.reg_.size()==modulus.reg_.size())\n    {\n        if (TaoCrypt::Subtract(result.reg_.begin(), a.reg_.begin(),\n                               b.reg_.begin(), a.reg_.size()))\n            TaoCrypt::Add(result.reg_.begin(), result.reg_.begin(),\n                          modulus.reg_.begin(), a.reg_.size());\n        return result;\n    }\n    else\n    {\n        result1 = a-b;\n        if (result1.IsNegative())\n            result1 += modulus;\n        return result1;\n    }\n}\n\nInteger& ModularArithmetic::Reduce(Integer &a, const Integer &b) const\n{\n    if (a.reg_.size()==modulus.reg_.size() && \n        b.reg_.size()==modulus.reg_.size())\n    {\n        if (TaoCrypt::Subtract(a.reg_.get_buffer(), a.reg_.get_buffer(),\n                               b.reg_.get_buffer(), a.reg_.size()))\n            TaoCrypt::Add(a.reg_.get_buffer(), a.reg_.get_buffer(),\n                          modulus.reg_.get_buffer(), a.reg_.size());\n    }\n    else\n    {\n        a-=b;\n        if (a.IsNegative())\n            a+=modulus;\n    }\n\n    return a;\n}\n\nconst Integer& ModularArithmetic::Inverse(const Integer &a) const\n{\n    if (!a)\n        return a;\n\n    CopyWords(result.reg_.begin(), modulus.reg_.begin(), modulus.reg_.size());\n    if (TaoCrypt::Subtract(result.reg_.begin(), result.reg_.begin(),\n                           a.reg_.begin(), a.reg_.size()))\n        Decrement(result.reg_.begin()+a.reg_.size(), 1,\n                  modulus.reg_.size()-a.reg_.size());\n\n    return result;\n}\n\nInteger ModularArithmetic::CascadeExponentiate(const Integer &x,\n                  const Integer &e1, const Integer &y, const Integer &e2) const\n{\n    if (modulus.IsOdd())\n    {\n        MontgomeryRepresentation dr(modulus);\n        return dr.ConvertOut(dr.CascadeExponentiate(dr.ConvertIn(x), e1,\n                                                    dr.ConvertIn(y), e2));\n    }\n    else\n        return AbstractRing::CascadeExponentiate(x, e1, y, e2);\n}\n\nvoid ModularArithmetic::SimultaneousExponentiate(Integer *results,\n        const Integer &base, const Integer *exponents,\n        unsigned int exponentsCount) const\n{\n    if (modulus.IsOdd())\n    {\n        MontgomeryRepresentation dr(modulus);\n        dr.SimultaneousExponentiate(results, dr.ConvertIn(base), exponents,\n                                    exponentsCount);\n        for (unsigned int i=0; i<exponentsCount; i++)\n            results[i] = dr.ConvertOut(results[i]);\n    }\n    else\n        AbstractRing::SimultaneousExponentiate(results, base,\n                                                    exponents, exponentsCount);\n}\n\n\n// ********************************************************\n\n#define A0      A\n#define A1      (A+N2)\n#define B0      B\n#define B1      (B+N2)\n\n#define T0      T\n#define T1      (T+N2)\n#define T2      (T+N)\n#define T3      (T+N+N2)\n\n#define R0      R\n#define R1      (R+N2)\n#define R2      (R+N)\n#define R3      (R+N+N2)\n\n\ninline void MultiplyBottom(word *R, word *T, const word *A, const word *B,\n                           unsigned int N)\n{\n    RecursiveMultiplyBottom(R, T, A, B, N);\n}\n\ninline void MultiplyTop(word *R, word *T, const word *L, const word *A,\n                        const word *B, unsigned int N)\n{\n    RecursiveMultiplyTop(R, T, L, A, B, N);\n}\n\n\n// R[N] --- result = X/(2**(WORD_BITS*N)) mod M\n// T[3*N] - temporary work space\n// X[2*N] - number to be reduced\n// M[N] --- modulus\n// U[N] --- multiplicative inverse of M mod 2**(WORD_BITS*N)\n\nvoid MontgomeryReduce(word *R, word *T, const word *X, const word *M,\n                      const word *U, unsigned int N)\n{\n    MultiplyBottom(R, T, X, U, N);\n    MultiplyTop(T, T+N, X, R, M, N);\n    word borrow = Subtract(T, X+N, T, N);\n    // defend against timing attack by doing this Add even when not needed\n    word carry = Add(T+N, T, M, N);\n    (void)carry;            // shut up compiler\n    CopyWords(R, T + (borrow ? N : 0), N);\n}\n\n// R[N] ----- result = A inverse mod 2**(WORD_BITS*N)\n// T[3*N/2] - temporary work space\n// A[N] ----- an odd number as input\n\nvoid RecursiveInverseModPower2(word *R, word *T, const word *A, unsigned int N)\n{\n    if (N==2)\n    {\n        T[0] = AtomicInverseModPower2(A[0]);\n        T[1] = 0;\n        LowLevel::Multiply2Bottom(T+2, T, A);\n        TwosComplement(T+2, 2);\n        Increment(T+2, 2, 2);\n        LowLevel::Multiply2Bottom(R, T, T+2);\n    }\n    else\n    {\n        const unsigned int N2 = N/2;\n        RecursiveInverseModPower2(R0, T0, A0, N2);\n        T0[0] = 1;\n        SetWords(T0+1, 0, N2-1);\n        MultiplyTop(R1, T1, T0, R0, A0, N2);\n        MultiplyBottom(T0, T1, R0, A1, N2);\n        Add(T0, R1, T0, N2);\n        TwosComplement(T0, N2);\n        MultiplyBottom(R1, T1, R0, T0, N2);\n    }\n}\n\n\n#undef A0\n#undef A1\n#undef B0\n#undef B1\n\n#undef T0\n#undef T1\n#undef T2\n#undef T3\n\n#undef R0\n#undef R1\n#undef R2\n#undef R3\n\n\n// modulus must be odd\nMontgomeryRepresentation::MontgomeryRepresentation(const Integer &m)\n    : ModularArithmetic(m),\n      u((word)0, modulus.reg_.size()),\n      workspace(5*modulus.reg_.size())\n{\n    RecursiveInverseModPower2(u.reg_.get_buffer(), workspace.get_buffer(),\n                              modulus.reg_.get_buffer(), modulus.reg_.size());\n}\n\nconst Integer& MontgomeryRepresentation::Multiply(const Integer &a,\n                                                  const Integer &b) const\n{\n    word *const T = workspace.begin();\n    word *const R = result.reg_.begin();\n    const unsigned int N = modulus.reg_.size();\n\n    AsymmetricMultiply(T, T+2*N, a.reg_.get_buffer(), a.reg_.size(),\n                       b.reg_.get_buffer(), b.reg_.size());\n    SetWords(T+a.reg_.size()+b.reg_.size(),0, 2*N-a.reg_.size()-b.reg_.size());\n    MontgomeryReduce(R, T+2*N, T, modulus.reg_.get_buffer(),\n                     u.reg_.get_buffer(), N);\n    return result;\n}\n\nconst Integer& MontgomeryRepresentation::Square(const Integer &a) const\n{\n    word *const T = workspace.begin();\n    word *const R = result.reg_.begin();\n    const unsigned int N = modulus.reg_.size();\n\n    TaoCrypt::Square(T, T+2*N, a.reg_.get_buffer(), a.reg_.size());\n    SetWords(T+2*a.reg_.size(), 0, 2*N-2*a.reg_.size());\n    MontgomeryReduce(R, T+2*N, T, modulus.reg_.get_buffer(),\n                     u.reg_.get_buffer(), N);\n    return result;\n}\n\nInteger MontgomeryRepresentation::ConvertOut(const Integer &a) const\n{\n    word *const T = workspace.begin();\n    word *const R = result.reg_.begin();\n    const unsigned int N = modulus.reg_.size();\n\n    CopyWords(T, a.reg_.get_buffer(), a.reg_.size());\n    SetWords(T+a.reg_.size(), 0, 2*N-a.reg_.size());\n    MontgomeryReduce(R, T+2*N, T, modulus.reg_.get_buffer(),\n                     u.reg_.get_buffer(), N);\n    return result;\n}\n\nconst Integer& MontgomeryRepresentation::MultiplicativeInverse(\n                                                        const Integer &a) const\n{\n//  return (EuclideanMultiplicativeInverse(a, modulus)<<\n//      (2*WORD_BITS*modulus.reg_.size()))%modulus;\n    word *const T = workspace.begin();\n    word *const R = result.reg_.begin();\n    const unsigned int N = modulus.reg_.size();\n\n    CopyWords(T, a.reg_.get_buffer(), a.reg_.size());\n    SetWords(T+a.reg_.size(), 0, 2*N-a.reg_.size());\n    MontgomeryReduce(R, T+2*N, T, modulus.reg_.get_buffer(),\n                     u.reg_.get_buffer(), N);\n    unsigned k = AlmostInverse(R, T, R, N, modulus.reg_.get_buffer(), N);\n\n//  cout << \"k=\" << k << \" N*32=\" << 32*N << endl;\n\n    if (k>N*WORD_BITS)\n        DivideByPower2Mod(R, R, k-N*WORD_BITS, modulus.reg_.get_buffer(), N);\n    else\n        MultiplyByPower2Mod(R, R, N*WORD_BITS-k, modulus.reg_.get_buffer(), N);\n\n    return result;\n}\n\n\n//  mod Root stuff\nInteger ModularRoot(const Integer &a, const Integer &dp, const Integer &dq,\n                    const Integer &p, const Integer &q, const Integer &u)\n{\n    Integer p2 = ModularExponentiation((a % p), dp, p);\n    Integer q2 = ModularExponentiation((a % q), dq, q);\n    return CRT(p2, p, q2, q, u);\n}\n\nInteger CRT(const Integer &xp, const Integer &p, const Integer &xq,\n            const Integer &q, const Integer &u)\n{\n    // isn't operator overloading great?\n    return p * (u * (xq-xp) % q) + xp;\n}\n\n\n#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION\n#ifndef TAOCRYPT_NATIVE_DWORD_AVAILABLE\ntemplate hword DivideThreeWordsByTwo<hword, Word>(hword*, hword, hword, Word*);\n#endif\ntemplate word DivideThreeWordsByTwo<word, DWord>(word*, word, word, DWord*);\n#ifdef SSE2_INTRINSICS_AVAILABLE\ntemplate class AlignedAllocator<word>;\n#endif\n#endif\n\n\n} // namespace\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/make.bat",
    "content": "REM Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.\nREM \nREM This program is free software; you can redistribute it and/or modify\nREM it under the terms of the GNU General Public License as published by\nREM the Free Software Foundation; version 2 of the License.\nREM \nREM This program is distributed in the hope that it will be useful,\nREM but WITHOUT ANY WARRANTY; without even the implied warranty of\nREM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nREM GNU General Public License for more details.\nREM \nREM You should have received a copy of the GNU General Public License\nREM along with this program; if not, write to the Free Software\nREM Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\n\nREM quick and dirty build file for testing different MSDEVs\nsetlocal \n\nset myFLAGS= /I../include /I../mySTL /c /W3 /G6 /O2 \n\ncl %myFLAGS% aes.cpp\ncl %myFLAGS% aestables.cpp\ncl %myFLAGS% algebra.cpp\ncl %myFLAGS% arc4.cpp\n\ncl %myFLAGS% asn.cpp\ncl %myFLAGS% bftables.cpp\ncl %myFLAGS% blowfish.cpp\ncl %myFLAGS% coding.cpp\n\ncl %myFLAGS% des.cpp\ncl %myFLAGS% dh.cpp\ncl %myFLAGS% dsa.cpp\ncl %myFLAGS% file.cpp\n\ncl %myFLAGS% hash.cpp\ncl %myFLAGS% integer.cpp\ncl %myFLAGS% md2.cpp\ncl %myFLAGS% md4.cpp\ncl %myFLAGS% md5.cpp\n\ncl %myFLAGS% misc.cpp\ncl %myFLAGS% random.cpp\ncl %myFLAGS% ripemd.cpp\ncl %myFLAGS% rsa.cpp\n\ncl %myFLAGS% sha.cpp\ncl %myFLAGS% template_instnt.cpp\ncl %myFLAGS% tftables.cpp\ncl %myFLAGS% twofish.cpp\n\nlink.exe -lib /out:taocrypt.lib aes.obj aestables.obj algebra.obj arc4.obj asn.obj bftables.obj blowfish.obj coding.obj des.obj dh.obj dsa.obj file.obj hash.obj integer.obj md2.obj md4.obj md5.obj misc.obj random.obj ripemd.obj rsa.obj sha.obj template_instnt.obj tftables.obj twofish.obj\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/md2.cpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* based on Wei Dai's md2.cpp from CryptoPP */\n\n#include \"runtime.hpp\"\n#include \"md2.hpp\"\n#include <string.h>\n\nnamespace TaoCrypt {\n\n\nMD2::MD2()\n    : X_(X_SIZE), C_(BLOCK_SIZE), buffer_(BLOCK_SIZE)\n{\n    Init();\n}\n\nvoid MD2::Init()\n{\n    memset(X_.get_buffer(), 0, X_SIZE);\n    memset(C_.get_buffer(), 0, BLOCK_SIZE);\n    memset(buffer_.get_buffer(), 0, BLOCK_SIZE);\n    count_ = 0;\n}\n\n\nvoid MD2::Update(const byte* data, word32 len)\n{\n\n    static const byte S[256] = \n    {\n        41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6,\n        19, 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188,\n        76, 130, 202, 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24,\n        138, 23, 229, 18, 190, 78, 196, 214, 218, 158, 222, 73, 160, 251,\n        245, 142, 187, 47, 238, 122, 169, 104, 121, 145, 21, 178, 7, 63,\n        148, 194, 16, 137, 11, 34, 95, 33, 128, 127, 93, 154, 90, 144, 50,\n        39, 53, 62, 204, 231, 191, 247, 151, 3, 255, 25, 48, 179, 72, 165,\n        181, 209, 215, 94, 146, 42, 172, 86, 170, 198, 79, 184, 56, 210,\n        150, 164, 125, 182, 118, 252, 107, 226, 156, 116, 4, 241, 69, 157,\n        112, 89, 100, 113, 135, 32, 134, 91, 207, 101, 230, 45, 168, 2, 27,\n        96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15,\n        85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197,\n        234, 38, 44, 83, 13, 110, 133, 40, 132, 9, 211, 223, 205, 244, 65,\n        129, 77, 82, 106, 220, 55, 200, 108, 193, 171, 250, 36, 225, 123,\n        8, 12, 189, 177, 74, 120, 136, 149, 139, 227, 99, 232, 109, 233,\n        203, 213, 254, 59, 0, 29, 57, 242, 239, 183, 14, 102, 88, 208, 228,\n        166, 119, 114, 248, 235, 117, 75, 10, 49, 68, 80, 180, 143, 237,\n        31, 26, 219, 153, 141, 51, 159, 17, 131, 20\n    };\n\n    while (len) {\n        word32 L = (PAD_SIZE - count_) < len ? (PAD_SIZE - count_) : len;\n        memcpy(buffer_.get_buffer() + count_, data, L);\n        count_ += L;\n        data += L;\n        len  -= L;\n\n        if (count_==PAD_SIZE) {\n            count_ = 0;\n            memcpy(X_.get_buffer() + PAD_SIZE, buffer_.get_buffer(), PAD_SIZE);\n            byte t = C_[15];\n\n            int i;\n            for(i = 0; i < PAD_SIZE; i++) {\n                X_[32 + i] = X_[PAD_SIZE + i] ^ X_[i];\n                t = C_[i] ^= S[buffer_[i] ^ t];\n            }\n\n            t=0;\n            for(i = 0; i < 18; i++) {\n                for(int j = 0; j < X_SIZE; j += 8) {\n                    t = X_[j+0] ^= S[t];\n                    t = X_[j+1] ^= S[t];\n                    t = X_[j+2] ^= S[t];\n                    t = X_[j+3] ^= S[t];\n                    t = X_[j+4] ^= S[t];\n                    t = X_[j+5] ^= S[t];\n                    t = X_[j+6] ^= S[t];\n                    t = X_[j+7] ^= S[t];\n                }\n                t = (t + i) & 0xFF;\n            }\n        }\n    }\n}\n\n\nvoid MD2::Final(byte *hash)\n{\n    byte   padding[BLOCK_SIZE];\n    word32 padLen = PAD_SIZE - count_;\n\n    for (word32 i = 0; i < padLen; i++)\n        padding[i] = static_cast<byte>(padLen);\n\n    Update(padding, padLen);\n    Update(C_.get_buffer(), BLOCK_SIZE);\n\n    memcpy(hash, X_.get_buffer(), DIGEST_SIZE);\n\n    Init();\n}\n\n\n\n\n} // namespace\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/md4.cpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* based on Wei Dai's md4.cpp from CryptoPP */\n\n#include \"runtime.hpp\"\n#include \"md4.hpp\"\n#ifdef USE_SYS_STL\n    #include <algorithm>\n#else\n    #include \"algorithm.hpp\"\n#endif\n\n\nnamespace STL = STL_NAMESPACE;\n   \n\nnamespace TaoCrypt {\n\nvoid MD4::Init()\n{\n    digest_[0] = 0x67452301L;\n    digest_[1] = 0xefcdab89L;\n    digest_[2] = 0x98badcfeL;\n    digest_[3] = 0x10325476L;\n\n    buffLen_ = 0;\n    loLen_  = 0;\n    hiLen_  = 0;\n}\n\n\nMD4::MD4(const MD4& that) : HASHwithTransform(DIGEST_SIZE / sizeof(word32),\n                                              BLOCK_SIZE) \n{ \n    buffLen_ = that.buffLen_;\n    loLen_  =  that.loLen_;\n    hiLen_  =  that.hiLen_;\n\n    memcpy(digest_, that.digest_, DIGEST_SIZE);\n    memcpy(buffer_, that.buffer_, BLOCK_SIZE);\n}\n\nMD4& MD4::operator= (const MD4& that)\n{\n    MD4 tmp(that);\n    Swap(tmp);\n\n    return *this;\n}\n\n\nvoid MD4::Swap(MD4& other)\n{\n    STL::swap(loLen_,   other.loLen_);\n    STL::swap(hiLen_,   other.hiLen_);\n    STL::swap(buffLen_, other.buffLen_);\n\n    memcpy(digest_, other.digest_, DIGEST_SIZE);\n    memcpy(buffer_, other.buffer_, BLOCK_SIZE);\n}\n\n\nvoid MD4::Transform()\n{\n#define F(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))\n#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z)))\n#define H(x, y, z) ((x) ^ (y) ^ (z))\n\n    word32 A, B, C, D;\n\n    A = digest_[0];\n    B = digest_[1];\n    C = digest_[2];\n    D = digest_[3];\n\n#define function(a,b,c,d,k,s) a=rotlFixed(a+F(b,c,d)+buffer_[k],s);\n    function(A,B,C,D, 0, 3);\n    function(D,A,B,C, 1, 7);\n    function(C,D,A,B, 2,11);\n    function(B,C,D,A, 3,19);\n    function(A,B,C,D, 4, 3);\n    function(D,A,B,C, 5, 7);\n    function(C,D,A,B, 6,11);\n    function(B,C,D,A, 7,19);\n    function(A,B,C,D, 8, 3);\n    function(D,A,B,C, 9, 7);\n    function(C,D,A,B,10,11);\n    function(B,C,D,A,11,19);\n    function(A,B,C,D,12, 3);\n    function(D,A,B,C,13, 7);\n    function(C,D,A,B,14,11);\n    function(B,C,D,A,15,19);\n\n#undef function\t  \n#define function(a,b,c,d,k,s) a=rotlFixed(a+G(b,c,d)+buffer_[k]+0x5a827999,s);\n    function(A,B,C,D, 0, 3);\n    function(D,A,B,C, 4, 5);\n    function(C,D,A,B, 8, 9);\n    function(B,C,D,A,12,13);\n    function(A,B,C,D, 1, 3);\n    function(D,A,B,C, 5, 5);\n    function(C,D,A,B, 9, 9);\n    function(B,C,D,A,13,13);\n    function(A,B,C,D, 2, 3);\n    function(D,A,B,C, 6, 5);\n    function(C,D,A,B,10, 9);\n    function(B,C,D,A,14,13);\n    function(A,B,C,D, 3, 3);\n    function(D,A,B,C, 7, 5);\n    function(C,D,A,B,11, 9);\n    function(B,C,D,A,15,13);\n\n#undef function\t \n#define function(a,b,c,d,k,s) a=rotlFixed(a+H(b,c,d)+buffer_[k]+0x6ed9eba1,s);\n    function(A,B,C,D, 0, 3);\n    function(D,A,B,C, 8, 9);\n    function(C,D,A,B, 4,11);\n    function(B,C,D,A,12,15);\n    function(A,B,C,D, 2, 3);\n    function(D,A,B,C,10, 9);\n    function(C,D,A,B, 6,11);\n    function(B,C,D,A,14,15);\n    function(A,B,C,D, 1, 3);\n    function(D,A,B,C, 9, 9);\n    function(C,D,A,B, 5,11);\n    function(B,C,D,A,13,15);\n    function(A,B,C,D, 3, 3);\n    function(D,A,B,C,11, 9);\n    function(C,D,A,B, 7,11);\n    function(B,C,D,A,15,15);\n\n    digest_[0] += A;\n    digest_[1] += B;\n    digest_[2] += C;\n    digest_[3] += D;\n}\n\n\n} // namespace\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/md5.cpp",
    "content": "/*\n   Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* based on Wei Dai's md5.cpp from CryptoPP */\n\n#include \"runtime.hpp\"\n#include \"md5.hpp\"\n#ifdef USE_SYS_STL\n    #include <algorithm>\n#else\n    #include \"algorithm.hpp\"\n#endif\n\n\nnamespace STL = STL_NAMESPACE;\n\n\n\nnamespace TaoCrypt {\n\nvoid MD5::Init()\n{\n    digest_[0] = 0x67452301L;\n    digest_[1] = 0xefcdab89L;\n    digest_[2] = 0x98badcfeL;\n    digest_[3] = 0x10325476L;\n\n    buffLen_ = 0;\n    loLen_  = 0;\n    hiLen_  = 0;\n}\n\n\nMD5::MD5(const MD5& that) : HASHwithTransform(DIGEST_SIZE / sizeof(word32),\n                                              BLOCK_SIZE) \n{ \n    buffLen_ = that.buffLen_;\n    loLen_  =  that.loLen_;\n    hiLen_  =  that.hiLen_;\n\n    memcpy(digest_, that.digest_, DIGEST_SIZE);\n    memcpy(buffer_, that.buffer_, BLOCK_SIZE);\n}\n\nMD5& MD5::operator= (const MD5& that)\n{\n    MD5 tmp(that);\n    Swap(tmp);\n\n    return *this;\n}\n\n\nvoid MD5::Swap(MD5& other)\n{\n    STL::swap(loLen_,   other.loLen_);\n    STL::swap(hiLen_,   other.hiLen_);\n    STL::swap(buffLen_, other.buffLen_);\n\n    memcpy(digest_, other.digest_, DIGEST_SIZE);\n    memcpy(buffer_, other.buffer_, BLOCK_SIZE);\n}\n\n\n#ifdef DO_MD5_ASM\n\n// Update digest with data of size len\nvoid MD5::Update(const byte* data, word32 len)\n{\n    if (!isMMX) {\n        HASHwithTransform::Update(data, len);\n        return;\n    }\n\n    byte* local = reinterpret_cast<byte*>(buffer_);\n\n    // remove buffered data if possible\n    if (buffLen_)  {   \n        word32 add = min(len, BLOCK_SIZE - buffLen_);\n        memcpy(&local[buffLen_], data, add);\n\n        buffLen_ += add;\n        data     += add;\n        len      -= add;\n\n        if (buffLen_ == BLOCK_SIZE) {\n            Transform();\n            AddLength(BLOCK_SIZE);\n            buffLen_ = 0;\n        }\n    }\n\n    // at once for asm\n    if (buffLen_ == 0) {\n        word32 times = len / BLOCK_SIZE;\n        if (times) {\n            AsmTransform(data, times);\n            const word32 add = BLOCK_SIZE * times;\n            AddLength(add);\n            len  -= add;\n            data += add;\n        }\n    }\n\n    // cache any data left\n    if (len) {\n        memcpy(&local[buffLen_], data, len);\n        buffLen_ += len;\n    }\n}\n\n\n\n\n/*\n    // w = rotlFixed(w + f(x, y, z) + index[edi] + data, s) + x\n#define ASMMD5STEP(f, w, x, y, z, index, data, s)       \\\n    f(x, y, z)                                          \\\n    AS2(    mov   ebp, [edi + index * 4]            )   \\\n    AS2(    lea     w, [esi + w + data]             )   \\\n    AS2(    add     w, ebp                          )   \\\n    AS2(    rol     w, s                            )   \\\n    AS2(    add     w, x                            )\n\n\n    // F1(x, y, z) (z ^ (x & (y ^ z)))\n    // place in esi\n#define ASMF1(x, y, z) \\\n    AS2(    mov   esi, y                )   \\\n    AS2(    xor   esi, z                )   \\\n    AS2(    and   esi, x                )   \\\n    AS2(    xor   esi, z                )\n\n\n#define ASMF2(x, y, z) ASMF1(z, x, y)\n\n\n    // F3(x ^ y ^ z)\n    // place in esi\n#define ASMF3(x, y, z)  \\\n    AS2(    mov   esi, x                )   \\\n    AS2(    xor   esi, y                )   \\\n    AS2(    xor   esi, z                )\n\n\n\n    // F4(x, y, z) (y ^ (x | ~z))\n    // place in esi\n#define ASMF4(x, y, z)  \\\n    AS2(    mov   esi, z                )   \\\n    AS1(    not   esi                   )   \\\n    AS2(     or   esi, x                )   \\\n    AS2(    xor   esi, y                )\n*/\n\n\n    // combine above ASMMD5STEP(f w/ each f ASMF1 - F4\n\n    // esi already set up, after using set for next round\n    // ebp already set up, set up using next round index\n    \n#define MD5STEP1(w, x, y, z, index, data, s)    \\\n    AS2(    xor   esi, z                    )   \\\n    AS2(    and   esi, x                    )   \\\n    AS2(    lea     w, [ebp + w + data]     )   \\\n    AS2(    xor   esi, z                    )   \\\n    AS2(    add     w, esi                  )   \\\n    AS2(    mov   esi, x                    )   \\\n    AS2(    rol     w, s                    )   \\\n    AS2(    mov   ebp, [edi + index * 4]    )   \\\n    AS2(    add     w, x                    )\n\n#define MD5STEP2(w, x, y, z, index, data, s)    \\\n    AS2(    xor   esi, x                    )   \\\n    AS2(    and   esi, z                    )   \\\n    AS2(    lea     w, [ebp + w + data]     )   \\\n    AS2(    xor   esi, y                    )   \\\n    AS2(    add     w, esi                  )   \\\n    AS2(    mov   esi, x                    )   \\\n    AS2(    rol     w, s                    )   \\\n    AS2(    mov   ebp, [edi + index * 4]    )   \\\n    AS2(    add     w, x                    )\n\n\n#define MD5STEP3(w, x, y, z, index, data, s)    \\\n    AS2(    xor   esi, z                    )   \\\n    AS2(    lea     w, [ebp + w + data]     )   \\\n    AS2(    xor   esi, x                    )   \\\n    AS2(    add     w, esi                  )   \\\n    AS2(    mov   esi, x                    )   \\\n    AS2(    rol     w, s                    )   \\\n    AS2(    mov   ebp, [edi + index * 4]    )   \\\n    AS2(    add     w, x                    )\n\n\n#define MD5STEP4(w, x, y, z, index, data, s)    \\\n    AS2(     or   esi, x                    )   \\\n    AS2(    lea     w, [ebp + w + data]     )   \\\n    AS2(    xor   esi, y                    )   \\\n    AS2(    add     w, esi                  )   \\\n    AS2(    mov   esi, y                    )   \\\n    AS2(    rol     w, s                    )   \\\n    AS1(    not   esi                       )   \\\n    AS2(    mov   ebp, [edi + index * 4]    )   \\\n    AS2(    add     w, x                    )\n\n\n\n#ifdef _MSC_VER\n    __declspec(naked) \n#else\n    __attribute__ ((noinline))\n#endif\nvoid MD5::AsmTransform(const byte* data, word32 times)\n{\n#ifdef __GNUC__\n    #define AS1(x)    #x \";\"\n    #define AS2(x, y) #x \", \" #y \";\"\n\n    #define PROLOG()  \\\n    __asm__ __volatile__ \\\n    ( \\\n        \".intel_syntax noprefix;\" \\\n        \"push ebx;\" \\\n        \"push ebp;\"\n    #define EPILOG()  \\\n        \"pop ebp;\" \\\n        \"pop ebx;\" \\\n       \t\"emms;\" \\\n       \t\".att_syntax;\" \\\n            : \\\n            : \"c\" (this), \"D\" (data), \"a\" (times) \\\n            : \"%esi\", \"%edx\", \"memory\", \"cc\" \\\n    );\n\n#else\n    #define AS1(x)    __asm x\n    #define AS2(x, y) __asm x, y\n\n    #define PROLOG() \\\n        AS1(    push  ebp                       )   \\\n        AS2(    mov   ebp, esp                  )   \\\n        AS2(    movd  mm3, edi                  )   \\\n        AS2(    movd  mm4, ebx                  )   \\\n        AS2(    movd  mm5, esi                  )   \\\n        AS2(    movd  mm6, ebp                  )   \\\n        AS2(    mov   edi, DWORD PTR [ebp +  8] )   \\\n        AS2(    mov   eax, DWORD PTR [ebp + 12] )\n\n    #define EPILOG() \\\n        AS2(    movd  ebp, mm6                  )   \\\n        AS2(    movd  esi, mm5                  )   \\\n        AS2(    movd  ebx, mm4                  )   \\\n        AS2(    movd  edi, mm3                  )   \\\n        AS2(    mov   esp, ebp                  )   \\\n        AS1(    pop   ebp                       )   \\\n        AS1(    emms                            )   \\\n        AS1(    ret  8                          )\n        \n#endif\n\n\n    PROLOG()\n\n    AS2(    mov   esi, ecx              )\n\n    #ifdef OLD_GCC_OFFSET\n        AS2(    add   esi, 20               )   // digest_[0]\n    #else\n        AS2(    add   esi, 16               )   // digest_[0]\n    #endif\n\n    AS2(    movd  mm2, eax              )   // store times_\n    AS2(    movd  mm1, esi              )   // store digest_\n    \n    AS2(    mov   eax, [esi]            )   // a\n    AS2(    mov   ebx, [esi +  4]       )   // b\n    AS2(    mov   ecx, [esi +  8]       )   // c\n    AS2(    mov   edx, [esi + 12]       )   // d\n  \n#ifdef _MSC_VER\n    AS1( loopStart: )  // loopStart\n#else\n    AS1( 0: )          // loopStart for some gas (need numeric for jump back \n#endif\n\n    // set up\n    AS2(    mov   esi, ecx      )\n    AS2(    mov   ebp, [edi]    )\n\n    MD5STEP1( eax, ebx, ecx, edx, 1,   0xd76aa478,  7)\n    MD5STEP1( edx, eax, ebx, ecx, 2,   0xe8c7b756, 12)\n    MD5STEP1( ecx, edx, eax, ebx, 3,   0x242070db, 17)\n    MD5STEP1( ebx, ecx, edx, eax, 4,   0xc1bdceee, 22)\n    MD5STEP1( eax, ebx, ecx, edx, 5,   0xf57c0faf,  7)\n    MD5STEP1( edx, eax, ebx, ecx, 6,   0x4787c62a, 12)\n    MD5STEP1( ecx, edx, eax, ebx, 7,   0xa8304613, 17)\n    MD5STEP1( ebx, ecx, edx, eax, 8,   0xfd469501, 22)\n    MD5STEP1( eax, ebx, ecx, edx, 9,   0x698098d8,  7)\n    MD5STEP1( edx, eax, ebx, ecx, 10,  0x8b44f7af, 12)\n    MD5STEP1( ecx, edx, eax, ebx, 11,  0xffff5bb1, 17)\n    MD5STEP1( ebx, ecx, edx, eax, 12,  0x895cd7be, 22)\n    MD5STEP1( eax, ebx, ecx, edx, 13,  0x6b901122,  7)\n    MD5STEP1( edx, eax, ebx, ecx, 14,  0xfd987193, 12)\n    MD5STEP1( ecx, edx, eax, ebx, 15,  0xa679438e, 17)\n    MD5STEP1( ebx, ecx, edx, eax, 1,   0x49b40821, 22)\n\n    MD5STEP2( eax, ebx, ecx, edx, 6,  0xf61e2562,  5)\n    MD5STEP2( edx, eax, ebx, ecx, 11, 0xc040b340,  9)\n    MD5STEP2( ecx, edx, eax, ebx, 0,  0x265e5a51, 14)\n    MD5STEP2( ebx, ecx, edx, eax, 5,  0xe9b6c7aa, 20)\n    MD5STEP2( eax, ebx, ecx, edx, 10, 0xd62f105d,  5)\n    MD5STEP2( edx, eax, ebx, ecx, 15, 0x02441453,  9)\n    MD5STEP2( ecx, edx, eax, ebx, 4,  0xd8a1e681, 14)\n    MD5STEP2( ebx, ecx, edx, eax, 9,  0xe7d3fbc8, 20)\n    MD5STEP2( eax, ebx, ecx, edx, 14, 0x21e1cde6,  5)\n    MD5STEP2( edx, eax, ebx, ecx, 3,  0xc33707d6,  9)\n    MD5STEP2( ecx, edx, eax, ebx, 8,  0xf4d50d87, 14)\n    MD5STEP2( ebx, ecx, edx, eax, 13, 0x455a14ed, 20)\n    MD5STEP2( eax, ebx, ecx, edx, 2,  0xa9e3e905,  5)\n    MD5STEP2( edx, eax, ebx, ecx, 7,  0xfcefa3f8,  9)\n    MD5STEP2( ecx, edx, eax, ebx, 12, 0x676f02d9, 14)\n    MD5STEP2( ebx, ecx, edx, eax, 5,  0x8d2a4c8a, 20)\n\n    MD5STEP3(  eax, ebx, ecx, edx, 8,   0xfffa3942,  4)\n    MD5STEP3(  edx, eax, ebx, ecx, 11,  0x8771f681, 11)\n    MD5STEP3(  ecx, edx, eax, ebx, 14,  0x6d9d6122, 16)\n    MD5STEP3(  ebx, ecx, edx, eax, 1,   0xfde5380c, 23)\n    MD5STEP3(  eax, ebx, ecx, edx, 4,   0xa4beea44,  4)\n    MD5STEP3(  edx, eax, ebx, ecx, 7,   0x4bdecfa9, 11)\n    MD5STEP3(  ecx, edx, eax, ebx, 10,  0xf6bb4b60, 16)\n    MD5STEP3(  ebx, ecx, edx, eax, 13,  0xbebfbc70, 23)\n    MD5STEP3(  eax, ebx, ecx, edx, 0,   0x289b7ec6,  4)\n    MD5STEP3(  edx, eax, ebx, ecx, 3,   0xeaa127fa, 11)\n    MD5STEP3(  ecx, edx, eax, ebx, 6,   0xd4ef3085, 16)\n    MD5STEP3(  ebx, ecx, edx, eax, 9,   0x04881d05, 23)\n    MD5STEP3(  eax, ebx, ecx, edx, 12,  0xd9d4d039,  4)\n    MD5STEP3(  edx, eax, ebx, ecx, 15,  0xe6db99e5, 11)\n    MD5STEP3(  ecx, edx, eax, ebx, 2,   0x1fa27cf8, 16)\n    MD5STEP3(  ebx, ecx, edx, eax, 0,   0xc4ac5665, 23)\n\n    // setup\n    AS2(    mov   esi, edx      )\n    AS1(    not   esi           )\n\n    MD5STEP4(  eax, ebx, ecx, edx, 7,   0xf4292244,  6)\n    MD5STEP4(  edx, eax, ebx, ecx, 14,  0x432aff97, 10)\n    MD5STEP4(  ecx, edx, eax, ebx, 5,   0xab9423a7, 15)\n    MD5STEP4(  ebx, ecx, edx, eax, 12,  0xfc93a039, 21)\n    MD5STEP4(  eax, ebx, ecx, edx, 3,   0x655b59c3,  6)\n    MD5STEP4(  edx, eax, ebx, ecx, 10,  0x8f0ccc92, 10)\n    MD5STEP4(  ecx, edx, eax, ebx, 1,   0xffeff47d, 15)\n    MD5STEP4(  ebx, ecx, edx, eax, 8,   0x85845dd1, 21)\n    MD5STEP4(  eax, ebx, ecx, edx, 15,  0x6fa87e4f,  6)\n    MD5STEP4(  edx, eax, ebx, ecx, 6,   0xfe2ce6e0, 10)\n    MD5STEP4(  ecx, edx, eax, ebx, 13,  0xa3014314, 15)\n    MD5STEP4(  ebx, ecx, edx, eax, 4,   0x4e0811a1, 21)\n    MD5STEP4(  eax, ebx, ecx, edx, 11,  0xf7537e82,  6)\n    MD5STEP4(  edx, eax, ebx, ecx, 2,   0xbd3af235, 10)\n    MD5STEP4(  ecx, edx, eax, ebx, 9,   0x2ad7d2bb, 15)\n    MD5STEP4(  ebx, ecx, edx, eax, 9,   0xeb86d391, 21)\n    \n    AS2(    movd  esi, mm1              )   // digest_\n\n    AS2(    add   [esi],      eax       )   // write out\n    AS2(    add   [esi +  4], ebx       )\n    AS2(    add   [esi +  8], ecx       )\n    AS2(    add   [esi + 12], edx       )\n\n    AS2(    add   edi, 64               )\n\n    AS2(    mov   eax, [esi]            )\n    AS2(    mov   ebx, [esi +  4]       )\n    AS2(    mov   ecx, [esi +  8]       )\n    AS2(    mov   edx, [esi + 12]       )\n\n    AS2(    movd  ebp, mm2              )   // times\n    AS1(    dec   ebp                   )\n    AS2(    movd  mm2, ebp              )\n#ifdef _MSC_VER\n    AS1(    jnz   loopStart )  // loopStart\n#else\n    AS1(    jnz   0b )         // loopStart\n#endif\n\n\n    EPILOG()\n}\n\n\n#endif // DO_MD5_ASM\n\n\nvoid MD5::Transform()\n{\n#define F1(x, y, z) (z ^ (x & (y ^ z)))\n#define F2(x, y, z) F1(z, x, y)\n#define F3(x, y, z) (x ^ y ^ z)\n#define F4(x, y, z) (y ^ (x | ~z))\n\n#define MD5STEP(f, w, x, y, z, data, s) \\\n    w = rotlFixed(w + f(x, y, z) + data, s) + x\n\n    // Copy context->state[] to working vars \n    word32 a = digest_[0];\n    word32 b = digest_[1];\n    word32 c = digest_[2];\n    word32 d = digest_[3];\n\n    MD5STEP(F1, a, b, c, d, buffer_[0]  + 0xd76aa478,  7);\n    MD5STEP(F1, d, a, b, c, buffer_[1]  + 0xe8c7b756, 12);\n    MD5STEP(F1, c, d, a, b, buffer_[2]  + 0x242070db, 17);\n    MD5STEP(F1, b, c, d, a, buffer_[3]  + 0xc1bdceee, 22);\n    MD5STEP(F1, a, b, c, d, buffer_[4]  + 0xf57c0faf,  7);\n    MD5STEP(F1, d, a, b, c, buffer_[5]  + 0x4787c62a, 12);\n    MD5STEP(F1, c, d, a, b, buffer_[6]  + 0xa8304613, 17);\n    MD5STEP(F1, b, c, d, a, buffer_[7]  + 0xfd469501, 22);\n    MD5STEP(F1, a, b, c, d, buffer_[8]  + 0x698098d8,  7);\n    MD5STEP(F1, d, a, b, c, buffer_[9]  + 0x8b44f7af, 12);\n    MD5STEP(F1, c, d, a, b, buffer_[10] + 0xffff5bb1, 17);\n    MD5STEP(F1, b, c, d, a, buffer_[11] + 0x895cd7be, 22);\n    MD5STEP(F1, a, b, c, d, buffer_[12] + 0x6b901122,  7);\n    MD5STEP(F1, d, a, b, c, buffer_[13] + 0xfd987193, 12);\n    MD5STEP(F1, c, d, a, b, buffer_[14] + 0xa679438e, 17);\n    MD5STEP(F1, b, c, d, a, buffer_[15] + 0x49b40821, 22);\n\n    MD5STEP(F2, a, b, c, d, buffer_[1]  + 0xf61e2562,  5);\n    MD5STEP(F2, d, a, b, c, buffer_[6]  + 0xc040b340,  9);\n    MD5STEP(F2, c, d, a, b, buffer_[11] + 0x265e5a51, 14);\n    MD5STEP(F2, b, c, d, a, buffer_[0]  + 0xe9b6c7aa, 20);\n    MD5STEP(F2, a, b, c, d, buffer_[5]  + 0xd62f105d,  5);\n    MD5STEP(F2, d, a, b, c, buffer_[10] + 0x02441453,  9);\n    MD5STEP(F2, c, d, a, b, buffer_[15] + 0xd8a1e681, 14);\n    MD5STEP(F2, b, c, d, a, buffer_[4]  + 0xe7d3fbc8, 20);\n    MD5STEP(F2, a, b, c, d, buffer_[9]  + 0x21e1cde6,  5);\n    MD5STEP(F2, d, a, b, c, buffer_[14] + 0xc33707d6,  9);\n    MD5STEP(F2, c, d, a, b, buffer_[3]  + 0xf4d50d87, 14);\n    MD5STEP(F2, b, c, d, a, buffer_[8]  + 0x455a14ed, 20);\n    MD5STEP(F2, a, b, c, d, buffer_[13] + 0xa9e3e905,  5);\n    MD5STEP(F2, d, a, b, c, buffer_[2]  + 0xfcefa3f8,  9);\n    MD5STEP(F2, c, d, a, b, buffer_[7]  + 0x676f02d9, 14);\n    MD5STEP(F2, b, c, d, a, buffer_[12] + 0x8d2a4c8a, 20);\n\n    MD5STEP(F3, a, b, c, d, buffer_[5]  + 0xfffa3942,  4);\n    MD5STEP(F3, d, a, b, c, buffer_[8]  + 0x8771f681, 11);\n    MD5STEP(F3, c, d, a, b, buffer_[11] + 0x6d9d6122, 16);\n    MD5STEP(F3, b, c, d, a, buffer_[14] + 0xfde5380c, 23);\n    MD5STEP(F3, a, b, c, d, buffer_[1]  + 0xa4beea44,  4);\n    MD5STEP(F3, d, a, b, c, buffer_[4]  + 0x4bdecfa9, 11);\n    MD5STEP(F3, c, d, a, b, buffer_[7]  + 0xf6bb4b60, 16);\n    MD5STEP(F3, b, c, d, a, buffer_[10] + 0xbebfbc70, 23);\n    MD5STEP(F3, a, b, c, d, buffer_[13] + 0x289b7ec6,  4);\n    MD5STEP(F3, d, a, b, c, buffer_[0]  + 0xeaa127fa, 11);\n    MD5STEP(F3, c, d, a, b, buffer_[3]  + 0xd4ef3085, 16);\n    MD5STEP(F3, b, c, d, a, buffer_[6]  + 0x04881d05, 23);\n    MD5STEP(F3, a, b, c, d, buffer_[9]  + 0xd9d4d039,  4);\n    MD5STEP(F3, d, a, b, c, buffer_[12] + 0xe6db99e5, 11);\n    MD5STEP(F3, c, d, a, b, buffer_[15] + 0x1fa27cf8, 16);\n    MD5STEP(F3, b, c, d, a, buffer_[2]  + 0xc4ac5665, 23);\n\n    MD5STEP(F4, a, b, c, d, buffer_[0]  + 0xf4292244,  6);\n    MD5STEP(F4, d, a, b, c, buffer_[7]  + 0x432aff97, 10);\n    MD5STEP(F4, c, d, a, b, buffer_[14] + 0xab9423a7, 15);\n    MD5STEP(F4, b, c, d, a, buffer_[5]  + 0xfc93a039, 21);\n    MD5STEP(F4, a, b, c, d, buffer_[12] + 0x655b59c3,  6);\n    MD5STEP(F4, d, a, b, c, buffer_[3]  + 0x8f0ccc92, 10);\n    MD5STEP(F4, c, d, a, b, buffer_[10] + 0xffeff47d, 15);\n    MD5STEP(F4, b, c, d, a, buffer_[1]  + 0x85845dd1, 21);\n    MD5STEP(F4, a, b, c, d, buffer_[8]  + 0x6fa87e4f,  6);\n    MD5STEP(F4, d, a, b, c, buffer_[15] + 0xfe2ce6e0, 10);\n    MD5STEP(F4, c, d, a, b, buffer_[6]  + 0xa3014314, 15);\n    MD5STEP(F4, b, c, d, a, buffer_[13] + 0x4e0811a1, 21);\n    MD5STEP(F4, a, b, c, d, buffer_[4]  + 0xf7537e82,  6);\n    MD5STEP(F4, d, a, b, c, buffer_[11] + 0xbd3af235, 10);\n    MD5STEP(F4, c, d, a, b, buffer_[2]  + 0x2ad7d2bb, 15);\n    MD5STEP(F4, b, c, d, a, buffer_[9]  + 0xeb86d391, 21);\n    \n    // Add the working vars back into digest state[]\n    digest_[0] += a;\n    digest_[1] += b;\n    digest_[2] += c;\n    digest_[3] += d;\n\n    // Wipe variables\n    a = b = c = d = 0;\n}\n\n\n} // namespace\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/misc.cpp",
    "content": "/*\n   Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* based on Wei Dai's misc.cpp from CryptoPP */\n\n\n#include \"runtime.hpp\"\n#include \"misc.hpp\"\n\n\n#ifdef __GNUC__\n    #include <signal.h>\n    #include <setjmp.h>\n#endif\n\n#ifdef USE_SYS_STL\n    #include <algorithm>\n#else\n    #include \"algorithm.hpp\"\n#endif\n\nnamespace STL = STL_NAMESPACE;\n\n\n#ifdef YASSL_PURE_C\n\n    void* operator new(size_t sz, TaoCrypt::new_t)\n    {\n        void* ptr = malloc(sz ? sz : 1);\n        if (!ptr) abort();\n\n        return ptr;\n    }\n\n\n    void operator delete(void* ptr, TaoCrypt::new_t)\n    {\n        if (ptr) free(ptr);\n    }\n\n\n    void* operator new[](size_t sz, TaoCrypt::new_t nt)\n    {\n        return ::operator new(sz, nt);\n    }\n\n\n    void operator delete[](void* ptr, TaoCrypt::new_t nt)\n    {\n        ::operator delete(ptr, nt);\n    }\n\n\n    /* uncomment to test\n    // make sure not using globals anywhere by forgetting to use overloaded\n    void* operator new(size_t sz);\n\n    void operator delete(void* ptr);\n\n    void* operator new[](size_t sz);\n\n    void operator delete[](void* ptr);\n    */\n\n\n    namespace TaoCrypt {\n\n        new_t tc;   // for library new\n\n    }\n\n#ifdef __sun\n\n// Handler for pure virtual functions\nnamespace __Crun {\n    void pure_error() {\n    }\n}\n\n#endif\n\n#if defined(__ICC) || defined(__INTEL_COMPILER) || (__GNUC__ > 2)\n\nextern \"C\" {\n\n    int __cxa_pure_virtual() {\n      return 0;\n    }\n\n}  // extern \"C\"\n\n#endif\n\n#endif // YASSL_PURE_C\n\n\nnamespace TaoCrypt {\n\n\ninline void XorWords(word* r, const word* a, unsigned int n)\n{\n    for (unsigned int i=0; i<n; i++)\n        r[i] ^= a[i];\n}\n\n\nvoid xorbuf(byte* buf, const byte* mask, unsigned int count)\n{\n    if (((size_t)buf | (size_t)mask | count) % WORD_SIZE == 0)\n        XorWords((word *)buf, (const word *)mask, count/WORD_SIZE);\n    else\n    {\n        for (unsigned int i=0; i<count; i++)\n            buf[i] ^= mask[i];\n    }\n}\n\n\nunsigned int BytePrecision(word value)\n{\n    unsigned int i;\n    for (i=sizeof(value); i; --i)\n        if (value >> (i-1)*8)\n            break;\n\n    return i;\n}\n\n\nunsigned int BitPrecision(word value)\n{\n    if (!value)\n        return 0;\n\n    unsigned int l = 0,\n                 h = 8 * sizeof(value);\n\n    while (h-l > 1)\n    {\n        unsigned int t = (l+h)/2;\n        if (value >> t)\n            l = t;\n        else\n            h = t;\n    }\n\n    return h;\n}\n\n\nword Crop(word value, unsigned int size)\n{\n    if (size < 8*sizeof(value))\n        return (value & ((1L << size) - 1));\n    else\n        return value;\n}\n\n\n\n#ifdef TAOCRYPT_X86ASM_AVAILABLE\n\n\nbool HaveCpuId()\n{\n#ifdef _MSC_VER\n    __try\n    {\n        __asm\n        {\n            mov eax, 0\n            cpuid\n        }            \n    }\n    __except (1)\n    {\n        return false;\n    }\n    return true;\n#else\n    word32 eax, ebx;\n    __asm__ __volatile\n    (\n        /* Put EFLAGS in eax and ebx */\n        \"pushf;\"\n        \"pushf;\"\n        \"pop %0;\"\n        \"movl %0,%1;\"\n\n        /* Flip the cpuid bit and store back in EFLAGS */\n        \"xorl $0x200000,%0;\"\n        \"push %0;\"\n        \"popf;\"\n\n        /* Read EFLAGS again */\n        \"pushf;\"\n        \"pop %0;\"\n        \"popf\"\n        : \"=r\" (eax), \"=r\" (ebx)\n        :\n        : \"cc\"\n    );\n\n    if (eax == ebx)\n        return false;\n    return true;\n#endif\n}\n\n\nvoid CpuId(word32 input, word32 *output)\n{\n#ifdef __GNUC__\n    __asm__\n    (\n        // save ebx in case -fPIC is being used\n        \"push %%ebx; cpuid; mov %%ebx, %%edi; pop %%ebx\"\n        : \"=a\" (output[0]), \"=D\" (output[1]), \"=c\" (output[2]), \"=d\"(output[3])\n        : \"a\" (input)\n    );\n#else\n    __asm\n    {\n        mov eax, input\n        cpuid\n        mov edi, output\n        mov [edi], eax\n        mov [edi+4], ebx\n        mov [edi+8], ecx\n        mov [edi+12], edx\n    }\n#endif\n}\n\n\nbool IsPentium()\n{\n    if (!HaveCpuId())\n        return false;\n\n    word32 cpuid[4];\n\n    CpuId(0, cpuid);\n    STL::swap(cpuid[2], cpuid[3]);\n    if (memcmp(cpuid+1, \"GenuineIntel\", 12) != 0)\n        return false;\n\n    CpuId(1, cpuid);\n    byte family = ((cpuid[0] >> 8) & 0xf);\n    if (family < 5)\n        return false;\n\n    return true;\n}\n\n\n\nstatic bool IsMmx()\n{\n    if (!IsPentium())\n        return false;\n\n    word32 cpuid[4];\n\n    CpuId(1, cpuid);\n    if ((cpuid[3] & (1 << 23)) == 0)\n        return false;\n\n    return true;\n}\n\n\nbool isMMX = IsMmx();\n\n\n#endif // TAOCRYPT_X86ASM_AVAILABLE\n\n\n\n\n}  // namespace\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/rabbit.cpp",
    "content": "/*\n   Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n#include \"runtime.hpp\"\n#include \"rabbit.hpp\"\n\n\n\nnamespace TaoCrypt {\n\n\n#define U32V(x)  (word32)(x)\n\n\n#ifdef BIG_ENDIAN_ORDER\n    #define LITTLE32(x) ByteReverse((word32)x)\n#else\n    #define LITTLE32(x) (x)\n#endif\n\n\n// local\nnamespace {\n\n\n/* Square a 32-bit unsigned integer to obtain the 64-bit result and return */\n/* the upper 32 bits XOR the lower 32 bits */\nword32 RABBIT_g_func(word32 x)\n{\n    /* Temporary variables */\n    word32 a, b, h, l;\n\n    /* Construct high and low argument for squaring */\n    a = x&0xFFFF;\n    b = x>>16;\n\n    /* Calculate high and low result of squaring */\n    h = (((U32V(a*a)>>17) + U32V(a*b))>>15) + b*b;\n    l = x*x;\n\n    /* Return high XOR low */\n    return U32V(h^l);\n}\n\n\n} // namespace local\n\n\n/* Calculate the next internal state */\nvoid Rabbit::NextState(RabbitCtx which)\n{\n    /* Temporary variables */\n    word32 g[8], c_old[8], i;\n\n    Ctx* ctx;\n\n    if (which == Master)\n        ctx = &masterCtx_;\n    else\n        ctx = &workCtx_;\n\n    /* Save old counter values */\n    for (i=0; i<8; i++)\n        c_old[i] = ctx->c[i];\n\n    /* Calculate new counter values */\n    ctx->c[0] = U32V(ctx->c[0] + 0x4D34D34D + ctx->carry);\n    ctx->c[1] = U32V(ctx->c[1] + 0xD34D34D3 + (ctx->c[0] < c_old[0]));\n    ctx->c[2] = U32V(ctx->c[2] + 0x34D34D34 + (ctx->c[1] < c_old[1]));\n    ctx->c[3] = U32V(ctx->c[3] + 0x4D34D34D + (ctx->c[2] < c_old[2]));\n    ctx->c[4] = U32V(ctx->c[4] + 0xD34D34D3 + (ctx->c[3] < c_old[3]));\n    ctx->c[5] = U32V(ctx->c[5] + 0x34D34D34 + (ctx->c[4] < c_old[4]));\n    ctx->c[6] = U32V(ctx->c[6] + 0x4D34D34D + (ctx->c[5] < c_old[5]));\n    ctx->c[7] = U32V(ctx->c[7] + 0xD34D34D3 + (ctx->c[6] < c_old[6]));\n    ctx->carry = (ctx->c[7] < c_old[7]);\n   \n    /* Calculate the g-values */\n    for (i=0;i<8;i++)\n        g[i] = RABBIT_g_func(U32V(ctx->x[i] + ctx->c[i]));\n\n    /* Calculate new state values */\n    ctx->x[0] = U32V(g[0] + rotlFixed(g[7],16) + rotlFixed(g[6], 16));\n    ctx->x[1] = U32V(g[1] + rotlFixed(g[0], 8) + g[7]);\n    ctx->x[2] = U32V(g[2] + rotlFixed(g[1],16) + rotlFixed(g[0], 16));\n    ctx->x[3] = U32V(g[3] + rotlFixed(g[2], 8) + g[1]);\n    ctx->x[4] = U32V(g[4] + rotlFixed(g[3],16) + rotlFixed(g[2], 16));\n    ctx->x[5] = U32V(g[5] + rotlFixed(g[4], 8) + g[3]);\n    ctx->x[6] = U32V(g[6] + rotlFixed(g[5],16) + rotlFixed(g[4], 16));\n    ctx->x[7] = U32V(g[7] + rotlFixed(g[6], 8) + g[5]);\n}\n\n\n/* IV setup */\nvoid Rabbit::SetIV(const byte* iv)\n{\n    /* Temporary variables */\n    word32 i0, i1, i2, i3, i;\n      \n    /* Generate four subvectors */\n    i0 = LITTLE32(*(word32*)(iv+0));\n    i2 = LITTLE32(*(word32*)(iv+4));\n    i1 = (i0>>16) | (i2&0xFFFF0000);\n    i3 = (i2<<16) | (i0&0x0000FFFF);\n\n    /* Modify counter values */\n    workCtx_.c[0] = masterCtx_.c[0] ^ i0;\n    workCtx_.c[1] = masterCtx_.c[1] ^ i1;\n    workCtx_.c[2] = masterCtx_.c[2] ^ i2;\n    workCtx_.c[3] = masterCtx_.c[3] ^ i3;\n    workCtx_.c[4] = masterCtx_.c[4] ^ i0;\n    workCtx_.c[5] = masterCtx_.c[5] ^ i1;\n    workCtx_.c[6] = masterCtx_.c[6] ^ i2;\n    workCtx_.c[7] = masterCtx_.c[7] ^ i3;\n\n    /* Copy state variables */\n    for (i=0; i<8; i++)\n        workCtx_.x[i] = masterCtx_.x[i];\n    workCtx_.carry = masterCtx_.carry;\n\n    /* Iterate the system four times */\n    for (i=0; i<4; i++)\n        NextState(Work);\n}\n\n\n/* Key setup */\nvoid Rabbit::SetKey(const byte* key, const byte* iv)\n{\n    /* Temporary variables */\n    word32 k0, k1, k2, k3, i;\n\n    /* Generate four subkeys */\n    k0 = LITTLE32(*(word32*)(key+ 0));\n    k1 = LITTLE32(*(word32*)(key+ 4));\n    k2 = LITTLE32(*(word32*)(key+ 8));\n    k3 = LITTLE32(*(word32*)(key+12));\n\n    /* Generate initial state variables */\n    masterCtx_.x[0] = k0;\n    masterCtx_.x[2] = k1;\n    masterCtx_.x[4] = k2;\n    masterCtx_.x[6] = k3;\n    masterCtx_.x[1] = U32V(k3<<16) | (k2>>16);\n    masterCtx_.x[3] = U32V(k0<<16) | (k3>>16);\n    masterCtx_.x[5] = U32V(k1<<16) | (k0>>16);\n    masterCtx_.x[7] = U32V(k2<<16) | (k1>>16);\n\n    /* Generate initial counter values */\n    masterCtx_.c[0] = rotlFixed(k2, 16);\n    masterCtx_.c[2] = rotlFixed(k3, 16);\n    masterCtx_.c[4] = rotlFixed(k0, 16);\n    masterCtx_.c[6] = rotlFixed(k1, 16);\n    masterCtx_.c[1] = (k0&0xFFFF0000) | (k1&0xFFFF);\n    masterCtx_.c[3] = (k1&0xFFFF0000) | (k2&0xFFFF);\n    masterCtx_.c[5] = (k2&0xFFFF0000) | (k3&0xFFFF);\n    masterCtx_.c[7] = (k3&0xFFFF0000) | (k0&0xFFFF);\n\n    /* Clear carry bit */\n    masterCtx_.carry = 0;\n\n    /* Iterate the system four times */\n    for (i=0; i<4; i++)\n        NextState(Master);\n\n    /* Modify the counters */\n    for (i=0; i<8; i++)\n        masterCtx_.c[i] ^= masterCtx_.x[(i+4)&0x7];\n\n    /* Copy master instance to work instance */\n    for (i=0; i<8; i++) {\n        workCtx_.x[i] = masterCtx_.x[i];\n        workCtx_.c[i] = masterCtx_.c[i];\n    }\n    workCtx_.carry = masterCtx_.carry;\n\n    if (iv) SetIV(iv);    \n}\n\n\n/* Encrypt/decrypt a message of any size */\nvoid Rabbit::Process(byte* output, const byte* input, word32 msglen)\n{\n    /* Temporary variables */\n    word32 i;\n\n    /* Encrypt/decrypt all full blocks */\n    while (msglen >= 16) {\n        /* Iterate the system */\n        NextState(Work);\n\n        /* Encrypt/decrypt 16 bytes of data */\n        *(word32*)(output+ 0) = *(word32*)(input+ 0) ^\n                   LITTLE32(workCtx_.x[0] ^ (workCtx_.x[5]>>16) ^\n                   U32V(workCtx_.x[3]<<16));\n        *(word32*)(output+ 4) = *(word32*)(input+ 4) ^\n                   LITTLE32(workCtx_.x[2] ^ (workCtx_.x[7]>>16) ^\n                   U32V(workCtx_.x[5]<<16));\n        *(word32*)(output+ 8) = *(word32*)(input+ 8) ^\n                   LITTLE32(workCtx_.x[4] ^ (workCtx_.x[1]>>16) ^\n                   U32V(workCtx_.x[7]<<16));\n        *(word32*)(output+12) = *(word32*)(input+12) ^\n                   LITTLE32(workCtx_.x[6] ^ (workCtx_.x[3]>>16) ^\n                   U32V(workCtx_.x[1]<<16));\n\n        /* Increment pointers and decrement length */\n        input  += 16;\n        output += 16;\n        msglen -= 16;\n    }\n\n    /* Encrypt/decrypt remaining data */\n    if (msglen) {\n\n        word32 tmp[4];\n        byte*  buffer = (byte*)tmp;\n\n        memset(tmp, 0, sizeof(tmp));   /* help static analysis */\n\n        /* Iterate the system */\n        NextState(Work);\n\n        /* Generate 16 bytes of pseudo-random data */\n        tmp[0] = LITTLE32(workCtx_.x[0] ^\n                  (workCtx_.x[5]>>16) ^ U32V(workCtx_.x[3]<<16));\n        tmp[1] = LITTLE32(workCtx_.x[2] ^ \n                  (workCtx_.x[7]>>16) ^ U32V(workCtx_.x[5]<<16));\n        tmp[2] = LITTLE32(workCtx_.x[4] ^ \n                  (workCtx_.x[1]>>16) ^ U32V(workCtx_.x[7]<<16));\n        tmp[3] = LITTLE32(workCtx_.x[6] ^ \n                  (workCtx_.x[3]>>16) ^ U32V(workCtx_.x[1]<<16));\n\n        /* Encrypt/decrypt the data */\n        for (i=0; i<msglen; i++)\n            output[i] = input[i] ^ buffer[i];\n    }\n}\n\n\n}  // namespace\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/random.cpp",
    "content": "/*\n   Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* random.cpp implements a crypto secure Random Number Generator using an OS\n   specific seed, switch to /dev/random for more security but may block\n*/\n\n#include \"runtime.hpp\"\n#include \"random.hpp\"\n#include <string.h>\n#include <time.h>\n\n#if defined(_WIN32)\n    #include <windows.h>\n    #include <wincrypt.h>\n#else\n    #include <errno.h>\n    #include <fcntl.h>\n    #include <unistd.h>\n#endif // _WIN32\n\nnamespace TaoCrypt {\n\n\n// Get seed and key cipher\nRandomNumberGenerator::RandomNumberGenerator()\n{\n    byte key[32];\n    byte junk[256];\n\n    seed_.GenerateSeed(key, sizeof(key));\n    cipher_.SetKey(key, sizeof(key));\n    GenerateBlock(junk, sizeof(junk));  // rid initial state\n}\n\n\n// place a generated block in output\nvoid RandomNumberGenerator::GenerateBlock(byte* output, word32 sz)\n{\n    memset(output, 0, sz);\n    cipher_.Process(output, output, sz);\n}\n\n\nbyte RandomNumberGenerator::GenerateByte()\n{\n    byte b;\n    GenerateBlock(&b, 1);\n\n    return b;\n}\n\n\n#if defined(_WIN32)\n\n/* The OS_Seed implementation for windows */\n\nOS_Seed::OS_Seed()\n{\n    if(!CryptAcquireContext(&handle_, 0, 0, PROV_RSA_FULL,\n                             CRYPT_VERIFYCONTEXT))\n        error_.SetError(WINCRYPT_E);\n}\n\n\nOS_Seed::~OS_Seed()\n{\n    CryptReleaseContext(handle_, 0);\n}\n\n\nvoid OS_Seed::GenerateSeed(byte* output, word32 sz)\n{\n    if (!CryptGenRandom(handle_, sz, output))\n        error_.SetError(CRYPTGEN_E);\n}\n\n\n#else\n\n/* The default OS_Seed implementation */\n\nOS_Seed::OS_Seed()\n{\n    fd_ = open(\"/dev/urandom\",O_RDONLY);\n    if (fd_ == -1) {\n        fd_ = open(\"/dev/random\",O_RDONLY);\n        if (fd_ == -1)\n            error_.SetError(OPEN_RAN_E);\n    }\n}\n\n\nOS_Seed::~OS_Seed() \n{\n    close(fd_);\n}\n\n\n// may block\nvoid OS_Seed::GenerateSeed(byte* output, word32 sz)\n{\n    while (sz) {\n        int len = read(fd_, output, sz);\n        if (len == -1) {\n            error_.SetError(READ_RAN_E);\n            return;\n        }\n\n        sz     -= len;\n        output += len;\n\n        if (sz)\n            sleep(1);\n    }\n}\n\n#endif // _WIN32\n\n\n\n} // namespace\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/ripemd.cpp",
    "content": "/*\n   Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/* based on Wei Dai's ripemd.cpp from CryptoPP */\n\n#include \"runtime.hpp\"\n#include \"ripemd.hpp\"\n#ifdef USE_SYS_STL\n    #include <algorithm>\n#else\n    #include \"algorithm.hpp\"\n#endif\n\n\nnamespace STL = STL_NAMESPACE;\n\n\n\nnamespace TaoCrypt {\n\nvoid RIPEMD160::Init()\n{\n    digest_[0] = 0x67452301L;\n    digest_[1] = 0xefcdab89L;\n    digest_[2] = 0x98badcfeL;\n    digest_[3] = 0x10325476L;\n    digest_[4] = 0xc3d2e1f0L;\n\n    buffLen_ = 0;\n    loLen_  = 0;\n    hiLen_  = 0;\n}\n\n\nRIPEMD160::RIPEMD160(const RIPEMD160& that)\n    : HASHwithTransform(DIGEST_SIZE / sizeof(word32), BLOCK_SIZE) \n{ \n    buffLen_ = that.buffLen_;\n    loLen_   = that.loLen_;\n    hiLen_   = that.hiLen_;\n\n    memcpy(digest_, that.digest_, DIGEST_SIZE);\n    memcpy(buffer_, that.buffer_, BLOCK_SIZE);\n}\n\n\nRIPEMD160& RIPEMD160::operator= (const RIPEMD160& that)\n{\n    RIPEMD160 tmp(that);\n    Swap(tmp);\n\n    return *this;\n}\n\n\nvoid RIPEMD160::Swap(RIPEMD160& other)\n{\n    STL::swap(loLen_,   other.loLen_);\n    STL::swap(hiLen_,   other.hiLen_);\n    STL::swap(buffLen_, other.buffLen_);\n\n    memcpy(digest_, other.digest_, DIGEST_SIZE);\n    memcpy(buffer_, other.buffer_, BLOCK_SIZE);\n}\n\n\n#ifdef DO_RIPEMD_ASM\n\n// Update digest with data of size len\nvoid RIPEMD160::Update(const byte* data, word32 len)\n{\n    if (!isMMX) {\n        HASHwithTransform::Update(data, len);\n        return;\n    }\n\n    byte* local = reinterpret_cast<byte*>(buffer_);\n\n    // remove buffered data if possible\n    if (buffLen_)  {   \n        word32 add = min(len, BLOCK_SIZE - buffLen_);\n        memcpy(&local[buffLen_], data, add);\n\n        buffLen_ += add;\n        data     += add;\n        len      -= add;\n\n        if (buffLen_ == BLOCK_SIZE) {\n            Transform();\n            AddLength(BLOCK_SIZE);\n            buffLen_ = 0;\n        }\n    }\n\n    // all at once for asm\n    if (buffLen_ == 0) {\n        word32 times = len / BLOCK_SIZE;\n        if (times) {\n            AsmTransform(data, times);\n            const word32 add = BLOCK_SIZE * times;\n            AddLength(add);\n            len  -= add;\n            data += add;\n        }\n    }\n\n    // cache any data left\n    if (len) {\n        memcpy(&local[buffLen_], data, len);\n        buffLen_ += len;\n    }\n}\n\n#endif // DO_RIPEMD_ASM\n\n\n// for all\n#define F(x, y, z)    (x ^ y ^ z) \n#define G(x, y, z)    (z ^ (x & (y^z)))\n#define H(x, y, z)    (z ^ (x | ~y))\n#define I(x, y, z)    (y ^ (z & (x^y)))\n#define J(x, y, z)    (x ^ (y | ~z))\n\n#define k0 0\n#define k1 0x5a827999\n#define k2 0x6ed9eba1\n#define k3 0x8f1bbcdc\n#define k4 0xa953fd4e\n#define k5 0x50a28be6\n#define k6 0x5c4dd124\n#define k7 0x6d703ef3\n#define k8 0x7a6d76e9\n#define k9 0\n\n// for 160 and 320\n#define Subround(f, a, b, c, d, e, x, s, k) \\\n    a += f(b, c, d) + x + k;\\\n    a = rotlFixed((word32)a, s) + e;\\\n    c = rotlFixed((word32)c, 10U)\n\n\nvoid RIPEMD160::Transform()\n{\n    unsigned long a1, b1, c1, d1, e1, a2, b2, c2, d2, e2;\n    a1 = a2 = digest_[0];\n    b1 = b2 = digest_[1];\n    c1 = c2 = digest_[2];\n    d1 = d2 = digest_[3];\n    e1 = e2 = digest_[4];\n\n    Subround(F, a1, b1, c1, d1, e1, buffer_[ 0], 11, k0);\n    Subround(F, e1, a1, b1, c1, d1, buffer_[ 1], 14, k0);\n    Subround(F, d1, e1, a1, b1, c1, buffer_[ 2], 15, k0);\n    Subround(F, c1, d1, e1, a1, b1, buffer_[ 3], 12, k0);\n    Subround(F, b1, c1, d1, e1, a1, buffer_[ 4],  5, k0);\n    Subround(F, a1, b1, c1, d1, e1, buffer_[ 5],  8, k0);\n    Subround(F, e1, a1, b1, c1, d1, buffer_[ 6],  7, k0);\n    Subround(F, d1, e1, a1, b1, c1, buffer_[ 7],  9, k0);\n    Subround(F, c1, d1, e1, a1, b1, buffer_[ 8], 11, k0);\n    Subround(F, b1, c1, d1, e1, a1, buffer_[ 9], 13, k0);\n    Subround(F, a1, b1, c1, d1, e1, buffer_[10], 14, k0);\n    Subround(F, e1, a1, b1, c1, d1, buffer_[11], 15, k0);\n    Subround(F, d1, e1, a1, b1, c1, buffer_[12],  6, k0);\n    Subround(F, c1, d1, e1, a1, b1, buffer_[13],  7, k0);\n    Subround(F, b1, c1, d1, e1, a1, buffer_[14],  9, k0);\n    Subround(F, a1, b1, c1, d1, e1, buffer_[15],  8, k0);\n\n    Subround(G, e1, a1, b1, c1, d1, buffer_[ 7],  7, k1);\n    Subround(G, d1, e1, a1, b1, c1, buffer_[ 4],  6, k1);\n    Subround(G, c1, d1, e1, a1, b1, buffer_[13],  8, k1);\n    Subround(G, b1, c1, d1, e1, a1, buffer_[ 1], 13, k1);\n    Subround(G, a1, b1, c1, d1, e1, buffer_[10], 11, k1);\n    Subround(G, e1, a1, b1, c1, d1, buffer_[ 6],  9, k1);\n    Subround(G, d1, e1, a1, b1, c1, buffer_[15],  7, k1);\n    Subround(G, c1, d1, e1, a1, b1, buffer_[ 3], 15, k1);\n    Subround(G, b1, c1, d1, e1, a1, buffer_[12],  7, k1);\n    Subround(G, a1, b1, c1, d1, e1, buffer_[ 0], 12, k1);\n    Subround(G, e1, a1, b1, c1, d1, buffer_[ 9], 15, k1);\n    Subround(G, d1, e1, a1, b1, c1, buffer_[ 5],  9, k1);\n    Subround(G, c1, d1, e1, a1, b1, buffer_[ 2], 11, k1);\n    Subround(G, b1, c1, d1, e1, a1, buffer_[14],  7, k1);\n    Subround(G, a1, b1, c1, d1, e1, buffer_[11], 13, k1);\n    Subround(G, e1, a1, b1, c1, d1, buffer_[ 8], 12, k1);\n\n    Subround(H, d1, e1, a1, b1, c1, buffer_[ 3], 11, k2);\n    Subround(H, c1, d1, e1, a1, b1, buffer_[10], 13, k2);\n    Subround(H, b1, c1, d1, e1, a1, buffer_[14],  6, k2);\n    Subround(H, a1, b1, c1, d1, e1, buffer_[ 4],  7, k2);\n    Subround(H, e1, a1, b1, c1, d1, buffer_[ 9], 14, k2);\n    Subround(H, d1, e1, a1, b1, c1, buffer_[15],  9, k2);\n    Subround(H, c1, d1, e1, a1, b1, buffer_[ 8], 13, k2);\n    Subround(H, b1, c1, d1, e1, a1, buffer_[ 1], 15, k2);\n    Subround(H, a1, b1, c1, d1, e1, buffer_[ 2], 14, k2);\n    Subround(H, e1, a1, b1, c1, d1, buffer_[ 7],  8, k2);\n    Subround(H, d1, e1, a1, b1, c1, buffer_[ 0], 13, k2);\n    Subround(H, c1, d1, e1, a1, b1, buffer_[ 6],  6, k2);\n    Subround(H, b1, c1, d1, e1, a1, buffer_[13],  5, k2);\n    Subround(H, a1, b1, c1, d1, e1, buffer_[11], 12, k2);\n    Subround(H, e1, a1, b1, c1, d1, buffer_[ 5],  7, k2);\n    Subround(H, d1, e1, a1, b1, c1, buffer_[12],  5, k2);\n\n    Subround(I, c1, d1, e1, a1, b1, buffer_[ 1], 11, k3);\n    Subround(I, b1, c1, d1, e1, a1, buffer_[ 9], 12, k3);\n    Subround(I, a1, b1, c1, d1, e1, buffer_[11], 14, k3);\n    Subround(I, e1, a1, b1, c1, d1, buffer_[10], 15, k3);\n    Subround(I, d1, e1, a1, b1, c1, buffer_[ 0], 14, k3);\n    Subround(I, c1, d1, e1, a1, b1, buffer_[ 8], 15, k3);\n    Subround(I, b1, c1, d1, e1, a1, buffer_[12],  9, k3);\n    Subround(I, a1, b1, c1, d1, e1, buffer_[ 4],  8, k3);\n    Subround(I, e1, a1, b1, c1, d1, buffer_[13],  9, k3);\n    Subround(I, d1, e1, a1, b1, c1, buffer_[ 3], 14, k3);\n    Subround(I, c1, d1, e1, a1, b1, buffer_[ 7],  5, k3);\n    Subround(I, b1, c1, d1, e1, a1, buffer_[15],  6, k3);\n    Subround(I, a1, b1, c1, d1, e1, buffer_[14],  8, k3);\n    Subround(I, e1, a1, b1, c1, d1, buffer_[ 5],  6, k3);\n    Subround(I, d1, e1, a1, b1, c1, buffer_[ 6],  5, k3);\n    Subround(I, c1, d1, e1, a1, b1, buffer_[ 2], 12, k3);\n\n    Subround(J, b1, c1, d1, e1, a1, buffer_[ 4],  9, k4);\n    Subround(J, a1, b1, c1, d1, e1, buffer_[ 0], 15, k4);\n    Subround(J, e1, a1, b1, c1, d1, buffer_[ 5],  5, k4);\n    Subround(J, d1, e1, a1, b1, c1, buffer_[ 9], 11, k4);\n    Subround(J, c1, d1, e1, a1, b1, buffer_[ 7],  6, k4);\n    Subround(J, b1, c1, d1, e1, a1, buffer_[12],  8, k4);\n    Subround(J, a1, b1, c1, d1, e1, buffer_[ 2], 13, k4);\n    Subround(J, e1, a1, b1, c1, d1, buffer_[10], 12, k4);\n    Subround(J, d1, e1, a1, b1, c1, buffer_[14],  5, k4);\n    Subround(J, c1, d1, e1, a1, b1, buffer_[ 1], 12, k4);\n    Subround(J, b1, c1, d1, e1, a1, buffer_[ 3], 13, k4);\n    Subround(J, a1, b1, c1, d1, e1, buffer_[ 8], 14, k4);\n    Subround(J, e1, a1, b1, c1, d1, buffer_[11], 11, k4);\n    Subround(J, d1, e1, a1, b1, c1, buffer_[ 6],  8, k4);\n    Subround(J, c1, d1, e1, a1, b1, buffer_[15],  5, k4);\n    Subround(J, b1, c1, d1, e1, a1, buffer_[13],  6, k4);\n\n    Subround(J, a2, b2, c2, d2, e2, buffer_[ 5],  8, k5);\n    Subround(J, e2, a2, b2, c2, d2, buffer_[14],  9, k5);\n    Subround(J, d2, e2, a2, b2, c2, buffer_[ 7],  9, k5);\n    Subround(J, c2, d2, e2, a2, b2, buffer_[ 0], 11, k5);\n    Subround(J, b2, c2, d2, e2, a2, buffer_[ 9], 13, k5);\n    Subround(J, a2, b2, c2, d2, e2, buffer_[ 2], 15, k5);\n    Subround(J, e2, a2, b2, c2, d2, buffer_[11], 15, k5);\n    Subround(J, d2, e2, a2, b2, c2, buffer_[ 4],  5, k5);\n    Subround(J, c2, d2, e2, a2, b2, buffer_[13],  7, k5);\n    Subround(J, b2, c2, d2, e2, a2, buffer_[ 6],  7, k5);\n    Subround(J, a2, b2, c2, d2, e2, buffer_[15],  8, k5);\n    Subround(J, e2, a2, b2, c2, d2, buffer_[ 8], 11, k5);\n    Subround(J, d2, e2, a2, b2, c2, buffer_[ 1], 14, k5);\n    Subround(J, c2, d2, e2, a2, b2, buffer_[10], 14, k5);\n    Subround(J, b2, c2, d2, e2, a2, buffer_[ 3], 12, k5);\n    Subround(J, a2, b2, c2, d2, e2, buffer_[12],  6, k5);\n\n    Subround(I, e2, a2, b2, c2, d2, buffer_[ 6],  9, k6); \n    Subround(I, d2, e2, a2, b2, c2, buffer_[11], 13, k6);\n    Subround(I, c2, d2, e2, a2, b2, buffer_[ 3], 15, k6);\n    Subround(I, b2, c2, d2, e2, a2, buffer_[ 7],  7, k6);\n    Subround(I, a2, b2, c2, d2, e2, buffer_[ 0], 12, k6);\n    Subround(I, e2, a2, b2, c2, d2, buffer_[13],  8, k6);\n    Subround(I, d2, e2, a2, b2, c2, buffer_[ 5],  9, k6);\n    Subround(I, c2, d2, e2, a2, b2, buffer_[10], 11, k6);\n    Subround(I, b2, c2, d2, e2, a2, buffer_[14],  7, k6);\n    Subround(I, a2, b2, c2, d2, e2, buffer_[15],  7, k6);\n    Subround(I, e2, a2, b2, c2, d2, buffer_[ 8], 12, k6);\n    Subround(I, d2, e2, a2, b2, c2, buffer_[12],  7, k6);\n    Subround(I, c2, d2, e2, a2, b2, buffer_[ 4],  6, k6);\n    Subround(I, b2, c2, d2, e2, a2, buffer_[ 9], 15, k6);\n    Subround(I, a2, b2, c2, d2, e2, buffer_[ 1], 13, k6);\n    Subround(I, e2, a2, b2, c2, d2, buffer_[ 2], 11, k6);\n\n    Subround(H, d2, e2, a2, b2, c2, buffer_[15],  9, k7);\n    Subround(H, c2, d2, e2, a2, b2, buffer_[ 5],  7, k7);\n    Subround(H, b2, c2, d2, e2, a2, buffer_[ 1], 15, k7);\n    Subround(H, a2, b2, c2, d2, e2, buffer_[ 3], 11, k7);\n    Subround(H, e2, a2, b2, c2, d2, buffer_[ 7],  8, k7);\n    Subround(H, d2, e2, a2, b2, c2, buffer_[14],  6, k7);\n    Subround(H, c2, d2, e2, a2, b2, buffer_[ 6],  6, k7);\n    Subround(H, b2, c2, d2, e2, a2, buffer_[ 9], 14, k7);\n    Subround(H, a2, b2, c2, d2, e2, buffer_[11], 12, k7);\n    Subround(H, e2, a2, b2, c2, d2, buffer_[ 8], 13, k7);\n    Subround(H, d2, e2, a2, b2, c2, buffer_[12],  5, k7);\n    Subround(H, c2, d2, e2, a2, b2, buffer_[ 2], 14, k7);\n    Subround(H, b2, c2, d2, e2, a2, buffer_[10], 13, k7);\n    Subround(H, a2, b2, c2, d2, e2, buffer_[ 0], 13, k7);\n    Subround(H, e2, a2, b2, c2, d2, buffer_[ 4],  7, k7);\n    Subround(H, d2, e2, a2, b2, c2, buffer_[13],  5, k7);\n\n    Subround(G, c2, d2, e2, a2, b2, buffer_[ 8], 15, k8);\n    Subround(G, b2, c2, d2, e2, a2, buffer_[ 6],  5, k8);\n    Subround(G, a2, b2, c2, d2, e2, buffer_[ 4],  8, k8);\n    Subround(G, e2, a2, b2, c2, d2, buffer_[ 1], 11, k8);\n    Subround(G, d2, e2, a2, b2, c2, buffer_[ 3], 14, k8);\n    Subround(G, c2, d2, e2, a2, b2, buffer_[11], 14, k8);\n    Subround(G, b2, c2, d2, e2, a2, buffer_[15],  6, k8);\n    Subround(G, a2, b2, c2, d2, e2, buffer_[ 0], 14, k8);\n    Subround(G, e2, a2, b2, c2, d2, buffer_[ 5],  6, k8);\n    Subround(G, d2, e2, a2, b2, c2, buffer_[12],  9, k8);\n    Subround(G, c2, d2, e2, a2, b2, buffer_[ 2], 12, k8);\n    Subround(G, b2, c2, d2, e2, a2, buffer_[13],  9, k8);\n    Subround(G, a2, b2, c2, d2, e2, buffer_[ 9], 12, k8);\n    Subround(G, e2, a2, b2, c2, d2, buffer_[ 7],  5, k8);\n    Subround(G, d2, e2, a2, b2, c2, buffer_[10], 15, k8);\n    Subround(G, c2, d2, e2, a2, b2, buffer_[14],  8, k8);\n\n    Subround(F, b2, c2, d2, e2, a2, buffer_[12],  8, k9);\n    Subround(F, a2, b2, c2, d2, e2, buffer_[15],  5, k9);\n    Subround(F, e2, a2, b2, c2, d2, buffer_[10], 12, k9);\n    Subround(F, d2, e2, a2, b2, c2, buffer_[ 4],  9, k9);\n    Subround(F, c2, d2, e2, a2, b2, buffer_[ 1], 12, k9);\n    Subround(F, b2, c2, d2, e2, a2, buffer_[ 5],  5, k9);\n    Subround(F, a2, b2, c2, d2, e2, buffer_[ 8], 14, k9);\n    Subround(F, e2, a2, b2, c2, d2, buffer_[ 7],  6, k9);\n    Subround(F, d2, e2, a2, b2, c2, buffer_[ 6],  8, k9);\n    Subround(F, c2, d2, e2, a2, b2, buffer_[ 2], 13, k9);\n    Subround(F, b2, c2, d2, e2, a2, buffer_[13],  6, k9);\n    Subround(F, a2, b2, c2, d2, e2, buffer_[14],  5, k9);\n    Subround(F, e2, a2, b2, c2, d2, buffer_[ 0], 15, k9);\n    Subround(F, d2, e2, a2, b2, c2, buffer_[ 3], 13, k9);\n    Subround(F, c2, d2, e2, a2, b2, buffer_[ 9], 11, k9);\n    Subround(F, b2, c2, d2, e2, a2, buffer_[11], 11, k9);\n\n    c1         = digest_[1] + c1 + d2;\n    digest_[1] = digest_[2] + d1 + e2;\n    digest_[2] = digest_[3] + e1 + a2;\n    digest_[3] = digest_[4] + a1 + b2;\n    digest_[4] = digest_[0] + b1 + c2;\n    digest_[0] = c1;\n}\n\n\n#ifdef DO_RIPEMD_ASM\n\n/*\n    // F(x ^ y ^ z)\n    // place in esi\n#define ASMF(x, y, z)  \\\n    AS2(    mov   esi, x                )   \\\n    AS2(    xor   esi, y                )   \\\n    AS2(    xor   esi, z                )\n\n\n    // G(z ^ (x & (y^z)))\n    // place in esi\n#define ASMG(x, y, z)  \\\n    AS2(    mov   esi, z                )   \\\n    AS2(    xor   esi, y                )   \\\n    AS2(    and   esi, x                )   \\\n    AS2(    xor   esi, z                )\n\n    \n    // H(z ^ (x | ~y))\n    // place in esi\n#define ASMH(x, y, z) \\\n    AS2(    mov   esi, y                )   \\\n    AS1(    not   esi                   )   \\\n    AS2(     or   esi, x                )   \\\n    AS2(    xor   esi, z                )\n\n\n    // I(y ^ (z & (x^y)))\n    // place in esi\n#define ASMI(x, y, z)  \\\n    AS2(    mov   esi, y                )   \\\n    AS2(    xor   esi, x                )   \\\n    AS2(    and   esi, z                )   \\\n    AS2(    xor   esi, y                )\n\n\n    // J(x ^ (y | ~z)))\n    // place in esi\n#define ASMJ(x, y, z)   \\\n    AS2(    mov   esi, z                )   \\\n    AS1(    not   esi                   )   \\\n    AS2(     or   esi, y                )   \\\n    AS2(    xor   esi, x                )\n\n\n// for 160 and 320\n// #define ASMSubround(f, a, b, c, d, e, i, s, k) \n//    a += f(b, c, d) + data[i] + k;\n//    a = rotlFixed((word32)a, s) + e;\n//    c = rotlFixed((word32)c, 10U)\n\n#define ASMSubround(f, a, b, c, d, e, index, s, k) \\\n    // a += f(b, c, d) + data[i] + k                    \\\n    AS2(    mov   esp, [edi + index * 4]            )   \\\n    f(b, c, d)                                          \\\n    AS2(    add   esi, k                            )   \\\n    AS2(    add   esi, esp                          )   \\\n    AS2(    add     a, esi                          )   \\\n    // a = rotlFixed((word32)a, s) + e                  \\\n    AS2(    rol     a, s                            )   \\\n    AS2(    rol     c, 10                           )   \\\n    // c = rotlFixed((word32)c, 10U)                    \\\n    AS2(    add     a, e                            )\n*/\n\n\n// combine F into subround w/ setup\n// esi already has c, setup for next round when done\n// esp already has edi[index], setup for next round when done\n\n#define ASMSubroundF(a, b, c, d, e, index, s) \\\n    /* a += (b ^ c ^ d) + data[i] + k  */               \\\n    AS2(    xor   esi, b                            )   \\\n    AS2(    add     a, [edi + index * 4]            )   \\\n    AS2(    xor   esi, d                            )   \\\n    AS2(    add     a, esi                          )   \\\n    /* a = rotlFixed((word32)a, s) + e */               \\\n    AS2(    mov   esi, b                            )   \\\n    AS2(    rol     a, s                            )   \\\n    /* c = rotlFixed((word32)c, 10U) */                 \\\n    AS2(    rol     c, 10                           )   \\\n    AS2(    add     a, e                            )\n\n\n// combine G into subround w/ setup\n// esi already has c, setup for next round when done\n// esp already has edi[index], setup for next round when done\n\n#define ASMSubroundG(a, b, c, d, e, index, s, k) \\\n    /* a += (d ^ (b & (c^d))) + data[i] + k  */         \\\n    AS2(    xor   esi, d                            )   \\\n    AS2(    and   esi, b                            )   \\\n    AS2(    add     a, [edi + index * 4]            )   \\\n    AS2(    xor   esi, d                            )   \\\n    AS2(    lea     a, [esi + a + k]                )   \\\n    /* a = rotlFixed((word32)a, s) + e */               \\\n    AS2(    mov   esi, b                            )   \\\n    AS2(    rol     a, s                            )   \\\n    /* c = rotlFixed((word32)c, 10U) */                 \\\n    AS2(    rol     c, 10                           )   \\\n    AS2(    add     a, e                            )\n\n\n// combine H into subround w/ setup\n// esi already has c, setup for next round when done\n// esp already has edi[index], setup for next round when done\n\n#define ASMSubroundH(a, b, c, d, e, index, s, k) \\\n    /* a += (d ^ (b | ~c)) + data[i] + k  */            \\\n    AS1(    not   esi                               )   \\\n    AS2(     or   esi, b                            )   \\\n    AS2(    add     a, [edi + index * 4]            )   \\\n    AS2(    xor   esi, d                            )   \\\n    AS2(    lea     a, [esi + a + k]                )   \\\n    /* a = rotlFixed((word32)a, s) + e */               \\\n    AS2(    mov   esi, b                            )   \\\n    AS2(    rol     a, s                            )   \\\n    /* c = rotlFixed((word32)c, 10U) */                 \\\n    AS2(    rol     c, 10                           )   \\\n    AS2(    add     a, e                            )\n\n\n// combine I into subround w/ setup\n// esi already has c, setup for next round when done\n// esp already has edi[index], setup for next round when done\n\n#define ASMSubroundI(a, b, c, d, e, index, s, k) \\\n    /* a += (c ^ (d & (b^c))) + data[i] + k  */         \\\n    AS2(    xor   esi, b                            )   \\\n    AS2(    and   esi, d                            )   \\\n    AS2(    add     a, [edi + index * 4]            )   \\\n    AS2(    xor   esi, c                            )   \\\n    AS2(    lea     a, [esi + a + k]                )   \\\n    /* a = rotlFixed((word32)a, s) + e */               \\\n    AS2(    mov   esi, b                            )   \\\n    AS2(    rol     a, s                            )   \\\n    /* c = rotlFixed((word32)c, 10U) */                 \\\n    AS2(    rol     c, 10                           )   \\\n    AS2(    add     a, e                            )\n\n\n// combine J into subround w/ setup\n// esi already has d, setup for next round when done\n// esp already has edi[index], setup for next round when done\n\n#define ASMSubroundJ(a, b, c, d, e, index, s, k) \\\n    /* a += (b ^ (c | ~d))) + data[i] + k  */           \\\n    AS1(    not   esi                               )   \\\n    AS2(     or   esi, c                            )   \\\n    /* c = rotlFixed((word32)c, 10U) */                 \\\n    AS2(    add     a, [edi + index * 4]            )   \\\n    AS2(    xor   esi, b                            )   \\\n    AS2(    rol     c, 10                           )   \\\n    AS2(    lea     a, [esi + a + k]                )   \\\n    /* a = rotlFixed((word32)a, s) + e */               \\\n    AS2(    rol     a, s                            )   \\\n    AS2(    mov   esi, c                            )   \\\n    AS2(    add     a, e                            )\n\n\n#ifdef _MSC_VER\n    __declspec(naked) \n#else\n    __attribute__ ((noinline))\n#endif\nvoid RIPEMD160::AsmTransform(const byte* data, word32 times)\n{\n#ifdef __GNUC__\n    #define AS1(x)    #x \";\"\n    #define AS2(x, y) #x \", \" #y \";\"\n\n    #define PROLOG()  \\\n    __asm__ __volatile__ \\\n    ( \\\n        \".intel_syntax noprefix;\" \\\n        \"push ebx;\" \\\n        \"push ebp;\"\n    #define EPILOG()  \\\n        \"pop ebp;\" \\\n        \"pop ebx;\" \\\n       \t\"emms;\" \\\n       \t\".att_syntax;\" \\\n            : \\\n            : \"c\" (this), \"D\" (data), \"d\" (times) \\\n            : \"%esi\", \"%eax\", \"memory\", \"cc\" \\\n    );\n\n#else\n    #define AS1(x)    __asm x\n    #define AS2(x, y) __asm x, y\n\n    #define PROLOG() \\\n        AS1(    push  ebp                       )   \\\n        AS2(    mov   ebp, esp                  )   \\\n        AS2(    movd  mm3, edi                  )   \\\n        AS2(    movd  mm4, ebx                  )   \\\n        AS2(    movd  mm5, esi                  )   \\\n        AS2(    movd  mm6, ebp                  )   \\\n        AS2(    mov   edi, DWORD PTR [ebp +  8] )   \\\n        AS2(    mov   edx, DWORD PTR [ebp + 12] )\n\n    #define EPILOG() \\\n        AS2(    movd  ebp, mm6                  )   \\\n        AS2(    movd  esi, mm5                  )   \\\n        AS2(    movd  ebx, mm4                  )   \\\n        AS2(    movd  edi, mm3                  )   \\\n        AS2(    mov   esp, ebp                  )   \\\n        AS1(    pop   ebp                       )   \\\n        AS1(    emms                            )   \\\n        AS1(    ret   8                         )\n        \n#endif\n\n    PROLOG()\n\n    #ifdef OLD_GCC_OFFSET\n        AS2(    lea   esi, [ecx + 20]               )   // digest_[0]\n    #else\n        AS2(    lea   esi, [ecx + 16]               )   // digest_[0]\n    #endif\n\n    AS2(    sub   esp, 24               )   // make room for tmp a1 - e1\n    AS2(    movd  mm1, esi              )   // store digest_\n    \n#ifdef _MSC_VER\n    AS1( loopStart: )  // loopStart\n#else\n    AS1( 0: )          // loopStart for some gas (need numeric for jump back \n#endif\n\n    AS2(    movd  mm2, edx              )   // store times_\n\n    AS2(    mov   eax, [esi]            )   // a1\n    AS2(    mov   ebx, [esi +  4]       )   // b1\n    AS2(    mov   ecx, [esi +  8]       )   // c1\n    AS2(    mov   edx, [esi + 12]       )   // d1\n    AS2(    mov   ebp, [esi + 16]       )   // e1\n\n    // setup \n    AS2(    mov   esi, ecx      )\n\n    ASMSubroundF( eax, ebx, ecx, edx, ebp,  0, 11)\n    ASMSubroundF( ebp, eax, ebx, ecx, edx,  1, 14)\n    ASMSubroundF( edx, ebp, eax, ebx, ecx,  2, 15)\n    ASMSubroundF( ecx, edx, ebp, eax, ebx,  3, 12)\n    ASMSubroundF( ebx, ecx, edx, ebp, eax,  4,  5)\n    ASMSubroundF( eax, ebx, ecx, edx, ebp,  5,  8)\n    ASMSubroundF( ebp, eax, ebx, ecx, edx,  6,  7)\n    ASMSubroundF( edx, ebp, eax, ebx, ecx,  7,  9)\n    ASMSubroundF( ecx, edx, ebp, eax, ebx,  8, 11)\n    ASMSubroundF( ebx, ecx, edx, ebp, eax,  9, 13)\n    ASMSubroundF( eax, ebx, ecx, edx, ebp, 10, 14)\n    ASMSubroundF( ebp, eax, ebx, ecx, edx, 11, 15)\n    ASMSubroundF( edx, ebp, eax, ebx, ecx, 12,  6)\n    ASMSubroundF( ecx, edx, ebp, eax, ebx, 13,  7)\n    ASMSubroundF( ebx, ecx, edx, ebp, eax, 14,  9)\n    ASMSubroundF( eax, ebx, ecx, edx, ebp, 15,  8)\n\n    ASMSubroundG( ebp, eax, ebx, ecx, edx,  7,  7, k1)\n    ASMSubroundG( edx, ebp, eax, ebx, ecx,  4,  6, k1)\n    ASMSubroundG( ecx, edx, ebp, eax, ebx, 13,  8, k1)\n    ASMSubroundG( ebx, ecx, edx, ebp, eax,  1, 13, k1)\n    ASMSubroundG( eax, ebx, ecx, edx, ebp, 10, 11, k1)\n    ASMSubroundG( ebp, eax, ebx, ecx, edx,  6,  9, k1)\n    ASMSubroundG( edx, ebp, eax, ebx, ecx, 15,  7, k1)\n    ASMSubroundG( ecx, edx, ebp, eax, ebx,  3, 15, k1)\n    ASMSubroundG( ebx, ecx, edx, ebp, eax, 12,  7, k1)\n    ASMSubroundG( eax, ebx, ecx, edx, ebp,  0, 12, k1)\n    ASMSubroundG( ebp, eax, ebx, ecx, edx,  9, 15, k1)\n    ASMSubroundG( edx, ebp, eax, ebx, ecx,  5,  9, k1)\n    ASMSubroundG( ecx, edx, ebp, eax, ebx,  2, 11, k1)\n    ASMSubroundG( ebx, ecx, edx, ebp, eax, 14,  7, k1)\n    ASMSubroundG( eax, ebx, ecx, edx, ebp, 11, 13, k1)\n    ASMSubroundG( ebp, eax, ebx, ecx, edx,  8, 12, k1)\n\n    ASMSubroundH( edx, ebp, eax, ebx, ecx,  3, 11, k2)\n    ASMSubroundH( ecx, edx, ebp, eax, ebx, 10, 13, k2)\n    ASMSubroundH( ebx, ecx, edx, ebp, eax, 14,  6, k2)\n    ASMSubroundH( eax, ebx, ecx, edx, ebp,  4,  7, k2)\n    ASMSubroundH( ebp, eax, ebx, ecx, edx,  9, 14, k2)\n    ASMSubroundH( edx, ebp, eax, ebx, ecx, 15,  9, k2)\n    ASMSubroundH( ecx, edx, ebp, eax, ebx,  8, 13, k2)\n    ASMSubroundH( ebx, ecx, edx, ebp, eax,  1, 15, k2)\n    ASMSubroundH( eax, ebx, ecx, edx, ebp,  2, 14, k2)\n    ASMSubroundH( ebp, eax, ebx, ecx, edx,  7,  8, k2)\n    ASMSubroundH( edx, ebp, eax, ebx, ecx,  0, 13, k2)\n    ASMSubroundH( ecx, edx, ebp, eax, ebx,  6,  6, k2)\n    ASMSubroundH( ebx, ecx, edx, ebp, eax, 13,  5, k2)\n    ASMSubroundH( eax, ebx, ecx, edx, ebp, 11, 12, k2)\n    ASMSubroundH( ebp, eax, ebx, ecx, edx,  5,  7, k2)\n    ASMSubroundH( edx, ebp, eax, ebx, ecx, 12,  5, k2)\n\n    ASMSubroundI( ecx, edx, ebp, eax, ebx,  1, 11, k3)\n    ASMSubroundI( ebx, ecx, edx, ebp, eax,  9, 12, k3)\n    ASMSubroundI( eax, ebx, ecx, edx, ebp, 11, 14, k3)\n    ASMSubroundI( ebp, eax, ebx, ecx, edx, 10, 15, k3)\n    ASMSubroundI( edx, ebp, eax, ebx, ecx,  0, 14, k3)\n    ASMSubroundI( ecx, edx, ebp, eax, ebx,  8, 15, k3)\n    ASMSubroundI( ebx, ecx, edx, ebp, eax, 12,  9, k3)\n    ASMSubroundI( eax, ebx, ecx, edx, ebp,  4,  8, k3)\n    ASMSubroundI( ebp, eax, ebx, ecx, edx, 13,  9, k3)\n    ASMSubroundI( edx, ebp, eax, ebx, ecx,  3, 14, k3)\n    ASMSubroundI( ecx, edx, ebp, eax, ebx,  7,  5, k3)\n    ASMSubroundI( ebx, ecx, edx, ebp, eax, 15,  6, k3)\n    ASMSubroundI( eax, ebx, ecx, edx, ebp, 14,  8, k3)\n    ASMSubroundI( ebp, eax, ebx, ecx, edx,  5,  6, k3)\n    ASMSubroundI( edx, ebp, eax, ebx, ecx,  6,  5, k3)\n    ASMSubroundI( ecx, edx, ebp, eax, ebx,  2, 12, k3)\n\n    // setup\n    AS2(    mov   esi, ebp      )\n\n    ASMSubroundJ( ebx, ecx, edx, ebp, eax,  4,  9, k4)\n    ASMSubroundJ( eax, ebx, ecx, edx, ebp,  0, 15, k4)\n    ASMSubroundJ( ebp, eax, ebx, ecx, edx,  5,  5, k4)\n    ASMSubroundJ( edx, ebp, eax, ebx, ecx,  9, 11, k4)\n    ASMSubroundJ( ecx, edx, ebp, eax, ebx,  7,  6, k4)\n    ASMSubroundJ( ebx, ecx, edx, ebp, eax, 12,  8, k4)\n    ASMSubroundJ( eax, ebx, ecx, edx, ebp,  2, 13, k4)\n    ASMSubroundJ( ebp, eax, ebx, ecx, edx, 10, 12, k4)\n    ASMSubroundJ( edx, ebp, eax, ebx, ecx, 14,  5, k4)\n    ASMSubroundJ( ecx, edx, ebp, eax, ebx,  1, 12, k4)\n    ASMSubroundJ( ebx, ecx, edx, ebp, eax,  3, 13, k4)\n    ASMSubroundJ( eax, ebx, ecx, edx, ebp,  8, 14, k4)\n    ASMSubroundJ( ebp, eax, ebx, ecx, edx, 11, 11, k4)\n    ASMSubroundJ( edx, ebp, eax, ebx, ecx,  6,  8, k4)\n    ASMSubroundJ( ecx, edx, ebp, eax, ebx, 15,  5, k4)\n    ASMSubroundJ( ebx, ecx, edx, ebp, eax, 13,  6, k4)\n\n    // store a1 - e1 on stack\n    AS2(    movd  esi, mm1              )   // digest_\n\n    AS2(    mov   [esp],      eax       )\n    AS2(    mov   [esp +  4], ebx       )\n    AS2(    mov   [esp +  8], ecx       )\n    AS2(    mov   [esp + 12], edx       )\n    AS2(    mov   [esp + 16], ebp       )\n\n    AS2(    mov   eax, [esi]            )   // a2\n    AS2(    mov   ebx, [esi +  4]       )   // b2\n    AS2(    mov   ecx, [esi +  8]       )   // c2\n    AS2(    mov   edx, [esi + 12]       )   // d2\n    AS2(    mov   ebp, [esi + 16]       )   // e2\n\n\n    // setup\n    AS2(    mov   esi, edx      )\n\n    ASMSubroundJ( eax, ebx, ecx, edx, ebp,  5,  8, k5)\n    ASMSubroundJ( ebp, eax, ebx, ecx, edx, 14,  9, k5)\n    ASMSubroundJ( edx, ebp, eax, ebx, ecx,  7,  9, k5)\n    ASMSubroundJ( ecx, edx, ebp, eax, ebx,  0, 11, k5)\n    ASMSubroundJ( ebx, ecx, edx, ebp, eax,  9, 13, k5)\n    ASMSubroundJ( eax, ebx, ecx, edx, ebp,  2, 15, k5)\n    ASMSubroundJ( ebp, eax, ebx, ecx, edx, 11, 15, k5)\n    ASMSubroundJ( edx, ebp, eax, ebx, ecx,  4,  5, k5)\n    ASMSubroundJ( ecx, edx, ebp, eax, ebx, 13,  7, k5)\n    ASMSubroundJ( ebx, ecx, edx, ebp, eax,  6,  7, k5)\n    ASMSubroundJ( eax, ebx, ecx, edx, ebp, 15,  8, k5)\n    ASMSubroundJ( ebp, eax, ebx, ecx, edx,  8, 11, k5)\n    ASMSubroundJ( edx, ebp, eax, ebx, ecx,  1, 14, k5)\n    ASMSubroundJ( ecx, edx, ebp, eax, ebx, 10, 14, k5)\n    ASMSubroundJ( ebx, ecx, edx, ebp, eax,  3, 12, k5)\n    ASMSubroundJ( eax, ebx, ecx, edx, ebp, 12,  6, k5)\n\n    // setup\n    AS2(    mov   esi, ebx      )\n\n    ASMSubroundI( ebp, eax, ebx, ecx, edx,  6,  9, k6) \n    ASMSubroundI( edx, ebp, eax, ebx, ecx, 11, 13, k6)\n    ASMSubroundI( ecx, edx, ebp, eax, ebx,  3, 15, k6)\n    ASMSubroundI( ebx, ecx, edx, ebp, eax,  7,  7, k6)\n    ASMSubroundI( eax, ebx, ecx, edx, ebp,  0, 12, k6)\n    ASMSubroundI( ebp, eax, ebx, ecx, edx, 13,  8, k6)\n    ASMSubroundI( edx, ebp, eax, ebx, ecx,  5,  9, k6)\n    ASMSubroundI( ecx, edx, ebp, eax, ebx, 10, 11, k6)\n    ASMSubroundI( ebx, ecx, edx, ebp, eax, 14,  7, k6)\n    ASMSubroundI( eax, ebx, ecx, edx, ebp, 15,  7, k6)\n    ASMSubroundI( ebp, eax, ebx, ecx, edx,  8, 12, k6)\n    ASMSubroundI( edx, ebp, eax, ebx, ecx, 12,  7, k6)\n    ASMSubroundI( ecx, edx, ebp, eax, ebx,  4,  6, k6)\n    ASMSubroundI( ebx, ecx, edx, ebp, eax,  9, 15, k6)\n    ASMSubroundI( eax, ebx, ecx, edx, ebp,  1, 13, k6)\n    ASMSubroundI( ebp, eax, ebx, ecx, edx,  2, 11, k6)\n\n    ASMSubroundH( edx, ebp, eax, ebx, ecx, 15,  9, k7)\n    ASMSubroundH( ecx, edx, ebp, eax, ebx,  5,  7, k7)\n    ASMSubroundH( ebx, ecx, edx, ebp, eax,  1, 15, k7)\n    ASMSubroundH( eax, ebx, ecx, edx, ebp,  3, 11, k7)\n    ASMSubroundH( ebp, eax, ebx, ecx, edx,  7,  8, k7)\n    ASMSubroundH( edx, ebp, eax, ebx, ecx, 14,  6, k7)\n    ASMSubroundH( ecx, edx, ebp, eax, ebx,  6,  6, k7)\n    ASMSubroundH( ebx, ecx, edx, ebp, eax,  9, 14, k7)\n    ASMSubroundH( eax, ebx, ecx, edx, ebp, 11, 12, k7)\n    ASMSubroundH( ebp, eax, ebx, ecx, edx,  8, 13, k7)\n    ASMSubroundH( edx, ebp, eax, ebx, ecx, 12,  5, k7)\n    ASMSubroundH( ecx, edx, ebp, eax, ebx,  2, 14, k7)\n    ASMSubroundH( ebx, ecx, edx, ebp, eax, 10, 13, k7)\n    ASMSubroundH( eax, ebx, ecx, edx, ebp,  0, 13, k7)\n    ASMSubroundH( ebp, eax, ebx, ecx, edx,  4,  7, k7)\n    ASMSubroundH( edx, ebp, eax, ebx, ecx, 13,  5, k7)\n\n    ASMSubroundG( ecx, edx, ebp, eax, ebx,  8, 15, k8)\n    ASMSubroundG( ebx, ecx, edx, ebp, eax,  6,  5, k8)\n    ASMSubroundG( eax, ebx, ecx, edx, ebp,  4,  8, k8)\n    ASMSubroundG( ebp, eax, ebx, ecx, edx,  1, 11, k8)\n    ASMSubroundG( edx, ebp, eax, ebx, ecx,  3, 14, k8)\n    ASMSubroundG( ecx, edx, ebp, eax, ebx, 11, 14, k8)\n    ASMSubroundG( ebx, ecx, edx, ebp, eax, 15,  6, k8)\n    ASMSubroundG( eax, ebx, ecx, edx, ebp,  0, 14, k8)\n    ASMSubroundG( ebp, eax, ebx, ecx, edx,  5,  6, k8)\n    ASMSubroundG( edx, ebp, eax, ebx, ecx, 12,  9, k8)\n    ASMSubroundG( ecx, edx, ebp, eax, ebx,  2, 12, k8)\n    ASMSubroundG( ebx, ecx, edx, ebp, eax, 13,  9, k8)\n    ASMSubroundG( eax, ebx, ecx, edx, ebp,  9, 12, k8)\n    ASMSubroundG( ebp, eax, ebx, ecx, edx,  7,  5, k8)\n    ASMSubroundG( edx, ebp, eax, ebx, ecx, 10, 15, k8)\n    ASMSubroundG( ecx, edx, ebp, eax, ebx, 14,  8, k8)\n\n    ASMSubroundF( ebx, ecx, edx, ebp, eax, 12,  8)\n    ASMSubroundF( eax, ebx, ecx, edx, ebp, 15,  5)\n    ASMSubroundF( ebp, eax, ebx, ecx, edx, 10, 12)\n    ASMSubroundF( edx, ebp, eax, ebx, ecx,  4,  9)\n    ASMSubroundF( ecx, edx, ebp, eax, ebx,  1, 12)\n    ASMSubroundF( ebx, ecx, edx, ebp, eax,  5,  5)\n    ASMSubroundF( eax, ebx, ecx, edx, ebp,  8, 14)\n    ASMSubroundF( ebp, eax, ebx, ecx, edx,  7,  6)\n    ASMSubroundF( edx, ebp, eax, ebx, ecx,  6,  8)\n    ASMSubroundF( ecx, edx, ebp, eax, ebx,  2, 13)\n    ASMSubroundF( ebx, ecx, edx, ebp, eax, 13,  6)\n    ASMSubroundF( eax, ebx, ecx, edx, ebp, 14,  5)\n    ASMSubroundF( ebp, eax, ebx, ecx, edx,  0, 15)\n    ASMSubroundF( edx, ebp, eax, ebx, ecx,  3, 13)\n    ASMSubroundF( ecx, edx, ebp, eax, ebx,  9, 11)\n    ASMSubroundF( ebx, ecx, edx, ebp, eax, 11, 11)\n\n    // advance data and store for next round\n    AS2(    add   edi, 64                       )\n    AS2(    movd  esi, mm1                      )   // digest_\n    AS2(    movd  mm0, edi                      )   // store\n\n    // now edi as tmp\n\n    // c1         = digest_[1] + c1 + d2;\n    AS2(    add   [esp +  8], edx               )   // + d2\n    AS2(    mov   edi, [esi + 4]                )   // digest_[1]\n    AS2(    add   [esp +  8], edi               )\n\n    // digest_[1] = digest_[2] + d1 + e2;\n    AS2(    mov   [esi + 4], ebp                )   // e2\n    AS2(    mov   edi, [esp + 12]               )   // d1\n    AS2(    add   edi, [esi + 8]                )   // digest_[2]\n    AS2(    add   [esi + 4], edi                )\n\n    // digest_[2] = digest_[3] + e1 + a2;\n    AS2(    mov   [esi + 8], eax                )   // a2\n    AS2(    mov   edi, [esp + 16]               )   // e1\n    AS2(    add   edi, [esi + 12]               )   // digest_[3]\n    AS2(    add   [esi + 8], edi                )\n\n    // digest_[3] = digest_[4] + a1 + b2;\n    AS2(    mov   [esi + 12], ebx               )   // b2\n    AS2(    mov   edi, [esp]                    )   // a1\n    AS2(    add   edi, [esi + 16]               )   // digest_[4]\n    AS2(    add   [esi + 12], edi               )\n\n    // digest_[4] = digest_[0] + b1 + c2;\n    AS2(    mov   [esi + 16], ecx               )   // c2\n    AS2(    mov   edi, [esp +  4]               )   // b1\n    AS2(    add   edi, [esi]                    )   // digest_[0]\n    AS2(    add   [esi + 16], edi               )\n\n    // digest_[0] = c1;\n    AS2(    mov   edi, [esp +  8]               )   // c1\n    AS2(    mov   [esi], edi                    )\n\n    // setup for loop back\n    AS2(    movd  edx, mm2              )   // times\n    AS2(    movd  edi, mm0              )   // data, already advanced\n    AS1(    dec   edx                   )\n#ifdef _MSC_VER\n    AS1(    jnz   loopStart )  // loopStart\n#else\n    AS1(    jnz   0b )         // loopStart\n#endif\n\n    // inline adjust \n    AS2(    add   esp, 24               )   // fix room on stack\n\n    EPILOG()\n}\n\n\n#endif // DO_RIPEMD_ASM\n\n\n} // namespace TaoCrypt\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/rsa.cpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* based on Wei Dai's rsa.cpp from CryptoPP */\n\n#include \"runtime.hpp\"\n#include \"rsa.hpp\"\n#include \"asn.hpp\"\n#include \"modarith.hpp\"\n\n\n\nnamespace TaoCrypt {\n\n\nInteger RSA_PublicKey::ApplyFunction(const Integer& x) const\n{\n    return a_exp_b_mod_c(x, e_, n_);\n}\n\n\nRSA_PublicKey::RSA_PublicKey(Source& source)\n{\n    Initialize(source);\n}\n\n\nvoid RSA_PublicKey::Initialize(Source& source)\n{\n    RSA_Public_Decoder decoder(source);\n    decoder.Decode(*this);\n}\n\n\nInteger RSA_PrivateKey::CalculateInverse(RandomNumberGenerator& rng,\n                                         const Integer& x) const\n{\n    ModularArithmetic modn(n_);\n\n    Integer r(rng, Integer::One(), n_ - Integer::One());\n    Integer re = modn.Exponentiate(r, e_);\n    re = modn.Multiply(re, x);\t\t\t// blind\n\n    // here we follow the notation of PKCS #1 and let u=q inverse mod p\n    // but in ModRoot, u=p inverse mod q, so we reverse the order of p and q\n\n    Integer y = ModularRoot(re, dq_, dp_, q_, p_, u_);\n    y = modn.Divide(y, r);\t\t\t\t    // unblind\n       \n    return y;\n}\n\n\nRSA_PrivateKey::RSA_PrivateKey(Source& source)\n{\n    Initialize(source);\n}\n\n\nvoid RSA_PrivateKey::Initialize(Source& source)\n{\n    RSA_Private_Decoder decoder(source);\n    decoder.Decode(*this);\n}\n\n\nvoid RSA_BlockType2::Pad(const byte *input, word32 inputLen, byte *pkcsBlock,\n                         word32 pkcsBlockLen, RandomNumberGenerator& rng) const\n{\n    // convert from bit length to byte length\n    if (pkcsBlockLen % 8 != 0)\n    {\n        pkcsBlock[0] = 0;\n        pkcsBlock++;\n    }\n    pkcsBlockLen /= 8;\n\n    pkcsBlock[0] = 2;  // block type 2\n\n    // pad with non-zero random bytes\n    word32 padLen = pkcsBlockLen - inputLen - 1;\n    rng.GenerateBlock(&pkcsBlock[1], padLen);\n    for (word32 i = 1; i < padLen; i++)\n        if (pkcsBlock[i] == 0) pkcsBlock[i] = 0x01;\n    \n    pkcsBlock[pkcsBlockLen-inputLen-1] = 0;     // separator\n    memcpy(pkcsBlock+pkcsBlockLen-inputLen, input, inputLen);\n}\n\nword32 RSA_BlockType2::UnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,\n                           byte *output) const\n{\n    bool invalid = false;\n    unsigned int maxOutputLen = SaturatingSubtract(pkcsBlockLen / 8, 10U);\n\n    // convert from bit length to byte length\n    if (pkcsBlockLen % 8 != 0)\n    {\n        invalid = (pkcsBlock[0] != 0) || invalid;\n        pkcsBlock++;\n    }\n    pkcsBlockLen /= 8;\n\n    // Require block type 2.\n    invalid = (pkcsBlock[0] != 2) || invalid;\n\n    // skip past the padding until we find the separator\n    unsigned i=1;\n    while (i<pkcsBlockLen && pkcsBlock[i++]) { // null body\n        }\n    if (!(i==pkcsBlockLen || pkcsBlock[i-1]==0))\n        return 0;\n\n    unsigned int outputLen = pkcsBlockLen - i;\n    invalid = (outputLen > maxOutputLen) || invalid;\n\n    if (invalid)\n        return 0;\n\n    memcpy (output, pkcsBlock+i, outputLen);\n    return outputLen;\n}\n\n\nvoid RSA_BlockType1::Pad(const byte* input, word32 inputLen, byte* pkcsBlock,\n                         word32 pkcsBlockLen, RandomNumberGenerator&) const\n{\n    // sanity checks\n    if (input == NULL || pkcsBlock == NULL)\n        return;\n\n    // convert from bit length to byte length\n    if (pkcsBlockLen % 8 != 0)\n    {\n        pkcsBlock[0] = 0;\n        pkcsBlock++;\n    }\n    pkcsBlockLen /= 8;\n\n    pkcsBlock[0] = 1;  // block type 1 for SSL\n\n    // pad with 0xff bytes\n    memset(&pkcsBlock[1], 0xFF, pkcsBlockLen - inputLen - 2);\n\n    pkcsBlock[pkcsBlockLen-inputLen-1] = 0;     // separator\n    memcpy(pkcsBlock+pkcsBlockLen-inputLen, input, inputLen);\n}\n\n\nword32 RSA_BlockType1::UnPad(const byte* pkcsBlock, word32 pkcsBlockLen,\n                             byte* output) const\n{\n    bool invalid = false;\n    unsigned int maxOutputLen = SaturatingSubtract(pkcsBlockLen / 8, 10U);\n\n    // convert from bit length to byte length\n    if (pkcsBlockLen % 8 != 0)\n    {\n        invalid = (pkcsBlock[0] != 0) || invalid;\n        pkcsBlock++;\n    }\n    pkcsBlockLen /= 8;\n\n    // Require block type 1 for SSL.\n    invalid = (pkcsBlock[0] != 1) || invalid;\n\n    // skip past the padding until we find the separator\n    unsigned i=1;\n    while (i<pkcsBlockLen && pkcsBlock[i++] == 0xFF) { // null body\n        }\n    if (!(i==pkcsBlockLen || pkcsBlock[i-1]==0))\n        return 0;\n\n    unsigned int outputLen = pkcsBlockLen - i;\n    invalid = (outputLen > maxOutputLen) || invalid;\n\n    if (invalid)\n        return 0;\n\n    memcpy(output, pkcsBlock+i, outputLen);\n    return outputLen;\n}\n\n\nword32 SSL_Decrypt(const RSA_PublicKey& key, const byte* sig, byte* plain)\n{\n    PK_Lengths lengths(key.GetModulus());\n   \n    ByteBlock paddedBlock(BitsToBytes(lengths.PaddedBlockBitLength()));\n    Integer x = key.ApplyFunction(Integer(sig,\n                                          lengths.FixedCiphertextLength()));\n    if (x.ByteCount() > paddedBlock.size())\n        x = Integer::Zero();\t\n    x.Encode(paddedBlock.get_buffer(), paddedBlock.size());\n    return RSA_BlockType1().UnPad(paddedBlock.get_buffer(),\n                                  lengths.PaddedBlockBitLength(), plain);\n}\n\n\n} // namespace\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/sha.cpp",
    "content": "/*\n   Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* based on Wei Dai's sha.cpp from CryptoPP */\n\n#include \"runtime.hpp\"\n#include <string.h>\n#include \"sha.hpp\"\n#ifdef USE_SYS_STL\n    #include <algorithm>\n#else\n    #include \"algorithm.hpp\"\n#endif\n\n\nnamespace STL = STL_NAMESPACE;\n\n\n\nnamespace TaoCrypt {\n\n#define blk0(i) (W[i] = buffer_[i])\n#define blk1(i) (W[i&15] = \\\n                 rotlFixed(W[(i+13)&15]^W[(i+8)&15]^W[(i+2)&15]^W[i&15],1))\n\n#define f1(x,y,z) (z^(x &(y^z)))\n#define f2(x,y,z) (x^y^z)\n#define f3(x,y,z) ((x&y)|(z&(x|y)))\n#define f4(x,y,z) (x^y^z)\n\n// (R0+R1), R2, R3, R4 are the different operations used in SHA1\n#define R0(v,w,x,y,z,i) z+= f1(w,x,y) + blk0(i) + 0x5A827999+ \\\n                        rotlFixed(v,5); w = rotlFixed(w,30);\n#define R1(v,w,x,y,z,i) z+= f1(w,x,y) + blk1(i) + 0x5A827999+ \\\n                        rotlFixed(v,5); w = rotlFixed(w,30);\n#define R2(v,w,x,y,z,i) z+= f2(w,x,y) + blk1(i) + 0x6ED9EBA1+ \\\n                        rotlFixed(v,5); w = rotlFixed(w,30);\n#define R3(v,w,x,y,z,i) z+= f3(w,x,y) + blk1(i) + 0x8F1BBCDC+ \\\n                        rotlFixed(v,5); w = rotlFixed(w,30);\n#define R4(v,w,x,y,z,i) z+= f4(w,x,y) + blk1(i) + 0xCA62C1D6+ \\\n                        rotlFixed(v,5); w = rotlFixed(w,30);\n\n\nvoid SHA::Init()\n{\n    digest_[0] = 0x67452301L;\n    digest_[1] = 0xEFCDAB89L;\n    digest_[2] = 0x98BADCFEL;\n    digest_[3] = 0x10325476L;\n    digest_[4] = 0xC3D2E1F0L;\n\n    buffLen_ = 0;\n    loLen_  = 0;\n    hiLen_  = 0;\n}\n\nvoid SHA256::Init()\n{\n    digest_[0] = 0x6A09E667L;\n    digest_[1] = 0xBB67AE85L;\n    digest_[2] = 0x3C6EF372L;\n    digest_[3] = 0xA54FF53AL;\n    digest_[4] = 0x510E527FL;\n    digest_[5] = 0x9B05688CL;\n    digest_[6] = 0x1F83D9ABL;\n    digest_[7] = 0x5BE0CD19L;\n\n    buffLen_ = 0;\n    loLen_  = 0;\n    hiLen_  = 0;\n}\n\n\nvoid SHA224::Init()\n{\n    digest_[0] = 0xc1059ed8;\n    digest_[1] = 0x367cd507;\n    digest_[2] = 0x3070dd17;\n    digest_[3] = 0xf70e5939;\n    digest_[4] = 0xffc00b31;\n    digest_[5] = 0x68581511;\n    digest_[6] = 0x64f98fa7;\n    digest_[7] = 0xbefa4fa4;\n\n    buffLen_ = 0;\n    loLen_  = 0;\n    hiLen_  = 0;\n}\n\n\n#ifdef WORD64_AVAILABLE\n\nvoid SHA512::Init()\n{\n    digest_[0] = W64LIT(0x6a09e667f3bcc908);\n    digest_[1] = W64LIT(0xbb67ae8584caa73b);\n    digest_[2] = W64LIT(0x3c6ef372fe94f82b);\n    digest_[3] = W64LIT(0xa54ff53a5f1d36f1);\n    digest_[4] = W64LIT(0x510e527fade682d1);\n    digest_[5] = W64LIT(0x9b05688c2b3e6c1f);\n    digest_[6] = W64LIT(0x1f83d9abfb41bd6b);\n    digest_[7] = W64LIT(0x5be0cd19137e2179);\n\n    buffLen_ = 0;\n    loLen_  = 0;\n    hiLen_  = 0;\n}\n\n\nvoid SHA384::Init()\n{\n    digest_[0] = W64LIT(0xcbbb9d5dc1059ed8);\n    digest_[1] = W64LIT(0x629a292a367cd507);\n    digest_[2] = W64LIT(0x9159015a3070dd17);\n    digest_[3] = W64LIT(0x152fecd8f70e5939);\n    digest_[4] = W64LIT(0x67332667ffc00b31);\n    digest_[5] = W64LIT(0x8eb44a8768581511);\n    digest_[6] = W64LIT(0xdb0c2e0d64f98fa7);\n    digest_[7] = W64LIT(0x47b5481dbefa4fa4);\n\n    buffLen_ = 0;\n    loLen_  = 0;\n    hiLen_  = 0;\n}\n\n#endif // WORD64_AVAILABLE\n\n\nSHA::SHA(const SHA& that) : HASHwithTransform(DIGEST_SIZE / sizeof(word32),\n                                              BLOCK_SIZE) \n{ \n    buffLen_ = that.buffLen_;\n    loLen_   = that.loLen_;\n    hiLen_   = that.hiLen_;\n\n    memcpy(digest_, that.digest_, DIGEST_SIZE);\n    memcpy(buffer_, that.buffer_, BLOCK_SIZE);\n}\n\n\nSHA256::SHA256(const SHA256& that) : HASHwithTransform(DIGEST_SIZE /\n                                       sizeof(word32), BLOCK_SIZE) \n{ \n    buffLen_ = that.buffLen_;\n    loLen_   = that.loLen_;\n    hiLen_   = that.hiLen_;\n\n    memcpy(digest_, that.digest_, DIGEST_SIZE);\n    memcpy(buffer_, that.buffer_, BLOCK_SIZE);\n}\n\n\nSHA224::SHA224(const SHA224& that) : HASHwithTransform(SHA256::DIGEST_SIZE /\n                                       sizeof(word32), BLOCK_SIZE) \n{ \n    buffLen_ = that.buffLen_;\n    loLen_   = that.loLen_;\n    hiLen_   = that.hiLen_;\n\n    memcpy(digest_, that.digest_, DIGEST_SIZE);\n    memcpy(buffer_, that.buffer_, BLOCK_SIZE);\n}\n\n\n#ifdef WORD64_AVAILABLE \n\nSHA512::SHA512(const SHA512& that) : HASH64withTransform(DIGEST_SIZE /\n                                       sizeof(word64), BLOCK_SIZE) \n{ \n    buffLen_ = that.buffLen_;\n    loLen_   = that.loLen_;\n    hiLen_   = that.hiLen_;\n\n    memcpy(digest_, that.digest_, DIGEST_SIZE);\n    memcpy(buffer_, that.buffer_, BLOCK_SIZE);\n}\n\n\nSHA384::SHA384(const SHA384& that) : HASH64withTransform(SHA512::DIGEST_SIZE /\n                                       sizeof(word64), BLOCK_SIZE) \n{ \n    buffLen_ = that.buffLen_;\n    loLen_   = that.loLen_;\n    hiLen_   = that.hiLen_;\n\n    memcpy(digest_, that.digest_, DIGEST_SIZE);\n    memcpy(buffer_, that.buffer_, BLOCK_SIZE);\n}\n\n#endif // WORD64_AVAILABLE\n\n\nSHA& SHA::operator= (const SHA& that)\n{\n    SHA tmp(that);\n    Swap(tmp);\n\n    return *this;\n}\n\n\nSHA256& SHA256::operator= (const SHA256& that)\n{\n    SHA256 tmp(that);\n    Swap(tmp);\n\n    return *this;\n}\n\n\nSHA224& SHA224::operator= (const SHA224& that)\n{\n    SHA224 tmp(that);\n    Swap(tmp);\n\n    return *this;\n}\n\n\n#ifdef WORD64_AVAILABLE\n\nSHA512& SHA512::operator= (const SHA512& that)\n{\n    SHA512 tmp(that);\n    Swap(tmp);\n\n    return *this;\n}\n\n\nSHA384& SHA384::operator= (const SHA384& that)\n{\n    SHA384 tmp(that);\n    Swap(tmp);\n\n    return *this;\n}\n\n#endif // WORD64_AVAILABLE\n\n\nvoid SHA::Swap(SHA& other)\n{\n    STL::swap(loLen_,   other.loLen_);\n    STL::swap(hiLen_,   other.hiLen_);\n    STL::swap(buffLen_, other.buffLen_);\n\n    memcpy(digest_, other.digest_, DIGEST_SIZE);\n    memcpy(buffer_, other.buffer_, BLOCK_SIZE);\n}\n\n\nvoid SHA256::Swap(SHA256& other)\n{\n    STL::swap(loLen_,   other.loLen_);\n    STL::swap(hiLen_,   other.hiLen_);\n    STL::swap(buffLen_, other.buffLen_);\n\n    memcpy(digest_, other.digest_, DIGEST_SIZE);\n    memcpy(buffer_, other.buffer_, BLOCK_SIZE);\n}\n\n\nvoid SHA224::Swap(SHA224& other)\n{\n    STL::swap(loLen_,   other.loLen_);\n    STL::swap(hiLen_,   other.hiLen_);\n    STL::swap(buffLen_, other.buffLen_);\n\n    memcpy(digest_, other.digest_, DIGEST_SIZE);\n    memcpy(buffer_, other.buffer_, BLOCK_SIZE);\n}\n\n\n#ifdef WORD64_AVAILABLE\n\nvoid SHA512::Swap(SHA512& other)\n{\n    STL::swap(loLen_,   other.loLen_);\n    STL::swap(hiLen_,   other.hiLen_);\n    STL::swap(buffLen_, other.buffLen_);\n\n    memcpy(digest_, other.digest_, DIGEST_SIZE);\n    memcpy(buffer_, other.buffer_, BLOCK_SIZE);\n}\n\n\nvoid SHA384::Swap(SHA384& other)\n{\n    STL::swap(loLen_,   other.loLen_);\n    STL::swap(hiLen_,   other.hiLen_);\n    STL::swap(buffLen_, other.buffLen_);\n\n    memcpy(digest_, other.digest_, DIGEST_SIZE);\n    memcpy(buffer_, other.buffer_, BLOCK_SIZE);\n}\n\n#endif // WORD64_AVIALABLE\n\n\n#ifdef DO_SHA_ASM\n\n// Update digest with data of size len\nvoid SHA::Update(const byte* data, word32 len)\n{\n    if (!isMMX) {\n        HASHwithTransform::Update(data, len);\n        return;\n    }\n\n    byte* local = reinterpret_cast<byte*>(buffer_);\n\n    // remove buffered data if possible\n    if (buffLen_)  {   \n        word32 add = min(len, BLOCK_SIZE - buffLen_);\n        memcpy(&local[buffLen_], data, add);\n\n        buffLen_ += add;\n        data     += add;\n        len      -= add;\n\n        if (buffLen_ == BLOCK_SIZE) {\n            ByteReverse(local, local, BLOCK_SIZE);\n            Transform();\n            AddLength(BLOCK_SIZE);\n            buffLen_ = 0;\n        }\n    }\n\n    // all at once for asm\n    if (buffLen_ == 0) {\n        word32 times = len / BLOCK_SIZE;\n        if (times) {\n            AsmTransform(data, times);\n            const word32 add = BLOCK_SIZE * times;\n            AddLength(add);\n            len  -= add;\n            data += add;\n        }\n    }\n\n    // cache any data left\n    if (len) {\n        memcpy(&local[buffLen_], data, len);\n        buffLen_ += len;\n    }\n}\n\n#endif // DO_SHA_ASM\n\n\nvoid SHA::Transform()\n{\n    word32 W[BLOCK_SIZE / sizeof(word32)];\n\n    // Copy context->state[] to working vars \n    word32 a = digest_[0];\n    word32 b = digest_[1];\n    word32 c = digest_[2];\n    word32 d = digest_[3];\n    word32 e = digest_[4];\n\n    // 4 rounds of 20 operations each. Loop unrolled. \n    R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);\n    R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);\n    R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);\n    R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);\n\n    R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);\n\n    R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);\n    R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);\n    R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);\n    R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);\n    R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);\n\n    R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);\n    R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);\n    R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);\n    R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);\n    R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);\n\n    R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);\n    R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);\n    R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);\n    R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);\n    R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);\n\n    // Add the working vars back into digest state[]\n    digest_[0] += a;\n    digest_[1] += b;\n    digest_[2] += c;\n    digest_[3] += d;\n    digest_[4] += e;\n\n    // Wipe variables\n    a = b = c = d = e = 0;\n    memset(W, 0, sizeof(W));\n}\n\n\n#define blk2(i) (W[i&15]+=s1(W[(i-2)&15])+W[(i-7)&15]+s0(W[(i-15)&15]))\n\n#define Ch(x,y,z) (z^(x&(y^z)))\n#define Maj(x,y,z) ((x&y)|(z&(x|y)))\n\n#define a(i) T[(0-i)&7]\n#define b(i) T[(1-i)&7]\n#define c(i) T[(2-i)&7]\n#define d(i) T[(3-i)&7]\n#define e(i) T[(4-i)&7]\n#define f(i) T[(5-i)&7]\n#define g(i) T[(6-i)&7]\n#define h(i) T[(7-i)&7]\n\n#define R(i) h(i)+=S1(e(i))+Ch(e(i),f(i),g(i))+K[i+j]+(j?blk2(i):blk0(i));\\\n\td(i)+=h(i);h(i)+=S0(a(i))+Maj(a(i),b(i),c(i))\n\n// for SHA256\n#define S0(x) (rotrFixed(x,2)^rotrFixed(x,13)^rotrFixed(x,22))\n#define S1(x) (rotrFixed(x,6)^rotrFixed(x,11)^rotrFixed(x,25))\n#define s0(x) (rotrFixed(x,7)^rotrFixed(x,18)^(x>>3))\n#define s1(x) (rotrFixed(x,17)^rotrFixed(x,19)^(x>>10))\n\n\nstatic const word32 K256[64] = {\n\t0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,\n\t0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n\t0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,\n\t0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n\t0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,\n\t0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n\t0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,\n\t0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n\t0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,\n\t0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n\t0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,\n\t0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n\t0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,\n\t0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n\t0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,\n\t0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\n};\n\n\nstatic void Transform256(word32* digest_, word32* buffer_)\n{\n    const  word32* K = K256;\n\n    word32 W[16];\n    word32 T[8];\n\n    // Copy digest to working vars\n    memcpy(T, digest_, sizeof(T));\n\n    // 64 operations, partially loop unrolled\n    for (unsigned int j = 0; j < 64; j += 16) {\n        R( 0); R( 1); R( 2); R( 3);\n        R( 4); R( 5); R( 6); R( 7);\n        R( 8); R( 9); R(10); R(11);\n        R(12); R(13); R(14); R(15);\n    }\n\n    // Add the working vars back into digest\n    digest_[0] += a(0);\n    digest_[1] += b(0);\n    digest_[2] += c(0);\n    digest_[3] += d(0);\n    digest_[4] += e(0);\n    digest_[5] += f(0);\n    digest_[6] += g(0);\n    digest_[7] += h(0);\n\n    // Wipe variables\n    memset(W, 0, sizeof(W));\n    memset(T, 0, sizeof(T));\n}\n\n\n// undef for 256\n#undef S0\n#undef S1\n#undef s0\n#undef s1\n\n\nvoid SHA256::Transform()\n{\n    Transform256(digest_, buffer_);\n}\n\n\nvoid SHA224::Transform()\n{\n    Transform256(digest_, buffer_);\n}\n\n\n#ifdef WORD64_AVAILABLE\n\nstatic const word64 K512[80] = {\n\tW64LIT(0x428a2f98d728ae22), W64LIT(0x7137449123ef65cd),\n\tW64LIT(0xb5c0fbcfec4d3b2f), W64LIT(0xe9b5dba58189dbbc),\n\tW64LIT(0x3956c25bf348b538), W64LIT(0x59f111f1b605d019),\n\tW64LIT(0x923f82a4af194f9b), W64LIT(0xab1c5ed5da6d8118),\n\tW64LIT(0xd807aa98a3030242), W64LIT(0x12835b0145706fbe),\n\tW64LIT(0x243185be4ee4b28c), W64LIT(0x550c7dc3d5ffb4e2),\n\tW64LIT(0x72be5d74f27b896f), W64LIT(0x80deb1fe3b1696b1),\n\tW64LIT(0x9bdc06a725c71235), W64LIT(0xc19bf174cf692694),\n\tW64LIT(0xe49b69c19ef14ad2), W64LIT(0xefbe4786384f25e3),\n\tW64LIT(0x0fc19dc68b8cd5b5), W64LIT(0x240ca1cc77ac9c65),\n\tW64LIT(0x2de92c6f592b0275), W64LIT(0x4a7484aa6ea6e483),\n\tW64LIT(0x5cb0a9dcbd41fbd4), W64LIT(0x76f988da831153b5),\n\tW64LIT(0x983e5152ee66dfab), W64LIT(0xa831c66d2db43210),\n\tW64LIT(0xb00327c898fb213f), W64LIT(0xbf597fc7beef0ee4),\n\tW64LIT(0xc6e00bf33da88fc2), W64LIT(0xd5a79147930aa725),\n\tW64LIT(0x06ca6351e003826f), W64LIT(0x142929670a0e6e70),\n\tW64LIT(0x27b70a8546d22ffc), W64LIT(0x2e1b21385c26c926),\n\tW64LIT(0x4d2c6dfc5ac42aed), W64LIT(0x53380d139d95b3df),\n\tW64LIT(0x650a73548baf63de), W64LIT(0x766a0abb3c77b2a8),\n\tW64LIT(0x81c2c92e47edaee6), W64LIT(0x92722c851482353b),\n\tW64LIT(0xa2bfe8a14cf10364), W64LIT(0xa81a664bbc423001),\n\tW64LIT(0xc24b8b70d0f89791), W64LIT(0xc76c51a30654be30),\n\tW64LIT(0xd192e819d6ef5218), W64LIT(0xd69906245565a910),\n\tW64LIT(0xf40e35855771202a), W64LIT(0x106aa07032bbd1b8),\n\tW64LIT(0x19a4c116b8d2d0c8), W64LIT(0x1e376c085141ab53),\n\tW64LIT(0x2748774cdf8eeb99), W64LIT(0x34b0bcb5e19b48a8),\n\tW64LIT(0x391c0cb3c5c95a63), W64LIT(0x4ed8aa4ae3418acb),\n\tW64LIT(0x5b9cca4f7763e373), W64LIT(0x682e6ff3d6b2b8a3),\n\tW64LIT(0x748f82ee5defb2fc), W64LIT(0x78a5636f43172f60),\n\tW64LIT(0x84c87814a1f0ab72), W64LIT(0x8cc702081a6439ec),\n\tW64LIT(0x90befffa23631e28), W64LIT(0xa4506cebde82bde9),\n\tW64LIT(0xbef9a3f7b2c67915), W64LIT(0xc67178f2e372532b),\n\tW64LIT(0xca273eceea26619c), W64LIT(0xd186b8c721c0c207),\n\tW64LIT(0xeada7dd6cde0eb1e), W64LIT(0xf57d4f7fee6ed178),\n\tW64LIT(0x06f067aa72176fba), W64LIT(0x0a637dc5a2c898a6),\n\tW64LIT(0x113f9804bef90dae), W64LIT(0x1b710b35131c471b),\n\tW64LIT(0x28db77f523047d84), W64LIT(0x32caab7b40c72493),\n\tW64LIT(0x3c9ebe0a15c9bebc), W64LIT(0x431d67c49c100d4c),\n\tW64LIT(0x4cc5d4becb3e42b6), W64LIT(0x597f299cfc657e2a),\n\tW64LIT(0x5fcb6fab3ad6faec), W64LIT(0x6c44198c4a475817)\n};\n\n\n// for SHA512\n#define S0(x) (rotrFixed(x,28)^rotrFixed(x,34)^rotrFixed(x,39))\n#define S1(x) (rotrFixed(x,14)^rotrFixed(x,18)^rotrFixed(x,41))\n#define s0(x) (rotrFixed(x,1)^rotrFixed(x,8)^(x>>7))\n#define s1(x) (rotrFixed(x,19)^rotrFixed(x,61)^(x>>6))\n\n\nstatic void Transform512(word64* digest_, word64* buffer_)\n{\n    const word64* K = K512;\n\n    word64 W[16];\n    word64 T[8];\n\n    // Copy digest to working vars\n    memcpy(T, digest_, sizeof(T));\n\n    // 64 operations, partially loop unrolled\n    for (unsigned int j = 0; j < 80; j += 16) {\n        R( 0); R( 1); R( 2); R( 3);\n        R( 4); R( 5); R( 6); R( 7);\n        R( 8); R( 9); R(10); R(11);\n        R(12); R(13); R(14); R(15);\n    }\n\n    // Add the working vars back into digest \n\n    digest_[0] += a(0);\n    digest_[1] += b(0);\n    digest_[2] += c(0);\n    digest_[3] += d(0);\n    digest_[4] += e(0);\n    digest_[5] += f(0);\n    digest_[6] += g(0);\n    digest_[7] += h(0);\n\n    // Wipe variables\n    memset(W, 0, sizeof(W));\n    memset(T, 0, sizeof(T));\n}\n\n\nvoid SHA512::Transform()\n{\n    Transform512(digest_, buffer_);\n}\n\n\nvoid SHA384::Transform()\n{\n    Transform512(digest_, buffer_);\n}\n\n#endif // WORD64_AVIALABLE\n\n\n#ifdef DO_SHA_ASM\n\n// f1(x,y,z) (z^(x &(y^z)))\n// place in esi\n#define ASMf1(x,y,z)   \\\n    AS2(    mov   esi, y    )   \\\n    AS2(    xor   esi, z    )   \\\n    AS2(    and   esi, x    )   \\\n    AS2(    xor   esi, z    )\n\n\n// R0(v,w,x,y,z,i) =\n//      z+= f1(w,x,y) + W[i] + 0x5A827999 + rotlFixed(v,5);\n//      w = rotlFixed(w,30);\n\n//      use esi for f\n//      use edi as tmp\n\n\n#define ASMR0(v,w,x,y,z,i) \\\n    AS2(    mov   esi, x                        )   \\\n    AS2(    mov   edi, [esp + i * 4]            )   \\\n    AS2(    xor   esi, y                        )   \\\n    AS2(    and   esi, w                        )   \\\n    AS2(    lea     z, [edi + z + 0x5A827999]   )   \\\n    AS2(    mov   edi, v                        )   \\\n    AS2(    xor   esi, y                        )   \\\n    AS2(    rol   edi, 5                        )   \\\n    AS2(    add     z, esi                      )   \\\n    AS2(    rol     w, 30                       )   \\\n    AS2(    add     z, edi                      )\n\n\n/*  Some macro stuff, but older gas ( < 2,16 ) can't process &, so do by hand\n    % won't work on gas at all\n\n#define xstr(s) str(s)\n#define  str(s) #s\n\n#define WOFF1(a) ( a       & 15)\n#define WOFF2(a) ((a +  2) & 15)\n#define WOFF3(a) ((a +  8) & 15)\n#define WOFF4(a) ((a + 13) & 15)\n\n#ifdef __GNUC__\n    #define WGET1(i) asm(\"mov esp, [edi - \"xstr(WOFF1(i))\" * 4] \");\n    #define WGET2(i) asm(\"xor esp, [edi - \"xstr(WOFF2(i))\" * 4] \");\n    #define WGET3(i) asm(\"xor esp, [edi - \"xstr(WOFF3(i))\" * 4] \");\n    #define WGET4(i) asm(\"xor esp, [edi - \"xstr(WOFF4(i))\" * 4] \");\n    #define WPUT1(i) asm(\"mov [edi - \"xstr(WOFF1(i))\" * 4], esp \");\n#else\n    #define WGET1(i) AS2( mov   esp, [edi - WOFF1(i) * 4]   )\n    #define WGET2(i) AS2( xor   esp, [edi - WOFF2(i) * 4]   )\n    #define WGET3(i) AS2( xor   esp, [edi - WOFF3(i) * 4]   )\n    #define WGET4(i) AS2( xor   esp, [edi - WOFF4(i) * 4]   )\n    #define WPUT1(i) AS2( mov   [edi - WOFF1(i) * 4], esp   )\n#endif\n*/\n\n// ASMR1 = ASMR0 but use esp for W calcs\n\n#define ASMR1(v,w,x,y,z,i,W1,W2,W3,W4) \\\n    AS2(    mov   edi, [esp + W1 * 4]           )   \\\n    AS2(    mov   esi, x                        )   \\\n    AS2(    xor   edi, [esp + W2 * 4]           )   \\\n    AS2(    xor   esi, y                        )   \\\n    AS2(    xor   edi, [esp + W3 * 4]           )   \\\n    AS2(    and   esi, w                        )   \\\n    AS2(    xor   edi, [esp + W4 * 4]           )   \\\n    AS2(    rol   edi, 1                        )   \\\n    AS2(    xor   esi, y                        )   \\\n    AS2(    mov   [esp + W1 * 4], edi           )   \\\n    AS2(    lea     z, [edi + z + 0x5A827999]   )   \\\n    AS2(    mov   edi, v                        )   \\\n    AS2(    rol   edi, 5                        )   \\\n    AS2(    add     z, esi                      )   \\\n    AS2(    rol     w, 30                       )   \\\n    AS2(    add     z, edi                      )\n\n\n// ASMR2 = ASMR1 but f is xor, xor instead\n\n#define ASMR2(v,w,x,y,z,i,W1,W2,W3,W4) \\\n    AS2(    mov   edi, [esp + W1 * 4]           )   \\\n    AS2(    mov   esi, x                        )   \\\n    AS2(    xor   edi, [esp + W2 * 4]           )   \\\n    AS2(    xor   esi, y                        )   \\\n    AS2(    xor   edi, [esp + W3 * 4]           )   \\\n    AS2(    xor   esi, w                        )   \\\n    AS2(    xor   edi, [esp + W4 * 4]           )   \\\n    AS2(    rol   edi, 1                        )   \\\n    AS2(    add     z, esi                      )   \\\n    AS2(    mov   [esp + W1 * 4], edi           )   \\\n    AS2(    lea     z, [edi + z + 0x6ED9EBA1]   )   \\\n    AS2(    mov   edi, v                        )   \\\n    AS2(    rol   edi, 5                        )   \\\n    AS2(    rol     w, 30                       )   \\\n    AS2(    add     z, edi                      )\n\n\n// ASMR3 = ASMR2 but f is (x&y)|(z&(x|y))\n//               which is (w&x)|(y&(w|x))\n\n#define ASMR3(v,w,x,y,z,i,W1,W2,W3,W4) \\\n    AS2(    mov   edi, [esp + W1 * 4]           )   \\\n    AS2(    mov   esi, x                        )   \\\n    AS2(    xor   edi, [esp + W2 * 4]           )   \\\n    AS2(     or   esi, w                        )   \\\n    AS2(    xor   edi, [esp + W3 * 4]           )   \\\n    AS2(    and   esi, y                        )   \\\n    AS2(    xor   edi, [esp + W4 * 4]           )   \\\n    AS2(    movd  mm0, esi                      )   \\\n    AS2(    rol   edi, 1                        )   \\\n    AS2(    mov   esi, x                        )   \\\n    AS2(    mov   [esp + W1 * 4], edi           )   \\\n    AS2(    and   esi, w                        )   \\\n    AS2(    lea     z, [edi + z + 0x8F1BBCDC]   )   \\\n    AS2(    movd  edi, mm0                      )   \\\n    AS2(     or   esi, edi                      )   \\\n    AS2(    mov   edi, v                        )   \\\n    AS2(    rol   edi, 5                        )   \\\n    AS2(    add     z, esi                      )   \\\n    AS2(    rol     w, 30                       )   \\\n    AS2(    add     z, edi                      )\n\n\n// ASMR4 = ASMR2 but different constant\n\n#define ASMR4(v,w,x,y,z,i,W1,W2,W3,W4) \\\n    AS2(    mov   edi, [esp + W1 * 4]           )   \\\n    AS2(    mov   esi, x                        )   \\\n    AS2(    xor   edi, [esp + W2 * 4]           )   \\\n    AS2(    xor   esi, y                        )   \\\n    AS2(    xor   edi, [esp + W3 * 4]           )   \\\n    AS2(    xor   esi, w                        )   \\\n    AS2(    xor   edi, [esp + W4 * 4]           )   \\\n    AS2(    rol   edi, 1                        )   \\\n    AS2(    add     z, esi                      )   \\\n    AS2(    mov   [esp + W1 * 4], edi           )   \\\n    AS2(    lea     z, [edi + z + 0xCA62C1D6]   )   \\\n    AS2(    mov   edi, v                        )   \\\n    AS2(    rol   edi, 5                        )   \\\n    AS2(    rol     w, 30                       )   \\\n    AS2(    add     z, edi                      )\n\n\n#ifdef _MSC_VER\n    __declspec(naked)\n#else\n    __attribute__ ((noinline))\n#endif\nvoid SHA::AsmTransform(const byte* data, word32 times)\n{\n#ifdef __GNUC__\n    #define AS1(x)    #x \";\"\n    #define AS2(x, y) #x \", \" #y \";\"\n\n    #define PROLOG()  \\\n    __asm__ __volatile__ \\\n    ( \\\n        \".intel_syntax noprefix;\" \\\n        \"push ebx;\" \\\n        \"push ebp;\"\n    #define EPILOG()  \\\n        \"pop ebp;\" \\\n        \"pop ebx;\" \\\n       \t\"emms;\" \\\n       \t\".att_syntax;\" \\\n            : \\\n            : \"c\" (this), \"D\" (data), \"a\" (times) \\\n            : \"%esi\", \"%edx\", \"memory\", \"cc\" \\\n    );\n\n#else\n    #define AS1(x)    __asm x\n    #define AS2(x, y) __asm x, y\n\n    #define PROLOG() \\\n        AS1(    push  ebp                           )   \\\n        AS2(    mov   ebp, esp                      )   \\\n        AS2(    movd  mm3, edi                      )   \\\n        AS2(    movd  mm4, ebx                      )   \\\n        AS2(    movd  mm5, esi                      )   \\\n        AS2(    movd  mm6, ebp                      )   \\\n        AS2(    mov   edi, data                     )   \\\n        AS2(    mov   eax, times                    )\n\n    #define EPILOG() \\\n        AS2(    movd  ebp, mm6                  )   \\\n        AS2(    movd  esi, mm5                  )   \\\n        AS2(    movd  ebx, mm4                  )   \\\n        AS2(    movd  edi, mm3                  )   \\\n        AS2(    mov   esp, ebp                  )   \\\n        AS1(    pop   ebp                       )   \\\n        AS1(    emms   )                            \\\n        AS1(    ret 8  )   \n#endif\n\n    PROLOG()\n\n    AS2(    mov   esi, ecx              )\n\n    #ifdef OLD_GCC_OFFSET\n        AS2(    add   esi, 20               )   // digest_[0]\n    #else\n        AS2(    add   esi, 16               )   // digest_[0]\n    #endif\n\n    AS2(    movd  mm2, eax              )   // store times_\n    AS2(    movd  mm1, esi              )   // store digest_\n\n    AS2(    sub   esp, 68               )   // make room on stack\n\n#ifdef _MSC_VER\n    AS1( loopStart: )  // loopStart\n#else\n    AS1( 0: )          // loopStart for some gas (need numeric for jump back \n#endif\n\n    // byte reverse 16 words of input, 4 at a time, put on stack for W[]\n\n    // part 1\n    AS2(    mov   eax, [edi]        )\n    AS2(    mov   ebx, [edi +  4]   )\n    AS2(    mov   ecx, [edi +  8]   )\n    AS2(    mov   edx, [edi + 12]   )\n\n    AS1(    bswap eax   )\n    AS1(    bswap ebx   )\n    AS1(    bswap ecx   )\n    AS1(    bswap edx   )\n\n    AS2(    mov   [esp],      eax   )\n    AS2(    mov   [esp +  4], ebx   )\n    AS2(    mov   [esp +  8], ecx   )\n    AS2(    mov   [esp + 12], edx   )\n\n    // part 2\n    AS2(    mov   eax, [edi + 16]   )\n    AS2(    mov   ebx, [edi + 20]   )\n    AS2(    mov   ecx, [edi + 24]   )\n    AS2(    mov   edx, [edi + 28]   )\n\n    AS1(    bswap eax   )\n    AS1(    bswap ebx   )\n    AS1(    bswap ecx   )\n    AS1(    bswap edx   )\n\n    AS2(    mov   [esp + 16], eax   )\n    AS2(    mov   [esp + 20], ebx   )\n    AS2(    mov   [esp + 24], ecx   )\n    AS2(    mov   [esp + 28], edx   )\n\n\n    // part 3\n    AS2(    mov   eax, [edi + 32]   )\n    AS2(    mov   ebx, [edi + 36]   )\n    AS2(    mov   ecx, [edi + 40]   )\n    AS2(    mov   edx, [edi + 44]   )\n\n    AS1(    bswap eax   )\n    AS1(    bswap ebx   )\n    AS1(    bswap ecx   )\n    AS1(    bswap edx   )\n\n    AS2(    mov   [esp + 32], eax   )\n    AS2(    mov   [esp + 36], ebx   )\n    AS2(    mov   [esp + 40], ecx   )\n    AS2(    mov   [esp + 44], edx   )\n\n\n    // part 4\n    AS2(    mov   eax, [edi + 48]   )\n    AS2(    mov   ebx, [edi + 52]   )\n    AS2(    mov   ecx, [edi + 56]   )\n    AS2(    mov   edx, [edi + 60]   )\n\n    AS1(    bswap eax   )\n    AS1(    bswap ebx   )\n    AS1(    bswap ecx   )\n    AS1(    bswap edx   )\n\n    AS2(    mov   [esp + 48], eax   )\n    AS2(    mov   [esp + 52], ebx   )\n    AS2(    mov   [esp + 56], ecx   )\n    AS2(    mov   [esp + 60], edx   )\n\n    AS2(    mov   [esp + 64], edi   )   // store edi for end\n\n    // read from digest_\n    AS2(    mov   eax, [esi]            )   // a1\n    AS2(    mov   ebx, [esi +  4]       )   // b1\n    AS2(    mov   ecx, [esi +  8]       )   // c1\n    AS2(    mov   edx, [esi + 12]       )   // d1\n    AS2(    mov   ebp, [esi + 16]       )   // e1\n\n\n    ASMR0(eax, ebx, ecx, edx, ebp,  0)\n    ASMR0(ebp, eax, ebx, ecx, edx,  1)\n    ASMR0(edx, ebp, eax, ebx, ecx,  2)\n    ASMR0(ecx, edx, ebp, eax, ebx,  3)\n    ASMR0(ebx, ecx, edx, ebp, eax,  4)\n    ASMR0(eax, ebx, ecx, edx, ebp,  5)\n    ASMR0(ebp, eax, ebx, ecx, edx,  6)\n    ASMR0(edx, ebp, eax, ebx, ecx,  7)\n    ASMR0(ecx, edx, ebp, eax, ebx,  8)\n    ASMR0(ebx, ecx, edx, ebp, eax,  9)\n    ASMR0(eax, ebx, ecx, edx, ebp, 10)\n    ASMR0(ebp, eax, ebx, ecx, edx, 11)\n    ASMR0(edx, ebp, eax, ebx, ecx, 12)\n    ASMR0(ecx, edx, ebp, eax, ebx, 13)\n    ASMR0(ebx, ecx, edx, ebp, eax, 14)\n    ASMR0(eax, ebx, ecx, edx, ebp, 15)\n\n    ASMR1(ebp, eax, ebx, ecx, edx, 16,  0,  2,  8, 13)\n    ASMR1(edx, ebp, eax, ebx, ecx, 17,  1,  3,  9, 14)\n    ASMR1(ecx, edx, ebp, eax, ebx, 18,  2,  4, 10, 15)\n    ASMR1(ebx, ecx, edx, ebp, eax, 19,  3,  5, 11,  0)\n\n    ASMR2(eax, ebx, ecx, edx, ebp, 20,  4,  6, 12,  1)\n    ASMR2(ebp, eax, ebx, ecx, edx, 21,  5,  7, 13,  2)\n    ASMR2(edx, ebp, eax, ebx, ecx, 22,  6,  8, 14,  3)\n    ASMR2(ecx, edx, ebp, eax, ebx, 23,  7,  9, 15,  4)\n    ASMR2(ebx, ecx, edx, ebp, eax, 24,  8, 10,  0,  5)\n    ASMR2(eax, ebx, ecx, edx, ebp, 25,  9, 11,  1,  6)\n    ASMR2(ebp, eax, ebx, ecx, edx, 26, 10, 12,  2,  7)\n    ASMR2(edx, ebp, eax, ebx, ecx, 27, 11, 13,  3,  8)\n    ASMR2(ecx, edx, ebp, eax, ebx, 28, 12, 14,  4,  9)\n    ASMR2(ebx, ecx, edx, ebp, eax, 29, 13, 15,  5, 10)\n    ASMR2(eax, ebx, ecx, edx, ebp, 30, 14,  0,  6, 11)\n    ASMR2(ebp, eax, ebx, ecx, edx, 31, 15,  1,  7, 12)\n    ASMR2(edx, ebp, eax, ebx, ecx, 32,  0,  2,  8, 13)\n    ASMR2(ecx, edx, ebp, eax, ebx, 33,  1,  3,  9, 14)\n    ASMR2(ebx, ecx, edx, ebp, eax, 34,  2,  4, 10, 15)\n    ASMR2(eax, ebx, ecx, edx, ebp, 35,  3,  5, 11,  0)\n    ASMR2(ebp, eax, ebx, ecx, edx, 36,  4,  6, 12,  1)\n    ASMR2(edx, ebp, eax, ebx, ecx, 37,  5,  7, 13,  2)\n    ASMR2(ecx, edx, ebp, eax, ebx, 38,  6,  8, 14,  3)\n    ASMR2(ebx, ecx, edx, ebp, eax, 39,  7,  9, 15,  4)\n\n\n    ASMR3(eax, ebx, ecx, edx, ebp, 40,  8, 10,  0,  5)\n    ASMR3(ebp, eax, ebx, ecx, edx, 41,  9, 11,  1,  6)\n    ASMR3(edx, ebp, eax, ebx, ecx, 42, 10, 12,  2,  7)\n    ASMR3(ecx, edx, ebp, eax, ebx, 43, 11, 13,  3,  8)\n    ASMR3(ebx, ecx, edx, ebp, eax, 44, 12, 14,  4,  9)\n    ASMR3(eax, ebx, ecx, edx, ebp, 45, 13, 15,  5, 10)\n    ASMR3(ebp, eax, ebx, ecx, edx, 46, 14,  0,  6, 11)\n    ASMR3(edx, ebp, eax, ebx, ecx, 47, 15,  1,  7, 12)\n    ASMR3(ecx, edx, ebp, eax, ebx, 48,  0,  2,  8, 13)\n    ASMR3(ebx, ecx, edx, ebp, eax, 49,  1,  3,  9, 14)\n    ASMR3(eax, ebx, ecx, edx, ebp, 50,  2,  4, 10, 15)\n    ASMR3(ebp, eax, ebx, ecx, edx, 51,  3,  5, 11,  0)\n    ASMR3(edx, ebp, eax, ebx, ecx, 52,  4,  6, 12,  1)\n    ASMR3(ecx, edx, ebp, eax, ebx, 53,  5,  7, 13,  2)\n    ASMR3(ebx, ecx, edx, ebp, eax, 54,  6,  8, 14,  3)\n    ASMR3(eax, ebx, ecx, edx, ebp, 55,  7,  9, 15,  4)\n    ASMR3(ebp, eax, ebx, ecx, edx, 56,  8, 10,  0,  5)\n    ASMR3(edx, ebp, eax, ebx, ecx, 57,  9, 11,  1,  6)\n    ASMR3(ecx, edx, ebp, eax, ebx, 58, 10, 12,  2,  7)\n    ASMR3(ebx, ecx, edx, ebp, eax, 59, 11, 13,  3,  8)\n\n    ASMR4(eax, ebx, ecx, edx, ebp, 60, 12, 14,  4,  9)\n    ASMR4(ebp, eax, ebx, ecx, edx, 61, 13, 15,  5, 10)\n    ASMR4(edx, ebp, eax, ebx, ecx, 62, 14,  0,  6, 11)\n    ASMR4(ecx, edx, ebp, eax, ebx, 63, 15,  1,  7, 12)\n    ASMR4(ebx, ecx, edx, ebp, eax, 64,  0,  2,  8, 13)\n    ASMR4(eax, ebx, ecx, edx, ebp, 65,  1,  3,  9, 14)\n    ASMR4(ebp, eax, ebx, ecx, edx, 66,  2,  4, 10, 15)\n    ASMR4(edx, ebp, eax, ebx, ecx, 67,  3,  5, 11,  0)\n    ASMR4(ecx, edx, ebp, eax, ebx, 68,  4,  6, 12,  1)\n    ASMR4(ebx, ecx, edx, ebp, eax, 69,  5,  7, 13,  2)\n    ASMR4(eax, ebx, ecx, edx, ebp, 70,  6,  8, 14,  3)\n    ASMR4(ebp, eax, ebx, ecx, edx, 71,  7,  9, 15,  4)\n    ASMR4(edx, ebp, eax, ebx, ecx, 72,  8, 10,  0,  5)\n    ASMR4(ecx, edx, ebp, eax, ebx, 73,  9, 11,  1,  6)\n    ASMR4(ebx, ecx, edx, ebp, eax, 74, 10, 12,  2,  7)\n    ASMR4(eax, ebx, ecx, edx, ebp, 75, 11, 13,  3,  8)\n    ASMR4(ebp, eax, ebx, ecx, edx, 76, 12, 14,  4,  9)\n    ASMR4(edx, ebp, eax, ebx, ecx, 77, 13, 15,  5, 10)\n    ASMR4(ecx, edx, ebp, eax, ebx, 78, 14,  0,  6, 11)\n    ASMR4(ebx, ecx, edx, ebp, eax, 79, 15,  1,  7, 12)\n\n\n    AS2(    movd  esi, mm1              )   // digest_\n\n    AS2(    add   [esi],      eax       )   // write out\n    AS2(    add   [esi +  4], ebx       )\n    AS2(    add   [esi +  8], ecx       )\n    AS2(    add   [esi + 12], edx       )\n    AS2(    add   [esi + 16], ebp       )\n\n    // setup next round\n    AS2(    movd  ebp, mm2              )   // times\n \n    AS2(    mov   edi, DWORD PTR [esp + 64] )   // data\n    \n    AS2(    add   edi, 64               )   // next round of data\n    AS2(    mov   [esp + 64], edi       )   // restore\n    \n    AS1(    dec   ebp                   )\n    AS2(    movd  mm2, ebp              )\n#ifdef _MSC_VER\n    AS1(    jnz   loopStart )  // loopStart\n#else\n    AS1(    jnz   0b )         // loopStart\n#endif\n\n    // inline adjust \n    AS2(    add   esp, 68               )   // fix room on stack\n\n    EPILOG()\n}\n\n\n#endif // DO_SHA_ASM\n\n} // namespace\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/template_instnt.cpp",
    "content": "/*\n   Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n\n/*  Explicit template instantiation requests \n */\n\n\n#include \"runtime.hpp\"\n#include \"integer.hpp\"\n#include \"rsa.hpp\"\n#include \"sha.hpp\"\n#include \"md5.hpp\"\n#include \"hmac.hpp\"\n#include \"ripemd.hpp\"\n#include \"pwdbased.hpp\"\n#include \"algebra.hpp\"\n#include \"vector.hpp\"\n#include \"hash.hpp\"\n\n#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION\nnamespace TaoCrypt {\n\n#if defined(SSE2_INTRINSICS_AVAILABLE)\ntemplate AlignedAllocator<unsigned int>::pointer StdReallocate<unsigned int, AlignedAllocator<unsigned int> >(AlignedAllocator<unsigned int>&, unsigned int*, AlignedAllocator<unsigned int>::size_type, AlignedAllocator<unsigned int>::size_type, bool);\n#endif\n\ntemplate class RSA_Decryptor<RSA_BlockType2>;\ntemplate class RSA_Encryptor<RSA_BlockType1>;\ntemplate class RSA_Encryptor<RSA_BlockType2>;\ntemplate void tcDelete<HASH>(HASH*);\ntemplate void tcDelete<Integer>(Integer*);\ntemplate void tcArrayDelete<byte>(byte*);\ntemplate AllocatorWithCleanup<byte>::pointer StdReallocate<byte, AllocatorWithCleanup<byte> >(AllocatorWithCleanup<byte>&, byte*, AllocatorWithCleanup<byte>::size_type, AllocatorWithCleanup<byte>::size_type, bool);\ntemplate void tcArrayDelete<word>(word*);\ntemplate AllocatorWithCleanup<word>::pointer StdReallocate<word, AllocatorWithCleanup<word> >(AllocatorWithCleanup<word>&, word*, AllocatorWithCleanup<word>::size_type, AllocatorWithCleanup<word>::size_type, bool);\n\n#ifndef TAOCRYPT_SLOW_WORD64 // defined when word != word32\ntemplate void tcArrayDelete<word32>(word32*);\ntemplate AllocatorWithCleanup<word32>::pointer StdReallocate<word32, AllocatorWithCleanup<word32> >(AllocatorWithCleanup<word32>&, word32*, AllocatorWithCleanup<word32>::size_type, AllocatorWithCleanup<word32>::size_type, bool);\n#endif\n\ntemplate void tcArrayDelete<char>(char*);\n\ntemplate class PBKDF2_HMAC<SHA>;\ntemplate class HMAC<MD5>;\ntemplate class HMAC<SHA>;\ntemplate class HMAC<RIPEMD160>;\n}\n\nnamespace mySTL {\ntemplate vector<TaoCrypt::Integer>* uninit_fill_n<vector<TaoCrypt::Integer>*, size_t, vector<TaoCrypt::Integer> >(vector<TaoCrypt::Integer>*, size_t, vector<TaoCrypt::Integer> const&);\ntemplate void destroy<vector<TaoCrypt::Integer>*>(vector<TaoCrypt::Integer>*, vector<TaoCrypt::Integer>*);\ntemplate TaoCrypt::Integer* uninit_copy<TaoCrypt::Integer*, TaoCrypt::Integer*>(TaoCrypt::Integer*, TaoCrypt::Integer*, TaoCrypt::Integer*);\ntemplate TaoCrypt::Integer* uninit_fill_n<TaoCrypt::Integer*, size_t, TaoCrypt::Integer>(TaoCrypt::Integer*, size_t, TaoCrypt::Integer const&);\ntemplate void destroy<TaoCrypt::Integer*>(TaoCrypt::Integer*, TaoCrypt::Integer*);\ntemplate TaoCrypt::byte* GetArrayMemory<TaoCrypt::byte>(size_t);\ntemplate void FreeArrayMemory<TaoCrypt::byte>(TaoCrypt::byte*);\ntemplate TaoCrypt::Integer* GetArrayMemory<TaoCrypt::Integer>(size_t);\ntemplate void FreeArrayMemory<TaoCrypt::Integer>(TaoCrypt::Integer*);\ntemplate vector<TaoCrypt::Integer>* GetArrayMemory<vector<TaoCrypt::Integer> >(size_t);\ntemplate void FreeArrayMemory<vector<TaoCrypt::Integer> >(vector<TaoCrypt::Integer>*);\ntemplate void FreeArrayMemory<void>(void*);\n}\n\n#endif\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/tftables.cpp",
    "content": "/*\n   Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* based on Wei Dai's tftables.cpp from CryptoPP */\n\n#include \"runtime.hpp\"\n#include \"twofish.hpp\"\n\n\nnamespace TaoCrypt {\n\n\nconst byte Twofish::q_[2][256] = {\n{\n   0xA9, 0x67, 0xB3, 0xE8, 0x04, 0xFD, 0xA3, 0x76, 0x9A, 0x92, 0x80, 0x78,\n   0xE4, 0xDD, 0xD1, 0x38, 0x0D, 0xC6, 0x35, 0x98, 0x18, 0xF7, 0xEC, 0x6C,\n   0x43, 0x75, 0x37, 0x26, 0xFA, 0x13, 0x94, 0x48, 0xF2, 0xD0, 0x8B, 0x30,\n   0x84, 0x54, 0xDF, 0x23, 0x19, 0x5B, 0x3D, 0x59, 0xF3, 0xAE, 0xA2, 0x82,\n   0x63, 0x01, 0x83, 0x2E, 0xD9, 0x51, 0x9B, 0x7C, 0xA6, 0xEB, 0xA5, 0xBE,\n   0x16, 0x0C, 0xE3, 0x61, 0xC0, 0x8C, 0x3A, 0xF5, 0x73, 0x2C, 0x25, 0x0B,\n   0xBB, 0x4E, 0x89, 0x6B, 0x53, 0x6A, 0xB4, 0xF1, 0xE1, 0xE6, 0xBD, 0x45,\n   0xE2, 0xF4, 0xB6, 0x66, 0xCC, 0x95, 0x03, 0x56, 0xD4, 0x1C, 0x1E, 0xD7,\n   0xFB, 0xC3, 0x8E, 0xB5, 0xE9, 0xCF, 0xBF, 0xBA, 0xEA, 0x77, 0x39, 0xAF,\n   0x33, 0xC9, 0x62, 0x71, 0x81, 0x79, 0x09, 0xAD, 0x24, 0xCD, 0xF9, 0xD8,\n   0xE5, 0xC5, 0xB9, 0x4D, 0x44, 0x08, 0x86, 0xE7, 0xA1, 0x1D, 0xAA, 0xED,\n   0x06, 0x70, 0xB2, 0xD2, 0x41, 0x7B, 0xA0, 0x11, 0x31, 0xC2, 0x27, 0x90,\n   0x20, 0xF6, 0x60, 0xFF, 0x96, 0x5C, 0xB1, 0xAB, 0x9E, 0x9C, 0x52, 0x1B,\n   0x5F, 0x93, 0x0A, 0xEF, 0x91, 0x85, 0x49, 0xEE, 0x2D, 0x4F, 0x8F, 0x3B,\n   0x47, 0x87, 0x6D, 0x46, 0xD6, 0x3E, 0x69, 0x64, 0x2A, 0xCE, 0xCB, 0x2F,\n   0xFC, 0x97, 0x05, 0x7A, 0xAC, 0x7F, 0xD5, 0x1A, 0x4B, 0x0E, 0xA7, 0x5A,\n   0x28, 0x14, 0x3F, 0x29, 0x88, 0x3C, 0x4C, 0x02, 0xB8, 0xDA, 0xB0, 0x17,\n   0x55, 0x1F, 0x8A, 0x7D, 0x57, 0xC7, 0x8D, 0x74, 0xB7, 0xC4, 0x9F, 0x72,\n   0x7E, 0x15, 0x22, 0x12, 0x58, 0x07, 0x99, 0x34, 0x6E, 0x50, 0xDE, 0x68,\n   0x65, 0xBC, 0xDB, 0xF8, 0xC8, 0xA8, 0x2B, 0x40, 0xDC, 0xFE, 0x32, 0xA4,\n   0xCA, 0x10, 0x21, 0xF0, 0xD3, 0x5D, 0x0F, 0x00, 0x6F, 0x9D, 0x36, 0x42,\n   0x4A, 0x5E, 0xC1, 0xE0\n},\n{\n   0x75, 0xF3, 0xC6, 0xF4, 0xDB, 0x7B, 0xFB, 0xC8, 0x4A, 0xD3, 0xE6, 0x6B,\n   0x45, 0x7D, 0xE8, 0x4B, 0xD6, 0x32, 0xD8, 0xFD, 0x37, 0x71, 0xF1, 0xE1,\n   0x30, 0x0F, 0xF8, 0x1B, 0x87, 0xFA, 0x06, 0x3F, 0x5E, 0xBA, 0xAE, 0x5B,\n   0x8A, 0x00, 0xBC, 0x9D, 0x6D, 0xC1, 0xB1, 0x0E, 0x80, 0x5D, 0xD2, 0xD5,\n   0xA0, 0x84, 0x07, 0x14, 0xB5, 0x90, 0x2C, 0xA3, 0xB2, 0x73, 0x4C, 0x54,\n   0x92, 0x74, 0x36, 0x51, 0x38, 0xB0, 0xBD, 0x5A, 0xFC, 0x60, 0x62, 0x96,\n   0x6C, 0x42, 0xF7, 0x10, 0x7C, 0x28, 0x27, 0x8C, 0x13, 0x95, 0x9C, 0xC7,\n   0x24, 0x46, 0x3B, 0x70, 0xCA, 0xE3, 0x85, 0xCB, 0x11, 0xD0, 0x93, 0xB8,\n   0xA6, 0x83, 0x20, 0xFF, 0x9F, 0x77, 0xC3, 0xCC, 0x03, 0x6F, 0x08, 0xBF,\n   0x40, 0xE7, 0x2B, 0xE2, 0x79, 0x0C, 0xAA, 0x82, 0x41, 0x3A, 0xEA, 0xB9,\n   0xE4, 0x9A, 0xA4, 0x97, 0x7E, 0xDA, 0x7A, 0x17, 0x66, 0x94, 0xA1, 0x1D,\n   0x3D, 0xF0, 0xDE, 0xB3, 0x0B, 0x72, 0xA7, 0x1C, 0xEF, 0xD1, 0x53, 0x3E,\n   0x8F, 0x33, 0x26, 0x5F, 0xEC, 0x76, 0x2A, 0x49, 0x81, 0x88, 0xEE, 0x21,\n   0xC4, 0x1A, 0xEB, 0xD9, 0xC5, 0x39, 0x99, 0xCD, 0xAD, 0x31, 0x8B, 0x01,\n   0x18, 0x23, 0xDD, 0x1F, 0x4E, 0x2D, 0xF9, 0x48, 0x4F, 0xF2, 0x65, 0x8E,\n   0x78, 0x5C, 0x58, 0x19, 0x8D, 0xE5, 0x98, 0x57, 0x67, 0x7F, 0x05, 0x64,\n   0xAF, 0x63, 0xB6, 0xFE, 0xF5, 0xB7, 0x3C, 0xA5, 0xCE, 0xE9, 0x68, 0x44,\n   0xE0, 0x4D, 0x43, 0x69, 0x29, 0x2E, 0xAC, 0x15, 0x59, 0xA8, 0x0A, 0x9E,\n   0x6E, 0x47, 0xDF, 0x34, 0x35, 0x6A, 0xCF, 0xDC, 0x22, 0xC9, 0xC0, 0x9B,\n   0x89, 0xD4, 0xED, 0xAB, 0x12, 0xA2, 0x0D, 0x52, 0xBB, 0x02, 0x2F, 0xA9,\n   0xD7, 0x61, 0x1E, 0xB4, 0x50, 0x04, 0xF6, 0xC2, 0x16, 0x25, 0x86, 0x56,\n   0x55, 0x09, 0xBE, 0x91\n}\n};\n\n\nconst word32 Twofish::mds_[4][256] = {\n    {\n\t0xbcbc3275, 0xecec21f3, 0x202043c6, 0xb3b3c9f4, \n\t0xdada03db, 0x02028b7b, 0xe2e22bfb, 0x9e9efac8, \n\t0xc9c9ec4a, 0xd4d409d3, 0x18186be6, 0x1e1e9f6b, \n\t0x98980e45, 0xb2b2387d, 0xa6a6d2e8, 0x2626b74b, \n\t0x3c3c57d6, 0x93938a32, 0x8282eed8, 0x525298fd, \n\t0x7b7bd437, 0xbbbb3771, 0x5b5b97f1, 0x474783e1, \n\t0x24243c30, 0x5151e20f, 0xbabac6f8, 0x4a4af31b, \n\t0xbfbf4887, 0x0d0d70fa, 0xb0b0b306, 0x7575de3f, \n\t0xd2d2fd5e, 0x7d7d20ba, 0x666631ae, 0x3a3aa35b, \n\t0x59591c8a, 0x00000000, 0xcdcd93bc, 0x1a1ae09d, \n\t0xaeae2c6d, 0x7f7fabc1, 0x2b2bc7b1, 0xbebeb90e, \n\t0xe0e0a080, 0x8a8a105d, 0x3b3b52d2, 0x6464bad5, \n\t0xd8d888a0, 0xe7e7a584, 0x5f5fe807, 0x1b1b1114, \n\t0x2c2cc2b5, 0xfcfcb490, 0x3131272c, 0x808065a3, \n\t0x73732ab2, 0x0c0c8173, 0x79795f4c, 0x6b6b4154, \n\t0x4b4b0292, 0x53536974, 0x94948f36, 0x83831f51, \n\t0x2a2a3638, 0xc4c49cb0, 0x2222c8bd, 0xd5d5f85a, \n\t0xbdbdc3fc, 0x48487860, 0xffffce62, 0x4c4c0796, \n\t0x4141776c, 0xc7c7e642, 0xebeb24f7, 0x1c1c1410, \n\t0x5d5d637c, 0x36362228, 0x6767c027, 0xe9e9af8c, \n\t0x4444f913, 0x1414ea95, 0xf5f5bb9c, 0xcfcf18c7, \n\t0x3f3f2d24, 0xc0c0e346, 0x7272db3b, 0x54546c70, \n\t0x29294cca, 0xf0f035e3, 0x0808fe85, 0xc6c617cb, \n\t0xf3f34f11, 0x8c8ce4d0, 0xa4a45993, 0xcaca96b8, \n\t0x68683ba6, 0xb8b84d83, 0x38382820, 0xe5e52eff, \n\t0xadad569f, 0x0b0b8477, 0xc8c81dc3, 0x9999ffcc, \n\t0x5858ed03, 0x19199a6f, 0x0e0e0a08, 0x95957ebf, \n\t0x70705040, 0xf7f730e7, 0x6e6ecf2b, 0x1f1f6ee2, \n\t0xb5b53d79, 0x09090f0c, 0x616134aa, 0x57571682, \n\t0x9f9f0b41, 0x9d9d803a, 0x111164ea, 0x2525cdb9, \n\t0xafafdde4, 0x4545089a, 0xdfdf8da4, 0xa3a35c97, \n\t0xeaead57e, 0x353558da, 0xededd07a, 0x4343fc17, \n\t0xf8f8cb66, 0xfbfbb194, 0x3737d3a1, 0xfafa401d, \n\t0xc2c2683d, 0xb4b4ccf0, 0x32325dde, 0x9c9c71b3, \n\t0x5656e70b, 0xe3e3da72, 0x878760a7, 0x15151b1c, \n\t0xf9f93aef, 0x6363bfd1, 0x3434a953, 0x9a9a853e, \n\t0xb1b1428f, 0x7c7cd133, 0x88889b26, 0x3d3da65f, \n\t0xa1a1d7ec, 0xe4e4df76, 0x8181942a, 0x91910149, \n\t0x0f0ffb81, 0xeeeeaa88, 0x161661ee, 0xd7d77321, \n\t0x9797f5c4, 0xa5a5a81a, 0xfefe3feb, 0x6d6db5d9, \n\t0x7878aec5, 0xc5c56d39, 0x1d1de599, 0x7676a4cd, \n\t0x3e3edcad, 0xcbcb6731, 0xb6b6478b, 0xefef5b01, \n\t0x12121e18, 0x6060c523, 0x6a6ab0dd, 0x4d4df61f, \n\t0xcecee94e, 0xdede7c2d, 0x55559df9, 0x7e7e5a48, \n\t0x2121b24f, 0x03037af2, 0xa0a02665, 0x5e5e198e, \n\t0x5a5a6678, 0x65654b5c, 0x62624e58, 0xfdfd4519, \n\t0x0606f48d, 0x404086e5, 0xf2f2be98, 0x3333ac57, \n\t0x17179067, 0x05058e7f, 0xe8e85e05, 0x4f4f7d64, \n\t0x89896aaf, 0x10109563, 0x74742fb6, 0x0a0a75fe, \n\t0x5c5c92f5, 0x9b9b74b7, 0x2d2d333c, 0x3030d6a5, \n\t0x2e2e49ce, 0x494989e9, 0x46467268, 0x77775544, \n\t0xa8a8d8e0, 0x9696044d, 0x2828bd43, 0xa9a92969, \n\t0xd9d97929, 0x8686912e, 0xd1d187ac, 0xf4f44a15, \n\t0x8d8d1559, 0xd6d682a8, 0xb9b9bc0a, 0x42420d9e, \n\t0xf6f6c16e, 0x2f2fb847, 0xdddd06df, 0x23233934, \n\t0xcccc6235, 0xf1f1c46a, 0xc1c112cf, 0x8585ebdc, \n\t0x8f8f9e22, 0x7171a1c9, 0x9090f0c0, 0xaaaa539b, \n\t0x0101f189, 0x8b8be1d4, 0x4e4e8ced, 0x8e8e6fab, \n\t0xababa212, 0x6f6f3ea2, 0xe6e6540d, 0xdbdbf252, \n\t0x92927bbb, 0xb7b7b602, 0x6969ca2f, 0x3939d9a9, \n\t0xd3d30cd7, 0xa7a72361, 0xa2a2ad1e, 0xc3c399b4, \n\t0x6c6c4450, 0x07070504, 0x04047ff6, 0x272746c2, \n\t0xacaca716, 0xd0d07625, 0x50501386, 0xdcdcf756, \n\t0x84841a55, 0xe1e15109, 0x7a7a25be, 0x1313ef91\n    },\n    {\n\t0xa9d93939, 0x67901717, 0xb3719c9c, 0xe8d2a6a6, \n\t0x04050707, 0xfd985252, 0xa3658080, 0x76dfe4e4, \n\t0x9a084545, 0x92024b4b, 0x80a0e0e0, 0x78665a5a, \n\t0xe4ddafaf, 0xddb06a6a, 0xd1bf6363, 0x38362a2a, \n\t0x0d54e6e6, 0xc6432020, 0x3562cccc, 0x98bef2f2, \n\t0x181e1212, 0xf724ebeb, 0xecd7a1a1, 0x6c774141, \n\t0x43bd2828, 0x7532bcbc, 0x37d47b7b, 0x269b8888, \n\t0xfa700d0d, 0x13f94444, 0x94b1fbfb, 0x485a7e7e, \n\t0xf27a0303, 0xd0e48c8c, 0x8b47b6b6, 0x303c2424, \n\t0x84a5e7e7, 0x54416b6b, 0xdf06dddd, 0x23c56060, \n\t0x1945fdfd, 0x5ba33a3a, 0x3d68c2c2, 0x59158d8d, \n\t0xf321ecec, 0xae316666, 0xa23e6f6f, 0x82165757, \n\t0x63951010, 0x015befef, 0x834db8b8, 0x2e918686, \n\t0xd9b56d6d, 0x511f8383, 0x9b53aaaa, 0x7c635d5d, \n\t0xa63b6868, 0xeb3ffefe, 0xa5d63030, 0xbe257a7a, \n\t0x16a7acac, 0x0c0f0909, 0xe335f0f0, 0x6123a7a7, \n\t0xc0f09090, 0x8cafe9e9, 0x3a809d9d, 0xf5925c5c, \n\t0x73810c0c, 0x2c273131, 0x2576d0d0, 0x0be75656, \n\t0xbb7b9292, 0x4ee9cece, 0x89f10101, 0x6b9f1e1e, \n\t0x53a93434, 0x6ac4f1f1, 0xb499c3c3, 0xf1975b5b, \n\t0xe1834747, 0xe66b1818, 0xbdc82222, 0x450e9898, \n\t0xe26e1f1f, 0xf4c9b3b3, 0xb62f7474, 0x66cbf8f8, \n\t0xccff9999, 0x95ea1414, 0x03ed5858, 0x56f7dcdc, \n\t0xd4e18b8b, 0x1c1b1515, 0x1eada2a2, 0xd70cd3d3, \n\t0xfb2be2e2, 0xc31dc8c8, 0x8e195e5e, 0xb5c22c2c, \n\t0xe9894949, 0xcf12c1c1, 0xbf7e9595, 0xba207d7d, \n\t0xea641111, 0x77840b0b, 0x396dc5c5, 0xaf6a8989, \n\t0x33d17c7c, 0xc9a17171, 0x62ceffff, 0x7137bbbb, \n\t0x81fb0f0f, 0x793db5b5, 0x0951e1e1, 0xaddc3e3e, \n\t0x242d3f3f, 0xcda47676, 0xf99d5555, 0xd8ee8282, \n\t0xe5864040, 0xc5ae7878, 0xb9cd2525, 0x4d049696, \n\t0x44557777, 0x080a0e0e, 0x86135050, 0xe730f7f7, \n\t0xa1d33737, 0x1d40fafa, 0xaa346161, 0xed8c4e4e, \n\t0x06b3b0b0, 0x706c5454, 0xb22a7373, 0xd2523b3b, \n\t0x410b9f9f, 0x7b8b0202, 0xa088d8d8, 0x114ff3f3, \n\t0x3167cbcb, 0xc2462727, 0x27c06767, 0x90b4fcfc, \n\t0x20283838, 0xf67f0404, 0x60784848, 0xff2ee5e5, \n\t0x96074c4c, 0x5c4b6565, 0xb1c72b2b, 0xab6f8e8e, \n\t0x9e0d4242, 0x9cbbf5f5, 0x52f2dbdb, 0x1bf34a4a, \n\t0x5fa63d3d, 0x9359a4a4, 0x0abcb9b9, 0xef3af9f9, \n\t0x91ef1313, 0x85fe0808, 0x49019191, 0xee611616, \n\t0x2d7cdede, 0x4fb22121, 0x8f42b1b1, 0x3bdb7272, \n\t0x47b82f2f, 0x8748bfbf, 0x6d2caeae, 0x46e3c0c0, \n\t0xd6573c3c, 0x3e859a9a, 0x6929a9a9, 0x647d4f4f, \n\t0x2a948181, 0xce492e2e, 0xcb17c6c6, 0x2fca6969, \n\t0xfcc3bdbd, 0x975ca3a3, 0x055ee8e8, 0x7ad0eded, \n\t0xac87d1d1, 0x7f8e0505, 0xd5ba6464, 0x1aa8a5a5, \n\t0x4bb72626, 0x0eb9bebe, 0xa7608787, 0x5af8d5d5, \n\t0x28223636, 0x14111b1b, 0x3fde7575, 0x2979d9d9, \n\t0x88aaeeee, 0x3c332d2d, 0x4c5f7979, 0x02b6b7b7, \n\t0xb896caca, 0xda583535, 0xb09cc4c4, 0x17fc4343, \n\t0x551a8484, 0x1ff64d4d, 0x8a1c5959, 0x7d38b2b2, \n\t0x57ac3333, 0xc718cfcf, 0x8df40606, 0x74695353, \n\t0xb7749b9b, 0xc4f59797, 0x9f56adad, 0x72dae3e3, \n\t0x7ed5eaea, 0x154af4f4, 0x229e8f8f, 0x12a2abab, \n\t0x584e6262, 0x07e85f5f, 0x99e51d1d, 0x34392323, \n\t0x6ec1f6f6, 0x50446c6c, 0xde5d3232, 0x68724646, \n\t0x6526a0a0, 0xbc93cdcd, 0xdb03dada, 0xf8c6baba, \n\t0xc8fa9e9e, 0xa882d6d6, 0x2bcf6e6e, 0x40507070, \n\t0xdceb8585, 0xfe750a0a, 0x328a9393, 0xa48ddfdf, \n\t0xca4c2929, 0x10141c1c, 0x2173d7d7, 0xf0ccb4b4, \n\t0xd309d4d4, 0x5d108a8a, 0x0fe25151, 0x00000000, \n\t0x6f9a1919, 0x9de01a1a, 0x368f9494, 0x42e6c7c7, \n\t0x4aecc9c9, 0x5efdd2d2, 0xc1ab7f7f, 0xe0d8a8a8\n    },\n    {\n\t0xbc75bc32, 0xecf3ec21, 0x20c62043, 0xb3f4b3c9, \n\t0xdadbda03, 0x027b028b, 0xe2fbe22b, 0x9ec89efa, \n\t0xc94ac9ec, 0xd4d3d409, 0x18e6186b, 0x1e6b1e9f, \n\t0x9845980e, 0xb27db238, 0xa6e8a6d2, 0x264b26b7, \n\t0x3cd63c57, 0x9332938a, 0x82d882ee, 0x52fd5298, \n\t0x7b377bd4, 0xbb71bb37, 0x5bf15b97, 0x47e14783, \n\t0x2430243c, 0x510f51e2, 0xbaf8bac6, 0x4a1b4af3, \n\t0xbf87bf48, 0x0dfa0d70, 0xb006b0b3, 0x753f75de, \n\t0xd25ed2fd, 0x7dba7d20, 0x66ae6631, 0x3a5b3aa3, \n\t0x598a591c, 0x00000000, 0xcdbccd93, 0x1a9d1ae0, \n\t0xae6dae2c, 0x7fc17fab, 0x2bb12bc7, 0xbe0ebeb9, \n\t0xe080e0a0, 0x8a5d8a10, 0x3bd23b52, 0x64d564ba, \n\t0xd8a0d888, 0xe784e7a5, 0x5f075fe8, 0x1b141b11, \n\t0x2cb52cc2, 0xfc90fcb4, 0x312c3127, 0x80a38065, \n\t0x73b2732a, 0x0c730c81, 0x794c795f, 0x6b546b41, \n\t0x4b924b02, 0x53745369, 0x9436948f, 0x8351831f, \n\t0x2a382a36, 0xc4b0c49c, 0x22bd22c8, 0xd55ad5f8, \n\t0xbdfcbdc3, 0x48604878, 0xff62ffce, 0x4c964c07, \n\t0x416c4177, 0xc742c7e6, 0xebf7eb24, 0x1c101c14, \n\t0x5d7c5d63, 0x36283622, 0x672767c0, 0xe98ce9af, \n\t0x441344f9, 0x149514ea, 0xf59cf5bb, 0xcfc7cf18, \n\t0x3f243f2d, 0xc046c0e3, 0x723b72db, 0x5470546c, \n\t0x29ca294c, 0xf0e3f035, 0x088508fe, 0xc6cbc617, \n\t0xf311f34f, 0x8cd08ce4, 0xa493a459, 0xcab8ca96, \n\t0x68a6683b, 0xb883b84d, 0x38203828, 0xe5ffe52e, \n\t0xad9fad56, 0x0b770b84, 0xc8c3c81d, 0x99cc99ff, \n\t0x580358ed, 0x196f199a, 0x0e080e0a, 0x95bf957e, \n\t0x70407050, 0xf7e7f730, 0x6e2b6ecf, 0x1fe21f6e, \n\t0xb579b53d, 0x090c090f, 0x61aa6134, 0x57825716, \n\t0x9f419f0b, 0x9d3a9d80, 0x11ea1164, 0x25b925cd, \n\t0xafe4afdd, 0x459a4508, 0xdfa4df8d, 0xa397a35c, \n\t0xea7eead5, 0x35da3558, 0xed7aedd0, 0x431743fc, \n\t0xf866f8cb, 0xfb94fbb1, 0x37a137d3, 0xfa1dfa40, \n\t0xc23dc268, 0xb4f0b4cc, 0x32de325d, 0x9cb39c71, \n\t0x560b56e7, 0xe372e3da, 0x87a78760, 0x151c151b, \n\t0xf9eff93a, 0x63d163bf, 0x345334a9, 0x9a3e9a85, \n\t0xb18fb142, 0x7c337cd1, 0x8826889b, 0x3d5f3da6, \n\t0xa1eca1d7, 0xe476e4df, 0x812a8194, 0x91499101, \n\t0x0f810ffb, 0xee88eeaa, 0x16ee1661, 0xd721d773, \n\t0x97c497f5, 0xa51aa5a8, 0xfeebfe3f, 0x6dd96db5, \n\t0x78c578ae, 0xc539c56d, 0x1d991de5, 0x76cd76a4, \n\t0x3ead3edc, 0xcb31cb67, 0xb68bb647, 0xef01ef5b, \n\t0x1218121e, 0x602360c5, 0x6add6ab0, 0x4d1f4df6, \n\t0xce4ecee9, 0xde2dde7c, 0x55f9559d, 0x7e487e5a, \n\t0x214f21b2, 0x03f2037a, 0xa065a026, 0x5e8e5e19, \n\t0x5a785a66, 0x655c654b, 0x6258624e, 0xfd19fd45, \n\t0x068d06f4, 0x40e54086, 0xf298f2be, 0x335733ac, \n\t0x17671790, 0x057f058e, 0xe805e85e, 0x4f644f7d, \n\t0x89af896a, 0x10631095, 0x74b6742f, 0x0afe0a75, \n\t0x5cf55c92, 0x9bb79b74, 0x2d3c2d33, 0x30a530d6, \n\t0x2ece2e49, 0x49e94989, 0x46684672, 0x77447755, \n\t0xa8e0a8d8, 0x964d9604, 0x284328bd, 0xa969a929, \n\t0xd929d979, 0x862e8691, 0xd1acd187, 0xf415f44a, \n\t0x8d598d15, 0xd6a8d682, 0xb90ab9bc, 0x429e420d, \n\t0xf66ef6c1, 0x2f472fb8, 0xdddfdd06, 0x23342339, \n\t0xcc35cc62, 0xf16af1c4, 0xc1cfc112, 0x85dc85eb, \n\t0x8f228f9e, 0x71c971a1, 0x90c090f0, 0xaa9baa53, \n\t0x018901f1, 0x8bd48be1, 0x4eed4e8c, 0x8eab8e6f, \n\t0xab12aba2, 0x6fa26f3e, 0xe60de654, 0xdb52dbf2, \n\t0x92bb927b, 0xb702b7b6, 0x692f69ca, 0x39a939d9, \n\t0xd3d7d30c, 0xa761a723, 0xa21ea2ad, 0xc3b4c399, \n\t0x6c506c44, 0x07040705, 0x04f6047f, 0x27c22746, \n\t0xac16aca7, 0xd025d076, 0x50865013, 0xdc56dcf7, \n\t0x8455841a, 0xe109e151, 0x7abe7a25, 0x139113ef\n    },\n    {\n\t0xd939a9d9, 0x90176790, 0x719cb371, 0xd2a6e8d2, \n\t0x05070405, 0x9852fd98, 0x6580a365, 0xdfe476df, \n\t0x08459a08, 0x024b9202, 0xa0e080a0, 0x665a7866, \n\t0xddafe4dd, 0xb06addb0, 0xbf63d1bf, 0x362a3836, \n\t0x54e60d54, 0x4320c643, 0x62cc3562, 0xbef298be, \n\t0x1e12181e, 0x24ebf724, 0xd7a1ecd7, 0x77416c77, \n\t0xbd2843bd, 0x32bc7532, 0xd47b37d4, 0x9b88269b, \n\t0x700dfa70, 0xf94413f9, 0xb1fb94b1, 0x5a7e485a, \n\t0x7a03f27a, 0xe48cd0e4, 0x47b68b47, 0x3c24303c, \n\t0xa5e784a5, 0x416b5441, 0x06dddf06, 0xc56023c5, \n\t0x45fd1945, 0xa33a5ba3, 0x68c23d68, 0x158d5915, \n\t0x21ecf321, 0x3166ae31, 0x3e6fa23e, 0x16578216, \n\t0x95106395, 0x5bef015b, 0x4db8834d, 0x91862e91, \n\t0xb56dd9b5, 0x1f83511f, 0x53aa9b53, 0x635d7c63, \n\t0x3b68a63b, 0x3ffeeb3f, 0xd630a5d6, 0x257abe25, \n\t0xa7ac16a7, 0x0f090c0f, 0x35f0e335, 0x23a76123, \n\t0xf090c0f0, 0xafe98caf, 0x809d3a80, 0x925cf592, \n\t0x810c7381, 0x27312c27, 0x76d02576, 0xe7560be7, \n\t0x7b92bb7b, 0xe9ce4ee9, 0xf10189f1, 0x9f1e6b9f, \n\t0xa93453a9, 0xc4f16ac4, 0x99c3b499, 0x975bf197, \n\t0x8347e183, 0x6b18e66b, 0xc822bdc8, 0x0e98450e, \n\t0x6e1fe26e, 0xc9b3f4c9, 0x2f74b62f, 0xcbf866cb, \n\t0xff99ccff, 0xea1495ea, 0xed5803ed, 0xf7dc56f7, \n\t0xe18bd4e1, 0x1b151c1b, 0xada21ead, 0x0cd3d70c, \n\t0x2be2fb2b, 0x1dc8c31d, 0x195e8e19, 0xc22cb5c2, \n\t0x8949e989, 0x12c1cf12, 0x7e95bf7e, 0x207dba20, \n\t0x6411ea64, 0x840b7784, 0x6dc5396d, 0x6a89af6a, \n\t0xd17c33d1, 0xa171c9a1, 0xceff62ce, 0x37bb7137, \n\t0xfb0f81fb, 0x3db5793d, 0x51e10951, 0xdc3eaddc, \n\t0x2d3f242d, 0xa476cda4, 0x9d55f99d, 0xee82d8ee, \n\t0x8640e586, 0xae78c5ae, 0xcd25b9cd, 0x04964d04, \n\t0x55774455, 0x0a0e080a, 0x13508613, 0x30f7e730, \n\t0xd337a1d3, 0x40fa1d40, 0x3461aa34, 0x8c4eed8c, \n\t0xb3b006b3, 0x6c54706c, 0x2a73b22a, 0x523bd252, \n\t0x0b9f410b, 0x8b027b8b, 0x88d8a088, 0x4ff3114f, \n\t0x67cb3167, 0x4627c246, 0xc06727c0, 0xb4fc90b4, \n\t0x28382028, 0x7f04f67f, 0x78486078, 0x2ee5ff2e, \n\t0x074c9607, 0x4b655c4b, 0xc72bb1c7, 0x6f8eab6f, \n\t0x0d429e0d, 0xbbf59cbb, 0xf2db52f2, 0xf34a1bf3, \n\t0xa63d5fa6, 0x59a49359, 0xbcb90abc, 0x3af9ef3a, \n\t0xef1391ef, 0xfe0885fe, 0x01914901, 0x6116ee61, \n\t0x7cde2d7c, 0xb2214fb2, 0x42b18f42, 0xdb723bdb, \n\t0xb82f47b8, 0x48bf8748, 0x2cae6d2c, 0xe3c046e3, \n\t0x573cd657, 0x859a3e85, 0x29a96929, 0x7d4f647d, \n\t0x94812a94, 0x492ece49, 0x17c6cb17, 0xca692fca, \n\t0xc3bdfcc3, 0x5ca3975c, 0x5ee8055e, 0xd0ed7ad0, \n\t0x87d1ac87, 0x8e057f8e, 0xba64d5ba, 0xa8a51aa8, \n\t0xb7264bb7, 0xb9be0eb9, 0x6087a760, 0xf8d55af8, \n\t0x22362822, 0x111b1411, 0xde753fde, 0x79d92979, \n\t0xaaee88aa, 0x332d3c33, 0x5f794c5f, 0xb6b702b6, \n\t0x96cab896, 0x5835da58, 0x9cc4b09c, 0xfc4317fc, \n\t0x1a84551a, 0xf64d1ff6, 0x1c598a1c, 0x38b27d38, \n\t0xac3357ac, 0x18cfc718, 0xf4068df4, 0x69537469, \n\t0x749bb774, 0xf597c4f5, 0x56ad9f56, 0xdae372da, \n\t0xd5ea7ed5, 0x4af4154a, 0x9e8f229e, 0xa2ab12a2, \n\t0x4e62584e, 0xe85f07e8, 0xe51d99e5, 0x39233439, \n\t0xc1f66ec1, 0x446c5044, 0x5d32de5d, 0x72466872, \n\t0x26a06526, 0x93cdbc93, 0x03dadb03, 0xc6baf8c6, \n\t0xfa9ec8fa, 0x82d6a882, 0xcf6e2bcf, 0x50704050, \n\t0xeb85dceb, 0x750afe75, 0x8a93328a, 0x8ddfa48d, \n\t0x4c29ca4c, 0x141c1014, 0x73d72173, 0xccb4f0cc, \n\t0x09d4d309, 0x108a5d10, 0xe2510fe2, 0x00000000, \n\t0x9a196f9a, 0xe01a9de0, 0x8f94368f, 0xe6c742e6, \n\t0xecc94aec, 0xfdd25efd, 0xab7fc1ab, 0xd8a8e0d8\n    }\n};\n\n\n} // namespace\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/src/twofish.cpp",
    "content": "/*\n   Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n/* C++ based on Wei Dai's twofish.cpp from CryptoPP */\n/* x86 asm original */\n\n\n#if defined(TAOCRYPT_KERNEL_MODE)\n    #define DO_TAOCRYPT_KERNEL_MODE\n#endif                                  // only some modules now support this\n\n#include \"runtime.hpp\"\n#include \"twofish.hpp\"\n\n\n\nnamespace TaoCrypt {\n\n\n#if defined(DO_TWOFISH_ASM)\n\n// ia32 optimized version\nvoid Twofish::Process(byte* out, const byte* in, word32 sz)\n{\n    if (!isMMX) {\n        Mode_BASE::Process(out, in, sz);\n        return;\n    }\n\n    word32 blocks = sz / BLOCK_SIZE;\n\n    if (mode_ == ECB)\n        while (blocks--) {\n            if (dir_ == ENCRYPTION)\n                AsmEncrypt(in, out);\n            else\n                AsmDecrypt(in, out);\n        \n            out += BLOCK_SIZE;\n            in  += BLOCK_SIZE;\n        }\n    else if (mode_ == CBC) {\n        if (dir_ == ENCRYPTION) {\n            while (blocks--) {\n                r_[0] ^= *(word32*)in;\n                r_[1] ^= *(word32*)(in +  4);\n                r_[2] ^= *(word32*)(in +  8);\n                r_[3] ^= *(word32*)(in + 12);\n\n                AsmEncrypt((byte*)r_, (byte*)r_);\n                memcpy(out, r_, BLOCK_SIZE);\n\n                out += BLOCK_SIZE;\n                in  += BLOCK_SIZE;\n            }\n        }\n        else {\n            while (blocks--) {\n                AsmDecrypt(in, out);\n               \n                *(word32*)out        ^= r_[0];\n                *(word32*)(out +  4) ^= r_[1];\n                *(word32*)(out +  8) ^= r_[2];\n                *(word32*)(out + 12) ^= r_[3];\n\n                memcpy(r_, in, BLOCK_SIZE);\n\n                out += BLOCK_SIZE;\n                in  += BLOCK_SIZE;\n            }\n        }\n    }\n}\n\n#endif // DO_TWOFISH_ASM\n\n\nnamespace {     // locals\n\n// compute (c * x^4) mod (x^4 + (a + 1/a) * x^3 + a * x^2 + (a + 1/a) * x + 1)\n// over GF(256)\nstatic inline unsigned int Mod(unsigned int c)\n{\n\tstatic const unsigned int modulus = 0x14d;\n\tunsigned int c2 = (c<<1) ^ ((c & 0x80) ? modulus : 0);\n\tunsigned int c1 = c2 ^ (c>>1) ^ ((c & 1) ? (modulus>>1) : 0);\n\treturn c | (c1 << 8) | (c2 << 16) | (c1 << 24);\n}\n\n// compute RS(12,8) code with the above polynomial as generator\n// this is equivalent to multiplying by the RS matrix\nstatic word32 ReedSolomon(word32 high, word32 low)\n{\n\tfor (unsigned int i=0; i<8; i++) {\n\t\thigh = Mod(high>>24) ^ (high<<8) ^ (low>>24);\n\t\tlow <<= 8;\n\t}\n\treturn high;\n}\n\n}  // local namespace\n\n\n\ninline word32 Twofish::h0(word32 x, const word32* key, unsigned int kLen)\n{\n\tx = x | (x<<8) | (x<<16) | (x<<24);\n\tswitch(kLen)\n\t{\n#define Q(a, b, c, d, t) q_[a][GETBYTE(t,0)] ^ (q_[b][GETBYTE(t,1)] << 8) ^  \\\n            (q_[c][GETBYTE(t,2)] << 16) ^ (q_[d][GETBYTE(t,3)] << 24)\n\tcase 4: x = Q(1, 0, 0, 1, x) ^ key[6];\n\tcase 3: x = Q(1, 1, 0, 0, x) ^ key[4];\n\tcase 2: x = Q(0, 1, 0, 1, x) ^ key[2];\n\t\t\tx = Q(0, 0, 1, 1, x) ^ key[0];\n\t}\n\treturn x;\n}\n\ninline word32 Twofish::h(word32 x, const word32* key, unsigned int kLen)\n{\n\tx = h0(x, key, kLen);\n\treturn mds_[0][GETBYTE(x,0)] ^ mds_[1][GETBYTE(x,1)] ^ \n        mds_[2][GETBYTE(x,2)] ^ mds_[3][GETBYTE(x,3)];\n}\n\n\nvoid Twofish::SetKey(const byte* userKey, word32 keylen, CipherDir /*dummy*/)\n{\n\tunsigned int len = (keylen <= 16 ? 2 : (keylen <= 24 ? 3 : 4));\n    word32 key[8];\n\tGetUserKey(LittleEndianOrder, key, len*2, userKey, keylen);\n\n\tunsigned int i;\n\tfor (i=0; i<40; i+=2) {\n\t\tword32 a = h(i, key, len);\n\t\tword32 b = rotlFixed(h(i+1, key+1, len), 8);\n\t\tk_[i] = a+b;\n\t\tk_[i+1] = rotlFixed(a+2*b, 9);\n\t}\n\n\tword32 svec[8];\n\tfor (i=0; i<len; i++)\n\t\tsvec[2*(len-i-1)] = ReedSolomon(key[2*i+1], key[2*i]);\n\n\tfor (i=0; i<256; i++) {\n\t\tword32 t = h0(i, svec, len);\n\t\ts_[0][i] = mds_[0][GETBYTE(t, 0)];\n\t\ts_[1][i] = mds_[1][GETBYTE(t, 1)];\n\t\ts_[2][i] = mds_[2][GETBYTE(t, 2)];\n\t\ts_[3][i] = mds_[3][GETBYTE(t, 3)];\n\t}\n}\n\n\nvoid Twofish::ProcessAndXorBlock(const byte* in, const byte* xOr, byte* out)\n    const\n{\n    if (dir_ == ENCRYPTION)\n        encrypt(in, xOr, out);\n    else\n        decrypt(in, xOr, out);\n}\n\n#define G1(x) (s_[0][GETBYTE(x,0)] ^ s_[1][GETBYTE(x,1)] ^ \\\n            s_[2][GETBYTE(x,2)] ^ s_[3][GETBYTE(x,3)])\n#define G2(x) (s_[0][GETBYTE(x,3)] ^ s_[1][GETBYTE(x,0)] ^ \\\n            s_[2][GETBYTE(x,1)] ^ s_[3][GETBYTE(x,2)])\n\n#define ENCROUND(n, a, b, c, d) \\\n\tx = G1 (a); y = G2 (b); \\\n\tx += y; y += x + k[2 * (n) + 1]; \\\n\t(c) ^= x + k[2 * (n)]; \\\n\t(c) = rotrFixed(c, 1); \\\n\t(d) = rotlFixed(d, 1) ^ y\n\n#define ENCCYCLE(n) \\\n\tENCROUND (2 * (n), a, b, c, d); \\\n\tENCROUND (2 * (n) + 1, c, d, a, b)\n\n#define DECROUND(n, a, b, c, d) \\\n\tx = G1 (a); y = G2 (b); \\\n\tx += y; y += x; \\\n\t(d) ^= y + k[2 * (n) + 1]; \\\n\t(d) = rotrFixed(d, 1); \\\n\t(c) = rotlFixed(c, 1); \\\n\t(c) ^= (x + k[2 * (n)])\n\n#define DECCYCLE(n) \\\n\tDECROUND (2 * (n) + 1, c, d, a, b); \\\n\tDECROUND (2 * (n), a, b, c, d)\n\n\ntypedef BlockGetAndPut<word32, LittleEndian> gpBlock;\n\nvoid Twofish::encrypt(const byte* inBlock, const byte* xorBlock,\n                  byte* outBlock) const\n{\n\tword32 x, y, a, b, c, d;\n\n\tgpBlock::Get(inBlock)(a)(b)(c)(d);\n\n\ta ^= k_[0];\n\tb ^= k_[1];\n\tc ^= k_[2];\n\td ^= k_[3];\n\n\tconst word32 *k = k_+8;\n\n\tENCCYCLE (0);\n\tENCCYCLE (1);\n\tENCCYCLE (2);\n\tENCCYCLE (3);\n\tENCCYCLE (4);\n\tENCCYCLE (5);\n\tENCCYCLE (6);\n\tENCCYCLE (7);\n\n\tc ^= k_[4];\n\td ^= k_[5];\n\ta ^= k_[6];\n\tb ^= k_[7]; \n\n\tgpBlock::Put(xorBlock, outBlock)(c)(d)(a)(b);\n}\n\n\nvoid Twofish::decrypt(const byte* inBlock, const byte* xorBlock,\n                  byte* outBlock) const\n{\n\tword32 x, y, a, b, c, d;\n\n\tgpBlock::Get(inBlock)(c)(d)(a)(b);\n\n\tc ^= k_[4];\n\td ^= k_[5];\n\ta ^= k_[6];\n\tb ^= k_[7];\n\n\tconst word32 *k = k_+8;\n\tDECCYCLE (7);\n\tDECCYCLE (6);\n\tDECCYCLE (5);\n\tDECCYCLE (4);\n\tDECCYCLE (3);\n\tDECCYCLE (2);\n\tDECCYCLE (1);\n\tDECCYCLE (0);\n\n\ta ^= k_[0];\n\tb ^= k_[1];\n\tc ^= k_[2];\n\td ^= k_[3];\n\n\tgpBlock::Put(xorBlock, outBlock)(a)(b)(c)(d);\n}\n\n\n\n#if defined(DO_TWOFISH_ASM)\n    #ifdef __GNUC__\n        #define AS1(x)    #x \";\"\n        #define AS2(x, y) #x \", \" #y \";\"\n\n        #define PROLOG()  \\\n        __asm__ __volatile__ \\\n        ( \\\n            \".intel_syntax noprefix;\" \\\n            \"push ebx;\" \\\n            \"push ebp;\" \\\n            \"movd mm3, eax;\" \\\n            \"movd mm6, ebp;\"\n        #define EPILOG()  \\\n            \"pop ebp;\" \\\n            \"pop ebx;\" \\\n       \t    \"emms;\" \\\n       \t    \".att_syntax;\" \\\n                : \\\n                : \"D\" (this), \"S\" (inBlock), \"a\" (outBlock) \\\n                : \"%ecx\", \"%edx\", \"memory\", \"cc\" \\\n        );\n\n    #else\n        #define AS1(x)    __asm x\n        #define AS2(x, y) __asm x, y\n\n        #define PROLOG() \\\n            AS1(    push  ebp                           )   \\\n            AS2(    mov   ebp, esp                      )   \\\n            AS2(    movd  mm3, edi                      )   \\\n            AS2(    movd  mm4, ebx                      )   \\\n            AS2(    movd  mm5, esi                      )   \\\n            AS2(    movd  mm6, ebp                      )   \\\n            AS2(    mov   edi, ecx                      )   \\\n            AS2(    mov   esi, DWORD PTR [ebp +  8]     )\n\n        /* ebp already set */\n        #define EPILOG()  \\\n            AS2(    movd esi, mm5                   )   \\\n            AS2(    movd ebx, mm4                   )   \\\n            AS2(    movd edi, mm3                   )   \\\n            AS2(    mov  esp, ebp                   )   \\\n            AS1(    pop  ebp                        )   \\\n            AS1(    emms                            )   \\\n            AS1(    ret 8                           )    \n            \n    #endif\n\n\n\n\n    // x = esi, y = [esp], s_ = ebp\n    // edi always open for G1 and G2\n    // G1 also uses edx after save and restore\n    // G2 also uses eax after save and restore\n    //      and ecx for tmp [esp] which Rounds also use\n    //      and restore from mm7\n\n    // x = G1(a)   bytes(0,1,2,3)\n#define ASMG1(z, zl, zh) \\\n    AS2(    movd  mm2, edx                          )   \\\n    AS2(    movzx edi, zl                           )   \\\n    AS2(    mov   esi, DWORD PTR     [ebp + edi*4]  )   \\\n    AS2(    movzx edx, zh                           )   \\\n    AS2(    xor   esi, DWORD PTR 1024[ebp + edx*4]  )   \\\n                                                        \\\n    AS2(    mov   edx, z                            )   \\\n    AS2(    shr   edx, 16                           )   \\\n    AS2(    movzx edi, dl                           )   \\\n    AS2(    xor   esi, DWORD PTR 2048[ebp + edi*4]  )   \\\n    AS2(    movzx edx, dh                           )   \\\n    AS2(    xor   esi, DWORD PTR 3072[ebp + edx*4]  )   \\\n    AS2(    movd  edx, mm2                          )\n\n\n    // y = G2(b)  bytes(3,0,1,2)  [ put y into ecx for Rounds ]\n#define ASMG2(z, zl, zh)    \\\n    AS2(    movd  mm7, ecx                          )   \\\n    AS2(    movd  mm2, eax                          )   \\\n    AS2(    mov   edi, z                            )   \\\n    AS2(    shr   edi, 24                           )   \\\n    AS2(    mov   ecx, DWORD PTR     [ebp + edi*4]  )   \\\n    AS2(    movzx eax, zl                           )   \\\n    AS2(    xor   ecx, DWORD PTR 1024[ebp + eax*4]  )   \\\n                                                        \\\n    AS2(    mov   eax, z                            )   \\\n    AS2(    shr   eax, 16                           )   \\\n    AS2(    movzx edi, zh                           )   \\\n    AS2(    xor   ecx, DWORD PTR 2048[ebp + edi*4]  )   \\\n    AS2(    movzx eax, al                           )   \\\n    AS2(    xor   ecx, DWORD PTR 3072[ebp + eax*4]  )   \\\n    AS2(    movd  eax, mm2                          )\n\n\n    // encrypt Round (n), \n    // x = esi, k = ebp, edi open\n    // y is in ecx from G2, restore when done from mm7\n    //      before C (which be same register!)\n#define ASMENCROUND(N, A, A2, A3, B, B2, B3, C, D)      \\\n    /* setup s_  */                                     \\\n    AS2(    movd  ebp, mm1                          )   \\\n    ASMG1(A, A2, A3)                                    \\\n    ASMG2(B, B2, B3)                                    \\\n    /* setup k  */                                      \\\n    AS2(    movd  ebp, mm0                          )   \\\n    /* x += y   */                                      \\\n    AS2(    add   esi, ecx                          )   \\\n    AS2(    add   ebp, 32                           )   \\\n    /* y += x + k[2 * (n) + 1] */                       \\\n    AS2(    add   ecx, esi                          )   \\\n    AS2(    rol   D,   1                            )   \\\n    AS2(    add   ecx, DWORD PTR [ebp + 8 * N + 4]  )   \\\n\t/* (d) = rotlFixed(d, 1) ^ y  */                    \\\n    AS2(    xor   D,   ecx                          )   \\\n    AS2(    movd  ecx, mm7                          )   \\\n\t/* (c) ^= x + k[2 * (n)] */                         \\\n    AS2(    mov   edi, esi                          )   \\\n    AS2(    add   edi, DWORD PTR [ebp + 8 * N]      )   \\\n    AS2(    xor   C,   edi                          )   \\\n\t/* (c) = rotrFixed(c, 1) */                         \\\n    AS2(    ror   C,   1                            )\n\n\n    // decrypt Round (n), \n    // x = esi, k = ebp, edi open\n    // y is in ecx from G2, restore ecx from mm7 when done\n#define ASMDECROUND(N, A, A2, A3, B, B2, B3, C, D)      \\\n    /* setup s_  */                                     \\\n    AS2(    movd  ebp, mm1                          )   \\\n    ASMG1(A, A2, A3)                                    \\\n    ASMG2(B, B2, B3)                                    \\\n    /* setup k  */                                      \\\n    AS2(    movd  ebp, mm0                          )   \\\n    /* x += y   */                                      \\\n    AS2(    add   esi, ecx                          )   \\\n    AS2(    add   ebp, 32                           )   \\\n    /* y += x     */                                    \\\n    AS2(    add   ecx, esi                          )   \\\n\t/* (d) ^= y + k[2 * (n) + 1] */                     \\\n    AS2(    mov   edi, DWORD PTR [ebp + 8 * N + 4]  )   \\\n    AS2(    add   edi, ecx                          )   \\\n    AS2(    movd  ecx, mm7                          )   \\\n    AS2(    xor   D,   edi                          )   \\\n\t/* (d) = rotrFixed(d, 1)     */                     \\\n    AS2(    ror   D,   1                            )   \\\n\t/* (c) = rotlFixed(c, 1)     */                     \\\n    AS2(    rol   C,   1                            )   \\\n\t/* (c) ^= (x + k[2 * (n)])   */                     \\\n    AS2(    mov   edi, esi                          )   \\\n    AS2(    add   edi, DWORD PTR [ebp + 8 * N]      )   \\\n    AS2(    xor   C,   edi                          )\n\n\n#ifdef _MSC_VER\n    __declspec(naked) \n#else\n    __attribute__ ((noinline))\n#endif\nvoid Twofish::AsmEncrypt(const byte* inBlock, byte* outBlock) const\n{\n    PROLOG()\n\n    #ifdef OLD_GCC_OFFSET\n        AS2(    add   edi, 60                       ) // k_\n    #else\n        AS2(    add   edi, 56                       ) // k_\n    #endif\n\n    AS2(    mov   ebp, edi                      )\n\n    AS2(    mov   eax, DWORD PTR [esi]          ) // a\n    AS2(    movd  mm0, edi                      ) // store k_\n    AS2(    mov   ebx, DWORD PTR [esi +  4]     ) // b\n    AS2(    add   ebp, 160                      ) // s_[0]\n    AS2(    mov   ecx, DWORD PTR [esi +  8]     ) // c\n    AS2(    movd  mm1, ebp                      ) // store s_\n    AS2(    mov   edx, DWORD PTR [esi + 12]     ) // d\n    \n    AS2(    xor   eax, DWORD PTR [edi]          ) // k_[0]\n    AS2(    xor   ebx, DWORD PTR [edi +  4]     ) //   [1]\n    AS2(    xor   ecx, DWORD PTR [edi +  8]     ) //   [2]\n    AS2(    xor   edx, DWORD PTR [edi + 12]     ) //   [3]\n\n\n    ASMENCROUND( 0, eax, al, ah, ebx, bl, bh, ecx, edx)\n    ASMENCROUND( 1, ecx, cl, ch, edx, dl, dh, eax, ebx)\n    ASMENCROUND( 2, eax, al, ah, ebx, bl, bh, ecx, edx)\n    ASMENCROUND( 3, ecx, cl, ch, edx, dl, dh, eax, ebx)\n    ASMENCROUND( 4, eax, al, ah, ebx, bl, bh, ecx, edx)\n    ASMENCROUND( 5, ecx, cl, ch, edx, dl, dh, eax, ebx)\n    ASMENCROUND( 6, eax, al, ah, ebx, bl, bh, ecx, edx)\n    ASMENCROUND( 7, ecx, cl, ch, edx, dl, dh, eax, ebx)\n    ASMENCROUND( 8, eax, al, ah, ebx, bl, bh, ecx, edx)\n    ASMENCROUND( 9, ecx, cl, ch, edx, dl, dh, eax, ebx)\n    ASMENCROUND(10, eax, al, ah, ebx, bl, bh, ecx, edx)\n    ASMENCROUND(11, ecx, cl, ch, edx, dl, dh, eax, ebx)\n    ASMENCROUND(12, eax, al, ah, ebx, bl, bh, ecx, edx)\n    ASMENCROUND(13, ecx, cl, ch, edx, dl, dh, eax, ebx)\n    ASMENCROUND(14, eax, al, ah, ebx, bl, bh, ecx, edx)\n    ASMENCROUND(15, ecx, cl, ch, edx, dl, dh, eax, ebx)\n\n\n    AS2(    movd  ebp, mm6                      )\n    AS2(    movd  esi, mm0                      ) // k_\n    #ifdef __GNUC__\n        AS2(    movd  edi, mm3                  ) // outBlock\n    #else\n        AS2(    mov   edi, [ebp + 12]           ) // outBlock\n    #endif\n\n    AS2(    xor   ecx, DWORD PTR [esi + 16]     ) // k_[4]\n    AS2(    xor   edx, DWORD PTR [esi + 20]     ) // k_[5]\n    AS2(    xor   eax, DWORD PTR [esi + 24]     ) // k_[6]\n    AS2(    xor   ebx, DWORD PTR [esi + 28]     ) // k_[7]\n\n    AS2(    mov   [edi],      ecx               ) // write out\n    AS2(    mov   [edi +  4], edx               ) // write out\n    AS2(    mov   [edi +  8], eax               ) // write out\n    AS2(    mov   [edi + 12], ebx               ) // write out\n\n\n    EPILOG()\n}\n\n\n#ifdef _MSC_VER\n    __declspec(naked) \n#else\n    __attribute__ ((noinline))\n#endif\nvoid Twofish::AsmDecrypt(const byte* inBlock, byte* outBlock) const\n{\n    PROLOG()\n\n    #ifdef OLD_GCC_OFFSET\n        AS2(    add   edi, 60                       ) // k_\n    #else\n        AS2(    add   edi, 56                       ) // k_\n    #endif\n\n    AS2(    mov   ebp, edi                      )\n\n    AS2(    mov   ecx, DWORD PTR [esi]          ) // c\n    AS2(    movd  mm0, edi                      ) // store k_\n    AS2(    mov   edx, DWORD PTR [esi +  4]     ) // d\n    AS2(    add   ebp, 160                      ) // s_[0]\n    AS2(    mov   eax, DWORD PTR [esi +  8]     ) // a\n    AS2(    movd  mm1, ebp                      ) // store s_\n    AS2(    mov   ebx, DWORD PTR [esi + 12]     ) // b\n\n    AS2(    xor   ecx, DWORD PTR [edi + 16]     ) // k_[4]\n    AS2(    xor   edx, DWORD PTR [edi + 20]     ) //   [5]\n    AS2(    xor   eax, DWORD PTR [edi + 24]     ) //   [6]\n    AS2(    xor   ebx, DWORD PTR [edi + 28]     ) //   [7]\n\n\n    ASMDECROUND(15, ecx, cl, ch, edx, dl, dh, eax, ebx)\n    ASMDECROUND(14, eax, al, ah, ebx, bl, bh, ecx, edx)\n    ASMDECROUND(13, ecx, cl, ch, edx, dl, dh, eax, ebx)\n    ASMDECROUND(12, eax, al, ah, ebx, bl, bh, ecx, edx)\n    ASMDECROUND(11, ecx, cl, ch, edx, dl, dh, eax, ebx)\n    ASMDECROUND(10, eax, al, ah, ebx, bl, bh, ecx, edx)\n    ASMDECROUND( 9, ecx, cl, ch, edx, dl, dh, eax, ebx)\n    ASMDECROUND( 8, eax, al, ah, ebx, bl, bh, ecx, edx)\n    ASMDECROUND( 7, ecx, cl, ch, edx, dl, dh, eax, ebx)\n    ASMDECROUND( 6, eax, al, ah, ebx, bl, bh, ecx, edx)\n    ASMDECROUND( 5, ecx, cl, ch, edx, dl, dh, eax, ebx)\n    ASMDECROUND( 4, eax, al, ah, ebx, bl, bh, ecx, edx)\n    ASMDECROUND( 3, ecx, cl, ch, edx, dl, dh, eax, ebx)\n    ASMDECROUND( 2, eax, al, ah, ebx, bl, bh, ecx, edx)\n    ASMDECROUND( 1, ecx, cl, ch, edx, dl, dh, eax, ebx)\n    ASMDECROUND( 0, eax, al, ah, ebx, bl, bh, ecx, edx)\n\n\n    AS2(    movd  ebp, mm6                      )\n    AS2(    movd  esi, mm0                      ) // k_\n    #ifdef __GNUC__\n        AS2(    movd  edi, mm3                  ) // outBlock\n    #else\n        AS2(    mov   edi, [ebp + 12]           ) // outBlock\n    #endif\n\n    AS2(    xor   eax, DWORD PTR [esi     ]     ) // k_[0]\n    AS2(    xor   ebx, DWORD PTR [esi +  4]     ) // k_[1]\n    AS2(    xor   ecx, DWORD PTR [esi +  8]     ) // k_[2]\n    AS2(    xor   edx, DWORD PTR [esi + 12]     ) // k_[3]\n\n    AS2(    mov   [edi],      eax               ) // write out\n    AS2(    mov   [edi +  4], ebx               ) // write out\n    AS2(    mov   [edi +  8], ecx               ) // write out\n    AS2(    mov   [edi + 12], edx               ) // write out\n\n\n    EPILOG()\n}\n\n\n\n#endif // defined(DO_TWOFISH_ASM)\n\n\n\n\n\n} // namespace\n\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/taocrypt.dsp",
    "content": "# Microsoft Developer Studio Project File - Name=\"taocrypt\" - Package Owner=<4>\n# Microsoft Developer Studio Generated Build File, Format Version 6.00\n# ** DO NOT EDIT **\n\n# TARGTYPE \"Win32 (x86) Static Library\" 0x0104\n\nCFG=taocrypt - Win32 Debug\n!MESSAGE This is not a valid makefile. To build this project using NMAKE,\n!MESSAGE use the Export Makefile command and run\n!MESSAGE \n!MESSAGE NMAKE /f \"taocrypt.mak\".\n!MESSAGE \n!MESSAGE You can specify a configuration when running NMAKE\n!MESSAGE by defining the macro CFG on the command line. For example:\n!MESSAGE \n!MESSAGE NMAKE /f \"taocrypt.mak\" CFG=\"taocrypt - Win32 Debug\"\n!MESSAGE \n!MESSAGE Possible choices for configuration are:\n!MESSAGE \n!MESSAGE \"taocrypt - Win32 Release\" (based on \"Win32 (x86) Static Library\")\n!MESSAGE \"taocrypt - Win32 Debug\" (based on \"Win32 (x86) Static Library\")\n!MESSAGE \n\n# Begin Project\n# PROP AllowPerConfigDependencies 0\n# PROP Scc_ProjName \"\"\n# PROP Scc_LocalPath \"\"\nCPP=cl.exe\nRSC=rc.exe\n\n!IF  \"$(CFG)\" == \"taocrypt - Win32 Release\"\n\n# PROP BASE Use_MFC 0\n# PROP BASE Use_Debug_Libraries 0\n# PROP BASE Output_Dir \"taocrypt___Win32_Release\"\n# PROP BASE Intermediate_Dir \"taocrypt___Win32_Release\"\n# PROP BASE Target_Dir \"\"\n# PROP Use_MFC 0\n# PROP Use_Debug_Libraries 0\n# PROP Output_Dir \"Release\"\n# PROP Intermediate_Dir \"Release\"\n# PROP Target_Dir \"\"\n# ADD BASE CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_MBCS\" /D \"_LIB\" /YX /FD /c\n# ADD CPP /nologo /G6 /MT /W3 /O2 /I \"include\" /I \"mySTL\" /D \"WIN32\" /D \"NDEBUG\" /D \"_MBCS\" /D \"_LIB\" /YX /FD /c\n# ADD BASE RSC /l 0x409 /d \"NDEBUG\"\n# ADD RSC /l 0x409 /d \"NDEBUG\"\nBSC32=bscmake.exe\n# ADD BASE BSC32 /nologo\n# ADD BSC32 /nologo\nLIB32=link.exe -lib\n# ADD BASE LIB32 /nologo\n# ADD LIB32 /nologo\n\n!ELSEIF  \"$(CFG)\" == \"taocrypt - Win32 Debug\"\n\n# PROP BASE Use_MFC 0\n# PROP BASE Use_Debug_Libraries 1\n# PROP BASE Output_Dir \"taocrypt___Win32_Debug\"\n# PROP BASE Intermediate_Dir \"taocrypt___Win32_Debug\"\n# PROP BASE Target_Dir \"\"\n# PROP Use_MFC 0\n# PROP Use_Debug_Libraries 1\n# PROP Output_Dir \"Debug\"\n# PROP Intermediate_Dir \"Debug\"\n# PROP Target_Dir \"\"\n# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_MBCS\" /D \"_LIB\" /YX /FD /GZ /c\n# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I \"include\" /I \"mySTL\" /D \"WIN32\" /D \"_DEBUG\" /D \"_MBCS\" /D \"_LIB\" /YX /FD /GZ /c\n# SUBTRACT CPP /Fr\n# ADD BASE RSC /l 0x409 /d \"_DEBUG\"\n# ADD RSC /l 0x409 /d \"_DEBUG\"\nBSC32=bscmake.exe\n# ADD BASE BSC32 /nologo\n# ADD BSC32 /nologo\nLIB32=link.exe -lib\n# ADD BASE LIB32 /nologo\n# ADD LIB32 /nologo\n\n!ENDIF \n\n# Begin Target\n\n# Name \"taocrypt - Win32 Release\"\n# Name \"taocrypt - Win32 Debug\"\n# Begin Group \"Source Files\"\n\n# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\n# Begin Source File\n\nSOURCE=.\\src\\aes.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\aestables.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\algebra.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\arc4.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\asn.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\bftables.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\blowfish.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\coding.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\des.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\dh.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\dsa.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\file.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\hash.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\hc128.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\integer.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\md2.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\md4.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\md5.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\misc.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\rabbit.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\random.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\ripemd.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\rsa.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\sha.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\tftables.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\twofish.cpp\n# End Source File\n# End Group\n# Begin Group \"Header Files\"\n\n# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\n# Begin Source File\n\nSOURCE=.\\include\\aes.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\algebra.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\arc4.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\asn.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\block.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\blowfish.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\coding.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\des.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\dh.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\dsa.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\error.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\file.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\hash.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\hc128.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\hmac.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\integer.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\md2.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\md4.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\md5.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\misc.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\modarith.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\modes.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\pwdbased.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\rabbit.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\random.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\ripemd.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\rsa.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\sha.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\twofish.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\type_traits.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\types.hpp\n# End Source File\n# End Group\n# End Target\n# End Project\n"
  },
  {
    "path": "ext/yassl/taocrypt/taocrypt.dsw",
    "content": "Microsoft Developer Studio Workspace File, Format Version 6.00\n# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\n\n###############################################################################\n\nProject: \"benchmark\"=.\\benchmark\\benchmark.dsp - Package Owner=<4>\n\nPackage=<5>\n{{{\n}}}\n\nPackage=<4>\n{{{\n    Begin Project Dependency\n    Project_Dep_Name taocrypt\n    End Project Dependency\n}}}\n\n###############################################################################\n\nProject: \"taocrypt\"=.\\taocrypt.dsp - Package Owner=<4>\n\nPackage=<5>\n{{{\n}}}\n\nPackage=<4>\n{{{\n}}}\n\n###############################################################################\n\nProject: \"test\"=.\\test\\test.dsp - Package Owner=<4>\n\nPackage=<5>\n{{{\n}}}\n\nPackage=<4>\n{{{\n    Begin Project Dependency\n    Project_Dep_Name taocrypt\n    End Project Dependency\n}}}\n\n###############################################################################\n\nGlobal:\n\nPackage=<5>\n{{{\n}}}\n\nPackage=<3>\n{{{\n}}}\n\n###############################################################################\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/test/make.bat",
    "content": "REM Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.\nREM \nREM This program is free software; you can redistribute it and/or modify\nREM it under the terms of the GNU General Public License as published by\nREM the Free Software Foundation; version 2 of the License.\nREM \nREM This program is distributed in the hope that it will be useful,\nREM but WITHOUT ANY WARRANTY; without even the implied warranty of\nREM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nREM GNU General Public License for more details.\nREM \nREM You should have received a copy of the GNU General Public License\nREM along with this program; if not, write to the Free Software\nREM Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\n\nREM quick and dirty build file for testing different MSDEVs\nsetlocal \n\nset myFLAGS= /I../include /I../mySTL /c /W3 /G6 /O2\n\ncl %myFLAGS% test.cpp\n\nlink.exe  /out:test.exe ../src/taocrypt.lib test.obj advapi32.lib\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/test/memory.cpp",
    "content": "/*\n   Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n// memory.cpp\n#include \"../../include/lock.hpp\"     // locking\n#include <new>          // std::bad_alloc\n#include <cstdlib>      // malloc\n#include <cstring>      // memset\n#include <fstream>      // ofstream\n#include <sstream>      // stringstream\n#include <cassert>      // assert\n#include <iomanip>      // setiosflags\n\n/*********************************************************************\n\nTo use MemoryTracker merely add this file to your project\nNo need to instantiate anything\n\nIf your app is multi threaded define MULTI_THREADED\n\n*********************************************************************/\n\n\n// locals\nnamespace {\n\nclass MemoryTracker {\n    std::ofstream log_;\npublic:\n    MemoryTracker();\n    ~MemoryTracker();\nprivate:\n    MemoryTracker(const MemoryTracker&);             // hide copy\n    MemoryTracker& operator=(const MemoryTracker&);  // and assign\n\n    void LogStats();\n};\n\n\nstruct alloc_node {\n    alloc_node* left_;\n    alloc_node* right_;\n  \n    alloc_node() : left_(0), right_(0) {}\n};\n\n\nalloc_node* Root = 0;\n\nsize_t Allocs    = 0;\nsize_t DeAllocs  = 0;\nsize_t Bytes     = 0;\n\n\nstruct size_tracker {\n    size_t size_;\n    size_t count_;\n};\n\nsize_tracker sizes[] = \n{\n    {0,0},\n    {2,0},\n    {4,0},\n    {8,0},\n    {16,0},\n    {32,0},\n    {64,0},\n    {128,0},\n    {256,0},\n    {512,0},\n    {1024,0},\n    {2048,0},\n    {4096,0},\n    {8192,0},\n};\n\nconst size_t size_elements(sizeof(sizes) / sizeof(size_tracker));\n\nbool Tracking(false);\n\nusing   yaSSL::Mutex;\ntypedef Mutex::Lock Lock;\n\nMutex mutex;\n\nMemoryTracker theTracker;\n\n\nbool lookup(alloc_node*& find, void* key, alloc_node*& prev)\n{\n    bool found(false);\n\n    while (find) {\n        if (find == key) {\n            found = true;\n            break;\n        }\n        prev = find;\n        if (key < find)\n            find = find->left_;\n        else\n            find = find->right_;\n    }\n    return found;\n}\n\n\n// iterative insert\nvoid insert(alloc_node* entry)\n{\n    if (!Root) {\n        Root = entry;\n        return;\n    }\n       \n    alloc_node* tmp  = Root;\n    alloc_node* prev = 0;\n\n    if (lookup(tmp, entry, prev)) \n        assert(0); // duplicate\n\n    if (entry < prev)\n        prev->left_  = entry;\n    else\n        prev->right_ = entry;\n}\n\n\nalloc_node* predecessorSwap(alloc_node* del)\n{\n    alloc_node* pred = del->left_;\n    alloc_node* predPrev = del;\n\n    while (pred->right_) {\n        predPrev = pred;\n        pred = pred->right_;\n    }\n    if (predPrev == del)\n        predPrev->left_  = pred->left_;\n    else\n        predPrev->right_ = pred->left_;\n\n    pred->left_  = del->left_;\n    pred->right_ = del->right_;\n\n    return pred;\n}\n\n\n// iterative remove\nvoid remove(void* ptr)\n{\n    alloc_node* del  = Root;\n    alloc_node* prev = 0;\n    alloc_node* replace = 0;\n\n    if ( lookup(del, ptr, prev) == false)\n        assert(0); // oops, not there\n\n    if (del->left_ && del->right_)          // two children\n        replace = predecessorSwap(del);\n    else if (!del->left_ && !del->right_)   // no children\n        replace = 0;\n    else                                    // one child\n        replace = (del->left_) ? del->left_ : del->right_;\n\n    if (del == Root)\n        Root = replace;\n    else if (prev->left_ == del)\n        prev->left_  = replace;\n    else\n        prev->right_ = replace;\n}\n\n\ntypedef void (*fp)(alloc_node*, void*);\n\nvoid applyInOrder(alloc_node* root, fp f, void* arg)\n{\n    if (root == 0)\n        return;\n    \n    applyInOrder(root->left_,  f, arg);\n    f(root, arg);\n    applyInOrder(root->right_, f, arg);\n}\n\n\nvoid show(alloc_node* ptr, void* arg)\n{\n    std::ofstream* log = static_cast<std::ofstream*>(arg);\n    *log << ptr << '\\n';\n}\n\n\nMemoryTracker::MemoryTracker() : log_(\"memory.log\")\n{\n#ifdef __GNUC__\n    // Force pool allocator to cleanup at exit\n    setenv(\"GLIBCPP_FORCE_NEW\", \"1\", 0);\n#endif\n\n#ifdef _MSC_VER\n    // msvc6 needs to create Facility for ostream before main starts, otherwise\n    // if another ostream is created and destroyed in main scope, log stats\n    // will access a dead Facility reference (std::numput)\n    int msvcFac = 6;\n    log_ << \"MSVC \" << msvcFac << \"workaround\" << std::endl; \n#endif\n\n\n    Tracking = true;\n}\n\n\nMemoryTracker::~MemoryTracker()\n{\n    // stop tracking before log (which will alloc on output)\n    Tracking = false;\n    LogStats();\n\n    //assert(Allocs == DeAllocs);\n    //assert(Root == 0);\n}\n\n\nvoid MemoryTracker::LogStats()\n{\n    log_ << \"Number of Allocs:     \" << Allocs    << '\\n';\n    log_ << \"Number of DeAllocs:   \" << DeAllocs  << '\\n';\n    log_ << \"Number of bytes used: \" << Bytes     << '\\n';\n\n    log_ << \"Alloc size table:\\n\";\n    log_ << \" Bytes \" << '\\t' << \"   Times\\n\";\n\n    for (size_t i = 0; i < size_elements; ++i) {\n        log_ << \" \" << sizes[i].size_  << \"  \" << '\\t';\n        log_ << std::setiosflags(std::ios::right) << std::setw(8);\n        log_ << sizes[i].count_ << '\\n';\n    }\n\n    if (Allocs != DeAllocs) {\n        log_<< \"Showing new'd allocs with no deletes\" << '\\n';\n        applyInOrder(Root, show, &log_);\n    }\n    log_.flush();\n}\n\n\n// return power of 2 up to size_tracker elements\nsize_t powerOf2(size_t sz)\n{\n    size_t shifts = 0;\n\n    if (sz)\n        sz -= 1;\n    else\n        return 0;\n\t   \n    while (sz) {\n        sz >>= 1;\n        ++shifts;\n    }\n\n    return shifts < size_elements ? shifts : size_elements;\n}\n\n\n} // namespace local\n\n\nvoid* operator new(size_t sz)\n{\n    // put alloc node in front of requested memory\n    void* ptr = malloc(sz + sizeof(alloc_node));\n    if (ptr) {\n        if (Tracking) {\n            Lock l(mutex);\n            ++Allocs;\n            Bytes += sz;\n            ++sizes[powerOf2(sz)].count_;\n            insert(new (ptr) alloc_node);\n        }\n        return static_cast<char*>(ptr) + sizeof(alloc_node);\n    }\n    else\n        assert(0);\n}\n\n\nvoid operator delete(void* ptr)\n{\n    if (ptr) {\n        ptr = static_cast<char*>(ptr) - sizeof(alloc_node);  // correct offset\n        if (Tracking) {\n            Lock l(mutex);\n            ++DeAllocs;\n            remove(ptr);\n        }\n        free(ptr);\n    }\n}\n\n\nvoid* operator new[](size_t sz)\n{\n    return ::operator new(sz);\n}\n\n\nvoid operator delete[](void* ptr)\n{\n    ::operator delete(ptr);\n}\n\n\nextern \"C\" {\n\nvoid* XMALLOC(size_t sz, void* head)\n{\n    return ::operator new(sz);\n}\n\nvoid* XREALLOC(void* ptr, size_t sz, void* heap)\n{\n    void* ret = ::operator new(sz);\n\n    if (ret && ptr)\n        memcpy(ret, ptr, sz);\n\n    if (ret)\n        ::operator delete(ptr);\n    return ret;\n}\n\n\nvoid XFREE(void* ptr, void* heap)\n{\n    ::operator delete(ptr);\n}\n\n}  // extern \"C\"\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/test/test.cpp",
    "content": "/*\n   Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n// test.cpp\n// test taocrypt functionality\n\n#include <string.h>\n#include <stdio.h>\n\n#include \"runtime.hpp\"\n#include \"sha.hpp\"\n#include \"md5.hpp\"\n#include \"md2.hpp\"\n#include \"md4.hpp\"\n#include \"ripemd.hpp\"\n#include \"hmac.hpp\"\n#include \"arc4.hpp\"\n#include \"des.hpp\"\n#include \"rsa.hpp\"\n#include \"dsa.hpp\"\n#include \"aes.hpp\"\n#include \"twofish.hpp\"\n#include \"blowfish.hpp\"\n#include \"asn.hpp\"\n#include \"dh.hpp\"\n#include \"coding.hpp\"\n#include \"random.hpp\"\n#include \"pwdbased.hpp\"\n#include \"rabbit.hpp\"\n#include \"hc128.hpp\"\n\n\n\nusing TaoCrypt::byte;\nusing TaoCrypt::word32;\nusing TaoCrypt::SHA;\nusing TaoCrypt::SHA256;\nusing TaoCrypt::SHA224;\n#ifdef WORD64_AVAILABLE\n    using TaoCrypt::SHA512;\n    using TaoCrypt::SHA384;\n#endif\nusing TaoCrypt::MD5;\nusing TaoCrypt::MD2;\nusing TaoCrypt::MD4;\nusing TaoCrypt::RIPEMD160;\nusing TaoCrypt::HMAC;\nusing TaoCrypt::ARC4;\nusing TaoCrypt::DES_EDE3_CBC_Encryption;\nusing TaoCrypt::DES_EDE3_CBC_Decryption;\nusing TaoCrypt::DES_CBC_Encryption;\nusing TaoCrypt::DES_CBC_Decryption;\nusing TaoCrypt::DES_ECB_Encryption;\nusing TaoCrypt::DES_ECB_Decryption;\nusing TaoCrypt::AES_CBC_Encryption;\nusing TaoCrypt::AES_CBC_Decryption;\nusing TaoCrypt::AES_ECB_Encryption;\nusing TaoCrypt::AES_ECB_Decryption;\nusing TaoCrypt::Twofish_CBC_Encryption;\nusing TaoCrypt::Twofish_CBC_Decryption;\nusing TaoCrypt::Twofish_ECB_Encryption;\nusing TaoCrypt::Twofish_ECB_Decryption;\nusing TaoCrypt::Blowfish_CBC_Encryption;\nusing TaoCrypt::Blowfish_CBC_Decryption;\nusing TaoCrypt::Blowfish_ECB_Encryption;\nusing TaoCrypt::Blowfish_ECB_Decryption;\nusing TaoCrypt::RSA_PrivateKey;\nusing TaoCrypt::RSA_PublicKey;\nusing TaoCrypt::DSA_PrivateKey;\nusing TaoCrypt::DSA_PublicKey;\nusing TaoCrypt::DSA_Signer;\nusing TaoCrypt::DSA_Verifier;\nusing TaoCrypt::RSAES_Encryptor;\nusing TaoCrypt::RSAES_Decryptor;\nusing TaoCrypt::Source;\nusing TaoCrypt::FileSource;\nusing TaoCrypt::FileSource;\nusing TaoCrypt::HexDecoder;\nusing TaoCrypt::HexEncoder;\nusing TaoCrypt::Base64Decoder;\nusing TaoCrypt::Base64Encoder;\nusing TaoCrypt::CertDecoder;\nusing TaoCrypt::DH;\nusing TaoCrypt::EncodeDSA_Signature;\nusing TaoCrypt::DecodeDSA_Signature;\nusing TaoCrypt::PBKDF2_HMAC;\nusing TaoCrypt::tcArrayDelete;\nusing TaoCrypt::GetCert;\nusing TaoCrypt::GetPKCS_Cert;\nusing TaoCrypt::Rabbit;\nusing TaoCrypt::HC128;\n\nstruct testVector {\n    byte*  input_;\n    byte*  output_; \n    word32 inLen_;\n    word32 outLen_;\n\n    testVector(const char* in, const char* out) : input_((byte*)in),\n               output_((byte*)out), inLen_((word32)strlen(in)),\n               outLen_((word32)strlen(out)) {}\n};\n\nint  sha_test();\nint  sha256_test();\n#ifdef WORD64_AVAILABLE\n    int  sha512_test();\n    int  sha384_test();\n#endif\nint  sha224_test();\nint  md5_test();\nint  md2_test();\nint  md4_test();\nint  ripemd_test();\nint  hmac_test();\nint  arc4_test();\nint  des_test();\nint  aes_test();\nint  twofish_test();\nint  blowfish_test();\nint  rsa_test();\nint  dsa_test();\nint  dh_test();\nint  pwdbased_test();\nint  pkcs12_test();\nint  rabbit_test();\nint  hc128_test();\n\nTaoCrypt::RandomNumberGenerator rng;\n\n\nvoid err_sys(const char* msg, int es)\n{\n    printf(\"%s\\n\", msg);\n    exit(es);    \n}\n\n// func_args from test.hpp, so don't have to pull in other junk\nstruct func_args {\n    int    argc;\n    char** argv;\n    int    return_code;\n};\n\n\n/* \n   DES, AES, Blowfish, and Twofish need aligned (4 byte) input/output for\n   processing, can turn this off by setting gpBlock(assumeAligned = false)\n   but would hurt performance.  yaSSL always uses dynamic memory so we have\n   at least 8 byte alignment.  This test tried to force alignment for stack\n   variables (for convenience) but some compiler versions and optimizations\n   seemed to be off.  So we have msgTmp variable which we copy into dynamic\n   memory at runtime to ensure proper alignment, along with plain/cipher.\n   Whew!\n*/\nconst byte msgTmp[] = { // \"now is the time for all \" w/o trailing 0\n    0x6e,0x6f,0x77,0x20,0x69,0x73,0x20,0x74,\n    0x68,0x65,0x20,0x74,0x69,0x6d,0x65,0x20,\n    0x66,0x6f,0x72,0x20,0x61,0x6c,0x6c,0x20\n};\n\nbyte* msg    = 0;   // for block cipher input\nbyte* plain  = 0;   // for cipher decrypt comparison \nbyte* cipher = 0;   // block output\n\n\nvoid taocrypt_test(void* args)\n{\n    ((func_args*)args)->return_code = -1; // error state\n\n    msg    = NEW_TC byte[24];\n    plain  = NEW_TC byte[24];\n    cipher = NEW_TC byte[24];\n\n    memcpy(msg, msgTmp, 24);\n\n    int ret = 0;\n    if ( (ret = sha_test()) ) \n        err_sys(\"SHA      test failed!\\n\", ret);\n    else\n        printf( \"SHA      test passed!\\n\");\n\n    if ( (ret = sha256_test()) ) \n        err_sys(\"SHA-256  test failed!\\n\", ret);\n    else\n        printf( \"SHA-256  test passed!\\n\");\n\n    if ( (ret = sha224_test()) ) \n        err_sys(\"SHA-224  test failed!\\n\", ret);\n    else\n        printf( \"SHA-224  test passed!\\n\");\n\n#ifdef WORD64_AVAILABLE\n\n    if ( (ret = sha512_test()) ) \n        err_sys(\"SHA-512  test failed!\\n\", ret);\n    else\n        printf( \"SHA-512  test passed!\\n\");\n\n    if ( (ret = sha384_test()) ) \n        err_sys(\"SHA-384  test failed!\\n\", ret);\n    else\n        printf( \"SHA-384  test passed!\\n\");\n\n#endif\n\n    if ( (ret = md5_test()) ) \n        err_sys(\"MD5      test failed!\\n\", ret);\n    else\n        printf( \"MD5      test passed!\\n\");\n\n    if ( (ret = md2_test()) ) \n        err_sys(\"MD2      test failed!\\n\", ret);\n    else\n        printf( \"MD2      test passed!\\n\");\n\n    if ( (ret = md4_test()) ) \n        err_sys(\"MD4      test failed!\\n\", ret);\n    else\n        printf( \"MD4      test passed!\\n\");\n\n    if ( (ret = ripemd_test()) )\n        err_sys(\"RIPEMD   test failed!\\n\", ret);\n    else\n        printf( \"RIPEMD   test passed!\\n\");\n\n    if ( ( ret = hmac_test()) )\n        err_sys(\"HMAC     test failed!\\n\", ret);\n    else\n        printf( \"HMAC     test passed!\\n\");\n\n    if ( (ret = arc4_test()) )\n        err_sys(\"ARC4     test failed!\\n\", ret);\n    else\n        printf( \"ARC4     test passed!\\n\");\n\n    if ( (ret = rabbit_test()) )\n        err_sys(\"Rabbit   test failed!\\n\", ret);\n    else\n        printf( \"Rabbit   test passed!\\n\");\n\n    if ( (ret = hc128_test()) )\n        err_sys(\"HC128    test failed!\\n\", ret);\n    else\n        printf( \"HC128    test passed!\\n\");\n\n    if ( (ret = des_test()) )\n        err_sys(\"DES      test failed!\\n\", ret);\n    else\n        printf( \"DES      test passed!\\n\");\n\n    if ( (ret = aes_test()) )\n        err_sys(\"AES      test failed!\\n\", ret);\n    else\n        printf( \"AES      test passed!\\n\");\n\n    if ( (ret = twofish_test()) )\n        err_sys(\"Twofish  test failed!\\n\", ret);\n    else\n        printf( \"Twofish  test passed!\\n\");\n\n    if ( (ret = blowfish_test()) )\n        err_sys(\"Blowfish test failed!\\n\", ret);\n    else\n        printf( \"Blowfish test passed!\\n\");\n\n    if ( (ret = rsa_test()) )\n        err_sys(\"RSA      test failed!\\n\", ret);\n    else\n        printf( \"RSA      test passed!\\n\");\n\n    if ( (ret = dh_test()) )\n        err_sys(\"DH       test failed!\\n\", ret);\n    else\n        printf( \"DH       test passed!\\n\");\n\n    if ( (ret = dsa_test()) )\n        err_sys(\"DSA      test failed!\\n\", ret);\n    else\n        printf( \"DSA      test passed!\\n\");\n\n    if ( (ret = pwdbased_test()) )\n        err_sys(\"PBKDF2   test failed!\\n\", ret);\n    else\n        printf( \"PBKDF2   test passed!\\n\");\n\n    /* not ready yet\n    if ( (ret = pkcs12_test()) )\n        err_sys(\"PKCS12   test failed!\\n\", ret);\n    else\n        printf( \"PKCS12   test passed!\\n\");\n    */\n\n    tcArrayDelete(cipher);\n    tcArrayDelete(plain);\n    tcArrayDelete(msg);\n\n    ((func_args*)args)->return_code = ret;\n}\n\n\n// so overall tests can pull in test function \n#ifndef NO_MAIN_DRIVER\n\n    int main(int argc, char** argv)\n    {\n        func_args args;\n\n        args.argc = argc;\n        args.argv = argv;\n\n        taocrypt_test(&args);\n        TaoCrypt::CleanUp();\n\n        return args.return_code;\n    }\n\n#endif // NO_MAIN_DRIVER\n\n\nvoid file_test(const char* file, byte* check)\n{\n    FILE* f;\n    int i = 0;\n    MD5    md5;\n    byte   buf[1024];\n    byte   md5sum[MD5::DIGEST_SIZE];\n    \n    if( !( f = fopen( file, \"rb\" ) )) {\n        printf(\"Can't open %s\\n\", file);\n        return;\n    }\n    while( ( i = (int)fread(buf, 1, sizeof(buf), f )) > 0 )\n        md5.Update(buf, i);\n    \n    md5.Final(md5sum);\n    memcpy(check, md5sum, sizeof(md5sum));\n\n    for(int j = 0; j < MD5::DIGEST_SIZE; ++j ) \n        printf( \"%02x\", md5sum[j] );\n   \n    printf(\"  %s\\n\", file);\n\n    fclose(f);\n}\n\n\nint sha_test()\n{\n    SHA  sha;\n    byte hash[SHA::DIGEST_SIZE];\n\n    testVector test_sha[] =\n    {\n        testVector(\"abc\", \n                 \"\\xA9\\x99\\x3E\\x36\\x47\\x06\\x81\\x6A\\xBA\\x3E\\x25\\x71\\x78\\x50\\xC2\"\n                 \"\\x6C\\x9C\\xD0\\xD8\\x9D\"),\n        testVector(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\",\n                 \"\\x84\\x98\\x3E\\x44\\x1C\\x3B\\xD2\\x6E\\xBA\\xAE\\x4A\\xA1\\xF9\\x51\\x29\"\n                 \"\\xE5\\xE5\\x46\\x70\\xF1\"),\n        testVector(\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n                 \"aaaaaa\", \n                 \"\\x00\\x98\\xBA\\x82\\x4B\\x5C\\x16\\x42\\x7B\\xD7\\xA1\\x12\\x2A\\x5A\\x44\"\n                 \"\\x2A\\x25\\xEC\\x64\\x4D\"),\n        testVector(\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n                 \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n                 \"aaaaaaaaaa\",\n                 \"\\xAD\\x5B\\x3F\\xDB\\xCB\\x52\\x67\\x78\\xC2\\x83\\x9D\\x2F\\x15\\x1E\\xA7\"\n                 \"\\x53\\x99\\x5E\\x26\\xA0\")  \n    };\n\n    int times( sizeof(test_sha) / sizeof(testVector) );\n    for (int i = 0; i < times; ++i) {\n        sha.Update(test_sha[i].input_, test_sha[i].inLen_);\n        sha.Final(hash);\n\n        if (memcmp(hash, test_sha[i].output_, SHA::DIGEST_SIZE) != 0)\n            return -1 - i;\n    }\n\n    return 0;\n}\n\n\nint sha256_test()\n{\n    SHA256 sha;\n    byte   hash[SHA256::DIGEST_SIZE];\n\n    testVector test_sha[] =\n    {\n        testVector(\"abc\",\n                 \"\\xBA\\x78\\x16\\xBF\\x8F\\x01\\xCF\\xEA\\x41\\x41\\x40\\xDE\\x5D\\xAE\\x22\"\n                 \"\\x23\\xB0\\x03\\x61\\xA3\\x96\\x17\\x7A\\x9C\\xB4\\x10\\xFF\\x61\\xF2\\x00\"\n                 \"\\x15\\xAD\"),\n        testVector(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\",\n                 \"\\x24\\x8D\\x6A\\x61\\xD2\\x06\\x38\\xB8\\xE5\\xC0\\x26\\x93\\x0C\\x3E\\x60\"\n                 \"\\x39\\xA3\\x3C\\xE4\\x59\\x64\\xFF\\x21\\x67\\xF6\\xEC\\xED\\xD4\\x19\\xDB\"\n                 \"\\x06\\xC1\")\n    };\n\n    int times( sizeof(test_sha) / sizeof(testVector) );\n    for (int i = 0; i < times; ++i) {\n        sha.Update(test_sha[i].input_, test_sha[i].inLen_);\n        sha.Final(hash);\n\n        if (memcmp(hash, test_sha[i].output_, SHA256::DIGEST_SIZE) != 0)\n            return -1 - i;\n    }\n\n    return 0;\n}\n\n\n#ifdef WORD64_AVAILABLE\n\nint sha512_test()\n{\n    SHA512 sha;\n    byte   hash[SHA512::DIGEST_SIZE];\n\n    testVector test_sha[] =\n    {\n        testVector(\"abc\",\n                 \"\\xdd\\xaf\\x35\\xa1\\x93\\x61\\x7a\\xba\\xcc\\x41\\x73\\x49\\xae\\x20\\x41\"\n                 \"\\x31\\x12\\xe6\\xfa\\x4e\\x89\\xa9\\x7e\\xa2\\x0a\\x9e\\xee\\xe6\\x4b\\x55\"\n                 \"\\xd3\\x9a\\x21\\x92\\x99\\x2a\\x27\\x4f\\xc1\\xa8\\x36\\xba\\x3c\\x23\\xa3\"\n                 \"\\xfe\\xeb\\xbd\\x45\\x4d\\x44\\x23\\x64\\x3c\\xe8\\x0e\\x2a\\x9a\\xc9\\x4f\"\n                 \"\\xa5\\x4c\\xa4\\x9f\"),\n        testVector(\"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhi\"\n                   \"jklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu\", \n                 \"\\x8e\\x95\\x9b\\x75\\xda\\xe3\\x13\\xda\\x8c\\xf4\\xf7\\x28\\x14\\xfc\\x14\"\n                 \"\\x3f\\x8f\\x77\\x79\\xc6\\xeb\\x9f\\x7f\\xa1\\x72\\x99\\xae\\xad\\xb6\\x88\"\n                 \"\\x90\\x18\\x50\\x1d\\x28\\x9e\\x49\\x00\\xf7\\xe4\\x33\\x1b\\x99\\xde\\xc4\"\n                 \"\\xb5\\x43\\x3a\\xc7\\xd3\\x29\\xee\\xb6\\xdd\\x26\\x54\\x5e\\x96\\xe5\\x5b\"\n                 \"\\x87\\x4b\\xe9\\x09\")\n    };\n\n    int times( sizeof(test_sha) / sizeof(testVector) );\n    for (int i = 0; i < times; ++i) {\n        sha.Update(test_sha[i].input_, test_sha[i].inLen_);\n        sha.Final(hash);\n\n        if (memcmp(hash, test_sha[i].output_, SHA512::DIGEST_SIZE) != 0)\n            return -1 - i;\n    }\n\n    return 0;\n}\n\n\nint sha384_test()\n{\n    SHA384 sha;\n    byte   hash[SHA384::DIGEST_SIZE];\n\n    testVector test_sha[] =\n    {\n        testVector(\"abc\",\n                 \"\\xcb\\x00\\x75\\x3f\\x45\\xa3\\x5e\\x8b\\xb5\\xa0\\x3d\\x69\\x9a\\xc6\\x50\"\n                 \"\\x07\\x27\\x2c\\x32\\xab\\x0e\\xde\\xd1\\x63\\x1a\\x8b\\x60\\x5a\\x43\\xff\"\n                 \"\\x5b\\xed\\x80\\x86\\x07\\x2b\\xa1\\xe7\\xcc\\x23\\x58\\xba\\xec\\xa1\\x34\"\n                 \"\\xc8\\x25\\xa7\"),\n        testVector(\"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhi\"\n                   \"jklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu\", \n                 \"\\x09\\x33\\x0c\\x33\\xf7\\x11\\x47\\xe8\\x3d\\x19\\x2f\\xc7\\x82\\xcd\\x1b\"\n                 \"\\x47\\x53\\x11\\x1b\\x17\\x3b\\x3b\\x05\\xd2\\x2f\\xa0\\x80\\x86\\xe3\\xb0\"\n                 \"\\xf7\\x12\\xfc\\xc7\\xc7\\x1a\\x55\\x7e\\x2d\\xb9\\x66\\xc3\\xe9\\xfa\\x91\"\n                 \"\\x74\\x60\\x39\")\n    };\n\n    int times( sizeof(test_sha) / sizeof(testVector) );\n    for (int i = 0; i < times; ++i) {\n        sha.Update(test_sha[i].input_, test_sha[i].inLen_);\n        sha.Final(hash);\n\n        if (memcmp(hash, test_sha[i].output_, SHA384::DIGEST_SIZE) != 0)\n            return -1 - i;\n    }\n\n    return 0;\n}\n\n#endif // WORD64_AVAILABLE\n\n\nint sha224_test()\n{\n    SHA224 sha;\n    byte   hash[SHA224::DIGEST_SIZE];\n\n    testVector test_sha[] =\n    {\n        testVector(\"abc\",\n                 \"\\x23\\x09\\x7d\\x22\\x34\\x05\\xd8\\x22\\x86\\x42\\xa4\\x77\\xbd\\xa2\\x55\"\n                 \"\\xb3\\x2a\\xad\\xbc\\xe4\\xbd\\xa0\\xb3\\xf7\\xe3\\x6c\\x9d\\xa7\"),\n        testVector(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\",\n                 \"\\x75\\x38\\x8b\\x16\\x51\\x27\\x76\\xcc\\x5d\\xba\\x5d\\xa1\\xfd\\x89\\x01\"\n                 \"\\x50\\xb0\\xc6\\x45\\x5c\\xb4\\xf5\\x8b\\x19\\x52\\x52\\x25\\x25\")\n    };\n\n    int times( sizeof(test_sha) / sizeof(testVector) );\n    for (int i = 0; i < times; ++i) {\n        sha.Update(test_sha[i].input_, test_sha[i].inLen_);\n        sha.Final(hash);\n\n        if (memcmp(hash, test_sha[i].output_, SHA224::DIGEST_SIZE) != 0)\n            return -1 - i;\n    }\n\n    return 0;\n}\n\n\nint md5_test()\n{\n    MD5  md5;\n    byte hash[MD5::DIGEST_SIZE];\n\n    testVector test_md5[] =\n    {\n        testVector(\"abc\", \n                 \"\\x90\\x01\\x50\\x98\\x3c\\xd2\\x4f\\xb0\\xd6\\x96\\x3f\\x7d\\x28\\xe1\\x7f\"\n                 \"\\x72\"),\n        testVector(\"message digest\", \n                 \"\\xf9\\x6b\\x69\\x7d\\x7c\\xb7\\x93\\x8d\\x52\\x5a\\x2f\\x31\\xaa\\xf1\\x61\"\n                 \"\\xd0\"),\n        testVector(\"abcdefghijklmnopqrstuvwxyz\",\n                 \"\\xc3\\xfc\\xd3\\xd7\\x61\\x92\\xe4\\x00\\x7d\\xfb\\x49\\x6c\\xca\\x67\\xe1\"\n                 \"\\x3b\"),\n        testVector(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345\"\n                 \"6789\",\n                 \"\\xd1\\x74\\xab\\x98\\xd2\\x77\\xd9\\xf5\\xa5\\x61\\x1c\\x2c\\x9f\\x41\\x9d\"\n                 \"\\x9f\"),\n        testVector(\"1234567890123456789012345678901234567890123456789012345678\"\n                 \"9012345678901234567890\",\n                 \"\\x57\\xed\\xf4\\xa2\\x2b\\xe3\\xc9\\x55\\xac\\x49\\xda\\x2e\\x21\\x07\\xb6\"\n                 \"\\x7a\")\n    };\n\n    int times( sizeof(test_md5) / sizeof(testVector) );\n    for (int i = 0; i < times; ++i) {\n        md5.Update(test_md5[i].input_, test_md5[i].inLen_);\n        md5.Final(hash);\n\n        if (memcmp(hash, test_md5[i].output_, MD5::DIGEST_SIZE) != 0)\n            return -5 - i;\n    }\n\n    return 0;\n}\n\n\nint md4_test()\n{\n    MD4  md4;\n    byte hash[MD4::DIGEST_SIZE];\n\n    testVector test_md4[] =\n    {\n        testVector(\"\",\n                 \"\\x31\\xd6\\xcf\\xe0\\xd1\\x6a\\xe9\\x31\\xb7\\x3c\\x59\\xd7\\xe0\\xc0\\x89\"\n                 \"\\xc0\"),\n        testVector(\"a\",\n                 \"\\xbd\\xe5\\x2c\\xb3\\x1d\\xe3\\x3e\\x46\\x24\\x5e\\x05\\xfb\\xdb\\xd6\\xfb\"\n                 \"\\x24\"),\n        testVector(\"abc\", \n                 \"\\xa4\\x48\\x01\\x7a\\xaf\\x21\\xd8\\x52\\x5f\\xc1\\x0a\\xe8\\x7a\\xa6\\x72\"\n                 \"\\x9d\"),\n        testVector(\"message digest\", \n                 \"\\xd9\\x13\\x0a\\x81\\x64\\x54\\x9f\\xe8\\x18\\x87\\x48\\x06\\xe1\\xc7\\x01\"\n                 \"\\x4b\"),\n        testVector(\"abcdefghijklmnopqrstuvwxyz\",\n                 \"\\xd7\\x9e\\x1c\\x30\\x8a\\xa5\\xbb\\xcd\\xee\\xa8\\xed\\x63\\xdf\\x41\\x2d\"\n                 \"\\xa9\"),\n        testVector(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345\"\n                 \"6789\",\n                 \"\\x04\\x3f\\x85\\x82\\xf2\\x41\\xdb\\x35\\x1c\\xe6\\x27\\xe1\\x53\\xe7\\xf0\"\n                 \"\\xe4\"),\n        testVector(\"1234567890123456789012345678901234567890123456789012345678\"\n                 \"9012345678901234567890\",\n                 \"\\xe3\\x3b\\x4d\\xdc\\x9c\\x38\\xf2\\x19\\x9c\\x3e\\x7b\\x16\\x4f\\xcc\\x05\"\n                 \"\\x36\")\n    };\n\n    int times( sizeof(test_md4) / sizeof(testVector) );\n    for (int i = 0; i < times; ++i) {\n        md4.Update(test_md4[i].input_, test_md4[i].inLen_);\n        md4.Final(hash);\n\n        if (memcmp(hash, test_md4[i].output_, MD4::DIGEST_SIZE) != 0)\n            return -5 - i;\n    }\n\n    return 0;\n}\n\n\nint md2_test()\n{\n    MD2  md5;\n    byte hash[MD2::DIGEST_SIZE];\n\n    testVector test_md2[] =\n    {\n        testVector(\"\",\n                   \"\\x83\\x50\\xe5\\xa3\\xe2\\x4c\\x15\\x3d\\xf2\\x27\\x5c\\x9f\\x80\\x69\"\n                   \"\\x27\\x73\"),\n        testVector(\"a\",\n                   \"\\x32\\xec\\x01\\xec\\x4a\\x6d\\xac\\x72\\xc0\\xab\\x96\\xfb\\x34\\xc0\"\n                   \"\\xb5\\xd1\"),\n        testVector(\"abc\",\n                   \"\\xda\\x85\\x3b\\x0d\\x3f\\x88\\xd9\\x9b\\x30\\x28\\x3a\\x69\\xe6\\xde\"\n                   \"\\xd6\\xbb\"),\n        testVector(\"message digest\",\n                   \"\\xab\\x4f\\x49\\x6b\\xfb\\x2a\\x53\\x0b\\x21\\x9f\\xf3\\x30\\x31\\xfe\"\n                   \"\\x06\\xb0\"),\n        testVector(\"abcdefghijklmnopqrstuvwxyz\",\n                   \"\\x4e\\x8d\\xdf\\xf3\\x65\\x02\\x92\\xab\\x5a\\x41\\x08\\xc3\\xaa\\x47\"\n                   \"\\x94\\x0b\"),\n        testVector(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"\n                   \"0123456789\",\n                   \"\\xda\\x33\\xde\\xf2\\xa4\\x2d\\xf1\\x39\\x75\\x35\\x28\\x46\\xc3\\x03\"\n                   \"\\x38\\xcd\"),\n        testVector(\"12345678901234567890123456789012345678901234567890123456\"\n                   \"789012345678901234567890\",\n                   \"\\xd5\\x97\\x6f\\x79\\xd8\\x3d\\x3a\\x0d\\xc9\\x80\\x6c\\x3c\\x66\\xf3\"\n                   \"\\xef\\xd8\")\n    };\n\n    int times( sizeof(test_md2) / sizeof(testVector) );\n    for (int i = 0; i < times; ++i) {\n        md5.Update(test_md2[i].input_, test_md2[i].inLen_);\n        md5.Final(hash);\n\n        if (memcmp(hash, test_md2[i].output_, MD2::DIGEST_SIZE) != 0)\n            return -10 - i;\n    }\n\n    return 0;\n}\n\n\nint ripemd_test()\n{\n    RIPEMD160  ripe160;\n    byte hash[RIPEMD160::DIGEST_SIZE];\n\n    testVector test_ripemd[] =\n    {\n        testVector(\"\",\n                   \"\\x9c\\x11\\x85\\xa5\\xc5\\xe9\\xfc\\x54\\x61\\x28\\x08\\x97\\x7e\\xe8\"\n                   \"\\xf5\\x48\\xb2\\x25\\x8d\\x31\"),\n        testVector(\"a\",\n                   \"\\x0b\\xdc\\x9d\\x2d\\x25\\x6b\\x3e\\xe9\\xda\\xae\\x34\\x7b\\xe6\\xf4\"\n                   \"\\xdc\\x83\\x5a\\x46\\x7f\\xfe\"),\n        testVector(\"abc\",\n                   \"\\x8e\\xb2\\x08\\xf7\\xe0\\x5d\\x98\\x7a\\x9b\\x04\\x4a\\x8e\\x98\\xc6\"\n                   \"\\xb0\\x87\\xf1\\x5a\\x0b\\xfc\"),\n        testVector(\"message digest\",\n                   \"\\x5d\\x06\\x89\\xef\\x49\\xd2\\xfa\\xe5\\x72\\xb8\\x81\\xb1\\x23\\xa8\"\n                   \"\\x5f\\xfa\\x21\\x59\\x5f\\x36\"),\n        testVector(\"abcdefghijklmnopqrstuvwxyz\",\n                   \"\\xf7\\x1c\\x27\\x10\\x9c\\x69\\x2c\\x1b\\x56\\xbb\\xdc\\xeb\\x5b\\x9d\"\n                   \"\\x28\\x65\\xb3\\x70\\x8d\\xbc\"),\n        testVector(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\",\n                   \"\\x12\\xa0\\x53\\x38\\x4a\\x9c\\x0c\\x88\\xe4\\x05\\xa0\\x6c\\x27\\xdc\"\n                   \"\\xf4\\x9a\\xda\\x62\\xeb\\x2b\"),\n        testVector(\"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123\"\n                   \"456789\",\n                   \"\\xb0\\xe2\\x0b\\x6e\\x31\\x16\\x64\\x02\\x86\\xed\\x3a\\x87\\xa5\\x71\"\n                   \"\\x30\\x79\\xb2\\x1f\\x51\\x89\"),\n        testVector(\"12345678901234567890123456789012345678901234567890123456\"\n                   \"789012345678901234567890\",\n                   \"\\x9b\\x75\\x2e\\x45\\x57\\x3d\\x4b\\x39\\xf4\\xdb\\xd3\\x32\\x3c\\xab\"\n                   \"\\x82\\xbf\\x63\\x32\\x6b\\xfb\"),\n    };\n\n    int times( sizeof(test_ripemd) / sizeof(testVector) );\n    for (int i = 0; i < times; ++i) {\n        ripe160.Update(test_ripemd[i].input_, test_ripemd[i].inLen_);\n        ripe160.Final(hash);\n\n        if (memcmp(hash, test_ripemd[i].output_, RIPEMD160::DIGEST_SIZE) != 0)\n            return -100 - i;\n    }\n\n    return 0;\n}\n\n\nint hmac_test()\n{\n    HMAC<MD5> hmacMD5;\n    byte hash[MD5::DIGEST_SIZE];\n\n    const char* keys[]=\n    {\n        \"\\x0b\\x0b\\x0b\\x0b\\x0b\\x0b\\x0b\\x0b\\x0b\\x0b\\x0b\\x0b\\x0b\\x0b\\x0b\\x0b\",\n        \"Jefe\",\n        \"\\xAA\\xAA\\xAA\\xAA\\xAA\\xAA\\xAA\\xAA\\xAA\\xAA\\xAA\\xAA\\xAA\\xAA\\xAA\\xAA\"\n    };\n\n    testVector test_hmacMD5[] = \n    {\n        testVector(\"Hi There\",\n                 \"\\x92\\x94\\x72\\x7a\\x36\\x38\\xbb\\x1c\\x13\\xf4\\x8e\\xf8\\x15\\x8b\\xfc\"\n                 \"\\x9d\"),\n        testVector(\"what do ya want for nothing?\",\n                 \"\\x75\\x0c\\x78\\x3e\\x6a\\xb0\\xb5\\x03\\xea\\xa8\\x6e\\x31\\x0a\\x5d\\xb7\"\n                 \"\\x38\"),\n        testVector(\"\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\"\n                 \"\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\"\n                 \"\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\"\n                 \"\\xDD\\xDD\\xDD\\xDD\\xDD\\xDD\",\n                 \"\\x56\\xbe\\x34\\x52\\x1d\\x14\\x4c\\x88\\xdb\\xb8\\xc7\\x33\\xf0\\xe8\\xb3\"\n                 \"\\xf6\")\n    };\n\n    int times( sizeof(test_hmacMD5) / sizeof(testVector) );\n    for (int i = 0; i < times; ++i) {\n        hmacMD5.SetKey((byte*)keys[i], (word32)strlen(keys[i]));\n        hmacMD5.Update(test_hmacMD5[i].input_, test_hmacMD5[i].inLen_);\n        hmacMD5.Final(hash);\n\n        if (memcmp(hash, test_hmacMD5[i].output_, MD5::DIGEST_SIZE) != 0)\n            return -20 - i;\n    }\n\n    return 0;\n}\n\n\nint arc4_test()\n{\n    byte cipher[16];\n    byte plain[16];\n\n    const char* keys[] = \n    {           \n        \"\\x01\\x23\\x45\\x67\\x89\\xab\\xcd\\xef\",\n        \"\\x01\\x23\\x45\\x67\\x89\\xab\\xcd\\xef\",\n        \"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n        \"\\xef\\x01\\x23\\x45\"\n    };\n\n    testVector test_arc4[] =\n    {\n        testVector(\"\\x01\\x23\\x45\\x67\\x89\\xab\\xcd\\xef\",\n                   \"\\x75\\xb7\\x87\\x80\\x99\\xe0\\xc5\\x96\"),\n        testVector(\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n                   \"\\x74\\x94\\xc2\\xe7\\x10\\x4b\\x08\\x79\"),\n        testVector(\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n                   \"\\xde\\x18\\x89\\x41\\xa3\\x37\\x5d\\x3a\"),\n        testVector(\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n                   \"\\xd6\\xa1\\x41\\xa7\\xec\\x3c\\x38\\xdf\\xbd\\x61\")\n    };\n\n\n    int times( sizeof(test_arc4) / sizeof(testVector) );\n    for (int i = 0; i < times; ++i) {\n        ARC4::Encryption enc;\n        ARC4::Decryption dec;\n\n        enc.SetKey((byte*)keys[i], (word32)strlen(keys[i]));\n        dec.SetKey((byte*)keys[i], (word32)strlen(keys[i]));\n\n        enc.Process(cipher, test_arc4[i].input_, test_arc4[i].outLen_);\n        dec.Process(plain,  cipher, test_arc4[i].outLen_);\n\n        if (memcmp(plain, test_arc4[i].input_, test_arc4[i].outLen_))\n            return -30 - i;\n\n        if (memcmp(cipher, test_arc4[i].output_, test_arc4[i].outLen_))\n            return -40 - i;\n    }\n\n    return 0;\n}\n\n\nint rabbit_test()\n{\n    byte cipher[16];\n    byte plain[16];\n\n    const char* keys[] = \n    {           \n        \"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n        \"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n        \"\\xAC\\xC3\\x51\\xDC\\xF1\\x62\\xFC\\x3B\\xFE\\x36\\x3D\\x2E\\x29\\x13\\x28\\x91\"\n    };\n\n    const char* ivs[] =\n    {\n        \"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n        \"\\x59\\x7E\\x26\\xC1\\x75\\xF5\\x73\\xC3\",\n        0\n    };\n\n\n    testVector test_rabbit[] =\n    {\n        testVector(\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n                   \"\\xED\\xB7\\x05\\x67\\x37\\x5D\\xCD\\x7C\"),\n        testVector(\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n                   \"\\x6D\\x7D\\x01\\x22\\x92\\xCC\\xDC\\xE0\"),\n        testVector(\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n                   \"\\x9C\\x51\\xE2\\x87\\x84\\xC3\\x7F\\xE9\")\n    };\n\n\n    int times( sizeof(test_rabbit) / sizeof(testVector) );\n    for (int i = 0; i < times; ++i) {\n        Rabbit::Encryption enc;\n        Rabbit::Decryption dec;\n\n        enc.SetKey((byte*)keys[i], (byte*)ivs[i]);\n        dec.SetKey((byte*)keys[i], (byte*)ivs[i]);\n\n        enc.Process(cipher, test_rabbit[i].input_, test_rabbit[i].outLen_);\n        dec.Process(plain,  cipher, test_rabbit[i].outLen_);\n\n        if (memcmp(plain, test_rabbit[i].input_, test_rabbit[i].outLen_))\n            return -230 - i;\n\n        if (memcmp(cipher, test_rabbit[i].output_, test_rabbit[i].outLen_))\n            return -240 - i;\n    }\n\n    return 0;\n}\n\n\nint hc128_test()\n{\n    byte cipher[16];\n    byte plain[16];\n\n    const char* keys[] = \n    {           \n        \"\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n        \"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n        \"\\x00\\x53\\xA6\\xF9\\x4C\\x9F\\xF2\\x45\\x98\\xEB\\x3E\\x91\\xE4\\x37\\x8A\\xDD\",\n        \"\\x0F\\x62\\xB5\\x08\\x5B\\xAE\\x01\\x54\\xA7\\xFA\\x4D\\xA0\\xF3\\x46\\x99\\xEC\"\n    };\n\n    const char* ivs[] =\n    {\n        \"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n        \"\\x80\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n        \"\\x0D\\x74\\xDB\\x42\\xA9\\x10\\x77\\xDE\\x45\\xAC\\x13\\x7A\\xE1\\x48\\xAF\\x16\",\n        \"\\x28\\x8F\\xF6\\x5D\\xC4\\x2B\\x92\\xF9\\x60\\xC7\\x2E\\x95\\xFC\\x63\\xCA\\x31\"\n    };\n\n    testVector test_hc128[] =\n    {\n        testVector(\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n                   \"\\x37\\x86\\x02\\xB9\\x8F\\x32\\xA7\\x48\"),\n        testVector(\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n                   \"\\x33\\x7F\\x86\\x11\\xC6\\xED\\x61\\x5F\"),\n        testVector(\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n                   \"\\x2E\\x1E\\xD1\\x2A\\x85\\x51\\xC0\\x5A\"),\n      testVector(\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\",\n                 \"\\x1C\\xD8\\xAE\\xDD\\xFE\\x52\\xE2\\x17\\xE8\\x35\\xD0\\xB7\\xE8\\x4E\\x29\")\n    };\n\n    int times( sizeof(test_hc128) / sizeof(testVector) );\n    for (int i = 0; i < times; ++i) {\n        HC128::Encryption enc;\n        HC128::Decryption dec;\n\n        enc.SetKey((byte*)keys[i], (byte*)ivs[i]);\n        dec.SetKey((byte*)keys[i], (byte*)ivs[i]);\n\n        enc.Process(cipher, test_hc128[i].input_, test_hc128[i].outLen_);\n        dec.Process(plain,  cipher, test_hc128[i].outLen_);\n\n        if (memcmp(plain, test_hc128[i].input_, test_hc128[i].outLen_))\n            return -330 - i;\n\n        if (memcmp(cipher, test_hc128[i].output_, test_hc128[i].outLen_))\n            return -340 - i;\n    }\n\n    return 0;\n}\n\n\nint des_test()\n{\n    //ECB mode\n    DES_ECB_Encryption enc;\n    DES_ECB_Decryption dec;\n\n    const int sz = TaoCrypt::DES_BLOCK_SIZE * 3;\n    const byte key[] = { 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef };\n    const byte iv[] =  { 0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef };\n\n    enc.SetKey(key, sizeof(key));\n    enc.Process(cipher, msg, sz);\n    dec.SetKey(key, sizeof(key));\n    dec.Process(plain, cipher, sz);\n\n    if (memcmp(plain, msg, sz))\n        return -50;\n\n    const byte verify1[] = \n    {\n        0xf9,0x99,0xb8,0x8e,0xaf,0xea,0x71,0x53,\n        0x6a,0x27,0x17,0x87,0xab,0x88,0x83,0xf9,\n        0x89,0x3d,0x51,0xec,0x4b,0x56,0x3b,0x53\n    };\n\n    if (memcmp(cipher, verify1, sz))\n        return -51;\n\n    // CBC mode\n    DES_CBC_Encryption enc2;\n    DES_CBC_Decryption dec2;\n\n    enc2.SetKey(key, sizeof(key), iv);\n    enc2.Process(cipher, msg, sz);\n    dec2.SetKey(key, sizeof(key), iv);\n    dec2.Process(plain, cipher, sz);\n\n    if (memcmp(plain, msg, sz))\n        return -52;\n\n    const byte verify2[] = \n    {\n        0x8b,0x7c,0x52,0xb0,0x01,0x2b,0x6c,0xb8,\n        0x4f,0x0f,0xeb,0xf3,0xfb,0x5f,0x86,0x73,\n        0x15,0x85,0xb3,0x22,0x4b,0x86,0x2b,0x4b\n    };\n\n    if (memcmp(cipher, verify2, sz))\n        return -53;\n\n    // EDE3 CBC mode\n    DES_EDE3_CBC_Encryption enc3;\n    DES_EDE3_CBC_Decryption dec3;\n\n    const byte key3[] = \n    {\n        0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,\n        0xfe,0xde,0xba,0x98,0x76,0x54,0x32,0x10,\n        0x89,0xab,0xcd,0xef,0x01,0x23,0x45,0x67\n    };\n    const byte iv3[] = \n    {\n        0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef,\n        0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,\n        0x11,0x21,0x31,0x41,0x51,0x61,0x71,0x81\n        \n    };\n\n    enc3.SetKey(key3, sizeof(key3), iv3);\n    enc3.Process(cipher, msg, sz);\n    dec3.SetKey(key3, sizeof(key3), iv3);\n    dec3.Process(plain, cipher, sz);\n\n    if (memcmp(plain, msg, sz))\n        return -54;\n\n    const byte verify3[] = \n    {\n        0x08,0x8a,0xae,0xe6,0x9a,0xa9,0xc1,0x13,\n        0x93,0x7d,0xf7,0x3a,0x11,0x56,0x66,0xb3,\n        0x18,0xbc,0xbb,0x6d,0xd2,0xb1,0x16,0xda\n    };\n\n    if (memcmp(cipher, verify3, sz))\n        return -55;\n\n    return 0;\n}\n\n\nint aes_test()\n{\n    AES_CBC_Encryption enc;\n    AES_CBC_Decryption dec;\n    const int bs(TaoCrypt::AES::BLOCK_SIZE);\n\n    byte key[] = \"0123456789abcdef   \";  // align\n    byte iv[]  = \"1234567890abcdef   \";  // align\n\n    enc.SetKey(key, bs, iv);\n    dec.SetKey(key, bs, iv);\n\n    enc.Process(cipher, msg, bs);\n    dec.Process(plain, cipher, bs);\n\n    if (memcmp(plain, msg, bs))\n        return -60;\n\n    const byte verify[] = \n    {\n        0x95,0x94,0x92,0x57,0x5f,0x42,0x81,0x53,\n        0x2c,0xcc,0x9d,0x46,0x77,0xa2,0x33,0xcb\n    };\n\n    if (memcmp(cipher, verify, bs))\n        return -61;\n\n    AES_ECB_Encryption enc2;\n    AES_ECB_Decryption dec2;\n\n    enc2.SetKey(key, bs, iv);\n    dec2.SetKey(key, bs, iv);\n\n    enc2.Process(cipher, msg, bs);\n    dec2.Process(plain, cipher, bs);\n\n    if (memcmp(plain, msg, bs))\n        return -62;\n\n    const byte verify2[] = \n    {\n        0xd0,0xc9,0xd9,0xc9,0x40,0xe8,0x97,0xb6,\n        0xc8,0x8c,0x33,0x3b,0xb5,0x8f,0x85,0xd1\n    };\n\n    if (memcmp(cipher, verify2, bs))\n        return -63;\n\n    return 0;\n}\n\n\nint twofish_test()\n{\n    Twofish_CBC_Encryption enc;\n    Twofish_CBC_Decryption dec;\n    const int bs(TaoCrypt::Twofish::BLOCK_SIZE);\n\n    byte key[] = \"0123456789abcdef   \";  // align\n    byte iv[]  = \"1234567890abcdef   \";  // align\n\n    enc.SetKey(key, bs, iv);\n    dec.SetKey(key, bs, iv);\n\n    enc.Process(cipher, msg, bs);\n    dec.Process(plain, cipher, bs);\n\n    if (memcmp(plain, msg, bs))\n        return -60;\n\n    const byte verify[] = \n    {\n        0xD2,0xD7,0x47,0x47,0x4A,0x65,0x4E,0x16,\n        0x21,0x03,0x58,0x79,0x5F,0x02,0x27,0x2C\n    };\n\n    if (memcmp(cipher, verify, bs))\n        return -61;\n\n    Twofish_ECB_Encryption enc2;\n    Twofish_ECB_Decryption dec2;\n\n    enc2.SetKey(key, bs, iv);\n    dec2.SetKey(key, bs, iv);\n\n    enc2.Process(cipher, msg, bs);\n    dec2.Process(plain, cipher, bs);\n\n    if (memcmp(plain, msg, bs))\n        return -62;\n\n    const byte verify2[] = \n    {\n        0x3B,0x6C,0x63,0x10,0x34,0xAB,0xB2,0x87,\n        0xC4,0xCD,0x6B,0x91,0x14,0xC5,0x3A,0x09\n    };\n\n    if (memcmp(cipher, verify2, bs))\n        return -63;\n\n    return 0;\n}\n\n\nint blowfish_test()\n{\n    Blowfish_CBC_Encryption enc;\n    Blowfish_CBC_Decryption dec;\n    const int bs(TaoCrypt::Blowfish::BLOCK_SIZE);\n\n    byte key[] = \"0123456789abcdef   \";  // align\n    byte iv[]  = \"1234567890abcdef   \";  // align\n\n    enc.SetKey(key, 16, iv);\n    dec.SetKey(key, 16, iv);\n\n    enc.Process(cipher, msg, bs * 2);\n    dec.Process(plain, cipher, bs * 2);\n\n    if (memcmp(plain, msg, bs))\n        return -60;\n\n    const byte verify[] = \n    {\n        0x0E,0x26,0xAA,0x29,0x11,0x25,0xAB,0xB5,\n        0xBC,0xD9,0x08,0xC4,0x94,0x6C,0x89,0xA3\n    };\n\n    if (memcmp(cipher, verify, bs))\n        return -61;\n\n    Blowfish_ECB_Encryption enc2;\n    Blowfish_ECB_Decryption dec2;\n\n    enc2.SetKey(key, 16, iv);\n    dec2.SetKey(key, 16, iv);\n\n    enc2.Process(cipher, msg, bs * 2);\n    dec2.Process(plain, cipher, bs * 2);\n\n    if (memcmp(plain, msg, bs))\n        return -62;\n\n    const byte verify2[] = \n    {\n        0xE7,0x42,0xB9,0x37,0xC8,0x7D,0x93,0xCA,\n        0x8F,0xCE,0x39,0x32,0xDE,0xD7,0xBC,0x5B\n    };\n\n    if (memcmp(cipher, verify2, bs))\n        return -63;\n\n    return 0;\n}\n\n\nint rsa_test()\n{\n    Source source;\n    FileSource(\"../certs/client-key.der\", source);\n    if (source.size() == 0) {\n        FileSource(\"../../certs/client-key.der\", source);  // for testsuite\n        if (source.size() == 0) {\n            FileSource(\"../../../certs/client-key.der\", source); // Debug dir\n            if (source.size() == 0)\n                err_sys(\"where's your certs dir?\", -79);\n        }\n    }\n    RSA_PrivateKey priv(source);\n\n    RSAES_Encryptor enc(priv);\n    byte message[] = \"Everyone gets Friday off.\";\n    const word32 len = (word32)strlen((char*)message);\n    byte cipher[512];\n    enc.Encrypt(message, len, cipher, rng);\n\n    RSAES_Decryptor dec(priv);\n    byte plain[512];\n    dec.Decrypt(cipher, priv.FixedCiphertextLength(), plain, rng);\n\n    if (memcmp(plain, message, len))\n        return -70;\n\n    dec.SSL_Sign(message, len, cipher, rng);\n    if (!enc.SSL_Verify(message, len, cipher))\n        return -71;\n\n\n    // test decode   \n    Source source2;\n    FileSource(\"../certs/client-cert.der\", source2);\n    if (source2.size() == 0) {\n        FileSource(\"../../certs/client-cert.der\", source2);  // for testsuite\n        if (source2.size() == 0) {\n            FileSource(\"../../../certs/client-cert.der\", source2); // Debug dir\n            if (source2.size() == 0)\n                err_sys(\"where's your certs dir?\", -79);\n        }\n    }\n    CertDecoder cd(source2, true, 0, false, CertDecoder::CA);\n    if (cd.GetError().What())\n        err_sys(\"cert error\", -80);\n    Source source3(cd.GetPublicKey().GetKey(), cd.GetPublicKey().size());\n    RSA_PublicKey pub(source3);\n \n    return 0;\n}\n\n\nint dh_test()\n{\n    Source source;\n    FileSource(\"../certs/dh1024.dat\", source);\n    if (source.size() == 0) {\n        FileSource(\"../../certs/dh1024.dat\", source);  // for testsuite\n        if (source.size() == 0) {\n            FileSource(\"../../../certs/dh1024.dat\", source); // win32 Debug dir\n            if (source.size() == 0)\n                err_sys(\"where's your certs dir?\", -79);\n        }\n    }\n    HexDecoder hDec(source);\n\n    DH dh(source);\n\n    byte pub[128];\n    byte priv[128];\n    byte agree[128];\n    byte pub2[128];\n    byte priv2[128];\n    byte agree2[128];\n\n    DH dh2(dh);\n\n    dh.GenerateKeyPair(rng, priv, pub);\n    dh2.GenerateKeyPair(rng, priv2, pub2);\n    dh.Agree(agree, priv, pub2); \n    dh2.Agree(agree2, priv2, pub);\n\n    \n    if ( memcmp(agree, agree2, dh.GetByteLength()) )\n        return -80;\n\n    return 0;\n}\n\n\nint dsa_test()\n{\n    Source source;\n    FileSource(\"../certs/dsa1024.der\", source);\n    if (source.size() == 0) {\n        FileSource(\"../../certs/dsa1024.der\", source);  // for testsuite\n        if (source.size() == 0) {\n            FileSource(\"../../../certs/dsa1024.der\", source); // win32 Debug dir\n            if (source.size() == 0)\n                err_sys(\"where's your certs dir?\", -89);\n        }\n    }\n\n    const char msg[] = \"this is the message\";\n    byte signature[40];\n\n    DSA_PrivateKey priv(source);\n    DSA_Signer signer(priv);\n\n    SHA sha;\n    byte digest[SHA::DIGEST_SIZE];\n    sha.Update((byte*)msg, sizeof(msg));\n    sha.Final(digest);\n\n    signer.Sign(digest, signature, rng);\n\n    byte encoded[sizeof(signature) + 6];\n    byte decoded[40];\n\n    word32 encSz = EncodeDSA_Signature(signer.GetR(), signer.GetS(), encoded);\n    DecodeDSA_Signature(decoded, encoded, encSz);\n\n    DSA_PublicKey pub(priv);\n    DSA_Verifier verifier(pub);\n\n    if (!verifier.Verify(digest, decoded))\n        return -90;\n\n    return 0;\n}\n\n\nint pwdbased_test()\n{\n    PBKDF2_HMAC<SHA> pb;\n\n    byte derived[32];\n    const byte pwd1[] = \"password   \";  // align\n    const byte salt[]  = { 0x12, 0x34, 0x56, 0x78, 0x78, 0x56, 0x34, 0x12 };\n    \n    pb.DeriveKey(derived, 8, pwd1, 8, salt, sizeof(salt), 5);\n\n    const byte verify1[] = { 0xD1, 0xDA, 0xA7, 0x86, 0x15, 0xF2, 0x87, 0xE6 };\n\n    if ( memcmp(derived, verify1, sizeof(verify1)) )\n        return -101;\n\n\n    const byte pwd2[] = \"All n-entities must communicate with other n-entities\"\n                        \" via n-1 entiteeheehees   \";  // align\n\n    pb.DeriveKey(derived, 24, pwd2, 76, salt, sizeof(salt), 500);\n\n    const byte verify2[] = { 0x6A, 0x89, 0x70, 0xBF, 0x68, 0xC9, 0x2C, 0xAE,\n                             0xA8, 0x4A, 0x8D, 0xF2, 0x85, 0x10, 0x85, 0x86,\n                             0x07, 0x12, 0x63, 0x80, 0xCC, 0x47, 0xAB, 0x2D\n    };\n\n    if ( memcmp(derived, verify2, sizeof(verify2)) )\n        return -102;\n\n    return 0;\n}\n\n\n/*\nint pkcs12_test()\n{\n    Source cert;\n    FileSource(\"../certs/server-cert.pem\", cert);\n    if (cert.size() == 0) {\n        FileSource(\"../../certs/server-cert.pem\", cert);  // for testsuite\n        if (cert.size() == 0) {\n            FileSource(\"../../../certs/server-cert.pem\", cert); // Debug dir\n            if (cert.size() == 0)\n                err_sys(\"where's your certs dir?\", -109);\n        }\n    }\n\n    if (GetCert(cert) != 0)\n        return -110;\n\n    Source source;\n    FileSource(\"../certs/server.p12\", source);\n    if (source.size() == 0) {\n        FileSource(\"../../certs/server.p12\", source);  // for testsuite\n        if (source.size() == 0) {\n            FileSource(\"../../../certs/server.p12\", source); // Debug dir\n            if (source.size() == 0)\n                err_sys(\"where's your certs dir?\", -111);\n        }\n    }\n\n    if (GetPKCS_Cert(\"password\", source) != 0)\n        return -112;\n\n    return 0;\n}\n*/\n\n"
  },
  {
    "path": "ext/yassl/taocrypt/test/test.dsp",
    "content": "# Microsoft Developer Studio Project File - Name=\"test\" - Package Owner=<4>\n# Microsoft Developer Studio Generated Build File, Format Version 6.00\n# ** DO NOT EDIT **\n\n# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\n\nCFG=test - Win32 Debug\n!MESSAGE This is not a valid makefile. To build this project using NMAKE,\n!MESSAGE use the Export Makefile command and run\n!MESSAGE \n!MESSAGE NMAKE /f \"test.mak\".\n!MESSAGE \n!MESSAGE You can specify a configuration when running NMAKE\n!MESSAGE by defining the macro CFG on the command line. For example:\n!MESSAGE \n!MESSAGE NMAKE /f \"test.mak\" CFG=\"test - Win32 Debug\"\n!MESSAGE \n!MESSAGE Possible choices for configuration are:\n!MESSAGE \n!MESSAGE \"test - Win32 Release\" (based on \"Win32 (x86) Console Application\")\n!MESSAGE \"test - Win32 Debug\" (based on \"Win32 (x86) Console Application\")\n!MESSAGE \n\n# Begin Project\n# PROP AllowPerConfigDependencies 0\n# PROP Scc_ProjName \"\"\n# PROP Scc_LocalPath \"\"\nCPP=cl.exe\nRSC=rc.exe\n\n!IF  \"$(CFG)\" == \"test - Win32 Release\"\n\n# PROP BASE Use_MFC 0\n# PROP BASE Use_Debug_Libraries 0\n# PROP BASE Output_Dir \"test___Win32_Release\"\n# PROP BASE Intermediate_Dir \"test___Win32_Release\"\n# PROP BASE Target_Dir \"\"\n# PROP Use_MFC 0\n# PROP Use_Debug_Libraries 0\n# PROP Output_Dir \"Release\"\n# PROP Intermediate_Dir \"Release\"\n# PROP Ignore_Export_Lib 0\n# PROP Target_Dir \"\"\n# ADD BASE CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n# ADD CPP /nologo /MD /W3 /O2 /I \"../include\" /I \"../mySTL\" /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /FR /YX /FD /c\n# ADD BASE RSC /l 0x409 /d \"NDEBUG\"\n# ADD RSC /l 0x409 /d \"NDEBUG\"\nBSC32=bscmake.exe\n# ADD BASE BSC32 /nologo\n# ADD BSC32 /nologo\nLINK32=link.exe\n# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\n# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\n\n!ELSEIF  \"$(CFG)\" == \"test - Win32 Debug\"\n\n# PROP BASE Use_MFC 0\n# PROP BASE Use_Debug_Libraries 1\n# PROP BASE Output_Dir \"test___Win32_Debug\"\n# PROP BASE Intermediate_Dir \"test___Win32_Debug\"\n# PROP BASE Target_Dir \"\"\n# PROP Use_MFC 0\n# PROP Use_Debug_Libraries 1\n# PROP Output_Dir \"Debug\"\n# PROP Intermediate_Dir \"Debug\"\n# PROP Ignore_Export_Lib 0\n# PROP Target_Dir \"\"\n# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ /c\n# ADD CPP /nologo /MDd /W3 /Gm /ZI /Od /I \"../include\" /I \"../mySTL\" /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /FR /YX /FD /GZ /c\n# ADD BASE RSC /l 0x409 /d \"_DEBUG\"\n# ADD RSC /l 0x409 /d \"_DEBUG\"\nBSC32=bscmake.exe\n# ADD BASE BSC32 /nologo\n# ADD BSC32 /nologo\nLINK32=link.exe\n# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\n# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\n\n!ENDIF \n\n# Begin Target\n\n# Name \"test - Win32 Release\"\n# Name \"test - Win32 Debug\"\n# Begin Group \"Source Files\"\n\n# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\n# Begin Source File\n\nSOURCE=.\\test.cpp\n# End Source File\n# End Group\n# Begin Group \"Header Files\"\n\n# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\n# End Group\n# Begin Group \"Resource Files\"\n\n# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\n# End Group\n# End Target\n# End Project\n"
  },
  {
    "path": "ext/yassl/taocrypt/test.dsw",
    "content": "Microsoft Developer Studio Workspace File, Format Version 6.00\n# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\n\n###############################################################################\n\nProject: \"test\"=.\\test.dsp - Package Owner=<4>\n\nPackage=<5>\n{{{\n}}}\n\nPackage=<4>\n{{{\n}}}\n\n###############################################################################\n\nGlobal:\n\nPackage=<5>\n{{{\n}}}\n\nPackage=<3>\n{{{\n}}}\n\n###############################################################################\n\n"
  },
  {
    "path": "ext/yassl/testsuite/cipher-test.sh",
    "content": "#!/bin/bash\n\n# test all yassl cipher suties \n# \n\n\nno_pid=-1\nserver_pid=$no_pid\n\n\ndo_cleanup() {\n    echo \"in cleanup\"\n\n    if [[ $server_pid != $no_pid ]]\n    then\n        echo \"killing server\"\n        kill -9 $server_pid\n    fi\n}\n\ndo_trap() {\n    echo \"got trap\"\n    do_cleanup\n    exit -1\n}\n\ntrap do_trap INT TERM\n\n\n# make sure example server and client are built\nif test ! -s ../examples/server/server; then\n    echo \"Please build yaSSL first, example server missing\"\n    exit -1\nfi\n\nif test ! -s ../examples/client/client; then\n    echo \"Please build yaSSL first, example client missing\"\n    exit -1\nfi\n\n\n# non DSA suites\nfor suite in {\"DHE-RSA-AES256-SHA\",\"AES256-SHA\",\"DHE-RSA-AES128-SHA\",\"AES128-SHA\",\"AES256-RMD\",\"AES128-RMD\",\"DES-CBC3-RMD\",\"DHE-RSA-AES256-RMD\",\"DHE-RSA-AES128-RMD\",\"DHE-RSA-DES-CBC3-RMD\",\"RC4-SHA\",\"RC4-MD5\",\"DES-CBC3-SHA\",\"DES-CBC-SHA\",\"EDH-RSA-DES-CBC3-SHA\",\"EDH-RSA-DES-CBC-SHA\"}\ndo\n  for client_auth in {y,n}\n  do\n    echo \"Trying $suite client auth = $client_auth ...\"\n\n    if test -e server_ready; then\n        echo -e \"removing exisitng server_ready file\"\n        rm server_ready\n    fi\n    ../examples/server/server $client_auth &\n    server_pid=$!\n\n    while [ ! -s server_ready ]; do\n        echo -e \"waiting for server_ready file...\"\n        sleep 0.1\n    done\n\n    ../examples/client/client $suite\n    client_result=$?\n\n    wait $server_pid\n    server_result=$?\n\n    server_pid=$no_pid\n\n    if [[ $client_result != 0 ]]\n    then\n        echo \"Client Error\"\n        exit $client_result\n    fi\n\n    if [[ $server_result != 0 ]]\n    then\n        echo \"Server Error\"\n        exit $server_result\n    fi\n\n  done   # end client auth loop\ndone  # end non dsa suite list\necho -e \"Non DSA Loop SUCCESS\"\n\n\n\n# DSA suites\nfor suite in {\"DHE-DSS-AES256-SHA\",\"DHE-DSS-AES128-SHA\",\"DHE-DSS-AES256-RMD\",\"DHE-DSS-AES128-RMD\",\"DHE-DSS-DES-CBC3-RMD\",\"EDH-DSS-DES-CBC3-SHA\",\"EDH-DSS-DES-CBC-SHA\"}\ndo\n  for client_auth in {y,n}\n  do\n    echo \"Trying $suite client auth = $client_auth ...\"\n\n    if test -e server_ready; then\n        echo -e \"removing exisitng server_ready file\"\n        rm server_ready\n    fi\n    # d signifies DSA\n    ../examples/server/server $client_auth d &\n    server_pid=$!\n\n    while [ ! -s server_ready ]; do\n        echo -e \"waiting for server_ready file...\"\n        sleep 0.1\n    done\n\n    ../examples/client/client $suite\n    client_result=$?\n\n    wait $server_pid\n    server_result=$?\n\n    server_pid=$no_pid\n\n    if [[ $client_result != 0 ]]\n    then\n        echo \"Client Error\"\n        exit $client_result\n    fi\n\n    if [[ $server_result != 0 ]]\n    then\n        echo \"Server Error\"\n        exit $server_result\n    fi\n\n  done   # end client auth loop\ndone  # end dsa suite list\necho -e \"DSA Loop SUCCESS\"\n\nexit 0\n"
  },
  {
    "path": "ext/yassl/testsuite/input",
    "content": "// testsuite.cpp\n\n#include \"test.hpp\"\n#include \"md5.hpp\"\n\ntypedef unsigned char byte;\n\nvoid taocrypt_test(void*);\nvoid file_test(char*, byte*);\n\nvoid client_test(void*);\nvoid echoclient_test(void*);\n\nTHREAD_RETURN YASSL_API server_test(void*);\nTHREAD_RETURN YASSL_API echoserver_test(void*);\n\nint main(int argc, char** argv)\n{\n    func_args args(argc, argv);\n    func_args server_args(args);\n\n    // *** Crypto Test ***\n    taocrypt_test(&args);\n    assert(args.return_code == 0);\n    \n    \n    // *** Simple yaSSL client server test ***\n    THREAD_TYPE thread;\n\n    start_thread(server_test, &server_args, &thread);\n    client_test(&args);\n\n    assert(args.return_code == 0);\n    join_thread(thread);\n    assert(server_args.return_code == 0);\n    \n\n    // *** Echo input yaSSL client server test ***\n    start_thread(echoserver_test, &server_args, &thread);\n    func_args echo_args;\n\n            // setup args\n    echo_args.argc = 3;\n    echo_args.argv = new char*[echo_args.argc];\n    for (int i = 0; i < echo_args.argc; i++)\n        echo_args.argv[i] = new char[32];\n   \n    strcpy(echo_args.argv[0], \"echoclient\");\n    strcpy(echo_args.argv[1], \"input\");\n    strcpy(echo_args.argv[2], \"output\");\n    remove(\"output\");\n\n            // make sure OK\n    echoclient_test(&echo_args);\n    assert(echo_args.return_code == 0);\n\n\n    // *** Echo quit yaSSL client server test ***\n    echo_args.argc = 2;\n    strcpy(echo_args.argv[1], \"quit\");\n\n    echoclient_test(&echo_args);\n    assert(echo_args.return_code == 0);\n    join_thread(thread);\n    assert(server_args.return_code == 0);\n\n\n            // input output compare\n    byte input[TaoCrypt::MD5::DIGEST_SIZE];\n    byte output[TaoCrypt::MD5::DIGEST_SIZE];\n    file_test(\"input\", input);\n    file_test(\"output\", output);\n    assert(memcmp(input, output, sizeof(input)) == 0);\n\n    printf(\"\\nAll tests passed!\\n\");\n\n    // cleanup\n    for (int j = echo_args.argc; j >= 0; j--)\n        delete[] echo_args.argv[j];\n    delete[] echo_args.argv;\n\n    return 0;\n}\n\n\n\nvoid start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread)\n{\n#ifdef _WIN32\n    *thread = _beginthreadex(0, 0, fun, args, 0, 0);\n#else\n    pthread_create(thread, 0, fun, args);\n#endif\n}\n\n\nvoid join_thread(THREAD_TYPE thread)\n{\n#ifdef _WIN32\n    int res = WaitForSingleObject(reinterpret_cast<HANDLE>(thread), INFINITE);\n    assert(res == WAIT_OBJECT_0);\n    res = CloseHandle(reinterpret_cast<HANDLE>(thread));\n    assert(res);\n#else\n    pthread_join(thread, 0);\n#endif\n}\n"
  },
  {
    "path": "ext/yassl/testsuite/make.bat",
    "content": "REM Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.\nREM \nREM This program is free software; you can redistribute it and/or modify\nREM it under the terms of the GNU General Public License as published by\nREM the Free Software Foundation; version 2 of the License.\nREM \nREM This program is distributed in the hope that it will be useful,\nREM but WITHOUT ANY WARRANTY; without even the implied warranty of\nREM MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nREM GNU General Public License for more details.\nREM \nREM You should have received a copy of the GNU General Public License\nREM along with this program; if not, write to the Free Software\nREM Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\n\nREM quick and dirty build file for testing different MSDEVs\nsetlocal \n\nset myFLAGS= /I../include /I../taocrypt/include /I../taocrypt/mySTL /c /W3 /G6 /O2 /MT /D\"WIN32\" /D\"NO_MAIN_DRIVER\"\n\ncl %myFLAGS% testsuite.cpp\ncl %myFLAGS% ../examples/client/client.cpp\ncl %myFLAGS% ../examples/echoclient/echoclient.cpp\ncl %myFLAGS% ../examples/server/server.cpp\ncl %myFLAGS% ../examples/echoserver/echoserver.cpp\ncl %myFLAGS% ../taocrypt/test/test.cpp\n\nlink.exe  /out:testsuite.exe ../src/yassl.lib ../taocrypt/src/taocrypt.lib testsuite.obj client.obj server.obj echoclient.obj echoserver.obj test.obj advapi32.lib Ws2_32.lib\n\n"
  },
  {
    "path": "ext/yassl/testsuite/quit",
    "content": "quit\n\n"
  },
  {
    "path": "ext/yassl/testsuite/test.hpp",
    "content": "/*\n   Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n// test.hpp\n\n#ifndef yaSSL_TEST_HPP\n#define yaSSL_TEST_HPP\n\n#include \"runtime.hpp\"\n#include \"openssl/ssl.h\"   /* openssl compatibility test */\n#include \"error.hpp\"\n#include <stdio.h>\n#include <stdlib.h>\n#include <assert.h>\n\n//#define NON_BLOCKING  // test server and client example (not echos)\n\n#ifdef _WIN32\n    #include <winsock2.h>\n    #include <process.h>\n    #ifdef TEST_IPV6            // don't require newer SDK for IPV4\n\t    #include <ws2tcpip.h>\n        #include <wspiapi.h>\n    #endif\n    #define SOCKET_T unsigned int\n#else\n    #include <string.h>\n    #include <unistd.h>\n    #include <netinet/in.h>\n    #include <arpa/inet.h>\n    #include <sys/ioctl.h>\n    #include <sys/time.h>\n    #include <sys/types.h>\n    #include <sys/socket.h>\n    #ifdef TEST_IPV6\n        #include <netdb.h>\n    #endif\n    #include <pthread.h>\n#ifdef NON_BLOCKING\n    #include <fcntl.h>\n#endif\n    #define SOCKET_T int\n#endif /* _WIN32 */\n\n\n#ifdef _MSC_VER\n    // disable conversion warning\n    // 4996 warning to use MS extensions e.g., strcpy_s instead of strncpy\n    #pragma warning(disable:4244 4996)\n#endif\n\n\n#if !defined(_SOCKLEN_T) && (defined(_WIN32) || defined(__APPLE__))\n    typedef int socklen_t;\n#endif\n\n\n// Check type of third arg to accept\n#if defined(__hpux)\n// HPUX uses int* for third parameter to accept\n    typedef int*       ACCEPT_THIRD_T;\n#else\n    typedef socklen_t* ACCEPT_THIRD_T;\n#endif\n\n\n#ifdef TEST_IPV6\n    typedef sockaddr_in6 SOCKADDR_IN_T;\n    #define AF_INET_V    AF_INET6\n#else\n    typedef sockaddr_in  SOCKADDR_IN_T;\n    #define AF_INET_V    AF_INET\n#endif\n   \n\n// Check if _POSIX_THREADS should be forced\n#if !defined(_POSIX_THREADS) && defined(__hpux)\n// HPUX does not define _POSIX_THREADS as it's not _fully_ implemented\n#define _POSIX_THREADS\n#endif\n\n\n#ifndef _POSIX_THREADS\n    typedef unsigned int  THREAD_RETURN;\n    typedef HANDLE        THREAD_TYPE;\n    #define YASSL_API __stdcall\n#else\n    typedef void*         THREAD_RETURN;\n    typedef pthread_t     THREAD_TYPE;\n    #define YASSL_API \n#endif\n\n\nstruct tcp_ready {\n#ifdef _POSIX_THREADS\n    pthread_mutex_t mutex_;\n    pthread_cond_t  cond_;\n    bool            ready_;   // predicate\n\n    tcp_ready() : ready_(false)\n    {\n        pthread_mutex_init(&mutex_, 0);\n        pthread_cond_init(&cond_, 0);\n    }\n\n    ~tcp_ready()\n    {\n        pthread_mutex_destroy(&mutex_);\n        pthread_cond_destroy(&cond_);\n    }\n#endif\n};    \n\n\nstruct func_args {\n    int    argc;\n    char** argv;\n    int    return_code;\n    const char* file_ready;\n    tcp_ready* signal_;\n\n    func_args(int c = 0, char** v = 0) : argc(c), argv(v), file_ready(0) {}\n\n    void SetSignal(tcp_ready* p) { signal_ = p; }\n};\n\ntypedef THREAD_RETURN YASSL_API THREAD_FUNC(void*);\n\nvoid start_thread(THREAD_FUNC, func_args*, THREAD_TYPE*);\nvoid join_thread(THREAD_TYPE);\n\n// yaSSL\nconst char* const    yasslIP      = \"127.0.0.1\";\nconst unsigned short yasslPort    =  11111;\nconst unsigned short proxyPort    =  12345;\n\n\n// client\nconst char* const cert = \"../certs/client-cert.pem\";\nconst char* const key  = \"../certs/client-key.pem\";\n\nconst char* const certSuite = \"../../certs/client-cert.pem\";\nconst char* const keySuite  = \"../../certs/client-key.pem\";\n\nconst char* const certDebug = \"../../../certs/client-cert.pem\";\nconst char* const keyDebug  = \"../../../certs/client-key.pem\";\n\n\n// server\nconst char* const svrCert = \"../certs/server-cert.pem\";\nconst char* const svrKey  = \"../certs/server-key.pem\";\n\nconst char* const svrCert2 = \"../../certs/server-cert.pem\";\nconst char* const svrKey2  = \"../../certs/server-key.pem\";\n\nconst char* const svrCert3 = \"../../../certs/server-cert.pem\";\nconst char* const svrKey3  = \"../../../certs/server-key.pem\";\n\n\n// server dsa\nconst char* const dsaCert = \"../certs/dsa-cert.pem\";\nconst char* const dsaKey  = \"../certs/dsa1024.der\";\n\nconst char* const dsaCert2 = \"../../certs/dsa-cert.pem\";\nconst char* const dsaKey2  = \"../../certs/dsa1024.der\";\n\nconst char* const dsaCert3 = \"../../../certs/dsa-cert.pem\";\nconst char* const dsaKey3  = \"../../../certs/dsa1024.der\";\n\n\n// CA \nconst char* const caCert  = \"../certs/ca-cert.pem\";\nconst char* const caCert2 = \"../../certs/ca-cert.pem\";\nconst char* const caCert3 = \"../../../certs/ca-cert.pem\";\n\n\nusing namespace yaSSL;\n\n\ninline void err_sys(const char* msg)\n{\n    printf(\"yassl error: %s\\n\", msg);\n    exit(EXIT_FAILURE);\n}\n\n\nextern \"C\" {\n  static int PasswordCallBack(char*, int, int, void*);\n}\n\n\nstatic int PasswordCallBack(char* passwd, int sz, int rw, void* userdata)\n{\n    strncpy(passwd, \"yassl123\", sz);\n    return 8;\n}\n\n\ninline void store_ca(SSL_CTX* ctx)\n{\n    // To allow testing from serveral dirs\n    if (SSL_CTX_load_verify_locations(ctx, caCert, 0) != SSL_SUCCESS)\n        if (SSL_CTX_load_verify_locations(ctx, caCert2, 0) != SSL_SUCCESS)\n            if (SSL_CTX_load_verify_locations(ctx, caCert3, 0) != SSL_SUCCESS)\n                err_sys(\"failed to use certificate: certs/cacert.pem\");\n\n    // load client CA for server verify\n    if (SSL_CTX_load_verify_locations(ctx, cert, 0) != SSL_SUCCESS)\n        if (SSL_CTX_load_verify_locations(ctx, certSuite, 0) != SSL_SUCCESS)\n            if (SSL_CTX_load_verify_locations(ctx, certDebug,0) != SSL_SUCCESS)\n                err_sys(\"failed to use certificate: certs/client-cert.pem\");\n\n    // DSA cert \n    if (SSL_CTX_load_verify_locations(ctx, dsaCert, 0) != SSL_SUCCESS)\n        if (SSL_CTX_load_verify_locations(ctx, dsaCert2, 0) != SSL_SUCCESS)\n            if (SSL_CTX_load_verify_locations(ctx, dsaCert3, 0) != SSL_SUCCESS)\n                err_sys(\"failed to use certificate: certs/dsa-cert.pem\");\n\n}\n\n\n// client\ninline void set_certs(SSL_CTX* ctx)\n{\n    store_ca(ctx);\n    SSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);\n\n    // To allow testing from serveral dirs\n    if (SSL_CTX_use_certificate_file(ctx, cert, SSL_FILETYPE_PEM)\n        != SSL_SUCCESS)\n        if (SSL_CTX_use_certificate_file(ctx, certSuite, SSL_FILETYPE_PEM)\n            != SSL_SUCCESS)\n            if (SSL_CTX_use_certificate_file(ctx, certDebug, SSL_FILETYPE_PEM)\n                != SSL_SUCCESS)\n                err_sys(\"failed to use certificate: certs/client-cert.pem\");\n    \n    // To allow testing from several dirs\n    if (SSL_CTX_use_PrivateKey_file(ctx, key, SSL_FILETYPE_PEM)\n         != SSL_SUCCESS) \n         if (SSL_CTX_use_PrivateKey_file(ctx, keySuite, SSL_FILETYPE_PEM)\n            != SSL_SUCCESS) \n                if (SSL_CTX_use_PrivateKey_file(ctx,keyDebug,SSL_FILETYPE_PEM)\n                    != SSL_SUCCESS) \n                    err_sys(\"failed to use key file: certs/client-key.pem\");\n}\n\n\n// server\ninline void set_serverCerts(SSL_CTX* ctx)\n{\n    store_ca(ctx);\n    SSL_CTX_set_default_passwd_cb(ctx, PasswordCallBack);\n\n    // To allow testing from serveral dirs\n    if (SSL_CTX_use_certificate_file(ctx, svrCert, SSL_FILETYPE_PEM)\n        != SSL_SUCCESS)\n        if (SSL_CTX_use_certificate_file(ctx, svrCert2, SSL_FILETYPE_PEM)\n            != SSL_SUCCESS)\n            if (SSL_CTX_use_certificate_file(ctx, svrCert3, SSL_FILETYPE_PEM)\n                != SSL_SUCCESS)\n                err_sys(\"failed to use certificate: certs/server-cert.pem\");\n    \n    // To allow testing from several dirs\n    if (SSL_CTX_use_PrivateKey_file(ctx, svrKey, SSL_FILETYPE_PEM)\n         != SSL_SUCCESS) \n         if (SSL_CTX_use_PrivateKey_file(ctx, svrKey2, SSL_FILETYPE_PEM)\n            != SSL_SUCCESS) \n                if (SSL_CTX_use_PrivateKey_file(ctx, svrKey3,SSL_FILETYPE_PEM)\n                    != SSL_SUCCESS) \n                    err_sys(\"failed to use key file: certs/server-key.pem\");\n}\n\n\n// dsa server\ninline void set_dsaServerCerts(SSL_CTX* ctx)\n{\n    store_ca(ctx);\n\n    // To allow testing from serveral dirs\n    if (SSL_CTX_use_certificate_file(ctx, dsaCert, SSL_FILETYPE_PEM)\n        != SSL_SUCCESS)\n        if (SSL_CTX_use_certificate_file(ctx, dsaCert2, SSL_FILETYPE_PEM)\n            != SSL_SUCCESS)\n            if (SSL_CTX_use_certificate_file(ctx, dsaCert3, SSL_FILETYPE_PEM)\n                != SSL_SUCCESS)\n                err_sys(\"failed to use certificate: certs/dsa-cert.pem\");\n    \n    // To allow testing from several dirs\n    if (SSL_CTX_use_PrivateKey_file(ctx, dsaKey, SSL_FILETYPE_ASN1)\n         != SSL_SUCCESS) \n         if (SSL_CTX_use_PrivateKey_file(ctx, dsaKey2, SSL_FILETYPE_ASN1)\n            != SSL_SUCCESS) \n                if (SSL_CTX_use_PrivateKey_file(ctx, dsaKey3,SSL_FILETYPE_ASN1)\n                    != SSL_SUCCESS) \n                    err_sys(\"failed to use key file: certs/dsa1024.der\");\n}\n\n\ninline void set_args(int& argc, char**& argv, func_args& args)\n{\n    argc = args.argc;\n    argv = args.argv;\n    args.return_code = -1; // error state\n}\n\n\ninline void set_file_ready(const char* name, func_args& args)\n{\n    args.file_ready = name;\n}\n\n\ninline void tcp_set_nonblocking(SOCKET_T& sockfd)\n{\n#ifdef NON_BLOCKING\n    #ifdef _WIN32\n        unsigned long blocking = 1;\n        int ret = ioctlsocket(sockfd, FIONBIO, &blocking);\n    #else\n        int flags = fcntl(sockfd, F_GETFL, 0);\n        int ret = fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);\n    #endif\n#endif\n}\n\n\ninline void tcp_socket(SOCKET_T& sockfd, SOCKADDR_IN_T& addr)\n{\n    sockfd = socket(AF_INET_V, SOCK_STREAM, 0);\n    memset(&addr, 0, sizeof(addr));\n\n#ifdef TEST_IPV6\n    addr.sin6_family = AF_INET_V;\n    addr.sin6_port = htons(yasslPort);\n    addr.sin6_addr = in6addr_loopback;\n\n    /* // for external testing later \n    addrinfo hints;\n    memset(&hints, 0, sizeof(hints));\n    hints.ai_family   = AF_INET_V;\n    hints.ai_socktype = SOCK_STREAM;\n    hints.ai_flags    = AI_PASSIVE;\n\n    getaddrinfo(yasslIP6, yasslPortStr, &hints, info);\n    // then use info connect(sockfd, info->ai_addr, info->ai_addrlen)\n\n    if (*info == 0)\n        err_sys(\"getaddrinfo failed\");\n        */   // end external testing later\n#else\n    addr.sin_family = AF_INET_V;\n#ifdef YASSL_PROXY_PORT\n    addr.sin_port = htons(proxyPort);\n#else\n    addr.sin_port = htons(yasslPort);\n#endif\n    addr.sin_addr.s_addr = inet_addr(yasslIP);\n#endif\n\n}\n\n\ninline void tcp_close(SOCKET_T& sockfd)\n{\n#ifdef _WIN32\n    closesocket(sockfd);\n#else\n    close(sockfd);\n#endif\n    sockfd = (SOCKET_T) -1;\n}\n\n\ninline void tcp_connect(SOCKET_T& sockfd)\n{\n    SOCKADDR_IN_T addr;\n    tcp_socket(sockfd, addr);\n\n    if (connect(sockfd, (const sockaddr*)&addr, sizeof(addr)) != 0) {\n        tcp_close(sockfd);\n        err_sys(\"tcp connect failed\");\n    }\n}\n\n\ninline void tcp_listen(SOCKET_T& sockfd)\n{\n    SOCKADDR_IN_T addr;\n    tcp_socket(sockfd, addr);\n\n#ifndef _WIN32\n    int       on  = 1;\n    socklen_t len = sizeof(on);\n    setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &on, len);\n#endif\n\n    if (bind(sockfd, (const sockaddr*)&addr, sizeof(addr)) != 0) {\n        tcp_close(sockfd);\n        err_sys(\"tcp bind failed\");\n    }\n    if (listen(sockfd, 3) != 0) {\n        tcp_close(sockfd);\n        err_sys(\"tcp listen failed\");\n    }\n}\n\n\ninline void create_ready_file(func_args& args)\n{\n    FILE* f = fopen(args.file_ready, \"w+\");\n\n    if (f) {\n        fputs(\"ready\", f);\n        fclose(f);\n    }\n}\n\n\ninline void tcp_accept(SOCKET_T& sockfd, SOCKET_T& clientfd, func_args& args)\n{\n    tcp_listen(sockfd);\n\n    SOCKADDR_IN_T client;\n    socklen_t client_len = sizeof(client);\n\n#if defined(_POSIX_THREADS) && defined(NO_MAIN_DRIVER)\n    // signal ready to tcp_accept\n    tcp_ready& ready = *args.signal_;\n    pthread_mutex_lock(&ready.mutex_);\n    ready.ready_ = true;\n    pthread_cond_signal(&ready.cond_);\n    pthread_mutex_unlock(&ready.mutex_);\n#endif\n\n    if (args.file_ready)\n        create_ready_file(args);\n\n    clientfd = accept(sockfd, (sockaddr*)&client, (ACCEPT_THIRD_T)&client_len);\n\n    if (clientfd == (SOCKET_T) -1) {\n        tcp_close(sockfd);\n        err_sys(\"tcp accept failed\");\n    }\n\n#ifdef NON_BLOCKING\n    tcp_set_nonblocking(clientfd);\n#endif\n}\n\n\ninline void showPeer(SSL* ssl)\n{\n    X509* peer = SSL_get_peer_certificate(ssl);\n    if (peer) {\n        char* issuer  = X509_NAME_oneline(X509_get_issuer_name(peer), 0, 0);\n        char* subject = X509_NAME_oneline(X509_get_subject_name(peer), 0, 0);\n\n        printf(\"peer's cert info:\\n issuer : %s\\n subject: %s\\n\", issuer,\n                                                                  subject);\n        free(subject);\n        free(issuer);\n    }\n    else\n        printf(\"peer has no cert!\\n\");\n}\n\n\n\ninline DH* set_tmpDH(SSL_CTX* ctx)\n{\n    static unsigned char dh1024_p[] =\n    {\n        0xE6, 0x96, 0x9D, 0x3D, 0x49, 0x5B, 0xE3, 0x2C, 0x7C, 0xF1, 0x80, 0xC3,\n        0xBD, 0xD4, 0x79, 0x8E, 0x91, 0xB7, 0x81, 0x82, 0x51, 0xBB, 0x05, 0x5E,\n        0x2A, 0x20, 0x64, 0x90, 0x4A, 0x79, 0xA7, 0x70, 0xFA, 0x15, 0xA2, 0x59,\n        0xCB, 0xD5, 0x23, 0xA6, 0xA6, 0xEF, 0x09, 0xC4, 0x30, 0x48, 0xD5, 0xA2,\n        0x2F, 0x97, 0x1F, 0x3C, 0x20, 0x12, 0x9B, 0x48, 0x00, 0x0E, 0x6E, 0xDD,\n        0x06, 0x1C, 0xBC, 0x05, 0x3E, 0x37, 0x1D, 0x79, 0x4E, 0x53, 0x27, 0xDF,\n        0x61, 0x1E, 0xBB, 0xBE, 0x1B, 0xAC, 0x9B, 0x5C, 0x60, 0x44, 0xCF, 0x02,\n        0x3D, 0x76, 0xE0, 0x5E, 0xEA, 0x9B, 0xAD, 0x99, 0x1B, 0x13, 0xA6, 0x3C,\n        0x97, 0x4E, 0x9E, 0xF1, 0x83, 0x9E, 0xB5, 0xDB, 0x12, 0x51, 0x36, 0xF7,\n        0x26, 0x2E, 0x56, 0xA8, 0x87, 0x15, 0x38, 0xDF, 0xD8, 0x23, 0xC6, 0x50,\n        0x50, 0x85, 0xE2, 0x1F, 0x0D, 0xD5, 0xC8, 0x6B,\n    };\n\n    static unsigned char dh1024_g[] =\n    {\n      0x02,\n    };\n\n    DH* dh;\n    if ( (dh = DH_new()) ) {\n        dh->p = BN_bin2bn(dh1024_p, sizeof(dh1024_p), 0);\n        dh->g = BN_bin2bn(dh1024_g, sizeof(dh1024_g), 0);\n    }\n    if (!dh->p || !dh->g) {\n        DH_free(dh);\n        dh = 0;\n    }\n    SSL_CTX_set_tmp_dh(ctx, dh);\n    return dh;\n}\n\n\ninline int verify_callback(int preverify_ok, X509_STORE_CTX* ctx)\n{\n    X509* err_cert = X509_STORE_CTX_get_current_cert(ctx);\n    int   err      = X509_STORE_CTX_get_error(ctx);\n    int   depth    = X509_STORE_CTX_get_error_depth(ctx);\n\n    // test allow self signed\n    if (err_cert && depth == 0 && err == TaoCrypt::SIG_OTHER_E)\n        return 1;\n\n    return 0;\n}\n\n\n#endif // yaSSL_TEST_HPP\n\n"
  },
  {
    "path": "ext/yassl/testsuite/testsuite.cpp",
    "content": "/*\n   Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; see the file COPYING. If not, write to the\n   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,\n   MA  02110-1301  USA.\n*/\n\n// testsuite.cpp\n\n#include \"test.hpp\"\n#include \"md5.hpp\"\n\n\ntypedef unsigned char byte;\n\nvoid taocrypt_test(void*);\nvoid file_test(const char*, byte*);\n\nvoid client_test(void*);\nvoid echoclient_test(void*);\n\nTHREAD_RETURN YASSL_API server_test(void*);\nTHREAD_RETURN YASSL_API echoserver_test(void*);\n\nvoid wait_tcp_ready(func_args&);\n\n\n\nint main(int argc, char** argv)\n{\n    func_args args(argc, argv);\n    func_args server_args(argc, argv);\n\n    // *** Crypto Test ***\n    taocrypt_test(&args);\n    assert(args.return_code == 0);\n    \n    \n    // *** Simple yaSSL client server test ***\n    tcp_ready ready;\n    server_args.SetSignal(&ready);\n\n    THREAD_TYPE serverThread;\n    start_thread(server_test, &server_args, &serverThread);\n    wait_tcp_ready(server_args);\n\n    client_test(&args);\n    assert(args.return_code == 0);\n    join_thread(serverThread);\n    assert(server_args.return_code == 0);\n    \n\n    // *** Echo input yaSSL client server test ***\n    start_thread(echoserver_test, &server_args, &serverThread);\n    wait_tcp_ready(server_args);\n    func_args echo_args;\n\n            // setup args\n    const int numArgs = 3;\n    echo_args.argc = numArgs;\n    char* myArgv[numArgs];\n\n    char argc0[32];\n    char argc1[32];\n    char argc2[32];\n\n    myArgv[0] = argc0;\n    myArgv[1] = argc1;\n    myArgv[2] = argc2;\n\n    echo_args.argv = myArgv;\n   \n    strcpy(echo_args.argv[0], \"echoclient\");\n    strcpy(echo_args.argv[1], \"input\");\n    strcpy(echo_args.argv[2], \"output\");\n    remove(\"output\");\n\n            // make sure OK\n    echoclient_test(&echo_args);\n    assert(echo_args.return_code == 0);\n\n\n    // *** Echo quit yaSSL client server test ***\n    echo_args.argc = 2;\n    strcpy(echo_args.argv[1], \"quit\");\n\n    echoclient_test(&echo_args);\n    assert(echo_args.return_code == 0);\n    join_thread(serverThread);\n    assert(server_args.return_code == 0);\n\n\n            // input output compare\n    byte input[TaoCrypt::MD5::DIGEST_SIZE];\n    byte output[TaoCrypt::MD5::DIGEST_SIZE];\n    file_test(\"input\", input);\n    file_test(\"output\", output);\n    assert(memcmp(input, output, sizeof(input)) == 0);\n\n    printf(\"\\nAll tests passed!\\n\");\n    yaSSL_CleanUp();\n\n    return 0;\n}\n\n\n\nvoid start_thread(THREAD_FUNC fun, func_args* args, THREAD_TYPE* thread)\n{\n#ifndef _POSIX_THREADS\n    *thread = (HANDLE)_beginthreadex(0, 0, fun, args, 0, 0);\n#else\n    pthread_create(thread, 0, fun, args);\n#endif\n}\n\n\nvoid join_thread(THREAD_TYPE thread)\n{\n#ifndef _POSIX_THREADS\n    int res = WaitForSingleObject(thread, INFINITE);\n    assert(res == WAIT_OBJECT_0);\n    res = CloseHandle(thread);\n    assert(res);\n#else\n    pthread_join(thread, 0);\n#endif\n}\n\n\n\nvoid wait_tcp_ready(func_args& args)\n{\n#ifdef _POSIX_THREADS\n    pthread_mutex_lock(&args.signal_->mutex_);\n    \n    if (!args.signal_->ready_)\n        pthread_cond_wait(&args.signal_->cond_, &args.signal_->mutex_);\n    args.signal_->ready_ = false; // reset\n\n    pthread_mutex_unlock(&args.signal_->mutex_);\n#endif\n}\n\n\nint test_openSSL_des()\n{\n    /* test des encrypt/decrypt */\n    char data[] = \"this is my data \";\n    int  dataSz = (int)strlen(data);\n    DES_key_schedule key[3];\n    byte iv[8];\n    EVP_BytesToKey(EVP_des_ede3_cbc(), EVP_md5(), NULL, (byte*)data, dataSz, 1,\n                   (byte*)key, iv);\n\n    byte cipher[16];\n    DES_ede3_cbc_encrypt((byte*)data, cipher, dataSz, &key[0], &key[1],\n                         &key[2], &iv, true);\n    byte plain[16];\n    DES_ede3_cbc_encrypt(cipher, plain, 16, &key[0], &key[1], &key[2],\n                         &iv, false);\n    return 0;\n}\n"
  },
  {
    "path": "ext/yassl/testsuite/testsuite.dsp",
    "content": "# Microsoft Developer Studio Project File - Name=\"testsuite\" - Package Owner=<4>\n# Microsoft Developer Studio Generated Build File, Format Version 6.00\n# ** DO NOT EDIT **\n\n# TARGTYPE \"Win32 (x86) Console Application\" 0x0103\n\nCFG=testsuite - Win32 Debug\n!MESSAGE This is not a valid makefile. To build this project using NMAKE,\n!MESSAGE use the Export Makefile command and run\n!MESSAGE \n!MESSAGE NMAKE /f \"testsuite.mak\".\n!MESSAGE \n!MESSAGE You can specify a configuration when running NMAKE\n!MESSAGE by defining the macro CFG on the command line. For example:\n!MESSAGE \n!MESSAGE NMAKE /f \"testsuite.mak\" CFG=\"testsuite - Win32 Debug\"\n!MESSAGE \n!MESSAGE Possible choices for configuration are:\n!MESSAGE \n!MESSAGE \"testsuite - Win32 Release\" (based on \"Win32 (x86) Console Application\")\n!MESSAGE \"testsuite - Win32 Debug\" (based on \"Win32 (x86) Console Application\")\n!MESSAGE \n\n# Begin Project\n# PROP AllowPerConfigDependencies 0\n# PROP Scc_ProjName \"\"\n# PROP Scc_LocalPath \"\"\nCPP=cl.exe\nRSC=rc.exe\n\n!IF  \"$(CFG)\" == \"testsuite - Win32 Release\"\n\n# PROP BASE Use_MFC 0\n# PROP BASE Use_Debug_Libraries 0\n# PROP BASE Output_Dir \"Release\"\n# PROP BASE Intermediate_Dir \"Release\"\n# PROP BASE Target_Dir \"\"\n# PROP Use_MFC 0\n# PROP Use_Debug_Libraries 0\n# PROP Output_Dir \"Release\"\n# PROP Intermediate_Dir \"Release\"\n# PROP Ignore_Export_Lib 0\n# PROP Target_Dir \"\"\n# ADD BASE CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /c\n# ADD CPP /nologo /MT /W3 /O2 /I \"../taocrypt/include\" /I \"../include\" /I \"../taocrypt/mySTL\" /D \"NDEBUG\" /D \"WIN32\" /D \"_CONSOLE\" /D \"_MBCS\" /D \"NO_MAIN_DRIVER\" /YX /FD /c\n# ADD BASE RSC /l 0x409 /d \"NDEBUG\"\n# ADD RSC /l 0x409 /d \"NDEBUG\"\nBSC32=bscmake.exe\n# ADD BASE BSC32 /nologo\n# ADD BSC32 /nologo\nLINK32=link.exe\n# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\n# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:\"LIBC\"\n# SUBTRACT LINK32 /nodefaultlib\n\n!ELSEIF  \"$(CFG)\" == \"testsuite - Win32 Debug\"\n\n# PROP BASE Use_MFC 0\n# PROP BASE Use_Debug_Libraries 1\n# PROP BASE Output_Dir \"Debug\"\n# PROP BASE Intermediate_Dir \"Debug\"\n# PROP BASE Target_Dir \"\"\n# PROP Use_MFC 0\n# PROP Use_Debug_Libraries 1\n# PROP Output_Dir \"Debug\"\n# PROP Intermediate_Dir \"Debug\"\n# PROP Ignore_Export_Lib 0\n# PROP Target_Dir \"\"\n# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_CONSOLE\" /D \"_MBCS\" /YX /FD /GZ /c\n# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I \"../taocrypt/include\" /I \"../include\" /I \"../taocrypt/mySTL\" /D \"_DEBUG\" /D \"WIN32\" /D \"_CONSOLE\" /D \"_MBCS\" /D \"NO_MAIN_DRIVER\" /FR /YX /FD /GZ /c\n# ADD BASE RSC /l 0x409 /d \"_DEBUG\"\n# ADD RSC /l 0x409 /d \"_DEBUG\"\nBSC32=bscmake.exe\n# ADD BASE BSC32 /nologo\n# ADD BSC32 /nologo\nLINK32=link.exe\n# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\n# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:\"LIBCD\" /pdbtype:sept\n\n!ENDIF \n\n# Begin Target\n\n# Name \"testsuite - Win32 Release\"\n# Name \"testsuite - Win32 Debug\"\n# Begin Group \"Source Files\"\n\n# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\n# Begin Source File\n\nSOURCE=..\\examples\\client\\client.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=..\\examples\\echoclient\\echoclient.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=..\\examples\\echoserver\\echoserver.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=..\\examples\\server\\server.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=..\\taocrypt\\test\\test.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\testsuite.cpp\n# End Source File\n# End Group\n# Begin Group \"Header Files\"\n\n# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\n# Begin Source File\n\nSOURCE=.\\test.hpp\n# End Source File\n# End Group\n# Begin Group \"Resource Files\"\n\n# PROP Default_Filter \"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\"\n# End Group\n# End Target\n# End Project\n"
  },
  {
    "path": "ext/yassl/yassl.dsp",
    "content": "# Microsoft Developer Studio Project File - Name=\"yassl\" - Package Owner=<4>\n# Microsoft Developer Studio Generated Build File, Format Version 6.00\n# ** DO NOT EDIT **\n\n# TARGTYPE \"Win32 (x86) Static Library\" 0x0104\n\nCFG=yassl - Win32 Debug\n!MESSAGE This is not a valid makefile. To build this project using NMAKE,\n!MESSAGE use the Export Makefile command and run\n!MESSAGE \n!MESSAGE NMAKE /f \"yassl.mak\".\n!MESSAGE \n!MESSAGE You can specify a configuration when running NMAKE\n!MESSAGE by defining the macro CFG on the command line. For example:\n!MESSAGE \n!MESSAGE NMAKE /f \"yassl.mak\" CFG=\"yassl - Win32 Debug\"\n!MESSAGE \n!MESSAGE Possible choices for configuration are:\n!MESSAGE \n!MESSAGE \"yassl - Win32 Release\" (based on \"Win32 (x86) Static Library\")\n!MESSAGE \"yassl - Win32 Debug\" (based on \"Win32 (x86) Static Library\")\n!MESSAGE \n\n# Begin Project\n# PROP AllowPerConfigDependencies 0\n# PROP Scc_ProjName \"\"\n# PROP Scc_LocalPath \"\"\nCPP=cl.exe\nRSC=rc.exe\n\n!IF  \"$(CFG)\" == \"yassl - Win32 Release\"\n\n# PROP BASE Use_MFC 0\n# PROP BASE Use_Debug_Libraries 0\n# PROP BASE Output_Dir \"Release\"\n# PROP BASE Intermediate_Dir \"Release\"\n# PROP BASE Target_Dir \"\"\n# PROP Use_MFC 0\n# PROP Use_Debug_Libraries 0\n# PROP Output_Dir \"Release\"\n# PROP Intermediate_Dir \"Release\"\n# PROP Target_Dir \"\"\n# ADD BASE CPP /nologo /W3 /GX /O2 /D \"WIN32\" /D \"NDEBUG\" /D \"_MBCS\" /D \"_LIB\" /D \"YASSL_PREFIX\" /YX /FD /c\n# ADD CPP /nologo /MT /W3 /O2 /I \"include\" /I \"taocrypt\\include\" /I \"taocrypt\\mySTL\" /D \"WIN32\" /D \"NDEBUG\" /D \"_MBCS\" /D \"_LIB\" /D \"YASSL_PREFIX\" /YX /FD /c\n# ADD BASE RSC /l 0x409 /d \"NDEBUG\"\n# ADD RSC /l 0x409 /d \"NDEBUG\"\nBSC32=bscmake.exe\n# ADD BASE BSC32 /nologo\n# ADD BSC32 /nologo\nLIB32=link.exe -lib\n# ADD BASE LIB32 /nologo\n# ADD LIB32 /nologo\n\n!ELSEIF  \"$(CFG)\" == \"yassl - Win32 Debug\"\n\n# PROP BASE Use_MFC 0\n# PROP BASE Use_Debug_Libraries 1\n# PROP BASE Output_Dir \"Debug\"\n# PROP BASE Intermediate_Dir \"Debug\"\n# PROP BASE Target_Dir \"\"\n# PROP Use_MFC 0\n# PROP Use_Debug_Libraries 1\n# PROP Output_Dir \"Debug\"\n# PROP Intermediate_Dir \"Debug\"\n# PROP Target_Dir \"\"\n# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D \"WIN32\" /D \"_DEBUG\" /D \"_MBCS\" /D \"_LIB\" /D \"YASSL_PREFIX\" /YX /FD /GZ /c\n# ADD CPP /nologo /MTd /W3 /Gm /ZI /Od /I \"include\" /I \"taocrypt\\include\" /I \"taocrypt\\mySTL\" /D \"WIN32\" /D \"_DEBUG\" /D \"_MBCS\" /D \"_LIB\" /D \"YASSL_PREFIX\" /FR /YX /FD /GZ /c\n# ADD BASE RSC /l 0x409 /d \"_DEBUG\"\n# ADD RSC /l 0x409 /d \"_DEBUG\"\nBSC32=bscmake.exe\n# ADD BASE BSC32 /nologo\n# ADD BSC32 /nologo\nLIB32=link.exe -lib\n# ADD BASE LIB32 /nologo\n# ADD LIB32 /nologo\n\n!ENDIF \n\n# Begin Target\n\n# Name \"yassl - Win32 Release\"\n# Name \"yassl - Win32 Debug\"\n# Begin Group \"Source Files\"\n\n# PROP Default_Filter \"cpp;c;cxx;rc;def;r;odl;idl;hpj;bat\"\n# Begin Source File\n\nSOURCE=.\\src\\buffer.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\cert_wrapper.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\crypto_wrapper.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\handshake.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\lock.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\log.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\socket_wrapper.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\ssl.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\timer.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\yassl_error.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\yassl_imp.cpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\src\\yassl_int.cpp\n# End Source File\n# End Group\n# Begin Group \"Header Files\"\n\n# PROP Default_Filter \"h;hpp;hxx;hm;inl\"\n# Begin Source File\n\nSOURCE=.\\include\\buffer.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\cert_wrapper.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\crypto_wrapper.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\factory.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\handshake.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\lock.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\log.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\socket_wrapper.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\timer.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\yassl_error.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\yassl_imp.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\yassl_int.hpp\n# End Source File\n# Begin Source File\n\nSOURCE=.\\include\\yassl_types.hpp\n# End Source File\n# End Group\n# End Target\n# End Project\n"
  },
  {
    "path": "ext/yassl/yassl.dsw",
    "content": "Microsoft Developer Studio Workspace File, Format Version 6.00\n# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\n\n###############################################################################\n\nProject: \"benchmark\"=.\\taocrypt\\benchmark\\benchmark.dsp - Package Owner=<4>\n\nPackage=<5>\n{{{\n}}}\n\nPackage=<4>\n{{{\n    Begin Project Dependency\n    Project_Dep_Name taocrypt\n    End Project Dependency\n}}}\n\n###############################################################################\n\nProject: \"client\"=.\\examples\\client\\client.dsp - Package Owner=<4>\n\nPackage=<5>\n{{{\n}}}\n\nPackage=<4>\n{{{\n    Begin Project Dependency\n    Project_Dep_Name yassl\n    End Project Dependency\n}}}\n\n###############################################################################\n\nProject: \"echoclient\"=.\\examples\\echoclient\\echoclient.dsp - Package Owner=<4>\n\nPackage=<5>\n{{{\n}}}\n\nPackage=<4>\n{{{\n    Begin Project Dependency\n    Project_Dep_Name yassl\n    End Project Dependency\n}}}\n\n###############################################################################\n\nProject: \"echoserver\"=.\\examples\\echoserver\\echoserver.dsp - Package Owner=<4>\n\nPackage=<5>\n{{{\n}}}\n\nPackage=<4>\n{{{\n    Begin Project Dependency\n    Project_Dep_Name yassl\n    End Project Dependency\n}}}\n\n###############################################################################\n\nProject: \"server\"=.\\examples\\server\\server.dsp - Package Owner=<4>\n\nPackage=<5>\n{{{\n}}}\n\nPackage=<4>\n{{{\n    Begin Project Dependency\n    Project_Dep_Name yassl\n    End Project Dependency\n}}}\n\n###############################################################################\n\nProject: \"taocrypt\"=.\\taocrypt\\taocrypt.dsp - Package Owner=<4>\n\nPackage=<5>\n{{{\n}}}\n\nPackage=<4>\n{{{\n}}}\n\n###############################################################################\n\nProject: \"test\"=.\\taocrypt\\test\\test.dsp - Package Owner=<4>\n\nPackage=<5>\n{{{\n}}}\n\nPackage=<4>\n{{{\n    Begin Project Dependency\n    Project_Dep_Name taocrypt\n    End Project Dependency\n}}}\n\n###############################################################################\n\nProject: \"testsuite\"=.\\testsuite\\testsuite.dsp - Package Owner=<4>\n\nPackage=<5>\n{{{\n}}}\n\nPackage=<4>\n{{{\n    Begin Project Dependency\n    Project_Dep_Name yassl\n    End Project Dependency\n}}}\n\n###############################################################################\n\nProject: \"yassl\"=.\\yassl.dsp - Package Owner=<4>\n\nPackage=<5>\n{{{\n}}}\n\nPackage=<4>\n{{{\n    Begin Project Dependency\n    Project_Dep_Name taocrypt\n    End Project Dependency\n}}}\n\n###############################################################################\n\nGlobal:\n\nPackage=<5>\n{{{\n}}}\n\nPackage=<3>\n{{{\n}}}\n\n###############################################################################\n\n"
  },
  {
    "path": "packaging/README_Debian.md",
    "content": "\nPackaging for Debian and Ubuntu\n===============================\n\nEach Debian-based Linux distribution has its own packaging folder prefixed\nwith `deb-`. The code name for each Debian or Ubuntu distribution\nis used instead of the version number. At the time of writing (Sep 2015)\nthe following are supported:\n\n  deb-jessie  Debian 8\n  deb-trusty  Ubuntu 14.04\n  deb-vivid   Ubuntu 15.04\n  deb-wily    Ubuntu 15.10\n\nCombining common and per distribution folders\n---------------------------------------------\n\nThe folder `deb-common` holds files which are identical for each Debian\nor Ubuntu distribution. To get the full directory for packaging both the\ncommon and the per distribution folder has to be copied. For example,\nto create the packaging folder for Ubuntu 15.04 (vivid) we do the\nfollowing:\n\n  $ cp -a deb-common debian\n  $ cp -a deb-vivid/* debian/\n\nThe folder `debian` will contain all necessary files to create the package\nfor Ubuntu 15.04.\n\nNote that the `deb-common` does not contain files such as `changelog`,\n`control`, or `rules`. There are also no placeholders to prevent the\n`deb-common` to be used and potentially create incorrect packages.\n\nCreating packages\n-----------------\n\nThe `build_deb.sh` can be used to automate the process creating Debian\npackages. It will copy the necessary files, build the packages, and\nwrite a log file which can be used to debug.\n\nExample usage of `bulid_deb.sh`, when inside source of MySQL Router:\n\n    $ mkdir build\n    $ cd build\n    $ cmake ..\n    $ make package_source\n    $ sh ../packaging/build_deb.sh mysql-router-2.0.2.tar.gz\n\nThe log file will be available inside the `DebianBuild` folder:\n\n    DebianBuild/debuild.log\n\nWhen done, the `build_deb.sh` will show the packages which were build:\n\n    Debian packages:\n    mysql-router_2.0.2-1ubuntu14.04_amd64.deb\n    mysql-router-dev_2.0.2-1ubuntu14.04_amd64.deb\n\nInstallation Layout\n-------------------\n\nThe following tree shows the installation layout of MySQL Router on\nDebian-based 64-bit distributions.\n\n    ├── etc\n    │   ├── init.d\n    │   │   └── mysqlrouter\n    │   └── mysql\n    │       └── mysqlrouter.conf\n    └── usr\n        ├── lib\n        │   └── x86_64-linux-gnu\n        │       ├── libmysqlharness.so.0\n        │       ├── libmysqlrouter.so.0\n        │       └── mysqlrouter\n        │           ├── metadata_cache.so\n        │           ├── keepalive.so\n        │           └── routing.so\n        ├── bin\n        │   └── mysqlrouter\n        └── share\n            ├── doc\n            │   └── mysql-router\n            │       ├── changelog.Debian.gz\n            │       ├── copyright\n            │       ├── sample_mysqlrouter.conf\n            │       ├── License.txt.gz\n            │       └── README.txt\n            └── lintian\n                └── overrides\n                    └── mysql-router\n\n"
  },
  {
    "path": "packaging/WiX/CMakeLists.txt",
    "content": "# Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nIF(NOT WIN32)\n  RETURN()\nENDIF()\n\nFIND_PATH(WIX_DIR NAMES heat.exe)\n\nIF(NOT WIX_DIR)\n  IF(NOT _WIX_DIR_CHECKED)\n    SET(_WIX_DIR_CHECKED 1 CACHE INTERNAL \"\")\n    MESSAGE(WARNING \"Cannot find wix 3, installer project will not be generated\")\n  ENDIF()\n  RETURN()\nENDIF()\n\nADD_SUBDIRECTORY(ca)\n\nFIND_PROGRAM(HEAT_EXECUTABLE heat ${WIX_DIR})\nFIND_PROGRAM(CANDLE_EXECUTABLE candle ${WIX_DIR})\nFIND_PROGRAM(LIGHT_EXECUTABLE light ${WIX_DIR})\n\n# WiX wants the license text as rtf; if there is no rtf license,\n# we create a fake one from the plain text COPYING file.\nIF(EXISTS \"${CMAKE_CURRENT_SOURCE_DIR}/COPYING.rtf\")\n SET(COPYING_RTF \"${CMAKE_CURRENT_SOURCE_DIR}/COPYING.rtf\")\nELSE()\n  IF(EXISTS \"${CMAKE_CURRENT_SOURCE_DIR}/../../LICENSE.mysql\")\n    SET(LICENSE_FILE \"${CMAKE_CURRENT_SOURCE_DIR}/../../LICENSE.mysql\")\n  ELSE()\n    SET(LICENSE_FILE \"${CMAKE_CURRENT_SOURCE_DIR}/../../License.txt\")\n  ENDIF()\n  FILE(READ ${LICENSE_FILE} CONTENTS)\n  STRING(REGEX REPLACE \"\\n\" \"\\\\\\\\par\\n\" CONTENTS \"${CONTENTS}\")\n  STRING(REGEX REPLACE \"\\t\" \"\\\\\\\\tab\" CONTENTS \"${CONTENTS}\")\n  FILE(WRITE \"${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf\" \"{\\\\rtf1\\\\ansi\\\\deff0{\\\\fonttbl{\\\\f0\\\\fnil\\\\fcharset0 Courier New;}}\\\\viewkind4\\\\uc1\\\\pard\\\\lang1031\\\\f0\\\\fs15\")\n  FILE(APPEND \"${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf\" \"${CONTENTS}\")\n  FILE(APPEND \"${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf\" \"\\n}\\n\")\n  SET(COPYING_RTF \"${CMAKE_CURRENT_BINARY_DIR}/COPYING.rtf\")\nENDIF()\nSET(CPACK_WIX_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/CPackWixConfig.cmake)\nSET(CPACK_WIX_INCLUDE \"${CMAKE_CURRENT_BINARY_DIR}/mysql_router_extra.wxs;${CMAKE_CURRENT_SOURCE_DIR}/custom_ui.wxs\")\n\nIF(CMAKE_SIZEOF_VOID_P EQUAL 8)\n  SET(WixWin64 \" Win64='yes'\")\nELSE()\n  SET(WixWin64 \" Win64='no'\")\nENDIF()\n\nif(NOT CMAKE_CFG_INTDIR STREQUAL \".\")\n  foreach(conf ${CMAKE_CONFIGURATION_TYPES})\n    CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysqlrouter.conf.in  ${PROJECT_BINARY_DIR}/stage/${conf}/etc/mysqlrouter.conf.sample)\n  endforeach()\nelse()\n  CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysqlrouter.conf.in  ${PROJECT_BINARY_DIR}/stage/etc/mysqlrouter.conf.sample)\nendif()\n\nCONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql_router_extra.wxs.in\n  ${CMAKE_CURRENT_BINARY_DIR}/mysql_router_extra.wxs)\n\n## configure_file doesn't support generator expressions\nSET(WIXCA_LOCATION \"$<TARGET_FILE:wixca>\")\n\nif(NOT CMAKE_CFG_INTDIR STREQUAL \".\")\n  FILE(READ \"${CMAKE_CURRENT_SOURCE_DIR}/create_msi.cmake.in\" TMPL_CONTENT)\n  STRING(CONFIGURE \"${TMPL_CONTENT}\" GEN_CONTENT @ONLY)\n  FILE(GENERATE OUTPUT \"${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/create_msi.cmake\"\n    CONTENT \"${GEN_CONTENT}\")\nelse()\n  FILE(READ \"${CMAKE_CURRENT_SOURCE_DIR}/create_msi.cmake.in\" TMPL_CONTENT)\n  STRING(CONFIGURE \"${TMPL_CONTENT}\" GEN_CONTENT @ONLY)\n  FILE(GENERATE OUTPUT \"${CMAKE_CURRENT_BINARY_DIR}/create_msi.cmake\"\n    CONTENT \"${GEN_CONTENT}\")\nendif()\n\n\nif(NOT CMAKE_CFG_INTDIR STREQUAL \".\")\n SET(CONFIG_PARAM \"-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_CFG_INTDIR}\")\nENDIF()\n\n\nADD_CUSTOM_TARGET(\n  MSI\n  COMMAND set VS_UNICODE_OUTPUT=\n  COMMAND ${CMAKE_COMMAND}\n  ${CONFIG_PARAM}\n  -P  ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/create_msi.cmake\n)\nADD_DEPENDENCIES(MSI wixca)\n"
  },
  {
    "path": "packaging/WiX/CPackWixConfig.cmake",
    "content": "# Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA\n\n# NOTE: grep these for CPACK_COMPONENT, rest of the name is dynamically generated\n\nSET(CPACK_COMPONENTS_USED\n    \"Router\")\n\n# Always install (hidden), includes Readme files\nSET(CPACK_COMPONENT_GROUP_ALWAYSINSTALL_HIDDEN 1)\nSET(CPACK_COMPONENT_README_GROUP \"AlwaysInstall\")\n\n# Feature MySQL Router\nSET(CPACK_COMPONENT_MYSQLROUTER_DISPLAY_NAME \"MySQL Router\")\nSET(CPACK_COMPONENT_MYSQLROUTER_DESCRIPTION \"Install MySQL Router\")\n"
  },
  {
    "path": "packaging/WiX/ca/CMakeLists.txt",
    "content": "# Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nIF(CMAKE_SIZEOF_VOID_P EQUAL 8)\n  SET(WIX_ARCH \"x64\")\nELSE()\n  SET(WIX_ARCH \"x86\")\nENDIF()\n\nIF(MSVC_VERSION GREATER 1909 AND MSVC_VERSION LESS 1920)\n  SET(WIX_MSVC_DIR \"VS2017\")\nELSEIF(MSVC_VERSION EQUAL 1900)\n  SET(WIX_MSVC_DIR \"VS2015\")\nELSEIF(MSVC_VERSION EQUAL 1800)\n  SET(WIX_MSVC_DIR \"VS2013\")\nELSEIF(MSVC_VERSION EQUAL 1600)\n  SET(WIX_MSVC_DIR \"VS2010\")\nELSE()\n  # When next VS is out, add the correct version here\n  MESSAGE(FATAL_ERROR \"Unknown VS version: ${MSVC_VERSION}\")\nENDIF()\n\n\n# Installed directory layout\nIF(IS_DIRECTORY \"${WIX_DIR}/../SDK/${WIX_MSVC_DIR}\")\n  SET(WIX_MSVC_DIR \"${WIX_DIR}/../SDK/${WIX_MSVC_DIR}\")\n  INCLUDE_DIRECTORIES(${WIX_MSVC_DIR}/inc)\n# Unzipped directory layout\nELSEIF(IS_DIRECTORY \"${WIX_DIR}/SDK/${WIX_MSVC_DIR}\")\n  SET(WIX_MSVC_DIR \"${WIX_DIR}/SDK/${WIX_MSVC_DIR}\")\n  INCLUDE_DIRECTORIES(${WIX_DIR}/SDK/inc)\nELSE()\n  MESSAGE(FATAL_ERROR \"Cannot find ${WIX_MSVC_DIR} directory\")\nENDIF()\n\nLINK_DIRECTORIES(${WIX_MSVC_DIR}/lib/${WIX_ARCH})\n\nSET(WIXCA_SOURCES CustomAction.cpp CustomAction.def\n  \"${CMAKE_SOURCE_DIR}/src/router/src/windows/nt_servc.cc\" )\n\nINCLUDE_DIRECTORIES(\"${CMAKE_SOURCE_DIR}/src/router/src/windows\")\n\nMESSAGE(STATUS \"Searching for wcautil in ${WIX_MSVC_DIR}/lib/${WIX_ARCH}\")\nMESSAGE(STATUS \"Searching for dutil in ${WIX_MSVC_DIR}/lib/${WIX_ARCH}\")\n\nFIND_LIBRARY(WIX_WCAUTIL_LIBRARY \n  NAMES wcautil\n  PATHS ${WIX_MSVC_DIR}/lib/${WIX_ARCH})\n\nFIND_LIBRARY(WIX_DUTIL_LIBRARY \n  NAMES dutil\n  PATHS ${WIX_MSVC_DIR}/lib/${WIX_ARCH})\n\nMESSAGE(STATUS \"Found: ${WIX_WCAUTIL_LIBRARY}\")\nMESSAGE(STATUS \"Found: ${WIX_DUTIL_LIBRARY}\")\n\n#ADD_VERSION_INFO(wixca SHARED WIXCA_SOURCES)\nCONFIGURE_FILE(../versioninfo.rc.in ${CMAKE_BINARY_DIR}/versioninfo_dll.rc)\n\n\nADD_LIBRARY(wixca SHARED EXCLUDE_FROM_ALL ${WIXCA_SOURCES} ${CMAKE_BINARY_DIR}/versioninfo_dll.rc)\nTARGET_LINK_LIBRARIES(wixca ${WIX_WCAUTIL_LIBRARY} ${WIX_DUTIL_LIBRARY}\n  msi version )\n"
  },
  {
    "path": "packaging/WiX/ca/CustomAction.cpp",
    "content": "/* Copyright (c) 2010, 2017 Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; if not, write to the Free Software\n   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */\n\n#ifndef UNICODE\n#define UNICODE\n#endif\n\n#include <windows.h>\n#include <winreg.h>\n#include <msi.h>\n#include <msiquery.h>\n#include <wcautil.h>\n#include <string.h>\n#include <strsafe.h>\n#include <direct.h>\n#include <stdlib.h>\n#include <tchar.h>\n#include \"nt_servc.h\"\n\n\nint stop_service(const char *service_name)\n{\n  int stopped = 0;\n  WcaLog(LOGMSG_STANDARD, \"Trying to stop the service.\");\n  SC_HANDLE hSCM = NULL;\n  hSCM = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);\n  if (hSCM != NULL) {\n    SC_HANDLE hService = NULL;\n    hService = OpenServiceA(hSCM, service_name, SERVICE_STOP | SERVICE_QUERY_STATUS | DELETE);\n    if (hService != NULL) {\n      WcaLog(LOGMSG_STANDARD, \"Waiting for the service to stop...\");\n      SERVICE_STATUS status;\n      /* Attempt to stop the service */\n      if (ControlService(hService, SERVICE_CONTROL_STOP, &status)) {\n        /* Now wait until it's stopped */\n        while (\"it's one big, mean and cruel world out there\") {\n          if (!QueryServiceStatus(hService, &status)) {\n            WcaLog(LOGMSG_STANDARD, \"Error while querying service status in 'stop_service' (code %d)\", GetLastError());\n            break;\n          }\n          if (status.dwCurrentState == SERVICE_STOPPED) break;\n          Sleep(1000);\n        }\n        WcaLog(LOGMSG_STANDARD, \"Stopped the service.\");\n        stopped = 1;\n      }\n      /* Mark the service for deletion */\n      DeleteService(hService);\n      CloseServiceHandle(hService);\n    }\n    CloseServiceHandle(hSCM);\n  }  \n  return stopped;\n}\n\nint remove_service(const TCHAR *service_name) {\n\n  int result = 0;\n  SC_HANDLE service;\n  SC_HANDLE hSCM = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);\n  if(hSCM == NULL) { \n    WcaLog(LOGMSG_STANDARD, \"Failed to open the Service Control Mananger (with code %d)\\n\", GetLastError());\n    return result;\n  }\n  service = OpenService(hSCM, service_name, DELETE);\n  if (service == NULL) {\n    WcaLog(LOGMSG_STANDARD, \"Failed to open the service to delete (with code %d)\\n\", GetLastError());\n    CloseServiceHandle(hSCM);\n    return 1;\n  }\n  if (!DeleteService(service)) {\n    DWORD code = GetLastError();\n    WcaLog(LOGMSG_STANDARD, \"Failed to delete the service after opening it (with code %d)\\n\", code);\n    if (code == ERROR_SERVICE_MARKED_FOR_DELETE) {\n      MessageBox(NULL, L\"MySQL Router is marked for deletion, but needs to restart computer to remove it.\", L\"Info\", 0);\n      result = 1;\n    }\n  } else {\n    WcaLog(LOGMSG_STANDARD, \"Service deleted successfully\\n\");\n    result = 1;\n  }\n  \n  CloseServiceHandle(service);\n  CloseServiceHandle(hSCM);\n\n  return result;\n}\n\n\nUINT wrap(MSIHANDLE hInstall, char *name, int check_only) {\n  HRESULT hr = S_OK;\n  UINT er = ERROR_SUCCESS;\n\n  hr = WcaInitialize(hInstall, name);\n  ExitOnFailure(hr, \"Failed to initialize\");\n\n  WcaLog(LOGMSG_STANDARD, \"Initialized.\");\n\n  LPCTSTR szInternName = TEXT(\"MySQLRouter\");\n  int rc = remove_service(szInternName);\n\tif (!rc) {\n\t  er = ERROR_CANCELLED;\n\t}\n\nLExit:\n  WcaSetReturnValue(er);\n  return WcaFinalize(er);\n}\n\nUINT __stdcall RemoveServiceNoninteractive(MSIHANDLE hInstall) {\n  return wrap(hInstall, \"RemoveServiceNoninteractive\", -1);\n}\n\nUINT __stdcall RemoveService(MSIHANDLE hInstall) {\n  return wrap(hInstall, \"RemoveService\", 0);\n}\n\nUINT __stdcall TestService(MSIHANDLE hInstall) {\n  return wrap(hInstall, \"TestService\", 1);\n}\n\n// We implement a simple string buffer class to avoid having to link to MSVCR\nclass StringBuffer {\npublic:\n\tStringBuffer()\t{\n\t\tsize_ = 1024;\n\t\tlength_ = 0;\n\t\tbuffer_ = (char*)malloc(size_);\n\t}\n\n\t~StringBuffer() {\n\t\tif (buffer_)\n\t\t\tfree(buffer_);\n\t}\n\n\tvoid append(const char *s) {\n\t\tappend(s, strlen(s));\n\t}\n\n\tvoid append(const char *s, size_t length)\t{\n\t\tif (length_ + length + 1 > size_)\t{\n\t\t\tchar *tmp = (char*)realloc(buffer_, size_ + length + 1);\n\t\t\tsize_ += length + 1;\n\t\t\tif (!tmp)\t{\n\t\t\t\tfree(buffer_);\n\t\t\t\tbuffer_ = NULL;\n\t\t\t}\n      else {\n        buffer_ = tmp;\n      }\n\t\t}\n\t\tif (buffer_) {\n\t\t\tmemcpy(buffer_ + length_, s, length);\n\t\t\tlength_ += length;\n\t\t\tbuffer_[length_] = 0;\n\t\t}\n\t}\n\n\tconst char *c_str() const {\n\t\treturn buffer_;\n\t}\n\n\tchar *release()\t{\n\t\tchar *tmp = buffer_;\n\t\tbuffer_ = NULL;\n\t\treturn tmp;\n\t}\n\nprivate:\n\tchar *buffer_;\n\tsize_t length_;\n\tsize_t size_;\n};\n\n\nstatic char *replace_variable(char *data, const char *name, const char *value) {\n  char *start = data;\n\tchar *ptr = NULL;\n  char *end = data + strlen(data);\n\tsize_t name_len = strlen(name);\n\tsize_t value_len = strlen(value);\n\tStringBuffer result;\n\n  while ((ptr = strstr(start, name)))\t{\n\t\tresult.append(start, ptr-start);\n\t\tresult.append(value, value_len);\n\t\tstart = ptr + name_len;\n  }\n\tresult.append(start, strlen(start));\n\n\treturn result.release();\n}\n\n\nstatic bool dir_exists(char *dir_path)\n{\n  DWORD dwAttrib = GetFileAttributesA(dir_path);\n\n  if (dwAttrib != INVALID_FILE_ATTRIBUTES) {\n    if ((dwAttrib & FILE_ATTRIBUTE_DIRECTORY) == 0) {\n      WcaLog(LOGMSG_STANDARD, \"Error: the path '%s' exists as a file (must be a directory)\\n\", dir_path);\n      return false;\n    } else {\n      return true;\n    }\n  } else {\n    return false;\n  }\n}\n\n\nstatic DWORD create_directory_recursively(const char *path)\n{\n  DWORD code = 0;\n  // ensure we have writeable copy for the string\n  HLOCAL buf = LocalAlloc(0, strlen(path) + 1);\n  if (buf == NULL) {\n    return GetLastError();\n  }\n  strcpy(reinterpret_cast<char *>(buf), path);\n  char *pc, *pc_base;\n  pc = pc_base = reinterpret_cast<char *>(buf);\n  while (*pc)\n  {\n    if (*pc == '\\\\' || *pc == '/')\n    {\n      *pc = '\\0';\n      if (!dir_exists(pc_base))\n      {\n        if (!CreateDirectoryA(pc_base, NULL))\n        {\n          code = GetLastError();\n        }\n      }\n      *pc = '\\\\';\n      if (code != 0) goto end;\n    }\n    ++pc;\n  }\n\n  if (!dir_exists(pc_base))\n  {\n    if (!CreateDirectoryA(pc_base, NULL))\n    {\n      code = GetLastError();\n    }\n  }\nend:\n  LocalFree(buf);\n  return code;\n}\n\n\n/* Copies the default config file from the install dir's etc folder to the proper place in\n  ProgramData */\nint install_config_file(const char *install_dir, const char* progdata_dir) {\n  DWORD code;\n  if ((code = create_directory_recursively(progdata_dir)) != 0)\n  {\n    WcaLog(LOGMSG_STANDARD, \"Creating some directory part of the path '%s' failed with error %d\", progdata_dir, code);\n    return -1;\n  }\n\n\tStringBuffer source_path;\n\tsource_path.append(install_dir);\n\tsource_path.append(\"\\\\etc\\\\mysqlrouter.conf.sample\");\n  FILE *f = fopen(source_path.c_str(), \"r\");\n  if (!f) {\n    WcaLog(LOGMSG_STANDARD, \"Can't open config file template %s: %s\", source_path.c_str(), strerror(errno));\n    return -1;\n  }\n  char template_data[64 * 1024];\n  size_t len;\n  len = fread(template_data, 1, sizeof(template_data), f);\n  if (len < 0) {\n    WcaLog(LOGMSG_STANDARD, \"Could not read config file template data from %s: %i\", source_path, errno);\n    fclose(f);\n    return -1;\n  }\n  fclose(f);\n  template_data[len] = 0;\n\n\tchar *buffer;\n  // do find/replace of variables\n  buffer = replace_variable(template_data, \"%INSTALL_FOLDER%\", install_dir);\n\tif (buffer) {\n\t\tchar *buffer2;\n  \tbuffer2 = replace_variable(buffer, \"%PROGRAMDATA_FOLDER%\", progdata_dir);\n\t\tfree(buffer);\n\t\tbuffer = buffer2;\n\t}\n\tif (!buffer) {\n\t\tWcaLog(LOGMSG_STANDARD, \"Out of memory creating default config file\");\n\t\treturn -1;\n\t}\n\t// write the config file\n\tStringBuffer target_file;\n\ttarget_file.append(progdata_dir);\n\ttarget_file.append(\"\\\\mysqlrouter.conf\");\n\tFILE *tmp;\n\tif ((tmp = fopen(target_file.c_str(), \"r\")) != NULL) {\n\t\tfclose(tmp);\n\t\tWcaLog(LOGMSG_STANDARD, \"Config file %s already exists, skipping creation\", target_file.c_str());\n\t} else {\n\t\tFILE *of = fopen(target_file.c_str(), \"w+\");\n\t\tif (!of) {\n\t\t\tWcaLog(LOGMSG_STANDARD, \"Could not create config file %s: %s\", target_file.c_str(), strerror(errno));\n\t\t\treturn ERROR_INSTALL_FAILURE;\n\t\t}\telse {\n\t\t\tif (fwrite(buffer, 1, strlen(buffer), of) < 0) {\n\t\t\t\tWcaLog(LOGMSG_STANDARD, \"Error writing config file %s: %s\", target_file.c_str(), strerror(errno));\n\t\t\t\t// ignore the error\n\t\t\t} else {\n\t\t\t\tWcaLog(LOGMSG_STANDARD, \"Wrote config file %s\", target_file.c_str());\n\t\t\t}\n\t\t\tfclose(of);\n\t\t}\n\t}\n\tfree(buffer);\n  return 0;\n}\n\n\nUINT create_config_file(MSIHANDLE hInstall) {\n  HRESULT hr = S_OK;\n  UINT er = ERROR_SUCCESS;\n\n  hr = WcaInitialize(hInstall, \"InstallDefaultConfigFile\");\n  ExitOnFailure(hr, \"Failed to initialize config updater\");\n\n  WcaLog(LOGMSG_STANDARD, \"Initialized config updater.\");\n\n  char custom_data[1024*2];\n  DWORD custom_data_size = sizeof(custom_data);\n  if (MsiGetPropertyA(hInstall, \"CustomActionData\", custom_data, &custom_data_size) == ERROR_SUCCESS) {\n\t\tchar *ptr = NULL;\n\t\tWcaLog(LOGMSG_STANDARD, \"%s\", custom_data);\n\t\tchar *p = strtok_s(custom_data, \";\", &ptr);\n\t  char *install_dir = NULL;\n\t  char *data_dir = NULL;\n\t\twhile (p)\n\t\t{\n\t\t\tchar *sep = strchr(p, '=');\n\t\t\tif (strncmp(p, \"INSTALL\", strlen(\"INSTALL\")) == 0) {\n\t\t\t\tinstall_dir = sep+1;\n\t\t\t\tif (*(sep-1) == '\\\\')\n\t\t\t\t\t*(sep-1) = 0; // trim trailing backslash\n\t\t\t}\telse if (strncmp(p, \"DATA\", strlen(\"DATA\")) == 0)\t{\n\t\t\t\tdata_dir = sep+1;\n\t\t\t\tif (*(sep-1) == '\\\\')\n\t\t\t\t\t*(sep-1) = 0; // trim trailing backslash\n\t\t\t}\n\t\t\tp = strtok_s(NULL, \";\", &ptr);\n\t\t}\n\n    if (!install_dir)\t{\n      WcaLog(LOGMSG_STANDARD, \"Could not determine Install directory\");\n      er = ERROR_INSTALL_FAILURE;\n    } else if (!data_dir)\t{\n\t\t\tWcaLog(LOGMSG_STANDARD, \"Could not determine ProgramData directory\");\n\t\t\ter = ERROR_INSTALL_FAILURE;\n\t\t}\telse {\n\t\t\t// normalize paths to use / as separator\n\t\t\tfor (char *c = install_dir; *c; ++c) {\n\t\t\t\tif (*c == '\\\\')\n\t\t\t\t\t*c = '/';\n\t\t\t}\n\t\t\tfor (char *c = data_dir; *c; ++c) {\n\t\t\t\tif (*c == '\\\\')\n\t\t\t\t\t*c = '/';\n\t\t\t}\n      int rc = install_config_file(install_dir, data_dir);\n      if (rc < 0)\n        er = ERROR_INSTALL_FAILURE;\n    }\n  }\telse {\n\t\tWcaLog(LOGMSG_STANDARD, \"Could not CustomActionData\");\n  \ter = ERROR_INSTALL_FAILURE;\n  }\nLExit:\n  return WcaFinalize(er);\n}\n\n\nUINT __stdcall InstallDefaultConfigFile(MSIHANDLE hInstall) {\n\n\treturn create_config_file(hInstall);\n}\n\n\nUINT __stdcall RunPostInstall(MSIHANDLE hInstall) {\n\treturn 0;\n}\n\n\nUINT DoInstallService(MSIHANDLE hInstall, char *install_dir, char *data_dir)\n{\n  char szFilePath[_MAX_PATH];\n  int startType = 0;\n  LPCSTR szInternNameA = \"MySQLRouter\";\n  LPCTSTR szInternName = TEXT(\"MySQLRouter\");\n  LPCSTR szDisplayName = \"MySQL Router\";\n  LPCSTR szFullPath = \"\";\n  LPCSTR szAccountName = \"NT AUTHORITY\\\\LocalService\";\n\n  strcpy(szFilePath, \"\\\"\");\n  strcat(szFilePath, install_dir);\n  strcat(szFilePath, \"bin\\\\mysqlrouter.exe\\\"\");\n  strcat(szFilePath, \" -c \\\"\");\n  strcat(szFilePath, data_dir);\n  strcat(szFilePath, \"\\\\mysqlrouter.conf\\\" --service\");\n  int len = strlen(szFilePath);\n  for (int i = 0; i < len; i++)\n  {\n    if (szFilePath[i] == '/')\n    {\n      szFilePath[i] = '\\\\';\n    }\n  }\n  \n  NTService service;\n  if (!service.SeekStatus(szInternNameA, 1))\n  {\n    printf(\"Service already installed\\n\");\n    WcaLog(LOGMSG_STANDARD, \"Service already installed, trying to remove...\\n\");\n    stop_service(szInternNameA);\n    if (remove_service(szInternName)) {\n      WcaLog(LOGMSG_STANDARD, \"Error when removing the already installed service\\n\");\n      return FALSE;\n    }\n    else\n      WcaLog(LOGMSG_STANDARD, \"Service removed successfully.\\n\");\n  }\n  BOOL res = service.Install(startType, szInternNameA, szDisplayName, szFilePath, szAccountName);\n  return res;\n}\n\nUINT __stdcall InstallService(MSIHANDLE hInstall)\n{\n  HRESULT hr = S_OK;\n  UINT er = ERROR_SUCCESS;\n\n  hr = WcaInitialize(hInstall, \"InstallService\");\n  ExitOnFailure(hr, \"Failed to initialize service installer\");\n\n  WcaLog(LOGMSG_STANDARD, \"Initialized service installer.\");\n\n  char custom_data[1024 * 2];\n  DWORD custom_data_size = sizeof(custom_data);\n  if (MsiGetPropertyA(hInstall, \"CustomActionData\", custom_data, &custom_data_size) == ERROR_SUCCESS) {\n    char *ptr = NULL;\n    WcaLog(LOGMSG_STANDARD, \"%s\", custom_data);\n    char *p = strtok_s(custom_data, \";\", &ptr);\n    char *install_dir = NULL;\n    char *data_dir = NULL;\n    while (p)\n    {\n      char *sep = strchr(p, '=');\n      if (strncmp(p, \"INSTALL\", strlen(\"INSTALL\")) == 0) {\n        install_dir = sep + 1;\n        if (*(sep - 1) == '\\\\')\n          *(sep - 1) = 0; // trim trailing backslash\n      }\n      else if (strncmp(p, \"DATA\", strlen(\"DATA\")) == 0) {\n        data_dir = sep + 1;\n        if (*(sep - 1) == '\\\\')\n          *(sep - 1) = 0; // trim trailing backslash\n      }\n      p = strtok_s(NULL, \";\", &ptr);\n    }\n\n    if (!install_dir) {\n      WcaLog(LOGMSG_STANDARD, \"Could not determine Install directory\");\n      er = ERROR_INSTALL_FAILURE;\n    }\n    else if (!data_dir) {\n      WcaLog(LOGMSG_STANDARD, \"Could not determine ProgramData directory\");\n      er = ERROR_INSTALL_FAILURE;\n    }\n    else {\n      // normalize paths to use / as separator\n      for (char *c = install_dir; *c; ++c) {\n        if (*c == '\\\\')\n          *c = '/';\n      }\n      for (char *c = data_dir; *c; ++c) {\n        if (*c == '\\\\')\n          *c = '/';\n      }\n      int rc = DoInstallService(hInstall, install_dir, data_dir);\n      if (!rc)\n        er = ERROR_INSTALL_FAILURE;\n    }\n  }\n  else {\n    WcaLog(LOGMSG_STANDARD, \"Could not get CustomActionData\");\n    er = ERROR_INSTALL_FAILURE;\n  }\nLExit:\n  return WcaFinalize(er);\n}\n\n\n/* DllMain - Initialize and cleanup WiX custom action utils */\nextern \"C\" BOOL WINAPI DllMain(\n\t__in HINSTANCE hInst,\n\t__in ULONG ulReason,\n\t__in LPVOID\n\t) {\n\tswitch(ulReason) {\n\tcase DLL_PROCESS_ATTACH:\n\t\tWcaGlobalInitialize(hInst);\n\t\tbreak;\n\n\tcase DLL_PROCESS_DETACH:\n\t\tWcaGlobalFinalize();\n\t\tbreak;\n\t}\n\treturn TRUE;\n}\n"
  },
  {
    "path": "packaging/WiX/ca/CustomAction.def",
    "content": "LIBRARY \"wixca\"\nVERSION 1.0\n\nEXPORTS\n\nRemoveService\nRemoveServiceNoninteractive\nTestService\nRunPostInstall\nInstallDefaultConfigFile\nInstallService\n"
  },
  {
    "path": "packaging/WiX/create_msi.cmake.in",
    "content": "# Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n\nSET(CMAKE_BINARY_DIR \"@CMAKE_BINARY_DIR@\")\nSET(CMAKE_CURRENT_SOURCE_DIR \"@CMAKE_CURRENT_SOURCE_DIR@\")\nSET(CANDLE_EXECUTABLE \"@CANDLE_EXECUTABLE@\")\nSET(LIGHT_EXECUTABLE \"@LIGHT_EXECUTABLE@\")\nSET(CMAKE_COMMAND \"@CMAKE_COMMAND@\")\nSET(CMAKE_CFG_INTDIR \"@CMAKE_CFG_INTDIR@\")\nSET(VERSION \"@PROJECT_VERSION@\")\nSET(MAJOR_VERSION \"@PROJECT_VERSION_MAJOR@\")\nSET(MINOR_VERSION \"@PROJECT_VERSION_MINOR@\")\nSET(PATCH_VERSION \"@PROJECT_VERSION_PATCH@\")\nSET(CMAKE_SIZEOF_VOID_P @CMAKE_SIZEOF_VOID_P@)\nSET(MANUFACTURER \"Oracle Corporation\")\nSET(WIXCA_LOCATION \"@WIXCA_LOCATION@\")\nSET(COPYING_RTF \"@COPYING_RTF@\")\nSET(CPACK_WIX_CONFIG \"@CPACK_WIX_CONFIG@\")\nSET(CPACK_WIX_INCLUDE \"@CPACK_WIX_INCLUDE@\")\nSET(PRODUCT_NAME \"MySQL Router\")\nSET(PRODUCT_DESCRIPTION \"MySQL Router\")\nSET(UPGRADE_ID \"9FC37322-7617-4205-B7BD-F72C30EF101A\")\nSET(UPGRADE_CODE \"9FC37322-7617-4205-B7BD-F72C30EF101A\")\nSET(GPL \"@GPL@\")\n\n#LIST(APPEND EXCLUDE_DIRS\n     #scripts\n#)\n\n#LIST(APPEND EXCLUDE_FILES\n#)\n\n\nIF(CMAKE_SIZEOF_VOID_P EQUAL 8)\n  SET(Win64 \" Win64='yes'\")\n  SET(Platform x64)\n  SET(PlatformProgramFilesFolder ProgramFiles64Folder)\nELSE()\n  SET(Platform x86)\n  SET(PlatformProgramFilesFolder ProgramFilesFolder)\n  SET(Win64 \" Win64='no'\")\nENDIF()\n\nSET(ENV{VS_UNICODE_OUTPUT})\n\nINCLUDE(${CMAKE_BINARY_DIR}/CPackConfig.cmake)\n\nIF(CPACK_WIX_CONFIG)\n  INCLUDE(${CPACK_WIX_CONFIG})\nENDIF()\n\nIF(NOT CPACK_WIX_UI)\n  SET(CPACK_WIX_UI \"WixUI_Minimal_Custom\")\nENDIF()\n\nSET(WIX_FEATURES)\nFOREACH(comp ${CPACK_COMPONENTS_ALL})\n STRING(TOUPPER \"${comp}\" comp_upper)\n IF(NOT CPACK_COMPONENT_${comp_upper}_GROUP)\n   SET(WIX_FEATURE_${comp_upper}_COMPONENTS \"${comp}\")\n   SET(CPACK_COMPONENT_${comp_upper}_HIDDEN 1)\n   SET(CPACK_COMPONENT_GROUP_${comp_upper}_DISPLAY_NAME ${CPACK_COMPONENT_${comp_upper}_DISPLAY_NAME})\n   SET(CPACK_COMPONENT_GROUP_${comp_upper}_DESCRIPTION ${CPACK_COMPONENT_${comp_upper}_DESCRIPTION})\n   SET(CPACK_COMPONENT_GROUP_${comp_upper}_WIX_LEVEL ${CPACK_COMPONENT_${comp_upper}_WIX_LEVEL})\n   SET(WIX_FEATURES ${WIX_FEATURES} WIX_FEATURE_${comp_upper})\n ELSE()\n   SET(FEATURE_NAME WIX_FEATURE_${CPACK_COMPONENT_${comp_upper}_GROUP})\n   SET(WIX_FEATURES ${WIX_FEATURES} ${FEATURE_NAME})\n   LIST(APPEND ${FEATURE_NAME}_COMPONENTS ${comp})\n ENDIF()\nENDFOREACH()\n\nIF(WIFX_FEATURES)\n  LIST(REMOVE_DUPLICATES WIX_FEATURES)\nELSE()\n  SET(WIX_FEATURES DefaultFeature)\nENDIF()\n\nSET(CPACK_WIX_FEATURES)\n\nFOREACH(f ${WIX_FEATURES})\n STRING(TOUPPER \"${f}\" f_upper)\n STRING(REPLACE \"WIX_FEATURE_\" \"\" f_upper ${f_upper})\n IF (CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME)\n  SET(TITLE ${CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME})\n ELSE()\n  SET(TITLE  CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME)\n ENDIF()\n\n IF (CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION)\n  SET(DESCRIPTION ${CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION})\n ELSE()\n  SET(DESCRIPTION CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION)\n ENDIF()\n IF(CPACK_COMPONENT_${f_upper}_WIX_LEVEL)\n   SET(Level ${CPACK_COMPONENT_${f_upper}_WIX_LEVEL})\n ELSE()\n   SET(Level 1)\n ENDIF()\n IF(CPACK_COMPONENT_GROUP_${f_upper}_HIDDEN)\n   SET(DISPLAY \"Display='hidden'\")\n   SET(TITLE ${f_upper})\n   SET(DESCRIPTION ${f_upper})\n ELSE()\n   SET(DISPLAY)\n   IF(CPACK_COMPONENT_GROUP_${f_upper}_EXPANDED)\n    SET(DISPLAY \"Display='expand'\")\n   ENDIF()\n   IF (CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME)\n    SET(TITLE ${CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME})\n   ELSE()\n     SET(TITLE  CPACK_COMPONENT_GROUP_${f_upper}_DISPLAY_NAME)\n   ENDIF()\n   IF (CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION)\n     SET(DESCRIPTION ${CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION})\n   ELSE()\n     SET(DESCRIPTION CPACK_COMPONENT_GROUP_${f_upper}_DESCRIPTION)\n   ENDIF()\n ENDIF()\n\n # Override display name & description for Default feature\n IF(\"${f_upper}\" MATCHES \"DEFAULTFEATURE\")\n   SET(TITLE \"MySQL Router\")\n   SET(DESCRIPTION \"The MySQL Router executable &amp; plugins\")\n ENDIF()\n\n SET(CPACK_WIX_FEATURES\n \"${CPACK_WIX_FEATURES}\n   <Feature  Id='${f_upper}'\n     Title='${TITLE}'\n     Description='${DESCRIPTION}'\n     ConfigurableDirectory='INSTALLDIR'\n     Level='${Level}' ${DISPLAY} >\"\n  )\n FOREACH(c ${${f}_COMPONENTS})\n   STRING(TOUPPER \"${c}\" c_upper)\n   IF (CPACK_COMPONENT_${c_upper}_DISPLAY_NAME)\n    SET(TITLE ${CPACK_COMPONENT_${c_upper}_DISPLAY_NAME})\n   ELSE()\n    SET(TITLE CPACK_COMPONENT_${c_upper}_DISPLAY_NAME)\n   ENDIF()\n\n   IF (CPACK_COMPONENT_${c_upper}_DESCRIPTION)\n     SET(DESCRIPTION ${CPACK_COMPONENT_${c_upper}_DESCRIPTION})\n   ELSE()\n     SET(DESCRIPTION CPACK_COMPONENT_${c_upper}_DESCRIPTION)\n   ENDIF()\n   IF(CPACK_COMPONENT_${c_upper}_WIX_LEVEL)\n    SET(Level ${CPACK_COMPONENT_${c_upper}_WIX_LEVEL})\n   ELSE()\n    SET(Level 1)\n   ENDIF()\n   IF(CPACK_COMPONENT_${c_upper}_HIDDEN)\n   SET(CPACK_WIX_FEATURES\n   \"${CPACK_WIX_FEATURES}\n     <ComponentGroupRef Id='componentgroup.${c}'/>\")\n   ELSE()\n   SET(CPACK_WIX_FEATURES\n   \"${CPACK_WIX_FEATURES}\n    <Feature Id='${c}'\n       Title='${TITLE}'\n       Description='${DESCRIPTION}'\n       ConfigurableDirectory='INSTALLDIR'\n       Level='${Level}'>\n       <ComponentGroupRef Id='componentgroup.${c}'/>\n    </Feature>\")\n  ENDIF()\n\n  ENDFOREACH()\n   SET(CPACK_WIX_FEATURES\n   \"${CPACK_WIX_FEATURES}\n   </Feature>\n   \")\nENDFOREACH()\n\n\nSET(CPACK_WIX_FEATURES\n\"${CPACK_WIX_FEATURES}\n  <Feature Id='DefaultFeature' Level='1'>\n    <ComponentGroupRef Id='AllFiles'/>\n  </Feature>\n\"\n )\n\nIF(CMAKE_INSTALL_CONFIG_NAME)\n  STRING(REPLACE \"${CMAKE_CFG_INTDIR}\" \"${CMAKE_INSTALL_CONFIG_NAME}\"\n    WIXCA_LOCATION \"${WIXCA_LOCATION}\")\n  SET(CONFIG_PARAM \"-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_INSTALL_CONFIG_NAME}\")\nENDIF()\n\n\n# FOREACH(comp ${CPACK_COMPONENTS_ALL})\n#  SET(ENV{DESTDIR} testinstall/${comp})\n#  SET(DIRS ${DIRS} testinstall/${comp})\n#  EXECUTE_PROCESS(\n#   COMMAND ${CMAKE_COMMAND} ${CONFIG_PARAM} -DCMAKE_INSTALL_COMPONENT=${comp}\n#    -DCMAKE_INSTALL_PREFIX=  -P ${CMAKE_BINARY_DIR}/cmake_install.cmake\n#    OUTPUT_QUIET\n#   )\n# ENDFOREACH()\n\nMACRO(GENERATE_GUID VarName)\n EXECUTE_PROCESS(COMMAND uuidgen -c\n OUTPUT_VARIABLE ${VarName}\n OUTPUT_STRIP_TRAILING_WHITESPACE)\nENDMACRO()\n\nSET(INC_VAR 0)\nMACRO(MAKE_WIX_IDENTIFIER str varname)\n  STRING(REPLACE \"/\" \".\" ${varname} \"${str}\")\n  STRING(REGEX REPLACE \"[^a-zA-Z_0-9.]\" \"_\" ${varname} \"${${varname}}\")\n  STRING(LENGTH \"${${varname}}\" len)\n  # Identifier should be smaller than 72 character\n  # We have to cut down the length to 70 chars, since we add 2 char prefix\n  # pretty often\n  IF(len GREATER 70)\n   STRING(SUBSTRING  \"${${varname}}\" 0 67 shortstr)\n   MATH(EXPR INC_VAR ${INC_VAR}+1)\n   SET(${varname} \"${shortstr}${INC_VAR}\")\n  ENDIF()\nENDMACRO()\n\n\nFUNCTION(TRAVERSE_FILES dir topdir file file_comp  dir_root)\n  FILE(RELATIVE_PATH dir_rel ${topdir} ${dir})\n  IF(dir_rel)\n    LIST(FIND EXCLUDE_DIRS ${dir_rel} TO_EXCLUDE)\n    IF(NOT TO_EXCLUDE EQUAL -1)\n      MESSAGE(STATUS \"excluding directory: ${dir_rel}\")\n      RETURN()\n    ENDIF()\n  ENDIF()\n  FILE(GLOB all_files ${dir}/*)\n  IF(NOT all_files)\n    RETURN()\n  ENDIF()\n  IF(dir_rel)\n   MAKE_DIRECTORY(${dir_root}/${dir_rel})\n   MAKE_WIX_IDENTIFIER(\"${dir_rel}\" id)\n   SET(DirectoryRefId  \"D.${id}\")\n  ELSE()\n   SET(DirectoryRefId \"INSTALLDIR\")\n  ENDIF()\n  FILE(APPEND ${file} \"<DirectoryRef Id='${DirectoryRefId}'>\\n\")\n  MESSAGE(OUTPUT \"${file} --- ${all_files}\")\n  SET(NONEXEFILES)\n  FOREACH(f ${all_files})\n    IF(NOT IS_DIRECTORY ${f})\n      FILE(RELATIVE_PATH rel ${topdir} ${f})\n      SET(TO_EXCLUDE)\n      IF(rel MATCHES \"\\\\.pdb$\" OR rel MATCHES \"\\\\.conf$\" OR rel MATCHES \"\\\\.ini$\")\n        SET(TO_EXCLUDE TRUE)\n      ELSE()\n        LIST(FIND EXCLUDE_FILES ${rel} RES)\n        IF(NOT RES EQUAL -1)\n          SET(TO_EXCLUDE TRUE)\n        ENDIF()\n      ENDIF()\n      IF(TO_EXCLUDE)\n        MESSAGE(STATUS \"excluding file: ${rel}\")\n      ELSE()\n       MAKE_WIX_IDENTIFIER(\"${rel}\" id)\n        FILE(TO_NATIVE_PATH ${f} f_native)\n        IF(\"${rel}\" MATCHES \"lib/harness-library.dll\" OR \"${rel}\" MATCHES \".ilk\" OR \"${rel}\" MATCHES \".log\" OR\n           \"${rel}\" MATCHES \"lib/bad_one.dll\" OR \"${rel}\" MATCHES \"lib/bad_two.dll\" OR\n           \"${rel}\" MATCHES \"lib/example.dll\" OR \"${rel}\" MATCHES \"lib/magic.dll\" OR\n           \"${rel}\" MATCHES \"lib/lifecycle\" OR\n           \"${rel}\" MATCHES \"bin/mysql_server_mock.exe\")\n          # ignore /lib version of harness-library (it is on bin folder already)\n          # also ignore .ilk files and a bunch of DLLs that are useful for testing only.\n        ELSE()\n          GET_FILENAME_COMPONENT(f_ext \"${f}\" EXT)\n          # According to MSDN each DLL or EXE should be in the own component\n          IF(f_ext MATCHES \".exe\" OR f_ext MATCHES \".dll\")\n            FILE(APPEND ${file} \"  <Component Id='C.${id}' Guid='*' ${Win64}>\\n\")\n            FILE(APPEND ${file} \"    <File Id='F.${id}' KeyPath='yes' Source='${f_native}'/>\\n\")\n            FILE(APPEND ${file} \"  </Component>\\n\")\n            FILE(APPEND ${file_comp} \"  <ComponentRef Id='C.${id}'/>\\n\")\n          ELSE()\n            SET(NONEXEFILES  \"${NONEXEFILES}\\n<File Id='F.${id}' Source='${f_native}'/>\" )\n          ENDIF()\n        ENDIF()\n      ENDIF()\n    ENDIF()\n  ENDFOREACH()\n  FILE(APPEND ${file} \"</DirectoryRef>\\n\")\n  IF(NONEXEFILES)\n    GENERATE_GUID(guid)\n    SET(ComponentId \"C._files_${COMP_NAME}.${DirectoryRefId}\")\n    FILE(APPEND ${file}\n      \"<DirectoryRef Id='${DirectoryRefId}'>\\n<Component Guid='${guid}' Id='${ComponentId}' ${Win64}>${NONEXEFILES}\\n</Component></DirectoryRef>\\n\")\n    FILE(APPEND ${file_comp} \"  <ComponentRef Id='${ComponentId}'/>\\n\")\n  ENDIF()\n  FOREACH(f ${all_files})\n    IF(IS_DIRECTORY ${f})\n      TRAVERSE_FILES(${f} ${topdir} ${file} ${file_comp}  ${dir_root})\n    ENDIF()\n  ENDFOREACH()\nENDFUNCTION()\n\nFUNCTION(TRAVERSE_DIRECTORIES dir topdir file prefix)\n  FILE(RELATIVE_PATH rel ${topdir} ${dir})\n  IF(rel)\n    MAKE_WIX_IDENTIFIER(\"${rel}\" id)\n    GET_FILENAME_COMPONENT(name ${dir} NAME)\n    FILE(APPEND ${file} \"${prefix}<Directory Id='D.${id}' Name='${name}'>\\n\")\n  ENDIF()\n  FILE(GLOB all_files ${dir}/*)\n  FOREACH(f ${all_files})\n    IF(IS_DIRECTORY ${f})\n      TRAVERSE_DIRECTORIES(${f} ${topdir} ${file} \"${prefix}  \")\n    ENDIF()\n  ENDFOREACH()\n  IF(rel)\n    FILE(APPEND ${file} \"${prefix}</Directory>\\n\")\n  ENDIF()\nENDFUNCTION()\n\nSET(COMP_NAME AllFiles)\nGET_FILENAME_COMPONENT(abs . ABSOLUTE)\nFOREACH(d ${CMAKE_BINARY_DIR}/stage/${CMAKE_INSTALL_CONFIG_NAME})\n  GET_FILENAME_COMPONENT(d ${d} ABSOLUTE)\n  GET_FILENAME_COMPONENT(d_name ${d} NAME)\n\n  TRAVERSE_FILES(${d} ${d} ${abs}/all_components.wxs ${abs}/all_component_group.wxs \"${CMAKE_BINARY_DIR}/stage\")\nENDFOREACH()\n\n\nFILE(READ all_components.wxs CPACK_WIX_COMPONENTS)\nFILE(REMOVE all_components.wxs)\n\nFILE(READ all_component_group.wxs WIX_TMP)\nSET(CPACK_WIX_COMPONENT_GROUPS \"<ComponentGroup Id='AllFiles'>\\n${WIX_TMP}\\n</ComponentGroup>\")\nFILE(REMOVE all_component_group.wxs)\n\nFILE(WRITE directories.wxs \"<DirectoryRef Id='INSTALLDIR'>\\n\")\nTRAVERSE_DIRECTORIES(${CMAKE_BINARY_DIR}/stage/${CMAKE_INSTALL_CONFIG_NAME} ${CMAKE_BINARY_DIR}/stage/${CMAKE_INSTALL_CONFIG_NAME} directories.wxs \"\")\nFILE(APPEND directories.wxs \"</DirectoryRef>\\n\")\n\nFILE(READ directories.wxs CPACK_WIX_DIRECTORIES)\nFILE(REMOVE directories.wxs)\n\nFOREACH(src ${CPACK_WIX_INCLUDE})\nSET(CPACK_WIX_INCLUDES\n\"${CPACK_WIX_INCLUDES}\n <?include ${src}?>\"\n)\nENDFOREACH()\n\nCONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql_router.wxs.in\n ${CMAKE_CURRENT_BINARY_DIR}/mysql_router.wxs)\n\nSET(EXTRA_CANDLE_ARGS)\nIF(\"$ENV{EXTRA_CANDLE_ARGS}\")\n  SET(EXTRA_CANDLE_ARGS \"$ENV{EXTRA_CANDLE_ARGS}\")\nENDIF()\n\nSET(EXTRA_LIGHT_ARGS)\nIF(\"$ENV{EXTRA_LIGHT_ARGS}\")\n  SET(EXTRA_LIGHT_ARGS \"$ENV{EXTRA_LIGHT_ARGS}\")\nENDIF()\n\nFILE(REMOVE mysql_router.wixobj)\nEXECUTE_PROCESS(\n COMMAND \"${CANDLE_EXECUTABLE}\" -nologo -v -ext WixUtilExtension  mysql_router.wxs ${EXTRA_CANDLE_ARGS}\n RESULT_VARIABLE CANDLE_RESULT\n OUTPUT_VARIABLE CANDLE_OUTPUT\n ERROR_VARIABLE CANDLE_OUTPUT\n)\n\nIF(CANDLE_RESULT)\n\tMESSAGE(FATAL_ERROR \"ERROR: can't run ${CANDLE_EXECUTABLE}: ${CANDLE_RESULT} ${CANDLE_OUTPUT}\")\nENDIF()\n\nEXECUTE_PROCESS(\n COMMAND \"${LIGHT_EXECUTABLE}\" -ext WixUIExtension -ext WixUtilExtension\n  -v -nologo\n  mysql_router.wixobj  -out  ${CMAKE_BINARY_DIR}/${CPACK_PACKAGE_FILE_NAME}.msi\n  ${EXTRA_LIGHT_ARGS}\n RESULT_VARIABLE LIGHT_RESULT\n OUTPUT_VARIABLE LIGHT_OUTPUT\n ERROR_VARIABLE LIGHT_OUTPUT\n)\n\nIF(LIGHT_RESULT)\n\tMESSAGE(FATAL_ERROR \"ERROR: can't run ${LIGHT_EXECUTABLE}: ${LIGHT_RESULT} ${LIGHT_OUTPUT}\")\nENDIF()\n"
  },
  {
    "path": "packaging/WiX/custom_ui.wxs",
    "content": "<Include xmlns=\"http://schemas.microsoft.com/wix/2006/wi\"\n         xmlns:util=\"http://schemas.microsoft.com/wix/UtilExtension\">\n\n<!--\n   Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; if not, write to the Free Software\n   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n-->\n\n  <UI Id=\"WixUI_Minimal_Custom\">\n    <Dialog Id=\"CustomWelcomeDlg\" Width=\"370\" Height=\"270\" Title=\"[ProductName] Setup\" NoMinimize=\"yes\">\n      <Control Id=\"Cancel\" Type=\"PushButton\" X=\"304\" Y=\"243\" Width=\"56\" Height=\"17\" Cancel=\"yes\" Text=\"!(loc.WixUICancel)\">\n        <Publish Event=\"SpawnDialog\" Value=\"CancelDlg\">1</Publish>\n      </Control>\n      <Control Id=\"Next\" Type=\"PushButton\" X=\"220\" Y=\"243\" Width=\"56\" Height=\"17\" Default=\"yes\" Text=\"!(loc.WixUINext)\">\n        <Publish Event=\"NewDialog\" Value=\"LicenseAgreementDlg\">NOT OLDERVERSIONBEINGUPGRADED</Publish>\n        <Publish Event=\"NewDialog\" Value=\"UpgradeDlg\">OLDERVERSIONBEINGUPGRADED</Publish>\n\t  </Control>\n      <Control Id=\"Back\" Type=\"PushButton\" X=\"156\" Y=\"243\" Width=\"56\" Height=\"17\" Text=\"!(loc.WixUIBack)\" Disabled=\"yes\" />\n      <Control Id=\"Description\" Type=\"Text\" X=\"135\" Y=\"80\" Width=\"220\" Height=\"60\" Transparent=\"yes\" NoPrefix=\"yes\" Text=\"!(loc.WelcomeDlgDescription)\" />\n      <Control Id=\"Title\" Type=\"Text\" X=\"135\" Y=\"20\" Width=\"220\" Height=\"60\" Transparent=\"yes\" NoPrefix=\"yes\" Text=\"!(loc.WelcomeDlgTitle)\" />\n      <Control Id=\"CopyrightText\" Type=\"Text\" X=\"135\" Y=\"200\" Width=\"220\" Height=\"40\" Transparent=\"yes\" Text=\"Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.\" />\n      <Control Id=\"Bitmap\" Type=\"Bitmap\" X=\"0\" Y=\"0\" Width=\"370\" Height=\"234\" TabSkip=\"no\" Text=\"!(loc.WelcomeDlgBitmap)\" />\n      <Control Id=\"BottomLine\" Type=\"Line\" X=\"0\" Y=\"234\" Width=\"370\" Height=\"0\" />\n    </Dialog>\n\n    <Dialog Id=\"UpgradeDlg\" Width=\"370\" Height=\"270\" Title=\"[ProductName] Setup\" NoMinimize=\"yes\">\n      <Control Id=\"Install\" Type=\"PushButton\" ElevationShield=\"yes\" X=\"212\" Y=\"243\" Width=\"80\" Height=\"17\" Default=\"yes\"  Text=\"Upgrade\">\n        <Publish Event=\"EndDialog\" Value=\"Return\"><![CDATA[OutOfDiskSpace <> 1]]></Publish>\n        <Publish Event=\"SpawnDialog\" Value=\"OutOfRbDiskDlg\">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND (PROMPTROLLBACKCOST=\"P\" OR NOT PROMPTROLLBACKCOST)</Publish>\n        <Publish Event=\"EndDialog\" Value=\"Return\">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST=\"D\"</Publish>\n        <Publish Event=\"EnableRollback\" Value=\"False\">OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 0 AND PROMPTROLLBACKCOST=\"D\"</Publish>\n        <Publish Event=\"SpawnDialog\" Value=\"OutOfDiskDlg\">(OutOfDiskSpace = 1 AND OutOfNoRbDiskSpace = 1) OR (OutOfDiskSpace = 1 AND PROMPTROLLBACKCOST=\"F\")</Publish>\n      </Control>\n      <Control Id=\"Cancel\" Type=\"PushButton\" X=\"304\" Y=\"243\" Width=\"56\" Height=\"17\" Cancel=\"yes\" Text=\"!(loc.WixUICancel)\">\n        <Publish Event=\"SpawnDialog\" Value=\"CancelDlg\">1</Publish>\n      </Control>\n      <Control Id=\"Back\" Type=\"PushButton\" X=\"156\" Y=\"243\" Width=\"56\" Height=\"17\" Text=\"!(loc.WixUIBack)\">\n        <Condition Action=\"default\">WixUI_InstallMode = \"Remove\"</Condition>\n      </Control>\n      <Control Id=\"InstallTitle\" Type=\"Text\" X=\"15\" Y=\"15\" Width=\"300\" Height=\"15\" Transparent=\"yes\" NoPrefix=\"yes\" Hidden=\"yes\" Text=\"!(loc.VerifyReadyDlgInstallTitle)\">\n        <Condition Action=\"show\">NOT Installed</Condition>\n      </Control>\n      <Control Id=\"InstallText\" Type=\"Text\" X=\"25\" Y=\"70\" Width=\"320\" Height=\"80\" Hidden=\"yes\" Text=\"!(loc.VerifyReadyDlgInstallText)\">\n        <Condition Action=\"show\">NOT Installed</Condition>\n      </Control>\n      <Control Id=\"UpgradeText\" Type=\"Text\" X=\"25\" Y=\"70\" Width=\"320\" Height=\"80\" Hidden=\"no\" NoPrefix=\"yes\"\n      Text=\"Click Upgrade to upgrade your installation from version [OLDERVERSION] to version [ProductVersion]. Click Cancel to exit the upgrade.\"/>\n      <Control Id=\"BannerBitmap\" Type=\"Bitmap\" X=\"0\" Y=\"0\" Width=\"370\" Height=\"44\" TabSkip=\"no\" Text=\"!(loc.VerifyReadyDlgBannerBitmap)\" />\n      <Control Id=\"BannerLine\" Type=\"Line\" X=\"0\" Y=\"44\" Width=\"370\" Height=\"0\" />\n      <Control Id=\"BottomLine\" Type=\"Line\" X=\"0\" Y=\"234\" Width=\"370\" Height=\"0\" />\n    </Dialog>\n\n    <TextStyle Id=\"WixUI_Font_Normal\" FaceName=\"Tahoma\" Size=\"8\" />\n    <TextStyle Id=\"WixUI_Font_Bigger\" FaceName=\"Tahoma\" Size=\"12\" />\n    <TextStyle Id=\"WixUI_Font_Title\" FaceName=\"Tahoma\" Size=\"9\" Bold=\"yes\" />\n\n    <Property Id=\"DefaultUIFont\" Value=\"WixUI_Font_Normal\" />\n    <Property Id=\"WixUI_Mode\" Value=\"Minimal\" />\n\n    <DialogRef Id=\"ErrorDlg\" />\n    <DialogRef Id=\"FatalError\" />\n    <DialogRef Id=\"FilesInUse\" />\n    <DialogRef Id=\"MsiRMFilesInUse\" />\n    <DialogRef Id=\"PrepareDlg\" />\n    <DialogRef Id=\"ProgressDlg\" />\n    <DialogRef Id=\"ResumeDlg\" />\n    <DialogRef Id=\"UserExit\" />\n\n    <Publish Dialog=\"ExitDialog\" Control=\"Finish\" Event=\"EndDialog\" Value=\"Return\" Order=\"999\">1</Publish>\n\n    <Publish Dialog=\"LicenseAgreementDlg\" Control=\"Back\" Event=\"NewDialog\" Value=\"CustomWelcomeDlg\">1</Publish>\n    <Publish Dialog=\"LicenseAgreementDlg\" Control=\"Next\" Event=\"NewDialog\" Value=\"VerifyReadyDlg\" Order=\"2\">LicenseAccepted = \"1\"</Publish>\n\n    <Publish Dialog=\"VerifyReadyDlg\" Control=\"Back\" Event=\"NewDialog\" Value=\"LicenseAgreementDlg\" Order=\"1\">1</Publish>\n\n    <Publish Dialog=\"MaintenanceWelcomeDlg\" Control=\"Next\" Event=\"NewDialog\" Value=\"MaintenanceTypeDlg\">1</Publish>\n\n    <Publish Dialog=\"MaintenanceTypeDlg\" Control=\"RepairButton\" Event=\"NewDialog\" Value=\"VerifyReadyDlg\">1</Publish>\n    <Publish Dialog=\"MaintenanceTypeDlg\" Control=\"RemoveButton\" Event=\"NewDialog\" Value=\"VerifyReadyDlg\">1</Publish>\n    <Publish Dialog=\"MaintenanceTypeDlg\" Control=\"Back\" Event=\"NewDialog\" Value=\"MaintenanceWelcomeDlg\">1</Publish>\n\n    <Publish Dialog=\"UpgradeDlg\" Control=\"Back\" Event=\"NewDialog\" Value=\"CustomWelcomeDlg\">1</Publish>\n\n    <InstallUISequence>\n      <Show Dialog=\"CustomWelcomeDlg\" Before=\"ProgressDlg\">NOT Installed</Show>\n    </InstallUISequence>\n  </UI>\n\n  <UIRef Id=\"WixUI_Common\" />\n</Include>\n"
  },
  {
    "path": "packaging/WiX/extra.wxs.in",
    "content": "<Include xmlns=\"http://schemas.microsoft.com/wix/2006/wi\"\n         xmlns:util=\"http://schemas.microsoft.com/wix/UtilExtension\">\n\n<!--\n   Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.\n   \n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n   \n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n   \n   You should have received a copy of the GNU General Public License\n   along with this program; if not, write to the Free Software\n   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n-->\n\n</Include>\n\n\n\n"
  },
  {
    "path": "packaging/WiX/mysql_router.wxs.in",
    "content": "<Wix xmlns=\"http://schemas.microsoft.com/wix/2006/wi\"\n      xmlns:util=\"http://schemas.microsoft.com/wix/UtilExtension\">\n\n<!--\n   Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; if not, write to the Free Software\n   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n-->\n\n  <Product\n    Id=\"*\"\n    UpgradeCode=\"@UPGRADE_CODE@\"\n    Name=\"@PRODUCT_NAME@ @MAJOR_VERSION@.@MINOR_VERSION@\"\n    Version=\"@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@\"\n    Language=\"1033\"\n    Manufacturer=\"@MANUFACTURER@\">\n\n    <Package Id='*'\n       Keywords='Installer'\n       Description=\"@PRODUCT_DESCRIPTION@\"\n       Manufacturer='@MANUFACTURER@'\n       InstallerVersion='301'\n       Languages='1033'\n       Compressed='yes'\n       SummaryCodepage='1252'\n       Platform='@Platform@'\n       InstallScope=\"perMachine\"/>\n\n    <Media Id='1' Cabinet='product.cab' EmbedCab='yes' />\n\n    <!-- Upgrade -->\n    <Upgrade Id=\"@UPGRADE_ID@\">\n      <?if '@PATCH_VERSION@' != '0'?>\n      <UpgradeVersion\n        Minimum=\"@MAJOR_VERSION@.@MINOR_VERSION@.0\"\n        IncludeMinimum=\"yes\"\n        Maximum=\"@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@\"\n        IncludeMaximum=\"yes\"\n        Property=\"OLDERVERSIONBEINGUPGRADED\"\n        MigrateFeatures=\"yes\"\n        />\n      <?endif?>\n      <UpgradeVersion\n        Minimum=\"@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@\"\n        IncludeMinimum=\"no\"\n        OnlyDetect=\"yes\"\n        Property=\"NEWERVERSIONDETECTED\" />\n    </Upgrade>\n    <Condition Message=\"A later version of [ProductName] is already installed. Setup will now exit.\">\n      NOT NEWERVERSIONDETECTED OR Installed\n    </Condition>\n    <InstallExecuteSequence>\n      <RemoveExistingProducts After=\"InstallInitialize\"/>\n    </InstallExecuteSequence>\n\n    <?if NOT(\"@Platform@\" = \"x86\") ?>\n      <Property Id=\"VS14REDISTX64\">\n        <RegistrySearch Id=\"FindRedistVS14\"\n            Win64=\"no\"\n            Root=\"HKLM\"\n            Key=\"SOFTWARE\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\x64\"\n            Name=\"Version\"\n            Type=\"raw\" />\n      </Property>\n      <Condition Message=\"This application requires Visual Studio 2015 x64 Redistributable. Please install the Redistributable then run this installer again.\">\n        Installed OR VS14REDISTX64\n      </Condition>\n    <?endif?>\n    <?if \"@Platform@\" = \"x86\" ?>\n      <Property Id=\"VS12REDISTX86\">\n        <RegistrySearch Id=\"FindRedistVS14\"\n            Win64=\"no\"\n            Root=\"HKLM\"\n            Key=\"SOFTWARE\\Microsoft\\VisualStudio\\14.0\\VC\\Runtimes\\x86\"\n            Name=\"Version\"\n            Type=\"raw\" />\n      </Property>\n      <Condition Message=\"This application requires Visual Studio 2015 x86 Redistributable. Please install the Redistributable then run this installer again.\">\n        Installed OR VS14REDISTX86\n      </Condition>\n    <?endif?>\n\n    <!-- Save/restore install location -->\n    <CustomAction Id=\"SaveTargetDir\" Property=\"ARPINSTALLLOCATION\" Value=\"[INSTALLDIR]\" />\n    <InstallExecuteSequence>\n      <Custom Action=\"SaveTargetDir\" After=\"InstallValidate\">\n        NOT\n        Installed\n      </Custom>\n    </InstallExecuteSequence>\n    <InstallUISequence>\n      <!-- App search is what does FindInstallLocation, and it is dependent on FindRelatedProducts -->\n      <AppSearch After=\"FindRelatedProducts\"/>\n    </InstallUISequence>\n\n    <!-- Find previous installation -->\n    <Property Id=\"INSTALLDIR\">\n      <RegistrySearch Id=\"FindInstallLocation\"\n          Root=\"HKLM\"\n          @Win64@\n          Key=\"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\[OLDERVERSIONBEINGUPGRADED]\"\n          Name=\"InstallLocation\"\n          Type=\"raw\" />\n    </Property>\n    <Property Id=\"OLDERVERSION\">\n      <RegistrySearch Id=\"FindOlderVersion\"\n        Root=\"HKLM\"\n        @Win64@\n        Key=\"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\[OLDERVERSIONBEINGUPGRADED]\"\n        Name=\"DisplayVersion\"\n        Type=\"raw\" />\n    </Property>\n    <Property Id=\"INSTALLDIR2\">\n       <RegistrySearch Id=\"FindInstallLocation2\"\n          Root=\"HKLM\"\n          Key=\"SOFTWARE\\MySQL AB\\[ProductName]\"\n          Name=\"Location\"\n          Type=\"raw\" />\n    </Property>\n    <CustomAction Id=\"SetInstallDir2\" Property=\"INSTALLDIR\" Value=\"[INSTALLDIR2]\" />\n    <InstallUISequence>\n    <Custom Action=\"SetInstallDir2\" After=\"AppSearch\">INSTALLDIR2</Custom>\n    </InstallUISequence>\n\n\n    <!-- UI -->\n    <Property Id=\"WIXUI_INSTALLDIR\" Value=\"INSTALLDIR\"></Property>\n    <UIRef Id=\"@CPACK_WIX_UI@\" />\n    <UIRef Id=\"WixUI_ErrorProgressText\" />\n    <WixVariable\n      Id=\"WixUIBannerBmp\"\n      Value=\"@CMAKE_CURRENT_SOURCE_DIR@/AdminHeader.jpg\" />\n    <WixVariable\n      Id=\"WixUIDialogBmp\"\n      Value=\"@CMAKE_CURRENT_SOURCE_DIR@/AdminBackground.jpg\" />\n    <Icon\n      Id=\"icon.ico\"\n      SourceFile=\"@CMAKE_CURRENT_SOURCE_DIR@/MySQLRouter.ico\"/>\n    <Property\n      Id=\"ARPPRODUCTICON\"\n      Value=\"icon.ico\" />\n\n    <!-- License -->\n    <WixVariable\n      Id=\"WixUILicenseRtf\"\n      Value=\"@COPYING_RTF@\"/>\n\n    <!-- How to remove the service on uninstall -->\n    <Binary Id='wixca.dll' SourceFile='@WIXCA_LOCATION@' />\n    <CustomAction Id=\"UnregisterProperty\" Property=\"UnregisterService\" Value=\"[INSTALLDIR]\" Return=\"check\" />\n    <CustomAction Id=\"RunPostInstallProperty\" Property=\"RunPostInstall\" Value=\"[INSTALLDIR]\" Return=\"check\" />\n    <CustomAction Id=\"UnregisterPropertySilent\" Property=\"UnregisterServiceSilently\" Value=\"[INSTALLDIR]\" Return=\"check\" />\n    <CustomAction Id=\"UnregisterService\"\n                  BinaryKey=\"wixca.dll\"\n                  DllEntry=\"RemoveService\"\n                  Execute=\"deferred\"\n                  Impersonate=\"no\"\n                  Return=\"check\" />\n    <CustomAction Id=\"UnregisterServiceSilently\"\n                  BinaryKey=\"wixca.dll\"\n                  DllEntry=\"RemoveServiceNoninteractive\"\n                  Execute=\"deferred\"\n                  Impersonate=\"no\"\n                  Return=\"check\" />\n    <CustomAction Id=\"RunPostInstall\"\n                  BinaryKey=\"wixca.dll\"\n                  DllEntry=\"RunPostInstall\"\n                  Execute=\"deferred\"\n                  Impersonate=\"no\"\n                  Return=\"asyncWait\" />\n    <CustomAction Id=\"InstallDefaultConfigFile\"\n                  BinaryKey=\"wixca.dll\"\n                  DllEntry=\"InstallDefaultConfigFile\"\n                  Execute=\"deferred\"\n                  Impersonate=\"no\"\n                  Return=\"check\" />\n    <CustomAction Id=\"RegisterService\"\n                  BinaryKey=\"wixca.dll\"\n                  DllEntry=\"InstallService\"\n                  Execute=\"deferred\"\n                  Impersonate=\"no\"\n                  Return=\"check\" />                  \n    <SetProperty Id=\"InstallDefaultConfigFile\" Value=\"INSTALLDIR=[INSTALLDIR];DATADIR=[CommonAppDataFolder]MySQL\\@PRODUCT_NAME@\" Sequence=\"execute\" Before=\"InstallDefaultConfigFile\"/>\n    <SetProperty Id=\"RegisterService\" Value=\"INSTALLDIR=[INSTALLDIR];DATADIR=[CommonAppDataFolder]MySQL\\@PRODUCT_NAME@\" Sequence=\"execute\" Before=\"InstallDefaultConfigFile\"/>\n    <InstallExecuteSequence>\n      <Custom Action=\"UnregisterProperty\" After=\"InstallInitialize\">Installed And Not UPGRADINGPRODUCTCODE And REMOVE=\"ALL\"</Custom>\n      <Custom Action=\"UnregisterPropertySilent\" After=\"InstallInitialize\">Installed And Not UPGRADINGPRODUCTCODE And REMOVE=\"ALL\"</Custom>\n      <Custom Action=\"UnregisterService\" After=\"UnregisterProperty\">Installed And Not UPGRADINGPRODUCTCODE And REMOVE=\"ALL\" And UILevel&gt;4</Custom>\n      <Custom Action=\"UnregisterServiceSilently\" After=\"UnregisterPropertySilent\">Installed And Not UPGRADINGPRODUCTCODE And REMOVE=\"ALL\" And UILevel&lt;=4</Custom>\n      <Custom Action=\"RunPostInstallProperty\" After=\"InstallFiles\">NOT(REMOVE=\"ALL\")</Custom>\n      <Custom Action=\"InstallDefaultConfigFile\" After=\"RunPostInstallProperty\">NOT(REMOVE=\"ALL\")</Custom>\n      <Custom Action=\"RegisterService\" After=\"InstallDefaultConfigFile\">NOT(REMOVE=\"ALL\")</Custom>\n      <Custom Action=\"RunPostInstall\" After=\"RunPostInstallProperty\">NOT(REMOVE=\"ALL\")</Custom>\n    </InstallExecuteSequence>\n\n    <!-- Installation root-->\n    <Directory Id='TARGETDIR' Name='SourceDir'>\n      <Directory Id='@PlatformProgramFilesFolder@'>\n        <Directory Id='directory.MySQL' Name='MySQL'>\n          <Directory Id='INSTALLDIR' Name='@PRODUCT_NAME@ @MAJOR_VERSION@.@MINOR_VERSION@'>\n            <Directory Id='DOCDIR' Name='doc' />\n          </Directory>\n        </Directory>\n      </Directory>\n    </Directory>\n\n  <!-- Add documentation files to the installation -->\n  <DirectoryRef Id=\"DOCDIR\">\n    <Component Id=\"License.txt\" @Win64@ Guid=\"{9A064A62-989C-4076-B995-E10453CC6BAB}\">\n        <File Id=\"License.txt\" Source=\"@CMAKE_CURRENT_SOURCE_DIR@\\..\\..\\License.txt\" KeyPath=\"yes\"/>\n    </Component>\n    <Component Id=\"README.txt\" @Win64@ Guid=\"{24109AC5-CF9A-465D-8B07-861654F5475A}\">\n        <File Id=\"README.txt\" Source=\"@CMAKE_CURRENT_SOURCE_DIR@\\..\\..\\README.txt\" KeyPath=\"yes\"/>\n    </Component>\n  </DirectoryRef>\n\n  <Feature Id=\"Documentation\" Title=\"MySQL Router Documentation Files\" Display=\"hidden\" Level=\"1\">\n     <ComponentRef Id=\"License.txt\" />\n     <ComponentRef Id=\"README.txt\" />\n  </Feature>\n\n    <!-- CPACK_WIX_FEATURES -->\n    @CPACK_WIX_FEATURES@\n\n    <!-- CPACK_WIX_DIRECTORIES -->\n    @CPACK_WIX_DIRECTORIES@\n\n    <!--CPACK_WIX_COMPONENTS-->\n    @CPACK_WIX_COMPONENTS@\n\n    <!--CPACK_WIX_COMPONENTS_GROUPS -->\n    @CPACK_WIX_COMPONENT_GROUPS@\n\n    <!--CPACK_WIX_INCLUDES -->\n    @CPACK_WIX_INCLUDES@\n  </Product>\n\n</Wix>\n"
  },
  {
    "path": "packaging/WiX/mysql_router_extra.wxs.in",
    "content": "<Include xmlns=\"http://schemas.microsoft.com/wix/2006/wi\"\n         xmlns:util=\"http://schemas.microsoft.com/wix/UtilExtension\">\n\n<!--\n   Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License as published by\n   the Free Software Foundation; version 2 of the License.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; if not, write to the Free Software\n   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n-->\n    <!-- Registry -->\n    <!-- We still use \"MySQL AB\" because we don't want to break software that expects it -->\n    <DirectoryRef Id='TARGETDIR'>\n    <Component Id=\"RegKeys\" Guid=\"*\">\n      <RegistryKey\n        Id='MySQLRouterKey'\n        Root='HKLM'\n        Key='SOFTWARE\\MySQL AB\\[ProductName]'\n        Action='createAndRemoveOnUninstall'>\n        <RegistryValue\n          Type='string'\n          Name='Location'\n          Value='[INSTALLDIR]'/>\n        <RegistryValue\n          Type=\"string\"\n          Name=\"Version\"\n          Value=\"[ProductVersion]\"/>\n        <RegistryValue\n          Type=\"string\"\n          Name=\"DataLocation\"\n          Value=\"[DATADIR]\"/>\n      </RegistryKey>\n    </Component>\n    </DirectoryRef>\n    <Feature\n    Id='RegKeys'\n    Display='hidden'\n    Level='1'>\n    <ComponentRef Id='RegKeys'/>\n    </Feature>\n\n    </Include>\n"
  },
  {
    "path": "packaging/WiX/mysqlrouter.conf.in",
    "content": "# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA\n\n#\n# MySQL Router configuration file\n#\n# Documentation is available at\n#    http://dev.mysql.com/doc/mysql-router/en/\n\n[DEFAULT]\nlogging_folder = %PROGRAMDATA_FOLDER%\nplugin_folder = %INSTALL_FOLDER%/lib\nruntime_folder = %PROGRAMDATA_FOLDER%\nconfig_folder = %PROGRAMDATA_FOLDER%\n\n[logger]\nlevel = INFO\n\n# If no plugin is configured which starts a service, keepalive\n# will make sure MySQL Router will not immediately exit. It is\n# safe to remove once Router is configured.\n[keepalive]\ninterval = 60\n"
  },
  {
    "path": "packaging/WiX/versioninfo.rc.in",
    "content": "// Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.\n// \n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; version 2 of the License.\n// \n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n// \n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n\n#include <windows.h>\nPROJECT_VERSION_VS_INFO VERSIONINFO\nFILEVERSION     @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,0\nPRODUCTVERSION  @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,0\nFILEFLAGSMASK   VS_FFI_FILEFLAGSMASK\nFILEFLAGS       0\nFILEOS          VOS__WINDOWS32\nFILETYPE        VFT_DLL\nFILESUBTYPE     VFT2_UNKNOWN\nBEGIN\n    BLOCK \"StringFileInfo\"\n    BEGIN\n        BLOCK \"040904E4\"\n        BEGIN\n            VALUE \"FileVersion\",      \"@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@.0\\0\"\n            VALUE \"ProductVersion\",   \"@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@.0\\0\"\n        END\n    END\n    BLOCK \"VarFileInfo\"\n    BEGIN\n        VALUE \"Translation\", 0x409, 1252\n    END\nEND\n"
  },
  {
    "path": "packaging/build_deb.sh",
    "content": "#!/bin/sh\n\n# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA\n\n# When no arguments are given, show some help\nif [ $# -eq 0 ]; then\n  echo \"Usage: `basename $0` /path/to/mysql-router-2.0.0.tar.gz <debuild arguments>\"\n  exit 0\nfi\n\nDEFAULT_DEBUILD_ARGS=\"-us -uc\"  # no signing\n\nME=$0\nSOURCETAR=$1\nshift\nDEBUILDARGS=${@:-$DEFAULT_DEBUILD_ARGS}\nWORKDIR=`pwd`/DebianBuild\nLOG=$WORKDIR/debuild.log\n\nif [ \"$SOURCETAR\" = \"\" ] || [ ! -f $SOURCETAR ]; then\n  echo \"Source TAR archive not available\"\n  exit 1\nfi\nSOURCETAR=`realpath $SOURCETAR`\nREPODIR=`dirname $ME`/..\nREPODIR=`realpath $REPODIR`\n\n# Check if we are where we are supposed to be\nif [ ! -f $REPODIR/src/router/src/router_app.cc ]; then\n  echo \"This script is supposed to run within the MySQL Router source repository.\"\n  exit 1\nfi\n\n# Get and check support for Debian/Ubuntu release support\nDEBCODE=`lsb_release -c -s`\nif [ $? -ne 0 ]; then\n  echo \"Failed getting relesae information. Make sure lsb_release is avialable.\"\n  exit 1\nfi\nDEBCOMMONDIR=$REPODIR/packaging/deb-common\nDEBINFODIR=$REPODIR/packaging/deb-$DEBCODE\nif [ ! -d $DEBINFODIR ]; then\n  echo \"Debian/Ubuntu with code name $DEBINFODIR is not supported.\"\n  exit 1\nfi\n\necho \"Using source TAR: $SOURCETAR\"\n\nORIGDIR=`pwd`\nrm -Rf $WORKDIR\nmkdir $WORKDIR\ncd $WORKDIR\n\n# Rename source TAR to comply to Debian standards\ncp $SOURCETAR .\nTARBASE=`basename $SOURCETAR .tar.gz`\nVERSION=${TARBASE##*-}\nPKGNAME=${TARBASE%%-$VERSION*}\n\nDEBSRCTAR=${PKGNAME}_$VERSION.orig.tar.gz\nmv $TARBASE.tar.gz $DEBSRCTAR\necho \"Renamed TAR to $DEBSRCTAR\"\n\n# Unpack Source and copy the appropriated Debian package files as well as common files\ntar xzf $DEBSRCTAR\ncp -a $DEBCOMMONDIR $TARBASE/debian\ncp -a $DEBINFODIR/* $TARBASE/debian/\necho \"Copied `basename $DEBINFODIR`\"\n\n# Build Debian package\ncd $TARBASE\nif [ ! -f debian/rules ]; then\n  echo \"Wrong location: can not start debuild (in `pwd`)\"\n  exit 1\nfi\necho \"Process logged to $LOG\"\necho \"Building package using 'debuild $DEBUILDARGS'..\"\ndebuild $DEBUILDARGS 2>$LOG 1>&2\nif [ $? -ne 0 ]; then\n  tail -n30 $LOG\nelse\n  lintian=`sed -ne '1,/^Now running lintian...\\$/d; /Finished running lintian.\\$/,\\$ d; p' $LOG`\n\n  if [ -n \"$lintian\" ]; then\n    echo\n    echo \"Lintian errors and warnings\"\n    echo \"---------------------------\"\n    echo \"$lintian\"\n    echo\n  fi\n\n  echo \"Debian packages:\"\n  for debfile in `ls $WORKDIR/*.deb`; do\n    cp -a $debfile $ORIGDIR\n    echo \"`basename $debfile`\"\n  done\nfi\n"
  },
  {
    "path": "packaging/build_rpm.sh",
    "content": "#!/bin/sh\n\n# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA\n\n# Show some help\nif [ \"$1\" == \"--help\" ]; then\n  echo \"Usage: `basename $0` [--commercial] <rpmbuild arguments>\"\n  exit 0\nfi\n\nDEFAULT_RPMBUILD_ARGS=\"-ba\"\n\nME=$0\nCOM=0\nGPL=1\nif [ \"$1\" == \"--commercial\" ]; then\n  COM=1\n  GPL=0\nfi\nshift\nRPMBUILDARGS=${@:-$DEFAULT_RPMBUILD_ARGS}\n\ncmake .. -DGPL=${GPL}\nmake package_source\nSPEC=\"mysql-router.spec\"\n\nif [ ! -f ./$SPEC ]; then\n  echo \"Spec file not available.\"\n  exit 1\nfi\n\nWORKDIR=`pwd`/RPMBuild\nLOG=${WORKDIR}/rpmbuild.log\n\nif [ $COM -eq 1 ]; then\n  SOURCETAR=`ls mysql-router-commercial*.tar.gz`\nelse\n  SOURCETAR=`ls mysql-router-*.tar.gz`\nfi\n\nif [ \"${SOURCETAR}\" = \"\" ] || [ ! -f ${SOURCETAR} ]; then\n  echo \"Source TAR archive not available\"\n  exit 1\nfi\n\nif [ ! -d ../mysql-server ]; then\n  echo \"MySQL Server not available in ../mysql-server\"\n  exit 1\nfi\nMYSQL_SERVER=`realpath ../mysql-server`\necho \"Using MySQL libraries from ${MYSQL_SERVER}\"\n\nSOURCETAR=`realpath ${SOURCETAR}`\nREPODIR=`dirname ${ME}`/..\nREPODIR=`realpath ${REPODIR}`\n\nset -e\n\necho \"Preparing workdir\"\nrm -Rf ${WORKDIR}\nmkdir -p ${WORKDIR}/{SOURCES,BUILD,SPECS,RPMS,SRPMS}\n\necho \"Copying spec file(s)\"\ncp -a ${SPEC} ${WORKDIR}/SPECS\n\necho \"Copying source files $SOURCETAR\"\ncp -a $SOURCETAR ${WORKDIR}/SOURCES\ncp -a packaging/rpm-oel/mysqlrouter.* ${WORKDIR}/SOURCES\n\nrpmbuild -v --define=\"_topdir ${WORKDIR}\" --define=\"with_mysql ${MYSQL_SERVER}\" \\\n  --define=\"_tmppath ${WORKDIR}\" --define=\"commercial $COM\" ${RPMBUILDARGS} ${SPEC}\n\nmv ${WORKDIR}/RPMS/*.rpm .\nmv ${WORKDIR}/SRPMS/*.rpm .\n\nset +e\n\n\n"
  },
  {
    "path": "packaging/deb-artful/changelog",
    "content": "mysql-router (8.0.12-1ubuntu17.10) artful; urgency=low\n\n  * For release notes, please refer to https://dev.mysql.com/doc/relnotes/mysql-router/en/changes-8.0.x.html\n\n -- MySQL Release Engineering <mysql-build@oss.oracle.com>  Tue, 13 Mar 2018 10:36:55 +0200\n"
  },
  {
    "path": "packaging/deb-artful/control",
    "content": "Source: mysql-router\nMaintainer: MySQL Release Engineering <mysql-build@oss.oracle.com>\nSection: database\nPriority: optional\nStandards-Version: 3.9.6\nHomepage: http://www.mysql.com/\nBuild-Depends: cmake,\n debhelper (>= 9.0.0),\n dh-apparmor,\n fakeroot, lsb-release\n\nPackage: mysql-router\nArchitecture: any\nPre-Depends: debconf, adduser\nDepends: ${misc:Depends}, ${shlibs:Depends}\nDescription: MySQL Router\n The MySQL(TM) Router software delivers a fast, multi-threaded way of\n routing connections from MySQL Clients to MySQL Servers. MySQL is a\n trademark of Oracle.\n\nPackage: mysql-router-dev\nArchitecture: any\nDepends: ${misc:Depends}, ${shlibs:Depends}\nDescription: MySQL Router development files\n The MySQL(TM) Router software delivers a fast, multi-threaded way of\n routing connections from MySQL Clients to MySQL Servers. MySQL is a\n trademark of Oracle.\n"
  },
  {
    "path": "packaging/deb-bionic/changelog",
    "content": "mysql-router (8.0.12-1ubuntu18.04) bionic; urgency=low\n\n  * For release notes, please refer to https://dev.mysql.com/doc/relnotes/mysql-router/en/changes-8.0.x.html\n\n -- MySQL Release Engineering <mysql-build@oss.oracle.com>  Tue, 13 Mar 2018 10:36:55 +0200\n"
  },
  {
    "path": "packaging/deb-bionic/control",
    "content": "Source: mysql-router\nMaintainer: MySQL Release Engineering <mysql-build@oss.oracle.com>\nSection: database\nPriority: optional\nStandards-Version: 3.9.6\nHomepage: http://www.mysql.com/\nBuild-Depends: cmake,\n debhelper (>= 9.0.0),\n dh-apparmor,\n fakeroot, lsb-release\n\nPackage: mysql-router\nArchitecture: any\nPre-Depends: debconf, adduser\nDepends: ${misc:Depends}, ${shlibs:Depends}\nDescription: MySQL Router\n The MySQL(TM) Router software delivers a fast, multi-threaded way of\n routing connections from MySQL Clients to MySQL Servers. MySQL is a\n trademark of Oracle.\n\nPackage: mysql-router-dev\nArchitecture: any\nDepends: ${misc:Depends}, ${shlibs:Depends}\nDescription: MySQL Router development files\n The MySQL(TM) Router software delivers a fast, multi-threaded way of\n routing connections from MySQL Clients to MySQL Servers. MySQL is a\n trademark of Oracle.\n"
  },
  {
    "path": "packaging/deb-common/compat",
    "content": "9"
  },
  {
    "path": "packaging/deb-common/copyright",
    "content": "Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/\nUpstream-Name: MySQL Router 8.0\nUpstream-Contact: MySQL Release Engineering <mysql-build@oss.oracle.com>\nSource: http://dev.mysql.com/\n\nFiles: *\nCopyright: 2015, 2017, Oracle and/or its affiliates. All rights reserved.\nLicense: GPL-2\n This is a release of MySQL Router, release dual-licensed.\n For the avoidance of doubt, this particular copy of the software\n is released under the version 2 of the GNU General Public License.\n MySQL Router is brought to you by Oracle.\n .\n This distribution may include materials developed by third\n parties. For license and attribution notices for these\n materials, please refer to the documentation that accompanies\n this distribution (see the \"Licenses for Third-Party Components\"\n appendix) or view the online documentation at\n <http://dev.mysql.com/doc/>.\n .\n GPLv2 Disclaimer\n For the avoidance of doubt, except that if any license choice\n other than GPL or LGPL is available it will apply instead,\n Oracle elects to use only the General Public License version 2\n (GPLv2) at this time for any software where a choice of GPL\n license versions is made available with the language indicating\n that GPLv2 or any later version may be used, or where a choice\n .\n The full text of the GNU General Public License version 2 can\n be found in the file\n `/usr/share/mysqlrouter/License.txt'.\n"
  },
  {
    "path": "packaging/deb-common/extra/apparmor-profile.in",
    "content": "# vim:syntax=apparmor\n\n#include <tunables/global>\n\n/usr/bin/mysqlrouter {\n  #include <abstractions/base>\n  #include <abstractions/nameservice>\n  #include <abstractions/user-tmp>\n\n# Allow system resource access\n  /sys/devices/system/cpu/ r,\n  capability sys_resource,\n  capability dac_override,\n  capability setuid,\n  capability setgid,\n  capability chown,\n  capability fowner,\n\n# Allow config access\n  /etc/mysqlrouter/** rw,\n  /var/lib/mysqlrouter/keyring rw,\n\n# Allow runtime files such as PID-file\n  /var/run/mysqlrouter/mysqlrouter.pid rw,\n\n# Allow read/ write to /tmp\n  /tmp/ r,\n  /tmp/* rw,\n\n# Allow execution of MySQL Router binary\n  /usr/bin/mysqlrouter mr,\n\n# Allow plugin access\n  /usr/lib/@DEB_HOST_MULTIARCH@/mysqlrouter/*.so mr,\n\n# Allow log file access\n  /var/log/mysqlrouter/ rw,\n  /var/log/mysqlrouter/** rw,\n}\n"
  },
  {
    "path": "packaging/deb-common/extra/mysqlrouter.conf.in",
    "content": "# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA\n\n#\n# MySQL Router configuration file for Debian/Ubuntu\n#\n# Documentation is available at\n#    http://dev.mysql.com/doc/mysql-router/en/\n\n[DEFAULT]\nlogging_folder = /var/log/mysqlrouter/\nplugin_folder = /usr/lib/@DEB_HOST_MULTIARCH@/mysqlrouter\nruntime_folder = /var/run/mysqlrouter\nconfig_folder = /etc/mysqlrouter\n\n[logger]\nlevel = INFO\n\n# If no plugin is configured which starts a service, keepalive\n# will make sure MySQL Router will not immediately exit. It is\n# safe to remove once Router is configured.\n[keepalive]\ninterval = 60\n"
  },
  {
    "path": "packaging/deb-common/mysql-router-dev.install",
    "content": "# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA\n\nusr/lib/*/libmysqlrouter.so\nusr/lib/*/libmysqlharness.so\nusr/lib/*/libmysqlharness.a\n\nusr/share/mysql-router/docs/License.txt usr/share/doc/mysql-router-dev\nusr/share/mysql-router/docs/README.txt usr/share/doc/mysql-router-dev\n"
  },
  {
    "path": "packaging/deb-common/mysql-router-dev.lintian-overrides",
    "content": "# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA\n\nmysql-router-dev: copyright-should-refer-to-common-license-file-for-lgpl\nmysql-router-dev: extra-license-file usr/share/doc/mysql-router-dev/License.txt.gz\n"
  },
  {
    "path": "packaging/deb-common/mysql-router.install",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA\n\nusr/bin/mysqlrouter\nusr/bin/mysqlrouter_plugin_info\n\nusr/lib/*/libmysqlrouter.so.1\nusr/lib/*/libmysqlharness.so.1\n\nusr/lib/*/mysqlrouter/keepalive.so\nusr/lib/*/mysqlrouter/x_protocol.so\nusr/lib/*/mysqlrouter/mysql_protocol.so\nusr/lib/*/mysqlrouter/syslog.so\nusr/lib/*/mysqlrouter/routing.so\nusr/lib/*/mysqlrouter/metadata_cache.so\n\n\ndebian/extra/mysqlrouter.conf etc/mysqlrouter\netc/apparmor.d/usr.bin.mysqlrouter\n\nusr/share/mysql-router/docs/sample_mysqlrouter.conf usr/share/doc/mysql-router\nusr/share/mysql-router/docs/License.txt usr/share/doc/mysql-router\nusr/share/mysql-router/docs/README.txt usr/share/doc/mysql-router"
  },
  {
    "path": "packaging/deb-common/mysql-router.lintian-overrides",
    "content": "# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA\n\nmysql-router: copyright-should-refer-to-common-license-file-for-lgpl\nmysql-router: package-name-doesnt-match-sonames\nmysql-router: extra-license-file usr/share/doc/mysql-router/License.txt.gz\nmysql-router: maintainer-script-ignores-errors postinst\n\n# We need the RPATH defined in Plugins\nmysql-router: binary-or-shlib-defines-rpath usr/lib/x86_64-linux-gnu/mysqlrouter/metadata_cache.so lib/x86_64-linux-gnu/mysqlrouter\nmysql-router: binary-or-shlib-defines-rpath usr/lib/x86_64-linux-gnu/mysqlrouter/keepalive.so /usr/lib/mysqlrouter\nmysql-router: binary-or-shlib-defines-rpath usr/lib/x86_64-linux-gnu/mysqlrouter/routing.so lib/x86_64-linux-gnu/mysqlrouter\n\n# Documentation is online\nmysql-router: binary-without-manpage usr/bin/mysqlrouter\nmysql-router: binary-without-manpage usr/bin/mysqlrouter_plugin_info\n"
  },
  {
    "path": "packaging/deb-common/mysql-router.mysqlrouter.init",
    "content": "#!/bin/sh\n\n### BEGIN INIT INFO\n# Provides:          mysqlrouter\n# Required-Start:    $remote_fs $syslog\n# Required-Stop:     $remote_fs $syslog\n# Default-Start:     2 3 4 5\n# Default-Stop:      0 1 6\n# Short-Description: Start / Stop MySQL Router\n# Description:       This service script facilitates startup and shutdown of\n#                    MySQL Router.\n### END INIT INFO\n\n# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n#\n# Maintainer: MySQL Release Engineering <mysql-build@oss.oracle.com>\n#\n\n. /lib/lsb/init-functions\n\nDESC=\"Start / Stop MySQL Router\"\nDAEMON=/usr/bin/mysqlrouter\nDAEMON_OPTIONS=\"-c /etc/mysqlrouter/mysqlrouter.conf\"\nNAME=\"MySQL Router\"\nRUNTIMEDIR=/var/run/mysqlrouter/\nPID=${RUNTIMEDIR}/mysqlrouter.pid\nSTOP_RETRY=3\nLOGDIR=/var/log/mysqlrouter\nLOGFILE=${LOGDIR}/mysqlrouter.log\nDATADIR=/var/lib/mysqlrouter\n\ndo_start() {\n\n  local retval=0\n  log_daemon_msg \"Starting MySQL Router\"\n\n  if [ ! -x $DAEMON ]; then\n    log_end_msg 1\n    return 0\n  fi\n\n  if [ ! -d ${RUNTIMEDIR} -a ! -L ${RUNTIMEDIR} ];\n  then\n    install -d -m 0755 -o mysqlrouter -g mysqlrouter ${RUNTIMEDIR}\n  fi\n\n  if [ ! -d ${DATADIR} -a ! -L ${DATADIR} ];\n  then\n    install -d -m 0750 -o mysqlrouter -g mysqlrouter ${DATADIR}\n  fi\n\n  if [ ! -d ${LOGDIR} -a ! -L ${LOGDIR} ];\n  then\n    install -d -m 0750 -o mysqlrouter -g adm ${LOGDIR}\n  fi\n\n  install /dev/null -m 0640 -o mysqlrouter -g adm ${LOGFILE}\n\n  [ -x /lib/init/apparmor-profile-load ] && /lib/init/apparmor-profile-load usr.bin.mysqlrouter\n\n  start-stop-daemon --start \\\n    --pidfile $PID \\\n    --startas $DAEMON \\\n    --oknodo \\\n    --make-pidfile \\\n    --background \\\n    --chuid mysqlrouter \\\n    -- $DAEMON_OPTIONS 2>/dev/null\n  retval=$?\n\n  case $retval in\n    0) log_end_msg 0 ;;\n    1)\n      log_warning_msg \"already running\"\n      log_end_msg 0\n      ;;\n    2) log_end_msg 1 ;;  # failure\n  esac\n\n  return $retval\n}\n\ndo_stop() {\n  local retval\n\n  log_daemon_msg \"Stopping $NAME\"\n\n  if [ ! -x $DAEMON ]; then\n    log_end_msg 1\n    return 0\n  fi\n\n  start-stop-daemon --stop \\\n    --pidfile $PID \\\n    --startas $DAEMON \\\n    --quiet \\\n    --retry=$STOP_RETRY\n  retval=$?\n\n  case $retval in\n    0)\n      log_end_msg 0\n      ;;\n    1)\n      log_warning_msg \"not running\"\n      log_end_msg 255\n      ;;\n    *) log_end_msg 1 ;;\n  esac\n\n  return $retval\n}\n\ndo_status() {\n  status_of_proc -p $PID $DAEMON \"$NAME\"\n}\n\ncase \"$1\" in\n  start)\n    do_start\n    ;;\n  status)\n    do_status\n    ;;\n  restart|force-reload)\n    do_stop\n    sleep 1\n    do_start\n    ;;\n  stop)\n    do_stop\n    sleep 1\n    ;;\n  *)\n    >2& echo \"Usage: /etc/init.d/mysqlrouter {start|stop|status|restart|force-reload}\"\n    exit 3\nesac\n"
  },
  {
    "path": "packaging/deb-common/mysql-router.postinst",
    "content": "#!/bin/sh\n\n# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA\n\n. /usr/share/debconf/confmodule\n\ncase \"$1\" in\n  configure)\n    set -e\n    ldconfig\n    set +e\n    ;;\n\n  abort-remove)\n    ;;\n\n  abort-upgrade|abort-configure)\n    ;;\nesac\n\n#DEBHELPER#\n\nexit 0\n"
  },
  {
    "path": "packaging/deb-common/mysql-router.postrm",
    "content": "#!/bin/sh\n\n# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA\n\n. /usr/share/debconf/confmodule\n\nremove_dirs_from_var() {\n  RUNTIMEDIR=/var/run/mysqlrouter\n  DATADIR=/var/lib/mysqlrouter\n  LOGDIR=/var/log/mysqlrouter\n\n  if [ -d ${RUNTIMEDIR} -o -L ${RUNTIMEDIR} ]; then\n    rm -fr ${RUNTIMEDIR}\n  fi\n\n  if [ -d ${DATADIR} -o -L ${DATADIR} ]; then\n    rm -fr ${DATADIR}\n  fi\n\n  if [ -d ${LOGDIR} -o -L ${LOGDIR} ]; then\n    rm -fr ${LOGDIR}\n  fi\n}\n\ncase \"$1\" in\n  remove)\n    ;;\n  purge)\n    set -e\n    db_purge\n\n    # Router stuff in /etc gets automatically removed, but stuff in /var we have\n    # to remove ourselves\n    remove_dirs_from_var\n\n    set +e\n    ;;\nesac\n\n#DEBHELPER#\n\nexit 0\n"
  },
  {
    "path": "packaging/deb-common/mysql-router.preinst",
    "content": "#!/bin/sh\n\n# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA\n\n. /usr/share/debconf/confmodule\n\nLOGDIR=/var/log/mysqlrouter\nMYSQLROUTERHOME=/var/lib/mysqlrouter\nLOGFILE=${MYSQLLOGDIR}/mysqlrouter.log\n\nfix_permissions_for_var_run() {\n\n  # This directory had different owner and permissions in older versions of Router,\n  # which may cause problems, therefore we reset them here if the directory exists.\n  RUNTIMEDIR=/var/run/mysqlrouter\n  if [ -d ${RUNTIMEDIR} ]; then\n    install -d -m 0755 -o mysqlrouter -g mysqlrouter ${RUNTIMEDIR}\n  fi\n}\n\ncase \"$1\" in\n  install)\n\n    set -e\n\n    if [ -x /etc/init.d/mysqlrouter ]; then\n      invoke-rc.d mysqlrouter stop || exit $?\n    fi\n\n    addgroup --quiet --system mysqlrouter\n    adduser --quiet --system --ingroup mysqlrouter --disabled-login --home ${MYSQLROUTERHOME} --shell /bin/false \\\n      --gecos \"MySQL Router\" mysqlrouter\n\n    if [ ! -d $LOGDIR ] && [ ! -L $LOGDIR ]; then\n      install -d -m 0750 -o mysqlrouter -g adm ${LOGDIR}\n    fi\n    install /dev/null -m 0640 -o mysqlrouter -g adm ${LOGFILE}\n\n    fix_permissions_for_var_run\n\n    set +e\n    ;;\n\n  upgrade)\n    set -e\n\n    fix_permissions_for_var_run\n\n    #DEBHELPER#\n\n    set +e\n    ;;\nesac\n\nexit 0\n"
  },
  {
    "path": "packaging/deb-common/mysql-router.prerm",
    "content": "#!/bin/sh\n\n# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA\n\nset -e\n\ncase \"$1\" in\n  remove)\n    ;;\n\n  abort-upgrade|abort-remove|abort-configure)\n    ;;\nesac\n\t\n\n#DEBHELPER#\n\nset +e\n\nexit 0\n"
  },
  {
    "path": "packaging/deb-common/rules",
    "content": "#!/usr/bin/make -f\n\n# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA\n\n%:\n\tdh $@\n\nexport DH_VERBOSE=1\nexport CFLAGS=\nexport CXXFLAGS=\n\noverride_dh_auto_configure:\n\t@echo \"RULES.$@\"\n\tsed 's/@DEB_HOST_MULTIARCH@/$(DEB_HOST_MULTIARCH)/g' \\\n\t\tdebian/extra/mysqlrouter.conf.in > debian/extra/mysqlrouter.conf\n\tsed 's/@DEB_HOST_MULTIARCH@/$(DEB_HOST_MULTIARCH)/g' \\\n\t\tdebian/extra/apparmor-profile.in > debian/extra/apparmor-profile\n\tcmake . \\\n\t\t-DCMAKE_INSTALL_PREFIX=/usr \\\n\t\t-DROUTER_CONFIGDIR=/etc/mysqlrouter \\\n\t\t-DPROJECT_EDITION=\"GPL community edition\" \\\n\t\t-DINSTALL_LAYOUT=\"DEB\" \\\n\t\t-DWITH_STATIC=yes \\\n\t\t-DENABLE_TESTS=yes -DENABLE_GCOV=yes\n\ttouch $@\n\noverride_dh_auto_build:\n\t@echo \"RULES.$@\"\n\t$(MAKE) -j8\n\ttouch $@\n\noverride_dh_auto_test:\n\t@echo \"RULES.$@\"\n\t$(MAKE) test || true\n\ttouch $@\n\noverride_dh_auto_install:\n\t@echo \"RULES.$@\"\n\tdh_auto_install --destdir=debian/tmp\n\tinstall -g root -o root -m 0644 -D debian/extra/apparmor-profile \\\n\t\tdebian/tmp/etc/apparmor.d/usr.bin.mysqlrouter\n\ttouch $@\n\noverride_dh_installinit:\n\t@echo \"RULES.$@\"\n\tdh_apparmor -pmysql-router --profile-name=usr.bin.mysqlrouter\n\tdh_installinit --name=mysqlrouter -u\"defaults 19 21\"\n\ttouch $@\n\noverride_dh_install:\n\tdh_install --fail-missing\n"
  },
  {
    "path": "packaging/deb-common/source/format",
    "content": "3.0 (quilt)"
  },
  {
    "path": "packaging/deb-jessie/changelog",
    "content": "mysql-router (8.0.12-1debian8) jessie; urgency=low\n\n  * For release notes, please refer to https://dev.mysql.com/doc/relnotes/mysql-router/en/changes-8.0.x.html\n\n -- MySQL Release Engineering <mysql-build@oss.oracle.com>  Tue, 13 Mar 2018 10:36:55 +0200\n"
  },
  {
    "path": "packaging/deb-jessie/control",
    "content": "Source: mysql-router\nMaintainer: MySQL Release Engineering <mysql-build@oss.oracle.com>\nSection: database\nPriority: optional\nStandards-Version: 3.9.6\nHomepage: http://www.mysql.com/\nBuild-Depends: cmake,\n debhelper (>= 9.0.0),\n dh-apparmor,\n fakeroot, lsb-release\n\nPackage: mysql-router\nArchitecture: any\nPre-Depends: debconf, adduser\nDepends: ${misc:Depends}, ${shlibs:Depends}\nDescription: MySQL Router\n The MySQL(TM) Router software delivers a fast, multi-threaded way of\n routing connections from MySQL Clients to MySQL Servers. MySQL is a\n trademark of Oracle.\n\nPackage: mysql-router-dev\nArchitecture: any\nDepends: ${misc:Depends}, ${shlibs:Depends}\nDescription: MySQL Router development files\n The MySQL(TM) Router software delivers a fast, multi-threaded way of\n routing connections from MySQL Clients to MySQL Servers. MySQL is a\n trademark of Oracle.\n"
  },
  {
    "path": "packaging/deb-stretch/changelog",
    "content": "mysql-router (8.0.12-1debian9) stretch; urgency=low\n\n  * For release notes, please refer to https://dev.mysql.com/doc/relnotes/mysql-router/en/changes-8.0.x.html\n\n -- MySQL Release Engineering <mysql-build@oss.oracle.com>  Tue, 13 Mar 2018 10:36:55 +0200\n"
  },
  {
    "path": "packaging/deb-stretch/control",
    "content": "Source: mysql-router\nMaintainer: MySQL Release Engineering <mysql-build@oss.oracle.com>\nSection: database\nPriority: optional\nStandards-Version: 3.9.6\nHomepage: http://www.mysql.com/\nBuild-Depends: cmake,\n debhelper (>= 9.0.0),\n dh-apparmor,\n fakeroot, lsb-release\n\nPackage: mysql-router\nArchitecture: any\nPre-Depends: debconf, adduser\nDepends: ${misc:Depends}, ${shlibs:Depends}\nDescription: MySQL Router\n The MySQL(TM) Router software delivers a fast, multi-threaded way of\n routing connections from MySQL Clients to MySQL Servers. MySQL is a\n trademark of Oracle.\n\nPackage: mysql-router-dev\nArchitecture: any\nDepends: ${misc:Depends}, ${shlibs:Depends}\nDescription: MySQL Router development files\n The MySQL(TM) Router software delivers a fast, multi-threaded way of\n routing connections from MySQL Clients to MySQL Servers. MySQL is a\n trademark of Oracle.\n"
  },
  {
    "path": "packaging/deb-trusty/changelog",
    "content": "mysql-router (8.0.12-1ubuntu14.04) trusty; urgency=low\n\n  * For release notes, please refer to https://dev.mysql.com/doc/relnotes/mysql-router/en/changes-8.0.x.html\n\n -- MySQL Release Engineering <mysql-build@oss.oracle.com>  Tue, 13 Mar 2018 10:36:55 +0200\n"
  },
  {
    "path": "packaging/deb-trusty/control",
    "content": "Source: mysql-router\nMaintainer: MySQL Release Engineering <mysql-build@oss.oracle.com>\nSection: database\nPriority: optional\nStandards-Version: 3.9.5\nHomepage: http://www.mysql.com/\nBuild-Depends: cmake,\n debhelper (>= 9.0.0),\n dh-apparmor,\n fakeroot, lsb-release\n\nPackage: mysql-router\nArchitecture: any\nPre-Depends: debconf, adduser\nDepends: ${misc:Depends}, ${shlibs:Depends}\nDescription: MySQL Router\n The MySQL(TM) Router software delivers a fast, multi-threaded way of\n routing connections from MySQL Clients to MySQL Servers. MySQL is a\n trademark of Oracle.\n\nPackage: mysql-router-dev\nArchitecture: any\nDepends: ${misc:Depends}, ${shlibs:Depends}\nDescription: MySQL Router development files\n The MySQL(TM) Router software delivers a fast, multi-threaded way of\n routing connections from MySQL Clients to MySQL Servers. MySQL is a\n trademark of Oracle.\n"
  },
  {
    "path": "packaging/deb-vivid/changelog",
    "content": "mysql-router (8.0.12-1ubuntu15.04) vivid; urgency=low\n\n  * For release notes, please refer to https://dev.mysql.com/doc/relnotes/mysql-router/en/changes-8.0.x.html\n\n -- MySQL Release Engineering <mysql-build@oss.oracle.com>  Tue, 13 Mar 2018 10:36:55 +0200\n"
  },
  {
    "path": "packaging/deb-vivid/control",
    "content": "Source: mysql-router\nMaintainer: MySQL Release Engineering <mysql-build@oss.oracle.com>\nSection: database\nPriority: optional\nStandards-Version: 3.9.6\nHomepage: http://www.mysql.com/\nBuild-Depends: cmake,\n debhelper (>= 9.0.0),\n dh-apparmor,\n fakeroot, lsb-release\n\nPackage: mysql-router\nArchitecture: any\nPre-Depends: debconf, adduser\nDepends: ${misc:Depends}, ${shlibs:Depends}\nDescription: MySQL Router\n The MySQL(TM) Router software delivers a fast, multi-threaded way of\n routing connections from MySQL Clients to MySQL Servers. MySQL is a\n trademark of Oracle.\n\nPackage: mysql-router-dev\nArchitecture: any\nDepends: ${misc:Depends}, ${shlibs:Depends}\nDescription: MySQL Router development files\n The MySQL(TM) Router software delivers a fast, multi-threaded way of\n routing connections from MySQL Clients to MySQL Servers. MySQL is a\n trademark of Oracle.\n"
  },
  {
    "path": "packaging/deb-wily/changelog",
    "content": "mysql-router (8.0.12-1ubuntu15.10) wily; urgency=low\n\n  * For release notes, please refer to https://dev.mysql.com/doc/relnotes/mysql-router/en/changes-8.0.x.html\n\n -- MySQL Release Engineering <mysql-build@oss.oracle.com>  Tue, 13 Mar 2018 10:36:55 +0200\n"
  },
  {
    "path": "packaging/deb-wily/control",
    "content": "Source: mysql-router\nMaintainer: MySQL Release Engineering <mysql-build@oss.oracle.com>\nSection: database\nPriority: optional\nStandards-Version: 3.9.6\nHomepage: http://www.mysql.com/\nBuild-Depends: cmake,\n debhelper (>= 9.0.0),\n dh-apparmor,\n fakeroot, lsb-release\n\nPackage: mysql-router\nArchitecture: any\nPre-Depends: debconf, adduser\nDepends: ${misc:Depends}, ${shlibs:Depends}\nDescription: MySQL Router\n The MySQL(TM) Router software delivers a fast, multi-threaded way of\n routing connections from MySQL Clients to MySQL Servers. MySQL is a\n trademark of Oracle.\n\nPackage: mysql-router-dev\nArchitecture: any\nDepends: ${misc:Depends}, ${shlibs:Depends}\nDescription: MySQL Router development files\n The MySQL(TM) Router software delivers a fast, multi-threaded way of\n routing connections from MySQL Clients to MySQL Servers. MySQL is a\n trademark of Oracle.\n"
  },
  {
    "path": "packaging/deb-xenial/changelog",
    "content": "mysql-router (8.0.12-1ubuntu16.04) xenial; urgency=low\n\n  * For release notes, please refer to https://dev.mysql.com/doc/relnotes/mysql-router/en/changes-8.0.x.html\n\n -- MySQL Release Engineering <mysql-build@oss.oracle.com>  Tue, 13 Mar 2018 10:36:55 +0200\n"
  },
  {
    "path": "packaging/deb-xenial/control",
    "content": "Source: mysql-router\nMaintainer: MySQL Release Engineering <mysql-build@oss.oracle.com>\nSection: database\nPriority: optional\nStandards-Version: 3.9.6\nHomepage: http://www.mysql.com/\nBuild-Depends: cmake,\n debhelper (>= 9.0.0),\n dh-apparmor,\n fakeroot, lsb-release\n\nPackage: mysql-router\nArchitecture: any\nPre-Depends: debconf, adduser\nDepends: ${misc:Depends}, ${shlibs:Depends}\nDescription: MySQL Router\n The MySQL(TM) Router software delivers a fast, multi-threaded way of\n routing connections from MySQL Clients to MySQL Servers. MySQL is a\n trademark of Oracle.\n\nPackage: mysql-router-dev\nArchitecture: any\nDepends: ${misc:Depends}, ${shlibs:Depends}\nDescription: MySQL Router development files\n The MySQL(TM) Router software delivers a fast, multi-threaded way of\n routing connections from MySQL Clients to MySQL Servers. MySQL is a\n trademark of Oracle.\n"
  },
  {
    "path": "packaging/deb-yakkety/changelog",
    "content": "mysql-router (8.0.12-1ubuntu16.10) yakkety; urgency=low\n\n  * For release notes, please refer to https://dev.mysql.com/doc/relnotes/mysql-router/en/changes-8.0.x.html\n\n -- MySQL Release Engineering <mysql-build@oss.oracle.com>  Tue, 13 Mar 2018 10:36:55 +0200\n"
  },
  {
    "path": "packaging/deb-yakkety/control",
    "content": "Source: mysql-router\nMaintainer: MySQL Release Engineering <mysql-build@oss.oracle.com>\nSection: database\nPriority: optional\nStandards-Version: 3.9.8\nHomepage: http://www.mysql.com/\nBuild-Depends: cmake,\n debhelper (>= 9.0.0),\n dh-apparmor,\n fakeroot, lsb-release\n\nPackage: mysql-router\nArchitecture: any\nPre-Depends: debconf, adduser\nDepends: ${misc:Depends}, ${shlibs:Depends}\nDescription: MySQL Router\n The MySQL(TM) Router software delivers a fast, multi-threaded way of\n routing connections from MySQL Clients to MySQL Servers. MySQL is a\n trademark of Oracle.\n\nPackage: mysql-router-dev\nArchitecture: any\nDepends: ${misc:Depends}, ${shlibs:Depends}\nDescription: MySQL Router development files\n The MySQL(TM) Router software delivers a fast, multi-threaded way of\n routing connections from MySQL Clients to MySQL Servers. MySQL is a\n trademark of Oracle.\n"
  },
  {
    "path": "packaging/deb-zesty/changelog",
    "content": "mysql-router (8.0.12-1ubuntu17.04) zesty; urgency=low\n\n  * For release notes, please refer to https://dev.mysql.com/doc/relnotes/mysql-router/en/changes-8.0.x.html\n\n -- MySQL Release Engineering <mysql-build@oss.oracle.com>  Tue, 13 Mar 2018 10:36:55 +0200\n"
  },
  {
    "path": "packaging/deb-zesty/control",
    "content": "Source: mysql-router\nMaintainer: MySQL Release Engineering <mysql-build@oss.oracle.com>\nSection: database\nPriority: optional\nStandards-Version: 3.9.5\nHomepage: http://www.mysql.com/\nBuild-Depends: cmake,\n debhelper (>= 9.0.0),\n dh-apparmor,\n fakeroot, lsb-release\n\nPackage: mysql-router\nArchitecture: any\nPre-Depends: debconf, adduser\nDepends: ${misc:Depends}, ${shlibs:Depends}\nDescription: MySQL Router\n The MySQL(TM) Router software delivers a fast, multi-threaded way of\n routing connections from MySQL Clients to MySQL Servers. MySQL is a\n trademark of Oracle.\n\nPackage: mysql-router-dev\nArchitecture: any\nDepends: ${misc:Depends}, ${shlibs:Depends}\nDescription: MySQL Router development files\n The MySQL(TM) Router software delivers a fast, multi-threaded way of\n routing connections from MySQL Clients to MySQL Servers. MySQL is a\n trademark of Oracle.\n"
  },
  {
    "path": "packaging/rpm-oel/CMakeLists.txt",
    "content": "# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nconfigure_file(mysql-router.spec.in ${CMAKE_BINARY_DIR}/mysql-router.spec @ONLY)\n\nif(ARCH_64BIT)\n  set(RPM_LIBDIR \"/usr/lib64\")\nelse()\n  set(RPM_LIBDIR \"/usr/lib\")\nendif()\n\nconfigure_file(mysqlrouter.conf.in ${CMAKE_BINARY_DIR}/packaging/rpm-oel/mysqlrouter.conf @ONLY)\nconfigure_file(mysqlrouter.init ${CMAKE_BINARY_DIR}/packaging/rpm-oel/mysqlrouter.init @ONLY)\nconfigure_file(mysqlrouter.service ${CMAKE_BINARY_DIR}/packaging/rpm-oel/mysqlrouter.service @ONLY)\nconfigure_file(mysqlrouter.tmpfiles.d ${CMAKE_BINARY_DIR}/packaging/rpm-oel/mysqlrouter.tmpfiles.d @ONLY)\n"
  },
  {
    "path": "packaging/rpm-oel/mysql-router.spec.in",
    "content": "# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# MySQL MySQL Router is licensed under the terms of the GPLv2\n# <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n\n%{!?src_base:                 %global src_base mysql-router}\n\n%global milestone    dmr\n\n%global src_dir               %{src_base}-%{version}%{?milestone:-%{milestone}}\n\n%if 0%{?suse_version} == 1315\n%global dist            .sles12\n%endif\n\n%if 0%{?commercial}\n%global license_type    Commercial\n%global product_suffix  -commercial\n%global project_edition -DPROJECT_EDITION=Commercial -DGPL=no\n%else\n%global license_type    GPLv2\n%endif\n\n%{!?with_systemd:       %global systemd 1}\n%{?el6:                 %global systemd 0}\n\nSummary:       MySQL Router\nName:          mysql-router%{?product_suffix}\nVersion:       @PROJECT_VERSION_TEXT@\nRelease:       1@RPM_EXTRA_VERSION@%{?commercial:.1}%{?dist}\nLicense:       @ORACLE_COPYRIGHT@ Under %{?license_type} license as shown in the Description field.\nGroup:         Applications/Databases\nURL:           https://dev.mysql.com/downloads/router/\nSource0:       https://cdn.mysql.com/Downloads/router/mysql-router-%{?commercial:commercial-}%{version}@PROJECT_PACKAGE_EXTRAS@.tar.gz\nSource1:       mysqlrouter.service\nSource2:       mysqlrouter.tmpfiles.d\nSource3:       mysqlrouter.init\nSource4:       mysqlrouter.conf\nBuildRequires: cmake\n%{?el6:BuildRequires:  devtoolset-6-gcc}\n%{?el6:BuildRequires:  devtoolset-6-gcc-c++}\n%{?el7:BuildRequires:  devtoolset-6-gcc}\n%{?el7:BuildRequires:  devtoolset-6-gcc-c++}\n%if 0%{?commercial}\nProvides:      mysql-router = %{version}-%{release}\nObsoletes:     mysql-router < %{version}-%{release}\n%endif\n%if 0%{?suse_version} >= 1210\nBuildRequires: systemd-rpm-macros\n%endif\nBuildRoot:     %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)\n%if 0%{?systemd}\nRequires(post):   systemd\nRequires(preun):  systemd\nRequires(postun): systemd\n%else\nRequires(post):   /sbin/chkconfig\nRequires(preun):  /sbin/chkconfig\nRequires(preun):  /sbin/service\n%endif\n\n%description\nThe MySQL(TM) Router software delivers a fast, multi-threaded way of\nrouting connections from MySQL Clients to MySQL Servers. MySQL is a\ntrademark of Oracle.\n\nThe MySQL software has Dual Licensing, which means you can use the\nMySQL software free of charge under the GNU General Public License\n(http://www.gnu.org/licenses/). You can also purchase commercial MySQL\nlicenses from Oracle and/or its affiliates if you do not wish to be\nbound by the terms of the GPL. See the chapter \"Licensing and Support\"\nin the manual for further info.\n\nThe MySQL web site (http://www.mysql.com/) provides the latest news\nand information about the MySQL software. Also please see the\ndocumentation and the manual for more information.\n\n%package     -n mysql-router%{?product_suffix}-devel\nSummary:        Development header files and libraries for MySQL Router\nGroup:          Applications/Databases\n%if 0%{?commercial}\nProvides:       mysql-router-devel = %{version}-%{release}\nObsoletes:      mysql-router-devel < %{version}-%{release}\n%endif\n%description -n mysql-router%{?product_suffix}-devel\nThis package contains the development header files and libraries\nnecessary to develop MySQL Router applications.\n\n%prep\n%setup -q -n %{name}-%{version}@PROJECT_PACKAGE_EXTRAS@\n\n%build\nmkdir release && pushd release\n%{?el6:export CC=/opt/rh/devtoolset-6/root/usr/bin/gcc}\n%{?el6:export CXX=/opt/rh/devtoolset-6/root/usr/bin/g++}\n%{?el7:export CC=/opt/rh/devtoolset-6/root/usr/bin/gcc}\n%{?el7:export CXX=/opt/rh/devtoolset-6/root/usr/bin/g++}\ncmake .. -DINSTALL_LAYOUT=RPM \\\n  -DWITH_STATIC=yes -DWITH_MYSQL=\"%{with_mysql}\" %{?project_edition} \\\n  -DWITH_LIBEVENT=\"%{with_libevent}\" \\\n  -DWITH_SSL=\"%{with_ssl}\" \\\n  -DENABLE_TESTS=yes -DENABLE_GCOV=yes\nmake %{?_smp_mflags} VERBOSE=1\nmake test || true\npopd\n\n%install\nrm -rf %{buildroot}\npushd release\n%{?el6:export CC=/opt/rh/devtoolset-6/root/usr/bin/gcc}\n%{?el6:export CXX=/opt/rh/devtoolset-6/root/usr/bin/g++}\n%{?el7:export CC=/opt/rh/devtoolset-6/root/usr/bin/gcc}\n%{?el7:export CXX=/opt/rh/devtoolset-6/root/usr/bin/g++}\nmake DESTDIR=%{buildroot} install\n\ninstall -d -m 0755 %{buildroot}/%{_localstatedir}/log/mysqlrouter\ninstall -d -m 0755 %{buildroot}/%{_localstatedir}/run/mysqlrouter\n\n%if 0%{?systemd}\ninstall -D -p -m 0644 %{SOURCE1} %{buildroot}%{_unitdir}/mysqlrouter.service\ninstall -D -p -m 0644 %{SOURCE2} %{buildroot}%{_tmpfilesdir}/mysqlrouter.conf\n%else\ninstall -D -p -m 0755 %{SOURCE3} %{buildroot}%{_sysconfdir}/init.d/mysqlrouter\n%endif\ninstall -D -p -m 0644 %{SOURCE4} %{buildroot}%{_sysconfdir}/mysqlrouter/mysqlrouter.conf\n\n# remove some unwanted files\nrm -rf %{buildroot}%{_includedir}\nrm -rf %{buildroot}/%{_libdir}/libmysqlharness.a\n\n%clean\nrm -rf %{buildroot}\n\n%pre\n/usr/sbin/groupadd -r mysqlrouter >/dev/null 2>&1 || :\n/usr/sbin/useradd -M -N -g mysqlrouter -r -d /var/lib/mysqlrouter -s /bin/false \\\n    -c \"MySQL Router\" mysqlrouter >/dev/null 2>&1 || :\n%if 0%{?suse_version}\n%service_add_pre mysqlrouter.service\n%endif\n\n%post\n/sbin/ldconfig\n%if 0%{?systemd}\n%if 0%{?suse_version}\n%service_add_post mysqlrouter.service\n/usr/bin/systemd-tmpfiles --create %{_tmpfilesdir}/mysqlrouter.conf >/dev/null 2>&1 || :\n%else\n%systemd_post mysqlrouter.service\n%endif # suse_version\n%else\n/sbin/chkconfig --add mysqlrouter\n%endif # systemd\n\n%preun\n%if 0%{?systemd}\n%if 0%{?suse_version}\n%service_del_preun mysqlrouter.service\n%else\n%systemd_preun mysqlrouter.service\n%endif # suse_version\n%else\nif [ \"$1\" = 0 ]; then\n    /sbin/service mysqlrouter stop >/dev/null 2>&1 || :\n    /sbin/chkconfig --del mysqlrouter\nfi\n%endif # systemd\n\n%postun\n/sbin/ldconfig\n%if 0%{?systemd}\n%if 0%{?suse_version}\n%service_del_postun mysqlrouter.service\n%else\n%systemd_postun_with_restart mysqlrouter.service\n%endif # suse_version\n%else\nif [ $1 -ge 1 ]; then\n    /sbin/service mysqlrouter condrestart >/dev/null 2>&1 || :\nfi\n%endif # systemd\n\n%files\n%defattr(-, root, root, -)\n%doc License.txt README.txt doc/sample_mysqlrouter.conf\n%dir %{_sysconfdir}/mysqlrouter\n%config(noreplace) %{_sysconfdir}/mysqlrouter/mysqlrouter.conf\n%{_bindir}/mysqlrouter\n%{_bindir}/mysqlrouter_plugin_info\n%if 0%{?systemd}\n%{_unitdir}/mysqlrouter.service\n%{_tmpfilesdir}/mysqlrouter.conf\n%else\n%{_sysconfdir}/init.d/mysqlrouter\n%endif\n%{_libdir}/libmysql*.so.*\n%{_libdir}/libmysqlharness.so\n%{_libdir}/libmysqlrouter.so\n%dir %{_libdir}/mysqlrouter\n%{_libdir}/mysqlrouter/*.so\n%dir %attr(755, mysqlrouter, mysqlrouter) %{_localstatedir}/log/mysqlrouter\n%dir %attr(755, mysqlrouter, mysqlrouter) %{_localstatedir}/run/mysqlrouter\n\n%changelog\n* Fri Oct 20 2017 Andrzej Religa <andrzej.religa@oracle.com> - 8.0.4\n- Added sample config file to the rpm package\n\n* Fri Sep 01 2017 Balasubramanian Kandasamy <balasubramanian.kandasamy@oracle.com> - 8.0.3-0.1\n- Updated for 8.0.3 dmr release\n\n* Tue Jun 06 2017 Andrzej Religa <andrzej.religa@oracle.com> - 2.1.4-1\n- added mysqlrouter_plugin_info binary\n\n* Mon Mar 20 2017 Balasubramanian Kandasamy <balasubramanian.kandasamy@oracle.com> - 2.1.3-1\n- Updated for 2.1.3 GA release\n\n* Thu Feb 23 2017 Pawel Mroszczyk <pawel.mroszczyk@oracle.com> - 2.1.2-0.1-rc\n- Updated for 2.1.2 rc release: changed file/dir owner to mysqlrouter:mysqlrouter\n\n* Mon Jan 30 2017 Balasubramanian Kandasamy <balasubramanian.kandasamy@oracle.com> - 2.1.2-0.1-rc\n- Updated for 2.1.2 rc release\n\n* Tue Nov 29 2016 Balasubramanian Kandasamy <balasubramanian.kandasamy@oracle.com> - 2.1.1-0.1\n- Updated for 2.1.1 labs release\n\n* Sat Sep 10 2016 Balasubramanian Kandasamy <balasubramanian.kandasamy@oracle.com> - 2.1.0-0.1\n- Updated for 2.1.0 labs release\n\n* Thu Nov 26 2015 Balasubramanian Kandasamy <balasubramanian.kandasamy@oracle.com> - 2.0.3-1\n- Add support for el6\n- Fix group and buildreq\n\n* Thu Oct 15 2015 Geert Vanderkelen <geert.vanderkelen@oracle.com> - 2.0.2-1\n- Added pre and postun scripts for sles\n- Making version a variable and using _libdir\n- Adding -DWITH_MYSQL and building libmysqlclient statically in\n\n* Wed Aug 19 2015 Geert Vanderkelen <geert.vanderkelen@oracle.com> - 2.0.1-1\n- Initial version\n"
  },
  {
    "path": "packaging/rpm-oel/mysqlrouter.conf.in",
    "content": "# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA\n\n#\n# MySQL Router configuration file\n#\n# Documentation is available at\n#    http://dev.mysql.com/doc/mysql-router/en/\n\n[DEFAULT]\nlogging_folder = /var/log/mysqlrouter/\nplugin_folder = @RPM_LIBDIR@/mysqlrouter\nruntime_folder = /var/run/mysqlrouter\nconfig_folder = /etc/mysqlrouter\n\n[logger]\nlevel = INFO\n\n# If no plugin is configured which starts a service, keepalive\n# will make sure MySQL Router will not immediately exit. It is\n# safe to remove once Router is configured.\n[keepalive]\ninterval = 60\n"
  },
  {
    "path": "packaging/rpm-oel/mysqlrouter.init",
    "content": "#! /bin/bash\n#\n# mysqlrouter\tThis shell script takes care of starting and stopping\n#\t\tthe MySQL Router\n#\n# chkconfig: 2345 66 34\n# description: MySQL Router\n# processname: mysqlrouter\n# config: /etc/mysqlrouter/mysqlrouter.conf\n# pidfile: /var/run/mysqlrouter/mysqlrouter.pid\n#\n# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n#\n# Maintainer: MySQL Release Engineering <mysql-build@oss.oracle.com>\n#\n\n# Source function library\n. /etc/rc.d/init.d/functions\n\n# Source networking configuration\n. /etc/sysconfig/network\n\nexec=/usr/bin/mysqlrouter\nprog=mysqlrouter\npiddir=/var/run/mysqlrouter\npidfile=/var/run/mysqlrouter/mysqlrouter.pid\nlogdir=/var/log/mysqlrouter\nlogfile=$logdir/mysqlrouter.log\nlockfile=/var/lock/subsys/$prog\ndatadir=/var/lib/mysqlrouter\n\nstart () {\n    [ -d $piddir ] || [ -L $piddir ] || install -d -m 0750 -o mysqlrouter -g mysqlrouter ${piddir}\n    [ -d $logdir ] || [ -L $logdir ] || install -d -m 0750 -o mysqlrouter -g mysqlrouter ${logdir}\n    [ -e $logfile ] || [ -L $logfile ] || install /dev/null -m 0750 -o mysqlrouter -g mysqlrouter ${logfile}\n    export ROUTER_PID=$pidfile\n    [ -d $datadir ] || mkdir -p $datadir\n    chown mysqlrouter:mysqlrouter $datadir\n    daemon $exec --user=mysqlrouter -c /etc/mysqlrouter/mysqlrouter.conf >/dev/null 2>&1 &\n    ret=$?\n    if [ $ret -eq \"0\" ]; then\n\taction $\"Starting $prog: \" /bin/true\n\ttouch /var/lock/subsys/$prog\n    else\n\taction $\"Starting $prog: \" /bin/false\n    fi\n    return $ret\n}\n\nstop () {\n    [ -f /var/lock/subsys/$prog ] || return 0\n    killproc mysqlrouter >/dev/null 2>&1\n    ret=$?\n    if [ $ret -eq \"0\" ]; then\n\trm -f $pidfile\n\trm -f /var/lock/subsys/$prog\n\taction $\"Stopping $prog: \" /bin/true\n    else\n\taction $\"Stopping $prog: \" /bin/false\n    fi\n}\n\nrestart ()  {\n    stop\n    start\n}\n\ncondrestart () {\n    [ -e /var/lock/subsys/$prog ] && restart || return 0\n}\n\ncase \"$1\" in\n    start)\n\tstart\n\t;;\n    stop)\n\tstop\n\t;;\n    status)\n\tstatus -p \"$pidfile\" $prog\n\t;;\n    restart)\n\trestart\n\t;;\n    condrestart|try-restart)\n\tcondrestart\n\t;;\n    reload)\n\texit 3\n\t;;\n    force-reload)\n\trestart\n\t;;\n    *)\n\techo $\"Usage: $0 {start|stop|status|condrestart|try-restart|reload|force-reload}\"\n\texit 2\nesac\n\nexit $?\n"
  },
  {
    "path": "packaging/rpm-oel/mysqlrouter.service",
    "content": "[Unit]\nDescription=MySQL Router\nAfter=syslog.target\nAfter=network.target\n\n[Service]\nType=simple\nUser=mysqlrouter\nGroup=mysqlrouter\n\nPIDFile=/var/run/mysqlrouter/mysqlrouter.pid\n\nExecStart=/usr/bin/mysqlrouter -c /etc/mysqlrouter/mysqlrouter.conf\n\nPrivateTmp=true\n\n[Install]\nWantedBy=multi-user.target\n\n"
  },
  {
    "path": "packaging/rpm-oel/mysqlrouter.tmpfiles.d",
    "content": "# Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify it\n# under the terms of the GNU General Public License as published by the Free\n# Software Foundation; version 2 of the License.\n#\n# This program is distributed in the hope that it will be useful, but WITHOUT\n# ANY  WARRANTY; without even the implied warranty of MERCHANTABILITY or\n# FITNESS  FOR A PARTICULAR PURPOSE. See the GNU General Public License for\n# more details.\n#\n# You should have received a copy of the GNU General Public License along with\n# this program; if not, write to the Free Software Foundation, Inc., 51\n# Franklin St, Fifth Floor, Boston, MA 02110-1301  USA\n\nd /var/run/mysqlrouter 0755 mysqlrouter mysqlrouter  -\n"
  },
  {
    "path": "src/CMakeLists.txt",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nADD_SUBDIRECTORY(harness)\nADD_SUBDIRECTORY(http)\nADD_SUBDIRECTORY(keepalive)\nADD_SUBDIRECTORY(metadata_cache)\nADD_SUBDIRECTORY(mock_server)\nADD_SUBDIRECTORY(mysql_protocol)\nADD_SUBDIRECTORY(plugin_info)\nADD_SUBDIRECTORY(router)\nADD_SUBDIRECTORY(routing)\nADD_SUBDIRECTORY(syslog)\nADD_SUBDIRECTORY(x_protocol)\n"
  },
  {
    "path": "src/harness/.gitignore",
    "content": "*~\n*.o\n*.so\n*.a\n\n# Generated files\nharness/include/plugin.h\n\n# Doxygen generated documentation\ndoc/**\n\n# Build and Packaging\nbuild/\nBUILD/\ncmake_install.cmake\nCMakeFiles\nCMakeCache.txt\nMakefile\nCPack*.cmake\n\n# Editor files & folders\n.idea/\n.DS_Store\n\n"
  },
  {
    "path": "src/harness/CMakeLists.txt",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n# Basic variables\nset(HARNESS_NAME \"harness\" CACHE STRING\n  \"Name of Harness\")\n\nset(HARNESS_INSTALL_LIBRARY_DIR \"${INSTALL_LIBDIR}\"\n    CACHE PATH \"Installation directory for Harness libraries\")\nset(HARNESS_INSTALL_BIN_DIR \"bin\" CACHE PATH\n    \"Installation directory for Harness main binaries\")\nset(ENABLE_HARNESS_PROGRAM YES CACHE BOOL\n  \"Whether to build and install the Harness main program\")\nset(HARNESS_INSTALL_PLUGINS YES CACHE BOOL\n  \"Whether to install the Harness provided plugins\")\n\nmessage(STATUS \"Harness will install plugins in ${HARNESS_INSTALL_LIBRARY_DIR}/${HARNESS_NAME}\")\n\n# Basic variables\nset(HARNESS_NAME \"harness\"\n  CACHE STRING \"Name of Harness\")\nset(INSTALL_INCLUDE_DIR \"include/mysql/harness\")\nset(HARNESS_INSTALL_INCLUDE_PREFIX \"include/mysql\")\nset(HARNESS_INSTALL_PROGRAM YES\n  CACHE BOOL \"Whether to install the Harness main program\")\nset(HARNESS_INSTALL_PLUGINS YES\n  CACHE BOOL \"Whether to install the Harness provided plugins\")\nif(NOT CMAKE_CFG_INTDIR STREQUAL \".\")\n  foreach(config_ ${CMAKE_CONFIGURATION_TYPES})\n    string(TOUPPER ${config_} config__)\n    set(HARNESS_PLUGIN_OUTPUT_DIRECTORY_${config__} ${MySQLRouter_BINARY_STAGE_DIR}/${config_}/lib\n      CACHE STRING \"Output directory for plugins ${config_} build\")\n  endforeach()\nendif()\nset(HARNESS_PLUGIN_OUTPUT_DIRECTORY ${MySQLRouter_BINARY_STAGE_DIR}/lib/${HARNESS_NAME}\n  CACHE STRING \"Output directory for plugins\")\nset(ENABLE_TESTS OFF\n  CACHE BOOL \"Enable unit tests when building\")\n\ninclude(Plugin)\n\n# Check for C++ 11 support\ninclude(CheckCXXCompilerFlag)\nif(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES \"Clang\")\n  # This declares that we are POSIX.1-2001 compliant and\n  # XSI-conforming. The pre-processor variable _POSIX_C_SOURCE is\n  # indirectly set when we set _XOPEN_SOURCE.\n  add_definitions(-D_XOPEN_SOURCE=600)\n\n  check_cxx_compiler_flag(\"-std=c++11\" COMPILER_SUPPORTS_CXX11)\n  check_cxx_compiler_flag(\"-std=c++0x\" COMPILER_SUPPORTS_CXX0X)\n  if(COMPILER_SUPPORTS_CXX11)\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -std=c++11\")\n  elseif(COMPILER_SUPPORTS_CXX0X)\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -std=c++0x\")\n  else()\n    message(STATUS \"You need C++11 support, but ${CMAKE_CXX_COMPILER} does not have that.\")\n  endif()\n  set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra -Wconversion\")\n  if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_COMPILER_IS_GNUCXX VERSION_LESS \"4.9\")\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wno-write-strings\")\n  endif()\nelseif(CMAKE_CXX_COMPILER_ID MATCHES \"MSVC\")\n  if(MSVC_VERSION VERSION_LESS 1800)\n    message(FATAL_ERROR \"Compiler ${CMAKE_CXX_COMPILER} is too old; need at least MSVC 12.0\")\n  endif()\n  set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} /TP\")\n  add_definitions(-DWIN32_LEAN_AND_MEAN)\nelseif(CMAKE_CXX_COMPILER_ID MATCHES \"SunPro\")\n  if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13.0)\n    message(FATAL_ERROR \"Compiler ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_VERSION} is too old; need at least SunPro 5.13.0 (aka Oracle Developer Studio 12.4)\")\n  endif()\n  set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -std=c++11\")\nelse()\n  message(FATAL_ERROR \"You need C++11 support, but ${CMAKE_CXX_COMPILER} does not have that.\")\nendif()\n\n# Platform specifics\nif(WIN32)\n  include(CheckIncludeFileCXX)\n  check_include_file_cxx(\"shlwapi.h\" Shlwapi_FOUND)\n  if(Shlwapi_FOUND)\n    set(SHLWAPI_LIBRARIES \"shlwapi.dll\")\n  else()\n    message(FATAL_ERROR \"Shlwapi library not found\")\n  endif()\nelse()\n  set(SHLWAPI_LIBRARIES)\nendif()\n\nif(ENABLE_TESTS)\n  enable_testing()\n  add_subdirectory(shared)\nendif()\n\ninclude(${MySQLRouter_SOURCE_DIR}/cmake/compile_flags.cmake)\ninclude(GenerateExportHeader)\n\nset(MY_SSL_SOURCE_DIR ${MySQLRouter_SOURCE_DIR}/src/router/src/common)\nset(MY_SSL_INCLUDE_DIRS ${MySQLRouter_SOURCE_DIR}/src/router/include\n                        ${SSL_INCLUDE_DIRS})\n\nset(harness_source\n  ${MY_SSL_SOURCE_DIR}/my_aes.cc\n  src/loader.cc src/utilities.cc src/config_parser.cc src/designator.cc\n  src/loader_config.cc\n  src/common.cc  src/filesystem.cc\n  src/arg_handler.cc\n  src/dim.cc\n  src/hostname_validator.cc\n  src/mysql_router_thread.cc\n  src/process_launcher.cc\n  src/logging/handler.cc\n  src/logging/logger.cc\n  src/logging/logging.cc\n  src/logging/registry.cc\n  src/random_generator.cc\n  src/socket_operations.cc\n  src/tcp_address.cc\n  src/keyring/keyring_manager.cc\n  src/keyring/keyring_memory.cc\n  src/keyring/keyring_file.cc\n  src/networking/ip_address.cc\n  src/networking/ipv4_address.cc\n  src/networking/ipv6_address.cc\n  src/networking/resolver.cc)\n\nif(WITH_SSL STREQUAL \"bundled\")\n  set(MY_SSL_IMPL ${MY_SSL_SOURCE_DIR}/my_aes_yassl.cc)\nelse()\n  set(MY_SSL_IMPL ${MY_SSL_SOURCE_DIR}/my_aes_openssl.cc)\nendif()\n\nset(harness_source ${harness_source} ${MY_SSL_IMPL})\n\n# Disable warnings from 3rd party code that we have no control over.\nif(CMAKE_COMPILER_IS_GNUCXX OR \"${CMAKE_CXX_COMPILER_ID}\" MATCHES \"Clang\")\n  add_compile_flags(${MY_SSL_SOURCE_DIR}/my_aes.cc ${MY_SSL_IMPL} COMPILE_FLAGS\n    -Wno-sign-conversion\n    -Wno-unused-parameter\n    -Wno-conversion)\nendif()\n\nif(WIN32)\n  list(APPEND harness_source\n    src/filesystem-windows.cc src/utilities-windows.cc src/loader-windows.cc)\nelse()\n  list(APPEND harness_source\n    src/filesystem-posix.cc src/utilities-posix.cc src/loader-posix.cc)\nendif()\n\ninclude_directories(\n  ${CMAKE_CURRENT_SOURCE_DIR}/include/mysql/harness\n  ${CMAKE_CURRENT_SOURCE_DIR}/src\n  ${MySQLRouter_BINARY_DIR}/include\n  ${MY_SSL_INCLUDE_DIRS})\n\nif(WIN32)\n  set(WINSOCK_LIBRARIES Ws2_32.lib)\nendif()\nset(common_libraries ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT}\n                     ${SHLWAPI_LIBRARIES} ${WINSOCK_LIBRARIES} ${SSL_LIBRARIES})\n\nconfigure_file(plugin.h.in ${MySQLRouter_BINARY_DIR}/${INSTALL_INCLUDE_DIR}/plugin.h\n  ESCAPE_QUOTES @ONLY)\n\n# create harness library - static version\nadd_library(harness-archive STATIC ${harness_source})\ntarget_link_libraries(harness-archive ${common_libraries})\ntarget_include_directories(harness-archive PUBLIC include)\nif(WIN32)\n  set_target_properties(harness-archive PROPERTIES\n    COMPILE_FLAGS -DHARNESS_STATIC_DEFINE)\nendif()\nif(THREADS_HAVE_PTHREAD_ARG)\n  target_compile_options(PUBLIC harness-archive \"-pthread\")\nendif()\n\n# create harness library - dynamic version\nadd_library(harness-library SHARED ${harness_source})\ntarget_link_libraries(harness-library ${common_libraries})\ntarget_include_directories(harness-library PUBLIC include)\n\ngenerate_export_header(harness-library\n  BASE_NAME HARNESS\n  EXPORT_FILE_NAME ${MySQLRouter_BINARY_DIR}/include/harness_export.h)\n\nif(${CMAKE_SYSTEM_NAME} STREQUAL \"SunOS\")\n  target_link_libraries(harness-library -lnsl -lsocket)\n  target_link_libraries(harness-archive -lnsl -lsocket)\nendif()\n\nif(NOT WIN32)\n  set_target_properties(harness-archive harness-library PROPERTIES\n    OUTPUT_NAME \"mysqlharness\"\n    PREFIX \"lib\"\n    SOVERSION 1)\nelse()\n  set_target_properties(harness-archive PROPERTIES\n    OUTPUT_NAME \"mysqlharness_a\"\n    PREFIX \"lib\"\n    SOVERSION 1)\nendif()\n\n# Fix install path in stage dir, so that files get to\n# stage/${configuration_type}/{bin,etc,lib} instead of\n# stage/{bin,etc,lib}/${configuration_type}\nif (NOT CMAKE_CFG_INTDIR STREQUAL \".\")\n  foreach(config_ ${CMAKE_CONFIGURATION_TYPES})\n    string(TOUPPER ${config_} config_)\n    set_target_properties(harness-library PROPERTIES\n      RUNTIME_OUTPUT_DIRECTORY_${config_} ${MySQLRouter_BINARY_DIR}/stage/${config_}/bin\n      LIBRARY_OUTPUT_DIRECTORY_${config_} ${MySQLRouter_BINARY_DIR}/stage/${config_}/lib\n    )\n  endforeach()\nelse()\n  set_target_properties(harness-library PROPERTIES\n    LIBRARY_OUTPUT_DIRECTORY ${MySQLRouter_BINARY_DIR}/stage/lib\n    RUNTIME_OUTPUT_DIRECTORY ${MySQLRouter_BINARY_DIR}/stage/bin)\nendif()\n\n# don't install headers until a) a final destination is found and b) API is stable\n# file(GLOB harness_headers include/*.h)\n# install(FILES ${harness_headers}\n#   DESTINATION ${HARNESS_INSTALL_INCLUDE_PREFIX}/${HARNESS_NAME})\nif(NOT WIN32)\n  install(TARGETS harness-archive harness-library\n        LIBRARY DESTINATION ${HARNESS_INSTALL_LIBRARY_DIR}\n        ARCHIVE DESTINATION ${HARNESS_INSTALL_LIBRARY_DIR})\nelse()\n  install(TARGETS harness-archive\n        ARCHIVE DESTINATION ${HARNESS_INSTALL_LIBRARY_DIR})\n  install(TARGETS harness-library\n        RUNTIME DESTINATION ${HARNESS_INSTALL_BIN_DIR}\n        LIBRARY DESTINATION ${HARNESS_INSTALL_LIBRARY_DIR})\n  install(FILES $<TARGET_PDB_FILE:harness-library>\n        DESTINATION ${HARNESS_INSTALL_BIN_DIR})\nendif()\n\nif(ENABLE_TESTS)\n  add_subdirectory(tests)\nendif()\n"
  },
  {
    "path": "src/harness/CPPLINT.cfg",
    "content": "set noparent\nfilter=-whitespace/comments,-build/header_guard,-readability/namespace,-build/c++11,-build/include,-runtime/int,+build/include_alpha\n"
  },
  {
    "path": "src/harness/Doxyfile.in",
    "content": "# Doxyfile 1.8.6\n\n# This file describes the settings to be used by the documentation system\n# doxygen (www.doxygen.org) for a project.\n#\n# All text after a double hash (##) is considered a comment and is placed in\n# front of the TAG it is preceding.\n#\n# All text after a single hash (#) is considered a comment and will be ignored.\n# The format is:\n# TAG = value [value, ...]\n# For lists, items can also be appended using:\n# TAG += value [value, ...]\n# Values that contain spaces should be placed between quotes (\\\" \\\").\n\n#---------------------------------------------------------------------------\n# Project related configuration options\n#---------------------------------------------------------------------------\n\n# This tag specifies the encoding used for all characters in the config file\n# that follow. The default is UTF-8 which is also the encoding used for all text\n# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv\n# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv\n# for the list of possible encodings.\n# The default value is: UTF-8.\n\nDOXYFILE_ENCODING      = UTF-8\n\n# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by\n# double-quotes, unless you are using Doxywizard) that should identify the\n# project for which the documentation is generated. This name is used in the\n# title of most generated pages and in a few other places.\n# The default value is: My Project.\n\nPROJECT_NAME           = \"MySQL Harness\"\n\n# The PROJECT_NUMBER tag can be used to enter a project or revision number. This\n# could be handy for archiving the generated documentation or if some version\n# control system is used.\n\nPROJECT_NUMBER         =\n\n# Using the PROJECT_BRIEF tag one can provide an optional one line description\n# for a project that appears at the top of each page and should give viewer a\n# quick idea about the purpose of the project. Keep the description short.\n\nPROJECT_BRIEF          = Plugin harness\n\n# With the PROJECT_LOGO tag one can specify an logo or icon that is included in\n# the documentation. The maximum height of the logo should not exceed 55 pixels\n# and the maximum width should not exceed 200 pixels. Doxygen will copy the logo\n# to the output directory.\n\nPROJECT_LOGO           =\n\n# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path\n# into which the generated documentation will be written. If a relative path is\n# entered, it will be relative to the location where doxygen was started. If\n# left blank the current directory will be used.\n\nOUTPUT_DIRECTORY       = doc\n\n# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create 4096 sub-\n# directories (in 2 levels) under the output directory of each output format and\n# will distribute the generated files over these directories. Enabling this\n# option can be useful when feeding doxygen a huge amount of source files, where\n# putting all generated files in the same directory would otherwise causes\n# performance problems for the file system.\n# The default value is: NO.\n\nCREATE_SUBDIRS         = NO\n\n# The OUTPUT_LANGUAGE tag is used to specify the language in which all\n# documentation generated by doxygen is written. Doxygen will use this\n# information to generate all constant output in the proper language.\n# Possible values are: Afrikaans, Arabic, Armenian, Brazilian, Catalan, Chinese,\n# Chinese-Traditional, Croatian, Czech, Danish, Dutch, English (United States),\n# Esperanto, Farsi (Persian), Finnish, French, German, Greek, Hungarian,\n# Indonesian, Italian, Japanese, Japanese-en (Japanese with English messages),\n# Korean, Korean-en (Korean with English messages), Latvian, Lithuanian,\n# Macedonian, Norwegian, Persian (Farsi), Polish, Portuguese, Romanian, Russian,\n# Serbian, Serbian-Cyrillic, Slovak, Slovene, Spanish, Swedish, Turkish,\n# Ukrainian and Vietnamese.\n# The default value is: English.\n\nOUTPUT_LANGUAGE        = English\n\n# If the BRIEF_MEMBER_DESC tag is set to YES doxygen will include brief member\n# descriptions after the members that are listed in the file and class\n# documentation (similar to Javadoc). Set to NO to disable this.\n# The default value is: YES.\n\nBRIEF_MEMBER_DESC      = YES\n\n# If the REPEAT_BRIEF tag is set to YES doxygen will prepend the brief\n# description of a member or function before the detailed description\n#\n# Note: If both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the\n# brief descriptions will be completely suppressed.\n# The default value is: YES.\n\nREPEAT_BRIEF           = YES\n\n# This tag implements a quasi-intelligent brief description abbreviator that is\n# used to form the text in various listings. Each string in this list, if found\n# as the leading text of the brief description, will be stripped from the text\n# and the result, after processing the whole list, is used as the annotated\n# text. Otherwise, the brief description is used as-is. If left blank, the\n# following values are used ($name is automatically replaced with the name of\n# the entity):The $name class, The $name widget, The $name file, is, provides,\n# specifies, contains, represents, a, an and the.\n\nABBREVIATE_BRIEF       =\n\n# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then\n# doxygen will generate a detailed section even if there is only a brief\n# description.\n# The default value is: NO.\n\nALWAYS_DETAILED_SEC    = NO\n\n# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all\n# inherited members of a class in the documentation of that class as if those\n# members were ordinary class members. Constructors, destructors and assignment\n# operators of the base classes will not be shown.\n# The default value is: NO.\n\nINLINE_INHERITED_MEMB  = NO\n\n# If the FULL_PATH_NAMES tag is set to YES doxygen will prepend the full path\n# before files name in the file list and in the header files. If set to NO the\n# shortest path that makes the file name unique will be used\n# The default value is: YES.\n\nFULL_PATH_NAMES        = YES\n\n# The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path.\n# Stripping is only done if one of the specified strings matches the left-hand\n# part of the path. The tag can be used to show relative paths in the file list.\n# If left blank the directory from which doxygen is run is used as the path to\n# strip.\n#\n# Note that you can specify absolute paths here, but also relative paths, which\n# will be relative from the directory where doxygen is started.\n# This tag requires that the tag FULL_PATH_NAMES is set to YES.\n\nSTRIP_FROM_PATH        =\n\n# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the\n# path mentioned in the documentation of a class, which tells the reader which\n# header file to include in order to use a class. If left blank only the name of\n# the header file containing the class definition is used. Otherwise one should\n# specify the list of include paths that are normally passed to the compiler\n# using the -I flag.\n\nSTRIP_FROM_INC_PATH    =\n\n# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but\n# less readable) file names. This can be useful is your file systems doesn't\n# support long names like on DOS, Mac, or CD-ROM.\n# The default value is: NO.\n\nSHORT_NAMES            = NO\n\n# If the JAVADOC_AUTOBRIEF tag is set to YES then doxygen will interpret the\n# first line (until the first dot) of a Javadoc-style comment as the brief\n# description. If set to NO, the Javadoc-style will behave just like regular Qt-\n# style comments (thus requiring an explicit @brief command for a brief\n# description.)\n# The default value is: NO.\n\nJAVADOC_AUTOBRIEF      = NO\n\n# If the QT_AUTOBRIEF tag is set to YES then doxygen will interpret the first\n# line (until the first dot) of a Qt-style comment as the brief description. If\n# set to NO, the Qt-style will behave just like regular Qt-style comments (thus\n# requiring an explicit \\brief command for a brief description.)\n# The default value is: NO.\n\nQT_AUTOBRIEF           = NO\n\n# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make doxygen treat a\n# multi-line C++ special comment block (i.e. a block of //! or /// comments) as\n# a brief description. This used to be the default behavior. The new default is\n# to treat a multi-line C++ comment block as a detailed description. Set this\n# tag to YES if you prefer the old behavior instead.\n#\n# Note that setting this tag to YES also means that rational rose comments are\n# not recognized any more.\n# The default value is: NO.\n\nMULTILINE_CPP_IS_BRIEF = NO\n\n# If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the\n# documentation from any documented member that it re-implements.\n# The default value is: YES.\n\nINHERIT_DOCS           = YES\n\n# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce a\n# new page for each member. If set to NO, the documentation of a member will be\n# part of the file/class/namespace that contains it.\n# The default value is: NO.\n\nSEPARATE_MEMBER_PAGES  = NO\n\n# The TAB_SIZE tag can be used to set the number of spaces in a tab. Doxygen\n# uses this value to replace tabs by spaces in code fragments.\n# Minimum value: 1, maximum value: 16, default value: 4.\n\nTAB_SIZE               = 4\n\n# This tag can be used to specify a number of aliases that act as commands in\n# the documentation. An alias has the form:\n# name=value\n# For example adding\n# \"sideeffect=@par Side Effects:\\n\"\n# will allow you to put the command \\sideeffect (or @sideeffect) in the\n# documentation, which will result in a user-defined paragraph with heading\n# \"Side Effects:\". You can put \\n's in the value part of an alias to insert\n# newlines.\n\nALIASES                =\n\n# This tag can be used to specify a number of word-keyword mappings (TCL only).\n# A mapping has the form \"name=value\". For example adding \"class=itcl::class\"\n# will allow you to use the command class in the itcl::class meaning.\n\nTCL_SUBST              =\n\n# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources\n# only. Doxygen will then generate output that is more tailored for C. For\n# instance, some of the names that are used will be different. The list of all\n# members will be omitted, etc.\n# The default value is: NO.\n\nOPTIMIZE_OUTPUT_FOR_C  = NO\n\n# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java or\n# Python sources only. Doxygen will then generate output that is more tailored\n# for that language. For instance, namespaces will be presented as packages,\n# qualified scopes will look different, etc.\n# The default value is: NO.\n\nOPTIMIZE_OUTPUT_JAVA   = NO\n\n# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran\n# sources. Doxygen will then generate output that is tailored for Fortran.\n# The default value is: NO.\n\nOPTIMIZE_FOR_FORTRAN   = NO\n\n# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL\n# sources. Doxygen will then generate output that is tailored for VHDL.\n# The default value is: NO.\n\nOPTIMIZE_OUTPUT_VHDL   = NO\n\n# Doxygen selects the parser to use depending on the extension of the files it\n# parses. With this tag you can assign which parser to use for a given\n# extension. Doxygen has a built-in mapping, but you can override or extend it\n# using this tag. The format is ext=language, where ext is a file extension, and\n# language is one of the parsers supported by doxygen: IDL, Java, Javascript,\n# C#, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL. For instance to make\n# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C\n# (default is Fortran), use: inc=Fortran f=C.\n#\n# Note For files without extension you can use no_extension as a placeholder.\n#\n# Note that for custom extensions you also need to set FILE_PATTERNS otherwise\n# the files are not read by doxygen.\n\nEXTENSION_MAPPING      =\n\n# If the MARKDOWN_SUPPORT tag is enabled then doxygen pre-processes all comments\n# according to the Markdown format, which allows for more readable\n# documentation. See http://daringfireball.net/projects/markdown/ for details.\n# The output of markdown processing is further processed by doxygen, so you can\n# mix doxygen, HTML, and XML commands with Markdown formatting. Disable only in\n# case of backward compatibilities issues.\n# The default value is: YES.\n\nMARKDOWN_SUPPORT       = YES\n\n# When enabled doxygen tries to link words that correspond to documented\n# classes, or namespaces to their corresponding documentation. Such a link can\n# be prevented in individual cases by by putting a % sign in front of the word\n# or globally by setting AUTOLINK_SUPPORT to NO.\n# The default value is: YES.\n\nAUTOLINK_SUPPORT       = YES\n\n# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want\n# to include (a tag file for) the STL sources as input, then you should set this\n# tag to YES in order to let doxygen match functions declarations and\n# definitions whose arguments contain STL classes (e.g. func(std::string);\n# versus func(std::string) {}). This also make the inheritance and collaboration\n# diagrams that involve STL classes more complete and accurate.\n# The default value is: NO.\n\nBUILTIN_STL_SUPPORT    = NO\n\n# If you use Microsoft's C++/CLI language, you should set this option to YES to\n# enable parsing support.\n# The default value is: NO.\n\nCPP_CLI_SUPPORT        = NO\n\n# Set the SIP_SUPPORT tag to YES if your project consists of sip (see:\n# http://www.riverbankcomputing.co.uk/software/sip/intro) sources only. Doxygen\n# will parse them like normal C++ but will assume all classes use public instead\n# of private inheritance when no explicit protection keyword is present.\n# The default value is: NO.\n\nSIP_SUPPORT            = NO\n\n# For Microsoft's IDL there are propget and propput attributes to indicate\n# getter and setter methods for a property. Setting this option to YES will make\n# doxygen to replace the get and set methods by a property in the documentation.\n# This will only work if the methods are indeed getting or setting a simple\n# type. If this is not the case, or you want to show the methods anyway, you\n# should set this option to NO.\n# The default value is: YES.\n\nIDL_PROPERTY_SUPPORT   = YES\n\n# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC\n# tag is set to YES, then doxygen will reuse the documentation of the first\n# member in the group (if any) for the other members of the group. By default\n# all members of a group must be documented explicitly.\n# The default value is: NO.\n\nDISTRIBUTE_GROUP_DOC   = NO\n\n# Set the SUBGROUPING tag to YES to allow class member groups of the same type\n# (for instance a group of public functions) to be put as a subgroup of that\n# type (e.g. under the Public Functions section). Set it to NO to prevent\n# subgrouping. Alternatively, this can be done per class using the\n# \\nosubgrouping command.\n# The default value is: YES.\n\nSUBGROUPING            = YES\n\n# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and unions\n# are shown inside the group in which they are included (e.g. using \\ingroup)\n# instead of on a separate page (for HTML and Man pages) or section (for LaTeX\n# and RTF).\n#\n# Note that this feature does not work in combination with\n# SEPARATE_MEMBER_PAGES.\n# The default value is: NO.\n\nINLINE_GROUPED_CLASSES = NO\n\n# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and unions\n# with only public data fields or simple typedef fields will be shown inline in\n# the documentation of the scope in which they are defined (i.e. file,\n# namespace, or group documentation), provided this scope is documented. If set\n# to NO, structs, classes, and unions are shown on a separate page (for HTML and\n# Man pages) or section (for LaTeX and RTF).\n# The default value is: NO.\n\nINLINE_SIMPLE_STRUCTS  = NO\n\n# When TYPEDEF_HIDES_STRUCT tag is enabled, a typedef of a struct, union, or\n# enum is documented as struct, union, or enum with the name of the typedef. So\n# typedef struct TypeS {} TypeT, will appear in the documentation as a struct\n# with name TypeT. When disabled the typedef will appear as a member of a file,\n# namespace, or class. And the struct will be named TypeS. This can typically be\n# useful for C code in case the coding convention dictates that all compound\n# types are typedef'ed and only the typedef is referenced, never the tag name.\n# The default value is: NO.\n\nTYPEDEF_HIDES_STRUCT   = NO\n\n# The size of the symbol lookup cache can be set using LOOKUP_CACHE_SIZE. This\n# cache is used to resolve symbols given their name and scope. Since this can be\n# an expensive process and often the same symbol appears multiple times in the\n# code, doxygen keeps a cache of pre-resolved symbols. If the cache is too small\n# doxygen will become slower. If the cache is too large, memory is wasted. The\n# cache size is given by this formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range\n# is 0..9, the default is 0, corresponding to a cache size of 2^16=65536\n# symbols. At the end of a run doxygen will report the cache usage and suggest\n# the optimal cache size from a speed point of view.\n# Minimum value: 0, maximum value: 9, default value: 0.\n\nLOOKUP_CACHE_SIZE      = 0\n\n#---------------------------------------------------------------------------\n# Build related configuration options\n#---------------------------------------------------------------------------\n\n# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in\n# documentation are documented, even if no documentation was available. Private\n# class members and static file members will be hidden unless the\n# EXTRACT_PRIVATE respectively EXTRACT_STATIC tags are set to YES.\n# Note: This will also disable the warnings about undocumented members that are\n# normally produced when WARNINGS is set to YES.\n# The default value is: NO.\n\nEXTRACT_ALL            = NO\n\n# If the EXTRACT_PRIVATE tag is set to YES all private members of a class will\n# be included in the documentation.\n# The default value is: NO.\n\nEXTRACT_PRIVATE        = NO\n\n# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal\n# scope will be included in the documentation.\n# The default value is: NO.\n\nEXTRACT_PACKAGE        = NO\n\n# If the EXTRACT_STATIC tag is set to YES all static members of a file will be\n# included in the documentation.\n# The default value is: NO.\n\nEXTRACT_STATIC         = NO\n\n# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) defined\n# locally in source files will be included in the documentation. If set to NO\n# only classes defined in header files are included. Does not have any effect\n# for Java sources.\n# The default value is: YES.\n\nEXTRACT_LOCAL_CLASSES  = YES\n\n# This flag is only useful for Objective-C code. When set to YES local methods,\n# which are defined in the implementation section but not in the interface are\n# included in the documentation. If set to NO only methods in the interface are\n# included.\n# The default value is: NO.\n\nEXTRACT_LOCAL_METHODS  = NO\n\n# If this flag is set to YES, the members of anonymous namespaces will be\n# extracted and appear in the documentation as a namespace called\n# 'anonymous_namespace{file}', where file will be replaced with the base name of\n# the file that contains the anonymous namespace. By default anonymous namespace\n# are hidden.\n# The default value is: NO.\n\nEXTRACT_ANON_NSPACES   = NO\n\n# If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all\n# undocumented members inside documented classes or files. If set to NO these\n# members will be included in the various overviews, but no documentation\n# section is generated. This option has no effect if EXTRACT_ALL is enabled.\n# The default value is: NO.\n\nHIDE_UNDOC_MEMBERS     = NO\n\n# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all\n# undocumented classes that are normally visible in the class hierarchy. If set\n# to NO these classes will be included in the various overviews. This option has\n# no effect if EXTRACT_ALL is enabled.\n# The default value is: NO.\n\nHIDE_UNDOC_CLASSES     = NO\n\n# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend\n# (class|struct|union) declarations. If set to NO these declarations will be\n# included in the documentation.\n# The default value is: NO.\n\nHIDE_FRIEND_COMPOUNDS  = NO\n\n# If the HIDE_IN_BODY_DOCS tag is set to YES, doxygen will hide any\n# documentation blocks found inside the body of a function. If set to NO these\n# blocks will be appended to the function's detailed documentation block.\n# The default value is: NO.\n\nHIDE_IN_BODY_DOCS      = NO\n\n# The INTERNAL_DOCS tag determines if documentation that is typed after a\n# \\internal command is included. If the tag is set to NO then the documentation\n# will be excluded. Set it to YES to include the internal documentation.\n# The default value is: NO.\n\nINTERNAL_DOCS          = NO\n\n# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file\n# names in lower-case letters. If set to YES upper-case letters are also\n# allowed. This is useful if you have classes or files whose names only differ\n# in case and if your file system supports case sensitive file names. Windows\n# and Mac users are advised to set this option to NO.\n# The default value is: system dependent.\n\nCASE_SENSE_NAMES       = YES\n\n# If the HIDE_SCOPE_NAMES tag is set to NO then doxygen will show members with\n# their full class and namespace scopes in the documentation. If set to YES the\n# scope will be hidden.\n# The default value is: NO.\n\nHIDE_SCOPE_NAMES       = NO\n\n# If the SHOW_INCLUDE_FILES tag is set to YES then doxygen will put a list of\n# the files that are included by a file in the documentation of that file.\n# The default value is: YES.\n\nSHOW_INCLUDE_FILES     = YES\n\n# If the SHOW_GROUPED_MEMB_INC tag is set to YES then Doxygen will add for each\n# grouped member an include statement to the documentation, telling the reader\n# which file to include in order to use the member.\n# The default value is: NO.\n\nSHOW_GROUPED_MEMB_INC  = NO\n\n# If the FORCE_LOCAL_INCLUDES tag is set to YES then doxygen will list include\n# files with double quotes in the documentation rather than with sharp brackets.\n# The default value is: NO.\n\nFORCE_LOCAL_INCLUDES   = NO\n\n# If the INLINE_INFO tag is set to YES then a tag [inline] is inserted in the\n# documentation for inline members.\n# The default value is: YES.\n\nINLINE_INFO            = YES\n\n# If the SORT_MEMBER_DOCS tag is set to YES then doxygen will sort the\n# (detailed) documentation of file and class members alphabetically by member\n# name. If set to NO the members will appear in declaration order.\n# The default value is: YES.\n\nSORT_MEMBER_DOCS       = YES\n\n# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the brief\n# descriptions of file, namespace and class members alphabetically by member\n# name. If set to NO the members will appear in declaration order. Note that\n# this will also influence the order of the classes in the class list.\n# The default value is: NO.\n\nSORT_BRIEF_DOCS        = NO\n\n# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the\n# (brief and detailed) documentation of class members so that constructors and\n# destructors are listed first. If set to NO the constructors will appear in the\n# respective orders defined by SORT_BRIEF_DOCS and SORT_MEMBER_DOCS.\n# Note: If SORT_BRIEF_DOCS is set to NO this option is ignored for sorting brief\n# member documentation.\n# Note: If SORT_MEMBER_DOCS is set to NO this option is ignored for sorting\n# detailed member documentation.\n# The default value is: NO.\n\nSORT_MEMBERS_CTORS_1ST = NO\n\n# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the hierarchy\n# of group names into alphabetical order. If set to NO the group names will\n# appear in their defined order.\n# The default value is: NO.\n\nSORT_GROUP_NAMES       = NO\n\n# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be sorted by\n# fully-qualified names, including namespaces. If set to NO, the class list will\n# be sorted only by class name, not including the namespace part.\n# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.\n# Note: This option applies only to the class list, not to the alphabetical\n# list.\n# The default value is: NO.\n\nSORT_BY_SCOPE_NAME     = NO\n\n# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to do proper\n# type resolution of all parameters of a function it will reject a match between\n# the prototype and the implementation of a member function even if there is\n# only one candidate or it is obvious which candidate to choose by doing a\n# simple string match. By disabling STRICT_PROTO_MATCHING doxygen will still\n# accept a match between prototype and implementation in such cases.\n# The default value is: NO.\n\nSTRICT_PROTO_MATCHING  = NO\n\n# The GENERATE_TODOLIST tag can be used to enable ( YES) or disable ( NO) the\n# todo list. This list is created by putting \\todo commands in the\n# documentation.\n# The default value is: YES.\n\nGENERATE_TODOLIST      = YES\n\n# The GENERATE_TESTLIST tag can be used to enable ( YES) or disable ( NO) the\n# test list. This list is created by putting \\test commands in the\n# documentation.\n# The default value is: YES.\n\nGENERATE_TESTLIST      = YES\n\n# The GENERATE_BUGLIST tag can be used to enable ( YES) or disable ( NO) the bug\n# list. This list is created by putting \\bug commands in the documentation.\n# The default value is: YES.\n\nGENERATE_BUGLIST       = YES\n\n# The GENERATE_DEPRECATEDLIST tag can be used to enable ( YES) or disable ( NO)\n# the deprecated list. This list is created by putting \\deprecated commands in\n# the documentation.\n# The default value is: YES.\n\nGENERATE_DEPRECATEDLIST= YES\n\n# The ENABLED_SECTIONS tag can be used to enable conditional documentation\n# sections, marked by \\if <section_label> ... \\endif and \\cond <section_label>\n# ... \\endcond blocks.\n\nENABLED_SECTIONS       =\n\n# The MAX_INITIALIZER_LINES tag determines the maximum number of lines that the\n# initial value of a variable or macro / define can have for it to appear in the\n# documentation. If the initializer consists of more lines than specified here\n# it will be hidden. Use a value of 0 to hide initializers completely. The\n# appearance of the value of individual variables and macros / defines can be\n# controlled using \\showinitializer or \\hideinitializer command in the\n# documentation regardless of this setting.\n# Minimum value: 0, maximum value: 10000, default value: 30.\n\nMAX_INITIALIZER_LINES  = 30\n\n# Set the SHOW_USED_FILES tag to NO to disable the list of files generated at\n# the bottom of the documentation of classes and structs. If set to YES the list\n# will mention the files that were used to generate the documentation.\n# The default value is: YES.\n\nSHOW_USED_FILES        = YES\n\n# Set the SHOW_FILES tag to NO to disable the generation of the Files page. This\n# will remove the Files entry from the Quick Index and from the Folder Tree View\n# (if specified).\n# The default value is: YES.\n\nSHOW_FILES             = YES\n\n# Set the SHOW_NAMESPACES tag to NO to disable the generation of the Namespaces\n# page. This will remove the Namespaces entry from the Quick Index and from the\n# Folder Tree View (if specified).\n# The default value is: YES.\n\nSHOW_NAMESPACES        = YES\n\n# The FILE_VERSION_FILTER tag can be used to specify a program or script that\n# doxygen should invoke to get the current version for each file (typically from\n# the version control system). Doxygen will invoke the program by executing (via\n# popen()) the command command input-file, where command is the value of the\n# FILE_VERSION_FILTER tag, and input-file is the name of an input file provided\n# by doxygen. Whatever the program writes to standard output is used as the file\n# version. For an example see the documentation.\n\nFILE_VERSION_FILTER    =\n\n# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed\n# by doxygen. The layout file controls the global structure of the generated\n# output files in an output format independent way. To create the layout file\n# that represents doxygen's defaults, run doxygen with the -l option. You can\n# optionally specify a file name after the option, if omitted DoxygenLayout.xml\n# will be used as the name of the layout file.\n#\n# Note that if you run doxygen from a directory containing a file called\n# DoxygenLayout.xml, doxygen will parse it automatically even if the LAYOUT_FILE\n# tag is left empty.\n\nLAYOUT_FILE            =\n\n# The CITE_BIB_FILES tag can be used to specify one or more bib files containing\n# the reference definitions. This must be a list of .bib files. The .bib\n# extension is automatically appended if omitted. This requires the bibtex tool\n# to be installed. See also http://en.wikipedia.org/wiki/BibTeX for more info.\n# For LaTeX the style of the bibliography can be controlled using\n# LATEX_BIB_STYLE. To use this feature you need bibtex and perl available in the\n# search path. Do not use file names with spaces, bibtex cannot handle them. See\n# also \\cite for info how to create references.\n\nCITE_BIB_FILES         =\n\n#---------------------------------------------------------------------------\n# Configuration options related to warning and progress messages\n#---------------------------------------------------------------------------\n\n# The QUIET tag can be used to turn on/off the messages that are generated to\n# standard output by doxygen. If QUIET is set to YES this implies that the\n# messages are off.\n# The default value is: NO.\n\nQUIET                  = NO\n\n# The WARNINGS tag can be used to turn on/off the warning messages that are\n# generated to standard error ( stderr) by doxygen. If WARNINGS is set to YES\n# this implies that the warnings are on.\n#\n# Tip: Turn warnings on while writing the documentation.\n# The default value is: YES.\n\nWARNINGS               = YES\n\n# If the WARN_IF_UNDOCUMENTED tag is set to YES, then doxygen will generate\n# warnings for undocumented members. If EXTRACT_ALL is set to YES then this flag\n# will automatically be disabled.\n# The default value is: YES.\n\nWARN_IF_UNDOCUMENTED   = YES\n\n# If the WARN_IF_DOC_ERROR tag is set to YES, doxygen will generate warnings for\n# potential errors in the documentation, such as not documenting some parameters\n# in a documented function, or documenting parameters that don't exist or using\n# markup commands wrongly.\n# The default value is: YES.\n\nWARN_IF_DOC_ERROR      = YES\n\n# This WARN_NO_PARAMDOC option can be enabled to get warnings for functions that\n# are documented, but have no documentation for their parameters or return\n# value. If set to NO doxygen will only warn about wrong or incomplete parameter\n# documentation, but not about the absence of documentation.\n# The default value is: NO.\n\nWARN_NO_PARAMDOC       = NO\n\n# The WARN_FORMAT tag determines the format of the warning messages that doxygen\n# can produce. The string should contain the $file, $line, and $text tags, which\n# will be replaced by the file and line number from which the warning originated\n# and the warning text. Optionally the format may contain $version, which will\n# be replaced by the version of the file (if it could be obtained via\n# FILE_VERSION_FILTER)\n# The default value is: $file:$line: $text.\n\nWARN_FORMAT            = \"$file:$line: $text\"\n\n# The WARN_LOGFILE tag can be used to specify a file to which warning and error\n# messages should be written. If left blank the output is written to standard\n# error (stderr).\n\nWARN_LOGFILE           =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the input files\n#---------------------------------------------------------------------------\n\n# The INPUT tag is used to specify the files and/or directories that contain\n# documented source files. You may enter file names like myfile.cpp or\n# directories like /usr/src/myproject. Separate the files or directories with\n# spaces.\n# Note: If this tag is empty the current directory is searched.\n\nINPUT                  = @CMAKE_SOURCE_DIR@/plugins \\\n                         @CMAKE_SOURCE_DIR@/harness\n\n# This tag can be used to specify the character encoding of the source files\n# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses\n# libiconv (or the iconv built into libc) for the transcoding. See the libiconv\n# documentation (see: http://www.gnu.org/software/libiconv) for the list of\n# possible encodings.\n# The default value is: UTF-8.\n\nINPUT_ENCODING         = UTF-8\n\n# If the value of the INPUT tag contains directories, you can use the\n# FILE_PATTERNS tag to specify one or more wildcard patterns (like *.cpp and\n# *.h) to filter out the source-files in the directories. If left blank the\n# following patterns are tested:*.c, *.cc, *.cxx, *.cpp, *.c++, *.java, *.ii,\n# *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, *.hh, *.hxx, *.hpp,\n# *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, *.m, *.markdown,\n# *.md, *.mm, *.dox, *.py, *.f90, *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf,\n# *.qsf, *.as and *.js.\n\nFILE_PATTERNS          =\n\n# The RECURSIVE tag can be used to specify whether or not subdirectories should\n# be searched for input files as well.\n# The default value is: NO.\n\nRECURSIVE              = YES\n\n# The EXCLUDE tag can be used to specify files and/or directories that should be\n# excluded from the INPUT source files. This way you can easily exclude a\n# subdirectory from a directory tree whose root is specified with the INPUT tag.\n#\n# Note that relative paths are relative to the directory from which doxygen is\n# run.\n\nEXCLUDE                =\n\n# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or\n# directories that are symbolic links (a Unix file system feature) are excluded\n# from the input.\n# The default value is: NO.\n\nEXCLUDE_SYMLINKS       = NO\n\n# If the value of the INPUT tag contains directories, you can use the\n# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude\n# certain files from those directories.\n#\n# Note that the wildcards are matched against the file with absolute path, so to\n# exclude all test directories for example use the pattern */test/*\n\nEXCLUDE_PATTERNS       =\n\n# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names\n# (namespaces, classes, functions, etc.) that should be excluded from the\n# output. The symbol name can be a fully qualified name, a word, or if the\n# wildcard * is used, a substring. Examples: ANamespace, AClass,\n# AClass::ANamespace, ANamespace::*Test\n#\n# Note that the wildcards are matched against the file with absolute path, so to\n# exclude all test directories use the pattern */test/*\n\nEXCLUDE_SYMBOLS        =\n\n# The EXAMPLE_PATH tag can be used to specify one or more files or directories\n# that contain example code fragments that are included (see the \\include\n# command).\n\nEXAMPLE_PATH           =\n\n# If the value of the EXAMPLE_PATH tag contains directories, you can use the\n# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and\n# *.h) to filter out the source-files in the directories. If left blank all\n# files are included.\n\nEXAMPLE_PATTERNS       =\n\n# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be\n# searched for input files to be used with the \\include or \\dontinclude commands\n# irrespective of the value of the RECURSIVE tag.\n# The default value is: NO.\n\nEXAMPLE_RECURSIVE      = NO\n\n# The IMAGE_PATH tag can be used to specify one or more files or directories\n# that contain images that are to be included in the documentation (see the\n# \\image command).\n\nIMAGE_PATH             =\n\n# The INPUT_FILTER tag can be used to specify a program that doxygen should\n# invoke to filter for each input file. Doxygen will invoke the filter program\n# by executing (via popen()) the command:\n#\n# <filter> <input-file>\n#\n# where <filter> is the value of the INPUT_FILTER tag, and <input-file> is the\n# name of an input file. Doxygen will then use the output that the filter\n# program writes to standard output. If FILTER_PATTERNS is specified, this tag\n# will be ignored.\n#\n# Note that the filter must not add or remove lines; it is applied before the\n# code is scanned, but not when the output code is generated. If lines are added\n# or removed, the anchors will not be placed correctly.\n\nINPUT_FILTER           =\n\n# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern\n# basis. Doxygen will compare the file name with each pattern and apply the\n# filter if there is a match. The filters are a list of the form: pattern=filter\n# (like *.cpp=my_cpp_filter). See INPUT_FILTER for further information on how\n# filters are used. If the FILTER_PATTERNS tag is empty or if none of the\n# patterns match the file name, INPUT_FILTER is applied.\n\nFILTER_PATTERNS        =\n\n# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using\n# INPUT_FILTER ) will also be used to filter the input files that are used for\n# producing the source files to browse (i.e. when SOURCE_BROWSER is set to YES).\n# The default value is: NO.\n\nFILTER_SOURCE_FILES    = NO\n\n# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file\n# pattern. A pattern will override the setting for FILTER_PATTERN (if any) and\n# it is also possible to disable source filtering for a specific pattern using\n# *.ext= (so without naming a filter).\n# This tag requires that the tag FILTER_SOURCE_FILES is set to YES.\n\nFILTER_SOURCE_PATTERNS =\n\n# If the USE_MDFILE_AS_MAINPAGE tag refers to the name of a markdown file that\n# is part of the input, its contents will be placed on the main page\n# (index.html). This can be useful if you have a project on for instance GitHub\n# and want to reuse the introduction page also for the doxygen output.\n\nUSE_MDFILE_AS_MAINPAGE =\n\n#---------------------------------------------------------------------------\n# Configuration options related to source browsing\n#---------------------------------------------------------------------------\n\n# If the SOURCE_BROWSER tag is set to YES then a list of source files will be\n# generated. Documented entities will be cross-referenced with these sources.\n#\n# Note: To get rid of all source code in the generated output, make sure that\n# also VERBATIM_HEADERS is set to NO.\n# The default value is: NO.\n\nSOURCE_BROWSER         = NO\n\n# Setting the INLINE_SOURCES tag to YES will include the body of functions,\n# classes and enums directly into the documentation.\n# The default value is: NO.\n\nINLINE_SOURCES         = NO\n\n# Setting the STRIP_CODE_COMMENTS tag to YES will instruct doxygen to hide any\n# special comment blocks from generated source code fragments. Normal C, C++ and\n# Fortran comments will always remain visible.\n# The default value is: YES.\n\nSTRIP_CODE_COMMENTS    = YES\n\n# If the REFERENCED_BY_RELATION tag is set to YES then for each documented\n# function all documented functions referencing it will be listed.\n# The default value is: NO.\n\nREFERENCED_BY_RELATION = NO\n\n# If the REFERENCES_RELATION tag is set to YES then for each documented function\n# all documented entities called/used by that function will be listed.\n# The default value is: NO.\n\nREFERENCES_RELATION    = NO\n\n# If the REFERENCES_LINK_SOURCE tag is set to YES and SOURCE_BROWSER tag is set\n# to YES, then the hyperlinks from functions in REFERENCES_RELATION and\n# REFERENCED_BY_RELATION lists will link to the source code. Otherwise they will\n# link to the documentation.\n# The default value is: YES.\n\nREFERENCES_LINK_SOURCE = YES\n\n# If SOURCE_TOOLTIPS is enabled (the default) then hovering a hyperlink in the\n# source code will show a tooltip with additional information such as prototype,\n# brief description and links to the definition and documentation. Since this\n# will make the HTML file larger and loading of large files a bit slower, you\n# can opt to disable this feature.\n# The default value is: YES.\n# This tag requires that the tag SOURCE_BROWSER is set to YES.\n\nSOURCE_TOOLTIPS        = YES\n\n# If the USE_HTAGS tag is set to YES then the references to source code will\n# point to the HTML generated by the htags(1) tool instead of doxygen built-in\n# source browser. The htags tool is part of GNU's global source tagging system\n# (see http://www.gnu.org/software/global/global.html). You will need version\n# 4.8.6 or higher.\n#\n# To use it do the following:\n# - Install the latest version of global\n# - Enable SOURCE_BROWSER and USE_HTAGS in the config file\n# - Make sure the INPUT points to the root of the source tree\n# - Run doxygen as normal\n#\n# Doxygen will invoke htags (and that will in turn invoke gtags), so these\n# tools must be available from the command line (i.e. in the search path).\n#\n# The result: instead of the source browser generated by doxygen, the links to\n# source code will now point to the output of htags.\n# The default value is: NO.\n# This tag requires that the tag SOURCE_BROWSER is set to YES.\n\nUSE_HTAGS              = NO\n\n# If the VERBATIM_HEADERS tag is set the YES then doxygen will generate a\n# verbatim copy of the header file for each class for which an include is\n# specified. Set to NO to disable this.\n# See also: Section \\class.\n# The default value is: YES.\n\nVERBATIM_HEADERS       = YES\n\n#---------------------------------------------------------------------------\n# Configuration options related to the alphabetical class index\n#---------------------------------------------------------------------------\n\n# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index of all\n# compounds will be generated. Enable this if the project contains a lot of\n# classes, structs, unions or interfaces.\n# The default value is: YES.\n\nALPHABETICAL_INDEX     = YES\n\n# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in\n# which the alphabetical index list will be split.\n# Minimum value: 1, maximum value: 20, default value: 5.\n# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.\n\nCOLS_IN_ALPHA_INDEX    = 5\n\n# In case all classes in a project start with a common prefix, all classes will\n# be put under the same header in the alphabetical index. The IGNORE_PREFIX tag\n# can be used to specify a prefix (or a list of prefixes) that should be ignored\n# while generating the index headers.\n# This tag requires that the tag ALPHABETICAL_INDEX is set to YES.\n\nIGNORE_PREFIX          =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the HTML output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_HTML tag is set to YES doxygen will generate HTML output\n# The default value is: YES.\n\nGENERATE_HTML          = YES\n\n# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: html.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_OUTPUT            = html\n\n# The HTML_FILE_EXTENSION tag can be used to specify the file extension for each\n# generated HTML page (for example: .htm, .php, .asp).\n# The default value is: .html.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_FILE_EXTENSION    = .html\n\n# The HTML_HEADER tag can be used to specify a user-defined HTML header file for\n# each generated HTML page. If the tag is left blank doxygen will generate a\n# standard header.\n#\n# To get valid HTML the header file that includes any scripts and style sheets\n# that doxygen needs, which is dependent on the configuration options used (e.g.\n# the setting GENERATE_TREEVIEW). It is highly recommended to start with a\n# default header using\n# doxygen -w html new_header.html new_footer.html new_stylesheet.css\n# YourConfigFile\n# and then modify the file new_header.html. See also section \"Doxygen usage\"\n# for information on how to generate the default header that doxygen normally\n# uses.\n# Note: The header is subject to change so you typically have to regenerate the\n# default header when upgrading to a newer version of doxygen. For a description\n# of the possible markers and block names see the documentation.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_HEADER            =\n\n# The HTML_FOOTER tag can be used to specify a user-defined HTML footer for each\n# generated HTML page. If the tag is left blank doxygen will generate a standard\n# footer. See HTML_HEADER for more information on how to generate a default\n# footer and what special commands can be used inside the footer. See also\n# section \"Doxygen usage\" for information on how to generate the default footer\n# that doxygen normally uses.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_FOOTER            =\n\n# The HTML_STYLESHEET tag can be used to specify a user-defined cascading style\n# sheet that is used by each HTML page. It can be used to fine-tune the look of\n# the HTML output. If left blank doxygen will generate a default style sheet.\n# See also section \"Doxygen usage\" for information on how to generate the style\n# sheet that doxygen normally uses.\n# Note: It is recommended to use HTML_EXTRA_STYLESHEET instead of this tag, as\n# it is more robust and this tag (HTML_STYLESHEET) will in the future become\n# obsolete.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_STYLESHEET        =\n\n# The HTML_EXTRA_STYLESHEET tag can be used to specify an additional user-\n# defined cascading style sheet that is included after the standard style sheets\n# created by doxygen. Using this option one can overrule certain style aspects.\n# This is preferred over using HTML_STYLESHEET since it does not replace the\n# standard style sheet and is therefor more robust against future updates.\n# Doxygen will copy the style sheet file to the output directory. For an example\n# see the documentation.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_EXTRA_STYLESHEET  =\n\n# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or\n# other source files which should be copied to the HTML output directory. Note\n# that these files will be copied to the base HTML output directory. Use the\n# $relpath^ marker in the HTML_HEADER and/or HTML_FOOTER files to load these\n# files. In the HTML_STYLESHEET file, use the file name only. Also note that the\n# files will be copied as-is; there are no commands or markers available.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_EXTRA_FILES       =\n\n# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. Doxygen\n# will adjust the colors in the stylesheet and background images according to\n# this color. Hue is specified as an angle on a colorwheel, see\n# http://en.wikipedia.org/wiki/Hue for more information. For instance the value\n# 0 represents red, 60 is yellow, 120 is green, 180 is cyan, 240 is blue, 300\n# purple, and 360 is red again.\n# Minimum value: 0, maximum value: 359, default value: 220.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_COLORSTYLE_HUE    = 220\n\n# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of the colors\n# in the HTML output. For a value of 0 the output will use grayscales only. A\n# value of 255 will produce the most vivid colors.\n# Minimum value: 0, maximum value: 255, default value: 100.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_COLORSTYLE_SAT    = 100\n\n# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to the\n# luminance component of the colors in the HTML output. Values below 100\n# gradually make the output lighter, whereas values above 100 make the output\n# darker. The value divided by 100 is the actual gamma applied, so 80 represents\n# a gamma of 0.8, The value 220 represents a gamma of 2.2, and 100 does not\n# change the gamma.\n# Minimum value: 40, maximum value: 240, default value: 80.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_COLORSTYLE_GAMMA  = 80\n\n# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML\n# page will contain the date and time when the page was generated. Setting this\n# to NO can help when comparing the output of multiple runs.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_TIMESTAMP         = YES\n\n# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML\n# documentation will contain sections that can be hidden and shown after the\n# page has loaded.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_DYNAMIC_SECTIONS  = NO\n\n# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of entries\n# shown in the various tree structured indices initially; the user can expand\n# and collapse entries dynamically later on. Doxygen will expand the tree to\n# such a level that at most the specified number of entries are visible (unless\n# a fully collapsed tree already exceeds this amount). So setting the number of\n# entries 1 will produce a full collapsed tree by default. 0 is a special value\n# representing an infinite number of entries and will result in a full expanded\n# tree by default.\n# Minimum value: 0, maximum value: 9999, default value: 100.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nHTML_INDEX_NUM_ENTRIES = 100\n\n# If the GENERATE_DOCSET tag is set to YES, additional index files will be\n# generated that can be used as input for Apple's Xcode 3 integrated development\n# environment (see: http://developer.apple.com/tools/xcode/), introduced with\n# OSX 10.5 (Leopard). To create a documentation set, doxygen will generate a\n# Makefile in the HTML output directory. Running make will produce the docset in\n# that directory and running make install will install the docset in\n# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at\n# startup. See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html\n# for more information.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_DOCSET        = NO\n\n# This tag determines the name of the docset feed. A documentation feed provides\n# an umbrella under which multiple documentation sets from a single provider\n# (such as a company or product suite) can be grouped.\n# The default value is: Doxygen generated docs.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_FEEDNAME        = \"Doxygen generated docs\"\n\n# This tag specifies a string that should uniquely identify the documentation\n# set bundle. This should be a reverse domain-name style string, e.g.\n# com.mycompany.MyDocSet. Doxygen will append .docset to the name.\n# The default value is: org.doxygen.Project.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_BUNDLE_ID       = org.doxygen.Project\n\n# The DOCSET_PUBLISHER_ID tag specifies a string that should uniquely identify\n# the documentation publisher. This should be a reverse domain-name style\n# string, e.g. com.mycompany.MyDocSet.documentation.\n# The default value is: org.doxygen.Publisher.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_PUBLISHER_ID    = org.doxygen.Publisher\n\n# The DOCSET_PUBLISHER_NAME tag identifies the documentation publisher.\n# The default value is: Publisher.\n# This tag requires that the tag GENERATE_DOCSET is set to YES.\n\nDOCSET_PUBLISHER_NAME  = Publisher\n\n# If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three\n# additional HTML index files: index.hhp, index.hhc, and index.hhk. The\n# index.hhp is a project file that can be read by Microsoft's HTML Help Workshop\n# (see: http://www.microsoft.com/en-us/download/details.aspx?id=21138) on\n# Windows.\n#\n# The HTML Help Workshop contains a compiler that can convert all HTML output\n# generated by doxygen into a single compiled HTML file (.chm). Compiled HTML\n# files are now used as the Windows 98 help format, and will replace the old\n# Windows help format (.hlp) on all Windows platforms in the future. Compressed\n# HTML files also contain an index, a table of contents, and you can search for\n# words in the documentation. The HTML workshop also contains a viewer for\n# compressed HTML files.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_HTMLHELP      = NO\n\n# The CHM_FILE tag can be used to specify the file name of the resulting .chm\n# file. You can add a path in front of the file if the result should not be\n# written to the html output directory.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nCHM_FILE               =\n\n# The HHC_LOCATION tag can be used to specify the location (absolute path\n# including file name) of the HTML help compiler ( hhc.exe). If non-empty\n# doxygen will try to run the HTML help compiler on the generated index.hhp.\n# The file has to be specified with full path.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nHHC_LOCATION           =\n\n# The GENERATE_CHI flag controls if a separate .chi index file is generated (\n# YES) or that it should be included in the master .chm file ( NO).\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nGENERATE_CHI           = NO\n\n# The CHM_INDEX_ENCODING is used to encode HtmlHelp index ( hhk), content ( hhc)\n# and project file content.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nCHM_INDEX_ENCODING     =\n\n# The BINARY_TOC flag controls whether a binary table of contents is generated (\n# YES) or a normal table of contents ( NO) in the .chm file.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nBINARY_TOC             = NO\n\n# The TOC_EXPAND flag can be set to YES to add extra items for group members to\n# the table of contents of the HTML help documentation and to the tree view.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTMLHELP is set to YES.\n\nTOC_EXPAND             = NO\n\n# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and\n# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated that\n# can be used as input for Qt's qhelpgenerator to generate a Qt Compressed Help\n# (.qch) of the generated HTML documentation.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_QHP           = NO\n\n# If the QHG_LOCATION tag is specified, the QCH_FILE tag can be used to specify\n# the file name of the resulting .qch file. The path specified is relative to\n# the HTML output folder.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQCH_FILE               =\n\n# The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help\n# Project output. For more information please see Qt Help Project / Namespace\n# (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#namespace).\n# The default value is: org.doxygen.Project.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_NAMESPACE          = org.doxygen.Project\n\n# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt\n# Help Project output. For more information please see Qt Help Project / Virtual\n# Folders (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#virtual-\n# folders).\n# The default value is: doc.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_VIRTUAL_FOLDER     = doc\n\n# If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom\n# filter to add. For more information please see Qt Help Project / Custom\n# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-\n# filters).\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_CUST_FILTER_NAME   =\n\n# The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the\n# custom filter to add. For more information please see Qt Help Project / Custom\n# Filters (see: http://qt-project.org/doc/qt-4.8/qthelpproject.html#custom-\n# filters).\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_CUST_FILTER_ATTRS  =\n\n# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this\n# project's filter section matches. Qt Help Project / Filter Attributes (see:\n# http://qt-project.org/doc/qt-4.8/qthelpproject.html#filter-attributes).\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHP_SECT_FILTER_ATTRS  =\n\n# The QHG_LOCATION tag can be used to specify the location of Qt's\n# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the\n# generated .qhp file.\n# This tag requires that the tag GENERATE_QHP is set to YES.\n\nQHG_LOCATION           =\n\n# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files will be\n# generated, together with the HTML files, they form an Eclipse help plugin. To\n# install this plugin and make it available under the help contents menu in\n# Eclipse, the contents of the directory containing the HTML and XML files needs\n# to be copied into the plugins directory of eclipse. The name of the directory\n# within the plugins directory should be the same as the ECLIPSE_DOC_ID value.\n# After copying Eclipse needs to be restarted before the help appears.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_ECLIPSEHELP   = NO\n\n# A unique identifier for the Eclipse help plugin. When installing the plugin\n# the directory name containing the HTML and XML files should also have this\n# name. Each documentation set should have its own identifier.\n# The default value is: org.doxygen.Project.\n# This tag requires that the tag GENERATE_ECLIPSEHELP is set to YES.\n\nECLIPSE_DOC_ID         = org.doxygen.Project\n\n# If you want full control over the layout of the generated HTML pages it might\n# be necessary to disable the index and replace it with your own. The\n# DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) at top\n# of each HTML page. A value of NO enables the index and the value YES disables\n# it. Since the tabs in the index contain the same information as the navigation\n# tree, you can set this option to YES if you also set GENERATE_TREEVIEW to YES.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nDISABLE_INDEX          = NO\n\n# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index\n# structure should be generated to display hierarchical information. If the tag\n# value is set to YES, a side panel will be generated containing a tree-like\n# index structure (just like the one that is generated for HTML Help). For this\n# to work a browser that supports JavaScript, DHTML, CSS and frames is required\n# (i.e. any modern browser). Windows users are probably better off using the\n# HTML help feature. Via custom stylesheets (see HTML_EXTRA_STYLESHEET) one can\n# further fine-tune the look of the index. As an example, the default style\n# sheet generated by doxygen has an example that shows how to put an image at\n# the root of the tree instead of the PROJECT_NAME. Since the tree basically has\n# the same information as the tab index, you could consider setting\n# DISABLE_INDEX to YES when enabling this option.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nGENERATE_TREEVIEW      = NO\n\n# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values that\n# doxygen will group on one line in the generated HTML documentation.\n#\n# Note that a value of 0 will completely suppress the enum values from appearing\n# in the overview section.\n# Minimum value: 0, maximum value: 20, default value: 4.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nENUM_VALUES_PER_LINE   = 4\n\n# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be used\n# to set the initial width (in pixels) of the frame in which the tree is shown.\n# Minimum value: 0, maximum value: 1500, default value: 250.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nTREEVIEW_WIDTH         = 250\n\n# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open links to\n# external symbols imported via tag files in a separate window.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nEXT_LINKS_IN_WINDOW    = NO\n\n# Use this tag to change the font size of LaTeX formulas included as images in\n# the HTML documentation. When you change the font size after a successful\n# doxygen run you need to manually remove any form_*.png images from the HTML\n# output directory to force them to be regenerated.\n# Minimum value: 8, maximum value: 50, default value: 10.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nFORMULA_FONTSIZE       = 10\n\n# Use the FORMULA_TRANPARENT tag to determine whether or not the images\n# generated for formulas are transparent PNGs. Transparent PNGs are not\n# supported properly for IE 6.0, but are supported on all modern browsers.\n#\n# Note that when changing this option you need to delete any form_*.png files in\n# the HTML output directory before the changes have effect.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nFORMULA_TRANSPARENT    = YES\n\n# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see\n# http://www.mathjax.org) which uses client side Javascript for the rendering\n# instead of using prerendered bitmaps. Use this if you do not have LaTeX\n# installed or if you want to formulas look prettier in the HTML output. When\n# enabled you may also need to install MathJax separately and configure the path\n# to it using the MATHJAX_RELPATH option.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nUSE_MATHJAX            = NO\n\n# When MathJax is enabled you can set the default output format to be used for\n# the MathJax output. See the MathJax site (see:\n# http://docs.mathjax.org/en/latest/output.html) for more details.\n# Possible values are: HTML-CSS (which is slower, but has the best\n# compatibility), NativeMML (i.e. MathML) and SVG.\n# The default value is: HTML-CSS.\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_FORMAT         = HTML-CSS\n\n# When MathJax is enabled you need to specify the location relative to the HTML\n# output directory using the MATHJAX_RELPATH option. The destination directory\n# should contain the MathJax.js script. For instance, if the mathjax directory\n# is located at the same level as the HTML output directory, then\n# MATHJAX_RELPATH should be ../mathjax. The default value points to the MathJax\n# Content Delivery Network so you can quickly see the result without installing\n# MathJax. However, it is strongly recommended to install a local copy of\n# MathJax from http://www.mathjax.org before deployment.\n# The default value is: http://cdn.mathjax.org/mathjax/latest.\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_RELPATH        = http://cdn.mathjax.org/mathjax/latest\n\n# The MATHJAX_EXTENSIONS tag can be used to specify one or more MathJax\n# extension names that should be enabled during MathJax rendering. For example\n# MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_EXTENSIONS     =\n\n# The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces\n# of code that will be used on startup of the MathJax code. See the MathJax site\n# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an\n# example see the documentation.\n# This tag requires that the tag USE_MATHJAX is set to YES.\n\nMATHJAX_CODEFILE       =\n\n# When the SEARCHENGINE tag is enabled doxygen will generate a search box for\n# the HTML output. The underlying search engine uses javascript and DHTML and\n# should work on any modern browser. Note that when using HTML help\n# (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET)\n# there is already a search function so this one should typically be disabled.\n# For large projects the javascript based search engine can be slow, then\n# enabling SERVER_BASED_SEARCH may provide a better solution. It is possible to\n# search using the keyboard; to jump to the search box use <access key> + S\n# (what the <access key> is depends on the OS and browser, but it is typically\n# <CTRL>, <ALT>/<option>, or both). Inside the search box use the <cursor down\n# key> to jump into the search results window, the results can be navigated\n# using the <cursor keys>. Press <Enter> to select an item or <escape> to cancel\n# the search. The filter options can be selected when the cursor is inside the\n# search box by pressing <Shift>+<cursor down>. Also here use the <cursor keys>\n# to select a filter and <Enter> or <escape> to activate or cancel the filter\n# option.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_HTML is set to YES.\n\nSEARCHENGINE           = YES\n\n# When the SERVER_BASED_SEARCH tag is enabled the search engine will be\n# implemented using a web server instead of a web client using Javascript. There\n# are two flavours of web server based searching depending on the\n# EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for\n# searching and an index file used by the script. When EXTERNAL_SEARCH is\n# enabled the indexing and searching needs to be provided by external tools. See\n# the section \"External Indexing and Searching\" for details.\n# The default value is: NO.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nSERVER_BASED_SEARCH    = NO\n\n# When EXTERNAL_SEARCH tag is enabled doxygen will no longer generate the PHP\n# script for searching. Instead the search results are written to an XML file\n# which needs to be processed by an external indexer. Doxygen will invoke an\n# external search engine pointed to by the SEARCHENGINE_URL option to obtain the\n# search results.\n#\n# Doxygen ships with an example indexer ( doxyindexer) and search engine\n# (doxysearch.cgi) which are based on the open source search engine library\n# Xapian (see: http://xapian.org/).\n#\n# See the section \"External Indexing and Searching\" for details.\n# The default value is: NO.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nEXTERNAL_SEARCH        = NO\n\n# The SEARCHENGINE_URL should point to a search engine hosted by a web server\n# which will return the search results when EXTERNAL_SEARCH is enabled.\n#\n# Doxygen ships with an example indexer ( doxyindexer) and search engine\n# (doxysearch.cgi) which are based on the open source search engine library\n# Xapian (see: http://xapian.org/). See the section \"External Indexing and\n# Searching\" for details.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nSEARCHENGINE_URL       =\n\n# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed\n# search data is written to a file for indexing by an external tool. With the\n# SEARCHDATA_FILE tag the name of this file can be specified.\n# The default file is: searchdata.xml.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nSEARCHDATA_FILE        = searchdata.xml\n\n# When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the\n# EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is\n# useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple\n# projects and redirect the results back to the right project.\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nEXTERNAL_SEARCH_ID     =\n\n# The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen\n# projects other than the one defined by this configuration file, but that are\n# all added to the same external search index. Each project needs to have a\n# unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id of\n# to a relative location where the documentation can be found. The format is:\n# EXTRA_SEARCH_MAPPINGS = tagname1=loc1 tagname2=loc2 ...\n# This tag requires that the tag SEARCHENGINE is set to YES.\n\nEXTRA_SEARCH_MAPPINGS  =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the LaTeX output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_LATEX tag is set to YES doxygen will generate LaTeX output.\n# The default value is: YES.\n\nGENERATE_LATEX         = YES\n\n# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: latex.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_OUTPUT           = latex\n\n# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be\n# invoked.\n#\n# Note that when enabling USE_PDFLATEX this option is only used for generating\n# bitmaps for formulas in the HTML output, but not in the Makefile that is\n# written to the output directory.\n# The default file is: latex.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_CMD_NAME         = latex\n\n# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to generate\n# index for LaTeX.\n# The default file is: makeindex.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nMAKEINDEX_CMD_NAME     = makeindex\n\n# If the COMPACT_LATEX tag is set to YES doxygen generates more compact LaTeX\n# documents. This may be useful for small projects and may help to save some\n# trees in general.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nCOMPACT_LATEX          = NO\n\n# The PAPER_TYPE tag can be used to set the paper type that is used by the\n# printer.\n# Possible values are: a4 (210 x 297 mm), letter (8.5 x 11 inches), legal (8.5 x\n# 14 inches) and executive (7.25 x 10.5 inches).\n# The default value is: a4.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nPAPER_TYPE             = a4\n\n# The EXTRA_PACKAGES tag can be used to specify one or more LaTeX package names\n# that should be included in the LaTeX output. To get the times font for\n# instance you can specify\n# EXTRA_PACKAGES=times\n# If left blank no extra packages will be included.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nEXTRA_PACKAGES         =\n\n# The LATEX_HEADER tag can be used to specify a personal LaTeX header for the\n# generated LaTeX document. The header should contain everything until the first\n# chapter. If it is left blank doxygen will generate a standard header. See\n# section \"Doxygen usage\" for information on how to let doxygen write the\n# default header to a separate file.\n#\n# Note: Only use a user-defined header if you know what you are doing! The\n# following commands have a special meaning inside the header: $title,\n# $datetime, $date, $doxygenversion, $projectname, $projectnumber. Doxygen will\n# replace them by respectively the title of the page, the current date and time,\n# only the current date, the version number of doxygen, the project name (see\n# PROJECT_NAME), or the project number (see PROJECT_NUMBER).\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_HEADER           =\n\n# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for the\n# generated LaTeX document. The footer should contain everything after the last\n# chapter. If it is left blank doxygen will generate a standard footer.\n#\n# Note: Only use a user-defined footer if you know what you are doing!\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_FOOTER           =\n\n# The LATEX_EXTRA_FILES tag can be used to specify one or more extra images or\n# other source files which should be copied to the LATEX_OUTPUT output\n# directory. Note that the files will be copied as-is; there are no commands or\n# markers available.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_EXTRA_FILES      =\n\n# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated is\n# prepared for conversion to PDF (using ps2pdf or pdflatex). The PDF file will\n# contain links (just like the HTML output) instead of page references. This\n# makes the output suitable for online browsing using a PDF viewer.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nPDF_HYPERLINKS         = YES\n\n# If the LATEX_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate\n# the PDF file directly from the LaTeX files. Set this option to YES to get a\n# higher quality PDF documentation.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nUSE_PDFLATEX           = YES\n\n# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode\n# command to the generated LaTeX files. This will instruct LaTeX to keep running\n# if errors occur, instead of asking the user for help. This option is also used\n# when generating formulas in HTML.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_BATCHMODE        = NO\n\n# If the LATEX_HIDE_INDICES tag is set to YES then doxygen will not include the\n# index chapters (such as File Index, Compound Index, etc.) in the output.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_HIDE_INDICES     = NO\n\n# If the LATEX_SOURCE_CODE tag is set to YES then doxygen will include source\n# code with syntax highlighting in the LaTeX output.\n#\n# Note that which sources are shown also depends on other settings such as\n# SOURCE_BROWSER.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_SOURCE_CODE      = NO\n\n# The LATEX_BIB_STYLE tag can be used to specify the style to use for the\n# bibliography, e.g. plainnat, or ieeetr. See\n# http://en.wikipedia.org/wiki/BibTeX and \\cite for more info.\n# The default value is: plain.\n# This tag requires that the tag GENERATE_LATEX is set to YES.\n\nLATEX_BIB_STYLE        = plain\n\n#---------------------------------------------------------------------------\n# Configuration options related to the RTF output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_RTF tag is set to YES doxygen will generate RTF output. The\n# RTF output is optimized for Word 97 and may not look too pretty with other RTF\n# readers/editors.\n# The default value is: NO.\n\nGENERATE_RTF           = NO\n\n# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: rtf.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_OUTPUT             = rtf\n\n# If the COMPACT_RTF tag is set to YES doxygen generates more compact RTF\n# documents. This may be useful for small projects and may help to save some\n# trees in general.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nCOMPACT_RTF            = NO\n\n# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated will\n# contain hyperlink fields. The RTF file will contain links (just like the HTML\n# output) instead of page references. This makes the output suitable for online\n# browsing using Word or some other Word compatible readers that support those\n# fields.\n#\n# Note: WordPad (write) and others do not support links.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_HYPERLINKS         = NO\n\n# Load stylesheet definitions from file. Syntax is similar to doxygen's config\n# file, i.e. a series of assignments. You only have to provide replacements,\n# missing definitions are set to their default value.\n#\n# See also section \"Doxygen usage\" for information on how to generate the\n# default style sheet that doxygen normally uses.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_STYLESHEET_FILE    =\n\n# Set optional variables used in the generation of an RTF document. Syntax is\n# similar to doxygen's config file. A template extensions file can be generated\n# using doxygen -e rtf extensionFile.\n# This tag requires that the tag GENERATE_RTF is set to YES.\n\nRTF_EXTENSIONS_FILE    =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the man page output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_MAN tag is set to YES doxygen will generate man pages for\n# classes and files.\n# The default value is: NO.\n\nGENERATE_MAN           = NO\n\n# The MAN_OUTPUT tag is used to specify where the man pages will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it. A directory man3 will be created inside the directory specified by\n# MAN_OUTPUT.\n# The default directory is: man.\n# This tag requires that the tag GENERATE_MAN is set to YES.\n\nMAN_OUTPUT             = man\n\n# The MAN_EXTENSION tag determines the extension that is added to the generated\n# man pages. In case the manual section does not start with a number, the number\n# 3 is prepended. The dot (.) at the beginning of the MAN_EXTENSION tag is\n# optional.\n# The default value is: .3.\n# This tag requires that the tag GENERATE_MAN is set to YES.\n\nMAN_EXTENSION          = .3\n\n# If the MAN_LINKS tag is set to YES and doxygen generates man output, then it\n# will generate one additional man file for each entity documented in the real\n# man page(s). These additional files only source the real man page, but without\n# them the man command would be unable to find the correct page.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_MAN is set to YES.\n\nMAN_LINKS              = NO\n\n#---------------------------------------------------------------------------\n# Configuration options related to the XML output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_XML tag is set to YES doxygen will generate an XML file that\n# captures the structure of the code including all documentation.\n# The default value is: NO.\n\nGENERATE_XML           = NO\n\n# The XML_OUTPUT tag is used to specify where the XML pages will be put. If a\n# relative path is entered the value of OUTPUT_DIRECTORY will be put in front of\n# it.\n# The default directory is: xml.\n# This tag requires that the tag GENERATE_XML is set to YES.\n\nXML_OUTPUT             = xml\n\n# The XML_SCHEMA tag can be used to specify a XML schema, which can be used by a\n# validating XML parser to check the syntax of the XML files.\n# This tag requires that the tag GENERATE_XML is set to YES.\n\nXML_SCHEMA             =\n\n# The XML_DTD tag can be used to specify a XML DTD, which can be used by a\n# validating XML parser to check the syntax of the XML files.\n# This tag requires that the tag GENERATE_XML is set to YES.\n\nXML_DTD                =\n\n# If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program\n# listings (including syntax highlighting and cross-referencing information) to\n# the XML output. Note that enabling this will significantly increase the size\n# of the XML output.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_XML is set to YES.\n\nXML_PROGRAMLISTING     = YES\n\n#---------------------------------------------------------------------------\n# Configuration options related to the DOCBOOK output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_DOCBOOK tag is set to YES doxygen will generate Docbook files\n# that can be used to generate PDF.\n# The default value is: NO.\n\nGENERATE_DOCBOOK       = NO\n\n# The DOCBOOK_OUTPUT tag is used to specify where the Docbook pages will be put.\n# If a relative path is entered the value of OUTPUT_DIRECTORY will be put in\n# front of it.\n# The default directory is: docbook.\n# This tag requires that the tag GENERATE_DOCBOOK is set to YES.\n\nDOCBOOK_OUTPUT         = docbook\n\n#---------------------------------------------------------------------------\n# Configuration options for the AutoGen Definitions output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_AUTOGEN_DEF tag is set to YES doxygen will generate an AutoGen\n# Definitions (see http://autogen.sf.net) file that captures the structure of\n# the code including all documentation. Note that this feature is still\n# experimental and incomplete at the moment.\n# The default value is: NO.\n\nGENERATE_AUTOGEN_DEF   = NO\n\n#---------------------------------------------------------------------------\n# Configuration options related to the Perl module output\n#---------------------------------------------------------------------------\n\n# If the GENERATE_PERLMOD tag is set to YES doxygen will generate a Perl module\n# file that captures the structure of the code including all documentation.\n#\n# Note that this feature is still experimental and incomplete at the moment.\n# The default value is: NO.\n\nGENERATE_PERLMOD       = NO\n\n# If the PERLMOD_LATEX tag is set to YES doxygen will generate the necessary\n# Makefile rules, Perl scripts and LaTeX code to be able to generate PDF and DVI\n# output from the Perl module output.\n# The default value is: NO.\n# This tag requires that the tag GENERATE_PERLMOD is set to YES.\n\nPERLMOD_LATEX          = NO\n\n# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be nicely\n# formatted so it can be parsed by a human reader. This is useful if you want to\n# understand what is going on. On the other hand, if this tag is set to NO the\n# size of the Perl module output will be much smaller and Perl will parse it\n# just the same.\n# The default value is: YES.\n# This tag requires that the tag GENERATE_PERLMOD is set to YES.\n\nPERLMOD_PRETTY         = YES\n\n# The names of the make variables in the generated doxyrules.make file are\n# prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. This is useful\n# so different doxyrules.make files included by the same Makefile don't\n# overwrite each other's variables.\n# This tag requires that the tag GENERATE_PERLMOD is set to YES.\n\nPERLMOD_MAKEVAR_PREFIX =\n\n#---------------------------------------------------------------------------\n# Configuration options related to the preprocessor\n#---------------------------------------------------------------------------\n\n# If the ENABLE_PREPROCESSING tag is set to YES doxygen will evaluate all\n# C-preprocessor directives found in the sources and include files.\n# The default value is: YES.\n\nENABLE_PREPROCESSING   = YES\n\n# If the MACRO_EXPANSION tag is set to YES doxygen will expand all macro names\n# in the source code. If set to NO only conditional compilation will be\n# performed. Macro expansion can be done in a controlled way by setting\n# EXPAND_ONLY_PREDEF to YES.\n# The default value is: NO.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nMACRO_EXPANSION        = NO\n\n# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then\n# the macro expansion is limited to the macros specified with the PREDEFINED and\n# EXPAND_AS_DEFINED tags.\n# The default value is: NO.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nEXPAND_ONLY_PREDEF     = NO\n\n# If the SEARCH_INCLUDES tag is set to YES the includes files in the\n# INCLUDE_PATH will be searched if a #include is found.\n# The default value is: YES.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nSEARCH_INCLUDES        = YES\n\n# The INCLUDE_PATH tag can be used to specify one or more directories that\n# contain include files that are not input files but should be processed by the\n# preprocessor.\n# This tag requires that the tag SEARCH_INCLUDES is set to YES.\n\nINCLUDE_PATH           =\n\n# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard\n# patterns (like *.h and *.hpp) to filter out the header-files in the\n# directories. If left blank, the patterns specified with FILE_PATTERNS will be\n# used.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nINCLUDE_FILE_PATTERNS  =\n\n# The PREDEFINED tag can be used to specify one or more macro names that are\n# defined before the preprocessor is started (similar to the -D option of e.g.\n# gcc). The argument of the tag is a list of macros of the form: name or\n# name=definition (no spaces). If the definition and the \"=\" are omitted, \"=1\"\n# is assumed. To prevent a macro definition from being undefined via #undef or\n# recursively expanded use the := operator instead of the = operator.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nPREDEFINED             =\n\n# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this\n# tag can be used to specify a list of macro names that should be expanded. The\n# macro definition that is found in the sources will be used. Use the PREDEFINED\n# tag if you want to use a different macro definition that overrules the\n# definition found in the source code.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nEXPAND_AS_DEFINED      =\n\n# If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will\n# remove all refrences to function-like macros that are alone on a line, have an\n# all uppercase name, and do not end with a semicolon. Such function macros are\n# typically used for boiler-plate code, and will confuse the parser if not\n# removed.\n# The default value is: YES.\n# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.\n\nSKIP_FUNCTION_MACROS   = YES\n\n#---------------------------------------------------------------------------\n# Configuration options related to external references\n#---------------------------------------------------------------------------\n\n# The TAGFILES tag can be used to specify one or more tag files. For each tag\n# file the location of the external documentation should be added. The format of\n# a tag file without this location is as follows:\n# TAGFILES = file1 file2 ...\n# Adding location for the tag files is done as follows:\n# TAGFILES = file1=loc1 \"file2 = loc2\" ...\n# where loc1 and loc2 can be relative or absolute paths or URLs. See the\n# section \"Linking to external documentation\" for more information about the use\n# of tag files.\n# Note: Each tag file must have an unique name (where the name does NOT include\n# the path). If a tag file is not located in the directory in which doxygen is\n# run, you must also specify the path to the tagfile here.\n\nTAGFILES               =\n\n# When a file name is specified after GENERATE_TAGFILE, doxygen will create a\n# tag file that is based on the input files it reads. See section \"Linking to\n# external documentation\" for more information about the usage of tag files.\n\nGENERATE_TAGFILE       =\n\n# If the ALLEXTERNALS tag is set to YES all external class will be listed in the\n# class index. If set to NO only the inherited external classes will be listed.\n# The default value is: NO.\n\nALLEXTERNALS           = NO\n\n# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed in\n# the modules index. If set to NO, only the current project's groups will be\n# listed.\n# The default value is: YES.\n\nEXTERNAL_GROUPS        = YES\n\n# If the EXTERNAL_PAGES tag is set to YES all external pages will be listed in\n# the related pages index. If set to NO, only the current project's pages will\n# be listed.\n# The default value is: YES.\n\nEXTERNAL_PAGES         = YES\n\n# The PERL_PATH should be the absolute path and name of the perl script\n# interpreter (i.e. the result of 'which perl').\n# The default file (with absolute path) is: /usr/bin/perl.\n\nPERL_PATH              = /usr/bin/perl\n\n#---------------------------------------------------------------------------\n# Configuration options related to the dot tool\n#---------------------------------------------------------------------------\n\n# If the CLASS_DIAGRAMS tag is set to YES doxygen will generate a class diagram\n# (in HTML and LaTeX) for classes with base or super classes. Setting the tag to\n# NO turns the diagrams off. Note that this option also works with HAVE_DOT\n# disabled, but it is recommended to install and use dot, since it yields more\n# powerful graphs.\n# The default value is: YES.\n\nCLASS_DIAGRAMS         = YES\n\n# You can define message sequence charts within doxygen comments using the \\msc\n# command. Doxygen will then run the mscgen tool (see:\n# http://www.mcternan.me.uk/mscgen/)) to produce the chart and insert it in the\n# documentation. The MSCGEN_PATH tag allows you to specify the directory where\n# the mscgen tool resides. If left empty the tool is assumed to be found in the\n# default search path.\n\nMSCGEN_PATH            =\n\n# You can include diagrams made with dia in doxygen documentation. Doxygen will\n# then run dia to produce the diagram and insert it in the documentation. The\n# DIA_PATH tag allows you to specify the directory where the dia binary resides.\n# If left empty dia is assumed to be found in the default search path.\n\nDIA_PATH               =\n\n# If set to YES, the inheritance and collaboration graphs will hide inheritance\n# and usage relations if the target is undocumented or is not a class.\n# The default value is: YES.\n\nHIDE_UNDOC_RELATIONS   = YES\n\n# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is\n# available from the path. This tool is part of Graphviz (see:\n# http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent\n# Bell Labs. The other options in this section have no effect if this option is\n# set to NO\n# The default value is: NO.\n\nHAVE_DOT               = NO\n\n# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed\n# to run in parallel. When set to 0 doxygen will base this on the number of\n# processors available in the system. You can set it explicitly to a value\n# larger than 0 to get control over the balance between CPU load and processing\n# speed.\n# Minimum value: 0, maximum value: 32, default value: 0.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_NUM_THREADS        = 0\n\n# When you want a differently looking font n the dot files that doxygen\n# generates you can specify the font name using DOT_FONTNAME. You need to make\n# sure dot is able to find the font, which can be done by putting it in a\n# standard location or by setting the DOTFONTPATH environment variable or by\n# setting DOT_FONTPATH to the directory containing the font.\n# The default value is: Helvetica.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_FONTNAME           = Helvetica\n\n# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of\n# dot graphs.\n# Minimum value: 4, maximum value: 24, default value: 10.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_FONTSIZE           = 10\n\n# By default doxygen will tell dot to use the default font as specified with\n# DOT_FONTNAME. If you specify a different font using DOT_FONTNAME you can set\n# the path where dot can find it using this tag.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_FONTPATH           =\n\n# If the CLASS_GRAPH tag is set to YES then doxygen will generate a graph for\n# each documented class showing the direct and indirect inheritance relations.\n# Setting this tag to YES will force the CLASS_DIAGRAMS tag to NO.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCLASS_GRAPH            = YES\n\n# If the COLLABORATION_GRAPH tag is set to YES then doxygen will generate a\n# graph for each documented class showing the direct and indirect implementation\n# dependencies (inheritance, containment, and class references variables) of the\n# class with other documented classes.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCOLLABORATION_GRAPH    = YES\n\n# If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for\n# groups, showing the direct groups dependencies.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nGROUP_GRAPHS           = YES\n\n# If the UML_LOOK tag is set to YES doxygen will generate inheritance and\n# collaboration diagrams in a style similar to the OMG's Unified Modeling\n# Language.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nUML_LOOK               = NO\n\n# If the UML_LOOK tag is enabled, the fields and methods are shown inside the\n# class node. If there are many fields or methods and many nodes the graph may\n# become too big to be useful. The UML_LIMIT_NUM_FIELDS threshold limits the\n# number of items for each type to make the size more manageable. Set this to 0\n# for no limit. Note that the threshold may be exceeded by 50% before the limit\n# is enforced. So when you set the threshold to 10, up to 15 fields may appear,\n# but if the number exceeds 15, the total amount of fields shown is limited to\n# 10.\n# Minimum value: 0, maximum value: 100, default value: 10.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nUML_LIMIT_NUM_FIELDS   = 10\n\n# If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and\n# collaboration graphs will show the relations between templates and their\n# instances.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nTEMPLATE_RELATIONS     = NO\n\n# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to\n# YES then doxygen will generate a graph for each documented file showing the\n# direct and indirect include dependencies of the file with other documented\n# files.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nINCLUDE_GRAPH          = YES\n\n# If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are\n# set to YES then doxygen will generate a graph for each documented file showing\n# the direct and indirect include dependencies of the file with other documented\n# files.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nINCLUDED_BY_GRAPH      = YES\n\n# If the CALL_GRAPH tag is set to YES then doxygen will generate a call\n# dependency graph for every global function or class method.\n#\n# Note that enabling this option will significantly increase the time of a run.\n# So in most cases it will be better to enable call graphs for selected\n# functions only using the \\callgraph command.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCALL_GRAPH             = NO\n\n# If the CALLER_GRAPH tag is set to YES then doxygen will generate a caller\n# dependency graph for every global function or class method.\n#\n# Note that enabling this option will significantly increase the time of a run.\n# So in most cases it will be better to enable caller graphs for selected\n# functions only using the \\callergraph command.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nCALLER_GRAPH           = NO\n\n# If the GRAPHICAL_HIERARCHY tag is set to YES then doxygen will graphical\n# hierarchy of all classes instead of a textual one.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nGRAPHICAL_HIERARCHY    = YES\n\n# If the DIRECTORY_GRAPH tag is set to YES then doxygen will show the\n# dependencies a directory has on other directories in a graphical way. The\n# dependency relations are determined by the #include relations between the\n# files in the directories.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDIRECTORY_GRAPH        = YES\n\n# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images\n# generated by dot.\n# Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order\n# to make the SVG files visible in IE 9+ (other browsers do not have this\n# requirement).\n# Possible values are: png, jpg, gif and svg.\n# The default value is: png.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_IMAGE_FORMAT       = png\n\n# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to\n# enable generation of interactive SVG images that allow zooming and panning.\n#\n# Note that this requires a modern browser other than Internet Explorer. Tested\n# and working are Firefox, Chrome, Safari, and Opera.\n# Note: For IE 9+ you need to set HTML_FILE_EXTENSION to xhtml in order to make\n# the SVG files visible. Older versions of IE do not have SVG support.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nINTERACTIVE_SVG        = NO\n\n# The DOT_PATH tag can be used to specify the path where the dot tool can be\n# found. If left blank, it is assumed the dot tool can be found in the path.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_PATH               =\n\n# The DOTFILE_DIRS tag can be used to specify one or more directories that\n# contain dot files that are included in the documentation (see the \\dotfile\n# command).\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOTFILE_DIRS           =\n\n# The MSCFILE_DIRS tag can be used to specify one or more directories that\n# contain msc files that are included in the documentation (see the \\mscfile\n# command).\n\nMSCFILE_DIRS           =\n\n# The DIAFILE_DIRS tag can be used to specify one or more directories that\n# contain dia files that are included in the documentation (see the \\diafile\n# command).\n\nDIAFILE_DIRS           =\n\n# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of nodes\n# that will be shown in the graph. If the number of nodes in a graph becomes\n# larger than this value, doxygen will truncate the graph, which is visualized\n# by representing a node as a red box. Note that doxygen if the number of direct\n# children of the root node in a graph is already larger than\n# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note that\n# the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.\n# Minimum value: 0, maximum value: 10000, default value: 50.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_GRAPH_MAX_NODES    = 50\n\n# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the graphs\n# generated by dot. A depth value of 3 means that only nodes reachable from the\n# root by following a path via at most 3 edges will be shown. Nodes that lay\n# further from the root node will be omitted. Note that setting this option to 1\n# or 2 may greatly reduce the computation time needed for large code bases. Also\n# note that the size of a graph can be further restricted by\n# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.\n# Minimum value: 0, maximum value: 1000, default value: 0.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nMAX_DOT_GRAPH_DEPTH    = 0\n\n# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent\n# background. This is disabled by default, because dot on Windows does not seem\n# to support this out of the box.\n#\n# Warning: Depending on the platform used, enabling this option may lead to\n# badly anti-aliased labels on the edges of a graph (i.e. they become hard to\n# read).\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_TRANSPARENT        = NO\n\n# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output\n# files in one run (i.e. multiple -o and -T options on the command line). This\n# makes dot run faster, but since only newer versions of dot (>1.8.10) support\n# this, this feature is disabled by default.\n# The default value is: NO.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_MULTI_TARGETS      = YES\n\n# If the GENERATE_LEGEND tag is set to YES doxygen will generate a legend page\n# explaining the meaning of the various boxes and arrows in the dot generated\n# graphs.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nGENERATE_LEGEND        = YES\n\n# If the DOT_CLEANUP tag is set to YES doxygen will remove the intermediate dot\n# files that are used to generate the various graphs.\n# The default value is: YES.\n# This tag requires that the tag HAVE_DOT is set to YES.\n\nDOT_CLEANUP            = YES\n"
  },
  {
    "path": "src/harness/README.txt",
    "content": "MySQL Harness\n=============\n\nMySQL Harness is an extensible framework that handles loading and\nunloading of *plugins*. The built-in features are dependency tracking\nbetween plugins, configuration file handling, and support for plugin\nlife-cycles.\n\nFor the avoidance of doubt, this particular copy of the software is\nreleased under the version 2 of the GNU General Public License.\n\nCopyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\nBuilding\n--------\n\nTo build the MySQL Harness you use the standard steps to build from\nCMake:\n\n    cmake .\n    make\n\nIf you want to do an out-of-source build, the procedure is:\n\n    mkdir build\n    cd build\n    cmake <path-to-source>\n    make\n\n\nBuilding and running the unit tests\n-----------------------------------\n\nTo build the unit tests:\n\n    cmake <path-to-source> -DENABLE_TESTS=1\n\nTo run the tests\n\n    make test\n\n\nCoverage information\n--------------------\n\nTo build so that coverage information is generated:\n\n    cmake <path-to-source> -DENABLE_COVERAGE=1\n\nTo get coverage information, just run the program or the unit tests\n(do not forget to enable the unit tests if you want to run them). Once\nyou have collected coverage information, you can generate an HTML\nreport in `<build-dir>/coverage/html` using:\n\n    make coverage-html\n\nThere are three variables to control where the information is\ncollected and where the reports are written:\n\n- `GCOV_BASE_DIR` is a cache variable with the full path to a base\n  directory for the coverage information.\n\n  It defaults to `${CMAKE_BUILD_DIR}/coverage`.\n  \n- `GCOV_INFO_FILE` is a cache varible with the full path to the info\n  file for the collected coverage information.\n\n  It defaults to `${GCOV_BASE_DIR}/coverage.info`.\n  \n- `GCOV_HTML_DIR` is a cache variable with the full path to the\n  directory where the HTML coverage report will be generated.\n\n  It defaults to `${GCOV_BASE_DIR}/html`.\n\n\nDocumentation\n-------------\n\nDocumentation can be built as follows:\n\n    make docs\n\nThe documentation is using Doxygen to extract documentation comments\nfrom the source code.\n\nThe documentation will be placed in the `doc/` directory under the\nbuild directory. For more detailed information about the code, please\nread the documentation rather than rely on this `README`.\n\n\nInstalling\n----------\n\nTo install the files, use `make install`. This will install the\nharness, the harness library, the header files for writing plugins,\nand the available plugins that were not marked with `NO_INSTALL` (see\nbelow).\n\nIf you want to provide a different install prefix, you can do that by\nsetting the `CMAKE_INSTALL_PREFIX`:\n\n    cmake . -DCMAKE_INSTALL_PREFIX=~/tmp\n\n\nRunning\n-------\n\nTo start the harness, you need a configuration file. You can find an\nexample in `data/main.conf`:\n\n    # Example configuration file\n\n    [DEFAULT]\n    logging_folder = /var/log/router\n    config_folder = /etc/mysql/router\n    plugin_folder = /var/lib/router\n    runtime_folder = /var/run/router\n    data_folder = /var/lib/router\n\n    [example]\n    library = example\n\nThe configuration file contain information about all the plugins that\nshould be loaded when starting and configuration options for each\nplugin.  The default section contains configuration options available\nin to all plugins.\n\nTo run the harness, just provide the configuration file as the only\nargument:\n\n    harness /etc/mysql/harness/main.conf\n\nNote that the harness read directories for logging, configuration,\netc. from the configuration file so you have to make sure these are\npresent and that the section name is used to find the plugin structure\nin the shared library (see below).\n\nTypically, the harness will then load plugins from the directory\n`/var/lib/harness` and write log files to `/var/log/harness`.\n\n\nWriting Plugins\n---------------\n\nNOTE: This chapter quickly outlines the basic concepts, there is also\n      more in-depth information available at the beginning of loader.h,\n      which you will probably want to read to gain further insight.\n\nAll available plugins are in the `plugins/` directory. There is one\ndirectory for each plugin and it is assumed that it contain a\n`CMakeLists.txt` file.\n\nThe main `CMakeLists.txt` file provide an `add_harness_plugin`\nfunction that can be used add new plugins.\n\n    add_harness_plugin(<name> [ NO_INSTALL ]\n                       INTERFACE <directory>\n                       SOURCES <source> ...\n                       REQUIRES <plugin> ...)\n\nThis function adds a plugin named `<name>` built from the given\nsources. If `NO_INSTALL` is provided, it will not be installed with\nthe harness (useful if you have plugins used for testing, see the\n`tests/` directory). Otherwise, the plugin will be installed in the\n*root*`/var/lib/harness` directory.\n\nThe header files in the directory given by `INTERFACE` are the\ninterface files to the plugin and shall be used by other plugins\nrequiring features from this plugin. These header files will be\ninstalled alongside the harness include files and will also be made\navailable to other plugins while building from source.\n\n### Plugin Directory Structure ###\n\nSimilar to the harness, each plugin have two types of files:\n\n* Plugin-internal files used to build the plugin. These include the\n  source files and but also header files associated with each source\n  file and are stored in the `src` directory of the plugin directory.\n* Interface files used by other plugins. These are header files that\n  are made available to other plugins and are installed alongside the\n  harness installed files, usually under the directory\n  `/usr/include/mysql/harness`.\n\n### Application Information Structure ###\n\nThe application information structure contains some basic fields\nproviding information to the plugin. Currently these fields are\nprovided:\n\n    struct AppInfo {\n      const char *program;                 /* Name of the application */\n      const char *plugin_folder;           /* Location of plugins */\n      const char *logging_folder;          /* Log file directory */\n      const char *config_folder;           /* Config file directory */\n      const char *runtime_folder;          /* Run file directory */\n      const Config* config;                /* Configuration information */\n    };\n\n\n### Configuration Section Information Structure ###\n\nConfiguration section object (class `ConfigSection`) carries configuration\ninformation specific to a particular plugin instance. It reflects\ninformation provided in router configuration file for one specific\nconfiguration section. Only parts relevant to configuration retrieval are\nlisted below, the actual class carries additional methods and fields:\n\n    class ConfigSection {\n     public:\n      ConfigSection& operator=(const ConfigSection&) = delete;\n      std::string    get(const std::string& option) const;\n\n     public:\n      const std::string name;\n      const std::string key;\n    };\n\n\n### Plugin Structure ###\n\nTo define a new plugin, you have to create an instance of the\n`Plugin` structure in your plugin similar to this:\n\n    #include <mysql/harness/plugin.h>\n\n    static const char* requires[] = {\n      \"magic (>>1.0)\",\n    };\n\n    Plugin example = {\n      PLUGIN_ABI_VERSION,\n      ARCHITECTURE_DESCRIPTOR,\n      \"An example plugin\",       // Brief description of plugin\n      VERSION_NUMBER(1,0,0),     // Version number of the plugin\n\n      // Array of required plugins\n      sizeof(requires)/sizeof(*requires),\n      requires,\n\n      // Array of plugins that conflict with this one\n      0,\n      NULL,\n\n      // pointers to API functions, can be NULL if not implemented\n      init,\n      deinit,\n      start,\n      stop,\n    };\n\n\n### Initialization and Cleanup ###\n\nAfter the plugin is loaded, the `init()` function is called for all\nplugins with a pointer to the function call environment object (not to be\nconfused with application environment passed from the shell) as the only argument.\n\nThe `init()` functions are called in dependency order so that all\n`init()` functions in required plugins are called before the `init()`\nfunction in the plugin itself.\n\nBefore the harness exits, it will call the `deinit()` function with a\npointer to environment object as the only argument.\n\n\n### Starting and Stopping the Plugin ###\n\nAfter all the plugins have been successfully initialized, a thread\nwill be created for each plugin that has a `start()` function\ndefined.\n\n#### Overview ####\n\nThe `start()` function will be called with a pointer to environment object\nas the only parameter. When all the plugins return from their `start()`\nfunctions, the harness will perform cleanup and exit. If plugin\nprovides a `stop()` function, it will also be called at that time.\n\nIMPORTANT: `start()` function runs in a different thread than `stop()`\nfunction. By the time `stop()` runs, depending on the circumstances,\n`start()` thread may or may not exist.\n\n#### Shutdown Provision ####\nIt is typical to implement start function in such a way that it will\n\"persist\" (i.e. it will run some forever-loop processing requests\nrather than exit briefly after being called). In such case, Harness\nmust have a way to terminate it during shutdown operation. This is\naccomplished by providing a `is_running()` function, that polls harness\nstate. This function should be routinely called from plugin's `start()`\nfunction to determine if it should shut down. Typically, `start()`\nwould be implemented more-or-less like so:\n\n    void start()\n    {\n      // run-once code\n\n      while (is_running())\n      {\n        // forever-loop code\n      }\n\n      // clean-up code\n    }\n\nThere is also an alternative blocking function available, `wait_for_stop()`,\nshould that be better suited for your plugin. Instead of quickly returning\na boolean flag, it will block until Harness initiates shut down. It is\nfunctionally equivalent to:\n\n    while (is_running())\n    {\n      // sleep a little or break on timeout\n    }\n\nWhen entering shutdown mode, Harness will notify all plugins to shut down\nvia mechanism described above. It is also possible for plugins to exit on\ntheir own, whether due to error or intended behavior. In some designs,\n`start()` function might need to be able to set the flag returned by\n`is_running()` to false. For such cases, `clear_running()` flag is provided,\nwhich will do exactly that.\n\nIMPORTANT! Please note that all 3 functions described above (`is_running()`,\n`wait_for_stop()` and `clear_running()`) can only be called from a thread\nrunning `start()` function. If your plugins spawns more threads, these\nfunctions CANNOT be called from them.\n\n### Returning Success/Failure from Plugin Function ###\n\nHarness expects all four plugin functions (`init(), `start()`, `stop()` and\n`deinit()`) to notify it in case of an error. This is done via function:\n\n    set_error(PluginFuncEnv* env, ErrorType error, const char* format, ...);\n\nCalling this function flags that the function has failed, and passes the\nerror type and string back to Harness. The converse is also true: not\ncalling this function prior to exiting the function implies success.\nThis distinction is important, because Harness may take certain actions\nbased on the status returned by each function.\n\nIMPORTANT! Throwing exceptions from these functions is not supported.\nIf your plugin uses exceptions internally, that is fine, but please\nensure they are handled before reaching the Harness-Plugin boundary.\n\n\n### Threading Concerns ###\n\nFor each plugin (independent of other plugins):\nOf the 4 plugin functions, `init()` runs first. It is guaranteed that\nit will exit before `start()` and `stop()` are called. `start()` and\n`stop()` can be called in parallel to each other, in any order, with\ntheir lifetimes possibly overlapping. They are guaranteed to both have\nexited before `deinit()` is called.\n\nIf any of the 4 plugin functions spawn any additional threads, Harness\nmakes no provisions for interacting with them in any way: calling\nHarness functions from them is not supported in particular; also such\nthreads should exit before their parent function finishes running.\n\n\nLicense\n-------\n\nLicense information can be found in the License.txt file.\n\nThis distribution may include materials developed by third\nparties. For license and attribution notices for these\nmaterials, please refer to the documentation that accompanies\nthis distribution (see the \"Licenses for Third-Party Components\"\nappendix) or view the online documentation at\n<http://dev.mysql.com/doc/>.\n\nGPLv2 Disclaimer\nFor the avoidance of doubt, except that if any license choice\nother than GPL or LGPL is available it will apply instead,\nOracle elects to use only the General Public License version 2\n(GPLv2) at this time for any software where a choice of GPL\nlicense versions is made available with the language indicating\nthat GPLv2 or any later version may be used, or where a choice\nof which version of the GPL is applied is otherwise unspecified.\n"
  },
  {
    "path": "src/harness/data/main.conf",
    "content": "# Standard configuration file\n\n[DEFAULT]\nlogging_folder = /var/log/{program}\nconfig_folder = /etc/mysql/{program}\nplugin_folder = /usr/lib/{program}\nruntime_folder = /var/run/{program}\n"
  },
  {
    "path": "src/harness/include/common.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_COMMON_INCLUDED\n#define MYSQL_HARNESS_COMMON_INCLUDED\n\n#include <string>\n#include <sstream>\n#include <cstdlib>\n#include \"harness_export.h\"\n\n/**\n * @defgroup Various operations\n *\n * This module contain various utility operations.\n */\n\nnamespace mysql_harness {\n\n/**\n * Deleter for smart pointers pointing to objects allocated with `std::malloc`.\n */\ntemplate<typename T>\nclass StdFreeDeleter {\n public:\n  void operator()(T* ptr) {\n    std::free(ptr);\n  }\n};\n\n/**\n * Changes file access permissions to be fully accessible by all users.\n *\n * On Unix, the function sets file permission mask to 777.\n * On Windows, Everyone group is granted full access to the file.\n *\n * @param[in] file_name File name.\n *\n * @except std::exception Failed to change file permissions.\n */\nvoid HARNESS_EXPORT make_file_public(const std::string& file_name);\n\n/**\n * Changes file access permissions to be accessible only by a limited set of\n * users.\n *\n * On Unix, the function sets file permission mask to 600.\n * On Windows, all permissions to this file are removed for Everyone group.\n *\n * @param[in] file_name File name.\n *\n * @except std::exception Failed to change file permissions.\n */\nvoid HARNESS_EXPORT make_file_private(const std::string& file_name);\n\n/** @brief Wrapper for thread safe function returning error string.\n *\n * @param err error number\n * @return string describing the error\n */\nstd::string HARNESS_EXPORT get_strerror(int err);\n\n/** @brief Rename a thread (useful for debugging purposes).\n *\n * @param thread_name thread name, 15 chars max\n */\nvoid HARNESS_EXPORT rename_thread(const char thread_name[16]);\n\n/** @brief Return a truncated version of input string (fast version)\n *\n * WARNING!\n * This function is optimised for speed, but see note below for use restrictions.\n * If these are a problem, use truncate_string_r() instead.\n *\n * This function returns a refernce to the input string if input.size() <= max_len,\n * otherwise it returns a reference to a truncated copy of input string.\n *\n * @param input input text\n * @param max_len maximum length after truncation\n * @return const reference to truncated string\n *\n * @note This function may return a reference to a string allocated on thread-local\n *       storage. Therefore, the resulting string reference is only valid until\n *       another call to this function is made from caller's thread (other threads\n *       calling this function have no impact), and by the same token, dereferencing\n *       it outside of the caller's thread may lead to a race. If your use case\n *       violates these limitations, you should use truncate_string_r() instead\n *       to ensure safety.\n */\nHARNESS_EXPORT\nconst std::string& truncate_string(const std::string& input, size_t max_len = 80);\n\n/** @brief Return a truncated version of input string (reentrant version)\n *\n * This is a safe version of truncate_string(), which lifts its use restrictions\n * by always returning a copy of result string. Please see documentation of\n * truncate_string() for more information.\n */\nHARNESS_EXPORT\nstd::string truncate_string_r(const std::string& input, size_t max_len = 80);\n\n\n/**\n * Emit a range of elements using the serial comma.\n *\n * This function can be used to output a range of elements using a\n * serial comma (also known as the Oxford comma). To emit a list of\n * the first five prime numbers as \"The first five prime numbers are\n * 2, 3, 5, 7, and 11\":\n *\n * @code\n * std::vector<int> primes{2, 3, 5, 7, 11};\n * std::cout << \"The first five prime numbers are \";\n * serial_comma(std::cout, primes.begin(), primes.end());\n * std::cout << std::endl;\n * @endcode\n *\n * @param out Output stream\n * @param start Input iterator to start of range.\n * @param finish Input iterator to one-after-end of range.\n * @param delim Delimiter to use. Defaults to \"and\".\n */\ntemplate <class InputIt>\nvoid serial_comma(std::ostream& out, InputIt start, InputIt finish,\n                  const std::string& delim = \"and\") {\n  auto elements = std::distance(start, finish);\n  if (elements == 1) {\n    out << *start;\n  } else if (elements == 2) {\n    out << *start++;\n    out << \" \" << delim << \" \" << *start;\n  } else {\n    while (elements-- > 0) {\n      out << *start++;\n      if (elements > 0)\n        out << \", \";\n      if (elements == 1)\n        out << delim << \" \";\n    }\n  }\n}\n\n/**\n * Returns string containing list of the elements using the serial comma.\n *\n * This function can be used to output a range of elements using a\n * serial comma (also known as the Oxford comma). To return a list of\n * the first five prime numbers as \"The first five prime numbers are\n * 2, 3, 5, 7, and 11\":\n *\n * @code\n * std::vector<int> primes{2, 3, 5, 7, 11};\n * std::cout << \"The first five prime numbers are \"\n *           << serial_comma(primes.begin(), primes.end()) << std::endl;\n * @endcode\n *\n * @param start Input iterator to start of range.\n * @param finish Input iterator to one-after-end of range.\n * @param delim Delimiter to use. Defaults to \"and\".\n *\n * @return string containing list of the elements\n */\ntemplate <class InputIt>\nstd::string serial_comma(InputIt start, InputIt finish,\n                         const std::string& delim = \"and\") {\n\n  std::stringstream out;\n  serial_comma(out, start, finish, delim);\n\n  return out.str();\n}\n\n} // namespace mysql_harness\n\n/**\n * Macros for disabling and enabling compiler warnings.\n *\n * The primary use case for these macros is suppressing warnings coming from\n * system and 3rd-party libraries' headers included in our code. It should\n * not be used to hide warnings in our code.\n */\n\n#if defined(_MSC_VER)\n\n  #define MYSQL_HARNESS_DISABLE_WARNINGS() \\\n    __pragma(warning(push)) \\\n    __pragma(warning(disable:))\n\n  #define MYSQL_HARNESS_ENABLE_WARNINGS() __pragma(warning(pop))\n\n#elif defined(__clang__) || \\\n      __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)\n\n  #define MYSQL_HARNESS_PRAGMA_COMMON(cmd) _Pragma(#cmd)\n\n  #ifdef __clang__\n    #define MYSQL_HARNESS_PRAGMA(cmd) MYSQL_HARNESS_PRAGMA_COMMON(clang cmd)\n  #elif __GNUC__\n    #define MYSQL_HARNESS_PRAGMA(cmd) MYSQL_HARNESS_PRAGMA_COMMON(GCC cmd)\n  #endif\n\n  #define MYSQL_HARNESS_DISABLE_WARNINGS() \\\n    MYSQL_HARNESS_PRAGMA(diagnostic push) \\\n    MYSQL_HARNESS_PRAGMA(diagnostic ignored \"-Wsign-conversion\") \\\n    MYSQL_HARNESS_PRAGMA(diagnostic ignored \"-Wpedantic\") \\\n    MYSQL_HARNESS_PRAGMA(diagnostic ignored \"-Wshadow\") \\\n    MYSQL_HARNESS_PRAGMA(diagnostic ignored \"-Wconversion\") \\\n    MYSQL_HARNESS_PRAGMA(diagnostic ignored \"-Wsign-compare\") \\\n    MYSQL_HARNESS_PRAGMA(diagnostic ignored \"-Wunused-parameter\") \\\n    MYSQL_HARNESS_PRAGMA(diagnostic ignored \"-Wdeprecated-declarations\")\n\n  #define MYSQL_HARNESS_ENABLE_WARNINGS() MYSQL_HARNESS_PRAGMA(diagnostic pop)\n\n#else\n\n  // Unsupported compiler, leaving warnings as they were.\n  #define MYSQL_HARNESS_DISABLE_WARNINGS()\n  #define MYSQL_HARNESS_ENABLE_WARNINGS()\n\n#endif\n\n#endif /* MYSQL_HARNESS_COMMON_INCLUDED */\n"
  },
  {
    "path": "src/harness/include/dim.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_DIMANAGER_INCLUDED\n#define MYSQL_HARNESS_DIMANAGER_INCLUDED\n\n#include \"harness_export.h\"\n#include \"unique_ptr.h\"\n\n#include <functional>\n#include <string>   // unfortunately, std::string is a typedef and therefore not easy to forward-declare\n#include <mutex>    // using fwd declaration + ptr-to-implementation gives build errors on BSD-based systems\n\n\n\n/** @file\n *  @brief Provides simple, yet useful dependency injection mechanism\n *\n * # Introduction\n *\n * Let's start with showing usage, for example class Foo:\n *\n * @code\n *     class Foo {\n *      public:\n *       Foo();\n *       void do_something();\n *     };\n * @endcode\n *\n * We want DIM to make instance(s) of this class available throughout our\n * application.\n *\n * ## Scenario 1: when Foo is a singleton\n *\n * @code\n *     void init_code() {\n *       DIM::instance().set_Foo([](){ return new Foo; });\n *     }\n *\n *     void use_code() {\n *       Foo& foo = DIM::instance().get_Foo();\n *\n *       // each call works on the same object\n *       foo.do_something();\n *       foo.do_something();\n *       foo.do_something();\n *     }\n * @endcode\n *\n * ## Scenario 2: when Foo is not a singleton\n *\n * @code\n *     void init_code() {\n *       DIM::instance().set_Foo([](){ return new Foo; });\n *     }\n *\n *     void use_code() {\n *       // each call generates a new object\n *       UniquePtr<Foo> foo1 = DIM::instance().new_Foo();\n *       foo1->do_something();\n *\n *       UniquePtr<Foo> foo2 = DIM::instance().new_Foo();\n *       foo2->do_something();\n *\n *       UniquePtr<Foo> foo3 = DIM::instance().new_Foo();\n *       foo3->do_something();\n *     }\n * @endcode\n *\n * ## Scenario 3: when Foo already exists (typically used in unit tests)\n *\n * @code\n *     Foo foo_that_lives_forever;\n *\n *     void init_code() {\n *       DIM::instance().set_Foo(\n *         [](){\n *           return &foo_that_lives_forever;\n *         },\n *         [](Foo*) {}); // so that DIM does not try to delete it\n *     }\n *\n *     void use_code() {\n *       Foo& foo = DIM::instance().get_Foo();\n *       foo.do_something();\n *     }\n * @endcode\n *\n * Convenient, isn't it?  But to make all this happen, class Foo (boilerplate code) has\n * to be added to DIM class.\n *\n * # Usage\n *\n * Adding a new managed object is done in 4 steps:\n *\n * 1. add class forward declaration\n * 2. add object factory + deleter setter\n * 3. add singleton object getter or object creator. Adding both usually makes no sense\n * 4. add factory and deleter function objects\n *\n * Here is the (relevant part of) class DIM for class Foo:\n *\n *\n * @code\n *     // [step 1]\n *     // forward declarations\n *     class Foo;\n *\n *     class DIM {\n *       // ... constructors, instance(), other support methods ...\n *\n *      public:\n *       // [step 2]\n *       // factory + deleter setter\n *       void set_Foo(const std::function<Foo*(void)>& factory,\n *         const std::function<void(Foo*)>& deleter =\n *             std::default_delete<Foo>()) {\n *           factory_Foo_ = factory; deleter_Foo_ = deleter;\n *       }\n *\n *       // [step 3]\n *       // singleton object getter\n *       // (shown here, but normally mutually-exclusive with next method)\n *       Foo& get_Foo() const {\n *         return get_generic<Foo>(factory_Foo_, deleter_Foo_);\n *       }\n *\n *       // object creator\n *       // (shown here, but normally mutually-exclusive with previous method)\n *       UniquePtr<Foo> new_Foo() const {\n *         return new_generic(factory_Foo_, deleter_Foo_);\n *       }\n *\n *      private:\n *       // factory and deleter function objects [step 4]\n *       std::function<Foo*(void)> factory_Foo_;\n *       std::function<void(Foo*)> deleter_Foo_;\n *     };\n * @endcode\n *\n *\n * ## Example\n *\n * @code\n *     // forward declarations [step 1]\n *     class Foo;\n *     class Bar;\n *     class Baz;\n *\n *     class DIM {\n *       // ... constructors, instance(), other support methods ...\n *\n *       // Example: Foo depends on Bar and Baz,\n *       //          Bar depends on Baz and some int,\n *       //          Baz depends on nothing\n *\n *      public:\n *       // factory + deleter setters [step 2]\n *       void set_Foo(const std::function<Foo*(void)>& factory,\n *         const std::function<void(Foo*)>& deleter =\n *             std::default_delete<Foo>()) {\n *           factory_Foo_ = factory; deleter_Foo_ = deleter;\n *       }\n *\n *       void set_Bar(const std::function<Bar*(void)>& factory,\n *         const std::function<void(Bar*)>& deleter =\n *             std::default_delete<Bar>()) {\n *           factory_Bar_ = factory; deleter_Bar_ = deleter;\n *       }\n *\n *       void set_Baz(const std::function<Baz*(void)>& factory,\n *         const std::function<void(Baz*)>& deleter =\n *             std::default_delete<Baz>()) {\n *           factory_Baz_ = factory; deleter_Baz_ = deleter;\n *       }\n *\n *       // singleton object getters\n *       // (all are shown, but normally mutually-exclusive\n *       // with next group) [step 3]\n *       Foo& get_Foo() const {\n *         return get_generic<Foo>(factory_Foo_, deleter_Foo_);\n *       }\n *       Bar& get_Bar() const {\n *         return get_generic<Bar>(factory_Bar_, deleter_Bar_);\n *       }\n *       Baz& get_Baz() const {\n *         return get_generic<Baz>(factory_Baz_, deleter_Baz_);\n *       }\n *\n *       // object creators\n *       // (all are shown, but normally mutually-exclusive\n *       // with previous group) [step 3]\n *       UniquePtr<Foo> new_Foo() const {\n *         return new_generic(factory_Foo_, deleter_Foo_);\n *       }\n *       UniquePtr<Bar> new_Bar() const {\n *         return new_generic(factory_Bar_, deleter_Bar_);\n *       }\n *       UniquePtr<Baz> new_Baz() const {\n *         return new_generic(factory_Baz_, deleter_Baz_);\n *       }\n *\n *      private:\n *       // factory and deleter function objects [step 4]\n *       std::function<Foo*(void)> factory_Foo_;\n *       std::function<void(Foo*)> deleter_Foo_;\n *       std::function<Bar*(void)> factory_Bar_;\n *       std::function<void(Bar*)> deleter_Bar_;\n *       std::function<Baz*(void)> factory_Baz_;\n *       std::function<void(Baz*)> deleter_Baz_;\n *     };\n *\n *\n *\n *     // actual classes\n *     struct Baz {\n *       Baz() {}\n *     };\n *     struct Bar {\n *       Bar(Baz, int) {}\n *     };\n *     struct Foo {\n *       Foo(Bar, Baz) {}\n *       void do_something() {}\n *     };\n *\n *\n *\n *     // usage\n *     int main() {\n *       int n = 3306;\n *\n *       // init code\n *       DIM& dim = DIM::instance();\n *       dim.set_Foo([&dim]()    {\n *           return new Foo(dim.get_Bar(), dim.get_Baz()); });\n *       dim.set_Bar([&dim, n]() {\n *           return new Bar(dim.get_Baz(), n);             });\n *       dim.set_Baz([]()        {\n *           return new Baz;                               });\n *\n *       // use code (as singleton)\n *       //\n *       // will automatically instantiate Bar and Baz as well\n *       dim.get_Foo().do_something();\n *\n *       // use code (as new object)\n *       UniquePtr<Foo> foo = dim.new_Foo();\n *       foo->do_something();\n *     }\n * @endcode\n *\n * # Object Reset\n *\n * There's also an option to reset an object managed by DIM, should you need it. Normally,\n * on the first call to get_Foo(), it will call the factory_Foo_() to create the object\n * before returning it. On subsequent calls, it will just return that Foo object previously\n * created. But what if you needed to reset that object? And perhaps to create it via another\n * Foo factory method, or with different parameters?\n *\n * For such case, we can define reset_Foo() method, which will reset the Foo object back to\n * nullptr. The Foo object can no longer be kept inside of get_Foo(), because it has to be\n * modifiable via reset_Foo(). Here's the code:\n *\n *\n * @code\n *     // Foo-related members.\n *     //\n *     // instance_Foo_ is new here, it now stores the Foo object\n *     //\n *     // (previously, this object was stored as a static variable\n *     // inside of get_Foo()\n *     std::function<Foo*(void)> factory_Foo_;\n *     std::function<void(Foo*)> deleter_Foo_;\n *     UniquePtr<Foo>            instance_Foo_; // <---- new member\n *\n *     // getter now relies on get_external_generic() to manage the Foo object\n *     Foo& get_Foo() {\n *       return get_external_generic(instance_Foo_,\n *                                   factory_Foo_,\n *                                   deleter_Foo_);\n *     }\n *\n *     // this is our new function.\n *     //\n *     // After calling it, set_Foo() can be used again\n *     // to set the factory method, which will be\n *     // triggered on subsequent call to get_Foo() to\n *     // create the new Foo object\n *     void reset_Foo() { reset_generic(instance_Foo_); }\n *\n *     // set_Foo remains unaltered\n *     void set_Foo(const std::function<Foo*(void)>& factory,\n *         const std::function<void(Foo*)>& deleter =\n *           std::default_delete<Foo>()) {\n *       factory_Foo_ = factory;\n *       deleter_Foo_ = deleter;\n *     }\n * @endcode\n *\n * ## Example\n *\n * @code\n *     // init code\n *     DIM& dim = DIM::instance();\n *     dim.set_Foo([]() { return new Foo(42); });\n *\n *     // use code\n *\n *     // automatically calls set_Foo() which returns new Foo(42)\n *     dim.get_Foo().do_something();\n *\n *     // does not call set_Foo() anymore\n *     dim.get_Foo().do_something();\n *\n *     // does not call set_Foo() anymore\n *     dim.get_Foo().do_something();\n *\n *     // sets new creating function\n *     dim.set_Foo([]() {\n *         return new Foo(555);\n *     });\n *     // but the new set_Foo() is still not called\n *     dim.get_Foo().do_something();\n *\n *     dim.reset_Foo();\n *\n *     // automatically calls (new) set_Foo(), which returns new Foo(555)\n *     dim.get_Foo().do_something();\n * @endcode\n *\n */\n\n// forward declarations [step 1]\nnamespace mysqlrouter { class MySQLSession; }\nnamespace mysqlrouter { class Ofstream; }\nnamespace mysql_harness { class RandomGeneratorInterface; }\nnamespace mysql_harness { namespace logging { class Registry; } }\nnamespace mysql_harness { class LoaderConfig; }\n\nnamespace mysql_harness {\n\nclass HARNESS_EXPORT DIM { // DIM = Dependency Injection Manager\n\n  // this class is a singleton\n  protected:\n  DIM();\n  ~DIM();\n  public:\n  DIM(const DIM&) = delete;\n  DIM& operator=(const DIM&) = delete;\n  static DIM& instance();\n\n  // NOTE: once we gain confidence in this DIM and we can treat it as black box,\n  //       all the boilerplate stuff (steps 2-4) for each class can be generated by a macro)\n\n public:\n  ////////////////////////////////////////////////////////////////////////////////\n  // factory and deleter setters [step 2]\n  ////////////////////////////////////////////////////////////////////////////////\n\n  // Logging Registry\n  void reset_LoggingRegistry() { reset_generic(instance_LoggingRegistry_); }\n  void set_LoggingRegistry(const std::function<mysql_harness::logging::Registry*(void)>& factory,\n                           const std::function<void(mysql_harness::logging::Registry*)>& deleter) {\n    factory_LoggingRegistry_ = factory;\n    deleter_LoggingRegistry_ = deleter;\n  }\n\n  // MySQLSession\n  void set_MySQLSession(const std::function<mysqlrouter::MySQLSession*(void)>& factory,\n                        const std::function<void(mysqlrouter::MySQLSession*)>& deleter) {\n    factory_MySQLSession_ = factory;\n    deleter_MySQLSession_ = deleter;\n  }\n\n  // Ofstream\n  void set_Ofstream(const std::function<mysqlrouter::Ofstream*(void)>& factory,\n                    const std::function<void(mysqlrouter::Ofstream*)>& deleter) {\n    factory_Ofstream_ = factory;\n    deleter_Ofstream_ = deleter;\n  }\n\n  // RandomGenerator\n  void set_RandomGenerator(const std::function<mysql_harness::RandomGeneratorInterface*(void)>& factory,\n                           const std::function<void(mysql_harness::RandomGeneratorInterface*)>& deleter) {\n    factory_RandomGenerator_ = factory;\n    deleter_RandomGenerator_ = deleter;\n  }\n\n  // LoaderConfig\n  void reset_Config() { reset_generic(instance_Config_); }\n  void set_Config(const std::function<mysql_harness::LoaderConfig*(void)>& factory,\n                  const std::function<void(mysql_harness::LoaderConfig*)>& deleter) {\n    factory_Config_ = factory;\n    deleter_Config_ = deleter;\n  }\n\n  ////////////////////////////////////////////////////////////////////////////////\n  // object getters [step 3] (used for singleton objects)\n  ////////////////////////////////////////////////////////////////////////////////\n\n  // Logging Registry\n  mysql_harness::logging::Registry& get_LoggingRegistry() { return get_external_generic(instance_LoggingRegistry_, factory_LoggingRegistry_, deleter_LoggingRegistry_); }\n\n  // RandomGenerator\n  mysql_harness::RandomGeneratorInterface& get_RandomGenerator() const { return get_generic(factory_RandomGenerator_, deleter_RandomGenerator_); }\n\n  // LoaderConfig\n  mysql_harness::LoaderConfig& get_Config() { return get_external_generic(instance_Config_, factory_Config_, deleter_Config_); }\n\n  ////////////////////////////////////////////////////////////////////////////////\n  // object creators [step 3] (used for non-singleton objects)\n  ////////////////////////////////////////////////////////////////////////////////\n\n  // MySQLSession\n  UniquePtr<mysqlrouter::MySQLSession> new_MySQLSession() const { return new_generic(factory_MySQLSession_, deleter_MySQLSession_); }\n\n  // Ofstream\n  UniquePtr<mysqlrouter::Ofstream> new_Ofstream() const { return new_generic(factory_Ofstream_, deleter_Ofstream_); }\n\n private:\n  ////////////////////////////////////////////////////////////////////////////////\n  // factory and deleter functions [step 4]\n  ////////////////////////////////////////////////////////////////////////////////\n\n  // Logging Registry\n  std::function<mysql_harness::logging::Registry*(void)> factory_LoggingRegistry_;\n  std::function<void(mysql_harness::logging::Registry*)> deleter_LoggingRegistry_;\n  UniquePtr<mysql_harness::logging::Registry> instance_LoggingRegistry_;\n\n  // MySQLSession\n  std::function<mysqlrouter::MySQLSession*(void)> factory_MySQLSession_;\n  std::function<void(mysqlrouter::MySQLSession*)> deleter_MySQLSession_;\n\n  // Ofstream\n  std::function<mysqlrouter::Ofstream*(void)> factory_Ofstream_;\n  std::function<void(mysqlrouter::Ofstream*)> deleter_Ofstream_;\n\n  // RandomGenerator\n  std::function<mysql_harness::RandomGeneratorInterface*(void)> factory_RandomGenerator_;\n  std::function<void(mysql_harness::RandomGeneratorInterface*)> deleter_RandomGenerator_;\n\n  // LoaderConfig\n  std::function<mysql_harness::LoaderConfig*(void)> factory_Config_;\n  std::function<void(mysql_harness::LoaderConfig*)> deleter_Config_;\n  UniquePtr<mysql_harness::LoaderConfig> instance_Config_;\n\n\n\n  ////////////////////////////////////////////////////////////////////////////////\n  // utility functions\n  ////////////////////////////////////////////////////////////////////////////////\n\n protected:\n  template <typename T>\n  static T& get_generic(const std::function<T*(void)>& factory, const std::function<void(T*)>& deleter) {\n    static UniquePtr<T> obj = new_generic(factory, deleter);\n    return *obj;\n  }\n\n  // new_generic*() (add more variants if needed, or convert into varargs template)\n  template <typename T>\n  static UniquePtr<T> new_generic(const std::function<T*(void)>& factory, const std::function<void(T*)>& deleter) {\n    return UniquePtr<T>(\n      factory(),\n      [deleter](T* p){ deleter(p); }  // [&deleter] would be unsafe if set_T() was called before this object got erased\n    );\n  }\n  template <typename T, typename A1>\n  static UniquePtr<T> new_generic1(const std::function<T*(A1)>& factory, const std::function<void(T*)>& deleter, const A1& a1) {\n    return UniquePtr<T>(\n      factory(a1),\n      [deleter](T* p){ deleter(p); }  // [&deleter] would be unsafe if set_T() was called before this object got erased\n    );\n  }\n  template <typename T, typename A1, typename A2>\n  static UniquePtr<T> new_generic2(const std::function<T*(A1,A2)>& factory, const std::function<void(T*)>& deleter, const A1& a1, const A2& a2) {\n    return UniquePtr<T>(\n      factory(a1, a2),\n      [deleter](T* p){ deleter(p); }  // [&deleter] would be unsafe if set_T() was called before this object got erased\n    );\n  }\n\n  template <typename T>\n  T& get_external_generic(UniquePtr<T>& object, const std::function<T*(void)>& factory, const std::function<void(T*)>& deleter) {\n    mtx_.lock();\n    std::shared_ptr<void> exit_trigger(nullptr, [&](void*){ mtx_.unlock(); });\n\n    if (!object)\n      object = new_generic(factory, deleter);\n\n    return *object;\n  }\n\n  template <typename T>\n  void reset_generic(UniquePtr<T>& object) {\n    mtx_.lock();\n    std::shared_ptr<void> exit_trigger(nullptr, [&](void*){ mtx_.unlock(); });\n\n    object.reset();\n  }\n\n  mutable std::recursive_mutex mtx_;\n\n};  // class DIM\n\n} // namespace mysql_harness\n#endif //#ifndef MYSQL_HARNESS_DIMANAGER_INCLUDED\n"
  },
  {
    "path": "src/harness/include/harness_assert.h",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_HARNESS_ASSERT_INCLUDED\n#define MYSQL_HARNESS_HARNESS_ASSERT_INCLUDED\n\n#include <stdlib.h>\n\n/** Improved assert()\n *\n * This macro is meant to provide analogous functionality to the well-known\n * assert() macro. In contrast to the original, it should also work in\n * release builds.\n */\n#define harness_assert(COND) if (!(COND)) abort();\n\n/** assert(0) idiom with an explicit name\n * \n * This is essentially the assert(0) idiom, but with more explicit name\n * to clarify the intent.\n */\n#define harness_assert_this_should_not_execute() \\\n    harness_assert(\"If execution reached this line, you have a bug\" == nullptr);\n\n#endif /* MYSQL_HARNESS_HARNESS_ASSERT_INCLUDED */\n\n"
  },
  {
    "path": "src/harness/include/hostname_validator.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_HOSTNAME_VALIDATOR_INCLUDED\n#define MYSQL_HARNESS_HOSTNAME_VALIDATOR_INCLUDED\n\n#include \"harness_export.h\"\n\nnamespace mysql_harness {\n\n/** @brief A simple hostname validator\n *\n * WARNING! This is a very simple validator, it does not handle all cornercases\n *          correctly.\n *\n * This validator was quickly written, meant as a quick filter for obvious\n * ill-formed hostnames. We chose to err on the side of being too permissive\n * rather than too strict, therefore it can produce false positives, but\n * hopefully will not produce false negatives.\n *\n * @param hostname Hostname or IP of a host\n *\n * @returns false if hostname is invalid, true if it's (possibly) valid\n */\nbool HARNESS_EXPORT is_valid_hostname(const char* hostname);\n\n} // namespace mysql_harness\n\n#endif // #define MYSQL_HARNESS_HOSTNAME_VALIDATOR_INCLUDED\n"
  },
  {
    "path": "src/harness/include/keyring/keyring.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_KEYRING_INCLUDED\n#define MYSQL_HARNESS_KEYRING_INCLUDED\n\n#include \"harness_export.h\"\n#include <string>\n#include <stdexcept>\n\n\nnamespace mysql_harness {\n\n\n/**\n * Keyring interface.\n *\n * Keyrings are responsible for storage and retrieval of sensitive data\n * (such as login credentials).\n */\nclass HARNESS_EXPORT Keyring {\n public:\n  virtual ~Keyring() = default;\n\n  /**\n   * Stores an attribute value in an entry.\n   *\n   * @param[in] uid Entry id.\n   * @param[in] attribute Attribute id.\n   * @param[in] value Attribute value.\n   */\n  virtual void store(const std::string &uid,\n                     const std::string &attribute,\n                     const std::string &value) = 0;\n\n  /**\n   * Retrieves attribute value from an entry.\n   *\n   * @param[in] uid Entry id.\n   * @param[in] attribute Attribute id.\n   *\n   * @return Attribute value.\n   *\n   * @exception std::out_of_range Attribute not found.\n   */\n  virtual std::string fetch(const std::string &uid,\n                            const std::string &attribute) const = 0;\n\n  /**\n   * Removes an entry.\n   *\n   * @param[in] uid Entry id.\n   */\n  virtual void remove(const std::string &uid) = 0;\n\n  /**\n   * Removes an attribute from an entry.\n   *\n   * @param[in] uid Entry id.\n   * @param[in] attribute Attribute id.\n   */\n  virtual void remove_attribute(const std::string &uid,\n                                const std::string &attribute) = 0;\n};\n\n\n} // namespace mysql_harness\n\n\n#endif // MYSQL_HARNESS_KEYRING_INCLUDED\n"
  },
  {
    "path": "src/harness/include/keyring/keyring_file.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_KEYRING_FILE_INCLUDED\n#define MYSQL_HARNESS_KEYRING_FILE_INCLUDED\n\n#include \"keyring_memory.h\"\n#include <iostream>\n\nnamespace mysql_harness {\n\n\n/**\n * KeyringFile class.\n *\n * Implements Keyring interface and provides additional methods for loading and\n * saving keyring to file.\n */\nclass HARNESS_EXPORT KeyringFile : public KeyringMemory {\n public:\n  KeyringFile() = default;\n\n  /**\n   * Sets additional data to be stored with the file but will not be\n   * encrypted.\n   *\n   * @param[in] data to store in header\n   */\n  void set_header(const std::string &data);\n\n  /**\n   * Saves keyring to file.\n   *\n   * @param[in] file_name Keyring file name.\n   * @param[in] key Key used for encryption.\n   *\n   * @exception std::exception Saving to file failed.\n   */\n  void save(const std::string& file_name, const std::string& key) const;\n\n  /**\n   * Load keyring from file.\n   *\n   * @param[in] file_name Keyring file name.\n   * @param[in] key Key used for decryption.\n   *\n   * @exception std::exception Loading from file failed.\n   */\n  void load(const std::string& file_name, const std::string& key);\n\n  /**\n   * Read header data from file.\n   *\n   * @param[in] file_name Keyring file name.\n   *\n   * @exception std::exception Loading from file failed.\n   */\n  std::string read_header(const std::string& file_name);\n\n private:\n  std::string header_;\n};\n\n\n} // namespace mysql_harness\n\n\n#endif // MYSQL_HARNESS_KEYRING_FILE_INCLUDED\n"
  },
  {
    "path": "src/harness/include/keyring/keyring_manager.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_KEYRING_MANAGER_INCLUDED\n#define MYSQL_HARNESS_KEYRING_MANAGER_INCLUDED\n\n#include <string>\n#include <stdexcept>\n#include \"keyring.h\"\n\nnamespace mysql_harness {\n\nclass invalid_master_keyfile : public std::runtime_error {\npublic:\n  invalid_master_keyfile(const std::string &w) : std::runtime_error(w) {}\n};\n\nstatic const int kMaxKeyringKeyLength = 255;\n\n/**\n * Initialize an instance of a keyring to be used in the application\n * from the contents of a file, using the given master key file.\n *\n * @param keyring_file_path path to the file where keyring is stored\n * @param master_key_path path to the file keyring master keys are stored\n * @param create_if_needed creates the keyring if it doesn't exist yet\n *\n * @return false if the keyring had to be created\n */\nHARNESS_EXPORT bool init_keyring(const std::string &keyring_file_path,\n                                 const std::string &master_key_path,\n                                 bool create_if_needed);\n\n/**\n * Initialize an instance of a keyring to be used in the application\n * from the contents of a file, using the given master key.\n *\n * @param keyring_file_path path to the file where keyring is stored\n * @param master_key master key for the keyring\n * @param create_if_needed creates the keyring if it doesn't exist yet\n *\n * @return false if the keyring had to be created\n */\nHARNESS_EXPORT bool init_keyring_with_key(const std::string &keyring_file_path,\n                                          const std::string &master_key,\n                                          bool create_if_needed);\n\n/**\n * Saves the keyring contents to disk.\n */\nHARNESS_EXPORT void flush_keyring();\n\n\n/**\n * Gets a previously initialized singleton instance of the keyring\n */\nHARNESS_EXPORT Keyring *get_keyring();\n\n/**\n * Clears the keyring singleton.\n */\nHARNESS_EXPORT void reset_keyring();\n}\n\n#endif\n"
  },
  {
    "path": "src/harness/include/keyring/keyring_memory.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_KEYRING_MEMORY_INCLUDED\n#define MYSQL_HARNESS_KEYRING_MEMORY_INCLUDED\n\n#include \"keyring.h\"\n#include <map>\n#include <vector>\n\n\nnamespace mysql_harness {\n\nclass decryption_error : public std::runtime_error {\npublic:\n  decryption_error(const char *_what) : std::runtime_error(_what) {}\n};\n\n/**\n * KeyringMemory class.\n *\n * Implements Keyring interface and provides additional methods for parsing\n * and serialization using a simple binary format. Also, handles AES encryption.\n * Used primarily for testing and as a base for KeyringFile.\n */\nclass HARNESS_EXPORT KeyringMemory : public Keyring {\n public:\n  constexpr static unsigned int kFormatVersion = 0;\n\n  KeyringMemory() = default;\n\n  /**\n   * Serializes and encrypts keyring data to memory buffer.\n   *\n   * @param[in] key Key used for encryption.\n   *\n   * @return Serialized keyring data.\n   *\n   * @exception std::exception Serialization failed.\n   */\n  std::vector<char> serialize(const std::string& key) const;\n\n  /**\n   * Parses and decrypts keyring data.\n   *\n   * @param[in] key Key used for decryption.\n   * @param[in] buffer Serialized keyring data.\n   * @param[in] buffer_size Size of the data.\n   *\n   * @exception std::exception Parsing failed.\n   */\n  void parse(const std::string& key, const char* buffer,\n             std::size_t buffer_size);\n\n  // Keyring interface.\n  virtual void store(const std::string &uid,\n                     const std::string &attribute,\n                     const std::string &value) override;\n\n  virtual std::string fetch(const std::string &uid,\n                            const std::string &attribute) const override;\n\n  virtual void remove(const std::string &uid) override;\n\n  virtual void remove_attribute(const std::string &uid,\n                                const std::string &attribute) override;\n\n private:\n  std::map<std::string, std::map<std::string, std::string>> entries_;\n};\n\n\n} // namespace mysql_harness\n\n\n#endif // MYSQL_HARNESS_KEYRING_MEMORY_INCLUDED\n"
  },
  {
    "path": "src/harness/include/mysql/harness/arg_handler.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef HARNESS_ARG_HANDLER_INCLUDED\n#define HARNESS_ARG_HANDLER_INCLUDED\n\n/** @file\n * @brief Defining the commandline argument handler class CmdArgHandler\n *\n * This file defines the commandline argument handler class CmdArgHandler.\n */\n\n#include \"harness_export.h\"\n\n#include <cstdint>\n#include <functional>\n#include <memory>\n#include <string>\n#include <vector>\n\nenum class CmdOptionValueReq : uint8_t {\n  none = 0x01,\n  required = 0x02,\n  optional = 0x03,\n};\n\nusing ActionFunc = std::function<void(const std::string &)>;\nusing AtEndActionFunc = std::function<void()>;\nusing OptionNames = std::vector<std::string>;\n\n/** @brief CmdOption stores information about command line options\n *\n * The CmdOption structure stores information about command line options.\n *\n */\nstruct CmdOption {\n  using ActionFunc  = std::function<void(const std::string &)>;\n  using AtEndActionFunc = std::function<void()>;\n  using OptionNames = std::vector<std::string>;\n\n  OptionNames names;\n  std::string description;\n  CmdOptionValueReq value_req;\n  std::string value;\n  std::string metavar;\n  ActionFunc action;\n  AtEndActionFunc at_end_action;\n\n  CmdOption(OptionNames names_,\n            std::string description_,\n            CmdOptionValueReq value_req_,\n            const std::string metavar_,\n            ActionFunc action_,\n            AtEndActionFunc at_end_action_ = []{})\n  : names(names_), description(description_), value_req(value_req_),\n    metavar(metavar_), action(action_), at_end_action(at_end_action_) {}\n};\n\n/** @brief Definition of a vector holding unique pointers to CmdOption\n * objects **/\nusing OptionContainer = std::vector<CmdOption>;\n\n/** @class CmdArgHandler\n *  @brief Handles command line arguments\n *\n * The CmdArgHandler class handles command line arguments. It is a\n * replacement and supports most of the POSIX GNU getopt library.\n *\n * Command line options can have multiple aliases. For example, the\n * typical `--help` can be also called `-h`, or even `--help-me`. Long\n * names starting with one dash are not supported.\n *\n * Command line options are added through the `add_option()` method\n * and can be given 1 or more names and a description. It is also\n * possible to require the option to have a value, or make the value\n * optional.\n *\n * During processing of the command line arguments, actions will be\n * executed when the option (and it's potential value) was found.\n *\n * Usage example:\n *\n *     #include \"arg_handler.h\"\n *\n *     void MyApp::prepare_command_line_options() {\n *       // CmdArgHandler handler_;\n *       handler_.add_option(OptionNames({\"-h\", \"--help\", \"--sos\"}), \"Show help screen\",\n *                          CmdOptionValueReq::none, \"\",\n *                          [this](const string &) { this->show_help(); }\n *       handler_.add_option(OptionNames({\"--config\"}), \"Configuration file\",\n *                          CmdOptionValueReq::none, \"\",\n *                          [this](const string &value) { this->set_config_file(value); },\n *                          []{});\n *\n *     void MyApp::init(const vector<string> arguments) {\n *       prepare_command_line_options();\n *       handler_.process(arguments);\n *     }\n *\n *  All arguments which are not valid option names are are not values of options are considered\n *  rest arguments. By default, rest arguments are not allowed and will raise a std::invalid_argument\n *  exception. It is possible to allow them through the constructor.\n *\n *  The CmdArgHandler class also provides functionality to help creating help\n *  screen or show how to use the the command line application. The method `usage_lines()`\n *  produces a usage line showing all the option names, their required or optional\n *  value with a meta variable. Similar, method `option_descriptions()` will get\n *  all options and their descriptions. All this is text wrapped at a configurable\n *  margin as well as, if needed, indented.\n *\n *  @devnote\n *  The command line argument handling in CmdArgHandler is the bare minimum needed\n *  for MySQL Router. It was needed to make sure that the application would compile\n *  on system where the getopt library is not available.\n *  @enddevnote\n *\n */\nclass HARNESS_EXPORT CmdArgHandler {\n public:\n  /** @brief Constructor\n   *\n   * @param allow_rest_arguments_ whether we allow rest arguments or not\n   */\n  explicit CmdArgHandler(bool allow_rest_arguments_)\n      : allow_rest_arguments(allow_rest_arguments_) {}\n\n  /** @brief Default constructor\n   *\n   * By default, rest arguments are not allowed.\n   */\n  CmdArgHandler() : CmdArgHandler(false) {}\n\n  /** @brief Adds a command line option\n   *\n   * Adds a command line option given names, description, value\n   * requirement and optional action.\n   *\n   * `names` is a vector of strings which contains names starting\n   * with either a single or double dash, `-` or `--`. It is possible\n   * to add more than one name for an option.\n   *\n   * The description text will be used in the help output. Note that\n   * this can be a very long as text will be wrapped (and optionally\n   * indented). New lines in the description will be respected.\n   *\n   * The `metavar` argument is used in the usage text as a placeholder\n   * for the (optional) value of the option, for example, when `metavar`\n   * is set to `path`, the usage would show:\n   *\n   *     --config=<path>\n   *\n   * The value_req argument should be either:\n   *\n   * * `CmdOptionValueReq::none` : option has no value\n   * * `CmdOptionValueReq::required` : option requires value\n   * * `CmdOptionValueReq::optional` : option has optional value\n   *\n   * The `action` argument should be a `std::function` and is called\n   * with the (optional) value of the option. The function should\n   * accept only a `const std::string`.\n   *\n   * The `at_end_action` argument should be a `std::function`. This is optional\n   * argument, if not provided then []{} is used as at_end_action. The `at_end_action`\n   * is ment to be used for additional validation, if particular set of options\n   * has to be used together, or if particular set of options cannot be used together.\n   *\n   * Example usage:\n   *\n   *       handler_.add_option(OptionNames({\"--config\"}), \"Configuration file\",\n   *                          CmdOptionValueReq::none, \"\",\n   *                          [this](const string &value) { this->set_config_file(value); },\n   *                          []{});\n   *\n   * @devnote\n   * The `add_option` method will assert when `names` is empty,\n   * one of the names is not valid or when a name was already used with\n   * another option.\n   * @enddevnote\n   *\n   * @param names vector of string with option names, each starting with - or --\n   * @param description descriptive text explaining the option\n   * @param value_req value requirement of the option\n   * @param metavar for formatting help text when option accepts a value\n   * @param action action to perform when the option was found\n   * @param at_end_action task to perform after all actions have been done\n   */\n  void add_option(const OptionNames& names,\n                  const std::string& description,\n                  const CmdOptionValueReq& value_req,\n                  const std::string& metavar,\n                  ActionFunc action,\n                  AtEndActionFunc at_end_action = []{}) noexcept;\n\n  void add_option(const CmdOption &other) noexcept;\n\n  /** @brief Processes given command line arguments\n   *\n   * Processes given command line argument provided as a vector\n   * of strings. It uses the stored option information added through the\n   * `add_option()` method.\n   *\n   * Typically, the vector passed to process() are the argc and argv\n   * arguments of the main() function:\n   *\n   *     process({argv + 1, argv + argc})\n   *\n   * When an option is found which requires an argument, optional or\n   * not, process() will exit the application with an error message.\n   *\n   * If the option has an action defined, the function will be\n   * executed with the (optional) value as argument.\n   *\n   * @param arguments vector of strings\n   */\n  void process(const std::vector<std::string>& arguments);\n\n#ifndef NDEBUG\n  bool debug_check_option_names(const CmdOption::OptionNames& names) const;\n#endif\n\n  /** @brief Checks whether given name is a valid option name\n   *\n   * Checks whether the given name is a valid option name.\n   *\n   * A valid option name should:\n   *\n   * * have at least consist of 2 characters\n   * * start with a dash '-'\n   * * match the reqular expression ^--[A-Za-z]{2}[A-Za-z_-]+$\n   *\n   * It is allowed to use the equal sign when giving value. Following options\n   * are equal:\n   *     --config /path/to/mysqlrouter.conf\n   *     --config=/path/to/mysqlrouter.conf\n   *\n   * Throws std::invalid_argument when option name is not valid or\n   * option was not registered.\n   *\n   * Examples of valid option names:\n   *\n   *     -h\n   *     --with-ham\n   *     --with_spam\n   *\n   * Example of invalid option names:\n   *\n   *     -help\n   *     ---spam\n   *     --x-ham\n   *\n   * @param name option name to check\n   * @return true if name is valid; false otherwise\n   */\n  bool is_valid_option_name(const std::string& name) const noexcept;\n\n  /** @brief Finds the option by name\n   *\n   * Finds the option by one of its name. The name should include the the dash prefix.\n   *\n   * Example usage:\n   *     // check if option name is already present\n   *     assert(options_.end() == find_option(name))\n   *\n   * @param name name of the option as string\n   * @returns iterator object\n   */\n  OptionContainer::const_iterator\n      find_option(const std::string& name) const noexcept;\n\n  /** @brief Produces lines of text suitable to show usage\n   *\n   * Produces lines of text suitable to show usage of the command line\n   * appliation. Each option is shown with all its names and with optional\n   * or required value.\n   *\n   * The `prefix` argument can be used to add text, usually the name\n   * of the command, in front of the options. The lines are indented\n   * using the size of the prefix.\n   *\n   * The `rest_metavar` can be used to name non-options arguments.\n   *\n   * The `width` argument is used to set the maximum length of the lines.\n   *\n   * Example output when all lines are printed:\n   *\n   *     usage: mysqlrouter [-v|--version] [-h|--help] [-c|--config=<path>]\n   *                        [-a=[<foo>]] [rest..]\n   *\n   *\n   * @param prefix text in front of options (usually command name)\n   * @param rest_metavar name of rest arguments (empty if not needed)\n   * @param width maximum length of each line\n   * @return vector of strings\n   */\n  std::vector<std::string>\n      usage_lines(const std::string& prefix,\n                  const std::string& rest_metavar,\n                  size_t width) const noexcept;\n\n  /** @brief Produces description of all options\n   *\n   * Produces description of all options. The result is typically shown\n   * when the help screen is requested, for example when the `--help`\n   * option is given.\n   *\n   * The `width` argument is used to set the maximum length of the lines. Text is\n   * wrapped accordingly.\n   *\n   * Each description can be indented using space. The amount is given\n   * by `indent` option.\n   *\n   * Example output when lines are printed:\n   *\n   *     -v, --version\n   *           Show version\n   *     -h, --help\n   *           Show help\n   *     -c <path>, --config <path>\n   *           Path to the configuration file\n   *\n   * @param width maximum length of each line\n   * @param indent how much the description should be indented.\n   * @return vector of strings\n   */\n  std::vector<std::string> option_descriptions(const size_t width,\n                                               const size_t indent) noexcept;\n\n  /** @brief Returns an iterator to first option\n   *\n   * Returns an iterator to the first option.\n   *\n   * @returns iterator\n   */\n  OptionContainer::const_iterator begin() {\n    return options_.begin();\n  }\n\n  /** @brief Returns an iterator to end of the option container\n   *\n   * Returns an iterator to the end of the option container.\n   *\n   * @returns iterator\n   */\n  OptionContainer::const_iterator end() {\n    return options_.end();\n  }\n\n  /** @brief Clears registered options\n   *\n   * Clears the registered options.\n   *\n   */\n  void clear_options() {\n    options_.clear();\n  }\n\n  /** @brief Gets all registered options\n   *\n   * Returns as a reference to a vector of CmdOption objects.\n   *\n   * @return std::vector<CmdOption>\n   */\n  const std::vector<CmdOption>& get_options() const noexcept {\n    return options_;\n  }\n\n  /** @brief Returns the rest arguments\n   *\n   * Returns the rest arguments.\n   *\n   * If rest arguments are not allow or there were no rest arguments,\n   * an empty vector is returned.\n   *\n   * @return vector of strings\n   */\n  const std::vector<std::string>& get_rest_arguments() const noexcept {\n    return rest_arguments_;\n  }\n\n  /** @brief Whether to allow rest arguments or not **/\n  bool allow_rest_arguments;\n\n private:\n  /** @brief Vector with registered options **/\n  std::vector<CmdOption> options_;\n  /** @brief Vector with arguments as strings not processed as options **/\n  std::vector<std::string> rest_arguments_;\n};\n\n#endif // HARNESS_ARG_HANDLER_INCLUDED\n"
  },
  {
    "path": "src/harness/include/mysql/harness/compiler_attributes.h",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_COMPILER_ATTRIBUTES_INCLUDED\n#define MYSQL_HARNESS_COMPILER_ATTRIBUTES_INCLUDED\n\n#if defined(__GNUC__)\n#  define ATTRIBUTE_GCC_FORMAT(style, fmt_pos, arg_pos) __attribute__((format(style, fmt_pos, arg_pos)))\n#else\n#  define ATTRIBUTE_GCC_FORMAT(style, fmt_pos, arg_pos)\n#endif\n\n#endif // MYSQL_HARNESS_COMPILER_ATTRIBUTES_INCLUDED\n"
  },
  {
    "path": "src/harness/include/mysql/harness/config_parser.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_CONFIG_PARSER_INCLUDED\n#define MYSQL_HARNESS_CONFIG_PARSER_INCLUDED\n\n#include <functional>\n#include <iterator>\n#include <list>\n#include <map>\n#include <memory>\n#include <stdexcept>\n#include <string>\n#include <vector>\n\n#include \"harness_export.h\"\n\nnamespace mysql_harness {\n\nclass ConfigSection;\nclass Path;\n\n/**\n * Convenience class for handling iterator range.\n *\n * This is a template class that accept a pair of iterators and\n * implement the necessary methods to be able to be used as a sequence\n * container.\n */\ntemplate <class Iter>\nclass Range {\n public:\n  using value_type = typename Iter::value_type;\n  using reference = typename Iter::reference;\n  using iterator = Iter;\n  using const_iterator = iterator;\n  using difference_type = typename std::iterator_traits<Iter>::difference_type;\n  using size_type = difference_type;\n\n  Range(Iter start, Iter finish) : begin_(start), end_(finish) {}\n\n  /** Get iterator to beginning of range. */\n  Iter begin() const { return begin_; }\n\n  /** Get iterator to end of range. */\n  Iter end() const { return end_; }\n\n  /** Check if range is empty. */\n  bool empty() const { return begin_ == end_; }\n\n  /**\n   * Get size of the range, that is, number of elements in the range.\n   *\n   * @note This call `std::distance` internally.\n   *\n   * @returns The number of elements in the range.\n   */\n  size_type size() const {\n    return std::distance(begin_, end_);\n  }\n\n private:\n  Iter begin_;\n  Iter end_;\n};\n\n/**\n * Exception thrown for syntax errors.\n *\n * @ingroup ConfigParser\n * Exception thrown for errors during parsing configuration file.\n */\n\nclass syntax_error : public std::logic_error {\n public:\n  explicit syntax_error(const std::string& msg) : std::logic_error(msg) {}\n};\n\n/**\n * Exception thrown for section problems.\n *\n * @ingroup ConfigParser\n */\n\nclass bad_section : public std::runtime_error {\n public:\n  explicit bad_section(const std::string& msg) : std::runtime_error(msg) {}\n};\n\n\n/**\n * Exception thrown for option problems.\n *\n * @ingroup ConfigParser\n */\n\nclass bad_option : public std::runtime_error {\n public:\n  explicit bad_option(const std::string& msg) : std::runtime_error(msg) {}\n};\n\n\n/**\n * Configuration section.\n *\n * @ingroup ConfigParser\n *\n * A named configuration file section with a zero or more\n * configuration file options.\n */\n\nclass HARNESS_EXPORT ConfigSection {\n public:\n  using OptionMap = std::map<std::string, std::string>;\n  using OptionRange = Range<OptionMap::const_iterator>;\n\n  ConfigSection(const std::string& name_arg,\n                const std::string& key_arg,\n                const std::shared_ptr<const ConfigSection>& defaults);\n\n  ConfigSection(const ConfigSection&,\n                const std::shared_ptr<const ConfigSection>& defaults);\n  ConfigSection& operator=(const ConfigSection&) = delete;\n\n  /**\n   * Clear the options in the section.\n   *\n   * This will remove options from the configuration section.\n   */\n  void clear();\n\n  /**\n   * Update section with contents of another section.\n   *\n   * The configuration section will be updated with the contents of\n   * the other section. For any options that exist in the section, the\n   * value will be overwritten by the values in the `other`\n   * section. If the option do not exist, a new option will be created\n   * and the value set to the value of the option in the `other`\n   * section.\n   *\n   * @note The section name and key have to match for the update to be\n   * done.\n   *\n   * @exception bad_section Thrown if the section name or section key\n   * do not match.\n   *\n   * @param other Section to copy options and values from.\n   */\n  void update(const ConfigSection& other); // throws bad_section\n\n  std::string get(const std::string& option) const;\n  void set(const std::string& option, const std::string& value);  // throws bad_option\n  void add(const std::string& option, const std::string& value);\n  bool has(const std::string& option) const;\n\n  /**\n   * Range for options in section.\n   *\n   * Typical usage is:\n   *\n   * @code\n   * for (auto elem: section.get_options())\n   *   std::cout << \"Option \" << elem.first\n   *             << \" has value \" << elem.second\n   *             << std::endl;\n   * @endcode\n   *\n   * @returns a range of options each consisting of a pair\n   * option-value.\n   */\n  OptionRange get_options() const {\n    return OptionRange(options_.begin(), options_.end());\n  }\n\n  /*\n   * Returns name of the section in which option is specified. The returned\n   * name may be the name of the section or the name of the default section.\n   *\n   * @option option The name of the option\n   * @return The name of the ConfigSection which option is specified.\n   */\n  std::string get_section_name(const std::string& option) const;\n\n#ifndef NDEBUG\n  bool assert_default(const ConfigSection* def) const {\n    return def == defaults_.get();\n  }\n#endif\n\n public:\n  const std::string name;\n  const std::string key;\n\n private:\n  std::string do_replace(const std::string& value, int depth = 0) const;\n\n  const int kMaxInterpolationDepth = 10;\n\n  std::pair<OptionMap::const_iterator, bool>\n      do_locate(const std::string& option) const;\n\n  const std::shared_ptr<const ConfigSection> defaults_;\n  OptionMap options_;\n};\n\n\n/**\n * Configuration.\n *\n * @ingroup ConfigParser\n *\n * A configuration consisting of named configuration sections.\n *\n * There are three different constructors that are available with\n * different kind of parameters.\n */\n\nclass HARNESS_EXPORT Config {\n public:\n  using SectionKey = std::pair<std::string, std::string>;\n  using OptionMap = ConfigSection::OptionMap;\n  using SectionList = std::list<ConfigSection*>;\n  using ConstSectionList = std::list<const ConfigSection*>;\n\n  /**@{*/\n  /** Flags for construction of configurations. */\n\n  static constexpr unsigned int allow_keys = 1U;\n\n  /**@}*/\n\n  /**\n   * Default pattern to used to identify configuration files.\n   */\n  static constexpr const char* DEFAULT_PATTERN = \"*.cfg\";\n\n  explicit Config(unsigned int flags = 0U) noexcept;\n\n  /** @overload */  // throws bad_option\n  template <class AssocT>\n  explicit Config(const AssocT& parameters, unsigned int flags = 0U)\n      : Config(flags) {\n    for (auto item : parameters)\n      defaults_->set(item.first, item.second);  // throws bad_option\n  }\n\n  /**\n   * Construct a configuration.\n   *\n   * Construct a configuration instace by reading a configuration file\n   * and overriding the values read from a list of supplied\n   * parameters.\n   *\n   * @param parameters Associative container with parameters.\n   * @param reserved Sequence container of reserved words.\n   * @param flags flags.\n   */\n\n  /** @overload */  // throws bad_option\n  template <class AssocT, class SeqT>\n  explicit Config(const AssocT& parameters,\n                  const SeqT& reserved,\n                  unsigned int flags = 0U)\n      : Config(parameters, flags) /* throws bad_option */ {\n    for (auto word : reserved)\n      reserved_.push_back(word);\n  }\n\n  virtual ~Config() = default;\n\n  template <class SeqT>\n  void set_reserved(const SeqT& reserved) {\n    reserved_.assign(reserved.begin(), reserved.end());\n  }\n\n  /**\n   * Read configuration file from file, directory, or input stream.\n   *\n   * If there are conflicting sections (several instance sections with\n   * identical name and key) or conflicting options (several instances\n   * of an option in the same section) in the input, an exception will\n   * be thrown.\n   *\n   * If the input is a stream, the contents of the stream will be\n   * added to the configuration, but if the input is either a file or\n   * a directory, the exisisting contents of the configuration will be\n   * removed.\n   *\n   * If a `pattern` is given, the path is assumed to be a directory\n   * and all files matching the pattern will be read into the the\n   * configuration object. The files together will be treated as if it\n   * is a single file, that is, no conflicting option values or\n   * sections are allowed and will raise an exception.\n   *\n   * @param input Input stream to read from.\n   *\n   * @exception syntax_error Raised if there is a syntax error in the\n   * configuration file and the configuration file have to be corrected.\n   *\n   * @exception bad_section Raised if there is a duplicate section\n   * (section with the same name and key) in the input stream.\n   *\n   * @exception bad_option Raised if there is a duplicate definition\n   * of an option (same option is given twice in a section).\n   */\n  void read(std::istream& input);\n\n  /** @overload */\n  void read(const Path& path);\n\n  /*\n   * @param path Path to directory or file to read from.\n   * @param pattern Glob pattern for configuration files in the directory.\n   */\n  /** @overload */\n  void read(const Path& path, const std::string& pattern);\n\n  /**\n   * Check if the configuration is empty.\n   *\n   * @return `true` if there are any sections in the configuration\n   * (not counting the default section), `false` otherwise.\n   */\n  bool empty() const;\n\n  /**\n   * Clear the configuration.\n   *\n   * This will remove all configuration information from the\n   * configuration, including the default section, but not the\n   * reserved words nor the flags set.\n   */\n  void clear();\n\n  /**\n   * Remove section from configuration\n   *\n   * @param section_key section+key to remove.\n   *\n   * @return true if section was removed, false if section did not exist\n   */\n  bool remove(const SectionKey& section_key) noexcept;\n\n  /*\n   * @param section Name of section to remove.\n   * @param key Optional key of section to remove.\n   */\n  /** @overload */\n  bool remove(const std::string& section,\n              const std::string& key = std::string()) noexcept;\n\n  /**\n   * Update configuration using another configuration.\n   *\n   * This will incorporate all the sections and options from the\n   * `other` configuration by adding sections that are missing and\n   * overwriting option values for sections that exist in the current\n   * configuration.\n   *\n   * @param other Configuration to read section, options, and values\n   * from.\n   */\n  void update(const Config& other);\n\n  /**\n   * Get a list of sections having a name.\n   *\n   * There can be several sections under the same name, but they will\n   * have different keys.\n   *\n   * @note The empty string is used to denote the keyless section.\n   *\n   * @param section Section name of sections to fetch.\n   */\n  ConstSectionList get(const std::string& section) const;\n\n  /** @overload */\n  SectionList get(const std::string& section);\n\n  /**\n   * Get a section by name and key.\n   *\n   * Get a section given a name and a key. Since there can be several\n   * sections with the same name (but different keys) this will always\n   * return a unique section.\n   *\n   * @note The empty string is used to denote the keyless section.\n   *\n   * @param section Name of section to fetch.\n   * @param key Key for section to fetch.\n   *\n   * @return Reference to section instance.\n   *\n   * @exception bad_section Thrown if the section do not exist or if a\n   * key were used but is not allowed.\n   */\n  ConfigSection& get(const std::string& section, const std::string& key);\n\n  /** @overload */\n  const ConfigSection& get(const std::string& section,\n                           const std::string& key) const;\n\n  /**\n   * Add a new section to the configuration.\n   *\n   * @param section Name of section to add.\n   * @param key Optional key of section to add.\n   *\n   * @return Reference to newly constructed configuration section\n   * instance.\n   */\n  ConfigSection& add(const std::string& section,\n                     const std::string& key = std::string());\n\n  bool has(const std::string& section,\n           const std::string& key = std::string()) const;\n  \n  /**\n   * @return True if a section exists, no matter what the key is.\n   */\n  bool has_any(const std::string& section) const;\n\n  std::string get_default(const std::string& option) const;\n  bool has_default(const std::string& option) const;\n  void set_default(const std::string& option, const std::string& value);\n\n  bool is_reserved(const std::string& word) const;\n\n  std::list<Config::SectionKey> section_names() const {\n    decltype(section_names()) result;\n    for (auto& section : sections_)\n      result.push_back(section.first);\n    return result;\n  }\n\n  /**\n   * Get a list of all sections in the configuration.\n   */\n  ConstSectionList sections() const;\n\n protected:\n  using SectionMap = std::map<SectionKey, ConfigSection>;\n  using ReservedList = std::vector<std::string>;\n\n  /**\n   * Copy the guts of another configuration.\n   *\n   * This member function is used to copy configuration state (the\n   * \"guts\") but not the sections and options, including not copying\n   * the default section.\n   */\n  void copy_guts(const Config& source) noexcept;\n\n  std::string replace_variables(const std::string& value) const;\n\n  /**\n   * Function to read single file.\n   *\n   * @throws std::runtime_error, syntax_error\n   */\n  virtual void do_read_file(const Path& path);\n\n  /**\n   * Function to read the configuration from a stream.\n   *\n   * @throws syntax_error, maybe bad_section (not sure if it can happen)\n   *\n   * @note This function is guaranteeed to be called for reading all\n   * configurations so it can be overridden to handle post- or\n   * pre-parsing actions.\n   */\n  virtual void do_read_stream(std::istream& input);\n\n  SectionMap sections_;\n  ReservedList reserved_;\n  std::shared_ptr<ConfigSection> defaults_;\n  unsigned int flags_;\n};\n\n}  // namespace mysql_harness\n\n#endif /* MYSQL_HARNESS_CONFIG_PARSER_INCLUDED */\n"
  },
  {
    "path": "src/harness/include/mysql/harness/filesystem.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_FILESYSTEM_INCLUDED\n#define MYSQL_HARNESS_FILESYSTEM_INCLUDED\n\n#include \"harness_export.h\"\n\n#include <memory>\n#include <string>\n\n\nnamespace mysql_harness {\n\n/**\n * @defgroup Filesystem Platform-independent file system operations\n *\n * This module contain platform-independent file system operations.\n */\n\n/**\n * Class representing a path in a file system.\n *\n * @ingroup Filesystem\n *\n * Paths are used to access files in the file system and can be either\n * relative or absolute. Absolute paths have a slash (`/`) first in\n * the path, otherwise, the path is relative.\n */\nclass HARNESS_EXPORT Path {\n  friend std::ostream& operator<<(std::ostream& out, const Path& path) {\n    out << path.path_;\n    return out;\n  }\n\n public:\n  /**\n   * Enum used to identify file types.\n   */\n\n  enum class FileType {\n    /** An error occured when trying to get file type, but it is *not*\n     * that the file was not found. */\n    STATUS_ERROR,\n\n    /** Empty path was given */\n    EMPTY_PATH,\n\n    /** The file was not found. */\n    FILE_NOT_FOUND,\n\n    /** The file is a regular file. */\n    REGULAR_FILE,\n\n    /** The file is a directory. */\n    DIRECTORY_FILE,\n\n    /** The file is a symbolic link. */\n    SYMLINK_FILE,\n\n    /** The file is a block device */\n    BLOCK_FILE,\n\n    /** The file is a character device */\n    CHARACTER_FILE,\n\n    /** The file is a FIFO */\n    FIFO_FILE,\n\n    /** The file is a UNIX socket */\n    SOCKET_FILE,\n\n    /** The type of the file is unknown, either because it was not\n     * fetched yet or because stat(2) reported something else than the\n     * above. */\n    TYPE_UNKNOWN,\n  };\n\n  friend HARNESS_EXPORT std::ostream& operator<<(std::ostream& out, FileType type);\n\n  Path() noexcept;\n\n /**\n   * Construct a path\n   *\n   * @param path Non-empty string denoting the path.\n   */\n  /** @overload */  // throws std::invalid_argument\n  Path(const std::string& path);  // NOLINT(runtime/explicit)\n\n  /** @overload */  // throws std::invalid_argument\n  Path(const char* path);  // NOLINT(runtime/explicit)\n\n  /**\n   * Create a path from directory, basename, and extension.\n   */\n  static Path make_path(const Path& directory,\n                        const std::string& basename,\n                        const std::string& extension);\n\n  bool operator==(const Path& rhs) const;\n\n  /**\n   * Path ordering operator.\n   *\n   * This is mainly used for ordered containers. The paths are ordered\n   * lexicographically.\n   */\n  bool operator<(const Path& rhs) const;\n\n  /**\n   * Get the file type.\n   *\n   * The file type is normally cached so if the file type under a path\n   * changes it is necessary to force a refresh.\n   *\n   * @param refresh Set to `true` if the file type should be\n   * refreshed, default to `false`.\n   *\n   * @return The type of the file.\n   */\n  FileType type(bool refresh = false) const;\n\n  /**\n   * Check if the file is a directory.\n   */\n  bool is_directory() const;\n\n  /**\n   * Check if the file is a regular file.\n   */\n  bool is_regular() const;\n\n  /**\n   * Check if path exists\n   */\n  bool exists() const;\n\n  /*\n   * @brief Checks if path exists and can be opened for reading.\n   *\n   * @return true if path exists and can be opened for reading,\n   *         false otherwise.\n   */\n  bool is_readable() const;\n\n  /**\n   * Get the directory name of the path.\n   *\n   * This will strip the last component of a path, assuming that the\n   * what remains is a directory name. If the path is a relative path\n   * that do not contain any directory separators, a dot will be\n   * returned (denoting the current directory).\n   *\n   * @note No checking of the components are done, this is just simple\n   * path manipulation.\n   *\n   * @return A new path object representing the directory portion of\n   * the path.\n   */\n  Path dirname() const;\n\n  /**\n   * Get the basename of the path.\n   *\n   * Return the basename of the path: the path without the directory\n   * portion.\n   *\n   * @note No checking of the components are done, this is just simple\n   * path manipulation.\n   *\n   * @return A new path object representing the basename of the path.\n   * the path.\n   */\n  Path basename() const;\n\n  /**\n   * Append a path component to the current path.\n   *\n   * This function will append a path component to the path using the\n   * apropriate directory separator.\n   *\n   * @param other Path component to append to the path.\n   */\n  void append(const Path& other);\n\n\n  /**\n   * Join two path components to form a new path.\n   *\n   * This function will join the two path components using a\n   * directory separator.\n   *\n   * @note This will return a new `Path` object. If you want to modify\n   * the existing path object, you should use `append` instead.\n   *\n   * @param other Path component to be appended to the path\n   */\n  Path join(const Path& other) const;\n\n  /** @overload */\n  Path join(const char* other) const { return join(Path(other)); }\n\n  /**\n   * Returns the canonical form of the path, resolving relative paths.\n   */\n  Path real_path() const;\n\n\n  /**\n   * Get a C-string representation to the path.\n   *\n   * @note This will return a pointer to the internal representation\n   * of the path and hence will become a dangling pointer when the\n   * `Path` object is destroyed.\n   *\n   * @return Pointer to a null-terminated C-string.\n   */\n  const char *c_str() const {\n    return path_.c_str();\n  }\n\n  /**\n   * Get a string representation of the path.\n   *\n   * @return Instance of std::string containing the path.\n   */\n  const std::string& str() const noexcept {\n    return path_;\n  }\n\n  /**\n   * Test if path is set\n   *\n   * @return Test result\n   */\n  bool is_set() const noexcept {\n    return (type_ != FileType::EMPTY_PATH);\n  }\n\n  /**\n   * Directory separator string.\n   *\n   * @note This is platform-dependent and defined in the apropriate\n   * source file.\n   */\n  static const char * const directory_separator;\n\n  /**\n   * Root directory string.\n   *\n   * @note This is platform-dependent and defined in the apropriate\n   * source file.\n   */\n  static const char * const root_directory;\n\n  operator bool() const noexcept { return is_set(); }\n\n private:\n  void validate_non_empty_path() const; // throws std::invalid_argument\n\n  std::string path_;\n  mutable FileType type_;\n};\n\n/**\n * Class representing a directory in a file system.\n *\n * @ingroup Filesystem\n *\n * In addition to being a refinement of `Path`, it also have functions\n * that make it act like a container of paths and support iterating\n * over the entries in a directory.\n *\n * An example of how it could be used is:\n * @code\n * for (auto&& entry: Directory(path))\n *   std::cout << entry << std::endl;\n * @endcode\n */\nclass HARNESS_EXPORT Directory : public Path {\n public:\n  /**\n   * Directory iterator for iterating over directory entries.\n   *\n   * A directory iterator is an input iterator.\n   */\n  using DirectoryIteratorBase = std::iterator<std::input_iterator_tag, Path>;\n\n  class HARNESS_EXPORT DirectoryIterator\n      : public DirectoryIteratorBase {\n    friend class Directory;\n\n   public:\n    DirectoryIterator(const Path& path,\n                      const std::string& pattern = std::string());\n\n    // Create an end iterator\n    DirectoryIterator();\n\n    /**\n     * Destructor.\n     *\n     * @note We need this *declared* because the default constructor\n     * try to generate a default constructor for shared_ptr on State\n     * below, which does not work since it is not visible. The\n     * destructor need to be *defined* in the corresponding .cc file\n     * since the State type is visible there (but you can use a\n     * default definition).\n     */\n    ~DirectoryIterator();\n\n    // We need these since the default move/copy constructor is\n    // deleted when you define a destructor.\n#if !defined(_MSC_VER) || (_MSC_VER >= 1900)\n    DirectoryIterator(DirectoryIterator&&);\n    DirectoryIterator(const DirectoryIterator&);\n#endif\n\n    /** Standard iterator operators */\n    /** @{ */\n    Path operator*() const;\n    DirectoryIterator& operator++();\n    Path operator->() { return this->operator*(); }\n    bool operator!=(const DirectoryIterator& other) const;\n\n    // This avoids C2678 (no binary operator found) in MSVC,\n    // MSVC's std::copy implementation (used by TestFilesystem) uses operator==\n    // (while GCC's implementation uses operator!=).\n    bool operator==(const DirectoryIterator& other) const {\n      return !(this->operator!=(other));\n    }\n    /** @} */\n\n   private:\n    /**\n     * Path to the root of the directory\n     */\n    const Path path_;\n\n    /**\n     * Pattern that matches entries iterated over.\n     */\n    std::string pattern_;\n\n    /*\n     * Platform-dependent container for iterator state.\n     *\n     * The definition of this class is different for different\n     * platforms, meaning that it is not defined here at all but\n     * rather in the corresponding `filesystem-<platform>.cc` file.\n     *\n     * The directory iterator is the most critical piece since it holds\n     * an iteration state for the platform: something that requires\n     * different types on the platforms.\n     */\n    class State;\n    std::shared_ptr<State> state_;\n  };\n\n  /**\n   * Construct a directory instance.\n   *\n   * Construct a directory instance in different ways depending on the\n   * version of the constructor used.\n   */\n  Directory(const std::string& path)  // NOLINT(runtime/explicit)\n      : Path(path) {} // throws std::invalid_argument\n\n  /** @overload */  // throws std::invalid_argument\n  Directory(const Path& path);  // NOLINT(runtime/explicit)\n\n  ~Directory();\n\n  /**\n   * Iterator to first entry.\n   *\n   * @return Returns an iterator pointing to the first entry.\n   */\n  DirectoryIterator begin();\n\n  /**\n   * Iterator past-the-end of entries.\n   *\n   * @return Returns an iterator pointing *past-the-end* of the entries.\n   */\n  DirectoryIterator end();\n\n  /**\n   * Iterate over entries matching a glob.\n   */\n  DirectoryIterator glob(const std::string& glob);\n};\n\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// Utility free functions\n//\n////////////////////////////////////////////////////////////////////////////////\n\n/** @brief Removes a directory.\n *\n * @ingroup Filesystem\n *\n * @param dir path of the directory to be removed; this directory must be empty\n *\n * @return 0 on success, -1 on error and sets errno\n */\nHARNESS_EXPORT\nint delete_dir(const std::string& dir) noexcept;\n\n/** @brief Removes a file.\n *\n * @ingroup Filesystem\n *\n * @param path of the file to be removed\n *\n * @return 0 on success, -1 on error\n */\nHARNESS_EXPORT\nint delete_file(const std::string& path) noexcept;\n\n/** @brief Removes directory and all its contents.\n *\n * @ingroup Filesystem\n *\n * @param dir path of the directory to be removed\n *\n * @return 0 on success, -1 on error\n */\nHARNESS_EXPORT\nint delete_dir_recursive(const std::string& dir) noexcept;\n\n/** @brief Creates a temporary directory with partially-random name and returns its path.\n *\n * Creates a directory with a name of form {prefix}-{6 random alphanumerals}.\n * For example, a possible directory name created by a call to get_tmp_dir(\"foo\")\n * might be:\n *   foo-3f9x0z\n *\n * Such directory is usually meant to be used as a temporary directory (thus the\n * \"_tmp_\" in the name of this function).\n *\n * @ingroup Filesystem\n *\n * @param name name to be used as a directory name prefix\n *\n * @return path to the created directory\n *\n * @throws std::runtime_error if operation failed\n */\nHARNESS_EXPORT\nstd::string get_tmp_dir(const std::string& name = \"router\");\n\n} // namespace mysql_harness\n\n#endif /* MYSQL_HARNESS_FILESYSTEM_INCLUDED */\n"
  },
  {
    "path": "src/harness/include/mysql/harness/loader.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/**\n * @class mysql_harness::Loader\n *\n * @ingroup Loader\n *\n *\n *\n * ## Introduction\n *\n * The loader class is responsible for managing the life-cycle of\n * plugins in the harness. Each plugin goes through seven steps in the\n * life-cycle, of which steps #2, #3, #5 and #6 are optional:\n *\n * 1. Loading\n * 2. Initialization\n * 3. Starting\n * 4. Running\n * 5. Stopping\n * 6. Deinitialization\n * 7. Unloading\n *\n * ## Overview of Life-cycle Steps\n *\n * ### 1. Loading ###\n *\n * When *loading*, the plugin is loaded using the dynamic library\n * support available on the operating system. Symbols are evaluated\n * lazily (for example, the `RTLD_LAZY` flag is used for `dlopen`) to\n * allow plugins to be loaded in any order. The symbols that are\n * exported by the plugin are made available to all other plugins\n * loaded (flag `RTLD_GLOBAL` to `dlopen`).\n *\n * As part of the loading procedure, the *plugin structure* (see\n * Plugin class) is fetched from the module and used for the four\n * optional steps below.\n *\n *\n *\n * ### 2. Initialization ###\n *\n * After all the plugins are successfully loaded, each plugin is given\n * a chance to perform initialization. This step is only executed if\n * the plugin structure defines an `init` function. Note that it is\n * guaranteed that the init function of a plugin is called *after* the\n * `init` function of all plugins it requires have been called. The\n * list of these dependencies is specified via `requires` field of the\n * `Plugin` struct.\n *\n * @note if some plugin `init()` function fails, any plugin `init()`\n * functions schedulled to run after will not run, and harness will\n * proceed straight to deinitialization step, bypassing calling\n * `start()` and `stop()` functions.\n *\n *\n *\n * ### 3. Starting ###\n * After all plugins have been successfully initialized, a thread is\n * created for each plugin that has a non-NULL `start` field in the\n * plugin structure. The threads are started in an arbitrary order,\n * so you have to be careful about not assuming that, for example,\n * other plugins required by the plugin have started their thread. If\n * the plugin does not define a `start` function, no thread is created.\n * There is a \"running\" flag associated with each such thread; this\n * flag is set when the thread starts but before the `start` function\n * is called. If necessary, the plugin can spawn more threads using\n * standard C++11 thread calls, however, these threads should not\n * call harness API functions.\n *\n *\n *\n * ### 4. Running ###\n * After starting all plugins (that needed to be started), the harness\n * will enter the *running step*. This is the \"normal\" phase, where the\n * application spends most of its lifetime (application and plugins\n * service requests or do whatever it is they do). Harness will remain\n * in this step until one of two things happen:\n *\n *   1. shutdown signal is received by the harness\n *   2. one of the plugins exits with error\n *\n * When one of these two events occurrs, harness progresses to the\n * next step.\n *\n *\n *\n * ### 5. Stopping ###\n * In this step, harness \"tells\" plugins running `start()` to exit this\n * function by clearing the \"running\" flag. It also invokes `stop()`\n * function for all plugins that provided it. It then waits for all\n * running plugin threads to exit.\n *\n * @note under certain circumstances, `stop()` may overlap execution\n *       with `start()`, or even be called before `start()`.\n *\n *\n *\n * ### 6. Deinitialization ###\n * After all threads have stopped, regardless of whether they stopped\n * with an error or not, the plugins are deinitialized in reverse order\n * of initialization by calling the function in the `deinit` field of\n * the `Plugin` structure. Regardless of whether the `deinit()` functions\n * return an error or not, all plugins schedulled for deinitialisation\n * will be deinitialized.\n *\n * @note for any `init()` functions that failed, `deinit()` functions\n *       will not run.\n * @note plugins may have a `deinit()` function despite not having a\n *       corresponding `init()`. In such cases, the missing `init()` is\n *       treated as if it existed and ran successfully.\n *\n *\n *\n * ### 7. Unloading ###\n * After a plugin has deinitialized, it can be unloaded. It is\n * guaranteed that no module is unloaded before it has been\n * deinitialized.\n *\n * @note This step is currently unimplemented - meaning, it does nothing.\n *       The plugins will remain loaded in memory until the process shuts\n *       down. This makes no practical difference on application behavior\n *       at present, but might be needed if Harness gained ability to\n *       reload plugins in the future.\n\n## Behavior Diagrams\n\nPrevious section described quickly each step of the life-cycle process. In this\nsection, two flow charts are presented which show the operation of all seven\nsteps. First shows a high-level overview, and the second shows all 7 life-cycle\nsteps in more detail. Discussion of details follows in the following sections.\n\nSome points to keep in mind while viewing the diagrams:\n\n- diagrams describe code behavior rather than implementation. So for example:\n  - pseudocode does not directly correspond 1:1 to real code. However, it\n    behaves exactly like the real code.\n\n- seven life-cycle functions shown are actual functions (@c Loader's methods,\n  to be more precise)\n  - load_all(), init_all(), start_all(), main_loop(), stop_all(), deinit_all()\n    are implemented functions (first 6 steps of life-cycle)\n  - unload_all() is the 7th step of life-cycle, but it's currently unimplemented\n\n- when plugin functions exit with error, they do so by calling\n  set_error() before exiting\n\n- some things are not shown to keep the diagram simple:\n  - first error returned by any of the 7 life-cycle functions is\n    saved and passed at the end of life-cycle flow to the calling code\n\n\n### Overview\n\n@verbatim\n\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n\\                                                                              \\\n\\   START                                                                      \\\n\\     |                                                                        \\\n\\     |                                                                        \\\n\\     |                                                                        \\\n\\     V                                                                        \\\n\\   [load_all()]                                                               \\\n\\     |                                                                        \\\n\\     V                                                                        \\\n\\   <LOAD_OK?>                                                                 \\\n\\     |   |                                                                    \\\n\\ +---N   Y                                                                    \\\n\\ |       |                                                                    \\\n\\ |       v                                                                    \\\n\\ | [init_all()]                                                               \\\n\\ |   |                                                                        \\\n\\ |   v                                                                        \\\n\\ | <INIT_OK?>                                         (  each plugin runs  )  \\\n\\ |   |   |                                            (in a separate thread)  \\\n\\ |   N   Y                                                                    \\\n\\ |   |   |                                             [plugin[1]->start()]   \\\n\\ |   |   v             start plugin threads            [plugin[2]->start()]   \\\n\\ |   | [start_all()] - - - - - - - - - - - - - - - - ->[    ..      ..    ]   \\\n\\ |   |   |                                             [    ..      ..    ]   \\\n\\ |   |   |  + - - - - - - - - - - - - - - - - - - - - -[plugin[n]->start()]   \\\n\\ |   |   |            notification when each                     ^            \\\n\\ |   |   |  |           thread terminates                                     \\\n\\ |   |   |                                                       |            \\\n\\ |   |   |  |                                                     stop plugin \\\n\\ |   |   |                                                       |  threads   \\\n\\ |   |   |  |                                                                 \\\n\\ |   |   |                                                       |            \\\n\\ |   |   v  v                                                                 \\\n\\ |   | [main_loop()]= call ==>[stop_all()] - - - - - - - - - - - +            \\\n\\ |   |   |                                                                    \\\n\\ |   |   |        \\                                                           \\\n\\ |   *<--+         \\                                                          \\\n\\ |   |              \\__ waits for all plugin                                  \\\n\\ |   v                  threads to terminate                                  \\\n\\ | [deinit_all()]                                                             \\\n\\ |   |                                                                        \\\n\\ |   v                                                                        \\\n\\ +-->*                                                                        \\\n\\     |                                                                        \\\n\\     v                                                                        \\\n\\   [unload_all()]                                                             \\\n\\     |                                                                        \\\n\\     |         \\                                                              \\\n\\     |          \\                                                             \\\n\\     v           \\__ currently not implemented                                \\\n\\    END                                                                       \\\n\\                                                                              \\\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n\n@endverbatim\n\n\n### Detailed View\n\n@verbatim\n\n            START\n              |\n              |\n              v\n\\\\\\\\ load_all() \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n\\                                    \\\n\\  LOAD_OK = true                    \\\n\\  foreach plugin:                   \\\n\\    load plugin                     \\\n\\    if (exit_status != ok):         \\\n\\      LOAD_OK = false               \\\n\\      break loop                    \\\n\\                                    \\\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n              |\n              |\n              v\n            <LOAD_OK?>\n              |   |\n              Y   N----> unload_all() (see further down)\n              |\n              |\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\|\\\\\\ init_all() \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n\\             |                               \\\n\\             v                               \\\n\\           [INIT_OK = true, i = 1]           \\\n\\             |                               \\\n\\             v                               \\\n\\     +----><plugin[i] exists?>               \\\n\\     |       |   |                           \\\n\\   [i++]     Y   N---------------------+     \\\n\\     ^       |                         |     \\\n\\     |       |                         |     \\\n\\     |       v                         |     \\\n\\     |     <plugin[i] has init()?>     |     \\\n\\     |       |   |                     |     \\\n\\     |       N   Y---+                 |     \\\n\\     |       |       |                 |     \\\n\\     |       |       |                 |     \\\n\\     |       |       v                 |     \\\n\\     |       |     [plugin[i]->init()] |     \\\n\\     |       |       |                 |     \\\n\\     |       |       |                 |     \\\n\\     |       |       |                 |     \\\n\\     |       |       |                 |     \\\n\\     |       |       v                 |     \\\n\\     |       |     <exit ok?>          |     \\\n\\     |       v       |   |             |     \\\n\\     +-------*<------Y   N             |     \\\n\\                         |             |     \\\n\\                         |             |     \\\n\\                         v             |     \\\n\\                   [INIT_OK = false]   |     \\\n\\                     |                 |     \\\n\\                     v                 |     \\\n\\                     *<----------------+     \\\n\\                     |                       \\\n\\                     v                       \\\n\\                   [LAST_PLUGIN = i-1]       \\\n\\                     |                       \\\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n                      |\n                      |\n                      v\n                    <INIT_OK?>\n                      |   |\n                      Y   N----> deinit_all() (see further down)\n                      |\n                      |\n                      v\n\\\\\\\\ start_all() \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n\\                                        \\\n\\   for i = 1 to LAST_PLUGIN:            \\\n\\     if plugin[i] has start():          \\  start start() in new thread\n\\       new thread(plugin[i]->start()) - - - - - - - - - - - - - - - - +\n\\                                        \\\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\                             |\n                      |\n                      |                                                |\n    +-----------------+\n    |                                                                  |\n\\\\\\\\|\\\\\\ main_loop() \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\n    |                                                                  |       \\\n    v                                                                          \\\n+-->*                                                                  |       \\\n|   |                                                                          \\\n|   v                                                                  |       \\\n| <any plugin threads running?>                                                \\\n|   |   |                                                              |       \\\n|   N   Y---+                                                                  \\\n|   |       |                                                          |       \\\n|   |     <shutdown signal received && stop_all() not called yet?>             \\\n|   |       |   |                                                      |       \\\n|   |       N   Y                                                              \\\n|   |       |    == call ==>[stop_all()]- - - - - - - - - - - - - +    |       \\\n|   |       |   |                     tell (each) start() to exit              \\\n|   |       *<--+                                                 |    |       \\\n|   |       |                                                                  \\\n|   |       |                                                     v    v       \\\n|   |       |                                             [plugin[1]->start()] \\\n|   |       v                 (one) plugin thread exits   [plugin[2]->start()] \\\n|   |     [wait for (any)]<- - - - - - - - - - - - - - - -[    ..      ..    ] \\\n|   |     [ thread exit  ]                                [    ..      ..    ] \\\n|   |       |                                             [plugin[n]->start()] \\\n|   |       |                                                     ^            \\\n|   |       |                                                                  \\\n|   |       v                                                     |            \\\n|   |     <thread exit ok?>                                                    \\\n|   |       |   |                                                 |            \\\n|   |       Y   N---+                                                          \\\n|   |       |       |                                             |            \\\n|   |       |       v                                                          \\\n|   |       |     <stop_all() called already?>                    |            \\\n|   |       v       |   |                                                      \\\n|   |       *<------Y   N                                    tell (each)       \\\n|   |       |            = call ==+                        start() to exit     \\\n|   |       |           |         |                               |            \\\n|   |       v           |         |                                            \\\n+---|-------*<----------+         *==>[stop_all()]- - - - - - - - +            \\\n    |                             |                                            \\\n    |                             |        |                                   \\\n    v                             |        |                                   \\\n  <stop_all() called already?>    |        |                                   \\\n    |   |                         |        |                                   \\\n    Y   N                         |        |                                   \\\n    |    == call =================+        |                                   \\\n    |   |                                  |                                   \\\n    *---+                                  |                                   \\\n    |                                      |                                   \\\n\\\\\\\\|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n    |                                      |\n    |                                      |\n    v                                      |\n    *<---- init_all() (if !INIT_OK)        |\n    |                                      |\n    |                                      |\n    v                                      |\n\\\\\\\\ deinit_all() \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\     |\n\\                                    \\     |\n\\  for i = LAST_PLUGIN to 1:         \\     |\n\\    if plugin[i] has deinit():      \\     |\n\\      plugin[i]->deinit()           \\     |\n\\      if (exit_status != ok):       \\     |\n\\        # ignore error              \\     |\n\\                                    \\     |\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\     |\n    |                                      |\n    |                                      |\n    v                                      |\n    *<---- load_all() (if !LOAD_OK)        |\n    |                                      |\n    v                                      |\n\\\\\\\\ unload_all() \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\     |\n\\                                    \\     |\n\\  no-op (currently unimplemented)   \\     |\n\\                                    \\     |\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\     |\n    |                                      |\n    |                                      |\n    v                                      /\n   END                                    /\n                                         /\n                                        /\n                                       /                  (  each plugin runs  )\n                                      /                   (in a separate thread)\n\\\\\\\\ stop_all() \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\  run_flag == false\n\\                                    \\    tells start()    [plugin[1]->start()]\n\\  for i = 1 to LAST_PLUGIN:         \\      to exit        [plugin[2]->start()]\n\\    run_flag[i] = false - - - - - - - - - - - - - - - - ->[    ..      ..    ]\n\\    if plugin[i] has stop():        \\                     [    ..      ..    ]\n\\      plugin[i]->stop()             \\                     [    ..      ..    ]\n\\      if (exit_status != ok):       \\                     [plugin[n]->start()]\n\\        # ignore error              \\\n\\                                    \\\n\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\n\n@endverbatim\n\n\n\n\n## Discussion\n\n### Persistence (definition)\n\nBefore continuing, we need to define the word \"persist\", used later on. When we\nsay \"persist\", we'll mean the opposite of \"exit\". So when we say a function or\na thread persists, it means that it's not returning/exiting, but instead is\nrunning some forever-loop or is blocked on something, etc. What it's doing\nexactly doesn't matter, what matters, is that it hasn't terminated but\n\"lives on\" (in case of a function, to \"persist\" means the same as to \"block\",\nbut for threads that might sound confusing, this is why we need a new word).\nSo when we call start() in a new thread, it will either run and keep running\n(thread will persist), or it will run briefly and return (thread will exit).\nIn short, \"to persist\" means the opposite of \"to finish running and exit\".\n\n### Plugin API functions\n\nEach plugin can define none, any or all of the following 4 callbacks.\nThey're function pointers, that can be null if not implemented. They're\ntypically called in the order as listed below (under certain circumstances,\nstop() may overlap execution with start(), or even be called before start()).\n\n- init()    -- called inside of main thread\n- start()   -- main thread creates a new thread, then calls this\n- stop()    -- called inside of main thread\n- deinit()  -- called inside of main thread\n\n### Starting and Stopping: Start() ###\n\nIt is typical to implement start function in such a way that it will\n\"persist\" (i.e. it will run some forever-loop processing requests\nrather than exit briefly after being called). In such case, Harness\nmust have a way to terminate it during shutdown operation.\n\nFor this purpose, Harness exposes a boolean \"running\" flag to each plugin, which\nserves as means to communicate the need to shutdown; it is read by `is_running()`\nfunction. This function should be routinely polled by plugin's `start()`\nfunction to determine if it should shut down, and once it returns false,\nplugin `start()` should terminate as soon as possible. Failure to terminate\nwill block Harness from progressing further in its shutdown procedure,\nresulting in application \"hanging\" during shutdown. Typically, `start()`\nwould be implemented more-or-less like so:\n\n    void start()\n    {\n      // run-once code\n\n      while (is_running())\n      {\n        // forever-loop code\n      }\n\n      // clean-up code\n    }\n\nThere is also an alternative blocking function available, `wait_for_stop()`,\nshould that be better suited for the particular plugin design. Instead of\nquickly returning a boolean flag, it will block (with an optional timeout)\nuntil Harness flags to shut down this plugin. It is an efficient functional\nequivalent of:\n\n    while (is_running())\n    {\n      // sleep a little or break on timeout\n    }\n\nWhen entering shutdown phase, Harness will notify all plugins to shut down\nvia mechanisms described above. It is also permitted for plugins to exit on\ntheir own, whether due to error or intended behavior, without consulting\nthis \"running\" flag. Polling the \"running\" flag is only needed when `start()`\n\"persists\" and does not normally exit until told to do so.\n\nAlso, in some designs, `start()` function might find it convenient to be able to\nset the \"running\" flag to false, in order to trigger its own shutdown in another\npiece of code. For such cases, `clear_running()` function is provided, which\nwill do exactly that.\n\nIMPORTANT! Please note that all 3 functions described above (`is_running()`,\n`wait_for_stop()` and `clear_running()`) can only be called from a thread\nrunning `start()` function. If `start()` spawns more theads, these\nfunctions CANNOT be called from them. These functions also cannot be called\nfrom the other three plugin functions (`init()`, `stop()` and `deinit()`).\n\n### Starting and Stopping: Stop() ###\n\nDuring shutdown, or after plugin `start()` function exits (whichever comes\nfirst), plugin's `stop()` function will be called, if defined.\n\nIMPORTANT: `start()` function runs in a different thread than `stop()`\nfunction. By the time `stop()` runs, depending on the circumstances,\n`start()` thread may or may not exist.\n\nIMPORTANT: `stop()` will always be called during shutdown, regardless of whether\nstart() exited with error, exited successfully or is still running.  `stop()`\nmust be able to deal with all 3 scenarios. The rationale for this design\ndecision is given Error Handling section.\n\n\n\n### Persistence in Plugin Functions ###\n\nWhile start() may persist, the other three functions (init(), stop() and\ndeinit()) must obviously not persist, since they run in the main thread.\nAny blocking behavior exhibited in these functions (caused by a bug or\notherwise) will cause the entire application to hang, as will start() that\ndoes not poll and/or honor is_running() flag.\n\n\n\n### Returning Success/Failure from Plugin Function ###\n\nHarness expects all four plugin functions (`init(), `start()`, `stop()` and\n`deinit()`) to notify it in case of an error. This is done via function:\n\n    set_error(PluginFuncEnv* env, ErrorType error, const char* format, ...);\n\nCalling this function flags that the function has failed, and passes the\nerror type and string back to Harness. The converse is also true: not\ncalling this function prior to exiting the function implies success.\nThis distinction is important, because Harness may take certain actions\nbased on the status returned by each function.\n\nIMPORTANT! Throwing exceptions from these functions is not supported.\nIf your plugin uses exceptions internally, that is fine, but please\nensure they are handled before reaching the Harness-Plugin boundary.\n\n\n### Threading Concerns ###\n\nFor each plugin (independent of other plugins):\nOf the 4 plugin functions, `init()` runs first. It is guaranteed that\nit will exit before `start()` and `stop()` are called. `start()` and\n`stop()` can be called in parallel to each other, in any order, with\ntheir lifetimes possibly overlapping. They are guaranteed to both have\nexited before `deinit()` is called.\n\nIf any of the 4 plugin functions spawn any additional threads, Harness\nmakes no provisions for interacting with them in any way: calling\nHarness functions from them is not supported in particular; also such\nthreads should exit before their parent function finishes running.\n\n\n\n### Error Handling ###\n\nNOTE: WL#9558 HLD version of this section additionally discusses design,\n      rationale for the approach chosen, etc; look there if interested.\n\nWhen plugin functions enounter an error, they are expected to signal it via\nset_error(). What happens next, depends on the case, but in all four\ncases the error will be logged automatically by the harness. Also, the first\nerror passed from any plugin will be saved until the end of life-cycle processing,\nthen passed down to the code calling the harness. This will allow the application\ncode to deal with it accordingly (probably do some of its own cleaning and shut\ndown, but that's up to the application). In general, the first error from init()\nor start() will cause the harness to initiate shut down procedure, while the\nerrors from stop() and deinit() will be ignored completely (except of course for\nbeing logged and possibly saved for passing on at the end).\nActions taken for each plugin function are as follows:\n\n\n\n#### init() fails:\n\n  - skip init() for remaining plugins\n\n  - don't run any start() and stop() (proceed directly to deinitialisation)\n\n  - run deinit() only for plugins initialiased so far (excluding the failing\n    one), in reverse order of initialisation, and exit\n\n  - when init() is not provided (is null), it counts as if it ran, if it would\n    have run before the failing plugin (according to topological order)\n\n\n\n#### start() fails:\n\n  - proceed to stop all plugins, then deinit() all in reverse order of\n    initialisation and exit. Please note that ALL plugins will be flagged\n    to stop and have their stop() function called (not just the ones that\n    succeeded in starting - plugin's stop() must be able to deal with such\n    a situation)\n\n\n\n#### stop() or deinit() fails:\n\n  - log error and ignore, proceed as if it didn't happen\n\n*/\n\n#ifndef MYSQL_HARNESS_LOADER_INCLUDED\n#define MYSQL_HARNESS_LOADER_INCLUDED\n\n#include \"router_config.h\"\n\n#include \"config_parser.h\"\n#include \"filesystem.h\"\n#include \"mysql/harness/loader_config.h\"\n#include \"mysql/harness/plugin.h\"\n\n#include \"harness_export.h\"\n\n#include <csignal>\n#include <cstdarg>  // va_list\n#include <exception>\n#include <future>\n#include <istream>\n#include <list>\n#include <map>\n#include <queue>\n#include <set>\n#include <string>\n#include <thread>\n#include <tuple>\n\n#ifdef FRIEND_TEST\n  // TODO replace by #include after merge:\n  // #include \"../../../mysqlrouter/utils.h\"  // DECLARE_TEST\n  /** @brief Declare test (class)\n   *\n   * When using FRIEND_TEST() on classes that are not in the same namespace\n   * as the test, the test (class) needs to be forward-declared. This marco\n   * eases this.\n   *\n   * @note We need this for unit tests, BUT on the TESTED code side (not in unit test code)\n   */\n  #define DECLARE_TEST(test_case_name, test_name)\\\n    class test_case_name##_##test_name##_Test\n\n  class TestLoader;\n  class LifecycleTest;\n\n  DECLARE_TEST(TestStart, StartLogger);\n  DECLARE_TEST(LifecycleTest, Simple_None);\n  DECLARE_TEST(LifecycleTest, Simple_AllFunctions);\n  DECLARE_TEST(LifecycleTest, Simple_Init);\n  DECLARE_TEST(LifecycleTest, Simple_StartStop);\n  DECLARE_TEST(LifecycleTest, Simple_StartStopBlocking);\n  DECLARE_TEST(LifecycleTest, Simple_Start);\n  DECLARE_TEST(LifecycleTest, Simple_Stop);\n  DECLARE_TEST(LifecycleTest, Simple_Deinit);\n  DECLARE_TEST(LifecycleTest, ThreeInstances_NoError);\n  DECLARE_TEST(LifecycleTest, BothLifecycles_NoError);\n  DECLARE_TEST(LifecycleTest, OneInstance_NothingPersists_NoError);\n  DECLARE_TEST(LifecycleTest, OneInstance_NothingPersists_StopFails);\n  DECLARE_TEST(LifecycleTest, ThreeInstances_InitFails);\n  DECLARE_TEST(LifecycleTest, BothLifecycles_InitFails);\n  DECLARE_TEST(LifecycleTest, ThreeInstances_Start1Fails);\n  DECLARE_TEST(LifecycleTest, ThreeInstances_Start2Fails);\n  DECLARE_TEST(LifecycleTest, ThreeInstances_Start3Fails);\n  DECLARE_TEST(LifecycleTest, ThreeInstances_2StartsFail);\n  DECLARE_TEST(LifecycleTest, ThreeInstances_StopFails);\n  DECLARE_TEST(LifecycleTest, ThreeInstances_DeinintFails);\n  DECLARE_TEST(LifecycleTest, ThreeInstances_StartStopDeinitFail);\n  DECLARE_TEST(LifecycleTest, NoInstances);\n  DECLARE_TEST(LifecycleTest, EmptyErrorMessage);\n  DECLARE_TEST(LifecycleTest, send_signals);\n  DECLARE_TEST(LifecycleTest, send_signals2);\n  DECLARE_TEST(LifecycleTest, wait_for_stop);\n  DECLARE_TEST(LifecycleTest, InitThrows);\n  DECLARE_TEST(LifecycleTest, StartThrows);\n  DECLARE_TEST(LifecycleTest, StopThrows);\n  DECLARE_TEST(LifecycleTest, DeinitThrows);\n  DECLARE_TEST(LifecycleTest, InitThrowsWeird);\n  DECLARE_TEST(LifecycleTest, StartThrowsWeird);\n  DECLARE_TEST(LifecycleTest, StopThrowsWeird);\n  DECLARE_TEST(LifecycleTest, DeinitThrowsWeird);\n  DECLARE_TEST(LoaderReadTest, Loading);\n#endif\n\nnamespace mysql_harness {\n\nstruct Plugin;\nclass Path;\n\n/**\n * PluginFuncEnv object\n *\n * This object is the basis of all communication between Harness and plugin\n * functions. It is passed to plugin functions (as an opaque pointer), and\n * plugin functions return it back to Harness when calling Harness API\n * functions. It has several functions:\n *\n * - maintains a \"running\" flag, which controls starting/stopping\n *   of plugins\n *\n * - conveys exit status back to Harness after each plugin function exits\n *\n * - conveys more information (AppInfo, ConfigSection, ...) to\n *   plugin functions. Note that not all fields are set for all functions -\n *   setting ConfigSection ptr when calling init() makes no sense, for example\n *\n * @note Below we only briefly document the methods. For more information, see\n * Harness API documentation for their corresponding free-function proxies\n * in plugin.h\n */\nclass HARNESS_EXPORT PluginFuncEnv {\n public:\n\n  /**\n   * Constructor\n   *\n   * @param info AppInfo to pass to plugin function. Can be NULL.\n   * Pointer is owned by the caller and must outlive plugin function call.\n   * @param section ConfigSection to pass to plugin function. Can be NULL.\n   * Pointer is owned by the caller and must outlive plugin function call.\n   * @param running Set \"running\" flag. true = plugin should be running\n   */\n  PluginFuncEnv(const AppInfo* info, const ConfigSection* section, bool running = false);\n\n  // further info getters\n  // (see also corresponding Harness API functions in plugin.h for more info)\n  const ConfigSection* get_config_section() const noexcept;\n  const AppInfo* get_app_info() const noexcept;\n\n  // running flag\n  // (see also corresponding Harness API functions in plugin.h for more info)\n  void set_running() noexcept;\n  void clear_running() noexcept;\n  bool is_running() const noexcept;\n  bool wait_for_stop(uint32_t milliseconds) const noexcept; // 0 = infinite wait\n\n  // error handling\n  // (see also corresponding Harness API functions in plugin.h for more info)\n  bool exit_ok() const noexcept;\n  void set_error(ErrorType error_type, const char* fmt, va_list ap) noexcept\n#ifdef HAVE_ATTRIBUTE_FORMAT\n    __attribute__((format(printf, 3, 0)))\n#endif\n    ;\n  std::tuple<std::string, std::exception_ptr> pop_error() noexcept;\n\n private:\n  const AppInfo* app_info_;             // \\.\n  const ConfigSection* config_section_; //  > initialized in ctor\n  bool running_;                        // /\n  std::string error_message_;\n  ErrorType error_type_ = kNoError;\n\n  mutable std::condition_variable cond_;\n  mutable std::mutex mutex_;\n};\n\n\nclass HARNESS_EXPORT Loader {\n public:\n  /**\n   * Constructor for Loader.\n   *\n   * @param program Name of our program\n   * @param config Router configuration\n   */\n  Loader(const std::string& program, LoaderConfig& config)\n      : config_(config), program_(program) {}\n\n  Loader(const Loader&) = delete;\n  Loader& operator=(const Loader&) = delete;\n\n  /**\n   * Destructor.\n   *\n   * The destructor will call dlclose() on all unclosed shared\n   * libraries.\n   */\n\n  ~Loader();\n\n  /**\n   * Fetch available plugins.\n   *\n   * @return List of names of available plugins.\n   */\n\n  std::list<Config::SectionKey> available() const;\n\n  /**\n   * Initialize and start all loaded plugins.\n   *\n   * All registered plugins will be initialized in proper order and\n   * started (if they have a `start` callback).\n   *\n   * @throws first exception that was triggered by an error returned from any\n   * plugin function.\n   */\n  void start();\n\n  /**\n   * Get reference to configuration object.\n   *\n   * @note In production code we initialize Loader with LoaderConfig\n   * reference maintained by DIM, so this method will return this object.\n   */\n  LoaderConfig &get_config() { return config_; }\n\n private:\n  enum class Status {\n    UNVISITED,\n    ONGOING,\n    VISITED\n  };\n\n  /**\n   * Flags progress of Loader. The progress always proceeds from top to bottom\n   * order in this list.\n   */\n  enum class Stage {\n    // NOTE: do not alter order of these enums!\n    Unset,\n    Loading,\n    Initializing,\n    Starting,\n    Running,\n    Stopping,\n    Deinitializing,\n    Unloading,\n  };\n\n  void platform_specific_init();\n\n  /**\n   * Load the named plugin from a specific library.\n   *\n   * @param plugin_name Name of the plugin to be loaded.\n   *\n   * @param library_name Name of the library the plugin should be\n   * loaded from.\n   *\n   * @throws bad_plugin (std::runtime_error) on load error\n   */\n  Plugin *load_from(const std::string& plugin_name,\n                    const std::string& library_name);\n\n  Plugin *load(const std::string& plugin_name);\n\n  /**\n   * Load the named plugin and all dependent plugins.\n   *\n   * @param plugin_name Name of the plugin to be loaded.\n   * @param key Key of the plugin to be loaded.\n   *\n   * @throws bad_plugin (std::runtime_error) on load error\n   * @throws bad_section (std::runtime_error) when section 'plugin_name' is not\n   * present in configuration\n   *\n   * @post After the execution of this procedure, the plugin and all\n   * plugins required by that plugin will be loaded.\n   */\n  /** @overload */\n  Plugin *load(const std::string& plugin_name, const std::string& key);\n\n  // IMPORTANT design note: start_all() will block until PluginFuncEnv objects\n  // have been created for all plugins. This guarantees that the required\n  // PluginFuncEnv will always exist when plugin stop() function is called.\n\n  // start() calls these, indents reflect call hierarchy\n  void               load_all();     // throws bad_plugin on load error\n  void                 setup_info();\n  std::exception_ptr run();          // returns first exception returned from below harness functions\n  std::exception_ptr   init_all();   // returns first exception triggered by init()\n  void                 start_all();  // forwards first exception triggered by start() to main_loop()\n  std::exception_ptr   main_loop();  // returns first exception triggered by start() or stop()\n  std::exception_ptr     stop_all(); // returns first exception triggered by stop()\n  std::exception_ptr   deinit_all(); // returns first exception triggered by deinit()\n  void               unload_all();\n\n  /**\n   * Topological sort of all plugins and their dependencies.\n   *\n   * Will create a list of plugins in topological order from \"top\"\n   * to \"bottom\".\n   */\n  bool topsort();\n  bool visit(const std::string& name, std::map<std::string, Status>* seen,\n             std::list<std::string>* order);\n\n  /**\n   * Holds plugin's API call information\n   *\n   * @note There's 1 instance per plugin type (not plugin instance)\n   */\n  class HARNESS_EXPORT PluginInfo {\n   public:\n    PluginInfo(const std::string& folder, const std::string& library); // throws bad_plugin\n    PluginInfo(const PluginInfo&) = delete;\n    PluginInfo(PluginInfo&&);\n    PluginInfo(void* h, Plugin* ext) : handle(h), plugin(ext) {}\n    ~PluginInfo();\n\n    void load_plugin(const std::string& name);  // throws bad_plugin\n\n    /**\n     * Pointer to plugin structure.\n     *\n     * @note This pointer can be null, so remember to check it before\n     * using it.\n     *\n     * @todo Make this member private to avoid exposing the internal\n     * state.\n     */\n    void *handle;\n    Plugin *plugin;\n\n\n   private:\n    class Impl;\n    Impl* impl_;\n  };\n\n  using PluginMap = std::map<std::string, PluginInfo>;\n  using SessionList = std::vector<std::future<std::exception_ptr>>;\n\n  // Init order is important, so keep config_ first.\n\n  /**\n   * Configuration sections for all plugins.\n   */\n  LoaderConfig& config_;\n\n  /**\n   * Map of all successfully-loaded plugins (without key name).\n   */\n  PluginMap plugins_;\n\n  /**\n   * Map of all {plugin instance -> plugin start() PluginFuncEnv} objects. Initially\n   * these objects are created in Loader::start_all() and then kept around\n   * until the end of Loader::stop_all().\n   * At the time of writing, PluginFuncEnv objects for remaining plugin functions\n   * (init(), stop() and deinit()) are not required to live beyond their\n   * respective functions calls, and are therefore created on stack (automatic\n   * variables) as needed during those calls.\n   */\n  std::map<const ConfigSection*, std::shared_ptr<PluginFuncEnv>> plugin_start_env_;\n\n  /**\n   * List of all active session.\n   */\n  SessionList sessions_;\n\n  /**\n   * Initialization order.\n   */\n  std::list<std::string> order_;\n\n  std::string logging_folder_;\n  std::string plugin_folder_;\n  std::string runtime_folder_;\n  std::string config_folder_;\n  std::string data_folder_;\n  std::string program_;\n  AppInfo appinfo_;\n\n#ifdef FRIEND_TEST\n  friend class ::TestLoader;\n  friend class ::LifecycleTest;\n\n  FRIEND_TEST(::TestStart, StartLogger);\n  FRIEND_TEST(::LifecycleTest, Simple_None);\n  FRIEND_TEST(::LifecycleTest, Simple_AllFunctions);\n  FRIEND_TEST(::LifecycleTest, Simple_Init);\n  FRIEND_TEST(::LifecycleTest, Simple_StartStop);\n  FRIEND_TEST(::LifecycleTest, Simple_StartStopBlocking);\n  FRIEND_TEST(::LifecycleTest, Simple_Start);\n  FRIEND_TEST(::LifecycleTest, Simple_Stop);\n  FRIEND_TEST(::LifecycleTest, Simple_Deinit);\n  FRIEND_TEST(::LifecycleTest, ThreeInstances_NoError);\n  FRIEND_TEST(::LifecycleTest, BothLifecycles_NoError);\n  FRIEND_TEST(::LifecycleTest, OneInstance_NothingPersists_NoError);\n  FRIEND_TEST(::LifecycleTest, OneInstance_NothingPersists_StopFails);\n  FRIEND_TEST(::LifecycleTest, ThreeInstances_InitFails);\n  FRIEND_TEST(::LifecycleTest, BothLifecycles_InitFails);\n  FRIEND_TEST(::LifecycleTest, ThreeInstances_Start1Fails);\n  FRIEND_TEST(::LifecycleTest, ThreeInstances_Start2Fails);\n  FRIEND_TEST(::LifecycleTest, ThreeInstances_Start3Fails);\n  FRIEND_TEST(::LifecycleTest, ThreeInstances_2StartsFail);\n  FRIEND_TEST(::LifecycleTest, ThreeInstances_StopFails);\n  FRIEND_TEST(::LifecycleTest, ThreeInstances_DeinintFails);\n  FRIEND_TEST(::LifecycleTest, ThreeInstances_StartStopDeinitFail);\n  FRIEND_TEST(::LifecycleTest, NoInstances);\n  FRIEND_TEST(::LifecycleTest, EmptyErrorMessage);\n  FRIEND_TEST(::LifecycleTest, send_signals);\n  FRIEND_TEST(::LifecycleTest, send_signals2);\n  FRIEND_TEST(::LifecycleTest, wait_for_stop);\n  FRIEND_TEST(::LifecycleTest, InitThrows);\n  FRIEND_TEST(::LifecycleTest, StartThrows);\n  FRIEND_TEST(::LifecycleTest, StopThrows);\n  FRIEND_TEST(::LifecycleTest, DeinitThrows);\n  FRIEND_TEST(::LifecycleTest, InitThrowsWeird);\n  FRIEND_TEST(::LifecycleTest, StartThrowsWeird);\n  FRIEND_TEST(::LifecycleTest, StopThrowsWeird);\n  FRIEND_TEST(::LifecycleTest, DeinitThrowsWeird);\n  FRIEND_TEST(::LoaderReadTest, Loading);\n#endif\n\n};  // class Loader\n\n} // namespace mysql_harness\n\nHARNESS_EXPORT\nvoid request_application_shutdown();\n\n#ifdef FRIEND_TEST\nnamespace unittest_backdoor {\n  HARNESS_EXPORT\n  void set_shutdown_pending(bool shutdown_pending);\n}\n#endif\n\n#endif /* MYSQL_HARNESS_LOADER_INCLUDED */\n"
  },
  {
    "path": "src/harness/include/mysql/harness/loader_config.h",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_LOADER_CONFIG_INCLUDED\n#define MYSQL_HARNESS_LOADER_CONFIG_INCLUDED\n\n#include \"config_parser.h\"\n#include \"harness_export.h\"\n\nnamespace mysql_harness {\n\nclass Path;\n\n/**\n * Configuration file handler for the loader.\n *\n * @ingroup ConfigParser\n *\n * Specialized version of the config file read that does some extra\n * checks after reading the configuration file.\n */\nclass HARNESS_EXPORT LoaderConfig : public Config {\n public:\n  using Config::Config;\n\n  /**\n   * Fill and check the configuration.\n   *\n   * This function will fill in default values for any options that\n   * should have default values and check all sections to make sure\n   * that they have valid values.\n   *\n   * @exception bad_section Thrown if the configuration is not correct.\n   */\n  void fill_and_check();\n\n  /**\n   * Read a configuration entry.\n   *\n   * This will read one configuration entry and incorporate it into\n   * the configuration. The entry can be either a directory or a file.\n   *\n   * This function allows reading multiple configuration entries and\n   * can be used to load paths of configurations. An example of how it\n   * could be used is:\n   *\n   * @code\n   * LoaderConfig config;\n   * for (auto&& entry: my_path)\n   *    config.read(entry);\n   * @endcode\n   *\n   * @param path Path to configuration entry to read.\n   * @throws std::invalid_argument, std::runtime_error, syntax_error, ...\n   */\n  void read(const Path& path);\n\n  /**\n   * Return true if we are logging to a file, false if we are logging\n   * to console instead.\n   */\n  bool logging_to_file() const;\n\n  /**\n   * Return log filename.\n   *\n   * @throws std::invalid_argument if not logging to file\n   */\n  Path get_log_file() const;\n};\n\n} // namespace mysql_harness\n\n#endif // MYSQL_HARNESS_LOADER_CONFIG_INCLUDED\n"
  },
  {
    "path": "src/harness/include/mysql/harness/logging/handler.h",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_LOGGER_HANDLER_INCLUDED\n#define MYSQL_HARNESS_LOGGER_HANDLER_INCLUDED\n\n#include \"mysql/harness/logging/logging.h\"\n#include \"harness_export.h\"\n\n#include <iostream>\n#include <fstream>\n#include <mutex>\n#include <string>\n\nnamespace mysql_harness {\n\nnamespace logging {\n\n/**\n * Base class for log message handler.\n *\n * This class is used to implement a log message handler. You need\n * to implement the `do_log` primitive to process the log\n * record. If, for some reason, the implementation is unable to log\n * the record, and exception can be thrown that will be caught by\n * the harness.\n */\nclass HARNESS_EXPORT Handler {\n public:\n  /**\n   * Default identifier\n   *\n   * Every handler provides a default name which could be used as key in\n   * registry to uniquely identify it. There is no obligation to use it, it\n   * is only supplied for convenience. In case of many instances of the same\n   * handler, using a key derived from this default (such as\n   * \"my_handler:instance1\") is suggested.\n   *\n   * This field should be set in derived classes\n   */\n  static constexpr const char* kDefaultName = nullptr;\n\n  virtual ~Handler() = default;\n\n  void handle(const Record& record);\n\n  void set_level(LogLevel level) { level_ = level; }\n  LogLevel get_level() const { return level_; }\n\n protected:\n  std::string format(const Record& record) const;\n\n  explicit Handler(bool format_messages, LogLevel level);\n\n private:\n  /**\n   * Log message handler primitive.\n   *\n   * This member function is implemented by subclasses to properly log\n   * a record wherever it need to be logged.  If it is not possible to\n   * log the message properly, an exception should be thrown and will\n   * be caught by the caller.\n   *\n   * @param record Record containing information about the message.\n   */\n  virtual void do_log(const Record& record) = 0;\n\n  /**\n   * Flags if log messages should be formatted (prefixed with log level,\n   * timestamp, etc) before logging.\n   */\n  bool format_messages_;\n\n  /**\n   * Log level set for the handler.\n   */\n  LogLevel level_;\n};\n\n/**\n * Handler to write to an output stream.\n *\n * @code\n * Logger logger(\"my_module\");\n * ...\n * logger.add_handler(StreamHandler(std::clog));\n * @endcode\n */\nclass HARNESS_EXPORT StreamHandler : public Handler {\n public:\n  static constexpr const char* kDefaultName = \"stream\";\n\n  explicit StreamHandler(std::ostream& stream,\n                         bool format_messages = true,\n                         LogLevel level = LogLevel::kNotSet);\n\n protected:\n  std::ostream& stream_;\n  std::mutex stream_mutex_;\n\n private:\n  void do_log(const Record& record) override;\n};\n\n/**\n * Handler that writes to a file.\n *\n * @code\n * Logger logger(\"my_module\");\n * ...\n * logger.add_handler(FileHandler(\"/var/log/router.log\"));\n * @endcode\n */\nclass HARNESS_EXPORT FileHandler : public StreamHandler {\n public:\n  static constexpr const char* kDefaultName = \"file\";\n\n  explicit FileHandler(const Path& path,\n                       bool format_messages = true,\n                       LogLevel level = LogLevel::kNotSet);\n  ~FileHandler();\n\n private:\n  std::ofstream fstream_;\n};\n\n\n}  // namespace logging\n\n}  // namespace mysql_harness\n\n#endif /* MYSQL_HARNESS_LOGGER_HANDLER_INCLUDED */\n"
  },
  {
    "path": "src/harness/include/mysql/harness/logging/logger.h",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_LOGGER_LOGGER_INCLUDED\n#define MYSQL_HARNESS_LOGGER_LOGGER_INCLUDED\n\n#include \"mysql/harness/logging/logging.h\"\n#include \"harness_export.h\"\n\n#include <set>\n#include <string>\n\nnamespace mysql_harness {\n\nnamespace logging {\n\nclass Registry;\n\n/**\n * Logger class.\n *\n * The logger class handles the logging for one or more logging\n * handlers. Each logger class instance keeps state for logging for one\n * module or subsystem. You can add handlers to a logger which will\n * then be used for all logging to that subsystem.\n */\nclass HARNESS_EXPORT Logger {\n public:\n  explicit Logger(Registry& registry,\n                  LogLevel level = kDefaultLogLevel);\n\n  // such null object is useless, however we need the ability to create an\n  // object and populate it later inside of guarded scope (e.g: std::lock_guard)\n  Logger() : level_(LogLevel::kNotSet) {}\n\n  void attach_handler(std::string name);\n  void detach_handler(std::string name, bool handler_must_exist = true);\n  void handle(const Record& record);\n  const std::set<std::string>& get_handler_names() const { return handlers_; }\n\n  void set_level(LogLevel level) { level_ = level; }\n  LogLevel get_level() const { return level_; }\n\n private:\n  LogLevel level_;\n  std::set<std::string> handlers_;\n  const Registry* registry_;  // owner backreference (we don't own Registry, Registry owns us)\n};\n\n} // namespace logging\n\n} // namespace mysql_harness\n\n#endif /* MYSQL_HARNESS_LOGGER_LOGGER_INCLUDED */\n"
  },
  {
    "path": "src/harness/include/mysql/harness/logging/logging.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/**\n * @file\n * @brief Logging interface for using and extending the logging subsystem.\n */\n\n#ifndef MYSQL_HARNESS_LOGGING_INCLUDED\n#define MYSQL_HARNESS_LOGGING_INCLUDED\n\n#include \"mysql/harness/compiler_attributes.h\"\n#include \"mysql/harness/filesystem.h\"\n#include \"harness_export.h\"\n\n#include <fstream>\n#include <mutex>\n#include <list>\n#include <string>\n#include <cstdarg>\n\n#ifndef _WIN32\n#  include <sys/types.h>\n#  include <unistd.h>\n#endif\n\n#ifdef _MSC_VER\n#  ifdef logger_EXPORTS\n/* We are building this library */\n#    define LOGGER_API __declspec(dllexport)\n#  else\n/* We are using this library */\n#    define LOGGER_API __declspec(dllimport)\n#  endif\n#else\n#  define LOGGER_API\n#endif\n\n#ifdef _WIN32\n#  define WIN32_LEAN_AND_MEAN\n#  include <windows.h>\n#  define pid_t DWORD\n#endif\n\nnamespace mysql_harness {\n\nnamespace logging {\n\n/**\n * Max message length that can be logged; if message is longer,\n * it will be truncated to this length.\n */\nconst size_t kLogMessageMaxSize = 4096;\n\n/**\n * Section name and option name used in config file (and later in configuration\n * object) to specify log level, best explained by example:\n *\n *  vvvvvv------------------ kConfigSectionLogger\n * [logger]\n * level = DEBUG\n * ^^^^^-------------------- kConfigOptionLogLevel\n */\nconstexpr char kConfigOptionLogLevel[] = \"level\";\nconstexpr char kConfigSectionLogger[] = \"logger\";\n\n/**\n * Special names reserved for \"main\" program logger. It will use one of the\n * two handlers, depending on whether logging_folder is empty or not.\n */\nconstexpr char kMainLogger[] = \"main\";\nconstexpr char kMainLogHandler[] = \"main_log_handler\";\nconstexpr char kMainConsoleHandler[] = \"main_console_handler\";\n\nconstexpr char kSqlLogger[] = \"sql\";\n/**\n * Log level values.\n *\n * Log levels are ordered numerically from most important (lowest\n * value) to least important (highest value).\n */\nenum class LogLevel {\n  /** Fatal failure. Router usually exits after logging this. */\n  kFatal,\n\n  /**\n   * Error message. indicate that something is not working properly and\n   * actions need to be taken. However, the router continue\n   * operating but the particular thread issuing the error message\n   * might terminate.\n   */\n  kError,\n\n  /**\n   * Warning message. Indicate a potential problem that could require\n   * actions, but does not cause a problem for the continous operation\n   * of the router.\n   */\n  kWarning,\n\n  /**\n   * Informational message. Information that can be useful to check\n   * the behaviour of the router during normal operation.\n   */\n  kInfo,\n\n  /**\n   * Debug message. Message contain internal details that can be\n   * useful for debugging problematic situations, especially regarding\n   * the router itself.\n   */\n  kDebug,\n\n  kNotSet  // Always higher than all other log messages\n};\n\n/**\n * Default log level used by the router.\n */\nconst LogLevel kDefaultLogLevel = LogLevel::kWarning;\n\n/**\n * Log level name for the default log level used by the router\n */\nconst char* const kDefaultLogLevelName = \"warning\";\n\n/**\n * Log level name used in raw logging mode\n */\nconst char* const kRawLogLevelName = \"info\";\n\n/**\n * Log record containing information collected by the logging\n * system.\n *\n * The log record is passed to the handlers together with message.\n */\nstruct Record {\n  LogLevel level;\n  pid_t process_id;\n  time_t created;\n  std::string domain;\n  std::string message;\n};\n\n\n\n/**\n * Log message for the domain.\n *\n * This will log an error, warning, informational, or debug message\n * for the given domain. The domain have to be be registered before\n * anything is being logged. The `Loader` uses the plugin name as the\n * domain name, so normally you should provide the plugin name as the\n * first argument to this function.\n *\n * @param name Domain name to use when logging message.\n *\n * @param fmt `printf`-style format string, with arguments following.\n */\n/** @{ */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * Pre-processor symbol containing the name of the log domain. If not\n * defined explicitly when compiling, it will be an empty string, which\n * means that it logs to the top log domain.\n */\n\n#ifndef MYSQL_ROUTER_LOG_DOMAIN\n#define MYSQL_ROUTER_LOG_DOMAIN \"\"\n#endif\n\n/*\n * We need to declare these first, because __attribute__ can only be used in\n * declarations.\n */\nstatic inline void log_error(const char *fmt, ...) ATTRIBUTE_GCC_FORMAT(printf, 1, 2);\nstatic inline void log_warning(const char *fmt, ...) ATTRIBUTE_GCC_FORMAT(printf, 1, 2);\nstatic inline void log_info(const char *fmt, ...) ATTRIBUTE_GCC_FORMAT(printf, 1, 2);\nstatic inline void log_debug(const char *fmt, ...) ATTRIBUTE_GCC_FORMAT(printf, 1, 2);\n\n/*\n * Define inline functions that pick up the log domain defined for the module.\n */\n\nstatic inline void log_error(const char* fmt, ...) {\n  extern void log_message(LogLevel level, const char* module, const char* fmt, va_list ap);\n  va_list ap;\n  va_start(ap, fmt);\n  log_message(LogLevel::kError, MYSQL_ROUTER_LOG_DOMAIN, fmt, ap);\n  va_end(ap);\n}\n\nstatic inline void log_warning(const char* fmt, ...) {\n  extern void log_message(LogLevel level, const char* module, const char* fmt, va_list ap);\n  va_list ap;\n  va_start(ap, fmt);\n  log_message(LogLevel::kWarning, MYSQL_ROUTER_LOG_DOMAIN, fmt, ap);\n  va_end(ap);\n}\n\nstatic inline void log_info(const char* fmt, ...) {\n  extern void log_message(LogLevel level, const char* module, const char* fmt, va_list ap);\n  va_list ap;\n  va_start(ap, fmt);\n  log_message(LogLevel::kInfo, MYSQL_ROUTER_LOG_DOMAIN, fmt, ap);\n  va_end(ap);\n}\n\nstatic inline void log_debug(const char* fmt, ...) {\n  extern void log_message(LogLevel level, const char* module, const char* fmt, va_list ap);\n  va_list ap;\n  va_start(ap, fmt);\n  log_message(LogLevel::kDebug, MYSQL_ROUTER_LOG_DOMAIN, fmt, ap);\n  va_end(ap);\n}\n\n/** @} */\n\n#ifdef __cplusplus\n}\n#endif\n\n}  // namespace logging\n\n}  // namespace mysql_harness\n\n/**\n * convenience macro to avoid common boilerplate\n */\n#define IMPORT_LOG_FUNCTIONS() \\\nusing mysql_harness::logging::log_error;    \\\nusing mysql_harness::logging::log_warning;  \\\nusing mysql_harness::logging::log_info;     \\\nusing mysql_harness::logging::log_debug;\n\n#endif // MYSQL_HARNESS_LOGGING_INCLUDED\n"
  },
  {
    "path": "src/harness/include/mysql/harness/logging/registry.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_LOGGER_REGISTRY_INCLUDED\n#define MYSQL_HARNESS_LOGGER_REGISTRY_INCLUDED\n\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysql/harness/logging/logger.h\"\n#include \"mysql/harness/filesystem.h\"\n#include \"mysql/harness/config_parser.h\"\n#include \"harness_export.h\"\n\n#include <atomic>\n#include <map>\n#include <mutex>\n#include <string>\n\nnamespace mysql_harness {\n\nnamespace logging {\n\n// log level is stored in this hacky global variable; see place where it's\n// set for exaplanation\nHARNESS_EXPORT\nextern std::string g_HACK_default_log_level;\n\nclass Handler;\n\nclass HARNESS_EXPORT Registry {\n public:\n  const static std::map<std::string, LogLevel> kLogLevels;\n\n  Registry() = default;\n  Registry(const Registry&) = delete;\n  Registry& operator=(const Registry&) = delete;\n\n  ~Registry() = default;\n\n//----[ logger CRUD ]-----------------------------------------------------------\n\n  /**\n   * Create a logger in the internal registry\n   *\n   * @param name Logger id (log domain it services)\n   * @param level Log level for logger\n   *\n   * @throws std::logic_error if there is a logger already registered with given\n   *         module name\n   */\n  void create_logger(const std::string& name,\n                     LogLevel level = LogLevel::kNotSet);\n\n  /**\n   * Remove a named logger from the internal registry\n   *\n   * @param name Logger id (log domain it services)\n   *\n   * @throws std::logic_error if there is no logger registered with given\n   *         module name\n   */\n  void remove_logger(const std::string& name);\n\n  /**\n   * Return logger for particular module\n   *\n   * The reason why this function returns by value is thread-safety.\n   *\n   * @param name Logger id (log domain it services)\n   *\n   * @throws std::logic_error if no logger is registered for given module name\n   */\n  Logger get_logger(const std::string& name) const;\n\n  /**\n   * Update logger for particular module\n   *\n   * This function provides a thread-safe way of updating the Logger object in\n   * the registry.\n   *\n   * @param name Logger id (log domain it services)\n   * @param logger Logger object\n   *\n   * @throws std::logic_error if no logger is registered for given module name\n   */\n  void update_logger(const std::string& name, const Logger& logger);\n\n  /**\n   * Get the logger names (id's) from the internal registry\n   */\n  std::set<std::string> get_logger_names() const;\n\n//----[ handler CRUD ]----------------------------------------------------------\n\n  /**\n   * Add a handler to the internal registry\n   *\n   * @param name Handler id\n   * @param handler Shared pointer to handler\n   *\n   * @throws std::logic_error if there is a handler already registered with given\n   *         module name\n   */\n  void add_handler(std::string name, std::shared_ptr<Handler> handler);\n\n  /**\n   * Remove handler from the internal registry\n   *\n   * @param name Handler id\n   *\n   * @throws std::logic_error if no handler is registered for given name\n   */\n  void remove_handler(std::string name);\n\n  /**\n   * Return handler in the internal registry\n   *\n   * @param name Handler id\n   *\n   * @throws std::logic_error if no handler is registered for given name\n   */\n  std::shared_ptr<Handler> get_handler(std::string name) const;\n\n  /**\n   * Get the handler names from the internal registry\n   */\n  std::set<std::string> get_handler_names() const;\n\n  /**\n   * Flag that the registry has been initialized\n   *\n   * This method should be called after log initialization is complete to\n   * flag that logging facility is now available. Note that this is a\n   * convenience flag - it does not directly affect the operation of Registry.\n   * However, a logging function (i.e. log_message()) might want to query\n   * this flag when called and do whatever it deems appropriate.\n   */\n  void set_ready() noexcept { ready_ = true; }\n\n  /**\n   * Query if logging facility is ready to use\n   *\n   * The exact meaning of this flag is not defined here, see description in\n   * set_ready()\n   */\n  bool is_ready() const noexcept { return ready_; }\n\n private:\n  mutable std::mutex mtx_;\n  std::map<std::string, Logger> loggers_; // key = log domain\n  std::map<std::string, std::shared_ptr<Handler>> handlers_; // key = handler id\n  std::atomic<bool> ready_{false};\n\n}; // class Registry\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// high-level utility functions\n//\n////////////////////////////////////////////////////////////////////////////////\n\n  /**\n   * Get default log level\n   *\n   * Fetches default log level set in the configuration file\n   *\n   * @param config Configuration items from configuration file\n   *\n   * @throws std::invalid_argument if [logger].level in configuration is invalid\n   */\n  HARNESS_EXPORT\n  LogLevel get_default_log_level(const Config& config);\n\n  /**\n   * Attach handler to all loggers\n   *\n   * @param registry Registry object, typically managed by DIM\n   * @param name Logger id (log domain it services)\n   */\n  HARNESS_EXPORT\n  void attach_handler_to_all_loggers(Registry& registry, std::string name);\n\n  /**\n   * Set log levels for all the loggers to specified value\n   *\n   * @param registry Registry object, typically managed by DIM\n   * @param level Log level for logger\n   */\n  HARNESS_EXPORT\n  void set_log_level_for_all_loggers(Registry& registry, LogLevel level);\n\n  /**\n   * Clear registry\n   *\n   * Removes all Loggers and removes all references to Handlers (they're held\n   * as shared pointers, which may mean they will also be deleted)\n   *\n   * @param registry Registry object, typically managed by DIM\n   */\n  HARNESS_EXPORT\n  void clear_registry(Registry& registry);\n\n  /**\n   * Initialize logging facility\n   *\n   * Initializes logging facility by registering a logger for each given module.\n   * Loggers will have their log level set to default log level ([logger].level)\n   * set in the Router configuration .\n   *\n   * @note Loggers will not have any handlers attached, this needs to be done\n   *       separately (see `create_main_logfile_handler()`)\n   *\n   * @param registry Registry object, typically managed by DIM\n   * @param config Configuration items from configuration file\n   * @param modules List of plugin names loaded\n   * @param main_app_log_domain Log domain (logger id) to be used as the main\n   *                            program logger. This logger must exist, because\n   *                            log_*() functions might fail\n   *\n   * @throws std::invalid_argument (derived from logic_error) on invalid\n   *         [logger].level\n   * @throws std::logic_error on other error\n   */\n  HARNESS_EXPORT\n  void init_loggers(Registry& registry,\n                    const mysql_harness::Config& config,\n                    const std::list<std::string>& modules,\n                    const std::string& main_app_log_domain);\n\n  /*\n   * Initialize a logger and register it in the Registry..\n   *\n   * Register a logger for a given name and given log level.\n   *\n   * @param registry Registry object, typically managed by DIM\n   * @param logger_name The name under which the logger is registered\n   * @param log_level The log level.\n   *\n   * @throws std::logic_error\n   */\n  HARNESS_EXPORT\n  void init_logger(Registry& registry, const mysql_harness::Config& config, const std::string& logger_name);\n\n  /**\n   * Initialize logfile handler\n   *\n   * Initializes handler which will handle application's log. This handler\n   * will be attached to all currently-registered loggers. If `logging_folder`\n   * is empty, handler will log messages to console, otherwise, logfile will be\n   * used and its path and filename will be derived from `program` and\n   * `logging_folder` parameters.\n   *\n   * @param registry Registry object, typically managed by DIM\n   * @param program Name of the main program (Router)\n   * @param logging_folder logging_folder provided in configuration file\n   * @param format_messages If set to true, log messages will be formatted\n   *        (prefixed with log level, timestamp, etc) before logging\n   *\n   * @throws std::runtime_error if opening log file fails\n   */\n  HARNESS_EXPORT\n  void create_main_logfile_handler(Registry& registry,\n                                   const std::string& program,\n                                   const std::string& logging_folder,\n                                   bool format_messages);\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// These functions are simple proxies that can be used by logger plugins\n// to register their logging services. Note that they can only be called after\n// logging facility has been initialized; but by the time the plugins are loaded,\n// logging facility is already operational, so this is fine for plugin use.\n//\n////////////////////////////////////////////////////////////////////////////////\n\n  /** Set log level for all registered loggers. */\n  HARNESS_EXPORT\n  void set_log_level_for_all_loggers(LogLevel level);\n\n  /**\n   * Register handler for all plugins.\n   *\n   * This will register a handler for all plugins that have been\n   * registered with the logging subsystem (normally all plugins that\n   * have been loaded by `Loader`).\n   *\n   * @param handler Shared pointer to dynamically allocated handler.\n   *\n   * For example, to register a custom handler from a plugin, you would\n   * do the following:\n   *\n   * @code\n   * void init() {\n   *   ...\n   *   register_handler(std::make_shared<MyHandler>(...));\n   *   ...\n   * }\n   * @endcode\n   */\n  HARNESS_EXPORT\n  void register_handler(std::string name, std::shared_ptr<Handler> handler);\n\n  /**\n   * Unregister a handler.\n   *\n   * This will unregister a previously registered handler.\n   *\n   * @param name name of registered handler.\n   */\n  HARNESS_EXPORT\n  void unregister_handler(std::string name);\n\n  /**\n  * Returns pointer to the default logger sink stream.\n  */\n  HARNESS_EXPORT\n  std::ostream *get_default_logger_stream();\n\n} // namespace logging\n\n} // namespace mysql_harness\n\n#endif /* MYSQL_HARNESS_LOGGER_REGISTRY_INCLUDED */\n"
  },
  {
    "path": "src/harness/include/mysql/harness/networking/ip_address.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_NETWORKING_IP_ADDRESS_INCLUDED\n#define MYSQL_HARNESS_NETWORKING_IP_ADDRESS_INCLUDED\n\n#include \"mysql/harness/networking/ipv4_address.h\"\n#include \"mysql/harness/networking/ipv6_address.h\"\n#include \"harness_export.h\"\n\n#include <ostream>\n#include <string>\n\n\nnamespace mysql_harness {\n\n/**\n * IPAddress for both v4 and v6\n *\n * This class manages IP address of both version 4, and version 6.\n *\n * The following example shows the creation of two `IPAddress` objects\n * for the localhost for both IPv4 and IPv6:\n *\n * @code\n * mysql_harness::IPAddress ip4(\"127.0.0.1\");\n * mysql_harness::IPAddress ip6 = \"::1\";\n *\n * std::cout << ip4 << \" and \" << ip6 << std::endl;\n * @endcode\n *\n */\nclass HARNESS_EXPORT IPAddress {\n public:\n  /**\n   * Constructs a new IPAddress object as IPv4 and initialized\n   * to zero.\n   */\n  IPAddress() : address_type_(AddressType::kIPv4),\n                ipv4_address_(), ipv6_address_() {}\n\n  /**\n   * Constructs a new IPAddress object from the given IPv4Address\n   * instance.\n   *\n   * @param address an IPv4Address object\n   */\n  explicit IPAddress(const IPv4Address &address)\n    : address_type_(AddressType::kIPv4),\n      ipv4_address_(address), ipv6_address_() {}\n\n  /**\n   * Constructs a new IPAddress object from the given IPv6Address\n   * instance.\n   *\n   * @param address an IPv6Address object\n   */\n  explicit IPAddress(const IPv6Address &address)\n    : address_type_(AddressType::kIPv6),\n      ipv4_address_(), ipv6_address_(address) {}\n\n  /**\n   * Constructs a new IPAddress object using the null-terminated\n   * character string or `std::string` representing an IP address\n   * of any type. The address type is deduced by the number of\n   * colons `:` in the string.\n   *\n   * @throws std::invalid_argument when data could not be converted\n   * to either an IPv4 or IPv6 address.\n   *\n   * @param data string representing an IP address\n   */\n  explicit IPAddress(const std::string &data);\n\n  /** @overload */\n  explicit IPAddress(const char *data) : IPAddress(std::string(data)) {}\n\n  /** Copy constructor */\n  IPAddress(const IPAddress &other)\n    : address_type_(other.address_type_),\n      ipv4_address_(other.ipv4_address_),\n      ipv6_address_(other.ipv6_address_) {}\n\n  /** Copy assignment */\n  IPAddress &operator=(const IPAddress &other) {\n    if (this != &other) {\n      IPAddress tmp(other);\n      swap(tmp);\n    }\n    return *this;\n  }\n\n  /** @overload */\n  IPAddress &operator=(const IPv4Address &other) {\n    address_type_ = AddressType::kIPv4;\n    ipv4_address_ = other;\n    return *this;\n  }\n\n  /** @overload */\n  IPAddress &operator=(const IPv6Address &other) {\n    address_type_ = AddressType::kIPv6;\n    ipv6_address_ = other;\n    return *this;\n  }\n\n  /**\n   * Exchange data between two IPAddress objects\n   *\n   * @param other object to exchange with\n   */\n  void swap(IPAddress &other) noexcept {\n    using std::swap;\n    swap(address_type_, other.address_type_);\n    swap(ipv4_address_, other.ipv4_address_);\n    swap(ipv6_address_, other.ipv6_address_);\n  }\n\n  /**\n   * Return whether address is IPv4\n   *\n   * @return true if address is IPv4\n   */\n  bool is_ipv4() const noexcept {\n    return address_type_ == AddressType::kIPv4;\n  }\n\n  /**\n   * Return whether address is IPv6\n   *\n   * @return true if address is IPv6\n   */\n  bool is_ipv6() const noexcept {\n    return address_type_ == AddressType::kIPv6;\n  }\n\n  const IPv4Address& as_ipv4() const {\n    if (address_type_ != AddressType::kIPv4) {\n      throw std::runtime_error(\"address is not IPv4\");\n    }\n    return ipv4_address_;\n  }\n\n  const IPv6Address& as_ipv6() const {\n    if (address_type_ != AddressType::kIPv6) {\n      throw std::runtime_error(\"address is not IPv6\");\n    }\n    return ipv6_address_;\n  }\n\n  /**\n   * Returns text representation of the IP address\n   *\n   * An empty string is returned incase the IP address is neither\n   * IPv4 or IPv6.\n   *\n   * @return IP address as a `std::string`, or empty.\n   */\n  std::string str() const;\n\n  /**\n   * Compare IP addresses\n   *\n   * @return true if IP addresses are equal\n   */\n  HARNESS_EXPORT\n  friend bool operator==(const IPAddress &a, const IPAddress &b);\n\n  /**\n   * Compare IP addresses\n   *\n   * @return true if IP addresses are not equal\n   */\n  HARNESS_EXPORT\n  friend bool operator!=(const IPAddress &a, const IPAddress &b) {\n    return !(a == b);\n  }\n\n  /**\n   * Overload stream insertion operator\n   */\n  HARNESS_EXPORT\n  friend std::ostream &operator<<(std::ostream &out, const IPAddress &address) {\n    out << address.str();\n    return out;\n  }\n\n private:\n  /** IP address types */\n  enum class AddressType {\n    kIPv4 = 0,\n    kIPv6,\n  };\n\n  /** Type of the IP Address */\n  AddressType address_type_;\n\n  /** Holds the IPv4 address */\n  IPv4Address ipv4_address_;\n\n  /** Holds the IPv6 address */\n  IPv6Address ipv6_address_;\n};\n\n} // namespace mysql_harness\n\n#endif // MYSQL_HARNESS_NETWORKING_IP_ADDRESS_INCLUDED\n"
  },
  {
    "path": "src/harness/include/mysql/harness/networking/ipv4_address.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_NETWORKING_IPV4_ADDRESS_INCLUDED\n#define MYSQL_HARNESS_NETWORKING_IPV4_ADDRESS_INCLUDED\n\n#include \"harness_export.h\"\n\n#include <array>\n#include <iostream>\n#include <string>\n\n#ifndef _WIN32\n#  include <arpa/inet.h>\n#else\n#  define WIN32_LEAN_AND_MEAN\n#  include <windows.h>\n#  include <winsock2.h>\n#  include <ws2tcpip.h>\n#endif\n\nnamespace mysql_harness {\n\n/**\n * IPv4Address for IP version 4 addresses\n *\n * This class manages IP v4 addresses.\n *\n * The following will create an `IPv4Address` instance for the localhost\n * address:\n *\n * ```\n * mysql_harness::IPv4Address ip4(\"127.0.0.1\");\n *\n * std::cout << \"IPv4: \" << ip4 << std::endl;\n * ```\n *\n * `mysql_harness::IPAddress` should be used to manage IP addresses\n * when using both IPv4 and IPv6.\n *\n */\nclass HARNESS_EXPORT IPv4Address {\n public:\n  /**\n   * Constructs a new IPv4Address object leaving the internal structure\n   * initialized to zero.\n   *\n   */\n  IPv4Address() {\n    address_.s_addr = 0;\n  }\n\n  /**\n   * Constructs a new IPv4Address object using the given unsigned\n   * integer.\n   *\n   * @param addr unsigned 32-bit integer representing an IPv4 address\n   */\n  explicit IPv4Address(uint32_t addr) {\n    address_.s_addr = addr;\n  }\n\n  /**\n   * Constructs a new IPv4Address object using the null-terminated\n   * character string or a `std::string` representing the IPv4 address.\n   *\n   * @throws std::invalid_argument when data could not be converted\n   * to an IPv4 address\n   * @param data string representing a IPv4 address\n   */\n  explicit IPv4Address(const char *data);\n\n  /** @overload */\n  explicit IPv4Address(const std::string &data) : IPv4Address(data.c_str()) {}\n\n  /** Copy constructor */\n  IPv4Address(const IPv4Address &other) : address_(other.address_) {}\n\n  /** Copy assignment */\n  IPv4Address &operator=(const IPv4Address &other) {\n    if (this != &other) {\n      address_ = other.address_;\n    }\n    return *this;\n  }\n\n  /**\n   * Returns text representation of the IPv4 address\n   *\n   * Throws `std::system_error` when it was not possible to\n   * get the textual representation of the IPv4 address.\n   *\n   * @return IPv4 address as a `std::string`\n   */\n  std::string str() const;\n\n  /**\n   * Compare IPv4 addresses for equality\n   *\n   * @return true if IPv4 addresses are equal\n   */\n  friend bool operator==(const IPv4Address &a, const IPv4Address &b) {\n    return a.address_.s_addr == b.address_.s_addr;\n  }\n\n  /**\n   * Compare IPv4 addresses for inequality\n   *\n   * @return true if IPv4 addresses are not equal\n   */\n  friend bool operator!=(const IPv4Address &a, const IPv4Address &b) {\n    return a.address_.s_addr != b.address_.s_addr;\n  }\n\n  /**\n   * Overload stream insertion operator\n   */\n  friend std::ostream &operator<<(std::ostream &out,\n                                  const IPv4Address &address) {\n    out << address.str();\n    return out;\n  }\n\n private:\n  /** Storage of the IPv4 address. */\n  in_addr address_;\n};\n\n}\n\n#endif // MYSQL_HARNESS_NETWORKING_IPV4_ADDRESS_INCLUDED\n"
  },
  {
    "path": "src/harness/include/mysql/harness/networking/ipv6_address.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_NETWORKING_IPV6_ADDRESS_INCLUDED\n#define MYSQL_HARNESS_NETWORKING_IPV6_ADDRESS_INCLUDED\n\n#ifndef _WIN32\n#  include <arpa/inet.h>\n#  include <netinet/in.h>\n#else\n#  define WIN32_LEAN_AND_MEAN\n#  include <ws2tcpip.h> // in6_addr\n#endif\n#include <array>\n#include <cerrno>\n#include <cstdlib>\n#include <cstring>\n#include <iomanip>\n#include <iostream>\n#include <sstream>\n#include <string>\n\n#include \"harness_export.h\"\n\nnamespace mysql_harness {\n\n/**\n * IPv6Address for IP version 6 addresses\n *\n * This class manages IP v6 addresses.\n *\n * The following will create an `IPv6Address` instance for the localhost\n * address:\n *\n * ```\n * mysql_harness::IPv6Address ip6(\"::1\");\n *\n * std::cout << \"IPv6: \" << ip6 << std::endl;\n * ```\n *\n * `mysql_harness::IPAddress` should be used to manage IP addresses\n * when using both IPv4 and IPv6.\n *\n */\nclass HARNESS_EXPORT IPv6Address {\n public:\n  /**\n   * Constructs a new IPv6Address object leaving the internal structure\n   * initialized to zero.\n   *\n   */\n  IPv6Address() : address_() {}\n\n  /**\n   * Constructs a new IPv6Address object copying the given array\n   * of 16 unsigned integers to the internal structure.\n   *\n   * @param s6addr array of 16 uint8_t\n   */\n  explicit IPv6Address(const uint8_t s6addr[16]) {\n    std::memcpy(address_.s6_addr, s6addr, sizeof(address_.s6_addr));\n  }\n\n  /**\n   * Constructs a new IPv6Address object using the null-terminated\n   * character string or a `std::string` representing the IPv6 address.\n   *\n   * @throws std::invalid_argument when data could not be converted\n   * to an IPv6 address\n   * @param data string representing an IPv6 address\n   */\n  explicit IPv6Address(const char *data);\n\n  /** @overload */\n  explicit IPv6Address(const std::string &data) : IPv6Address(data.c_str()) {}\n\n  /** Copy constructor */\n  IPv6Address(const IPv6Address &other)\n    : address_(other.address_) {\n  }\n\n  /** Copy assignment */\n  IPv6Address &operator=(const IPv6Address &other) {\n    if (this != &other) {\n      address_ = other.address_;\n    }\n    return *this;\n  }\n\n  /**\n   * Returns text representation of the IPv6 address\n   *\n   * Throws `std::system_error` when it was not possible to\n   * get the textual representation of the IPv6 address.\n   *\n   * @return IPv6 address as a `std::string`\n   */\n  std::string str() const;\n\n  /**\n   * Compare IPv6 addresses for equality\n   *\n   * @return true if IPv6 addresses are equal\n   */\n  friend bool operator==(const IPv6Address &a, const IPv6Address &b) {\n    return std::memcmp(&a.address_, &b.address_, sizeof(a.address_)) == 0;\n  }\n\n  /**\n   * Compare IPv6 addresses for inequality\n   *\n   * @return true if IPv6 addresses are not equal\n   */\n  friend bool operator!=(const IPv6Address &a, const IPv6Address &b) {\n    return !(a == b);\n  }\n\n  /**\n   * Overload stream insertion operator\n   */\n  friend std::ostream &operator<<(std::ostream &out,\n                                  const IPv6Address &address) {\n    out << address.str();\n    return out;\n  }\n\n private:\n  /** Storage of the IPv6 address */\n  in6_addr address_;\n};\n\n} // namespace mysql_harness\n\n#endif // MYSQL_HARNESS_NETWORKING_IPV4_ADDRESS_INCLUDED\n"
  },
  {
    "path": "src/harness/include/mysql/harness/networking/resolver.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_NETWORKING_RESOLVER_INCLUDED\n#define MYSQL_HARNESS_NETWORKING_RESOLVER_INCLUDED\n\n#include <string>\n#include <vector>\n\n#include \"ip_address.h\"\n#include \"harness_export.h\"\n\nnamespace mysql_harness {\n\nclass HARNESS_EXPORT Resolver {\n public:\n  /**\n   * Resolves the hostname to one or more IP addresses\n   *\n   * @param name hostname to resolve\n   * @return a `std::vector` containing instances of `IPAddress`\n   */\n  std::vector<IPAddress> hostname(const char *name) const;\n\n  /** @overload */\n  std::vector<IPAddress> hostname(const std::string &name) const {\n    return hostname(name.c_str());\n  }\n\n  /**\n   * Resolves a TCP service name to its TCP port\n   *\n   * This method will resolve a service name such as `http` to\n   * it's standard port `80`.\n   *\n   * @throws std::invalid_argument when given service name could not\n   * be resolved.\n   * @param name service name to resolve\n   * @return port number of the given service\n   */\n  uint16_t tcp_service_name(const char *name) const;\n\n  uint16_t tcp_service_name(const std::string &name) const {\n    return tcp_service_name(name.c_str());\n  }\n\n  /**\n   * Resolves a TCP port to its service name\n   *\n   * This method will resolve a TCP port to its service name.\n   * When no service name is associated with the port, the port\n   * number is returned as string.\n   *\n   * @param port TCP port to resolve\n   * @return service name or port as string\n   */\n  std::string tcp_service_port(uint16_t port) const;\n\n protected:\n  typedef std::pair<uint16_t, std::string> ServiceCacheEntry;\n\n  /** Lookup cached TCP port using service name\n   *\n   * @param name TCP service name\n   * @return port number for service or 0 if not cached\n   */\n  uint16_t cached_tcp_service_by_name(const std::string &name) const;\n\n  /** Lookup cached service name using TCP port\n   *\n   * @param port TCP port number\n   * @return service name or empty string if not cached\n   */\n  std::string cached_tcp_service_by_port(uint16_t port) const;\n\n  /** Cache holding resolved TCP services */\n  mutable std::vector<ServiceCacheEntry> cache_tcp_services_{};\n};\n\n\n}\n\n#endif // MYSQL_HARNESS_NETWORKING_RESOLVER_INCLUDED\n\n"
  },
  {
    "path": "src/harness/include/mysql/harness/queue.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_QUEUE_INCLUDED\n#define MYSQL_HARNESS_QUEUE_INCLUDED\n\n#include <atomic>\n#include <condition_variable>\n#include <iostream>\n#include <memory>\n#include <mutex>\n\nnamespace mysql_harness {\n\n/**\n * Thread-safe queue.\n *\n * This class implements a thread-safe queue allowing multiple\n * simultaneous readers and writers.\n */\ntemplate <class T>\nclass queue {\n  friend std::ostream& operator<<(std::ostream& out, const queue& q) {\n    std::lock(q.head_mtx_, q.tail_mtx_);\n    std::lock_guard<std::mutex> l1(q.head_mtx_, std::adopt_lock);\n    std::lock_guard<std::mutex> l2(q.tail_mtx_, std::adopt_lock);\n    for (Node* ptr = q.head_.get() ; ptr != q.tail_ ; ptr = ptr->next_.get()) {\n      out << *ptr->data_;\n      if (ptr->next_.get() != q.tail_)\n        out << \", \";\n    }\n    return out;\n  }\n\n private:\n  /**\n   * Node in the queue, holding the enqueued value.\n   */\n  struct Node {\n    /*** The enqueued value */\n    std::shared_ptr<T> data_;\n\n    /*** Pointer to the next node in the queue */\n    std::unique_ptr<Node> next_;\n  };\n\n  /**\n   * Protected get of pointer to tail node.\n   */\n  Node* get_tail() {\n    std::lock_guard<std::mutex> lock(tail_mtx_);\n    return tail_;\n  }\n\n  /** @overload */\n  const Node* get_tail() const {\n    std::lock_guard<std::mutex> lock(tail_mtx_);\n    return tail_;\n  }\n\n  /**\n   * Helper function to unlink the front node of the queue.\n   *\n   * @pre The queue is non-empty and the head mutex is acquired.\n   */\n  std::unique_ptr<Node> unlink_front() {\n    std::unique_ptr<Node> head = std::move(head_);\n    head_ = std::move(head->next_);\n    --size_;\n    assert(head_.get() != nullptr);\n    return head;\n  }\n\n  /**\n   * Pop front node, blocking if one is not available.\n   *\n   * @internal\n   *\n   * We use `get_tail()` here to fetch the value of the tail, which\n   * means we are releasing the tail mutex after fetching the tail\n   * pointer. This means that elements can be added to the queue after\n   * we have fetched the tail pointer.\n   *\n   * However, since we have aquired the head mutex, it is not possible\n   * that any elements are *removed* from the queue, which means that\n   * if the test for empty was false when we fetched the tail pointer,\n   * it will be `false` even if more items are added to the queue\n   * while this thread does the comparison.\n   */\n  std::unique_ptr<Node> pop_front() {\n    std::unique_lock<std::mutex> lock(head_mtx_);\n    cond_.wait(lock, [this]{ return head_.get() != get_tail(); });\n    return unlink_front();\n  }\n\n  template <class Rep, class Period>\n  std::unique_ptr<Node>\n      pop_front(const std::chrono::duration<Rep, Period>& rel_time) {\n    std::unique_lock<std::mutex> lock(head_mtx_);\n    auto not_empty = [this]{\n      return head_.get() != get_tail();\n    };\n    if (cond_.wait_for(lock, rel_time, not_empty))\n      return unlink_front();\n    return std::unique_ptr<Node>();\n  }\n\n  /**\n   * Pop front node, if one is available.\n   */\n  std::unique_ptr<Node> try_pop_front() {\n    std::lock_guard<std::mutex> lock(head_mtx_);\n    if (head_.get() == get_tail())\n      return std::unique_ptr<Node>();\n    return unlink_front();\n  }\n\n public:\n  using size_type = std::size_t;\n\n  queue() : size_(0), head_(new Node), tail_(head_.get()) {}\n\n  queue(const queue&) = delete;\n  queue& operator=(const queue&) = delete;\n\n  /**\n   * Get the size of the queue.\n   *\n   * @return A positive integer denoting the number of elements in the\n   * queue.\n   */\n  size_type size(std::memory_order order =\n                 std::memory_order_seq_cst) const noexcept {\n    return size_.load(order);\n  }\n\n  /**\n   * Check if the queue is empty.\n   *\n   * @note Checking if the queue is empty before removing an element\n   * from the queue is not thread safe and in this case `try_pop`\n   * should be used intead.\n   */\n  bool empty() const {\n    std::lock_guard<std::mutex> lock(head_mtx_);\n    return head_.get() == get_tail();\n  }\n\n  void push(T val) {\n    // The push works by creating a new empty sentinel node and a\n    // shared pointer to the value to push. After that, the value is\n    // moved to the current tail node and the new empty sentinel is\n    // added last.\n    std::unique_ptr<Node> new_node(new Node);\n    std::shared_ptr<T> new_data = std::make_shared<T>(std::move(val));\n\n    {\n      std::lock_guard<std::mutex> lock(tail_mtx_);\n      Node* ptr = new_node.get();\n      tail_->data_ = std::move(new_data);\n      tail_->next_ = std::move(new_node);\n      tail_ = ptr;\n      ++size_;\n      assert(tail_ != nullptr);\n      assert(tail_->data_.get() == nullptr);\n      assert(tail_->next_.get() == nullptr);\n    }\n    cond_.notify_one();\n  }\n\n  bool pop(T* result) {\n    auto head = pop_front();\n    *result = std::move(*head->data_);\n    return true;\n  }\n\n  template <class Rep, class Period>\n  bool pop(T* result, const std::chrono::duration<Rep, Period>& rel_time) {\n    if (auto head = pop_front(rel_time)) {\n      *result = std::move(*head->data_);\n      return true;\n    }\n    return false;\n  }\n\n  std::shared_ptr<T> pop() {\n    std::unique_ptr<Node> head = pop_front();\n    return head->data_;\n  }\n\n  template <class Rep, class Period>\n  std::shared_ptr<T> pop(const std::chrono::duration<Rep, Period>& rel_time) {\n    if (std::unique_ptr<Node> head = pop_front(rel_time))\n      return head->data_;\n    return std::shared_ptr<T>();\n  }\n\n  bool try_pop(T* result) {\n    if (std::unique_ptr<Node> head = try_pop_front()) {\n      *result = std::move(*head->data_);\n      return true;\n    }\n    return false;\n  }\n\n  std::shared_ptr<T> try_pop() {\n    if (std::unique_ptr<Node> head = try_pop_front()) {\n      return head->data_;\n    } else {\n      return std::shared_ptr<T>();\n    }\n  }\n\n private:\n  mutable std::condition_variable cond_;\n  std::atomic_size_t size_;\n  std::unique_ptr<Node> head_;\n  mutable std::mutex head_mtx_;\n  Node* tail_;\n  mutable std::mutex tail_mtx_;\n};\n\n}  // namespace mysql_harness\n\n#endif /* MYSQL_HARNESS_QUEUE_INCLUDED */\n"
  },
  {
    "path": "src/harness/include/mysql_router_thread.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_MYSQL_ROUTER_THREAD_INCLUDED\n#define MYSQL_HARNESS_MYSQL_ROUTER_THREAD_INCLUDED\n\n\n#include \"harness_export.h\"\n\n#ifndef MYSQL_ABI_CHECK\n#if defined(_WIN32)\n#include <windows.h>\n#include <stdlib.h>\n#else\n#include <pthread.h>  // IWYU pragma: export\n#include <sched.h>    // IWYU pragma: export\n#include <stdexcept>\n#endif\n#endif /* MYSQL_ABI_CHECK */\n\n\nnamespace mysql_harness {\n\nstatic const size_t kDefaultStackSizeInKiloBytes = 1024;\n\n#ifdef _WIN32\ntypedef DWORD mysql_router_thread_t;\ntypedef struct thread_attr {\n  DWORD dwStackSize;\n  int detachstate;\n} mysql_router_thread_attr_t;\n#else\ntypedef pthread_t mysql_router_thread_t;\ntypedef pthread_attr_t mysql_router_thread_attr_t;\n#endif\n\nstruct mysql_router_thread_handle {\n  mysql_router_thread_t thread{0};\n#ifdef _WIN32\n  HANDLE handle{INVALID_HANDLE_VALUE};\n#endif\n};\n\n#ifdef _WIN32\n#define MYSQL_ROUTER_THREAD_CREATE_JOINABLE 0\n#define MYSQL_ROUTER_THREAD_CREATE_DETACHED 1\ntypedef void *(__cdecl *my_start_routine)(void *);\n#else\n#define MYSQL_ROUTER_THREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE\n#define MYSQL_ROUTER_THREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED\ntypedef void *(*my_start_routine)(void *);\n#endif\n\n/**\n * @brief MySQLRouterThread provides higher level interface to managing threads.\n */\nclass HARNESS_EXPORT MySQLRouterThread {\npublic:\n  using thread_function = void*(void*);\n\n  /**\n   * Allocates memory for thread of execution.\n   *\n   * @param thread_stack_size the memory size allocated to thread's stack\n   *\n   * @throw std::runtime_error if cannot adjust thread size\n   */\n  MySQLRouterThread(size_t thread_stack_size = mysql_harness::kDefaultStackSizeInKiloBytes);\n\n  /**\n   * Execute run_thread function in thread of execution.\n   *\n   * @param run_thread the pointer to the function that is executed in thread. It has to be non-member void*(void*) function\n   * @param args_ptr pointer to run_thread parameter\n   * @param detach true if thread is detached, false if thread is joinable\n   *\n   * @throw std::runtime_error if cannot create new thread of execution\n   */\n  void run(thread_function run_thread, void* args_ptr, bool detach = false);\n\n  /**\n   * Waits for a thread to finish its execution\n   */\n  void join();\n\n  /**\n   * Waits for a thread to finish its execution if thread is joinable and join wasn't called.\n   */\n  ~MySQLRouterThread();\n\nprivate:\n\n  /** @brief handle to the thread */\n  mysql_harness::mysql_router_thread_handle thread_handle_;\n\n  /** @brief attribute of thread */\n  mysql_harness::mysql_router_thread_attr_t thread_attr_;\n\n  /** @brief true if thread is joinable but join wasn't called, false otherwise */\n  bool should_join_ = false;\n};\n\n} // end of mysql_harness namespace\n\n#endif // end of MYSQL_HARNESS_MYSQL_ROUTER_THREAD_INCLUDED\n"
  },
  {
    "path": "src/harness/include/process_launcher.h",
    "content": "/* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License, version 2.0,\n   as published by the Free Software Foundation.\n\n   This program is also distributed with certain software (including\n   but not limited to OpenSSL) that is licensed under separate terms,\n   as designated in a particular file or component or in included license\n   documentation.  The authors of MySQL hereby grant you an additional\n   permission to link the program and your derivative works with the\n   separately licensed software that they have included with MySQL.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; if not, write to the Free Software\n   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */\n\n#ifndef _PROCESS_LAUNCHER_H_\n#define _PROCESS_LAUNCHER_H_\n\n#include \"harness_export.h\"\n#include <utility>\n\n#ifdef _WIN32\n#  define _CRT_SECURE_NO_WARNINGS 1\n#  ifdef UNICODE\n#    #undef UNICODE\n#  endif\n#  include <windows.h>\n#else\n#  include <unistd.h>\n#endif\n#include <stdint.h>\n#include <string>\n\nnamespace mysql_harness {\n\n/** an alive, spawned process\n *\n * @todo\n *   refactor ProcessLauchner and SpawnedProcess into:\n *   - ProcessLauncher having only the spawn/launch() method and no state\n *   - Process as a thin wrapper around 'pid' and operators on it\n *   - SpawnedProcess being a Process with stdin/stdout/stderr\n *   - a way to declare ownership over the 'pid' (if owned, kill pid in destructor)\n *   For now, this mostly exists to make the move-constructor of ProcessLauncher easier to implement.\n */\nclass HARNESS_EXPORT SpawnedProcess {\npublic:\n  SpawnedProcess(const char *pcmd_line, const char ** pargs, bool predirect_stderr = true) :\n    cmd_line{pcmd_line},\n    args{pargs},\n#ifdef _WIN32\n    child_in_rd{INVALID_HANDLE_VALUE},\n    child_in_wr{INVALID_HANDLE_VALUE},\n    child_out_rd{INVALID_HANDLE_VALUE},\n    child_out_wr{INVALID_HANDLE_VALUE},\n    // pi\n    // si\n#else\n    childpid{-1},\n    fd_in{-1, -1},\n    fd_out{-1, -1},\n#endif\n    redirect_stderr{predirect_stderr}\n  {}\n\n  virtual ~SpawnedProcess() {}\n\n  const std::string& get_cmd_line() { return cmd_line; }\n\nprotected:\n  const std::string cmd_line;\n  const char **args;\n#ifdef _WIN32\n  HANDLE child_in_rd;\n  HANDLE child_in_wr;\n  HANDLE child_out_rd;\n  HANDLE child_out_wr;\n  PROCESS_INFORMATION pi;\n  STARTUPINFO si;\n#else\n  pid_t childpid;\n  int fd_in[2];\n  int fd_out[2];\n#endif\n  bool redirect_stderr;\n};\n\n\n// Launches a process as child of current process and exposes the stdin & stdout of the child process\n// (implemented thru pipelines) so the client of this class can read from the child's stdout and write to the child's stdin.\n// For usage, see unit tests.\n//\nclass HARNESS_EXPORT ProcessLauncher : public SpawnedProcess {\n\n#ifdef _WIN32\n  /*\n   * After ProcessLauncher sends all data to remote process, it closes the handle\n   * to notify the remote process that no more data will be sent.\n   *\n   * Since you cannot close the same handle more than once, store information if handle should\n   * be closed in child_in_wr_closed.\n   */\n  bool child_in_wr_closed = false;\n#endif\n\npublic:\n  /**\n   * Creates a new process and launch it.\n   * Argument 'args' must have a last entry that is NULL.\n   * If redirect_stderr is true, the child's stderr is redirected to the same stream than child's stdout.\n   */\n  ProcessLauncher(const char *pcmd_line, const char ** pargs, bool predirect_stderr = true) :\n    SpawnedProcess(pcmd_line, pargs, predirect_stderr),\n    is_alive{false}\n  {}\n\n  // copying a Process results in multiple destructors trying\n  // to kill the same alive process. Disable it.\n  ProcessLauncher(const ProcessLauncher &) = delete;\n  ProcessLauncher operator=(const ProcessLauncher &) = delete;\n\n  ProcessLauncher(ProcessLauncher &&rhs) : SpawnedProcess(rhs), is_alive(std::move(rhs.is_alive)) {\n    // make sure destructor on the other object doesn't try to kill\n    // the process-id we just moved\n\n    rhs.is_alive = false;\n  }\n\n  ~ProcessLauncher();\n\n  /** Launches the child process, and makes pipes available for read/write. */\n  void start();\n\n  /**\n   * Read up to a 'count' bytes from the stdout of the child process.\n   * This method blocks until the amount of bytes is read or specified timeout\n   * expires.\n   * @param buf already allocated buffer where the read data will be stored.\n   * @param count the maximum amount of bytes to read.\n   * @param timeout_ms timeout (in milliseconds) for the read to complete\n   * @return the real number of bytes read.\n   * Returns an shcore::Exception in case of error when reading.\n   */\n  int read(char *buf, size_t count, unsigned timeout_ms);\n\n  /**\n   * Writes several butes into stdin of child process.\n   * Returns an shcore::Exception in case of error when writing.\n   */\n  int write(const char *buf, size_t count);\n\n  /**\n   * Kills the child process and returns process' exit code.\n   */\n  int kill();\n\n  /**\n   * Returns the child process handle.\n   * In Linux this needs to be cast to pid_t, in Windows to cast to HANDLE.\n   */\n  uint64_t get_pid() const;\n\n  /**\n   * Wait for the child process to exists and returns its exit code.\n   * If the child process is already dead, wait() just returns.\n   * Returns the exit code of the process.\n   */\n  int wait(unsigned int timeout_ms = 1000);\n\n  /**\n  * Returns the file descriptor write handle (to write child's stdin).\n  * In Linux this needs to be cast to int, in Windows to cast to HANDLE.\n  */\n  uint64_t get_fd_write() const;\n\n  /**\n  * Returns the file descriptor read handle (to read child's stdout).\n  * In Linux this needs to be cast to int, in Windows to cast to HANDLE.\n  */\n  uint64_t get_fd_read() const;\n\n  /**\n   * Closes pipe to process' STDIN in order to notify the process that all\n   * data was sent.\n   */\n  void end_of_write();\n\nprivate:\n  /**\n   * Throws an exception with the specified message, if msg == NULL, the exception's message is specific of the platform error.\n   * (errno in Linux / GetLastError in Windows).\n   */\n  void report_error(const char *msg, const char* prefix = \"\");\n\n  /**\n   * Closes child process and returns process' exit code.\n   *\n   * @throws std::system_error if sending signal to child process fails\n   * @throws std::runtime_error if waiting for process to change state fails\n   *\n   * @return process exit code.\n   */\n  int close();\n\n  bool is_alive;\n};\n\n} // end of namespace mysql_harness\n\n#endif // _PROCESS_LAUNCHER_H_\n"
  },
  {
    "path": "src/harness/include/random_generator.h",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_RANDOM_GENERATOR_INCLUDED\n#define MYSQL_HARNESS_RANDOM_GENERATOR_INCLUDED\n\n#include <string>\n\n#include \"harness_export.h\"\n\nnamespace mysql_harness {\n\nclass HARNESS_EXPORT RandomGeneratorInterface {\n public:\n  enum AlphabetContent: unsigned {\n    AlphabetDigits = 0x1,\n    AlphabetLowercase = 0x2,\n    AlphabetUppercase = 0x4,\n    AlphabetSpecial = 0x8,\n    AlphabetAll = 0xFF\n  };\n\n  /** @brief Generates a random string out of selected alphabet\n   *\n   * @param length length of string requested\n   * @param alphabet_mask bitmasmask indicating which alphabet symbol groups should be\n   *                      used for indentifier generation (see AlphabetContent enum\n   *                      for possible values that can be or-ed)\n   * @return string with the generated random chars\n   *\n   * @throws std::invalid_argument when the alphabet_mask is empty or invalid\n   *\n   */\n  virtual std::string generate_identifier(unsigned length, unsigned alphabet_mask = AlphabetAll) = 0;\n\n  /** @brief Generates a random password that adheres to the STRONG password requirements:\n   *         * contains at least 1 digit\n   *         * contains at least 1 uppercase letter\n   *         * contains at least 1 lowercase letter\n   *         * contains at least 1 special character\n   *\n   * @param length length of requested password (should be at least 8)\n   * @return string with the generated password\n   *\n   * @throws std::invalid_argument when the requested length is less than 8\n   *\n   */\n  virtual std::string generate_strong_password(unsigned length) = 0;\n  virtual ~RandomGeneratorInterface();\n};\n\nclass HARNESS_EXPORT RandomGenerator : public RandomGeneratorInterface {\n public:\n  std::string generate_identifier(unsigned length, unsigned alphabet_mask = AlphabetAll) override;\n  std::string generate_strong_password(unsigned length) override;\n};\n\nclass HARNESS_EXPORT FakeRandomGenerator : public RandomGeneratorInterface {\n public:\n  // returns \"012345678901234567890123...\", truncated to password_length\n  std::string generate_identifier(unsigned length, unsigned) override;\n  // returns \"012345678901234567890123...\", truncated to password_length\n  std::string generate_strong_password(unsigned length) override;\n};\n\n} // namespace mysql_harness\n\n\n#endif // MYSQL_HARNESS_RANDOM_GENERATOR_INCLUDED\n"
  },
  {
    "path": "src/harness/include/socket_operations.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_SOCKETOPERATIONS_INCLUDED\n#define MYSQL_HARNESS_SOCKETOPERATIONS_INCLUDED\n\n#include <chrono>\n#include <stdexcept>\n#include <string>\n#ifdef _WIN32\n#  define WIN32_LEAN_AND_MEAN\n#  include <windows.h>\n#  include <winsock2.h>\n#  include <ws2tcpip.h>\n   typedef ULONG nfds_t;\n   typedef long ssize_t;\n#else\n#  include <errno.h>\n#  include <netdb.h>\n#  include <poll.h>\n#  include <sys/types.h>\n#endif\n\n#include \"harness_export.h\"\n#include \"tcp_address.h\"\n\nnamespace mysql_harness {\n\n/** @class SocketOperationsBase\n * @brief Base class to allow multiple SocketOperations implementations\n *        (at least one \"real\" and one mock for testing purposes)\n */\nclass HARNESS_EXPORT SocketOperationsBase {\n public:\n\n  virtual ~SocketOperationsBase() = default;\n\n  // the following functions are thin wrappers around syscalls\n  virtual ssize_t write(int  fd, void *buffer, size_t nbyte) = 0;\n  virtual ssize_t read(int fd, void *buffer, size_t nbyte) = 0;\n  virtual void close(int fd) = 0;\n  virtual void shutdown(int fd) = 0;\n  virtual void freeaddrinfo(addrinfo *ai) = 0;\n  virtual int getaddrinfo(const char *node, const char *service, const addrinfo *hints, addrinfo **res) = 0;\n  virtual int bind(int fd, const struct sockaddr *addr, socklen_t len) = 0;\n  virtual int socket(int domain, int type, int protocol) = 0;\n  virtual int setsockopt(int fd, int level, int optname,\n                         const void *optval, socklen_t optlen) = 0;\n  virtual int listen(int fd, int n) = 0;\n  virtual int get_errno() = 0;\n  virtual void set_errno(int) = 0;\n  virtual int poll(struct pollfd *fds, nfds_t nfds, std::chrono::milliseconds timeout) = 0;\n\n  /** @brief Wrapper around socket library write() with a looping logic\n   *         making sure the whole buffer got written\n   */\n  virtual ssize_t write_all(int fd, void *buffer, size_t nbyte) {\n    ssize_t written = 0;\n    size_t buffer_offset = 0;\n    while (buffer_offset < nbyte) {\n      if ((written = this->write(fd, reinterpret_cast<char*>(buffer)+buffer_offset, nbyte-buffer_offset)) < 0) {\n        return -1;\n      }\n      buffer_offset += static_cast<size_t>(written);\n    }\n    return static_cast<ssize_t>(nbyte);\n  }\n\n  /**\n   * wait for a non-blocking connect() to finish\n   *\n   * @param sock a connected socket\n   * @param timeout time to wait for the connect to complete\n   *\n   * call connect_non_blocking_status() to get the final result\n   */\n  virtual int connect_non_blocking_wait(int sock, std::chrono::milliseconds timeout) = 0;\n\n  /**\n   * get the non-blocking connect() status\n   *\n   * must be called after connect()ed socket became writable.\n   *\n   * @see connect_non_blocking_wait() and poll()\n   */\n  virtual int connect_non_blocking_status(int sock, int &so_error) = 0;\n\n  /** @brief Exception thrown by `get_local_hostname()` on error */\n  class LocalHostnameResolutionError : public std::runtime_error {\n    using std::runtime_error::runtime_error;\n  };\n\n  /** @brief return hostname of local host */\n  virtual std::string get_local_hostname() = 0;\n};\n\n/** @class SocketOperations\n * @brief This class provides a \"real\" (not mock) implementation\n */\nclass HARNESS_EXPORT SocketOperations : public SocketOperationsBase {\n public:\n  static SocketOperations* instance();\n\n  /** @brief Thin wrapper around socket library write() */\n  ssize_t write(int fd, void *buffer, size_t nbyte) override;\n\n  /** @brief Thin wrapper around socket library read() */\n  ssize_t read(int fd, void *buffer, size_t nbyte) override;\n\n  /** @brief Thin wrapper around socket library close() */\n  void close(int fd)  override;\n\n  /** @brief Thin wrapper around socket library shutdown() */\n  void shutdown(int fd) override;\n\n  /** @brief Thin wrapper around socket library freeaddrinfo() */\n  void freeaddrinfo(addrinfo *ai) override;\n\n  /** @brief Thin wrapper around socket library getaddrinfo() */\n  int getaddrinfo(const char *node, const char *service, const addrinfo *hints, addrinfo **res) override;\n\n  /** @brief Thin wrapper around socket library bind() */\n  int bind(int fd, const struct sockaddr *addr, socklen_t len) override;\n\n  /** @brief Thin wrapper around socket library socket() */\n  int socket(int domain, int type, int protocol) override;\n\n  /** @brief Thin wrapper around socket library setsockopt() */\n  int setsockopt(int fd, int level, int optname,\n                 const void *optval, socklen_t optlen) override;\n\n  /** @brief Thin wrapper around socket library listen() */\n  int listen(int fd, int n) override;\n\n  /**\n   * wrapper around poll()/WSAPoll()\n   */\n  int poll(struct pollfd *fds, nfds_t nfds, std::chrono::milliseconds timeout) override;\n\n  /**\n   * wait for a non-blocking connect() to finish\n   *\n   * call connect_non_blocking_status() to get the final result\n   *\n   * @param sock a connected socket\n   * @param timeout time to wait for the connect to complete\n   */\n  int connect_non_blocking_wait(int sock, std::chrono::milliseconds timeout) override;\n\n  /**\n   * get the non-blocking connect() status\n   *\n   * must be called after connect()ed socket became writable.\n   *\n   * @see connect_non_blocking_wait() and poll()\n   */\n  int connect_non_blocking_status(int sock, int &so_error) override;\n\n  /** @brief return hostname of local host\n   *\n   * @throws `LocalHostnameResolutionError` (std::runtime_error) on failure\n   */\n  std::string get_local_hostname() override;\n\n  /**\n   * get the error-code of the last (socket) operation\n   *\n   * @see errno or WSAGetLastError()\n   */\n  int get_errno() override {\n#ifdef _WIN32\n    return WSAGetLastError();\n#else\n    return errno;\n#endif\n  }\n\n  /**\n   * wrapper around errno/WSAGetLastError()\n   */\n  void set_errno(int e) override {\n#ifdef _WIN32\n    WSASetLastError(e);\n#else\n    errno = e;\n#endif\n  }\n private:\n  SocketOperations(const SocketOperations&) = delete;\n  SocketOperations operator=(const SocketOperations&) = delete;\n  SocketOperations() = default;\n};\n\n} // namespace mysql_harness\n\n#endif // MYSQL_HARNESS_SOCKETOPERATIONS_INCLUDED\n"
  },
  {
    "path": "src/harness/include/tcp_address.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_TCPADDRESS_INCLUDED\n#define MYSQL_HARNESS_TCPADDRESS_INCLUDED\n\n#include <cstdint>\n#include <string>\n\n#include \"harness_export.h\"\n\nnamespace mysql_harness {\n\n/** @brief Defines an IP address with port number  */\nclass HARNESS_EXPORT TCPAddress {\npublic:\n  enum class Family {\n    UNKNOWN = 0,\n    IPV4 = 1,\n    IPV6 = 2,\n    INVALID = 9,\n  };\n\n  TCPAddress(const std::string &address = \"\", uint32_t tcp_port = 0)\n      : addr(address), port(validate_port(tcp_port)), ip_family_(Family::UNKNOWN) {\n    detect_family();\n  }\n\n  /** @brief Copy constructor */\n  TCPAddress(const TCPAddress &other)\n      : addr(other.addr), port(other.port), ip_family_(other.ip_family_) { }\n\n  /** @brief Move constructor */\n  TCPAddress(TCPAddress &&other)\n      : addr(std::move(other.addr)), port(other.port), ip_family_(other.ip_family_) { }\n\n  /** @brief Copy assignment */\n  TCPAddress &operator=(const TCPAddress &other) {\n    std::string *my_addr = const_cast<std::string *>(&this->addr);\n    *my_addr = other.addr;\n    uint16_t *my_port = const_cast<uint16_t *>(&this->port);\n    *my_port = other.port;\n    Family *my_family = const_cast<Family *>(&this->ip_family_);\n    *my_family = other.ip_family_;\n    return *this;\n  }\n\n  /** @brief Move assignment */\n  TCPAddress &operator=(TCPAddress &&other) {\n    std::string *my_addr = const_cast<std::string *>(&this->addr);\n    *my_addr = other.addr;\n    uint16_t *my_port = const_cast<uint16_t *>(&this->port);\n    *my_port = other.port;\n    Family *my_family = const_cast<Family *>(&this->ip_family_);\n    *my_family = other.ip_family_;\n    return *this;\n  }\n\n  /** @brief Returns the address as a string\n   *\n   * Returns the address as a string.\n   *\n   * @return instance of std::string\n   */\n  std::string str() const;\n\n  /** @brief Compares two addresses for equality\n   *\n   */\n  friend bool operator==(const TCPAddress &left, const TCPAddress &right) {\n    return (left.addr == right.addr) && (left.port == right.port);\n  }\n\n  /**\n   * @brief Function for performing comparision of TCPAddresses\n   */\n  friend bool operator<(const TCPAddress& left, const TCPAddress& right) {\n    if (left.addr < right.addr) return true;\n    else if (left.addr > right.addr) return false;\n    return left.port < right.port;\n  }\n\n  /** @brief Returns whether the TCPAddress is valid\n   *\n   * Returns whether the address and port are valid. This function also\n   * detects the family when it was still Family::UNKNOWN.\n   */\n  bool is_valid() noexcept;\n\n  /** @brief Returns whether the TCPAddress is IPv4\n   *\n   * Returns true when the address is IPv4; false\n   * when it is IPv6.\n   */\n  bool is_ipv4();\n\n  template<Family T>\n  bool is_family() {\n    if (ip_family_ == T) {\n      return true;\n    }\n    return false;\n  }\n\n  /* @brief Returns the address family\n   *\n   * returns TCPAddress::Family\n   */\n  Family get_family() const noexcept {\n    return ip_family_;\n  }\n\n  /** @brief Network name IP */\n  const std::string addr;\n  /** @brief TCP port */\n  const uint16_t port;\n\nprivate:\n  /** @brief Initialize the address family */\n  void detect_family() noexcept;\n\n  /** @brief Validates the given port number */\n  uint16_t validate_port(uint32_t tcp_port);\n\n  /** @brief Address family for this IP Address */\n  Family ip_family_;\n};\n\n} // namespace mysql_harness\n\n#endif // MYSQL_HARNESS_TCPADDRESS_INCLUDED\n"
  },
  {
    "path": "src/harness/include/unique_ptr.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_UNIQUEPTR_INCLUDED\n#define MYSQL_HARNESS_UNIQUEPTR_INCLUDED\n\n#include <assert.h> // <cassert> is flawed: assert() lands in global namespace on Ubuntu 14.04, not std::\n#include <functional>\n#include <memory>\n\nnamespace mysql_harness {\n\n/* @brief: improved std::unique_ptr super-class\n *\n * std::unique_ptr has one problem: it's tedious to use with custom deleters.\n * This class is a convenience super-class, which makes working with unique_ptr\n * easier. Advantages:\n *\n *   1. Improved constructor for easier type declaration (deleter type is\n *      automatically resolved):\n *\n *        UniquePtr<Foo> foo(new_foo(), foo_deleter);\n *        UniquePtr<Foo> bar = std::move(foo);\n *\n *      instead of:\n *\n *        std::unique_ptr<Foo, decltype(foo_deleter)> foo(new_foo(), foo_deleter);\n *        std::unique_ptr<Foo, decltype(foo_deleter)> bar = std::move(foo);\n *\n *\n *\n *   2. UniquePtr constructor ALWAYS defines a custom deleter, which is a must if we're\n *      passing unique_ptr accross DLL boundaries (the idea is to release the memory\n *      within the same DLL in which it was allocated). However, if all we need is a\n *      default deleter, it will implicitly define it for us:\n *\n *        UniquePtr<Foo> foo(new_foo()); // std::default_delete is default 2nd parameter\n *\n *      instead of:\n *\n *        std::unique_ptr<Foo, std::default_delete> foo(new_foo(), std::default_delete());\n *\n *\n *\n *   3. In debug builds, it offers a safety feature to warn the developer, if (s)he\n *      forgets about the custom deleter. See comments above release() method\n */\ntemplate <typename T>\nclass UniquePtr : public std::unique_ptr<T, std::function<void(T*)>> {\n public:\n  UniquePtr() {}\n\n  UniquePtr(T* ptr, std::function<void(T*)> deleter = std::default_delete<T>())\n    : std::unique_ptr<T, std::function<void(T*)>>(ptr, deleter)\n  {}\n\n  UniquePtr(const UniquePtr<T>&) = delete;\n  UniquePtr(UniquePtr<T>&& other)\n    : std::unique_ptr<T, std::function<void(T*)>>::unique_ptr(std::move(other))\n    #ifndef NDEBUG\n    , get_deleter_called_(other.get_deleter_called_)\n    #endif\n  {}\n\n  UniquePtr& operator=(const UniquePtr<T>&) = delete;\n  UniquePtr& operator=(UniquePtr<T>&& other) {\n    #ifndef NDEBUG\n    get_deleter_called_ = other.get_deleter_called_;\n    #endif\n    std::unique_ptr<T, std::function<void(T*)>>::operator=(std::move(other));\n    return *this;\n  }\n\n  // It is typical for developers never to worry about how they create and how they delete objects.\n  // Since we're using custom deleter, we want to make sure that the developer doesn't forget about that.\n  // We want to protect against a situation like so:\n  //\n  //   // some_place_1\n  //   UniquePtr<A> u_ptr(new A, my_custom_deleter(ptr); });\n  //\n  //   // some_place_2\n  //   A* raw_ptr = u_ptr.release();  // dev forgot that u_ptr also stores the deleter to erase this object\n  //   ...\n  //   ...\n  //   delete raw_ptr;  // KABOOOM!!!\n  //\n  // So the least we can do, is try to remind the developer if we notice the dev didn't bother fetching\n  // the deleter.\n  //\n  #ifndef NDEBUG\n    T* release() {\n      assert(get_deleter_called_);  // do you know what you're doing? (how are you going to delete this object?)\n      return std::unique_ptr<T, std::function<void(T*)>>::release();\n    }\n\n    typename UniquePtr<T>::deleter_type get_deleter() {\n      get_deleter_called_ = true;   // dev didn't forget about the deleter, good!\n      return std::unique_ptr<T, std::function<void(T*)>>::get_deleter();\n    }\n\n   private:\n    bool get_deleter_called_ = false;\n  #endif\n};\n\n} // namespace mysql_harness\n#endif //#ifndef MYSQL_HARNESS_UNIQUEPTR_INCLUDED\n"
  },
  {
    "path": "src/harness/internal/README.md",
    "content": "MySQL Harness - Internal notes\n==============================\n\nThese are internal notes regarding the MySQL Harness. They are mostly\nrelated to procedural issues for managing the repository and code that\nare not intended (nor interesting) for the public.\n\nThese notes does not (and should not) contain any internal or\nconfidential information.\n\nFor the avoidance of doubt, this particular copy of the software\n(including the files in this directory) is released under the version\n2 of the GNU General Public License.\n\nCopyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n\nInternal Files\n--------------\n\nFiles that are not going to be part of a release should normally be\nplaced in the `internal/` directory. If necessary, they can be placed\nelsewhere but Release Engineering need to know about these files.\n\nThe file `exclude-from-release.txt` contain files and directories that\nshould be excluded from the release and not uploaded to, for example,\nGitHub. Please make sure to add internal files here.\n\n\nCreating feature and issue branches\n-----------------------------------\n\nFeature branches are almost always based on the `master` branch. To\ncreate a feature branch, use the command:\n\n    git checkout -b feature/my-precious master\n\nIf the current branch is already `master`, you can omit it from the\nline above.\n\nTo activate pre-commit hooks it is necessary to copy them from the\n`internal` directory to the `.git` directory:\n\n    cp internal/hooks/pre-commit .git/hooks\n\nThere is more information about what the Git hooks below.\n\n\nPreparations for Code Review\n----------------------------\n\nPatches are usually uploaded to ReviewBoard and reviewed there. Before\nuploading the patch, ensure that:\n\n- It build in all build configurations on your machine.\n\n- There are no code style issues\n\nTo check that it builds in all build configurations on your platform\nthere is a script available in the directory `internal/checks`.\n\n    python internal/checks/build_all.py\n\nIf you have installed the pre-commit hook then committing will run the\npre-commit hooks and catch mistakes that can be caught by the\nautomated checks.\n\nOnce the patch is committed, you can generate a diff between the\n`master` branch and the committed work using:\n\n    git diff master..HEAD >my-precious-1.diff\n\n\nPreparations for Merging\n------------------------\n\nWhen it is time to merge the branch with either the master branch or\none of the version branches, please\n[rebase and squash](https://help.github.com/articles/about-git-rebase/)\nthe patches in the branch before pushing to the repository to combine\nseveral patches for the same issue. Each feature and each issue should\nbe one single patch.\n\nYou can rebase and squash the branch using:\n\n    git rebase -i master\n\nor\n\n    git rebase -i master feature/my-precious\n\nif your current branch is already `feature/my-precious`.\n\n\nCoding Style\n------------\n\nFor the code we follow the\n[Google C++ Style Guide](http://google.github.io/styleguide/cppguide.html),\nwith some exceptions. To check that the code follow the style guide,\nyou can install `cpplint` in your path and CMake will automatically\nconstruct a `check` target that will run `cpplint` on the source\nfiles. When looking for `cpplint` it will both look for `cpplint` and\n`cpplint.py`.\n\n### Git Hooks ###\n\nThere are a few useful hooks in this directory, but you have to set up\nusing these explicitly using the following line:\n\n    git config core.hooksPath internal/hooks\n\nOr if your version (before 2.9) of Git does not support\n`core.hooksPath`, you can either link or copy the hook files:\n\n    ln -s internal/hooks/* .git/hooks\n    cp internal/hooks/* .git/hooks\n\nThere is a pre-commit hook that will run the equivalent of `make\ncheck` before allowing the commit to proceed. This will catch any\ncoding-style related issues before a patch is created. If you do not\nwant to run this check when committing (for example, because this is\njust an intermediate commit), you can disable the checking using the\n`--no-verify` option when committing.\n\nSince the pre-commit hook can be circumvented, there is also a\n`update` hook that is used by the repository. It will not accept any\npatches into the master branch or the version branches that do not\npass the equivalent of `make check`.\n"
  },
  {
    "path": "src/harness/internal/checks/build_all.py",
    "content": "#!/usr/bin/python\n\nimport csv\nimport itertools\nimport os\nimport shutil\nimport subprocess\nimport sys\n\nfrom subprocess import check_output\n\nBUILD_DIR = \"BUILD\"\n\ndef do_call(cmd):\n    do_dot()\n    check_output(cmd, stderr=subprocess.STDOUT, cwd=BUILD_DIR)\n\ndef do_dot():\n    sys.stdout.write(\".\")\n    sys.stdout.flush()\n\ndef cmake(options):\n    cmd = [\"cmake\", \"..\"]\n    cmd.extend(\"-D{0}={1}\".format(k, v) for k,v in options.items())\n    do_call(cmd)\n\ndef do_build(enable_tests, build_type, build_program, harness_name=None, with_gmock=None):\n    args = { 'ENABLE_TESTS': 'yes' if enable_tests else 'no' }\n    if build_type:\n        args['CMAKE_BUILD_TYPE'] = build_type\n    if build_program:\n        args['ENABLE_HARNESS_PROGRAM'] = 'yes'\n    if harness_name:\n        args['HARNESS_NAME'] = harness_name\n    if with_gmock:\n        args['WITH_GMOCK'] = with_gmock\n\n    shutil.rmtree(BUILD_DIR, ignore_errors=True)\n    os.mkdir(BUILD_DIR)\n    do_dot()\n    cmake(args)\n    null = open(os.devnull, 'w')\n    do_call(['make', '-j4'])\n    if enable_tests:\n        do_call(['make', 'test'])\n\ndef _pretty(val):\n    if val is None:\n        return ''\n    if isinstance(val, bool):\n        return 'Yes' if val else 'No'\n    return str(val)\n\ndef write_table(columns, titles, rows):\n    header = [titles[col] for col in columns]\n    rows_with_header = [header]\n    rows_with_header.extend(rows)\n    width = [max(len(str(r)) for r in col) for col in zip(*rows_with_header)]\n    def _line(row):\n        return \" \".join(\n            \"{:>{}}\".format(x, width[i]) for i, x in enumerate(row)\n        )\n\n    lines = [_line(header)]\n    lines.append(_line(['-' * w for w in width]))\n    for row in rows:\n        lines.append(_line(_pretty(c) for c in row))\n    print \"\\n\".join(lines)\n\ndef main():\n    facets = [\n        [False, True],              # Enable tests or not\n        ['Debug', 'Release'],       # Build type\n        [False, True],              # Build harness program\n        [None, 'oddity'],           # Harness name to use\n        [None, '/opt/gmock-1.7.0'], # GMock source code to use\n    ]\n\n    columns = ['test', 'btype', 'program', 'name', 'gmock', 'result']\n    titles = {\n        'test': 'Build Tests',\n        'btype': 'Build Type',\n        'program': 'Build Program',\n        'name': 'Harness Name',\n        'gmock': 'GMock Root',\n        'result': 'Result'\n    }\n    rows = []\n    sys.stdout.write(\"Building...\")\n    for testing, btype, build_program, name, gmock in itertools.product(*facets):\n        result = {\n            'test': testing,\n            'btype': btype,\n            'program': build_program,\n            'name': name,\n            'gmock': gmock\n        }\n        try:\n            do_build(testing, btype, build_program, name, gmock)\n            result['result'] = 'OK'\n        except subprocess.CalledProcessError as err:\n            result['result'] = 'FAILED'\n            result['errors'] = err.output\n        rows.append([result[c] for c in columns])\n    sys.stdout.write(\"\\n\")\n\n    # Print the summary table\n    write_table(columns, titles, rows)\n\n    # Print any errors that occured\n    for row in rows:\n        if 'errors' in row:\n            for col in columns:\n                print \"{0}: {1}\".format(title[col], row[col])\n            print \"Errors:\"\n            print row['errors']\n\n    sys.exit(0)\n\nif __name__ == '__main__':\n    main()\n"
  },
  {
    "path": "src/harness/internal/exclude-from-release.txt",
    "content": "CPPLINT.cfg\n/internal/\n"
  },
  {
    "path": "src/harness/internal/hooks/pre-commit",
    "content": "#!/bin/sh\n\nif git rev-parse --verify HEAD >/dev/null 2>&1\nthen\n\tagainst=HEAD\nelse\n\t# Initial commit: diff against an empty tree object\n\tagainst=4b825dc642cb6eb9a060e54bf8d69288fbee4904\nfi\n\n# Redirect output to stderr.\nexec 1>&2\n\n# We do not allow non-ASCII filenames.\nfiles_with_non_ascii=$(\n    git diff --cached --name-only --diff-filter=A -z $against |\n    LC_ALL=C tr -d '[ -~]\\0' |\n    wc -c\n)\nif [ $files_with_non_ascii != 0 ]; then\n    echo \"Error: Attempt to add a non-ASCII file name. This can cause problems\"\n    echo \"if you want to work with people on other platforms.\"\n    exit 1\nfi\n\n# If there are whitespace errors, print the offending file names and fail.\ngit diff-index --check --cached $against -- || exit 1\n\n# Find cpplint and run it on all source and header files\ncpplint=`which cpplint cpplint.py | head -1`\nif [ -z \"$cpplint\" ]; then\n    echo \"Command 'cpplint' or 'cpplint.py' not found in path\"\n    exit 1\nfi\n\ndirs='harness plugins shared examples'\nfind $dirs '(' -name '*.cc' -o -name '*.h' ')' \\\n    -exec $cpplint {} + >/tmp/pre-commit-$$.txt 2>&1\nif [ $? -ne 0 ]; then\n    grep -v '^Done\\|^Total' /tmp/pre-commit-$$.txt\n    rm /tmp/pre-commit-$$.txt\n    exit 1\nelse\n    rm /tmp/pre-commit-$$.txt\nfi\n"
  },
  {
    "path": "src/harness/internal/hooks/pre-receive",
    "content": "#!/bin/bash\n\n# Check for basic programs\n\n# Find cpplint and run it on all source and header files\nlint=`which cpplint cpplint.py | head -1`\nif [ -z \"$lint\" ]; then\n    echo \"Command 'cpplint' or 'cpplint.py' not found in path\"\n    exit 1\nfi\n\nrepository=$PWD\n\n# check-deletion <oldrev> <newrev> <refspec>\n#\n# True if no critical branch is deleted.\nfunction check-deletion() {\n    case $3 in\n        refs/heads/master|refs/heads/version/*)\n            return $(test `expr $2 : \"0*$\"` -eq 0)\n            ;;\n    esac\n    return 0\n}\n\n# check-branch-name <oldrev> <newrev> <refspec>\n#\n# True if branch name was OK.\nfunction check-branch-name () {\n    case $3 in\n        refs/heads/*)           # Reference to real branch\n            branch=${3##refs/heads/}\n            case $branch in\n                master|feature/*|issue/*)\n                    return 0\n                    ;;\n                version/*) # Version branch\n                    return $(expr $branch : \"version/[0-9]\\+.[0-9]\\+\")\n                    ;;\n                *)\n                    return 1\n                    ;;\n            esac\n            ;;\n    esac\n}\n\n# check-filenames <oldrev> <newrev> <refspec>\n#\n# Check that all file names are valid and acceptable.\nfunction check-filenames () {\n    files=$(\n        git diff --name-only --diff-filter=A -z $1 $2 |\n        LC_ALL=C tr -d '[ -~]\\0' |\n        wc -c\n    )\n    test $files -eq 0\n}\n\n# check-coding-style <oldrev> <newrev> <refspec>\n#\n# Check that the coding style is followed. We do this by checking out\n# a temporary tree.\nfunction check-coding-style () (\n    local -r newrev=$2\n    local -r branch=${3##refs/heads/}\n    local -r safename=`echo $branch | tr '/' '-'`\n    local -r workdir=`mktemp --directory --tmpdir $safename.XXX`\n    local -r dirs='harness plugins shared examples'\n    local -r tmpfile=`mktemp --tmpdir`\n    local exit_code=0\n\n    # Ignore references that are not branches\n    if [ $(expr $3 : \"refs/heads/\") -eq 0 ]; then\n        return 0\n    fi\n\n    # Create the work directory and check out a temporary version of\n    # the tree.\n    git --git-dir=$repository --work-tree=$workdir checkout $newrev -f -q -- ./\n    cd $workdir\n\n    # Run Cpplint on all C++ files and print the offending lines, if\n    # there are any.\n    find $dirs '(' -name '*.cc' -o -name '*.h' ')' \\\n        -exec $lint {} + >$tmpfile 2>&1\n    exit_code=$?\n    if [ $exit_code -ne 0 ]; then\n        grep -v '^Done\\|^Total' $tmpfile\n    fi\n    rm $tmpfile\n    rm -rf $workdir\n    return $exit_code\n)\n\nfunction check-branch () {\n    check-deletion \"$@\" || return 1\n    check-branch-name \"$@\" || return 1\n    check-filenames \"$@\" || return 1\n\n    # Check for trailing whitespace on lines\n    git diff --check $1 $2 || return 1\n\n    check-coding-style \"$@\" || return 1\n}\n\nexit_code=0\n\nwhile read oldrev newrev refname; do\n    case $refname in\n        refs/heads/*)\n            branch=${refname##refs/heads/}\n            if ! check-branch $oldrev $newrev $refname; then\n                exit_code=1\n                continue\n            fi\n            ;;\n        *)\n            ;;\n    esac\ndone\n\nexit $exit_code\n"
  },
  {
    "path": "src/harness/internal/hooks/update",
    "content": "#!/bin/sh\n\n# This script takes three arguments: the name of the reference\n# (branch), the SHA-1 that reference pointed to before the push, and\n# the SHA-1 the user is trying to push.\nrefname=$1\noldrev=$2\nnewrev=$3\nrepodir=`pwd`\n\n# Redirect output to stderr.\nexec 1>&2\n\n# Ignore branches that are not version branches or the master.\ncase $refname in\n    refs/heads/master)\n        branch=${refname##refs/heads/}\n        worktree=/tmp/$branch-update-$$\n        ;;\n    refs/heads/version/*)\n        branch=${refname##refs/heads/}\n        worktree=/tmp/`echo $branch | tr '/' '-'`-update-$$\n        ;;\n    *)\n        exit 0\n        ;;\nesac\n\n# Check out a temporary version of the tree and work there.\ngit clone -q -b $branch $repodir $worktree\ncd $worktree\n\n# Need to reset GIT_DIR since it assumes a bare repository and we have\n# now switched to a working tree.\nGIT_DIR=.git/\n\n# We do not allow non-ASCII filenames.\nfiles_with_non_ascii=`git diff --cached --name-only --diff-filter=A -z $oldrev | LC_ALL=C tr -d '[ -~]\\0' | wc -c`\n\nif [ $files_with_non_ascii -ne 0 ]; then\n    echo \"Error: Attempt to add a non-ASCII file name. This can cause problems\"\n    echo \"if you want to work with people on other platforms.\"\n    exit 1\nfi\n\n# If there are whitespace errors, print the offending file names and fail.\ngit diff-index --check --cached $oldrev -- || exit 1\n\n# Find cpplint and run it on all source and header files\ncpplint=`which cpplint cpplint.py | head -1`\nif [ -z \"$cpplint\" ]; then\n    echo \"Command 'cpplint' or 'cpplint.py' not found in path\"\n    exit 1\nfi\n\ndirs='harness plugins shared examples'\nfind $dirs '(' -name '*.cc' -o -name '*.h' ')' \\\n    -exec $cpplint {} + >/tmp/pre-commit-$$.txt 2>&1\nif [ $? -ne 0 ]; then\n    grep -v '^Done\\|^Total' /tmp/pre-commit-$$.txt\n    rm /tmp/pre-commit-$$.txt\n    exit 1\nelse\n    rm /tmp/pre-commit-$$.txt\nfi\n"
  },
  {
    "path": "src/harness/plugin.h.in",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_PLUGIN_INCLUDED\n#define MYSQL_HARNESS_PLUGIN_INCLUDED\n\n#include \"harness_export.h\"\n\n#include <cstdlib>\n#include <cstdint>\n\nnamespace mysql_harness {\n\n/* Forward declarations */\nstruct AppInfo;\nclass Config;\nclass ConfigSection;\nclass PluginFuncEnv;\n\n/** @defgroup Harness_API Harness API\n *\n * Harness API provides a set of functions that can be called from 4 plugin\n * functions (`start()`, `stop()`, `init()`, `deinit()`). Each call requires\n * `PluginFuncEnv*` as first argument - this is an opaque pointer that is passed\n * to plugin function in its argument list.\n *\n * @note Not all API functions can be called from all plugin functions. See\n * description of each function for details.\n *\n * @{\n */\n\n/**\n * This is a list of pre-defined error types, which can be used in\n * set_error() API call. Select the one that best-describes your situation.\n * As a rule of thumb, use one of kConfig* if the error occurs due to\n * configuration issue, or kRuntimeError otherwise.\n *\n * Since plugin functions are not allowed to throw, it is recommended to\n * surround your plugin function code with try/catch blocks, and catching\n * (in addition to any specific exceptions) all exceptions\n * (using the \"catch (...) { .. }\" block). In this catch block, using\n * kUndefinedError is recommended.\n *\n * @note There is another enum missing from table below (kNoError),\n * it is internal to MySQL Router, DO NOT USE it in your plugin.\n */\nenum HARNESS_EXPORT ErrorType {\n  // internal to MySQL Router project, DO NOT USE THIS in your plugin\n  kNoError = 0,             // uninitialized error value\n\n  // API\n  kRuntimeError = 1,        /**< runtime error */\n  kConfigInvalidArgument,   /**< configuration error */\n  kConfigSyntaxError,       /**< configuration syntax error */\n  kUndefinedError,          /**< typically set from plugin's general safeguard\n                                 ('catch (...) {..}' block) */\n};\n\n/** @brief Returns error to Harness\n *\n * Function callable from: `init()`, `start()`, `stop()`, `deinit()`\n *\n * Plugin functions cannot throw nor return a value. To communicate failure,\n * this function should be called.\n *\n * Calling this function not only passes the error type and string back to\n * Harness, but also implies that the function has failed. The converse is also\n * true: not calling this function prior to exiting the function implies\n * success.  This distinction is important, because Harness may take certain\n * actions based on the status returned by each function.\n *\n * @param env Pointer to PluginFuncEnv object passed to plugin function\n * @param error_type One of the pre-defined error codes\n * @param fmt format-string of error-msg to get logged\n * It can be NULL, but it's recommended to provide a meaningful message.\n */\nvoid HARNESS_EXPORT set_error(mysql_harness::PluginFuncEnv* env,\n                    mysql_harness::ErrorType error_type,\n                    const char* fmt, ...) noexcept\n#ifdef __GNUC__\n__attribute__((format(printf, 3, 4)))\n#endif\n  ;\n\n/** @brief Checks whether plugin shutdown was requested\n *\n * Function callable from: `start()`\n *\n * Since plugin is running in its own thread (inside its `start()` function),\n * it needs to be notified when Harness wants it to shut down.  Harness\n * provides two notification mechanisms: blocking and non-blocking. The plugin\n * developer can choose the one that is most convenient.\n *\n * This is the non-blocking version. It should be regularly polled by `start()`,\n * and upon returning false, `start()` should shut down the plugin and exit.\n *\n * @param env Pointer to PluginFuncEnv object passed to plugin function\n * @return \"running\" flag. If true, `start()` may continue running, if false,\n * `start()` should shut down\n */\nbool HARNESS_EXPORT is_running(const mysql_harness::PluginFuncEnv* env) noexcept;\n\n/** @brief Blocks until shutdown is requested (or optionally timeout)\n *\n * Function callable from: `start()`\n *\n * Since plugin is running in its own thread (inside its `start()` function),\n * it needs to be notified when Harness wants it to shut down.  Harness\n * provides two notification mechanisms: blocking and non-blocking. The plugin\n * developer can choose the one that is most convenient.\n *\n * This is the blocking version. It is a responsive and efficient functional\n * equivalent of:\n * @code\n *\n *   while (is_running(env)) {\n *     // sleep a little bit or break on timeout\n *   }\n *\n * @endcode\n * @param env Pointer to PluginFuncEnv object passed to plugin function\n * @param milliseconds Timeout in milliseconds, 0 = wait forever\n * @return true if stop was requested, false on timeout\n */\nbool HARNESS_EXPORT wait_for_stop(const mysql_harness::PluginFuncEnv* env,\n                                  uint32_t milliseconds) noexcept;\n\n/** @brief Clears \"running flag\" to induce plugin shutdown\n *\n * Function callable from: `start()`\n *\n * There may be occassions when the plugin needs to request its own shutdown\n * (typically after it detects an error). In such case, this function should\n * be called - it will set the \"running\" flag to false. Subsequent calls to\n * is_running() and wait_for_stop() will reflect this new setting.\n *\n * @note This only sets \"running\" flag for the plugin that calls this. Other\n * plugins have their own \"running\" flags, which means they are unaffected.\n *\n * @param env Pointer to PluginFuncEnv object passed to plugin function\n */\n\nvoid HARNESS_EXPORT clear_running(mysql_harness::PluginFuncEnv* env) noexcept;\n\n/** @brief Retrieves information from Harness\n *\n * function callable from: `init()`, `deinit()`\n *\n * This function returns an AppInfo object, which provides further plugin environment\n * information.\n *\n * @param env Pointer to env object passed to plugin function\n * @return Pointer to AppInfo object\n */\nconst HARNESS_EXPORT AppInfo* get_app_info(const mysql_harness::PluginFuncEnv* env) noexcept;\n\n/** @brief Retrieves information from Harness\n *\n * function callable from: `start()`, `stop()`\n *\n * This function returns a ConfigSection object, which provides further\n * plugin environment information.\n *\n * @param env Pointer to PluginFuncEnv object passed to plugin function\n * @return Pointer to ConfigSection object\n */\nconst HARNESS_EXPORT ConfigSection* get_config_section(const mysql_harness::PluginFuncEnv* env) noexcept;\n\n/**@}*/\n\n\n\n/**\n * Structure with information about the harness.\n *\n * @ingroup Loader\n *\n * This structure is made available to plugins so that they can get\n * information about the plugin harness.\n *\n * @note We are intentionally using C calls here to avoid issues with\n * symbol conversions and calling conventions. The file can be\n * included both as a C and C++ file.\n *\n */\n\nstruct AppInfo {\n  /**\n   * Program name.\n   *\n   * Name of the application.\n   */\n\n  const char *program;\n\n  /**\n   * Directory name for plugins.\n   *\n   * Name of the directory where extensions can be found and it\n   * depends on how the harness was installed. In a typical\n   * installation with installation prefix `/` it will be\n   * `/var/lib/mysql/<name>`.\n   */\n\n  const char *plugin_folder;\n\n\n  /**\n   * Directory name for log files.\n   *\n   * Name of the directory where log files should be placed. In a\n   * typical installation with installation prefix `/` this will be\n   * `/var/log/<name>`.\n   */\n\n  const char *logging_folder;\n\n  /**\n   * Directory name for run files.\n   *\n   * Name of the directory where run files should be placed. In a\n   * typical installation with installation prefix `/` this will be\n   * `/var/run/<name>`.\n   */\n\n  const char *runtime_folder;\n\n  /**\n   * Directory name for data files.\n   *\n   * Name of the directory where data files should be placed. In a\n   * typical installation with installation prefix `/` this will be\n   * `/var/lib/<name>`.\n   */\n\n  const char *data_folder;\n\n\n  /**\n   * Directory name for configuration files.\n   *\n   * Name of the directory where run files should be placed. In a\n   * typical installation with installation prefix `/` this will be\n   * `/etc/<name>`.\n   */\n\n  const char *config_folder;\n\n\n  /**\n   * Configuration information.\n   */\n\n  const Config* config;\n\n};\n\n\n/**\n * Structure containing information about the plugin.\n *\n * @ingroup Loader\n *\n * The name of the plugin is give by the filename.\n */\n\nstruct Plugin {\n  /**\n   * Version of the plugin interface the plugin was built for.\n   *\n   * This field contain the ABI version the plugin was built for and\n   * is checked when loading the plugin to determine if the structure\n   * can be safely read. It shall normally be set to\n   * `PLUGIN_ABI_VERSION`, which is the version of the ABI that is\n   * being used.\n   *\n   * The least significant byte contain the minor version, the second\n   * least significant byte contain the major version of the\n   * interface. The most significant two bytes are unused and should\n   * be set to zero.\n   *\n   * @note Whenever new callbacks are added but none of the existing\n   * ones are changed, the minor version will be stepped. If the\n   * existing functions are changed in an incompatible way (something\n   * that could break the calling conventions for a platform), the\n   * major version will be stepped. Typically, the major version have\n   * to be stepped whenever parameters to existing functions are\n   * changed, but there are exceptions.\n   *\n   * @see PLUGIN_ABI_VERSION\n   */\n\n  uint32_t abi_version;\n\n\n  /**\n   * Architecture descriptor.\n   *\n   * A descriptor for the architecture the plugin was build\n   * for. Normally, `ARCHITECTURE_DESCRIPTOR` should be used.\n   *\n   * The architecture descriptor is a string that contain information\n   * about the architecture the plugin is being compiled with. It need\n   * to match the architecture of the harness.\n   *\n   * The architecture is a C string containing four slash-separated\n   * fields (or a star to denote that this is not checked):\n   *\n   * - CPU\n   * - Operating system\n   * - Naming scheme and calling conventions (essentially the compiler\n   *   and version of compiler being used to build the solution).\n   * - Runtime\n   *\n   * @see ARCHITECTURE_DESCRIPTOR\n   */\n\n  const char* arch_descriptor;\n\n\n  /**\n   * Brief description of plugin, to show in listings.\n   */\n\n  const char *brief;\n\n\n  /**\n   * Plugin version.\n   *\n   * Version of the plugin, given as a version number.\n   *\n   * @see VERSION_NUMBER\n   */\n  uint32_t plugin_version;\n\n  /**\n   * Array of names of required plugins.\n   *\n   * Length is given as the number of elements in the array and the\n   * array contain the names of the required plugins as C strings.\n   *\n   * A typical use is:\n   * @code\n   * const char *requires[] = {\n   *   \"first\",\n   *   \"second\",\n   * };\n   *\n   * Plugin my_plugin = {\n   *   ...\n   *   sizeof(requires)/sizeof(*requires),\n   *   requires,\n   *   ...\n   * };\n   * @endcode\n   */\n\n  size_t requires_length;\n  const char **requires;\n\n\n  /**\n   * Array of names of plugins it conflicts with.\n   *\n   * The array is defined in a similar way to how the `requires` array\n   * is defined.\n   */\n\n  size_t conflicts_length;\n  const char **conflicts;\n\n\n  /**\n   * Module initialization function.\n   *\n   * This function is called after the module is loaded. The pointer\n   * can be NULL, in which case no initialization takes place.\n   *\n   * @pre All modules that is in the list of required modules have\n   * their @c init() function called before this modules init\n   * function.\n   *\n   * @param env Pointer to PluginFuncEnv object, which is the basis of\n   * all communication with harness. Please see its documentation\n   * for more information. Particularly, calling get_app_info(env)\n   * will provide information about harness this module was loaded into.\n   *\n   * @note This function must not throw (it is not declared with 'noexcept'\n   * due to certain technical limitations)\n   */\n\n  void (*init)(PluginFuncEnv* env); // not allowed to throw!\n\n\n  /**\n   * Module deinitialization function.\n   *\n   * This function is called after module threads have exited but\n   * before the module is unloaded.\n   *\n   * @pre All `deinit` functions in modules will required by this\n   * module are called after the `deinit` function of this module\n   * have exited.\n   *\n   * @param env Pointer to PluginFuncEnv object, which is the basis of\n   * all communication with harness. Please see its documentation\n   * for more information. Particularly, calling get_app_info(env)\n   * will provide information about harness this module was loaded into.\n   *\n   * @note This function must not throw (it is not declared with 'noexcept'\n   * due to certain technical limitations)\n   */\n\n  void (*deinit)(PluginFuncEnv* env); // not allowed to throw!\n\n\n  /**\n   * Module thread start function.\n   *\n   * If this field is non-NULL, the plugin will be assigned a new\n   * thread and the start function will be called. The start functions\n   * of different plugins are called in an arbitrary order, so no\n   * expectations on the start order should be made.\n   * This function must respect harness' notification to stop running,\n   * and exit when notified. It shall regularly poll a \"running\" flag\n   * exposed by harness (see is_running() and wait_for_stop()), it may\n   * also clear this flag via clear_running() if it needs to.\n   *\n   * @param env Pointer to PluginFuncEnv object, which is the basis of\n   * all communication with harness. Please see its documentation\n   * for more information. Particularly, calling get_config_section(\n   * env) will provide pointer to the section that is being started.\n   * You can find both the name and the key in this section object.\n   *\n   * @note This function must not throw (it is not declared with 'noexcept'\n   * due to certain technical limitations)\n   */\n\n  void (*start)(PluginFuncEnv* env);  // not allowed to throw!\n\n\n  /**\n   * Module thread stop (notification) function.\n   *\n   * This function is called when stopping start(). Since start() runs\n   * in a different thread, no assumptions should be made on whether\n   * stop() runs before, during or after start() exits. Also, the\n   * stop() functions of different plugins are called in an arbitrary\n   * order, so no expectations on stop() calling order should be made.\n   *\n   * @note this function does not cause the plugin running start() to\n   * exit - harness uses another mechanism to facilitate that. Instead,\n   * this function is called *in addition* to stopping the start() function,\n   * as a courtesy notification call, should that be useful.\n   *\n   * @note unlike start(), which runs in its own thread, stop() runs in\n   * harness' thread\n   *\n   * @note under certain circumstances, `stop()` may overlap execution\n   * with `start()`, or even be called before `start()`. stop() must be\n   * able to deal with all such cases.\n   *\n   * @param env Pointer to PluginFuncEnv object, which is the basis of\n   * all communication with harness. Please see its documentation\n   * for more information. Particularly, calling get_config_section(\n   * env) will provide pointer to the section that is being started.\n   * You can find both the name and the key in this section object.\n   *\n   * @note This function must not throw (it is not declared with 'noexcept'\n   * due to certain technical limitations)\n   */\n\n  void (*stop)(PluginFuncEnv* env); // not allowed to throw!\n};\n\n\n/**\n * Current version of the library.\n *\n * @ingroup Loader\n *\n * This constant is the version of the plugin interface in use. This\n * should be used when initializing the module structure.\n *\n * @see Plugin\n */\n\nconst uint32_t PLUGIN_ABI_VERSION = 0x0200;\n\n/**\n * Default architecture descriptor.\n *\n * @ingroup Loader\n */\nconst char* const ARCHITECTURE_DESCRIPTOR = \"@MYSQL_HARNESS_ARCH_CPU@/@MYSQL_HARNESS_ARCH_OS@/@MYSQL_HARNESS_ARCH_COMPILER@/@MYSQL_HARNESS_ARCH_RUNTIME@\";\n\n/**\n * Macro to create a version number from a major, minor and patch version.\n *\n * @ingroup Loader\n */\n#define VERSION_NUMBER(MAJ, MIN, PAT) \\\n  ((((MAJ) & 0xFF) << 24) | (((MIN) & 0xFF) << 16) | ((PAT) & 0xFFFF))\n\n/**\n * Macros to extract major/minor/patch version from the full version number.\n *\n * @ingroup Loader\n */\n#define VERSION_MAJOR(VER) (((VER) >> 24) & 0xFF)\n#define VERSION_MINOR(VER) (((VER) >> 16) & 0xFF)\n#define VERSION_PATCH(VER) ((VER) & 0xFFFF)\n\n/**\n * Macro to create ABI version number from a major and minor version.\n *\n * @ingroup Loader\n */\n#define ABI_VERSION_NUMBER(MAJ, MIN) \\\n  ((((MAJ) & 0xFF) << 8) | ((MIN) & 0xFF))\n\n/**\n * Macros to extract major/minor version from the full ABI version number.\n *\n * @ingroup Loader\n */\n#define ABI_VERSION_MAJOR(VER) (((VER) >> 8) & 0xFF)\n#define ABI_VERSION_MINOR(VER) ((VER) & 0xFF)\n}\n\n#endif /* MYSQL_HARNESS_PLUGIN_INCLUDED */\n"
  },
  {
    "path": "src/harness/shared/CMakeLists.txt",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nadd_library(test-helpers STATIC src/test_helpers.cc)\nset_target_properties(test-helpers PROPERTIES\n  LINKER_LANGUAGE CXX)\nif(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL \"Clang\")\n  # silence undefined use of macro-vars in gtest.\n  # we can't use #pragma's due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431 to\n  # supress it locally.\n  set_target_properties(test-helpers PROPERTIES\n    COMPILE_FLAGS \"-Wno-undef -Wno-conversion\")\nendif()\ntarget_include_directories(test-helpers\n  PUBLIC include\n  PUBLIC ${GMOCK_INCLUDE_DIRS}\n  PUBLIC ../harness/include\n  PUBLIC ${MySQLRouter_BINARY_DIR}/include)\ntarget_link_libraries(test-helpers\n  PUBLIC ${TEST_LIBRARIES} harness-library)\n"
  },
  {
    "path": "src/harness/shared/include/test/helpers.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_HELPERS_INCLUDED\n#define MYSQL_HARNESS_HELPERS_INCLUDED\n\n// Third-party headers\n#include \"gtest/gtest.h\"\n\n#include \"mysql/harness/loader.h\"\n\n// Standard headers\n#include <algorithm>\n#include <string>\n#include <vector>\n#include <list>\n\ntemplate <typename T>\nstd::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {\n  out << \"{\";\n  for (auto&& elem : v)\n    out << \" \" << elem;\n  out << \" }\";\n  return out;\n}\n\ntemplate <typename T>\nstd::ostream& operator<<(std::ostream& out, const std::list<T>& v) {\n  out << \"{\";\n  for (auto&& elem : v)\n    out << \" \" << elem;\n  out << \" }\";\n  return out;\n}\n\ntemplate <typename A, typename B>\nstd::ostream& operator<<(std::ostream& out, const std::pair<A, B>& p) {\n  return out << p.first << \":\" << p.second;\n}\n\ntemplate <typename SeqCont1, typename SeqCont2>\n::testing::AssertionResult\nAssertSetEqual(const char* seq1_expr, const char *seq2_expr,\n               const SeqCont1& seq1, const SeqCont2& seq2) {\n  std::vector<typename SeqCont1::value_type> c1(seq1.begin(), seq1.end());\n  std::vector<typename SeqCont2::value_type> c2(seq2.begin(), seq2.end());\n  std::sort(c1.begin(), c1.end());\n  std::sort(c2.begin(), c2.end());\n\n  // Check for elements that are in the first range but not in the second.\n  std::vector<typename SeqCont2::value_type> c1_not_c2;\n  std::set_difference(c1.begin(), c1.end(), c2.begin(), c2.end(),\n                      std::back_inserter(c1_not_c2));\n  if (c1_not_c2.size() > 0) {\n    auto result = ::testing::AssertionFailure();\n    result << seq1_expr << \" had elements not in \" << seq2_expr << \": \";\n    for (auto elem : c1_not_c2)\n      result << elem << \" \";\n    return result;\n  }\n\n  // Check for elements that are in the second range but not in the first.\n  std::vector<typename SeqCont2::value_type> c2_not_c1;\n  std::set_difference(c2.begin(), c2.end(), c1.begin(), c1.end(),\n                      std::back_inserter(c2_not_c1));\n  if (c2_not_c1.size() > 0) {\n    auto result = ::testing::AssertionFailure();\n    result << seq2_expr << \" had elements not in \" << seq1_expr << \": \";\n    for (auto elem : c2_not_c1)\n      result << elem << \" \";\n    return result;\n  }\n\n  return ::testing::AssertionSuccess();\n}\n\n#define EXPECT_SETEQ(S1, S2) \\\n  EXPECT_PRED_FORMAT2(AssertSetEqual, S1, S2)\n\n::testing::AssertionResult\nAssertLoaderSectionAvailable(const char *loader_expr,\n                             const char *section_expr,\n                             mysql_harness::Loader* loader,\n                             const std::string& section_name);\n\n#define EXPECT_SECTION_AVAILABLE(S, L)  \\\n  EXPECT_PRED_FORMAT2(AssertLoaderSectionAvailable, L, S)\n\n/**\n * Just register logger with DIM for unit tests (unlike init_log(), which also\n * initializes it)\n */\nvoid register_test_logger();\n\n/**\n * Register + init logger for unit tests\n *\n * Creates application (\"main\") logger, which will write all messages to the\n * console. Almost all of our code relies on the fact of \"main\" logger being\n * initialized, so it is necessary to provide one for unit tests. Also, some\n * unit tests analyze log output, and expect that output to exist on stderr.\n */\nvoid init_test_logger(const std::list<std::string>& additional_log_domains = {},\n                      const std::string& log_folder = \"\",\n                      const std::string& log_filename = \"\");\n\n/**\n * Temporary Directory object using RAII semantics\n *\n * This class creates a temporary directory with (partially) random name, which\n * it removes on destruction along with its contents. It exposes an API to\n * conveniently work with this directory.\n */\nclass TmpDir {\n public:\n\n  // RAII\n  TmpDir() :\n    tmp_dir_(mysql_harness::get_tmp_dir()) {}\n  TmpDir(const std::string& dir_name_prefix) :\n    tmp_dir_(mysql_harness::get_tmp_dir(dir_name_prefix)) {}\n  ~TmpDir() {\n    mysql_harness::delete_dir(tmp_dir_);\n  }\n\n  // return path to tmp dir\n  std::string operator()() {\n    return tmp_dir_;\n  }\n\n  // return path/to/file in tmp dir\n  std::string file(const std::string& fname) {\n    return tmp_dir_ + \"/\" + fname;\n  }\n\n private:\n  std::string tmp_dir_;\n};\n\n#endif /* MYSQL_HARNESS_HELPERS_INCLUDED */\n"
  },
  {
    "path": "src/harness/shared/src/test_helpers.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"test/helpers.h\"\n\n#include \"dim.h\"\n#include \"mysql/harness/loader.h\"\n#include \"mysql/harness/logging/registry.h\"\n\n::testing::AssertionResult\nAssertLoaderSectionAvailable(const char *loader_expr,\n                             const char *section_expr,\n                             mysql_harness::Loader* loader,\n                             const std::string& section_name) {\n  using std::pair;\n  using std::string;\n\n  auto lst = loader->available();\n  auto match_example = [&section_name](const pair<string, string>& elem){\n    return elem.first == section_name;\n  };\n\n  if (std::count_if(lst.begin(), lst.end(), match_example) > 0)\n    return ::testing::AssertionSuccess();\n\n  std::ostringstream sections;\n  for (auto& name : lst) {\n    sections << \" \" << name.first;\n    if (!name.second.empty()) {\n      sections << \":\" << name.second;\n    }\n  }\n  return ::testing::AssertionFailure()\n         << \"Loader '\" << loader_expr << \"' did not contain section '\"\n         << section_name << \"' (from expression '\" << section_expr << \"')\\n\"\n         << \"Sections were: \" << sections.str();\n}\n\nvoid register_test_logger() {\n  mysql_harness::DIM& dim = mysql_harness::DIM::instance();\n  dim.set_LoggingRegistry(\n    []() {\n      static mysql_harness::logging::Registry registry;\n      return &registry;\n    },\n    [](mysql_harness::logging::Registry*){}  // don't delete our static!\n  );\n}\n\nvoid init_test_logger(const std::list<std::string>& additional_log_domains /* = {} */,\n                      const std::string& log_folder /* = \"\" */,\n                      const std::string& log_filename /* = \"\" */) {\n\n  register_test_logger();\n\n  mysql_harness::DIM& dim = mysql_harness::DIM::instance();\n  mysql_harness::logging::Registry& registry = dim.get_LoggingRegistry();\n\n  mysql_harness::Config config;\n\n  // NOTE: See where g_HACK_default_log_level is set in production code to understand\n  // the hack. One day we will want to revert to something analogous to what we had before.\n  // Original code looked like this:\n  //   config.set_default(mysql_harness::logging::kConfigOptionLogLevel, \"debug\");\n  mysql_harness::logging::g_HACK_default_log_level = \"debug\";\n\n  std::list<std::string> log_domains(additional_log_domains.begin(),\n                                     additional_log_domains.end());\n  log_domains.push_back(mysql_harness::logging::kMainLogger);\n\n  mysql_harness::logging::clear_registry(registry);\n  mysql_harness::logging::init_loggers(registry, config, log_domains, mysql_harness::logging::kMainLogger);\n  mysql_harness::logging::create_main_logfile_handler(registry, log_filename, log_folder, true);\n\n  registry.set_ready();\n}\n"
  },
  {
    "path": "src/harness/src/arg_handler.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql/harness/arg_handler.h\"\n\n#include \"utilities.h\"\n\n#include <algorithm>\n#include <assert.h>\n#include <iostream>\n#include <sstream>\n#include <string>\n#include <vector>\n\nusing std::string;\nusing std::vector;\nusing std::unique_ptr;\n\nusing mysql_harness::utility::string_format;\nusing mysql_harness::utility::wrap_string;\nusing mysql_harness::utility::regex_pattern_matches;\n\n#ifndef NDEBUG\nbool CmdArgHandler::debug_check_option_names(\n    const CmdOption::OptionNames& names) const {\n  for (auto&& name : names) {\n    if (!is_valid_option_name(name))  // valid option names\n      return false;\n    if (options_.end() != find_option(name))  // unique name\n      return false;\n  }\n  return true;\n}\n#endif\n\nvoid\nCmdArgHandler::add_option(const CmdOption::OptionNames& names,\n                          const string& description,\n                          const CmdOptionValueReq& value_req,\n                          const string& metavar,\n                          CmdOption::ActionFunc action,\n                          CmdOption::AtEndActionFunc at_end_action) noexcept {\n  assert(!names.empty());  // need none empty names container\n  assert(debug_check_option_names(names));\n  options_.emplace_back(names, description, value_req, metavar, action, at_end_action);\n}\n\nvoid CmdArgHandler::add_option(const CmdOption &other) noexcept {\n  assert(!other.names.empty());  // need none empty names container\n  assert(debug_check_option_names(other.names));\n\n  options_.emplace_back(other.names, other.description,\n                        other.value_req, other.metavar, other.action, other.at_end_action);\n}\n\nOptionContainer::const_iterator\nCmdArgHandler::find_option(const std::string& name) const noexcept {\n  for (auto opt = options_.begin(); opt != options_.end(); ++opt) {\n    auto res = std::find(opt->names.begin(), opt->names.end(), name);\n    if (res != opt->names.end()) {\n      return opt;\n    }\n  }\n\n  return options_.end();\n}\n\n/** @fn CmdArgHandler::is_valid_option_name(const string name) noexcept\n *\n * @devnote\n * Some compilers, like gcc 4.8, have no support for C++11 regular expression.\n * @enddevnote\n */\nbool CmdArgHandler::is_valid_option_name(const string& name) const noexcept {\n  // Handle tokens like -h or -v\n  if (name.size() == 2 && name.at(1) != '-') {\n    return name.at(0) == '-';\n  }\n\n  // Handle tokens like --help or --with-sauce\n  return regex_pattern_matches(name, \"^--[A-Za-z][A-Za-z_-]*[A-Za-z]$\");\n}\n\nvoid CmdArgHandler::process(const vector<string>& arguments) {\n  size_t pos;\n  string argpart;\n  string value;\n  rest_arguments_.clear();\n  auto args_end = arguments.end();\n  vector<std::pair<CmdOption::ActionFunc, string> > schedule;\n  vector<CmdOption::AtEndActionFunc> at_end_schedule;\n\n  for (auto part = arguments.begin(); part < args_end; ++part) {\n    if ((pos = (*part).find('=')) != string::npos) {\n      // Option like --config=/path/to/config.conf\n      argpart = (*part).substr(0, pos);\n      value = (*part).substr(pos + 1);\n    } else {\n      argpart = *part;\n      value = \"\";\n    }\n\n    // Save none-option arguments\n    if (!is_valid_option_name(argpart)) {\n      if (!allow_rest_arguments) {\n        throw std::invalid_argument(\"invalid argument '\" + argpart +\"'.\");\n      }\n      rest_arguments_.push_back(argpart);\n      continue;\n    }\n\n    auto opt_iter = find_option(argpart);\n    if (options_.end() != opt_iter) {\n      auto &option = *opt_iter;\n      string err_value_req =\n          string_format(\"option '%s' requires a value.\", argpart.c_str());\n\n      if (option.value_req == CmdOptionValueReq::required) {\n        if (value.empty()) {\n          if (part == (args_end - 1)) {\n            // No more parts to get value from\n            throw std::invalid_argument(err_value_req);\n          }\n\n          ++part;\n          if (!part->empty() && part->at(0) == '-') {\n            throw std::invalid_argument(err_value_req);\n          }\n          value = *part;\n        }\n      } else if (option.value_req == CmdOptionValueReq::optional) {\n        if (value.empty() && part != (args_end - 1)) {\n          ++part;\n          if (part->empty() || part->at(0) != '-') {\n            value = *part;\n          }\n        }\n      }\n\n      // Execute actions after\n      if (option.action != nullptr) {\n        schedule.emplace_back(option.action, value);\n        at_end_schedule.push_back(option.at_end_action);\n      }\n    } else {\n      auto message = string_format(\"unknown option '%s'.\", argpart.c_str());\n      throw std::invalid_argument(message);\n    }\n  }\n\n  // Execute actions after processing\n  for (auto it : schedule) {\n    std::bind(it.first, it.second)();\n  }\n\n  // Execute at the end actions\n  for (auto at_end_action : at_end_schedule) {\n    at_end_action();\n  }\n}\n\nvector<string>\nCmdArgHandler::usage_lines(const string& prefix,\n                           const string& rest_metavar,\n                           size_t width) const noexcept {\n  std::stringstream ss;\n  vector<string> usage;\n\n  for (auto option = options_.begin(); option != options_.end(); ++option) {\n    ss.clear();\n    ss.str(string());\n\n    ss << \"[\";\n    for (auto name = option->names.begin();\n         name != option->names.end(); ++name) {\n      ss << *name;\n      if (name == --option->names.end()) {\n        if (option->value_req != CmdOptionValueReq::none) {\n          if (option->value_req == CmdOptionValueReq::optional) {\n            ss << \"=[\";\n          } else {\n            ss << \"=\";\n          }\n          ss << \"<\" << (option->metavar.empty() ? \"VALUE\" : option->metavar)\n             << \">\";\n          if (option->value_req == CmdOptionValueReq::optional) {\n            ss << \"]\";\n          }\n        }\n        ss << \"]\";\n      } else {\n        ss << \"|\";\n      }\n    }\n    usage.push_back(ss.str());\n  }\n\n  if (allow_rest_arguments && !rest_metavar.empty()) {\n    ss.clear();\n    ss.str(string());\n    ss << \"[\" << rest_metavar << \"]\";\n    usage.push_back(ss.str());\n  }\n\n  ss.clear();\n  ss.str(string());\n  size_t line_size = 0;\n  vector<string> result{};\n\n  ss << prefix;\n  line_size = ss.str().size();\n  auto indent = string(line_size, ' ');\n\n  auto end_usage = usage.end();\n  for (auto item = usage.begin(); item != end_usage; ++item) {\n    // option can not be bigger than width\n    assert(((*item).size() + indent.size()) < width);\n    auto need_newline = (line_size + (*item).size() + indent.size()) > width;\n\n    if (need_newline) {\n      result.push_back(ss.str());\n      ss.clear();\n      ss.str(string());\n      ss << indent;\n    }\n\n    ss << \" \" << *item;\n    line_size = ss.str().size();\n  }\n\n  // Add the last line\n  result.push_back(ss.str());\n\n  return result;\n}\n\nvector<string>\nCmdArgHandler::option_descriptions(size_t width,\n                                   size_t indent) noexcept {\n  std::stringstream ss;\n  vector<string> desc_lines;\n\n  for (auto option = options_.begin(); option != options_.end(); ++option) {\n    auto value_req = option->value_req;\n    ss.clear();\n    ss.str(string());\n\n    ss << \"  \";\n    for (auto iter_name = option->names.begin();\n         iter_name != option->names.end(); ++iter_name) {\n      auto name = *iter_name;\n      ss << name;\n\n      if (value_req != CmdOptionValueReq::none) {\n        if (value_req == CmdOptionValueReq::optional) {\n          ss << \" [\";\n        }\n        ss << \" <\" << (option->metavar.empty() ? \"VALUE\" : option->metavar);\n        ss << \">\";\n        if (value_req == CmdOptionValueReq::optional) {\n          ss << \"]\";\n        }\n      }\n\n      if (iter_name != --option->names.end()) {\n        ss << \", \";\n      }\n    }\n    desc_lines.push_back(ss.str());\n\n    ss.clear();\n    ss.str(string());\n\n    string desc = option->description;\n    for (auto line : wrap_string(option->description, width, indent)) {\n      desc_lines.push_back(line);\n    }\n  }\n\n  return desc_lines;\n}\n"
  },
  {
    "path": "src/harness/src/common.cc",
    "content": "/*\nCopyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\nThis program is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License, version 2.0,\nas published by the Free Software Foundation.\n\nThis program is also distributed with certain software (including\nbut not limited to OpenSSL) that is licensed under separate terms,\nas designated in a particular file or component or in included license\ndocumentation.  The authors of MySQL hereby grant you an additional\npermission to link the program and your derivative works with the\nseparately licensed software that they have included with MySQL.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <sstream>\n#include <memory>\n#include <assert.h> // <cassert> is flawed: assert() lands in global namespace on Ubuntu 14.04, not std::\n#include <string.h>\n#include <fstream>\n#include <system_error>\n\n#include \"common.h\"\n#include \"harness_assert.h\"\n\n#ifdef _WIN32\n#include <windows.h>\n#include <aclapi.h>\n#else\n#include <pthread.h>\n#include <sys/stat.h>\n#endif\n\n\n#ifdef _WIN32\n\n/**\n * Deleter for smart pointers pointing to objects that require to be released\n * with `LocalFree`.\n */\nclass LocalFreeDeleter {\npublic:\n  void operator()(HLOCAL hnd) {\n    LocalFree(hnd);\n  }\n};\n\n// smart pointer for SID, allocated with LocalAlloc.\ntypedef std::unique_ptr<SID, LocalFreeDeleter> SidPtr;\n\n/**\n * Gets the SID of the current process user.\n * The SID in Windows is the Security IDentifier, a security principal to which\n * permissions are attached (machine, user group, user).\n */\nstatic void GetCurrentUserSid(SidPtr& pSID) {\n  typedef std::unique_ptr<TOKEN_USER, LocalFreeDeleter> TokenUserPtr;\n  DWORD dw_size = 0;\n  HANDLE h_token;\n  TOKEN_INFORMATION_CLASS token_class = TokenUser;\n  // Gets security token of the current process\n  if (!OpenProcessToken(GetCurrentProcess(), TOKEN_READ | TOKEN_QUERY, &h_token)) {\n    throw std::runtime_error(\"OpenProcessToken() failed: \" + std::to_string(GetLastError()));\n  }\n  // Gets the user token from the security token (this one only finds out the buffer size required)\n  if (!GetTokenInformation(h_token, token_class, NULL, 0, &dw_size)) {\n    DWORD dwResult = GetLastError();\n    if (dwResult != ERROR_INSUFFICIENT_BUFFER) {\n      throw std::runtime_error(\"GetTokenInformation() failed: \" + std::to_string(dwResult));\n    }\n  }\n\n  TokenUserPtr user((PTOKEN_USER)LocalAlloc(GPTR, dw_size));\n  if (user.get() == NULL) {\n    throw std::runtime_error(\"LocalAlloc() failed: \" + std::to_string(GetLastError()));\n  }\n\n  // Gets the user token from the security token (this one retrieves the actual user token)\n  if (!GetTokenInformation(h_token, token_class, user.get(), dw_size, &dw_size)) {\n    throw std::runtime_error(\"GetTokenInformation() failed: \" + std::to_string(GetLastError()));\n  }\n  // Copies from the user token the SID\n  DWORD dw_sid_len = GetLengthSid(user->User.Sid);\n  pSID.reset((SID*)LocalAlloc(GPTR, dw_sid_len));\n  CopySid(dw_sid_len, pSID.get(), user->User.Sid);\n}\n\n/**\n * Makes a file fully accessible by the current process user and\n * read only for LocalService account (which is the account under which the MySQL\n * router runs as service). And not accessible for everyone else.\n */\nstatic void make_file_private_win32(const std::string& filename) {\n  typedef std::unique_ptr<SECURITY_DESCRIPTOR, LocalFreeDeleter> SecurityDescriptorPtr;\n  PACL new_dacl = NULL;\n  SidPtr current_user((SID*)NULL);\n  DWORD sid_size = SECURITY_MAX_SID_SIZE;\n  SID local_service_sid;\n  DWORD dw_res;\n  // Obtains the SID of the LocalService account (the account under which runs\n  // the Router as a service in Windows)\n  if (CreateWellKnownSid(WinLocalServiceSid, NULL, &local_service_sid, &sid_size) == FALSE) {\n    throw std::runtime_error(\"CreateWellKnownSid() failed: \" + std::to_string(GetLastError()));\n  }\n  // Retrieves the current user process SID.\n  GetCurrentUserSid(current_user);\n\n  // Sets the actual permissions: two ACEs (access control entries) (one for\n  // current user, one for LocalService) are configured and attached to a\n  // Security Descriptor's DACL (Discretionary Access Control List), then\n  // the Security Descriptors is used in SetFileSecurity API.\n  EXPLICIT_ACCESSA ea[2];\n  ZeroMemory(&ea, 2 * sizeof(EXPLICIT_ACCESSA));\n  // Full acceess for current user\n  ea[0].grfAccessPermissions = ACCESS_SYSTEM_SECURITY | READ_CONTROL | WRITE_DAC | GENERIC_ALL;\n  ea[0].grfAccessMode = GRANT_ACCESS;\n  ea[0].grfInheritance = NO_INHERITANCE;\n  ea[0].Trustee.TrusteeForm = TRUSTEE_IS_SID;\n  ea[0].Trustee.ptstrName = reinterpret_cast<char*>(current_user.get());\n  // Read only access for LocalService account\n  ea[1].grfAccessPermissions = GENERIC_READ;\n  ea[1].grfAccessMode = GRANT_ACCESS;\n  ea[1].grfInheritance = NO_INHERITANCE;\n  ea[1].Trustee.TrusteeForm = TRUSTEE_IS_SID;\n  ea[1].Trustee.ptstrName = reinterpret_cast<char*>(&local_service_sid);\n  // Make a new DACL with the two ACEs\n  dw_res = SetEntriesInAclA(2, ea, NULL, &new_dacl);\n\n  try {\n    if (ERROR_SUCCESS != dw_res) {\n      throw std::runtime_error(\"SetEntriesInAcl() failed: \" + std::to_string(dw_res));\n    }\n\n    // create and initialize a security descriptor.\n    SecurityDescriptorPtr psd((SECURITY_DESCRIPTOR*)LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH));\n    if (psd.get() == NULL) {\n      throw std::runtime_error(\"LocalAlloc() failed: \" + std::to_string(GetLastError()));\n    }\n\n    if (!InitializeSecurityDescriptor(psd.get(), SECURITY_DESCRIPTOR_REVISION)) {\n      throw std::runtime_error(\"InitializeSecurityDescriptor failed: \" + std::to_string(GetLastError()));\n    }\n    // attach the DACL to the security descriptor\n    if (!SetSecurityDescriptorDacl(psd.get(), TRUE, new_dacl, FALSE)) {\n      throw std::runtime_error(\"SetSecurityDescriptorDacl failed: \" + std::to_string(GetLastError()));\n    }\n\n    if (!SetFileSecurityA(filename.c_str(), DACL_SECURITY_INFORMATION, psd.get()))\n    {\n      dw_res = GetLastError();\n      throw std::system_error(dw_res, std::system_category(), \"SetFileSecurity failed: \" + std::to_string(dw_res));\n    }\n    LocalFree((HLOCAL)new_dacl);\n  } catch (...) {\n    if (new_dacl != NULL)\n      LocalFree((HLOCAL)new_dacl);\n    throw;\n  }\n}\n\n\n/**\n * Sets file permissions for Everyone group.\n *\n * @param[in] file_name File name.\n * @param[in] mask Access rights mask for Everyone group.\n *\n * @except std::exception Failed to change file permissions.\n */\nstatic void set_everyone_group_access_rights(const std::string& file_name,\n                                             DWORD mask) {\n  using SecurityDescriptorPtr =\n    std::unique_ptr<SECURITY_DESCRIPTOR, LocalFreeDeleter>;\n  using AclPtr = std::unique_ptr<ACL, LocalFreeDeleter>;\n  using SidPtr = std::unique_ptr<SID, mysql_harness::StdFreeDeleter<SID>>;\n\n  // Create Everyone SID.\n  DWORD sid_size = SECURITY_MAX_SID_SIZE;\n  SidPtr everyone_sid(static_cast<SID*>(std::malloc(sid_size)));\n\n  if (CreateWellKnownSid(WinWorldSid, NULL, everyone_sid.get(), &sid_size) ==\n        FALSE) {\n    throw std::runtime_error(\"CreateWellKnownSid() failed: \" +\n                             std::to_string(GetLastError()));\n  }\n\n  // Get file security descriptor.\n  ACL* old_dacl;\n  SecurityDescriptorPtr sec_desc;\n\n  {\n    PSECURITY_DESCRIPTOR sec_desc_tmp;\n    auto result = GetNamedSecurityInfoA(file_name.c_str(), SE_FILE_OBJECT,\n                                        DACL_SECURITY_INFORMATION, NULL, NULL,\n                                        &old_dacl, NULL, &sec_desc_tmp);\n\n    if (result != ERROR_SUCCESS) {\n      throw std::system_error(result, std::system_category(), \"GetNamedSecurityInfo() failed: \" +\n                               std::to_string(result));\n    }\n\n    // If everything went fine, we move raw pointer to smart pointer.\n    sec_desc.reset(reinterpret_cast<SECURITY_DESCRIPTOR*>(sec_desc_tmp));\n  }\n\n  // Setting access permissions for Everyone group.\n  EXPLICIT_ACCESSA ea[1];\n\n  memset(&ea, 0, sizeof(ea));\n  ea[0].grfAccessPermissions = mask;\n  ea[0].grfAccessMode = SET_ACCESS;\n  ea[0].grfInheritance = NO_INHERITANCE;\n  ea[0].Trustee.TrusteeForm = TRUSTEE_IS_SID;\n  ea[0].Trustee.ptstrName = reinterpret_cast<char*>(everyone_sid.get());\n\n  // Create new ACL permission set.\n  AclPtr new_dacl;\n\n  {\n    ACL* new_dacl_tmp;\n    auto result = SetEntriesInAclA(1, &ea[0], old_dacl, &new_dacl_tmp);\n\n    if (result != ERROR_SUCCESS) {\n      throw std::runtime_error(\"SetEntriesInAcl() failed: \" +\n                               std::to_string(result));\n    }\n\n    // If everything went fine, we move raw pointer to smart pointer.\n    new_dacl.reset(new_dacl_tmp);\n  }\n\n  // Set file security descriptor.\n  auto result = SetNamedSecurityInfoA(const_cast<char*>(file_name.c_str()),\n                                 SE_FILE_OBJECT, DACL_SECURITY_INFORMATION,\n                                 NULL, NULL, new_dacl.get(), NULL);\n\n  if (result != ERROR_SUCCESS) {\n    throw std::system_error(result, std::system_category(), \"SetNamedSecurityInfo() failed: \" +\n                             std::to_string(result));\n  }\n}\n\n#else\n\n/**\n * Sets access permissions for a file.\n *\n * @param[in] file_name File name.\n * @param[in] mask Access permission mask.\n *\n * @except std::exception Failed to change file permissions.\n */\nstatic void throwing_chmod(const std::string& file_name, mode_t mask) {\n  if (chmod(file_name.c_str(), mask) != 0) {\n    throw std::runtime_error(\"chmod() failed: \" + file_name + \": \" +\n                             mysql_harness::get_strerror(errno));\n  }\n}\n\n#endif // _WIN32\n\n\nnamespace mysql_harness {\n\nvoid make_file_public(const std::string& file_name) {\n#ifdef _WIN32\n  set_everyone_group_access_rights(\n    file_name, FILE_GENERIC_EXECUTE | FILE_GENERIC_WRITE | FILE_GENERIC_READ);\n#else\n  throwing_chmod(file_name, S_IRWXU | S_IRWXG | S_IRWXO);\n#endif\n}\n\nvoid make_file_private(const std::string& file_name) {\n#ifdef _WIN32\n  try {\n    make_file_private_win32(file_name);\n  } catch (const std::system_error &e) {\n    throw std::system_error(e.code(), \"Could not set permissions for file '\" + file_name + \"': \" + e.what());\n  }\n#else\n  try {\n    throwing_chmod(file_name, S_IRUSR | S_IWUSR);\n  } catch (std::runtime_error& e) {\n    throw std::runtime_error(\"Could not set permissions for file '\" + file_name + \"': \" + e.what());\n  }\n#endif\n}\n\nstd::string get_strerror(int err) {\n    char msg[256];\n    std::string result;\n\n#if  !defined(_GNU_SOURCE) && ((defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600))\n  // glibc's POSIX version\n  int ret = strerror_r(err, msg, sizeof(msg));\n  if (ret) {\n    return \"errno= \" + std::to_string(err) + \" (strerror_r failed: \" + std::to_string(ret) + \")\";\n  } else {\n    result = std::string(msg);\n  }\n#elif defined(_WIN32)\n  int ret = strerror_s(msg, sizeof(msg), err);\n  if (ret) {\n    return \"errno= \" + std::to_string(err) + \" (strerror_s failed: \" + std::to_string(ret) + \")\";\n  } else {\n    result = std::string(msg);\n  }\n#elif defined(__GLIBC__) && defined (_GNU_SOURCE)\n  // glibc's POSIX version, GNU version\n  char* ret = strerror_r(err, msg, sizeof(msg));\n  result = std::string(ret);\n#else\n  // POSIX version\n  int ret = strerror_r(err, msg, sizeof(msg));\n  if (ret) {\n    return \"errno= \" + std::to_string(err) + \" (strerror_r failed: \" + std::to_string(ret) + \")\";\n  } else {\n    result = std::string(msg);\n  }\n#endif\n\n  return result;\n}\n\n#ifdef _WIN32\nconst DWORD MS_VC_EXCEPTION = 0x406D1388;\n#pragma pack(push,8)\ntypedef struct tagTHREADNAME_INFO\n{\n  DWORD dwType;\n  LPCSTR szName;\n  DWORD dwThreadID;\n  DWORD dwFlags;\n} THREADNAME_INFO;\n#pragma pack(pop)\n#endif\n\nvoid rename_thread(const char thread_name[16]) {\n\n// linux\n#ifdef __linux__\n  assert(strnlen(thread_name, 16) < 16);  // max allowed len for thread_name\n  pthread_setname_np(pthread_self(), thread_name);\n\n// windows\n#elif defined(_WIN32)\n#ifdef _DEBUG\n\t// In Win32 API there is no API for setting thread name, but according to \n\t// Microsoft documentation, there is a \"secret handshake\" between debuggee\n\t// & debugger using the special values used here.\n  THREADNAME_INFO info;\n  info.dwType = 0x1000;\n  info.szName = thread_name;\n  info.dwThreadID = GetCurrentThreadId();\n  info.dwFlags = 0;\n#pragma warning(push)\n#pragma warning(disable: 6320 6322)\n  __try{\n      RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR*)&info);\n  }\n  __except (EXCEPTION_EXECUTE_HANDLER){\n  }\n#pragma warning(pop)\n#endif  // #ifdef _DEBUG\n\n// other\n#else\n  // TODO: on BSD/OSX, this should build but does not: pthread_setname_np(thread_name);\n  (void) thread_name;\n\n#endif\n}\n\nstatic inline const std::string& truncate_string_backend(const std::string& input,\n                                                         std::string& output,\n                                                         size_t max_len) {\n\n  // to keep code simple, we don't support unlikely use cases\n  harness_assert(max_len >= 6); // 3 (to fit the first 3 chars) + 3 (to fit \"...\"), allowing: \"foo...\"\n                                // ^--- arbitrarily-reasonable number, could be even 0 if we wanted\n\n  // no truncation needed, so just return the original\n  if (input.size() <= max_len)\n    return input;\n\n  // we truncate and overwrite last three characters with \"...\"\n  // (\"foobarbaz\" becomes \"foobar...\")\n  output.assign(input, 0, max_len);\n  output[max_len-3] = '.';\n  output[max_len-2] = '.';\n  output[max_len-1] = '.';\n  return output;\n}\n\nconst std::string& truncate_string(const std::string& input, size_t max_len /*= 80*/) {\n  thread_local std::string output;\n  return truncate_string_backend(input, output, max_len);\n}\n\nstd::string truncate_string_r(const std::string& input, size_t max_len /*= 80*/) {\n  std::string output;\n  return truncate_string_backend(input, output, max_len);\n}\n\n} // namespace mysql_harness\n"
  },
  {
    "path": "src/harness/src/config_parser.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n\n/**\n * @defgroup ConfigParser Configuration file parser\n *\n * @section Configuration file format\n *\n * The configuration parser parses traditional `.INI` files consisting\n * of sections and options with values but contain some additional\n * features to provide more flexible configuration of the harness.\n */\n\n#include \"mysql/harness/config_parser.h\"\n#include \"mysql/harness/filesystem.h\"\n\n#include \"utilities.h\"\n\n#include <algorithm>\n#include <cassert>\n#include <fstream>\n#include <ios>\n#include <sstream>\n#include <stdexcept>\n#include <string>\n\nusing std::ostringstream;\nusing std::shared_ptr;\n\nusing mysql_harness::utility::find_range_first;\nusing mysql_harness::utility::matches_glob;\nusing mysql_harness::utility::strip;\n\nnamespace mysql_harness {\n\n// satisfy ODR requirements\nconstexpr const char* Config::DEFAULT_PATTERN;\n\nstatic bool isident(const char ch) {\n  return isalnum(ch) || ch == '_';\n}\n\nstatic void inplace_lower(std::string* str) {\n  std::transform(str->begin(), str->end(), str->begin(), ::tolower);\n}\n\nstatic std::string lower(std::string str) {\n  std::transform(str.begin(), str.end(), str.begin(), ::tolower);\n  return str;\n}\n\nstatic void check_option(const std::string& str) {\n  if (!all_of(str.begin(), str.end(), isident))\n    throw bad_option(\"Not a legal option name: '\" + str + \"'\");\n}\n\n#ifndef DOXYGEN_SHOULD_SKIP_THIS\n// doxygen has problems to parse the 'const shared_ptr<const ConfigSection>&'\n// and treats it as 'const const shared_ptr<ConfigSection>&' can't find a match\nConfigSection::ConfigSection(const std::string& name_arg,\n                             const std::string& key_arg,\n                             const shared_ptr<const ConfigSection>& defaults)\n  : name(name_arg), key(key_arg), defaults_(defaults) {}\n\nConfigSection::ConfigSection(const ConfigSection& other,\n                             const shared_ptr<const ConfigSection>& defaults)\n  : name(other.name), key(other.key), defaults_(defaults),\n    options_(other.options_) {}\n#endif\n\nvoid ConfigSection::clear() {\n  options_.clear();\n}\n\n// throws bad_section\nvoid ConfigSection::update(const ConfigSection& other) {\n#ifndef NDEBUG\n  auto old_defaults = defaults_;\n#endif\n\n  if (other.name != name || other.key != key) {\n    ostringstream buffer;\n    buffer << \"Trying to update section \" << name << \":\" << key\n           << \" using section \" << other.name << \":\" << other.key;\n    throw bad_section(buffer.str());\n  }\n\n  for (auto& option : other.options_)\n    options_[option.first] = option.second;\n\n  assert(old_defaults == defaults_);\n}\n\nstd::string\nConfigSection::do_replace(const std::string& value, int depth) const {\n  std::string result;\n  bool inside_braces = false;\n  std::string::const_iterator mark = value.begin();\n\n  // Simple hack to avoid infinite recursion because of\n  // back-references.\n  if (depth > kMaxInterpolationDepth)\n    throw syntax_error(\"Max recursion depth for interpolation exceeded.\");\n\n  // Scan the string one character at a time and store the result of\n  // substituting variable interpolations in the result variable.\n  //\n  // The scan keeps a mark iterator available that either point to the\n  // beginning of the string, the last seen open brace, or just after\n  // the last seen closing brace.\n  //\n  // At any point of the iteration, everything before the mark is\n  // already in the result string, and everything at the mark and\n  // later is not transfered to the result string.\n  for (auto current = value.begin() ; current != value.end() ; ++current) {\n    if (inside_braces && *current == '}') {\n      // Inside braces and found the end brace.\n      const std::string ident(mark + 1, current);\n      auto loc = do_locate(ident);\n      if (std::get<1>(loc))\n        result.append(do_replace(std::get<0>(loc)->second, depth + 1));\n      else\n        result.append(mark, current + 1);\n      mark = current + 1;\n      inside_braces = false;\n    } else if (*current == '{') {\n      // Start a possible variable interpolation\n      result.append(mark, current);\n      mark = current;\n      inside_braces = true;\n    }\n  }\n\n  // Append any trailing content of the original string.\n  result.append(mark, value.end());\n\n  return result;\n}\n\nstd::string ConfigSection::get(const std::string& option) const {\n  check_option(option);\n  auto result = do_locate(option);\n  if (std::get<1>(result))\n    return do_replace(std::get<0>(result)->second);\n  throw bad_option(\"Value for '\" + option + \"' not found\");\n}\n\nstd::string ConfigSection::get_section_name(const std::string& option) const {\n  check_option(option);\n  if (!has(option)) {\n    return \"\";\n  }\n  auto it = options_.find(lower(option));\n  if (it != options_.end()) {\n    return key.empty() ? name : name + \":\" + key;\n  }\n  else {\n    return defaults_->get_section_name(option);\n  }\n}\n\nbool ConfigSection::has(const std::string& option) const {\n  check_option(option);\n  return std::get<1>(do_locate(option));\n}\n\nstd::pair<ConfigSection::OptionMap::const_iterator, bool>\nConfigSection::do_locate(const std::string& option) const {\n  auto it = options_.find(lower(option));\n  if (it != options_.end())\n    return {it, true};\n\n  if (defaults_)\n    return defaults_->do_locate(option);\n\n  // We return a default constructed iterator: any iterator will do.\n  return {OptionMap::const_iterator(), false};\n}\n\nvoid ConfigSection::set(const std::string& option, const std::string& value) {\n  check_option(option); // throws bad_option\n  options_[lower(option)] = value;\n}\n\nvoid ConfigSection::add(const std::string& option, const std::string& value) {\n  auto ret = options_.emplace(OptionMap::value_type(lower(option), value));\n  if (!ret.second)\n    throw bad_option(\"Option '\" + option + \"' already defined\");\n}\n\nConfig::Config(unsigned int flags) noexcept\n  : defaults_(std::make_shared<ConfigSection>(\"default\", \"\", nullptr)),\n    flags_(flags) {}\n\nvoid Config::copy_guts(const Config& source) noexcept {\n  reserved_ = source.reserved_;\n  flags_ = source.flags_;\n}\n\nbool Config::has(const std::string& section, const std::string& key) const {\n  auto it = sections_.find(make_pair(section, key));\n  return (it != sections_.end());\n}\n\nbool Config::has_any(const std::string& section) const {\n  for (auto it : sections_) {\n    if (it.first.first == section) return true;\n  }\n  return false;\n}\n\nConfig::ConstSectionList Config::get(const std::string& section) const {\n  auto rng = find_range_first(sections_, section);\n  if (distance(rng.first, rng.second) == 0)\n    throw bad_section(\"Section name '\" + section + \"' does not exist\");\n  ConstSectionList result;\n  for (auto&& iter = rng.first ; iter != rng.second ; ++iter)\n    result.push_back(&iter->second);\n  return result;\n}\n\nConfig::SectionList Config::get(const std::string& section) {\n  auto rng = find_range_first(sections_, section);\n  if (distance(rng.first, rng.second) == 0)\n    throw bad_section(\"Section name '\" + section + \"' does not exist\");\n  SectionList result;\n  for (auto&& iter = rng.first ; iter != rng.second ; ++iter)\n    result.push_back(&iter->second);\n  return result;\n}\n\nConfigSection&\nConfig::get(const std::string& section, const std::string& key) {\n  // Check if we allow keys and throw an error if keys are not\n  // allowed.\n  if (!(flags_ & allow_keys))\n    throw bad_section(\"Key '\" + key + \"' used but keys are not allowed\");\n\n  SectionMap::iterator sec = sections_.find(make_pair(section, key));\n  if (sec == sections_.end())\n    throw bad_section(\"Section '\" + section + \"' with key '\" + key\n                      + \"' does not exist\");\n  return sec->second;\n}\n\nconst ConfigSection&\nConfig::get(const std::string& section, const std::string& key) const {\n  return const_cast<Config*>(this)->get(section, key);\n}\n\nstd::string Config::get_default(const std::string& option) const {\n  return defaults_->get(option);\n}\n\nbool Config::has_default(const std::string& option) const {\n  return defaults_->has(option);\n}\n\nvoid Config::set_default(const std::string& option, const std::string& value) {\n  defaults_->set(option, value);\n}\n\nbool Config::is_reserved(const std::string& word) const {\n  auto match = [&word](const std::string& pattern) {\n    return matches_glob(word, pattern);\n  };\n\n  auto it = find_if(reserved_.begin(), reserved_.end(), match);\n  return (it != reserved_.end());\n}\n\n// throws syntax_error, bad_section\nConfigSection&\nConfig::add(const std::string& section, const std::string& key) {\n  if (is_reserved(section))\n    throw syntax_error(\"Section name '\" + section + \"' is reserved\");\n\n  ConfigSection cnfsec(section, key, defaults_);\n  auto result = sections_.emplace(make_pair(section, key), std::move(cnfsec));\n  if (!result.second) {\n    ostringstream buffer;\n    buffer << \"Section '\" << section << (key.empty() ? \"\" : (\":\" + key)) << \"' already exists\";\n    throw bad_section(buffer.str());\n  }\n\n  // Return reference to the newly inserted section.\n  return result.first->second;\n}\n\n// throws std::invalid_argument, std::runtime_error, syntax_error, ...\nvoid Config::read(const Path& path) {\n  if (path.is_directory()) {\n    read(path, Config::DEFAULT_PATTERN);  // throws std::invalid_argument, possibly others\n  } else if (path.is_regular()) {\n    Config new_config;\n    new_config.copy_guts(*this);\n    new_config.do_read_file(path);  // throws std::runtime_error, syntax_error\n    update(new_config);\n  } else {\n    ostringstream buffer;\n    buffer << \"Path '\" << path << \"' \";\n    if (path.type() == Path::FileType::FILE_NOT_FOUND)\n      buffer << \"does not exist\";\n    else\n      buffer << \"is not a directory or a file\";\n    throw std::runtime_error(buffer.str());\n  }\n}\n\n// throws std::invalid_argument, std::runtime_error, syntax_error, ...\nvoid Config::read(const Path& path, const std::string& pattern) {\n  Directory dir(path); // throws std::invalid_argument\n  Config new_config;\n  new_config.copy_guts(*this);\n  for (auto&& iter = dir.glob(pattern) ; iter != dir.end() ; ++iter) {\n    Path entry(*iter);\n    if (entry.is_regular()) // throws std::invalid_argument\n      new_config.do_read_file(entry); // throws std::runtime_error, syntax_error\n  }\n  update(new_config);\n}\n\nvoid Config::read(std::istream& input) {\n  do_read_stream(input);  // throws syntax_error, maybe bad_section\n}\n\nvoid Config::do_read_file(const Path& path) {\n  std::ifstream ifs(path.c_str(), std::ifstream::in);\n  if (ifs.fail()) {\n    ostringstream buffer;\n    buffer << \"Unable to open file \" << path << \" for reading\";\n    throw std::runtime_error(buffer.str());\n  }\n  do_read_stream(ifs);  // throws syntax_error, maybe bad_section\n}\n\nvoid Config::do_read_stream(std::istream& input) {\n  ConfigSection *current = NULL;\n  std::string line;\n  while (getline(input, line)) {\n    strip(&line);\n\n    // Skip empty lines and comment lines.\n    if (line.size() == 0 || line[0] == '#' || line[0] == ';')\n      continue;\n\n    // Check for section start and parse it if so.\n    if (line[0] == '[') {\n      // Check that it is only allowed characters\n      if (line.back() != ']') {\n        std::string message(\"Malformed section header: '\" + line + \"'\");\n        throw syntax_error(message);\n      }\n\n      // Remove leading and trailing brackets\n      line.erase(0, 1);\n      line.erase(line.size() - 1);\n\n      // Extract the key, if configured to allow keys. Otherwise, the\n      // key will be the empty string and the section name is all\n      // within the brackets.\n      std::string section_name(line);\n      std::string section_key;\n      if (flags_ & allow_keys) {\n        // Split line at first colon\n        auto pos = line.find_last_of(':');\n        if (pos != std::string::npos) {\n          section_key = std::string(line, pos + 1);\n\n          // Check that the section key is correct\n          if (section_key.size() == 0 ||\n              !std::all_of(section_key.begin(), section_key.end(), isident)) {\n            std::string message(\"Invalid section key '\" + section_key + \"'\");\n            throw syntax_error(message);\n          }\n\n          section_name.erase(pos);\n        }\n      }\n\n      // Check that the section name consists of allowable characters only\n      if (!std::all_of(section_name.begin(), section_name.end(), isident)) {\n        std::string message(\"Invalid section name '\" + section_name + \"'\");\n        if (!(flags_ & allow_keys) &&\n            line.find_last_of(':') != std::string::npos) {\n          message += \" (keys not configured)\";\n        }\n        throw syntax_error(message);\n      }\n\n      // Section names are always stored in lowercase and we do not\n      // distinguish between sections in lower and upper case.\n      inplace_lower(&section_name);\n\n      // If there is a key, check that it is not on the default section\n      if (allow_keys && section_name == \"default\" && !section_key.empty())\n        throw syntax_error(\"Key not allowed on DEFAULT section\");\n\n      if (section_name == \"default\")\n        current = defaults_.get();\n      else\n        current = &add(section_name, section_key); // throws syntax_error, bad_section\n    } else {  // if (line[0] != '[')\n      if (current == NULL)\n        throw syntax_error(\"Option line before start of section\");\n      // Got option line\n      std::string::size_type pos = line.find_first_of(\":=\");\n      if (pos == std::string::npos)\n        throw syntax_error(\"Malformed option line: '\" + line + \"'\");\n      std::string option(line, 0, pos);\n      strip(&option);\n      std::string value(line, pos + 1);\n      strip(&value);\n\n      // Check that the section name consists of allowable characters only\n      if (!std::all_of(option.begin(), option.end(), isident))\n        throw syntax_error(\"Invalid option name '\" + option + \"'\");\n\n     current->add(option, value); // throws syntax_error, bad_section\n    }\n  }\n\n  if (line.size() > 0)\n    throw syntax_error(\"Unterminated last line\");\n}\n\n\nbool Config::empty() const {\n  return sections_.empty();\n}\n\nvoid Config::clear() {\n  defaults_->clear();\n  sections_.clear();\n}\n\n\nbool Config::remove(const SectionKey& section_key) noexcept {\n  return sections_.erase(section_key);\n}\n\nbool Config::remove(const std::string& section,\n                    const std::string& key /*= std::string()*/) noexcept {\n  return remove(SectionKey(section, key));\n}\n\nvoid Config::update(const Config& other) {\n  // Pre-condition is that the default section pointers before the\n  // update all refer to the default section for this configuration\n  // instance.\n  assert(std::all_of(sections_.cbegin(), sections_.cend(),\n                     [this](const SectionMap::value_type& val) -> bool {\n                       return val.second.assert_default(defaults_.get());\n                     }));\n\n  for (const auto& section : other.sections_) {\n    const SectionKey& key = section.first;\n    SectionMap::iterator iter = sections_.find(key);\n    if (iter == sections_.end())\n      sections_.emplace(key, ConfigSection(section.second, defaults_));\n    else\n      iter->second.update(section.second);\n  }\n\n  defaults_->update(*other.defaults_.get());\n\n  // Post-condition is that the default section pointers after the\n  // update all refer to the default section for this configuration\n  // instance.\n#ifndef NDEBUG\n  auto check = [this](const SectionMap::value_type& val) -> bool {\n    return val.second.assert_default(defaults_.get());\n  };\n#endif\n  assert(std::all_of(sections_.cbegin(), sections_.cend(), check));\n}\n\nConfig::ConstSectionList Config::sections() const {\n  decltype(sections()) result;\n  for (auto& section : sections_)\n    result.push_back(&section.second);\n  return result;\n}\n\n}\n"
  },
  {
    "path": "src/harness/src/designator.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"designator.h\"\n\n#include <cassert>\n#include <cstdio>\n#include <cstdlib>\n#include <stdexcept>\n#include <string>\n\n#define DO_DEBUG 0\n\n#if DO_DEBUG\nvoid Designator::trace(const std::string& where) const {\n  fprintf(stderr, \"[%20s]: %s\\n\", where.c_str(),\n          std::string(cur_, input_.end()).c_str());\n}\n#endif\n\ninline std::string::value_type Designator::peek() const {\n  if (cur_ == input_.end())\n    return '\\0';                       // Return NUL character if end.\n  return *cur_;\n}\n\ninline std::string::value_type Designator::next() {\n  if (cur_ == input_.end())\n    parse_error(\"Unexpected end of input\");\n  return *++cur_;\n}\n\n[[ noreturn ]]\nvoid Designator::parse_error(const std::string& prefix) const {\n  std::string\n    message(prefix + \" at '\" + std::string(cur_, input_.end()) + \"'\");\n  throw std::runtime_error(message);\n}\n\nvoid Designator::skip_space() {\n#if DO_DEBUG\n  trace(__func__);\n#endif\n  while (isspace(peek()))\n    ++cur_;\n}\n\nlong Designator::parse_number() {\n#if DO_DEBUG\n  trace(__func__);\n#endif\n  skip_space();\n  std::string::const_iterator start = cur_;\n  while (::isdigit(peek()))\n    ++cur_;\n  if (std::distance(start, cur_) == 0)\n    parse_error(\"Expected number\");\n  return strtol(std::string(start, cur_).c_str(), NULL, 10);\n}\n\nvoid Designator::parse_plugin() {\n#if DO_DEBUG\n  trace(__func__);\n#endif\n  skip_space();\n  std::string::const_iterator start = cur_;\n  if (!::isalpha(peek()) && peek() != '_')\n    parse_error(\"Invalid start of module name\");\n  while (::isalnum(peek()) || peek() == '_')\n    ++cur_;\n  plugin.assign(start, cur_);\n}\n\nvoid Designator::parse_version_list() {\n#if DO_DEBUG\n  trace(__func__);\n#endif\n  while (true) {\n    skip_space();\n    Relation rel = parse_relation();\n    Version ver = parse_version();\n    constraint.push_back(std::make_pair(rel, ver));\n#if DO_DEBUG\n    trace(__func__);\n#endif\n    skip_space();\n    if (peek() != ',')\n      break;\n    ++cur_;\n  }\n}\n\nDesignator::Relation Designator::parse_relation() {\n#if DO_DEBUG\n  trace(__func__);\n#endif\n  switch (peek()) {\n  case '<':\n    switch (next()) {\n    case '=':\n      ++cur_;\n      return LESS_EQUAL;\n\n    case '<':\n      ++cur_;\n      return LESS_THEN;\n    }\n    --cur_;\n    break;\n\n  case '>':\n    switch (next()) {\n    case '=':\n      ++cur_;\n      return GREATER_EQUAL;\n\n    case '>':\n      ++cur_;\n      return GREATER_THEN;\n    }\n    --cur_;\n    break;\n\n  case '!':\n    switch (next()) {\n    case '=':\n      ++cur_;\n      return NOT_EQUAL;\n    }\n    --cur_;\n    break;\n\n  case '=':\n    switch (next()) {\n    case '=':\n      ++cur_;\n      return EQUAL;\n    }\n    --cur_;\n    break;\n  }\n  parse_error(\"Expected operator\");\n  return EQUAL; // Needs returning something\n}\n\nVersion Designator::parse_version() {\n#if DO_DEBUG\n  trace(__func__);\n#endif\n  Version version;\n\n  version.ver_major = parse_number();\n  if (peek() != '.')\n    return version;\n  ++cur_;\n  version.ver_minor = parse_number();\n\n  if (peek() != '.')\n    return version;\n  ++cur_;\n  version.ver_patch = parse_number();\n\n  return version;\n}\n\nvoid Designator::parse_root() {\n#if DO_DEBUG\n  trace(__func__);\n#endif\n  parse_plugin();\n#if DO_DEBUG\n  trace(__func__);\n#endif\n  skip_space();\n  switch (peek()) {\n  case '(':\n    ++cur_;\n    parse_version_list();\n    skip_space();\n    if (peek() != ')')\n      parse_error(\"Expected end of version list\");\n    ++cur_;\n    break;\n\n  case 0:\n    break;\n\n  default:\n    parse_error(\"Expected start of version list\");\n  }\n}\n\nbool Designator::version_good(const Version& version) const {\n  for (auto& check : constraint) {\n    switch (check.first) {\n    case LESS_THEN:\n      if (!(version < check.second))\n        return false;\n      break;\n\n    case LESS_EQUAL:\n      if (!(version <= check.second))\n        return false;\n      break;\n\n    case GREATER_THEN:\n      if (!(version > check.second))\n        return false;\n      break;\n\n    case GREATER_EQUAL:\n      if (!(version >= check.second))\n        return false;\n      break;\n\n    case EQUAL:\n      if (!(version == check.second))\n        return false;\n      break;\n\n    case NOT_EQUAL:\n      if (!(version != check.second))\n        return false;\n      break;\n\n    default:      // Should not be reached\n      throw std::runtime_error(\"Bad relation operator for constraint\");\n    }\n  }\n  return true;\n}\n\n\nDesignator::Designator(const std::string& str)\n    : input_(str), cur_(input_.begin()) {\n  parse_root();\n  skip_space();                                 // Trailing space allowed\n  if (cur_ != input_.end()) {\n    std::string trailing(cur_, input_.end());\n    throw std::runtime_error(\"Trailing input: '\" + trailing + \"'\");\n  }\n}\n"
  },
  {
    "path": "src/harness/src/designator.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_DESIGNATOR_INCLUDED\n#define MYSQL_HARNESS_DESIGNATOR_INCLUDED\n\n#include <iostream>\n#include <sstream>\n#include <string>\n#include <vector>\n\n#include \"harness_export.h\"\n\n/**\n * Class representing a version.\n *\n * Versions consist of a three-position dotted pair\n * `MAJOR.MINOR.PATCH` where MAJOR is the major version number, MINOR\n * is the minor version number, and PATCH is the patch number. Version\n * comparison is done lexicographically in the normal manner so that\n * 1.1.5 < 1.2.1 < 1.2.3.\n */\nclass Version {\n public:\n  friend std::ostream& operator<<(std::ostream& out, const Version& ver) {\n    out << ver.str();\n    return out;\n  }\n\n  friend bool operator<(const Version& lhs, const Version& rhs) {\n    return (lhs.ver_major < rhs.ver_major) ||\n      (lhs.ver_major == rhs.ver_major && lhs.ver_minor < rhs.ver_minor) ||\n      (lhs.ver_minor == rhs.ver_minor && lhs.ver_patch < rhs.ver_patch);\n  }\n\n  friend bool operator==(const Version& lhs, const Version& rhs) {\n    return (lhs.ver_major == rhs.ver_major) &&\n      (lhs.ver_minor == rhs.ver_minor) &&\n      (lhs.ver_patch == rhs.ver_patch);\n  }\n\n  friend bool operator!=(const Version& lhs, const Version& rhs) {\n    return !(lhs == rhs);\n  }\n\n  friend bool operator<=(const Version& lhs, const Version& rhs) {\n    return (lhs < rhs) || (lhs == rhs);\n  }\n\n  friend bool operator>(const Version& lhs, const Version& rhs) {\n    return (rhs < lhs);\n  }\n\n  friend bool operator>=(const Version& lhs, const Version& rhs) {\n    return (lhs > rhs) || (lhs == rhs);\n  }\n\n  Version(int x, int y, int z = 0)\n  : ver_major(x), ver_minor(y), ver_patch(z) {}\n\n  Version() : Version(0, 0, 0) {}\n\n  explicit Version(unsigned long ver)\n    : ver_major((ver >> 24) & 0xFF), ver_minor((ver >> 16) & 0xFF),\n      ver_patch(ver & 0xFFFF) {}\n\n  std::string str() const {\n    std::ostringstream buffer;\n    buffer << ver_major << \".\" << ver_minor << \".\" << ver_patch;\n    return buffer.str();\n  }\n\n  long ver_major;\n  long ver_minor;\n  long ver_patch;\n};\n\n\n/**\n * Designator grammar\n *\n * root ::= name\n * root ::= name \"(\" op version ( \",\" op version )* \")\"\n * op ::= \"<<\" | \"<=\" | \"!=\" | \"==\" | \">>\" | \">=\"\n * version ::= number \".\" number \".\" number\n */\n\nclass HARNESS_EXPORT Designator {\n public:\n  explicit Designator(const std::string& str);\n\n  enum Relation {\n    LESS_THEN,\n    LESS_EQUAL,\n    EQUAL,\n    NOT_EQUAL,\n    GREATER_EQUAL,\n    GREATER_THEN\n  };\n\n public:\n  class Constraint : public std::vector< std::pair<Relation, Version>> {\n    friend std::ostream& operator<<(std::ostream& out, const Constraint& con) {\n      static const char *const name[] = {\n        \"<<\", \"<=\", \"==\", \"!=\", \">=\", \">>\",\n      };\n      for (auto item : con)\n        out << name[item.first] << item.second;\n      return out;\n    }\n  };\n\n  bool version_good(const Version& ver) const;\n\n  std::string plugin;\n  Constraint constraint;\n\n private:\n  void trace(const std::string& where) const;\n\n  [[ noreturn ]] void parse_error(const std::string& prefix) const;\n  std::string::value_type peek() const;\n  std::string::value_type next();\n\n  Relation parse_relation();\n  Version parse_version();\n  long parse_number();\n  void parse_plugin();\n  void parse_root();\n  void parse_version_list();\n  void skip_space();\n\n  const std::string& input_;\n  std::string::const_iterator cur_;\n\n};\n\n#endif /* MYSQL_HARNESS_DESIGNATOR_INCLUDED */\n"
  },
  {
    "path": "src/harness/src/dim.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"dim.h\"\n\nnamespace mysql_harness {\n\n/*static*/ DIM& DIM::instance() {\n  static DIM manager;\n  return manager;\n}\n\n// we define them here to make sure they're not inlined\n// (that could be dangerous when called from other DLLs)\nDIM::DIM() {}\nDIM::~DIM() {}\n\n} // namespace mysql_harness\n\n"
  },
  {
    "path": "src/harness/src/exception.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_EXCEPTION_INCLUDED\n#define MYSQL_HARNESS_EXCEPTION_INCLUDED\n\n#include <stdexcept>\n\n/**\n * Exception thrown when the plugin loading failed.\n */\n\nclass bad_plugin : public std::runtime_error {\n public:\n  explicit bad_plugin(const std::string& msg) : std::runtime_error(msg) {}\n};\n\n#endif /* MYSQL_HARNESS_EXCEPTION_INCLUDED */\n"
  },
  {
    "path": "src/harness/src/filesystem-posix.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n// On OSX, this causes __DARWIN_C_LEVEL to be upgraded to __DARWIN_C_FULL in\n// sys/cdefs.h, which in turn enables non-POSIX extensions such as mkdtemp().\n// Needs to be set before sys/cdefs.h gets #included (from any other headers),\n// thus best left here before any #includes.\n#ifdef __APPLE__\n#  define _DARWIN_C_SOURCE\n#endif\n\n#include \"common.h\"\n#include \"mysql/harness/filesystem.h\"\n\n#include <cassert>\n#include <sstream>\n#include <stdexcept>\n\n#include <dirent.h>\n#include <errno.h>\n#include <fnmatch.h>\n#include <string.h>\n#include <sys/stat.h>\n#include <sys/types.h>\n#include <unistd.h>\n\n#if defined(__sun) && defined(__SVR4) // Solaris\n  #include <limits.h> // PATH_MAX; maybe <climits> would be ok too,\n#endif                //           had no easy way of checking\n\nusing std::ostringstream;\nusing std::runtime_error;\nusing std::string;\n\nnamespace {\n  const std::string dirsep(\"/\");\n  const std::string extsep(\".\");\n}\n\nnamespace mysql_harness {\n\n////////////////////////////////////////////////////////////////\n// class Path members and free functions\n\nconst char * const Path::directory_separator = \"/\";\nconst char * const Path::root_directory = \"/\";\n\nPath::FileType Path::type(bool refresh) const {\n  validate_non_empty_path();\n  if (type_ == FileType::TYPE_UNKNOWN || refresh) {\n    struct stat stat_buf;\n    if (stat(c_str(), &stat_buf) == -1) {\n      if (errno == ENOENT || errno == ENOTDIR)\n        type_ = FileType::FILE_NOT_FOUND;\n      else\n        type_ = FileType::STATUS_ERROR;\n    } else {\n      switch (stat_buf.st_mode & S_IFMT) {\n      case S_IFDIR:\n        type_ = FileType::DIRECTORY_FILE;\n        break;\n      case S_IFBLK:\n        type_ = FileType::BLOCK_FILE;\n        break;\n      case S_IFCHR:\n        type_ = FileType::CHARACTER_FILE;\n        break;\n      case S_IFIFO:\n        type_ = FileType::FIFO_FILE;\n        break;\n      case S_IFLNK:\n        type_ = FileType::SYMLINK_FILE;\n        break;\n      case S_IFREG:\n        type_ = FileType::REGULAR_FILE;\n        break;\n      case S_IFSOCK:\n        type_ = FileType::SOCKET_FILE;\n        break;\n      default:\n        type_ = FileType::TYPE_UNKNOWN;\n        break;\n      }\n    }\n  }\n  return type_;\n}\n\n////////////////////////////////////////////////////////////////\n// Directory::DirectoryIterator\n\nclass Directory::DirectoryIterator::State {\n public:\n  State();\n  State(const Path& path, const string& pattern);\n  ~State();\n\n  bool eof() const {\n    return result_ == nullptr;\n  }\n\n  void fill_result();\n\n  template <typename IteratorType>\n  static bool equal(const IteratorType& lhs, const IteratorType& rhs) {\n    assert(lhs != nullptr && rhs != nullptr);\n\n    // If either one is null (end iterators), they are equal if both\n    // are end iterators.\n    if (lhs->result_ == nullptr || rhs->result_ == nullptr)\n      return lhs->result_ == rhs->result_;\n\n    // Otherwise they are not equal (this is an input iterator and we\n    // should not compare entries received through different\n    // iterations.\n    return false;\n  }\n\n  DIR *dirp_;\n\n  struct free_dealloc {\n    void operator()(void* p) { if (p) free(p); }\n  };\n\n  std::unique_ptr<dirent, free_dealloc> entry_;\n  const string pattern_;\n  struct dirent *result_;\n};\n\n\nDirectory::DirectoryIterator::State::State()\n  : dirp_(nullptr), pattern_(\"\"), result_(nullptr) {}\n\nDirectory::DirectoryIterator::State::State(const Path& path,\n                                           const string& pattern)\n    : dirp_(opendir(path.c_str())), pattern_(pattern) {\n\n  // dirent can be NOT large enough to hold a directory name, so we need to\n  // ensure there's extra space for it. From the \"man readdir_r\":\n  // \"Since POSIX.1 does not specify the size of the d_name field, and other nonstandard fields may\n  //  precede that field within the dirent structure, portable  applications\n  //  that use readdir_r() should allocate the buffer whose address is passed in entry as follows:\n  //    name_max = pathconf(dirpath, _PC_NAME_MAX);\n  //    if (name_max == -1)         /* Limit not defined, or error */\n  //        name_max = 255;         /* Take a guess */\n  //    len = offsetof(struct dirent, d_name) + name_max + 1;\n  //    entryp = malloc(len);\n  //  (POSIX.1 requires that d_name is the last field in a struct dirent.)\"\n  size_t alloc_size = sizeof(struct dirent) + (size_t)pathconf(path.str().c_str(), _PC_NAME_MAX) + 1;\n\n  // We need RAII here as we throw an exception in the constructor which means we can't rely\n  // on the desctructor always being called\n  entry_.reset((struct dirent*)malloc(alloc_size));\n  result_ = entry_.get();\n\n  if (dirp_ == nullptr) {\n    ostringstream buffer;\n    char buf[256];\n    if (strerror_r(errno, buf, sizeof(buf)) != 0)\n      buffer << \"Failed to open path \" << path << \" - \" << errno;\n    else\n      buffer << \"Failed to open path \" << path << \" - \" << buf;\n    throw runtime_error(buffer.str());\n  }\n\n  fill_result();\n}\n\n\nDirectory::DirectoryIterator::State::~State() {\n  // There is no guarantee that calling closedir() with NULL will\n  // work. For example, BSD systems do not always support this.\n  if (dirp_ != nullptr)\n    closedir(dirp_);\n}\n\nvoid Directory::DirectoryIterator::State::fill_result() {\n  // This is similar to scandir(2), but we do not use scandir(2) since\n  // we want to be thread-safe.\n\n  // If we have reached the end, filling do not have any effect.\n  if (result_ == nullptr)\n    return;\n\n  while (true) {\n    // new GCC doesn't like readdir_r(), and deprecates it in favor of\n    // readdir(). However, readdir() is not thread-safe on all platforms yet.\n    MYSQL_HARNESS_DISABLE_WARNINGS()\n    int error = readdir_r(dirp_, entry_.get(), &result_);\n    MYSQL_HARNESS_ENABLE_WARNINGS()\n\n    if (error) {\n      ostringstream buffer;\n      char msg[256];\n      if (strerror_r(error, msg, sizeof(msg)))\n        buffer << \"strerror_r failed: \" << errno;\n      else\n        buffer << \"Failed to read directory entry - \" << msg;\n      throw std::runtime_error(buffer.str());\n    }\n\n    // If there are no more entries, we're done.\n    if (result_ == nullptr)\n      break;\n\n    // Skip current directory and parent directory.\n    if (strcmp(result_->d_name, \".\") == 0 ||\n        strcmp(result_->d_name, \"..\") == 0)\n      continue;\n\n    // If no pattern is given, we're done.\n    if (pattern_.size() == 0)\n      break;\n\n    // Skip any entries that do not match the pattern\n    error = fnmatch(pattern_.c_str(), result_->d_name, FNM_PATHNAME);\n    if (error == FNM_NOMATCH) {\n      continue;\n    } else if (error == 0) {\n      break;\n    } else {\n      ostringstream buffer;\n      char msg[256];\n      if (strerror_r(error, msg, sizeof(msg)))\n        buffer << \"strerror_r failed: \" << errno;\n      else\n        buffer << \"Match failed - \" << msg;\n      throw std::runtime_error(buffer.str());\n    }\n  }\n}\n\n\n////////////////////////////////////////////////////////////////\n// Directory::DirectoryIterator\n\n// These definition of the default constructor and destructor need to\n// be here since the automatically generated default\n// constructor/destructor uses the definition of the class 'State',\n// which is not available when the header file is read.\nDirectory::DirectoryIterator::~DirectoryIterator() {}\nDirectory::DirectoryIterator::DirectoryIterator(\n    DirectoryIterator&&) = default;\nDirectory::DirectoryIterator::DirectoryIterator(\n    const DirectoryIterator& other) : DirectoryIteratorBase(other), path_(other.path_), pattern_(other.pattern_), state_(other.state_) {\n}\n\nDirectory::DirectoryIterator::DirectoryIterator()\n  : path_(\"*END*\"), state_(std::make_shared<State>()) {}\n\n\nDirectory::DirectoryIterator::DirectoryIterator(const Path& path,\n                              const string& pattern)\n  : path_(path), state_(std::make_shared<State>(path, pattern)) {}\n\n\nDirectory::DirectoryIterator& Directory::DirectoryIterator::operator++() {\n  assert(state_ != nullptr);\n  state_->fill_result();\n  return *this;\n}\n\n\nPath Directory::DirectoryIterator::operator*() const {\n  assert(state_ != nullptr && state_->result_ != nullptr);\n  return path_.join(state_->result_->d_name);\n}\n\nbool\nDirectory::DirectoryIterator::operator!=(\n    const Directory::DirectoryIterator& rhs) const {\n  return !State::equal(state_, rhs.state_);\n}\n\nPath\nPath::make_path(const Path& dir,\n                const std::string& base,\n                const std::string& ext) {\n  return dir.join(base + extsep + ext);\n}\n\nPath Path::real_path() const {\n  validate_non_empty_path();\n  char buf[PATH_MAX];\n  if (realpath(c_str(), buf))\n    return Path(buf);\n  else\n    return Path();\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// Utility free functions\n//\n////////////////////////////////////////////////////////////////////////////////\n\nint delete_dir(const std::string& dir) noexcept {\n  return ::rmdir(dir.c_str());\n}\n\nint delete_file(const std::string& path) noexcept {\n  return ::unlink(path.c_str());\n}\n\nstd::string get_tmp_dir(const std::string& name) {\n  const size_t MAX_LEN = 256;\n  const std::string pattern_str = std::string(name + \"-XXXXXX\");\n  const char* pattern = pattern_str.c_str();\n  if (strlen(pattern) >= MAX_LEN) {\n    throw std::runtime_error(\"Could not create temporary directory, name too long\");\n  }\n  char buf[MAX_LEN];\n  strncpy(buf, pattern, sizeof(buf)-1);\n  const char *res = mkdtemp(buf);\n  if (res == nullptr) {\n    throw std::runtime_error(\"Could not create temporary directory\");\n  }\n\n  return std::string(res);\n}\n\n} // namespace mysql_harness\n"
  },
  {
    "path": "src/harness/src/filesystem-windows.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"filesystem.h\"\n\n#include <cassert>\n#include <cerrno>\n#include <direct.h>\n#include <random>\n#include <sstream>\n#include <stdexcept>\n#include <string>\n\n#include <sys/stat.h>\n#include <sys/types.h>\n#include <windows.h>\n#include <shlwapi.h>\n\nusing std::string;\nusing std::ostringstream;\nusing std::runtime_error;\n\nnamespace {\n  std::string get_last_error() {\n    char message[512];\n    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM\n      | FORMAT_MESSAGE_IGNORE_INSERTS\n      | FORMAT_MESSAGE_ALLOCATE_BUFFER,\n      nullptr, GetLastError(),\n      LANG_NEUTRAL, message, sizeof(message),\n      nullptr);\n    return std::string(message);\n  }\n  const std::string dirsep(\"/\");\n  const std::string extsep(\".\");\n}\n\nnamespace mysql_harness {\n\n////////////////////////////////////////////////////////////////\n// class Path members and free functions\n\n// We normalize the Path class to use / internally, to avoid problems\n// with code that assume \\ to be an escape character\nconst char * const Path::directory_separator = \"/\";\nconst char * const Path::root_directory = \"/\";\n\nPath::FileType Path::type(bool refresh) const {\n  validate_non_empty_path();\n  if (type_ == FileType::TYPE_UNKNOWN || refresh) {\n    struct _stat stat_buf;\n    if (_stat(c_str(), &stat_buf) == -1) {\n      if (errno == ENOENT) {\n        // Special case, a drive name like \"C:\"\n        if (path_[path_.size() - 1] == ':')\n        {\n          DWORD flags = GetFileAttributesA(path_.c_str());\n          // API reports it as directory if it exist\n          if (flags & FILE_ATTRIBUTE_DIRECTORY) {\n            type_ = FileType::DIRECTORY_FILE;\n            return type_;\n          }\n        }\n        type_ = FileType::FILE_NOT_FOUND;\n      } else if (errno == EINVAL)\n        type_ = FileType::STATUS_ERROR;\n    } else {\n      switch (stat_buf.st_mode & S_IFMT) {\n      case S_IFDIR:\n        type_ = FileType::DIRECTORY_FILE;\n        break;\n      case S_IFCHR:\n        type_ = FileType::CHARACTER_FILE;\n        break;\n      case S_IFREG:\n        type_ = FileType::REGULAR_FILE;\n        break;\n      default:\n        type_ = FileType::TYPE_UNKNOWN;\n        break;\n      }\n    }\n  }\n  return type_;\n}\n\n////////////////////////////////////////////////////////////////\n// Directory::Iterator::State\n\nclass Directory::DirectoryIterator::State {\n public:\n  State();\n  State(const Path& path, const string& pattern);\n  ~State();\n\n  void fill_result();\n\n  template <typename IteratorType>\n  static bool equal(const IteratorType& lhs, const IteratorType& rhs) {\n    assert(lhs != nullptr && rhs != nullptr);\n\n    // If either interator is an end iterator, they are equal if both\n    // are end iterators.\n    if (!lhs->more_ || !rhs->more_)\n      return lhs->more_ == rhs->more_;\n\n    // Otherwise, they are not equal (since we are using input\n    // iterators, they do not compare equal in any other cases).\n    return false;\n  }\n\n  WIN32_FIND_DATA data_;\n  HANDLE handle_;\n  bool more_;\n  const string pattern_;\n\n private:\n  static const char* dot;\n  static const char* dotdot;\n};\n\nconst char* Directory::DirectoryIterator::State::dot = \".\";\nconst char* Directory::DirectoryIterator::State::dotdot = \"..\";\n\nDirectory::DirectoryIterator::State::State()\n  : handle_(INVALID_HANDLE_VALUE), more_(false), pattern_(\"\") {}\n\nDirectory::DirectoryIterator::State::State(const Path& path,\n                                  const string& pattern)\n  : handle_(INVALID_HANDLE_VALUE), more_(true), pattern_(pattern) {\n  const Path r_path = path.real_path();\n  const string pat = r_path.join(pattern.size() > 0 ? pattern : \"*\").str();\n\n  if (pat.size() > MAX_PATH) {\n    ostringstream  buffer;\n    buffer << \"Failed to open path \" << path << \" - \" << \"path too long\";\n    throw runtime_error(buffer.str());\n  }\n\n  handle_ = FindFirstFile(pat.c_str(), &data_);\n  bool first = true;\n  if (handle_ != INVALID_HANDLE_VALUE) {\n    more_ = true;\n\n    while (more_) {\n      if (first)\n        first = false;\n      else\n        more_ = (FindNextFile(handle_, &data_) != 0);\n      if (!more_) {\n        int error = GetLastError();\n        if (error != ERROR_NO_MORE_FILES) {\n          ostringstream buffer;\n          buffer << \"Failed to read directory entry - \"\n            << get_last_error();\n          throw runtime_error(buffer.str());\n        }\n      } else {\n        // Skip current directory and parent directory.\n        if (!strcmp(data_.cFileName, dot) || !strcmp(data_.cFileName, dotdot))\n          continue;\n\n        // If no pattern is given, we're done.\n        if (pattern_.size() == 0)\n          break;\n\n        BOOL result = PathMatchSpecA(data_.cFileName, pattern_.c_str());\n        if (!result)\n          continue;\n        else\n          break;\n      }\n    }\n  } else {\n    throw runtime_error(\"FindFirstFile - \" + get_last_error());\n  }\n}\n\nDirectory::DirectoryIterator::State::~State() {\n  if (handle_ != INVALID_HANDLE_VALUE)\n    FindClose(handle_);\n}\n\n\nvoid Directory::DirectoryIterator::State::fill_result() {\n  assert(handle_ != INVALID_HANDLE_VALUE);\n  while (true) {\n    more_ = (FindNextFile(handle_, &data_) != 0);\n    if (!more_) {\n      int error = GetLastError();\n      if (error != ERROR_NO_MORE_FILES) {\n        ostringstream buffer;\n        buffer << \"Failed to read directory entry - \"\n               << get_last_error();\n        throw runtime_error(buffer.str());\n      } else {\n        break;\n      }\n    } else {\n      // Skip current directory and parent directory.\n      if (!strcmp(data_.cFileName, dot) || !strcmp(data_.cFileName, dotdot))\n        continue;\n\n      // If no pattern is given, we're done.\n      if (pattern_.size() == 0)\n        break;\n\n      // Skip any entries that do not match the pattern\n      BOOL result = PathMatchSpecA(data_.cFileName, pattern_.c_str());\n      if (!result)\n        continue;\n      else\n        break;\n    }\n  }\n}\n\n\n////////////////////////////////////////////////////////////////\n// Directory::Iterator\n\n// These definition of the default constructor and destructor need to\n// be here since the automatically generated default\n// constructor/destructor uses the definition of the class 'State',\n// which is not available when the header file is read.\n#if !defined(_MSC_VER) || (_MSC_VER >= 1900)\nDirectory::DirectoryIterator::~DirectoryIterator() = default;\nDirectory::DirectoryIterator::DirectoryIterator(\n    DirectoryIterator&&) = default;\nDirectory::DirectoryIterator::DirectoryIterator(\n    const DirectoryIterator&) = default;\n#elif defined(_MSC_VER)\nDirectory::DirectoryIterator::~DirectoryIterator() {\n  state_.reset();\n}\n#endif\n\nDirectory::DirectoryIterator::DirectoryIterator()\n  : path_(\"*END*\"), state_(std::make_shared<State>()) {}\n\n\nDirectory::DirectoryIterator::DirectoryIterator(const Path& path,\n                                                const std::string& pattern)\n  : path_(path.real_path()), state_(std::make_shared<State>(path, pattern)) {}\n\n\nDirectory::DirectoryIterator& Directory::DirectoryIterator::operator++() {\n  assert(state_ != nullptr);\n  state_->fill_result();\n  return *this;\n}\n\nPath Directory::DirectoryIterator::operator*() const {\n  assert(state_ != nullptr && state_->handle_ != INVALID_HANDLE_VALUE);\n  return path_.join(state_->data_.cFileName);\n}\n\nbool\nDirectory::DirectoryIterator::operator!=(const DirectoryIterator& rhs) const {\n  return !State::equal(state_, rhs.state_);\n}\n\nPath\nPath::make_path(const Path& dir,\n                const std::string& base,\n                const std::string& ext) {\n  return dir.join(base + extsep + ext);\n}\n\nPath Path::real_path() const {\n  validate_non_empty_path();\n\n  // store a copy of str() in native_path\n  assert(0 < str().size() && str().size() < MAX_PATH);\n  char native_path[MAX_PATH];\n  std::memcpy(native_path, c_str(), str().size() + 1); // +1 for null terminator\n\n  // replace all '/' with '\\'\n  char* p = native_path;\n  while (*p) {\n    if (*p == '/') {\n      *p = '\\\\';\n    }\n    p++;\n  }\n\n  // resolve absolute path\n  char path[MAX_PATH];\n  if (GetFullPathNameA(native_path, sizeof(path), path, nullptr) == 0) {\n    return Path();\n  }\n\n  // check if the path exists, to match posix behaviour\n  WIN32_FIND_DATA find_data;\n  HANDLE h = FindFirstFile(path, &find_data);\n  if (h == INVALID_HANDLE_VALUE) {\n    auto error = GetLastError();\n    // If we got ERROR_ACCESS_DENIED here that does not necessarily mean\n    // that the path does not exist. We still can have the access to the\n    // file itself but we can't call the Find on the directory that contains\n    // the file. (This is true for example when the config file is placed in\n    // the User's directory and it is accesseed by the router that is run\n    // as a Windows service.)\n    // In that case we do not treat that as an error.\n    if (error != ERROR_ACCESS_DENIED) {\n      return Path();\n    }\n  }\n  else {\n    FindClose(h);\n  }\n\n  return Path(path);\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// Utility free functions\n//\n////////////////////////////////////////////////////////////////////////////////\n\nint delete_dir(const std::string& dir) noexcept {\n  return _rmdir(dir.c_str());\n}\n\nint delete_file(const std::string& path) noexcept {\n  // In Windows a file recently closed may fail to be deleted because its\n  // still be locked (or have a 3rd party reading it, like an Indexer service\n  // or AntiVirus). So the recommended is to retry the delete operation.\n  BOOL flag = TRUE;\n  int max_attempts = 10;\n  while (max_attempts--)\n  {\n    flag = DeleteFile(path.c_str());\n    DWORD err = GetLastError();\n    if (flag) break;\n    else if (err == ERROR_FILE_NOT_FOUND) { flag = 1; break; }\n    else if (err == ERROR_ACCESS_DENIED) { Sleep(100); continue; }\n    else { return -1; }\n  }\n\n  return flag ? 0 : -1;\n}\n\nstd::string get_tmp_dir(const std::string& name) {\n  char buf[MAX_PATH];\n  auto res = GetTempPath(MAX_PATH, buf);\n  if (res == 0 || res > MAX_PATH) {\n    throw std::runtime_error(\"Could not get temporary directory\");\n  }\n\n  auto generate_random_sequence = [](size_t len) -> std::string {\n    std::random_device rd;\n    std::string result;\n    static const char alphabet[] = \"abcdefghijklmnopqrstuvwxyz\";\n    std::uniform_int_distribution<unsigned long> dist(0, sizeof(alphabet) - 2);\n\n    for (size_t i = 0; i < len; ++i) {\n      result += alphabet[dist(rd)];\n    }\n\n    return result;\n  };\n\n  std::string dir_name = name + \"-\" + generate_random_sequence(10);\n  std::string result = Path(buf).join(dir_name).str();\n  int err = _mkdir(result.c_str());\n  if (err != 0) {\n    throw std::runtime_error(\"Error creating temporary directory \" + result);\n  }\n  return result;\n}\n\n} // namespace mysql_harness\n"
  },
  {
    "path": "src/harness/src/filesystem.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql/harness/filesystem.h\"\n\n#include <cstring>\n#include <ostream>\n#include <fstream>\n\nusing std::string;\n\nnamespace mysql_harness {\n\n////////////////////////////////////////////////////////////////\n// class Path members and free functions\n\nPath::Path() noexcept : type_(FileType::EMPTY_PATH) {}\n\n// throws std::invalid_argument\nPath::Path(const string& path) : path_(path), type_(FileType::TYPE_UNKNOWN) {\n#ifdef _WIN32\n  // in Windows, we normalize directory separator from \\ to /, to not\n  // confuse the rest of the code, which assume \\ to be an escape char\n  std::string::size_type p = path_.find('\\\\');\n  while (p != std::string::npos) {\n    path_[p] = '/';\n    p = path_.find('\\\\');\n  }\n#endif\n  string::size_type pos = path_.find_last_not_of(directory_separator);\n  if (pos != string::npos)\n    path_.erase(pos + 1);\n  else if (path_.size() > 0)\n    path_.erase(1);\n  else\n    throw std::invalid_argument(\"Empty path\");\n}\n\n// throws std::invalid_argument\nPath::Path(const char* path) : Path(string(path)) {}\n\n// throws std::invalid_argument\nvoid Path::validate_non_empty_path() const {\n  if (!is_set()) {\n    throw std::invalid_argument(\"Empty path\");\n  }\n}\n\nbool Path::operator==(const Path& rhs) const {\n  return real_path().str() == rhs.real_path().str();\n}\n\n\nbool Path::operator<(const Path& rhs) const {\n  return path_ < rhs.path_;\n}\n\n\nPath Path::basename() const {\n  validate_non_empty_path();  // throws std::invalid_argument\n  string::size_type pos = path_.find_last_of(directory_separator);\n  if (pos == string::npos)\n    return *this;\n  else if (pos > 1)\n    return string(path_, pos + 1);\n  else\n    return Path(root_directory);\n}\n\n\nPath Path::dirname() const {\n  validate_non_empty_path();  // throws std::invalid_argument\n  string::size_type pos = path_.find_last_of(directory_separator);\n  if (pos == string::npos)\n    return Path(\".\");\n  else if (pos > 1)\n    return string(path_, 0, pos);\n  else\n    return Path(root_directory);\n}\n\nbool Path::is_directory() const {\n  validate_non_empty_path();  // throws std::invalid_argument\n  return type() == FileType::DIRECTORY_FILE;\n}\n\nbool Path::is_regular() const {\n  validate_non_empty_path();  // throws std::invalid_argument\n  return type() == FileType::REGULAR_FILE;\n}\n\nbool Path::exists() const {\n  validate_non_empty_path();  // throws std::invalid_argument\n  return type() != FileType::FILE_NOT_FOUND\n    && type() != FileType::STATUS_ERROR;\n}\n\nbool Path::is_readable() const {\n  validate_non_empty_path();\n  return exists() && std::ifstream(real_path().str()).good();\n}\n\nvoid Path::append(const Path& other) {\n  validate_non_empty_path();  // throws std::invalid_argument\n  other.validate_non_empty_path();  // throws std::invalid_argument\n  path_.append(directory_separator + other.path_);\n  type_ = FileType::TYPE_UNKNOWN;\n}\n\n\nPath Path::join(const Path& other) const {\n  validate_non_empty_path();  // throws std::invalid_argument\n  other.validate_non_empty_path();  // throws std::invalid_argument\n  Path result(*this);\n  result.append(other);\n  return result;\n}\n\nstd::ostream& operator<<(std::ostream& out, Path::FileType type) {\n  static const char* type_names[]{\n    \"ERROR\",\n    \"not found\",\n    \"regular\",\n    \"directory\",\n    \"symlink\",\n    \"block device\",\n    \"character device\",\n    \"FIFO\",\n    \"socket\",\n    \"UNKNOWN\",\n  };\n  out << type_names[static_cast<int>(type)];\n  return out;\n}\n\n\n///////////////////////////////////////////////////////////\n// Directory::Iterator members\n\nDirectory::DirectoryIterator Directory::begin() {\n  return DirectoryIterator(*this);\n}\n\n\nDirectory::DirectoryIterator Directory::glob(const string& pattern) {\n  return DirectoryIterator(*this, pattern);\n}\n\n\nDirectory::DirectoryIterator Directory::end() {\n  return DirectoryIterator();\n}\n\n///////////////////////////////////////////////////////////\n// Directory members\n\nDirectory::~Directory() = default;\n\n// throws std::invalid_argument\nDirectory::Directory(const Path& path) : Path(path) {}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// Utility free functions\n//\n////////////////////////////////////////////////////////////////////////////////\n\nint delete_dir_recursive(const std::string& dir) noexcept {\n  mysql_harness::Directory d(dir);\n  try {\n    for (auto const &f : d) {\n      if (f.is_directory()) {\n        if (delete_dir_recursive(f.str()) < 0)\n          return -1;\n      } else {\n        if (delete_file(f.str()) < 0)\n          return -1;\n      }\n    }\n  } catch (...) {\n    return -1;\n  }\n  return delete_dir(dir);\n}\n\n} // namespace mysql_harness\n"
  },
  {
    "path": "src/harness/src/hostname_validator.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"hostname_validator.h\"\n#include \"harness_assert.h\"\n\n#ifdef _WIN32\n#  define USE_STD_REGEX // flag that C++11 regex is fully supported\n#endif\n\n#ifdef USE_STD_REGEX\n#  include <regex>\n#else\n#  include <regex.h>\n#endif\n\nnamespace mysql_harness {\n\nbool is_valid_hostname(const char* hostname) {\n\n  // WARNING! This is minimalistic validation, it doesn't catch all cornercases.\n  //          Please see notes in Doxygen function description.\n\n  const char re_text[] = \"^[-._a-z0-9]+$\";\n  bool is_valid;\n#ifdef USE_STD_REGEX\n  is_valid = std::regex_match(hostname, std::regex(re_text, std::regex::icase));\n#else\n  regex_t re;\n  harness_assert(!regcomp(&re, re_text, REG_EXTENDED | REG_ICASE | REG_NOSUB));\n  is_valid = !regexec(&re, hostname, 0, nullptr, 0);\n  regfree(&re);\n#endif\n\n  return is_valid;\n}\n\n} // namespace mysql_harness\n"
  },
  {
    "path": "src/harness/src/keyring/keyring_file.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"keyring/keyring_file.h\"\n#include \"common.h\"\n#include <fstream>\n#include <memory>\n#include <string.h>\n#include <system_error>\n\n#ifdef _WIN32\n#include <aclapi.h>\n#else\n#include <sys/stat.h>\n#endif\n\nconstexpr const char kKeyringFileSignature[] = {'M', 'R', 'K', 'R'};\n\n#ifdef _WIN32\n\n// Smart pointers for WinAPI structures that use C-style memory management.\nusing SecurityDescriptorPtr =\n    std::unique_ptr<SECURITY_DESCRIPTOR,\n                    mysql_harness::StdFreeDeleter<SECURITY_DESCRIPTOR>>;\nusing SidPtr = std::unique_ptr<SID, mysql_harness::StdFreeDeleter<SID>>;\n\n/**\n * Retrieves file's DACL security descriptor.\n *\n * @param[in] file_name File name.\n *\n * @return File's DACL security descriptor.\n *\n * @except std::exception Failed to retrieve security descriptor.\n */\nstatic SecurityDescriptorPtr get_security_descriptor(\n    const std::string& file_name) {\n  static constexpr SECURITY_INFORMATION kReqInfo = DACL_SECURITY_INFORMATION;\n\n  // Get the size of the descriptor.\n  DWORD sec_desc_size;\n\n  if (GetFileSecurityA(file_name.c_str(), kReqInfo, nullptr,\n                       0, &sec_desc_size) == FALSE) {\n    // calling code checks for errno\n    // also multiple calls to GetLastError() erase error value\n    errno = GetLastError();\n\n    // We expect to receive `ERROR_INSUFFICIENT_BUFFER`.\n    if (errno != ERROR_INSUFFICIENT_BUFFER) {\n      throw std::system_error(errno, std::system_category(), \"GetFileSecurity() failed (\" + file_name +\n                               \"): \" + std::to_string(errno));\n    }\n  }\n\n  SecurityDescriptorPtr sec_desc(\n      static_cast<SECURITY_DESCRIPTOR*>(std::malloc(sec_desc_size)));\n\n  if (GetFileSecurityA(file_name.c_str(), kReqInfo, sec_desc.get(),\n                       sec_desc_size, &sec_desc_size) == FALSE) {\n    errno = GetLastError();\n    throw std::system_error(errno, std::system_category(), \"GetFileSecurity() failed (\" + file_name + \"): \" +\n                             std::to_string(GetLastError()));\n  }\n\n  return sec_desc;\n}\n\n/**\n * Verifies permissions of an access ACE entry.\n *\n * @param[in] access_ace Access ACE entry.\n *\n * @except std::exception Everyone has access to the ACE access entry or\n *                        an error occured.\n */\nstatic void check_ace_access_rights(ACCESS_ALLOWED_ACE* access_ace) {\n  SID* sid = reinterpret_cast<SID*>(&access_ace->SidStart);\n  DWORD sid_size = SECURITY_MAX_SID_SIZE;\n  SidPtr everyone_sid(static_cast<SID*>(std::malloc(sid_size)));\n\n  if (CreateWellKnownSid(WinWorldSid, nullptr,\n                         everyone_sid.get(), &sid_size) == FALSE) {\n    throw std::runtime_error(\"CreateWellKnownSid() failed: \" +\n                             std::to_string(GetLastError()));\n  }\n\n  if (EqualSid(sid, everyone_sid.get())) {\n    if (access_ace->Mask & (FILE_EXECUTE)) {\n      throw std::runtime_error(\"Invalid keyring file access rights \"\n                               \"(Execute privilege granted to Everyone).\");\n    }\n    if (access_ace->Mask &\n        (FILE_WRITE_DATA | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES)) {\n      throw std::runtime_error(\"Invalid keyring file access rights \"\n                               \"(Write privilege granted to Everyone).\");\n    }\n    if (access_ace->Mask &\n        (FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES)) {\n      throw std::runtime_error(\"Invalid keyring file access rights \"\n                               \"(Read privilege granted to Everyone).\");\n    }\n  }\n}\n\n/**\n * Verifies access permissions in a DACL.\n *\n * @param[in] dacl DACL to be verified.\n *\n * @except std::exception DACL contains an ACL entry that grants full access to\n *                        Everyone or an error occured.\n */\nstatic void check_acl_access_rights(ACL* dacl) {\n  ACL_SIZE_INFORMATION dacl_size_info;\n\n  if (GetAclInformation(dacl, &dacl_size_info, sizeof(dacl_size_info),\n                        AclSizeInformation) == FALSE) {\n    throw std::runtime_error(\"GetAclInformation() failed: \" +\n                             std::to_string(GetLastError()));\n  }\n\n  for (DWORD ace_idx = 0; ace_idx < dacl_size_info.AceCount; ++ace_idx) {\n    LPVOID ace = nullptr;\n\n    if (GetAce(dacl, ace_idx, &ace) == FALSE) {\n      throw std::runtime_error(\"GetAce() failed: \" +\n                               std::to_string(GetLastError()));\n      continue;\n    }\n\n    if (static_cast<ACE_HEADER*>(ace)->AceType == ACCESS_ALLOWED_ACE_TYPE)\n      check_ace_access_rights(static_cast<ACCESS_ALLOWED_ACE*>(ace));\n  }\n}\n\n/**\n * Verifies access permissions in a security descriptor.\n *\n * @param[in] sec_desc Security descriptor to be verified.\n *\n * @except std::exception Security descriptor grants full access to\n *                        Everyone or an error occured.\n */\nstatic void check_security_descriptor_access_rights(\n    SecurityDescriptorPtr sec_desc) {\n  BOOL dacl_present;\n  ACL* dacl;\n  BOOL dacl_defaulted;\n\n  if (GetSecurityDescriptorDacl(sec_desc.get(), &dacl_present, &dacl,\n                                &dacl_defaulted) == FALSE) {\n    throw std::runtime_error(\"GetSecurityDescriptorDacl() failed: \" +\n                             std::to_string(GetLastError()));\n  }\n\n  if (!dacl_present) {\n    // No DACL means: no access allowed. Which is fine.\n    return;\n  }\n\n  if (!dacl) {\n    // Empty DACL means: all access allowed.\n      throw std::runtime_error(\"Invalid keyring file access rights \"\n                               \"(Everyone has full access rights).\");\n  }\n\n  check_acl_access_rights(dacl);\n}\n\n#endif // _WIN32\n\n/**\n * Verifies access permissions of a file.\n *\n * On Unix systems it throws if file's permissions differ from 600.\n * On Windows it throws if file can be accessed by Everyone group.\n *\n * @param[in] file_name File to be verified.\n *\n * @except std::exception File access rights are too permissive or\n *                        an error occured.\n * @except std::system_error OS and/or filesystem doesn't support file\n *                           permissions.\n */\nstatic void check_file_access_rights(const std::string& file_name) {\n#ifdef _WIN32\n  check_security_descriptor_access_rights(get_security_descriptor(file_name));\n#else\n  struct stat status;\n\n  if (stat(file_name.c_str(), &status) != 0) {\n    if (errno == ENOENT)\n      return;\n    throw std::runtime_error(\"stat() failed (\" + file_name + \"): \" +\n                             mysql_harness::get_strerror(errno));\n  }\n\n  static constexpr mode_t kFullAccessMask = (S_IRWXU | S_IRWXG | S_IRWXO);\n  static constexpr mode_t kRequiredAccessMask = (S_IRUSR | S_IWUSR);\n\n  if ((status.st_mode & kFullAccessMask) != kRequiredAccessMask)\n    throw std::runtime_error(\"Keyring file (\" + file_name + \") has file permissions that are not strict enough\"\n                             \" (only RW for file's owner is allowed).\");\n\n#endif // _WIN32\n}\n\n\nnamespace mysql_harness {\n\nvoid KeyringFile::set_header(const std::string &data) {\n  header_ = data;\n}\n\nvoid KeyringFile::save(const std::string& file_name,\n                       const std::string& key) const {\n  if (key.empty()) {\n    throw std::runtime_error(\"Keyring encryption key must not be blank\");\n  }\n  // Serialize keyring.\n  auto buffer = serialize(key);\n\n  // Save keyring data to file.\n  std::ofstream file;\n\n  file.exceptions(std::ofstream::failbit | std::ofstream::badbit);\n\n\n#ifndef _WIN32\n  try {\n    file.open(file_name,\n      std::ofstream::out | std::ofstream::binary | std::ofstream::trunc);\n  }\n  catch (std::exception& e) {\n    throw std::runtime_error(std::string(\"Failed to open keyring file for writing: \") +\n      file_name + \": \" + get_strerror(errno));\n  }\n#else\n  // For Microsoft Windows, on repeated saving of files (like our unit tests) the file opening sometimes fails with\n  // \"Access Denied\", since it works fine when disabling indexing of file contents for the whole folder\n  // we assume the indexer is not releasing the file fast enough.\n  // So here we simply retry the opening of the file.\n  int retries = 5;\n  do {\n    try {\n      file.open(file_name,\n        std::ofstream::out | std::ofstream::binary | std::ofstream::trunc);\n      break;\n    }\n    catch (const std::exception&) {\n      if (retries-- > 0) {\n        Sleep(100);\n        continue;\n      }\n      throw std::runtime_error(std::string(\"Failed to open keyring file for writing: \") +\n        file_name + \": \" + get_strerror(errno));\n    }\n  } while (true);\n#endif\n\n  try {\n    make_file_private(file_name);\n  } catch (const std::system_error &e) {\n#ifdef _WIN32\n      if (e.code() != std::error_code(ERROR_INVALID_FUNCTION, std::system_category()))\n        // if the filesystem can't set permissions, ignore it\n#endif\n        throw;\n  }\n\n  try {\n    // write signature\n    file.write(kKeyringFileSignature, sizeof(kKeyringFileSignature));\n    // write header\n    uint32_t header_size = static_cast<uint32_t>(header_.size());\n    file.write(reinterpret_cast<char*>(&header_size), sizeof(header_size));\n    if (header_.size() > 0)\n      file.write(header_.data(), static_cast<std::streamsize>(header_.size()));\n    // write data\n    file.write(buffer.data(), static_cast<std::streamsize>(buffer.size()));\n    file.close();\n  } catch (std::exception& e) {\n    throw std::runtime_error(std::string(\"Failed to save keyring file: \") +\n                             e.what());\n  }\n}\n\nstatic void verify_file_permissions(const std::string& file_name) {\n\n  // Verify keyring file's access permissions.\n  try {\n    // throws std::system_error if permissions are not supported by OS and/or filesystem\n    // throws std::runtime_error on bad permissions or error in retrieval\n    // file not existing is ok\n    check_file_access_rights(file_name);\n\n  } catch (const std::system_error &e) {\n#ifdef _WIN32\n      if (e.code() != std::error_code(ERROR_INVALID_FUNCTION, std::system_category()))\n        // if the filesystem can't set permissions, ignore it\n#endif\n        throw;\n  }\n}\n\nvoid KeyringFile::load(const std::string& file_name, const std::string& key) {\n\n  // throws std::runtime_error with appropriate error message on verification failure\n  verify_file_permissions(file_name);\n\n  // Read keyring data from file.\n  std::ifstream file;\n\n  file.exceptions(std::ifstream::failbit | std::ifstream::badbit);\n  try {\n    file.open(file_name,\n              std::ifstream::in | std::ifstream::binary | std::ifstream::ate);\n  } catch (const std::exception&) {\n    throw std::runtime_error(std::string(\"Failed to load keyring file: \") +\n                             file_name + \": \" + get_strerror(errno));\n  }\n\n  file.seekg(0, file.end);\n  std::size_t file_size = static_cast<std::size_t>(file.tellg());\n\n  // read and check signature\n  file.seekg(0, file.beg);\n  {\n    char sig[sizeof(kKeyringFileSignature)];\n    try {\n      file.read(sig, sizeof(sig));\n    } catch (const std::ios_base::failure& e) {\n      throw std::runtime_error(\"Failure reading contents of keyring file \" + file_name);\n    }\n    if (strncmp(sig, kKeyringFileSignature, sizeof(kKeyringFileSignature)) != 0)\n      throw std::runtime_error(\"Invalid data found in keyring file \" + file_name);\n  }\n  // read header, if there's one\n  {\n    uint32_t header_size;\n    file.read(reinterpret_cast<char*>(&header_size), sizeof(header_size));\n    if (header_size > 0) {\n      if (header_size > file_size - sizeof(kKeyringFileSignature) - sizeof(header_size)) {\n        throw std::runtime_error(\"Invalid data found in keyring file \" + file_name);\n      }\n      header_.resize(header_size);\n      file.read(&header_[0], static_cast<std::streamsize>(header_.size()));\n    }\n  }\n\n  std::size_t data_size = file_size - static_cast<std::size_t>(file.tellg());\n\n  std::vector<char> buffer(static_cast<std::size_t>(data_size));\n  file.read(buffer.data(), static_cast<std::streamsize>(buffer.size()));\n\n  // Parse keyring data.\n  parse(key, buffer.data(), buffer.size());\n}\n\nstd::string KeyringFile::read_header(const std::string& file_name) {\n\n  // throws std::runtime_error with appropriate error message on verification failure\n  verify_file_permissions(file_name);\n\n  // Read keyring data from file.\n  std::ifstream file;\n\n  file.exceptions(std::ifstream::failbit | std::ifstream::badbit);\n  try {\n    file.open(file_name,\n              std::ifstream::in | std::ifstream::binary | std::ifstream::ate);\n  } catch (const std::exception&) {\n    throw std::runtime_error(std::string(\"Failed to open keyring file: \") +\n                             file_name + \": \" + get_strerror(errno));\n  }\n\n  std::size_t file_size = static_cast<std::size_t>(file.tellg());\n\n  file.seekg(0);\n  // read and check signature\n  {\n    char sig[sizeof(kKeyringFileSignature)];\n    file.read(sig, sizeof(sig));\n    if (strncmp(sig, kKeyringFileSignature, sizeof(kKeyringFileSignature)) != 0)\n      throw std::runtime_error(\"Invalid data found in keyring file \" + file_name);\n  }\n  // read header, if there's one\n  std::string header;\n  {\n    uint32_t header_size;\n    file.read(reinterpret_cast<char*>(&header_size), sizeof(header_size));\n    if (header_size > 0) {\n      if (header_size > file_size - sizeof(kKeyringFileSignature) - sizeof(header_size)) {\n        throw std::runtime_error(\"Invalid data found in keyring file \" + file_name);\n      }\n      header.resize(header_size);\n      file.read(&header[0], static_cast<std::streamsize>(header.size()));\n    }\n  }\n  return header;\n}\n} // namespace mysql_harness\n"
  },
  {
    "path": "src/harness/src/keyring/keyring_manager.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"keyring/keyring_manager.h\"\n#include \"keyring/keyring_file.h\"\n#include \"mysql/harness/filesystem.h\"\n#include \"common.h\"\n#include \"dim.h\"\n#include \"mysqlrouter/my_aes.h\"\n#include \"random_generator.h\"\n#include <string.h>\n#include <random>\n#include <system_error>\n#include <fstream>\n#ifndef _WIN32\n#include <sys/stat.h>\n#else\n#include <windows.h>\n#endif\n\n\n/*\n * Keyring Management\n *\n * One or more passwords can be stored in the keyring, which is persisted on\n * disk in the keyring file.\n * The encryption key of the keyring can be fed to the keyring through an\n * auto-generated and persisted on a master key file\n *\n * The keyring's encryption key will be itself\n * encrypted by a second key, which is generated automatically and stored\n * in the keyring file. The location of the master key file is selected by the\n * user and the same key file can be shared by multiple keyrings.\n *\n * File Layout:\n *\n *  Keyring File                 KeyFile\n * +-------------+             +-------------------+\n * | KeyFile Key |             | Keyring File Name |\n * |-------------|             | Keyring Key       |\n * | Password    |             | Keyring File Name |\n * | Password    |             | Keyring Key       |\n * | ...         |             +-------------------+\n * +-------------+\n */\n\nnamespace mysql_harness {\n\nstatic std::unique_ptr<KeyringFile> g_keyring;\nstatic std::string g_keyring_file_path;\nstatic std::string g_keyring_key;\n\nconstexpr auto kAesMode = myaes::my_aes_256_cbc;\nconstexpr unsigned char kAesIv[] = {\n    0x39, 0x62, 0x9f, 0x52, 0x7f, 0x76, 0x9a, 0xae,\n    0xcd, 0xca, 0xf7, 0x04, 0x65, 0x8e, 0x5d, 0x88\n};\n\nstatic const unsigned kKeyLength = 32;\nstatic const char kMasterKeyFileSignature[] = \"MRKF\";\n\nclass MasterKeyFile {\npublic:\n  MasterKeyFile(const std::string &file)\n      : path_(file) {\n  }\n\n  void load() {\n    std::ifstream f;\n    if (Path(path_).is_directory())\n      throw invalid_master_keyfile(path_+\" is a directory\");\n    f.open(path_, std::ios_base::binary|std::ios_base::in);\n    if (f.fail()) {\n      throw std::system_error(std::error_code(errno, std::system_category()), \"Can't open file \"+path_);\n    }\n    char buf[sizeof(kMasterKeyFileSignature)] = {0};\n    f.read(buf, sizeof(buf));\n    if (strncmp(buf, kMasterKeyFileSignature, sizeof(kMasterKeyFileSignature)) != 0)\n      throw invalid_master_keyfile(\"Master key file (\" + path_ + \") has invalid file signature\");\n    entries_.clear();\n    try {\n      while (!f.eof()) {\n        uint32_t length;\n        f.read(reinterpret_cast<char*>(&length), sizeof(length));\n        std::string data;\n        data.resize(length);\n        f.read(&data[0], static_cast<std::streamsize>(data.size()));\n        std::string n, v;\n        n = std::string(data.data(), strlen(data.data()));\n        v = data.substr(n.size()+1);\n        entries_.push_back(std::make_pair(n, v));\n      }\n    } catch (std::exception &e) {\n      throw std::runtime_error(\"Error reading from master key file \"+path_+\n          \": \"+e.what());\n    }\n    f.close();\n  }\n\n  void save() {\n    std::ofstream f;\n    f.open(path_, std::ios_base::binary|std::ios_base::trunc|std::ios_base::out);\n    if (f.fail()) {\n      throw std::runtime_error(\"Could not open master key file \"+path_+\n          \": \"+get_strerror(errno));\n    }\n    try {\n      try {\n        make_file_private(path_);\n      } catch (const std::system_error &e) {\n#ifdef _WIN32\n        if (e.code() != std::error_code(ERROR_INVALID_FUNCTION, std::system_category()))\n            // if the filesystem can't set permissions, the test later would fail\n#endif\n          throw;\n      }\n    }\n    catch (std::exception &e) {\n      throw std::runtime_error(\"Could not set permissions of master key file \" + path_ +\n        \": \" + e.what());\n    }\n    f.write(kMasterKeyFileSignature, sizeof(kMasterKeyFileSignature));\n    for (auto &entry : entries_) {\n      uint32_t length = static_cast<uint32_t>(entry.first.length() + entry.second.length() + 1);\n      f.write(reinterpret_cast<char*>(&length), sizeof(length));\n      // write name of the entry\n      f.write(entry.first.data(), static_cast<std::streamsize>(entry.first.length()+1));\n      // write encrypted entry data\n      f.write(entry.second.data(), static_cast<std::streamsize>(entry.second.length()));\n    }\n    f.close();\n  }\n\n  void add(const std::string &id, const std::string &value,\n           const std::string &key) {\n    auto aes_buffer_size = myaes::my_aes_get_size(\n        static_cast<uint32_t>(value.length()), myaes::my_aes_256_cbc);\n    std::vector<char> aes_buffer(static_cast<size_t>(aes_buffer_size));\n\n    auto encrypted_size = myaes::my_aes_encrypt(\n        reinterpret_cast<const unsigned char*>(value.data()),\n        static_cast<uint32_t>(value.length()),\n        reinterpret_cast<unsigned char*>(aes_buffer.data()),\n        reinterpret_cast<const unsigned char*>(key.data()),\n        static_cast<uint32_t>(key.length()), myaes::my_aes_256_cbc, kAesIv);\n    if (encrypted_size < 0) {\n      throw std::runtime_error(\"Could not encrypt master key data\");\n    }\n    aes_buffer.resize(static_cast<std::size_t>(encrypted_size));\n    entries_.push_back(std::make_pair(id, std::string(&aes_buffer[0], aes_buffer.size())));\n  }\n\n  std::string get(const std::string &id, const std::string &key) {\n    for (auto &entry : entries_) {\n      if (entry.first == id) {\n        std::vector<char> decrypted_buffer(entry.second.size());\n\n        auto decrypted_size = my_aes_decrypt(\n            reinterpret_cast<const unsigned char*>(entry.second.data()),\n            static_cast<uint32_t>(entry.second.length()),\n            reinterpret_cast<unsigned char*>(decrypted_buffer.data()),\n            reinterpret_cast<const unsigned char*>(key.data()),\n            static_cast<uint32_t>(key.length()), kAesMode, kAesIv);\n\n        if (decrypted_size < 0)\n          throw decryption_error(\"Decryption failed.\");\n\n        // std::string() wants an 'unsigned ...', but my_aes_decript gives an signed int.\n        // Due to the use of 'auto', we don't know the target type at static_cast<> time\n        // and have to let the compiler do the work for us and let it figure out the right\n        // unsigned type at compile time.\n        return std::string(&decrypted_buffer[0], static_cast<std::make_unsigned<decltype(decrypted_size)>::type>(decrypted_size));\n      }\n    }\n    return \"\";\n  }\n\nprivate:\n  std::string path_;\n  std::vector<std::pair<std::string, std::string>> entries_;\n};\n\n\n/**\n * Gets the master_key for the specified keyring_file from the master key store.\n * If the master key store file does not exist, it will be created along with\n * a new master_key, which will be stored and also returned.\n * If the master key store already exists, but does not have an entry for the\n * master key, it will be generated and then stored.\n *\n * Returns the master_key and the scramble for the master_key\n */\nstatic std::pair<std::string,std::string>\n    get_master_key(MasterKeyFile &mkf,\n                   const std::string &keyring_file_path,\n                   bool create_if_needed) {\n  KeyringFile kf;\n\n  // get the scramble for the master key file from the keyring file itself\n  std::string master_scramble;\n\n  try {\n    master_scramble = kf.read_header(keyring_file_path);\n    if (master_scramble.empty()) {\n      throw std::runtime_error(\"Keyring file '\"+keyring_file_path+\"' was created in an old version and needs to be recreated. Please delete and bootstrap again.\");\n    }\n  } catch (std::exception&) {\n    if (errno != ENOENT || !create_if_needed)\n      throw;\n  }\n  std::string master_key;\n  // get the key for the keyring from the master key file, decrypting it with\n  // the scramble\n  if (!master_scramble.empty()) {\n    try {\n      // look up for the master_key for this given keyring file\n      master_key = mkf.get(keyring_file_path, master_scramble);\n    } catch (std::out_of_range&) {\n      // missing key will be handled further down\n    }\n  }\n  if (master_key.empty()) {\n    if (!create_if_needed)\n      throw std::runtime_error(\"Master key for keyring at '\" + keyring_file_path + \"' could not be read\");\n    // if the master key doesn't exist anywhere yet, generate one and store it\n    mysql_harness::RandomGeneratorInterface& rg = mysql_harness::DIM::instance().get_RandomGenerator();\n    master_key = rg.generate_strong_password(kKeyLength);\n    // scramble to encrypt the master key with, which should be stored in the\n    // keyring\n    master_scramble = rg.generate_strong_password(kKeyLength);\n    mkf.add(keyring_file_path, master_key, master_scramble);\n  }\n  return std::make_pair(master_key, master_scramble);\n}\n\nbool init_keyring(const std::string &keyring_file_path,\n                  const std::string &master_key_path,\n                  bool create_if_needed) {\n  std::string master_key;\n  std::string master_scramble;\n  MasterKeyFile mkf(master_key_path);\n\n  errno = 0;\n  try {\n    mkf.load();\n  } catch (std::exception&) {\n    if (errno == ENOENT && create_if_needed) {\n      // ignore the error and proceed to create the file\n    } else\n      throw;\n  }\n\n  // throws std::runtime_error (anything else?)\n  std::tie(master_key, master_scramble) = get_master_key(mkf,\n                                                         keyring_file_path,\n                                                         create_if_needed);\n\n  bool existed = init_keyring_with_key(keyring_file_path, master_key, create_if_needed);\n  if (create_if_needed && !existed) {\n    g_keyring->set_header(master_scramble);\n    flush_keyring();\n    try {\n      mkf.save();\n    } catch (...) {\n      throw std::runtime_error(\"Unable to save master key to \" + master_key_path\n          + \": \" + get_strerror(errno));\n    }\n  }\n  return existed;\n}\n\nbool init_keyring_with_key(const std::string &keyring_file_path,\n                           const std::string &master_key,\n                           bool create_if_needed) {\n  if (g_keyring)\n    throw std::logic_error(\"Keyring already initialized\");\n  bool existed = false;\n  std::unique_ptr<KeyringFile> key_store(new KeyringFile());\n  try {\n    key_store->load(keyring_file_path, master_key);\n    existed = true;\n  } catch (const std::exception &) {\n    if (!create_if_needed)\n      throw;\n    // force initial creation\n    key_store->save(keyring_file_path, master_key);\n  }\n  g_keyring = std::move(key_store);\n  g_keyring_file_path = keyring_file_path;\n  g_keyring_key = master_key;\n  return existed;\n}\n\nvoid flush_keyring() {\n  if (!g_keyring)\n    throw std::logic_error(\"No keyring loaded\");\n  g_keyring->save(g_keyring_file_path, g_keyring_key);\n}\n\nKeyring *get_keyring() {\n  return g_keyring.get();\n}\n\nvoid reset_keyring() {\n  g_keyring.reset();\n}\n\n\n}\n"
  },
  {
    "path": "src/harness/src/keyring/keyring_memory.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"keyring/keyring_memory.h\"\n#include \"mysqlrouter/my_aes.h\"\n#include <cstdint>\n#include <cstring>\n\n\nconstexpr auto kAesMode = myaes::my_aes_256_cbc;\nconstexpr unsigned char kAesIv[] = {\n    0x39, 0x62, 0x9f, 0x52, 0x7f, 0x76, 0x9a, 0xae,\n    0xcd, 0xca, 0xf7, 0x04, 0x65, 0x8e, 0x5d, 0x88\n};\n\nconstexpr std::uint32_t kKeyringDataSignature = 0x043d4d0a;\n\n\n// Writes a raw data to buffer and returns new buffer offset.\n// If buffer is null then doesn't write anything, but still returns the\n// correct offset.\nstatic std::size_t serialize(char* buffer, std::size_t offset,\n                             const void* data, std::size_t data_size) {\n  if (buffer)\n    std::memcpy(buffer + offset, data, data_size);\n\n  return offset + data_size;\n}\n\n// Writes a std::size_t value to buffer and returns new buffer offset.\n// If buffer is null then doesn't write anything, but still returns the\n// correct offset.\nstatic std::size_t serialize(char* buffer, std::size_t offset,\n                             std::size_t value) {\n  std::uint32_t value_u32 = static_cast<std::uint32_t>(value);\n\n  return serialize(buffer, offset, &value_u32, sizeof(value_u32));\n}\n\n// Writes a std::string to buffer (its size and contents) and returns new buffer\n// offset. If buffer is null then doesn't write anything, but still\n// returns the correct offset.\nstatic std::size_t serialize(char* buffer, std::size_t offset,\n                             const std::string& value) {\n  offset = serialize(buffer, offset, value.length());\n\n  return serialize(buffer, offset, value.data(), value.length());\n}\n\n// Writes entity map to buffer and returns numbers of bytes written.\n// If buffer is null then doesn't write anything, but still returns the\n// number of bytes that would have been written.\n// Warning: Buffer needs to be able to fit the entity map. It is possible to\n// make sure what size is required by calling the function with buffer pointer\n// set to null.\nstatic std::size_t serialize(\n    char* buffer,\n    const std::map<std::string, std::map<std::string, std::string>>& entries) {\n  // Save keyring file signature.\n  auto offset = serialize(buffer, 0, &kKeyringDataSignature,\n                          sizeof(kKeyringDataSignature));\n\n  // Save keyring format version.\n  offset = serialize(buffer, offset,\n                     mysql_harness::KeyringMemory::kFormatVersion);\n\n  // Save number of keyring entries.\n  offset = serialize(buffer, offset, entries.size());\n\n  // Save entries.\n  for (const auto& entry : entries) {\n    // Save entry name.\n    offset = serialize(buffer, offset, entry.first);\n\n    // Save number of entry attributes.\n    offset = serialize(buffer, offset, entry.second.size());\n\n    // Save entry attributes.\n    for (const auto& attribute : entry.second) {\n      // Save attribute name.\n      offset = serialize(buffer, offset, attribute.first);\n\n      // Save attribute value.\n      offset = serialize(buffer, offset, attribute.second);\n    }\n  }\n\n  return offset;\n}\n\n// Verifies if buffer has enough space for more data.\nstatic void check_buffer_size(std::size_t data_size, std::size_t buffer_size,\n                              std::size_t offset) {\n  if (offset + data_size > buffer_size)\n    throw std::out_of_range(\"Keyring input buffer invalid.\");\n}\n\n// Reads raw data from buffer and returns new buffer offset.\nstatic std::size_t parse(const char* buffer, std::size_t buffer_size,\n                         std::size_t offset, void* data,\n                         std::size_t data_size) {\n  check_buffer_size(data_size, buffer_size, offset);\n  std::memcpy(data, buffer + offset, data_size);\n\n  return offset + data_size;\n}\n\n// Reads a std::size_t value from buffer and returns new buffer offset.\nstatic std::size_t parse(const char* buffer, std::size_t buffer_size,\n                         std::size_t offset, std::size_t& value) {\n  std::uint32_t value_u32;\n\n  offset = parse(buffer, buffer_size, offset, &value_u32, sizeof(value_u32));\n  value = static_cast<std::size_t>(value_u32);\n\n  return offset;\n}\n\n// Reads a std::string value from buffer and returns new buffer offset.\nstatic std::size_t parse(const char* buffer, std::size_t buffer_size,\n                         std::size_t offset, std::string& value) {\n  std::size_t string_length;\n  offset = parse(buffer, buffer_size, offset, string_length);\n\n  check_buffer_size(string_length, buffer_size, offset);\n  value.assign(buffer + offset, string_length);\n  offset += string_length;\n\n  return offset;\n}\n\n// Reads an entity map from a buffer.\nstatic void parse(\n    const char* buffer, std::size_t buffer_size,\n    std::map<std::string, std::map<std::string, std::string>>& entries) {\n  // Parse keyring file signature.\n  std::uint32_t keyring_file_signature;\n  auto offset = parse(buffer, buffer_size, 0, &keyring_file_signature,\n                      sizeof(keyring_file_signature));\n\n  if (keyring_file_signature != kKeyringDataSignature) {\n    throw std::runtime_error(\n        \"Invalid keyring file signature. The file is damaged or decryption key \"\n        \"is invalid.\");\n  }\n\n  // Parse keyring format version.\n  std::size_t keyring_version;\n  offset = parse(buffer, buffer_size, offset, keyring_version);\n\n  if (keyring_version != mysql_harness::KeyringMemory::kFormatVersion)\n    throw std::runtime_error(\"Invalid keyring format version.\");\n\n  // Parse number of keyring entries.\n  std::size_t entry_count;\n  offset = parse(buffer, buffer_size, offset, entry_count);\n\n  for (std::size_t entry_idx = 0; entry_idx < entry_count; ++entry_idx) {\n    // Parse entry name.\n    std::string entry_name;\n    offset = parse(buffer, buffer_size, offset, entry_name);\n\n    // Parse number of entry attributes.\n    std::size_t attr_count;\n    offset = parse(buffer, buffer_size, offset, attr_count);\n\n    for (std::size_t attr_idx = 0; attr_idx < attr_count; ++attr_idx) {\n      // Parse attribute name.\n      std::string attr_name;\n      offset = parse(buffer, buffer_size, offset, attr_name);\n\n      // Parse attribute value.\n      std::string attr_value;\n      offset = parse(buffer, buffer_size, offset, attr_value);\n\n      entries[entry_name].emplace(attr_name, attr_value);\n    }\n  }\n}\n\n\nnamespace mysql_harness {\n\n\nvoid KeyringMemory::store(const std::string &uid,\n                          const std::string &attribute,\n                          const std::string &value) {\n  entries_[uid][attribute] = value;\n}\n\nstd::string KeyringMemory::fetch(const std::string &uid,\n                                 const std::string &attribute) const {\n  return entries_.at(uid).at(attribute);\n}\n\nvoid KeyringMemory::remove(const std::string &uid) {\n  entries_.erase(uid);\n}\n\nvoid KeyringMemory::remove_attribute(const std::string &uid,\n                                     const std::string &attribute) {\n  try {\n    entries_.at(uid).erase(attribute);\n  } catch (std::out_of_range&) {\n    // Ignore.\n  }\n}\n\nstd::vector<char> KeyringMemory::serialize(const std::string& key) const {\n  // Serialize keyring.\n  auto buffer_size = ::serialize(nullptr, entries_);\n  std::vector<char> buffer(buffer_size);\n\n  ::serialize(buffer.data(), entries_);\n\n  // Encrypt buffer.\n  auto aes_buffer_size = myaes::my_aes_get_size(\n      static_cast<uint32_t>(buffer_size), kAesMode);\n  std::vector<char> aes_buffer(static_cast<std::size_t>(aes_buffer_size));\n\n  auto encrypted_size = myaes::my_aes_encrypt(\n      reinterpret_cast<const unsigned char*>(buffer.data()),\n      static_cast<uint32_t>(buffer_size),\n      reinterpret_cast<unsigned char*>(aes_buffer.data()),\n      reinterpret_cast<const unsigned char*>(key.data()),\n      static_cast<uint32_t>(key.length()), kAesMode, kAesIv);\n\n  if (encrypted_size < 0)\n    throw std::runtime_error(\"Keyring encryption failed.\");\n\n  return aes_buffer;\n}\n\nvoid KeyringMemory::parse(const std::string& key, const char* buffer,\n                          std::size_t buffer_size) {\n  // Decrypt buffer.\n  std::vector<char> decrypted_buffer(buffer_size);\n\n  auto decrypted_size = my_aes_decrypt(\n      reinterpret_cast<const unsigned char*>(buffer),\n      static_cast<uint32_t>(buffer_size),\n      reinterpret_cast<unsigned char*>(decrypted_buffer.data()),\n      reinterpret_cast<const unsigned char*>(key.data()),\n      static_cast<uint32_t>(key.length()), kAesMode, kAesIv);\n\n  if (decrypted_size < 0)\n    throw decryption_error(\"Keyring decryption failed.\");\n\n  // Parse keyring data.\n  ::parse(decrypted_buffer.data(), static_cast<std::size_t>(decrypted_size), entries_);\n}\n\n\n} // namespace mysql_harness\n"
  },
  {
    "path": "src/harness/src/loader-posix.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql/harness/loader.h\"\n\n#include \"mysql/harness/filesystem.h\"\n\n#include \"exception.h\"\n\n#include <dlfcn.h>\n#include <unistd.h>\n\n#include <cassert>\n#include <sstream>\n\n#define USE_DLCLOSE 1\n\n// disable dlclose() when built with lsan\n//\n// clang has __has_feature(address_sanitizer)\n// gcc has __SANITIZE_ADDRESS__\n#if defined(__has_feature)\n  #if __has_feature(address_sanitizer)\n#undef USE_DLCLOSE\n#define USE_DLCLOSE 0\n  #endif\n#endif\n\n#if defined(__SANITIZE_ADDRESS__) && __SANITIZE_ADDRESS__ == 1\n#undef USE_DLCLOSE\n#define USE_DLCLOSE 0\n#endif\n\nnamespace mysql_harness {\n\n////////////////////////////////////////////////////////////////\n// class Loader\n\nvoid Loader::platform_specific_init() {}\n\n////////////////////////////////////////////////////////////////\n// class Loader::PluginInfo::Impl\n\nclass Loader::PluginInfo::Impl {\n public:\n  // throws bad_plugin\n  Impl(const std::string& plugin_folder,\n       const std::string& library_name);\n\n  ~Impl();\n\n  Path path;\n  void* handle;\n};\n\nLoader::PluginInfo::Impl::Impl(const std::string& plugin_folder,\n                               const std::string& library_name)\n  : path(Path::make_path(plugin_folder, library_name, \"so\")),\n    handle(dlopen(path.c_str(), RTLD_LOCAL | RTLD_NOW)) {\n  if (handle == nullptr)\n    throw bad_plugin(dlerror());\n}\n\nLoader::PluginInfo::Impl::~Impl() {\n#if USE_DLCLOSE\n  dlclose(handle);\n#endif\n}\n\n////////////////////////////////////////////////////////////////\n// class Loader::PluginInfo\n\nLoader::PluginInfo::~PluginInfo() {\n  delete impl_;\n}\n\nLoader::PluginInfo::PluginInfo(PluginInfo&& p) {\n  if (&p != this) {\n    this->impl_ = p.impl_;\n    p.impl_ = NULL;\n    this->plugin = p.plugin;\n    p.plugin = NULL;\n    this->handle = p.handle;\n    p.handle = NULL;\n  }\n}\n\nLoader::PluginInfo::PluginInfo(const std::string& plugin_folder,\n                               const std::string& library_name)\n  : impl_(new Impl(plugin_folder, library_name)) {}\n\nvoid Loader::PluginInfo::load_plugin(const std::string& name) {\n  assert(impl_->handle);\n\n  dlerror();  // clear any previous errors\n\n  std::string symbol = \"harness_plugin_\" + name;\n  Plugin* p = reinterpret_cast<Plugin*>(dlsym(impl_->handle, symbol.c_str()));\n\n  const char* error = dlerror();\n  if (error) {\n    std::ostringstream buffer;\n    buffer << \"Loading plugin '\" << name << \"' failed: \" << error;\n    throw bad_plugin(buffer.str());\n  }\n\n  this->plugin = p;\n}\n\n} // namespace mysql_harness\n"
  },
  {
    "path": "src/harness/src/loader-windows.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"loader.h\"\n\n#include \"exception.h\"\n#include \"filesystem.h\"\n\n#include <Windows.h>\n\n#include <cassert>\n#include <sstream>\n\nnamespace mysql_harness {\n\n////////////////////////////////////////////////////////////////\n// class Loader\n\nvoid Loader::platform_specific_init() {\n  std::string plugin_path = config_.get_default(\"plugin_folder\");\n  SetDllDirectory(plugin_path.c_str());\n}\n\n////////////////////////////////////////////////////////////////\n// class Loader::PluginInfo::Impl\n\nclass Loader::PluginInfo::Impl {\n public:\n  // throws bad_plugin\n  Impl(const std::string& plugin_folder,\n       const std::string& library_name);\n\n  ~Impl();\n\n  Path path;\n  HMODULE handle;\n};\n\nLoader::PluginInfo::Impl::Impl(const std::string& plugin_folder,\n                               const std::string& library_name)\n  : path(Path::make_path(plugin_folder, library_name, \"dll\")) {\n  handle = LoadLibrary(path.real_path().c_str());\n\n  if (handle == nullptr) {\n    char buffer[512];\n    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_MAX_WIDTH_MASK,\n                  nullptr, GetLastError(),\n                  LANG_NEUTRAL, buffer, sizeof(buffer), nullptr);\n    throw bad_plugin(path.str()+\": \"+buffer);\n  }\n}\n\nLoader::PluginInfo::Impl::~Impl() {\n  FreeLibrary(handle);\n}\n\n////////////////////////////////////////////////////////////////\n// class Loader::PluginInfo\n\nLoader::PluginInfo::~PluginInfo() {\n  delete impl_;\n}\n\nLoader::PluginInfo::PluginInfo(Loader::PluginInfo&& p) {\n  if (&p != this) {\n    this->impl_ = p.impl_;\n    p.impl_ = NULL;\n    this->plugin = p.plugin;\n    p.plugin = NULL;\n    this->handle = p.handle;\n    p.handle = NULL;\n  }\n}\n\nLoader::PluginInfo::PluginInfo(const std::string& plugin_folder,\n                               const std::string& library_name)\n  : impl_(new Impl(plugin_folder, library_name)) {}\n\nvoid Loader::PluginInfo::load_plugin(const std::string& name) {\n  assert(impl_->handle);\n\n  SetLastError(0);\n\n  std::string symbol = \"harness_plugin_\" + name;\n  Plugin* plugin = reinterpret_cast<Plugin*>(GetProcAddress(impl_->handle,\n                                                            symbol.c_str()));\n\n  DWORD error = GetLastError();\n  if (error) {\n    char err_msg[512];\n    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_MAX_WIDTH_MASK,\n                  nullptr, error,\n                  LANG_NEUTRAL, err_msg, sizeof(err_msg), nullptr);\n\n    std::ostringstream buffer;\n    buffer << \"Loading plugin '\" << name << \"' failed: \" << err_msg;\n    throw bad_plugin(buffer.str());\n  }\n\n  this->plugin = plugin;\n}\n\n} // namespace mysql_harness\n"
  },
  {
    "path": "src/harness/src/loader.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#define MYSQL_ROUTER_LOG_DOMAIN ::mysql_harness::logging::kMainLogger // must precede #include \"logging.h\"\n#include \"mysql/harness/loader.h\"\n\n////////////////////////////////////////\n// Package include files\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysql/harness/filesystem.h\"\n#include \"mysql/harness/plugin.h\"\n#include \"designator.h\"\n#include \"exception.h\"\n#include \"utilities.h\"\nIMPORT_LOG_FUNCTIONS()\n\n////////////////////////////////////////\n// Standard include files\n#include <algorithm>\n#include <atomic>\n#include <cctype>\n#include <cstring>\n#include <exception>\n#include <map>\n#include <sstream>\n#include <string>\n#include <system_error>\n#include <thread>\n\n#ifndef _WIN32\n#  include <dlfcn.h>\n#  include <unistd.h>\n#endif\n\n// <cassert> places assert() in global namespace on Ubuntu14.04, but might\n// place it in std:: on other platforms\n#include <assert.h>\n\n// safer than using cstdarg because va_* family of things might be macros or\n// functions on different platforms, in which case they will either have std::\n// prefix or they won't. Here's an example from QNX:\n//   https://svn.boost.org/trac/boost/ticket/3133\n#include <stdarg.h>\n\n// need POSIX signals and threads to support signal handling (pthread_sigmask(),\n// sigaction() and friends). For platforms that do not have them (e.g. Windows),\n// a different mechanism is used instead (see proxy_main()).\n// Compiler on Solaris does not always define _POSIX_C_SOURCE although the signal handling is there\n#if (!defined _WIN32)\n# define USE_POSIX_SIGNALS\n#endif\n\n#ifdef USE_POSIX_SIGNALS\n# include <pthread.h>\n#endif\n\nusing mysql_harness::utility::find_range_first;\nusing mysql_harness::utility::make_range;\nusing mysql_harness::utility::reverse;\n\nusing mysql_harness::Path;\nusing mysql_harness::Config;\n\nusing std::ostringstream;\n\n\n\nstatic const int kPluginExitCheckInterval = 100;  // milliseconds\n\n/**\n * @defgroup Loader Plugin loader\n *\n * Plugin loader for loading and working with plugins.\n */\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// Signal handling\n//\n////////////////////////////////////////////////////////////////////////////////\n\n\n// when Router receives a signal to shut down, this flag is set\nstatic volatile std::atomic<sig_atomic_t> g_shutdown_pending { 0 };\n\n// ensure that 'terminate'-flag is thread-safe and signal-safe\n//\n// * sigatomic_t is not thread-safe\n// * std::atomic is not signal-safe by default (only lock-free std::atomics are signal-safe)\n//\n// assume that sig_atomic_t is int-or-long\n// (in C++17 we could use std::atomic<sig_atomic_t>.is_always_lock_free)\nstatic_assert((std::is_same<sig_atomic_t, int>::value && (ATOMIC_INT_LOCK_FREE == 2)) ||\n    (std::is_same<sig_atomic_t, long>::value && (ATOMIC_LONG_LOCK_FREE == 2)), \"expected sig_atomic_t to lock-free\");\n\n\n// called from sig_handler() on Unix,\n//        from NTService class and Ctrl+C handler on Windows\nvoid request_application_shutdown() {\n  g_shutdown_pending = 1;\n}\n\nstatic void sig_handler(int signal) {\n#ifdef USE_POSIX_SIGNALS\n  switch (signal) {\n    case SIGINT:\n    case SIGTERM:\n      request_application_shutdown();\n      break;\n    default:\n      break;\n  }\n#endif\n}\n\nstatic void block_all_signals() {\n#ifdef USE_POSIX_SIGNALS\n  sigset_t ss;\n  sigfillset(&ss);\n  if (0 != pthread_sigmask(SIG_SETMASK, &ss, nullptr)) {\n    throw std::runtime_error(\"pthread_sigmask() failed: \"\n                             + std::string(std::strerror(errno)));\n  }\n#endif\n}\n\nstatic void set_signal_handlers() {\n#ifdef USE_POSIX_SIGNALS\n\n  // set up handlers\n  {\n    struct sigaction sa;\n\n    // It would seem reasonable to set all fields explicity instead. It turns out\n    // that on Ubuntu 14.04 (and maybe others?), sa.sa_sigaction and sa.sa_handler\n    // are a union! (yes, man page about struct sigaction is incorrect)\n    memset(&sa, 0, sizeof(sa));\n    sa.sa_handler = sig_handler;\n    sigfillset(&sa.sa_mask); // for good measure, it doesn't really matter\n                             // what we block - the handler is trivial\n\n    if (sigaction(SIGINT,  &sa, nullptr) == -1 ||\n        sigaction(SIGTERM, &sa, nullptr) == -1) {\n      throw std::runtime_error(\"sigaction() failed: \"\n                               + std::string(std::strerror(errno)));\n    }\n  }\n\n  // and finally, let's unblock the signals\n  {\n    sigset_t ss;\n    sigemptyset(&ss);\n    sigaddset(&ss, SIGINT);\n    sigaddset(&ss, SIGTERM);\n    if (0 != pthread_sigmask(SIG_UNBLOCK, &ss, nullptr)) {\n      throw std::runtime_error(\"pthread_sigmask() failed: \"\n                               + std::string(std::strerror(errno)));\n    }\n  }\n#endif\n}\n\n\n\nnamespace mysql_harness {\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// PluginFuncEnv\n//\n////////////////////////////////////////////////////////////////////////////////\n\nPluginFuncEnv::PluginFuncEnv(const AppInfo* info,\n                 const ConfigSection* section,\n                 bool running /*= false*/)\n  : app_info_(info), config_section_(section), running_(running) {}\n\n//----[ further config getters ]----------------------------------------------\n\nconst ConfigSection* PluginFuncEnv::get_config_section() const noexcept {\n  std::lock_guard<std::mutex> lock(mutex_);\n  assert(config_section_);\n  return config_section_;\n}\n\nconst AppInfo* PluginFuncEnv::get_app_info() const noexcept {\n  std::lock_guard<std::mutex> lock(mutex_);\n  assert(app_info_);\n  return app_info_;\n}\n\n//----[ running flag ]--------------------------------------------------------\n\nvoid PluginFuncEnv::set_running() noexcept {\n  std::lock_guard<std::mutex> lock(mutex_);\n  running_ = true;\n}\n\nvoid PluginFuncEnv::clear_running() noexcept {\n  std::unique_lock<std::mutex> lock(mutex_);\n  running_ = false;\n  lock.unlock();\n  cond_.notify_all(); // for wait_for_stop()\n}\n\nbool PluginFuncEnv::is_running() const noexcept {\n  std::lock_guard<std::mutex> lock(mutex_);\n  return running_;\n}\n\nbool PluginFuncEnv::wait_for_stop(uint32_t milliseconds) const noexcept {\n  auto pred = [this]() noexcept -> bool {\n    return !running_;\n  };\n\n  std::unique_lock<std::mutex> lock(mutex_);\n  if (milliseconds) // 0 = wait forever\n    cond_.wait_for(lock, std::chrono::milliseconds(milliseconds), pred);\n  else\n    cond_.wait(lock, pred);\n  return pred();\n}\n\n//----[ error handling ]------------------------------------------------------\n\nbool PluginFuncEnv::exit_ok() const noexcept {\n  std::lock_guard<std::mutex> lock(mutex_);\n  return error_type_ == kNoError;\n}\n\nvoid PluginFuncEnv::set_error(ErrorType error_type, const char* fmt, va_list ap) noexcept {\n  std::lock_guard<std::mutex> lock(mutex_);\n\n  assert(error_message_.empty());   // \\_ previous message wasn't consumed\n  assert(error_type_ == kNoError);  // /\n  assert(error_type  != kNoError);  // what would be the purpose of that?\n\n  error_type_ = error_type;\n  if (fmt) {\n    char buf[1024] = {0};\n    vsnprintf(buf, sizeof(buf), fmt, ap);\n    error_message_ = buf;\n  } else {\n    error_message_ = \"<empty message>\";\n  }\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// Harness API\n//\n////////////////////////////////////////////////////////////////////////////////\n\n//----[ further config getters ]----------------------------------------------\n\nconst AppInfo* get_app_info(const PluginFuncEnv* env) noexcept {\n  return env->get_app_info();\n}\n\nconst ConfigSection* get_config_section(const PluginFuncEnv* env) noexcept {\n  return env->get_config_section();\n}\n\n//----[ running flag ]--------------------------------------------------------\n\nbool is_running(const PluginFuncEnv* env) noexcept {\n  return env->is_running();\n}\n\nbool wait_for_stop(const PluginFuncEnv* env, uint32_t milliseconds) noexcept {\n  return env->wait_for_stop(milliseconds);\n}\n\nvoid clear_running(PluginFuncEnv* env) noexcept {\n  return env->clear_running();\n}\n\n//----[ error handling ]------------------------------------------------------\n\nvoid set_error(PluginFuncEnv* env, ErrorType error_type, const char* fmt, ...) noexcept\n#ifdef HAVE_ATTRIBUTE_FORMAT\n  __attribute__((format(printf, 3, 4)))\n#endif\n  ;\n\nvoid set_error(PluginFuncEnv* env, ErrorType error_type, const char* fmt, ...) noexcept {\n  va_list args;\n  va_start(args, fmt);\n  env->set_error(error_type, fmt, args);\n  va_end(args);\n}\n\nstd::tuple<std::string, std::exception_ptr> PluginFuncEnv::pop_error() noexcept {\n  std::lock_guard<std::mutex> lock(mutex_);\n\n  // At the time of writing, the exception type was used in Router's main.cc\n  // to discriminate between error types, to give the user a hint of what\n  // caused the problem (configuration error, runtime error, etc).\n  std::tuple<std::string, std::exception_ptr> ret;\n  switch (error_type_) {\n    case kRuntimeError:\n      ret = std::make_tuple(error_message_,\n            std::make_exception_ptr(std::runtime_error(error_message_)));\n      break;\n\n    case kConfigInvalidArgument:\n      ret = std::make_tuple(error_message_,\n            std::make_exception_ptr(std::invalid_argument(error_message_)));\n      break;\n\n    case kConfigSyntaxError:\n      ret = std::make_tuple(error_message_,\n            std::make_exception_ptr(mysql_harness::syntax_error(error_message_)));\n      break;\n\n    case kUndefinedError:\n      ret = std::make_tuple(error_message_,\n            std::make_exception_ptr(std::runtime_error(error_message_)));\n      break;\n\n    case kNoError:\n      assert(0);  // this function shouldn't be called in such case\n\n      // defensive programming:\n      // on production systems, default to runtime_error and go on\n      ret = std::make_tuple(error_message_,\n            std::make_exception_ptr(std::runtime_error(error_message_)));\n      break;\n  }\n\n  error_type_ = kNoError;\n  error_message_.clear();\n\n  return ret;\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// Loader\n//\n////////////////////////////////////////////////////////////////////////////////\n\nLoader::~Loader() {\n}\n\nPlugin* Loader::load_from(const std::string& plugin_name,\n                          const std::string& library_name) {\n  std::string error;\n  setup_info();\n\n  // We always load the library (even if it is already loaded) to\n  // honor potential dynamic library open/close reference counts. It\n  // is up to the platform implementation to ensure that multiple\n  // instances of a library can be handled.\n\n  PluginInfo info(plugin_folder_, library_name);  // throws bad_plugin\n\n  info.load_plugin(plugin_name);  // throws bad_plugin\n\n  // Check that ABI version and architecture match\n  auto plugin = info.plugin;\n  if ((plugin->abi_version & 0xFF00) != (PLUGIN_ABI_VERSION & 0xFF00) ||\n      (plugin->abi_version & 0xFF) > (PLUGIN_ABI_VERSION & 0xFF)) {\n    ostringstream buffer;\n    buffer.setf(std::ios::hex, std::ios::basefield);\n    buffer.setf(std::ios::showbase);\n    buffer << \"Bad ABI version - plugin version: \" << plugin->abi_version\n           << \", loader version: \" << PLUGIN_ABI_VERSION;\n    throw bad_plugin(buffer.str());\n  }\n\n  // Recursively load dependent modules, we skip NULL entries since\n  // the user might have added these by accident (for example, he\n  // assumed that the array was NULL-terminated) and they can safely\n  // be ignored instead of raising an error.\n  for (auto req : make_range(plugin->requires, plugin->requires_length)) {\n    if (req != nullptr) {\n      // Parse the designator to extract the plugin and constraints.\n      Designator designator(req);\n\n      // Load the plugin using the plugin name.\n      Plugin* dep_plugin = load(designator.plugin); // throws bad_plugin\n\n      // Check that the version of the plugin match what the\n      // designator expected and raise an exception if they don't\n      // match.\n      if (!designator.version_good(Version(dep_plugin->plugin_version))) {\n        Version version(dep_plugin->plugin_version);\n        std::ostringstream buffer;\n        buffer << designator.plugin << \": plugin version was \" << version\n               << \", expected \" << designator.constraint;\n        throw bad_plugin(buffer.str());\n      }\n    }\n  }\n\n  // If all went well, we register the plugin and return a\n  // pointer to it.\n  plugins_.emplace(plugin_name, std::move(info));\n  log_debug(\"  plugin '%s' loaded ok\", plugin_name.c_str());\n  return plugin;\n}\n\nPlugin* Loader::load(const std::string& plugin_name, const std::string& key) {\n  log_info(\"  plugin '%s:%s' loading\", plugin_name.c_str(), key.c_str());\n\n  ConfigSection& plugin = config_.get(plugin_name, key);  // throws bad_section\n  const std::string& library_name = plugin.get(\"library\");\n  return load_from(plugin_name, library_name);  // throws bad_plugin\n}\n\nPlugin* Loader::load(const std::string& plugin_name) {\n  log_info(\"  plugin '%s' loading\", plugin_name.c_str());\n\n  Config::SectionList plugins = config_.get(plugin_name); // throws bad_section\n  if (plugins.size() > 1) {\n    std::ostringstream buffer;\n    buffer << \"Section name '\" << plugin_name\n           << \"' is ambiguous. Alternatives are:\";\n    for (const ConfigSection* plugin : plugins)\n      buffer << \" \" << plugin->key;\n    throw bad_section(buffer.str());\n  } else if (plugins.size() == 0) {\n    std::ostringstream buffer;\n    buffer << \"Section name '\" << plugin_name\n           << \"' does not exist\";\n    throw bad_section(buffer.str());\n  }\n\n  assert(plugins.size() == 1);\n  const ConfigSection* section = plugins.front();\n  const std::string& library_name = section->get(\"library\");\n  return load_from(plugin_name, library_name);  // throws bad_plugin\n}\n\nvoid Loader::start() {\n\n  // unload plugins on exit\n  std::shared_ptr<void> exit_guard(nullptr, [this](void*){ unload_all(); });\n\n  // load plugins\n  load_all(); // throws bad_plugin on load error, causing an early return\n\n  // init and run plugins\n  std::exception_ptr first_eptr = run();\n  if (first_eptr) {\n    std::rethrow_exception(first_eptr);\n  }\n}\n\nvoid Loader::load_all() {\n  log_info(\"Loading all plugins.\");\n\n  platform_specific_init();\n  for (std::pair<const std::string&, std::string> name : available()) {\n    try {\n      load(name.first, name.second);\n    } catch (const bad_plugin& e) {\n      log_error(\"  plugin '%s' failed to load: %s\", name.first.c_str(), e.what());\n      throw;\n    }\n  }\n}\n\nvoid Loader::unload_all() {\n  // this stage has no implementation so far; however, we want to flag that we\n  // reached this stage\n  log_info(\"Unloading all plugins.\");\n}\n\nstd::exception_ptr Loader::run() {\n\n  // initialize plugins\n  std::exception_ptr first_eptr = init_all();\n\n  // run plugins if initialization didn't fail\n  if (!first_eptr) {\n    start_all();  // if start() throws, exception is forwarded to main_loop()\n    first_eptr = main_loop(); // calls stop_all() before exiting\n  }\n\n  // not strict requiremnt, just good measure (they're no longer needed at\n  // this point)\n  assert(plugin_start_env_.empty());\n\n  // deinitialize plugins\n  std::exception_ptr tmp = deinit_all();\n  if (!first_eptr) {\n    first_eptr = tmp;\n  }\n\n  // return the first exception that was triggered by an error returned from\n  // any plugin function\n  return first_eptr;\n}\n\nstd::list<Config::SectionKey> Loader::available() const {\n  return config_.section_names();\n}\n\nvoid Loader::setup_info() {\n  logging_folder_ = config_.get_default(\"logging_folder\");\n  plugin_folder_ = config_.get_default(\"plugin_folder\");\n  runtime_folder_ = config_.get_default(\"runtime_folder\");\n  config_folder_ = config_.get_default(\"config_folder\");\n  data_folder_ = config_.get_default(\"data_folder\");\n\n  appinfo_.logging_folder = logging_folder_.c_str();\n  appinfo_.plugin_folder = plugin_folder_.c_str();\n  appinfo_.runtime_folder = runtime_folder_.c_str();\n  appinfo_.config_folder = config_folder_.c_str();\n  appinfo_.data_folder = data_folder_.c_str();\n  appinfo_.config = &config_;\n  appinfo_.program = program_.c_str();\n}\n\nstatic void call_plugin_function(PluginFuncEnv* env,\n                                 std::exception_ptr& eptr,\n                                 void (*fptr)(PluginFuncEnv*),\n                                 const char* fnc_name,\n                                 const char* plugin_name,\n                                 const char* plugin_key = nullptr) noexcept {\n\n  auto handle_plugin_exception = [](std::exception_ptr& first_eptr,\n                                    const std::string& func_name,\n                                    const char* plug_name,\n                                    const char* plug_key,\n                                    const std::exception* e)\n                                    noexcept -> void {\n    // Plugins are not allowed to throw, so let's alert the devs. But in\n    // production, we want to be robust and try to handle this gracefully\n    assert(0);\n\n    if (!first_eptr)\n      first_eptr = std::current_exception();\n\n    std::string what = e ? (std::string(\": \") + e->what())\n                         : \".\";\n    if (plug_key)\n      log_error(\"  plugin '%s:%s' %s threw unexpected exception \"\n                \"- please contact plugin developers for more information%s\",\n                 plug_name, plug_key, func_name.c_str(), what.c_str());\n    else\n      log_error(\"  plugin '%s' %s threw unexpected exception \"\n                \"- please contact plugin developers for more information%s\",\n                 plug_name, func_name.c_str(), what.c_str());\n  };\n\n  // This try/catch block is about defensive programming - plugins are not\n  // allowed to throw. But if the exception is caught anyway, we have to\n  // handle it somehow. In debug builds, we throw an assertion. In release\n  // builds, we whine about it in logs, but otherwise handle it like a\n  // normal error. This behavior is officially undefined, thus we are free\n  // to change this at our discretion.\n  try {\n\n    // call the plugin\n    fptr(env);\n\n    // error handling\n    if (env->exit_ok()) {\n      if (plugin_key)\n        log_debug(\"  plugin '%s:%s' %s exit ok\", plugin_name, plugin_key,\n                  fnc_name);\n      else\n        log_debug(\"  plugin '%s' %s exit ok\", plugin_name, fnc_name);\n    } else {\n      std::string message;\n      if (!eptr) {\n        std::tie(message, eptr) = env->pop_error();\n      } else {\n        std::tie(message, std::ignore) = env->pop_error();\n      }\n      if (plugin_key)\n        log_error(\"  plugin '%s:%s' %s failed: %s\", plugin_name, plugin_key,\n                  fnc_name, message.c_str());\n      else\n        log_error(\"  plugin '%s' %s failed: %s\", plugin_name, fnc_name,\n                  message.c_str());\n    }\n\n  } catch (const std::exception& e) {\n    handle_plugin_exception(eptr, fnc_name, plugin_name, plugin_key, &e);\n  } catch (...) {\n    handle_plugin_exception(eptr, fnc_name, plugin_name, plugin_key, nullptr);\n  }\n}\n\n// returns first exception triggered by init()\nstd::exception_ptr Loader::init_all() {\n  log_info(\"Initializing all plugins.\");\n\n  if (!topsort())\n    throw std::logic_error(\"Circular dependencies in plugins\");\n\n  order_.reverse(); // we need reverse-topo order\n  for (auto it = order_.begin(); it != order_.end(); ++it) {\n\n    const std::string& plugin_name = *it;\n    PluginInfo &info = plugins_.at(plugin_name);\n\n    if (!info.plugin->init) {\n      log_debug(\"  plugin '%s' doesn't implement init()\", plugin_name.c_str());\n      continue;\n    }\n\n    log_info(\"  plugin '%s' initializing\", plugin_name.c_str());\n    PluginFuncEnv env(&appinfo_, nullptr);\n\n    std::exception_ptr eptr;\n    call_plugin_function(&env, eptr, info.plugin->init, \"init\",\n                         plugin_name.c_str());\n    if (eptr) {\n      // erase this and all remaining plugins from the list, so that\n      // deinit_all() will not try to run deinit() on them\n      order_.erase(it, order_.end());\n      return eptr;\n    }\n\n  } // for (auto it = order_.begin(); it != order_.end(); ++it)\n\n  return nullptr;\n}\n\n\n// forwards first exception triggered by start() to main_loop()\nvoid Loader::start_all() {\n  log_info(\"Starting all plugins.\");\n\n  // On Windows, this is a no-op, because we don't use signals on Windows\n  // On Unix systems, this line does two things:\n  // - for main thread, it block all signals until we set up the proper handlers\n  //   later on\n  // - since the signal mask is inherited, it will be passed on to new (plugin)\n  //   threads. However, unlike in case of main thread, we will never unblock\n  //   the signals there. This way, all signals sent to the program are\n  //   guaranteed to be passed on to the main thread.\n  block_all_signals();\n\n  // start all the plugins (call plugin's start() function)\n  for (const ConfigSection* section : config_.sections()) {\n\n    PluginInfo& plugin = plugins_.at(section->name);\n    void (*fptr)(PluginFuncEnv*) = plugin.plugin->start;\n\n    if (!fptr) {\n      log_debug(\"  plugin '%s:%s' doesn't implement start()\",\n                section->name.c_str(), section->key.c_str());\n\n      // create a env object for later\n      assert(plugin_start_env_.count(section) == 0);\n      plugin_start_env_[section] = std::make_shared<PluginFuncEnv>(nullptr, section, false);\n\n      continue;\n    }\n\n    // future will remain valid even after promise is destructed\n    std::promise<std::shared_ptr<PluginFuncEnv>> env_promise;\n\n    // plugin start() will run in this new thread\n    auto dispatch = [fptr, section, &env_promise]()\n        -> std::exception_ptr {\n      log_info(\"  plugin '%s:%s' starting\",\n               section->name.c_str(), section->key.c_str());\n\n      // init env object and unblock harness thread\n      std::shared_ptr<PluginFuncEnv> this_thread_env =\n          std::make_shared<PluginFuncEnv>(nullptr, section, true);\n      env_promise.set_value(this_thread_env); // shared_ptr gets copied here (future will own a copy)\n\n      std::exception_ptr eptr;\n      call_plugin_function(this_thread_env.get(), eptr, fptr, \"start\",\n                           section->name.c_str(), section->key.c_str());\n      return eptr;\n    };\n\n    // launch plugin and save the future for exit status retrieval later on\n    std::future<std::exception_ptr> fut =\n        std::async(std::launch::async, dispatch);\n    sessions_.push_back(std::move(fut));\n\n    // block until dispatch() initializes plugin thread to a thread-safe state,\n    // then save the env object for later\n    assert(plugin_start_env_.count(section) == 0);\n    plugin_start_env_[section] = env_promise.get_future().get();  // returns shared_ptr to PluginFuncEnv; PluginFuncEnv exists on heap\n\n  } // for (const ConfigSection* section: config_.sections())\n\n  // We wait with this until after we launch all plugin threads, to avoid\n  // a potential race if a signal was received while plugins were still\n  // launching.\n  set_signal_handlers();\n}\n\n// returns first exception triggered by start() or stop()\nstd::exception_ptr Loader::main_loop() {\n  log_info(\"Running.\");\n\n  // This function waits for all threads to finish. First thread that returns\n  // an exception will trigger stop_all().\n\n  // This is the \"main\" loop, where the Router app spends all its time while\n  // \"running\" (servicing requests, etc). It stays here until all plugins are\n  // terminated (all futures are settled) or until shutdown signal was received.\n  std::exception_ptr first_eptr;\n  bool have_unsettled_futures;\n  bool called_stop_all = false;\n  do { // while (have_unsettled_futures)\n    have_unsettled_futures = false;\n    std::chrono::steady_clock::time_point timepoint =\n        std::chrono::steady_clock::now() +\n        std::chrono::milliseconds(kPluginExitCheckInterval);\n\n    // handle received shutdown signal\n    if (g_shutdown_pending && !called_stop_all) {\n      std::exception_ptr tmp = stop_all();\n      if (!first_eptr) {\n        first_eptr = tmp;\n      }\n      called_stop_all = true;\n    }\n\n    // check all plugin instances for termination\n    for (std::future<std::exception_ptr>& fut : sessions_) {\n\n      // handle this plugin no longer running\n      if (!fut.valid()) {\n        continue;\n      }\n\n      // handle terminating plugin\n      //\n      // NOTE: Here we rely on ambiguous behavior of future::wait_until().\n      // What will be returned when you call it when future is ready BUT\n      // timepoint is expired? On Ubuntu 14.04, it returns future_status::ready,\n      // which seems reasonable. However to ensure it works all platforms, we\n      // have a unit test in test_loader_lifecycle.cc to guard against\n      // surprises.\n      if (fut.wait_until(timepoint) == std::future_status::ready) {\n        std::exception_ptr tmp = fut.get();\n\n        // if plugin's start() threw, we save its exception and initiate shutdown\n        if (tmp && !first_eptr) {\n          first_eptr = tmp;\n          if(!called_stop_all) {\n            stop_all();\n            called_stop_all = true;\n          }\n        }\n      } else { // this plugin is still running\n        have_unsettled_futures = true;\n      }\n\n    } // for (std::future<std::exception_ptr>& fut : sessions_)\n\n  } while (have_unsettled_futures);\n\n  // No (plugin) threads are running at this point, all futures have been\n  // consumed. It's weird to tell all plugins to stop after they already\n  // stopped, however, we guarantee that each plugin that exposes a stop()\n  // function will have this function called during shutdown, thus we must\n  // make sure it happens.\n  if (!called_stop_all) {\n    std::exception_ptr tmp = stop_all();\n    if (!first_eptr) {\n      first_eptr = tmp;\n    }\n  }\n\n  // we will no longer need the env objects for start(), might as well\n  // clean them up now for good measure\n  plugin_start_env_.clear();\n\n  // We just return the first exception that was raised (if any). If there\n  // are other exceptions, they are ignored.\n  return first_eptr;\n}\n\n// returns first exception triggered by stop()\nstd::exception_ptr Loader::stop_all() {\n  // This function runs exactly once - it will be called even if all plugins\n  // exit by themselves (thus there's nothing to stop).\n  log_info(\"Shutting down. Stopping all plugins.\");\n\n  // iterate over all plugin instances\n  std::exception_ptr first_eptr;\n  for (const ConfigSection* section : config_.sections()) {\n\n    PluginInfo& plugin = plugins_.at(section->name);\n    void (*fptr)(PluginFuncEnv*) = plugin.plugin->stop;\n\n    assert(plugin_start_env_.count(section));\n    assert(plugin_start_env_[section]->get_config_section() == section);\n\n    // flag plugin::start() to exit (if one exists and it's running)\n    plugin_start_env_[section]->clear_running();\n\n    if (!fptr) {\n      log_debug(\"  plugin '%s:%s' doesn't implement stop()\",\n                section->name.c_str(), section->key.c_str());\n      continue;\n    }\n\n    log_info(\"  plugin '%s:%s' stopping\",\n             section->name.c_str(), section->key.c_str());\n\n    PluginFuncEnv stop_env(nullptr, section);\n    call_plugin_function(&stop_env, first_eptr, fptr, \"stop\",\n                         section->name.c_str(), section->key.c_str());\n\n  } // for (const ConfigSection* section: config_.sections())\n\n  return first_eptr;\n}\n\n// returns first exception triggered by deinit()\nstd::exception_ptr Loader::deinit_all() {\n  log_info(\"Deinitializing all plugins.\");\n\n  // we could just reverse order_ and that would work too,\n  // but by leaving it intact it's easier to unit-test it\n  std::list<std::string> deinit_order = order_;\n  deinit_order.reverse();\n\n  // call deinit() on all plugins that support the call\n  std::exception_ptr first_eptr;\n  for (std::string& plugin_name : deinit_order) {\n\n    PluginInfo& info = plugins_.at(plugin_name);\n\n    if (!info.plugin->deinit) {\n      log_debug(\"  plugin '%s' doesn't implement deinit()\", plugin_name.c_str());\n      continue;\n    }\n\n    log_info(\"  plugin '%s' deinitializing\", plugin_name.c_str());\n    PluginFuncEnv env(&appinfo_, nullptr);\n\n    call_plugin_function(&env, first_eptr, info.plugin->deinit, \"deinit\",\n                         plugin_name.c_str());\n  }\n\n  return first_eptr;\n}\n\nbool Loader::topsort() {\n  std::map<std::string, Loader::Status> status;\n  std::list<std::string> order;\n  for (std::pair<const std::string, PluginInfo>& plugin : plugins_) {\n    bool succeeded = visit(plugin.first, &status, &order);\n    if (!succeeded)\n      return false;\n  }\n  order_.swap(order);\n  return true;\n}\n\nbool Loader::visit(const std::string& designator,\n                   std::map<std::string, Loader::Status>* status,\n                   std::list<std::string>* order) {\n  Designator info(designator);\n  switch ((*status)[info.plugin]) {\n  case Status::VISITED:\n    return true;\n\n  case Status::ONGOING:\n    // If we see a node we are processing, it's not a DAG and cannot\n    // be topologically sorted.\n    return false;\n\n  case Status::UNVISITED:\n    {\n      (*status)[info.plugin] = Status::ONGOING;\n      if (Plugin *plugin = plugins_.at(info.plugin).plugin) {\n        for (auto required : make_range(plugin->requires,\n                                        plugin->requires_length)) {\n          assert(required != NULL);\n          bool succeeded = visit(required, status, order);\n          if (!succeeded)\n            return false;\n        }\n      }\n      (*status)[info.plugin] = Status::VISITED;\n      order->push_front(info.plugin);\n      return true;\n    }\n  }\n  return true;\n}\n\n} // namespace mysql_harness\n\n// unit test access - DON'T USE IN PRODUCTION CODE!\n// (unfortunately we cannot guard this with #ifdef FRIEND_TEST)\nnamespace unittest_backdoor {\n  HARNESS_EXPORT\n  void set_shutdown_pending(bool shutdown_pending) {\n    g_shutdown_pending = shutdown_pending;\n  }\n}\n\n"
  },
  {
    "path": "src/harness/src/loader_config.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql/harness/loader_config.h\"\n#include \"mysql/harness/filesystem.h\"\n\n////////////////////////////////////////\n// Package include files\n#include \"utilities.h\"\n\n////////////////////////////////////////\n// Standard include files\n#include <algorithm>\n#include <sstream>\n#include <string>\n\n// <cassert> places assert() in global namespace on Ubuntu14.04, but might\n// place it in std:: on other platforms\n#include <assert.h>\n\nusing mysql_harness::utility::find_range_first;\nusing std::ostringstream;\n\nnamespace mysql_harness {\n\nvoid LoaderConfig::fill_and_check() {\n  // Set the default value of library for all sections that do not\n  // have the library set.\n  for (auto&& elem : sections_) {\n    if (!elem.second.has(\"library\")) {\n      const std::string& section_name = elem.first.first;\n\n      // Section name is always a always stored as lowercase legal C\n      // identifier, hence it is also legal as a file name, but we\n      // assert that to make sure.\n      assert(std::all_of(section_name.begin(), section_name.end(),\n                         [](const char ch) -> bool {\n                           return isalnum(ch) || ch == '_';\n                         }));\n\n      elem.second.set(\"library\", section_name);\n    }\n  }\n\n  // Check all sections to make sure that the values are correct.\n  for (auto&& iter = sections_.begin() ; iter != sections_.end() ; ++iter) {\n    const std::string& section_name = iter->second.name;\n    const auto& seclist = find_range_first(sections_, section_name, iter);\n\n    const std::string& library = seclist.first->second.get(\"library\");\n    auto library_mismatch = [&library](decltype(*seclist.first)& it) -> bool {\n      return it.second.get(\"library\") != library;\n    };\n\n    auto mismatch = find_if(seclist.first, seclist.second, library_mismatch);\n    if (mismatch != seclist.second) {\n      const auto& name = seclist.first->first;\n      std::ostringstream buffer;\n      buffer << \"Library for section '\"\n             << name.first << \":\" << name.second\n             << \"' does not match library in section '\"\n             << mismatch->first.first << \":\" << mismatch->first.second;\n      throw bad_section(buffer.str());\n    }\n  }\n}\n\nvoid LoaderConfig::read(const Path& path) {\n  Config::read(path); // throws std::invalid_argument, std::runtime_error, syntax_error, ...\n\n  // This means it is checked after each file load, which might\n  // require changes in the future if checks that cover the entire\n  // configuration are added. Right now it just contain safety checks.\n  fill_and_check();\n}\n\nbool LoaderConfig::logging_to_file() const {\n  return ! get_default(\"logging_folder\").empty();\n}\n\nPath LoaderConfig::get_log_file() const {\n  return Path::make_path(get_default(\"logging_folder\"), \"mysqlrouter\", \"log\");\n}\n\n} // namespace mysql_harness\n"
  },
  {
    "path": "src/harness/src/logging/handler.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/** @file\n * Module for implementing the Logger functionality.\n */\n\n#include \"mysql/harness/logging/handler.h\"\n#include \"mysql/harness/logging/logging.h\"\n\n#include \"common.h\"\n#include \"mysql/harness/config_parser.h\"\n#include \"mysql/harness/filesystem.h\"\n#include \"mysql/harness/plugin.h\"\n\n#include <algorithm>\n#include <cerrno>\n#include <cstring>\n#include <fstream>\n#include <sstream>\n#include <string>\n#include <thread>\n#ifndef _WIN32\n#  include <sys/types.h>\n#  include <unistd.h>\n#endif\n\nusing mysql_harness::Path;\n\n#if defined(_MSC_VER) && defined(logger_EXPORTS)\n/* We are building this library */\n#  define LOGGER_API __declspec(dllexport)\n#else\n#  define LOGGER_API\n#endif\n\nusing std::ofstream;\nusing std::ostringstream;\n\nstatic const char *const level_str[] = {\n  \"FATAL\", \"ERROR\", \"WARNING\", \"INFO\", \"DEBUG\"\n};\n\nnamespace mysql_harness {\n\nnamespace logging {\n\n////////////////////////////////////////////////////////////////\n// class Handler\n\nHandler::Handler(bool format_messages, LogLevel level) :\n    format_messages_(format_messages), level_(level) {}\n\n// Log format is:\n// <date> <time> <plugin> <level> [<thread>] <message>\n\nstd::string Handler::format(const Record& record) const {\n  // Bypass formatting if disabled\n  if (!format_messages_)\n    return record.message;\n\n  // Format the time (19 characters)\n  char time_buf[20];\n  strftime(time_buf, sizeof(time_buf), \"%Y-%m-%d %H:%M:%S\",\n           localtime(&record.created));\n\n  // Get the thread ID in a printable format\n  std::stringstream ss;\n  ss << std::hex << std::this_thread::get_id();\n\n  // We ignore the return value from snprintf, which means that the\n  // output is truncated if the total length exceeds the buffer size.\n  char buffer[512];\n  snprintf(buffer, sizeof(buffer), \"%-19s %s %s [%s] %s\",\n           time_buf, record.domain.c_str(),\n           level_str[static_cast<int>(record.level)],\n           ss.str().c_str(), record.message.c_str());\n\n  // Note: This copies the buffer into an std::string\n  return buffer;\n}\n\nvoid Handler::handle(const Record& record) {\n  do_log(record);\n}\n\n// satisfy ODR\nconstexpr const char* StreamHandler::kDefaultName;\n\n////////////////////////////////////////////////////////////////\n// class StreamHandler\n\nStreamHandler::StreamHandler(std::ostream& out,\n                             bool format_messages,\n                             LogLevel level)\n    : Handler(format_messages, level), stream_(out) {}\n\nvoid StreamHandler::do_log(const Record& record) {\n  std::lock_guard<std::mutex> lock(stream_mutex_);\n  stream_ << format(record) << std::endl;\n}\n\n////////////////////////////////////////////////////////////////\n// class FileHandler\n\nFileHandler::FileHandler(const Path& path,\n                         bool format_messages,\n                         LogLevel level)\n    : StreamHandler(fstream_, format_messages, level),\n      fstream_(path.str(), ofstream::app) {\n  if (fstream_.fail()) {\n    // get the last-error early as with VS2015 it has been seen\n    // that something in std::system_error() called SetLastError(0)\n    auto last_error =\n#ifdef _WIN32\n      GetLastError()\n#else\n      errno\n#endif\n      ;\n\n    if (path.exists()) {\n      throw std::system_error(last_error, std::system_category(), \"File exists, but cannot open for writing \" + path.str());\n    } else {\n      throw std::system_error(last_error, std::system_category(), \"Cannot create file in directory \" + path.dirname().str());\n    }\n  }\n}\n\n// satisfy ODR\nconstexpr const char* FileHandler::kDefaultName;\n\nFileHandler::~FileHandler() {}\n\n} // namespace logging\n\n\n} // mysql_harness\n\n"
  },
  {
    "path": "src/harness/src/logging/logger.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql/harness/logging/logger.h\"\n#include \"mysql/harness/logging/handler.h\"\n#include \"mysql/harness/logging/registry.h\"\n\nnamespace mysql_harness {\n\nnamespace logging {\n\n\n////////////////////////////////////////////////////////////////\n// class Logger\n\nLogger::Logger(Registry& registry, LogLevel level)\n    : level_(level), registry_(&registry) {}\n\nvoid Logger::attach_handler(std::string name) {\n  // verification that the handler actually exists will be performed in\n  // Registry::update_logger() - it makes no sense to do it earlier, since it\n  // can still change between now and the time when we update_logger() is called\n  handlers_.emplace(name);\n}\n\nvoid Logger::detach_handler(std::string name, bool handler_must_exist /*= true */) {\n  if (handlers_.erase(name) == 0 && handler_must_exist)\n    throw std::logic_error(std::string(\"Detaching unknown handler '\") + name + \"'\");\n}\n\nvoid Logger::handle(const Record& record) {\n  if (record.level <= level_) {\n    for (const std::string& handler_id : handlers_) {\n      std::shared_ptr<Handler> handler;\n      try {\n        handler = registry_->get_handler(handler_id.c_str());\n      } catch (std::logic_error&) {\n        // It may happen that another thread has removed this handler since\n        // we got a copy of our Logger object, and we now have a dangling\n        // reference. In such case, simply skip it.\n        continue;\n      }\n      if (record.level <= handler->get_level())\n        handler->handle(record);\n    }\n  }\n}\n\n} // namespace logging\n\n} // namespace mysql_harness\n"
  },
  {
    "path": "src/harness/src/logging/logging.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysql/harness/logging/registry.h\"\n#include \"dim.h\"\n\nnamespace mysql_harness {\n\nnamespace logging {\n\n}  // namespace logging\n\n}  // namespace mysql_harness\n// EMPTY NOW\n"
  },
  {
    "path": "src/harness/src/logging/registry.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifdef _WIN32\n#  define WIN32_LEAN_AND_MEAN\n#  include <windows.h>\n#  define getpid GetCurrentProcessId\n#endif\n\n#include \"mysql/harness/config_parser.h\"\n#include \"mysql/harness/logging/handler.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysql/harness/logging/registry.h\"\n\n#include \"dim.h\"\n#include \"utilities.h\"\n#include \"common.h\"\n\n#include <algorithm>\n#include <cassert>\n#include <iostream>\n#include <sstream>\n#include <cstdarg>\n\n\nusing mysql_harness::Path;\nusing mysql_harness::logging::LogLevel;\nusing mysql_harness::logging::Logger;\nusing mysql_harness::logging::Record;\nusing mysql_harness::serial_comma;\n\n// TODO one day we'll improve this and move it to a common spot\n#define harness_assert(COND) if (!(COND)) abort();\n\nnamespace mysql_harness {\n\nnamespace logging {\n\n/*static*/\nconst std::map<std::string, LogLevel> Registry::kLogLevels{\n  {\"fatal\", LogLevel::kFatal},\n  {\"error\", LogLevel::kError},\n  {\"warning\", LogLevel::kWarning},\n  {\"info\", LogLevel::kInfo},\n  {\"debug\", LogLevel::kDebug},\n};\n\n// log level is stored in this hacky global variable; see place where it's\n// set for exaplanation\nstd::string g_HACK_default_log_level;\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// logger CRUD\n//\n////////////////////////////////////////////////////////////////////////////////\n\n// throws std::logic_error\nvoid Registry::create_logger(const std::string& name, LogLevel level) {\n  std::lock_guard<std::mutex> lock(mtx_);\n  auto result = loggers_.emplace(name, Logger(*this, level));\n  if (result.second == false)\n    throw std::logic_error(\"Duplicate logger '\" + name + \"'\");\n}\n\n// throws std::logic_error\nvoid Registry::remove_logger(const std::string& name) {\n  std::lock_guard<std::mutex> lock(mtx_);\n  if (loggers_.erase(name) == 0)\n    throw std::logic_error(\"Removing non-existant logger '\" + name + \"'\");\n}\n\n// throws std::logic_error\nLogger Registry::get_logger(const std::string& name) const {\n  std::lock_guard<std::mutex> lock(mtx_);\n\n  auto it = loggers_.find(name);\n  if (it == loggers_.end())\n    throw std::logic_error(\"Accessing non-existant logger '\" + name + \"'\");\n\n  return it->second;\n}\n\n// throws std::logic_error\nvoid Registry::update_logger(const std::string& name, const Logger& logger) {\n\n  // this internally locks mtx_, so we call it before we lock it for good here\n  const std::set<std::string> handlers_in_registry = get_handler_names();\n\n  std::lock_guard<std::mutex> lock(mtx_);\n\n  // verify logger exists\n  auto it = loggers_.find(name);\n  if (it == loggers_.end())\n    throw std::logic_error(\"Updating non-existant logger '\" + name + \"'\");\n\n  // verify that all the handlers the new logger brings exist\n  for (const std::string& s : logger.get_handler_names())\n    if (std::find(handlers_in_registry.begin(), handlers_in_registry.end(), s)\n        == handlers_in_registry.end())\n      throw std::logic_error(std::string(\"Attaching unknown handler '\") + s + \"'\");\n\n  it->second = logger;\n}\n\nstd::set<std::string> Registry::get_logger_names() const {\n  std::lock_guard<std::mutex> lock(mtx_);\n  std::set<std::string> result;\n  for (const auto& pair : loggers_)\n    result.emplace(pair.first);\n  return result;\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// handler CRUD\n//\n////////////////////////////////////////////////////////////////////////////////\n\n// throws std::logic_error\nvoid Registry::add_handler(std::string name, std::shared_ptr<Handler> handler) {\n  std::lock_guard<std::mutex> lock(mtx_);\n\n  auto result = handlers_.emplace(name, handler);\n  if (!result.second)\n    throw std::logic_error(\"Duplicate handler '\" + name + \"'\");\n}\n\n// throws std::logic_error\nvoid Registry::remove_handler(std::string name) {\n  std::lock_guard<std::mutex> lock(mtx_);\n\n  auto it = handlers_.find(name);\n  if (it == handlers_.end())\n    throw std::logic_error(\"Removing non-existant handler '\" + name + \"'\");\n\n  // first remove the handler from all loggers\n  for (auto& pair : loggers_)\n    pair.second.detach_handler(name, false);\n\n  handlers_.erase(it);\n}\n\n// throws std::logic_error\nstd::shared_ptr<Handler> Registry::get_handler(std::string name) const {\n  std::lock_guard<std::mutex> lock(mtx_);\n\n  auto it = handlers_.find(name);\n  if (it == handlers_.end())\n    throw std::logic_error(\"Accessing non-existant handler '\" + name + \"'\");\n\n  return it->second;\n}\n\nstd::set<std::string> Registry::get_handler_names() const {\n  std::lock_guard<std::mutex> lock(mtx_);\n  std::set<std::string> result;\n  for (const auto& pair : handlers_)\n    result.emplace(pair.first);\n  return result;\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// high-level functions\n//\n////////////////////////////////////////////////////////////////////////////////\n\nstatic std::string g_main_app_log_domain;\n\nvoid attach_handler_to_all_loggers(Registry& registry, std::string handler_name) {\n  for (const std::string& logger_name : registry.get_logger_names()) {\n    Logger logger = registry.get_logger(logger_name);\n    logger.attach_handler(handler_name);  // no-op if handler is already attached\n    registry.update_logger(logger_name, logger);\n  }\n}\n\nvoid set_log_level_for_all_loggers(Registry& registry, LogLevel level) {\n  for (const std::string& logger_name : registry.get_logger_names()) {\n    Logger logger = registry.get_logger(logger_name);\n    logger.set_level(level);\n    registry.update_logger(logger_name, logger);\n  }\n}\n\nvoid clear_registry(Registry& registry) {\n  // wipe any existing loggers\n  for (const std::string& name : registry.get_logger_names())\n    registry.remove_logger(name); // throws std::logic_error\n\n  // wipe any existing handlers\n  for (const std::string& name : registry.get_handler_names())\n    registry.remove_handler(name.c_str()); // throws std::logic_error\n}\n\nstd::ostream *get_default_logger_stream() {\n  return &std::cerr;\n}\n\nvoid create_main_logfile_handler(Registry& registry,\n                                 const std::string& program,\n                                 const std::string& logging_folder,\n                                 bool format_messages) {\n  // Register the console as the handler if the logging folder is\n  // undefined. Otherwise, register a file handler.\n  if (logging_folder.empty()) {\n    registry.add_handler(kMainConsoleHandler,\n                         std::make_shared<StreamHandler>(*get_default_logger_stream(),\n                                                         format_messages));\n    attach_handler_to_all_loggers(registry, kMainConsoleHandler);\n  } else {\n    Path log_file = Path::make_path(logging_folder, program, \"log\");\n\n    // throws std::runtime_error on failure to open file\n    registry.add_handler(kMainLogHandler,\n                         std::make_shared<FileHandler>(log_file, format_messages));\n\n    attach_handler_to_all_loggers(registry, kMainLogHandler);\n  }\n}\n\nvoid init_logger(Registry& registry, const Config& config, const std::string& logger_name) {\n  registry.create_logger(logger_name, get_default_log_level(config));\n}\n\nvoid init_loggers(Registry& registry,\n                  const Config& config,\n                  const std::list<std::string>& modules,\n                  const std::string& main_app) {\n\n  // Create a logger for each module in the logging registry.\n  LogLevel level = get_default_log_level(config); // throws std::invalid_argument\n  for (const std::string& module : modules)\n    registry.create_logger(module, level); // throws std::logic_error\n\n  // ensure that we have at least 1 logger registered: the main app logger\n  g_main_app_log_domain = main_app;\n  harness_assert(registry.get_logger_names().size() > 0);\n}\n\nLogLevel get_default_log_level(const Config& config) {\n\n  // What we do here is an UGLY HACK. See code where g_HACK_default_log_level\n  // is set for explanation.\n  //\n  // Before introducing this hack in Router v8.0, we used to obtain the default\n  // log level from configuration, like so:\n  //\n  //   // We get the default log level from the configuration.\n  //   auto level_name = config.get_default(\"log_level\");\n  //\n  // Once we have a proper remedy, something analogous should be reinstated.\n\n  // Obtain default log level (through UGLY HACK)\n  (void) config;  // after we remove this hack, config will be used once again\n  std::string level_name = mysql_harness::logging::g_HACK_default_log_level;\n\n  std::transform(level_name.begin(), level_name.end(),\n                 level_name.begin(), ::tolower);\n\n  // Return its enum representation\n  try {\n    return Registry::kLogLevels.at(level_name);\n  } catch (std::out_of_range& exc) {\n    std::stringstream buffer;\n\n    buffer << \"Log level '\" << level_name\n           << \"' is not valid. Valid values are: \";\n\n    // Print the entries using a serial comma\n    std::vector<std::string> alternatives;\n    for (const auto& pair : Registry::kLogLevels)\n      alternatives.push_back(pair.first);\n    serial_comma(buffer, alternatives.begin(), alternatives.end());\n    throw std::invalid_argument(buffer.str());\n  }\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// These functions are simple proxies that can be used by logger plugins\n// to register their logging services. Note that they can only be called after\n// logging facility has been initialized; but by the time the plugins are loaded,\n// logging facility is already operational, so this is fine for plugin use.\n//\n////////////////////////////////////////////////////////////////////////////////\n\nvoid register_handler(std::string name, std::shared_ptr<Handler> handler) {\n  mysql_harness::logging::Registry& registry = mysql_harness::DIM::instance().get_LoggingRegistry();\n  registry.add_handler(name, handler);\n  attach_handler_to_all_loggers(registry, name);\n}\n\nvoid unregister_handler(std::string name) {\n  mysql_harness::logging::Registry& registry = mysql_harness::DIM::instance().get_LoggingRegistry();\n  registry.remove_handler(name);\n}\n\nvoid set_log_level_for_all_loggers(LogLevel level) {\n  mysql_harness::logging::Registry& registry = mysql_harness::DIM::instance().get_LoggingRegistry();\n  set_log_level_for_all_loggers(registry, level);\n}\n\n\n\n}  // namespace logging\n\n}  // namespace mysql_harness\n\n\n\n////////////////////////////////////////////////////////////////\n// Logging functions for use by plugins.\n\n// We want to hide log_message(), because instead we want plugins to call\n// log_error(), log_warning(), etc. However, those functions must be inline\n// and are therefore defined in the header file - which means log_message()\n// must have external linkage. So to solve this visibility conflict, we declare\n// log_message() locally, inside of log_error(), log_warning(), etc.\n//\n// Normally, this would only leave us with having to define log_message() here.\n// However, since we are building a DLL/DSO with this file, and since VS only\n// allows __declspec(dllimport/dllexport) in function declarations, we must\n// provide both declaration and definition.\nextern \"C\" void LOGGER_API log_message(LogLevel level, const char* module, const char* fmt, va_list ap)\n#ifdef HAVE_ATTRIBUTE_FORMAT\n  __attribute__((format(printf, 3, 0)))\n#endif\n  ;\n\nextern \"C\" void log_message(LogLevel level, const char* module, const char* fmt, va_list ap) {\n  harness_assert(level <= LogLevel::kDebug);\n\n  // get timestamp\n  time_t now;\n  time(&now);\n\n  mysql_harness::logging::Registry& registry = mysql_harness::DIM::instance().\n                                               get_LoggingRegistry();\n  harness_assert(registry.is_ready());\n\n  // Find the logger for the module\n  // NOTE that we copy the logger. Even if some other thread removes this\n  //      logger from registry, our call will still be valid. As for the\n  //      case of handlers getting removed in the meantime, Logger::handle()\n  //      handles this properly.\n  Logger logger;\n  try {\n    logger = registry.get_logger(module);\n  } catch (std::logic_error&) {\n    // Logger is not registered for this module (log domain), so log as main\n    // application domain instead (which should always be available)\n    using mysql_harness::logging::g_main_app_log_domain;\n    harness_assert(!g_main_app_log_domain.empty());\n    try {\n      logger = registry.get_logger(g_main_app_log_domain);\n    } catch (std::logic_error&) {\n      harness_assert(0);\n    }\n\n    // Complain that we're logging this elsewhere\n    char msg[mysql_harness::logging::kLogMessageMaxSize];\n    snprintf(msg, sizeof(msg),\n             \"Module '%s' not registered with logger - \"\n             \"logging the following message as '%s' instead\",\n             module, g_main_app_log_domain.c_str());\n    logger.handle({LogLevel::kError, getpid(), now, g_main_app_log_domain, msg});\n\n    // And switch log domain to main application domain for the original\n    // log message\n    module = g_main_app_log_domain.c_str();\n  }\n\n  // Build the message\n  char message[mysql_harness::logging::kLogMessageMaxSize];\n  vsnprintf(message, sizeof(message), fmt, ap);\n\n  // Build the record for the handler.\n  Record record{level, getpid(), now, module, message};\n\n  // Pass the record to the correct logger. The record should be\n  // passed to only one logger since otherwise the handler can get\n  // multiple calls, resulting in multiple log records.\n  logger.handle(record);\n}\n\n"
  },
  {
    "path": "src/harness/src/mysql_router_thread.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql_router_thread.h\"\n\n#include <stdexcept>\n#include <string>\n\n#ifdef _WIN32\n#include <errno.h>\n#include <process.h>\n#include <signal.h>\n#include <stdlib.h>\n#endif\n\nnamespace mysql_harness {\n\nstatic inline int mysql_router_thread_attr_init(mysql_router_thread_attr_t *attr) {\n#ifdef _WIN32\n  attr->dwStackSize = 0;\n  /* Set to joinable by default to match Linux */\n  attr->detachstate = MYSQL_ROUTER_THREAD_CREATE_JOINABLE;\n  return 0;\n#else\n  return pthread_attr_init(attr);\n#endif\n}\n\nstatic inline int mysql_router_thread_attr_setstacksize(mysql_router_thread_attr_t *attr,\n                                              size_t stacksize) {\n#ifdef _WIN32\n  attr->dwStackSize = (DWORD)stacksize;\n  return 0;\n#else\n  return pthread_attr_setstacksize(attr, stacksize);\n#endif\n}\n\nstatic inline int mysql_router_thread_attr_setdetachstate(mysql_router_thread_attr_t *attr,\n                                                int detachstate) {\n#ifdef _WIN32\n  attr->detachstate = detachstate;\n  return 0;\n#else\n  return pthread_attr_setdetachstate(attr, detachstate);\n#endif\n}\n\n/**\n * @brief checks if thread pointed by thread was started\n */\nstatic inline bool mysql_router_thread_started(const mysql_router_thread_handle *thread) {\n#ifndef _WIN32\n  return thread->thread != 0;\n#else\n  return thread->handle != INVALID_HANDLE_VALUE;\n#endif\n}\n\n/**\n * @brief checks if thread pointed by attr is joinable\n *\n * @throw std::runtime_error if cannot check if thread is joinable\n */\nstatic inline bool mysql_router_thread_joinable(const mysql_router_thread_attr_t *attr) {\n#ifndef _WIN32\n  int detachstate;\n\n  int rc = pthread_attr_getdetachstate(attr, &detachstate);\n  if (rc)\n    throw std::runtime_error(\"Failed to check if thread is joinable\");\n\n  return detachstate == MYSQL_ROUTER_THREAD_CREATE_JOINABLE;\n#else\n  return attr->detachstate == MYSQL_ROUTER_THREAD_CREATE_JOINABLE;\n#endif\n}\n\n#ifdef _WIN32\nstruct thread_start_parameter {\n  my_start_routine func;\n  void *arg;\n};\n\nstatic unsigned int __stdcall win_thread_start(void *p) {\n  struct thread_start_parameter *par = (struct thread_start_parameter *)p;\n  my_start_routine func = par->func;\n  void *arg = par->arg;\n  free(p);\n  (*func)(arg);\n  return 0;\n}\n#endif\n\nint mysql_router_thread_create(mysql_router_thread_handle *thread, const mysql_router_thread_attr_t *attr,\n                     my_start_routine func, void *arg) {\n#ifndef _WIN32\n  return pthread_create(&thread->thread, attr, func, arg);\n#else\n  struct thread_start_parameter *par;\n  unsigned int stack_size;\n\n  par = (struct thread_start_parameter *)malloc(sizeof(*par));\n  if (!par) goto error_return;\n\n  par->func = func;\n  par->arg = arg;\n  stack_size = attr ? attr->dwStackSize : kDefaultStackSizeInKiloBytes;\n\n  thread->handle =\n      (HANDLE)_beginthreadex(NULL, stack_size, win_thread_start, par, 0,\n                             (unsigned int *)&thread->thread);\n\n  if (thread->handle) {\n    /* Note that JOINABLE is default, so attr == NULL => JOINABLE. */\n    if (attr && attr->detachstate == MYSQL_ROUTER_THREAD_CREATE_DETACHED) {\n      /*\n        Close handles for detached threads right away to avoid leaking\n        handles. For joinable threads we need the handle during\n        mysql_router_thread_join. It will be closed there.\n      */\n      CloseHandle(thread->handle);\n      thread->handle = NULL;\n    }\n    return 0;\n  }\n\n  free(par);\n\nerror_return:\n  thread->thread = 0;\n  thread->handle = NULL;\n  return 1;\n#endif\n}\n\nint mysql_router_thread_join(mysql_router_thread_handle *thread, void **value_ptr) {\n#ifndef _WIN32\n  return pthread_join(thread->thread, value_ptr);\n#else\n  DWORD ret;\n  int result = 0;\n  ret = WaitForSingleObject(thread->handle, INFINITE);\n  if (ret != WAIT_OBJECT_0) {\n    result = 1;\n  }\n  if (thread->handle) CloseHandle(thread->handle);\n  thread->thread = 0;\n  thread->handle = NULL;\n  return result;\n#endif\n}\n\nMySQLRouterThread::MySQLRouterThread(size_t thread_stack_size) {\n  mysql_router_thread_attr_init(&thread_attr_);\n\n  int res = mysql_router_thread_attr_setstacksize(&thread_attr_, thread_stack_size << 10);\n  if (res)\n    throw std::runtime_error(\"Failed to adjust stack size, result code=\" + std::to_string(res));\n}\n\nvoid MySQLRouterThread::run(thread_function run_thread, void* args_ptr, bool detach) {\n  if (detach) {\n    mysql_router_thread_attr_setdetachstate(&thread_attr_, MYSQL_ROUTER_THREAD_CREATE_DETACHED);\n  } else {\n    should_join_ = true;\n  }\n\n  int ret = mysql_router_thread_create(&thread_handle_, &thread_attr_, run_thread, args_ptr);\n  if (ret)\n    throw std::runtime_error(\"Cannot create Thread\");\n}\n\nvoid MySQLRouterThread::join() {\n  if (mysql_router_thread_started(&thread_handle_) &&\n      mysql_router_thread_joinable(&thread_attr_)) {\n    mysql_router_thread_join(&thread_handle_, nullptr);\n  }\n  should_join_ = false;\n}\n\nMySQLRouterThread::~MySQLRouterThread() {\n  if(should_join_)\n    join();\n}\n\n} // end of harness namespace\n"
  },
  {
    "path": "src/harness/src/networking/ip_address.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql/harness/networking/ip_address.h\"\n#include \"mysql/harness/networking/ipv4_address.h\"\n#include \"mysql/harness/networking/ipv6_address.h\"\n\n#include <algorithm>\n#include <string>\n\nnamespace mysql_harness {\n\nIPAddress::IPAddress(const std::string &data) {\n  // IPv6 has at least 2 colons\n  if (std::count(data.begin(), data.end(), ':') >= 2) {\n    ipv6_address_ = IPv6Address(data); // throws std::invalid_argument\n    address_type_ = AddressType::kIPv6;\n  } else {\n    ipv4_address_ = IPv4Address(data); // throws std::invalid_argument\n    address_type_ = AddressType::kIPv4;\n  }\n}\n\nstd::string IPAddress::str() const {\n  if (is_ipv4()) {\n    return ipv4_address_.str();\n  } else if (is_ipv6()) {\n    return ipv6_address_.str();\n  } else {\n    return {};\n  }\n}\n\nbool operator==(const IPAddress &a, const IPAddress &b) {\n  if (a.address_type_ != b.address_type_) {\n    return false;\n  }\n\n  if (a.address_type_ == IPAddress::AddressType::kIPv4) {\n    return a.ipv4_address_ == b.ipv4_address_;\n  } else {\n    return a.ipv6_address_ == b.ipv6_address_;\n  }\n}\n\n} // namespace mysql_harness\n"
  },
  {
    "path": "src/harness/src/networking/ipv4_address.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql/harness/networking/ipv4_address.h\"\n\n#include \"utilities.h\"\n\n#ifndef _WIN32\n#  include <arpa/inet.h>\n#  include <netinet/in.h>\n#  include <sys/socket.h>\n#else\n#  define WIN32_LEAN_AND_MEAN\n#  include <windows.h>\n#  include <winsock2.h>\n#  include <ws2tcpip.h>\n#endif\n#include <cerrno>\n#include <cstring>\n#include <string>\n\nusing mysql_harness::utility::get_message_error;\n\nnamespace mysql_harness {\n\nIPv4Address::IPv4Address(const char *data) {\n  if (inet_pton(AF_INET, data, &address_) <= 0) {\n    throw std::invalid_argument(std::string(\"ipv4 parsing error\"));\n  }\n}\n\nstd::string IPv4Address::str() const {\n  char tmp[INET_ADDRSTRLEN];\n\n  if (auto addr = inet_ntop(AF_INET, const_cast<in_addr*>(&address_),\n                            tmp, INET_ADDRSTRLEN)) {\n    return addr;\n  }\n\n  throw std::runtime_error(\n      std::string(\"inet_ntop failed: \") + get_message_error(errno));\n}\n\n}\n"
  },
  {
    "path": "src/harness/src/networking/ipv6_address.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql/harness/networking/ipv6_address.h\"\n\n#include \"utilities.h\"\n\n#ifndef _WIN32\n#  include <arpa/inet.h>\n#  include <netinet/in.h>\n#  include <sys/socket.h>\n#else\n#  define WIN32_LEAN_AND_MEAN\n#  include <ws2tcpip.h> // in6_addr, inet_pton, etc\n#endif\n#include <cerrno>\n#include <cstring>\n#include <string>\n\n\nnamespace mysql_harness {\n\nIPv6Address::IPv6Address(const char *data) {\n  if (inet_pton(AF_INET6, data, &address_) <= 0) {\n    throw std::invalid_argument(std::string(\"ipv6 parsing error\"));\n  }\n}\n\nstd::string IPv6Address::str() const {\n  char tmp[INET6_ADDRSTRLEN];\n\n  if (inet_ntop(AF_INET6, const_cast<in6_addr*>(&address_),\n                tmp, INET6_ADDRSTRLEN)) {\n    return tmp;\n  }\n\n  throw std::runtime_error(\n    std::string(\"inet_ntop failed: \") + strerror(errno));\n}\n\n} // namespace mysql_harness\n"
  },
  {
    "path": "src/harness/src/networking/resolver.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql/harness/networking/resolver.h\"\n#include \"mysql/harness/networking/ip_address.h\"\n#include \"mysql/harness/networking/ipv4_address.h\"\n#include \"mysql/harness/networking/ipv6_address.h\"\n\n#ifndef _WIN32\n#  include <netdb.h>\n#  include <sys/socket.h>\n#endif\n#include <algorithm>\n#include <string>\n#include <sys/types.h>\n#include <vector>\n\n#ifndef NI_MAXSERV\n#define NI_MAXSERV 32\n#endif\n\nnamespace mysql_harness {\n\nstd::vector<IPAddress> Resolver::hostname(const char *name) const {\n  struct addrinfo hints, *result;\n\n  memset(&hints, 0, sizeof(hints));\n  hints.ai_family = AF_UNSPEC;\n  hints.ai_socktype = SOCK_STREAM;\n\n  if (auto err = getaddrinfo(name, nullptr, &hints, &result) != 0) {\n    throw std::invalid_argument(std::string(\"hostname resolve failed for \")\n                                + name + \": \" + gai_strerror(err));\n  }\n\n  std::vector<IPAddress> result_ips{};\n  struct addrinfo *res;\n  for (res = result; res; res = res->ai_next) {\n    if (res->ai_family == AF_INET) {\n      // IPv4\n      result_ips.emplace_back(\n        IPv4Address(((struct sockaddr_in*)res->ai_addr)->sin_addr.s_addr));\n    } else if (res->ai_family == AF_INET6) {\n      // IPv6\n      result_ips.emplace_back(\n        IPv6Address(((struct sockaddr_in6*)res->ai_addr)->sin6_addr.s6_addr));\n    }\n  }\n\n  freeaddrinfo(result);\n\n  return result_ips;\n}\n\nuint16_t Resolver::tcp_service_name(const char *name) const {\n  if (uint16_t cached = cached_tcp_service_by_name(name)) {\n    return cached;\n  }\n\n  struct servent *servinfo = getservbyname(name, \"tcp\");\n\n  if (!servinfo) {\n    throw std::invalid_argument(\n        std::string(\"service name resolve failed for \") + name);\n  }\n\n  uint16_t port = htons(static_cast<uint16_t>(servinfo->s_port));\n  cache_tcp_services_.push_back(std::make_pair(port, std::string(name)));\n\n  return port;\n}\n\nstd::string Resolver::tcp_service_port(uint16_t port) const {\n  std::string cached = cached_tcp_service_by_port(port);\n  if (!cached.empty()) {\n    return cached;\n  }\n\n  struct servent *servinfo = getservbyport(htons(port), \"tcp\");\n\n  if (!servinfo) {\n    // we cache the empty string so we don't look it up later\n    cache_tcp_services_.push_back(std::make_pair(port, std::string()));\n    // we simply return the port number as string\n    return std::to_string(port);\n  }\n\n  std::string service_name(servinfo->s_name);\n  cache_tcp_services_.push_back(std::make_pair(port, service_name));\n\n  return service_name;\n}\n\nuint16_t Resolver::cached_tcp_service_by_name(const std::string &name) const {\n  auto result = std::find_if(cache_tcp_services_.begin(),\n                             cache_tcp_services_.end(),\n                             [&name](ServiceCacheEntry service) {\n                               return service.second == name;\n                             });\n\n  if (result == cache_tcp_services_.end()) {\n    return 0;\n  }\n\n  return result->first;\n}\n\nstd::string Resolver::cached_tcp_service_by_port(uint16_t port) const {\n  auto result = std::find_if(cache_tcp_services_.begin(),\n                             cache_tcp_services_.end(),\n                             [&port](ServiceCacheEntry service) {\n                               return service.first == port;\n                             });\n\n  if (result == cache_tcp_services_.end()) {\n    return {};\n  }\n\n  return result->second;\n}\n\n}\n"
  },
  {
    "path": "src/harness/src/process_launcher.cc",
    "content": "/* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License, version 2.0,\n   as published by the Free Software Foundation.\n\n   This program is also distributed with certain software (including\n   but not limited to OpenSSL) that is licensed under separate terms,\n   as designated in a particular file or component or in included license\n   documentation.  The authors of MySQL hereby grant you an additional\n   permission to link the program and your derivative works with the\n   separately licensed software that they have included with MySQL.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; if not, write to the Free Software\n   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */\n\n#define NOMINMAX\n\n#include \"process_launcher.h\"\n\n#include <chrono>\n#include <string>\n#include <system_error>\n#include <thread>\n#include <algorithm>\n#include <cerrno>\n\n#ifdef _WIN32\n#  include <windows.h>\n#  include <tchar.h>\n#  include <stdio.h>\n#else\n#  include <stdio.h>\n#  include <unistd.h>\n#  include <sys/types.h>\n#  include <stdlib.h>\n#  include <string.h>\n#  include <sys/wait.h>\n#  include <string.h>\n#  include <poll.h>\n#  include <errno.h>\n#  include <signal.h>\n#  include <fcntl.h>\n#  include <sys/select.h>\n#endif\n\n\nnamespace mysql_harness {\n\n// performance tweaks\nconstexpr unsigned kWaitPidCheckInterval = 10;\nconstexpr auto kTerminateWaitInterval = std::chrono::seconds(10);\n\nProcessLauncher::~ProcessLauncher() {\n  if (is_alive) {\n    try {\n      close();\n    } catch (std::exception &e) {\n      fprintf(stderr, \"Can't stop the alive process %s: %s\\n\", cmd_line.c_str(),\n          e.what());\n    }\n  }\n}\n\n#ifdef _WIN32\n\nvoid ProcessLauncher::start() {\n  SECURITY_ATTRIBUTES saAttr;\n\n  saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);\n  saAttr.bInheritHandle = TRUE;\n  saAttr.lpSecurityDescriptor = NULL;\n\n  if (!CreatePipe(&child_out_rd, &child_out_wr, &saAttr, 0))\n    report_error(\"Failed to create child_out_rd\");\n\n  if (!SetHandleInformation(child_out_rd, HANDLE_FLAG_INHERIT, 0))\n    report_error(\"Failed to create child_out_rd\");\n\n  // force non blocking IO in Windows\n  DWORD mode = PIPE_NOWAIT;\n  //BOOL res = SetNamedPipeHandleState(child_out_rd, &mode, NULL, NULL);\n\n  if (!CreatePipe(&child_in_rd, &child_in_wr, &saAttr, 0))\n    report_error(\"Failed to create child_in_rd\");\n\n  if (!SetHandleInformation(child_in_wr, HANDLE_FLAG_INHERIT, 0))\n    report_error(\"Failed to created child_in_wr\");\n\n  // Create Process\n  std::string s = this->cmd_line;\n  const char **pc = args;\n  while (*++pc != NULL) {\n    s += \" \";\n    s += *pc;\n  }\n  char *sz_cmd_line = (char *)malloc(s.length() + 1);\n  if (!sz_cmd_line)\n    report_error(\"Cannot assign memory for command line in ProcessLauncher::start\");\n  _tcscpy(sz_cmd_line, s.c_str());\n\n  BOOL bSuccess = FALSE;\n\n  ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));\n\n  ZeroMemory(&si, sizeof(STARTUPINFO));\n  si.cb = sizeof(STARTUPINFO);\n  if (redirect_stderr)\n    si.hStdError = child_out_wr;\n  si.hStdOutput = child_out_wr;\n  si.hStdInput = child_in_rd;\n  si.dwFlags |= STARTF_USESTDHANDLES;\n\n  bSuccess = CreateProcess(\n    NULL,          // lpApplicationName\n    sz_cmd_line,     // lpCommandLine\n    NULL,          // lpProcessAttributes\n    NULL,          // lpThreadAttributes\n    TRUE,          // bInheritHandles\n    0,             // dwCreationFlags\n    NULL,          // lpEnvironment\n    NULL,          // lpCurrentDirectory\n    &si,           // lpStartupInfo\n    &pi);          // lpProcessInformation\n\n  if (!bSuccess)\n    report_error((\"Failed to start process \" + s).c_str());\n  else\n    is_alive = true;\n\n  CloseHandle(child_out_wr);\n  CloseHandle(child_in_rd);\n\n  //DWORD res1 = WaitForInputIdle(pi.hProcess, 100);\n  //res1 = WaitForSingleObject(pi.hThread, 100);\n  free(sz_cmd_line);\n}\n\nuint64_t ProcessLauncher::get_pid() const {\n  return (uint64_t)pi.hProcess;\n}\n\nint ProcessLauncher::wait(unsigned int timeout_ms) {\n  DWORD dwExit = 0;\n  BOOL get_ret{FALSE};\n  if (get_ret = GetExitCodeProcess(pi.hProcess, &dwExit)) {\n    if (dwExit == STILL_ACTIVE) {\n      auto wait_ret = WaitForSingleObject(pi.hProcess, timeout_ms);\n      if (wait_ret == 0) {\n        get_ret = GetExitCodeProcess(pi.hProcess, &dwExit);\n      }\n      else {\n        throw std::runtime_error(\"Error waiting for process exit: \" + std::to_string(wait_ret));\n      }\n    }\n  }\n  if (get_ret == FALSE) {\n    DWORD dwError = GetLastError();\n    if (dwError != ERROR_INVALID_HANDLE)  // not closed already?\n      report_error(NULL);\n    else\n      dwExit = 128; // Invalid handle\n  }\n  return dwExit;\n}\n\nint ProcessLauncher::close() {\n  DWORD dwExit;\n  if (GetExitCodeProcess(pi.hProcess, &dwExit)) {\n    if (dwExit == STILL_ACTIVE) {\n      if (!TerminateProcess(pi.hProcess, 0))\n        report_error(NULL);\n      // TerminateProcess is async, wait for process to end.\n      WaitForSingleObject(pi.hProcess, INFINITE);\n    }\n  } else {\n    if (is_alive)\n      report_error(NULL);\n  }\n\n  if (!CloseHandle(pi.hProcess))\n    report_error(NULL);\n  if (!CloseHandle(pi.hThread))\n    report_error(NULL);\n\n  if (!CloseHandle(child_out_rd))\n    report_error(NULL);\n  if (!child_in_wr_closed && !CloseHandle(child_in_wr))\n    report_error(NULL);\n\n  is_alive = false;\n  return 0;\n}\n\nint ProcessLauncher::read(char *buf, size_t count, unsigned timeout_ms) {\n  DWORD dwBytesRead;\n  DWORD dwBytesAvail;\n\n  // at least 1ms\n  auto std_interval_ms = std::max(timeout_ms / 10U, 1U);\n\n  do {\n    // check if there is data in the pipe before issuing a blocking read\n    BOOL bSuccess = PeekNamedPipe(child_out_rd, NULL, 0, NULL, &dwBytesAvail, NULL);\n\n    if (!bSuccess) {\n      DWORD dwCode = GetLastError();\n      if (dwCode == ERROR_NO_DATA || dwCode == ERROR_BROKEN_PIPE)\n        return EOF;\n      else\n        report_error(NULL);\n    }\n\n    // we got data, let's read it\n    if (dwBytesAvail != 0) break;\n\n    if (timeout_ms == 0) {\n      // no data and time left to wait\n      //\n\n      return 0;\n    }\n\n    auto interval_ms = std::min(timeout_ms, std_interval_ms);\n\n    // just wait the whole timeout and try again\n    auto sleep_time = std::chrono::milliseconds(interval_ms);\n\n    std::this_thread::sleep_for(sleep_time);\n\n    timeout_ms -= interval_ms;\n  } while (true);\n\n  BOOL bSuccess = ReadFile(child_out_rd, buf, count, &dwBytesRead, NULL);\n\n  if (bSuccess == FALSE) {\n    DWORD dwCode = GetLastError();\n    if (dwCode == ERROR_NO_DATA || dwCode == ERROR_BROKEN_PIPE)\n      return EOF;\n    else\n      report_error(NULL);\n  }\n\n  return dwBytesRead;\n}\n\nint ProcessLauncher::write(const char *buf, size_t count) {\n  DWORD dwBytesWritten;\n  BOOL bSuccess = FALSE;\n  bSuccess = WriteFile(child_in_wr, buf, count, &dwBytesWritten, NULL);\n  if (!bSuccess) {\n    if (GetLastError() != ERROR_NO_DATA)  // otherwise child process just died.\n      report_error(NULL);\n  } else {\n    // When child input buffer is full, this returns zero in NO_WAIT mode.\n    return dwBytesWritten;\n  }\n  return 0; // so the compiler does not cry\n}\n\nvoid ProcessLauncher::end_of_write() {\n  CloseHandle(child_in_wr);\n  child_in_wr_closed = true;\n}\n\nvoid ProcessLauncher::report_error(const char *msg, const char* prefix) {\n  DWORD dwCode = GetLastError();\n  LPTSTR lpMsgBuf;\n\n  if (msg != NULL) {\n    throw std::system_error(dwCode, std::generic_category(), msg);\n  } else {\n    FormatMessage(\n      FORMAT_MESSAGE_ALLOCATE_BUFFER |\n      FORMAT_MESSAGE_FROM_SYSTEM |\n      FORMAT_MESSAGE_IGNORE_INSERTS,\n      NULL,\n      dwCode,\n      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),\n      (LPTSTR)&lpMsgBuf,\n      0, NULL);\n    std::string msgerr;\n    if (prefix != \"\") {\n      msgerr += std::string(prefix) + \"; \";\n    }\n    msgerr += \"SystemError: \";\n    msgerr += lpMsgBuf;\n    msgerr += \"with error code %d\" + std::to_string(dwCode) + \".\";\n    throw std::system_error(dwCode, std::generic_category(), msgerr);\n  }\n}\n\nuint64_t ProcessLauncher::get_fd_write() const {\n  return (uint64_t)child_in_wr;\n}\n\nuint64_t ProcessLauncher::get_fd_read() const {\n  return (uint64_t)child_out_rd;\n}\n\n#else\n\nvoid ProcessLauncher::start()\n{\n  if( pipe(fd_in) < 0 )\n  {\n    report_error(NULL, \"ProcessLauncher::start() pipe(fd_in)\");\n  }\n  if( pipe(fd_out) < 0 )\n  {\n    report_error(NULL, \"ProcessLauncher::start() pipe(fd_out)\");\n  }\n\n  // Ignore broken pipe signal\n  signal(SIGPIPE, SIG_IGN);\n\n  childpid = fork();\n  if(childpid == -1)\n  {\n    report_error(NULL, \"ProcessLauncher::start() fork()\");\n  }\n\n  if(childpid == 0)\n  {\n#ifdef LINUX\n    prctl(PR_SET_PDEATHSIG, SIGHUP);\n#endif\n\n    ::close(fd_out[0]);\n    ::close(fd_in[1]);\n    while( dup2(fd_out[1], STDOUT_FILENO) == -1 )\n    {\n      if(errno == EINTR) continue;\n      else report_error(NULL, \"ProcessLauncher::start() dup2()\");\n    }\n\n    if(redirect_stderr)\n    {\n      while( dup2(fd_out[1], STDERR_FILENO) == -1 )\n      {\n        if(errno == EINTR) continue;\n        else report_error(NULL, \"ProcessLauncher::start() dup2()\");\n      }\n    }\n    while( dup2(fd_in[0], STDIN_FILENO) == -1 )\n    {\n      if(errno == EINTR) continue;\n      else report_error(NULL, \"ProcessLauncher::start() dup2()\");\n    }\n\n    fcntl(fd_out[1], F_SETFD, FD_CLOEXEC);\n    fcntl(fd_in[0], F_SETFD, FD_CLOEXEC);\n\n    execvp(cmd_line.c_str(), (char * const *)args);\n    // if exec returns, there is an error.\n    int my_errno = errno;\n    fprintf(stderr, \"%s could not be executed: %s (errno %d)\\n\", cmd_line.c_str(), strerror(my_errno), my_errno);\n\n    // we need to identify an ENOENT and since some programs return 2 as exit-code\n    // we need to return a non-existent code, 128 is a general convention used to indicate\n    // a failure to execute another program in a subprocess\n    if (my_errno == 2)\n      my_errno = 128;\n\n    exit(my_errno);\n  }\n  else\n  {\n    ::close(fd_out[1]);\n    ::close(fd_in[0]);\n\n    fd_out[1] = -1;\n    fd_in[0] = -1;\n\n    is_alive = true;\n  }\n}\n\nint ProcessLauncher::close()\n{\n  int result = 0;\n  if (is_alive) {\n    // only try to kill the pid, if we started it. Not that we hurt someone else.\n    if(::kill(childpid, SIGTERM) < 0) {\n      if (errno != ESRCH) {\n        throw std::system_error(errno, std::system_category(), strerror(errno));\n      }\n    } else {\n      try {\n        // wait for it shutdown before using the big hammer\n        result = wait(static_cast<unsigned int>(std::chrono::duration_cast<std::chrono::milliseconds>(kTerminateWaitInterval).count()));\n      } catch(const std::system_error &e) {\n        if(e.code() != std::error_code(ESRCH, std::system_category())) {\n          if(::kill(childpid, SIGKILL) < 0) {\n            if (errno != ESRCH) {\n              throw std::system_error(errno, std::system_category(), strerror(errno));\n            }\n          }\n        }\n        result = wait();\n      }\n    }\n  }\n\n  if (fd_out[0] != -1) ::close(fd_out[0]);\n  if (fd_in[1] != -1) ::close(fd_in[1]);\n\n  fd_out[0] = -1;\n  fd_in[1] = -1;\n  is_alive = false;\n\n  return result;\n}\n\nvoid ProcessLauncher::end_of_write() {\n  if (fd_in[1] != -1) ::close(fd_in[1]);\n  fd_in[1] = -1;\n}\n\nint ProcessLauncher::read(char *buf, size_t count, unsigned timeout_ms)\n{\n  int n;\n  fd_set set;\n  struct timeval timeout;\n  memset (&timeout, 0x0, sizeof(timeout));\n  timeout.tv_sec = static_cast<decltype(timeout.tv_sec)>(timeout_ms / 1000);\n  timeout.tv_usec = static_cast<decltype(timeout.tv_usec)>((timeout_ms % 1000) * 1000);\n\n  FD_ZERO(&set);\n  FD_SET(fd_out[0], &set);\n\n  int res = select(fd_out[0] + 1, &set, NULL, NULL, &timeout);\n  if (res < 0) report_error(nullptr, \"select()\");\n  if (res == 0) return 0;\n\n  if((n = (int)::read(fd_out[0], buf, count)) >= 0)\n    return n;\n\n  report_error(nullptr, \"read\");\n  return -1;\n}\n\nint ProcessLauncher::write(const char *buf, size_t count)\n{\n  int n;\n  if ((n = (int)::write(fd_in[1], buf, count)) >= 0)\n    return n;\n  if (errno == EPIPE) return 0;\n  report_error(NULL, \"write\");\n  return -1;\n}\n\nvoid ProcessLauncher::report_error(const char *msg, const char *prefix)\n{\n  char sys_err[ 64 ] = {'\\0'};\n  int errnum = errno;\n  if (msg == NULL) {\n\n    // we do this #ifdef dance because on unix systems strerror_r() will generate\n    // a warning if we don't collect the result (warn_unused_result attribute)\n  #if ((defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE >= 200112L)) ||    \\\n         (defined _XOPEN_SOURCE && (_XOPEN_SOURCE >= 600)))      &&    \\\n        ! defined _GNU_SOURCE\n    int r = strerror_r(errno, sys_err, sizeof(sys_err));\n    (void)r;  // silence unused variable;\n  #elif defined(_GNU_SOURCE) && defined(__GLIBC__)\n    const char *r = strerror_r(errno, sys_err, sizeof(sys_err));\n    (void)r;  // silence unused variable;\n  #else\n    strerror_r(errno, sys_err, sizeof(sys_err));\n  #endif\n\n    std::string s = std::string(prefix) + \"; \" + std::string(sys_err) +\n        \"with errno .\" + std::to_string(errnum);\n    throw std::system_error(errnum, std::generic_category(), s);\n  }\n  else {\n    throw std::system_error(errnum, std::generic_category(), msg);\n  }\n}\n\nuint64_t ProcessLauncher::get_pid() const\n{\n  static_assert(sizeof(pid_t) <= sizeof(uint64_t), \"sizeof(pid_t) > sizeof(uint64_t)\");\n  return (uint64_t)childpid;\n}\n\nint ProcessLauncher::wait(const unsigned int timeout_ms)\n{\n  unsigned int wait_time = timeout_ms;\n  do {\n    int status;\n\n    pid_t ret = ::waitpid(childpid, &status, WNOHANG);\n\n    if (ret == 0) {\n      auto sleep_for = std::min(wait_time, kWaitPidCheckInterval);\n      if (sleep_for > 0) {\n        std::this_thread::sleep_for(std::chrono::milliseconds(sleep_for));\n        wait_time -= sleep_for;\n      } else {\n        throw std::system_error(ETIMEDOUT, std::generic_category(),\n            std::string(\"Timed out waiting \" + std::to_string(timeout_ms) + \" ms for the process \" + std::to_string(childpid) + \" to exit\"));\n      }\n    } else if (ret == -1) {\n      throw std::system_error(errno, std::generic_category(),\n          std::string(\"waiting for process \" + std::to_string(childpid) + \" failed\"));\n    } else {\n      if (WIFEXITED(status)) {\n        return WEXITSTATUS(status);\n      } else if (WIFSIGNALED(status)) {\n        throw std::runtime_error(std::string(\"Process \" + std::to_string(childpid) + \" got signal \" + std::to_string(WTERMSIG(status))));\n      } else {\n        // it neither exited, not received a signal.\n        throw std::runtime_error(std::string(\"Process \" + std::to_string(childpid) + \" ... not idea\"));\n      }\n    }\n  }\n  while(true);\n}\n\nuint64_t ProcessLauncher::get_fd_write() const\n{\n  return (uint64_t)fd_in[1];\n}\n\nuint64_t ProcessLauncher::get_fd_read() const\n{\n  return (uint64_t)fd_out[0];\n}\n\n#endif\n\nint ProcessLauncher::kill() {\n  return close();\n}\n\n} // end of namespace mysql_harness\n"
  },
  {
    "path": "src/harness/src/random_generator.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"random_generator.h\"\n\n#include <algorithm>\n#include <assert.h> // <cassert> is flawed: assert() lands in global namespace on Ubuntu 14.04, not std::\n#include <random>\n#include <stdexcept>\n#include <string>\n\nnamespace mysql_harness {\n\nnamespace {\nconst unsigned kMinPasswordLength = 8;\n\nconst std::string kAlphabetDigits = \"0123456789\";\nconst std::string kAlphabetLowercase = \"abcdefghijklmnopqrstuvwxyz\";\nconst std::string kAlphabetUppercase = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\nconst std::string kAlphabetSpecial = \"~@#$^&*()-=+]}[{|;:.>,</?\";\n\nstd::string get_alphabet(unsigned alphabet_mask) {\n  std::string result;\n  if (alphabet_mask & RandomGenerator::AlphabetDigits) result += kAlphabetDigits;\n  if (alphabet_mask & RandomGenerator::AlphabetLowercase) result += kAlphabetLowercase;\n  if (alphabet_mask & RandomGenerator::AlphabetUppercase) result += kAlphabetUppercase;\n  if (alphabet_mask & RandomGenerator::AlphabetSpecial) result += kAlphabetSpecial;\n\n  return result;\n}\n}\n\nRandomGeneratorInterface::~RandomGeneratorInterface() = default;\n\nstd::string RandomGenerator::generate_identifier(unsigned length, unsigned alphabet_mask) /*override*/ {\n  std::string result;\n  std::random_device rd;\n  const std::string alphabet = get_alphabet(alphabet_mask);\n\n  if (alphabet.length() < 1) {\n    throw std::invalid_argument(\"Wrong alphabet mask provided for generate_identifier(\"\n                                + std::to_string(alphabet_mask) + \")\");\n  }\n\n  std::uniform_int_distribution<unsigned long> dist(0, alphabet.length() - 1);\n\n  for (unsigned i = 0; i < length; i++)\n    result += alphabet[dist(rd)];\n\n  return result;\n}\n\nstd::string RandomGenerator::generate_strong_password(unsigned length) /*override*/ {\n  if (length < kMinPasswordLength) {\n    throw std::invalid_argument(\"The password needs to be at least \"\n                                + std::to_string(kMinPasswordLength)\n                                + \" charactes long\");\n  }\n\n  std::string result;\n  result += generate_identifier(1, AlphabetDigits); // at least one digit\n  result += generate_identifier(1, AlphabetLowercase); // at least one lowercase letter\n  result += generate_identifier(1, AlphabetUppercase); // at least one upperrcase letter\n  result += generate_identifier(1, AlphabetSpecial); // at least one special character\n\n  // fill the rest with random data from the whole characters set\n  length -= static_cast<unsigned>(result.length());\n  result += generate_identifier(length, AlphabetAll);\n\n  std::random_shuffle(result.begin(), result.end());\n\n  return result;\n}\n\n// returns \"012345678901234567890123...\", truncated to length\nstd::string FakeRandomGenerator::generate_identifier(unsigned length, unsigned) /*override*/ {\n  std::string pwd;\n  for (unsigned i = 0; i < length; i++)\n    pwd += static_cast<char>('0' + i % 10);\n  return pwd;\n}\n\n// returns \"012345678901234567890123...\", truncated to length\nstd::string FakeRandomGenerator::generate_strong_password(unsigned length) /*override*/ {\n  return generate_identifier(length, 0);\n}\n\n} // namespace mysql_harness\n"
  },
  {
    "path": "src/harness/src/socket_operations.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"common.h\"\n#include \"socket_operations.h\"\n#include \"common.h\"\n\n#include <memory>\n#ifndef _WIN32\n# include <arpa/inet.h>\n# include <fcntl.h>\n# include <ifaddrs.h>\n# include <netdb.h>\n# include <netinet/tcp.h>\n# include <sys/socket.h>\n# include <poll.h>\n# include <sys/stat.h>\n# include <sys/types.h>\n# include <termios.h>\n# include <unistd.h>\n# ifndef __APPLE__\n#  include <ifaddrs.h>\n#  include <net/if.h>\n# endif\n#else\n# define WIN32_LEAN_AND_MEAN\n# include <windows.h>\n# include <winsock2.h>\n# include <ws2tcpip.h>\n#endif\n\nnamespace mysql_harness {\n\nSocketOperations* SocketOperations::instance() {\n  static SocketOperations instance_;\n  return &instance_;\n}\n\nint SocketOperations::poll(struct pollfd *fds, nfds_t nfds, std::chrono::milliseconds timeout_ms) {\n#ifdef _WIN32\n  return ::WSAPoll(fds, nfds, timeout_ms.count());\n#else\n  return ::poll(fds, nfds, static_cast<int>(timeout_ms.count()));\n#endif\n}\n\nint SocketOperations::connect_non_blocking_wait(int sock, std::chrono::milliseconds timeout_ms) {\n  struct pollfd fds[] = {\n    { sock, POLLOUT, 0 },\n  };\n\n  int res = poll(fds, sizeof(fds) / sizeof(fds[0]), timeout_ms);\n\n  if (0 == res) {\n    // timeout\n    this->set_errno(ETIMEDOUT);\n    return -1;\n  } else if (res < 0) {\n    // some error\n    return -1;\n  }\n\n  bool connect_writable = (fds[0].revents & POLLOUT) != 0;\n\n  if (!connect_writable) {\n    // this should not happen\n    this->set_errno(EINVAL);\n    return -1;\n  }\n\n  return 0;\n}\n\nint SocketOperations::connect_non_blocking_status(int sock, int &so_error) {\n  socklen_t error_len = static_cast<socklen_t>(sizeof(so_error));\n\n  if (getsockopt(sock, SOL_SOCKET, SO_ERROR, reinterpret_cast<char *>(&so_error), &error_len) == -1) {\n    so_error = get_errno();\n    return -1;\n  }\n\n  if (so_error) {\n    return -1;\n  }\n\n  return 0;\n}\n\nssize_t SocketOperations::write(int fd, void *buffer, size_t nbyte) {\n#ifndef _WIN32\n  return ::write(fd, buffer, nbyte);\n#else\n  return ::send(fd, reinterpret_cast<const char *>(buffer), nbyte, 0);\n#endif\n}\n\nssize_t SocketOperations::read(int fd, void *buffer, size_t nbyte) {\n#ifndef _WIN32\n  return ::read(fd, buffer, nbyte);\n#else\n  return ::recv(fd, reinterpret_cast<char *>(buffer), nbyte, 0);\n#endif\n}\n\nvoid SocketOperations::close(int fd) {\n#ifndef _WIN32\n  ::close(fd);\n#else\n  ::closesocket(fd);\n#endif\n}\n\nvoid SocketOperations::shutdown(int fd) {\n#ifndef _WIN32\n  ::shutdown(fd, SHUT_RDWR);\n#else\n  ::shutdown(fd, SD_BOTH);\n#endif\n}\n\nvoid SocketOperations::freeaddrinfo(addrinfo *ai) {\n  return ::freeaddrinfo(ai);\n}\n\nint SocketOperations::getaddrinfo(const char *node, const char *service,\n                                  const addrinfo *hints, addrinfo **res) {\n  return ::getaddrinfo(node, service, hints, res);\n}\n\nint SocketOperations::bind(int fd, const struct sockaddr *addr, socklen_t len) {\n  return ::bind(fd, addr, len);\n}\n\nint SocketOperations::socket(int domain, int type, int protocol) {\n  return ::socket(domain, type, protocol);\n}\n\nint SocketOperations::setsockopt(int fd, int level, int optname,\n                                 const void *optval, socklen_t optlen) {\n#ifndef _WIN32\n  return ::setsockopt(fd, level, optname, optval, optlen);\n#else\n  return ::setsockopt(fd, level, optname, reinterpret_cast<const char*>(optval), optlen);\n#endif\n}\n\nint SocketOperations::listen(int fd, int n) {\n  return ::listen(fd, n);\n}\n\nstd::string SocketOperations::get_local_hostname() {\n  char buf[1024] = {0};\n#if defined(_WIN32) || defined(__APPLE__) || defined(__FreeBSD__)\n  int ret = gethostname(buf, sizeof(buf));\n  if (ret < 0) {\n    int err = get_errno();\n    throw LocalHostnameResolutionError(\"Could not get local hostname: \"\n                                       + mysql_harness::get_strerror(err)\n                                       + \" (ret: \" + std::to_string(ret)\n                                       + \", error: \" + std::to_string(err) + \")\");\n  }\n#else\n  struct ifaddrs *ifa = nullptr, *ifap;\n  int ret = -1, family;\n  socklen_t addrlen;\n\n  std::shared_ptr<ifaddrs> ifa_deleter(nullptr, [&](void*){if (ifa) freeifaddrs(ifa);});\n  if ((ret = getifaddrs(&ifa)) != 0 || !ifa) {\n    throw LocalHostnameResolutionError(\"Could not get local host address: \"\n                                       + mysql_harness::get_strerror(errno)\n                                       + \" (ret: \" + std::to_string(ret)\n                                       + \", errno: \" + std::to_string(errno) + \")\");\n  }\n  for (ifap = ifa; ifap != NULL; ifap = ifap->ifa_next) {\n    if ((ifap->ifa_addr == NULL) || (ifap->ifa_flags & IFF_LOOPBACK) || (!(ifap->ifa_flags & IFF_UP)))\n      continue;\n    family = ifap->ifa_addr->sa_family;\n    if (family != AF_INET && family != AF_INET6)\n      continue;\n    if (family == AF_INET6) {\n      struct sockaddr_in6 *sin6;\n\n      sin6 = (struct sockaddr_in6 *)ifap->ifa_addr;\n      if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) || IN6_IS_ADDR_MC_LINKLOCAL(&sin6->sin6_addr))\n        continue;\n    }\n    addrlen = static_cast<socklen_t>((family == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6));\n    ret = getnameinfo(ifap->ifa_addr, addrlen, buf,\n        static_cast<socklen_t>(sizeof(buf)), NULL, 0, NI_NAMEREQD);\n  }\n  if (ret != EAI_NONAME && ret != 0) {\n    throw LocalHostnameResolutionError(\"Could not get local hostname: \"\n                                       + std::string(gai_strerror(ret))\n                                       + \" (ret: \" + std::to_string(ret)\n                                       + \", errno: \" + std::to_string(errno) + \")\");\n  }\n#endif\n  return buf;\n}\n\n} // namespace mysql_harness\n"
  },
  {
    "path": "src/harness/src/tcp_address.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"tcp_address.h\"\n\n#include <cstring>\n#include <sstream>\n#ifndef _WIN32\n#  include <netdb.h>\n#  include <sys/socket.h>\n#else\n#  define WIN32_LEAN_AND_MEAN\n#  include <windows.h>\n#  include <winsock2.h>\n#  include <ws2tcpip.h>\n#endif\n\nnamespace mysql_harness {\n\nvoid TCPAddress::detect_family() noexcept {\n  // Function only run once by setting ip_family_ > Family::UNKNOWN\n  ip_family_ = Family::INVALID;\n\n  if (addr.empty()) {\n    return;\n  }\n\n  struct addrinfo *servinfo, *info, hints;\n  int err;\n\n  memset(&hints, 0, sizeof hints);\n  hints.ai_family = AF_UNSPEC;\n  hints.ai_socktype = SOCK_STREAM;\n  hints.ai_flags = AI_PASSIVE;\n\n  err = getaddrinfo(addr.c_str(), nullptr, &hints, &servinfo);\n  if (err != 0) {\n    // We consider the IP/name to be invalid\n    return;\n  }\n\n  // Get family and IP address\n  for (info = servinfo; info != nullptr; info = info->ai_next) {\n    if (info->ai_family == AF_INET6) {\n      ip_family_ = Family::IPV6;\n    } else if (info->ai_family == AF_INET) {\n      ip_family_ = Family::IPV4;\n    }\n  }\n  freeaddrinfo(servinfo);\n}\n\nuint16_t TCPAddress::validate_port(uint32_t tcp_port) {\n  if (tcp_port < 1 || tcp_port > UINT16_MAX) {\n    return 0;\n  }\n  return static_cast<uint16_t>(tcp_port);\n}\n\nstd::string TCPAddress::str() const {\n  std::ostringstream os;\n\n  if (ip_family_ == Family::IPV6) {\n    os << \"[\" << addr << \"]\";\n  } else {\n    os << addr;\n  }\n\n  if (port > 0) {\n    os << \":\" << port;\n  }\n\n  return os.str();\n}\n\nbool TCPAddress::is_valid() noexcept {\n  if (ip_family_ == Family::UNKNOWN) {\n    detect_family();\n  }\n  return !(addr.empty() || port == 0 || ip_family_ == Family::INVALID);\n}\n\n} // namespace mysql_harness\n\n"
  },
  {
    "path": "src/harness/src/utilities-posix.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"utilities.h\"\n\n#include <fnmatch.h>\n#include <unistd.h>\n#include <regex.h>\n#include <string>\n\nnamespace mysql_harness {\n\nnamespace utility {\n\nbool matches_glob(const std::string& word, const std::string& pattern) {\n  return (fnmatch(pattern.c_str(), word.c_str(), 0) == 0);\n}\n\nvoid sleep_seconds(unsigned int seconds) {\n  sleep(seconds);\n}\n\nbool regex_pattern_matches(const std::string &s,\n                      const std::string &pattern) {\n  regex_t regex;\n  auto r = regcomp(&regex, pattern.c_str(), REG_EXTENDED);\n  if (r) {\n    throw std::runtime_error(\"Error compiling regex pattern: \" + pattern);\n  }\n  r = regexec(&regex, s.c_str(), 0, NULL, 0);\n  regfree(&regex);\n  return (r == 0);\n}\n\n}  // namespace utility\n\n} // namespace mysql_harness\n"
  },
  {
    "path": "src/harness/src/utilities-windows.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"utilities.h\"\n\n#include <Windows.h>\n#include <Winsock2.h>\n#include <Shlwapi.h>\n\n#include <regex>\n#include <string>\n\nnamespace mysql_harness {\n\nnamespace utility {\n\nbool matches_glob(const std::string& word, const std::string& pattern) {\n  return PathMatchSpec(word.c_str(), pattern.c_str());\n}\n\nvoid sleep_seconds(unsigned int seconds) {\n  Sleep(1000 * seconds);\n}\n\nstd::string get_message_error(int errcode) {\n  if (errcode == SOCKET_ERROR || errcode == 0) {\n    errcode = WSAGetLastError();\n  }\n\n  LPTSTR lpMsgBuf;\n\n  if (0 != FormatMessage(\n      FORMAT_MESSAGE_ALLOCATE_BUFFER |\n      FORMAT_MESSAGE_FROM_SYSTEM |\n      FORMAT_MESSAGE_IGNORE_INSERTS,\n      NULL,\n      errcode,\n      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),\n      (LPTSTR)&lpMsgBuf,\n      0, NULL)) {\n    std::string msgerr = \"SystemError: \";\n    msgerr += lpMsgBuf;\n    LocalFree(lpMsgBuf);\n    return msgerr;\n  } else {\n    return \"SystemError: \" + std::to_string(errcode);\n  }\n}\n\nbool regex_pattern_matches(const std::string &s,\n                            const std::string &pattern) {\n  std::regex regex(pattern, std::regex::extended);\n  return std::regex_match(s, regex);\n}\n\n\n}  // namespace utility\n\n} // namespace mysql_harness\n"
  },
  {
    "path": "src/harness/src/utilities.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"utilities.h\"\n\n#include <algorithm>\n#include <cassert>\n#include <cstdarg>\n#include <cstdio>\n#include <string.h>\n\nusing std::string;\nusing std::vector;\n\nnamespace mysql_harness {\n\nnamespace utility {\n\nstring dirname(const string& path) {\n  string::size_type pos = path.rfind('/');\n  if (pos != string::npos)\n    return string(path, 0, pos);\n  else\n    return string(\".\");\n}\n\nstring basename(const string& path) {\n  string::size_type pos = path.rfind('/');\n  if (pos != string::npos)\n    return string(path, pos + 1);\n  else\n    return path;\n}\n\nvoid strip(string* str, const char* chars) {\n  str->erase(str->find_last_not_of(chars) + 1);\n  str->erase(0, str->find_first_not_of(chars));\n}\n\nstring strip_copy(string str, const char* chars) {\n  strip(&str, chars);\n  return str;\n}\n\nstring string_format(const char* format, ...) {\n  va_list args;\n  va_start(args, format);\n  va_list args_next;\n  va_copy(args_next, args);\n\n  int size = vsnprintf(nullptr, 0, format, args);\n  std::vector<char> buf(static_cast<size_t>(size) + 1);\n  va_end(args);\n\n  vsnprintf(buf.data(), buf.size(), format, args_next);\n  va_end(args_next);\n\n  return string(buf.begin(), buf.end() - 1);\n}\n\nvector<string>\nwrap_string(const string& to_wrap, size_t width, size_t indent_size) {\n  size_t curr_pos = 0;\n  size_t wrap_pos = 0;\n  size_t prev_pos = 0;\n  string work{to_wrap};\n  vector<string> res{};\n  auto indent = string(indent_size, ' ');\n  auto real_width = width - indent_size;\n\n  size_t str_size = work.size();\n  if (str_size < real_width) {\n    res.push_back(indent + work);\n  } else {\n    work.erase(std::remove(work.begin(), work.end(), '\\r'), work.end());\n    std::replace(work.begin(), work.end(), '\\t', ' '), work.end();\n    str_size = work.size();\n\n    do {\n      curr_pos = prev_pos + real_width;\n\n      // respect forcing newline\n      wrap_pos = work.find(\"\\n\", prev_pos);\n      if (wrap_pos == string::npos || wrap_pos > curr_pos) {\n        // No new line found till real_width\n        wrap_pos = work.find_last_of(\" \", curr_pos);\n      }\n      if (wrap_pos != string::npos) {\n        assert(wrap_pos - prev_pos != string::npos);\n        res.push_back(indent + work.substr(prev_pos, wrap_pos - prev_pos));\n        prev_pos = wrap_pos + 1;  // + 1 to skip space\n      } else {\n        break;\n      }\n    } while (str_size - prev_pos > real_width ||\n             work.find(\"\\n\", prev_pos) != string::npos);\n    res.push_back(indent + work.substr(prev_pos));\n  }\n\n  return res;\n}\n\n#ifndef _WIN32\nstd::string get_message_error(int errcode) {\n  return std::string(strerror(errcode));\n}\n#endif\n\n}\n\n}\n"
  },
  {
    "path": "src/harness/src/utilities.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQL_HARNESS_UTILITIES_INCLUDED\n#define MYSQL_HARNESS_UTILITIES_INCLUDED\n\n#include <memory>\n#include <ostream>\n#include <string>\n#include <vector>\n\n#include \"harness_export.h\"\n#include \"router_config.h\"\n\nnamespace mysql_harness {\n\nnamespace utility {\n\n/**\n * Class to turn C array into range.\n *\n * @see make_range\n */\n\ntemplate <class Type>\nclass Range {\n public:\n  class iterator {\n   public:\n    explicit iterator(Type* ptr) : ptr_(ptr)  {}\n\n    iterator& operator++() {\n      ++ptr_;\n      return *this;\n    }\n\n    bool operator==(const iterator& rhs) {\n      return ptr_ == rhs.ptr_;\n    }\n\n    bool operator!=(const iterator& rhs) {\n      return ptr_ != rhs.ptr_;\n    }\n\n    Type& operator*() {\n      return *ptr_;\n    }\n\n    const Type& operator*() const {\n      return *ptr_;\n    }\n\n   private:\n    Type *ptr_;\n  };\n\n  Range(Type* ptr, size_t length) : start_(ptr), finish_(ptr + length) {}\n\n  iterator begin() {\n    return iterator(start_);\n  }\n\n  iterator end() {\n    return iterator(finish_);\n  }\n\n private:\n  Type* start_;\n  Type* finish_;\n};\n\n\n/**\n * Create a range from a plain C array.\n *\n * This function create a range from a plain array so that arrays can\n * be used in range-based loops.\n *\n * @see Range\n */\n\ntemplate <class Type>\nRange<Type> make_range(Type* ptr, size_t length) {\n  return Range<Type>(ptr, length);\n}\n\n\n/**\n * Class for creating a reverse range from another range.\n */\n\ntemplate <typename Range>\nclass RangeReverse {\n public:\n  explicit RangeReverse(Range& range) : range_(range) {}\n\n  typename Range::reverse_iterator begin() {\n    return range_.rbegin();\n  }\n\n  typename Range::const_reverse_iterator begin() const {\n    return range_.rbegin();\n  }\n\n  typename Range::reverse_iterator end() {\n    return range_.rend();\n  }\n\n  typename Range::const_reverse_iterator end() const {\n    return range_.rend();\n  }\n\n private:\n  Range& range_;\n};\n\n\n/**\n * Iterate over a range in reverse.\n *\n * Function take a range, which can be any sequence container, and\n * return a reverse range that iterate the sequence in reverse.\n *\n * Typical use-case is:\n * @code\n * for (auto item : reverse_iterate(my_list)) {\n *   ...\n * }\n * @endcode\n */\ntemplate <typename Range>\nRangeReverse<Range> reverse(Range& x) {  // NOLINT(runtime/references)\n  return RangeReverse<Range>(x);\n}\n\ntemplate <class Map>\nstd::pair<typename Map::iterator, typename Map::iterator>\nfind_range_first(Map& assoc,  // NOLINT(runtime/references)\n                 const typename Map::key_type::first_type& first,\n                 typename Map::iterator start) {\n  typename Map::iterator finish = start;\n  while (finish != assoc.end() && finish->first.first == first)\n    ++finish;\n  return make_pair(start, finish);\n}\n\ntemplate <class Map>\nstd::pair<typename Map::iterator, typename Map::iterator>\nfind_range_first(Map& assoc,  // NOLINT(runtime/references)\n                 const typename Map::key_type::first_type& first) {\n  typedef typename Map::key_type::second_type SType;\n  return find_range_first(assoc, first,\n                          assoc.lower_bound(make_pair(first, SType())));\n}\n\n\ntemplate <class Map>\nstd::pair<typename Map::const_iterator, typename Map::const_iterator>\nfind_range_first(const Map& assoc,\n                 const typename Map::key_type::first_type& first,\n                 typename Map::const_iterator start) {\n  typename Map::const_iterator finish = start;\n  while (finish != assoc.end() && finish->first.first == first)\n    ++finish;\n  return make_pair(start, finish);\n}\n\ntemplate <class Map>\nstd::pair<typename Map::const_iterator, typename Map::const_iterator>\nfind_range_first(const Map& assoc,\n                 const typename Map::key_type::first_type& first) {\n  typedef typename Map::key_type::second_type SType;\n  return find_range_first(assoc, first,\n                          assoc.lower_bound(make_pair(first, SType())));\n}\n\n\nstd::string dirname(const std::string& path);\nstd::string basename(const std::string& path);\n\n/**\n * Remove starting and trailing delimiters from string.\n */\nvoid strip(std::string* str, const char* chars = \" \\t\\n\\r\\f\\v\");\nHARNESS_EXPORT\nstd::string strip_copy(std::string str, const char* chars = \" \\t\\n\\r\\f\\v\");\nstd::string string_format(const char* format, ...)\n#ifdef HAVE_ATTRIBUTE_FORMAT\n  __attribute__((format(printf, 1, 2)))\n#endif\n  ;\n\nstd::vector<std::string> wrap_string(const std::string& to_wrap,\n                                     size_t width, size_t indent_size);\nbool matches_glob(const std::string& word, const std::string& pattern);\nstd::string get_message_error(int errcode);\n\n/*\n * Checks wheter given string matches the pattern using extended posix regex.\n*/\nbool regex_pattern_matches(const std::string &s, const std::string &pattern);\n\n}  // namespace utility\n\n} // namespace mysql_harness\n#endif /* MYSQL_HARNESS_UTILITIES_INCLUDED */\n"
  },
  {
    "path": "src/harness/tests/CMakeLists.txt",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nenable_testing()\n\ninclude_directories(${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} include)\n\ninclude(HarnessTesting)\n\nif(NOT CMAKE_CFG_INTDIR STREQUAL \".\")\n  foreach(config ${CMAKE_CONFIGURATION_TYPES})\n    execute_process(\n      COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${config}/var\n      COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${config}/var/log\n      COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${config}/var/log/harness\n    )\n  endforeach()\nelse()\n  execute_process(\n    COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/var\n    COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/var/log\n    COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/var/log/harness\n  )\nendif()\n\nadd_subdirectory(plugins)\n\nSET(TEST_MODULE harness)\n\nSET(TESTS\n  test_loader.cc\n  test_loader_lifecycle.cc\n  test_logging.cc\n  test_designator.cc\n  test_iterator.cc\n  test_utilities.cc\n  test_common.cc\n  test_config.cc\n  test_filesystem.cc\n  test_hostname_validator.cc\n  test_ip_address.cc\n  test_bug22104451.cc\n  test_resolver.cc\n  test_random_generator.cc\n  test_mysql_router_thread.cc\n)\n\nforeach(TEST ${TESTS})\n  add_test_file(${TEST} MODULE ${TEST_MODULE}\n    INCLUDE_DIRS ${MySQLRouter_SOURCE_DIR}/src/harness/shared/include/\n    LIB_DEPENDS test-helpers)\nendforeach()\n\nSET(TESTS\n  test_keyring.cc\n  test_keyring_manager.cc\n)\n\nforeach(TEST ${TESTS})\n  add_test_file(${TEST} MODULE ${TEST_MODULE}\n    INCLUDE_DIRS ${MySQLRouter_SOURCE_DIR}/src/harness/shared/include/\n    LIB_DEPENDS test-helpers;${SSL_LIBRARIES})\nendforeach()\n\nset(OUT_DIR ${PROJECT_BINARY_DIR}/tests/${TEST_MODULE}/)\n\n# Use configuration file templates to generate configuration files\nfile(GLOB_RECURSE _templates RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} \"*.cfg.in\")\nif(NOT CMAKE_CFG_INTDIR STREQUAL \".\")\n  set(ORIG_HARNESS_PLUGIN_OUTPUT_DIRECTORY ${HARNESS_PLUGIN_OUTPUT_DIRECTORY})\n\n  foreach(config ${CMAKE_CONFIGURATION_TYPES})\n    foreach(_template ${_templates})\n      string(REGEX REPLACE \".in$\" \"\" _output ${config}/${_template})\n      message(STATUS \"Generating ${_output} in ${OUT_DIR} from ${_template}\")\n      string(TOUPPER ${config} config_)\n      set(HARNESS_PLUGIN_OUTPUT_DIRECTORY ${HARNESS_PLUGIN_OUTPUT_DIRECTORY_${config_}})\n      configure_file(${_template} ${OUT_DIR}/${_output})\n    endforeach()\n\n    # Copy plain configuration files\n    file(GLOB_RECURSE _files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} \"*.cfg\")\n    foreach(_file ${_files})\n      configure_file(${_file} ${OUT_DIR}/${config}/${_file} COPYONLY)\n    endforeach()\n  endforeach()\n  set(HARNESS_PLUGIN_OUTPUT_DIRECTORY ${OLD_HARNESS_PLUGIN_OUTPUT_DIRECTORY})\nelse()\n  foreach(_template ${_templates})\n    string(REGEX REPLACE \".in$\" \"\" _output ${_template})\n    message(STATUS \"Generating ${_output} from ${_template}\")\n    configure_file(${_template} ${OUT_DIR}/${_output})\n  endforeach()\n\n  # Copy plain configuration files\n  file(GLOB_RECURSE _files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} \"*.cfg\")\n  foreach(_file ${_files})\n    configure_file(${_file} ${OUT_DIR}/${_file} COPYONLY)\n  endforeach()\nendif()\n"
  },
  {
    "path": "src/harness/tests/data/logger.cfg",
    "content": "# Example configuration file for router\n\n[DEFAULT]\nlogging_folder = var/log\nconfig_folder = etc\nplugin_folder = var/lib\nruntime_folder = var/run\ndata_folder = var/lib\n\n[example]\nlibrary = example\n\n[magic]\nlibrary = magic\nmessage = Some kind of\n"
  },
  {
    "path": "src/harness/tests/data/logger.d/default.cfg",
    "content": "[DEFAULT]\nlogging_folder = var/log\nconfig_folder = etc\nplugin_folder = var/lib\nruntime_folder = var/run\n"
  },
  {
    "path": "src/harness/tests/data/logger.d/magic.cfg",
    "content": "[magic]\nlibrary = magic\nmessage = Some kind of\n"
  },
  {
    "path": "src/harness/tests/data/logger.d/one.cfg",
    "content": "[example]\nlibrary = example\n\n"
  },
  {
    "path": "src/harness/tests/data/magic-alt.cfg",
    "content": "# This file only contain a magic section that have a message that is\n# different from all others. It is used to test the overwrite\n# functionality.\n[magic]\nmessage = Another message\n"
  },
  {
    "path": "src/harness/tests/data/tests-bad-1.cfg",
    "content": "[DEFAULT]\nlogging_folder = {prefix}/var/log/{program}\nplugin_folder = {prefix}/var/lib/{program}\nruntime_folder = {prefix}/var/run/{program}\nconfig_folder = {prefix}/var/run/{program}\ndata_folder = {prefix}/var/lib/{program}\n\n# Two instance of the same plugin should throw an error, even if\n# everything else is OK.\n[example]\nlibrary = example\n\n[example]\nlibrary = example\n"
  },
  {
    "path": "src/harness/tests/data/tests-bad-2.cfg",
    "content": "[DEFAULT]\nlogging_folder = {prefix}/var/log/{program}\nplugin_folder = {prefix}/var/lib/{program}\nruntime_folder = {prefix}/var/run/{program}\nconfig_folder = {prefix}/var/run/{program}\ndata_folder = {prefix}/var/lib/{program}\n\n# Two instance of the same plugin and same key should throw an error,\n# even if everything else is OK.\n[example:one]\nlibrary = example\n\n[example:one]\nlibrary = example\n"
  },
  {
    "path": "src/harness/tests/data/tests-bad-3.cfg",
    "content": "[DEFAULT]\nlogging_folder = {prefix}/var/log/{program}\nplugin_folder = {prefix}/var/lib/{program}\nruntime_folder = {prefix}/var/run/{program}\nconfig_folder = {prefix}/var/run/{program}\ndata_folder = {prefix}/var/lib/{program}\n\n# Two instance of the same plugin with different libraries should\n# throw an error.\n[example:one]\nlibrary = example\n\n[example:two]\nlibrary = magic\n"
  },
  {
    "path": "src/harness/tests/data/tests-good-1.cfg.in",
    "content": "[DEFAULT]\nlogging_folder = {prefix}/var/log/{program}\nplugin_folder = @HARNESS_PLUGIN_OUTPUT_DIRECTORY@\nruntime_folder = {prefix}/var/run/{program}\nconfig_folder = {prefix}/var/run/{program}\ndata_folder = {prefix}/var/lib/{program}\n\n[magic]\nlibrary = magic\nmessage = It is some kind of magic\n\n# Two instance of the same plugin with different keys and values for\n# the message option. Note that the library option have to be the same\n# for the loader to work.\n\n[example:one]\nlibrary = example\n\n[example:two]\nlibrary = example\n\n[bad_one]\nlibrary = bad_one\n\n[bad_two]\nlibrary = bad_two\n"
  },
  {
    "path": "src/harness/tests/data/tests-good-2.cfg.in",
    "content": "[DEFAULT]\nlogging_folder = {prefix}/var/log/{program}\nplugin_folder = @HARNESS_PLUGIN_OUTPUT_DIRECTORY@\nruntime_folder = {prefix}/var/run/{program}\nconfig_folder = {prefix}/var/run/{program}\ndata_folder = {prefix}/var/lib/{program}\n\n[magic]\nmessage = It is some kind of magic\n\n# Two instance of the same plugin with different keys and values for\n# the message option. Note that the library option have to be the same\n# for the loader to work.\n\n[example:one]\n# No library necessary, default to the section name, that is \"example\"\n\n[example:two]\n# No library necessary, default to the section name, that is \"example\"\n\n[bad_one]\nlibrary = bad_one\n\n[bad_two]\nlibrary = bad_two\n"
  },
  {
    "path": "src/harness/tests/data/tests-start-1.cfg.in",
    "content": "[DEFAULT]\nlogging_folder = {prefix}/var/log/{program}\nplugin_folder = @HARNESS_PLUGIN_OUTPUT_DIRECTORY@\nruntime_folder = {prefix}/var/run/{program}\nconfig_folder = {prefix}/var/run/{program}\ndata_folder = {prefix}/var/lib/{program}\n\n[magic]\nlibrary = magic\nmessage = It is some kind of magic\nsuki = bad\n"
  },
  {
    "path": "src/harness/tests/include/lifecycle.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef LIFECYCLE_INCLUDED\n#define LIFECYCLE_INCLUDED\n\n#include <mutex>\n#include <condition_variable>\n\nnamespace mysql_harness { namespace test {\n\nstruct LifecyclePluginSyncBus {\n  std::condition_variable cv;\n  std::mutex mtx;\n  std::string msg;\n};\n\n// 3 elements are for: instance1/all, instance2 and instance3\nusing LifecyclePluginSyncBusSet = LifecyclePluginSyncBus[3];\n\nstruct LifecyclePluginITC {\n  LifecyclePluginSyncBus* (*get_bus_from_key)(const char*);\n};\n\n}} // namespace mysql_harness { namespace test {\n\n\n#endif /* LIFECYCLE_INCLUDED */\n"
  },
  {
    "path": "src/harness/tests/include/magic.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MAGIC_INCLUDED\n#define MAGIC_INCLUDED\n\n#include <stdexcept>\n\nclass bad_suki : public std::runtime_error {\n public:\n  explicit bad_suki(const std::string& msg) : std::runtime_error(msg) {}\n};\n\n#endif /* MAGIC_INCLUDED */\n"
  },
  {
    "path": "src/harness/tests/plugins/CMakeLists.txt",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nadd_harness_plugin(bad_one NO_INSTALL\n  DESTINATION_SUFFIX harness\n  SOURCES bad_one.cc)\nadd_harness_plugin(bad_two NO_INSTALL\n  DESTINATION_SUFFIX harness\n  SOURCES bad_two.cc)\nadd_harness_plugin(magic NO_INSTALL\n  DESTINATION_SUFFIX harness\n  INTERFACE include\n  SOURCES magic.cc)\nadd_harness_plugin(harness_example NO_INSTALL\n  DESTINATION_SUFFIX harness\n  SOURCES example.cc\n  REQUIRES magic\n  OUTPUT_NAME example)\nadd_harness_plugin(lifecycle NO_INSTALL\n  DESTINATION_SUFFIX harness\n  INTERFACE include\n  SOURCES lifecycle.cc\n)\nadd_harness_plugin(lifecycle2 NO_INSTALL\n  DESTINATION_SUFFIX harness\n  INTERFACE include\n  SOURCES lifecycle2.cc)\nadd_harness_plugin(lifecycle3 NO_INSTALL\n  DESTINATION_SUFFIX harness\n  INTERFACE include\n  SOURCES lifecycle3.cc)\n"
  },
  {
    "path": "src/harness/tests/plugins/bad_one.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql/harness/plugin.h\"\n\nusing mysql_harness::PluginFuncEnv;\nusing mysql_harness::Plugin;\nusing mysql_harness::PLUGIN_ABI_VERSION;\nusing mysql_harness::ARCHITECTURE_DESCRIPTOR;\n\nstatic const char* requires[] = {\n  // This plugin do not exist\n  \"foobar\",\n};\n\nstatic void init(PluginFuncEnv*) {\n}\n\nstatic void deinit(PluginFuncEnv*) {\n}\n\n#if defined(_MSC_VER) && defined(bad_one_EXPORTS)\n/* We are building this library */\n#  define EXAMPLE_API __declspec(dllexport)\n#else\n#  define EXAMPLE_API\n#endif\n\nextern \"C\" {\n  Plugin EXAMPLE_API harness_plugin_bad_one = {\n    PLUGIN_ABI_VERSION,\n    ARCHITECTURE_DESCRIPTOR,\n    \"A bad plugin\",\n    VERSION_NUMBER(1, 0, 0),\n    sizeof(requires)/sizeof(*requires),\n    requires,\n    0,\n    nullptr,\n    init,\n    deinit,\n    nullptr,  // start\n    nullptr,  // stop\n  };\n}\n"
  },
  {
    "path": "src/harness/tests/plugins/bad_two.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql/harness/plugin.h\"\n\nusing mysql_harness::PluginFuncEnv;\nusing mysql_harness::Plugin;\nusing mysql_harness::PLUGIN_ABI_VERSION;\nusing mysql_harness::ARCHITECTURE_DESCRIPTOR;\n\nstatic const char* requires[] = {\n  // Magic plugin is version 1.2.3, so version does not match and this\n  // should fail to load.\n  \"magic (>>1.2.3)\",\n};\n\nstatic void init(PluginFuncEnv*) {\n}\n\nstatic void deinit(PluginFuncEnv*) {\n}\n\n#if defined(_MSC_VER) && defined(bad_two_EXPORTS)\n/* We are building this library */\n#  define EXAMPLE_API __declspec(dllexport)\n#else\n#  define EXAMPLE_API\n#endif\n\nextern \"C\" {\n  Plugin EXAMPLE_API harness_plugin_bad_two = {\n    PLUGIN_ABI_VERSION,\n    ARCHITECTURE_DESCRIPTOR,\n    \"A bad plugin\",\n    VERSION_NUMBER(1, 0, 0),\n    sizeof(requires)/sizeof(*requires),\n    requires,\n    0,\n    nullptr,\n    init,\n    deinit,\n    nullptr,  // start\n    nullptr,  // stop\n  };\n}\n"
  },
  {
    "path": "src/harness/tests/plugins/example.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysql/harness/plugin.h\"\n\n#include <iostream>\n#include <cstdlib>\n\n#ifndef _WIN32\n#  include <unistd.h>\n#else\n#  include <windows.h>\n#endif\n\nusing mysql_harness::ARCHITECTURE_DESCRIPTOR;\nusing mysql_harness::ConfigSection;\nusing mysql_harness::PluginFuncEnv;\nusing mysql_harness::PLUGIN_ABI_VERSION;\nusing mysql_harness::Plugin;\nusing mysql_harness::logging::log_info;\n\n#ifdef _WIN32\n#  define EXAMPLE_IMPORT __declspec(dllimport)\n#else\n#  define EXAMPLE_IMPORT\n#endif\n\nextern \"C\" {\n  extern void EXAMPLE_IMPORT do_magic();\n}\n\n\n#if defined(_MSC_VER) && defined(harness_example_EXPORTS)\n/* We are building this library */\n#  define EXAMPLE_API __declspec(dllexport)\n#else\n#  define EXAMPLE_API\n#endif\n\nstatic const char* requires[] = {\n  \"magic (>>1.0)\",\n};\n\nstatic void init(PluginFuncEnv*);\nstatic void deinit(PluginFuncEnv*);\nstatic void start(PluginFuncEnv*);\n\nextern \"C\" {\n  Plugin EXAMPLE_API harness_plugin_example = {\n    PLUGIN_ABI_VERSION,\n    ARCHITECTURE_DESCRIPTOR,\n    \"An example plugin\",\n    VERSION_NUMBER(1, 0, 0),\n    sizeof(requires) / sizeof(*requires),\n    requires,\n    0,\n    nullptr,  // conflicts\n    init,     // init\n    deinit,   // deinit\n    start,    // start\n    nullptr,  // stop\n  };\n\n}\n\nstatic void init(PluginFuncEnv*) {\n  do_magic();\n}\n\nstatic void deinit(PluginFuncEnv*) {\n}\n\nstatic void start(PluginFuncEnv*) {\n  for (int x = 0 ; x < 10 ; ++x) {\n    log_info(\"example <count: %d>\", x);\n#ifndef _WIN32\n    sleep(1);\n#else\n    Sleep(1000);\n#endif\n  }\n}\n\n"
  },
  {
    "path": "src/harness/tests/plugins/lifecycle.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// This test plugin is used to test Harness' handling of plugin lifecycle.\n// The plugin exposes all 4 lifecycle functions (init, start, stop and deinit),\n// and what they do (how they exit, i.e. whether they throw, exit, block, etc)\n// depends on the plugin configuration. For details, see comments in\n// init_exit_strategies().\n//\n////////////////////////////////////////////////////////////////////////////////\n\n#include \"config_parser.h\"\n#include \"harness_assert.h\"\n#include \"router_config.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"lifecycle.h\"\n#include \"mysql/harness/plugin.h\"\n\n#include <chrono>\n#include <condition_variable>\n#include <cstdlib>\n#include <mutex>\n#include <stdarg.h> // some things not in std:: in cstdarg (Ubuntu 14.04)\n#include <thread>\n\nIMPORT_LOG_FUNCTIONS()\n\nnamespace mysql_harness {\n  class PluginFuncEnv;\n}\n\nusing mysql_harness::ARCHITECTURE_DESCRIPTOR;\nusing mysql_harness::AppInfo;\nusing mysql_harness::ConfigSection;\nusing mysql_harness::PluginFuncEnv;\nusing mysql_harness::PLUGIN_ABI_VERSION;\nusing mysql_harness::Plugin;\nusing mysql_harness::kRuntimeError;\n\nconst int kExitCheckInterval = 1;\nconst int kPersistDuration   = 100;\n\n////////////////////////////////////////////////////////////////////////////////\n// ITC STUFF (InterThread Communication)\n////////////////////////////////////////////////////////////////////////////////\n\nnamespace {\n\n  // these are made visible to unit test via passing back &g_lifecycle_plugin_ITC\n  // during a special init() call\n  static mysql_harness::test::LifecyclePluginSyncBus* get_bus_from_key(const char* key);\n  static mysql_harness::test::LifecyclePluginSyncBusSet g_lifecycle_plugin_logs;\n  static mysql_harness::test::LifecyclePluginITC g_lifecycle_plugin_ITC {\n    &get_bus_from_key,\n  };\n\n  static mysql_harness::test::LifecyclePluginSyncBus* get_bus_from_key(const char* key) {\n    std::string k(key); // easier than typing strcmp() everywhere\n\n    if (k == \"instance1\" || k == \"all\")\n      return &g_lifecycle_plugin_logs[0];\n    else if (k == \"instance2\")\n      return &g_lifecycle_plugin_logs[1];\n    else if (k == \"instance3\")\n      return &g_lifecycle_plugin_logs[2];\n\n    // unsupported instance name\n    harness_assert_this_should_not_execute();\n  }\n\n  static void log_info(bool notify, const std::string& key, const char* format, ...)\n#ifdef HAVE_ATTRIBUTE_FORMAT\n    __attribute__((format(printf, 3, 4)))\n#endif\n    ;\n\n  static void log_info(bool notify, const std::string& key, const char* format, ...) {\n    char buf[1024];\n    va_list args;\n    va_start(args, format);\n    vsnprintf(buf, sizeof(buf), format, args);\n    va_end(args);\n\n    // call the real log_info()\n    ::log_info(\"%s\", buf);\n\n    // and also post notification on ITC bus, if requested\n    if (notify) {\n      mysql_harness::test::LifecyclePluginSyncBus& bus = *get_bus_from_key(key.c_str());\n      bus.mtx.lock();\n      bus.msg = buf;\n      bus.mtx.unlock();\n      bus.cv.notify_one();\n    }\n  }\n\n} // namespace {\n\n////////////////////////////////////////////////////////////////////////////////\n// PLUGIN IMPLEMENTATION\n////////////////////////////////////////////////////////////////////////////////\n\n// proxy useful for debugging, keep it disabled unless developing this code\n#if 0\n  #include <stdarg.h> // some things not in std:: in cstdarg (Ubuntu 14.04)\n  #include <iostream>\n\n  static void LOG_INFO(const char* format, ...) {\n    char buf[1024];\n    va_list args;\n    va_start(args, format);\n    vsnprintf(buf, sizeof(buf), format, args);\n    va_end(args);\n    std::cerr << \"===>\" << buf << std::endl;\n    log_info(\"%s\", buf);\n  }\n  #define log_info LOG_INFO\n#endif\n\nnamespace {\n\n  // we start with 123 so that we're likely to detect a bug if the enum is not set\n  // (uninitialized memory often contains 0)\n  enum ExitType { ET_EXIT = 123, ET_EXIT_SLOW, ET_EXIT_ON_STOP, ET_EXIT_ON_STOP_SYNC,\n                  ET_THROW, ET_THROW_WEIRD, ET_ERROR, ET_ERROR_EMPTY, };\n\n  struct ExitStrategy {\n    std::map<std::string, ExitType> exit_type;\n    bool                            strategy_set;\n  };\n\n  std::map<std::string, ExitStrategy> g_strategies;\n  std::mutex                          g_strategies_mtx;\n\n  // called at the earliest opportunity, needs to run only once\n  // (since last reset)\n  void init_exit_strategies(const ConfigSection* section) {\n\n    std::lock_guard<std::mutex> lock(g_strategies_mtx);\n\n    // running more than once doesn't change anything, just wastes cycles\n    // and obfuscates purpose of this code\n    if (g_strategies[section->key].strategy_set) {\n      return;\n    } else {\n      g_strategies[section->key].strategy_set = true;\n    }\n\n    // Each function's behavior (exit strategy) is defined inside the\n    // configuration file, one line per function. General definition form:\n    //\n    //   (init|start|stop|deinit) = <option>\n    //\n    // where <option> is one of:\n    //   exit         - exit right away\n    //   exit_slow    - exit after a significant delay\n    //   exitonstop   - exit after stop(), async polling (valid for start() only)\n    //   exitonstop_s - exit after stop(), blocking      (valid for start() only)\n    //   throw        - throw a typical exception (derived from std::exception)\n    //   throw_weird  - throw an unusual exception (not derived from std::exception)\n    //   error        - exit with error (like 'exit', but call set_error() before exiting)\n    //   error_empty  - like above, but set_error(..., NULL)\n    //\n    // Example configuration section:\n    //\n    //   [lifecycle]\n    //   init   = exit        # init() will exit\n    //   start  = exitonstop  # start() will exit after it gets notified to do so\n    //   stop   = throw       # stop() will throw\n    //   deinit = exit_slow   # deinit() will never exit\n\n    // process configuration\n    for (const std::string& func : {\"init\", \"start\", \"stop\", \"deinit\"}) {\n      if (section->has(func)) {\n        const std::string& line = section->get(func);\n\n        // assign exit strategy\n        if (line.find(\"exit_slow\") != std::string::npos) {\n          g_strategies[section->key].exit_type[func] = ET_EXIT_SLOW;\n        }\n        else if (line.find(\"throw_weird\") != std::string::npos) {\n          g_strategies[section->key].exit_type[func] = ET_THROW_WEIRD;\n        }\n        else if (line.find(\"throw\") != std::string::npos) {\n          g_strategies[section->key].exit_type[func] = ET_THROW;\n        }\n        else if (line.find(\"error_empty\") != std::string::npos) {\n          g_strategies[section->key].exit_type[func] = ET_ERROR_EMPTY;\n        }\n        else if (line.find(\"error\") != std::string::npos) {\n          g_strategies[section->key].exit_type[func] = ET_ERROR;\n        }\n        else if (line.find(\"exitonstop_s\") != std::string::npos\n             && func == \"start\") {\n          g_strategies[section->key].exit_type[func] = ET_EXIT_ON_STOP_SYNC;\n        }\n        else if (line.find(\"exitonstop\") != std::string::npos\n             && func == \"start\") {\n          g_strategies[section->key].exit_type[func] = ET_EXIT_ON_STOP;\n        }\n        else if (line.find(\"exit\") != std::string::npos) {\n          g_strategies[section->key].exit_type[func] = ET_EXIT;\n        }\n        else {\n          // invalid exit strategy (your unit test is messed up)\n          harness_assert_this_should_not_execute();\n        }\n      }\n    }\n  }\n\n  void execute_exit_strategy(const std::string& func, PluginFuncEnv* env) {\n\n    // init() and deinit() are called only once per plugin (not per plugin\n    // instance), but we need an instance name for our logic to work, therefore\n    // we pick the first plugin instance in such case\n    const std::string& key = (func == \"init\" || func == \"deinit\")\n        ? get_app_info(env)->config->get(\"lifecycle\").front()->key\n        : get_config_section(env)->key;\n\n    std::unique_lock<std::mutex> lock(g_strategies_mtx);\n\n    // init() and deinit() are called only once per plugin, so \"all\" is less\n    // confusing for those functions\n    const char* key_for_log = (func == \"init\" || func == \"deinit\")\n                              ? \"all\" : key.c_str();\n\n    // in case of start() function (which runs in a separate thread), in\n    // addition to logging, we also want to post a notification on ITC bus\n    bool notify = (func == \"start\");\n\n    switch (g_strategies[key].exit_type[func]) {\n      case ET_EXIT:\n        log_info(notify, key_for_log, \"  lifecycle:%s %s():EXIT.\", key_for_log, func.c_str());\n        return;     // added . here ^ so EXIT* don't match str search\n\n      case ET_THROW:   // added . here v so THROW_WEIRD don't match str search\n        log_info(notify, key_for_log, \"  lifecycle:%s %s():THROW.\", key_for_log, func.c_str());\n        throw std::runtime_error(std::string(\"lifecycle:\") + key_for_log + \" \"\n                                 + func + \"(): I'm throwing!\");\n      case ET_THROW_WEIRD:\n        log_info(notify, key_for_log, \"  lifecycle:%s %s():THROW_WEIRD\", key_for_log, func.c_str());\n        throw int(42);  // throw something that's not a std::exception\n\n      case ET_ERROR:\n        log_info(notify, key_for_log, \"  lifecycle:%s %s():ERROR\", key_for_log, func.c_str());\n        set_error(env, kRuntimeError, \"lifecycle:%s %s(): I'm returning error!\",\n            key_for_log, func.c_str());\n        return;\n\n      case ET_ERROR_EMPTY:\n        log_info(notify, key_for_log, \"  lifecycle:%s %s():ERROR_EMPTY\", key_for_log, func.c_str());\n        set_error(env, kRuntimeError, nullptr);\n        return;\n\n      case ET_EXIT_SLOW:\n        log_info(notify, key_for_log, \"  lifecycle:%s %s():EXIT_SLOW:sleeping\", key_for_log, func.c_str());\n        if (wait_for_stop(env, kPersistDuration))\n          log_info(notify, key_for_log, \"  lifecycle:%s %s():EXIT_SLOW:done, stop request received\", key_for_log, func.c_str());\n        else\n          log_info(notify, key_for_log, \"  lifecycle:%s %s():EXIT_SLOW:done, timed out\", key_for_log, func.c_str());\n        return;\n\n      case ET_EXIT_ON_STOP:\n        log_info(notify, key_for_log, \"  lifecycle:%s %s():EXIT_ON_STOP:sleeping\",\n                 key_for_log, func.c_str());\n        harness_assert(func == \"start\");\n        lock.unlock();  // we don't need it anymore\n        while(is_running(env)) {\n          std::this_thread::sleep_for(\n              std::chrono::milliseconds(kExitCheckInterval));\n        }\n        log_info(notify, key_for_log, \"  lifecycle:%s %s():EXIT_ON_STOP:done\",\n                 key_for_log, func.c_str());\n        return;\n\n      case ET_EXIT_ON_STOP_SYNC:\n        log_info(notify, key_for_log, \"  lifecycle:%s %s():EXIT_ON_STOP_SYNC:sleeping\",\n                 key_for_log, func.c_str());\n        harness_assert(func == \"start\");\n        lock.unlock();  // we don't need it anymore\n        wait_for_stop(env, 0);\n        log_info(notify, key_for_log, \"  lifecycle:%s %s():EXIT_ON_STOP_SYNC:done\",\n                 key_for_log, func.c_str());\n        return;\n    }\n  }\n\n} // unnamed namespace\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n// PLUGIN API\n////////////////////////////////////////////////////////////////////////////////\n\n  #if defined(_MSC_VER) && defined(lifecycle_EXPORTS)\n  /* We are building this library */\n  #  define LIFECYCLE_API __declspec(dllexport)\n  #else\n  #  define LIFECYCLE_API\n  #endif\n\n  static const char* requires[] = {\n    \"magic (>>1.0)\",\n    \"lifecycle3\",\n  };\n\n  static void init(PluginFuncEnv* env) {\n\n    // for explanation of pointer tagging, see https://en.wikipedia.org/wiki/Pointer_tagging\n    // PluginFuncEnv* ending with bit0 == 1 is special - it's a hack to perform\n    // pre-initialization:\n    // - tell the plugin to pre-initialize (unit test level init, not the normal plugin init())\n    // - return the necessary ITC info back to unit test\n    uintptr_t ptr = reinterpret_cast<uintptr_t>(env);\n    if (ptr & 0x01) {\n\n      // initialize the plugin\n      {\n        std::lock_guard<std::mutex> lock(g_strategies_mtx);\n        g_strategies.clear();\n\n        for (const std::string& key : {\"instance1\", \"instance2\", \"instance3\"}) {\n          g_strategies[key].strategy_set = false; // optimisation,\n        }                                         // doesn't affect behavior\n      }\n\n      // pass ITC struct ptr back to unit test\n      {\n        // env is really LifecyclePluginITC**\n        using mysql_harness::test::LifecyclePluginITC;\n        ptr--;  // untag the ptr\n        LifecyclePluginITC** ppitc = reinterpret_cast<LifecyclePluginITC**>(ptr);\n        *ppitc = &g_lifecycle_plugin_ITC;\n      }\n\n      // return, since this is not a real init() call\n      return;\n    }\n\n    const AppInfo* info = get_app_info(env);\n\n    // init() and deinit() are called only once per plugin (not per plugin\n    // instance), but we need an instance name for our logic to work, therefore\n    // we pick the first plugin instance in such case\n    const ConfigSection* section = info->config->get(\"lifecycle\").front();\n\n    // only 3 predefined instances are supported\n    harness_assert(section->key == \"instance1\"\n                || section->key == \"instance2\"\n                || section->key == \"instance3\");\n\n    log_info(false, section->key, \"%s\", \"lifecycle:all init():begin\");\n\n    init_exit_strategies(section);\n    execute_exit_strategy(\"init\", env);\n  }\n\n  static void start(PluginFuncEnv* env) {\n    const ConfigSection* section = get_config_section(env);\n\n    log_info(true, section->key, \"lifecycle:%s start():begin\", section->key.c_str());\n\n    init_exit_strategies(section);\n    execute_exit_strategy(\"start\", env);\n  }\n\n  static void stop(PluginFuncEnv* env) {\n    const ConfigSection* section = get_config_section(env);\n\n    log_info(false, section->key, \"lifecycle:%s stop():begin\", section->key.c_str());\n\n    init_exit_strategies(section);\n    execute_exit_strategy(\"stop\", env);\n  }\n\n  static void deinit(PluginFuncEnv* env) {\n    const AppInfo* info = get_app_info(env);\n\n    // init() and deinit() are called only once per plugin (not per plugin\n    // instance), but we need an instance name for our logic to work, therefore\n    // we pick the first plugin instance in such case\n    const ConfigSection* section = info->config->get(\"lifecycle\").front();\n\n    // only 3 predefined instances are supported\n    harness_assert(section->key == \"instance1\"\n                || section->key == \"instance2\"\n                || section->key == \"instance3\");\n\n    log_info(false, section->key, \"%s\", \"lifecycle:all deinit():begin\");\n\n    init_exit_strategies(section);\n    execute_exit_strategy(\"deinit\", env);\n  }\n\n  extern \"C\" {\n    Plugin LIFECYCLE_API harness_plugin_lifecycle = {\n      PLUGIN_ABI_VERSION,\n      ARCHITECTURE_DESCRIPTOR,\n      \"Lifecycle test plugin\",\n      VERSION_NUMBER(1,0,0),\n      sizeof(requires)/sizeof(*requires),\n      requires,\n      0,        // \\_ conflicts\n      nullptr,  // /\n      init,     // init\n      deinit,   // deinit\n      start,    // start\n      stop,     // stop\n    };\n  }\n\n"
  },
  {
    "path": "src/harness/tests/plugins/lifecycle2.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// This test plugin is used to test Harness' handling of plugin lifecycle.\n// The plugin exposes all 4 lifecycle functions (init, start, stop and deinit),\n// which do nothing except log that they ran. start() persists until stop() makes\n// it exit.\n//\n// The notable feature of this plugin is its (artificial) depenency on another\n// test plugin, \"lifecycle\".  This is useful in testing correctness of plugin\n// initialisation and deinitialisation.\n//\n////////////////////////////////////////////////////////////////////////////////\n\n#include \"mysql/harness/plugin.h\"\nnamespace mysql_harness {\n  class PluginFuncEnv;\n}\n\n#include <thread>\n\nusing mysql_harness::ARCHITECTURE_DESCRIPTOR;\nusing mysql_harness::AppInfo;\nusing mysql_harness::PluginFuncEnv;\nusing mysql_harness::PLUGIN_ABI_VERSION;\nusing mysql_harness::Plugin;\n\n// debug printer, keep it disabled unless developing this code\n#if 0\n  #include <iostream>\n  void trace(const char* message) {\n    std::cerr << \"===>\" << message << std::endl;\n  }\n#else\n  void trace(const char*, ...) {}\n#endif\n\n#if defined(_MSC_VER) && defined(lifecycle2_EXPORTS)\n/* We are building this library */\n#  define LIFECYCLE2_API __declspec(dllexport)\n#else\n#  define LIFECYCLE2_API\n#endif\n\n// (artificial) dependency on \"lifecycle\" plugin (lifecycle.cc):\n// At CMake level we don't specify this requirement, because truly, this plugin\n// doesn't depend on lifecycle. However, to ensure that it is always initialized\n// after lifecycle in unit tests, we set this dependency here to enforce this.\nstatic const char* requires[] = {\n  \"lifecycle\",\n};\n\nstatic void init(PluginFuncEnv* env) {\n  const AppInfo* info = get_app_info(env);\n\n  // nullptr is special - it's a hack to tell the plugin to reset state\n  if (info != nullptr) {\n    trace(\"lifecycle2 init()\");\n  }\n}\n\nstatic void start(PluginFuncEnv* env) {\n  trace(\"lifecycle2 start():sleeping\");\n\n  while(is_running(env)) {\n    std::this_thread::sleep_for(std::chrono::milliseconds(1));\n  }\n\n  trace(\"lifecycle2 start():done\");\n}\n\nstatic void stop(PluginFuncEnv*) {\n  trace(\"lifecycle2 stop()\");\n}\n\nstatic void deinit(PluginFuncEnv*) {\n  trace(\"lifecycle2 deinit()\");\n}\n\nextern \"C\" {\n  Plugin LIFECYCLE2_API harness_plugin_lifecycle2 = {\n    PLUGIN_ABI_VERSION,\n    ARCHITECTURE_DESCRIPTOR,\n    \"Lifecycle2 test plugin\",\n    VERSION_NUMBER(1,0,0),\n    sizeof(requires)/sizeof(*requires),\n    requires,\n    0,        // \\_ conflicts\n    nullptr,  // /\n    init,     // init\n    deinit,   // deinit\n    start,    // start\n    stop,     // stop\n  };\n}\n\n"
  },
  {
    "path": "src/harness/tests/plugins/lifecycle3.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// This test plugin is used to test Harness' handling of plugin lifecycle.\n// The plugin exposes 2 lifecycle functions (init, deinit), which do nothing.\n//\n// This plugin is an (artificial) dependency of another test plugin, \"lifecycle\" -\n// it is useful in testing correctness of plugin initialisation and deinitialisation.\n//\n////////////////////////////////////////////////////////////////////////////////\n\n#include \"mysql/harness/plugin.h\"\n\nnamespace mysql_harness {\n  class PluginFuncEnv;\n}\n\nusing mysql_harness::ARCHITECTURE_DESCRIPTOR;\nusing mysql_harness::PluginFuncEnv;\nusing mysql_harness::PLUGIN_ABI_VERSION;\nusing mysql_harness::Plugin;\n\n\n#if defined(_MSC_VER) && defined(lifecycle3_EXPORTS)\n/* We are building this library */\n#  define LIFECYCLE3_API __declspec(dllexport)\n#else\n#  define LIFECYCLE3_API\n#endif\n\nstatic void init(PluginFuncEnv*) {}\nstatic void deinit(PluginFuncEnv*) {}\n\nextern \"C\" {\n  Plugin LIFECYCLE3_API harness_plugin_lifecycle3 = {\n    PLUGIN_ABI_VERSION,\n    ARCHITECTURE_DESCRIPTOR,\n    \"Logging functions\",\n    VERSION_NUMBER(0, 0, 1),\n    0, nullptr,  // Requires\n    0, nullptr,  // Conflicts\n    init,\n    deinit,\n    nullptr,     // start\n    nullptr,     // stop\n  };\n}\n"
  },
  {
    "path": "src/harness/tests/plugins/magic.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"magic.h\"\n\n#include \"mysql/harness/config_parser.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysql/harness/plugin.h\"\n\n#include <cstdlib>\n#include <iostream>\n\nusing mysql_harness::ARCHITECTURE_DESCRIPTOR;\nusing mysql_harness::AppInfo;\nusing mysql_harness::ConfigSection;\nusing mysql_harness::PluginFuncEnv;\nusing mysql_harness::PLUGIN_ABI_VERSION;\nusing mysql_harness::Plugin;\nusing mysql_harness::bad_option;\nusing mysql_harness::logging::log_info;\n\n#if defined(_MSC_VER) && defined(magic_EXPORTS)\n/* We are building this library */\n#  define MAGIC_API __declspec(dllexport)\n#else\n#  define MAGIC_API\n#endif\n\nconst AppInfo* g_info;\nconst ConfigSection* g_section;\n\nstatic void init(PluginFuncEnv* env) {\n  g_info = get_app_info(env);\n}\n\nextern \"C\" void MAGIC_API do_magic() {\n  auto&& section = g_info->config->get(\"magic\", \"\");\n  auto&& message = section.get(\"message\");\n  log_info(\"%s\", message.c_str());\n}\n\nstatic void start(PluginFuncEnv* env) {\n  const ConfigSection* section = get_config_section(env);\n  try {\n    if (section->has(\"suki\") && section->get(\"suki\") == \"bad\") {\n      set_error(env, mysql_harness::kRuntimeError, \"The suki was bad, please throw away\");\n    }\n  } catch (bad_option&) {}\n\n  if (section->has(\"do_magic\"))\n    do_magic();\n}\n\nextern \"C\" {\n  Plugin MAGIC_API harness_plugin_magic = {\n    PLUGIN_ABI_VERSION,\n    ARCHITECTURE_DESCRIPTOR,\n    \"A magic plugin\",\n    VERSION_NUMBER(1, 2, 3),\n    0,\n    nullptr,\n    0,\n    nullptr,\n    init,\n    nullptr,  // deinit\n    start,    // start\n    nullptr,  // stop\n  };\n}\n"
  },
  {
    "path": "src/harness/tests/test_bug22104451.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/**\n * BUG22104451 Router hangs when config value length > 256 characters\n *\n */\n\n#include \"mysql/harness/config_parser.h\"\n\n////////////////////////////////////////\n// Third-party include files\n#include \"gtest/gtest.h\"\n\nusing mysql_harness::Config;\n\nclass Bug22104451 : public ::testing::Test {\n  virtual void SetUp() {}\n  virtual void TearDown() {}\n};\n\nTEST_F(Bug22104451, ReadLongValues) {\n  std::stringstream c;\n  std:: string long_destinations = \"localhost:13005,localhost:13003,\"\n    \"localhost:13004,localhost:17001,localhost:17001,localhost:17001,\"\n    \"localhost:17001,localhost:17001,localhost:17001,localhost:17001,\"\n    \"localhost:17001,localhost:17001,localhost:17001,localhost:17001,\"\n    \"localhost:17001,localhost:17001,localhost:17001,localhost:17001,\"\n    \"localhost:17001,localhost:17001\";\n\n  c << \"[routing:c]\\n\"\n    << \"bind_address = 127.0.0.1:7006\\n\"\n    << \"destinations = \" << long_destinations << \"\\n\"\n    << \"mode = read-only\\n\";\n\n  EXPECT_NO_THROW({\n    Config config(Config::allow_keys);\n    std::istringstream input(c.str());\n    config.read(input);\n    EXPECT_EQ(long_destinations,\n              config.get(\"routing\", \"c\").get(\"destinations\"));\n  });\n}\n"
  },
  {
    "path": "src/harness/tests/test_common.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"gtest/gtest.h\"\n#include \"gmock/gmock.h\"\n#include <thread>\n\n#include \"common.h\"\n\n\nusing ::testing::StrEq;\n\nTEST(TestCommon, truncate_string) {\n  // This test tests truncate_string() and truncate_string_r(). Since both\n  // utilize the same backend, common functionality tests are ran only on\n  // truncate_string().\n\n  using mysql_harness::truncate_string;\n  using mysql_harness::truncate_string_r;\n\n  constexpr size_t kMinMaxLen = 6;  // max_len less than this triggers assertion\n\n  // simple case\n  {\n    const std::string s = \"1234567890\";\n    size_t len = s.size();\n    EXPECT_TRUE(truncate_string(s, len+1) == s);\n    EXPECT_TRUE(truncate_string(s, len+0) == s);\n    EXPECT_THAT(truncate_string(s, len-1), StrEq(\"123456...\"));\n  }\n\n  // max_len too short\n  // This test doesn't work in Windows or FreeBSD, because of how ASSERT_DEATH works\n  // It also fails on release version\n  #if !defined(_WIN32) && !defined(__FreeBSD__) && !defined(NDEBUG)\n  {\n    ASSERT_DEATH(truncate_string(\"123456\", kMinMaxLen-1), \"\");\n  }\n  #endif\n\n  // string len = kMinMaxLen\n  {\n    const std::string s = \"123456\";\n    size_t len = s.size();\n    EXPECT_TRUE(truncate_string(s, len+1) == s);\n    EXPECT_TRUE(truncate_string(s, len+0) == s);\n    // testing with len-1 would trigger assertion, as shown in the previous test\n  }\n\n  // short string\n  {\n    const std::string s = \"1\";\n    EXPECT_TRUE(truncate_string(s, kMinMaxLen) == s);\n  }\n\n  // empty string\n  {\n    const std::string s = \"\";\n    EXPECT_TRUE(truncate_string(s, kMinMaxLen) == s);\n  }\n\n  // thread-safety test\n  {\n    const std::string& r1 = truncate_string(\"1234567890\", 8);\n\n    std::thread([](){\n      const std::string& r2 = truncate_string(\"abcdefghij\", 8);\n      EXPECT_THAT(r2, StrEq(\"abcde...\"));\n    }).join();\n\n    // call to truncate_string() in another thread should not overwrite this result\n    EXPECT_THAT(r1, StrEq(\"12345...\"));\n\n    // but calling it in this thread will (this funcionality is not a requirement, the test only demonstrates the weakness)\n    truncate_string(\"blablabla\", 8);\n    EXPECT_THAT(r1, StrEq(\"blabl...\"));\n  }\n\n  // re-entry test (using truncate_string_r() instead of truncate_string())\n  {\n    const std::string& r1 = truncate_string_r(\"1234567890\", 8);\n\n    std::thread([](){\n      const std::string& r2 = truncate_string_r(\"abcdefghij\", 8);\n      EXPECT_THAT(r2, StrEq(\"abcde...\"));\n    }).join();\n\n    // call to truncate_string_r() in another thread should not overwrite this result\n    EXPECT_THAT(r1, StrEq(\"12345...\"));\n\n    // call to truncate_string_r() in this thread should not overwrite this result\n    truncate_string_r(\"blablabla\", 8);\n    EXPECT_THAT(r1, StrEq(\"12345...\"));\n  }\n}\n\nTEST(TestCommon, SerialComma) {\n  using mysql_harness::serial_comma;\n\n  auto expect_output = [](int count, const std::string& expect) {\n    constexpr int primes[]{2, 3, 5, 7, 11};\n\n    std::string res = \"Primes are \";\n    res += serial_comma(&primes[0], &primes[count]);\n    EXPECT_EQ(res, \"Primes are \" + expect);\n  };\n\n  expect_output(1, \"2\");\n  expect_output(2, \"2 and 3\");\n  expect_output(3, \"2, 3, and 5\");\n  expect_output(5, \"2, 3, 5, 7, and 11\");\n}\n"
  },
  {
    "path": "src/harness/tests/test_config.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql/harness/config_parser.h\"\n#include \"mysql/harness/filesystem.h\"\n#include \"mysql/harness/plugin.h\"\n\n////////////////////////////////////////\n// Test system include files\n#include \"test/helpers.h\"\n\n////////////////////////////////////////\n// Third-party include files\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n////////////////////////////////////////\n// Standard include files\n#include <iostream>\n#include <sstream>\n#include <stdexcept>\n#include <string>\n\nusing mysql_harness::Config;\nusing mysql_harness::ConfigSection;\nusing mysql_harness::Path;\nusing mysql_harness::bad_option;\nusing mysql_harness::bad_section;\nusing mysql_harness::syntax_error;\n\nusing testing::ElementsAreArray;\nusing testing::Eq;\nusing testing::IsEmpty;\nusing testing::SizeIs;\nusing testing::TestWithParam;\nusing testing::UnorderedElementsAreArray;\nusing testing::ValuesIn;\n\nnamespace mysql_harness {\n\nbool operator==(const Config& lhs, const Config& rhs) {\n  // We just check the section names to start with\n  auto&& lhs_names = lhs.section_names();\n  auto&& rhs_names = rhs.section_names();\n\n  // Check if the sizes differ. This is not an optimization since\n  // std::equal does not work properly on ranges of unequal size.\n  if (lhs_names.size() != rhs_names.size())\n    return false;\n\n  // Put the lists in vectors and sort them\n  std::vector<std::pair<std::string, std::string>>\n    lhs_vec(lhs_names.begin(), lhs_names.end());\n  std::sort(lhs_vec.begin(), lhs_vec.end());\n\n  std::vector<std::pair<std::string, std::string>>\n    rhs_vec(rhs_names.begin(), rhs_names.end());\n  std::sort(rhs_vec.begin(), rhs_vec.end());\n\n  // Compare the elements of the sorted vectors\n  return std::equal(lhs_vec.begin(), lhs_vec.end(), rhs_vec.begin());\n}\n\n}\n\nstd::list<std::string>\nsection_names(const mysql_harness::Config::ConstSectionList& sections) {\n  std::list<std::string> result;\n  for (auto& section : sections)\n    result.push_back(section->name);\n  std::cerr << result << std::endl;\n  return result;\n}\n\n\nvoid PrintTo(const Config& config, std::ostream& out) {\n  for (auto&& val : config.section_names())\n    out << val.first << \":\" << val.second << \" \";\n}\n\nclass ConfigTest : public ::testing::Test {\n protected:\n  virtual void SetUp() {\n    std::vector<std::string> words;\n    words.push_back(\"reserved\");\n    config.set_reserved(words);\n  }\n\n  Config config;\n};\n\nPath g_here;\n\nTEST_F(ConfigTest, TestEmpty) {\n  EXPECT_TRUE(config.is_reserved(\"reserved\"));\n  EXPECT_FALSE(config.is_reserved(\"legal\"));\n\n  // A newly created configuration is always empty.\n  EXPECT_TRUE(config.empty());\n\n  // Test that fetching a non-existing section throws an exception.\n  EXPECT_THROW(config.get(\"magic\"), std::runtime_error);\n\n  EXPECT_FALSE(config.has(\"magic\"));\n}\n\nTEST_F(ConfigTest, SetGetTest) {\n  // Add the section\n  config.add(\"magic\");\n\n  // Test that fetching a section get the right section back.\n  EXPECT_TRUE(config.has(\"magic\"));\n\n  Config::SectionList sections = config.get(\"magic\");\n  EXPECT_EQ(1U, sections.size());\n\n  ConfigSection* section = sections.front();\n  EXPECT_EQ(\"magic\", section->name);\n\n  // Test that fetching a non-existing option in a section throws a\n  // run-time exception.\n  EXPECT_THROW(section->get(\"my_option\"), std::runtime_error);\n\n  // Set the value of the option in the section\n  section->set(\"my_option\", \"my_value\");\n\n  // Check that the value can be retrieved.\n  EXPECT_EQ(\"my_value\", section->get(\"my_option\"));\n\n  config.clear();\n  EXPECT_TRUE(config.empty());\n}\n\nTEST_F(ConfigTest, RemoveTest) {\n\n  constexpr const char* section_name = \"my_section_name\";\n  constexpr const char* section_key = \"my_section_key\";\n\n  // config without section key\n  {\n    Config conf;\n\n    // add a section with some key/value pair\n    conf.add(section_name);\n    conf.get(section_name).front()->set(\"my_option\", \"my_value\");\n    EXPECT_STREQ(\"my_value\", conf.get(section_name).front()->get(\"my_option\").c_str());\n\n    // removing non-existent section should be a no-op, but return false\n    EXPECT_FALSE(conf.remove(\"no_such_section\", \"no_such_key\"));\n    EXPECT_FALSE(conf.remove(\"no_such_section\", \"\"));\n    EXPECT_FALSE(conf.remove(\"no_such_section\"));\n    EXPECT_FALSE(conf.remove(section_name, \"no_such_key\"));\n\n    // removing existing section should return true\n    EXPECT_TRUE(conf.remove(section_name));\n    EXPECT_FALSE(conf.remove(section_name)); // no-op again\n\n    // other tests proving the section got removed\n    EXPECT_TRUE(conf.empty());\n  }\n\n  // config with section key\n  {\n    Config conf(mysql_harness::Config::allow_keys);\n\n    // add a section with some key/value pair\n    conf.add(section_name, section_key);\n    conf.get(section_name, section_key).set(\"my_option\", \"my_value\");\n    EXPECT_STREQ(\"my_value\", conf.get(section_name, section_key).get(\"my_option\").c_str());\n\n    // removing non-existent section should be a no-op, but return false\n    EXPECT_FALSE(conf.remove(\"no_such_section\", section_key));\n    EXPECT_FALSE(conf.remove(\"no_such_section\", \"no_such_key\"));\n    EXPECT_FALSE(conf.remove(\"no_such_section\", \"\"));\n    EXPECT_FALSE(conf.remove(\"no_such_section\"));\n    EXPECT_FALSE(conf.remove(section_name, \"no_such_key\"));\n    EXPECT_FALSE(conf.remove(section_name, \"\"));\n    EXPECT_FALSE(conf.remove(section_name));\n\n    // removing existing section should return true\n    EXPECT_TRUE(conf.remove(section_name, section_key));\n    EXPECT_FALSE(conf.remove(section_name, section_key)); // no-op again\n\n    // other tests proving the section got removed\n    EXPECT_TRUE(conf.empty());\n  }\n}\n\nTEST_F(ConfigTest, IsEmptyStringWhenOptionNotInSection) {\n  config.add(\"section_name\");\n  Config::SectionList sections = config.get(\"section_name\");\n  ConfigSection* section = sections.front();\n  ASSERT_THAT(section->get_section_name(\"option_name\"), testing::Eq(\"\"));\n  config.clear();\n  EXPECT_TRUE(config.empty());\n}\n\nTEST_F(ConfigTest, IsCurrentSectionWhenOptionInCurrentSection) {\n  config.add(\"section_name\");\n  Config::SectionList sections = config.get(\"section_name\");\n  ConfigSection* section = sections.front();\n  section->set(\"option_name\", \"value\");\n  ASSERT_THAT(section->get_section_name(\"option_name\"), testing::Eq(\"section_name\"));\n  config.clear();\n  EXPECT_TRUE(config.empty());\n}\n\nTEST_F(ConfigTest, IsDefaultWhenOptionInDefault) {\n  std::stringstream c;\n  c << \"[DEFAULT]\\ndefault_option=0\\n[section_name_1]\\noption_1=value_1\\noption_2=value_2\\noption_3=value_3\\n\";\n  config.read(c);\n  Config::SectionList sections = config.get(\"section_name_1\");\n  ConfigSection* section = sections.front();\n  ASSERT_THAT(section->get_section_name(\"default_option\"), testing::Eq(\"default\"));\n  config.clear();\n  EXPECT_TRUE(config.empty());\n}\n\nclass GoodParseTestAllowKey : public ::testing::TestWithParam<const char*> {\n protected:\n  virtual void SetUp() {\n    config = new Config(Config::allow_keys);\n\n    std::vector<std::string> words;\n    words.push_back(\"reserved\");\n    config->set_reserved(words);\n\n    std::istringstream input(GetParam());\n    config->read(input);\n  }\n\n  virtual void TearDown() {\n    delete config;\n    config = nullptr;\n  }\n\n  Config *config;\n};\n\nTEST_P(GoodParseTestAllowKey, SectionOne) {\n  // Checking that getting a non-existent section throws exception\n  EXPECT_THROW(config->get(\"nonexistant-section\"), bad_section);\n\n  Config::SectionList sections = config->get(\"one\");\n  EXPECT_EQ(1U, sections.size());\n\n  ConfigSection* section = sections.front();\n  EXPECT_EQ(\"one\", section->name);\n  EXPECT_EQ(\"bar\", section->get(\"foo\"));\n\n  // Checking that getting a non-existient option in an existing\n  // section throws exception.\n  EXPECT_THROW(section->get(\"nonexistant-option\"), bad_option);\n}\n\nconst char *good_examples[] = {\n  (\"[one]\\n\" \"foo = bar\\n\"),\n  (\"[one]\\n\" \"foo: bar\\n\"),\n  (\" [one]   \\n\" \"  foo: bar   \\n\"),\n  (\" [one]\\n\" \"  foo   :bar   \\n\"),\n  (\"# Hello\\n\"\n   \" [one]\\n\" \"  foo   :bar   \\n\"),\n  (\"# Hello\\n\"\n   \"# World!\\n\"\n   \" [one]\\n\" \"  foo   :bar   \\n\"),\n  (\"; Hello\\n\"\n   \" [one]\\n\" \"  foo   :bar   \\n\"),\n  (\"[DEFAULT]\\n\" \"foo = bar\\n\"\n   \"[one]\\n\"),\n  (\"[DEFAULT]\\n\" \"other = ar\\n\"\n   \"[one]\\n\" \"foo = b{other}\\n\"),\n  (\"[DEFAULT]\\n\" \"one = b\\n\" \"two = r\\n\"\n   \"[one]\\n\" \"foo = {one}a{two}\\n\"),\n  (\"[DEFAULT]\\n\" \"one = b\\n\" \"two = r\\n\"\n   \"[one:my_key]\\n\" \"foo = {one}a{two}\\n\")\n};\n\nINSTANTIATE_TEST_CASE_P(TestParsing, GoodParseTestAllowKey,\n                        ::testing::ValuesIn(good_examples));\n\n// Test fixture to compare option value with the result of\n// interpolating the value.\nusing Sample = std::pair<std::string, std::string>;\nclass TestInterpolate : public TestWithParam<Sample> {\n protected:\n  virtual void SetUp() {\n    config_ = new Config(Config::allow_keys);\n    config_->add(\"testing\", \"a_key\");\n    config_->set_default(\"datadir\", \"--path--\");\n  }\n\n  virtual void TearDown() {\n    delete config_;\n    config_ = nullptr;\n  }\n\n  Config *config_;\n};\n\nTEST_P(TestInterpolate, CheckExpected) {\n  auto value = std::get<0>(GetParam());\n  auto expect = std::get<1>(GetParam());\n\n  auto&& section = config_->get(\"testing\", \"a_key\");\n  section.set(\"option_name\", value);\n  EXPECT_THAT(section.get(\"option_name\"), Eq(expect));\n}\n\nSample interpolate_examples[] = {\n  {\"foo\",                       \"foo\"},\n  {\"c:\\\\foo\\\\bar\\\\{datadir}\",   \"c:\\\\foo\\\\bar\\\\--path--\"},\n  {\"c:\\\\foo\\\\bar\\\\{undefined}\", \"c:\\\\foo\\\\bar\\\\{undefined}\"},\n  {\"{datadir}\\\\foo\",            \"--path--\\\\foo\"},\n  {\"{datadir}\",                 \"--path--\"},\n  {\"foo{datadir}bar\",           \"foo--path--bar\"},\n  {\"{{datadir}}\",               \"{--path--}\"},\n  {\"{datadir}}\",                \"--path--}\"},\n  {\"{{datadir}\",                \"{--path--\"},\n  {\"{{{datadir}}}\",             \"{{--path--}}\"},\n  {\"{datadir\",                  \"{datadir\"},\n  {\"c:\\\\foo\\\\bar\\\\{425432-5425432-5423534253-542342}\",\n   \"c:\\\\foo\\\\bar\\\\{425432-5425432-5423534253-542342}\"},\n};\n\nINSTANTIATE_TEST_CASE_P(TestParsing, TestInterpolate,\n                        ValuesIn(interpolate_examples));\n\nTEST(TestConfig, RecursiveInterpolate) {\n  const char *const config_text{\n    \"[DEFAULT]\\n\"\n    \"basedir = /root/dir\\n\"\n    \"datadir = {basedir}/data\\n\"\n\n    \"[one]\\n\"\n    \"log = {datadir}/router.log\\n\"\n    \"rec = {other}\\n\"  // Recursive reference\n    \"other = {rec}\\n\"\n  };\n\n  Config config(Config::allow_keys);\n  std::istringstream input(config_text);\n  config.read(input);\n\n  auto&& section = config.get(\"one\", \"\");\n  EXPECT_THAT(section.get(\"log\"), Eq(\"/root/dir/data/router.log\"));\n  EXPECT_THROW(section.get(\"rec\"), syntax_error);\n}\n\nclass BadParseTestForbidKey : public ::testing::TestWithParam<const char*> {\n protected:\n  virtual void SetUp() {\n    config = new Config;\n\n    std::vector<std::string> words;\n    words.push_back(\"reserved\");\n    config->set_reserved(words);\n  }\n\n  virtual void TearDown() {\n    delete config;\n    config = nullptr;\n  }\n\n  Config *config;\n};\n\nTEST_P(BadParseTestForbidKey, SyntaxError) {\n  std::istringstream input{GetParam()};\n  EXPECT_ANY_THROW(config->read(input));\n}\n\nstatic const char* syntax_problems[] = {\n  // Unterminated section header line\n  (\"[one\\n\" \"foo = bar\\n\"),\n\n  // Malformed start of a section\n  (\"one]\\n\" \"foo: bar\\n\"),\n\n  // Bad section name\n  (\"[one]\\n\" \"foo = bar\\n\"\n   \"[reserved]\\n\" \"foo = baz\\n\"),\n\n  // Options before first section\n  (\"  foo: bar   \\n\" \"[one]\\n\"),\n\n  // Unterminated last line\n  (\"[one]\\n\" \"foo = bar\"),\n\n  // Repeated option\n  (\"[one]\\n\" \"foo = bar\\n\" \"foo = baz\\n\"),\n  (\"[one]\\n\" \"foo = bar\\n\" \"Foo = baz\\n\"),\n\n  // Space in option\n  (\"[one]\\n\" \"foo bar = bar\\n\" \"bar = baz\\n\"),\n\n  // Repeated section\n  (\"[one]\\n\" \"foo = bar\\n\" \"[one]\\n\" \"foo = baz\\n\"),\n  (\"[one]\\n\" \"foo = bar\\n\" \"[ONE]\\n\" \"foo = baz\\n\"),\n\n  // Key but keys not allowed\n  (\"[one:my_key]\\n\" \"foo = bar\\n\" \"[two]\\n\" \"foo = baz\\n\"),\n};\n\nINSTANTIATE_TEST_CASE_P(TestParsingSyntaxError, BadParseTestForbidKey,\n                        ::testing::ValuesIn(syntax_problems));\n\nclass BadParseTestAllowKeys : public ::testing::TestWithParam<const char*> {\n protected:\n  virtual void SetUp() {\n    config = new Config(Config::allow_keys);\n\n    std::vector<std::string> words;\n    words.push_back(\"reserved\");\n    config->set_reserved(words);\n  }\n\n  virtual void TearDown() {\n    delete config;\n    config = nullptr;\n  }\n\n  Config *config;\n};\n\nTEST_P(BadParseTestAllowKeys, SemanticError) {\n  std::istringstream input{GetParam()};\n  EXPECT_THROW(config->read(input), syntax_error);\n}\n\nstatic const char* semantic_problems[] = {\n  // Empty key\n  (\"[one:]\\n\" \"foo = bar\\n\" \"[two]\\n\" \"foo = baz\\n\"),\n\n  // Key on default section\n  (\"[DEFAULT:key]\\n\" \"one = b\\n\" \"two = r\\n\"\n   \"[one:key1]\\n\" \"foo = {one}a{two}\\n\"\n   \"[one:key2]\\n\" \"foo = {one}a{two}\\n\"),\n};\n\nINSTANTIATE_TEST_CASE_P(TestParseErrorAllowKeys, BadParseTestAllowKeys,\n                        ::testing::ValuesIn(semantic_problems));\n\nTEST(TestConfig, ConfigUpdate) {\n  const char *const configs[]{\n    (\"[one]\\n\"\n     \"one = first\\n\"\n     \"two = second\\n\"),\n    (\"[one]\\n\"\n     \"one = new first\\n\"\n     \"[two]\\n\"\n     \"one = first\\n\"),\n  };\n\n  Config config(Config::allow_keys);\n  std::istringstream input(configs[0]);\n  config.read(input);\n\n  Config other(Config::allow_keys);\n  std::istringstream other_input(configs[1]);\n  other.read(other_input);\n\n  Config expected(Config::allow_keys);\n  config.update(other);\n\n  ConfigSection& one = config.get(\"one\", \"\");\n  ConfigSection& two = config.get(\"two\", \"\");\n  EXPECT_EQ(\"new first\", one.get(\"one\"));\n  EXPECT_EQ(\"second\", one.get(\"two\"));\n  EXPECT_EQ(\"first\", two.get(\"one\"));\n\n  // Non-existent options should still throw an exception\n  auto&& section = config.get(\"one\", \"\");\n  EXPECT_THROW(section.get(\"nonexistant-option\"), bad_option);\n\n  // Check that merging sections with mismatching names generates an\n  // exception\n  EXPECT_THROW(one.update(two), bad_section);\n}\n\nTEST(TestConfig, ConfigReadBasic) {\n  // Here are three different sources of configurations that should\n  // all be identical. One is a single file, one is a directory, and\n  // one is a stream.\n\n  Config dir_config = Config(Config::allow_keys);\n  dir_config.read(g_here.join(\"data/logger.d\"), \"*.cfg\");\n\n  Config file_config = Config(Config::allow_keys);\n  file_config.read(g_here.join(\"data/logger.cfg\"));\n\n  const char *const config_string =\n    (\"[DEFAULT]\\n\"\n     \"logging_folder = var/log\\n\"\n     \"config_folder = etc\\n\"\n     \"plugin_folder = var/lib\\n\"\n     \"runtime_folder = var/run\\n\"\n     \"[example]\\n\"\n     \"library = example\\n\"\n     \"[magic]\\n\"\n     \"library = magic\\n\"\n     \"message = Some kind of\\n\");\n\n  Config stream_config(Config::allow_keys);\n  std::istringstream stream_input(config_string);\n  stream_config.read(stream_input);\n\n  EXPECT_EQ(dir_config, file_config);\n  EXPECT_EQ(dir_config, stream_config);\n  EXPECT_EQ(file_config, stream_config);\n}\n\n// Here we test that reads of configuration entries overwrite previous\n// read entries.\nTEST(TestConfig, ConfigReadOverwrite) {\n  Config config = Config(Config::allow_keys);\n  config.read(g_here.join(\"data/logger.d\"), \"*.cfg\");\n  EXPECT_EQ(\"Some kind of\", config.get(\"magic\", \"\").get(\"message\"));\n\n  // Non-existent options should still throw an exception\n  {\n    auto&& section = config.get(\"magic\", \"\");\n    EXPECT_THROW(section.get(\"not-in-section\"), bad_option);\n  }\n\n  config.read(g_here.join(\"data/magic-alt.cfg\"));\n  EXPECT_EQ(\"Another message\", config.get(\"magic\", \"\").get(\"message\"));\n\n  // Non-existent options should still throw an exception\n  {\n    auto&& section = config.get(\"magic\", \"\");\n    EXPECT_THROW(section.get(\"not-in-section\"), bad_option);\n  }\n}\n\nTEST(TestConfig, SectionRead) {\n  static const char *const config_string =\n    (\"[DEFAULT]\\n\"\n     \"logging_folder = var/log\\n\"\n     \"config_folder = etc\\n\"\n     \"plugin_folder = var/lib\\n\"\n     \"runtime_folder = var/run\\n\"\n     \"[empty]\\n\"\n     \"[example]\\n\"\n     \"library = magic\\n\"\n     \"message = Some kind of\\n\");\n\n  Config config(Config::allow_keys);\n  std::istringstream stream_input(config_string);\n  config.read(stream_input);\n\n  // Test that the sections command return the right sections\n  EXPECT_THAT(section_names(config.sections()),\n              UnorderedElementsAreArray({\"example\", \"empty\"}));\n\n  // Test that options for a section is correct\n  std::set<std::pair<std::string, std::string>> expected_options{\n    {\"library\", \"magic\"},\n    {\"message\", \"Some kind of\"}\n  };\n\n  // ElementsAreArray() segfaults with Sun Studio compiler\n  //  EXPECT_THAT(config.get(\"example\", \"\").get_options(),\n  //              ElementsAreArray(expected_options));\n  auto config_options = config.get(\"example\", \"\").get_options();\n  for (const auto& op: config_options) {\n    EXPECT_EQ(1u, expected_options.count(op));\n  }\n  EXPECT_THAT(config_options, SizeIs(2));\n\n  EXPECT_THAT(config.get(\"empty\", \"\").get_options(),\n              IsEmpty());\n  EXPECT_THAT(config.get(\"empty\", \"\").get_options(),\n              SizeIs(0));\n}\n\nint main(int argc, char *argv[]) {\n  g_here = Path(argv[0]).dirname();\n\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/harness/tests/test_designator.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"designator.h\"\n\n#include \"mysql/harness/plugin.h\"\n#include \"utilities.h\"\n\n////////////////////////////////////////\n// Test system include files\n#include \"test/helpers.h\"\n\n////////////////////////////////////////\n// Third-party include files\n#include \"gtest/gtest.h\"\n\n////////////////////////////////////////\n// Standard include files\n#include <iostream>\n\nusing mysql_harness::utility::make_range;\n\nvoid check_desig(const std::string& input, const std::string& plugin) {\n  Designator desig(input);\n  EXPECT_EQ(plugin, desig.plugin);\n}\n\nvoid check_desig(const std::string& input,\n                 const std::string& plugin, Designator::Relation relation,\n                 long major_version, long minor_version, long patch_version) {\n  Designator desig(input);\n  EXPECT_EQ(plugin, desig.plugin);\n\n  EXPECT_EQ(1, static_cast<int>(desig.constraint.size()));\n  std::pair<Designator::Relation, Version> elem = desig.constraint.front();\n  EXPECT_EQ(relation, elem.first);\n  EXPECT_EQ(major_version, elem.second.ver_major);\n  EXPECT_EQ(minor_version, elem.second.ver_minor);\n  EXPECT_EQ(patch_version, elem.second.ver_patch);\n}\n\n\nvoid check_desig(const std::string& input,\n                 const std::string& plugin,\n                 Designator::Relation relation1,\n                 long major_version1,\n                 long minor_version1,\n                 long patch_version1,\n                 Designator::Relation relation2,\n                 long major_version2,\n                 long minor_version2,\n                 long patch_version2) {\n  Designator desig(input);\n  EXPECT_EQ(plugin, desig.plugin);\n\n  EXPECT_EQ(2, static_cast<int>(desig.constraint.size()));\n  std::pair<Designator::Relation, Version> elem1 = desig.constraint[0];\n  EXPECT_EQ(relation1, elem1.first);\n  EXPECT_EQ(major_version1, elem1.second.ver_major);\n  EXPECT_EQ(minor_version1, elem1.second.ver_minor);\n  EXPECT_EQ(patch_version1, elem1.second.ver_patch);\n\n  std::pair<Designator::Relation, Version> elem2 = desig.constraint[1];\n  EXPECT_EQ(relation2, elem2.first);\n  EXPECT_EQ(major_version2, elem2.second.ver_major);\n  EXPECT_EQ(minor_version2, elem2.second.ver_minor);\n  EXPECT_EQ(patch_version2, elem2.second.ver_patch);\n}\n\nTEST(TestDesignator, TestGoodDesignators) {\n  check_desig(\"foo\", \"foo\");\n  check_desig(\"foo(<<1)\", \"foo\",\n              Designator::LESS_THEN, 1, 0, 0);\n  check_desig(\"foo (<=1.2)  \", \"foo\",\n              Designator::LESS_EQUAL, 1, 2, 0);\n  check_desig(\"foo  (  >>  1.2.3  ) \\t\",\n              \"foo\", Designator::GREATER_THEN, 1, 2, 3);\n  check_desig(\"foo\\t(!=1.2.55)\\t\",\n              \"foo\", Designator::NOT_EQUAL, 1, 2, 55);\n  check_desig(\"foo\\t(==1.4711.001)\\t\",\n              \"foo\", Designator::EQUAL, 1, 4711, 1);\n\n  check_desig(\"foo (<=1.2, >>1.3)  \", \"foo\",\n              Designator::LESS_EQUAL, 1, 2, 0,\n              Designator::GREATER_THEN, 1, 3, 0);\n  check_desig(\"foo (<=1.2 , >>1.3)  \", \"foo\",\n              Designator::LESS_EQUAL, 1, 2, 0,\n              Designator::GREATER_THEN, 1, 3, 0);\n  check_desig(\"foo(<=1.2, >>1.3)\", \"foo\",\n              Designator::LESS_EQUAL, 1, 2, 0,\n              Designator::GREATER_THEN, 1, 3, 0);\n}\n\n\nTEST(TestDesignator, TestBadDesignators) {\n  const char *strings[] = {\n    \"foo(\",\n    \"foo\\t(!1.2.55)\",\n    \"foo\\t(!1.2.55)\",\n    \"foo\\t(=1.2.55)\",\n    \"foo\\t(<1.2.55)\",\n    \"foo\\t(<<1.2.\",\n    \"foo\\t(<<1.2\",\n    \"foo\\t(<<.2.55)\",\n    \"foo\\t(<<1.2.55\",\n    \"foo<<1.2.55\",\n  };\n\n  for (auto input : make_range(strings, sizeof(strings) / sizeof(*strings))) {\n    auto make_designator = [&]() { Designator desig{ input }; };\n    EXPECT_THROW(make_designator(), std::runtime_error);\n  }\n}\n\nTEST(TestDesignator, TestVersion) {\n  EXPECT_EQ(Version(1, 0, 0), Version(1, 0, 0));\n  EXPECT_FALSE(Version(1, 0, 0) < Version(1, 0, 0));\n  EXPECT_LE(Version(1, 0, 0), Version(1, 0, 0));\n  EXPECT_FALSE(Version(1, 0, 0) > Version(1, 0, 0));\n  EXPECT_GE(Version(1, 0, 0), Version(1, 0, 0));\n\n  EXPECT_NE(Version(1, 0, 0), Version(1, 0, 1));\n  EXPECT_LT(Version(1, 0, 0), Version(1, 0, 1));\n  EXPECT_LE(Version(1, 0, 0), Version(1, 0, 1));\n  EXPECT_FALSE(Version(1, 0, 0) > Version(1, 0, 1));\n  EXPECT_FALSE(Version(1, 0, 0) >= Version(1, 0, 1));\n\n  EXPECT_FALSE(Version(1, 0, 0) == Version(1, 1, 0));\n  EXPECT_LT(Version(1, 0, 0), Version(1, 1, 0));\n  EXPECT_LE(Version(1, 0, 0), Version(1, 1, 0));\n  EXPECT_FALSE(Version(1, 0, 0) > Version(1, 1, 0));\n  EXPECT_FALSE(Version(1, 0, 0) >= Version(1, 1, 0));\n\n  EXPECT_FALSE(Version(1, 0, 0) == Version(1, 1, 5));\n  EXPECT_LT(Version(1, 0, 0), Version(1, 1, 5));\n  EXPECT_LE(Version(1, 0, 0), Version(1, 1, 5));\n  EXPECT_FALSE(Version(1, 0, 0) > Version(1, 1, 5));\n  EXPECT_FALSE(Version(1, 0, 0) >= Version(1, 1, 5));\n\n  EXPECT_FALSE(Version(1, 0, 0) == Version(2, 1, 5));\n  EXPECT_LT(Version(1, 0, 0), Version(2, 1, 5));\n  EXPECT_LE(Version(1, 0, 0), Version(2, 1, 5));\n  EXPECT_FALSE(Version(1, 0, 0) > Version(2, 1, 5));\n  EXPECT_FALSE(Version(1, 0, 0) >= Version(2, 1, 5));\n\n  EXPECT_EQ(Version(VERSION_NUMBER(1, 0, 0)), Version(1, 0, 0));\n  EXPECT_EQ(Version(VERSION_NUMBER(1, 1, 0)), Version(1, 1, 0));\n  EXPECT_EQ(Version(VERSION_NUMBER(1, 2, 0)), Version(1, 2, 0));\n  EXPECT_EQ(Version(VERSION_NUMBER(1, 0, 2)), Version(1, 0, 2));\n  EXPECT_EQ(Version(VERSION_NUMBER(1, 2, 3)), Version(1, 2, 3));\n}\n\nTEST(TestDesignator, TestConstraints) {\n  EXPECT_TRUE(Designator(\"foo(<< 1.2)\").version_good(Version(1, 1)));\n  EXPECT_FALSE(Designator(\"foo(<< 1.2)\").version_good(Version(1, 2)));\n  EXPECT_TRUE(Designator(\"foo(<= 1.2)\").version_good(Version(1, 2)));\n  EXPECT_FALSE(Designator(\"foo(<= 1.2)\").version_good(Version(1, 2, 1)));\n  EXPECT_TRUE(Designator(\"foo(>= 1.2)\").version_good(Version(1, 2, 2)));\n  EXPECT_TRUE(Designator(\"foo(>>1.2)\").version_good(Version(1, 2, 2)));\n  EXPECT_FALSE(Designator(\"foo(>= 1.2, !=1.2.2)\")\n               .version_good(Version(1, 2, 2)));\n  EXPECT_FALSE(Designator(\"foo(>> 1.2, !=1.2.2)\")\n               .version_good(Version(1, 2, 2)));\n  EXPECT_TRUE(Designator(\"foo(>> 1.2, !=1.2.2)\")\n              .version_good(Version(1, 2, 3)));\n}\n"
  },
  {
    "path": "src/harness/tests/test_dim_and_unique_ptr.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n////////////////////////////////////////\n// Test system include files\n#include \"dim.h\"\n#include \"test/helpers.h\"\n\n////////////////////////////////////////\n// Standard include files\n#include <memory>\n\n////////////////////////////////////////\n// Third-party include files\n\n// #include GMock, but ignore GMock warnings\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wsign-conversion\"\n#endif\n#include \"gmock/gmock.h\"\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n\n\nusing ::testing::_;\nusing mysql_harness::UniquePtr;\n\nclass Notifier {\n public:\n  MOCK_METHOD1(called_ctor,void(const std::string&));\n  MOCK_METHOD1(called_dtor,void(const std::string&));\n  MOCK_METHOD1(called_deleter,void(const std::string&));\n  MOCK_METHOD1(called_do_something,void(const std::string&));\n};\n\n// GMock objects cannot be global, because EXPECT_CALL()s are evaluated in their\n// destructors. The simplest workaround is to set a ptr to such a local object,\n// and make that globally-accessible to the things that need it.\nNotifier* g_notifier = NULL;\nvoid set_notifier(Notifier& notifier) {\n  g_notifier = &notifier;\n}\n\nclass A {\n public:\n  A() {\n    if (call_notifier_ && g_notifier)\n      g_notifier->called_ctor(\"A\");\n  }\n\n  explicit A(int) : call_notifier_(false) {} // special ctor used by class B, that doesn't call notifier methods\n\n  virtual ~A() {\n    if (call_notifier_ && g_notifier)\n      g_notifier->called_dtor(\"A\");\n  }\n\n  A(const A&)            { should_never_call_this(\"COPY CONSTRUCTOR\"); }\n  A(A&&)                 { should_never_call_this(\"MOVE CONSTRUCTOR\"); }\n  A& operator=(const A&) { should_never_call_this(\"COPY ASSIGNMENT\"); return *this; }\n  A& operator=(A&&)      { should_never_call_this(\"MOVE ASSIGNMENT\"); return *this; }\n  static int& should_never_call_this_ignore_cnt() { return should_never_call_this_ignore_cnt_; }\n\n  virtual void do_something() {}\n\n private:\n  void should_never_call_this(const std::string& origin) {\n    if (should_never_call_this_ignore_cnt_)\n      should_never_call_this_ignore_cnt_--;\n    else\n      FAIL() << origin <<  \" should never be called\";\n  }\n\n  static int should_never_call_this_ignore_cnt_;\n  bool call_notifier_ = true;\n};\n/*static*/ int A::should_never_call_this_ignore_cnt_;\n\n\n\nclass Deleter {\n public:\n  void operator()(A* ptr) {\n    if (g_notifier)\n      g_notifier->called_deleter(\"-\");\n    delete ptr;\n  }\n};\n\nvoid deleter(A* ptr) {\n  Deleter()(ptr);\n}\n\n\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// UniquePtr tests\n//\n// Note: many of the tests found below seem like they don't do much. Keep in mind\n//       that ability to build this test, is also a test! (templates are tricky)\n//\n////////////////////////////////////////////////////////////////////////////////\n\nclass UniquePtrTest : public ::testing::Test {\n protected:\n  void SetUp() override {\n    set_notifier(notifier_);\n  }\n\n  Notifier& get_notifier() {\n    return notifier_;\n  }\n\n private:\n  Notifier notifier_;\n};\n\nTEST_F(UniquePtrTest, test_illegal_operations_warning) {\n  EXPECT_CALL(get_notifier(), called_ctor(\"A\")).Times(1);\n  EXPECT_CALL(get_notifier(), called_dtor(\"A\")).Times(3);\n\n  A::should_never_call_this_ignore_cnt() = 4;\n  A a1;\n  A a2(a1);\n  a2 = a1;\n  A a3(std::move(a2));\n  a2 = std::move(a1);\n  EXPECT_EQ(0, A::should_never_call_this_ignore_cnt());\n}\n\nTEST_F(UniquePtrTest, direct_creation) {\n  EXPECT_CALL(get_notifier(), called_ctor(\"A\")).Times(1);\n  EXPECT_CALL(get_notifier(), called_dtor(\"A\")).Times(1);\n  A a1;\n}\n\nTEST_F(UniquePtrTest, null_pointer) {\n  EXPECT_CALL(get_notifier(), called_ctor(\"A\")).Times(0);\n  EXPECT_CALL(get_notifier(), called_dtor(\"A\")).Times(0);\n  UniquePtr<A> p01;\n  UniquePtr<A> p11(NULL);\n  UniquePtr<A> p12(nullptr);\n  UniquePtr<A> p21(NULL, NULL);\n  UniquePtr<A> p22(nullptr, nullptr);\n  UniquePtr<A> p23(NULL, nullptr);\n  UniquePtr<A> p24(nullptr, NULL);\n}\n\nTEST_F(UniquePtrTest, null_pointer_with_custom_deleter) {\n  EXPECT_CALL(get_notifier(), called_ctor(\"A\")).Times(0);\n  EXPECT_CALL(get_notifier(), called_dtor(\"A\")).Times(0);\n  EXPECT_CALL(get_notifier(), called_deleter(\"-\")).Times(0);\n  UniquePtr<A> p11(nullptr, [](A* a){ delete a; });\n  UniquePtr<A> p12(nullptr, deleter);\n  UniquePtr<A> p13(nullptr, Deleter());\n  UniquePtr<A> p14(nullptr, std::default_delete<A>());\n  UniquePtr<A> p21(NULL, [](A* a){ delete a; });\n  UniquePtr<A> p22(NULL, deleter);\n  UniquePtr<A> p23(NULL, Deleter());\n  UniquePtr<A> p24(NULL, std::default_delete<A>());\n}\n\nTEST_F(UniquePtrTest, deleter) {\n  EXPECT_CALL(get_notifier(), called_ctor(\"A\")).Times(5);\n  EXPECT_CALL(get_notifier(), called_dtor(\"A\")).Times(5);\n  EXPECT_CALL(get_notifier(), called_deleter(\"-\")).Times(2);\n  UniquePtr<A> p10(new A);\n  UniquePtr<A> p11(new A, [](A* a){ delete a; });\n  UniquePtr<A> p12(new A, deleter);\n  UniquePtr<A> p13(new A, Deleter());\n  UniquePtr<A> p14(new A, std::default_delete<A>());\n}\n\nTEST_F(UniquePtrTest, moving_stuff) {\n  EXPECT_CALL(get_notifier(), called_ctor(\"A\")).Times(1);\n  EXPECT_CALL(get_notifier(), called_dtor(\"A\")).Times(1);\n\n  UniquePtr<A> p0(new A);\n  EXPECT_TRUE(!!p0);\n  EXPECT_NE(p0.get(), nullptr);\n\n  UniquePtr<A> p1(std::move(p0));\n  EXPECT_TRUE(!!p1);\n  EXPECT_FALSE(p0);\n\n  UniquePtr<A> p2 = std::move(p1);\n  EXPECT_TRUE(!!p2);\n  EXPECT_FALSE(p1);\n\n  UniquePtr<A> p3;\n  p3 = std::move(p2);\n  EXPECT_TRUE(!!p3);\n  EXPECT_FALSE(p2);\n\n  UniquePtr<A> p4;\n  p4 = std::move(p3);\n  EXPECT_TRUE(!!p4);\n  EXPECT_FALSE(p3);\n\n#ifndef __clang__\n  // Clang genereates -Wself-move warning, because self-move is undefined per C++11 standard.\n  // However, a lot of people feel it should be a no-op. Our UniquePtr adheres to that tighter\n  // specification.\n  p4 = std::move(p4);\n  EXPECT_TRUE(!!p4);\n#endif\n}\n\nTEST_F(UniquePtrTest, shared_ptr_conversion) {\n  EXPECT_CALL(get_notifier(), called_ctor(\"A\")).Times(2);\n  EXPECT_CALL(get_notifier(), called_dtor(\"A\")).Times(2);\n  EXPECT_CALL(get_notifier(), called_deleter(\"-\")).Times(2);\n\n  UniquePtr<A> p0(new A, deleter);\n  std::shared_ptr<A> sp0 = std::move(p0);\n  EXPECT_TRUE(!!sp0);\n  EXPECT_FALSE(p0);\n\n  UniquePtr<A> p1(new A, deleter);\n  std::shared_ptr<A> sp1(std::move(p1));\n  EXPECT_TRUE(!!sp1);\n  EXPECT_FALSE(p1);\n}\n\n// Disabled this test because it behaves differently on different platforms.\n// The culprit is the EXPECT_DEBUG_DEATH(), which does some voodoo magic that\n// isn't very portable.  For example, it can fail on same compiler (VS2015u3)\n// but on different Windows versions (7 vs 10 for example).  Swapping #ifdef\n// blocks can fix this test on one machine, but will make it fail on another.\n// Hopefully one day we can re-enable this test, if EXPECT_DEBUG_DEATH() becomes\n// more portable.\n#if !defined(__FreeBSD__) // EXPECT_DEBUG_DEATH() doesn't build on BSD\nTEST_F(UniquePtrTest, DISABLED_release_assertion) {\n  EXPECT_CALL(get_notifier(), called_ctor(\"A\")).Times(1);\n#ifdef _WIN32\n  EXPECT_CALL(get_notifier(), called_dtor(\"A\")).Times(0);\n  EXPECT_CALL(get_notifier(), called_deleter(\"-\")).Times(0);\n#else\n  EXPECT_CALL(get_notifier(), called_dtor(\"A\")).Times(1);    // \\_ the process would die\n  EXPECT_CALL(get_notifier(), called_deleter(\"-\")).Times(1); // /  in real life\n#endif\n  UniquePtr<A> p1(new A, deleter);\n\n  // switch the death test to thread-safe mode. More info:\n  // https://github.com/google/googletest/blob/master/googletest/docs/AdvancedGuide.md#death-tests-and-threads\n  ::testing::FLAGS_gtest_death_test_style = \"threadsafe\";\n\n  // NOTE: this line triggers plenty of valgrind warnings, disable when testing with valgrind\n#if 1\n  EXPECT_DEBUG_DEATH(p1.release(), \"\");\n#endif\n}\n#endif\n\nTEST_F(UniquePtrTest, release_and_get_deleter) {\n  UniquePtr<A>::deleter_type del;\n  A* raw_ptr;\n  {\n    EXPECT_CALL(get_notifier(), called_ctor(\"A\")).Times(1);\n    raw_ptr = new A;\n  }\n  {\n    EXPECT_CALL(get_notifier(), called_dtor(\"A\")).Times(0);\n    EXPECT_CALL(get_notifier(), called_deleter(\"-\")).Times(0);\n    UniquePtr<A> p1(raw_ptr, deleter);\n    del = p1.get_deleter();\n    p1.release();\n  }\n  {\n    EXPECT_CALL(get_notifier(), called_dtor(\"A\")).Times(1);\n    EXPECT_CALL(get_notifier(), called_deleter(\"-\")).Times(1);\n    del(raw_ptr);\n  }\n}\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// Dependency Injectino Manager (DIM) tests\n//\n////////////////////////////////////////////////////////////////////////////////\n\nclass Foo;\nclass Bar;\nclass Baz;\nclass Ext;\n\nclass TestDIM : public mysql_harness::DIM {\n  // this class is a singleton\n private:\n  TestDIM() {}\n public:\n  TestDIM(const TestDIM&) = delete;\n  TestDIM& operator==(const TestDIM&) = delete;\n  static TestDIM& instance() {\n    static TestDIM manager;\n    return manager;\n  }\n\n public:\n  // factory and deleter setters [step 2]\n  void set_A(const std::function<A*(void)>&             factory, const std::function<void(A*)>& deleter = std::default_delete<A>()) { factory_A_  = factory; deleter_A_ = deleter; }\n  void set_A(const std::function<A*(const char*)>&      factory, const std::function<void(A*)>& deleter = std::default_delete<A>()) { factory_A1_ = factory; deleter_A_ = deleter; }\n  void set_A(const std::function<A*(const char*, int)>& factory, const std::function<void(A*)>& deleter = std::default_delete<A>()) { factory_A2_ = factory; deleter_A_ = deleter; }\n  void set_Foo(const std::function<Foo*(void)>& factory, const std::function<void(Foo*)>& deleter = std::default_delete<Foo>()) { factory_Foo_ = factory; deleter_Foo_ = deleter; }\n  void set_Bar(const std::function<Bar*(void)>& factory, const std::function<void(Bar*)>& deleter = std::default_delete<Bar>()) { factory_Bar_ = factory; deleter_Bar_ = deleter; }\n  void set_Baz(const std::function<Baz*(void)>& factory, const std::function<void(Baz*)>& deleter = std::default_delete<Baz>()) { factory_Baz_ = factory; deleter_Baz_ = deleter; }\n  void set_Ext(const std::function<Ext*(void)>& factory, const std::function<void(Ext*)>& deleter = std::default_delete<Ext>()) { factory_Ext_ = factory; deleter_Ext_ = deleter; }\n  void reset_Ext() { reset_generic(instance_Ext_); }\n\n  // NOTE: for convenience of not writing two separate test classes, we have both new_A() and get_A() here,\n  //       but normally only one of those two methods would be implemented (we either want DIM to manage\n  //       particular class as a singleton class or not). Ditto Foo, Bar and Baz.\n\n  // object getters [step 3]\n  A& get_A() const { return get_generic(factory_A_, deleter_A_); }\n  Foo& get_Foo() const { return get_generic<Foo>(factory_Foo_, deleter_Foo_); }\n  Bar& get_Bar() const { return get_generic<Bar>(factory_Bar_, deleter_Bar_); }\n  Baz& get_Baz() const { return get_generic<Baz>(factory_Baz_, deleter_Baz_); }\n  Ext& get_Ext() { return get_external_generic(instance_Ext_, factory_Ext_, deleter_Ext_); }\n\n  // object creators [step 3]\n  UniquePtr<A> new_A()                           const { return new_generic(factory_A_, deleter_A_); }\n  UniquePtr<A> new_A(const char* arg1)           const { return new_generic1(factory_A1_, deleter_A_, arg1); }\n  UniquePtr<A> new_A(const char* arg1, int arg2) const { return new_generic2(factory_A2_, deleter_A_, arg1, arg2); }\n  UniquePtr<Foo> new_Foo() const { return new_generic(factory_Foo_, deleter_Foo_); }\n  UniquePtr<Bar> new_Bar() const { return new_generic(factory_Bar_, deleter_Bar_); }\n  UniquePtr<Baz> new_Baz() const { return new_generic(factory_Baz_, deleter_Baz_); }\n\n private:\n  // factory and deleter functions [step 4]\n  std::function<A*(void)>             factory_A_;   std::function<A*(const char*)> factory_A1_;\n  std::function<A*(const char*, int)> factory_A2_;  std::function<void(A*)>        deleter_A_;\n  std::function<Foo*(void)> factory_Foo_;  std::function<void(Foo*)> deleter_Foo_;\n  std::function<Bar*(void)> factory_Bar_;  std::function<void(Bar*)> deleter_Bar_;\n  std::function<Baz*(void)> factory_Baz_;  std::function<void(Baz*)> deleter_Baz_;\n  std::function<Ext*(void)> factory_Ext_;  std::function<void(Ext*)> deleter_Ext_; UniquePtr<Ext> instance_Ext_;\n};\n\nclass DIMTest : public ::testing::Test {\n public:\n  TestDIM& dim = TestDIM::instance();\n};\n\nclass B : public A {\n public:\n  B() : A(0) {\n    if (g_notifier)\n      g_notifier->called_ctor(\"B\");\n  }\n  B(const char* arg1) : A(0) {\n    if (g_notifier) {\n      std::string s = std::string(\"B(\") + arg1 + \")\";\n      g_notifier->called_ctor(s.c_str());\n    }\n  }\n  B(const char* arg1, int arg2) : A(0) {\n    if (g_notifier) {\n      std::string s = std::string(\"B(\") + arg1 + \",\" + std::to_string(arg2) + \")\";\n      g_notifier->called_ctor(s.c_str());\n    }\n  }\n\n  ~B() override {\n    if (g_notifier)\n      g_notifier->called_dtor(\"B\");\n  }\n\n  void do_something() override {\n    if (g_notifier)\n      g_notifier->called_do_something(\"B\");\n  }\n};\n\nTEST_F(DIMTest, singleton_simple) {\n\n  // 1st get_A() call should create a new istance\n  {\n    Notifier notifier;\n    set_notifier(notifier);\n    EXPECT_CALL(notifier, called_ctor(\"B\")).Times(1);\n    EXPECT_CALL(notifier, called_dtor(\"B\")).Times(0); // \\_ singleton should outlive\n    EXPECT_CALL(notifier, called_deleter(\"-\")).Times(0); // /  everything\n    EXPECT_CALL(notifier, called_do_something(\"B\")).Times(1);\n\n    // multiple set_A() are ok (to allow overriding defaults) - only last one matters\n    // (also use this opportunity to test passing various deleters - if they'll trigger build failure)\n    dim.set_A([](){ return nullptr; });\n    dim.set_A([](){ return nullptr; }, [](A*){} );\n    dim.set_A([](){ return nullptr; }, Deleter() );\n    dim.set_A([](){ return new A; });\n    dim.set_A([](){ return new A; }, nullptr);\n    dim.set_A([](){ return new B; }, deleter);  // only this one matters\n\n    A& a = dim.get_A();\n    a.do_something();\n  }\n\n  // subsequent get_A() calls should not create new instances\n  {\n    Notifier notifier;\n    set_notifier(notifier);\n    EXPECT_CALL(notifier, called_ctor(\"B\")).Times(0);  // no new instance should be created\n    EXPECT_CALL(notifier, called_dtor(\"B\")).Times(0);\n    EXPECT_CALL(notifier, called_deleter(\"-\")).Times(0);\n    EXPECT_CALL(notifier, called_do_something(\"B\")).Times(1);\n\n    A& a = dim.get_A();\n    a.do_something();\n  }\n\n  // calling set_A() should have no effect if singleton has already been created\n  {\n    Notifier notifier;\n    set_notifier(notifier);\n    EXPECT_CALL(notifier, called_ctor(\"B\")).Times(0);\n    EXPECT_CALL(notifier, called_dtor(\"B\")).Times(0);\n    EXPECT_CALL(notifier, called_deleter(\"-\")).Times(0);\n    EXPECT_CALL(notifier, called_do_something(\"B\")).Times(1);\n\n    // this brutal creator and deleter should never get called\n    dim.set_A([](){ assert(0); return nullptr; }, [](A*){ assert(0); } );\n\n    A& a = dim.get_A();\n    a.do_something();\n  }\n}\n\n// Foo depends on Bar and Baz,\n// Bar depends on Baz and some int,\n// Baz depends on nothing\nclass Baz {\n public:\n  Baz() {\n    if (g_notifier)\n      g_notifier->called_ctor(\"Baz\");\n  }\n};\nclass Bar {\n public:\n  Bar(Baz, int) {\n    if (g_notifier)\n      g_notifier->called_ctor(\"Bar\");\n  }\n};\nclass Foo {\n public:\n  Foo(Bar, Baz) {\n    if (g_notifier)\n      g_notifier->called_ctor(\"Foo\");\n  }\n  void do_something() {\n    if (g_notifier)\n      g_notifier->called_do_something(\"Foo\");\n  }\n};\n\nTEST_F(DIMTest, singleton_dependency_cascade) {\n\n  // init factories\n  {\n    int n = 42;\n    dim.set_Foo([this]()    { return new Foo(dim.get_Bar(), dim.get_Baz()); });\n    dim.set_Bar([this, n]() { return new Bar(dim.get_Baz(), n);             });\n    dim.set_Baz([]()        { return new Baz;                               });\n  }\n\n  // should trigger creation of Foo, Bar and Baz\n  {\n    Notifier notifier;\n    set_notifier(notifier);\n    EXPECT_CALL(notifier, called_ctor(\"Foo\")).Times(1);\n    EXPECT_CALL(notifier, called_ctor(\"Bar\")).Times(1);\n    EXPECT_CALL(notifier, called_ctor(\"Baz\")).Times(1);\n    EXPECT_CALL(notifier, called_do_something(\"Foo\")).Times(1);\n    EXPECT_CALL(notifier, called_dtor(_)).Times(0);    // \\_ singletons should outlive\n    EXPECT_CALL(notifier, called_deleter(_)).Times(0); // /  everything\n\n    dim.get_Foo().do_something();\n  }\n}\n\nvoid deleter0(A* ptr) {\n  if (g_notifier)\n    g_notifier->called_deleter(\"B0\");\n  delete ptr;\n}\n\nvoid deleter1(A* ptr) {\n  if (g_notifier)\n    g_notifier->called_deleter(\"B1\");\n  delete ptr;\n}\n\nvoid deleter2(A* ptr) {\n  if (g_notifier)\n    g_notifier->called_deleter(\"B2\");\n  delete ptr;\n}\n\nvoid deleterX(A*) {\n  FAIL() << \"This deleter should never be called\";\n}\n\nTEST_F(DIMTest, factory_simple) {\n  Notifier notifier;\n  set_notifier(notifier);\n  EXPECT_CALL(notifier, called_ctor(\"B\")).Times(1);\n  EXPECT_CALL(notifier, called_ctor(\"B(arg1)\")).Times(1);\n  EXPECT_CALL(notifier, called_ctor(\"B(arg1,2)\")).Times(1);\n  EXPECT_CALL(notifier, called_dtor(\"B\")).Times(3);\n  EXPECT_CALL(notifier, called_deleter(\"-\")).Times(3);  // last deleter matters\n  EXPECT_CALL(notifier, called_do_something(\"B\")).Times(3);\n\n  // note that different variants of set_A() share the deleter - only last one set matters\n  dim.set_A([](){ return new B; } );\n  dim.set_A([](const char* arg1){ return new B(arg1); }, [](A* p) { delete p; });\n  dim.set_A([](const char* arg1, int arg2){ return new B(arg1, arg2); }, deleter);\n  UniquePtr<A> a0 = dim.new_A();\n  UniquePtr<A> a1 = dim.new_A(\"arg1\");\n  UniquePtr<A> a2 = dim.new_A(\"arg1\", 2);\n  a0->do_something();\n  a1->do_something();\n  a2->do_something();\n}\n\nTEST_F(DIMTest, factory_object_should_remember_its_deleter) {\n  Notifier notifier;\n  set_notifier(notifier);\n  EXPECT_CALL(notifier, called_ctor(\"B\")).Times(1);\n  EXPECT_CALL(notifier, called_ctor(\"B(arg1)\")).Times(1);\n  EXPECT_CALL(notifier, called_ctor(\"B(arg1,2)\")).Times(1);\n  EXPECT_CALL(notifier, called_dtor(\"B\")).Times(3);\n  EXPECT_CALL(notifier, called_deleter(\"B0\")).Times(1);\n  EXPECT_CALL(notifier, called_deleter(\"B1\")).Times(1);\n  EXPECT_CALL(notifier, called_deleter(\"B2\")).Times(1);\n\n  // changing deleter should not affect objects already instantiated\n  // (instantiated objects should \"remeber their deleter\" - they should be deleted\n  // with the deleter current at the time of their instantiation)\n  {\n    dim.set_A([](){ return new B; }, deleter0 );\n    UniquePtr<A> a0 = dim.new_A();\n    dim.set_A([](){ return new B; }, deleterX );\n  }\n  {\n    dim.set_A([](const char* arg1){ return new B(arg1); }, deleter1);\n    UniquePtr<A> a1 = dim.new_A(\"arg1\");\n    dim.set_A([](const char* arg1){ return new B(arg1); }, deleterX);\n  }\n  {\n    dim.set_A([](const char* arg1, int arg2){ return new B(arg1, arg2); }, deleter2);\n    UniquePtr<A> a2 = dim.new_A(\"arg1\", 2);\n    dim.set_A([](const char* arg1, int arg2){ return new B(arg1, arg2); }, deleterX);\n  }\n}\n\nTEST_F(DIMTest, factory_object_should_remember_its_deleter2) {\n  Notifier notifier;\n  set_notifier(notifier);\n  EXPECT_CALL(notifier, called_ctor(\"B\")).Times(1);\n  EXPECT_CALL(notifier, called_ctor(\"B(arg1)\")).Times(1);\n  EXPECT_CALL(notifier, called_ctor(\"B(arg1,2)\")).Times(1);\n  EXPECT_CALL(notifier, called_dtor(\"B\")).Times(3);\n  EXPECT_CALL(notifier, called_deleter(\"B0\")).Times(1);\n  EXPECT_CALL(notifier, called_deleter(\"B1\")).Times(1);\n  EXPECT_CALL(notifier, called_deleter(\"B2\")).Times(1);\n\n  // same idea as previous test, but with different variants overwriting the deleter\n  // (all versions of get_A() share the same deleter)\n  {\n    dim.set_A([](){ return new B; }, deleter0 );\n    UniquePtr<A> a0 = dim.new_A();\n    dim.set_A([](const char* arg1){ return new B(arg1); }, deleter1);\n    UniquePtr<A> a1 = dim.new_A(\"arg1\");\n    dim.set_A([](const char* arg1, int arg2){ return new B(arg1, arg2); }, deleter2);\n    UniquePtr<A> a2 = dim.new_A(\"arg1\", 2);\n  }\n}\n\nclass Ext {\n public:\n  Ext(int xx) : x(xx) {}\n  int x;\n};\n\nTEST_F(DIMTest, object_reset) {\n  dim.set_Ext([]() { return new Ext(42); });  // set new factory\n  EXPECT_EQ(dim.get_Ext().x, 42);             // the factory gets called here\n\n  dim.set_Ext([]() { return new Ext(555); }); // set new factory again, ...\n  EXPECT_EQ(dim.get_Ext().x, 42);             // but it will not be called yet, ...\n\n  dim.reset_Ext();                            // until we reset the object.\n  EXPECT_EQ(dim.get_Ext().x, 555);            // now it gets called!\n}\n\n\n\n\n\nint main(int argc, char *argv[]) {\n  ::testing::InitGoogleTest(&argc, argv);\n  int res = RUN_ALL_TESTS();\n\n  // All the singletons will start running their destructors soon, and some of\n  // them call g_notifier methods. But g_notifier is now a dangling pointer,\n  // so here we set it to NULL so it's properly handled.\n  g_notifier = nullptr;\n\n  return res;\n}\n"
  },
  {
    "path": "src/harness/tests/test_filesystem.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql/harness/filesystem.h\"\n\n////////////////////////////////////////\n// Test system include files\n#include \"test/helpers.h\"\n\n////////////////////////////////////////\n// Third-party include files\n#include \"gtest/gtest.h\"\n\n////////////////////////////////////////\n// Standard include files\n\n#include <iostream>\n#include <vector>\n#include <fstream>\n\nusing std::cout;\nusing std::endl;\nusing std::back_inserter;\n\nusing mysql_harness::Path;\nusing mysql_harness::Directory;\n\nPath g_here;\n\nTEST(TestFilesystem, TestPath) {\n  // Testing basic path construction\n  EXPECT_EQ(Path(\"/data/logger.cfg\"), \"/data/logger.cfg\");\n  EXPECT_EQ(Path(\"data/logger.cfg\"), \"data/logger.cfg\");\n  EXPECT_EQ(Path(\"/\"), \"/\");\n  EXPECT_EQ(Path(\"//\"), \"/\");\n  EXPECT_EQ(Path(\"////////\"), \"/\");\n  EXPECT_EQ(Path(\"/data/\"), \"/data\");\n  EXPECT_EQ(Path(\"data/\"), \"data\");\n  EXPECT_EQ(Path(\"data////\"), \"data\");\n\n  // Testing dirname function\n  EXPECT_EQ(Path(\"foo.cfg\").dirname(), \".\");\n  EXPECT_EQ(Path(\"foo/bar.cfg\").dirname(), \"foo\");\n  EXPECT_EQ(Path(\"/foo/bar.cfg\").dirname(), \"/foo\");\n  EXPECT_EQ(Path(\"/\").dirname(), \"/\");\n\n  // Testing basename function\n  EXPECT_EQ(Path(\"foo.cfg\").basename(), \"foo.cfg\");\n  EXPECT_EQ(Path(\"foo/bar.cfg\").basename(), \"bar.cfg\");\n  EXPECT_EQ(Path(\"/foo/bar.cfg\").basename(), \"bar.cfg\");\n  EXPECT_EQ(Path(\"/\").basename(), \"/\");\n\n  // Testing join function (and indirectly the append function).\n  Path new_path = Path(\"data\").join(\"test\");\n  EXPECT_EQ(new_path, \"data/test\");\n\n  // Testing file status checking functions\n  EXPECT_EQ(g_here.join(\"data\").type(),\n            Path::FileType::DIRECTORY_FILE);\n\n#ifdef _WIN32\n  EXPECT_EQ(Path(\"c:\").type(), Path::FileType::DIRECTORY_FILE);\n#endif\n\n  EXPECT_EQ(g_here.join(\"data/logger.cfg\").type(),\n               Path::FileType::REGULAR_FILE);\n  EXPECT_EQ(g_here.join(\"data/does-not-exist.cfg\").type(),\n               Path::FileType::FILE_NOT_FOUND);\n\n  EXPECT_TRUE(g_here.join(\"data\").is_directory());\n  EXPECT_FALSE(g_here.join(\"data/logger.cfg\").is_directory());\n  EXPECT_FALSE(g_here.join(\"data\").is_regular());\n  EXPECT_TRUE(g_here.join(\"data/logger.cfg\").is_regular());\n}\n\nTEST(TestFilesystem, EmptyPath) {\n  // Testing error usage\n  EXPECT_THROW({ Path path(\"\"); }, std::invalid_argument);\n\n  // Default-constructed paths should be possible to create, but not\n  // to use.\n  Path path;\n  EXPECT_THROW(path.is_regular(), std::invalid_argument);\n  EXPECT_THROW(path.is_directory(), std::invalid_argument);\n  EXPECT_THROW(path.type(), std::invalid_argument);\n  EXPECT_THROW(path.append(g_here), std::invalid_argument);\n  EXPECT_THROW(path.join(g_here), std::invalid_argument);\n  EXPECT_THROW(path.basename(), std::invalid_argument);\n  EXPECT_THROW(path.dirname(), std::invalid_argument);\n  EXPECT_THROW(g_here.append(path), std::invalid_argument);\n  EXPECT_THROW(g_here.join(path), std::invalid_argument);\n\n  // Once a real path is moved into it, all should be fine.\n  path = g_here;\n  EXPECT_EQ(path, g_here);\n  EXPECT_TRUE(path.is_directory());\n  EXPECT_FALSE(path.is_regular());\n}\n\n\nTEST(TestFilesystem, TestDirectory) {\n  Directory directory(g_here.join(\"data\"));\n\n  {\n    // These are the files in the \"data\" directory in the test\n    // directory. Please update it if you add more files.\n    //\n    // TODO(Mats): Do not use the data directory for this but create a\n    // dedicated directory for testing this feature.\n    std::vector<Path> expect{\n      g_here.join(\"data/logger.d\"),\n      g_here.join(\"data/logger.cfg\"),\n      g_here.join(\"data/tests-bad-1.cfg\"),\n      g_here.join(\"data/tests-bad-2.cfg\"),\n      g_here.join(\"data/tests-bad-3.cfg\"),\n      g_here.join(\"data/tests-good-1.cfg\"),\n      g_here.join(\"data/tests-good-2.cfg\"),\n      g_here.join(\"data/tests-start-1.cfg\"),\n      g_here.join(\"data/magic-alt.cfg\"),\n      g_here.join(\"data/keepalive.cfg\"),\n    };\n\n    decltype(expect) result(directory.begin(), directory.end());\n    EXPECT_SETEQ(expect, result);\n  }\n\n  {\n    // These are files in the \"data\" directory in the test\n    // directory. Please update it if you add more files.\n    std::vector<Path> expect{\n      g_here.join(\"data/tests-bad-1.cfg\"),\n      g_here.join(\"data/tests-bad-2.cfg\"),\n      g_here.join(\"data/tests-bad-3.cfg\"),\n    };\n\n    decltype(expect) result(directory.glob(\"tests-bad*.cfg\"), directory.end());\n    EXPECT_SETEQ(expect, result);\n  }\n}\n\n// unfortunately it's not (reasonably) possible to make folders read-only on Windows,\n// therefore we can run the following 2 tests only on Unix\n// https://support.microsoft.com/en-us/help/326549/you-cannot-view-or-change-the-read-only-or-the-system-attributes-of-fo\nTEST(TestFilesystem, IsReadableIfFileCanBeRead) {\n#ifndef _WIN32\n\n  // create temporary file\n  const std::string directory = mysql_harness::get_tmp_dir(\"tmp\");\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){mysql_harness::delete_dir_recursive(directory);});\n\n  mysql_harness::Path path = mysql_harness::Path(directory).join(\"/tmp_file\");\n  std::ofstream file(path.str());\n\n  if (!file.good())\n    throw(std::runtime_error(\"Could not create file \" + path.str()));\n\n  // make file readable\n  chmod(path.c_str(), S_IRUSR);\n  ASSERT_TRUE(path.is_readable());\n#endif\n}\n\nTEST(TestFilesystem, IsNotReadableIfFileCanNotBeRead) {\n#ifndef _WIN32\n\n  // create temporary file\n  const std::string directory = mysql_harness::get_tmp_dir(\"tmp\");\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){mysql_harness::delete_dir_recursive(directory);});\n\n  mysql_harness::Path path = mysql_harness::Path(directory).join(\"/tmp_file\");\n  std::ofstream file(path.str());\n\n  if (!file.good())\n    throw(std::runtime_error(\"Could not create file \" + path.str()));\n\n  // make file readable\n  chmod(path.c_str(), S_IWUSR | S_IXUSR);\n  ASSERT_FALSE(path.is_readable());\n#endif\n}\n\nint main(int argc, char *argv[]) {\n  g_here = Path(argv[0]).dirname();\n\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/harness/tests/test_hostname_validator.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"hostname_validator.h\"\n\n////////////////////////////////////////\n// Test system include files\n\n////////////////////////////////////////\n// Third-party include files\n#include \"gmock/gmock.h\"\n\n////////////////////////////////////////\n// Standard include files\n\nusing mysql_harness::is_valid_hostname;\n\n/**\n * @file\n * @brief Unit tests for simple hostname validator\n */\n\n/**\n * @test verify that is_valid_hostname() returns true for valid hostnames\n *\n * @note Please see function documentation for expected behavior, it may be\n *       surprising.\n */\nTEST(TestHostnameValidator, valid_hostname) {\n\n  EXPECT_TRUE(is_valid_hostname(\"foo\"));\n  EXPECT_TRUE(is_valid_hostname(\"foo.BAR\"));\n  EXPECT_TRUE(is_valid_hostname(\"foo-BAR_baz\"));\n  EXPECT_TRUE(is_valid_hostname(\"1.2.3.4\"));\n  EXPECT_TRUE(is_valid_hostname(\"x\"));\n}\n\n/**\n * @test verify that is_valid_hostname() returns false for invalid hostnames\n *\n * @note Please see function documentation for expected behavior, it may be\n *       surprising.\n */\nTEST(TestHostnameValidator, invalid_hostname) {\n\n  EXPECT_FALSE(is_valid_hostname(\"\"));\n  EXPECT_FALSE(is_valid_hostname(\" \"));\n  EXPECT_FALSE(is_valid_hostname(\"foo bar\"));\n  EXPECT_FALSE(is_valid_hostname(\"^\"));\n  EXPECT_FALSE(is_valid_hostname(\"foo^bar\"));\n}\n\n/**\n * @note Things that pass at the time of implementing is_valid_hostname(), but\n *       probably shouldn't. This testcase is disabled, its sole purpose is to\n *       make the developer aware of this problem.\n */\nTEST(TestHostnameValidator, DISABLED_known_mishandled_cornercases) {\n\n  // NOTE: If any of these start failing one day, that's probably a good thing!\n  //       Please see function description for details.\n  EXPECT_TRUE(is_valid_hostname(\".foo\"));\n  EXPECT_TRUE(is_valid_hostname(\"foo.\"));\n  EXPECT_TRUE(is_valid_hostname(\".foo.bar.\"));\n  EXPECT_TRUE(is_valid_hostname(\".\"));\n  EXPECT_TRUE(is_valid_hostname(\"-\"));\n  EXPECT_TRUE(is_valid_hostname(\"1_2-3.4\"));\n  EXPECT_TRUE(is_valid_hostname(\"foo.bar.1.2\"));\n}\n\n"
  },
  {
    "path": "src/harness/tests/test_ip_address.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql/harness/networking/ip_address.h\"\n\n////////////////////////////////////////\n// Test system include files\n#include \"test/helpers.h\"\n\n////////////////////////////////////////\n// Third-party include files\n#include \"gmock/gmock.h\"\n\n////////////////////////////////////////\n// Standard include files\n#include <exception>\n#include <iostream>\n\nusing mysql_harness::IPv4Address;\nusing mysql_harness::IPv6Address;\nusing mysql_harness::IPAddress;\n\n////////////////////////////////////////\n// mysql_harness::IPv4Address\n\nTEST(TestIPv4Address, FromToString) {\n  std::string test_addr{\"127.0.0.1\"};\n\n  {\n    IPv4Address ip(test_addr);\n    ASSERT_EQ(test_addr, ip.str());\n  }\n\n  {\n    IPv4Address ip(test_addr.c_str());\n    ASSERT_EQ(test_addr, ip.str());\n  }\n}\n\nTEST(TestIPv4Address, FromStringFail) {\n  using ::testing::HasSubstr;\n  {\n    // Cannot handle IPv6\n    std::string test_addr{\"fe80::6e40:8ff:fea2:5d7e\"};\n    EXPECT_THROW({ IPv4Address ip(test_addr); }, std::invalid_argument);\n    try {\n      IPv4Address ip(test_addr);\n    } catch (const std::invalid_argument &exc) {\n      EXPECT_THAT(exc.what(), HasSubstr(\"parsing error\"));\n    }\n  }\n\n  {\n    // Wrong IPv4 address\n    std::string test_addr{\"300.1.2.3\"};\n    EXPECT_THROW({ IPv4Address ip(test_addr); }, std::invalid_argument);\n    try {\n      IPv4Address ip(test_addr);\n    } catch (const std::invalid_argument &exc) {\n      EXPECT_THAT(exc.what(), HasSubstr(\"parsing error\"));\n    }\n  }\n}\n\nTEST(TestIPv4Address, CopyConstructor) {\n  std::string test_addr{\"192.168.14.5\"};\n  IPv4Address ip(test_addr);\n\n  auto copy(ip);\n\n  EXPECT_EQ(test_addr, copy.str());\n}\n\nTEST(TestIPv4Address, CopyAssigment) {\n  std::string test_addr{\"192.168.14.5\"};\n  IPv4Address ip(test_addr);\n\n  IPv4Address copy{};\n  copy = ip;\n\n  EXPECT_EQ(test_addr, copy.str());\n}\n\nTEST(TestIPv4Address, Equality) {\n  IPv4Address ip1(\"192.168.14.5\");\n  IPv4Address ip2(\"192.168.14.5\");\n  IPv4Address ip3(\"192.168.14.200\");\n  EXPECT_EQ(ip1, ip2);\n  EXPECT_NE(ip1, ip3);\n}\n\nTEST(TestIPv4Address, Inequality) {\n  IPv4Address ip1(\"192.168.14.5\");\n  IPv4Address ip2(\"192.168.14.5\");\n  IPv4Address ip3(\"192.168.14.200\");\n  EXPECT_NE(ip1, ip3);\n  EXPECT_EQ(ip1, ip2);\n}\n\nTEST(TestIPv4Address, OperatorStreamInsertion) {\n  std::ostringstream os;\n\n  std::string test_addr{\"192.168.14.5\"};\n\n  IPv4Address ip(test_addr);\n\n  os << ip;\n  ASSERT_EQ(test_addr, os.str());\n}\n\n////////////////////////////////////////\n// mysql_harness::IPv6Address\n\nTEST(TestIPv6Address, FromString) {\n  std::string test_addr{\"fe80::1\"};\n\n  {\n    IPv6Address ip(test_addr);\n    EXPECT_EQ(test_addr, ip.str());\n  }\n\n  {\n    IPv6Address ip(test_addr.c_str());\n    EXPECT_EQ(test_addr, ip.str());\n  }\n\n  {\n    test_addr = \"fe80::6e40:8ff:fea2:5d7e\";\n    IPv6Address ip(test_addr);\n    EXPECT_EQ(test_addr, ip.str());\n  }\n\n  {\n    EXPECT_EQ(test_addr, IPv6Address(test_addr).str());\n  }\n}\n\nTEST(TestIPv6Address, FromStringFail) {\n  using ::testing::HasSubstr;\n\n  {\n    // Cannot handle IPv4\n    std::string str_ipv4{\"192.168.14.5\"};\n    EXPECT_THROW({ IPv6Address ip(str_ipv4); }, std::invalid_argument);\n    try {\n      IPv6Address ip{str_ipv4};\n    } catch (const std::invalid_argument &exc) {\n      EXPECT_THAT(exc.what(), HasSubstr(\"parsing error\"));\n    }\n  }\n\n  {\n    // Wrong IPv6 address\n    std::string str_ipv6_wrong{\"fe80::6e40:8ff:fea2:5d7x\"}; // x at the end\n    EXPECT_THROW({ IPv6Address ip(str_ipv6_wrong); }, std::invalid_argument);\n    try {\n      IPv6Address ip{str_ipv6_wrong};\n    } catch (const std::invalid_argument &exc) {\n      EXPECT_THAT(exc.what(), HasSubstr(\"parsing error\"));\n    }\n  }\n}\n\nTEST(TestIPv6Address, CopyConstructor) {\n  std::string test_addr{\"fe80::6e40:8ff:fea2:5d7e\"};\n  IPv6Address ip(test_addr);\n\n  auto copy(ip);\n\n  ASSERT_EQ(test_addr, copy.str());\n}\n\nTEST(TestIPv6Address, CopyAssigment) {\n  std::string test_addr{\"fe80::6e40:8ff:fea2:5d7e\"};\n  IPv6Address ip(test_addr);\n\n  IPv6Address copy{};\n  copy = ip;\n\n  ASSERT_EQ(test_addr, copy.str());\n}\n\nTEST(TestIPv6Address, OperatorStreamInsertion) {\n  std::ostringstream os;\n\n  std::string test_addr{\"fe80::6e40:8ff:fea2:5d7e\"};\n\n  IPv6Address ip(test_addr);\n\n  os << ip;\n  ASSERT_EQ(test_addr, os.str());\n}\n\nTEST(TestIPv6Address, Equality) {\n  IPv6Address ip1(\"fe80::6e40:8ff:fea2:5d7e\");\n  IPv6Address ip2(\"fe80::6e40:8ff:fea2:5d7e\");\n  IPv6Address ip3(\"fe80::6e40:8ff:fea2:8e2a\");\n  ASSERT_TRUE(ip1 == ip2);\n  ASSERT_FALSE(ip1 == ip3);\n}\n\nTEST(TestIPv6Address, Inequality) {\n  IPv6Address ip1(\"fe80::6e40:8ff:fea2:5d7e\");\n  IPv6Address ip2(\"fe80::6e40:8ff:fea2:5d7e\");\n  IPv6Address ip3(\"fe80::6e40:8ff:fea2:8e2a\");\n  ASSERT_TRUE(ip1 != ip3);\n  ASSERT_FALSE(ip1 != ip2);\n}\n\n////////////////////////////////////////\n// mysql_harness::IPAddress\n\nTEST(TestIPAddress, Constructor) {\n  {\n    IPAddress addr;\n    EXPECT_TRUE(addr.is_ipv4());\n    EXPECT_EQ(addr.str(), std::string(\"0.0.0.0\"));\n  }\n\n  {\n    IPAddress addr(\"127.0.0.1\");\n    EXPECT_TRUE(addr.is_ipv4());\n  }\n\n  {\n    IPAddress addr(\"::1\");\n    EXPECT_TRUE(addr.is_ipv6());\n  }\n\n  ASSERT_THROW({ IPAddress(\"127.0.0.1fooo\"); }, std::invalid_argument);\n  ASSERT_THROW({ IPAddress(\":::1\"); }, std::invalid_argument);\n}\n\nTEST(TestIPAddress, ConstructorIPv4) {\n  IPAddress addr(IPv4Address(\"127.0.0.1\"));\n  EXPECT_TRUE(addr.is_ipv4());\n  EXPECT_FALSE(addr.is_ipv6());\n}\n\nTEST(TestIPAddress, ConstructorIPv6) {\n  IPAddress addr(IPv6Address(\"fe80::1\"));\n  EXPECT_TRUE(addr.is_ipv6());\n  EXPECT_FALSE(addr.is_ipv4());\n}\n\nTEST(TestIPAddress, CopyConstructor) {\n  std::string test_addr4{\"192.168.14.5\"};\n  std::string test_addr6{\"fe80::6e40:8ff:fea2:5d7e\"};\n\n  IPAddress copy4{IPAddress(test_addr4)};\n  IPAddress copy6{IPAddress(test_addr6)};\n\n  EXPECT_EQ(test_addr4, copy4.str());\n  EXPECT_EQ(test_addr6, copy6.str());\n}\n\nTEST(TestIPAddress, CopyAssigment) {\n  std::string test_addr4{\"192.168.14.5\"};\n  std::string test_addr6{\"fe80::6e40:8ff:fea2:5d7e\"};\n\n  IPAddress ip4(test_addr4);\n  IPAddress ip6(test_addr6);\n\n  IPAddress copy4{};\n  IPAddress copy6{};\n\n  copy4 = ip4;\n  copy6 = ip6;\n\n  EXPECT_EQ(test_addr4, copy4.str());\n  EXPECT_EQ(test_addr6, copy6.str());\n}\n\nTEST(TestIPAddress, OperatorStreamInsertion) {\n  std::ostringstream os;\n\n  std::string test_addr{\"fe80::6e40:8ff:fea2:5d7e\"};\n\n  IPAddress ip(test_addr);\n\n  os << ip;\n  EXPECT_EQ(test_addr, os.str());\n}\n\nTEST(TestIPAddress, AsIPv4) {\n  std::string test_addr4{\"192.168.14.5\"};\n\n  IPv4Address ipv4(test_addr4);\n  auto ip = IPAddress(ipv4);\n  ASSERT_TRUE(ipv4 == ip.as_ipv4());\n  ASSERT_THROW({ ip.as_ipv6(); }, std::runtime_error);\n}\n\nTEST(TestIPAddress, AsIPv6) {\n  std::string test_addr6{\"fe80::6e40:8ff:fea2:5d7e\"};\n\n  IPv6Address ipv6(test_addr6);\n  auto ip = IPAddress(ipv6);\n  ASSERT_TRUE(ipv6 == ip.as_ipv6());\n  ASSERT_THROW({ ip.as_ipv4(); }, std::runtime_error);\n}\n"
  },
  {
    "path": "src/harness/tests/test_iterator.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"utilities.h\"\n\n////////////////////////////////////////\n// Test system include files\n#include \"test/helpers.h\"\n\n////////////////////////////////////////\n// Third-party include files\n#include \"gtest/gtest.h\"\n\n////////////////////////////////////////\n// Standard include files\n#include <cstdlib>\n#include <cstring>\n#include <iostream>\n#include <stdexcept>\n\nusing mysql_harness::utility::make_range;\n\nTEST(TestIterator, TestIterator) {\n  static const char* array[] = {\n    \"one\", \"two\", \"three\",\n  };\n  const size_t array_length = sizeof(array)/sizeof(*array);\n  const char** ptr = array;\n\n  auto range = make_range(array, array_length);\n  for (auto elem : range) {\n    EXPECT_EQ(elem, *ptr);\n    EXPECT_LT(ptr - array,\n              static_cast<long>(sizeof(array)/sizeof(*array)));\n    ++ptr;\n  }\n}\n"
  },
  {
    "path": "src/harness/tests/test_keyring.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <system_error>\n\n#include \"test/helpers.h\"\n\n////////////////////////////////////////\n// Third-party include files\n#include \"gtest/gtest.h\"\n\n////////////////////////////////////////\n// Standard include files\n\n#ifdef _WIN32\n#include <aclapi.h>\n#else\n#include <sys/stat.h>\n#endif\n\n#include \"keyring/keyring_file.h\"\n#include \"common.h\"\n\n\nconstexpr char kAesKey[] = \"AesKey\";\nconstexpr char kKeyringFileName[] = \"keyring_config\";\n\n\n/**\n * Generic keyring test.\n *\n * Covers tests common for `KeyringMemory` and `KeyringFile`.\n */\ntemplate <typename T>\nclass KeyringTest : public ::testing::Test {\n public:\n  KeyringTest() = default;\n};\n\nusing KeyringTestTypes = ::testing::Types<mysql_harness::KeyringMemory,\n                                          mysql_harness::KeyringFile>;\nTYPED_TEST_CASE(KeyringTest, KeyringTestTypes);\n\n\n/**\n * Deletes a file.\n *\n * @param[in] file_name Name of the file to be deleted.\n *\n * @except std::exception Failed to delete the file.\n */\nstatic void delete_file(const std::string& file_name) {\n#ifdef _WIN32\n\n  if (DeleteFileA(file_name.c_str()) == 0) {\n    auto error = GetLastError();\n\n    if (error != ERROR_FILE_NOT_FOUND) {\n      throw std::runtime_error(\"DeleteFile() failed: \" +\n                               std::to_string(error));\n    }\n  }\n\n#else\n\n  if (unlink(file_name.c_str()) != 0 && errno != ENOENT) {\n    throw std::runtime_error(\"unlink() failed: \" +\n                             std::to_string(errno));\n  }\n\n#endif // _WIN32\n}\n\n/**\n * KeyringFile test.\n *\n * Prepares environment for file-based keyring implementation.\n */\nclass KeyringFileTest : public ::testing::Test {\n public:\n  KeyringFileTest() = default;\n\n  virtual void SetUp() override {\n    delete_file(kKeyringFileName);\n  }\n};\n\n/**\n * Fills keyring with test data.\n *\n * @param[out] keyring Keyring to be filled with data.\n */\nstatic void fill_keyring(mysql_harness::Keyring& keyring) {\n  keyring.store(\"E1\", \"E1A1\", \"E1V1\");\n  keyring.store(\"E1\", \"E1A2\", \"E1V2\");\n  keyring.store(\"E2\", \"E2A1\", \"E2V1\");\n  keyring.store(\"E2\", \"E2A2\", \"E2V2\");\n}\n\n/**\n * Verifies keyring contents.\n *\n * @param[in] keyring Keyring to be verified.\n */\nstatic void verify_keyring(const mysql_harness::Keyring& keyring) {\n  ASSERT_EQ(keyring.fetch(\"E1\", \"E1A1\"), \"E1V1\");\n  ASSERT_EQ(keyring.fetch(\"E1\", \"E1A2\"), \"E1V2\");\n  ASSERT_EQ(keyring.fetch(\"E2\", \"E2A1\"), \"E2V1\");\n  ASSERT_EQ(keyring.fetch(\"E2\", \"E2A2\"), \"E2V2\");\n}\n\nTYPED_TEST(KeyringTest, StoreFetch) {\n  TypeParam keyring;\n\n  fill_keyring(keyring);\n  verify_keyring(keyring);\n}\n\nTYPED_TEST(KeyringTest, AttributeOverwrite) {\n  TypeParam keyring;\n\n  keyring.store(\"Entry\", \"Attribute\", \"Value\");\n  keyring.store(\"Entry\", \"Attribute\", \"OtherValue\");\n\n  ASSERT_EQ(keyring.fetch(\"Entry\", \"Attribute\"), \"OtherValue\");\n}\n\nTYPED_TEST(KeyringTest, FetchUndefinedEntry) {\n  TypeParam keyring;\n\n  fill_keyring(keyring);\n\n  EXPECT_THROW(keyring.fetch(\"InvalidEntry\", \"Attr\"), std::out_of_range);\n}\n\nTYPED_TEST(KeyringTest, FetchUndefinedAttribute) {\n  TypeParam keyring;\n\n  fill_keyring(keyring);\n\n  EXPECT_THROW(keyring.fetch(\"Entry\", \"AttrInvalid\"), std::out_of_range);\n}\n\nTYPED_TEST(KeyringTest, RemoveEntry) {\n  TypeParam keyring;\n\n  keyring.store(\"Entry\", \"Attr\", \"Value\");\n  keyring.remove(\"Entry\");\n\n  EXPECT_THROW(keyring.fetch(\"Entry\", \"Attr\"), std::out_of_range);\n}\n\nTYPED_TEST(KeyringTest, RemoveAttribute) {\n  TypeParam keyring;\n\n  keyring.store(\"Entry\", \"Attr\", \"Value\");\n  keyring.remove_attribute(\"Entry\", \"Attr\");\n\n  EXPECT_THROW(keyring.fetch(\"Entry\", \"Attr\"), std::out_of_range);\n}\n\nTYPED_TEST(KeyringTest, SaveAndLoadEmpty) {\n  std::vector<char> keyring_data;\n\n  // Serialize empty keyring.\n  {\n    TypeParam keyring;\n\n    keyring_data = keyring.serialize(kAesKey);\n  }\n\n  // Parse keyring data.\n  TypeParam keyring;\n\n  keyring.parse(kAesKey, keyring_data.data(), keyring_data.size());\n}\n\nTYPED_TEST(KeyringTest, SaveAndLoadFilled) {\n  std::vector<char> keyring_data;\n\n  // Serialize filled keyring.\n  {\n    TypeParam keyring;\n\n    fill_keyring(keyring);\n    keyring_data = keyring.serialize(kAesKey);\n  }\n\n  // Parse keyring data and verify contents.\n  TypeParam keyring;\n\n  keyring.parse(kAesKey, keyring_data.data(), keyring_data.size());\n  verify_keyring(keyring);\n}\n\nTYPED_TEST(KeyringTest, SaveAndLoadBroken) {\n  std::vector<char> keyring_data;\n\n  // Serialize filled keyring.\n  {\n    TypeParam keyring;\n\n    fill_keyring(keyring);\n    keyring_data = keyring.serialize(kAesKey);\n  }\n\n  // Try loading a few randomly broken keyring buffers.\n  for (std::size_t test_count = 0; test_count < 20; ++test_count) {\n    TypeParam keyring;\n    auto buffer_offset = static_cast<size_t>(std::rand()) % keyring_data.size();\n    auto buffer_size = static_cast<size_t>(std::rand()) % (keyring_data.size() - buffer_offset + 1);\n\n    if (buffer_offset + buffer_size == keyring_data.size()) {\n      // Buffer valid, ignore.\n      continue;\n    }\n\n    EXPECT_THROW(\n        keyring.parse(kAesKey,\n                      keyring_data.data() + buffer_offset, buffer_size),\n        std::exception);\n  }\n}\n\nTYPED_TEST(KeyringTest, SaveAndLoadWithInvalidKey) {\n  std::vector<char> keyring_data;\n\n  // Serialize filled keyring.\n  {\n    TypeParam keyring;\n\n    fill_keyring(keyring);\n    keyring_data = keyring.serialize(kAesKey);\n  }\n\n  // Parse keyring data with invalid encryption key.\n  TypeParam keyring;\n\n  EXPECT_THROW(\n      keyring.parse(\"invalid_key\", keyring_data.data(), keyring_data.size()),\n      std::exception);\n}\n\nTEST_F(KeyringFileTest, LoadFromFileWithCorrectPermissions) {\n  {\n    mysql_harness::KeyringFile keyring;\n\n    fill_keyring(keyring);\n    keyring.save(kKeyringFileName, kAesKey);\n    try {\n      mysql_harness::make_file_private(kKeyringFileName);\n    } catch (const std::system_error &e) {\n#ifdef _WIN32\n      if (e.code() != std::error_code(ERROR_INVALID_FUNCTION, std::system_category()))\n        // if the filesystem can't set permissions, ignore it\n#endif\n        throw;\n    }\n  }\n\n  mysql_harness::KeyringFile keyring;\n\n  keyring.load(kKeyringFileName, kAesKey);\n  verify_keyring(keyring);\n}\n\nTEST_F(KeyringFileTest, LoadFromFileWithWrongPermissions) {\n  {\n    mysql_harness::KeyringFile keyring;\n\n    fill_keyring(keyring);\n    keyring.save(kKeyringFileName, kAesKey);\n    try {\n      mysql_harness::make_file_public(kKeyringFileName);\n    } catch (const std::system_error &e) {\n#ifdef _WIN32\n      if (e.code() == std::error_code(ERROR_INVALID_FUNCTION, std::system_category())) {\n        // if the filesystem can't set permissions, the test later would fail\n\treturn;\n      }\n#endif\n      throw;\n    }\n  }\n\n  mysql_harness::KeyringFile keyring;\n\n  EXPECT_THROW(keyring.load(kKeyringFileName, kAesKey), std::exception);\n}\n\nTEST_F(KeyringFileTest, LoadFromNonexistentFile) {\n  mysql_harness::KeyringFile keyring;\n\n  // Setup() deletes keyring file.\n  EXPECT_THROW(keyring.load(kKeyringFileName, kAesKey), std::exception);\n}\n\nint main(int argc, char *argv[]) {\n\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/harness/tests/test_keyring_manager.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"test/helpers.h\"\n#include \"gtest/gtest.h\"\n#include \"common.h\"\n#include \"dim.h\"\n#include \"random_generator.h\"\n#include \"keyring/keyring_memory.h\"\n#include \"keyring/keyring_manager.h\"\n\n#include <set>\n#include <fstream>\n\n#ifndef _WIN32\n#include <sys/stat.h>\n#include <unistd.h>\n#else\n#include <windows.h>\n#endif\n\n\nusing namespace testing;\n\nclass TemporaryFileCleaner {\npublic:\n  ~TemporaryFileCleaner() {\n    if (!getenv(\"TEST_DONT_DELETE_FILES\")) {\n      for (auto path : tmp_files_) {\n#ifndef _WIN32\n        ::unlink(path.c_str());\n#else\n        DeleteFile(path.c_str()) ? 0 : -1;\n#endif\n      }\n    }\n  }\n\n  const std::string &add(const std::string &path) {\n    tmp_files_.insert(path);\n    return path;\n  }\n\nprivate:\n  std::set<std::string> tmp_files_;\n};\n\n\n#ifdef _WIN32\n// Copied from keyring_file.cc\n\n// Smart pointers for WinAPI structures that use C-style memory management.\nusing SecurityDescriptorPtr =\n    std::unique_ptr<SECURITY_DESCRIPTOR,\n                    mysql_harness::StdFreeDeleter<SECURITY_DESCRIPTOR>>;\nusing SidPtr = std::unique_ptr<SID, mysql_harness::StdFreeDeleter<SID>>;\n\n/**\n * Retrieves file's DACL security descriptor.\n *\n * @param[in] file_name File name.\n *\n * @return File's DACL security descriptor.\n *\n * @except std::exception Failed to retrieve security descriptor.\n */\nstatic SecurityDescriptorPtr get_security_descriptor(\n    const std::string& file_name) {\n  static constexpr SECURITY_INFORMATION kReqInfo = DACL_SECURITY_INFORMATION;\n\n  // Get the size of the descriptor.\n  DWORD sec_desc_size;\n\n  if (GetFileSecurityA(file_name.c_str(), kReqInfo, nullptr,\n                       0, &sec_desc_size) == FALSE) {\n    auto error = GetLastError();\n\n    // We expect to receive `ERROR_INSUFFICIENT_BUFFER`.\n    if (error != ERROR_INSUFFICIENT_BUFFER) {\n      throw std::runtime_error(\"GetFileSecurity() failed (\" + file_name +\n                               \"): \" + std::to_string(error));\n    }\n  }\n\n  SecurityDescriptorPtr sec_desc(\n      static_cast<SECURITY_DESCRIPTOR*>(std::malloc(sec_desc_size)));\n\n  if (GetFileSecurityA(file_name.c_str(), kReqInfo, sec_desc.get(),\n                       sec_desc_size, &sec_desc_size) == FALSE) {\n    throw std::runtime_error(\"GetFileSecurity() failed (\" + file_name + \"): \" +\n                             std::to_string(GetLastError()));\n  }\n\n  return sec_desc;\n}\n\n/**\n * Verifies permissions of an access ACE entry.\n *\n * @param[in] access_ace Access ACE entry.\n *\n * @except std::exception Everyone has access to the ACE access entry or\n *                        an error occured.\n */\nstatic void check_ace_access_rights(ACCESS_ALLOWED_ACE* access_ace) {\n  SID* sid = reinterpret_cast<SID*>(&access_ace->SidStart);\n  DWORD sid_size = SECURITY_MAX_SID_SIZE;\n  SidPtr everyone_sid(static_cast<SID*>(std::malloc(sid_size)));\n\n  if (CreateWellKnownSid(WinWorldSid, nullptr,\n                         everyone_sid.get(), &sid_size) == FALSE) {\n    throw std::runtime_error(\"CreateWellKnownSid() failed: \" +\n                             std::to_string(GetLastError()));\n  }\n\n  if (EqualSid(sid, everyone_sid.get())) {\n    if (access_ace->Mask & (FILE_EXECUTE)) {\n      throw std::runtime_error(\"Invalid keyring file access rights \"\n                               \"(Execute privilege granted to Everyone).\");\n    }\n    if (access_ace->Mask &\n        (FILE_WRITE_DATA | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES)) {\n      throw std::runtime_error(\"Invalid keyring file access rights \"\n                               \"(Write privilege granted to Everyone).\");\n    }\n    if (access_ace->Mask &\n        (FILE_READ_DATA | FILE_READ_EA | FILE_READ_ATTRIBUTES)) {\n      throw std::runtime_error(\"Invalid keyring file access rights \"\n                               \"(Read privilege granted to Everyone).\");\n    }\n  }\n}\n\n/**\n * Verifies access permissions in a DACL.\n *\n * @param[in] dacl DACL to be verified.\n *\n * @except std::exception DACL contains an ACL entry that grants full access to\n *                        Everyone or an error occured.\n */\nstatic void check_acl_access_rights(ACL* dacl) {\n  ACL_SIZE_INFORMATION dacl_size_info;\n\n  if (GetAclInformation(dacl, &dacl_size_info, sizeof(dacl_size_info),\n                        AclSizeInformation) == FALSE) {\n    throw std::runtime_error(\"GetAclInformation() failed: \" +\n                             std::to_string(GetLastError()));\n  }\n\n  for (DWORD ace_idx = 0; ace_idx < dacl_size_info.AceCount; ++ace_idx) {\n    LPVOID ace = nullptr;\n\n    if (GetAce(dacl, ace_idx, &ace) == FALSE) {\n      throw std::runtime_error(\"GetAce() failed: \" +\n                               std::to_string(GetLastError()));\n      continue;\n    }\n\n    if (static_cast<ACE_HEADER*>(ace)->AceType == ACCESS_ALLOWED_ACE_TYPE)\n      check_ace_access_rights(static_cast<ACCESS_ALLOWED_ACE*>(ace));\n  }\n}\n\n/**\n * Verifies access permissions in a security descriptor.\n *\n * @param[in] sec_desc Security descriptor to be verified.\n *\n * @except std::exception Security descriptor grants full access to\n *                        Everyone or an error occured.\n */\nstatic void check_security_descriptor_access_rights(\n    SecurityDescriptorPtr sec_desc) {\n  BOOL dacl_present;\n  ACL* dacl;\n  BOOL dacl_defaulted;\n\n  if (GetSecurityDescriptorDacl(sec_desc.get(), &dacl_present, &dacl,\n                                &dacl_defaulted) == FALSE) {\n    throw std::runtime_error(\"GetSecurityDescriptorDacl() failed: \" +\n                             std::to_string(GetLastError()));\n  }\n\n  if (!dacl_present) {\n    // No DACL means: no access allowed. Which is fine.\n    return;\n  }\n\n  if (!dacl) {\n    // Empty DACL means: all access allowed.\n      throw std::runtime_error(\"Invalid keyring file access rights \"\n                               \"(Everyone has full access rights).\");\n  }\n\n  check_acl_access_rights(dacl);\n}\n#endif // _WIN32\n\nstatic bool check_file_private(const std::string &file) {\n#ifdef _WIN32\n  try {\n    check_security_descriptor_access_rights(get_security_descriptor(file));\n    return true;\n  } catch (...) {\n    return false;\n  }\n#else\n  struct stat st;\n  if (stat(file.c_str(), &st) < 0) {\n    throw std::runtime_error(file+\": \" + strerror(errno));\n  }\n  if ((st.st_mode & (S_IRWXU|S_IRWXG|S_IRWXO)) == (S_IRUSR|S_IWUSR))\n    return true;\n  return false;\n#endif\n}\n\nclass FileChangeChecker {\npublic:\n  FileChangeChecker(const std::string &file) : path_(file) {\n    std::ifstream f;\n    std::stringstream ss;\n    f.open(file, std::ifstream::binary);\n    if (f.fail())\n      throw std::runtime_error(file+\" \"+mysql_harness::get_strerror(errno));\n    ss << f.rdbuf();\n    contents_ = ss.str();\n    f.close();\n  }\n\n  bool check_unchanged() {\n    std::ifstream f;\n    std::stringstream ss;\n    f.open(path_, std::ifstream::binary);\n    if (f.fail())\n      throw std::runtime_error(path_+\" \"+mysql_harness::get_strerror(errno));\n    ss << f.rdbuf();\n    f.close();\n    return ss.str() == contents_;\n  }\n\nprivate:\n  std::string path_;\n  std::string contents_;\n};\n\n\nstatic bool file_exists(const std::string &file) {\n  return mysql_harness::Path(file).exists();\n}\n\nTmpDir tmp_dir;\n\nTEST(KeyringManager, init_tests) {\n  mysql_harness::DIM::instance().set_RandomGenerator(\n    [](){ static mysql_harness::FakeRandomGenerator rg; return &rg; },\n    [](mysql_harness::RandomGeneratorInterface*){}  // don't delete our static!\n  );\n}\n\nTEST(KeyringManager, init_with_key) {\n  TemporaryFileCleaner cleaner;\n\n  EXPECT_TRUE(mysql_harness::get_keyring() == nullptr);\n  mysql_harness::init_keyring_with_key(cleaner.add(tmp_dir.file(\"keyring\")), \"secret\", true);\n  {\n    mysql_harness::Keyring *kr = mysql_harness::get_keyring();\n    EXPECT_NE(kr, nullptr);\n\n    kr->store(\"foo\", \"bar\", \"baz\");\n    mysql_harness::flush_keyring();\n    EXPECT_TRUE(check_file_private(tmp_dir.file(\"keyring\")));\n\n    // this key will not be saved to disk b/c of missing flush\n    kr->store(\"account\", \"password\", \"\");\n    EXPECT_EQ(kr->fetch(\"foo\", \"bar\"), \"baz\");\n\n    EXPECT_EQ(kr->fetch(\"account\", \"password\"), \"\");\n  }\n  mysql_harness::reset_keyring();\n  EXPECT_TRUE(mysql_harness::get_keyring() == nullptr);\n\n  EXPECT_FALSE(file_exists(tmp_dir.file(\"badkeyring\")));\n  ASSERT_THROW(\n    mysql_harness::init_keyring_with_key(tmp_dir.file(\"badkeyring\"), \"secret\", false),\n    std::runtime_error);\n  EXPECT_FALSE(file_exists(tmp_dir.file(\"badkeyring\")));\n\n#ifndef _WIN32\n  ASSERT_THROW(\n    mysql_harness::init_keyring_with_key(\"/badkeyring\", \"secret\", false),\n    std::runtime_error);\n  EXPECT_FALSE(file_exists(\"/badkeyring\"));\n\n  ASSERT_THROW(\n    mysql_harness::init_keyring_with_key(\"/badkeyring\", \"secret\", true),\n    std::runtime_error);\n  EXPECT_FALSE(file_exists(\"/badkeyring\"));\n#endif\n\n  ASSERT_THROW(\n    mysql_harness::init_keyring_with_key(tmp_dir.file(\"keyring\"), \"badkey\", false),\n    mysql_harness::decryption_error);\n\n  ASSERT_THROW(\n    mysql_harness::init_keyring_with_key(tmp_dir.file(\"keyring\"), \"\", false),\n    mysql_harness::decryption_error);\n\n  EXPECT_TRUE(mysql_harness::get_keyring() == nullptr);\n\n  mysql_harness::init_keyring_with_key(tmp_dir.file(\"keyring\"), \"secret\", false);\n  {\n    mysql_harness::Keyring *kr = mysql_harness::get_keyring();\n\n    EXPECT_EQ(kr->fetch(\"foo\", \"bar\"), \"baz\");\n    ASSERT_THROW(\n      kr->fetch(\"account\", \"password\"),\n      std::out_of_range);\n  }\n\n  mysql_harness::reset_keyring();\n  EXPECT_TRUE(mysql_harness::get_keyring() == nullptr);\n  // no key no service\n  ASSERT_THROW(\n    mysql_harness::init_keyring_with_key(cleaner.add(tmp_dir.file(\"xkeyring\")), \"\", true),\n    std::runtime_error);\n  EXPECT_FALSE(file_exists(tmp_dir.file(\"xkeyring\")));\n\n  // try to open non-existing keyring\n  ASSERT_THROW(\n    mysql_harness::init_keyring_with_key(cleaner.add(tmp_dir.file(\"invalidkeyring\")), \"secret\", false),\n    std::runtime_error);\n  EXPECT_FALSE(file_exists(tmp_dir.file(\"invalidkeyring\")));\n\n  // check if keyring is created even if empty\n  mysql_harness::init_keyring_with_key(cleaner.add(tmp_dir.file(\"emptykeyring\")), \"secret2\", true);\n  EXPECT_TRUE(file_exists(tmp_dir.file(\"emptykeyring\")));\n  mysql_harness::reset_keyring();\n}\n\n\nTEST(KeyringManager, init_with_key_file) {\n  TemporaryFileCleaner cleaner;\n\n  EXPECT_FALSE(file_exists(tmp_dir.file(\"keyring\")));\n  EXPECT_FALSE(file_exists(tmp_dir.file(\"keyfile\")));\n\n  EXPECT_TRUE(mysql_harness::get_keyring() == nullptr);\n  mysql_harness::init_keyring(cleaner.add(tmp_dir.file(\"keyring\")),\n                              cleaner.add(tmp_dir.file(\"keyfile\")), true);\n  EXPECT_TRUE(file_exists(tmp_dir.file(\"keyring\")));\n  EXPECT_TRUE(file_exists(tmp_dir.file(\"keyfile\")));\n  {\n    mysql_harness::Keyring *kr = mysql_harness::get_keyring();\n    EXPECT_NE(kr, nullptr);\n\n    kr->store(\"foo\", \"bar\", \"baz\");\n    mysql_harness::flush_keyring();\n    EXPECT_TRUE(check_file_private(tmp_dir.file(\"keyring\")));\n    EXPECT_TRUE(check_file_private(tmp_dir.file(\"keyfile\")));\n\n    // this key will not be saved to disk b/c of missing flush\n    kr->store(\"account\", \"password\", \"\");\n    EXPECT_EQ(kr->fetch(\"foo\", \"bar\"), \"baz\");\n\n    EXPECT_EQ(kr->fetch(\"account\", \"password\"), \"\");\n  }\n  mysql_harness::reset_keyring();\n  EXPECT_TRUE(mysql_harness::get_keyring() == nullptr);\n\n  FileChangeChecker check_kf(tmp_dir.file(\"keyfile\"));\n  FileChangeChecker check_kr(tmp_dir.file(\"keyring\"));\n\n  EXPECT_FALSE(file_exists(tmp_dir.file(\"badkeyring\")));\n  EXPECT_TRUE(file_exists(tmp_dir.file(\"keyfile\")));\n  ASSERT_THROW(\n    mysql_harness::init_keyring(tmp_dir.file(\"badkeyring\"), tmp_dir.file(\"keyfile\"), false),\n    std::runtime_error);\n  EXPECT_FALSE(file_exists(tmp_dir.file(\"badkeyring\")));\n\n#ifndef _WIN32\n  ASSERT_THROW(\n    mysql_harness::init_keyring(\"/badkeyring\", tmp_dir.file(\"keyfile\"), false),\n    std::runtime_error);\n  EXPECT_FALSE(file_exists(\"/badkeyring\"));\n\n  ASSERT_THROW(\n    mysql_harness::init_keyring(\"/badkeyring\", tmp_dir.file(\"keyfile\"), true),\n    std::runtime_error);\n  EXPECT_FALSE(file_exists(\"/badkeyring\"));\n  EXPECT_TRUE(check_kf.check_unchanged());\n\n  ASSERT_THROW(\n    mysql_harness::init_keyring(tmp_dir.file(\"keyring\"), \"/keyfile\", false),\n    std::runtime_error);\n  EXPECT_FALSE(file_exists(\"/keyfile\"));\n\n  ASSERT_THROW(\n    mysql_harness::init_keyring(\"/keyring\", \"/keyfile\", false),\n    std::runtime_error);\n  EXPECT_FALSE(file_exists(\"/keyring\"));\n  EXPECT_FALSE(file_exists(\"/keyfile\"));\n#endif\n  ASSERT_THROW(\n    mysql_harness::init_keyring(tmp_dir.file(\"keyring\"), \"\", false),\n    std::invalid_argument);\n\n  EXPECT_TRUE(mysql_harness::get_keyring() == nullptr);\n\n  // ensure that none of the tests above touched the keyring files\n  EXPECT_TRUE(check_kf.check_unchanged());\n  EXPECT_TRUE(check_kr.check_unchanged());\n\n  EXPECT_TRUE(file_exists(tmp_dir.file(\"keyring\")));\n  EXPECT_TRUE(file_exists(tmp_dir.file(\"keyfile\")));\n  // reopen it\n  mysql_harness::init_keyring(tmp_dir.file(\"keyring\"), tmp_dir.file(\"keyfile\"), false);\n  {\n    mysql_harness::Keyring *kr = mysql_harness::get_keyring();\n\n    EXPECT_EQ(kr->fetch(\"foo\", \"bar\"), \"baz\");\n\n    ASSERT_THROW(kr->fetch(\"account\", \"password\"),\n                std::out_of_range);\n  }\n  mysql_harness::reset_keyring();\n  EXPECT_TRUE(mysql_harness::get_keyring() == nullptr);\n\n  // try to reopen keyring with bad key file\n  ASSERT_THROW(\n    mysql_harness::init_keyring(tmp_dir.file(\"keyring\"), tmp_dir.file(\"badkeyfile\"), false),\n    std::runtime_error);\n\n  // try to reopen bad keyring with right keyfile\n  ASSERT_THROW(\n    mysql_harness::init_keyring(tmp_dir.file(\"badkeyring\"), tmp_dir.file(\"keyfile\"), false),\n    std::runtime_error);\n\n  ASSERT_THROW(\n    mysql_harness::init_keyring(tmp_dir.file(\"badkeyring\"), tmp_dir.file(\"badkeyfile\"), false),\n    std::runtime_error);\n  EXPECT_TRUE(mysql_harness::get_keyring() == nullptr);\n\n  // ensure that none of the tests above touched the keyring files\n  EXPECT_TRUE(check_kf.check_unchanged());\n  EXPECT_TRUE(check_kr.check_unchanged());\n\n  // create a new keyring reusing the same keyfile, which should result in\n  // 2 master keys stored in the same keyfile\n  EXPECT_FALSE(file_exists(tmp_dir.file(\"keyring2\")));\n  mysql_harness::init_keyring(cleaner.add(tmp_dir.file(\"keyring2\")),\n                              cleaner.add(tmp_dir.file(\"keyfile\")), true);\n  EXPECT_TRUE(file_exists(tmp_dir.file(\"keyring2\")));\n  {\n    mysql_harness::Keyring *kr = mysql_harness::get_keyring();\n    EXPECT_NE(kr, nullptr);\n\n    kr->store(\"user\", \"pass\", \"hooray\");\n    mysql_harness::flush_keyring();\n    EXPECT_TRUE(check_file_private(tmp_dir.file(\"keyring2\")));\n\n    mysql_harness::flush_keyring();\n    EXPECT_TRUE(file_exists(tmp_dir.file(\"keyring2\")));\n  }\n  mysql_harness::reset_keyring();\n\n  // the orignal keyring should still be unchanged, but not the keyfile\n  bool b1 = check_kf.check_unchanged();\n  bool b2 = check_kr.check_unchanged();\n  EXPECT_FALSE(b1);\n  EXPECT_TRUE(b2);\n\n  // now try to reopen both keyrings\n  mysql_harness::init_keyring(cleaner.add(tmp_dir.file(\"keyring2\")),\n                              cleaner.add(tmp_dir.file(\"keyfile\")), false);\n  {\n    mysql_harness::Keyring *kr = mysql_harness::get_keyring();\n    EXPECT_EQ(kr->fetch(\"user\", \"pass\"), \"hooray\");\n  }\n  mysql_harness::reset_keyring();\n\n  mysql_harness::init_keyring(cleaner.add(tmp_dir.file(\"keyring\")),\n                              cleaner.add(tmp_dir.file(\"keyfile\")), false);\n  {\n    mysql_harness::Keyring *kr = mysql_harness::get_keyring();\n    EXPECT_EQ(kr->fetch(\"foo\", \"bar\"), \"baz\");\n  }\n  mysql_harness::reset_keyring();\n\n  // now try to open with bogus key file\n  ASSERT_THROW(\n    mysql_harness::init_keyring(cleaner.add(tmp_dir.file(\"keyring\")),\n                                cleaner.add(tmp_dir.file(\"keyring2\")), false),\n    std::runtime_error);\n}\n\nTEST(KeyringManager, regression) {\n  TemporaryFileCleaner cleaner;\n\n  // init keyring with no create flag was writing to existing file on open\n  mysql_harness::init_keyring(cleaner.add(tmp_dir.file(\"keyring\")),\n                              cleaner.add(tmp_dir.file(\"keyfile\")), true);\n  mysql_harness::Keyring *kr = mysql_harness::get_keyring();\n  kr->store(\"1\",\"2\", \"3\");\n  mysql_harness::flush_keyring();\n  mysql_harness::reset_keyring();\n\n  FileChangeChecker check_kf(tmp_dir.file(\"keyfile\"));\n  FileChangeChecker check_kr(tmp_dir.file(\"keyring\"));\n\n  mysql_harness::init_keyring(cleaner.add(tmp_dir.file(\"keyring\")),\n                              cleaner.add(tmp_dir.file(\"keyfile\")), false);\n  EXPECT_TRUE(check_kf.check_unchanged());\n  EXPECT_TRUE(check_kr.check_unchanged());\n\n  ASSERT_THROW(\n    mysql_harness::init_keyring(cleaner.add(tmp_dir.file(\"bogus1\")),\n                                cleaner.add(tmp_dir.file(\"bogus2\")), false),\n    std::runtime_error);\n  ASSERT_THROW(\n    mysql_harness::init_keyring(cleaner.add(tmp_dir.file(\"bogus1\")),\n                                cleaner.add(tmp_dir.file(\"keyfile\")), false),\n    std::runtime_error);\n  EXPECT_FALSE(file_exists(tmp_dir.file(\"bogus1\")));\n  EXPECT_FALSE(file_exists(tmp_dir.file(\"bogus2\")));\n\n  EXPECT_TRUE(check_kf.check_unchanged());\n  EXPECT_TRUE(check_kr.check_unchanged());\n\n  mysql_harness::reset_keyring();\n}\n"
  },
  {
    "path": "src/harness/tests/test_loader.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n// must have this first, before #includes that rely on it\n#include <gtest/gtest_prod.h>\n\n#include \"mysql/harness/loader.h\"\n#include \"mysql/harness/filesystem.h\"\n#include \"mysql/harness/plugin.h\"\n\n#include \"dim.h\"\n#include \"exception.h\"\n#include \"utilities.h\"\n\n////////////////////////////////////////\n// Test plugin include files\n#include \"magic.h\"\n\n////////////////////////////////////////\n// Test system include files\n#include \"test/helpers.h\"\n\n////////////////////////////////////////\n// Third-party include files\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n////////////////////////////////////////\n// Standard include files\n#include <algorithm>\n#include <cstdlib>\n#include <cstring>\n#include <iostream>\n#include <string>\n#include <vector>\n\nusing std::cout;\nusing std::endl;\n\nusing mysql_harness::Loader;\nusing mysql_harness::Path;\nusing mysql_harness::Plugin;\nusing mysql_harness::bad_section;\n\nusing testing::UnorderedElementsAre;\n\nPath g_here;\n\nclass LoaderTest : public ::testing::TestWithParam<const char*> {\n protected:\n  virtual void SetUp() {\n    std::map<std::string, std::string> params;\n    params[\"program\"] = \"harness\";\n    params[\"prefix\"] = g_here.c_str();\n\n    config_.reset(new mysql_harness::LoaderConfig(params, std::vector<std::string>(),\n                                                  mysql_harness::Config::allow_keys));\n    loader = new Loader(\"harness\", *config_);\n  }\n\n  virtual void TearDown() {\n    delete loader;\n    loader = nullptr;\n  }\n\n  Loader *loader;\n  std::unique_ptr<mysql_harness::LoaderConfig> config_;\n};\n\nclass LoaderReadTest : public LoaderTest {\n protected:\n  virtual void SetUp() {\n    LoaderTest::SetUp();\n    loader->get_config().read(Path(g_here).join(GetParam()));\n  }\n};\n\nTEST_P(LoaderReadTest, Available) {\n  auto lst = loader->available();\n  EXPECT_EQ(5U, lst.size());\n\n  EXPECT_SECTION_AVAILABLE(\"example\", loader);\n  EXPECT_SECTION_AVAILABLE(\"magic\", loader);\n}\n\nTEST_P(LoaderReadTest, Loading) {\n  // These should fail, for different reasons\n\n  // Test that loading something non-existant works\n  EXPECT_THROW(loader->load(\"nonexistant-plugin\"), bad_section);\n\n  // Dependent plugin do not exist\n  EXPECT_THROW(loader->load(\"bad_one\"), bad_section);\n\n  // Wrong version of dependent sections\n  EXPECT_THROW(loader->load(\"bad_two\"), bad_plugin);\n\n  // These should all be OK.\n  Plugin* ext1 = loader->load(\"example\", \"one\");\n  EXPECT_NE(ext1, nullptr);\n  EXPECT_STREQ(\"An example plugin\", ext1->brief);\n\n  Plugin* ext2 = loader->load(\"example\", \"two\");\n  EXPECT_NE(ext2, nullptr);\n  EXPECT_STREQ(\"An example plugin\", ext2->brief);\n\n  Plugin* ext3 = loader->load(\"magic\");\n  EXPECT_NE(ext3, nullptr);\n  EXPECT_STREQ(\"A magic plugin\", ext3->brief);\n}\n\nconst char *good_cfgs[] = {\n  \"data/tests-good-1.cfg\",\n  \"data/tests-good-2.cfg\",\n};\n\nINSTANTIATE_TEST_CASE_P(TestLoaderGood, LoaderReadTest,\n                        ::testing::ValuesIn(good_cfgs));\n\nTEST_P(LoaderTest, BadSection) {\n  EXPECT_THROW(loader->get_config().read(g_here.join(GetParam())), bad_section);\n}\n\n//TODO: this test is fixed in WL#10822\n#if 0\nTEST(TestStart, StartLogger) {\n  std::map<std::string, std::string> params;\n  params[\"program\"] = \"harness\";\n  params[\"prefix\"] = g_here.c_str();\n\n  Loader loader(\"harness\", params);\n  loader.read(g_here.join(\"data/tests-start-2.cfg\"));\n  loader.load_all();\n\n  loader.setup_logging();\n\n  std::exception_ptr eptr = loader.init_all();\n  ASSERT_FALSE(eptr);\n\n  // Check that all plugins have a module registered with the logger.\n  auto loggers = get_logger_names();\n  EXPECT_THAT(loggers, UnorderedElementsAre(\"main\", \"magic\"));\n}\n#endif\n\nTEST(TestStart, StartFailure) {\n  std::map<std::string, std::string> params;\n  params[\"program\"] = \"harness\";\n  params[\"prefix\"] = g_here.c_str();\n\n  mysql_harness::LoaderConfig config(params, std::vector<std::string>(), mysql_harness::Config::allow_keys);\n  config.read(g_here.join(\"data/tests-start-1.cfg\"));\n  mysql_harness::Loader loader(\"harness\", config);\n  try {\n    loader.start();\n    FAIL() << \"start() should throw std::runtime_error\";\n  } catch (const std::runtime_error& exc) {\n    EXPECT_STREQ(\"The suki was bad, please throw away\", exc.what());\n    return;\n  }\n  FAIL() << \"Did not catch expected exception\";\n}\n\nconst char *bad_cfgs[] = {\n  \"data/tests-bad-1.cfg\",\n  \"data/tests-bad-2.cfg\",\n  \"data/tests-bad-3.cfg\",\n};\n\nINSTANTIATE_TEST_CASE_P(TestLoaderBad, LoaderTest,\n                        ::testing::ValuesIn(bad_cfgs));\n\nint main(int argc, char *argv[]) {\n  g_here = Path(argv[0]).dirname();\n  init_test_logger();\n\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/harness/tests/test_loader_lifecycle.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// These unit tests test the harness for proper plugin lifecycle management.\n// They focus on four plugin API functions: init(), start(), stop() and\n// deinit(). A special plugin was written (lifecycle.cc) which is the workhorse\n// of these tests. It has configurable exit strategies (see comments in the\n// source file), which allows us to test different scenarios.\n// Also, another secondary plugin was written (lifecycle2.cc); that one is much\n// simpler and it has an (artificial) dependency on lifecycle.cc plugin. It is\n// used to help in testing initialisation/deinitialisation behaviour.\n//\n// Since we have to shutdown the harness many times, we also test the harness\n// shutdown functionality (signal handling) while testing plugin lifecycle.\n//\n////////////////////////////////////////////////////////////////////////////////\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// lifecycle test plugins dependency chart:\n//\n//                                           ,--(depends on)--> lifecycle3\n// lifecycle2 --(depends on)--> lifecycle --<\n//                                           `--(depends on)--> magic\n//\n////////////////////////////////////////////////////////////////////////////////\n\n// must have this first, before #includes that rely on it\n#include <gtest/gtest_prod.h>\n\n////////////////////////////////////////\n// Harness include files\n#include \"loader.h\"\n#include \"exception.h\"\n#include \"filesystem.h\"\n#include \"lifecycle.h\"\n#include \"mysql/harness/plugin.h\"\n#include \"test/helpers.h\"\n#include \"utilities.h\"\n#include \"mysql/harness/logging/registry.h\"\n\n////////////////////////////////////////\n// Third-party include files\n#include \"gtest/gtest.h\"\n#include \"gmock/gmock.h\"\n\n////////////////////////////////////////\n// Standard include files\n#include <algorithm>\n#include <chrono>\n#include <cstdlib>\n#include <cstring>\n#include <fstream>\n#include <future>\n#include <iostream>\n#include <signal.h>\n#include <sstream>\n#include <string>\n#include <thread>\n#include <vector>\n\n// see loader.cc for more info on this define\n#ifndef _WIN32\n# define USE_POSIX_SIGNALS\n#endif\n\n#define USE_DLCLOSE 1\n\n// disable dlclose() when built with lsan\n//\n// clang has __has_feature(address_sanitizer)\n// gcc has __SANITIZE_ADDRESS__\n#if defined(__has_feature)\n  #if __has_feature(address_sanitizer)\n#undef USE_DLCLOSE\n#define USE_DLCLOSE 0\n  #endif\n#endif\n\n#if defined(__SANITIZE_ADDRESS__) && __SANITIZE_ADDRESS__ == 1\n#undef USE_DLCLOSE\n#define USE_DLCLOSE 0\n#endif\n\n\nusing mysql_harness::Loader;\nusing mysql_harness::Path;\nusing mysql_harness::Plugin;\nusing mysql_harness::test::LifecyclePluginSyncBus;\nusing ::testing::HasSubstr;\nnamespace ch = std::chrono;\n\n\n\n// try increasing these if unit tests fail\nconst int kSleepShutdown = 10;\n\nPath g_here;\n\n\n\nclass TestLoader : public Loader {\n\n public:\n  TestLoader(const std::string& program,\n             mysql_harness::LoaderConfig& config)\n      : Loader(program, config) {\n    unittest_backdoor::set_shutdown_pending(0);\n  }\n\n  // lifecycle plugin exposes all four lifecycle functions. But we can\n  // override any of them into nullptr using this struct in\n  // init_lifecycle_plugin()\n  struct ApiFunctionEnableSwitches {\n    bool init;\n    bool start;\n    bool stop;\n    bool deinit;\n  };\n\n  void read(std::istream& stream)\n  {\n    config_.Config::read(stream);\n    config_.fill_and_check();\n  }\n\n  // Loader::load_all() with ability to disable functions\n  void load_all(ApiFunctionEnableSwitches switches)\n  {\n    Loader::load_all();\n    init_lifecycle_plugin(switches);\n  }\n\n  LifecyclePluginSyncBus& get_msg_bus_from_lifecycle_plugin(const char* key) {\n    return * lifecycle_plugin_itc_->get_bus_from_key(key);\n  }\n\n private:\n  void init_lifecycle_plugin(ApiFunctionEnableSwitches switches)\n  {\n    Plugin* plugin = plugins_.at(\"lifecycle\").plugin;\n\n#if !USE_DLCLOSE\n    // with address sanitizer we don't unload the plugin which means\n    // the overwritten plugin hooks don't get reset to their initial values\n    //\n    // we need to capture original pointers and reset them\n    // each time\n    static Plugin virgin_plugin = *plugin;\n    *plugin = virgin_plugin;\n#endif\n\n    // signal plugin to reset state and init our lifecycle_plugin_itc_\n    // (we use a special hack (tag the pointer with last bit=1) to tell it that\n    // this is not a normal init() call, but a special call meant to\n    // pre-initialize the plugin for the test). In next line, +1 = pointer tag\n    uintptr_t ptr = reinterpret_cast<uintptr_t>(&lifecycle_plugin_itc_) + 1;\n    plugin->init(reinterpret_cast<mysql_harness::PluginFuncEnv*>(ptr));\n\n    // override plugin functions as requested\n    if (!switches.init) plugin->init = nullptr;\n    if (!switches.start) plugin->start = nullptr;\n    if (!switches.stop) plugin->stop = nullptr;\n    if (!switches.deinit) plugin->deinit = nullptr;\n  }\n\n  // struct to expose additional things we need from lifecycle plugin,\n  // pointer owner = lifecycle plugin\n  mysql_harness::test::LifecyclePluginITC* lifecycle_plugin_itc_;\n}; // class TestLoader\n\n\n\nclass BasicConsoleOutputTest : public ::testing::Test {\n\n protected:\n  void clear_log() {\n    log.str(\"\");\n    log.clear();\n  }\n\n  std::stringstream log;\n\n private:\n  void SetUp() {\n    std::ostream *log_stream = mysql_harness::logging::get_default_logger_stream();\n\n    orig_log_stream_ = log_stream->rdbuf();\n    log_stream->rdbuf(log.rdbuf());\n  }\n\n  void TearDown() {\n    if (orig_log_stream_) {\n      std::ostream *log_stream = mysql_harness::logging::get_default_logger_stream();\n      log_stream->rdbuf(orig_log_stream_);\n    }\n  }\n\n  std::streambuf* orig_log_stream_;\n};\n\nclass LifecycleTest : public BasicConsoleOutputTest {\n public:\n\n  LifecycleTest() :\n      params_{ {\"program\", \"harness\"}, {\"prefix\", g_here.c_str()} },\n      config_(params_, std::vector<std::string>(), mysql_harness::Config::allow_keys),\n      loader_(\"harness\", config_) {\n    config_text_ <<\n      \"[DEFAULT]                                      \\n\"\n#ifndef _WIN32\n      \"logging_folder =                               \\n\"\n      \"plugin_folder  = {prefix}/../../stage/lib/mysqlrouter\\n\"\n      \"runtime_folder = {prefix}/var/run/{program}    \\n\"\n      \"config_folder  = {prefix}/var/run/{program}    \\n\"\n      \"data_folder    = {prefix}/../../stage/lib/mysqlrouter\\n\"\n#elif defined(CMAKE_INTDIR)\n      \"logging_folder = \\n\"\n      \"plugin_folder  = {prefix}/../../../stage/\" CMAKE_INTDIR \"/lib\\n\"\n      \"runtime_folder = {prefix}/var/run\\n\"\n      \"config_folder  = {prefix}/etc\\n\"\n      \"data_folder    = {prefix}/var/lib\\n\"\n#else\n      \"logging_folder = \\n\"\n      \"plugin_folder  = {prefix}/../../../stage/lib\\n\"\n      \"runtime_folder = {prefix}/var/run\\n\"\n      \"config_folder  = {prefix}/etc\\n\"\n      \"data_folder    = {prefix}/var/lib\\n\"\n#endif\n// TODO: restore this after after [logger] hack is reverted (grep for g_HACK_default_log_level)\n//    \"                                               \\n\"\n//    \"[logger]                                       \\n\"\n//    \"level = DEBUG                                  \\n\"\n      \"                                               \\n\"\n      \"[lifecycle3]                                   \\n\"\n      \"                                               \\n\"\n      \"[magic]                                        \\n\"\n      \"suki = magic                                   \\n\"\n      \"                                               \\n\"\n      \"[lifecycle:instance1]                          \\n\";\n  }\n\n  void init_test(std::istream& config_text,\n                 TestLoader::ApiFunctionEnableSwitches switches\n                 = {true, true, true, true} ) {\n    loader_.read(config_text);\n    loader_.load_all(switches);\n    clear_log();\n  }\n\n  void init_test_without_lifecycle_plugin(std::istream& config_text) {\n    loader_.read(config_text);\n    clear_log();\n  }\n\n  void refresh_log() {\n    // the getline() loop below runs until EOF, therefore on subsequent calls\n    // we need to clear the EOF flag before we can read again\n    log.clear();\n\n    std::string line;\n    while (std::getline(log, line)) {\n      log_lines_.push_back(line);\n    }\n  }\n\n  // NOTE:\n  // Despite the name, LifecyclePluginSyncBus is additionally used for 2-way\n  // synchronisation (please rename it if you have a better name). This is\n  // because if we freeze_bus(), an attempt to pass another message from plugin\n  // will block it, until we unfreeze_and_wait_for_msg().\n\n  LifecyclePluginSyncBus& msg_bus(const char* key) {\n    return loader_.get_msg_bus_from_lifecycle_plugin(key);\n  }\n\n  void freeze_bus(LifecyclePluginSyncBus& bus) {\n    bus.mtx.lock();  // so that we don't miss a signal\n  }\n\n  void unfreeze_and_wait_for_msg(LifecyclePluginSyncBus& bus, const char* msg) {\n    std::unique_lock<std::mutex> lock(bus.mtx, std::adopt_lock);\n\n    // block until we receive message we're interested in\n    bus.cv.wait(lock, [&bus, msg](){\n      return bus.msg.find(msg) != bus.msg.npos;\n    });\n  }\n\n  long count_in_log(const char* needle) {\n    long cnt = 0;\n    for (const std::string& line : log_lines_)\n      if (line.find(needle) != line.npos)\n        cnt++;\n    return cnt;\n  }\n\n  const std::map<std::string, std::string> params_;\n  mysql_harness::LoaderConfig config_;\n  TestLoader        loader_;\n  std::stringstream config_text_;\n\n  std::vector<std::string> log_lines_;\n}; // class LifecycleTest\n\n\n\nvoid delayed_shutdown() {\n  std::this_thread::sleep_for(ch::milliseconds(kSleepShutdown));\n  request_application_shutdown();\n}\n\nint time_diff(const ch::time_point<ch::steady_clock>& t0,\n              const ch::time_point<ch::steady_clock>& t1) {\n\n  ch::milliseconds duration = ch::duration_cast<ch::milliseconds>(t1 - t0);\n  return static_cast<int>(duration.count());\n}\n\nvoid run_then_signal_shutdown(const std::function<void()>& l) {\n  ch::time_point<ch::steady_clock> t0 = ch::steady_clock::now();\n  std::thread(delayed_shutdown).detach();\n  l();\n  ch::time_point<ch::steady_clock> t1 = ch::steady_clock::now();\n  EXPECT_LE(kSleepShutdown, time_diff(t0, t1));\n}\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// UNIT TESTS: PLATFORM SPECIFIC STUFF\n//\n////////////////////////////////////////////////////////////////////////////////\n\nTEST(StdLibrary, FutureWaitUntil) {\n\n  // Here we test undocumented/ambiguous behaviour of std::future::wait_until():\n  // what will be returned when you call it when future is ready BUT\n  // timeout is expired? In principle, both return values are plausible:\n  //\n  //   future_status::ready\n  //   future_status::timeout\n  //\n  // On Ubuntu 14.04, it returns future_status::ready, which seems reasonable.\n  // However to ensure it works all platforms, we have a unit test here to to\n  // guard against a nasty surprise in Loader::main_loop() which relies on this\n  // behaviour.\n\n  // fulfill the promise\n  std::promise<int> p;\n  std::future<int>  f = p.get_future();\n  p.set_value(42);\n\n  // set timeout\n  ch::steady_clock::time_point timepoint =\n      ch::steady_clock::now() + ch::milliseconds(10);\n\n  // sleep beyond the timeout\n  std::this_thread::sleep_for(ch::milliseconds(30));\n\n  // wait_until() should return that our future is ready,\n  // regardless of the expired timeout\n  std::future_status status = f.wait_until(timepoint);\n  ASSERT_EQ(std::future_status::ready, status);\n  EXPECT_EQ(42, f.get());\n}\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// UNIT TESTS: SIMPLE\n//\n////////////////////////////////////////////////////////////////////////////////\n\n// 2017.03.24: at the time of writing, this is what the \"meat\" of Loader looked\n// like. In the tests below, load_all() is executed in TestLoader::load_all()\n// (called from init_test()), and run() (either as a whole or in parts)\n// should be called directly from unit tests.\n//\n//   void Loader::start() {\n//     load_all();\n//     std::exception_ptr first_eptr = run();\n//     unload_all();\n//\n//     if (first_eptr) {\n//       std::rethrow_exception(first_eptr);\n//     }\n//   }\n//\n//   void Loader::load_all() {\n//     platform_specific_init();\n//     for (std::pair<const std::string&, std::string> name : available()) {\n//       load(name.first, name.second);\n//     }\n//   }\n//\n//   std::exception_ptr Loader::run() {\n//\n//     // initialize plugins\n//     std::exception_ptr first_eptr = init_all();\n//\n//     // run plugins if initialization didn't fail\n//     if (!first_eptr) {\n//       start_all();  // if start() throws, exception is forwarded to main_loop()\n//       first_eptr = main_loop(); // calls stop_all() before exiting\n//     }\n//     assert(plugin_start_env_.empty());  // stop_all() should have ran and cleaned them up\n//\n//     // deinitialize plugins\n//     std::exception_ptr tmp = deinit_all();\n//     if (!first_eptr) {\n//       first_eptr = tmp;\n//     }\n//\n//     // return the first exception that was triggered by an error returned from\n//     // any plugin function\n//     return first_eptr;\n//   }\n\nTEST_F(LifecycleTest, Simple_None) {\n  init_test(config_text_, {false, false, false, false});\n\n  EXPECT_EQ(loader_.init_all(),   nullptr);\n  loader_.start_all();\n  EXPECT_EQ(loader_.main_loop(),  nullptr);\n  EXPECT_EQ(loader_.deinit_all(), nullptr);\n\n  const std::list<std::string> initialized = {\"magic\", \"lifecycle3\", \"lifecycle\"};\n  EXPECT_EQ(initialized, loader_.order_);\n\n  refresh_log();\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all init():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all init():EXIT\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 start():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 start():EXIT\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 stop():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 stop():EXIT\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():EXIT\"));\n}\n\nTEST_F(LifecycleTest, Simple_AllFunctions) {\n  config_text_ << \"init   = exit           \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = exit           \\n\"\n               << \"deinit = exit           \\n\";\n  init_test(config_text_, {true, true, true, true});\n  LifecyclePluginSyncBus& bus = msg_bus(\"instance1\");\n\n  EXPECT_EQ(loader_.init_all(), nullptr);\n  freeze_bus(bus);\n  loader_.start_all();\n  unfreeze_and_wait_for_msg(bus, \"lifecycle:instance1 start():EXIT_ON_STOP:sleeping\");\n\n  const std::list<std::string> initialized = {\"magic\", \"lifecycle3\", \"lifecycle\"};\n  EXPECT_EQ(initialized, loader_.order_);\n\n  refresh_log();\n  EXPECT_EQ(1, count_in_log(\"lifecycle:all init():begin\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:all init():EXIT.\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 start():begin\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 start():EXIT_ON_STOP:sleeping\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 start():EXIT_ON_STOP:done\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 stop():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 stop():EXIT\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():EXIT\"));\n\n  // signal shutdown after 10ms, main_loop() should block until then\n  run_then_signal_shutdown([&](){ EXPECT_EQ(loader_.main_loop(), nullptr); });\n\n  refresh_log();\n  EXPECT_EQ(1, count_in_log(\"Shutting down. Stopping all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 start():EXIT_ON_STOP:done\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 stop():begin\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 stop():EXIT.\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():EXIT.\"));\n\n  EXPECT_EQ(loader_.deinit_all(), nullptr);\n\n  refresh_log();\n  EXPECT_EQ(1, count_in_log(\"lifecycle:all deinit():begin\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:all deinit():EXIT.\"));\n}\n\nTEST_F(LifecycleTest, Simple_Init) {\n  config_text_ << \"init = exit\\n\";\n  init_test(config_text_, {true, false, false, false});\n\n  EXPECT_EQ(loader_.init_all(), nullptr);\n            loader_.start_all();\n  EXPECT_EQ(loader_.main_loop(), nullptr);\n  EXPECT_EQ(loader_.deinit_all(), nullptr);\n\n  const std::list<std::string> initialized = {\"magic\", \"lifecycle3\", \"lifecycle\"};\n  EXPECT_EQ(initialized, loader_.order_);\n\n  refresh_log();\n  EXPECT_EQ(1, count_in_log(\"lifecycle:all init():begin\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:all init():EXIT\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 start():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 start():EXIT\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 stop():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 stop():EXIT\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():EXIT\"));\n}\n\nTEST_F(LifecycleTest, Simple_StartStop) {\n  config_text_ << \"start = exitonstop\\n\";\n  config_text_ << \"stop  = exit\\n\";\n  init_test(config_text_, {false, true, true, false});\n  LifecyclePluginSyncBus& bus = msg_bus(\"instance1\");\n\n  EXPECT_EQ(loader_.init_all(), nullptr);\n  freeze_bus(bus);\n  loader_.start_all();\n  unfreeze_and_wait_for_msg(bus, \"lifecycle:instance1 start():EXIT_ON_STOP:sleeping\");\n\n  const std::list<std::string> initialized = {\"magic\", \"lifecycle3\", \"lifecycle\"};\n  EXPECT_EQ(initialized, loader_.order_);\n\n  refresh_log();\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all init():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all init():EXIT.\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 start():begin\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 start():EXIT_ON_STOP:sleeping\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 start():EXIT_ON_STOP:done\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 stop():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 stop():EXIT\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():EXIT\"));\n\n  // signal shutdown after 10ms, main_loop() should block until then\n  run_then_signal_shutdown([&](){ EXPECT_EQ(loader_.main_loop(), nullptr); });\n\n  EXPECT_EQ(loader_.deinit_all(), nullptr);\n\n  refresh_log();\n  EXPECT_EQ(1, count_in_log(\"Shutting down. Stopping all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 start():EXIT_ON_STOP:done\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 stop():begin\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 stop():EXIT.\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():EXIT.\"));\n}\n\nTEST_F(LifecycleTest, Simple_StartStopBlocking) {\n  // Same test as Simple_StartStop, but start() uses blocking API call to wait\n  // until told to shut down, vs actively polling the \"running\" flag\n\n  config_text_ << \"start = exitonstop_s\\n\"; // <--- note the \"_s\" postfix\n  config_text_ << \"stop  = exit\\n\";\n  init_test(config_text_, {false, true, true, false});\n  LifecyclePluginSyncBus& bus = msg_bus(\"instance1\");\n\n  EXPECT_EQ(loader_.init_all(), nullptr);\n  freeze_bus(bus);\n  loader_.start_all();\n  unfreeze_and_wait_for_msg(bus, \"lifecycle:instance1 start():EXIT_ON_STOP_SYNC:sleeping\");\n\n  const std::list<std::string> initialized = {\"magic\", \"lifecycle3\", \"lifecycle\"};\n  EXPECT_EQ(initialized, loader_.order_);\n\n  refresh_log();\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all init():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all init():EXIT.\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 start():begin\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 start():EXIT_ON_STOP_SYNC:sleeping\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 start():EXIT_ON_STOP_SYNC:done\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 stop():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 stop():EXIT\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():EXIT\"));\n\n  // signal shutdown after 10ms, main_loop() should block until then\n  run_then_signal_shutdown([&](){ EXPECT_EQ(loader_.main_loop(), nullptr); });\n\n  EXPECT_EQ(loader_.deinit_all(), nullptr);\n\n  refresh_log();\n  EXPECT_EQ(1, count_in_log(\"Shutting down. Stopping all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 start():EXIT_ON_STOP_SYNC:done\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 stop():begin\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 stop():EXIT.\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():EXIT.\"));\n}\n\nTEST_F(LifecycleTest, Simple_Start) {\n  config_text_ << \"start = exitonstop\\n\";\n  init_test(config_text_, {false, true, false, false});\n  LifecyclePluginSyncBus& bus = msg_bus(\"instance1\");\n\n  EXPECT_EQ(loader_.init_all(), nullptr);\n  freeze_bus(bus);\n  loader_.start_all();\n  unfreeze_and_wait_for_msg(bus, \"lifecycle:instance1 start():EXIT_ON_STOP:sleeping\");\n\n  const std::list<std::string> initialized = {\"magic\", \"lifecycle3\", \"lifecycle\"};\n  EXPECT_EQ(initialized, loader_.order_);\n\n  refresh_log();\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all init():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all init():EXIT.\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 start():begin\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 start():EXIT_ON_STOP:sleeping\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 start():EXIT_ON_STOP:done\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 stop():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 stop():EXIT\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():EXIT\"));\n\n  // signal shutdown after 10ms, main_loop() should block until then\n  run_then_signal_shutdown([&](){ EXPECT_EQ(loader_.main_loop(), nullptr); });\n\n  EXPECT_EQ(loader_.deinit_all(), nullptr);\n\n  refresh_log();\n  EXPECT_EQ(1, count_in_log(\"Shutting down. Stopping all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 start():EXIT_ON_STOP:done\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 stop():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 stop():EXIT.\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():EXIT.\"));\n}\n\nTEST_F(LifecycleTest, Simple_Stop) {\n  config_text_ << \"stop = exit\\n\";\n  init_test(config_text_, {false, false, true, false});\n\n  EXPECT_EQ(loader_.init_all(), nullptr);\n            loader_.start_all();\n\n  const std::list<std::string> initialized = {\"magic\", \"lifecycle3\", \"lifecycle\"};\n  EXPECT_EQ(initialized, loader_.order_);\n\n  refresh_log();\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all init():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all init():EXIT\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 start():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 start():EXIT\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 stop():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 stop():EXIT\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():EXIT\"));\n\n  EXPECT_EQ(loader_.main_loop(), nullptr);\n\n  refresh_log();\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 stop():begin\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 stop():EXIT\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():EXIT\"));\n\n  EXPECT_EQ(loader_.deinit_all(), nullptr);\n\n  refresh_log();\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():EXIT\"));\n}\n\nTEST_F(LifecycleTest, Simple_Deinit) {\n  config_text_ << \"deinit = exit\\n\";\n  init_test(config_text_, {false, false, false, true});\n\n  EXPECT_EQ(loader_.init_all(), nullptr);\n            loader_.start_all();\n  EXPECT_EQ(loader_.main_loop(), nullptr);\n\n  const std::list<std::string> initialized = {\"magic\", \"lifecycle3\", \"lifecycle\"};\n  EXPECT_EQ(initialized, loader_.order_);\n\n  refresh_log();\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all init():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all init():EXIT\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 start():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 start():EXIT\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 stop():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 stop():EXIT\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:all deinit():EXIT\"));\n\n  EXPECT_EQ(loader_.deinit_all(), nullptr);\n\n  refresh_log();\n  EXPECT_EQ(1, count_in_log(\"lifecycle:all deinit():begin\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:all deinit():EXIT\"));\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// UNIT TESTS: COMPLEX\n//\n////////////////////////////////////////////////////////////////////////////////\n\nTEST_F(LifecycleTest, ThreeInstances_NoError) {\n  // In this testcase we do thorough checking, and provide elaborate comments.\n  // We won't do it in other tests, so read this one for better understanding\n  // of others.\n\n  // init() and deinit() config is taken from first instance. This is because\n  // init() and deinit() run only once per plugin, not per plugin instance.\n  config_text_ << \"init   = exit           \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = exit           \\n\"\n               << \"deinit = exit           \\n\"\n               << \"                        \\n\"\n               << \"[lifecycle:instance2]   \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = exit           \\n\"\n               << \"                        \\n\"\n               << \"[lifecycle:instance3]   \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = exit           \\n\";\n  init_test(config_text_);\n\n  // signal shutdown after 10ms, run() should block until then\n  run_then_signal_shutdown([&](){ loader_.run(); });\n\n  // all 3 plugins should have remained on the list of \"to be deinitialized\",\n  // since they all should have initialized properly\n  const std::list<std::string> initialized = {\"magic\", \"lifecycle3\", \"lifecycle\"};\n  EXPECT_EQ(initialized, loader_.order_);\n\n  refresh_log();\n\n  // initialisation proceeds in defined order\n  EXPECT_EQ(1, count_in_log(\"Initializing all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic' initializing\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic' init exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3' initializing\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3' init exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' initializing\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' init exit ok\"));\n\n  // plugins may be started in arbitrary order (they run in separate threads)\n  EXPECT_EQ(1, count_in_log(\"Starting all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3:' doesn't implement start()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' starting\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance2' starting\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance3' starting\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic:' starting\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic:' start exit ok\"));\n\n  // similarly, they may stop in arbitrary order\n  EXPECT_EQ(1, count_in_log(\"Shutting down. Stopping all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' stopping\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' stop exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance2' stopping\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance2' stop exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance3' stopping\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance3' stop exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3:' doesn't implement stop()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic:' doesn't implement stop()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance2' start exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance3' start exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' start exit ok\"));\n\n  // deinitializasation proceeds in reverse order of initialisation\n  EXPECT_EQ(1, count_in_log(\"Deinitializing all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' deinitializing\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3' deinitializing\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic' doesn't implement deinit()\"));\n\n  // this is a sunny day scenario, nothing should fail\n  EXPECT_EQ(0, count_in_log(\"failed\"));\n\n  // failure messages would look like this:\n  // init()   -> \"plugin 'lifecycle' init failed: <message>\"\n  // start()  -> \"plugin 'lifecycle:instance1' start terminated with exception: <message>\"\n  // stop()   -> \"plugin 'lifecycle:instance1' stop failed: <message>\"\n  // deinit() -> \"plugin 'lifecycle' deinit failed: <message>\"\n}\n\nTEST_F(LifecycleTest, BothLifecycles_NoError) {\n  config_text_ << \"init   = exit           \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = exit           \\n\"\n               << \"deinit = exit           \\n\"\n               << \"                        \\n\"\n               << \"[lifecycle2]            \\n\";\n  init_test(config_text_);\n\n  // signal shutdown after 10ms, run() should block until then\n  run_then_signal_shutdown([&](){ loader_.run(); });\n\n  const std::list<std::string> initialized =\n      {\"magic\", \"lifecycle3\", \"lifecycle\", \"lifecycle2\"};\n  EXPECT_EQ(initialized, loader_.order_);\n\n  refresh_log();\n\n  EXPECT_EQ(1, count_in_log(\"Initializing all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic' init exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3' init exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' init exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle2' init exit ok\"));\n\n  EXPECT_EQ(1, count_in_log(\"Starting all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3:' doesn't implement start()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' starting\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle2:' start exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic:' start exit ok\"));\n\n  EXPECT_EQ(1, count_in_log(\"Shutting down. Stopping all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' stop exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle2:' stop exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3:' doesn't implement stop()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic:' doesn't implement stop()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' start exit ok\"));\n\n  EXPECT_EQ(1, count_in_log(\"Deinitializing all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle2' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic' doesn't implement deinit()\"));\n\n  EXPECT_EQ(0, count_in_log(\"failed\"));\n}\n\nTEST_F(LifecycleTest, OneInstance_NothingPersists_NoError) {\n  config_text_ << \"init   = exit           \\n\"\n               << \"start  = exit           \\n\"\n               << \"stop   = exit           \\n\"\n               << \"deinit = exit           \\n\";\n  init_test(config_text_);\n\n  // Router should just shut down on it's own, since there's nothing to run\n  // (all plugin start() functions just exit)\n  loader_.run();\n\n  refresh_log();\n\n  EXPECT_EQ(1, count_in_log(\"Initializing all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic' init exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3' init exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' init exit ok\"));\n\n  EXPECT_EQ(1, count_in_log(\"Starting all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic:' start exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3:' doesn't implement start()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' starting\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' start exit ok\"));\n\n  EXPECT_EQ(1, count_in_log(\"Shutting down. Stopping all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' stop exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3:' doesn't implement stop()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic:' doesn't implement stop()\"));\n\n  EXPECT_EQ(1, count_in_log(\"Deinitializing all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic' doesn't implement deinit()\"));\n\n  EXPECT_EQ(0, count_in_log(\"failed\"));\n}\n\nTEST_F(LifecycleTest, OneInstance_NothingPersists_StopFails) {\n  config_text_ << \"init   = exit           \\n\"\n               << \"start  = exit           \\n\"\n               << \"stop   = error          \\n\"\n               << \"deinit = exit           \\n\";\n  init_test(config_text_);\n\n  // Router should just shut down on it's own, since there's nothing to run\n  // (all plugin start() functions just exit)\n  try {\n    std::exception_ptr e = loader_.run();\n    if (e) std::rethrow_exception(e);\n    FAIL() << \"stop() should throw std::runtime_error\";\n  } catch (const std::runtime_error& e) {\n    EXPECT_STREQ(\"lifecycle:instance1 stop(): I'm returning error!\", e.what());\n  } catch (...) {\n    FAIL() << \"stop() should throw std::runtime_error\";\n  }\n\n  refresh_log();\n\n  EXPECT_EQ(1, count_in_log(\"Initializing all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic' init exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3' init exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' init exit ok\"));\n\n  EXPECT_EQ(1, count_in_log(\"Starting all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3:' doesn't implement start()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' starting\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' start exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic:' start exit ok\"));\n\n  EXPECT_EQ(1, count_in_log(\"Shutting down. Stopping all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' stop failed: \"\n                                      \"lifecycle:instance1 stop(): I'm returning error!\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3:' doesn't implement stop()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic:' doesn't implement stop()\"));\n\n  EXPECT_EQ(1, count_in_log(\"Deinitializing all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic' doesn't implement deinit()\"));\n}\n\nTEST_F(LifecycleTest, ThreeInstances_InitFails) {\n  config_text_ << \"init   = error          \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = exit           \\n\"\n               << \"deinit = exit           \\n\"\n               << \"                        \\n\"\n               << \"[lifecycle:instance2]   \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = exit           \\n\"\n               << \"                        \\n\"\n               << \"[lifecycle:instance3]   \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = exit           \\n\";\n  init_test(config_text_);\n\n  try {\n    std::exception_ptr e = loader_.run();\n    if (e) std::rethrow_exception(e);\n    FAIL() << \"init() should throw std::runtime_error\";\n  } catch (const std::runtime_error& e) {\n    EXPECT_STREQ(\"lifecycle:all init(): I'm returning error!\", e.what());\n  } catch (...) {\n    FAIL() << \"init() should throw std::runtime_error\";\n  }\n\n  // lifecycle should not be on the list of to-be-deinitialized, since it\n  // failed initialisation\n  const std::list<std::string> initialized = {\"magic\", \"lifecycle3\"};\n  EXPECT_EQ(initialized, loader_.order_);\n\n  refresh_log();\n\n  // lifecycle2 should not be initialized\n  EXPECT_EQ(1, count_in_log(\"Initializing all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic' init exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3' init exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' init failed: \"\n                                      \"lifecycle:all init(): I'm returning error!\"));\n  // start() and stop() shouldn't run\n  EXPECT_EQ(0, count_in_log(\"Starting all plugins.\"));\n  EXPECT_EQ(0, count_in_log(\"Shutting down. Stopping all plugins.\"));\n\n  // lifecycle2 should not be deinintialized\n  EXPECT_EQ(1, count_in_log(\"Deinitializing all plugins.\"));\n  EXPECT_EQ(0, count_in_log(\"  plugin 'lifecycle' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic' doesn't implement deinit()\"));\n}\n\nTEST_F(LifecycleTest, BothLifecycles_InitFails) {\n  config_text_ << \"init   = error          \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = exit           \\n\"\n               << \"deinit = exit           \\n\"\n               << \"                        \\n\"\n               << \"[lifecycle2]            \\n\";\n  init_test(config_text_);\n\n  try {\n    std::exception_ptr e = loader_.run();\n    if (e) std::rethrow_exception(e);\n    FAIL() << \"init() should throw std::runtime_error\";\n  } catch (const std::runtime_error& e) {\n    EXPECT_STREQ(\"lifecycle:all init(): I'm returning error!\", e.what());\n  } catch (...) {\n    FAIL() << \"init() should throw std::runtime_error\";\n  }\n\n  // lifecycle should not be on the list of to-be-deinitialized, since it\n  // failed initialisation; neither should lifecycle2, because it never reached\n  // initialisation phase\n  const std::list<std::string> initialized = {\"magic\", \"lifecycle3\"};\n  EXPECT_EQ(initialized, loader_.order_);\n\n  refresh_log();\n\n  // lifecycle2 should not be initialized\n  EXPECT_EQ(1, count_in_log(\"Initializing all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic' init exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3' init exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' initializing\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' init failed: \"\n                                      \"lifecycle:all init(): I'm returning error!\"));\n  EXPECT_EQ(0, count_in_log(\"  plugin 'lifecycle2' initializing\"));\n\n  // start() and stop() shouldn't run\n  EXPECT_EQ(0, count_in_log(\"Starting all plugins.\"));\n  EXPECT_EQ(0, count_in_log(\"Shutting down. Stopping all plugins.\"));\n\n  // lifecycle2 should not be deinintialized\n  EXPECT_EQ(1, count_in_log(\"Deinitializing all plugins.\"));\n  EXPECT_EQ(0, count_in_log(\"  plugin 'lifecycle2' deinitializing\"));\n  EXPECT_EQ(0, count_in_log(\"  plugin 'lifecycle' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic' doesn't implement deinit()\"));\n}\n\nTEST_F(LifecycleTest, ThreeInstances_Start1Fails) {\n  config_text_ << \"init   = exit           \\n\"\n               << \"start  = error          \\n\"\n               << \"stop   = exit           \\n\"\n               << \"deinit = exit           \\n\"\n               << \"                        \\n\"\n               << \"[lifecycle:instance2]   \\n\"\n               << \"start  = exit           \\n\"\n               << \"stop   = exit           \\n\"\n               << \"                        \\n\"\n               << \"[lifecycle:instance3]   \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = exit           \\n\";\n  init_test(config_text_);\n\n  try {\n    std::exception_ptr e = loader_.run();\n    if (e) std::rethrow_exception(e);\n    FAIL() << \"start() should throw std::runtime_error\";\n  } catch (const std::runtime_error& e) {\n    EXPECT_STREQ(\"lifecycle:instance1 start(): I'm returning error!\", e.what());\n  } catch (...) {\n    FAIL() << \"start() should throw std::runtime_error\";\n  }\n\n  const std::list<std::string> initialized = {\"magic\", \"lifecycle3\", \"lifecycle\"};\n  EXPECT_EQ(initialized, loader_.order_);\n\n  refresh_log();\n\n  EXPECT_EQ(1, count_in_log(\"Initializing all plugins.\"));\n\n  EXPECT_EQ(1, count_in_log(\"Starting all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic:' start exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3:' doesn't implement start()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' start failed: \"\n                   \"lifecycle:instance1 start(): I'm returning error!\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance2' starting\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance3' starting\"));\n\n  EXPECT_EQ(1, count_in_log(\"Shutting down. Stopping all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic:' doesn't implement stop()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3:' doesn't implement stop()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance2' stop exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance3' stop exit ok\"));\n\n  EXPECT_EQ(1, count_in_log(\"Deinitializing all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic' doesn't implement deinit()\"));\n}\n\nTEST_F(LifecycleTest, ThreeInstances_Start2Fails) {\n  config_text_ << \"init   = exit           \\n\"\n               << \"start  = exit           \\n\"\n               << \"stop   = exit           \\n\"\n               << \"deinit = exit           \\n\"\n               << \"                        \\n\"\n               << \"[lifecycle:instance2]   \\n\"\n               << \"start  = error          \\n\"\n               << \"stop   = exit           \\n\"\n               << \"                        \\n\"\n               << \"[lifecycle:instance3]   \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = exit           \\n\";\n  init_test(config_text_);\n\n  try {\n    std::exception_ptr e = loader_.run();\n    if (e) std::rethrow_exception(e);\n    FAIL() << \"start() should throw std::runtime_error\";\n  } catch (const std::runtime_error& e) {\n    EXPECT_STREQ(\"lifecycle:instance2 start(): I'm returning error!\", e.what());\n  } catch (...) {\n    FAIL() << \"start() should throw std::runtime_error\";\n  }\n\n  const std::list<std::string> initialized = {\"magic\", \"lifecycle3\", \"lifecycle\"};\n  EXPECT_EQ(initialized, loader_.order_);\n\n  refresh_log();\n\n  EXPECT_EQ(1, count_in_log(\"Initializing all plugins.\"));\n\n  EXPECT_EQ(1, count_in_log(\"Starting all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic:' start exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3:' doesn't implement start()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' starting\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance2' start failed: \"\n                   \"lifecycle:instance2 start(): I'm returning error!\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance3' starting\"));\n\n  EXPECT_EQ(1, count_in_log(\"Shutting down. Stopping all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic:' doesn't implement stop()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3:' doesn't implement stop()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' stop exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance3' stop exit ok\"));\n\n  EXPECT_EQ(1, count_in_log(\"Deinitializing all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic' doesn't implement deinit()\"));\n}\n\nTEST_F(LifecycleTest, ThreeInstances_Start3Fails) {\n  config_text_ << \"init   = exit           \\n\"\n               << \"start  = exit           \\n\"\n               << \"stop   = exit           \\n\"\n               << \"deinit = exit           \\n\"\n               << \"                        \\n\"\n               << \"[lifecycle:instance2]   \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = exit           \\n\"\n               << \"                        \\n\"\n               << \"[lifecycle:instance3]   \\n\"\n               << \"start  = error          \\n\"\n               << \"stop   = exit           \\n\";\n  init_test(config_text_);\n\n  try {\n    std::exception_ptr e = loader_.run();\n    if (e) std::rethrow_exception(e);\n    FAIL() << \"start() should throw std::runtime_error\";\n  } catch (const std::runtime_error& e) {\n    EXPECT_STREQ(\"lifecycle:instance3 start(): I'm returning error!\", e.what());\n  } catch (...) {\n    FAIL() << \"start() should throw std::runtime_error\";\n  }\n\n  const std::list<std::string> initialized = {\"magic\", \"lifecycle3\", \"lifecycle\"};\n  EXPECT_EQ(initialized, loader_.order_);\n\n  refresh_log();\n\n  EXPECT_EQ(1, count_in_log(\"Initializing all plugins.\"));\n\n  EXPECT_EQ(1, count_in_log(\"Starting all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic:' start exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3:' doesn't implement start()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' starting\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance2' starting\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance3' start failed: \"\n                   \"lifecycle:instance3 start(): I'm returning error!\"));\n\n  EXPECT_EQ(1, count_in_log(\"Shutting down. Stopping all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic:' doesn't implement stop()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3:' doesn't implement stop()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' stop exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance2' stop exit ok\"));\n\n  EXPECT_EQ(1, count_in_log(\"Deinitializing all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic' doesn't implement deinit()\"));\n}\n\nTEST_F(LifecycleTest, ThreeInstances_2StartsFail) {\n  config_text_ << \"init   = exit           \\n\"\n               << \"start  = error          \\n\"\n               << \"stop   = exit           \\n\"\n               << \"deinit = exit           \\n\"\n               << \"                        \\n\"\n               << \"[lifecycle:instance2]   \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = exit           \\n\"\n               << \"                        \\n\"\n               << \"[lifecycle:instance3]   \\n\"\n               << \"start  = error          \\n\"\n               << \"stop   = exit           \\n\";\n  init_test(config_text_);\n\n  try {\n    std::exception_ptr e = loader_.run();\n    if (e) std::rethrow_exception(e);\n    FAIL() << \"start() should throw std::runtime_error\";\n  } catch (const std::runtime_error& e) {\n    // instance1 or instance3, undeterministic\n    EXPECT_TRUE(strstr(e.what(), \"start(): I'm returning error!\"));\n  } catch (...) {\n    FAIL() << \"start() should throw std::runtime_error\";\n  }\n\n  const std::list<std::string> initialized = {\"magic\", \"lifecycle3\", \"lifecycle\"};\n  EXPECT_EQ(initialized, loader_.order_);\n\n  refresh_log();\n\n  EXPECT_EQ(1, count_in_log(\"Initializing all plugins.\"));\n\n  EXPECT_EQ(1, count_in_log(\"Starting all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic:' start exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3:' doesn't implement start()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' start failed: \"\n                   \"lifecycle:instance1 start(): I'm returning error!\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance2' starting\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance3' start failed: \"\n                   \"lifecycle:instance3 start(): I'm returning error!\"));\n\n  EXPECT_EQ(1, count_in_log(\"Shutting down. Stopping all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic:' doesn't implement stop()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3:' doesn't implement stop()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance2' stop exit ok\"));\n\n  EXPECT_EQ(1, count_in_log(\"Deinitializing all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic' doesn't implement deinit()\"));\n}\n\nTEST_F(LifecycleTest, ThreeInstances_StopFails) {\n  config_text_ << \"init   = exit           \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = exit           \\n\"\n               << \"deinit = exit           \\n\"\n               << \"                        \\n\"\n               << \"[lifecycle:instance2]   \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = error          \\n\"\n               << \"                        \\n\"\n               << \"[lifecycle:instance3]   \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = exit           \\n\";\n  init_test(config_text_);\n\n  // signal shutdown after 10ms, run() should block until then\n  run_then_signal_shutdown([&](){\n    try {\n      std::exception_ptr e = loader_.run();\n      if (e) std::rethrow_exception(e);\n      FAIL() << \"stop() should throw std::runtime_error\";\n    } catch (const std::runtime_error& e) {\n      EXPECT_STREQ(\"lifecycle:instance2 stop(): I'm returning error!\", e.what());\n    } catch (...) {\n      FAIL() << \"stop() should throw std::runtime_error\";\n    }\n  });\n\n  refresh_log();\n\n  EXPECT_EQ(1, count_in_log(\"Initializing all plugins.\"));\n\n  EXPECT_EQ(1, count_in_log(\"Starting all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic:' starting\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic:' start exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3:' doesn't implement start()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' starting\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance2' starting\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance3' starting\"));\n\n  EXPECT_EQ(1, count_in_log(\"Shutting down. Stopping all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic:' doesn't implement stop()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3:' doesn't implement stop()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' stop exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance2' stop failed: \"\n                                \"lifecycle:instance2 stop(): I'm returning error!\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance3' stop exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' start exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance2' start exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance3' start exit ok\"));\n\n  EXPECT_EQ(1, count_in_log(\"Deinitializing all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic' doesn't implement deinit()\"));\n}\n\nTEST_F(LifecycleTest, ThreeInstances_DeinintFails) {\n  config_text_ << \"init   = exit           \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = exit           \\n\"\n               << \"deinit = error          \\n\"\n               << \"                        \\n\"\n               << \"[lifecycle:instance2]   \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = exit           \\n\"\n               << \"                        \\n\"\n               << \"[lifecycle:instance3]   \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = exit           \\n\";\n  init_test(config_text_);\n\n  // signal shutdown after 10ms, run() should block until then\n  run_then_signal_shutdown([&](){\n    try {\n      std::exception_ptr e = loader_.run();\n      if (e) std::rethrow_exception(e);\n      FAIL() << \"deinit() should throw std::runtime_error\";\n    } catch (const std::runtime_error& e) {\n      EXPECT_STREQ(\"lifecycle:all deinit(): I'm returning error!\", e.what());\n    } catch (...) {\n      FAIL() << \"deinit() should throw std::runtime_error\";\n    }\n  });\n\n  refresh_log();\n\n  EXPECT_EQ(1, count_in_log(\"Initializing all plugins.\"));\n\n  EXPECT_EQ(1, count_in_log(\"Starting all plugins.\"));\n\n  EXPECT_EQ(1, count_in_log(\"Shutting down. Stopping all plugins.\"));\n\n  EXPECT_EQ(1, count_in_log(\"Deinitializing all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' deinit failed: \"\n                                      \"lifecycle:all deinit(): I'm returning error!\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic' doesn't implement deinit()\"));\n}\n\nTEST_F(LifecycleTest, ThreeInstances_StartStopDeinitFail) {\n  config_text_ << \"init   = exit           \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = exit           \\n\"\n               << \"deinit = error          \\n\"\n               << \"                        \\n\"\n               << \"[lifecycle:instance2]   \\n\"\n               << \"start  = error          \\n\"\n               << \"stop   = exit           \\n\"\n               << \"                        \\n\"\n               << \"[lifecycle:instance3]   \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = error          \\n\";\n  init_test(config_text_);\n\n  // exception from start() should get propagated\n  try {\n    std::exception_ptr e = loader_.run();\n    if (e) std::rethrow_exception(e);\n    FAIL() << \"start() should throw std::runtime_error\";\n  } catch (const std::runtime_error& e) {\n    EXPECT_STREQ(\"lifecycle:instance2 start(): I'm returning error!\", e.what());\n  } catch (...) {\n    FAIL() << \"start() should throw std::runtime_error\";\n  }\n\n  const std::list<std::string> initialized = {\"magic\", \"lifecycle3\", \"lifecycle\"};\n  EXPECT_EQ(initialized, loader_.order_);\n\n  refresh_log();\n\n  EXPECT_EQ(1, count_in_log(\"Initializing all plugins.\"));\n\n  EXPECT_EQ(1, count_in_log(\"Starting all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic:' start exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3:' doesn't implement start()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' starting\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance2' start failed: \"\n                   \"lifecycle:instance2 start(): I'm returning error!\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance3' starting\"));\n\n  EXPECT_EQ(1, count_in_log(\"Shutting down. Stopping all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic:' doesn't implement stop()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3:' doesn't implement stop()\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' stop exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance3' stop failed: \"\n                                \"lifecycle:instance3 stop(): I'm returning error!\"));\n\n  EXPECT_EQ(1, count_in_log(\"Deinitializing all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' deinit failed: \"\n                                      \"lifecycle:all deinit(): I'm returning error!\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle3' deinit exit ok\"));\n  EXPECT_EQ(1, count_in_log(\"  plugin 'magic' doesn't implement deinit()\"));\n}\n\nTEST_F(LifecycleTest, NoInstances) {\n  config_text_.str(\n      \"[DEFAULT]                                      \\n\"\n      \"logging_folder =                               \\n\"\n      \"plugin_folder  = {prefix}/../../../stage/lib/mysqlrouter\\n\"\n      \"runtime_folder = {prefix}/var/run/{program}    \\n\"\n      \"config_folder  = {prefix}/var/run/{program}    \\n\"\n// TODO: restore this after after [logger] hack is reverted (grep for g_HACK_default_log_level)\n//    \"                                               \\n\"\n//    \"[logger]                                       \\n\"\n//    \"level = DEBUG                                  \\n\"\n      \"                                               \\n\");\n  init_test_without_lifecycle_plugin(config_text_);\n\n  loader_.run();\n\n  refresh_log();\n\n  EXPECT_EQ(1, count_in_log(\"Initializing all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"Starting all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"Shutting down. Stopping all plugins.\"));\n  EXPECT_EQ(1, count_in_log(\"Deinitializing all plugins.\"));\n  EXPECT_EQ(0, count_in_log(\"failed\"));\n}\n\n// note: we don't test an equivalent scenario when the plugin throws (an empty\n//       \"what\" field), because to accomplish this, plugin would have to throw\n//       something like:\n//\n//           throw std::runtime_error();\n//\n//       which (on GCC 4.8.4 anyway) emits std::logic_error with a message\n//       complaining about a null std::string. In other words, what() returning\n//       a null string in harness' catch block is not likely.\nTEST_F(LifecycleTest, EmptyErrorMessage) {\n\n  // this test tests PluginFuncEnv::set_error() function, when passed a null\n  // string.\n\n  config_text_ << \"init   = error_empty    \\n\"\n               << \"start  = exit           \\n\"\n               << \"stop   = exit           \\n\"\n               << \"deinit = exit           \\n\";\n  init_test(config_text_, {true, false, false, false});\n\n  // null string should be replaced with '<empty message>'\n  try {\n    std::exception_ptr e = loader_.run();\n    if (e) std::rethrow_exception(e);\n    FAIL() << \"init() should throw std::runtime_error\";\n  } catch (const std::runtime_error& e) {\n    EXPECT_STREQ(\"<empty message>\", e.what());\n  } catch (...) {\n    FAIL() << \"init() should throw std::runtime_error\";\n  }\n\n  // null string should be replaced with '<empty message>'\n  refresh_log();\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' init failed: <empty message>\"));\n}\n\n// maybe these should be moved to test_loader.cc (or wherever PluginFuncEnv class ends up)\n// these tests probably obsolete the EmptyErrorMessage test above\nTEST_F(LifecycleTest, set_error_message) {\n  std::string emsg;\n  mysql_harness::PluginFuncEnv ctx(nullptr, nullptr);\n\n  // simple\n  mysql_harness::set_error(&ctx, mysql_harness::kRuntimeError, \"foo\");\n  std::tie(emsg, std::ignore) = ctx.pop_error();\n  EXPECT_STREQ(\"foo\", emsg.c_str());\n\n  // complex\n  mysql_harness::set_error(&ctx, mysql_harness::kRuntimeError, \"[%s:%s] %d\", \"foo\", \"bar\", 42);\n  std::tie(emsg, std::ignore) = ctx.pop_error();\n  EXPECT_STREQ(\"[foo:bar] 42\", emsg.c_str());\n\n  // cornercase: empty\n#ifndef __GNUC__\n  // gcc/clang catch it at compile time: error: zero-length gnu_printf format string [-Werror=format-zero-length]\n  mysql_harness::set_error(&ctx, mysql_harness::kRuntimeError, \"\");\n  std::tie(emsg, std::ignore) = ctx.pop_error();\n  EXPECT_STREQ(\"\", emsg.c_str());\n#endif\n\n  // cornercase: NULL\n  mysql_harness::set_error(&ctx, mysql_harness::kRuntimeError, nullptr);\n  std::tie(emsg, std::ignore) = ctx.pop_error();\n  EXPECT_STREQ(\"<empty message>\", emsg.c_str());\n\n#ifndef __GNUC__\n  // gcc/clang catch it at compile time: error: too many arguments for format [-Werror=format-extra-args]\n  // cornercase: NULL + arg\n  mysql_harness::set_error(&ctx, mysql_harness::kRuntimeError, nullptr, \"foo\");\n  std::tie(emsg, std::ignore) = ctx.pop_error();\n  EXPECT_STREQ(\"<empty message>\", emsg.c_str());\n#endif\n\n#ifndef __GNUC__\n  // gcc/clang catch it at compile time\n\n  // cornercase: extra arg\n  mysql_harness::set_error(&ctx, mysql_harness::kRuntimeError, \"foo\", \"bar\");\n  std::tie(emsg, std::ignore) = ctx.pop_error();\n  EXPECT_STREQ(\"foo\", emsg.c_str());\n#endif\n}\n\nTEST_F(LifecycleTest, set_error_exception) {\n  std::exception_ptr eptr;\n  mysql_harness::PluginFuncEnv ctx(nullptr, nullptr);\n\n  // test all supported exception types\n\n  mysql_harness::set_error(&ctx, mysql_harness::kRuntimeError, nullptr);\n  std::tie(std::ignore, eptr) = ctx.pop_error();\n  EXPECT_THROW({ std::rethrow_exception(eptr); }, std::runtime_error);\n\n  mysql_harness::set_error(&ctx, mysql_harness::kConfigInvalidArgument, nullptr);\n  std::tie(std::ignore, eptr) = ctx.pop_error();\n  EXPECT_THROW({ std::rethrow_exception(eptr); }, std::invalid_argument);\n\n  mysql_harness::set_error(&ctx, mysql_harness::kConfigSyntaxError, nullptr);\n  std::tie(std::ignore, eptr) = ctx.pop_error();\n  EXPECT_THROW({ std::rethrow_exception(eptr); }, mysql_harness::syntax_error);\n\n  mysql_harness::set_error(&ctx, mysql_harness::kUndefinedError, nullptr);\n  std::tie(std::ignore, eptr) = ctx.pop_error();\n  EXPECT_THROW({ std::rethrow_exception(eptr); }, std::runtime_error);\n}\n\n#ifdef USE_POSIX_SIGNALS  // these don't make sense on Windows\nTEST_F(LifecycleTest, send_signals) {\n  // this test verifies that:\n  // - sending SIGINT or SIGTERM will trigger shutdown\n  //   (we only test SIGINT here, and SIGTERM in the next test)\n  // - sending any other signal will do nothing\n\n  config_text_ << \"init   = exit           \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = exit           \\n\"\n               << \"deinit = exit           \\n\";\n  init_test(config_text_, {true, true, true, true});\n  LifecyclePluginSyncBus& bus = msg_bus(\"instance1\");\n\n  EXPECT_EQ(loader_.init_all(), nullptr);\n  freeze_bus(bus);\n  loader_.start_all();\n  unfreeze_and_wait_for_msg(bus, \"lifecycle:instance1 start():EXIT_ON_STOP:sleeping\");\n\n  // nothing should happen - all signals but the ones we care about should be ignored\n  // (here we only test a few, the rest is assumed to behave the same)\n  raise(SIGUSR1);\n  raise(SIGALRM);\n\n  // signal shutdown after 10ms, main_loop() should block until then\n  auto call_SIGINT = []() {\n    std::this_thread::sleep_for(ch::milliseconds(kSleepShutdown));\n    raise(SIGINT);\n  };\n  std::thread(call_SIGINT).detach();\n  EXPECT_EQ(loader_.main_loop(), nullptr);\n\n  refresh_log();\n  EXPECT_EQ(1, count_in_log(\"Shutting down. Stopping all plugins.\"));\n}\n\nTEST_F(LifecycleTest, send_signals2) {\n  // continuation of the previous test (test SIGTERM this time)\n\n  config_text_ << \"init   = exit           \\n\"\n               << \"start  = exitonstop     \\n\"\n               << \"stop   = exit           \\n\"\n               << \"deinit = exit           \\n\";\n  init_test(config_text_, {true, true, true, true});\n  LifecyclePluginSyncBus& bus = msg_bus(\"instance1\");\n\n  EXPECT_EQ(loader_.init_all(), nullptr);\n  freeze_bus(bus);\n  loader_.start_all();\n  unfreeze_and_wait_for_msg(bus, \"lifecycle:instance1 start():EXIT_ON_STOP:sleeping\");\n\n  // signal shutdown after 10ms, main_loop() should block until then\n  auto call_SIGINT = []() {\n    std::this_thread::sleep_for(ch::milliseconds(kSleepShutdown));\n    raise(SIGTERM);\n  };\n  std::thread(call_SIGINT).detach();\n  EXPECT_EQ(loader_.main_loop(), nullptr);\n\n  refresh_log();\n  EXPECT_EQ(1, count_in_log(\"Shutting down. Stopping all plugins.\"));\n}\n#endif\n\nTEST_F(LifecycleTest, wait_for_stop) {\n  // This test is really about testing Harness API function wait_for_stop(),\n  // when passed a timeout value. It is used when start/stop = exit_slow, and\n  // here we verify its behaviour.\n  //\n  // SCENARIO:\n  // while start() is running, \"Router is running\", thus start() should block,\n  // waiting for Harness to progress to \"stopping\" state. That will not occur\n  // until all plugins have exited, in this case meaning, the start() exits\n  // (until its wait_for_stop() returns, thus the plugin is really waiting for\n  // itself :)).\n  // Once that all plugins have exited, Harness will be in the \"stopping\" state,\n  // thus plugin's stop() function will be called.  It also calls wait_for_stop(),\n  // but this time it should exit immediately, since the Harness is shutting down.\n  //\n  // EXPECTATIONS:\n  // wait_for_stop() inside start() should block for 100ms, return false\n  // wait_for_stop() inside stop() should return immediately, return true\n\n  config_text_ << \"start = exit_slow\\n\";  // \\_ they run\n  config_text_ << \"stop  = exit_slow\\n\";  // /  wait_for_stop() inside\n  init_test(config_text_, {false, true, true, false});\n  LifecyclePluginSyncBus& bus = msg_bus(\"instance1\");\n\n  EXPECT_EQ(loader_.init_all(), nullptr);\n  freeze_bus(bus);\n\n  // mark time start\n  ch::time_point<ch::steady_clock> t0 = ch::steady_clock::now();\n\n  loader_.start_all();\n  unfreeze_and_wait_for_msg(bus, \"lifecycle:instance1 start():EXIT_SLOW:sleeping\");\n\n  // wait_for_stop() in start() should be sleeping right now, blocking progress\n  refresh_log();\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 start():begin\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 start():EXIT_SLOW:sleeping\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 start():EXIT_SLOW:done, stop request received\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 start():EXIT_SLOW:done, timed out\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 stop():begin\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 stop():EXIT_SLOW:done, stop request received\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 stop():EXIT_SLOW:done, timed out\"));\n\n  // wait for it to exit (it will unblock main_loop())\n  EXPECT_EQ(loader_.main_loop(), nullptr);\n\n  // verify that:\n  //   - wait_for_stop() in start() blocked\n  //   - wait_for_stop() in stop() did not block\n  ch::time_point<ch::steady_clock> t1 = ch::steady_clock::now();\n  EXPECT_LE(100, time_diff(t0, t1));  // 100 = kPersistDuration in lifecycle.cc\n  EXPECT_GT(200, time_diff(t0, t1));  // 200 would mean that both start() and stop() blocked\n\n  // verify what both wait_for_stop()'s returned\n  refresh_log();\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 start():EXIT_SLOW:done, stop request received\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 start():EXIT_SLOW:done, timed out\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 stop():begin\"));\n  EXPECT_EQ(1, count_in_log(\"lifecycle:instance1 stop():EXIT_SLOW:done, stop request received\"));\n  EXPECT_EQ(0, count_in_log(\"lifecycle:instance1 stop():EXIT_SLOW:done, timed out\"));\n}\n\n// Next 4 tests should only run in release builds. Code in debug builds throws\n// assertion to warn the plugin developers that their plugins throw. But we\n// wouldn't want to do this on production systems, so instead, we handle this\n// error gracefully. Note that officially this behaviour is undefined, thus\n// we are free to change this behaviour as we see fit.\n#ifdef NDEBUG  // cmake's -DCMAKE_BUILD_TYPE=Release or RelWithDebInfo (not\n               // case sensitive) will define it\nTEST_F(LifecycleTest, InitThrows) {\n  config_text_ << \"init = throw\\n\";\n  init_test(config_text_, {true, false, false, false});\n\n  try {\n    std::exception_ptr e = loader_.run();\n    if (e) std::rethrow_exception(e);\n    FAIL() << \"init() should throw std::runtime_error\";\n  } catch (const std::runtime_error& e) {\n    EXPECT_STREQ(\"lifecycle:all init(): I'm throwing!\", e.what());\n  } catch (...) {\n    FAIL() << \"init() should throw std::runtime_error\";\n  }\n\n  refresh_log();\n\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' init threw unexpected \"\n      \"exception - please contact plugin developers for more information: \"\n      \"lifecycle:all init(): I'm throwing!\"));\n}\n\nTEST_F(LifecycleTest, StartThrows) {\n  config_text_ << \"start = throw\\n\";\n  init_test(config_text_, {false, true, false, false});\n\n  try {\n    std::exception_ptr e = loader_.run();\n    if (e) std::rethrow_exception(e);\n    FAIL() << \"start() should throw std::runtime_error\";\n  } catch (const std::runtime_error& e) {\n    EXPECT_STREQ(\"lifecycle:instance1 start(): I'm throwing!\", e.what());\n  } catch (...) {\n    FAIL() << \"start() should throw std::runtime_error\";\n  }\n\n  refresh_log();\n\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' start threw \"\n      \"unexpected exception - please contact plugin developers for more \"\n      \"information: lifecycle:instance1 start(): I'm throwing!\"));\n}\n\nTEST_F(LifecycleTest, StopThrows) {\n  config_text_ << \"stop = throw\\n\";\n  init_test(config_text_, {false, false, true, false});\n\n  try {\n    std::exception_ptr e = loader_.run();\n    if (e) std::rethrow_exception(e);\n    FAIL() << \"stop() should throw std::runtime_error\";\n  } catch (const std::runtime_error& e) {\n    EXPECT_STREQ(\"lifecycle:instance1 stop(): I'm throwing!\", e.what());\n  } catch (...) {\n    FAIL() << \"stop() should throw std::runtime_error\";\n  }\n\n  refresh_log();\n\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' stop threw \"\n      \"unexpected exception - please contact plugin developers for more \"\n      \"information: lifecycle:instance1 stop(): I'm throwing!\"));\n}\n\nTEST_F(LifecycleTest, DeinitThrows) {\n  config_text_ << \"deinit = throw\\n\";\n  init_test(config_text_, {false, false, false, true});\n\n  try {\n    std::exception_ptr e = loader_.run();\n    if (e) std::rethrow_exception(e);\n    FAIL() << \"deinit() should throw std::runtime_error\";\n  } catch (const std::runtime_error& e) {\n    EXPECT_STREQ(\"lifecycle:all deinit(): I'm throwing!\", e.what());\n  } catch (...) {\n    FAIL() << \"deinit() should throw std::runtime_error\";\n  }\n\n  refresh_log();\n\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' deinit threw unexpected \"\n      \"exception - please contact plugin developers for more information: \"\n      \"lifecycle:all deinit(): I'm throwing!\"));\n}\n\n// The following 4 are the same as above 4, but this time we throw unusual\n// exceptions (not derived from std::exception), to test catch(...) logic\n// in Loader's code\nTEST_F(LifecycleTest, InitThrowsWeird) {\n  config_text_ << \"init = throw_weird\\n\";\n  init_test(config_text_, {true, false, false, false});\n\n  try {\n    std::exception_ptr e = loader_.run();\n    if (e) std::rethrow_exception(e);\n    FAIL() << \"init() should throw non-standard exception object\";\n  } catch (const std::runtime_error& e) {\n    FAIL() << \"init() should throw non-standard exception object\";\n  } catch (...) {\n  }\n\n  refresh_log();\n\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' init threw unexpected \"\n      \"exception - please contact plugin developers for more information.\"));\n}\n\nTEST_F(LifecycleTest, StartThrowsWeird) {\n  config_text_ << \"start = throw_weird\\n\";\n  init_test(config_text_, {false, true, false, false});\n\n  try {\n    std::exception_ptr e = loader_.run();\n    if (e) std::rethrow_exception(e);\n    FAIL() << \"start() should throw non-standard exception object\";\n  } catch (const std::runtime_error& e) {\n    FAIL() << \"start() should throw non-standard exception object\";\n  } catch (...) {\n  }\n\n  refresh_log();\n\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' start threw unexpected \"\n      \"exception - please contact plugin developers for more information.\"));\n}\n\nTEST_F(LifecycleTest, StopThrowsWeird) {\n  config_text_ << \"stop = throw_weird\\n\";\n  init_test(config_text_, {false, false, true, false});\n\n  try {\n    std::exception_ptr e = loader_.run();\n    if (e) std::rethrow_exception(e);\n    FAIL() << \"stop() should throw non-standard exception object\";\n  } catch (const std::runtime_error& e) {\n    FAIL() << \"stop() should throw non-standard exception object\";\n  } catch (...) {\n  }\n\n  refresh_log();\n\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle:instance1' stop threw unexpected \"\n      \"exception - please contact plugin developers for more information.\"));\n}\n\nTEST_F(LifecycleTest, DeinitThrowsWeird) {\n  config_text_ << \"deinit = throw_weird\\n\";\n  init_test(config_text_, {false, false, false, true});\n\n  try {\n    std::exception_ptr e = loader_.run();\n    if (e) std::rethrow_exception(e);\n    FAIL() << \"deinit() should throw non-standard exception object\";\n  } catch (const std::runtime_error& e) {\n    FAIL() << \"deinit() should throw non-standard exception object\";\n  } catch (...) {\n  }\n\n  refresh_log();\n\n  EXPECT_EQ(1, count_in_log(\"  plugin 'lifecycle' deinit threw unexpected \"\n      \"exception - please contact plugin developers for more information.\"));\n}\n\n#endif // #ifdef NDEBUG\n\nTEST_F(LifecycleTest, LoadingNonExistentPlugin) {\n  clear_log();\n\n  config_text_ << \"[nonexistent_plugin]\\n\";   // should cause Loader::load_all() to throw\n  config_text_ << \"[nonexistent_plugin_2]\\n\"; // no attempt to load this should be made\n  loader_.read(config_text_);\n\n  try {\n    loader_.start();\n    FAIL() << \"Loader::start() should throw bad_plugin\";\n  } catch (const bad_plugin& e) {\n    EXPECT_THAT(e.what(), HasSubstr(\"nonexistent_plugin\"));\n  } catch (const std::exception &e) {\n    FAIL() << \"Loader::start() should throw bad_plugin, but got: \" << e.what();\n  }\n\n  // Expect something like so:\n  // \"2017-07-13 14:38:57 main ERROR [7ffff7fd5780]   plugin 'nonexistent_plugin' failed to load: <OS-specific error text>\"\n  // \"2017-07-13 14:38:57 main INFO [7ffff7fd5780] Unloading all plugins.\"\n  refresh_log();\n  EXPECT_EQ(1, count_in_log(\"]   plugin 'nonexistent_plugin' failed to load: \"));\n  EXPECT_EQ(1, count_in_log(\"] Unloading all plugins.\"));\n\n  // Loader::load_all() should have stopped loading as soon as it encountered 'nonexistent_plugin'.\n  // Therefore, it should not attempt to load the next plugin, 'nonexistent_plugin_2', thus we should\n  // find no trace of such string in the log.\n  EXPECT_EQ(0, count_in_log(\"nonexistent_plugin_2\"));\n}\n\n\n\nint main(int argc, char *argv[])\n{\n  g_here = Path(argv[0]).dirname();\n  init_test_logger();\n\n  ::testing::InitGoogleTest(&argc, argv);\n  int res = RUN_ALL_TESTS();\n\n  return res;\n}\n\n"
  },
  {
    "path": "src/harness/tests/test_logging.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#define MYSQL_ROUTER_LOG_DOMAIN \"my_domain\"\n\n#ifdef _WIN32\n#  define NOMINMAX\n#  define getpid GetCurrentProcessId\n#endif\n\n////////////////////////////////////////\n// Internal interfaces\n#include \"dim.h\"\n#include \"include/magic.h\"\n#include \"common.h\"\n#include \"test/helpers.h\"\n#include \"mysql/harness/loader.h\"\n#include \"mysql/harness/filesystem.h\"\n#include \"mysql/harness/logging/handler.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysql/harness/logging/registry.h\"\n\n////////////////////////////////////////\n// Third-party include files\nMYSQL_HARNESS_DISABLE_WARNINGS()\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\nMYSQL_HARNESS_ENABLE_WARNINGS()\n\n////////////////////////////////////////\n// Standard include files\n#include <stdexcept>\n\n#ifndef _WIN32\n#include <unistd.h> // unlink\n#endif\n\nusing mysql_harness::Path;\nusing mysql_harness::logging::FileHandler;\nusing mysql_harness::logging::LogLevel;\nusing mysql_harness::logging::Logger;\nusing mysql_harness::logging::Record;\nusing mysql_harness::logging::StreamHandler;\nusing mysql_harness::logging::log_debug;\nusing mysql_harness::logging::log_error;\nusing mysql_harness::logging::log_info;\nusing mysql_harness::logging::log_warning;\n\n\n#if GTEST_HAS_COMBINE\n// only available if the system has <tr1/tuple> [if not gtest's own, minimal tr1/tuple is used.\nusing testing::Combine;\n#endif\nusing testing::ContainsRegex;\nusing testing::EndsWith;\nusing testing::Eq;\nusing testing::Ge;\nusing testing::Gt;\nusing testing::HasSubstr;\nusing testing::Not;\nusing testing::StartsWith;\nusing testing::StrEq;\nusing testing::Test;\nusing testing::Values;\nusing testing::ValuesIn;\nusing testing::WithParamInterface;\n\nconst std::string kDateRegex =\n#if GTEST_USES_SIMPLE_RE\n\"\\\\d\\\\d\\\\d\\\\d-\\\\d\\\\d-\\\\d\\\\d \\\\d\\\\d:\\\\d\\\\d:\\\\d\\\\d\";\n#else\n\"[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\";\n#endif\n\n//TODO move this and ASSERT_THROW_LIKE from:\n//   tests/helpers/router_test_helpers.h\n// to:\n//   mysql_harness/shared/include/test/helpers.h\n#define EXPECT_THROW_LIKE(expr, exc, msg) try { \\\n      expr;\\\n      ADD_FAILURE() << \"Expected exception of type \" #exc << \" but got none\\n\";\\\n    } catch (exc &e) {\\\n      if (std::string(e.what()).find(msg) == std::string::npos) {\\\n          ADD_FAILURE() << \"Expected exception with message: \" << msg << \"\\nbut got: \" << e.what() << \"\\n\";\\\n      }\\\n    } catch (...) {\\\n      ADD_FAILURE() << \"Expected exception of type \" #exc << \" but got another\\n\";\\\n    }\n\nnamespace {\n  Path g_here;\n  mysql_harness::logging::Registry* g_registry;\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n// Registry tests\n////////////////////////////////////////////////////////////////////////////////\n\nclass LoggingLowLevelTest : public Test {\n public:\n  void SetUp() override {\n    clear_registry(*g_registry);\n    g_registry->add_handler(\"handler_1\", std::make_shared<StreamHandler>(std::cerr));\n    g_registry->add_handler(\"handler_2\", std::make_shared<StreamHandler>(std::cerr));\n    g_registry->add_handler(\"handler_3\", std::make_shared<StreamHandler>(std::cerr));\n  }\n\n  void TearDown() override {\n    clear_registry(*g_registry);\n  }\n};\n\nTEST_F(LoggingLowLevelTest, test_handler_CRUD) {\n\n  // remove default stuff\n  clear_registry(*g_registry);\n\n  // handler doesn't exist yet\n  ASSERT_EQ(0u, g_registry->get_handler_names().size());\n  EXPECT_THROW_LIKE(\n    g_registry->get_handler(\"foo\"),\n    std::logic_error, \"Accessing non-existant handler 'foo'\"\n  );\n\n  // add it\n  g_registry->add_handler(\"foo\", std::make_shared<StreamHandler>(std::cerr));\n\n  // try adding it again\n  EXPECT_THROW_LIKE(\n    g_registry->add_handler(\"foo\", std::make_shared<StreamHandler>(std::cerr)),\n    std::logic_error, \"Duplicate handler 'foo'\"\n  );\n\n  // it exists now\n  ASSERT_EQ(1u, g_registry->get_handler_names().size());\n  EXPECT_NO_THROW(g_registry->get_handler(\"foo\"));\n  EXPECT_STREQ(\"foo\", g_registry->get_handler_names().begin()->c_str());\n\n  // remove it\n  EXPECT_NO_THROW(g_registry->remove_handler(\"foo\"));\n\n  // try removing it again\n  EXPECT_THROW_LIKE(\n    g_registry->remove_handler(\"foo\"),\n    std::logic_error, \"Removing non-existant handler 'foo'\"\n  );\n\n  // it doesn't exist now\n  EXPECT_EQ(0u, g_registry->get_handler_names().size());\n  EXPECT_THROW_LIKE(\n    g_registry->get_handler(\"foo\"),\n    std::logic_error, \"Accessing non-existant handler 'foo'\"\n  );\n}\n\nTEST_F(LoggingLowLevelTest, test_logger_CRUD) {\n\n  // logger doesn't exist yet\n  ASSERT_EQ(0u, g_registry->get_logger_names().size());\n  EXPECT_THROW_LIKE(\n    g_registry->get_logger(\"foo\"),\n    std::logic_error, \"Accessing non-existant logger 'foo'\"\n  );\n  EXPECT_THROW_LIKE(\n    g_registry->update_logger(\"foo\", Logger()),\n    std::logic_error, \"Updating non-existant logger 'foo'\"\n  );\n\n  // add it\n  g_registry->create_logger(\"foo\", LogLevel::kError);\n\n  // try adding it again\n  EXPECT_THROW_LIKE(\n    g_registry->create_logger(\"foo\", LogLevel::kError),\n    std::logic_error, \"Duplicate logger 'foo'\"\n  );\n\n  // it exists now\n  ASSERT_EQ(1u, g_registry->get_logger_names().size());\n  EXPECT_NO_THROW(g_registry->get_logger(\"foo\"));\n  EXPECT_STREQ(\"foo\", g_registry->get_logger_names().begin()->c_str());\n\n  // update it\n  EXPECT_NO_THROW(g_registry->update_logger(\"foo\", Logger()));\n\n  // remove it\n  EXPECT_NO_THROW(g_registry->remove_logger(\"foo\"));\n\n  // try removing it again\n  EXPECT_THROW_LIKE(\n    g_registry->remove_logger(\"foo\"),\n    std::logic_error, \"Removing non-existant logger 'foo'\"\n  );\n\n  // it doesn't exist now\n  EXPECT_EQ(0u, g_registry->get_logger_names().size());\n  EXPECT_THROW_LIKE(\n    g_registry->get_logger(\"foo\"),\n    std::logic_error, \"Accessing non-existant logger 'foo'\"\n  );\n}\n\nTEST_F(LoggingLowLevelTest, test_logger_update) {\n\n  g_registry->create_logger(\"foo\");\n  EXPECT_EQ(0u, g_registry->get_logger(\"foo\").get_handler_names().size());\n\n  // valid update\n  {\n    Logger l = g_registry->get_logger(\"foo\");\n    EXPECT_NO_THROW(l.attach_handler(\"handler_1\"));\n    EXPECT_NO_THROW(l.attach_handler(\"handler_2\"));\n    EXPECT_NO_THROW(l.attach_handler(\"handler_3\"));\n    EXPECT_NO_THROW(g_registry->update_logger(\"foo\", l));\n\n    // handlers should have been successfully added\n    EXPECT_EQ(3u, g_registry->get_logger(\"foo\").get_handler_names().size());\n  }\n\n  // not all handlers exist\n  {\n    Logger l = g_registry->get_logger(\"foo\");\n    EXPECT_NO_THROW(l.attach_handler(\"handler_1\"));\n    EXPECT_NO_THROW(l.attach_handler(\"unicorn\"));\n    EXPECT_NO_THROW(l.attach_handler(\"handler_3\"));\n    EXPECT_THROW_LIKE(\n      g_registry->update_logger(\"foo\", l),\n      std::logic_error, \"Attaching unknown handler 'unicorn'\"\n    );\n\n    // failed update should not change the logger in the registry\n    EXPECT_EQ(3u, g_registry->get_logger(\"foo\").get_handler_names().size());\n  }\n\n  // detaching non-existant handlers is optionally verified by detach_handler().\n  // It is not something that concerns update_logger(), since it only sees\n  // the Logger object after all the handlers that were supposed to be detached,\n  // got detached\n  {\n    Logger l = g_registry->get_logger(\"foo\");\n    EXPECT_NO_THROW(l.detach_handler(\"handler_1\", true)); // true = verify\n    EXPECT_NO_THROW(l.detach_handler(\"unicorn\", false));  // false = don't verify, no-op\n    EXPECT_THROW_LIKE(\n      l.detach_handler(\"unicorn\", true),\n      std::logic_error, \"Detaching unknown handler 'unicorn'\"\n    );\n    EXPECT_THROW_LIKE(\n      l.detach_handler(\"unicorn\"),  // true is default\n      std::logic_error, \"Detaching unknown handler 'unicorn'\"\n    );\n\n    // logger object should still be valid after failed detach_handler() and\n    // contain the two handlers we did not remove\n    EXPECT_EQ(2u, l.get_handler_names().size());\n    EXPECT_EQ(1, std::count(l.get_handler_names().begin(), l.get_handler_names().end(), \"handler_2\"));\n    EXPECT_EQ(1, std::count(l.get_handler_names().begin(), l.get_handler_names().end(), \"handler_3\"));\n\n    // logger should update successfully\n    EXPECT_NO_THROW(g_registry->update_logger(\"foo\", l));\n    EXPECT_EQ(2u, g_registry->get_logger(\"foo\").get_handler_names().size());\n  }\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n// higher-level tests\n////////////////////////////////////////////////////////////////////////////////\n\nTEST(FunctionalTest, ThisMustRunAsFirst) {\n  init_test_logger();\n}\n\nTEST(FunctionalTest, LogFromUnregisteredModule) {\n\n  // Test a scenario when no domain logger has been added yet. Logging should\n  // fall back to using application (\"main\") logger, which is always added by\n  // the application (init_log() in main(), in our case), albeit with an extra\n  // error message preceding it.\n\n  std::stringstream buffer;\n  auto handler = std::make_shared<StreamHandler>(buffer);\n  g_registry->add_handler(StreamHandler::kDefaultName, handler);\n  attach_handler_to_all_loggers(*g_registry, StreamHandler::kDefaultName);\n\n  log_info(\"Test message from an unregistered module\");\n  std::string log = buffer.str();\n\n  // log message should be something like (2 lines):\n  // 2017-04-12 14:05:31 main ERROR [7ffff7fd5780] Module 'my_domain' not registered with logger - logging the following message as 'main' instead\n  // 2017-04-12 14:05:31 main INFO [7ffff7fd5780] Test message from an unregistered module\n  EXPECT_NE(log.npos, log.find(\" main ERROR\"));\n  EXPECT_NE(log.npos, log.find(\" Module 'my_domain' not registered with logger - logging the following message as 'main' instead\\n\"));\n  size_t first_endl = log.find('\\n');\n  EXPECT_NE(log.npos, log.find(\" main INFO\", first_endl));\n  EXPECT_NE(log.npos, log.find(\" Test message from an unregistered module\\n\", first_endl));\n\n  // clean up\n  g_registry->remove_handler(StreamHandler::kDefaultName);\n}\n\nTEST(FunctionalTest, LogOnDanglingHandlerReference) {\n\n  // NOTE: \"a_gonner\" and \"z_stayer\" are named like that to ensure that\n  // iterating over the container (std::set<std::string>) inside Logger::handler()\n  // will process \"a_gonner\" first. std::set makes guarrantee that iterating over\n  // its elements will be in ascending element order, which means alphabetical order\n  // in case of std::string.\n  // By having those two named like that, we additionally verify that logging to a\n  // valid handler will still work AFTER trying to log to a removed handler.\n\n  // add 2 new handlers\n  std::stringstream buffer;\n  auto handler = std::make_shared<StreamHandler>(buffer);\n  g_registry->add_handler(\"a_gonner\", std::make_shared<StreamHandler>(std::cerr));\n  g_registry->add_handler(\"z_stayer\", handler);\n\n  // create a logger with the new handlers attached\n  g_registry->create_logger(\"my_logger\");\n  Logger l(*g_registry);\n  l.attach_handler(\"z_stayer\");\n  l.attach_handler(\"a_gonner\");\n  g_registry->update_logger(\"my_logger\", l);\n\n  // now remove first handler\n  g_registry->remove_handler(\"a_gonner\");\n\n  // and try to log with the logger still holding a referece to it.\n  // Logger::handle() should deal with it properly - it should log\n  // to all (still existing) handlers (\"z_stayer\" in this case).\n  EXPECT_NO_THROW(\n    l.handle(Record{LogLevel::kWarning, getpid(), 0, \"my_logger\", \"Test message\"})\n  );\n  std::string log = buffer.str();\n\n  // log message should be something like:\n  // 2017-04-12 14:05:31 my_logger WARNING [7ffff7fd5780] Test message\n  EXPECT_NE(log.npos, log.find(\" my_logger WARNING\"));\n  EXPECT_NE(log.npos, log.find(\" Test message\\n\"));\n\n  // clean up\n  g_registry->remove_handler(\"z_stayer\");\n  g_registry->remove_logger(\"my_logger\");\n}\n\nTEST(TestBasic, Setup) {\n  // Test that creating a logger will give it a name and a default log\n  // level.\n  Logger logger(*g_registry);\n  EXPECT_EQ(logger.get_level(), LogLevel::kWarning);\n\n  logger.set_level(LogLevel::kDebug);\n  EXPECT_EQ(logger.get_level(), LogLevel::kDebug);\n}\n\nclass LoggingTest : public Test {\n public:\n  // Here we are just testing that messages are written and in the\n  // right format. We use kNotSet log level, which will print all\n  // messages.\n  Logger logger{*g_registry, LogLevel::kNotSet};\n};\n\nTEST_F(LoggingTest, StreamHandler) {\n  std::stringstream buffer;\n\n  g_registry->add_handler(\"TestStreamHandler\", std::make_shared<StreamHandler>(buffer));\n  logger.attach_handler(\"TestStreamHandler\");\n\n  // A bunch of casts to int for tellp to avoid C2666 in MSVC\n  ASSERT_THAT((int)buffer.tellp(), Eq(0));\n  logger.handle(Record{LogLevel::kInfo, getpid(), 0, \"my_module\", \"Message\"});\n  EXPECT_THAT((int)buffer.tellp(), Gt(0));\n\n  // message should be logged after applying format (timestamp, etc)\n  EXPECT_THAT(buffer.str(), ContainsRegex(kDateRegex + \" my_module INFO.*Message\\n\"));\n\n  // clean up\n  g_registry->remove_handler(\"TestStreamHandler\");\n}\n\nTEST_F(LoggingTest, FileHandler) {\n  // Check that an exception is thrown for a path that cannot be\n  // opened.\n  EXPECT_ANY_THROW(FileHandler(\"/something/very/unlikely/to/exist\"));\n\n  // We do not use mktemp or friends since we want this to work on\n  // Windows as well.\n  Path log_file(g_here.join(\"log4-\" + std::to_string(getpid()) + \".log\"));\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){unlink(log_file.c_str());});\n\n  g_registry->add_handler(\"TestFileHandler\", std::make_shared<FileHandler>(log_file));\n  logger.attach_handler(\"TestFileHandler\");\n\n  // Log one record\n  logger.handle(Record{LogLevel::kInfo, getpid(), 0, \"my_module\", \"Message\"});\n\n  // Open and read the entire file into memory.\n  std::vector<std::string> lines;\n  {\n    std::ifstream ifs_log(log_file.str());\n    std::string line;\n    while (std::getline(ifs_log, line))\n      lines.push_back(line);\n  }\n\n  // We do the assertion here to ensure that we can do as many tests\n  // as possible and report issues.\n  ASSERT_THAT(lines.size(), Ge(1));\n\n  // Check basic properties for the first line.\n  EXPECT_THAT(lines.size(), Eq(1));\n\n  // message should be logged after applying format (timestamp, etc)\n  EXPECT_THAT(lines.at(0), ContainsRegex(kDateRegex + \" my_module INFO.*Message\"));\n\n  // clean up\n  g_registry->remove_handler(\"TestFileHandler\");\n}\n\n/**\n * @test\n *      Verify if no exception is throw when file can be opened for writing.\n */\nTEST_F(LoggingTest, DontThrowIfOpenedLogFileForWriting) {\n    std::string tmp_dir = mysql_harness::get_tmp_dir(\"logging\");\n    Path dir_path(tmp_dir);\n    Path file_path(dir_path.join(\"test_file.log\").str());\n\n    ASSERT_TRUE(dir_path.exists());\n    {\n      std::ofstream file(file_path.str());\n    }\n    ASSERT_TRUE(file_path.exists());\n    ASSERT_NO_THROW(FileHandler{file_path.str()});\n}\n\n#ifndef _WIN32\n/**\n * @test\n *       Verify if appropriate system_error is thrown when cannot\n *       create file in directory.\n *\n * There is component test: RouterLoggingTest, bad_logging_folder\n * that uses file as a directory to veryfy scenario when file cannot\n * be created in directory.\n */\nTEST_F(LoggingTest, FileHandlerThrowsNoPermissionToCreateFileInDirectory) {\n\n  std::string tmp_dir = mysql_harness::get_tmp_dir(\"logging\");\n  Path dir_path(tmp_dir);\n  Path file_path(dir_path.join(\"test_file.log\").str());\n\n  ASSERT_TRUE(dir_path.exists());\n\n  // set permissions\n  chmod(dir_path.c_str(), S_IRUSR);\n\n  ASSERT_FALSE(file_path.exists());\n  EXPECT_THROW_LIKE(FileHandler(file_path.str()), std::system_error,\n      \"Cannot create file in directory \" + file_path.dirname().str() +\n      \": Permission denied\");\n}\n#endif\n\n/**\n * @test\n *      Verify if appropriate system_error is thrown when file cannot\n *      be opened for writing.\n */\nTEST_F(LoggingTest, FileHandlerThrowsFileExistsButCannotOpenToWriteReadOnlyFile) {\n  std::string tmp_dir = mysql_harness::get_tmp_dir(\"logging\");\n  Path dir_path(tmp_dir);\n  Path file_path(dir_path.join(\"test_file.log\").str());\n\n  // create empty log file\n  ASSERT_TRUE(dir_path.exists());\n  {\n    std::ofstream file(file_path.str());\n  }\n\n  // set file read-only\n#ifdef _WIN32\n    // set file read-only\n    if (SetFileAttributes(file_path.c_str(), FILE_ATTRIBUTE_READONLY) == FALSE)\n        FAIL() << \"cannot set read-only attribute to file\\n\";\n#else\n    chmod(file_path.c_str(), S_IRUSR);\n#endif\n\n#ifdef _WIN32\n    EXPECT_THROW_LIKE(FileHandler(file_path.str()), std::system_error,\n        \"File exists, but cannot open for writing \" + file_path.str()\n        + \": Access is denied.\");\n#else\n    EXPECT_THROW_LIKE(FileHandler(file_path.str()), std::system_error,\n        \"File exists, but cannot open for writing \" + file_path.str()\n        + \": Permission denied\");\n#endif\n}\n\nTEST_F(LoggingTest, HandlerWithDisabledFormatting) {\n  std::stringstream buffer;\n\n  g_registry->add_handler(\"TestStreamHandler\", std::make_shared<StreamHandler>(buffer, false));\n  logger.attach_handler(\"TestStreamHandler\");\n\n  // A bunch of casts to int for tellp to avoid C2666 in MSVC\n  ASSERT_THAT((int)buffer.tellp(), Eq(0));\n  logger.handle(Record{LogLevel::kInfo, getpid(), 0, \"my_module\", \"Message\"});\n  EXPECT_THAT((int)buffer.tellp(), Gt(0));\n\n  // message should be logged verbatim\n  EXPECT_THAT(buffer.str(), StrEq(\"Message\\n\"));\n\n  // clean up\n  g_registry->remove_handler(\"TestStreamHandler\");\n}\n\nTEST_F(LoggingTest, Messages) {\n  std::stringstream buffer;\n\n  g_registry->add_handler(\"TestStreamHandler\", std::make_shared<StreamHandler>(buffer));\n  logger.attach_handler(\"TestStreamHandler\");\n\n  time_t now;\n  time(&now);\n\n  auto pid = getpid();\n\n  auto check_message = [this, &buffer, now, pid](\n      const std::string& message, LogLevel level,\n      const std::string& level_str) {\n    buffer.str(\"\");\n    ASSERT_THAT((int)buffer.tellp(), Eq(0));\n\n    Record record{level, pid, now, \"my_module\", message};\n    logger.handle(record);\n\n    EXPECT_THAT(buffer.str(), EndsWith(message + \"\\n\"));\n    EXPECT_THAT(buffer.str(), HasSubstr(level_str));\n  };\n\n  check_message(\"Crazy noodles\", LogLevel::kError, \" ERROR \");\n  check_message(\"Sloth tantrum\", LogLevel::kWarning, \" WARNING \");\n  check_message(\"Russel's teapot\", LogLevel::kInfo, \" INFO \");\n  check_message(\"Bugs galore\", LogLevel::kDebug, \" DEBUG \");\n\n  // clean up\n  g_registry->remove_handler(\"TestStreamHandler\");\n}\n\n#if GTEST_HAS_COMBINE\nclass LogLevelTest\n    : public LoggingTest,\n      public WithParamInterface<std::tuple<LogLevel, LogLevel>> {};\n\n// Check that messages are not emitted when the level is set higher.\nTEST_P(LogLevelTest, Level) {\n  LogLevel logger_level = std::get<0>(GetParam());\n  LogLevel handler_level = std::get<1>(GetParam());\n\n  std::stringstream buffer;\n  g_registry->add_handler(\"TestStreamHandler\", std::make_shared<StreamHandler>(buffer, true, handler_level));\n  logger.attach_handler(\"TestStreamHandler\");\n\n  time_t now;\n  time(&now);\n\n  auto pid = getpid();\n\n  // Set the log level of the logger.\n  logger.set_level(logger_level);\n\n  // Some handy shorthands for the levels as integers.\n  const int min_level = std::min(static_cast<int>(logger_level),\n                                 static_cast<int>(handler_level));\n  const int max_level = static_cast<int>(LogLevel::kNotSet);\n\n  // Loop over all levels below or equal to the provided level and\n  // make sure that something is printed.\n  for (int lvl = 0 ; lvl < min_level + 1 ; ++lvl) {\n    buffer.str(\"\");\n    ASSERT_THAT((int)buffer.tellp(), Eq(0));\n    logger.handle(Record{\n        static_cast<LogLevel>(lvl), pid, now, \"my_module\", \"Some message\"});\n    auto output = buffer.str();\n    EXPECT_THAT(output.size(), Gt(0));\n  }\n\n  // Loop over all levels above the provided level and make sure\n  // that nothing is printed.\n  for (int lvl = min_level + 1 ; lvl < max_level ; ++lvl) {\n    buffer.str(\"\");\n    ASSERT_THAT((int)buffer.tellp(), Eq(0));\n    logger.handle(Record{\n        static_cast<LogLevel>(lvl), pid, now, \"my_module\", \"Some message\"});\n    auto output = buffer.str();\n    EXPECT_THAT(output.size(), Eq(0));\n  }\n\n  // clean up\n  g_registry->remove_handler(\"TestStreamHandler\");\n}\n\nconst LogLevel all_levels[]{\n  LogLevel::kFatal, LogLevel::kError, LogLevel::kWarning, LogLevel::kInfo,\n  LogLevel::kDebug\n};\n\nINSTANTIATE_TEST_CASE_P(CheckLogLevel, LogLevelTest,\n                        Combine(ValuesIn(all_levels), ValuesIn(all_levels)));\n#endif\n////////////////////////////////////////////////////////////////\n// Tests of the functional interface to the logger.\n////////////////////////////////////////////////////////////////\n\nTEST(FunctionalTest, CreateRemove) {\n  // Test that creating two modules with different names succeed.\n  EXPECT_NO_THROW(g_registry->create_logger(\"my_first\"));\n  EXPECT_NO_THROW(g_registry->create_logger(\"my_second\"));\n\n  // Test that trying to create two loggers for the same module fails.\n  EXPECT_THROW(g_registry->create_logger(\"my_first\"), std::logic_error);\n  EXPECT_THROW(g_registry->create_logger(\"my_second\"), std::logic_error);\n\n  // Check that we can remove one of the modules and that removing it\n  // a second time fails (mostly to get full coverage).\n  ASSERT_NO_THROW(g_registry->remove_logger(\"my_second\"));\n  EXPECT_THROW(g_registry->remove_logger(\"my_second\"), std::logic_error);\n\n  // Clean up after the tests\n  ASSERT_NO_THROW(g_registry->remove_logger(\"my_first\"));\n}\n\nvoid expect_no_log(void (*func)(const char*, ...) ATTRIBUTE_GCC_FORMAT(printf, 1, 2),\n                   std::stringstream& buffer) {\n  // Clear the buffer first and ensure that it was cleared to avoid\n  // triggering other errors.\n  buffer.str(\"\");\n  ASSERT_THAT((int)buffer.tellp(), Eq(0));\n\n  // Write a simple message with a variable\n  const int x = 3;\n  func(\"Just a test of %d\", x);\n\n  // Log should be empty\n  EXPECT_THAT((int)buffer.tellp(), Eq(0));\n}\n\nvoid expect_log(void (*func)(const char*, ...) ATTRIBUTE_GCC_FORMAT(printf, 1, 2),\n                std::stringstream& buffer, const char* kind) {\n  // Clear the buffer first and ensure that it was cleared to avoid\n  // triggering other errors.\n  buffer.str(\"\");\n  ASSERT_THAT((int)buffer.tellp(), Eq(0));\n\n  // Write a simple message with a variable\n  const int x = 3;\n  func(\"Just a test of %d\", x);\n\n  auto log = buffer.str();\n\n  // Check that only one line was generated for the message. If the\n  // message was sent to more than one logger, it could result in\n  // multiple messages.\n  EXPECT_THAT(std::count(log.begin(), log.end(), '\\n'), Eq(1));\n\n  // Check that the log contain the (expanded) message, the correct\n  // indication (e.g., ERROR or WARNING), and the module name.\n  EXPECT_THAT(log, HasSubstr(\"Just a test of 3\"));\n  EXPECT_THAT(log, HasSubstr(kind));\n  EXPECT_THAT(log, HasSubstr(MYSQL_ROUTER_LOG_DOMAIN));\n}\n\nTEST(FunctionalTest, Handlers) {\n  // The loader creates these modules during start, so tests of the\n  // logger that involves the loader are inside the loader unit\n  // test. Here we instead call these functions directly.\n  ASSERT_NO_THROW(g_registry->create_logger(MYSQL_ROUTER_LOG_DOMAIN));\n\n  std::stringstream buffer;\n  auto handler = std::make_shared<StreamHandler>(buffer);\n  g_registry->add_handler(StreamHandler::kDefaultName, handler);\n  attach_handler_to_all_loggers(*g_registry, StreamHandler::kDefaultName);\n\n  set_log_level_for_all_loggers(*g_registry, LogLevel::kDebug);\n  expect_log(log_error, buffer, \"ERROR\");\n  expect_log(log_warning, buffer, \"WARNING\");\n  expect_log(log_info, buffer, \"INFO\");\n  expect_log(log_debug, buffer, \"DEBUG\");\n\n  set_log_level_for_all_loggers(*g_registry, LogLevel::kError);\n  expect_log(log_error, buffer, \"ERROR\");\n  expect_no_log(log_warning, buffer);\n  expect_no_log(log_info, buffer);\n  expect_no_log(log_debug, buffer);\n\n  set_log_level_for_all_loggers(*g_registry, LogLevel::kWarning);\n  expect_log(log_error, buffer, \"ERROR\");\n  expect_log(log_warning, buffer, \"WARNING\");\n  expect_no_log(log_info, buffer);\n  expect_no_log(log_debug, buffer);\n\n  // Check that nothing is logged when the handler is unregistered.\n  g_registry->remove_handler(StreamHandler::kDefaultName);\n  set_log_level_for_all_loggers(*g_registry, LogLevel::kNotSet);\n  expect_no_log(log_error, buffer);\n  expect_no_log(log_warning, buffer);\n  expect_no_log(log_info, buffer);\n  expect_no_log(log_debug, buffer);\n}\n\n\n\nint main(int argc, char *argv[]) {\n  g_here = Path(argv[0]).dirname();\n  init_test_logger();\n  g_registry = &mysql_harness::DIM::instance().get_LoggingRegistry();\n\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/harness/tests/test_mysql_router_thread.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n#include <thread>\n\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n#include \"mysql_router_thread.h\"\n\n// this flag should be set to true by thread\nbool flag = false;\n\nclass MySqlRouterThreadTest : public testing::Test {\npublic:\n  void SetUp() override {\n    flag = false;\n  }\n};\n\nvoid* f(void*) {\n  flag = true;\n  return nullptr;\n}\n\nTEST_F(MySqlRouterThreadTest, ThreadCreated) {\n  mysql_harness::MySQLRouterThread thread;\n  ASSERT_NO_THROW(thread.run(&f, nullptr));\n  std::this_thread::sleep_for(std::chrono::milliseconds(100));\n  ASSERT_TRUE(flag);\n}\n\nTEST_F(MySqlRouterThreadTest, DetachTreadCreated) {\n  mysql_harness::MySQLRouterThread thread;\n  ASSERT_NO_THROW(thread.run(&f, nullptr, true));\n  std::this_thread::sleep_for(std::chrono::milliseconds(100));\n  ASSERT_TRUE(flag);\n}\n\nint main(int argc, char *argv[]) {\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/harness/tests/test_queue.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"queue.h\"\n\n////////////////////////////////////////\n// Test system include files\n#include \"test/helpers.h\"\n\n////////////////////////////////////////\n// Third-party include files\n#include \"gmock/gmock.h\"\n\n////////////////////////////////////////\n// Standard include files\n#include <chrono>\n#include <thread>\n#include <map>\n#include <set>\n#include <tuple>\n\nusing mysql_harness::queue;\n\nusing std::chrono::milliseconds;\nusing std::get;\nusing std::map;\nusing std::ref;\nusing std::set;\nusing std::thread;\n\nusing testing::Contains;\nusing testing::Eq;\nusing testing::Not;\n\nclass TestFilledQueue : public ::testing::Test {\n public:\n  void SetUp() {\n    for (int i = 0 ; i < 10 ; ++i)\n      my_queue.push(i);\n    ASSERT_THAT(my_queue.empty(), Eq(false));\n    ASSERT_THAT(my_queue.size(), Eq(10U));\n  }\n\n  queue<int> my_queue;\n};\n\n\nTEST_F(TestFilledQueue, BasicPop1) {\n  for (int i = 0 ; i < 10 ; ++i) {\n    auto ptr = my_queue.pop();\n    EXPECT_THAT(*ptr, Eq(i));\n  }\n}\n\nTEST_F(TestFilledQueue, BasicPop2) {\n  for (int i = 0 ; i < 10 ; ++i) {\n    int value;\n    my_queue.pop(&value);\n    EXPECT_THAT(value, Eq(i));\n  }\n}\n\nTEST_F(TestFilledQueue, BasicPopTimeout1) {\n  for (int i = 0 ; i < 10 ; ++i) {\n    auto ptr = my_queue.pop(milliseconds(100));\n    EXPECT_THAT(*ptr, Eq(i));\n  }\n  EXPECT_THAT(my_queue.pop(milliseconds(100)), Eq(nullptr));\n}\n\nTEST_F(TestFilledQueue, BasicPopTimeout2) {\n  int value;\n  for (int i = 0 ; i < 10 ; ++i) {\n    my_queue.pop(&value, milliseconds(100));\n    EXPECT_THAT(value, Eq(i));\n  }\n  EXPECT_THAT(my_queue.pop(&value, milliseconds(100)), Eq(false));\n}\n\nTEST_F(TestFilledQueue, BasicTryPop1) {\n  for (int i = 0 ; i < 10 ; ++i) {\n    auto ptr = my_queue.try_pop();\n    EXPECT_THAT(*ptr, Eq(i));\n  }\n  EXPECT_THAT(my_queue.try_pop(), Eq(nullptr));\n}\n\nTEST_F(TestFilledQueue, BasicTryPop2) {\n  int value;\n  for (int i = 0 ; i < 10 ; ++i) {\n    my_queue.try_pop(&value);\n    EXPECT_THAT(value, Eq(i));\n  }\n  EXPECT_THAT(my_queue.try_pop(&value), Eq(false));\n}\n\nTEST(TestQueue, PopEmpty) {\n  queue<int> my_queue;\n\n  ASSERT_THAT(my_queue.empty(), Eq(true));\n  EXPECT_THAT(my_queue.size(), Eq(0U));\n  EXPECT_THAT(my_queue.try_pop(), Eq(nullptr));\n  EXPECT_THAT(my_queue.pop(milliseconds(100)), Eq(nullptr));\n  int value;\n  EXPECT_THAT(my_queue.pop(&value, milliseconds(100)), Eq(false));\n}\n\nTEST(TestQueue, PopPush) {\n  queue<int> my_queue;\n  ASSERT_THAT(my_queue.empty(), Eq(true));\n\n  auto f1 = [&my_queue]{\n    int value;\n    my_queue.pop(&value);\n    EXPECT_THAT(value, Eq(47));\n  };\n\n  thread t1(f1);\n  std::this_thread::sleep_for(milliseconds(10));\n  my_queue.push(47);\n  t1.join();\n  EXPECT_THAT(my_queue.empty(), Eq(true));\n}\n\nTEST(TestQueue, ProducerConsumer) {\n  // Don't spawn too many threads, it generates a segfault.\n  thread intermediates[10];\n  thread producers[50];\n  thread consumers[50];\n  queue<std::pair<thread::id, int>> queue[2];\n\n  std::atomic<bool> done(false);\n\n  // Spawn intermediate threads first\n  auto intermediate_thread = [&queue, &done] {\n    try {\n      while (!done)\n        if (auto elem = queue[0].pop(milliseconds(100)))\n          queue[1].push(*elem);\n    } catch (std::exception& err) {\n      std::cerr << err.what() << std::endl;\n    }\n  };\n\n  for (auto& intermediate : intermediates)\n    intermediate = thread(intermediate_thread);\n\n  auto producer_thread = [&queue, &done]{\n    try {\n      for (int i = 0 ; i < 1000 ; ++i)\n        queue[0].push(std::make_pair(std::this_thread::get_id(), i));\n    } catch (std::exception& err) {\n      std::cerr << err.what() << std::endl;\n    }\n  };\n\n  for (auto& producer : producers)\n    producer = thread(producer_thread);\n\n  auto consumer_thread = [&queue, &done]{\n    map<thread::id, set<int>> seen;\n    try {\n      while (!done) {\n        auto ptr = queue[1].pop(milliseconds(100));\n        EXPECT_THAT(seen[get<0>(*ptr)], Not(Contains(get<1>(*ptr))));\n        seen[get<0>(*ptr)].insert(get<1>(*ptr));\n      }\n    } catch (std::exception& err) {\n      std::cerr << err.what() << std::endl;\n    }\n  };\n\n  for (auto& consumer : consumers)\n    consumer = thread(consumer_thread);\n\n  // Wait for the producers to finish\n  for (auto& producer : producers)\n    producer.join();\n\n  done = true;\n\n  for (auto& consumer : consumers)\n    consumer.join();\n\n  for (auto& intermediate : intermediates)\n    intermediate.join();\n}\n"
  },
  {
    "path": "src/harness/tests/test_random_generator.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"gtest/gtest.h\"\n\n#include \"random_generator.h\"\n\nnamespace {\nconst std::string kAlphabetDigits = \"0123456789\";\nconst std::string kAlphabetLowercase = \"abcdefghijklmnopqrstuvwxyz\";\nconst std::string kAlphabetUppercase = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\";\nconst std::string kAlphabetSpecial = \"~@#$^&*()-=+]}[{|;:.>,</?\";\nconst std::string kAlphabetAll = kAlphabetDigits + kAlphabetLowercase + kAlphabetUppercase + kAlphabetSpecial;\n}\n\n\nTEST(UtilsTests, generate_identifier_ok) {\n  using RandGen = mysql_harness::RandomGenerator;\n  RandGen generator;\n  const unsigned kTestLen = 100u;\n\n\n  // digits only\n  {\n    std::string s = generator.generate_identifier(kTestLen, RandGen::AlphabetDigits);\n    EXPECT_EQ(std::string::npos, s.find_first_not_of(kAlphabetDigits));\n    EXPECT_EQ(kTestLen, s.size());\n  }\n\n  // lowercase letters only\n  {\n    std::string s = generator.generate_identifier(kTestLen, RandGen::AlphabetLowercase);\n    EXPECT_EQ(std::string::npos, s.find_first_not_of(kAlphabetLowercase));\n    EXPECT_EQ(kTestLen, s.size());\n  }\n\n  // uppercase letters only\n  {\n    std::string s = generator.generate_identifier(kTestLen, RandGen::AlphabetUppercase);\n    EXPECT_EQ(std::string::npos, s.find_first_not_of(kAlphabetUppercase));\n    EXPECT_EQ(kTestLen, s.size());\n  }\n\n  // special characters only\n  {\n    std::string s = generator.generate_identifier(kTestLen, RandGen::AlphabetSpecial);\n    EXPECT_EQ(std::string::npos, s.find_first_not_of(kAlphabetSpecial));\n    EXPECT_EQ(kTestLen, s.size());\n  }\n\n  // digits and lowercase only\n  {\n    std::string s = generator.generate_identifier(kTestLen, RandGen::AlphabetLowercase | RandGen::AlphabetDigits);\n    EXPECT_EQ(std::string::npos, s.find_first_not_of(kAlphabetDigits+kAlphabetLowercase));\n    EXPECT_EQ(kTestLen, s.size());\n  }\n\n  // length = 0\n  {\n    std::string s = generator.generate_identifier(0);\n    EXPECT_EQ(0u, s.size());\n  }\n\n  // length = 1\n  {\n    std::string s = generator.generate_identifier(1);\n    EXPECT_EQ(1u, s.size());\n  }\n}\n\nTEST(UtilsTests, generate_identifier_wrong_alphabet_mask) {\n  using RandGen = mysql_harness::RandomGenerator;\n  RandGen generator;\n  const unsigned kTestLen = 100u;\n\n  {\n    try {\n      generator.generate_identifier(kTestLen, 0);\n      FAIL() << \"Expected exception\";\n    }\n    catch(const std::invalid_argument& exc) {\n      EXPECT_STREQ(\"Wrong alphabet mask provided for generate_identifier(0)\", exc.what());\n    }\n    catch (...) {\n      FAIL() << \"Invalid exception, expected std::invalid_argument\";\n    }\n  }\n}\n\nTEST(UtilsTests, generate_identifier_check_symbols_usage) {\n  // check that all the symbols from the alphabet are being used\n  using RandGen = mysql_harness::RandomGenerator;\n  RandGen generator;\n  // number large enough so that (in practice) at least one representative of each\n  // possible random char will be present in the output.  Obviously nothing is 100%\n  // guaranteed, the idea is to make random test failures very very very unlikely.\n  constexpr unsigned kBigNumber = 10 * 1000;\n\n  std::string s = generator.generate_identifier(kBigNumber, RandGen::AlphabetAll);\n  for (const char& c: kAlphabetAll) {\n    EXPECT_NE(std::string::npos, s.find(c));\n  }\n}\n\nTEST(UtilsTests, generate_strong_password_ok) {\n  mysql_harness::RandomGenerator generator;\n  const unsigned kTestLen = 8u;\n\n  const std::string pass = generator.generate_strong_password(kTestLen);\n\n  EXPECT_EQ(kTestLen, pass.size());\n\n  // at least one digit\n  EXPECT_NE(std::string::npos, pass.find_first_of(kAlphabetDigits));\n  // at least one lowercase letter\n  EXPECT_NE(std::string::npos, pass.find_first_of(kAlphabetLowercase));\n  // at least one uppercase letter\n  EXPECT_NE(std::string::npos, pass.find_first_of(kAlphabetUppercase));\n  // at least one spacial char\n  EXPECT_NE(std::string::npos, pass.find_first_of(kAlphabetSpecial));\n\n  // check that all the chars are from the alphabet\n  EXPECT_EQ(std::string::npos, pass.find_first_not_of(kAlphabetAll));\n}\n\nTEST(UtilsTests, generate_strong_password_too_short) {\n  mysql_harness::RandomGenerator generator;\n  const unsigned kTestLen = 7u;\n\n  try {\n    generator.generate_strong_password(kTestLen);\n    FAIL() << \"Expected exception\";\n  }\n  catch(const std::invalid_argument& exc) {\n    EXPECT_STREQ(\"The password needs to be at least 8 charactes long\", exc.what());\n  }\n  catch (...) {\n    FAIL() << \"Invalid exception, expected std::invalid_argument\";\n  }\n}\n"
  },
  {
    "path": "src/harness/tests/test_resolver.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql/harness/networking/ip_address.h\"\n#include \"mysql/harness/networking/ipv4_address.h\"\n#include \"mysql/harness/networking/resolver.h\"\n\n////////////////////////////////////////\n// Test system include files\n#include \"test/helpers.h\"\n\n////////////////////////////////////////\n// Third-party include files\n#include \"gmock/gmock.h\"\n\n////////////////////////////////////////\n// Standard include files\n#include <exception>\n\nusing mysql_harness::IPAddress;\nusing mysql_harness::Resolver;\n\n// class used for testing private functionality like caching\nclass MockResolver : public Resolver {\n public:\n  uint16_t cached_tcp_service_by_name(const std::string &name) const {\n    return Resolver::cached_tcp_service_by_name(name);\n  }\n\n  std::string cached_tcp_service_by_port(uint16_t port) const {\n    return Resolver::cached_tcp_service_by_port(port);\n  }\n};\n\nTEST(TestResolver, Hostname) {\n  using ::testing::Contains;\n  Resolver resolver;\n\n  {\n    // Some systems have both IPv4 and IPv6 for 'localhost'\n    mysql_harness::IPAddress ip4(\"127.0.0.1\");\n    mysql_harness::IPAddress ip6(\"::1\");\n\n    auto result = resolver.hostname(\"localhost\");\n    ASSERT_THAT(result, ::testing::AnyOf(Contains(ip4), Contains(ip6)));\n  }\n}\n\nTEST(TestNameResolver, HostnameFail) {\n  Resolver resolver;\n  ASSERT_THROW({resolver.hostname(\"foobar.dkkdkdk.r4nd0m\");},\n               std::invalid_argument);\n}\n\nTEST(TestResolver, TCPServiceName) {\n  Resolver resolver;\n  EXPECT_EQ(21, resolver.tcp_service_name(\"ftp\"));\n#if !defined(_WIN32) && !defined(__sun)\n  EXPECT_EQ(3306, resolver.tcp_service_name(\"mysql\"));\n#endif\n}\n\nTEST(TestResolver, TCPServiceNameFail) {\n  Resolver resolver;\n  ASSERT_THROW({resolver.tcp_service_name(\"foo_bar\");}, std::invalid_argument);\n}\n\nTEST(TestResolver, TCPServicePort) {\n  Resolver resolver;\n\n  EXPECT_EQ(std::string(\"ftp\"), resolver.tcp_service_port(21));\n#if !defined(_WIN32) && !defined(__sun)\n  EXPECT_EQ(std::string(\"mysql\"), resolver.tcp_service_port(3306));\n#endif\n  EXPECT_EQ(std::string(\"ssh\"), resolver.tcp_service_port(22));\n  // port numbers without service name\n  EXPECT_EQ(std::string(\"49151\"),\n            resolver.tcp_service_port(49151)); // IANA reserved port number\n}\n\nTEST(TestResolver, TCPServiceCache) {\n  MockResolver resolver;\n\n  // query, so cache is updated\n  EXPECT_EQ(21, resolver.tcp_service_name(\"ftp\"));\n#if !defined(_WIN32) && !defined(__sun)\n  EXPECT_EQ(std::string(\"mysql\"), resolver.tcp_service_port(3306));\n#endif\n  // check if in cache\n#if !defined(_WIN32) && !defined(__sun)\n  EXPECT_EQ(3306, resolver.cached_tcp_service_by_name(\"mysql\"));\n#endif\n  EXPECT_EQ(std::string(\"ftp\"), resolver.cached_tcp_service_by_port(21));\n}\n\nint main(int argc, char *argv[]) {\n#ifdef _WIN32\n  WSADATA wsaData;\n  int iResult;\n  iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);\n  if (iResult != 0) {\n    std::cout << \"WSAStartup() failed\\n\";\n    return 1;\n  }\n#endif\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/harness/tests/test_utilities.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"utilities.h\"\n\n#ifdef __GNUC__\n#pragma GCC diagnostic push\n#pragma GCC diagnostic ignored \"-Wundef\"\n#endif\n\n////////////////////////////////////////\n// Third-party include files\n#include \"gtest/gtest.h\"\n\n#ifdef __GNUC__\n#pragma GCC diagnostic pop\n#endif\n\n\n////////////////////////////////////////\n// Standard include files\n#include <cstring>\n#include <iostream>\n#include <map>\n#include <stdexcept>\n#include <string>\n#include <utility>\n\nusing std::map;\nusing std::string;\nusing std::pair;\nusing std::make_pair;\n\nusing mysql_harness::utility::find_range_first;\nusing mysql_harness::utility::make_range;\nusing mysql_harness::utility::strip;\nusing mysql_harness::utility::strip_copy;\n\nTEST(TestUtilities, Strip) {\n  const char *strings[][2] = {\n    { \"foo\", \"foo\", },\n    { \" foo\", \"foo\", },\n    { \"foo \", \"foo\", },\n    { \" \\tfoo \\t\\t\", \"foo\", },\n    { \"\", \"\" },\n  };\n\n  for (auto sample : make_range(strings, sizeof(strings)/sizeof(*strings))) {\n    std::string str = strip_copy(sample[0]);\n    EXPECT_EQ(sample[1], str);\n  }\n}\n\nTEST(TestUtilities, FindRangeFirst) {\n  using Map = map<pair<string, string>, string>;\n  Map assoc;\n  assoc.emplace(make_pair(\"one\", \"first\"), \"alpha\");\n  assoc.emplace(make_pair(\"one\", \"second\"), \"beta\");\n  assoc.emplace(make_pair(\"two\", \"first\"), \"gamma\");\n  assoc.emplace(make_pair(\"two\", \"second\"), \"delta\");\n  assoc.emplace(make_pair(\"two\", \"three\"), \"epsilon\");\n\n  auto rng1 = find_range_first(assoc, \"one\");\n  ASSERT_NE(rng1.first, assoc.end());\n  EXPECT_NE(rng1.second, assoc.end());\n  EXPECT_EQ(2, distance(rng1.first, rng1.second));\n  EXPECT_EQ(\"alpha\", rng1.first++->second);\n  EXPECT_EQ(\"beta\", rng1.first++->second);\n  EXPECT_EQ(rng1.second, rng1.first);\n\n  auto rng2 = find_range_first(assoc, \"two\");\n  ASSERT_NE(rng2.first, assoc.end());\n  EXPECT_EQ(rng2.second, assoc.end());\n  EXPECT_EQ(3, distance(rng2.first, rng2.second));\n  EXPECT_EQ(\"gamma\", rng2.first++->second);\n  EXPECT_EQ(\"delta\", rng2.first++->second);\n  EXPECT_EQ(\"epsilon\", rng2.first++->second);\n  EXPECT_EQ(rng2.second, rng2.first);\n\n  // Check for ranges that do not exist\n  auto rng3 = find_range_first(assoc, \"aardvark\");\n  EXPECT_EQ(0, distance(rng3.first, rng3.second));\n\n  auto rng4 = find_range_first(assoc, \"xyzzy\");\n  EXPECT_EQ(rng4.first, assoc.end());\n  EXPECT_EQ(0, distance(rng4.first, rng4.second));\n}\n"
  },
  {
    "path": "src/http/CMakeLists.txt",
    "content": "# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nADD_SUBDIRECTORY(src)\nIF(ENABLE_TESTS)\n  ADD_SUBDIRECTORY(tests)\nENDIF()\n"
  },
  {
    "path": "src/http/include/mysqlrouter/http_client.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_HTTP_CLIENT_INCLUDED\n#define MYSQLROUTER_HTTP_CLIENT_INCLUDED\n\n#include \"mysqlrouter/http_client_export.h\"\n#include \"mysqlrouter/http_common.h\"\n\nclass HTTP_CLIENT_EXPORT HttpClient {\npublic:\n  HttpClient();\n  ~HttpClient();\n  HttpClient(IOContext &io_ctx, const std::string &address, uint16_t port);\n\n  void make_request(HttpRequest *req, HttpMethod::type method, const std::string &uri);\n  void make_request_sync(HttpRequest *req, HttpMethod::type method, const std::string &uri);\nprivate:\n  class impl;\n\n  std::unique_ptr<impl> pImpl_;\n\n  IOContext &io_ctx_;\n};\n\n#endif\n"
  },
  {
    "path": "src/http/include/mysqlrouter/http_client_export.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_HTTP_CLIENT_EXPORT_INCLUDED\n#define MYSQLROUTER_HTTP_CLIENT_EXPORT_INCLUDED\n\n#ifdef _WIN32\n#  ifdef http_client_DEFINE_STATIC\n#    define HTTP_CLIENT_EXPORT\n#  else\n#    ifdef http_client_EXPORTS\n#      define HTTP_CLIENT_EXPORT __declspec(dllexport)\n#    else\n#      define HTTP_CLIENT_EXPORT __declspec(dllimport)\n#    endif\n#  endif\n#else\n#  define HTTP_CLIENT_EXPORT\n#endif\n\n#endif\n"
  },
  {
    "path": "src/http/include/mysqlrouter/http_common.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_HTTP_COMMON_INCLUDED\n#define MYSQLROUTER_HTTP_COMMON_INCLUDED\n\n#include \"mysqlrouter/http_common_export.h\"\n\n#include <ctime>\n#include <memory>\n#include <functional>  // std::function\n#include <vector>\n#include <bitset>\n\nstruct evhttp_uri;\nstruct evhttp_request;\nstruct evkeyvalq;\nstruct evkeyval;\nstruct evbuffer;\n\nclass HttpServer;\n\n// http_common.cc\n\n\n// https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml\nnamespace HttpStatusCode {\n  using name_type = const char *;\n  using key_type = unsigned int;\n\n  constexpr key_type Continue = 100;  // RFC 7231\n  constexpr key_type SwitchingProtocols = 101;  // RFC 7231\n  constexpr key_type Processing = 102;  // RFC 2518\n  constexpr key_type EarlyHints = 103;  // RFC 8297\n\n  constexpr key_type Ok = 200;  // RFC 7231\n  constexpr key_type Created = 201;  // RFC 7231\n  constexpr key_type Accepted = 202;  // RFC 7231\n  constexpr key_type NonAuthoritiveInformation = 203;  // RFC 7231\n  constexpr key_type NoContent = 204;  // RFC 7231\n  constexpr key_type ResetContent = 205;  // RFC 7231\n  constexpr key_type PartialContent = 206;  // RFC 7233\n  constexpr key_type MultiStatus = 207;  // RFC 4918\n  constexpr key_type AlreadyReported = 208;  // RFC 5842\n  constexpr key_type InstanceManipulationUsed = 226;  // RFC 3229\n\n  constexpr key_type MultipleChoices = 300;  // RFC 7231\n  constexpr key_type MovedPermanently = 301;  // RFC 7231\n  constexpr key_type Found = 302;  // RFC 7231\n  constexpr key_type SeeOther = 303;  // RFC 7231\n  constexpr key_type NotModified = 304;  // RFC 7232\n  constexpr key_type UseProxy = 305;  // RFC 7231\n  constexpr key_type TemporaryRedirect = 307;  // RFC 7231\n  constexpr key_type PermanentRedirect = 308;  // RFC 7538\n\n  constexpr key_type BadRequest = 400;  // RFC 7231\n  constexpr key_type Unauthorized = 401;  // RFC 7235\n  constexpr key_type PaymentRequired = 402;  // RFC 7231\n  constexpr key_type Forbidden = 403;  // RFC 7231\n  constexpr key_type NotFound = 404;  // RFC 7231\n  constexpr key_type MethodNotAllowed = 405;  // RFC 7231\n  constexpr key_type NotAcceptable = 406;  // RFC 7231\n  constexpr key_type ProxyAuthenticationRequired = 407;  // RFC 7235\n  constexpr key_type RequestTimeout = 408;  // RFC 7231\n  constexpr key_type Conflicts = 409;  // RFC 7231\n  constexpr key_type Gone = 410;  // RFC 7231\n  constexpr key_type LengthRequired = 411;  // RFC 7231\n  constexpr key_type PreconditionFailed = 412;  // RFC 7232\n  constexpr key_type PayloadTooLarge = 413;  // RFC 7231\n  constexpr key_type URITooLarge = 414;  // RFC 7231\n  constexpr key_type UnsupportedMediaType = 415;  // RFC 7231\n  constexpr key_type RangeNotSatisfiable = 416;  // RFC 7233\n  constexpr key_type ExpectationFailed = 417;  // RFC 7231\n  constexpr key_type IamaTeapot = 418;  // RFC 7168\n  constexpr key_type MisdirectedRequest = 421;  // RFC 7540\n  constexpr key_type UnprocessableEntity = 422;  // RFC 4918\n  constexpr key_type Locked = 423;  // RFC 4918\n  constexpr key_type FailedDependency = 424;  // RFC 4918\n  constexpr key_type UpgradeRequired = 426;  // RFC 7231\n  constexpr key_type PreconditionRequired = 428;  // RFC 6585\n  constexpr key_type TooManyRequests = 429;  // RFC 6585\n  constexpr key_type RequestHeaderFieldsTooLarge = 431;  // RFC 6585\n  constexpr key_type UnavailableForLegalReasons = 451;  // RFC 7725\n\n  constexpr key_type InternalError = 500;  // RFC 7231\n  constexpr key_type NotImplemented = 501;  // RFC 7231\n  constexpr key_type BadGateway = 502;  // RFC 7231\n  constexpr key_type ServiceUnavailable = 503;  // RFC 7231\n  constexpr key_type GatewayTimeout = 504;  // RFC 7231\n  constexpr key_type HTTPVersionNotSupported = 505;  // RFC 7231\n  constexpr key_type VariantAlsoNegotiates = 506;  // RFC 2295\n  constexpr key_type InsufficientStorage = 507;  // RFC 4918\n  constexpr key_type LoopDetected = 508;  // RFC 5842\n  constexpr key_type NotExtended = 510;  // RFC 2774\n  constexpr key_type NetworkAuthorizationRequired = 511;  // RFC 6585\n\n  inline name_type get_default_status_text(key_type key) {\n    switch (key) {\n      case Continue: return \"Continue\";\n      case SwitchingProtocols: return \"Switching Protocols\";\n      case Processing: return \"Processing\";\n      case EarlyHints: return \"Early Hints\";\n\n      case Ok: return \"Ok\";\n      case Created: return \"Created\";\n      case Accepted: return \"Accepted\";\n      case NonAuthoritiveInformation: return \"Non Authoritive Information\";\n      case NoContent: return \"No Content\";\n      case ResetContent: return \"Reset Content\";\n      case PartialContent: return \"Partial Content\";\n      case MultiStatus: return \"Multi Status\";\n      case AlreadyReported: return \"Already Reported\";\n      case InstanceManipulationUsed: return \"IMUsed\";\n\n      case MultipleChoices: return \"Multiple Choices\";\n      case MovedPermanently: return \"Moved Permanently\";\n      case Found: return \"Found\";\n      case SeeOther: return \"See Other\";\n      case NotModified: return \"Not Modified\";\n      case UseProxy: return \"Use Proxy\";\n      case TemporaryRedirect: return \"Temporary Redirect\";\n      case PermanentRedirect: return \"Permanent Redirect\";\n\n      case BadRequest: return \"Bad Request\";\n      case Unauthorized: return \"Unauthorized\";\n      case PaymentRequired: return \"Payment Required\";\n      case Forbidden: return \"Forbidden\";\n      case NotFound: return \"Not Found\";\n      case MethodNotAllowed: return \"Method Not Allowed\";\n      case NotAcceptable: return \"Not NotAcceptable\";\n      case ProxyAuthenticationRequired: return \"Proxy Authentication Required\";\n      case RequestTimeout: return \"Request Timeout\";\n      case Conflicts: return \"Conflicts\";\n      case Gone: return \"Gone\";\n      case LengthRequired: return \"Length Required\";\n      case PreconditionFailed: return \"Precondition Failed\";\n      case PayloadTooLarge: return \"Payload Too Large\";\n      case URITooLarge: return \"URITooLarge\";\n      case UnsupportedMediaType: return \"Unsupported MediaType\";\n      case RangeNotSatisfiable: return \"Range Not Satisfiable\";\n      case ExpectationFailed: return \"Expectation Failed\";\n      case IamaTeapot: return \"I am a Teapot\";\n      case MisdirectedRequest: return \"Misdirected Request\";\n      case UnprocessableEntity: return \"Unprocessable Entity\";\n      case Locked: return \"Locked\";\n      case FailedDependency: return \"Failed Dependency\";\n      case UpgradeRequired: return \"Upgrade Required\";\n      case PreconditionRequired: return \"Precondition Required\";\n      case TooManyRequests: return \"Too Many Requests\";\n      case RequestHeaderFieldsTooLarge: return \"Request Header Fields Too Large\";\n      case UnavailableForLegalReasons: return \"Unavailable For Legal Reasons\";\n\n      case InternalError: return \"Internal Error\";\n      case NotImplemented: return \"Not Implemented\";\n      case BadGateway: return \"Bad Gateway\";\n      case ServiceUnavailable: return \"Service Unavailable\";\n      case GatewayTimeout: return \"Gateway Timeout\";\n      case HTTPVersionNotSupported: return \"HTTP Version Not Supported\";\n      case VariantAlsoNegotiates: return \"Variant Also Negotiates\";\n      case InsufficientStorage: return \"Insufficient Storage\";\n      case LoopDetected: return \"Loop Detected\";\n      case NotExtended: return \"Not Extended\";\n      case NetworkAuthorizationRequired: return \"Network Authorization Required\";\n      default: throw std::logic_error(\"no text for HTTP Status \" + std::to_string(key));\n    }\n  }\n}\n\n/**\n * representation of HTTP URI.\n *\n * wraps evhttp_uri and exposes a subset of the libevent function-set\n */\nclass HTTP_COMMON_EXPORT HttpUri {\npublic:\n  HttpUri(std::unique_ptr<evhttp_uri, std::function<void(evhttp_uri *)>> uri);\n  HttpUri(HttpUri &&);\n  ~HttpUri();\n\n  /**\n   * create HttpUri from string.\n   */\n  static HttpUri parse(const std::string &uri_str);\n\n  /**\n   * get path part of the URI.\n   */\n  std::string get_path() const;\nprivate:\n  struct impl;\n\n  std::unique_ptr<impl> pImpl_;\n};\n\n/**\n * a Buffer to send/read from network.\n *\n * - memory buffer\n * - file\n *\n * wraps evbuffer\n */\nclass HTTP_COMMON_EXPORT HttpBuffer {\npublic:\n  HttpBuffer(std::unique_ptr<evbuffer, std::function<void(evbuffer *)>> buffer);\n\n  HttpBuffer(HttpBuffer &&);\n\n  ~HttpBuffer();\n\n  /**\n   * add a memory buffer.\n   */\n  void add(const char *data, size_t data_size);\n\n  /**\n   * add a file.\n   */\n  void add_file(int file_fd, off_t offset, off_t size);\n\n  /**\n   * get length of buffer.\n   */\n  size_t length() const;\n\n  /**\n   * move a subset out from the front of the buffer.\n   */\n  std::vector<uint8_t> pop_front(size_t length);\nprivate:\n  struct impl;\n\n  std::unique_ptr<impl> pImpl_;\n\n  friend class HttpRequest;\n};\n\n/**\n * headers of a HTTP response/request.\n */\nclass HTTP_COMMON_EXPORT HttpHeaders {\npublic:\n  class HTTP_COMMON_EXPORT Iterator {\n    evkeyval *node_;\n  public:\n    Iterator(evkeyval *node):\n      node_{node}\n    {}\n    std::pair<std::string, std::string> operator*();\n    Iterator& operator++();\n    bool operator!=(const Iterator &it) const;\n  };\n  HttpHeaders(std::unique_ptr<evkeyvalq, std::function<void(evkeyvalq *)>> hdrs);\n  HttpHeaders(HttpHeaders &&);\n\n  ~HttpHeaders();\n\n  /**\n   * add a header.\n   */\n  int add(const char *key, const char *value);\n\n  /**\n   * get a header.\n   */\n  const char *get(const char *key) const;\n\n  Iterator begin();\n  Iterator end();\nprivate:\n  struct impl;\n\n  std::unique_ptr<impl> pImpl_;\n};\n\nnamespace HttpMethod {\n  using type = int;\n  using pos_type = unsigned;\n  namespace Pos {\n    constexpr pos_type Get = 0;\n    constexpr pos_type Post = 1;\n    constexpr pos_type Head = 2;\n    constexpr pos_type Put = 3;\n    constexpr pos_type Delete = 4;\n    constexpr pos_type Options = 5;\n    constexpr pos_type Trace = 6;\n    constexpr pos_type Connect = 7;\n    constexpr pos_type Patch = 8;\n\n    constexpr pos_type _LAST = Patch;\n  }\n  using Bitset = std::bitset<Pos::_LAST>;\n\n  constexpr type Get { 1 << Pos::Get };\n  constexpr type Post { 1 << Pos::Post };\n  constexpr type Head { 1 << Pos::Head };\n  constexpr type Put { 1 << Pos::Put };\n  constexpr type Delete { 1 << Pos::Delete };\n  constexpr type Options { 1 << Pos::Options };\n  constexpr type Trace { 1 << Pos::Trace };\n  constexpr type Connect { 1 << Pos::Connect };\n  constexpr type Patch { 1 << Pos::Patch };\n}\n\n/**\n * IO Context for network operations.\n *\n * wraps libevent's base\n */\nclass HTTP_COMMON_EXPORT IOContext {\npublic:\n  IOContext();\n  ~IOContext();\n\n  /**\n   * wait for events to fire and calls handlers.\n   *\n   * exits if no more pending events\n   *\n   * @returns false if no events were pending nor active, true otherwise\n   * @throws  std::runtime_error on internal, unexpected error\n   */\n  bool dispatch();\nprivate:\n  class impl;\n\n  std::unique_ptr<impl> pImpl_;\n  friend class HttpClient;\n};\n\n/**\n * a HTTP request and response.\n *\n * wraps evhttp_request\n */\nclass HTTP_COMMON_EXPORT HttpRequest {\npublic:\n  using RequestHandler = void (*)(HttpRequest *, void *);\n\n  HttpRequest(RequestHandler cb, void *arg = nullptr);\n  HttpRequest(std::unique_ptr<evhttp_request, std::function<void(evhttp_request *)>> req);\n  HttpRequest(HttpRequest &&);\n  ~HttpRequest();\n\n  HttpHeaders get_output_headers();\n  HttpHeaders get_input_headers() const;\n  HttpBuffer get_output_buffer();\n  HttpBuffer get_input_buffer() const;\n\n  unsigned get_response_code() const;\n  std::string get_response_code_line() const;\n\n  HttpMethod::type get_method() const;\n\n  std::string get_uri() const;\n\n  void send_reply(int status_code) {\n    send_reply(status_code, HttpStatusCode::get_default_status_text(status_code));\n  }\n  void send_reply(int status_code, std::string status_text);\n  void send_reply(int status_code, std::string status_text, HttpBuffer &buffer);\n\n  void send_error(int status_code) {\n    send_error(status_code, HttpStatusCode::get_default_status_text(status_code));\n  }\n  void send_error(int status_code, std::string status_text);\n\n  static void sync_callback(HttpRequest *, void *);\n\n  operator bool();\n\n  int error_code();\n  void error_code(int);\n  std::string error_msg();\n\n  /**\n   * is request modified since 'last_modified'.\n   *\n   * @return true, if local content is newer than the clients last known date, false otherwise\n   */\n  bool is_modified_since(time_t last_modified);\n\n  /**\n   * add a Last-Modified-Since header to the response headers.\n   */\n  bool add_last_modified(time_t last_modified);\nprivate:\n  class impl;\n\n  std::unique_ptr<impl> pImpl_;\n\n  friend class HttpClient;\n};\n\n// http_time.cc\n\n/**\n * convert a Date: header into a time_t.\n *\n * @return a time_t representation of Date: header value\n * @throws std::out_of_range on invalid formats\n */\nHTTP_COMMON_EXPORT time_t time_from_rfc5322_fixdate(const char *date_buf);\n\n/**\n * convert time_t into a Date: header value.\n *\n */\nHTTP_COMMON_EXPORT int time_to_rfc5322_fixdate(time_t ts, char *date_buf, size_t date_buf_len);\n\n#endif\n"
  },
  {
    "path": "src/http/include/mysqlrouter/http_common_export.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_HTTP_COMMON_EXPORT_INCLUDED\n#define MYSQLROUTER_HTTP_COMMON_EXPORT_INCLUDED\n\n#ifdef _WIN32\n#  ifdef http_common_DEFINE_STATIC\n#    define HTTP_COMMON_EXPORT\n#  else\n#    ifdef http_common_EXPORTS\n#      define HTTP_COMMON_EXPORT __declspec(dllexport)\n#    else\n#      define HTTP_COMMON_EXPORT __declspec(dllimport)\n#    endif\n#  endif\n#else\n#  define HTTP_COMMON_EXPORT\n#endif\n\n#endif\n"
  },
  {
    "path": "src/http/include/mysqlrouter/http_server_component.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_HTTP_SERVER_COMPONENT_INCLUDED\n#define MYSQLROUTER_HTTP_SERVER_COMPONENT_INCLUDED\n\n#include <mutex>\n\n#include \"mysqlrouter/http_common.h\"\n#include \"mysqlrouter/http_server_export.h\"\n\nclass HTTP_SERVER_EXPORT BaseRequestHandler {\npublic:\n  void call(HttpRequest &req, void *me) {\n    auto *my = static_cast<BaseRequestHandler *>(me);\n    my->handle_request(req);\n  }\n\n  virtual void handle_request(HttpRequest &req) = 0;\n\n  virtual ~BaseRequestHandler();\n};\n\nclass HTTP_SERVER_EXPORT HttpServerComponent {\npublic:\n  static HttpServerComponent& getInstance();\n  void init(std::shared_ptr<HttpServer> srv);\n  void add_route(const std::string &url_regex, std::unique_ptr<BaseRequestHandler> cb);\n  void remove_route(const std::string &url_regex);\nprivate:\n  // disable copy, as we are a single-instance\n  HttpServerComponent(HttpServerComponent const &) = delete;\n  void operator=(HttpServerComponent const &) = delete;\n\n  struct RouterData {\n    std::string url_regex_str;\n    std::unique_ptr<BaseRequestHandler> handler;\n  };\n\n  std::mutex rh_mu; // request handler mutex\n  std::vector<RouterData> request_handlers_;\n\n  std::weak_ptr<HttpServer> srv_;\n\n  HttpServerComponent() = default;\n};\n\n\n#endif\n"
  },
  {
    "path": "src/http/include/mysqlrouter/http_server_export.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_HTTP_SERVER_EXPORT_INCLUDED\n#define MYSQLROUTER_HTTP_SERVER_EXPORT_INCLUDED\n\n#ifdef _WIN32\n#  ifdef http_server_DEFINE_STATIC\n#    define HTTP_SERVER_EXPORT\n#  else\n#    ifdef http_server_EXPORTS\n#      define HTTP_SERVER_EXPORT __declspec(dllexport)\n#    else\n#      define HTTP_SERVER_EXPORT __declspec(dllimport)\n#    endif\n#  endif\n#else\n#  define HTTP_SERVER_EXPORT\n#endif\n\n#endif\n"
  },
  {
    "path": "src/http/include/mysqlrouter/rest_client.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n#ifndef MYSQL_ROUTER_REST_CLIENT_H_INCLUDED\n#define MYSQL_ROUTER_REST_CLIENT_H_INCLUDED\n\n#include \"mysqlrouter/http_client.h\"\n\nclass HTTP_CLIENT_EXPORT RestClient {\npublic:\n  RestClient(IOContext &io_ctx, const std::string &address, uint16_t port):\n    http_client_{io_ctx, address, port},\n    hostname_{address}\n  {}\n\n  HttpRequest request_sync(\n      HttpMethod::type method,\n      const std::string &uri,\n      const std::string &request_body = {},\n      const std::string &content_type = \"application/json\");\n\nprivate:\n  HttpClient http_client_;\n  std::string hostname_;\n};\n\n#endif\n"
  },
  {
    "path": "src/http/src/CMakeLists.txt",
    "content": "# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nADD_LIBRARY(http_common\n  SHARED\n  http_common.cc\n  http_time.cc\n  )\nTARGET_LINK_LIBRARIES(http_common\n  ${LIBEVENT2_EXTRA}\n  ${LIBEVENT2_CORE})\n\nADD_HARNESS_PLUGIN(http_server\n  NO_INSTALL\n  SOURCES http_server_plugin.cc\n  static_files.cc\n  http_server_component.cc\n  REQUIRES router_lib;http_common)\n\n## place event.dll into the same dir as http_common\n##\n## setting PATH isn't good enough as the windows has an event.dll\n## in system paths which would take precedence\nIF (WIN32 AND (NOT WITH_LIBEVENT STREQUAL \"system\"))\n  SET(LIBEVENT_NAME event)\n\n  ADD_CUSTOM_COMMAND(TARGET http_common PRE_BUILD\n    COMMAND ${CMAKE_COMMAND} -E copy_if_different\n    \"${WITH_LIBEVENT}/bin/${LIBEVENT_NAME}.dll\"\n    \"$<TARGET_FILE_DIR:http_common>/${LIBEVENT_NAME}.dll\"\n    )\nENDIF()\n\nADD_LIBRARY(http_client\n  SHARED\n  http_client.cc\n  rest_client.cc\n  )\nTARGET_LINK_LIBRARIES(http_client\n  ${LIBEVENT2_EXTRA}\n  ${LIBEVENT2_CORE}\n  http_common)\n\nADD_EXECUTABLE(rest_cli\n  rest_cli.cc)\nTARGET_LINK_LIBRARIES(rest_cli\n  harness-library\n  http_client)\n\n\nINCLUDE_DIRECTORIES(${LIBEVENT2_INCLUDE_DIR}/)\nINCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/harness/include/)\nINCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/ext/rapidjson/include/)\nINCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/router/include/)\nINCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/metadata_cache/include/)\nINCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/http/include/)\n"
  },
  {
    "path": "src/http/src/http_client.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <event2/event.h>\n#include <event2/http.h>\n\n#include <string>\n#include <iostream>\n\n#include \"mysqlrouter/http_client.h\"\n#include \"http_request_impl.h\"\n\nclass IOContext::impl {\npublic:\n  std::unique_ptr<event_base, std::function<void(event_base *)>> ev_base { nullptr, event_base_free };\n\n  impl() {\n    ev_base.reset(event_base_new());\n  }\n};\n\nIOContext::IOContext():\n  pImpl_{new impl()}\n{\n}\n\nbool IOContext::dispatch() {\n  int ret = event_base_dispatch(pImpl_->ev_base.get());\n\n  if (ret == -1) {\n    // we don't have an better error here\n    throw std::runtime_error(\"event_base_dispath() error\");\n  }\n\n  return ret == 0;\n}\n\nIOContext::~IOContext() = default;\n\n\nclass HttpClient::impl {\npublic:\n  std::unique_ptr<evhttp_connection, std::function<void(evhttp_connection *)>> conn { nullptr, evhttp_connection_free };\n\n  impl() = default;\n};\n\nHttpClient::HttpClient(IOContext &io_ctx, const std::string &address, uint16_t port):\n  pImpl_{new impl()},\n\n  // gcc-4.8 requires a () here, instead of {}\n  //\n  // invalid initialization of non-const reference of type ‘IOContext&’ from an rvalue of type ‘<brace-enclosed initializer list>’\n  io_ctx_(io_ctx)\n{\n  auto *ev_base = io_ctx_.pImpl_->ev_base.get();\n  pImpl_->conn.reset(evhttp_connection_base_new(ev_base, NULL, address.c_str(), port));\n}\n\nvoid HttpClient::make_request(HttpRequest *req, HttpMethod::type method, const std::string &uri) {\n  auto *ev_req = req->pImpl_->req.get();\n\n  if (0 != evhttp_make_request(pImpl_->conn.get(), ev_req,\n      static_cast<enum evhttp_cmd_type>(method), uri.c_str())) {\n    throw std::runtime_error(\"evhttp_make_request() failed\");\n  }\n\n  // don't free the evhttp_request() when HttpRequest gets destructed\n  // as the eventloop will do it\n  req->pImpl_->disown();\n}\n\nvoid HttpClient::make_request_sync(HttpRequest *req, HttpMethod::type method, const std::string &uri) {\n  make_request(req, method, uri);\n\n  io_ctx_.dispatch();\n}\n\n\nHttpClient::~HttpClient() = default;\n"
  },
  {
    "path": "src/http/src/http_common.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/**\n * API Facade around libevent's http interface\n */\n\n#include <iostream>\n\n#include <event2/buffer.h>\n#include <event2/event.h>\n#include <event2/http.h>\n#include <event2/util.h>\n#include <event2/keyvalq_struct.h>\n#include <event2/http_struct.h>\n\n#include \"mysqlrouter/http_common.h\"\n#include \"http_request_impl.h\"\n\n\n// wrap evhttp_uri\n\nstruct HttpUri::impl {\n  std::unique_ptr<evhttp_uri, std::function<void(evhttp_uri *)>> uri;\n};\n\nHttpUri::HttpUri(std::unique_ptr<evhttp_uri, std::function<void(evhttp_uri *)>> uri) {\n  pImpl_.reset(new impl { std::move(uri) });\n}\n\nHttpUri::HttpUri(HttpUri &&) = default;\nHttpUri::~HttpUri() = default;\n\nHttpUri HttpUri::parse(const std::string &uri_str) {\n  // wrap a owned pointer\n  return HttpUri {\n    std::unique_ptr<evhttp_uri, decltype(&evhttp_uri_free)> {\n      evhttp_uri_parse(uri_str.c_str()), &evhttp_uri_free }\n  };\n}\n\nstd::string HttpUri::get_path() const {\n  return evhttp_uri_get_path(pImpl_->uri.get());\n}\n\n\n// wrap evbuffer\n\nstruct HttpBuffer::impl {\n  std::unique_ptr<evbuffer, std::function<void(evbuffer *)>> buffer;\n};\n\n// non-owning pointer\nHttpBuffer::HttpBuffer(std::unique_ptr<evbuffer, std::function<void(evbuffer *)>> buffer) {\n  pImpl_.reset(new impl { std::move(buffer) });\n}\n\nvoid HttpBuffer::add(const char *data, size_t data_size) {\n  evbuffer_add(pImpl_->buffer.get(), data, data_size);\n}\n\nvoid HttpBuffer::add_file(int file_fd, off_t offset, off_t size) {\n  evbuffer_add_file(pImpl_->buffer.get(), file_fd, offset, size);\n}\n\nsize_t HttpBuffer::length() const {\n  return evbuffer_get_length(pImpl_->buffer.get());\n}\n\nstd::vector<uint8_t> HttpBuffer::pop_front(size_t len) {\n  std::vector<uint8_t> data;\n  data.resize(len);\n\n  int bytes_read;\n  if (-1 == (bytes_read = evbuffer_remove(pImpl_->buffer.get(), data.data(), data.size()))) {\n    throw std::runtime_error(\"couldn't pop bytes from front of buffer\");\n  }\n\n  data.resize(bytes_read);\n  data.shrink_to_fit();\n\n  return data;\n}\n\n\nHttpBuffer::HttpBuffer(HttpBuffer &&)  = default;\nHttpBuffer::~HttpBuffer() = default;\n\n\n// wrap evkeyvalq\n\nstruct HttpHeaders::impl {\n  std::unique_ptr<evkeyvalq, std::function<void(evkeyvalq *)>> hdrs;\n};\n\nHttpHeaders::HttpHeaders(std::unique_ptr<evkeyvalq, std::function<void(evkeyvalq *)>> hdrs) {\n  pImpl_.reset(new impl { std::move(hdrs) });\n}\n\nint HttpHeaders::add(const char *key, const char *value) {\n  return evhttp_add_header(pImpl_->hdrs.get(), key, value);\n}\n\nconst char *HttpHeaders::get(const char *key) const {\n  return evhttp_find_header(pImpl_->hdrs.get(), key);\n}\n\nstd::pair<std::string, std::string> HttpHeaders::Iterator::operator *() {\n  return { node_->key, node_->value };\n}\n\nHttpHeaders::Iterator& HttpHeaders::Iterator::operator ++() {\n  node_ = node_->next.tqe_next;\n\n  return *this;\n}\n\nbool HttpHeaders::Iterator::operator!=(const Iterator &it) const {\n  return node_ != it.node_;\n}\n\nHttpHeaders::Iterator HttpHeaders::begin() {\n  return pImpl_->hdrs->tqh_first;\n}\n\nHttpHeaders::Iterator HttpHeaders::end() {\n  return *(pImpl_->hdrs->tqh_last);\n}\n\nHttpHeaders::HttpHeaders(HttpHeaders &&) = default;\nHttpHeaders::~HttpHeaders() = default;\n\n\n// wrap evhttp_request\n\nHttpRequest::HttpRequest(std::unique_ptr<evhttp_request, std::function<void(evhttp_request *)>> req)\n{\n  pImpl_.reset(new impl { std::move(req) });\n}\n\nstruct RequestHandlerCtx {\n  HttpRequest *req;\n  HttpRequest::RequestHandler cb;\n  void *cb_data;\n};\n\nvoid HttpRequest::sync_callback(HttpRequest *req, void *){\n  // if connection was successful, keep the request-object alive past this\n  // request-handler lifetime\n  evhttp_request *ev_req = req->pImpl_->req.get();\n  if (ev_req) {\n#if LIBEVENT_VERSION_NUMBER >= 0x02010600\n    evhttp_request_own(ev_req);\n#else\n    // swap the evhttp_request, as evhttp_request_own() is broken\n    // before libevent 2.1.6.\n    //\n    // see: https://github.com/libevent/libevent/issues/68\n    //\n    // libevent will free the event, let's make sure it only sees\n    // an empty evhttp_request\n    auto *copied_req = evhttp_request_new(nullptr, nullptr);\n\n    std::swap(copied_req->evcon, ev_req->evcon);\n    std::swap(copied_req->flags, ev_req->flags);\n\n    std::swap(copied_req->input_headers, ev_req->input_headers);\n    std::swap(copied_req->output_headers, ev_req->output_headers);\n    std::swap(copied_req->remote_host, ev_req->remote_host);\n    std::swap(copied_req->remote_port, ev_req->remote_port);\n    std::swap(copied_req->host_cache, ev_req->host_cache);\n    std::swap(copied_req->kind, ev_req->kind);\n    std::swap(copied_req->type, ev_req->type);\n    std::swap(copied_req->headers_size, ev_req->headers_size);\n    std::swap(copied_req->body_size, ev_req->body_size);\n    std::swap(copied_req->uri, ev_req->uri);\n    std::swap(copied_req->uri_elems, ev_req->uri_elems);\n    std::swap(copied_req->major, ev_req->major);\n    std::swap(copied_req->minor, ev_req->minor);\n    std::swap(copied_req->response_code, ev_req->response_code);\n    std::swap(copied_req->response_code_line, ev_req->response_code_line);\n    std::swap(copied_req->input_buffer, ev_req->input_buffer);\n    std::swap(copied_req->ntoread, ev_req->ntoread);\n    copied_req->chunked = ev_req->chunked;\n    copied_req->userdone = ev_req->userdone;\n    std::swap(copied_req->output_buffer, ev_req->output_buffer);\n\n    // release the old one, and let the event-loop free it\n    req->pImpl_->req.release();\n\n    // but take ownership of the new one\n    req->pImpl_->req.reset(copied_req);\n    req->pImpl_->own();\n#endif\n  }\n};\n\nHttpRequest::HttpRequest(HttpRequest::RequestHandler cb, void *cb_arg) {\n  auto *ev_req = evhttp_request_new(\n      [](evhttp_request *req, void *ev_cb_arg) {\n        auto *ctx = static_cast<RequestHandlerCtx *>(ev_cb_arg);\n\n        ctx->req->pImpl_->req.release(); // the old request object may already be free()ed in case of error\n        ctx->req->pImpl_->req.reset(req); // just update with what we have\n        ctx->cb(ctx->req, ctx->cb_data);\n\n        delete ctx;\n      }, new RequestHandlerCtx{this, cb, cb_arg});\n\n#if LIBEVENT_VERSION_NUMBER >= 0x02010000\n  evhttp_request_set_error_cb(ev_req, [](evhttp_request_error err_code, void *ev_cb_arg){\n      auto *ctx = static_cast<RequestHandlerCtx *>(ev_cb_arg);\n\n      ctx->req->error_code(err_code);\n      });\n#endif\n\n  pImpl_.reset(new impl {\n      std::unique_ptr<evhttp_request, std::function<void(evhttp_request *)>>(\n        ev_req, evhttp_request_free)});\n}\n\nHttpRequest::HttpRequest(HttpRequest &&) = default;\nHttpRequest::~HttpRequest() = default;\n\nvoid HttpRequest::send_error(int status_code, std::string status_text) {\n  evhttp_send_error(pImpl_->req.get(), status_code, status_text.c_str());\n}\n\nvoid HttpRequest::send_reply(int status_code, std::string status_text, HttpBuffer &chunk) {\n  evhttp_send_reply(pImpl_->req.get(), status_code, status_text.c_str(), chunk.pImpl_->buffer.get());\n}\n\nvoid HttpRequest::send_reply(int status_code, std::string status_text) {\n  evhttp_send_reply(pImpl_->req.get(), status_code, status_text.c_str(), nullptr);\n}\n\nHttpRequest::operator bool() {\n  return pImpl_->req.operator bool();\n}\n\nvoid HttpRequest::error_code(int err_code) {\n  pImpl_->error_code = err_code;\n}\n\nint HttpRequest::error_code() {\n  return pImpl_->error_code;\n}\n\nstd::string HttpRequest::error_msg() {\n  switch(pImpl_->error_code) {\n#if LIBEVENT_VERSION_NUMBER >= 0x02010000\n  case EVREQ_HTTP_TIMEOUT: return \"timeout\";\n  case EVREQ_HTTP_EOF: return \"eof\";\n  case EVREQ_HTTP_INVALID_HEADER: return \"invalid-header\";\n  case EVREQ_HTTP_BUFFER_ERROR: return \"buffer-error\";\n  case EVREQ_HTTP_REQUEST_CANCEL: return \"request-cancel\";\n  case EVREQ_HTTP_DATA_TOO_LONG: return \"data-too-long\";\n#endif\n  default: return \"unknown\";\n  }\n}\n\n\nstd::string HttpRequest::get_uri() const {\n  return evhttp_request_get_uri(pImpl_->req.get());\n}\n\nHttpHeaders HttpRequest::get_output_headers() {\n  auto *ev_req = pImpl_->req.get();\n\n  if (nullptr == ev_req) {\n    throw std::logic_error(\"request is null\");\n  }\n  // wrap a non-owned pointer\n  return std::unique_ptr<evkeyvalq, std::function<void(evkeyvalq *)>>(\n      evhttp_request_get_output_headers(ev_req),\n         [](evkeyvalq *){});\n}\n\nHttpHeaders HttpRequest::get_input_headers() const {\n  auto *ev_req = pImpl_->req.get();\n\n  if (nullptr == ev_req) {\n    throw std::logic_error(\"request is null\");\n  }\n  // wrap a non-owned pointer\n  return std::unique_ptr<evkeyvalq, std::function<void(evkeyvalq *)>>(\n      evhttp_request_get_input_headers(ev_req),\n         [](evkeyvalq *){});\n}\n\nHttpBuffer HttpRequest::get_output_buffer() {\n  // wrap a non-owned pointer\n  auto *ev_req = pImpl_->req.get();\n\n  if (nullptr == ev_req) {\n    throw std::logic_error(\"request is null\");\n  }\n\n  return std::unique_ptr<evbuffer, std::function<void(evbuffer *)>>(\n      evhttp_request_get_output_buffer(ev_req), [](evbuffer *){});\n}\n\nunsigned HttpRequest::get_response_code() const {\n  auto *ev_req = pImpl_->req.get();\n\n  if (nullptr == ev_req) {\n    throw std::logic_error(\"request is null\");\n  }\n\n  return evhttp_request_get_response_code(ev_req);\n}\n\nstd::string HttpRequest::get_response_code_line() const {\n  auto *ev_req = pImpl_->req.get();\n  if (nullptr == ev_req) {\n    throw std::logic_error(\"request is null\");\n  }\n\n#if LIBEVENT_VERSION_NUMBER >= 0x02010000\n  return evhttp_request_get_response_code_line(ev_req);\n#else\n  return HttpStatusCode::get_default_status_text(evhttp_request_get_response_code(ev_req));\n#endif\n}\n\n\nHttpBuffer HttpRequest::get_input_buffer() const {\n  auto *ev_req = pImpl_->req.get();\n\n  if (nullptr == ev_req) {\n    throw std::logic_error(\"request is null\");\n  }\n\n  // wrap a non-owned pointer\n  return std::unique_ptr<evbuffer, std::function<void(evbuffer *)>>(\n      evhttp_request_get_input_buffer(ev_req),\n         [](evbuffer *){});\n}\n\nHttpMethod::type HttpRequest::get_method() const {\n  return evhttp_request_get_command(pImpl_->req.get());\n}\n\nbool HttpRequest::is_modified_since(time_t last_modified) {\n  auto req_hdrs = get_input_headers();\n\n  auto *if_mod_since = req_hdrs.get(\"If-Modified-Since\");\n  if (if_mod_since != nullptr) {\n    try {\n      time_t if_mod_since_ts = time_from_rfc5322_fixdate(if_mod_since);\n\n      if (!(last_modified > if_mod_since_ts)) {\n        return false;\n      }\n    } catch (const std::exception &) {\n      return false;\n    }\n  }\n  return true;\n}\n\nbool HttpRequest::add_last_modified(time_t last_modified) {\n  auto out_hdrs = get_output_headers();\n  char date_buf[50];\n\n  if (sizeof(date_buf) - time_to_rfc5322_fixdate(last_modified, date_buf, sizeof(date_buf)) > 0) {\n    out_hdrs.add(\"Last-Modified\", date_buf);\n\n    return true;\n  } else {\n    return false;\n  }\n}\n"
  },
  {
    "path": "src/http/src/http_request_impl.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <event2/http.h>\n\nclass HttpRequest::impl {\npublic:\n  using evhttp_req_type = std::unique_ptr<evhttp_request, std::function<void(evhttp_request *)>>;\n\n  int error_code {0};\n\n  evhttp_req_type req;\n\n  impl(evhttp_req_type request):\n    req{std::move(request)}\n  {\n  }\n\n  void own() {\n    owns_http_request = true;\n  }\n\n  void disown() {\n    owns_http_request = false;\n  }\n\n  ~impl() {\n    // there are two ways to drop ownership of the wrapped\n    // evhttp_request:\n    //\n    // - before evhttp_make_request(), HttpRequest owns the evhttp_request\n    // - after evhttp_make_request(), ownership moves to the event-loop\n    // - after the eventloop is done, it free()s the evhttp_request if no one called \"evhttp_request_own\"\n    // - ... in which case HttpRequest stays the owner and has to free it\n    if (req && !evhttp_request_is_owned(req.get()) && !owns_http_request) {\n      req.release();\n    }\n  }\nprivate:\n  bool owns_http_request { true };\n};\n"
  },
  {
    "path": "src/http/src/http_server_component.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <string>\n#include <memory>\n#include <mutex>\n\n#include \"mysqlrouter/http_server_component.h\"\n#include \"http_server_plugin.h\"\n\n// must be declared in .cc file as otherwise each plugin\n// gets its own class-instance of BaseRequestHandler which leads\n// to undefined behaviour (ubsan -> vptr)\nBaseRequestHandler::~BaseRequestHandler() = default;\n\n//\n// HTTP Server's public API\n//\nvoid HttpServerComponent::add_route(const std::string &url_regex, std::unique_ptr<BaseRequestHandler> handler)\n{\n  std::lock_guard<std::mutex> lock(rh_mu);\n\n  // if srv_ already points to the http_server forward the\n  // route directly, otherwise add it to the delayed backlog\n  if (auto srv = srv_.lock()) {\n    srv->add_route(url_regex, std::move(handler));\n  } else {\n    request_handlers_.emplace_back(RouterData { url_regex, std::move(handler) });\n  }\n}\n\nvoid HttpServerComponent::remove_route(const std::string &url_regex)\n{\n  std::lock_guard<std::mutex> lock(rh_mu);\n\n  // if srv_ already points to the http_server forward the\n  // route directly, otherwise add it to the delayed backlog\n  if (auto srv = srv_.lock()) {\n    srv->remove_route(url_regex);\n  } else {\n    for (auto it = request_handlers_.begin(); it != request_handlers_.end(); ) {\n      if (it->url_regex_str == url_regex) {\n        it = request_handlers_.erase(it);\n      } else {\n        it++;\n      }\n    }\n  }\n}\n\n\nvoid HttpServerComponent::init(std::shared_ptr<HttpServer> srv) {\n  std::lock_guard<std::mutex> lock(rh_mu);\n\n  srv_ = srv;\n\n  for (auto &route: request_handlers_) {\n    srv->add_route(route.url_regex_str, std::move(route.handler));\n  }\n\n  request_handlers_.clear();\n}\n\nHttpServerComponent& HttpServerComponent::getInstance() {\n  static HttpServerComponent instance;\n\n  return instance;\n}\n\n"
  },
  {
    "path": "src/http/src/http_server_plugin.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/**\n */\n\n#include <atomic>\n#include <chrono>\n#include <thread>\n#include <mutex>\n\n#include <sys/types.h>\n\n#include <event2/buffer.h>\n#include <event2/event.h>\n#include <event2/http.h>\n#include <event2/listener.h>\n#include <event2/util.h>\n\n// Harness interface include files\n#include \"mysql/harness/config_parser.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysql/harness/plugin.h\"\n\n#include \"mysqlrouter/plugin_config.h\"\n#include \"mysqlrouter/http_server_component.h\"\n#include \"http_server_plugin.h\"\n#include \"posix_re.h\"\n\nIMPORT_LOG_FUNCTIONS()\n\nstatic constexpr const char kSectionName[] { \"http_server\" };\n\nusing mysql_harness::ARCHITECTURE_DESCRIPTOR;\nusing mysql_harness::PluginFuncEnv;\nusing mysql_harness::PLUGIN_ABI_VERSION;\nusing mysql_harness::Plugin;\n\nstd::atomic<int> g_shutdown_pending { 0 };\n\n/**\n * request router\n *\n * send requests for a path of the URI to a handler callback\n *\n * if no handler is found, reply with 404 not found\n */\nvoid HttpRequestRouter::append(const std::string &url_regex_str, std::unique_ptr<BaseRequestHandler> cb) {\n  std::lock_guard<std::mutex> lock(route_mtx_);\n  request_handlers_.emplace_back(RouterData { url_regex_str, PosixRE {url_regex_str}, std::move(cb) });\n}\n\nvoid HttpRequestRouter::remove(const std::string &url_regex_str) {\n  std::lock_guard<std::mutex> lock(route_mtx_);\n  for (auto it = request_handlers_.begin(); it != request_handlers_.end(); ) {\n    if (it->url_regex_str == url_regex_str) {\n      it = request_handlers_.erase(it);\n    } else {\n      it++;\n    }\n  }\n}\n\n// if no routes are specified, return 404\nvoid HttpRequestRouter::route_default(HttpRequest &req) {\n  if (default_route_) {\n    default_route_->handle_request(req);\n  } else {\n    req.send_error(HttpStatusCode::NotFound, \"Not Found\");\n  }\n}\n\nvoid HttpRequestRouter::set_default_route(std::unique_ptr<BaseRequestHandler> cb) {\n  std::lock_guard<std::mutex> lock(route_mtx_);\n  default_route_ = std::move(cb);\n}\n\nvoid HttpRequestRouter::clear_default_route() {\n  std::lock_guard<std::mutex> lock(route_mtx_);\n  default_route_ = nullptr;\n}\n\n\nvoid HttpRequestRouter::route(HttpRequest req) {\n  std::lock_guard<std::mutex> lock(route_mtx_);\n\n  auto uri = req.get_uri();\n\n  for (auto &request_handler: request_handlers_) {\n    if (request_handler.url_regex.search(uri)) {\n      request_handler.handler->handle_request(req);\n      return;\n    }\n  }\n\n  route_default(req);\n}\n\n\nvoid stop_eventloop(evutil_socket_t, short, void *cb_arg) {\n  auto *ev_base = static_cast<event_base *>(cb_arg);\n\n  if (g_shutdown_pending != 0) {\n    event_base_loopexit(ev_base, nullptr);\n  }\n}\n\nvoid HttpRequestThread::accept_socket() {\n  // we could replace the callback after accept here, but sadly\n  // we don't have access to it easily\n  evhttp_accept_socket_with_handle(ev_http.get(), accept_fd_);\n}\n\nvoid HttpRequestThread::set_request_router(HttpRequestRouter &router) {\n  evhttp_set_gencb(ev_http.get(), [](evhttp_request * req, void * user_data) {\n      auto *rtr = static_cast<HttpRequestRouter *>(user_data);\n      rtr->route(\n          HttpRequest {\n          std::unique_ptr<evhttp_request, std::function<void(evhttp_request *)>>(\n              req, [](evhttp_request *){})\n          });\n      }, &router);\n}\n\nvoid HttpRequestThread::wait_and_dispatch() {\n  struct timeval tv { 0, 100 * 1000 };\n  event_add(ev_shutdown_timer.get(), &tv);\n  event_base_dispatch(ev_base.get());\n}\n\nclass HttpRequestMainThread : public HttpRequestThread\n{\npublic:\n  HttpRequestMainThread(const char *address, uint16_t port):\n    address_(address), port_(port) {\n\n    auto *handle = evhttp_bind_socket_with_handle(ev_http.get(), address_.c_str(), port_);\n    if (nullptr == handle) {\n      throw std::runtime_error(\"binding socket failed ...\");\n    }\n    accept_fd_ = evhttp_bound_socket_get_fd(handle);\n  }\nprivate:\n  std::string address_;\n  uint16_t port_;\n};\n\nclass HttpRequestWorkerThread : public HttpRequestThread\n{\npublic:\n  explicit HttpRequestWorkerThread(harness_socket_t accept_fd)\n  {\n    accept_fd_ = accept_fd;\n  }\n};\n\nvoid HttpServer::join_all() {\n  while (!sys_threads.empty()) {\n    auto &thr = sys_threads.back();\n    thr.join();\n    sys_threads.pop_back();\n  }\n}\n\nvoid HttpServer::start(size_t max_threads) {\n  thread_contexts.emplace_back(HttpRequestMainThread(address_.c_str(), port_));\n\n  harness_socket_t accept_fd = thread_contexts[0].get_socket_fd();\n  for (size_t ndx = 1; ndx < max_threads; ndx++) {\n    thread_contexts.emplace_back(HttpRequestWorkerThread(accept_fd));\n  }\n\n  for (size_t ndx = 0; ndx < max_threads; ndx++) {\n    auto &thr = thread_contexts[ndx];\n\n    sys_threads.emplace_back(\n      [&]() {\n        thr.set_request_router(request_router_);\n        thr.accept_socket();\n        thr.wait_and_dispatch();\n      }\n    );\n  }\n}\n\nvoid HttpServer::add_route(const std::string &url_regex, std::unique_ptr<BaseRequestHandler> cb) {\n  log_debug(\"adding route for regex: %s\", url_regex.c_str());\n  if (url_regex.empty()) {\n    request_router_.set_default_route(std::move(cb));\n  } else {\n    request_router_.append(url_regex, std::move(cb));\n  }\n}\n\nvoid HttpServer::remove_route(const std::string &url_regex) {\n  log_debug(\"removing route for regex: %s\", url_regex.c_str());\n  if (url_regex.empty()) {\n    request_router_.clear_default_route();\n  } else {\n    request_router_.remove(url_regex);\n  }\n}\n\n\nclass PluginConfig : public mysqlrouter::BasePluginConfig {\npublic:\n  std::string static_basedir;\n  std::string srv_address;\n  uint16_t srv_port;\n\n  explicit PluginConfig(const mysql_harness::ConfigSection *section):\n    mysqlrouter::BasePluginConfig(section),\n    static_basedir(get_option_string(section, \"static_folder\")),\n    srv_address(get_option_string(section, \"bind_address\")),\n    srv_port(get_uint_option<uint16_t>(section, \"port\"))\n  {}\n\n  std::string get_default(const std::string &option) const override {\n    const std::map<std::string, std::string> defaults{\n        {\"bind_address\", \"0.0.0.0\"},\n        {\"port\", \"5555\"},\n    };\n\n    auto it = defaults.find(option);\n    if (it == defaults.end()) {\n      return std::string();\n    }\n    return it->second;\n  }\n\n  bool is_required(const std::string & /* option */) const override {\n    return false;\n  }\n};\nstatic std::map<std::string, std::shared_ptr<HttpServer>> http_servers;\n\nstatic void init(PluginFuncEnv* env) {\n  const mysql_harness::AppInfo* info = get_app_info(env);\n  bool has_started = false;\n\n  if (nullptr == info->config) {\n    return;\n  }\n\n  // assume there is only one section for us\n  //\n  try {\n    for (const mysql_harness::ConfigSection* section: info->config->sections()) {\n      if (section->name != kSectionName) {\n        continue;\n      }\n\n      if (has_started) {\n        // ignore all the other sections for now\n        continue;\n      }\n\n      has_started = true;\n\n      PluginConfig config {section};\n\n      log_info(\"listening on %s:%u\", config.srv_address.c_str(), config.srv_port);\n\n      http_servers.emplace(\n          std::make_pair(section->name,\n          std::make_shared<HttpServer>(config.srv_address.c_str(), config.srv_port)));\n\n      auto srv = http_servers.at(section->name);\n      HttpServerComponent::getInstance().init(srv);\n\n      if (!config.static_basedir.empty()) {\n        srv->add_route(\"\",\n            std::unique_ptr<HttpStaticFolderHandler>(\n              new HttpStaticFolderHandler(config.static_basedir)));\n      }\n    }\n  } catch (const std::invalid_argument& exc) {\n    set_error(env, mysql_harness::kConfigInvalidArgument, \"%s\", exc.what());\n  } catch (const std::exception& exc) {\n    set_error(env, mysql_harness::kRuntimeError, \"%s\", exc.what());\n  } catch (...) {\n    set_error(env, mysql_harness::kUndefinedError, \"Unexpected exception\");\n  }\n}\n\nstatic void start(PluginFuncEnv* env) {\n  // - version string\n  // - hostname\n  // - active-connections vs. max-connections\n  // - listing port statistics\n  //   - ip addresses\n  // - backend status\n  //   - throughput\n  //   - response latency (min time first packet)\n  //   - replication lag\n  // - backend health\n  // - configuration\n  //   - ports\n  //   - log-level\n  //   - metadata server ip\n  // - cluster health\n  //   - time since last check\n  //   - log group member changes\n  // - important log messages\n  // - mismatch between group-membership and metadata\n  try {\n    auto srv = http_servers.at(get_config_section(env)->name);\n\n    // add routes\n\n    srv->start(8);\n\n    // we are supposed to block\n    while (is_running(env)) {\n      std::this_thread::sleep_for(std::chrono::milliseconds(100));\n    }\n    g_shutdown_pending = 1;\n\n    srv->join_all();\n  } catch (const std::invalid_argument& exc) {\n    set_error(env, mysql_harness::kConfigInvalidArgument, \"%s\", exc.what());\n  } catch (const std::exception& exc) {\n    set_error(env, mysql_harness::kRuntimeError, \"%s\", exc.what());\n  } catch (...) {\n    set_error(env, mysql_harness::kUndefinedError, \"Unexpected exception\");\n  }\n}\n\nextern \"C\" {\nPlugin HTTP_SERVER_EXPORT harness_plugin_http_server = {\n  PLUGIN_ABI_VERSION,\n  ARCHITECTURE_DESCRIPTOR,\n  \"HTTP_SERVER\",\n  VERSION_NUMBER(0, 0, 1),\n  0, nullptr,  // requires\n  0, nullptr,  // conflicts\n  init,        // init\n  nullptr,     // deinit\n  start,       // start\n  nullptr,     // stop\n};\n}\n"
  },
  {
    "path": "src/http/src/http_server_plugin.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_HTTP_SERVER_PLUGIN_INCLUDED\n#define MYSQLROUTER_HTTP_SERVER_PLUGIN_INCLUDED\n\n#include <string>\n#include <vector>\n#include <thread>\n#include <mutex>\n\n#include <event2/buffer.h>\n#include <event2/event.h>\n#include <event2/http.h>\n#include <event2/listener.h>\n#include <event2/util.h>\n\n#include \"mysqlrouter/http_server_component.h\"\n#include \"posix_re.h\"\n\nusing harness_socket_t = evutil_socket_t;\n\nvoid stop_eventloop(evutil_socket_t, short, void *cb_arg);\n\nclass HttpRequestRouter\n{\npublic:\n  void append(const std::string &url_regex_str, std::unique_ptr<BaseRequestHandler> cb);\n  void remove(const std::string &url_regex_str);\n\n  // if no routes are specified, return 404\n  void route_default(HttpRequest &req);\n\n  void set_default_route(std::unique_ptr<BaseRequestHandler> cb);\n  void clear_default_route();\n  void route(HttpRequest req);\nprivate:\n  struct RouterData {\n    std::string url_regex_str;\n    PosixRE url_regex;\n    std::unique_ptr<BaseRequestHandler> handler;\n  };\n  std::vector<RouterData> request_handlers_;\n\n  std::unique_ptr<BaseRequestHandler> default_route_;\n\n  std::mutex route_mtx_;\n};\n\n/**\n * base class of all http request handler threads\n *\n * - HttpRequestMainThread opens the socket, and accepts and handles connections\n * - HttpRequestWorkerThread accepts and handles connections, using the socket\n *   listened by the main-thread\n *\n * As all threads can accept in parallel this may lead to a thundering herd problem\n * and quite likely it is better to let only one thread accept() and push the socket\n * handling into async-deque and let all workers steal from the queue\n */\nclass HttpRequestThread\n{\npublic:\n  HttpRequestThread() :\n    ev_base(event_base_new(), &event_base_free),\n    ev_http(evhttp_new(ev_base.get()), &evhttp_free),\n    ev_shutdown_timer(event_new(ev_base.get(), -1, EV_PERSIST, stop_eventloop, ev_base.get()), &event_free)\n  {}\n\n  harness_socket_t get_socket_fd() { return accept_fd_; }\n\n  void accept_socket();\n  void set_request_router(HttpRequestRouter &router);\n  void wait_and_dispatch();\nprotected:\n  std::unique_ptr<event_base, decltype(&event_base_free)> ev_base;\n  std::unique_ptr<evhttp, decltype(&evhttp_free)> ev_http;\n  std::unique_ptr<event, decltype(&event_free)> ev_shutdown_timer;\n\n  harness_socket_t accept_fd_ { -1 };\n};\n\n\nclass HttpServer\n{\npublic:\n  HttpServer(const char *address, uint16_t port):\n    address_(address), port_(port)\n  {};\n\n  HttpServer(const HttpServer&) = delete;\n  HttpServer &operator=(const HttpServer&) = delete;\n\n  HttpServer(HttpServer &&) = default;\n  HttpServer &operator=(HttpServer&&) = default;\n\n  void join_all();\n\n  ~HttpServer() {\n    join_all();\n  }\n\n  void start(size_t max_threads);\n  void add_route(const std::string &url_regex, std::unique_ptr<BaseRequestHandler> cb);\n  void remove_route(const std::string &url_regex);\nprivate:\n  std::vector<HttpRequestThread> thread_contexts;\n  std::string address_;\n  uint16_t port_;\n  HttpRequestRouter request_router_;\n\n  std::vector<std::thread> sys_threads;\n};\n\nclass HttpStaticFolderHandler: public BaseRequestHandler {\npublic:\n  explicit HttpStaticFolderHandler(std::string static_basedir):\n    static_basedir_(std::move(static_basedir)) {}\n\n  void handle_request(HttpRequest &req) override;\nprivate:\n  std::string static_basedir_;\n};\n\n#endif\n"
  },
  {
    "path": "src/http/src/http_time.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <array>\n#include <ctime>     // mktime, gmtime_r, gmtime_s\n#include <cstring>   // memset\n#include <cstdio>    // sscanf\n#include <map>\n\n#include <iostream>  // cerr\n\n#include <event2/util.h>\n\n#include \"mysqlrouter/http_common.h\"\n\nint time_to_rfc5322_fixdate(time_t ts, char *date_buf, size_t date_buf_len) {\n  struct tm t_m;\n\n#ifdef _WIN32\n  // returns a errno_t\n  if (0 != gmtime_s(&t_m, &ts)) {\n    return 0; // no bytes written to output\n  }\n#else\n  if (nullptr == gmtime_r(&ts, &t_m)) {\n    return 0; // no bytes written to output\n  }\n#endif\n\n  constexpr std::array<const char *, 7> kDayNames { { \"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\" } };\n\n  constexpr std::array<const char *, 12> kMonthNames { { \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\" } };\n\n  return evutil_snprintf(date_buf, date_buf_len, \"%s, %02d %s %4d %02d:%02d:%02d GMT\",\n    kDayNames.at(t_m.tm_wday), t_m.tm_mday, kMonthNames.at(t_m.tm_mon),\n    1900 + t_m.tm_year, t_m.tm_hour, t_m.tm_min, t_m.tm_sec);\n}\n\nstatic\ntime_t time_from_struct_tm_utc(struct tm *t_m) {\n#if defined(_WIN32)\n  return _mkgmtime(t_m);\n#elif defined(__sun)\n  // solaris, linux have typeof('timezone') == time_t\n  return mktime(t_m) - timezone;\n#else\n  // linux, freebsd and apple have timegm()\n  return timegm(t_m);\n#endif\n}\n\n\n\ntime_t time_from_rfc5322_fixdate(const char *date_buf) {\n  // we can't use strptime as\n  //\n  // - it isn't portable\n  // - takes locale into account, but we need en_EN all the time\n  //\n  // std::regex is broken on gcc-4.x\n  // sscanf it is.\n  //\n  struct tm t_m;\n  memset(&t_m, 0, sizeof(t_m));\n\n  char wday[4];\n  char mon[4];\n  char timezone_s[4];\n  if (8 != sscanf(date_buf, \"%3s, %2u %3s %4u %2u:%2u:%2u %3s\",\n        wday,\n        &t_m.tm_mday,\n        mon,\n        &t_m.tm_year,\n        &t_m.tm_hour,\n        &t_m.tm_min,\n        &t_m.tm_sec,\n        timezone_s\n        )) {\n    throw std::out_of_range(\"invalid date\");\n  }\n\n  // throws out-of-range\n  std::map<std::string, decltype(t_m.tm_mon)> {\n    { \"Sun\", 0 },\n    { \"Mon\", 1 },\n    { \"Tue\", 2 },\n    { \"Wed\", 3 },\n    { \"Thu\", 4 },\n    { \"Fri\", 5 },\n    { \"Sat\", 6 },\n  }.at(wday);\n\n  // throws out-of-range\n  t_m.tm_mon = std::map<std::string, decltype(t_m.tm_mon)> {\n    { \"Jan\", 0 },\n    { \"Feb\", 1 },\n    { \"Mar\", 2 },\n    { \"Apr\", 3 },\n    { \"May\", 4 },\n    { \"Jun\", 5 },\n    { \"Jul\", 6 },\n    { \"Aug\", 7 },\n    { \"Sep\", 8 },\n    { \"Oct\", 9 },\n    { \"Nov\", 10 },\n    { \"Dec\", 11 },\n  }.at(mon);\n  if (t_m.tm_year < 1900) {\n    throw std::out_of_range(\"year too small\");\n  }\n  if (std::string(timezone_s) != \"GMT\") {\n    throw std::out_of_range(\"invalid timezone\");\n  }\n  t_m.tm_year -= 1900;\n\n  return time_from_struct_tm_utc(&t_m);\n}\n\n\n"
  },
  {
    "path": "src/http/src/posix_re.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_POSIX_RE_INCLUDED\n#define MYSQLROUTER_POSIX_RE_INCLUDED\n\n// Posix (Extended) Regular Expression\n//\n// C++11 has std::regex, by gcc-4.x throws exceptions when it\n// it used. Instead we build on a subset of std::regex\n//\n//\n\n#if ((defined(__GNUC__) && __GNUC__ < 5) && !defined(__clang__))\n// detect broken gcc 4.x, but ignore clang which announces itself as GCC 4.2.1\n#if !defined(_WIN32)\n#define USE_POSIX_RE_IMPL\n#else\n#error \"GCC 4.x or older, on Windows isn't supported\"\n#endif\n#endif\n\n#ifdef USE_POSIX_RE_IMPL\n#include <regex.h>\n#else\n#include <regex>\n#endif\n\n#include <memory>\n\nclass PosixRE_constants {\npublic:\n#ifdef USE_POSIX_RE_IMPL\n  using syntax_option_type = int;\n  using match_flag_type = int;\n  using error_type = int;\n  static constexpr auto match_default = 0;\n  static constexpr auto basic = 0;\n  static constexpr auto extended = REG_EXTENDED;\n  static constexpr auto icase = REG_ICASE;\n  static constexpr auto nosubs = REG_NOSUB;\n\n  static constexpr auto match_not_bol = REG_NOTBOL;\n  static constexpr auto match_not_eol = REG_NOTEOL;\n#else\n  using syntax_option_type = std::regex_constants::syntax_option_type;\n  using error_type = std::regex_constants::error_type;\n  using match_flag_type = std::regex_constants::match_flag_type;\n  static constexpr auto match_default = std::regex_constants::match_default;\n  static constexpr auto basic = std::regex_constants::basic;\n  static constexpr auto extended = std::regex_constants::extended;\n  static constexpr auto icase = std::regex_constants::icase;\n  static constexpr auto nosubs = std::regex_constants::nosubs;\n\n  static constexpr auto match_not_bol = std::regex_constants::match_not_bol;\n  static constexpr auto match_not_eol = std::regex_constants::match_not_eol;\n#endif\n};\n\nclass PosixREError: public std::runtime_error {\n  PosixRE_constants::error_type code_;\npublic:\n  PosixREError(PosixRE_constants::error_type c, const char *w):\n    std::runtime_error{w},\n    code_{c}\n  {\n  }\n\n  PosixRE_constants::error_type code() const noexcept {\n    return code_;\n  }\n};\n\n\n\nclass PosixRE {\npublic:\n  using flag_type = PosixRE_constants::syntax_option_type;\n  using match_flag_type = PosixRE_constants::match_flag_type;\n  static constexpr auto match_default = PosixRE_constants::match_default;\n\n  static constexpr auto basic = PosixRE_constants::basic;\n  static constexpr auto extended = PosixRE_constants::extended;\n  static constexpr auto icase = PosixRE_constants::icase;\n  static constexpr auto nosubs = PosixRE_constants::nosubs;\n\n  static constexpr auto match_not_eol = PosixRE_constants::match_not_eol;\n  static constexpr auto match_not_bol = PosixRE_constants::match_not_bol;\n\n  PosixRE(const std::string &regex_str, flag_type syntax_options = extended):\n#ifdef USE_POSIX_RE_IMPL\n    reg_{new regex_t}\n#else\n    reg_{regex_str, syntax_options}\n#endif\n  {\n#ifdef USE_POSIX_RE_IMPL\n    int error_code;\n    if (0 != (error_code = regcomp(reg_.get(), regex_str.c_str(), syntax_options))) {\n      char errbuf[256];\n      regerror(error_code, reg_.get(), errbuf, sizeof(errbuf));\n\n      throw PosixREError(error_code, errbuf);\n    }\n#endif\n  }\n\n  PosixRE(const char *regex_str, flag_type syntax_options = extended):\n#ifdef USE_POSIX_RE_IMPL\n    reg_{new regex_t}\n#else\n    reg_{regex_str, syntax_options}\n#endif\n  {\n#ifdef USE_POSIX_RE_IMPL\n    int error_code;\n    if (0 != (error_code = regcomp(reg_.get(), regex_str, syntax_options))) {\n      char errbuf[256];\n      regerror(error_code, reg_.get(), errbuf, sizeof(errbuf));\n\n      throw PosixREError(error_code, errbuf);\n    }\n#endif\n  }\n\n  // no copy, move only\n  PosixRE(const PosixRE &) = default;\n  PosixRE &operator=(const PosixRE&) = default;\n\n  PosixRE(PosixRE &&) = default;\n  PosixRE &operator=(PosixRE &&) = default;\n\n  ~PosixRE() {\n#ifdef USE_POSIX_RE_IMPL\n    auto r = reg_.get();\n    if (r) regfree(r);\n#endif\n  }\n\n  /**\n   * search entire line for match.\n   */\n  bool search(const std::string &line, match_flag_type match_flags = match_default) const {\n#ifdef USE_POSIX_RE_IMPL\n    if (0 != regexec(reg_.get(), line.c_str(), 0, NULL, match_flags)) {\n      return false;\n    }\n\n    return true;\n#else\n    return std::regex_search(line, reg_, match_flags);\n#endif\n  }\nprivate:\n#ifdef USE_POSIX_RE_IMPL\n  std::unique_ptr<regex_t> reg_;\n#else\n  std::regex reg_;\n#endif\n};\n\n\n#endif\n"
  },
  {
    "path": "src/http/src/rest_cli.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <iostream>\n#include <sstream>\n#include <stdio.h>\n\n#include \"mysqlrouter/http_common.h\"\n#include \"mysqlrouter/rest_client.h\"\n#include \"dim.h\"\n#include \"mysql/harness/arg_handler.h\"\n#include \"mysql/harness/loader.h\"\n#include \"mysql/harness/loader_config.h\"\n#include \"mysql/harness/logging/registry.h\"\n\n\nstruct RestClientConfig {\n  std::string uri {\"/\"};\n  std::string hostname;\n  std::string content_type { \"application/json\" };\n  uint16_t port { 80 };\n  bool verbose { false };\n  bool request_data_stdin { false };\n  HttpMethod::type method { HttpMethod::Get };\n  std::string request_data;\n};\n\nclass RestClientFrontend {\npublic:\n  RestClientConfig init_from_arguments(const std::vector<std::string> &arguments) {\n    program_name_ = arguments[0];\n\n    prepare_command_options();\n    arg_handler_.process(std::vector<std::string>{arguments.begin() + 1, arguments.end()});\n\n    return config_;\n  }\n\n  bool is_print_and_exit() const noexcept {\n    return do_print_and_exit_;\n  }\n\n  std::string get_version_line() const noexcept {\n    return MYSQL_ROUTER_VERSION;\n  }\n\n  std::string get_help() const {\n    std::stringstream os;\n\n    for (auto line: arg_handler_.usage_lines(\"Usage: \" + program_name_, \"\", 80)) {\n      os << line << std::endl;\n    }\n\n    return os.str();\n  }\n\nprivate:\n  RestClientConfig config_;\n  std::string program_name_;\n\n  void prepare_command_options() {\n    arg_handler_.add_option(CmdOption::OptionNames({\"-V\", \"--version\"}), \"Display version information and exit.\",\n                            CmdOptionValueReq::none, \"\", [this](const std::string &) {\n          std::cout << this->get_version_line() << std::endl;\n          this->do_print_and_exit_ = true;\n        });\n\n    arg_handler_.add_option(CmdOption::OptionNames({\"-?\", \"--help\"}), \"Display this help and exit.\",\n                            CmdOptionValueReq::none, \"\", [this](const std::string &) {\n          std::cout << this->get_help() << std::endl;\n          this->do_print_and_exit_ = true;\n        });\n\n    arg_handler_.add_option(\n        CmdOption::OptionNames({\"--uri\"}), \"URI\",\n        CmdOptionValueReq::required, \"uri\",\n        [this](const std::string &uri) {\n          config_.uri = uri;\n        });\n    arg_handler_.add_option(\n        CmdOption::OptionNames({\"-P\", \"--port\"}), \"TCP port to listen on for classic protocol connections.\",\n        CmdOptionValueReq::required, \"int\",\n        [this](const std::string &port) {\n          config_.port =  static_cast<unsigned>(std::stoul(port));\n       });\n    arg_handler_.add_option(\n        CmdOption::OptionNames({\"-h\", \"--host\"}), \"hostname of HTTP server.\",\n        CmdOptionValueReq::required, \"hostname\",\n        [this](const std::string &hostname) {\n          config_.hostname = hostname;\n       });\n    arg_handler_.add_option(\n        CmdOption::OptionNames({\"--content-type\"}), \"Content-Type of the request-body.\",\n        CmdOptionValueReq::required, \"string\",\n        [this](const std::string &content_type) {\n          config_.content_type = content_type;\n       });\n    arg_handler_.add_option(\n        CmdOption::OptionNames({\"--data\"}), \"request-body.\",\n        CmdOptionValueReq::required, \"string\",\n        [this](const std::string &data) {\n          config_.request_data = data;\n       });\n    arg_handler_.add_option(\n        CmdOption::OptionNames({\"--data-stdin\"}), \"read request-body from stdin.\",\n        CmdOptionValueReq::none, \"\",\n        [this](const std::string &) {\n          config_.request_data_stdin = true;\n       });\n    arg_handler_.add_option(\n        CmdOption::OptionNames({\"--verbose\"}), \"verbose\",\n        CmdOptionValueReq::none, \"\",\n        [this](const std::string &) {\n          config_.verbose = true;\n       });\n    arg_handler_.add_option(\n        CmdOption::OptionNames({\"--method\"}), \"HTTP method\",\n        CmdOptionValueReq::required, \"{GET|POST|PUT|DELETE|...}\",\n        [this](const std::string &method) {\n          std::map<std::string, HttpMethod::type> methods {\n            {\"GET\", HttpMethod::Get},\n            {\"PUT\", HttpMethod::Put},\n            {\"POST\", HttpMethod::Post},\n            {\"DELETE\", HttpMethod::Delete},\n            {\"CONNECT\", HttpMethod::Connect},\n            {\"TRACE\", HttpMethod::Trace},\n            {\"PATCH\", HttpMethod::Patch},\n            {\"HEAD\", HttpMethod::Head},\n            {\"OPTIONS\", HttpMethod::Options}\n          };\n          auto it = methods.find(method);\n\n          if (it == methods.end()) {\n            throw std::logic_error(\"unknown method: \" + method);\n          } else {\n            config_.method = (*it).second;\n          }\n       });\n  }\n\n  CmdArgHandler arg_handler_;\n  bool do_print_and_exit_ { false };\n};\n\nint main(int argc, char **argv) {\n  IOContext io_ctx;\n\n  try {\n    RestClientFrontend frontend;\n    auto frontend_config = frontend.init_from_arguments(std::vector<std::string> { argv, argv + argc });\n\n    if (frontend.is_print_and_exit()) {\n      return 0;\n    }\n\n    if (!frontend_config.request_data.empty() && frontend_config.request_data_stdin) {\n      throw std::logic_error(\"--data-stdin and --data are mutual exclusive options\");\n    }\n\n    if (frontend_config.hostname.empty()) {\n      throw std::logic_error(\"--host must be set\");\n    }\n\n    std::string request_data;\n    if (frontend_config.request_data_stdin) {\n      while (true) {\n        char buf[128];\n        auto bytes_read = ::fread(buf, 1, sizeof(buf), stdin);\n\n        if (bytes_read == 0) {\n          if (feof(stdin)) {\n            break;\n          } else if (ferror(stdin)) {\n            throw std::runtime_error(\"reading from stdin failed\");\n          } else {\n            throw std::runtime_error(\"fread() returned 0, but no EOF nor error?\");\n          }\n        }\n        request_data.append(buf, buf + bytes_read);\n      }\n    } else {\n      request_data = frontend_config.request_data;\n    }\n\n    auto req = RestClient(io_ctx, frontend_config.hostname, frontend_config.port).\n      request_sync(frontend_config.method, frontend_config.uri, request_data, frontend_config.content_type);\n    if (req) {\n      if (req.get_response_code() > 0) {\n        if (frontend_config.verbose) {\n          std::cerr << \"> \" << req.get_response_code()\n            << \" \"\n            << req.get_response_code_line()\n            << std::endl;\n          for (auto const &hdr: req.get_input_headers()) {\n            std::cerr << \"> \" << hdr.first\n              << \": \"\n              << hdr.second\n              << std::endl;\n          }\n        }\n        auto resp_body = req.get_input_buffer();\n        auto resp_body_content = resp_body.pop_front(resp_body.length());\n\n        std::cout << std::string(resp_body_content.begin(), resp_body_content.end()) << std::endl;\n        return 0;\n      } else {\n        std::cerr << \"HTTP Request to \"\n          << frontend_config.hostname << \":\" << std::to_string(frontend_config.port)\n          << \" failed: \"\n          << req.error_msg()\n          << std::endl;\n        return -1;\n      }\n    } else {\n      // we don't really know why it failed.\n      std::cerr << \"HTTP Request to \"\n        << frontend_config.hostname << \":\" << std::to_string(frontend_config.port)\n        << \" failed (early): \"\n        << req.error_msg()\n        << std::endl;\n      return -1;\n    }\n  } catch (const std::exception &e) {\n    std::cerr << e.what() << std::endl;\n    return -1;\n  }\n}\n"
  },
  {
    "path": "src/http/src/rest_client.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysqlrouter/rest_client.h\"\n\nHttpRequest RestClient::request_sync(\n    HttpMethod::type method,\n    const std::string &uri,\n    const std::string &request_body /* = {} */,\n    const std::string &content_type /* = \"application/json\" */) {\n  HttpRequest req {HttpRequest::sync_callback, nullptr};\n\n  // TRACE forbids a request-body\n  if (!request_body.empty()) {\n    if (method == HttpMethod::Trace) {\n      throw std::logic_error(\"TRACE can't have request-body\");\n    }\n    req.get_output_headers().add(\"Content-Type\", content_type.c_str());\n    auto out_buf = req.get_output_buffer();\n    out_buf.add(request_body.data(), request_body.size());\n  }\n\n  // ask the server to close the connection after this request\n  req.get_output_headers().add(\"Connection\", \"close\");\n  req.get_output_headers().add(\"Host\", hostname_.c_str());\n  http_client_.make_request_sync(&req, method, uri);\n\n  return req;\n}\n"
  },
  {
    "path": "src/http/src/static_files.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <string>\n#include <memory>\n#include <map>\n\n#ifdef _WIN32\n#include <io.h>  // close\n#else\n#include <unistd.h>  // close\n#endif\n#include <fcntl.h>\n#include <sys/stat.h>\n#include <sys/types.h>\n\n#include \"mysqlrouter/http_server_component.h\"\n#include \"http_server_plugin.h\"\n\nvoid HttpStaticFolderHandler::handle_request(HttpRequest &req) {\n  HttpUri parsed_uri { HttpUri::parse( req.get_uri() ) };\n\n  // guess mime-type\n\n  std::string file_path { static_basedir_ };\n\n  file_path += \"/\";\n  // normalize the path\n  file_path += parsed_uri.get_path();\n\n  auto out_hdrs = req.get_output_headers();\n\n  auto n = file_path.rfind('.');\n  if (n != std::string::npos) {\n    const std::map<std::string, std::string> mimetypes {\n      { \"css\", \"text/css\" },\n      { \"js\", \"text/javascript\" },\n      { \"json\", \"application/json\" },\n      { \"html\", \"text/html\" },\n      { \"png\", \"image/png\" },\n      { \"svg\", \"image/svg+xml\" },\n    };\n    std::string extension = file_path.substr(n + 1);\n    auto it = mimetypes.find(extension);\n\n    if (it != mimetypes.end()) {\n      // found\n      out_hdrs.add(\"Content-Type\", it->second.c_str());\n    } else {\n      out_hdrs.add(\"Content-Type\", \"application/octet-stream\");\n    }\n  }\n\n  struct stat st;\n  if (-1 == stat(file_path.c_str(), &st)) {\n    if (errno == ENOENT) {\n      // if it was a directory\n      req.send_error(HttpStatusCode::NotFound);\n\n      return;\n    } else {\n      req.send_error(HttpStatusCode::InternalError);\n\n      return;\n    }\n  }\n\n  // if we have a directory, check if it contains a index.html file\n  if ((st.st_mode & S_IFMT) == S_IFDIR) {\n    file_path += \"/index.html\";\n\n    if (-1 == stat(file_path.c_str(), &st)) {\n      if (errno == ENOENT) {\n        // if it was a directory\n        req.send_error(HttpStatusCode::NotFound);\n\n        return;\n      } else {\n        req.send_error(HttpStatusCode::InternalError);\n\n        return;\n      }\n    }\n  }\n\n  // file exists\n\n  int file_fd = open(file_path.c_str(), O_RDONLY);\n\n  if (file_fd < 0) {\n    if (errno == ENOENT) {\n      // if it was a directory\n      req.send_error(HttpStatusCode::NotFound);\n\n      return;\n    } else {\n      req.send_error(HttpStatusCode::InternalError);\n\n      return;\n    }\n  } else {\n    if (!req.is_modified_since(st.st_mtime)) {\n      req.send_error(HttpStatusCode::NotModified);\n      return;\n    }\n\n    req.add_last_modified(st.st_mtime);\n\n    auto chunk = req.get_output_buffer();\n    // if the file-size is 0, there is nothing to send ... and it triggers a mmap() error\n    if (st.st_size > 0) {\n      // only use sendfile if packet is large enough as it will be sent in sep TCP packet/syscall\n      //\n      // using TCP_CORK would help here\n      // if (st.st_size > 64 * 1024) {\n      //    evbuffer_set_flags(chunk, EVBUFFER_FLAG_DRAINS_TO_FD);\n      // }\n      chunk.add_file(file_fd, 0, st.st_size);\n      // file_fd is owned by evbuffer_add_file(), don't close it\n    } else {\n      close(file_fd);\n    }\n\n    req.send_reply(HttpStatusCode::Ok, HttpStatusCode::get_default_status_text(HttpStatusCode::Ok), chunk);\n\n    return;\n  }\n}\n\n\n"
  },
  {
    "path": "src/http/tests/CMakeLists.txt",
    "content": "# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\ninclude_directories(../include ../src)\n\nadd_test_file(test_time.cc\n  MODULE http\n  LIB_DEPENDS http_client\n  INCLUDE_DIRS ${GTEST_INCLUDE_DIRS}\n  )\n\nadd_test_file(test_posix_re.cc\n  MODULE http\n  INCLUDE_DIRS ${GTEST_INCLUDE_DIRS}\n  )\n"
  },
  {
    "path": "src/http/tests/test_posix_re.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"gmock/gmock.h\"\n\n\n#include \"posix_re.h\"\n\nclass PosixReTest : public ::testing::Test {\nprotected:\n  virtual void SetUp() {\n  }\n};\n\nTEST_F(PosixReTest, search) {\n  SCOPED_TRACE(\"// parse\");\n\n  EXPECT_TRUE(PosixRE(\"bcd\").search(\"abcde\"));\n  EXPECT_FALSE(PosixRE(\"^bcd\").search(\"abcde\"));\n  EXPECT_FALSE(PosixRE(\"bcd$\").search(\"abcde\"));\n  EXPECT_TRUE(PosixRE(\"^bcd\").search(\"bcde\"));\n}\n\nTEST_F(PosixReTest, construct) {\n  SCOPED_TRACE(\"// parse\");\n\n  // either a PosixREError or a std::regex_error\n  EXPECT_THROW(PosixRE(\"[a-z][\"), std::runtime_error);\n}\n\n\nint main(int argc, char *argv[])\n{\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/http/tests/test_time.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"gmock/gmock.h\"\n\n#include \"mysqlrouter/http_client.h\"\n\n#ifdef _WIN32\n#include <WinSock2.h>\n#endif\n\nclass HttpTimeParsesTest : public ::testing::Test, public ::testing::WithParamInterface<std::tuple<const char *, time_t, const char *>> {\nprotected:\n  void SetUp() override {\n  }\n};\n\nclass HttpTimeThrowsTest : public ::testing::Test, public ::testing::WithParamInterface<const char*> {\nprotected:\n  void SetUp() override {\n  }\n};\n\n\nTEST_P(HttpTimeParsesTest, time_from_rfc5322_fixdate) {\n  EXPECT_NO_THROW(\n    EXPECT_THAT(time_from_rfc5322_fixdate(std::get<0>(GetParam())), ::testing::Eq(std::get<1>(GetParam()))));\n\n  char date_buf[30];\n  EXPECT_NO_THROW(\n    EXPECT_THAT(time_to_rfc5322_fixdate(std::get<1>(GetParam()), date_buf, sizeof(date_buf)), ::testing::Eq(29)));\n\n  // equal, if you ignore whitespace\n  EXPECT_NO_THROW(\n    EXPECT_THAT(date_buf, ::testing::StrEq(std::get<2>(GetParam()))));\n}\n\nINSTANTIATE_TEST_CASE_P(HttpTimeParses,\n    HttpTimeParsesTest,\n    ::testing::Values(\n      // parses a valid date\n      std::make_tuple(\"Thu, 31 May 2018 15:18:20 GMT\", static_cast<time_t>(1527779900), \"Thu, 31 May 2018 15:18:20 GMT\"),\n      // whitespace get ignored\n      std::make_tuple(\"Thu,  31  May  2018  15:18:20  GMT\", static_cast<time_t>(1527779900), \"Thu, 31 May 2018 15:18:20 GMT\"),\n\n      // other date\n      std::make_tuple(\"Thu, 31 May 2018 05:18:20 GMT\", static_cast<time_t>(1527743900), \"Thu, 31 May 2018 05:18:20 GMT\")\n      ));\n\nTEST_P(HttpTimeThrowsTest, time_from_rfc5322_fixdate_p) {\n  EXPECT_THROW(time_from_rfc5322_fixdate(GetParam()), std::out_of_range);\n}\n\nINSTANTIATE_TEST_CASE_P(HttpTimeThrows,\n    HttpTimeThrowsTest,\n    ::testing::Values(\n      // year too small\n      \"Thu, 31 May 1899 15:18:20 GMT\",\n\n      // wrong timezone\n      \"Thu, 31 May 2018 5:18:20 UTC\",\n\n      // throws at invalid weekday\");\n      \"Tho, 31 May 2018 15:18:20 GMT\",\n\n      // throws at invalid month\");\n      \"Thu, 31 Mai 2018 15:18:20 GMT\",\n\n      // throws at short year\");\n      \"Thu, 31 May 201 15:18:20 GMT\",\n\n      // throws at long year\n      \"Thu, 31 May 20188 15:18:20 GMT\"));\n\n\nint main(int argc, char *argv[])\n{\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/keepalive/CMakeLists.txt",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nadd_harness_plugin(keepalive\n  INTERFACE include\n  SOURCES src/keepalive.cc)\n\nif(ENABLE_TESTS)\n  add_subdirectory(tests)\nendif()"
  },
  {
    "path": "src/keepalive/src/keepalive.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/**\n * Keepalive Plugin\n *\n * Keepalive plugin is simply sending a message every, by default,\n * 8 seconds and running until Router is shut down.\n *\n * [keepalive]\n * interval = 2\n * runs = 3\n */\n\n#include <chrono>\n#include <iostream>\n#include <thread>\n\n// Harness interface include files\n#include \"mysql/harness/config_parser.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysql/harness/plugin.h\"\n\nusing mysql_harness::ARCHITECTURE_DESCRIPTOR;\nusing mysql_harness::ConfigSection;\nusing mysql_harness::PluginFuncEnv;\nusing mysql_harness::PLUGIN_ABI_VERSION;\nusing mysql_harness::Plugin;\nusing mysql_harness::logging::log_info;\n\n// Keep symbols with external linkage away from global scope so that\n// they do not clash with other symbols.\nnamespace {\n\nconst int kInterval = 60;  // in seconds\nconst int kRuns = 0;  // 0 means for ever\n\n}\n\nstatic void init(PluginFuncEnv*) {\n}\n\nstatic void start(PluginFuncEnv* env) {\n  const ConfigSection* section = get_config_section(env);\n  int interval = kInterval;\n  try {\n    interval = std::stoi(section->get(\"interval\"));\n  } catch (...) {\n    // Anything in valid will result in using the default.\n  }\n\n  int runs = kRuns;\n  try {\n    runs = std::stoi(section->get(\"runs\"));\n  } catch (...) {\n    // Anything in valid will result in using the default.\n  }\n\n  std::string name = section->name;\n  if (!section->key.empty()) {\n    name += \" \" + section->key;\n  }\n\n  log_info(\"%s started with interval %d\", name.c_str(), interval);\n  if (runs) {\n    log_info(\"%s will run %d time(s)\", name.c_str(), runs);\n  }\n\n  for (int total_runs = 0 ; runs == 0 || total_runs < runs ; ++total_runs) {\n    log_info(\"%s\", name.c_str());\n    if (wait_for_stop(env, static_cast<uint32_t>(interval * 1000)))\n      break;\n  }\n}\n\n#if defined(_MSC_VER) && defined(keepalive_EXPORTS)\n/* We are building this library */\n#  define DLLEXPORT __declspec(dllexport)\n#else\n#  define DLLEXPORT\n#endif\n\nextern \"C\" {\nPlugin DLLEXPORT harness_plugin_keepalive = {\n  PLUGIN_ABI_VERSION,\n  ARCHITECTURE_DESCRIPTOR,\n  \"Keepalive Plugin\",\n  VERSION_NUMBER(0, 0, 1),\n  0, nullptr,\n  0, nullptr,  // conflicts\n  init,        // init\n  nullptr,     // deinit\n  start,       // start\n  nullptr,     // stop\n};\n}\n"
  },
  {
    "path": "src/keepalive/tests/CMakeLists.txt",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nenable_testing()\n\ninclude_directories(${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS})\n\nSET(TESTS\n  test_plugin_keepalive.cc\n)\n\nforeach(TEST ${TESTS})\n  add_test_file(${TEST} MODULE harness\n    INCLUDE_DIRS ${MySQLRouter_SOURCE_DIR}/src/harness/shared/include/\n    LIB_DEPENDS test-helpers)\nendforeach()\n\n\ncreate_harness_test_directory_post_build(test_harness_plugin_keepalive keepalive)\nconfigure_harness_test_file(data/keepalive.cfg.in data/keepalive.cfg)\n"
  },
  {
    "path": "src/keepalive/tests/data/keepalive.cfg.in",
    "content": "\n# Configuration file for Keepalive plugin tests\n\n[DEFAULT]\nlogging_folder = {prefix}/var/log/keepalive\nplugin_folder = @HARNESS_PLUGIN_OUTPUT_DIRECTORY@\nruntime_folder = {prefix}/var/run/{program}\nconfig_folder = {prefix}/var/run/{program}\ndata_folder = {prefix}/var/lib/{program}\n\n[keepalive]\ninterval = 1\nruns = 2\n"
  },
  {
    "path": "src/keepalive/tests/test_plugin_keepalive.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n////////////////////////////////////////\n// Harness interface include files\n#include \"mysql/harness/filesystem.h\"\n#include \"mysql/harness/loader.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysql/harness/plugin.h\"\n\n////////////////////////////////////////\n// Test system include files\n#include \"test/helpers.h\"\n\n////////////////////////////////////////\n// Third-party include files\n#include \"gtest/gtest.h\"\n\n////////////////////////////////////////\n// Standard include files\n#include <iostream>\n#include <fstream>\n#include <climits>\n\nusing std::cout;\nusing std::endl;\n\nusing mysql_harness::Loader;\nusing mysql_harness::Path;\n\nPath g_here;\n\nclass KeepalivePluginTest : public ::testing::Test {\n protected:\n  virtual void SetUp() {\n    Path here = Path(g_here);\n    orig_cout_ = std::cout.rdbuf();\n    std::cout.rdbuf(ssout.rdbuf());\n\n    std::map<std::string, std::string> params;\n    params[\"program\"] = \"harness\";\n    params[\"prefix\"] = here.c_str();\n    params[\"log_level\"] = \"info\";\n\n    config_.reset(new mysql_harness::LoaderConfig(params, std::vector<std::string>(),\n                                                  mysql_harness::Config::allow_keys));\n    config_->read(here.join(\"data/keepalive.cfg\"));\n    loader = new Loader(\"harness\", *config_);\n  }\n\n  virtual void TearDown() {\n    std::cout.rdbuf(orig_cout_);\n    delete loader;\n    loader = nullptr;\n  }\n\n  Loader *loader;\n  std::unique_ptr<mysql_harness::LoaderConfig> config_;\n\n private:\n  std::stringstream ssout;\n  std::streambuf *orig_cout_;\n};\n\nTEST_F(KeepalivePluginTest, Available) {\n  auto lst = loader->available();\n  EXPECT_EQ(1U, lst.size());\n\n  EXPECT_SECTION_AVAILABLE(\"keepalive\", loader);\n}\n\nTEST_F(KeepalivePluginTest, CheckLog) {\n  auto logging_folder = g_here.join(\"/var/log/keepalive\");\n  const auto log_file = Path::make_path(logging_folder, \"harness\", \"log\");\n  init_test_logger({\"keepalive\"}, loader->get_config().get_default(\"logging_folder\"), \"harness\");\n\n  // Make sure log file is empty\n  std::fstream fs;\n  fs.open(log_file.str(), std::fstream::trunc | std::ofstream::out);\n  fs.close();\n\n  ASSERT_NO_THROW(loader->start());\n\n  std::ifstream ifs_log(log_file.str());\n  std::string line;\n  std::vector<std::string> lines;\n  while (std::getline(ifs_log, line)) {\n    lines.push_back(line);\n  }\n\n  auto find_line = [&lines](unsigned start_line, const char* needle) -> unsigned {\n    for (unsigned i = start_line; i < lines.size(); i++)\n      if (lines[i].find(needle) != std::string::npos)\n        return i;\n    return UINT_MAX;\n  };\n\n  ASSERT_GE(lines.size(), 4U);\n  unsigned start_line = 0;\n  EXPECT_NE(UINT_MAX, start_line = find_line(start_line, \"keepalive started with interval 1\"));\n  EXPECT_NE(UINT_MAX, start_line = find_line(start_line, \"2 time(s)\"));\n  EXPECT_NE(UINT_MAX, start_line = find_line(start_line, \"keepalive\"));\n  EXPECT_NE(UINT_MAX, start_line = find_line(start_line, \"INFO\"));\n  EXPECT_NE(UINT_MAX, start_line = find_line(start_line, \"keepalive\"));\n}\n\nint main(int argc, char *argv[]) {\n  g_here = Path(argv[0]).dirname().str();\n\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/metadata_cache/CMakeLists.txt",
    "content": "# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nset(METADATA_CACHE_SOURCES\n  src/metadata_factory.cc\n  src/cluster_metadata.cc\n  src/metadata_cache.cc\n  src/cache_api.cc\n  src/group_replication_metadata.cc\n)\n\ninclude_directories(\n  ../router/include\n  include/\n  src/\n  ${MySQL_INCLUDE_DIRS}\n)\n\nadd_definitions(${SSL_DEFINES})\n\nadd_harness_plugin(metadata_cache SOURCES\n  src/metadata_cache_plugin.cc\n  src/plugin_config.cc\n  ${METADATA_CACHE_SOURCES}\n  REQUIRES router_lib)\n\ntarget_link_libraries(metadata_cache PRIVATE ${MySQL_LIBRARIES})\n# don't install headers until a) a final destination is found and b) API is stable\n# file(GLOB metadata_cache_headers include/mysqlrouter/*.h)\n# install(FILES ${metadata_cache_headers}\n#   DESTINATION include/mysql/${HARNESS_NAME})\n\nif(ENABLE_TESTS)\n    add_subdirectory(tests/)\nendif()\n"
  },
  {
    "path": "src/metadata_cache/include/mysqlrouter/metadata_cache.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_METADATA_CACHE_INCLUDED\n#define MYSQLROUTER_METADATA_CACHE_INCLUDED\n\n#include <chrono>\n#include <stdexcept>\n#include <exception>\n#include <vector>\n#include <map>\n#include <list>\n#include <string>\n\n#include \"mysqlrouter/utils.h\"\n#include \"mysqlrouter/datatypes.h\"\n#include \"mysql_router_thread.h\"\n#include \"tcp_address.h\"\n\n#ifdef _WIN32\n#  ifdef metadata_cache_DEFINE_STATIC\n#    define METADATA_API\n#  else\n#    ifdef metadata_cache_EXPORTS\n#      define METADATA_API __declspec(dllexport)\n#    else\n#      define METADATA_API __declspec(dllimport)\n#    endif\n#  endif\n#else\n#  define METADATA_API\n#endif\n\nnamespace metadata_cache {\n\nextern const uint16_t kDefaultMetadataPort;\nextern const std::string kDefaultMetadataAddress;\nextern const std::string kDefaultMetadataUser;\nextern const std::string kDefaultMetadataPassword;\nextern const std::chrono::milliseconds kDefaultMetadataTTL;\nextern const std::string kDefaultMetadataCluster;\nextern const unsigned int kDefaultConnectTimeout;\nextern const unsigned int kDefaultReadTimeout;\n\nenum class METADATA_API ReplicasetStatus {\n  AvailableWritable,\n  AvailableReadOnly,\n  UnavailableRecovering,\n  Unavailable\n};\n\nenum class METADATA_API ServerMode {\n  ReadWrite,\n  ReadOnly,\n  Unavailable\n};\n\nenum class METADATA_API InstanceStatus {\n  Reachable,\n  InvalidHost, // Network connection cannot even be attempted (ie bad IP)\n  Unreachable, // TCP connection cannot be opened\n  Unusable     // TCP connection can be opened but session can't be opened\n};\n\n/** @class ManagedInstance\n *\n * Class ManagedInstance represents a server managed by the topology.\n */\nclass METADATA_API ManagedInstance {\npublic:\n  bool operator==(const ManagedInstance& other) const;\n\n  /** @brief The name of the replicaset to which the server belongs */\n  std::string replicaset_name;\n  /** @brief The uuid of the MySQL server */\n  std::string mysql_server_uuid;\n  /** @brief The role of the server */\n  std::string role;\n  /** @brief The mode of the server */\n  ServerMode mode;\n  /** @brief The server weight */\n  float weight;\n  /** @brief The version token of the server */\n  unsigned int version_token;\n  /** @brief The location of the server */\n  std::string location;\n  /** @brief The host name on which the server is running */\n  std::string host;\n  /** The port number in which the server is running */\n  unsigned int port;\n  /** The X protocol port number in which the server is running */\n  unsigned int xport;\n};\n\n/** @class ManagedReplicaSet\n * Represents a replicaset (a GR group)\n */\nclass METADATA_API ManagedReplicaSet {\npublic:\n  /** @brief The name of the replica set */\n  std::string name;\n#ifdef not_used_yet\n  /** @brief The group_name as known to the GR subsystem */\n  std::string group_id;\n  /** @brief The id of the group view from GR. Changes with topology changes */\n  std::string group_view_id;\n#endif\n  /** @brief List of the members that belong to the group */\n  std::vector<metadata_cache::ManagedInstance> members;\n\n  /** @brief Whether replicaset is in single_primary_mode (from PFS) */\n  bool single_primary_mode;\n};\n\n/** @class connection_error\n *\n * Class that represents all the exceptions thrown while trying to\n * connect with a node managed by the topology.\n *\n */\nclass connection_error : public std::runtime_error {\npublic:\n  explicit connection_error(const std::string &what_arg) : std::runtime_error(\n    what_arg) { }\n};\n\n/** @class metadata_error\n * Class that represents all the exceptions that are thrown while fetching the\n * metadata.\n *\n */\nclass metadata_error : public std::runtime_error {\npublic:\n  explicit metadata_error(const std::string &what_arg) : std::runtime_error(\n    what_arg) { }\n};\n\n/** @class LookupResult\n *\n * Class holding result after looking up data in the cache.\n */\nclass METADATA_API LookupResult {\npublic:\n  /** @brief Constructor */\n  LookupResult(const std::vector<ManagedInstance> &instance_vector_) :\n  instance_vector(instance_vector_) { }\n\n  /** @brief List of ManagedInstance objects */\n  const std::vector<metadata_cache::ManagedInstance> instance_vector;\n};\n\n/**\n * @brief Abstract class that provides interface for listener on\n *        replicaset status changes.\n *\n *        When state of replicaset is changed, notify function is called.\n */\nclass METADATA_API ReplicasetStateListenerInterface {\npublic:\n\n  /**\n   * @brief Callback function that is called when state of replicaset is changed.\n   *\n   * @param instances allowed nodes\n   * @param md_servers_reachable true if metadata changed, false if metadata unavailable\n   */\n  virtual void notify(const LookupResult& instances, const bool md_servers_reachable) noexcept = 0;\n  virtual ~ReplicasetStateListenerInterface();\n};\n\n/**\n * @brief Abstract class that provides interface for adding and removing\n *        observers on replicaset status changes.\n *\n *        When state of replicaset is changed, then ReplicasetStateListenerInterface::notify\n *        function is called for every registered observer.\n */\nclass METADATA_API ReplicasetStateNotifierInterface {\npublic:\n\n  /**\n   * @brief Register observer that is notified when there is a change in the replicaset nodes setup/state\n   *        discovered.\n   *\n   * @param replicaset_name name of the replicaset\n   * @param listener Observer object that is notified when replicaset nodes state is changed.\n   *\n   * @throw std::runtime_error if metadata cache not initialized\n   */\n  virtual void add_listener(const std::string& replicaset_name, ReplicasetStateListenerInterface* listener) = 0;\n\n  /**\n   * @brief Unregister observer previously registered with add_listener()\n   *\n   * @param replicaset_name name of the replicaset\n   * @param listener Observer object that should be unregistered.\n   *\n   * @throw std::runtime_error if metadata cache not initialized\n   */\n  virtual void remove_listener(const std::string& replicaset_name, ReplicasetStateListenerInterface* listener) = 0;\n  virtual ~ReplicasetStateNotifierInterface();\n};\n\nMETADATA_API class MetadataCacheAPIBase : public ReplicasetStateNotifierInterface {\n public:\n\n  /** @brief Initialize a MetadataCache object and start caching\n   *\n   * The metadata_cache::cache_init function will initialize a MetadataCache object\n   * using the given arguments and store it globally using the given cache_name.\n   *\n   * Parameters host, port, user, password are used to setup the connection with\n   * the metadata server.\n   *\n   * Cache name given by cache_name can be empty, but must be unique.\n   *\n   * The parameters connection_timeout and connection_attempts are used when\n   * connected to the metadata server.\n   *\n   * Throws a std::runtime_error when the cache object was already\n   * initialized.\n   *\n   * @param bootstrap_servers The list of metadata servers from.\n   * @param user MySQL Metadata username\n   * @param password MySQL Metadata password\n   * @param ttl The time to live for the cached data\n   * @param ssl_options SSL relatd options for connection\n   * @param cluster_name The name of the cluster to be used.\n   * @param connect_timeout The time in seconds after which trying to connect\n   *                        to metadata server should time out.\n   * @param read_timeout The time in seconds after which read from metadata\n   *                     server should time out.\n   * @param thread_stack_size memory in kilobytes allocated for thread's stack\n   */\n  virtual void cache_init(const std::vector<mysql_harness::TCPAddress> &bootstrap_servers,\n                          const std::string &user, const std::string &password,\n                          std::chrono::milliseconds ttl, const mysqlrouter::SSLOptions &ssl_options,\n                          const std::string &cluster_name,\n                          int connect_timeout, int read_timeout,\n                          size_t thread_stack_size = mysql_harness::kDefaultStackSizeInKiloBytes) = 0;\n\n  /**\n   * @brief Teardown the metadata cache\n   */\n  virtual void cache_stop() noexcept = 0;\n\n  /** @brief Returns list of managed server in a HA replicaset\n   * * Returns a list of MySQL servers managed by the topology for the given\n   * HA replicaset.\n   *\n   * @param replicaset_name ID of the HA replicaset\n   * @return List of ManagedInstance objects\n   */\n  virtual LookupResult lookup_replicaset(const std::string &replicaset_name) = 0;\n\n\n  /** @brief Update the status of the instance\n   *\n   * Called when an instance from a replicaset cannot be reached for one reason\n   * or another. When an instance becomes unreachable, an emergency mode is set\n   * (the rate of refresh of the metadata cache increases to once per second)\n   * and lasts until disabled after a suitable change in the metadata cache is\n   * discovered.\n   *\n   * @param instance_id - the mysql_server_uuid that identifies the server instance\n   * @param status - the status of the instance\n   */\n  virtual void mark_instance_reachability(const std::string &instance_id,\n                                          InstanceStatus status) = 0;\n\n  /** @brief Wait until there's a primary member in the replicaset\n   *\n   * To be called when the master of a single-master replicaset is down and\n   * we want to wait until one becomes elected.\n   *\n   * @param replicaset_name - the name of the replicaset\n   * @param timeout - amount of time to wait for a failover, in seconds\n   * @return true if a primary member exists\n   */\n  virtual bool wait_primary_failover(const std::string &replicaset_name,\n                                          int timeout) = 0;\n\n  /**\n   * @brief Register observer that is notified when there is a change in the replicaset nodes setup/state\n   *        discovered.\n   *\n   * @param replicaset_name name of the replicaset\n   * @param listener Observer object that is notified when replicaset nodes state is changed.\n   */\n  virtual void add_listener(const std::string& replicaset_name, ReplicasetStateListenerInterface* listener) = 0;\n\n  /**\n   * @brief Unregister observer previously registered with add_listener()\n   *\n   * @param replicaset_name name of the replicaset\n   * @param listener Observer object that should be unregistered.\n   */\n  virtual void remove_listener(const std::string& replicaset_name, ReplicasetStateListenerInterface* listener) = 0;\n\n  virtual  ~MetadataCacheAPIBase() {}\n};\n\nMETADATA_API class MetadataCacheAPI: public MetadataCacheAPIBase {\n public:\n  static METADATA_API MetadataCacheAPIBase* instance();\n\n  void cache_init(const std::vector<mysql_harness::TCPAddress> &bootstrap_servers,\n                  const std::string &user, const std::string &password,\n                  std::chrono::milliseconds ttl, const mysqlrouter::SSLOptions &ssl_options,\n                  const std::string &cluster_name,\n                  int connect_timeout, int read_timeout, size_t thread_stack_size) override;\n\n  void cache_stop() noexcept override;\n\n  LookupResult lookup_replicaset(const std::string &replicaset_name) override;\n\n  void mark_instance_reachability(const std::string &instance_id,\n                                  InstanceStatus status)  override;\n\n  bool wait_primary_failover(const std::string &replicaset_name,\n                             int timeout) override;\n\n  void add_listener(const std::string& replicaset_name, ReplicasetStateListenerInterface* listener) override;\n  void remove_listener(const std::string& replicaset_name, ReplicasetStateListenerInterface* listener) override;\n\n private:\n  MetadataCacheAPI() {}\n  MetadataCacheAPI(const MetadataCacheAPI&) = delete;\n  MetadataCacheAPI& operator=(const MetadataCacheAPI&) = delete;\n};\n\n} // namespace metadata_cache\n\n#endif // MYSQLROUTER_METADATA_CACHE_INCLUDED\n"
  },
  {
    "path": "src/metadata_cache/src/cache_api.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysqlrouter/metadata_cache.h\"\n#include \"metadata_cache.h\"\n#include \"metadata_factory.h\"\n\n#include \"cluster_metadata.h\"\n\n#include <map>\n#include <memory>\n\n// routing's destination_* and the metadata-cache plugin itself\n// may work on the cache in parallel.\nstatic std::mutex g_metadata_cache_m;\nstatic std::unique_ptr<MetadataCache> g_metadata_cache(nullptr);\n\nnamespace metadata_cache {\n\nconst uint16_t kDefaultMetadataPort = 32275;\nconst std::chrono::milliseconds kDefaultMetadataTTL = std::chrono::milliseconds(500);\nconst std::string kDefaultMetadataAddress{\"127.0.0.1:\" + mysqlrouter::to_string(\n    kDefaultMetadataPort)};\nconst std::string kDefaultMetadataUser = \"\";\nconst std::string kDefaultMetadataPassword = \"\";\nconst std::string kDefaultMetadataCluster = \"\"; // blank cluster name means pick the 1st (and only) cluster\nconst unsigned int kDefaultConnectTimeout = 30;\nconst unsigned int kDefaultReadTimeout = 30;\n\nReplicasetStateListenerInterface::~ReplicasetStateListenerInterface() = default;\nReplicasetStateNotifierInterface::~ReplicasetStateNotifierInterface() = default;\n\nMetadataCacheAPIBase* MetadataCacheAPI::instance() {\n  static MetadataCacheAPI instance_;\n  return &instance_;\n}\n\n#define LOCK_METADATA_AND_CHECK_INITIALIZED() \\\n  std::lock_guard<std::mutex> lock(g_metadata_cache_m); \\\n  if (g_metadata_cache == nullptr) { \\\n    throw std::runtime_error(\"Metadata Cache not initialized\"); \\\n  }\n\n\n/**\n * Initialize the metadata cache.\n *\n * @param bootstrap_servers The initial set of servers that contain the server\n *                          topology metadata.\n * @param user The user name used to connect to the metadata servers.\n * @param password The password used to connect to the metadata servers.\n * @param ttl The ttl for the contents of the cache\n * @param ssl_options SSL related options for connections\n * @param cluster_name The name of the cluster from the metadata schema\n * @param connect_timeout The time in seconds after which trying to connect\n *                        to metadata server timeouts\n * @param read_timeout The time in seconds after which read from metadata\n *                     server should timeout.\n * @param thread_stack_size memory in kilobytes allocated for thread's stack\n */\nvoid MetadataCacheAPI::cache_init(const std::vector<mysql_harness::TCPAddress> &bootstrap_servers,\n                  const std::string &user,\n                  const std::string &password,\n                  std::chrono::milliseconds ttl,\n                  const mysqlrouter::SSLOptions &ssl_options,\n                  const std::string &cluster_name,\n                  int connect_timeout,\n                  int read_timeout,\n                  size_t thread_stack_size) {\n  std::lock_guard<std::mutex> lock(g_metadata_cache_m);\n\n  g_metadata_cache.reset(new MetadataCache(bootstrap_servers,\n    get_instance(user, password, connect_timeout, read_timeout, 1, ttl, ssl_options), ttl,\n                 ssl_options, cluster_name, thread_stack_size));\n  g_metadata_cache->start();\n}\n\n/**\n * Teardown the metadata cache\n */\nvoid MetadataCacheAPI::cache_stop() noexcept {\n  std::lock_guard<std::mutex> lock(g_metadata_cache_m);\n\n  if (g_metadata_cache) // might be NULL if cache_init() failed very early\n    g_metadata_cache->stop();\n}\n\n/**\n * Lookup the servers that belong to the given replicaset.\n *\n * @param replicaset_name The name of the replicaset whose servers need\n *                      to be looked up.\n *\n * @return An object that encapsulates a list of managed MySQL servers.\n *\n */\nLookupResult MetadataCacheAPI::lookup_replicaset(const std::string &replicaset_name) {\n  LOCK_METADATA_AND_CHECK_INITIALIZED();\n\n  return LookupResult(g_metadata_cache->replicaset_lookup(replicaset_name));\n}\n\n\nvoid MetadataCacheAPI::mark_instance_reachability(const std::string &instance_id,\n                                InstanceStatus status) {\n  LOCK_METADATA_AND_CHECK_INITIALIZED();\n\n  g_metadata_cache->mark_instance_reachability(instance_id, status);\n}\n\nbool MetadataCacheAPI::wait_primary_failover(const std::string &replicaset_name, int timeout) {\n  LOCK_METADATA_AND_CHECK_INITIALIZED();\n\n  return g_metadata_cache->wait_primary_failover(replicaset_name, timeout);\n}\n\nvoid MetadataCacheAPI::add_listener(const std::string& replicaset_name, ReplicasetStateListenerInterface* listener) {\n  LOCK_METADATA_AND_CHECK_INITIALIZED();\n  g_metadata_cache->add_listener(replicaset_name, listener);\n}\nvoid MetadataCacheAPI::remove_listener(const std::string& replicaset_name, ReplicasetStateListenerInterface* listener) {\n  LOCK_METADATA_AND_CHECK_INITIALIZED();\n  g_metadata_cache->remove_listener(replicaset_name, listener);\n}\n\n} // namespace metadata_cache\n"
  },
  {
    "path": "src/metadata_cache/src/cluster_metadata.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"cluster_metadata.h\"\n#include \"dim.h\"\n#include \"group_replication_metadata.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysqlrouter/mysql_session.h\"\n#include \"mysqlrouter/uri.h\"\n#include \"mysqlrouter/utils.h\"\n#include \"tcp_address.h\"\n\n#include <algorithm>\n#include <cassert>\n#include <chrono>\n#include <cstdlib>\n#include <vector>\n#include <sstream>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n\n#include <mysql.h>\n#include <errmsg.h>\n\nusing mysqlrouter::MySQLSession;\nusing mysqlrouter::strtoi_checked;\nIMPORT_LOG_FUNCTIONS()\n\n/**\n * Return a string representation of the input character string.\n *\n * @param input_str A character string.\n *\n * @return A string object encapsulation of the input character string. An empty\n *         string if input string is nullptr.\n */\nstd::string get_string(const char *input_str) {\n  if (input_str == nullptr) {\n    return \"\";\n  }\n  return std::string(input_str);\n}\n\nClusterMetadata::ClusterMetadata(const std::string &user,\n                                 const std::string &password,\n                                 int connect_timeout,\n                                 int read_timeout,\n                                 int /*connection_attempts*/,\n                                 std::chrono::milliseconds ttl,\n                                 const mysqlrouter::SSLOptions &ssl_options) {\n  this->ttl_ = ttl;\n  this->user_ = user;\n  this->password_ = password;\n  this->connect_timeout_ = connect_timeout;\n  this->read_timeout_ = read_timeout;\n#if 0 // not used so far\n  this->metadata_uuid_ = \"\";\n  this->message_ = \"\";\n  this->connection_attempts_ = connection_attempts;\n  this->reconnect_tries_ = 0;\n#endif\n\n  if (ssl_options.mode.empty()) {\n    ssl_mode_ = SSL_MODE_PREFERRED; // default mode\n  } else {\n    try {\n      ssl_mode_ = MySQLSession::parse_ssl_mode(ssl_options.mode);\n      log_info(\"Connections using ssl_mode '%s'\", ssl_options.mode.c_str());\n    } catch (const std::logic_error& e) {\n      throw metadata_cache::metadata_error(\"Error initializing metadata cache: invalid configuration item 'ssl_mode=\" + ssl_options.mode + \"'\");\n    }\n  }\n  ssl_options_ = ssl_options;\n}\n\n/** @brief Destructor\n *\n * Disconnect and release the connection to the metadata node.\n * (RAII will close the connection in metadata_connection_)\n */\nClusterMetadata::~ClusterMetadata() {}\n\nbool ClusterMetadata::do_connect(MySQLSession& connection, const metadata_cache::ManagedInstance &mi) {\n\n  std::string host = (mi.host == \"localhost\" ? \"127.0.0.1\" : mi.host);\n  try {\n    connection.set_ssl_options(ssl_mode_,\n                               ssl_options_.tls_version,\n                               ssl_options_.cipher,\n                               ssl_options_.ca, ssl_options_.capath,\n                               ssl_options_.crl, ssl_options_.crlpath);\n    connection.connect(host, static_cast<unsigned int>(mi.port), user_, password_,\n        \"\" /* unix-socket */, \"\" /* default-schema */, connect_timeout_, read_timeout_);\n    return true;\n  } catch (const MySQLSession::Error& e) {\n    return false; // error is logged in calling function\n  }\n}\n\nbool ClusterMetadata::connect(const metadata_cache::ManagedInstance &metadata_server) noexcept {\n\n  // Get a clean metadata server connection object\n  // (RAII will close the old one if needed).\n  try {\n    metadata_connection_ = mysql_harness::DIM::instance().new_MySQLSession();\n  } catch (const std::logic_error& e) {\n    // defensive programming, shouldn't really happen\n    log_error(\"Failed connecting with Metadata Server: %s\", e.what());\n    return false;\n  }\n\n  if (do_connect(*metadata_connection_, metadata_server)) {\n    log_info(\"Connected with metadata server running on %s:%i\", metadata_server.host.c_str(), metadata_server.port);\n    return true;\n  }\n\n  // connection attempt failed\n  log_warning(\"Failed connecting with Metadata Server %s:%d: %s (%i)\",\n              metadata_server.host.c_str(), metadata_server.port,\n              metadata_connection_->last_error(),\n              metadata_connection_->last_errno());\n\n  metadata_connection_.reset();\n  return false;\n}\n\nvoid ClusterMetadata::update_replicaset_status(const std::string &name,\n    metadata_cache::ManagedReplicaSet &replicaset) { // throws metadata_cache::metadata_error\n  log_debug(\"Updating replicaset status from GR for '%s'\", name.c_str());\n\n  // iterate over all cadidate nodes until we find the node that is part of quorum\n  bool found_quorum = false;\n  std::shared_ptr<MySQLSession> gr_member_connection;\n  for (const metadata_cache::ManagedInstance& mi : replicaset.members) {\n    std::string mi_addr = (mi.host == \"localhost\" ? \"127.0.0.1\" : mi.host) + \":\" + std::to_string(mi.port);\n\n    // this function could test these in an if() instead of assert(),\n    // but so far the logic that calls this function ensures this\n    assert(metadata_connection_->is_connected());\n\n    // connect to node\n    if (mi_addr == metadata_connection_->get_address()) { // optimisation: if node is the same as metadata server,\n      gr_member_connection = metadata_connection_;        //               share the established connection\n    } else {\n      try {\n        gr_member_connection = mysql_harness::DIM::instance().new_MySQLSession();\n      } catch (const std::logic_error& e) {\n        // defensive programming, shouldn't really happen. If it does, there's nothing we can do really, we give up\n        log_error(\"While updating metadata, could not initialise MySQL connetion structure\");\n        throw metadata_cache::metadata_error(e.what());\n      }\n\n      if (!do_connect(*gr_member_connection, mi)) {\n        log_warning(\"While updating metadata, could not establish a connection to replicaset '%s' through %s\",\n                  name.c_str(), mi_addr.c_str());\n        continue; // server down, next!\n      }\n    }\n\n    assert(gr_member_connection->is_connected());\n    log_info(\"Connected to replicaset '%s' through %s\", name.c_str(), mi_addr.c_str());\n\n    try {\n      bool single_primary_mode = true;\n\n      // this node's perspective: give status of all nodes you see\n      std::map<std::string, GroupReplicationMember> member_status =\n          fetch_group_replication_members(*gr_member_connection,\n                                          single_primary_mode); // throws metadata_cache::metadata_error\n      log_debug(\"Replicaset '%s' has %lu members in metadata, %lu in status table\",\n                name.c_str(), static_cast<unsigned long>(replicaset.members.size()),\n                static_cast<unsigned long>(member_status.size()));  // 32bit Linux requires cast\n\n      // check status of all nodes; updates instances ------------------vvvvvvvvvvvvvvvvvv\n      metadata_cache::ReplicasetStatus status = check_replicaset_status(replicaset.members, member_status);\n      switch (status) {\n        case metadata_cache::ReplicasetStatus::AvailableWritable: // we have quorum, good!\n          found_quorum = true;\n          break;\n        case metadata_cache::ReplicasetStatus::AvailableReadOnly: // have quorum, but only RO\n          found_quorum = true;\n          break;\n        case metadata_cache::ReplicasetStatus::UnavailableRecovering:  // have quorum, but only with recovering nodes (cornercase)\n          log_warning(\"quorum for replicaset '%s' consists only of recovering nodes!\", name.c_str());\n          found_quorum = true;  // no point in futher search\n          break;\n        case metadata_cache::ReplicasetStatus::Unavailable:       // we have nothing\n          log_warning(\"%s is not part of quorum for replicaset '%s'\", mi_addr.c_str(), name.c_str());\n          continue;   // this server is no good, next!\n      }\n\n      if (found_quorum) {\n        replicaset.single_primary_mode = single_primary_mode;\n        break; // break out of the member iteration loop\n      }\n\n    } catch (const metadata_cache::metadata_error& e) {\n      log_warning(\"Unable to fetch live group_replication member data from %s from replicaset '%s': %s\",\n                  mi_addr.c_str(), name.c_str(), e.what());\n      continue; // faulty server, next!\n    } catch (...) {\n      assert(0);  // unexpected exception\n      log_warning(\"Unable to fetch live group_replication member data from %s from replicaset '%s'\",\n                  mi_addr.c_str(), name.c_str());\n      continue; // faulty server, next!\n    }\n\n  } // for (const metadata_cache::ManagedInstance& mi : instances)\n  log_debug(\"End updating replicaset for '%s'\", name.c_str());\n\n  if (!found_quorum) {\n    std::string msg(\"Unable to fetch live group_replication member data from any server in replicaset '\");\n    msg += name + \"'\";\n    log_error(\"%s\", msg.c_str());\n\n    // if we don't have a quorum, we want to give \"nothing\" to the Routing plugin, so it doesn't\n    // route anything. Routing plugin is dumb, it has no idea what a quorum is, etc.\n    replicaset.members.clear();\n  }\n}\n\nmetadata_cache::ReplicasetStatus ClusterMetadata::check_replicaset_status(\n    std::vector<metadata_cache::ManagedInstance> &instances,\n    const std::map<std::string, GroupReplicationMember> &member_status) const noexcept {\n\n  // In ideal world, the best way to write this function would be to completely ignore\n  // nodes in `instances` and operate on information from `member_status` only. However,\n  // there is one problem: the host:port information contained there may not be accurate\n  // (localhost vs external addressing issues), and we are forced to use the host:port\n  // from `instances` instead. This leads to nasty corner-cases if inconsistencies\n  // exist between the two sets, however.\n\n  // Therefore, this code will work well only under one assumption:\n  // All nodes in `member_status` are present in `instances`. This assumption should\n  // hold unless a user \"manually\" adds new nodes to the replicaset without adding them\n  // to metadata (and the user is not allowed to do that).\n\n  // Detect violation of above assumption (alarm if there's a node in `member_status` not present\n  // in `instances`). It's O(n*m), but the CPU time is negligible while keeping code simple.\n  for (const auto& status_node : member_status) {\n    using MI = metadata_cache::ManagedInstance;\n    auto found = std::find_if(instances.begin(), instances.end(), [&status_node] (const MI& metadata_node) {\n      return status_node.first == metadata_node.mysql_server_uuid;\n    });\n    if (found == instances.end()) {\n      log_error(\"Member %s:%d (%s) found in replicaset, yet is not defined in metadata!\",\n                status_node.second.host.c_str(), status_node.second.port, status_node.first.c_str());\n    }\n  }\n\n  using metadata_cache::ServerMode;\n  using metadata_cache::ReplicasetStatus;\n  using GR_State = GroupReplicationMember::State;\n  using GR_Role  = GroupReplicationMember::Role;\n\n  // we do two things here:\n  // 1. for all `instances`, set .mode according to corresponding .status found in `member_status`\n  // 2. count nodes which are part of quorum (online/recovering nodes)\n  unsigned int quorum_count = 0;\n  bool have_primary_instance = false;\n  bool have_secondary_instance = false;\n  for (auto &member : instances) {\n    auto status = member_status.find(member.mysql_server_uuid);\n    if (status != member_status.end()) {\n      switch (status->second.state) {\n        case GR_State::Online:\n          switch (status->second.role) {\n            case GR_Role::Primary:\n              have_primary_instance = true;\n              member.mode = ServerMode::ReadWrite;\n              quorum_count++;\n              break;\n            case GR_Role::Secondary:\n              have_secondary_instance = true;\n              member.mode = ServerMode::ReadOnly;\n              quorum_count++;\n              break;\n          }\n          break;\n        case GR_State::Recovering:\n        case GR_State::Unreachable:\n        case GR_State::Offline:  // online node with disabled GR maps to this\n        case GR_State::Error:\n        case GR_State::Other:\n          // This could be done with a fallthrough but latest gcc (7.1) generates a warning\n          // for that and there is no sane and portable way to suppress it.\n          if (GR_State::Recovering ==  status->second.state)\n            quorum_count++;\n          member.mode = ServerMode::Unavailable;\n          break;\n      }\n    } else {\n      member.mode = ServerMode::Unavailable;\n      log_warning(\"Member %s:%d (%s) defined in metadata not found in actual replicaset\",\n                   member.host.c_str(), member.port, member.mysql_server_uuid.c_str());\n    }\n  }\n\n  // quorum_count is based on nodes from `instances` instead of `member_status`.\n  // This is okay, because all nodes in `member_status` are present in `instances`\n  // (our assumption described at the top)\n  bool have_quorum = (quorum_count > member_status.size()/2);\n\n  // if we don't have quorum, we don't allow any access. Some configurations might\n  // allow RO access in this case, but we don't support it at the momemnt\n  if (!have_quorum)\n    return ReplicasetStatus::Unavailable;\n\n  // if we have quorum but no primary/secondary instances, it means the quorum\n  // is composed purely of recovering nodes (this is an unlikey cornercase)\n  if (!(have_primary_instance || have_secondary_instance))\n    return ReplicasetStatus::UnavailableRecovering;\n\n  // if primary node was not elected yet, we can only allow reads (typically this is\n  // a temporary state shortly after a node failure, but could also be more permanent)\n  return have_primary_instance\n      ? ReplicasetStatus::AvailableWritable   // typical case\n      : ReplicasetStatus::AvailableReadOnly;  // primary not elected yet\n}\n\n// throws metadata_cache::metadata_error\nClusterMetadata::ReplicaSetsByName ClusterMetadata::fetch_instances(\n    const std::string &cluster_name) {\n  log_debug(\"Updating metadata information for cluster '%s'\", cluster_name.c_str());\n\n  assert(metadata_connection_->is_connected());\n\n  // fetch existing replicasets in the cluster from the metadata server (this is the topology that was configured,\n  // it will be compared later against current topology reported by (a server in) replicaset)\n  ReplicaSetsByName replicasets(fetch_instances_from_metadata_server(cluster_name)); // throws metadata_cache::metadata_error\n  if (replicasets.empty())\n    log_warning(\"No replicasets defined for cluster '%s'\", cluster_name.c_str());\n\n  // now connect to each replicaset and query it for the list and status of its members.\n  // (more precisely, foreach replicaset: search and connect to a member which is part of quorum to retrieve this data)\n  for (auto &&rs : replicasets) {\n    update_replicaset_status(rs.first, rs.second);  // throws metadata_cache::metadata_error\n  }\n\n  return replicasets;\n}\n\n// throws metadata_cache::metadata_error\nClusterMetadata::ReplicaSetsByName ClusterMetadata::fetch_instances_from_metadata_server(\n    const std::string &cluster_name) {\n\n  // Get expected topology (what was configured) from metadata server. This will later be compared against\n  // current topology (what exists NOW) obtained from one of the nodes belonging to a quorum.\n  // Note that this topology will also be successfully returned when a particular metadata server\n  // is not part of GR, as serving metadata and being part of replicaset are two orthogonal ideas.\n  std::string query(\"SELECT \"\n                    \"R.replicaset_name, \"\n                    \"I.mysql_server_uuid, \"\n                    \"I.role, \"\n                    \"I.weight, \"\n                    \"I.version_token, \"\n                    \"H.location, \"\n                    \"I.addresses->>'$.mysqlClassic', \"\n                    \"I.addresses->>'$.mysqlX' \"\n                    \"FROM \"\n                    \"mysql_innodb_cluster_metadata.clusters AS F \"\n                    \"JOIN mysql_innodb_cluster_metadata.replicasets AS R \"\n                    \"ON F.cluster_id = R.cluster_id \"\n                    \"JOIN mysql_innodb_cluster_metadata.instances AS I \"\n                    \"ON R.replicaset_id = I.replicaset_id \"\n                    \"JOIN mysql_innodb_cluster_metadata.hosts AS H \"\n                    \"ON I.host_id = H.host_id \"\n                    \"WHERE F.cluster_name = \" + metadata_connection_->quote(cluster_name) + \";\");\n\n  // example response\n  // +-----------------+--------------------------------------+------+--------+---------------+----------+--------------------------------+--------------------------+\n  // | replicaset_name | mysql_server_uuid                    | role | weight | version_token | location | I.addresses->>'$.mysqlClassic' | I.addresses->>'$.mysqlX' |\n  // +-----------------+--------------------------------------+------+--------+---------------+----------+--------------------------------+--------------------------+\n  // | default         | 30ec658e-861d-11e6-9988-08002741aeb6 | HA   |   NULL |          NULL | blabla   | localhost:3310                 | NULL                     |\n  // | default         | 3acfe4ca-861d-11e6-9e56-08002741aeb6 | HA   |   NULL |          NULL | blabla   | localhost:3320                 | NULL                     |\n  // | default         | 4c08b4a2-861d-11e6-a256-08002741aeb6 | HA   |   NULL |          NULL | blabla   | localhost:3330                 | NULL                     |\n  // +-----------------+--------------------------------------+------+--------+---------------+----------+--------------------------------+--------------------------+\n\n  // The following instance map stores a list of servers mapped to every\n  // replicaset name.\n  // {\n  //   {replicaset_1:[host1:port1, host2:port2, host3:port3]},\n  //   {replicaset_2:[host4:port4, host5:port5, host6:port6]},\n  //   ...\n  //   {replicaset_n:[hostj:portj, hostk:portk, hostl:portl]}\n  // }\n  ReplicaSetsByName replicaset_map;\n\n  // Deserialize the resultset into a map that stores a list of server\n  // instance objects mapped to each replicaset.\n  auto result_processor = [&replicaset_map](const MySQLSession::Row& row) -> bool {\n\n    if (row.size() != 8) {  // TODO write a testcase for this\n      throw metadata_cache::metadata_error(\"Unexpected number of fields in the resultset. \"\n                                           \"Expected = 8, got = \" + std::to_string(row.size()));\n    }\n\n    metadata_cache::ManagedInstance s;\n    s.replicaset_name = get_string(row[0]);\n    s.mysql_server_uuid = get_string(row[1]);\n    s.role = get_string(row[2]);\n    s.weight = row[3] ? std::strtof(row[3], nullptr) : 0;\n    s.version_token = row[4] ? static_cast<unsigned int>(strtoi_checked(row[4])) : 0;\n    s.location = get_string(row[5]);\n    try {\n      std::string uri = get_string(row[6]);\n      std::string::size_type p;\n      if ((p = uri.find(':')) != std::string::npos) {\n        s.host = uri.substr(0, p);\n        s.port = static_cast<unsigned int>(strtoi_checked(uri.substr(p+1).c_str()));\n      } else {\n        s.host = uri;\n        s.port = 3306;\n      }\n    } catch (std::runtime_error &e) {\n      log_warning(\"Error parsing URI in metadata for instance %s: '%s': %s\",\n          row[1], row[6], e.what());\n      return true;  // next row\n    }\n    // X protocol support is not mandatory\n    if (row[7] && *row[7]) {\n      try {\n        std::string uri = get_string(row[7]);\n        std::string::size_type p;\n        if ((p = uri.find(':')) != std::string::npos) {\n          s.host = uri.substr(0, p);\n          s.xport = static_cast<unsigned int>(strtoi_checked(uri.substr(p+1).c_str()));\n        } else {\n          s.host = uri;\n          s.xport = 33060;\n        }\n      } catch (std::runtime_error &e) {\n        log_warning(\"Error parsing URI in metadata for instance %s: '%s': %s\",\n            row[1], row[7], e.what());\n        return true;  // next row\n      }\n    } else {\n      s.xport = s.port * 10;\n    }\n\n    auto &rset(replicaset_map[s.replicaset_name]);\n    rset.members.push_back(s);\n    rset.name = s.replicaset_name;\n    rset.single_primary_mode = true; // actual value set elsewhere from GR metadata\n\n    return true;  // false = I don't want more rows\n  };\n\n  assert(metadata_connection_->is_connected());\n\n  try {\n    metadata_connection_->query(query, result_processor);\n  } catch (const MySQLSession::Error& e) {\n    throw metadata_cache::metadata_error(e.what());\n  } catch (const metadata_cache::metadata_error& e) {\n    throw;\n  } catch (...) {\n    assert(0);  // don't expect anything else to be thrown -> catch dev's attention\n    throw;      // in production, rethrow anyway just in case\n  }\n\n  return replicaset_map;\n}\n\n#if 0 // not used so far\nunsigned int ClusterMetadata::fetch_ttl() {\n  return ttl_;\n}\n#endif\n"
  },
  {
    "path": "src/metadata_cache/src/cluster_metadata.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef METADATA_CACHE_METADATA_INCLUDED\n#define METADATA_CACHE_METADATA_INCLUDED\n\n#include \"mysqlrouter/metadata_cache.h\"\n#include \"mysqlrouter/mysql_session.h\"\n#include \"metadata.h\"\n#include \"tcp_address.h\"\n\n#include <chrono>\n#include <vector>\n#include <memory>\n#include <map>\n#include <string>\n#include <string.h>\n\nstruct GroupReplicationMember;\n\nnamespace mysqlrouter { class MySQLSession; }\n\n/** @class ClusterMetadata\n *\n * The `ClusterMetadata` class encapsulates a connection to the Metadata server. It\n * uses the mysqlrouter::MySQLSession to setup, manage and retrieve results.\n *\n */\nclass METADATA_API ClusterMetadata : public MetaData {\n public:\n  /** @brief Constructor\n   *\n   * @param user The user name used to authenticate to the metadata server.\n   * @param password The password used to authenticate to the metadata server.\n   * @param connect_timeout The time after which trying to connect to the\n   *                        metadata server should timeout (in seconds).\n   * @param read_timeout The time after which read from metadata server should\n   *                     timeout (in seconds).\n   * @param connection_attempts The number of times a connection to metadata\n   *                            must be attempted, when a connection attempt\n   *                            fails.  NOTE: not used so far\n   * @param ttl The time to live of the data in the cache (in milliseconds).\n   * @param ssl_options SSL related options to use for MySQL connections\n   */\n  ClusterMetadata(const std::string &user, const std::string &password,\n                  int connect_timeout, int read_timeout,\n                  int connection_attempts, std::chrono::milliseconds ttl,\n                  const mysqlrouter::SSLOptions &ssl_options);\n\n  /** @brief Destructor\n   *\n   * Disconnect and release the connection to the metadata node.\n   */\n  virtual ~ClusterMetadata();\n\n\n  /** @brief Returns replicasets defined in the metadata server\n   *\n   * Returns relation as a std::map between replicaset name and object\n   * of the replicasets defined in the metadata and GR status tables.\n   *\n   * @param cluster_name the name of the cluster to query\n   * @return Map of replicaset ID, server list pairs.\n   * @throws metadata_cache::metadata_error\n   */\n  ReplicaSetsByName fetch_instances(const std::string &cluster_name) override; // throws metadata_cache::metadata_error\n\n#if 0 // not used so far\n  /** @brief Returns the refresh interval provided by the metadata server.\n   *\n   * Returns the refresh interval (also known as TTL) provided by metadata server.\n   *\n   * @return refresh interval of the Metadata cache.\n   */\n  unsigned int fetch_ttl() override;\n#endif\n\n  /** @brief Connects with the Metadata server\n   *\n   *\n   * @param metadata_server the server instance for which the connection\n   *                        should be attempted.\n   *\n   * @return a boolean to indicate if the connection was successful.\n   */\n  bool connect(const metadata_cache::ManagedInstance &metadata_server) noexcept override;\n\n  /** @brief Disconnects from the Metadata server\n   *\n   * This is a no-op, as MySQLSession object used underneath for\n   * connection handling employs RAII, making this method unnecessary.\n   */\n  void disconnect() noexcept override {}\n\n private:\n  /** Connects a MYSQL connection to the given instance\n   */\n  bool do_connect(mysqlrouter::MySQLSession& connection, const metadata_cache::ManagedInstance &mi);\n\n  /** @brief Queries the metadata server for the list of instances and\n   * replicasets that belong to the desired cluster.\n   */\n  ReplicaSetsByName fetch_instances_from_metadata_server(const std::string &cluster_name);\n\n  /** Query the GR performance_schema tables for live information about a replicaset.\n   *\n   * update_replicaset_status() calls check_replicaset_status() for some of its processing.\n   * Together, they:\n   * - check current topology (status) returned from a replicaset node\n   * - update 'instances' with this state\n   * - get other metadata about the replicaset\n   *\n   * The information is pulled from GR maintained performance_schema tables.\n   */\n  void update_replicaset_status(const std::string &name,\n      metadata_cache::ManagedReplicaSet &replicaset); // throws metadata_cache::metadata_error\n\n  /** @brief Hard to summarise, please read the full description\n   *\n   * Does two things based on `member_status` provided:\n   * - updates `instances` with status info from `member_status`\n   * - performs quorum calculations and returns replicaset's overall health\n   *   based on the result, one of: read-only, read-write or not-available\n   *\n   * @param member_status node statuses obtained from status SQL query\n   * @param instances list of nodes to be updated with status info\n   * @return replicaset availability state (RW, RO or NA)\n   */\n  metadata_cache::ReplicasetStatus check_replicaset_status(\n      std::vector<metadata_cache::ManagedInstance> &instances,\n      const std::map<std::string, GroupReplicationMember> &member_status) const noexcept;\n\n  // Metadata node connection information\n  std::string user_;\n  std::string password_;\n\n  // Metadata node generic information\n  std::chrono::milliseconds ttl_;\n  mysql_ssl_mode ssl_mode_;\n  mysqlrouter::SSLOptions ssl_options_;\n\n  std::string cluster_name_;\n#if 0 // not used so far\n  std::string metadata_uuid_;\n  std::string message_;\n#endif\n\n  // The time after which trying to connect to the metadata server should timeout.\n  int connect_timeout_;\n  // The time after which read from metadata server should timeout.\n  int read_timeout_;\n\n#if 0 // not used so far\n  // The number of times we should try connecting to the metadata server if a\n  // connection attempt fails.\n  int connection_attempts_;\n#endif\n\n  // connection to metadata server (it may also be shared with GR status queries for optimisation purposes)\n  std::shared_ptr<mysqlrouter::MySQLSession> metadata_connection_;\n\n#if 0 // not used so far\n  // How many times we tried to reconnected (for logging purposes)\n  size_t reconnect_tries_;\n#endif\n\n#ifdef FRIEND_TEST\n  FRIEND_TEST(MetadataTest, FetchInstancesFromMetadataServer);\n  FRIEND_TEST(MetadataTest, CheckReplicasetStatus_3NodeSetup);\n  FRIEND_TEST(MetadataTest, CheckReplicasetStatus_VariableNodeSetup);\n  FRIEND_TEST(MetadataTest, CheckReplicasetStatus_VariousStatuses);\n  FRIEND_TEST(MetadataTest, UpdateReplicasetStatus_PrimaryMember_FailConnectOnNode2);\n  FRIEND_TEST(MetadataTest, UpdateReplicasetStatus_PrimaryMember_FailConnectOnAllNodes);\n  FRIEND_TEST(MetadataTest, UpdateReplicasetStatus_PrimaryMember_EmptyOnNode1);\n  FRIEND_TEST(MetadataTest, UpdateReplicasetStatus_PrimaryMember_EmptyOnAllNodes);\n  FRIEND_TEST(MetadataTest, UpdateReplicasetStatus_PrimaryMember_FailQueryOnNode1);\n  FRIEND_TEST(MetadataTest, UpdateReplicasetStatus_PrimaryMember_FailQueryOnAllNodes);\n  FRIEND_TEST(MetadataTest, UpdateReplicasetStatus_Status_FailQueryOnNode1);\n  FRIEND_TEST(MetadataTest, UpdateReplicasetStatus_Status_FailQueryOnAllNodes);\n  FRIEND_TEST(MetadataTest, UpdateReplicasetStatus_SimpleSunnyDayScenario);\n  FRIEND_TEST(MetadataTest, CheckReplicasetStatus_Recovering);\n  FRIEND_TEST(MetadataTest, CheckReplicasetStatus_ErrorAndOther);\n  FRIEND_TEST(MetadataTest, CheckReplicasetStatus_Cornercase2of5Alive);\n  FRIEND_TEST(MetadataTest, CheckReplicasetStatus_Cornercase3of5Alive);\n  FRIEND_TEST(MetadataTest, CheckReplicasetStatus_Cornercase1Common);\n#endif\n};\n\n#endif // METADATA_CACHE_METADATA_INCLUDED\n"
  },
  {
    "path": "src/metadata_cache/src/group_replication_metadata.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"group_replication_metadata.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"metadata.h\"\n#include \"mysqlrouter/mysql_session.h\"\n\n#include <cstdlib>\n#include <cstring>\n#include <assert.h> // <cassert> is flawed: assert() lands in global namespace on Ubuntu 14.04, not std::\n#include <memory>\n#include <sstream>\n\nusing mysqlrouter::MySQLSession;\nIMPORT_LOG_FUNCTIONS()\n\n// throws metadata_cache::metadata_error\nstatic std::string find_group_replication_primary_member(MySQLSession& connection) {\n\n  // NOTE: In single-master mode, this function will return primary node ID as\n  //       seen by this node (provided this node is currently part of GR),\n  //       but in multi-master node, it will always return <empty>.\n  //       Such is behavior of group_replication_primary_member variable.\n\n  std::string primary_member;\n\n  auto result_processor = [&primary_member](const MySQLSession::Row& row) -> bool {\n\n    // Typical reponse is shown below. If this node is part of group replication AND we're in SM mode,\n    // 'Value' will show the primary node, else, it will be empty.\n    // +----------------------------------+--------------------------------------+\n    // | Variable_name                    | Value                                |\n    // +----------------------------------+--------------------------------------+\n    // | group_replication_primary_member | 3acfe4ca-861d-11e6-9e56-08002741aeb6 |\n    // +----------------------------------+--------------------------------------+\n\n    if (row.size() != 2) {  // TODO write a testcase for this\n      throw metadata_cache::metadata_error(\"Unexpected number of fields in the status response. \"\n                                           \"Expected = 2, got = \" + std::to_string(row.size()));\n    }\n\n    assert(!strcmp(row[0], \"group_replication_primary_member\"));\n    primary_member = row[1] ? row[1] : \"\";\n    return false; // false = I don't want more rows\n  };\n\n  // Get primary node (as seen by this node). primary_member will contain ID of the primary node\n  // (such as \"3acfe4ca-861d-11e6-9e56-08002741aeb6\"), or \"\" if this node is not (currently) part of GR\n  // It will also be empty if we're running GR in multi-master mode.\n  try {\n    connection.query(\"show status like 'group_replication_primary_member'\", result_processor);\n  } catch (const MySQLSession::Error& e) {\n    throw metadata_cache::metadata_error(e.what());\n  } catch (const metadata_cache::metadata_error& e) {\n    throw;\n  } catch (...) {\n    assert(0);  // don't expect anything else to be thrown -> catch dev's attention\n    throw;      // in production, rethrow anyway just in case\n  }\n\n  return primary_member;\n}\n\n// throws metadata_cache::metadata_error\nstd::map<std::string, GroupReplicationMember> fetch_group_replication_members(\n    MySQLSession& connection, bool &single_master) {\n\n  std::map<std::string, GroupReplicationMember> members;\n\n  // who's the primary node? (throws metadata_cache::metadata_error)\n  std::string primary_member = find_group_replication_primary_member(connection);\n\n\n  auto result_processor = [&members, &primary_member, &single_master](const MySQLSession::Row& row) -> bool {\n\n    // example response from node that left GR (sees only itself):\n    // +--------------------------------------+-------------+-------------+--------------+-----------------------------------------+\n    // | member_id                            | member_host | member_port | member_state | @@group_replication_single_primary_mode |\n    // +--------------------------------------+-------------+-------------+--------------+-----------------------------------------+\n    // | 30ec658e-861d-11e6-9988-08002741aeb6 | ubuntu      |        3310 | OFFLINE      |                                       1 |\n    // +--------------------------------------+-------------+-------------+--------------+-----------------------------------------+\n    //\n    // example response from node that is still part of GR (normally should see itself and all other GR members):\n    // +--------------------------------------+-------------+-------------+--------------+-----------------------------------------+\n    // | member_id                            | member_host | member_port | member_state | @@group_replication_single_primary_mode |\n    // +--------------------------------------+-------------+-------------+--------------+-----------------------------------------+\n    // | 3acfe4ca-861d-11e6-9e56-08002741aeb6 | ubuntu      |        3320 | ONLINE       |                                       1 |\n    // | 4c08b4a2-861d-11e6-a256-08002741aeb6 | ubuntu      |        3330 | ONLINE       |                                       1 |\n    // +--------------------------------------+-------------+-------------+--------------+-----------------------------------------+\n\n    if (row.size() != 5) {  // TODO write a testcase for this\n      throw metadata_cache::metadata_error(\"Unexpected number of fields in resultset from group_replication query. \"\n                                           \"Expected = 5, got = \" + std::to_string(row.size()));\n    }\n\n    // read fields from row\n    const char *member_id = row[0];\n    const char *member_host = row[1];\n    const char *member_port = row[2];\n    const char *member_state = row[3];\n    single_master = row[4] && (strcmp(row[4], \"1\") == 0 || strcmp(row[4], \"ON\") == 0);\n    if (!member_id || !member_host || !member_port || !member_state) {\n      log_warning(\"Query %s returned %s, %s, %s, %s, %s\",\n                \"SELECT member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode\"\n                \" FROM performance_schema.replication_group_members\"\n                \" WHERE channel_name = 'group_replication_applier'\",\n               row[0], row[1], row[2], row[3], row[4]);\n      throw metadata_cache::metadata_error(\"Unexpected value in group_replication_metadata query results\");\n    }\n\n    // populate GroupReplicationMember with data from row\n    GroupReplicationMember member;\n    member.member_id = member_id;\n    member.host = member_host;\n    member.port = static_cast<uint16_t>(std::atoi(member_port));\n    if (std::strcmp(member_state, \"ONLINE\") == 0)\n      member.state = GroupReplicationMember::State::Online;\n    else if (std::strcmp(member_state, \"OFFLINE\") == 0)\n      member.state = GroupReplicationMember::State::Offline;\n    else if (std::strcmp(member_state, \"UNREACHABLE\") == 0)\n      member.state = GroupReplicationMember::State::Unreachable;\n    else if (std::strcmp(member_state, \"RECOVERING\") == 0)\n      member.state = GroupReplicationMember::State::Recovering;\n    else if (std::strcmp(member_state, \"ERROR\") == 0)\n      member.state = GroupReplicationMember::State::Error;\n    else {\n      log_info(\"Unknown state %s in replication_group_members table for %s\", member_state, member_id);\n      member.state = GroupReplicationMember::State::Other;\n    }\n\n    // if single_master == true, we're in single-master mode, implying at most 1 Primary(RW) node\n    // if single_master == false, we're in multi-master mode, implying all nodes are Primary(RW)\n    if (primary_member == member.member_id || !single_master)\n      member.role = GroupReplicationMember::Role::Primary;\n    else\n      member.role = GroupReplicationMember::Role::Secondary;\n\n    // add GroupReplicationMember to map that will be returned\n    members[member_id] = member;\n\n    return true;  // false = I don't want more rows\n  };\n\n  // TODO optimisation some day:\n  // Query executed in find_group_replication_primary_member() can be optimised away\n  // by blending into the following query.  Unit tests will also have to be updated.\n\n  // get current topology (as seen by this node)\n  try {\n    connection.query(\n      \"SELECT member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode\"\n      \" FROM performance_schema.replication_group_members\"\n      \" WHERE channel_name = 'group_replication_applier'\",\n      result_processor);\n\n  } catch (const MySQLSession::Error& e) {\n    throw metadata_cache::metadata_error(e.what());\n  } catch (const metadata_cache::metadata_error& e) {\n    throw;\n  } catch (...) {\n    assert(0);  // don't expect anything else to be thrown -> catch dev's attention\n    throw;      // in production, rethrow anyway just in case\n  }\n\n  return members;\n}\n"
  },
  {
    "path": "src/metadata_cache/src/group_replication_metadata.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef GROUP_REPLICATION_METADATA_INCLUDED\n#define GROUP_REPLICATION_METADATA_INCLUDED\n\n#include <string>\n#include <vector>\n#include <map>\n\nnamespace mysqlrouter { class MySQLSession; }\n\nstruct GroupReplicationMember {\n  enum class State {\n    Online,\n    Recovering,\n    Unreachable,\n    Offline,\n    Error,\n    Other,\n  };\n  enum class Role {\n    Primary,\n    Secondary,\n  };\n  std::string member_id;\n  std::string host;\n  uint16_t port;\n  State state;\n  Role role;\n};\n\n/** Fetches the list of group replication members known to the instance of the\n * given connection.\n *\n * throws metadata_cache::metadata_error\n */\nstd::map<std::string, GroupReplicationMember>\nfetch_group_replication_members(mysqlrouter::MySQLSession& connection, bool &single_master);\n\n#endif\n"
  },
  {
    "path": "src/metadata_cache/src/metadata.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef METADATA_CACHE_METADATA_INTERFACE_INCLUDED\n#define METADATA_CACHE_METADATA_INTERFACE_INCLUDED\n\n#include \"mysqlrouter/metadata_cache.h\"\n\n#include <vector>\n#include <map>\n#include <string>\n\n/**\n * The metadata class is used to create a pluggable transport layer\n * from which the metadata is fetched for the metadata cache.\n */\nclass METADATA_API MetaData {\npublic:\n  using ReplicaSetsByName = std::map<std::string, metadata_cache::ManagedReplicaSet>;\n  virtual ReplicaSetsByName fetch_instances(const std::string &cluster_name) = 0;\n\n  virtual bool connect(const metadata_cache::ManagedInstance &metadata_server) = 0;\n  virtual void disconnect() = 0;\n  virtual ~MetaData() { }\n};\n\n#endif // METADATA_CACHE_METADATA_INTERFACE_INCLUDED\n"
  },
  {
    "path": "src/metadata_cache/src/metadata_cache.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/**\n * @defgroup MDC Metadata Cache\n *\n * Synopsis\n * ========\n *\n * Metadata Cache plugin communicates with Metadata and Group Replication\n * exposed by the cluster to obtain its topology and availablity information.\n * The digest of this information is then exposed to Routing Plugin in form of a\n * routing table.\n * Key components:\n * - Metadata Cache API - interface through which it exposes its service\n * - Refresh Mechansim - responsible for updating routing table\n *\n *\n *\n *\n *\n * Glossary\n * ========\n *\n * replicaset = group of servers that contain the same data; in simple cases\n *              replicaset and cluster are interchangeable, but in case of\n *              sharded cluster this no longer applies, as the cluster will be\n *              composed of multiple replicasets, each handling a different\n *              shard.\n *\n * MD = metadata, several tables residing on the metadata server, which (among\n *      other things) contain cluster topology information. It reflects the\n *      desired \"as it should be\" version of topology.\n *\n * GR = Group Replication, a server-side plugin responsible for synchronising\n *      data between cluster nodes. It exposes certain dynamic tables (views)\n *      that we query to obtain health status of the cluster. It reflects the\n *      real \"as it actually is\" version of topology.\n *\n * MDC = MD Cache, this plugin (the code that you're reading now).\n *\n * MM = multi-master, a replication mode in which all GR members are RW.\n *\n * SM = single-master, a replication mode in which only one GR member is RW,\n *      rest are RO.\n *\n * ATTOW = contraction for \"at the time of writing\".\n *\n * [xx] (where x is a digit) = reference to a note in Notes section.\n *\n *\n *\n *\n *\n * Refresh Mechanism\n * =================\n *\n * @note\n * To keep docs simpler, all below describes how MDC behaves in case of handling\n * just one replicaset. It has been designed to handle more than one, however,\n * ATTOW we don't test it with more than one, so we are uncertain if it would\n * actually deliver on that promise.  This is also the reason why throughout the\n * MDC code there are data structures that are collections of replicasets and\n * for loops that iterate over them, yet in reality we always deal with just one\n * element in those containers and such loops iterate only once.\n *\n *\n *\n *\n *\n * ## Overview\n * MDC refresh runs in its own thread and periodically queries both MD and GR\n * for status, then updates routing table which is queried by the Routing\n * Plugin. Its entry point is `MetadataCache::start()`, which (indirectly) runs\n * a \"forever loop\" in `MetadataCache::refresh_thread()`, which in turn is\n * responsible for perodically running `MetadataCache::refresh()`.\n *\n * `MetadataCache::refresh()` is the \"workhorse\" of refresh mechanism.\n *\n *\n *\n *\n *\n * ## Refresh trigger\n * `MetadataCache::refresh_thread()` call to `MetadataCache::refresh()` can be\n * triggered in 2 ways:\n * - `<TTL>` seconds passed since last refresh\n * - emergency mode (replicaset is flagged to have at least one node unreachable).\n *\n * It's implemented by running a sleep loop between refreshes. The loop sleeps 1\n * second at a time, until `<TTL>` iterations have gone or emergency mode is\n * enabled.\n *\n *\n *\n * ### Emergency mode\n * Emergency mode is entered, when Routing Plugin discovers that it's unable to\n * connect to a node that's declared by MDC as routable (node that is labelled\n * as writable or readonly). In such situation, it will flag the replicaset as\n * missing a node, and MDC will react by increasing refresh rate to 1/s (if it\n * is currently lower).\n *\n * This emergency mode will stay enabled, until routing table resulting from\n * most recent MD and GR query is different from the one before it _AND_ the\n * replicaset is in RW mode.\n *\n * @note\n * The reason why we require the routing table to be different before we disable\n * the emergency mode, is because it usually takes several seconds for GR to\n * figure out that some node went down. Thus we want to wait until GR gives us a\n * topology that reflects the change. This strategy might have a bug however\n * [05].\n *\n * @note\n * The reason why we require the replicaset to be in RW mode before we disable\n * the emergency mode, is the assumption that the user wants the replicaset to\n * be RW and if it is in RO, it is undergoing a failure. This assumption is\n * probably flawed [06].\n *\n *\n *\n *\n *\n * ## Refresh process\n * Once refresh is called, it goes through the following stages:\n * - Stage 1: Query MD\n * - Stage 2: Query GR, combine results with MD, determine availability\n * - Stage 3: Update routing table\n *\n * In subsequent sections each stage is described in more detail\n *\n *\n *\n *\n *\n * ### Stage 1: Query MD\n * This stage can be divided into two major substages:\n *   1. Connect to MD server\n *   2. Extract MD information\n *\n *\n *\n * #### Stage 1.1: Connect to MD server\n *\n * Implemented in: `ClusterMetadata::connect()`\n *\n * MDC starts with a list of MD servers written in the configuration file, such\n * as:\n *\n *     bootstrap_server_addresses = mysql://192.168.56.101:3310,\n *                                  mysql://192.168.56.101:3320,\n *                                  mysql://192.168.56.101:3330\n *\n * It iterates through the list and tries to connect to each one, until\n * connection succeeds.\n *\n * @note\n * This behavior might change in near future, because it does not ensure that\n * connected MD server holds valid MD data [01].\n *\n * @note\n * Iteration always starting from 1st server on the list might also change [02].\n *\n * @note\n * New connection is always established and old one closed off, even if old one\n * is still alive and usable.\n *\n *\n *\n * #### Stage 1.2: Extract MD Information\n *\n * Implemented in: `ClusterMetadata::fetch_instances_from_metadata_server()`\n *\n * Using connection established in Stage 1.1, MDC runs a SQL query which\n * extracts a list of nodes (GR members) belonging to the replicaset. Note that\n * this the configured \"should be\" view of replicaset topology, which might not\n * correspond to actual topology, if for example some nodes became unavailable,\n * changed their role or new nodes were added without updating MD in the\n * server.\n *\n * @note\n * ATTOW, if this query fails, whole refresh process fails [03].\n *\n *\n *\n *\n *\n * ### Stage 2: Query GR, combine results with MD, determine availability\n *\n * Implemented in: `ClusterMetadata::update_replicaset_status()`\n *\n * Here MDC iterates through the list of GR members obtained from MD in Stage\n * 1.2, until it finds a \"trustworthy\" GR node. A \"trustworthy\" GR node is one\n * that passes the following substages:\n *   1. successfully connects\n *   2. successfully responds to 2 GR status SQL queries\n *   3. is part of quorum (regardless of whether it's available or not)\n *\n * If MDC doesn't find a \"trustworthy\" node, it clears the routing table,\n * resulting in Routing Plugin not routing any new connections.\n *\n * @note\n * Since Stage 2 got its list of candidate GR nodes from MD server, it follows\n * that MDC will never query any nodes not present in MD for GR status.\n *\n * @note\n * Any routing table updates will not go into effect until Stage 3, where it is\n * applied.\n *\n * @note\n * ATTOW clearing routing table will not automatically close off old\n * connections. This is a bug which is addressed by upcoming WL#11954.\n *\n *\n *\n * #### Stage 2.1: Connect to GR node\n *\n * Implemented in: `ClusterMetadata::update_replicaset_status()`\n *\n * New connection to GR node is established (on failure, Stage 2 progresses to\n * next iteration).\n *\n * @note\n * Since connection to MD server in Stage 1.1 is not closed after that stage\n * finishes, there's an optimisation done for when connecting to a GR member\n * that's the same node as the MD server - in such case, the connection is\n * simply re-used rather than new one opened.\n *\n *\n *\n * #### Stage 2.2: Extract GR status\n *\n * Implemented in: `fetch_group_replication_members()` and\n *                   `find_group_replication_primary_member()`\n *\n * Two SQL queries are ran and combined to produce a status report of all nodes\n * seen by this node (which would be the entire replicaset if it was in perfect\n * health, or its subset if some nodes became unavailable or the replicaset was\n * experiencing a split-brain scenario):\n *\n *   1. determine the PRIMARY member of the replicaset (if there is more than\n *      one, such as in MM setups, the first one is returned and the rest are\n *      ignored)\n *\n *   2. get the membership and health status of all GR nodes, as seen by this\n *      node\n *\n * If either SQL query fails to execute, Stage 2 iterates to next GR node.\n *\n * @note\n * ATTOW, 1st query is always ran, regardless of whether we're in MM mode or\n * not. As all nodes are PRIMARY in MM setups, we could optimise this query away\n * in MM setups.\n *\n *\n *\n * #### Stage 2.3: Quorum test\n *\n * Implemented in: `ClusterMetadata::update_replicaset_status()` and\n *                   `ClusterMetadata::check_replicaset_status()`\n *\n * MD and GR data collected up to now are compared, to see if GR node just\n * queried belongs to an available replicaset (or to an available replicaset\n * partition, if replicaset has partitioned). For a replicaset (partition) to\n * be considered available, it has to have quorum, that is, meet the following\n * condition:\n *\n *     count(ONLINE nodes) + count(RECOVERING nodes)\n *         is greater than\n *     1/2 * count(all original nodes according to MD).\n *\n * If particular GR node does not meet the quorum condition, Stage 2 iterates\n * to next GR node.\n *\n * OTOH, if GR node is part of quorum, Stage 2 will not iterate further,\n * because it would be pointless (it's not possible to find a member that's\n * part of another quorum, because there can only be one quorum, the one we\n * just found). This matters, because having quorum does not automatically\n * imply being available, as next paragraph explains.\n *\n * The availability test will resolve node's replicaset to be in of the 4\n * possible states:\n * - Unavailable (this node is not part of quorum)\n * - UnavailableRecovering (quorum is met, but it consists of only RECOVERING\n *   nodes - this is a rare cornercase)\n * - AvailableWritable (quorum is met, at least one RW node present)\n * - AvailableReadOnly (quorum is met, no RW nodes present)\n *\n * As already mentioned, reaching 1st of the 4 above states will result in\n * Stage 2 iterating to the next node. OTOH, achieving one of remaining 3\n * states will cause MDC to move on to Stage 3, where it sets the routing table\n * accordingly.\n *\n *\n * ##### GR-MD dishorenecy\n *\n * ATTOW, our Router has a certain limitation: it assumes that MD contains an\n * exact set or superset of nodes in GR. The user is normally expected to use\n * MySQL Shell to reconfigure the replicaset, which automatically updates both\n * GR and MD, keeping them in sync. But if for some reason the user tinkers with\n * GR directly and adds nodes without updating MD accordingly,\n * availablity/quorum calculations will be skewed. We run checks to detect such\n * situation, and log a warning like so:\n *\n *     log_error(\"Member %s:%d (%s) found in replicaset, yet is not defined in\n *     metadata!\"\n *\n * but beyond that we just act defensively by having our quorum calculation be\n * conservative, and error on the side of caution when such discrepancy happens\n * (quorum becomes harder to reach than if MD contained all GR members).\n *\n * Quorum is evaluated in code as follows:\n *\n *     bool have_quorum = (quorum_count > member_status.size()/2);\n *\n * - `quorum_count` is the sum of PRIMARY, SECONDARY and RECOVERING nodes that\n *   appear in MD _and_ GR\n * - `member_status.size()` is the sum of all nodes in GR, regardless of if they\n *   show up in MD or not\n * - any nodes in MD but not in GR will be marked as Unavailable, this is an\n *   expected scenario, and we react correctly; they do not increment\n *   `quorum_count` nor `member_status.size()`\n * - any nodes in GR but not in MD will never become routing destinations,\n *   but they will increment the `member_status.size()`, making quorum harder to\n *   reach.\n *\n * To illustrate how our quorum calculation will behave when GR and MD get out\n * sync, below are some example scenarios:\n *\n * ###### Scenario 1\n *\n *     MD defines nodes A, B, C\n *     GR defines nodes A, B, C, D, E\n *     A, B are alive; C, D, E are dead\n *\n * Availability calculation should deem replicaset to be unavailable, because\n * only 2 of 5 nodes are alive, even though looking purely from MD point-of-view,\n * 2 of its 3 nodes are still alive, thus could be considered a quorum.\n * In such case:\n *\n *     quorum_count = 2 (A and B)\n *     member_status.size() = 5\n *\n * and thus:\n *\n *     have_quorum = (2 > 5/2) = false\n *\n * ###### Scenario 2\n *\n *     MD defines nodes A, B, C\n *     GR defines nodes A, B, C, D, E\n *     A, B are dead, C, D, E are alive\n *\n * Availability calculation, if fully GR-aware, could deem replicaset as\n * available, because looking from purely GR perspective, 3 of 5 nodes form\n * quorum. OTOH, looking from MD perspective, only 1 of 3 its nodes (C) is\n * alive.\n *\n * Our availability calculation prefers to err on the side of caution. So here\n * the availability is judged as not available, even though it could be. But\n * that's the price we pay in exchange for the safety the algorithm provides\n * demonstrated in the previous scenario:\n *\n *     quorum_count = 1 (C)\n *     member_status.size() = 5\n *\n * and thus:\n *\n *     have_quorum = (1 > 5/2) = false\n *\n * ###### Scenario 3\n *\n *     MD defines nodes A, B, C\n *     GR defines nodes       C, D, E\n *     A, B are not reported by GR, C, D, E are alive\n *\n * According to GR, there's a quorum between nodes C, D and E. However, from MD\n * point-of-view, A and B went missing and only C is known to be alive.\n *\n * Again, our available calculation prefers to err on the safe side:\n *\n *     quorum_count = 1 (C)\n *     member_status.size() = 5\n *\n * and thus:\n *\n *     have_quorum = (1 > 5/2) = false\n *\n *\n * ##### Why don't we just use GR data (and do away with Metadata)?\n *\n * Need for cluster configuration aside, there is another challenge. GR can\n * provide IP/hostnames of nodes as it sees them from its own perspective, but\n * those IP/hostnames might not be externally-reachable. OTOH, MD tables provide\n * external IP/hostnames which Router relies upon to reach the GR nodes.\n *\n *\n *\n *\n *\n * ### Stage 3: Update routing table\n *\n * Implemented in: `MetadataCache::refresh()`\n *\n * Once stage 2 is complete, the resulting routing table from Stage 2 is\n * applied. It is also compared to the old routing table and if there is a\n * difference between them, two things happen:\n *\n * 1. Appropriate log messages are issued advising of availability change.\n *\n * 2. A check is run if replicaset is in RW mode. If it is, emergency mode is\n *    called off (see \"Emergency mode\" section for more information).\n *\n *\n *\n *\n *\n * ##NOTES\n *\n * ### Emergency mode\n * [05] Imagine a scenario where a replicaset is perfectly healthy, but Routing\n *      Plugin has a network hickup and fails to connect to one of its nodes. As\n *      a result, it will flag the replicaset as missing a node, triggerring\n *      emergency mode. Emergency mode will only be turned off after routing\n *      table changes (the assumption is that the current one is stale and we're\n *      waiting for an updated one reflecting the problem Routing Plugin\n *      observed). However, since the replicaset is healthy, as long as it stays\n *      that way no such update will come, leaving emergency mode enabled\n *      indefinitely. This has been reported as BUG#27065614\n *\n * [06] Requiring replicaset to be available in RW mode before disabling\n *      emergency mode has a flaw: if replicaset is placed in super-read-only\n *      mode, it is possible for PRIMARY node to be read-only.\n *\n *\n * ### Stage 1.1\n * [01] There has been a recent concern ATTOW, that MD returned might be stale,\n *      if MD server node is in RECOVERING state. This assumes the MD server is\n *      also deployed on an InnoDB cluster.\n *\n * [02] It might be better to always start from the last successfully-connected\n *      server, rather than 1st on the list, to avoid unneccessary connection\n *      attempts when 1st server is dead.\n *\n *\n * ### Stage 1.2\n * [03] If MD-fetching SQL statement fails to execute or process properly, it\n *      will raise an exception that is caught by the topmost catch of the\n *      refresh process, meaning, another MD server will not be queried. This is\n *      a bug, reported as BUG#28082473\n */\n\n#ifdef _WIN32\n#define NOMINMAX\n#endif\n\n#include \"common.h\"\n#include \"metadata_cache.h\"\n#include \"mysql/harness/logging/logging.h\"\n\n#include <cassert>\n#include <vector>\n#include <memory>\n#include <cmath>  // fabs()\n\nIMPORT_LOG_FUNCTIONS()\n\nMetadataCache::MetadataCache(\n  const std::vector<mysql_harness::TCPAddress> &bootstrap_servers,\n  std::shared_ptr<MetaData> cluster_metadata, // this could be changed to UniquePtr\n  std::chrono::milliseconds ttl,\n  const mysqlrouter::SSLOptions &ssl_options,\n  const std::string &cluster,\n  size_t thread_stack_size) : refresh_thread_(thread_stack_size) {\n  std::string host;\n  for (auto s : bootstrap_servers) {\n    metadata_cache::ManagedInstance bootstrap_server_instance;\n    host = (s.addr == \"localhost\" ? \"127.0.0.1\" : s.addr);\n    bootstrap_server_instance.host = host;\n    bootstrap_server_instance.port = s.port;\n    metadata_servers_.push_back(bootstrap_server_instance);\n  }\n  ttl_ = ttl;\n  cluster_name_ = cluster;\n  terminate_ = false;\n  meta_data_ = cluster_metadata;\n  ssl_options_ = ssl_options;\n  refresh();\n}\n\nvoid* MetadataCache::run_thread(void* context) {\n  MetadataCache* metadata_cache = static_cast<MetadataCache*>(context);\n  metadata_cache->refresh_thread();\n  return nullptr;\n}\n\nvoid MetadataCache::refresh_thread() {\n  mysql_harness::rename_thread(\"MDC Refresh\");\n\n  // this will be only useful if the TTL is set to some value that is more than 1 second\n  const std::chrono::milliseconds kTerminateOrForcedRefreshCheckInterval = std::chrono::seconds(1);\n\n  while (!terminate_) {\n    refresh();\n\n    auto ttl_left = ttl_;\n    // wait for up to TTL until next refresh, unless some replicaset loses an\n    // online (primary or secondary) server - in that case, \"emergency mode\" is\n    // enabled and we refresh every 1s until \"emergency mode\" is called off.\n    while (ttl_left > std::chrono::milliseconds(0)) {\n      if (terminate_) return;\n\n      auto sleep_for = std::min(ttl_left, kTerminateOrForcedRefreshCheckInterval);\n      std::this_thread::sleep_for(sleep_for);\n      ttl_left -= sleep_for;\n\n      {\n        std::lock_guard<std::mutex> lock(replicasets_with_unreachable_nodes_mtx_);\n\n        if (!replicasets_with_unreachable_nodes_.empty())\n          break; // we're in \"emergency mode\", don't wait until TTL expires\n      }\n    }\n  }\n}\n\n/**\n * Connect to the metadata servers and refresh the metadata information in the\n * cache.\n */\nvoid MetadataCache::start() {\n  refresh_thread_.run(&run_thread, this);\n}\n\n/**\n * Stop the refresh thread.\n */\nvoid MetadataCache::stop() noexcept {\n  terminate_ = true;\n  refresh_thread_.join();\n}\n\n/**\n * Return a list of servers that are part of a replicaset.\n *\n * @param replicaset_name The replicaset that is being looked up.\n */\nstd::vector<metadata_cache::ManagedInstance> MetadataCache::replicaset_lookup(\n  const std::string &replicaset_name) {\n  std::lock_guard<std::mutex> lock(cache_refreshing_mutex_);\n  auto replicaset = replicaset_data_.find(replicaset_name);\n\n  if (replicaset == replicaset_data_.end()) {\n    log_warning(\"Replicaset '%s' not available\", replicaset_name.c_str());\n    return {};\n  }\n  return replicaset_data_[replicaset_name].members;\n}\n\nbool metadata_cache::ManagedInstance::operator==(const ManagedInstance& other) const {\n  return mysql_server_uuid == other.mysql_server_uuid &&\n         replicaset_name == other.replicaset_name &&\n         role == other.role &&\n         mode == other.mode &&\n         std::fabs(weight - other.weight) < 0.001 &&  // 0.001 = reasonable guess, change if needed\n         host == other.host &&\n         location == other.location &&\n         port == other.port &&\n         version_token == other.version_token &&\n         xport == other.xport;\n}\n\ninline bool compare_instance_lists(const MetaData::ReplicaSetsByName &map_a,\n                                   const MetaData::ReplicaSetsByName &map_b) {\n  if (map_a.size() != map_b.size())\n    return false;\n  auto ai = map_a.begin();\n  auto bi = map_b.begin();\n  for (; ai != map_a.end(); ++ai, ++bi) {\n    if ((ai->first != bi->first) || (ai->second.members.size() != bi->second.members.size()))\n      return false;\n    auto a = ai->second.members.begin();\n    auto b = bi->second.members.begin();\n    for (; a != ai->second.members.end(); ++a, ++b) {\n      if (!(*a == *b))\n        return false;\n    }\n  }\n  return true;\n}\n\nstatic const char *str_mode(metadata_cache::ServerMode mode) {\n  switch (mode) {\n    case metadata_cache::ServerMode::ReadWrite: return \"RW\";\n    case metadata_cache::ServerMode::ReadOnly: return \"RO\";\n    case metadata_cache::ServerMode::Unavailable: return \"n/a\";\n    default: return \"?\";\n  }\n}\n\n/**\n * Refresh the metadata information in the cache.\n */\nvoid MetadataCache::refresh() {\n  // fetch metadata\n  for (auto &metadata_server: metadata_servers_) {\n    if (!meta_data_->connect(metadata_server)) {\n      log_error(\"Failed to connect to metadata server %s\", metadata_server.mysql_server_uuid.c_str());\n      continue;\n     }\n     bool result = fetch_metadata_from_connected_instance();\n     if (result) return; // successfully updated metadata\n  }\n\n  // we failed to fetch metadata from any of the metadata servers\n  log_error(\"Failed connecting with any of the metadata servers\");\n  // clearing metadata\n  {\n    bool clearing;\n    {\n      std::lock_guard<std::mutex> lock(cache_refreshing_mutex_);\n      clearing = !replicaset_data_.empty();\n      if (clearing)\n        replicaset_data_.clear();\n    }\n    if (clearing) {\n      log_info(\"... cleared current routing table as a precaution\");\n      on_instances_changed(/*md_servers_reachable=*/false);\n    }\n  }\n}\n\nbool MetadataCache::fetch_metadata_from_connected_instance() {\n  try {\n    // Fetch the metadata and store it in a temporary variable.\n    std::map<std::string, metadata_cache::ManagedReplicaSet>\n      replicaset_data_temp = meta_data_->fetch_instances(cluster_name_);\n    bool changed = false;\n\n    {\n      // Ensure that the refresh does not result in an inconsistency during the\n      // lookup.\n      std::lock_guard<std::mutex> lock(cache_refreshing_mutex_);\n      if (!compare_instance_lists(replicaset_data_, replicaset_data_temp)) {\n        replicaset_data_ = replicaset_data_temp;\n        changed = true;\n      }\n    }\n\n    // we want to trigger those actions not only if the metadata has really changed\n    // but also when something external (like unsuccessful client connection)\n    // triggered the refresh so that we werified if this wasn't false alarm\n    // and turn it off if it was\n    if (changed) {\n      log_info(\"Potential changes detected in cluster '%s' after metadata refresh\",\n          cluster_name_.c_str());\n      // dump some informational/debugging information about the replicasets\n      if (replicaset_data_.empty())\n        log_error(\"Metadata for cluster '%s' is empty!\", cluster_name_.c_str());\n      else {\n        log_info(\"Metadata for cluster '%s' has %i replicasets:\",\n          cluster_name_.c_str(), (int)replicaset_data_.size());\n        for (auto &rs : replicaset_data_) {\n          log_info(\"'%s' (%i members, %s)\", rs.first.c_str(),\n                    (int)rs.second.members.size(),\n                    rs.second.single_primary_mode ? \"single-master\" : \"multi-master\");\n          for (auto &mi : rs.second.members) {\n            log_info(\"    %s:%i / %i - role=%s mode=%s\", mi.host.c_str(),\n                mi.port, mi.xport, mi.role.c_str(), str_mode(mi.mode));\n\n            if (mi.mode == metadata_cache::ServerMode::ReadWrite) {\n              // If we were running with a primary or secondary node gone\n              // missing before (in so-called \"emergency mode\"), we trust that\n              // the update fixed the problem. This is wrong behavior that\n              // should be fixed, see notes [05] and [06] in Notes section of\n              // Metadata Cache module in Doxygen.\n              std::lock_guard<std::mutex> lock(replicasets_with_unreachable_nodes_mtx_);\n              auto rs_with_unreachable_node = replicasets_with_unreachable_nodes_.find(rs.first);\n              if (rs_with_unreachable_node != replicasets_with_unreachable_nodes_.end()) {\n                // disable \"emergency mode\" for this replicaset\n                replicasets_with_unreachable_nodes_.erase(rs_with_unreachable_node);\n              }\n            }\n          }\n        }\n      }\n\n      on_instances_changed(/*md_servers_reachable=*/true);\n    }\n\n    /* Not sure about this, the metadata server could be stored elsewhere\n\n    // Fetch the set of servers in the primary replicaset. These servers\n    // store the metadata information.\n    std::vector<metadata_cache::ManagedInstance> metadata_servers_temp_ =\n      replicaset_lookup(cluster_name_);\n    // If the metadata replicaset contains servers, replace the current list\n    // of metadata servers with the new list.\n    if (!metadata_servers_temp_.empty()) {\n      std::lock_guard<std::mutex> lock(metadata_servers_mutex_);\n      metadata_servers_ = metadata_servers_temp_;\n    }*/\n  } catch (const std::runtime_error &exc) {\n    // fetching the meatadata failed\n    log_error(\"Failed fetching metadata: %s\", exc.what());\n    return false;\n  }\n\n  return true;\n}\n\nvoid MetadataCache::on_instances_changed(const bool md_servers_reachable) {\n  std::lock_guard<std::mutex> lock(replicaset_instances_change_callbacks_mtx_);\n\n  for (auto& replicaset_clb: listeners_) {\n    const std::string replicaset_name = replicaset_clb.first;\n    auto res = replicaset_lookup(replicaset_name);\n\n    for(auto each : listeners_[replicaset_name]) {\n      each->notify(res, md_servers_reachable);\n    }\n  }\n}\n\nvoid MetadataCache::mark_instance_reachability(const std::string &instance_id,\n                                metadata_cache::InstanceStatus status) {\n  // If the status is that the primary or secondary instance is physically\n  // unreachable, we enable \"emergency mode\" (temporarily increase the refresh\n  // rate to 1/s if currently lower) until the replicaset routing table\n  // reflects this reality (or at least that is the the intent; in practice\n  // this mechanism is buggy - see Metadata Cache module documentation in\n  // Doxygen, section \"Emergency mode\")\n\n  std::lock_guard<std::mutex> lock(cache_refreshing_mutex_);\n  // the replicaset that the given instance belongs to\n  metadata_cache::ManagedInstance *instance = nullptr;\n  metadata_cache::ManagedReplicaSet *replicaset = nullptr;\n  for (auto &rs : replicaset_data_) {\n    for (auto &inst : rs.second.members) {\n      if (inst.mysql_server_uuid == instance_id) {\n        instance = &inst;\n        replicaset = &rs.second;\n        break;\n      }\n    }\n    if (replicaset)\n      break;\n  }\n\n  // If the instance got marked as invalid we want to trigger metadata-cache update ASAP\n  // to aviod keeping try to route to that instance\n  if (replicaset) {\n    std::lock_guard<std::mutex> lplock(replicasets_with_unreachable_nodes_mtx_);\n    switch (status) {\n      case metadata_cache::InstanceStatus::Reachable:\n        break;\n      case metadata_cache::InstanceStatus::InvalidHost:\n        log_warning(\"Instance '%s:%i' [%s] of replicaset '%s' is invalid. Increasing metadata cache refresh frequency.\",\n                    instance->host.c_str(), instance->port, instance_id.c_str(),\n                    replicaset->name.c_str());\n        replicasets_with_unreachable_nodes_.insert(replicaset->name);\n        break;\n      case metadata_cache::InstanceStatus::Unreachable:\n        log_warning(\"Instance '%s:%i' [%s] of replicaset '%s' is unreachable. Increasing metadata cache refresh frequency.\",\n                    instance->host.c_str(), instance->port, instance_id.c_str(),\n                    replicaset->name.c_str());\n        replicasets_with_unreachable_nodes_.insert(replicaset->name);\n        break;\n      case metadata_cache::InstanceStatus::Unusable:\n        break;\n    }\n  }\n}\n\nbool MetadataCache::wait_primary_failover(const std::string &replicaset_name,\n                                          int timeout) {\n  log_debug(\"Waiting for failover to happen in '%s' for %is\",\n            replicaset_name.c_str(), timeout);\n  time_t stime = std::time(NULL);\n  while (std::time(NULL) - stime <= timeout) {\n    {\n      std::lock_guard<std::mutex> lock(cache_refreshing_mutex_);\n      if (replicasets_with_unreachable_nodes_.count(replicaset_name) == 0) {\n        return true;\n      }\n    }\n    std::this_thread::sleep_for(metadata_cache::kDefaultMetadataTTL);\n  }\n  return false;\n}\n\nvoid MetadataCache::add_listener(const std::string& replicaset_name, metadata_cache::ReplicasetStateListenerInterface* listener) {\n  std::lock_guard<std::mutex> lock(replicaset_instances_change_callbacks_mtx_);\n  listeners_[replicaset_name].insert(listener);\n}\n\nvoid MetadataCache::remove_listener(const std::string& replicaset_name, metadata_cache::ReplicasetStateListenerInterface* listener) {\n  std::lock_guard<std::mutex> lock(replicaset_instances_change_callbacks_mtx_);\n  listeners_[replicaset_name].erase(listener);\n}\n"
  },
  {
    "path": "src/metadata_cache/src/metadata_cache.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef METADATA_CACHE_METADATA_CACHE_INCLUDED\n#define METADATA_CACHE_METADATA_CACHE_INCLUDED\n\n#include \"mysqlrouter/metadata_cache.h\"\n#include \"metadata.h\"\n#include \"mysql_router_thread.h\"\n\n#include <algorithm>\n#include <chrono>\n#include <ctime>\n#include <memory>\n#include <mutex>\n#include <string>\n#include <thread>\n#include <set>\n#include <atomic>\n\n#include \"mysql/harness/logging/logging.h\"\n\nclass ClusterMetadata;\n\n/** @class MetadataCache\n *\n * The MetadataCache manages cached information fetched from the\n * MySQL Server.\n *\n */\nclass METADATA_API MetadataCache : public metadata_cache::ReplicasetStateNotifierInterface {\n\npublic:\n\n  /**\n   * Initialize a connection to the MySQL Metadata server.\n   *\n   * @param bootstrap_servers The servers that store the metadata.\n   * @param cluster_metadata metadata of the cluster\n   * @param ttl The TTL of the cached data.\n   * @param ssl_options SSL related options for connection\n   * @param cluster_name The name of the desired cluster in the metadata server\n   * @param thread_stack_size The maximum memory allocated for thread's stack\n   */\n  MetadataCache(const std::vector<mysql_harness::TCPAddress> &bootstrap_servers,\n                std::shared_ptr<MetaData> cluster_metadata,\n                std::chrono::milliseconds ttl, const mysqlrouter::SSLOptions &ssl_options,\n                const std::string &cluster_name,\n                size_t thread_stack_size = mysql_harness::kDefaultStackSizeInKiloBytes);\n\n  /** @brief Starts the Metadata Cache\n   *\n   * Starts the Metadata Cache and launch thread.\n   */\n  void start();\n\n  /** @brief Stops the Metadata Cache\n   *\n   * Stops the Metadata Cache and the launch thread.\n   */\n  void stop() noexcept;\n\n  /** @brief Returns list of managed servers in a replicaset\n   *\n   * Returns list of managed servers in a replicaset.\n   *\n   * @param replicaset_name The ID of the replicaset being looked up\n   * @return std::vector containing ManagedInstance objects\n   */\n  std::vector<metadata_cache::ManagedInstance> replicaset_lookup(\n    const std::string &replicaset_name);\n\n  /** @brief Update the status of the instance\n   *\n   * Called when an instance from a replicaset cannot be reached for one reason\n   * or another. When an instance becomes unreachable, an emergency mode is set\n   * (the rate of refresh of the metadata cache increases to once per second if\n   * currently lower) and lasts until disabled after a suitable change in the\n   * metadata cache is discovered.\n   *\n   * @param instance_id - the mysql_server_uuid that identifies the server instance\n   * @param status - the status of the instance\n   */\n  void mark_instance_reachability(const std::string &instance_id,\n                                  metadata_cache::InstanceStatus status);\n\n  /** @brief Wait until there's a primary member in the replicaset\n   *\n   * To be called when the master of a single-master replicaset is down and\n   * we want to wait until one becomes elected.\n   *\n   * @param replicaset_name name of the replicaset\n   * @param timeout - amount of time to wait for a failover, in seconds\n   * @return true if a primary member exists\n   */\n  bool wait_primary_failover(const std::string &replicaset_name, int timeout);\n\n  /** @brief refresh replicaset information */\n  void refresh_thread();\n\n  /** @brief run refresh thread */\n  static void* run_thread(void* context);\n\n\n  /**\n   * @brief Register observer that is notified when there is a change in the replicaset nodes setup/state\n   *        discovered.\n   *\n   * @param replicaset_name name of the replicaset\n   * @param listener Observer object that is notified when replicaset nodes state is changed.\n   */\n  void add_listener(const std::string& replicaset_name, metadata_cache::ReplicasetStateListenerInterface* listener) override;\n\n  /**\n   * @brief Unregister observer previously registered with add_listener()\n   *\n   * @param replicaset_name name of the replicaset\n   * @param listener Observer object that should be unregistered.\n   */\n  void remove_listener(const std::string& replicaset_name, metadata_cache::ReplicasetStateListenerInterface* listener) override;\n\nprivate:\n\n  /** @brief Refreshes the cache\n   *\n   */\n  void refresh();\n\n  /** @brief Fetches metadata from the metadata server we are currently connected to.\n   *\n   * @return true if the operation succeeded, false otherwise\n   */\n  bool fetch_metadata_from_connected_instance();\n\n  // Called each time the metadata has changed and we need to notify\n  // the subscribed observers\n  void on_instances_changed(const bool md_servers_reachable);\n\n  // Stores the list replicasets and their server instances.\n  // Keyed by replicaset name\n  std::map<std::string, metadata_cache::ManagedReplicaSet> replicaset_data_;\n\n  // The name of the cluster in the topology.\n  std::string cluster_name_;\n\n  // The list of servers that contain the metadata about the managed\n  // topology.\n  std::vector<metadata_cache::ManagedInstance> metadata_servers_;\n\n  // The time to live of the metadata cache.\n  std::chrono::milliseconds ttl_;\n\n  // SSL options for MySQL connections\n  mysqlrouter::SSLOptions ssl_options_;\n\n  // Stores the pointer to the transport layer implementation. The transport\n  // layer communicates with the servers storing the metadata and fetches the\n  // topology information.\n  std::shared_ptr<MetaData> meta_data_;\n\n  /** @brief refresh thread facade */\n  mysql_harness::MySQLRouterThread refresh_thread_;\n\n  // This mutex is used to ensure that a lookup of the metadata is consistent\n  // with the changes in the metadata due to a cache refresh.\n  std::mutex cache_refreshing_mutex_;\n\n  #if 0 // not used so far\n  // This mutex ensures that a refresh of the servers that contain the metadata\n  // is consistent with the use of the server list.\n  std::mutex metadata_servers_mutex_;\n  #endif\n\n  // Contains a set of replicaset names that have at least one unreachable\n  // (primary or secondary) node appearing in the routing table\n  std::set<std::string> replicasets_with_unreachable_nodes_;\n\n  std::mutex replicasets_with_unreachable_nodes_mtx_;\n\n  // Flag used to terminate the refresh thread.\n  std::atomic_bool terminate_;\n\n  // map of lists (per each replicaset name) of registered callbacks to be called\n  // on selected replicaset instances change event\n  std::mutex replicaset_instances_change_callbacks_mtx_;\n\n  std::map<std::string, std::set<metadata_cache::ReplicasetStateListenerInterface*>> listeners_;\n\n#ifdef FRIEND_TEST\n  FRIEND_TEST(FailoverTest, basics);\n  FRIEND_TEST(FailoverTest, primary_failover);\n  FRIEND_TEST(MetadataCacheTest2, basic_test);\n  FRIEND_TEST(MetadataCacheTest2, metadata_server_connection_failures);\n#endif\n};\n\n#endif // METADATA_CACHE_METADATA_CACHE_INCLUDED\n"
  },
  {
    "path": "src/metadata_cache/src/metadata_cache_plugin.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"dim.h\"\n#include \"metadata_cache.h\"\n#include \"mysql/harness/loader_config.h\"\n#include \"mysqlrouter/mysql_session.h\"  // kSslModePreferred\n#include \"plugin_config.h\"\n\n#include <string>\n#include <thread>\n#ifndef _WIN32\n#  include <termios.h>\n#  include <unistd.h>\n#endif\n\n#include \"keyring/keyring_manager.h\"\n#include \"mysqlrouter/utils.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysql/harness/config_parser.h\"\n#include \"tcp_address.h\"\n\nusing metadata_cache::LookupResult;\nusing mysql_harness::TCPAddress;\nusing std::string;\nIMPORT_LOG_FUNCTIONS()\n\nstatic const mysql_harness::AppInfo *g_app_info;\nstatic const string kSectionName = \"metadata_cache\";\nstatic const char *kKeyringAttributePassword = \"password\";\n\nstatic void init(mysql_harness::PluginFuncEnv* env) {\n  g_app_info = get_app_info(env);\n  // If a valid configuration object was found.\n  if (g_app_info && g_app_info->config) {\n    // if a valid metadata_cache section was found in the router\n    // configuration.\n    if (g_app_info->config->get(kSectionName).empty()) {\n      log_error(\"[metadata_cache] section is empty\");  // TODO remove after Loader starts logging\n      set_error(env, mysql_harness::kConfigInvalidArgument, \"[metadata_cache] section is empty\");\n    }\n  }\n}\n\nstatic std::string get_option(const mysql_harness::ConfigSection *section,\n                              const std::string &key,\n                              const std::string &def_value) {\n  if (section->has(key))\n    return section->get(key);\n  return def_value;\n}\n\nstatic mysqlrouter::SSLOptions make_ssl_options(\n    const mysql_harness::ConfigSection *section) {\n  mysqlrouter::SSLOptions options;\n\n  options.mode = get_option(section, \"ssl_mode\", mysqlrouter::MySQLSession::kSslModePreferred);\n  options.cipher = get_option(section, \"ssl_cipher\", \"\");\n  options.tls_version = get_option(section, \"tls_version\", \"\");\n  options.ca = get_option(section, \"ssl_ca\", \"\");\n  options.capath = get_option(section, \"ssl_capath\", \"\");\n  options.crl = get_option(section, \"ssl_crl\", \"\");\n  options.crlpath = get_option(section, \"ssl_crlpath\", \"\");\n\n  return options;\n}\n\n/**\n * Initialize the metadata cache for fetching the information from the\n * metadata servers.\n *\n * @param env plugin's environment\n */\nstatic void start(mysql_harness::PluginFuncEnv* env) {\n    const mysql_harness::ConfigSection* section = get_config_section(env);\n\n  // launch metadata cache\n  try {\n    MetadataCachePluginConfig config(section);\n    std::chrono::milliseconds ttl{config.ttl};\n    string metadata_cluster{config.metadata_cluster};\n\n    // Initialize the defaults.\n    metadata_cluster = metadata_cluster.empty()?\n      metadata_cache::kDefaultMetadataCluster : metadata_cluster;\n\n    std::string password;\n    try {\n      password = mysql_harness::get_keyring() ?\n        mysql_harness::get_keyring()->fetch(config.user,\n                                            kKeyringAttributePassword) : \"\";\n    }\n    catch (const std::out_of_range&) {\n      std::string msg = \"Could not find the password for user '\" + config.user + \"' in the keyring. \"\n              \"metadata_cache not initialized properly.\";\n      throw std::runtime_error(msg);\n    }\n\n    log_info(\"Starting Metadata Cache\");\n    // Initialize the metadata cache.\n    metadata_cache::MetadataCacheAPI::instance()->cache_init(config.bootstrap_addresses, config.user,\n                               password, ttl,\n                               make_ssl_options(section),\n                               metadata_cluster,\n                               config.connect_timeout,\n                               config.read_timeout,\n                               config.thread_stack_size);\n  } catch (const std::runtime_error &exc) { // metadata_cache::metadata_error inherits from runtime_error\n    log_error(\"%s\", exc.what());  // TODO remove after Loader starts logging\n    set_error(env, mysql_harness::kRuntimeError, \"%s\", exc.what());\n    clear_running(env);\n  } catch (const std::invalid_argument &exc) {\n    log_error(\"%s\", exc.what());  // TODO remove after Loader starts logging\n    set_error(env, mysql_harness::kConfigInvalidArgument, \"%s\", exc.what());\n    clear_running(env);\n  } catch (...) {\n    log_error(\"Unexpected exception\");  // TODO remove after Loader starts logging\n    set_error(env, mysql_harness::kUndefinedError, \"Unexpected exception\");\n    clear_running(env);\n  }\n\n  // keep it running until Harness tells us to shut down\n  wait_for_stop(env, 0);\n  metadata_cache::MetadataCacheAPI::instance()->cache_stop();\n}\n\nextern \"C\" {\n\nmysql_harness::Plugin METADATA_API harness_plugin_metadata_cache = {\n    mysql_harness::PLUGIN_ABI_VERSION,\n    mysql_harness::ARCHITECTURE_DESCRIPTOR,\n    \"Metadata Cache, managing information fetched from the Metadata Server\",\n    VERSION_NUMBER(0, 0, 1),\n    0, NULL,                                      // Requires\n    0, NULL,                                      // Conflicts\n    init,\n    NULL,\n    start,                                       // start\n    NULL                                         // stop\n};\n\n}\n"
  },
  {
    "path": "src/metadata_cache/src/metadata_factory.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"metadata_factory.h\"\n#include \"cluster_metadata.h\"\n\nstd::shared_ptr<MetaData> meta_data{nullptr};\n\n/**\n * Return an instance of NG metadata.\n *\n * @param user The user name used to authenticate to the metadata server.\n * @param password The password used to authenticate to the metadata server.\n * @param connect_timeout The time after which trying to connect to the\n *                        metadata server should timeout.\n * @param read_timeout The time after which read from metadata server should\n *                     timeout.\n * @param connection_attempts The number of times a connection to the metadata\n *                            server must be attempted, when a connection\n *                            attempt fails.\n * @param ttl The TTL of the cached data (in milliseconds).\n * @param ssl_options SSL related options to be used for connection\n */\nstd::shared_ptr<MetaData> get_instance(\n  const std::string &user,\n  const std::string &password,\n  int connect_timeout,\n  int read_timeout,\n  int connection_attempts,\n  std::chrono::milliseconds ttl,\n  const mysqlrouter::SSLOptions &ssl_options\n  ) {\n  meta_data.reset(new ClusterMetadata(user, password, connect_timeout,\n                                      read_timeout, connection_attempts, ttl,\n                                      ssl_options));\n  return meta_data;\n}\n"
  },
  {
    "path": "src/metadata_cache/src/metadata_factory.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef METADATA_CACHE_METADATA_FACTORY_INCLUDED\n#define METADATA_CACHE_METADATA_FACTORY_INCLUDED\n\n#include <memory>\n\n#include \"metadata.h\"\n#include \"tcp_address.h\"\n\n//This provides a factory method that returns a pluggable instance\n//to the underlying transport layer implementation. The transport\n//layer provides the means from which the metadata is\n//fetched.\n\nstd::shared_ptr<MetaData> get_instance(\n  const std::string &user, const std::string &password, int connect_timeout,\n  int read_timeout, int connection_attempts, std::chrono::milliseconds ttl,\n  const mysqlrouter::SSLOptions &ssl_options);\n\n#endif // METADATA_CACHE_METADATA_FACTORY_INCLUDED\n"
  },
  {
    "path": "src/metadata_cache/src/plugin_config.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysqlrouter/metadata_cache.h\"\n#include \"plugin_config.h\"\n#include \"mysqlrouter/uri.h\"\n#include \"mysqlrouter/utils.h\"\n\n#include <algorithm>\n#include <cerrno>\n#include <exception>\n#include <limits.h>\n#include <map>\n#include <vector>\n\n#include \"mysql/harness/logging/logging.h\"\n\nusing mysqlrouter::string_format;\nusing mysqlrouter::to_string;\nusing mysqlrouter::ms_to_seconds_string;\nusing std::invalid_argument;\n\nstd::string MetadataCachePluginConfig::get_default(const std::string &option) const {\n\n  static const std::map<std::string, std::string> defaults{\n      {\"address\",  metadata_cache::kDefaultMetadataAddress},\n      {\"ttl\", ms_to_seconds_string(metadata_cache::kDefaultMetadataTTL)},\n      {\"connect_timeout\", to_string(metadata_cache::kDefaultConnectTimeout)},\n      {\"read_timeout\", to_string(metadata_cache::kDefaultReadTimeout)},\n      {\"thread_stack_size\", to_string(mysql_harness::kDefaultStackSizeInKiloBytes)}\n  };\n  auto it = defaults.find(option);\n  if (it == defaults.end()) {\n    return std::string();\n  }\n  return it->second;\n}\n\nbool MetadataCachePluginConfig::is_required(const std::string &option) const {\n  const std::vector<std::string> required{\n      \"user\",\n  };\n\n  return std::find(required.begin(), required.end(), option) != required.end();\n}\n\nstd::vector<mysql_harness::TCPAddress>\nMetadataCachePluginConfig::get_bootstrap_servers(\n  const mysql_harness::ConfigSection *section, const std::string &option,\n  uint16_t default_port) {\n\n  std::string value = get_option_string(section, option);\n  std::stringstream ss(value);\n\n  std::pair<std::string, uint16_t> bind_info;\n\n  std::string address;\n  std::vector<mysql_harness::TCPAddress> address_vector;\n\n  // Fetch the string that contains the list of bootstrap servers separated\n  // by a delimiter (,).\n  while(getline(ss, address, ','))\n  {\n    try {\n      mysqlrouter::URI u(address);\n      bind_info.first = u.host;\n      bind_info.second = u.port;\n      if (bind_info.second == 0) {\n        bind_info.second = default_port;\n      }\n      address_vector.push_back(mysql_harness::TCPAddress(bind_info.first,\n                                                     bind_info.second));\n    } catch (const std::runtime_error &exc) {\n      throw invalid_argument(get_log_prefix(option) + \" is incorrect (\" +\n                             exc.what() + \")\");\n    }\n  }\n  return address_vector;\n}\n"
  },
  {
    "path": "src/metadata_cache/src/plugin_config.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef METADATA_CACHE_PLUGIN_CONFIG_INCLUDED\n#define METADATA_CACHE_PLUGIN_CONFIG_INCLUDED\n\n#include \"mysqlrouter/metadata_cache.h\"\n\n#include <chrono>\n#include <map>\n#include <string>\n#include <vector>\n\n#include \"mysql/harness/config_parser.h\"\n#include \"mysql/harness/plugin.h\"\n#include <mysqlrouter/plugin_config.h>\n#include \"tcp_address.h\"\n\n\nextern \"C\"\n{\n  extern mysql_harness::Plugin METADATA_API harness_plugin_metadata_cache ;\n}\n\nclass MetadataCachePluginConfig final : public mysqlrouter::BasePluginConfig {\npublic:\n  /** @brief Constructor\n   *\n   * @param section from configuration file provided as ConfigSection\n   */\n  MetadataCachePluginConfig(const mysql_harness::ConfigSection *section)\n      : BasePluginConfig(section),\n        bootstrap_addresses(get_bootstrap_servers(\n                              section, \"bootstrap_server_addresses\",\n                              metadata_cache::kDefaultMetadataPort)),\n        user(get_option_string(section, \"user\")),\n        ttl(get_option_milliseconds(section, \"ttl\", 0.0, 3600.0)),\n        metadata_cluster(get_option_string(section, \"metadata_cluster\")),\n        connect_timeout(get_uint_option<uint16_t>(section, \"connect_timeout\", 1)),\n        read_timeout(get_uint_option<uint16_t>(section, \"read_timeout\", 1)),\n        thread_stack_size(get_uint_option<uint32_t>(section, \"thread_stack_size\", 1, 65535))\n  { }\n\n  /**\n   * @param option name of the option\n   */\n  std::string get_default(const std::string &option) const override;\n  bool is_required(const std::string &option) const override;\n\n  /** @brief MySQL Metadata host to connect with */\n  const std::vector<mysql_harness::TCPAddress> bootstrap_addresses;\n  /** @brief User used for authenticating with MySQL Metadata */\n  const std::string user;\n  /** @brief TTL used for storing data in the cache */\n  const std::chrono::milliseconds ttl;\n  /** @brief Cluster in the metadata */\n  const std::string metadata_cluster;\n  /** @brief connect_timeout The time in seconds after which trying to connect\n   * to metadata server timeouts */\n  const unsigned int connect_timeout;\n  /** @brief read_timeout The time in seconds after which read from metadata\n   * server timeouts */\n  const unsigned int read_timeout;\n  /** @brief memory in kilobytes allocated for thread's stack */\n  const unsigned int thread_stack_size;\n\nprivate:\n  /** @brief Gets a list of metadata servers.\n   *\n   *\n   * Throws std::invalid_argument on errors.\n   *\n   * @param section Instance of ConfigSection\n   * @param option Option name in section\n   * @param default_port Use this port when none was provided\n   * @return std::vector<mysql_harness::TCPAddress>\n   */\n  std::vector<mysql_harness::TCPAddress> get_bootstrap_servers(\n    const mysql_harness::ConfigSection *section, const std::string &option,\n    uint16_t default_port);\n};\n\n#endif // METADATA_CACHE_PLUGIN_CONFIG_INCLUDED\n"
  },
  {
    "path": "src/metadata_cache/tests/CMakeLists.txt",
    "content": "# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n# The sources are re-built to test the metadata cache implementation with\n# a store layer that can supply the metadata without an actual connection\n# to the metadata node. In this case, mock_metadata.cc implements the metadata\n# interface without implementing a connection to the underlying metadata node.\n# The MockMetadata class does the functionality of the Metadata class.\n\nset(METADATA_CACHE_TESTS_HELPER\n  ${PROJECT_SOURCE_DIR}/src/metadata_cache/src/cluster_metadata.cc\n  ${PROJECT_SOURCE_DIR}/src/metadata_cache/src/metadata_cache.cc\n  ${PROJECT_SOURCE_DIR}/src/metadata_cache/src/cache_api.cc\n  ${PROJECT_SOURCE_DIR}/src/metadata_cache/src/plugin_config.cc\n  ${PROJECT_SOURCE_DIR}/src/metadata_cache/src/group_replication_metadata.cc\n  ${PROJECT_SOURCE_DIR}/src/metadata_cache/tests/helper/mock_metadata.cc\n  ${PROJECT_SOURCE_DIR}/src/metadata_cache/tests/helper/mock_metadata_factory.cc\n)\n\n\nset(include_dirs\n  ${PROJECT_SOURCE_DIR}/src/metadata_cache/include\n  ${PROJECT_SOURCE_DIR}/src/metadata_cache/src\n  ${PROJECT_SOURCE_DIR}/src/metadata_cache/tests/helper\n  ${PROJECT_SOURCE_DIR}/tests/helpers\n  )\n\n# We do not link to the metadata cache libraries since the sources are\n# already built as part of the test libraries.\nif(NOT WIN32)\n  add_library(metadata_cache_tests SHARED ${METADATA_CACHE_TESTS_HELPER})\n  target_link_libraries(metadata_cache_tests router_lib ${MySQL_LIBRARIES})\nelse()\n  add_library(metadata_cache_tests STATIC ${METADATA_CACHE_TESTS_HELPER})\n  target_link_libraries(metadata_cache_tests router_lib metadata_cache ${MySQL_LIBRARIES})\n  target_compile_definitions(metadata_cache_tests PRIVATE -Dmetadata_cache_DEFINE_STATIC=1)\n  target_compile_definitions(metadata_cache_tests PRIVATE -Dmetadata_cache_tests_DEFINE_STATIC=1)\nendif()\n\nset_target_properties(metadata_cache_tests PROPERTIES\n                      LIBRARY_OUTPUT_DIRECTORY\n                      ${MySQLRouter_BINARY_STAGE_DIR}/lib)\n\n\ntarget_include_directories(metadata_cache_tests PRIVATE ${include_dirs})\n\nadd_test_dir(${CMAKE_CURRENT_SOURCE_DIR}\n             MODULE \"metadata_cache\"\n             LIB_DEPENDS\n               metadata_cache_tests\n               test-helpers\n             INCLUDE_DIRS\n               ${PROJECT_SOURCE_DIR}/src/metadata_cache/include\n               ${PROJECT_SOURCE_DIR}/src/metadata_cache/src\n               ${PROJECT_SOURCE_DIR}/src/metadata_cache/tests/helper\n               ${PROJECT_SOURCE_DIR}/tests/helpers\n               ${PROJECT_SOURCE_DIR}/src/harness/shared/include\n)\n\nif(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL \"Clang\")\n  # silence undefined use of macro-vars in gtest.\n  # we can't use #pragma's due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431 to\n  # supress it locally.\n  set_target_properties(\n    test_metadata_cache_plugin_config\n    PROPERTIES\n    COMPILE_FLAGS \"-Wno-undef -Wno-conversion\")\nendif()\n\n\n\ntarget_compile_definitions(test_metadata_cache_cache_plugin PRIVATE -Dmetadata_cache_DEFINE_STATIC=1)\ntarget_compile_definitions(test_metadata_cache_metadata_cache PRIVATE -Dmetadata_cache_DEFINE_STATIC=1)\ntarget_compile_definitions(test_metadata_cache_cache_plugin PRIVATE -Dmetadata_cache_tests_DEFINE_STATIC=1)\ntarget_compile_definitions(test_metadata_cache_metadata_cache PRIVATE -Dmetadata_cache_tests_DEFINE_STATIC=1)\ntarget_compile_definitions(test_metadata_cache_metadata PRIVATE -Dmetadata_cache_DEFINE_STATIC=1)\ntarget_compile_definitions(test_metadata_cache_metadata PRIVATE -Dmetadata_cache_tests_DEFINE_STATIC=1)\ntarget_compile_definitions(test_metadata_cache_failover PRIVATE -Dmetadata_cache_DEFINE_STATIC=1)\ntarget_compile_definitions(test_metadata_cache_failover PRIVATE -Dmetadata_cache_tests_DEFINE_STATIC=1)\ntarget_compile_definitions(test_metadata_cache_plugin_config PRIVATE -Dmetadata_cache_DEFINE_STATIC=1)\ntarget_compile_definitions(test_metadata_cache_plugin_config PRIVATE -Dmetadata_cache_tests_DEFINE_STATIC=1)\n"
  },
  {
    "path": "src/metadata_cache/tests/helper/mock_metadata.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mock_metadata.h\"\n\n#include <map>\n#include <memory>\n#include <vector>\n\n#include \"mysqlrouter/metadata_cache.h\"\n\n\nusing namespace std;\n\n/** @brief Constructor\n * @param user The user name used to authenticate to the metadata server.\n * @param password The password used to authenticate to the metadata server.\n * @param connect_timeout The time after which trying to connect to the\n *                        metadata server should timeout.\n * @param read_timeout The time after which read from metadata server should\n *                     timeout.\n * @param connection_attempts The number of times a connection to metadata must\n *                            be attempted, when a connection attempt fails.\n * @param ttl The TTL of the cached data.\n * @param ssl_options SSL related options for connections\n */\nMockNG::MockNG(const std::string &user, const std::string &password,\n               int connect_timeout, int read_timeout,\n               int connection_attempts, std::chrono::milliseconds ttl,\n               const mysqlrouter::SSLOptions &ssl_options)\n  : ClusterMetadata(user, password, connect_timeout, read_timeout,\n                    connection_attempts, ttl, ssl_options) {\n  ms1.replicaset_name = \"replicaset-1\";\n  ms1.mysql_server_uuid = \"instance-1\";\n  ms1.location = \"us.wa.seattle\";\n  ms1.host = \"host-1\";\n  ms1.port = 3306;\n  ms1.xport = 33060;\n  ms1.mode = metadata_cache::ServerMode::ReadWrite;\n  ms1.role = \"master\";\n  ms1.weight = 1;\n  ms1.version_token = 0;\n\n  ms2.replicaset_name = \"replicaset-1\";\n  ms2.mysql_server_uuid = \"instance-2\";\n  ms2.location = \"us.ca.cupertino\";\n  ms2.host = \"host-2\";\n  ms2.port = 3306;\n  ms2.xport = 33060;\n  ms2.mode = metadata_cache::ServerMode::ReadOnly;\n  ms2.role = \"master\";\n  ms2.weight = 1;\n  ms2.version_token = 0;\n\n  ms3.replicaset_name = \"replicaset-1\";\n  ms3.mysql_server_uuid = \"instance-3\";\n  ms3.location = \"us.wi.madison\";\n  ms3.host = \"host-3\";\n  ms3.port = 3306;\n  ms3.xport = 33060;\n  ms3.mode = metadata_cache::ServerMode::ReadOnly;\n  ms3.role = \"scale-out\";\n  ms3.weight = 1;\n  ms3.version_token = 0;\n\n  ms4.replicaset_name = \"replicaset-2\";\n  ms4.mysql_server_uuid = \"instance-4\";\n  ms4.location = \"us.wi.madison\";\n  ms4.host = \"host-4\";\n  ms4.port = 3306;\n  ms4.xport = 33060;\n  ms4.mode = metadata_cache::ServerMode::ReadWrite;\n  ms4.role = \"master\";\n  ms4.weight = 1;\n  ms4.version_token = 0;\n\n  ms5.replicaset_name = \"replicaset-2\";\n  ms5.mysql_server_uuid = \"instance-5\";\n  ms5.location = \"us.wi.madison\";\n  ms5.host = \"host-5\";\n  ms5.port = 3306;\n  ms5.xport = 33060;\n  ms5.mode = metadata_cache::ServerMode::ReadOnly;\n  ms5.role = \"master\";\n  ms5.weight = 1;\n  ms5.version_token = 0;\n\n  ms6.replicaset_name = \"replicaset-2\";\n  ms6.mysql_server_uuid = \"instance-6\";\n  ms6.location = \"us.wi.madison\";\n  ms6.host = \"host-6\";\n  ms6.port = 3306;\n  ms6.xport = 33060;\n  ms6.mode = metadata_cache::ServerMode::ReadOnly;\n  ms6.role = \"scale-out\";\n  ms6.weight = 1;\n  ms6.version_token = 0;\n\n  ms7.replicaset_name = \"replicaset-3\";\n  ms7.mysql_server_uuid = \"instance-7\";\n  ms7.location = \"us.wi.madison\";\n  ms7.host = \"host-7\";\n  ms7.port = 3306;\n  ms7.xport = 33060;\n  ms7.mode = metadata_cache::ServerMode::ReadWrite;\n  ms7.role = \"master\";\n  ms7.weight = 1;\n  ms7.version_token = 0;\n\n  ms8.replicaset_name = \"replicaset-3\";\n  ms8.mysql_server_uuid = \"instance-8\";\n  ms8.location = \"us.wi.madison\";\n  ms8.host = \"host-8\";\n  ms8.port = 3306;\n  ms8.xport = 33060;\n  ms8.mode = metadata_cache::ServerMode::ReadWrite;\n  ms8.role = \"master\";\n  ms8.weight = 1;\n  ms8.version_token = 0;\n\n  ms9.replicaset_name = \"replicaset-3\";\n  ms9.mysql_server_uuid = \"instance-9\";\n  ms9.location = \"us.wi.madison\";\n  ms9.host = \"host-9\";\n  ms9.port = 3306;\n  ms9.xport = 33060;\n  ms9.mode = metadata_cache::ServerMode::ReadWrite;\n  ms9.role = \"scale-out\";\n  ms9.weight = 1;\n  ms9.version_token = 0;\n\n  replicaset_1_vector.push_back(ms1);\n  replicaset_1_vector.push_back(ms2);\n  replicaset_1_vector.push_back(ms3);\n\n  replicaset_2_vector.push_back(ms4);\n  replicaset_2_vector.push_back(ms5);\n  replicaset_2_vector.push_back(ms6);\n\n  replicaset_3_vector.push_back(ms7);\n  replicaset_3_vector.push_back(ms8);\n  replicaset_3_vector.push_back(ms9);\n\n\n  replicaset_map[\"replicaset-1\"].name = \"replicaset-1\";\n  replicaset_map[\"replicaset-1\"].single_primary_mode = true;\n  replicaset_map[\"replicaset-1\"].members = replicaset_1_vector;\n\n  replicaset_map[\"replicaset-2\"].name = \"replicaset-2\";\n  replicaset_map[\"replicaset-2\"].single_primary_mode = true;\n  replicaset_map[\"replicaset-2\"].members = replicaset_2_vector;\n\n  replicaset_map[\"replicaset-3\"].name = \"replicaset-3\";\n  replicaset_map[\"replicaset-3\"].single_primary_mode = false;\n  replicaset_map[\"replicaset-3\"].members = replicaset_3_vector;\n}\n\n/** @brief Destructor\n *\n * Disconnect and release the connection to the metadata node.\n */\nMockNG::~MockNG() {}\n\n/** @brief Returns relation between replicaset ID and list of servers\n *\n * Returns relation as a std::map between replicaset ID and list of managed servers.\n *\n * @return Map of replicaset ID, server list pairs.\n */\nClusterMetadata::ReplicaSetsByName MockNG::fetch_instances(const std::string &cluster_name) {\n  (void)cluster_name;\n  return replicaset_map;\n}\n\n/** @brief Mock connect method.\n *\n * Mock connect method, does nothing.\n *\n * @return a boolean to indicate if the connection was successful.\n */\nbool MockNG::connect(const metadata_cache::ManagedInstance& metadata_server) noexcept {\n  (void)metadata_server;\n  return true;\n}\n\n/** @brief Mock connect method.\n *\n * Mock connect method, does nothing.\n *\n * @return a boolean to indicate if the connection was successful.\n */\nvoid MockNG::disconnect() noexcept {\n}\n\n#if 0 // not used so far\n/**\n *\n * Returns a mock refresh interval.\n *\n * @return refresh interval of the Metadata cache.\n */\nunsigned int MockNG::fetch_ttl() {\n  return 5;\n}\n#endif\n"
  },
  {
    "path": "src/metadata_cache/tests/helper/mock_metadata.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n#ifndef MOCK_METADATA_INCLUDED\n#define MOCK_METADATA_INCLUDED\n\n#include <vector>\n\n#include \"cluster_metadata.h\"\n\n#include \"tcp_address.h\"\n\n#ifdef _WIN32\n#  ifdef metadata_cache_tests_DEFINE_STATIC\n#    define METADATA_TESTS_API\n#  else\n#    ifdef metadata_cache_tests_EXPORTS\n#      define METADATA_TESTS_API __declspec(dllexport)\n#    else\n#      define METADATA_TESTS_API __declspec(dllimport)\n#    endif\n#  endif\n#else\n#  define METADATA_TESTS_API\n#endif\n\n/** @class MockNG\n *\n * Used for simulating NG metadata for testing purposes.\n *\n */\n\nclass METADATA_TESTS_API MockNG : public ClusterMetadata {\npublic:\n  /**\n   * Objects representing the servers that are part of the topology.\n   */\n  metadata_cache::ManagedInstance ms1;\n  metadata_cache::ManagedInstance ms2;\n  metadata_cache::ManagedInstance ms3;\n  metadata_cache::ManagedInstance ms4;\n  metadata_cache::ManagedInstance ms5;\n  metadata_cache::ManagedInstance ms6;\n  metadata_cache::ManagedInstance ms7;\n  metadata_cache::ManagedInstance ms8;\n  metadata_cache::ManagedInstance ms9;\n\n  /**\n   * Server list for each replicaset in the topology. Each server object\n   * represents all relevant information about the server that is\n   * part of the topology.\n   */\n  std::vector<metadata_cache::ManagedInstance> replicaset_1_vector;\n  std::vector<metadata_cache::ManagedInstance> replicaset_2_vector;\n  std::vector<metadata_cache::ManagedInstance> replicaset_3_vector;\n\n  /**\n   * The information about the HA topology being managed.\n   */\n  ReplicaSetsByName replicaset_map;\n\n  /** @brief Constructor\n   * @param user The user name used to authenticate to the metadata server.\n   * @param password The password used to authenticate to the metadata server.\n   * @param connect_timeout The time after which trying to connect to the\n   *                        metadata server should timeout.\n   * @param read_timeout The time after which read from the metadata server\n   *                     should timeout.\n   * @param connection_attempts The number of times a connection to the metadata\n   *                            server must be attempted, when a connection\n   *                            attempt fails.\n   * @param ttl The time to live of the data in the cache.\n   */\n  MockNG(const std::string &user, const std::string &password,\n         int connect_timeout, int read_timeout,\n         int connection_attempts, std::chrono::milliseconds ttl,\n         const mysqlrouter::SSLOptions &ssl_options = mysqlrouter::SSLOptions());\n\n  /** @brief Destructor\n   *\n   * Disconnect and release the connection to the metadata node.\n   */\n  virtual ~MockNG();\n\n  /** @brief Mock connect method.\n   *\n   * Mock connect method, does nothing.\n   *\n   * @return a boolean to indicate if the connection was successful.\n   */\n  bool connect(const metadata_cache::ManagedInstance &metadata_server) noexcept override;\n\n  /** @brief Mock disconnect method.\n   *\n   * Mock method, does nothing.\n   *\n   */\n  void disconnect() noexcept override;\n\n  /**\n   *\n   * Returns relation as a std::map between replicaset ID and list of managed\n   * servers.\n   *\n   * @return Map of replicaset ID, server list pairs.\n   */\n  ReplicaSetsByName fetch_instances(const std::string &farm_name) override;\n\n\n\n#if 0 // not used so far\n  /**\n   *\n   * Returns a mock refresh interval.\n   *\n   * @return refresh interval of the Metadata cache.\n   */\n  unsigned int fetch_ttl() override;\n#endif\n};\n\n\n\n#endif //MOCK_METADATA_INCLUDED\n"
  },
  {
    "path": "src/metadata_cache/tests/helper/mock_metadata_factory.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <memory>\n\n#include \"mock_metadata.h\"\n\nstd::shared_ptr<MetaData> meta_data;\n\n/**\n * Create an instance of the mock metadata.\n *\n * @param user The user name used to authenticate to the metadata server.\n * @param password The password used to authenticate to the metadata server.\n * @param connect_timeout The time after which trying to connect to the\n *                        metadata server should timeout.\n * @param read_timeout The time after which read from the metadata server should timeout.\n * @param connection_attempts The number of times a connection to metadata must be\n *                            attempted, when a connection attempt fails.\n * @param ttl The TTL of the cached data.\n * @param ssl_options ssl options\n */\nstd::shared_ptr<MetaData> get_instance(\n  const std::string &user,\n  const std::string &password,\n  int connect_timeout,\n  int read_timeout,\n  int connection_attempts,\n  std::chrono::milliseconds ttl,\n  const mysqlrouter::SSLOptions &ssl_options) {\n  meta_data.reset(new MockNG(user, password, connect_timeout, read_timeout,\n                             connection_attempts, ttl, ssl_options));\n  return meta_data;\n}\n"
  },
  {
    "path": "src/metadata_cache/tests/test_cache_plugin.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/**\n * Tests the metadata cache plugin implementation.\n */\n\n#include \"mock_metadata.h\"\n#include \"mysqlrouter/metadata_cache.h\"\n#include \"tcp_address.h\"\n#include \"test/helpers.h\"\n\n#include <chrono>\n#include <vector>\n#include <thread>\n\n#include \"gmock/gmock.h\"\n\n/**\n * Constants that are used throughout the test cases.\n */\n\nconst std::string kDefaultTestReplicaset_1 = \"replicaset-1\";  // replicaset-1\nconst std::string kDefaultTestReplicaset_2 = \"replicaset-2\";  // replicaset-2\nconst std::string kDefaultTestReplicaset_3 = \"replicaset-3\";  // replicaset-3\n\nconst std::string kDefaultMetadataHost = \"127.0.0.1\";  // 127.0.0.1\nconst std::string kDefaultMetadataUser = \"admin\";  // admin\nconst std::string kDefaultMetadataPassword = \"\";  //\nconst int kDefaultMetadataPort = 32275; // 32275\nconst std::chrono::milliseconds kDefaultMetadataTTL = std::chrono::seconds(1);\nconst std::string kDefaultMetadataReplicaset = \"replicaset-1\";\n\nconst mysql_harness::TCPAddress bootstrap_server(kDefaultMetadataHost,\n                                               kDefaultMetadataPort);\nconst std::vector<mysql_harness::TCPAddress> bootstrap_server_vector =\n{bootstrap_server};\n\nusing std::thread;\nusing metadata_cache::ManagedInstance;\n\nclass MetadataCachePluginTest : public ::testing::Test {\npublic:\n  MockNG mf;\n\n  MetadataCachePluginTest() : mf(kDefaultMetadataUser,\n                                 kDefaultMetadataPassword,\n                                 1,\n                                 1,\n                                 1,\n                                 kDefaultMetadataTTL) {}\n\n  void SetUp() override {\n    std::vector<ManagedInstance> instance_vector_1;\n    metadata_cache::MetadataCacheAPI::instance()->cache_init(bootstrap_server_vector, kDefaultMetadataUser,\n                               kDefaultMetadataPassword, kDefaultMetadataTTL, mysqlrouter::SSLOptions(),\n                               kDefaultMetadataReplicaset, 1, 1);\n    int count = 1;\n    /**\n     * Wait until the plugin is completely initialized. Since\n     * the plugin initialization is started on a separate thread,\n     * we are required to wait until the cache is populated.\n     */\n    while (instance_vector_1.size() != 3) {\n      try {\n        instance_vector_1 = cache_api_->lookup_replicaset(\n          kDefaultTestReplicaset_1).instance_vector;\n      } catch (const std::runtime_error &exc) {\n        /**\n         * If the lookup fails after 5 attempts it points to an error\n         * in the cache initialization. This is an exception situation.\n         */\n        if (count++ >= 5)\n          throw exc;\n      }\n      /**\n       * Sleep before retrying the lookup.\n       */\n      std::this_thread::sleep_for(std::chrono::milliseconds(200));\n    }\n  }\n\n  void TearDown() override {\n    metadata_cache::MetadataCacheAPI::instance()->cache_stop();\n  }\n\n  metadata_cache::MetadataCacheAPIBase* cache_api_{metadata_cache::MetadataCacheAPI::instance()};\n};\n\n/**\n * Test that looking up an invalid replicaset returns a empty list.\n */\nTEST_F(MetadataCachePluginTest, InvalidReplicasetTest) {\n  EXPECT_TRUE(cache_api_->lookup_replicaset(\"InvalidReplicaset\").\n              instance_vector.empty());\n}\n\n/**\n * Test that the list of servers that are part of a replicaset is accurate.\n */\nTEST_F(MetadataCachePluginTest, ValidReplicasetTest_1) {\n  std::vector<ManagedInstance> instance_vector_1 = cache_api_->lookup_replicaset(\n    kDefaultTestReplicaset_1).instance_vector;\n\n  EXPECT_EQ(instance_vector_1[0], mf.ms1);\n  EXPECT_EQ(instance_vector_1[1], mf.ms2);\n  EXPECT_EQ(instance_vector_1[2], mf.ms3);\n}\n\nint main(int argc, char *argv[]) {\n  init_test_logger();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/metadata_cache/tests/test_failover.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/**\n * Test the metadata cache implementation.\n */\n\n#include \"gtest/gtest_prod.h\"\n#include \"metadata_cache.h\"\n#include \"dim.h\"\n#include \"cluster_metadata.h\"\n#include \"mysql_session_replayer.h\"\n#include \"tcp_address.h\"\n#include \"test/helpers.h\"\n\n#include \"gmock/gmock.h\"\n\nusing namespace metadata_cache;\n\nclass FailoverTest : public ::testing::Test {\npublic:\n  std::shared_ptr<MySQLSessionReplayer> session;\n  std::shared_ptr<ClusterMetadata> cmeta;\n  std::shared_ptr<MetadataCache> cache;\n\n  FailoverTest() {\n  }\n\n  // per-test setup\n  virtual void SetUp() override {\n    session.reset(new MySQLSessionReplayer(true));\n\n    // setup DI for MySQLSession\n    mysql_harness::DIM::instance().set_MySQLSession(\n      [this](){ return session.get(); }, // provide pointer to session\n      [](mysqlrouter::MySQLSession*){}   // and don't try deleting it!\n    );\n\n    cmeta.reset(new ClusterMetadata(\"admin\", \"admin\", 1, 1, 1, std::chrono::seconds(10), mysqlrouter::SSLOptions()));\n  }\n\n  void init_cache() {\n    cache.reset(new MetadataCache({mysql_harness::TCPAddress(\"localhost\", 32275)},\n                                  cmeta, std::chrono::seconds(10), mysqlrouter::SSLOptions(), \"cluster-1\"));\n  }\n\n\n  // make queries on metadata schema return a 3 members replicaset\n  void expect_metadata_1() {\n    MySQLSessionReplayer &m = *session;\n\n    m.expect_query(\"SELECT R.replicaset_name, I.mysql_server_uuid, I.role, I.weight, I.version_token, H.location, I.addresses->>'$.mysqlClassic', I.addresses->>'$.mysqlX' FROM mysql_innodb_cluster_metadata.clusters AS F JOIN mysql_innodb_cluster_metadata.replicasets AS R ON F.cluster_id = R.cluster_id JOIN mysql_innodb_cluster_metadata.instances AS I ON R.replicaset_id = I.replicaset_id JOIN mysql_innodb_cluster_metadata.hosts AS H ON I.host_id = H.host_id WHERE F.cluster_name = 'cluster-1';\");\n    m.then_return(8, {\n      // replicaset_name, mysql_server_uuid, role, weight, version_token, location, I.addresses->>'$.mysqlClassic', I.addresses->>'$.mysqlX'\n      {m.string_or_null(\"default\"), m.string_or_null(\"uuid-server1\"), m.string_or_null(\"HA\"), m.string_or_null(), m.string_or_null(), m.string_or_null(\"\"), m.string_or_null(\"localhost:3000\"), m.string_or_null(\"localhost:30000\")},\n      {m.string_or_null(\"default\"), m.string_or_null(\"uuid-server2\"), m.string_or_null(\"HA\"), m.string_or_null(), m.string_or_null(), m.string_or_null(\"\"), m.string_or_null(\"localhost:3001\"), m.string_or_null(\"localhost:30010\")},\n      {m.string_or_null(\"default\"), m.string_or_null(\"uuid-server3\"), m.string_or_null(\"HA\"), m.string_or_null(), m.string_or_null(), m.string_or_null(\"\"), m.string_or_null(\"localhost:3002\"), m.string_or_null(\"localhost:30020\")}\n    });\n  }\n\n  // make queries on PFS.replication_group_members return all members ONLINE\n  void expect_group_members_1() {\n    MySQLSessionReplayer &m = *session;\n\n    m.expect_query(\"show status like 'group_replication_primary_member'\");\n    m.then_return(2, {\n        // Variable_name, Value\n        {m.string_or_null(\"group_replication_primary_member\"), m.string_or_null(\"uuid-server1\")}\n      });\n\n    m.expect_query(\"SELECT member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode FROM performance_schema.replication_group_members WHERE channel_name = 'group_replication_applier'\");\n    m.then_return(5, {\n        // member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode\n        {m.string_or_null(\"uuid-server1\"), m.string_or_null(\"somehost\"), m.string_or_null(\"3000\"), m.string_or_null(\"ONLINE\"), m.string_or_null(\"1\")},\n        {m.string_or_null(\"uuid-server2\"), m.string_or_null(\"somehost\"), m.string_or_null(\"3001\"), m.string_or_null(\"ONLINE\"), m.string_or_null(\"1\")},\n        {m.string_or_null(\"uuid-server3\"), m.string_or_null(\"somehost\"), m.string_or_null(\"3002\"), m.string_or_null(\"ONLINE\"), m.string_or_null(\"1\")}\n      });\n  }\n\n  // make queries on PFS.replication_group_members return primary in the given state\n  void expect_group_members_1_primary_fail(const char *state,\n            const char *primary_override = \"uuid-server1\") {\n    MySQLSessionReplayer &m = *session;\n\n    m.expect_query(\"show status like 'group_replication_primary_member'\");\n    m.then_return(2, {\n        // Variable_name, Value\n        {m.string_or_null(\"group_replication_primary_member\"), m.string_or_null(primary_override)}\n      });\n\n    m.expect_query(\"SELECT member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode FROM performance_schema.replication_group_members WHERE channel_name = 'group_replication_applier'\");\n    if (!state) {\n      // primary not listed at all\n      m.then_return(5, {\n          // member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode\n          {m.string_or_null(\"uuid-server2\"), m.string_or_null(\"somehost\"), m.string_or_null(\"3001\"), m.string_or_null(\"ONLINE\"), m.string_or_null(\"1\")},\n          {m.string_or_null(\"uuid-server3\"), m.string_or_null(\"somehost\"), m.string_or_null(\"3002\"), m.string_or_null(\"ONLINE\"), m.string_or_null(\"1\")}\n        });\n    } else {\n      m.then_return(5, {\n          // member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode\n          {m.string_or_null(\"uuid-server1\"), m.string_or_null(\"somehost\"), m.string_or_null(\"3000\"), m.string_or_null(state), m.string_or_null(\"1\")},\n          {m.string_or_null(\"uuid-server2\"), m.string_or_null(\"somehost\"), m.string_or_null(\"3001\"), m.string_or_null(\"ONLINE\"), m.string_or_null(\"1\")},\n          {m.string_or_null(\"uuid-server3\"), m.string_or_null(\"somehost\"), m.string_or_null(\"3002\"), m.string_or_null(\"ONLINE\"), m.string_or_null(\"1\")}\n        });\n    }\n  }\n\n};\n\nclass DelayCheck {\npublic:\n  DelayCheck() {\n    start_time_ = time(NULL);\n  }\n\n  long time_elapsed() {\n    return time(NULL) - start_time_;\n  }\nprivate:\n  time_t start_time_;\n};\n\n\nTEST_F(FailoverTest, basics) {\n  expect_metadata_1();\n  expect_group_members_1();\n  init_cache();\n\n  // ensure that the instance list returned by a lookup is the expected one\n  // in the case everything's online and well\n  auto instances = cache->replicaset_lookup(\"default\");\n\n  ASSERT_EQ(3U, instances.size());\n  EXPECT_EQ(\"uuid-server1\", instances[0].mysql_server_uuid);\n  EXPECT_EQ(ServerMode::ReadWrite, instances[0].mode);\n  EXPECT_EQ(\"uuid-server2\", instances[1].mysql_server_uuid);\n  EXPECT_EQ(ServerMode::ReadOnly, instances[1].mode);\n  EXPECT_EQ(\"uuid-server3\", instances[2].mysql_server_uuid);\n  EXPECT_EQ(ServerMode::ReadOnly, instances[2].mode);\n\n  // this should succeed right away\n  DelayCheck t;\n  EXPECT_TRUE(cache->wait_primary_failover(\"default\", 2));\n  EXPECT_LE(t.time_elapsed(), 1);\n\n  // ensure no expected queries leftover\n  ASSERT_FALSE(session->print_expected());\n}\n\n\nTEST_F(FailoverTest, primary_failover) {\n  // normal operation\n  // ----------------\n\n  expect_metadata_1();\n  expect_group_members_1();\n  init_cache();\n\n  // ensure that the instance list returned by a lookup is the expected one\n  // in the case everything's online and well\n  auto instances = cache->replicaset_lookup(\"default\");\n\n  ASSERT_EQ(3U, instances.size());\n  EXPECT_EQ(\"uuid-server1\", instances[0].mysql_server_uuid);\n  EXPECT_EQ(ServerMode::ReadWrite, instances[0].mode);\n  EXPECT_EQ(\"uuid-server2\", instances[1].mysql_server_uuid);\n  EXPECT_EQ(ServerMode::ReadOnly, instances[1].mode);\n  EXPECT_EQ(\"uuid-server3\", instances[2].mysql_server_uuid);\n  EXPECT_EQ(ServerMode::ReadOnly, instances[2].mode);\n\n  // this should succeed right away\n  {\n    DelayCheck t;\n    EXPECT_TRUE(cache->wait_primary_failover(\"default\", 2));\n    EXPECT_LE(t.time_elapsed(), 1);\n  }\n\n  // ensure no expected queries leftover\n  ASSERT_FALSE(session->print_expected());\n\n  // now the primary goes down (but group view not updated yet by GR)\n  // ----------------------------------------------------------------\n  expect_metadata_1();\n  expect_group_members_1();\n  cache->refresh();\n\n  cache->mark_instance_reachability(\"uuid-server1\",\n                                    metadata_cache::InstanceStatus::Unreachable);\n  // this should fail with timeout b/c no primary yet\n  {\n    DelayCheck t;\n    EXPECT_FALSE(cache->wait_primary_failover(\"default\", 1));\n    EXPECT_GE(t.time_elapsed(), 1);\n  }\n\n  instances = cache->replicaset_lookup(\"default\");\n\n  ASSERT_EQ(3U, instances.size());\n  // primary is still visible, even tho it's dead.. that's because we pretend\n  // we're getting updates from an instance that hasn't noticed that yet\n  EXPECT_EQ(\"uuid-server1\", instances[0].mysql_server_uuid);\n  EXPECT_EQ(ServerMode::ReadWrite, instances[0].mode);\n  EXPECT_EQ(\"uuid-server2\", instances[1].mysql_server_uuid);\n  EXPECT_EQ(ServerMode::ReadOnly, instances[1].mode);\n  EXPECT_EQ(\"uuid-server3\", instances[2].mysql_server_uuid);\n  EXPECT_EQ(ServerMode::ReadOnly, instances[2].mode);\n\n  // GR notices the server went down, new primary picked\n  // ---------------------------------------------------\n  expect_metadata_1();\n  expect_group_members_1_primary_fail(nullptr, \"uuid-server2\");\n  cache->refresh();\n\n  // this should succeed\n  {\n    DelayCheck t;\n    EXPECT_TRUE(cache->wait_primary_failover(\"default\", 2));\n    EXPECT_LE(t.time_elapsed(), 1);\n  }\n\n  instances = cache->replicaset_lookup(\"default\");\n\n  ASSERT_EQ(3U, instances.size());\n  EXPECT_EQ(\"uuid-server1\", instances[0].mysql_server_uuid);\n  EXPECT_EQ(ServerMode::Unavailable, instances[0].mode);\n  EXPECT_EQ(\"uuid-server2\", instances[1].mysql_server_uuid);\n  EXPECT_EQ(ServerMode::ReadWrite, instances[1].mode);\n  EXPECT_EQ(\"uuid-server3\", instances[2].mysql_server_uuid);\n  EXPECT_EQ(ServerMode::ReadOnly, instances[2].mode);\n}\n\nint main(int argc, char *argv[]) {\n  init_test_logger();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/metadata_cache/tests/test_metadata.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n// must have these first, before #includes that rely on it\n#include <gtest/gtest_prod.h>\n\n#include \"cluster_metadata.h\"\n#include \"dim.h\"\n#include \"group_replication_metadata.h\"\n#include \"metadata_cache.h\"\n#include \"mysqlrouter/mysql_session.h\"\n#include \"test/helpers.h\"\n\n#include <memory>\n#include <map>\n#include <cmath>\n#include <algorithm>\n#include <set>\n\n//ignore GMock warnings\n#ifdef __clang__\n#  ifndef __has_warning\n#    define __has_warning(x) 0\n#  endif\n#  pragma clang diagnostic push\n#  if __has_warning(\"-Winconsistent-missing-override\")\n#    pragma clang diagnostic ignored \"-Winconsistent-missing-override\"\n#  endif\n#  if __has_warning(\"-Wsign-conversion\")\n#    pragma clang diagnostic ignored \"-Wsign-conversion\"\n#  endif\n#  include \"gmock/gmock.h\"\n#else\n#  include \"gmock/gmock.h\"\n#endif\n\n\nusing ::testing::_;\nusing ::testing::Assign;\nusing ::testing::Invoke;\nusing ::testing::InvokeWithoutArgs;\nusing ::testing::Mock;\nusing ::testing::Return;\nusing ::testing::StartsWith;\nusing ::testing::Throw;\n\nusing mysqlrouter::MySQLSession;\nusing metadata_cache::ManagedInstance;\nusing metadata_cache::ManagedReplicaSet;\nusing metadata_cache::ServerMode;\n\nusing State = GroupReplicationMember::State;\nusing Role  = GroupReplicationMember::Role;\nusing RS    = metadata_cache::ReplicasetStatus;\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// These tests focus on testing functionality implemented in metadata_cache.{h,cc}.\n//\n// Notes:\n// - throughout tests we use human-readable UUIDs (\"intance-1\", \"instance-2\", etc)\n//   for clarity, but actual code will deal with proper GUIDs (such as\n//   \"3acfe4ca-861d-11e6-9e56-08002741aeb6\"). At the time of writing, these IDs\n//   are treated like any other plain strings in production code (we call empty(),\n//   operator==(), etc, on them, but we never parse them), thus allowing us to use\n//   human-readable UUIDs in tests.\n// - the test groups are arranged in order that they run in production. This should\n//   help diagnose problems faster, as the stuff tested later depends on the stuff\n//   tested earlier.\n//\n// TODO: At the time of writing, tests don't test multiple replicaset scenarios.\n//       The code will probably work as is, but \"it doesn't work until it's proven\n//       by a unit test\".\n//\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * @file\n * @brief These tests verify Metadata Cache's _refresh process_ at its different\n *        stages.\n */\n\n\n// query #1 (occurrs first) - fetches expected (configured) topology from metadata server\nstd::string query_metadata = \"SELECT \"\n    \"R.replicaset_name, I.mysql_server_uuid, I.role, I.weight, I.version_token, H.location, \"\n    \"I.addresses->>'$.mysqlClassic', I.addresses->>'$.mysqlX' \"\n    \"FROM mysql_innodb_cluster_metadata.clusters AS F \"\n    \"JOIN mysql_innodb_cluster_metadata.replicasets AS R ON F.cluster_id = R.cluster_id \"\n    \"JOIN mysql_innodb_cluster_metadata.instances AS I ON R.replicaset_id = I.replicaset_id \"\n    \"JOIN mysql_innodb_cluster_metadata.hosts AS H ON I.host_id = H.host_id \"\n    \"WHERE F.cluster_name = \" /*'<cluster name>';\"*/;\n\n// query #2 (occurs second) - fetches primary member as seen by a particular node\nstd::string query_primary_member = \"show status like 'group_replication_primary_member'\";\n\n// query #3 (occurs last) - fetches current topology as seen by a particular node\nstd::string query_status = \"SELECT \"\n    \"member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode \"\n    \"FROM performance_schema.replication_group_members \"\n    \"WHERE channel_name = 'group_replication_applier'\";\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// mock classes\n//\n////////////////////////////////////////////////////////////////////////////////\n\nclass MockMySQLSession: public MySQLSession {\n public:\n  MOCK_METHOD2(query, void(const std::string& query, const RowProcessor& processor));\n  MOCK_METHOD2(flag_succeed, void(const std::string&, unsigned int));\n  MOCK_METHOD2(flag_fail, void(const std::string&, unsigned int));\n\n  void connect(const std::string& host,\n               unsigned int port,\n               const std::string&,\n               const std::string&,\n               const std::string&,\n               const std::string&,\n               int = kDefaultConnectTimeout,\n               int = kDefaultReadTimeout) override {\n    connect_cnt_++;\n\n    std::string host_port = host + ':' + std::to_string(port);\n    if (good_conns_.count(host_port))\n      connect_succeed(host, port);\n    else\n      connect_fail(host, port); // throws Error\n  }\n\n  void set_good_conns(std::set<std::string>&& conns) {\n    good_conns_ = std::move(conns);\n  }\n\n  void query_impl(const RowProcessor &processor,\n                  const std::vector<Row>& resultset,\n                  bool should_succeed = true) const {\n\n    // emulate real MySQLSession::query() error-handling logic\n    if (!connected_)\n      throw std::logic_error(\"Not connected\");\n    if (!should_succeed) {\n      std::string s = \"Error executing MySQL query: some error(42)\";\n      throw Error(s.c_str(), 42);\n    }\n\n    for(const Row& row : resultset) {\n      if (!processor(row))  // processor is allowed to throw\n        break;\n    }\n  }\n\n private:\n  void connect_succeed(const std::string& host, unsigned int port) {\n    flag_succeed(host, port);\n\n    // emulate real MySQLSession::connect() behaviour on success\n    connected_ = true;\n    connection_address_ = host + \":\" + std::to_string(port);\n  }\n\n  void connect_fail(const std::string& host, unsigned int port) {\n    flag_fail(host, port);\n\n    // emulate real MySQLSession::connect() behaviour on failure\n    std::string s = \"Error connecting to MySQL server at \";\n    s += host + \":\" + std::to_string(port) + \": some error(42)\";\n    throw Error(s.c_str(), 42);\n  }\n\n  int connect_cnt_ = 0;\n  std::set<std::string> good_conns_;\n};\n\nclass MockMySQLSessionFactory {\n  const int kInstances = 4;\n\n public:\n  MockMySQLSessionFactory()\n  {\n    // we pre-allocate instances and then return those in create() and get()\n    for (int i = 0; i < kInstances; i++) {\n      sessions_.emplace_back(new MockMySQLSession);\n    }\n  }\n\n  std::shared_ptr<MySQLSession> create() const {\n    return sessions_.at(next_++);\n  }\n\n  MockMySQLSession& get(unsigned i) const {\n    return *sessions_.at(i);\n  }\n\n  int create_cnt() const {\n    // without cast, we'd need to type 'u' everywhere, like so:\n    // EXPECT_EQ(1u, factory.create_cnt());\n    return static_cast<int>(next_);\n  }\n\n private:\n  // can't use vector<MockMySQLSession>, because MockMySQLSession is not copyable\n  // due to GMock (produces weird linker errors)\n  std::vector<std::shared_ptr<MockMySQLSession>> sessions_;\n\n  mutable unsigned next_ = 0;\n};\n\nstatic bool cmp_mi_FIFMS(const ManagedInstance& lhs, const ManagedInstance& rhs) {\n\n  // This function compares fields set by Metadata::fetch_instances_from_metadata_server().\n  // Ignored fields (they're not being set at the time of writing):\n  //   ServerMode mode;\n\n  return lhs.replicaset_name == rhs.replicaset_name\n      && lhs.mysql_server_uuid == rhs.mysql_server_uuid\n      && lhs.role == rhs.role\n      && std::fabs(lhs.weight - rhs.weight) < 0.001\n      && lhs.version_token == rhs.version_token\n      && lhs.location == rhs.location\n      && lhs.host == rhs.host\n      && lhs.port == rhs.port\n      && lhs.xport == rhs.xport;\n}\n\nstatic bool cmp_mi_FI(const ManagedInstance& lhs, const ManagedInstance& rhs) {\n\n  // This function compares fields set by Metadata::fetch_instances().\n  // Ignored fields (they're not being set at the time of writing):\n  //   std::string role;\n  //   float weight;\n  //   unsigned int version_token;\n  //   std::string location;\n\n  return lhs.replicaset_name == rhs.replicaset_name\n      && lhs.mysql_server_uuid == rhs.mysql_server_uuid\n      && lhs.mode == rhs.mode\n      && lhs.host == rhs.host\n      && lhs.port == rhs.port\n      && lhs.xport == rhs.xport;\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// test class\n//\n////////////////////////////////////////////////////////////////////////////////\n\nclass MetadataTest : public ::testing::Test {\n\n public:\n\n  void SetUp() override {\n    // redirect cout > nothing (following tests print to cout)\n    original_cout = std::cout.rdbuf();\n    std::cout.rdbuf(nullptr);\n\n    // setup DI for MySQLSession\n    mysql_harness::DIM::instance().set_MySQLSession(\n      [this](){ return session_factory.create().get(); }, // provide raw pointer\n      [](MySQLSession*){}                                 // and try don't deleting it!\n    );\n  }\n\n  void TearDown() override {\n    // undo cout redirect\n    std::cout.rdbuf(original_cout);\n  }\n\n  std::streambuf* original_cout;\n\n  //---- helper functions --------------------------------------------------------\n\n  void connect_to_first_metadata_server() {\n\n    std::vector<ManagedInstance> metadata_servers {\n      {\"replicaset-1\", \"instance-1\", \"\", ServerMode::ReadWrite, 0, 0, \"\", \"localhost\", 3310, 33100},\n    };\n    session_factory.get(0).set_good_conns({\"127.0.0.1:3310\", \"127.0.0.1:3320\", \"127.0.0.1:3330\"});\n\n    EXPECT_CALL(session_factory.get(0), flag_succeed(_, 3310)).Times(1);\n    EXPECT_TRUE(metadata.connect(metadata_servers[0]));\n  }\n\n  void enable_connection(unsigned session, unsigned port) {\n    session_factory.get(session).set_good_conns({std::string(\"127.0.0.1:\") + std::to_string(port)});  // \\_ new connection\n    EXPECT_CALL(session_factory.get(session), flag_succeed(_, port)).Times(1);                        // /  should succeed\n  }\n\n  //----- mock SQL queries -------------------------------------------------------\n\n  std::function<void(const std::string&, const MySQLSession::RowProcessor& processor)> query_primary_member_ok(unsigned session) {\n    return [this, session](const std::string&, const MySQLSession::RowProcessor& processor) {\n      session_factory.get(session).query_impl(processor, {{\"group_replication_primary_member\", \"instance-1\"}}); // typical response\n    };\n  }\n\n  std::function<void(const std::string&, const MySQLSession::RowProcessor& processor)> query_primary_member_empty(unsigned session) {\n    return [this, session](const std::string&, const MySQLSession::RowProcessor& processor) {\n      session_factory.get(session).query_impl(processor, {{\"group_replication_primary_member\", \"\"}}); // empty response\n    };\n  }\n\n  std::function<void(const std::string&, const MySQLSession::RowProcessor& processor)> query_primary_member_fail(unsigned session) {\n    return [this, session](const std::string&, const MySQLSession::RowProcessor& processor) {\n      session_factory.get(session).query_impl(processor, {}, false); // false = induce fail query\n    };\n  }\n\n  std::function<void(const std::string&, const MySQLSession::RowProcessor& processor)> query_status_fail(unsigned session) {\n    return [this, session](const std::string&, const MySQLSession::RowProcessor& processor) {\n      session_factory.get(session).query_impl(processor, {}, false); // false = induce fail query\n    };\n  }\n\n  std::function<void(const std::string&, const MySQLSession::RowProcessor& processor)> query_status_ok(unsigned session) {\n    return [this, session](const std::string&, const MySQLSession::RowProcessor& processor) {\n      session_factory.get(session).query_impl(processor, {\n        {\"instance-1\", \"ubuntu\", \"3310\", \"ONLINE\", \"1\"},  // \\.\n        {\"instance-2\", \"ubuntu\", \"3320\", \"ONLINE\", \"1\"},  //  > typical response\n        {\"instance-3\", \"ubuntu\", \"3330\", \"ONLINE\", \"1\"},  // /\n      });\n    };\n  }\n\n\n\n private: // toggling between public and private because we require these vars in this particular order\n  std::unique_ptr<MockMySQLSessionFactory> up_session_factory_{new MockMySQLSessionFactory()};\n public:\n  MockMySQLSessionFactory& session_factory = *up_session_factory_; // hack: we can do this because unique_ptr will outlive our tests\n  ClusterMetadata metadata{\"user\", \"pass\", 0, 0, 0, std::chrono::milliseconds(0), mysqlrouter::SSLOptions()};\n\n  // set instances that would be returned by successful metadata.fetch_instances_from_metadata_server()\n  // for a healthy 3-node setup. Only some tests need this variable.\n\n  const ManagedReplicaSet typical_replicaset {\n    \"replicaset-1\", {\n      // will be set ----------------------vvvvvvvvvvvvvvvvvvvvvvv  v--v--vv--- ignored at the time of writing\n      {\"replicaset-1\", \"instance-1\", \"HA\", ServerMode::Unavailable, 0, 0, \"\", \"localhost\", 3310, 33100},\n      {\"replicaset-1\", \"instance-2\", \"HA\", ServerMode::Unavailable, 0, 0, \"\", \"localhost\", 3320, 33200},\n      {\"replicaset-1\", \"instance-3\", \"HA\", ServerMode::Unavailable, 0, 0, \"\", \"localhost\", 3330, 33300},\n      // ignored at time of writing -^^^^--------------------------------------------------------^^^^^\n      // TODO: ok to ignore xport?\n    },\n    false\n  };\n};\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// test ClusterMetadata::connect()\n//\n////////////////////////////////////////////////////////////////////////////////\n\nTEST_F(MetadataTest, ConnectToMetadataServer_Succeed) {\n\n  ManagedInstance metadata_server{\"replicaset-1\", \"instance-1\", \"\", ServerMode::ReadWrite, 0, 0, \"\", \"localhost\", 3310, 33100};\n  session_factory.get(0).set_good_conns({\"127.0.0.1:3310\"});\n\n  // should connect successfully\n  EXPECT_CALL(session_factory.get(0), flag_succeed(_, 3310)).Times(1);\n  EXPECT_TRUE(metadata.connect(metadata_server));\n}\n\nTEST_F(MetadataTest, ConnectToMetadataServer_Failed) {\n\n  ManagedInstance metadata_server{\"replicaset-1\", \"instance-1\", \"\", ServerMode::ReadWrite, 0, 0, \"\", \"localhost\", 3310, 33100};\n\n  // connetion attempt should fail\n  EXPECT_CALL(session_factory.get(0), flag_fail(_, 3310)).Times(1);\n  EXPECT_FALSE(metadata.connect(metadata_server));\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// test ClusterMetadata::fetch_instances_from_metadata_server()\n// [QUERY #1: query_metadata]\n//\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * @test\n * Verify that `ClusterMetadata::fetch_instances_from_metadata_server()` returns\n * correct information that it obtains from MD server via SQL query. Tested\n * result sets:\n *\n *   1. empty\n *   2. many nodes in many replicasets\n *   3. SQL query fails\n */\nTEST_F(MetadataTest, FetchInstancesFromMetadataServer) {\n\n  connect_to_first_metadata_server();\n\n  // test automatic conversions\n  {\n    auto resultset_metadata = [this](const std::string&, const MySQLSession::RowProcessor& processor) {\n      session_factory.get(0).query_impl(processor, {\n        {\"replicaset-1\", \"instance-1\", \"HA\",               \"0.2\", \"0\", \"location1\", \"localhost:3310\", \"localhost:33100\"},\n        {\"replicaset-1\", \"instance-2\", \"arbitrary_string\", \"1.5\", \"1\", \"s.o_loc\",   \"localhost:3320\", NULL},\n        {\"replicaset-1\", \"instance-3\", \"\",                 \"0.0\", \"99\", \"\",         \"localhost\", NULL},\n        {\"replicaset-1\", \"instance-4\", \"\",                  NULL, NULL, \"\",         NULL, NULL},\n      });\n    };\n    EXPECT_CALL(session_factory.get(0), query(StartsWith(query_metadata), _)).Times(1).WillOnce(Invoke(resultset_metadata));\n\n    ClusterMetadata::ReplicaSetsByName rs = metadata.fetch_instances_from_metadata_server(\"replicaset-1\");\n\n    EXPECT_EQ(1u, rs.size());\n    EXPECT_EQ(4u, rs.at(\"replicaset-1\").members.size()); // not set/checked -------------------vvvvvvvvvvvvvvvvvvvvvvv\n    EXPECT_TRUE(cmp_mi_FIFMS(ManagedInstance{\"replicaset-1\", \"instance-1\", \"HA\",               ServerMode::Unavailable, 0.2f, 0, \"location1\", \"localhost\", 3310, 33100}, rs.at(\"replicaset-1\").members.at(0)));\n    EXPECT_TRUE(cmp_mi_FIFMS(ManagedInstance{\"replicaset-1\", \"instance-2\", \"arbitrary_string\", ServerMode::Unavailable, 1.5f, 1, \"s.o_loc\",   \"localhost\", 3320, 33200}, rs.at(\"replicaset-1\").members.at(1)));\n    EXPECT_TRUE(cmp_mi_FIFMS(ManagedInstance{\"replicaset-1\", \"instance-3\", \"\",                 ServerMode::Unavailable, 0.0f, 99, \"\",         \"localhost\", 3306, 33060}, rs.at(\"replicaset-1\").members.at(2)));\n    EXPECT_TRUE(cmp_mi_FIFMS(ManagedInstance{\"replicaset-1\", \"instance-4\", \"\",                 ServerMode::Unavailable, 0.0f, 0, \"\",          \"\", 3306, 33060}, rs.at(\"replicaset-1\").members.at(3)));\n    // TODO is this really right behavior? ---------------------------------------------------------------------------------------------------^^\n  }\n\n  // empty result\n  {\n    auto resultset_metadata = [this](const std::string&, const MySQLSession::RowProcessor& processor) {\n      session_factory.get(0).query_impl(processor, {\n      });\n    };\n    EXPECT_CALL(session_factory.get(0), query(StartsWith(query_metadata), _)).Times(1).WillOnce(Invoke(resultset_metadata));\n\n    ClusterMetadata::ReplicaSetsByName rs = metadata.fetch_instances_from_metadata_server(\"replicaset-1\");\n\n    EXPECT_EQ(0u, rs.size());\n  }\n\n  // multiple replicasets\n  {\n    auto resultset_metadata = [this](const std::string&, const MySQLSession::RowProcessor& processor) {\n      session_factory.get(0).query_impl(processor, {\n        {\"replicaset-2\", \"instance-4\", \"HA\", NULL, NULL, \"\", \"localhost2:3333\", NULL},\n        {\"replicaset-1\", \"instance-1\", \"HA\", NULL, NULL, \"\", \"localhost1:1111\", NULL},\n        {\"replicaset-1\", \"instance-2\", \"HA\", NULL, NULL, \"\", \"localhost1:2222\", NULL},\n        {\"replicaset-1\", \"instance-3\", \"HA\", NULL, NULL, \"\", \"localhost1:3333\", NULL},\n        {\"replicaset-3\", \"instance-5\", \"HA\", NULL, NULL, \"\", \"localhost3:3333\", NULL},\n        {\"replicaset-3\", \"instance-6\", \"HA\", NULL, NULL, \"\", \"localhost3:3333\", NULL},\n      });\n    };\n    EXPECT_CALL(session_factory.get(0), query(StartsWith(query_metadata), _)).Times(1).WillOnce(Invoke(resultset_metadata));\n\n    ClusterMetadata::ReplicaSetsByName rs = metadata.fetch_instances_from_metadata_server(\"replicaset-1\");\n\n    EXPECT_EQ(3u, rs.size());\n    EXPECT_EQ(3u, rs.at(\"replicaset-1\").members.size());\n    EXPECT_TRUE(cmp_mi_FIFMS(ManagedInstance{\"replicaset-1\", \"instance-1\", \"HA\", ServerMode::Unavailable, 0, 0, \"\", \"localhost1\", 1111, 11110}, rs.at(\"replicaset-1\").members.at(0)));\n    EXPECT_TRUE(cmp_mi_FIFMS(ManagedInstance{\"replicaset-1\", \"instance-2\", \"HA\", ServerMode::Unavailable, 0, 0, \"\", \"localhost1\", 2222, 22220}, rs.at(\"replicaset-1\").members.at(1)));\n    EXPECT_TRUE(cmp_mi_FIFMS(ManagedInstance{\"replicaset-1\", \"instance-3\", \"HA\", ServerMode::Unavailable, 0, 0, \"\", \"localhost1\", 3333, 33330}, rs.at(\"replicaset-1\").members.at(2)));\n    EXPECT_EQ(1u, rs.at(\"replicaset-2\").members.size());\n    EXPECT_TRUE(cmp_mi_FIFMS(ManagedInstance{\"replicaset-2\", \"instance-4\", \"HA\", ServerMode::Unavailable, 0, 0, \"\", \"localhost2\", 3333, 33330}, rs.at(\"replicaset-2\").members.at(0)));\n    EXPECT_EQ(2u, rs.at(\"replicaset-3\").members.size());\n    EXPECT_TRUE(cmp_mi_FIFMS(ManagedInstance{\"replicaset-3\", \"instance-5\", \"HA\", ServerMode::Unavailable, 0, 0, \"\", \"localhost3\", 3333, 33330}, rs.at(\"replicaset-3\").members.at(0)));\n    EXPECT_TRUE(cmp_mi_FIFMS(ManagedInstance{\"replicaset-3\", \"instance-6\", \"HA\", ServerMode::Unavailable, 0, 0, \"\", \"localhost3\", 3333, 33330}, rs.at(\"replicaset-3\").members.at(1)));\n  }\n\n  // query fails\n  {\n    auto resultset_metadata = [this](const std::string&, const MySQLSession::RowProcessor& processor) {\n      session_factory.get(0).query_impl(processor, {}, false);\n    };\n    EXPECT_CALL(session_factory.get(0), query(StartsWith(query_metadata), _)).Times(1).WillOnce(Invoke(resultset_metadata));\n\n    // exception thrown by MySQLSession::query() should get repackaged in metadata_cache::metadata_error\n    ClusterMetadata::ReplicaSetsByName rs;\n    try {\n      rs = metadata.fetch_instances_from_metadata_server(\"replicaset-1\");\n      FAIL() << \"Expected metadata_cache::metadata_error to be thrown\";\n    } catch (const metadata_cache::metadata_error& e) {\n      EXPECT_STREQ(\"Error executing MySQL query: some error(42)\", e.what());\n      EXPECT_EQ(0u, rs.size());\n    } catch (...) {\n      FAIL() << \"Expected metadata_cache::metadata_error to be thrown\";\n    }\n  }\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// test ClusterMetadata::check_replicaset_status()\n//\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * @test\n * Verify that `ClusterMetadata::check_replicaset_status()` returns proper\n * status for each node (instance) that it received from MD server, and\n * calculates proper replicaset availability.\n *\n * The tested function has two inputs: MD (cluster topology from MD server) and\n * GR (health status from GR tables). All tested scenarios in this test keep the\n * MD constant (3 nodes) and while varying the GR.\n */\nTEST_F(MetadataTest, CheckReplicasetStatus_3NodeSetup) {\n\n  std::vector<ManagedInstance> servers_in_metadata {\n    // ServerMode doesn't matter ------vvvvvvvvvvv\n    {\"\", \"instance-1\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n    {\"\", \"instance-2\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n    {\"\", \"instance-3\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n  };\n\n  // typical\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-1\", {\"\", \"\", 0, State::Online, Role::Primary  } },\n      { \"instance-2\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n      { \"instance-3\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::AvailableWritable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::ReadWrite,   servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(2).mode);\n  }\n\n  // less typical\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-1\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n      { \"instance-2\", {\"\", \"\", 0, State::Online, Role::Primary  } },\n      { \"instance-3\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::AvailableWritable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::ReadWrite,   servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(2).mode);\n\n    auto r = {ServerMode::ReadOnly, ServerMode::ReadWrite, ServerMode::ReadOnly};\n    EXPECT_TRUE(std::equal(r.begin(), r.end(), servers_in_metadata.begin(), [](ServerMode mode, ManagedInstance mi) {\n      return mode == mi.mode;\n    }));\n  }\n\n  // less typical\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-1\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n      { \"instance-2\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n      { \"instance-3\", {\"\", \"\", 0, State::Online, Role::Primary  } },\n    };\n    EXPECT_EQ(RS::AvailableWritable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::ReadWrite,   servers_in_metadata.at(2).mode);\n\n    auto r = {ServerMode::ReadOnly, ServerMode::ReadOnly, ServerMode::ReadWrite};\n    EXPECT_TRUE(std::equal(r.begin(), r.end(), servers_in_metadata.begin(), [](ServerMode mode, ManagedInstance mi) {\n      return mode == mi.mode;\n    }));\n  }\n\n  // no primary\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-1\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n      { \"instance-2\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n      { \"instance-3\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::AvailableReadOnly, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(2).mode);\n\n    auto r = {ServerMode::ReadOnly, ServerMode::ReadOnly, ServerMode::ReadOnly};\n    EXPECT_TRUE(std::equal(r.begin(), r.end(), servers_in_metadata.begin(), [](ServerMode mode, ManagedInstance mi) {\n      return mode == mi.mode;\n    }));\n  }\n\n  // multi-primary (currently unsupported, but treat as single-primary)\n  // TODO: this behaviour should change, probably turn all Primary -> Unavailable but leave Secondary alone\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-1\", {\"\", \"\", 0, State::Online, Role::Primary} },\n      { \"instance-2\", {\"\", \"\", 0, State::Online, Role::Primary} },\n      { \"instance-3\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n    };\n    #ifdef NDEBUG // guardian assert() should fail in Debug\n    EXPECT_EQ(RS::AvailableWritable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::ReadWrite,   servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::ReadWrite,   servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(2).mode);\n\n    auto r = {ServerMode::ReadWrite, ServerMode::ReadWrite, ServerMode::ReadOnly};\n    EXPECT_TRUE(std::equal(r.begin(), r.end(), servers_in_metadata.begin(), [](ServerMode mode, ManagedInstance mi) {\n      return mode == mi.mode;\n    }));\n    #endif\n  }\n\n  // 1 node missing\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-1\", {\"\", \"\", 0, State::Online, Role::Primary  } },\n      { \"instance-3\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::AvailableWritable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::ReadWrite,   servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(2).mode);\n    // should log warning \"Member <host>:<port> (instance-2) defined in metadata not found in actual replicaset\"\n\n  }\n\n  // 1 node missing, no primary\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-2\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n      { \"instance-3\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::AvailableReadOnly, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(2).mode);\n    // should log warning \"Member <host>:<port> (instance-1) defined in metadata not found in actual replicaset\"\n  }\n\n  // 2 nodes missing\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-1\", {\"\", \"\", 0, State::Online, Role::Primary  } },\n    };\n    EXPECT_EQ(RS::AvailableWritable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::ReadWrite,   servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(2).mode);\n    // should log warning \"Member <host>:<port> (instance-2) defined in metadata not found in actual replicaset\"\n    // should log warning \"Member <host>:<port> (instance-3) defined in metadata not found in actual replicaset\"\n  }\n\n  // 2 nodes missing, no primary\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-3\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::AvailableReadOnly, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(2).mode);\n    // should log warning \"Member <host>:<port> (instance-1) defined in metadata not found in actual replicaset\"\n    // should log warning \"Member <host>:<port> (instance-2) defined in metadata not found in actual replicaset\"\n  }\n\n  // all nodes missing\n  {\n    std::map<std::string, GroupReplicationMember> server_status {};\n    EXPECT_EQ(RS::Unavailable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(2).mode);\n    // should log warning \"Member <host>:<port> (instance-1) defined in metadata not found in actual replicaset\"\n    // should log warning \"Member <host>:<port> (instance-2) defined in metadata not found in actual replicaset\"\n    // should log warning \"Member <host>:<port> (instance-3) defined in metadata not found in actual replicaset\"\n  }\n\n  // 1 unknown id\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-4\", {\"instance-4\", \"host4\", 4444, State::Online, Role::Secondary} },\n      { \"instance-2\", {\"\", \"\", 0, State::Online, Role::Primary  } },\n      { \"instance-3\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::AvailableWritable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::ReadWrite,   servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(2).mode);\n    // should log warning \"Member <host>:<port> (instance-1) defined in metadata not found in actual replicaset\"\n    // should log error \"Member <host>:<port> (instance-4) found in replicaset, yet is not defined in metadata!\"\n  }\n\n  // 2 unknown ids\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-4\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n      { \"instance-2\", {\"\", \"\", 0, State::Online, Role::Primary  } },\n      { \"instance-5\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::Unavailable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::ReadWrite,   servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(2).mode);\n    // should log warning \"Member <host>:<port> (instance-1) defined in metadata not found in actual replicaset\"\n    // should log warning \"Member <host>:<port> (instance-3) defined in metadata not found in actual replicaset\"\n    // should log error \"Member <host>:<port> (instance-4) found in replicaset, yet is not defined in metadata!\"\n    // should log error \"Member <host>:<port> (instance-5) found in replicaset, yet is not defined in metadata!\"\n  }\n\n  // more nodes than expected\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-1\", {\"\", \"\", 0, State::Online, Role::Primary  } },\n      { \"instance-2\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n      { \"instance-3\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n      { \"instance-4\", {\"\", \"\", 0, State::Online, Role::Primary  } },\n      { \"instance-5\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::AvailableWritable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::ReadWrite,   servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(2).mode);\n    // should log error \"Member <host>:<port> (instance-4) found in replicaset, yet is not defined in metadata!\"\n    // should log error \"Member <host>:<port> (instance-5) found in replicaset, yet is not defined in metadata!\"\n  }\n}\n\n/**\n * @test\n * Verify that `ClusterMetadata::check_replicaset_status()` returns proper\n * status for each node (instance) that it received from MD server, and\n * calculates proper replicaset availability.\n *\n * This test is similar to `CheckReplicasetStatus_3NodeSetup`, but here we the\n * inputs flip: MD is variable, GR is always 3 nodes.\n */\nTEST_F(MetadataTest, CheckReplicasetStatus_VariableNodeSetup) {\n\n  std::map<std::string, GroupReplicationMember> server_status {\n    { \"instance-1\", {\"\", \"\", 0, State::Online, Role::Primary  } },\n    { \"instance-2\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n    { \"instance-3\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n  };\n\n  // Next 2 scenarios test situation in which the status report (view) contains\n  // only a subset of servers provided by metadata server. At the time of writing,\n  // this longer list of servers is essentially irrelevant, and the \"view\" is\n  // king. See notes in ClusterMetadata::check_replicaset_status() for more info.\n\n  // 7-node setup according to metadata\n  {\n    std::vector<ManagedInstance> servers_in_metadata {\n      // ServerMode doesn't matter ------vvvvvvvvvvv\n      {\"\", \"instance-1\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n      {\"\", \"instance-2\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n      {\"\", \"instance-3\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n      {\"\", \"instance-4\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n      {\"\", \"instance-5\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n      {\"\", \"instance-6\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n      {\"\", \"instance-7\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n    };\n    EXPECT_EQ(RS::AvailableWritable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::ReadWrite,   servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(2).mode);\n    // should log warning \"Member <host>:<port> (instance-*) defined in metadata not found in actual replicaset\"\n    // for instanes 4-7\n  }\n\n  // 4-node setup according to metadata\n  {\n    std::vector<ManagedInstance> servers_in_metadata {\n      {\"\", \"instance-1\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n      {\"\", \"instance-2\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n      {\"\", \"instance-3\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n      {\"\", \"instance-4\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n    };\n    EXPECT_EQ(RS::AvailableWritable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::ReadWrite,   servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(2).mode);\n    // should log warning \"Member <host>:<port> (instance-4) defined in metadata not found in actual replicaset\"\n  }\n\n  // This time, the status report (view) contains some servers not defined by\n  // metadata server. Here the situation is a little different: the \"view\" is\n  // still what matters, but subject to one restriction: nodes not defined in\n  // metadata don't count, they're ignored.\n  // NOTE that these scenarios should never happen, and if they do, the DBA\n  // is at fault (the setup is messed up). Here we only test how our system will\n  // handle such bad setup, and it should handle it defensively, err on the safe\n  // side. Indeed, in case of undefined nodes, they will be not be counted\n  // towards reaching quorum, making attaining quorum more difficult.\n\n  // 2-node setup according to metadata -> quorum requires 3 nodes, 2 nodes count\n  {\n    std::vector<ManagedInstance> servers_in_metadata {\n      {\"\", \"instance-1\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n      {\"\", \"instance-2\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n    };\n    EXPECT_EQ(RS::AvailableWritable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::ReadWrite,   servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(1).mode);\n    // should log error \"Member <host>:<port> (instance-3) found in replicaset, yet is not defined in metadata!\"\n  }\n\n  // 1-node setup according to metadata -> quorum requires 3 nodes, 1 node counts\n  {\n    std::vector<ManagedInstance> servers_in_metadata {\n      {\"\", \"instance-1\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n    };\n    EXPECT_EQ(RS::Unavailable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::ReadWrite,   servers_in_metadata.at(0).mode);\n    // should log error \"Member <host>:<port> (instance-2) found in replicaset, yet is not defined in metadata!\"\n    // should log error \"Member <host>:<port> (instance-3) found in replicaset, yet is not defined in metadata!\"\n  }\n\n  // 0-node setup according to metadata -> quorum requires 3 nodes, 0 node count\n  {\n    std::vector<ManagedInstance> servers_in_metadata {};\n    EXPECT_EQ(RS::Unavailable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    // should log error \"Member <host>:<port> (instance-1) found in replicaset, yet is not defined in metadata!\"\n    // should log error \"Member <host>:<port> (instance-2) found in replicaset, yet is not defined in metadata!\"\n    // should log error \"Member <host>:<port> (instance-3) found in replicaset, yet is not defined in metadata!\"\n  }\n\n}\n\n/**\n * @test\n * Verify that `ClusterMetadata::check_replicaset_status()` returns proper\n * status for each node (instance) that it received from MD server, and\n * calculates proper replicaset availability.\n *\n * This test focuses on scenarios where 1 and 2 nodes (out of 3-node setup) are\n * in one of unavailable states (offline, error, unreachable, other).\n */\nTEST_F(MetadataTest, CheckReplicasetStatus_VariousStatuses) {\n\n  std::vector<ManagedInstance> servers_in_metadata {\n    // ServerMode doesn't matter ------vvvvvvvvvvv\n    {\"\", \"instance-1\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n    {\"\", \"instance-2\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n    {\"\", \"instance-3\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n  };\n\n  for (State state : {State::Offline, State::Error, State::Unreachable, State::Other}) {\n\n    // should keep quorum\n    {\n      std::map<std::string, GroupReplicationMember> server_status {\n        { \"instance-1\", {\"\", \"\", 0, State::Online,  Role::Primary  } },\n        { \"instance-2\", {\"\", \"\", 0, State::Online,  Role::Secondary} },\n        { \"instance-3\", {\"\", \"\", 0, state,          Role::Secondary} },\n      };\n      EXPECT_EQ(RS::AvailableWritable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n      EXPECT_EQ(ServerMode::ReadWrite,   servers_in_metadata.at(0).mode);\n      EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(1).mode);\n      EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(2).mode);\n    }\n\n    // should keep quorum\n    {\n      std::map<std::string, GroupReplicationMember> server_status {\n        { \"instance-1\", {\"\", \"\", 0, State::Online,  Role::Secondary} },\n        { \"instance-2\", {\"\", \"\", 0, State::Online,  Role::Secondary} },\n        { \"instance-3\", {\"\", \"\", 0, state,          Role::Secondary} },\n      };\n      EXPECT_EQ(RS::AvailableReadOnly, metadata.check_replicaset_status(servers_in_metadata, server_status));\n      EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(0).mode);\n      EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(1).mode);\n      EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(2).mode);\n    }\n\n    // should lose quorum\n    {\n      std::map<std::string, GroupReplicationMember> server_status {\n        { \"instance-1\", {\"\", \"\", 0, State::Online,  Role::Primary  } },\n        { \"instance-2\", {\"\", \"\", 0, state,          Role::Secondary} },\n        { \"instance-3\", {\"\", \"\", 0, state,          Role::Secondary} },\n      };\n      EXPECT_EQ(RS::Unavailable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n      EXPECT_EQ(ServerMode::ReadWrite,   servers_in_metadata.at(0).mode);\n      EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(1).mode);\n      EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(2).mode);\n    }\n  }\n}\n\n/**\n * @test\n * Verify that `ClusterMetadata::check_replicaset_status()` returns proper\n * status for each node (instance) that it received from MD server, and\n * calculates proper replicaset availability.\n *\n * Here we test various scenarios with RECOVERING nodes. RECOVERING nodes\n * should be treated as valid quorum members just like ONLINE nodes, but they\n * cannot be routed to. RS::Recovering should be returned in a (corner) case\n * when all nodes in quorum are recovering.\n */\nTEST_F(MetadataTest, CheckReplicasetStatus_Recovering) {\n\n  std::vector<ManagedInstance> servers_in_metadata {\n    // ServerMode doesn't matter ------vvvvvvvvvvv\n    {\"\", \"instance-1\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n    {\"\", \"instance-2\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n    {\"\", \"instance-3\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n  };\n\n\n\n  // 1 node recovering, 1 RW, 1 RO\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-1\", {\"\", \"\", 0, State::Online,     Role::Primary  } },\n      { \"instance-2\", {\"\", \"\", 0, State::Online,     Role::Secondary} },\n      { \"instance-3\", {\"\", \"\", 0, State::Recovering, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::AvailableWritable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::ReadWrite,   servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(2).mode);\n  }\n\n  // 1 node recovering, 1 offline, 1 RW\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-1\", {\"\", \"\", 0, State::Online,     Role::Primary  } },\n      { \"instance-2\", {\"\", \"\", 0, State::Error,      Role::Secondary} },\n      { \"instance-3\", {\"\", \"\", 0, State::Recovering, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::AvailableWritable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::ReadWrite,   servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(2).mode);\n  }\n\n  // 1 node recovering, 1 offline, 1 RO\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-1\", {\"\", \"\", 0, State::Online,     Role::Secondary} },\n      { \"instance-2\", {\"\", \"\", 0, State::Error,      Role::Secondary} },\n      { \"instance-3\", {\"\", \"\", 0, State::Recovering, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::AvailableReadOnly, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(2).mode);\n  }\n\n  // 1 node recovering, 2 offline\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-1\", {\"\", \"\", 0, State::Error,      Role::Secondary} },\n      { \"instance-2\", {\"\", \"\", 0, State::Error,      Role::Secondary} },\n      { \"instance-3\", {\"\", \"\", 0, State::Recovering, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::Unavailable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(2).mode);\n  }\n\n  // 1 node recovering, 1 offline, 1 left replicaset\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-2\", {\"\", \"\", 0, State::Error,      Role::Secondary} },\n      { \"instance-3\", {\"\", \"\", 0, State::Recovering, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::Unavailable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(1).mode);\n  }\n\n  // 1 node recovering, 2 left replicaset\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-3\", {\"\", \"\", 0, State::Recovering, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::UnavailableRecovering, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(0).mode);\n  }\n\n\n\n  // 2 nodes recovering, 1 RW\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-1\", {\"\", \"\", 0, State::Online,     Role::Primary  } },\n      { \"instance-2\", {\"\", \"\", 0, State::Recovering, Role::Secondary} },\n      { \"instance-3\", {\"\", \"\", 0, State::Recovering, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::AvailableWritable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::ReadWrite,   servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(2).mode);\n  }\n\n  // 2 nodes recovering, 1 RO\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-1\", {\"\", \"\", 0, State::Online,     Role::Secondary} },\n      { \"instance-2\", {\"\", \"\", 0, State::Recovering, Role::Secondary} },\n      { \"instance-3\", {\"\", \"\", 0, State::Recovering, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::AvailableReadOnly, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(2).mode);\n  }\n\n  // 2 nodes recovering, 1 offline\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-1\", {\"\", \"\", 0, State::Error,      Role::Secondary} },\n      { \"instance-2\", {\"\", \"\", 0, State::Recovering, Role::Secondary} },\n      { \"instance-3\", {\"\", \"\", 0, State::Recovering, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::UnavailableRecovering, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(2).mode);\n  }\n\n  // 2 nodes recovering, 1 left replicaset\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-2\", {\"\", \"\", 0, State::Recovering, Role::Secondary} },\n      { \"instance-3\", {\"\", \"\", 0, State::Recovering, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::UnavailableRecovering, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(1).mode);\n  }\n\n\n\n  // 3 nodes recovering\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"instance-1\", {\"\", \"\", 0, State::Recovering, Role::Secondary} },\n      { \"instance-2\", {\"\", \"\", 0, State::Recovering, Role::Secondary} },\n      { \"instance-3\", {\"\", \"\", 0, State::Recovering, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::UnavailableRecovering, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(2).mode);\n  }\n}\n\n/**\n * @test\n * Verify that `ClusterMetadata::check_replicaset_status()` returns proper\n * status for each node (instance) that it received from MD server, and\n * calculates proper replicaset availability.\n *\n * Here we test an interesting cornercase:\n *\n *     MD defines nodes A, B, C\n *     GR defines nodes A, B, C, D, E\n *     A, B are alive; C, D, E are dead\n *\n * Availability calculation should deem replicaset to be unavailable, because\n * only 2 of 5 nodes are alive, even though looking purely from MD point-of-view,\n * 2 of its 3 nodes are still alive, thus could be considered a quorum.\n */\nTEST_F(MetadataTest, CheckReplicasetStatus_Cornercase2of5Alive) {\n\n  // MD defines 3 nodes\n  std::vector<ManagedInstance> servers_in_metadata {\n    {\"\", \"node-A\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n    {\"\", \"node-B\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n    {\"\", \"node-C\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n  };\n\n  // GR reports 5 nodes, of which only 2 are alive (no qourum), BUT from\n  // perspective of MD-defined nodes, 2 of its 3 are alive (have quorum).\n  // We choose to be pessimistic (no quorum)\n  for (State dead_state : {State::Offline, State::Error, State::Unreachable, State::Other}) {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"node-A\", {\"\", \"\", 0, State::Online, Role::Primary  } },\n      { \"node-B\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n      { \"node-C\", {\"\", \"\", 0, dead_state, Role::Secondary} },\n      { \"node-D\", {\"\", \"\", 0, dead_state, Role::Secondary} },\n      { \"node-E\", {\"\", \"\", 0, dead_state, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::Unavailable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    // should log error \"Member <host>:<port> (node-D) found in replicaset, yet is not defined in metadata!\"\n    // should log error \"Member <host>:<port> (node-E) found in replicaset, yet is not defined in metadata!\"\n\n    // meeting these is not strictly required, because when the cluster is\n    // unavailable, ATTOW these results will be ignored. But OTOH, there's no\n    // reason why these computations should fail - so we use the opportunity to\n    // check if they still compute correctly despite replicaset being\n    // unavailable. If one day we need these results to compute differently,\n    // please feel free to erase these tests.\n    EXPECT_EQ(3u, servers_in_metadata.size()); // new nodes reported by GR will not be added\n    EXPECT_EQ(ServerMode::ReadWrite,   servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::ReadOnly,    servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::Unavailable, servers_in_metadata.at(2).mode);\n  }\n}\n\n/**\n * @test\n * Verify that `ClusterMetadata::check_replicaset_status()` returns proper\n * status for each node (instance) that it received from MD server, and\n * calculates proper replicaset availability.\n *\n * Here we test an interesting cornercase:\n *\n *     MD defines nodes A, B, C\n *     GR defines nodes A, B, C, D, E\n *     A, B are dead, C, D, E are alive\n *\n * Availability calculation, if fully GR-aware, could deem replicaset as\n * available, because looking from purely GR perspective, 3 of 5 nodes form\n * quorum.\n *\n * However, our availability calculation in\n * `ClusterMetadata::check_replicaset_status()` always assumes that MD is in\n * sync with GR (which it always should be), but just in case it violates this\n * assumption, it prefers to err on the side of caution. This erring on the side\n * of caution is demonstrated in this test, where the availability is judged as\n * not available, even though it could be. But that's the price we pay in\n * exchange for the safety the algorithm provides which is demonstrated in the\n * CheckReplicasetStatus_Cornercase2of5Alive testcase.\n */\nTEST_F(MetadataTest, CheckReplicasetStatus_Cornercase3of5Alive) {\n\n  // NOTE: If this test starts failing one day because check_replicaset_status()\n  //       starts returning that the replicaset is available, it might be a good\n  //       thing, BUT ONLY AS LONG as CheckReplicasetStatus_Cornercase2of5Alive\n  //       is also passing. Please read the description of that test, and this\n  //       one, before drawing conclusions.\n\n  // MD defines 3 nodes\n  std::vector<ManagedInstance> servers_in_metadata {\n    {\"\", \"node-A\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n    {\"\", \"node-B\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n    {\"\", \"node-C\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n  };\n\n  // GR reports 5 nodes, of which 3 are alive (have qourum), BUT from\n  // the perspective of MD-defined nodes, only 1 of its 3 is alive (no quorum).\n  // We choose to be pessimistic (no quorum)\n  for (State dead_state : {State::Offline, State::Error, State::Unreachable, State::Other}) {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"node-A\", {\"\", \"\", 0, dead_state, Role::Primary  } },\n      { \"node-B\", {\"\", \"\", 0, dead_state, Role::Secondary} },\n      { \"node-C\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n      { \"node-D\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n      { \"node-E\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::Unavailable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    // should log error \"Member <host>:<port> (node-D) found in replicaset, yet is not defined in metadata!\"\n    // should log error \"Member <host>:<port> (node-E) found in replicaset, yet is not defined in metadata!\"\n\n    // meeting these is not strictly required, because when the cluster is\n    // unavailable, ATTOW these results will be ignored. But OTOH, there's no\n    // reason why these computations should fail - so we use the opportunity to\n    // check if they still compute correctly despite replicaset being\n    // unavailable. If one day we need these results to compute differently,\n    // please feel free to erase these tests.\n    EXPECT_EQ(3u, servers_in_metadata.size()); // new nodes reported by GR will not be added\n    EXPECT_EQ(ServerMode::Unavailable,   servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::Unavailable,   servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::ReadOnly,      servers_in_metadata.at(2).mode);\n  }\n}\n\n/**\n * @test\n * Verify that `ClusterMetadata::check_replicaset_status()` returns proper\n * status for each node (instance) that it received from MD server, and\n * calculates proper replicaset availability.\n *\n * Here we test an interesting cornercase:\n *\n *     MD defines nodes A, B, C\n *     GR defines nodes       C, D, E\n *     A, B are not reported by GR, C, D, E are alive\n *\n * According to GR, there's a quorum between nodes C, D and E. However, from MD\n * point-of-view, A, B went missing and only C is known to be alive.\n *\n * Our availability calculation in `ClusterMetadata::check_replicaset_status()`\n * always assumes that MD is in sync with GR (which it always should be), but\n * just in case it violates this assumption, it prefers to err on the side of\n * caution. This erring on the side of caution is demonstrated in this test,\n * where the availability is judged as not available, even though it could be.\n * But that's the price we pay in exchange for the safety the algorithm provides\n * which is demonstrated in the CheckReplicasetStatus_Cornercase2of5Alive\n * testcase.\n */\nTEST_F(MetadataTest, CheckReplicasetStatus_Cornercase1Common) {\n\n  // NOTE: If this test starts failing one day because check_replicaset_status()\n  //       starts returning that the replicaset is available, it might be a good\n  //       thing, BUT ONLY AS LONG as CheckReplicasetStatus_Cornercase2of5Alive\n  //       is also passing. Please read the description of that test, and this\n  //       one, before drawing conclusions.\n\n  // MD defines 3 nodes\n  std::vector<ManagedInstance> servers_in_metadata {\n    {\"\", \"node-A\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n    {\"\", \"node-B\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n    {\"\", \"node-C\", \"\", ServerMode::Unavailable, 0, 0, \"\", \"\", 0, 0},\n  };\n\n  // GR reports 3 nodes, of which 3 are alive (have qourum), BUT from\n  // the perspective of MD-defined nodes, only 1 of its 3 is alive (no quorum).\n  // We choose to be pessimistic (no quorum)\n  {\n    std::map<std::string, GroupReplicationMember> server_status {\n      { \"node-C\", {\"\", \"\", 0, State::Online, Role::Primary  } },\n      { \"node-D\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n      { \"node-E\", {\"\", \"\", 0, State::Online, Role::Secondary} },\n    };\n    EXPECT_EQ(RS::Unavailable, metadata.check_replicaset_status(servers_in_metadata, server_status));\n    // should log warning \"Member <host>:<port> (node-A) defined in metadata not found in actual replicaset\"\n    // should log warning \"Member <host>:<port> (node-B) defined in metadata not found in actual replicaset\"\n    // should log error \"Member <host>:<port> (node-D) found in replicaset, yet is not defined in metadata!\"\n    // should log error \"Member <host>:<port> (node-E) found in replicaset, yet is not defined in metadata!\"\n\n    // meeting these is not strictly required, because when the cluster is\n    // unavailable, ATTOW these results will be ignored. But OTOH, there's no\n    // reason why these computations should fail - so we use the opportunity to\n    // check if they still compute correctly despite replicaset being\n    // unavailable. If one day we need these results to compute differently,\n    // please feel free to erase these tests.\n    EXPECT_EQ(3u, servers_in_metadata.size()); // new nodes reported by GR will not be added, nor old ones removed\n    EXPECT_EQ(ServerMode::Unavailable,   servers_in_metadata.at(0).mode);\n    EXPECT_EQ(ServerMode::Unavailable,   servers_in_metadata.at(1).mode);\n    EXPECT_EQ(ServerMode::ReadWrite,     servers_in_metadata.at(2).mode);\n  }\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// test ClusterMetadata::update_replicaset_status() - connection failures\n//\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * @test\n * Verify `ClusterMetadata::update_replicaset_status()` will correctly update\n * routing table, even despite having to failover on connection errors.\n *\n *     Scenario details:\n *     iteration 1 (instance-1): query_primary_member FAILS\n *     iteration 2 (instance-2): CAN'T CONNECT\n *     iteration 3 (instance-3): query_primary_member OK, query_status OK\n */\nTEST_F(MetadataTest, UpdateReplicasetStatus_PrimaryMember_FailConnectOnNode2) {\n\n  connect_to_first_metadata_server();\n\n  // update_replicaset_status() first iteration: requests start with existing connection to instance-1 (shared with metadata server)\n  unsigned session = 0;\n\n  // 1st query_primary_member should go to existing connection (shared with metadata server) -> make the query fail\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_primary_member), _)).Times(1)\n    .WillOnce(Invoke(query_primary_member_fail(session)));\n\n  // since 1st query_primary_member failed, update_replicaset_status() should try to connect to\n  // instance-2. Let's make that new connections fail by NOT using enable_connection(session)\n  //enable_connection(++session, 3320); // we don't call this on purpose\n  EXPECT_CALL(session_factory.get(++session), flag_fail(_, 3320)).Times(1);\n\n  // Next\n  // instance-2. Let's make that new connections fail by NOT using enable_connection(session)\n  //enable_connection(++session, 3320); // we don't call this on purpose\n\n  // since 2nd connection failed, update_replicaset_status() should try to connect to instance-3.\n  // Let's allow this.\n  enable_connection(++session, 3330);\n\n  // 3rd query_primary_member: let's return \"instance-1\"\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_primary_member), _)).Times(1)\n    .WillOnce(Invoke(query_primary_member_ok(session)));\n\n  // 3rd query_status: let's return good data\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_status), _)).Times(1)\n    .WillOnce(Invoke(query_status_ok(session)));\n\n  EXPECT_EQ(1, session_factory.create_cnt());          // caused by connect_to_first_metadata_server()\n\n  ManagedReplicaSet replicaset = typical_replicaset;\n  metadata.update_replicaset_status(\"replicaset-1\", replicaset);\n\n  EXPECT_EQ(3u, replicaset.members.size());\n  EXPECT_TRUE(cmp_mi_FI(ManagedInstance{\"replicaset-1\", \"instance-1\", \"\", ServerMode::ReadWrite, 0, 0, \"\", \"localhost\", 3310, 33100}, replicaset.members.at(0)));\n  EXPECT_TRUE(cmp_mi_FI(ManagedInstance{\"replicaset-1\", \"instance-2\", \"\", ServerMode::ReadOnly,  0, 0, \"\", \"localhost\", 3320, 33200}, replicaset.members.at(1)));\n  EXPECT_TRUE(cmp_mi_FI(ManagedInstance{\"replicaset-1\", \"instance-3\", \"\", ServerMode::ReadOnly,  0, 0, \"\", \"localhost\", 3330, 33300}, replicaset.members.at(2)));\n\n  EXPECT_EQ(3, session_factory.create_cnt());          // +2 from new connections to localhost:3320 and :3330\n}\n\n/**\n * @test\n * Verify `ClusterMetadata::update_replicaset_status()` will handle correctly\n * when all connect attempts fail. Finally, it should clear the routing table\n * since it's unable to connect to any server.\n *\n *     Scenario details:\n *     iteration 1 (instance-1): query_primary_member FAILS\n *     iteration 2 (instance-2): CAN'T CONNECT\n *     iteration 3 (instance-3): CAN'T CONNECT\n */\nTEST_F(MetadataTest, UpdateReplicasetStatus_PrimaryMember_FailConnectOnAllNodes) {\n\n  connect_to_first_metadata_server();\n\n\n  // update_replicaset_status() first iteration: requests start with existing connection to instance-1 (shared with metadata server)\n  unsigned session = 0;\n\n  // 1st query_primary_member should go to existing connection (shared with metadata server) -> make the query fail\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_primary_member), _)).Times(1)\n    .WillOnce(Invoke(query_primary_member_fail(session)));\n\n  // since 1st query_primary_member failed, update_replicaset_status() should try to connect to\n  // instance-2, then instance-3. Let's make those new connections fail by NOT using enable_connection(session)\n  EXPECT_CALL(session_factory.get(++session), flag_fail(_, 3320)).Times(1);\n  EXPECT_CALL(session_factory.get(++session), flag_fail(_, 3330)).Times(1);\n\n  EXPECT_EQ(1, session_factory.create_cnt());          // caused by connect_to_first_metadata_server()\n\n  // if update_replicaset_status() can't connect to a quorum, it should clear replicaset.members\n  ManagedReplicaSet replicaset = typical_replicaset;\n  metadata.update_replicaset_status(\"replicaset-1\", replicaset);\n  EXPECT_TRUE(replicaset.members.empty());\n\n  EXPECT_EQ(3, session_factory.create_cnt());          // +2 from new connections to localhost:3320 and :3330\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// test ClusterMetadata::update_replicaset_status() - query_primary_member failures\n// [QUERY #2: query_primary_member]\n//\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * @test\n * Verify `ClusterMetadata::update_replicaset_status()` will correctly update\n * routing table, even despite having to failover on fetching primary member\n * failing.\n *\n *     Scenario details:\n *     iteration 1 (instance-1): query_primary_member FAILS\n *     iteration 2 (instance-2): query_primary_member OK, query_status OK\n */\nTEST_F(MetadataTest, UpdateReplicasetStatus_PrimaryMember_FailQueryOnNode1) {\n\n  connect_to_first_metadata_server();\n\n  // update_replicaset_status() first iteration: requests start with existing connection to instance-1 (shared with metadata server)\n  unsigned session = 0;\n\n  // 1st query_primary_member should go to existing connection (shared with metadata server) -> make the query fail\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_primary_member), _)).Times(1)\n    .WillOnce(Invoke(query_primary_member_fail(session)));\n\n  // since 1st query_primary_member failed, 2nd should to to instance-2 -> make it succeed.\n  // Note that the connection to instance-2 has to be created first\n  enable_connection(++session, 3320);\n\n  // 2nd query_primary_member: let's return \"instance-1\"\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_primary_member), _)).Times(1)\n    .WillOnce(Invoke(query_primary_member_ok(session)));\n\n  // 2nd query_status: let's return good data\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_status), _)).Times(1)\n    .WillOnce(Invoke(query_status_ok(session)));\n\n  EXPECT_EQ(1, session_factory.create_cnt());          // caused by connect_to_first_metadata_server()\n\n  ManagedReplicaSet replicaset = typical_replicaset;\n  metadata.update_replicaset_status(\"replicaset-1\", replicaset);\n\n  EXPECT_EQ(2, session_factory.create_cnt());          // +1 from new connection to localhost:3320 (instance-2)\n\n  // query_status reported back from instance-2\n  EXPECT_EQ(3u, replicaset.members.size());\n  EXPECT_TRUE(cmp_mi_FI(ManagedInstance{\"replicaset-1\", \"instance-1\", \"\", ServerMode::ReadWrite, 0, 0, \"\", \"localhost\", 3310, 33100}, replicaset.members.at(0)));\n  EXPECT_TRUE(cmp_mi_FI(ManagedInstance{\"replicaset-1\", \"instance-2\", \"\", ServerMode::ReadOnly,  0, 0, \"\", \"localhost\", 3320, 33200}, replicaset.members.at(1)));\n  EXPECT_TRUE(cmp_mi_FI(ManagedInstance{\"replicaset-1\", \"instance-3\", \"\", ServerMode::ReadOnly,  0, 0, \"\", \"localhost\", 3330, 33300}, replicaset.members.at(2)));\n}\n\n/**\n * @test\n * Verify `ClusterMetadata::update_replicaset_status()` will handle correctly\n * when all primary member query attempts fail. Finally, it should clear the\n * routing table since it was unable to complete its operation successfully.\n *\n *     Scenario details:\n *     iteration 1 (instance-1): query_primary_member FAILS\n *     iteration 2 (instance-2): query_primary_member FAILS\n *     iteration 3 (instance-3): query_primary_member FAILS\n */\nTEST_F(MetadataTest, UpdateReplicasetStatus_PrimaryMember_FailQueryOnAllNodes) {\n\n  connect_to_first_metadata_server();\n\n  // update_replicaset_status() first iteration: requests start with existing connection to instance-1 (shared with metadata server)\n  unsigned session = 0;\n\n  // 1st query_primary_member should go to existing connection (shared with metadata server) -> make the query fail\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_primary_member), _)).Times(1)\n    .WillOnce(Invoke(query_primary_member_fail(session)));\n\n  // since 1st query_primary_member failed, should issue 2nd query to instance-2 -> also make the query fail\n  // Note that the connection to instance-2 has to be created first\n  enable_connection(++session, 3320);\n\n  // 2nd query_primary_member: let's fail again\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_primary_member), _)).Times(1)\n    .WillOnce(Invoke(query_primary_member_fail(session)));\n\n  // since 2nd query_primary_member failed, should issue 3rd query to instance-3 -> also make the query fail\n  // Note that the connection to instance-3 has to be created first\n  enable_connection(++session, 3330);\n\n  // 3rd query_primary_member: let's fail again\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_primary_member), _)).Times(1)\n    .WillOnce(Invoke(query_primary_member_fail(session)));\n\n  EXPECT_EQ(1, session_factory.create_cnt());          // caused by connect_to_first_metadata_server()\n\n  // if update_replicaset_status() can't connect to a quorum, it should clear replicaset.members\n  ManagedReplicaSet replicaset = typical_replicaset;\n  metadata.update_replicaset_status(\"replicaset-1\", replicaset);\n  EXPECT_TRUE(replicaset.members.empty());\n\n  EXPECT_EQ(3, session_factory.create_cnt());          // +2 from new connections to localhost:3320 and :3330\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// test ClusterMetadata::update_replicaset_status() - query_status failures\n// [QUERY #3: query_status]\n//\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * @test\n * Verify `ClusterMetadata::update_replicaset_status()` will correctly update\n * routing table, even despite having to failover on fetching healh status\n * failing.\n *\n *     Scenario details:\n *     iteration 1 (instance-1): query_primary_member OK, query_status FAILS\n *     iteration 2 (instance-2): query_primary_member OK, query_status OK\n */\nTEST_F(MetadataTest, UpdateReplicasetStatus_Status_FailQueryOnNode1) {\n\n  connect_to_first_metadata_server();\n\n  // update_replicaset_status() first iteration: requests start with existing connection to instance-1 (shared with metadata server)\n  unsigned session = 0;\n\n  // 1st query_primary_member: let's return \"instance-1\"\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_primary_member), _)).Times(1)\n    .WillOnce(Invoke(query_primary_member_ok(session)));\n\n  // 1st query_status: let's fail the query\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_status), _)).Times(1)\n    .WillOnce(Invoke(query_status_fail(session)));\n\n  // since 1st query_status failed, update_replicaset_status() should start another iteration, but on instance-2 this time.\n  // Note that the connection to instance-2 has to be created first\n  enable_connection(++session, 3320);\n\n  // 2nd query_primary_member: let's again return \"instance-1\"\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_primary_member), _)).Times(1)\n    .WillOnce(Invoke(query_primary_member_ok(session)));\n\n  // 2nd query_status: let's return good data\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_status), _)).Times(1)\n    .WillOnce(Invoke(query_status_ok(session)));\n\n  EXPECT_EQ(1, session_factory.create_cnt());          // caused by connect_to_first_metadata_server()\n\n  ManagedReplicaSet replicaset = typical_replicaset;\n  metadata.update_replicaset_status(\"replicaset-1\", replicaset);\n\n  EXPECT_EQ(2, session_factory.create_cnt());          // +1 from new connection to localhost:3320 (instance-2)\n\n  // query_status reported back from instance-1\n  EXPECT_EQ(3u, replicaset.members.size());\n  EXPECT_TRUE(cmp_mi_FI(ManagedInstance{\"replicaset-1\", \"instance-1\", \"\", ServerMode::ReadWrite, 0, 0, \"\", \"localhost\", 3310, 33100}, replicaset.members.at(0)));\n  EXPECT_TRUE(cmp_mi_FI(ManagedInstance{\"replicaset-1\", \"instance-2\", \"\", ServerMode::ReadOnly,  0, 0, \"\", \"localhost\", 3320, 33200}, replicaset.members.at(1)));\n  EXPECT_TRUE(cmp_mi_FI(ManagedInstance{\"replicaset-1\", \"instance-3\", \"\", ServerMode::ReadOnly,  0, 0, \"\", \"localhost\", 3330, 33300}, replicaset.members.at(2)));\n}\n\n/**\n * @test\n * Verify `ClusterMetadata::update_replicaset_status()` will handle correctly\n * when all health status query attempts fail. Finally, it should clear the\n * routing table since it was unable to complete its operation successfully.\n *\n *     Scenario details:\n *     iteration 1 (instance-1): query_primary_member OK, query_status FAILS\n *     iteration 2 (instance-2): query_primary_member OK, query_status FAILS\n *     iteration 3 (instance-2): query_primary_member OK, query_status FAILS\n */\nTEST_F(MetadataTest, UpdateReplicasetStatus_Status_FailQueryOnAllNodes) {\n\n  connect_to_first_metadata_server();\n\n  // update_replicaset_status() first iteration: requests start with existing connection to instance-1 (shared with metadata server)\n  unsigned session = 0;\n\n  // 1st query_primary_member: let's return \"instance-1\"\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_primary_member), _)).Times(1)\n    .WillOnce(Invoke(query_primary_member_ok(session)));\n\n  // 1st query_status: let's fail the query\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_status), _)).Times(1)\n    .WillOnce(Invoke(query_status_fail(session)));\n\n  // since 1st query_status failed, update_replicaset_status() should start another iteration, but on instance-2 this time.\n  // Note that the connection to instance-2 has to be created first\n  enable_connection(++session, 3320);\n\n  // 2nd query_primary_member: let's again return \"instance-1\"\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_primary_member), _)).Times(1)\n    .WillOnce(Invoke(query_primary_member_ok(session)));\n\n  // 2nd query_status: let's fail the query\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_status), _)).Times(1)\n    .WillOnce(Invoke(query_status_fail(session)));\n\n  // since 2st query_status failed, update_replicaset_status() should start another iteration, but on instance-3 this time.\n  // Note that the connection to instance-3 has to be created first\n  enable_connection(++session, 3330);\n\n  // 3rd query_primary_member: let's again return \"instance-1\"\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_primary_member), _)).Times(1)\n    .WillOnce(Invoke(query_primary_member_ok(session)));\n\n  // 3rd query_status: let's fail the query\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_status), _)).Times(1)\n    .WillOnce(Invoke(query_status_fail(session)));\n\n  EXPECT_EQ(1, session_factory.create_cnt());          // caused by connect_to_first_metadata_server()\n\n  // if update_replicaset_status() can't connect to a quorum, it should clear replicaset.members\n  ManagedReplicaSet replicaset = typical_replicaset;\n  metadata.update_replicaset_status(\"replicaset-1\", replicaset);\n  EXPECT_TRUE(replicaset.members.empty());\n\n  EXPECT_EQ(3, session_factory.create_cnt());          // +2 from new connections to localhost:3320 and :3330\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// test ClusterMetadata::update_replicaset_status() - success scenarios\n// [QUERY #2 + #3]\n//\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * @test\n * Verify `ClusterMetadata::update_replicaset_status()` will return correct\n * results in a sunny-day scenario.\n *\n *     Scenario details:\n *     iteration 1 (instance-1): query_primary_member OK, query_status OK\n */\nTEST_F(MetadataTest, UpdateReplicasetStatus_SimpleSunnyDayScenario) {\n  connect_to_first_metadata_server();\n\n  // update_replicaset_status() first iteration: all requests go to existing connection to instance-1 (shared with metadata server)\n  unsigned session = 0;\n\n  // 1st query_primary_member: let's return \"instance-1\"\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_primary_member), _)).Times(1)\n    .WillOnce(Invoke(query_primary_member_ok(session)));\n\n  // 1st query_status as seen from instance-1\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_status), _)).Times(1)\n    .WillOnce(Invoke(query_status_ok(session)));\n\n  EXPECT_EQ(1, session_factory.create_cnt());          // caused by connect_to_first_metadata_server()\n\n  ManagedReplicaSet replicaset = typical_replicaset;\n  metadata.update_replicaset_status(\"replicaset-1\", replicaset);\n\n  EXPECT_EQ(1, session_factory.create_cnt());          // should resuse localhost:3310 connection,\n\n  // query_status reported back from instance-1\n  EXPECT_EQ(3u, replicaset.members.size());\n  EXPECT_TRUE(cmp_mi_FI(ManagedInstance{\"replicaset-1\", \"instance-1\", \"\", ServerMode::ReadWrite, 0, 0, \"\", \"localhost\", 3310, 33100}, replicaset.members.at(0)));\n  EXPECT_TRUE(cmp_mi_FI(ManagedInstance{\"replicaset-1\", \"instance-2\", \"\", ServerMode::ReadOnly,  0, 0, \"\", \"localhost\", 3320, 33200}, replicaset.members.at(1)));\n  EXPECT_TRUE(cmp_mi_FI(ManagedInstance{\"replicaset-1\", \"instance-3\", \"\", ServerMode::ReadOnly,  0, 0, \"\", \"localhost\", 3330, 33300}, replicaset.members.at(2)));\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// test ClusterMetadata::fetch_instances()\n// (this is the highest-level function, it calls everything tested above\n// except connect() (which is a separate step))\n//\n// TODO add tests for multiple replicasets here, when we begin supporting them\n//\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * @test\n * Verify `ClusterMetadata::fetch_instances()` will return correct results in a\n * sunny-day scenario.\n */\nTEST_F(MetadataTest, FetchInstances_1Replicaset_ok) {\n\n  connect_to_first_metadata_server();\n\n  // update_replicaset_status() first iteration: all requests go to existing connection to instance-1 (shared with metadata server)\n  unsigned session = 0;\n\n  auto resultset_metadata = [this](const std::string&, const MySQLSession::RowProcessor& processor) {\n    session_factory.get(0).query_impl(processor, {\n      {\"replicaset-1\", \"instance-1\", \"HA\", NULL, NULL, \"blabla\", \"localhost:3310\", NULL},\n      {\"replicaset-1\", \"instance-2\", \"HA\", NULL, NULL, \"blabla\", \"localhost:3320\", NULL},\n      {\"replicaset-1\", \"instance-3\", \"HA\", NULL, NULL, \"blabla\", \"localhost:3330\", NULL},\n    });\n  };\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_metadata), _)).Times(1)\n    .WillOnce(Invoke(resultset_metadata));\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_primary_member), _)).Times(1)\n    .WillOnce(Invoke(query_primary_member_ok(session)));\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_status), _)).Times(1)\n    .WillOnce(Invoke(query_status_ok(session)));\n\n  ClusterMetadata::ReplicaSetsByName rs = metadata.fetch_instances(\"replicaset-1\");\n\n  EXPECT_EQ(1u, rs.size());\n  EXPECT_EQ(3u, rs.at(\"replicaset-1\").members.size());\n  EXPECT_TRUE(cmp_mi_FI(ManagedInstance{\"replicaset-1\", \"instance-1\", \"\", ServerMode::ReadWrite, 0, 0, \"\", \"localhost\", 3310, 33100}, rs.at(\"replicaset-1\").members.at(0)));\n  EXPECT_TRUE(cmp_mi_FI(ManagedInstance{\"replicaset-1\", \"instance-2\", \"\", ServerMode::ReadOnly, 0, 0, \"\", \"localhost\", 3320, 33200}, rs.at(\"replicaset-1\").members.at(1)));\n  EXPECT_TRUE(cmp_mi_FI(ManagedInstance{\"replicaset-1\", \"instance-3\", \"\", ServerMode::ReadOnly, 0, 0, \"\", \"localhost\", 3330, 33300}, rs.at(\"replicaset-1\").members.at(2)));\n}\n\n/**\n * @test\n * Verify `ClusterMetadata::fetch_instances()` will handle correctly when\n * retreiving information from all servers fail. It should return an empty\n * routing table since it's unable to complete its operation successfully.\n */\nTEST_F(MetadataTest, FetchInstances_1Replicaset_fail) {\n\n  connect_to_first_metadata_server();\n\n  // update_replicaset_status() first iteration: requests start with existing connection to instance-1 (shared with metadata server)\n  unsigned session = 0;\n\n  auto resultset_metadata = [this](const std::string&, const MySQLSession::RowProcessor& processor) {\n    session_factory.get(0).query_impl(processor, {\n      {\"replicaset-1\", \"instance-1\", \"HA\", NULL, NULL, \"blabla\", \"localhost:3310\", NULL},\n      {\"replicaset-1\", \"instance-2\", \"HA\", NULL, NULL, \"blabla\", \"localhost:3320\", NULL},\n      {\"replicaset-1\", \"instance-3\", \"HA\", NULL, NULL, \"blabla\", \"localhost:3330\", NULL},\n    });\n  };\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_metadata), _)).Times(1)\n    .WillOnce(Invoke(resultset_metadata));\n\n  // fail query_primary_member, then further connections\n  EXPECT_CALL(session_factory.get(session), query(StartsWith(query_primary_member), _)).Times(1)\n    .WillOnce(Invoke(query_primary_member_fail(session)));\n  EXPECT_CALL(session_factory.get(++session), flag_fail(_, 3320)).Times(1);\n  EXPECT_CALL(session_factory.get(++session), flag_fail(_, 3330)).Times(1);\n\n  // if fetch_instances() can't connect to a quorum for a particular replicaset, it should clear its replicaset.members\n  ClusterMetadata::ReplicaSetsByName rs = metadata.fetch_instances(\"replicaset-1\");\n  EXPECT_EQ(1u, rs.size());\n  EXPECT_EQ(0u, rs.at(\"replicaset-1\").members.size());\n}\n\nint main(int argc, char *argv[]) {\n  init_test_logger();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/metadata_cache/tests/test_metadata_cache.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/**\n * Test the metadata cache implementation.\n */\n\n#include \"gtest/gtest_prod.h\" // must be the first header\n#include \"gmock/gmock.h\"\n\n#include \"cluster_metadata.h\"\n#include \"dim.h\"\n#include \"metadata_cache.h\"\n#include \"metadata_factory.h\"\n#include \"mock_metadata.h\"\n#include \"mysql_session_replayer.h\"\n#include \"tcp_address.h\"\n#include \"test/helpers.h\"\n\nusing metadata_cache::ManagedInstance;\nusing mysql_harness::TCPAddress;\n\nclass MetadataCacheTest : public ::testing::Test {\npublic:\n  MockNG mf;\n  MetadataCache cache;\n\n  MetadataCacheTest() : mf(\"admin\", \"admin\", 1, 1, 1, std::chrono::seconds(10)),\n                      cache({TCPAddress(\"localhost\", 32275)},\n                              get_instance(\"admin\", \"admin\", 1, 1, 1, std::chrono::seconds(10),\n                                           mysqlrouter::SSLOptions()),\n                              std::chrono::seconds(10), mysqlrouter::SSLOptions(), \"replicaset-1\") {}\n};\n\n/**\n * Test that the list of servers that are part of a replicaset is accurate.\n */\nTEST_F(MetadataCacheTest, ValidReplicasetTest_1) {\n  std::vector<ManagedInstance> instance_vector_1;\n\n  instance_vector_1 = cache.replicaset_lookup(\"replicaset-1\");\n  ASSERT_EQ(3U, instance_vector_1.size());\n  EXPECT_EQ(instance_vector_1[0], mf.ms1);\n  EXPECT_EQ(instance_vector_1[1], mf.ms2);\n  EXPECT_EQ(instance_vector_1[2], mf.ms3);\n}\n\n/**\n * Test that looking up an invalid replicaset returns a empty list.\n */\nTEST_F(MetadataCacheTest, InvalidReplicasetTest) {\n  std::vector<ManagedInstance> instance_vector;\n\n  instance_vector = cache.replicaset_lookup(\"InvalidReplicasetTest\");\n\n  EXPECT_TRUE(instance_vector.empty());\n}\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// Test Metadata Cache vs metadata server availabilty\n//\n////////////////////////////////////////////////////////////////////////////////\n\nclass MetadataCacheTest2 : public ::testing::Test {\n public:\n  // per-test setup\n  virtual void SetUp() override {\n    session.reset(new MySQLSessionReplayer(true));\n    mysql_harness::DIM::instance().set_MySQLSession(\n      [this](){ return session.get(); }, // provide pointer to session\n      [](mysqlrouter::MySQLSession*){}   // and don't try deleting it!\n    );\n    cmeta.reset(new ClusterMetadata(\"admin\", \"admin\", 1, 1, 1, std::chrono::seconds(10), mysqlrouter::SSLOptions()));\n  }\n\n  // make queries on metadata schema return a 3 members replicaset\n  void expect_sql_metadata() {\n    MySQLSessionReplayer &m = *session;\n\n    m.expect_query(\"SELECT R.replicaset_name, I.mysql_server_uuid, I.role, I.weight, I.version_token, H.location, I.addresses->>'$.mysqlClassic', I.addresses->>'$.mysqlX' FROM mysql_innodb_cluster_metadata.clusters AS F JOIN mysql_innodb_cluster_metadata.replicasets AS R ON F.cluster_id = R.cluster_id JOIN mysql_innodb_cluster_metadata.instances AS I ON R.replicaset_id = I.replicaset_id JOIN mysql_innodb_cluster_metadata.hosts AS H ON I.host_id = H.host_id WHERE F.cluster_name = 'cluster-1';\");\n    m.then_return(8, {\n      // replicaset_name, mysql_server_uuid, role, weight, version_token, location, I.addresses->>'$.mysqlClassic', I.addresses->>'$.mysqlX'\n      {m.string_or_null(\"cluster-1\"), m.string_or_null(\"uuid-server1\"), m.string_or_null(\"HA\"), m.string_or_null(), m.string_or_null(), m.string_or_null(\"\"), m.string_or_null(\"localhost:3000\"), m.string_or_null(\"localhost:30000\")},\n      {m.string_or_null(\"cluster-1\"), m.string_or_null(\"uuid-server2\"), m.string_or_null(\"HA\"), m.string_or_null(), m.string_or_null(), m.string_or_null(\"\"), m.string_or_null(\"localhost:3001\"), m.string_or_null(\"localhost:30010\")},\n      {m.string_or_null(\"cluster-1\"), m.string_or_null(\"uuid-server3\"), m.string_or_null(\"HA\"), m.string_or_null(), m.string_or_null(), m.string_or_null(\"\"), m.string_or_null(\"localhost:3002\"), m.string_or_null(\"localhost:30020\")}\n    });\n  }\n\n  // make queries on PFS.replication_group_members return all members ONLINE\n  void expect_sql_members() {\n    MySQLSessionReplayer &m = *session;\n\n    m.expect_query(\"show status like 'group_replication_primary_member'\");\n    m.then_return(2, {\n      // Variable_name, Value\n      {m.string_or_null(\"group_replication_primary_member\"), m.string_or_null(\"uuid-server1\")}\n    });\n\n    m.expect_query(\"SELECT member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode FROM performance_schema.replication_group_members WHERE channel_name = 'group_replication_applier'\");\n    m.then_return(5, {\n      // member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode\n      {m.string_or_null(\"uuid-server1\"), m.string_or_null(\"somehost\"), m.string_or_null(\"3000\"), m.string_or_null(\"ONLINE\"), m.string_or_null(\"1\")},\n      {m.string_or_null(\"uuid-server2\"), m.string_or_null(\"somehost\"), m.string_or_null(\"3001\"), m.string_or_null(\"ONLINE\"), m.string_or_null(\"1\")},\n      {m.string_or_null(\"uuid-server3\"), m.string_or_null(\"somehost\"), m.string_or_null(\"3002\"), m.string_or_null(\"ONLINE\"), m.string_or_null(\"1\")}\n    });\n  }\n\n  std::shared_ptr<MySQLSessionReplayer> session;\n  std::shared_ptr<ClusterMetadata> cmeta;\n  std::shared_ptr<MetadataCache> cache;\n\n  std::vector<TCPAddress> metadata_servers {\n    {\"localhost\", 3000},\n    {\"localhost\", 3001},\n    {\"localhost\", 3002},\n  };\n};\n\nvoid expect_cluster_routable(MetadataCache& mc) {\n  std::vector<ManagedInstance> instances = mc.replicaset_lookup(\"cluster-1\");\n  ASSERT_EQ(3U, instances.size());\n  EXPECT_EQ(\"uuid-server1\", instances[0].mysql_server_uuid);\n  EXPECT_EQ(metadata_cache::ServerMode::ReadWrite, instances[0].mode);\n  EXPECT_EQ(\"uuid-server2\", instances[1].mysql_server_uuid);\n  EXPECT_EQ(metadata_cache::ServerMode::ReadOnly, instances[1].mode);\n  EXPECT_EQ(\"uuid-server3\", instances[2].mysql_server_uuid);\n  EXPECT_EQ(metadata_cache::ServerMode::ReadOnly, instances[2].mode);\n}\n\nvoid expect_cluster_not_routable(MetadataCache& mc) {\n  std::vector<ManagedInstance> instances = mc.replicaset_lookup(\"cluster-1\");\n  ASSERT_EQ(0U, instances.size());\n}\n\nTEST_F(MetadataCacheTest2, basic_test) {\n\n  // start off with all metadata servers up\n  expect_sql_metadata();\n  expect_sql_members();\n  MetadataCache mc(metadata_servers, cmeta, std::chrono::seconds(10), mysqlrouter::SSLOptions(), \"cluster-1\");\n\n  // verify that cluster can be seen\n  expect_cluster_routable(mc);\n  expect_cluster_routable(mc);  // repeated queries should not change anything\n  expect_cluster_routable(mc);  // repeated queries should not change anything\n\n  // refresh MC\n  expect_sql_metadata();\n  expect_sql_members();\n  mc.refresh();\n\n  // verify that cluster can be seen\n  expect_cluster_routable(mc);\n  expect_cluster_routable(mc);  // repeated queries should not change anything\n  expect_cluster_routable(mc);  // repeated queries should not change anything\n}\n\nTEST_F(MetadataCacheTest2, metadata_server_connection_failures) {\n\n  // Here we test MC behaviour when metadata servers go down and back up again. ATM (2017.01.10, might be changed later)\n  // at least one metadata server must be reachable for Router to continue Routing.\n\n  MySQLSessionReplayer& m = *session;\n\n  // start off with all metadata servers up\n  expect_sql_metadata();\n  expect_sql_members();\n  MetadataCache mc(metadata_servers, cmeta, std::chrono::seconds(10), mysqlrouter::SSLOptions(), \"cluster-1\");\n  expect_cluster_routable(mc);\n\n  // refresh: fail connecting to first metadata server\n  m.expect_connect(\"127.0.0.1\", 3000, \"admin\", \"admin\", \"\").then_error(\"some fake bad connection message\", 66);\n  expect_sql_metadata();\n  expect_sql_members();\n  mc.refresh();\n  expect_cluster_routable(mc);\n\n  // refresh: fail connecting to all 3 metadata servers\n  m.expect_connect(\"127.0.0.1\", 3000, \"admin\", \"admin\", \"\").then_error(\"some fake bad connection message\", 66);\n  m.expect_connect(\"127.0.0.1\", 3001, \"admin\", \"admin\", \"\").then_error(\"some fake bad connection message\", 66);\n  m.expect_connect(\"127.0.0.1\", 3002, \"admin\", \"admin\", \"\").then_error(\"some fake bad connection message\", 66);\n  mc.refresh();\n  expect_cluster_not_routable(mc); // lookup should return nothing (all route paths should have been cleared)\n\n  // refresh: fail connecting to first 2 metadata servers\n  m.expect_connect(\"127.0.0.1\", 3000, \"admin\", \"admin\", \"\").then_error(\"some fake bad connection message\", 66);\n  m.expect_connect(\"127.0.0.1\", 3001, \"admin\", \"admin\", \"\").then_error(\"some fake bad connection message\", 66);\n  expect_sql_metadata();\n  expect_sql_members();\n  mc.refresh();\n  expect_cluster_routable(mc); // lookup should see the cluster again\n}\n\nint main(int argc, char *argv[]) {\n  init_test_logger();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n\n"
  },
  {
    "path": "src/metadata_cache/tests/test_plugin_config.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <typeinfo>\n\n#include \"../src/plugin_config.h\"\n#include \"../src/metadata_cache.h\"\n\n#include \"router_test_helpers.h\"\n\n#include \"gmock/gmock.h\"\n\nusing ::testing::StrEq;\nusing ::testing::Eq;\nusing ::testing::ContainerEq;\n\nusing mysql_harness::TCPAddress;\n\n// demangle the symbols returned by typeid().name() if needed\n//\n// typeid() on gcc/clang returns a mangled name, msvc doesn't.\nstatic std::string cxx_demangle_name(const char *mangled) {\n#if defined(__GNUC__) && defined(__cplusplus)\n  // gcc and clang are mangling the names\n  std::shared_ptr<char> demangled_name(abi::__cxa_demangle(mangled, 0, 0, nullptr), [&](char *p){\n    if (p) free(p);\n  });\n\n  return std::string(demangled_name.get());\n#else\n  return mangled;\n#endif\n}\n\n\n// the Good\n\nstruct GoodTestData {\n  struct {\n    std::map<std::string, std::string> extra_config_lines;\n  } input;\n\n  struct {\n    std::string user;\n    std::chrono::milliseconds ttl;\n    std::string metadata_cluster;\n    std::vector<TCPAddress> bootstrap_addresses;\n  } expected;\n};\n\nclass MetadataCachePluginConfigGoodTest : public ::testing::Test,\n  public ::testing::WithParamInterface<GoodTestData> {\n};\n\nnamespace mysql_harness {\n  // operator needs to be defined in the namespace of the printed type\n  std::ostream& operator<<(std::ostream& os, const TCPAddress& addr) {\n    return os << addr.str();\n  }\n}\n\ntemplate<typename T>\nstd::ostream& operator<<(std::ostream& os, const std::vector<T>& container) {\n  os << \"[\";\n  bool is_first = true;\n  for (auto &it: container) {\n    if (!is_first) os << \", \";\n    os << it;\n\n    is_first = false;\n  }\n  os << \"]\";\n  return os;\n}\n\nstd::ostream& operator<<(std::ostream& os, const GoodTestData& test_data) {\n  return os << \"user=\" << test_data.expected.user << \", \"\n    << \"ttl=\" << mysqlrouter::ms_to_seconds_string(test_data.expected.ttl) << \", \"\n    << \"metadata_cluster=\" << test_data.expected.metadata_cluster << \", \"\n    << \"bootstrap_server_addresses=\" << test_data.expected.bootstrap_addresses;\n}\n\n/**\n * check if valid configs can be parsed\n */\nTEST_P(MetadataCachePluginConfigGoodTest, GoodConfigs) {\n  GoodTestData test_data = GetParam();\n\n  mysql_harness::Config config;\n  mysql_harness::ConfigSection& section = config.add(\"metadata_cache\", \"\");\n\n  for (const std::pair<std::string, std::string>& pair: test_data.input.extra_config_lines) {\n    section.add(pair.first, pair.second);\n  }\n\n  MetadataCachePluginConfig plugin_config(&section);\n\n  EXPECT_THAT(plugin_config.user, StrEq(test_data.expected.user));\n  EXPECT_THAT(plugin_config.ttl, Eq(test_data.expected.ttl));\n  EXPECT_THAT(plugin_config.metadata_cluster, StrEq(test_data.expected.metadata_cluster));\n  EXPECT_THAT(plugin_config.bootstrap_addresses, ContainerEq(test_data.expected.bootstrap_addresses));\n}\n\nINSTANTIATE_TEST_CASE_P(SomethingUseful, MetadataCachePluginConfigGoodTest,\n  ::testing::ValuesIn(std::vector<GoodTestData>({\n    // minimal config\n    {\n      {\n        std::map<std::string, std::string>({\n          { \"user\", \"foo\" }, // required\n        })\n      },\n\n      {\n        \"foo\",\n        metadata_cache::kDefaultMetadataTTL,\n        \"\",\n        std::vector<TCPAddress>()\n      }\n    },\n    // TTL = 0.5 seconds\n    {\n      {\n        std::map<std::string, std::string>({\n          { \"user\", \"foo\", }, // required\n          { \"ttl\", \"0.5\", },\n        })\n      },\n\n      {\n        \"foo\",\n        std::chrono::milliseconds(500),\n        \"\", std::vector<TCPAddress>()\n      }\n    },\n    // TTL = 0 seconds\n    {\n      {\n        std::map<std::string, std::string>({\n          { \"user\", \"foo\", }, // required\n          { \"ttl\", \"0\", },\n        })\n      },\n      {\n        \"foo\",\n        std::chrono::milliseconds(0),\n        \"\", std::vector<TCPAddress>()\n      }\n    },\n    // TTL = 5 seconds\n    {\n      {\n        std::map<std::string, std::string>({\n          { \"user\", \"foo\", }, // required\n          { \"ttl\", \"5\", },\n        })\n      },\n      {\n        \"foo\",\n        std::chrono::milliseconds(5000),\n        \"\", std::vector<TCPAddress>()\n      }\n    },\n    // bootstrap_servers, nicely split into pieces\n    {\n      {\n        std::map<std::string, std::string>({\n          { \"user\", \"foo\", }, // required\n          { \"ttl\", \"0.5\", },\n          { \"bootstrap_server_addresses\", \"mysql://foobar,mysql://fuzzbozz\", },\n        })\n      },\n      {\n        \"foo\",\n        std::chrono::milliseconds(500),\n        \"\",\n        std::vector<TCPAddress>({\n          { TCPAddress(\"foobar\", metadata_cache::kDefaultMetadataPort), },\n          { TCPAddress(\"fuzzbozz\", metadata_cache::kDefaultMetadataPort), },\n        })\n      }\n    },\n    // bootstrap_servers, single value\n    {\n      {\n        std::map<std::string, std::string>({\n          { \"user\", \"foo\", }, // required\n          { \"bootstrap_server_addresses\", \"mysql://foobar\", },\n        })\n      },\n\n      {\n        \"foo\",\n        metadata_cache::kDefaultMetadataTTL,\n        \"\",\n        std::vector<TCPAddress>({\n          { TCPAddress(\"foobar\", metadata_cache::kDefaultMetadataPort), },\n        })\n      }\n    },\n    // metadata_cluster\n    {\n      {\n        std::map<std::string, std::string>({\n          { \"user\", \"foo\", }, // required\n          { \"ttl\", \"0.5\", },\n          { \"bootstrap_server_addresses\", \"mysql://foobar,mysql://fuzzbozz\", },\n          { \"metadata_cluster\", \"whatisthis\", },\n        })\n      },\n\n      {\n        \"foo\",\n        std::chrono::milliseconds(500),\n        \"whatisthis\",\n        std::vector<TCPAddress>({\n          { TCPAddress(\"foobar\", metadata_cache::kDefaultMetadataPort), },\n          { TCPAddress(\"fuzzbozz\", metadata_cache::kDefaultMetadataPort), },\n        })\n      }\n    },\n  })));\n\n\n// the Bad\nstruct BadTestData {\n  struct {\n    std::map<std::string, std::string> extra_config_lines;\n  } input;\n\n  struct {\n    const std::type_info &exception_type;\n    std::string exception_msg;\n  } expected;\n};\n\nclass MetadataCachePluginConfigBadTest : public ::testing::Test,\n  public ::testing::WithParamInterface<BadTestData> {\n};\n\nstd::ostream& operator<<(std::ostream& os, const BadTestData& test_data) {\n  return os << test_data.expected.exception_type.name();\n}\n\n/**\n * check if invalid configs fail properly\n */\nTEST_P(MetadataCachePluginConfigBadTest, BadConfigs) {\n  BadTestData test_data = GetParam();\n\n  mysql_harness::Config config;\n  mysql_harness::ConfigSection& section = config.add(\"metadata_cache\", \"\");\n\n  for (const std::pair<std::string, std::string>& pair: test_data.input.extra_config_lines) {\n    section.add(pair.first, pair.second);\n  }\n\n  try {\n    MetadataCachePluginConfig plugin_config(&section);\n    FAIL() << \"should have failed\";\n  } catch (const std::exception &exc) {\n    EXPECT_THAT(cxx_demangle_name(typeid(exc).name()), StrEq(cxx_demangle_name(test_data.expected.exception_type.name())));\n    EXPECT_THAT(exc.what(), StrEq(test_data.expected.exception_msg));\n  }\n}\n\nINSTANTIATE_TEST_CASE_P(SomethingUseful, MetadataCachePluginConfigBadTest,\n  ::testing::ValuesIn(std::vector<BadTestData>({\n    // user option is required\n    {\n      {\n        std::map<std::string, std::string>(),\n      },\n\n      {\n        typeid(mysqlrouter::option_not_present),\n        \"option user in [metadata_cache] is required\",\n      }\n    },\n    // ttl is garbage\n    {\n      {\n        std::map<std::string, std::string>({\n          { \"user\", \"foo\" }, // required\n          { \"ttl\", \"garbage\" },\n        }),\n      },\n      {\n        typeid(std::invalid_argument),\n        \"option ttl in [metadata_cache] needs value between 0 and 3600 inclusive, was 'garbage'\",\n      }\n    },\n    // ttl is too big\n    {\n      {\n        std::map<std::string, std::string>({\n          { \"user\", \"foo\" }, // required\n          { \"ttl\", \"3600.1\" },\n        }),\n      },\n\n      {\n        typeid(std::invalid_argument),\n        \"option ttl in [metadata_cache] needs value between 0 and 3600 inclusive, was '3600.1'\",\n      }\n    },\n    // ttl is negative\n    {\n      {\n        std::map<std::string, std::string>({\n          { \"user\", \"foo\" }, // required\n          { \"ttl\", \"-0.1\" },\n        }),\n      },\n      {\n        typeid(std::invalid_argument),\n        \"option ttl in [metadata_cache] needs value between 0 and 3600 inclusive, was '-0.1'\",\n      }\n    },\n  })));\n\nusing mysqlrouter::BasePluginConfig;\n\n// Valid millisecond configuration values\nusing GetOptionMillisecondsOkTestData = std::pair<std::string, std::chrono::milliseconds>;\n\nclass GetOptionMillisecondsOkTest : public ::testing::Test,\n  public ::testing::WithParamInterface<GetOptionMillisecondsOkTestData> {};\n\nTEST_P(GetOptionMillisecondsOkTest, StringToMilliseconds) {\n  GetOptionMillisecondsOkTestData test_data = GetParam();\n\n  ASSERT_EQ(test_data.second, BasePluginConfig::get_option_milliseconds(test_data.first));\n}\n\nINSTANTIATE_TEST_CASE_P(OkData, GetOptionMillisecondsOkTest,\n  ::testing::ValuesIn(std::vector<GetOptionMillisecondsOkTestData>({\n    { \"1.0\", std::chrono::milliseconds(1000)},\n    { \"1\", std::chrono::milliseconds(1000)},\n    { \"1.0\", std::chrono::milliseconds(1000)},\n    { \"0.001\", std::chrono::milliseconds(1)},\n    { \"0.0019\", std::chrono::milliseconds(1)},\n    { \"0.002\", std::chrono::milliseconds(2)},\n    { \"0.0020\", std::chrono::milliseconds(2)},\n    { \"0.00200\", std::chrono::milliseconds(2)},\n    { \"0.1\", std::chrono::milliseconds(100)},\n    { \"0.0009\", std::chrono::milliseconds(0)},\n    { \"0.011999\", std::chrono::milliseconds(11)},\n    { \"1.6E2\", std::chrono::milliseconds(160000)},\n    { \"1.6e2\", std::chrono::milliseconds(160000)},\n    { \"1.6E+2\", std::chrono::milliseconds(160000)},\n    { \"1.6E-2\", std::chrono::milliseconds(16)},\n    { \"1.6E-0\", std::chrono::milliseconds(1600)},\n    { \"1.6E+0\", std::chrono::milliseconds(1600)},\n    { \"0.0\", std::chrono::milliseconds(0)},\n    { \"0\", std::chrono::milliseconds(0)},\n    { \"0.00000\", std::chrono::milliseconds(0)},\n    { \"3600\", std::chrono::milliseconds(3600000)},\n    { \"3600.0\", std::chrono::milliseconds(3600000)},\n    { \"3600.0000\", std::chrono::milliseconds(3600000)},\n})));\n\n// Invalid millisecond configuration values\nusing GetOptionMillisecondsBadTestData = std::pair<std::string, std::string>;\n\nclass GetOptionMillisecondsBadTest : public ::testing::Test,\n  public ::testing::WithParamInterface<GetOptionMillisecondsBadTestData> {};\n\nTEST_P(GetOptionMillisecondsBadTest, StringToMilliseconds) {\n  GetOptionMillisecondsBadTestData test_data = GetParam();\n\n  ASSERT_THROW_LIKE(\n    BasePluginConfig::get_option_milliseconds(test_data.first, 0.0, 3600.0),\n    std::invalid_argument,\n    test_data.second\n  );\n}\n\nINSTANTIATE_TEST_CASE_P(OkData, GetOptionMillisecondsBadTest,\n  ::testing::ValuesIn(std::vector<GetOptionMillisecondsBadTestData>({\n    { \"-1.0\", \"needs value between 0 and 3600 inclusive, was '-1.0'\"},\n    { \"1,0\", \"needs value between 0 and 3600 inclusive, was '1,0'\"},\n    { \"1xx\", \"needs value between 0 and 3600 inclusive, was '1xx'\"},\n    { \"3600.1\", \"needs value between 0 and 3600 inclusive, was '3600.1'\"},\n    { \"3600.001\", \"needs value between 0 and 3600 inclusive, was '3600.001'\"},\n})));\n"
  },
  {
    "path": "src/mock_server/CMakeLists.txt",
    "content": "# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nADD_SUBDIRECTORY(src)\n"
  },
  {
    "path": "src/mock_server/include/mysqlrouter/mock_server_component.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_MOCK_SERVER_COMPONENT_INCLUDED\n#define MYSQLROUTER_MOCK_SERVER_COMPONENT_INCLUDED\n\n#include <memory>\n\n#include \"mysqlrouter/mock_server_export.h\"\n#include \"mysqlrouter/mock_server_global_scope.h\"\n\nnamespace server_mock {\n  class MySQLServerMock;\n}\n\nclass MOCK_SERVER_EXPORT MockServerComponent {\n  // disable copy, as we are a single-instance\n  MockServerComponent(MockServerComponent const &) = delete;\n  void operator=(MockServerComponent const &) = delete;\n\n  std::weak_ptr<server_mock::MySQLServerMock> srv_;\n\n  MockServerComponent() = default;\npublic:\n  static MockServerComponent& getInstance();\n\n  void init(std::shared_ptr<server_mock::MySQLServerMock> srv);\n\n  std::shared_ptr<MockServerGlobalScope> getGlobalScope();\n  void close_all_connections();\n};\n\n#endif\n"
  },
  {
    "path": "src/mock_server/include/mysqlrouter/mock_server_export.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_MOCK_SERVER_EXPORT_INCLUDED\n#define MYSQLROUTER_MOCK_SERVER_EXPORT_INCLUDED\n\n#ifdef _WIN32\n#  ifdef mock_server_DEFINE_STATIC\n#    define MOCK_SERVER_EXPORT\n#  else\n#    ifdef mock_server_EXPORTS\n#      define MOCK_SERVER_EXPORT __declspec(dllexport)\n#    else\n#      define MOCK_SERVER_EXPORT __declspec(dllimport)\n#    endif\n#  endif\n#else\n#  define MOCK_SERVER_EXPORT\n#endif\n\n#endif\n"
  },
  {
    "path": "src/mock_server/include/mysqlrouter/mock_server_global_scope.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_MOCK_SERVER_GLOBAL_SCOPE_INCLUDED\n#define MYSQLROUTER_MOCK_SERVER_GLOBAL_SCOPE_INCLUDED\n\n#include <string>\n#include <map>\n#include <mutex>\n\nclass MockServerGlobalScope {\npublic:\n  using key_type = std::string;\n  using value_type = std::string;\n  using type = std::map<key_type, value_type>;\n\n  type get_all() {\n    std::lock_guard<std::mutex> foo(global_mutex_);\n    return global_;\n  }\n\n  void set(const key_type &key, const value_type &value) {\n    std::lock_guard<std::mutex> foo(global_mutex_);\n\n    global_[key] = value;\n  }\n\n  void reset(type globals) {\n    std::lock_guard<std::mutex> foo(global_mutex_);\n    global_ = globals;\n  }\n\nprivate:\n  type global_;\n  std::mutex global_mutex_;\n};\n\n#endif\n"
  },
  {
    "path": "src/mock_server/src/CMakeLists.txt",
    "content": "# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n################################################################################\n# build JSON schema embedder, then use it to generate mysql_server_mock_schema.cc\n# (server mock dependency) from mysql_server_mock_schema.js\n################################################################################\n\n# build JSON schema embedder\nadd_executable(json_schema_embedder json_schema_embedder.cc)\n\n# generate mysql_server_mock_schema.cc, which embeds mysql_server_mock_schema.js\n# as a c-string. Server mock build will trigger this as its dependency [_HERE_]\nadd_custom_command(OUTPUT mysql_server_mock_schema.cc\n                   COMMAND json_schema_embedder\n                     ${CMAKE_CURRENT_SOURCE_DIR}/mysql_server_mock_schema.js\n                     ${CMAKE_CURRENT_BINARY_DIR}/mysql_server_mock_schema.cc)\n\n\n\n\n\n# Implementation files that include RapidJSON headers.\n# Used to supress warnings for those.\nset(json_sources json_statement_reader.cc)\ncheck_cxx_compiler_flag(\"-Wshadow\" HAVE_SHADOW)\nif(HAVE_SHADOW)\n  add_compile_flags(${json_sources} COMPILE_FLAGS \"-Wno-shadow\")\nendif()\ncheck_cxx_compiler_flag(\"-Werror\" HAVE_ERROR)\nIF(HAVE_ERROR)\n  add_compile_flags(${json_sources} COMPILE_FLAGS \"-Wno-error\")\nENDIF()\ncheck_cxx_compiler_flag(\"-Wconversion\" HAVE_CONVERSION)\nIF(HAVE_CONVERSION)\n  add_compile_flags(${json_sources} COMPILE_FLAGS \"-Wno-conversion\")\nENDIF()\ncheck_cxx_compiler_flag(\"-Wpedantic\" HAVE_PEDANTIC)\nIF(HAVE_PEDANTIC)\n  add_compile_flags(${json_sources} COMPILE_FLAGS \"-Wno-pedantic\")\nENDIF()\n\n\nset(common_libraries)\nset(math_libraries)\nif(WIN32)\n  list(APPEND common_libraries Ws2_32.lib)\nelseif(${CMAKE_SYSTEM_NAME} STREQUAL \"SunOS\")\n  list(APPEND common_libraries -lnsl -lsocket -lpthread)\n  LIST(APPEND math_libraries -lm)\nelse()\n  list(APPEND common_libraries -lpthread)\n  LIST(APPEND math_libraries -lm)\nendif()\n\n## Ubuntu 18.02 has duktape-2.2.0\nSET(DUKTAPE_SOURCE_DIR ${PROJECT_SOURCE_DIR}/ext/duktape/duktape-2.1.0/)\n\nadd_library(duktape SHARED\n  ${DUKTAPE_SOURCE_DIR}/src/duktape.c\n  ${DUKTAPE_SOURCE_DIR}/extras/logging/duk_logging.c\n  ${DUKTAPE_SOURCE_DIR}/extras/module-node/duk_module_node.c\n  )\ntarget_include_directories(duktape PUBLIC\n  ${DUKTAPE_SOURCE_DIR}/src/\n  ${DUKTAPE_SOURCE_DIR}/extras/logging/\n  ${DUKTAPE_SOURCE_DIR}/extras/module-node/\n  )\ntarget_link_libraries(duktape ${math_libraries})\n\nadd_harness_plugin(mock_server\n  NO_INSTALL\n  SOURCES json_statement_reader.cc\n  duktape_statement_reader.cc\n  mysql_protocol_decoder.cc\n  mysql_protocol_encoder.cc\n  mysql_protocol_utils.cc\n  mysql_server_mock.cc\n  mysql_server_mock_schema.cc\n  duk_module_shim.c\n  duk_node_fs.c\n  mock_server_plugin.cc\n  mock_server_component.cc\n  REQUIRES mysql_protocol;duktape)\ntarget_include_directories(mock_server PUBLIC\n  ${PROJECT_SOURCE_DIR}/src/mock_server/include/\n  ${RAPIDJSON_INCLUDE_DIRS}\n  ${DUKTAPE_SOURCE_DIR}/src/\n  ${DUKTAPE_SOURCE_DIR}/extras/logging/\n  ${DUKTAPE_SOURCE_DIR}/extras/module-node/\n  ${DUKTAPE_SOURCE_DIR}/extras/module-duktape/\n  ${PROJECT_SOURCE_DIR}/src/router/include\n  ${PROJECT_SOURCE_DIR}/src/mysql_protocol/include/\n  )\n\nadd_harness_plugin(rest_mock_server\n  NO_INSTALL\n  SOURCES rest_mock_server.cc\n  REQUIRES mock_server;http_server)\ntarget_include_directories(rest_mock_server PUBLIC\n  ${PROJECT_SOURCE_DIR}/src/http/include\n  )\n\nadd_executable(mysql_server_mock\n  main.cc\n  )\n\ntarget_link_libraries(mysql_server_mock ${common_libraries} harness-library)\nset_target_output_directory(mysql_server_mock RUNTIME_OUTPUT_DIRECTORY bin)\n"
  },
  {
    "path": "src/mock_server/src/duk_module_shim.c",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"duktape.h\"\n#include \"duk_module_duktape.h\"\n#include \"duk_module_node.h\"\n#include \"duk_module_shim.h\"\n#include \"duk_node_fs.h\"\n\n#include <string.h>\n#include <stdlib.h> // _fullpath\n#include <sys/stat.h>\n\n#ifdef _WIN32\n#include <direct.h> // getcwd\n#else\n#include <unistd.h>\n#endif\n\n#ifndef PATH_MAX\n#ifdef _MAX_PATH\n// windows has MAX_PATH instead\n#define PATH_MAX _MAX_PATH\n#endif\n#endif\n\n#ifndef STDIN_FILENO\n#define STDIN_FILENO 0\n#endif\n\n#ifndef STDOUT_FILENO\n#define STDOUT_FILENO 1\n#endif\n\n#ifndef STDERR_FILENO\n#define STDERR_FILENO 2\n#endif\n\n\n\nstatic\nduk_ret_t node_path_join(duk_context *ctx) {\n  duk_idx_t arg_count = duk_get_top(ctx);\n  duk_idx_t i;\n\n  duk_push_string(ctx, \"/\");\n  for (i = 0; i < arg_count; i++) {\n    duk_dup(ctx, i);\n  }\n  duk_join(ctx, arg_count);\n\n  return 1;\n}\n\n// normalize path\nstatic\nduk_ret_t normalize_path(duk_context *ctx, duk_idx_t obj_idx) {\n  const char *p = duk_require_string(ctx, obj_idx);\n\n#ifdef _WIN32\n  char resolved_path[_MAX_PATH];\n  duk_push_string(ctx, _fullpath(resolved_path, p, sizeof(resolved_path)));\n#else\n  char resolved_path[PATH_MAX];\n\n  duk_push_string(ctx, realpath(p, resolved_path));\n#endif\n  return 1;\n}\n\nstatic\nduk_ret_t node_format_string(duk_context *ctx) {\n  duk_idx_t arg_count = duk_get_top(ctx);\n  duk_idx_t arg_ndx = 1;\n  size_t section_count = 0;\n\n  duk_push_lstring(ctx, \"\", 0);\n  if (arg_count > 0) {\n    const char *fmt = duk_require_string(ctx, 0);\n    const char *start = NULL;\n\n    const char *s = fmt;\n    for (; s < fmt + strlen(fmt); s++) {\n      if (*s == '%') {\n        if (start) {\n          duk_push_lstring(ctx, start, s - start);\n          section_count++;\n\n          start = NULL;\n        }\n        switch (*(s + 1)) {\n        case '%':\n          duk_push_lstring(ctx, \"%\", 1);\n          section_count++;\n          s++;\n          break;\n        case 's':\n        case 'd':\n        case 'i':\n        case 'j': // TODO: json\n        case 'f':\n          duk_dup(ctx, arg_ndx++);\n          duk_safe_to_string(ctx, -1);\n          section_count++;\n          s++;\n          break;\n        default:\n          s++;\n          fprintf(stderr, \"unknown format op: %c\", *(s + 1));\n        }\n      } else {\n        if (NULL == start) start = s;\n      }\n    }\n    if (start) {\n      duk_push_lstring(ctx, start, s - start);\n      section_count++;\n    }\n  }\n\n  duk_join(ctx, section_count);\n\n  return 1;\n}\n\nstatic\nduk_ret_t node_path_resolve(duk_context *ctx) {\n  normalize_path(ctx, 0);\n  return 1;\n}\n\n\nstatic const duk_function_list_entry path_module_funcs[] = {\n  { \"join\", node_path_join, DUK_VARARGS },\n  { \"resolve\", node_path_resolve, 1 },\n  { NULL, NULL, 0 }\n};\n\nstatic\nduk_ret_t node_util_inherits(duk_context *ctx) {\n  if (DUK_EXEC_SUCCESS != duk_pcompile_string(ctx, DUK_COMPILE_FUNCTION,\n        \"function inherits(ctor, superCtor) {\\n\"\n        \"  ctor.super_ = superCtor\\n\"\n        \"  Object.setPrototypeOf(ctor.prototype, superCtor.prototype);\\n\"\n        \"});\\n\")) {\n    return duk_throw(ctx);\n  }\n  duk_dup(ctx, 0);\n  duk_dup(ctx, 1);\n  if (DUK_EXEC_SUCCESS != duk_pcall(ctx, 2)) {\n    return duk_throw(ctx);\n  }\n\n  return 1;\n};\n\nstatic const duk_function_list_entry util_module_funcs[] = {\n  { \"inherits\", node_util_inherits, 2 }\n};\n\nstatic const duk_function_list_entry fs_module_funcs[] = {\n  { NULL, NULL, 0 }\n};\n\nstatic const duk_function_list_entry events_module_funcs[] = {\n  { NULL, NULL, 0 }\n};\n\nstatic const duk_function_list_entry assert_module_funcs[] = {\n  { NULL, NULL, 0 }\n};\n\nstatic const duk_function_list_entry os_module_funcs[] = {\n  { NULL, NULL, 0 }\n};\n\nstatic\nduk_ret_t node_console_log(duk_context *ctx) {\n\n  // duk_push_lstring(ctx, \"\", 0);\n  // duk_push_string(ctx, \"WARN: \");\n  node_format_string(ctx);\n  // duk_join(ctx, 2);\n\n  puts(duk_get_string(ctx, -1));\n\n  // duk_pop(ctx);\n\n  return 0;\n}\n\nstatic const duk_function_list_entry console_module_funcs[] = {\n  { \"log\", node_console_log, DUK_VARARGS },\n  { \"warn\", node_console_log, DUK_VARARGS }\n};\n\nstatic\nduk_ret_t node_tty_isatty(duk_context *ctx) {\n#ifndef _WIN32\n  duk_push_boolean(ctx, isatty(duk_require_int(ctx, 0)));\n#else\n  duk_push_boolean(ctx, 0);\n#endif\n  return 1;\n};\n\nstatic\nduk_ret_t node_tty_getwindowsize(duk_context *ctx) {\n  duk_push_array(ctx);\n  duk_push_int(ctx, 25);\n  duk_put_prop_index(ctx, -2, 0);\n  duk_push_int(ctx, 80);\n  duk_put_prop_index(ctx, -2, 1);\n  return 1;\n};\n\n\nstatic const duk_function_list_entry tty_module_funcs[] = {\n  { \"isatty\", node_tty_isatty, 1 },\n  { \"getWindowSize\", node_tty_getwindowsize, 0 },\n  { NULL, NULL, 0 }\n};\n\nstatic\nduk_ret_t node_process_getenv(duk_context *ctx) {\n  duk_push_string(ctx, getenv(duk_require_string(ctx, 0)));\n  return 1;\n};\n\nstatic\nduk_ret_t node_process_cwd(duk_context *ctx) {\n  char current_dir[PATH_MAX];\n  duk_push_string(ctx, getcwd(current_dir, sizeof(current_dir)));\n  return 1;\n};\n\nstatic\nduk_ret_t node_process_on(duk_context *ctx) {\n  return 0;\n};\n\nstatic\nduk_ret_t node_process_remove_listener(duk_context *ctx) {\n  return 0;\n};\n\nstatic\nduk_ret_t node_process_nexttick(duk_context *ctx) {\n  duk_require_function(ctx, 0);\n\n  duk_dup(ctx, 0);\n  duk_pcall(ctx, 0);\n  return 0;\n};\n\n\nstatic const duk_function_list_entry process_module_funcs[] = {\n  { \"getenv\", node_process_getenv, 1 },\n  { \"cwd\", node_process_cwd, 0 },\n  { \"on\", node_process_on, 2 },\n  { \"removeListener\", node_process_remove_listener, 2 },\n  { \"nextTick\", node_process_nexttick, 1 },\n  { NULL, NULL, 0 }\n};\n\nstatic\nduk_ret_t node_write_stderr(duk_context *ctx) {\n  size_t buf_len;\n  const char *buf = duk_require_lstring(ctx, 0, &buf_len);\n  write(STDERR_FILENO, buf, buf_len);\n\n  return 0;\n};\n\nstatic\nduk_ret_t node_write_stdout(duk_context *ctx) {\n  size_t buf_len;\n  const char *buf = duk_require_lstring(ctx, 0, &buf_len);\n  write(STDOUT_FILENO, buf, buf_len);\n\n  return 0;\n};\n\nstatic\nduk_ret_t node_clear_timeout(duk_context *ctx) {\n  return 0;\n};\n\n\n\nstatic\nduk_ret_t dukopen_process_module(duk_context *ctx) {\n  duk_push_object(ctx);\n\n  duk_put_function_list(ctx, -1, process_module_funcs);\n\n  duk_push_object(ctx);\n  duk_push_int(ctx, STDERR_FILENO);\n  duk_put_prop_string(ctx, -2, \"fd\");\n\n  duk_push_c_function(ctx, node_write_stderr, 1);\n  duk_put_prop_string(ctx, -2, \"write\");\n\n  duk_put_prop_string(ctx, -2, \"stderr\");\n\n  duk_push_object(ctx);\n  duk_push_int(ctx, STDOUT_FILENO);\n  duk_put_prop_string(ctx, -2, \"fd\");\n\n  duk_push_c_function(ctx, node_write_stdout, 1);\n  duk_put_prop_string(ctx, -2, \"write\");\n\n  duk_put_prop_string(ctx, -2, \"stdout\");\n\n  return 1;\n}\n\nstatic\nduk_ret_t dukopen_process_module_init_env(duk_context *ctx) {\n  duk_get_global_string(ctx, \"process\");\n  if (DUK_EXEC_SUCCESS != duk_pcompile_string(ctx, DUK_COMPILE_FUNCTION, \"function () { return new Proxy({}, {get: function(targ, key, recv) {return process.getenv(key);}}); }\")) {\n    return duk_throw(ctx);\n  }\n  if (DUK_EXEC_SUCCESS != duk_pcall(ctx, 0)) {\n    return duk_throw(ctx);\n  }\n\n  duk_put_prop_string(ctx, -2, \"env\");\n\n\n  duk_push_array(ctx);\n  duk_put_prop_string(ctx, -2, \"argv\");\n\n\n  duk_pop(ctx);\n\n  return 0;\n}\n\nstatic\nduk_ret_t cb_resolve_module(duk_context *ctx) {\n  // expect module.paths in the global scope\n  // append .js, check if it exits\n  // if file is a directory:\n  //   check for package.js -> \"main\"\n  //   otherwise index.js\n  const char *module_id = duk_require_string(ctx, 0);\n  const char *parent_id = duk_require_string(ctx, 1);\n\n  // fprintf(stderr, \"%s:%d: %s\\n\", __PRETTY_FUNCTION__, __LINE__, module_id);\n  if ((0 == strcmp(module_id, \"path\")) ||\n      (0 == strcmp(module_id, \"util\")) ||\n      (0 == strcmp(module_id, \"events\")) ||\n      (0 == strcmp(module_id, \"assert\")) ||\n      (0 == strcmp(module_id, \"tty\")) ||\n      (0 == strcmp(module_id, \"os\")) ||\n      (0 == strcmp(module_id, \"fs\"))) {\n    duk_push_string(ctx, module_id);\n    return 1;\n  }\n\n  if (module_id[0] == '/') {\n    struct stat st;\n    if ((0 == stat(module_id, &st)) && (st.st_mode & S_IFMT) == S_IFREG) {\n      // file exists, leave it on the stack\n      duk_push_string(ctx, module_id);\n\n      normalize_path(ctx, -1);\n      duk_remove(ctx, -2);\n\n      return 1;\n    }\n  } else {\n    int has_parent_id = strlen(parent_id) > 0;\n\n    if (has_parent_id && module_id[0] == '.') {\n      // strip the filename from the parent's id\n      char *last_sep = strrchr(parent_id, '/');\n      if (NULL == last_sep) {\n        return duk_generic_error(ctx, \"expected / in %s\", parent_id);\n      }\n      // get the prefix of the string as base dir\n      duk_push_array(ctx);\n      duk_push_lstring(ctx, parent_id, last_sep - parent_id);\n      duk_put_prop_index(ctx, -2, 0);\n    } else {\n      duk_get_global_string(ctx, \"module\");\n      duk_get_prop_string(ctx, -1, \"paths\");\n      duk_remove(ctx, -2); // we don't need 'module' anymore\n    }\n    duk_enum(ctx, -1, DUK_ENUM_ARRAY_INDICES_ONLY);\n    duk_remove(ctx, -2); // we don't need 'paths' anymore\n\n    while (duk_next(ctx, -1, 1)) {\n      // walk the paths\n      const char *search_dir = duk_require_string(ctx, -1);\n\n      // has <module-id>?\n      duk_push_string(ctx, \"/\"); // sep\n      duk_push_string(ctx, search_dir);\n      duk_push_string(ctx, module_id); // module_id\n      duk_join(ctx, 2);\n\n      struct stat st;\n      if ((0 == stat(duk_get_string(ctx, -1), &st)) && (st.st_mode & S_IFMT) == S_IFREG) {\n        // file exists, leave it on the stack\n        duk_remove(ctx, -2); // remove value\n        duk_remove(ctx, -2); // remove key\n        duk_remove(ctx, -2); // remove enum\n\n        normalize_path(ctx, -1);\n        duk_remove(ctx, -2);\n\n        return 1;\n      }\n\n      duk_pop(ctx); // filename\n\n      // has <module-id>.js?\n      duk_push_string(ctx, \"/\"); // sep\n      duk_push_string(ctx, search_dir);\n\n      {\n        duk_push_string(ctx, \"\"); // sep\n        duk_push_string(ctx, module_id); // module_id\n        duk_push_string(ctx, \".js\");\n        duk_join(ctx, 2);\n      }\n\n      duk_join(ctx, 2);\n\n      if ((0 == stat(duk_get_string(ctx, -1), &st)) && (st.st_mode & S_IFMT) == S_IFREG) {\n        // file exists, leave it on the stack\n        duk_remove(ctx, -2); // remove value\n        duk_remove(ctx, -2); // remove key\n        duk_remove(ctx, -2); // remove enum\n\n        normalize_path(ctx, -1);\n        duk_remove(ctx, -2);\n\n        return 1;\n      }\n\n      duk_pop(ctx); // filename\n\n      // has <module-id>/package.json?\n      duk_push_string(ctx, \"/\"); // sep\n      duk_push_string(ctx, search_dir);\n      duk_push_string(ctx, module_id); // module_id\n      duk_push_string(ctx, \"package.json\");\n\n      duk_join(ctx, 3);\n\n      if ((0 == stat(duk_get_string(ctx, -1), &st)) && (st.st_mode & S_IFMT) == S_IFREG) {\n        // file exists, leave it on the stack\n        // eval it and loop for \"main\"\n\n        duk_push_c_function(ctx, duk_node_fs_read_file_sync, 1);\n        duk_dup(ctx, -2); // the path\n        if (DUK_EXEC_SUCCESS != duk_pcall(ctx, 1)) {\n          // file existed, but now we failed to opten it\n          return duk_throw(ctx); // rethrow the error\n        }\n        // we get a buffer, but want to return a string\n        duk_buffer_to_string(ctx, -1);\n        duk_json_decode(ctx, -1);\n\n        // we should have an object on the stack now\n        if (!duk_is_object(ctx, -1)) {\n          return duk_generic_error(ctx, \"expected an object in %s\", duk_get_string(ctx, -2));\n        }\n\n        duk_get_prop_string(ctx, -1, \"main\");\n        duk_remove(ctx, -2); // remove json-object\n        if (duk_is_string(ctx, -1)) {\n          const char *main_file = duk_require_string(ctx, -1);\n\n          duk_push_string(ctx, \"/\"); // sep\n          duk_push_string(ctx, search_dir);\n          duk_push_string(ctx, module_id); // module_id\n          duk_push_string(ctx, main_file);\n\n          duk_join(ctx, 3);\n\n          if ((0 == stat(duk_get_string(ctx, -1), &st)) && (st.st_mode & S_IFMT) == S_IFREG) {\n            duk_remove(ctx, -2); // remove old filename\n            duk_remove(ctx, -2); // remove value\n            duk_remove(ctx, -2); // remove key\n            duk_remove(ctx, -2); // remove enum\n\n            normalize_path(ctx, -1);\n            duk_remove(ctx, -2);\n\n            return 1;\n          }\n          duk_pop(ctx); // new filename\n\n          duk_push_string(ctx, \"/\"); // sep\n          duk_push_string(ctx, search_dir);\n          duk_push_string(ctx, module_id); // module_id\n          duk_push_string(ctx, main_file);\n          duk_push_string(ctx, \"index.js\");\n\n          duk_join(ctx, 4);\n\n          if ((0 == stat(duk_get_string(ctx, -1), &st)) && (st.st_mode & S_IFMT) == S_IFREG) {\n            duk_remove(ctx, -2); // remove old filename\n            duk_remove(ctx, -2); // remove value\n            duk_remove(ctx, -2); // remove key\n            duk_remove(ctx, -2); // remove enum\n\n            normalize_path(ctx, -1);\n            duk_remove(ctx, -2);\n\n            return 1;\n          }\n          duk_pop(ctx); // new filename\n\n\n          duk_pop(ctx); // main-file\n        } else {\n          // no main file set\n          duk_pop(ctx); // main-file\n        }\n      }\n\n      duk_pop(ctx); // filename\n\n      // has <module-id>/index.js?\n      duk_push_string(ctx, \"/\"); // sep\n      duk_dup(ctx, -2); // value\n      duk_push_string(ctx, module_id); // module_id\n      duk_push_string(ctx, \"index.js\");\n\n      duk_join(ctx, 3);\n\n      if ((0 == stat(duk_get_string(ctx, -1), &st)) && (st.st_mode & S_IFMT) == S_IFREG) {\n        // file exists, leave it on the stack\n        duk_remove(ctx, -2); // remove value\n        duk_remove(ctx, -2); // remove key\n        duk_remove(ctx, -2); // remove enum\n\n        normalize_path(ctx, -1);\n        duk_remove(ctx, -2);\n\n        return 1;\n      }\n\n      duk_pop(ctx); // filename\n\n      duk_pop(ctx); // value\n      duk_pop(ctx); // key\n    }\n\n    duk_pop(ctx); // enum\n  }\n\n  return duk_generic_error(ctx, \"Cannot find module: %s\", module_id);\n}\n\nstatic\nduk_ret_t cb_load_module(duk_context *ctx) {\n  // 0 resolved_id\n  // 1 exports\n  // 2 module\n  //\n  duk_push_array(ctx);\n  duk_put_prop_string(ctx, 2, \"paths\");\n\n  const char *resolved_id = duk_require_string(ctx, 0);\n\n  if (0 == strcmp(resolved_id, \"path\")) {\n    duk_put_function_list(ctx, 1, path_module_funcs);\n\n    duk_push_undefined(ctx);\n    return 1;\n  } else if (0 == strcmp(resolved_id, \"util\")) {\n    duk_put_function_list(ctx, 1, util_module_funcs);\n\n    duk_push_undefined(ctx);\n    return 1;\n  } else if (0 == strcmp(resolved_id, \"fs\")) {\n    duk_put_function_list(ctx, 1, fs_module_funcs);\n\n    duk_push_undefined(ctx);\n    return 1;\n  } else if (0 == strcmp(resolved_id, \"process\")) {\n    duk_put_function_list(ctx, 1, process_module_funcs);\n\n    duk_push_undefined(ctx);\n    return 1;\n  } else if (0 == strcmp(resolved_id, \"console\")) {\n    duk_put_function_list(ctx, 1, console_module_funcs);\n\n    duk_push_undefined(ctx);\n    return 1;\n  } else if (0 == strcmp(resolved_id, \"events\")) {\n    duk_push_string(ctx, \"events.js\");\n    if (DUK_EXEC_SUCCESS != duk_pcompile_string_filename(ctx, DUK_COMPILE_EVAL,\n          \"function EventEmitter() {\\n\"\n          \"  EventEmitter.init.call(this);\\n\"\n          \"};\\n\"\n          \"EventEmitter.prototype._events = undefined;\\n\"\n          \"EventEmitter.prototype.on = function(name, cb) {\\n\"\n          \"  if (this._events === undefined) {\\n\"\n          \"    this._events = Object.create(null);\\n\"\n          \"  }\\n\"\n          \"  if (!(name in this._events)) {\\n\"\n          \"    this._events[name] = [];\\n\"\n          \"  }\\n\"\n          \"  this._events[name].push(cb);\\n\"\n          \"};\\n\"\n          \"EventEmitter.init = function() {\\n\"\n          \"  if (this._events === undefined || \\n\"\n          \"      this._events == Object.getPropertyOf(this)._events) {\\n\"\n          \"    this._events = Object.create(null);\\n\"\n          \"  }\\n\"\n          \"};\\n\"\n          \"EventEmitter.prototype.once = function(name, cb) {\\n\"\n          \"  if (this._events === undefined) {\\n\"\n          \"    this._events = Object.create(null);\\n\"\n          \"  }\\n\"\n          \"  if (!(name in this._events)) {\\n\"\n          \"    this._events[name] = [];\\n\"\n          \"  }\\n\"\n          \"  this._events[name].push(cb);\\n\"\n          \"};\\n\"\n          \"EventEmitter.prototype.emit = function(typ) {\\n\"\n          \"  var args = Array.prototype.slice.call(arguments, 1);\\n\"\n          \"  if (this._events === undefined) {\\n\"\n          \"    return false;\\n\"\n          \"  }\\n\"\n          \"  if (!(typ in this._events)) {\\n\"\n          \"    return false;\\n\"\n          \"  }\\n\"\n          \"  var handlers = this._events[typ];\\n\"\n          \"  if (handlers === undefined) {\\n\"\n          \"    return false;\\n\"\n          \"  }\\n\"\n          \"  for (var ndx = 0; ndx < handlers.length; ndx++) {\\n\"\n          \"    Reflect.apply(handlers[ndx], this, args);\"\n          \"  }\\n\"\n          \"  return true;\\n\"\n          \"};\\n\"\n          // make sure eval returns it\n          \"EventEmitter;\\n\"\n          )) {\n      duk_throw(ctx);\n    }\n    if (DUK_EXEC_SUCCESS != duk_pcall(ctx, 0)) {\n      duk_throw(ctx);\n    }\n    duk_put_prop_string(ctx, 1, \"EventEmitter\");\n\n    duk_push_undefined(ctx);\n    return 1;\n  } else if (0 == strcmp(resolved_id, \"assert\")) {\n    duk_put_function_list(ctx, 1, assert_module_funcs);\n\n    duk_push_undefined(ctx);\n    return 1;\n  } else if (0 == strcmp(resolved_id, \"tty\")) {\n    duk_put_function_list(ctx, 1, tty_module_funcs);\n\n    duk_push_undefined(ctx);\n    return 1;\n  } else if (0 == strcmp(resolved_id, \"os\")) {\n    duk_put_function_list(ctx, 1, os_module_funcs);\n\n    duk_push_undefined(ctx);\n    return 1;\n  }\n\n  duk_push_c_function(ctx, duk_node_fs_read_file_sync, 1);\n  duk_push_string(ctx, resolved_id);\n  if (DUK_EXEC_SUCCESS != duk_pcall(ctx, 1)) {\n    // file existed, but now we failed to opten it\n    return duk_throw(ctx); // rethrow the error\n  }\n\n  // we get a buffer, but want to return a string\n  duk_buffer_to_string(ctx, -1);\n\n  return 1;\n}\n\nvoid duk_module_shim_init(duk_context *ctx, const char *prefix) {\n  // init the basic node-js builtins\n  duk_push_c_function(ctx, dukopen_process_module, 0);\n  duk_call(ctx, 0);\n  duk_put_global_string(ctx, \"process\");\n\n  duk_push_object(ctx);\n  duk_put_function_list(ctx, -1, console_module_funcs);\n  duk_put_global_string(ctx, \"console\");\n\n  dukopen_process_module_init_env(ctx);\n\n  duk_push_c_function(ctx, node_clear_timeout, 1);\n  duk_put_global_string(ctx, \"clearTimeout\");\n\n\n  // var _module = []\n  duk_idx_t module_ndx = duk_push_object(ctx); // module\n\n  // var _paths = []\n  duk_idx_t paths_ndx = duk_push_array(ctx); // array\n\n  // var _path = path.join(cwd, \"local_modules\");\n  duk_push_c_function(ctx, node_path_join, DUK_VARARGS);\n\n  duk_push_string(ctx, prefix);\n  duk_push_string(ctx, \"local_modules\");\n\n  duk_pcall(ctx, 2);\n\n  // _paths[0] = _path\n  duk_put_prop_index(ctx, paths_ndx, 0);\n\n  // var _path = path.join(cwd, \"npm\", \"node_modules\");\n  duk_push_c_function(ctx, node_path_join, DUK_VARARGS);\n\n  duk_push_string(ctx, prefix);\n  duk_push_string(ctx, \"npm\");\n  duk_push_string(ctx, \"node_modules\");\n\n  duk_pcall(ctx, 3);\n\n  // _paths[1] = _path\n  duk_put_prop_index(ctx, paths_ndx, 1);\n\n  // _modules[\"paths\"] = _paths\n  duk_put_prop_string(ctx, module_ndx, \"paths\");\n\n  // modules = _modules\n  duk_put_global_string(ctx, \"module\");\n\n  // as the module.paths is setup, init the module loader\n\n  duk_push_object(ctx);\n  duk_push_c_function(ctx, cb_resolve_module, DUK_VARARGS);\n  duk_put_prop_string(ctx, -2, \"resolve\");\n  duk_push_c_function(ctx, cb_load_module, DUK_VARARGS);\n  duk_put_prop_string(ctx, -2, \"load\");\n  duk_module_node_init(ctx);\n}\n\n// duktape-cli only knows about the 'duk_module_duktape_init()' call\n// provide a facade which looks the same, but calls the node-js compat\n// loader\nvoid duk_module_duktape_init(duk_context *ctx) {\n  // var cwd = getcwd()\n  duk_push_c_function(ctx, node_process_cwd, 0);\n  duk_pcall(ctx, 0);\n\n  duk_module_shim_init(ctx, duk_get_string(ctx, -1));\n  duk_pop(ctx);\n}\n"
  },
  {
    "path": "src/mock_server/src/duk_module_shim.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef DUK_MODULE_SHIM_INCLUDED\n#define DUK_MODULE_SHIM_INCLUDED\n\n#include \"duktape.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\nvoid duk_module_shim_init(duk_context *ctx, const char *prefix);\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "src/mock_server/src/duk_node_fs.c",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <stdio.h>\n#include <errno.h>\n\n#include \"duk_node_fs.h\"\n\nduk_ret_t duk_node_fs_read_file_sync(duk_context *ctx) {\n  char *buf;\n  size_t len;\n  size_t off;\n  int rc;\n  FILE *f;\n\n  const char *fn = duk_require_string(ctx, 0);\n\n  f = fopen(fn, \"rb\");\n  if (!f) {\n    return duk_error(ctx, DUK_ERR_TYPE_ERROR, \"cannot open file %s for reading, errno %ld: %s\",\n        fn, (long) errno, strerror(errno));\n  }\n\n  rc = fseek(f, 0, SEEK_END);\n  if (rc < 0) {\n    (void) fclose(f);\n    return duk_error(ctx, DUK_ERR_TYPE_ERROR, \"fseek() failed for %s, errno %ld: %s\",\n              fn, (long) errno, strerror(errno));\n  }\n  len = (size_t) ftell(f);\n  rc = fseek(f, 0, SEEK_SET);\n  if (rc < 0) {\n    (void) fclose(f);\n    return duk_error(ctx, DUK_ERR_TYPE_ERROR, \"fseek() failed for %s, errno %ld: %s\",\n              fn, (long) errno, strerror(errno));\n  }\n\n  buf = (char *) duk_push_fixed_buffer(ctx, (duk_size_t) len);\n  for (off = 0; off < len;) {\n    size_t got;\n    got = fread((void *) (buf + off), 1, len - off, f);\n    if (ferror(f)) {\n      (void) fclose(f);\n      return duk_error(ctx, DUK_ERR_TYPE_ERROR, \"error while reading %s\", fn);\n    }\n    if (got == 0) {\n      if (feof(f)) {\n        break;\n      } else {\n        (void) fclose(f);\n        return duk_error(ctx, DUK_ERR_TYPE_ERROR, \"error while reading %s\", fn);\n      }\n    }\n    off += got;\n  }\n\n  if (f) {\n    (void) fclose(f);\n  }\n\n  return 1;\n}\n"
  },
  {
    "path": "src/mock_server/src/duk_node_fs.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef DUK_NODE_FS_INCLUDED\n#define DUK_NODE_FS_INCLUDED\n\n#include \"duktape.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\nduk_ret_t duk_node_fs_read_file_sync(duk_context *ctx);\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "src/mock_server/src/duktape_statement_reader.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifdef _WIN32\n// disable the min() macro in favor of std::min() and std::numeric_limits<>::min()\n#define NOMINMAX\n#endif\n\n#include <string>\n#include <map>\n#include <functional>\n\n#include \"duktape.h\"\n#include \"duk_logging.h\"\n#include \"duk_module_shim.h\"\n#include \"duktape_statement_reader.h\"\n#include \"duk_node_fs.h\"\n#include \"mysql/harness/logging/logging.h\"\n\nIMPORT_LOG_FUNCTIONS()\n\nnamespace server_mock {\n\n/*\n * get the names of the type.\n *\n * returns a comma-seperated string\n *\n * useful for debugging\n */\nstatic\nstd::string duk_get_type_names(duk_context *ctx, duk_idx_t ndx) {\n  std::string names;\n  bool is_first = true;\n\n  std::vector<std::pair<std::function<bool(duk_context *, duk_idx_t)>, std::string>> type_checks = {\n    { duk_is_array, \"array\" },\n    { duk_is_boolean, \"boolean\" },\n    { duk_is_buffer, \"buffer\" },\n    { duk_is_buffer_data, \"buffer_data\" },\n    { duk_is_c_function, \"c-function\" },\n    { duk_is_dynamic_buffer, \"dynamic-buffer\" },\n    { [](duk_context *_ctx, duk_idx_t _ndx) -> bool { return duk_is_callable(_ctx, _ndx); }, \"callable\" },\n    { [](duk_context *_ctx, duk_idx_t _ndx) -> bool { return duk_is_error(_ctx, _ndx); }, \"error\" },\n    { duk_is_function, \"function\" },\n    { duk_is_ecmascript_function, \"ecmascript-function\" },\n    { duk_is_null, \"null\" },\n    { duk_is_number, \"number\" },\n    { duk_is_object, \"object\" },\n    { duk_is_pointer, \"pointer\" },\n    { [](duk_context *_ctx, duk_idx_t _ndx) -> bool { return duk_is_primitive(_ctx, _ndx); }, \"primitive\" },\n    { duk_is_string, \"string\" },\n    { duk_is_symbol, \"symbol\" },\n    { duk_is_thread, \"thread\" },\n    { duk_is_undefined, \"undefined\" },\n  };\n\n  for (auto &check: type_checks) {\n    if (check.first(ctx, ndx)) {\n      if (is_first) {\n        is_first = false;\n      } else {\n        names.append(\", \");\n      }\n\n      names.append(check.second);\n    }\n  }\n\n  return names;\n\n\n}\n\n\n\nclass DuktapeRuntimeError: public std::runtime_error {\npublic:\n  static std::string what_from_error(duk_context *ctx, duk_idx_t error_ndx) noexcept {\n    if (duk_is_error(ctx, error_ndx)) {\n      duk_get_prop_string(ctx, -1, \"stack\");\n      std::string err_stack { duk_safe_to_string(ctx, error_ndx) };\n      duk_pop(ctx);\n      duk_get_prop_string(ctx, -1, \"fileName\");\n      std::string err_filename { duk_safe_to_string(ctx, error_ndx) };\n      duk_pop(ctx);\n      duk_get_prop_string(ctx, -1, \"lineNumber\");\n      std::string err_fileline { duk_safe_to_string(ctx, error_ndx) };\n      duk_pop(ctx);\n\n      duk_pop(ctx); // error-obj\n\n      return \"at \" + err_filename + \":\" + err_fileline + \": \" + err_stack;\n    } else {\n      std::string err_msg { duk_safe_to_string(ctx, error_ndx) };\n\n      duk_pop(ctx); // error-obj\n\n      return err_msg;\n    }\n  }\n  DuktapeRuntimeError(duk_context *ctx, duk_idx_t error_ndx):\n    std::runtime_error{what_from_error(ctx, error_ndx)}\n  {\n  }\n};\n\n\nstruct DuktapeStatementReader::Pimpl {\n  std::string get_object_string_value(duk_idx_t idx,\n      const std::string &field,\n      const std::string &default_val = \"\",\n      bool is_required = false) {\n    std::string value;\n\n    duk_get_prop_string(ctx, idx, field.c_str());\n\n    if (duk_is_undefined(ctx, -1)) {\n      if (is_required) {\n        throw std::runtime_error(\"Wrong statements document structure: missing field \\\"\" + field  + \"\\\"\");\n      }\n\n      value = default_val;\n    } else {\n      value = duk_to_string(ctx, -1);\n    }\n\n    duk_pop(ctx);\n\n    return value;\n  }\n\n  template<class INT_TYPE>\n  typename std::enable_if<std::is_unsigned<INT_TYPE>::value, INT_TYPE>::type\n  get_object_integer_value(duk_idx_t idx,\n                                    const std::string& field,\n                                    const INT_TYPE default_val = 0,\n                                    bool is_required = false) {\n    INT_TYPE value;\n\n    duk_get_prop_string(ctx, idx, field.c_str());\n\n    if (duk_is_undefined(ctx, -1)) {\n      if (is_required) {\n        throw std::runtime_error(\"Wrong statements document structure: missing field \\\"\" + field  + \"\\\"\");\n      }\n\n      value = default_val;\n    } else if (duk_is_number(ctx, -1)) {\n      if (duk_get_number(ctx, -1) < std::numeric_limits<INT_TYPE>::min()) {\n        throw std::runtime_error(\"value out-of-range for field \\\"\" + field  + \"\\\"\");\n      }\n      if (duk_get_number(ctx, -1) > std::numeric_limits<INT_TYPE>::max()) {\n        throw std::runtime_error(\"value out-of-range for field \\\"\" + field  + \"\\\"\");\n      }\n      value = duk_to_uint(ctx, -1);\n    } else {\n      throw std::runtime_error(\"wrong type for field \\\"\" + field  + \"\\\", expected unsigned number\");\n    }\n\n    duk_pop(ctx);\n\n    return value;\n  }\n\n  std::unique_ptr<Response> get_ok(duk_idx_t idx) {\n    if (!duk_is_object(ctx, idx)) {\n      throw std::runtime_error(\"expect a object\");\n    }\n\n    return std::unique_ptr<Response>(new OkResponse(\n          get_object_integer_value<uint16_t>(-1, \"last_insert_id\", 0),\n          get_object_integer_value<uint16_t>(-1, \"warning_count\", 0)\n          ));\n  }\n\n\n  std::unique_ptr<Response> get_error(duk_idx_t idx) {\n    if (!duk_is_object(ctx, idx)) {\n      throw std::runtime_error(\"expect a object\");\n    }\n\n    return std::unique_ptr<Response>(new ErrorResponse(\n          get_object_integer_value<uint16_t>(-1, \"code\", 0, true),\n          get_object_string_value(-1, \"message\", \"\", true),\n          get_object_string_value(-1, \"sql_state\", \"HY000\")\n          ));\n  }\n\n  std::unique_ptr<Response> get_result(duk_idx_t idx) {\n    std::unique_ptr<ResultsetResponse> response(new ResultsetResponse);\n    if (!duk_is_object(ctx, idx)) {\n      throw std::runtime_error(\"expect a object\");\n    }\n    duk_get_prop_string(ctx, idx, \"columns\");\n\n    if (!duk_is_array(ctx, idx)) {\n      throw std::runtime_error(\"expect a object\");\n    }\n    // iterate over the column meta\n    duk_enum(ctx, -1, DUK_ENUM_ARRAY_INDICES_ONLY);\n    while (duk_next(ctx, -1, 1)) {\n      // @-2 column-ndx\n      // @-1 column\n      RowValueType row_values;\n\n      column_info_type column_info {\n          get_object_string_value(-1, \"name\", \"\", true),\n          column_type_from_string(get_object_string_value(-1, \"type\", \"\", true)),\n          get_object_string_value(-1, \"orig_name\"),\n          get_object_string_value(-1, \"table\"),\n          get_object_string_value(-1, \"orig_table\"),\n          get_object_string_value(-1, \"schema\"),\n          get_object_string_value(-1, \"catalog\", \"def\"),\n          get_object_integer_value<uint16_t>(-1, \"flags\"),\n          get_object_integer_value<uint8_t>(-1, \"decimals\"),\n          get_object_integer_value<uint32_t>(-1, \"length\"),\n          get_object_integer_value<uint16_t>(-1, \"character_set\", 63),\n          1 // repeat\n      };\n\n      if (duk_get_prop_string(ctx, -1, \"repeat\")) {\n        throw std::runtime_error(\"repeat is not supported\");\n      }\n      duk_pop(ctx);\n\n      response->columns.push_back(column_info);\n\n      duk_pop(ctx); // row\n      duk_pop(ctx); // row-ndx\n    }\n    duk_pop(ctx); // rows-enum\n\n    duk_pop(ctx);\n    duk_get_prop_string(ctx, idx, \"rows\");\n\n    // object|undefined\n    if (duk_is_object(ctx, -1)) {\n      // no rows\n\n      duk_enum(ctx, -1, DUK_ENUM_ARRAY_INDICES_ONLY);\n      while (duk_next(ctx, -1, 1)) {\n        // @-2 row-ndx\n        // @-1 row\n        RowValueType row_values;\n\n        duk_enum(ctx, -1, DUK_ENUM_ARRAY_INDICES_ONLY);\n        while (duk_next(ctx, -1, 1)) {\n          if (duk_is_null(ctx, -1)) {\n            row_values.push_back(std::make_pair(false, \"\"));\n          } else {\n            row_values.push_back(std::make_pair(true, duk_to_string(ctx, -1)));\n          }\n          duk_pop(ctx); // field\n          duk_pop(ctx); // field-ndx\n        }\n        duk_pop(ctx); // field-enum\n        response->rows.push_back(row_values);\n\n        duk_pop(ctx); // row\n        duk_pop(ctx); // row-ndx\n      }\n      duk_pop(ctx); // rows-enum\n    } else if (!duk_is_undefined(ctx, -1)) {\n      throw std::runtime_error(\"rows: expected array or undefined, get \" + duk_get_type_names(ctx, -1));\n    }\n\n    duk_pop(ctx); // \"rows\"\n\n    // gcc-4.8 needs a std::move, other's don't\n    return std::move(response);\n  }\n  duk_context *ctx {nullptr};\n};\n\nduk_int_t duk_peval_file(duk_context *ctx, const char *path) {\n  duk_push_c_function(ctx, duk_node_fs_read_file_sync, 1);\n  duk_push_string(ctx, path);\n  if (duk_int_t rc = duk_pcall(ctx, 1)) {\n    return rc;\n  }\n\n  duk_buffer_to_string(ctx, -1);\n  duk_push_string(ctx, path);\n  if (duk_int_t rc = duk_pcompile(ctx, DUK_COMPILE_EVAL)) {\n    return rc;\n  }\n  duk_push_global_object(ctx);\n  return duk_pcall_method(ctx, 0);\n}\n\nstatic\nduk_int_t process_get_shared(duk_context *ctx) {\n  const char *key = duk_require_string(ctx, 0);\n\n  duk_push_global_stash(ctx);\n  duk_get_prop_string(ctx, -1, \"shared\");\n  auto *shared_globals = static_cast<MockServerGlobalScope *>(duk_get_pointer(ctx, -1));\n\n  auto v = shared_globals->get_all();\n\n  auto it = v.find(key);\n  if (it == v.end()) {\n    duk_push_undefined(ctx);\n  } else {\n    auto value = (*it).second;\n    duk_push_lstring(ctx, value.c_str(), value.size());\n    duk_json_decode(ctx, -1);\n  }\n\n  duk_remove(ctx, -2); // 'shared' pointer\n  duk_remove(ctx, -2); // global stash\n\n  return 1;\n}\n\nstatic\nduk_int_t process_set_shared(duk_context *ctx) {\n  const char *key = duk_require_string(ctx, 0);\n  duk_require_valid_index(ctx, 1);\n\n  duk_push_global_stash(ctx);\n  duk_get_prop_string(ctx, -1, \"shared\");\n  auto *shared_globals = static_cast<MockServerGlobalScope *>(duk_get_pointer(ctx, -1));\n\n  if (nullptr == shared_globals) {\n    return duk_generic_error(ctx, \"shared is null\");\n  }\n\n  duk_dup(ctx, 1);\n  shared_globals->set(key, duk_json_encode(ctx, -1));\n\n  duk_pop(ctx); // the dup\n  duk_pop(ctx); // 'shared' pointer\n  duk_pop(ctx); // global\n\n  return 0;\n}\n\n/**\n * dismissable scope guard.\n *\n * used with RAII to call cleanup function if not dismissed\n *\n * allows to release resources in case exceptions are thrown\n */\nclass ScopeGuard {\npublic:\n  template<class Callable>\n  ScopeGuard(Callable &&undo_func):\n    undo_func_{std::forward<Callable>(undo_func)}\n  {\n  }\n\n  void dismiss() {\n    undo_func_ = nullptr;\n  }\n  ~ScopeGuard() {\n    if (undo_func_) undo_func_();\n  }\nprivate:\n  std::function<void()> undo_func_;\n};\n\nDuktapeStatementReader::DuktapeStatementReader(\n    const std::string &filename,\n    const std::string &module_prefix,\n    std::map<std::string, std::string> session_data,\n    std::shared_ptr<MockServerGlobalScope> shared_globals):\n  pimpl_{new Pimpl()},\n  shared_{shared_globals}\n{\n  auto *ctx = duk_create_heap_default();\n\n  // free the duk_context if an exception gets thrown as DuktapeStatementReaders's destructor\n  // will not be called in that case.\n  ScopeGuard duk_guard{[&ctx](){\n    duk_destroy_heap(ctx);\n  }};\n\n  // init module-loader\n  duk_module_shim_init(ctx, module_prefix.c_str());\n\n  duk_push_global_stash(ctx);\n  if (nullptr == shared_.get()) {\n    // why is the shared-ptr empty?\n    throw std::logic_error(\"expected shared global variable object to be set, but it isn't.\");\n  }\n\n  duk_push_pointer(ctx, shared_.get());\n  duk_put_prop_string(ctx, -2, \"shared\");\n  duk_pop(ctx); // stash\n\n  duk_get_global_string(ctx, \"process\");\n  if (duk_is_undefined(ctx, -1)) {\n    // duk_module_shim_init() is expected to initialize it.\n    throw std::runtime_error(\"expected 'process' to exist, but it is undefined.\");\n  }\n  duk_push_c_function(ctx, process_get_shared, 1);\n  duk_put_prop_string(ctx, -2, \"get_shared\");\n\n  duk_push_c_function(ctx, process_set_shared, 2);\n  duk_put_prop_string(ctx, -2, \"set_shared\");\n\n  duk_pop(ctx);\n\n  // mysqld = {\n  //   session: {\n  //     port: 3306\n  //   }\n  //   global: // proxy that calls process.get_shared()/.set_shared()\n  // }\n  duk_push_global_object(ctx);\n  duk_push_object(ctx);\n  duk_push_object(ctx);\n\n  // map of string and json-string\n  for (auto &el: session_data) {\n    duk_push_lstring(ctx, el.second.data(), el.second.size());\n    duk_json_decode(ctx, -1);\n    duk_put_prop_lstring(ctx, -2, el.first.data(), el.first.size());\n  }\n\n  duk_put_prop_string(ctx, -2, \"session\");\n\n  if (DUK_EXEC_SUCCESS != duk_pcompile_string(ctx, DUK_COMPILE_FUNCTION,\n      \"function () {\\n\"\n      \"  return new Proxy({}, {\\n\"\n      \"    get: function(targ, key, recv) {return process.get_shared(key);},\\n\"\n      \"    set: function(targ, key, val, recv) {return process.set_shared(key, val);}\\n\"\n      \"  });\\n\"\n      \"}\")) {\n    throw DuktapeRuntimeError(ctx, -1);\n  }\n  if (DUK_EXEC_SUCCESS != duk_pcall(ctx, 0)) {\n    throw DuktapeRuntimeError(ctx, -1);\n  }\n\n  duk_put_prop_string(ctx, -2, \"global\");\n\n  duk_put_prop_string(ctx, -2, \"mysqld\");\n\n  if (DUK_EXEC_SUCCESS != duk_peval_file(ctx, filename.c_str())) {\n    throw DuktapeRuntimeError(ctx, -1);\n  }\n\n  if (!duk_is_object(ctx, -1)) {\n    throw std::runtime_error(filename + \": expected statement handler to return an object, got \" + duk_get_type_names(ctx, -1));\n  }\n  duk_get_prop_string(ctx, -1, \"stmts\");\n  if (!(duk_is_callable(ctx, -1) || duk_is_thread(ctx, -1) || duk_is_array(ctx, -1))) {\n    throw std::runtime_error(\"expected 'stmts' to be one of callable, thread or array, got \" + duk_get_type_names(ctx, -1));\n  }\n\n  if (duk_is_array(ctx, -1)) {\n    duk_enum(ctx, -1, DUK_ENUM_ARRAY_INDICES_ONLY);\n  }\n\n  // we are still alive, dismiss the guard\n  pimpl_->ctx = ctx;\n  duk_guard.dismiss();\n}\n\nDuktapeStatementReader::~DuktapeStatementReader() {\n  // duk_pop(pimpl_->ctx);\n\n  if (pimpl_->ctx) duk_destroy_heap(pimpl_->ctx);\n}\n\nStatementAndResponse DuktapeStatementReader::handle_statement(const std::string &statement) {\n  auto *ctx = pimpl_->ctx;\n  bool is_enumable = false;\n\n  if (duk_is_thread(ctx, -1)) {\n    if (DUK_EXEC_SUCCESS != duk_pcompile_string(ctx, DUK_COMPILE_FUNCTION, \"function (t, stmt) { return Duktape.Thread.resume(t, stmt); }\")) {\n      throw DuktapeRuntimeError(ctx, -1);\n    }\n    duk_dup(ctx, -2); // the thread\n    duk_push_lstring(ctx, statement.c_str(), statement.size());\n\n    if (DUK_EXEC_SUCCESS != duk_pcall(ctx, 2)) {\n      throw DuktapeRuntimeError(ctx, -1);\n    }\n    // @-1 result of resume\n  } else if (duk_is_callable(ctx, -1)) {\n    duk_dup(ctx, -1); // copy the function to keep it on the stack for the next run\n    duk_push_lstring(ctx, statement.c_str(), statement.size());\n\n    if (DUK_EXEC_SUCCESS != duk_pcall(ctx, 1)) {\n      throw DuktapeRuntimeError(ctx, -1);\n    }\n  } else {\n    if (!duk_is_object(ctx, -1)) { // enumarator is an object\n      throw std::runtime_error(\"expected 'stmts' enumerator to be an object, got \" + duk_get_type_names(ctx, -1));\n    }\n\n    // @-1 is an enumarator\n    if (0 == duk_next(ctx, -1, true)) {\n      duk_pop(ctx);\n      return {};\n    }\n    // @-3 is an enumarator\n    // @-2 is key\n    // @-1 is value\n    is_enumable = true;\n  }\n\n  // value must be an object\n  if (!duk_is_object(ctx, -1)) {\n    throw std::runtime_error(\"expected 'stmts' to return an 'object', got \" + duk_get_type_names(ctx, -1));\n  }\n\n  StatementAndResponse response;\n  duk_get_prop_string(ctx, -1, \"exec_time\");\n  if (!duk_is_undefined(ctx, -1)) {\n    if (!duk_is_number(ctx, -1)) {\n      throw std::runtime_error(\"exec_time must be a number, if set, get \" + duk_get_type_names(ctx, -1));\n    }\n    if (duk_get_number(ctx, -1) < 0) {\n      throw std::out_of_range(\"exec_time must be a non-negative number\");\n    }\n\n    // exec-time is written in the tracefile as microseconds\n    response.exec_time = std::chrono::microseconds(static_cast<long>(duk_get_number(ctx, -1) * 1000));\n  }\n  duk_pop(ctx);\n\n\n  duk_get_prop_string(ctx, -1, \"result\");\n  if (!duk_is_undefined(ctx, -1)) {\n    response.response_type = StatementAndResponse::StatementResponseType::STMT_RES_RESULT;\n    response.response = pimpl_->get_result(-1);\n  } else {\n    duk_pop(ctx); // result\n    duk_get_prop_string(ctx, -1, \"error\");\n    if (!duk_is_undefined(ctx, -1)) {\n      response.response_type = StatementAndResponse::StatementResponseType::STMT_RES_ERROR;\n      response.response = pimpl_->get_error(-1);\n    } else {\n      duk_pop(ctx); // error\n      duk_get_prop_string(ctx, -1, \"ok\");\n      if (!duk_is_undefined(ctx, -1)) {\n        response.response_type = StatementAndResponse::StatementResponseType::STMT_RES_OK;\n        response.response = pimpl_->get_ok(-1);\n      } else {\n        throw std::runtime_error(\"expected 'error', 'ok' or 'result'\");\n      }\n    }\n  }\n  duk_pop(ctx); // last prop\n\n  duk_pop(ctx); // value\n  if (is_enumable) {\n    duk_pop(ctx); // key\n  }\n\n  return response;\n}\n\nstd::chrono::microseconds DuktapeStatementReader::get_default_exec_time() {\n  return std::chrono::microseconds{0};\n}\n\n}\n"
  },
  {
    "path": "src/mock_server/src/duktape_statement_reader.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLD_MOCK_DUKTAPE_STATEMENT_READER_INCLUDED\n#define MYSQLD_MOCK_DUKTAPE_STATEMENT_READER_INCLUDED\n\n#include <string>\n#include <map>\n\n#include \"mysqlrouter/mock_server_global_scope.h\"\n#include \"statement_reader.h\"\n\nnamespace server_mock {\nclass DuktapeStatementReader: public StatementReaderBase {\npublic:\n  DuktapeStatementReader(const std::string &filename,\n      const std::string &module_prefix,\n      std::map<std::string, std::string> session_data,\n      std::shared_ptr<MockServerGlobalScope> shared_globals);\n\n  StatementAndResponse handle_statement(const std::string &statement) override;\n\n  std::chrono::microseconds get_default_exec_time() override;\n\n  ~DuktapeStatementReader();\nprivate:\n  struct Pimpl;\n  std::unique_ptr<Pimpl> pimpl_;\n  std::shared_ptr<MockServerGlobalScope> shared_;\n};\n}\n\n#endif\n"
  },
  {
    "path": "src/mock_server/src/json_schema_embedder.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <cerrno>\n#include <cstdio>\n#include <cstring> // strerror()\n#include <stdexcept>\n#include <string>\n\n/**\n * This program takes a text file as input (presumably a JSON schema), and writes\n * a .cc file as output, which contains contents of the input file as an array\n * of chars. You can think of it as our own customised version of 'xxd -i' Unix\n * command.\n */\n\nint main(int argc, const char** argv) {\n\n  auto throw_error = [&](const std::string& msg, const std::string& filename ) {\n    throw std::runtime_error(msg + \" '\" + filename + \"': \" + strerror(errno));\n  };\n\n  try {\n\n    // get commandline args\n    if (argc != 3)\n      throw std::runtime_error(std::string(\"USAGE: \") + argv[0] + \" <in_file> <out_file>\");\n    const char* in_filename = argv[1];\n    const char* out_filename = argv[2];\n\n    // open input and output files\n    FILE* in_file;\n    FILE* out_file;\n    if (!(in_file = fopen(in_filename, \"r\")))\n      throw_error(\"Failed to open input file\", in_filename);\n    if (!(out_file = fopen(out_filename, \"w\")))\n      throw_error(\"Failed to open output file\", out_filename);\n\n    // write commend and 1st part of the array definition\n    if (!fprintf(\n        out_file,\n        \"// This file was auto-generated during CMake build process, using command:\\n\"\n        \"//\\n\"\n        \"//   %s %s %s\\n\"\n        \"//\\n\"\n        \"// (see \" __FILE__ \")\\n\"\n        \"\\n\"\n        \"extern const char kSqlQueryJsonSchema[] = {\\n\",\n        argv[0], argv[1], argv[2]\n      ))\n      throw_error(\"Failed writing output file\", out_filename);\n\n    // write array elements\n    int cnt = 0;\n    while(true) {\n\n      // read char and write it as array element; break loop on EOF or throw on I/O error\n      char c;\n      if (fread(&c, 1, 1, in_file)) {\n        if (!fprintf(out_file, \"0x%02x, \", c))\n          throw_error(\"Failed writing output file\", out_filename);\n      } else {\n        if (feof(in_file))\n          break;\n        else\n          throw_error(\"Failed reading input file\", in_filename);\n      }\n\n      // line break every 16th element\n      if ((cnt++ & 0xf) == 0xf)\n        if(!fprintf(out_file, \"\\n\"))\n          throw_error(\"Failed writing output file\", out_filename);\n    }\n\n    // write last part of array definition\n    if (!fprintf(out_file, \"0x00 };\\n\"))  // 0x00 is the string terminator\n      throw_error(\"Failed writing output file\", out_filename);\n\n    // close files\n    if (fclose(in_file))\n      throw_error(\"Failed closing input file\", in_filename);\n    if (fclose(out_file))\n      throw_error(\"Failed closing output file\", out_filename);\n\n    return 0;\n\n  } catch (const std::exception& e) {\n    fprintf(stderr, \"%s\\n\", e.what());\n    return 1;\n  }\n}\n\n"
  },
  {
    "path": "src/mock_server/src/json_statement_reader.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"json_statement_reader.h\"\n\n#ifdef RAPIDJSON_NO_SIZETYPEDEFINE\n// if we build within the server, it will set RAPIDJSON_NO_SIZETYPEDEFINE globally\n// and require to include my_rapidjson_size_t.h\n#include \"my_rapidjson_size_t.h\"\n#endif\n\n#include \"rapidjson/document.h\"\n#include \"rapidjson/error/en.h\"\n#include \"rapidjson/filereadstream.h\"\n#include \"rapidjson/schema.h\"\n#include \"rapidjson/stringbuffer.h\"\n#include <cassert>\n#include <cerrno>\n#include <chrono>\n#include <memory>\n\n#include \"mysql_server_mock_schema.h\"\n\n#ifdef _WIN32\n#  include <regex>\n#else\n#  include <regex.h>\n#endif\n#include \"mysql_protocol_encoder.h\"\n\nnamespace {\n\n// default allocator for rapidJson (MemoryPoolAllocator) is broken for SparcSolaris\nusing JsonDocument = rapidjson::GenericDocument<rapidjson::UTF8<>,  rapidjson::CrtAllocator>;\nusing JsonValue = rapidjson::GenericValue<rapidjson::UTF8<>,  rapidjson::CrtAllocator>;\nusing JsonSchemaDocument = rapidjson::GenericSchemaDocument<JsonValue, rapidjson::CrtAllocator>;\nusing JsonSchemaValidator = rapidjson::GenericSchemaValidator<JsonSchemaDocument>;\n\nstd::string get_json_value_as_string(const JsonValue& value, size_t repeat = 1) {\n  if (value.IsString()) {\n    const std::string val = value.GetString();\n    std::string result;\n    if (val.empty()) return val;\n    result.reserve(val.length() * repeat);\n\n    for (size_t i = 0; i < repeat; ++i) {\n      result += val;\n    }\n\n    return result;\n  }\n  if (value.IsNull()) return \"\";\n  if (value.IsInt()) return std::to_string(value.GetInt());\n  if (value.IsUint()) return std::to_string(value.GetUint());\n  if (value.IsDouble()) return std::to_string(value.GetDouble());\n  // TODO: implement other types when needed\n\n  throw(std::runtime_error(\"Unsupported json value type: \"\n                           + std::to_string(static_cast<int>(value.GetType()))));\n}\n\nstd::string get_json_string_field(const JsonValue& parent,\n                                  const std::string& field,\n                                  const std::string& default_val = \"\",\n                                  bool required = false) {\n  const bool found = parent.HasMember(field.c_str());\n  if (!found) {\n    harness_assert(!required);  // schema should have caught this\n    return default_val;\n  }\n\n  harness_assert(parent[field.c_str()].IsString());  // schema should have caught this\n\n  return parent[field.c_str()].GetString();\n}\n\ndouble get_json_double_field(const JsonValue& parent,\n                             const std::string& field,\n                             const double default_val = 0.0,\n                             bool required = false) {\n  const bool found = parent.HasMember(field.c_str());\n  if (!found) {\n    harness_assert(!required);  // schema should have caught this\n    return default_val;\n  }\n\n  harness_assert(parent[field.c_str()].IsDouble());  // schema should have caught this\n  return parent[field.c_str()].GetDouble();\n}\n\ntemplate<class INT_TYPE>\nINT_TYPE get_json_integer_field(const JsonValue& parent,\n                                  const std::string& field,\n                                  const INT_TYPE default_val = 0,\n                                  bool required = false) {\n  const bool found = parent.HasMember(field.c_str());\n  if (!found) {\n    harness_assert(!required);  // schema should have caught this\n    return default_val;\n  }\n\n  harness_assert(parent[field.c_str()].IsInt());  // schema should have caught this\n\n  return static_cast<INT_TYPE>(parent[field.c_str()].GetInt());\n}\n\n} // namspace {}\n\nnamespace server_mock {\n\nstruct QueriesJsonReader::Pimpl {\n\n  JsonDocument json_document_;\n  size_t current_stmt_{0u};\n\n  // load queries JSON; throws std::runtime_error on invalid JSON file\n  Pimpl(const std::string& json_filename): json_document_(load_json_from_file(json_filename)) {}\n\n  static JsonDocument load_json_from_file(const std::string& filename);\n  static void validate_json_against_schema(const JsonSchemaDocument& schema, const JsonDocument& json);\n\n  std::unique_ptr<Response> read_result_info(const JsonValue& stmt);\n  std::unique_ptr<Response> read_ok_info(const JsonValue& stmt);\n  std::unique_ptr<Response> read_error_info(const JsonValue& stmt);\n};\n\nQueriesJsonReader::QueriesJsonReader(const std::string &json_filename):\n              pimpl_(new Pimpl(json_filename)) {\n\n  // construct schema JSON; throws std::runtime_error on invalid JSON, but note\n  // that invalid schema will slip by without throwing (but it will cause\n  // validate_json_against_schema() to fail later on)\n  JsonDocument schema_json;\n  if(schema_json.Parse<rapidjson::kParseCommentsFlag>(kSqlQueryJsonSchema).HasParseError())\n    throw std::runtime_error(\"Parsing JSON schema failed at offset \"\n                             + std::to_string(schema_json.GetErrorOffset()) + \": \"\n                             + rapidjson::GetParseError_En(schema_json.GetParseError()));\n  JsonSchemaDocument schema(schema_json);\n\n  // validate JSON against schema; throws std::runtime if validation fails\n  try {\n    pimpl_->validate_json_against_schema(schema, pimpl_->json_document_);\n  } catch (const std::runtime_error& e) {\n    // TODO: we could also get here if schema itself is not valid. To diagnose that,\n    //       another validate_json_against_schema() could be ran here to validate our\n    //       schema against schema spec (http://json-schema.org/draft-04/schema#)\n\n    throw std::runtime_error(\"JSON file '\" + json_filename +\n                             \"' failed validation against JSON schema:\\n\" + e.what());\n  }\n\n  // schema should have caught these\n  harness_assert(pimpl_->json_document_.HasMember(\"stmts\"));\n  harness_assert(pimpl_->json_document_[\"stmts\"].IsArray());\n}\n\n// this is needed for pimpl, otherwise compiler complains\n// about pimpl unknown size in std::unique_ptr\nQueriesJsonReader::~QueriesJsonReader() = default;\n\n// throws std::runtime_error on\n// - file read error\n// - JSON parse error\n/*static*/ JsonDocument QueriesJsonReader::Pimpl::load_json_from_file(const std::string& filename) {\n\n  // This DOES NOT have to be big enough to contain the entire JSON file.\n  // In such case, FileReadStream will automatically read more from the file\n  // once it reaches end of buffer.\n  constexpr size_t kMaxFileSize = 64 * 1024;\n\n  // open JSON file\n#ifndef _WIN32\n  FILE* fp = fopen(filename.c_str(), \"rb\"); // after rapidjson doc\n#else\n  FILE* fp = fopen(filename.c_str(), \"r\");\n#endif\n  if (!fp) {\n    throw std::runtime_error(\"Could not open JSON file '\" + filename\n                             + \"' for reading: \" + strerror(errno));\n  }\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){fclose(fp);});\n\n  // read JSON file\n  char readBuffer[kMaxFileSize];\n  rapidjson::FileReadStream is(fp, readBuffer, sizeof(readBuffer));\n\n  // ensure file is a valid JSON file\n  JsonDocument json;\n  if (json.ParseStream<rapidjson::kParseCommentsFlag>(is).HasParseError()) {\n    throw std::runtime_error(\"Parsing JSON file '\" + filename + \"' failed at offset \"\n                             + std::to_string(json.GetErrorOffset()) + \": \"\n                             + rapidjson::GetParseError_En(json.GetParseError()));\n  }\n\n  return json;\n}\n\n//throws std::runtime_error on failed validation\n/*static*/\nvoid QueriesJsonReader::Pimpl::validate_json_against_schema(const JsonSchemaDocument& schema,\n                                                            const JsonDocument& json) {\n  // verify JSON against the schema\n  JsonSchemaValidator validator(schema);\n  if (!json.Accept(validator)) {\n    // validation failed - throw an error with info of where the problem is\n    rapidjson::StringBuffer sb_schema;\n    validator.GetInvalidSchemaPointer().StringifyUriFragment(sb_schema);\n    rapidjson::StringBuffer sb_json;\n    validator.GetInvalidDocumentPointer().StringifyUriFragment(sb_json);\n    throw std::runtime_error(\n      std::string(\"Failed schema directive: \") + sb_schema.GetString() +\n      \"\\nFailed schema keyword:   \" + validator.GetInvalidSchemaKeyword() +\n      \"\\nFailure location in validated document: \" + sb_json.GetString() + \"\\n\"\n    );\n  }\n}\n\nnamespace {\n\nbool pattern_matching(const std::string &s,\n                      const std::string &pattern) {\n#ifndef _WIN32\n  regex_t regex;\n  auto r = regcomp(&regex, pattern.c_str(), REG_EXTENDED);\n  if (r) {\n    throw std::runtime_error(\"Error compiling regex pattern: \" + pattern);\n  }\n  r = regexec(&regex, s.c_str(), 0, NULL, 0);\n  regfree(&regex);\n  return (r == 0);\n#else\n  std::regex regex(pattern);\n  return std::regex_match(s, regex);\n#endif\n}\n\n} // unnamed namespace\n\n\nStatementAndResponse QueriesJsonReader::handle_statement(const std::string &statement_received) {\n  StatementAndResponse response;\n\n  const JsonValue& stmts = pimpl_->json_document_[\"stmts\"];\n  if (pimpl_->current_stmt_ >= stmts.Size()) return response;\n\n  auto& stmt = stmts[pimpl_->current_stmt_++];\n  harness_assert(stmt.HasMember(\"stmt\") || stmt.HasMember(\"stmt.regex\"));  // schema should have caught this\n\n  if (stmt.HasMember(\"exec_time\")) {\n    double exec_time = get_json_double_field(stmt, \"exec_time\", 0.0);\n    response.exec_time = std::chrono::microseconds(static_cast<long>(exec_time * 1000));\n  }\n  else {\n    response.exec_time = get_default_exec_time();\n  }\n\n  bool statement_is_regex = false;\n  std::string name{\"stmt\"};\n  if (stmt.HasMember(\"stmt.regex\")) {\n    name = \"stmt.regex\";\n    statement_is_regex = true;\n  }\n\n  harness_assert(stmt[name.c_str()].IsString());  // schema should have caught this\n\n  std::string statement = stmt[name.c_str()].GetString();\n\n  bool statement_matching{false};\n  if (!statement_is_regex) { // not regex\n    statement_matching = (statement_received == statement);\n  } else { // regex\n    statement_matching = pattern_matching(statement_received,\n                                          statement);\n  }\n\n  if (!statement_matching) {\n    response.response_type = StatementAndResponse::StatementResponseType::STMT_RES_ERROR;\n    response.response.reset(new ErrorResponse(MYSQL_PARSE_ERROR,\n        std::string(\"Unexpected stmt, got: \\\"\") + statement_received +\n        \"\\\"; expected: \\\"\" + statement + \"\\\"\"));\n  } else if (stmt.HasMember(\"ok\")) {\n    response.response_type = StatementAndResponse::StatementResponseType::STMT_RES_OK;\n    response.response = pimpl_->read_ok_info(stmt);\n  } else if (stmt.HasMember(\"error\")) {\n    response.response_type = StatementAndResponse::StatementResponseType::STMT_RES_ERROR;\n    response.response = pimpl_->read_error_info(stmt);\n  } else if (stmt.HasMember(\"result\")) {\n    response.response_type = StatementAndResponse::StatementResponseType::STMT_RES_RESULT;\n    response.response = pimpl_->read_result_info(stmt);\n  } else {\n    harness_assert_this_should_not_execute(); // schema should have caught this\n  }\n\n  return response;\n}\n\nstd::chrono::microseconds QueriesJsonReader::get_default_exec_time() {\n\n  if (pimpl_->json_document_.HasMember(\"defaults\")) {\n    auto& defaults = pimpl_->json_document_[\"defaults\"];\n    if (defaults.HasMember(\"exec_time\")) {\n      double exec_time = get_json_double_field(defaults, \"exec_time\", 0.0);\n      return std::chrono::microseconds(static_cast<long>(exec_time * 1000));\n    }\n  }\n  return std::chrono::microseconds(0);\n}\n\nstd::unique_ptr<Response> QueriesJsonReader::Pimpl::read_result_info(const JsonValue &stmt) {\n  // only asserting as this should have been checked before if we got here\n  assert(stmt.HasMember(\"result\"));\n\n  const auto& result = stmt[\"result\"];\n\n  std::unique_ptr<ResultsetResponse> response(new ResultsetResponse);\n\n  // read columns\n  if (result.HasMember(\"columns\")) {\n    const auto& columns = result[\"columns\"];\n    harness_assert(columns.IsArray());  // schema should have caught this\n\n    for (size_t i = 0; i < columns.Size(); ++i) {\n      auto& column = columns[i];\n      column_info_type column_info {\n          get_json_string_field(column, \"name\", \"\", true),\n          column_type_from_string(get_json_string_field(column, \"type\", \"\", true)),\n          get_json_string_field(column, \"orig_name\"),\n          get_json_string_field(column, \"table\"),\n          get_json_string_field(column, \"orig_table\"),\n          get_json_string_field(column, \"schema\"),\n          get_json_string_field(column, \"catalog\", \"def\"),\n          get_json_integer_field<uint16_t>(column, \"flags\"),\n          get_json_integer_field<uint8_t>(column, \"decimals\"),\n          get_json_integer_field<uint32_t>(column, \"length\"),\n          get_json_integer_field<uint16_t>(column, \"character_set\", 63),\n          get_json_integer_field<unsigned>(column, \"repeat\", 1)\n      };\n\n      response->columns.push_back(column_info);\n    }\n  }\n\n  // read rows\n  if (result.HasMember(\"rows\")) {\n    const auto& rows = result[\"rows\"];\n    harness_assert(rows.IsArray());  // schema should have caught this\n\n    auto columns_size = response->columns.size();\n\n    for (size_t i = 0; i < rows.Size(); ++i) {\n      auto& row = rows[i];\n      harness_assert(row.IsArray());  // schema should have caught this\n\n      // this check cannot be performed by validating against schema, thus we need it in code\n      if (row.Size() != columns_size) {\n        throw std::runtime_error(std::string(\"Wrong statements document structure: \") +\n            \"number of row fields different than number of columns \" +\n            std::to_string(row.Size()) + \" != \" + std::to_string(columns_size));\n      }\n\n      RowValueType row_values;\n      for (size_t j = 0; j < row.Size(); ++j) {\n        auto& column_info = response->columns[j];\n        const size_t repeat = static_cast<size_t>(column_info.repeat);\n        if (row[j].IsNull()) {\n          row_values.push_back(std::make_pair(false, \"\"));\n        } else {\n          row_values.push_back(std::make_pair(true, get_json_value_as_string(row[j], repeat)));\n        }\n      }\n\n      response->rows.push_back(row_values);\n    }\n  }\n\n  return std::move(response);\n}\n\nstd::unique_ptr<Response> QueriesJsonReader::Pimpl::read_ok_info(const JsonValue &stmt) {\n  // only asserting as this should have been checked before if we got here\n  assert(stmt.HasMember(\"ok\"));\n\n  const auto& f_ok = stmt[\"ok\"];\n\n  return std::unique_ptr<Response>(new OkResponse(\n    get_json_integer_field<unsigned int>(f_ok, \"last_insert_id\", 0),\n    get_json_integer_field<unsigned int>(f_ok, \"warnings\", 0)));\n}\n\nstd::unique_ptr<Response> QueriesJsonReader::Pimpl::read_error_info(const JsonValue &stmt) {\n  // only asserting as this should have been checked before if we got here\n  assert(stmt.HasMember(\"error\"));\n\n  const auto& f_error = stmt[\"error\"];\n\n  return std::unique_ptr<Response>(new ErrorResponse(\n    get_json_integer_field<unsigned int>(f_error, \"code\", 0, true),\n    get_json_string_field(f_error, \"message\", \"unknown error-msg\"),\n    get_json_string_field(f_error, \"sql_state\", \"HY000\")));\n}\n\n\n\n} // namespace server_mock\n"
  },
  {
    "path": "src/mock_server/src/json_statement_reader.h",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLD_MOCK_JSON_STATEMENT_READER_INCLUDED\n#define MYSQLD_MOCK_JSON_STATEMENT_READER_INCLUDED\n\n#include <chrono>\n#include <map>\n#include <memory>\n#include <string>\n#include <vector>\n\n#include \"statement_reader.h\"\n\nnamespace server_mock {\n\n/** @class QueriesJsonReader\n *\n * @brief  Responsible for reading the json file with\n *         the expected statements and simplifying the data\n *         structures used by RapidJSON into vectors.\n **/\nclass QueriesJsonReader: public StatementReaderBase {\n public:\n\n  /** @brief Constructor.\n   *\n   * @param filename Path to the json file with definitins\n   *         of the expected SQL statements and responses\n   **/\n  QueriesJsonReader(const std::string &filename);\n\n  /** @brief Returns the data about the next statement from the\n   *         json file. If there is no more statements it returns\n   *         empty statement.\n   **/\n  StatementAndResponse handle_statement(const std::string &statement) override;\n\n  /** @brief Returns the default execution time in microseconds. If\n   *         no default execution time is provided in json file, then\n   *         0 microseconds is returned.\n   **/\n  std::chrono::microseconds get_default_exec_time() override;\n\n  virtual ~QueriesJsonReader();\nprivate:\n  // This is to avoid including RapidJSON headers here, which would cause\n  // them included also in other files (they give tons of warnings, which\n  // better suppres only for single implementation file).\n  struct Pimpl;\n  std::unique_ptr<Pimpl> pimpl_;\n};\n\n\n} // namespace\n\n#endif // MYSQLD_MOCK_JSON_STATEMENT_READER_INCLUDED\n"
  },
  {
    "path": "src/mock_server/src/main.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <iostream>\n#include <sstream>\n#ifdef _WIN32\n#  define WIN32_LEAN_AND_MEAN\n#  include <winsock2.h>\n#  include <direct.h>  // getcwd\n#else\n#  include <unistd.h>  // getcwd\n#  include <limits.h>  // PATH_MAX\n#endif\n\n#include \"dim.h\"\n#include \"mysql/harness/arg_handler.h\"\n#include \"mysql/harness/loader.h\"\n#include \"mysql/harness/loader_config.h\"\n#include \"mysql/harness/logging/registry.h\"\n\n#ifndef PATH_MAX\n#ifdef _MAX_PATH\n// windows has _MAX_PATH instead\n#define PATH_MAX _MAX_PATH\n#endif\n#endif\n\nconstexpr unsigned kHelpScreenWidth = 72;\nconstexpr unsigned kHelpScreenIndent = 8;\n\nstruct MysqlServerMockConfig {\n  std::string queries_filename;\n  std::string module_prefix;\n  unsigned port { 3306 };\n  unsigned http_port { 0 };\n  bool verbose { false };\n};\n\nstatic void init_DIM() {\n  mysql_harness::DIM& dim = mysql_harness::DIM::instance();\n\n  // logging facility\n  dim.set_LoggingRegistry(\n    []() {\n      static mysql_harness::logging::Registry registry;\n      return &registry;\n    },\n    [](mysql_harness::logging::Registry*){}  // don't delete our static!\n  );\n}\n\nclass MysqlServerMockFrontend {\npublic:\n  std::string get_version_line() {\n    return MYSQL_ROUTER_VERSION;\n  }\n\n  std::string get_help() {\n    std::stringstream os;\n\n    for (auto line: arg_handler_.usage_lines(\"Usage: mysql_server_mock\", \"\", kHelpScreenWidth)) {\n      os << line << std::endl;\n    }\n\n    os << \"\\nOptions:\" << std::endl;\n    for (auto line: arg_handler_.option_descriptions(kHelpScreenWidth, kHelpScreenIndent)) {\n      os << line << std::endl;\n    }\n\n    return os.str();\n  }\n\n  MysqlServerMockConfig init_from_arguments(const std::vector<std::string> &arguments) {\n    program_name_ = arguments[0];\n    origin_dir_ = mysql_harness::Path(program_name_).dirname();\n\n    prepare_command_options();\n    arg_handler_.process(std::vector<std::string>{arguments.begin() + 1, arguments.end()});\n\n    return config_;\n  }\n\n  bool is_print_and_exit() {\n    return do_print_and_exit_;\n  }\n\n  void run() {\n    std::unique_ptr<mysql_harness::Loader> loader_;\n\n    init_DIM();\n    mysql_harness::LoaderConfig loader_config(mysql_harness::Config::allow_keys);\n\n    mysql_harness::DIM& dim = mysql_harness::DIM::instance();\n    mysql_harness::logging::Registry& registry = dim.get_LoggingRegistry();\n\n    mysql_harness::Config config;\n\n    // NOTE: See where g_HACK_default_log_level is set in production code to understand\n    // the hack. One day we will want to revert to something analogous to what we had before.\n    // Original code looked like this:\n    //   config.set_default(mysql_harness::logging::kConfigOptionLogLevel, \"debug\");\n    if (config_.verbose) {\n      mysql_harness::logging::g_HACK_default_log_level = \"debug\";\n    } else {\n      mysql_harness::logging::g_HACK_default_log_level = \"warning\";\n    }\n\n    mysql_harness::logging::clear_registry(registry);\n    mysql_harness::logging::init_loggers(registry, config,\n        {mysql_harness::logging::kMainLogger, \"mock_server\", \"http_server\", \"\", \"rest_mock_server\"},\n        mysql_harness::logging::kMainLogger);\n    mysql_harness::logging::create_main_logfile_handler(registry, \"\", \"\", true);\n\n    registry.set_ready();\n\n    if (config_.module_prefix.empty()) {\n      char cwd[PATH_MAX];\n\n      if (nullptr == getcwd(cwd, sizeof(cwd))) {\n        throw std::system_error(errno, std::generic_category());\n      }\n\n      config_.module_prefix = cwd;\n    }\n\n    // log to stderr\n    loader_config.set_default(\"logging_folder\", \"\");\n\n    // assume all path relative to the installed binary\n    auto base_path = mysql_harness::Path(origin_dir_).join(\"..\");\n    loader_config.set_default(\"plugin_folder\", mysql_harness::Path(base_path).join(\"lib\")\n#ifndef _WIN32\n        .join(\"mysqlrouter\")\n#endif\n        .str());\n\n    // those are unused, but must be set\n    loader_config.set_default(\"runtime_folder\", mysql_harness::Path(base_path).join(\"var\").join(\"lib\").str());\n    loader_config.set_default(\"config_folder\", mysql_harness::Path(base_path).join(\"etc\").str());\n    loader_config.set_default(\"data_folder\", mysql_harness::Path(base_path).join(\"var\").join(\"share\").str());\n\n    if (config_.http_port != 0) {\n      auto &rest_mock_server_config = loader_config.add(\"rest_mock_server\", \"\");\n      rest_mock_server_config.set(\"library\", \"rest_mock_server\");\n\n      auto &http_server_config = loader_config.add(\"http_server\", \"\");\n      http_server_config.set(\"library\", \"http_server\");\n      http_server_config.set(\"port\", std::to_string(config_.http_port));\n      http_server_config.set(\"static_folder\", \"\");\n    }\n\n    auto &mock_server_config = loader_config.add(\"mock_server\", \"\");\n    mock_server_config.set(\"library\", \"mock_server\");\n    mock_server_config.set(\"port\", std::to_string(config_.port));\n    mock_server_config.set(\"filename\", config_.queries_filename);\n    mock_server_config.set(\"module_prefix\", config_.module_prefix);\n\n    try {\n      loader_.reset(new mysql_harness::Loader(\"server-mock\", loader_config));\n    } catch (const std::runtime_error &err) {\n      throw std::runtime_error(std::string(\"init-loader failed: \") + err.what());\n    }\n\n    loader_->start();\n  }\nprivate:\n  void prepare_command_options() {\n    arg_handler_.add_option(CmdOption::OptionNames({\"-V\", \"--version\"}), \"Display version information and exit.\",\n                            CmdOptionValueReq::none, \"\", [this](const std::string &) {\n          std::cout << this->get_version_line() << std::endl;\n          this->do_print_and_exit_ = true;\n        });\n\n    arg_handler_.add_option(CmdOption::OptionNames({\"-?\", \"--help\"}), \"Display this help and exit.\",\n                            CmdOptionValueReq::none, \"\", [this](const std::string &) {\n          std::cout << this->get_help() << std::endl;\n          this->do_print_and_exit_ = true;\n        });\n\n    arg_handler_.add_option(\n        CmdOption::OptionNames({\"-f\", \"--filename\"}), \"tracefile to load.\",\n        CmdOptionValueReq::required, \"filename\",\n        [this](const std::string &filename) {\n          config_.queries_filename = filename;\n        });\n    arg_handler_.add_option(\n        CmdOption::OptionNames({\"-P\", \"--port\"}), \"TCP port to listen on for classic protocol connections.\",\n        CmdOptionValueReq::required, \"int\",\n        [this](const std::string &port) {\n          config_.port = static_cast<unsigned>(std::stoul(port));\n       });\n    arg_handler_.add_option(\n        CmdOption::OptionNames({\"--http-port\"}), \"TCP port to listen on for HTTP/REST connections.\",\n        CmdOptionValueReq::required, \"int\",\n        [this](const std::string &port) {\n          config_.http_port = static_cast<unsigned>(std::stoul(port));\n       });\n    arg_handler_.add_option(\n        CmdOption::OptionNames({\"--module-prefix\"}), \"path prefix for javascript modules (default current directory).\",\n        CmdOptionValueReq::required, \"path\",\n        [this](const std::string &module_prefix) {\n          config_.module_prefix = module_prefix;\n       });\n    arg_handler_.add_option(\n        CmdOption::OptionNames({\"--verbose\"}), \"verbose\",\n        CmdOptionValueReq::none, \"\",\n        [this](const std::string &) {\n          config_.verbose = true;\n       });\n  }\n\n  CmdArgHandler arg_handler_;\n  bool do_print_and_exit_ { false };\n\n  MysqlServerMockConfig config_;\n\n  std::string program_name_;\n  mysql_harness::Path origin_dir_;\n};\n\nint main(int argc, char* argv[]) {\n  MysqlServerMockFrontend frontend;\n\n#ifdef _WIN32\n  WSADATA wsaData;\n  int result;\n  result = WSAStartup(MAKEWORD(2, 2), &wsaData);\n  if (result != 0) {\n    std::cerr << \"WSAStartup failed with error: \" << result << std::endl;\n    return -1;\n  }\n#endif\n\n  std::vector<std::string> arguments { argv, argv + argc };\n  try {\n    auto frontend_config = frontend.init_from_arguments(arguments);\n\n    if (frontend.is_print_and_exit()) {\n      return 0;\n    }\n\n    frontend.run();\n  }\n  catch (const std::exception& e) {\n    std::cout << \"ERROR: \" << e.what() << std::endl;\n    return -1;\n  }\n\n  return 0;\n}\n"
  },
  {
    "path": "src/mock_server/src/mock_server_component.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysqlrouter/mock_server_component.h\"\n#include \"mysqlrouter/mock_server_global_scope.h\"\n#include \"mysql_server_mock.h\"\n\n//\n// HTTP Server's public API\n//\nstd::shared_ptr<MockServerGlobalScope> MockServerComponent::getGlobalScope()\n{\n  if (auto srv = srv_.lock()) {\n    return srv->get_global_scope();\n  } else {\n    return {};\n  }\n}\n\nvoid MockServerComponent::init(std::shared_ptr<server_mock::MySQLServerMock> srv) {\n  srv_ = srv;\n}\n\n\nMockServerComponent& MockServerComponent::getInstance() {\n  static MockServerComponent instance;\n\n  return instance;\n}\n\nvoid MockServerComponent::close_all_connections() {\n  // if we have a mock_server instance, call its close_all_connections()\n  if (auto srv = srv_.lock()) {\n    srv->close_all_connections();\n  }\n}\n"
  },
  {
    "path": "src/mock_server/src/mock_server_plugin.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifdef _WIN32\n#include <direct.h>  // getcwd\n#else\n#include <unistd.h>  // getcwd\n#endif\n\n#include \"mysql/harness/plugin.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysql/harness/config_parser.h\"\n#include \"mock_server_plugin.h\"\n#include \"mysql_server_mock.h\"\n#include \"mysqlrouter/plugin_config.h\"\n\nIMPORT_LOG_FUNCTIONS()\n\n#ifndef PATH_MAX\n#ifdef _MAX_PATH\n// windows has _MAX_PATH instead\n#define PATH_MAX _MAX_PATH\n#endif\n#endif\n\n\nstatic constexpr const char kSectionName[] { \"mock_server\" };\n\nclass PluginConfig : public mysqlrouter::BasePluginConfig {\npublic:\n  std::string trace_filename;\n  std::string module_prefix;\n  std::string srv_address;\n  uint16_t srv_port;\n\n  explicit PluginConfig(const mysql_harness::ConfigSection *section):\n    mysqlrouter::BasePluginConfig(section),\n    trace_filename(get_option_string(section, \"filename\")),\n    module_prefix(get_option_string(section, \"module_prefix\")),\n    srv_address(get_option_string(section, \"bind_address\")),\n    srv_port(get_uint_option<uint16_t>(section, \"port\"))\n  {}\n\n  std::string get_default(const std::string &option) const override {\n    char cwd[PATH_MAX];\n\n    if (nullptr == getcwd(cwd, sizeof(cwd))) {\n      throw std::system_error(errno, std::generic_category());\n    }\n\n    const std::map<std::string, std::string> defaults{\n        {\"bind_address\", \"0.0.0.0\"},\n        {\"module_prefix\", cwd},\n        {\"port\", \"3306\"},\n    };\n\n    auto it = defaults.find(option);\n    if (it == defaults.end()) {\n      return std::string();\n    }\n    return it->second;\n  }\n\n  bool is_required(const std::string &option) const override {\n    if (option == \"filename\") return true;\n    return false;\n  }\n};\n\nstatic std::map<std::string, std::shared_ptr<server_mock::MySQLServerMock>> mock_servers;\n\nstatic void init(mysql_harness::PluginFuncEnv* env) {\n  const mysql_harness::AppInfo* info = get_app_info(env);\n  bool has_started = false;\n\n  try {\n    if (info->config != nullptr) {\n      for (const mysql_harness::ConfigSection* section: info->config->sections()) {\n        if (section->name != kSectionName) {\n          continue;\n        }\n        if (has_started) {\n          // ignore all the other sections for now\n          break;\n        }\n\n        has_started = true;\n\n        PluginConfig config {section};\n        mock_servers.emplace(\n            std::make_pair(section->name,\n              std::make_shared<server_mock::MySQLServerMock>(\n                config.trace_filename,\n                config.module_prefix,\n                config.srv_port,\n                0)));\n\n        MockServerComponent::getInstance().init(mock_servers.at(section->name));\n      }\n    }\n  } catch (const std::invalid_argument& exc) {\n    set_error(env, mysql_harness::kConfigInvalidArgument, \"%s\", exc.what());\n  } catch (const std::exception& exc) {\n    set_error(env, mysql_harness::kRuntimeError, \"%s\", exc.what());\n  } catch (...) {\n    set_error(env, mysql_harness::kUndefinedError, \"Unexpected exception\");\n  }\n}\n\nstatic void start(mysql_harness::PluginFuncEnv* env) {\n  const mysql_harness::ConfigSection* section = get_config_section(env);\n\n  std::string name;\n  if (!section->key.empty()) {\n    name = section->name + \":\" + section->key;\n  } else {\n    name = section->name;\n  }\n\n  try {\n    auto srv = mock_servers.at(get_config_section(env)->name);\n\n    srv->run(env);\n  } catch (const std::invalid_argument &exc) {\n    set_error(env, mysql_harness::kConfigInvalidArgument, \"%s\", exc.what());\n  } catch (const std::runtime_error &exc) {\n    set_error(env, mysql_harness::kRuntimeError, \"%s: %s\", name.c_str(), exc.what());\n  } catch (const std::exception &exc) {\n    set_error(env, mysql_harness::kUndefinedError, \"%s: %s\", name.c_str(), exc.what());\n  } catch (...) {\n    set_error(env, mysql_harness::kUndefinedError, \"Unexpected exception\");\n  }\n}\n\nextern \"C\" {\n  mysql_harness::Plugin MOCK_SERVER_EXPORT harness_plugin_mock_server = {\n      mysql_harness::PLUGIN_ABI_VERSION,\n      mysql_harness::ARCHITECTURE_DESCRIPTOR,\n      \"Routing MySQL connections between MySQL clients/connectors and servers\",\n      VERSION_NUMBER(0, 0, 1),\n      0, nullptr, // requires\n      0, nullptr, // Conflicts\n      init,       // init\n      nullptr,    // deinit\n      start,      // start\n      nullptr     // stop\n  };\n}\n"
  },
  {
    "path": "src/mock_server/src/mock_server_plugin.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MOCK_SERVER_PLUGIN_INCLUDED\n#define MOCK_SERVER_PLUGIN_INCLUDED\n\n#include \"mysql/harness/plugin.h\"\n#include \"mysqlrouter/mock_server_export.h\"\n\nextern \"C\"\n{\n  extern mysql_harness::Plugin MOCK_SERVER_EXPORT harness_plugin_mock_server;\n}\n\n#endif\n"
  },
  {
    "path": "src/mock_server/src/mysql_protocol_common.h",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLD_MOCK_MYSQL_PROTOCOL_COMMON_INCLUDED\n#define MYSQLD_MOCK_MYSQL_PROTOCOL_COMMON_INCLUDED\n\n#include <string>\n\n//TODO after migration to Server repo: delete mysqlrouter/ after moving stuff 1 level up\n#include \"mysqlrouter/mysql_protocol.h\"\n\nnamespace server_mock {\n\nusing byte = uint8_t;\n\n/** @enum MySQLColumnType\n *\n * Supported MySQL Coumn types.\n *\n **/\nenum class MySQLColumnType {\n  DECIMAL =  0x00,\n  TINY =  0x01,\n  SHORT =  0x02,\n  LONG = 0x03,\n  FLOAT = 0x04,\n  DOUBLE = 0x05,\n  NULL_ = 0x06,\n  TIMESTAMP = 0x07,\n  LONGLONG = 0x08,\n  INT24 = 0x09,\n  DATE = 0x0a,\n  TIME = 0x0b,\n  DATETIME = 0x0c,\n  YEAR = 0x0d,\n  NEWDATE = 0x0e,\n  VARCHAR = 0x0f,\n  BIT = 0x10,\n  NEWDECIMAL = 0xf7,\n  ENUM = 0xf7,\n  SET = 0xf8,\n  TINY_BLOB = 0xf9,\n  MEDIUM_BLOB = 0xfa,\n  LONG_BLOB = 0xfb,\n  BLOB = 0xfc,\n  VAR_STRING = 0xfd,\n  STRING = 0xfe,\n  GEOMETRY = 0xff\n};\n\n/** @brief Struct for keeping column specific data\n *\n **/\nstruct column_info_type {\n  std::string name;\n  MySQLColumnType type;\n  std::string orig_name;\n  std::string table;\n  std::string orig_table;\n  std::string schema;\n  std::string catalog;\n  uint16_t flags;\n  uint8_t decimals;\n  uint32_t length;\n  uint16_t character_set;\n\n  unsigned repeat;\n};\n\n/** @brief Vector for keeping has_value|string representation of the values\n *         of the single row (ordered by column)\n **/\nusing RowValueType = std::vector<std::pair<bool, std::string>>;\n\nMySQLColumnType column_type_from_string(const std::string& type);\n\n} // namespace\n\n#endif // MYSQLD_MOCK_MYSQL_PROTOCOL_COMMON_INCLUDED\n"
  },
  {
    "path": "src/mock_server/src/mysql_protocol_decoder.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql_protocol_decoder.h\"\n\n#ifndef _WIN32\n#  include <netdb.h>\n#  include <netinet/in.h>\n#  include <fcntl.h>\n#  include <sys/un.h>\n#  include <sys/select.h>\n#  include <sys/socket.h>\n#  include <sys/types.h>\n#  include <unistd.h>\n#else\n#  define WIN32_LEAN_AND_MEAN\n#  include <windows.h>\n#  include <winsock2.h>\n#  include <ws2tcpip.h>\n#endif\n\n#include <iostream>\n\nnamespace server_mock {\n\n//TODO use of this class should probably be replaced by mysql_protocol::Packet* classes\n\nMySQLProtocolDecoder::MySQLProtocolDecoder(const ReadCallback& read_clb):\n  read_callback_(read_clb)\n{}\n\nvoid MySQLProtocolDecoder::read_message(socket_t client_socket, int flags) {\n  ProtocolPacketType result;\n  uint8_t header_buf[4];\n  uint32_t header{0};\n\n  read_callback_(client_socket, &header_buf[0], sizeof(header_buf), flags);\n\n  for (size_t i = 1; i <= 4; ++i) {\n    header <<= 8;\n    header |= header_buf[4-i];\n  }\n\n  uint32_t pkt_len = header & 0x00ffffff;\n\n  if (pkt_len == 0x00ffffff) {\n    // this means more data comming, which we don't need/support atm\n    throw std::runtime_error(\"Protocol messages split into several packets not supported!\");\n  }\n\n  packet_.packet_seq = static_cast<uint8_t>(header >> 24);\n\n  if (pkt_len > 0) {\n    packet_.packet_buffer.resize(pkt_len);\n    read_callback_(client_socket, &packet_.packet_buffer[0], pkt_len, flags);\n  }\n}\n\nmysql_protocol::Command MySQLProtocolDecoder::get_command_type() const {\n  return static_cast<mysql_protocol::Command>(packet_.packet_buffer[0]);\n}\n\nstd::string MySQLProtocolDecoder::get_statement() const {\n  size_t buf_len = packet_.packet_buffer.size() - 1;\n  if (buf_len == 0) return \"\";\n\n  std::vector<char> statement(buf_len+1);\n  const char* buf = reinterpret_cast<const char*>(&packet_.packet_buffer[1]);\n  std::copy(buf, buf+buf_len, &statement[0]);\n  statement[buf_len] = '\\0';\n\n  return std::string(statement.data());\n}\n\n\n} // namespace\n"
  },
  {
    "path": "src/mock_server/src/mysql_protocol_decoder.h",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLD_MOCK_MYSQL_PROTOCOL_DECODER_INCLUDED\n#define MYSQLD_MOCK_MYSQL_PROTOCOL_DECODER_INCLUDED\n\n#include <functional>\n#include <string>\n#include <vector>\n#include <stdint.h>\n\n#ifdef _WIN32\n#  define WIN32_LEAN_AND_MEAN\n#  include <windows.h>\n#  include <winsock2.h>\n#  include <ws2tcpip.h>\nusing socket_t = SOCKET;\n#else\nusing socket_t = int;\n#endif\n\n#include \"mysql_protocol_common.h\"\n\nnamespace server_mock {\n\nusing byte = uint8_t;\n\n/** @class MySQLProtocolDecoder\n *\n * @brief Responsible for decoding classic MySQL protocol packets\n *\n **/\nclass MySQLProtocolDecoder {\n public:\n\n  /** @brief Callback used to read more data from the socket\n   **/\n  using ReadCallback = std::function<void(int, uint8_t *data, size_t size, int)>;\n\n  /** @brief Constructor\n   *\n   * @param read_clb Callback to use to read more data from the socket\n   **/\n  MySQLProtocolDecoder(const ReadCallback& read_clb);\n\n  /** @brief Reads single packet from the network socket.\n   **/\n  void read_message(socket_t client_socket, int flags=0);\n\n  /** @brief Retrieves sequence number of the packet\n   *\n   * @returns sequence number\n   */\n  uint8_t packet_seq() const { return packet_.packet_seq; }\n\n  /** @brief Retrieves command type from the packet sent by the client.\n   *\n   * @returns command type\n   **/\n  mysql_protocol::Command get_command_type() const;\n\n  /** @brief Retrieves SQL statement from the packet sent by the client.\n   *\n   * The method assumes that the packet is MySQL QUERY command.\n   *\n   * @returns SQL statement\n   **/\n  std::string get_statement() const;\n\n private:\n  /** @brief Single protocol packet data.\n   **/\n  struct ProtocolPacketType {\n    // packet sequence number\n    uint8_t packet_seq{0};\n    // raw packet data\n    std::vector<byte> packet_buffer;\n  };\n\n  const ReadCallback read_callback_;\n  ProtocolPacketType packet_;\n  mysql_protocol::Capabilities::Flags capabilities_;\n};\n\n} // namespace\n\n#endif // MYSQLD_MOCK_MYSQL_PROTOCOL_DECODER_INCLUDED\n"
  },
  {
    "path": "src/mock_server/src/mysql_protocol_encoder.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql_protocol_encoder.h\"\n\n#include <cassert>\n#include <iostream>\n\nnamespace server_mock {\n\nMySQLProtocolEncoder::MsgBuffer\nMySQLProtocolEncoder::encode_ok_message(uint8_t seq_no,\n                               uint64_t affected_rows,\n                               uint64_t last_insert_id,\n                               uint16_t status,\n                               uint16_t warnings) {\n  MsgBuffer out_buffer;\n\n  encode_msg_begin(out_buffer);\n\n  append_byte(out_buffer, 0x0);\n  append_lenenc_int(out_buffer, affected_rows);\n  append_lenenc_int(out_buffer, last_insert_id);\n  append_int(out_buffer, status);\n  append_int(out_buffer, warnings);\n\n  encode_msg_end(out_buffer, seq_no);\n\n  return out_buffer;\n}\n\nMySQLProtocolEncoder::MsgBuffer\nMySQLProtocolEncoder::encode_error_message(uint8_t seq_no,\n                                  uint16_t error_code,\n                                  const std::string &sql_state,\n                                  const std::string &error_msg) {\n  MsgBuffer out_buffer;\n\n  encode_msg_begin(out_buffer);\n\n  append_byte(out_buffer, 0xff);\n  append_int(out_buffer, error_code);\n  append_byte(out_buffer, 0x23); // \"#\"\n  append_str(out_buffer, sql_state);\n  append_str(out_buffer, error_msg);\n\n  encode_msg_end(out_buffer, seq_no);\n\n  return out_buffer;\n}\n\nMySQLProtocolEncoder::MsgBuffer\nMySQLProtocolEncoder::encode_greetings_message(uint8_t seq_no,\n                                              const std::string &mysql_version,\n                                              uint32_t connection_id,\n                                              std::string auth_plugin_data /*= 20-byte str*/,\n                                              mysql_protocol::Capabilities::Flags capabilities /* =... */,\n                                              const std::string &auth_plugin_name /*= ... */,\n                                              uint8_t character_set /* = 0 */,\n                                              uint16_t status_flags /* = 0 */) {\n\n  ////////////////////////////////////////////////////////////////////////////////\n  //\n  // This is the layout of the Protocol::HandshakeV10 packet, according to:\n  // https://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::Handshake\n  //\n  //   1              [0a] protocol version\n  //   string[NUL]    server version\n  //   4              connection id\n  //   string[8]      auth-plugin-data-part-1\n  //   1              [00] filler\n  //   2              capability flags (lower 2 bytes)\n  //   if more data in the packet {\n  //     1              character set\n  //     2              status flags\n  //     2              capability flags (upper 2 bytes)\n  //     if capabilities & CLIENT_PLUGIN_AUTH {\n  //       1              length of auth-plugin-data\n  //     } else {\n  //       1              [00]\n  //     }\n  //     string[10]     reserved (all [00])\n  //     if capabilities & CLIENT_SECURE_CONNECTION {\n  //       string[$len]   auth-plugin-data-part-2 ($len=MAX(13, length of auth-plugin-data - 8))\n  //     }\n  //     if capabilities & CLIENT_PLUGIN_AUTH {\n  //       string[NUL]    auth-plugin name\n  //     }\n  //   }\n  //\n  // NOTE: auth-plugin-data-part-2 must contain 0 as its last byte!\n  //\n  ////////////////////////////////////////////////////////////////////////////////\n\n  // make sure the caller did not already add the final \\0, which we are about to do\n  assert(auth_plugin_data.back() != 0); // remove this assert if our auth-plugin-data needs\n                                        // to support 0's in its payload (so far we just use text)\n                                        // so the assertion works correctly)\n  assert(auth_plugin_data.size() > 8);  // our implementation might not work for len <= 8 bytes\n\n  // add the required 0-terminator to auth-plugin-data\n  auth_plugin_data.push_back(0);        // auth-plugin-data must have its last byte as 0\n\n  using namespace mysql_protocol;\n\n  MsgBuffer out_buffer;\n\n  encode_msg_begin(out_buffer);\n\n  // protocol version\n  append_byte(out_buffer, 0x0a);\n\n  // server version\n  append_str(out_buffer, mysql_version);\n  append_byte(out_buffer, 0x0); // string terminator\n\n  // connection id\n  append_int(out_buffer, connection_id);\n\n  // auth-plugin-data-part-1\n  append_str(out_buffer, auth_plugin_data.substr(0,8));\n\n  // [00] filler\n  append_byte(out_buffer, 0x0);\n\n  // capability flags (lower 2 bytes)\n  append_int(out_buffer, capabilities.low_16_bits());\n\n  // character set\n  append_byte(out_buffer, character_set);\n\n  // status flags\n  append_int(out_buffer, status_flags);\n\n  // capability flags (upper 2 bytes)\n  append_int(out_buffer, capabilities.high_16_bits());\n\n  // if capabilities & CLIENT_PLUGIN_AUTH {\n  //   1              length of auth-plugin-data\n  // } else {\n  //   1              [00]\n  // }\n  if (capabilities.test(Capabilities::PLUGIN_AUTH)) {\n    append_byte(out_buffer, auth_plugin_data.size());\n  } else {\n    append_byte(out_buffer, 0x0);\n  }\n\n  // 10 reserved zero bytes\n  append_str(out_buffer, std::string(10, '\\0'));\n\n  // if capabilities & CLIENT_SECURE_CONNECTION {\n  //   string[$len]   auth-plugin-data-part-2 ($len=MAX(13, length of auth-plugin-data - 8))\n  // }\n  if (capabilities.test(Capabilities::SECURE_CONNECTION)) {\n    append_str(out_buffer, auth_plugin_data.substr(8));\n  }\n\n  // if capabilities & CLIENT_PLUGIN_AUTH {\n  //   string[NUL]    auth-plugin name\n  // }\n  if (capabilities.test(Capabilities::PLUGIN_AUTH)) {\n    append_str(out_buffer, auth_plugin_name);\n    append_byte(out_buffer, 0x0); // string-terminator\n  }\n\n  encode_msg_end(out_buffer, seq_no);\n\n  return out_buffer;\n}\n\nMySQLProtocolEncoder::MsgBuffer\nMySQLProtocolEncoder::encode_auth_switch_message(uint8_t seq_no,\n                                                 const std::string &auth_plugin_name,\n                                                 const std::string &auth_plugin_data) {\n\n  ////////////////////////////////////////////////////////////////////////////////\n  //\n  // This is the layout of the Protocol::AuthSwitchRequest\n  //\n  //   int<1>       0xfe (254)\n  //   string[NUL]  auth-plugin-name\n  //   string[EOF]  auth-plugin-data\n  //\n  // NOTE: auth-plugin-data must contain 0 as its last byte!\n  //\n  ////////////////////////////////////////////////////////////////////////////////\n\n  // make sure the caller did not already add the final \\0, we will do this\n  // ourselves in this method\n  assert(auth_plugin_data.back() != 0); // remove this assert if our auth-plugin-data needs\n                                        // to support 0's in its payload (so far we just use text,\n                                        // so the assertion works correctly)\n\n  MsgBuffer out_buffer;\n  encode_msg_begin(out_buffer);\n\n  append_byte(out_buffer, 0xfe);\n  append_str(out_buffer, auth_plugin_name);\n  append_byte(out_buffer, 0x0);\n  append_str(out_buffer, auth_plugin_data);\n  append_byte(out_buffer, 0x0); // add the required 0 byte\n\n  encode_msg_end(out_buffer, seq_no);\n  return out_buffer;\n}\n\nMySQLProtocolEncoder::MsgBuffer\nMySQLProtocolEncoder::encode_columns_number_message(uint8_t seq_no, uint64_t number) {\n  MsgBuffer out_buffer;\n  encode_msg_begin(out_buffer);\n\n  append_lenenc_int(out_buffer, number);\n\n  encode_msg_end(out_buffer, seq_no);\n  return out_buffer;\n}\n\nMySQLProtocolEncoder::MsgBuffer\nMySQLProtocolEncoder::encode_column_meta_message(uint8_t seq_no,\n                                                const column_info_type &column_info) {\n  MsgBuffer out_buffer;\n  encode_msg_begin(out_buffer);\n\n  append_lenenc_str(out_buffer, column_info.catalog);\n  append_lenenc_str(out_buffer, column_info.schema);\n  append_lenenc_str(out_buffer, column_info.table);\n  append_lenenc_str(out_buffer, column_info.orig_table);\n  append_lenenc_str(out_buffer, column_info.name);\n  append_lenenc_str(out_buffer, column_info.orig_name);\n\n  MsgBuffer meta_buffer;\n  append_int(meta_buffer, column_info.character_set);\n  append_int(meta_buffer, column_info.length);\n  append_byte(meta_buffer, static_cast<uint8_t>(column_info.type));\n  append_int(meta_buffer, column_info.flags);\n  append_byte(meta_buffer, column_info.decimals);\n  append_int(meta_buffer, static_cast<uint16_t>(0));\n\n  append_lenenc_int(out_buffer, meta_buffer.size());\n  append_buffer(out_buffer, meta_buffer);\n\n  encode_msg_end(out_buffer, seq_no);\n  return out_buffer;\n}\n\nMySQLProtocolEncoder::MsgBuffer\nMySQLProtocolEncoder::encode_row_message(uint8_t seq_no,\n                                         const std::vector<column_info_type> &columns_info,\n                                         const RowValueType &row_values) {\n  MsgBuffer out_buffer;\n  encode_msg_begin(out_buffer);\n\n  if (columns_info.size() != row_values.size()) {\n    throw std::runtime_error(std::string(\"columns_info.size() != row_values.size() \")\n              + std::to_string(columns_info.size())\n              + std::string(\"!=\") +  std::to_string(row_values.size()));\n  }\n\n  for (size_t i = 0; i < row_values.size(); ++i) {\n    if (row_values[i].first) {\n      append_lenenc_str(out_buffer, row_values[i].second);\n    } else {\n      append_byte(out_buffer, 0xfb); // NULL\n    }\n  }\n\n  encode_msg_end(out_buffer, seq_no);\n  return out_buffer;\n}\n\nMySQLProtocolEncoder::MsgBuffer\nMySQLProtocolEncoder::encode_eof_message(uint8_t seq_no, uint16_t status,\n                                         uint16_t warnings) {\n  MsgBuffer out_buffer;\n  encode_msg_begin(out_buffer);\n\n  append_byte(out_buffer, 0xfe);  // ok\n  append_int(out_buffer, status);\n  append_int(out_buffer, warnings);\n\n  encode_msg_end(out_buffer, seq_no);\n  return out_buffer;\n}\n\nvoid MySQLProtocolEncoder::encode_msg_begin(MsgBuffer &out_buffer) {\n  // reserve space for header\n  append_int(out_buffer, static_cast<uint32_t>(0x0));\n}\n\nvoid MySQLProtocolEncoder::encode_msg_end(MsgBuffer &out_buffer, uint8_t seq_no) {\n  assert(out_buffer.size() >= 4);\n  // fill the header\n  uint32_t msg_len = static_cast<uint32_t>(out_buffer.size()) - 4;\n  if (msg_len > 0xffffff) {\n    throw std::runtime_error(\"Invalid message length: \" + std::to_string(msg_len));\n  }\n  uint32_t header = msg_len | static_cast<uint32_t>(seq_no << 24);\n\n  auto len = sizeof(header);\n  for (size_t i = 0; len > 0; ++i, --len) {\n    out_buffer[i] = static_cast<byte>(header);\n    header = static_cast<decltype(header)>(header >> 8);\n  }\n}\n\nvoid MySQLProtocolEncoder::append_byte(MsgBuffer& buffer, byte value) {\n  buffer.push_back(value);\n}\n\nvoid MySQLProtocolEncoder::append_str(MsgBuffer &buffer, const std::string &value) {\n  buffer.insert(buffer.end(), value.begin(), value.end());\n}\n\nvoid MySQLProtocolEncoder::append_buffer(MsgBuffer &buffer, const MsgBuffer &value) {\n  buffer.insert(buffer.end(), value.begin(), value.end());\n}\n\nvoid MySQLProtocolEncoder::append_lenenc_int(MsgBuffer &buffer, uint64_t val) {\n  if (val < 251) {\n    append_byte(buffer, static_cast<byte>(val));\n  }\n  else if (val < (1 << 16)) {\n    append_byte(buffer, 0xfc);\n    append_int(buffer, static_cast<uint16_t>(val));\n  }\n  else {\n    append_byte(buffer, 0xfe);\n    append_int(buffer, val);\n  }\n}\n\nvoid MySQLProtocolEncoder::append_lenenc_str(MsgBuffer &buffer, const std::string &value) {\n  append_lenenc_int(buffer, value.length());\n  append_str(buffer, value);\n}\n\nMySQLColumnType column_type_from_string(const std::string& type) {\n  int res = 0;\n\n  try {\n    res =  std::stoi(type);\n  }\n  catch (const std::invalid_argument&) {\n    if (type == \"DECIMAL\") return MySQLColumnType::DECIMAL;\n    if (type == \"TINY\") return MySQLColumnType::TINY;\n    if (type == \"SHORT\") return MySQLColumnType::SHORT;\n    if (type == \"LONG\") return MySQLColumnType::LONG;\n    if (type == \"INT24\") return MySQLColumnType::INT24;\n    if (type == \"LONGLONG\") return MySQLColumnType::LONGLONG;\n    if (type == \"DECIMAL\") return MySQLColumnType::DECIMAL;\n    if (type == \"NEWDECIMAL\") return MySQLColumnType::NEWDECIMAL;\n    if (type == \"FLOAT\") return MySQLColumnType::FLOAT;\n    if (type == \"DOUBLE\") return MySQLColumnType::DOUBLE;\n    if (type == \"BIT\") return MySQLColumnType::BIT;\n    if (type == \"TIMESTAMP\") return MySQLColumnType::TIMESTAMP;\n    if (type == \"DATE\") return MySQLColumnType::DATE;\n    if (type == \"TIME\") return MySQLColumnType::TIME;\n    if (type == \"DATETIME\") return MySQLColumnType::DATETIME;\n    if (type == \"YEAR\") return MySQLColumnType::YEAR;\n    if (type == \"STRING\") return MySQLColumnType::STRING;\n    if (type == \"VAR_STRING\") return MySQLColumnType::VAR_STRING;\n    if (type == \"BLOB\") return MySQLColumnType::BLOB;\n    if (type == \"SET\") return MySQLColumnType::SET;\n    if (type == \"ENUM\") return MySQLColumnType::ENUM;\n    if (type == \"GEOMETRY\") return MySQLColumnType::GEOMETRY;\n    if (type == \"NULL\") return MySQLColumnType::NULL_;\n    if (type == \"TINYBLOB\") return MySQLColumnType::TINY_BLOB;\n    if (type == \"LONGBLOB\") return MySQLColumnType::LONG_BLOB;\n    if (type == \"MEDIUMBLOB\") return MySQLColumnType::MEDIUM_BLOB;\n\n    throw std::invalid_argument(\"Unknown type: \\\"\" + type + \"\\\"\");\n  }\n\n  return static_cast<MySQLColumnType>(res);\n}\n\n} // namespace\n"
  },
  {
    "path": "src/mock_server/src/mysql_protocol_encoder.h",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLD_MOCK_MYSQL_PROTOCOL_ENCODER_INCLUDED\n#define MYSQLD_MOCK_MYSQL_PROTOCOL_ENCODER_INCLUDED\n\n#include <string>\n#include <vector>\n#include <stdint.h>\n\n#include \"mysql_protocol_common.h\"\n#include \"json_statement_reader.h\"\n\nnamespace server_mock {\n\nconst uint16_t MYSQL_PARSE_ERROR = 1064;\n\n\nclass MySQLProtocolEncoder {\npublic:\n\n  using MsgBuffer = std::vector<byte>;\n\n  /** @brief Encodes MySQL OK message\n   *\n   * @param seq_no          protocol packet sequence number to use\n   * @param affected_rows   number of the rows affected by the statment\n   *                        this OK replies to\n   * @param last_insert_id  id of the last row inserted by the statement\n   *                        this OK replies to (if any)\n   * @param status          status of the statement this OK replies to\n   * @param warnings        number of the warning for the statement this OK replies to\n   *\n   * @returns buffer with the encoded message\n   **/\n  MsgBuffer encode_ok_message(uint8_t seq_no,\n                               uint64_t affected_rows = 0,\n                               uint64_t last_insert_id = 0,\n                               uint16_t status = 0,\n                               uint16_t warnings = 0);\n\n  /** @brief Encodes MySQL error message\n   *\n   * @param seq_no      protocol packet sequence number to use\n   * @param error_code  code of the reported error\n   * @param sql_state   SQL state to report\n   * @param error_msg   error message\n   *\n   * @returns buffer with the encoded message\n   **/\n  MsgBuffer encode_error_message(uint8_t seq_no,\n                                  uint16_t error_code,\n                                  const std::string &sql_state,\n                                  const std::string &error_msg);\n\n  /** @brief Encodes MySQL greetings message sent from the server when\n   *         the client connects.\n   *\n   * @param seq_no          protocol packet sequence number to use\n   * @param mysql_version   MySQL server version string\n   * @param connection_id   is of the client connection\n   * @param auth_plugin_data authentication plugin data (nonce)\n   * @param capabilities    bitmask with MySQL Server capabilities\n   * @param auth_plugin_name auth-plugin name, written only if PLUGIN_AUTH cap.flag is set\n   * @param character_set   id of the connection character set\n   * @param status_flags    bitmask with MySQL Server status flags\n   *\n   * @returns buffer with the encoded message\n   **/\n  MsgBuffer encode_greetings_message(uint8_t seq_no,\n                                      const std::string &mysql_version = \"8.0.5\",\n                                      uint32_t connection_id = 1,\n                                      std::string auth_plugin_data = \"123456789|123456789|\",\n                                      mysql_protocol::Capabilities::Flags capabilities = mysql_protocol::Capabilities::PROTOCOL_41\n                                                                                       | mysql_protocol::Capabilities::SECURE_CONNECTION,\n                                      const std::string &auth_plugin_name = \"mysql_native_password\",\n                                      uint8_t character_set = 0,\n                                      uint16_t status_flags = 0);\n\n  /** @brief Encodes MySQL auth-switch message sent from the server when\n   *         the client connects.\n   *\n   * @param seq_no          protocol packet sequence number to use\n   * @param auth_plugin_name auth-plugin name, written only if PLUGIN_AUTH cap.flag is set\n   * @param auth_plugin_data authentication plugin data (nonce)\n   *\n   * @note auth_plugin_data should contain the 8/20/32 nonce bytes, WITHOUT the\n   *       final \\0 at the end (it will be added automatically by this method)\n   *\n   * @returns buffer with the encoded message\n   **/\n  MsgBuffer encode_auth_switch_message(uint8_t seq_no,\n                                       const std::string &auth_plugin_name,\n                                       const std::string &auth_plugin_data);\n\n  /** @brief Encodes message containing number of the columns\n   *        (used while sending resultset for the QUERY).\n   *\n   * @param seq_no  protocol packet sequence number to use\n   * @param number  number of the columns to encode\n   *\n   * @returns buffer with the encoded message\n   **/\n  MsgBuffer encode_columns_number_message(uint8_t seq_no, uint64_t number);\n\n\n  /** @brief Encodes message containing single column metadata.\n   *\n   * @param seq_no       protocol packet sequence number to use\n   * @param column_info  map containing parameters names and values pairs for the column\n   *\n   * @returns buffer with the encoded message\n   **/\n  MsgBuffer encode_column_meta_message(uint8_t seq_no,\n                                        const column_info_type &column_info);\n\n  /** @brief Encodes message containing single row in the resultset.\n   *\n   * @param seq_no        protocol packet sequence number to use\n   * @param columns_info  vector with column metadata for consecutive row fields\n   * @param row_values    vector with values (as string) for the consecutive row fields\n   *\n   * @returns buffer with the encoded message\n   **/\n  MsgBuffer encode_row_message(uint8_t seq_no,\n                                const std::vector<column_info_type> &columns_info,\n                                const RowValueType &row_values);\n\n  /** @brief Encodes EOF message used to mark the end of columns metadata and rows\n   *         when sending the resultset to the client.\n   *\n   * @param seq_no    protocol packet sequence number to use\n   * @param status    status mask for the ongoing operation\n   * @param warnings  number of the warnings for ongoing operation\n   *\n   * @returns buffer with the encoded message\n   **/\n  MsgBuffer encode_eof_message(uint8_t seq_no,\n                                uint16_t status = 0,\n                                uint16_t warnings = 0);\n\n protected:\n  void encode_msg_begin(MsgBuffer &out_buffer);\n  void encode_msg_end(MsgBuffer &out_buffer, uint8_t seq_no);\n  void append_byte(MsgBuffer& buffer, byte value);\n\n  template<class T, typename = std::enable_if<std::is_integral<T>::value>>\n  void append_int(MsgBuffer& buffer, T value, size_t len = sizeof(T)) {\n    buffer.reserve(buffer.size() + len);\n    while(len-- > 0) {\n      byte b = static_cast<byte>(value);\n      buffer.push_back(b);\n      value = static_cast<T>(value >> 8);\n    }\n  }\n\n  void append_str(MsgBuffer &buffer, const std::string &value);\n  void append_buffer(MsgBuffer &buffer, const MsgBuffer &value);\n  void append_lenenc_int(MsgBuffer &buffer, uint64_t val);\n  void append_lenenc_str(MsgBuffer &buffer, const std::string &value);\n};\n\n} // namespace\n\n#endif // MYSQLD_MOCK_MYSQL_PROTOCOL_ENCODER_INCLUDED\n"
  },
  {
    "path": "src/mock_server/src/mysql_protocol_utils.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/*\n * include climits first to ensure _POSIX_C_SOURCE will be set\n * correctly early.\n *\n * On solaris sys/feature_set.h must be included before errno.h\n * to ensure the right version of 'errno' is provided:\n *\n * - without _POSIX_C_SOURCE >= 199509L: 'extern int errno'\n * - with, '*(___errno())', the thread-local-storage version.\n *\n * including climits is safe on all platforms AND includes\n * sys/feature_set.h on solaris.\n */\n#include <climits>\n#include <system_error>\n\n#ifndef _WIN32\n#  include <sys/socket.h>\n#  include <sys/types.h>\n#  include <unistd.h>\n#  include <poll.h>\n#  include <cstring>\n#else\n#  define WIN32_LEAN_AND_MEAN\n#  include <windows.h>\n#  include <winsock2.h>\ntypedef long ssize_t;\n#endif\n\n#include \"mysql_protocol_encoder.h\"\n#include \"mysql_protocol_decoder.h\"\n#include \"mysql_protocol_utils.h\"\n\n\nint get_socket_errno() {\n#ifndef _WIN32\n  return errno;\n#else\n  return WSAGetLastError();\n#endif\n}\n\nstd::string get_socket_errno_str() {\n  return std::to_string(get_socket_errno());\n}\n\nvoid send_packet(socket_t client_socket, const uint8_t *data, size_t size, int flags) {\n  ssize_t sent = 0;\n  size_t buffer_offset = 0;\n  while (buffer_offset < size) {\n    if ((sent = send(client_socket, reinterpret_cast<const char*>(data) + buffer_offset,\n                     size-buffer_offset, flags)) < 0) {\n      throw std::system_error(get_socket_errno(), std::system_category(), \"send() failed\");\n    }\n    buffer_offset += static_cast<size_t>(sent);\n  }\n}\n\nvoid send_packet(socket_t client_socket,\n                 const server_mock::MySQLProtocolEncoder::MsgBuffer &buffer,\n                 int flags) {\n  send_packet(client_socket, buffer.data(), buffer.size(), flags);\n}\n\nvoid read_packet(socket_t client_socket, uint8_t *data, size_t size, int flags) {\n  ssize_t received = 0;\n  size_t buffer_offset = 0;\n  while (buffer_offset < size) {\n    // check if the current socket is readable/open\n    //\n    // allow interrupting the read() by closing the socket in another thread\n#ifdef _WIN32\n    WSAPOLLFD\n#else\n    struct pollfd\n#endif\n      fds[1];\n    memset(fds, 0, sizeof(fds));\n\n    fds[0].fd = client_socket;\n#ifdef _WIN32\n    fds[0].events = POLLRDNORM;\n#else\n    fds[0].events = POLLIN|POLLHUP;\n#endif\n\n    while (true) {\n      // check if someone closed our socket externally\n#ifdef _WIN32\n      int r = ::WSAPoll(fds, 1, 100);\n#else\n      int r = ::poll(fds, 1, 100);\n#endif\n\n      if (r > 0) break;\n      if (r < 0) throw std::system_error(get_socket_errno(), std::system_category(), \"poll() failed\");\n\n      if (fds[0].revents & POLLNVAL) {\n        // another thread may have closed the socket\n        throw std::runtime_error(\"poll() reported: invalid socket\");\n      }\n\n      // timeout, just wait a bit more\n    }\n\n    received = recv(client_socket, reinterpret_cast<char*>(data)+buffer_offset,\n                    size-buffer_offset, flags);\n    if (received < 0) {\n      throw std::system_error(get_socket_errno(), std::system_category(), \"recv() failed\");\n    } else if (received == 0) {\n      // connection closed by client\n      throw std::runtime_error(\"recv() failed: Connection Closed\");\n    }\n    buffer_offset += static_cast<size_t>(received);\n  }\n}\n\nint close_socket(socket_t sock) {\n#ifndef _WIN32\n  return close(sock);\n#else\n  return closesocket(sock);\n#endif\n}\n"
  },
  {
    "path": "src/mock_server/src/mysql_protocol_utils.h",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLD_MOCK_MYSQL_PROTOCOL_UTILS_INCLUDED\n#define MYSQLD_MOCK_MYSQL_PROTOCOL_UTILS_INCLUDED\n\n#include \"mysql_protocol_encoder.h\"\n#include \"mysql_protocol_decoder.h\"\n\nint get_socket_errno();\nstd::string get_socket_errno_str();\nvoid send_packet(socket_t client_socket, const uint8_t *data, size_t size, int flags = 0);\nvoid send_packet(socket_t client_socket,\n                 const server_mock::MySQLProtocolEncoder::MsgBuffer &buffer,\n                 int flags = 0);\nvoid read_packet(socket_t client_socket, uint8_t *data, size_t size, int flags = 0);\nint close_socket(socket_t sock);\n\n#endif // MYSQLD_MOCK_MYSQL_PROTOCOL_UTILS_INCLUDED\n"
  },
  {
    "path": "src/mock_server/src/mysql_server_mock.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql_server_mock.h\"\n#include \"mysql_protocol_utils.h\"\n#include \"json_statement_reader.h\"\n#include \"duktape_statement_reader.h\"\n\n#include \"mysql/harness/logging/logging.h\"\nIMPORT_LOG_FUNCTIONS()\n\n#include <cstring>\n#include <functional>\n#include <iostream>\n#include <thread>\n#include <atomic>\n#include <condition_variable>\n#include <system_error>\n#include <deque>\n#include <queue>\n#include <set>\n\n#ifndef _WIN32\n#  include <netdb.h>\n#  include <netinet/in.h>\n#  include <fcntl.h>\n#  include <signal.h>\n#  include <sys/un.h>\n#  include <sys/select.h>\n#  include <sys/socket.h>\n#  include <sys/types.h>\n#  include <netinet/tcp.h>\n#  include <unistd.h>\n#else\n#  define WIN32_LEAN_AND_MEAN\n#  include <windows.h>\n#  include <winsock2.h>\n#  include <ws2tcpip.h>\n#endif\n\n#ifdef _WIN32\nconstexpr socket_t kInvalidSocket = INVALID_SOCKET;\n#else\nconstexpr socket_t kInvalidSocket = -1;\n#endif\n\n\nusing namespace std::placeholders;\n\nnamespace server_mock {\n\nconstexpr char kAuthCachingSha2Password[] = \"caching_sha2_password\";\nconstexpr char kAuthNativePassword[] = \"mysql_native_password\";\nconstexpr size_t kReadBufSize = 16 * 1024;  // size big enough to contain any packet we're likely to read\n\nMySQLServerMock::MySQLServerMock(\n    const std::string &expected_queries_file,\n    const std::string &module_prefix,\n    unsigned bind_port, bool debug_mode):\n  bind_port_{bind_port},\n  debug_mode_{debug_mode},\n  expected_queries_file_{expected_queries_file},\n  module_prefix_{module_prefix}\n  {\n  if (debug_mode_)\n    std::cout << \"\\n\\nExpected SQL queries come from file '\"\n              << expected_queries_file << \"'\\n\\n\" << std::flush;\n}\n\nMySQLServerMock::~MySQLServerMock() {\n  if (listener_ > 0) {\n    close_socket(listener_);\n  }\n}\n\n// close all active connections\nvoid MySQLServerMock::close_all_connections() {\n  std::lock_guard<std::mutex> active_fd_lock(active_fds_mutex_);\n  for (auto it = active_fds_.begin(); it != active_fds_.end(); ) {\n    close_socket(*it);\n    it = active_fds_.erase(it);\n  }\n}\n\nvoid MySQLServerMock::run(mysql_harness::PluginFuncEnv* env) {\n  setup_service();\n  handle_connections(env);\n}\n\nvoid MySQLServerMock::setup_service() {\n  int err;\n  struct addrinfo hints, *ainfo;\n\n  std::memset(&hints, 0, sizeof(hints));\n  hints.ai_family = AF_INET;\n  hints.ai_socktype = SOCK_STREAM;\n  hints.ai_flags = AI_PASSIVE;\n\n  err = getaddrinfo(nullptr, std::to_string(bind_port_).c_str(), &hints, &ainfo);\n  if (err != 0) {\n    throw std::runtime_error(std::string(\"getaddrinfo() failed: \") + gai_strerror(err));\n  }\n\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){freeaddrinfo(ainfo);});\n\n  listener_ = socket(ainfo->ai_family, ainfo->ai_socktype, ainfo->ai_protocol);\n  if (listener_ < 0) {\n    throw std::runtime_error(\"socket() failed: \" + get_socket_errno_str());\n  }\n\n  int option_value = 1;\n  if (setsockopt(listener_, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<const char*>(&option_value),\n        static_cast<socklen_t>(sizeof(int))) == -1) {\n    throw std::runtime_error(\"setsockopt() failed: \" + get_socket_errno_str());\n  }\n\n  err = bind(listener_, ainfo->ai_addr, ainfo->ai_addrlen);\n  if (err < 0) {\n    throw std::runtime_error(\"bind('0.0.0.0', \" + std::to_string(bind_port_)+ \") failed: \" + strerror(get_socket_errno()) + \" (\" + get_socket_errno_str() + \")\");\n  }\n\n  err = listen(listener_, kListenQueueSize);\n  if (err < 0) {\n    throw std::runtime_error(\"listen() failed: \" + get_socket_errno_str());\n  }\n}\n\nvoid MySQLServerMockSession::send_handshake(\n    socket_t client_socket,\n    mysql_protocol::Capabilities::Flags our_capabilities) {\n\n  constexpr const char* plugin_name = kAuthNativePassword;\n  constexpr const char* plugin_data = \"123456789|ABCDEFGHI|\"; // 20 bytes\n\n  std::vector<uint8_t> buf = protocol_encoder_.encode_greetings_message(\n      0, \"8.0.5\", 1, plugin_data, our_capabilities, plugin_name);\n  send_packet(client_socket, buf);\n}\n\nmysql_protocol::HandshakeResponsePacket MySQLServerMockSession::handle_handshake_response(\n    socket_t client_socket,\n    mysql_protocol::Capabilities::Flags our_capabilities) {\n\n  typedef std::vector<uint8_t> MsgBuffer;\n  using namespace mysql_protocol;\n\n  uint8_t buf[kReadBufSize];\n  size_t payload_size;\n  constexpr size_t header_len = HandshakeResponsePacket::get_header_length();\n\n  // receive handshake response packet\n  {\n    // reads all bytes or throws\n    read_packet(client_socket, buf, header_len);\n\n    if (HandshakeResponsePacket::read_sequence_id(buf) != 1)\n      throw std::runtime_error(\"Handshake response packet with incorrect sequence number: \" +\n                               std::to_string(HandshakeResponsePacket::read_sequence_id(buf)));\n\n    payload_size = HandshakeResponsePacket::read_payload_size(buf);\n    assert(header_len + payload_size <= sizeof(buf));\n\n    // reads all bytes or throws\n    read_packet(client_socket, buf + header_len, payload_size);\n  }\n\n  // parse handshake response packet\n  {\n    HandshakeResponsePacket pkt(MsgBuffer(buf, buf + header_len + payload_size));\n    try {\n      pkt.parse_payload(our_capabilities);\n\n      #if 0 // enable if you need to debug\n      pkt.debug_dump();\n      #endif\n      return pkt;\n    } catch (const std::runtime_error& e) {\n      // Dump packet contents to stdout, so we can try to debug what went wrong.\n      // Since parsing failed, this is also likely to throw. If it doesn't,\n      // great, but we'll be happy to take whatever info the dump can give us\n      // before throwing.\n      try {\n        pkt.debug_dump();\n      } catch (...) {}\n\n      throw;\n    }\n  }\n}\n\nvoid MySQLServerMockSession::handle_auth_switch(socket_t client_socket) {\n\n  constexpr uint8_t seq_nr = 2;\n\n  // send switch-auth request packet\n  {\n    constexpr const char* plugin_data = \"123456789|ABCDEFGHI|\";\n\n    auto buf = protocol_encoder_.encode_auth_switch_message(\n                   seq_nr, kAuthCachingSha2Password, plugin_data);\n    send_packet(client_socket, buf);\n  }\n\n  // receive auth-data packet\n  {\n    using namespace mysql_protocol;\n    constexpr size_t header_len = HandshakeResponsePacket::get_header_length();\n\n    uint8_t buf[kReadBufSize];\n\n    // reads all bytes or throws\n    read_packet(client_socket, buf, header_len);\n\n    if (HandshakeResponsePacket::read_sequence_id(buf) != seq_nr + 1)\n      throw std::runtime_error(\"Auth-change response packet with incorrect sequence number: \" +\n                               std::to_string(HandshakeResponsePacket::read_sequence_id(buf)));\n\n    size_t payload_size = HandshakeResponsePacket::read_payload_size(buf);\n    assert(header_len + payload_size <= sizeof(buf));\n\n    // reads all bytes or throws\n    read_packet(client_socket, buf + header_len, payload_size);\n\n    // for now, we ignore the contents we just read, because we always positively\n    // authenticate the client\n  }\n\n}\n\nvoid MySQLServerMockSession::send_fast_auth(socket_t client_socket) {\n  // a mysql-8 client will send us a cache-256-password-scramble\n  // and expects a \\x03 back (fast-auth) + a OK packet\n  // Here we send the 1st of the two.\n\n  // pretend we do cached_sha256 fast-auth\n  constexpr uint8_t seq_nr = 4;\n  constexpr uint8_t fast_auth_cmd = 3;\n  constexpr uint8_t payload_size_bytes[] = {1, 0, 0};\n  constexpr uint8_t switch_auth[] = {payload_size_bytes[0], payload_size_bytes[1], payload_size_bytes[2],\n                                     seq_nr, fast_auth_cmd};\n\n  send_packet(client_socket, switch_auth, sizeof(switch_auth));\n}\n\nvoid non_blocking(socket_t handle_, bool mode) {\n#ifdef _WIN32\n  u_long arg = mode ? 1 : 0;\n  ioctlsocket(handle_, FIONBIO, &arg);\n#else\n  int flags = fcntl(handle_, F_GETFL, 0);\n  fcntl(handle_, F_SETFL, (flags & ~O_NONBLOCK) | (mode ? O_NONBLOCK : 0));\n#endif\n}\n\nclass StatementReaderFactory {\npublic:\n  static StatementReaderBase *create(const std::string &filename,\n      std::string &module_prefix,\n      std::map<std::string, std::string> session_data,\n      std::shared_ptr<MockServerGlobalScope> shared_globals) {\n    if (filename.substr(filename.size() - 3) == \".js\") {\n      return new DuktapeStatementReader(filename, module_prefix, session_data, shared_globals);\n    } else if (filename.substr(filename.size() - 5) == \".json\") {\n      return new QueriesJsonReader(filename);\n    } else {\n      throw std::runtime_error(\"can't create reader for \" + filename);\n    }\n  }\n};\n\nMySQLServerMockSession::MySQLServerMockSession(\n    socket_t client_sock,\n    std::unique_ptr<StatementReaderBase> statement_processor,\n    bool debug_mode):\n  client_socket_{client_sock},\n  protocol_decoder_{&read_packet},\n  json_reader_{std::move(statement_processor)},\n  debug_mode_{debug_mode}\n{\n  // if it doesn't work, no problem.\n  int one = 1;\n  setsockopt(client_socket_, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast<const char *>(&one), sizeof(one));\n\n  non_blocking(client_socket_, false);\n\n}\n\nMySQLServerMockSession::~MySQLServerMockSession() {\n}\n\nvoid MySQLServerMockSession::run() {\n  try {\n    ////////////////////////////////////////////////////////////////////////////////\n    //\n    // This is the handshake packet that my server v8.0.5 emits:\n    //\n    //        <header >   v10  <--- server version\n    //  0000: 6c00 0000   0a   38 2e30 2e35 2d65 6e74 6572 7072 6973 652d 636f 6d6d 6572 6369 616c            l....8.0.5-enterprise-commercial\n    //\n    //                         server version -> <conn id> <-- auth data 1 -->  zero cap.low char status\n    //  0020: 2d61 6476 616e 6365 642d 6c6f 6700 0800 0000 5b09 4e78 3d48 0a11   00   ff ff   ff   0200       -advanced-log.....[.Nx=H........\n    //\n    //      cap.hi  auth-len  <- reserved 10 0-bytes ->   <SECURE_CONN && auth-data 2    >   <PLUGIN_AUTH && auth-plugin name\n    //  0040: ffc3     15     00 0000 0000 0000 0000 00   64 1242 070c 5263 2d01 710c 4100   6361 6368 696e   .............d.B..Rc-.q.A.cachin\n    //\n    //        auth-plugin name --------------------->\n    //  0060: 675f 7368 6132 5f70 6173 7377 6f72 6400                                                         g_sha2_password.\n    //\n    //\n    //  client v8.0.5 reponds with capability flags: 05ae ff01\n    //\n    ////////////////////////////////////////////////////////////////////////////////\n\n    using namespace mysql_protocol;\n\n    constexpr Capabilities::Flags our_capabilities = Capabilities::PROTOCOL_41\n                                                   | Capabilities::PLUGIN_AUTH\n                                                   | Capabilities::SECURE_CONNECTION;\n\n    send_handshake(client_socket_, our_capabilities);\n    HandshakeResponsePacket handshake_response = handle_handshake_response(\n                                                     client_socket_, our_capabilities);\n\n    uint8_t packet_seq = 2u;\n    if (handshake_response.get_auth_plugin() == kAuthCachingSha2Password) {\n      // typically, client >= 8.0.4 will trigger this branch\n\n      handle_auth_switch(client_socket_);\n      send_fast_auth(client_socket_);\n      packet_seq += 3;  // 2 from auth-switch + 1 from fast-auth\n\n    } else if (handshake_response.get_auth_plugin() == kAuthNativePassword) {\n      // typically, client <= 5.7 will trigger this branch; do nothing, we're good\n    } else {\n      // unexpected auth-plugin name\n      assert(0);\n    }\n\n    send_ok(client_socket_, packet_seq);\n\n    bool res = process_statements(client_socket_);\n    if (!res) {\n      std::cout << \"Error processing statements with client: \" << client_socket_ << std::endl;\n    }\n  }\n  catch (const std::exception &e) {\n    log_warning(\"Exception caught in connection loop: %s\", e.what());\n  }\n}\n\nstruct Work {\n  socket_t client_socket;\n  std::string expected_queries_file;\n  std::string module_prefix;\n  bool debug_mode;\n};\n\ntemplate<typename Data>\nclass concurrent_queue {\npublic:\n  Data pop() {\n    std::unique_lock<std::mutex> mlock(mutex_);\n\n    while(queue_.empty()) {\n      cond_.wait(mlock);\n    }\n\n    auto item = queue_.front();\n    queue_.pop();\n    return item;\n  }\n\n  void push(Data&& item) {\n    std::unique_lock<std::mutex> mlock(mutex_);\n\n    queue_.push(std::move(item));\n\n    mlock.unlock();\n    cond_.notify_one();\n  }\n\nprivate:\n  std::queue<Data> queue_;\n  std::mutex mutex_;\n  std::condition_variable cond_;\n};\n\nvoid MySQLServerMock::handle_connections(mysql_harness::PluginFuncEnv* env) {\n  struct sockaddr_storage client_addr;\n  socklen_t addr_size = sizeof(client_addr);\n\n  log_info(\"Starting to handle connections on port: %d\", bind_port_);\n\n  concurrent_queue<Work> work_queue;\n  concurrent_queue<socket_t> socket_queue;\n\n  auto connection_handler = [&]() -> void {\n    while (true) {\n      auto work = work_queue.pop();\n\n      // exit\n      if (work.client_socket == kInvalidSocket) break;\n\n      try {\n        sockaddr_in addr;\n        socklen_t addr_len = sizeof(addr);\n        if (-1 == getsockname(work.client_socket, reinterpret_cast<sockaddr *>(&addr), &addr_len)) {\n          throw std::system_error(get_socket_errno(), std::system_category(), \"getsockname() failed\");\n        }\n        std::unique_ptr<StatementReaderBase> statement_reader {\n          StatementReaderFactory::create(\n              work.expected_queries_file,\n              work.module_prefix,\n              // expose session data json-encoded string\n              {\n                { \"port\", std::to_string(ntohs(addr.sin_port)) },\n              },\n              shared_globals_)};\n\n        MySQLServerMockSession session(\n            work.client_socket,\n            std::move(statement_reader),\n            work.debug_mode);\n        try {\n          session.run();\n        } catch (const std::exception &e) {\n          log_error(\"%s\", e.what());\n        }\n      } catch (const std::exception &e) {\n        // close the connection before Session took over.\n        send_packet(work.client_socket,\n            MySQLProtocolEncoder().encode_error_message(\n              0, 1064, \"\", \"reader error: \" + std::string(e.what())),\n            0);\n        log_error(\"%s\", e.what());\n      }\n\n      // first remove the book-keeping, then close the socket\n      // to avoid a race between the acceptor and the worker thread\n      {\n        // socket is done, unregister it\n        std::lock_guard<std::mutex> active_fd_lock(active_fds_mutex_);\n        auto it = active_fds_.find(work.client_socket);\n        if (it != active_fds_.end()) {\n          // it should always be there\n          active_fds_.erase(it);\n        }\n      }\n      close_socket(work.client_socket);\n    }\n  };\n\n  non_blocking(listener_, true);\n\n  std::deque<std::thread> worker_threads;\n  for (size_t ndx = 0; ndx < 4; ndx++) {\n    worker_threads.emplace_back(connection_handler);\n  }\n\n  while (is_running(env)) {\n    fd_set fds;\n    FD_ZERO (&fds);\n    FD_SET (listener_, &fds);\n\n    // timeval is initialized in loop because value of timeval may be overriden by calling select.\n    timeval tv;\n    tv.tv_sec = 0;\n    tv.tv_usec = 10000;\n\n    int err = select (listener_ + 1, &fds, NULL, NULL, &tv);\n\n    if (err < 0) {\n      std::cerr << \"select() failed: \" << strerror(errno) << \"\\n\";\n      break;\n    } else if (err == 0) {\n      // timeout\n      continue;\n    }\n\n    if (FD_ISSET(listener_, &fds)) {\n      while (true) {\n        socket_t client_socket = accept(listener_, (struct sockaddr*)&client_addr, &addr_size);\n        if (client_socket == kInvalidSocket) {\n          auto accept_errno = get_socket_errno();\n\n          // if we got interrupted at shutdown, just leave\n          if (!is_running(env)) break;\n\n          if (accept_errno == EAGAIN) break;\n          if (accept_errno == EWOULDBLOCK) break;\n#ifdef _WIN32\n          if (accept_errno == WSAEWOULDBLOCK) break;\n          if (accept_errno == WSAEINTR) continue;\n#endif\n          if (accept_errno == EINTR) continue;\n\n          std::cerr << \"accept() failed: errno=\" << accept_errno << std::endl;\n          return;\n        }\n\n        {\n          // socket is new, register it\n          std::lock_guard<std::mutex> active_fd_lock(active_fds_mutex_);\n          active_fds_.emplace(client_socket);\n        }\n\n        // std::cout << \"Accepted client \" << client_socket << std::endl;\n        work_queue.push(Work {client_socket, expected_queries_file_, module_prefix_, debug_mode_});\n      }\n    }\n  }\n\n  // beware, this closes all sockets that are either in the work-queue or\n  // currently handled by worker-threads. As long as we don't reuse the file-handles\n  // for anything else before we leave this function, this approach is safe.\n  close_all_connections();\n\n  // std::cerr << \"sending death-signal to threads\" << std::endl;\n  for (size_t ndx = 0; ndx < worker_threads.size(); ndx++) {\n    work_queue.push(Work { kInvalidSocket, \"\", \"\", 0});\n  }\n  // std::cerr << \"joining threads\" << std::endl;\n  for (size_t ndx = 0; ndx < worker_threads.size(); ndx++) {\n    worker_threads[ndx].join();\n  }\n  // std::cerr << \"done\" << std::endl;\n}\n\nbool MySQLServerMockSession::process_statements(socket_t client_socket) {\n  using mysql_protocol::Command;\n\n  while (!killed_) {\n    protocol_decoder_.read_message(client_socket);\n    auto cmd = protocol_decoder_.get_command_type();\n    switch (cmd) {\n    case Command::QUERY: {\n      std::string statement_received = protocol_decoder_.get_statement();\n\n      try {\n        handle_statement(client_socket, protocol_decoder_.packet_seq(),\n            json_reader_->handle_statement(statement_received));\n      } catch (const std::exception &e) {\n        // handling statement failed. Return the error to the client\n        uint8_t packet_seq = protocol_decoder_.packet_seq() + 1;   // rollover to 0 is ok\n        std::this_thread::sleep_for(json_reader_->get_default_exec_time());\n        send_error(client_socket, packet_seq, 1064, std::string(\"executing statement failed: \") + e.what());\n\n        // assume the connection is broken\n        return true;\n      }\n    }\n    break;\n    case Command::QUIT:\n      // std::cout << \"received QUIT command from the client\" << std::endl;\n      return true;\n    default:\n      std::cerr << \"received unsupported command from the client: \"\n                << static_cast<int>(cmd) << \"\\n\";\n      uint8_t packet_seq = protocol_decoder_.packet_seq() + 1;   // rollover to 0 is ok\n      std::this_thread::sleep_for(json_reader_->get_default_exec_time());\n      send_error(client_socket, packet_seq, 1064, \"Unsupported command: \" + std::to_string(cmd));\n    }\n  }\n\n  return true;\n}\n\nstatic void debug_trace_result(const ResultsetResponse *resultset) {\n  std::cout << \"QUERY RESULT:\\n\";\n  for (size_t i = 0; i < resultset->rows.size(); ++i) {\n    for (const auto& cell : resultset->rows[i])\n      std::cout << \"  |  \" << (cell.first ? cell.second : \"NULL\");\n    std::cout << \"  |\\n\";\n  }\n  std::cout << \"\\n\\n\\n\" << std::flush;\n}\n\nvoid MySQLServerMockSession::handle_statement(socket_t client_socket, uint8_t seq_no,\n                    const StatementAndResponse& statement) {\n  using StatementResponseType = StatementAndResponse::StatementResponseType;\n\n  switch (statement.response_type) {\n  case StatementResponseType::STMT_RES_OK: {\n    if (debug_mode_) std::cout << std::endl;  // visual separator\n    OkResponse *response = dynamic_cast<OkResponse *>(statement.response.get());\n    std::this_thread::sleep_for(statement.exec_time);\n    send_ok(client_socket, static_cast<uint8_t>(seq_no+1), 0, response->last_insert_id, 0, response->warning_count);\n  }\n  break;\n  case StatementResponseType::STMT_RES_RESULT: {\n    ResultsetResponse *response = dynamic_cast<ResultsetResponse *>(statement.response.get());\n    if (debug_mode_) {\n      debug_trace_result(response);\n    }\n    seq_no = static_cast<uint8_t>(seq_no + 1);\n    auto buf = protocol_encoder_.encode_columns_number_message(seq_no++, response->columns.size());\n    std::this_thread::sleep_for(statement.exec_time);\n    send_packet(client_socket, buf);\n    for (const auto& column: response->columns) {\n      auto col_buf = protocol_encoder_.encode_column_meta_message(seq_no++, column);\n      send_packet(client_socket, col_buf);\n    }\n    buf = protocol_encoder_.encode_eof_message(seq_no++);\n    send_packet(client_socket, buf);\n\n    for (size_t i = 0; i < response->rows.size(); ++i) {\n      auto res_buf = protocol_encoder_.encode_row_message(seq_no++, response->columns, response->rows[i]);\n      send_packet(client_socket, res_buf);\n    }\n    buf = protocol_encoder_.encode_eof_message(seq_no++);\n    send_packet(client_socket, buf);\n  }\n  break;\n  case StatementResponseType::STMT_RES_ERROR: {\n    if (debug_mode_) std::cout << std::endl;  // visual separator\n    ErrorResponse *response = dynamic_cast<ErrorResponse *>(statement.response.get());\n    send_error(client_socket, static_cast<uint8_t>(seq_no+1), response->code, response->msg);\n  }\n  break;\n  default:;\n    throw std::runtime_error(\"Unsupported command in handle_statement(): \" +\n      std::to_string((int)statement.response_type));\n  }\n}\n\nvoid MySQLServerMockSession::send_error(socket_t client_socket, uint8_t seq_no,\n                                 uint16_t error_code,\n                                 const std::string &error_msg,\n                                 const std::string &sql_state) {\n  auto buf = protocol_encoder_.encode_error_message(seq_no, error_code,\n                                                    sql_state, error_msg);\n  send_packet(client_socket, buf);\n}\n\nvoid MySQLServerMockSession::send_ok(socket_t client_socket, uint8_t seq_no,\n    uint64_t affected_rows,\n    uint64_t last_insert_id,\n    uint16_t server_status,\n    uint16_t warning_count) {\n  auto buf = protocol_encoder_.encode_ok_message(seq_no, affected_rows, last_insert_id, server_status, warning_count);\n  send_packet(client_socket, buf);\n}\n\n} // namespace server_mock\n"
  },
  {
    "path": "src/mock_server/src/mysql_server_mock.h",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLD_MOCK_MYSQL_SERVER_MOCK_INCLUDED\n#define MYSQLD_MOCK_MYSQL_SERVER_MOCK_INCLUDED\n\n#include <memory>\n#include <mutex>\n#include <set>\n\n#include \"statement_reader.h\"\n#include \"mysql_protocol_decoder.h\"\n#include \"mysql_protocol_encoder.h\"\n#include \"mysqlrouter/mock_server_component.h\"\n#include \"mysql/harness/plugin.h\"\n\nnamespace server_mock {\n\nclass MySQLServerMockSession {\npublic:\n  MySQLServerMockSession(socket_t client_sock,\n      std::unique_ptr<StatementReaderBase> statement_processor,\n      bool debug_mode);\n\n  ~MySQLServerMockSession();\n\n  void send_handshake(socket_t client_socket,\n                      mysql_protocol::Capabilities::Flags our_capabilities);\n\n  mysql_protocol::HandshakeResponsePacket handle_handshake_response(\n      socket_t client_socket,\n      mysql_protocol::Capabilities::Flags our_capabilities);\n\n  void handle_auth_switch(socket_t client_socket);\n\n  void send_fast_auth(socket_t client_socket);\n\n  bool process_statements(socket_t client_socket);\n\n  void handle_statement(socket_t client_socket, uint8_t seq_no,\n                        const StatementAndResponse& statement);\n\n  void send_error(socket_t client_socket, uint8_t seq_no,\n                  uint16_t error_code,\n                  const std::string &error_msg,\n                  const std::string &sql_state = \"HY000\");\n\n  void send_ok(socket_t client_socket, uint8_t seq_no,\n      uint64_t affected_rows=0,\n      uint64_t last_insert_id=0,\n      uint16_t server_status=0,\n      uint16_t warning_count=0);\n\n  void run();\n\n  void kill() {\n    killed_ = true;\n  }\nprivate:\n  bool killed_ { false };\n  socket_t client_socket_;\n  MySQLProtocolEncoder protocol_encoder_;\n  MySQLProtocolDecoder protocol_decoder_;\n  std::unique_ptr<StatementReaderBase> json_reader_;\n  bool debug_mode_;\n};\n\n/** @class MySQLServerMock\n *\n * @brief Main class. Resposible for accepting and handling client's connections.\n *\n **/\nclass MySQLServerMock {\n public:\n\n  /** @brief Constructor.\n   *\n   * @param expected_queries_file Path to the json file with definitins\n   *                        of the expected SQL statements and responses\n   * @param module_prefix prefix of javascript modules used by the nodejs compatible module-loader\n   * @param bind_port Number of the port on which the server accepts clients\n   *                        connections\n   * @param debug_mode Flag indicating if the handled queries should be printed to\n   *                   the standard output\n   */\n  MySQLServerMock(\n      const std::string &expected_queries_file,\n      const std::string &module_prefix,\n      unsigned bind_port,\n      bool debug_mode);\n\n  /** @brief Starts handling the clients connections in infinite loop.\n   *         Will return only in case of an exception (error).\n   */\n  void run(mysql_harness::PluginFuncEnv* env);\n\n  std::shared_ptr<MockServerGlobalScope> get_global_scope() {\n    return shared_globals_;\n  }\n\n  void close_all_connections();\n\n  ~MySQLServerMock();\n\n private:\n  void setup_service();\n\n  void handle_connections(mysql_harness::PluginFuncEnv* env);\n\n  static constexpr int kListenQueueSize = 128;\n  unsigned bind_port_;\n  bool debug_mode_;\n  socket_t listener_{socket_t(-1)};\n  std::string expected_queries_file_;\n  std::string module_prefix_;\n\n  std::shared_ptr<MockServerGlobalScope> shared_globals_ {new MockServerGlobalScope};\n\n  std::mutex active_fds_mutex_;\n  std::set<socket_t> active_fds_;\n};\n\n} // namespace\n\n#endif // MYSQLD_MOCK_MYSQL_SERVER_MOCK_INCLUDED\n"
  },
  {
    "path": "src/mock_server/src/mysql_server_mock.md",
    "content": "# MySQL %Protocol Trace Replayer\n\nThe MySQL %Protocol Trace Replayer\n\n* speaks (a subset of) the MySQL Client/Server protocol\n* knows how to\n\n  * authenticate\n  * respond to statements send by the client with\n\n    * resultsets\n    * status (Ok, last-insert-id, ...)\n    * Error\n\nIt reads the protocol trace from a JSON file which contains:\n\n* sequence of statements to expect\n* responses to send\n* extra context information like execution-times\n\n## Motivation\n\n### Testing in isolation\n\nTesting MySQL InnoDB Cluster components like\n\n* MySQL Shell\n* MySQL Router\n* Connectors\n\ninvolves:\n\n1. initialize a MySQL Server via the MySQL Shell `dba.deploySandboxInstance`\n\n  * which runs `mysqld --initialize`\n\n2. use the MySQL Shell to\n\n  * builds a cluster with ``dba.createCluster``\n  * add more nodes with ``cluster.addInstance``\n\n  (10-20 seconds).\n\n4. execute the statements to test the right behaviour (100ms)\n5. shut down the whole setup again (1s)\n\nThe setup and shutdown costs (20s) outscale the actual\ntest runtime (100ms) by a great margin.\n\n### Mocking the MySQL Server\n\nOn the other side all the components speak to the MySQL Server\nover the MySQL %Protocol only. Statements are sent, responses\nare received. What the MySQL Server did inbetween to generate\nthe response isn't visible from the outside.\n\nThere is no difference from the point of view of the clients\nif the response comes from a genuine MySQL Server or from\nanother program that returns the same bytes over the wire.\n\n## Simple Demo\n\nA simple trace-file:\n\n```{.json}\n{\"stmts\": [\n  {\n    \"stmt\": \"select @@version_comment limit 1\",\n    \"result\": {\n      \"columns\": [{\n        \"type\": \"STRING\",\n        \"name\": \"@@version_comment\"\n      }],\n      \"rows\": [\n        [\"ImAMock\"]\n      ]}\n  },\n  {\n    \"stmt\": \"select USER()\",\n    \"result\": {\n      \"columns\": [{\n        \"type\": \"STRING\",\n        \"name\": \"USER()\"\n      }],\n      \"rows\": [\n        [\"mock\"]\n      ]\n    }\n  }]\n}\n```\n\nStarting the mock:\n\n```\n$ ./mysql_server_mock ./simple.json 5500\n```\n\nUse a client to talk to the mock:\n\n```\n$ mysql --port=5500\nServer version: 8.0.0-mock ImAMock\n\n[...]\n\nmock@localhost:5500 (none)>\n```\n\n# Design Goals\n\n## Allow Faster Testing\n\nWhen using a MySQL Server the execution time of a statement is driven\nby the system that is used (storage-io, network-io, cpu speed, ...).\n\nIn cases where the execution time doesn't affect the behaviour\n(timeout testing, ...) the test setup could pretend the system\nhas zero latency (storage in RAM, super fast CPUs, local networks).\n\nIt would be required to:\n\n* capture the statement exchanged between client and server\n* provide a MySQL Server mock which\n\n  * speaks the MySQL %Protocol\n  * listens on a TCP port\n  * returns the predefined results depending on the statement as a MySQL Server would.\n\n## More Error Cases\n\nBy using the Server Mock it is easier to create error-cases that\nare hard to create in real setups:\n\n* disk full\n* server dead\n* nodes out of sync\n* ...\n\n## Less options for failure\n\nBy using the %Protocol Trace Replayer in the Router tests, the tests don't need\nthe rely on installing\n\n* MySQL Shell\n* MySQL Server\n\nwhich involves:\n\n* ensure the right version\n* check they actually work on the target\n* using the right paths\n\n## Not a Replacement for Integration tests\n\nthe %Protocol Trace Replayer is **NOT** a replacement for Integration tests where\n\n* a real Shell is used with\n* a real MySQL Server with\n* a real MySQL Router.\n\n# MySQL Router Demo\n\n## Bootstrapping a router\n\nTo bootstrap a router, the router expects to talk to a MySQL Server. It:\n\n* logs in with `root` and some password\n* executes 15 statements\n* writes ``mysqlrouter.conf``\n\nStart the \"MySQL Server\" mock on port ``5050`` with the ``bootstrapper.yaml``\n\n    $ ./mysql_server_mock --mysqld-port=5050 --stmt-file=./bootstrapper.yaml\n\nLet the router do the bootstrap\n\n    $ mysqlrouter --bootstrap localhost:5050 -d router-conf\n    Bootstrapping MySQL Router instance at <stripped>/rounter-conf...\n    MySQL Router  has now been configured for the InnoDB cluster 'test'.\n\n    The following connection information can be used to connect to the cluster.\n\n    Classic MySQL protocol connections to cluster 'test':\n    - Read/Write Connections: localhost:6446\n    - Read/Only Connections: localhost:6447\n\n    X protocol connections to cluster 'test':\n    - Read/Write Connections: localhost:64460\n    - Read/Only Connections: localhost:64470\n\nThe mock will log:\n\n    2017-01-24 12:24:11,551 MAIN INFO: listening on 5050\n    2017-01-24 12:24:23,357 MAIN INFO: accepted connection from ('127.0.0.1', 38684)\n    2017-01-24 12:24:23,358 MAIN DEBUG: received: SELECT * FROM mysql_innodb_cluster_metadata.schema_version\n    2017-01-24 12:24:23,358 MAIN DEBUG: sending Result\n    2017-01-24 12:24:23,395 MAIN DEBUG: received: SELECT  ((SELECT count(*) FROM ...\n\n\nAfter the bootstrap is finished the bootstrap-mysql-server-mock can be stopped.\n\n## Running the router\n\nUsing the bootstrapped config:\n\n* the metadata store is expected on port ``5500``\n* the data store is expected on port ``5100``\n\nStart the metadata-store\n\n    $ ./mysql_server_mock --mysqld-port=5500 --stmt-file=./metadata-store.yaml\n\nStart the data-store\n\n    $ ./mysql_server_mock --mysqld-port=5100 --stmt-file=./group-replication.yaml\n\nStart the router\n\n    $ mysqlrouter --config router-conf/mysqlrouter.conf\n\nThe router log file says:\n\n    2017-01-24 12:28:30 INFO    [7fc57d7eb700] [routing:test_default_ro] started: listening on 0.0.0.0:6447; read-only\n    2017-01-24 12:28:30 INFO    [7fc57dfec700] Starting Metadata Cache\n    2017-01-24 12:28:30 INFO    [7fc57cfea700] [routing:test_default_rw] started: listening on 0.0.0.0:6446; read-write\n    2017-01-24 12:28:30 INFO    [7fc577fff700] [routing:test_default_x_rw] started: listening on 0.0.0.0:64460; read-write\n    2017-01-24 12:28:30 INFO    [7fc5747e9700] [routing:test_default_x_ro] started: listening on 0.0.0.0:64470; read-only\n    2017-01-24 12:28:30 INFO    [7fc57dfec700] Connected with metadata server running on 127.0.0.1:5500\n    2017-01-24 12:28:30 INFO    [7fc57dfec700] Changes detected in cluster 'test' after metadata refresh\n    2017-01-24 12:28:30 INFO    [7fc57dfec700] Metadata for cluster 'test' has 1 replicasets:\n    2017-01-24 12:28:30 INFO    [7fc57dfec700] 'default' (3 members, single-master)\n    2017-01-24 12:28:30 INFO    [7fc57dfec700]     localhost:5100 / 50000 - role=HA mode=RW\n    2017-01-24 12:28:30 INFO    [7fc57dfec700]     localhost:5110 / 50100 - role=HA mode=RO\n    2017-01-24 12:28:30 INFO    [7fc57dfec700]     localhost:5120 / 50200 - role=HA mode=RO\n    2017-01-24 12:28:30 INFO    [7fc5757fa700] Connected with metadata server running on 127.0.0.1:5500\n\nThe ``metadata-store`` mock outputs:\n\n    2017-01-24 12:28:10,322 MAIN INFO: listening on 5500\n    2017-01-24 12:28:20,774 MAIN INFO: accepted connection from ('127.0.0.1', 53278)\n    2017-01-24 12:28:20,775 MAIN DEBUG: received: SELECT R.replicaset_name, I.mysql_server_uuid, I.role, I.weight, I.version_token, H.location, I.addresses->>'$.mysqlClassic', I.addresses->>'$.mysqlX' FROM mysql_innodb_cluster_metadata.clusters AS F JOIN mysql_innodb_cluster_metadata.replicasets AS R ON F.cluster_id = R.cluster_id JOIN mysql_innodb_cluster_metadata.instances AS I ON R.replicaset_id = I.replicaset_id JOIN mysql_innodb_cluster_metadata.hosts AS H ON I.host_id = H.host_id WHERE F.cluster_name = 'test';\n    2017-01-24 12:28:20,775 MAIN DEBUG: sending Result\n\nThe ``group-replication`` mock outputs:\n\n    2017-01-24 12:28:27,851 MAIN INFO: listening on 5100\n    2017-01-24 12:28:30,755 MAIN INFO: accepted connection from ('127.0.0.1', 41520)\n    2017-01-24 12:28:30,755 MAIN DEBUG: received: show status like 'group_replication_primary_member'\n    2017-01-24 12:28:30,755 MAIN DEBUG: sending Result\n    2017-01-24 12:28:30,795 MAIN DEBUG: received: SELECT member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode FROM performance_schema.replication_group_members WHERE channel_name = 'group_replication_applier'\n    2017-01-24 12:28:30,795 MAIN DEBUG: sending Result\n    2017-01-24 12:28:30,835 MAIN INFO: closed connection to ('127.0.0.1', 41520)\n\n## Trace files\n\nThe ``mysql_server_mock`` is driven by trace-files.\n\nIt describes what the mock shall respond with when it receives:\n\n* statements (``stmts``)\n\n### Format\n\n\\include src/mock_server/src/mysql_server_mock_schema.js\n"
  },
  {
    "path": "src/mock_server/src/mysql_server_mock_schema.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLD_MOCK_MYSQL_SERVER_MOCK_SCHEMA_INCLUDED\n#define MYSQLD_MOCK_MYSQL_SERVER_MOCK_SCHEMA_INCLUDED\n\n// contents are auto-generated at CMake level, using json_schema_embedder\n// (see json_schema_embedder.cc) and written into mysql_server_mock_schema.cc\nextern const char kSqlQueryJsonSchema[];\n\n#endif // MYSQLD_MOCK_MYSQL_SERVER_MOCK_SCHEMA_INCLUDED\n"
  },
  {
    "path": "src/mock_server/src/mysql_server_mock_schema.js",
    "content": "{\n  \"title\": \"MySQL Server Mock Data\",\n  \"description\": \"JSON Schema of the input files of the mysql-server-mock\",\n  \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n\n  \"type\": \"object\",\n  \"additionalProperties\": false,\n\n  \"definitions\": {\n    \"Ok\": {\n      \"description\": \"OK response\",\n      \"type\": \"object\",\n      \"additionalProperties\": false,\n      \"properties\": {\n        \"last_insert_id\": {\n          \"description\": \"last insert id\",\n          \"type\": \"integer\",\n          \"minimum\": 0,\n          \"default\": 0\n        },\n        \"warning_count\": {\n          \"description\": \"number of warnings\",\n          \"type\": \"integer\",\n          \"minimum\": 0,\n          \"default\": 0\n        }\n      }\n    },\n\n    \"Error\": {\n      \"description\": \"Error response\",\n      \"type\": \"object\",\n      \"additionalProperties\": false,\n      \"required\": [\"code\", \"message\"],\n      \"properties\": {\n        \"message\": {\n          \"type\": \"string\"\n        },\n        \"sql_state\": {\n          \"description\": \"SQL state\",\n          \"type\": \"string\",\n          \"minLength\": 5,\n          \"maxLength\": 5,\n          \"default\": \"HY000\"\n        },\n        \"code\": {\n          \"description\": \"error code\",\n          \"type\": \"integer\",\n          \"minimum\": 0\n        }\n      }\n    },\n\n    \"ExecTime\": {\n      \"description\": \"Execution time in milliseconds\",\n      \"type\": \"number\",\n      \"minimum\": 0,\n      \"default\": 0\n    },\n\n    \"ResultsetColumn\": {\n      \"description\": \"column description\",\n      \"type\": \"object\",\n      \"additionalProperties\": false,\n      \"required\": [\"type\", \"name\"],\n\n      \"properties\": {\n        \"type\": {\n          \"description\": \"datatype of the column\",\n          \"enum\": [\n            \"TINY\",\n            \"SHORT\",\n            \"LONG\",\n            \"INT24\",\n            \"LONGLONG\",\n            \"DECIMAL\",\n            \"NEWDECIMAL\",\n            \"FLOAT\",\n            \"DOUBLE\",\n            \"BIT\",\n            \"TIMESTAMP\",\n            \"DATE\",\n            \"TIME\",\n            \"DATETIME\",\n            \"YEAR\",\n            \"STRING\",\n            \"VAR_STRING\",\n            \"BLOB\",\n            \"SET\",\n            \"ENUM\",\n            \"GEOMETRY\",\n            \"NULL\",\n            \"TINYBLOB\",\n            \"LONGBLOB\",\n            \"MEDIUMBLOB\"\n          ]\n        },\n        \"name\": {\n          \"description\": \"name of the column\",\n          \"type\": \"string\"\n        },\n        \"orig_name\": {\n          \"description\": \"original name of the column\",\n          \"type\": \"string\"\n        },\n        \"table\": {\n          \"description\": \"name of the column table\",\n          \"type\": \"string\"\n        },\n        \"orig_table\": {\n          \"description\": \"original name of the column table\",\n          \"type\": \"string\"\n        },\n        \"schema\": {\n          \"description\": \"name of the column table schema\",\n          \"type\": \"string\"\n        },\n        \"catalog\": {\n          \"description\": \"name of the catalog\",\n          \"type\": \"string\"\n        },\n        \"flags\": {\n          \"description\": \"column flags\",\n          \"type\": \"integer\",\n          \"minimum\": 0,\n          \"maximum\": 65535,\n          \"default\": 0\n        },\n        \"decimals\": {\n          \"description\": \"column decimals\",\n          \"type\": \"integer\",\n          \"minimum\": 0,\n          \"maximum\": 255,\n          \"default\": 0\n        },\n        \"length\": {\n          \"description\": \"column length\",\n          \"type\": \"integer\",\n          \"minimum\": 0\n        },\n        \"character_set\": {\n          \"description\": \"column character set\",\n          \"type\": \"integer\",\n          \"minimum\": 0,\n          \"maximum\": 65535,\n          \"default\": 63\n        },\n        \"comment\": {\n          \"description\": \"additional information/comment about the column; ignored by the server mock, for self-documenting only\",\n          \"type\": \"string\"\n        },\n        \"repeat\": {\n          \"description\": \"if set to positive number n, the data for given field will be duplicated n times; useful for generating big packets; supported only for columns with type STRING\",\n          \"type\": \"integer\",\n          \"minimum\": 1,\n          \"default\": 1\n        }\n      }\n    },\n\n    \"ResultsetRow\": {\n      \"description\": \"resultset row\",\n      \"type\": \"array\",\n      \"minItems\": 1,\n      \"items\": {\n        \"title\": \"ResultsetField\",\n        \"description\": \"field of a resultset row\",\n        \"type\": [ \"number\", \"string\", \"boolean\", \"null\" ]\n      }\n    },\n\n    \"Result\": {\n      \"description\": \"resultset for a statement\",\n      \"type\": \"object\",\n      \"additionalProperties\": false,\n\n      \"properties\": {\n        \"columns\": {\n          \"description\": \"column descriptions\",\n          \"type\": \"array\",\n          \"minItems\": 1,\n          \"items\": {\n            \"$ref\": \"#/definitions/ResultsetColumn\"\n          }\n        },\n        \"rows\": {\n          \"description\": \"resultset rows\",\n          \"type\": \"array\",\n          \"items\": {\n            \"$ref\": \"#/definitions/ResultsetRow\"\n          }\n        }\n      },\n      \"required\": [\"columns\"]\n    },\n\n    \"RPC\": {\n      \"description\": \"statement and its response\",\n      \"type\": \"object\",\n      \"additionalProperties\": false,\n\n      \"properties\": {\n        \"stmt\": {\n          \"description\": \"statement text\",\n          \"type\": \"string\"\n        },\n        \"exec_time\" : {\n          \"$ref\": \"#/definitions/ExecTime\"\n        },\n        \"stmt.regex\": {\n          \"description\": \"regular expression matching the statement text\",\n          \"type\": \"string\"\n        },\n        \"result\": {\n          \"$ref\": \"#/definitions/Result\"\n        },\n        \"ok\": {\n          \"$ref\": \"#/definitions/Ok\"\n        },\n        \"error\": {\n          \"$ref\": \"#/definitions/Error\"\n        }\n      },\n      \"allOf\": [\n        {\n          \"oneOf\": [\n            {\n              \"required\": [\"stmt\"]\n            },\n            {\n              \"required\": [\"stmt.regex\"]\n            }\n          ]\n        },\n        {\n          \"oneOf\": [\n            {\n              \"required\": [\"ok\"]\n            },\n            {\n              \"required\": [\"result\"]\n            },\n            {\n              \"required\": [\"error\"]\n            }\n          ]\n        }\n      ]\n    }\n  },\n\n  \"properties\": {\n    \"defaults\": {\n      \"description\": \"Default options\",\n      \"type\": \"object\",\n       \"properties\" : {\n         \"exec_time\" : {\n           \"$ref\": \"#/definitions/ExecTime\"\n         }\n       }\n    },\n    \"stmts\": {\n      \"description\": \"RPCs that the mock will expect and process one after the other\",\n      \"type\": \"array\",\n      \"items\": {\n        \"$ref\": \"#/definitions/RPC\"\n      }\n    }\n  },\n  \"required\": [\"stmts\"]\n}\n"
  },
  {
    "path": "src/mock_server/src/rest_mock_server.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/**\n */\n\n#include <atomic>\n#include <chrono>\n\n#include <rapidjson/document.h>\n#include <rapidjson/writer.h>\n#include <rapidjson/error/en.h>\n\n// Harness interface include files\n#include \"mysql/harness/config_parser.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysql/harness/plugin.h\"\n\n#include \"mysqlrouter/plugin_config.h\"\n\n#include \"mysqlrouter/http_server_component.h\"\n#include \"mysqlrouter/mock_server_component.h\"\n\nIMPORT_LOG_FUNCTIONS()\n\n#ifdef _WIN32\n  // workaround error C2039: 'GetObjectA': is not a member of ...\n  //\n  // as winnt.h #defines GetObject(...) GetObjectA(...)\n  // and we call json_doc.GetObject() which gets replaced by the c-pre-processor\n#  ifdef GetObject\n#    undef GetObject\n#  endif\n#endif\n\nstatic constexpr const char kSectionName[] { \"rest_mock_server\" };\nstatic constexpr const char kRestGlobalsUri[] { \"^/api/v1/mock_server/globals/$\" };\nstatic constexpr const char kRestConnectionsUri[] { \"^/api/v1/mock_server/connections/$\" };\n\n// AddressSanitizer gets confused by the default, MemoryPoolAllocator\n// Solaris sparc also gets crashes\nusing JsonDocument = rapidjson::GenericDocument<rapidjson::UTF8<>,  rapidjson::CrtAllocator>;\nusing JsonValue = rapidjson::GenericValue<rapidjson::UTF8<>,  rapidjson::CrtAllocator>;\n\n\nusing mysql_harness::ARCHITECTURE_DESCRIPTOR;\nusing mysql_harness::PluginFuncEnv;\nusing mysql_harness::PLUGIN_ABI_VERSION;\nusing mysql_harness::Plugin;\n\nclass RestApiV1MockServerGlobals: public BaseRequestHandler {\npublic:\n  RestApiV1MockServerGlobals():\n    last_modified_(time(nullptr)) {}\n\n  // GET|PUT\n  //\n  void handle_request(HttpRequest &req) override {\n    last_modified_ = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());\n\n    if (!((HttpMethod::Get|HttpMethod::Put) & req.get_method())) {\n      req.get_output_headers().add(\"Allow\", \"GET, PUT\");\n      req.send_reply(HttpStatusCode::MethodNotAllowed);\n      return;\n    }\n\n    if (req.get_input_headers().get(\"Content-Range\")) {\n      req.send_reply(HttpStatusCode::NotImplemented);\n      return;\n    }\n\n    if (HttpMethod::Get & req.get_method()) {\n      if (!req.is_modified_since(last_modified_)) {\n        req.send_reply(HttpStatusCode::NotModified);\n        return;\n      }\n\n      // GET\n      req.add_last_modified(last_modified_);\n\n      handle_global_get_all(req);\n    } else if (HttpMethod::Put & req.get_method()) {\n      handle_global_put_all(req);\n    }\n  }\nprivate:\n  time_t last_modified_;\n\n  void handle_global_put_all(HttpRequest &req) {\n    const char *content_type = req.get_input_headers().get(\"Content-Type\");\n    // PUT\n    //\n    // required content-type: application/json\n    if (nullptr == content_type || std::string(content_type) != \"application/json\") {\n      req.send_reply(HttpStatusCode::UnsupportedMediaType);\n      return;\n    }\n    auto body = req.get_input_buffer();\n    auto data = body.pop_front(body.length());\n    std::string str_data(data.begin(), data.end());\n\n    JsonDocument body_doc;\n    body_doc.Parse(str_data.c_str());\n\n    if (body_doc.HasParseError()) {\n      auto out_hdrs = req.get_output_headers();\n      auto out_buf = req.get_output_buffer();\n      out_hdrs.add(\"Content-Type\", \"text/plain\");\n\n      std::string parse_error(rapidjson::GetParseError_En(body_doc.GetParseError()));\n\n      out_buf.add(parse_error.data(), parse_error.size());\n\n      req.send_reply(HttpStatusCode::UnprocessableEntity, \"Unprocessable Entity\", out_buf);\n      return;\n    }\n\n    if (!body_doc.IsObject()) {\n      req.send_reply(HttpStatusCode::UnprocessableEntity);\n      return;\n    }\n\n    // replace all the globals\n    typename MockServerGlobalScope::type all_globals;\n\n    for (auto& m : body_doc.GetObject()) {\n      rapidjson::StringBuffer json_buf;\n      rapidjson::Writer<rapidjson::StringBuffer> json_writer(json_buf);\n      m.value.Accept(json_writer);\n\n      all_globals[m.name.GetString()] = std::string(json_buf.GetString(), json_buf.GetSize());\n    }\n\n    auto shared_globals = MockServerComponent::getInstance().getGlobalScope();\n    shared_globals->reset(all_globals);\n\n    req.send_reply(HttpStatusCode::NoContent);\n  }\n\n  void handle_global_get_all(HttpRequest &req) {\n    auto chunk = req.get_output_buffer();\n\n    {\n      rapidjson::StringBuffer json_buf;\n      {\n        rapidjson::Writer<rapidjson::StringBuffer> json_writer(json_buf);\n        JsonDocument json_doc;\n\n        json_doc.SetObject();\n\n        auto shared_globals = MockServerComponent::getInstance().getGlobalScope();\n        auto all_globals = shared_globals->get_all();\n\n        for (auto &element: all_globals) {\n          JsonDocument value_doc;\n          value_doc.Parse(element.second.c_str()); // value is a json-value as string\n\n          if (value_doc.HasParseError()) {\n            req.send_reply(HttpStatusCode::InternalError);\n            return;\n          }\n\n          json_doc.AddMember(\n              JsonValue(element.first.c_str(), element.first.size(), json_doc.GetAllocator()),\n              value_doc,\n              json_doc.GetAllocator());\n        }\n\n        json_doc.Accept(json_writer);\n      } // free json_doc and json_writer early\n\n      // perhaps we could use evbuffer_add_reference() and a unique-ptr on json_buf here.\n      // needs to be benchmarked\n      chunk.add(json_buf.GetString(), json_buf.GetSize());\n    } // free json_buf early\n\n    auto out_hdrs = req.get_output_headers();\n    out_hdrs.add(\"Content-Type\", \"application/json\");\n\n    req.send_reply(HttpStatusCode::Ok, \"Ok\", chunk);\n  }\n\n};\n\nclass RestApiV1MockServerConnections: public BaseRequestHandler {\npublic:\n  // allow methods: DELETE\n  //\n  void handle_request(HttpRequest &req) override {\n    if (!((HttpMethod::Delete) & req.get_method())) {\n      req.get_output_headers().add(\"Allow\", \"DELETE\");\n      req.send_reply(HttpStatusCode::MethodNotAllowed);\n      return;\n    }\n\n    if (req.get_input_headers().get(\"Content-Range\")) {\n      req.send_reply(HttpStatusCode::NotImplemented);\n      return;\n    }\n\n    handle_connections_delete_all(req);\n  }\nprivate:\n  /**\n   * close all connections.\n   */\n  void handle_connections_delete_all(HttpRequest &req) {\n    // tell the mock_server to close all connections\n    MockServerComponent::getInstance().close_all_connections();\n\n    req.send_reply(HttpStatusCode::Ok);\n  }\n\n};\n\n\nstatic void init(PluginFuncEnv* env) {\n  const mysql_harness::AppInfo* info = get_app_info(env);\n\n  if (nullptr == info->config) {\n    return;\n  }\n\n  for (const mysql_harness::ConfigSection* section: info->config->sections()) {\n    if (section->name != kSectionName) {\n      continue;\n    }\n\n    // hmm, what to read from the config?\n  }\n}\n\nstatic void start(PluginFuncEnv*) {\n  auto &srv = HttpServerComponent::getInstance();\n\n  srv.add_route(kRestGlobalsUri, std::unique_ptr<BaseRequestHandler>(new RestApiV1MockServerGlobals()));\n  srv.add_route(kRestConnectionsUri, std::unique_ptr<BaseRequestHandler>(new RestApiV1MockServerConnections()));\n}\n\nstatic void stop(PluginFuncEnv*) {\n  auto &srv = HttpServerComponent::getInstance();\n\n  srv.remove_route(kRestConnectionsUri);\n  srv.remove_route(kRestGlobalsUri);\n}\n\n\n#if defined(_MSC_VER) && defined(rest_mock_server_EXPORTS)\n/* We are building this library */\n#  define DLLEXPORT __declspec(dllexport)\n#else\n#  define DLLEXPORT\n#endif\n\nconst char *plugin_requires[] = {\n  \"mock_server\",\n  \"http_server\",\n};\n\nextern \"C\" {\nPlugin DLLEXPORT harness_plugin_rest_mock_server = {\n  PLUGIN_ABI_VERSION,\n  ARCHITECTURE_DESCRIPTOR,\n  \"REST_MOCK_SERVER\",\n  VERSION_NUMBER(0, 0, 1),\n  sizeof(plugin_requires)/sizeof(plugin_requires[0]), plugin_requires,  // requires\n  0, nullptr,  // conflicts\n  init,        // init\n  nullptr,     // deinit\n  start,       // start\n  stop,     // stop\n};\n}\n"
  },
  {
    "path": "src/mock_server/src/statement_reader.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLD_MOCK_STATEMENT_READER_INCLUDED\n#define MYSQLD_MOCK_STATEMENT_READER_INCLUDED\n\n#include <chrono>\n#include <memory>\n#include <string>\n#include <vector>\n\n#include \"mysql_protocol_common.h\"\n\nnamespace server_mock {\n\nstruct Response {\n  virtual ~Response() = default;\n};\n\n/** @brief Keeps result data for single SQL statement that returns\n *         resultset.\n **/\nstruct ResultsetResponse : public Response {\n  std::vector<column_info_type> columns;\n  std::vector<RowValueType> rows;\n};\n\nstruct OkResponse : public Response {\n  OkResponse(unsigned int last_insert_id_=0, unsigned int warning_count_=0) : last_insert_id(last_insert_id_), warning_count(warning_count_) {}\n\n  unsigned int last_insert_id;\n  unsigned int warning_count;\n};\n\nstruct ErrorResponse : public Response {\n  ErrorResponse(unsigned int code_, std::string msg_, std::string sql_state_=\"HY000\") : code(code_), msg(msg_), sql_state(sql_state_) {}\n\n  unsigned int code;\n  std::string msg;\n  std::string sql_state;\n};\n\n/** @class StatementAndResponse\n *\n * @brief Keeps single SQL statement data.\n **/\nstruct StatementAndResponse {\n  /** @enum StatementResponseType\n   *\n   * Response expected for given SQL statement.\n   **/\n  enum class StatementResponseType {\n     STMT_RES_UNKNOWN, STMT_RES_OK, STMT_RES_ERROR, STMT_RES_RESULT\n  };\n\n  // exected response type for the statement\n  StatementResponseType response_type;\n\n  std::unique_ptr<Response> response;\n\n  // execution time in microseconds\n  std::chrono::microseconds exec_time{0};\n};\n\nclass StatementReaderBase {\n public:\n  /** @brief Returns the data about the next statement from the\n   *         json file. If there is no more statements it returns\n   *         empty statement.\n   **/\n  virtual StatementAndResponse handle_statement(const std::string &statement) = 0;\n\n  /** @brief Returns the default execution time in microseconds. If\n   *         no default execution time is provided in json file, then\n   *         0 microseconds is returned.\n   **/\n  virtual std::chrono::microseconds get_default_exec_time() = 0;\n\n  virtual ~StatementReaderBase() = default;\n};\n\n\n}\n\n#endif\n"
  },
  {
    "path": "src/mysql_protocol/CMakeLists.txt",
    "content": "# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nset(SOURCE_FILES\n  src/handshake_packet.cc\n  src/error_packet.cc\n  src/base_packet.cc\n  )\n\nset(include_dirs\n  ../src/router/include\n  include\n  )\n\nadd_harness_plugin(mysql_protocol\n  SOURCES ${SOURCE_FILES}\n  REQUIRES router_lib)\ntarget_include_directories(mysql_protocol PRIVATE ${include_dirs})\n\n# don't install headers until a) a final destination is found and b) API is stable\n# file(GLOB mysqlv10_headers include/mysqlrouter/*.h)\n# install(FILES ${mysqlv10_headers}\n#   DESTINATION \"include/mysql/${HARNESS_NAME}\")\n\n# file(GLOB mysqlv10_headers include/mysqlrouter/mysql_protocol/*.h)\n# install(FILES ${mysqlv10_headers}\n#   DESTINATION \"include/${HARNESS_NAME}/mysql_protocol\")\n\nif(ENABLE_TESTS)\n  add_subdirectory(tests/)\nendif()\n"
  },
  {
    "path": "src/mysql_protocol/include/mysqlrouter/mysql_protocol/base_packet.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_MYSQL_PROTOCOL_BASE_PACKET_INCLUDED\n#define MYSQLROUTER_MYSQL_PROTOCOL_BASE_PACKET_INCLUDED\n\n#include <algorithm>\n#include <climits>\n#include <cstdint>\n#include <iostream>\n#include <utility>\n#include <stdexcept>\n#include <string>\n#include <vector>\n\n#include \"harness_assert.h\"\n\n// GCC 4.8.4 requires all classes to be forward-declared before being used with\n// \"friend class <friendee>\", if they're in a different namespace than the friender\n#ifdef FRIEND_TEST\n#include \"mysqlrouter/utils.h\"  // DECLARE_TEST\n  DECLARE_TEST(HandshakeResponseParseTest, server_does_not_support_PROTOCOL_41);\n  DECLARE_TEST(HandshakeResponseParseTest, no_PROTOCOL_41);\n  DECLARE_TEST(HandshakeResponseParseTest, bad_payload_length);\n  DECLARE_TEST(HandshakeResponseParseTest, bad_seq_number);\n  DECLARE_TEST(HandshakeResponseParseTest, max_packet_size);\n  DECLARE_TEST(HandshakeResponseParseTest, character_set);\n  DECLARE_TEST(HandshakeResponseParseTest, reserved);\n  DECLARE_TEST(HandshakeResponseParseTest, username);\n  DECLARE_TEST(HandshakeResponseParseTest, auth_response);\n  DECLARE_TEST(HandshakeResponseParseTest, database);\n  DECLARE_TEST(HandshakeResponseParseTest, auth_plugin);\n  DECLARE_TEST(HandshakeResponseParseTest, connection_attrs);\n  DECLARE_TEST(HandshakeResponseParseTest, all);\n#endif\n\nnamespace mysql_protocol {\n\n/** @class Packet\n * @brief Interface to MySQL packets\n *\n * This class is the base class for all the types of MySQL packets\n * such as ErrorPacket and HandshakeResponsePacket.\n *\n */\nclass MYSQL_PROTOCOL_API Packet : public std::vector<uint8_t> {\n\n  /** @note This class exposes several types of methods for data manipulation.\n   *\n   * Packet buffer operations, they work like standard stream operations:\n   *   seek()/tell()  - set/get buffer position\n   *   write_*()      - write data at current buffer position\n   *   read_*()       - read data at current buffer position\n   *\n   * Packet buffer operations with specified position:\n   *   read_*_from()  - read data from specified buffer position\n   *\n   * Packet field setters/getters:\n   *   get_*()   - return fields from this class (packet needs to be parsed first)\n   *   set_*()   - set fields in this class\n   */\n\n public:\n  using vector_t = std::vector<uint8_t>;\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n// constructors, destructors, assignment operators\n////////////////////////////////////////////////////////////////////////////////\n\n  /** @brief Header length of packets */\n  static const unsigned int kHeaderSize{4};\n\n  /** @brief Default of max_allowed_packet defined by the MySQL Server (2^30) */\n  static const unsigned int kMaxAllowedSize{1073741824};\n\n  /** @brief Constructor */\n  Packet() : Packet(0, Capabilities::ALL_ZEROS) { }\n\n  /** @overload\n   *\n   * This constructor takes a buffer, stores the data, and tries to get\n   * information out of the buffer.\n   *\n   * When buffer is 4 or bigger, the payload size and sequence ID of the packet\n   * is read from the first 4 bytes (packet header).\n   *\n   * When allow_partial is false, the payload size is not enforced and buffer\n   * can be smaller than payload size given in the header. Allow partial packets\n   * can be useful when all you need is to parse the heade\n   *\n   * @param buffer Vector of uint8_t\n   * @param allow_partial Whether to allow buffers which have incomplete payload\n   */\n  explicit Packet(const vector_t &buffer, bool allow_partial = false)\n      : Packet(buffer, Capabilities::ALL_ZEROS, allow_partial) { }\n\n  /** @overload\n   *\n   * @param buffer Vector of uint8_t\n   * @param capabilities Server or Client capability flags\n   * @param allow_partial Whether to allow buffers which have incomplete payload\n   */\n  Packet(const vector_t &buffer, Capabilities::Flags capabilities, bool allow_partial = false);\n\n  /** @overload\n   *\n   * @param sequence_id Sequence ID of MySQL packet\n   */\n  explicit Packet(uint8_t sequence_id) : Packet(sequence_id, Capabilities::ALL_ZEROS) { }\n\n  /** @overload\n   *\n   * @param sequence_id Sequence ID of MySQL packet\n   * @param capabilities Server or Client capability flags\n   */\n  Packet(uint8_t sequence_id, Capabilities::Flags capabilities)\n      : vector(), sequence_id_(sequence_id),\n        payload_size_(0), capability_flags_(capabilities) { }\n\n  /** @overload */\n  Packet(std::initializer_list<uint8_t> ilist);\n\n  /** @brief Destructor */\n  virtual ~Packet() { }\n\n  /** @brief Copy Constructor */\n  Packet(const Packet&) = default;\n\n  /** @brief Move Constructor */\n  Packet(Packet &&other) : vector(std::move(other)), sequence_id_(other.get_sequence_id()),\n                           payload_size_(other.get_payload_size()),\n                           capability_flags_(other.get_capabilities()) {\n    other.sequence_id_ = 0;\n    other.capability_flags_ = Capabilities::ALL_ZEROS;\n    other.payload_size_ = 0;\n  }\n\n  /** @brief Copy Assignment */\n  Packet &operator=(const Packet &) = default;\n\n  /** @brief Move Assigment */\n  Packet &operator=(Packet &&other) {\n    swap(other);\n    sequence_id_ = other.sequence_id_;\n    payload_size_ = other.payload_size_;\n    capability_flags_ = other.get_capabilities();\n    other.sequence_id_ = 0;\n    other.capability_flags_ = Capabilities::ALL_ZEROS;\n    other.payload_size_ = 0;\n    return *this;\n  }\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n// packet buffer operations: stream interface\n////////////////////////////////////////////////////////////////////////////////\n\n  /** @brief Sets current read/write position used by read_*()/write_*() calls */\n  void seek(size_t position) const {\n    if (position > size())\n      throw std::range_error(\"seek past EOF\");\n    position_ = position;\n  }\n\n  /** @brief Returns current read/write position used by read_*()/write_*() calls */\n  size_t tell() const {\n    return position_;\n  }\n\n  /** @brief Gets an integral from given packet\n   *\n   * Gets an integral from packet buffer at the current position and advances it\n   * by the length of the read. The size of the integral is deduced from the give\n   * type but can be overwritten using the size parameter.\n   *\n   * Supported are integral of 1, 2, 3, 4, or 8 bytes. To retrieve an 24 bit\n   * integral it is necessary to use a 32-bit integral type and\n   * provided the size, for example:\n   *\n   *     auto id = Packet::read_int_from<uint32_t>(buffer, 0, 3);\n   *\n   * In MySQL packets, integrals are stored using little-endian format.\n   *\n   * @param length size of the integer to parse\n   * @return integer type\n   *\n   * @throws std::range_error (std::runtime_error) on start or end beyond EOF\n   *\n   * @see read_int_from()\n   */\n  template<typename Type, typename = std::enable_if<std::is_integral<Type>::value>>\n  Type read_int(size_t length = sizeof(Type)) const {\n    Type res = read_int_from<Type>(position_, length); // throws range_error/runtime_error\n    position_ += length;\n    return res;\n  }\n\n  /** @brief Gets a length encoded integer from given packet\n   *\n   * Gets a length encoded integer from packet buffer at the current position\n   * and advances it by the length of the read. Function also returns the length\n   * of the parsed integer token (you will need to advance your read position by\n   * this value to get to next field in the packet)\n   *\n   * @return uint64_t\n   *\n   * @throws std::range_error (std::runtime_error) on start or end beyond EOF,\n   *         std::runtime_error on bad first byte (which determines int length)\n   *         (strong exception safety guarrantee)\n   *\n   * @see read_lenenc_uint_from()\n   */\n  uint64_t read_lenenc_uint() const;\n\n  /** @brief Gets raw bytes from packet\n    *\n    * Gets raw byes from packet buffer at the current position and advances it\n    * by the length of the read.\n    *\n    * @param length Number of bytes to read\n    * @return std::vector<uint8_t>\n    *\n    * @throws std::range_error (std::runtime_error) on start or end beyond EOF\n    *         (strong exception safety guarrantee)\n    *\n    * @see read_bytes_from()\n    */\n  std::vector<uint8_t> read_bytes(size_t length) const;\n\n  /** @brief Gets raw bytes from packet using length encoded size\n   *\n   * Gets raw bytes with length encoded size from packet buffer at the current\n   * position and advances it by the length of the read.\n   *\n   * @return std::vector<uint8_t>\n   *\n   * @throws std::range_error (std::runtime_error) on start or end beyond EOF,\n   *         std::runtime_error on bad first byte (which determines int length)\n   *         (strong exception safety guarrantee)\n   *\n   * @see read_lenenc_bytes_from()\n   */\n  std::vector<uint8_t> read_lenenc_bytes() const;\n\n  /** @brief Gets zero-terminated string from packet\n   *\n   * Gets zero-terminated string from packet buffer at the current position and\n   * advances it by the length of the read.\n   *\n   * @return std::string\n   *\n   * @see read_string_nul_from()\n   */\n  std::string read_string_nul() const;\n\n  /** @brief Gets raw bytes from packet from position until EOF\n   *\n   * Gets raw bytes from packet buffer at the current position and advances it\n   * by the length of the read.\n   *\n   * @return std::vector<uint8_t>\n   *\n   * @throws std::range_error (std::runtime_error) on start beyond EOF,\n   *         std::runtime_error on zero-terminator not found\n   *         (strong exception safety guarrantee)\n   *\n   * @see read_bytes_eof_from()\n   */\n  std::vector<uint8_t> read_bytes_eof() const;\n\n  /** @brief Packs and adds an integral to the buffer\n   *\n   * Packs and adds an integral to the given buffer.\n   *\n   * @param value Integral to add to the packet\n   * @param length Size of the integral (default: size of integral)\n   *\n   */\n  template<class T, typename = std::enable_if<std::is_integral<T>::value>>\n  void write_int(T value, size_t length = sizeof(T)) {\n    reserve(size() + length);\n    while(length-- > 0) {\n      // Assignment to temporary variable `b` prevents too aggressive inlining\n      // optimization in some compilers (e.g. GCC 4.9.2 on Solaris, with -O2).\n      // Without it, `value` wasn't getting updated before push_back() under\n      // certain conditions, and resulted in filling packet's buffer with\n      // invalid data.\n      uint8_t b = static_cast<uint8_t>(value);\n      update_or_append(b);\n      value = static_cast<T>(value >> CHAR_BIT);\n    }\n  }\n\n  /** @brief Packs and adds a length-encoded integral to the buffer\n   *\n   * Packs and adds a length-encoded integral to the given buffer.\n   *\n   * @param value Integral to add to the packet\n   * @return Size of the encoded integral (one of: 1, 3, 4 or 9 bytes)\n   */\n  size_t write_lenenc_uint(uint64_t value);\n\n  /** @brief Adds bytes to the given packet\n   *\n   * Adds the given bytes to the buffer.\n   *\n   * @param bytes Bytes to add to the packet\n   *\n   */\n  void write_bytes(const Packet::vector_t &bytes) {\n    write_bytes_impl(bytes.data(), bytes.size());\n  }\n\n  /** @brief Adds a string to the given packet\n   *\n   * Adds the given string to the buffer. It does not append a zero-terminator\n   * after this string.\n   *\n   * @param str String to add to the packet\n   */\n  void write_string(const std::string &str) {\n    write_bytes_impl(reinterpret_cast<const uint8_t*>(str.data()), str.size());\n  } //               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ std::string contains signed chars\n\n  /** @brief Adds bytes at the end of the buffer\n   *\n   * Appends a byte many times to the packet buffer at EOF and advances current\n   * position by the length of the write (so that it points to EOF once again)\n   *\n   * @param count number of times to append the byte\n   * @param byte byte to append\n   *\n   * @throws std::range_error (std::runtime_error) if current position is not\n   *         currently at EOF\n   */\n  void append_bytes(size_t count, uint8_t byte);\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n// packet buffer operations: direct position interface\n////////////////////////////////////////////////////////////////////////////////\n\n  /** @brief Gets an integral from given packet\n   *\n   * Gets an integral from a buffer at the given position. The size of the\n   * integral is deduced from the give type but can be overwritten using\n   * the size parameter.\n   *\n   * Supported are integral of 1, 2, 3, 4, or 8 bytes. To retrieve an 24 bit\n   * integral it is necessary to use a 32-bit integral type and\n   * provided the size, for example:\n   *\n   *     auto id = Packet::read_int_from<uint32_t>(buffer, 0, 3);\n   *\n   * In MySQL packets, integrals are stored using little-endian format.\n   *\n   * @param position Position where to start reading\n   * @param length size of the integer to parse\n   * @return integer type\n   *\n   * @throws std::range_error (std::runtime_error) on start or end beyond EOF\n   */\n  template<typename Type, typename = std::enable_if<std::is_integral<Type>::value>>\n  Type read_int_from(size_t position, size_t length = sizeof(Type)) const {\n\n    harness_assert((length >= 1 && length <= 4) || length == 8);\n    if (position + length > size())\n      throw std::range_error(\"start or end beyond EOF\");\n\n    if (length == 1) {\n      return static_cast<Type>((*this)[position]);\n    }\n\n    uint64_t result = 0;\n    auto it = begin() + static_cast<long>(position + length);\n    while (length-- > 0) {\n      result <<= 8;\n      result |= *--it;\n    }\n\n    return static_cast<Type>(result);\n  }\n\n  /** @brief Gets a length encoded integer from given packet\n   *\n   * Function also returns the length of the parsed integer token (you will need\n   * to advance your read position by this value to get to next field in the packet)\n   *\n   * @param position Position where to start reading\n   * @return std::pair<uint64_t, size_t>\n   *\n   * @throws std::range_error (std::runtime_error) on start or end beyond EOF,\n   *         std::runtime_error on bad first byte (which determines int length)\n   *         (strong exception safety guarrantee)\n   */\n  std::pair<uint64_t, size_t> read_lenenc_uint_from(size_t position) const;\n\n  /** @brief Gets a string from packet\n   *\n   * Gets a string from the given buffer at the given position. When size is\n   * not given, we read until the end of the buffer.\n   * When nil byte is found before we reach the requested size, the string will be\n   * not be size long (if size is not 0).\n   *\n   * When pos is greater than the size of the buffer, an empty string is returned.\n   *\n   * @param position Position from which to start reading\n   * @param length Length of the string to read (default 0)\n   * @return std::string\n   */\n  std::string read_string_from(unsigned long position,\n                         unsigned long length = UINT_MAX) const;\n\n  /** @brief Gets a zero-terminated string from packet\n   *\n   * @param position Position from which to start reading\n   * @return std::string\n   *\n   * @throws std::range_error (std::runtime_error) on start beyond EOF,\n   *         std::runtime_error on zero-terminator not found\n   *         (strong exception safety guarrantee)\n   */\n  std::string read_string_nul_from(size_t position) const;\n\n  /** @brief Gets raw bytes from packet\n    *\n    * @param position Position from which to start reading\n    * @param length Number of bytes to read\n    * @return std::vector<uint8_t>\n    *\n    * @throws std::range_error (std::runtime_error) on start or end beyond EOF\n    *         (strong exception safety guarrantee)\n    */\n  std::vector<uint8_t> read_bytes_from(size_t position, size_t length) const;\n\n  /** @brief Gets raw bytes from packet using length encoded size\n   *\n   * Function also returns the length of the parsed bytes token (you will need\n   * to advance your read position by this value to get to next field in the packet)\n   *\n   * @param position Position from which to start reading\n   * @return std::pair<std::vector<uint8_t>, size_t>\n   *\n   * @throws std::range_error (std::runtime_error) on start or end beyond EOF,\n   *         std::runtime_error on bad first byte (which determines int length)\n   *         (strong exception safety guarrantee)\n   */\n  std::pair<std::vector<uint8_t>, size_t> read_lenenc_bytes_from(size_t position) const;\n\n  /** @brief Gets raw bytes from packet from position until EOF\n   *\n   * @param position Position from which to start reading\n   * @return std::vector<uint8_t>\n   *\n   * @throws std::range_error (std::runtime_error) on start beyond EOF,\n   *         std::runtime_error on zero-terminator not found\n   *         (strong exception safety guarrantee)\n   */\n  std::vector<uint8_t> read_bytes_eof_from(size_t position) const;\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n// packet buffer operations: static method interface\n////////////////////////////////////////////////////////////////////////////////\n\n  /** @brief Gets the packet sequence ID from supplied buffer\n   *\n   * @param header 4-byte header\n   * @return uint8_t\n   */\n  static uint8_t read_sequence_id(const uint8_t header[4]) noexcept {\n    return header[3];\n  }\n\n  /** @brief Gets the payload size from supplied buffer\n   *\n   * @param header 4-byte header\n   * @return uint32_t payload size of the packet\n   */\n  static uint32_t read_payload_size(const uint8_t header[4]) noexcept {\n    return header[0] + (header[1] << 8) + (header[2] << 16);\n  }\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n// packet field setter/getter interface\n////////////////////////////////////////////////////////////////////////////////\n\n  /** @brief Returns header length of MySQL Protocol packet\n   *\n   * @return header length (4 bytes)\n   */\n  static constexpr size_t get_header_length() noexcept {\n    return 4;\n  }\n\n  /** @brief Gets the packet sequence ID\n   *\n   * @return uint8_t\n   */\n  uint8_t get_sequence_id() const noexcept {\n    return sequence_id_;\n  }\n\n  /** @brief Sets the packet sequence ID\n   *\n   * @param id Sequence ID of the packet\n   */\n  void set_sequence_id(uint8_t id) noexcept {\n    sequence_id_ = id;\n  }\n\n  /** @brief Gets server/client capabilities\n   *\n   * @return Capabilities\n   */\n  Capabilities::Flags get_capabilities() const noexcept {\n    return capability_flags_;\n  }\n\n  /** @brief Gets the payload size\n   *\n   * Returns the payload size parsed retrieved from the packet header.\n   *\n   * @return uint32_t\n   */\n  uint32_t get_payload_size() const noexcept {\n    return payload_size_;\n  }\n\n\n\n\n\n protected:\n\n  /** @brief Resets packet\n   *\n   * Resets the packet and sets the sequence id.\n   */\n  void reset() {\n    this->assign({0x0, 0x0, 0x0, sequence_id_});\n  }\n\n  /** @brief Updates payload size in packet header\n   *\n   * Updates the size of the payload storing it in the first 3 bytes\n   * of the packet. This method is called after preparing the packet.\n   */\n  void update_packet_size();\n\n  /** @brief MySQL packet sequence ID */\n  uint8_t sequence_id_;\n\n  /** @brief Payload of the packet */\n  std::vector<uint8_t> payload_;\n\n  /** @brief Payload size */\n  uint32_t payload_size_;\n\n  /** @brief Capability flags */\n  Capabilities::Flags capability_flags_;\n\n  /** @brief read/write position for stream operations */\n  mutable size_t position_;\n\n\n\n private:\n\n  void parse_header(bool allow_partial = false);\n\n  void write_bytes_impl(const unsigned char* bytes, size_t length);\n\n  static inline void update_or_append(std::vector<uint8_t>& vec, size_t& position, uint8_t value) {\n    harness_assert(position <= vec.size()); // allow write before or at EOF\n\n    if (position < vec.size())\n      vec[position] = value;\n    else\n      vec.push_back(value);\n\n    position++;\n  }\n\n  inline void update_or_append(size_t& position, uint8_t value) {\n    update_or_append(*this, position, value);\n  }\n\n  inline void update_or_append(uint8_t value) {\n    update_or_append(position_, value);\n  }\n\n#ifdef FRIEND_TEST\n  FRIEND_TEST(::HandshakeResponseParseTest, server_does_not_support_PROTOCOL_41);\n  FRIEND_TEST(::HandshakeResponseParseTest, no_PROTOCOL_41);\n  FRIEND_TEST(::HandshakeResponseParseTest, bad_payload_length);\n  FRIEND_TEST(::HandshakeResponseParseTest, bad_seq_number);\n  FRIEND_TEST(::HandshakeResponseParseTest, max_packet_size);\n  FRIEND_TEST(::HandshakeResponseParseTest, character_set);\n  FRIEND_TEST(::HandshakeResponseParseTest, reserved);\n  FRIEND_TEST(::HandshakeResponseParseTest, username);\n  FRIEND_TEST(::HandshakeResponseParseTest, auth_response);\n  FRIEND_TEST(::HandshakeResponseParseTest, database);\n  FRIEND_TEST(::HandshakeResponseParseTest, auth_plugin);\n  FRIEND_TEST(::HandshakeResponseParseTest, connection_attrs);\n  FRIEND_TEST(::HandshakeResponseParseTest, all);\n#endif\n\n};\n\n} // namespace mysql_protocol\n\n#endif // MYSQLROUTER_MYSQLV10_BASE_PACKET_INCLUDED\n"
  },
  {
    "path": "src/mysql_protocol/include/mysqlrouter/mysql_protocol/constants.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_MYSQL_PROTOCOL_CONSTANTS_INCLUDED\n#define MYSQLROUTER_MYSQL_PROTOCOL_CONSTANTS_INCLUDED\n\n#include <cstdint>\n\nnamespace mysql_protocol {\n\nnamespace Capabilities {\n\n  /** Type used to pass capability bitset as one number */\n  typedef uint32_t AllFlags;\n\n  /** Type used to pass high/low half of capability bitset as one number */\n  typedef uint16_t HalfFlags;\n\n  class Flags {\n   public:\n    constexpr Flags() : flags_(0) {}\n    explicit constexpr Flags(AllFlags flags) : flags_(flags) {}\n\n    Flags& operator=(const Flags& other) = default;\n\n    constexpr bool operator==(const Flags& other) const {\n      return flags_ == other.flags_;\n    }\n\n    constexpr bool operator!=(const Flags& other) const {\n      return flags_ != other.flags_;\n    }\n\n    constexpr Flags operator|(const Flags& other) const {\n      return Flags(flags_ | other.flags_);\n    }\n\n    constexpr Flags operator&(const Flags& other) const {\n      return Flags(flags_ & other.flags_);\n    }\n\n    bool test(const Flags& want) const { return (flags_ & want.flags_) == want.flags_; }\n    Flags& set(const Flags& other)   { flags_ |= other.flags_; return *this; }\n    Flags& clear(const Flags& other) { flags_ &= ~other.flags_; return *this; }\n    Flags& reset()                   { flags_ = 0; return *this; }\n\n    constexpr AllFlags  bits() const { return flags_; }\n    constexpr HalfFlags high_16_bits() const  { return static_cast<HalfFlags>(flags_ >> 16); }\n    constexpr HalfFlags low_16_bits() const   { return static_cast<HalfFlags>(flags_ & 0x0000ffff); }\n\n    Flags& clear_high_16_bits()   { flags_ &= 0x0000ffff; return *this; }\n    Flags& clear_low_16_bits()    { flags_ &= 0xffff0000; return *this; }\n\n   private:\n    AllFlags flags_;\n  };\n\n  /** @brief Capability flags passed in handshake packet.\n   *\n   * See https://dev.mysql.com/doc/internals/en/capability-flags.html\n   * See also MySQL Server source include/mysql_com.h\n   * To search for documentation of a particular flag, prepend CLIENT_ to its name\n   * (it was removed on purpose to prevent name collisions when #including mysql.h)\n   **/\n  static constexpr Flags LONG_PASSWORD          (1 << 0);\n  static constexpr Flags FOUND_ROWS             (1 << 1);\n  static constexpr Flags LONG_FLAG              (1 << 2);\n  static constexpr Flags CONNECT_WITH_DB        (1 << 3);\n\n  static constexpr Flags NO_SCHEMA              (1 << 4);\n  static constexpr Flags COMPRESS               (1 << 5);\n  static constexpr Flags ODBC                   (1 << 6);\n  static constexpr Flags LOCAL_FILES            (1 << 7);\n\n  static constexpr Flags IGNORE_SPACE           (1 << 8);\n  static constexpr Flags PROTOCOL_41            (1 << 9);   // Server: supports the 4.1 protocol, Client: uses the 4.1 protocol\n  static constexpr Flags INTERACTIVE            (1 << 10);\n  static constexpr Flags SSL                    (1 << 11);  // Server: supports SSL, Client: switch to SSL\n\n  static constexpr Flags SIG_PIPE               (1 << 12);\n  static constexpr Flags TRANSACTIONS           (1 << 13);\n  static constexpr Flags RESERVED_14            (1 << 14);  // deprecated in 8.0.3\n  static constexpr Flags SECURE_CONNECTION      (1 << 15);  // deprecated in 8.0.3\n\n  static constexpr Flags MULTI_STATEMENTS       (1 << 16);\n  static constexpr Flags MULTI_RESULTS          (1 << 17);\n  static constexpr Flags MULTI_PS_MULTO_RESULTS (1 << 18);\n  static constexpr Flags PLUGIN_AUTH            (1 << 19);\n\n  static constexpr Flags CONNECT_ATTRS          (1 << 20);\n  static constexpr Flags PLUGIN_AUTH_LENENC_CLIENT_DATA(1 << 21);\n  static constexpr Flags EXPIRED_PASSWORDS      (1 << 22);\n  static constexpr Flags SESSION_TRACK          (1 << 23);\n\n  static constexpr Flags DEPRECATE_EOF          (1 << 24);\n  static constexpr Flags OPTIONAL_RESULTSET_METADATA (1 << 25); // \\  docs for 5.7 don't\n  static constexpr Flags SSL_VERIFY_SERVER_CERT (1UL << 30);    //  > mention these\n  static constexpr Flags REMEMBER_OPTIONS       (1UL << 31);    // /\n\n  // other useful flags (our invention, mysql_com.h does not define them)\n  static constexpr Flags ALL_ZEROS              (0U);\n  static constexpr Flags ALL_ONES               (~0U);\n\n} // namespace Capabilities\n\n/** @enum Command\n *\n * Types of the supported commands from the client.\n *\n **/\nenum Command {\n  SLEEP               = 0x00,\n  QUIT                = 0x01,\n  INIT_DB             = 0x02,\n  QUERY               = 0x03,\n  FIELD_LIST          = 0x04,\n  CREATE_DB           = 0x05,\n  DROP_DB             = 0x06,\n  REFRESH             = 0x07,\n  SHUTDOWN            = 0x08,\n  STATISTICS          = 0x09,\n  PROCESS_INFO        = 0x0a,\n  CONNECT             = 0x0b,\n  PROCESS_KILL        = 0x0c,\n  DEBUG               = 0x0d,\n  PING                = 0x0e,\n  TIME                = 0x0f,\n  DELAYED_INSERT      = 0x10,\n  CHANGE_USER         = 0x11,\n  BINLOG_DUMP         = 0x12,\n  TABLE_DUMP          = 0x13,\n  CONNECT_OUT         = 0x14,\n  REGISTER_SLAVE      = 0x15,\n  STMT_PREPARE        = 0x16,\n  STMT_EXECUTE        = 0x17,\n  STMT_SEND_LOG_DATA  = 0x18,\n  STMT_CLOSE          = 0x19,\n  STMT_RESET          = 0x1a,\n  SET_OPTION          = 0x1b,\n  STMT_FETCH          = 0x1c,\n  DAEMON              = 0x1d,\n  BINLOG_DUMP_GTID    = 0x1e,\n  RESET_CONNECTION    = 0x1f,\n};\n\n} // namespace mysql_protocol\n\n#endif // MYSQLROUTER_MYSQL_PROTOCOL_CONSTANTS_INCLUDED\n"
  },
  {
    "path": "src/mysql_protocol/include/mysqlrouter/mysql_protocol/error_packet.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_MYSQL_PROTOCOL_ERROR_PACKET_INCLUDED\n#define MYSQLROUTER_MYSQL_PROTOCOL_ERROR_PACKET_INCLUDED\n\n#include \"base_packet.h\"\n\nnamespace mysql_protocol {\n\n/** @class ErrorPacket\n * @brief Creates a MySQL error packet\n *\n * This class creates a MySQL error packet which is send to the MySQL Client.\n *\n */\nclass MYSQL_PROTOCOL_API ErrorPacket final : public Packet {\n public:\n  /** @brief Constructor\n   *\n   * @note The default constructor will set the error code to 1105, message\n   * \"Unknown error\", and SQL State \"HY000\". These values come from the\n   * MySQL Server server errors.\n   */\n  ErrorPacket() : Packet(0), code_(1105), message_(\"Unknown error\"), sql_state_(\"HY000\") {\n    prepare_packet();\n  };\n\n  /** @overload\n   *\n   * @param buffer bytes of the error packet\n   */\n  ErrorPacket(const std::vector<uint8_t> &buffer) : ErrorPacket(buffer, Capabilities::ALL_ZEROS) { }\n\n  ErrorPacket(const std::vector<uint8_t> &buffer, Capabilities::Flags capabilities);\n\n  /** @overload\n   *\n   * @param sequence_id MySQL Packet number\n   * @param err_code Error code provided to MySQL client\n   * @param err_msg Error message provided to MySQL client\n   * @param sql_state SQL State used in error message\n   * @param capabilities Server/Client capability flags (default 0)\n   */\n  ErrorPacket(uint8_t sequence_id, uint16_t err_code, const std::string &err_msg,\n              const std::string &sql_state, Capabilities::Flags capabilities = Capabilities::ALL_ZEROS);\n\n  /** @brief Gets error code\n   *\n   * Gets the MySQL error code of the MySQL error packet.\n   *\n   * @return unsigned short\n   */\n  unsigned short get_code() const noexcept {\n    return code_;\n  }\n\n  /** @brief Gets error message\n   *\n   * Gets the MySQL error message of the MySQL error packet.\n   *\n   * @return const std::string reference\n   */\n  const std::string &get_message() const noexcept {\n    return message_;\n  }\n\n  /** @brief Gets SQL state\n   *\n   * Gets the SQL state of the MySQL error packet.\n   *\n   * @return const std::string reference\n   */\n  const std::string &get_sql_state() const noexcept {\n    return sql_state_;\n  }\n\n private:\n  /** @brief Prepares the packet\n   *\n   * Prepares the actual MySQL Error packet and stores it. The header is\n   * created using the sequence id and the size of the payload.\n   */\n  void prepare_packet();\n\n  /** @brief Parses the packet\n   *\n   * Parses the packet from the given buffer.\n   */\n  void parse_payload();\n\n  /** @brief MySQL error code */\n  unsigned short code_;\n\n  /** @brief MySQL error message */\n  std::string message_;\n\n  /** @brief MySQL SQL state */\n  std::string sql_state_;\n};\n\n} // namespace mysql_protocol\n\n\n#endif // MYSQLROUTER_MYSQL_PROTOCOL_ERROR_PACKET_INCLUDED\n"
  },
  {
    "path": "src/mysql_protocol/include/mysqlrouter/mysql_protocol/handshake_packet.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_MYSQL_PROTOCOL_HANDSHAKE_PACKET_INCLUDED\n#define MYSQLROUTER_MYSQL_PROTOCOL_HANDSHAKE_PACKET_INCLUDED\n\n#include \"base_packet.h\"\n#include <memory>\n\n// GCC 4.8.4 requires all classes to be forward-declared before being used with\n// \"friend class <friendee>\", if they're in a different namespace than the friender\n#ifdef FRIEND_TEST\n#include \"mysqlrouter/utils.h\"  // DECLARE_TEST\n  DECLARE_TEST(HandshakeResponseParseTest, server_does_not_support_PROTOCOL_41);\n  DECLARE_TEST(HandshakeResponseParseTest, no_PROTOCOL_41);\n  DECLARE_TEST(HandshakeResponseParseTest, bad_payload_length);\n  DECLARE_TEST(HandshakeResponseParseTest, bad_seq_number);\n  DECLARE_TEST(HandshakeResponseParseTest, max_packet_size);\n  DECLARE_TEST(HandshakeResponseParseTest, character_set);\n  DECLARE_TEST(HandshakeResponseParseTest, reserved);\n  DECLARE_TEST(HandshakeResponseParseTest, username);\n  DECLARE_TEST(HandshakeResponseParseTest, auth_response);\n  DECLARE_TEST(HandshakeResponseParseTest, database);\n  DECLARE_TEST(HandshakeResponseParseTest, auth_plugin);\n  DECLARE_TEST(HandshakeResponseParseTest, connection_attrs);\n  DECLARE_TEST(HandshakeResponseParseTest, all);\n#endif\n\nnamespace mysql_protocol {\n\n/** @class HandshakeResponsePacket\n * @brief Creates a MySQL handshake response packet\n *\n * This class creates a MySQL handshake response packet which is send by\n * the MySQL client after receiving the server's handshake packet.\n *\n */\nclass MYSQL_PROTOCOL_API HandshakeResponsePacket final : public Packet {\n\n public:\n\n  /** @brief Default capability flags\n   *\n   * Default capability flags\n   *\n   */\n  static constexpr Capabilities::Flags kDefaultClientCapabilities =\n      Capabilities::LONG_PASSWORD |\n      Capabilities::LONG_FLAG |\n      Capabilities::CONNECT_WITH_DB |\n      Capabilities::LOCAL_FILES |\n      Capabilities::PROTOCOL_41 |\n      Capabilities::TRANSACTIONS |\n      Capabilities::SECURE_CONNECTION |\n      Capabilities::MULTI_STATEMENTS |\n      Capabilities::MULTI_RESULTS;\n\n  /** @brief Constructor\n   *\n   * This version of constructor just creates an uninitialized packet\n   */\n  HandshakeResponsePacket() : Packet(0), username_(\"\"), password_(\"\"),\n                              char_set_(8), auth_plugin_(\"mysql_native_password\"), auth_response_({}) {\n    prepare_packet();\n  }\n\n  /** @overload\n   *\n   * This version of constructor takes in packet bytes, parses it and writes\n   * results in object's fields\n   *\n   * @param buffer Packet payload (including packet header)\n   * @param server_capabilities Capabilities sent by the server in Handshake Packet;\n   *        see note in parse_payload()\n   * @param auto_parse_payload Disables automatic parsing of payload if set to false\n   *        Note that header is still parsed (sequence_id_ and payload_size_ are set)\n   *\n   * @throws std::runtime_error on unrecognised or invalid packet, when parsing\n   */\n  HandshakeResponsePacket(const std::vector<uint8_t>& buffer,\n                          bool auto_parse_payload = false,\n                          Capabilities::Flags server_capabilities = Capabilities::ALL_ZEROS)\n      : Packet(buffer) {\n    if (auto_parse_payload)\n      parse_payload(server_capabilities);\n  }\n\n  /** @overload\n   *\n   * This version of constructor takes in fields, and generates packet bytes\n   *\n   * @param sequence_id MySQL Packet number\n   * @param auth_response Authentication data from the MySQL server handshake\n   * @param username MySQL username to use\n   * @param password MySQL password to use\n   * @param database MySQL database to use when connecting (default is empty)\n   * @param char_set MySQL character set code (default 8, latin1)\n   * @param auth_plugin MySQL authentication plugin name (default 'mysql_native_password')\n   */\n  HandshakeResponsePacket(uint8_t sequence_id,\n                          const std::vector<unsigned char> &auth_response, const std::string &username,\n                          const std::string &password, const std::string &database = \"\",\n                          unsigned char char_set = 8,\n                          const std::string &auth_plugin = \"mysql_native_password\");\n\n  /** @brief Parses packet payload, results written to object's field\n   *\n   * @param server_capabilities Capabilities sent by the server in Handshake Packet, see note below\n   *\n   * @throws std::runtime_error on unrecognised or invalid packet\n   *\n   * @note MySQL Protocol has a quirk: In the Handshake Packet, server sends to client its capability\n   *       flags, then in Handshake Response Packet, client sends its own, possibly including some\n   *       that the server did not advertise. Despite advertising these flags unique to client, it\n   *       does not actually use them. This is vital in understanding packets. If data chunk dataX\n   *       depeneded on capability X, then how should a packet be parsed when it comes in?\n   *         {data1, data2, dataX, data3, data4}\n   *       or\n   *         {data1, data2, data3, data4}\n   *       Apparently the latter\n   */\n  void parse_payload(Capabilities::Flags server_capabilities) {\n    init_parser_if_not_initialized();\n    parser_->parse(server_capabilities);\n  }\n\n  /** @brief returns username specified in the packet */\n  const std::string& get_username() const { return username_; }\n\n  /** @brief returns database name specified in the packet */\n  const std::string& get_database() const { return database_; }\n\n  /** @brief returns character set specified in the packet */\n  uint8_t get_character_set() const { return char_set_; }\n\n  /** @brief returns auth-plugin-name specified in the packet */\n  const std::string& get_auth_plugin() const { return auth_plugin_; }\n\n  /** @brief returns auth-plugin-data specified in the packet */\n  const std::vector<uint8_t>& get_auth_response() const { return auth_response_; }\n\n  /** @brief returns max packet size specified in the packet */\n  uint32_t get_max_packet_size() const { return max_packet_size_; }\n\n  /** @brief (debug tool) parse packet contents and print this info on stdout */\n  void debug_dump() {\n    init_parser_if_not_initialized();\n    parser_->debug_dump();\n  }\n\n private:\n\n  class Parser;\n\n  /** @brief Prepares the packet\n   *\n   * Prepares the actual MySQL Error packet and stores it. The header is\n   * created using the sequence id and the size of the payload.\n   */\n  void prepare_packet();\n\n  /** @brief Initializes Parser needed to parse the packet payload */\n  void init_parser_if_not_initialized() {\n    if (!parser_) {\n      if (Parser41::is_protocol41(*this)) {\n        parser_.reset(new Parser41(*this));\n      } else if (Parser320::is_protocol320(*this)) {\n        parser_.reset(new Parser320(*this));\n      } else {\n        assert(0);\n      }\n    }\n  }\n\n  /** @brief MySQL username */\n  std::string username_;\n\n  /** @brief MySQL password */\n  std::string password_;\n\n  /** @brief MySQL database */\n  std::string database_;\n\n  /** @brief MySQL character set */\n  unsigned char char_set_;\n\n  /** @brief MySQL authentication plugin name */\n  std::string auth_plugin_;\n\n  /** @brief MySQL auth-response */\n  std::vector<unsigned char> auth_response_;\n\n  /** @brief Max size that of a command packet that the client wants to send to the server */\n  uint32_t max_packet_size_;\n\n  /** @brief Parser used to parse this packet */\n  std::unique_ptr<Parser> parser_;\n\n  class MYSQL_PROTOCOL_API Parser {\n   public:\n    virtual ~Parser() = default;\n    virtual void parse(Capabilities::Flags server_capabilities) = 0;\n\n    // debug tools\n    static std::string bytes2str(const uint8_t* bytes,\n                                 size_t length, size_t bytes_per_group = 4) noexcept;\n    virtual void debug_dump() const = 0;\n  };\n\n  class MYSQL_PROTOCOL_API Parser41 : public Parser {\n   public:\n\n    Parser41(HandshakeResponsePacket& packet) : packet_(packet) {}\n\n    /** @brief Tests if handshake response packet has PROTOCOL_41 flag set\n     *\n     * This is a very simple method, it only checks that single flag and does\n     * nothing else (in particular, it doesn't perform any kind of validation)\n     */\n    static bool is_protocol41(const HandshakeResponsePacket& packet);\n\n    /** @brief Parses handshake response packet\n     *\n     * This method assumes that the current packet is a PROTOCOL41 handshake response.\n     *\n     * @param server_capabilities Capability flags of the server. Client's flags will\n     *        be &-ed with them before applying rules for packet parsing.\n     * @throws std::runtime_error on unrecognised or invalid packet\n     */\n    void parse(Capabilities::Flags server_capabilities) override;\n\n    // debug tools\n    void debug_dump() const noexcept override;\n\n   private:\n\n    /** @brief Helper functions called by parse()\n     *\n     * All these methods throw std::runtime_error on parse errors; in particular,\n     * std::range_error (std::runtime_error specialization) is thrown on EOF\n     * */\n    void part1_max_packet_size();\n    void part2_character_set();\n    void part3_reserved();\n    void part4_username();\n    void part5_auth_response();\n    void part6_database();\n    void part7_auth_plugin();\n    void part8_connection_attrs();\n\n    HandshakeResponsePacket& packet_;\n    Capabilities::Flags effective_capability_flags_;\n\n    #ifdef FRIEND_TEST\n    FRIEND_TEST(::HandshakeResponseParseTest, server_does_not_support_PROTOCOL_41);\n    FRIEND_TEST(::HandshakeResponseParseTest, no_PROTOCOL_41);\n    FRIEND_TEST(::HandshakeResponseParseTest, bad_payload_length);\n    FRIEND_TEST(::HandshakeResponseParseTest, bad_seq_number);\n    FRIEND_TEST(::HandshakeResponseParseTest, max_packet_size);\n    FRIEND_TEST(::HandshakeResponseParseTest, character_set);\n    FRIEND_TEST(::HandshakeResponseParseTest, reserved);\n    FRIEND_TEST(::HandshakeResponseParseTest, username);\n    FRIEND_TEST(::HandshakeResponseParseTest, auth_response);\n    FRIEND_TEST(::HandshakeResponseParseTest, database);\n    FRIEND_TEST(::HandshakeResponseParseTest, auth_plugin);\n    FRIEND_TEST(::HandshakeResponseParseTest, connection_attrs);\n    FRIEND_TEST(::HandshakeResponseParseTest, all);\n    #endif\n\n  };\n\n  class MYSQL_PROTOCOL_API Parser320 : public Parser {\n   public:\n\n    Parser320(HandshakeResponsePacket& packet) : packet_(packet) {}\n\n    /** @brief Tests if handshake response packet DOES NOT have PROTOCOL_41 flag set\n     *\n     * This is a very simple method, it only checks that single flag and does\n     * nothing else (in particular, it doesn't perform any kind of validation)\n     */\n    static bool is_protocol320(const HandshakeResponsePacket& packet);\n\n    /** @brief Parses handshake response packet\n     *\n     * Currently not implemented\n     */\n    void parse(Capabilities::Flags server_capabilities) override;\n    void debug_dump() const override;\n\n    HandshakeResponsePacket& packet_;\n    Capabilities::Flags effective_capability_flags_;\n  };\n\n  #ifdef FRIEND_TEST\n  FRIEND_TEST(::HandshakeResponseParseTest, server_does_not_support_PROTOCOL_41);\n  FRIEND_TEST(::HandshakeResponseParseTest, no_PROTOCOL_41);\n  FRIEND_TEST(::HandshakeResponseParseTest, bad_payload_length);\n  FRIEND_TEST(::HandshakeResponseParseTest, bad_seq_number);\n  FRIEND_TEST(::HandshakeResponseParseTest, max_packet_size);\n  FRIEND_TEST(::HandshakeResponseParseTest, character_set);\n  FRIEND_TEST(::HandshakeResponseParseTest, reserved);\n  FRIEND_TEST(::HandshakeResponseParseTest, username);\n  FRIEND_TEST(::HandshakeResponseParseTest, auth_response);\n  FRIEND_TEST(::HandshakeResponseParseTest, database);\n  FRIEND_TEST(::HandshakeResponseParseTest, auth_plugin);\n  FRIEND_TEST(::HandshakeResponseParseTest, connection_attrs);\n  FRIEND_TEST(::HandshakeResponseParseTest, all);\n  #endif\n\n}; // class HandshakeResponsePacket\n\n} // namespace mysql_protocol\n\n#endif // MYSQLROUTER_MYSQL_PROTOCOL_HANDSHAKE_PACKET_INCLUDED\n"
  },
  {
    "path": "src/mysql_protocol/include/mysqlrouter/mysql_protocol.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_MYSQL_PROTOCOL_INCLUDED\n#define MYSQLROUTER_MYSQL_PROTOCOL_INCLUDED\n\n#include <cassert>\n#include <cmath>\n#include <cstddef>\n#include <string>\n#include <typeinfo>\n#include <vector>\n\n#ifdef _WIN32\n#  ifdef mysql_protocol_EXPORTS\n#    define MYSQL_PROTOCOL_API __declspec(dllexport)\n#  else\n#    define MYSQL_PROTOCOL_API __declspec(dllimport)\n#  endif\n#else\n#  define MYSQL_PROTOCOL_API\n#endif\n\n#include \"mysql_protocol/constants.h\" // comes first\n#include \"mysql_protocol/base_packet.h\"\n#include \"mysql_protocol/error_packet.h\"\n#include \"mysql_protocol/handshake_packet.h\"\n\nnamespace mysql_protocol {\n\n/** @class packet_error\n * @brief Exception raised for any errors with MySQL packets\n *\n */\nclass MYSQL_PROTOCOL_API packet_error : public std::runtime_error {\n  public:\n    explicit packet_error(const std::string &what_arg) : std::runtime_error(what_arg) { }\n};\n\n} // namespace mysql_protocol\n\n#endif // MYSQLROUTER_MYSQL_PROTOCOL_INCLUDED\n"
  },
  {
    "path": "src/mysql_protocol/src/base_packet.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysqlrouter/mysql_protocol.h\"\n#include \"mysqlrouter/utils.h\"\n\n#include <algorithm>\n#include <cstdint>\n#include <limits>\n#include <utility>\n\nnamespace mysql_protocol {\n\nPacket::Packet(const vector_t &buffer, Capabilities::Flags capabilities, bool allow_partial)\n    : vector(buffer), sequence_id_(0),\n      payload_size_(0), capability_flags_(capabilities) {\n  parse_header(allow_partial);\n}\n\nPacket::Packet(std::initializer_list<uint8_t> ilist) : Packet(vector_t(ilist)) {\n  parse_header();\n}\n\nvoid Packet::parse_header(bool allow_partial) {\n  if (size() < 4) {\n    // do nothing when there are not enough bytes\n    return;\n  }\n\n  payload_size_ = read_int_from<uint32_t>(0, 3);\n\n  if (!allow_partial && this->size() < payload_size_ + 4) {\n    throw packet_error(\"Incorrect payload size (was \" +\n                       std::to_string(this->size()) + \"; should be at least \" + std::to_string(payload_size_) + \")\");\n  }\n\n  sequence_id_ = (*this)[3];\n}\n\nvoid Packet::update_packet_size() {\n  if (size() < 4)\n    throw std::range_error(\"buffer not big enough\");\n  if (size() - 4 > kMaxAllowedSize)\n    throw std::runtime_error(\"illegal packet size\");\n\n  // Update the size\n  size_t current_pos = tell();\n  seek(0);\n  write_int<uint32_t>(static_cast<uint32_t>(size()) - 4, 3);\n  seek(current_pos);\n}\n\nuint64_t Packet::read_lenenc_uint() const {\n  auto pr = read_lenenc_uint_from(position_);  // throws range_error/runtime_error\n  position_ += pr.second;\n  return pr.first;\n}\n\nstd::vector<uint8_t> Packet::read_bytes(size_t length) const {\n  std::vector<uint8_t> res = read_bytes_from(position_, length); // throws range_error/runtime_error\n  position_ += length;\n  return res;\n}\n\nstd::vector<uint8_t> Packet::read_lenenc_bytes() const {\n  auto pr = read_lenenc_bytes_from(position_);  // throws range_error/runtime_error\n  std::vector<uint8_t> res = pr.first;\n  position_ += pr.second;\n  return res;\n}\n\nstd::string Packet::read_string_nul() const {\n  std::string res = read_string_nul_from(position_);  // throws range_error/runtime_error\n  position_ += res.size() + 1; // +1 for zero-terminator\n  return res;\n}\n\nstd::vector<uint8_t> Packet::read_bytes_eof() const {\n  std::vector<uint8_t> res = read_bytes_eof_from(position_);  // throws range_error/runtime_error\n  position_ += res.size();\n  return res;\n}\n\nstd::pair<uint64_t, size_t> Packet::read_lenenc_uint_from(size_t position) const {\n\n  if (position >= size())\n    throw std::range_error(\"start beyond EOF\");\n  if ((*this)[position] == 0xff ||  // 0xff is undefined in length encoded integers\n      (*this)[position] == 0xfb)    // 0xfb represents NULL and not used in length encoded integers\n    throw std::runtime_error(\"illegal value at first byte\");\n\n  // single-byte uint\n  if ((*this)[position] < 0xfb) {\n    return std::make_pair((*this)[position], 1);\n  }\n\n  // multi-byte uint\n  size_t length = 2;\n  switch ((*this)[position]) {\n    case 0xfc:\n      length = 2;\n      break;\n    case 0xfd:\n      length = 3;\n      break;\n    case 0xfe:  // NOTE: up to MySQL 3.22 0xfe was follwed by 4 bytes, not 8\n      length = 8;\n  }\n  if (position + length >= size())\n    throw std::range_error(\"end beyond EOF\");\n\n  return std::make_pair(read_int_from<uint64_t>(position + 1, length), length + 1);\n}\n\nstd::string Packet::read_string_from(unsigned long position, unsigned long length) const {\n\n  if (static_cast<size_t>(position) > size()) {\n    return \"\";\n  }\n\n  auto start = begin() + static_cast<vector_t::difference_type>(position);\n  auto finish = (length == UINT_MAX) ? size() : position + length;\n  auto it = std::find(start, begin() + static_cast<vector_t::difference_type>(finish), 0);\n  return std::string(start, it);\n}\n\nstd::string Packet::read_string_nul_from(size_t position) const {\n  if (position >= size())\n    throw std::range_error(\"start beyond EOF\");\n\n  auto it = std::find(begin() + position, end(), 0);\n  if (it == end())\n    throw std::runtime_error(\"zero-terminator not found\");\n\n  return std::string(begin() + position, it);\n}\n\nstd::vector<uint8_t> Packet::read_bytes_from(size_t position, size_t length) const {\n\n  if (position + length > size())\n    throw std::range_error(\"start or end beyond EOF\");\n\n  return std::vector<uint8_t>(begin() + position, begin() + position + length);\n}\n\nstd::pair<std::vector<uint8_t>, size_t> Packet::read_lenenc_bytes_from(size_t position) const {\n  auto pr = read_lenenc_uint_from(position); // throws runtime_error, range_error\n\n  size_t lenenc_uint_value = pr.first;\n  size_t lenenc_uint_token_len = pr.second;\n\n  size_t start = position + lenenc_uint_token_len;\n  size_t endd = start + lenenc_uint_value;  // 'end' already exists\n  if (endd > size())\n    throw std::range_error(\"start or end beyond EOF\");\n\n  return make_pair(std::vector<uint8_t>(begin() + start, begin() + endd),\n                   lenenc_uint_token_len + lenenc_uint_value);\n}\n\nstd::vector<uint8_t> Packet::read_bytes_eof_from(size_t position) const {\n  if (position >= size())\n    throw std::range_error(\"start beyond EOF\");\n\n  return std::vector<uint8_t>(begin() + position, end());\n}\n\nvoid Packet::write_bytes_impl(const uint8_t* bytes, size_t length) {\n  const size_t bytes_before_eof = size() - position_;\n\n  if (length > bytes_before_eof) {\n    std::copy(bytes, bytes + bytes_before_eof, begin() + position_);\n    insert(end(), bytes + bytes_before_eof, bytes + length);\n  } else {\n    std::copy(bytes, bytes + length, begin() + position_);\n  }\n\n  position_ += length;\n}\n\nsize_t Packet::write_lenenc_uint(uint64_t value) {\n\n  // Specification is here: https://dev.mysql.com/doc/internals/en/integer.html\n  //\n  // To convert a number value into a length-encoded integer:\n  //\n  //   If the value is < 251,             it is stored as a 1-byte integer.\n  //   If the value is ≥ 251 and < 2^16,  it is stored as 0xfc + 2-byte integer.\n  //   If the value is ≥ 2^16 and < 2^24, it is stored as 0xfd + 3-byte integer.\n  //   If the value is ≥ 2^24 and < 2^64, it is stored as 0xfe + 8-byte integer.\n\n  constexpr uint64_t k2p16 = 1 << 16;\n  constexpr uint64_t k2p24 = 1 << 24;\n\n  if (value < 251) {\n    update_or_append(static_cast<uint8_t>(value));\n    return 1;\n  } else if (value < k2p16) {\n    update_or_append(0xfc);\n    write_int<uint16_t>(static_cast<uint16_t>(value));\n    return 3;\n  } else if (value < k2p24) {\n    update_or_append(0xfd);\n    write_int(value, 3);\n    return 4;\n  } else {\n    update_or_append(0xfe);\n    write_int<uint64_t>(value);\n    return 9;\n  }\n}\n\nvoid Packet::append_bytes(size_t count, uint8_t byte) {\n  if (position_ != size())\n    throw std::range_error(\"not at EOF\");\n  insert(end(), count, byte);\n  position_ += count;\n}\n\n} // namespace mysql_protocol\n"
  },
  {
    "path": "src/mysql_protocol/src/error_packet.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysqlrouter/mysql_protocol.h\"\n#include \"mysqlrouter/utils.h\"\n\n#include <cassert>\n#include <cstddef>\n#include <cstdint>\n#include <iomanip>\n#include <iostream>\n#include <string>\n#include <vector>\n\nnamespace mysql_protocol {\n\nErrorPacket::ErrorPacket(uint8_t sequence_id, uint16_t err_code, const std::string &err_msg,\n                         const std::string &sql_state, Capabilities::Flags capabilities)\n    : Packet(sequence_id, capabilities),\n      code_(err_code),\n      message_(err_msg),\n      sql_state_(sql_state) {\n  prepare_packet();\n}\n\nErrorPacket::ErrorPacket(const std::vector<uint8_t> &buffer,\n                         Capabilities::Flags capabilities) : Packet(buffer, capabilities) {\n  parse_payload();\n}\n\nstatic constexpr uint8_t kHashChar = 0x23;  // 0x23 == '#'\n\nvoid ErrorPacket::prepare_packet() {\n  assert(sql_state_.size() == 5);\n\n  reset();\n  position_ = size();\n\n  reserve(size() +\n    sizeof(uint8_t) +   // error identifier byte\n    sizeof(uint16_t) +  // error code\n    sizeof(uint8_t) +   // SQL state\n    message_.size()     // the message\n  );\n\n  // Error identifier byte\n  write_int<uint8_t>(0xff);\n\n  // error code\n  write_int<uint16_t>(code_);\n\n  // SQL State\n  if (capability_flags_.test(Capabilities::PROTOCOL_41)) {\n    write_int<uint8_t>(kHashChar);\n    if (sql_state_.size() != 5) {\n      write_string(\"HY000\");\n    } else {\n      write_string(sql_state_);\n    }\n  }\n\n  // The message\n  write_string(message_);\n\n  // Update the payload size in the header\n  update_packet_size();\n}\n\nvoid ErrorPacket::parse_payload() {\n  bool prot41 = capability_flags_.test(Capabilities::PROTOCOL_41);\n  // Sanity checks\n  if (!((*this)[4] == 0xff && (*this)[6])) {\n    throw packet_error(\"Error packet marker 0xff not found\");\n  }\n  // Check if SQLState is available when CLIENT_PROTOCOL_41 flag is set\n  if (prot41 && (*this)[7] != kHashChar) {\n    throw packet_error(\"Error packet does not contain SQL state\");\n  }\n\n  unsigned long pos = 5;\n  code_ = read_int_from<uint16_t>(pos);\n  pos += 2;\n  if ((*this)[7] == kHashChar) {\n    // We get the SQLState even when CLIENT_PROTOCOL_41 flag was not set\n    // This is needed in cases when the server sends an\n    // error to the client instead of the handshake.\n    sql_state_ = read_string_from(++pos, 5); // We skip kHashChar ('#')\n    pos += 5;\n  } else {\n    sql_state_ = \"\";\n  }\n  message_ = read_string_from(pos);\n}\n\n} // namespace mysql_protocol\n"
  },
  {
    "path": "src/mysql_protocol/src/handshake_packet.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysqlrouter/mysql_protocol.h\"\n#include \"mysqlrouter/utils.h\"\n\n#include <cassert>\n#include <cstddef>\n#include <iomanip>\n#include <iostream>\n#include <string>\n#include <utility>\n#include <vector>\n\nnamespace mysql_protocol {\n\n// required by C++11, deprecated in C++17\nconstexpr Capabilities::Flags HandshakeResponsePacket::kDefaultClientCapabilities;\n\nHandshakeResponsePacket::HandshakeResponsePacket(uint8_t sequence_id,\n                                                 const std::vector<unsigned char> &auth_response,\n                                                 const std::string &username,\n                                                 const std::string &password, const std::string &database,\n                                                 unsigned char char_set,\n                                                 const std::string &auth_plugin)\n    : Packet(sequence_id), username_(username), password_(password),\n      database_(database), char_set_(char_set), auth_plugin_(auth_plugin), auth_response_(auth_response) {\n  prepare_packet();\n}\n\n/** @fn HandshakeResponsePacket::prepare_packet()\n *\n * @devnote\n * Password is currently not used and 'incorrect' authentication data is\n * being set in this packet (making the packet currently unusable for authentication.\n * This is to satisfy fix for BUG22020088.\n * @enddevnote\n */\nvoid HandshakeResponsePacket::prepare_packet() {\n\n  reset();\n  position_ = size();\n\n  reserve(size() +\n    sizeof(uint32_t) +      // capabilities\n    sizeof(uint32_t) +      // max packet size\n    sizeof(uint8_t) +       // character set\n    23 +                    // 23 0-byte filler\n    username_.size() + 1 +  // username + nul-terminator\n    sizeof(uint8_t) + 20 +  // auth-data-len + auth-data\n    database_.size() + 1 +  // username + nul-terminator\n    auth_plugin_.size() + 1 // auth-plugin + nul-terminator\n  );\n\n  // capabilities\n  write_int<uint32_t>(kDefaultClientCapabilities.bits());\n\n  // max packet size\n  write_int<uint32_t>(kMaxAllowedSize);\n\n  // Character set\n  write_int<uint8_t>(char_set_);\n\n  // Filler\n  append_bytes(23, 0x0);\n\n  // Username\n  if (!username_.empty()) {\n    write_string(username_);\n  }\n  write_int<uint8_t>(0);\n\n  // Auth Data\n  write_int<uint8_t>(20);\n  append_bytes(20, 0x71);   // 0x71 is fake data; can be anything\n\n  // Database\n  if (!database_.empty()) {\n    write_string(database_);\n  }\n  write_int<uint8_t>(0);\n\n  // Authentication plugin name\n  write_string(auth_plugin_);\n  write_int<uint8_t>(0);\n\n  update_packet_size();\n}\n\n\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// HandshakeResponsePacket::Parser320 (unimplemented)\n//\n////////////////////////////////////////////////////////////////////////////////\n\n  /*static*/\n  bool HandshakeResponsePacket::Parser320::is_protocol320(const HandshakeResponsePacket& packet) {\n    return ! Parser41::is_protocol41(packet);\n  }\n\n  /*virtual*/\n  void HandshakeResponsePacket::Parser320::parse(Capabilities::Flags server_capabilities) /*override*/ {\n    (void) server_capabilities;\n    throw std::runtime_error(\"Handshake response packet: Protocol is version 320, which is not implemented atm\");\n  }\n\n  /*virtual*/\n  void HandshakeResponsePacket::Parser320::debug_dump() const {\n    throw std::runtime_error(\"not implemented\");\n  };\n\n\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// HandshakeResponsePacket::Parser41 (partial implementation - just essentials)\n//\n////////////////////////////////////////////////////////////////////////////////\n\n  /*static*/\n  bool HandshakeResponsePacket::Parser41::is_protocol41(const HandshakeResponsePacket& packet) {\n\n    constexpr size_t kFlagsOffset = 4;                   // vvvvvvvvv-- only low 16 bits are needed\n    if (packet.size() < kFlagsOffset + sizeof(Capabilities::HalfFlags))\n      throw std::runtime_error(\"HandshakeResponsePacket: tried reading capability flags past EOF\");\n\n    Capabilities::Flags flags(packet.read_int_from<Capabilities::HalfFlags>(kFlagsOffset));\n    return flags.test(Capabilities::PROTOCOL_41);\n  }\n\n  void HandshakeResponsePacket::Parser41::part1_max_packet_size() {\n\n    /**\n     * This function implements this part of the specification:\n     *\n     *   4              max-packet size\n     */\n\n    using MaxPacketSize = decltype(packet_.max_packet_size_);\n\n    packet_.max_packet_size_ = packet_.read_int<MaxPacketSize>();\n  }\n\n  void HandshakeResponsePacket::Parser41::part2_character_set() {\n\n    /**\n     * This function implements this part of the specification:\n     *\n     *   1              character set\n     */\n\n    using CharSet = decltype(packet_.char_set_);\n\n    packet_.char_set_ = packet_.read_int<CharSet>();\n  }\n\n  void HandshakeResponsePacket::Parser41::part3_reserved() {\n\n    /**\n     * This function implements this part of the specification:\n     *\n     *   string[23]     reserved (all [0])\n     */\n\n    constexpr size_t kReservedBytes = 23;\n    vector<uint8_t> reserved = packet_.read_bytes(kReservedBytes);\n\n    // proper packet should have all of those set to 0\n    if (! std::all_of(reserved.begin(), reserved.end(), [](uint8_t c) { return c == 0; }))\n      throw std::runtime_error(\"Handshake response packet: found non-zero value in reserved 23-byte field\");\n  }\n\n  void HandshakeResponsePacket::Parser41::part4_username() {\n\n    /**\n     * This function implements this part of the specification:\n     *\n     *   string[NUL]    username\n     */\n\n    packet_.username_ = packet_.read_string_nul();\n  }\n\n  void HandshakeResponsePacket::Parser41::part5_auth_response() {\n\n    /**\n     * This function implements this part of the specification:\n     *\n     *   if capabilities & CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA {\n     *     lenenc-int     length of auth-response\n     *     string[n]      auth-response\n     *   } else if capabilities & CLIENT_SECURE_CONNECTION {\n     *     1              length of auth-response\n     *     string[n]      auth-response\n     *   } else {\n     *     string[NUL]    auth-response\n     *   }\n     */\n\n    if (effective_capability_flags_.test(Capabilities::PLUGIN_AUTH_LENENC_CLIENT_DATA)) {\n\n      // get auth-response string length\n      uint64_t len = packet_.read_lenenc_uint(); // length 0 is a valid value\n\n      // get auth-response string\n      packet_.auth_response_ = packet_.read_bytes(len);\n\n    } else if (effective_capability_flags_.test(Capabilities::SECURE_CONNECTION)) {\n\n      // get auth-response string length\n      uint64_t len = packet_.read_int<uint8_t>();\n\n      // get auth-response string\n      packet_.auth_response_ = packet_.read_bytes(len);\n\n    } else {\n      throw std::runtime_error(\"Handshake response packet: capabilities PLUGIN_AUTH_LENENC_CLIENT_DATA and SECURE_CONNECTION both missing is not implemented atm\");\n    }\n  }\n\n  void HandshakeResponsePacket::Parser41::part6_database() {\n\n    /**\n     * This function implements this part of the specification:\n     *\n     *   if capabilities & CLIENT_CONNECT_WITH_DB {\n     *     string[NUL]    database\n     *   }\n     */\n\n    if (effective_capability_flags_.test(Capabilities::CONNECT_WITH_DB))\n      packet_.database_ = packet_.read_string_nul();\n  }\n\n  void HandshakeResponsePacket::Parser41::part7_auth_plugin() {\n\n    /**\n     * This function implements this part of the specification:\n     *\n     *   if capabilities & CLIENT_PLUGIN_AUTH {\n     *     string[NUL]    auth plugin name\n     *   }\n     */\n\n    if (effective_capability_flags_.test(Capabilities::PLUGIN_AUTH))\n      packet_.auth_plugin_ = packet_.read_string_nul();\n  }\n\n  void HandshakeResponsePacket::Parser41::part8_connection_attrs() {\n\n    /**\n     * This function implements this part of the specification:\n     *\n     *   if capabilities & CLIENT_CONNECT_ATTRS {\n     *     lenenc-int     length of all key-values\n     *     lenenc-str     key\n     *     lenenc-str     value\n     *     if-more data in 'length of all key-values', more keys and value pairs\n     *   }\n     */\n\n    if (effective_capability_flags_.test(Capabilities::CONNECT_ATTRS))\n      throw std::runtime_error(\"Handshake response packet: capability CONNECT_ATTRS is not implemented atm\");\n  }\n\n\n  void HandshakeResponsePacket::Parser41::parse(Capabilities::Flags server_capabilities) /*override*/ {\n\n    // full packet specification is here:\n    // http://dev.mysql.com/doc/internals/en/connection-phase-packets.html#packet-Protocol::HandshakeResponse41\n\n    // we only support PROTOCOL_41 for now, so server has to support it\n    if (! server_capabilities.test(Capabilities::PROTOCOL_41))\n      throw std::runtime_error(\"Handshake response packet: server not supporting PROTOCOL_41 in not implemented atm\");\n\n    // header\n    {\n      // header should have already been parsed by Packet::parse_header(), which is\n      // called by Packet constructor, so here we just skip it over\n      packet_.seek(Packet::get_header_length());\n\n      // correct handshake packet always has seq num = 1\n      if (packet_.get_sequence_id() != 1)\n        throw std::runtime_error(\"Handshake response packet: sequence number different than 1\");\n    }\n\n    // capabilities\n    {\n      // NOTE: in PROTOCOL_320, capabilities are expressed only in 2 bytes, PROTOCOL_41 uses 4\n      packet_.capability_flags_ = Capabilities::Flags(packet_.read_int<Capabilities::AllFlags>());\n\n      // see @note in HandshakeResponsePacket ctor\n      effective_capability_flags_ = packet_.capability_flags_ & server_capabilities;\n\n      // ensure we're indeed parsing PROTOCOL_41\n      assert(effective_capability_flags_.test(Capabilities::PROTOCOL_41));\n    }\n\n    // parse protocol-defined fields; all part*() throw std::runtime_error (or its derivatives)\n    {\n      part1_max_packet_size();\n      part2_character_set();\n      part3_reserved();\n      part4_username();\n      part5_auth_response();\n      part6_database();\n      part7_auth_plugin();\n      part8_connection_attrs();\n    }\n\n    // now let's verify packet payload length vs what we parsed\n    if (packet_.tell() != Packet::get_header_length() + packet_.payload_size_)\n      throw std::runtime_error(\"Handshake response packet: parsed ok, but payload packet size (\" +\n                               std::to_string(packet_.payload_size_) + \" bytes) differs from what we parsed (\" +\n                               std::to_string(packet_.tell()) + \" bytes)\");\n  }\n\n\n////////////////////////////////////////////////////////////////////////////////\n//\n// Debug Tools\n//\n////////////////////////////////////////////////////////////////////////////////\n\n  /*static*/ std::string HandshakeResponsePacket::Parser::bytes2str(\n      const uint8_t* bytes,\n      size_t length,\n      size_t bytes_per_group /* = 4 */) noexcept {\n\n    assert(bytes_per_group > 0);\n\n    const size_t space_after_modulus = bytes_per_group - 1;\n    std::ostringstream buf;\n    buf << std::hex;\n\n    for (size_t i = 0; i < length; i++) {\n      buf << (bytes[i] & 0xf0 >> 4) << (bytes[i] & 0x0f);\n      if (i % bytes_per_group == space_after_modulus)\n        buf << \" \";\n    }\n\n    return buf.str();\n  }\n\n  // throws std::runtime_error\n  void HandshakeResponsePacket::Parser41::debug_dump() const noexcept {\n    assert(packet_.size() >= get_header_length());\n\n    // This function is likely to throw std::runtime_error just about anywhere,\n    // if parsing the packet failed or would fail if ran.\n\n    printf(\"\\n--[BEGIN DUMP]----------------------------------------------\\n\");\n\n    // raw bytes\n    printf(\"\\n  [RAW]\\n\");\n    printf(\"    %s\\n\", bytes2str(packet_.data(), packet_.size()).c_str());\n\n    // header\n    size_t pos = 0; // add space between size and seq nr --------v\n    printf(\"\\n  [HEADER] %s\\n\", bytes2str(packet_.data() + pos, 4, 3).c_str());\n    pos += 4;\n    printf(\"    size = %u\\n\", packet_.get_payload_size());\n    printf(\"    seq_nr = %u\\n\", packet_.get_sequence_id());\n\n    // flags\n    {\n      printf(\"\\n  [CAPABILITY FLAGS (all sent by client are listed, * = also sent by server)] %s\\n\", bytes2str(packet_.data() + pos, 4, 2).c_str());\n      using namespace Capabilities;\n\n      auto print_flag = [&](Flags flag, const char* name) {\n        if (packet_.get_capabilities().test(flag))\n          printf(\"  %c %s\\n\", effective_capability_flags_.test(flag) ? '*' : ' ', name);\n      };\n\n      print_flag(LONG_PASSWORD, \"LONG_PASSWORD\");\n      print_flag(FOUND_ROWS, \"FOUND_ROWS\");\n      print_flag(LONG_FLAG, \"LONG_FLAG\");\n      print_flag(CONNECT_WITH_DB, \"CONNECT_WITH_DB\");\n\n      print_flag(NO_SCHEMA, \"NO_SCHEMA\");\n      print_flag(COMPRESS, \"COMPRESS\");\n      print_flag(ODBC, \"ODBC\");\n      print_flag(LOCAL_FILES, \"LOCAL_FILES\");\n\n      print_flag(IGNORE_SPACE, \"IGNORE_SPACE\");\n      print_flag(PROTOCOL_41, \"PROTOCOL_41\");\n      print_flag(INTERACTIVE, \"INTERACTIVE\");\n      print_flag(SSL, \"SSL\");\n\n      print_flag(SIG_PIPE, \"SIG_PIPE\");\n      print_flag(TRANSACTIONS, \"TRANSACTIONS\");\n      print_flag(RESERVED_14, \"RESERVED_14\");\n      print_flag(SECURE_CONNECTION, \"SECURE_CONNECTION\");\n\n      print_flag(MULTI_STATEMENTS, \"MULTI_STATEMENTS\");\n      print_flag(MULTI_RESULTS, \"MULTI_RESULTS\");\n      print_flag(MULTI_PS_MULTO_RESULTS, \"MULTI_PS_MULTO_RESULTS\");\n      print_flag(PLUGIN_AUTH, \"PLUGIN_AUTH\");\n\n      print_flag(CONNECT_ATTRS, \"CONNECT_ATTRS\");\n      print_flag(PLUGIN_AUTH_LENENC_CLIENT_DATA, \"PLUGIN_AUTH_LENENC_CLIENT_DATA\");\n      print_flag(EXPIRED_PASSWORDS, \"EXPIRED_PASSWORDS\");\n      print_flag(SESSION_TRACK, \"SESSION_TRACK\");\n\n      print_flag(DEPRECATE_EOF, \"DEPRECATE_EOF\");\n\n      pos += 4;\n    }\n\n    // max packet size\n    printf(\"\\n  [MAX PACKET SIZE] %s\\n\", bytes2str(packet_.data() + pos, 4).c_str());\n    pos += 4;\n    printf(\"    max_packet_size = %u\\n\", packet_.get_max_packet_size());\n\n    // character set\n    printf(\"\\n  [CHARACTER SET] %s\\n\", bytes2str(packet_.data() + pos, 1).c_str());\n    pos += 1;\n    printf(\"    character_set = %u\\n\", packet_.get_character_set());\n\n    // skip over 23 reserveed zero bytes\n    printf(\"\\n  [23 RESERVED ZERO BYTES] %s\\n\", bytes2str(packet_.data() + pos, 23).c_str());\n    pos += 23;\n\n    // rest of the fields\n    printf(\"\\n  [REST] %s\\n\", bytes2str(packet_.data() + pos, packet_.size() - pos).c_str());\n    printf(\"    username = '%s'\\n\", packet_.get_username().c_str());\n    {\n      // find end of username (search for zero-terminator)\n      size_t i = pos;\n      while (packet_[i] && i < packet_.size()) i++;\n\n      // advance to next field (which is auth_response)\n      pos = i + 1;\n\n      // if either is not set, 1st byte DOES NOT contain size length-encoded size\n      assert(effective_capability_flags_.test(Capabilities::SECURE_CONNECTION) ||\n             effective_capability_flags_.test(Capabilities::PLUGIN_AUTH_LENENC_CLIENT_DATA));\n\n      size_t len = packet_[pos]; // assume length is encoded in only 1 byte\n      pos += 1;   // advance past auth_response length\n      if (len > 0)\n        printf(\"    auth_response = (%zu bytes) %s\\n\", len, bytes2str(packet_.data() + pos, len).c_str());\n      else\n        printf(\"    auth_response is empty\\n\");\n\n      pos += len; // advance past auth_response payload\n    }\n    printf(\"    database = '%s'\\n\", packet_.get_database().c_str());\n    printf(\"    auth_plugin = '%s'\\n\", packet_.get_auth_plugin().c_str());\n    //not implemented yet: printf(\"  connection_attrs = %u\\n\", packet_.get_connection_attr());\n\n    printf(\"\\n--[END DUMP]------------------------------------------------\\n\\n\");\n  }\n\n} // namespace mysql_protocol\n"
  },
  {
    "path": "src/mysql_protocol/tests/CMakeLists.txt",
    "content": "# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\ninclude_directories(\n  ../include\n)\n\nadd_test_dir(${CMAKE_CURRENT_SOURCE_DIR}\n  MODULE \"mysql_protocol\"\n  LIB_DEPENDS mysql_protocol)\n"
  },
  {
    "path": "src/mysql_protocol/tests/test_base_packet.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n\n#include <gmock/gmock.h>\n\n#include <cstdlib>\n#include <cstring>\n#include <string.h>\n\n#include \"mysqlrouter/mysql_protocol.h\"\n#include \"mysqlrouter/utils.h\"\n\n//TODO This is already defined in ../../../tests/helpers/router_test_helpers.h, but\n//     we don't want to include that (different sub-project).  Instead, it should be\n//     moved to mysql_harness/shared/include/test/helpers.h first, and then #included\n//     from here.\n#define EXPECT_THROW_LIKE(expr, exc, msg) try { \\\n      expr;\\\n      ADD_FAILURE() << \"Expected exception of type \" #exc << \" but got none\\n\";\\\n    } catch (exc &e) {\\\n      if (std::string(e.what()).find(msg) == std::string::npos) {\\\n          ADD_FAILURE() << \"Expected exception with message: \" << msg << \"\\nbut got: \" << e.what() << \"\\n\";\\\n      }\\\n    } catch (...) {\\\n      ADD_FAILURE() << \"Expected exception of type \" #exc << \" but got another\\n\";\\\n    }\n\nusing std::string;\nusing ::testing::ContainerEq;\nusing ::testing::NotNull;\n\nusing mysql_protocol::Packet;\nusing namespace mysql_protocol;\n\nclass MySQLProtocolPacketTest : public ::testing::Test {\npublic:\n  Packet::vector_t case1 = {0x04, 0x0, 0x0, 0x01, 't', 'e', 's', 't'};\nprotected:\n  virtual void SetUp() {\n  }\n};\n\nTEST_F(MySQLProtocolPacketTest, Constructors) {\n  {\n    auto p = Packet();\n    EXPECT_EQ(0, p.get_sequence_id());\n    EXPECT_EQ(0U, p.get_capabilities().bits());\n    EXPECT_EQ(0UL, p.get_payload_size());\n  }\n\n  {\n    auto p = Packet(2);\n    EXPECT_EQ(2, p.get_sequence_id());\n    EXPECT_EQ(0U, p.get_capabilities().bits());\n    EXPECT_EQ(0U, p.get_payload_size());\n  }\n\n  {\n    auto p = Packet(2, Capabilities::PROTOCOL_41);\n    EXPECT_EQ(2, p.get_sequence_id());\n    EXPECT_EQ(Capabilities::PROTOCOL_41, p.get_capabilities());\n    EXPECT_EQ(0U, p.get_payload_size());\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, CopyConstructor) {\n  {\n    Packet p({0x1, 0x0, 0x0, 0x9, 0x32});\n    Packet p_copy(p);\n    ASSERT_EQ(p.size(), p_copy.size());\n    ASSERT_EQ(p.get_sequence_id(), p_copy.get_sequence_id());\n    ASSERT_EQ(0U, p_copy.get_capabilities().bits());\n  }\n\n  {\n    Packet p({0x1, 0x0, 0x0, 0x9, 0x32}, Capabilities::PROTOCOL_41);\n    Packet p_copy(p);\n    ASSERT_EQ(p.size(), p_copy.size());\n    ASSERT_EQ(p.get_sequence_id(), p_copy.get_sequence_id());\n    ASSERT_EQ(Capabilities::PROTOCOL_41, p_copy.get_capabilities());\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, CopyAssignment) {\n  {\n    Packet p({0x1, 0x0, 0x0, 0x9, 0x32});\n    Packet p_copy{};\n    p_copy = p;\n    ASSERT_EQ(p.size(), p_copy.size());\n    ASSERT_EQ(p.get_sequence_id(), p_copy.get_sequence_id());\n    ASSERT_EQ(p.get_payload_size(), p_copy.get_payload_size());\n    ASSERT_EQ(0U, p_copy.get_capabilities().bits());\n  }\n\n  {\n    Packet p({0x1, 0x0, 0x0, 0x9, 0x32}, Capabilities::PROTOCOL_41);\n    Packet p_copy{};\n    p_copy = p;\n    ASSERT_EQ(p.size(), p_copy.size());\n    ASSERT_EQ(p.get_sequence_id(), p_copy.get_sequence_id());\n    ASSERT_EQ(p.get_payload_size(), p_copy.get_payload_size());\n    ASSERT_EQ(p.get_capabilities(), p_copy.get_capabilities());\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, MoveConstructor) {\n  Packet::vector_t buffer = {0x1, 0x0, 0x0, 0x9, 0x32};\n  {\n    Packet p(buffer, Capabilities::PROTOCOL_41);\n    Packet q(std::move(p));\n\n    ASSERT_EQ(buffer.size(), q.size());\n    ASSERT_EQ(Capabilities::PROTOCOL_41, q.get_capabilities());\n    ASSERT_EQ(9U, q.get_sequence_id());\n    ASSERT_EQ(1U, q.get_payload_size());\n\n    // original should be empty and re-set\n    ASSERT_EQ(0U, p.size());\n    ASSERT_EQ(0U, p.get_capabilities().bits());\n    ASSERT_EQ(0U, p.get_sequence_id());\n    ASSERT_EQ(0U, p.get_payload_size());\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, MoveAssigment) {\n  Packet::vector_t buffer = {0x1, 0x0, 0x0, 0x9, 0x32};\n  {\n    Packet p(buffer, Capabilities::PROTOCOL_41);\n    Packet q{};\n    q = std::move(p);\n\n    ASSERT_EQ(buffer.size(), q.size());\n    ASSERT_EQ(Capabilities::PROTOCOL_41, q.get_capabilities());\n    ASSERT_EQ(9U, q.get_sequence_id());\n    ASSERT_EQ(1U, q.get_payload_size());\n\n    // original should be empty and re-set\n    ASSERT_EQ(0U, p.size());\n    ASSERT_EQ(0U, p.get_capabilities().bits());\n    ASSERT_EQ(0U, p.get_sequence_id());\n    ASSERT_EQ(0U, p.get_payload_size());\n  }\n}\n\n\nTEST_F(MySQLProtocolPacketTest, ConstructWithBuffer) {\n  {\n    auto p = Packet(case1);\n    ASSERT_THAT(p, ContainerEq(case1));\n    ASSERT_EQ(4UL, p.get_payload_size());\n    ASSERT_EQ(1UL, p.get_sequence_id());\n  }\n\n  {\n    Packet::vector_t incomplete = {0x04, 0x0, 0x0};\n    auto p = Packet(incomplete);\n    ASSERT_THAT(p, ContainerEq(incomplete));\n    ASSERT_EQ(0UL, p.get_payload_size());\n    ASSERT_EQ(0UL, p.get_sequence_id());\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, seek_and_tell) {\n  Packet p;\n\n  // test seek/tell at beginning + add payload\n  p.seek(0);\n  EXPECT_EQ(0u, p.tell());\n  p.write_int<uint8_t>(11);\n  p.write_int<uint8_t>(12);\n  p.write_int<uint8_t>(13);\n  p.write_int<uint8_t>(14);\n\n  // test seek/tell in the middle\n  p.seek(2);\n  EXPECT_EQ(2u, p.tell());\n  EXPECT_EQ(13u, p.read_int<uint8_t>());\n  EXPECT_EQ(3u, p.tell());\n\n  // seek to EOF\n  EXPECT_NO_THROW(p.seek(p.size()));\n\n  // seek past EOF\n  EXPECT_THROW_LIKE(\n    p.seek(p.size()+1),\n    std::range_error,\n    \"seek past EOF\"\n  );\n}\n\nTEST_F(MySQLProtocolPacketTest, PackInt1Bytes) {\n  {\n    Packet p{};\n    p.seek(0);\n    p.write_int<uint8_t>(0);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x0}));\n\n    p.write_int<uint8_t>(134);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x0, 0x86}));\n\n    p.write_int<uint8_t>(255);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x0, 0x86, 0xff}));\n  }\n\n  {\n    // signed\n    Packet p{};\n    p.seek(0);\n    p.write_int<int8_t>(0);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x0}));\n\n    p.write_int<int8_t>(static_cast<int8_t>(-134));\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x0, 0x7a}));\n\n    p.write_int<int8_t>(static_cast<int8_t>(-254));\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x0, 0x7a, 0x02}));\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, PackInt2Bytes) {\n  {\n    Packet p{};\n    p.seek(0);\n    p.write_int<uint16_t>(0);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x0, 0x00}));\n\n    // Do not change the 0x0086 constant. Accidentally, it tests for\n    // optimization-related bugs in some versions of GCC.\n    p.write_int<uint16_t>(0x0086);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x0, 0x00, 0x86, 0x00}));\n\n    p.write_int<uint16_t>(300);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x0, 0x00, 0x86, 0x00, 0x2c, 0x1}));\n\n    p.write_int<uint16_t>(UINT16_MAX);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x0, 0x00, 0x86, 0x00, 0x2c, 0x1, 0xff, 0xff}));\n  }\n\n  {\n    // signed\n    Packet p{};\n    p.seek(0);\n    p.write_int<int16_t>(INT16_MIN);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x0, 0x80}));\n\n    p = {};\n    p.seek(0);\n    p.write_int<int16_t>(INT16_MAX);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0xff, 0x7f}));\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, PackInt3BytesUnsigned) {\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<uint32_t>(0, 3);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x0, 0x00, 0x00}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<uint32_t>(134, 3);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x86, 0x00, 0x00}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<uint32_t>(500, 3);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0xf4, 0x1, 0x0}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<uint32_t>(53123, 3);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x83, 0xcf, 0x0}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<uint32_t>((1ULL << (CHAR_BIT * 3)) - 1, 3);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0xff, 0xff, 0xff}));\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, PackInt3BytesSigned) {\n  Packet p;\n  p.seek(0);\n  p.write_int<int32_t>(-8388608, 3);\n  ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x00, 0x00, 0x80}));\n\n  p = {};\n  p.seek(0);\n  p.write_int<int32_t>(-1234567, 3);\n  ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x79, 0x29, 0xed}));\n\n  p = {};\n  p.seek(0);\n  p.write_int<int32_t>(8388607, 3);\n  ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0xff, 0xff, 0x7f}));\n}\n\nTEST_F(MySQLProtocolPacketTest, PackInt4ByteUnsigned) {\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<uint32_t>(0);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x0, 0x00, 0x00, 0x00}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<uint32_t>(134);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x86, 0x00, 0x00, 0x00}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<uint32_t>(500);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0xf4, 0x1, 0x00, 0x00}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<uint32_t>(53123);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x83, 0xcf, 0x0, 0x0}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<uint32_t>(2253123);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x43, 0x61, 0x22, 0x0}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<uint32_t>(UINT32_MAX);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0xff, 0xff, 0xff, 0xff}));\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, PackInt4ByteSigned) {\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<int32_t>(0);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x0, 0x00, 0x00, 0x00}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<int32_t>(134);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x86, 0x00, 0x00, 0x00}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<int32_t>(-500);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x0c, 0xfe, 0xff, 0xff}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<int32_t>(53123);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x83, 0xcf, 0x0, 0x0}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<int32_t>(-2253123);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0xbd, 0x9e, 0xdd, 0xff}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<int32_t>(INT32_MIN);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x00, 0x00, 0x00, 0x80}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<int32_t>(INT32_MAX);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0xff, 0xff, 0xff, 0x7f}));\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, write_int_range_test) {\n\n  using V8 = std::vector<uint8_t>;\n\n  // construct template packet\n  Packet p_template;\n  p_template.seek(0);\n  p_template.write_bytes(V8{101, 102, 103, 104});\n  ASSERT_EQ(V8({101, 102, 103, 104}), p_template);\n\n  {\n    Packet p = p_template;\n    p.seek(0);\n    p.write_int<int16_t>(0x0201);\n    V8 expected = {1, 2, 103, 104};\n    EXPECT_EQ(expected, p);\n  }\n  {\n    Packet p = p_template;\n    p.seek(1);\n    p.write_int<int16_t>(0x0201);\n    V8 expected = {101, 1, 2, 104};\n    EXPECT_EQ(expected, p);\n  }\n  {\n    Packet p = p_template;\n    p.seek(2);\n    p.write_int<int16_t>(0x0201);\n    V8 expected = {101, 102, 1, 2};\n    EXPECT_EQ(expected, p);\n  }\n  {\n    Packet p = p_template;\n    p.seek(3);\n    p.write_int<int16_t>(0x0201);\n    V8 expected = {101, 102, 103, 1, 2};\n    EXPECT_EQ(expected, p);\n  }\n  {\n    Packet p = p_template;\n    p.seek(4);\n    p.write_int<int16_t>(0x0201);\n    V8 expected = {101, 102, 103, 104, 1, 2};\n    EXPECT_EQ(expected, p);\n  }\n\n  // no test past EOF is necessary, because it's not possible to seek that far\n}\n\n\nTEST_F(MySQLProtocolPacketTest, PackLenEncodedInt) {\n\n  using V8 = std::vector<uint8_t>;\n\n  // 1-byte\n  {\n    Packet buf;\n    buf.seek(0);\n    EXPECT_EQ(1u, buf.write_lenenc_uint(0u));\n    EXPECT_EQ(V8({0u}), buf);\n  }\n  {\n    Packet buf;\n    buf.seek(0);\n    EXPECT_EQ(1u, buf.write_lenenc_uint(250u));\n    EXPECT_EQ(V8({250u}), buf);\n  }\n\n  // 3-byte\n  {\n    Packet buf;\n    buf.seek(0);\n    EXPECT_EQ(3u, buf.write_lenenc_uint(251u));\n    EXPECT_EQ(V8({0xfc, 251u, 0u}), buf);\n  }\n  {\n    Packet buf;\n    buf.seek(0);\n    EXPECT_EQ(3u, buf.write_lenenc_uint(0x1234));\n    EXPECT_EQ(V8({0xfc, 0x34, 0x12}), buf);\n  }\n  {\n    Packet buf;\n    buf.seek(0);\n    EXPECT_EQ(3u, buf.write_lenenc_uint(0xffff));\n    EXPECT_EQ(V8({0xfc, 0xff, 0xff}), buf);\n  }\n\n  // 4-byte\n  {\n    Packet buf;\n    buf.seek(0);\n    EXPECT_EQ(4u, buf.write_lenenc_uint(0x010000));\n    EXPECT_EQ(V8({0xfd, 0u, 0u, 1u}), buf);\n  }\n  {\n    Packet buf;\n    buf.seek(0);\n    EXPECT_EQ(4u, buf.write_lenenc_uint(0x123456));\n    EXPECT_EQ(V8({0xfd, 0x56, 0x34, 0x12}), buf);\n  }\n  {\n    Packet buf;\n    buf.seek(0);\n    EXPECT_EQ(4u, buf.write_lenenc_uint(0xffffff));\n    EXPECT_EQ(V8({0xfd, 0xff, 0xff, 0xff}), buf);\n  }\n\n  // 9-byte\n  {\n    Packet buf;\n    buf.seek(0);\n    EXPECT_EQ(9u, buf.write_lenenc_uint(0x01000000));\n    EXPECT_EQ(V8({0xfe,   0u, 0u, 0u, 1u,   0u, 0u, 0u, 0u}), buf);\n  }\n  {\n    Packet buf;\n    buf.seek(0);\n    EXPECT_EQ(9u, buf.write_lenenc_uint(0x1234567890abcdef));\n    EXPECT_EQ(V8({0xfe,   0xef, 0xcd, 0xab, 0x90,   0x78, 0x56, 0x34, 0x12}), buf);\n  }\n\n  // range tests\n  {\n    // construct template packet\n    Packet p_template;\n    p_template.seek(0);\n    p_template.write_bytes(V8{101, 102, 103, 104, 105, 106});\n    ASSERT_EQ(V8({101, 102, 103, 104, 105, 106}), p_template);\n\n    {\n      Packet p = p_template;\n      p.seek(0);\n      p.write_lenenc_uint(0x030201);\n      V8 expected = {0xfd, 1, 2, 3, 105, 106};\n      EXPECT_EQ(expected, p);\n    }\n    {\n      Packet p = p_template;\n      p.seek(1);\n      p.write_lenenc_uint(0x030201);\n      V8 expected = {101, 0xfd, 1, 2, 3, 106};\n      EXPECT_EQ(expected, p);\n    }\n    {\n      Packet p = p_template;\n      p.seek(2);\n      p.write_lenenc_uint(0x030201);\n      V8 expected = {101, 102, 0xfd, 1, 2, 3};\n      EXPECT_EQ(expected, p);\n    }\n    {\n      Packet p = p_template;\n      p.seek(3);\n      p.write_lenenc_uint(0x030201);\n      V8 expected = {101, 102, 103, 0xfd, 1, 2, 3};\n      EXPECT_EQ(expected, p);\n    }\n    {\n      Packet p = p_template;\n      p.seek(4);\n      p.write_lenenc_uint(0x030201);\n      V8 expected = {101, 102, 103, 104, 0xfd, 1, 2, 3};\n      EXPECT_EQ(expected, p);\n    }\n    {\n      Packet p = p_template;\n      p.seek(5);\n      p.write_lenenc_uint(0x030201);\n      V8 expected = {101, 102, 103, 104, 105, 0xfd, 1, 2, 3};\n      EXPECT_EQ(expected, p);\n    }\n    {\n      Packet p = p_template;\n      p.seek(6);\n      p.write_lenenc_uint(0x030201);\n      V8 expected = {101, 102, 103, 104, 105, 106, 0xfd, 1, 2, 3};\n      EXPECT_EQ(expected, p);\n    }\n\n    // no test past EOF is necessary, because it's not possible to seek that far\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, PackInt8BytesUnsigned) {\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<uint64_t>(0);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<uint64_t>(134);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x86, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<uint64_t>(500);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0xf4, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<uint64_t>(53123);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x83, 0xcf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<uint64_t>(2253123);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x43, 0x61, 0x22, 0x0, 0x0, 0x0, 0x0, 0x0}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<uint64_t>(361417177240330563UL);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x43, 0x61, 0x22, 0x1, 0x2, 0x3, 0x4, 0x5}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<uint64_t>(4294967295);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0}));\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, PackInt8BytesSigned) {\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<uint64_t>(0);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<int64_t>(134);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x86, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<int64_t>(-500);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x0c, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<int64_t>(53123);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x83, 0xcf, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<int64_t>(-2253123);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0xbd, 0x9e, 0xdd, 0xff, 0xff, 0xff, 0xff, 0xff}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<int64_t>(361417177240330563L);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x43, 0x61, 0x22, 0x1, 0x2, 0x3, 0x4, 0x5}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<int64_t>(-361417177240330563L);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0xbd, 0x9e, 0xdd, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<int64_t>(4294967295);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x0}));\n  }\n\n  {\n    Packet p;\n    p.seek(0);\n    p.write_int<int64_t>(-4294967295LL);\n    ASSERT_THAT(p, ContainerEq(std::vector<uint8_t>{0x01, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff}));\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, write_bytes) {\n  using V8 = std::vector<uint8_t>;\n  V8 bytes = {1, 2, 3};\n\n  // construct template packet\n  Packet p_template;\n  p_template.seek(0);\n  p_template.write_bytes(V8{101, 102, 103, 104, 105});\n  ASSERT_EQ(V8({101, 102, 103, 104, 105}), p_template);\n  EXPECT_EQ(5u, p_template.tell());\n\n  // write at 0\n  {\n    Packet p = p_template;\n    p.seek(0);\n    p.write_bytes(bytes);\n\n    V8 expected = {1, 2, 3, 104, 105};\n    EXPECT_EQ(expected, p);\n    EXPECT_EQ(3u, p.tell());\n  }\n\n  // write at 1\n  {\n    Packet p = p_template;\n    p.seek(1);\n    p.write_bytes(bytes);\n\n    V8 expected = {101, 1, 2, 3, 105};\n    EXPECT_EQ(expected, p);\n    EXPECT_EQ(4u, p.tell());\n  }\n\n  // write at 2\n  {\n    Packet p = p_template;\n    p.seek(2);\n    p.write_bytes(bytes);\n\n    V8 expected = {101, 102, 1, 2, 3};\n    EXPECT_EQ(expected, p);\n    EXPECT_EQ(5u, p.tell());\n  }\n\n  // write at 3\n  {\n    Packet p = p_template;\n    p.seek(3);\n    p.write_bytes(bytes);\n\n    V8 expected = {101, 102, 103, 1, 2, 3};\n    EXPECT_EQ(expected, p);\n    EXPECT_EQ(6u, p.tell());\n  }\n\n  // write at 4\n  {\n    Packet p = p_template;\n    p.seek(4);\n    p.write_bytes(bytes);\n\n    V8 expected = {101, 102, 103, 104, 1, 2, 3};\n    EXPECT_EQ(expected, p);\n    EXPECT_EQ(7u, p.tell());\n  }\n\n  // write at 5 (EOF)\n  {\n    Packet p = p_template;\n    p.seek(5);\n    p.write_bytes(bytes);\n\n    V8 expected = {101, 102, 103, 104, 105, 1, 2, 3};\n    EXPECT_EQ(expected, p);\n    EXPECT_EQ(8u, p.tell());\n  }\n\n  // write empty at 0\n  {\n    Packet p = p_template;\n    p.seek(0);\n    p.write_bytes({});\n\n    V8 expected = {101, 102, 103, 104, 105};\n    EXPECT_EQ(expected, p);\n    EXPECT_EQ(0u, p.tell());\n  }\n\n  // write empty at 3\n  {\n    Packet p = p_template;\n    p.seek(3);\n    p.write_bytes({});\n\n    V8 expected = {101, 102, 103, 104, 105};\n    EXPECT_EQ(expected, p);\n    EXPECT_EQ(3u, p.tell());\n  }\n\n  // write empty at 5 (EOF)\n  {\n    Packet p = p_template;\n    p.seek(5);\n    p.write_bytes({});\n\n    V8 expected = {101, 102, 103, 104, 105};\n    EXPECT_EQ(expected, p);\n    EXPECT_EQ(5u, p.tell());\n  }\n\n  // no test past EOF is necessary, because it's not possible to seek that far\n}\n\nTEST_F(MySQLProtocolPacketTest, write_string) {\n  using V8 = std::vector<uint8_t>;\n  std::string str = \"abc\";\n\n  auto as_string = [](Packet packet) {\n    packet.seek(0);\n    V8 v = packet.read_bytes_eof();\n    return std::string(v.begin(), v.end());\n  };\n\n  // construct template packet\n  Packet p_template;\n  p_template.seek(0);\n  p_template.write_string(\"12345\");\n  ASSERT_EQ(\"12345\", as_string(p_template));\n  EXPECT_EQ(5u, p_template.tell());\n\n  // write at 0\n  {\n    Packet p = p_template;\n    p.seek(0);\n    p.write_string(str);\n    EXPECT_EQ(\"abc45\", as_string(p));\n    EXPECT_EQ(3u, p.tell());\n  }\n\n  // write at 1\n  {\n    Packet p = p_template;\n    p.seek(1);\n    p.write_string(str);\n    EXPECT_EQ(\"1abc5\", as_string(p));\n    EXPECT_EQ(4u, p.tell());\n  }\n\n  // write at 2\n  {\n    Packet p = p_template;\n    p.seek(2);\n    p.write_string(str);\n    EXPECT_EQ(\"12abc\", as_string(p));\n    EXPECT_EQ(5u, p.tell());\n  }\n\n  // write at 3\n  {\n    Packet p = p_template;\n    p.seek(3);\n    p.write_string(str);\n    EXPECT_EQ(\"123abc\", as_string(p));\n    EXPECT_EQ(6u, p.tell());\n  }\n\n  // write at 4\n  {\n    Packet p = p_template;\n    p.seek(4);\n    p.write_string(str);\n    EXPECT_EQ(\"1234abc\", as_string(p));\n    EXPECT_EQ(7u, p.tell());\n  }\n\n  // write at 5 (EOF)\n  {\n    Packet p = p_template;\n    p.seek(5);\n    p.write_string(str);\n    EXPECT_EQ(\"12345abc\", as_string(p));\n    EXPECT_EQ(8u, p.tell());\n  }\n\n  // write empty at 0\n  {\n    Packet p = p_template;\n    p.seek(0);\n    p.write_string(\"\");\n\n    EXPECT_EQ(\"12345\", as_string(p));\n    EXPECT_EQ(0u, p.tell());\n  }\n\n  // write empty at 3\n  {\n    Packet p = p_template;\n    p.seek(3);\n    p.write_string(\"\");\n\n    EXPECT_EQ(\"12345\", as_string(p));\n    EXPECT_EQ(3u, p.tell());\n  }\n\n  // write empty at 5 (EOF)\n  {\n    Packet p = p_template;\n    p.seek(5);\n    p.write_string(\"\");\n\n    EXPECT_EQ(\"12345\", as_string(p));\n    EXPECT_EQ(5u, p.tell());\n  }\n\n  // no test past EOF is necessary, because it's not possible to seek that far\n}\n\nTEST_F(MySQLProtocolPacketTest, UnpackUInt8) {\n  {\n    Packet buf{0x10};\n    EXPECT_EQ(16u, buf.read_int_from<uint8_t>(0));\n  }\n  {\n    Packet buf{0x10, 0x20};\n    EXPECT_EQ(32u, buf.read_int_from<uint8_t>(1));\n  }\n\n  {\n    Packet buf{0x10};\n    EXPECT_EQ(16u, buf.read_int_from<uint8_t>(0, 1));\n  }\n  {\n    Packet buf{0x10, 0x20};\n    EXPECT_EQ(16u, buf.read_int_from<uint8_t>(0, 2));\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, UnpackUInt16) {\n  {\n    Packet buf{0x10, 0x00};\n    EXPECT_EQ(16u, buf.read_int_from<uint16_t>(0, 2));\n  }\n\n  {\n    Packet buf{0x10, 0x20};\n    EXPECT_EQ(8208u, buf.read_int_from<uint16_t>(0));\n  }\n\n  {\n    Packet buf{0x10, 0x20, 0x30};\n    EXPECT_EQ(8208u, buf.read_int_from<uint16_t>(0, 2));\n  }\n\n  {\n    Packet buf{0xab, 0xba};\n    EXPECT_EQ(47787u, buf.read_int_from<uint16_t>(0));\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, UnpackInt3Bytes) {\n\n  // unsigned\n  {\n    Packet buf{0x10, 0x00, 0x00};\n    EXPECT_EQ(16U, buf.read_int_from<uint32_t>(0, 3));\n  }\n\n  {\n    Packet buf{0x10, 0x20, 0x00};\n    EXPECT_EQ(8208U, buf.read_int_from<uint32_t>(0, 3));\n  }\n\n  {\n    Packet buf{0x10, 0x20, 0x30};\n    EXPECT_EQ(3153936U, buf.read_int_from<uint32_t>(0, 3));\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, UnpackInt4bytes) {\n\n  // unsigned\n  {\n    Packet buf({0x10, 0x00, 0x00, 0x00}, true);\n    EXPECT_EQ(16U, buf.read_int_from<uint32_t>(0));\n  }\n\n  {\n    Packet buf({0x10, 0x20, 0x00, 0x00}, true);\n    EXPECT_EQ(8208U, buf.read_int_from<uint32_t>(0));\n  }\n\n  {\n    Packet buf({0x10, 0x20, 0x30, 0x40}, true);\n    EXPECT_EQ(1076895760U, buf.read_int_from<uint32_t>(0, 4));\n  }\n\n  {\n    Packet buf({0x10, 0x20, 0x30, 0x40, 0x50}, true);\n    EXPECT_EQ(1076895760U, buf.read_int_from<uint32_t>(0, 4));\n  }\n\n  // signed\n  {\n    Packet buf({0xff, 0xff, 0xff, 0xff}, true);\n    EXPECT_EQ(-1, buf.read_int_from<int>(0));\n  }\n\n  {\n    Packet buf({0xf2, 0xff, 0xff, 0xff}, true);\n    EXPECT_EQ(-14, buf.read_int_from<int>(0));\n  }\n\n  {\n    Packet buf({0xff, 0xff, 0xff, 0xfe}, true);\n    EXPECT_EQ(-16777217, buf.read_int_from<int>(0));\n  }\n\n  {\n    Packet buf({0xff, 0xff, 0xff, 0x7f}, true);\n    EXPECT_EQ(2147483647, buf.read_int_from<int>(0, 4));\n  }\n\n  {\n    Packet buf({0x02, 0x00, 0x00, 0x80}, true);\n    EXPECT_EQ(-2147483646, buf.read_int_from<int>(0, 4));\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, UnpackUInt64) {\n  {\n    Packet buf({0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, true);\n    EXPECT_EQ(16UL, buf.read_int_from<uint64_t>(0));\n  }\n\n  {\n    Packet buf({0x10, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, true);\n    EXPECT_EQ(8208UL, buf.read_int_from<uint64_t>(0));\n  }\n\n  {\n    Packet buf({0x10, 0x20, 0x30, 0x40, 0x00, 0x00, 0x00, 0x00}, true);\n    EXPECT_EQ(1076895760UL, buf.read_int_from<uint64_t>(0, 8));\n  }\n\n  {\n    Packet buf({0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00}, true);\n    EXPECT_EQ(4294967295UL, buf.read_int_from<uint64_t>(0));\n  }\n\n  {\n    Packet buf({0x10, 0x20, 0x30, 0x40, 0x50, 0x00, 0x00, 0x80, 0x90}, true);\n    EXPECT_EQ(9223372381529055248UL, buf.read_int_from<uint64_t>(0));\n  }\n\n  {\n    Packet buf({0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, true);\n    EXPECT_EQ(18446744073709551615UL, buf.read_int_from<uint64_t>(0));\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, UnpackInt_invalid_input) {\n\n  Packet buf10({0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xa0}, true);\n\n  // supported sizes\n  {\n    for (size_t i : {1, 2, 3, 4, 8})\n      buf10.read_int_from<uint64_t>(0, i); // shouldn't die\n  }\n\n  // unsuppposed sizes\n  {\n    for (size_t i : {0, 5, 6, 7, 9}) { // doesn't compile without {} on VS2015\n      EXPECT_DEATH_IF_SUPPORTED(buf10.read_int_from<uint64_t>(0, i), \"\");\n    }\n  }\n\n  // start beyond EOF\n  {\n    Packet buf{};\n    EXPECT_THROW_LIKE(\n      buf.read_int_from<uint64_t>(0, 1),\n      std::range_error,\n      \"start or end beyond EOF\"\n    );\n  }\n  {\n    EXPECT_NO_THROW(buf10.read_int_from<uint64_t>(9, 1));\n  }\n  {\n    EXPECT_THROW_LIKE(\n      buf10.read_int_from<uint64_t>(10, 1),\n      std::range_error,\n      \"start or end beyond EOF\"\n    );\n  }\n\n  // end beyond EOF\n  {\n    EXPECT_NO_THROW(buf10.read_int_from<uint64_t>(6, 4));\n  }\n  {\n    EXPECT_THROW_LIKE(\n      buf10.read_int_from<uint64_t>(7, 4),\n      std::range_error,\n      \"start or end beyond EOF\"\n    );\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, UnpackLenEncodedInt) {\n\n  {\n    Packet buf(Packet::vector_t{0xfa}, true);\n    EXPECT_EQ(250U, buf.read_lenenc_uint_from(0).first);\n    EXPECT_EQ(1U, buf.read_lenenc_uint_from(0).second);\n  }\n\n  {\n    Packet buf({0xfc, 0xfb, 0x00}, true);\n    EXPECT_EQ(251U, buf.read_lenenc_uint_from(0).first);\n    EXPECT_EQ(3U, buf.read_lenenc_uint_from(0).second);\n  }\n\n  {\n    Packet buf({0xfc, 0xff, 0xff}, true);\n    EXPECT_EQ(65535U, buf.read_lenenc_uint_from(0).first);\n    EXPECT_EQ(3U, buf.read_lenenc_uint_from(0).second);\n  }\n\n  {\n    Packet buf({0xfd, 0x00, 0x00, 0x01}, true);\n    EXPECT_EQ(65536U, buf.read_lenenc_uint_from(0).first);\n    EXPECT_EQ(4U, buf.read_lenenc_uint_from(0).second);\n  }\n\n  {\n    Packet buf({0xfd, 0xff, 0xff, 0xff, 0xff}, true);\n    EXPECT_EQ(16777215U, buf.read_lenenc_uint_from(0).first);\n    EXPECT_EQ(4U, buf.read_lenenc_uint_from(0).second);\n  }\n\n  // this test has special significance: if we parsed according to protocol v3.20\n  // (which we don't implement atm), this would have to return 5U instead of 9U\n  {\n    Packet buf({0xfe, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00}, true);\n    EXPECT_EQ(16777216U, buf.read_lenenc_uint_from(0).first);\n    EXPECT_EQ(9U, buf.read_lenenc_uint_from(0).second);\n  }\n\n  {\n    Packet buf({0xfe, 0x10, 0x20, 0x30, 0x40, 0x50, 0x00, 0x00, 0x80, 0x90}, true);\n    EXPECT_EQ(9223372381529055248UL, buf.read_lenenc_uint_from(0).first);\n    EXPECT_EQ(9U, buf.read_lenenc_uint_from(0).second);\n  }\n\n  {\n    Packet buf({0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, true);\n    EXPECT_EQ(ULLONG_MAX, buf.read_lenenc_uint_from(0).first);\n    EXPECT_EQ(9U, buf.read_lenenc_uint_from(0).second);\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, read_lenenc_uint_from) {\n\n  // ok\n  {\n    Packet buf({0xfe, 0x10, 0x20, 0x30, 0x40, 0x50, 0x00, 0x00, 0x80}, true);\n    EXPECT_NO_THROW(buf.read_lenenc_uint_from(0));\n  }\n\n  // start beyond EOF\n  {\n    Packet buf({0xfe, 0x10, 0x20, 0x30, 0x40, 0x50, 0x00, 0x00, 0x80}, true);\n    EXPECT_THROW_LIKE(\n      buf.read_lenenc_uint_from(10),\n      std::range_error,\n      \"start beyond EOF\"\n    );\n  }\n\n  // end beyond EOF\n  {\n    Packet buf({0xfe, 0x10, 0x20, 0x30, 0x40, 0x50, 0x00, 0x00}, true);\n    EXPECT_THROW_LIKE(\n      buf.read_lenenc_uint_from(0),\n      std::range_error,\n      \"end beyond EOF\"\n    );\n  }\n\n  // illegal first byte\n  {\n    Packet buf({0xfb}, true);\n    EXPECT_THROW_LIKE(\n      buf.read_lenenc_uint_from(0),\n      std::runtime_error,\n      \"illegal value at first byte\"\n    );\n  }\n  {\n    Packet buf({0xff}, true);\n    EXPECT_THROW_LIKE(\n      buf.read_lenenc_uint_from(0),\n      std::runtime_error,\n      \"illegal value at first byte\"\n    );\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, read_lenenc_uint) {\n\n  Packet buf({0xfe, 0x10, 0x20, 0x30,   0x40, 0x50, 0x00, 0x00,   0x80, 0xfe}, true);\n  buf.seek(0);\n  EXPECT_NO_THROW(buf.read_lenenc_uint());\n  EXPECT_EQ(9u, buf.tell());\n\n  EXPECT_THROW_LIKE(\n    buf.read_lenenc_uint(),\n    std::range_error,\n    \"end beyond EOF\"\n  );\n  EXPECT_EQ(9u, buf.tell());\n}\n\nTEST_F(MySQLProtocolPacketTest, UnpackString) {\n  {\n    Packet p({'h', 'a', 'm', 0x0, 's', 'p', 'a', 'm'}, true);\n    auto res = p.read_string_from(0);\n    EXPECT_EQ(string(\"ham\"), res);\n    res = p.read_string_from(res.size() + 1UL);\n    EXPECT_EQ(string(\"spam\"), res);\n    res = p.read_string_from(0, p.size());\n    EXPECT_EQ(string(\"ham\"), res);\n  }\n\n  {\n    Packet p{};\n    EXPECT_EQ(string{}, p.read_string_from(0));\n  }\n\n  {\n    Packet p({'h', 'a', 'm', 's', 'p', 'a', 'm'}, true);\n    EXPECT_EQ(string(\"hamspam\"), p.read_string_from(0));\n  }\n\n  {\n    Packet p({'h', 'a', 'm'}, true);\n    EXPECT_EQ(string(\"\"), p.read_string_from(30));\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, UnpackStringLengthFixed) {\n  Packet p({'h', 'a', 'm', 's', 'p', 'a', 'm'}, true);\n\n  {\n    auto res = p.read_string_from(0, 3);\n    EXPECT_EQ(res, string(\"ham\"));\n  }\n\n  {\n    auto res = p.read_string_from(0, 2);\n    EXPECT_EQ(res, string(\"ha\"));\n  }\n\n  {\n    auto res = p.read_string_from(3, 4);\n    EXPECT_EQ(res, string(\"spam\"));\n  }\n}\n\nTEST_F(MySQLProtocolPacketTest, read_string_nul_from) {\n  Packet p({'s', 'o', 'm', 'e', 0x0, 'n', 'o', 'z', 'e', 'r', 'o'}, true);\n\n  EXPECT_EQ(\"some\", p.read_string_nul_from(0));\n  EXPECT_EQ(\"ome\", p.read_string_nul_from(1));\n  EXPECT_EQ(\"\", p.read_string_nul_from(4));\n  EXPECT_THROW_LIKE(\n    p.read_string_nul_from(5),\n    std::runtime_error,\n    \"zero-terminator not found\"\n  );\n  EXPECT_THROW_LIKE(\n    p.read_string_nul_from(10),\n    std::runtime_error,\n    \"zero-terminator not found\"\n  );\n  EXPECT_THROW_LIKE(\n    p.read_string_nul_from(11),\n    std::range_error,\n    \"start beyond EOF\"\n  );\n}\n\nTEST_F(MySQLProtocolPacketTest, read_string_nul) {\n  Packet p({'s', 'o', 'm', 'e', 0x0, 's', 't', 'r', 'i', 'n', 'g', 0x0, 'n', 'o', 'z', 'e', 'r', 'o'}, true);\n  p.seek(0);\n\n  EXPECT_EQ(\"some\", p.read_string_nul());\n  EXPECT_EQ(5u, p.tell());\n\n  EXPECT_EQ(\"string\", p.read_string_nul());\n  EXPECT_EQ(12u, p.tell());\n\n  EXPECT_THROW_LIKE(\n    p.read_string_nul(),\n    std::runtime_error,\n    \"zero-terminator not found\"\n  );\n  EXPECT_EQ(12u, p.tell());\n}\n\nTEST_F(MySQLProtocolPacketTest, read_bytes_from) {\n  Packet p({0x1, 0x0, 0x0, 0x9, 0x32});\n  using V = std::vector<uint8_t>;\n\n  EXPECT_EQ(V{}, p.read_bytes_from(0,0));\n  EXPECT_EQ(V{0x1}, p.read_bytes_from(0,1));\n\n  {\n    V exp = {0x1, 0x0, 0x0, 0x9}; // doesn't build inline\n    EXPECT_EQ(exp, p.read_bytes_from(0,4));\n  }\n  {\n    V exp = {0x0, 0x0, 0x9, 0x32};\n    EXPECT_EQ(exp, p.read_bytes_from(1,4));\n  }\n\n  EXPECT_THROW_LIKE(\n    p.read_bytes_from(2,4),\n    std::range_error,\n    \"start or end beyond EOF\"\n  );\n\n  EXPECT_EQ(V{}, p.read_bytes_from(5,0));\n}\n\nTEST_F(MySQLProtocolPacketTest, read_bytes) {\n  Packet p({1, 0, 0, 9, 32});\n  using V = std::vector<uint8_t>;\n\n  p.seek(0);\n\n  V exp = {1, 0, 0}; // doesn't build inline\n  EXPECT_EQ(exp, p.read_bytes(3));\n  EXPECT_EQ(3u, p.tell());\n\n  EXPECT_THROW_LIKE(\n    p.read_bytes(3),\n    std::runtime_error,\n    \"start or end beyond EOF\"\n  );\n  EXPECT_EQ(3u, p.tell());\n}\n\nTEST_F(MySQLProtocolPacketTest, read_bytes_eof_from) {\n  Packet p({0x0, 0x9, 0x32, 0x0}, true);\n  using V = std::vector<uint8_t>;\n\n  {\n    V exp = {0x0, 0x9, 0x32, 0x0}; // doesn't build inline\n    EXPECT_EQ(exp, p.read_bytes_eof_from(0));\n  }\n  {\n    V exp = {0x0};\n    EXPECT_EQ(exp, p.read_bytes_eof_from(3));\n  }\n\n  EXPECT_THROW_LIKE(\n    p.read_bytes_eof_from(4),\n    std::range_error,\n    \"start beyond EOF\"\n  );\n}\n\nTEST_F(MySQLProtocolPacketTest, read_bytes_eof) {\n  Packet p({0x0, 0x9, 0x32, 0x0}, true);\n  using V = std::vector<uint8_t>;\n\n  p.seek(0);\n  V exp = {0x0, 0x9, 0x32, 0x0}; // doesn't build inline\n\n  EXPECT_EQ(exp, p.read_bytes_eof());\n  EXPECT_EQ(4u, p.tell());\n\n  EXPECT_THROW_LIKE(\n    p.read_bytes_eof(),\n    std::range_error,\n    \"start beyond EOF\"\n  );\n}\n\nTEST_F(MySQLProtocolPacketTest, UnpackBytesLengthEncoded1Byte) {\n  Packet p({0x07, 'h', 'a', 'm', 's', 'p', 'a', 'm', 'f', 'o', 'o'}, true);\n  auto pr = p.read_lenenc_bytes_from(0);\n  EXPECT_THAT(pr.first, ContainerEq(Packet::vector_t{'h', 'a', 'm', 's', 'p', 'a', 'm'}));\n  EXPECT_EQ(8u, pr.second);\n}\n\nTEST_F(MySQLProtocolPacketTest, UnpackStringLengthEncoded3Bytes) {\n  size_t length = 316;\n  unsigned char filler = 0x4d;\n\n  std::vector<uint8_t> data(length + 3, filler);\n  data[0] = 0xfc;\n  data[1] = 0x3c;\n  data[2] = 0x01;\n  Packet p(data, true);\n\n  auto pr = p.read_lenenc_bytes_from(0);\n  EXPECT_EQ(pr.first.size(), length);\n  EXPECT_EQ(pr.first[0], filler);\n  EXPECT_EQ(pr.first[length - 1], filler);\n  EXPECT_EQ(length + 3, pr.second);\n}\n\nTEST_F(MySQLProtocolPacketTest, UnpackStringLengthEncoded8Bytes) {\n  size_t length = 16777216;\n  unsigned char filler = 0x4d;\n\n  std::vector<uint8_t> data(length + 9, filler);\n  std::vector<uint8_t> enc_length{0xfe, 0x0, 0x0, 0x0, 0x01, 0x0, 0x0, 0x0, 0x0};\n  std::copy(enc_length.begin(), enc_length.end(), data.begin());\n  Packet p(data, true);\n\n  auto pr = p.read_lenenc_bytes_from(0);\n  EXPECT_EQ(pr.first.size(), length);\n  EXPECT_EQ(pr.first[length - 1], filler);\n  EXPECT_EQ(length + 9, pr.second);\n}\n\nTEST_F(MySQLProtocolPacketTest, UnpackStringLengthEncoded8BytesWithNulByte) {\n  size_t length = 16777216;\n  unsigned char filler = 0x4d;\n\n  std::vector<uint8_t> data(length + 9, filler);\n  std::vector<uint8_t> enc_length{0xfe, 0x0, 0x0, 0x0, 0x01, 0x0, 0x0, 0x0, 0x0};\n  std::copy(enc_length.begin(), enc_length.end(), data.begin());\n  data[length / 2] = 0x0;\n  Packet p(data, true);\n\n  auto pr = p.read_lenenc_bytes_from(0);\n  EXPECT_EQ(pr.first.size(), length);\n  EXPECT_EQ(pr.first[length - 1], filler);\n  EXPECT_EQ(length + 9, pr.second);\n}\n\nTEST_F(MySQLProtocolPacketTest, read_lenenc_bytes_from) {\n  // throw scenarios for length-encoded uint are tested by read_lenenc_uint_from() test,\n  // so here we only need to test for the cases of payload being beyond EOF\n\n  Packet buf({4, 0x10, 0x20, 0x30, 0x40}, true);\n\n  EXPECT_NO_THROW(buf.read_lenenc_bytes_from(0));\n\n  buf.pop_back();\n  EXPECT_THROW_LIKE(\n    buf.read_lenenc_bytes_from(0),\n    std::range_error,\n    \"start or end beyond EOF\"\n  );\n}\n\nTEST_F(MySQLProtocolPacketTest, read_lenenc_bytes) {\n\n  Packet buf({4, 0x10, 0x20, 0x30,   0x40, 2, 0x11, 0x22,   0x99}, true);\n  buf.seek(0);\n  EXPECT_NO_THROW(buf.read_lenenc_bytes());\n  EXPECT_EQ(5u, buf.tell());\n  EXPECT_NO_THROW(buf.read_lenenc_bytes());\n  EXPECT_EQ(8u, buf.tell());\n\n  EXPECT_THROW_LIKE(\n    buf.read_lenenc_bytes(),\n    std::range_error,\n    \"end beyond EOF\"\n  );\n  EXPECT_EQ(8u, buf.tell());\n}\n\nTEST_F(MySQLProtocolPacketTest, append_bytes) {\n  Packet buf({0x10, 0x20, 0x30, 0x40}, true);\n\n  // add 0 bytes\n  buf.seek(buf.size());\n  buf.append_bytes(0, 0x99);\n  EXPECT_EQ(4u, buf.tell());\n\n  // add 3 bytes\n  buf.append_bytes(3, 0x99);\n  Packet exp({0x10, 0x20, 0x30, 0x40, 0x99, 0x99, 0x99}, true);\n  EXPECT_EQ(7u, buf.tell());\n  EXPECT_EQ(exp, buf);\n\n  // not at EOF\n  buf.seek(6);\n  EXPECT_THROW_LIKE(\n    buf.append_bytes(3, 0x99),\n    std::range_error,\n    \"not at EOF\"\n  );\n}\n\nint main(int argc, char *argv[]) {\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/mysql_protocol/tests/test_constants.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n\n#include <gmock/gmock.h>\n\n#include \"mysqlrouter/mysql_protocol.h\"\n\n/**\n * @file\n * @brief Tests to test mysql_protocol Capabilities flags\n */\n\nusing namespace mysql_protocol;\n\nclass MySQLProtocolCapabilitiesTest : public ::testing::Test {};\n\n/**\n * @test test constructors\n */\nTEST_F(MySQLProtocolCapabilitiesTest, constructor) {\n\n  {\n    Capabilities::Flags cap;\n    EXPECT_EQ(0U, cap.bits());\n  }\n  {\n    Capabilities::Flags cap(0x1234);\n    EXPECT_EQ(0x1234U, cap.bits());\n  }\n  {\n    Capabilities::Flags cap(Capabilities::LONG_PASSWORD);\n    EXPECT_EQ(Capabilities::LONG_PASSWORD.bits(), cap.bits());\n  }\n}\n\n/**\n * @test test operator=()\n */\nTEST_F(MySQLProtocolCapabilitiesTest, assignment) {\n\n  {\n    Capabilities::Flags cap;\n    cap = Capabilities::Flags(0x1234);\n    EXPECT_EQ(0x1234U, cap.bits());\n  }\n  {\n    Capabilities::Flags cap;\n    cap = Capabilities::LONG_PASSWORD;\n    EXPECT_EQ(Capabilities::LONG_PASSWORD.bits(), cap.bits());\n  }\n}\n\n/**\n * @test test operator==() and operator!=()\n */\nTEST_F(MySQLProtocolCapabilitiesTest, comparison) {\n\n  Capabilities::Flags cap1(Capabilities::LONG_PASSWORD);\n  Capabilities::Flags cap2(Capabilities::FOUND_ROWS);\n\n  EXPECT_TRUE(cap1 == cap1);\n  EXPECT_TRUE(cap1 != cap2);\n  EXPECT_FALSE(cap1 != cap1);\n  EXPECT_FALSE(cap1 == cap2);\n}\n\n/**\n * @test test methods that modify flags\n */\nTEST_F(MySQLProtocolCapabilitiesTest, write) {\n  using namespace Capabilities;\n\n  Flags cap(LONG_PASSWORD | FOUND_ROWS | LONG_FLAG | CONNECT_WITH_DB);\n\n  cap.clear(FOUND_ROWS | LONG_FLAG);\n  EXPECT_EQ(LONG_PASSWORD | CONNECT_WITH_DB, cap);\n\n  cap.set(PLUGIN_AUTH | DEPRECATE_EOF);\n  EXPECT_EQ(LONG_PASSWORD | CONNECT_WITH_DB | PLUGIN_AUTH | DEPRECATE_EOF, cap);\n\n  {\n    Flags cap2 = cap;\n    cap2.clear_low_16_bits();\n    EXPECT_EQ(PLUGIN_AUTH | DEPRECATE_EOF, cap2);\n  }\n\n  {\n    Flags cap2 = cap;\n    cap2.clear_high_16_bits();\n    EXPECT_EQ(LONG_PASSWORD | CONNECT_WITH_DB, cap2);\n  }\n\n  cap.reset();\n  EXPECT_EQ(ALL_ZEROS, cap);\n\n  Flags cap1(                FOUND_ROWS | LONG_FLAG |                   PLUGIN_AUTH | DEPRECATE_EOF);\n  Flags cap2(LONG_PASSWORD              | LONG_FLAG | CONNECT_WITH_DB               | DEPRECATE_EOF);\n  EXPECT_EQ(LONG_FLAG | DEPRECATE_EOF, cap1 & cap2);\n}\n\n/**\n * @test test methods that return flags\n */\nTEST_F(MySQLProtocolCapabilitiesTest, read) {\n  using namespace Capabilities;\n\n  Capabilities::Flags cap(LONG_PASSWORD | NO_SCHEMA | SSL |                   // these are in low bits\n                          MULTI_STATEMENTS | CONNECT_ATTRS | DEPRECATE_EOF ); // these are in high bits\n\n  // test for one bit at a time\n  EXPECT_TRUE(cap.test(LONG_PASSWORD));\n  EXPECT_TRUE(cap.test(SSL));\n  EXPECT_TRUE(cap.test(CONNECT_ATTRS));\n  EXPECT_FALSE(cap.test(LONG_FLAG));\n  EXPECT_FALSE(cap.test(FOUND_ROWS));\n\n  // test for many bits at a time\n  EXPECT_TRUE(cap.test(LONG_PASSWORD | SSL | CONNECT_ATTRS));               // testing subset of set bits\n  EXPECT_FALSE(cap.test(LONG_PASSWORD | SSL | CONNECT_ATTRS | LONG_FLAG));  // LONG_FLAG not set\n\n  // test low/high bits\n  EXPECT_EQ((LONG_PASSWORD | NO_SCHEMA | SSL).bits(),              static_cast<AllFlags>(cap.low_16_bits()));\n  EXPECT_EQ((MULTI_STATEMENTS | CONNECT_ATTRS | DEPRECATE_EOF).bits(), static_cast<AllFlags>(cap.high_16_bits() << 16));\n}\n\nint main(int argc, char *argv[]) {\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/mysql_protocol/tests/test_error_packet.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <gmock/gmock.h>\n\n#include <cstdlib>\n#include <cstring>\n#include <string.h>\n\n#include \"mysqlrouter/mysql_protocol.h\"\n#include \"mysqlrouter/utils.h\"\n\nusing std::string;\nusing ::testing::ContainerEq;\nusing ::testing::HasSubstr;\nusing ::testing::NotNull;\n\nusing namespace mysql_protocol;\n\nclass MySQLProtocolTest : public ::testing::Test {\npublic:\n  mysql_protocol::Packet::vector_t case_w_sqlstate = {\n      0x1d, 0x00, 0x00, 0x00, 0xff, 0x9f, 0x0f, 0x23,\n      0x58, 0x59, 0x31, 0x32, 0x33, 0x54, 0x68, 0x69,\n      0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x74,\n      0x65, 0x73, 0x74, 0x20, 0x65, 0x72, 0x72, 0x6f,\n      0x72,\n  };\n\n  mysql_protocol::Packet::vector_t case_wo_sqlstate = {\n      0x17, 0x00, 0x00, 0x00, 0xff, 0x9f, 0x0f, 0x54,\n      0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61,\n      0x20, 0x74, 0x65, 0x73, 0x74, 0x20, 0x65, 0x72,\n      0x72, 0x6f, 0x72,\n  };\nprotected:\n  virtual void SetUp() {\n  }\n};\n\nTEST_F(MySQLProtocolTest, Constructor) {\n  string msg = \"This is a test error\";\n  uint16_t code = 3999;\n\n  auto error_packet = mysql_protocol::ErrorPacket(0, code, msg, \"XY123\");\n\n  ASSERT_EQ(0U, error_packet.get_capabilities().bits());\n  ASSERT_EQ(case_wo_sqlstate.size(), error_packet.size());\n  ASSERT_THAT(error_packet, ContainerEq(case_wo_sqlstate));\n}\n\nTEST_F(MySQLProtocolTest, ConstructorBufferCapabilities) {\n  {\n    // Without SQL State; CLIENT_PROTOCOL_41 capability flag not set\n    auto p = mysql_protocol::ErrorPacket(case_wo_sqlstate);\n\n    ASSERT_EQ(0U, p.get_capabilities().bits());\n    ASSERT_EQ(case_wo_sqlstate.size(), p.size());\n    ASSERT_THAT(p, ContainerEq(case_wo_sqlstate));\n    ASSERT_EQ(\"\", p.get_sql_state());\n    ASSERT_EQ(\"This is a test error\", p.get_message());\n  }\n\n  {\n    // With SQL State; CLIENT_PROTOCOL_41 capability flag set\n    auto p = mysql_protocol::ErrorPacket(case_w_sqlstate, Capabilities::PROTOCOL_41);\n\n    ASSERT_EQ(Capabilities::PROTOCOL_41, p.get_capabilities());\n    ASSERT_EQ(case_w_sqlstate.size(), p.size());\n    ASSERT_THAT(p, ContainerEq(case_w_sqlstate));\n    ASSERT_EQ(\"XY123\", p.get_sql_state());\n    ASSERT_EQ(\"This is a test error\", p.get_message());\n  }\n\n  {\n    // With SQL State; CLIENT_PROTOCOL_41 capability flag not set\n    auto p = mysql_protocol::ErrorPacket(case_w_sqlstate);\n\n    ASSERT_EQ(0U, p.get_capabilities().bits());\n    ASSERT_EQ(case_w_sqlstate.size(), p.size());\n    ASSERT_THAT(p, ContainerEq(case_w_sqlstate));\n    ASSERT_EQ(\"XY123\", p.get_sql_state());\n    ASSERT_EQ(\"This is a test error\", p.get_message());\n  }\n}\n\nTEST_F(MySQLProtocolTest, ConstructorWithCapabilities) {\n  string msg = \"This is a test error\";\n  uint16_t code = 3999;\n\n  auto error_packet = mysql_protocol::ErrorPacket(0, code, msg, \"XY123\",\n                                                  Capabilities::PROTOCOL_41);\n\n  ASSERT_EQ(error_packet.get_capabilities(), Capabilities::PROTOCOL_41);\n  ASSERT_EQ(case_w_sqlstate.size(), error_packet.size());\n  ASSERT_THAT(error_packet, ContainerEq(case_w_sqlstate));\n}\n\nTEST_F(MySQLProtocolTest, ParsePayloadErrors) {\n  {\n    // One byte missing; payload size incorrect\n    auto buffer = mysql_protocol::Packet::vector_t(case_w_sqlstate.begin(), case_w_sqlstate.end() - 1);\n\n    ASSERT_THROW({ mysql_protocol::ErrorPacket e(buffer); }, mysql_protocol::packet_error);\n    try {\n      mysql_protocol::ErrorPacket e(buffer);\n    } catch (const mysql_protocol::packet_error &exc) {\n      ASSERT_THAT(exc.what(), HasSubstr(\"Incorrect payload size\"));\n    }\n  }\n\n  {\n    // 0xff not found as 5th byte\n    auto buffer = case_w_sqlstate;\n    buffer[4] = 0xfe;\n    ASSERT_THROW({ mysql_protocol::ErrorPacket e(buffer); }, mysql_protocol::packet_error);\n    try {\n      mysql_protocol::ErrorPacket e(buffer);\n    } catch (const mysql_protocol::packet_error &exc) {\n      ASSERT_THAT(exc.what(), HasSubstr(\"Error packet marker 0xff not found\"));\n    }\n  }\n\n  {\n    // SQLState should be present\n    std::vector<uint8_t> buffer = {\n        0x17, 0x00, 0x00, 0x00, 0xff, 0x9f, 0x0f, 0x54,\n        0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61,\n        0x20, 0x74, 0x65, 0x73, 0x74, 0x20, 0x65, 0x72,\n        0x72, 0x6f, 0x72,\n    };\n\n    ASSERT_THROW({ mysql_protocol::ErrorPacket e(buffer, Capabilities::PROTOCOL_41); },\n                 mysql_protocol::packet_error);\n    try {\n      mysql_protocol::ErrorPacket e(buffer, Capabilities::PROTOCOL_41);\n    } catch (const mysql_protocol::packet_error &exc) {\n      ASSERT_THAT(exc.what(), HasSubstr(\"Error packet does not contain SQL state\"));\n    }\n  }\n}\n\n"
  },
  {
    "path": "src/mysql_protocol/tests/test_handshake_packet.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <gmock/gmock.h>\n\n#include <cstdlib>\n#include <cstring>\n#include <string.h>\n\n#include \"mysqlrouter/mysql_protocol.h\"\n#include \"mysqlrouter/utils.h\"\n\n//TODO This is already defined in ../../../tests/helpers/router_test_helpers.h, but\n//     we don't want to include that (different sub-project).  Instead, it should be\n//     moved to mysql_harness/shared/include/test/helpers.h first, and then #included\n//     from here.\n#define EXPECT_THROW_LIKE(expr, exc, msg) try { \\\n      expr;\\\n      ADD_FAILURE() << \"Expected exception of type \" #exc << \" but got none\\n\";\\\n    } catch (exc &e) {\\\n      if (std::string(e.what()).find(msg) == std::string::npos) {\\\n          ADD_FAILURE() << \"Expected exception with message: \" << msg << \"\\nbut got: \" << e.what() << \"\\n\";\\\n      }\\\n    } catch (...) {\\\n      ADD_FAILURE() << \"Expected exception of type \" #exc << \" but got another\\n\";\\\n    }\n\nusing std::string;\nusing ::testing::ContainerEq;\nusing ::testing::NotNull;\nusing namespace mysql_protocol;\n\n/**\n * @file\n * @brief Unit tests to test Handshake Response Packet, and PROTOCOL41 parser\n */\n\nclass HandshakeResponsePacketTest : public ::testing::Test {\nprotected:\n  virtual void SetUp() {\n  }\n};\n\nTEST_F(HandshakeResponsePacketTest, DefaultConstructor) {\n  mysql_protocol::HandshakeResponsePacket p{};\n\n  std::vector<unsigned char> exp {\n      0x4d, 0x00, 0x00, 0x00, 0x8d, 0xa2, 0x03, 0x00, 0x00, 0x00, 0x00, 0x40, 0x08, 0x00, 0x00, 0x00,\n      0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n      0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71,\n      0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x00, 0x6d, 0x79, 0x73, 0x71, 0x6c,\n      0x5f, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64,\n      0x00,\n  };\n\n  ASSERT_THAT(p, ContainerEq(exp));\n}\n\nTEST_F(HandshakeResponsePacketTest, Constructor) {\n  std::vector<unsigned char> auth_response = {0x50, 0x51, 0x50, 0x51, 0x50, 0x51};\n  {\n    // Setting the username; empty password\n    mysql_protocol::HandshakeResponsePacket p(1, auth_response, \"ROUTERTEST\", \"\");\n\n    std::vector<unsigned char> exp {\n        0x57, 0x00, 0x00, 0x01, 0x8d, 0xa2, 0x03, 0x00, 0x00, 0x00, 0x00, 0x40, 0x08, 0x00, 0x00, 0x00,\n        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n        0x00, 0x00, 0x00, 0x00, 0x52, 0x4f, 0x55, 0x54, 0x45, 0x52, 0x54, 0x45, 0x53, 0x54, 0x00, 0x14,\n        0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71,\n        0x71, 0x71, 0x71, 0x71, 0x00, 0x6d, 0x79, 0x73, 0x71, 0x6c, 0x5f, 0x6e, 0x61, 0x74, 0x69, 0x76,\n        0x65, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x00,\n    };\n\n    ASSERT_THAT(p, ContainerEq(exp));\n  }\n\n  {\n    // Database set\n    mysql_protocol::HandshakeResponsePacket p(1, auth_response, \"ROUTERTEST\", \"\", \"router_db\");\n\n    std::vector<unsigned char> exp {\n        0x60, 0x00, 0x00, 0x01, 0x8d, 0xa2, 0x03, 0x00, 0x00, 0x00, 0x00, 0x40, 0x08, 0x00, 0x00, 0x00,\n        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n        0x00, 0x00, 0x00, 0x00, 0x52, 0x4f, 0x55, 0x54, 0x45, 0x52, 0x54, 0x45, 0x53, 0x54, 0x00, 0x14,\n        0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71,\n        0x71, 0x71, 0x71, 0x71, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x5f, 0x64, 0x62, 0x00, 0x6d, 0x79,\n        0x73, 0x71, 0x6c, 0x5f, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77,\n        0x6f, 0x72, 0x64, 0x00\n    };\n\n    ASSERT_THAT(p, ContainerEq(exp));\n  }\n\n  {\n    // Character set\n    mysql_protocol::HandshakeResponsePacket p(1, auth_response, \"ROUTERTEST\", \"\", \"router_db\", 80);\n\n    std::vector<unsigned char> exp {\n        0x60, 0x00, 0x00, 0x01, 0x8d, 0xa2, 0x03, 0x00, 0x00, 0x00, 0x00, 0x40, 0x50, 0x00, 0x00, 0x00,\n        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n        0x00, 0x00, 0x00, 0x00, 0x52, 0x4f, 0x55, 0x54, 0x45, 0x52, 0x54, 0x45, 0x53, 0x54, 0x00, 0x14,\n        0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71,\n        0x71, 0x71, 0x71, 0x71, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x5f, 0x64, 0x62, 0x00, 0x6d, 0x79,\n        0x73, 0x71, 0x6c, 0x5f, 0x6e, 0x61, 0x74, 0x69, 0x76, 0x65, 0x5f, 0x70, 0x61, 0x73, 0x73, 0x77,\n        0x6f, 0x72, 0x64, 0x00\n    };\n\n    ASSERT_THAT(p, ContainerEq(exp));\n  }\n\n  {\n    // Character set\n    mysql_protocol::HandshakeResponsePacket p(1, auth_response, \"ROUTERTEST\", \"\", \"router_db\", 8, \"router_auth_plugin\");\n\n    std::vector<unsigned char> exp {\n        0x5d, 0x00, 0x00, 0x01, 0x8d, 0xa2, 0x03, 0x00, 0x00, 0x00, 0x00, 0x40, 0x08, 0x00, 0x00, 0x00,\n        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n        0x00, 0x00, 0x00, 0x00, 0x52, 0x4f, 0x55, 0x54, 0x45, 0x52, 0x54, 0x45, 0x53, 0x54, 0x00, 0x14,\n        0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71, 0x71,\n        0x71, 0x71, 0x71, 0x71, 0x72, 0x6f, 0x75, 0x74, 0x65, 0x72, 0x5f, 0x64, 0x62, 0x00, 0x72, 0x6f,\n        0x75, 0x74, 0x65, 0x72, 0x5f, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e,\n        0x00,\n    };\n\n    ASSERT_THAT(p, ContainerEq(exp));\n  }\n}\n\n\n\n\n\nclass HandshakeResponseParseTest : public ::testing::Test {\n public:\n  void SetUp() override {}\n};\n\n/** @brief Converts string of hex values into bytes\n *\n * For example, supplied string like so \"11223344\" will yield an array containing\n * bytes {0x11, 0x22, 0x33, 0x44}. Spaces between bytes are ignored, so \"11 22     3344\"\n * is equivalent to the previous string. OTOH, spaces between hexadecimals of the\n * same byte are not allowed - \"1 1223344\" will throw an assertion.\n *\n * @param hex_text Input string with bytes written as hex\n * @return std::vector<uint32_t>\n */\nstd::vector<uint8_t> str2bytes(const std::string& hex_text) {\n\n  std::vector<uint8_t> result;\n  bool have_high_hex = false;\n\n  auto append = [&](uint8_t hex) {\n    assert (hex <= 15);\n\n    static uint8_t high_hex;\n\n    if (have_high_hex)\n      result.push_back(16 * high_hex + hex);\n    else\n      high_hex = hex;\n\n    have_high_hex = !have_high_hex;\n  };\n\n  for (const char c : hex_text) {\n    // allow spaces between bytes (sets of two hexadecimals)\n    if (c == ' ')\n      if (have_high_hex)\n        assert(0);  // don't allow <space> between high and low hexadecimals of the same byte\n      else\n        continue;\n\n    // append hexadecimal\n    else if ('0' <= c && c <= '9')\n      append(c - '0');\n    else if ('a' <= c && c <= 'f')\n      append(c - 'a' + 10);\n\n    // unrecognised token\n    else\n      assert(0);\n  }\n\n  return result;\n}\n\nconstexpr bool kAutoPayloadParse = true;\nconstexpr bool kNoPayloadParse = false;\n\n/**\n * @test So far we require PROTOCOL_41 to be spoken by both client and server\n */\nTEST_F(HandshakeResponseParseTest, server_does_not_support_PROTOCOL_41) {\n\n  EXPECT_THROW(\n    HandshakeResponsePacket({}, kAutoPayloadParse, Capabilities::ALL_ZEROS),\n    std::runtime_error\n  );\n}\n\n/**\n * @test Verify behavior on missing CLIENT_PROTOCOL_41 flag\n */\nTEST_F(HandshakeResponseParseTest, no_PROTOCOL_41) {\n\n  // EOF\n  {\n    // missing capability flags ------------------------vvvvvvvvv\n    std::vector<uint8_t> bytes = str2bytes(\"0000 0001            \");\n\n    EXPECT_THROW_LIKE(\n      HandshakeResponsePacket pkt(bytes, kAutoPayloadParse, Capabilities::PROTOCOL_41),\n      std::runtime_error, \"HandshakeResponsePacket: tried reading capability flags past EOF\"\n    );\n  }\n\n  // no PROTOCOL_41 capability flag\n  {\n    // Note that PROTOCOL_41 flag is stored in the first (low) 16 bits, thus providing\n    // the other 16 bits of flags is not required. Below we only provide those low 16 bits.\n\n    // the missing flag is here flag (0x0200) -------------v\n    std::vector<uint8_t> bytes = str2bytes(\"0200 0001   fffd\");\n\n    EXPECT_THROW_LIKE(\n      HandshakeResponsePacket pkt(bytes, kAutoPayloadParse, Capabilities::PROTOCOL_41),\n      std::runtime_error, \"Handshake response packet: Protocol is version 320, which is not implemented atm\"\n    );\n  }\n}\n\n/**\n * @test Verify behavior on bad payload count in header\n */\nTEST_F(HandshakeResponseParseTest, bad_payload_length) {\n\n  // bad payload length (should be 08) ---vv          <-- payload ---------->\n  std::vector<uint8_t> bytes = str2bytes(\"5500 0000   11 22 33 44   0000 0000\");\n\n  EXPECT_THROW_LIKE(\n    HandshakeResponsePacket pkt(bytes, kAutoPayloadParse, Capabilities::PROTOCOL_41),\n    std::runtime_error, \"Incorrect payload size (was 12; should be at least 85)\"\n  );\n}\n\n/**\n * @test Verify behavior on bad sequence number in the header\n */\nTEST_F(HandshakeResponseParseTest, bad_seq_number) {\n\n  // bad sequence nr (should be 01) -------------vv   <cap.flags>\n  std::vector<uint8_t> bytes = str2bytes(\"0800 0099   11 22 33 44   0000 0000\");\n\n  EXPECT_THROW_LIKE(\n    HandshakeResponsePacket pkt(bytes, kAutoPayloadParse, Capabilities::PROTOCOL_41),\n    std::runtime_error, \"Handshake response packet: sequence number different than 1\"\n  );\n}\n\n/**\n * @test Verify parsing of max packet size\n */\nTEST_F(HandshakeResponseParseTest, max_packet_size) {\n\n  constexpr size_t kOffset = 8;\n  constexpr size_t kLength = 4;\n\n  // EOF\n  {\n    // missing max packet size -------------------------------------vvvvvvvvv\n    std::vector<uint8_t> bytes = str2bytes(\"0000 0000   0002 0000            \");\n\n    HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n\n    HandshakeResponsePacket::Parser41 prs(pkt);\n    EXPECT_THROW_LIKE(\n      pkt.position_ = kOffset;\n      prs.part1_max_packet_size(),\n      std::runtime_error, \"start or end beyond EOF\"\n    );\n  }\n\n  // ok\n  {\n    //                                          max packet size --vvvvvvvvv\n    std::vector<uint8_t> bytes = str2bytes(\"0800 0000   0002 0000 0000 0040\");\n\n    HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n\n    HandshakeResponsePacket::Parser41 prs(pkt);\n    pkt.position_ = kOffset;\n    prs.part1_max_packet_size();\n    EXPECT_EQ(kOffset + kLength, pkt.position_);\n    EXPECT_EQ(0x40000000u, pkt.max_packet_size_);\n  }\n}\n\n/**\n * @test Verify parsing of character set\n */\nTEST_F(HandshakeResponseParseTest, character_set) {\n\n  constexpr size_t kOffset = 12;\n  constexpr size_t kLength = 1;\n\n  // EOF\n  {\n    // missing char set ----------------------------------------------------vv\n    std::vector<uint8_t> bytes = str2bytes(\"0000 0000   0000 0000 0000 0000   \");\n\n    HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n\n    HandshakeResponsePacket::Parser41 prs(pkt);\n    EXPECT_THROW_LIKE(\n      pkt.position_ = kOffset;\n      prs.part2_character_set(),\n      std::runtime_error, \"start or end beyond EOF\"\n    );\n  }\n\n  // ok\n  { //                                                           char set --vv\n    std::vector<uint8_t> bytes = str2bytes(\"0000 0000   0000 0000 0000 0000 42\");\n\n    HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n\n    HandshakeResponsePacket::Parser41 prs(pkt);\n    pkt.position_ = kOffset;\n    prs.part2_character_set();\n    EXPECT_EQ(kOffset + kLength, pkt.position_);\n    EXPECT_EQ(0x42u, pkt.char_set_);\n  }\n}\n\n/**\n * @test Verify parsing of 23 byte zero field\n */\nTEST_F(HandshakeResponseParseTest, reserved) {\n\n  constexpr size_t kOffset = 13;\n  constexpr size_t kLength = 23;\n\n  // EOF\n  {\n    std::vector<uint8_t> bytes = str2bytes(\"0000 0000   0000 0000 0000 0000 00\"\n        \"\" /* missing all 00 */);\n\n    HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n\n    HandshakeResponsePacket::Parser41 prs(pkt);\n    EXPECT_THROW_LIKE(\n      pkt.position_ = kOffset;\n      prs.part3_reserved(),\n      std::runtime_error, \"start or end beyond EOF\"\n    );\n  }\n\n  // reserved field is too short\n  {\n    std::vector<uint8_t> bytes = str2bytes(\"0000 0000   0000 0000 0000 0000 00\"\n        \"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\" /* missing one 00 */);\n\n    HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n\n    HandshakeResponsePacket::Parser41 prs(pkt);\n    EXPECT_THROW_LIKE(\n      pkt.position_ = kOffset;\n      prs.part3_reserved(),\n      std::runtime_error, \"start or end beyond EOF\"\n\n    );\n  }\n\n  // reserved field contains non-zeros\n  {\n    // each iteration sets a different byte of the 23-byte range to non-zero\n    for (size_t one = kOffset; one < kOffset + kLength; one++) {\n      std::vector<uint8_t> bytes = str2bytes(\"0000 0000   0000 0000 0000 0000 00\"\n          \"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\");\n      bytes[one] = 1;\n\n      HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n\n      HandshakeResponsePacket::Parser41 prs(pkt);\n      EXPECT_THROW_LIKE(\n      pkt.position_ = kOffset;\n        prs.part3_reserved(),\n        std::runtime_error, \"Handshake response packet: found non-zero value in reserved 23-byte field\"\n      );\n    }\n  }\n\n  // reserved field ok\n  {\n    std::vector<uint8_t> bytes = str2bytes(\"0000 0000   0000 0000 0000 0000 00\"\n        \"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\");\n\n    HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n\n    HandshakeResponsePacket::Parser41 prs(pkt);\n    pkt.position_ = kOffset;\n    prs.part3_reserved();\n    EXPECT_EQ(kOffset + kLength, pkt.position_);\n  }\n}\n\n/**\n * @test Verify parsing of user name\n */\nTEST_F(HandshakeResponseParseTest, username) {\n\n  const std::vector<uint8_t> bytes_before_username = str2bytes(\"0000 0000   0000 0000 0000 0000 00\"\n      \"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\");\n  const size_t kOffset = bytes_before_username.size();\n\n  // EOF\n  {\n    std::vector<uint8_t> bytes = bytes_before_username; // no username bytes follow\n\n    HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n\n    HandshakeResponsePacket::Parser41 prs(pkt);\n    EXPECT_THROW_LIKE(\n      pkt.position_ = kOffset;\n      prs.part4_username(),\n      std::runtime_error, \"start beyond EOF\"\n    );\n  }\n\n  // any non-zero chars will do, we only validate size\n  std::vector<uint8_t> username32 = str2bytes(\n      \"01020304050607080910 11121314151617181920 21222324252627282930 3132\");\n\n  // username missing zero-terminator\n  {\n    std::vector<uint8_t> bytes = bytes_before_username;\n    bytes.insert(bytes.end(), username32.begin(), username32.end());\n\n    HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n\n    HandshakeResponsePacket::Parser41 prs(pkt);\n    EXPECT_THROW_LIKE(\n      pkt.position_ = kOffset;\n      prs.part4_username(),\n      std::runtime_error, \"zero-terminator not found\"\n    );\n  }\n\n  // username ok\n  {\n    std::vector<uint8_t> bytes = bytes_before_username;\n    bytes.insert(bytes.end(), username32.begin(), username32.end());\n    bytes.push_back(0);   // terminator\n\n    HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n\n    HandshakeResponsePacket::Parser41 prs(pkt);\n    pkt.position_ = kOffset;\n    prs.part4_username();\n    EXPECT_EQ(kOffset + username32.size() + 1, pkt.position_);\n    EXPECT_EQ(std::string(username32.begin(), username32.end()), pkt.username_);\n  }\n}\n\n/**\n * @test Verify parsing of auth response (partial implementation)\n */\nTEST_F(HandshakeResponseParseTest, auth_response) {\n\n  const std::vector<uint8_t> bytes_before_auth_response = str2bytes(\"0000 0000   0000 0000 0000 0000 00\"\n      \"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\"\n      \"11 22 33 44 00\" /* username */);\n  const size_t kOffset = bytes_before_auth_response.size();\n\n  // EOF\n  {\n    std::vector<uint8_t> bytes = bytes_before_auth_response; // no auth-response bytes follow\n\n    for (Capabilities::Flags flags : {\n        Capabilities::PROTOCOL_41 | Capabilities::PLUGIN_AUTH_LENENC_CLIENT_DATA,\n        Capabilities::PROTOCOL_41 | Capabilities::SECURE_CONNECTION,\n    }) {\n\n      HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n\n      HandshakeResponsePacket::Parser41 prs(pkt);\n      prs.effective_capability_flags_ = flags;\n      EXPECT_THROW_LIKE(\n        pkt.position_ = kOffset;\n        prs.part5_auth_response(),\n        std::runtime_error, \"beyond EOF\"  // can be \"start beyond EOF\" or \"start or end beyond EOF\"\n      );\n\n    }\n  }\n\n  // unsupported capability flags : both PLUGIN_AUTH_LENENC_CLIENT_DATA and SECURE_CONNECTION missing\n  {\n    std::vector<uint8_t> bytes = bytes_before_auth_response;\n    bytes.push_back(0); // what value we add doesn't matter for this test\n\n    HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n\n    HandshakeResponsePacket::Parser41 prs(pkt);\n    EXPECT_THROW_LIKE(\n      pkt.position_ = kOffset;\n      prs.part5_auth_response(),\n      std::runtime_error, \"Handshake response packet: capabilities PLUGIN_AUTH_LENENC_CLIENT_DATA and SECURE_CONNECTION both missing is not implemented atm\"\n    );\n  }\n\n  // PLUGIN_AUTH_LENENC_CLIENT_DATA : ok\n  {\n    std::vector<uint8_t> bytes = bytes_before_auth_response;\n    std::vector<uint8_t> auth_response{0x11, 0x22, 0x00, 0x33, 0x00};\n\n    HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n    pkt.seek(pkt.size());\n    size_t uint_len = pkt.write_lenenc_uint(auth_response.size());\n    pkt.write_bytes(auth_response);\n\n    HandshakeResponsePacket::Parser41 prs(pkt);\n    prs.effective_capability_flags_ = Capabilities::PLUGIN_AUTH_LENENC_CLIENT_DATA;\n    pkt.position_ = kOffset;\n    prs.part5_auth_response();\n    EXPECT_EQ(kOffset + auth_response.size() + uint_len, pkt.position_);\n    EXPECT_EQ(auth_response, pkt.auth_response_);\n  }\n\n  // SECURE_CONNECTION : ok\n  {\n    std::vector<uint8_t> bytes = bytes_before_auth_response;\n    std::vector<uint8_t> auth_response{0x11, 0x22, 0x00, 0x33, 0x00};\n\n    HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n    pkt.seek(pkt.size());\n    pkt.write_int<uint8_t>(auth_response.size());\n    pkt.write_bytes(auth_response);\n\n    HandshakeResponsePacket::Parser41 prs(pkt);\n    prs.effective_capability_flags_ = Capabilities::SECURE_CONNECTION;\n    pkt.position_ = kOffset;\n    prs.part5_auth_response();\n    EXPECT_EQ(kOffset + auth_response.size() + 1, pkt.position_);\n    EXPECT_EQ(auth_response, pkt.auth_response_);\n  }\n}\n\n/**\n * @test Verify parsing of database name\n */\nTEST_F(HandshakeResponseParseTest, database) {\n\n  const std::vector<uint8_t> bytes_before_database = str2bytes(\"0000 0000   0000 0000 0000 0000 00\"\n      \"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\" /* reserved 23 bytes */\n      \"11 22 33 44 00\" /* username */   \"00\" /* auth response */);\n  const size_t kOffset = bytes_before_database.size();\n  constexpr Capabilities::Flags flags = Capabilities::CONNECT_WITH_DB;\n\n  // capability flag not set\n  {\n    std::vector<uint8_t> bytes = bytes_before_database;\n    bytes.push_back(0); // terminator\n\n    HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n\n    HandshakeResponsePacket::Parser41 prs(pkt);\n    pkt.position_ = kOffset;\n    prs.part6_database();\n    EXPECT_EQ(kOffset, pkt.position_);\n    EXPECT_EQ(std::string(\"\"), pkt.database_);\n  }\n\n  // EOF\n  {\n    std::vector<uint8_t> bytes = bytes_before_database; // no database bytes follow\n\n    HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n\n    HandshakeResponsePacket::Parser41 prs(pkt);\n    prs.effective_capability_flags_ = flags;\n    EXPECT_THROW_LIKE(\n      pkt.position_ = kOffset;\n      prs.part6_database(),\n      std::runtime_error, \"start beyond EOF\"\n    );\n  }\n\n  // any non-zero chars will do, we only validate size\n  std::vector<uint8_t> database = str2bytes(\n      \"01020304050607080910 11121314151617181920 21222324252627282930\"\n      \"31323334353637383940 41424344454647484950 51525354555657585960 61626364\");\n\n  // database missing zero-terminator\n  {\n    std::vector<uint8_t> bytes = bytes_before_database;\n    bytes.insert(bytes.end(), database.begin(), database.end());\n\n    HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n\n    HandshakeResponsePacket::Parser41 prs(pkt);\n    prs.effective_capability_flags_ = flags;\n    EXPECT_THROW_LIKE(\n      pkt.position_ = kOffset;\n      prs.part6_database(),\n      std::runtime_error, \"zero-terminator not found\"\n    );\n  }\n\n  // database ok\n  {\n    std::vector<uint8_t> bytes = bytes_before_database;\n    bytes.insert(bytes.end(), database.begin(), database.end());\n    bytes.push_back(0);   // terminator\n\n    HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n\n    HandshakeResponsePacket::Parser41 prs(pkt);\n    prs.effective_capability_flags_ = flags;\n    pkt.position_ = kOffset;\n    prs.part6_database();\n    EXPECT_EQ(kOffset + database.size() + 1, pkt.position_);\n    EXPECT_EQ(std::string(database.begin(), database.end()), pkt.database_);\n  }\n}\n\n/**\n * @test Verify parsing of auth plugin name\n */\nTEST_F(HandshakeResponseParseTest, auth_plugin) {\n\n  const std::vector<uint8_t> bytes_before_auth_plugin = str2bytes(\"0000 0000   0000 0000 0000 0000 00\"\n      \"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\" /* reserved 23 bytes */\n      \"11 22 33 44 00\" /* username */   \"00\" /* auth response */   \"\" /* database */);\n  const size_t kOffset = bytes_before_auth_plugin.size();\n  constexpr Capabilities::Flags flags = Capabilities::PLUGIN_AUTH;\n\n  // capability flag not set\n  {\n    std::vector<uint8_t> bytes = bytes_before_auth_plugin;\n    bytes.push_back(0); // terminator\n\n    HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n\n    HandshakeResponsePacket::Parser41 prs(pkt);\n    pkt.position_ = kOffset;\n    prs.part7_auth_plugin();\n    EXPECT_EQ(kOffset, pkt.position_);\n    EXPECT_EQ(std::string(\"\"), pkt.auth_plugin_);\n  }\n\n  // EOF\n  {\n    std::vector<uint8_t> bytes = bytes_before_auth_plugin; // no auth plugin name bytes follow\n\n    HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n\n    HandshakeResponsePacket::Parser41 prs(pkt);\n    prs.effective_capability_flags_ = flags;\n    EXPECT_THROW_LIKE(\n      pkt.position_ = kOffset;\n      prs.part7_auth_plugin(),\n      std::runtime_error, \"start beyond EOF\"\n    );\n  }\n\n  // any non-zero chars will do, we only validate size\n  std::vector<uint8_t> auth_plugin = str2bytes(\n      \"01020304050607080910 11121314151617181920 21222324252627282930\"\n      \"31323334353637383940 41424344454647484950 51525354555657585960 61626364\");\n\n  // auth plugin missing zero-terminator\n  {\n    std::vector<uint8_t> bytes = bytes_before_auth_plugin;\n    bytes.insert(bytes.end(), auth_plugin.begin(), auth_plugin.end());\n\n    HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n\n    HandshakeResponsePacket::Parser41 prs(pkt);\n    prs.effective_capability_flags_ = flags;\n    EXPECT_THROW_LIKE(\n      pkt.position_ = kOffset;\n      prs.part7_auth_plugin(),\n      std::runtime_error, \"zero-terminator not found\"\n    );\n  }\n\n  // auth plugin name ok\n  {\n    std::vector<uint8_t> bytes = bytes_before_auth_plugin;\n    bytes.insert(bytes.end(), auth_plugin.begin(), auth_plugin.end());\n    bytes.push_back(0);   // terminator\n\n    HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n\n    HandshakeResponsePacket::Parser41 prs(pkt);\n    prs.effective_capability_flags_ = flags;\n    pkt.position_ = kOffset;\n    prs.part7_auth_plugin();\n    EXPECT_EQ(kOffset + auth_plugin.size() + 1, pkt.position_);\n    EXPECT_EQ(std::string(auth_plugin.begin(), auth_plugin.end()), pkt.auth_plugin_);\n  }\n}\n\n/**\n * @test Verify parsing of connection attributes (unimplemented atm)\n */\nTEST_F(HandshakeResponseParseTest, connection_attrs) {\n\n  const std::vector<uint8_t> bytes_before_connection_attrs = str2bytes(\"0000 0000   0000 0000 0000 0000 00\"\n      \"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\" /* reserved 23 bytes */\n      \"11 22 33 44 00\" /* username */   \"00\" /* auth response */\n      \"\" /* database */   \"\" /* auth plugin name */);\n  const size_t kOffset = bytes_before_connection_attrs.size();\n  constexpr Capabilities::Flags flags = Capabilities::CONNECT_ATTRS;\n\n  // CONNECT_ATTRS is not implemented atm\n  {\n    std::vector<uint8_t> bytes = bytes_before_connection_attrs;\n\n    HandshakeResponsePacket pkt(bytes, kNoPayloadParse);\n\n    HandshakeResponsePacket::Parser41 prs(pkt);\n    prs.effective_capability_flags_ = flags;\n    EXPECT_THROW_LIKE(\n      pkt.position_ = kOffset;\n      prs.part8_connection_attrs(),\n      std::runtime_error, \"Handshake response packet: capability CONNECT_ATTRS is not implemented atm\"\n    );\n  }\n}\n\n/**\n * @test A complete test that verifies parsing of everything we support in one shot\n */\nTEST_F(HandshakeResponseParseTest, all) {\n\n  ////////////////////////////////////////////////////////////////////////////////\n  //\n  //  Packet format is as follows:\n  //\n  //    4              capability flags, CLIENT_PROTOCOL_41 always set\n  //    4              max-packet size\n  //    1              character set\n  //    string[23]     reserved (all [0])\n  //    string[NUL]    username\n  //\n  //    if capabilities & CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA {\n  //      lenenc-int     length of auth-response\n  //      string[n]      auth-response\n  //    } else if capabilities & CLIENT_SECURE_CONNECTION {\n  //      1              length of auth-response\n  //      string[n]      auth-response\n  //    } else {\n  //      string[NUL]    auth-response\n  //    }\n  //\n  //    if capabilities & CLIENT_CONNECT_WITH_DB {\n  //      string[NUL]    database\n  //    }\n  //\n  //    if capabilities & CLIENT_PLUGIN_AUTH {\n  //      string[NUL]    auth plugin name\n  //    }\n  //\n  //    if capabilities & CLIENT_CONNECT_ATTRS {\n  //      lenenc-int     length of all key-values\n  //      lenenc-str     key\n  //      lenenc-str     value\n  //      if-more data in 'length of all key-values', more keys and value pairs\n  //    }\n  //\n  ////////////////////////////////////////////////////////////////////////////////\n\n  // below fields are in order of appearance in the packet\n  const uint8_t seq_id = 1;\n  Capabilities::Flags cap_flags = Capabilities::PROTOCOL_41 |\n                                  Capabilities::PLUGIN_AUTH_LENENC_CLIENT_DATA |\n                                  Capabilities::CONNECT_WITH_DB |\n                                  Capabilities::PLUGIN_AUTH;\n  // static fields\n  const uint32_t max_packet_size = 0x12345678;\n  const uint8_t char_set = 0x42;\n  /* reserved 23 zero bytes - no variable needed for this one */\n  const std::string username = \"some_user\";\n\n  // conditional fields              v-- length of following bytes\n  std::vector<uint8_t> auth_response{5, 0x11, 0x22, 0x00, 0x33, 0x00};\n  const std::string database = \"some_database\";\n  const std::string auth_plugin = \"some_auth_plugin\";\n\n  std::vector<uint8_t> bytes;\n\n  // construct packet content\n  {\n    auto bytes_push_back_uint32 = [&bytes](uint32_t value) {\n      for (size_t i = 0; i < sizeof(uint32_t); i++) {\n        bytes.push_back(value & 0xff);\n        value >>= CHAR_BIT;\n      }\n    };\n\n    // add header\n    bytes.insert(bytes.end(), 3, 0);  // payload size placeholder\n    bytes.push_back(seq_id);\n\n    // add capability flags\n    bytes_push_back_uint32(cap_flags.bits());\n\n    // add static fields\n    bytes_push_back_uint32(max_packet_size);\n    bytes.push_back(char_set);\n    bytes.insert(bytes.end(), 23, 0);\n    bytes.insert(bytes.end(), username.begin(), username.end());\n    bytes.insert(bytes.end(), 0); // username zero-terminator\n\n    // add conditional fields\n    bytes.insert(bytes.end(), auth_response.begin(), auth_response.end());\n    bytes.insert(bytes.end(), database.begin(), database.end());\n    bytes.insert(bytes.end(), 0); // database zero-terminator\n    bytes.insert(bytes.end(), auth_plugin.begin(), auth_plugin.end());\n    bytes.insert(bytes.end(), 0); // auth_plugin zero-terminator\n\n    // update payload counter\n    assert(bytes.size() < 251);   // ensure that size can be encoded in a single byte\n    bytes[0] = bytes.size() - 4;  // -4 because header doesn't count\n  }\n\n  // construct packet\n  HandshakeResponsePacket pkt(bytes, kAutoPayloadParse, Capabilities::ALL_ONES);\n\n  // verify that fields parsed correctly\n  {\n    // header\n    EXPECT_EQ(bytes.size(), pkt.size());\n    EXPECT_EQ(seq_id, pkt.sequence_id_);\n\n    // capability flags\n    EXPECT_EQ(cap_flags, pkt.capability_flags_);\n\n    // static fields\n    EXPECT_EQ(max_packet_size, pkt.max_packet_size_);\n    EXPECT_EQ(char_set, pkt.char_set_);\n    EXPECT_EQ(username, pkt.username_);\n\n    // conditional fields\n    auth_response.erase(auth_response.begin()); // erase string-length byte\n    EXPECT_EQ(auth_response, pkt.auth_response_);\n    EXPECT_EQ(database, pkt.database_);\n    EXPECT_EQ(auth_plugin, pkt.auth_plugin_);\n  }\n}\n\n"
  },
  {
    "path": "src/plugin_info/CMakeLists.txt",
    "content": "# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nfile(GLOB_RECURSE sources ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc)\ninclude_directories(${CMAKE_BINARY_DIR}/include)\nadd_executable(mysqlrouter_plugin_info ${sources})\n\n# Implementation files that include RapidJSON headers.\n# Used to supress warnings for those.\nset(json_sources src/plugin.cc)\ncheck_cxx_compiler_flag(\"-Wshadow\" HAVE_SHADOW)\nif(HAVE_SHADOW)\n  add_compile_flags(${json_sources} COMPILE_FLAGS \"-Wno-shadow\")\nendif()\ncheck_cxx_compiler_flag(\"-Werror\" HAVE_ERROR)\nIF(HAVE_ERROR)\n  add_compile_flags(${json_sources} COMPILE_FLAGS \"-Wno-error\")\nENDIF()\ncheck_cxx_compiler_flag(\"-Wconversion\" HAVE_CONVERSION)\nIF(HAVE_CONVERSION)\n  add_compile_flags(${json_sources} COMPILE_FLAGS \"-Wno-conversion\")\nENDIF()\ncheck_cxx_compiler_flag(\"-Wpedantic\" HAVE_PEDANTIC)\nIF(HAVE_PEDANTIC)\n  add_compile_flags(${json_sources} COMPILE_FLAGS \"-Wno-pedantic\")\nENDIF()\n\nset(common_libraries)\nif(WIN32)\n  # we nedd harness for Path only on Windows\n  list(APPEND common_libraries harness-library)\nendif()\n\ntarget_link_libraries(mysqlrouter_plugin_info ${common_libraries} ${CMAKE_DL_LIBS})\n\nif(EXISTS \"${CMAKE_SOURCE_DIR}/extra/rapidjson/\")\n  # prefer server-side rapidjson\n  SET(RAPIDJSON_INCLUDE_DIRS \"${CMAKE_SOURCE_DIR}/extra/rapidjson/include/\")\nelse()\n  SET(RAPIDJSON_INCLUDE_DIRS \"${MySQLRouter_SOURCE_DIR}/ext/rapidjson/include/\")\nendif()\n\ntarget_include_directories(mysqlrouter_plugin_info PUBLIC ${RAPIDJSON_INCLUDE_DIRS})\n\nset_target_output_directory(mysqlrouter_plugin_info RUNTIME_OUTPUT_DIRECTORY bin)\n\ninstall(TARGETS mysqlrouter_plugin_info\n        RUNTIME DESTINATION ${INSTALL_BINDIR})\n\nif(WIN32)\n  install(FILES $<TARGET_PDB_FILE:mysqlrouter_plugin_info>\n        DESTINATION ${INSTALL_BINDIR})\nendif()\n\nif(ENABLE_TESTS)\n  enable_testing()\n  add_subdirectory(tests/)\nendif()\n"
  },
  {
    "path": "src/plugin_info/src/library_file.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"library_file.h\"\n\n#ifndef _WIN32\n#include <dlfcn.h>\n#include <unistd.h>\n#else\n#include <Windows.h>\n#include \"mysql/harness/filesystem.h\"\n#endif\n\n#define USE_DLCLOSE 1\n\n// disable dlclose() when built with lsan\n//\n// clang has __has_feature(address_sanitizer)\n// gcc has __SANITIZE_ADDRESS__\n#if defined(__has_feature)\n  #if __has_feature(address_sanitizer)\n#undef USE_DLCLOSE\n#define USE_DLCLOSE 0\n  #endif\n#endif\n\n#if defined(__SANITIZE_ADDRESS__) && __SANITIZE_ADDRESS__ == 1\n#undef USE_DLCLOSE\n#define USE_DLCLOSE 0\n#endif\n\nstruct Library_file::Library_file_impl {\n#ifndef _WIN32\n  void* handle;\n#else\n  HMODULE handle;\n#endif\n};\n\n#ifdef _WIN32\nnamespace {\nvoid throw_current_error(const std::string& prefix) {\n  char buffer[512];\n  FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_MAX_WIDTH_MASK,\n    nullptr, GetLastError(),\n    LANG_NEUTRAL, buffer, sizeof(buffer), nullptr);\n  throw std::runtime_error(prefix + buffer);\n}\n}\n#endif\n\nLibrary_file::Library_file(const std::string &file_name, const std::string &plugin_name):\n                impl_(new Library_file_impl()),\n                plugin_name_(plugin_name),\n                file_name_(file_name) {\n#ifndef _WIN32\n  impl_->handle = dlopen(file_name.c_str(), RTLD_LOCAL | RTLD_LAZY);\n  if (impl_->handle == nullptr) {\n    throw std::runtime_error(\"Could not load plugin file: \" + file_name + \". Error: \" + dlerror());\n  }\n#else\n  mysql_harness::Path lib_file(file_name);\n  // we need to do this so all the dlls that plugin library needs could be found\n  auto res = SetCurrentDirectory(lib_file.dirname().c_str());\n  if (!res) {\n    throw_current_error(\"Could not switch directory to \" + lib_file.dirname().str() + \": \");\n  }\n  impl_->handle = LoadLibrary(lib_file.real_path().c_str());\n  if (impl_->handle == nullptr) {\n    throw_current_error(\"Could not load plugin file: \" + file_name + \". \");\n  }\n#endif\n}\n\nuint32_t Library_file::get_abi_version() const {\n  Plugin_abi*plugin = get_plugin_struct<Plugin_abi>(plugin_name_);\n\n  return plugin->abi_version;\n}\n\ntemplate <class T>\nT* Library_file::get_plugin_struct(const std::string &symbol) const {\n  // In the older MySQLRouter releases some plugins did not use harness_plugin_ prefix for\n  // the plugin structure name.\n  // So we check harness_plugin_xxx and then xxx if the first check failed.\n\n  T* result{nullptr};\n  try {\n    result = get_plugin_struct_internal<T>(\"harness_plugin_\" + symbol);\n  }\n  catch (const std::runtime_error&) {\n    result = get_plugin_struct_internal<T>(plugin_name_);\n  }\n\n  return result;\n}\n\ntemplate <class T>\nT* Library_file::get_plugin_struct_internal(const std::string &symbol) const {\n  T* result{nullptr};\n\n#ifndef _WIN32\n  result = reinterpret_cast<T*>(dlsym(impl_->handle, symbol.c_str()));\n  const char* error = dlerror();\n  if (error) {\n    throw  std::runtime_error(\"Loading plugin information for '\" + file_name_\n      + \"' failed: \" + error);\n  }\n#else\n  SetLastError(0);\n  result = reinterpret_cast<T*>(GetProcAddress(impl_->handle, symbol.c_str()));\n  DWORD error = GetLastError();\n  if (error) {\n    throw_current_error(\"Loading plugin information for '\" + file_name_ + \"' failed: \");\n  }\n#endif\n\n  return result;\n}\n\ntemplate Plugin_abi* Library_file::get_plugin_struct<Plugin_abi>(const std::string&) const;\ntemplate Plugin_v1* Library_file::get_plugin_struct<Plugin_v1>(const std::string&) const;\ntemplate Plugin_abi* Library_file::get_plugin_struct_internal<Plugin_abi>(const std::string&) const;\ntemplate Plugin_v1* Library_file::get_plugin_struct_internal<Plugin_v1>(const std::string&) const;\n\nLibrary_file::~Library_file() {\n  // disable dlclose() if run with address sanitizer to get good memleak reports\n#if USE_DLCLOSE\n#ifndef _WIN32\n  if (impl_->handle)\n    dlclose(impl_->handle);\n#else\n  if (impl_->handle) {\n    FreeLibrary(impl_->handle);\n  }\n#endif\n#endif\n}\n"
  },
  {
    "path": "src/plugin_info/src/library_file.h",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_PLUGIN_INFO_PLUGIN_FILE_INCLUDED\n#define MYSQLROUTER_PLUGIN_INFO_PLUGIN_FILE_INCLUDED\n\n#include <memory>\n#include <string>\n\n#include \"plugin.h\"\n\n/** @class Library_file\n *\n * @brief Abstraction over the plugin library file, hides system specific\n *        dynamic library handling.\n *\n **/\nclass Library_file {\npublic:\n  /** @brief Constructor\n   *\n   * @param file_name   path to the plugin file on the filesystem\n   * @param plugin_name name of the plugin (has to match name of the exported Plugin struct)\n   **/\n  explicit Library_file(const std::string &file_name,\n                        const std::string &plugin_name);\n\n  /** @brief Returns ABI version of the plugin represented by the object.\n   **/\n  uint32_t get_abi_version() const;\n\n  /** @brief Returns version specific Plugin struct of the plugin.\n   *         Specified by the caller through the template parameter.\n   *\n   * @param symbol name of the struct symbol\n   *\n   **/\n  template <class T>\n  T* get_plugin_struct(const std::string& symbol) const;\n\n  /** @brief Destructor\n   **/\n  ~Library_file();\n\nprivate:\n  struct Library_file_impl;\n  std::unique_ptr<Library_file_impl> impl_;\n\n  template <class T>\n  T* get_plugin_struct_internal(const std::string& symbol) const;\n\n  const std::string plugin_name_;\n  const std::string file_name_;\n};\n\n#endif\n"
  },
  {
    "path": "src/plugin_info/src/main.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <iostream>\n#include \"plugin_info_app.h\"\n\n\nint main(int argc, char* argv[]) {\n  Plugin_info_app plugin_info_app(argc, (const char**)argv, std::cout, std::cerr);\n\n  return plugin_info_app.run();\n}\n"
  },
  {
    "path": "src/plugin_info/src/plugin.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"plugin.h\"\n\n#include <iterator>\n#include <sstream>\n\n#ifdef RAPIDJSON_NO_SIZETYPEDEFINE\n// if we build within the server, it will set RAPIDJSON_NO_SIZETYPEDEFINE globally\n// and require to include my_rapidjson_size_t.h\n#include \"my_rapidjson_size_t.h\"\n#endif\n\n#include \"rapidjson/prettywriter.h\"\n#include \"rapidjson/stringbuffer.h\"\n\nPlugin_info::Plugin_info(const Plugin_v1& plugin):\n            abi_version(plugin.abi_version),\n            arch_descriptor(plugin.arch_descriptor ? plugin.arch_descriptor : \"\"),\n            brief(plugin.brief ? plugin.brief : \"\"),\n            plugin_version(plugin.plugin_version) {\n  copy_to_list(requires, plugin.requires, plugin.requires_length);\n  copy_to_list(conflicts, plugin.conflicts, plugin.conflicts_length);\n}\n\n\nstd::string Plugin_info::get_abi_version_str(uint32_t ver) {\n  return std::to_string(ABI_VERSION_MAJOR(ver)) + \".\"\n         + std::to_string(ABI_VERSION_MINOR(ver));\n}\n\nstd::string Plugin_info::get_plugin_version_str(uint32_t ver) {\n  return std::to_string(VERSION_MAJOR(ver)) + \".\"\n         + std::to_string(VERSION_MINOR(ver)) + \".\"\n         + std::to_string(VERSION_PATCH(ver));\n}\n\nvoid Plugin_info::copy_to_list(std::list<std::string>& out_list,\n                               const char** in_list,\n                               size_t in_list_size) {\n  std::copy(in_list, in_list + in_list_size, std::back_inserter(out_list));\n}\n\nvoid Plugin_info::print_as_json(std::ostream& out_stream) const {\n  rapidjson::StringBuffer buff;\n  rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buff);\n  writer.StartObject();\n\n  writer.Key(\"abi-version\");\n  std::string abi_version_str = get_abi_version_str(abi_version);\n  writer.String(abi_version_str.c_str());\n\n  writer.Key(\"arch-descriptor\");\n  writer.String(arch_descriptor.c_str());\n\n  writer.Key(\"brief\");\n  writer.String(brief.c_str());\n\n  writer.Key(\"plugin-version\");\n  std::string plugin_version_str = get_plugin_version_str(plugin_version);\n  writer.String(plugin_version_str.c_str());\n\n  writer.Key(\"requires\");\n  writer.StartArray();\n  for (const auto& i: requires)\n      writer.String(i.c_str());\n  writer.EndArray();\n\n  writer.Key(\"conflicts\");\n  writer.StartArray();\n  for (const auto& i: conflicts)\n      writer.String(i.c_str());\n  writer.EndArray();\n\n  writer.EndObject();\n\n  out_stream << buff.GetString();\n}\n\nstd::ostream& operator<<(std::ostream& stream, const Plugin_info& plugin_info) {\n  plugin_info.print_as_json(stream);\n  return stream;\n}\n"
  },
  {
    "path": "src/plugin_info/src/plugin.h",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_PLUGIN_INFO_PLUGIN_INCLUDED\n#define MYSQLROUTER_PLUGIN_INFO_PLUGIN_INCLUDED\n\n#include <iostream>\n#include <list>\n\n// we duplicate the Plugin struct here to have the history of the potential changes\n// but we still include this one for VERSION_ macros\n#include \"mysql/harness/plugin.h\"\n\n/** @struct Plugin_abi\n *\n * @brief The assumend and expected beginning of each version of Plugin struct\n *\n **/\nstruct Plugin_abi {\n  uint32_t abi_version;\n};\n\n/** @struct Plugin_v1\n *\n * @brief Data fields of the first version of the Plugin struct.\n *        Whenever this changes, add a new struct (callded vX) here,\n *        respective contructor to Plugin_info and its handling\n *\n **/\nstruct Plugin_v1 {\n  uint32_t abi_version;\n\n  const char* arch_descriptor;\n  const char *brief;\n  uint32_t plugin_version;\n\n  size_t requires_length;\n  const char **requires;\n\n  size_t conflicts_length;\n  const char **conflicts;\n\n  /* some function pointers follow; we are not really interested in those and we\n    don't want to be dependent on their types/arguments so we skip them here */\n};\n\n/** @class Plugin_info\n *\n * @brief Version independent plugin data storage, defines conversion from\n *        existing versions and enables writing the data as a JSON text.\n *\n **/\nclass Plugin_info {\n public:\n  /** @brief Constructor\n   *\n   * @param plugin contructor from v1 of Plugin struct\n   **/\n  explicit Plugin_info(const Plugin_v1& plugin);\n\n  /** @brief prints the JSON representation of the Plugin_info object to the\n   *         selected output stream\n   *\n   **/\n  friend std::ostream& operator<<(std::ostream& stream, const Plugin_info& plugin_info);\n\n  /** @brief converts ABI version integer to string representation\n   *\n   * @param ver integer representation to convert\n   **/\n  static std::string get_abi_version_str(uint32_t ver);\n\n  /** @brief converts plugin version integer to string representation\n   *\n   * @param ver integer representation to convert\n   **/\n  static std::string get_plugin_version_str(uint32_t ver);\n\n private:\n  static void copy_to_list(std::list<std::string>& out_list,\n                    const char** in_list,\n                    size_t in_list_size);\n\n  void print_as_json(std::ostream& out_stream) const;\n\n  uint32_t abi_version;\n\n  std::string arch_descriptor;\n  std::string brief;\n  uint32_t plugin_version;\n\n  std::list<std::string> requires;\n  std::list<std::string> conflicts;\n};\n\n#endif\n"
  },
  {
    "path": "src/plugin_info/src/plugin_info_app.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"plugin_info_app.h\"\n#include \"library_file.h\"\n\n#include \"router_config.h\"\n\nPlugin_info_app::Plugin_info_app(int argc,\n                                 const char** argv,\n                                 std::ostream& out_stream,\n                                 std::ostream& out_stream_err):\n                    argc_(argc), argv_(argv),\n                    out_stream_(out_stream),\n                    out_stream_err_(out_stream_err)\n{}\n\nint Plugin_info_app::run() {\n  if (argc_ == 2) {\n    std::string command = argv_[1];\n    if (command == \"--help\") {\n      print_usage(argv_[0]);\n      return 0;\n    }\n\n    if (command == \"--version\") {\n      print_version();\n      return 0;\n    }\n  }\n\n  if (argc_ != 3) {\n    print_usage(argv_[0]);\n    return -1;\n  }\n\n  const std::string file_name = argv_[1];\n  const std::string plugin_name = argv_[2];\n\n  try {\n    Library_file plugin_file(file_name, plugin_name);\n    uint32_t abi_version = plugin_file.get_abi_version();\n\n    if (abi_version > mysql_harness::PLUGIN_ABI_VERSION) {\n      throw std::runtime_error(\"Unsupported plugin ABI version: \"\n                               + Plugin_info::get_abi_version_str(abi_version));\n    }\n\n    // all the other versions so far have the same structure from our perspective\n    Plugin_v1* plugin = plugin_file.get_plugin_struct<Plugin_v1>(plugin_name);\n    Plugin_info plugin_info(*plugin);\n    out_stream_ << plugin_info << std::endl;\n  }\n  catch (std::runtime_error& err) {\n    out_stream_err_ << err.what() << std::endl;\n    return -1;\n  }\n\n  return 0;\n}\n\nvoid Plugin_info_app::print_usage(const char* exec_name) {\n  out_stream_err_ << \"Usage:\" << std::endl;\n  out_stream_err_ << \"\\t\" << exec_name << \" <mysqlrouter_plugin_file> <mysql_plugin_name>\" << std::endl;\n  out_stream_err_ << \"Example:\" << std::endl;\n#ifndef _WIN32\n  out_stream_err_ << \"\\t\" << exec_name << \" /usr/lib/mysqlrouter/routing.so routing\" << std::endl;\n#else\n  out_stream_err_ << \"\\t\" << exec_name << \" \\\"c:\\\\Program Files (x86)\\\\MySQL\\\\MySQL Router 2.1\\\\lib\\\\routing.dll\\\" routing\" << std::endl;\n#endif\n  out_stream_err_ << \"To print help information:\" << std::endl;\n  out_stream_err_ << \"\\t\" << exec_name << \" --help\" << std::endl;\n  out_stream_err_ << \"To print application version:\" << std::endl;\n  out_stream_err_ << \"\\t\" << exec_name << \" --version\" << std::endl;\n}\n\nvoid Plugin_info_app::print_version() {\n  out_stream_err_ << kPluginInfoAppName << \" \"\n                  << MYSQL_ROUTER_VERSION << std::endl; // we use the same version as MySQLRouter\n}\n"
  },
  {
    "path": "src/plugin_info/src/plugin_info_app.h",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_PLUGIN_INFO_APP_INCLUDED\n#define MYSQLROUTER_PLUGIN_INFO_APP_INCLUDED\n\n#include <ostream>\n\n// name displayed with --version request\nconst std::string kPluginInfoAppName = \"MySQLRouter Plugin Info App\";\n\n/** @class Plugin_info\n *\n * @brief Application class, enables testing of the application through the\n *        selecting input parameters and regular and error outputs.\n *\n **/\nclass Plugin_info_app final {\n public:\n  /** Constructor.\n   *\n   * @brief Normal application operation exepcts 3 parameters:\n   *        {app_name} {path_to_plugin_file} {plugin_name}\n   *        This retrieves the data read from the plugin file to the output stream.\n   *\n   *        Other supported options are:\n   *        {app_name} --help     outputs application usage to the error stream\n   *        {app_name} --version  outputs application version to the error stream\n   *\n   * @param argc number of parameters passed to the application\n   * @param argv array of the parameters passed to the applications\n   *        NOTE: the first parameter is expected to be application file name as in\n   *              c and c++ main() convention\n   * @param out_stream      Output stream for the data printed by the application\n   * @param out_stream_err  Output stream for the error data printed by the application\n   *\n   **/\n  Plugin_info_app(int argc,\n                  const char** argv,\n                  std::ostream& out_stream,\n                  std::ostream& out_stream_err);\n\n  /**\n   * @brief Executes the action requested from the application with the parameters\n   *        passed to the contructor. Redirects the output to the streams provided\n   *        to the constructor.\n   *\n   * @returns 0 on success, -1 if an error occured.\n   **/\n  int run();\n private:\n  void print_usage(const char* exec_name);\n  void print_version();\n\n  const int argc_;\n  const char** const argv_;\n\n  std::ostream& out_stream_;\n  std::ostream& out_stream_err_;\n};\n\n#endif\n"
  },
  {
    "path": "src/plugin_info/tests/CMakeLists.txt",
    "content": "# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nset(PLUGIN_INFO_SOURCES\n  ${CMAKE_CURRENT_SOURCE_DIR}/../src/plugin.cc\n  ${CMAKE_CURRENT_SOURCE_DIR}/../src/library_file.cc\n  ${CMAKE_CURRENT_SOURCE_DIR}/../src/plugin_info_app.cc\n)\n\n# Implementation files that include RapidJSON headers.\n# Used to supress warnings for those.\nset(json_sources ${CMAKE_CURRENT_SOURCE_DIR}/../src/plugin.cc)\ncheck_cxx_compiler_flag(\"-Wshadow\" HAVE_SHADOW)\nif(HAVE_SHADOW)\n  add_compile_flags(${json_sources} COMPILE_FLAGS \"-Wno-shadow\")\nendif()\ncheck_cxx_compiler_flag(\"-Werror\" HAVE_ERROR)\nIF(HAVE_ERROR)\n  add_compile_flags(${json_sources} COMPILE_FLAGS \"-Wno-error\")\nENDIF()\ncheck_cxx_compiler_flag(\"-Wconversion\" HAVE_CONVERSION)\nIF(HAVE_CONVERSION)\n  add_compile_flags(${json_sources} COMPILE_FLAGS \"-Wno-conversion\")\nENDIF()\ncheck_cxx_compiler_flag(\"-Wpedantic\" HAVE_PEDANTIC)\nIF(HAVE_PEDANTIC)\n  add_compile_flags(${json_sources} COMPILE_FLAGS \"-Wno-pedantic\")\nENDIF()\n\n\nif(EXISTS \"${CMAKE_SOURCE_DIR}/extra/rapidjson/\")\n  # prefer server-side rapidjson\n  SET(RAPIDJSON_INCLUDE_DIRS \"${CMAKE_SOURCE_DIR}/extra/rapidjson/include/\")\nelse()\n  SET(RAPIDJSON_INCLUDE_DIRS \"${MySQLRouter_SOURCE_DIR}/ext/rapidjson/include/\")\nendif()\n\nset(include_dirs\n  ${CMAKE_CURRENT_SOURCE_DIR}/../src/\n  ${RAPIDJSON_INCLUDE_DIRS}\n  ${CMAKE_SOURCE_DIR}/src/harness/include\n  )\n\nif(NOT WIN32)\n  add_library(plugin_info_tests SHARED ${PLUGIN_INFO_SOURCES})\nelse()\n  add_library(plugin_info_tests STATIC ${PLUGIN_INFO_SOURCES})\nendif()\n\ntarget_link_libraries(plugin_info_tests harness-library)\n\nset_target_properties(plugin_info_tests PROPERTIES\n                      LIBRARY_OUTPUT_DIRECTORY\n                      ${MySQLRouter_BINARY_STAGE_DIR}/lib)\n\n\ntarget_include_directories(plugin_info_tests PRIVATE ${include_dirs})\n\nadd_test_dir(${CMAKE_CURRENT_SOURCE_DIR}\n             MODULE \"mysqlrouter_plugin_info\"\n             LIB_DEPENDS\n               plugin_info_tests\n             INCLUDE_DIRS\n               ${include_dirs}\n)\n"
  },
  {
    "path": "src/plugin_info/tests/test_plugin_info_app.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/**\n * Test the mysqlrouter_plugin_info tool.\n */\n\n#include \"gmock/gmock.h\"\n\n#include \"plugin_info_app.h\"\n\n#include \"mysql/harness/filesystem.h\"\n#include \"mysql/harness/plugin.h\"\n#include \"router_config.h\"\n\n#include <iostream>\n#include <sstream>\n\nusing mysql_harness::Path;\n\nusing testing::StartsWith;\nusing testing::StrEq;\nusing testing::WithParamInterface;\nusing testing::ValuesIn;\n\nusing std::string;\n\nPath g_origin_path;\n\nclass PluginInfoAppTest : public ::testing::Test {\n protected:\n  virtual void SetUp();\n\n  void verify_help_output();\n  void verify_version_output();\n  void verify_plugin_info(const string &brief,\n                          const string& version,\n                          const string& requires,\n                          const string& conflicts);\n\n  string get_plugin_file_path(const string& plugin_name);\n\n\n  std::stringstream out_stream_;\n  std::stringstream out_stream_err_;\n\n  Path plugin_dir_;\n};\n\nconst char* kPluginInfoAppExeFileName = \"mysqlrouter_plugin_info\";\n\nvoid PluginInfoAppTest::SetUp() {\n  out_stream_.str(\"\");\n  out_stream_err_.str(\"\");\n\n  char *stage_dir_c = std::getenv(\"STAGE_DIR\");\n  auto stage_dir = Path(stage_dir_c ? stage_dir_c : \"./stage\");\n#ifdef CMAKE_INTDIR\n  if (!g_origin_path.str().empty()) {\n    stage_dir = Path(stage_dir.join(g_origin_path.basename()));\n  }\n  else {\n    throw std::runtime_error(\"Origin dir not set\");\n  }\n#endif\n\n  plugin_dir_ = stage_dir;\n  plugin_dir_.append(\"lib\");\n#ifndef _WIN32\n  plugin_dir_.append(\"mysqlrouter\");\n#endif\n}\n\nstring PluginInfoAppTest::get_plugin_file_path(const string& plugin_name) {\n  Path plugin_path = plugin_dir_;\n  string plugin_file = plugin_name;\n\n#ifndef _WIN32\n  plugin_file += \".so\";\n#else\n  plugin_file += \".dll\";\n#endif\n\n  plugin_path.append(plugin_file);\n  return plugin_path.str();\n}\n\nvoid PluginInfoAppTest::verify_help_output() {\n\n  const string kHelpOutput = \"Usage:\\n\"\n      \"\\tmysqlrouter_plugin_info <mysqlrouter_plugin_file> <mysql_plugin_name>\\n\"\n      \"Example:\\n\"\n#ifndef _WIN32\n      \"\\tmysqlrouter_plugin_info /usr/lib/mysqlrouter/routing.so routing\\n\"\n#else\n      \"\\tmysqlrouter_plugin_info \\\"c:\\\\Program Files (x86)\\\\MySQL\\\\MySQL Router 2.1\\\\lib\\\\routing.dll\\\" routing\\n\"\n#endif\n      \"To print help information:\\n\"\n      \"\\tmysqlrouter_plugin_info --help\\n\"\n      \"To print application version:\\n\"\n      \"\\tmysqlrouter_plugin_info --version\\n\";\n\n  EXPECT_THAT(out_stream_.str(), StrEq(\"\"));\n  EXPECT_THAT(out_stream_err_.str(), StrEq(kHelpOutput));\n}\n\nvoid PluginInfoAppTest::verify_version_output() {\n\n  const string kVersionOutput = kPluginInfoAppName + \" \" + MYSQL_ROUTER_VERSION + \"\\n\";\n\n  EXPECT_THAT(out_stream_.str(), StrEq(\"\"));\n  EXPECT_THAT(out_stream_err_.str(), StrEq(kVersionOutput));\n}\n\nvoid PluginInfoAppTest::verify_plugin_info(const string& brief,\n                                           const string& version,\n                                           const string& requires,\n                                           const string& conflicts) {\n\n  EXPECT_THAT(out_stream_err_.str(), StrEq(\"\"));\n\n  const auto abi_version = ::mysql_harness::PLUGIN_ABI_VERSION;\n  const std::string abi_version_str = std::to_string(ABI_VERSION_MAJOR(abi_version)) + \".\"\n                                      + std::to_string(ABI_VERSION_MINOR(abi_version));\n\n  const string expected_json = \"{\\n\"\n                               \"    \\\"abi-version\\\": \\\"\" + abi_version_str + \"\\\",\\n\"\n                               \"    \\\"arch-descriptor\\\": \\\"\" + string(mysql_harness::ARCHITECTURE_DESCRIPTOR) + \"\\\",\\n\"\n                               \"    \\\"brief\\\": \\\"\" + brief +  \"\\\",\\n\"\n                               \"    \\\"plugin-version\\\": \\\"\" + version + \"\\\",\\n\"\n                               \"    \\\"requires\\\": [\" + requires + \"],\\n\"\n                               \"    \\\"conflicts\\\": [\" + conflicts + \"]\\n\"\n                               \"}\\n\";\n\n  EXPECT_THAT(out_stream_.str(), StrEq(expected_json));\n}\n\nTEST_F(PluginInfoAppTest, NoParametersPassed) {\n  const char* argv[] = {kPluginInfoAppExeFileName};\n  const int argc = static_cast<int>(sizeof(argv)/sizeof(char*));\n  Plugin_info_app plugin_info_app(argc, argv, out_stream_, out_stream_err_);\n\n  int res = plugin_info_app.run();\n\n  // if the mysqlrouter_plugin_info was called with no command line options\n  // we expect usage being printed to error stream and app returning with -1\n  EXPECT_EQ(-1, res);\n  verify_help_output();\n}\n\nTEST_F(PluginInfoAppTest, HelpRequested) {\n  const char* argv[] = {kPluginInfoAppExeFileName, \"--help\"};\n  const int argc = static_cast<int>(sizeof(argv)/sizeof(char*));\n  Plugin_info_app plugin_info_app(argc, argv, out_stream_, out_stream_err_);\n\n  int res = plugin_info_app.run();\n\n  // if the mysqlrouter_plugin_info was called with --help parameter\n  // we expect usage being printed to error stream and app returning with 0\n  EXPECT_EQ(0, res);\n  verify_help_output();\n}\n\nTEST_F(PluginInfoAppTest, VersionRequested) {\n  const char* argv[] = {kPluginInfoAppExeFileName, \"--version\"};\n  const int argc = static_cast<int>(sizeof(argv)/sizeof(char*));\n  Plugin_info_app plugin_info_app(argc, argv, out_stream_, out_stream_err_);\n\n  int res = plugin_info_app.run();\n\n  // if the mysqlrouter_plugin_info was called with --version parameter\n  // we expect the version being printed to error stream and app returning with 0\n  EXPECT_EQ(0, res);\n  verify_version_output();\n}\n\nTEST_F(PluginInfoAppTest, WrongNumberOfParams) {\n  const char* argv[] = {kPluginInfoAppExeFileName, \"one\", \"two\", \"three\"};\n  const int argc = static_cast<int>(sizeof(argv)/sizeof(char*));\n  Plugin_info_app plugin_info_app(argc, argv, out_stream_, out_stream_err_);\n\n  int res = plugin_info_app.run();\n\n  // if the mysqlrouter_plugin_info was called with too many command line parameters\n  // we expect usage being printed to error stream and app returning with -1\n  EXPECT_EQ(-1, res);\n  verify_help_output();\n}\n\nTEST_F(PluginInfoAppTest, NonExistingLibrary) {\n  const char* non_existing_plugin = \"non_existing_plugin\";\n  std::string lib_path = get_plugin_file_path(non_existing_plugin);\n  const char* argv[] = {kPluginInfoAppExeFileName, lib_path.c_str(), non_existing_plugin};\n  const int argc = static_cast<int>(sizeof(argv)/sizeof(char*));\n\n  Plugin_info_app plugin_info_app(argc, argv, out_stream_, out_stream_err_);\n  int res = plugin_info_app.run();\n\n  EXPECT_EQ(-1, res);\n\n  const std::string expected_error = \"Could not load plugin file: \";\n\n  // check if correct error gets printed on error stream\n  EXPECT_THAT(out_stream_.str(), StrEq(\"\"));\n  EXPECT_THAT(out_stream_err_.str(), StartsWith(expected_error));\n}\n\nTEST_F(PluginInfoAppTest, NonPluginExistingLibrary) {\n  // we use mysql_protocol which is an existing library but it's not a plugin\n  // so should not have Plugin struct exported/defined\n  const char* non_plugin_lib = \"mysql_protocol\";\n  std::string lib_path = get_plugin_file_path(non_plugin_lib);\n  const char* argv[] = {kPluginInfoAppExeFileName, lib_path.c_str(), non_plugin_lib};\n  const int argc = static_cast<int>(sizeof(argv)/sizeof(char*));\n\n  Plugin_info_app plugin_info_app(argc, argv, out_stream_, out_stream_err_);\n  int res = plugin_info_app.run();\n\n  EXPECT_EQ(-1, res);\n\n  const std::string expected_error = \"Loading plugin information for '\" + lib_path +  \"' failed:\";\n\n  // check if correct error gets printed on error stream\n  EXPECT_THAT(out_stream_.str(), StrEq(\"\"));\n  EXPECT_THAT(out_stream_err_.str(), StartsWith(expected_error));\n}\n\n//\n// Check if the expected information is printed for each of the plugins we currently ship\n// with MySQLRouter\n//\n\n//                            <name,   brief,  version ,requires, conflicts>\nusing Plugin_data = std::tuple<string, string, string,  string,   string>;\n\nclass PluginInfoAppTestReadInfo\n    : public PluginInfoAppTest,\n      public WithParamInterface<Plugin_data> {};\n\nTEST_P(PluginInfoAppTestReadInfo, ReadInfo) {\n  const string plugin_name = std::get<0>(GetParam());\n  const string plugin_brief = std::get<1>(GetParam());\n  const string plugin_version = std::get<2>(GetParam());\n  const string plugin_requires = std::get<3>(GetParam());\n  const string plugin_conflicts = std::get<4>(GetParam());\n  const string plugin_file_path = get_plugin_file_path(plugin_name);\n\n  const char* argv[] = {kPluginInfoAppExeFileName, plugin_file_path.c_str(), plugin_name.c_str()};\n  const int argc = static_cast<int>(sizeof(argv)/sizeof(char*));\n\n  Plugin_info_app plugin_info_app(argc, argv, out_stream_, out_stream_err_);\n\n  int res = plugin_info_app.run();\n\n  EXPECT_EQ(0, res);\n  verify_plugin_info(plugin_brief, plugin_version,\n                     plugin_requires, plugin_conflicts);\n}\n\nconst Plugin_data router_plugins[] {\n  Plugin_data{\"routing\", \"Routing MySQL connections between MySQL clients/connectors and servers\", \"0.0.1\", \"\", \"\"},\n  Plugin_data{\"metadata_cache\", \"Metadata Cache, managing information fetched from the Metadata Server\", \"0.0.1\", \"\", \"\"},\n  Plugin_data{\"keepalive\", \"Keepalive Plugin\", \"0.0.1\", \"\", \"\"},\n};\n\nINSTANTIATE_TEST_CASE_P(CheckReadInfo, PluginInfoAppTestReadInfo,\n                        ValuesIn(router_plugins));\n\n\nint main(int argc, char *argv[]) {\n  g_origin_path = Path(argv[0]).dirname();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/router/CMakeLists.txt",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\ninclude_directories(\n  ${PROJECT_SOURCE_DIR}/include/\n)\n\nadd_subdirectory(src/)\nif(ENABLE_TESTS)\n  add_subdirectory(tests/)\nendif()\n\nif(INSTALL_DOCDIR)\n  install(FILES ${PROJECT_SOURCE_DIR}/doc/sample_mysqlrouter.conf DESTINATION ${INSTALL_DOCDIR})\n  if(NOT EXISTS \"${CMAKE_SOURCE_DIR}/include/mysql.h\")\n    # only install the README, License and so on of we are not part of the server-tree\n    if(NOT GPL)\n      InstallCommercialReadmeLicense()\n    endif()\n    install(FILES ${PROJECT_SOURCE_DIR}/README.txt DESTINATION ${INSTALL_DOCDIR})\n    install(FILES ${PROJECT_SOURCE_DIR}/License.txt DESTINATION ${INSTALL_DOCDIR})\n    if(INSTALL_LAYOUT STREQUAL \"DEFAULT\" OR INSTALL_LAYOUT STREQUAL \"STANDALONE\")\n      if(GPL)\n        install(FILES ${PROJECT_SOURCE_DIR}/packaging/deb-common/mysql-router.mysqlrouter.init\n          DESTINATION ${INSTALL_DOCDIR} RENAME sample_mysqlrouter.init)\n      else()\n        install(FILES ${PROJECT_SOURCE_DIR}/internal/packaging/deb-common-commercial/mysql-router-commercial.mysqlrouter.init\n          DESTINATION ${INSTALL_DOCDIR} RENAME sample_mysqlrouter.init)\n      endif()\n    endif()\n  endif()\nendif()\n\n\n# don't install headers until a) a final destination is found and b) API is stable\n#\n# file(GLOB router_headers include/mysqlrouter/*.h)\n# install(FILES ${router_headers}\n#   DESTINATION \"include/mysql/${HARNESS_NAME}\")\n\n# Install logging, runtime, config and data folders\nif(INSTALL_LAYOUT STREQUAL \"DEFAULT\" OR INSTALL_LAYOUT STREQUAL \"STANDALONE\")\n  # if we are part of the mysql-server tree, LOGDIR, CONFIGDIR, ... won't be set\n  # provide reasonable defaults\n  if (NOT INSTALL_LOGDIR)\n    SET(INSTALL_LOGDIR \"log\")\n  ENDIF()\n  if (NOT INSTALL_CONFIGDIR)\n    SET(INSTALL_CONFIGDIR \"etc\")\n  ENDIF()\n  if (NOT INSTALL_DATADIR)\n    SET(INSTALL_DATADIR \"share/mysqlrouter\")\n  ENDIF()\n  if (NOT INSTALL_RUNTIMEDIR)\n    SET(INSTALL_RUNTIMEDIR \"run\")\n  ENDIF()\n  foreach(_dirvar LOGDIR RUNTIMEDIR CONFIGDIR DATADIR)\n    set(_dir ${INSTALL_${_dirvar}})\n    IF(NOT _dir)\n      MESSAGE(FATAL_ERROR \"INSTALL_${_dirvar} is empty.\")\n    ENDIF()\n    set(_stage_dir ${MySQLRouter_BINARY_STAGE_DIR}/${_dir})\n    file(MAKE_DIRECTORY ${_stage_dir})\n\n    # create a empty directory in the install folder\n    install(DIRECTORY DESTINATION \"./${_dir}\"\n      DIRECTORY_PERMISSIONS\n        OWNER_WRITE OWNER_READ OWNER_EXECUTE\n        GROUP_WRITE GROUP_READ GROUP_EXECUTE\n        WORLD_READ WORLD_EXECUTE\n      )\n  endforeach()\n\n  if(WIN32)\n    # In commercial ZIP packages we distribute the redistributable VC++ runtime\n    # But that can be done only in release builds (not debug).\n    # (Debug builds ZIP packages does not include it)\n   if((NOT GPL) AND INSTALL_LAYOUT STREQUAL \"STANDALONE\")\n     if(NOT(DMYSQL_BUILD STREQUAL \"debug\"))\n       message(STATUS \"Gathering VC++ redistributable\")\n       include(InstallRequiredSystemLibraries)\n     else()\n       message(WARNING \"No VC++ runtime will be redistributed for Debug builds\")\n     endif()\n    endif()\n  endif()\nendif()\n"
  },
  {
    "path": "src/router/include/mysqlrouter/datatypes.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_DATATYPES_INCLUDED\n#define MYSQLROUTER_DATATYPES_INCLUDED\n\n#include <cstdint>\n#include <iostream>\n#include <string>\n#ifndef _WIN32\n#  include <arpa/inet.h>\n#endif\n\nnamespace mysqlrouter {\n\n/** @brief SSL connection related options */\nstruct SSLOptions {\n  std::string mode;\n\n  std::string cipher;\n  std::string tls_version;\n  std::string ca;\n  std::string capath;\n  std::string crl;\n  std::string crlpath;\n};\n\n} // namespace mysqlrouter\n\n#endif // MYSQLROUTER_UTILS_INCLUDED\n"
  },
  {
    "path": "src/router/include/mysqlrouter/keyring_info.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef KEYRING_INFO_INCLUDED\n#define KEYRING_INFO_INCLUDED\n\n#include <chrono>\n#include <stdexcept>\n\nnamespace mysql_harness {\nclass Config;\n}\n\n/**\n * @brief MasterKeyWriteError class represents error during writing\n * master key using master-key-writer. More detail about the nature\n * of the error can be accessed using what() member function.\n */\nclass MasterKeyWriteError : public std::runtime_error {\npublic:\n  explicit MasterKeyWriteError(const std::string& msg) : std::runtime_error(msg) {}\n};\n\n/**\n * @brief MasterKeyReadError class represents error during reading\n * master key using master-key-reader. More detail about the nature\n * of the error can be accessed using what() member function.\n */\nclass MasterKeyReadError : public std::runtime_error {\npublic:\n  explicit MasterKeyReadError(const std::string& msg) : std::runtime_error(msg) {}\n};\n\n/**\n * @brief SetRouterIdEnvVariableError class represents error duing\n * adding ROUTER_ID variable to environment. More detail about the\n * nature of the error can be accessed using what() member function.\n */\nclass SetRouterIdEnvVariableError : public std::runtime_error {\npublic:\n  explicit SetRouterIdEnvVariableError(const std::string& msg) : std::runtime_error(msg) {}\n};\n\n/**\n * @brief KeyringInfo class encapsulates loading and storing master key\n * using master-key-reader and master-key-writer.\n */\nclass KeyringInfo {\nprivate:\n\n  /** @brief The path to keyring file */\n  std::string keyring_file_;\n\n  /** @brief The path to master key file, empty if master key file is not used */\n  std::string master_key_file_;\n\n  /** @brief The path to master-key-reader that is used to read master key */\n  std::string master_key_reader_;\n\n  /** @brief The path to master-key-writer that is used to store master key */\n  std::string master_key_writer_;\n\n  /** @brief The master key that is used to encode/decode keyring content */\n  std::string master_key_;\n\n  /** @brief The maximum time to write master key using master-key-writer or read master key using master-key-fetcher. */\n  std::chrono::milliseconds rw_timeout_ = std::chrono::milliseconds(30000);\n\n  /** @brief If true then log verbose error messages */\n  bool verbose_ = true;\n\npublic:\n  /**\n   * Default constructor.\n   *\n   * @param verbose IF true then log verbose error messages\n   */\n  KeyringInfo(bool verbose = true) noexcept : verbose_(verbose) {}\n\n  /**\n   * Constructs KeyringInfo and assigns keyring file and master key file\n   *\n   * @param keyring_file The path to keyring file\n   * @param master_key_file The path to master key file\n   */\n  KeyringInfo(const std::string& keyring_file,\n      const std::string& master_key_file) noexcept :\n      keyring_file_(keyring_file), master_key_file_(master_key_file) {\n  }\n\n  void set_keyring_file(const std::string& keyring_file) noexcept {\n    keyring_file_ = keyring_file;\n  }\n\n  const std::string& get_keyring_file() const noexcept {\n    return keyring_file_;\n  }\n\n  void set_master_key_file(const std::string& master_key_file) noexcept {\n    master_key_file_ = master_key_file;\n  }\n\n  const std::string& get_master_key_file() const noexcept{\n    return master_key_file_;\n  }\n\n  void set_master_key_reader(const std::string& master_key_reader) noexcept {\n    master_key_reader_ = master_key_reader;\n  }\n\n  const std::string& get_master_key_reader() const noexcept {\n    return master_key_reader_;\n  }\n\n  void set_master_key_writer(const std::string& master_key_writer) noexcept {\n    master_key_writer_ = master_key_writer;\n  }\n\n  const std::string& get_master_key_writer() const noexcept {\n    return master_key_writer_;\n  }\n\n  void set_master_key(const std::string& master_key) noexcept {\n    master_key_ = master_key;\n  }\n\n  const std::string& get_master_key() const noexcept {\n    return master_key_;\n  }\n\n  /**\n   * @brief Initializes KeyringInfo using data read from Config. It initializes\n   * keyring_file, master_key_file_, master_key_reader_ and master_key_writer.\n   *\n   * @param config The Config that is used to initialize KeyringInfo\n   * @param bootstrap_directory The path to bootstrap directory\n   */\n  void init(mysql_harness::Config &config, const std::string& bootstrap_directory) noexcept;\n\n  /**\n   * @brief Reads master key using master_key_reader_;\n   *\n   * @return true if successfully read master key, false otherwise.\n   */\n  bool read_master_key() noexcept;\n\n  /**\n   * @brief Writes master key using master_key_writer_;\n   *\n   * @return true if write was successful, false otherwise.\n   */\n  bool write_master_key() const noexcept;\n\n  /*\n   * @brief Generate master key and store it in KeyringInfo. Generated\n   * master key can be accessed using master_key_ attribute.\n   */\n  void generate_master_key() noexcept;\n\n  /**\n   * @brief Adds ROUTER_ID variable to environment.\n   *\n   * @throw SetRouterIdEnvVariableError if adding ROUTER_ID to environment\n   * fails.\n   */\n  void add_router_id_to_env(uint32_t router_id) const;\n\n  /**\n   * @brief Checks if master-key-reader/master-key-writer should be\n   * used to load/store master key.\n   *\n   * @return true if master-key-reader/master-key-writer should be used\n   * to load/store master key, false otherwise.\n   */\n  bool use_master_key_external_facility() const noexcept;\n\n  /**\n   * @brief Checks if mysqlrouter.key and keyring files should be used to\n   * store master key.\n   *\n   * @return true if master key should be used to store master key, false otherwise.\n   */\n  bool use_master_key_file() const noexcept;\n\n  /**\n   * @brief Checks if master key is correct: it cannot be empty, and cannot\n   * be longer than mysql_harness::kMaxKeyringKeyLength.\n   *\n   * @throw std::runtime_error if master key is empty or is longer than\n   * mysql_harness::kMaxKeyringKeyLength\n   */\n  void validate_master_key() const;\n\n  /**\n   * @brief Returns path to keyring file based on data read from config or bootstrap directory.\n   *\n   * @return The path to keyring file\n   */\n  std::string get_keyring_file(const mysql_harness::Config &config, const std::string& bootstrap_directory) const noexcept;\n};\n\n#endif /* KEYRING_INFO_INCLUDED */\n"
  },
  {
    "path": "src/router/include/mysqlrouter/log_filter.h",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef LOG_FILTER_INCLUDED\n#define LOG_FILTER_INCLUDED\n\n#include <string>\n#include <vector>\n\n#ifdef _WIN32\n#  include <regex>\nusing regex_and_group_indices = std::pair<std::regex, std::vector<size_t>>;\n#else\n#include <regex.h>\nusing regex_and_group_indices = std::pair<regex_t, std::vector<size_t>>;\n#endif\n\nnamespace mysqlrouter {\n\n/*\n * A LogFilter allows to replace substring with '***'.\n */\nclass LogFilter {\n public:\n  static const char kFillCharacter;\n  static const unsigned int kFillSize = 3;\n\n  /*\n   * @param statement The string to be filtered.\n   *\n   * @return filtered string\n   */\n  std::string filter(const std::string& statement) const;\n\n  /*\n   * @param pattern The string with pattern to match\n   * @param group_indices The vector with indices of groups that will be replaced\n   *                      with '***'\n   */\n  void add_pattern(const std::string& pattern, const std::vector<size_t>& group_indices);\n\n  /*\n   * @param pattern The string with pattern to match\n   * @param group_index The index of the group that will be replaced with '***'\n   */\n  void add_pattern(const std::string& pattern, size_t group_index);\n\n  virtual ~LogFilter();\n\n private:\n  std::vector<regex_and_group_indices> patterns_;\n};\n\n/**\n * A SQLLogFilter allows to replace substrings defined by a set of hardcoded\n * regular expressions with '***'.\n */\nclass SQLLogFilter : public LogFilter {\n public:\n\n  /*\n  * Adds default patterns defined as regular expressions.\n  */\n  void add_default_sql_patterns();\n};\n\n} // end of mysqlrouter namespace\n\n#endif // LOG_FILTER_INCLUDED\n"
  },
  {
    "path": "src/router/include/mysqlrouter/my_aes.h",
    "content": "#ifndef MY_AES_INCLUDED\n#define MY_AES_INCLUDED\n\n/* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.\n\n This program is free software; you can redistribute it and/or modify\n it under the terms of the GNU General Public License, version 2.0,\n as published by the Free Software Foundation.\n \n This program is also distributed with certain software (including\n but not limited to OpenSSL) that is licensed under separate terms,\n as designated in a particular file or component or in included license\n documentation.  The authors of MySQL hereby grant you an additional\n permission to link the program and your derivative works with the\n separately licensed software that they have included with MySQL.\n \n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n GNU General Public License for more details.\n \n You should have received a copy of the GNU General Public License\n along with this program; if not, write to the Free Software\n Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */\n\n\n/**\n  @file src/router/include/mysqlrouter/my_aes.h\n  Wrapper to give simple interface for MySQL to AES standard encryption.\n*/\n\n\n#include <stdint.h>\n\nnamespace myaes {\n\n/** AES IV size is 16 bytes for all supported ciphers except ECB */\n#define MY_AES_IV_SIZE 16\n\n/** AES block size is fixed to be 128 bits for CBC and ECB */\n#define MY_AES_BLOCK_SIZE 16\n\n\n/** Supported AES cipher/block mode combos */\nenum my_aes_opmode\n{\n   my_aes_128_ecb,\n   my_aes_192_ecb,\n   my_aes_256_ecb,\n   my_aes_128_cbc,\n   my_aes_192_cbc,\n   my_aes_256_cbc\n#ifndef HAVE_YASSL\n   ,my_aes_128_cfb1,\n   my_aes_192_cfb1,\n   my_aes_256_cfb1,\n   my_aes_128_cfb8,\n   my_aes_192_cfb8,\n   my_aes_256_cfb8,\n   my_aes_128_cfb128,\n   my_aes_192_cfb128,\n   my_aes_256_cfb128,\n   my_aes_128_ofb,\n   my_aes_192_ofb,\n   my_aes_256_ofb\n#endif\n};\n\n#define MY_AES_BEGIN my_aes_128_ecb\n#ifdef HAVE_YASSL\n#define MY_AES_END my_aes_256_cbc\n#else\n#define MY_AES_END my_aes_256_ofb\n#endif\n\n/* If bad data discovered during decoding */\n#define MY_AES_BAD_DATA  -1\n\n/** String representations of the supported AES modes. Keep in sync with my_aes_opmode */\nextern const char *my_aes_opmode_names[];\n\n/**\n  Encrypt a buffer using AES\n\n  @param [in] source           Pointer to data for encryption\n  @param [in] source_length    Size of encryption data\n  @param [out] dest            Buffer to place encrypted data (must be large enough)\n  @param [in] key              Key to be used for encryption\n  @param [in] key_length       Length of the key. Will handle keys of any length\n  @param [in] mode             encryption mode\n  @param [in] iv               16 bytes initialization vector if needed. Otherwise NULL\n  @param [in] padding          if padding needed.\n  @return              size of encrypted data, or negative in case of error\n*/\n\nint my_aes_encrypt(const unsigned char *source, uint32_t source_length,\n                   unsigned char *dest,\n                   const unsigned char *key, uint32_t key_length,\n                   enum my_aes_opmode mode, const unsigned char *iv,\n                   bool padding = true);\n\n/**\n  Decrypt an AES encrypted buffer\n\n  @param source         Pointer to data for decryption\n  @param source_length  size of encrypted data\n  @param dest           buffer to place decrypted data (must be large enough)\n  @param key            Key to be used for decryption\n  @param key_length     Length of the key. Will handle keys of any length\n  @param mode           encryption mode\n  @param iv             16 bytes initialization vector if needed. Otherwise NULL\n  @param padding        if padding needed.\n  @return size of original data.\n*/\n\n\nint my_aes_decrypt(const unsigned char *source, uint32_t source_length,\n                   unsigned char *dest,\n                   const unsigned char *key, uint32_t key_length,\n                   enum my_aes_opmode mode, const unsigned char *iv,\n                   bool padding = true);\n\n/**\n  Calculate the size of a buffer large enough for encrypted data.\n\n  @param source_length  length of data to be encrypted\n  @param opmode         encryption mode\n  @return               size of buffer required to store encrypted data\n*/\n\nint my_aes_get_size(uint32_t source_length, enum my_aes_opmode opmode);\n\n/**\n  Return true if the AES cipher and block mode requires an IV.\n\n  @param opmode           encryption mode\n\n  @retval TRUE   IV needed\n  @retval FALSE  IV not needed\n*/\n\nbool my_aes_needs_iv(my_aes_opmode opmode);\n\n}\n\n#endif /* MY_AES_INCLUDED */\n"
  },
  {
    "path": "src/router/include/mysqlrouter/my_aes_impl.h",
    "content": "/*\n  Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/** Maximum supported key length */\n#define MAX_AES_KEY_LENGTH 256\n\n/* TODO: remove in a future version */\n/* Guard against using an old export control restriction #define */\n#ifdef AES_USE_KEY_BITS\n#error AES_USE_KEY_BITS not supported\n#endif\n\nnamespace myaes {\n\nextern uint32_t *my_aes_opmode_key_sizes;\n\n\nvoid my_aes_create_key(const unsigned char *key, uint32_t key_length,\n                       uint8_t *rkey, enum my_aes_opmode opmode);\n}\n"
  },
  {
    "path": "src/router/include/mysqlrouter/mysql_session.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef _ROUTER_MYSQL_SESSION_H_\n#define _ROUTER_MYSQL_SESSION_H_\n\n#include \"mysqlrouter/log_filter.h\"\n\n#include <string>\n#include <vector>\n#include <stdexcept>\n#include <functional>\n#include <memory>\n\n#include <mysql.h>  // enum mysql_ssl_mode\n\n#ifdef FRIEND_TEST\nclass MockMySQLSession;\n#endif\n\nnamespace mysqlrouter {\n\nclass MySQLSession {\n public:\n  static const int kDefaultConnectTimeout = 30;\n  static const int kDefaultReadTimeout = 30;\n  typedef std::vector<const char*> Row;\n  typedef std::function<bool (const Row&)> RowProcessor;\n\n  // text representations of SSL modes\n  static const char kSslModeDisabled[];\n  static const char kSslModePreferred[];\n  static const char kSslModeRequired[];\n  static const char kSslModeVerifyCa[];\n  static const char kSslModeVerifyIdentity[];\n\n  class Transaction {\n   public:\n    Transaction(MySQLSession *session) : session_(session) {\n      session_->execute(\"START TRANSACTION\");\n    }\n\n    ~Transaction() {\n      if (session_) {\n        try {\n          session_->execute(\"ROLLBACK\");\n        } catch (...) {\n          // ignore errors during rollback on d-tor\n        }\n      }\n    }\n\n    void commit() {\n      session_->execute(\"COMMIT\");\n      session_ = nullptr;\n    }\n\n    void rollback() {\n      session_->execute(\"ROLLBACK\");\n      session_ = nullptr;\n    }\n\n   private:\n    MySQLSession *session_;\n  };\n\n  class Error : public std::runtime_error {\n   public:\n    Error(const char *error, unsigned int code__)\n    : std::runtime_error(error), code_(code__) {}\n\n    Error(const std::string &error, unsigned int code__)\n    : std::runtime_error(error), code_(code__) {}\n\n    unsigned int code() const { return code_; }\n   private:\n    unsigned int code_;\n  };\n\n  class ResultRow {\n   public:\n    virtual ~ResultRow() {}\n    size_t size() const { return row_.size(); }\n    const char *operator[] (size_t i) { return row_[i]; }\n   protected:\n    Row row_;\n  };\n\n  MySQLSession();\n  virtual ~MySQLSession();\n\n  static mysql_ssl_mode parse_ssl_mode(std::string ssl_mode); // throws std::logic_error\n  static const char* ssl_mode_to_string(mysql_ssl_mode ssl_mode) noexcept;\n\n  virtual void set_ssl_options(mysql_ssl_mode ssl_mode,\n                               const std::string &tls_version,\n                               const std::string &ssl_cipher,\n                               const std::string &ca, const std::string &capath,\n                               const std::string &crl, const std::string &crlpath);         // throws Error\n  virtual void set_ssl_cert(const std::string &cert, const std::string &key);\n\n  virtual void connect(const std::string &host, unsigned int port,\n                       const std::string &username,\n                       const std::string &password,\n                       const std::string &unix_socket,\n                       const std::string &default_schema,\n                       int connect_timeout = kDefaultConnectTimeout,\n                       int read_timeout = kDefaultReadTimeout); // throws Error\n  virtual void disconnect();\n\n  virtual void execute(const std::string &query); // throws Error, std::logic_error\n  virtual void query(const std::string &query, const RowProcessor &processor);  // throws Error, std::logic_error\n  virtual ResultRow *query_one(const std::string &query); // throws Error\n\n  virtual uint64_t last_insert_id() noexcept;\n\n  virtual std::string quote(const std::string &s, char qchar = '\\'') noexcept;\n\n  virtual bool is_connected() noexcept { return connection_ && connected_; }\n  const std::string& get_address() noexcept { return connection_address_; }\n\n  virtual const char *last_error();\n  virtual unsigned int last_errno();\n\nprivate:\n  MYSQL *connection_;\n  bool connected_;\n  std::string connection_address_;\n  SQLLogFilter log_filter_;\n\n  virtual MYSQL* raw_mysql() noexcept { return connection_; }\n  static bool check_for_yassl(MYSQL *connection);\n\n  #ifdef FRIEND_TEST\n  friend class ::MockMySQLSession;\n  #endif\n};\n\n} // namespace mysqlrouter\n\n#endif\n"
  },
  {
    "path": "src/router/include/mysqlrouter/plugin_config.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_PLUGIN_CONFIG_INCLUDED\n#define MYSQLROUTER_PLUGIN_CONFIG_INCLUDED\n\n#include \"mysql/harness/config_parser.h\"\n#include \"mysql/harness/filesystem.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysqlrouter/utils.h\"\n#include \"tcp_address.h\"\n\n#include <cerrno>\n#include <cassert>\n#include <cstdlib>\n#include <iostream>\n#include <limits>\n#include <map>\n#include <sstream>\n#include <string>\n\n#ifdef _WIN32\n#  pragma push_macro(\"max\")\n#  undef max\n#endif\n\nnamespace mysqlrouter {\n\n/** Exception that gets thrown when the configuarion option is missing\n */\nclass option_not_present : public std::invalid_argument {\npublic:\n  using std::invalid_argument::invalid_argument;\n};\n\n/** Exception that gets thrown when the configuarion option is present\n *  but it is empty value\n */\nclass option_empty : public std::invalid_argument {\npublic:\n  using std::invalid_argument::invalid_argument;\n};\n\n/** @class BasePluginConfig\n * @brief Retrieve and manage plugin configuration\n *\n * BasePluginConfig is an abstract class which can be used to by plugins\n * to derive their own class retrieving configuration from, for example,\n * Harness `ConfigSection instances`.\n */\nclass BasePluginConfig {\npublic:\n  using defaults_map = std::map<std::string, std::string>;\n\n  /** @brief Constructor\n   */\n  BasePluginConfig() { }\n\n  /**\n   * destructor\n   */\n  virtual ~BasePluginConfig() = default;\n\n  /** @brief Gets value of given option as string\n   *\n   * @throws option_not_present if the required option is missing\n   * @throws option_empty if the required option is present but empty\n   *\n   * @param section Instance of ConfigSection\n   * @param option name of the option\n   * @return Option value as std::string\n   *\n   */\n  std::string get_option_string(const mysql_harness::ConfigSection *section, const std::string &option) const;\n\n  /** @brief Gets a number of milliseconds from a string value\n   *\n   * The expected option value is a string with floating point number in seconds\n   * (with '.' as a decimal separator) in standard or scientific notation\n   * Example:\n   *  for value = \"1.0\" expected result is std::chrono:milliseconds(1000)\n   *  for value = \"0.01\" expected result is std::chrono:milliseconds(10)\n   *  for value = \"1.6E-2\" expected result is std::chrono:milliseconds(16)\n   *\n   * @param value Instance of ConfigSection\n   * @param min_value Minimum value\n   * @param max_value Maximum value\n   * @param log_prefix prefix to be used when creating a message for the\n   *        exception\n   * @return value converted to milliseconds\n   * @throws std::invalid_argument on errors\n   */\n  static std::chrono::milliseconds get_option_milliseconds(const std::string& value,\n                                       double min_value = 0.0, double max_value = std::numeric_limits<double>::max(),\n                                       const std::string& log_prefix = \"\");\n\n  /** @brief Name of the section */\n  std::string section_name;\n\nprotected:\n  /** @brief Constructor for derived classes */\n  BasePluginConfig(const mysql_harness::ConfigSection *section) : section_name(get_section_name(section)) {}\n\n  /** @brief Generate the name for this configuration\n   *\n   * @param section Instance of ConfigSection\n   * @return the name for this configuration\n   */\n  virtual std::string get_section_name(const mysql_harness::ConfigSection *section) const noexcept;\n\n  /** @brief Gets the default for the given option\n   *\n   * Gets the default value of the given option. If no default option\n   * is available, an empty string is returned.\n   *\n   * @param option name of the option\n   * @return default value for given option as std::string\n   */\n  virtual std::string get_default(const std::string &option) const = 0;\n\n  /** @brief Returns whether the given option is required\n   *\n   * @return bool\n   */\n  virtual bool is_required(const std::string &option) const = 0;\n\n  /**\n   * @brief Returns message prefix for option and section\n   *\n   * Gets the message prefix of option and section. The option\n   * name will be mentioned as well as the section from the configuration.\n   *\n   * For example, option wait_timeout in section [routing:homepage] will\n   * return a prefix (without quotes):\n   *   \"option wait_timeout in [routing:homepage]\"\n   *\n   * This is useful when reporting errors.\n   *\n   * @param option Name of the option\n   * @param section Pointer to Instance of ConfigSection, nullptr by default\n   * @return Prefix as std::string\n   */\n  virtual std::string get_log_prefix(const std::string &option,\n                                     const mysql_harness::ConfigSection *section = nullptr) const noexcept;\n\n  /** @brief Gets an unsigned integer using the given option\n   *\n   * Gets an unsigned integer using the given option. The type can be\n   * any unsigned integer type such as uint16_t.\n   *\n   * The min_value argument can be used to set a minimum value for\n   * the option. For example, when 0 (zero) is not allowed, min_value\n   * can be set to 0. The maximum value is whatever the maximum of the\n   * use type is.\n   *\n   * Throws std::invalid_argument on errors.\n   *\n   * @param section Instance of ConfigSection\n   * @param option Option name in section\n   * @param min_value Minimum value\n   * @param max_value Maximum value\n   * @return value read from the configuration\n   */\n  template<typename T>\n  T get_uint_option(const mysql_harness::ConfigSection *section, const std::string &option,\n                    T min_value = 0, T max_value = std::numeric_limits<T>::max()) {\n    std::string value = get_option_string(section, option);\n\n    assert(max_value <= std::numeric_limits<long long>::max());\n\n    char *rest;\n    errno = 0;\n    long long tol = std::strtoll(value.c_str(), &rest, 0);\n    T result = static_cast<T>(tol);\n\n    if (tol < 0 || errno > 0 || *rest != '\\0' || result > max_value || result < min_value ||\n        result != tol || // if casting lost high-order bytes\n        (max_value > 0 && result > max_value)) {\n      std::ostringstream os;\n      os << get_log_prefix(option, section) << \" needs value between \" << min_value << \" and \"\n         << to_string(max_value) << \" inclusive\";\n      if (!value.empty()) {\n        os << \", was '\" << value << \"'\";\n      }\n      throw std::invalid_argument(os.str());\n    }\n    return result;\n  }\n\n  /** @brief Gets a number of milliseconds using the given option\n   *\n   * The expected option value is a string with floating point number in seconds\n   * (with '.' as a decimal separator) in standard or scientific notation\n   * Example:\n   *  for value = \"1.0\" expected result is std::chrono:milliseconds(1000)\n   *  for value = \"0.01\" expected result is std::chrono:milliseconds(10)\n   *  for value = \"1.6E-2\" expected result is std::chrono:milliseconds(16)\n   *\n   * @param section Instance of ConfigSection\n   * @param option Option name in section\n   * @param min_value Minimum value\n   * @param max_value Maximum value\n   * @return value read from the configuration converted to milliseconds\n   * @throws std::invalid_argument on errors\n   */\n  std::chrono::milliseconds get_option_milliseconds(const mysql_harness::ConfigSection *section, const std::string &option,\n      double min_value = 0.0, double max_value = std::numeric_limits<double>::max()) const;\n\n  /** @brief Gets a TCP address using the given option\n   *\n   * Gets a TCP address using the given option. The option value is\n   * split in 2 giving the IP (or address) and the TCP Port. When\n   * require_port is true, a valid port number will be required.\n   *\n   * Throws std::invalid_argument on errors.\n   *\n   * @param section Instance of ConfigSection\n   * @param option Option name in section\n   * @param require_port Whether a TCP port is required\n   * @param default_port default port\n   * @return mysql_harness::TCPAddress\n   */\n  mysql_harness::TCPAddress get_option_tcp_address(const mysql_harness::ConfigSection *section, const std::string &option,\n                                    bool require_port = false, int default_port = -1);\n\n  int get_option_tcp_port(const mysql_harness::ConfigSection *section, const std::string &option);\n\n  /** @brief Gets location of a named socket\n   *\n   * Gets location of a named socket. The option value is checked first\n   * for its validity. For example, on UNIX system the path can be\n   * at most (sizeof(sockaddr_un().sun_path)-1) characters.\n   *\n   * Throws std::invalid_argument on errors.\n   *\n   * @param section Instance of ConfigSection\n   * @param option Option name in section\n   * @return Path object\n   */\n  mysql_harness::Path get_option_named_socket(const mysql_harness::ConfigSection *section, const std::string &option);\n};\n\n} // namespace mysqlrouter\n\n#ifdef _WIN32\n#  pragma pop_macro(\"max\")\n#endif\n\n\n#endif // MYSQLROUTER_PLUGIN_CONFIG_INCLUDED\n"
  },
  {
    "path": "src/router/include/mysqlrouter/sha1.h",
    "content": "/* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.\n\n This program is free software; you can redistribute it and/or modify\n it under the terms of the GNU General Public License, version 2.0,\n as published by the Free Software Foundation.\n \n This program is also distributed with certain software (including\n but not limited to OpenSSL) that is licensed under separate terms,\n as designated in a particular file or component or in included license\n documentation.  The authors of MySQL hereby grant you an additional\n permission to link the program and your derivative works with the\n separately licensed software that they have included with MySQL.\n \n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n GNU General Public License for more details.\n \n You should have received a copy of the GNU General Public License\n along with this program; if not, write to the Free Software\n Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef SHA1_INCLUDED\n#define SHA1_INCLUDED\n\n#include <cstddef>\n#include <cstdint>\n\n#define SHA1_HASH_SIZE 20 /* Hash size in bytes */\n\nnamespace my_sha1 {\n\nvoid compute_sha1_hash(uint8_t *digest, const char *buf, size_t len);\nvoid compute_sha1_hash_multi(uint8_t *digest, const char *buf1, int len1,\n                             const char *buf2, int len2);\n\n}\n\n#endif /* SHA1_INCLUDED */\n"
  },
  {
    "path": "src/router/include/mysqlrouter/uri.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef URI_ROUTING_INCLUDED\n#define URI_ROUTING_INCLUDED\n\n#include \"router_config.h\"\n\n#include <cstdint>\n#include <exception>\n#include <map>\n#include <string>\n#include <tuple>\n#include <vector>\n#ifndef _WIN32\n#  include <unistd.h>\n#endif\n\nnamespace mysqlrouter {\n\nusing URIAuthority = std::tuple<std::string, uint16_t, std::string, std::string>; // host, port, username, password\nusing URIPath = std::vector<std::string>;\nusing URIQuery = std::map<std::string, std::string>;\n\n/** @class URIError\n * @brief Exception when URI was not valid\n *\n */\nclass URIError : public std::runtime_error {\npublic:\n  URIError(const char *msg, const std::string &uri, size_t position);\n  explicit URIError(const std::string &what_arg) : std::runtime_error(what_arg) { }\n};\n\n/** @class URI\n * @brief Parse and create URIs according to RFC3986\n *\n * This class will parse and make the elements of the URI\n * available as members.\n *\n * Links:\n * * (RFC 3986)[https://tools.ietf.org/html/rfc3986)\n *\n */\nclass URI {\npublic:\n  /** @brief Delimiter used in the Query part */\n  static const char query_delimiter = '&';\n\n  /** @brief Default constructor\n   *\n   * Rootless URIs like \"mailto:user@example.com\" may be forbidden to make sure\n   * that simple \"host:addr\" doesn't get parsed as (scheme='host', path='addr')\n   *\n   * @param uri URI string to decode\n   * @param allow_path_rootless if parsing rootless URIs is allowed.\n   */\n  URI(const std::string &uri, bool allow_path_rootless = true) : scheme(), host(), port(0), username(), password(), path(), query(),\n                           fragment(), uri_(uri), allow_path_rootless_(allow_path_rootless) {\n    if (!uri.empty()) {\n      init_from_uri(uri);\n    }\n  };\n\n  bool operator==(const URI &u2) const;\n  bool operator!=(const URI &u2) const;\n\n  /** return string representation of the URI */\n  std::string str() const;\n\n  /** @brief overload */\n  URI() : URI(\"\") { };\n\n  /** @brief Sets URI using the given URI string\n   *\n   * @param uri URI as string\n   */\n  void set_uri(const std::string &uri) {\n    init_from_uri(uri);\n  }\n\n  /** @brief Scheme of the URI */\n  std::string scheme;\n  /** @brief Host part found in the Authority */\n  std::string host;\n  /** @brief Port found in the Authority */\n  uint16_t port;  // 0 means use default (no dynamically allocation needed here)\n  /** @brief Username part found in the Authority */\n  std::string username;\n  /** @brief Password part found in the Authority */\n  std::string password;\n  /** @brief Path part of the URI */\n  URIPath path;\n  /** @brief Query part of the URI */\n  URIQuery query;\n  /** @brief Fragment part of the URI */\n  std::string fragment;\n\nprivate:\n  /** @brief Sets information using the given URI\n   *\n   * Takes a and parsers out all URI elements.\n   *\n   * Throws URIError on errors.\n   *\n   * @param uri URI to use\n   */\n  void init_from_uri(const std::string &uri);\n\n  /** @brief Copy of the original given URI */\n  std::string uri_;\n\n  /** @brief all URIs like mail:foo@example.org which don't have a authority */\n  bool allow_path_rootless_;\n};\n\nstd::ostream& operator<<(std::ostream &strm, const URI &uri);\n\nclass URIParser {\npublic:\n  static URI parse(const std::string &uri, bool allow_path_rootless = true);\n  static URI parse_shorthand_uri(const std::string &uri, bool allow_path_rootless = true,\n      const std::string &default_scheme = \"mysql\");\n};\n\n\n} // namespace mysqlrouter\n\n#endif // URI_ROUTING_INCLUDED\n"
  },
  {
    "path": "src/router/include/mysqlrouter/utils.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_UTILS_INCLUDED\n#define MYSQLROUTER_UTILS_INCLUDED\n\n#include <chrono>\n#include <cstdarg>\n#include <cstdint>\n#include <sstream>\n#include <string>\n#include <vector>\n#include <functional>\n#ifndef _WIN32\n#  include <sys/stat.h>\n#  include <sys/types.h>\n#  include <netdb.h>\n#  include <pwd.h>\n#endif\n\n#include <stdio.h>\n#include <fstream>\n#include <iostream>\n#include <map>\n\n#include \"router_config.h\"\n\nnamespace mysqlrouter {\n\n#ifndef _WIN32\nusing perm_mode = mode_t;\n#else\nusing perm_mode = int;\n#endif\n/** @brief Constant for directory accessible only for the owner */\nextern const perm_mode kStrictDirectoryPerm;\n\n/** @class Ofstream\n *  @brief interface to std::ofstream and alternative (mock) implementations\n *\n * std::ofstream is not mockable, because its methods are not virtual. To work around this,\n * we create this interface class, which then acts as superclass to various std::ofstream\n * implementation classes.\n */\nclass Ofstream : public std::ofstream {\n public:\n  // disabled copying the ofstream constructurs as sunpro 12.5 says:\n  //\n  //   'ofstream' not in 'std::ofstream'\n  //\n  // If there is a need to have other than the no-param constructor\n  // that is inherited by default, a new solution has to be found.\n  //\n  // using std::ofstream::ofstream;\n  virtual ~Ofstream() {}\n  virtual void open(const char* filename, std::ios_base::openmode mode = std::ios_base::out) = 0;\n  virtual void open(const std::string& filename, std::ios_base::openmode mode = std::ios_base::out) = 0;\n};\n\n/** @class RealOfstream\n *  @brief simple std::ofstream adapter, needed for DI purposes\n *\n * This class is just a simple adapter for std::ofstream. It forwards all calls to std::ofstream\n */\nclass RealOfstream : public Ofstream {\n public:\n  // using Ofstream::Ofstream;\n  virtual void open(const char* filename, std::ios_base::openmode mode = std::ios_base::out) {\n    return std::ofstream::open(filename, mode);\n  }\n  virtual void open(const std::string& filename, std::ios_base::openmode mode = std::ios_base::out) {\n    return open(filename.c_str(), mode);\n  }\n};\n\n/** @class MockOfstream\n *  @brief mock implementation of std::ofstream\n *\n * The idea behind this class is to allow unit tests to run, without actually causing a mess on disk.\n * So far a minimal implementation is provided, which can be expanded as needed.\n */\nclass MockOfstream : public Ofstream {\n public:\n  MockOfstream(const char* filename, ios_base::openmode mode = ios_base::out) {\n    open(filename, mode);\n  }\n\n  // mock open\n  void open(const char* filename, ios_base::openmode mode = ios_base::out) override;\n  void open(const std::string& filename, std::ios_base::openmode mode = std::ios_base::out) override {\n    return open(filename.c_str(), mode);\n  }\n\n  // extract the original filename\n  static std::string application_to_real_filename(const std::string& application_filename) {\n    return filenames_.at(application_filename);\n  }\n\n  // run this at the end of the unit test\n  static void clean_up() {\n    for (auto filename : filenames_)\n      erase_file(filename.second);\n  }\n\n private:\n  static std::string gen_fake_filename(unsigned long i);\n  static void erase_file(const std::string& filename);\n  static std::map<std::string, std::string> filenames_; // key = application filename, value = filename on disk\n};\n\n// Some (older) compiler have no std::to_string available\ntemplate<typename T>\nstd::string to_string(const T &data) {\n  std::ostringstream os;\n  os << data;\n  return os.str();\n}\n\n// represent milliseconds as floating point seconds\nstd::string ms_to_seconds_string(const std::chrono::milliseconds &msec);\n\n/** @brief Returns string formatted using given data\n*\n* Returns string formatted using given data accepting the same arguments\n* and format specifies as the typical printf.\n*\n* @param format specify how to format the data\n* @param ... variable argument list containing the data\n* @returns formatted text as string\n*/\nstd::string string_format(const char *format, ...)\n#ifdef HAVE_ATTRIBUTE_FORMAT\n                       __attribute__((format(printf, 1, 2)))\n#endif\n;\n\n/**\n * Split host and port\n *\n * @param data a string with hostname and port\n * @return std::pair<string, uint16_t> containing address and port\n */\nstd::pair<std::string, uint16_t> split_addr_port(const std::string data);\n\n/**\n * Validates a string containing a TCP port\n *\n * Validates whether the data can be used as a TCP port. A TCP port is\n * a valid number in the range of 0 and 65535. The returned integer is\n * of type uint16_t.\n *\n * An empty data string will result in TCP port 0 to be returned.\n *\n * Throws runtime_error when the given string can not be converted\n * to an integer or when the integer is to big.\n *\n * @param data string containing the TCP port number\n * @return uint16_t the TCP port number\n */\nuint16_t get_tcp_port(const std::string& data);\n\n/** @brief Splits a string using a delimiter\n *\n * Splits a string using the given delimiter. When allow_empty\n * is true (default), tokens can be empty, and will be included\n * as empty in the result.\n *\n * @param data a string to split\n * @param delimiter a char used as delimiter\n * @param allow_empty whether to allow empty tokens or not (default true)\n * @return std::vector<string> containing tokens\n */\nstd::vector<std::string> split_string(const std::string& data, const char delimiter, bool allow_empty = true);\n\n/**\n * Removes leading whitespaces from the string\n *\n * @param str the string to be trimmed\n */\nvoid left_trim(std::string& str);\n\n/**\n * Removes trailing whitespaces from the string\n *\n * @param str the string to be trimmed\n */\nvoid right_trim(std::string& str);\n\n/**\n * Removes both leading and trailing whitespaces from the string\n *\n * @param str the string to be trimmed\n */\nvoid trim(std::string& str);\n\n/** @brief Dumps buffer as hex values\n *\n * Debugging function which dumps the given buffer as hex values\n * in rows of 16 bytes. When literals is true, characters in a-z\n * or A-Z, are printed as-is.\n *\n * @param buffer char array or front of vector<uint8_t>\n * @param count number of bytes to dump\n * @param start from where to start dumping\n * @param literals whether to show a-zA-Z as-is\n * @return string containing the dump\n */\nstd::string hexdump(const unsigned char *buffer, size_t count, long start = 0, bool literals = false);\n\n/** @brief Returns the platform specific error code of last operation\n * Using errno in UNIX & Linux systems and GetLastError in Windows systems.\n * If myerrnum arg is not zero will use GetLastError in Windows (if myerrnum is zero in Unix will read the *current* errno).\n * @return the error code description\n */\nstd::string get_last_error(int myerrnum = 0);\n\n/** @brief Prompts for a password from the console.\n */\nstd::string prompt_password(const std::string &prompt);\n\n/** @brief Override default prompt password function\n */\nvoid set_prompt_password(const std::function<std::string (const std::string &)> &f);\n\n#ifdef _WIN32\n/** @brief Returns whether if the router process is running as a Windows Service\n */\nbool is_running_as_service();\n\n/** @brief Writes to the Windows event log.\n */\nvoid write_windows_event_log(const std::string& msg);\n\n#endif\n\n/** @brief Substitutes placeholders of environment variables in a string\n *\n * Substitutes placeholders of environement variables in a string. A\n * placeholder contains the name of the variable and will be fetched\n * from the environment. The substitution is done in-place.\n *\n * Note that it is not an error to pass a string with no variable to\n * be substituted - in such case success will be returned, and the\n * original string will remain unchanged.\n * Also note, that if an error occurs, the resulting string value is\n * undefined (it will be left in an inconsistent state).\n *\n * @return bool (success flag)\n */\nbool substitute_envvar(std::string &line) noexcept;\n\n/*\n * @brief Substitutes placeholder of particular environment variable in file path.\n *\n * @param s the file path in which variable name is substituted with value\n * @param name The environment variable name\n * @param value The environment variable value\n *\n * @return path to file\n */\nstd::string substitute_variable(const std::string &s,\n                                const std::string &name,\n                                const std::string &value);\n\n/** @brief Wraps the given string\n *\n * Wraps the given string based on the spaces between words.\n * New lines are respected; carriage return and tab characters are\n * removed.\n *\n * The `width` specifies how much characters will in each line. It is also\n * possible to prefix each line with a number of spaces using the `indent_size` argument.\n *\n * @param str string to wrap\n * @param width maximum line length\n * @param indent number of spaces to prefix each line with\n * @return vector of strings\n */\nstd::vector<std::string> wrap_string(const std::string &str, size_t width, size_t indent);\n\nbool my_check_access(const std::string& path);\n\nint mkdir(const std::string& dir, perm_mode mode);\n\n/** @brief Copy contents of one file to another.\n *\n * Exception thrown if open, create read or write operation fails.\n */\nvoid copy_file(const std::string &from, const std::string &to);\n\n/** @brief renames file, returns 0 if succeed, or positive error code if fails.\n *\n * The function will overwrite the 'to' file if already exists.\n */\nint rename_file(const std::string &from, const std::string &to);\n\n/** @brief Returns whether the socket name passed as parameter is valid\n */\nbool is_valid_socket_name(const std::string &socket, std::string &err_msg);\n\n/** @brief Converts char array to signed integer, intuitively.\n *\n * Using strtol() can be daunting. This function wraps its with logic to ease\n * its use. Features:\n * - errno value is unaltered\n * - on error, default value is returned\n * - unlike strtol(), this function will fail (return default_result) if anything\n *   other than digits and sign are present in the char array. Inputs such as\n *   \" 12\" or \"abc12.3\" will fail, while strtol() would return 12.\n *\n * @param value           char array to get converted\n * @param default_result  value to return in case of nullptr being passed\n */\nint strtoi_checked(const char* value, int default_result = 0);\n\n/** @brief Converts char array to unsigned integer, intuitively.\n *         adding check for null parameter and some conversion restrictions.\n *\n * Using strtoul() can be daunting. This function wraps its with logic to ease\n * its use. Features:\n * - errno value is unaltered\n * - on error, default value is returned\n * - unlike strtoul(), this function will fail (return default_result) if anything\n *   other than digits and sign are present in the char array. Inputs such as\n *   \" 12\" or \"abc12.3\" will fail, while strtoul() would return 12.\n *\n * @param value           char array to get converted\n * @param default_result  value to return in case of nullptr being passed\n */\nunsigned strtoui_checked(const char* value, unsigned default_result = 0);\n\n#ifndef _WIN32\n\n/** @class SysUserOperationsBase\n * @brief Base class to allow multiple SysUserOperations implementations\n */\nclass SysUserOperationsBase {\n public:\n#ifdef __APPLE__\n  using gid_type = int;\n#else\n  using gid_type = gid_t;\n#endif\n  virtual ~SysUserOperationsBase() = default;\n\n  virtual int initgroups (const char *user, gid_type gid) = 0;\n  virtual int setgid(gid_t gid) = 0;\n  virtual int setuid(uid_t uid) = 0;\n  virtual int setegid(gid_t gid) = 0;\n  virtual int seteuid(uid_t uid) = 0;\n  virtual uid_t geteuid (void) = 0;\n  virtual struct passwd *getpwnam(const char *name) = 0;\n  virtual struct passwd *getpwuid(uid_t uid) = 0;\n  virtual int chown(const char *file, uid_t owner, gid_t group) = 0;\n};\n\n/** @class SysUserOperations\n * @brief This class provides implementations of SysUserOperationsBase methods\n */\nclass SysUserOperations : public SysUserOperationsBase {\n public:\n\n  static SysUserOperations* instance();\n\n  /** @brief Thin wrapper around system initgroups() */\n  int initgroups (const char *user, gid_type gid) override;\n\n  /** @brief Thin wrapper around system setgid() */\n  virtual int setgid(gid_t gid) override;\n\n  /** @brief Thin wrapper around system setuid() */\n  virtual int setuid(uid_t uid) override;\n\n  /** @brief Thin wrapper around system setegid() */\n  virtual int setegid(gid_t gid) override;\n\n  /** @brief Thin wrapper around system seteuid() */\n  virtual int seteuid(uid_t uid) override;\n\n  /** @brief Thin wrapper around system geteuid() */\n  virtual uid_t geteuid() override;\n\n  /** @brief Thin wrapper around system getpwnam() */\n  virtual struct passwd *getpwnam(const char *name) override;\n\n  /** @brief Thin wrapper around system getpwuid() */\n  virtual struct passwd *getpwuid(uid_t uid) override;\n\n  /** @brief Thin wrapper around system chown() */\n  virtual int chown(const char *file, uid_t owner, gid_t group) override;\n private:\n  SysUserOperations(const SysUserOperations&) = delete;\n  SysUserOperations operator=(const SysUserOperations&) = delete;\n  SysUserOperations() = default;\n};\n\n/** @brief Sets the owner of selected file/directory if it exists.\n *\n * @throws std::runtime_error in case of an error\n *\n * @param filepath              path to the file/directory this operation applies to\n * @param username              name of the system user that should be new owner of the file\n * @param user_info_arg         passwd structure for the system user that should be new owner of the file\n * @param sys_user_operations   object for the system specific operation that should be used by the function\n */\nvoid set_owner_if_file_exists(const std::string &filepath,\n                              const std::string &username, struct passwd *user_info_arg,\n                              mysqlrouter::SysUserOperationsBase* sys_user_operations);\n\n/** @brief Sets effective user of the calling process.\n *\n * @throws std::runtime_error in case of an error\n *\n * @param username            name of the system user that the process should switch to\n * @param permanently         if it's tru then if the root is dropping privileges it can't be regained after\n *                            this call\n * @param sys_user_operations object for the system specific operation that should be used by the function\n */\nvoid set_user(const std::string &username, bool permanently = false,\n              mysqlrouter::SysUserOperationsBase* sys_user_operations = SysUserOperations::instance());\n\n/** @brief Checks if the given user can be switched to or made an owner of a selected file.\n *\n * @throws std::runtime_error in case of an error\n *\n * @param username            name of the system user to check\n * @param must_be_root        make sure that the current user is root\n * @param sys_user_operations object for the system specific operation that should be used by the function\n * @return pointer to the user's passwd structure if the user can be switched to or nullptr otherwise\n *\n */\nstruct passwd* check_user(const std::string& username,\n                          bool must_be_root,\n                          mysqlrouter::SysUserOperationsBase* sys_user_operations);\n\n\n#endif // ! _WIN32\n\n\n} // namespace mysqlrouter\n\n/** @brief Declare test (class)\n *\n * When using FRIEND_TEST() on classes that are not in the same namespace\n * as the test, the test (class) needs to be forward-declared. This marco\n * eases this.\n *\n * @note We need this for unit tests, BUT on the TESTED code side (not in unit test code)\n */\n#define DECLARE_TEST(test_case_name, test_name)\\\n  class test_case_name##_##test_name##_Test\n\n#endif // MYSQLROUTER_UTILS_INCLUDED\n"
  },
  {
    "path": "src/router/include/mysqlrouter/utils_sqlstring.h",
    "content": "/*\n * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License, version 2.0,\n * as published by the Free Software Foundation.\n *\n * This program is also distributed with certain software (including\n * but not limited to OpenSSL) that is licensed under separate terms,\n * as designated in a particular file or component or in included license\n * documentation.  The authors of MySQL hereby grant you an additional\n * permission to link the program and your derivative works with the\n * separately licensed software that they have included with MySQL.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n */\n\n#ifndef _UTILS_SQLSTRING_H_\n#define _UTILS_SQLSTRING_H_\n\n#ifndef __STDC_FORMAT_MACROS\n#define __STDC_FORMAT_MACROS 1\n#endif\n#include <inttypes.h>\n#include <string>\n\n#include <stdexcept>\n\nnamespace mysqlrouter {\n\nenum SqlStringFlags {\n  QuoteOnlyIfNeeded = 1 << 0,\n  UseAnsiQuotes = 1 << 1,\n\n  EndOfInput = 1 << 7\n};\n\nstd::string escape_sql_string(const std::string &string, bool wildcards = false); // \"strings\" or 'strings'\nstd::string escape_backticks(const std::string &string);  // `identifier`\nstd::string quote_identifier(const std::string& identifier, const char quote_char);\nstd::string quote_identifier_if_needed(const std::string &ident, const char quote_char);\n\nclass sqlstring {\npublic:\n  struct sqlstringformat {\n    int _flags;\n    sqlstringformat(const int flags) : _flags(flags) {}\n  };\n\nprivate:\n  std::string _formatted;\n  std::string _format_string_left;\n  sqlstringformat _format;\n\n  std::string consume_until_next_escape();\n  int next_escape();\n\n  sqlstring& append(const std::string &s);\npublic:\n  static const sqlstring null;\n  static const sqlstring end;\n\n  sqlstring();\n  sqlstring(const char* format_string, const sqlstringformat format = 0);\n  sqlstring(const sqlstring &copy);\n  bool done() const;\n\n  operator std::string() const;\n  std::string str() const;\n\n  //! modifies formatting options\n  sqlstring &operator <<(const sqlstringformat);\n  //! replaces a ? in the format string with a float numeric value\n  sqlstring &operator <<(const float val) { return operator<<((double)val); }\n  //! replaces a ? in the format string with a double numeric value\n  sqlstring &operator <<(const double);\n  //! replaces a ? in the format string with a quoted string value or ! with a back-quoted identifier value\n  sqlstring &operator <<(const std::string&);\n  //! replaces a ? in the format string with a quoted string value or ! with a back-quoted identifier value\n  //! is the value is NULL, ? will be replaced with a NULL. ! will raise an exception\n  sqlstring &operator <<(const char*);\n  //! replaces a ? or ! with the content of the other string verbatim\n  sqlstring &operator <<(const sqlstring&);\n  //! replaces a ? in the format string with any integer numeric value\n  template<typename T>\n  sqlstring &operator <<(const T value) {\n    int esc = next_escape();\n    if (esc != '?')\n        throw std::invalid_argument(\"Error formatting SQL query: invalid escape for numeric argument\");\n    append(std::to_string(value));\n    append(consume_until_next_escape());\n    return *this;\n  }\n};\n}\n\n#endif\n"
  },
  {
    "path": "src/router/include/mysqlrouter/windows/password_vault.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef SRC_ROUTER_INCLUDE_MYSQLROUTER_WINDOWS_PASSWORD_VAULT_H_\n#define SRC_ROUTER_INCLUDE_MYSQLROUTER_WINDOWS_PASSWORD_VAULT_H_\n\n#include <map>\n#include <string>\n\n\n\nclass PasswordVault {\n public:\n  /** @brief Create an instance of the vault.\n   *\n   * On creation the vault cache is initialized with the contents of the vault\n   * file at %APPDATA%/MySQL/MySQL Router/mysql_router_user_data.dat.\n   * The passwords are stored in the cache in cleartext.\n   */\n  PasswordVault();\n\n  /** @brief wipes the contents of the vault cache.\n   */\n  ~PasswordVault();\n\n  /** @brief Updates a pair (section name, password) in the vault cache.\n   *\n   * If the record for the given section name & password does not exits, it is\n   * created. If it exists it is just updated with the new password.\n   *\n   * @param section_name The name of the configuration section to store in the\n   *   vault.\n   * @param password The password, in clear text, of the user in the\n   *   configuration section to store in the vault.\n   */\n  void update_password(const std::string& section_name, const std::string& password);\n\n  /** @brief Retrieves the password, in clear text, for the given section as\n   *     is stored in the vault.\n   *\n   * @param section_name The name of the configuration section for which to \n   *   retrieve the password.\n   * @param out_password Output paramter. The password in clear text if the \n   *   section name was found in the vault.\n   * @return true if a password was retrieved for the given section, false if \n   *   the section name could not be found in the vault.\n   */\n  bool get_password(const std::string& section_name, std::string& out_password) const;\n\n  /** @brief Removes the password from the vault for the given section name.\n   * \n   * After executing this method for a fiven section name, the method \n   *   get_password will return false for the same section name.\n   *\n   * @param section_name The name of the configuration section for which to \n   *   remove the password.\n   */\n  void remove_password(const std::string& section_name);\n\n  /** @brief Stores the vault cache into persistent storage in encrypted form.\n   *\n   * The vault location in persistent storage is \n   * %APPDATA%/MySQL/MySQL Router/mysql_router_user_data.dat.\n   */\n  void store_passwords();\n\n  /** @brief Wipes the contents of the vault file.\n   * \n   * NOTE: The delete the vault cache (in memory) created for an instance of \n   * PasswordVault is done automatically in the destructor.\n   */\n  void clear_passwords();\n\n private:\n  void load_passwords();\n  std::string get_vault_path() const;\n  // Password cache as pairs <section_name, password>\n  std::map<std::string, std::string> _passwords;\n  void password_scrambler(std::string& pass);\n};\n\n#endif  // SRC_ROUTER_INCLUDE_MYSQLROUTER_WINDOWS_PASSWORD_VAULT_H_\n"
  },
  {
    "path": "src/router/src/CMakeLists.txt",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n# MS Visual C++ specifics\nif(\"${CMAKE_CXX_COMPILER_ID}\" STREQUAL \"MSVC\")\n  add_definitions(-D_CRT_SECURE_NO_WARNINGS)  # bypass Warning C4996 (getenv)\nendif()\n\ninclude(${CMAKE_SOURCE_DIR}/cmake/compile_flags.cmake)\n\ninclude_directories(${CMAKE_CURRENT_SOURCE_DIR}/../include/mysqlrouter\n  ${SSL_INCLUDE_DIRS}\n  ${RAPIDJSON_INCLUDE_DIRS})\n\nif(WITH_SSL STREQUAL \"bundled\")\n  set(MY_AES_IMPL common/my_aes_yassl.cc)\n  add_definitions(-DSIZEOF_LONG=${SIZEOF_LONG} -DSIZEOF_LONG_LONG=${SIZEOF_LONG_LONG})\nelse()\n  set(MY_AES_IMPL common/my_aes_openssl.cc)\nendif()\n\nadd_definitions(${SSL_DEFINES})\n\n\nset(lib_source_files\n  config_files.cc\n  config_generator.cc\n  cluster_metadata.cc\n  router_app.cc\n  utils.cc\n  uri.cc\n  keyring_info.cc\n  plugin_config.cc\n  common/log_filter.cc\n  # common/my_aes.cc\n  common/my_sha1.cc\n  common/mysql_session.cc\n  common/utils_sqlstring.cc\n  # ${MY_AES_IMPL}\n  )\nif(WIN32)\n  list(APPEND lib_source_files windows/nt_servc.cc windows/main-windows.cc windows/password_vault.cc)\nendif()\n\n# Disable warnings from 3rd party code that we have no control over\nif(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES \"Clang\")\n  add_compile_flags(common/my_aes.cc common/my_sha1.cc ${MY_AES_IMPL} COMPILE_FLAGS\n      -Wno-sign-conversion\n      -Wno-unused-parameter\n      -Wno-conversion)\nendif()\n\nset(source_files main.cc)\n\nif(NOT WIN32)\n  add_library(router_lib SHARED ${lib_source_files} ${common_files})\nelse()\n  # on Windows, we statically link the router lib to otherwise avoid exporting a bunch of symbols\n  add_library(router_lib STATIC ${lib_source_files})\nendif()\ntarget_link_libraries(router_lib ${CMAKE_DL_LIBS} harness-library ${MySQL_LIBRARIES} ${SSL_LIBRARIES})\nif(WIN32)\n  target_link_libraries(router_lib crypt32)\nendif()\ntarget_include_directories(router_lib PUBLIC ../include ${MySQL_INCLUDE_DIRS})\nif(WITH_HARNESS)\n  target_include_directories(router_lib PUBLIC \"${PROJECT_BINARY_DIR}\")\n  target_include_directories(router_lib PUBLIC \"${PROJECT_BINARY_DIR}/include/mysql/harness\")\n  target_include_directories(router_lib PUBLIC \"${PROJECT_BINARY_DIR}/include\")\n  target_include_directories(router_lib PUBLIC \"${PROJECT_BINARY_DIR}/harness\")\nendif()\nset_target_output_directory(router_lib LIBRARY_OUTPUT_DIRECTORY lib)\nif(NOT WIN32)\n  set_target_properties(router_lib PROPERTIES\n    OUTPUT_NAME \"mysqlrouter\"\n    SOVERSION 1\n  )\nelse()\n  set_target_properties(router_lib PROPERTIES\n    OUTPUT_NAME \"mysqlrouter_lib\"\n    SOVERSION 1\n  )\nendif()\n\nadd_executable(${MYSQL_ROUTER_TARGET} ${source_files})\ntarget_link_libraries(${MYSQL_ROUTER_TARGET} ${CMAKE_DL_LIBS} router_lib harness-library)\nif(WIN32)\n  target_link_libraries(${MYSQL_ROUTER_TARGET} crypt32)\nendif()\nif(CMAKE_SYSTEM_NAME STREQUAL \"SunOS\")\n  target_link_libraries(${MYSQL_ROUTER_TARGET} -lnsl -lsocket)\nendif()\n\nset_target_output_directory(${MYSQL_ROUTER_TARGET} RUNTIME_OUTPUT_DIRECTORY bin)\n\nif(WIN32)\n  if(TARGET libmysql)\n    # if we are part of the server tree, copy the target file directly\n    add_custom_command(TARGET ${MYSQL_ROUTER_TARGET} PRE_BUILD\n                          COMMAND ${CMAKE_COMMAND} -E copy\n                          $<TARGET_FILE:libmysql> $<TARGET_FILE_DIR:${MYSQL_ROUTER_TARGET}>/)\n  else()\n    set(MYSQL_DLL ${MySQL_LIBRARIES})\n    string(REPLACE \".lib\" \".dll\" MYSQL_DLL ${MYSQL_DLL})\n    get_filename_component(MYSQL_FILE ${MYSQL_DLL} NAME)\n    get_filename_component(MYSQL_DLL ${MYSQL_DLL} DIRECTORY)\n\n    # Copies the dll to the binary location to enable debugging\n    add_custom_command(TARGET ${MYSQL_ROUTER_TARGET} PRE_BUILD\n                          COMMAND ${CMAKE_COMMAND} -E copy\n                          \"${MYSQL_DLL}/${MYSQL_FILE}\" $<TARGET_FILE_DIR:${MYSQL_ROUTER_TARGET}>/${MYSQL_FILE})\n    install(FILES \"${MYSQL_DLL}/${MYSQL_FILE}\" DESTINATION bin)\n  endif()\n\n  IF (WITH_SSL_PATH)\n    GET_FILENAME_COMPONENT(CRYPTO_NAME \"${CRYPTO_LIBRARY}\" NAME_WE)\n    GET_FILENAME_COMPONENT(OPENSSL_NAME \"${OPENSSL_LIBRARY}\" NAME_WE)\n    FILE(GLOB HAVE_CRYPTO_DLL \"${WITH_SSL_PATH}/bin/${CRYPTO_NAME}.dll\")\n    FILE(GLOB HAVE_OPENSSL_DLL \"${WITH_SSL_PATH}/bin/${OPENSSL_NAME}.dll\")\n    IF (HAVE_CRYPTO_DLL AND HAVE_OPENSSL_DLL)\n      install(FILES \"${HAVE_CRYPTO_DLL}\" DESTINATION bin)\n      install(FILES \"${HAVE_OPENSSL_DLL}\" DESTINATION bin)\n    ENDIF()\n  ENDIF()\n\nendif()\n\nCOPY_OPENSSL_DLLS(${MYSQL_ROUTER_TARGET} $<TARGET_FILE_DIR:${MYSQL_ROUTER_TARGET}>)\n\nif(CMAKE_SYSTEM_NAME STREQUAL \"Darwin\")\n  set_target_properties(${MYSQL_ROUTER_TARGET} PROPERTIES\n    LINK_FLAGS \"-undefined dynamic_lookup\")\nelseif(CMAKE_COMPILER_IS_GNUCXX)\nendif()\n\n# For testing\nif(ENABLE_TESTS)\n  file(GLOB config_files ${CMAKE_CURRENT_SOURCE_DIR}/../tests/*.conf.in)\n  if(CMAKE_CFG_INTDIR STREQUAL \".\")\n    set(ROUTER_STAGE_DIR ${MySQLRouter_BINARY_STAGE_DIR})\n    if(WIN32)\n      set(ROUTER_PLUGIN_DIR_SUFFIX \"lib\")\n    else()\n      set(ROUTER_PLUGIN_DIR_SUFFIX \"lib/mysqlrouter\")\n    endif()\n    foreach(config_file ${config_files})\n      get_filename_component(dest_config_file ${config_file} NAME)\n      string(REGEX REPLACE \".in$\" \"\" dest_config_file ${dest_config_file})\n      configure_file(${config_file} ${MySQLRouter_BINARY_STAGE_DIR}/etc/${dest_config_file})\n    endforeach()\n  else()\n    foreach(conf ${CMAKE_CONFIGURATION_TYPES})\n      set(ROUTER_STAGE_DIR ${MySQLRouter_BINARY_STAGE_DIR}/${conf})\n      set(ROUTER_PLUGIN_DIR_SUFFIX \"lib\")\n      foreach(config_file ${config_files})\n        get_filename_component(dest_config_file ${config_file} NAME)\n        string(REGEX REPLACE \".in$\" \"\" dest_config_file ${dest_config_file})\n        configure_file(${config_file} ${MySQLRouter_BINARY_STAGE_DIR}/${conf}/etc/${dest_config_file})\n      endforeach()\n    endforeach()\n  endif()\nendif()\n\ninstall(TARGETS ${MYSQL_ROUTER_TARGET} router_lib\n  RUNTIME DESTINATION ${INSTALL_BINDIR}\n  LIBRARY DESTINATION ${INSTALL_LIBDIR}\n  ARCHIVE DESTINATION ${INSTALL_LIBDIR})\n\nif (WIN32)\n  install(FILES $<TARGET_PDB_FILE:${MYSQL_ROUTER_TARGET}> DESTINATION bin)\nendif()\n"
  },
  {
    "path": "src/router/src/cluster_metadata.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n\n#include \"cluster_metadata.h\"\n#include \"common.h\"\n#include \"mysqlrouter/utils.h\"\n#include \"mysqlrouter/utils_sqlstring.h\"\n#include \"mysql/harness/logging/logging.h\"\nIMPORT_LOG_FUNCTIONS()\n\n#include <string.h>\n#ifdef _WIN32\n#  define strcasecmp _stricmp\n#endif\n\n// Semantic version number that this Router version supports\nstatic const int kClusterRequiredMetadataMajorVersion = 1;\nstatic const int kClusterRequiredMetadataMinorVersion = 0;\nstatic const int kClusterRequiredMetadataPatchVersion = 0;\n\nusing mysqlrouter::strtoi_checked;\nusing mysqlrouter::sqlstring;\nusing mysqlrouter::MySQLSession;\nusing mysqlrouter::MySQLInnoDBClusterMetadata;\n\nstatic bool version_matches(const std::tuple<int,int,int> &required,\n                            const std::tuple<int,int,int> &available) {\n  // incompatible metadata\n  if (std::get<0>(available) != std::get<0>(required) ||\n    // metadata missing stuff we need\n    (std::get<1>(available) < std::get<1>(required)) ||\n    // metadata missing bugfixes we're expecting\n    (std::get<1>(available) == std::get<1>(required) &&\n      std::get<2>(available) < std::get<2>(required))) {\n    return false;\n  }\n  return true;\n}\n\n\nstatic bool check_version(MySQLSession *mysql, std::tuple<int,int,int> &version) {\n  std::unique_ptr<MySQLSession::ResultRow> result(mysql->query_one(\"SELECT * FROM mysql_innodb_cluster_metadata.schema_version\"));\n  if (!result) {\n    throw std::runtime_error(\"Invalid MySQL InnoDB cluster metadata\");\n  }\n\n  int major, minor, patch;\n\n  size_t result_size = result->size();\n  if (result_size == 3) {\n    major = strtoi_checked((*result)[0]);\n    minor = strtoi_checked((*result)[1]);\n    patch = strtoi_checked((*result)[2]);\n  } else if (result_size == 2) {\n    // Initially shell used to create version number with 2 digits only (1.0)\n    // It has since moved to 3 digit numbers. We normalize it to 1.0.0 here for\n    // simplicity and backwards compatibility.\n    major = 1;\n    minor = 0;\n    patch = 0;\n  }\n  else {\n    throw std::out_of_range(\"Invalid number of values returned from mysql_innodb_cluster_metadata.schema_version: \"\n                             \"expected 2 or 3 got \" + std::to_string(result_size));\n  }\n  version = std::make_tuple(major, minor, patch);\n\n  if (!version_matches(std::make_tuple(kClusterRequiredMetadataMajorVersion,\n                                      kClusterRequiredMetadataMinorVersion,\n                                      kClusterRequiredMetadataPatchVersion),\n                      version)) {\n    // log_error(\"Metadata schema version is %d.%d.%d, while we require at least %d.%d.%d\",\n    //           major, minor, patch,\n    //           kClusterRequiredMetadataMajorVersion,\n    //           kClusterRequiredMetadataMinorVersion,\n    //           kClusterRequiredMetadataPatchVersion);\n    return false;\n  }\n  //log_debug(\"Metadata schema version is %d.%d.%d, required is at least %d.%d.%d\",\n  //           major, minor, patch,\n  //           kClusterRequiredMetadataMajorVersion,\n  //           kClusterRequiredMetadataMinorVersion,\n  //           kClusterRequiredMetadataPatchVersion);\n  return true;\n}\n\nstatic bool check_group_replication_online(MySQLSession *mysql) {\n  std::string q = \"SELECT member_state\"\n                  \" FROM performance_schema.replication_group_members\"\n                  \" WHERE member_id = @@server_uuid\";\n  std::unique_ptr<MySQLSession::ResultRow> result(mysql->query_one(q));\n  if (result && (*result)[0]) {\n    if (strcmp((*result)[0], \"ONLINE\") == 0)\n      return true;\n    // log_warning(\"Member state for current server is %s\", (*result)[0]);\n    return false;\n  }\n  throw std::logic_error(\"No result returned for metadata query\");\n}\n\nstatic bool check_group_has_quorum(MySQLSession *mysql) {\n  std::string q = \"SELECT SUM(IF(member_state = 'ONLINE', 1, 0)) as num_onlines, COUNT(*) as num_total\"\n                  \" FROM performance_schema.replication_group_members\";\n\n  std::unique_ptr<MySQLSession::ResultRow> result(mysql->query_one(q));\n  if (result) {\n    if (result->size() != 2) {\n      throw std::out_of_range(\"Invalid number of values returned from performance_schema.replication_group_members: \"\n                              \"expected 2 got \" + std::to_string(result->size()));\n    }\n    int online = strtoi_checked((*result)[0]);\n    int all = strtoi_checked((*result)[1]);\n    //log_info(\"%d members online out of %d\", online, all);\n    if (online >= all/2+1)\n      return true;\n    return false;\n  }\n\n  throw std::logic_error(\"No result returned for metadata query\");\n}\n\nstatic void get_group_member_config(MySQLSession *mysql, int &ret_single_primary_mode, std::string &ret_primary_server_uuid, std::string &ret_my_server_uuid) {\n  std::string q = \"SELECT @@group_replication_single_primary_mode=1 as single_primary_mode, \"\n                  \"       (SELECT variable_value FROM performance_schema.global_status WHERE variable_name='group_replication_primary_member') as primary_member, \"\n                  \"        @@server_uuid as my_uuid\";\n\n  std::unique_ptr<MySQLSession::ResultRow> result(mysql->query_one(q));\n  if (!result) {\n    throw std::logic_error(\"Expected resultset, got nothing for: \" + q);\n  }\n\n  if (result->size() != 3) {\n    throw std::out_of_range(\"Invalid number of values returned from query for primary: \"\n                            \"expected 3 got \" + std::to_string(result->size()));\n  }\n\n  ret_single_primary_mode = strtoi_checked((*result)[0]);\n  ret_primary_server_uuid = (*result)[1];\n  ret_my_server_uuid = (*result)[2];\n}\n\nstatic bool check_group_member_is_primary(MySQLSession *mysql, std::string &ret_primary) {\n  int single_primary_mode;\n  std::string my_server_uuid;\n\n  get_group_member_config(mysql, single_primary_mode, ret_primary, my_server_uuid);\n\n  return (single_primary_mode == 0 || ret_primary == my_server_uuid);\n}\n\nstatic bool check_metadata_is_supported(MySQLSession *mysql,\n      const std::tuple<int,int,int> &version) {\n  // check if there's only 1 cluster and 1 replicaset and that this member\n  // is in that replicaset\n  std::string q = \"SELECT \"\n                  \" ((SELECT count(*) FROM mysql_innodb_cluster_metadata.clusters) <= 1\"\n                  \"  AND (SELECT count(*) FROM mysql_innodb_cluster_metadata.replicasets) <= 1) as has_one_replicaset,\"\n                  \" (SELECT attributes->>'$.group_replication_group_name' FROM mysql_innodb_cluster_metadata.replicasets)\"\n                  \"  = @@group_replication_group_name as replicaset_is_ours\";\n\n  std::unique_ptr<MySQLSession::ResultRow> result(mysql->query_one(q));\n  if (result) {\n    if (result->size() != 2) {\n      throw std::out_of_range(\"Invalid number of values returned from query for metadata support: \"\n                              \"expected 2 got \" + std::to_string(result->size()));\n    }\n    bool has_only_one_replicaset = strtoi_checked((*result)[0]) == 1;\n    bool replicaset_is_ours = true;\n    if (version_matches(std::make_tuple(1, 0, 1), version))\n      replicaset_is_ours = strtoi_checked((*result)[1]) == 1;\n\n    // log_info(\"Replicaset/Cluster is unique = %i, Replicaset is our own = %i\",\n    //           has_only_one_replicaset, replicaset_is_ours);\n    return has_only_one_replicaset && replicaset_is_ours;\n  }\n  throw std::logic_error(\"No result returned for metadata query\");\n}\n\nvoid mysqlrouter::require_innodb_metadata_is_ok(MySQLSession *mysql) {\n  std::tuple<int,int,int> mdversion;\n\n  if (!check_version(mysql, mdversion)) {\n    throw std::runtime_error(\"This version of MySQL Router is not compatible with the provided MySQL InnoDB cluster metadata.\");\n  }\n\n  if (!check_metadata_is_supported(mysql, mdversion)) {\n    throw std::runtime_error(\"The provided server contains an unsupported InnoDB cluster metadata.\");\n  }\n}\n\nvoid mysqlrouter::require_innodb_group_replication_is_ok(MySQLSession *mysql) {\n  if (!check_group_replication_online(mysql)) {\n    throw std::runtime_error(\"The provided server is currently not an ONLINE member of a InnoDB cluster.\");\n  }\n\n  if (!check_group_has_quorum(mysql)) {\n    throw std::runtime_error(\"The provided server is currently not in a InnoDB cluster group with quorum and thus may contain inaccurate or outdated data.\");\n  }\n}\n\n\nvoid mysqlrouter::check_innodb_metadata_cluster_session(MySQLSession *mysql,\n                                                        bool read_only_ok) {\n  // check that the server has the metadata in the correct version\n  // check that the server we're querying contains metadata for the group it's in\n  //   (metadata server group must be same as managed group currently)\n  // check that the server we're bootstrapping from has GR enabled\n  // check that the server we're bootstrapping from has quorum\n  // check that the server we're bootstrapping from is not super_read_only\n  try {\n    std::tuple<int,int,int> mdversion;\n\n    if (!check_version(mysql, mdversion)) {\n      throw std::runtime_error(\"This version of MySQL Router is not compatible with the provided MySQL InnoDB cluster metadata.\");\n    }\n\n    if (!check_metadata_is_supported(mysql, mdversion)) {\n      throw std::runtime_error(\"The provided server contains an unsupported InnoDB cluster metadata.\");\n    }\n\n    if (!check_group_replication_online(mysql)) {\n      throw std::runtime_error(\"The provided server is currently not an ONLINE member of a InnoDB cluster.\");\n    }\n\n    if (!check_group_has_quorum(mysql)) {\n      throw std::runtime_error(\"The provided server is currently not in a InnoDB cluster group with quorum and thus may contain inaccurate or outdated data.\");\n    }\n\n    std::string primary;\n    if (!read_only_ok && !check_group_member_is_primary(mysql, primary)) {\n      throw std::runtime_error(\"The provided server is not an updatable member of the cluster. Please try again with the Primary member of the replicaset\" + (primary.empty() ? std::string(\".\") : \" (\"+primary+\").\"));\n    }\n  } catch (MySQLSession::Error &e) {\n    /*\n     * If the metadata cache is missing:\n     * - MySQL server before version 8.0 returns error: Table 'mysql_innodb_cluster_metadata.schema_version' doesn't exist (1146)\n     * - MySQL server version 8.0 returns error: Unknown database 'mysql_innodb_cluster_metadata' (1049).\n     * We handle both codes the same way here.\n     */\n    if (e.code() == 1146 || e.code() == 1049) {\n      throw std::runtime_error(\"The provided server does not seem to contain metadata for a MySQL InnoDB cluster\");\n    }\n    throw;\n  }\n}\n\nvoid MySQLInnoDBClusterMetadata::check_router_id(uint32_t router_id,\n                                                 const std::string& hostname_override) {\n  // query metadata for this router_id\n  sqlstring query(\"SELECT h.host_id, h.host_name\"\n                  \" FROM mysql_innodb_cluster_metadata.routers r\"\n                  \" JOIN mysql_innodb_cluster_metadata.hosts h\"\n                  \"    ON r.host_id = h.host_id\"\n                  \" WHERE r.router_id = ?\");\n  query << router_id << sqlstring::end;\n  std::unique_ptr<MySQLSession::ResultRow> row(mysql_->query_one(query));\n  if (!row) {\n    //log_warning(\"router_id %u not in metadata\", router_id);\n    throw std::runtime_error(\"router_id \"+std::to_string(router_id)+\" not found in metadata\");\n  }\n\n  // get_local_hostname() throws LocalHostnameResolutionError (std::runtime_error)\n  std::string hostname = hostname_override.empty()\n                       ? socket_operations_->get_local_hostname()\n                       : hostname_override;\n\n  if ((*row)[1] && strcasecmp((*row)[1], hostname.c_str()) == 0) {\n    return;\n  }\n  //log_warning(\"router_id %u maps to an instance at hostname %s, while this hostname is %s\",\n  //                router_id, row[1], hostname.c_str());\n\n  // if the host doesn't match, we force a new router_id to be generated\n  throw std::runtime_error(\"router_id \" + std::to_string(router_id)\n      + \" is associated with a different host ('\"+(*row)[1]+\"' vs '\"+hostname+\"')\");\n}\n\nvoid MySQLInnoDBClusterMetadata::update_router_info(uint32_t router_id,\n    const std::string &rw_endpoint,\n    const std::string &ro_endpoint,\n    const std::string &rw_x_endpoint,\n    const std::string &ro_x_endpoint) {\n\n  sqlstring query(\"UPDATE mysql_innodb_cluster_metadata.routers\"\n                  \" SET attributes = \"\n                  \"   JSON_SET(JSON_SET(JSON_SET(JSON_SET(attributes,\"\n                  \"    'RWEndpoint', ?),\"\n                  \"    'ROEndpoint', ?),\"\n                  \"    'RWXEndpoint', ?),\"\n                  \"    'ROXEndpoint', ?)\"\n                  \" WHERE router_id = ?\");\n  query << rw_endpoint;\n  query << ro_endpoint;\n  query << rw_x_endpoint;\n  query << ro_x_endpoint;\n  query << router_id;\n  query << sqlstring::end;\n\n  mysql_->execute(query);\n}\n\nuint32_t MySQLInnoDBClusterMetadata::register_router(\n    const std::string &router_name, bool overwrite,\n    const std::string &hostname_override) {\n  uint32_t host_id;\n\n  // get_local_hostname() throws LocalHostnameResolutionError (std::runtime_error)\n  std::string hostname = hostname_override.empty()\n                       ? socket_operations_->get_local_hostname()\n                       : hostname_override;\n\n  // check if the host already exists in the metadata schema and if so, get\n  // our host_id.. if it doesn't, insert it and get the host_id\n  sqlstring query(\"SELECT host_id, host_name, ip_address\"\n                   \" FROM mysql_innodb_cluster_metadata.hosts\"\n                   \" WHERE host_name = ?\"\n                   \" LIMIT 1\");\n  query << hostname << sqlstring::end;\n  {\n    std::unique_ptr<MySQLSession::ResultRow> row(mysql_->query_one(query));\n    if (!row) {\n      // host is not known to the metadata, register it\n      query = sqlstring(\"INSERT INTO mysql_innodb_cluster_metadata.hosts\"\n                        \"        (host_name, location, attributes)\"\n                        \" VALUES (?, '', \"\n                        \"         JSON_OBJECT('registeredFrom', 'mysql-router'))\");\n      query << hostname << sqlstring::end;\n      mysql_->execute(query);\n      host_id = static_cast<uint32_t>(mysql_->last_insert_id());\n      // log_info(\"host_id for local host '%s' newly registered as '%u'\",\n      //        hostname.c_str(), host_id);\n    } else {\n      host_id = static_cast<uint32_t>(std::strtoul((*row)[0], NULL, 10));\n      // log_info(\"host_id for local host '%s' already registered as '%u'\",\n      //        hostname.c_str(), host_id);\n    }\n  }\n  // now insert the router and get the router id\n  query = sqlstring(\"INSERT INTO mysql_innodb_cluster_metadata.routers\"\n                    \"        (host_id, router_name)\"\n                    \" VALUES (?, ?)\");\n  // log_info(\"Router instance '%s' registered with id %u\", router_name.c_str(), router_id);\n  query << host_id << router_name << sqlstring::end;\n  try {\n    mysql_->execute(query);\n  } catch (MySQLSession::Error &e) {\n    if (e.code() == 1062 && overwrite)  {\n      //log_warning(\"Replacing instance %s (host_id %i) of router\",\n      //            router_name.c_str(), host_id);\n      query = sqlstring(\"SELECT router_id FROM mysql_innodb_cluster_metadata.routers\"\n                        \" WHERE host_id = ? AND router_name = ?\");\n      query << host_id << router_name << sqlstring::end;\n      std::unique_ptr<MySQLSession::ResultRow> row(mysql_->query_one(query));\n      if (row) {\n        return static_cast<uint32_t>(std::stoul((*row)[0]));\n      }\n    }\n    throw;\n  }\n  return static_cast<uint32_t>(mysql_->last_insert_id());\n}\n\n"
  },
  {
    "path": "src/router/src/cluster_metadata.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef ROUTER_CLUSTER_METADATA_INCLUDED\n#define ROUTER_CLUSTER_METADATA_INCLUDED\n\n#include \"config_generator.h\"\n#include \"mysqlrouter/mysql_session.h\"\n#include \"socket_operations.h\"\n\nnamespace mysqlrouter {\n\nclass MySQLInnoDBClusterMetadata {\npublic:\n  MySQLInnoDBClusterMetadata(MySQLSession *mysql,\n                             mysql_harness::SocketOperationsBase *sockops =\n                                 mysql_harness::SocketOperations::instance())\n  : mysql_(mysql), socket_operations_(sockops) {}\n\n  /** @brief Checks if Router with id is already registered in metadata database\n   *\n   * @param router_id Router id\n   * @param hostname_override If non-empty, this hostname will be used instead\n   *        of getting queried from OS\n   *\n   * @throws LocalHostnameResolutionError(std::runtime_error) on hostname query\n   *         failure, std::runtime_error on other failure\n   */\n  void check_router_id(uint32_t router_id, const std::string& hostname_override = \"\");\n\n  /** @brief Registers Router in metadata database\n   *\n   * @param router_name Router name\n   * @param overwrite if Router name is already registered, allow this registration\n   *        to be \"hijacked\" instead of throwing\n   * @param hostname_override If non-empty, this hostname will be used instead\n   *        of getting queried from OS\n   *\n   * @throws LocalHostnameResolutionError(std::runtime_error) on hostname query\n   *         failure, std::runtime_error on other failure\n   */\n  uint32_t register_router(const std::string &router_name, bool overwrite,\n                           const std::string &hostname_override = \"\");\n\n  void update_router_info(uint32_t router_id,\n    const std::string &rw_endpoint,\n    const std::string &ro_endpoint,\n    const std::string &rw_x_endpoint,\n    const std::string &ro_x_endpoint);\nprivate:\n  MySQLSession *mysql_;\n  mysql_harness::SocketOperationsBase *socket_operations_;\n};\n\n\nvoid check_innodb_metadata_cluster_session(MySQLSession *mysql, bool read_only_ok);\nvoid require_innodb_metadata_is_ok(MySQLSession *mysql);\nvoid require_innodb_group_replication_is_ok(MySQLSession *mysql);\n\n}\n\n#endif //ROUTER_CLUSTER_METADATA_INCLUDED\n"
  },
  {
    "path": "src/router/src/common/log_filter.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysqlrouter/log_filter.h\"\n#include <stdexcept>\n\n#ifdef _WIN32\n#define USE_STD_REGEX\n#endif\n\n#include <algorithm>\n#include <sstream>\n#include <iterator>\n\nnamespace mysqlrouter {\n\nconst char LogFilter::kFillCharacter = '*';\n\nnamespace {\n#ifdef USE_STD_REGEX\nsize_t get_result_size(size_t original_size,\n    const std::smatch& matches,\n    const std::vector<size_t>& group_index_vector) {\n  size_t hash_groups_size = 0;\n  for (size_t group_index : group_index_vector) {\n    hash_groups_size += matches[group_index].length();\n  }\n  return original_size - hash_groups_size\n      + group_index_vector.size() * LogFilter::kFillSize;\n}\n#else\nsize_t get_result_size(size_t original_size, regmatch_t* matches,\n    const std::vector<size_t>& group_index_vector) {\n\n  size_t replaced_text_size = 0;\n  for(size_t group_index : group_index_vector) {\n    replaced_text_size += (matches[group_index].rm_eo - matches[group_index].rm_so);\n  }\n\n  return original_size - replaced_text_size\n      + group_index_vector.size() * LogFilter::kFillSize;\n}\n#endif\n}\n\nstd::string LogFilter::filter(const std::string& statement) const {\n#ifdef USE_STD_REGEX\n  for(const auto& each : patterns_) {\n    std::smatch matches;\n    if (std::regex_search(statement, matches, each.first)) {\n      const std::vector<size_t>& group_index_vector = each.second;\n      std::string result;\n      result.reserve(get_result_size(statement.size(), matches, group_index_vector));\n      auto statement_iterator = statement.begin();\n      for(size_t group_index : group_index_vector) {\n        if (matches[group_index].matched) {\n          std::copy(statement_iterator, matches[group_index].first,\n              std::back_inserter(result));\n          std::fill_n(std::back_inserter(result), LogFilter::kFillSize, LogFilter::kFillCharacter);\n          statement_iterator = matches[group_index].second;\n        }\n        else {\n          // This should never happen\n          throw std::logic_error(\"regex group is NOT matched\");\n        }\n      }\n      std::copy(statement_iterator, statement.end(), std::back_inserter(result));\n      return result;\n    }\n  }\n#else\n  for(const auto& each : patterns_) {\n    int r_err;\n    constexpr size_t kMaxExpectedGroups = 5;\n    regmatch_t matches[kMaxExpectedGroups];\n    r_err = regexec(&each.first, statement.c_str(),\n        sizeof(matches)/sizeof(matches[0]), matches, 0);\n    if (r_err == 0) {\n      const std::vector<size_t>& group_index_vector = each.second;\n      std::string result;\n      result.reserve(get_result_size(statement.size(), matches, group_index_vector));\n      auto statement_iterator = statement.begin();\n      for(size_t group_index : group_index_vector) {\n        std::copy(statement_iterator, statement.begin() + matches[group_index].rm_so,\n            std::back_inserter(result));\n        std::fill_n(std::back_inserter(result), LogFilter::kFillSize, LogFilter::kFillCharacter);\n        statement_iterator = statement.begin() + matches[group_index].rm_eo;\n      }\n      std::copy(statement_iterator, statement.end(), std::back_inserter(result));\n      return result;\n    }\n  }\n#endif\n  return statement;\n}\n\nvoid LogFilter::add_pattern(const std::string& pattern, size_t group_index) {\n  add_pattern(pattern, std::vector<size_t>(1, group_index));\n}\n\nvoid LogFilter::add_pattern(const std::string& pattern,\n                            const std::vector<size_t>& group_indices) {\n#ifdef USE_STD_REGEX\n  patterns_.push_back(std::make_pair(std::regex(pattern), group_indices));\n#else\n  regex_t compiled_pattern;\n  int r_err;\n  char r_errbuf[256];\n\n  r_err = regcomp(&compiled_pattern, pattern.c_str(), REG_EXTENDED);\n\n  if (r_err) {\n    regerror(r_err, NULL, r_errbuf, sizeof(r_errbuf));\n    throw std::runtime_error(\"Failed to compile pattern\" + std::string(r_errbuf));\n  }\n  patterns_.push_back(std::make_pair(std::move(compiled_pattern), group_indices));\n#endif\n}\n\nLogFilter::~LogFilter() {\n#ifndef USE_STD_REGEX\n  for(auto& each : patterns_) {\n    regfree(&(each.first));\n  }\n#endif\n}\n\nvoid SQLLogFilter::add_default_sql_patterns() {\n  add_pattern(\"^CREATE USER ([[:graph:]]+) IDENTIFIED WITH mysql_native_password AS ([[:graph:]]*)\", 2);\n  add_pattern(\"^CREATE USER ([[:graph:]]+) IDENTIFIED BY ([[:graph:]]*)\", 2);\n}\n\n} // end of mysqlrouter namespace\n"
  },
  {
    "path": "src/router/src/common/my_aes.cc",
    "content": "/* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.\n\n This program is free software; you can redistribute it and/or modify\n it under the terms of the GNU General Public License, version 2.0,\n as published by the Free Software Foundation.\n \n This program is also distributed with certain software (including\n but not limited to OpenSSL) that is licensed under separate terms,\n as designated in a particular file or component or in included license\n documentation.  The authors of MySQL hereby grant you an additional\n permission to link the program and your derivative works with the\n separately licensed software that they have included with MySQL.\n \n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n GNU General Public License for more details.\n \n You should have received a copy of the GNU General Public License\n along with this program; if not, write to the Free Software\n Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */\n\n#include \"router_config.h\"\n#include \"mysqlrouter/my_aes.h\"\n#include \"mysqlrouter/my_aes_impl.h\"\n#include <string.h>\n#include <stdint.h>\n\nnamespace myaes {\n\n/**\n  Transforms an arbitrary long key into a fixed length AES key\n\n  AES keys are of fixed length. This routine takes an arbitrary long key\n  iterates over it in AES key length increment and XORs the bytes with the\n  AES key buffer being prepared.\n  The bytes from the last incomplete iteration are XORed to the start\n  of the key until their depletion.\n  Needed since crypto function routines expect a fixed length key.\n\n  @param [in] key               Key to use for real key creation\n  @param [in] key_length        Length of the key\n  @param [out] rkey             Real key (used by OpenSSL/YaSSL)\n  @param [out] opmode           encryption mode\n*/\n\nvoid my_aes_create_key(const unsigned char *key, uint32_t key_length,\n                       uint8_t *rkey, enum my_aes_opmode opmode)\n{\n  const uint32_t key_size= my_aes_opmode_key_sizes[opmode] / 8;\n  uint8_t *rkey_end;                              /* Real key boundary */\n  uint8_t *ptr;                                   /* Start of the real key*/\n  uint8_t *sptr;                                  /* Start of the working key */\n  uint8_t *key_end= ((uint8_t *)key) + key_length;  /* Working key boundary*/\n\n  rkey_end= rkey + key_size;\n\n  memset(rkey, 0, key_size);          /* Set initial key  */\n\n  for (ptr= rkey, sptr= (uint8_t *)key; sptr < key_end; ptr++, sptr++)\n  {\n    if (ptr == rkey_end)\n      /*  Just loop over tmp_key until we used all key */\n      ptr= rkey;\n    *ptr^= *sptr;\n  }\n}\n\n}\n"
  },
  {
    "path": "src/router/src/common/my_aes_openssl.cc",
    "content": "/* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\nThis program is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License, version 2.0,\nas published by the Free Software Foundation.\n\nThis program is also distributed with certain software (including\nbut not limited to OpenSSL) that is licensed under separate terms,\nas designated in a particular file or component or in included license\ndocumentation.  The authors of MySQL hereby grant you an additional\npermission to link the program and your derivative works with the\nseparately licensed software that they have included with MySQL.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */\n\n#include \"mysqlrouter/my_aes.h\"\n#include \"mysqlrouter/my_aes_impl.h\"\n#include <string.h>\n#include <stdint.h>\n\n#include <openssl/aes.h>\n#include <openssl/evp.h>\n#include <openssl/err.h>\n#include <openssl/bio.h>\n\nnamespace myaes {\n\n/*\n  xplugin needs BIO_new_bio_pair, but the server does not.\n  Add an explicit dependency here, so that it is available when loading\n  the plugin.\n */\nint dummy_function_needed_by_xplugin()\n{\n  BIO *bio1;\n  BIO *bio2;\n  return BIO_new_bio_pair(&bio1, 42U, &bio2, 42U);\n}\n\n\n/* keep in sync with enum my_aes_opmode in my_aes.h */\nconst char *my_aes_opmode_names[]=\n{\n  \"aes-128-ecb\",\n  \"aes-192-ecb\",\n  \"aes-256-ecb\",\n  \"aes-128-cbc\",\n  \"aes-192-cbc\",\n  \"aes-256-cbc\",\n  \"aes-128-cfb1\",\n  \"aes-192-cfb1\",\n  \"aes-256-cfb1\",\n  \"aes-128-cfb8\",\n  \"aes-192-cfb8\",\n  \"aes-256-cfb8\",\n  \"aes-128-cfb128\",\n  \"aes-192-cfb128\",\n  \"aes-256-cfb128\",\n  \"aes-128-ofb\",\n  \"aes-192-ofb\",\n  \"aes-256-ofb\",\n  NULL /* needed for the type enumeration */\n};\n\n\n/* keep in sync with enum my_aes_opmode in my_aes.h */\nstatic uint32_t my_aes_opmode_key_sizes_impl[]=\n{\n  128 /* aes-128-ecb */,\n  192 /* aes-192-ecb */,\n  256 /* aes-256-ecb */,\n  128 /* aes-128-cbc */,\n  192 /* aes-192-cbc */,\n  256 /* aes-256-cbc */,\n  128 /* aes-128-cfb1 */,\n  192 /* aes-192-cfb1 */,\n  256 /* aes-256-cfb1 */,\n  128 /* aes-128-cfb8 */,\n  192 /* aes-192-cfb8 */,\n  256 /* aes-256-cfb8 */,\n  128 /* aes-128-cfb128 */,\n  192 /* aes-192-cfb128 */,\n  256 /* aes-256-cfb128 */,\n  128 /* aes-128-ofb */,\n  192 /* aes-192-ofb */,\n  256 /* aes-256-ofb */\n};\n\nuint32_t *my_aes_opmode_key_sizes= my_aes_opmode_key_sizes_impl;\n\n\n\nstatic const EVP_CIPHER *\naes_evp_type(const my_aes_opmode mode)\n{\n  switch (mode)\n  {\n  case my_aes_128_ecb:    return EVP_aes_128_ecb();\n  case my_aes_128_cbc:    return EVP_aes_128_cbc();\n  case my_aes_128_cfb1:   return EVP_aes_128_cfb1();\n  case my_aes_128_cfb8:   return EVP_aes_128_cfb8();\n  case my_aes_128_cfb128: return EVP_aes_128_cfb128();\n  case my_aes_128_ofb:    return EVP_aes_128_ofb();\n  case my_aes_192_ecb:    return EVP_aes_192_ecb();\n  case my_aes_192_cbc:    return EVP_aes_192_cbc();\n  case my_aes_192_cfb1:   return EVP_aes_192_cfb1();\n  case my_aes_192_cfb8:   return EVP_aes_192_cfb8();\n  case my_aes_192_cfb128: return EVP_aes_192_cfb128();\n  case my_aes_192_ofb:    return EVP_aes_192_ofb();\n  case my_aes_256_ecb:    return EVP_aes_256_ecb();\n  case my_aes_256_cbc:    return EVP_aes_256_cbc();\n  case my_aes_256_cfb1:   return EVP_aes_256_cfb1();\n  case my_aes_256_cfb8:   return EVP_aes_256_cfb8();\n  case my_aes_256_cfb128: return EVP_aes_256_cfb128();\n  case my_aes_256_ofb:    return EVP_aes_256_ofb();\n  default: return NULL;\n  }\n}\n\n\nint my_aes_encrypt(const unsigned char *source, uint32_t source_length,\n                   unsigned char *dest,\n                   const unsigned char *key, uint32_t key_length,\n                   enum my_aes_opmode mode, const unsigned char *iv,\n                   bool padding)\n{\n  const EVP_CIPHER *cipher= aes_evp_type(mode);\n  int u_len, f_len;\n  /* The real key to be used for encryption */\n  unsigned char rkey[MAX_AES_KEY_LENGTH / 8];\n  my_aes_create_key(key, key_length, rkey, mode);\n\n  if (!cipher || (EVP_CIPHER_iv_length(cipher) > 0 && !iv))\n    return MY_AES_BAD_DATA;\n\n#if OPENSSL_VERSION_NUMBER < 0x10100000L\n  EVP_CIPHER_CTX stack_ctx;\n  EVP_CIPHER_CTX *ctx = &stack_ctx;\n#else\n  EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();\n#endif\n\n  if (!EVP_EncryptInit(ctx, cipher, rkey, iv))\n    goto aes_error;                             /* Error */\n  if (!EVP_CIPHER_CTX_set_padding(ctx, padding))\n    goto aes_error;                             /* Error */\n  if (!EVP_EncryptUpdate(ctx, dest, &u_len, source, source_length))\n    goto aes_error;                             /* Error */\n\n  if (!EVP_EncryptFinal(ctx, dest + u_len, &f_len))\n    goto aes_error;                             /* Error */\n\n#if OPENSSL_VERSION_NUMBER < 0x10100000L\n  EVP_CIPHER_CTX_cleanup(ctx);\n#else\n  EVP_CIPHER_CTX_free(ctx);\n#endif\n  return u_len + f_len;\n\naes_error:\n  /* need to explicitly clean up the error if we want to ignore it */\n  ERR_clear_error();\n#if OPENSSL_VERSION_NUMBER < 0x10100000L\n  EVP_CIPHER_CTX_cleanup(ctx);\n#else\n  EVP_CIPHER_CTX_free(ctx);\n#endif\n  return MY_AES_BAD_DATA;\n}\n\n\nint my_aes_decrypt(const unsigned char *source, uint32_t source_length,\n                   unsigned char *dest,\n                   const unsigned char *key, uint32_t key_length,\n                   enum my_aes_opmode mode, const unsigned char *iv,\n                   bool padding)\n{\n\n  const EVP_CIPHER *cipher= aes_evp_type(mode);\n  int u_len, f_len;\n\n  /* The real key to be used for decryption */\n  unsigned char rkey[MAX_AES_KEY_LENGTH / 8];\n\n  my_aes_create_key(key, key_length, rkey, mode);\n  if (!cipher || (EVP_CIPHER_iv_length(cipher) > 0 && !iv))\n    return MY_AES_BAD_DATA;\n\n#if OPENSSL_VERSION_NUMBER < 0x10100000L\n  EVP_CIPHER_CTX stack_ctx;\n  EVP_CIPHER_CTX *ctx = &stack_ctx;\n#else\n  EVP_CIPHER_CTX *ctx = EVP_CIPHER_CTX_new();\n#endif\n\n  EVP_CIPHER_CTX_init(ctx);\n\n  if (!EVP_DecryptInit(ctx, aes_evp_type(mode), rkey, iv))\n    goto aes_error;                             /* Error */\n  if (!EVP_CIPHER_CTX_set_padding(ctx, padding))\n    goto aes_error;                             /* Error */\n  if (!EVP_DecryptUpdate(ctx, dest, &u_len, source, source_length))\n    goto aes_error;                             /* Error */\n  if (!EVP_DecryptFinal_ex(ctx, dest + u_len, &f_len))\n    goto aes_error;                             /* Error */\n\n#if OPENSSL_VERSION_NUMBER < 0x10100000L\n  EVP_CIPHER_CTX_cleanup(ctx);\n#else\n  EVP_CIPHER_CTX_free(ctx);\n#endif\n  return u_len + f_len;\n\naes_error:\n  /* need to explicitly clean up the error if we want to ignore it */\n  ERR_clear_error();\n#if OPENSSL_VERSION_NUMBER < 0x10100000L\n  EVP_CIPHER_CTX_cleanup(ctx);\n#else\n  EVP_CIPHER_CTX_free(ctx);\n#endif\n  return MY_AES_BAD_DATA;\n}\n\n\nint my_aes_get_size(uint32_t source_length, my_aes_opmode opmode)\n{\n  const EVP_CIPHER *cipher= aes_evp_type(opmode);\n  size_t block_size;\n\n  block_size= EVP_CIPHER_block_size(cipher);\n\n  return block_size > 1 ?\n    block_size * (source_length / block_size) + block_size :\n    source_length;\n}\n\n/**\n  Return true if the AES cipher and block mode requires an IV\n\n  SYNOPSIS\n  my_aes_needs_iv()\n  @param opmode           encryption mode\n\n  @retval true   IV needed\n  @retval false  IV not needed\n*/\n\nbool my_aes_needs_iv(my_aes_opmode opmode)\n{\n  const EVP_CIPHER *cipher= aes_evp_type(opmode);\n  int iv_length;\n\n  iv_length= EVP_CIPHER_iv_length(cipher);\n  return iv_length != 0 ? true : false;\n}\n\n}\n"
  },
  {
    "path": "src/router/src/common/my_aes_yassl.cc",
    "content": "/* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.\n\nThis program is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License, version 2.0,\nas published by the Free Software Foundation.\n\nThis program is also distributed with certain software (including\nbut not limited to OpenSSL) that is licensed under separate terms,\nas designated in a particular file or component or in included license\ndocumentation.  The authors of MySQL hereby grant you an additional\npermission to link the program and your derivative works with the\nseparately licensed software that they have included with MySQL.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */\n\n#include \"router_config.h\"\n#include \"mysqlrouter/my_aes.h\"\n#include \"mysqlrouter/my_aes_impl.h\"\n#include <string.h>\n#include <stdint.h>\n\n#include \"aes.hpp\"\n#include \"openssl/ssl.h\"\n\nnamespace myaes {\n\n/* keep in sync with enum my_aes_opmode in my_aes.h */\nconst char *my_aes_opmode_names[]=\n{\n  \"aes-128-ecb\",\n  \"aes-192-ecb\",\n  \"aes-256-ecb\",\n  \"aes-128-cbc\",\n  \"aes-192-cbc\",\n  \"aes-256-cbc\",\n  NULL /* needed for the type enumeration */\n};\n\n\n/* keep in sync with enum my_aes_opmode in my_aes.h */\nstatic uint32_t my_aes_opmode_key_sizes_impl[]=\n{\n  128 /* aes-128-ecb */,\n  192 /* aes-192-ecb */,\n  256 /* aes-256-ecb */,\n  128 /* aes-128-cbc */,\n  192 /* aes-192-cbc */,\n  256 /* aes-256-cbc */,\n};\n\nuint32_t *my_aes_opmode_key_sizes= my_aes_opmode_key_sizes_impl;\n\n\ntemplate <TaoCrypt::CipherDir DIR>\nclass MyCipherCtx\n{\npublic:\n  MyCipherCtx(enum my_aes_opmode mode) : m_mode(mode)\n  {\n    switch (m_mode)\n    {\n    case my_aes_128_ecb:\n    case my_aes_192_ecb:\n    case my_aes_256_ecb:\n      m_need_iv= false;\n      break;\n    default:\n      m_need_iv= true;\n      break;\n    }\n  }\n\n  bool SetKey(const unsigned char *key, uint32_t block_size,\n              const unsigned char *iv)\n  {\n    if (m_need_iv)\n    {\n      if (!iv)\n        return true;\n      cbc.SetKey(key, block_size, iv);\n    }\n    else\n      ecb.SetKey(key, block_size);\n    return false;\n  }\n\n  void Process(unsigned char *dest, const unsigned char * source,\n               uint32_t block_size)\n  {\n    if (m_need_iv)\n      cbc.Process(dest, source, block_size);\n    else\n      ecb.Process(dest, source, block_size);\n  }\n\n  bool needs_iv() const\n  {\n    return m_need_iv;\n  }\n\nprivate:\n  /* we initialize the two classes to avoid dynamic allocation */\n  TaoCrypt::BlockCipher<DIR, TaoCrypt::AES, TaoCrypt::ECB> ecb;\n  TaoCrypt::BlockCipher<DIR, TaoCrypt::AES, TaoCrypt::CBC> cbc;\n  enum my_aes_opmode m_mode;\n  bool m_need_iv;\n};\n\n\nint my_aes_encrypt(const unsigned char *source, uint32_t source_length,\n                   unsigned char *dest,\n                   const unsigned char *key, uint32_t key_length,\n                   enum my_aes_opmode mode, const unsigned char *iv,\n                   bool padding)\n{\n  MyCipherCtx<TaoCrypt::ENCRYPTION> enc(mode);\n\n  /* 128 bit block used for padding */\n  unsigned char block[MY_AES_BLOCK_SIZE];\n  uint32_t num_blocks;                               /* number of complete blocks */\n  uint32_t i;\n  /* predicted real key size */\n  const uint32_t key_size= my_aes_opmode_key_sizes[mode] / 8;\n  /* The real key to be used for encryption */\n  unsigned char rkey[MAX_AES_KEY_LENGTH / 8];\n\n  my_aes_create_key(key, key_length, rkey, mode);\n\n  if (enc.SetKey(rkey, key_size, iv))\n    return MY_AES_BAD_DATA;\n\n  num_blocks= source_length / MY_AES_BLOCK_SIZE;\n\n  /* Encode all complete blocks */\n  for (i = num_blocks; i > 0;\n       i--, source+= MY_AES_BLOCK_SIZE, dest+= MY_AES_BLOCK_SIZE)\n       enc.Process(dest, source, MY_AES_BLOCK_SIZE);\n\n  /* If no padding, return here */\n  if (!padding)\n\t  return (int) (MY_AES_BLOCK_SIZE * num_blocks);\n  /*\n  Re-implement standard PKCS padding for the last block.\n  Pad the last incomplete data block (even if empty) with bytes\n  equal to the size of extra padding stored into that last packet.\n  This also means that there will always be one more block,\n  even if the source data size is dividable by the AES block size.\n  */\n  unsigned char pad_len=\n    MY_AES_BLOCK_SIZE - (source_length - MY_AES_BLOCK_SIZE * num_blocks);\n  memcpy(block, source, MY_AES_BLOCK_SIZE - pad_len);\n  memset(block + MY_AES_BLOCK_SIZE - pad_len, pad_len, pad_len);\n\n  enc.Process(dest, block, MY_AES_BLOCK_SIZE);\n\n  /* we've added a block */\n  num_blocks+= 1;\n\n  return (int) (MY_AES_BLOCK_SIZE * num_blocks);\n}\n\n\nint my_aes_decrypt(const unsigned char *source, uint32_t source_length,\n                   unsigned char *dest,\n                   const unsigned char *key, uint32_t key_length,\n                   enum my_aes_opmode mode, const unsigned char *iv,\n                   bool padding)\n{\n  MyCipherCtx<TaoCrypt::DECRYPTION> dec(mode);\n  /* 128 bit block used for padding */\n  uint8_t block[MY_AES_BLOCK_SIZE];\n  uint32_t num_blocks;                               /* Number of complete blocks */\n  int i;\n  /* predicted real key size */\n  const uint32_t key_size= my_aes_opmode_key_sizes[mode] / 8;\n  /* The real key to be used for decryption */\n  unsigned char rkey[MAX_AES_KEY_LENGTH / 8];\n\n  my_aes_create_key(key, key_length, rkey, mode);\n  dec.SetKey(rkey, key_size, iv);\n\n  num_blocks= source_length / MY_AES_BLOCK_SIZE;\n\n  /*\n  Input size has to be a multiple of the AES block size.\n  And, due to the standard PKCS padding, at least one block long.\n  */\n  if ((source_length != num_blocks * MY_AES_BLOCK_SIZE) || num_blocks == 0)\n    return MY_AES_BAD_DATA;\n\n  /* Decode all but the last block */\n  for (i= padding? num_blocks - 1: num_blocks; i > 0;\n       i--, source+= MY_AES_BLOCK_SIZE, dest+= MY_AES_BLOCK_SIZE)\n       dec.Process(dest, source, MY_AES_BLOCK_SIZE);\n\n  /* If no padding, return here. */\n  if (!padding)\n\t  return MY_AES_BLOCK_SIZE * num_blocks;\n\n  /* unwarp the standard PKCS padding */\n  dec.Process(block, source, MY_AES_BLOCK_SIZE);\n\n  /* Use last char in the block as size */\n  uint8_t pad_len = block[MY_AES_BLOCK_SIZE - 1];\n\n  if (pad_len > MY_AES_BLOCK_SIZE)\n    return MY_AES_BAD_DATA;\n  /* We could also check whole padding but we do not really need this */\n\n  memcpy(dest, block, MY_AES_BLOCK_SIZE - pad_len);\n  return MY_AES_BLOCK_SIZE * num_blocks - pad_len;\n}\n\n\nint my_aes_get_size(uint32_t source_length, my_aes_opmode)\n{\n  return MY_AES_BLOCK_SIZE * (source_length / MY_AES_BLOCK_SIZE)\n    + MY_AES_BLOCK_SIZE;\n}\n\n\nbool my_aes_needs_iv(my_aes_opmode opmode)\n{\n  MyCipherCtx<TaoCrypt::ENCRYPTION> enc(opmode);\n\n  return enc.needs_iv() ? true : false;\n}\n\n}\n"
  },
  {
    "path": "src/router/src/common/my_sha1.cc",
    "content": "/* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.\n\n This program is free software; you can redistribute it and/or modify\n it under the terms of the GNU General Public License, version 2.0,\n as published by the Free Software Foundation.\n \n This program is also distributed with certain software (including\n but not limited to OpenSSL) that is licensed under separate terms,\n as designated in a particular file or component or in included license\n documentation.  The authors of MySQL hereby grant you an additional\n permission to link the program and your derivative works with the\n separately licensed software that they have included with MySQL.\n \n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n GNU General Public License for more details.\n \n You should have received a copy of the GNU General Public License\n along with this program; if not, write to the Free Software\n Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */\n\n\n/**\n  @file\n\n  @brief\n  Wrapper functions for OpenSSL, YaSSL implementations. Also provides a\n  Compatibility layer to make available YaSSL's SHA1 implementation.\n*/\n\n#include \"mysqlrouter/sha1.h\"\n\n\n#if defined(HAVE_YASSL)\n#include \"sha.hpp\"\nnamespace my_sha1 {\n\n/**\n  Compute SHA1 message digest using YaSSL.\n\n  @param digest [out]  Computed SHA1 digest\n  @param buf    [in]   Message to be computed\n  @param len    [in]   Length of the message\n*/\nvoid mysql_sha1_yassl(uint8_t *digest, const char *buf, size_t len)\n{\n  TaoCrypt::SHA hasher;\n  hasher.Update((const TaoCrypt::byte *) buf, (TaoCrypt::word32)len);\n  hasher.Final ((TaoCrypt::byte *) digest);\n}\n\n/**\n  Compute SHA1 message digest for two messages in order to\n  emulate sha1(msg1, msg2) using YaSSL.\n\n  @param digest [out]  Computed SHA1 digest\n  @param buf1   [in]   First message\n  @param len1   [in]   Length of first message\n  @param buf2   [in]   Second message\n  @param len2   [in]   Length of second message\n*/\nvoid mysql_sha1_multi_yassl(uint8_t *digest, const char *buf1, int len1,\n                            const char *buf2, int len2)\n{\n  TaoCrypt::SHA hasher;\n  hasher.Update((const TaoCrypt::byte *) buf1, len1);\n  hasher.Update((const TaoCrypt::byte *) buf2, len2);\n  hasher.Final((TaoCrypt::byte *) digest);\n}\n}\n#elif defined(HAVE_OPENSSL)\n#include <openssl/sha.h>\n\nnamespace my_sha1 {\n\nint mysql_sha1_reset(SHA_CTX *context)\n{\n    return SHA1_Init(context);\n}\n\n\nint mysql_sha1_input(SHA_CTX *context, const uint8_t *message_array,\n                     unsigned length)\n{\n    return SHA1_Update(context, message_array, length);\n}\n\n\nint mysql_sha1_result(SHA_CTX *context,\n                      uint8_t Message_Digest[SHA1_HASH_SIZE])\n{\n    return SHA1_Final(Message_Digest, context);\n}\n\n}\n\n#endif /* HAVE_YASSL */\n\nnamespace my_sha1 {\n\n/**\n  Wrapper function to compute SHA1 message digest.\n\n  @param digest [out]  Computed SHA1 digest\n  @param buf    [in]   Message to be computed\n  @param len    [in]   Length of the message\n*/\nvoid compute_sha1_hash(uint8_t *digest, const char *buf, size_t len)\n{\n#if defined(HAVE_YASSL)\n  mysql_sha1_yassl(digest, buf, len);\n#elif defined(HAVE_OPENSSL)\n  SHA_CTX sha1_context;\n\n  mysql_sha1_reset(&sha1_context);\n  mysql_sha1_input(&sha1_context, (const uint8_t *) buf, len);\n  mysql_sha1_result(&sha1_context, digest);\n#endif /* HAVE_YASSL */\n}\n\n\n/**\n  Wrapper function to compute SHA1 message digest for\n  two messages in order to emulate sha1(msg1, msg2).\n\n  @param digest [out]  Computed SHA1 digest\n  @param buf1   [in]   First message\n  @param len1   [in]   Length of first message\n  @param buf2   [in]   Second message\n  @param len2   [in]   Length of second message\n*/\nvoid compute_sha1_hash_multi(uint8_t *digest, const char *buf1, int len1,\n                             const char *buf2, int len2)\n{\n#if defined(HAVE_YASSL)\n  mysql_sha1_multi_yassl(digest, buf1, len1, buf2, len2);\n#elif defined(HAVE_OPENSSL)\n  SHA_CTX sha1_context;\n\n  mysql_sha1_reset(&sha1_context);\n  mysql_sha1_input(&sha1_context, (const uint8_t *) buf1, len1);\n  mysql_sha1_input(&sha1_context, (const uint8_t *) buf2, len2);\n  mysql_sha1_result(&sha1_context, digest);\n#endif /* HAVE_YASSL */\n}\n\n}\n"
  },
  {
    "path": "src/router/src/common/mysql_session.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysqlrouter/mysql_session.h\"\n#define MYSQL_ROUTER_LOG_DOMAIN \"sql\"\n#include \"mysql/harness/logging/logging.h\"\n\n#include <assert.h> // <cassert> is flawed: assert() lands in global namespace on Ubuntu 14.04, not std::\n#include <sstream>\n#include <fstream>\n#include <mysql.h>\n#include <algorithm>\n#include <cstdlib>\n#include <ctype.h>  // not <cctype> because we don't want std::toupper(), which causes problems with std::transform()\n#include <iostream>\n#include <chrono>\n\nIMPORT_LOG_FUNCTIONS()\n\nusing namespace mysqlrouter;\n\n/*\n   Mock recorder for MySQLSession\n   ------------------------------\n\n   In dev builds, #define MOCK_RECORDER below to enable recording of\n   MySQL sessions for mock test writing purposes.\n\n   When enabled, the MYSQL_ROUTER_RECORD_MOCK environment variable can be set\n   to make MySQLSession dump all calls to it, along with its results, so that\n   they can be replayed later with a MySQLSessionReplayer object.\n */\n// #define MOCK_RECORDER\n// #define MOCK_RECORDER_JSON\n\n#if defined(NDEBUG)\n#ifdef MOCK_RECORDER\n#undef MOCK_RECORDER\n#endif\n#endif\n\n/*static*/ const char MySQLSession::kSslModeDisabled[]  = \"DISABLED\";\n/*static*/ const char MySQLSession::kSslModePreferred[] = \"PREFERRED\";\n/*static*/ const char MySQLSession::kSslModeRequired[]  = \"REQUIRED\";\n/*static*/ const char MySQLSession::kSslModeVerifyCa[]  = \"VERIFY_CA\";\n/*static*/ const char MySQLSession::kSslModeVerifyIdentity[]  = \"VERIFY_IDENTITY\";\n\n#ifdef MOCK_RECORDER\n#ifdef MOCK_RECORDER_JSON\n\n#define RAPIDJSON_HAS_STDSTRING 1\n\n#include \"rapidjson/prettywriter.h\"\n#include \"rapidjson/filewritestream.h\"\n#include <cstdio>\n\nusing StreamWriter = RAPIDJSON_NAMESPACE::PrettyWriter<RAPIDJSON_NAMESPACE::FileWriteStream>;\n\nclass Writer : public StreamWriter {\npublic:\n  Writer(std::FILE *f) : StreamWriter(f_stream_), f_stream_(f, buf_, sizeof(buf_)) {}\nprivate:\n  RAPIDJSON_NAMESPACE::FileWriteStream f_stream_;\n  char buf_[1024];\n};\n\nstatic const char *type_names[] = {\n  \"TINY\",\n  \"SHORT\",\n  \"LONG\",\n  \"INT24\",\n  \"LONGLONG\",\n  \"DECIMAL\",\n  \"NEWDECIMAL\",\n  \"FLOAT\",\n  \"DOUBLE\",\n  \"BIT\",\n  \"TIMESTAMP\",\n  \"DATE\",\n  \"TIME\",\n  \"DATETIME\",\n  \"YEAR\",\n  \"STRING\",\n  \"VAR_STRING\",\n  \"BLOB\",\n  \"SET\",\n  \"ENUM\",\n  \"GEOMETRY\",\n  \"NULL\",\n  \"TINYBLOB\",\n  \"LONGBLOB\",\n  \"MEDIUMBLOB\",\n};\n\nint type_names_ndx(enum_field_types type) {\n  switch (type) {\n  case MYSQL_TYPE_TINY: return 0;\n  case MYSQL_TYPE_SHORT: return 1;\n  case MYSQL_TYPE_LONG: return 2;\n  case MYSQL_TYPE_INT24: return 3;\n  case MYSQL_TYPE_LONGLONG: return 4;\n  case MYSQL_TYPE_DECIMAL: return 5;\n  case MYSQL_TYPE_NEWDECIMAL: return 6;\n  case MYSQL_TYPE_FLOAT: return 7;\n  case MYSQL_TYPE_DOUBLE: return 8;\n  case MYSQL_TYPE_BIT: return 9;\n  case MYSQL_TYPE_TIMESTAMP: return 10;\n  case MYSQL_TYPE_DATE: return 11;\n  case MYSQL_TYPE_TIME: return 12;\n  case MYSQL_TYPE_DATETIME: return 13;\n  case MYSQL_TYPE_YEAR: return 14;\n  case MYSQL_TYPE_STRING: return 15;\n  case MYSQL_TYPE_VAR_STRING: return 16;\n  case MYSQL_TYPE_BLOB: return 17;\n  case MYSQL_TYPE_SET: return 18;\n  case MYSQL_TYPE_ENUM: return 19;\n  case MYSQL_TYPE_GEOMETRY: return 20;\n  case MYSQL_TYPE_NULL: return 21;\n  case MYSQL_TYPE_TINY_BLOB: return 22;\n  case MYSQL_TYPE_LONG_BLOB: return 23;\n  case MYSQL_TYPE_MEDIUM_BLOB: return 24;\n  default:\n    throw std::invalid_argument(\"invalid protocol field type: \" + std::to_string(type));\n  }\n}\n\nclass MySQLServerMockRecorder {\npublic:\n  MySQLServerMockRecorder(FILE *f) : writer_(f) {\n    writer_.StartObject();\n    writer_.Key(\"stmts\");\n    writer_.StartArray();\n\n    // we never close it ...\n  }\n\n  ~MySQLServerMockRecorder() {\n    writer_.EndArray();\n    writer_.EndObject();\n  }\n\n  void execute(const std::string &q) {\n    exec_start_ = std::chrono::steady_clock::now();\n\n    writer_.StartObject();\n\n    writer_.Key(\"stmt\");\n    writer_.String(q);\n  }\n\n  void query(const std::string &q) {\n    execute(q);\n  }\n\n  void query_one(const std::string &q) {\n    execute(q);\n  }\n\n  void write_exec_time() {\n    writer_.Key(\"exec_time\");\n    writer_.Double(\n        std::chrono::duration<double, std::milli>(\n          std::chrono::steady_clock::now() - exec_start_).count());\n  }\n\n  void execute_done(uint64_t last_insert_id, uint64_t warning_count) {\n    write_exec_time();\n\n    writer_.Key(\"ok\");\n    writer_.StartObject();\n    if (last_insert_id) {\n      writer_.Key(\"last_insert_id\");\n      writer_.Uint(last_insert_id);\n    }\n    if (warning_count) {\n      writer_.Key(\"warning_count\");\n      writer_.Uint(warning_count);\n    }\n    writer_.EndObject();\n\n    writer_.EndObject();\n  }\n\n  void result_error(const char *error, unsigned int code, const char *sql_state, MySQLSession &) {\n    write_exec_time();\n\n    writer_.Key(\"error\");\n    writer_.StartObject();\n    writer_.Key(\"code\");\n    writer_.Uint(code);\n\n    writer_.Key(\"message\");\n    writer_.String(error);\n\n    writer_.Key(\"sql_state\");\n    writer_.String(sql_state);\n\n    writer_.EndObject();\n\n    writer_.EndObject();\n  }\n\n  void result_rows_begin(unsigned int num_fields, MYSQL_FIELD *fields) {\n    write_exec_time();\n\n    nfields_ = num_fields;\n\n    writer_.Key(\"result\");\n\n    writer_.StartObject();\n    writer_.Key(\"columns\");\n\n    writer_.StartArray();\n    for (unsigned int i = 0; i < num_fields; i++) {\n      writer_.StartObject();\n      writer_.Key(\"name\");\n      writer_.String(fields[i].name);\n\n      writer_.Key(\"type\");\n      // the compiler should be smart enough to convert the strlen() into a sizeof()\n      writer_.String(type_names[type_names_ndx(fields[i].type)],\n          strlen(type_names[type_names_ndx(fields[i].type)]));\n      writer_.EndObject();\n    }\n    writer_.EndArray();\n\n    writer_.Key(\"rows\");\n    writer_.StartArray();\n  }\n\n  void result_rows_add(MYSQL_ROW row, MySQLSession &) {\n    writer_.StartArray();\n    for (unsigned int i = 0; i < nfields_; i++) {\n      if (row[i])\n        writer_.String(row[i]);\n      else\n        writer_.Null();\n    }\n    writer_.EndArray();\n  }\n\n  void result_rows_end() {\n    writer_.EndArray();\n    writer_.EndObject();\n    writer_.EndObject();\n  }\n\nprivate:\n  std::chrono::steady_clock::time_point exec_start_;\n  unsigned int nfields_;\n  Writer writer_;\n};\n\nstatic MySQLServerMockRecorder g_mock_recorder(fopen(getenv(\"MYSQL_ROUTER_RECORD_MOCK\") ? getenv(\"MYSQL_ROUTER_RECORD_MOCK\") : \"/dev/null\", \"wb\"));\n#else\nclass GoogleMockRecorder {\npublic:\n  GoogleMockRecorder() : record_(false) {\n    const char *outfile = std::getenv(\"MYSQL_ROUTER_RECORD_MOCK\");\n    if (outfile) {\n      std::cerr << \"Enabled mock recording...\\n\";\n      record_ = true;\n      outf_.open(outfile, std::ofstream::trunc | std::ofstream::out);\n    }\n  }\n\n  void execute(const std::string &q) {\n    outf_ << \"  m.expect_execute(\\\"\" << q << \"\\\");\\n\";\n  }\n\n  void query(const std::string &q) {\n    outf_ << \"  m.expect_query(\\\"\" << q << \"\\\");\\n\";\n  }\n\n  void query_one(const std::string &q) {\n    outf_ << \"  m.expect_query_one(\\\"\" << q << \"\\\");\\n\";\n  }\n\n  void execute_done(uint64_t last_insert_id, uint64_t /* warning_count */) {\n    outf_ << \"  m.then_ok(\"<< last_insert_id << \");\\n\";\n  }\n\n  void result_error(const char *error, unsigned int code, const char* /* sql_state */, MySQLSession &s) {\n    outf_ << \"  m.then_error(\" << s.quote(error, '\\\"') << \", \" << code << \");\\n\\n\";\n  }\n\n  void result_rows_begin(unsigned int num_fields, MYSQL_FIELD *fields) {\n    nfields_ = num_fields;\n    need_comma_ = false;\n    outf_ << \"  m.then_return(\"<< num_fields << \", {\\n\";\n    outf_ << \"      // \";\n    for (unsigned int i = 0; i < num_fields; i++) {\n      if (i > 0)\n        outf_ << \", \";\n      outf_ << fields[i].name;\n    }\n    outf_ << \"\\n\";\n  }\n\n  void result_rows_add(MYSQL_ROW row, MySQLSession &s) {\n    if (need_comma_) {\n      outf_ << \",\\n\";\n    }\n    need_comma_ = true;\n    outf_ << \"      {\";\n    for (unsigned int i = 0; i < nfields_; i++) {\n      if (i > 0)\n        outf_ << \", \";\n      if (row[i])\n        outf_ << \"m.string_or_null(\" << s.quote(row[i], '\\\"') << \")\";\n      else\n        outf_ << \"m.string_or_null()\";\n    }\n    outf_ << \"}\";\n  }\n\n  void result_rows_end() {\n    if (need_comma_)\n      outf_ << \"\\n\";\n    outf_ << \"    });\\n\\n\";\n  }\n\nprivate:\n  std::ofstream outf_;\n  unsigned int nfields_;\n  bool need_comma_;\n  bool record_;\n};\n\nstatic GoogleMockRecorder g_mock_recorder;\n#endif\n\n#define MOCK_REC_EXECUTE(q) g_mock_recorder.execute(q)\n#define MOCK_REC_OK(lid, warning_count) g_mock_recorder.execute_done(lid, warning_count)\n#define MOCK_REC_QUERY(q) g_mock_recorder.query(q)\n#define MOCK_REC_QUERY_ONE(q) g_mock_recorder.query_one(q)\n#define MOCK_REC_ERROR(e, c, s, m) g_mock_recorder.result_error(e, c, s, m)\n#define MOCK_REC_BEGIN(nf,f) g_mock_recorder.result_rows_begin(nf, f)\n#define MOCK_REC_END() g_mock_recorder.result_rows_end()\n#define MOCK_REC_ROW(r, m) g_mock_recorder.result_rows_add(r, m)\n#else // !MOCK_RECORDER\n#define MOCK_REC_EXECUTE(q) do {} while(0)\n#define MOCK_REC_OK(lid, warning_count) do {} while(0)\n#define MOCK_REC_QUERY(q) do {} while(0)\n#define MOCK_REC_QUERY_ONE(q) do {} while(0)\n#define MOCK_REC_ERROR(e, c, s, m) do {} while(0)\n#define MOCK_REC_BEGIN(nf,f) do {} while(0)\n#define MOCK_REC_END() do {} while(0)\n#define MOCK_REC_ROW(r, m) do {} while(0)\n#endif // !MOCK_RECORDER\n\nMySQLSession::MySQLSession() {\n  connection_ = new MYSQL();\n  connected_ = false;\n  if (!mysql_init(connection_)) {\n    // not supposed to happen\n    throw std::logic_error(\"Error initializing MySQL connection structure\");\n  }\n  log_filter_.add_default_sql_patterns();\n}\n\n\nMySQLSession::~MySQLSession() {\n  mysql_close(connection_);\n\n  delete connection_;\n}\n\n/*static*/\nmysql_ssl_mode MySQLSession::parse_ssl_mode(std::string ssl_mode) {\n\n  // we allow lowercase equivalents, to be consistent with mysql client\n  std::transform(ssl_mode.begin(), ssl_mode.end(), ssl_mode.begin(), toupper);\n\n  if (ssl_mode == kSslModeDisabled)\n    return SSL_MODE_DISABLED;\n  else if (ssl_mode == kSslModePreferred)\n    return SSL_MODE_PREFERRED;\n  else if (ssl_mode == kSslModeRequired)\n    return SSL_MODE_REQUIRED;\n  else if (ssl_mode == kSslModeVerifyCa)\n    return SSL_MODE_VERIFY_CA;\n  else if (ssl_mode == kSslModeVerifyIdentity)\n    return SSL_MODE_VERIFY_IDENTITY;\n  else\n    throw std::logic_error(std::string(\"Unrecognised SSL mode '\") + ssl_mode + \"'\");\n}\n\n/*static*/\nconst char* MySQLSession::ssl_mode_to_string(mysql_ssl_mode ssl_mode) noexcept {\n  const char* text = NULL;\n\n  // The better way would be to do away with text variable and return kSslMode*\n  // directly from each case. Unfortunately, Clang 3.4 doesn't like it:\n  //   control reaches end of non-void function [-Werror=return-type]\n  // even though it knows all cases are handled (issues another warning if any\n  // one is removed).\n  switch (ssl_mode) {\n    case SSL_MODE_DISABLED:\n      text = kSslModeDisabled;\n      break;\n    case SSL_MODE_PREFERRED:\n      text = kSslModePreferred;\n      break;\n    case SSL_MODE_REQUIRED:\n      text = kSslModeRequired;\n      break;\n    case SSL_MODE_VERIFY_CA:\n      text = kSslModeVerifyCa;\n      break;\n    case SSL_MODE_VERIFY_IDENTITY:\n      text = kSslModeVerifyIdentity;\n      break;\n  }\n\n  return text;\n}\n\nbool MySQLSession::check_for_yassl(MYSQL *connection) {\n  static bool check_done = false;\n  static bool is_yassl = false;\n  if (!check_done) {\n    const char* old_version{nullptr};\n    // the assumption is that yaSSL does not support this version\n    const char* kTlsNoYassl = \"TLSv1.2\";\n\n    if (mysql_get_option(connection, MYSQL_OPT_TLS_VERSION, &old_version)) {\n      throw Error(\"Error checking for SSL implementation\", mysql_errno(connection));\n    }\n    int res = mysql_options(connection, MYSQL_OPT_TLS_VERSION, kTlsNoYassl);\n    is_yassl = (res != 0);\n    if (mysql_options(connection, MYSQL_OPT_TLS_VERSION, old_version)) {\n      throw Error(\"Error checking for SSL implementation\", mysql_errno(connection));\n    }\n    check_done = true;\n  }\n\n  return is_yassl;\n}\n\nvoid MySQLSession::set_ssl_options(mysql_ssl_mode ssl_mode,\n                                   const std::string &tls_version,\n                                   const std::string &ssl_cipher,\n                                   const std::string &ca, const std::string &capath,\n                                   const std::string &crl, const std::string &crlpath) {\n\n\n  if (check_for_yassl(connection_)) {\n    if ((ssl_mode >= SSL_MODE_VERIFY_CA) ||\n        (!ca.empty()) || (!capath.empty()) ||\n        (!crl.empty()) || (!crlpath.empty())) {\n      throw std::invalid_argument(\"Certificate Verification is disabled in this build of the MySQL Router. \\n\"\n                                  \"The following parameters are not supported: \\n\"\n                                  \" --ssl-mode=VERIFY_CA, --ssl-mode=VERIFY_IDENTITY, \\n\"\n                                  \" --ssl-ca, --ssl-capath, --ssl-crl, --ssl-crlpath \\n\"\n                                  \"Please check documentation for the details.\"\n                                  );\n    }\n  }\n\n  if (!ssl_cipher.empty() &&\n      mysql_options(connection_, MYSQL_OPT_SSL_CIPHER, ssl_cipher.c_str()) != 0) {\n    throw Error((\"Error setting SSL_CIPHER option for MySQL connection: \"\n                + std::string(mysql_error(connection_))).c_str(),\n                mysql_errno(connection_));\n  }\n\n  if (!tls_version.empty() &&\n      mysql_options(connection_, MYSQL_OPT_TLS_VERSION, tls_version.c_str()) != 0) {\n    throw Error(\"Error setting TLS_VERSION option for MySQL connection\",\n                mysql_errno(connection_));\n  }\n\n  if (!ca.empty() &&\n      mysql_options(connection_, MYSQL_OPT_SSL_CA, ca.c_str()) != 0) {\n    throw Error((\"Error setting SSL_CA option for MySQL connection: \"\n                + std::string(mysql_error(connection_))).c_str(),\n                mysql_errno(connection_));\n  }\n\n  if (!capath.empty() &&\n      mysql_options(connection_, MYSQL_OPT_SSL_CAPATH, capath.c_str()) != 0) {\n    throw Error((\"Error setting SSL_CAPATH option for MySQL connection: \"\n                + std::string(mysql_error(connection_))).c_str(),\n                mysql_errno(connection_));\n  }\n\n  if (!crl.empty() &&\n      mysql_options(connection_, MYSQL_OPT_SSL_CRL, crl.c_str()) != 0) {\n    throw Error((\"Error setting SSL_CRL option for MySQL connection: \"\n                + std::string(mysql_error(connection_))).c_str(),\n                mysql_errno(connection_));\n  }\n\n  if (!crlpath.empty() &&\n      mysql_options(connection_, MYSQL_OPT_SSL_CRLPATH, crlpath.c_str()) != 0) {\n    throw Error((\"Error setting SSL_CRLPATH option for MySQL connection: \"\n                + std::string(mysql_error(connection_))).c_str(),\n                mysql_errno(connection_));\n  }\n\n  // this has to be the last option that gets set due to what appears to be a bug in libmysql\n  // causing ssl_mode downgrade from REQUIRED if other options (like tls_version) are also specified\n  if (mysql_options(connection_, MYSQL_OPT_SSL_MODE, &ssl_mode) != 0) {\n    const char* text = ssl_mode_to_string(ssl_mode);\n    std::string msg = std::string(\"Setting SSL mode to '\") + text + \"' on connection failed: \"\n                    + mysql_error(connection_);\n    throw Error(msg.c_str(), mysql_errno(connection_));\n  }\n}\n\nvoid MySQLSession::set_ssl_cert(const std::string &cert, const std::string &key) {\n  if (mysql_options(connection_, MYSQL_OPT_SSL_CERT, cert.c_str()) != 0 ||\n      mysql_options(connection_, MYSQL_OPT_SSL_KEY, key.c_str()) != 0) {\n    throw Error((\"Error setting client SSL certificate for connection: \"\n                + std::string(mysql_error(connection_))).c_str(),\n                mysql_errno(connection_));\n  }\n}\n\nvoid MySQLSession::connect(const std::string &host, unsigned int port,\n                           const std::string &username,\n                           const std::string &password,\n                           const std::string &unix_socket,\n                           const std::string &default_schema,\n                           int connect_timeout,\n                           int read_timeout) {\n  unsigned int protocol = MYSQL_PROTOCOL_TCP;\n  connected_ = false;\n\n  // Following would fail only when invalid values are given. It is not possible\n  // for the user to change these values.\n  mysql_options(connection_, MYSQL_OPT_CONNECT_TIMEOUT,\n                &connect_timeout);\n  mysql_options(connection_, MYSQL_OPT_READ_TIMEOUT,\n                &read_timeout);\n\n  if (unix_socket.length() > 0) {\n#ifdef _WIN32\n    protocol = MYSQL_PROTOCOL_PIPE;\n#else\n    protocol = MYSQL_PROTOCOL_SOCKET;\n#endif\n  }\n  mysql_options(connection_, MYSQL_OPT_PROTOCOL,\n                reinterpret_cast<char *> (&protocol));\n\n  const unsigned long client_flags = (\n    CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_PROTOCOL_41 |\n    CLIENT_MULTI_RESULTS\n    );\n  std::string tmp_conn_addr = unix_socket.length() > 0 ? unix_socket : host + \":\" + std::to_string(port);\n  if (!mysql_real_connect(connection_, host.c_str(), username.c_str(),\n                         password.c_str(), default_schema.c_str(),\n                         port, unix_socket.c_str(),\n                         client_flags)) {\n    std::stringstream ss;\n    ss << \"Error connecting to MySQL server at \" << tmp_conn_addr;\n    ss << \": \" << mysql_error(connection_) << \" (\" << mysql_errno(connection_) << \")\";\n    throw Error(ss.str().c_str(), mysql_errno(connection_));\n  }\n  connected_ = true;\n  connection_address_ = tmp_conn_addr;\n}\n\nvoid MySQLSession::disconnect() {\n  // close the socket and free internal data\n  mysql_close(connection_);\n\n  // initialize the connection handle again as _close() is also free()ing\n  // a lot of internal data.\n  mysql_init(connection_);\n  connected_ = false;\n  connection_address_.clear();\n}\n\nvoid MySQLSession::execute(const std::string &q) {\n  log_debug(\"Executing query: %s\", log_filter_.filter(q).c_str());\n  std::shared_ptr<void> exit_guard(nullptr, [](void*) {\n    log_debug(\"Done executing query\");\n  });\n\n  if (connected_) {\n    MOCK_REC_EXECUTE(q);\n    if (mysql_real_query(connection_, q.data(), q.length()) != 0) {\n      std::stringstream ss;\n      ss << \"Error executing MySQL query\";\n      ss << \": \" << mysql_error(connection_) << \" (\" << mysql_errno(connection_) << \")\";\n      MOCK_REC_ERROR(mysql_error(connection_), mysql_errno(connection_), mysql_sqlstate(connection_), *this);\n      throw Error(ss.str().c_str(), mysql_errno(connection_));\n    }\n    MYSQL_RES *res = mysql_store_result(connection_);\n    MOCK_REC_OK(mysql_insert_id(connection_), mysql_warning_count(connection_));\n    if (res)\n      mysql_free_result(res);\n  } else\n    throw std::logic_error(\"Not connected\");\n}\n\n/*\n  Execute query on the session and iterate the results with the given callback.\n\n  The processor callback is called with a vector of strings, which conain the\n  values of each field of a row. It is called once per row.\n  If the processor returns false, the result row iteration stops.\n */\nvoid MySQLSession::query(const std::string &q,\n                         const RowProcessor &processor) {\n  log_debug(\"Executing query: %s\", log_filter_.filter(q).c_str());\n  std::shared_ptr<void> exit_guard(nullptr, [](void*) {\n    log_debug(\"Done executing query\");\n  });\n  if (connected_) {\n    MOCK_REC_QUERY(q);\n    if (mysql_real_query(connection_, q.data(), q.length()) != 0) {\n      std::stringstream ss;\n      ss << \"Error executing MySQL query\";\n      ss << \": \" << mysql_error(connection_) << \" (\" << mysql_errno(connection_) << \")\";\n      MOCK_REC_ERROR(mysql_error(connection_), mysql_errno(connection_), mysql_sqlstate(connection_), *this);\n      throw Error(ss.str().c_str(), mysql_errno(connection_));\n    }\n    MYSQL_RES *res = mysql_store_result(connection_);\n    if (res) {\n      unsigned int nfields = mysql_num_fields(res);\n      MOCK_REC_BEGIN(nfields, mysql_fetch_fields(res));\n      std::vector<const char*> outrow;\n      outrow.resize(nfields);\n      MYSQL_ROW row;\n      while ((row = mysql_fetch_row(res))) {\n        MOCK_REC_ROW(row, *this);\n        for (unsigned int i = 0; i < nfields; i++) {\n          outrow[i] = row[i];\n        }\n        try {\n          if (!processor(outrow))\n            break;\n        } catch (...) {\n          mysql_free_result(res);\n          throw;\n        }\n      }\n      MOCK_REC_END();\n      mysql_free_result(res);\n    } else {\n      std::stringstream ss;\n      ss << \"Error fetching query results: \";\n      ss << mysql_error(connection_) << \" (\" << mysql_errno(connection_) << \")\";\n      MOCK_REC_ERROR(mysql_error(connection_), mysql_errno(connection_), mysql_sqlstate(connection_), *this);\n      throw Error(ss.str().c_str(), mysql_errno(connection_));\n    }\n  } else\n    throw std::logic_error(\"Not connected\");\n}\n\nclass RealResultRow : public MySQLSession::ResultRow {\npublic:\n  RealResultRow(const MySQLSession::Row &row, MYSQL_RES *res)\n  : res_(res) {\n    row_ = row;\n  }\n\n  virtual ~RealResultRow() {\n    mysql_free_result(res_);\n  }\nprivate:\n  MYSQL_RES *res_;\n};\n\nMySQLSession::ResultRow *MySQLSession::query_one(const std::string &q) {\n  if (connection_) {\n    MOCK_REC_QUERY_ONE(q);\n    if (mysql_real_query(connection_, q.data(), q.length()) != 0) {\n      std::stringstream ss;\n      ss << \"Error executing MySQL query\";\n      ss << \": \" << mysql_error(connection_) << \" (\" << mysql_errno(connection_) << \")\";\n      MOCK_REC_ERROR(mysql_error(connection_), mysql_errno(connection_), mysql_sqlstate(connection_), *this);\n      throw Error(ss.str().c_str(), mysql_errno(connection_));\n    }\n    MYSQL_RES *res = mysql_store_result(connection_);\n    if (res) {\n      std::vector<const char*> outrow;\n      MYSQL_ROW row;\n      unsigned int nfields = mysql_num_fields(res);\n      MOCK_REC_BEGIN(nfields, mysql_fetch_fields(res));\n      if ((row = mysql_fetch_row(res))) {\n        MOCK_REC_ROW(row, *this);\n        outrow.resize(nfields);\n        for (unsigned int i = 0; i < nfields; i++) {\n          outrow[i] = row[i];\n        }\n      }\n      MOCK_REC_END();\n      if (outrow.empty()) {\n        mysql_free_result(res);\n        return nullptr;\n      }\n      return new RealResultRow(outrow, res);\n    } else {\n      std::stringstream ss;\n      ss << \"Error fetching query results: \";\n      ss << mysql_error(connection_) << \" (\" << mysql_errno(connection_) << \")\";\n      MOCK_REC_ERROR(mysql_error(connection_), mysql_errno(connection_), mysql_sqlstate(connection_), *this);\n      throw Error(ss.str().c_str(), mysql_errno(connection_));\n    }\n  }\n  throw Error(\"Not connected\", 0);  //TODO: query() returns std::logic_error() in such case, should probably be the same\n}\n\nuint64_t MySQLSession::last_insert_id() noexcept {\n  return mysql_insert_id(connection_);\n}\n\nstd::string MySQLSession::quote(const std::string &s, char qchar) noexcept {\n  std::string r;\n  r.resize(s.length()*2+3);\n  r[0] = qchar;\n  unsigned long len = mysql_real_escape_string_quote(connection_, &r[1],\n                                                    s.c_str(), s.length(), qchar);\n  r.resize(len+2);\n  r[len+1] = qchar;\n  return r;\n}\n\nconst char *MySQLSession::last_error() {\n  return connection_ ? mysql_error(connection_) : nullptr;\n}\n\nunsigned int MySQLSession::last_errno() {\n  return connection_ ? mysql_errno(connection_) : 0;\n}\n"
  },
  {
    "path": "src/router/src/common/utils_sqlstring.cc",
    "content": "/*\n * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License, version 2.0,\n * as published by the Free Software Foundation.\n *\n * This program is also distributed with certain software (including\n * but not limited to OpenSSL) that is licensed under separate terms,\n * as designated in a particular file or component or in included license\n * documentation.  The authors of MySQL hereby grant you an additional\n * permission to link the program and your derivative works with the\n * separately licensed software that they have included with MySQL.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n */\n\n#include \"utils_sqlstring.h\"\n#include <string.h>\n\n#ifdef _WIN32\n#  define strcasecmp _stricmp\n#endif\n\n// updated as of 5.7\nstatic const char *reserved_keywords[] = {\n  \"ACCESSIBLE\",\n  \"ADD\",\n  \"ALL\",\n  \"ALTER\",\n  \"ANALYZE\",\n  \"AND\",\n  \"AS\",\n  \"ASC\",\n  \"ASENSITIVE\",\n  \"BEFORE\",\n  \"BETWEEN\",\n  \"BIGINT\",\n  \"BINARY\",\n  \"BLOB\",\n  \"BOTH\",\n  \"BY\",\n  \"CALL\",\n  \"CASCADE\",\n  \"CASE\",\n  \"CHANGE\",\n  \"CHAR\",\n  \"CHARACTER\",\n  \"CHECK\",\n  \"COLLATE\",\n  \"COLUMN\",\n  \"CONDITION\",\n  \"CONSTRAINT\",\n  \"CONTINUE\",\n  \"CONVERT\",\n  \"CREATE\",\n  \"CROSS\",\n  \"CURRENT_DATE\",\n  \"CURRENT_TIME\",\n  \"CURRENT_TIMESTAMP\",\n  \"CURRENT_USER\",\n  \"CURSOR\",\n  \"DATABASE\",\n  \"DATABASES\",\n  \"DAY_HOUR\",\n  \"DAY_MICROSECOND\",\n  \"DAY_MINUTE\",\n  \"DAY_SECOND\",\n  \"DEC\",\n  \"DECIMAL\",\n  \"DECLARE\",\n  \"DEFAULT\",\n  \"DELAYED\",\n  \"DELETE\",\n  \"DESC\",\n  \"DESCRIBE\",\n  \"DETERMINISTIC\",\n  \"DISTINCT\",\n  \"DISTINCTROW\",\n  \"DIV\",\n  \"DOUBLE\",\n  \"DROP\",\n  \"DUAL\",\n  \"EACH\",\n  \"ELSE\",\n  \"ELSEIF\",\n  \"ENCLOSED\",\n  \"ESCAPED\",\n  \"EXISTS\",\n  \"EXIT\",\n  \"EXPLAIN\",\n  \"FALSE\",\n  \"FETCH\",\n  \"FLOAT\",\n  \"FLOAT4\",\n  \"FLOAT8\",\n  \"FOR\",\n  \"FORCE\",\n  \"FOREIGN\",\n  \"FROM\",\n  \"FULLTEXT\",\n  \"GET\",\n  \"GRANT\",\n  \"GROUP\",\n  \"HAVING\",\n  \"HIGH_PRIORITY\",\n  \"HOUR_MICROSECOND\",\n  \"HOUR_MINUTE\",\n  \"HOUR_SECOND\",\n  \"IF\",\n  \"IGNORE\",\n  \"IN\",\n  \"INDEX\",\n  \"INFILE\",\n  \"INNER\",\n  \"INOUT\",\n  \"INSENSITIVE\",\n  \"INSERT\",\n  \"INT\",\n  \"INT1\",\n  \"INT2\",\n  \"INT3\",\n  \"INT4\",\n  \"INT8\",\n  \"INTEGER\",\n  \"INTERVAL\",\n  \"INTO\",\n  \"IO_AFTER_GTIDS\",\n  \"IO_BEFORE_GTIDS\",\n  \"IS\",\n  \"ITERATE\",\n  \"JOIN\",\n  \"KEY\",\n  \"KEYS\",\n  \"KILL\",\n  \"LEADING\",\n  \"LEAVE\",\n  \"LEFT\",\n  \"LIKE\",\n  \"LIMIT\",\n  \"LINEAR\",\n  \"LINES\",\n  \"LOAD\",\n  \"LOCALTIME\",\n  \"LOCALTIMESTAMP\",\n  \"LOCK\",\n  \"LONG\",\n  \"LONGBLOB\",\n  \"LONGTEXT\",\n  \"LOOP\",\n  \"LOW_PRIORITY\",\n  \"MASTER_BIND\",\n  \"MASTER_SSL_VERIFY_SERVER_CERT\",\n  \"MATCH\",\n  \"MAXVALUE\",\n  \"MEDIUMBLOB\",\n  \"MEDIUMINT\",\n  \"MEDIUMTEXT\",\n  \"MIDDLEINT\",\n  \"MINUTE_MICROSECOND\",\n  \"MINUTE_SECOND\",\n  \"MOD\",\n  \"MODIFIES\",\n  \"NATURAL\",\n  \"NONBLOCKING\",\n  \"NOT\",\n  \"NO_WRITE_TO_BINLOG\",\n  \"NULL\",\n  \"NUMERIC\",\n  \"ON\",\n  \"OPTIMIZE\",\n  \"OPTION\",\n  \"OPTIONALLY\",\n  \"OR\",\n  \"ORDER\",\n  \"OUT\",\n  \"OUTER\",\n  \"OUTFILE\",\n  \"PARTITION\",\n  \"PRECISION\",\n  \"PRIMARY\",\n  \"PROCEDURE\",\n  \"PURGE\",\n  \"RANGE\",\n  \"READ\",\n  \"READS\",\n  \"READ_WRITE\",\n  \"REAL\",\n  \"REFERENCES\",\n  \"REGEXP\",\n  \"RELEASE\",\n  \"RENAME\",\n  \"REPEAT\",\n  \"REPLACE\",\n  \"REQUIRE\",\n  \"RESIGNAL\",\n  \"RESTRICT\",\n  \"RETURN\",\n  \"REVOKE\",\n  \"RIGHT\",\n  \"RLIKE\",\n  \"SCHEMA\",\n  \"SCHEMAS\",\n  \"SECOND_MICROSECOND\",\n  \"SELECT\",\n  \"SENSITIVE\",\n  \"SEPARATOR\",\n  \"SET\",\n  \"SHOW\",\n  \"SIGNAL\",\n  \"SMALLINT\",\n  \"SPATIAL\",\n  \"SPECIFIC\",\n  \"SQL\",\n  \"SQLEXCEPTION\",\n  \"SQLSTATE\",\n  \"SQLWARNING\",\n  \"SQL_BIG_RESULT\",\n  \"SQL_CALC_FOUND_ROWS\",\n  \"SQL_SMALL_RESULT\",\n  \"SSL\",\n  \"STARTING\",\n  \"STRAIGHT_JOIN\",\n  \"TABLE\",\n  \"TERMINATED\",\n  \"THEN\",\n  \"TINYBLOB\",\n  \"TINYINT\",\n  \"TINYTEXT\",\n  \"TO\",\n  \"TRAILING\",\n  \"TRIGGER\",\n  \"TRUE\",\n  \"UNDO\",\n  \"UNION\",\n  \"UNIQUE\",\n  \"UNLOCK\",\n  \"UNSIGNED\",\n  \"UPDATE\",\n  \"USAGE\",\n  \"USE\",\n  \"USING\",\n  \"UTC_DATE\",\n  \"UTC_TIME\",\n  \"UTC_TIMESTAMP\",\n  \"VALUES\",\n  \"VARBINARY\",\n  \"VARCHAR\",\n  \"VARCHARACTER\",\n  \"VARYING\",\n  \"WHEN\",\n  \"WHERE\",\n  \"WHILE\",\n  \"WITH\",\n  \"WRITE\",\n  \"XOR\",\n  \"YEAR_MONTH\",\n  \"ZEROFILL\",\n  NULL\n};\n\nnamespace mysqlrouter {\n//--------------------------------------------------------------------------------------------------\n\n/**\n* Escape a string to be used in a SQL query\n* Same code as used by mysql. Handles null bytes in the middle of the string.\n* If wildcards is true then _ and % are masked as well.\n*/\nstd::string escape_sql_string(const std::string &s, bool wildcards) {\n  std::string result;\n  result.reserve(s.size());\n\n  for (std::string::const_iterator ch = s.begin(); ch != s.end(); ++ch) {\n    char escape = 0;\n\n    switch (*ch) {\n      case 0:                             /* Must be escaped for 'mysql' */\n        escape = '0';\n        break;\n      case '\\n':                          /* Must be escaped for logs */\n        escape = 'n';\n        break;\n      case '\\r':\n        escape = 'r';\n        break;\n      case '\\\\':\n        escape = '\\\\';\n        break;\n      case '\\'':\n        escape = '\\'';\n        break;\n      case '\"':                           /* Better safe than sorry */\n        escape = '\"';\n        break;\n      case '\\032':                        /* This gives problems on Win32 */\n        escape = 'Z';\n        break;\n      case '_':\n        if (wildcards)\n          escape = '_';\n        break;\n      case '%':\n        if (wildcards)\n          escape = '%';\n        break;\n    }\n    if (escape) {\n      result.push_back('\\\\');\n      result.push_back(escape);\n    } else\n      result.push_back(*ch);\n  }\n  return result;\n}\n\n//--------------------------------------------------------------------------------------------------\n\n// NOTE: This is not the same as escape_sql_string, as embedded ` must be escaped as ``, not \\`\n// and \\ ' and \" must not be escaped\nstd::string escape_backticks(const std::string &s) {\n  std::string result;\n  result.reserve(s.size());\n\n  for (std::string::const_iterator ch = s.begin(); ch != s.end(); ++ch) {\n    char escape = 0;\n\n    switch (*ch) {\n      case 0:                             /* Must be escaped for 'mysql' */\n        escape = '0';\n        break;\n      case '\\n':                          /* Must be escaped for logs */\n        escape = 'n';\n        break;\n      case '\\r':\n        escape = 'r';\n        break;\n      case '\\032':                        /* This gives problems on Win32 */\n        escape = 'Z';\n        break;\n      case '`':\n        // special case\n        result.push_back('`');\n        break;\n    }\n    if (escape) {\n      result.push_back('\\\\');\n      result.push_back(escape);\n    } else\n      result.push_back(*ch);\n  }\n  return result;\n}\n\n//--------------------------------------------------------------------------------------------------\n\nbool is_reserved_word(const std::string &word) {\n  for (const char **kw = reserved_keywords; *kw != NULL; ++kw) {\n    if (strcasecmp(word.c_str(), *kw) == 0)\n      return true;\n  }\n  return false;\n}\n\n//--------------------------------------------------------------------------------------------------\n\nstd::string quote_identifier(const std::string& identifier, const char quote_char) {\n  return quote_char + identifier + quote_char;\n}\n\n//--------------------------------------------------------------------------------------------------\n\n/**\n* Quotes the given identifier, but only if it needs to be quoted.\n* http://dev.mysql.com/doc/refman/5.1/en/identifiers.html specifies what is allowed in unquoted identifiers.\n* Leading numbers are not strictly forbidden but discouraged as they may lead to ambiguous behavior.\n*/\nstd::string quote_identifier_if_needed(const std::string &ident, const char quote_char) {\n  bool needs_quotation = is_reserved_word(ident);  // check whether it's a reserved keyword\n  size_t digits = 0;\n\n  if (!needs_quotation) {\n    for (std::string::const_iterator i = ident.begin(); i != ident.end(); ++i) {\n      if ((*i >= 'a' && *i <= 'z') || (*i >= 'A' && *i <= 'Z') || (*i >= '0' && *i <= '9')\n          || (*i == '_') || (*i == '$') || ((unsigned char)(*i) > 0x7F)) {\n        if (*i >= '0' && *i <= '9')\n          digits++;\n\n        continue;\n      }\n      needs_quotation = true;\n      break;\n    }\n  }\n\n  if (needs_quotation || digits == ident.length())\n    return quote_char + ident + quote_char;\n  else\n    return ident;\n}\n\nconst sqlstring sqlstring::null(sqlstring(\"NULL\", 0));\nconst sqlstring sqlstring::end(sqlstring(\"\", EndOfInput));\n\n\nsqlstring::sqlstring(const char* format_string, const sqlstringformat format)\n  : _format_string_left(format_string), _format(format) {\n  append(consume_until_next_escape());\n}\n\nsqlstring::sqlstring(const sqlstring &copy)\n  : _formatted(copy._formatted), _format_string_left(copy._format_string_left), _format(copy._format) {}\n\nsqlstring::sqlstring()\n  : _format(0) {}\n\nstd::string sqlstring::consume_until_next_escape() {\n  std::string::size_type e = _format_string_left.length(), p = 0;\n  while (p < e) {\n    char ch = _format_string_left[p];\n    if (ch == '?' || ch == '!')\n      break;\n    ++p;\n  }\n  if (p > 0) {\n    std::string s = _format_string_left.substr(0, p);\n    if (p < e)\n      _format_string_left = _format_string_left.substr(p);\n    else\n      _format_string_left.clear();\n    return s;\n  }\n  return \"\";\n}\n\nint sqlstring::next_escape() {\n  if (_format_string_left.empty())\n    throw std::invalid_argument(\"Error formatting SQL query: more arguments than escapes\");\n  int c = _format_string_left[0];\n  _format_string_left = _format_string_left.substr(1);\n  return c;\n}\n\nsqlstring &sqlstring::append(const std::string &s) {\n  _formatted.append(s);\n  return *this;\n}\n\nsqlstring::operator std::string() const {\n  return _formatted + _format_string_left;\n}\n\nstd::string sqlstring::str() const {\n  return _formatted + _format_string_left;\n}\n\nbool sqlstring::done() const {\n  if (_format_string_left.empty())\n    return true;\n  return _format_string_left[0] != '!' && _format_string_left[0] != '?';\n}\n\nsqlstring &sqlstring::operator <<(const double v) {\n  int esc = next_escape();\n  if (esc != '?')\n    throw std::invalid_argument(\"Error formatting SQL query: invalid escape for numeric argument\");\n\n  append(std::to_string(v));\n  append(consume_until_next_escape());\n\n  return *this;\n}\n\nsqlstring &sqlstring::operator <<(const sqlstringformat format) {\n  _format = format;\n  return *this;\n}\n\nsqlstring &sqlstring::operator <<(const std::string& v) {\n  int esc = next_escape();\n  if (esc == '!') {\n    std::string escaped = escape_backticks(v);\n    if ((_format._flags & QuoteOnlyIfNeeded) != 0)\n      append(quote_identifier_if_needed(escaped, '`'));\n    else\n      append(quote_identifier(escaped, '`'));\n  } else if (esc == '?') {\n    if (_format._flags & UseAnsiQuotes)\n      append(\"\\\"\").append(escape_sql_string(v)).append(\"\\\"\");\n    else\n      append(\"'\").append(escape_sql_string(v)).append(\"'\");\n  } else // shouldn't happen\n    throw std::invalid_argument(\"Error formatting SQL query: internal error, expected ? or ! escape got something else\");\n  append(consume_until_next_escape());\n\n  return *this;\n}\n\nsqlstring &sqlstring::operator <<(const sqlstring& v) {\n  if ((v._format._flags & EndOfInput)) {\n    if (!done())\n      throw std::logic_error(\"Insufficient number of parameters given to sqlstring\");\n    return *this;\n  }\n  next_escape();\n\n  append(v);\n  append(consume_until_next_escape());\n\n  return *this;\n}\n\nsqlstring &sqlstring::operator <<(const char* v) {\n  int esc = next_escape();\n\n  if (esc == '!') {\n    if (!v)\n      throw std::invalid_argument(\"Error formatting SQL query: NULL value found for identifier\");\n    std::string quoted = escape_backticks(v);\n    if (quoted == v && (_format._flags & QuoteOnlyIfNeeded))\n      append(quoted);\n    else\n      append(\"`\").append(quoted).append(\"`\");\n  } else if (esc == '?') {\n    if (v) {\n      if (_format._flags & UseAnsiQuotes)\n        append(\"\\\"\").append(escape_sql_string(v)).append(\"\\\"\");\n      else\n        append(\"'\").append(escape_sql_string(v)).append(\"'\");\n    } else\n      append(\"NULL\");\n  } else // shouldn't happen\n    throw std::invalid_argument(\"Error formatting SQL query: internal error, expected ? or ! escape got something else\");\n  append(consume_until_next_escape());\n\n  return *this;\n}\n}\n"
  },
  {
    "path": "src/router/src/config_files.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n#include \"config_files.h\"\n#include \"router_app.h\"\n#include \"mysql/harness/filesystem.h\"\n\n#include <algorithm>\n#include <fstream>\n\nusing mysqlrouter::string_format;\nconst std::string path_sep = \":\";\n\nstd::string use_ini_extension(const std::string& file_name) {\n  auto pos = file_name.find_last_of(\".conf\");\n  if (pos == std::string::npos || (pos != file_name.length() - 1)) {\n    return std::string();\n  }\n  return file_name.substr(0, pos - 4) + \".ini\";\n}\n\nConfigFiles::ConfigFiles(const std::vector<std::string>& default_config_files,\n    const std::vector<std::string>& config_files,\n    const std::vector<std::string>& extra_config_files) {\n\n  auto config_file_containers = {\n    &default_config_files,\n    &config_files,\n    &extra_config_files\n  };\n\n  for (const vector<string> *vec: config_file_containers) {\n    for (const std::string &file: *vec) {\n      auto pos = std::find(available_config_files_.begin(), available_config_files_.end(), file);\n      if (pos != available_config_files_.end()) {\n        throw std::runtime_error(string_format(\"Duplicate configuration file: %s.\", file.c_str()));\n      }\n      if (mysql_harness::Path(file).is_readable()) {\n        available_config_files_.push_back(file);\n        if (vec != &extra_config_files) {\n          valid_config_count_++;\n        }\n        continue;\n      }\n\n      // if this is a default path we also check *.ini version to be backward compatible\n      // with the previous router versions that used *.ini\n      std::string file_ini;\n      if (vec == &default_config_files) {\n        file_ini = use_ini_extension(file);\n        if (!file_ini.empty() && mysql_harness::Path(file_ini).is_readable()) {\n          available_config_files_.push_back(file_ini);\n          valid_config_count_++;\n          continue;\n        }\n      }\n\n      paths_attempted_.append(file).append(path_sep);\n      if (!file_ini.empty())\n          paths_attempted_.append(file_ini).append(path_sep);\n    }\n  }\n\n  // Can not have extra configuration files when we do not have other configuration files\n  if (!extra_config_files.empty() && valid_config_count_ == 0) {\n    throw std::runtime_error(\"Extra configuration files only work when other configuration files are available.\");\n  }\n}\n\nconst std::vector<std::string>& ConfigFiles::available_config_files() const {\n  return available_config_files_;\n}\n\nconst std::string& ConfigFiles::paths_attempted() const {\n  return paths_attempted_;\n}\n\nbool ConfigFiles::empty() const {\n  return available_config_files_.empty();\n}\n\nsize_t ConfigFiles::size() const {\n  return available_config_files_.size();\n}\n"
  },
  {
    "path": "src/router/src/config_files.h",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef ROUTER_CONFIG_FILES_INCLUDED\n#define ROUTER_CONFIG_FILES_INCLUDED\n\n#include <cstddef>\n#include <string>\n#include <vector>\n\n  /*\n   * @brief Converts configuration file name into legacy configuration file name.\n   * @return legacy configuration file name (ends with .ini suffix) if configuration\n   *         file has .conf suffix, empty string otherwise\n   */\n  std::string use_ini_extension(const std::string& file_name);\n\n/*\n * @class ConfigFiles\n *\n * The class ConfigFiles encapsulates handling of configuration files\n * of different types. There are 3 types of configuration files: default\n * configuration files, configuration files, extra configuration files.\n */\nclass ConfigFiles {\npublic:\n  /*\n   * @brief Constructor with configuration files.\n   *\n   * There are 3 types of configuration files: default configuration files,\n   * configuration files and extra configuration files.\n   *\n   * @param default_config_files list of configuration files which will be read\n   *                             (if available) by default\n   * @param config_files list of configuration files passed using command line\n   * @param extra_config_files list of extra configuration files passed using\n   *                           command line\n   */\n  ConfigFiles(const std::vector<std::string>& default_config_files,\n      const std::vector<std::string>& config_files,\n      const std::vector<std::string>& extra_config_files);\n  /*\n   * @return vector of configuration file names that exist and can be opened for reading.\n   */\n  const std::vector<std::string>& available_config_files() const;\n\n  /*\n   * @return list of comma separated configuration files that were checked if they\n   *         are available.\n   */\n  const std::string& paths_attempted() const;\n\n  /*\n   * @return true if there is at least 1 available configuration file, false otherwise.\n   */\n  bool empty() const;\n\n  /*\n   * @return a number of available configuration files.\n   */\n  size_t size() const;\n\nprivate:\n  // vector of available configuration file names\n  std::vector<std::string> available_config_files_;\n\n  // number of verified config files and defalt config files that were checked\n  size_t valid_config_count_ = 0;\n\n  // list of comma separated configuration files that were checked\n  std::string paths_attempted_;\n};\n\n#endif //ROUTER_CONFIG_FILES_INCLUDED\n"
  },
  {
    "path": "src/router/src/config_generator.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#define MYSQL_ROUTER_LOG_DOMAIN ::mysql_harness::logging::kMainLogger // must precede #include \"logging.h\"\n\n#include \"keyring/keyring_manager.h\"\n#include \"config_generator.h\"\n#include \"mysqlrouter/uri.h\"\n#include \"common.h\"\n#include \"dim.h\"\n#include \"harness_assert.h\"\n#include \"mysql/harness/config_parser.h\"\n#include \"mysql/harness/filesystem.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"rapidjson/rapidjson.h\"\n#include \"random_generator.h\"\n#include \"utils.h\"\n#include \"router_app.h\"\n#include \"mysqlrouter/sha1.h\"\n#include \"tcp_address.h\"\nIMPORT_LOG_FUNCTIONS()\n\n#ifdef _WIN32\n#include <Windows.h>\n#define strcasecmp _stricmp\n#else\n#include <sys/stat.h>\n#endif\n\n\n#include <algorithm>\n#include <cstring>\n#include <fstream>\n#include <iomanip>\n#include <iostream>\n#include <random>\n#include <sstream>\n#include <functional>\n\n#include \"cluster_metadata.h\"\n\nstatic const int kDefaultRWPort = 6446;\nstatic const int kDefaultROPort = 6447;\nstatic const char *kRWSocketName = \"mysql.sock\";\nstatic const char *kROSocketName = \"mysqlro.sock\";\n\nstatic const int kDefaultRWXPort = 64460;\nstatic const int kDefaultROXPort = 64470;\nstatic const char *kRWXSocketName = \"mysqlx.sock\";\nstatic const char *kROXSocketName = \"mysqlxro.sock\";\n\nstatic const int kMaxTCPPortNumber = 65535;\nstatic const int kAllocatedTCPPortCount = 4; // 2 for classic, 2 for X\n\nstatic const std::string kSystemRouterName = \"system\";\n\nstatic const int kMetadataServerPasswordLength = 16;\nstatic const int kMaxRouterNameLength = 255; // must match metadata router.name column\n\nstatic const char *kKeyringAttributePassword = \"password\";\n\nstatic const std::chrono::milliseconds kDefaultMetadataTTL = std::chrono::milliseconds(500);\nstatic constexpr uint32_t kMaxRouterId = 999999;  // max router id is 6 digits due to username size constraints\nstatic constexpr unsigned kNumRandomChars = 12;\nstatic constexpr unsigned kDefaultPasswordRetries = 20; // number of the retries when generating random password\n                                                        // for the router user during the bootstrap\nstatic constexpr unsigned kMaxPasswordRetries = 10000;\n\nusing mysql_harness::get_strerror;\nusing mysql_harness::truncate_string;\nusing mysql_harness::Path;\nusing mysql_harness::UniquePtr;\nusing mysql_harness::DIM;\nusing mysql_harness::TCPAddress;\nusing namespace mysqlrouter;\n\nnamespace {\nstruct password_too_weak: public std::runtime_error {\n  using std::runtime_error::runtime_error;\n};\n\nstruct plugin_not_loaded: public std::runtime_error {\n  using std::runtime_error::runtime_error;\n};\n}\n\n\n/**\n * Return a string representation of the input character string.\n *\n * @param input_str A character string.\n *\n * @return A string object encapsulation of the input character string. An empty\n *         string if input string is nullptr.\n */\nstatic std::string get_string(const char *input_str) {\n  if (input_str == nullptr) {\n    return \"\";\n  }\n  return std::string(input_str);\n}\n\nstatic bool is_valid_name(const std::string& name) {\n  if (!name.empty()) {\n    for (char c : name) {\n      if (c == '\\n' || c=='\\r')\n        return false;\n    }\n  }\n  return true;\n}\n\n\nclass AutoCleaner {\npublic:\n  void add_file_delete(const std::string &f) {\n    files_[f] = std::make_pair(File, \"\");\n  }\n\n  void add_directory_delete(const std::string &d, bool recursive = false) {\n    files_[d] = std::make_pair(recursive ? DirectoryRecursive : Directory, \"\");\n  }\n\n  void add_file_revert(const std::string &file) {\n    add_file_revert(file, file + \".bck\");\n  }\n\n  void add_file_revert(const std::string &file, const std::string &backup_file) {\n    if (mysql_harness::Path(file).is_regular()) {\n      copy_file(file, backup_file);\n      files_[file] = std::make_pair(FileBackup, backup_file);\n    } else {\n      if (mysql_harness::Path(backup_file).exists())\n        mysql_harness::delete_file(backup_file);\n      files_[file] = std::make_pair(File, \"\");\n    }\n  }\n\n  void add_cleanup_callback(const std::string&callback_name, std::function<bool()> callback) noexcept {\n    callbacks_.push_back(CallbackInfo{callback_name, true, callback});\n  }\n\n  void remove(const std::string &p) noexcept {\n    files_.erase(p);\n  }\n\n  void clear() {\n    for (auto f = files_.rbegin(); f != files_.rend(); ++f) {\n      if (f->second.first == FileBackup)\n        mysql_harness::delete_file(f->second.second);\n    }\n    files_.clear();\n\n    for(auto& callback: callbacks_) {\n      callback.should_be_called = false;\n    }\n  }\n\n  ~AutoCleaner() {\n    // remove in reverse order, so that files are deleted before their\n    // contained directories\n    for (auto f = files_.rbegin(); f != files_.rend(); ++f) {\n      switch (f->second.first) {\n        case File:\n          mysql_harness::delete_file(f->first);\n          break;\n\n        case Directory:\n          mysql_harness::delete_dir(f->first);\n          break;\n\n        case DirectoryRecursive:\n          mysql_harness::delete_dir_recursive(f->first);\n          break;\n\n        case FileBackup:\n          copy_file(f->second.second, f->first);\n          mysql_harness::delete_file(f->second.second);\n          break;\n      }\n    }\n\n    for(const auto& callback_info : callbacks_) {\n      if (callback_info.should_be_called)\n        if (!callback_info.callback())\n          log_warning(\"Failed to execute: %s\", callback_info.callback_name.c_str());\n    }\n  }\nprivate:\n  enum Type {\n    Directory,\n    DirectoryRecursive,\n    File,\n    FileBackup\n  };\n\n  /**\n   * @brief Contains callback related information: callback function, callback name and\n   *        information if it should be called.\n   */\n  struct CallbackInfo {\n    /* text that is printed when function call fails */\n    std::string callback_name;\n\n    /* true if callback should be called then, false otherwise */\n    bool should_be_called;\n\n    /* function to call */\n    std::function<bool()> callback;\n  };\n\n  /*\n   * The map stores all the files that are scheduled to be auto-removed or\n   * restored from backup if clean() wasn't called.\n   * The key is a name of file to backup, and value is a pair of\n   * backup's type and name of backup file (used only for FileBackup type).\n   */\n  std::map<std::string, std::pair<Type, std::string>> files_;\n\n  /*\n   * The vector stores callbacks that are scheduled to be called if clean() wasn't called.\n   */\n  std::vector<CallbackInfo> callbacks_;\n};\n\ninline std::string get_opt(const std::map<std::string, std::string> &map,\n                       const std::string &key, const std::string &default_value) {\n  auto iter = map.find(key);\n  if (iter == map.end())\n    return default_value;\n  return iter->second;\n}\n\nConfigGenerator::ConfigGenerator(\n#ifndef _WIN32\n        SysUserOperationsBase* sys_user_operations\n#endif\n        ):\n    connect_timeout_(MySQLSession::kDefaultConnectTimeout),\n    read_timeout_(MySQLSession::kDefaultReadTimeout)\n #ifndef _WIN32\n    ,sys_user_operations_(sys_user_operations)\n #endif\n{}\n\n/*static*/\nvoid ConfigGenerator::set_ssl_options(MySQLSession* sess,\n                                   const std::map<std::string, std::string>& options) {\n\n  std::string ssl_mode = get_opt(options, \"ssl_mode\", MySQLSession::kSslModePreferred);\n  std::string ssl_cipher = get_opt(options, \"ssl_cipher\", \"\");\n  std::string tls_version = get_opt(options, \"tls_version\", \"\");\n  std::string ssl_ca = get_opt(options, \"ssl_ca\", \"\");\n  std::string ssl_capath = get_opt(options, \"ssl_capath\", \"\");\n  std::string ssl_crl = get_opt(options, \"ssl_crl\", \"\");\n  std::string ssl_crlpath = get_opt(options, \"ssl_crlpath\", \"\");\n\n  std::string ssl_cert = get_opt(options, \"ssl_cert\", \"\");\n  std::string ssl_key = get_opt(options, \"ssl_key\", \"\");\n\n  // parse ssl_mode option (already validated in cmdline option handling)\n  mysql_ssl_mode ssl_enum = MySQLSession::parse_ssl_mode(ssl_mode);\n\n  // set ssl mode + server authentication options\n  sess->set_ssl_options(ssl_enum, tls_version, ssl_cipher,\n                        ssl_ca, ssl_capath, ssl_crl, ssl_crlpath);\n\n  // set client authentication options\n  if (!ssl_cert.empty() || !ssl_key.empty()) {\n    sess->set_ssl_cert(ssl_cert, ssl_key);\n  }\n}\n\nbool ConfigGenerator::warn_on_no_ssl(const std::map<std::string, std::string> &options) {\n\n  // warninng applicable only if --ssl-mode=PREFERRED (or not specified, which defaults to PREFERRED)\n  std::string ssl_mode = get_opt(options, \"ssl_mode\", MySQLSession::kSslModePreferred);\n  std::transform(ssl_mode.begin(), ssl_mode.end(), ssl_mode.begin(), toupper);\n\n  if (ssl_mode != MySQLSession::kSslModePreferred)\n    return true;\n\n  // warn if the connection is unencrypted\n  try {\n    // example response\n    //\n    // > show status like \"ssl_cipher\"'\n    // +---------------+--------------------+\n    // | Variable_name | Value              |\n    // +---------------+--------------------+\n    // | Ssl_cipher    | DHE-RSA-AES256-SHA | (or null)\n    // +---------------+--------------------+\n\n    std::unique_ptr<MySQLSession::ResultRow> result(mysql_->query_one(\"show status like 'ssl_cipher'\"));\n    if (!result || result->size() != 2 || strcasecmp((*result)[0], \"ssl_cipher\"))\n      throw std::runtime_error(\"Error reading 'ssl_cipher' status variable\");\n\n    // if ssl_cipher is empty, it means the connection is unencrypted\n    if ((*result)[1] &&\n        (*result)[1][0]) {\n      return true;  // connection is encrypted\n    } else {\n      log_warning(\"WARNING: The MySQL server does not have SSL configured and \"\n                  \"metadata used by the router may be transmitted unencrypted.\");\n      return false; // connection is unencrypted\n    }\n  } catch (std::exception &e) {\n    log_error(\"Failed determining if metadata connection uses SSL: %s\", e.what());\n    throw std::runtime_error(e.what());\n  }\n}\n\nvoid ConfigGenerator::init(const std::string &server_url, const std::map<std::string, std::string> &bootstrap_options) {\n  // ensure defaults are in place in case ::init() gets called again\n  // and they aren't overwritten by bootstrap_options\n  connect_timeout_ = MySQLSession::kDefaultConnectTimeout;\n  read_timeout_ = MySQLSession::kDefaultReadTimeout;\n  std::string uri;\n\n  // check options\n  if (bootstrap_options.find(\"base-port\") != bootstrap_options.end()) {\n    char *end = NULL;\n    const char *tmp = bootstrap_options.at(\"base-port\").c_str();\n    int base_port = static_cast<int>(std::strtol(tmp, &end, 10));\n    int max_base_port = (kMaxTCPPortNumber - kAllocatedTCPPortCount + 1);\n    if (base_port <= 0 || base_port > max_base_port || end != tmp + strlen(tmp)) {\n      throw std::runtime_error(\"Invalid base-port number \" +\n          bootstrap_options.at(\"base-port\") +\n          \"; please pick a value between 1 and \"+std::to_string((max_base_port)));\n    }\n  }\n  if (bootstrap_options.find(\"bind-address\") != bootstrap_options.end()) {\n    auto address = bootstrap_options.at(\"bind-address\");\n    TCPAddress tmp(address, 1);\n    if (!tmp.is_valid()) {\n      throw std::runtime_error(\"Invalid bind-address value \" + address);\n    }\n  }\n  if (bootstrap_options.find(\"connect-timeout\") != bootstrap_options.end()) {\n    char *end = nullptr;\n    const char *tmp = bootstrap_options.at(\"connect-timeout\").c_str();\n    int connect_timeout = static_cast<int>(std::strtol(tmp, &end, 10));\n\n    if (connect_timeout <= 0 || connect_timeout > 65535 || end != tmp + strlen(tmp)) {\n      throw std::runtime_error(\n          \"option connect-timeout needs value between 1 and 65535 inclusive, was \"\n          + std::to_string((connect_timeout)));\n    }\n\n    connect_timeout_ = connect_timeout;\n  }\n  if (bootstrap_options.find(\"read-timeout\") != bootstrap_options.end()) {\n    char *end = nullptr;\n    const char *tmp = bootstrap_options.at(\"read-timeout\").c_str();\n    int read_timeout = static_cast<int>(std::strtol(tmp, &end, 10));\n\n    if (read_timeout <= 0 || read_timeout > 65535 || end != tmp + strlen(tmp)) {\n      throw std::runtime_error(\n          \"option read-timeout needs value between 1 and 65535 inclusive, was \"\n          + std::to_string((read_timeout)));\n    }\n\n    read_timeout_ = read_timeout;\n  }\n\n  const std::string default_schema = \"mysql://\";\n  // Extract connection information from the bootstrap server URL.\n  if (server_url.compare(0, default_schema.size(), default_schema) != 0) {\n    uri = default_schema + server_url;\n  } else {\n    uri = server_url;\n  }\n\n  URI u;\n  try {\n    // don't allow rootless URIs (mailto:foo@...) which would collide with the schema-less\n    // URIs are allow too: root:pw@host\n    u = URIParser::parse(uri, false);\n  } catch (const mysqlrouter::URIError &e) {\n    throw std::runtime_error(e.what());\n  }\n\n  // query, fragment and path should all be empty\n  if (!u.fragment.empty()) {\n    throw std::runtime_error(\"the bootstrap URI contains a #fragement, but shouldn't\");\n  }\n  if (!u.query.empty()) {\n    throw std::runtime_error(\"the bootstrap URI contains a ?query, but shouldn't\");\n  }\n  if (!u.path.empty()) {\n    throw std::runtime_error(\"the bootstrap URI contains a /path, but shouldn't\");\n  }\n\n  if (u.username.empty()) {\n    u.username = \"root\";\n  }\n  // we need to prompt for the password\n  if (u.password.empty()) {\n    u.password = prompt_password(\n      \"Please enter MySQL password for \"+u.username);\n  }\n\n  const auto& it = bootstrap_options.find(\"bootstrap_socket\");\n  std::string socket_name = (it != bootstrap_options.end()) ? it->second : \"\";\n\n  if (socket_name.size() > 0) {\n    // enforce host == \"localhost\" if a socket is used to avoid ambiguity with the possible hostname\n    if (u.host != \"localhost\") {\n      throw std::runtime_error(\"--bootstrap-socket given, but --bootstrap option contains a non-'localhost' hostname: \" + u.host);\n    }\n  } else {\n    // setup localhost address.\n    u.host = (u.host == \"localhost\" ? \"127.0.0.1\" : u.host);\n  }\n\n  mysql_ = DIM::instance().new_MySQLSession();\n  try\n  {\n    set_ssl_options(mysql_.get(), bootstrap_options);\n    mysql_->connect(u.host, u.port, u.username, u.password, socket_name, \"\",\n                    connect_timeout_, read_timeout_);\n  } catch (const MySQLSession::Error &e) {\n    std::stringstream err;\n    err << \"Unable to connect to the metadata server: \" << e.what();\n    throw std::runtime_error(err.str());\n  }\n\n  // check if the current server meta-data server\n  require_innodb_metadata_is_ok(mysql_.get());\n  require_innodb_group_replication_is_ok(mysql_.get());\n\n  gr_initial_username_ = u.username;\n  gr_initial_password_ = u.password;\n  gr_initial_hostname_ = u.host;\n  gr_initial_port_ = u.port;\n  gr_initial_socket_ = socket_name;\n}\n\nvoid ConfigGenerator::bootstrap_system_deployment(const std::string &config_file_path,\n    const std::map<std::string, std::string> &user_options,\n    const std::map<std::string, std::vector<std::string>> &multivalue_options,\n    const std::map<std::string, std::string> &default_paths) {\n  auto options(user_options);\n  bool quiet = user_options.find(\"quiet\") != user_options.end();\n  mysql_harness::Path _config_file_path(config_file_path);\n  AutoCleaner auto_clean;\n\n  std::string router_name;\n  if (user_options.find(\"name\") != user_options.end()) {\n    router_name = user_options.at(\"name\");\n    if (!is_valid_name(router_name))\n      throw std::runtime_error(\"Router name '\" + truncate_string(router_name) + \"' contains invalid characters.\");\n    if (router_name.length() > kMaxRouterNameLength)\n      throw std::runtime_error(\"Router name '\" + truncate_string(router_name) + \"' too long (max \" + std::to_string(kMaxRouterNameLength) + \").\");\n  }\n  if (router_name.empty())\n    router_name = kSystemRouterName;\n\n  if (user_options.find(\"socketsdir\") == user_options.end())\n    options[\"socketsdir\"] = \"/tmp\";\n\n  // (re-)bootstrap the instance\n  UniquePtr<Ofstream> config_file = DIM::instance().new_Ofstream();\n  config_file->open(config_file_path + \".tmp\");\n  if (config_file->fail()) {\n    throw std::runtime_error(\"Could not open \" + config_file_path + \".tmp for writing: \" + get_strerror(errno));\n  }\n  auto_clean.add_file_delete(config_file_path +\".tmp\");\n  bootstrap_deployment(*config_file, _config_file_path,\n    router_name, options, multivalue_options, default_paths,\n    false, auto_clean);\n  config_file->close();\n\n  if (backup_config_file_if_different(config_file_path, config_file_path + \".tmp\", options, &auto_clean)) {\n    if (!quiet)\n      std::cout << \"\\nExisting configurations backed up to '\" << config_file_path << \".bak'\" << std::endl;\n    auto_clean.add_file_delete(config_file_path);\n  }\n\n  // rename the .tmp file to the final file\n  if (mysqlrouter::rename_file((config_file_path + \".tmp\").c_str(), config_file_path.c_str()) != 0) {\n    //log_error(\"Error renaming %s.tmp to %s: %s\", config_file_path.c_str(),\n    //  config_file_path.c_str(), get_strerror(errno));\n    throw std::runtime_error(\"Could not save configuration file to final location\");\n  }\n  try {\n    mysql_harness::make_file_private(config_file_path);\n  } catch (const std::system_error &e) {\n#ifdef _WIN32\n    if (e.code() != std::error_code(ERROR_INVALID_FUNCTION, std::system_category()))\n        // if the filesystem can't set permissions, the test later would fail\n#endif\n      throw;\n  }\n  set_file_owner(options, config_file_path);\n  auto_clean.clear();\n}\n\nstatic bool is_directory_empty(mysql_harness::Directory dir) {\n  for (auto di = dir.begin(); di != dir.end(); ++di) {\n    std::string name = (*di).basename().str();\n    if (name != \".\" && name != \"..\")\n      return false;\n  }\n  return true;\n}\n\nvoid ConfigGenerator::set_keyring_info_real_paths(std::map<std::string, std::string>& options,\n    const mysql_harness::Path& path) {\n  keyring_info_.set_keyring_file(mysql_harness::Path(options[\"datadir\"]).\n      real_path().join(keyring_info_.get_keyring_file()).str());\n  keyring_info_.set_master_key_file(keyring_info_.get_master_key_file().empty() ?\n      \"\" : path.real_path().join(keyring_info_.get_master_key_file()).str());\n}\n\n/**\n * Create a self-contained deployment of the Router in a directory.\n */\nvoid ConfigGenerator::bootstrap_directory_deployment(const std::string &directory,\n    const std::map<std::string, std::string> &user_options,\n    const std::map<std::string, std::vector<std::string>> &multivalue_options,\n    const std::map<std::string, std::string> &default_paths) {\n  bool force = user_options.find(\"force\") != user_options.end();\n  bool quiet = user_options.find(\"quiet\") != user_options.end();\n  mysql_harness::Path path(directory);\n  mysql_harness::Path config_file_path;\n  std::string router_name;\n  AutoCleaner auto_clean;\n\n  if (user_options.find(\"name\") != user_options.end()) {\n    if ((router_name = user_options.at(\"name\")) == kSystemRouterName)\n      throw std::runtime_error(\"Router name '\" + kSystemRouterName + \"' is reserved\");\n    if (!is_valid_name(router_name))\n      throw std::runtime_error(\"Router name '\" + truncate_string(router_name) + \"' contains invalid characters.\");\n    if (router_name.length() > kMaxRouterNameLength)\n      throw std::runtime_error(\"Router name '\" + truncate_string(router_name) + \"' too long (max \"+std::to_string(kMaxRouterNameLength)+\").\");\n  }\n\n  if (!path.exists()) {\n    if (mkdir(directory.c_str(), kStrictDirectoryPerm) < 0) {\n      log_error(\"Cannot create directory '%s': %s\", truncate_string(directory).c_str(), get_strerror(errno).c_str());\n#ifndef _WIN32\n      if (errno == EACCES || errno == EPERM) {\n        log_error(\n          \"This may be caused by insufficient rights or AppArmor settings.\\n\"\n          \"If you have AppArmor enabled try adding full path to the output directory in the mysqlrouter profile file:\\n\"\n          \"/etc/apparmor.d/usr.bin.mysqlrouter\\n\\n\"\n          \"Example:\\n\\n\"\n          \"  /path/to/your/output/dir rw,\\n\"\n          \"  /path/to/your/output/dir/** rw,\"\n        );\n      }\n#endif\n      throw std::runtime_error(\"Could not create deployment directory\");\n    }\n    auto_clean.add_directory_delete(directory, true);\n  }\n\n  if (!Path(directory).is_directory()) {\n    throw std::runtime_error(\"Can't use \" + directory + \" for bootstrap, it is not directory.\");\n  }\n\n  set_file_owner(user_options, directory);\n\n  path = path.real_path();\n  config_file_path = path.join(mysql_harness::Path(\"mysqlrouter.conf\"));\n  if (!config_file_path.exists() && !force && !is_directory_empty(path)) {\n    log_error(\"Directory '%s' already contains files\", directory.c_str());\n    throw std::runtime_error(\"Directory already exits\");\n  }\n\n  std::map<std::string, std::string> options(user_options);\n\n  const std::vector<std::tuple<std::string, std::string, bool>> directories {\n    //              option name   dir_name      mkdir\n    std::make_tuple(\"logdir\",     \"log\",        true),\n    std::make_tuple(\"rundir\",     \"run\",        true),\n    std::make_tuple(\"datadir\",    \"data\",       true),\n    std::make_tuple(\"socketsdir\", \"\", false),\n  };\n\n  for (const auto &dir: directories) {\n    const auto& option_name = std::get<0>(dir);\n    const auto& dir_name = std::get<1>(dir);\n    const auto& do_mkdir = std::get<2>(dir);\n\n    if (user_options.find(option_name) == user_options.end()) {\n      if (dir_name.empty()) {\n        options[option_name] = path.str();\n      } else {\n        options[option_name] = path.join(dir_name).str();\n      }\n    }\n    if (do_mkdir) {\n      if (mkdir(options[option_name].c_str(), kStrictDirectoryPerm) < 0) {\n        if (errno != EEXIST) {\n          log_error(\"Cannot create directory '%s': %s\", truncate_string(options[option_name]).c_str(), get_strerror(errno).c_str());\n          throw std::runtime_error(\"Could not create \" + option_name + \"directory\");\n        }\n      } else {\n        auto_clean.add_directory_delete(options[option_name]);\n      }\n    }\n\n    // sets the directory owner if the directory exists and --user provided\n    set_file_owner(options, options[option_name]);\n  }\n\n  // (re-)bootstrap the instance\n  std::ofstream config_file;\n  config_file.open(config_file_path.str()+\".tmp\");\n  if (config_file.fail()) {\n    throw std::runtime_error(\"Could not open \"+config_file_path.str()+\".tmp for writing: \"+get_strerror(errno));\n  }\n  auto_clean.add_file_delete(config_file_path.str()+\".tmp\");\n  set_keyring_info_real_paths(options, path);\n\n  bootstrap_deployment(config_file, config_file_path, router_name, options, multivalue_options,\n                       default_paths, true, auto_clean); // throws std::runtime_error, ?\n  config_file.close();\n\n  if (backup_config_file_if_different(config_file_path, config_file_path.str() + \".tmp\", options)) {\n    if (!quiet)\n      std::cout << \"\\nExisting configurations backed up to '\" << config_file_path << \".bak'\" << std::endl;\n  }\n\n  // rename the .tmp file to the final file\n  if (mysqlrouter::rename_file((config_file_path.str() + \".tmp\").c_str(), config_file_path.c_str()) != 0) {\n    //log_error(\"Error renaming %s.tmp to %s: %s\", config_file_path.c_str(),\n    //  config_file_path.c_str(), get_strerror(errno));\n    throw std::runtime_error(\"Could not move configuration file '\" +\n      config_file_path.str() + \".tmp' to final location: \"\n       + mysqlrouter::get_last_error());\n  }\n\n  try {\n    mysql_harness::make_file_private(config_file_path.str());\n  } catch (const std::system_error &e) {\n#ifdef _WIN32\n    if (e.code() != std::error_code(ERROR_INVALID_FUNCTION, std::system_category()))\n        // if the filesystem can't set permissions, the test later would fail\n#endif\n      throw;\n  }\n  set_file_owner(options, config_file_path.str());\n\n  // create start/stop scripts\n  create_start_script(path.str(), keyring_info_.get_master_key_file().empty(), options);\n  create_stop_script(path.str(), options);\n\n#ifndef _WIN32\n  // If we are running with --user option we need to check if the user will have access\n  // to the directory where the bootstrap output files were created.\n  // It may not have access if it does not have search right to any of the directories\n  // on the path. We do this by switching to the --user and trying to open the config file.\n  if ( options.find(\"user\") != options.end()) {\n    std::string &user_name = options.at(\"user\");\n\n    set_user(user_name);\n    bool user_has_access{false};\n    {\n      std::ifstream conf_file;\n      conf_file.open(config_file_path.str());\n      user_has_access = !conf_file.fail();\n    }\n    // switch back to root, this is needed to clean up the files in case\n    // the user can't access them and we are failing the bootstrap\n    set_user(\"root\");\n\n    if (!user_has_access) {\n      throw std::runtime_error(\"Could not access the config file as user '\" + user_name\n                               + \"' after the bootstrap in the directory \" + directory + \" : \"\n                               + get_strerror(errno));\n    }\n  }\n#endif\n\n  auto_clean.clear();\n}\n\nConfigGenerator::Options ConfigGenerator::fill_options(\n    bool multi_master,\n    const std::map<std::string, std::string> &user_options) {\n  std::string bind_address{\"0.0.0.0\"};\n  bool use_sockets = false;\n  bool skip_tcp = false;\n  bool skip_classic_protocol = false;\n  bool skip_x_protocol = false;\n  int base_port = 0;\n  if (user_options.find(\"base-port\") != user_options.end()) {\n    char *end = NULL;\n    const char *tmp = user_options.at(\"base-port\").c_str();\n    base_port = static_cast<int>(std::strtol(tmp, &end, 10));\n    int max_base_port = (kMaxTCPPortNumber - kAllocatedTCPPortCount + 1);\n    if (base_port <= 0 || base_port > max_base_port || end != tmp + strlen(tmp)) {\n      throw std::runtime_error(\"Invalid base-port number \" +\n          user_options.at(\"base-port\") +\n          \"; please pick a value lower than \"+std::to_string((max_base_port)));\n    }\n  }\n  if (user_options.find(\"use-sockets\") != user_options.end()) {\n    use_sockets = true;\n  }\n  if (user_options.find(\"skip-tcp\") != user_options.end()) {\n    skip_tcp = true;\n  }\n  ConfigGenerator::Options options;\n  options.multi_master = multi_master;\n  if (user_options.find(\"bind-address\") != user_options.end()) {\n    auto address = user_options.at(\"bind-address\");\n    TCPAddress tmp(address, 1);\n    if (!tmp.is_valid()) {\n      throw std::runtime_error(\"Invalid bind-address value \" + address);\n    }\n    options.bind_address = address;\n  }\n  if (!skip_classic_protocol) {\n    if (use_sockets) {\n      options.rw_endpoint.socket = kRWSocketName;\n      if (!multi_master)\n        options.ro_endpoint.socket = kROSocketName;\n    }\n    if (!skip_tcp) {\n      options.rw_endpoint.port = base_port == 0 ? kDefaultRWPort : base_port++;\n      if (!multi_master)\n        options.ro_endpoint.port = base_port == 0 ? kDefaultROPort : base_port++;\n    }\n  }\n  if (!skip_x_protocol) {\n    if (use_sockets) {\n      options.rw_x_endpoint.socket = kRWXSocketName;\n      if (!multi_master)\n        options.ro_x_endpoint.socket = kROXSocketName;\n    }\n    if (!skip_tcp) {\n      options.rw_x_endpoint.port = base_port == 0 ? kDefaultRWXPort : base_port++;\n      if (!multi_master)\n        options.ro_x_endpoint.port = base_port == 0 ? kDefaultROXPort : base_port++;\n    }\n  }\n  if (user_options.find(\"logdir\") != user_options.end())\n    options.override_logdir = user_options.at(\"logdir\");\n  if (user_options.find(\"rundir\") != user_options.end())\n    options.override_rundir = user_options.at(\"rundir\");\n  if (user_options.find(\"datadir\") != user_options.end())\n    options.override_datadir = user_options.at(\"datadir\");\n  if (user_options.find(\"socketsdir\") != user_options.end())\n    options.socketsdir = user_options.at(\"socketsdir\");\n\n  options.ssl_options.mode = get_opt(user_options, \"ssl_mode\", \"\");\n  options.ssl_options.cipher = get_opt(user_options, \"ssl_cipher\", \"\");\n  options.ssl_options.tls_version = get_opt(user_options, \"tls_version\", \"\");\n  options.ssl_options.ca = get_opt(user_options, \"ssl_ca\", \"\");\n  options.ssl_options.capath = get_opt(user_options, \"ssl_capath\", \"\");\n  options.ssl_options.crl = get_opt(user_options, \"ssl_crl\", \"\");\n  options.ssl_options.crlpath = get_opt(user_options, \"ssl_crlpath\", \"\");\n\n  return options;\n}\n\nnamespace {\n\nunsigned get_password_retries(const std::map<std::string, std::string> &user_options) {\n  if (user_options.find(\"password-retries\") == user_options.end()) {\n    return kDefaultPasswordRetries;\n  }\n\n  char *end = NULL;\n  const char *tmp = user_options.at(\"password-retries\").c_str();\n  unsigned result = static_cast<unsigned>(std::strtoul(tmp, &end, 10));\n  if (result == 0 || result > kMaxPasswordRetries || end != tmp + strlen(tmp)) {\n    throw std::runtime_error(\"Invalid password-retries value '\" +\n        user_options.at(\"password-retries\") +\n        \"'; please pick a value from 1 to \" + std::to_string((kMaxPasswordRetries)));\n  }\n\n  return result;\n}\n\nstd::string compute_password_hash(const std::string &password) {\n  uint8_t hash_stage1[SHA1_HASH_SIZE];\n  my_sha1::compute_sha1_hash(hash_stage1, password.c_str(), password.length());\n  uint8_t hash_stage2[SHA1_HASH_SIZE];\n  my_sha1::compute_sha1_hash(hash_stage2, (const char *) hash_stage1, SHA1_HASH_SIZE);\n\n  std::stringstream ss;\n  ss << \"*\";\n  ss << std::hex << std::setfill('0') << std::uppercase;\n  for (unsigned i = 0; i < SHA1_HASH_SIZE; ++i) {\n    ss << std::setw(2) << (int)hash_stage2[i];\n  }\n\n  return ss.str();\n}\n\ninline std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep) {\n  if (ep.port > 0)\n    return std::to_string(ep.port);\n  else if (!ep.socket.empty())\n    return ep.socket;\n  else\n    return \"null\";\n}\n\n\n}\n\n/**\n * Error codes for MySQL Errors that we handle specifically\n *\n * @todo extend to other MySQL Error codes that need to be handled specifically\n *       and move into a place where other can access it too\n */\nenum class MySQLErrorc {\n  kSyntaxError = 1064,\n  kSuperReadOnly = 1290,\n  kLostConnection = 2013,\n};\n\n/**\n * Group Replication-aware decorator for MySQL Sessions\n */\nclass GrAwareDecorator {\npublic:\n  GrAwareDecorator(MySQLSession &sess,\n      const std::string &gr_initial_username,\n      const std::string &gr_initial_password,\n      const std::string &gr_initial_hostname,\n      unsigned long gr_initial_port,\n      const std::string &gr_initial_socket,\n      unsigned long connection_timeout,\n      std::set<MySQLErrorc> failure_codes = { MySQLErrorc::kSuperReadOnly, MySQLErrorc::kLostConnection }): mysql_(sess),\n  gr_initial_username_(gr_initial_username),\n  gr_initial_password_(gr_initial_password),\n  gr_initial_hostname_(gr_initial_hostname),\n  gr_initial_port_(gr_initial_port),\n  gr_initial_socket_(gr_initial_socket),\n  connection_timeout_(connection_timeout),\n  failure_codes_(failure_codes) {}\n\n  template<class R> R failover_on_failure(std::function<R()> wrapped_func);\nprivate:\n  std::vector<std::tuple<std::string, unsigned long>> fetch_group_replication_hosts();\n\n  MySQLSession &mysql_;\n  const std::string &gr_initial_username_;\n  const std::string &gr_initial_password_;\n  const std::string &gr_initial_hostname_;\n  unsigned long gr_initial_port_;\n  const std::string &gr_initial_socket_;\n  unsigned long connection_timeout_;\n  std::set<MySQLErrorc> failure_codes_;\n};\n\n\n/**\n * group replication aware failover\n *\n * @param wrapped_func function will be called\n *\n * assumes:\n *\n * - actively connected mysql_ session\n * - all nodes in the group have the same user/pass combination\n * - wrapped_func throws MySQLSession::Error with .code in .failure_codes\n */\ntemplate<class R>\nR GrAwareDecorator::failover_on_failure(std::function<R()> wrapped_func) {\n  bool fetched_gr_servers = false;\n  std::vector<std::tuple<std::string, unsigned long>> gr_servers;\n\n  // init it once, even though we'll never use it\n  auto gr_servers_it = gr_servers.begin();\n\n  do {\n    try {\n       return wrapped_func();\n    } catch (const MySQLSession::Error &e) {\n      MySQLErrorc ec = static_cast<MySQLErrorc>(e.code());\n\n      log_info(\"Executing statements failed with: '%s' (%d), trying to connect to another node\",\n          e.what(), e.code());\n\n      // code not in failure-set\n      if (failure_codes_.find(ec) == failure_codes_.end()) {\n        throw;\n      }\n\n      do {\n        if (!fetched_gr_servers) {\n          // lazy fetch the GR members\n          //\n          fetched_gr_servers = true;\n\n          log_info(\"Fetching Group Replication Members\");\n\n          for (auto &gr_node: fetch_group_replication_hosts()) {\n            auto const &gr_host = std::get<0>(gr_node);\n            auto gr_port = std::get<1>(gr_node);\n\n            // if we connected through TCP/IP, ignore the initial host\n            if (gr_initial_socket_.size() == 0 && (gr_host == gr_initial_hostname_ && gr_port == gr_initial_port_)) {\n              continue;\n            }\n\n            log_debug(\"added GR node: %s:%ld\", gr_host.c_str(), gr_port);\n            gr_servers.emplace_back(gr_host, gr_port);\n          }\n\n          // get a new iterator as the old one is now invalid\n          gr_servers_it = gr_servers.begin();\n        } else {\n          std::advance(gr_servers_it, 1);\n        }\n\n        if (gr_servers_it == gr_servers.end()) {\n          throw std::runtime_error(\"no more nodes to fail-over too, giving up.\");\n        }\n\n        if (mysql_.is_connected()) {\n          log_info(\"%s\", \"disconnecting from mysql-server\");\n          mysql_.disconnect();\n        }\n\n        auto const &tp = *gr_servers_it;\n\n        auto const &gr_host = std::get<0>(tp);\n        auto gr_port = std::get<1>(tp);\n\n        log_info(\"trying to connecting to mysql-server at %s:%ld\", gr_host.c_str(), gr_port);\n\n        try {\n          mysql_.connect(gr_host, gr_port, gr_initial_username_, gr_initial_password_, \"\", \"\", connection_timeout_);\n        } catch (const std::exception &inner_e) {\n          log_info(\"Failed connecting to %s:%ld: %s, trying next\", gr_host.c_str(), gr_port, inner_e.what());\n        }\n        // if this fails, we should just skip it and go to the next\n      } while (!mysql_.is_connected());\n    }\n  } while(true);\n}\n\nstd::vector<std::tuple<std::string, unsigned long>>\nGrAwareDecorator::fetch_group_replication_hosts() {\n  std::ostringstream query;\n\n  // Query the name of the replicaset, the servers in the replicaset and the\n  // router credentials using the URL of a server in the replicaset.\n  //\n  // order by member_role (in 8.0 and later) to sort PRIMARY over SECONDARY\n  query <<\n    \"SELECT member_host, member_port \"\n    \"  FROM performance_schema.replication_group_members \"\n    \" /*!80002 ORDER BY member_role */\";\n\n  try {\n    std::vector<std::tuple<std::string, unsigned long>> gr_servers;\n\n    mysql_.query(query.str(),\n        [&gr_servers] (const std::vector<const char*> &row)->bool {\n          gr_servers.push_back(std::make_tuple(std::string(row[0]), std::stoul(row[1])));\n          return true; // don't stop\n        }\n    );\n\n    return gr_servers;\n  } catch (MySQLSession::Error &e) {\n    // log_error(\"MySQL error: %s (%u)\", e.what(), e.code());\n    // log_error(\"    Failed query: %s\", query.str().c_str());\n    throw std::runtime_error(std::string(\"Error querying metadata: \") + e.what());\n  }\n}\n\nvoid ConfigGenerator::init_keyring_and_master_key(AutoCleaner& auto_clean,\n    const std::map<std::string, std::string> &user_options,\n    uint32_t router_id) {\n  // buffer original master key file, it will be restored when bootstrap fails\n  if (!keyring_info_.get_master_key_file().empty())\n    auto_clean.add_file_revert(keyring_info_.get_master_key_file());\n\n  // buffer original master key from external facility, it will be restored when bootstrap fails\n  if (keyring_info_.use_master_key_external_facility()) {\n    // add ROUTER_ID to ENV\n    keyring_info_.add_router_id_to_env(router_id);\n    KeyringInfo keyring_info_copy(false);\n    keyring_info_copy.set_master_key_reader(keyring_info_.get_master_key_reader());\n    keyring_info_copy.set_master_key_writer(keyring_info_.get_master_key_writer());\n    if (keyring_info_copy.read_master_key()) {\n      auto_clean.add_cleanup_callback(\"master_key_writer\", [keyring_info_copy] { return keyring_info_copy.write_master_key(); });\n    }\n  }\n  init_keyring_file(router_id);\n  set_file_owner(user_options, keyring_info_.get_keyring_file());\n  set_file_owner(user_options, keyring_info_.get_master_key_file());\n}\n\nvoid ConfigGenerator::bootstrap_deployment(std::ostream &config_file,\n    const mysql_harness::Path &config_file_path, const std::string &router_name,\n    const std::map<std::string, std::string> &user_options,\n    const std::map<std::string, std::vector<std::string>> &multivalue_options,\n    const std::map<std::string, std::string> &default_paths,\n    bool directory_deployment,\n    AutoCleaner& auto_clean) {\n  std::string primary_cluster_name;\n  std::string primary_replicaset_servers;\n  std::string primary_replicaset_name;\n  bool multi_master = false;\n  bool force = user_options.find(\"force\") != user_options.end();\n  bool quiet = user_options.find(\"quiet\") != user_options.end();\n  uint32_t router_id = 0;\n  std::string username;\n\n  using RandomGen = mysql_harness::RandomGeneratorInterface;\n  RandomGen& rg = mysql_harness::DIM::instance().get_RandomGenerator();\n\n  fetch_bootstrap_servers(\n    primary_replicaset_servers,\n    primary_cluster_name, primary_replicaset_name,\n    multi_master);\n\n  if (config_file_path.exists()) {\n    std::tie(router_id, username) = get_router_id_and_name_from_config(config_file_path.str(),\n                                               primary_cluster_name, force);\n  }\n\n  if (!quiet) {\n    std::string prefix;\n    if (router_id > 0) {\n      prefix = \"\\nReconfiguring\";\n    } else {\n      prefix = \"\\nBootstrapping\";\n    }\n    if (directory_deployment) {\n      std::cout << prefix << \" MySQL Router instance at '\" << config_file_path.dirname() << \"'...\" << std::endl;\n    } else {\n      std::cout << prefix << \" system MySQL Router instance...\" << std::endl;\n    }\n  }\n\n  std::string password;\n\n  Options options(fill_options(multi_master, user_options));\n\n  GrAwareDecorator gr_aware(*mysql_,\n      gr_initial_username_,\n      gr_initial_password_,\n      gr_initial_hostname_,\n      gr_initial_port_,\n      gr_initial_socket_,\n      connect_timeout_);\n\n\n  {\n    const std::string rw_endpoint = str(options.rw_endpoint);\n    const std::string ro_endpoint = str(options.ro_endpoint);\n    const std::string rw_x_endpoint = str(options.rw_x_endpoint);\n    const std::string ro_x_endpoint = str(options.ro_x_endpoint);\n\n    std::tie(password) = gr_aware.failover_on_failure<std::tuple<std::string>>([&]() {\n        return try_bootstrap_deployment(router_id, username,\n          router_name,\n          rg,\n          user_options,\n          multivalue_options,\n          rw_endpoint,\n          ro_endpoint,\n          rw_x_endpoint,\n          ro_x_endpoint);\n        });\n  }\n  init_keyring_and_master_key(auto_clean, user_options, router_id);\n\n  {\n    mysql_harness::Keyring *keyring = mysql_harness::get_keyring();\n\n    keyring->store(username, kKeyringAttributePassword, password);\n    try {\n      mysql_harness::flush_keyring();\n    } catch (std::exception &e) {\n      throw std::runtime_error(std::string(\"Error storing encrypted password to disk: \")+e.what());\n    }\n  }\n\n  options.keyring_file_path = keyring_info_.get_keyring_file();\n  if (keyring_info_.use_master_key_file())\n    options.keyring_master_key_file_path = keyring_info_.get_master_key_file();\n\n#ifndef _WIN32\n  /* Currently at this point the logger is not yet initialized but while bootstraping\n   * with the --user=<user> option we need to create a log file and chown it to the <user>.\n   * Otherwise when the router gets launched later (not bootstrap) with the same --user=<user>\n   * option, the user might not have right to the logging directory.\n   */\n  assert(default_paths.find(\"logging_folder\") != default_paths.end());\n  std::string logdir = (!options.override_logdir.empty()) ? options.override_logdir :\n                                                            default_paths.at(\"logging_folder\");\n  if (!logdir.empty()) {\n    auto log_path = mysql_harness::Path::make_path(logdir, \"mysqlrouter\", \"log\");\n    auto log_file = log_path.str();\n    std::fstream f;\n    f.open(log_file, std::ios::out);\n    set_file_owner(user_options, log_file);\n  }\n#endif\n\n  auto system_username = (user_options.find(\"user\") != user_options.end()) ?  user_options.at(\"user\") : \"\";\n\n  // generate the new config file\n  create_config(config_file, router_id, router_name, system_username,\n                primary_replicaset_servers,\n                primary_cluster_name,\n                primary_replicaset_name,\n                username,\n                options,\n                !quiet);\n}\n\nvoid ConfigGenerator::ensure_router_id_is_ours(uint32_t &router_id,\n                                               std::string &username,\n                                               const std::string &hostname_override,\n                                               MySQLInnoDBClusterMetadata &metadata) {\n  // if router data is valid\n  try {\n    metadata.check_router_id(router_id, hostname_override);\n  } catch (const mysql_harness::SocketOperationsBase::LocalHostnameResolutionError& e) {\n    throw std::runtime_error(\n        std::string(\"Could not verify if this Router instance is already registered with the \"\n                    \"cluster because querying this host's hostname from OS failed:\\n  \") + e.what()\n        + \"\\nYou may want to try --report-host option to manually supply this hostname.\"\n    );\n  } catch (const std::exception &e) {\n    log_warning(\"WARNING: %s\", e.what());\n    // TODO: abort here and suggest --force to force reconfiguration?\n    router_id = 0;\n    username.clear();\n  }\n}\n\nvoid ConfigGenerator::register_router_and_set_username(\n         uint32_t &router_id,\n         const std::string &router_name,\n         std::string &username,\n         const std::string &hostname_override,\n         bool force,\n         MySQLInnoDBClusterMetadata &metadata,\n         mysql_harness::RandomGeneratorInterface &rg) {\n  try {\n    router_id = metadata.register_router(router_name, force, hostname_override);\n  } catch (const mysql_harness::SocketOperationsBase::LocalHostnameResolutionError& e) {\n    throw std::runtime_error(\n        std::string(\"Could not register this Router instance with the cluster because \"\n                    \"querying this host's hostname from OS failed:\\n  \") + e.what()\n        + \"\\nYou may want to try --report-host option to manually supply this hostname.\"\n    );\n  } catch (MySQLSession::Error &e) {\n    if (e.code() == 1062) { // duplicate key\n      throw std::runtime_error(\n          \"It appears that a router instance named '\" + router_name +\n          \"' has been previously configured in this host. If that instance\"\n          \" no longer exists, use the --force option to overwrite it.\"\n      );\n    }\n\n    throw;\n  }\n\n  if (router_id > kMaxRouterId) {\n    throw std::runtime_error(\"router_id (\" + std::to_string(router_id)\n        + \") exceeded max allowable value (\" + std::to_string(kMaxRouterId) + \")\");\n  }\n\n  using RandomGen = mysql_harness::RandomGeneratorInterface;\n  username = \"mysql_router\" + std::to_string(router_id) + \"_\"\n      + rg.generate_identifier(kNumRandomChars,\n                               RandomGen::AlphabetDigits|RandomGen::AlphabetLowercase);\n}\n\nstd::tuple<std::string>\nConfigGenerator::try_bootstrap_deployment(uint32_t &router_id, std::string &username,\n    const std::string &router_name,\n    mysql_harness::RandomGeneratorInterface& rg,\n    const std::map<std::string, std::string> &user_options,\n    const std::map<std::string, std::vector<std::string>> &multivalue_options,\n    const std::string &rw_endpoint,\n    const std::string &ro_endpoint,\n    const std::string &rw_x_endpoint,\n    const std::string &ro_x_endpoint) {\n\n  MySQLSession::Transaction transaction(mysql_.get());\n  MySQLInnoDBClusterMetadata metadata(mysql_.get());\n\n  // set hostname override if provided\n  const auto& it = user_options.find(\"report-host\");\n  const std::string& hostname_override = (it != user_options.end())\n                                         ? it->second\n                                         : \"\";\n  // if reconfiguration;\n  if (router_id > 0) {\n    // throws std::runtime if our hostname couldn't be queried,\n    // resets router_id to 0 and clears username if router_id doesn't exist or\n    // belongs to a different host.\n    // NOTE that these were passed by reference to us, thus they are stored\n    //      outside of this function and will be persisted to the next call.\n    ensure_router_id_is_ours(router_id, username, hostname_override, metadata);\n  }\n\n  // if router not registered yet (or router_id was invalid)\n  if (router_id == 0) {\n    assert(username.empty());\n    bool force = user_options.find(\"force\") != user_options.end();\n\n    // throws std::runtime on failure\n    register_router_and_set_username(router_id, router_name, username,\n                                     hostname_override, force, metadata, rg);\n  }\n\n  assert(router_id);\n  assert(!username.empty());\n\n  // we erase any old accounts with the same name, if they exist\n  delete_account_for_all_hosts(username); // throws MySQLSession::Error, std::logic_error\n\n  // create_router_accounts() throws many things, see its description\n  std::string password = create_router_accounts(user_options, multivalue_options, username);\n\n  metadata.update_router_info(router_id,\n      rw_endpoint,\n      ro_endpoint,\n      rw_x_endpoint,\n      ro_x_endpoint);\n\n  transaction.commit();\n\n  return std::make_tuple(password);\n}\n\nvoid ConfigGenerator::init_keyring_file(uint32_t router_id) {\n\n  if (keyring_info_.use_master_key_external_facility()) {\n    if (!keyring_info_.read_master_key()) {\n      throw MasterKeyWriteError(\"Cannot fetch master key file using master key reader:\" + keyring_info_.get_master_key_reader());\n    }\n\n    if (keyring_info_.get_master_key().empty()) {\n      keyring_info_.add_router_id_to_env(router_id);\n      keyring_info_.generate_master_key();\n      if (!keyring_info_.write_master_key()) {\n        throw MasterKeyWriteError(\"Cannot write master key file using master key writer:\" + keyring_info_.get_master_key_writer());\n      }\n    }\n    mysql_harness::init_keyring_with_key(keyring_info_.get_keyring_file(), keyring_info_.get_master_key(), true);\n  }\n  else if (keyring_info_.use_master_key_file()) {\n    try {\n      mysql_harness::init_keyring(keyring_info_.get_keyring_file(), keyring_info_.get_master_key_file(), true);\n    } catch (mysql_harness::invalid_master_keyfile &) {\n      throw mysql_harness::invalid_master_keyfile(\"Invalid master key file \" + keyring_info_.get_master_key_file());\n    }\n  }\n  else { // prompt for password\n    std::string master_key;\n#ifdef _WIN32\n    // When no master key file is provided, console interaction is required to provide a master password. Since console interaction is not available when\n    // run as service, throw an error to abort.\n    if (mysqlrouter::is_running_as_service()) {\n      std::string msg = \"Cannot run router in Windows a service without a master key file. Please run MySQL Router from the command line (instead of as a service) to create a master keyring file.\";\n      mysqlrouter::write_windows_event_log(msg);\n      throw std::runtime_error(msg);\n    }\n#endif\n    if (mysql_harness::Path(keyring_info_.get_keyring_file()).exists()) {\n      master_key = prompt_password(\"Please provide the encryption key for key file at \" + keyring_info_.get_keyring_file());\n      if (master_key.length() > mysql_harness::kMaxKeyringKeyLength)\n        throw std::runtime_error(\"Encryption key is too long\");\n    } else {\n      std::cout <<\n        \"MySQL Router needs to create a InnoDB cluster metadata client account.\\n\"\n        \"To allow secure storage of its password, please provide an encryption key.\\n\" << std::endl;\n    again:\n      master_key = prompt_password(\"Please provide an encryption key\");\n      if (master_key.empty()) {\n        throw std::runtime_error(\"Keyring encryption key must not be blank\");\n      } else if (master_key.length() > mysql_harness::kMaxKeyringKeyLength) {\n        throw std::runtime_error(\"Encryption key is too long\");\n      } else {\n        std::string confirm = prompt_password(\"Please confirm encryption key\");\n        if (confirm != master_key) {\n          std::cout << \"Entered keys do not match. Please try again.\" << std::endl;\n          goto again;\n        }\n      }\n    }\n    mysql_harness::init_keyring_with_key(keyring_info_.get_keyring_file(), master_key, true);\n  }\n}\n\nvoid ConfigGenerator::fetch_bootstrap_servers(\n  std::string &bootstrap_servers,\n  std::string &metadata_cluster,\n  std::string &metadata_replicaset,\n  bool &multi_master) {\n\n  std::ostringstream query;\n\n  // Query the name of the replicaset, the servers in the replicaset and the\n  // router credentials using the URL of a server in the replicaset.\n  query << \"SELECT \"\n    \"F.cluster_name, \"\n    \"R.replicaset_name, \"\n    \"R.topology_type, \"\n    \"JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic')) \"\n    \"FROM \"\n    \"mysql_innodb_cluster_metadata.clusters AS F, \"\n    \"mysql_innodb_cluster_metadata.instances AS I, \"\n    \"mysql_innodb_cluster_metadata.replicasets AS R \"\n    \"WHERE \"\n    \"R.replicaset_id = \"\n    \"(SELECT replicaset_id FROM mysql_innodb_cluster_metadata.instances WHERE \"\n      \"mysql_server_uuid = @@server_uuid)\"\n    \"AND \"\n    \"I.replicaset_id = R.replicaset_id \"\n    \"AND \"\n    \"R.cluster_id = F.cluster_id\";\n\n  metadata_cluster = \"\";\n  metadata_replicaset = \"\";\n  bootstrap_servers = \"\";\n  try {\n    mysql_->query(query.str(),\n        [&metadata_cluster, &metadata_replicaset, &bootstrap_servers,\n          &multi_master]\n          (const std::vector<const char*> &row)->bool {\n      if (metadata_cluster == \"\") {\n        metadata_cluster = get_string(row[0]);\n      } else if (metadata_cluster != get_string(row[0])) {\n        // metadata with more than 1 replicaset not currently supported\n        throw std::runtime_error(\"Metadata contains more than one cluster\");\n      }\n      if (metadata_replicaset == \"\") {\n        metadata_replicaset = get_string(row[1]);\n      } else if (metadata_replicaset != get_string(row[1])) {\n        // metadata with more than 1 replicaset not currently supported\n        throw std::runtime_error(\"Metadata contains more than one replica-set\");\n      }\n      if (bootstrap_servers != \"\")\n        bootstrap_servers += \",\";\n      if (row[2]) {\n        if (strcmp(row[2], \"mm\") == 0)\n          multi_master = true;\n        else if (strcmp(row[2], \"pm\") == 0)\n          multi_master = false;\n        else\n          throw std::runtime_error(\"Unknown topology type in metadata: \"\n                                   + std::string(row[2]));\n      }\n      bootstrap_servers += \"mysql://\" + get_string(row[3]);\n      return true;\n    });\n  } catch (MySQLSession::Error &e) {\n    // log_error(\"MySQL error: %s (%u)\", e.what(), e.code());\n    // log_error(\"    Failed query: %s\", query.str().c_str());\n    throw std::runtime_error(std::string(\"Error querying metadata: \") + e.what());\n  }\n  if (metadata_cluster.empty())\n    throw std::runtime_error(\"No clusters defined in metadata server\");\n}\n\n// TODO This is very ugly, it should not be a global. It's set in main(), and\n//      used in find_executable_path() below to provide path to Router binary\n//      when generating start.sh.\nstd::string g_program_name;\n\n#ifdef _WIN32\n// This is only for Windows\nstatic std::string find_plugin_path() {\n  char szPath[MAX_PATH];\n  if (GetModuleFileName(NULL, szPath, sizeof(szPath)) != 0) {\n    mysql_harness::Path mypath(szPath);\n    mysql_harness::Path mypath2(mypath.dirname().dirname());\n    mypath2.append(\"lib\");\n    return std::string(mypath2.str());\n  }\n  throw std::logic_error(\"Could not find own installation directory\");\n}\n#endif\n\nstatic std::string find_executable_path() {\n#ifdef _WIN32\n  // the bin folder is not usually in the path, just the lib folder\n  char szPath[MAX_PATH];\n  if (GetModuleFileName(NULL, szPath, sizeof(szPath)) != 0)\n  {\n    char *pc = szPath - 1;\n    while (*++pc)\n      if (*pc == '\\\\') *pc = '/';\n    return std::string(szPath);\n  }\n#else\n  harness_assert(!g_program_name.empty());\n\n  if (g_program_name.find('/') != std::string::npos) {\n    char *tmp = realpath(g_program_name.c_str(), NULL);\n    harness_assert(tmp);  // will fail if g_program_name provides bogus path\n    std::string path(tmp);\n    free(tmp);\n    return path;\n  } else {\n    std::string path(std::getenv(\"PATH\"));\n    char *last = NULL;\n    char *p = strtok_r(&path[0], \":\", &last);\n    while (p) {\n      if (*p && p[strlen(p)-1] == '/')\n        p[strlen(p)-1] = 0;\n      std::string tmp(std::string(p)+\"/\"+g_program_name);\n      if (access(tmp.c_str(), R_OK|X_OK) == 0) {\n        return tmp;\n      }\n      p = strtok_r(NULL, \":\", &last);\n    }\n  }\n#endif\n  throw std::logic_error(\"Could not find own installation directory\");\n}\n\nstd::string ConfigGenerator::endpoint_option(const Options &options,\n                                             const Options::Endpoint &ep) {\n  std::string r;\n  if (ep.port > 0) {\n    auto bind_address = (!options.bind_address.empty()) ? options.bind_address : \"0.0.0.0\";\n    r.append(\"bind_address=\" + bind_address + \"\\n\");\n    r.append(\"bind_port=\" + std::to_string(ep.port));\n  }\n  if (!ep.socket.empty()) {\n    if (!r.empty())\n      r.append(\"\\n\");\n    r.append(\"socket=\" + options.socketsdir + \"/\" + ep.socket);\n  }\n  return r;\n}\n\n\nstatic std::string option_line(const std::string &key, const std::string &value) {\n  if (!value.empty()) {\n    return key + \"=\" + value + \"\\n\";\n  }\n  return \"\";\n}\n\nvoid ConfigGenerator::create_config(std::ostream &cfp,\n                                    uint32_t router_id,\n                                    const std::string &router_name,\n                                    const std::string &system_username,\n                                    const std::string &bootstrap_server_addresses,\n                                    const std::string &metadata_cluster,\n                                    const std::string &metadata_replicaset,\n                                    const std::string &username,\n                                    const Options &options,\n                                    bool print_configs) {\n  cfp << \"# File automatically generated during MySQL Router bootstrap\\n\";\n\n  cfp << \"[DEFAULT]\\n\";\n  if (!router_name.empty())\n    cfp << \"name=\" << router_name << \"\\n\";\n  if (!system_username.empty())\n    cfp << \"user=\" << system_username << \"\\n\";\n  if (!options.override_logdir.empty())\n    cfp << \"logging_folder=\" << options.override_logdir << \"\\n\";\n  if (!options.override_rundir.empty())\n    cfp << \"runtime_folder=\" << options.override_rundir << \"\\n\";\n  if (!options.override_datadir.empty())\n    cfp << \"data_folder=\" << options.override_datadir << \"\\n\";\n  if (!options.keyring_file_path.empty())\n    cfp << \"keyring_path=\" << options.keyring_file_path << \"\\n\";\n  if (!options.keyring_master_key_file_path.empty())\n    cfp << \"master_key_path=\" << options.keyring_master_key_file_path << \"\\n\";\n  if (!keyring_info_.get_master_key_reader().empty())\n    cfp << \"master_key_reader=\" << keyring_info_.get_master_key_reader() << \"\\n\";\n  if (!keyring_info_.get_master_key_writer().empty())\n    cfp << \"master_key_writer=\" << keyring_info_.get_master_key_writer() << \"\\n\";\n\n  cfp << \"connect_timeout=\" << connect_timeout_ << \"\\n\";\n  cfp << \"read_timeout=\" << read_timeout_ << \"\\n\";\n\n  const std::string metadata_key = metadata_cluster;\n  cfp << \"\\n\"\n      << \"[\" << mysql_harness::logging::kConfigSectionLogger << \"]\\n\"\n      << mysql_harness::logging::kConfigOptionLogLevel << \" = INFO\\n\"\n      << \"\\n\"\n      << \"[metadata_cache:\" << metadata_key << \"]\\n\"\n      << \"router_id=\" << router_id << \"\\n\"\n      << \"bootstrap_server_addresses=\" << bootstrap_server_addresses << \"\\n\"\n      << \"user=\" << username << \"\\n\"\n      << \"metadata_cluster=\" << metadata_cluster << \"\\n\"\n      << \"ttl=\" << mysqlrouter::ms_to_seconds_string(kDefaultMetadataTTL) << \"\\n\";\n\n  // SSL options\n  cfp << option_line(\"ssl_mode\", options.ssl_options.mode);\n  cfp << option_line(\"ssl_cipher\", options.ssl_options.cipher);\n  cfp << option_line(\"tls_version\", options.ssl_options.tls_version);\n  cfp << option_line(\"ssl_ca\", options.ssl_options.ca);\n  cfp << option_line(\"ssl_capath\", options.ssl_options.capath);\n  cfp << option_line(\"ssl_crl\", options.ssl_options.crl);\n  cfp << option_line(\"ssl_crlpath\", options.ssl_options.crlpath);\n  // Note: we don't write cert and key because\n  // creating router accounts with REQUIRE X509 is not yet supported.\n  // The cert and key options passed to bootstrap if for the bootstrap\n  // connection itself.\n  cfp << \"\\n\";\n\n  const std::string fast_router_key = metadata_key+\"_\"+metadata_replicaset;\n  if (options.rw_endpoint) {\n    cfp\n      << \"[routing:\" << fast_router_key << \"_rw]\\n\"\n      << endpoint_option(options, options.rw_endpoint) << \"\\n\"\n      << \"destinations=metadata-cache://\" << metadata_key << \"/\"\n          << metadata_replicaset << \"?role=PRIMARY\\n\"\n      << \"routing_strategy=round-robin\\n\"\n      << \"protocol=classic\\n\"\n      << \"\\n\";\n  }\n  if (options.ro_endpoint) {\n    cfp\n      << \"[routing:\" << fast_router_key << \"_ro]\\n\"\n      << endpoint_option(options, options.ro_endpoint) << \"\\n\"\n      << \"destinations=metadata-cache://\" << metadata_key << \"/\"\n          << metadata_replicaset << \"?role=SECONDARY\\n\"\n      << \"routing_strategy=round-robin\\n\"\n      << \"protocol=classic\\n\"\n      << \"\\n\";\n  }\n  if (options.rw_x_endpoint) {\n    cfp\n      << \"[routing:\" << fast_router_key << \"_x_rw]\\n\"\n      << endpoint_option(options, options.rw_x_endpoint) << \"\\n\"\n      << \"destinations=metadata-cache://\" << metadata_key << \"/\"\n          << metadata_replicaset << \"?role=PRIMARY\\n\"\n      << \"routing_strategy=round-robin\\n\"\n      << \"protocol=x\\n\"\n      << \"\\n\";\n  }\n  if (options.ro_x_endpoint) {\n    cfp\n      << \"[routing:\" << fast_router_key << \"_x_ro]\\n\"\n      << endpoint_option(options, options.ro_x_endpoint) << \"\\n\"\n      << \"destinations=metadata-cache://\" << metadata_key << \"/\"\n          << metadata_replicaset << \"?role=SECONDARY\\n\"\n      << \"routing_strategy=round-robin\\n\"\n      << \"protocol=x\\n\"\n      << \"\\n\";\n  }\n  cfp.flush();\n\n  if (print_configs) {\n    std::cout\n        << \"MySQL Router \"\n        << ((router_name.empty() || router_name == kSystemRouterName) ? \"\" : \"'\"+router_name+\"'\")\n        << \" has now been configured for the InnoDB cluster '\"\n        << metadata_cluster.c_str() << \"'\"\n        << (options.multi_master ? \" (multi-master)\" : \"\")\n        << \".\\n\" << std::endl;\n\n    std::cout << \"The following connection information can be used to connect to the cluster.\\n\" << std::endl;\n    if (options.rw_endpoint || options.ro_endpoint) {\n      std::cout << \"Classic MySQL protocol connections to cluster '\" << metadata_cluster << \"':\" << std::endl;\n      if (options.rw_endpoint.port > 0)\n        std::cout << \"- Read/Write Connections: localhost:\" << options.rw_endpoint.port << std::endl;\n      if (!options.rw_endpoint.socket.empty())\n        std::cout << \"- Read/Write Connections: \" << options.socketsdir << \"/\" << options.rw_endpoint.socket << std::endl;\n      if (options.ro_endpoint.port > 0)\n        std::cout << \"- Read/Only Connections: localhost:\" << options.ro_endpoint.port << std::endl;\n      if (!options.ro_endpoint.socket.empty())\n        std::cout << \"- Read/Only Connections: \" << options.socketsdir << \"/\" << options.ro_endpoint.socket << \"\\n\" << std::endl;\n    }\n    if (options.rw_x_endpoint || options.ro_x_endpoint) {\n      std::cout << \"X protocol connections to cluster '\" << metadata_cluster << \"':\" << std::endl;\n      if (options.rw_x_endpoint.port > 0)\n        std::cout << \"- Read/Write Connections: localhost:\" << options.rw_x_endpoint.port << std::endl;\n      if (!options.rw_x_endpoint.socket.empty())\n        std::cout << \"- Read/Write Connections: \" << options.socketsdir << \"/\" << options.rw_x_endpoint.socket << std::endl;\n      if (options.ro_x_endpoint.port > 0)\n        std::cout << \"- Read/Only Connections: localhost:\" << options.ro_x_endpoint.port << std::endl;\n      if (!options.ro_x_endpoint.socket.empty())\n        std::cout << \"- Read/Only Connections: \" << options.socketsdir.c_str() << \"/\" << options.ro_x_endpoint.socket << std::endl;\n    }\n  }\n}\n\n/**\n * create account to be used by Router.\n *\n * `<host>` part of `<user>@<host>` will be %, unless user specified otherwise\n * using --account-host switch. Multiple --account-host switches are allowed.\n */\nstd::string ConfigGenerator::create_router_accounts(const std::map<std::string, std::string> &user_options,\n                                                    const std::map<std::string, std::vector<std::string>> &multivalue_options,\n                                                    const std::string &username) {\n  /*\n  Ideally, we create a single account for the specific host that the router is\n  running on. But that has several problems in real world, including:\n  - if you're configuring on localhost ref to metadata server, the router will\n  think it's in localhost and thus it will need 2 accounts: user@localhost\n  and user@public_ip... further, there could be more than 1 IP for the host,\n  which (like lan IP, localhost, internet IP, VPN IP, IPv6 etc). We don't know\n  which ones are needed, so either we need to automatically create all of those\n  or have some very complicated and unreliable logic.\n  - using hostname is not reliable, because not every place will have name\n  resolution availble\n  - using IP (even if we can detect it correctly) will not work if IP is not\n  static\n\n  Summing up, '%' is the easy way to avoid these problems. But the decision\n  ultimately belongs to the user.\n  */\n\n  // extract --account-host args; if none were given, default to just one: \"%\"\n  // NOTE: By the time we call this function, all --account-host entries should\n  //       be sorted and any non-unique entries eliminated (to ensure CREATE USER\n  //       does not get called twice for the same user@host). This happens at the\n  //       commandline parsing level during --account-host processing.\n  constexpr const char kAccountHost[] = \"account-host\";\n  const std::vector<std::string>& hostnames = multivalue_options.count(kAccountHost)\n      ? multivalue_options.at(kAccountHost)\n      : std::vector<std::string>{\"%\"};\n\n  // NOTE ON EXCEPTIONS:\n  // create_account*() functions throw many things (see their descriptions)\n  // - we let the higher-level logic deal with them when that happens.\n\n  // create first account and save password info that got generated in the process\n  std::pair<std::string, bool> password_and_is_hashed =\n      create_account_with_compliant_password(user_options, username, hostnames.front());\n\n  // and now we use that password info for creation of remaining accounts\n  for (auto it = hostnames.begin() + 1; it != hostnames.end(); ++it) {\n    try {\n      create_account(username, *it, password_and_is_hashed.first /*password*/,\n                     password_and_is_hashed.second /*hash password*/);\n    }\n\n    // create_account_with_compliant_password() should have caught these (and\n    // dealt with them accordingly), since these occur either always or never.\n    // The only way these could occur here is if the Server's responses changed\n    // for some reason (reconfigured in the meantime?). Anyhow, probably an\n    // unlikely event.\n    catch (const plugin_not_loaded&) {\n      throw std::runtime_error(\"Error creating user account: unexpected error: \"\n          \"plugin not loaded (it seems Server changed its password policy, \"\n          \"has it been reconfigured in the meantime?)\");\n    } catch (const password_too_weak&) {\n      throw std::runtime_error(\"Error creating user account: unexpected error: \"\n          \"password too weak (it seems Server changed its password policy, \"\n          \"has it been reconfigured in the meantime?)\");\n    } catch (...) {\n      throw;  // all others we pass\n    }\n  }\n\n  return password_and_is_hashed.first;\n}\n\nstd::pair<std::string, bool> ConfigGenerator::create_account_with_compliant_password(\n                                                  const std::map<std::string, std::string> &user_options,\n                                                  const std::string &username,\n                                                  const std::string &hostname) {\n  using RandomGen = mysql_harness::RandomGeneratorInterface;\n  RandomGen& rg = mysql_harness::DIM::instance().get_RandomGenerator();\n\n  const bool force_password_validation = user_options.find(\"force-password-validation\") != user_options.end();\n  std::string password;\n  unsigned retries = get_password_retries(user_options);  // throws std::runtime_error\n  if (!force_password_validation) {\n    // 1) Try to create an account using mysql_native_password with the hashed password\n    //    to avoid validate_password verification (hashing is done inside create_account())\n    password = rg.generate_strong_password(kMetadataServerPasswordLength);\n    try {\n      // create_account() throws many things, see its description\n      create_account(username, hostname, password, true /*hash password*/);\n      return std::make_pair(password, true);\n    }\n    catch (const plugin_not_loaded&) {\n      // fallback to 2)\n    }\n  }\n\n  // 2) If 1) failed because of the missing mysql_native_password plugin,\n  //    or \"-force-password-validation\" parameter has being used\n  //    try to create an account using the password directly\n  while (true) {\n    password = rg.generate_strong_password(kMetadataServerPasswordLength);\n\n    try {\n      // create_account() throws many things, see its description\n      create_account(username, hostname, password, false /*hash password*/);\n      return std::make_pair(password, false);\n    }\n    catch (const password_too_weak& e) {\n      if (--retries == 0) {\n        // 3) If 2) failed issue an error suggesting the change to validate_password rules\n        std::stringstream err_msg;\n        err_msg << \"Error creating user account: \" << e.what() << std::endl\n                << \" Try to decrease the validate_password rules and try the operation again.\";\n        throw std::runtime_error(err_msg.str());\n      }\n      // generated password does not satisfy the current policy requirements.\n      // we do our best to generate strong password but with the validate_password\n      // plugin, the user can set very strong or unusual requirements that we are not able to\n      // predict so we just retry several times hoping to meet the requirements with the next\n      // generated password.\n      continue;\n    }\n  }\n\n  harness_assert_this_should_not_execute();\n}\n\n/*\n  Create MySQL account for this instance of the router in the target cluster.\n\n  The account will have access to the cluster metadata and to the\n  replication_group_members table of the performance_schema.\n  Note that this assumes that the metadata schema is stored in the destinations\n  cluster and that there is only one replicaset in it.\n */\nvoid ConfigGenerator::create_account(const std::string &username,\n                                     const std::string &hostname,\n                                     const std::string &password,\n                                     bool hash_password) {\n\n  const std::string account = username + \"@\" + mysql_->quote(hostname);\n  log_info(\"Creating account %s\", account.c_str());\n\n  const std::string create_user = \"CREATE USER \" + account + \" IDENTIFIED \"\n      + (hash_password ? \"WITH mysql_native_password AS \" : \"BY \")\n      + mysql_->quote(hash_password ? compute_password_hash(password) : password);\n//    + mysql_->quote(password) + \" REQUIRE X509\";\n\n  const std::vector<std::string> queries{\n    create_user,\n    \"GRANT SELECT ON mysql_innodb_cluster_metadata.* TO \" + account,\n    \"GRANT SELECT ON performance_schema.replication_group_members TO \" + account,\n    \"GRANT SELECT ON performance_schema.replication_group_member_stats TO \" + account\n  };\n\n  for (auto &q : queries) {\n    try {\n      mysql_->execute(q); // throws MySQLSession::Error, std::logic_error\n    } catch (MySQLSession::Error &e) {\n      // log_error(\"%s: executing query: %s\", e.what(), q.c_str());\n      try {\n        mysql_->execute(\"ROLLBACK\");\n      } catch (...) {\n        // log_error(\"Could not rollback transaction explicitly.\");\n      }\n      std::string err_msg = std::string(\"Error creating MySQL account for router: \") + e.what();\n      if (e.code() == 1819) { // password does not satisfy the current policy requirements\n        throw password_too_weak(err_msg);\n      }\n      if (e.code() == 1524) { // plugin not loaded\n        throw plugin_not_loaded(err_msg);\n      }\n\n      // it shouldn't have failed, let the upper layers try to handle it\n      throw MySQLSession::Error(err_msg, e.code());\n    }\n  }\n}\n\nvoid ConfigGenerator::delete_account_for_all_hosts(const std::string& username) {\n  std::vector<std::string> hostnames;\n\n  log_info(\"Checking for old Router accounts\");\n  {\n    // throws MySQLSession::Error, should be handled by caller\n    mysql_->query(\"SELECT host FROM mysql.user WHERE user = '\" + username + \"'\",\n                  [&hostnames](const std::vector<const char*>& row) -> bool {\n                    harness_assert(row.size() == 1);  // expect just 1 column\n                    hostnames.push_back(row[0]);\n                    return true; // don't stop\n                  });\n\n    if (hostnames.size() < 1) {\n      log_debug(\"No prior Router accounts found\");\n      return;\n    }\n  }\n\n  log_info(\"Found old Router accounts, removing\");\n  {\n    // build DROP USER statement to erase all existing accounts\n    std::string query = \"DROP USER \";\n    for (std::string& host : hostnames)\n      query += username + \"@\" + mysql_->quote(host) + \",\";\n    query.resize(query.size() - 1); // erase last ','\n\n    // throws MySQLSession::Error and std::logic_error, both should be handled by caller\n    mysql_->execute(query);\n  }\n}\n\n/**\n * Get router_id name values associated with a metadata_cache configuration for\n * the given cluster_name.\n *\n * The lookup is done through the metadata_cluster option inside the\n * metadata_cache section.\n */\nstd::pair<uint32_t, std::string> ConfigGenerator::get_router_id_and_name_from_config(\n    const std::string &config_file_path,\n    const std::string &cluster_name,\n    bool forcing_overwrite) {\n  mysql_harness::Path path(config_file_path);\n  std::string existing_cluster;\n  if (path.exists()) {\n    mysql_harness::Config config(mysql_harness::Config::allow_keys);\n    config.read(path);\n    mysql_harness::Config::SectionList sections;\n    if (config.has_any(\"metadata_cache\")) {\n      sections = config.get(\"metadata_cache\");\n    } else {\n      return std::make_pair(0, \"\");\n    }\n    if (sections.size() > 1) {\n      throw std::runtime_error(\"Bootstrapping of Router with multiple metadata_cache sections not supported\");\n    }\n    for (auto const &section : sections) {\n      if (section->has(\"metadata_cluster\")) {\n        existing_cluster = section->get(\"metadata_cluster\");\n        if (existing_cluster == cluster_name) {\n          // get router_id\n          if (! section->has(\"router_id\")) {\n            log_warning(\"WARNING: router_id not set for cluster '%s'\", cluster_name.c_str());\n            return std::make_pair(0, \"\");\n          }\n          std::string tmp = section->get(\"router_id\");\n          char *end;\n          unsigned long r = std::strtoul(tmp.c_str(), &end, 10);\n          if (end == tmp.c_str() || errno == ERANGE) {\n              throw std::runtime_error(\"Invalid router_id '\"+tmp\n                  +\"' for cluster '\"+cluster_name+\"' in \"+config_file_path);\n          }\n\n          // get username, example: user=mysql_router4_kot8tcepf3kn\n          if (! section->has(\"user\")) {\n            log_warning(\"WARNING: user not set for cluster '%s'\", cluster_name.c_str());\n            return std::make_pair(0, \"\");\n          }\n          std::string user = section->get(\"user\");\n\n          // return results\n          return std::make_pair(static_cast<uint32_t>(r), user);\n        }\n      }\n    }\n  }\n  if (!forcing_overwrite) {\n    std::string msg;\n    msg += \"The given Router instance is already configured for a cluster named '\"+existing_cluster+\"'.\\n\";\n    msg += \"If you'd like to replace it, please use the --force configuration option.\";\n    //XXX when multiple-clusters is supported, also suggest --add\n    throw std::runtime_error(msg);\n  }\n  return std::make_pair(0, \"\");\n}\n\n/* virtual */\nvoid ConfigGenerator::set_script_permissions(const std::string& script_path,\n                                             const std::map<std::string, std::string> &options) {\n// we only call this method from unix-specific code\n#ifndef _WIN32\n  if (::chmod(script_path.c_str(), kStrictDirectoryPerm) < 0) {\n    std::cerr << \"Could not change permissions for \" << script_path << \": \" << get_strerror(errno) << \"\\n\";\n  }\n  set_file_owner(options, script_path);\n#endif\n}\n\nvoid ConfigGenerator::create_start_script(const std::string &directory,\n                                          bool interactive_master_key,\n                                          const std::map<std::string, std::string> &options) {\n#ifdef _WIN32\n\n  std::ofstream script;\n  std::string script_path = directory + \"/start.ps1\";\n\n  script.open(script_path);\n  if (script.fail()) {\n    throw std::runtime_error(\"Could not open \" + script_path + \" for writing: \" + get_strerror(errno));\n  }\n  script << \"$env:path += \\\";\" << find_plugin_path() << \"\\\"\" << std::endl;\n  script << \"[Environment]::SetEnvironmentVariable(\\\"ROUTER_PID\\\",\" << \"\\\"\" << directory << \"\\\\\" << \"mysqlrouter.pid\\\", \\\"Process\\\")\" << std::endl;\n  script << \"Start-Process \\\"\" << find_executable_path() << \"\\\" \\\" -c \" << directory << \"/mysqlrouter.conf\\\"\" << \" -WindowStyle Hidden\" << std::endl;\n  script.close();\n\n#else\n\n  std::ofstream script;\n  std::string script_path = directory + \"/start.sh\";\n\n  script.open(script_path);\n  if (script.fail()) {\n    throw std::runtime_error(\"Could not open \" + script_path + \" for writing: \" + get_strerror(errno));\n  }\n  script << \"#!/bin/bash\\n\";\n  script << \"basedir=\" << directory << \"\\n\";\n  if (interactive_master_key) {\n    // prompt for password if master_key_path is not set\n    script << \"old_stty=`stty -g`\\n\";\n    script << \"stty -echo\\n\";\n    script << \"echo -n 'Encryption key for router keyring:'\\n\";\n    script << \"read password\\n\";\n    script << \"stty $old_stty\\n\";\n    script << \"echo $password | \";\n  }\n\n  // Router launch command\n  {\n    std::string main_cmd = \"ROUTER_PID=$basedir/mysqlrouter.pid \"\n        + find_executable_path() + \" -c $basedir/mysqlrouter.conf \";\n\n    if (options.find(\"user\") != options.end()) {\n      // if --user was given, we use it to generate shell code that works for both cases:\n      //   - when owner runs this script -> run without sudo and --user\n      //   - when someone else runs it   -> run with    sudo and --user\n\n      const std::string owner_name = options.at(\"user\");\n      harness_assert(!owner_name.empty());\n\n      script << \"if [ `whoami` == '\" << owner_name << \"' ]; then\"                \"\\n\"\n             << \"  \" << main_cmd << \"&\"                                          \"\\n\"\n             << \"else\"                                                           \"\\n\"\n             << \"  \" << \"sudo \" << main_cmd << \"--user=\" << owner_name << \" &\"   \"\\n\"\n             << \"fi\"                                                             \"\\n\";\n    } else {\n      // if --user was not given, we have no choice but to only provide the code for that case\n      script << main_cmd << \"&\\n\";\n    }\n  }\n\n  script << \"disown %-\\n\";\n  script.close();\n\n  set_script_permissions(script_path, options);\n\n#endif  // #ifdef _WIN32\n}\n\nvoid ConfigGenerator::create_stop_script(const std::string &directory,\n                                         const std::map<std::string, std::string> &options) {\n#ifdef _WIN32\n\n  std::ofstream script;\n  const std::string script_path = directory + \"/stop.ps1\";\n\n  script.open(script_path);\n  if (script.fail()) {\n    throw std::runtime_error(\"Could not open \" + script_path + \" for writing: \" + get_strerror(errno));\n  }\n  script << \"$filename = [Environment]::GetEnvironmentVariable(\\\"ROUTER_PID\\\", \\\"Process\\\")\" << std::endl;\n  script << \"If(Test-Path $filename) {\" << std::endl;\n  script << \"  $mypid = [IO.File]::ReadAllText($filename)\" << std::endl;\n  script << \"  Stop-Process -Id $mypid\" << std::endl;\n  script << \"  [IO.File]::Delete($filename)\" << std::endl;\n  script << \"}\" << std::endl;\n  script << \"else { Write-Host \\\"Error when trying to stop mysqlrouter process\\\" }\" << std::endl;\n  script.close();\n\n#else\n\n  std::ofstream script;\n  const std::string script_path = directory + \"/stop.sh\";\n\n  script.open(script_path);\n  if (script.fail()) {\n    throw std::runtime_error(\"Could not open \" + script_path + \" for writing: \" + get_strerror(errno));\n  }\n  script << \"#!/bin/bash\\n\";\n  script << \"if [ -f \" + directory + \"/mysqlrouter.pid ]; then\\n\";\n  script << \"  kill -TERM `cat \" + directory + \"/mysqlrouter.pid` && rm -f \" << directory + \"/mysqlrouter.pid\\n\";\n  script << \"fi\\n\";\n  script.close();\n\n  set_script_permissions(script_path, options);\n\n#endif  // #ifdef _WIN32\n}\n\nstatic bool files_equal(const std::string &f1, const std::string &f2) {\n  std::ifstream if1(f1);\n  std::ifstream if2(f2);\n\n  if1.seekg(0, if1.end);\n  std::streamoff fsize = if1.tellg();\n  if1.seekg(0, if1.beg);\n\n  if2.seekg(0, if2.end);\n  if (fsize != if2.tellg())\n    return false;\n  if2.seekg(0, if2.beg);\n\n  std::string data1, data2;\n  data1.resize(static_cast<size_t>(fsize));\n  data2.resize(static_cast<size_t>(fsize));\n\n  if1.read(&data1[0], static_cast<std::streamsize>(fsize));\n  if2.read(&data2[0], static_cast<std::streamsize>(fsize));\n\n  return data1 == data2;\n}\n\nbool ConfigGenerator::backup_config_file_if_different(const mysql_harness::Path &config_path,\n                                                      const std::string &new_file_path,\n                                                      const std::map<std::string, std::string> &options,\n                                                      AutoCleaner*  auto_cleaner) {\n  if (config_path.exists() && config_path.is_regular()) {\n    // if the old and new config files are the same, don't bother with a backup\n    if (!files_equal(config_path.str(), new_file_path)) {\n      std::string backup_file_name = config_path.str() + \".bak\";\n      if (auto_cleaner) {\n        auto_cleaner->add_file_revert(config_path.str(), backup_file_name);\n      }\n      else {\n        copy_file(config_path.str(), backup_file_name);\n      }\n      try {\n        mysql_harness::make_file_private(backup_file_name);\n      } catch (const std::system_error &e) {\n#ifdef _WIN32\n        if (e.code() != std::error_code(ERROR_INVALID_FUNCTION, std::system_category()))\n            // if the filesystem can't set permissions, the test later would fail\n#endif\n          throw;\n      }\n      set_file_owner(options, backup_file_name);\n      return true;\n    }\n  }\n  return false;\n}\n\nvoid ConfigGenerator::set_file_owner(const std::map<std::string, std::string> &options,\n                                     const std::string &file_path)\n{\n#ifndef _WIN32\n  bool change_owner = (options.count(\"user\") != 0) && (!options.at(\"user\").empty());\n  if (change_owner) {\n    auto username = options.at(\"user\");\n    auto user_info = check_user(username, true, sys_user_operations_);\n    if (user_info != nullptr) {\n      mysqlrouter::set_owner_if_file_exists(file_path, username, user_info, sys_user_operations_);\n    }\n  }\n#endif\n}\n"
  },
  {
    "path": "src/router/src/config_generator.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef ROUTER_CONFIG_GENERATOR_INCLUDED\n#define ROUTER_CONFIG_GENERATOR_INCLUDED\n\n#include <functional>\n#include <map>\n#include <vector>\n#include <string>\n#include <ostream>\n#include \"mysqlrouter/datatypes.h\"\n#include \"mysqlrouter/utils.h\"\n#include \"unique_ptr.h\"\n#include \"random_generator.h\"\n#include \"mysqlrouter/mysql_session.h\"\n#include \"mysqlrouter/keyring_info.h\"\n#include \"tcp_address.h\"\n\nnamespace mysql_harness {\n  class Path;\n}\n\n// GCC 4.8.4 requires all classes to be forward-declared before used with \"friend class <friendee>\",\n// if they're in a different namespace than the friender\n#ifdef FRIEND_TEST\n#include \"mysqlrouter/utils.h\"  // DECLARE_TEST\nDECLARE_TEST(ConfigGeneratorTest, fetch_bootstrap_servers_one);\nDECLARE_TEST(ConfigGeneratorTest, fetch_bootstrap_servers_three);\nDECLARE_TEST(ConfigGeneratorTest, fetch_bootstrap_servers_multiple_replicasets);\nDECLARE_TEST(ConfigGeneratorTest, fetch_bootstrap_servers_invalid);\nDECLARE_TEST(ConfigGeneratorTest, create_config_single_master);\nDECLARE_TEST(ConfigGeneratorTest, create_config_multi_master);\nDECLARE_TEST(ConfigGeneratorTest, delete_account_for_all_hosts);\nDECLARE_TEST(ConfigGeneratorTest, create_acount);\nDECLARE_TEST(ConfigGeneratorTest, create_router_accounts);\nDECLARE_TEST(ConfigGeneratorTest, fill_options);\nDECLARE_TEST(ConfigGeneratorTest, bootstrap_invalid_name);\nDECLARE_TEST(ConfigGeneratorTest, ssl_stage1_cmdline_arg_parse);\nDECLARE_TEST(ConfigGeneratorTest, ssl_stage2_bootstrap_connection);\nDECLARE_TEST(ConfigGeneratorTest, ssl_stage3_create_config);\nDECLARE_TEST(ConfigGeneratorTest, empty_config_file);\nDECLARE_TEST(ConfigGeneratorTest, warn_on_no_ssl);\nDECLARE_TEST(ConfigGeneratorTest, set_file_owner_no_user);\nDECLARE_TEST(ConfigGeneratorTest, set_file_owner_user_empty);\nDECLARE_TEST(ConfigGeneratorTest, start_sh);\nDECLARE_TEST(ConfigGeneratorTest, stop_sh);\nDECLARE_TEST(ConfigGeneratorTest, register_router_error_message);\nDECLARE_TEST(ConfigGeneratorTest, ensure_router_id_is_ours_error_message);\n#endif\n\nclass AutoCleaner;\n\nnamespace mysqlrouter {\nclass MySQLInnoDBClusterMetadata;\nclass MySQLSession;\nclass SysUserOperationsBase;\nclass SysUserOperations;\n\nclass ConfigGenerator {\npublic:\n  ConfigGenerator(\n#ifndef _WIN32\n    SysUserOperationsBase* sys_user_operations = SysUserOperations::instance()\n#endif\n  );\n  virtual ~ConfigGenerator() = default;\n\n  void init(const std::string &server_url, const std::map<std::string, std::string>& bootstrap_options);  // throws std::runtime_error\n  bool warn_on_no_ssl(const std::map<std::string, std::string> &options); // throws std::runtime_error\n\n  void bootstrap_system_deployment(const std::string &config_file_path,\n      const std::map<std::string, std::string> &options,\n      const std::map<std::string, std::vector<std::string>> &multivalue_options,\n      const std::map<std::string, std::string> &default_paths);\n\n  void bootstrap_directory_deployment(const std::string &directory,\n      const std::map<std::string, std::string> &options,\n      const std::map<std::string, std::vector<std::string>> &multivalue_options,\n      const std::map<std::string, std::string> &default_paths);\n\n  void set_keyring_info(const KeyringInfo &keyring_info) {\n    keyring_info_ = keyring_info;\n  }\n\n  struct Options {\n    struct Endpoint {\n      int port;\n      std::string socket;\n      Endpoint() : port(0) {}\n      Endpoint(const std::string &path) : port(0), socket(path) {}\n      Endpoint(int port_) : port(port_) {}\n\n      operator bool() const { return port > 0 || !socket.empty(); }\n    };\n    Options() : multi_master(false) {}\n\n    Endpoint rw_endpoint;\n    Endpoint ro_endpoint;\n    Endpoint rw_x_endpoint;\n    Endpoint ro_x_endpoint;\n\n    std::string override_logdir;\n    std::string override_rundir;\n    std::string override_datadir;\n    std::string socketsdir;\n\n    std::string keyring_file_path;\n    std::string keyring_master_key;\n    std::string keyring_master_key_file_path;\n\n    bool multi_master;\n    std::string bind_address;\n\n    int connect_timeout;\n    int read_timeout;\n\n    mysqlrouter::SSLOptions ssl_options;\n  };\n\n  void set_file_owner(const std::map<std::string, std::string> &options,\n                      const std::string &owner); // throws std::runtime_error\n\nprivate:\n  friend class MySQLInnoDBClusterMetadata;\n\n  Options fill_options(bool multi_master,\n      const std::map<std::string, std::string> &user_options);\n\n  void create_start_script(const std::string &directory,\n                           bool interactive_master_key,\n                           const std::map<std::string, std::string> &options);\n\n  void create_stop_script(const std::string &directory,\n                          const std::map<std::string, std::string> &options);\n\n  // virtual so we can disable it in unit tests\n  virtual void set_script_permissions(const std::string& script_path,\n                                      const std::map<std::string, std::string> &options);\n\n  void bootstrap_deployment(std::ostream &config_file,\n      const mysql_harness::Path &config_file_path, const std::string &name,\n      const std::map<std::string, std::string> &options,\n      const std::map<std::string, std::vector<std::string>> &multivalue_options,\n      const std::map<std::string, std::string> &default_paths,\n      bool directory_deployment,\n      AutoCleaner& auto_clean);\n\n  std::tuple<std::string>\n  try_bootstrap_deployment(uint32_t &router_id, std::string &username,\n      const std::string &router_name,\n      mysql_harness::RandomGeneratorInterface& rg,\n      const std::map<std::string, std::string> &user_options,\n      const std::map<std::string, std::vector<std::string>> &multivalue_options,\n      const std::string &rw_endpoint,\n      const std::string &ro_endpoint,\n      const std::string &rw_x_endpoint,\n      const std::string &ro_x_endpoint);\n\n  void init_keyring_file(uint32_t router_id);\n\n  void fetch_bootstrap_servers(std::string &bootstrap_servers,\n                               std::string &metadata_cluster,\n                               std::string &metadata_replicaset,\n                               bool &multi_master);\n\n  void create_config(std::ostream &config_file,\n                     uint32_t router_id,\n                     const std::string &router_name,\n                     const std::string &system_username,\n                     const std::string &bootstrap_server_addresses,\n                     const std::string &metadata_cluster,\n                     const std::string &metadata_replicaset,\n                     const std::string &username,\n                     const Options &options,\n                     bool print_configs = false);\n\n  /** @brief Deletes (old) Router accounts\n   *\n   * Deletes all accounts (for all hosts) for a particular username (ie. for user\n   * \"someuser\" it will delete `someuser@host1`, `someuser@host2`, `someuser@%`, etc)\n   *\n   * @param username Router account to be deleted (without the hostname part)\n   *\n   * @throws std::logic_error on not connected\n   *         MySQLSession::Error on SQL error\n   */\n  void delete_account_for_all_hosts(const std::string &username);\n\n  /** @brief Creates Router accounts\n   *\n   * Creates Router account for all needed hostnames (ie. `someuser@host1`,\n   * `someuser@host2`, `someuser@%`, etc).\n   *\n   * @note This is the higher-level method, which drives calls to lower-level\n   *       methods like create_account_with_compliant_password() and\n   *       create_account().\n   *\n   * @param user_options key/value map of bootstrap config options\n   * @param multivalue_options key/list-of-values map of bootstrap config options,\n   *        including list of hostnames\n   * @param username Router account to be created (without the hostname part)\n   *\n   * @returns auto-generated password\n   *\n   * @throws std::logic_error on not connected\n   *         std::runtime_error on bad password or Server's password policy\n   *                               changing during bootstrap\n   *         MySQLSession::Error on other (unexpected) SQL error\n   */\n  std::string create_router_accounts(const std::map<std::string, std::string> &user_options,\n                                     const std::map<std::string, std::vector<std::string>> &multivalue_options,\n                                     const std::string &username);\n\n  /** @brief Creates Router account with compliant password\n   *\n   * Creates Router account with a (self-generated) password that will pass Server's\n   * password policy. It first tries creating a hashed password using\n   * mysql_native_password plugin. If that fails, it falls back to using plaintext\n   * password, which the Server may reject for not being strong enough. If that's\n   * the case, it will generate another password and try again 2 more times (for a\n   * total of 3 password-generation attempts), after which it will give up.\n   *\n   * @note This is a higher-level method, with smart logic that drives calls to\n   *       lower-level create_account() method.\n   *\n   * @param user_options key/value map of bootstrap config options\n   * @param username Router account to be created - the username part\n   * @param hostname Router account to be created - the hostname part\n   *\n   * @returns std::pair, where:\n   *   - std::string contains the auto-generated password\n   *   - bool states if account was created with hashed password\n   *     (with mysql_native_password)\n   *\n   * @throws std::logic_error on not connected\n   *         std::runtime_error on bad password\n   *         MySQLSession::Error on other (unexpected) SQL error\n   */\n  std::pair<std::string, bool> create_account_with_compliant_password(\n                                   const std::map<std::string, std::string> &user_options,\n                                   const std::string &username,\n                                   const std::string &hostname);\n\n  /** @brief Creates Router account (low-level function)\n   *\n   * Creates Router accout using CREATE USER ang give it GRANTs.\n   *\n   * @param username Router account to be created - the username part\n   * @param hostname Router account to be created - the hostname part\n   * @param password Password for the account\n   * @param hash_password CREATE USER method:\n   *   true: password should be hashed, CREATE USER using mysql_native_password\n   *   false: password should remain plaintext, CREATE USER without mysql_native_password\n   *\n   * @throws std::logic_error on not connected\n   *         password_too_weak on Server not liking the password\n   *         plugin_not_loaded on Server not supporting mysql_native_password\n   *         MySQLSession::Error on other (unexpected) SQL error\n   */\n  void create_account(const std::string &username,\n                      const std::string &hostname,\n                      const std::string &password,\n                      bool hash_password = false);\n\n  std::pair<uint32_t, std::string> get_router_id_and_name_from_config(const std::string &config_file_path,\n                                          const std::string &cluster_name,\n                                          bool forcing_overwrite);\n\n  void update_router_info(uint32_t router_id, const Options &options);\n\n  std::string endpoint_option(const Options &options, const Options::Endpoint &ep);\n\n  bool backup_config_file_if_different(const mysql_harness::Path &config_path,\n                                       const std::string &new_file_path,\n                                       const std::map<std::string, std::string> &options,\n                                       AutoCleaner* auto_cleaner = nullptr);\n\n  void set_keyring_info_real_paths(std::map<std::string, std::string>& options, const mysql_harness::Path& path);\n\n  void init_keyring_and_master_key(AutoCleaner& auto_clean, const std::map<std::string, std::string> &user_options, uint32_t router_id);\n\n\n  static void set_ssl_options(MySQLSession* sess,\n                           const std::map<std::string, std::string>& options);\n\n  void ensure_router_id_is_ours(uint32_t &router_id,\n                                std::string &username,\n                                const std::string &hostname_override,\n                                MySQLInnoDBClusterMetadata &metadata);\n\n  void register_router_and_set_username(uint32_t &router_id,\n                                        const std::string &router_name,\n                                        std::string &username,\n                                        const std::string &hostname_override,\n                                        bool force,\n                                        MySQLInnoDBClusterMetadata &metadata,\n                                        mysql_harness::RandomGeneratorInterface &rg);\nprivate:\n  mysql_harness::UniquePtr<MySQLSession> mysql_;\n  int connect_timeout_;\n  int read_timeout_;\n\n  std::string gr_initial_hostname_;\n  unsigned int gr_initial_port_;\n  std::string gr_initial_username_;\n  std::string gr_initial_password_;\n  std::string gr_initial_socket_;\n\n  KeyringInfo keyring_info_;\n\n#ifndef _WIN32\n  SysUserOperationsBase* sys_user_operations_;\n#endif\n\n#ifdef FRIEND_TEST\n  FRIEND_TEST(::ConfigGeneratorTest, fetch_bootstrap_servers_one);\n  FRIEND_TEST(::ConfigGeneratorTest, fetch_bootstrap_servers_three);\n  FRIEND_TEST(::ConfigGeneratorTest, fetch_bootstrap_servers_multiple_replicasets);\n  FRIEND_TEST(::ConfigGeneratorTest, fetch_bootstrap_servers_invalid);\n  FRIEND_TEST(::ConfigGeneratorTest, create_config_single_master);\n  FRIEND_TEST(::ConfigGeneratorTest, create_config_multi_master);\n  FRIEND_TEST(::ConfigGeneratorTest, delete_account_for_all_hosts);\n  FRIEND_TEST(::ConfigGeneratorTest, create_acount);\n  FRIEND_TEST(::ConfigGeneratorTest, create_router_accounts);\n  FRIEND_TEST(::ConfigGeneratorTest, fill_options);\n  FRIEND_TEST(::ConfigGeneratorTest, bootstrap_invalid_name);\n  FRIEND_TEST(::ConfigGeneratorTest, ssl_stage1_cmdline_arg_parse);\n  FRIEND_TEST(::ConfigGeneratorTest, ssl_stage2_bootstrap_connection);\n  FRIEND_TEST(::ConfigGeneratorTest, ssl_stage3_create_config);\n  FRIEND_TEST(::ConfigGeneratorTest, empty_config_file);\n  FRIEND_TEST(::ConfigGeneratorTest, warn_on_no_ssl);\n  FRIEND_TEST(::ConfigGeneratorTest, set_file_owner_no_user);\n  FRIEND_TEST(::ConfigGeneratorTest, set_file_owner_user_empty);\n  FRIEND_TEST(::ConfigGeneratorTest, start_sh);\n  FRIEND_TEST(::ConfigGeneratorTest, stop_sh);\n  FRIEND_TEST(::ConfigGeneratorTest, register_router_error_message);\n  FRIEND_TEST(::ConfigGeneratorTest, ensure_router_id_is_ours_error_message);\n#endif\n};\n}\n#endif //ROUTER_CONFIG_GENERATOR_INCLUDED\n"
  },
  {
    "path": "src/router/src/keyring_info.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#define MYSQL_ROUTER_LOG_DOMAIN ::mysql_harness::logging::kMainLogger // must precede #include \"logging.h\"\n\n#include \"dim.h\"\n#include \"keyring_info.h\"\n#include \"keyring/keyring_manager.h\"\n#include \"mysql/harness/config_parser.h\"\n#include \"mysql/harness/filesystem.h\"\n#include \"mysql/harness/loader_config.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"process_launcher.h\"\n#include \"random_generator.h\"\n#include \"router_config.h\"\n#include \"utils.h\"\n\n#include <algorithm>\n#include <iostream>\n#include <stdlib.h>\n#include <string.h>\n\nIMPORT_LOG_FUNCTIONS()\n\nstatic const unsigned kKeyLength = 32;\nstatic const char *kDefaultKeyringFileName = \"keyring\";\n\nusing mysql_harness::ProcessLauncher;\n\nstd::string KeyringInfo::get_keyring_file(const mysql_harness::Config &config, const std::string& directory) const noexcept {\n  std::string keyring_file;\n\n  if (config.has_default(\"keyring_path\")) {\n    keyring_file = config.get_default(\"keyring_path\");\n  }\n\n  if (keyring_file.empty()) {\n    std::string data_dir_path = mysqlrouter::substitute_variable(MYSQL_ROUTER_DATA_FOLDER,\n                                                    \"{origin}\", directory);\n    keyring_file = mysql_harness::Path(data_dir_path).join(kDefaultKeyringFileName).str();\n  }\n\n  return keyring_file;\n}\n\nvoid KeyringInfo::init(mysql_harness::Config &config, const std::string& origin) noexcept {\n  keyring_file_ = get_keyring_file(config, origin);\n\n  if (config.has_default(\"master_key_path\"))\n    master_key_file_ = config.get_default(\"master_key_path\");\n\n  if (config.has_default(\"master_key_reader\"))\n    master_key_reader_ = config.get_default(\"master_key_reader\");\n\n  if (config.has_default(\"master_key_writer\"))\n    master_key_writer_ = config.get_default(\"master_key_writer\");\n}\n\nbool KeyringInfo::read_master_key() noexcept {\n  const char* args[2];\n  args[0] = master_key_reader_.c_str();\n  args[1] = nullptr;\n\n  auto timeout = std::chrono::steady_clock::now() + rw_timeout_;\n\n  try {\n    ProcessLauncher process_launcher(master_key_reader_.c_str(), args);\n    process_launcher.start();\n    while(std::chrono::steady_clock::now() < timeout) {\n      char output[1024] = {0};\n      int bytes_read = process_launcher.read(output, sizeof(output)-1, rw_timeout_.count());\n      if (bytes_read > 0) {\n        master_key_ += output;\n      } else {\n        // encountered end of input\n        break;\n      }\n    }\n\n    auto wait_for_exit = std::chrono::duration_cast<std::chrono::milliseconds>(timeout - std::chrono::steady_clock::now()).count();\n\n    int exit_code = 0;\n    if ((exit_code = process_launcher.wait(wait_for_exit))) {\n      master_key_ = \"\";\n      if (verbose_) {\n        log_error(\"Cannot execute master key reader '%s'\", get_master_key_reader().c_str());\n#if !defined(_WIN32) && !defined(__APPLE__)\n        if (exit_code == EACCES || exit_code == EPERM) {\n          log_error(\n            \"This may be caused by insufficient rights or AppArmor settings.\\n\"\n            \"If you have AppArmor enabled try adding MySQLRouter rights to execute your keyring reader in the mysqlrouter profile file:\\n\"\n            \"/etc/apparmor.d/usr.bin.mysqlrouter\\n\\n\"\n            \"Example:\\n\\n\"\n            \"  /path/to/your/master-key-reader Ux,\\n\"\n          );\n        }\n#endif\n      }\n      return false;\n    }\n  } catch(...) {\n    return false;\n  }\n\n  return true;\n}\n\nbool KeyringInfo::write_master_key() const noexcept {\n  const char* args[2];\n  args[0] = master_key_writer_.c_str();\n  args[1] = nullptr;\n\n  try {\n    ProcessLauncher process_launcher(master_key_writer_.c_str(), args);\n    process_launcher.start();\n    process_launcher.write(master_key_.c_str(), master_key_.size());\n    process_launcher.end_of_write();\n    int exit_code = 0;\n    if ((exit_code = process_launcher.wait(rw_timeout_.count()))) {\n      if (verbose_) {\n        log_error(\"Cannot execute master key writer '%s'\", get_master_key_writer().c_str());\n#if !defined(_WIN32) && !defined(__APPLE__)\n        if (exit_code == EACCES || exit_code == EPERM) {\n          log_error(\n            \"This may be caused by insufficient rights or AppArmor settings.\\n\"\n            \"If you have AppArmor enabled try adding MySQLRouter rights to execute your keyring writer in the mysqlrouter profile file:\\n\"\n            \"/etc/apparmor.d/usr.bin.mysqlrouter\\n\\n\"\n            \"Example:\\n\\n\"\n            \"  /path/to/your/master-key-writer Ux,\\n\"\n          );\n        }\n#endif\n      }\n      return false;\n    }\n  } catch (...) {\n    return false;\n  }\n  return true;\n}\n\nvoid KeyringInfo::generate_master_key() noexcept {\n  mysql_harness::RandomGeneratorInterface& rg = mysql_harness::DIM::instance().get_RandomGenerator();\n  master_key_ = rg.generate_strong_password(kKeyLength);\n}\n\nvoid KeyringInfo::add_router_id_to_env(uint32_t router_id) const {\n  int err_code;\n#ifdef _WIN32\n  err_code = _putenv_s(\"ROUTER_ID\", std::to_string(router_id).c_str());\n#else\n  err_code = ::setenv(\"ROUTER_ID\", std::to_string(router_id).c_str() ,1);\n#endif\n  if (err_code)\n    throw SetRouterIdEnvVariableError(\"Failed to add ROUTER_ID=\"\n        + std::to_string(router_id) + \" to Environment, error_code=\"\n        + std::to_string(err_code));\n}\n\nbool KeyringInfo::use_master_key_external_facility() const noexcept {\n  return !master_key_reader_.empty();\n}\n\nbool KeyringInfo::use_master_key_file() const noexcept {\n  return !use_master_key_external_facility() && !master_key_file_.empty();\n}\n\nvoid KeyringInfo::validate_master_key() const {\n  if (master_key_.empty())\n    throw std::runtime_error(\"Encryption key is empty\");\n  if (master_key_.length() > mysql_harness::kMaxKeyringKeyLength)\n    throw std::runtime_error(\n        \"Encryption key can't be longer than \"\n            + std::to_string(mysql_harness::kMaxKeyringKeyLength)\n            + \". Master key length: \" + std::to_string(master_key_.length()));\n}\n"
  },
  {
    "path": "src/router/src/main.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#define MYSQL_ROUTER_LOG_DOMAIN ::mysql_harness::logging::kMainLogger // must precede #include \"logging.h\"\n\n#include \"common.h\"\n#include \"dim.h\"\n#include \"utils.h\"\n#include \"mysql_session.h\"\n#include \"mysql/harness/loader_config.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysql/harness/logging/registry.h\"\n#include \"router_app.h\"\n#include \"random_generator.h\"\n#include \"windows/main-windows.h\"\n#include <mysql.h>\n#include <iostream>\nIMPORT_LOG_FUNCTIONS()\n\n\n/** @brief Initialise Dependency Injection Manager (DIM)\n *\n * This is the place to initialise all the DI stuff used thoroughout our application.\n * (well, maybe we'll want plugins to init their own stuff, we'll see).\n *\n * Naturally, unit tests will not run this code, as they will initialise the objects\n * they need their own way.\n */\nstatic void init_DIM() {\n  mysql_harness::DIM& dim = mysql_harness::DIM::instance();\n\n  // RandomGenerator\n  dim.set_RandomGenerator(\n    [](){ static mysql_harness::RandomGenerator rg; return &rg; },\n    [](mysql_harness::RandomGeneratorInterface*){}  // don't delete our static!\n  );\n\n  // MySQLSession\n  dim.set_MySQLSession([](){ return new mysqlrouter::MySQLSession(); }, std::default_delete<mysqlrouter::MySQLSession>());\n\n  // Ofstream\n  dim.set_Ofstream([](){ return new mysqlrouter::RealOfstream(); }, std::default_delete<mysqlrouter::Ofstream>());\n\n  // logging facility\n  dim.set_LoggingRegistry(\n    []() {\n      static mysql_harness::logging::Registry registry;\n      return &registry;\n    },\n    [](mysql_harness::logging::Registry*){}  // don't delete our static!\n  );\n}\n\nint real_main(int argc, char **argv) {\n  mysql_harness::rename_thread(\"main\");\n  init_DIM();\n\n  // initialize logger to log to stderr. After reading configuration inside of MySQLRouter::start(),\n  // it will be re-initialized according to information in the configuration file\n  mysql_harness::LoaderConfig config(mysql_harness::Config::allow_keys);\n  MySQLRouter::init_main_logger(config, true); // true = raw logging mode\n\n  // TODO This is very ugly, it should not be a global. It's defined in config_generator.cc and\n  //      used in find_executable_path() to provide path to Router binary when generating start.sh.\n  extern std::string g_program_name;\n  g_program_name = argv[0];\n\n  if (mysql_library_init(argc, argv, NULL)) {\n    log_error(\"Could not initialize MySQL library\");\n    return 1;\n  }\n\n  int result = 0;\n  try {\n    MySQLRouter router(argc, argv);\n    // This nested try/catch block is necessary in Windows, to\n    // workaround a crash that occurs when an exception is thrown from\n    // a plugin (e.g. routing_plugin_tests)\n    try {\n      router.start();\n    } catch (const std::invalid_argument &exc) {\n      log_error(\"Configuration error: %s\", exc.what());\n      result = 1;\n    } catch (const std::runtime_error &exc) {\n      log_error(\"Error: %s\", exc.what());\n      result = 1;\n    } catch (const silent_exception&) {}\n  } catch(const std::invalid_argument &exc) {\n    log_error(\"Configuration error: %s\", exc.what());\n    result = 1;\n  } catch(const std::runtime_error &exc) {\n    log_error(\"Error: %s\", exc.what());\n    result = 1;\n  } catch (const mysql_harness::syntax_error &exc) {\n    log_error(\"Configuration syntax error: %s\", exc.what());\n  } catch (const silent_exception&) {\n  } catch (const std::exception &exc) {\n    log_error(\"Error: %s\", exc.what());\n    result = 1;\n  }\n\n  // We should deinitialize mysql-lib but we can't do it safely here until\n  // we do WL9558 \"Plugin life-cycle that support graceful shutdown and restart.\"\n  // Currently we can get here while there are still some threads running\n  // (like metadata_cache thread that is managed by the global g_metadata_cache)\n  // that still use mysql-lib, which leads to crash.\n  mysql_library_end();\n\n  return result;\n}\n\nint main(int argc, char **argv) {\n#ifdef _WIN32\n  return proxy_main(real_main, argc, argv);\n#else\n  return real_main(argc, argv);\n#endif\n}\n"
  },
  {
    "path": "src/router/src/plugin_config.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysqlrouter/plugin_config.h\"\n\n#ifndef _WIN32\n# include <sys/un.h>\n# include <unistd.h>\n#endif\n\nusing std::invalid_argument;\nusing std::string;\n\nnamespace mysqlrouter {\n\nstring BasePluginConfig::get_section_name(const mysql_harness::ConfigSection *section) const noexcept {\n  auto name = section->name;\n  if (!section->key.empty()) {\n    name += \":\" + section->key;\n  }\n  return name;\n}\n\nstring BasePluginConfig::get_option_string(const mysql_harness::ConfigSection *section, const string &option) const {\n  bool required = is_required(option);\n  string value;\n\n  try {\n    value = section->get(option);\n  } catch (const mysql_harness::bad_option &exc) {\n    if (required) {\n      throw option_not_present(get_log_prefix(option) + \" is required\");\n    }\n  }\n\n  if (value.empty()) {\n    if (required) {\n      throw option_empty(get_log_prefix(option) + \" needs a value\");\n    }\n    value = get_default(option);\n  }\n\n  return value;\n}\n\nstring BasePluginConfig::get_log_prefix(const std::string &option,\n    const mysql_harness::ConfigSection *section) const noexcept {\n  return \"option \" + option + \" in [\" +\n      (section ? section->get_section_name(option) : section_name) + \"]\";\n}\n\n/*static*/\nstd::chrono::milliseconds BasePluginConfig::get_option_milliseconds(const std::string& value,\n                                     double min_value, double max_value,\n                                     const std::string& log_prefix) {\n  std::istringstream ss(value);\n  // we want to make sure the decinal separator is always '.' regardless of the user locale settings\n  // so we force classic locale\n  ss.imbue(std::locale(\"C\"));\n  double result  = 0.0;\n  if (!(ss >> result) || !ss.eof() || (result < min_value - 0.0001) || (result > max_value + 0.0001)) {\n    std::stringstream os;\n    os << log_prefix << \" needs value between \" << min_value << \" and \"\n       << to_string(max_value) << \" inclusive\";\n    if (!value.empty()) {\n      os << \", was '\" << value << \"'\";\n    }\n    throw std::invalid_argument(os.str());\n  }\n\n  return std::chrono::duration_cast<std::chrono::milliseconds>(\n                std::chrono::duration<double>(result));\n}\n\nstd::chrono::milliseconds BasePluginConfig::get_option_milliseconds(\n              const mysql_harness::ConfigSection *section, const std::string &option,\n               double min_value, double max_value) const {\n  std::string value = get_option_string(section, option);\n\n  return get_option_milliseconds(value, min_value, max_value, get_log_prefix(option, section));\n}\n\nmysql_harness::TCPAddress BasePluginConfig::get_option_tcp_address(const mysql_harness::ConfigSection *section,\n                                                    const string &option,\n                                                    bool require_port,\n                                                    int default_port) {\n  std::string value = get_option_string(section, option);\n\n  if (value.empty()) {\n    return mysql_harness::TCPAddress{};\n  }\n\n  try {\n    std::pair<string, uint16_t> bind_info = mysqlrouter::split_addr_port(value);\n\n    uint16_t port = bind_info.second;\n\n    if (port <= 0) {\n      if (default_port > 0) {\n        port = static_cast<uint16_t >(default_port);\n      } else if (require_port) {\n        throw std::runtime_error(\"TCP port missing\");\n      }\n    }\n\n    return mysql_harness::TCPAddress(bind_info.first, port);\n\n  } catch (const std::runtime_error &exc) {\n    throw invalid_argument(get_log_prefix(option) + \" is incorrect (\" + exc.what() + \")\");\n  }\n\n}\n\nint BasePluginConfig::get_option_tcp_port(const mysql_harness::ConfigSection *section,\n                                          const string &option) {\n  auto value = get_option_string(section, option);\n\n  if (!value.empty()) {\n    char *rest;\n    errno = 0;\n    auto result = std::strtol(value.c_str(), &rest, 0);\n\n    if (errno > 0 || *rest != '\\0' || result > UINT16_MAX || result < 1) {\n      std::ostringstream os;\n      os << get_log_prefix(option) << \" needs value between 1 and 65535 inclusive\";\n      if (!value.empty()) {\n        os << \", was '\" << value << \"'\";\n      }\n      throw std::invalid_argument(os.str());\n    }\n\n    return static_cast<int>(result);\n  }\n\n  return -1;\n}\n\nmysql_harness::Path BasePluginConfig::get_option_named_socket(const mysql_harness::ConfigSection *section,\n                                                              const string &option) {\n  std::string value = get_option_string(section, option);\n\n  std::string error;\n  if (!is_valid_socket_name(value, error)) {\n    throw invalid_argument(error);\n  }\n\n  if (value.empty()) {\n    return mysql_harness::Path();\n  }\n  return mysql_harness::Path(value);\n}\n\n} // namespace mysqlrouter\n"
  },
  {
    "path": "src/router/src/router_app.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#define MYSQL_ROUTER_LOG_DOMAIN ::mysql_harness::logging::kMainLogger // must precede #include \"logging.h\"\n\n#include \"common.h\"\n#include \"dim.h\"\n#include \"hostname_validator.h\"\n#include \"mysql/harness/config_parser.h\"\n#include \"mysql/harness/filesystem.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysql/harness/logging/registry.h\"\n#include \"harness_assert.h\"\n#include \"keyring/keyring_manager.h\"\n#include \"router_app.h\"\n#include \"config_generator.h\"\n#include \"mysql_session.h\"\n#include \"config_files.h\"\n\n#include <algorithm>\n#include <cerrno>\n#include <cstdio>\n#include <cstdlib>\n#include <cstring>\n#include <fstream>\n#include <iostream>\n#include <sstream>\n#include <string>\n#include <vector>\n\n#ifndef _WIN32\n#  include <fcntl.h>\n#  include <unistd.h>\n#  include <signal.h>\n   const char dir_sep = '/';\n   const std::string path_sep = \":\";\n#else\n#  include <windows.h>\n#  include <process.h>\n#  define getpid _getpid\n#  include \"mysqlrouter/windows/password_vault.h\"\n#  include <string.h>\n#  include <io.h>\n#  define strtok_r strtok_s\n   const char dir_sep = '\\\\';\n   const std::string path_sep = \";\";\n#endif\n\nIMPORT_LOG_FUNCTIONS()\n\nusing std::string;\nusing std::vector;\nusing mysql_harness::DIM;\nusing mysql_harness::get_strerror;\nusing mysql_harness::truncate_string;\nusing mysqlrouter::string_format;\nusing mysqlrouter::substitute_envvar;\nusing mysqlrouter::wrap_string;\nusing mysqlrouter::SysUserOperationsBase;\nusing mysqlrouter::SysUserOperations;\n\nstatic const char *kDefaultKeyringFileName = \"keyring\";\nstatic const char kProgramName[] = \"mysqlrouter\";\n\nstatic std::string find_full_path(const std::string &argv0) {\n#ifdef _WIN32\n  // the bin folder is not usually in the path, just the lib folder\n  char szPath[MAX_PATH];\n  if (GetModuleFileName(NULL, szPath, sizeof(szPath)) != 0)\n    return std::string(szPath);\n#else\n  mysql_harness::Path p_argv0(argv0);\n  // Path normalizes '\\' to '/'\n  if (p_argv0.str().find('/') != std::string::npos) {\n    // Path is either absolute or relative to the current working dir, so\n    // we can use realpath() to find the full absolute path\n    mysql_harness::Path path2(p_argv0.real_path());\n    const char *tmp = path2.c_str();\n    std::string path(tmp);\n    return path;\n  } else {\n    // Program was found via PATH lookup by the shell, so we\n    // try to find the program in one of the PATH dirs\n    std::string path(std::getenv(\"PATH\"));\n    char *last = NULL;\n    char *p = strtok_r(&path[0], path_sep.c_str(), &last);\n    while (p) {\n      std::string tmp(std::string(p)+dir_sep+argv0);\n      if(mysqlrouter::my_check_access(tmp)) {\n        mysql_harness::Path path1(tmp.c_str());\n        mysql_harness::Path path2(path1.real_path());\n        return path2.str();\n      }\n      p = strtok_r(NULL, path_sep.c_str(), &last);\n    }\n  }\n#endif\n  throw std::logic_error(\"Could not find own installation directory\");\n}\n\nstatic inline void set_signal_handlers() {\n#ifndef _WIN32\n  // until we have proper signal handling we need at least\n  // mask out broken pipe to prevent terminating the router\n  // if the receiving end closes the socket while the router\n  // writes to it\n  signal(SIGPIPE, SIG_IGN);\n#endif\n}\n\n// Check if the value is valid regular filename and if it is add to the vector,\n// if it is not throw an exception\nstatic void check_and_add_conf(std::vector<string> &configs,\n                               const std::string& value) {\n  mysql_harness::Path cfg_file_path;\n  try {\n    cfg_file_path = mysql_harness::Path(value);\n  } catch (const std::invalid_argument &exc) {\n    throw std::runtime_error(string_format(\"Failed reading configuration file: %s\", exc.what()));\n  }\n\n  if (cfg_file_path.is_regular()) {\n    configs.push_back(cfg_file_path.real_path().str());\n  } else if (cfg_file_path.is_directory()) {\n    throw std::runtime_error(string_format(\"Expected configuration file, got directory name: %s\", value.c_str()));\n  } else {\n    throw std::runtime_error(string_format(\"Failed reading configuration file: %s\", value.c_str()));\n  }\n}\n\nMySQLRouter::MySQLRouter(const mysql_harness::Path& origin, const vector<string>& arguments\n#ifndef _WIN32\n                         , SysUserOperationsBase *sys_user_operations\n#endif\n                         )\n    : version_(MYSQL_ROUTER_VERSION_MAJOR, MYSQL_ROUTER_VERSION_MINOR, MYSQL_ROUTER_VERSION_PATCH),\n      arg_handler_(), can_start_(false),\n      showing_info_(false),\n      origin_(origin)\n#ifndef _WIN32\n    , sys_user_operations_(sys_user_operations)\n#endif\n{\n  set_signal_handlers();\n  init(arguments);\n}\n\nMySQLRouter::MySQLRouter(const int argc, char **argv\n#ifndef _WIN32\n  , SysUserOperationsBase *sys_user_operations\n#endif\n)\n    : MySQLRouter(mysql_harness::Path(find_full_path(argv[0])).dirname(),\n                  vector<string>({argv + 1, argv + argc})\n#ifndef _WIN32\n                 ,sys_user_operations\n#endif\n    )\n{\n}\n\n// throws std::runtime_error\nvoid MySQLRouter::parse_command_options(const vector<string>& arguments) {\n  prepare_command_options();\n  try {\n    arg_handler_.process(arguments);\n  } catch (const std::invalid_argument &exc) {\n    throw std::runtime_error(exc.what());\n  }\n}\n\nvoid MySQLRouter::init(const vector<string>& arguments) {\n  set_default_config_files(CONFIG_FILES);\n\n  parse_command_options(arguments); // throws std::runtime_error\n\n  if (showing_info_) {\n    return;\n  }\n\n  if (!bootstrap_uri_.empty()) {\n\n#ifndef _WIN32\n    // If the user does the bootstrap with superuser (uid==0) but did not provide\n    // --user option let's encourage her/him to do so.\n    // Otherwise [s]he will end up with the files (config, log, etc.) owned\n    // by the root user and not accessible by others, which is likely not what\n    // was expected. The user still can use --user=root to force using superuser.\n    bool user_option = this->bootstrap_options_.count(\"user\") != 0 ;\n    bool superuser = sys_user_operations_->geteuid() == 0;\n\n    if (superuser && !user_option) {\n      std::string msg(\"You are bootstraping as a superuser.\\n\"\n                      \"This will make all the result files (config etc.) privately owned by the superuser.\\n\"\n                      \"Please use --user=username option to specify the user that will be running the router.\\n\"\n                      \"Use --user=root if this really should be the superuser.\");\n\n      throw std::runtime_error(msg);\n    }\n#endif\n\n    // default configuration for boostrap is not supported\n    // extra configuration for bootstrap is not supported\n    ConfigFiles config_files({}, config_files_, {});\n\n    if (!config_files.empty()) {\n      DIM::instance().reset_Config(); // simplifies unit tests\n      DIM::instance().set_Config([this, &config_files](){ return make_config({}, config_files); }, std::default_delete<mysql_harness::LoaderConfig>());\n      mysql_harness::LoaderConfig& config = DIM::instance().get_Config();\n\n      // reinit logger (right now the logger is configured to log to STDERR, here\n      //                we re-configure it with settings from config file)\n      init_main_logger(config, true); // true = raw logging mode\n    }\n\n    bootstrap(bootstrap_uri_);\n    return;\n  }\n\n  check_config_files();\n  can_start_ = true;\n}\n\nuint32_t MySQLRouter::get_router_id(mysql_harness::Config &config) {\n  uint32_t result = 0;\n\n  if (config.has_any(\"metadata_cache\")) {\n    const auto& metadata_caches = config.get(\"metadata_cache\");\n    for (const auto &section : metadata_caches) {\n      if (section->has(\"router_id\")) {\n        std::istringstream iss(section->get(\"router_id\"));\n        iss >> result;\n        break;\n      }\n    }\n  }\n  return result;\n}\n\nvoid MySQLRouter::init_keyring(mysql_harness::Config &config) {\n  bool needs_keyring = false;\n\n  if (config.has_any(\"metadata_cache\")) {\n    auto metadata_caches = config.get(\"metadata_cache\");\n    for (auto &section : metadata_caches) {\n      if (section->has(\"user\")) {\n        needs_keyring = true;\n        break;\n      }\n    }\n  }\n  if (needs_keyring) {\n    // Initialize keyring\n    keyring_info_.init(config, origin_.str());\n\n    if (keyring_info_.use_master_key_external_facility()) {\n      init_keyring_using_external_facility(config);\n    } else if (keyring_info_.use_master_key_file()) {\n      init_keyring_using_master_key_file();\n    } else { // prompt password\n      init_keyring_using_prompted_password();\n    }\n  }\n}\n\nvoid MySQLRouter::init_keyring_using_external_facility(mysql_harness::Config &config) {\n  keyring_info_.add_router_id_to_env(get_router_id(config));\n  if (!keyring_info_.read_master_key()) {\n    throw MasterKeyReadError(\"Cannot fetch master key using master key reader:\" + keyring_info_.get_master_key_reader());\n  }\n  keyring_info_.validate_master_key();\n  mysql_harness::init_keyring_with_key(keyring_info_.get_keyring_file(), keyring_info_.get_master_key(), false);\n}\n\nvoid MySQLRouter::init_keyring_using_master_key_file() {\n  mysql_harness::init_keyring(keyring_info_.get_keyring_file(), keyring_info_.get_master_key_file(), false);\n}\n\nvoid MySQLRouter::init_keyring_using_prompted_password() {\n#ifdef _WIN32\n  // When no master key file is provided, console interaction is required to\n  // provide a master password. Since console interaction is not available when\n  // run as service, throw an error to abort.\n  if (mysqlrouter::is_running_as_service())\n  {\n    std::string msg = \"Cannot run router in Windows a service without a master key file.\";\n    mysqlrouter::write_windows_event_log(msg);\n    throw std::runtime_error(msg);\n  }\n#endif\n  std::string master_key = mysqlrouter::prompt_password(\"Encryption key for router keyring\");\n  if (master_key.length() > mysql_harness::kMaxKeyringKeyLength)\n    throw std::runtime_error(\"Encryption key is too long\");\n  mysql_harness::init_keyring_with_key(keyring_info_.get_keyring_file(), master_key, false);\n}\n\nstatic string fixpath(const string &path, const std::string &basedir) {\n  if (path.empty())\n    return basedir;\n  if (path.compare(0, strlen(\"{origin}\"), \"{origin}\") == 0)\n    return path;\n  if (path.find(\"ENV{\") != std::string::npos)\n    return path;\n#ifdef _WIN32\n  if (path[0] == '\\\\' || path[0] == '/' || path[1] == ':')\n    return path;\n  // if the path is not absolute, it must be relative to the origin\n  return basedir+\"\\\\\"+path;\n#else\n  if (path[0] == '/')\n    return path;\n  // if the path is not absolute, it must be relative to the origin\n  return basedir+\"/\"+path;\n#endif\n}\n\nstd::map<std::string, std::string> MySQLRouter::get_default_paths() const {\n  std::string basedir = mysql_harness::Path(origin_).dirname().str();\n\n  std::map<std::string, std::string> params = {\n      {\"program\", kProgramName},\n      {\"origin\", origin_.str()},\n      {\"logging_folder\", fixpath(MYSQL_ROUTER_LOGGING_FOLDER, basedir)},\n      {\"plugin_folder\", fixpath(MYSQL_ROUTER_PLUGIN_FOLDER, basedir)},\n      {\"runtime_folder\", fixpath(MYSQL_ROUTER_RUNTIME_FOLDER, basedir)},\n      {\"config_folder\", fixpath(MYSQL_ROUTER_CONFIG_FOLDER, basedir)},\n      {\"data_folder\", fixpath(MYSQL_ROUTER_DATA_FOLDER, basedir)}\n  };\n  // check if the executable is being ran from the install location and if not\n  // set the plugin dir to a path relative to it\n#ifndef _WIN32\n  {\n    mysql_harness::Path install_origin(fixpath(MYSQL_ROUTER_BINARY_FOLDER, basedir));\n    if (!install_origin.exists() || !(install_origin.real_path() == origin_)) {\n      params[\"plugin_folder\"] = fixpath(MYSQL_ROUTER_PLUGIN_FOLDER, basedir);\n    }\n  }\n#else\n  {\n    mysql_harness::Path install_origin(fixpath(MYSQL_ROUTER_BINARY_FOLDER, basedir));\n    if (!install_origin.exists() || !(install_origin.real_path() == origin_)) {\n      params[\"plugin_folder\"] = origin_.dirname().join(\"lib\").str();\n    }\n  }\n#endif\n\n  // resolve environment variables & relative paths\n  for (auto it : params) {\n    std::string &param = params.at(it.first);\n    param.assign(mysqlrouter::substitute_variable(param, \"{origin}\", origin_.str()));\n  }\n  return params;\n}\n\n// throws mysql_harness::bad_section (std::runtime_error) on [logger:some_key] section\nstatic void set_default_log_level(mysql_harness::LoaderConfig& config, bool raw_mode /*= false*/) {\n\n  // What we do here is an UGLY HACK. TODO remove once we have a proper remedy.\n  //\n  // This is a (hopefully temporary) hack to guarantee backward compatibility\n  // after we revamped our logging facility in v8.0. Before, 8.0, our logger\n  // was a separate plugin, and thus config file had a [logger] section.\n  // Since 8.0, logger is integral part of the Harness and logger.so/dll no\n  // longer exists. Therefore [logger] section should no longer appear in the\n  // config file. Yet, we need to maintain backward compatibility of the\n  // config file, therefore must allow [logger] section to appear and carry the\n  // information it carried before. This however, presents numerous problems:\n  //\n  // - Loader will complain that it can't find a plugin.so (plugin.dll) and\n  //   shut down the Router\n  //\n  // - Loader will try to access start(), stop(), init() and deinit() functions\n  //   of the \"logger\" plugin, which are undefined\n  //\n  // - logger initialization will try to create a logger for non-existent\n  //   \"logger\" plugin\n  //\n  // - possibly others, the list is not necessairly exhaustive\n  //\n  //\n  //\n  // To work around these problems, we introduce an UGLY HACK:\n  // We allow [logger] section to appear, along with the log level key/value\n  // pair, as it did before. During log initialization, we look for that [logger]\n  // section and extract the information it carries. Then, we erase it from\n  // configuration, so that no other piece of code ever sees it.\n  // This hack relies on the fact that logging initialization is done very\n  // early in the startup of the Router, even before Loader or anything else\n  // gets a chance to access the configuration.\n\n  constexpr const char kNone[] = \"\";\n\n  // aliases with shorter names\n  constexpr const char* kLogLevel = mysql_harness::logging::kConfigOptionLogLevel;\n  constexpr const char* kLogger = mysql_harness::logging::kConfigSectionLogger;\n\n  // extract log level from [logger] section/log level entry, if it exists\n  if (config.has(kLogger) && config.get(kLogger, kNone).has(kLogLevel))\n    mysql_harness::logging::g_HACK_default_log_level = config.get(kLogger, kNone).get(kLogLevel);\n  // otherwise, set it to default\n  else\n    mysql_harness::logging::g_HACK_default_log_level = raw_mode\n        ? mysql_harness::logging::kRawLogLevelName\n        : mysql_harness::logging::kDefaultLogLevelName;\n\n  // now erase the entire [logger] section, if it exists (NOTE: it will not erase sections with keys)\n  config.remove(kLogger);  // no-op if [logger] section doesn't exist\n\n  // if there's anything leftover, it means it must be a section with a key\n  if (config.has_any(kLogger)) {\n    throw mysql_harness::bad_section(std::string(\"Section '\") + kLogger + \"' does not support keys\");\n  }\n}\n\nstd::exception_ptr detect_and_fix_nonfatal_problems(mysql_harness::LoaderConfig& config) {\n  // This function checks (and fixes) certain logging-related problems, which can be fixed well\n  // enough to enable the logger to initialize, and therefore log the actual problem, before the\n  // whole application exits with error.\n  //\n  // We return the exception ptr to the first problem we found.\n\n  std::exception_ptr eptr = nullptr;\n\n  // fix invalid log level\n  try {\n    mysql_harness::logging::get_default_log_level(config);\n  } catch (const std::invalid_argument&) {\n    mysql_harness::logging::g_HACK_default_log_level = mysql_harness::logging::kDefaultLogLevelName;\n    if (!eptr)\n      eptr = std::current_exception();\n  }\n\n  // return first problem found\n  return eptr;\n}\n\n/*static*/\nvoid MySQLRouter::init_main_logger(mysql_harness::LoaderConfig& config, bool raw_mode /*= false*/) {\n\n  // set defaults if they're not defined\n  set_default_log_level(config, raw_mode);  // throws std::runtime_error on [logger:some_key] section\n  if (!config.has_default(\"logging_folder\"))\n    config.set_default(\"logging_folder\", \"\");\n\n  const std::string logging_folder = config.get_default(\"logging_folder\");\n\n  // detect (and fix) certain logger config problems early\n  std::exception_ptr first_problem = detect_and_fix_nonfatal_problems(config);\n\n  // setup logging\n  {\n    // REMINDER: If something threw beyond this point, but before we managed to re-initialize\n    //           the logger (registry), we would be in a world of pain: throwing with a non-\n    //           functioning logger may cascade to a place where the error is logged and... BOOM!)\n    //           So we deal with the above problem by working on a new logger registry object,\n    //           and only if nothing throws, we replace the current registry with the new one at\n    //           the very end.\n\n    // our new logger registry, it will replace the current one if all goes well\n    std::unique_ptr<mysql_harness::logging::Registry> registry(new mysql_harness::logging::Registry());\n\n    // register loggers for all modules + main exec (throws std::logic_error, std::invalid_argument)\n    mysql_harness::logging::init_loggers(*registry, config,\n                                         {MYSQL_ROUTER_LOG_DOMAIN}, MYSQL_ROUTER_LOG_DOMAIN);\n\n    // register logger for sql domain\n    mysql_harness::logging::init_logger(*registry, config, \"sql\");\n\n    // attach all loggers to main handler (throws std::runtime_error)\n    mysql_harness::logging::create_main_logfile_handler(*registry, kProgramName,\n                                                        logging_folder, !raw_mode);\n\n    // nothing threw - we're good. Now let's replace the new registry with the old one\n    DIM::instance().set_LoggingRegistry([&registry](){ return registry.release(); },\n                                        std::default_delete<mysql_harness::logging::Registry>());\n    DIM::instance().reset_LoggingRegistry();\n\n    // flag that the new loggers are ready for use\n    DIM::instance().get_LoggingRegistry().set_ready();\n  }\n\n  // now that our logger is running, report the first problem found (if any)\n  if (first_problem)\n    std::rethrow_exception(first_problem);\n\n  // and give it a first spin\n  if (config.logging_to_file())\n    log_debug(\"Main logger initialized, logging to '%s'\", config.get_log_file().c_str());\n  else\n    log_debug(\"Main logger initialized, logging to STDERR\");\n}\n\nvoid MySQLRouter::init_plugin_loggers(mysql_harness::LoaderConfig& config) {\n  mysql_harness::logging::Registry& registry = DIM::instance().get_LoggingRegistry();\n\n  // logging facility should be operational and main logger should exist by now\n  assert(registry.is_ready());\n\n  // put together a list of plugins to be loaded. loader_->available() provides\n  // a list of plugin instances (one per each [section:key]), while we need\n  // a list of plugin names (each entry has to be unique).\n  std::set<std::string> modules;\n  std::list<mysql_harness::Config::SectionKey> plugins = loader_->available();\n  for (const mysql_harness::Config::SectionKey& sk : plugins)\n    modules.emplace(sk.first);\n\n  // create loggers for all modules (plugins)\n  std::list<std::string> log_domains(modules.begin(), modules.end());\n  mysql_harness::logging::init_loggers( // throws std::invalid_argument, std::logic_error\n      registry, config, log_domains, MYSQL_ROUTER_LOG_DOMAIN);\n\n  // take all the handlers that exist, and attach them to all new loggers.\n  // At the time of writing, there is only one such handler - the main console/file\n  // handler that was created in init_main_logger()\n  for (const std::string& h : registry.get_handler_names())\n    attach_handler_to_all_loggers(registry, h);\n}\n\n// throws std::runtime_error\nmysql_harness::LoaderConfig* MySQLRouter::make_config(const std::map<std::string, std::string> params, ConfigFiles config_files) {\n  constexpr const char* err_msg = \"Configuration error: %s.\";\n\n  try {\n    // LoaderConfig ctor throws bad_option (std::runtime_error)\n    std::unique_ptr<mysql_harness::LoaderConfig> config(\n        new mysql_harness::LoaderConfig(params, std::vector<std::string>(),\n                                        mysql_harness::Config::allow_keys));\n\n    // throws std::invalid_argument, std::runtime_error, syntax_error, ...\n    for (const mysql_harness::Path& config_file: config_files.available_config_files())\n      config->read(config_file);\n\n    return config.release();\n  } catch (const mysql_harness::syntax_error &err) {\n    throw std::runtime_error(string_format(err_msg, err.what()));\n  } catch (const std::runtime_error &err) {\n    throw std::runtime_error(string_format(err_msg, err.what()));\n  }\n}\n\n// throws std::runtime_error\nvoid MySQLRouter::init_loader(mysql_harness::LoaderConfig& config) {\n  std::string err_msg = \"Configuration error: %s.\"; // TODO: is this error message right?\n  try {\n    loader_ = std::unique_ptr<mysql_harness::Loader>(new mysql_harness::Loader(kProgramName, config));\n  } catch (const std::runtime_error &err) {\n    throw std::runtime_error(string_format(err_msg.c_str(), err.what()));\n  }\n}\n\nvoid MySQLRouter::start() {\n  if (showing_info_ || !bootstrap_uri_.empty()) {\n    // when we are showing info like --help or --version, we do not throw\n    return;\n  }\n\n#ifndef _WIN32\n  // if the --user parameter was provided on the command line, switch\n  // to the user asap before accessing the external files to check\n  // that the user has rights to use them\n  if (!user_cmd_line_.empty()) {\n    set_user(user_cmd_line_, true, this->sys_user_operations_);\n  }\n#endif\n\n  // default configuration for boostrap is not supported\n  // extra configuration for bootstrap is not supported\n  ConfigFiles config_files(default_config_files_, config_files_, extra_config_files_);\n  // read config, and also make this config globally-available via DIM\n  DIM::instance().reset_Config(); // simplifies unit tests\n  DIM::instance().set_Config([this, &config_files](){ return make_config(get_default_paths(), config_files); }, std::default_delete<mysql_harness::LoaderConfig>());\n  mysql_harness::LoaderConfig& config = DIM::instance().get_Config();\n\n#ifndef _WIN32\n  // --user param given on the command line has a priority over\n  // the user in the configuration\n  if (user_cmd_line_.empty() && config.has_default(\"user\")) {\n    set_user(config.get_default(\"user\"), true, this->sys_user_operations_);\n  }\n#endif\n\n  // create logging directory if necessary\n  if (config.logging_to_file()) {\n    // get logger directory\n    auto log_file = config.get_log_file();\n    std::string log_path(log_file.str()); // log_path = /path/to/file.log\n    size_t pos;\n    pos = log_path.find_last_of('/');\n    if (pos != std::string::npos)\n      log_path.erase(pos);                // log_path = /path/to\n\n    // mkdir if it doesn't exist\n    if (mysql_harness::Path(log_path).exists() == false &&\n        mysqlrouter::mkdir(log_path, mysqlrouter::kStrictDirectoryPerm) != 0)\n        throw std::runtime_error(\"Error when creating dir '\" + log_path + \"': \" + std::to_string(errno));\n  }\n\n  // reinit logger (right now the logger is configured to log to STDERR, here\n  //                we re-configure it with settings from config file)\n  init_main_logger(config); // throws std::runtime_error on error opening file or bad config\n\n  if (!can_start_) {\n    throw std::runtime_error(\"Can not start\");\n  }\n\n\n\n  // Using environment variable ROUTER_PID is a temporary solution. We will remove this\n  // functionality when Harness introduces the `pid_file` option.\n  auto pid_file_env = std::getenv(\"ROUTER_PID\");\n  if (pid_file_env != nullptr) {\n    pid_file_path_ = pid_file_env;\n    mysql_harness::Path pid_file_path(pid_file_path_);\n    if (pid_file_path.is_regular()) {\n      throw std::runtime_error(string_format(\"PID file %s found. Already running?\", pid_file_path_.c_str()));\n    }\n  }\n\n  init_loader(config);  // throws std::runtime_error\n\n  if (!pid_file_path_.empty()) {\n    auto pid = getpid();\n    std::ofstream pidfile(pid_file_path_);\n    if (pidfile.good()) {\n      pidfile << pid << std::endl;\n      pidfile.close();\n      log_info(\"PID %d written to '%s'\", pid, pid_file_path_.c_str());\n    } else {\n      throw std::runtime_error(\n          string_format(\"Failed writing PID to %s: %s\", pid_file_path_.c_str(), mysqlrouter::get_last_error(errno).c_str()));\n    }\n  }\n\n  std::list<mysql_harness::Config::SectionKey> plugins = loader_->available();\n  if (!plugins.size())\n    throw std::runtime_error(\"MySQL Router not configured to load or start any plugin. Exiting.\");\n\n  init_plugin_loggers(config);\n\n  // there can be at most one metadata_cache section because\n  // currently the router supports only one metadata_cache instance\n  if (config.has_any(\"metadata_cache\") && config.get(\"metadata_cache\").size() > 1)\n    throw std::runtime_error(\n        \"MySQL Router currently supports only one metadata_cache instance. \"\n        \"There is more than one metadata_cache section in the router configuration. Exiting.\"\n    );\n\n  init_keyring(config);\n\n  loader_->start();\n}\n\nvoid MySQLRouter::set_default_config_files(const char *locations) noexcept {\n  std::stringstream ss_line{locations};\n\n  // We remove all previous entries\n  default_config_files_.clear();\n  std::vector<string>().swap(default_config_files_);\n\n  for (string file; std::getline(ss_line, file, ';');) {\n    bool ok = mysqlrouter::substitute_envvar(file);\n    if (ok) { // if there's no placeholder in file path, this is OK too\n      default_config_files_.push_back(mysqlrouter::substitute_variable(file, \"{origin}\",\n                                                                       origin_.str()));\n    } else {\n      // Any other problem with placeholders we ignore and don't use file\n    }\n  }\n}\n\nstring MySQLRouter::get_version() noexcept {\n  return string(MYSQL_ROUTER_VERSION);\n}\n\nstring MySQLRouter::get_version_line() noexcept {\n  std::ostringstream os;\n  string edition{MYSQL_ROUTER_VERSION_EDITION};\n\n  os << MYSQL_ROUTER_PACKAGE_NAME << \" v\" << get_version();\n\n  os << \" on \" << MYSQL_ROUTER_PACKAGE_PLATFORM << \" (\" << (MYSQL_ROUTER_PACKAGE_ARCH_64BIT ? \"64-bit\" : \"32-bit\") << \")\";\n\n  if (!edition.empty()) {\n    os << \" (\" << edition << \")\";\n  }\n\n  return os.str();\n}\n\nvector<string> MySQLRouter::check_config_files() {\n  ConfigFiles config_files(default_config_files_, config_files_, extra_config_files_);\n  if (config_files.empty())\n    throw std::runtime_error(\"No valid configuration file available. See --help for more information (looked at paths '\"\n        + config_files.paths_attempted() + \"').\");\n  return config_files.available_config_files();\n}\n\nvoid MySQLRouter::save_bootstrap_option_not_empty(const std::string& option_name, const std::string& save_name,\n                                     const std::string& option_value) {\n  if (option_value.empty())\n    throw std::runtime_error(\"Value for option '\" + option_name + \"' can't be empty.\");\n\n  bootstrap_options_[save_name] = option_value;\n}\n\nvoid MySQLRouter::assert_bootstrap_mode(const std::string& option_name) const {\n  if (this->bootstrap_uri_.empty())\n    throw std::runtime_error(\"Option \" + option_name + \" can only be used together with -B/--bootstrap\");\n}\n\nvoid MySQLRouter::prepare_command_options() noexcept {\n\n  // General guidelines for naming command line options:\n  //\n  // Option names that start with --conf are meant to affect\n  // configuration only and used during bootstrap.\n  // If an option affects the bootstrap process itself, it should\n  // omit the --conf prefix, even if it affects both the bootstrap\n  // and the configuration.\n\n  arg_handler_.clear_options();\n  arg_handler_.add_option(CmdOption::OptionNames({\"-V\", \"--version\"}), \"Display version information and exit.\",\n                          CmdOptionValueReq::none, \"\", [this](const string &) {\n        std::cout << this->get_version_line() << std::endl;\n        this->showing_info_ = true;\n      });\n\n  arg_handler_.add_option(CmdOption::OptionNames({\"-?\", \"--help\"}), \"Display this help and exit.\",\n                          CmdOptionValueReq::none, \"\", [this](const string &) {\n        this->show_help();\n        this->showing_info_ = true;\n      });\n\n  arg_handler_.add_option(OptionNames({\"-B\", \"--bootstrap\"}),\n                          \"Bootstrap and configure Router for operation with a MySQL InnoDB cluster.\",\n                          CmdOptionValueReq::required, \"server_url\",\n                          [this](const string &server_url) {\n        if (server_url.empty()) {\n          throw std::runtime_error(\"Invalid value for --bootstrap/-B option\");\n        }\n        this->bootstrap_uri_ = server_url;\n      });\n\n  arg_handler_.add_option(OptionNames({\"--bootstrap-socket\"}),\n                          \"Bootstrap and configure Router via a Unix socket\",\n                          CmdOptionValueReq::required, \"socket_name\",\n                          [this](const string &socket_name) {\n        if (socket_name.empty()) {\n            throw std::runtime_error(\"Invalid value for --bootstrap-socket option\");\n        }\n\n        this->save_bootstrap_option_not_empty(\"--bootstrap-socket\", \"bootstrap_socket\", socket_name);\n    }, [this] { this->assert_bootstrap_mode(\"--bootstrap-socket\"); });\n\n  arg_handler_.add_option(OptionNames({\"-d\", \"--directory\"}),\n                          \"Creates a self-contained directory for a new instance of the Router. (bootstrap)\",\n                          CmdOptionValueReq::required, \"directory\",\n                          [this](const string &path) {\n        if (path.empty()) {\n          throw std::runtime_error(\"Invalid value for --directory option\");\n        }\n        this->bootstrap_directory_ = path;\n      }, [this] { this->assert_bootstrap_mode(\"-d/--directory\"); });\n\n#ifndef _WIN32\n  arg_handler_.add_option(OptionNames({\"--conf-use-sockets\"}),\n                          \"Whether to use Unix domain sockets. (bootstrap)\",\n                          CmdOptionValueReq::none, \"\",\n                          [this](const string &) {\n        this->bootstrap_options_[\"use-sockets\"] = \"1\";\n      }, [this] { this->assert_bootstrap_mode(\"--conf-use-sockets\"); });\n\n  arg_handler_.add_option(OptionNames({\"--conf-skip-tcp\"}),\n                          \"Whether to disable binding of a TCP port for incoming connections. (bootstrap)\",\n                          CmdOptionValueReq::none, \"\",\n                          [this](const string &) {\n        this->bootstrap_options_[\"skip-tcp\"] = \"1\";\n      }, [this] { this->assert_bootstrap_mode(\"--conf-skip-tcp\"); });\n#endif\n  arg_handler_.add_option(OptionNames({\"--conf-base-port\"}),\n                          \"Base port to use for listening router ports. (bootstrap)\",\n                          CmdOptionValueReq::required, \"port\",\n                          [this](const string &port) {\n        this->bootstrap_options_[\"base-port\"] = port;\n      }, [this] { this->assert_bootstrap_mode(\"--conf-base-port\"); });\n\n  arg_handler_.add_option(OptionNames({\"--conf-bind-address\"}),\n                          \"IP address of the interface to which router's listening sockets should bind. (bootstrap)\",\n                          CmdOptionValueReq::required, \"address\",\n                          [this](const string &address) {\n        this->bootstrap_options_[\"bind-address\"] = address;\n      }, [this] { this->assert_bootstrap_mode(\"--conf-bind-address\"); });\n\n  arg_handler_.add_option(OptionNames({\"--master-key-reader\"}),\n                          \"The tool that can be used to read master key, it has to be used together with --master-key-writer. (bootstrap)\",\n                          CmdOptionValueReq::required, \"\",\n                          [this](const string &master_key_reader) {\n        this->keyring_info_.set_master_key_reader(master_key_reader);\n      },\n      [this] {\n        this->assert_bootstrap_mode(\"--master-key-reader\");\n        if (this->keyring_info_.get_master_key_reader().empty() != this->keyring_info_.get_master_key_writer().empty())\n          throw std::runtime_error(\"Option --master-key-reader can only be used together with --master-key-writer.\");\n      });\n\n  arg_handler_.add_option(OptionNames({\"--master-key-writer\"}),\n                          \"The tool that can be used to store master key, it has to be used together with --master-key-reader. (bootstrap)\",\n                          CmdOptionValueReq::required, \"\",\n                          [this](const string &master_key_writer) {\n        this->keyring_info_.set_master_key_writer(master_key_writer);\n      },\n      [this] {\n        this->assert_bootstrap_mode(\"--master-key-writer\");\n        if (this->keyring_info_.get_master_key_reader().empty() != this->keyring_info_.get_master_key_writer().empty())\n          throw std::runtime_error(\"Option --master-key-writer can only be used together with --master-key-reader.\");\n      });\n\n  arg_handler_.add_option(OptionNames({\"--connect-timeout\"}),\n                          \"The time in seconds after which trying to connect to metadata server should timeout. It applies to bootstrap mode and is written to configuration file. It is also used in normal mode.\",\n                          CmdOptionValueReq::optional, \"\",\n                          [this](const  string &connect_timeout) {\n        this->bootstrap_options_[\"connect-timeout\"] = connect_timeout;\n      });\n  arg_handler_.add_option(OptionNames({\"--read-timeout\"}),\n                          \"The time in seconds after which read from metadata server should timeout. It applies to bootstrap mode and is written to configuration file. It is also used in normal mode.\",\n                          CmdOptionValueReq::optional, \"\",\n                          [this](const  string &read_timeout) {\n        this->bootstrap_options_[\"read-timeout\"] = read_timeout;\n      });\n#ifndef _WIN32\n  arg_handler_.add_option(OptionNames({\"-u\", \"--user\"}),\n                          \"Run the mysqlrouter as the user having the name user_name.\",\n                          CmdOptionValueReq::required, \"username\",\n                          [this](const string &username) {\n        this->username_ = username;\n      },\n      [this] {\n        if (this->bootstrap_uri_.empty()) {\n          this->user_cmd_line_ = this->username_;\n        }\n        else {\n          check_user(this->username_, true, this->sys_user_operations_);\n          this->bootstrap_options_[\"user\"] =  this->username_;\n        }\n      });\n#endif\n\n  arg_handler_.add_option(OptionNames({\"--name\"}),\n                          \"Gives a symbolic name for the router instance. (bootstrap)\",\n                          CmdOptionValueReq::optional, \"name\",\n                          [this](const string &name) {\n        this->bootstrap_options_[\"name\"] = name;\n      }, [this] { this->assert_bootstrap_mode(\"--name\"); });\n\n  arg_handler_.add_option(OptionNames({\"--force-password-validation\"}),\n                          \"When autocreating database account do not use HASHED password. (bootstrap)\",\n                          CmdOptionValueReq::none, \"\",\n                          [this](const string &) {\n        this->bootstrap_options_[\"force-password-validation\"] = \"1\";\n      }, [this] { this->assert_bootstrap_mode(\"--force-password-validation\"); });\n\n  arg_handler_.add_option(OptionNames({\"--password-retries\"}),\n                          \"Number of the retries for generating the router's user password. (bootstrap)\",\n                          CmdOptionValueReq::optional, \"password-retries\",\n                          [this](const string &retries) {\n        this->bootstrap_options_[\"password-retries\"] = retries;\n      }, [this] { this->assert_bootstrap_mode(\"--password-retries\"); });\n\n  arg_handler_.add_option(OptionNames({\"--account-host\"}),\n                          \"Host pattern to be used when creating Router's database user, default='%'. \"\n                          \"It can be used multiple times to provide multiple patterns. (bootstrap)\",\n                          CmdOptionValueReq::required, \"account-host\",\n                          [this](const string &host_pattern) {\n        std::vector<std::string>& hostnames = this->bootstrap_multivalue_options_[\"account-host\"];\n        hostnames.push_back(host_pattern);\n\n        // sort and eliminate any non-unique hostnames; we do this to ensure that\n        // CREATE USER does not get called twice for the same user@host later on\n        // in the ConfigGenerator\n        std::sort(hostnames.begin(), hostnames.end());\n        auto it = std::unique(hostnames.begin(), hostnames.end());\n        hostnames.resize(std::distance(hostnames.begin(), it));\n      }, [this] { this->assert_bootstrap_mode(\"--account-host\"); });\n\n  arg_handler_.add_option(OptionNames({\"--report-host\"}),\n                          \"Host name of this computer (it will be queried from OS if not provided). \"\n                          \"It is used as suffix (the part after '@') in Router's database user name; \"\n                          \"should match host name as seen by the cluster nodes (bootstrap)\",\n                          CmdOptionValueReq::required, \"report-host\",\n                          [this](const string &hostname) {\n\n        if (!mysql_harness::is_valid_hostname(hostname.c_str()))\n          throw std::runtime_error(\"Option --report-host has an invalid value.\");\n\n        auto pr = this->bootstrap_options_.insert({\"report-host\", hostname});\n        if (pr.second == false)\n          throw std::runtime_error(\"Option --report-host can only be used once.\");\n      }, [this] { this->assert_bootstrap_mode(\"--report-host\"); });\n\n  arg_handler_.add_option(OptionNames({\"--force\"}),\n                          \"Force reconfiguration of a possibly existing instance of the router. (bootstrap)\",\n                          CmdOptionValueReq::none, \"\",\n                          [this](const string &) {\n        this->bootstrap_options_[\"force\"] = \"1\";\n      }, [this] { this->assert_bootstrap_mode(\"--force\"); });\n\n  char ssl_mode_vals[128];\n  char ssl_mode_desc[384];\n  snprintf(ssl_mode_vals, sizeof(ssl_mode_vals), \"%s|%s|%s|%s|%s\",\n           mysqlrouter::MySQLSession::kSslModeDisabled,\n           mysqlrouter::MySQLSession::kSslModePreferred,\n           mysqlrouter::MySQLSession::kSslModeRequired,\n           mysqlrouter::MySQLSession::kSslModeVerifyCa,\n           mysqlrouter::MySQLSession::kSslModeVerifyIdentity);\n  snprintf(ssl_mode_desc, sizeof(ssl_mode_desc),\n           \"SSL connection mode for use during bootstrap and normal operation, when connecting to the metadata server. Analogous to --ssl-mode in mysql client. One of %s. Default = %s. (bootstrap)\",\n           ssl_mode_vals, mysqlrouter::MySQLSession::kSslModePreferred);\n\n  arg_handler_.add_option(OptionNames({\"--ssl-mode\"}), ssl_mode_desc,\n                          CmdOptionValueReq::required, \"mode\",\n                          [this](const string &ssl_mode) {\n        try {\n          mysqlrouter::MySQLSession::parse_ssl_mode(ssl_mode);  // we only care if this succeeds\n          bootstrap_options_[\"ssl_mode\"] = ssl_mode;\n        } catch (const std::logic_error& e) {\n          throw std::runtime_error(\"Invalid value for --ssl-mode option\");\n        }\n      }, [this] { this->assert_bootstrap_mode(\"--ssl-mode\"); });\n\n  arg_handler_.add_option(OptionNames({\"--ssl-cipher\"}), \": separated list of SSL ciphers to allow, if SSL is enabeld.\",\n                          CmdOptionValueReq::required, \"ciphers\",\n                          [this](const string &cipher) {\n        this->save_bootstrap_option_not_empty(\"--ssl-cipher\", \"ssl_cipher\", cipher);\n      }, [this] { this->assert_bootstrap_mode(\"--ssl-cipher\"); });\n\n  arg_handler_.add_option(OptionNames({\"--tls-version\"}), \", separated list of TLS versions to request, if SSL is enabled.\",\n                          CmdOptionValueReq::required, \"versions\",\n                          [this](const string &version) {\n        this->save_bootstrap_option_not_empty(\"--tls-version\", \"tls_version\", version);\n      }, [this] { this->assert_bootstrap_mode(\"--tls-version\"); });\n\n  arg_handler_.add_option(OptionNames({\"--ssl-ca\"}), \"Path to SSL CA file to verify server's certificate against.\",\n                          CmdOptionValueReq::required, \"path\",\n                          [this](const string &path) {\n        this->save_bootstrap_option_not_empty(\"--ssl-ca\", \"ssl_ca\", path);\n      }, [this] { this->assert_bootstrap_mode(\"--ssl-ca\"); });\n\n  arg_handler_.add_option(OptionNames({\"--ssl-capath\"}), \"Path to directory containing SSL CA files to verify server's certificate against.\",\n                          CmdOptionValueReq::required, \"directory\",\n                          [this](const string &path) {\n        this->save_bootstrap_option_not_empty(\"--ssl-capath\", \"ssl_capath\", path);\n      }, [this] { this->assert_bootstrap_mode(\"--ssl-capath\"); });\n\n  arg_handler_.add_option(OptionNames({\"--ssl-crl\"}), \"Path to SSL CRL file to use when verifying server certificate.\",\n                          CmdOptionValueReq::required, \"path\",\n                          [this](const string &path) {\n        this->save_bootstrap_option_not_empty(\"--ssl-crl\", \"ssl_crl\", path);\n      }, [this] { this->assert_bootstrap_mode(\"--ssl-crl\"); });\n\n  arg_handler_.add_option(OptionNames({\"--ssl-crlpath\"}), \"Path to directory containing SSL CRL files to use when verifying server certificate.\",\n                          CmdOptionValueReq::required, \"directory\",\n                          [this](const string &path) {\n        this->save_bootstrap_option_not_empty(\"--ssl-crlpath\", \"ssl_crlpath\", path);\n      }, [this] { this->assert_bootstrap_mode(\"--ssl-crlpath\"); });\n\n  arg_handler_.add_option(OptionNames({\"--ssl-cert\"}), \"Path to client SSL certificate, to be used if client certificate verification is required. Used during bootstrap only.\",\n                          CmdOptionValueReq::required, \"path\",\n                          [this](const string &path) {\n        this->save_bootstrap_option_not_empty(\"--ssl-cert\", \"ssl_cert\", path);\n      }, [this] { this->assert_bootstrap_mode(\"--ssl-cert\"); });\n\n  arg_handler_.add_option(OptionNames({\"--ssl-key\"}), \"Path to private key for client SSL certificate, to be used if client certificate verification is required. Used during bootstrap only.\",\n                          CmdOptionValueReq::required, \"path\",\n                          [this](const string &path) {\n        this->save_bootstrap_option_not_empty(\"--ssl-key\", \"ssl_key\", path);\n      }, [this] { this->assert_bootstrap_mode(\"--ssl-key\"); });\n\n  arg_handler_.add_option(OptionNames({\"-c\", \"--config\"}),\n                          \"Only read configuration from given file.\",\n                          CmdOptionValueReq::required, \"path\", [this](const string &value) {\n\n        if (!config_files_.empty()) {\n          throw std::runtime_error(\"Option -c/--config can only be used once; use -a/--extra-config instead.\");\n        }\n\n        // When --config is used, no defaults shall be read\n        default_config_files_.clear();\n        check_and_add_conf(config_files_, value);\n      });\n\n  arg_handler_.add_option(CmdOption::OptionNames({\"-a\", \"--extra-config\"}),\n                          \"Read this file after configuration files are read from either \"\n                              \"default locations or from files specified by the --config option.\",\n                          CmdOptionValueReq::required, \"path\", [this](const string &value) {\n        check_and_add_conf(extra_config_files_, value);\n      });\n// These are additional Windows-specific options, added (at the time of writing) in check_service_operations().\n// Grep after '--install-service' and you shall find.\n#ifdef _WIN32\n  arg_handler_.add_option(CmdOption::OptionNames({\"--install-service\"}), \"Install Router as Windows service\",\n                          CmdOptionValueReq::none, \"\", [this](const string &) {/*implemented elsewhere*/});\n\n  arg_handler_.add_option(CmdOption::OptionNames({\"--install-service-manual\"}), \"Install Router as Windows service, manually\",\n                          CmdOptionValueReq::none, \"\", [this](const string &) {/*implemented elsewhere*/});\n\n  arg_handler_.add_option(CmdOption::OptionNames({\"--remove-service\"}), \"Remove Router from Windows services\",\n                          CmdOptionValueReq::none, \"\", [this](const string &) {/*implemented elsewhere*/});\n\n  arg_handler_.add_option(CmdOption::OptionNames({\"--service\"}), \"Start Router as Windows service\",\n                          CmdOptionValueReq::none, \"\", [this](const string &) {/*implemented elsewhere*/});\n\n  arg_handler_.add_option(CmdOption::OptionNames({ \"--update-credentials-section\" }), \"Updates the credentials for the given section\",\n    CmdOptionValueReq::required, \"section_name\", [this](const string& value) {\n    std::string prompt = mysqlrouter::string_format(\"Enter password for config section '%s'\", value.c_str());\n    std::string pass = mysqlrouter::prompt_password(prompt);\n    PasswordVault pv;\n    pv.update_password(value, pass);\n    pv.store_passwords();\n    log_info(\"The password was stored in the vault successfully.\");\n    throw silent_exception();\n  });\n\n  arg_handler_.add_option(CmdOption::OptionNames({ \"--remove-credentials-section\" }), \"Removes the credentials for the given section\",\n    CmdOptionValueReq::required, \"section_name\", [this](const string& value) {\n    PasswordVault pv;\n    pv.remove_password(value);\n    pv.store_passwords();\n    log_info(\"The password was removed successfully.\");\n    throw silent_exception();\n  });\n\n  arg_handler_.add_option(CmdOption::OptionNames({ \"--clear-all-credentials\" }), \"Clear the vault, removing all the credentials stored on it\",\n    CmdOptionValueReq::none, \"\", [this](const string&) {\n    PasswordVault pv;\n    pv.clear_passwords();\n    log_info(\"Removed successfully all passwords from the vault.\");\n    throw silent_exception();\n  });\n#endif\n\n}\n\nvoid MySQLRouter::bootstrap(const std::string &server_url) {\n  mysqlrouter::ConfigGenerator config_gen{\n#ifndef _WIN32\n      sys_user_operations_\n#endif\n  };\n  config_gen.init(server_url, bootstrap_options_); // throws std::runtime_error\n  config_gen.warn_on_no_ssl(bootstrap_options_);   // throws std::runtime_error\n\n#ifdef _WIN32\n  // Cannot run boostrap mode as windows service since it requires console interaction.\n  if (mysqlrouter::is_running_as_service())\n  {\n    std::string msg = \"Cannot run router in boostrap mode as Windows service.\";\n    mysqlrouter::write_windows_event_log(msg);\n    throw std::runtime_error(msg);\n  }\n#endif\n\n  auto default_paths = get_default_paths();\n\n  if (bootstrap_directory_.empty()) {\n    std::string config_file_path =\n        mysqlrouter::substitute_variable(MYSQL_ROUTER_CONFIG_FOLDER\"/mysqlrouter.conf\",\n                                         \"{origin}\", origin_.str());\n    std::string master_key_path =\n        mysqlrouter::substitute_variable(MYSQL_ROUTER_CONFIG_FOLDER\"/mysqlrouter.key\",\n                                         \"{origin}\", origin_.str());\n    std::string default_keyring_file;\n    default_keyring_file = mysqlrouter::substitute_variable(MYSQL_ROUTER_DATA_FOLDER,\n                                                            \"{origin}\", origin_.str());\n    mysql_harness::Path keyring_dir(default_keyring_file);\n    if (!keyring_dir.exists()) {\n      if (mysqlrouter::mkdir(default_keyring_file, mysqlrouter::kStrictDirectoryPerm) < 0) {\n        log_error(\"Cannot create directory '%s': %s\", truncate_string(default_keyring_file).c_str(), get_strerror(errno).c_str());\n        throw std::runtime_error(\"Could not create keyring directory\");\n      } else {\n        // sets the directory owner for the --user if provided\n        config_gen.set_file_owner(bootstrap_options_, default_keyring_file);\n        default_keyring_file = keyring_dir.real_path().str();\n      }\n    }\n    default_keyring_file.append(\"/\").append(kDefaultKeyringFileName);\n\n    keyring_info_.set_keyring_file(default_keyring_file);\n    keyring_info_.set_master_key_file(master_key_path);\n    config_gen.set_keyring_info(keyring_info_);\n    config_gen.bootstrap_system_deployment(config_file_path,\n        bootstrap_options_, bootstrap_multivalue_options_, default_paths);\n  } else {\n    keyring_info_.set_keyring_file(kDefaultKeyringFileName);\n    keyring_info_.set_master_key_file(\"mysqlrouter.key\");\n    config_gen.set_keyring_info(keyring_info_);\n    config_gen.bootstrap_directory_deployment(bootstrap_directory_,\n        bootstrap_options_, bootstrap_multivalue_options_, default_paths);\n  }\n}\n\n\nvoid MySQLRouter::show_help() noexcept {\n  FILE *fp;\n  std::cout << get_version_line() << std::endl;\n  std::cout << WELCOME << std::endl;\n\n  for (auto line: wrap_string(\"Configuration read from the following files in the given order\"\n                                  \" (enclosed in parentheses means not available for reading):\", kHelpScreenWidth,\n                              0)) {\n    std::cout << line << std::endl;\n  }\n\n  for (auto file : default_config_files_) {\n\n    if ((fp = std::fopen(file.c_str(), \"r\")) == nullptr) {\n      std::cout << \"  (\" << file << \")\" << std::endl;\n    } else {\n      std::fclose(fp);\n      std::cout << \"  \" << file << std::endl;\n    }\n  }\n  const std::map<std::string, std::string> paths = get_default_paths();\n  std::cout << \"Plugins Path:\" << std::endl <<\n      \"  \" << paths.at(\"plugin_folder\") << std::endl;\n  std::cout << \"Default Log Directory:\" << std::endl <<\n      \"  \" << paths.at(\"logging_folder\") << std::endl;\n  std::cout << \"Default Persistent Data Directory:\" << std::endl <<\n      \"  \" << paths.at(\"data_folder\") << std::endl;\n  std::cout << \"Default Runtime State Directory:\" << std::endl <<\n      \"  \" << paths.at(\"runtime_folder\") << std::endl;\n  std::cout << std::endl;\n\n  show_usage();\n}\n\nvoid MySQLRouter::show_usage(bool include_options) noexcept {\n  for (auto line: arg_handler_.usage_lines(\"Usage: mysqlrouter\", \"\", kHelpScreenWidth)) {\n    std::cout << line << std::endl;\n  }\n\n  if (!include_options) {\n    return;\n  }\n\n  std::cout << \"\\nOptions:\" << std::endl;\n  for (auto line: arg_handler_.option_descriptions(kHelpScreenWidth, kHelpScreenIndent)) {\n    std::cout << line << std::endl;\n  }\n\n#ifdef _WIN32\n  std::cout << \"\\nExamples:\\n\"\n            << \"  Bootstrap for use with InnoDB cluster into system-wide installation\\n\"\n            << \"    mysqlrouter --bootstrap root@clusterinstance01\\n\"\n            << \"  Start router\\n\"\n            << \"    mysqlrouter\\n\"\n            << \"\\n\"\n            << \"  Bootstrap for use with InnoDb cluster in a self-contained directory\\n\"\n            << \"    mysqlrouter --bootstrap root@clusterinstance01 -d myrouter\\n\"\n            << \"  Start router\\n\"\n            << \"    myrouter\\\\start.ps1\\n\";\n#else\n  std::cout << \"\\nExamples:\\n\"\n            << \"  Bootstrap for use with InnoDB cluster into system-wide installation\\n\"\n            << \"    sudo mysqlrouter --bootstrap root@clusterinstance01 --user=mysqlrouter\\n\"\n            << \"  Start router\\n\"\n            << \"    sudo mysqlrouter --user=mysqlrouter&\\n\"\n            << \"\\n\"\n            << \"  Bootstrap for use with InnoDb cluster in a self-contained directory\\n\"\n            << \"    mysqlrouter --bootstrap root@clusterinstance01 -d myrouter\\n\"\n            << \"  Start router\\n\"\n            << \"    myrouter/start.sh\\n\";\n#endif\n  std::cout << \"\\n\";\n}\n\nvoid MySQLRouter::show_usage() noexcept {\n  show_usage(true);\n}\n"
  },
  {
    "path": "src/router/src/router_app.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef ROUTER_MYSQL_ROUTER_INCLUDED\n#define ROUTER_MYSQL_ROUTER_INCLUDED\n\n/** @file\n * @brief Defining the main class MySQLRouter\n *\n * This file defines the main class `MySQLRouter`.\n *\n */\n\n#include \"router_config.h\"\n#include \"mysql/harness/loader.h\"\n#include \"mysql/harness/arg_handler.h\"\n#include \"mysqlrouter/utils.h\"\n#include \"mysqlrouter/keyring_info.h\"\n\n#include <cstdint>\n#include <vector>\n\nusing std::string;\nusing std::tuple;\nusing std::make_tuple;\nusing std::vector;\n\nstatic const size_t kHelpScreenWidth = 72;\nstatic const size_t kHelpScreenIndent = 8;\n\nclass ConfigFiles;\n\n/** @class MySQLRouter\n *  @brief Manage the MySQL Router application.\n *\n *  The class MySQLRouter manages the MySQL Router application. It handles the\n *  command arguments, finds valid configuration files, and starts all plugins.\n *\n *  Since MySQL Router requires at least 1 configuration file to be available\n *  for reading, if no default configuration file location could be read and no\n *  explicit location was given, the application exits.\n *\n *  The class depends on MySQL Harness to, among other things, load the\n *  configuration and initalize all request plugins.\n *\n *  Example usage:\n *\n *     int main(int argc, char** argv) {\n *       MySQLRouter router(argc, argv);\n *       router.start();\n *     }\n *\n */\nclass MySQLRouter {\npublic:\n  /** @brief Default constructor\n   *\n   * Default constructor of MySQL Router which will not initialize.\n   *\n   * Usage:\n   *\n   *     MySQLRouter router;\n   *     router.start();\n   *\n   */\n  MySQLRouter() : can_start_(false), showing_info_(false)\n#ifndef _WIN32\n        ,sys_user_operations_(mysqlrouter::SysUserOperations::instance())\n#endif\n    {}\n\n\n  /** @brief Constructor with command line arguments as vector\n   *\n   * Constructor of MySQL Router which will start with the given command\n   * line arguments as a vector of strings.\n   *\n   * Example usage:\n   *\n   *     MySQLRouter router(Path(argv[0]).dirname(),\n   *                        vector<string>({argv + 1, argv + argc}));\n   *     router.start();\n   *\n   * @param origin Directory where executable is located\n   * @param arguments a vector of strings\n   * @param sys_user_operations .oO( ... )\n   */\n  MySQLRouter(const mysql_harness::Path& origin, const vector<string>& arguments\n#ifndef _WIN32\n             , mysqlrouter:: SysUserOperationsBase* sys_user_operations = mysqlrouter::SysUserOperations::instance()\n#endif\n          );\n\n  /** @brief Constructor with command line arguments\n   *\n   * Constructor of MySQL Router which will start with the given command\n   * line arguments given as the arguments argc and argv. Typically, argc\n   * and argv are passed on from the global main function.\n   *\n   * Example usage:\n   *\n   *     int main(int argc, char** argv) {\n   *       MySQLRouter router(argc, argv);\n   *       router.start();\n   *     }\n   *\n   * @param argc number of arguments\n   * @param argv pointer to first command line argument\n   * @param sys_user_operations .oO( ... )\n   */\n  MySQLRouter(const int argc, char** argv\n#ifndef _WIN32\n              , mysqlrouter::SysUserOperationsBase *sys_user_operations = mysqlrouter::SysUserOperations::instance()\n#endif\n  );\n\n  virtual ~MySQLRouter() = default;\n\n  /** @brief Initialize main logger\n   *\n   * Initializes main logger, according to options in the configuration.\n   *\n   * @param config Configuaration to be used to initialize logger\n   * @param raw_mode If true, all messages are logged raw; if false, messages\n   *        are subject formatting\n   *\n   * @throws std::runtime_error on:\n   * - failure to initialize file logger\n   * - bad configuration\n   *\n   * @note This function is static and public, because unlike init_plugin_loggers(),\n   * it's also meant to be called very early during startup, close to main().\n   */\n  static void init_main_logger(mysql_harness::LoaderConfig& config, bool raw_mode = false);\n\n  // Information member function\n  std::string get_package_name() noexcept;\n\n  /** @brief Returns the MySQL Router version as string\n   *\n   * Returns the MySQL Router as a string. The string is a concatenation\n   * of version's major, minor and patch parts, for example `1.0.2`.\n   *\n   * @return string containing the version\n   */\n  std::string get_version() noexcept;\n\n  /** @brief Returns string version details.\n   *\n   * Returns string with name and version details, including:\n   *\n   * * name of the application,\n   * * version,\n   * * platform and architecture,\n   * * edition,\n   * * and a special part-of-clause.\n   *\n   * The architecture is either 32-bit or 64-bit. Edition is usually used to\n   * denote whether release is either GPLv2 license or commercial.\n   *\n   * The part-of clause is used to show which product family MySQL Router\n   * belongs to.\n   *\n   * @devnote\n   * Most information can be defined while configuring using CMake and will\n   * become available through the router_config.h file (generated from\n   * router_config.h.in).\n   * @enddevnote\n   *\n   * @return a string containing version details\n   */\n  std::string get_version_line() noexcept;\n\n  /** @brief Starts the MySQL Router application\n   *\n   * Starts the MySQL Router application, reading the configuration file(s) and\n   * loading and starting all plugins.\n   *\n   * Example:\n   *\n   *     MySQLRouter router;\n   *     router.start();\n   *\n   * Throws std::runtime_error on configuration or plugin errors.\n   *\n   * @devnote\n   * We are using MySQL Harness to load and start the plugins. We give Harness\n   * a configuration files and it will parse it. Not that at this moment, Harness\n   * only accept one configuration file.\n   * @enddevnote\n   */\n  void start();\n\n  /** @brief Gets list of default configuration files\n   *\n   * Returns a list of configuration files which will be read (if available)\n   * by default.\n   *\n   * @return std::vector<string>\n   */\n  const std::vector<std::string>& get_default_config_files() const noexcept {\n    return default_config_files_;\n  }\n\n  /** @brief Gets list of configuration files passed using command line\n   *\n   * Returns a list of configuration files which were passed through command\n   * line options.\n   *\n   * @return std::vector<string>\n   */\n  const std::vector<std::string>& get_config_files() const noexcept {\n    return config_files_;\n  }\n\n  /** @brief Gets list of extra configuration files passed using command line\n   *\n   * Returns a list of extra configuration files which were passed through command\n   * line options.\n   *\n   * @return std::vector<string>\n   */\n  const std::vector<std::string>& get_extra_config_files() const noexcept {\n    return extra_config_files_;\n  }\n\n#if !defined(_MSC_VER) && !defined(UNIT_TESTS)\n  // MSVC produces different symbols for private vs public methods, which mean\n  // the #define private public trick for unit-testing private methods doesn't\n  // work. Thus, we turn private methods public in Windows.\nprivate:\n#endif\n\n  /** @brief Initializes the MySQL Router application\n   *\n   * Initialized the MySQL Router application by\n   *\n   * * setting the default configuration files,\n   * * loading the command line options,\n   * * processing the given command line arguments,\n   * * and finding all the usable configuration files.\n   *\n   * The command line options are passed using the `arguments`\n   * argument. It should be a vector of strings. For example, to start\n   * MySQL Router using the `main()` functions `argc` and `argv`\n   * arguments:\n   *\n   *     MySQLRouter router(vector<string>({argv + 1, argv + argc}));\n   *     router.start();\n   *\n   * @devnote\n   * We do not need the first command line argument, argv[0] since we do not\n   * use it.\n   * @enddevnote\n   *\n   * @param arguments command line arguments as vector of strings\n   */\n  virtual void init(const std::vector<std::string>& arguments);\n\n  /** @brief Prepares a command line option\n   *\n   * Prepares command line options for the MySQL Router `mysqlrouter` application.\n   *\n   * @internal\n   * Currently, to add options to the command line, you need to add it to the\n   * `prepare_command_options`-method using `CmdArgHandler::add_option()`.\n   * @endinternal\n   */\n  void prepare_command_options() noexcept;\n\n  /** @brief Process command line options\n   *\n   * Processes command line options for the MySQL Router `mysqlrouter` application.\n   */\n  void parse_command_options(const vector<string>& arguments); // throws std::runtime_error\n\n  /** @brief Finds all valid configuration files\n   *\n   * Finds all valid configuration files from the list of default\n   * configuration file locations.\n   *\n   * An exception of type `std::runtime_error` is thrown when no valid\n   * configuration file was found.\n   *\n   * @return returns a list of valid configuration file locations\n   *\n   */\n  std::vector<std::string> check_config_files();\n\n  /** @brief Shows the help screen on the console\n   *\n   * Shows the help screen on the console including\n   *\n   * * copyright and  trademark notice,\n   * * command line usage,\n   * * default configuration file locations,\n   * * and options with their descriptions.\n   *\n   * Users would use the command line option `--help`:\n   *\n   *     shell> mysqlrouter --help\n   */\n  void show_help() noexcept;\n\n  /** @brief Saves the selected command line option in the internal options array\n   *         after verifying it's value not empty and the router is doing bootstrap.\n   *\n   *  Throws: std::runtime_error\n   */\n  void save_bootstrap_option_not_empty(const std::string& option_name, const std::string& save_name,\n                                       const std::string& option_value);\n\n  /**\n   * @brief verify that bootstrap option (--bootstrap or -B) was given by user.\n   *\n   * @throw std::runtime_error if called in non-bootstrap mode.\n   */\n  void assert_bootstrap_mode(const std::string& option_name) const;\n\n  /** @brief Shows command line usage and option description\n   *\n   * Shows command line usage and all available options together with their description.\n   * It is possible to prevent the option listing by setting the argument `include_options`\n   * to `false`.\n   *\n   * @devnote\n   * This method is used by the `MySQLRouter::show_help()`. We keep a separate method so we could potentionally\n   * show the usage in other places or using different option combinations, for example after an\n   * error.\n   * @enddevnote\n   *\n   * @param include_options bool whether we show the options and descriptions\n   */\n  void show_usage(bool include_options) noexcept;\n\n  /* @overload */\n  void show_usage() noexcept;\n\n  /** @brief Sets default configuration file locations\n   *\n   *  Sets the default configuration file locations based on information\n   *  found in the locations argument. The locations should be provided\n   *  as a semicolon separated list.\n   *\n   *  The previous loaded locations are first removed. If not new locations\n   *  were provider (if locations argument is empty), then no configuration\n   *  files will be available.\n   *\n   *  Locations can include environment variable placeholders. These placeholders\n   *  are replaced using the provided name. For example, user Jane executing\n   *  MySQL Router:\n   *\n   *      /opt/ENV{USER}/etc    becomes   /opt/jane/etc\n   *\n   *  If the environment variable is not available, for example if MYSQL_ROUTER_HOME\n   *  was not set before starting MySQL Router, every location using this\n   *  environment variable will be ignored.\n   *\n   *  @param locations a char* with semicolon separated file locations\n   */\n  void set_default_config_files(const char *locations) noexcept;\n\n  void bootstrap(const std::string &metadata_server_uri);\n\n  /*\n   * @brief returns id of the router.\n   *\n   * @throw bad_section\n   */\n  uint32_t get_router_id(mysql_harness::Config &config);\n\n  void init_keyring(mysql_harness::Config &config);\n\n  /**\n   * @brief Initializes keyring using master-key-reader and master-key-writer.\n   *\n   * @throw MasterKeyReadError\n   */\n  void init_keyring_using_external_facility(mysql_harness::Config &config);\n\n  /**\n   * @brief Initializes keyring using master key file.\n   *\n   * @throw std::runtime_error\n   */\n  void init_keyring_using_master_key_file();\n\n  /**\n   * @brief Initializes keyring using password read from STDIN.\n   *\n   * @throw std::runtime_error\n   */\n  void init_keyring_using_prompted_password();\n\n  void init_plugin_loggers(mysql_harness::LoaderConfig& config);\n\n  // throws std::runtime_error\n  void init_loader(mysql_harness::LoaderConfig& config);\n\n  // throws std::runtime_error\n  mysql_harness::LoaderConfig* make_config(const std::map<std::string, std::string> params, ConfigFiles config_files);\n\n  std::map<std::string, std::string> get_default_paths() const;\n\n  /** @brief Tuple describing the MySQL Router version, with major, minor and patch level **/\n  std::tuple<const uint8_t, const uint8_t, const uint8_t> version_;\n\n  // TODO move these to class ConfigFiles\n  /** @brief Vector with default configuration file locations as strings **/\n  std::vector<std::string> default_config_files_;\n  // TODO move these to class ConfigFiles\n  /** @brief Vector with extra configuration file locations as strings **/\n  std::vector<std::string> extra_config_files_;\n  /** @brief Vector with configuration files passed through command line arguments **/\n  // TODO move these to class ConfigFiles\n  std::vector<string> config_files_;\n  /** @brief PID file location **/\n  std::string pid_file_path_;\n\n  /** @brief CmdArgHandler object handling command line arguments **/\n  CmdArgHandler arg_handler_;\n  /** @brief Harness loader **/\n  std::unique_ptr<mysql_harness::Loader> loader_;\n  /** @brief Whether the MySQLRouter can start or not **/\n  bool can_start_;\n  /** @brief Whether we are showing information on command line, for example, using --help or --version **/\n  bool showing_info_;\n  /**\n   * @brief Value of the argument passed to the -B or --bootstrap\n   *        command line option for bootstrapping.\n   */\n  std::string bootstrap_uri_;\n  /**\n   * @brief Valueof the argument passed to the --directory command line option\n   */\n  std::string bootstrap_directory_;\n  /**\n   * @brief key/value map of additional configuration options for bootstrap\n   */\n  std::map<std::string, std::string> bootstrap_options_;\n\n  /**\n   * @brief key/list-of-values map of additional configuration options for bootstrap\n   */\n  std::map<std::string, std::vector<std::string>> bootstrap_multivalue_options_;\n\n  /**\n   * Path to origin of executable.\n   *\n   * This variable contain the directory that the executable is\n   * running from.\n   */\n  mysql_harness::Path origin_;\n\n  KeyringInfo keyring_info_;\n\n#ifndef _WIN32\n  /** @brief Value of the --user parameter given on the command line if router is launched in bootstrap mode **/\n  std::string user_cmd_line_;\n\n  /** @brief Value of the --user parameter given on the command line. It is used to buffer the value of --user\n   * parameter till all command line parameters are parsed. If router is launched in bootstrap mode, then\n   * username_ is copied to user_cmd_line_, otherwise it is copied to bootstrap_options_[\"user\"]\n   **/\n  std::string username_;\n\n  /** @brief Pointer to the object to be used to perform system specific user-related operations **/\n  mysqlrouter::SysUserOperationsBase* sys_user_operations_;\n#endif\n\n#ifdef FRIEND_TEST\n  FRIEND_TEST(Bug24909259, PasswordPrompt_plain);\n  FRIEND_TEST(Bug24909259, PasswordPrompt_keyed);\n  FRIEND_TEST(ConfigGeneratorTest, ssl_stage1_cmdline_arg_parse);\n  FRIEND_TEST(ConfigGeneratorTest, ssl_stage2_bootstrap_connection);\n  FRIEND_TEST(ConfigGeneratorTest, ssl_stage3_create_config);\n#endif\n};\n\nclass silent_exception : public std::exception\n{\npublic:\n  silent_exception() : std::exception() {}\n};\n\n#endif // ROUTER_MYSQL_ROUTER_INCLUDED\n"
  },
  {
    "path": "src/router/src/uri.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysqlrouter/uri.h\"\n#include \"mysqlrouter/utils.h\"\n#include \"utils.h\"\n\n\n#include <algorithm>\n#include <cctype>\n#include <climits>\n#include <iostream>\n#include <memory>\n#include <string>\n\nusing std::string;\n\n// RFC 3986\n//\n// recursive decent parser\n//\n// TODO(jan): add IPvFuture\n\nconst string kDigit = \"0123456789\";\nconst string kHexLower = \"abcdef\";\nconst string kHexUpper = \"ABCDEF\";\nconst string kAlphaLower = kHexLower + \"ghijklmnopqrstuvwxyz\";\nconst string kAlphaUpper = kHexUpper + \"GHIJKLMNOPQRSTUVWXYZ\";\nconst string kAlpha = kAlphaLower + kAlphaUpper;\nconst string kUnreserved = kAlpha  + kDigit + \"-\" + \".\" + \"_\" + \"~\";\nconst string kHexDigit = kDigit + kHexLower + kHexUpper;\nconst string kGenDelims = \":/?#[]@\";\nconst string kSubDelims = \"!$&'()*+,;=\";\nconst string kReserved = kGenDelims + kSubDelims;\nconst string kPathCharNoPctEncoded = kUnreserved + kSubDelims + \":\" + \"@\";\nconst string kFragmentOrQuery = \"/?\";\n\nnamespace mysqlrouter {\n\nURIError::URIError(const char *msg, const std::string &uri, size_t position) :\n    std::runtime_error(std::string(\"invalid URI: \") + msg + \" at position \" + std::to_string(position) + \" for: \" + uri) {}\n\n/*\n * match zero-or-more of group of characters\n *\n * @returns matched length\n */\nstatic size_t\nmatch_zero_or_more(const string &s, const string &pat, size_t pos_start = 0) {\n  size_t pos_matched = s.find_first_not_of(pat, pos_start);\n\n  if (pos_matched == string::npos) {\n    pos_matched = s.length();\n  }\n\n  return pos_matched - pos_start;\n}\n\nstatic size_t\nskip(size_t pos_start, size_t match_len) {\n  return pos_start + match_len;\n}\n\nstatic string\ncapture(const string &s, size_t pos_start, size_t match_len, size_t &pos_end) {\n  pos_end = skip(pos_start, match_len);\n\n  return s.substr(pos_start, match_len);\n}\n\nstatic bool\nis_eol(const string &s, size_t pos_start) {\n  return pos_start == s.length();\n}\n\n\nstatic bool\nmatch_pct_encoded(const string &s, size_t pos_start, size_t &pos_end, string &pct_enc) {\n  // pct-encoded = \"%\" HEXDIG HEXDIG\n  if (s.length() - pos_start < 3) {\n    return false;\n  }\n\n  if (s.at(pos_start) != '%' || 0 == isxdigit(s.at(pos_start + 1)) || 0 == isxdigit(s.at(pos_start + 2))) {\n    return false;\n  }\n\n  pct_enc = capture(s, pos_start, 3, pos_end);\n\n  return true;\n}\n\nstatic bool\nmatch_path_chars(const string &s, size_t pos_start, size_t &pos_end, string &path_chars) {\n  // pchar       = unreserved / pct-encoded / sub-delims / \":\" / \"@\"\n\n  bool made_progress;\n  string tmp;\n  size_t pos_matched = pos_start;\n\n  do {\n    made_progress = false;\n\n    size_t match_len = match_zero_or_more(s, kPathCharNoPctEncoded, pos_matched);\n\n    if (match_len > 0) {\n      made_progress = true;\n\n      tmp.append(capture(s, pos_matched, match_len, pos_matched));\n    }\n\n    string pct_enc;\n    if (match_pct_encoded(s, pos_matched, pos_matched, pct_enc)) {\n      tmp.append(pct_enc);\n\n      made_progress = true;\n    }\n  } while(made_progress);\n\n  path_chars = std::move(tmp);\n  pos_end = pos_matched;\n\n  return true;\n}\n\nstatic bool\nmatch_scheme(const string &s, size_t pos_start, size_t &pos_end, string &scheme) {\n  // scheme = ALPHA *( ALPHA / DIGIT / \"+\" / \"-\" / \".\" )\n  //\n  size_t match_len = match_zero_or_more(s, kAlpha, pos_start);\n\n  if (match_len == 0) {\n    // no ALPHA\n    return false;\n  }\n  match_len += match_zero_or_more(s, kAlpha + kDigit + \"+-.\", pos_start + match_len);\n\n  scheme = capture(s, pos_start, match_len, pos_end);\n\n  return true;\n}\n\nstatic bool\nmatch_colon(const string &s, size_t pos_start, size_t &pos_end) {\n  if (is_eol(s, pos_start)) {\n    return false;\n  }\n\n  if (s.at(pos_start) != ':') {\n    return false;\n  }\n  pos_end = skip(pos_start, 1);\n\n  return true;\n}\n\nstatic bool\nmatch_double_colon(const string &s, size_t pos_start, size_t &pos_end) {\n  if (s.length() - pos_start < 2) {\n    return false;\n  }\n\n  if (s.at(pos_start) != ':' || s.at(pos_start + 1) != ':' ) {\n    return false;\n  }\n  pos_end = skip(pos_start, 2);\n\n  return true;\n}\n\n\nstatic bool\nmatch_userinfo(const string &s, size_t pos_start, size_t &pos_end, string &user_info) {\n  // userinfo    = *( unreserved / pct-encoded / sub-delims / \":\" )\n\n  bool made_progress;\n  string tmp;\n  size_t pos_matched = pos_start;\n\n  do {\n    made_progress = false;\n\n    size_t match_len = match_zero_or_more(s, kUnreserved + kSubDelims + \":\", pos_matched);\n\n    if (match_len > 0) {\n      made_progress = true;\n\n      tmp.append(capture(s, pos_matched, match_len, pos_matched));\n    }\n\n    string pct_enc;\n    if (match_pct_encoded(s, pos_matched, pos_matched, pct_enc)) {\n      tmp.append(pct_enc);\n\n      made_progress = true;\n    }\n  } while(made_progress);\n\n  if (is_eol(s, pos_matched)) {\n    // EOL, but we have to match also the '@'\n    return false;\n  }\n\n  if (s.at(pos_matched) != '@') {\n    return false;\n  }\n\n  user_info = std::move(tmp);\n\n  // skip the @\n  pos_end = pos_matched + 1;\n\n  return true;\n}\n\nstatic void\nsplit_userinfo(const string &user_info, string &username, string &password) {\n  size_t pos = user_info.find(':');\n  if (pos != string::npos) {\n    username = user_info.substr(0, pos);\n    password = user_info.substr(pos + 1, user_info.size() - (pos + 1));\n  } else {\n    // No password\n    username = user_info;\n    password = \"\";\n  }\n}\n\nstatic bool\nmatch_port(const string &s, size_t pos_start, size_t &pos_end, string &port) {\n  /* port        = *DIGIT\n   */\n  size_t match_len = match_zero_or_more(s, kDigit, pos_start);\n\n  port = capture(s, pos_start, match_len, pos_end);\n\n  return true;\n}\n\nstatic bool\nmatch_reg_name(const string &s, size_t pos_start, size_t &pos_end, string &reg_name, bool with_pct_encoded) {\n  /* reg-name    = *( unreserved / pct-encoded / sub-delims )\n   */\n  bool made_progress;\n  size_t pos_matched = pos_start;\n\n  do {\n    made_progress = false;\n\n    size_t match_len = match_zero_or_more(s, kUnreserved + kSubDelims, pos_matched);\n\n    if (match_len > 0) {\n      reg_name.append(capture(s, pos_matched, match_len, pos_matched));\n      made_progress = true;\n    }\n\n    if (with_pct_encoded) {\n      string pct_enc;\n      if (match_pct_encoded(s, pos_matched, pos_matched, pct_enc)) {\n        reg_name.append(pct_enc);\n\n        made_progress = true;\n      }\n    } else if (pos_matched < s.length() && s.at(pos_matched) == '%') {\n      reg_name += '%';\n      made_progress = true;\n      pos_matched += 1;\n    }\n  } while (made_progress);\n\n  pos_end = pos_matched;\n\n  return true;\n}\n\nstatic bool\nmatch_dec_octet(const string &s, size_t pos_start, size_t &pos_end, string &dec_octet) {\n  size_t match_len = match_zero_or_more(s, kDigit, pos_start);\n\n  if (match_len == 0 || match_len > 3) {\n    // decimal octets are 0 - 255. We should be more strict here.\n    return false;\n  }\n\n  dec_octet = capture(s, pos_start, match_len, pos_end);\n\n  return true;\n}\n\nstatic bool\nmatch_ipv4(const string &s, size_t pos_start, size_t &pos_end, string &ipv4_addr) {\n  string dec_octet;\n  size_t pos_matched;\n\n  if (!match_dec_octet(s, pos_start, pos_matched, dec_octet)) {\n    return false;\n  }\n  for (size_t i = 0; i < 3; i++) {\n    if (pos_matched >= s.length()) {\n      return false;\n    }\n    if (s.at(pos_matched) != '.') {\n      return false;\n    }\n    pos_matched += 1;\n    if (!match_dec_octet(s, pos_matched, pos_matched, dec_octet)) {\n      return false;\n    }\n  }\n\n  ipv4_addr = capture(s, pos_start, pos_matched - pos_start, pos_end);\n\n  return true;\n}\n\nstatic bool\nmatch_ipv6_h16(const string &s, size_t pos_start, size_t &pos_end, string &h16) {\n  // 1*4HEXDIG\n  size_t match_len = match_zero_or_more(s, kHexDigit, pos_start);\n\n  if (match_len < 1) {\n    return false;\n  }\n\n  if (match_len > 4) {\n    match_len = 4;\n  }\n\n  h16 = capture(s, pos_start, match_len, pos_end);\n\n  return true;\n}\n\nstatic bool\nmatch_ipv6_ls32(const string &s, size_t pos_start, size_t &pos_end, string &ls32) {\n  // ( h16 \":\" h16 ) / IPv4address\n  //\n  size_t pos_matched;\n  string tmp;\n\n  if (!(match_ipv6_h16(s, pos_start, pos_matched, tmp) &&\n        match_colon(s, pos_matched, pos_matched) &&\n        match_ipv6_h16(s, pos_matched, pos_matched, tmp)) &&\n      !match_ipv4(s, pos_start, pos_matched, tmp)) {\n    return false;\n  }\n\n  ls32 = capture(s, pos_start, pos_matched - pos_start, pos_end);\n\n  return true;\n}\n\nstatic bool\nmatch_ipv6_h16_colon(const string &s, size_t pos_start, size_t &pos_end, string &h16_colon) {\n  // h16 \":\"\n  //\n  // ensure that we don't make h16 \"::\"\n  size_t pos_matched;\n  string tmp;\n\n  if (!match_ipv6_h16(s, pos_start, pos_matched, tmp)) {\n    return false;\n  }\n\n  if (match_double_colon(s, pos_matched, pos_matched)) {\n    return false;\n  }\n\n  if (!match_colon(s, pos_matched, pos_matched)) {\n    return false;\n  }\n\n  h16_colon = capture(s, pos_start, pos_matched - pos_start, pos_end);\n\n  return true;\n}\n\nstatic bool\nmatch_ipv6_1(const string &s, size_t pos_start, size_t &pos_end, string &ipv6_addr) {\n  // 1st line in the IPv6Address line in the RFC\n  size_t pos_matched = pos_start;\n  string tmp;\n  size_t sections;\n\n  for (sections = 0; sections < 6; sections++) {\n    if (!match_ipv6_h16_colon(s, pos_matched, pos_matched, tmp)) {\n      return false;\n    }\n  }\n\n  if (sections != 6) {\n    return false;\n  }\n\n  if (!match_ipv6_ls32(s, pos_matched, pos_matched, tmp)) {\n    return false;\n  }\n\n  ipv6_addr = capture(s, pos_start, pos_matched - pos_start, pos_end);\n\n  return true;\n}\n\nstatic bool\nmatch_ipv6_2(const string &s, size_t pos_start, size_t &pos_end, string &ipv6_addr) {\n  // 2nd line in the IPv6Address line in the RFC\n  size_t pos_matched = pos_start;\n  string tmp;\n  size_t sections;\n\n  if (!match_double_colon(s, pos_matched, pos_matched)) {\n    return false;\n  }\n\n  for (sections = 0; sections < 5; sections++) {\n    if (!match_ipv6_h16_colon(s, pos_matched, pos_matched, tmp)) {\n      return false;\n    }\n  }\n\n  if (sections != 5) {\n    return false;\n  }\n\n  if (!match_ipv6_ls32(s, pos_matched, pos_matched, tmp)) {\n    return false;\n  }\n\n  ipv6_addr = capture(s, pos_start, pos_matched - pos_start, pos_end);\n\n  return true;\n}\n\nstatic bool\nmatch_ipv6_h16_colon_prefix(const string &s, size_t pos_start,\n    size_t max_pre_double_colon,\n    size_t &pos_end, string &ipv6_addr) {\n  size_t pos_matched = pos_start;\n  string tmp;\n  size_t sections;\n\n  for (sections = 0; sections < max_pre_double_colon; sections++) {\n    if (!match_ipv6_h16_colon(s, pos_matched, pos_matched, tmp)) {\n      break;\n    }\n  }\n\n  if (!match_ipv6_h16(s, pos_matched, pos_matched, tmp)) {\n    return false;\n  }\n\n  ipv6_addr = capture(s, pos_start, pos_matched - pos_start, pos_end);\n\n  return true;\n}\n\nstatic bool\nmatch_ipv6_3(const string &s, size_t pos_start,\n    size_t max_pre_double_colon,\n    size_t &pos_end, string &ipv6_addr) {\n  // 3rd-7th line in the IPv6Address line in the RFC\n  size_t pos_matched = pos_start;\n  string tmp;\n  size_t sections;\n\n  size_t post_double_colon = 4 - max_pre_double_colon;\n\n  match_ipv6_h16_colon_prefix(s, pos_matched, max_pre_double_colon, pos_matched, tmp);\n\n  if (!match_double_colon(s, pos_matched, pos_matched)) {\n    return false;\n  }\n\n  for (sections = 0; sections < post_double_colon; sections++) {\n    if (!match_ipv6_h16_colon(s, pos_matched, pos_matched, tmp)) {\n      return false;\n    }\n  }\n\n  if (sections != post_double_colon) {\n    return false;\n  }\n\n  if (!match_ipv6_ls32(s, pos_matched, pos_matched, tmp)) {\n    return false;\n  }\n\n  ipv6_addr = capture(s, pos_start, pos_matched - pos_start, pos_end);\n\n  return true;\n}\n\nstatic bool\nmatch_ipv6_8(const string &s, size_t pos_start,\n    size_t max_pre_double_colon,\n    size_t &pos_end, string &ipv6_addr) {\n  // 8th-9th line in the IPv6Address line in the RFC\n  size_t pos_matched = pos_start;\n  string tmp;\n\n  match_ipv6_h16_colon_prefix(s, pos_matched, max_pre_double_colon, pos_matched, tmp);\n\n  if (!match_double_colon(s, pos_matched, pos_matched)) {\n    return false;\n  }\n\n  if (max_pre_double_colon == 5) {\n    if (!match_ipv6_h16(s, pos_matched, pos_matched, tmp)) {\n      return false;\n    }\n  }\n\n  ipv6_addr = capture(s, pos_start, pos_matched - pos_start, pos_end);\n\n  return true;\n}\n\n\nstatic bool\nmatch_ipv6_zoneid(const string &s, size_t pos_start, size_t &pos_end, string &zoneid, bool with_pct_encoded) {\n  // zoneid       = unreserved / pct-encoded\n\n  bool made_progress;\n  string tmp;\n  size_t pos_matched = pos_start;\n\n  do {\n    made_progress = false;\n\n    size_t match_len = match_zero_or_more(s, kUnreserved, pos_matched);\n\n    if (match_len > 0) {\n      made_progress = true;\n\n      tmp.append(capture(s, pos_matched, match_len, pos_matched));\n    }\n\n    if (with_pct_encoded) {\n      string pct_enc;\n      if (match_pct_encoded(s, pos_matched, pos_matched, pct_enc)) {\n        tmp.append(pct_enc);\n\n        made_progress = true;\n      }\n    } else if (s.at(pos_matched) == '%') {\n        tmp += '%';\n\n        made_progress = true;\n        pos_matched += 1;\n    }\n  } while(made_progress);\n\n  if (tmp.length() == 0) {\n    return false;\n  }\n\n  zoneid = std::move(tmp);\n  pos_end = pos_matched;\n\n  return true;\n}\n\nstatic bool\nmatch_ipv6(const string &s, size_t pos_start, size_t &pos_end, string &ipv6_addr) {\n  // we can have max 8 sections.\n  // sections of all zeros may be compressed with :: once\n  // the last two sections may be IPv4 notation\n  // each section is separated with a :\n  //\n  //\n  return match_ipv6_1(s, pos_start, pos_end, ipv6_addr) ||\n      match_ipv6_2(s, pos_start, pos_end, ipv6_addr) ||\n      match_ipv6_3(s, pos_start, 0, pos_end, ipv6_addr) ||\n      match_ipv6_3(s, pos_start, 1, pos_end, ipv6_addr) ||\n      match_ipv6_3(s, pos_start, 2, pos_end, ipv6_addr) ||\n      match_ipv6_3(s, pos_start, 3, pos_end, ipv6_addr) ||\n      match_ipv6_3(s, pos_start, 4, pos_end, ipv6_addr) ||\n      match_ipv6_8(s, pos_start, 5, pos_end, ipv6_addr) ||\n      match_ipv6_8(s, pos_start, 6, pos_end, ipv6_addr);\n}\n\nstatic bool\nmatch_ip_literal(const string &s, size_t pos_start, size_t &pos_end, string &ip_literal, bool with_pct_encoded) {\n  // IP-literal = \"[\" ( IPv6address / IPv6addrz / IPvFuture ) \"]\"\n  //\n  // RFC 4291\n  //\n  // * :: allowed once per address\n  // * replaces a series of zeros\n  // * ::1 -> 0:0:0:0:0:0:0:1\n  if (is_eol(s, pos_start)) {\n    return false;\n  }\n  if (s.at(pos_start) != '[') {\n    return false;\n  }\n\n  pos_start += 1;\n\n  string tmp;\n  size_t pos_matched;\n\n  if (!match_ipv6(s, pos_start, pos_matched, tmp)) {\n    throw URIError(\"expected to find IPv6 address, but failed\", s, pos_start);\n  }\n\n  if (with_pct_encoded) {\n    if (match_pct_encoded(s, pos_matched, pos_matched, tmp)) {\n      if (tmp.compare(\"%25\") == 0) {\n        if (!match_ipv6_zoneid(s, pos_matched, pos_matched, tmp, with_pct_encoded)) {\n          throw URIError(\"invalid zoneid\", s, pos_matched);\n        }\n      } else {\n        throw URIError(\"invalid pct-encoded value, expected %25\", s, pos_matched - 2);\n      }\n    }\n  } else if (s.at(pos_matched) == '%') {\n    pos_matched += 1;\n  }\n\n  if (is_eol(s, pos_matched) || s.at(pos_matched) != ']') {\n    throw URIError(\"expected to find a ']'\", s, pos_matched);\n  }\n\n  ip_literal = capture(s, pos_start, pos_matched - pos_start, pos_end);\n  pos_end += 1;\n\n  return true;\n}\n\nstatic bool\nmatch_host(const string &s, size_t pos_start, size_t &pos_end, string &host, bool with_pct_encoded) {\n  // host        = IP-literal / IPv4address / reg-name\n  //\n  // match_reg_name has to be last as it accepts the 'empty host'\n\n  return match_ipv4(s, pos_start, pos_end, host) ||\n      match_ip_literal(s, pos_start, pos_end, host, with_pct_encoded) ||\n      match_reg_name(s, pos_start, pos_end, host, with_pct_encoded);\n}\n\nstatic bool\nmatch_authority(const string &s, size_t pos_start, size_t &pos_end,\n    string &tmp_host, string &tmp_port, string &tmp_username, string &tmp_password) {\n   /* RFC 2234 defines:\n   *\n   * - HEXDIG\n   *\n   * reserved = gen-delims / sub-delims\n   * gen-delims = \":\" / \"/\" / \"?\" / \"#\" / \"[\" / \"]\" / \"@\"\n   * sub-delims = \"!\" / \"$\" / \"&\" / \"'\" / \"(\" / \")\" / \"*\" / \"+\" / \",\" / \";\" / \"=\"\n   *\n   * unreserved = ALPHA / DIGIT / \"-\" / \".\" / \"_\" / \"~\"\n   *\n   * URI = scheme \":\" hier-part [ \"?\" query ] [ \"#\" fragment ]\n   * hier-part = \"//\" authority path-abempty\n   *     / path-absolute\n   *     / path-rootless\n   *     / path-empty\n   *\n   * authority = [ userinfo \"@\" ] host [ \":\" port ]\n   *\n   * ZoneID = 1* (reserved / pct-encoded)\n   * IPv6addrz = IPv6address \"%25\" ZoneID\n   * IPvFuture  = \"v\" 1*HEXDIG \".\" 1*( unreserved / sub-delims / \":\" )\n   * IPv4address = dec-octet \".\" dec-octet \".\" dec-octet \".\" dec-octet\n   * reg-name    = *( unreserved / pct-encoded / sub-delims )\n   *\n   * extension:\n   * userinfo = username [ \":\" password ]\n   * username = *( unreserved / pct-encoded / sub-delims )\n   * password = *( unreserved / pct-encoded / sub-delims / \":\" )\n   *\n   */\n\n  // if there is a \"//\" we have a authority\n  if (s.length() - pos_start < 2) {\n    return false;\n  }\n\n  if (s.compare(pos_start, 2, \"//\") != 0) {\n    return false;\n  }\n\n  size_t pos_matched = pos_start + 2;\n  string user_info;\n\n  if (match_userinfo(s, pos_matched, pos_matched, user_info)) {\n    split_userinfo(user_info, tmp_username, tmp_password);\n  }\n\n  if (!match_host(s, pos_matched, pos_matched, tmp_host, true)) {\n    throw URIError(\"expected host :(\", s, pos_matched);\n  }\n\n  // EOL, : or /\n  if (pos_matched < s.length() && s.at(pos_matched) == ':') {\n    pos_matched += 1;\n\n    match_port(s, pos_matched, pos_matched, tmp_port);\n  }\n\n  pos_end = pos_matched;\n  return true;\n}\n\nstatic bool\nmatch_path_segment(const string &s, size_t pos_start, size_t &pos_end, string &segment) {\n  return match_path_chars(s, pos_start, pos_end, segment);\n}\n\nstatic bool\nmatch_path_empty(const string &s, size_t pos_start, size_t &pos_end, string &path) {\n  string segment;\n\n  if (!match_path_chars(s, pos_start, pos_end, segment)) {\n    path = \"\";\n    return true;\n  }\n\n  if (segment.length() == 0) {\n    path = \"\";\n    return true;\n  }\n\n  return false;\n}\n\nstatic bool\nmatch_path_absolute(const string &s, size_t pos_start, size_t &pos_end, string &path) {\n  // we rely on match_path_absolute being called after match_authority.\n  // it allows us to simplify:\n  //\n  //   path-absolute = \"/\" [ segment-nz *( \"/\" segment ) ]\n  //\n  // to\n  //\n  //   path-absolute = \"/\" [ segment *( \"/\" segment ) ]\n  //\n  // and use this matcher for both the 'ab'-part of 'path-abempty'\n  // and the 'path-absolute' case.\n  if (is_eol(s, pos_start)) {\n    return false;\n  }\n\n  if (s.at(pos_start) != '/') {\n    return false;\n  }\n\n  size_t pos_matched = pos_start + 1;\n\n  string tmp;\n  do {\n    string segment;\n\n    if (match_path_segment(s, pos_matched, pos_matched, segment)) {\n      tmp.append(segment);\n    }\n\n    if (is_eol(s, pos_matched)) {\n      break;\n    }\n\n    if (s.at(pos_matched) != '/') {\n      break;\n    }\n\n    tmp.append(capture(s, pos_matched, 1, pos_matched));\n  } while (true);\n\n  path = std::move(tmp);\n  pos_end = pos_matched;\n\n  return true;\n}\n\nstatic bool\nmatch_path_absolute_or_empty(const string &s, size_t pos_start, size_t &pos_end, string &path) {\n  return match_path_absolute(s, pos_start, pos_end, path) || match_path_empty(s, pos_start, pos_end, path);\n}\n\nstatic bool\nmatch_path_rootless(const string &s, size_t pos_start, size_t &pos_end, string &path) {\n  // path-rootless = segment-nz *( \"/\" segment )\n  if (is_eol(s, pos_start)) {\n    return false;\n  }\n\n  string tmp;\n  size_t pos_matched;\n\n  if (!match_path_segment(s, pos_start, pos_matched, tmp)) {\n    return false;\n  }\n\n  if (tmp.length() == 0) {\n    // we need at least one path-char\n    return false;\n  }\n\n  while (!is_eol(s, pos_matched) && s.at(pos_matched) == '/') {\n    string segment;\n\n    tmp.append(capture(s, pos_matched, 1, pos_matched));\n\n    if (match_path_segment(s, pos_matched, pos_matched, segment)) {\n      tmp.append(segment);\n    }\n  }\n\n  path = std::move(tmp);\n  pos_end = pos_matched;\n\n  return true;\n}\n\nstatic bool\nmatch_fragment_query_chars(const string &s, size_t pos_start, size_t &pos_end, string &chars) {\n  // fragment and query matcher both share the same allowed chars after the initial char\n  //\n  // *( pchar / \"/\" / \"?\" )\n  string tmp;\n  size_t pos_matched = pos_start;\n  bool made_progress;\n\n  do {\n    string segment;\n\n    made_progress = false;\n\n    if (match_path_chars(s, pos_matched, pos_matched, segment) && segment.length() > 0) {\n      tmp.append(segment);\n      made_progress = true;\n    }\n\n    size_t match_len = match_zero_or_more(s, kFragmentOrQuery, pos_matched);\n\n    if (match_len > 0) {\n      tmp.append(capture(s, pos_matched, match_len, pos_matched));\n      made_progress = true;\n    }\n  } while(made_progress);\n\n  chars = std::move(tmp);\n  pos_end = pos_matched;\n\n  return true;\n}\n\n\nstatic bool\nmatch_fragment(const string &s, size_t pos_start, size_t &pos_end, string &fragment) {\n  //\n  // fragment    = *( pchar / \"/\" / \"?\" )\n  //\n  if (is_eol(s, pos_start)) {\n    return false;\n  }\n\n  if (s.at(pos_start) != '#') {\n    return false;\n  }\n\n  pos_start += 1;\n\n  return match_fragment_query_chars(s, pos_start, pos_end, fragment);\n}\n\n\nstatic bool\nmatch_query(const string &s, size_t pos_start, size_t &pos_end, string &query) {\n  if (is_eol(s, pos_start)) {\n    // already at EOL, we need to match at least ?\n    return false;\n  }\n\n  if (s.at(pos_start) != '?') {\n    return false;\n  }\n\n  pos_start += 1;\n\n  return match_fragment_query_chars(s, pos_start, pos_end, query);\n}\n\n// decode a string with pct-encoding\nstatic string\npct_decode(const string &s) {\n  size_t s_len = s.length();\n  string decoded;\n\n  // only alloc once. We may alloc too much.\n  decoded.reserve(s_len);\n\n  for (size_t ndx = 0; ndx < s_len; ndx++) {\n    if (s.at(ndx) == '%' && s_len - ndx > 2 && 0 != isxdigit(s.at(ndx + 1)) && 0 != isxdigit(s.at(ndx + 2))) {\n      decoded.append(1, static_cast<char>(std::stol(s.substr(ndx + 1, 2), nullptr, 16)));\n      ndx += 2;\n    } else {\n      decoded.append(1, s.at(ndx));\n    }\n  }\n  return decoded;\n}\n\nstatic URIQuery\nsplit_query(const string &s) {\n  URIQuery query;\n\n  for (auto& part: split_string(s, '&', false)) {\n    auto key_value = split_string(part, '=');\n    if (key_value.size() < 2) {\n      throw URIError(\"invalid URI: query-string part doesn't contain '='\");\n    }\n    if (!key_value[0].empty()) {\n      query[pct_decode(key_value[0])] = pct_decode(key_value[1]);\n    }\n  }\n\n  return query;\n}\n\n/**\n * if uri ~= host:port, URI(scheme=\"mysql\", host=host, port=port)  [no-pct-enc]\n * elif uri ~= ^/, URI(schema=\"mysql\", query={\"socket\": uri })     [no-pct-enc]\n * elif uri ~= ^\\\\, URI(schema=\"mysql\", query={\"socket\": uri })    [no-pct-enc]\n * else URI(uri)                                                   [pct-enc]\n */\nURI URIParser::parse_shorthand_uri(const std::string &uri, bool allow_path_rootless, const std::string &default_scheme) {\n  size_t pos_matched = 0;\n  std::string host;\n  std::string port;\n\n  if (uri.length() > 0 && (uri.at(0) == '/' || uri.at(0) == '\\\\')) {\n    URI u;\n    URIQuery query;\n\n    query[\"socket\"] = uri;\n    u.scheme = default_scheme;\n    u.query = query;\n\n    return u;\n  } else if (match_host(uri, 0, pos_matched, host, false)) {\n    // EOL, : or /\n    if (pos_matched < uri.length() && uri.at(pos_matched) == ':') {\n      pos_matched += 1;\n\n      match_port(uri, pos_matched, pos_matched, port);\n    }\n\n    if (pos_matched == uri.size()) {\n      uint64_t parsed_port = 0;\n      if (port.length() > 0) {\n        try {\n          parsed_port = std::stoul(port);\n        } catch (const std::out_of_range &) {\n          throw URIError(\"invalid URI: invalid port: impossible port number for: \" + uri);\n        }\n\n        if (parsed_port > USHRT_MAX) {\n          // the URI class only has 'uint16' for the port, even though\n          // the RFC allows arbit' large numbers.\n          throw URIError(\"invalid URI: invalid port: impossible port number for: \" + uri);\n        }\n      }\n\n      URI u;\n      URIQuery query;\n\n      query[\"socket\"] = uri;\n      u.scheme = default_scheme;\n      u.host = host;\n      u.port = static_cast<uint16_t>(parsed_port);\n\n      return u;\n    }\n  }\n\n  return URIParser::parse(uri, allow_path_rootless);\n}\n\n\nURI\nURIParser::parse(const string &uri, bool allow_path_rootless) {\n  size_t pos = 0;\n\n  // stage: match and extract fields\n  //\n  string tmp_scheme;\n  if (!match_scheme(uri, pos, pos, tmp_scheme)) {\n    throw URIError(\"no scheme\", uri, pos);\n  }\n\n  if (!match_colon(uri, pos, pos)) {\n    throw URIError(\"expected colon after scheme\", uri, pos);\n  }\n\n  string tmp_path;\n  string tmp_host;\n  string tmp_username;\n  string tmp_password;\n  string tmp_port;\n\n  if (match_authority(uri, pos, pos, tmp_host, tmp_port, tmp_username, tmp_password)) {\n    match_path_absolute_or_empty(uri, pos, pos, tmp_path);\n  } else if (match_path_absolute(uri, pos, pos, tmp_path)) {\n  } else if (allow_path_rootless && match_path_rootless(uri, pos, pos, tmp_path)) {\n  } else if (match_path_empty(uri, pos, pos, tmp_path)) {\n  } else {\n    throw URIError(\"neither authority nor path\", uri, pos);\n  }\n\n  string tmp_query;\n  match_query(uri, pos, pos, tmp_query);\n\n  string tmp_fragment;\n  match_fragment(uri, pos, pos, tmp_fragment);\n\n  // did we match the whole string?\n  if (pos != uri.length()) {\n    throw URIError(\"unexpected characters\", uri, pos);\n  }\n\n  // stage: URI is valid, check values\n  //\n  // post-process the values\n  //\n  // * split\n  //\n  //   * user-info\n  //   * paths\n  //   * query-stringa\n  //\n  // * decode the pct-encoding\n  // * convert strings to numbers\n  // * lowercase scheme\n\n  std::transform(tmp_scheme.begin(), tmp_scheme.end(), tmp_scheme.begin(), ::tolower);\n\n  uint64_t parsed_port = 0;\n  if (tmp_port.length() > 0) {\n    try {\n      parsed_port = std::stoul(tmp_port);\n    } catch (const std::out_of_range &) {\n      throw URIError(\"invalid URI: invalid port: impossible port number for: \" + uri);\n    }\n\n    if (parsed_port > USHRT_MAX) {\n      // the URI class only has 'uint16' for the port, even though\n      // the RFC allows arbit' large numbers.\n      throw URIError(\"invalid URI: invalid port: impossible port number for: \" + uri);\n    }\n  }\n\n  URI u;\n\n  u.scheme = tmp_scheme;\n  u.host = pct_decode(tmp_host);\n  u.port = static_cast<uint16_t>(parsed_port);\n  u.username = pct_decode(tmp_username);\n  u.password = pct_decode(tmp_password);\n  u.path = split_string(tmp_path, '/', false);\n  std::transform(u.path.begin(), u.path.end(), u.path.begin(), pct_decode);\n  u.query = split_query(tmp_query);\n  u.fragment = pct_decode(tmp_fragment);\n\n  return u;\n}\n\nstatic bool\nis_ipv6(const string &s) {\n  string ipv6_addr;\n  size_t pos_end;\n\n  if (!match_ipv6(s, 0, pos_end, ipv6_addr)) {\n    return false;\n  }\n\n  if (pos_end == s.length()) {\n    return true;\n  }\n\n  if (s.at(pos_end) == '%') {\n    // has a zoneid\n    return true;\n  }\n\n  return false;\n}\n\nstatic string\npct_encode(const string &s, const string &allowed_chars) {\n  string encoded;\n  const char hexchars[] = \"0123456789abcdef\";\n\n  // assume the common case that nothing has to be encoded.\n  encoded.reserve(s.length());\n\n  for (auto &c: s) {\n    if (allowed_chars.find(c) == string::npos) {\n      // not a allowed char, encode\n      encoded += '%';\n      encoded += hexchars[(c >> 4) & 0xf];\n      encoded += hexchars[c & 0xf];\n    } else {\n      encoded += c;\n    }\n  }\n  return encoded;\n}\n\nstd::ostream& operator<<(std::ostream &strm, const URI &uri) {\n  bool need_slash = false;\n\n  strm << uri.scheme << \":\";\n  if (uri.username.length() > 0 || uri.host.length() > 0 || uri.port > 0 || uri.password.length() > 0) {\n    // we have a authority\n    strm << \"//\";\n\n    if (uri.username.length() > 0) {\n      strm << pct_encode(uri.username, kUnreserved + kSubDelims);\n    }\n\n    if (uri.password.length() > 0) {\n      strm << \":\" << pct_encode(uri.password, kUnreserved + kSubDelims + \":\");\n    }\n\n    if (uri.username.length() > 0 || uri.password.length() > 0) {\n      strm << \"@\";\n    }\n\n    // IPv6, wrap in []\n    if (is_ipv6(uri.host)) {\n      strm << \"[\" << pct_encode(uri.host, kUnreserved + \":\") << \"]\";\n    } else {\n      strm << pct_encode(uri.host, kUnreserved + kSubDelims);\n    }\n\n    if (uri.port) {\n      strm << \":\" << uri.port;\n    }\n\n    need_slash = true;\n  }\n\n  for (auto &segment : uri.path) {\n    if (need_slash) {\n      strm << \"/\";\n    }\n    strm << pct_encode(segment, kPathCharNoPctEncoded);\n\n    need_slash = true;\n  }\n  if (uri.query.size() > 0) {\n    bool need_amp = false;\n\n    strm << \"?\";\n    for (auto &k_v : uri.query) {\n      if (need_amp) {\n        strm << \"&\";\n      }\n      strm << pct_encode(k_v.first, kUnreserved) << \"=\" << pct_encode(k_v.second, kUnreserved);\n      need_amp = true;\n    }\n  }\n  if (uri.fragment.size() > 0) {\n    strm << \"#\" << pct_encode(uri.fragment, kPathCharNoPctEncoded + \"/?\");\n  }\n  return strm;\n}\n\nstd::string\nURI::str() const {\n  std::stringstream ss;\n\n  ss << *this;\n\n  return ss.str();\n}\n\nvoid URI::init_from_uri(const string &uri) {\n  if (uri.empty()) {\n    return;\n  }\n\n  *this = URIParser::parse(uri, allow_path_rootless_);\n}\n\nbool\nURI::operator==(const URI &u2) const {\n  return host == u2.host &&\n    port == u2.port &&\n    scheme == u2.scheme &&\n    username == u2.username &&\n    password == u2.password &&\n    path == u2.path &&\n    query == u2.query &&\n    fragment == u2.fragment;\n}\n\nbool\nURI::operator!=(const URI &u2) const {\n  return !(*this==u2);\n}\n} // namespace mysqlrouter\n"
  },
  {
    "path": "src/router/src/utils.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysqlrouter/utils.h\"\n#include \"mysql/harness/filesystem.h\"\n#include \"common.h\"\n\n#include <algorithm>\n#include <cassert>\n#include <cstdarg>\n#include <cstdlib>\n#include <iomanip>\n#include <iostream>\n#include <fstream>\n#include <cctype>\n#include <climits>\n#include <stdexcept>\n#include <functional>\n#include <string.h>\n\n#ifndef _WIN32\n#include <fcntl.h>\n#include <grp.h>\n#include <sys/stat.h>\n#include <sys/types.h>\n#include <sys/un.h>\n#include <termios.h>\n#include <unistd.h>\n#else\n#include <windows.h>\n#include <direct.h>\n#include <io.h>\n#include <stdio.h>\nnamespace {\n  extern \"C\" bool g_windows_service;\n}\n#endif\n\nusing std::string;\n\nconst string kValidIPv6Chars = \"abcdefgABCDEFG0123456789:\";\nconst string kValidPortChars = \"0123456789\";\n\nnamespace mysqlrouter {\n\n#ifndef _WIN32\nconst perm_mode kStrictDirectoryPerm = S_IRWXU;\n#else\nconst perm_mode kStrictDirectoryPerm = 0;\n#endif\n\nvoid MockOfstream::open(const char* filename, ios_base::openmode mode /*= ios_base::out*/) {\n\n  // deal properly with A, B, C, B scenario\n  // (without this, last B would create a 4th file which would not be tracked by map)\n  if (filenames_.count(filename)) {\n    erase_file(filenames_.at(filename));\n    filenames_.erase(filename);\n  }\n\n  std::string fake_filename = gen_fake_filename(filenames_.size());\n  filenames_.emplace(filename, fake_filename);\n\n  std::ofstream::open(fake_filename, mode);\n}\n\n/*static*/ std::map<std::string, std::string> MockOfstream::filenames_;\n\n/*static*/ void MockOfstream::erase_file(const std::string& filename) {\n  remove(filename.c_str());\n}\n\n/*static*/ std::string MockOfstream::gen_fake_filename(unsigned long i) {\n#ifndef _WIN32\n  return std::string(\"/tmp/mysqlrouter_mockfile\") + std::to_string(i);\n#else\n  return std::string(\"C:\\\\temp\\\\mysqlrouter_mockfile\") + std::to_string(i);\n#endif\n}\n\nstd::vector<string> wrap_string(const string &to_wrap, size_t width, size_t indent_size) {\n  size_t curr_pos = 0;\n  size_t wrap_pos = 0;\n  size_t prev_pos = 0;\n  string work{to_wrap};\n  std::vector<string> res{};\n  auto indent = string(indent_size, ' ');\n  auto real_width = width - indent_size;\n\n  size_t str_size = work.size();\n  if (str_size < real_width) {\n    res.push_back(indent + work);\n  } else {\n    work.erase(std::remove(work.begin(), work.end(), '\\r'), work.end());\n    std::replace(work.begin(), work.end(), '\\t', ' '), work.end();\n    str_size = work.size();\n\n    do {\n      curr_pos = prev_pos + real_width;\n\n      // respect forcing newline\n      wrap_pos = work.find(\"\\n\", prev_pos);\n      if (wrap_pos == string::npos || wrap_pos > curr_pos) {\n        // No new line found till real_width\n        wrap_pos = work.find_last_of(\" \", curr_pos);\n      }\n      if (wrap_pos != string::npos) {\n        res.push_back(indent + work.substr(prev_pos, wrap_pos - prev_pos));\n        prev_pos = wrap_pos + 1;  // + 1 to skip space\n      } else {\n        break;\n      }\n    } while (str_size - prev_pos > real_width || work.find(\"\\n\", prev_pos) != string::npos);\n    res.push_back(indent + work.substr(prev_pos));\n  }\n\n  return res;\n}\n\nbool my_check_access(const std::string& path) {\n#ifndef _WIN32\n  return (access(path.c_str(), R_OK | X_OK) == 0);\n#else\n  return (_access(path.c_str(), 0x04) == 0);\n#endif\n}\n\nvoid copy_file(const std::string &from, const std::string &to) {\n  std::ofstream ofile;\n  std::ifstream ifile;\n\n  ofile.open(to, std::ofstream::out | std::ofstream::binary | std::ofstream::trunc);\n  if (ofile.fail()) {\n    throw std::runtime_error(\"Could not create file '\" + to + \"': \" +\n                             mysql_harness::get_strerror(errno));\n  }\n  ifile.open(from, std::ofstream::in | std::ofstream::binary);\n  if (ifile.fail()) {\n    throw std::runtime_error(\"Could not open file '\" + from + \"': \" +\n                             mysql_harness::get_strerror(errno));\n  }\n\n  ofile << ifile.rdbuf();\n\n  ofile.close();\n  ifile.close();\n}\n\nint rename_file(const std::string &from, const std::string &to)\n{\n#ifndef _WIN32\n  return rename(from.c_str(), to.c_str());\n#else\n  // In Windows, rename fails if the file destination alreayd exists, so ...\n  if (MoveFileExA(from.c_str(), to.c_str(),\n    MOVEFILE_REPLACE_EXISTING |  // override existing file\n    MOVEFILE_COPY_ALLOWED |      // allow copy of file to different drive\n    MOVEFILE_WRITE_THROUGH       // don't return until the operation is physically finished\n  ))\n    return 0;\n  else\n    return -1;\n#endif\n}\n\nint mkdir(const std::string& dir, perm_mode mode) {\n#ifndef _WIN32\n  return ::mkdir(dir.c_str(), mode);\n#else\n  return _mkdir(dir.c_str());\n#endif\n}\n\nbool substitute_envvar(std::string &line) noexcept {\n  size_t pos_start;\n  size_t pos_end;\n\n  pos_start = line.find(\"ENV{\");\n  if (pos_start == string::npos) {\n    return true;  // no environment variable placeholder found -> this is not an error, just a no-op\n  }\n\n  pos_end = line.find(\"}\", pos_start + 4);\n  if (pos_end == string::npos) {\n    return false; // environment placeholder not closed (missing '}')\n  }\n\n  string env_var = line.substr(pos_start + 4, pos_end - pos_start - 4);\n  if (env_var.empty()) {\n    return false; // no environment variable name found in placeholder\n  }\n\n  const char* env_var_value = std::getenv(env_var.c_str());\n  if (env_var_value == nullptr) {\n    return false; // unknown environment variable\n  }\n\n  // substitute the variable and return success\n  line.replace(pos_start, env_var.size() + 5, env_var_value);\n  return true;\n}\n\nstd::string substitute_variable(const std::string &s,\n                                const std::string &name,\n                                const std::string &value) {\n  std::string r(s);\n  std::string::size_type p;\n  while ((p = r.find(name)) != std::string::npos) {\n    std::string tmp(r.substr(0, p));\n    tmp.append(value);\n    tmp.append(r.substr(p+name.size()));\n    r = tmp;\n  }\n  mysqlrouter::substitute_envvar(r);\n  mysql_harness::Path path(r);\n  if (path.exists())\n    return path.real_path().str();\n  else\n    return r;\n}\n\nstring string_format(const char *format, ...) {\n\n  va_list args;\n  va_start(args, format);\n  va_list args_next;\n  va_copy(args_next, args);\n\n  int size = std::vsnprintf(nullptr, 0, format, args);\n  std::vector<char> buf(static_cast<size_t>(size) + 1U);\n  va_end(args);\n\n  std::vsnprintf(buf.data(), buf.size(), format, args_next);\n  va_end(args_next);\n\n  return string(buf.begin(), buf.end() - 1);\n}\n\nstd::string ms_to_seconds_string(const std::chrono::milliseconds &msec) {\n  std::ostringstream os;\n  os.imbue(std::locale(\"C\"));\n  std::chrono::duration<double> seconds = msec;\n  os << seconds.count();\n  return os.str();\n}\n\nstd::pair<string, uint16_t> split_addr_port(string data) {\n  size_t pos;\n  string addr;\n  uint16_t port = 0;\n  trim(data);\n\n  if (data.at(0) == '[') {\n    // IPv6 with port\n    pos = data.find(']');\n    if (pos == string::npos) {\n      throw std::runtime_error(\"invalid IPv6 address: missing closing square bracket\");\n    }\n    addr.assign(data, 1, pos - 1);\n    if (addr.find_first_not_of(kValidIPv6Chars) != string::npos) {\n      throw std::runtime_error(\"invalid IPv6 address: illegal character(s)\");\n    }\n    pos = data.find(\":\", pos);\n    if (pos != string::npos) {\n      try {\n        port = get_tcp_port(data.substr(pos + 1));\n      } catch (const std::runtime_error &exc) {\n        throw std::runtime_error(\"invalid TCP port: \" + string(exc.what()));\n      }\n    }\n  } else if (std::count(data.begin(), data.end(), ':') > 1) {\n    // IPv6 without port\n    pos = data.find(']');\n    if (pos != string::npos) {\n      throw std::runtime_error(\"invalid IPv6 address: missing opening square bracket\");\n    }\n    if (data.find_first_not_of(kValidIPv6Chars) != string::npos) {\n      throw std::runtime_error(\"invalid IPv6 address: illegal character(s)\");\n    }\n    addr.assign(data);\n  } else {\n    // IPv4 or address\n    pos = data.find(\":\");\n    addr = data.substr(0, pos);\n    if (pos != string::npos) {\n      try {\n        port = get_tcp_port(data.substr(pos + 1));\n      } catch (const std::runtime_error &exc) {\n        throw std::runtime_error(\"invalid TCP port: \" + string(exc.what()));\n      }\n    }\n  }\n\n  return std::make_pair(addr, port);\n}\n\nuint16_t get_tcp_port(const string &data) {\n  int port;\n\n  // We refuse data which is bigger than 5 characters\n  if (data.find_first_not_of(kValidPortChars) != string::npos || data.size() > 5) {\n    throw std::runtime_error(\"invalid characters or too long\");\n  }\n\n  try {\n    port = data.empty() ? 0 : static_cast<int>(std::strtol(data.c_str(), nullptr, 10));\n  } catch (const std::invalid_argument &exc) {\n    throw std::runtime_error(\"convertion to integer failed\");\n  } catch (const std::out_of_range &exc) {\n    throw std::runtime_error(\"impossible port number (out-of-range)\");\n  }\n\n  if (port > UINT16_MAX) {\n    throw std::runtime_error(\"impossible port number\");\n  }\n  return static_cast<uint16_t>(port);\n}\n\nstd::vector<string> split_string(const string& data, const char delimiter, bool allow_empty) {\n  std::stringstream ss(data);\n  std::string token;\n  std::vector<string> result;\n\n  if (data.empty()) {\n    return {};\n  }\n\n  while (std::getline(ss, token, delimiter)) {\n    if (token.empty() && !allow_empty) {\n      // Skip empty\n      continue;\n    }\n    result.push_back(token);\n  }\n\n  // When last character is delimiter, it denotes an empty token\n  if (allow_empty && data.back() == delimiter) {\n    result.push_back(\"\");\n  }\n\n  return result;\n}\n\nvoid left_trim(string& str) {\n  str.erase(str.begin(), std::find_if_not(str.begin(), str.end(), ::isspace));\n}\n\nvoid right_trim(string& str) {\n  str.erase(std::find_if_not(str.rbegin(), str.rend(), ::isspace).base(), str.end());\n}\n\nvoid trim(string& str) {\n  left_trim(str);\n  right_trim(str);\n}\n\nstring hexdump(const unsigned char *buffer, size_t count, long start, bool literals) {\n  std::ostringstream os;\n\n  using std::setfill;\n  using std::setw;\n  using std::hex;\n\n  int w = 16;\n  buffer += start;\n  size_t n = 0;\n  for (const unsigned char *ptr = buffer; n < count; ++n, ++ptr ) {\n    if (literals && ((*ptr >= 0x41 && *ptr <= 0x5a) || (*ptr >= 61 && *ptr <= 0x7a))) {\n      os << setfill(' ') << setw(2) << *ptr;\n    } else {\n      os << setfill('0') << setw(2) << hex << static_cast<int>(*ptr);\n    }\n    if (w == 1) {\n      os << std::endl;\n      w = 16;\n    } else {\n      os << \" \";\n      --w;\n    }\n  }\n  // Make sure there is always a new line on the last line\n  if (w < 16) {\n    os << std::endl;\n  }\n  return os.str();\n}\n\n/*\n* Returns the last system specific error description (using GetLastError in Windows or errno in Unix/OSX).\n*/\nstd::string get_last_error(int myerrnum)\n{\n#ifdef _WIN32\n  DWORD dwCode = myerrnum ? myerrnum : GetLastError();\n  LPTSTR lpMsgBuf;\n\n  FormatMessage(\n    FORMAT_MESSAGE_ALLOCATE_BUFFER |\n    FORMAT_MESSAGE_FROM_SYSTEM |\n    FORMAT_MESSAGE_IGNORE_INSERTS,\n    NULL,\n    dwCode,\n    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),\n    (LPTSTR)&lpMsgBuf,\n    0, NULL);\n  std::string msgerr = \"SystemError: \";\n  msgerr += lpMsgBuf;\n  msgerr += \"with error code %d.\";\n  std::string result = string_format(msgerr.c_str(), dwCode);\n  LocalFree(lpMsgBuf);\n  return result;\n#else\n  char sys_err[64];\n  int errnum = myerrnum ? myerrnum : errno;\n\n  sys_err[0] = 0; // init, in case strerror_r() fails\n\n  // we do this #ifdef dance because on unix systems strerror_r() will generate\n  // a warning if we don't collect the result (warn_unused_result attribute)\n#if ((defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE >= 200112L)) ||    \\\n       (defined _XOPEN_SOURCE && (_XOPEN_SOURCE >= 600)))      &&    \\\n      ! defined _GNU_SOURCE\n  int r = strerror_r(errno, sys_err, sizeof(sys_err));\n  (void)r;  // silence unused variable;\n#elif defined(_GNU_SOURCE) && defined(__GLIBC__)\n  const char *r = strerror_r(errno, sys_err, sizeof(sys_err));\n  (void)r;  // silence unused variable;\n#else\n  strerror_r(errno, sys_err, sizeof(sys_err));\n#endif\n\n  std::string s = sys_err;\n  s += \"with errno %d.\";\n  std::string result = string_format(s.c_str(), errnum);\n  return result;\n#endif\n  }\n\n#ifndef _WIN32\nstatic string default_prompt_password(const string &prompt) {\n  struct termios console;\n  bool no_terminal = false;\n  if (tcgetattr(STDIN_FILENO, &console) != 0) {\n    // this can happen if we're running without a terminal, in that case\n    // we don't care about terminal attributes\n    no_terminal = true;\n  }\n  std::cout << prompt << \": \" << std::flush;\n\n  if (!no_terminal) {\n    // prevent showing input\n    console.c_lflag &= ~(uint)ECHO;\n    tcsetattr(STDIN_FILENO, TCSANOW, &console);\n  }\n  string result;\n  std::getline(std::cin, result);\n\n  if (!no_terminal) {\n    // reset\n    console.c_lflag |= ECHO;\n    tcsetattr(STDIN_FILENO, TCSANOW, &console);\n  }\n  std::cout << std::endl;\n  return result;\n}\n#else\nstatic string default_prompt_password(const string &prompt) {\n\n  std::cout << prompt << \": \" << std::flush;\n\n  // prevent showing input\n  HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);\n  DWORD mode;\n  GetConsoleMode(hStdin, &mode);\n  mode &= ~ENABLE_ECHO_INPUT;\n  SetConsoleMode(hStdin, mode & (~ENABLE_ECHO_INPUT));\n\n  string result;\n  std::getline(std::cin, result);\n\n  // reset\n  SetConsoleMode(hStdin, mode);\n\n  std::cout << std::endl;\n  return result;\n}\n#endif\n\nstatic std::function<string (const string&)> g_prompt_password = default_prompt_password;\n\nvoid set_prompt_password(const std::function<std::string (const std::string &)> &f) {\n  g_prompt_password = f;\n}\n\nstring prompt_password(const std::string &prompt) {\n  return g_prompt_password(prompt);\n}\n\n\n#ifdef _WIN32\n\nbool is_running_as_service() {\n  return ::g_windows_service;\n}\n\nvoid write_windows_event_log(const std::string& msg) {\n  static const std::string event_source_name = \"MySQL Router\";\n  HANDLE event_src = NULL;\n  LPCSTR strings[2] = { NULL, NULL };\n  event_src = RegisterEventSourceA(NULL, event_source_name.c_str());\n  if (event_src) {\n    strings[0] = event_source_name.c_str();\n    strings[1] = msg.c_str();\n    ReportEventA(event_src, EVENTLOG_ERROR_TYPE, 0, 0, NULL, 2, 0, strings, NULL);\n    DeregisterEventSource(event_src);\n  } else {\n    throw std::runtime_error(\"Cannot create event log source, error: \" + std::to_string(GetLastError()));\n  }\n}\n#endif\n\nbool is_valid_socket_name(const std::string &socket, std::string &err_msg) {\n  bool result = true;\n\n#ifndef _WIN32\n  result = socket.size() <= (sizeof(sockaddr_un().sun_path)-1);\n  err_msg =  \"Socket file path can be at most \"\n           + to_string(sizeof(sockaddr_un().sun_path)-1)\n           + \" characters (was \" + to_string(socket.size()) + \")\";\n#endif\n\n  return result;\n}\n\ntemplate <typename RET, typename CONV_FUNC>\nRET strtoX_checked_common(CONV_FUNC conv_func, const char* value, RET default_value) {\n\n  static_assert(std::is_integral<RET>::value, \"This tempate function is meant for integers.\");\n\n  if (value == nullptr)\n    return default_value;\n\n  // Verify that input string consists of only valid_chars.  The idea is to\n  // impose extra restrictions on top of those implemented in conv_func,\n  // particularly to disallow:\n  // - whitespace characters\n  // - decimal numbers\n  // Futher validation is responsibility of conv_func.\n  {\n    // Compute (roughly) the max number of base10 digits RET can have.\n    //   max(1 byte)  = 255 -> 3 digits,\n    //   max(2 bytes) = 65,535 -> 5 digits,\n    //   max(4 bytes) = 4,294,967,295 -> 10 digits,\n    // etc\n    constexpr int kMaxDigits = static_cast<int>((float)sizeof(RET) * 2.41 + 1.0); // log10(2^8) = 2.408, +1 to round up\n\n    bool found_terminator = false;\n    for (int i = 0; i < kMaxDigits + 2; i++ ) { // +2 for sign and string-terminator\n      const char c = value[i];\n      if (c == 0)\n      {\n        found_terminator = true;\n        break;\n      }\n      if (!(('0' <= c && c <= '9') || (c == '-' && std::is_signed<RET>::value) || c == '+'))\n        return default_value;\n    }\n\n    if (!found_terminator)\n      return default_value;\n  }\n\n  // NOTE: we need to play with errno here as it is not enough to check\n  // for LONG_MIN, LONG_MAX as these are still valid values and ERANGE\n  // can be the result of some previous operation\n  auto old_errno = errno;\n  errno = 0;\n\n  char* tmp {nullptr};\n  auto result = conv_func(value, &tmp, 10);\n\n  // if our operation did not set the errno let's be kind enough\n  // to restore it's old value\n  auto our_errno = errno;\n  if (errno == 0) {\n    errno = old_errno;\n  }\n\n  // check if the conversion was valid\n  if (value == tmp || *tmp != '\\0' || our_errno == ERANGE) {\n    return default_value;\n  }\n\n  // check if the value fits after reducing bit width\n  RET r = static_cast<RET>(result);\n  if (r == result)  // false if high-order bytes were truncated\n    return r;\n  else\n    return default_value;\n}\n\n\n// We need those wrappers to suppress\n// \"error: mangled name for 'RET mysqlrouter::strtoX_checked_common(CONV_FUNC, const char*, RET)\n// [with RET = unsigned int; CONV_FUNC = long unsigned int (*)(const char*, char**, int) throw ()]'\n// will change in C++17 because the exception specification is part of a function type [-Werror=noexcept-type]\"\n// on the latest gcc (e.g. Fedora26)\n// It's because std::strtol and std::strtoul have throw() in their declaration and we use them as template params\n\nstatic long int strtol_wrapper(const char *nptr, char ** endptr, int base) {\n  return std::strtol(nptr, endptr, base);\n}\n\nstatic unsigned long int strtoul_wrapper(const char *nptr, char **endptr, int base) {\n  return std::strtoul(nptr, endptr, base);\n}\n\nint strtoi_checked(const char* value, int default_value) {\n  return strtoX_checked_common(strtol_wrapper, value, default_value);\n}\n\nunsigned strtoui_checked(const char* value, unsigned default_value) {\n  return strtoX_checked_common(strtoul_wrapper, value, default_value);\n}\n\n\n#ifndef _WIN32\n\n// class SysUserOperations\n\nSysUserOperations* SysUserOperations::instance() {\n  static SysUserOperations instance_;\n  return &instance_;\n}\n\nint SysUserOperations::initgroups(const char *user, gid_type gid) {\n  return ::initgroups(user, gid);\n}\n\nint SysUserOperations::setgid(gid_t gid) {\n  return ::setgid(gid);\n}\n\nint SysUserOperations::setuid(uid_t uid) {\n  return ::setuid(uid);\n}\n\nint SysUserOperations::setegid(gid_t gid) {\n  return ::setegid(gid);\n}\n\nint SysUserOperations::seteuid(uid_t uid) {\n  return ::seteuid(uid);\n}\n\nuid_t SysUserOperations::geteuid() {\n  return ::geteuid();\n}\n\nstruct passwd* SysUserOperations::getpwnam(const char *name) {\n  return ::getpwnam(name);\n}\n\nstruct passwd* SysUserOperations::getpwuid(uid_t uid) {\n  return ::getpwuid(uid);\n}\n\nint SysUserOperations::chown(const char *file, uid_t owner, gid_t group) {\n  return ::chown(file, owner, group);\n}\n\nvoid set_owner_if_file_exists(const std::string &filepath,\n                              const std::string &username, struct passwd *user_info_arg,\n                              SysUserOperationsBase* sys_user_operations) {\n  assert(user_info_arg != nullptr);\n  assert(sys_user_operations != nullptr);\n\n  if (sys_user_operations->chown(filepath.c_str(), user_info_arg->pw_uid, user_info_arg->pw_gid) == -1) {\n    if (errno != ENOENT) { // Not such file or directory is not an error\n      std::string info;\n      if (errno == EACCES || errno == EPERM) {\n        info = \"\\nOne possible reason can be that the root user does not have proper \"\n                \"rights because of root_squash on the NFS share.\\n\";\n      }\n\n      throw std::runtime_error(string_format(\"Can't set ownership of file '%s' to the user '%s'. \"\n                                             \"error: %s. %s\", filepath.c_str(), username.c_str(),\n                                             strerror(errno), info.c_str()));\n    }\n  }\n}\n\nstatic bool check_if_root(const std::string& username,\n                          SysUserOperationsBase* sys_user_operations) {\n  auto user_id = sys_user_operations->geteuid();\n\n  if (user_id) {\n    /* If real user is same as given with --user don't treat it as an error */\n    struct passwd *tmp_user_info = sys_user_operations->getpwnam(username.c_str());\n    if ((!tmp_user_info || user_id != tmp_user_info->pw_uid)) {\n      throw std::runtime_error(string_format(\"One can only use the -u/--user switch if running as root\"));\n    }\n    return false;\n  }\n\n  return true;\n}\n\nstatic passwd* get_user_info(const std::string& username,\n                             SysUserOperationsBase* sys_user_operations) {\n  struct passwd *tmp_user_info;\n  bool failed = false;\n\n  if (!(tmp_user_info = sys_user_operations->getpwnam(username.c_str()))) {\n    // Allow a numeric uid to be used\n    const char *pos;\n    for (pos = username.c_str(); std::isdigit(*pos); pos++);\n\n    if (*pos)  // Not numeric id\n      failed = true;\n    else if (!(tmp_user_info = sys_user_operations->getpwuid((uid_t)atoi(username.c_str()))))\n      failed = true;\n  }\n\n  if (failed) {\n    throw std::runtime_error(string_format(\"Can't use user '%s'. \"\n                                           \"Please check that the user exists!\", username.c_str()));\n  }\n\n  return tmp_user_info;\n}\n\nstruct passwd* check_user(const std::string& username,\n                          bool must_be_root,\n                          SysUserOperationsBase* sys_user_operations)\n{\n  assert(sys_user_operations != nullptr);\n  if (username.empty()) {\n      throw std::runtime_error(\"Empty user name in check_user() function.\");\n  }\n\n  if (must_be_root) {\n    if (!check_if_root(username, sys_user_operations))\n      return nullptr;\n  }\n\n  return get_user_info(username, sys_user_operations);\n}\n\nstatic void set_user_priv(const std::string &username, struct passwd *user_info_arg,\n                          bool permanently, SysUserOperationsBase* sys_user_operations)\n{\n  assert(user_info_arg != nullptr);\n  assert(sys_user_operations != nullptr);\n\n  sys_user_operations->initgroups((char*)username.c_str(), (SysUserOperationsBase::gid_type)user_info_arg->pw_gid);\n\n  if (permanently) {\n    if (sys_user_operations->setgid(user_info_arg->pw_gid) == -1) {\n      throw std::runtime_error(string_format(\"Error trying to set the user. \"\n                                             \"setgid failed: %s \", strerror(errno)));\n    }\n\n    if (sys_user_operations->setuid(user_info_arg->pw_uid) == -1) {\n      throw std::runtime_error(string_format(\"Error trying to set the user. \"\n                                             \"setuid failed: %s \", strerror(errno)));\n    }\n  }\n  else {\n    if (sys_user_operations->setegid(user_info_arg->pw_gid) == -1) {\n      throw std::runtime_error(string_format(\"Error trying to set the user. \"\n                                             \"setegid failed: %s \", strerror(errno)));\n    }\n\n    if (sys_user_operations->seteuid(user_info_arg->pw_uid) == -1) {\n      throw std::runtime_error(string_format(\"Error trying to set the user. \"\n                                             \"seteuid failed: %s \", strerror(errno)));\n    }\n  }\n}\n\nvoid set_user(const std::string &username, bool permanently, SysUserOperationsBase* sys_user_operations) {\n  auto user_info = check_user(username, permanently, sys_user_operations);\n  if (user_info != nullptr) {\n    set_user_priv(username, user_info, permanently, sys_user_operations);\n  }\n}\n\n#endif\n\n\n} // namespace mysqlrouter\n"
  },
  {
    "path": "src/router/src/windows/main-windows.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"nt_servc.h\"\n#include \"mysql/harness/loader.h\"\n\n#define WIN32_LEAN_AND_MEAN\n#include <iostream>\n#include <fstream>\n#include <windows.h>\n#include <winsock2.h>\n\nnamespace {\n\n  const char *kRouterServiceName = \"MySQLRouter\";\n  const char *kRouterServiceDisplayName = \"MySQL Router\";\n  const char *kAccount = \"NT AUTHORITY\\\\LocalService\";\n  \n  NTService g_service;\n  extern \"C\" bool      g_windows_service = false;\n  int     (*g_real_main)(int,char**);\n  \n  std::string &add_quoted_string(std::string &to, const char *from) {\n    if (!strchr(from, ' '))\n      return to.append(from);\n  \n    to.append(\"\\\"\").append(from).append(\"\\\"\");\n    return to;\n  }\n  \n  int router_service(void *p) {\n    g_real_main(g_service.my_argc, g_service.my_argv);\n    g_service.Stop(); // signal NTService to exit its thread, so we can exit the process\n    return 0;\n  }\n  \n  enum class ServiceStatus {\n    StartNormal,\n    StartAsService,\n    Done,\n    Error\n  };\n\n  bool file_exists(const char *path)\n  {\n    std::ifstream f(path);\n    return (!f) ? false : true;\n  }\n  \n  ServiceStatus check_service_operations(int argc, char **argv) {\n    if (g_service.GetOS())  { /* true NT family */\n      // check if a service installation option was passed\n      const char *config_path = NULL;\n      std::string full_service_path;\n      enum class ServiceOperation {\n        None,\n        Install,\n        InstallManual,\n        Remove,\n        Start\n      } operation = ServiceOperation::None;\n      for (int i = 1; i < argc; i++) {\n        if (strcmp(argv[i], \"-c\") == 0 || strcmp(argv[i], \"--config\") == 0) {\n          if (i < argc-1) {\n            config_path = argv[++i];\n          } else {\n            config_path = NULL;\n          }\n        } else if (strcmp(argv[i], \"--install-service\") == 0) {\n          operation = ServiceOperation::Install;\n        } else if (strcmp(argv[i], \"--install-service-manual\") == 0) {\n          operation = ServiceOperation::InstallManual;\n        } else if (strcmp(argv[i], \"--remove-service\") == 0) {\n          operation = ServiceOperation::Remove;\n        } else if (strcmp(argv[i], \"--service\") == 0) {\n          operation = ServiceOperation::Start;\n        }\n      }\n      switch (operation) {\n      case ServiceOperation::Install:\n      case ServiceOperation::InstallManual:\n        if (config_path == NULL || !file_exists(config_path)) {\n          std::cerr << \"Service install option requires an existing configuration file to be specified (-c <file>)\\n\";\n          return ServiceStatus::Error;\n        }\n        {\n          char abs_path[1024];\n          GetFullPathName(argv[0], sizeof(abs_path), abs_path, NULL);\n          add_quoted_string(full_service_path, abs_path);\n          full_service_path.append(\" -c \");\n          GetFullPathName(config_path, sizeof(abs_path), abs_path, NULL);\n          add_quoted_string(full_service_path, abs_path);\n        }\n        full_service_path.append(\" --service\");\n        g_service.Install(operation == ServiceOperation::Install ? 1 : 0,\n                        kRouterServiceName, kRouterServiceDisplayName, full_service_path.c_str(), kAccount);\n        return ServiceStatus::Done;\n      case ServiceOperation::Remove:\n        g_service.Remove(kRouterServiceName);\n        return ServiceStatus::Done;\n      case ServiceOperation::Start:\n        return ServiceStatus::StartAsService;\n      case ServiceOperation::None:\n        // normal start\n        break;\n      }\n    }\n    return ServiceStatus::StartNormal;\n  }\n  \n  /* Windows specific initialization code.\n   *\n   * Performs socket library initialization and service related things, including\n   * command line param handling for installation/removal of service.\n   */\n  ServiceStatus do_windows_init(int argc, char **argv) {\n    // WinSock init\n    WSADATA wsaData;\n    int result;\n    result = WSAStartup(MAKEWORD(2, 2), &wsaData);\n    if (result != 0) {\n      std::cerr << \"WSAStartup failed with error: \" << result << std::endl;\n      return ServiceStatus::Error;\n    }\n    // check Windows service specific command line options\n    ServiceStatus status = check_service_operations(argc, argv);\n    // Windows service init\n    g_service.my_argc = argc;\n    g_service.my_argv = argv;\n    return status;\n  }\n  \n  void do_windows_cleanup() {\n    // WinSock cleanup\n    WSACleanup();\n  \n    // Windows service deinit\n    if (g_service.IsNT() && g_windows_service) {\n      g_service.Stop();\n    } else {\n      g_service.SetShutdownEvent(0);\n    }\n  }\n\n  BOOL CtrlC_handler(DWORD ctrl_type) {\n    if (ctrl_type == CTRL_C_EVENT) {\n      // user presed Ctrl+C\n      request_application_shutdown();\n      return TRUE;  // don't pass this event to further handlers\n    } else {\n      // some other event\n      return FALSE; // let the default Windows handler deal with it\n    }\n  }\n\n  void register_CtrlC_handler() {\n    if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlC_handler, TRUE)) {\n      std::cerr << \"Could not install Ctrl+C handler, exiting.\\n\";\n      exit(1);\n    }\n  }\n\n} // unnamed namespace\n\nint proxy_main(int (*real_main)(int,char**), int argc, char **argv) {\n  int result = 0;\n  switch (do_windows_init(argc, argv))\n  {\n  case ServiceStatus::StartAsService:\n    if (g_service.IsService(kRouterServiceName)) {\n      /* start the default service */\n      g_windows_service = true;\n      g_real_main = real_main;\n\n      // blocks until one of following 2 functions are called:\n      // - g_service.Stop()        (called by us after main() finishes)\n      // - g_service.StopService() (triggered by OS due to outside event, such as termination request)\n      g_service.Init(kRouterServiceName, (void*)router_service, request_application_shutdown);\n      break;\n    } // fallthrough\n  case ServiceStatus::StartNormal:  // case when Router runs from \"DOS\" console\n    register_CtrlC_handler();\n    g_service.SetRunning();\n    result = real_main(argc, argv);\n    break;\n  case ServiceStatus::Done:\n    return 0;\n  case ServiceStatus::Error:\n    return 1;\n  }\n  do_windows_cleanup();\n  return result;\n}\n\n"
  },
  {
    "path": "src/router/src/windows/main-windows.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef ROUTER_MAIN_WINDOWS_INCLUDED\n#define ROUTER_MAIN_WINDOWS_INCLUDED\n\nint proxy_main(int (*real_main)(int,char**), int argc, char **argv);\n\n#endif // ROUTER_MAIN_WINDOWS_INCLUDED\n"
  },
  {
    "path": "src/router/src/windows/nt_servc.cc",
    "content": "/**\n  @file\n\n  @brief\n  Windows NT Service class library.\n\n  Copyright Abandoned 1998 Irena Pancirov - Irnet Snc\n  This file is public domain and comes with NO WARRANTY of any kind\n\n  Modifications copyright (c) 2000, 2016. Oracle and/or its affiliates.\n  All rights reserved.\n*/\n#include <windows.h>\n#include <process.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include \"nt_servc.h\"\n\nstatic NTService *pService;\n\n/* ------------------------------------------------------------------------\n\n -------------------------------------------------------------------------- */\nNTService::NTService()\n{\n    bOsNT            = FALSE;\n\n    //service variables\n    ServiceName      = NULL;\n    hExitEvent       = 0;\n    bPause           = FALSE;\n    bRunning         = FALSE;\n    hThreadHandle    = 0;\n    fpServiceThread  = NULL;\n\n    //time-out variables\n    nStartTimeOut    = 15000;\n    nStopTimeOut     = 86400000;\n    nPauseTimeOut    = 5000;\n    nResumeTimeOut   = 5000;\n\n    //install variables\n    dwDesiredAccess  = SERVICE_ALL_ACCESS;\n    dwServiceType    = SERVICE_WIN32_OWN_PROCESS;\n    dwStartType      = SERVICE_AUTO_START;\n    dwErrorControl   = SERVICE_ERROR_NORMAL;\n    szLoadOrderGroup = NULL;\n    lpdwTagID        = NULL;\n    szDependencies   = NULL;\n\n    my_argc          = 0;\n    my_argv          = NULL;\n    hShutdownEvent   = 0;\n    nError           = 0;\n    dwState          = 0;\n}\n\n/* ------------------------------------------------------------------------\n\n -------------------------------------------------------------------------- */\nNTService::~NTService()\n{\n  if (ServiceName != NULL) delete[] ServiceName;\n}\n/* ------------------------------------------------------------------------\n\n -------------------------------------------------------------------------- */\n\nBOOL NTService::GetOS()\n{\n  bOsNT = FALSE;\n  memset(&osVer, 0, sizeof(OSVERSIONINFO));\n  osVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);\n  if (GetVersionEx(&osVer))\n  {\n    if (osVer.dwPlatformId == VER_PLATFORM_WIN32_NT)\n      bOsNT = TRUE;\n  }\n  return bOsNT;\n}\n\n\n/**\n  Registers the main service thread with the service manager.\n\n  @param szInternName   Name of service to run in this process.\n  @param ServiceThread  pointer to the main programs entry function\n                        when the service is started\n  @param fpReqAppShutdownCb  pointer to callback function to call after receiving\n                             shutdown signal from Service Controller\n*/\n\n\nlong NTService::Init(LPCSTR szInternName, void *ServiceThread, void (*fpReqAppShutdownCb)())\n{\n\n  pService = this;\n\n  fpRequestApplicationShutdownCallback = fpReqAppShutdownCb;\n\n  fpServiceThread = (THREAD_FC)ServiceThread;\n  ServiceName = new char[lstrlen(szInternName)+1];\n  lstrcpy(ServiceName,szInternName);\n\n  SERVICE_TABLE_ENTRY stb[] =\n  {\n    { (char *)szInternName,(LPSERVICE_MAIN_FUNCTION) ServiceMain} ,\n    { NULL, NULL }\n  };\n\n  return StartServiceCtrlDispatcher(stb); //register with the Service Manager\n}\n\n\n/**\n  Installs the service with Service manager.\n\n  nError values:\n  - 0  success\n  - 1  Can't open the Service manager\n  - 2  Failed to create service.\n*/\n\n\nBOOL NTService::Install(int startType,\n                        LPCSTR szInternName,\n                        LPCSTR szDisplayName,\n                        LPCSTR szFullPath,\n                        LPCSTR szAccountName,\n                        LPCSTR szPassword)\n{\n  BOOL ret_val=FALSE;\n  SC_HANDLE newService, scm;\n\n  if (!SeekStatus(szInternName,1))\n   return FALSE;\n\n  char szFilePath[_MAX_PATH];\n  GetModuleFileName(NULL, szFilePath, sizeof(szFilePath));\n\n  // open a connection to the SCM\n  if (!(scm = OpenSCManager(0, 0,SC_MANAGER_CREATE_SERVICE)))\n    printf(\"Failed to install the service (Couldn't open the SCM)\\n\");\n  else        // Install the new service\n  {\n    if (!(newService=\n    CreateService(scm,\n      szInternName,\n      szDisplayName,\n      dwDesiredAccess,//default: SERVICE_ALL_ACCESS\n      dwServiceType,  //default: SERVICE_WIN32_OWN_PROCESS\n              //default: SERVICE_AUTOSTART\n      (startType == 1 ? SERVICE_AUTO_START :\n       SERVICE_DEMAND_START),\n      dwErrorControl, //default: SERVICE_ERROR_NORMAL\n      szFullPath, //exec full path\n      szLoadOrderGroup, //default: NULL\n      lpdwTagID,  //default: NULL\n      szDependencies, //default: NULL\n      szAccountName,  //default: NULL\n      szPassword))) //default: NULL\n      printf(\"Failed to install the service (Couldn't create service)\\n\");\n    else\n    {\n      printf(\"Service successfully installed.\\n\");\n      CloseServiceHandle(newService);\n      ret_val=TRUE;        // Everything went ok\n    }\n    CloseServiceHandle(scm);\n  }\n  return ret_val;\n}\n\n\n/**\n  Removes  the service.\n\n  nError values:\n  - 0  success\n  - 1  Can't open the Service manager\n  - 2  Failed to locate service\n  - 3  Failed to delete service.\n*/\n\n\nBOOL NTService::Remove(LPCSTR szInternName)\n{\n  BOOL ret_value=FALSE;\n  SC_HANDLE service, scm;\n\n  if (!SeekStatus(szInternName,0))\n   return FALSE;\n\n  nError=0;\n\n  // open a connection to the SCM\n  if (!(scm = OpenSCManager(0, 0,SC_MANAGER_CREATE_SERVICE)))\n  {\n    printf(\"Failed to remove the service (Couldn't open the SCM)\\n\");\n  }\n  else\n  {\n    if ((service = OpenService(scm,szInternName, DELETE)))\n    {\n      if (!DeleteService(service))\n        printf(\"Failed to remove the service (code %i)\\n\", GetLastError());\n      else\n      {\n        printf(\"Service successfully removed.\\n\");\n  ret_value=TRUE;       // everything went ok\n      }\n      CloseServiceHandle(service);\n    }\n    else\n      printf(\"Failed to remove the service (Couldn't open the service)\\n\");\n    CloseServiceHandle(scm);\n  }\n  return ret_value;\n}\n\n/**\n  this function should be called before the app. exits to stop\n  the service\n*/\nvoid NTService::Stop(void)\n{\n  SetStatus(SERVICE_STOP_PENDING,NO_ERROR, 0, 1, 60000);\n  StopService();\n  SetStatus(SERVICE_STOPPED, NO_ERROR, 0, 1, 1000);\n}\n\n/**\n  This is the function that is called from the\n  service manager to start the service.\n*/\n\n\nvoid NTService::ServiceMain(DWORD argc, LPTSTR *argv)\n{\n  // registration function\n  if (!(pService->hServiceStatusHandle =\n  RegisterServiceCtrlHandler(pService->ServiceName,\n           (LPHANDLER_FUNCTION)\n           NTService::ServiceCtrlHandler)))\n    goto error;\n\n  // notify SCM of progress\n  if (!pService->SetStatus(SERVICE_START_PENDING,NO_ERROR, 0, 1, 8000))\n    goto error;\n\n  // create the exit event\n  if (!(pService->hExitEvent = CreateEvent (0, TRUE, FALSE,0)))\n    goto error;\n\n  if (!pService->SetStatus(SERVICE_START_PENDING,NO_ERROR, 0, 3,\n         pService->nStartTimeOut))\n    goto error;\n\n  // save start arguments\n  //pService->my_argc=argc;\n  //pService->my_argv=argv;\n\n  pService->SetSlowStarting(120000);\n\n  // start the service\n  if (!pService->StartService())\n    goto error;\n\n  pService->SetRunning();\n\n  // wait for exit event\n  WaitForSingleObject (pService->hExitEvent, INFINITE);\n\n  // wait for Router main() thread to exit\n  if (WaitForSingleObject (pService->hThreadHandle, INFINITE) == WAIT_TIMEOUT)\n    CloseHandle(pService->hThreadHandle);\n\n  pService->Exit(0);\n  return;\n\nerror:\n  pService->Exit(GetLastError());\n  return;\n}\n\n\n\nvoid NTService::SetRunning()\n{\n  if (pService)\n    pService->SetStatus(SERVICE_RUNNING, NO_ERROR, 0, 0, 0);\n}\n\nvoid NTService::SetSlowStarting(unsigned long timeout)\n{\n  if (pService)\n    pService->SetStatus(SERVICE_START_PENDING,NO_ERROR, 0, 0, timeout);\n}\n\n\n/* ------------------------------------------------------------------------\n   StartService() - starts the application thread\n -------------------------------------------------------------------------- */\n\nBOOL NTService::StartService()\n{\n  // Start the real service's thread (application)\n  if (!(hThreadHandle = (HANDLE) _beginthread((THREAD_FC)fpServiceThread,0,\n                (void *) this)))\n    return FALSE;\n  bRunning = TRUE;\n  return TRUE;\n}\n/* ------------------------------------------------------------------------\n\n -------------------------------------------------------------------------- */\nvoid NTService::StopService()\n{\n  // notify Loader to initiate shutdown\n  fpRequestApplicationShutdownCallback();\n\n  bRunning=FALSE;\n\n  // Set the event for application\n  if (hShutdownEvent)\n     SetEvent(hShutdownEvent);\n\n  // Set the event for ServiceMain\n  SetEvent(hExitEvent);\n}\n/* ------------------------------------------------------------------------\n\n -------------------------------------------------------------------------- */\nvoid NTService::PauseService()\n{\n  bPause = TRUE;\n  SuspendThread(hThreadHandle);\n}\n/* ------------------------------------------------------------------------\n\n -------------------------------------------------------------------------- */\nvoid NTService::ResumeService()\n{\n  bPause=FALSE;\n  ResumeThread(hThreadHandle);\n}\n/* ------------------------------------------------------------------------\n\n -------------------------------------------------------------------------- */\nBOOL NTService::SetStatus (DWORD dwCurrentState,\n                           DWORD dwWin32ExitCode,\n                           DWORD dwServiceSpecificExitCode,\n                           DWORD dwCheckPoint,\n                           DWORD dwWaitHint)\n{\n  BOOL bRet;\n  SERVICE_STATUS serviceStatus;\n\n  dwState=dwCurrentState;\n\n  serviceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS;\n  serviceStatus.dwCurrentState = dwCurrentState;\n\n  if (dwCurrentState == SERVICE_START_PENDING)\n    serviceStatus.dwControlsAccepted = 0; //don't accept control events\n  else\n    serviceStatus.dwControlsAccepted =    (SERVICE_ACCEPT_STOP |\n             SERVICE_ACCEPT_PAUSE_CONTINUE |\n             SERVICE_ACCEPT_SHUTDOWN);\n\n  // if a specific exit code is defined,set up the win32 exit code properly\n  if (dwServiceSpecificExitCode == 0)\n    serviceStatus.dwWin32ExitCode = dwWin32ExitCode;\n  else\n    serviceStatus.dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR;\n\n  serviceStatus.dwServiceSpecificExitCode = dwServiceSpecificExitCode;\n\n  serviceStatus.dwCheckPoint = dwCheckPoint;\n  serviceStatus.dwWaitHint   = dwWaitHint;\n\n  // Pass the status to the Service Manager\n  if (!(bRet=SetServiceStatus (hServiceStatusHandle, &serviceStatus)))\n    StopService();\n\n  return bRet;\n}\n/* ------------------------------------------------------------------------\n\n -------------------------------------------------------------------------- */\nvoid NTService::ServiceCtrlHandler(DWORD ctrlCode)\n{\n  DWORD  dwState;\n\n  if (!pService)\n    return;\n\n  dwState=pService->dwState;  // get current state\n\n  switch(ctrlCode) {\n  case SERVICE_CONTROL_SHUTDOWN:\n  case SERVICE_CONTROL_STOP:\n    dwState = SERVICE_STOP_PENDING;\n    pService->SetStatus(SERVICE_STOP_PENDING,NO_ERROR, 0, 1,\n      pService->nStopTimeOut);\n    pService->StopService();\n    break;\n\n  default:\n    pService->SetStatus(dwState, NO_ERROR,0, 0, 0);\n    break;\n  }\n  //pService->SetStatus(dwState, NO_ERROR,0, 0, 0);\n}\n\n/* ------------------------------------------------------------------------\n\n -------------------------------------------------------------------------- */\n\nvoid NTService::Exit(DWORD error)\n{\n  if (hExitEvent)\n    CloseHandle(hExitEvent);\n\n  // Send a message to the scm to tell that we stop\n  if (hServiceStatusHandle)\n    SetStatus(SERVICE_STOPPED, error,0, 0, 0);\n\n  // If the thread has started kill it ???\n  // if (hThreadHandle) CloseHandle(hThreadHandle);\n\n}\n\n/* ------------------------------------------------------------------------\n\n -------------------------------------------------------------------------- */\n\nBOOL NTService::SeekStatus(LPCSTR szInternName, int OperationType)\n{\n  BOOL ret_value=FALSE;\n  SC_HANDLE service, scm;\n\n  // open a connection to the SCM\n  if (!(scm = OpenSCManager(0, 0,SC_MANAGER_CREATE_SERVICE)))\n  {\n    DWORD ret_error=GetLastError();\n    if (ret_error == ERROR_ACCESS_DENIED)\n    {\n     printf(\"Install/Remove of the Service Denied!\\n\");\n     if (!is_super_user())\n      printf(\"That operation should be made by a user with Administrator privileges!\\n\");\n    }\n    else\n     printf(\"There is a problem when opening the Service Control Manager!\\n\");\n  }\n  else\n  {\n    if (OperationType == 1)\n    {\n      /* an install operation */\n      if ((service = OpenService(scm,szInternName, SERVICE_ALL_ACCESS )))\n      {\n        LPQUERY_SERVICE_CONFIG ConfigBuf;\n        DWORD dwSize;\n\n        ConfigBuf = (LPQUERY_SERVICE_CONFIG) LocalAlloc(LPTR, 4096);\n        printf(\"The service already exists!\\n\");\n        if (QueryServiceConfig(service,ConfigBuf,4096,&dwSize))\n          printf(\"The current server installed: %s\\n\",\n           ConfigBuf->lpBinaryPathName);\n        LocalFree(ConfigBuf);\n        CloseServiceHandle(service);\n      }\n      else\n        ret_value=TRUE;\n    }\n    else\n    {\n      /* a remove operation */\n      if (!(service = OpenService(scm,szInternName, SERVICE_ALL_ACCESS )))\n        printf(\"The service doesn't exist!\\n\");\n      else\n      {\n        SERVICE_STATUS ss;\n\n        memset(&ss, 0, sizeof(ss));\n        if (QueryServiceStatus(service,&ss))\n        {\n          DWORD dwState = ss.dwCurrentState;\n          if (dwState == SERVICE_RUNNING)\n            printf(\"Failed to remove the service because the service is running\\nStop the service and try again\\n\");\n          else if (dwState == SERVICE_STOP_PENDING)\n            printf(\"Failed to remove the service because the service is in stop pending state!\\n\"\n                   \"Wait 30 seconds and try again.\\n\"\n                   \"If this condition persist, reboot the machine and try again\\n\");\n          else\n            ret_value= TRUE;\n        }\n        CloseServiceHandle(service);\n      }\n    }\n    CloseServiceHandle(scm);\n  }\n\n  return ret_value;\n}\n/* ------------------------------------------------------------------------\n -------------------------------------------------------------------------- */\nBOOL NTService::IsService(LPCSTR ServiceName)\n{\n  BOOL ret_value=FALSE;\n  SC_HANDLE service, scm;\n\n  if ((scm= OpenSCManager(0, 0,SC_MANAGER_ENUMERATE_SERVICE)))\n  {\n    if ((service = OpenService(scm,ServiceName, SERVICE_QUERY_STATUS)))\n    {\n      ret_value=TRUE;\n      CloseServiceHandle(service);\n    }\n    CloseServiceHandle(scm);\n  }\n  return ret_value;\n}\n/* ------------------------------------------------------------------------\n -------------------------------------------------------------------------- */\nBOOL NTService::got_service_option(char **argv, char *service_option)\n{\n  char *option;\n  for (option= argv[1]; *option; option++)\n    if (!strcmp(option, service_option))\n      return TRUE;\n  return FALSE;\n}\n/* ------------------------------------------------------------------------\n -------------------------------------------------------------------------- */\nBOOL NTService::is_super_user()\n{\n  HANDLE hAccessToken;\n  UCHAR InfoBuffer[1024];\n  PTOKEN_GROUPS ptgGroups=(PTOKEN_GROUPS)InfoBuffer;\n  DWORD dwInfoBufferSize;\n  PSID psidAdministrators;\n  SID_IDENTIFIER_AUTHORITY siaNtAuthority = SECURITY_NT_AUTHORITY;\n  UINT x;\n  BOOL ret_value=FALSE;\n\n  if (!OpenThreadToken(GetCurrentThread(), TOKEN_QUERY, TRUE,&hAccessToken ))\n  {\n   if (GetLastError() != ERROR_NO_TOKEN)\n     return FALSE;\n\n   if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hAccessToken))\n     return FALSE;\n  }\n\n  ret_value= GetTokenInformation(hAccessToken,TokenGroups,InfoBuffer,\n                                 1024, &dwInfoBufferSize);\n\n  CloseHandle(hAccessToken);\n\n  if (!ret_value )\n    return FALSE;\n\n  if (!AllocateAndInitializeSid(&siaNtAuthority, 2,\n        SECURITY_BUILTIN_DOMAIN_RID,\n        DOMAIN_ALIAS_RID_ADMINS,\n        0, 0, 0, 0, 0, 0,\n        &psidAdministrators))\n    return FALSE;\n\n  ret_value = FALSE;\n\n  for (x=0;x<ptgGroups->GroupCount;x++)\n  {\n   if ( EqualSid(psidAdministrators, ptgGroups->Groups[x].Sid) )\n   {\n    ret_value = TRUE;\n    break;\n   }\n\n  }\n  FreeSid(psidAdministrators);\n  return ret_value;\n}\n"
  },
  {
    "path": "src/router/src/windows/nt_servc.h",
    "content": "#ifndef NT_SERVC_INCLUDED\n#define NT_SERVC_INCLUDED\n\n#define WIN32_LEAN_AND_MEAN\n#include <windows.h>\n\n#ifdef StartService\n#  undef StartService\n#endif\n\n/**\n  @file\n\n  @brief\n  Windows NT Service class library\n\n  Copyright Abandoned 1998 Irena Pancirov - Irnet Snc\n  This file is public domain and comes with NO WARRANTY of any kind\n*/\n\n// main application thread\ntypedef void (*THREAD_FC)(void *);\n\nclass NTService\n{\n  public:\n    NTService();\n   ~NTService();\n\n    BOOL    bOsNT;        ///< true if OS is NT, false for Win95\n    //install optinos\n    DWORD   dwDesiredAccess;\n    DWORD   dwServiceType;\n    DWORD   dwStartType;\n    DWORD   dwErrorControl;\n\n    LPSTR   szLoadOrderGroup;\n    LPDWORD lpdwTagID;\n    LPSTR   szDependencies;\n    OSVERSIONINFO osVer;\n\n    // time-out (in milisec)\n    int     nStartTimeOut;\n    int     nStopTimeOut;\n    int     nPauseTimeOut;\n    int     nResumeTimeOut;\n\n    //\n    DWORD   my_argc;\n    LPTSTR *my_argv;\n    HANDLE  hShutdownEvent;\n    int     nError;\n    DWORD   dwState;\n\n    BOOL GetOS();       // returns TRUE if WinNT\n    BOOL IsNT() { return bOsNT;}\n    //init service entry point\n    long Init(LPCSTR szInternName,void *ServiceThread, void (*fpReqAppShutdownCb)());\n\n    //application shutdown event\n    void SetShutdownEvent(HANDLE hEvent){ hShutdownEvent=hEvent; }\n\n\n    //service install / un-install\n    BOOL Install(int startType,LPCSTR szInternName,LPCSTR szDisplayName,\n                 LPCSTR szFullPath, LPCSTR szAccountName=NULL,\n                 LPCSTR szPassword=NULL);\n    BOOL SeekStatus(LPCSTR szInternName, int OperationType);\n    BOOL Remove(LPCSTR szInternName);\n    BOOL is_super_user();\n\n    //running\n    BOOL got_service_option(char **argv, char *service_option);\n    BOOL IsService(LPCSTR ServiceName);\n\n    /*\n      SetRunning() is to be called by the application\n      when initialization completes and it can accept\n      stop request\n    */\n    void SetRunning(void);\n\n    /**\n      Sets a timeout after which SCM will abort service startup if SetRunning()\n      was not called or the timeout was not extended with another call to\n      SetSlowStarting(). Should be called when static initialization completes,\n      and the variable initialization part begins\n\n      @arg timeout  the timeout to pass to the SCM (in milliseconds)\n    */\n    void SetSlowStarting(unsigned long timeout);\n\n    /*\n      Stop() is to be called by the application to stop\n      the service\n    */\n    void Stop(void);    \n\n  protected:\n    LPSTR      ServiceName;\n    HANDLE     hExitEvent;\n    SERVICE_STATUS_HANDLE  hServiceStatusHandle;\n    BOOL       bPause;\n    BOOL       bRunning;\n    HANDLE     hThreadHandle;\n    THREAD_FC  fpServiceThread;\n    void       (*fpRequestApplicationShutdownCallback)() = nullptr;\n\n    void PauseService();\n    void ResumeService();\n    void StopService();\n    BOOL StartService();\n\n    static void ServiceMain(DWORD argc, LPTSTR *argv);\n    static void ServiceCtrlHandler (DWORD ctrlCode);\n\n    void Exit(DWORD error);\n    BOOL SetStatus (DWORD dwCurrentState,DWORD dwWin32ExitCode,\n                    DWORD dwServiceSpecificExitCode,\n                    DWORD dwCheckPoint,DWORD dwWaitHint);\n\n};\n/* ------------------------- the end -------------------------------------- */\n\n#endif /* NT_SERVC_INCLUDED */\n"
  },
  {
    "path": "src/router/src/windows/password_vault.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysqlrouter/windows/password_vault.h\"\n\n#include <windows.h>\n#include <shlobj.h>\n#include <comdef.h>\n#include <Dpapi.h>\n#include <Wincrypt.h>\n\n#include <iostream>\n#include <fstream>\n#include <memory>\n#include <strstream>\n#include <sstream>\n#include <vector>\n\n#include \"mysqlrouter/utils.h\"\n\n\nPasswordVault::PasswordVault() {\n  load_passwords();\n}\n\nPasswordVault::~PasswordVault() {\n  // scrambles all the passwords first\n  for (auto &it : _passwords) {\n  // for (std::map<std::string, std::string>::iterator it = _passwords.begin();\n  // it != _passwords.end(); ++it) {\n    std::string& pass = it.second;\n    password_scrambler(pass);\n  }\n  _passwords.clear();\n}\n\nstd::string PasswordVault::get_vault_path() const {\n  return \"C:\\\\ProgramData\\\\MySQL\\\\MySQL Router\\\\mysql_router_user_data.dat\";\n}\n\nvoid PasswordVault::password_scrambler(std::string& pass) {\n  for (size_t i = 0; i < pass.length(); ++i)\n    pass.at(i) = '*';\n}\n\nvoid PasswordVault::remove_password(const std::string& section_name) {\n  _passwords.erase(section_name);\n}\n\nvoid PasswordVault::update_password(const std::string& section_name,\n  const std::string& password) {\n  _passwords[section_name] = password;\n}\n\nbool PasswordVault::get_password(const std::string& section_name,\n  std::string& out_password) const {\n  std::map<std::string, std::string>::const_iterator it =\n    _passwords.find(section_name);\n  if (it != _passwords.end()) {\n    out_password = it->second;\n    return true;\n  } else {\n    return false;\n  }\n}\n\nvoid PasswordVault::clear_passwords() {\n  const std::string vault_path = get_vault_path();\n  std::ofstream f(vault_path, std::ios_base::trunc);\n  f.flush();\n  for (auto &it : _passwords) {\n    std::string& pass = it.second;\n    password_scrambler(pass);\n  }\n\n  _passwords.clear();\n}\n\nvoid PasswordVault::load_passwords() {\n  const std::string vault_path = get_vault_path();\n  std::unique_ptr<std::ifstream> file_vault(new std::ifstream(vault_path, std::ios_base::binary));\n  if (!file_vault) {\n    // creates the file if doesn't exist\n    std::ofstream file_vault_out(vault_path, std::ios_base::binary);\n    if (!file_vault_out)\n      throw std::runtime_error(\"Cannot open the vault at '\" + vault_path +\"'\");\n    file_vault_out.close();\n    file_vault.reset(new std::ifstream(vault_path, std::ios_base::binary));\n  }\n  std::streampos begin = file_vault->tellg();\n  file_vault->seekg(0, std::ios::end);\n  std::streampos end = file_vault->tellg();\n  if (end - begin == 0) return;\n  std::unique_ptr<char, void(*)(char*)> buf(new char[end - begin], \n    [](char* ptr) { delete[] ptr; });\n  file_vault->seekg(0, std::ios::beg);\n  file_vault->read(buf.get(), end - begin);\n\n  // decrypt the data\n  DATA_BLOB buf_encrypted;\n  DATA_BLOB buf_decrypted;\n  buf_encrypted.pbData = reinterpret_cast<BYTE *>(buf.get());\n  buf_encrypted.cbData = end - begin;\n  if (!CryptUnprotectData(&buf_encrypted, NULL, NULL, NULL, NULL, 0,\n    &buf_decrypted)) {\n    DWORD code = GetLastError();\n    throw std::runtime_error(mysqlrouter::string_format(\n      \"Error when decrypting the vault at '%s' with code '%d'\", vault_path,\n      code));\n  }\n\n  std::strstream ss(reinterpret_cast<char *>(buf_decrypted.pbData),\n    buf_decrypted.cbData, std::ios_base::in);\n\n  std::string line;\n  std::string section_name;\n  int i = 0;\n  while (std::getline(ss, line)) {\n    if (i % 2 == 0)\n      section_name = line;\n    else\n      _passwords[section_name] = line;\n    i++;\n  }\n  LocalFree(buf_decrypted.pbData);\n}\n\nvoid PasswordVault::store_passwords() {\n  std::stringstream ss(std::ios_base::out);\n  for (auto &it : _passwords) {\n  // for (std::map<std::string, std::string>::iterator it = _passwords.begin();\n    // it != _passwords.end(); ++it)\n    ss << it.first << std::endl;\n    ss << it.second << std::endl;\n  }\n  ss.flush();\n  // encrypt the data\n  DATA_BLOB buf_decrypted;\n  DATA_BLOB buf_encrypted;\n  std::string data = ss.str();\n  buf_decrypted.pbData = reinterpret_cast<BYTE *>(const_cast<char *>(data.c_str()));\n  buf_decrypted.cbData = ss.str().size();\n  if (!CryptProtectData(&buf_decrypted, NULL, NULL, NULL, NULL, CRYPTPROTECT_LOCAL_MACHINE, &buf_encrypted)) {\n    DWORD code = GetLastError();\n    throw std::runtime_error(mysqlrouter::string_format(\n      \"Error when encrypting the vault with code '%d'\", code));\n  }\n\n  const std::string vault_path = get_vault_path();\n  std::ofstream f(vault_path, std::ios_base::trunc | std::ios_base::binary);\n  if (!f)\n    throw std::runtime_error(\"Cannot open the vault at '\" + vault_path + \"'\");\n  f.write(reinterpret_cast<char *>(buf_encrypted.pbData), buf_encrypted.cbData);\n  f.flush();\n  LocalFree(buf_encrypted.pbData);\n}\n"
  },
  {
    "path": "src/router/tests/CMakeLists.txt",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\ninclude_directories(../include ../src ../../../tests/helpers)\n\nadd_test_dir(${CMAKE_CURRENT_SOURCE_DIR}\n  MODULE \"router\"\n  ENVIRONMENT \"MYSQL_ROUTER_HOME=${MySQLRouter_BINARY_STAGE_DIR}/etc/\"\n  LIB_DEPENDS test-helpers\n  INCLUDE_DIRS\n    ${MySQLRouter_SOURCE_DIR}/src/harness/shared/include\n    ${GTEST_INCLUDE_DIRS})\n\nadd_test_dir(issues MODULE issues\n  LIB_DEPENDS test-helpers\n  INCLUDE_DIRS ${GTEST_INCLUDE_DIRS})\n\nif(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL \"Clang\")\n  # silence undefined use of macro-vars in gtest.\n  # we can't use #pragma's due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431 to\n  # supress it locally.\n  set_target_properties(\n    test_router_uri\n    PROPERTIES\n    COMPILE_FLAGS \"-Wno-undef -Wno-conversion\")\nendif()\n\nfile(GLOB config_files ${CMAKE_CURRENT_SOURCE_DIR}/*.conf ${CMAKE_CURRENT_SOURCE_DIR}/*.ini)\nif(NOT CMAKE_CFG_INTDIR STREQUAL \".\")\n  foreach(conf ${CMAKE_CONFIGURATION_TYPES})\n    foreach(config_file ${config_files})\n      add_custom_command(TARGET test_router_mysqlrouter_app\n        COMMAND ${CMAKE_COMMAND} -E copy ${config_file} ${MySQLRouter_BINARY_STAGE_DIR}/${conf}/etc/\n        COMMENT \"Copying Router test data: ${config_file}\"\n      )\n    endforeach()\n  endforeach()\nelse()\n  foreach(config_file ${config_files})\n    add_custom_command(TARGET test_router_mysqlrouter_app\n      COMMAND ${CMAKE_COMMAND} -E copy ${config_file} ${MySQLRouter_BINARY_STAGE_DIR}/etc/\n      COMMENT \"Copying Router test data: ${config_file}\"\n    )\n  endforeach()\nendif()\n"
  },
  {
    "path": "src/router/tests/config_a.conf",
    "content": "[DEFAULT]\nlogging_folder =\nplugin_folder = /tmp\nruntime_folder = /tmp\nconfig_folder = /tmp\n\n[logger]\nlibrary = logger\nfile = config_a.conf\n"
  },
  {
    "path": "src/router/tests/config_b.conf",
    "content": "[config_b]\nlibrary = config_b\nfile = config_b.conf\n\n[config_a]\nlibrary = config_a\nham = spam\n"
  },
  {
    "path": "src/router/tests/config_c.ini",
    "content": "[DEFAULT]\nlogging_folder =\nplugin_folder = /tmp\nruntime_folder = /tmp\nconfig_folder = /tmp\n\n"
  },
  {
    "path": "src/router/tests/issues/test_bug22074209.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/**\n * BUG22074209 --HELP OUTPUT DOES NOT DISPLAY VERSION\n *\n */\n\n#include \"gtest_consoleoutput.h\"\n#include \"cmd_exec.h\"\n#include \"router_app.h\"\n\n#include \"gmock/gmock.h\"\n\nusing ::testing::StartsWith;\n\nPath   g_origin;\n\nclass Bug22074209 : public ConsoleOutputTest {\nprotected:\n  virtual void SetUp() {\n    set_origin(g_origin);\n    ConsoleOutputTest::SetUp();\n  }\n};\n\nTEST_F(Bug22074209, HelpShowsVersion) {\n  MySQLRouter r;\n  std::string cmd = app_mysqlrouter->str() + \" --help\";\n\n  auto cmd_result = cmd_exec(cmd, false);\n  EXPECT_THAT(cmd_result.output, StartsWith(r.get_version_line()));\n}\n\nint main(int argc, char *argv[]) {\n  g_origin = Path(argv[0]).dirname();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/router/tests/issues/test_bug22084430.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/**\n * BUG22084430 IPV6 ADDRESS IN LOGS DOES NOT USE []\n *\n */\n\n#include \"gmock/gmock.h\"\n\n#include \"router_test_helpers.h\"\n#include \"tcp_address.h\"\n\n#ifdef _WIN32\n#include <WinSock2.h>\n#endif\n\nusing mysql_harness::TCPAddress;\n\nclass Bug22084430 : public ::testing::Test {\n  virtual void SetUp() {}\n  virtual void TearDown() {}\n};\n\nTEST_F(Bug22084430, LogCorrectIPv6Address) {\n  std::map<std::string, TCPAddress> address{\n    {\"[::]:7002\", TCPAddress (\"::\", 7002)},\n    {\"[FE80:0000:0000:0000:0202:B3FF:FE1E:8329]:8329\", TCPAddress (\"FE80:0000:0000:0000:0202:B3FF:FE1E:8329\", 8329)},\n    {\"[FE80::0202:B3FF:FE1E:8329]:80\", TCPAddress (\"FE80::0202:B3FF:FE1E:8329\", 80)},\n  };\n\n  for (auto &it: address) {\n    EXPECT_EQ(it.second.str(), it.first);\n  }\n}\n\nTEST_F(Bug22084430, LogCorrectIPv4Address) {\n  std::map<std::string, TCPAddress> address{\n    {\"127.0.0.1:7002\", TCPAddress (\"127.0.0.1\", 7002)},\n    {\"192.168.1.128:8329\", TCPAddress (\"192.168.1.128\", 8329)},\n  };\n\n  for (auto &it: address) {\n    EXPECT_EQ(it.second.str(), it.first);\n  }\n}\n\n\nint main(int argc, char *argv[]) {\n  init_windows_sockets();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/router/tests/issues/test_bug22572346.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/**\n * BUG22572346 CORE DUMP WHILE STARTING THE ROUTER WHEN DESTINATIONS HAS @ CHARACTER\n *\n */\n#include \"gtest_consoleoutput.h\"\n#include \"router_app.h\"\n#include \"mysql/harness/config_parser.h\"\n#include \"router_test_helpers.h\"\n#include \"test/helpers.h\"\n\n#include <fstream>\n#include <string>\n\n#include \"gmock/gmock.h\"\n\nusing std::string;\nusing ::testing::StrEq;\nusing mysql_harness::Path;\n\nstring g_cwd;\nPath g_origin;\n\nclass Bug22572346 : public ConsoleOutputTest {\nprotected:\n  virtual void SetUp() {\n    set_origin(g_origin);\n    ConsoleOutputTest::SetUp();\n    config_path.reset(new Path(g_cwd));\n    config_path->append(\"Bug21572346.conf\");\n  }\n\n  void reset_config() {\n    std::ofstream ofs_config(config_path->str());\n    if (ofs_config.good()) {\n      ofs_config << \"[DEFAULT]\\n\";\n      ofs_config << \"logging_folder =\\n\";\n      ofs_config << \"plugin_folder = \" << plugin_dir->str() << \"\\n\";\n      ofs_config << \"runtime_folder = \" << stage_dir->str() << \"\\n\";\n      ofs_config << \"config_folder = \" << stage_dir->str() << \"\\n\\n\";\n      ofs_config.close();\n    }\n  }\n\n  std::unique_ptr<Path> config_path;\n};\n\nTEST_F(Bug22572346, ConfigVarWithIllegalCharAtBeg) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing:modeReadOnly]\\nbind_port = 7001\\ndestinations = {#mysqld1}\\nmode = read-only\\n\";\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument,\n    \"option destinations in [routing:modeReadOnly] has an invalid destination address '{#mysqld1}:3306'\");\n}\n\nTEST_F(Bug22572346, ConfigVarWithIllegalCharInMid) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing:modeReadOnly]\\nbind_port = 7001\\ndestinations = {mysqld@1}\\nmode = read-only\\n\";\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument,\n      \"option destinations in [routing:modeReadOnly] has an invalid destination address '{mysqld@1}:3306'\");\n}\n\nTEST_F(Bug22572346, ConfigVarWithIllegalCharAtEnd) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing:modeReadOnly]\\nbind_port = 7001\\ndestinations = {mysqld1`}\\nmode = read-only\\n\";\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument,\n      \"option destinations in [routing:modeReadOnly] has an invalid destination address '{mysqld1`}:3306'\");\n}\n\nTEST_F(Bug22572346, ConfigVarWithSameMultIllegalChars) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing:modeReadOnly]\\nbind_port = 7001\\ndestinations = {mysqld!!1}\\nmode = read-only\\n\";\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument,\n      \"option destinations in [routing:modeReadOnly] has an invalid destination address '{mysqld!!1}:3306'\");\n}\n\nTEST_F(Bug22572346, ConfigVarWithDiffMultIllegalChars) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing:modeReadOnly]\\nbind_port = 7001\\ndestinations = {mysql$d%1}\\nmode = read-only\\n\";\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument,\n      \"option destinations in [routing:modeReadOnly] has an invalid destination address '{mysql$d%1}:3306'\");\n}\n\nTEST_F(Bug22572346, ConfigBindPortWithIllegalChar) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing:modeReadOnly]\\nbind_port = {mysqld@1}\\ndestinations = localhost\\nmode = read-only\\n\";\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument,\n      \"option bind_port in [routing:modeReadOnly] needs value between 1 and 65535 inclusive, was '{mysqld@1}'\");\n}\n\nTEST_F(Bug22572346, ConfigVarWithSpaceAtBeg) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing:modeReadOnly]\\nbind_port = 7001\\ndestinations = { mysqld1}\\nmode = read-only\\n\";\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument,\n      \"option destinations in [routing:modeReadOnly] has an invalid destination address '{ mysqld1}:3306'\");\n}\n\nTEST_F(Bug22572346, ConfigVarWithSpaceInMid) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing:modeReadOnly]\\nbind_port = 7001\\ndestinations = {my sqld1}\\nmode = read-only\\n\";\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument,\n      \"option destinations in [routing:modeReadOnly] has an invalid destination address '{my sqld1}:3306'\");\n}\n\nTEST_F(Bug22572346, ConfigVarWithSpaceAtEnd) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing:modeReadOnly]\\nbind_port = 7001\\ndestinations = {mysqld1 }\\nmode = read-only\\n\";\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument,\n      \"option destinations in [routing:modeReadOnly] has an invalid destination address '{mysqld1 }:3306'\");\n}\n\nTEST_F(Bug22572346, ConfigVarWithSpaceBeforeIllegalChar) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing:modeReadOnly]\\nbind_port = 7001\\ndestinations = { @mysqld1}\\nmode = read-only\\n\";\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument,\n      \"option destinations in [routing:modeReadOnly] has an invalid destination address '{ @mysqld1}:3306'\");\n}\n\nTEST_F(Bug22572346, ConfigVarWithIllegalCharBeforeSpace) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing:modeReadOnly]\\nbind_port = 7001\\ndestinations = {m@ysql d1}\\nmode = read-only\\n\";\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument,\n      \"option destinations in [routing:modeReadOnly] has an invalid destination address '{m@ysql d1}:3306'\");\n}\n\nTEST_F(Bug22572346, ConfigVarWithMultSpace) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing:modeReadOnly]\\nbind_port = 7001\\ndestinations = {my sq ld1}\\nmode = read-only\\n\";\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument,\n      \"option destinations in [routing:modeReadOnly] has an invalid destination address '{my sq ld1}:3306'\");\n}\n\nint main(int argc, char *argv[]) {\n  init_windows_sockets();\n  g_origin = Path(argv[0]).dirname();\n  g_cwd = Path(argv[0]).dirname().str();\n  register_test_logger();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n\n"
  },
  {
    "path": "src/router/tests/issues/test_bug24909259.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/**\n * BUG24909259 ROUTER IS NOT ABLE TO CONNECT TO M/C AFTER BOOSTRAPPED WITH DIR & NAME OPTIONS\n *\n */\n\n#include <gtest/gtest_prod.h>\n\n#include \"dim.h\"\n#include \"router_app.h\"\n#include \"mysql/harness/config_parser.h\"\n#include \"random_generator.h\"\n#include \"router_test_helpers.h\"\n#include \"mysqlrouter/utils.h\"\n#include \"keyring/keyring_manager.h\"\n#include \"keyring/keyring_memory.h\"\n\n#include <fstream>\n#include <string>\n\n#include \"gmock/gmock.h\"\n\nstatic std::string kTestKRFile = \"tkeyfile\";\nstatic std::string kTestKRFile2 = \"tkeyfile2\";\nstatic struct Initter {\n  Initter() {\n    tmpdir_ = mysql_harness::get_tmp_dir();\n    kTestKRFile = tmpdir_ + \"/\" + kTestKRFile;\n    kTestKRFile2 = tmpdir_ + \"/\" + kTestKRFile2;\n  }\n  ~Initter() {\n    mysql_harness::delete_dir_recursive(tmpdir_);\n  }\n private:\n  std::string tmpdir_;\n} init;\nstatic std::string kTestKey = \"mykey\";\n\nstatic std::string my_prompt_password(const std::string &, int *num_password_prompts) {\n  *num_password_prompts = *num_password_prompts + 1;\n  return kTestKey;\n}\n\nusing namespace std::placeholders;\n\nstatic void create_keyfile(const std::string &path) {\n  mysql_harness::delete_file(path);\n  mysql_harness::delete_file(path+\".master\");\n  mysql_harness::init_keyring(path, path+\".master\", true);\n  mysql_harness::reset_keyring();\n}\n\nstatic void create_keyfile_withkey(const std::string &path, const std::string &key) {\n  mysql_harness::delete_file(path);\n  mysql_harness::init_keyring_with_key(path, key, true);\n  mysql_harness::reset_keyring();\n}\n\nTEST(Bug24909259, init_tests) {\n  mysql_harness::DIM::instance().set_RandomGenerator(\n    [](){ static mysql_harness::FakeRandomGenerator rg; return &rg; },\n    [](mysql_harness::RandomGeneratorInterface*){}  // don't delete our static!\n  );\n}\n\n//bug#24909259\nTEST(Bug24909259, PasswordPrompt_plain) {\n  create_keyfile(kTestKRFile);\n  create_keyfile_withkey(kTestKRFile2, kTestKey);\n\n  int num_password_prompts = 0;\n  mysqlrouter::set_prompt_password(std::bind(my_prompt_password, _1, &num_password_prompts));\n\n  // metadata_cache\n  mysql_harness::reset_keyring();\n  EXPECT_TRUE(mysql_harness::get_keyring() == nullptr);\n  {\n    mysql_harness::Config config(mysql_harness::Config::allow_keys);\n    std::stringstream ss(\"[metadata_cache]\\n\");\n    config.read(ss);\n\n    MySQLRouter router;\n    router.init_keyring(config);\n    EXPECT_TRUE(mysql_harness::get_keyring() == nullptr);\n    EXPECT_EQ(0, num_password_prompts);\n  }\n  mysql_harness::reset_keyring();\n  EXPECT_TRUE(mysql_harness::get_keyring() == nullptr);\n  {\n    mysql_harness::Config config(mysql_harness::Config::allow_keys);\n    std::stringstream ss(\"[metadata_cache]\\nuser=foo\\n\");\n    config.read(ss);\n\n    MySQLRouter router;\n    try {\n      router.init_keyring(config);\n\n      FAIL() << \"expected std::runtime_error, got no exception\";\n    } catch(const std::runtime_error &) {\n      // ok\n    } catch(const std::exception &e) {\n      FAIL() << \"expected std::runtime_error, got \" << typeid(e).name() << \": \" << e.what();\n    }\n    EXPECT_EQ(1, num_password_prompts);\n    EXPECT_TRUE(mysql_harness::get_keyring() == nullptr);\n  }\n  mysql_harness::reset_keyring();\n  {\n    mysql_harness::Config config(mysql_harness::Config::allow_keys);\n    std::stringstream ss(\"[DEFAULT]\\nkeyring_path=\"+kTestKRFile2+\"\\n[metadata_cache]\\nuser=foo\\n\");\n    config.read(ss);\n\n    MySQLRouter router;\n    router.init_keyring(config);\n    EXPECT_EQ(2, num_password_prompts);\n    EXPECT_TRUE(mysql_harness::get_keyring() != nullptr);\n  }\n  mysql_harness::reset_keyring();\n  {\n    // this one should succeed completely\n    mysql_harness::Config config(mysql_harness::Config::allow_keys);\n    std::stringstream ss(\"[DEFAULT]\\nkeyring_path=\"+kTestKRFile+\"\\nmaster_key_path=\"+kTestKRFile+\".master\\n[metadata_cache]\\nuser=foo\\n\");\n    config.read(ss);\n\n    MySQLRouter router;\n    router.init_keyring(config);\n    EXPECT_TRUE(mysql_harness::get_keyring() != nullptr);\n    EXPECT_EQ(2, num_password_prompts);\n  }\n  mysql_harness::reset_keyring();\n}\n\nTEST(Bug24909259, PasswordPrompt_keyed) {\n  create_keyfile(kTestKRFile);\n  create_keyfile_withkey(kTestKRFile2, kTestKey);\n\n  int num_password_prompts = 0;\n  mysqlrouter::set_prompt_password(std::bind(my_prompt_password, _1, &num_password_prompts));\n\n  // metadata_cache\n  mysql_harness::reset_keyring();\n  EXPECT_TRUE(mysql_harness::get_keyring() == nullptr);\n  {\n    mysql_harness::Config config(mysql_harness::Config::allow_keys);\n    std::stringstream ss(\"[metadata_cache:foo]\\n\");\n    config.read(ss);\n\n    MySQLRouter router;\n    router.init_keyring(config);\n    EXPECT_TRUE(mysql_harness::get_keyring() == nullptr);\n    EXPECT_EQ(0, num_password_prompts);\n  }\n  mysql_harness::reset_keyring();\n  EXPECT_TRUE(mysql_harness::get_keyring() == nullptr);\n  {\n    mysql_harness::Config config(mysql_harness::Config::allow_keys);\n    std::stringstream ss(\"[metadata_cache:foo]\\nuser=foo\\n\");\n    config.read(ss);\n\n    MySQLRouter router;\n    try {\n      router.init_keyring(config);\n\n      FAIL() << \"expected std::runtime_error, got no exception\";\n    } catch(const std::runtime_error &) {\n      // ok\n    } catch(const std::exception &e) {\n      FAIL() << \"expected std::runtime_error, got \" << typeid(e).name() << \": \" << e.what();\n    }\n    EXPECT_EQ(1, num_password_prompts);\n    EXPECT_TRUE(mysql_harness::get_keyring() == nullptr);\n  }\n  mysql_harness::reset_keyring();\n  {\n    mysql_harness::Config config(mysql_harness::Config::allow_keys);\n    std::stringstream ss(\"[DEFAULT]\\nkeyring_path=\"+kTestKRFile2+\"\\n[metadata_cache:foo]\\nuser=foo\\n\");\n    config.read(ss);\n\n    MySQLRouter router;\n    router.init_keyring(config);\n    EXPECT_EQ(2, num_password_prompts);\n    EXPECT_TRUE(mysql_harness::get_keyring() != nullptr);\n  }\n  mysql_harness::reset_keyring();\n  {\n    // this one should succeed completely\n    mysql_harness::Config config(mysql_harness::Config::allow_keys);\n    std::stringstream ss(\"[DEFAULT]\\nkeyring_path=\"+kTestKRFile+\"\\nmaster_key_path=\"+kTestKRFile+\".master\\n[metadata_cache:foo]\\nuser=foo\\n\");\n    config.read(ss);\n\n    MySQLRouter router;\n    router.init_keyring(config);\n    EXPECT_TRUE(mysql_harness::get_keyring() != nullptr);\n    EXPECT_EQ(2, num_password_prompts);\n  }\n  mysql_harness::reset_keyring();\n}\n"
  },
  {
    "path": "src/router/tests/mysqlrouter.conf.in",
    "content": "[DEFAULT]\nlogging_folder = @ROUTER_STAGE_DIR@/log\nplugin_folder = @ROUTER_STAGE_DIR@/@ROUTER_PLUGIN_DIR_SUFFIX@\nruntime_folder = @ROUTER_STAGE_DIR@/run\nconfig_folder = @ROUTER_STAGE_DIR@/etc\n\n[logger]\nlevel = INFO\n"
  },
  {
    "path": "src/router/tests/mysqlrouter_app.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#define UNIT_TESTS  // used in router_app.h\n#include \"router_config.h\"\n#include \"config_files.h\"\n#include \"dim.h\"\n#include \"mysql/harness/config_parser.h\"\n#include \"mysql/harness/loader.h\"\n#include \"mysql/harness/logging/registry.h\"\n#include \"router_app.h\"\n#include \"mysqlrouter/utils.h\"\n#include \"test/helpers.h\"\n#include \"router_test_helpers.h\"\n\n//ignore GMock warnings\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wsign-conversion\"\n#endif\n\n#include \"gmock/gmock.h\"\n#include \"gtest_consoleoutput.h\"\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n#include <cstdio>\n#include <sstream>\n#include <streambuf>\n#ifndef _WIN32\n#  include <unistd.h>\n#  include <pwd.h>\n#endif\n\n#ifdef __clang__\n// ignore GMock warnings\n#  pragma clang diagnostic push\n#  pragma clang diagnostic ignored \"-Wsign-conversion\"\n#  include \"gmock/gmock.h\"\n#  pragma clang diagnostic pop\n#else\n#  include \"gmock/gmock.h\"\n#endif\n\nusing std::string;\nusing std::vector;\n\nusing ::testing::_;\nusing ::testing::EndsWith;\nusing ::testing::HasSubstr;\nusing ::testing::IsEmpty;\nusing ::testing::Ge;\nusing ::testing::NotNull;\nusing ::testing::Return;\nusing ::testing::SizeIs;\nusing ::testing::StartsWith;\nusing ::testing::StrEq;\n\n#ifndef _WIN32\nusing mysqlrouter::SysUserOperationsBase;\n\nclass MockSysUserOperations: public SysUserOperationsBase {\n public:\n  MOCK_METHOD2(initgroups, int(const char *, gid_type));\n  MOCK_METHOD1(setgid, int(gid_t));\n  MOCK_METHOD1(setuid, int(uid_t));\n  MOCK_METHOD1(setegid, int(gid_t));\n  MOCK_METHOD1(seteuid, int(uid_t));\n  MOCK_METHOD0(geteuid, uid_t());\n  MOCK_METHOD1(getpwnam, struct passwd*(const char *));\n  MOCK_METHOD1(getpwuid, struct passwd*(uid_t));\n  MOCK_METHOD3(chown, int(const char*, uid_t, gid_t));\n};\n\n#endif\n\nusing mysql_harness::Path;\n\nconst string get_cwd() {\n  char buffer[FILENAME_MAX];\n  if (!getcwd(buffer, FILENAME_MAX)) {\n    throw std::runtime_error(\"getcwd failed: \" + string(strerror(errno)));\n  }\n  return string(buffer);\n}\n\nPath g_origin;\nPath g_stage_dir;\n\nclass AppTest : public ::testing::Test {\n\nprotected:\n  virtual void SetUp() {\n    stage_dir = g_stage_dir;\n\n    orig_cout_ = std::cout.rdbuf();\n    std::cout.rdbuf(ssout.rdbuf());\n#ifndef _WIN32\n    mock_sys_user_operations.reset(new MockSysUserOperations());\n#endif\n  }\n\n  virtual void TearDown() {\n    if (orig_cout_) {\n      std::cout.rdbuf(orig_cout_);\n    }\n  }\n\n  void reset_ssout() {\n    ssout.str(\"\");\n    ssout.clear();\n  }\n\n  Path stage_dir;\n  std::stringstream ssout;\n  std::streambuf *orig_cout_;\n\n#ifndef _WIN32\n  std::unique_ptr<MockSysUserOperations> mock_sys_user_operations;\n#endif\n};\n\nTEST_F(AppTest, DefaultConstructor) {\n  MySQLRouter r;\n  ASSERT_STREQ(MYSQL_ROUTER_VERSION, r.get_version().c_str());\n}\n\nTEST_F(AppTest, GetVersionAsString) {\n  MySQLRouter r;\n  ASSERT_STREQ(MYSQL_ROUTER_VERSION, r.get_version().c_str());\n}\n\nTEST_F(AppTest, GetVersionLine) {\n  MySQLRouter r;\n  ASSERT_THAT(r.get_version_line(), StartsWith(MYSQL_ROUTER_PACKAGE_NAME));\n  ASSERT_THAT(r.get_version_line(), HasSubstr(MYSQL_ROUTER_VERSION));\n  ASSERT_THAT(r.get_version_line(), HasSubstr(MYSQL_ROUTER_VERSION_EDITION));\n  ASSERT_THAT(r.get_version_line(), HasSubstr(MYSQL_ROUTER_PACKAGE_PLATFORM));\n  if (MYSQL_ROUTER_PACKAGE_ARCH_64BIT == 1) {\n    ASSERT_THAT(r.get_version_line(), HasSubstr(\"64-bit\"));\n  } else {\n    ASSERT_THAT(r.get_version_line(), HasSubstr(\"32-bit\"));\n  }\n}\n\nTEST_F(AppTest, CheckConfigFilesSuccess) {\n  MySQLRouter r;\n\n  r.default_config_files_ = {};\n  r.extra_config_files_ = { stage_dir.join(\"/etc/mysqlrouter_extra.conf\").str() };\n  ASSERT_THROW(r.check_config_files(), std::runtime_error);\n}\n\nTEST_F(AppTest, CmdLineConfig) {\n  vector<string> argv = {\n      \"--config\", stage_dir.join(\"etc\").join(\"mysqlrouter.conf\").str()\n  };\n  ASSERT_NO_THROW({ MySQLRouter r(g_origin, argv); });\n  MySQLRouter r(g_origin, argv);\n  ASSERT_THAT(r.get_config_files().at(0), EndsWith(\"mysqlrouter.conf\"));\n  ASSERT_THAT(r.get_default_config_files(), IsEmpty());\n  ASSERT_THAT(r.get_extra_config_files(), IsEmpty());\n}\n\nTEST_F(AppTest, CmdLineConfigFailRead) {\n  string not_existing = \"foobar.conf\";\n  vector<string> argv = {\n      \"--config\", stage_dir.join(not_existing).str(),\n  };\n  ASSERT_THROW({ MySQLRouter r(g_origin, argv); }, std::runtime_error);\n  try {\n    MySQLRouter r(g_origin, argv);\n    FAIL() << \"Should throw\";\n  } catch (const std::runtime_error &exc) {\n    EXPECT_THAT(exc.what(), HasSubstr(\"Failed reading configuration file\"));\n    ASSERT_THAT(exc.what(), HasSubstr(not_existing));\n  }\n}\n\nTEST_F(AppTest, CmdLineMultipleConfig) {\n  vector<string> argv = {\n      \"--config\", stage_dir.join(\"etc\").join(\"mysqlrouter.conf\").str(),\n      \"-c\", stage_dir.join(\"etc\").join(\"config_a.conf\").str(),\n      \"--config\", stage_dir.join(\"etc\").join(\"config_b.conf\").str()\n  };\n  ASSERT_THROW({ MySQLRouter r(g_origin, argv); }, std::runtime_error);\n  try {\n    MySQLRouter r(g_origin, argv);\n    FAIL() << \"Should throw\";\n  } catch (const std::runtime_error &exc) {\n    ASSERT_THAT(exc.what(), HasSubstr(\"can only be used once\"));\n  }\n}\n\nTEST_F(AppTest, CmdLineExtraConfig) {\n  vector<string> argv = {\n      \"-c\", stage_dir.join(\"etc\").join(\"config_a.conf\").str(),\n      \"--extra-config\", stage_dir.join(\"etc\").join(\"config_b.conf\").str()\n  };\n  ASSERT_NO_THROW({MySQLRouter r(g_origin, argv);});\n  MySQLRouter r(g_origin, argv);\n  ASSERT_THAT(r.get_extra_config_files().at(0), EndsWith(\"config_b.conf\"));\n  ASSERT_THAT(r.get_default_config_files(), SizeIs(0));\n  ASSERT_THAT(r.get_config_files(), SizeIs(1));\n}\n\nTEST_F(AppTest, CmdLineExtraConfigFailRead) {\n  string not_existing = \"foobar.conf\";\n  vector<string> argv = {\n      \"-c\", stage_dir.join(\"etc\").join(\"config_a.conf\").str(),\n      \"--extra-config\", stage_dir.join(\"etc\").join(not_existing).str()\n  };\n  ASSERT_THROW({ MySQLRouter r(g_origin, argv); }, std::runtime_error);\n  try {\n    MySQLRouter r(g_origin, argv);\n    FAIL() << \"Should throw\";\n  } catch (const std::runtime_error &exc) {\n    EXPECT_THAT(exc.what(), HasSubstr(\"Failed reading configuration file\"));\n    ASSERT_THAT(exc.what(), EndsWith(not_existing));\n  }\n}\n\nTEST_F(AppTest, CmdLineMultipleExtraConfig) {\n  vector<string> argv = {\n      \"-c\", stage_dir.join(\"etc\").join(\"mysqlrouter.conf\").str(),\n      \"-a\", stage_dir.join(\"etc\").join(\"config_a.conf\").str(),\n      \"--extra-config\", stage_dir.join(\"etc\").join(\"config_b.conf\").str()\n  };\n  ASSERT_NO_THROW({MySQLRouter r(g_origin, argv);});\n  MySQLRouter r(g_origin, argv);\n  ASSERT_THAT(r.get_config_files().at(0).c_str(), EndsWith(\"mysqlrouter.conf\"));\n  ASSERT_THAT(r.get_extra_config_files().at(0).c_str(), EndsWith(\"config_a.conf\"));\n  ASSERT_THAT(r.get_extra_config_files().at(1).c_str(), EndsWith(\"config_b.conf\"));\n  ASSERT_THAT(r.get_default_config_files(), SizeIs(0));\n  ASSERT_THAT(r.get_config_files(), SizeIs(1));\n}\n\nTEST_F(AppTest, CmdLineMultipleDuplicateExtraConfig) {\n  string duplicate = \"config_a.conf\";\n  vector<string> argv = {\n      \"-c\", stage_dir.join(\"etc\").join(\"config_a.conf\").str(),\n      \"--extra-config\", stage_dir.join(\"etc\").join(\"mysqlrouter.conf\").str(),\n      \"-a\", stage_dir.join(\"etc\").join(duplicate).str(),\n      \"--extra-config\", stage_dir.join(\"etc\").join(duplicate).str(),\n  };\n  ASSERT_THROW({ MySQLRouter r(g_origin, argv); }, std::runtime_error);\n  try {\n    MySQLRouter r(g_origin, argv);\n    FAIL() << \"Should throw\";\n  } catch (const std::runtime_error &exc) {\n    EXPECT_THAT(exc.what(), HasSubstr(\"Duplicate configuration file\"));\n    ASSERT_THAT(exc.what(), HasSubstr(duplicate));\n  }\n}\n\nTEST_F(AppTest, CmdLineExtraConfigNoDeafultFail) {\n\n  /*\n   * Check if mysqlrouter.conf does not exist in default locations.\n   */\n  std::stringstream ss_line{CONFIG_FILES};\n\n  for (string path; std::getline(ss_line, path, ';');) {\n    // malformed env var will result in error, valid or missing env var results in success\n    bool parse_ok = mysqlrouter::substitute_envvar(path);\n    if (parse_ok) {\n      std::string real_path = mysqlrouter::substitute_variable(path, \"{origin}\", g_origin.str());\n      ASSERT_FALSE(mysql_harness::Path(real_path).exists());\n    }\n  }\n\n  vector<string> argv = {\n      \"--extra-config\", stage_dir.join(\"etc\").join(\"mysqlrouter.conf\").str(),\n  };\n  ASSERT_THROW({ MySQLRouter r(g_origin, argv); }, std::runtime_error);\n  try {\n    MySQLRouter r(g_origin, argv);\n    FAIL() << \"Should throw\";\n  } catch (const std::runtime_error &exc) {\n    EXPECT_THAT(exc.what(), HasSubstr(\"Extra configuration files only work when other \"));\n  }\n}\n\nTEST_F(AppTest, CheckConfigFileFallbackToIniSuccess) {\n  MySQLRouter r;\n\n  r.default_config_files_ = {stage_dir.join(\"etc\").join(\"config_c.conf\").str()};\n  auto res = r.check_config_files();\n  ASSERT_EQ(1u, res.size());\n  ASSERT_THAT(res.at(0), HasSubstr(\"config_c.ini\"));\n}\n\nTEST_F(AppTest, CheckConfigFileFallbackToInNoDefault)\n{\n  // falling back to ini should not work for command line passed configs\n  MySQLRouter r;\n\n  r.config_files_ = {stage_dir.join(\"etc\").join(\"config_c.conf\").str()};\n\n  try {\n    r.check_config_files();\n    FAIL() << \"Should throw\";\n  } catch (const std::runtime_error &exc) {\n    EXPECT_THAT(exc.what(), HasSubstr(\"No valid configuration file\"));\n  }\n}\n\n#ifndef _WIN32\nTEST_F(AppTest, CmdLineUserBeforeBootstrap) {\n  MySQLRouter router;\n  vector<string> arguments = {\n      \"--user\", \"mysqlrouter\",\n      \"--bootstrap\", \"127.0.0.1:5000\"\n  };\n  ASSERT_THROW(router.parse_command_options(arguments), std::runtime_error);\n\n  try {\n    router.parse_command_options(arguments);\n    FAIL() << \"Should throw\";\n  } catch (const std::runtime_error &exc) {\n    EXPECT_THAT(exc.what(), StrEq(\"One can only use the -u/--user switch if running as root\"));\n  }\n}\n\nTEST_F(AppTest, CmdLineUserShortBeforeBootstrap) {\n  MySQLRouter router;\n  vector<string> arguments = {\n      \"-u\", \"mysqlrouter\",\n      \"--bootstrap\", \"127.0.0.1:5000\"\n  };\n  ASSERT_THROW(router.parse_command_options(arguments), std::runtime_error);\n\n  try {\n    router.parse_command_options(arguments);\n    FAIL() << \"Should throw\";\n  } catch (const std::runtime_error &exc) {\n    EXPECT_THAT(exc.what(), HasSubstr(\"One can only use the -u/--user switch if running as root\"));\n  }\n}\n#endif\n\nTEST_F(AppTest, CmdLineVersion) {\n  vector<string> argv = {\"--version\"};\n\n  reset_ssout();\n\n  MySQLRouter r(g_origin, argv);\n  ASSERT_THAT(ssout.str(), StartsWith(r.get_version_line()));\n}\n\nTEST_F(AppTest, CmdLineVersionShort) {\n  vector<string> argv = {\"-V\"};\n\n  reset_ssout();\n\n  MySQLRouter r(g_origin, argv);\n  ASSERT_THAT(ssout.str(), StartsWith(\"MySQL Router\"));\n}\n\nTEST_F(AppTest, CmdLineHelp) {\n  vector<string> argv = {\"--help\"};\n  reset_ssout();\n  MySQLRouter r(g_origin, argv);\n\n  // several substrings from help output that are unlikely to change soon\n  EXPECT_THAT(ssout.str(), HasSubstr(\"MySQL Router v\"));\n  EXPECT_THAT(ssout.str(), HasSubstr(\"Oracle is a registered trademark of Oracle Corporation and/or its\"));\n  EXPECT_THAT(ssout.str(), HasSubstr(\"Usage: mysqlrouter\"));\n}\n\nTEST_F(AppTest, CmdLineHelpShort) {\n  vector<string> argv = {\"-?\"};\n  reset_ssout();\n  MySQLRouter r(g_origin, argv);\n\n  // several substrings from help output that are unlikely to change soon\n  EXPECT_THAT(ssout.str(), HasSubstr(\"MySQL Router v\"));\n  EXPECT_THAT(ssout.str(), HasSubstr(\"Oracle is a registered trademark of Oracle Corporation and/or its\"));\n  EXPECT_THAT(ssout.str(), HasSubstr(\"Usage: mysqlrouter\"));\n}\n\nTEST_F(AppTest, ConfigFileParseError) {\n  vector<string> argv = {\n      \"--config\", stage_dir.join(\"etc\").join(\"parse_error.conf\").str(),\n  };\n  ASSERT_THROW({ MySQLRouter r(g_origin, argv); r.start(); }, std::runtime_error);\n  try {\n    MySQLRouter r(g_origin, argv);\n    r.start();\n    FAIL() << \"Should throw\";\n  } catch (const std::runtime_error &exc) {\n    EXPECT_THAT(exc.what(), HasSubstr(\"Configuration error: Malformed section header:\"));\n  }\n}\n\nTEST_F(AppTest, SectionOverMultipleConfigFiles) {\n  string extra_config = stage_dir.join(\"etc\").join(\"mysqlrouter_extra.conf\").str();\n  vector<string> argv = {\n      \"--config\", stage_dir.join(\"etc\").join(\"mysqlrouter.conf\").str(),\n      \"--extra-config=\" + extra_config\n  };\n  ASSERT_NO_THROW({MySQLRouter r(g_origin, argv);});\n\n  MySQLRouter r(g_origin, argv);\n  ASSERT_THAT(r.get_config_files().at(0).c_str(), EndsWith(\"mysqlrouter.conf\"));\n  ASSERT_THAT(r.get_extra_config_files().at(0).c_str(), EndsWith(\"mysqlrouter_extra.conf\"));\n\n  // let the Loader load the configuration files\n  ASSERT_NO_THROW(r.start());\n\n  auto section = r.loader_->get_config().get(\"magic\", \"\");\n  ASSERT_THAT(section.get(\"foo\"), StrEq(\"bar\"));\n  ASSERT_THROW(section.get(\"NotInTheSection\"), mysql_harness::bad_option);\n}\n\n#ifndef _WIN32\nTEST_F(AppTest, CanStartTrue) {\n  vector<string> argv = {\n      \"--config\", stage_dir.join(\"etc\").join(\"mysqlrouter.conf\").str()\n  };\n  ASSERT_NO_THROW({MySQLRouter r(g_origin, argv);});\n}\n\nTEST_F(AppTest, CanStartFalse) {\n  vector<vector<string> > cases = {\n      {\"\"},\n  };\n  for(auto &argv: cases) {\n    ASSERT_THROW({MySQLRouter r(g_origin, argv); r.start();}, std::runtime_error);\n  }\n}\n\n/*\n * We don't switch user for windows\n */\n#ifndef _WIN32\n\n/**\n * @test\n *       Verify that if --user/-u option is used, then user is switched before logger\n *       is initialized.\n */\nTEST_F(AppTest, SetCommandLineUserBeforeInitializingLogger) {\n  const char* user = \"mysqlrouter\";\n\n  vector<string> argv = {\n      \"--config\", stage_dir.join(\"etc\").join(\"mysqlrouter.conf\").str(),\n      \"--extra-config=\" + stage_dir.join(\"etc\").join(\"mysqlrouter_extra.conf\").str(),\n      \"--user=\" + std::string(user)\n  };\n\n  // set empty Registry (is_ready() return false)\n  std::unique_ptr<mysql_harness::logging::Registry> registry(new mysql_harness::logging::Registry());\n  mysql_harness::DIM::instance().set_LoggingRegistry([&registry](){ return registry.release(); },\n                                      std::default_delete<mysql_harness::logging::Registry>());\n  mysql_harness::DIM::instance().reset_LoggingRegistry();\n\n  struct passwd user_info;\n  user_info.pw_gid = 12; user_info.pw_uid = 17;\n\n  EXPECT_CALL(*mock_sys_user_operations, geteuid()).Times(1).WillOnce(Return(0));\n  EXPECT_CALL(*mock_sys_user_operations, getpwnam(StrEq(user))).Times(1).WillOnce(Return(&user_info));\n  EXPECT_CALL(*mock_sys_user_operations, initgroups(StrEq(user), (SysUserOperationsBase::gid_type)user_info.pw_gid)).Times(1);\n  EXPECT_CALL(*mock_sys_user_operations, setgid(user_info.pw_gid)).Times(1).WillOnce(Return(0));\n  EXPECT_CALL(*mock_sys_user_operations, setuid(user_info.pw_uid)).Times(1).WillOnce(\n      testing::DoAll(\n          testing::InvokeWithoutArgs(\n              [&] {\n                ASSERT_FALSE(mysql_harness::DIM::instance().get_LoggingRegistry().is_ready());\n              }), (Return(0))));\n\n  MySQLRouter r(g_origin, argv, mock_sys_user_operations.get());\n  ASSERT_NO_THROW(r.start());\n}\n\n/**\n * @test\n *       Verify that if --user/-u option is used, then user is switched before logger\n *       is initialized.\n */\nTEST_F(AppTest, SetConfigUserBeforeInitializingLogger) {\n  const char* user = \"mysqlrouter\";\n\n  std::string tmp_dir = mysql_harness::get_tmp_dir(\"AppTest\");\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){mysql_harness::delete_dir_recursive(tmp_dir);});\n\n  // copy config file and add user option to [DEFAULT] section\n  {\n    std::ofstream destination_stream(mysql_harness::Path(tmp_dir).join(\"mysqlrouter.conf\").str());\n    std::ifstream source_stream(stage_dir.join(\"etc\").join(\"mysqlrouter.conf\").str());\n\n    std::string line;\n    while(source_stream.good() && destination_stream.good()) {\n      getline(source_stream, line);\n      destination_stream << line << std::endl;\n      if (line.find(\"DEFAULT]\") != line.npos)\n        destination_stream << \"user=\" << std::string(user) << std::endl;\n    }\n  }\n\n  vector<string> argv = {\n      \"--config\", mysql_harness::Path(tmp_dir).join(\"mysqlrouter.conf\").str(),\n      \"--extra-config=\" + stage_dir.join(\"etc\").join(\"mysqlrouter_extra.conf\").str()\n  };\n\n  // set empty Registry (is_ready() return false)\n  std::unique_ptr<mysql_harness::logging::Registry> registry(new mysql_harness::logging::Registry());\n  mysql_harness::DIM::instance().set_LoggingRegistry([&registry](){ return registry.release(); },\n                                      std::default_delete<mysql_harness::logging::Registry>());\n  mysql_harness::DIM::instance().reset_LoggingRegistry();\n\n  struct passwd user_info;\n  user_info.pw_gid = 12; user_info.pw_uid = 17;\n\n  EXPECT_CALL(*mock_sys_user_operations, geteuid()).Times(1).WillOnce(Return(0));\n  EXPECT_CALL(*mock_sys_user_operations, getpwnam(StrEq(user))).Times(1).WillOnce(Return(&user_info));\n  EXPECT_CALL(*mock_sys_user_operations, initgroups(StrEq(user), (SysUserOperationsBase::gid_type)user_info.pw_gid)).Times(1);\n  EXPECT_CALL(*mock_sys_user_operations, setgid(user_info.pw_gid)).Times(1).WillOnce(Return(0));\n  EXPECT_CALL(*mock_sys_user_operations, setuid(user_info.pw_uid)).Times(1).WillOnce(\n      testing::DoAll(\n          testing::InvokeWithoutArgs(\n              [&] {\n                ASSERT_FALSE(mysql_harness::DIM::instance().get_LoggingRegistry().is_ready());\n              }), (Return(0))));\n\n  MySQLRouter r(g_origin, argv, mock_sys_user_operations.get());\n  ASSERT_NO_THROW(r.start());\n}\n\n#endif\n\nTEST_F(AppTest, ShowingInfoTrue) {\n\n  vector<vector<string> > cases = {\n      {\"--version\"},\n      {\"--help\"},\n      {\"--help\", \"--config\", stage_dir.join(\"etc\").join(\"mysqlrouter.conf\").str()},\n      {\"--config\", stage_dir.join(\"etc\").join(\"mysqlrouter.conf\").str(), \"--help\"},\n  };\n\n  // Make sure we do not start when showing information\n  for(auto &argv: cases) {\n    ASSERT_NO_THROW({MySQLRouter r(g_origin, argv); r.start();});\n    ASSERT_THAT(ssout.str(), HasSubstr(\"MySQL Router v\"));\n    reset_ssout();\n  }\n}\n\nTEST_F(AppTest, ShowingInfoFalse) {\n  // Cases should be allowing Router to start\n  vector<vector<string> > cases = {\n      {\"--config\", stage_dir.join(\"etc\").join(\"mysqlrouter.conf\").str(),\n       \"--extra-config=\" + stage_dir.join(\"etc\").join(\"mysqlrouter_extra.conf\").str()}\n  };\n\n  for(auto &argv: cases) {\n    ASSERT_NO_THROW({MySQLRouter r(g_origin, argv); r.start();});\n  }\n}\n\nTEST_F(AppTest, UserSetPermanentlyByName) {\n  const char* USER = \"mysqluser\";\n\n  struct passwd user_info;\n  user_info.pw_gid = 12; user_info.pw_uid = 17;\n\n  EXPECT_CALL(*mock_sys_user_operations, geteuid()).Times(1).WillOnce(Return(0));\n  EXPECT_CALL(*mock_sys_user_operations, getpwnam(StrEq(USER))).Times(1).WillOnce(Return(&user_info));\n  EXPECT_CALL(*mock_sys_user_operations, initgroups(StrEq(USER), (SysUserOperationsBase::gid_type)user_info.pw_gid)).Times(1);\n  EXPECT_CALL(*mock_sys_user_operations, setgid(user_info.pw_gid)).Times(1).WillOnce(Return(0));\n  EXPECT_CALL(*mock_sys_user_operations, setuid(user_info.pw_uid)).Times(1).WillOnce(Return(0));\n\n  ASSERT_NO_THROW({set_user(USER, true, mock_sys_user_operations.get());});\n}\n\nTEST_F(AppTest, UserSetPermanentlyById) {\n  const char* USER = \"1234\";\n\n  struct passwd user_info;\n  user_info.pw_gid = 12; user_info.pw_uid = 17;\n\n  EXPECT_CALL(*mock_sys_user_operations, geteuid()).Times(1).WillOnce(Return(0));\n  EXPECT_CALL(*mock_sys_user_operations, getpwnam(StrEq(USER))).Times(1).WillOnce(Return(nullptr));\n  EXPECT_CALL(*mock_sys_user_operations, getpwuid((uid_t)atoi(USER))).Times(1).WillOnce(Return(&user_info));\n  EXPECT_CALL(*mock_sys_user_operations, initgroups(StrEq(USER), (SysUserOperationsBase::gid_type)user_info.pw_gid)).Times(1);\n  EXPECT_CALL(*mock_sys_user_operations, setgid(user_info.pw_gid)).Times(1).WillOnce(Return(0));\n  EXPECT_CALL(*mock_sys_user_operations, setuid(user_info.pw_uid)).Times(1).WillOnce(Return(0));\n\n\n  ASSERT_NO_THROW({set_user(USER, true, mock_sys_user_operations.get());});\n}\n\nTEST_F(AppTest, UserSetPermanentlyByNotExistingId) {\n  const char* USER = \"124\";\n\n  EXPECT_CALL(*mock_sys_user_operations, geteuid()).Times(1).WillOnce(Return(0));\n  EXPECT_CALL(*mock_sys_user_operations, getpwnam(StrEq(USER))).Times(1).WillOnce(Return(nullptr));\n  EXPECT_CALL(*mock_sys_user_operations, getpwuid((uid_t)atoi(USER))).Times(1).WillOnce(Return(nullptr));\n\n  try {\n    set_user(USER, true, mock_sys_user_operations.get());\n    FAIL() << \"Should throw\";\n  } catch (const std::runtime_error &exc) {\n    EXPECT_THAT(exc.what(), StrEq(\"Can't use user '124'. \"\n                                  \"Please check that the user exists!\"));\n  }\n}\n\nTEST_F(AppTest, UserSetPermanentlyByNotExistingName) {\n  const char* USER = \"124name\";\n\n  EXPECT_CALL(*mock_sys_user_operations, geteuid()).Times(1).WillOnce(Return(0));\n  EXPECT_CALL(*mock_sys_user_operations, getpwnam(StrEq(USER))).Times(1).WillOnce(Return(nullptr));\n\n  try {\n    set_user(USER, true, mock_sys_user_operations.get());\n    FAIL() << \"Should throw\";\n  } catch (const std::runtime_error &exc) {\n    EXPECT_THAT(exc.what(), StrEq(\"Can't use user '124name'. \"\n                                  \"Please check that the user exists!\"));\n  }\n}\n\nTEST_F(AppTest, UserSetPermanentlyByNonRootUser) {\n  const char* USER = \"mysqlrouter\";\n\n  EXPECT_CALL(*mock_sys_user_operations, geteuid()).Times(1).WillOnce(Return(1));\n  EXPECT_CALL(*mock_sys_user_operations, getpwnam(StrEq(USER))).Times(1).WillOnce(Return(nullptr));\n\n  try {\n    set_user(USER, true, mock_sys_user_operations.get());\n    FAIL() << \"Should throw\";\n  } catch (const std::runtime_error &exc) {\n    EXPECT_THAT(exc.what(), StrEq(\"One can only use the -u/--user switch if running as root\"));\n  }\n}\n\nTEST_F(AppTest, UserSetPermanentlySetEGidFails) {\n  const char* USER = \"mysqlrouter\";\n\n  struct passwd user_info;\n  user_info.pw_gid = 12; user_info.pw_uid = 17;\n\n  EXPECT_CALL(*mock_sys_user_operations, geteuid()).Times(1).WillOnce(Return(0));\n  EXPECT_CALL(*mock_sys_user_operations, getpwnam(StrEq(USER))).Times(1).WillOnce(Return(&user_info));\n  EXPECT_CALL(*mock_sys_user_operations, initgroups(StrEq(USER), (SysUserOperationsBase::gid_type)user_info.pw_gid)).Times(1);\n  EXPECT_CALL(*mock_sys_user_operations, setgid(user_info.pw_gid)).Times(1).WillOnce(Return(-1));\n\n  try {\n    set_user(USER, true, mock_sys_user_operations.get());\n    FAIL() << \"Should throw\";\n  } catch (const std::runtime_error &exc) {\n    EXPECT_THAT(exc.what(), StartsWith(\"Error trying to set the user. setgid failed:\"));\n  }\n}\n\nTEST_F(AppTest, UserSetPermanentlySetEUidFails) {\n  const char* USER = \"mysqlrouter\";\n\n  struct passwd user_info;\n  user_info.pw_gid = 12; user_info.pw_uid = 17;\n\n  EXPECT_CALL(*mock_sys_user_operations, geteuid()).Times(1).WillOnce(Return(0));\n  EXPECT_CALL(*mock_sys_user_operations, getpwnam(StrEq(USER))).Times(1).WillOnce(Return(&user_info));\n  EXPECT_CALL(*mock_sys_user_operations, initgroups(StrEq(USER), (SysUserOperationsBase::gid_type)user_info.pw_gid)).Times(1);\n  EXPECT_CALL(*mock_sys_user_operations, setgid(user_info.pw_gid)).Times(1).WillOnce(Return(0));\n  EXPECT_CALL(*mock_sys_user_operations, setuid(user_info.pw_uid)).Times(1).WillOnce(Return(-1));\n\n  try {\n    set_user(USER, true, mock_sys_user_operations.get());\n    FAIL() << \"Should throw\";\n  } catch (const std::runtime_error &exc) {\n    EXPECT_THAT(exc.what(), StartsWith(\"Error trying to set the user. setuid failed:\"));\n  }\n}\n\nTEST_F(AppTest, UserSetByName) {\n  const char* USER = \"mysqluser\";\n\n  struct passwd user_info;\n  user_info.pw_gid = 12; user_info.pw_uid = 17;\n\n  EXPECT_CALL(*mock_sys_user_operations, getpwnam(StrEq(USER))).Times(1).WillOnce(Return(&user_info));\n  EXPECT_CALL(*mock_sys_user_operations, initgroups(StrEq(USER), (SysUserOperationsBase::gid_type)user_info.pw_gid)).Times(1);\n  EXPECT_CALL(*mock_sys_user_operations, setegid(user_info.pw_gid)).Times(1).WillOnce(Return(0));\n  EXPECT_CALL(*mock_sys_user_operations, seteuid(user_info.pw_uid)).Times(1).WillOnce(Return(0));\n\n  ASSERT_NO_THROW({set_user(USER, false, mock_sys_user_operations.get());});\n}\n\nTEST_F(AppTest, UserSetById) {\n  const char* USER = \"1234\";\n\n  struct passwd user_info;\n  user_info.pw_gid = 12; user_info.pw_uid = 17;\n\n  EXPECT_CALL(*mock_sys_user_operations, getpwnam(StrEq(USER))).Times(1).WillOnce(Return(nullptr));\n  EXPECT_CALL(*mock_sys_user_operations, getpwuid((uid_t)atoi(USER))).Times(1).WillOnce(Return(&user_info));\n  EXPECT_CALL(*mock_sys_user_operations, initgroups(StrEq(USER), (SysUserOperationsBase::gid_type)user_info.pw_gid)).Times(1);\n  EXPECT_CALL(*mock_sys_user_operations, setegid(user_info.pw_gid)).Times(1).WillOnce(Return(0));\n  EXPECT_CALL(*mock_sys_user_operations, seteuid(user_info.pw_uid)).Times(1).WillOnce(Return(0));\n\n  ASSERT_NO_THROW({set_user(USER, false, mock_sys_user_operations.get());});\n}\n\nTEST_F(AppTest, UserSetByNotExistingId) {\n  const char* USER = \"124\";\n\n  EXPECT_CALL(*mock_sys_user_operations, getpwnam(StrEq(USER))).Times(1).WillOnce(Return(nullptr));\n  EXPECT_CALL(*mock_sys_user_operations, getpwuid((uid_t)atoi(USER))).Times(1).WillOnce(Return(nullptr));\n\n  try {\n    set_user(USER, false, mock_sys_user_operations.get());\n    FAIL() << \"Should throw\";\n  } catch (const std::runtime_error &exc) {\n    EXPECT_THAT(exc.what(), StrEq(\"Can't use user '124'. \"\n                                  \"Please check that the user exists!\"));\n  }\n}\n\nTEST_F(AppTest, UserSetByNotExistingName) {\n  const char* USER = \"124name\";\n\n  EXPECT_CALL(*mock_sys_user_operations, getpwnam(StrEq(USER))).Times(1).WillOnce(Return(nullptr));\n\n  try {\n    set_user(USER, false, mock_sys_user_operations.get());\n    FAIL() << \"Should throw\";\n  } catch (const std::runtime_error &exc) {\n    EXPECT_THAT(exc.what(), StrEq(\"Can't use user '124name'. \"\n                                  \"Please check that the user exists!\"));\n  }\n}\n\nTEST_F(AppTest, UserSetSetGidFails) {\n  const char* USER = \"mysqlrouter\";\n\n  struct passwd user_info;\n  user_info.pw_gid = 12; user_info.pw_uid = 17;\n\n  EXPECT_CALL(*mock_sys_user_operations, getpwnam(StrEq(USER))).Times(1).WillOnce(Return(&user_info));\n  EXPECT_CALL(*mock_sys_user_operations, initgroups(StrEq(USER), (SysUserOperationsBase::gid_type)user_info.pw_gid)).Times(1);\n  EXPECT_CALL(*mock_sys_user_operations, setegid(user_info.pw_gid)).Times(1).WillOnce(Return(-1));\n\n  try {\n    set_user(USER, false, mock_sys_user_operations.get());\n    FAIL() << \"Should throw\";\n  } catch (const std::runtime_error &exc) {\n    EXPECT_THAT(exc.what(), StartsWith(\"Error trying to set the user. setegid failed:\"));\n  }\n}\n\nTEST_F(AppTest, UserSetSetUidFails) {\n  const char* USER = \"mysqlrouter\";\n\n  struct passwd user_info;\n  user_info.pw_gid = 12; user_info.pw_uid = 17;\n\n  EXPECT_CALL(*mock_sys_user_operations, getpwnam(StrEq(USER))).Times(1).WillOnce(Return(&user_info));\n  EXPECT_CALL(*mock_sys_user_operations, initgroups(StrEq(USER), (SysUserOperationsBase::gid_type)user_info.pw_gid)).Times(1);\n  EXPECT_CALL(*mock_sys_user_operations, setegid(user_info.pw_gid)).Times(1).WillOnce(Return(0));\n  EXPECT_CALL(*mock_sys_user_operations, seteuid(user_info.pw_uid)).Times(1).WillOnce(Return(-1));\n\n  try {\n    set_user(USER, false, mock_sys_user_operations.get());\n    FAIL() << \"Should throw\";\n  } catch (const std::runtime_error &exc) {\n    EXPECT_THAT(exc.what(), StartsWith(\"Error trying to set the user. seteuid failed:\"));\n  }\n}\n\nTEST_F(AppTest, BootstrapSuperuserNoUserOption) {\n  vector<string> argv = {\n    \"--bootstrap\", \"127.0.0.1:3060\"\n  };\n\n  EXPECT_CALL(*mock_sys_user_operations, geteuid()).Times(1).WillOnce(Return(0));\n\n  try {\n    MySQLRouter r(g_origin, argv, mock_sys_user_operations.get());\n    FAIL() << \"Should throw\";\n  } catch (const std::runtime_error &exc) {\n    EXPECT_THAT(exc.what(), StartsWith(\"You are bootstraping as a superuser.\"));\n  }\n}\n\n/**\n * @test\n *      Verify that std::runtime_error is thrown when --master-key-reader option is used\n *      in non-bootstrap mode.\n */\nTEST_F(AppTest, ThrowWhenMasterKeyReaderUsedWithoutBootstrap) {\n  vector<string> argv = { \"--master-key-reader=reader.sh\" };\n  ASSERT_THROW_LIKE(MySQLRouter(g_origin, argv, mock_sys_user_operations.get()), std::runtime_error,\n      \"Option --master-key-reader can only be used together with -B/--bootstrap\");\n}\n\n/**\n * @test\n *       Verify that std::runtime_error is thrown when --master_key-writer option is used\n *       in non-bootstrap mode.\n */\nTEST_F(AppTest, ThrowWhenMasterKeyWriterUsedWithoutBootstrap) {\n  vector<string> argv = { \"--master-key-writer=writer.sh\" };\n  ASSERT_THROW_LIKE(MySQLRouter(g_origin, argv, mock_sys_user_operations.get()), std::runtime_error,\n      \"Option --master-key-writer can only be used together with -B/--bootstrap\");\n}\n\n/**\n * @test\n *       Verify that std::runtime_error is thrown when --master-key-reader option is used\n *       without value.\n */\nTEST_F(AppTest, ThrowWhenMasterKeyReaderUsedWithoutValue) {\n  vector<string> argv = { \"--bootstrap\", \"127.0.0.1:3060\", \"--master-key-reader\" };\n  ASSERT_THROW_LIKE(MySQLRouter(g_origin, argv, mock_sys_user_operations.get()), std::runtime_error,\n      \"option '--master-key-reader' requires a value.\");\n}\n\n/**\n * @test\n *       Verify that std::runtime_error is thrown when --master-key-writer option is used\n *       without value.\n */\nTEST_F(AppTest, ThrowWhenMasterKeyWriterUsedWithoutValue) {\n  vector<string> argv = { \"--bootstrap\", \"127.0.0.1:3060\", \"--master-key-writer\" };\n  ASSERT_THROW_LIKE(MySQLRouter(g_origin, argv, mock_sys_user_operations.get()), std::runtime_error,\n      \"option '--master-key-writer' requires a value.\");\n}\n\n/**\n * @test\n *       Verify that std::runtime_error is throw when --master-key-reader option is used\n *       without using --master-key-writer option.\n */\nTEST_F(AppTest, ThrowWhenMasterKeyReaderUsedWithoutMasterKeyWriter) {\n  vector<string> argv = { \"--bootstrap\", \"127.0.0.1:3060\", \"--master-key-reader=reader.sh\" };\n  ASSERT_THROW_LIKE(MySQLRouter(g_origin, argv, mock_sys_user_operations.get()), std::runtime_error,\n      \"Option --master-key-reader can only be used together with --master-key-writer.\");\n}\n\n/**\n * @test\n *       Verify that std::runtime_error is thrown when --master-key-writer option is used\n *       without using --master-key-reader option.\n */\nTEST_F(AppTest, ThrowWhenMasterKeyWriterUsedWithoutMasterKeyReader) {\n  vector<string> argv = { \"--bootstrap\", \"127.0.0.1:3060\", \"--master-key-writer=writer.sh\" };\n  ASSERT_THROW_LIKE(MySQLRouter(g_origin, argv, mock_sys_user_operations.get()), std::runtime_error,\n      \"Option --master-key-writer can only be used together with --master-key-reader.\");\n}\n\n#endif // #ifndef _WIN32\n\nclass AppLoggerTest : public ConsoleOutputTest {\n protected:\n  void SetUp() override {\n    set_origin(g_origin);\n    ConsoleOutputTest::SetUp();\n  }\n};\n\nTEST_F(AppLoggerTest, TestLogger) {\n  // This test verifies that:\n  // - setting log level works (by overriding the default)\n  // - a logger is created for each of: main exec and all plugins\n\n  // create config file\n  Path config_path(g_origin.str());\n  config_path.append(\"test_mysqlrouter_app.conf\");\n  std::ofstream ofs_config(config_path.str());\n  if (ofs_config.good()) {\n    ofs_config << \"[DEFAULT]\\n\";\n    ofs_config << \"logging_folder =\\n\";\n    ofs_config << \"plugin_folder = \" << plugin_dir->str() << \"\\n\";\n    ofs_config << \"runtime_folder = \" << stage_dir->str() << \"\\n\";\n    ofs_config << \"config_folder = \" << stage_dir->str() << \"\\n\";\n    ofs_config << \"\\n\";\n    ofs_config << \"[logger]\\n\";\n    ofs_config << \"level = DEBUG\\n\";      // override the default (WARNING)\n    ofs_config << \"\\n\";\n    ofs_config << \"[magic]\\n\";            // magic plugin\n    ofs_config << \"do_magic = yes\\n\";\n    ofs_config << \"message = It is some kind of magic\\n\";\n    ofs_config << \"\\n\";\n    ofs_config << \"[lifecycle3]\\n\";           // lifecycle3 plugin (lifecycle dependency)\n    ofs_config << \"[lifecycle:instance1]\\n\";  // lifecycle plugin\n    ofs_config.close();\n  } else {\n    throw std::runtime_error(\"Failed creating config file '\" + config_path.str() + \"'\");\n  }\n\n  // run MySQLRouter\n  reset_ssout();\n  vector<string> argv = {\"-c\", config_path.c_str()};\n  MySQLRouter r(g_origin, argv);\n  ASSERT_NO_THROW(r.start());\n\n  // verify that all plugins have a module registered with the logger\n  auto loggers = mysql_harness::DIM::instance().get_LoggingRegistry().get_logger_names();\n  EXPECT_THAT(loggers, testing::UnorderedElementsAre(\n      mysql_harness::logging::kMainLogger, \"magic\", \"lifecycle\", \"lifecycle3\", \"sql\"));\n\n  // verify the log contains what we expect it to contain. We're looking for lines like this:\n  {\n    // 2017-05-03 11:30:23 main DEBUG [7ffff7fd4780] Main logger initialized, logging to STDERR\n    EXPECT_THAT(get_log_stream().str(), HasSubstr(\" main DEBUG \"));\n    EXPECT_THAT(get_log_stream().str(), HasSubstr(\" Main logger initialized, logging to STDERR\"));\n\n    // 2017-05-03 11:30:25 magic INFO [7ffff5e34700] It is some kind of magic\n    EXPECT_THAT(get_log_stream().str(), HasSubstr(\" magic INFO \"));\n    EXPECT_THAT(get_log_stream().str(), HasSubstr(\" It is some kind of magic\"));\n\n    // 2017-05-03 11:30:25 lifecycle INFO [7faefa705780] lifecycle:all init():begin\n    EXPECT_THAT(get_log_stream().str(), HasSubstr(\" lifecycle INFO \"));\n    EXPECT_THAT(get_log_stream().str(), HasSubstr(\" lifecycle:all init():begin\"));\n  }\n}\n\nTEST_F(AppTest, EmptyConfigPath) {\n  vector<string> argv = {\n      \"--config\", \"\"\n  };\n  EXPECT_THROW({ MySQLRouter r(g_origin, argv); },\n      std::runtime_error);\n}\n\n\nint main(int argc, char *argv[]) {\n  g_origin = Path(argv[0]).dirname();\n\n  if (char *stage_dir_env = std::getenv(\"STAGE_DIR\")) {\n    g_stage_dir = Path(stage_dir_env).real_path();\n  } else {\n    // try a few places\n    g_stage_dir = Path(get_cwd()).join(\"..\").join(\"..\").join(\"stage\");\n    if (!g_stage_dir.is_directory()) {\n      g_stage_dir = Path(get_cwd()).join(\"stage\");\n    }\n  }\n#ifdef CMAKE_INTDIR\n  g_stage_dir = g_stage_dir.join(g_origin.basename());\n#endif\n\n  if (!g_stage_dir.is_directory()) {\n    std::cout << \"Stage dir not valid (was \" << g_stage_dir << \"; can use STAGE_DIR env var)\" << std::endl;\n    return -1;\n  }\n\n  register_test_logger();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/router/tests/mysqlrouter_consolelogger.conf.in",
    "content": "[DEFAULT]\nlogging_folder =\nplugin_folder = @ROUTER_STAGE_DIR@/@ROUTER_PLUGIN_DIR_SUFFIX@\nruntime_folder = @ROUTER_STAGE_DIR@/run\nconfig_folder = @ROUTER_STAGE_DIR@/etc\n\n[logger]\nlibrary = logger\n"
  },
  {
    "path": "src/router/tests/mysqlrouter_extra.conf.in",
    "content": "[magic]\nfoo = bar\n"
  },
  {
    "path": "src/router/tests/mysqlrouter_nologger.conf.in",
    "content": "[DEFAULT]\nlogging_folder = @ROUTER_STAGE_DIR@/log\nplugin_folder = @ROUTER_STAGE_DIR@/@ROUTER_PLUGIN_DIR_SUFFIX@\nruntime_folder = @ROUTER_STAGE_DIR@/run\nconfig_folder = @ROUTER_STAGE_DIR@/etc\n"
  },
  {
    "path": "src/router/tests/mysqlrouter_utils.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/*\n * Test free functions found in utils.cc\n */\n\n#include \"gtest/gtest.h\"\n#include \"gmock/gmock.h\"\n\n#include <cstdlib>\n\n#include \"mysqlrouter/utils.h\"\n\nusing std::string;\n\nusing mysqlrouter::substitute_envvar;\nusing mysqlrouter::wrap_string;\n\nusing ::testing::StrEq;\nusing ::testing::ContainerEq;\n\n\nclass SubstituteEnvVarTest : public ::testing::Test {\nprotected:\n  virtual void SetUp() {\n    static char env[64];\n\n    snprintf ( env, sizeof(env), \"%s=%s\", env_name.c_str(), env_value.c_str() );\n    putenv(env);\n  }\n  string env_name {\"MYRTEST_ENVAR\"};\n  string env_value {\"MySQLRouterTest\"};\n};\n\nclass WrapStringTest : public ::testing::Test {\nprotected:\n  virtual void SetUp() {\n  }\n  string one_line {\n    \"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ac tempor ligula. Curabitur imperdiet sem eget \"\n    \"tincidunt viverra. Integer lacinia, velit vel aliquam finibus, dui turpis aliquet leo, pharetra finibus neque \"\n    \"elit id sapien. Nunc hendrerit ut felis nec gravida. Proin a mi id ligula pharetra pulvinar ut in sapien. \"\n    \"Cras lorem libero, mollis consectetur leo et, sollicitudin scelerisque mauris. Nunc semper dignissim libero, \"\n    \"vitae ullamcorper arcu luctus eu.\"\n  };\n  string with_newlines {\n    \"Lorem ipsum dolor sit amet, consectetur adipiscing elit.\\nUt ac tempor ligula. Curabitur imperdiet sem eget \"\n    \"tincidunt viverra. Integer lacinia, velit\\nvel aliquam finibus, dui turpis aliquet leo, pharetra finibus neque \"\n    \"elit id sapien. Nunc hendrerit ut felis nec\\ngravida. Proin a mi id ligula pharetra pulvinar ut in sapien. \"\n    \"Cras lorem libero, mollis consectetur\\nleo et, sollicitudin scelerisque mauris. Nunc semper dignissim libero, \"\n    \"vitae ullamcorper arcu luctus\\neu.\"\n  };\n\n  string short_line_less72 {\n    \"Lorem ipsum dolor sit amet, consectetur adipiscing elit.\"\n  };\n\n  string custom_indents {\n    \"           Lorem ipsum dolor      sit amet,\\n\"\n    \"           consectetur adipiscing elit.\"\n  };\n};\n\nclass StringFormatTest : public ::testing::Test {\nprotected:\n  virtual void SetUp() {\n  }\n};\n\n/*! \\brief Tests mysqlrouter::substitute_envvar()\n *\n */\n\nTEST_F(SubstituteEnvVarTest, Simple)\n{\nstring exp {env_value};\nstring test {\"ENV{\" + env_name + \"}\"};\nsubstitute_envvar(test);\nASSERT_STREQ(exp.c_str(), test.c_str());\n}\n\nTEST_F(SubstituteEnvVarTest, SimpleMiddleOfString)\n{\n  string exp {\"ham/\" + env_value + \"/spam\"};\n  string test {\"ham/ENV{\" + env_name + \"}/spam\"};\n  bool ok = substitute_envvar(test);\n\n  ASSERT_TRUE(ok);\n  ASSERT_STREQ(exp.c_str(), test.c_str());\n}\n\nTEST_F(SubstituteEnvVarTest, NoPlaceholder)\n{\n  string test {\"hamspam\"};\n  bool ok = substitute_envvar(test);  // nothing to do -> ok, just a no-op\n\n  ASSERT_TRUE(ok);\n  ASSERT_STREQ(\"hamspam\", test.c_str());  // no error, value should be left intact\n}\n\nTEST_F(SubstituteEnvVarTest, UnclosedPlaceholder)\n{\n  string test {\"hamENV{\" + env_name + \"spam\"};\n  bool ok = substitute_envvar(test);\n\n  ASSERT_FALSE(ok);\n  // value of test is now undefined\n}\n\nTEST_F(SubstituteEnvVarTest, EmptyVariableName)\n{\n  string test {\"hamENV{}spam\"};\n  bool ok = substitute_envvar(test);\n\n  ASSERT_FALSE(ok);\n  // value of test is now undefined\n}\n\nTEST_F(SubstituteEnvVarTest, UnknownEnvironmentVariable)\n{\n  string unknown_name {\"UNKNOWN_VARIABLE_12343xyzYEKfk\"};\n  string test {\"hamENV{\" + unknown_name + \"}spam\"};\n  bool ok = substitute_envvar(test);\n\n  ASSERT_FALSE(ok);\n  // value of test is now undefined\n}\n\n/*\n * Tests mysqlrouter::wrap_string()\n */\n\nTEST_F(WrapStringTest, ShortLine)\n{\n  std::vector<string> lines = wrap_string(short_line_less72, 72, 0);\n\n  std::vector<string> exp {short_line_less72};\n  ASSERT_THAT(lines, ContainerEq(exp));\n}\n\nTEST_F(WrapStringTest, OneLine72width)\n{\n  std::vector<string> lines = wrap_string(one_line, 72, 0);\n\n  std::vector<string> exp {\n    \"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ac tempor\",\n    \"ligula. Curabitur imperdiet sem eget tincidunt viverra. Integer lacinia,\",\n    \"velit vel aliquam finibus, dui turpis aliquet leo, pharetra finibus\",\n    \"neque elit id sapien. Nunc hendrerit ut felis nec gravida. Proin a mi id\",\n    \"ligula pharetra pulvinar ut in sapien. Cras lorem libero, mollis\",\n    \"consectetur leo et, sollicitudin scelerisque mauris. Nunc semper\",\n    \"dignissim libero, vitae ullamcorper arcu luctus eu.\",\n  };\n\n  ASSERT_THAT(lines, ContainerEq(exp));\n}\n\nTEST_F(WrapStringTest, OneLine72widthIndent4)\n{\n  std::vector<string> lines = wrap_string(one_line, 72, 4);\n\n  std::vector<string> exp {\n    \"    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ac\",\n    \"    tempor ligula. Curabitur imperdiet sem eget tincidunt viverra.\",\n    \"    Integer lacinia, velit vel aliquam finibus, dui turpis aliquet leo,\",\n    \"    pharetra finibus neque elit id sapien. Nunc hendrerit ut felis nec\",\n    \"    gravida. Proin a mi id ligula pharetra pulvinar ut in sapien. Cras\",\n    \"    lorem libero, mollis consectetur leo et, sollicitudin scelerisque\",\n    \"    mauris. Nunc semper dignissim libero, vitae ullamcorper arcu luctus\",\n    \"    eu.\",\n  };\n\n  ASSERT_THAT(lines, ContainerEq(exp));\n}\n\nTEST_F(WrapStringTest, RespectNewLine)\n{\n  std::vector<string> lines = wrap_string(with_newlines, 80, 0);\n\n  std::vector<string> exp {\n    \"Lorem ipsum dolor sit amet, consectetur adipiscing elit.\",\n    \"Ut ac tempor ligula. Curabitur imperdiet sem eget tincidunt viverra. Integer\",\n    \"lacinia, velit\",\n    \"vel aliquam finibus, dui turpis aliquet leo, pharetra finibus neque elit id\",\n    \"sapien. Nunc hendrerit ut felis nec\",\n    \"gravida. Proin a mi id ligula pharetra pulvinar ut in sapien. Cras lorem libero,\",\n    \"mollis consectetur\",\n    \"leo et, sollicitudin scelerisque mauris. Nunc semper dignissim libero, vitae\",\n    \"ullamcorper arcu luctus\",\n    \"eu.\",\n  };\n\n  ASSERT_THAT(lines, ContainerEq(exp));\n}\n\nTEST_F(WrapStringTest, RespectNewLineIndent2)\n{\n  std::vector<string> lines = wrap_string(with_newlines, 60, 2);\n\n  std::vector<string> exp {\n      \"  Lorem ipsum dolor sit amet, consectetur adipiscing elit.\",\n      \"  Ut ac tempor ligula. Curabitur imperdiet sem eget\",\n      \"  tincidunt viverra. Integer lacinia, velit\",\n      \"  vel aliquam finibus, dui turpis aliquet leo, pharetra\",\n      \"  finibus neque elit id sapien. Nunc hendrerit ut felis nec\",\n      \"  gravida. Proin a mi id ligula pharetra pulvinar ut in\",\n      \"  sapien. Cras lorem libero, mollis consectetur\",\n      \"  leo et, sollicitudin scelerisque mauris. Nunc semper\",\n      \"  dignissim libero, vitae ullamcorper arcu luctus\",\n      \"  eu.\",\n  };\n  ASSERT_THAT(lines, ContainerEq(exp));\n}\n\nTEST_F(WrapStringTest, CustomeIndents)\n{\n  std::vector<string> lines = wrap_string(custom_indents, 72, 5);\n\n  std::vector<string> exp {\n      \"                Lorem ipsum dolor      sit amet,\",\n      \"                consectetur adipiscing elit.\",\n  };\n\n  ASSERT_THAT(lines, ContainerEq(exp));\n}\n\n/*\n * Tests mysqlrouter::string_format()\n */\nTEST_F(StringFormatTest, Simple)\n{\n  EXPECT_EQ(std::string(\"5 + 5 = 10\"), mysqlrouter::string_format(\"%d + %d = %d\", 5, 5, 10));\n  EXPECT_EQ(std::string(\"Spam is 5\"), mysqlrouter::string_format(\"%s is %d\", \"Spam\", 5));\n}\n"
  },
  {
    "path": "src/router/tests/parse_error.conf",
    "content": "[config_a\nerror = \"Malformed section header..\""
  },
  {
    "path": "src/router/tests/router_arghandler.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql/harness/arg_handler.h\"\n\n#include <cstdint>\n#include <cstdio>\n#include <sstream>\n#include <streambuf>\n#include <vector>\n#ifndef _WIN32\n#  include <unistd.h>\n#endif\n\n//ignore GMock warnings\n#ifdef __clang__\n#  ifndef __has_warning\n#    define __has_warning(x) 0\n#  endif\n#  if __has_warning(\"-Wkeyword-macro\")\n#    pragma clang diagnostic ignored \"-Wkeyword-macro\"\n#  endif\n#  pragma clang diagnostic push\n#  pragma clang diagnostic ignored \"-Wsign-conversion\"\n#  include \"gmock/gmock.h\"\n#  pragma clang diagnostic pop\n#else\n#  include \"gmock/gmock.h\"\n#endif\n\n\nusing std::string;\nusing std::vector;\nusing ::testing::ContainerEq;\nusing ::testing::EndsWith;\nusing ::testing::HasSubstr;\nusing ::testing::IsEmpty;\nusing ::testing::Le;\nusing ::testing::Not;\nusing ::testing::SizeIs;\nusing ::testing::StartsWith;\nusing ::testing::StrEq;\n\nclass CmdOptionTest : public ::testing::Test {\nprotected:\n  virtual void SetUp() {\n  }\n\n  vector<string> names = {\"-a\", \"--some-long-a\"};\n  string description = \"Testing -a and --some-long-a\";\n  string metavar = \"test\";\n  string action_result;\n};\n\nclass ArgHandlerTest : public ::testing::Test {\nprotected:\n  virtual void SetUp() {\n  }\n\n  vector<CmdOption> cmd_options = {\n      CmdOption({\"-a\", \"--novalue-a\"}, \"Testing -a\", CmdOptionValueReq::none, \"\", nullptr),\n      CmdOption({\"-b\", \"--optional-b\"}, \"Testing -b\", CmdOptionValueReq::optional, \"optional\",\n                [this](const string &value) {\n                  this->action_result = value;\n                }),\n      CmdOption({\"-c\", \"--required-c\"}, \"Testing -c\", CmdOptionValueReq::required, \"required\",\n                [this](const string &value) {\n                  this->action_result = value;\n                }),\n  };\n  string action_result;\n};\n\n// We don't actually need it but without it for each call of ASSERT_ macro\n// with CmdOption as one of the params, gtest generates binary printer (hex representation)\n// for the CmdOption that causes Valgrind \"conditional jump\" errors from vfprintf()\nstd::ostream& operator<<(std::ostream& o, const CmdOption& cmd) {\n  for (const auto& name: cmd.names) {\n    o << name << \" \";\n  }\n  o << \"\\n\" << cmd.description << \"\\n\" << cmd.metavar << \"\\n\";\n  return o;\n}\n\nTEST(CmdOptionValueReq, CheckConstants) {\n  ASSERT_EQ(static_cast<uint8_t>(CmdOptionValueReq::none), 0x01);\n  ASSERT_EQ(static_cast<uint8_t>(CmdOptionValueReq::required), 0x02);\n  ASSERT_EQ(static_cast<uint8_t>(CmdOptionValueReq::optional), 0x03);\n}\n\nTEST_F(CmdOptionTest, Constructor) {\n  CmdOption opt(names, description, CmdOptionValueReq::none, metavar, nullptr);\n  ASSERT_THAT(opt.names, ContainerEq(names));\n  ASSERT_THAT(opt.description, StrEq(description));\n  ASSERT_THAT(opt.value_req, CmdOptionValueReq::none);\n  ASSERT_THAT(opt.metavar, StrEq(metavar));\n}\n\nTEST_F(CmdOptionTest, ConstructorWithAction) {\n  string value = \"the value\";\n  CmdOption opt(names, description, CmdOptionValueReq::none, metavar, [this](const string& v) {\n    this->action_result = v;\n  });\n  ASSERT_TRUE(nullptr != opt.action);\n  std::bind(opt.action, value)();\n  ASSERT_EQ(action_result, value);\n}\n\nTEST_F(ArgHandlerTest, DefaultConstructor) {\n  CmdArgHandler c;\n  ASSERT_FALSE(c.allow_rest_arguments);\n}\n\nTEST_F(ArgHandlerTest, ConstructorAllowRestArguments) {\n  CmdArgHandler c(true);\n  ASSERT_TRUE(c.allow_rest_arguments);\n}\n\nTEST_F(ArgHandlerTest, AddOption) {\n  // Function arguments tested at compile time using static_assert\n  CmdArgHandler c;\n  auto opt = cmd_options.at(0);\n  c.add_option(opt.names, opt.description, opt.value_req, opt.metavar, opt.action);\n  auto options = c.get_options();\n  ASSERT_THAT(options, SizeIs(1));\n  ASSERT_THAT(options.at(0).names, ContainerEq(opt.names));\n  ASSERT_THAT(options.at(0).description, StrEq(opt.description));\n  ASSERT_THAT(options.at(0).value_req, opt.value_req);\n  ASSERT_THAT(options.at(0).metavar, opt.metavar);\n}\n\nTEST_F(ArgHandlerTest, AddOptionWithAction) {\n  CmdArgHandler c;\n  string value = \"the value\";\n\n  c.add_option(cmd_options.at(1));\n  auto options = c.get_options();\n  ASSERT_THAT(options, SizeIs(1));\n  ASSERT_TRUE(nullptr != options.at(0).action);\n  std::bind(options.at(0).action, value)();\n  ASSERT_EQ(action_result, value);\n}\n\nTEST_F(ArgHandlerTest, FindOption) {\n  CmdArgHandler c;\n  for (auto &opt: cmd_options) {\n    c.add_option(opt);\n  }\n  auto options = c.get_options();\n  ASSERT_THAT((*c.find_option(\"-a\")).names, ContainerEq(options.at(0).names));\n  ASSERT_THAT((*c.find_option(\"--novalue-a\")).names, ContainerEq(options.at(0).names));\n  ASSERT_THAT((*c.find_option(\"-b\")).names, ContainerEq(options.at(1).names));\n  ASSERT_EQ(c.find_option(\"--non-existing-options\"), c.end());\n}\n\nTEST_F(ArgHandlerTest, IsValidOptionNameValids) {\n  CmdArgHandler c;\n  vector<string> valids = {\n    \"-a\",\n    \"--ab\",\n    \"--with-ab\"\n    \"--with_ab\"\n    \"-U\",\n    \"--UC\",\n    \"--WITH-AC\",\n    \"--WITH_AC\",\n  };\n  for (auto &name: valids) {\n    SCOPED_TRACE(\"Supposed to be valid: \" + name);\n    ASSERT_TRUE(c.is_valid_option_name(name));\n  }\n}\n\nTEST_F(ArgHandlerTest, IsValidOptionNameInvalids) {\n  CmdArgHandler c;\n  vector<string> invalids = {\n    \"-ab\",\n    \"--\",\n    \"-\",\n    \"---a\",\n    \"--with-ab-\",\n    \"--with-ab__\",\n    \"--.ab\",\n    \"--__ab\",\n    \"--AB \",\n    \"-AB\",\n    \"--\",\n    \"-\",\n    \"---U\"\n  };\n  for (auto &name: invalids) {\n    SCOPED_TRACE(\"Supposed to be invalid: \" + name);\n    ASSERT_FALSE(c.is_valid_option_name(name));\n  }\n}\n\nTEST_F(ArgHandlerTest, ProcessOptionNoValue) {\n  CmdArgHandler c(true);\n  for (auto &opt: cmd_options) {\n    c.add_option(opt);\n  }\n  c.process({\"-a\", \"some value after a\"});\n  ASSERT_THAT(action_result, StrEq(\"\"));\n\n  action_result = \"\";\n  c.process({\"--novalue-a\", \"rest\"});\n  ASSERT_THAT(action_result, StrEq(\"\"));\n\n  c.process({\"-a\", \"-b\"});\n  ASSERT_THAT(action_result, StrEq(\"\"));\n}\n\nTEST_F(ArgHandlerTest, ProcessRequiredOptional) {\n  CmdArgHandler c;\n    for (auto &opt: cmd_options) {\n    c.add_option(opt);\n  }\n  string value_b = \"value_option_b\";\n  c.process({\"-b\", value_b});\n  ASSERT_THAT(action_result, StrEq(value_b));\n\n  action_result = \"\";\n  c.process({\"--optional-b\", \"-a\"});\n  ASSERT_THAT(action_result, IsEmpty());\n\n  action_result = \"\";\n  c.process({\"-b\", \"-a\"});\n  ASSERT_THAT(action_result, IsEmpty());\n\n  action_result = \"\";\n  c.process({\"--optional-b\", \"-a\"});\n  ASSERT_THAT(action_result, IsEmpty());\n}\n\nTEST_F(ArgHandlerTest, ProcessOptionalRequired) {\n  CmdArgHandler c;\n    for (auto &opt: cmd_options) {\n    c.add_option(opt);\n  }\n\n  string value_c = \"value_option_c\";\n  c.process({\"-c\", value_c});\n  ASSERT_THAT(action_result, value_c);\n\n  action_result = \"\";\n  ASSERT_THROW({c.process({\"--required-c\"});}, std::invalid_argument);\n  try {\n    c.process({\"--required-c\"});\n  } catch (const std::invalid_argument &exc) {\n    ASSERT_THAT(exc.what(), HasSubstr(\"requires a value\"));\n  }\n}\n\nTEST_F(ArgHandlerTest, ProcessEmptyValue) {\n  // Bug#24809081\n  CmdArgHandler c;\n  for (auto &opt: cmd_options) {\n    c.add_option(opt);\n  }\n\n  string value = \"\";\n  ASSERT_NO_THROW(c.process({\"-c\", value}));\n  ASSERT_THAT(action_result, value);\n\n  ASSERT_NO_THROW(c.process({\"-b\", value}));\n  ASSERT_THAT(action_result, value);\n}\n\nTEST_F(ArgHandlerTest, ProcessUnknownOption) {\n  CmdArgHandler c;\n  for (auto &opt: cmd_options) {\n    c.add_option(opt);\n  }\n  ASSERT_THROW({c.process({\"--unknown-option\"});}, std::invalid_argument);\n  try {\n    c.process({\"--unknown-option\"});\n  } catch (const std::invalid_argument &exc) {\n    ASSERT_THAT(exc.what(), HasSubstr(\"unknown option\"));\n  }\n}\n\nTEST_F(ArgHandlerTest, ProcessRestArguments) {\n  vector<string> args;\n  vector<string> rest;\n  CmdArgHandler c(true);\n  for (auto &opt: cmd_options) {\n    c.add_option(opt);\n  }\n  rest = {\"some\", \"rest\", \"values\"};\n  args = {\"--novalue-a\"};\n  args.insert(args.end(), rest.begin(), rest.end());\n  c.process(args);\n  ASSERT_THAT(c.get_rest_arguments(), ContainerEq(rest));\n\n  rest.clear();\n  args.clear();\n  rest = {\"rest\", \"values\"};\n  args = {\"--optional-b\", \"some\"};\n  args.insert(args.end(), rest.begin(), rest.end());\n  c.process(args);\n  ASSERT_THAT(c.get_rest_arguments(), ContainerEq(rest));\n\n  rest.clear();\n  args.clear();\n  rest = {\"rest\", \"values\"};\n  args = {\"rest\", \"-b\", \"some\", \"values\"};\n  c.process(args);\n  ASSERT_THAT(c.get_rest_arguments(), ContainerEq(rest));\n}\n\nTEST_F(ArgHandlerTest, ProcessNotAllowedRestArguments) {\n  vector<string> args;\n  CmdArgHandler c(false);\n  for (auto &opt: cmd_options) {\n    c.add_option(opt);\n  }\n  args = {\"-a\", \"rest\", \"arguments\"};\n  ASSERT_THROW({c.process(args);}, std::invalid_argument);\n  try {\n    c.process(args);\n  } catch (const std::invalid_argument &exc) {\n    ASSERT_THAT(exc.what(), HasSubstr(\"invalid argument\"));\n    ASSERT_THAT(exc.what(), HasSubstr(\"'\" + args.at(1) + \"'\"));\n  }\n}\n\nTEST_F(ArgHandlerTest, UsageLineWithRestArguments) {\n  CmdArgHandler c(true);\n  vector<string> lines;\n  string usage_line;\n  for (auto &opt: cmd_options) {\n    c.add_option(opt);\n  }\n\n  lines = c.usage_lines(\"testarg\", \"REST\", 120);\n  ASSERT_THAT(lines, SizeIs(1));\n  usage_line = lines.at(0);\n\n  ASSERT_THAT(usage_line, StartsWith(\"testarg\"));\n  ASSERT_THAT(usage_line, EndsWith(\"[REST]\"));\n\n  for (auto &opt: cmd_options) {\n    for (auto &name: opt.names) {\n      ASSERT_THAT(usage_line, HasSubstr(name));\n    }\n  }\n}\n\nTEST_F(ArgHandlerTest, UsageLineWithoutRestArguments) {\n  CmdArgHandler c(false);\n  vector<string> lines;\n  string usage_line;\n  for (auto &opt: cmd_options) {\n    c.add_option(opt);\n  }\n\n  lines = c.usage_lines(\"testarg\", \"REST\", 120);\n  ASSERT_THAT(lines, SizeIs(1));\n  usage_line = lines.at(0);\n\n  ASSERT_THAT(usage_line, StartsWith(\"testarg\"));\n  ASSERT_THAT(usage_line, Not(EndsWith(\"[REST]\")));\n}\n\nTEST_F(ArgHandlerTest, UsageLineMultiLine) {\n  CmdArgHandler c(true);\n  vector<string> lines;\n  string usage_line;\n  size_t width = 40;\n  for (auto &opt: cmd_options) {\n    c.add_option(opt);\n  }\n\n  lines = c.usage_lines(\"testarg\", \"REST\", width);\n  ASSERT_THAT(lines, SizeIs(4));\n  ASSERT_THAT(lines.at(lines.size()-1), EndsWith(\"[REST]\"));\n\n  for (auto &line: lines) {\n    ASSERT_THAT(line.size(), Le(width));\n  }\n}\n\nTEST_F(ArgHandlerTest, OptionDescriptions) {\n  CmdArgHandler c(false);\n  vector<string> lines;\n  for (auto &opt: cmd_options) {\n    c.add_option(opt);\n  }\n\n  lines = c.option_descriptions(120, 8);\n  ASSERT_THAT(lines.at(0), StrEq(\"  -a, --novalue-a\"));\n  ASSERT_THAT(lines.at(1), StrEq(\"        Testing -a\"));\n  ASSERT_THAT(lines.at(2), StrEq(\"  -b [ <optional>], --optional-b [ <optional>]\"));\n  ASSERT_THAT(lines.at(3), StrEq(\"        Testing -b\"));\n  ASSERT_THAT(lines.at(4), StrEq(\"  -c <required>, --required-c <required>\"));\n  ASSERT_THAT(lines.at(5), StrEq(\"        Testing -c\"));\n}\n\nTEST_F(ArgHandlerTest, CheckIfTwoOptionsAreProvided) {\n  CmdArgHandler c(false);\n\n  bool option_a_set = false, option_b_set = false;\n\n  CmdOption option_a({\"--option-a\"}, \"Testing --option-a\",\n            CmdOptionValueReq::required, \"option-a_value\",\n            [&] (const string & /* value */) { option_a_set = true; },\n            [&] { if (option_a_set != option_b_set)\n              throw std::invalid_argument(\"--option-a has to be used together with --option-b\"); });\n\n  CmdOption option_b({\"--option-b\"}, \"Testing --option-b\",\n            CmdOptionValueReq::required, \"option-b_value\",\n            [&] (const string & /* value */) { option_b_set = true; },\n            [&] { if (option_a_set != option_b_set)\n              throw std::invalid_argument(\"--option-b has to be used together with --option-a\"); });\n\n  c.add_option(option_a);\n  c.add_option(option_b);\n\n  ASSERT_THROW({c.process({\"--option-a=value-a\"});}, std::invalid_argument);\n\n  option_a_set = false, option_b_set = false;\n  try {\n    c.process({\"--option-a=value-a\"});\n  } catch (const std::invalid_argument &exc) {\n    ASSERT_THAT(exc.what(), HasSubstr(\"--option-a has to be used together with --option-b\"));\n  }\n\n  option_a_set = false, option_b_set = false;\n  ASSERT_THROW({c.process({\"--option-b=value-b\"});}, std::invalid_argument);\n\n  option_a_set = false, option_b_set = false;\n  try {\n    c.process({\"--option-b=value-b\"});\n  } catch (const std::invalid_argument &exc) {\n    ASSERT_THAT(exc.what(), HasSubstr(\"--option-b has to be used together with --option-a\"));\n  }\n\n  option_a_set = false, option_b_set = false;\n  ASSERT_NO_THROW(c.process({\"--option-a=value-a\", \"--option-b=value-b\"}));\n\n  option_a_set = false, option_b_set = false;\n  ASSERT_NO_THROW(c.process({\"--option-b=value-b\", \"--option-a=value-a\"}));\n}\n"
  },
  {
    "path": "src/router/tests/test_cluster_metadata.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"router_test_helpers.h\"\n#include \"mysqlrouter/utils.h\"\n#include \"test/helpers.h\"\n\n#include <cstring>\n\n//ignore GMock warnings\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wsign-conversion\"\n#endif\n\n#include \"gmock/gmock.h\"\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n#include \"mysqlrouter/mysql_session.h\"\n#include \"mysql_session_replayer.h\"\n#include \"cluster_metadata.h\"\n\n\nusing ::testing::Return;\nusing namespace testing;\nusing mysqlrouter::MySQLInnoDBClusterMetadata;\n\nclass MockSocketOperations : public mysql_harness::SocketOperationsBase {\n public:\n  // this is what we test\n  MOCK_METHOD0(get_local_hostname, std::string());\n\n  // we don't call these, but we need to provide an implementation (they're pure virtual)\n  MOCK_METHOD3(read, ssize_t(int, void*, size_t));\n  MOCK_METHOD3(write, ssize_t(int, void*, size_t));\n  MOCK_METHOD1(close, void(int));\n  MOCK_METHOD1(shutdown, void(int));\n  MOCK_METHOD1(freeaddrinfo, void(addrinfo *ai));\n  MOCK_METHOD4(getaddrinfo, int(const char*, const char*, const addrinfo*, addrinfo**));\n  MOCK_METHOD3(bind, int(int, const struct sockaddr*, socklen_t));\n  MOCK_METHOD3(socket, int(int, int, int));\n  MOCK_METHOD5(setsockopt, int(int, int, int, const void*, socklen_t));\n  MOCK_METHOD2(listen, int(int fd, int n));\n  MOCK_METHOD3(poll, int(struct pollfd *, nfds_t, std::chrono::milliseconds));\n  MOCK_METHOD2(connect_non_blocking_wait, int(int sock, std::chrono::milliseconds timeout));\n  MOCK_METHOD2(connect_non_blocking_status, int(int sock, int &so_error));\n  MOCK_METHOD1(set_errno, void(int err));\n  MOCK_METHOD0(get_errno, int());\n};\n\nclass ClusterMetadataTest : public  ::testing::Test {\nprotected:\n  virtual void SetUp() {\n  }\n\n  MySQLSessionReplayer session_replayer;\n  MockSocketOperations hostname_operations;\n};\n\nconst std::string kQueryGetHostname = \"SELECT h.host_id, h.host_name\"\n            \" FROM mysql_innodb_cluster_metadata.routers r\"\n            \" JOIN mysql_innodb_cluster_metadata.hosts h\"\n            \"    ON r.host_id = h.host_id\"\n            \" WHERE r.router_id =\";\n\nconst std::string kCheckHostExists = \"SELECT host_id, host_name, ip_address\"\n        \" FROM mysql_innodb_cluster_metadata.hosts\"\n        \" WHERE host_name =\";\n\nconst std::string kRegisterRouter = \"INSERT INTO mysql_innodb_cluster_metadata.routers\"\n        \"        (host_id, router_name) VALUES\";\n\nTEST_F(ClusterMetadataTest, check_router_id_ok) {\n  const std::string kHostId = \"2\";\n  const std::string kHostname = \"hostname\";\n  MySQLInnoDBClusterMetadata cluster_metadata(&session_replayer, &hostname_operations);\n\n  session_replayer.expect_query_one(kQueryGetHostname).then_return(2, {{kHostId.c_str(), kHostname.c_str()}});\n  EXPECT_CALL(hostname_operations, get_local_hostname()).Times(1).WillOnce(Return(kHostname));\n\n  EXPECT_NO_THROW(cluster_metadata.check_router_id(1));\n}\n\nACTION_P(ThrowLocalHostnameResolutionError, msg)\n{\n  throw mysql_harness::SocketOperationsBase::LocalHostnameResolutionError(msg);\n}\n\n/**\n * @test verify that check_router_id() will throw if get_local_hostname() fails\n */\nTEST_F(ClusterMetadataTest, check_router_id_get_hostname_throws) {\n  const std::string kHostId = \"2\";\n  const std::string kHostname = \"\";\n  MySQLInnoDBClusterMetadata cluster_metadata(&session_replayer, &hostname_operations);\n\n  session_replayer.expect_query_one(kQueryGetHostname).then_return(2, {{kHostId.c_str(), kHostname.c_str()}});\n  EXPECT_CALL(hostname_operations, get_local_hostname()).Times(1).WillOnce(\n      ThrowLocalHostnameResolutionError(\"some error from get_local_hostname()\"));\n\n  EXPECT_THROW_LIKE(\n    cluster_metadata.check_router_id(1),\n    mysql_harness::SocketOperationsBase::LocalHostnameResolutionError,\n    \"some error from get_local_hostname()\"\n  );\n}\n\nTEST_F(ClusterMetadataTest, check_router_id_router_not_found) {\n  MySQLInnoDBClusterMetadata cluster_metadata(&session_replayer, &hostname_operations);\n\n  session_replayer.expect_query_one(kQueryGetHostname).then_return(2, {});\n\n  try {\n    cluster_metadata.check_router_id(1);\n    FAIL() << \"Expected exception\";\n  }\n  catch (std::runtime_error &e) {\n    ASSERT_STREQ(\"router_id 1 not found in metadata\", e.what());\n  }\n}\n\nTEST_F(ClusterMetadataTest, check_router_id_different_hostname) {\n  const std::string kHostId = \"2\";\n  const std::string kHostname1 = \"hostname\";\n  const std::string kHostname2 = \"another.hostname\";\n  MySQLInnoDBClusterMetadata cluster_metadata(&session_replayer, &hostname_operations);\n\n  session_replayer.expect_query_one(kQueryGetHostname).then_return(2, {{kHostId.c_str(), kHostname1.c_str()}});\n  EXPECT_CALL(hostname_operations, get_local_hostname()).Times(1).WillOnce(Return(kHostname2));\n\n  try {\n    cluster_metadata.check_router_id(1);\n    FAIL() << \"Expected exception\";\n  }\n  catch (std::runtime_error &e) {\n    ASSERT_STREQ(\"router_id 1 is associated with a different host ('hostname' vs 'another.hostname')\", e.what());\n  }\n}\n\nTEST_F(ClusterMetadataTest, register_router_ok) {\n  const std::string kRouterName = \"routername\";\n  const std::string kHostName = \"hostname\";\n  MySQLInnoDBClusterMetadata cluster_metadata(&session_replayer, &hostname_operations);\n\n  session_replayer.expect_query_one(kCheckHostExists).then_return(3, {{\"1\", kHostName.c_str(), \"127.0.0.1\"}});\n  session_replayer.expect_execute(kRegisterRouter).then_ok();\n  EXPECT_CALL(hostname_operations, get_local_hostname()).Times(1).WillOnce(Return(kHostName.c_str()));\n\n  EXPECT_NO_THROW(cluster_metadata.register_router(kRouterName, false));\n}\n\n/**\n * @test verify that register_router() will throw if get_local_hostname() fails\n */\nTEST_F(ClusterMetadataTest, register_router_get_hostname_throws) {\n  const std::string kRouterName = \"routername\";\n  const std::string kHostName = \"\";\n  MySQLInnoDBClusterMetadata cluster_metadata(&session_replayer, &hostname_operations);\n\n  session_replayer.expect_query_one(kCheckHostExists).then_return(3, {{\"1\", kHostName.c_str(), \"127.0.0.1\"}});\n  session_replayer.expect_execute(kRegisterRouter).then_ok();\n  EXPECT_CALL(hostname_operations, get_local_hostname()).Times(1).WillOnce(\n      ThrowLocalHostnameResolutionError(\"some error from get_local_hostname()\"));\n\n  // get_local_hostname() throwing should be handled inside register_router\n  EXPECT_THROW_LIKE(\n    cluster_metadata.register_router(kRouterName, false),\n    mysql_harness::SocketOperationsBase::LocalHostnameResolutionError,\n    \"some error from get_local_hostname()\"\n  );\n}\n\nint main(int argc, char *argv[]) {\n  init_test_logger();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/router/tests/test_config_files.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"config_files.h\"\n#include \"gmock/gmock.h\"\n\nTEST(ConfigFilesTest, IsLegacyConfigurationNameCorrect) {\n  ASSERT_THAT(use_ini_extension(\"my.conf.conf\"), testing::Eq(\"my.conf.ini\"));\n}\n"
  },
  {
    "path": "src/router/tests/test_config_generator.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n// must be the first header, don't move it\n#include <gtest/gtest_prod.h>\n\n#include \"cluster_metadata.h\"\n#include \"config_generator.h\"\n#include \"mysql/harness/config_parser.h\"\n#include \"mysql/harness/filesystem.h\"\n#include \"dim.h\"\n#include \"gtest_consoleoutput.h\"\n#include \"mysql_session_replayer.h\"\n#include \"mysqlrouter/mysql_session.h\"\n#include \"mysqlrouter/utils.h\"\n#include \"random_generator.h\"\n#include \"router_app.h\"\n#include \"router_test_helpers.h\"\n#include \"mysqlrouter/uri.h\"\n#include \"test/helpers.h\"\n\n#include <cstring>\n#include <fstream>\n#include <sstream>\n#include <streambuf>\n#include \"keyring/keyring_manager.h\"\n#ifndef _WIN32\n#include <netdb.h>\n#include <arpa/inet.h>\n#include <unistd.h>\n#endif\n\n//ignore GMock warnings\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wsign-conversion\"\n#endif\n\n#include \"gmock/gmock.h\"\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n#include <mysql.h>\n\nstd::string g_cwd;\nmysql_harness::Path g_origin;\nTmpDir tmp_dir;\n\nclass ReplayerWithMockSSL : public MySQLSessionReplayer {\n public:\n  void set_ssl_options(mysql_ssl_mode ssl_mode,\n                       const std::string &tls_version,\n                       const std::string &ssl_cipher,\n                       const std::string &ca, const std::string &capath,\n                       const std::string &crl, const std::string &crlpath) {\n    last_ssl_mode = ssl_mode;\n    last_tls_version = tls_version;\n    last_ssl_cipher = ssl_cipher;\n    last_ssl_ca = ca;\n    last_ssl_capath = capath;\n    last_ssl_crl = crl;\n    last_ssl_crlpath = crlpath;\n    if (should_throw_)\n      throw Error(\"\", 0);\n  }\n\n  void set_ssl_cert(const std::string &cert, const std::string &key) {\n    last_ssl_cert = cert;\n    last_ssl_key = key;\n    if (should_throw_)\n      throw Error(\"\", 0);\n  }\n\n  void set_ssl_mode_should_fail(bool flag) { should_throw_ = flag; }\n\n public:\n  mysql_ssl_mode last_ssl_mode;\n  std::string last_tls_version;\n  std::string last_ssl_cipher;\n  std::string last_ssl_ca;\n  std::string last_ssl_capath;\n  std::string last_ssl_crl;\n  std::string last_ssl_crlpath;\n  std::string last_ssl_cert;\n  std::string last_ssl_key;\n\n private:\n  bool should_throw_ = false;\n};\n\nclass ConfigGeneratorTest : public ConsoleOutputTest {\nprotected:\n  virtual void SetUp() {\n    mysql_harness::DIM::instance().set_RandomGenerator(\n      [](){ static mysql_harness::FakeRandomGenerator rg; return &rg; },\n      [](mysql_harness::RandomGeneratorInterface*){}  // don't delete our static!\n    );\n\n    mock_mysql.reset(new ReplayerWithMockSSL());\n    mysql_harness::DIM::instance().set_MySQLSession(\n      [this](){ return mock_mysql.get(); },\n      [](mysqlrouter::MySQLSession*){}   // don't try to delete it\n    );\n\n    set_origin(g_origin);\n    ConsoleOutputTest::SetUp();\n    config_path.reset(new Path(g_cwd));\n    config_path->append(\"Bug24570426.conf\");\n\n    default_paths[\"logging_folder\"] = \"\";\n  }\n\n  std::unique_ptr<Path> config_path;\n  std::map<std::string, std::string> default_paths;\n  std::unique_ptr<ReplayerWithMockSSL> mock_mysql;\n};\n\nconst std::string kServerUrl = \"mysql://test:test@127.0.0.1:3060\";\n\nusing ::testing::Return;\nusing namespace testing;\nusing mysqlrouter::ConfigGenerator;\nusing mysql_harness::delete_dir_recursive;\nusing mysql_harness::delete_file;\n\nstatic void common_pass_schema_version(MySQLSessionReplayer *m) {\n  m->expect_query_one(\"SELECT * FROM mysql_innodb_cluster_metadata.schema_version\");\n  m->then_return(2, {\n    // major, minor\n    {m->string_or_null(\"1\"), m->string_or_null(\"0\")}\n  });\n}\n\nstatic void common_pass_metadata_supported(MySQLSessionReplayer *m) {\n  m->expect_query_one(\"SELECT  ((SELECT count(*) FROM mysql_innodb_cluster_metadata.clusters) <= 1  AND (SELECT count(*) FROM mysql_innodb_cluster_metadata.replicasets) <= 1) as has_one_replicaset, (SELECT attributes->>'$.group_replication_group_name' FROM mysql_innodb_cluster_metadata.replicasets)  = @@group_replication_group_name as replicaset_is_ours\");\n  m->then_return(2, {\n    // has_one_replicaset, replicaset_is_ours\n    {m->string_or_null(\"1\"), m->string_or_null()}\n  });\n}\n\nstatic void common_pass_group_replication_online(MySQLSessionReplayer *m) {\n  m->expect_query_one(\"SELECT member_state FROM performance_schema.replication_group_members WHERE member_id = @@server_uuid\");\n  m->then_return(1, {\n    // member_state\n    {m->string_or_null(\"ONLINE\")}\n  });\n}\n\nstatic void common_pass_group_has_quorum(MySQLSessionReplayer *m) {\n  m->expect_query_one(\"SELECT SUM(IF(member_state = 'ONLINE', 1, 0)) as num_onlines, COUNT(*) as num_total FROM performance_schema.replication_group_members\");\n  m->then_return(2, {\n    // num_onlines, num_total\n    {m->string_or_null(\"3\"), m->string_or_null(\"3\")}\n  });\n}\n\n#if 0\nstatic void common_pass_member_is_primary(MySQLSessionReplayer *m) {\n  m->expect_query_one(\"SELECT @@group_replication_single_primary_mode=1 as single_primary_mode,        (SELECT variable_value FROM performance_schema.global_status WHERE variable_name='group_replication_primary_member') as primary_member,         @@server_uuid as my_uuid\");\n  m->then_return(3, {\n    // single_primary_mode, primary_member, my_uuid\n    {m->string_or_null(\"0\"), m->string_or_null(\"2d52f178-98f4-11e6-b0ff-8cc844fc24bf\"), m->string_or_null(\"2d52f178-98f4-11e6-b0ff-8cc844fc24bf\")}\n  });\n}\n#endif\n\nstatic void common_pass_metadata_checks(MySQLSessionReplayer *m) {\n  m->clear_expects();\n  common_pass_schema_version(m);\n  common_pass_metadata_supported(m);\n  common_pass_group_replication_online(m);\n  common_pass_group_has_quorum(m);\n  // common_pass_member_is_primary(m);\n}\n\nTEST_F(ConfigGeneratorTest, fetch_bootstrap_servers_one) {\n  std::string primary_cluster_name_;\n  std::string primary_replicaset_servers_;\n  std::string primary_replicaset_name_;\n  bool multi_master_ = false;\n\n  {\n    ConfigGenerator config_gen;\n    common_pass_metadata_checks(mock_mysql.get());\n    config_gen.init(kServerUrl, {});\n\n    mock_mysql->expect_query(\"\").then_return(4, {\n        {\"mycluster\", \"myreplicaset\", \"pm\", \"somehost:3306\"}});\n\n    config_gen.fetch_bootstrap_servers(\n      primary_replicaset_servers_,\n      primary_cluster_name_, primary_replicaset_name_, multi_master_);\n\n    ASSERT_THAT(primary_replicaset_servers_, Eq(\"mysql://somehost:3306\"));\n    ASSERT_THAT(primary_cluster_name_, Eq(\"mycluster\"));\n    ASSERT_THAT(primary_replicaset_name_, Eq(\"myreplicaset\"));\n    ASSERT_THAT(multi_master_, Eq(false));\n  }\n\n  {\n    ConfigGenerator config_gen;\n    common_pass_metadata_checks(mock_mysql.get());\n    config_gen.init(kServerUrl, {});\n\n    mock_mysql->expect_query(\"\").then_return(4, {\n        {\"mycluster\", \"myreplicaset\", \"mm\", \"somehost:3306\"}});\n\n    config_gen.fetch_bootstrap_servers(\n      primary_replicaset_servers_,\n      primary_cluster_name_, primary_replicaset_name_, multi_master_);\n\n    ASSERT_THAT(primary_replicaset_servers_, Eq(\"mysql://somehost:3306\"));\n    ASSERT_THAT(primary_cluster_name_, Eq(\"mycluster\"));\n    ASSERT_THAT(primary_replicaset_name_, Eq(\"myreplicaset\"));\n    ASSERT_THAT(multi_master_, Eq(true));\n  }\n\n  {\n    ConfigGenerator config_gen;\n    common_pass_metadata_checks(mock_mysql.get());\n    config_gen.init(kServerUrl, {});\n\n    mock_mysql->expect_query(\"\").then_return(4, {\n        {\"mycluster\", \"myreplicaset\", \"xxx\", \"somehost:3306\"}});\n\n    ASSERT_THROW(\n      config_gen.fetch_bootstrap_servers(\n        primary_replicaset_servers_,\n        primary_cluster_name_, primary_replicaset_name_, multi_master_),\n      std::runtime_error);\n  }\n}\n\nTEST_F(ConfigGeneratorTest, fetch_bootstrap_servers_three) {\n\n  std::string primary_cluster_name_;\n  std::string primary_replicaset_servers_;\n  std::string primary_replicaset_name_;\n  bool multi_master_ = false;\n\n  {\n    ConfigGenerator config_gen;\n    common_pass_metadata_checks(mock_mysql.get());\n    config_gen.init(kServerUrl, {});\n\n    // \"F.cluster_name, \"\n    // \"R.replicaset_name, \"\n    // \"R.topology_type, \"\n    // \"JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic')) \"\n    mock_mysql->expect_query(\"\").then_return(4, {\n        {\"mycluster\", \"myreplicaset\", \"pm\", \"somehost:3306\"},\n        {\"mycluster\", \"myreplicaset\", \"pm\", \"otherhost:3306\"},\n        {\"mycluster\", \"myreplicaset\", \"pm\", \"sumhost:3306\"}});\n\n    config_gen.fetch_bootstrap_servers(\n      primary_replicaset_servers_,\n      primary_cluster_name_, primary_replicaset_name_, multi_master_);\n\n    ASSERT_THAT(primary_replicaset_servers_, Eq(\"mysql://somehost:3306,mysql://otherhost:3306,mysql://sumhost:3306\"));\n    ASSERT_THAT(primary_cluster_name_, Eq(\"mycluster\"));\n    ASSERT_THAT(primary_replicaset_name_, Eq(\"myreplicaset\"));\n    ASSERT_THAT(multi_master_, Eq(false));\n  }\n}\n\nTEST_F(ConfigGeneratorTest, fetch_bootstrap_servers_multiple_replicasets) {\n  std::string primary_cluster_name_;\n  std::string primary_replicaset_servers_;\n  std::string primary_replicaset_name_;\n  bool multi_master_ = false;\n\n  {\n    ConfigGenerator config_gen;\n    common_pass_metadata_checks(mock_mysql.get());\n    config_gen.init(kServerUrl, {});\n    mock_mysql->expect_query(\"\").then_return(4, {\n        {\"mycluster\", \"myreplicaset\", \"pm\", \"somehost:3306\"},\n        {\"mycluster\", \"anotherreplicaset\", \"pm\", \"otherhost:3306\"}});\n\n    ASSERT_THROW(\n      config_gen.fetch_bootstrap_servers(\n        primary_replicaset_servers_,\n        primary_cluster_name_, primary_replicaset_name_, multi_master_),\n      std::runtime_error);\n  }\n\n  {\n    ConfigGenerator config_gen;\n    common_pass_metadata_checks(mock_mysql.get());\n    config_gen.init(kServerUrl, {});\n    mock_mysql->expect_query(\"\").then_return(4, {\n        {\"mycluster\", \"myreplicaset\", \"pm\", \"somehost:3306\"},\n        {\"anothercluster\", \"anotherreplicaset\", \"pm\", \"otherhost:3306\"}});\n\n    ASSERT_THROW(\n      config_gen.fetch_bootstrap_servers(\n        primary_replicaset_servers_,\n        primary_cluster_name_, primary_replicaset_name_, multi_master_),\n      std::runtime_error);\n  }\n}\n\n\nTEST_F(ConfigGeneratorTest, fetch_bootstrap_servers_invalid) {\n  std::string primary_cluster_name_;\n  std::string primary_replicaset_servers_;\n  std::string primary_replicaset_name_;\n  bool multi_master_ = false;\n\n  {\n    ConfigGenerator config_gen;\n    common_pass_metadata_checks(mock_mysql.get());\n    config_gen.init(kServerUrl, {});\n\n    mock_mysql->expect_query(\"\").then_return(4, {});\n    // no replicasets/clusters defined\n    ASSERT_THROW(\n      config_gen.fetch_bootstrap_servers(\n        primary_replicaset_servers_,\n        primary_cluster_name_, primary_replicaset_name_, multi_master_),\n      std::runtime_error\n    );\n  }\n}\n\nTEST_F(ConfigGeneratorTest, metadata_checks_invalid_data) {\n  // invalid number of values returned from schema_version table\n  {\n    ConfigGenerator config_gen;\n\n    mock_mysql->expect_query_one(\"SELECT * FROM mysql_innodb_cluster_metadata.schema_version\");\n    mock_mysql->then_return(1, {\n      // major, [minor missing]\n      {mock_mysql->string_or_null(\"0\")}\n    });\n\n    ASSERT_THROW_LIKE(\n      config_gen.init(kServerUrl, {}),\n      std::out_of_range,\n      \"Invalid number of values returned from mysql_innodb_cluster_metadata.schema_version: \"\n      \"expected 2 or 3 got 1\"\n    );\n  }\n\n  // invalid number of values returned from query for metadata support\n  {\n    ConfigGenerator config_gen;\n\n    common_pass_schema_version(mock_mysql.get());\n\n    mock_mysql->expect_query_one(\"SELECT  ((SELECT count(*) FROM mysql_innodb_cluster_metadata.clusters) <= 1  AND (SELECT count(*) FROM mysql_innodb_cluster_metadata.replicasets) <= 1) as has_one_replicaset, (SELECT attributes->>'$.group_replication_group_name' FROM mysql_innodb_cluster_metadata.replicasets)  = @@group_replication_group_name as replicaset_is_ours\");\n    mock_mysql->then_return(1, {\n      // has_one_replicaset, [replicaset_is_ours missing]\n      {mock_mysql->string_or_null(\"1\")}\n    });\n\n    ASSERT_THROW_LIKE(\n      config_gen.init(kServerUrl, {}),\n      std::out_of_range,\n      \"Invalid number of values returned from query for metadata support: \"\n      \"expected 2 got 1\"\n    );\n  }\n\n  // invalid number of values returned from query for member_state\n  {\n    ConfigGenerator config_gen;\n\n    common_pass_schema_version(mock_mysql.get());\n    common_pass_metadata_supported(mock_mysql.get());\n\n    mock_mysql->expect_query_one(\"SELECT member_state FROM performance_schema.replication_group_members WHERE member_id = @@server_uuid\");\n    mock_mysql->then_return(0, {\n      // [state field missing]\n    });\n\n    ASSERT_THROW_LIKE(\n      config_gen.init(kServerUrl, {}),\n      std::logic_error,\n      \"No result returned for metadata query\"\n    );\n  }\n\n  // invalid number of values returned from query checking for group quorum\n  {\n    ConfigGenerator config_gen;\n\n    common_pass_schema_version(mock_mysql.get());\n    common_pass_metadata_supported(mock_mysql.get());\n    common_pass_group_replication_online(mock_mysql.get());\n\n    mock_mysql->expect_query_one(\"SELECT SUM(IF(member_state = 'ONLINE', 1, 0)) as num_onlines, COUNT(*) as num_total FROM performance_schema.replication_group_members\");\n    mock_mysql->then_return(1, {\n      // num_onlines, [num_total field missing]\n      {mock_mysql->string_or_null(\"3\")}\n    });\n\n    ASSERT_THROW_LIKE(\n      config_gen.init(kServerUrl, {}),\n      std::out_of_range,\n      \"Invalid number of values returned from performance_schema.replication_group_members: \"\n      \"expected 2 got 1\"\n    );\n  }\n\n  // invalid number of values returned from query checking if member is primary\n  {\n    ConfigGenerator config_gen;\n\n    common_pass_schema_version(mock_mysql.get());\n    common_pass_metadata_supported(mock_mysql.get());\n    common_pass_group_replication_online(mock_mysql.get());\n    common_pass_group_has_quorum(mock_mysql.get());\n\n    mock_mysql->expect_query_one(\"SELECT @@group_replication_single_primary_mode=1 as single_primary_mode,        (SELECT variable_value FROM performance_schema.global_status WHERE variable_name='group_replication_primary_member') as primary_member,         @@server_uuid as my_uuid\");\n    mock_mysql->then_return(2, {\n      // single_primary_mode, primary_member, [my_uuid field missing]\n      {mock_mysql->string_or_null(\"0\"), mock_mysql->string_or_null(\"2d52f178-98f4-11e6-b0ff-8cc844fc24bf\")}\n    });\n\n    ASSERT_THROW_LIKE({\n        // bypass the config-gen init as we actually only test check_innodb_metadata_cluster_session()\n        // which isn't used by config-gen anymore\n        mysql_harness::UniquePtr<mysqlrouter::MySQLSession> mysql_ = mysql_harness::DIM::instance().new_MySQLSession();\n\n        mysqlrouter::URI u = mysqlrouter::URIParser::parse(kServerUrl, false);\n        mysql_->connect(u.host, u.port, u.username, u.password, \"\", \"\", 5);\n\n        mysqlrouter::check_innodb_metadata_cluster_session(mysql_.get(), false);\n      },\n      std::out_of_range,\n      \"Invalid number of values returned from query for primary: \"\n      \"expected 3 got 2\"\n    );\n  }\n\n}\n\nTEST_F(ConfigGeneratorTest, delete_account_for_all_hosts) {\n\n  auto gen_check_users_SQL = [this](const std::vector<const char*>& hostnames_to_return) {\n    std::vector<std::vector<MySQLSessionReplayer::string>> results;\n    for (const char* h : hostnames_to_return)\n      results.push_back({mock_mysql->string_or_null(h)});\n\n    mock_mysql->expect_query(\"SELECT host FROM mysql.user WHERE user = 'cluster_user'\").\n                then_return(1, results);\n  };\n\n  auto test_common = [this]() {\n    ConfigGenerator config_gen;\n    config_gen.init(kServerUrl, {});\n    config_gen.delete_account_for_all_hosts(\"cluster_user\");\n\n    EXPECT_TRUE(mock_mysql->empty());\n  };\n\n  // Router account does not exist\n  {\n    common_pass_metadata_checks(mock_mysql.get());\n    gen_check_users_SQL({});\n\n    test_common();\n  }\n\n  // Router account exists for 1 host\n  {\n    common_pass_metadata_checks(mock_mysql.get());\n    gen_check_users_SQL({\"foo\"});\n    mock_mysql->expect_execute(\"DROP USER cluster_user@'foo'\");\n\n    test_common();\n  }\n\n  // Router account exists for many hosts\n  {\n    common_pass_metadata_checks(mock_mysql.get());\n    gen_check_users_SQL({\"foo\", \"bar\", \"baz\"});\n    mock_mysql->expect_execute(\"DROP USER cluster_user@'foo',cluster_user@'bar',cluster_user@'baz'\");\n\n    test_common();\n  }\n\n  // SELECT fails\n  {\n    common_pass_metadata_checks(mock_mysql.get());\n    mock_mysql->expect_query(\"SELECT host FROM mysql.user WHERE user = 'cluster_user'\").\n                then_error(\"some error\", 1234);\n\n    ConfigGenerator config_gen;\n    config_gen.init(kServerUrl, {});\n    EXPECT_THROW_LIKE(\n      config_gen.delete_account_for_all_hosts(\"cluster_user\"),\n      std::runtime_error, \"some error\"\n    );\n\n    EXPECT_TRUE(mock_mysql->empty());\n  }\n\n  // DROP USER fails\n  {\n    common_pass_metadata_checks(mock_mysql.get());\n    gen_check_users_SQL({\"foo\", \"bar\", \"baz\"});\n    mock_mysql->expect_execute(\"DROP USER cluster_user@'foo',cluster_user@'bar',cluster_user@'baz'\").\n                then_error(\"some error\", 1234);\n\n    ConfigGenerator config_gen;\n    config_gen.init(kServerUrl, {});\n    EXPECT_THROW_LIKE(\n      config_gen.delete_account_for_all_hosts(\"cluster_user\"),\n      std::runtime_error, \"some error\"\n    );\n\n    EXPECT_TRUE(mock_mysql->empty());\n  }\n}\n\nTEST_F(ConfigGeneratorTest, create_acount) {\n  // using password directly\n  {\n    ::testing::InSequence s;\n    common_pass_metadata_checks(mock_mysql.get());\n    mock_mysql->expect_execute(\"CREATE USER cluster_user@'%' IDENTIFIED BY 'secret'\").then_ok();\n    mock_mysql->expect_execute(\"GRANT SELECT ON mysql_innodb_cluster_metadata.* TO cluster_user@'%'\").then_ok();\n    mock_mysql->expect_execute(\"GRANT SELECT ON performance_schema.replication_group_members TO cluster_user@'%'\").then_ok();\n    mock_mysql->expect_execute(\"GRANT SELECT ON performance_schema.replication_group_member_stats TO cluster_user@'%'\").then_ok();\n\n    ConfigGenerator config_gen;\n    config_gen.init(kServerUrl, {});\n    config_gen.create_account(\"cluster_user\", \"%\", \"secret\");\n  }\n\n  // using hashed password\n  {\n    ::testing::InSequence s;\n    common_pass_metadata_checks(mock_mysql.get());\n    mock_mysql->expect_execute(\"CREATE USER cluster_user@'%' IDENTIFIED WITH mysql_native_password \"\n                               \"AS '*14E65567ABDB5135D0CFD9A70B3032C179A49EE7'\").then_ok();\n    mock_mysql->expect_execute(\"GRANT SELECT ON mysql_innodb_cluster_metadata.* TO cluster_user@'%'\").then_ok();\n    mock_mysql->expect_execute(\"GRANT SELECT ON performance_schema.replication_group_members TO cluster_user@'%'\").then_ok();\n    mock_mysql->expect_execute(\"GRANT SELECT ON performance_schema.replication_group_member_stats TO cluster_user@'%'\").then_ok();\n\n    ConfigGenerator config_gen;\n    config_gen.init(kServerUrl, {});\n    config_gen.create_account(\"cluster_user\", \"%\", \"secret\", true); // true = hash the password\n  }\n}\n\nTEST_F(ConfigGeneratorTest, create_router_accounts) {\n\n  enum TestType {\n    NATIVE,     // CREATE USER using mysql_native_password and hashed password\n    FALLBACK    // CREATE USER using fallback method with plaintext password\n  };\n\n  for (TestType tt : {NATIVE, FALLBACK}) {\n\n    constexpr unsigned kDontFail = 99;\n    auto generate_expected_SQL = [&](const std::string& host,\n                                     bool first_create_user,\n                                     unsigned fail_on) {\n\n      // kDontFail => don't fail, 1..4 => fail on 1..4\n      assert((1 <= fail_on && fail_on <= 4) || fail_on == kDontFail);\n\n      if (tt == NATIVE) {\n        // CREATE USER using mysql_native_password and hashed password\n        if (fail_on > 0) mock_mysql->expect_execute(\n            \"CREATE USER cluster_user@'\" + host +\n            \"' IDENTIFIED WITH mysql_native_password AS '*BDF9890F9606F18B2E92EF0CA972006F1DBC44DF'\").then_ok();\n      } else {\n        // fail mysql_native_password method to induce fallback to plaintext method.\n        // Should be called only as the first CREATE USER, after this fallback should\n        // be used on all subsequent CREATE USER calls\n        if (first_create_user) mock_mysql->expect_execute(\"CREATE USER cluster_user@'\" + host +\n            \"' IDENTIFIED WITH mysql_native_password AS '*BDF9890F9606F18B2E92EF0CA972006F1DBC44DF'\").then_error(\"no such plugin\", 1524);\n\n        // CREATE USER using fallback method with plaintext password\n        if (fail_on > 0) mock_mysql->expect_execute(\n            \"CREATE USER cluster_user@'\" + host + \"' IDENTIFIED BY '0123456789012345'\").then_ok();\n      }\n      if (fail_on > 1) mock_mysql->expect_execute(\n          \"GRANT SELECT ON mysql_innodb_cluster_metadata.* TO cluster_user@'\" + host + \"'\").then_ok();\n      if (fail_on > 2) mock_mysql->expect_execute(\n          \"GRANT SELECT ON performance_schema.replication_group_members TO cluster_user@'\" + host + \"'\").then_ok();\n      if (fail_on > 3) mock_mysql->expect_execute(\n          \"GRANT SELECT ON performance_schema.replication_group_member_stats TO cluster_user@'\" + host + \"'\").then_ok();\n\n      if (fail_on != kDontFail)\n        mock_mysql->then_error(\"some error\", 1234); // i-th statement will return this error\n    };\n\n    // default hostname\n    {\n      ::testing::InSequence s;\n      common_pass_metadata_checks(mock_mysql.get());\n      generate_expected_SQL(\"%\", true, kDontFail);\n\n      ConfigGenerator config_gen;\n      config_gen.init(kServerUrl, {});\n      config_gen.create_router_accounts({}, {}, \"cluster_user\");\n    }\n\n    // 1 hostname\n    {\n      ::testing::InSequence s;\n      common_pass_metadata_checks(mock_mysql.get());\n      generate_expected_SQL(\"host1\", true, kDontFail);\n\n      ConfigGenerator config_gen;\n      config_gen.init(kServerUrl, {});\n      config_gen.create_router_accounts({}, {{\"account-host\", {\"host1\"}}}, \"cluster_user\");\n    }\n\n    // many hostnames\n    {\n      // NOTE: When we run bootstrap in real life, all --account-host entries should\n      //       get sorted and any non-unique entries eliminated (to ensure CREATE USER\n      //       does not get called twice for the same user@host). However, this happens\n      //       at the commandline parsing level, so by the time ConfigGenerator runs,\n      //       the list of hostnames is already unique and sorted. Here we just give\n      //       an arbitrary list to ensure it will work irrespective of input.\n\n      ::testing::InSequence s;\n      common_pass_metadata_checks(mock_mysql.get());\n\n      generate_expected_SQL(\"host1\", true, kDontFail);\n      generate_expected_SQL(\"%\", false, kDontFail);\n      generate_expected_SQL(\"host3%\", false, kDontFail);\n\n      ConfigGenerator config_gen;\n      config_gen.init(kServerUrl, {});\n      config_gen.create_router_accounts({}, {{\"account-host\", {\"host1\", \"%\", \"host3%\"}}}, \"cluster_user\");\n    }\n\n    // one of user-creating statements fails\n    for (unsigned fail_host = 1; fail_host < 3; fail_host++)\n    {\n      for (unsigned fail_sql = 1; fail_sql <= 4; fail_sql++)\n      {\n        ::testing::InSequence s;\n        common_pass_metadata_checks(mock_mysql.get());\n        switch (fail_host) {\n          case 1:\n            generate_expected_SQL(\"host1\", true, fail_sql);\n          break;\n          case 2:\n            generate_expected_SQL(\"host1\", true, kDontFail);\n            generate_expected_SQL(\"host2\", false, fail_sql);\n          break;\n          case 3:\n            generate_expected_SQL(\"host1\", true, kDontFail);\n            generate_expected_SQL(\"host2\", false, kDontFail);\n            generate_expected_SQL(\"host3\", false, fail_sql);\n          break;\n        }\n\n        // fail_sql-th SQL statement of fail_host will return this error\n        mock_mysql->then_error(\"some error\", 1234);\n\n        mock_mysql->expect_execute(\"ROLLBACK\");\n\n        ConfigGenerator config_gen;\n        config_gen.init(kServerUrl, {});\n        EXPECT_THROW_LIKE(\n          config_gen.create_router_accounts({}, {{\"account-host\", {\"host1\", \"host2\", \"host3\"}}}, \"cluster_user\"),\n          std::runtime_error, \"Error creating MySQL account for router: some error\"\n        );\n\n        EXPECT_TRUE(mock_mysql->empty());\n\n      } // for (unsigned fail_sql = 1; fail_sql <= 4; fail_sql++)\n    } // for (unsigned fail_host = 1; fail_host < 3; fail_host++)\n  } // for (TestType tt : {NATIVE, FALLBACK})\n}\n\nTEST_F(ConfigGeneratorTest, create_config_single_master) {\n  std::map<std::string, std::string> user_options;\n\n  ConfigGenerator config_gen;\n  common_pass_metadata_checks(mock_mysql.get());\n  config_gen.init(kServerUrl, {});\n  ConfigGenerator::Options options = config_gen.fill_options(false, user_options);\n\n  {\n    std::stringstream output;\n    config_gen.create_config(output,\n                        123, \"myrouter\", \"mysqlrouter\",\n                        \"server1,server2,server3\",\n                        \"mycluster\",\n                        \"myreplicaset\",\n                        \"cluster_user\",\n                        options);\n    ASSERT_THAT(output.str(),\n      Eq(\"# File automatically generated during MySQL Router bootstrap\\n\"\n        \"[DEFAULT]\\n\"\n        \"name=myrouter\\n\"\n        \"user=mysqlrouter\\n\"\n        \"connect_timeout=30\\n\"\n        \"read_timeout=30\\n\"\n        \"\\n\"\n        \"[logger]\\n\"\n        \"level = INFO\\n\"\n        \"\\n\"\n        \"[metadata_cache:mycluster]\\n\"\n        \"router_id=123\\n\"\n        \"bootstrap_server_addresses=server1,server2,server3\\n\"\n        \"user=cluster_user\\n\"\n        \"metadata_cluster=mycluster\\n\"\n        \"ttl=0.5\\n\"\n        \"\\n\"\n        \"[routing:mycluster_myreplicaset_rw]\\n\"\n        \"bind_address=0.0.0.0\\n\"\n        \"bind_port=6446\\n\"\n        \"destinations=metadata-cache://mycluster/myreplicaset?role=PRIMARY\\n\"\n        \"routing_strategy=round-robin\\n\"\n        \"protocol=classic\\n\"\n        \"\\n\"\n        \"[routing:mycluster_myreplicaset_ro]\\n\"\n        \"bind_address=0.0.0.0\\n\"\n        \"bind_port=6447\\n\"\n        \"destinations=metadata-cache://mycluster/myreplicaset?role=SECONDARY\\n\"\n        \"routing_strategy=round-robin\\n\"\n        \"protocol=classic\\n\"\n        \"\\n\"\n        \"[routing:mycluster_myreplicaset_x_rw]\\n\"\n        \"bind_address=0.0.0.0\\n\"\n        \"bind_port=64460\\n\"\n        \"destinations=metadata-cache://mycluster/myreplicaset?role=PRIMARY\\n\"\n        \"routing_strategy=round-robin\\n\"\n        \"protocol=x\\n\"\n        \"\\n\"\n        \"[routing:mycluster_myreplicaset_x_ro]\\n\"\n        \"bind_address=0.0.0.0\\n\"\n        \"bind_port=64470\\n\"\n        \"destinations=metadata-cache://mycluster/myreplicaset?role=SECONDARY\\n\"\n        \"routing_strategy=round-robin\\n\"\n        \"protocol=x\\n\"\n        \"\\n\"));\n  }\n  {\n    std::stringstream output;\n    // system instance (no key)\n    config_gen.create_config(output,\n                        123, \"\", \"\",\n                        \"server1,server2,server3\",\n                        \"mycluster\",\n                        \"myreplicaset\",\n                        \"cluster_user\",\n                        options);\n    ASSERT_THAT(output.str(),\n      Eq(\"# File automatically generated during MySQL Router bootstrap\\n\"\n          \"[DEFAULT]\\n\"\n          \"connect_timeout=30\\n\"\n          \"read_timeout=30\\n\"\n          \"\\n\"\n          \"[logger]\\n\"\n          \"level = INFO\\n\"\n          \"\\n\"\n          \"[metadata_cache:mycluster]\\n\"\n          \"router_id=123\\n\"\n          \"bootstrap_server_addresses=server1,server2,server3\\n\"\n          \"user=cluster_user\\n\"\n          \"metadata_cluster=mycluster\\n\"\n          \"ttl=0.5\\n\"\n          \"\\n\"\n          \"[routing:mycluster_myreplicaset_rw]\\n\"\n          \"bind_address=0.0.0.0\\n\"\n          \"bind_port=6446\\n\"\n          \"destinations=metadata-cache://mycluster/myreplicaset?role=PRIMARY\\n\"\n          \"routing_strategy=round-robin\\n\"\n          \"protocol=classic\\n\"\n          \"\\n\"\n          \"[routing:mycluster_myreplicaset_ro]\\n\"\n          \"bind_address=0.0.0.0\\n\"\n          \"bind_port=6447\\n\"\n          \"destinations=metadata-cache://mycluster/myreplicaset?role=SECONDARY\\n\"\n          \"routing_strategy=round-robin\\n\"\n          \"protocol=classic\\n\"\n          \"\\n\"\n          \"[routing:mycluster_myreplicaset_x_rw]\\n\"\n          \"bind_address=0.0.0.0\\n\"\n          \"bind_port=64460\\n\"\n          \"destinations=metadata-cache://mycluster/myreplicaset?role=PRIMARY\\n\"\n          \"routing_strategy=round-robin\\n\"\n          \"protocol=x\\n\"\n          \"\\n\"\n          \"[routing:mycluster_myreplicaset_x_ro]\\n\"\n          \"bind_address=0.0.0.0\\n\"\n          \"bind_port=64470\\n\"\n          \"destinations=metadata-cache://mycluster/myreplicaset?role=SECONDARY\\n\"\n          \"routing_strategy=round-robin\\n\"\n          \"protocol=x\\n\"\n          \"\\n\"));\n  }\n  {\n    std::stringstream output;\n    auto opts = user_options;\n    opts[\"base-port\"] = \"1234\";\n    options = config_gen.fill_options(false, opts);\n\n    config_gen.create_config(output,\n                        123, \"\", \"\",\n                        \"server1,server2,server3\",\n                        \"mycluster\",\n                        \"myreplicaset\",\n                        \"cluster_user\",\n                        options);\n    ASSERT_THAT(output.str(),\n      Eq(\"# File automatically generated during MySQL Router bootstrap\\n\"\n        \"[DEFAULT]\\n\"\n        \"connect_timeout=30\\n\"\n        \"read_timeout=30\\n\"\n        \"\\n\"\n        \"[logger]\\n\"\n        \"level = INFO\\n\"\n        \"\\n\"\n        \"[metadata_cache:mycluster]\\n\"\n        \"router_id=123\\n\"\n        \"bootstrap_server_addresses=server1,server2,server3\\n\"\n        \"user=cluster_user\\n\"\n        \"metadata_cluster=mycluster\\n\"\n        \"ttl=0.5\\n\"\n        \"\\n\"\n        \"[routing:mycluster_myreplicaset_rw]\\n\"\n        \"bind_address=0.0.0.0\\n\"\n        \"bind_port=1234\\n\"\n        \"destinations=metadata-cache://mycluster/myreplicaset?role=PRIMARY\\n\"\n        \"routing_strategy=round-robin\\n\"\n        \"protocol=classic\\n\"\n        \"\\n\"\n        \"[routing:mycluster_myreplicaset_ro]\\n\"\n        \"bind_address=0.0.0.0\\n\"\n        \"bind_port=1235\\n\"\n        \"destinations=metadata-cache://mycluster/myreplicaset?role=SECONDARY\\n\"\n        \"routing_strategy=round-robin\\n\"\n        \"protocol=classic\\n\"\n        \"\\n\"\n        \"[routing:mycluster_myreplicaset_x_rw]\\n\"\n        \"bind_address=0.0.0.0\\n\"\n        \"bind_port=1236\\n\"\n        \"destinations=metadata-cache://mycluster/myreplicaset?role=PRIMARY\\n\"\n        \"routing_strategy=round-robin\\n\"\n        \"protocol=x\\n\"\n        \"\\n\"\n        \"[routing:mycluster_myreplicaset_x_ro]\\n\"\n        \"bind_address=0.0.0.0\\n\"\n        \"bind_port=1237\\n\"\n        \"destinations=metadata-cache://mycluster/myreplicaset?role=SECONDARY\\n\"\n        \"routing_strategy=round-robin\\n\"\n        \"protocol=x\\n\"\n        \"\\n\"));\n  }\n  {\n    std::stringstream output;\n    auto opts = user_options;\n    opts[\"base-port\"] = \"123\";\n    opts[\"use-sockets\"] = \"1\";\n    opts[\"skip-tcp\"] = \"1\";\n    opts[\"socketsdir\"] = tmp_dir();\n    options = config_gen.fill_options(false, opts);\n\n    config_gen.create_config(output,\n                        123, \"\", \"\",\n                        \"server1,server2,server3\",\n                        \"mycluster\",\n                        \"myreplicaset\",\n                        \"cluster_user\",\n                        options);\n    ASSERT_THAT(output.str(),\n      Eq(\"# File automatically generated during MySQL Router bootstrap\\n\"\n        \"[DEFAULT]\\n\"\n        \"connect_timeout=30\\n\"\n        \"read_timeout=30\\n\"\n        \"\\n\"\n        \"[logger]\\n\"\n        \"level = INFO\\n\"\n        \"\\n\"\n        \"[metadata_cache:mycluster]\\n\"\n        \"router_id=123\\n\"\n        \"bootstrap_server_addresses=server1,server2,server3\\n\"\n        \"user=cluster_user\\n\"\n        \"metadata_cluster=mycluster\\n\"\n        \"ttl=0.5\\n\"\n        \"\\n\"\n        \"[routing:mycluster_myreplicaset_rw]\\n\"\n        \"socket=\" + tmp_dir() + \"/mysql.sock\\n\"\n        \"destinations=metadata-cache://mycluster/myreplicaset?role=PRIMARY\\n\"\n        \"routing_strategy=round-robin\\n\"\n        \"protocol=classic\\n\"\n        \"\\n\"\n        \"[routing:mycluster_myreplicaset_ro]\\n\"\n        \"socket=\" + tmp_dir() + \"/mysqlro.sock\\n\"\n        \"destinations=metadata-cache://mycluster/myreplicaset?role=SECONDARY\\n\"\n        \"routing_strategy=round-robin\\n\"\n        \"protocol=classic\\n\"\n        \"\\n\"\n        \"[routing:mycluster_myreplicaset_x_rw]\\n\"\n        \"socket=\" + tmp_dir() + \"/mysqlx.sock\\n\"\n        \"destinations=metadata-cache://mycluster/myreplicaset?role=PRIMARY\\n\"\n        \"routing_strategy=round-robin\\n\"\n        \"protocol=x\\n\"\n        \"\\n\"\n        \"[routing:mycluster_myreplicaset_x_ro]\\n\"\n        \"socket=\" + tmp_dir() + \"/mysqlxro.sock\\n\"\n        \"destinations=metadata-cache://mycluster/myreplicaset?role=SECONDARY\\n\"\n        \"routing_strategy=round-robin\\n\"\n        \"protocol=x\\n\"\n        \"\\n\"));\n  }\n  {\n    std::stringstream output;\n    auto opts = user_options;\n    opts[\"use-sockets\"] = \"1\";\n    opts[\"socketsdir\"] = tmp_dir();\n    options = config_gen.fill_options(false, opts);\n\n    config_gen.create_config(output,\n                        123, \"\", \"\",\n                        \"server1,server2,server3\",\n                        \"mycluster\",\n                        \"myreplicaset\",\n                        \"cluster_user\",\n                        options);\n    ASSERT_THAT(output.str(),\n      Eq(\"# File automatically generated during MySQL Router bootstrap\\n\"\n        \"[DEFAULT]\\n\"\n        \"connect_timeout=30\\n\"\n        \"read_timeout=30\\n\"\n        \"\\n\"\n        \"[logger]\\n\"\n        \"level = INFO\\n\"\n        \"\\n\"\n        \"[metadata_cache:mycluster]\\n\"\n        \"router_id=123\\n\"\n        \"bootstrap_server_addresses=server1,server2,server3\\n\"\n        \"user=cluster_user\\n\"\n        \"metadata_cluster=mycluster\\n\"\n        \"ttl=0.5\\n\"\n        \"\\n\"\n        \"[routing:mycluster_myreplicaset_rw]\\n\"\n        \"bind_address=0.0.0.0\\n\"\n        \"bind_port=6446\\n\"\n        \"socket=\" + tmp_dir() + \"/mysql.sock\\n\"\n        \"destinations=metadata-cache://mycluster/myreplicaset?role=PRIMARY\\n\"\n        \"routing_strategy=round-robin\\n\"\n        \"protocol=classic\\n\"\n        \"\\n\"\n        \"[routing:mycluster_myreplicaset_ro]\\n\"\n        \"bind_address=0.0.0.0\\n\"\n        \"bind_port=6447\\n\"\n        \"socket=\" + tmp_dir() + \"/mysqlro.sock\\n\"\n        \"destinations=metadata-cache://mycluster/myreplicaset?role=SECONDARY\\n\"\n        \"routing_strategy=round-robin\\n\"\n        \"protocol=classic\\n\"\n        \"\\n\"\n        \"[routing:mycluster_myreplicaset_x_rw]\\n\"\n        \"bind_address=0.0.0.0\\n\"\n        \"bind_port=64460\\n\"\n        \"socket=\" + tmp_dir() + \"/mysqlx.sock\\n\"\n        \"destinations=metadata-cache://mycluster/myreplicaset?role=PRIMARY\\n\"\n        \"routing_strategy=round-robin\\n\"\n        \"protocol=x\\n\"\n        \"\\n\"\n        \"[routing:mycluster_myreplicaset_x_ro]\\n\"\n        \"bind_address=0.0.0.0\\n\"\n        \"bind_port=64470\\n\"\n        \"socket=\" + tmp_dir() + \"/mysqlxro.sock\\n\"\n        \"destinations=metadata-cache://mycluster/myreplicaset?role=SECONDARY\\n\"\n        \"routing_strategy=round-robin\\n\"\n        \"protocol=x\\n\"\n        \"\\n\"));\n  }\n  {\n    std::stringstream output;\n    auto opts = user_options;\n    opts[\"bind-address\"] = \"127.0.0.1\";\n    options = config_gen.fill_options(false, opts);\n\n    config_gen.create_config(output,\n                        123, \"myrouter\", \"mysqlrouter\",\n                        \"server1,server2,server3\",\n                        \"mycluster\",\n                        \"myreplicaset\",\n                        \"cluster_user\",\n                        options);\n    ASSERT_THAT(output.str(),\n      Eq(\"# File automatically generated during MySQL Router bootstrap\\n\"\n        \"[DEFAULT]\\n\"\n        \"name=myrouter\\n\"\n        \"user=mysqlrouter\\n\"\n        \"connect_timeout=30\\n\"\n        \"read_timeout=30\\n\"\n        \"\\n\"\n        \"[logger]\\n\"\n        \"level = INFO\\n\"\n        \"\\n\"\n        \"[metadata_cache:mycluster]\\n\"\n        \"router_id=123\\n\"\n        \"bootstrap_server_addresses=server1,server2,server3\\n\"\n        \"user=cluster_user\\n\"\n        \"metadata_cluster=mycluster\\n\"\n        \"ttl=0.5\\n\"\n        \"\\n\"\n        \"[routing:mycluster_myreplicaset_rw]\\n\"\n        \"bind_address=127.0.0.1\\n\"\n        \"bind_port=6446\\n\"\n        \"destinations=metadata-cache://mycluster/myreplicaset?role=PRIMARY\\n\"\n        \"routing_strategy=round-robin\\n\"\n        \"protocol=classic\\n\"\n        \"\\n\"\n        \"[routing:mycluster_myreplicaset_ro]\\n\"\n        \"bind_address=127.0.0.1\\n\"\n        \"bind_port=6447\\n\"\n        \"destinations=metadata-cache://mycluster/myreplicaset?role=SECONDARY\\n\"\n        \"routing_strategy=round-robin\\n\"\n        \"protocol=classic\\n\"\n        \"\\n\"\n        \"[routing:mycluster_myreplicaset_x_rw]\\n\"\n        \"bind_address=127.0.0.1\\n\"\n        \"bind_port=64460\\n\"\n        \"destinations=metadata-cache://mycluster/myreplicaset?role=PRIMARY\\n\"\n        \"routing_strategy=round-robin\\n\"\n        \"protocol=x\\n\"\n        \"\\n\"\n        \"[routing:mycluster_myreplicaset_x_ro]\\n\"\n        \"bind_address=127.0.0.1\\n\"\n        \"bind_port=64470\\n\"\n        \"destinations=metadata-cache://mycluster/myreplicaset?role=SECONDARY\\n\"\n        \"routing_strategy=round-robin\\n\"\n        \"protocol=x\\n\"\n        \"\\n\"));\n  }\n\n}\n\n\nTEST_F(ConfigGeneratorTest, create_config_multi_master) {\n  std::stringstream output;\n\n  std::map<std::string, std::string> user_options;\n\n  ConfigGenerator config_gen;\n  common_pass_metadata_checks(mock_mysql.get());\n  config_gen.init(kServerUrl, {});\n  ConfigGenerator::Options options = config_gen.fill_options(true, user_options);\n  config_gen.create_config(output,\n                      123, \"myrouter\", \"\",\n                      \"server1,server2,server3\",\n                      \"mycluster\",\n                      \"myreplicaset\",\n                      \"cluster_user\",\n                      options);\n  ASSERT_THAT(output.str(),\n    Eq(\"# File automatically generated during MySQL Router bootstrap\\n\"\n        \"[DEFAULT]\\n\"\n        \"name=myrouter\\n\"\n        \"connect_timeout=30\\n\"\n        \"read_timeout=30\\n\"\n        \"\\n\"\n        \"[logger]\\n\"\n        \"level = INFO\\n\"\n        \"\\n\"\n        \"[metadata_cache:mycluster]\\n\"\n        \"router_id=123\\n\"\n        \"bootstrap_server_addresses=server1,server2,server3\\n\"\n        \"user=cluster_user\\n\"\n        \"metadata_cluster=mycluster\\n\"\n        \"ttl=0.5\\n\"\n        \"\\n\"\n        \"[routing:mycluster_myreplicaset_rw]\\n\"\n        \"bind_address=0.0.0.0\\n\"\n        \"bind_port=6446\\n\"\n        \"destinations=metadata-cache://mycluster/myreplicaset?role=PRIMARY\\n\"\n        \"routing_strategy=round-robin\\n\"\n        \"protocol=classic\\n\"\n        \"\\n\"\n        \"[routing:mycluster_myreplicaset_x_rw]\\n\"\n        \"bind_address=0.0.0.0\\n\"\n        \"bind_port=64460\\n\"\n        \"destinations=metadata-cache://mycluster/myreplicaset?role=PRIMARY\\n\"\n        \"routing_strategy=round-robin\\n\"\n        \"protocol=x\\n\"\n        \"\\n\"));\n}\n\nTEST_F(ConfigGeneratorTest, fill_options) {\n\n  ConfigGenerator config_gen;\n  common_pass_metadata_checks(mock_mysql.get());\n  config_gen.init(kServerUrl, {});\n\n  ConfigGenerator::Options options;\n  {\n    std::map<std::string, std::string> user_options;\n    options = config_gen.fill_options(true, user_options);\n    ASSERT_THAT(options.multi_master, Eq(true));\n    ASSERT_THAT(options.bind_address, Eq(\"\"));\n    ASSERT_THAT(options.rw_endpoint, Eq(true));\n    ASSERT_THAT(options.rw_endpoint.port, Eq(6446));\n    ASSERT_THAT(options.rw_endpoint.socket, Eq(\"\"));\n    ASSERT_THAT(options.ro_endpoint, Eq(false));\n    ASSERT_THAT(options.rw_x_endpoint, Eq(true));\n    ASSERT_THAT(options.ro_x_endpoint, Eq(false));\n    ASSERT_THAT(options.override_logdir, Eq(\"\"));\n    ASSERT_THAT(options.override_rundir, Eq(\"\"));\n    ASSERT_THAT(options.override_datadir, Eq(\"\"));\n  }\n  {\n    std::map<std::string, std::string> user_options;\n    user_options[\"bind-address\"] = \"127.0.0.1\";\n    options = config_gen.fill_options(true, user_options);\n    ASSERT_THAT(options.multi_master, Eq(true));\n    ASSERT_THAT(options.bind_address, Eq(\"127.0.0.1\"));\n    ASSERT_THAT(options.rw_endpoint, Eq(true));\n    ASSERT_THAT(options.rw_endpoint.port, Eq(6446));\n    ASSERT_THAT(options.rw_endpoint.socket, Eq(\"\"));\n    ASSERT_THAT(options.ro_endpoint, Eq(false));\n    ASSERT_THAT(options.rw_x_endpoint, Eq(true));\n    ASSERT_THAT(options.ro_x_endpoint, Eq(false));\n    ASSERT_THAT(options.override_logdir, Eq(\"\"));\n    ASSERT_THAT(options.override_rundir, Eq(\"\"));\n    ASSERT_THAT(options.override_datadir, Eq(\"\"));\n  }\n  {\n    std::map<std::string, std::string> user_options;\n    user_options[\"base-port\"] = \"1234\";\n    options = config_gen.fill_options(false, user_options);\n    ASSERT_THAT(options.multi_master, Eq(false));\n    ASSERT_THAT(options.bind_address, Eq(\"\"));\n    ASSERT_THAT(options.rw_endpoint, Eq(true));\n    ASSERT_THAT(options.rw_endpoint.port, Eq(1234));\n    ASSERT_THAT(options.rw_endpoint.socket, Eq(\"\"));\n    ASSERT_THAT(options.ro_endpoint, Eq(true));\n    ASSERT_THAT(options.ro_endpoint.port, Eq(1235));\n    ASSERT_THAT(options.ro_endpoint.socket, Eq(\"\"));\n    ASSERT_THAT(options.rw_x_endpoint, Eq(true));\n    ASSERT_THAT(options.ro_x_endpoint, Eq(true));\n    ASSERT_THAT(options.override_logdir, Eq(\"\"));\n    ASSERT_THAT(options.override_rundir, Eq(\"\"));\n    ASSERT_THAT(options.override_datadir, Eq(\"\"));\n  }\n  {\n    std::map<std::string, std::string> user_options;\n    user_options[\"base-port\"] = \"1\";\n    options = config_gen.fill_options(false, user_options);\n    ASSERT_THAT(options.rw_endpoint.port, Eq(1));\n    user_options[\"base-port\"] = \"3306\";\n    options = config_gen.fill_options(false, user_options);\n    ASSERT_THAT(options.rw_endpoint.port, Eq(3306));\n    user_options[\"base-port\"] = \"\";\n    ASSERT_THROW(\n      options = config_gen.fill_options(false, user_options),\n      std::runtime_error);\n    user_options[\"base-port\"] = \"-1\";\n    ASSERT_THROW(\n      options = config_gen.fill_options(false, user_options),\n      std::runtime_error);\n    user_options[\"base-port\"] = \"999999\";\n    ASSERT_THROW(\n      options = config_gen.fill_options(false, user_options),\n      std::runtime_error);\n    user_options[\"base-port\"] = \"0\";\n    ASSERT_THROW(\n      options = config_gen.fill_options(false, user_options),\n      std::runtime_error);\n    user_options[\"base-port\"] = \"65536\";\n    ASSERT_THROW(\n      options = config_gen.fill_options(false, user_options),\n      std::runtime_error);\n    user_options[\"base-port\"] = \"2000bozo\";\n    ASSERT_THROW(\n      options = config_gen.fill_options(false, user_options),\n      std::runtime_error);\n\n    // Bug #24808309\n    user_options[\"base-port\"] = \"65533\";\n    ASSERT_THROW_LIKE(\n      options = config_gen.fill_options(false, user_options),\n      std::runtime_error,\n      \"Invalid base-port number\");\n\n    user_options[\"base-port\"] = \"65532\";\n    ASSERT_NO_THROW(options = config_gen.fill_options(false, user_options));\n\n    ASSERT_THAT(options.rw_endpoint, Eq(true));\n    ASSERT_THAT(options.rw_endpoint.port, Eq(65532));\n    ASSERT_THAT(options.rw_endpoint.socket, Eq(\"\"));\n    ASSERT_THAT(options.ro_endpoint, Eq(true));\n    ASSERT_THAT(options.ro_endpoint.port, Eq(65533));\n    ASSERT_THAT(options.ro_endpoint.socket, Eq(\"\"));\n    ASSERT_THAT(options.rw_x_endpoint, Eq(true));\n    ASSERT_THAT(options.ro_x_endpoint, Eq(true));\n    ASSERT_THAT(options.rw_x_endpoint.port, Eq(65534));\n    ASSERT_THAT(options.rw_x_endpoint.socket, Eq(\"\"));\n    ASSERT_THAT(options.ro_x_endpoint, Eq(true));\n    ASSERT_THAT(options.ro_x_endpoint.port, Eq(65535));\n    ASSERT_THAT(options.ro_x_endpoint.socket, Eq(\"\"));\n  }\n  {\n     std::map<std::string, std::string> user_options;\n     user_options[\"bind-address\"] = \"invalid\";\n     ASSERT_THROW(\n       options = config_gen.fill_options(false, user_options),\n       std::runtime_error);\n     user_options[\"bind-address\"] = \"\";\n     ASSERT_THROW(\n       options = config_gen.fill_options(false, user_options),\n       std::runtime_error);\n     user_options[\"bind-address\"] = \"1.2.3.4.5\";\n     ASSERT_THROW(\n       options = config_gen.fill_options(false, user_options),\n       std::runtime_error);\n   }\n  {\n    std::map<std::string, std::string> user_options;\n    user_options[\"use-sockets\"] = \"1\";\n    user_options[\"skip-tcp\"] = \"1\";\n    options = config_gen.fill_options(false, user_options);\n    ASSERT_THAT(options.multi_master, Eq(false));\n    ASSERT_THAT(options.bind_address, Eq(\"\"));\n    ASSERT_THAT(options.rw_endpoint, Eq(true));\n    ASSERT_THAT(options.rw_endpoint.port, Eq(0));\n    ASSERT_THAT(options.rw_endpoint.socket, Eq(\"mysql.sock\"));\n    ASSERT_THAT(options.ro_endpoint, Eq(true));\n    ASSERT_THAT(options.ro_endpoint.port, Eq(0));\n    ASSERT_THAT(options.ro_endpoint.socket, Eq(\"mysqlro.sock\"));\n    ASSERT_THAT(options.rw_x_endpoint, Eq(true));\n    ASSERT_THAT(options.ro_x_endpoint, Eq(true));\n    ASSERT_THAT(options.override_logdir, Eq(\"\"));\n    ASSERT_THAT(options.override_rundir, Eq(\"\"));\n    ASSERT_THAT(options.override_datadir, Eq(\"\"));\n  }\n  {\n    std::map<std::string, std::string> user_options;\n    user_options[\"skip-tcp\"] = \"1\";\n    options = config_gen.fill_options(false, user_options);\n    ASSERT_THAT(options.multi_master, Eq(false));\n    ASSERT_THAT(options.bind_address, Eq(\"\"));\n    ASSERT_THAT(options.rw_endpoint, Eq(false));\n    ASSERT_THAT(options.rw_endpoint.port, Eq(0));\n    ASSERT_THAT(options.rw_endpoint.socket, Eq(\"\"));\n    ASSERT_THAT(options.ro_endpoint, Eq(false));\n    ASSERT_THAT(options.ro_endpoint.port, Eq(0));\n    ASSERT_THAT(options.ro_endpoint.socket, Eq(\"\"));\n    ASSERT_THAT(options.rw_x_endpoint, Eq(false));\n    ASSERT_THAT(options.ro_x_endpoint, Eq(false));\n    ASSERT_THAT(options.override_logdir, Eq(\"\"));\n    ASSERT_THAT(options.override_rundir, Eq(\"\"));\n    ASSERT_THAT(options.override_datadir, Eq(\"\"));\n  }\n  {\n    std::map<std::string, std::string> user_options;\n    user_options[\"use-sockets\"] = \"1\";\n    options = config_gen.fill_options(false, user_options);\n    ASSERT_THAT(options.multi_master, Eq(false));\n    ASSERT_THAT(options.bind_address, Eq(\"\"));\n    ASSERT_THAT(options.rw_endpoint, Eq(true));\n    ASSERT_THAT(options.rw_endpoint.port, Eq(6446));\n    ASSERT_THAT(options.rw_endpoint.socket, Eq(\"mysql.sock\"));\n    ASSERT_THAT(options.ro_endpoint, Eq(true));\n    ASSERT_THAT(options.ro_endpoint.port, Eq(6447));\n    ASSERT_THAT(options.ro_endpoint.socket, Eq(\"mysqlro.sock\"));\n    ASSERT_THAT(options.rw_x_endpoint, Eq(true));\n    ASSERT_THAT(options.ro_x_endpoint, Eq(true));\n    ASSERT_THAT(options.override_logdir, Eq(\"\"));\n    ASSERT_THAT(options.override_rundir, Eq(\"\"));\n    ASSERT_THAT(options.override_datadir, Eq(\"\"));\n  }\n  {\n    std::map<std::string, std::string> user_options;\n    options = config_gen.fill_options(false, user_options);\n    ASSERT_THAT(options.multi_master, Eq(false));\n    ASSERT_THAT(options.bind_address, Eq(\"\"));\n    ASSERT_THAT(options.rw_endpoint, Eq(true));\n    ASSERT_THAT(options.rw_endpoint.port, Eq(6446));\n    ASSERT_THAT(options.rw_endpoint.socket, Eq(\"\"));\n    ASSERT_THAT(options.ro_endpoint, Eq(true));\n    ASSERT_THAT(options.ro_endpoint.port, Eq(6447));\n    ASSERT_THAT(options.ro_endpoint.socket, Eq(\"\"));\n    ASSERT_THAT(options.rw_x_endpoint, Eq(true));\n    ASSERT_THAT(options.ro_x_endpoint, Eq(true));\n    ASSERT_THAT(options.override_logdir, Eq(\"\"));\n    ASSERT_THAT(options.override_rundir, Eq(\"\"));\n    ASSERT_THAT(options.override_datadir, Eq(\"\"));\n  }\n}\n\n//XXX TODO: add recursive directory delete function\n\nnamespace {\nenum action_t{ACTION_EXECUTE, ACTION_QUERY, ACTION_QUERY_ONE, ACTION_ERROR};\n\nstruct query_entry_t{\n  const char *query;\n  action_t action;\n  unsigned result_cols;\n  std::vector<std::vector<MySQLSessionReplayer::string>> results;\n  uint64_t last_insert_id;\n  unsigned error_code;\n\n  query_entry_t(const char *query_, action_t action_, uint64_t last_insert_id_ = 0, unsigned error_code_ = 0):\n    query(query_), action(action_), result_cols(0), last_insert_id(last_insert_id_), error_code(error_code_)\n  {}\n  query_entry_t(const char *query_, action_t action_,\n                unsigned results_cols_, const std::vector<std::vector<MySQLSessionReplayer::string>>& results_,\n                uint64_t last_insert_id_ = 0, unsigned error_code_ = 0):\n    query(query_), action(action_), result_cols(results_cols_), results(results_), last_insert_id(last_insert_id_), error_code(error_code_)\n  {}\n};\n\nstd::vector<query_entry_t> expected_bootstrap_queries = {\n  {\"START TRANSACTION\", ACTION_EXECUTE},\n  {\"SELECT host_id, host_name\", ACTION_QUERY_ONE, 2, {}},\n  {\"INSERT INTO mysql_innodb_cluster_metadata.hosts\", ACTION_EXECUTE},\n  {\"INSERT INTO mysql_innodb_cluster_metadata.routers\", ACTION_EXECUTE, 4},\n\n  // ConfigGenerator::delete_account_for_all_hosts() called before ConfigGenerator::create_router_accounts()\n  {\"SELECT host FROM mysql.user WHERE user = 'mysql_router4_012345678901'\", ACTION_QUERY, 1, {}},\n\n  // ConfigGenerator::create_account()\n  {\"CREATE USER mysql_router4_012345678901@'%'\", ACTION_EXECUTE},\n  {\"GRANT SELECT ON mysql_innodb_cluster_metadata.* TO mysql_router4_012345678901@'%'\", ACTION_EXECUTE},\n  {\"GRANT SELECT ON performance_schema.replication_group_members TO mysql_router4_012345678901@'%'\", ACTION_EXECUTE},\n  {\"GRANT SELECT ON performance_schema.replication_group_member_stats TO mysql_router4_012345678901@'%'\", ACTION_EXECUTE},\n\n  {\"UPDATE mysql_innodb_cluster_metadata.routers SET attributes = \", ACTION_EXECUTE},\n  {\"COMMIT\", ACTION_EXECUTE},\n};\n\nstatic void expect_bootstrap_queries(MySQLSessionReplayer *m, const char *cluster_name,\n                                     const std::vector<query_entry_t> &expected_queries = expected_bootstrap_queries) {\n  m->expect_query(\"\").then_return(4, {{cluster_name, \"myreplicaset\", \"pm\", \"somehost:3306\"}});\n  for (const auto &query: expected_queries) {\n    switch (query.action) {\n    case ACTION_EXECUTE:\n      m->expect_execute(query.query).then_ok(query.last_insert_id);\n      break;\n    case ACTION_QUERY:\n      m->expect_query(query.query).then_return(query.result_cols, query.results);\n      break;\n    case ACTION_QUERY_ONE:\n      m->expect_query_one(query.query).then_return(query.result_cols, query.results);\n      break;\n    default: /*ACTION_ERROR*/\n      m->expect_execute(query.query).then_error(\"ERROR:\", query.error_code);\n    }\n  }\n}\n\nstatic void bootstrap_name_test(MySQLSessionReplayer *mock_mysql,\n                                const std::string &dir,\n                                const std::string &name,\n                                bool expect_fail,\n                                const std::map<std::string, std::string> &default_paths) {\n  ::testing::InSequence s;\n\n  ConfigGenerator config_gen;\n  common_pass_metadata_checks(mock_mysql);\n  config_gen.init(kServerUrl, {});\n  if (!expect_fail)\n    expect_bootstrap_queries(mock_mysql, \"mycluster\");\n\n  std::map<std::string, std::string> options;\n  options[\"name\"] = name;\n  options[\"quiet\"] = \"1\";\n  options[\"id\"] = \"4\";\n  options[\"report-host\"] = \"dont.query.dns\";\n\n  KeyringInfo keyring_info(\"delme\", \"delme.key\");\n  config_gen.set_keyring_info(keyring_info);\n\n  config_gen.bootstrap_directory_deployment(dir,\n      options, {}, default_paths);\n}\n\n} // anonymous namespace\n\nTEST_F(ConfigGeneratorTest, bootstrap_invalid_name) {\n  const std::string dir = \"./bug24807941\";\n  delete_dir_recursive(dir);\n\n  // Bug#24807941\n  ASSERT_NO_THROW(bootstrap_name_test(mock_mysql.get(), dir, \"myname\", false, default_paths));\n  delete_dir_recursive(dir);\n  mysql_harness::reset_keyring();\n\n  ASSERT_NO_THROW(bootstrap_name_test(mock_mysql.get(),dir, \"myname\", false, default_paths));\n  delete_dir_recursive(dir);\n  mysql_harness::reset_keyring();\n\n  ASSERT_NO_THROW(bootstrap_name_test(mock_mysql.get(),dir, \"\", false, default_paths));\n  delete_dir_recursive(dir);\n  mysql_harness::reset_keyring();\n\n  ASSERT_THROW_LIKE(\n    bootstrap_name_test(mock_mysql.get(), dir, \"system\", true, default_paths),\n    std::runtime_error,\n    \"Router name 'system' is reserved\");\n  delete_dir_recursive(dir);\n  mysql_harness::reset_keyring();\n\n  std::vector<std::string> bad_names{\n    \"new\\nline\",\n    \"car\\rreturn\",\n  };\n  for (std::string &name : bad_names) {\n    ASSERT_THROW_LIKE(\n      bootstrap_name_test(mock_mysql.get(), dir, name, true, default_paths),\n      std::runtime_error,\n      \"Router name '\"+name+\"' contains invalid characters.\");\n    delete_dir_recursive(dir);\n    mysql_harness::reset_keyring();\n  }\n\n  ASSERT_THROW_LIKE(\n    bootstrap_name_test(mock_mysql.get(), dir, \"veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryverylongname\", true, default_paths),\n    std::runtime_error,\n    \"too long (max 255).\");\n  delete_dir_recursive(dir);\n  mysql_harness::reset_keyring();\n}\n\nTEST_F(ConfigGeneratorTest, bootstrap_cleanup_on_failure) {\n  const std::string dir = \"./bug24808634\";\n  delete_dir_recursive(dir);\n  delete_file(\"./bug24808634/delme.key\");\n\n  ASSERT_FALSE(mysql_harness::Path(dir).exists());\n  ASSERT_FALSE(mysql_harness::Path(\"./bug24808634/delme.key\").exists());\n\n  std::map<std::string, std::string> options;\n  options[\"name\"] = \"foobar\";\n  options[\"quiet\"] = \"1\";\n  options[\"report-host\"] = \"dont.query.dns\";\n\n  // cleanup on failure when dir didn't exist before\n  {\n    ConfigGenerator config_gen;\n    common_pass_metadata_checks(mock_mysql.get());\n    config_gen.init(kServerUrl, {});\n    mock_mysql->expect_query(\"SELECT F.cluster_name\").then_return(4, {{\"mycluter\", \"myreplicaset\", \"pm\", \"somehost:3306\"}});\n    mock_mysql->expect_execute(\"START TRANSACTION\").then_error(\"boo!\", 1234);\n\n    KeyringInfo keyring_info(\"delme\", \"delme.key\");\n    config_gen.set_keyring_info(keyring_info);\n\n    ASSERT_THROW_LIKE(\n      config_gen.bootstrap_directory_deployment(dir,\n          options, {}, default_paths),\n      mysqlrouter::MySQLSession::Error,\n      \"boo!\");\n\n    ASSERT_FALSE(mysql_harness::Path(dir).exists());\n    ASSERT_FALSE(mysql_harness::Path(\"./bug24808634/delme.key\").exists());\n  }\n  mysql_harness::reset_keyring();\n\n  // this should succeed, so that we can test that cleanup doesn't delete existing stuff\n  {\n    ConfigGenerator config_gen;\n    common_pass_metadata_checks(mock_mysql.get());\n    config_gen.init(kServerUrl, {});\n    expect_bootstrap_queries(mock_mysql.get(), \"mycluster\");\n\n    KeyringInfo keyring_info(\"delme\", \"delme.key\");\n    config_gen.set_keyring_info(keyring_info);\n\n    ASSERT_NO_THROW(\n      config_gen.bootstrap_directory_deployment(dir,\n          options, {}, default_paths));\n\n    ASSERT_TRUE(mysql_harness::Path(dir).exists());\n    ASSERT_TRUE(mysql_harness::Path(\"./bug24808634/delme.key\").exists());\n  }\n  mysql_harness::reset_keyring();\n\n  // don't cleanup on failure if dir already existed before\n  {\n    ConfigGenerator config_gen;\n      common_pass_metadata_checks(mock_mysql.get());\n    config_gen.init(kServerUrl, {});\n    mock_mysql->expect_query(\"\").then_return(4, {{\"mycluster\", \"myreplicaset\", \"pm\", \"somehost:3306\"}});\n    // force a failure during account creationg\n    mock_mysql->expect_execute(\"\").then_error(\"boo!\", 1234);\n\n    KeyringInfo keyring_info(\"delme\", \"delme.key\");\n    config_gen.set_keyring_info(keyring_info);\n\n    ASSERT_THROW_LIKE(\n      config_gen.bootstrap_directory_deployment(dir,\n            options, {}, default_paths),\n      std::runtime_error,\n      \"boo!\");\n\n    ASSERT_TRUE(mysql_harness::Path(dir).exists());\n    ASSERT_TRUE(mysql_harness::Path(dir).join(\"delme.key\").exists());\n  }\n  mysql_harness::reset_keyring();\n\n  // don't cleanup on failure in early validation if dir already existed before\n  {\n    ConfigGenerator config_gen;\n    common_pass_metadata_checks(mock_mysql.get());\n    config_gen.init(kServerUrl, {});\n    mock_mysql->expect_query(\"\").then_return(4, {{\"mycluter\", \"myreplicaset\", \"pm\", \"somehost:3306\"}});\n\n    std::map<std::string, std::string> options2 = options;\n    options2[\"name\"] = \"force\\nfailure\";\n\n    KeyringInfo keyring_info(\"delme\", \"delme.key\");\n    config_gen.set_keyring_info(keyring_info);\n\n    ASSERT_THROW(\n      config_gen.bootstrap_directory_deployment(dir,\n            options2, {}, default_paths),\n      std::runtime_error);\n    ASSERT_TRUE(mysql_harness::Path(dir).exists());\n    ASSERT_TRUE(mysql_harness::Path(dir).join(\"delme.key\").exists());\n  }\n  mysql_harness::reset_keyring();\n  delete_dir_recursive(dir);\n  delete_file(\"./bug24808634/delme.key\");\n}\n\nTEST_F(ConfigGeneratorTest, bug25391460) {\n  const std::string dir = \"./bug25391460\";\n  delete_dir_recursive(dir);\n\n  // Bug#24807941\n  {\n    ConfigGenerator config_gen;\n    common_pass_metadata_checks(mock_mysql.get());\n    expect_bootstrap_queries(mock_mysql.get(), \"mycluster\");\n    config_gen.init(kServerUrl, {});\n    mock_mysql->expect_query(\"\").then_return(4, {{\"mycluster\", \"myreplicaset\", \"pm\", \"somehost:3306\"}});\n\n    std::map<std::string, std::string> options;\n    options[\"quiet\"] = \"1\";\n    options[\"use-sockets\"] = \"1\";\n    options[\"report-host\"] = \"dont.query.dns\";\n\n    KeyringInfo keyring_info(\"delme\", \"delme.key\");\n    config_gen.set_keyring_info(keyring_info);\n\n    ASSERT_NO_THROW(\n      config_gen.bootstrap_directory_deployment(dir,\n            options, {}, default_paths));\n    ASSERT_TRUE(mysql_harness::Path(dir).exists());\n    ASSERT_TRUE(mysql_harness::Path(dir).join(\"delme.key\").exists());\n  }\n\n  // now read the config file and check that all socket paths are\n  // .../bug25391460/mysql*.sock instead of .../bug25391460/socketsdir/mysql*.sock\n  std::ifstream cf;\n  std::string basedir = mysql_harness::Path(dir).real_path().str();\n  cf.open(mysql_harness::Path(dir).join(\"mysqlrouter.conf\").str());\n  while (!cf.eof()) {\n    std::string line;\n    cf >> line;\n    if (line.compare(0, 7, \"socket=\") == 0) {\n      line = line.substr(7);\n      // check prefix/basedir\n      EXPECT_EQ(basedir, line.substr(0, basedir.length()));\n      std::string suffix = line.substr(basedir.length()+1);\n      // check filename extension\n      EXPECT_EQ(\".sock\", suffix.substr(suffix.length()-strlen(\".sock\")));\n      std::string::size_type end = suffix.rfind('/');\n      if (end == std::string::npos)\n        end = suffix.rfind('\\\\');\n      // check that the file is directly under the deployment directory\n      EXPECT_EQ(suffix.substr(end+1), suffix);\n    }\n  }\n\n  mysql_harness::reset_keyring();\n  delete_dir_recursive(dir);\n}\n\n\nstatic void bootstrap_overwrite_test(MySQLSessionReplayer *mock_mysql,\n                                     const std::string &dir,\n                                     const std::string &name,\n                                     bool force,\n                                     const char *cluster_name,\n                                     bool expect_fail,\n                                     const std::map<std::string, std::string> &default_paths) {\n  ::testing::InSequence s;\n\n  ConfigGenerator config_gen;\n  common_pass_metadata_checks(mock_mysql);\n  config_gen.init(kServerUrl, {});\n  if (!expect_fail)\n    expect_bootstrap_queries(mock_mysql, cluster_name);\n  else\n    mock_mysql->expect_query(\"\").then_return(4, {{cluster_name, \"myreplicaset\", \"pm\", \"somehost:3306\"}});\n\n  std::map<std::string, std::string> options;\n  options[\"name\"] = name;\n  options[\"quiet\"] = \"1\";\n  options[\"report-host\"] = \"dont.query.dns\";\n  if (force)\n    options[\"force\"] = \"1\";\n\n  KeyringInfo keyring_info(\"delme\", \"delme.key\");\n  config_gen.set_keyring_info(keyring_info);\n\n  config_gen.bootstrap_directory_deployment(dir,\n    options, {}, default_paths);\n}\n\n\nTEST_F(ConfigGeneratorTest, bootstrap_overwrite) {\n  std::string dir = \"./configtest\";\n\n  // pre-cleanup just in case\n  delete_dir_recursive(dir);\n  mysql_harness::reset_keyring();\n\n  // Overwrite tests. Run bootstrap twice on the same output directory\n  //\n  // Name    --force     cluster_name   Expected\n  // -------------------------------------------\n  // same    no          same           OK (refreshing config)\n  // same    no          diff           FAIL\n  // same    yes         same           OK\n  // same    yes         diff           OK (replacing config)\n  // diff    no          same           OK\n  // diff    no          diff           FAIL\n  // diff    yes         same           OK\n  // diff    yes         diff           OK\n  //\n  // diff name is just a rename, so no issue\n\n  SCOPED_TRACE(\"bootstrap_overwrite1\");\n  // same    no          same           OK (refreshing config)\n  ASSERT_NO_THROW(bootstrap_overwrite_test(mock_mysql.get(), dir, \"myname\", false, \"cluster\", false, default_paths));\n  mysql_harness::reset_keyring();\n  ASSERT_NO_THROW(bootstrap_overwrite_test(mock_mysql.get(), dir, \"myname\", false, \"cluster\", false, default_paths));\n  mysql_harness::reset_keyring();\n  ASSERT_FALSE(mysql_harness::Path(dir).join(\"mysqlrouter.conf.bak\").exists());\n  ASSERT_EQ(delete_dir_recursive(dir), 0);\n\n  SCOPED_TRACE(\"bootstrap_overwrite2\");\n  dir = \"./configtest2\";\n  // same    no          diff           FAIL\n  ASSERT_NO_THROW(bootstrap_overwrite_test(mock_mysql.get(), dir, \"myname\", false, \"cluster\", false, default_paths));\n  mysql_harness::reset_keyring();\n  ASSERT_THROW_LIKE(bootstrap_overwrite_test(mock_mysql.get(), dir, \"myname\", false, \"kluster\", true, default_paths),\n                    std::runtime_error,\n                    \"If you'd like to replace it, please use the --force\");\n  mysql_harness::reset_keyring();\n  ASSERT_FALSE(mysql_harness::Path(dir).join(\"mysqlrouter.conf.bak\").exists());\n  ASSERT_EQ(delete_dir_recursive(dir), 0);\n\n  dir = \"./configtest3\";\n  SCOPED_TRACE(\"bootstrap_overwrite3\");\n  // same    yes         same           OK\n  ASSERT_NO_THROW(bootstrap_overwrite_test(mock_mysql.get(), dir, \"myname\", true, \"cluster\", false, default_paths));\n  mysql_harness::reset_keyring();\n  ASSERT_NO_THROW(bootstrap_overwrite_test(mock_mysql.get(), dir, \"myname\", true, \"cluster\", false, default_paths));\n  mysql_harness::reset_keyring();\n  ASSERT_FALSE(mysql_harness::Path(dir).join(\"mysqlrouter.conf.bak\").exists());\n  ASSERT_EQ(delete_dir_recursive(dir), 0);\n\n  dir = \"./configtest4\";\n  SCOPED_TRACE(\"bootstrap_overwrite4\");\n  // same    yes         diff           OK (replacing config)\n  ASSERT_NO_THROW(bootstrap_overwrite_test(mock_mysql.get(), dir, \"myname\", false, \"cluster\", false, default_paths));\n  mysql_harness::reset_keyring();\n  ASSERT_NO_THROW(bootstrap_overwrite_test(mock_mysql.get(), dir, \"myname\", true, \"kluster\", false, default_paths));\n  mysql_harness::reset_keyring();\n  ASSERT_TRUE(mysql_harness::Path(dir).join(\"mysqlrouter.conf.bak\").exists());\n  ASSERT_EQ(delete_dir_recursive(dir), 0);\n\n  dir = \"./configtest5\";\n  SCOPED_TRACE(\"bootstrap_overwrite5\");\n  // diff    no          same           OK (refreshing config)\n  ASSERT_NO_THROW(bootstrap_overwrite_test(mock_mysql.get(), dir, \"myname\", false, \"cluster\", false, default_paths));\n  mysql_harness::reset_keyring();\n  ASSERT_NO_THROW(bootstrap_overwrite_test(mock_mysql.get(), dir, \"xmyname\", false, \"cluster\", false, default_paths));\n  mysql_harness::reset_keyring();\n  ASSERT_TRUE(mysql_harness::Path(dir).join(\"mysqlrouter.conf.bak\").exists());\n  ASSERT_EQ(delete_dir_recursive(dir), 0);\n\n  dir = \"./configtest6\";\n  SCOPED_TRACE(\"bootstrap_overwrite6\");\n  // diff    no          diff           FAIL\n  ASSERT_NO_THROW(bootstrap_overwrite_test(mock_mysql.get(), dir, \"myname\", false, \"cluster\", false, default_paths));\n  mysql_harness::reset_keyring();\n  ASSERT_THROW_LIKE(bootstrap_overwrite_test(mock_mysql.get(), dir, \"xmyname\", false, \"kluster\", true, default_paths),\n                    std::runtime_error,\n                    \"If you'd like to replace it, please use the --force\");\n  mysql_harness::reset_keyring();\n  ASSERT_FALSE(mysql_harness::Path(dir).join(\"mysqlrouter.conf.bak\").exists());\n  ASSERT_EQ(delete_dir_recursive(dir), 0);\n\n  dir = \"./configtest7\";\n  SCOPED_TRACE(\"bootstrap_overwrite7\");\n  // diff    yes         same           OK\n  ASSERT_NO_THROW(bootstrap_overwrite_test(mock_mysql.get(), dir, \"myname\", true, \"cluster\", false, default_paths));\n  mysql_harness::reset_keyring();\n  ASSERT_NO_THROW(bootstrap_overwrite_test(mock_mysql.get(), dir, \"xmyname\", true, \"cluster\", false, default_paths));\n  mysql_harness::reset_keyring();\n  ASSERT_TRUE(mysql_harness::Path(dir).join(\"mysqlrouter.conf.bak\").exists());\n  ASSERT_EQ(delete_dir_recursive(dir), 0);\n\n  dir = \"./configtest8\";\n  SCOPED_TRACE(\"bootstrap_overwrite8\");\n  // diff    yes         diff           OK (replacing config)\n  ASSERT_NO_THROW(bootstrap_overwrite_test(mock_mysql.get(), dir, \"myname\", false, \"cluster\", false, default_paths));\n  mysql_harness::reset_keyring();\n  ASSERT_NO_THROW(bootstrap_overwrite_test(mock_mysql.get(), dir, \"xmyname\", true, \"kluster\", false, default_paths));\n  mysql_harness::reset_keyring();\n  ASSERT_TRUE(mysql_harness::Path(dir).join(\"mysqlrouter.conf.bak\").exists());\n  ASSERT_EQ(delete_dir_recursive(dir), 0);\n}\n\n\nstatic void test_key_length(MySQLSessionReplayer *mock_mysql,\n                            const std::string &key,\n                            const std::map<std::string, std::string> &default_paths) {\n  using std::placeholders::_1;\n  ::testing::InSequence s;\n\n  mysqlrouter::set_prompt_password([key](const std::string&) -> std::string {\n    return key;\n  });\n  ConfigGenerator config_gen;\n  common_pass_metadata_checks(mock_mysql);\n  config_gen.init(kServerUrl, {});\n  expect_bootstrap_queries(mock_mysql, \"mycluster\");\n\n  std::map<std::string, std::string> options;\n  options[\"name\"] = \"test\";\n  options[\"quiet\"] = \"1\";\n  options[\"report-host\"] = \"dont.query.dns\";\n\n  KeyringInfo keyring_info(\"delme\", \"\");\n  config_gen.set_keyring_info(keyring_info);\n\n  config_gen.bootstrap_directory_deployment(\"key_too_long\",\n      options, {}, default_paths);\n}\n\nTEST_F(ConfigGeneratorTest, key_too_long) {\n  ASSERT_FALSE(mysql_harness::Path(\"key_too_long\").exists());\n\n  // bug #24942008, keyring key too long\n  ASSERT_NO_THROW(test_key_length(mock_mysql.get(), std::string(250, 'x'), default_paths));\n  delete_dir_recursive(\"key_too_long\");\n  mysql_harness::reset_keyring();\n\n  ASSERT_NO_THROW(test_key_length(mock_mysql.get(), std::string(255, 'x'), default_paths));\n  delete_dir_recursive(\"key_too_long\");\n  mysql_harness::reset_keyring();\n\n  ASSERT_THROW_LIKE(test_key_length(mock_mysql.get(), std::string(256, 'x'), default_paths),\n    std::runtime_error,\n    \"too long\");\n  delete_dir_recursive(\"key_too_long\");\n  mysql_harness::reset_keyring();\n\n  ASSERT_THROW_LIKE(test_key_length(mock_mysql.get(), std::string(5000, 'x'), default_paths),\n    std::runtime_error,\n    \"too long\");\n  delete_dir_recursive(\"key_too_long\");\n  mysql_harness::reset_keyring();\n}\n\nTEST_F(ConfigGeneratorTest, bad_master_key) {\n  // bug #24955928\n  delete_dir_recursive(\"./delme\");\n\n  std::map<std::string, std::string> options;\n  options[\"name\"] = \"foo\";\n  options[\"quiet\"] = \"1\";\n  options[\"report-host\"] = \"dont.query.dns\";\n\n  // reconfiguring with an empty master key file throws an error referencing\n  // the temporary file name instead of the actual name\n  {\n    ::testing::InSequence s;\n\n    ConfigGenerator config_gen;\n    common_pass_metadata_checks(mock_mysql.get());\n    config_gen.init(kServerUrl, {});\n    expect_bootstrap_queries(mock_mysql.get(), \"mycluster\");\n\n    KeyringInfo keyring_info(\"delme\", \"key\");\n    config_gen.set_keyring_info(keyring_info);\n\n    config_gen.bootstrap_directory_deployment(\"./delme\",\n        options, {}, default_paths);\n\n    mysql_harness::reset_keyring();\n  }\n  {\n    delete_file(\"delme/emptyfile\");\n    std::ofstream f(\"delme/emptyfile\");\n    ::testing::InSequence s;\n\n    ConfigGenerator config_gen;\n    common_pass_metadata_checks(mock_mysql.get());\n    config_gen.init(kServerUrl, {});\n    expect_bootstrap_queries(mock_mysql.get(), \"mycluster\");\n\n    KeyringInfo keyring_info(\"delme\", \"emptyfile\");\n    config_gen.set_keyring_info(keyring_info);\n\n    try {\n      config_gen.bootstrap_directory_deployment(\"./delme\",\n          options, {}, default_paths);\n      FAIL() << \"Was expecting exception but got none\\n\";\n    } catch (std::runtime_error &e) {\n      if (strstr(e.what(), \".tmp\"))\n        FAIL() << \"Exception text is: \" << e.what() << \"\\n\";\n      std::string expected = std::string(\"Invalid master key file \");\n      ASSERT_EQ(expected, std::string(e.what()).substr(0, expected.size()));\n    }\n  }\n  delete_dir_recursive(\"./delme\");\n  delete_file(\"emptyfile\");\n  mysql_harness::reset_keyring();\n  // directory name but no filename\n  {\n    ::testing::InSequence s;\n\n    ConfigGenerator config_gen;\n    common_pass_metadata_checks(mock_mysql.get());\n    config_gen.init(kServerUrl, {});\n    expect_bootstrap_queries(mock_mysql.get(), \"mycluster\");\n\n    KeyringInfo keyring_info(\"delme\", \".\");\n    config_gen.set_keyring_info(keyring_info);\n\n    ASSERT_THROW_LIKE(\n      config_gen.bootstrap_directory_deployment(\"./delme\",\n        options, {}, default_paths),\n      std::runtime_error,\n      \"Invalid master key file\");\n  }\n  delete_dir_recursive(\"./delme\");\n  mysql_harness::reset_keyring();\n}\n\nTEST_F(ConfigGeneratorTest, full_test) {\n  delete_dir_recursive(\"./delme\");\n  ::testing::InSequence s;\n\n  ConfigGenerator config_gen;\n  common_pass_metadata_checks(mock_mysql.get());\n  config_gen.init(kServerUrl, {});\n  expect_bootstrap_queries(mock_mysql.get(), \"mycluster\");\n\n  std::map<std::string, std::string> options;\n  options[\"name\"] = \"foo\";\n  options[\"quiet\"] = \"1\";\n  options[\"report-host\"] = \"dont.query.dns\";\n\n  KeyringInfo keyring_info(\"delme\", \"masterkey\");\n  config_gen.set_keyring_info(keyring_info);\n\n  ASSERT_NO_THROW(\n      config_gen.bootstrap_directory_deployment(\"./delme\",\n        options, {}, default_paths));\n\n  std::string value;\n  mysql_harness::Config config(mysql_harness::Config::allow_keys);\n  config.read(\"delme/mysqlrouter.conf\");\n\n  value = config.get_default(\"master_key_path\");\n  EXPECT_TRUE(ends_with(value, \"delme/masterkey\"));\n\n  value = config.get_default(\"name\");\n  EXPECT_EQ(value, \"foo\");\n\n  value = config.get_default(\"keyring_path\");\n  EXPECT_EQ(mysql_harness::Path(value).basename(), \"delme\");\n\n  delete_dir_recursive(\"delme\");\n  mysql_harness::reset_keyring();\n}\n\nTEST_F(ConfigGeneratorTest, empty_config_file) {\n  ConfigGenerator config;\n  uint32_t router_id;\n  const std::string test_dir(\"./delme\");\n  const std::string conf_path(test_dir + \"/mysqlrouter.conf\");\n\n  delete_dir_recursive(test_dir);\n  mysqlrouter::mkdir(test_dir, 0700);\n\n  std::ofstream file(conf_path, std::ofstream::out | std::ofstream::trunc);\n  file.close();\n\n  EXPECT_NO_THROW(\n    std::tie(router_id, std::ignore) = config.get_router_id_and_name_from_config(conf_path, \"dummy\", false)\n  );\n  EXPECT_EQ(router_id, uint32_t(0));\n\n  delete_dir_recursive(test_dir);\n  mysql_harness::reset_keyring();\n}\n\nTEST_F(ConfigGeneratorTest, ssl_stage1_cmdline_arg_parse) {\n\n  // These tests verify that SSL options are handled correctly at argument parsing stage during bootstrap.\n  // Note that at this stage, we only care about arguments being passed further down, and rely on mysql_*()\n  // calls to deal with eventual inconsistencies. The only exception to this rule is parsing --ssl-mode,\n  // which is a string that has to be converted to an SSL_MODE_* enum (though arguably that validation\n  // could also be delayed).\n\n  // --ssl-mode not given\n  {                               //vv---- vital!  We rely on it to exit out of MySQLRouter::init()\n    std::vector<std::string> argv {\"-V\", \"--bootstrap\", \"0:3310\" };\n    MySQLRouter router(Path(), argv);\n    EXPECT_EQ(0u, router.bootstrap_options_.count(\"ssl_mode\"));\n  }\n\n  // --ssl-mode missing or empty argument\n  {\n    const std::vector<std::string> argument_required_options{\"--ssl-mode\",\n        \"--ssl-cipher\", \"--tls-version\",\n        \"--ssl-ca\", \"--ssl-capath\", \"--ssl-crl\", \"--ssl-crlpath\",\n        \"--ssl-cert\", \"--ssl-key\"\n    };\n\n    for (auto &opt : argument_required_options) {\n                                           //vv---- vital!  We rely on it to exit out of MySQLRouter::init()\n      const std::vector<std::string> argv {\"-V\", \"--bootstrap\", \"0:3310\", opt};\n      try {\n        MySQLRouter router(Path(), argv);\n        FAIL() << \"Expected std::invalid_argument to be thrown\";\n      } catch (const std::runtime_error &e) {\n        EXPECT_STREQ((\"option '\"+opt+\"' requires a value.\").c_str(), e.what()); // TODO it would be nice to make case consistent\n        SUCCEED();\n      } catch (...) {\n        FAIL() << \"Expected std::runtime_error to be thrown\";\n      }\n\n      // the value is required but also it CAN'T be empty, like when the user uses --tls-version \"\"\n      const std::vector<std::string> argv2 {\"-V\", \"--bootstrap\", \"0:3310\", opt, \"\"};\n      try {\n        MySQLRouter router(Path(), argv2);\n        FAIL() << \"Expected std::invalid_argument to be thrown\";\n      } catch (const std::runtime_error &e) {\n        if (opt == \"--ssl-mode\") {\n          // The error for -ssl-mode is sligtly different than for other options - detected differently\n          EXPECT_STREQ(\"Invalid value for --ssl-mode option\", e.what());\n        }\n        else {\n          EXPECT_STREQ((\"Value for option '\"+opt+\"' can't be empty.\").c_str(), e.what());\n        }\n        SUCCEED();\n      } catch (...) {\n        FAIL() << \"Expected std::runtime_error to be thrown\";\n      }\n    }\n  }\n\n  // --ssl-mode has an invalid argument\n  {                               //vv---- vital!  We rely on it to exit out of MySQLRouter::init()\n    std::vector<std::string> argv {\"-V\", \"--ssl-mode\", \"bad\", \"--bootstrap\", \"0:3310\"};\n    try {\n      MySQLRouter router(Path(), argv);\n      FAIL() << \"Expected std::invalid_argument to be thrown\";\n    } catch (const std::runtime_error &e) {\n      EXPECT_STREQ(\"Invalid value for --ssl-mode option\", e.what());\n      SUCCEED();\n    } catch (...) {\n      FAIL() << \"Expected std::runtime_error to be thrown\";\n    }\n  }\n\n  // --ssl-mode has an invalid argument\n  {                               //vv---- vital!  We rely on it to exit out of MySQLRouter::init()\n    std::vector<std::string> argv {\"-V\", \"--bootstrap\", \"0:3310\", \"--ssl-mode\", \"bad\"};\n    try {\n      MySQLRouter router(Path(), argv);\n      FAIL() << \"Expected std::invalid_argument to be thrown\";\n    } catch (const std::runtime_error &e) {\n      EXPECT_STREQ(\"Invalid value for --ssl-mode option\", e.what());\n      SUCCEED();\n    } catch (...) {\n      FAIL() << \"Expected std::runtime_error to be thrown\";\n    }\n  }\n\n  // --ssl-mode = DISABLED + uppercase\n  {                               //vv---- vital!  We rely on it to exit out of MySQLRouter::init()\n    std::vector<std::string> argv {\"-V\", \"--bootstrap\", \"0:3310\", \"--ssl-mode\", \"DISABLED\"};\n    MySQLRouter router(Path(), argv);\n    EXPECT_EQ(\"DISABLED\", router.bootstrap_options_.at(\"ssl_mode\"));\n  }\n\n  // --ssl-mode = PREFERRED + lowercase\n  {                               //vv---- vital!  We rely on it to exit out of MySQLRouter::init()\n    std::vector<std::string> argv {\"-V\", \"--bootstrap\", \"0:3310\", \"--ssl-mode\", \"preferred\"};\n    MySQLRouter router(Path(), argv);\n    EXPECT_EQ(\"preferred\", router.bootstrap_options_.at(\"ssl_mode\"));\n  }\n\n  // --ssl-mode = REQUIRED + mixedcase\n  {                               //vv---- vital!  We rely on it to exit out of MySQLRouter::init()\n    std::vector<std::string> argv {\"-V\", \"--bootstrap\", \"0:3310\", \"--ssl-mode\", \"rEqUIrEd\"};\n    MySQLRouter router(Path(), argv);\n    EXPECT_EQ(\"rEqUIrEd\", router.bootstrap_options_.at(\"ssl_mode\"));\n  }\n\n  // --ssl-mode = VERIFY_CA\n  {                               //vv---- vital!  We rely on it to exit out of MySQLRouter::init()\n    std::vector<std::string> argv {\"-V\", \"--bootstrap\", \"0:3310\", \"--ssl-mode\", \"verify_ca\"};\n    MySQLRouter router(Path(), argv);\n    EXPECT_EQ(\"verify_ca\", router.bootstrap_options_.at(\"ssl_mode\"));\n  }\n\n  // --ssl-mode = VERIFY_CA, --ssl-ca etc\n  {                               //vv---- vital!  We rely on it to exit out of MySQLRouter::init()\n    std::vector<std::string> argv {\"-V\", \"--bootstrap\", \"0:3310\", \"--ssl-mode\", \"verify_ca\",\n                                    \"--ssl-ca=/some/ca.pem\", \"--ssl-capath=/some/cadir\",\n                                    \"--ssl-crl=/some/crl.pem\", \"--ssl-crlpath=/some/crldir\"};\n    MySQLRouter router(Path(), argv);\n    EXPECT_EQ(\"verify_ca\", router.bootstrap_options_.at(\"ssl_mode\"));\n    EXPECT_EQ(\"/some/ca.pem\", router.bootstrap_options_.at(\"ssl_ca\"));\n    EXPECT_EQ(\"/some/cadir\", router.bootstrap_options_.at(\"ssl_capath\"));\n    EXPECT_EQ(\"/some/crl.pem\", router.bootstrap_options_.at(\"ssl_crl\"));\n    EXPECT_EQ(\"/some/crldir\", router.bootstrap_options_.at(\"ssl_crlpath\"));\n  }\n\n  // --ssl-mode = VERIFY_IDENTITY, --ssl-ca etc\n  {                               //vv---- vital!  We rely on it to exit out of MySQLRouter::init()\n    std::vector<std::string> argv {\"-V\", \"--bootstrap\", \"0:3310\", \"--ssl-mode\", \"verify_identity\",\n                                    \"--ssl-ca=/some/ca.pem\", \"--ssl-capath=/some/cadir\",\n                                    \"--ssl-crl=/some/crl.pem\", \"--ssl-crlpath=/some/crldir\"};\n    MySQLRouter router(Path(), argv);\n    EXPECT_EQ(\"verify_identity\", router.bootstrap_options_.at(\"ssl_mode\"));\n    EXPECT_EQ(\"/some/ca.pem\", router.bootstrap_options_.at(\"ssl_ca\"));\n    EXPECT_EQ(\"/some/cadir\", router.bootstrap_options_.at(\"ssl_capath\"));\n    EXPECT_EQ(\"/some/crl.pem\", router.bootstrap_options_.at(\"ssl_crl\"));\n    EXPECT_EQ(\"/some/crldir\", router.bootstrap_options_.at(\"ssl_crlpath\"));\n  }\n\n  // --ssl-mode = REQUIRED, --ssl-* cipher options\n  {                               //vv---- vital!  We rely on it to exit out of MySQLRouter::init()\n    std::vector<std::string> argv {\"-V\", \"--bootstrap\", \"0:3310\", \"--ssl-mode\", \"required\",\n                                   \"--ssl-cipher\",  \"FOO-BAR-SHA678\", \"--tls-version\", \"TLSv1\"};\n    MySQLRouter router(Path(), argv);\n    EXPECT_EQ(\"required\", router.bootstrap_options_.at(\"ssl_mode\"));\n    EXPECT_EQ(\"FOO-BAR-SHA678\", router.bootstrap_options_.at(\"ssl_cipher\"));\n    EXPECT_EQ(\"TLSv1\", router.bootstrap_options_.at(\"tls_version\"));\n  }\n\n  // --ssl-mode = REQUIRED, --ssl-cert, --ssl-key\n  {                               //vv---- vital!  We rely on it to exit out of MySQLRouter::init()\n    std::vector<std::string> argv {\"-V\", \"--bootstrap\", \"0:3310\", \"--ssl-mode\", \"required\", \"--ssl-cert=/some/cert.pem\", \"--ssl-key=/some/key.pem\"};\n    MySQLRouter router(Path(), argv);\n    EXPECT_EQ(\"required\", router.bootstrap_options_.at(\"ssl_mode\"));\n    EXPECT_EQ(\"/some/cert.pem\", router.bootstrap_options_.at(\"ssl_cert\"));\n    EXPECT_EQ(\"/some/key.pem\", router.bootstrap_options_.at(\"ssl_key\"));\n  }\n}\n\nTEST_F(ConfigGeneratorTest, ssl_stage2_bootstrap_connection) {\n\n  // These tests verify that MySQLSession::set_ssl_options() gets called with appropriate\n  // SSL options before making connection to metadata server during bootstrap\n\n  mysqlrouter::set_prompt_password([](const std::string&) -> std::string { return \"\"; });\n\n  // mode\n  {\n    common_pass_metadata_checks(mock_mysql.get());\n    ConfigGenerator config_gen;\n    config_gen.init(\"\", {{\"ssl_mode\", \"DISABLED\"}});   // DISABLED + uppercase\n    EXPECT_EQ(mock_mysql->last_ssl_mode, SSL_MODE_DISABLED);\n  }\n  {\n    common_pass_metadata_checks(mock_mysql.get());\n    ConfigGenerator config_gen;\n    config_gen.init(\"\", {{\"ssl_mode\", \"preferred\"}});  // PREFERRED + lowercase\n    EXPECT_EQ(mock_mysql->last_ssl_mode, SSL_MODE_PREFERRED);\n  }\n  {\n    common_pass_metadata_checks(mock_mysql.get());\n    ConfigGenerator config_gen;\n    config_gen.init(\"\", {{\"ssl_mode\", \"rEqUIrEd\"}});   // REQUIRED + mixedcase\n    EXPECT_EQ(mock_mysql->last_ssl_mode, SSL_MODE_REQUIRED);\n  }\n  {\n    common_pass_metadata_checks(mock_mysql.get());\n    ConfigGenerator config_gen;\n    config_gen.init(\"\", {{\"ssl_mode\", \"VERIFY_CA\"}});\n    EXPECT_EQ(mock_mysql->last_ssl_mode, SSL_MODE_VERIFY_CA);\n  }\n  {\n    common_pass_metadata_checks(mock_mysql.get());\n    ConfigGenerator config_gen;\n    config_gen.init(\"\", {{\"ssl_mode\", \"VERIFY_IDENTITY\"}});\n    EXPECT_EQ(mock_mysql->last_ssl_mode, SSL_MODE_VERIFY_IDENTITY);\n  }\n  {\n    // invalid ssl_mode should get handled at arg-passing stage, and so we have a unit test for that\n    // in ssl_stage1_cmdline_arg_parse test above\n  }\n\n  // other fields\n  {\n    common_pass_metadata_checks(mock_mysql.get());\n    ConfigGenerator config_gen;\n    config_gen.init(\"\", {\n      {\"ssl_ca\",      \"/some/ca/file\"},\n      {\"ssl_capath\",  \"/some/ca/dir\"},\n      {\"ssl_crl\",     \"/some/crl/file\"},\n      {\"ssl_crlpath\", \"/some/crl/dir\"},\n      {\"ssl_cipher\",  \"FOO-BAR-SHA678\"},\n      {\"tls_version\", \"TLSv1\"},\n      {\"ssl_cert\",\"/some/cert.pem\"},\n      {\"ssl_key\", \"/some/key.pem\"},\n    });\n    EXPECT_EQ(mock_mysql->last_ssl_ca,      \"/some/ca/file\");\n    EXPECT_EQ(mock_mysql->last_ssl_capath,  \"/some/ca/dir\");\n    EXPECT_EQ(mock_mysql->last_ssl_crl,     \"/some/crl/file\");\n    EXPECT_EQ(mock_mysql->last_ssl_crlpath, \"/some/crl/dir\");\n    EXPECT_EQ(mock_mysql->last_ssl_cipher,  \"FOO-BAR-SHA678\");\n    EXPECT_EQ(mock_mysql->last_tls_version, \"TLSv1\");\n    EXPECT_EQ(mock_mysql->last_ssl_cert,    \"/some/cert.pem\");\n    EXPECT_EQ(mock_mysql->last_ssl_key,     \"/some/key.pem\");\n  }\n}\n\nTEST_F(ConfigGeneratorTest, ssl_stage3_create_config) {\n\n  // These tests verify that config parameters passed to ConfigGenerator::create_config() will make\n  // it to configuration file as expected. Note that even though ssl_mode options are not case-sensive,\n  // their case should be preserved (written to config file exactly as given in bootstrap options).\n\n  ConfigGenerator config_gen;\n\n  auto test_config_output = [&config_gen](const std::map<std::string, std::string>& user_options, const char* result) {\n    ConfigGenerator::Options options = config_gen.fill_options(false, user_options);\n    std::stringstream output;\n    config_gen.create_config(output, 123, \"myrouter\", \"user\", \"server1,server2,server3\",\n                             \"mycluster\", \"myreplicaset\", \"cluster_user\", options);\n    EXPECT_THAT(output.str(), HasSubstr(result));\n  };\n\n  test_config_output({{\"ssl_mode\", \"DISABLED\"}},  \"ssl_mode=DISABLED\");   // DISABLED + uppercase\n  test_config_output({{\"ssl_mode\", \"preferred\"}}, \"ssl_mode=preferred\");  // PREFERRED + lowercase\n  test_config_output({{\"ssl_mode\", \"rEqUIrEd\"}},  \"ssl_mode=rEqUIrEd\");   // REQUIRED + mixedcase\n  test_config_output({{\"ssl_mode\", \"Verify_Ca\"}}, \"ssl_mode=Verify_Ca\");\n  test_config_output({{\"ssl_mode\", \"Verify_identity\"}},  \"ssl_mode=Verify_identity\");\n\n  test_config_output({{\"ssl_ca\", \"/some/path\"}}, \"ssl_ca=/some/path\");\n  test_config_output({{\"ssl_capath\", \"/some/path\"}}, \"ssl_capath=/some/path\");\n  test_config_output({{\"ssl_crl\", \"/some/path\"}}, \"ssl_crl=/some/path\");\n  test_config_output({{\"ssl_crlpath\", \"/some/path\"}}, \"ssl_crlpath=/some/path\");\n  test_config_output({{\"ssl_cipher\", \"FOO-BAR-SHA678\"}}, \"ssl_cipher=FOO-BAR-SHA678\");\n  test_config_output({{\"tls_version\", \"TLSv1\"}}, \"tls_version=TLSv1\");\n}\n\nTEST_F(ConfigGeneratorTest, warn_on_no_ssl) {\n\n  // These test warn_on_no_ssl(). For convenience, it returns true if no warning has been issued,\n  // false if it issued a warning. And it throws if something went wrong.\n\n  constexpr char kQuery[] = \"show status like 'ssl_cipher'\";\n  ConfigGenerator config_gen;\n  common_pass_metadata_checks(mock_mysql.get());\n  config_gen.init(kServerUrl, {});\n\n  // anything other than PREFERRED (or empty, which defaults to PREFERRED) should never warn.\n  // warn_on_no_ssl() shouldn't even bother querying the database.\n  {\n    EXPECT_TRUE(config_gen.warn_on_no_ssl({{\"ssl_mode\", mysqlrouter::MySQLSession::kSslModeRequired}}));\n    EXPECT_TRUE(config_gen.warn_on_no_ssl({{\"ssl_mode\", mysqlrouter::MySQLSession::kSslModeDisabled}}));\n    EXPECT_TRUE(config_gen.warn_on_no_ssl({{\"ssl_mode\", mysqlrouter::MySQLSession::kSslModeVerifyCa}}));\n    EXPECT_TRUE(config_gen.warn_on_no_ssl({{\"ssl_mode\", mysqlrouter::MySQLSession::kSslModeVerifyIdentity}}));\n  }\n\n  // run for 2 ssl_mode cases: unspecified and PREFERRED (they are equivalent)\n  typedef std::map<std::string, std::string> Opts;\n  std::vector <Opts> opts{ Opts{}, Opts{{\"ssl_mode\", mysqlrouter::MySQLSession::kSslModePreferred}}};\n  for (const Opts& opt :  opts) {\n\n    { // have SLL\n      mock_mysql->expect_query_one(kQuery).then_return(0, {{\"ssl_cipher\", \"some_cipher\"}});\n      EXPECT_TRUE(config_gen.warn_on_no_ssl(opt));\n    }\n\n    { // don't have SLL - empty string\n      mock_mysql->expect_query_one(kQuery).then_return(0, {{\"ssl_cipher\", \"\"}});\n      EXPECT_FALSE(config_gen.warn_on_no_ssl(opt));\n    }\n\n    { // don't have SLL - null string\n      mock_mysql->expect_query_one(kQuery).then_return(0, {{\"ssl_cipher\", nullptr}});\n      EXPECT_FALSE(config_gen.warn_on_no_ssl(opt));\n    }\n\n    // CORNERCASES FOLLOW\n\n    { // query failure\n      mock_mysql->expect_query_one(kQuery).then_error(\"boo!\", 1234);\n      EXPECT_THROW(config_gen.warn_on_no_ssl(opt), std::runtime_error);\n    }\n\n    { // bogus query result - no columns\n      mock_mysql->expect_query_one(kQuery).then_return(0, {});\n      EXPECT_THROW(config_gen.warn_on_no_ssl(opt), std::runtime_error);\n    }\n\n    { // bogus query result - null column\n      mock_mysql->expect_query_one(kQuery).then_return(0, {{nullptr}});\n      EXPECT_THROW(config_gen.warn_on_no_ssl(opt), std::runtime_error);\n    }\n\n    { // bogus query result - 1 column\n      mock_mysql->expect_query_one(kQuery).then_return(0, {{\"foo\"}});\n      EXPECT_THROW(config_gen.warn_on_no_ssl(opt), std::runtime_error);\n    }\n\n    { // bogus query result - 1 column (ssl_cipher)\n      mock_mysql->expect_query_one(kQuery).then_return(0, {{\"ssl_cipher\"}});\n      EXPECT_THROW(config_gen.warn_on_no_ssl(opt), std::runtime_error);\n    }\n\n    { // bogus query result - 2 columns, but first is not ssl_cipher\n      mock_mysql->expect_query_one(kQuery).then_return(0, {{\"foo\", \"bar\"}});\n      EXPECT_THROW(config_gen.warn_on_no_ssl(opt), std::runtime_error);\n    }\n  }\n}\n\n\nTEST_F(ConfigGeneratorTest, warn_no_ssl_false) {\n\n  const std::vector<std::string> prefered_values{\"PREFERRED\", \"preferred\", \"Preferred\"};\n  for (size_t i = 0u; i < prefered_values.size(); ++i)\n  {\n    ConfigGenerator config_gen;\n\n    common_pass_metadata_checks(mock_mysql.get());\n    mock_mysql->expect_query_one(\"show status like 'ssl_cipher'\");\n    mock_mysql->then_return(2, {\n        {mock_mysql->string_or_null(\"ssl_cipher\"), mock_mysql->string_or_null(\"\")}\n      });\n\n    std::map<std::string, std::string> options;\n    options[\"ssl_mode\"] = prefered_values[i];\n\n    config_gen.init(kServerUrl, {});\n    const bool res = config_gen.warn_on_no_ssl(options);\n\n    ASSERT_FALSE(res);\n  }\n}\n\nTEST_F(ConfigGeneratorTest, warn_no_ssl_true) {\n\n  {\n    ConfigGenerator config_gen;\n\n    common_pass_metadata_checks(mock_mysql.get());\n\n    std::map<std::string, std::string> options;\n    options[\"ssl_mode\"] = \"DISABLED\";\n\n    config_gen.init(kServerUrl, {});\n    const bool res = config_gen.warn_on_no_ssl(options);\n\n    ASSERT_TRUE(res);\n  }\n}\n\nTEST_F(ConfigGeneratorTest, set_file_owner_no_user) {\n    ConfigGenerator config_gen;\n\n    std::map<std::string, std::string> empty_options;\n    ASSERT_NO_THROW (config_gen.set_file_owner(empty_options, tmp_dir() + \"/somefile\") );\n}\n\nTEST_F(ConfigGeneratorTest, set_file_owner_user_empty) {\n    ConfigGenerator config_gen;\n\n    std::map<std::string, std::string> bootstrap_options{{\"user\", \"\"}};\n    ASSERT_NO_THROW (config_gen.set_file_owner(bootstrap_options, tmp_dir() + \"/somefile\") );\n}\n\n\n// bootstrap from URI/unix-socket/hostname checks\nconst std::string kDefaultUsername = \"root\";\nconst std::string kDefaultPassword = \"\";\nconst std::string kEmptyUnixSocket = \"\";\nconst uint16_t kDefaultMysqlPort = 0;\n\n// passing a unix-socket path to --bootstrap should raise a runtime_error\nTEST_F(ConfigGeneratorTest, bootstrap_from_unixsocket) {\n  mysqlrouter::set_prompt_password([](const std::string&) -> std::string { return kDefaultPassword; });\n\n  mock_mysql->expect_connect(\"\", kDefaultMysqlPort, kDefaultUsername, kDefaultPassword, tmp_dir() + \"/mysql.sock\");\n\n  common_pass_metadata_checks(mock_mysql.get());\n\n  ConfigGenerator config_gen;\n  EXPECT_THROW({\n      config_gen.init(tmp_dir() + \"/mysql.sock\", {});\n      },\n      std::runtime_error);\n}\n\nTEST_F(ConfigGeneratorTest, bootstrap_from_ipv6) {\n  mysqlrouter::set_prompt_password([](const std::string&) -> std::string { return \"\"; });\n\n  mock_mysql->expect_connect(\"::1\", kDefaultMysqlPort, kDefaultUsername, kDefaultPassword, kEmptyUnixSocket);\n  common_pass_metadata_checks(mock_mysql.get());\n\n  ConfigGenerator config_gen;\n  config_gen.init(\"[::1]\", {});\n}\n\nTEST_F(ConfigGeneratorTest, bootstrap_from_ipv6_with_port) {\n  mysqlrouter::set_prompt_password([](const std::string&) -> std::string { return \"\"; });\n\n  mock_mysql->expect_connect(\"::1\", 3306, kDefaultUsername, kDefaultPassword, kEmptyUnixSocket);\n  common_pass_metadata_checks(mock_mysql.get());\n\n  ConfigGenerator config_gen;\n  config_gen.init(\"[::1]:3306\", {});\n}\n\nTEST_F(ConfigGeneratorTest, bootstrap_from_hostname) {\n  mysqlrouter::set_prompt_password([](const std::string&) -> std::string { return \"\"; });\n\n  mock_mysql->expect_connect(\"127.0.0.1\", 0, kDefaultUsername, kDefaultPassword, kEmptyUnixSocket);\n  common_pass_metadata_checks(mock_mysql.get());\n\n  ConfigGenerator config_gen;\n  config_gen.init(\"localhost\", {});\n}\n\nTEST_F(ConfigGeneratorTest, bootstrap_from_hostname_with_port) {\n  mysqlrouter::set_prompt_password([](const std::string&) -> std::string { return \"\"; });\n\n  mock_mysql->expect_connect(\"127.0.0.1\", 3306, kDefaultUsername, kDefaultPassword, kEmptyUnixSocket);\n  common_pass_metadata_checks(mock_mysql.get());\n\n  ConfigGenerator config_gen;\n  config_gen.init(\"localhost:3306\", {});\n}\n\nTEST_F(ConfigGeneratorTest, bootstrap_from_uri) {\n  mysqlrouter::set_prompt_password([](const std::string&) -> std::string { return \"\"; });\n\n  mock_mysql->expect_connect(\"127.0.0.1\", 3306, kDefaultUsername, kDefaultPassword, kEmptyUnixSocket);\n  common_pass_metadata_checks(mock_mysql.get());\n\n  ConfigGenerator config_gen;\n  config_gen.init(\"mysql://localhost:3306/\", {});\n}\n\nTEST_F(ConfigGeneratorTest, bootstrap_from_uri_unixsocket) {\n  mysqlrouter::set_prompt_password([](const std::string&) -> std::string { return \"\"; });\n\n  mock_mysql->expect_connect(\"localhost\", 3306, kDefaultUsername, kDefaultPassword, tmp_dir() + \"/mysql.sock\");\n  common_pass_metadata_checks(mock_mysql.get());\n\n  ConfigGenerator config_gen;\n  EXPECT_NO_THROW({\n      config_gen.init(\"mysql://localhost:3306/\", {{\"bootstrap_socket\", tmp_dir() + \"/mysql.sock\"}});\n      });\n}\n\n// a invalid URI (port too large) should trigger a expection\nTEST_F(ConfigGeneratorTest, bootstrap_from_invalid_uri) {\n  mysqlrouter::set_prompt_password([](const std::string&) -> std::string { return \"\"; });\n\n  common_pass_metadata_checks(mock_mysql.get());\n\n  ConfigGenerator config_gen;\n  EXPECT_THROW({\n      config_gen.init(\"mysql://localhost:330660/\", {{\"bootstrap_socket\", tmp_dir() + \"/mysql.sock\"}});\n      },\n      std::runtime_error);\n}\n\n// if socket-name is specified, the hostname in the bootstrap-uri has to be 'localhost'\nTEST_F(ConfigGeneratorTest, bootstrap_fail_if_socket_and_hostname) {\n  mysqlrouter::set_prompt_password([](const std::string&) -> std::string { return \"\"; });\n\n  common_pass_metadata_checks(mock_mysql.get());\n\n  ConfigGenerator config_gen;\n  EXPECT_THROW({\n      config_gen.init(\"somehost\", {{\"bootstrap_socket\", tmp_dir() + \"/mysql.sock\"}});\n      },\n      std::runtime_error);\n}\n\n// if socket-name is specified and hostname is 'localhost' then  bootstrap should work\nTEST_F(ConfigGeneratorTest, bootstrap_if_socket_and_localhost) {\n  mysqlrouter::set_prompt_password([](const std::string&) -> std::string { return \"\"; });\n\n  mock_mysql->expect_connect(\"localhost\", 0, kDefaultUsername, kDefaultPassword, tmp_dir() + \"/mysql.sock\");\n  common_pass_metadata_checks(mock_mysql.get());\n\n  ConfigGenerator config_gen;\n  EXPECT_NO_THROW({\n      config_gen.init(\"localhost\", {{\"bootstrap_socket\", tmp_dir() + \"/mysql.sock\"}});\n      });\n}\n\nstatic void bootstrap_password_test(MySQLSessionReplayer* mysql,\n                                    const std::string &dir,\n                                    const std::map<std::string, std::string> &default_paths,\n                                    const std::vector<query_entry_t> &bootstrap_queries,\n                                    std::string password_retries = \"5\",\n                                    bool force_password_validation = false) {\n  ConfigGenerator config_gen;\n  ::testing::InSequence s;\n  common_pass_metadata_checks(mysql);\n  config_gen.init(kServerUrl, {});\n  expect_bootstrap_queries(mysql, \"mycluster\", bootstrap_queries);\n\n  std::map<std::string, std::string> options;\n  options[\"name\"] = \"name\";\n  options[\"password-retries\"] = password_retries;\n  options[\"report-host\"] = \"dont.query.dns\";\n  if (force_password_validation)\n    options[\"force-password-validation\"] = \"1\";\n\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){\n    delete_dir_recursive(dir);\n    mysql_harness::reset_keyring();});\n\n  KeyringInfo keyring_info(\"delme\", \"delme.key\");\n  config_gen.set_keyring_info(keyring_info);\n\n  config_gen.bootstrap_directory_deployment(dir,\n      options, {}, default_paths);\n}\n\nstatic constexpr unsigned kCreateUserQuery = 5;   // measured from front\nstatic constexpr unsigned kCreateUserQuery2 = 6;  // measured backwards from end\n\nTEST_F(ConfigGeneratorTest, bootstrap_generate_password_force_password_validation) {\n  const std::string kDirName = \"./gen_pass_test\";\n\n  // copy expected bootstrap queries brefore CREATE USER\n  std::vector<query_entry_t> bootstrap_queries;\n  for (unsigned i = 0; i < kCreateUserQuery; ++i) {\n    bootstrap_queries.push_back(expected_bootstrap_queries.at(i));\n  }\n\n  // we expect the user to be created without using HASHed password\n  // and mysql_native_password plugin as we are forcing password validation\n  bootstrap_queries.push_back( {\"CREATE USER mysql_router4_012345678901@'%'\"\n                                \" IDENTIFIED BY\", ACTION_EXECUTE } );\n\n  // copy the remaining bootstrap queries\n  for (unsigned i = kCreateUserQuery + 1; i < expected_bootstrap_queries.size(); ++i) {\n    bootstrap_queries.push_back(expected_bootstrap_queries.at(i));\n  }\n\n  // verify the user is re-created as required\n  bootstrap_queries.at(bootstrap_queries.size() - kCreateUserQuery2) =\n      {\"CREATE USER mysql_router4_012345678901@'%' IDENTIFIED BY\", ACTION_EXECUTE};\n\n  bootstrap_password_test(mock_mysql.get(), kDirName, default_paths, bootstrap_queries, \"5\", true /*force_password_validation*/);\n}\n\nTEST_F(ConfigGeneratorTest, bootstrap_generate_password_no_native_plugin) {\n  const std::string kDirName = \"./gen_pass_test\";\n\n  // copy expected bootstrap queries brefore CREATE USER\n  std::vector<query_entry_t> bootstrap_queries;\n  for (unsigned i = 0; i < kCreateUserQuery; ++i) {\n    bootstrap_queries.push_back(expected_bootstrap_queries.at(i));\n  }\n\n  // emulate error 1524 (plugin not loaded) after the call to first CREATE USER\n  bootstrap_queries.push_back( {\"CREATE USER mysql_router4_012345678901@'%'\"\n                                \" IDENTIFIED WITH mysql_native_password AS\", ACTION_ERROR, 0, 1524 } );\n\n  // that should lead to rollback and retry witout hashed password\n  bootstrap_queries.push_back( {\"ROLLBACK\", ACTION_EXECUTE } );\n\n  bootstrap_queries.push_back( {\"CREATE USER mysql_router4_012345678901@'%'\"\n                                \" IDENTIFIED BY\", ACTION_EXECUTE } );\n\n  // copy the remaining bootstrap queries\n  for (unsigned i = kCreateUserQuery + 1; i < expected_bootstrap_queries.size(); ++i) {\n    bootstrap_queries.push_back(expected_bootstrap_queries.at(i));\n  }\n\n  // verify the user is re-created as required\n  bootstrap_queries.at(bootstrap_queries.size() - kCreateUserQuery2) =\n      {\"CREATE USER mysql_router4_012345678901@'%' IDENTIFIED BY\", ACTION_EXECUTE};\n\n  bootstrap_password_test(mock_mysql.get(), kDirName, default_paths, bootstrap_queries);\n}\n\nTEST_F(ConfigGeneratorTest, bootstrap_generate_password_with_native_plugin) {\n  const std::string kDirName = \"./gen_pass_test\";\n\n  // copy expected bootstrap queries brefore CREATE USER\n  std::vector<query_entry_t> bootstrap_queries;\n  for (unsigned i = 0; i < kCreateUserQuery; ++i) {\n    bootstrap_queries.push_back(expected_bootstrap_queries.at(i));\n  }\n\n  // emulate error 1524 (plugin not loaded) after the call to first CREATE USER\n  bootstrap_queries.push_back( {\"CREATE USER mysql_router4_012345678901@'%'\"\n                                \" IDENTIFIED WITH mysql_native_password AS\", ACTION_EXECUTE } );\n\n  // copy the remaining bootstrap queries\n  for (unsigned i = kCreateUserQuery + 1; i < expected_bootstrap_queries.size(); ++i) {\n    bootstrap_queries.push_back(expected_bootstrap_queries.at(i));\n  }\n\n  // verify the user is re-created as required\n  bootstrap_queries.at(bootstrap_queries.size() - kCreateUserQuery2) =\n      {\"CREATE USER mysql_router4_012345678901@'%' IDENTIFIED WITH mysql_native_password AS\", ACTION_EXECUTE};\n\n  bootstrap_password_test(mock_mysql.get(), kDirName, default_paths, bootstrap_queries);\n}\n\nTEST_F(ConfigGeneratorTest, bootstrap_generate_password_retry_ok)  {\n  const std::string kDirName = \"./gen_pass_test\";\n\n  // copy expected bootstrap queries brefore CREATE USER\n  std::vector<query_entry_t> bootstrap_queries;\n  for (unsigned i = 0; i < kCreateUserQuery; ++i) {\n    bootstrap_queries.push_back(expected_bootstrap_queries.at(i));\n  }\n\n  // emulate error 1524 (plugin not loaded) after the call to first CREATE USER\n  bootstrap_queries.push_back( {\"CREATE USER mysql_router4_012345678901@'%'\"\n                                \" IDENTIFIED WITH mysql_native_password AS\", ACTION_ERROR, 0, 1524 } );\n\n  // that should lead to rollback and retry witout hashed password\n  bootstrap_queries.push_back( {\"ROLLBACK\", ACTION_EXECUTE } );\n\n  // emulate error 1819) (password does not satisfy the current policy requirements) after the call to second CREATE USER\n  bootstrap_queries.push_back( {\"CREATE USER mysql_router4_012345678901@'%'\"\n                                \" IDENTIFIED BY\", ACTION_ERROR, 0, 1819 } );\n\n  // that should lead to rollback and another retry witout hashed password\n  bootstrap_queries.push_back( {\"ROLLBACK\", ACTION_EXECUTE } );\n\n  bootstrap_queries.push_back( {\"CREATE USER mysql_router4_012345678901@'%'\"\n                                \" IDENTIFIED BY\", ACTION_EXECUTE } );\n\n  // copy the remaining bootstrap queries\n  for (unsigned i = kCreateUserQuery + 1; i < expected_bootstrap_queries.size(); ++i) {\n    bootstrap_queries.push_back(expected_bootstrap_queries.at(i));\n  }\n\n  // verify the user is re-created as required\n  bootstrap_queries.at(bootstrap_queries.size() - kCreateUserQuery2) =\n      {\"CREATE USER mysql_router4_012345678901@'%' IDENTIFIED BY\", ACTION_EXECUTE};\n\n  bootstrap_password_test(mock_mysql.get(), kDirName, default_paths, bootstrap_queries);\n}\n\nTEST_F(ConfigGeneratorTest, bootstrap_generate_password_retry_failed) {\n  const std::string kDirName = \"./gen_pass_test\";\n  const unsigned kPasswordRetries = 3;\n\n  // copy expected bootstrap queries brefore CREATE USER\n  std::vector<query_entry_t> bootstrap_queries;\n  for (unsigned i = 0; i < kCreateUserQuery; ++i) {\n    bootstrap_queries.push_back(expected_bootstrap_queries.at(i));\n  }\n\n  // emulate error 1524 (plugin not loaded) after the call to first CREATE USER\n  bootstrap_queries.push_back( {\"CREATE USER mysql_router4_012345678901@'%'\"\n                                \" IDENTIFIED WITH mysql_native_password AS\", ACTION_ERROR, 0, 1524 } );\n\n  // that should lead to rollback and retry witout hashed password for \"kPasswordRetries\" number of times\n  for (unsigned i = 0; i < kPasswordRetries; ++i) {\n    bootstrap_queries.push_back( {\"ROLLBACK\", ACTION_EXECUTE } );\n\n    // each time emulate error 1819) (password does not satisfy the current policy requirements) after the call to second CREATE USER\n    bootstrap_queries.push_back( {\"CREATE USER mysql_router4_012345678901@'%'\"\n                                 \" IDENTIFIED BY\", ACTION_ERROR, 0, 1819 } );\n  }\n  bootstrap_queries.push_back( {\"ROLLBACK\", ACTION_EXECUTE } );\n\n  try {\n    bootstrap_password_test(mock_mysql.get(), kDirName, default_paths, bootstrap_queries, std::to_string(kPasswordRetries));\n    FAIL() << \"Expecting exception\";\n  }\n  catch (const std::runtime_error& exc) {\n\n    ASSERT_NE(std::string::npos,\n              std::string(exc.what()).find(\"Try to decrease the validate_password rules and try the operation again.\"));\n  }\n}\n\nTEST_F(ConfigGeneratorTest, bootstrap_password_retry_param_wrong_values) {\n  const std::string kDirName = \"./gen_pass_test\";\n  std::vector<query_entry_t> bootstrap_queries;\n  for (unsigned i = 0; i < kCreateUserQuery; ++i) {\n    bootstrap_queries.push_back(expected_bootstrap_queries.at(i));\n  }\n  // emulate error 1524 (plugin not loaded) after the call to first CREATE USER\n  bootstrap_queries.push_back( {\"CREATE USER mysql_router4_012345678901@'%'\"\n                                \" IDENTIFIED WITH mysql_native_password AS\", ACTION_ERROR, 0, 1524 } );\n  bootstrap_queries.push_back( {\"ROLLBACK\", ACTION_EXECUTE } );\n\n  // without --bootstrap\n  {\n    const std::vector<std::string> argv {\"--password-retries\", \"2\"};\n    try {\n      MySQLRouter router(Path(), argv);\n      FAIL() << \"Expected exception\";\n    } catch (const std::runtime_error &e) {\n      EXPECT_STREQ(\"Option --password-retries can only be used together with -B/--bootstrap\", e.what());\n    }\n  }\n\n  // value too small\n  {\n    try {\n      bootstrap_password_test(mock_mysql.get(), kDirName, default_paths, bootstrap_queries, \"0\");\n      FAIL() << \"Expecting exception\";\n    }\n    catch (const std::runtime_error& exc) {\n      EXPECT_STREQ(\"Invalid password-retries value '0'; please pick a value from 1 to 10000\", exc.what());\n    }\n  }\n\n  // value too big\n  {\n    try {\n      bootstrap_password_test(mock_mysql.get(), kDirName, default_paths, bootstrap_queries, \"999999\");\n      FAIL() << \"Expecting exception\";\n    }\n    catch (const std::runtime_error& exc) {\n      EXPECT_STREQ(\"Invalid password-retries value '999999'; please pick a value from 1 to 10000\", exc.what());\n    }\n  }\n\n  // value wrong type\n  {\n    try {\n      bootstrap_password_test(mock_mysql.get(), kDirName, default_paths, bootstrap_queries, \"foo\");\n      FAIL() << \"Expecting exception\";\n    }\n    catch (const std::runtime_error& exc) {\n      EXPECT_STREQ(\"Invalid password-retries value 'foo'; please pick a value from 1 to 10000\", exc.what());\n    }\n  }\n\n  // value empty\n  {\n    try {\n      bootstrap_password_test(mock_mysql.get(), kDirName, default_paths, bootstrap_queries, \"\");\n      FAIL() << \"Expecting exception\";\n    }\n    catch (const std::runtime_error& exc) {\n      EXPECT_STREQ(\"Invalid password-retries value ''; please pick a value from 1 to 10000\", exc.what());\n    }\n  }\n}\n\nclass TestConfigGenerator : public ConfigGenerator {\n private:\n  // we disable this method by overriding - calling it requires sudo access\n  void set_script_permissions(const std::string&,\n                              const std::map<std::string, std::string>&) override {};\n};\n\n// TODO This is very ugly, it should not be a global. It's defined in config_generator.cc and\n//      used in find_executable_path() to provide path to Router binary when generating start.sh.\nextern std::string g_program_name;\n\n// start.sh/stop.sh is unix-specific\n#ifndef _WIN32\nTEST_F(ConfigGeneratorTest, start_sh) {\n  // This test verifies that start.sh is generated correctly\n\n  // dir where we'll test start.sh\n  const std::string deployment_dir = mysql_harness::get_tmp_dir();\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){\n    mysql_harness::delete_dir_recursive(deployment_dir);\n  });\n\n  // get path to start.sh\n  mysql_harness::Path start_sh(deployment_dir);\n  start_sh.append(\"start.sh\");\n\n  // no --user\n  {\n    // generate start.sh\n    TestConfigGenerator().create_start_script(deployment_dir, false, {});\n\n    // test file contents\n    ASSERT_TRUE(start_sh.exists());\n    char buf[1024] = {0};\n    std::ifstream ifs(start_sh.c_str());\n    ifs.read(buf, sizeof(buf));\n    EXPECT_STREQ(\n        (std::string(\"#!/bin/bash\\n\") +\n         \"basedir=\" + deployment_dir.c_str() + \"\\n\"\n         \"ROUTER_PID=$basedir/mysqlrouter.pid \" + g_program_name + \" -c $basedir/mysqlrouter.conf &\\n\"\n         \"disown %-\\n\").c_str(),\n        buf);\n  }\n\n  // with --user\n  {\n    // generate start.sh\n    TestConfigGenerator().create_start_script(deployment_dir, false, {{\"user\", \"loser\"}});\n\n    // test file contents\n    ASSERT_TRUE(start_sh.exists());\n    char buf[1024] = {0};\n    std::ifstream ifs(start_sh.c_str());\n    ifs.read(buf, sizeof(buf));\n    EXPECT_STREQ(\n        (std::string(\"#!/bin/bash\\n\") +\n         \"basedir=\" + deployment_dir.c_str() + \"\\n\"\n         \"if [ `whoami` == 'loser' ]; then\\n\"\n         \"  ROUTER_PID=$basedir/mysqlrouter.pid \" + g_program_name + \" -c $basedir/mysqlrouter.conf &\\n\"\n         \"else\\n\"\n         \"  sudo ROUTER_PID=$basedir/mysqlrouter.pid \" + g_program_name + \" -c $basedir/mysqlrouter.conf --user=loser &\\n\"\n         \"fi\\n\"\n         \"disown %-\\n\").c_str(),\n        buf);\n  }\n}\n\nTEST_F(ConfigGeneratorTest, stop_sh) {\n  // This test verifies that stop.sh is generated correctly\n\n  // dir where we'll test stop.sh\n  const std::string deployment_dir = mysql_harness::get_tmp_dir();\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){\n    mysql_harness::delete_dir_recursive(deployment_dir);\n  });\n\n  // generate stop.sh\n  TestConfigGenerator().create_stop_script(deployment_dir, {});\n\n  // get path to stop.sh\n  mysql_harness::Path stop_sh(deployment_dir);\n  stop_sh.append(\"stop.sh\");\n\n  // test file contents\n  ASSERT_TRUE(stop_sh.exists());\n  char buf[1024] = {0};\n  std::ifstream ifs(stop_sh.c_str());\n  ifs.read(buf, sizeof(buf));\n  const std::string pid_file = deployment_dir + \"/mysqlrouter.pid\";\n  EXPECT_STREQ(\n      (std::string(\"#!/bin/bash\\n\") +\n       \"if [ -f \" + pid_file + \" ]; then\\n\"\n       \"  kill -TERM `cat \" + pid_file + \"` && rm -f \" + pid_file + \"\\n\"\n       \"fi\\n\").c_str(),\n      buf);\n}\n#endif // #ifndef _WIN32\n\n//TODO Create MockSocketOperations with all methods mocked somewhere in a place\n//     commonly accessible to all our tests.  At the time of writing this,\n//     there's several MockSocketOperations we have in our test code, they're\n//     mostly identical, but unfortunately cannot be reused because they're in\n//     different codecases.\nclass MockSocketOperations : public mysql_harness::SocketOperationsBase {\n public:\n  // this one is key to our tests here\n  std::string get_local_hostname() {\n    throw LocalHostnameResolutionError(\"some error message from get_local_hostname()\");\n  }\n\n  // we don't call these, but we need to provide an implementation (they're pure virtual)\n  MOCK_METHOD3(read, ssize_t(int, void*, size_t));\n  MOCK_METHOD3(write, ssize_t(int, void*, size_t));\n  MOCK_METHOD1(close, void(int));\n  MOCK_METHOD1(shutdown, void(int));\n  MOCK_METHOD1(freeaddrinfo, void(addrinfo *ai));\n  MOCK_METHOD4(getaddrinfo, int(const char*, const char*, const addrinfo*, addrinfo**));\n  MOCK_METHOD3(bind, int(int, const struct sockaddr*, socklen_t));\n  MOCK_METHOD3(socket, int(int, int, int));\n  MOCK_METHOD5(setsockopt, int(int, int, int, const void*, socklen_t));\n  MOCK_METHOD2(listen, int(int fd, int n));\n  MOCK_METHOD3(poll, int(struct pollfd *, nfds_t, std::chrono::milliseconds));\n  MOCK_METHOD2(connect_non_blocking_wait, int(int sock, std::chrono::milliseconds timeout));\n  MOCK_METHOD2(connect_non_blocking_status, int(int sock, int &so_error));\n  MOCK_METHOD1(set_errno, void(int err));\n  MOCK_METHOD0(get_errno, int());\n};\n\n/**\n * @test verify that exception thrown by (Mock)SocketOperations::get_local_hostname()\n *       when local hostname lookup fails in ConfigGenerator::register_router_and_set_username()\n *       will be caught and rethrown with a user-friendly message\n */\nTEST_F(ConfigGeneratorTest, register_router_error_message) {\n\n  MockSocketOperations sock_ops;  // this implementation will trigger our scenario by throwing\n\n  mysqlrouter::MySQLInnoDBClusterMetadata metadata(nullptr, &sock_ops);\n  mysql_harness::RandomGenerator rg;\n  uint32_t router_id = 1u;\n  std::string username;\n\n  EXPECT_THROW_LIKE(\n    ConfigGenerator().register_router_and_set_username(router_id, \"foo\", username, \"\", false, metadata, rg),\n    std::runtime_error,\n    \"Could not register this Router instance with the cluster because querying this host's hostname from OS failed:\\n\"\n    \"  some error message from get_local_hostname()\\n\"\n    \"You may want to try --report-host option to manually supply this hostname.\"\n  );\n}\n\n/**\n * @test verify that exception thrown by (Mock)SocketOperations::get_local_hostname()\n *       when local hostname lookup fails in ConfigGenerator::ensure_router_id_is_ours()\n *       will be caught and rethrown with a user-friendly message\n */\nTEST_F(ConfigGeneratorTest, ensure_router_id_is_ours_error_message) {\n\n  MockSocketOperations sock_ops;  // this implementation will trigger our scenario by throwing\n\n  MySQLSessionReplayer mysql;\n  mysqlrouter::MySQLInnoDBClusterMetadata metadata(&mysql, &sock_ops);\n  mysql.expect_query_one(\"SELECT h.host_id, h.host_name FROM mysql_innodb_cluster_metadata.routers \"\n                         \"r JOIN mysql_innodb_cluster_metadata.hosts h    ON r.host_id = h.host_id \"\n                         \"WHERE r.router_id = 1\").then_return(2, {\n                           {mysql.string_or_null(\"1\"), mysql.string_or_null(\"foo\")}\n                         });\n  mysql_harness::RandomGenerator rg;\n  uint32_t router_id = 1u;\n  std::string username;\n\n  EXPECT_THROW_LIKE(\n    ConfigGenerator().ensure_router_id_is_ours(router_id, username, \"\", metadata),\n    std::runtime_error,\n    \"Could not verify if this Router instance is already registered with the cluster because querying this host's hostname from OS failed:\\n\"\n    \"  some error message from get_local_hostname()\\n\"\n    \"You may want to try --report-host option to manually supply this hostname.\"\n  );\n}\n\nint main(int argc, char *argv[]) {\n  init_windows_sockets();\n  g_origin = mysql_harness::Path(argv[0]).dirname();\n  g_cwd = mysql_harness::Path(argv[0]).dirname().str();\n\n  // it would be nice to provide something more descriptive like \"/fake/path/to/mysqlrouter\", but\n  // unfortunately, this path goes through realpath() and therefore has to actually exist.\n  g_program_name = \"/\";\n\n  init_test_logger();\n\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n\n"
  },
  {
    "path": "src/router/tests/test_configuration_errors.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/**\n * BUG21771595 Exit application on configuration errors\n *\n */\n\n#include \"cmd_exec.h\"\n#include \"gtest_consoleoutput.h\"\n#include \"router_app.h\"\n#include \"router_test_helpers.h\"\n#include \"mysql/harness/config_parser.h\"\n#include \"mysql/harness/plugin.h\"\n#include \"test/helpers.h\"\n\n#include <fstream>\n#include <memory>\n#include <string>\n#ifdef _WIN32\n#include <WinSock2.h>\n#endif\n#include \"gmock/gmock.h\"\n\nusing std::string;\nusing ::testing::StrEq;\nusing ::testing::HasSubstr;\nusing mysql_harness::Path;\n\nstring g_cwd;\nPath g_origin;\n\nclass Bug21771595 : public ConsoleOutputTest {\nprotected:\n  virtual void SetUp() {\n    set_origin(g_origin);\n    ConsoleOutputTest::SetUp();\n    config_path.reset(new Path(g_cwd));\n    config_path->append(\"Bug21771595.conf\");\n\n  }\n\n  void reset_config() {\n    std::ofstream ofs_config(config_path->str());\n    if (ofs_config.good()) {\n      ofs_config << \"[DEFAULT]\\n\";\n      ofs_config << \"logging_folder =\\n\";\n      ofs_config << \"plugin_folder = \" << plugin_dir->str() << \"\\n\";\n      ofs_config << \"runtime_folder = \" << stage_dir->str() << \"\\n\";\n      ofs_config << \"config_folder = \" << stage_dir->str() << \"\\n\\n\";\n      ofs_config.close();\n    }\n  }\n\n  std::unique_ptr<Path> config_path;\n};\n\nTEST_F(Bug21771595, ExceptionRoutingInvalidTimeout) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing]\\nbind_address=127.0.0.1:7001\\ndestinations=127.0.0.1:3306\\nmode=read-only\\n\";\n  c << \"connect_timeout=0\\n\";\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n\n  ASSERT_THROW_LIKE(\n    r.start(),\n    std::invalid_argument,\n    \"option connect_timeout in [routing] needs value between 1 and 65535 inclusive, was '0'\"\n  );\n}\n\nTEST_F(Bug21771595, ExceptionMetadataCacheInvalidBindAddress) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[metadata_cache]\\nbootstrap_server_addresses=mysql://127.0.0.1:13000,mysql://127.0.0.1:99999\\n\\n\";\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(\n    r.start(),\n    std::invalid_argument,\n    \"option bootstrap_server_addresses in [metadata_cache] is incorrect (invalid URI: invalid port: impossible port number for: mysql://127.0.0.1:99999)\"\n  );\n}\n\nTEST_F(Bug21771595, AppExecRoutingInvalidTimeout) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing]\\nbind_address=127.0.0.1:7001\\ndestinations=127.0.0.1:3306\\nmode=read-only\\n\";\n  c << \"connect_timeout=0\\n\";\n  c.close();\n  string cmd = app_mysqlrouter->str() + \" -c \" + config_path->str();\n  auto cmd_result = cmd_exec(cmd, true, \"\");\n\n  ASSERT_EQ(1, cmd_result.exit_code);\n  ASSERT_THAT(cmd_result.output, HasSubstr(\n    \"Configuration error: option connect_timeout in [routing] needs value between 1 and 65535 inclusive, was '0'\"));\n}\n\nTEST_F(Bug21771595, AppExecMetadataCacheInvalidBindAddress) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[metadata_cache]\\nbootstrap_server_addresses=mysql://127.0.0.1:13000,mysql://127.0.0.1:99999\\n\\n\";\n  c.close();\n  string cmd = app_mysqlrouter->str() + \" -c \" + config_path->str();\n  auto cmd_result = cmd_exec(cmd, true);\n\n  //ASSERT_EQ(cmd_result.exit_code, 1);\n  ASSERT_THAT(cmd_result.output, HasSubstr(\n  \"option bootstrap_server_addresses in [metadata_cache] is incorrect (invalid URI: invalid port: impossible port number\"));\n}\n\nint main(int argc, char *argv[]) {\n  init_windows_sockets();\n  g_origin = Path(argv[0]).dirname();\n  g_cwd = Path(argv[0]).dirname().str();\n  register_test_logger();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/router/tests/test_console_output.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"gtest_consoleoutput.h\"\n#include \"cmd_exec.h\"\n#include \"router_test_helpers.h\"\n\n#include <cstring>\n#include <sstream>\n#include <streambuf>\n#ifndef _WIN32\n#include <unistd.h>\n#endif\n\n#include <gtest/gtest.h>\n#include <gmock/gmock.h>\n\nusing mysql_harness::Path;\n\nPath g_origin;\nPath g_stage_dir;\nPath g_mysqlrouter_exec;\nPath g_source_dir;\nbool g_skip_git_tests = false;\n\nconst int kFirstYear = 2015;\n\nstd::string g_help_output_raw;\nstd::vector<std::string> g_help_output;\n\nclass ConsoleOutputTestX : public ConsoleOutputTest {\n protected:\n  virtual void SetUp() {\n    set_origin(g_origin);\n    ConsoleOutputTest::SetUp();\n    g_mysqlrouter_exec = app_mysqlrouter.get()->real_path();\n\n    if (g_help_output.empty()) {\n      std::ostringstream cmd;\n      cmd << g_mysqlrouter_exec << \" --help\";\n      auto result = cmd_exec(cmd.str());\n      std::string line;\n      std::istringstream iss(result.output);\n      while (std::getline(iss, line)) {\n        g_help_output.push_back(line);\n      }\n      g_help_output_raw = result.output;\n    }\n  }\n};\n\n#ifndef _WIN32\n// In Windows, the git command is executed in its own shell, it is not available in the standard PATH of Windows.\nTEST_F(ConsoleOutputTestX, Copyright) {\n  SKIP_GIT_TESTS(g_skip_git_tests)\n  int last_year = 0;\n\n  // We need year of last commit. This year has to be present in copyright.\n  std::ostringstream os_cmd;\n  os_cmd << \"git log --pretty=format:%ad --date=short -1\";\n  auto result = cmd_exec(os_cmd.str(), false, g_source_dir.str());\n  try {\n    last_year = std::stoi(result.output.substr(0, 4));\n  } catch (const std::invalid_argument &exc) {\n    FAIL() << \"Failed getting year using '\" << result.output.substr(0, 4) << \"'\";\n  }\n\n  for (auto &line: g_help_output) {\n    if (starts_with(line, \"Copyright\")) {\n      ASSERT_THAT(line, ::testing::HasSubstr(std::to_string(kFirstYear) + \",\")) << \"Start year not in copyright\";\n      // following is checked only when in Git repository\n      if (last_year > kFirstYear) {\n        ASSERT_THAT(line, ::testing::HasSubstr(std::to_string(last_year) + \",\")) << \"Last year not in copyright\";\n      }\n      break;\n    }\n  }\n}\n#endif\n\nTEST_F(ConsoleOutputTestX, Trademark) {\n  for (auto &line: g_help_output) {\n    if (starts_with(line, \"Oracle is a registered trademark of Oracle\")) {\n      break;\n    }\n  }\n}\n\nTEST_F(ConsoleOutputTestX, ConfigurationFileList) {\n  bool found = false;\n  std::vector<std::string> config_files;\n  std::string indent = \"  \";\n\n  for (auto it = g_help_output.begin(); it < g_help_output.end(); ++it) {\n    auto line = *it;\n    if (found) {\n      if (line.empty()) {\n        break;\n      }\n      if (starts_with(line, indent)) {\n        auto file = line.substr(indent.size(), line.size());\n        config_files.push_back(file);\n      }\n    }\n    if (starts_with(line, \"Configuration read\")) {\n      it++; // skip next line\n      found = true;\n    }\n  }\n\n  ASSERT_TRUE(found) << \"Failed reading location configuration locations\";\n  ASSERT_TRUE(config_files.size() >= 2) << \"Failed getting at least 2 configuration file locations\";\n}\n\nTEST_F(ConsoleOutputTestX, BasicUsage) {\n  std::vector<std::string> options{\n      \"[-V|--version]\",\n      \"[-?|--help]\",\n      \"[-c|--config=<path>]\",\n      \"[-a|--extra-config=<path>]\",\n  };\n\n  for (auto option: options) {\n    ASSERT_THAT(g_help_output_raw, ::testing::HasSubstr(option));\n  }\n}\n\nTEST_F(ConsoleOutputTestX, BasicOptionDescriptions) {\n  std::vector<std::string> options{\n      \"  -V, --version\",\n      \"        Display version information and exit.\",\n      \"  -?, --help\",\n      \"        Display this help and exit.\",\n      \"  -c <path>, --config <path>\",\n      \"        Only read configuration from given file.\",\n      \"  -a <path>, --extra-config <path>\",\n      \"        Read this file after configuration files are read\",\n  };\n\n  for (auto option: options) {\n    ASSERT_THAT(g_help_output_raw, ::testing::HasSubstr(option));\n  }\n}\n\n\nint main(int argc, char *argv[]) {\n  g_origin = Path(argv[0]).dirname();\n  try {\n    g_source_dir = get_cmake_source_dir();\n    if (g_source_dir.is_set() && !Path(g_source_dir).join(\".git\").is_directory()) {\n      throw std::runtime_error(\"no git repository\");\n    }\n  } catch (const std::runtime_error &exc) {\n    std::cerr << \"WARNING: mysqlrouter source repository not available. \" << std::endl\n        << \"Use CMAKE_SOURCE_DIR environment variable to point to source repository. \" << std::endl\n        << \"Skipping tests using Git.\" << std::endl;\n    g_skip_git_tests = true;\n  }\n\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/router/tests/test_datatypes.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"gmock/gmock.h\"\n\n#include \"router_test_helpers.h\"\n#include \"tcp_address.h\"\n\n#ifdef _WIN32\n#include <WinSock2.h>\n#endif\n\nusing mysql_harness::TCPAddress;\n\nclass TCPAddressTest : public ::testing::Test {\nprotected:\n  virtual void SetUp() {\n  }\n};\n\nTEST_F(TCPAddressTest, EmptyAddress) {\n  TCPAddress a;\n  EXPECT_EQ(\"\", a.addr);\n  EXPECT_EQ(0, a.port);\n  EXPECT_FALSE(a.is_valid());\n  EXPECT_EQ(TCPAddress::Family::INVALID, a.get_family());\n  EXPECT_FALSE(a.is_family<TCPAddress::Family::IPV4>());\n  EXPECT_FALSE(a.is_family<TCPAddress::Family::IPV6>());\n}\n\nTEST_F(TCPAddressTest, IPv4LocalhostMySQL) {\n  TCPAddress a(\"127.0.0.1\", 3306);\n  EXPECT_EQ(\"127.0.0.1\", a.addr);\n  EXPECT_EQ(3306, a.port);\n  EXPECT_TRUE(a.is_valid());\n  EXPECT_EQ(TCPAddress::Family::IPV4, a.get_family());\n  EXPECT_TRUE(a.is_family<TCPAddress::Family::IPV4>());\n  EXPECT_FALSE(a.is_family<TCPAddress::Family::IPV6>());\n}\n\nTEST_F(TCPAddressTest, IPv6LocalhostMySQL) {\n  TCPAddress a(\"::1\", 3306);\n  EXPECT_EQ(\"::1\", a.addr);\n  EXPECT_EQ(3306, a.port);\n  EXPECT_TRUE(a.is_valid());\n  EXPECT_EQ(TCPAddress::Family::IPV6, a.get_family());\n  EXPECT_FALSE(a.is_family<TCPAddress::Family::IPV4>());\n  EXPECT_TRUE(a.is_family<TCPAddress::Family::IPV6>());\n}\n\nTEST_F(TCPAddressTest, IPv4InvalidAddress) {\n  TCPAddress a(\"999.999.999.999\", 3306);\n  EXPECT_EQ(\"999.999.999.999\", a.addr);\n  EXPECT_EQ(3306, a.port);\n  EXPECT_FALSE(a.is_valid());\n  EXPECT_EQ(TCPAddress::Family::INVALID, a.get_family());\n  EXPECT_FALSE(a.is_family<TCPAddress::Family::IPV4>());\n  EXPECT_FALSE(a.is_family<TCPAddress::Family::IPV6>());\n}\n\nTEST_F(TCPAddressTest, IPv4InvalidPort) {\n  TCPAddress a(\"192.168.1.2\", 0);\n  EXPECT_EQ(\"192.168.1.2\", a.addr);\n  EXPECT_EQ(0, a.port);\n  EXPECT_FALSE(a.is_valid());\n  EXPECT_EQ(TCPAddress::Family::IPV4, a.get_family());\n  EXPECT_TRUE(a.is_family<TCPAddress::Family::IPV4>());\n  EXPECT_FALSE(a.is_family<TCPAddress::Family::IPV6>());\n}\n\nTEST_F(TCPAddressTest, IPv6InvalidPort) {\n  TCPAddress a(\"fdc2:f6c4:a09e:b67b:1:2:3:4\", 99999);\n  EXPECT_EQ(\"fdc2:f6c4:a09e:b67b:1:2:3:4\", a.addr);\n  EXPECT_EQ(0, a.port);\n  EXPECT_FALSE(a.is_valid());\n  EXPECT_EQ(TCPAddress::Family::IPV6, a.get_family());\n  EXPECT_FALSE(a.is_family<TCPAddress::Family::IPV4>());\n  EXPECT_TRUE(a.is_family<TCPAddress::Family::IPV6>());\n}\n\nTEST_F(TCPAddressTest, IPv6ValidPort) {\n  TCPAddress a(\"fdc2:f6c4:a09e:b67b:1:2:3:4\", 3306);\n  EXPECT_EQ(\"fdc2:f6c4:a09e:b67b:1:2:3:4\", a.addr);\n  EXPECT_EQ(3306, a.port);\n  EXPECT_TRUE(a.is_valid());\n  EXPECT_EQ(TCPAddress::Family::IPV6, a.get_family());\n  EXPECT_FALSE(a.is_family<TCPAddress::Family::IPV4>());\n  EXPECT_TRUE(a.is_family<TCPAddress::Family::IPV6>());\n}\n\nint main(int argc, char *argv[])\n{\n  init_windows_sockets();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/router/tests/test_log_filter.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"gtest/gtest.h\"\n#include \"gmock/gmock.h\"\n#include \"mysqlrouter/log_filter.h\"\n\nnamespace mysqlrouter {\n\nclass LogFilterTest: public testing::Test {\n public:\n  LogFilter log_filter;\n};\n\nTEST_F(LogFilterTest, IsStatementNotChangedWhenNoPatternMatched) {\n  const std::string statement =\n      \"CREATE USER router_xxxx WITH mysql_native_password AS 'password123'\";\n  ASSERT_THAT(log_filter.filter(statement), testing::Eq(statement));\n}\n\nTEST_F(LogFilterTest, IsEmptyPasswordHiddenWhenPatternMatched) {\n  const std::string statement =\n      \"CREATE USER router_xxxx WITH mysql_native_password AS ''\";\n  const std::string pattern(\n      \"CREATE USER ([[:graph:]]+) WITH mysql_native_password AS ([[:graph:]]*)\");\n  log_filter.add_pattern(pattern, 2);\n  const std::string expected_result(\n      \"CREATE USER router_xxxx WITH mysql_native_password AS ***\");\n  ASSERT_THAT(log_filter.filter(statement), testing::Eq(expected_result));\n}\n\nTEST_F(LogFilterTest, IsSpecialCharacterPasswordHiddenWhenPatternMatched) {\n  const std::string statement =\n      \"CREATE USER router_xxxx WITH mysql_native_password AS '%$_*@'\";\n  const std::string pattern(\n      \"CREATE USER ([[:graph:]]+) WITH mysql_native_password AS ([[:graph:]]*)\");\n  log_filter.add_pattern(pattern, 2);\n  const std::string expected_result(\n      \"CREATE USER router_xxxx WITH mysql_native_password AS ***\");\n  ASSERT_THAT(log_filter.filter(statement), testing::Eq(expected_result));\n}\n\nTEST_F(LogFilterTest, IsPasswordHiddenWhenPatternMatched) {\n  const std::string statement =\n      \"CREATE USER router_xxxx WITH mysql_native_password AS 'password123'\";\n  const std::string pattern(\n      \"CREATE USER ([[:graph:]]+) WITH mysql_native_password AS ([[:graph:]]*)\");\n  log_filter.add_pattern(pattern, 2);\n  const std::string expected_result(\n      \"CREATE USER router_xxxx WITH mysql_native_password AS ***\");\n  ASSERT_THAT(log_filter.filter(statement), testing::Eq(expected_result));\n}\n\nTEST_F(LogFilterTest, IsMoreThenOneGroupHidden) {\n  const std::string statement =\n      \"ALTER USER \\'jeffrey\\'@\\'localhost\\' IDENTIFIED WITH sha256_password BY \\'new_password\\' PASSWORD EXPIRE INTERVAL 180 DAY\";\n  const std::string pattern =\n      \"ALTER USER ([[:graph:]]+) IDENTIFIED WITH ([[:graph:]]*) BY ([[:graph:]]*) PASSWORD EXPIRE INTERVAL 180 DAY\";\n  const std::string expected_result =\n      \"ALTER USER \\'jeffrey\\'@\\'localhost\\' IDENTIFIED WITH *** BY *** PASSWORD EXPIRE INTERVAL 180 DAY\";\n  log_filter.add_pattern(pattern, std::vector<size_t> {2, 3});\n  ASSERT_THAT(log_filter.filter(statement), testing::Eq(expected_result));\n}\n\n} // end of mysqlrouter namespace\n"
  },
  {
    "path": "src/router/tests/test_metadata_check.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"router_test_helpers.h\"\n#include \"mysqlrouter/utils.h\"\n\n#include <cstring>\n#include <sstream>\n\n//ignore GMock warnings\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wsign-conversion\"\n#endif\n\n#include \"gmock/gmock.h\"\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n#include \"mysqlrouter/mysql_session.h\"\n#include \"mysql_session_replayer.h\"\n#include \"cluster_metadata.h\"\n\n\nusing ::testing::Return;\nusing namespace testing;\n\n\nstatic MySQLSessionReplayer &q_schema_version(MySQLSessionReplayer &m) {\n  m.expect_query_one(\"SELECT * FROM mysql_innodb_cluster_metadata.schema_version\");\n  return m;\n}\n\nstatic MySQLSessionReplayer &q_schema_version(MySQLSessionReplayer &m,\n    const char *major, const char *minor, const char *patch = nullptr) {\n  m.expect_query_one(\"SELECT * FROM mysql_innodb_cluster_metadata.schema_version\");\n  if (!patch)\n    m.then_return(2, {{m.string_or_null(major), m.string_or_null(minor)}});\n  else\n    m.then_return(3, {{m.string_or_null(major), m.string_or_null(minor), m.string_or_null(patch)}});\n  return m;\n}\n\nstatic MySQLSessionReplayer &q_metadata_only_our_group(MySQLSessionReplayer &m) {\n  m.expect_query_one(\"SELECT  ((SELECT count(*) FROM mysql_innodb_cluster_metadata.clusters) <= 1  AND (SELECT count(*) FROM mysql_innodb_cluster_metadata.replicasets) <= 1) as has_one_replicaset, (SELECT attributes->>'$.group_replication_group_name' FROM mysql_innodb_cluster_metadata.replicasets)  = @@group_replication_group_name as replicaset_is_ours\");\n  return m;\n}\n\nstatic MySQLSessionReplayer &q_metadata_only_our_group(MySQLSessionReplayer &m,\n    const char *single_cluster, const char *is_our_own_group) {\n  m.expect_query_one(\"SELECT  ((SELECT count(*) FROM mysql_innodb_cluster_metadata.clusters) <= 1  AND (SELECT count(*) FROM mysql_innodb_cluster_metadata.replicasets) <= 1) as has_one_replicaset, (SELECT attributes->>'$.group_replication_group_name' FROM mysql_innodb_cluster_metadata.replicasets)  = @@group_replication_group_name as replicaset_is_ours\");\n  m.then_return(2, {{m.string_or_null(single_cluster), m.string_or_null(is_our_own_group)}});\n  return m;\n}\n\nstatic MySQLSessionReplayer &q_member_state(MySQLSessionReplayer &m) {\n  m.expect_query_one(\"SELECT member_state FROM performance_schema.replication_group_members WHERE member_id = @@server_uuid\");\n  return m;\n}\n\nstatic MySQLSessionReplayer &q_member_state(MySQLSessionReplayer &m,\n    const char *state) {\n  m.expect_query_one(\"SELECT member_state FROM performance_schema.replication_group_members WHERE member_id = @@server_uuid\");\n  m.then_return(1, {{m.string_or_null(state)}});\n  return m;\n}\n\nstatic MySQLSessionReplayer &q_quorum(MySQLSessionReplayer &m) {\n  m.expect_query_one(\"SELECT SUM(IF(member_state = 'ONLINE', 1, 0)) as num_onlines, COUNT(*) as num_total FROM performance_schema.replication_group_members\");\n  return m;\n}\n\nstatic MySQLSessionReplayer &q_quorum(MySQLSessionReplayer &m,\n    const char *num_onlines, const char *num_total) {\n  m.expect_query_one(\"SELECT SUM(IF(member_state = 'ONLINE', 1, 0)) as num_onlines, COUNT(*) as num_total FROM performance_schema.replication_group_members\");\n  m.then_return(2, {{m.string_or_null(num_onlines), m.string_or_null(num_total)}});\n  return m;\n}\n\nstatic MySQLSessionReplayer &q_single_primary_info(MySQLSessionReplayer &m) {\n  m.expect_query_one(\"SELECT @@group_replication_single_primary_mode=1 as single_primary_mode,        (SELECT variable_value FROM performance_schema.global_status WHERE variable_name='group_replication_primary_member') as primary_member,         @@server_uuid as my_uuid\");\n  return m;\n}\n\nstatic MySQLSessionReplayer &q_single_primary_info(MySQLSessionReplayer &m,\n    bool single_primary_mode, const char *primary_uuid, const char *my_uuid) {\n  m.expect_query_one(\"SELECT @@group_replication_single_primary_mode=1 as single_primary_mode,        (SELECT variable_value FROM performance_schema.global_status WHERE variable_name='group_replication_primary_member') as primary_member,         @@server_uuid as my_uuid\");\n  m.then_return(3, {{m.string_or_null(single_primary_mode ? \"1\" : \"0\"), m.string_or_null(primary_uuid), m.string_or_null(my_uuid)}});\n  return m;\n}\n\n// Unknown database 'mysql_innodb_cluster_metadata' (1049)\nTEST(MetadataCheck, metadata_unknown_database) {\n  MySQLSessionReplayer m;\n\n  q_schema_version(m).then_error(\"error\", 1049); // unknown database\n  ASSERT_THROW_LIKE(\n      mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"The provided server does not seem to contain metadata for a MySQL InnoDB cluster\");\n}\n\n// check that the server has the metadata in the correct version\nTEST(MetadataCheck, metadata_missing) {\n  MySQLSessionReplayer m;\n\n  q_schema_version(m).then_error(\"error\", 1146); // table doesn't exist\n  ASSERT_THROW_LIKE(\n      mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"The provided server does not seem to contain metadata for a MySQL InnoDB cluster\");\n}\n\nTEST(MetadataCheck, metadata_bad_version) {\n  MySQLSessionReplayer m;\n\n  q_schema_version(m, \"0\", \"0\", \"0\");\n  ASSERT_THROW_LIKE(\n      mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"This version of MySQL Router is not compatible with the provided MySQL InnoDB cluster metadata\");\n\n  // unexpected server errors should bubble up to the caller\n  m.expect_query_one(\"SELECT * FROM mysql_innodb_cluster_metadata.schema_version\").\n      then_error(\"Access denied for user 'native'@'%' to database 'mysql_innodb_cluster_metadata'\", 1044);\n  ASSERT_THROW_LIKE(\n      mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"Access denied for user 'native'@'%' to database 'mysql_innodb_cluster_metadata'\");\n}\n\n// check that the server we're querying contains metadata for the group it's in\n//   (metadata server group must be same as managed group currently)\nTEST(MetadataCheck, metadata_unsupported) {\n  MySQLSessionReplayer m;\n\n  q_schema_version(m, \"1\", \"0\");\n  q_metadata_only_our_group(m, \"2\", nullptr);\n  ASSERT_THROW_LIKE(mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"The provided server contains an unsupported InnoDB cluster metadata.\");\n\n  q_schema_version(m, \"1\", \"0\");\n  q_metadata_only_our_group(m, \"0\", nullptr);\n  ASSERT_THROW_LIKE(mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"The provided server contains an unsupported InnoDB cluster metadata.\");\n\n  q_schema_version(m, \"1\", \"0\", \"0\");\n  q_metadata_only_our_group(m, \"2\", nullptr);\n  ASSERT_THROW_LIKE(mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"The provided server contains an unsupported InnoDB cluster metadata.\");\n\n  q_schema_version(m, \"1\", \"0\", \"0\");\n  q_metadata_only_our_group(m, \"0\", nullptr);\n  ASSERT_THROW_LIKE(mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"The provided server contains an unsupported InnoDB cluster metadata.\");\n\n  // starting from 1.0.1, group_name in the metadata becomes mandatory\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"0\", \"1\");\n  ASSERT_THROW_LIKE(mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"The provided server contains an unsupported InnoDB cluster metadata.\");\n\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"0\", \"0\");\n  ASSERT_THROW_LIKE(mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"The provided server contains an unsupported InnoDB cluster metadata.\");\n\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"1\", \"0\");\n  ASSERT_THROW_LIKE(mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"The provided server contains an unsupported InnoDB cluster metadata.\");\n\n  // unexpected server errors should bubble up to the caller\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m).\n      then_error(\"Access denied for user 'native'@'%' to database 'mysql_innodb_cluster_metadata'\", 1044);\n  ASSERT_THROW_LIKE(mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"Access denied for user 'native'@'%' to database 'mysql_innodb_cluster_metadata'\");\n}\n\n// check that the server we're bootstrapping from has GR enabled\nTEST(MetadataCheck, metadata_gr_enabled) {\n  MySQLSessionReplayer m;\n\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"1\", \"1\");\n  q_member_state(m, \"OFFLINE\");\n\n  ASSERT_THROW_LIKE(mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"The provided server is currently not an ONLINE member of a InnoDB cluster.\");\n\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"1\", \"1\");\n  q_member_state(m, \"RECOVERING\");\n\n  ASSERT_THROW_LIKE(mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"The provided server is currently not an ONLINE member of a InnoDB cluster.\");\n\n  // unexpected server errors should bubble up to the caller\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"1\", \"1\");\n  q_member_state(m).\n      then_error(\"Access denied for user 'native'@'%' to database 'mysql_innodb_cluster_metadata'\", 1044);\n\n  ASSERT_THROW_LIKE(mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"Access denied for user 'native'@'%' to database 'mysql_innodb_cluster_metadata'\");\n}\n\nTEST(MetadataCheck, metadata_gr_enabled_ok) {\n  MySQLSessionReplayer m;\n\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"1\", \"1\");\n  q_member_state(m, \"ONLINE\");\n  q_quorum(m, \"1\", \"1\");\n  q_single_primary_info(m, false, \"\", \"abcd-1234-568\");\n  ASSERT_NO_THROW(mysqlrouter::check_innodb_metadata_cluster_session(&m, false));\n}\n\n// check that the server we're bootstrapping from has quorum\nTEST(MetadataCheck, metadata_has_quorum) {\n  MySQLSessionReplayer m;\n\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"1\", \"1\");\n  q_member_state(m, \"ONLINE\");\n  // num_onlines, num_total\n  q_quorum(m, \"1\", \"3\");\n  ASSERT_THROW_LIKE(mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"The provided server is currently not in a InnoDB cluster group with quorum and thus may contain inaccurate or outdated data\");\n\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"1\", \"1\");\n  q_member_state(m, \"ONLINE\");\n  q_quorum(m, \"0\", \"1\");\n  ASSERT_THROW_LIKE(mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"The provided server is currently not in a InnoDB cluster group with quorum and thus may contain inaccurate or outdated data.\");\n\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"1\", \"1\");\n  q_member_state(m, \"ONLINE\");\n  q_quorum(m, \"1\", \"2\");\n  ASSERT_THROW_LIKE(mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"The provided server is currently not in a InnoDB cluster group with quorum and thus may contain inaccurate or outdated data.\");\n\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"1\", \"1\");\n  q_member_state(m, \"ONLINE\");\n  q_quorum(m, \"2\", \"5\");\n  ASSERT_THROW_LIKE(mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"The provided server is currently not in a InnoDB cluster group with quorum and thus may contain inaccurate or outdated data.\");\n\n  // unexpected server errors should bubble up to the caller\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"1\", \"1\");\n  q_member_state(m, \"ONLINE\");\n  q_quorum(m).then_error(\"Access denied for user 'native'@'%' to database 'mysql_innodb_cluster_metadata'\", 1044);\n  ASSERT_THROW_LIKE(mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"Access denied for user 'native'@'%' to database 'mysql_innodb_cluster_metadata'\");\n}\n\nTEST(MetadataCheck, metadata_has_quorum_ok) {\n  MySQLSessionReplayer m;\n\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"1\", \"1\");\n  q_member_state(m, \"ONLINE\");\n  q_quorum(m, \"1\", \"1\");\n  q_single_primary_info(m, true, \"abcd-1234-567\", \"abcd-1234-567\");\n  ASSERT_NO_THROW(mysqlrouter::check_innodb_metadata_cluster_session(&m, false));\n\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"1\", \"1\");\n  q_member_state(m, \"ONLINE\");\n  q_quorum(m, \"2\", \"3\");\n  q_single_primary_info(m, true, \"abcd-1234-567\", \"abcd-1234-567\");\n  ASSERT_NO_THROW(mysqlrouter::check_innodb_metadata_cluster_session(&m, false));\n\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"1\", \"1\");\n  q_member_state(m, \"ONLINE\");\n  q_quorum(m, \"3\", \"3\");\n  q_single_primary_info(m, true, \"abcd-1234-567\", \"abcd-1234-567\");\n  ASSERT_NO_THROW(mysqlrouter::check_innodb_metadata_cluster_session(&m, false));\n\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"1\", \"1\");\n  q_member_state(m, \"ONLINE\");\n  q_quorum(m, \"3\", \"5\");\n  q_single_primary_info(m, true, \"abcd-1234-567\", \"abcd-1234-567\");\n  ASSERT_NO_THROW(mysqlrouter::check_innodb_metadata_cluster_session(&m, false));\n\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"1\", \"1\");\n  q_member_state(m, \"ONLINE\");\n  q_quorum(m, \"2\", \"2\");\n  q_single_primary_info(m, true, \"abcd-1234-567\", \"abcd-1234-567\");\n  ASSERT_NO_THROW(mysqlrouter::check_innodb_metadata_cluster_session(&m, false));\n}\n\n// check that the server we're bootstrapping from is not a non-primary\nTEST(MetadataCheck, non_primary) {\n  MySQLSessionReplayer m;\n\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"1\", \"1\");\n  q_member_state(m, \"ONLINE\");\n  q_quorum(m, \"1\", \"1\");\n  // single_primary_mode, primary_member, my_uuid\n  q_single_primary_info(m, true, \"abcd-1234-567\", \"abcd-1234-568\");\n  ASSERT_THROW_LIKE(mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"The provided server is not an updatable member of the cluster. Please try again with the Primary member of the replicaset (abcd-1234-567)\");\n\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"1\", \"1\");\n  q_member_state(m, \"ONLINE\");\n  q_quorum(m, \"1\", \"1\");\n  q_single_primary_info(m, true, \"\", \"abcd-1234-568\");\n  ASSERT_THROW_LIKE(mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"The provided server is not an updatable member of the cluster. Please try again with the Primary member of the replicaset\");\n\n  // unexpected server errors should bubble up to the caller\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"1\", \"1\");\n  q_member_state(m, \"ONLINE\");\n  q_quorum(m, \"1\", \"1\");\n  q_single_primary_info(m).then_error(\"Access denied for user 'native'@'%' to database 'mysql_innodb_cluster_metadata'\", 1044);\n  ASSERT_THROW_LIKE(mysqlrouter::check_innodb_metadata_cluster_session(&m, false),\n      std::runtime_error,\n      \"Access denied for user 'native'@'%' to database 'mysql_innodb_cluster_metadata'\");\n}\n\nTEST(MetadataCheck, non_primary_ok) {\n  MySQLSessionReplayer m;\n\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"1\", \"1\");\n  q_member_state(m, \"ONLINE\");\n  q_quorum(m, \"1\", \"1\");\n  // single_primary_mode, primary_member, my_uuid\n  q_single_primary_info(m, true, \"abcd-1234-567\", \"abcd-1234-567\");\n  ASSERT_NO_THROW(mysqlrouter::check_innodb_metadata_cluster_session(&m, false));\n\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"1\", \"1\");\n  q_member_state(m, \"ONLINE\");\n  q_quorum(m, \"1\", \"1\");\n  q_single_primary_info(m, false, \"\", \"abcd-1234-568\");\n  ASSERT_NO_THROW(mysqlrouter::check_innodb_metadata_cluster_session(&m, false));\n\n  q_schema_version(m, \"1\", \"0\", \"1\");\n  q_metadata_only_our_group(m, \"1\", \"1\");\n  q_member_state(m, \"ONLINE\");\n  q_quorum(m, \"1\", \"1\");\n  q_single_primary_info(m, false, \"123456789\", \"abcd-1234-568\");\n  ASSERT_NO_THROW(mysqlrouter::check_innodb_metadata_cluster_session(&m, false));\n}\n"
  },
  {
    "path": "src/router/tests/test_mysql_session.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n// must be the first header, don't move it\n#include <gtest/gtest_prod.h>\n\n// ignore GMock warnings\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wsign-conversion\"\n#endif\n#include \"gmock/gmock.h\"\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n#include <mysql.h>\n#include \"mysqlrouter/mysql_session.h\"\n\nclass MySQLSessionTest : public ::testing::Test {};\n\nusing mysqlrouter::MySQLSession;\n\nTEST_F(MySQLSessionTest, pasrse_ssl_mode) {\n  EXPECT_EQ(SSL_MODE_DISABLED,        MySQLSession::parse_ssl_mode(MySQLSession::kSslModeDisabled));\n  EXPECT_EQ(SSL_MODE_PREFERRED,       MySQLSession::parse_ssl_mode(MySQLSession::kSslModePreferred));\n  EXPECT_EQ(SSL_MODE_REQUIRED,        MySQLSession::parse_ssl_mode(MySQLSession::kSslModeRequired));\n  EXPECT_EQ(SSL_MODE_VERIFY_CA,       MySQLSession::parse_ssl_mode(MySQLSession::kSslModeVerifyCa));\n  EXPECT_EQ(SSL_MODE_VERIFY_IDENTITY, MySQLSession::parse_ssl_mode(MySQLSession::kSslModeVerifyIdentity));\n  EXPECT_THROW(MySQLSession::parse_ssl_mode(\"bad\"),   std::logic_error);\n}\n\nTEST_F(MySQLSessionTest, ssl_mode_to_string) {\n  EXPECT_EQ(MySQLSession::kSslModeDisabled,       MySQLSession::ssl_mode_to_string(SSL_MODE_DISABLED));\n  EXPECT_EQ(MySQLSession::kSslModePreferred,      MySQLSession::ssl_mode_to_string(SSL_MODE_PREFERRED));\n  EXPECT_EQ(MySQLSession::kSslModeRequired,       MySQLSession::ssl_mode_to_string(SSL_MODE_REQUIRED));\n  EXPECT_EQ(MySQLSession::kSslModeVerifyCa,       MySQLSession::ssl_mode_to_string(SSL_MODE_VERIFY_CA));\n  EXPECT_EQ(MySQLSession::kSslModeVerifyIdentity, MySQLSession::ssl_mode_to_string(SSL_MODE_VERIFY_IDENTITY));\n}\n\n"
  },
  {
    "path": "src/router/tests/test_plugins_config.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"gtest_consoleoutput.h\"\n#include \"cmd_exec.h\"\n#include \"router_app.h\"\n\n#include <fstream>\n\n#include \"gmock/gmock.h\"\n\nusing ::testing::HasSubstr;\nusing ::testing::StrEq;\nusing mysql_harness::Path;\nusing std::string;\n\nstring g_cwd;\nPath g_origin;\n\nclass PluginsConfigTest : public ConsoleOutputTest {\nprotected:\n  virtual void SetUp() {\n    set_origin(g_origin);\n    ConsoleOutputTest::SetUp();\n    config_path.reset(new Path(g_cwd));\n    config_path->append(\"PluginsConfigTest.conf\");\n  }\n\n  void reset_config() {\n    std::ofstream ofs_config(config_path->str());\n    if (ofs_config.good()) {\n      ofs_config << \"[DEFAULT]\\n\";\n      ofs_config << \"logging_folder =\\n\";\n      ofs_config << \"plugin_folder = \" << plugin_dir->str() << \"\\n\";\n      ofs_config << \"runtime_folder = \" << stage_dir->str() << \"\\n\";\n      ofs_config << \"config_folder = \" << stage_dir->str() << \"\\n\\n\";\n      ofs_config.close();\n    }\n  }\n\n  std::unique_ptr<Path> config_path;\n};\n\nTEST_F(PluginsConfigTest, NoPluginLoaded) {\n  reset_config();\n\n  string cmd = app_mysqlrouter->str() + \" -c \" + config_path->str();\n  auto cmd_result = cmd_exec(cmd, true);\n\n  ASSERT_THAT(cmd_result.output, HasSubstr(\"MySQL Router not configured to load or start any plugin. Exiting.\"));\n}\n\nTEST_F(PluginsConfigTest, OnePluginLoaded) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[magic]\\n\\n\"; // any plugin would do\n  c.close();\n\n  string cmd = app_mysqlrouter->str() + \" -c \" + config_path->str();\n  auto cmd_result = cmd_exec(cmd, true);\n\n  EXPECT_EQ(0, cmd_result.exit_code);\n  ASSERT_THAT(cmd_result.output, Not(HasSubstr(\"MySQL Router not configured to load or start any plugin. Exiting.\")));\n}\n\nTEST_F(PluginsConfigTest, TwoMetadadaCacheSections) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[metadata_cache:one]\\n\\n\";\n  c << \"[metadata_cache:two]\\n\\n\";\n  c.close();\n\n  string cmd = app_mysqlrouter->str() + \" -c \" + config_path->str();\n  auto cmd_result = cmd_exec(cmd, true);\n\n  ASSERT_THAT(cmd_result.output, HasSubstr(\"MySQL Router currently supports only one metadata_cache instance.\"));\n}\n\nTEST_F(PluginsConfigTest, SingleMetadataChacheSection) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[metadata_cache:one]\\n\\n\";\n  c.close();\n\n  string cmd = app_mysqlrouter->str() + \" -c \" + config_path->str();\n  auto cmd_result = cmd_exec(cmd, true);\n\n  // shoule be ok but complain about missing user option\n  ASSERT_THAT(cmd_result.output, HasSubstr(\"option user in [metadata_cache:one] is required\"));\n}\n\nint main(int argc, char *argv[]) {\n  g_origin = Path(argv[0]).dirname();\n  g_cwd = Path(argv[0]).dirname().str();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/router/tests/test_uri.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"gtest/gtest.h\"\n#include \"gmock/gmock.h\"\n\n#include <exception>\n\n#include \"mysqlrouter/uri.h\"\n\nusing std::string;\nusing ::testing::StrEq;\nusing mysqlrouter::URI;\nusing mysqlrouter::URIError;\nusing mysqlrouter::URIQuery;\nusing mysqlrouter::URIAuthority;\nusing mysqlrouter::URIPath;\nusing mysqlrouter::URIQuery;\n\nclass URISimpleTests: public ::testing::Test {\n};\n\n// default constructor tests\n\nTEST_F(URISimpleTests, Constructor)\n{\n  URI u;\n  ASSERT_TRUE(u.scheme.empty());\n  ASSERT_TRUE(u.host.empty());\n  ASSERT_EQ(u.port, 0);\n  ASSERT_TRUE(u.username.empty());\n  ASSERT_TRUE(u.password.empty());\n  ASSERT_TRUE(u.path.empty());\n  ASSERT_TRUE(u.query.empty());\n  ASSERT_TRUE(u.fragment.empty());\n}\n\n// parsing\n\nstruct URIParseGoodTestData {\n  struct {\n    const char *uri;\n  } input;\n\n  struct {\n    const char *scheme;\n    const char *host;\n    uint64_t port;\n    const char *username;\n    const char *password;\n    URIPath path;\n    URIQuery query;\n    const char *fragment;\n  } expected;\n};\n\n\n// pretty printer for the test data\n::std::ostream& operator<<(::std::ostream &os, const URIParseGoodTestData &data) {\n  return os << data.input.uri;\n}\n\nclass URIParseGoodTests: public ::testing::Test,\n  public ::testing::WithParamInterface<URIParseGoodTestData> {\n};\n\nTEST_P(URIParseGoodTests, ParseURIconstruct) {\n  auto test_param = GetParam();\n  URI u;\n\n  ASSERT_NO_THROW(u = URI(test_param.input.uri));\n\n  EXPECT_THAT(u.scheme, StrEq(test_param.expected.scheme));\n  EXPECT_THAT(u.host, StrEq(test_param.expected.host));\n  EXPECT_EQ(u.port, test_param.expected.port);\n  EXPECT_THAT(u.username, StrEq(test_param.expected.username));\n  EXPECT_THAT(u.password, StrEq(test_param.expected.password));\n  EXPECT_EQ(u.path, test_param.expected.path);\n  EXPECT_EQ(u.query, test_param.expected.query);\n  EXPECT_THAT(u.fragment, StrEq(test_param.expected.fragment));\n}\n\nTEST_P(URIParseGoodTests, ParseURIseturi) {\n  auto test_param = GetParam();\n  URI u;\n\n  ASSERT_NO_THROW(u = URI(\"ham://foo:bar@host/path?key=value#frag\"));\n  ASSERT_NO_THROW(u.set_uri(test_param.input.uri));\n\n  EXPECT_THAT(u.scheme, StrEq(test_param.expected.scheme));\n  EXPECT_THAT(u.host, StrEq(test_param.expected.host));\n  EXPECT_EQ(u.port, test_param.expected.port);\n  EXPECT_THAT(u.username, StrEq(test_param.expected.username));\n  EXPECT_THAT(u.password, StrEq(test_param.expected.password));\n  EXPECT_EQ(u.path, test_param.expected.path);\n  EXPECT_EQ(u.query, test_param.expected.query);\n  EXPECT_THAT(u.fragment, StrEq(test_param.expected.fragment));\n}\n\n\nURIParseGoodTestData uri_test_data[] = {\n  // just a scheme, everything else is empty\n  {\n    { \"ham:\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" }\n  },\n\n  // uppercase, translates to lowercase\n  {\n    { \"HAM:\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n\n  // check all allowed chars\n  {\n    { \"h123-+.:\", },\n    { \"h123-+.\", \"\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n\n  // no host, no trailing space\n  {\n    { \"ham://\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n\n  },\n  // no host, absolute path\n  {\n    { \"ham:/foo\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath({\"foo\"}), URIQuery(), \"\" },\n  },\n\n  // no host, no trailing space\n  {\n    { \"ham:///\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n\n  // no values, just sep's\n  {\n    { \"ham://:@:/\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n\n  // no values, just sep's\n  {\n    { \"ham://:/\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n\n  },\n  // no values, just sep's\n  {\n    { \"ham://:@/\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n\n  // host, no trailing space\n  {\n    { \"ham://spam.example.com\", },\n    { \"ham\", \"spam.example.com\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n\n  },\n  // host, with trailing space\n  {\n    { \"ham://spam.example.com/\", },\n    { \"ham\", \"spam.example.com\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n\n  // host, port-separator, but no value\n  {\n    { \"ham://spam.example.com:/\", },\n    { \"ham\", \"spam.example.com\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n\n  // host, port-separator, value\n  {\n    { \"ham://spam.example.com:80/\", },\n    { \"ham\", \"spam.example.com\", 80, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n\n  // host, userinfo empty\n  {\n    { \"ham://@spam.example.com:80/\", },\n    { \"ham\", \"spam.example.com\", 80, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n\n  // host, userinfo empty, pw empty, with sep\n  {\n    { \"ham://:@spam.example.com:80/\", },\n    { \"ham\", \"spam.example.com\", 80, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n\n  // host, userinfo, no pw\n  {\n    { \"ham://scott@spam.example.com:80/\", },\n    { \"ham\", \"spam.example.com\", 80, \"scott\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n\n  // host, userinfo, no pw\n  {\n    { \"ham://scott:@spam.example.com:80/\", },\n    { \"ham\", \"spam.example.com\", 80, \"scott\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n\n  // host, userinfo, pw\n  {\n    { \"ham://scott:tiger@spam.example.com:80/\", },\n    { \"ham\", \"spam.example.com\", 80, \"scott\", \"tiger\", URIPath(), URIQuery(), \"\" },\n  },\n\n  // no host, userinfo, pw\n  {\n    { \"ham://scott:tiger@/\", },\n    { \"ham\", \"\", 0, \"scott\", \"tiger\", URIPath(), URIQuery(), \"\" },\n  },\n\n  // no host, no user, pw\n  {\n    { \"ham://:tiger@/\", },\n    { \"ham\", \"\", 0, \"\", \"tiger\", URIPath(), URIQuery(), \"\" },\n  },\n\n  // ipv4\n  {\n    { \"ham://1.2.3.4\", },\n    { \"ham\", \"1.2.3.4\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n  // ipv4, trailing slash\n  {\n    { \"ham://1.2.3.4/\", },\n    { \"ham\", \"1.2.3.4\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n  // ipv4, port\n  {\n    { \"ham://1.2.3.4:82\", },\n    { \"ham\", \"1.2.3.4\", 82, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n\n  // ipv6, loopback address, compressed\n  {\n    { \"ham://[::1]\", },\n    { \"ham\", \"::1\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n\n  // ipv6, unspecified address\n  {\n    { \"ham://[::]\", },\n    { \"ham\", \"::\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n  // ipv6, full length\n  {\n    { \"ham://[ABCD:EF01:2345:6789:ABCD:EF01:2345:6789]\", },\n    { \"ham\", \"ABCD:EF01:2345:6789:ABCD:EF01:2345:6789\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n\n  // ipv6, abbreviated\n  {\n    { \"ham://[2001:DB8:0:0:8:800:200C:417A]\", },\n    { \"ham\", \"2001:DB8:0:0:8:800:200C:417A\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n  // ipv6, abbreviated, compressed\n  {\n    { \"ham://[2001:DB8::8:800:200C:417A]\", },\n    { \"ham\", \"2001:DB8::8:800:200C:417A\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n  // IPv6, ipv4 inside ipv6, compresses\n  {\n    { \"ham://[::13.1.68.3]\", },\n    { \"ham\", \"::13.1.68.3\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n  // IPv6 with zoneinfo\n  {\n    { \"ham://[::1\" \"%25\" \"foo]\", },\n    { \"ham\", \"::1%foo\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n\n\n  // ipv6, trailing slash\n  {\n    { \"ham://[::1]/\", },\n    { \"ham\", \"::1\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n  // ipv6, port\n  {\n    { \"ham://[::1]:81\", },\n    { \"ham\", \"::1\", 81, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n  // ipv6, port, trailing slash\n  {\n    { \"ham://[::1]:81/\", },\n    { \"ham\", \"::1\", 81, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n\n  // fragment\n  {\n    { \"ham:///#fragment\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath(), URIQuery(), \"fragment\" },\n  },\n\n  // fragment\n  {\n    { \"ham:///#fragment\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath(), URIQuery(), \"fragment\" },\n\n  },\n  // fragment ... with all allowed extra chars\n  {\n    { \"ham:///#fragment?@:/\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath(), URIQuery(), \"fragment?@:/\" },\n  },\n\n  // empty fragment\n  {\n    { \"ham:///#\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n\n  // query string\n  {\n    { \"ham:///?foo=bar\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath(), URIQuery({{\"foo\", \"bar\"}}), \"\" },\n  },\n\n  // query string, empty value\n  {\n    { \"ham:///?foo=\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath(), URIQuery({{\"foo\", \"\"}}), \"\" },\n  },\n\n  // query string, empty value, trailing &\n  {\n    { \"ham:///?foo=&\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath(), URIQuery({{\"foo\", \"\"}}), \"\" },\n  },\n\n  // query string, trailing &\n  {\n    { \"ham:///?foo=bar&\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath(), URIQuery({{\"foo\", \"bar\"}}), \"\" },\n  },\n\n  // query string, multiple values\n  {\n    { \"ham:///?foo=bar&fuz=baz\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath(), URIQuery({{\"foo\", \"bar\"}, {\"fuz\", \"baz\"}}), \"\" },\n  },\n\n  // query string, pct-encoding for key and value\n  {\n    { \"ham:///?foo%3d=bar%26&\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath(), URIQuery({{\"foo=\", \"bar&\"}, }), \"\" },\n  },\n\n\n  // path\n  {\n    { \"ham:///foo/\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath({\"foo\"}), URIQuery(), \"\" },\n  },\n\n  // path, no trailing slash\n  {\n    { \"ham:///foo\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath({\"foo\"}), URIQuery(), \"\" },\n  },\n\n  // double slash\n  {\n    { \"ham:///foo//bar\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath({\"foo\", \"bar\"}), URIQuery(), \"\" },\n  },\n\n  // empty host, empty path, query\n  {\n    { \"ham://?foo=bar\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath(), URIQuery({{\"foo\", \"bar\"}}), \"\" },\n  },\n\n  // empty host, empty path, fragment\n  {\n    { \"ham://#fragment\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath(), URIQuery(), \"fragment\" },\n  },\n\n  {\n    { \"mailto:foo@example.org\", },\n    { \"mailto\", \"\", 0, \"\", \"\", URIPath({\"foo@example.org\"}), URIQuery(), \"\" },\n  },\n\n  {\n    { \"urn:example:animal:ferret:nose\", },\n    { \"urn\", \"\", 0, \"\", \"\", URIPath({\"example:animal:ferret:nose\"}), URIQuery(), \"\" },\n  },\n\n  {\n    // pct-encoded reg-name\n    { \"ham://foo.%2f/\", },\n    { \"ham\", \"foo./\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n\n  {\n    // pct-encoded reg-name\n    { \"ham://foo.%2fbar/\", },\n    { \"ham\", \"foo./bar\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n\n  {\n    // pct-encoded reg-name\n    { \"ham://foo.%2f%2fbar/\", },\n    { \"ham\", \"foo.//bar\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n  {\n    // pct-encoded userinfo\n    { \"ham://user:fo%40@/\", },\n    { \"ham\", \"\", 0, \"user\", \"fo@\", URIPath(), URIQuery(), \"\" },\n  },\n  {\n    // pct-encoded userinfo, check if %3a [:] isn't decoded too early\n    { \"ham://user%3a:fo%40@/\", },\n    { \"ham\", \"\", 0, \"user:\", \"fo@\", URIPath(), URIQuery(), \"\" },\n  },\n  {\n    // pct-encoded userinfo, leading pct-enc is ok\n    { \"ham://%40user:fo%40bar%40@/\", },\n    { \"ham\", \"\", 0, \"@user\", \"fo@bar@\", URIPath(), URIQuery(), \"\" },\n  },\n  {\n    // pct-encoded path, trailing pct-enc\n    { \"ham:///fo%2f\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath({\"fo/\"}), URIQuery(), \"\" },\n  },\n\n  {\n    // pct-encoded reg-name\n    { \"s:v%88\", },\n    { \"s\", \"\", 0, \"\", \"\", URIPath({\"v\" \"\\x88\"}), URIQuery(), \"\" },\n  },\n\n  {\n    // fuzzer hang\n    { \"ham:o/scott:tiger@spam.example.com:80\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath({\"o\", \"scott:tiger@spam.example.com:80\"}), URIQuery(), \"\" },\n  },\n\n  {\n    // path-empty with query\n    { \"ham:?\", },\n    { \"ham\", \"\", 0, \"\", \"\", URIPath(), URIQuery(), \"\" },\n  },\n};\n\nINSTANTIATE_TEST_CASE_P(\n    URITests, URIParseGoodTests,\n    ::testing::ValuesIn(uri_test_data)\n    );\n\n\n\n// should all throw\nstruct URITestFailData {\n  struct {\n    const char *uri;\n  } input;\n\n  struct {\n    const char *exception_text;\n  } expected;\n};\n\n// pretty printer for the test data\n::std::ostream& operator<<(::std::ostream &os, const URITestFailData &data) {\n  return os << data.input.uri;\n}\n\n\n\nclass URIParseThrowingTests: public ::testing::Test,\n  public ::testing::WithParamInterface<URITestFailData> {\n};\n\nTEST_P(URIParseThrowingTests, FailsParseURI) {\n  // call GetParam outside the ASSERT to actually make it work\n  URITestFailData test_data = GetParam();\n\n  try {\n    auto u = URI(test_data.input.uri);\n\n    FAIL() << \"should have failed\";\n  } catch(URIError &e) {\n    EXPECT_THAT(e.what(), StrEq(test_data.expected.exception_text));\n  } catch(...) {\n    FAIL() << \"expected to throw URIError, got unexpected exception\";\n  }\n}\n\nURITestFailData uri_test_fail_data[] = {\n  {\n    // no trailing :\n    { \"ham\", },\n    { \"invalid URI: expected colon after scheme at position 3 for: ham\" },\n  },\n  {\n    // invalid chars\n    { \"ham$$:\", },\n    { \"invalid URI: expected colon after scheme at position 3 for: ham$$:\" },\n  },\n  {\n    // initial char has to be a ALPHA\n    { \"1ham:\", },\n    { \"invalid URI: no scheme at position 0 for: 1ham:\" },\n  },\n  {\n    // IPv6 has to be valid\n    { \"ham://[user@bar]:3306\", },\n    { \"invalid URI: expected to find IPv6 address, but failed at position 7 for: ham://[user@bar]:3306\" },\n  },\n  {\n    { \"ham://[\", },\n    { \"invalid URI: expected to find IPv6 address, but failed at position 7 for: ham://[\" },\n  },\n  {\n    // no =, no value\n    { \"ham:///?foo\", },\n    { \"invalid URI: query-string part doesn't contain '='\" },\n  },\n  {\n    // port too large\n    { \"ham://:99999\", },\n    { \"invalid URI: invalid port: impossible port number for: ham://:99999\" },\n  },\n  {\n    // port too large (stoul)\n    { \"ham://:999999999999999999999999999999999999999999999999999999999999999\", },\n    { \"invalid URI: invalid port: impossible port number for: ham://:999999999999999999999999999999999999999999999999999999999999999\" },\n  },\n  {\n    // invalid scheme\n    { \"ham//\", },\n    { \"invalid URI: expected colon after scheme at position 3 for: ham//\" },\n  },\n  {\n    // IPv6 validation, too may colons\n    { \"ham://[:::1]\", },\n    { \"invalid URI: expected to find a ']' at position 9 for: ham://[:::1]\" },\n  },\n  {\n    // IPv6 validation, only one colon\n    { \"ham://[::1::1]\", },\n    { \"invalid URI: expected to find a ']' at position 10 for: ham://[::1::1]\" },\n  },\n  {\n    // IPv6 validation, wrong sep\n    { \"ham://[::1%26foo]\", },\n    { \"invalid URI: invalid pct-encoded value, expected %25 at position 11 for: ham://[::1%26foo]\" },\n  },\n  {\n    // IPv6 validation, wrong ipv4\n    { \"ham://[::1.1.1]\", },\n    { \"invalid URI: expected to find a ']' at position 10 for: ham://[::1.1.1]\" },\n  },\n#if 0\n  {\n    // TODO: IPvFuture validation\n    { \"ham://[v66.abc]\", },\n    { \"invalid URI: expected to find a ']' at position 7 for: ham://[v66.abc]\" },\n  },\n#endif\n  {\n    // host, broken pct-encoded\n    { \"ham://%\", },\n    { \"invalid URI: unexpected characters at position 6 for: ham://%\" },\n  },\n  {\n    // host, broken pct-encoded\n    { \"ham://%a\", },\n    { \"invalid URI: unexpected characters at position 6 for: ham://%a\" },\n  },\n  {\n    // path, broken pct-encoded\n    { \"ham:%a\", },\n    { \"invalid URI: unexpected characters at position 4 for: ham:%a\" },\n  },\n  {\n    // fuzzer crash\n    { \"ham://[c::d:55%2555%25jm.examph55555C5I5%25\", },\n    { \"invalid URI: expected to find a ']' at position 43 for: ham://[c::d:55%2555%25jm.examph55555C5I5%25\", },\n  },\n  {\n    // fuzzer crash\n    { \"hhu://[c::B\", },\n    { \"invalid URI: expected to find a ']' at position 11 for: hhu://[c::B\", },\n  },\n};\n\nINSTANTIATE_TEST_CASE_P(\n    URITests, URIParseThrowingTests,\n    ::testing::ValuesIn(uri_test_fail_data));\n\n\n// parsing\n\nstruct URItoStringTestData {\n  struct {\n    const char *scheme;\n    const char *host;\n    uint16_t port;\n    const char *username;\n    const char *password;\n    URIPath path;\n    URIQuery query;\n    const char *fragment;\n  } input;\n\n  struct {\n    const char *uri;\n  } expected;\n};\n\n\n// pretty printer for the test data\n::std::ostream& operator<<(::std::ostream &os, const URItoStringTestData &data) {\n  return os << data.input.scheme << \"://\" << data.input.username << \":\" << data.input.password << \"@\" <<\n    data.input.host << \":\" << data.input.port << \"/\" << \"...\" << \"?\" << \"...\" << \"#\" << data.input.fragment;\n}\n\nclass URItoStringGoodTests: public ::testing::Test,\n  public ::testing::WithParamInterface<URItoStringTestData> {\n};\n\nTEST_P(URItoStringGoodTests, URItoString) {\n  auto test_param = GetParam();\n  URI u;\n\n  u.scheme = test_param.input.scheme;\n  u.host = test_param.input.host;\n  u.port = test_param.input.port;\n  u.username = test_param.input.username;\n  u.password = test_param.input.password;\n  u.path = test_param.input.path;\n  u.query = test_param.input.query;\n  u.fragment = test_param.input.fragment;\n\n  std::stringstream ss;\n\n  ss << u;\n\n  EXPECT_THAT(ss.str(), StrEq(test_param.expected.uri));\n\n}\n\n\nURItoStringTestData uri_to_string_test_data[] = {\n  {\n    { \"ham\", \"\", 0, \"\", \"\", URIPath(), URIQuery(), \"\", },\n    { \"ham:\" }\n  },\n  {\n    { \"mailto\", \"\", 0, \"\", \"\", URIPath({\"foo@example.org\"}), URIQuery(), \"\", },\n    { \"mailto:foo@example.org\" },\n  },\n  {\n    { \"http\", \"example.org\", 0, \"\", \"\", URIPath(), URIQuery(), \"\", },\n    { \"http://example.org\" },\n  },\n  {\n    { \"http\", \"example.org\", 80, \"\", \"\", URIPath(), URIQuery(), \"\", },\n    { \"http://example.org:80\" },\n  },\n  {\n    { \"http\", \"example.org\", 80, \"user\", \"\", URIPath(), URIQuery(), \"\", },\n    { \"http://user@example.org:80\" },\n  },\n  {\n    { \"http\", \"example.org\", 80, \"user\", \"pw\", URIPath(), URIQuery(), \"\", },\n    { \"http://user:pw@example.org:80\" },\n  },\n  {\n    { \"http\", \"example.org\", 80, \"\", \"pw\", URIPath(), URIQuery(), \"\", },\n    { \"http://:pw@example.org:80\" },\n  },\n  {\n    { \"http\", \"example.org\", 80, \"user\", \"pw\", URIPath({\"p\"}), URIQuery(), \"\", },\n    { \"http://user:pw@example.org:80/p\" },\n  },\n  {\n    { \"http\", \"example.org\", 80, \"user\", \"pw\", URIPath({\"p\", \"w\"}), URIQuery(), \"\", },\n    { \"http://user:pw@example.org:80/p/w\" },\n  },\n  {\n    { \"http\", \"example.org\", 80, \"user\", \"pw\", URIPath({\"p\", \"w\"}), URIQuery({{\"k\", \"v\"}}), \"\", },\n    { \"http://user:pw@example.org:80/p/w?k=v\" },\n  },\n  {\n    { \"http\", \"example.org\", 80, \"user\", \"pw\", URIPath({\"p\", \"w\"}), URIQuery({{\"k\", \"v\"}, {\"l\", \"m\"}}), \"\", },\n    { \"http://user:pw@example.org:80/p/w?k=v&l=m\" },\n  },\n  {\n    { \"http\", \"example.org\", 80, \"user\", \"pw\", URIPath({\"p\", \"w\"}), URIQuery({{\"k\", \"v\"}, {\"l\", \"m\"}}), \"frag\", },\n    { \"http://user:pw@example.org:80/p/w?k=v&l=m#frag\" },\n  },\n  {\n    { \"http\", \"/\", 0, \"\", \"\", URIPath(), URIQuery(), \"\", },\n    { \"http://%2f\" },\n  },\n  {\n    { \"http\", \"example.org\", 80, \"foo:bar\", \"\", URIPath(), URIQuery(), \"\", },\n    { \"http://foo%3abar@example.org:80\" },\n  },\n  // no need to encode the password's : as it is the 2nd sep\n  {\n    { \"http\", \"example.org\", 80, \"foo:bar\", \"p:w\", URIPath(), URIQuery(), \"\", },\n    { \"http://foo%3abar:p:w@example.org:80\" },\n  },\n  {\n    { \"http\", \"example.org\", 80, \"user\", \"pw\", URIPath({\"p/w\"}), URIQuery(), \"\", },\n    { \"http://user:pw@example.org:80/p%2fw\" },\n  },\n  {\n    { \"http\", \"example.org\", 80, \"user\", \"pw\", URIPath({\"p\", \"w\"}), URIQuery({{\"k=\", \"v&\"}}), \"\", },\n    { \"http://user:pw@example.org:80/p/w?k%3d=v%26\" },\n  },\n  {\n    { \"http\", \"example.org\", 80, \"user\", \"pw\", URIPath({\"p\", \"w\"}), URIQuery({{\"k\", \"v\"}, {\"l\", \"m#\"}}), \"frag\", },\n    { \"http://user:pw@example.org:80/p/w?k=v&l=m%23#frag\" },\n  },\n  {\n    { \"http\", \"::1\", 0, \"\", \"\", URIPath(), URIQuery(), \"\", },\n    { \"http://[::1]\" },\n  },\n  {\n    { \"http\", \"::1%lo\", 0, \"\", \"\", URIPath(), URIQuery(), \"\", },\n    { \"http://[::1%25lo]\" },\n  },\n  {\n    { \"http\", \"::1\", 80, \"\", \"\", URIPath(), URIQuery(), \"\", },\n    { \"http://[::1]:80\" },\n  },\n  {\n    { \"s\", \"\", 0, \"\", \"\", URIPath({\"v\\x88\"}), URIQuery(), \"\", },\n    { \"s:v%88\" },\n  },\n  {\n    { \"v\", \"\", 0, \"\", \"v(\", URIPath(), URIQuery(), \"\", },\n    { \"v://:v(@\" },\n  },\n};\n\nINSTANTIATE_TEST_CASE_P(\n    URITests, URItoStringGoodTests,\n    ::testing::ValuesIn(uri_to_string_test_data));\n\n// rootless\n\n// should all throw\nstruct URIRootlessTestFailData {\n  struct {\n    const char *uri;\n  } input;\n\n  struct {\n    const char *exception_text;\n  } expected;\n};\n\n// pretty printer for the test data\n::std::ostream& operator<<(::std::ostream &os, const URIRootlessTestFailData &data) {\n  return os << data.input.uri;\n}\n\nclass URIRootlessThrowingTests: public ::testing::Test,\n  public ::testing::WithParamInterface<URIRootlessTestFailData> {\n};\n\nTEST_P(URIRootlessThrowingTests, FailsParseURI) {\n  // call GetParam outside the ASSERT to actually make it work\n  auto test_data = GetParam();\n\n  try {\n    auto u = URI(test_data.input.uri, false);\n\n    FAIL() << \"should have failed\";\n  } catch(URIError &e) {\n    EXPECT_THAT(e.what(), StrEq(test_data.expected.exception_text));\n  } catch(...) {\n    FAIL() << \"expected to throw URIError, got unexpected exception\";\n  }\n}\n\nURIRootlessTestFailData uri_rootless_test_fail_data[] = {\n  {\n    // looks like a URI with scheme: localhost, path: 1234\n    {\n      \"localhost:1234\",\n    },\n    {\n      \"invalid URI: neither authority nor path at position 14 for: localhost:1234\"\n    }\n  },\n};\n\nINSTANTIATE_TEST_CASE_P(\n    URITests, URIRootlessThrowingTests,\n    ::testing::ValuesIn(uri_rootless_test_fail_data));\n"
  },
  {
    "path": "src/router/tests/test_utils.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n//ignore GMock warnings\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wconversion\"\n#endif\n\n#include \"gmock/gmock.h\"\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n#include \"mysqlrouter/utils.h\"\n#include \"mysql/harness/filesystem.h\"\n#include <fstream>\n#include <vector>\n\nconst std::string kIPv6AddrRange = \"fd84:8829:117d:63d5\";\n\nusing mysqlrouter::split_addr_port;\nusing mysqlrouter::get_tcp_port;\nusing mysqlrouter::hexdump;\nusing mysqlrouter::split_string;\nusing ::testing::ContainerEq;\nusing ::testing::Pair;\nusing std::string;\n\nclass SplitAddrPortTest: public ::testing::Test {\nprotected:\n  virtual void SetUp() {\n  }\n};\n\nTEST_F(SplitAddrPortTest, SplitAddrPort) {\n  std::string addr6 = kIPv6AddrRange + \":0001:0002:0003:0004\";\n\n  EXPECT_THAT(split_addr_port(addr6), ::testing::Pair(addr6, static_cast<uint16_t>(0)));\n  EXPECT_THAT(split_addr_port(\"[\" + addr6 + \"]\"), ::testing::Pair(addr6, static_cast<uint16_t>(0)));\n  EXPECT_THAT(split_addr_port(\"[\" + addr6 + \"]:3306\"), ::testing::Pair(addr6, static_cast<uint16_t>(3306)));\n\n  EXPECT_THAT(split_addr_port(\"192.168.14.77\"), ::testing::Pair(\"192.168.14.77\", static_cast<uint16_t>(0)));\n  EXPECT_THAT(split_addr_port(\"192.168.14.77:3306\"), ::testing::Pair(\"192.168.14.77\", static_cast<uint16_t>(3306)));\n\n  EXPECT_THAT(split_addr_port(\"mysql.example.com\"), ::testing::Pair(\"mysql.example.com\", static_cast<uint16_t>(0)));\n  EXPECT_THAT(split_addr_port(\"mysql.example.com:3306\"), ::testing::Pair(\"mysql.example.com\", static_cast<uint16_t>(3306)));\n}\n\nTEST_F(SplitAddrPortTest, SplitAddrPortFail) {\n  std::string addr6 = kIPv6AddrRange + \":0001:0002:0003:0004\";\n  ASSERT_THROW(split_addr_port(\"[\" + addr6), std::runtime_error);\n  ASSERT_THROW(split_addr_port(addr6 + \"]\"), std::runtime_error);\n  ASSERT_THROW(split_addr_port(kIPv6AddrRange + \":xyz00:0002:0003:0004\"), std::runtime_error);\n\n  // Invalid TCP port\n  ASSERT_THROW(split_addr_port(\"192.168.14.77:999999\"), std::runtime_error);\n  ASSERT_THROW(split_addr_port(\"192.168.14.77:66000\"), std::runtime_error);\n  ASSERT_THROW(split_addr_port(\"[\" + addr6 + \"]:999999\"), std::runtime_error);\n}\n\nclass GetTCPPortTest: public ::testing::Test {\nprotected:\n  virtual void SetUp() {\n  }\n};\n\nTEST_F(GetTCPPortTest, GetTCPPort) {\n  ASSERT_EQ(get_tcp_port(\"3306\"), static_cast<uint16_t>(3306));\n  ASSERT_EQ(get_tcp_port(\"0\"), static_cast<uint16_t>(0));\n  ASSERT_EQ(get_tcp_port(\"\"), static_cast<uint16_t>(0));\n  ASSERT_EQ(get_tcp_port(\"65535\"), 65535);\n}\n\nTEST_F(GetTCPPortTest, GetTCPPortFail) {\n  ASSERT_THROW(get_tcp_port(\"65536\"), std::runtime_error);\n  ASSERT_THROW(get_tcp_port(\"33 06\"), std::runtime_error);\n  ASSERT_THROW(get_tcp_port(\":3306\"), std::runtime_error);\n  ASSERT_THROW(get_tcp_port(\"99999999\"), std::runtime_error);\n  ASSERT_THROW(get_tcp_port(\"abcdef\"), std::runtime_error);\n}\n\nclass HexDumpTest: public ::testing::Test { };\n\nTEST_F(HexDumpTest, UsingCharArray) {\n  const unsigned char buffer[4] = \"abc\";\n  EXPECT_EQ(\"61 62 63 \\n\", hexdump(buffer, 3, 0));\n}\n\nTEST_F(HexDumpTest, UsingVector) {\n  std::vector<uint8_t> buffer = {'a', 'b', 'c'};\n  EXPECT_EQ(\"61 62 63 \\n\", hexdump(&buffer[0], 3, 0));\n}\n\nTEST_F(HexDumpTest, Literals) {\n  const unsigned char buffer[4] = \"abc\";\n  EXPECT_EQ(\" a  b  c \\n\", hexdump(buffer, 3, 0, true));\n  EXPECT_EQ(\"61 62 63 \\n\", hexdump(buffer, 3, 0, false));\n}\n\nTEST_F(HexDumpTest, Count) {\n  const unsigned char buffer[7] = \"abcdef\";\n  EXPECT_EQ(\" a  b  c  d  e  f \\n\", hexdump(buffer, 6, 0, true));\n  EXPECT_EQ(\" a  b  c \\n\", hexdump(buffer, 3, 0, true));\n}\n\nTEST_F(HexDumpTest, Start) {\n  const unsigned char buffer[7] = \"abcdef\";\n  EXPECT_EQ(\" a  b  c  d  e  f \\n\", hexdump(buffer, 6, 0, true));\n  EXPECT_EQ(\" d  e  f \\n\", hexdump(buffer, 3, 3, true));\n}\n\nTEST_F(HexDumpTest, MultiLine) {\n  const unsigned char buffer[33] = \"abcdefgh12345678ABCDEFGH12345678\";\n  EXPECT_EQ(\" a  b  c  d  e  f  g  h 31 32 33 34 35 36 37 38\\n A  B  C  D  E  F  G  H 31 32 33 34 35 36 37 38\\n\",\n            hexdump(buffer, 32, 0, true));\n}\n\nclass UtilsTests: public ::testing::Test {\nprotected:\n  virtual void SetUp() {\n  }\n};\n\nTEST_F(UtilsTests, SplitStringWithEmpty) {\nstd::vector<string> exp;\nstd::string tcase;\n\nexp = {\"val1\", \"val2\"};\nEXPECT_THAT(exp, ContainerEq(split_string(\"val1;val2\", ';')));\n\nexp = {\"\", \"val1\", \"val2\"};\nEXPECT_THAT(exp, ContainerEq(split_string(\";val1;val2\", ';')));\n\nexp = {\"val1\", \"val2\", \"\"};\nEXPECT_THAT(exp, ContainerEq(split_string(\"val1;val2;\", ';')));\n\nexp = {};\nEXPECT_THAT(exp, ContainerEq(split_string(\"\", ';')));\n\nexp = {\"\", \"\"};\nEXPECT_THAT(exp, ContainerEq(split_string(\";\", ';')));\n\n// No trimming\nexp = {\"  val1\", \"val2  \"};\nEXPECT_THAT(exp, ContainerEq(split_string(\"  val1&val2  \", '&')));\n\n}\n\nTEST_F(UtilsTests, SplitStringWithoutEmpty) {\nstd::vector<string> exp;\nstd::string tcase;\n\nexp = {\"val1\", \"val2\"};\nEXPECT_THAT(exp, ContainerEq(split_string(\"val1;val2\", ';', false)));\n\nexp = {\"val1\", \"val2\"};\nEXPECT_THAT(exp, ContainerEq(split_string(\";val1;val2\", ';', false)));\n\nexp = {\"val1\", \"val2\"};\nEXPECT_THAT(exp, ContainerEq(split_string(\"val1;val2;\", ';', false)));\n\nexp = {};\nEXPECT_THAT(exp, ContainerEq(split_string(\"\", ';', false)));\n\nexp = {};\nEXPECT_THAT(exp, ContainerEq(split_string(\";\", ';', false)));\n\n// No trimming\nexp = {\"  val1\", \"val2  \"};\nEXPECT_THAT(exp, ContainerEq(split_string(\"  val1&val2  \", '&', false)));\n}\n\n\nTEST_F(UtilsTests, delete_dir_recursive) {\n  using mysqlrouter::mkdir;\n  std::ofstream ofs;\n  mkdir(\"testdir\", 0700);\n  mkdir(\"testdir/a\", 0700);\n  mkdir(\"testdir/a/b\", 0700);\n  mkdir(\"testdir/a/a\", 0700);\n  std::ofstream().open(\"testdir/f\");\n  std::ofstream().open(\"testdir/f2\");\n  std::ofstream().open(\"testdir/a/f\");\n  std::ofstream().open(\"testdir/a/b/f\");\n  EXPECT_EQ(0, mysql_harness::delete_dir_recursive(\"testdir\"));\n}\n\n\nstatic bool files_equal(const std::string &f1, const std::string &f2) {\n  std::ifstream if1(f1);\n  std::ifstream if2(f2);\n\n  std::istreambuf_iterator<char> s1(if1), s1end;\n  std::istreambuf_iterator<char> s2(if1);\n\n  return std::equal(s1, s1end, s2);\n}\n\n\nTEST_F(UtilsTests, copy_file) {\n  std::ofstream(\"empty.tf\").close();\n  std::ofstream dataf(\"data.tf\");\n  for (int i = 0; i < 2000; i++)\n    dataf << \"somedata\\n\";\n  dataf.close();\n\n  mysqlrouter::copy_file(\"empty.tf\", \"empty.tf2\");\n  mysqlrouter::copy_file(\"data.tf\", \"data.tf2\");\n\n  try\n  {\n    EXPECT_TRUE(files_equal(\"empty.tf\", \"empty.tf2\"));\n    EXPECT_TRUE(files_equal(\"data.tf\", \"data.tf2\"));\n  } catch (...) {\n    mysql_harness::delete_file(\"empty.tf\");\n    mysql_harness::delete_file(\"empty.tf2\");\n    mysql_harness::delete_file(\"data.tf\");\n    mysql_harness::delete_file(\"data.tf2\");\n    throw;\n  }\n  mysql_harness::delete_file(\"empty.tf\");\n  mysql_harness::delete_file(\"empty.tf2\");\n  mysql_harness::delete_file(\"data.tf\");\n  mysql_harness::delete_file(\"data.tf2\");\n}\n\ntemplate <typename FUNC>\nvoid test_int_conv_common(FUNC func) {\n\n  // when func = strtoui_checked(), EXPECT_EQ() throws -Wsign-Compare warnings\n  // because \"66\" is a signed literal. To work around this, we cast the literal\n  // to whatever (signedness) type it needs to be.\n  typedef decltype(func(\"\", 0)) OUT_TYPE;\n  #define EXPECT_EQ2(a,b)  EXPECT_EQ(static_cast<OUT_TYPE>(a), (b))\n\n  // bad input tests\n  EXPECT_EQ2(66, func(\"\", 66));\n  EXPECT_EQ2(66, func(nullptr, 66));\n  EXPECT_EQ2(66, func(\"bad\", 66));\n  EXPECT_EQ2(0,  func(\"bad\", 0));\n\n  // bad input: no sign\n  EXPECT_EQ2(66, func(\"1bad1\", 66));\n  EXPECT_EQ2(66, func(\"12.345\", 66));\n  EXPECT_EQ2(66, func(\"12.0\", 66));\n  EXPECT_EQ2(66, func(\"  12\", 66));\n  EXPECT_EQ2(66, func(\" 12 \", 66));\n  EXPECT_EQ2(66, func(\" 12\", 66));\n  EXPECT_EQ2(66, func(\"12 \", 66));\n  EXPECT_EQ2(66, func(\"1 2\", 66));\n\n  // tabs instead of spaces\n  EXPECT_EQ2(66, func(\"\\t\\t12\", 66));\n  EXPECT_EQ2(66, func(\"\\t12\\t\", 66));\n  EXPECT_EQ2(66, func(\"\\t12\", 66));\n  EXPECT_EQ2(66, func(\"12\\t\", 66));\n  EXPECT_EQ2(66, func(\"1\\t2\", 66));\n\n  // bad input: - sign\n  EXPECT_EQ2(66, func(\"-12.345\", 66));\n  EXPECT_EQ2(66, func(\"-12.0\", 66));\n  EXPECT_EQ2(66, func(\"  -12\", 66));\n  EXPECT_EQ2(66, func(\" -12 \", 66));\n  EXPECT_EQ2(66, func(\" -12\", 66));\n  EXPECT_EQ2(66, func(\"-12 \", 66));\n  EXPECT_EQ2(66, func(\"-1 2\", 66));\n  EXPECT_EQ2(66, func(\"- 12\", 66));\n\n  // bad input: + sign\n  EXPECT_EQ2(66, func(\"+12.345\", 66));\n  EXPECT_EQ2(66, func(\"+12.0\", 66));\n  EXPECT_EQ2(66, func(\"  +12\", 66));\n  EXPECT_EQ2(66, func(\" +12 \", 66));\n  EXPECT_EQ2(66, func(\" +12\", 66));\n  EXPECT_EQ2(66, func(\"+12 \", 66));\n  EXPECT_EQ2(66, func(\"+1 2\", 66));\n  EXPECT_EQ2(66, func(\"+ 12\", 66));\n\n  // bad input: both signs\n  EXPECT_EQ2(66, func(\"-+12\", 66));\n  EXPECT_EQ2(66, func(\"+-12\", 66));\n\n  // verify erno is preserved\n  auto saved_errno = errno;\n  errno = 123;\n  EXPECT_EQ2(12, func(\"12\", 66));\n  EXPECT_EQ2(66, func(\"bad\", 66));\n  EXPECT_EQ(123, errno);\n  errno = saved_errno;\n\n  #undef EXPECT_EQ2\n}\n\nTEST_F(UtilsTests, int_conversion) {\n  using mysqlrouter::strtoi_checked;\n\n  test_int_conv_common(strtoi_checked);\n\n  // range tests: no sign\n  EXPECT_EQ(12, strtoi_checked(\"12\", 66));\n  EXPECT_EQ(66, strtoi_checked(\"66\", 66));\n  EXPECT_EQ(0,  strtoi_checked(\"0\", 66));\n  EXPECT_EQ(INT_MAX, strtoi_checked(std::to_string(INT_MAX).c_str(), 66));\n  EXPECT_EQ(INT_MIN, strtoi_checked(std::to_string(INT_MIN).c_str(), 66));\n  EXPECT_EQ(66, strtoi_checked(std::to_string((long long)INT_MAX + 1).c_str(), 66));\n  EXPECT_EQ(66, strtoi_checked(std::to_string((long long)INT_MIN - 1).c_str(), 66));\n  EXPECT_EQ(66, strtoi_checked(std::to_string(100ll * (long long)INT_MAX).c_str(), 66));\n\n  // - sign\n  EXPECT_EQ(-12, strtoi_checked(\"-12\", 66));\n  EXPECT_EQ(0,   strtoi_checked(\"-0\", 66));\n\n  // extra + sign\n  EXPECT_EQ(12, strtoi_checked(\"+12\", 66));\n  EXPECT_EQ(0,  strtoi_checked(\"+0\", 66));\n}\n\nTEST_F(UtilsTests, uint_conversion) {\n  using mysqlrouter::strtoui_checked;\n\n  test_int_conv_common(strtoui_checked);\n\n  // range tests\n  EXPECT_EQ(12u, strtoui_checked(\"12\", 66));\n  EXPECT_EQ(66u, strtoui_checked(\"66\", 66));\n  EXPECT_EQ(0u,  strtoui_checked(\"0\", 66));\n  EXPECT_EQ(UINT_MAX, strtoui_checked(std::to_string(UINT_MAX).c_str(), 66));\n  EXPECT_EQ(66u, strtoui_checked(std::to_string((long long)UINT_MAX + 1).c_str(), 66));\n  EXPECT_EQ(66u, strtoui_checked(\"-1\", 66));\n  EXPECT_EQ(66u, strtoui_checked(std::to_string(100ll * (long long)UINT_MAX).c_str(), 66));\n\n  // extra + sign\n  EXPECT_EQ(12u, strtoui_checked(\"+12\", 66));\n  EXPECT_EQ(0u,  strtoui_checked(\"+0\", 66));\n}\n\n"
  },
  {
    "path": "src/routing/CMakeLists.txt",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nset(ROUTING_SOURCE_FILES_X_PROTOCOL\n  ${CMAKE_CURRENT_SOURCE_DIR}/src/protocol/x_protocol.cc\n)\n\nset(ROUTING_SOURCE_FILES\n  ${CMAKE_CURRENT_SOURCE_DIR}/src/mysql_routing.cc\n  ${CMAKE_CURRENT_SOURCE_DIR}/src/utils.cc\n  ${CMAKE_CURRENT_SOURCE_DIR}/src/destination.cc\n  ${CMAKE_CURRENT_SOURCE_DIR}/src/dest_metadata_cache.cc\n  ${CMAKE_CURRENT_SOURCE_DIR}/src/dest_first_available.cc\n  ${CMAKE_CURRENT_SOURCE_DIR}/src/dest_next_available.cc\n  ${CMAKE_CURRENT_SOURCE_DIR}/src/dest_round_robin.cc\n  ${CMAKE_CURRENT_SOURCE_DIR}/src/routing.cc\n  ${CMAKE_CURRENT_SOURCE_DIR}/src/protocol/classic_protocol.cc\n  ${CMAKE_CURRENT_SOURCE_DIR}/src/connection.cc\n  ${CMAKE_CURRENT_SOURCE_DIR}/src/context.cc\n  ${CMAKE_CURRENT_SOURCE_DIR}/src/mysql_routing_common.cc\n  ${CMAKE_CURRENT_SOURCE_DIR}/src/connection_container.cc\n  ${ROUTING_SOURCE_FILES_X_PROTOCOL}\n)\n\nset(ROUTING_PLUGIN_SOURCE_FILES\n  ${CMAKE_CURRENT_SOURCE_DIR}/src/routing_plugin.cc\n  ${CMAKE_CURRENT_SOURCE_DIR}/src/plugin_config.cc\n)\n\nset(include_dirs\n  ${PROJECT_SOURCE_DIR}/src/router/include\n  ${PROJECT_SOURCE_DIR}/src/routing/include\n  ${PROJECT_SOURCE_DIR}/src/metadata_cache/include\n  ${PROJECT_SOURCE_DIR}/src/mysql_protocol/include\n  ${PROJECT_SOURCE_DIR}/src/x_protocol/include\n  ${PROTOBUF_INCLUDE_DIR}\n  ${PROJECT_BINARY_DIR}/generated/protobuf\n)\n\n# this file includes protobuf generated header that is causing 'shadow' warning on some compilers\ncheck_cxx_compiler_flag(\"-Wshadow\" CXX_HAVE_SHADOW)\nif(CXX_HAVE_SHADOW)\n  add_compile_flags(${CMAKE_CURRENT_SOURCE_DIR}/src/protocol/x_protocol.cc\n    COMPILE_FLAGS \"-Wno-shadow\")\nendif()\ncheck_cxx_compiler_flag(\"-Wsign-conversion\" CXX_HAVE_SIGN_CONVERSION)\nif(CXX_HAVE_SIGN_CONVERSION)\n  add_compile_flags(${CMAKE_CURRENT_SOURCE_DIR}/src/protocol/x_protocol.cc\n    COMPILE_FLAGS \"-Wno-sign-conversion\")\nendif()\ncheck_cxx_compiler_flag(\"-Wunused-parameter\" CXX_HAVE_UNUSED_PARAMETER)\nif(CXX_HAVE_UNUSED_PARAMETER)\n  add_compile_flags(${CMAKE_CURRENT_SOURCE_DIR}/src/protocol/x_protocol.cc\n    COMPILE_FLAGS \"-Wno-unused-parameter\")\nendif()\ncheck_cxx_compiler_flag(\"-Wdeprecated-declarations\" CXX_HAVE_DEPRECATED_DECLARATIONS)\nif(CXX_HAVE_DEPRECATED_DECLARATIONS)\n  add_compile_flags(${CMAKE_CURRENT_SOURCE_DIR}/src/protocol/x_protocol.cc\n    COMPILE_FLAGS \"-Wno-deprecated-declarations\")\nendif()\n\n# link_directories(${PROJECT_BINARY_DIR}/ext/protobuf/protobuf-3.0.0/cmake/)\n# The Plugin\nadd_harness_plugin(routing\n        SOURCES ${ROUTING_PLUGIN_SOURCE_FILES} ${ROUTING_SOURCE_FILES}\n        REQUIRES mysql_protocol x_protocol metadata_cache)\ntarget_include_directories(routing PRIVATE ${include_dirs})\n\nif(MSVC)\n  add_compile_flags(${PROTO_SRCS} COMPILE_FLAGS \"/wd4018\")\n  add_compile_flags(${ROUTING_SOURCE_FILES_X_PROTOCOL} COMPILE_FLAGS \"/DX_PROTOCOL_DEFINE_DYNAMIC\"\n                    \"/FImysqlrouter/xprotocol.h\")\nelse()\n  add_compile_flags(${ROUTING_SOURCE_FILES_X_PROTOCOL} COMPILE_FLAGS\n                    \"-include mysqlrouter/xprotocol.h\")\nendif(MSVC)\n\ntarget_link_libraries(routing PRIVATE ${PB_LIBRARY})\n\nif(CMAKE_SYSTEM_NAME STREQUAL \"SunOS\")\n  target_link_libraries(routing PRIVATE -lnsl PRIVATE -lsocket)\nendif()\n\n# don't install headers until a) a final destination is found and b) API is stable\n# file(GLOB routing_headers include/mysqlrouter/*.h)\n# install(FILES ${routing_headers}\n#   DESTINATION \"include/mysql/${HARNESS_NAME}\")\n\nif(ENABLE_TESTS)\n  add_subdirectory(tests/)\nendif()\n"
  },
  {
    "path": "src/routing/include/mysqlrouter/routing.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_ROUTING_INCLUDED\n#define MYSQLROUTER_ROUTING_INCLUDED\n\n#include \"socket_operations.h\"\n#include \"tcp_address.h\"\n#include \"mysqlrouter/plugin_config.h\"\n\n#include <map>\n#include <string>\n\n#ifdef _WIN32\n# define WIN32_LEAN_AND_MEAN\n# include <windows.h>\n# include <winsock2.h>\n# include <ws2tcpip.h>\n#else\n# include <poll.h>\n#endif\n\n#ifdef _WIN32\ntypedef ULONG nfds_t;\ntypedef long ssize_t;\n#  define WIN32_LEAN_AND_MEAN\n#  include <winsock2.h>\n#  include <ws2tcpip.h>\n#endif\n\nnamespace routing {\n\n/** @brief Timeout for idling clients (in seconds)\n *\n * Constant defining how long (in seconds) a client can keep the connection idling. This is similar to the\n * wait_timeout variable in the MySQL Server.\n */\nextern const int kDefaultWaitTimeout;\n\n/** @brief Max number of active routes for this routing instance */\nextern const int kDefaultMaxConnections;\n\n/** @brief Timeout connecting to destination (in seconds)\n *\n * Constant defining how long we wait to establish connection with the server before we give up.\n */\nextern const std::chrono::seconds kDefaultDestinationConnectionTimeout;\n\n/** @brief Maximum connect or handshake errors per host\n *\n * Maximum connect or handshake errors after which a host will be\n * blocked. Such errors can happen when the client does not reply\n * the handshake, sends an incorrect packet, or garbage.\n *\n */\nextern const unsigned long long kDefaultMaxConnectErrors;\n\n/** @brief Maximum connect or handshake errors per host\n *\n * Maximum connect or handshake errors after which a host will be\n * blocked. Such errors can happen when the client does not reply\n * the handshake, sends an incorrect packet, or garbage.\n *\n */\nextern const unsigned long long kDefaultMaxConnectErrors;\n\n/** @brief Default bind address\n *\n */\nextern const std::string kDefaultBindAddress;\n\n/** @brief Default net buffer length\n *\n * Default network buffer length which can be set in the MySQL Server.\n *\n * This should match the default of the latest MySQL Server.\n */\nextern const unsigned int kDefaultNetBufferLength;\n\n/** @brief Timeout waiting for handshake response from client\n *\n * The number of seconds that MySQL Router waits for a handshake response.\n * The default value is 9 seconds (default MySQL Server minus 1).\n *\n */\nextern const std::chrono::seconds kDefaultClientConnectTimeout;\n\n#ifdef _WIN32\n  const SOCKET kInvalidSocket = INVALID_SOCKET;// windows defines INVALID_SOCKET already\n#else\n  const int kInvalidSocket = -1;\n#endif\n\n\n/** @brief Modes supported by Routing plugin */\nenum class AccessMode {\n  kUndefined = 0,\n  kReadWrite = 1,\n  kReadOnly = 2,\n};\n\n/** @brief Routing strategies supported by Routing plugin */\nenum class RoutingStrategy {\n  kUndefined = 0,\n  kFirstAvailable = 1,\n  kNextAvailable = 2,\n  kRoundRobin = 3,\n  kRoundRobinWithFallback = 4,\n};\n\n/** @brief Get comma separated list of all access mode names\n *\n */\nstd::string get_access_mode_names();\n\n/** @brief Returns AccessMode for its literal representation\n *\n * If no AccessMode is found for given string,\n * AccessMode::kUndefined is returned.\n *\n * @param value literal representation of the access mode\n * @return AccessMode for the given string or AccessMode::kUndefined\n */\nAccessMode get_access_mode(const std::string& value);\n\n/** @brief Returns literal name of given access mode\n *\n * Returns literal name of given access mode as a std:string. When\n * the access mode is not found, empty string is returned.\n *\n * @param access_mode Access mode to look up\n * @return Name of access mode as std::string or empty string\n */\nstd::string get_access_mode_name(AccessMode access_mode) noexcept;\n\n/** @brief Get comma separated list of all routing stategy names\n *         for a given routing type (metadata cache or static)\n *\n *\n * @param metadata_cache bool flag indicating if the list should contain\n *                       strategies supported for metadata_cache\n *                        or static routing\n */\nstd::string get_routing_strategy_names(bool metadata_cache);\n\n/** @brief Returns RoutingStrategy for its literal representation\n *\n * If no RoutingStrategy is found for given string,\n * RoutingStrategy::kUndefined is returned.\n *\n * @param value literal representation of the access mode\n * @return RoutingStrategy for the given string or RoutingStrategy::kUndefined\n */\nRoutingStrategy get_routing_strategy(const std::string& value);\n\n/** @brief Returns literal name of given routing strategy\n *\n * Returns literal name of given routing strategy as a std:string. When\n * the routing strategy is not found, empty string is returned.\n *\n * @param routing_strategy Routing strategy to look up\n * @return Name of routing strategy as std::string or empty string\n */\nstd::string get_routing_strategy_name(RoutingStrategy routing_strategy) noexcept;\n\n/**\n * Sets blocking flag for given socket\n *\n * @param sock a socket file descriptor\n * @param blocking whether to set blocking off (false) or on (true)\n */\nvoid set_socket_blocking(int sock, bool blocking);\n\n\n/** @class RoutingSockOpsInterface\n * @brief Interface class to allow multiple RoutingSockOps implementations\n *        (at least one \"real\" and one mock for testing purposes)\n */\nclass RoutingSockOpsInterface {\n public:\n  virtual ~RoutingSockOpsInterface() = default;\n  virtual int get_mysql_socket(mysql_harness::TCPAddress addr, std::chrono::milliseconds connect_timeout_ms, bool log = true) noexcept = 0;\n  virtual mysql_harness::SocketOperationsBase* so() const = 0;\n};\n\n/** @class RoutingSockOps\n * @brief This class provides a \"real\" (not mock) implementation\n */\nclass RoutingSockOps : public RoutingSockOpsInterface {\n public:\n  RoutingSockOps(mysql_harness::SocketOperationsBase* sock_ops) : so_(sock_ops) {}\n\n  static RoutingSockOps* instance(mysql_harness::SocketOperationsBase* sock_ops);\n\n  /** @brief Returns socket descriptor of connected MySQL server\n   *\n   * Iterates through all available connections (until it succesfully connects)\n   * to the selected address as returned by getaddrinfo()\n   * (see its documentation for the details).\n   * If it's not able to connect via any path, it returns value < 0.\n   *\n   * Returns a socket descriptor for the connection to the MySQL Server or\n   * negative value when error occurred:\n   *  -2 - if connection timeout has expired for at least one of the attempted paths\n   *  -1 - in case of any other error\n   *\n   * @param addr information of the server we connect with\n   * @param connect_timeout timeout waiting for connection\n   * @param log whether to log errors or not\n   * @return a socket descriptor\n   */\n  int get_mysql_socket(mysql_harness::TCPAddress addr, std::chrono::milliseconds connect_timeout, bool log = true) noexcept override;\n\n  /** @brief Returns SocketOperations implementation used by this class */\n  mysql_harness::SocketOperationsBase* so() const override { return so_; }\n\n private:\n  RoutingSockOps() = default;\n  RoutingSockOps(const RoutingSockOps&) = delete;\n  RoutingSockOps operator=(const RoutingSockOps&) = delete;\n\n  mysql_harness::SocketOperationsBase* so_;\n};\n\n} // namespace routing\n\n#endif // MYSQLROUTER_ROUTING_INCLUDED\n"
  },
  {
    "path": "src/routing/src/connection.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <cstring>\n#include <string>\n\n#include \"common.h\"\n#include \"connection.h\"\n#include \"mysql_router_thread.h\"\n#include \"mysql_routing_common.h\"\n#include \"mysql/harness/loader.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysqlrouter/routing.h\"\n#include \"utils.h\"\nIMPORT_LOG_FUNCTIONS()\n\nMySQLRoutingConnection ::MySQLRoutingConnection(MySQLRoutingContext& context, int client_socket,\n    const sockaddr_storage& client_addr, int server_socket,\n    const mysql_harness::TCPAddress& server_address,\n    std::function<void(MySQLRoutingConnection*)> remove_callback) :\n  context_(context),\n  remove_callback_(remove_callback),\n  client_socket_(client_socket),\n  client_addr_(client_addr),\n  server_socket_(server_socket),\n  server_address_(server_address),\n  client_address_(make_client_address(client_socket, context)){\n}\n\nvoid MySQLRoutingConnection::start(bool detached) {\n  try {\n    // both lines can throw std::runtime_error\n    mysql_harness::MySQLRouterThread connect_thread(context_.get_thread_stack_size());\n    connect_thread.run(&run_thread, this, detached);\n  } catch(std::runtime_error& err) {\n    context_.get_protocol().send_error(client_socket_, 1040,\n                          \"Router couldn't spawn a new thread to service new client connection\",\n                          \"HY000\", context_.get_name());\n    context_.get_socket_operations()->close(client_socket_); // no shutdown() before close()\n\n    // we only want to log this message once, because in a low-resource situation, this would\n    // lead do a DoS against ourselves (heavy I/O and disk full)\n    static bool logged_this_before = false;\n    if (!logged_this_before) {\n      logged_this_before = true;\n      log_error(\"Couldn't spawn a new thread to service new client connection from %s.\"\n                \" This message will not be logged again until Router restarts, error=%s\",\n                get_peer_name(client_socket_).first.c_str(), err.what());\n    }\n  }\n}\n\nvoid* MySQLRoutingConnection::run_thread(void* context) {\n  MySQLRoutingConnection* connection(static_cast<MySQLRoutingConnection*>(context));\n  connection->run();\n  return nullptr;\n}\n\nbool MySQLRoutingConnection::check_sockets() {\n  if ((server_socket_ == routing::kInvalidSocket) ||\n      (client_socket_ == routing::kInvalidSocket)) {\n    std::stringstream os;\n    os << \"Can't connect to remote MySQL server for client connected to '\"\n      << context_.get_bind_address().addr << \":\" << context_.get_bind_address().port << \"'\";\n\n    log_warning(\"[%s] fd=%d %s\", context_.get_name().c_str(), client_socket_, os.str().c_str());\n\n    // at this point, it does not matter whether client gets the error\n    context_.get_protocol().send_error(client_socket_, 2003, os.str(), \"HY000\", context_.get_name());\n\n    if (client_socket_ != routing::kInvalidSocket) context_.get_socket_operations()->shutdown(client_socket_);\n    if (server_socket_ != routing::kInvalidSocket) context_.get_socket_operations()->shutdown(server_socket_);\n\n    if (client_socket_ != routing::kInvalidSocket) {\n      context_.get_socket_operations()->close(client_socket_);\n    }\n    if (server_socket_ != routing::kInvalidSocket) {\n      context_.get_socket_operations()->close(server_socket_);\n    }\n    return false;\n  }\n\n  return true;\n}\n\nvoid MySQLRoutingConnection::run() {\n  mysql_harness::rename_thread(get_routing_thread_name(context_.get_name(), \"RtC\").c_str());  // \"Rt client thread\" would be too long :(\n\n  context_.increase_active_thread_counter();\n  std::shared_ptr<void> thread_exit_guard(nullptr, [&](void *){\n    context_.decrease_active_thread_counter();\n\n    // remove callback has to be executed as a last thing in connection\n    remove_callback_(this);\n  });\n\n  std::size_t bytes_down = 0;\n  std::size_t bytes_up = 0;\n  std::size_t bytes_read = 0;\n  std::string extra_msg = \"\";\n  RoutingProtocolBuffer buffer(context_.get_net_buffer_length());\n  bool handshake_done = false;\n\n  if (!check_sockets()) {\n    return;\n  }\n\n  std::pair<std::string, int> c_ip = get_peer_name(client_socket_);\n  std::pair<std::string, int> s_ip = get_peer_name(server_socket_);\n\n  if (c_ip.second == 0) {\n    // Unix socket/Windows Named pipe\n    log_debug(\"[%s] fd=%d connected %s -> %s:%d as fd=%d\",\n        context_.get_name().c_str(),\n        client_socket_,\n        context_.get_bind_named_socket().c_str(),\n        s_ip.first.c_str(), s_ip.second,\n        server_socket_);\n  } else {\n    log_debug(\"[%s] fd=%d connected %s:%d -> %s:%d as fd=%d\",\n        context_.get_name().c_str(),\n        client_socket_,\n        c_ip.first.c_str(), c_ip.second,\n        s_ip.first.c_str(), s_ip.second,\n        server_socket_);\n  }\n\n  context_.increase_info_active_routes();\n  context_.increase_info_handled_routes();\n\n  int pktnr = 0;\n\n  bool connection_is_ok = true;\n  while (connection_is_ok && !disconnect_) {\n    const size_t kClientEventIndex = 0;\n    const size_t kServerEventIndex = 1;\n\n    struct pollfd fds[] = {\n      { routing::kInvalidSocket, POLLIN, 0 },\n      { routing::kInvalidSocket, POLLIN, 0 },\n    };\n\n    fds[kClientEventIndex].fd = client_socket_;\n    fds[kServerEventIndex].fd = server_socket_;\n\n    const std::chrono::milliseconds poll_timeout_ms =\n        handshake_done ? std::chrono::milliseconds(1000)\n                       : context_.get_client_connect_timeout();\n    int res = context_.get_socket_operations()->poll(fds, sizeof(fds) / sizeof(fds[0]), poll_timeout_ms);\n\n    if (res < 0) {\n      const int last_errno = context_.get_socket_operations()->get_errno();\n      switch (last_errno) {\n        case EINTR:\n        case EAGAIN:\n          // got interrupted. Just retry\n          break;\n        default:\n          // break the loop, something ugly happened\n          connection_is_ok = false;\n          extra_msg = std::string(\"poll() failed: \" + mysqlrouter::to_string(get_message_error(last_errno)));\n          break;\n      }\n\n      continue;\n    } else if (res == 0) {\n      // timeout\n      if (!handshake_done) {\n        connection_is_ok = false;\n        extra_msg = std::string(\"client auth timed out\");\n\n        break;\n      } else {\n        continue;\n      }\n    }\n\n    // something happened on the socket: either we have data or the socket was closed.\n    //\n    // closed sockets are signalled in two ways:\n    //\n    // * Linux: POLLIN + read() == 0\n    // * Windows: POLLHUP\n\n    const bool client_is_readable = (fds[kClientEventIndex].revents & (POLLIN|POLLHUP)) != 0;\n    const bool server_is_readable = (fds[kServerEventIndex].revents & (POLLIN|POLLHUP)) != 0;\n\n    // Handle traffic from Server to Client\n    // Note: In classic protocol Server _always_ talks first\n    if (context_.get_protocol().copy_packets(server_socket_, client_socket_, server_is_readable,\n                                             buffer, &pktnr, handshake_done, &bytes_read, true) == -1) {\n      const int last_errno = context_.get_socket_operations()->get_errno();\n      if (last_errno > 0) {\n        // if read() against closed socket, errno will be 0. Don't log that.\n        extra_msg = std::string(\"Copy server->client failed: \" + mysqlrouter::to_string(get_message_error(last_errno)));\n      }\n\n      connection_is_ok = false;\n    } else {\n      bytes_up += bytes_read;\n    }\n\n    // Handle traffic from Client to Server\n    if (context_.get_protocol().copy_packets(client_socket_, server_socket_, client_is_readable,\n                                             buffer, &pktnr, handshake_done, &bytes_read, false) == -1) {\n      const int last_errno = context_.get_socket_operations()->get_errno();\n      if (last_errno > 0) {\n        extra_msg = std::string(\"Copy client->server failed: \" + mysqlrouter::to_string(get_message_error(last_errno)));\n      } else if (!handshake_done) {\n        extra_msg = std::string(\"Copy client->server failed: unexpected connection close\");\n      }\n      // client close on us.\n      connection_is_ok = false;\n    } else {\n      bytes_down += bytes_read;\n    }\n\n  } // while (connection_is_ok && !disconnect_.load())\n\n  if (!handshake_done) {\n    log_info(\"[%s] fd=%d Pre-auth socket failure %s: %s\",\n        context_.get_name().c_str(),\n        client_socket_,\n        c_ip.first.c_str(), extra_msg.c_str());\n     auto ip_array = in_addr_to_array(client_addr_);\n     context_.block_client_host(ip_array, c_ip.first.c_str(), server_socket_);\n  }\n\n  // Either client or server terminated\n  context_.get_socket_operations()->shutdown(client_socket_);\n  context_.get_socket_operations()->shutdown(server_socket_);\n  context_.get_socket_operations()->close(client_socket_);\n  context_.get_socket_operations()->close(server_socket_);\n\n  context_.decrease_info_active_routes();\n#ifndef _WIN32\n  log_debug(\"[%s] fd=%d connection closed (up: %zub; down: %zub) %s\",\n      context_.get_name().c_str(),\n      client_socket_, bytes_up, bytes_down, extra_msg.c_str());\n#else\n  log_debug(\"[%s] fd=%d connection closed (up: %Iub; down: %Iub) %s\",\n      context_.get_name().c_str(),\n      client_socket_, bytes_up, bytes_down, extra_msg.c_str());\n#endif\n}\n\nvoid MySQLRoutingConnection::disconnect() noexcept {\n  disconnect_ = true;\n}\n\nconst mysql_harness::TCPAddress& MySQLRoutingConnection::get_server_address() const noexcept {\n  return server_address_;\n}\n\nconst std::string& MySQLRoutingConnection::get_client_address() const {\n  return client_address_;\n}\n\nstd::string MySQLRoutingConnection::make_client_address(int client_socket, const MySQLRoutingContext& context) {\n  std::pair<std::string, int> c_ip = get_peer_name(client_socket);\n\n  if (c_ip.second == 0) {\n    // Unix socket/Windows Named pipe\n    return context.get_bind_named_socket().c_str();\n  } else {\n    std::ostringstream oss;\n    oss << c_ip.first.c_str() << \":\" << c_ip.second;\n    return oss.str();\n  }\n}\n"
  },
  {
    "path": "src/routing/src/connection.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef ROUTING_CONNECTION_INCLUDED\n#define ROUTING_CONNECTION_INCLUDED\n\n#include <atomic>\n#include <chrono>\n#include <condition_variable>\n#include <mutex>\n\n#include \"context.h\"\n#include \"mysql_router_thread.h\"\n#include \"protocol/base_protocol.h\"\n#include \"tcp_address.h\"\n\n\nclass MySQLRouting;\nclass MySQLRoutingContext;\n\nnamespace mysql_harness { class PluginFuncEnv; }\n\n/**\n * @brief MySQLRoutingConnection represents a connection to MYSQL Server.\n *\n * The MySQLRoutingConnection wraps thread that handles traffic from one socket\n * to another.\n *\n * When instance of MySQLRoutingConnection object is created, remove callback\n * is passed, which is called when connection thread completes.\n */\nclass MySQLRoutingConnection {\n\npublic:\n\n  /**\n   * @brief Creates and initializes connection object. It doesn't create\n   *        new thread of execution. In order to create new thread of\n   *        execution call start().\n   *\n   * @param context wrapper for common data used by all connection threads\n   * @param client_socket socket used to send/receive data to/from client\n   * @param client_addr address of the socket used to send/receive data to/from client\n   * @param server_socket socket used to send/receive data to/from server\n   * @param server_address IP address and TCP port of MySQL Server\n   * @param remove_callback called when thread finishes its execution to remove\n   *        associated MySQLRoutingConnection from container. It must be called\n   *        at the very end of thread execution\n   */\n  MySQLRoutingConnection(MySQLRoutingContext& context,\n      int client_socket,\n      const sockaddr_storage& client_addr,\n      int server_socket,\n      const mysql_harness::TCPAddress& server_address,\n      std::function<void(MySQLRoutingConnection*)> remove_callback);\n\n  /**\n   * @brief Verify if client socket and server socket are valid.\n   *\n   * @return true if both client socket and server socket are valid, false otherwise\n   */\n  bool check_sockets();\n\n  /**\n   * @brief creates new thread of execution which calls run()\n   *\n   * @param detached true if start() should not block until run thread is completed,\n   *                 false otherwise\n   */\n  void start(bool detached = true);\n\n  /** @brief Worker function for thread\n   *\n   * Worker function handling incoming connection from a MySQL client using\n   * the poll-method.\n   *\n   * Errors are logged.\n   *\n   */\n  void run();\n\n  /**\n   * @brief mark connection to disconnect as soon as possible\n   */\n  void disconnect() noexcept;\n\n  /**\n   * @brief Returns address of server to which connection is established.\n   *\n   * @return address of server\n   */\n  const mysql_harness::TCPAddress& get_server_address() const noexcept;\n\n  /**\n   * @brief Returns address of client which connected to router\n   *\n   * @return address of client\n   */\n  const std::string& get_client_address() const;\n\nprivate:\n\n  /** @brief wrapper for common data used by all routing threads */\n  MySQLRoutingContext& context_;\n  /** @brief callback that is called when thread of execution completes */\n  std::function<void(MySQLRoutingConnection*)> remove_callback_;\n  /** @brief socket used to communicate with client */\n  int client_socket_;\n  /** @brief client's address */\n  const sockaddr_storage client_addr_;\n  /** @brief socket used to communicate with server */\n  int server_socket_;\n  mysql_harness::TCPAddress server_address_;\n  /** @brief true if connection should be disconnected */\n  std::atomic<bool> disconnect_{false};\n  /** @brief address of the client */\n  std::string client_address_;\n  /** @brief run client thread which will service this new connection */\n  static void* run_thread(void* context);\n  /** @brief make address of client */\n  static std::string make_client_address(int client_socket, const MySQLRoutingContext& context);\n};\n\n#endif /* ROUTING_CONNECTION_INCLUDED */\n"
  },
  {
    "path": "src/routing/src/connection_container.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"connection_container.h\"\n#include \"mysql/harness/logging/logging.h\"\n\nIMPORT_LOG_FUNCTIONS()\n\nvoid ConnectionContainer::add_connection(\n    std::unique_ptr<MySQLRoutingConnection> connection) {\n  connections_.put(connection.get(), std::move(connection));\n}\n\nvoid ConnectionContainer::disconnect(const AllowedNodes& nodes) {\n  unsigned number_of_disconnected_connections = 0;\n\n  auto mark_to_diconnect_if_not_allowed =\n      [&nodes, &number_of_disconnected_connections](std::pair<MySQLRoutingConnection* const,\n                                                    std::unique_ptr<MySQLRoutingConnection>>& connection) {\n    const auto& server_address = connection.first->get_server_address();\n    const std::string& client_address = connection.first->get_client_address();\n    if (std::find(nodes.begin(), nodes.end(), server_address) == nodes.end()) {\n      log_info(\"Disconnecting client %s from server %s\", client_address.c_str(), server_address.str().c_str());\n      connection.first->disconnect();\n      ++number_of_disconnected_connections;\n    }\n  };\n\n  connections_.for_each(mark_to_diconnect_if_not_allowed);\n  if (number_of_disconnected_connections > 0)\n    log_info(\"Disconnected %u connections\", number_of_disconnected_connections);\n}\n\nvoid ConnectionContainer::disconnect_all() {\n  auto mark_to_disconnect =\n      [](std::pair<MySQLRoutingConnection* const, std::unique_ptr<MySQLRoutingConnection>>& connection) {\n    connection.first->disconnect();\n  };\n\n  connections_.for_each(mark_to_disconnect);\n}\n\nvoid ConnectionContainer::remove_connection(\n    MySQLRoutingConnection* connection) {\n  connections_.erase(connection);\n}\n"
  },
  {
    "path": "src/routing/src/connection_container.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef ROUTING_CONNECTION_CONTAINER_INCLUDED\n#define ROUTING_CONNECTION_CONTAINER_INCLUDED\n\n#include <algorithm>\n#include <functional>\n#include <map>\n#include <memory>\n#include <mutex>\n#include <vector>\n\n#include \"connection.h\"\n#include \"destination.h\"\n#include \"mysql_routing_common.h\"\n#include \"mysqlrouter/datatypes.h\"\n#include \"tcp_address.h\"\n\nclass MySQLRoutingConnection;\n\n/**\n * @brief Basic Concurrent Map\n *\n * The concurrent_map is a hash-map, with fixed number of buckets.\n * The numer of buckets can be specified in constructor parameter\n * (num_buckets), by default is set to 23.\n */\ntemplate<typename Key, typename Value, typename Hash = std::hash<Key>>\nclass concurrent_map {\n\npublic:\n  using key_type = Key;\n  using mapped_type = Value;\n  using hash_type = Hash;\n\n  concurrent_map(unsigned num_buckets = kDefaultNumberOfBucket, const Hash& hasher = Hash()) :\n      buckets_(num_buckets), hasher_(hasher) {\n  }\n\n  concurrent_map(const concurrent_map& other) = delete;\n  concurrent_map& operator=(const concurrent_map& other) = delete;\n\n  template<typename Predicate>\n  void for_one(const Key& key, Predicate& p) {\n    get_bucket(key).for_one(key, p);\n  }\n\n  template<typename Predicate>\n  void for_each(Predicate& p) {\n    for(auto& each_bucket : buckets_) {\n      each_bucket.for_each(p);\n    }\n  }\n\n  void put(const Key& key, Value&& value) {\n    get_bucket(key).put(key, std::move(value));\n  }\n\n  void erase(const Key& key) {\n    get_bucket(key).erase(key);\n  }\n\n  std::size_t size() const {\n    std::size_t result{0};\n    for(auto& each_bucket : buckets_) {\n      result += each_bucket.size();\n    }\n    return result;\n  }\n\nprivate:\n  static const unsigned kDefaultNumberOfBucket = 127;\n\n  class Bucket {\n\n  public:\n    void put(const Key& key, Value&& value) {\n      std::lock_guard<std::mutex> lock(data_mutex_);\n      data_.emplace(key, std::move(value));\n    }\n\n    void erase(const Key& key) {\n      std::lock_guard<std::mutex> lock(data_mutex_);\n      data_.erase(key);\n    }\n\n    template<typename Predicate>\n    void for_one(const Key& key, Predicate& p) {\n      std::lock_guard<std::mutex> lock(data_mutex_);\n      const ConstBucketIterator found = data_.find(key);\n      if (found != data_.end())\n        p(found->second);\n    }\n\n    template<typename Predicate>\n    void for_each(Predicate& p) {\n      std::lock_guard<std::mutex> lock(data_mutex_);\n      std::for_each(data_.begin(), data_.end(), p);\n    }\n\n    std::size_t size() const {\n      std::lock_guard<std::mutex> lock(data_mutex_);\n      return data_.size();\n    }\n\n  private:\n\n    using BucketData = std::map<Key, Value>;\n    using BucketIterator = typename BucketData::iterator;\n    using ConstBucketIterator = typename BucketData::const_iterator;\n\n    BucketData data_;\n    mutable std::mutex data_mutex_;\n  };\n\n  std::vector<Bucket> buckets_;\n  Hash hasher_;\n\n  Bucket& get_bucket(const Key& key) {\n    const std::size_t bucket_index = hasher_(key) % buckets_.size();\n    return buckets_[bucket_index];\n  }\n\n  const Bucket& get_bucket(const Key& key) const {\n    const std::size_t bucket_index = hasher_(key) % buckets_.size();\n    return buckets_[bucket_index];\n  }\n};\n\n\n/**\n * @brief container for connections to MySQL Server.\n *\n * When thread of execution for connection to MySQL Server is completed, it should\n * call remove_connection to remove itself from connection container.\n */\nclass ConnectionContainer {\n  concurrent_map<MySQLRoutingConnection*, std::unique_ptr<MySQLRoutingConnection>> connections_;\n\npublic:\n\n  /**\n   * @brief Adds new connection to container.\n   *\n   * @param connection The connection to MySQL server\n   */\n  void add_connection(std::unique_ptr<MySQLRoutingConnection> connection);\n\n  /**\n   * @brief Disconnects all connections to servers that are not allowed any longer.\n   *\n   * @param nodes Allowed servers. Connections to servers that are not in nodes\n   *        are closed.\n   */\n  void disconnect(const AllowedNodes& nodes);\n\n  /**\n   * @brief Disconnects all connection in the ConnectionContainer.\n   */\n  void disconnect_all();\n\n  /**\n   * @brief removes connection from container\n   *\n   * This function should be called by thread of execution when connection thread completes.\n   * Do NOT call this function before connection's thread of execution completes.\n   *\n   * @param connection The connection to remove from container\n   */\n  void remove_connection(MySQLRoutingConnection* connection);\n};\n\n#endif /* ROUTING_CONNECTION_CONTAINER_INCLUDED */\n"
  },
  {
    "path": "src/routing/src/context.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n\n#include <cstring>\n#include \"context.h\"\n\n#include \"mysqlrouter/routing.h\"\n#include \"utils.h\"\n#include \"common.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"protocol/base_protocol.h\"\n#include <memory>\n\nIMPORT_LOG_FUNCTIONS()\n\n\nMySQLRoutingContext ::MySQLRoutingContext(BaseProtocol* protocol,\n    mysql_harness::SocketOperationsBase* socket_operations,\n    const std::string& name, unsigned int net_buffer_length,\n    std::chrono::milliseconds destination_connect_timeout,\n    std::chrono::milliseconds client_connect_timeout,\n    const mysql_harness::TCPAddress& bind_address,\n    const mysql_harness::Path& bind_named_socket,\n    unsigned long long max_connect_errors, size_t thread_stack_size) :\n  protocol_(protocol),\n  socket_operations_(socket_operations),\n  name_(name),\n  net_buffer_length_(net_buffer_length),\n  destination_connect_timeout_(destination_connect_timeout),\n  client_connect_timeout_(client_connect_timeout),\n  bind_address_(bind_address),\n  bind_named_socket_(bind_named_socket),\n  thread_stack_size_(thread_stack_size),\n  max_connect_errors_(max_connect_errors) {\n\n}\n\nbool MySQLRoutingContext::block_client_host(const ClientIpArray& client_ip_array,\n    const std::string &client_ip_str, int server) {\n  bool blocked = false;\n  {\n    std::lock_guard<std::mutex> lock(mutex_conn_errors_);\n\n    if (++conn_error_counters_[client_ip_array] >= max_connect_errors_) {\n      log_warning(\"[%s] blocking client host %s\", name_.c_str(), client_ip_str.c_str());\n      blocked = true;\n    } else {\n      log_info(\"[%s] %lu connection errors for %s (max %llu)\", name_.c_str(),\n               static_cast<unsigned long>(conn_error_counters_[client_ip_array]), // 32bit Linux requires cast\n               client_ip_str.c_str(), max_connect_errors_);\n    }\n  }\n\n  if (server >= 0) {\n    protocol_->on_block_client_host(server, name_);\n  }\n\n  return blocked;\n}\n\nconst std::vector<ClientIpArray> MySQLRoutingContext::get_blocked_client_hosts() const {\n  std::lock_guard<std::mutex> lock(mutex_conn_errors_);\n\n  std::vector<ClientIpArray> result;\n  for(const auto& client_ip: conn_error_counters_) {\n    if (client_ip.second >= max_connect_errors_) {\n      result.push_back(client_ip.first);\n    }\n  }\n\n  return result;\n}\n\nvoid MySQLRoutingContext::increase_active_thread_counter() {\n  {\n    std::lock_guard<std::mutex> lk(active_client_threads_cond_m_);\n    active_client_threads_++;\n  }\n  active_client_threads_cond_.notify_all();\n}\n\nvoid MySQLRoutingContext::decrease_active_thread_counter() {\n  {\n    std::lock_guard<std::mutex> lk(active_client_threads_cond_m_);\n    active_client_threads_--;\n  }\n  // notify the parent while we have the cond_mutex locked\n  // otherwise the parent may destruct before we are finished.\n  active_client_threads_cond_.notify_all();\n}\n\nvoid MySQLRoutingContext::increase_info_active_routes() {\n  ++info_active_routes_;\n}\n\nvoid MySQLRoutingContext::decrease_info_active_routes() {\n  --info_active_routes_;\n}\n\nvoid MySQLRoutingContext::increase_info_handled_routes() {\n  ++info_handled_routes_;\n}\n"
  },
  {
    "path": "src/routing/src/context.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n\n#ifndef ROUTING_CONTEXT_INCLUDED\n#define ROUTING_CONTEXT_INCLUDED\n\n#include <memory>\n#include <chrono>\n#include <map>\n#include <array>\n#include <mutex>\n#include <vector>\n#include <condition_variable>\n#include <atomic>\n\n#include \"mysqlrouter/routing.h\"\n#include \"mysqlrouter/datatypes.h\"\n#include \"mysql_router_thread.h\"\n#include \"tcp_address.h\"\n#include \"mysql/harness/filesystem.h\"\n#include \"utils.h\"\n\nclass BaseProtocol;\nnamespace routing { class RoutingSockOpsInterface; }\nnamespace mysql_harness { class SocketOperationsBase; }\n\n/**\n * @brief MySQLRoutingContext holds data used by MySQLRouting (1 per plugin instances)\n * and MySQLRoutingConnection instances (many instances). It is created and owned by\n * MySQLRouting while MySQLRoutingConnection objects hold reference to it.\n */\nclass MySQLRoutingContext {\n\npublic:\n  MySQLRoutingContext(BaseProtocol* protocol,\n      mysql_harness::SocketOperationsBase* socket_operations,\n      const std::string& name, unsigned int net_buffer_length,\n      std::chrono::milliseconds destination_connect_timeout,\n      std::chrono::milliseconds client_connect_timeout,\n      const mysql_harness::TCPAddress& bind_address,\n      const mysql_harness::Path& bind_named_socket,\n      unsigned long long max_connect_errors, size_t thread_stack_size);\n\n  /** @brief Checks and if needed, blocks a host from using this routing\n   *\n   * Blocks a host from using this routing adding its IP address to the\n   * list of blocked hosts when the maximum client errors has been\n   * reached. Each call of this function will increment the number of\n   * times it was called with the client IP address.\n   *\n   * When a client host is actually blocked, true will be returned,\n   * otherwise false.\n   *\n   * @param client_ip_array IP address as array[16] of uint8_t\n   * @param client_ip_str IP address as string (for logging purposes)\n   * @param server Server file descriptor to wish to send\n   *               fake handshake reply (default is not to send anything)\n   * @return bool\n   */\n  bool block_client_host(const ClientIpArray& client_ip_array,\n                         const std::string &client_ip_str, int server = -1);\n\n  /** @brief Returns list of blocked client hosts\n   *\n   * Returns list of the blocked client hosts.\n   */\n  const std::vector<ClientIpArray> get_blocked_client_hosts() const;\n\n  void increase_active_thread_counter();\n  void decrease_active_thread_counter();\n  void increase_info_active_routes();\n  void decrease_info_active_routes();\n  void increase_info_handled_routes();\n\n  mysql_harness::SocketOperationsBase* get_socket_operations() {\n    return socket_operations_;\n  }\n\n  BaseProtocol& get_protocol() {\n    return *protocol_;\n  }\n\n  const std::string& get_name() const {\n    return name_;\n  }\n\n  unsigned int get_net_buffer_length() const {\n    return net_buffer_length_;\n  }\n\n  std::chrono::milliseconds get_destination_connect_timeout() const {\n    return destination_connect_timeout_;\n  }\n\n  std::chrono::milliseconds get_client_connect_timeout() const {\n    return client_connect_timeout_;\n  }\n\n  const mysql_harness::TCPAddress& get_bind_address() const {\n    return bind_address_;\n  }\n\n  const mysql_harness::Path& get_bind_named_socket() const {\n    return bind_named_socket_;\n  }\n\n  size_t get_thread_stack_size() const {\n    return thread_stack_size_;\n  }\n\nprivate:\n  /** @brief object to handle protocol specific stuff */\n  std::unique_ptr<BaseProtocol> protocol_;\n\n  /** @brief object handling the operations on network sockets */\n  mysql_harness::SocketOperationsBase* socket_operations_;\n\n  /** @brief Descriptive name of the connection routing */\n  const std::string name_;\n\n  /** @brief Size of buffer to store receiving packets */\n  unsigned int net_buffer_length_;\n\n  /** @brief Timeout connecting to destination\n   *\n   * This timeout is used when trying to connect with a destination\n   * server. When the timeout is reached, another server will be\n   * tried. It is good to leave this time out 1 second or higher\n   * if using an unstable network.\n   */\n  std::chrono::milliseconds destination_connect_timeout_;\n\n  /** @brief Timeout waiting for handshake response from client */\n  std::chrono::milliseconds client_connect_timeout_;\n\n  /** @brief IP address and TCP port for setting up TCP service */\n  const mysql_harness::TCPAddress bind_address_;\n\n  /** @brief Path to named socket for setting up named socket service */\n  const mysql_harness::Path bind_named_socket_;\n\n    /** @brief memory in kilobytes allocated for thread's stack */\n  size_t thread_stack_size_ = mysql_harness::kDefaultStackSizeInKiloBytes;\n\n  mutable std::mutex mutex_conn_errors_;\n\npublic:\n  /** @brief Connection error counters for IPv4 or IPv6 hosts */\n  std::map<ClientIpArray, size_t> conn_error_counters_;\n\n  /** @brief Max connect errors blocking hosts when handshake not completed */\n  unsigned long long max_connect_errors_;\n\n  /** number of active client threads. */\n  uint64_t active_client_threads_ {0};\n  std::condition_variable active_client_threads_cond_;\n  std::mutex active_client_threads_cond_m_;\n\n  /** @brief Number of active routes */\n  std::atomic<uint16_t> info_active_routes_{0};\n  /** @brief Number of handled routes, not used at the moment */\n  std::atomic<uint64_t> info_handled_routes_{0};\n};\n#endif /* ROUTING_CONTEXT_INCLUDED */\n"
  },
  {
    "path": "src/routing/src/dest_first_available.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"dest_first_available.h\"\n#include \"mysql/harness/logging/logging.h\"\n\n#ifdef _WIN32\n#  define WIN32_LEAN_AND_MEAN\n#  include <windows.h>\n#  include <winsock2.h>\n#  include <ws2tcpip.h>\n#endif\n\nIMPORT_LOG_FUNCTIONS()\n\nint DestFirstAvailable::get_server_socket(std::chrono::milliseconds connect_timeout, int *error,\n                                          mysql_harness::TCPAddress *address) noexcept {\n  if (destinations_.empty()) {\n    return -1;\n  }\n\n  for (size_t i = 0; i < destinations_.size(); ++i) {\n    // We start at the currently available server\n    auto addr = destinations_.at(current_pos_);\n    log_debug(\"Trying server %s (index %lu)\", addr.str().c_str(),\n              static_cast<long unsigned>(i)); // 32bit Linux requires cast\n    auto sock = get_mysql_socket(addr, connect_timeout);\n    if (sock >= 0) {\n      if (address) *address = addr;\n      return sock;\n    } else {\n      if (++current_pos_ >= destinations_.size()) current_pos_ = 0;\n    }\n  }\n\n#ifndef _WIN32\n  *error = errno;\n#else\n  *error = WSAGetLastError();\n#endif\n  return -1;\n}\n"
  },
  {
    "path": "src/routing/src/dest_first_available.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef ROUTING_DEST_FIRST_AVAILABLE_INCLUDED\n#define ROUTING_DEST_FIRST_AVAILABLE_INCLUDED\n\n#include <chrono>\n\n#include \"destination.h\"\n#include \"mysqlrouter/routing.h\"\n\n#include \"mysql/harness/logging/logging.h\"\n\nclass DestFirstAvailable final : public RouteDestination {\n public:\n  using RouteDestination::RouteDestination;\n\n  int get_server_socket(std::chrono::milliseconds connect_timeout_ms, int *error,\n                        mysql_harness::TCPAddress *address = nullptr) noexcept override;\n};\n\n\n#endif // ROUTING_DEST_FIRST_AVAILABLE_INCLUDED\n"
  },
  {
    "path": "src/routing/src/dest_metadata_cache.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"dest_metadata_cache.h\"\n#include \"utils.h\"\n#include \"mysqlrouter/routing.h\"\n\n#include <algorithm>\n#include <chrono>\n#include <iostream>\n#include <set>\n#ifndef _WIN32\n#  include <netdb.h>\n#  include <netinet/tcp.h>\n#endif\n\n#include \"mysqlrouter/utils.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"tcp_address.h\"\n\nusing mysqlrouter::to_string;\nusing std::out_of_range;\nusing std::runtime_error;\nusing std::chrono::duration_cast;\nusing std::chrono::system_clock;\nusing std::chrono::seconds;\n\nusing metadata_cache::ManagedInstance;\nIMPORT_LOG_FUNCTIONS()\n\n// if client wants a primary and there's none, we can wait up to this amount of\n// seconds until giving up and disconnecting the client\n// TODO: possibly this should be made into a configurable option\nstatic const int kPrimaryFailoverTimeout = 10;\n\nstatic const std::set<std::string> supported_params{\"role\", \"allow_primary_reads\",\n                                                    \"disconnect_on_promoted_to_primary\",\n                                                    \"disconnect_on_metadata_unavailable\"};\n\nnamespace {\n\nDestMetadataCacheGroup::ServerRole get_server_role_from_uri(const mysqlrouter::URIQuery &uri) {\n  if (uri.find(\"role\") == uri.end())\n    throw runtime_error(\"Missing 'role' in routing destination specification\");\n\n  const std::string name =  uri.at(\"role\");\n  std::string name_lc = name;\n  std::transform(name.begin(), name.end(), name_lc.begin(), ::tolower);\n\n  if (name_lc == \"primary\")\n    return DestMetadataCacheGroup::ServerRole::Primary;\n  else if (name_lc == \"secondary\")\n    return DestMetadataCacheGroup::ServerRole::Secondary;\n  else if (name_lc == \"primary_and_secondary\")\n    return DestMetadataCacheGroup::ServerRole::PrimaryAndSecondary;\n\n  throw std::runtime_error(\"Invalid server role in metadata cache routing '\"+name+\"'\");\n}\n\nstd::string get_server_role_name(const DestMetadataCacheGroup::ServerRole role) {\n  switch (role) {\n   case DestMetadataCacheGroup::ServerRole::Primary:\n    return \"primary\";\n   case DestMetadataCacheGroup::ServerRole::Secondary:\n    return \"secondary\";\n   case DestMetadataCacheGroup::ServerRole::PrimaryAndSecondary:\n    return \"primary_and_secondary\";\n  }\n\n  return \"unknown\";\n}\n\nrouting::RoutingStrategy get_default_routing_strategy(const DestMetadataCacheGroup::ServerRole role) {\n  switch (role) {\n   case DestMetadataCacheGroup::ServerRole::Primary:\n   case DestMetadataCacheGroup::ServerRole::PrimaryAndSecondary:\n   case DestMetadataCacheGroup::ServerRole::Secondary:\n    return routing::RoutingStrategy::kRoundRobin;\n  }\n\n  return routing::RoutingStrategy::kUndefined;\n}\n\n\n/** @brief check that mode (if present) is correct for the role */\nbool mode_is_valid(const routing::AccessMode mode, const DestMetadataCacheGroup::ServerRole role) {\n  // no mode given, that's ok, nothing to check\n  if (mode == routing::AccessMode::kUndefined) {\n    return true;\n  }\n\n  switch (role) {\n   case DestMetadataCacheGroup::ServerRole::Primary:\n    return mode == routing::AccessMode::kReadWrite;\n   case DestMetadataCacheGroup::ServerRole::Secondary:\n   case DestMetadataCacheGroup::ServerRole::PrimaryAndSecondary:\n    return mode == routing::AccessMode::kReadOnly;\n   default:; //\n    /* fall-through, no acces mode is valid for that role */\n  }\n\n  return false;\n}\n\n// throws:\n// - runtime_error if invalid value for the option was discovered\n// - check_option_allowed() throws std::runtime_error (it is expected to throw if the given\n//   option is not allowed (because of wrong combination with other params. etc.))\nbool get_yes_no_option(const mysqlrouter::URIQuery &uri,\n                       const std::string& option_name,\n                       const bool defalut_res,\n                       const std::function<void()>& check_option_allowed) {\n  if (uri.find(option_name) == uri.end())\n    return defalut_res;\n\n  check_option_allowed(); // this should throw if this option is not allowed for given configuration\n\n  std::string value_lc = uri.at(option_name);\n  std::transform(value_lc.begin(), value_lc.end(), value_lc.begin(), ::tolower);\n\n  if (value_lc == \"no\")\n    return false;\n  else if (value_lc == \"yes\")\n    return true;\n  else\n    throw std::runtime_error(\"Invalid value for option '\" + option_name + \"'. Allowed are 'yes' and 'no'\");\n}\n\n// throws runtime_error if the parameter has wrong value or is not allowed for given configuration\nbool get_disconnect_on_promoted_to_primary(const mysqlrouter::URIQuery &uri,\n                                            const DestMetadataCacheGroup::ServerRole& role) {\n  const std::string kOptionName = \"disconnect_on_promoted_to_primary\";\n  auto check_option_allowed = [&]() {\n    if (role != DestMetadataCacheGroup::ServerRole::Secondary) {\n      throw std::runtime_error(\"Option '\" + kOptionName + \"' is valid only for mode=SECONDARY\");\n    }\n  };\n\n  return get_yes_no_option(uri, kOptionName, /*default=*/ false, check_option_allowed);\n}\n\n// throws runtime_error if the parameter has wrong value or is not allowed for given configuration\nbool get_disconnect_on_metadata_unavailable(const mysqlrouter::URIQuery &uri) {\n  const std::string kOptionName = \"disconnect_on_metadata_unavailable\";\n  auto check_option_allowed = [&]() {}; // always allowed\n\n  return get_yes_no_option(uri, kOptionName, /*default=*/ false, check_option_allowed);\n}\n\n} // namespace {\n\n\n\n#ifndef DOXYGEN_SHOULD_SKIP_THIS\n// doxygen confuses 'const mysqlrouter::URIQuery &query' with 'std::map<std::string, std::string>'\nDestMetadataCacheGroup::DestMetadataCacheGroup(const std::string &metadata_cache,\n                                               const std::string &replicaset,\n                                               const routing::RoutingStrategy routing_strategy,\n                                               const mysqlrouter::URIQuery &query,\n                                               const Protocol::Type protocol,\n                                               const routing::AccessMode access_mode,\n                                               metadata_cache::MetadataCacheAPIBase* cache_api,\n                                               routing::RoutingSockOpsInterface *routing_sock_ops) :\n    RouteDestination(protocol, routing_sock_ops),\n    cache_name_(metadata_cache),\n    ha_replicaset_(replicaset),\n    uri_query_(query),\n    current_pos_(0),\n    routing_strategy_(routing_strategy),\n    access_mode_(access_mode),\n    server_role_(get_server_role_from_uri(query)),\n    cache_api_(cache_api),\n    disconnect_on_promoted_to_primary_(get_disconnect_on_promoted_to_primary(query, server_role_)),\n    disconnect_on_metadata_unavailable_(get_disconnect_on_metadata_unavailable(query)) {\n\n  init();\n}\n#endif\n\nDestMetadataCacheGroup::AvailableDestinations DestMetadataCacheGroup::get_available(const metadata_cache::LookupResult& managed_servers,\n                                                                                    bool for_new_connections) {\n  // TODO: this is a workaround. We should do it in the init() but currently\n  // there is no way to check if metadata_cache is initialized so we postpone it to\n  // first connection request\n  subscribe_for_metadata_cache_changes();\n\n  DestMetadataCacheGroup::AvailableDestinations result;\n\n  bool primary_fallback{false};\n  const auto& managed_servers_vec = managed_servers.instance_vector;\n  if (routing_strategy_ == routing::RoutingStrategy::kRoundRobinWithFallback) {\n    // if there are no secondaries available we fall-back to primaries\n    auto secondary = std::find_if(managed_servers_vec.begin(), managed_servers_vec.end(),\n            [](const metadata_cache::ManagedInstance& i)\n            {\n              return i.mode == metadata_cache::ServerMode::ReadOnly;\n            });\n\n    primary_fallback = secondary == managed_servers_vec.end();\n  }\n\n  // if we are gathering the nodes for the decision about keeping existing connections\n  // we look also at the disconnect_on_promoted_to_primary_ setting\n  // if set to 'no' we need to allow primaries for role=SECONDARY\n  if (!for_new_connections && server_role_ == ServerRole::Secondary && !disconnect_on_promoted_to_primary_) {\n    primary_fallback = true;\n  }\n\n  for (const auto &it: managed_servers_vec) {\n    if (!(it.role == \"HA\")) {\n      continue;\n    }\n    auto port = (protocol_ == Protocol::Type::kXProtocol) ? static_cast<uint16_t>(it.xport) : static_cast<uint16_t>(it.port);\n\n    // role=PRIMARY_AND_SECONDARY\n    if ((server_role_ == ServerRole::PrimaryAndSecondary) &&\n        (it.mode == metadata_cache::ServerMode::ReadWrite || it.mode == metadata_cache::ServerMode::ReadOnly)) {\n      result.address.push_back(mysql_harness::TCPAddress(it.host, port));\n      result.id.push_back(it.mysql_server_uuid);\n      continue;\n    }\n\n    // role=SECONDARY\n    if (server_role_ == ServerRole::Secondary && it.mode == metadata_cache::ServerMode::ReadOnly) {\n      result.address.push_back(mysql_harness::TCPAddress(it.host, port));\n      result.id.push_back(it.mysql_server_uuid);\n      continue;\n    }\n\n    // role=PRIMARY\n    if ((server_role_ == ServerRole::Primary || primary_fallback)\n         && it.mode == metadata_cache::ServerMode::ReadWrite) {\n      result.address.push_back(mysql_harness::TCPAddress(it.host, port));\n      result.id.push_back(it.mysql_server_uuid);\n      continue;\n    }\n  }\n\n  return result;\n}\n\nvoid DestMetadataCacheGroup::init() {\n  // check if URI does not contain parameters that we don't understand\n  for (const auto& uri_param: uri_query_) {\n    if (supported_params.count(uri_param.first) == 0) {\n      throw std::runtime_error(\"Unsupported 'metadata-cache' parameter in URI: '\" + uri_param.first + \"'\");\n    }\n  }\n\n  // if the routing strategy is set we don't allow mode to be set\n  if (routing_strategy_ != routing::RoutingStrategy::kUndefined &&\n      access_mode_ != routing::AccessMode::kUndefined ) {\n    throw std::runtime_error(\"option 'mode' is not allowed together with 'routing_strategy' option\");\n  }\n\n  bool routing_strategy_default{false};\n  // if the routing_strategy is not set we go with the default based on the role\n  if (routing_strategy_ == routing::RoutingStrategy::kUndefined) {\n    routing_strategy_ = get_default_routing_strategy(server_role_);\n    routing_strategy_default = true;\n  }\n\n  // check that mode (if present) is correct for the role\n  // we don't actually use it but support it for backward compatibility\n  // and parity with STANDALONE routing destinations\n  if (!mode_is_valid(access_mode_, server_role_)) {\n    throw std::runtime_error(\"mode '\" + routing::get_access_mode_name(access_mode_) +\n                             \"' is not valid for 'role=\" + get_server_role_name(server_role_) + \"'\");\n  }\n\n  // this is for backward compatibility\n  // old(allow_primary_reads + role=SECONDARY) = new (role=PRIMARY_AND_SECONDARY)\n  auto query_part = uri_query_.find(\"allow_primary_reads\");\n  if (query_part != uri_query_.end()) {\n    if (server_role_ != ServerRole::Secondary) {\n      throw std::runtime_error(\"allow_primary_reads is supported only for SECONDARY routing\");\n    }\n    if (!routing_strategy_default) {\n      throw std::runtime_error(\"allow_primary_reads is only supported for backward compatibility: \"\n                               \"without routing_strategy but with mode defined, use role=PRIMARY_AND_SECONDARY instead\");\n    }\n    auto value = query_part->second;\n    std::transform(value.begin(), value.end(), value.begin(), ::tolower);\n    if (value == \"yes\") {\n      server_role_ = ServerRole::PrimaryAndSecondary;\n    }\n    else if (value == \"no\") {\n      // it's a default but we allow it for consistency\n    }\n    else {\n      throw std::runtime_error(\"Invalid value for allow_primary_reads option: '\" + query_part->second + \"'\");\n    }\n  }\n\n  // validate routing strategy:\n  switch (routing_strategy_) {\n    case routing::RoutingStrategy::kRoundRobinWithFallback:\n      if (server_role_ != ServerRole::Secondary) {\n        throw std::runtime_error(\"Strategy 'round-robin-with-fallback' is supported only for SECONDARY routing\");\n      }\n    break;\n    case routing::RoutingStrategy::kFirstAvailable:\n    case routing::RoutingStrategy::kRoundRobin:\n      break;\n    default:\n      throw std::runtime_error(\"Unsupported routing strategy: \"\n                               + routing::get_routing_strategy_name(routing_strategy_));\n  }\n}\n\nvoid DestMetadataCacheGroup::subscribe_for_metadata_cache_changes() {\n  std::lock_guard<std::mutex> lock(subscribed_for_metadata_cache_changes_mutex_);\n  if (subscribed_for_metadata_cache_changes_) return;\n  subscribed_for_metadata_cache_changes_ = true;\n  using namespace std::placeholders;\n\n  cache_api_->add_listener(ha_replicaset_, this);\n}\n\nDestMetadataCacheGroup::~DestMetadataCacheGroup() {\n  if (subscribed_for_metadata_cache_changes_) {\n    cache_api_->remove_listener(ha_replicaset_, this);\n  }\n}\n\nsize_t DestMetadataCacheGroup::get_next_server(\n    const DestMetadataCacheGroup::AvailableDestinations& available) {\n  std::lock_guard<std::mutex> lock(mutex_update_);\n  size_t result = 0;\n\n  switch (routing_strategy_) {\n  case routing::RoutingStrategy::kFirstAvailable:\n    result = current_pos_;\n    break;\n  case routing::RoutingStrategy::kRoundRobin:\n  case routing::RoutingStrategy::kRoundRobinWithFallback:\n    result = current_pos_;\n    if (result >= available.address.size()) {\n      result = 0;\n      current_pos_ = 0;\n    }\n    ++current_pos_;\n    if (current_pos_ >= available.address.size()) {\n      current_pos_ = 0;\n    }\n    break;\n  default:\n    assert(0);\n    // impossible we verify this in init()\n    ;\n  }\n\n  return result;\n}\n\nint DestMetadataCacheGroup::get_server_socket(std::chrono::milliseconds connect_timeout, int *error,\n                                              mysql_harness::TCPAddress *address) noexcept {\n  while (true) {\n    try {\n      auto available = get_available(cache_api_->lookup_replicaset(ha_replicaset_).instance_vector);\n      if (available.address.empty()) {\n        log_warning(\"No available servers found for '%s' %s routing\",\n            ha_replicaset_.c_str(),\n            server_role_ == ServerRole::Primary ? \"primary\" : \"secondary\");\n        return -1;\n      }\n\n      size_t next_up = get_next_server(available);\n      int fd = get_mysql_socket(available.address.at(next_up), connect_timeout);\n      if (fd < 0) {\n        // Signal that we can't connect to the instance\n        cache_api_->mark_instance_reachability(available.id.at(next_up),\n            metadata_cache::InstanceStatus::Unreachable);\n        // if we're looking for a primary member, wait for there to be at least one\n        if (server_role_ == ServerRole::Primary &&\n            cache_api_->wait_primary_failover(ha_replicaset_,\n                kPrimaryFailoverTimeout)) {\n          log_info(\"Retrying connection for '%s' after possible failover\",\n                   ha_replicaset_.c_str());\n          continue; // retry\n        }\n      }\n      if (address) *address = available.address.at(next_up);\n      return fd;\n    } catch (std::runtime_error & re) {\n      log_error(\"Failed getting managed servers from the Metadata server: %s\",\n                re.what());\n      break;\n    }\n  }\n\n  *error = errno;\n  return -1;\n}\n\nvoid DestMetadataCacheGroup::on_instances_change(const metadata_cache::LookupResult &instances, const bool md_servers_reachable) {\n  // we got notified that the metadata has changed.\n  // If instances is empty then (most like is empty)\n  // the metadata-cache cannot connect to the metadata-servers\n  // In that case we only trigger the callbacks (resulting in disconnects) if the user\n  // configured that it should happen (disconnect_on_metadata_unavailable_ == true)\n  if (!md_servers_reachable && !disconnect_on_metadata_unavailable_)\n    return;\n\n  const std::string reason = md_servers_reachable ? \"metadata change\" : \"metadata unavailable\";\n\n  const auto& available_nodes = get_available(instances,  /*for_new_connections=*/ false);\n  std::lock_guard<std::mutex> lock(allowed_nodes_change_callbacks_mtx_);\n  // notify all the registered listeneres about the list of available nodes change\n  for (auto& clb: allowed_nodes_change_callbacks_) {\n    clb(available_nodes.address, reason);\n  }\n}\n\nvoid DestMetadataCacheGroup::notify(const metadata_cache::LookupResult& instances, const bool md_servers_reachable) noexcept {\n  on_instances_change(instances, md_servers_reachable);\n}\n"
  },
  {
    "path": "src/routing/src/dest_metadata_cache.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef ROUTING_DEST_METADATA_CACHE_INCLUDED\n#define ROUTING_DEST_METADATA_CACHE_INCLUDED\n\n#include \"destination.h\"\n#include \"mysql_routing.h\"\n#include \"mysqlrouter/uri.h\"\n#include \"mysqlrouter/metadata_cache.h\"\n\n#include <thread>\n\n#include \"mysqlrouter/datatypes.h\"\n#include \"mysql/harness/logging/logging.h\"\n\nclass DestMetadataCacheGroup final : public RouteDestination, public metadata_cache::ReplicasetStateListenerInterface {\npublic:\n   enum ServerRole {\n     Primary,\n     Secondary,\n     PrimaryAndSecondary\n   };\n\n   /** @brief Constructor */\n   DestMetadataCacheGroup(const std::string &metadata_cache,\n                          const std::string &replicaset,\n                          const routing::RoutingStrategy routing_strategy,\n                          const mysqlrouter::URIQuery &query,\n                          const Protocol::Type protocol,\n                          const routing::AccessMode access_mode = routing::AccessMode::kUndefined,\n                          metadata_cache::MetadataCacheAPIBase* cache_api = metadata_cache::MetadataCacheAPI::instance(),\n                          routing::RoutingSockOpsInterface *routing_sock_ops =\n                              routing::RoutingSockOps::instance(mysql_harness::SocketOperations::instance()));\n\n  /** @brief Copy constructor */\n  DestMetadataCacheGroup(const DestMetadataCacheGroup &other) = delete;\n\n  /** @brief Move constructor */\n  DestMetadataCacheGroup(DestMetadataCacheGroup &&) = delete;\n\n  /** @brief Copy assignment */\n  DestMetadataCacheGroup &operator=(const DestMetadataCacheGroup &) = delete;\n\n  /** @brief Move assignment */\n  DestMetadataCacheGroup &operator=(DestMetadataCacheGroup &&) = delete;\n\n  int get_server_socket(std::chrono::milliseconds connect_timeout, int *error,\n                        mysql_harness::TCPAddress *address = nullptr) noexcept override;\n\n  ~DestMetadataCacheGroup();\n\n  void add(const std::string &, uint16_t) override { }\n\n\n  /** @brief Returns whether there are destination servers\n   *\n   * The empty() method always returns false for Metadata Cache.\n   *\n   * Checking whether the Metadata Cache is empty for given destination\n   * might be to expensive. We leave this to the get_server() method.\n   *\n   * @return Always returns False for Metadata Cache destination.\n   */\n  bool empty() const noexcept override {\n    return false;\n  }\n\n  /** @brief empty implementation\n   *\n   * This method actually does something - it disables the RouteDestination::start(),\n   * which launches Quarantine. For Metadata Cache routing, we don't need it.\n   */\n  void start() override {}\n\nprivate:\n  /** @brief The Metadata Cache to use\n   *\n   * cache_name_ is the the section key in the configuration of Metadata Cache.\n   *\n   * For example, given following Metadata Cache configuration, cache_name_ will be\n   * set to \"ham\":\n   *\n   *     [metadata_cache.ham]\n   *     host = metadata.example.com\n   *\n   */\n  const std::string cache_name_;\n\n  /** @brief The HA Group which will be used for looking up managed servers */\n  const std::string ha_replicaset_;\n\n  /** @brief Query part of the URI given as destination in the configuration\n   *\n   * For example, given following Metadata Cache configuration:\n   *\n   *     [routing:metadata_read_only]\n   *     ..\n   *     destination = metadata_cache:///cluster_name/replicaset_name?allow_primary_reads=yes\n   *\n   * The 'allow_primary_reads' is part of uri_query_.\n   */\n  const mysqlrouter::URIQuery uri_query_;\n\n  /** @brief Initializes\n   *\n   * This method initialized the object. It goes of the URI query information\n   * and sets members accordingly.\n   */\n  void init();\n\n  struct AvailableDestinations{\n    AddrVector address;\n    std::vector<std::string> id;\n  };\n\n  /** @brief Gets available destinations from Metadata Cache\n   *\n   * This method gets the destinations using Metadata Cache information. It uses\n   * the `metadata_cache::lookup_replicaset()` function to get a list of current managed\n   * servers.\n   *\n   */\n  AvailableDestinations get_available(const metadata_cache::LookupResult& managed_servers,\n                                      bool for_new_connections = true);\n\n  size_t get_next_server(const DestMetadataCacheGroup::AvailableDestinations& available);\n\n  size_t current_pos_;\n\n  routing::RoutingStrategy routing_strategy_;\n\n  routing::AccessMode access_mode_;\n\n  ServerRole server_role_;\n\n  metadata_cache::MetadataCacheAPIBase* cache_api_;\n\n\n  std::mutex subscribed_for_metadata_cache_changes_mutex_;\n  bool subscribed_for_metadata_cache_changes_{false};\n\n  bool disconnect_on_promoted_to_primary_{false};\n  bool disconnect_on_metadata_unavailable_{false};\n\n  void on_instances_change(const metadata_cache::LookupResult &instances, const bool md_servers_reachable);\n  void subscribe_for_metadata_cache_changes();\n\n  void notify(const metadata_cache::LookupResult& instances, const bool md_servers_reachable) noexcept override;\n};\n\n\n#endif // ROUTING_DEST_METADATA_CACHE_INCLUDED\n"
  },
  {
    "path": "src/routing/src/dest_next_available.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"dest_next_available.h\"\n#include \"mysql/harness/logging/logging.h\"\n\n#ifdef _WIN32\n#  define WIN32_LEAN_AND_MEAN\n#  include <windows.h>\n#  include <winsock2.h>\n#  include <ws2tcpip.h>\n#endif\n\nIMPORT_LOG_FUNCTIONS()\n\nint DestNextAvailable::get_server_socket(std::chrono::milliseconds connect_timeout,\n                                         int *error, mysql_harness::TCPAddress *address) noexcept {\n  // Say for example, that we have three servers: A, B and C.\n  // The active server should be failed-over in such fashion:\n  //\n  //   A -> B -> C -> no more connections (regardless of whether A and B go back up or not)\n  //\n  // This is what this function does.\n\n  if (destinations_.empty()) {\n    return -1;\n  }\n\n  // We start the list at the currently available server\n  for (size_t i = current_pos_; i < destinations_.size(); ++i) {\n    auto addr = destinations_.at(i);\n    log_debug(\"Trying server %s (index %lu)\", addr.str().c_str(),\n              static_cast<long unsigned>(i)); // 32bit Linux requires cast\n    auto sock = get_mysql_socket(addr, connect_timeout);\n    if (sock >= 0) {\n      current_pos_ = i;\n      if (address) *address = addr;\n      return sock;\n    }\n  }\n\n#ifndef _WIN32\n  *error = errno;\n#else\n  *error = WSAGetLastError();\n#endif\n  current_pos_ = destinations_.size();  // so for(..) above will no longer try to connect to a server\n  return -1;\n}\n"
  },
  {
    "path": "src/routing/src/dest_next_available.h",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef ROUTING_DEST_NEXT_AVAILABLE\n#define ROUTING_DEST_NEXT_AVAILABLE\n\n#include \"destination.h\"\n#include \"mysqlrouter/routing.h\"\n\n#include \"mysql/harness/logging/logging.h\"\n\nclass DestNextAvailable final : public RouteDestination {\n public:\n  using RouteDestination::RouteDestination;\n\n  int get_server_socket(std::chrono::milliseconds connect_timeout, int *error,\n                        mysql_harness::TCPAddress *address = nullptr) noexcept override;\n};\n\n\n#endif // ROUTING_DEST_NEXT_AVAILABLE\n"
  },
  {
    "path": "src/routing/src/dest_round_robin.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n#include <chrono>\n\n#include \"common.h\"\n#include \"dest_round_robin.h\"\n#include \"mysql/harness/logging/logging.h\"\n\n#ifdef _WIN32\n#  define WIN32_LEAN_AND_MEAN\n#  include <windows.h>\n#  include <winsock2.h>\n#  include <ws2tcpip.h>\n#else\n# include <netdb.h>\n# include <netinet/tcp.h>\n# include <sys/socket.h>\n#endif\n\nIMPORT_LOG_FUNCTIONS()\n\nusing mysql_harness::TCPAddress;\n\n// Timeout for trying to connect with quarantined servers\nstatic constexpr std::chrono::milliseconds kQuarantinedConnectTimeout(1 * 1000);\n// How long we pause before checking quarantined servers again (seconds)\nstatic const int kQuarantineCleanupInterval = 3;\n// Make sure Quarantine Manager Thread is run even with nothing in quarantine\nstatic const int kTimeoutQuarantineConditional = 2;\n\nvoid* DestRoundRobin::run_thread(void* context) {\n  DestRoundRobin* dest_round_robin = static_cast<DestRoundRobin*>(context);\n  dest_round_robin->quarantine_manager_thread();\n  return nullptr;\n}\n\nvoid DestRoundRobin::start() {\n  quarantine_thread_.run(&run_thread, this);\n}\n\n\nint DestRoundRobin::get_server_socket(std::chrono::milliseconds connect_timeout, int *error,\n                                      mysql_harness::TCPAddress *address) noexcept {\n  size_t server_pos;\n\n  const size_t num_servers = size();\n  // Try at most num_servers times\n  for (size_t i = 0; i < num_servers; i++) {\n    try {\n      server_pos = get_next_server();\n    }\n    catch (const std::runtime_error&) {\n      log_warning(\"No destinations currently available for routing\");\n      return -1;\n    }\n\n    // If server is quarantined, skip\n    {\n      std::lock_guard<std::mutex> lock(mutex_quarantine_);\n      if (is_quarantined(server_pos)) {\n        continue;\n      }\n    }\n\n    // Try server\n    TCPAddress server_addr = destinations_[server_pos];\n    log_debug(\"Trying server %s (index %lu)\", server_addr.str().c_str(),\n              static_cast<long unsigned>(server_pos));\n    auto sock = get_mysql_socket(server_addr, connect_timeout);\n    if (sock >= 0) {\n      // Server is available\n      if (address) *address = server_addr;\n      return sock;\n    } else {\n#ifndef _WIN32\n      *error = errno;\n#else\n      *error = WSAGetLastError();\n#endif\n      if (errno != ENFILE && errno != EMFILE) {\n        // We failed to get a connection to the server; we quarantine.\n        std::lock_guard<std::mutex> lock(mutex_quarantine_);\n        add_to_quarantine(server_pos);\n        if (quarantined_.size() == destinations_.size()) {\n          log_debug(\"No more destinations: all quarantined\");\n          break;\n        }\n        continue; // try another destination\n      }\n      break;\n    }\n  }\n\n  return -1; // no destination is available\n}\n\nDestRoundRobin::~DestRoundRobin() {\n  stopping_ = true;\n  quarantine_thread_.join();\n}\n\nvoid DestRoundRobin::add_to_quarantine(const size_t index) noexcept {\n  assert(index < size());\n  if (index >= size()) {\n    log_debug(\"Impossible server being quarantined (index %lu)\",\n              static_cast<long unsigned>(index));  // 32bit Linux requires cast\n    return;\n  }\n  if (!is_quarantined(index)) {\n    log_debug(\"Quarantine destination server %s (index %lu)\", destinations_.at(index).str().c_str(),\n              static_cast<long unsigned>(index));  // 32bit Linux requires cast\n    quarantined_.push_back(index);\n    condvar_quarantine_.notify_one();\n  }\n}\n\nvoid DestRoundRobin::cleanup_quarantine() noexcept {\n\n  mutex_quarantine_.lock();\n  // Nothing to do when nothing quarantined\n  if (quarantined_.empty()) {\n    mutex_quarantine_.unlock();\n    return;\n  }\n  // We work on a copy; updating the original\n  auto cpy_quarantined(quarantined_);\n  mutex_quarantine_.unlock();\n\n  for (auto it = cpy_quarantined.begin(); it != cpy_quarantined.end(); ++it) {\n    if (stopping_) {\n      return;\n    }\n\n    auto addr = destinations_.at(*it);\n    auto sock = get_mysql_socket(addr, kQuarantinedConnectTimeout, false);\n\n    if (sock >= 0) {\n#ifndef _WIN32\n      shutdown(sock, SHUT_RDWR);\n      close(sock);\n#else\n      shutdown(sock, SD_BOTH);\n      closesocket(sock);\n#endif\n      log_debug(\"Unquarantine destination server %s (index %lu)\", addr.str().c_str(),\n                static_cast<long unsigned>(*it)); // 32bit Linux requires cast\n      std::lock_guard<std::mutex> lock(mutex_quarantine_);\n      quarantined_.erase(std::remove(quarantined_.begin(), quarantined_.end(), *it));\n    }\n  }\n}\n\nvoid DestRoundRobin::quarantine_manager_thread() noexcept {\n  mysql_harness::rename_thread(\"RtQ:<unknown>\");  //TODO change <unknown> to instance name\n\n  std::unique_lock<std::mutex> lock(mutex_quarantine_manager_);\n  while (!stopping_) {\n    condvar_quarantine_.wait_for(lock, std::chrono::seconds(kTimeoutQuarantineConditional),\n                                 [this] { return !quarantined_.empty(); });\n\n    if (!stopping_) {\n      cleanup_quarantine();\n      // Temporize\n      std::this_thread::sleep_for(std::chrono::seconds(kQuarantineCleanupInterval));\n    }\n  }\n}\n\nsize_t DestRoundRobin::size_quarantine() {\n  std::lock_guard<std::mutex> lock(mutex_quarantine_);\n  return quarantined_.size();\n}\n"
  },
  {
    "path": "src/routing/src/dest_round_robin.h",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef ROUTING_DEST_ROUND_ROBIN_INCLUDED\n#define ROUTING_DEST_ROUND_ROBIN_INCLUDED\n\n#include \"destination.h\"\n#include \"mysqlrouter/routing.h\"\n\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysql_router_thread.h\"\n\nclass DestRoundRobin : public RouteDestination {\n public:\n  using RouteDestination::RouteDestination;\n\n  /** @brief Default constructor\n   *\n   * @param protocol Protocol for the destination, defaults to value returned\n   *        by Protocol::get_default()\n   * @param routing_sock_ops Socket operations implementation to use, defaults\n   *        to \"real\" (not mock) implementation (mysql_harness::SocketOperations)\n   * @param thread_stack_size memory in kilobytes allocated for thread's stack\n   */\n  DestRoundRobin(Protocol::Type protocol = Protocol::get_default(),\n                 routing::RoutingSockOpsInterface *routing_sock_ops =\n                     routing::RoutingSockOps::instance(mysql_harness::SocketOperations::instance()),\n                 size_t thread_stack_size = mysql_harness::kDefaultStackSizeInKiloBytes)\n      : RouteDestination(protocol, routing_sock_ops), quarantine_thread_(thread_stack_size) {}\n\n  /** @brief Destructor */\n  virtual ~DestRoundRobin();\n\n  /** @brief run Quarantine Manager Thread */\n  static void* run_thread(void* context);\n\n  virtual void start() override;\n\n  int get_server_socket(std::chrono::milliseconds connect_timeout, int *error,\n                        mysql_harness::TCPAddress *address = nullptr) noexcept override;\n\n  /** @brief Returns number of quarantined servers\n   *\n   * @return size_t\n   */\n  size_t size_quarantine();\n\n protected:\n  /** @brief Returns whether destination is quarantined\n   *\n   * Uses the given index to check whether the destination is\n   * quarantined.\n   *\n   * @param index index of the destination to check\n   * @return True if destination is quarantined\n   */\n  virtual bool is_quarantined(const size_t index) {\n    return std::find(quarantined_.begin(), quarantined_.end(), index) != quarantined_.end();\n  }\n\n  /** @brief Adds server to quarantine\n   *\n   * Adds the given server address to the quarantine list. The index argument\n   * is the index of the server in the destination list.\n   *\n   * @param index Index of the destination\n   */\n  virtual void add_to_quarantine(size_t index) noexcept;\n\n  /** @brief Worker checking and removing servers from quarantine\n   *\n   * This method is meant to run in a thread and calling the\n   * `cleanup_quarantine()` method.\n   *\n   * The caller is responsible for locking and unlocking the\n   * mutex `mutex_quarantine_`.\n   *\n   */\n  virtual void quarantine_manager_thread() noexcept;\n\n  /** @brief Checks and removes servers from quarantine\n   *\n   * This method removes servers from quarantine while trying to establish\n   * a connection. It is used in a seperate thread and will update the\n   * quarantine list, and will keep trying until the list is empty.\n   * A conditional variable is used to notify the thread servers were\n   * quarantined.\n   *\n   */\n  virtual void cleanup_quarantine() noexcept;\n\n  /** @brief List of destinations which are quarantined */\n  std::vector<size_t> quarantined_;\n\n  /** @brief Conditional variable blocking quarantine manager thread */\n  std::condition_variable condvar_quarantine_;\n\n  /** @brief Mutex for quarantine manager thread */\n  std::mutex mutex_quarantine_manager_;\n\n  /** @brief Mutex for updating quarantine */\n  std::mutex mutex_quarantine_;\n\n  /** @brief refresh thread facade */\n  mysql_harness::MySQLRouterThread quarantine_thread_;\n\n  /** @brief Whether we are stopping */\n  std::atomic_bool stopping_{false};\n};\n\n\n#endif // ROUTING_DEST_ROUND_ROBIN_INCLUDED\n"
  },
  {
    "path": "src/routing/src/destination.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"common.h\"\n#include \"destination.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysqlrouter/routing.h\"\n#include \"mysqlrouter/utils.h\"\n#include \"utils.h\"\n#include \"tcp_address.h\"\n\n#include <algorithm>\n#include <cassert>\n#include <iostream>\n#ifndef _WIN32\n#  include <netdb.h>\n#  include <netinet/tcp.h>\n#  include <sys/socket.h>\n#else\n#  define WIN32_LEAN_AND_MEAN\n#  include <windows.h>\n#  include <winsock2.h>\n#  include <ws2tcpip.h>\n#endif\n\n\nusing mysqlrouter::to_string;\nusing mysql_harness::TCPAddress;\nusing std::out_of_range;\nIMPORT_LOG_FUNCTIONS()\n\n// class DestinationNodesStateNotifier\n\nAllowedNodesChangeCallbacksListIterator\n  DestinationNodesStateNotifier::register_allowed_nodes_change_callback(\n    const AllowedNodesChangedCallback& clb) {\n  std::lock_guard<std::mutex> lock(allowed_nodes_change_callbacks_mtx_);\n  return allowed_nodes_change_callbacks_.insert(allowed_nodes_change_callbacks_.end(), clb);\n}\n\nvoid DestinationNodesStateNotifier::unregister_allowed_nodes_change_callback(\n    const AllowedNodesChangeCallbacksListIterator& it) {\n  std::lock_guard<std::mutex> lock(allowed_nodes_change_callbacks_mtx_);\n  allowed_nodes_change_callbacks_.erase(it);\n}\n\n// class RouteDestination\n\nvoid RouteDestination::add(const TCPAddress dest) {\n  auto dest_end = destinations_.end();\n\n  auto compare = [&dest](TCPAddress &other) { return dest == other; };\n\n  if (std::find_if(destinations_.begin(), dest_end, compare) == dest_end) {\n    std::lock_guard<std::mutex> lock(mutex_update_);\n    destinations_.push_back(dest);\n  }\n}\n\nvoid RouteDestination::add(const std::string &address, uint16_t port) {\n  add(TCPAddress(address, port));\n}\n\nvoid RouteDestination::remove(const std::string &address, uint16_t port) {\n  TCPAddress to_remove(address, port);\n  std::lock_guard<std::mutex> lock(mutex_update_);\n\n  auto func_same = [&to_remove](TCPAddress a) {\n    return (a.addr == to_remove.addr && a.port == to_remove.port);\n  };\n  destinations_.erase(std::remove_if(destinations_.begin(), destinations_.end(), func_same), destinations_.end());\n\n}\n\nTCPAddress RouteDestination::get(const std::string &address, uint16_t port) {\n  TCPAddress needle(address, port);\n  for (auto &it: destinations_) {\n    if (it == needle) {\n      return it;\n    }\n  }\n  throw out_of_range(\"Destination \" + needle.str() + \" not found\");\n}\n\nsize_t RouteDestination::size() noexcept {\n  return destinations_.size();\n}\n\nvoid RouteDestination::clear() {\n  if (destinations_.empty()) {\n    return;\n  }\n  std::lock_guard<std::mutex> lock(mutex_update_);\n  destinations_.clear();\n}\n\nsize_t RouteDestination::get_next_server() {\n  std::lock_guard<std::mutex> lock(mutex_update_);\n\n  if (destinations_.empty()) {\n    throw std::runtime_error(\"Destination servers list is empty\");\n  }\n\n  auto result = current_pos_.load();\n  current_pos_++;\n  if (current_pos_ >= destinations_.size()) current_pos_ = 0;\n\n  return result;\n}\n\nint RouteDestination::get_mysql_socket(const TCPAddress &addr, std::chrono::milliseconds connect_timeout, const bool log_errors) {\n  return routing_sock_ops_->get_mysql_socket(addr, connect_timeout, log_errors);\n}\n"
  },
  {
    "path": "src/routing/src/destination.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef ROUTING_DESTINATION_INCLUDED\n#define ROUTING_DESTINATION_INCLUDED\n\n#include \"router_config.h\"\n\n#include <algorithm>\n#include <atomic>\n#include <condition_variable>\n#include <cstdint>\n#include <mutex>\n#include <string>\n#include <thread>\n#include <vector>\n#include <list>\n\n#include \"mysqlrouter/routing.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"protocol/protocol.h\"\n#include \"tcp_address.h\"\nIMPORT_LOG_FUNCTIONS()\n\nusing AllowedNodes = std::vector<mysql_harness::TCPAddress>;\n// first argument is the new set of the allowed nodes\n// second argument is the description of the condition that triggered the change (like '\n// metadata change' etc.) can be used for logging purposes by the caller\nusing AllowedNodesChangedCallback = std::function<void(const AllowedNodes&, const std::string&)>;\n// NOTE: this has to be container like std::list that does not invalidate iterators\n// when it is modified as we return the iterator to the insterted callback to the caller\n// to allow unregistering\nusing AllowedNodesChangeCallbacksList = std::list<AllowedNodesChangedCallback>;\nusing AllowedNodesChangeCallbacksListIterator = AllowedNodesChangeCallbacksList::iterator;\n\n/** @class DestinationNodesStateNotifier\n *\n * Allows the obervers to register for notifications on the change in the state\n * of the destination nodes.\n */\nclass DestinationNodesStateNotifier {\n public:\n\n  /** @brief Registers the callback for notification on the change in the\n   *         state if the destination nodes.\n   *\n   * @param clb callback that should be called\n   * @return identifier of the inserted callback, can be used to unregister\n   *         the callback\n   */\n  AllowedNodesChangeCallbacksListIterator\n    register_allowed_nodes_change_callback( const AllowedNodesChangedCallback& clb);\n\n  /** @brief Unregisters the callback registered with register_allowed_nodes_change_callback().\n   *\n   * @param it  iterator returned by the call to register_allowed_nodes_change_callback()\n   */\n  void unregister_allowed_nodes_change_callback(\n      const AllowedNodesChangeCallbacksListIterator& it);\n\n protected:\n  AllowedNodesChangeCallbacksList allowed_nodes_change_callbacks_;\n  std::mutex allowed_nodes_change_callbacks_mtx_;\n};\n\n/** @class RouteDestination\n * @brief Manage destinations for a Connection Routing\n *\n * This class manages destinations which are used in Connection Routing.\n * A destination is usually a MySQL Server and is stored using the IP\n * or hostname together with the TCP port (defaulting to 3306 for classic\n * protocol or to 33060 for x protocol).\n *\n * RouteDestination is meant to be a base class and used to inherite and\n * create class which change the behavior. For example, the `get_next()`\n * method is usually changed to get the next server in the list.\n */\nclass RouteDestination: public DestinationNodesStateNotifier {\n public:\n\n  using AddrVector = std::vector<mysql_harness::TCPAddress>;\n\n  /** @brief Default constructor\n   *\n   * @param protocol Protocol for the destination, defaults to value returned\n   *        by Protocol::get_default()\n   * @param routing_sock_ops Socket operations implementation to use, defaults\n   *        to \"real\" (not mock) implementation (mysql_harness::SocketOperations)\n   */\n  RouteDestination(Protocol::Type protocol = Protocol::get_default(),\n                   routing::RoutingSockOpsInterface* routing_sock_ops =\n                       routing::RoutingSockOps::instance(mysql_harness::SocketOperations::instance()))\n      : current_pos_(0), routing_sock_ops_(routing_sock_ops), protocol_(protocol) {}\n\n  /** @brief Destructor */\n  virtual ~RouteDestination() {}\n\n  RouteDestination(const RouteDestination &other) = delete;\n  RouteDestination(RouteDestination &&other) = delete;\n  RouteDestination &operator=(const RouteDestination &other) = delete;\n  RouteDestination &operator=(RouteDestination &&other) = delete;\n\n  /** @brief Adds a destination\n   *\n   * Adds a destination using the given address and port number.\n   *\n   * @param dest destination address\n   */\n  virtual void add(const mysql_harness::TCPAddress dest);\n\n  /** @overload */\n  virtual void add(const std::string &address, uint16_t port);\n\n  /** @brief Removes a destination\n   *\n   * Removes a destination using the given address and port number.\n   *\n   * @param address IP or name\n   * @param port Port number\n   */\n  virtual void remove(const std::string &address, uint16_t port);\n\n  /** @brief Gets destination based on address and port\n   *\n   * Gets destination base on given address and port and returns a pair\n   * with the information.\n   *\n   * Raises std::out_of_range when the combination of address and port\n   * is not in the list of destinations.\n   *\n   * This function can be used to check whether given destination is in\n   * the list.\n   *\n   * @param address IP or name\n   * @param port Port number\n   * @return an instance of mysql_harness::TCPAddress\n   */\n  virtual mysql_harness::TCPAddress get(const std::string &address, uint16_t port);\n\n  /** @brief Removes all destinations\n   *\n   * Removes all destinations from the list.\n   */\n  virtual void clear();\n\n  /** @brief Gets next connection to destination\n   *\n   * Returns a socket descriptor for the connection to the MySQL Server or\n   * -1 when an error occurred, which means that no destination was\n   * available.\n   *\n   * @param connect_timeout timeout\n   * @param error Pointer to int for storing errno\n   * @param address Pointer to memory for storing destination address\n   *                if the caller is not interested in that it can pass default nullptr\n   * @return a socket descriptor\n   */\n  virtual int get_server_socket(std::chrono::milliseconds connect_timeout, int *error,\n                                mysql_harness::TCPAddress *address = nullptr) noexcept = 0;\n\n  /** @brief Gets the number of destinations\n   *\n   * Gets the number of destinations currently in the list.\n   *\n   * @return Number of destinations as size_t\n   */\n  size_t size() noexcept;\n\n  /** @brief Returns whether there are destinations\n   *\n   * @return whether the destination is empty\n   */\n  virtual bool empty() const noexcept {\n    return destinations_.empty();\n  }\n\n  /** @brief Start the destination threads (if any)\n   *\n   */\n  virtual void start() {}\n\n  AddrVector::iterator begin() {\n    return destinations_.begin();\n  }\n\n  AddrVector::const_iterator begin() const {\n    return destinations_.begin();\n  }\n\n  AddrVector::iterator end() {\n    return destinations_.end();\n  }\n\n  AddrVector::const_iterator end() const {\n    return destinations_.end();\n  }\n\n protected:\n  /** @brief Returns socket descriptor of connected MySQL server\n   *\n   * Returns a socket descriptor for the connection to the MySQL Server or\n   * -1 when an error occurred.\n   *\n   * This method normally calls SocketOperations::get_mysql_socket() (default\n   * \"real\" implementation), but can be configured to call another implementation\n   * (e.g. a mock counterpart).\n   *\n   * @param addr information of the server we connect with\n   * @param connect_timeout timeout waiting for connection\n   * @param log_errors whether to log errors or not\n   * @return a socket descriptor\n   */\n  virtual int get_mysql_socket(const mysql_harness::TCPAddress &addr, std::chrono::milliseconds connect_timeout, bool log_errors = true);\n\n  /** @brief Gets the id of the next server to connect to.\n   *\n   * @throws std::logic_error if destinations list is empty\n   */\n  size_t get_next_server();\n\n  /** @brief List of destinations */\n  AddrVector destinations_;\n\n  /** @brief Destination which will be used next */\n  std::atomic<size_t> current_pos_;\n\n  /** @brief Mutex for updating destinations and iterator */\n  std::mutex mutex_update_;\n\n  /** @brief socket operation methods (facilitates dependency injection)*/\n  routing::RoutingSockOpsInterface *routing_sock_ops_;\n\n  /** @brief Protocol for the destination */\n  Protocol::Type protocol_;\n};\n\n#endif // ROUTING_DESTINATION_INCLUDED\n"
  },
  {
    "path": "src/routing/src/mysql_routing.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n#ifdef _WIN32\n#  define NOMINMAX\n#endif\n\n#include \"utils.h\"\n#include \"common.h\"\n#include \"dest_first_available.h\"\n#include \"dest_next_available.h\"\n#include \"dest_round_robin.h\"\n#include \"dest_metadata_cache.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysql_routing.h\"\n#include \"mysqlrouter/metadata_cache.h\"\n#include \"mysqlrouter/routing.h\"\n#include \"mysqlrouter/uri.h\"\n#include \"mysqlrouter/utils.h\"\n#include \"mysql/harness/plugin.h\"\n#include \"plugin_config.h\"\n#include \"protocol/protocol.h\"\n#include \"connection.h\"\n#include \"mysql_routing_common.h\"\n\n#include \"mysql_router_thread.h\"\n\n#include <algorithm>\n#include <array>\n#include <cmath>\n#include <cstring>\n#include <future>\n#include <memory>\n#include <mutex>\n#include <sstream>\n\n#include <sys/types.h>\n\n#ifndef _WIN32\n#  include <netinet/in.h>\n#  include <fcntl.h>\n#  include <sys/un.h>\n#  include <sys/select.h>\n#  include <sys/socket.h>\n#  include <sys/stat.h>\n#else\n#  define WIN32_LEAN_AND_MEAN\n#  include <windows.h>\n#  include <winsock2.h>\n#  include <ws2tcpip.h>\n#endif\n\n#if defined(__sun)\n# include <ucred.h>\n#elif defined(__APPLE__) || defined(__FreeBSD__)\n# include <sys/ucred.h>\n#endif\n\nusing std::runtime_error;\nusing std::string;\nusing mysql_harness::get_strerror;\nusing mysqlrouter::string_format;\nusing mysqlrouter::to_string;\nusing routing::AccessMode;\nusing routing::RoutingStrategy;\nusing mysqlrouter::URI;\nusing mysqlrouter::URIError;\nusing mysqlrouter::URIQuery;\nusing mysql_harness::TCPAddress;\nusing mysqlrouter::is_valid_socket_name;\nIMPORT_LOG_FUNCTIONS()\n\nstatic int kListenQueueSize = 1024;\n\nstatic const char *kDefaultReplicaSetName = \"default\";\nstatic const std::chrono::milliseconds kAcceptorStopPollInterval_ms { 100 };\n\nMySQLRouting::MySQLRouting(routing::RoutingStrategy routing_strategy, uint16_t port,\n                           const Protocol::Type protocol,\n                           const routing::AccessMode access_mode,\n                           const string &bind_address,\n                           const mysql_harness::Path& named_socket,\n                           const string &route_name,\n                           int max_connections,\n                           std::chrono::milliseconds destination_connect_timeout,\n                           unsigned long long max_connect_errors,\n                           std::chrono::milliseconds client_connect_timeout,\n                           unsigned int net_buffer_length,\n                           routing::RoutingSockOpsInterface *routing_sock_ops,\n                           size_t thread_stack_size)\n    : context_(Protocol::create(protocol, routing_sock_ops), routing_sock_ops->so(),\n        route_name, net_buffer_length, destination_connect_timeout,\n        client_connect_timeout, TCPAddress(bind_address, port),\n        named_socket, max_connect_errors, thread_stack_size\n      ),\n      routing_sock_ops_(routing_sock_ops),\n      routing_strategy_(routing_strategy),\n      access_mode_(access_mode),\n      max_connections_(set_max_connections(max_connections)),\n      service_tcp_(routing::kInvalidSocket),\n      service_named_socket_(routing::kInvalidSocket) {\n\n  validate_destination_connect_timeout(destination_connect_timeout);\n\n  assert(routing_sock_ops_ != nullptr);\n\n  #ifdef _WIN32\n  if (named_socket.is_set()) {\n    throw std::invalid_argument(string_format(\"'socket' configuration item is not supported on Windows platform\"));\n  }\n  #endif\n\n  // This test is only a basic assertion.  Calling code is expected to check the validity of these arguments more thoroughally.\n  // At the time of writing, routing_plugin.cc : init() is one such place.\n  if (!context_.get_bind_address().port && !named_socket.is_set()) {\n    throw std::invalid_argument(string_format(\"No valid address:port (%s:%d) or socket (%s) to bind to\", bind_address.c_str(), port, named_socket.c_str()));\n  }\n}\n\nMySQLRouting::~MySQLRouting() {\n\n  if (service_tcp_ != routing::kInvalidSocket) {\n    context_.get_socket_operations()->shutdown(service_tcp_);\n    context_.get_socket_operations()->close(service_tcp_);\n  }\n}\n\nvoid MySQLRouting::start(mysql_harness::PluginFuncEnv* env) {\n\n  mysql_harness::rename_thread(get_routing_thread_name(context_.get_name(), \"RtM\").c_str());  // \"Rt main\" would be too long :(\n  if (context_.get_bind_address().port > 0) {\n    try {\n      setup_tcp_service();\n    } catch (const runtime_error &exc) {\n      clear_running(env);\n      throw runtime_error(\n          string_format(\"Setting up TCP service using %s: %s\", context_.get_bind_address().str().c_str(), exc.what()));\n    }\n    log_info(\"[%s] started: listening on %s\", context_.get_name().c_str(), context_.get_bind_address().str().c_str());\n  }\n#ifndef _WIN32\n  if (context_.get_bind_named_socket().is_set()) {\n    try {\n      setup_named_socket_service();\n    } catch (const runtime_error &exc) {\n      clear_running(env);\n      throw runtime_error(\n          string_format(\"Setting up named socket service '%s': %s\", context_.get_bind_named_socket().c_str(), exc.what()));\n    }\n    log_info(\"[%s] started: listening using %s\", context_.get_name().c_str(), context_.get_bind_named_socket().c_str());\n  }\n#endif\n  if (context_.get_bind_address().port > 0 || context_.get_bind_named_socket().is_set()) {\n    start_acceptor(env);\n#ifndef _WIN32\n    if (context_.get_bind_named_socket().is_set() && unlink(context_.get_bind_named_socket().str().c_str()) == -1) {\n      if (errno != ENOENT)\n        log_warning(\"%s\", (\"Failed removing socket file \" + context_.get_bind_named_socket().str() + \" (\" + get_strerror(errno) + \" (\" + to_string(errno) + \"))\").c_str());\n    }\n#endif\n  }\n}\n\n#if !defined(_WIN32)\n/*\n * get PID and UID of the other end of the unix-socket\n */\nstatic int unix_getpeercred(int sock, pid_t &peer_pid, uid_t &peer_uid) {\n#if defined(__sun)\n  ucred_t *ucred;\n\n  if (getpeerucred(sock, &ucred) == -1) {\n    return -1;\n  }\n\n  peer_pid = ucred_getpid(ucred);\n  peer_uid = ucred_getruid(ucred);\n\n  free(ucred);\n\n  return 0;\n#elif defined(_GNU_SOURCE)\n  struct ucred ucred;\n  socklen_t ucred_len = sizeof(ucred);\n\n  if (getsockopt(sock, SOL_SOCKET, SO_PEERCRED, &ucred, &ucred_len) == -1) {\n    return -1;\n  }\n\n  peer_pid = ucred.pid;\n  peer_uid = ucred.uid;\n\n  return 0;\n#else\n  // tag them as UNUSED to keep -Werror happy\n  (void)(sock);\n  (void)(peer_pid);\n  (void)(peer_uid);\n\n  return -1;\n#endif\n}\n#endif\n\n\nvoid MySQLRouting::start_acceptor(mysql_harness::PluginFuncEnv* env) {\n  mysql_harness::rename_thread(get_routing_thread_name(context_.get_name(), \"RtA\").c_str());  // \"Rt Acceptor\" would be too long :(\n\n  destination_->start();\n\n  auto allowed_nodes_changed = [&](const AllowedNodes& nodes, const std::string& reason) {\n\n    std::ostringstream oss;\n\n    if (!context_.get_bind_address().addr.empty()) {\n      oss << context_.get_bind_address().port;\n      if (!context_.get_bind_named_socket().str().empty())\n        oss << \" and \";\n    }\n\n    if (!context_.get_bind_named_socket().str().empty())\n      oss << \"named socket \" << context_.get_bind_named_socket();\n\n    log_info(\"Routing %s listening on %s got request to disconnect invalid connections: %s\",\n        context_.get_name().c_str(), oss.str().c_str(), reason.c_str());\n\n    // handle allowed nodes changed\n    connection_container_.disconnect(nodes);\n  };\n\n  allowed_nodes_list_iterator_ =\n      destination_->register_allowed_nodes_change_callback(allowed_nodes_changed);\n\n  std::shared_ptr<void> exit_guard(nullptr, [&](void *){\n    destination_->unregister_allowed_nodes_change_callback(allowed_nodes_list_iterator_);\n  });\n\n\n  if (service_tcp_ != routing::kInvalidSocket) {\n    routing::set_socket_blocking(service_tcp_, false);\n  }\n  if (service_named_socket_ != routing::kInvalidSocket) {\n    routing::set_socket_blocking(service_named_socket_, false);\n  }\n\n  const int kAcceptUnixSocketNdx = 0;\n  const int kAcceptTcpNdx = 1;\n  struct pollfd fds[] = {\n    { routing::kInvalidSocket, POLLIN, 0 },\n    { routing::kInvalidSocket, POLLIN, 0 },\n  };\n\n  fds[kAcceptTcpNdx].fd = service_tcp_;\n  fds[kAcceptUnixSocketNdx].fd = service_named_socket_;\n\n  while (is_running(env)) {\n    // wait for the accept() sockets to become readable (POLLIN)\n    int ready_fdnum = context_.get_socket_operations()->poll(fds, sizeof(fds) / sizeof(fds[0]), kAcceptorStopPollInterval_ms);\n    // < 0 - failure\n    // == 0 - timeout\n    // > 0  - number of pollfd's with a .revent\n\n    if (ready_fdnum < 0) {\n      const int last_errno = context_.get_socket_operations()->get_errno();\n      switch (last_errno) {\n        case EINTR:\n        case EAGAIN:\n          continue;\n        default:\n          log_error(\"[%s] poll() failed with error: %s\", context_.get_name().c_str(), get_message_error(last_errno).c_str());\n          break;\n      }\n    }\n\n    for (size_t ndx = 0; ndx < sizeof(fds) / sizeof(fds[0]) && ready_fdnum > 0; ndx++) {\n      // walk through all fields and check which fired\n\n      if ((fds[ndx].revents & POLLIN) == 0) {\n        continue;\n      }\n\n      --ready_fdnum;\n\n      int sock_client;\n      struct sockaddr_storage client_addr;\n      socklen_t sin_size = static_cast<socklen_t>(sizeof client_addr);\n\n\n      if ((sock_client = accept(fds[ndx].fd, (struct sockaddr *) &client_addr, &sin_size)) < 0) {\n        log_error(\"[%s] Failed accepting connection: %s\", context_.get_name().c_str(), get_message_error(context_.get_socket_operations()->get_errno()).c_str());\n        continue;\n      }\n\n      bool is_tcp = (ndx == kAcceptTcpNdx);\n\n      if (is_tcp) {\n        log_debug(\"[%s] fd=%d connection accepted at %s\", context_.get_name().c_str(), sock_client, context_.get_bind_address().str().c_str());\n      } else {\n#if !defined(_WIN32)\n        pid_t peer_pid;\n        uid_t peer_uid;\n\n        // try to be helpful of who tried to connect to use and failed.\n        // who == PID + UID\n        //\n        // if we can't get the PID, we'll just show a simpler errormsg\n\n        if (0 == unix_getpeercred(sock_client, peer_pid, peer_uid)) {\n          log_debug(\"[%s] fd=%d connection accepted at %s from (pid=%d, uid=%d)\",\n              context_.get_name().c_str(), sock_client, context_.get_bind_named_socket().str().c_str(),\n              peer_pid, peer_uid);\n        } else\n          // fall through\n#endif\n        log_debug(\"[%s] fd=%d connection accepted at %s\",\n            context_.get_name().c_str(), sock_client, context_.get_bind_named_socket().str().c_str());\n      }\n\n      if (context_.conn_error_counters_[in_addr_to_array(client_addr)] >= context_.max_connect_errors_) {\n        std::stringstream os;\n        os << \"Too many connection errors from \" << get_peer_name(sock_client).first;\n        context_.get_protocol().send_error(sock_client, 1129, os.str(), \"HY000\", context_.get_name());\n        log_info(\"%s\", os.str().c_str());\n        context_.get_socket_operations()->close(sock_client); // no shutdown() before close()\n        continue;\n      }\n\n      if (context_.info_active_routes_.load(std::memory_order_relaxed) >= max_connections_) {\n        context_.get_protocol().send_error(sock_client, 1040, \"Too many connections to MySQL Router\", \"HY000\", context_.get_name());\n        context_.get_socket_operations()->close(sock_client); // no shutdown() before close()\n        log_warning(\"[%s] reached max active connections (%d max=%d)\", context_.get_name().c_str(),\n                   context_.info_active_routes_.load(), max_connections_);\n        continue;\n      }\n\n      int opt_nodelay = 1;\n      if (is_tcp && setsockopt(sock_client, IPPROTO_TCP, TCP_NODELAY, reinterpret_cast<char *>(&opt_nodelay), static_cast<socklen_t>(sizeof(int))) == -1) {\n        log_info(\"[%s] fd=%d client setsockopt(TCP_NODELAY) failed: %s\", context_.get_name().c_str(), sock_client, get_message_error(context_.get_socket_operations()->get_errno()).c_str());\n\n        // if it fails, it will be slower, but cause no harm\n      }\n\n      // On some OS'es the socket will be non-blocking as a result of accept()\n      // on non-blocking socket. We need to make sure it's always blocking.\n      routing::set_socket_blocking(sock_client, true);\n\n      // launch client thread which will service this new connection\n      create_connection(sock_client, client_addr);\n    }\n  } // while (is_running(env))\n\n  // disconnect all connections\n  connection_container_.disconnect_all();\n\n  // wait until all connections are closed\n  {\n    std::unique_lock<std::mutex> lk(context_.active_client_threads_cond_m_);\n    context_.active_client_threads_cond_.wait(lk, [&]{ return context_.active_client_threads_ == 0;});\n  }\n\n  log_info(\"[%s] stopped\", context_.get_name().c_str());\n}\n\nvoid MySQLRouting::create_connection(int client_socket, const sockaddr_storage& client_addr) {\n  auto remove_callback = [this](MySQLRoutingConnection* connection) {\n    connection_container_.remove_connection(connection);\n  };\n\n  int error = 0;\n  mysql_harness::TCPAddress server_address;\n  int server_socket = destination_->get_server_socket(\n      context_.get_destination_connect_timeout(), &error, &server_address);\n\n  std::unique_ptr<MySQLRoutingConnection> new_connection(\n      new MySQLRoutingConnection(context_, client_socket, client_addr,\n          server_socket, server_address, remove_callback));\n\n  new_connection->start();\n  connection_container_.add_connection(std::move(new_connection));\n}\n\nstatic int get_socket_errno() {\n#ifdef _WIN32\n  return GetLastError();\n#else\n  return errno;\n#endif\n}\n\n// throws std::runtime_error\n/*static*/ void MySQLRouting::set_unix_socket_permissions(const char* socket_file) {\n#ifndef _WIN32  // Windows doesn't have Unix sockets\n\n  // make sure the socket is accessible to all users\n  // NOTE: According to man 7 unix, only r+w access is required to connect to socket, and indeed\n  //       setting permissions to rw-rw-rw- seems to work just fine on Ubuntu 14.04. However,\n  //       for some reason bind() creates rwxr-xr-x by default on said system, and Server 5.7 uses\n  //       rwxrwxrwx for its socket files. To be compliant with Server, we make our permissions\n  //       rwxrwxrwx as well, but the x is probably not necessary.\n  bool failed = chmod(socket_file, S_IRUSR | S_IRGRP | S_IROTH |  // read\n                                   S_IWUSR | S_IWGRP | S_IWOTH |  // write\n                                   S_IXUSR | S_IXGRP | S_IXOTH ); // execute\n  if (failed) {\n    std::string msg = std::string(\"Failed setting file permissions on socket file '\") +\n                      socket_file + \"': \" + get_strerror(errno);\n    log_error(\"%s\", msg.c_str());\n    throw std::runtime_error(msg);\n  }\n#endif\n}\n\nvoid MySQLRouting::setup_tcp_service() {\n  struct addrinfo *servinfo, *info, hints;\n  int err;\n\n  memset(&hints, 0, sizeof hints);\n  hints.ai_family = AF_UNSPEC;\n  hints.ai_socktype = SOCK_STREAM;\n  hints.ai_flags = AI_PASSIVE;\n\n  err = context_.get_socket_operations()->getaddrinfo(context_.get_bind_address().addr.c_str(),\n                                        to_string(context_.get_bind_address().port).c_str(), &hints, &servinfo);\n  if (err != 0) {\n    throw runtime_error(string_format(\"[%s] Failed getting address information (%s)\",\n        context_.get_name().c_str(), gai_strerror(err)));\n  }\n\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){if (servinfo) context_.get_socket_operations()->freeaddrinfo(servinfo);});\n\n  // Try to setup socket and bind\n  std::string error;\n  for (info = servinfo; info != nullptr; info = info->ai_next) {\n    if ((service_tcp_ = context_.get_socket_operations()->socket(info->ai_family, info->ai_socktype, info->ai_protocol)) == -1) {\n      error = get_message_error(get_socket_errno());\n      log_warning(\"[%s] setup_tcp_service() error from socket(): %s\", context_.get_name().c_str(), error.c_str());\n      continue;\n    }\n\n#if 1\n    int option_value = 1;\n    if (context_.get_socket_operations()->setsockopt(service_tcp_, SOL_SOCKET, SO_REUSEADDR, &option_value,\n            static_cast<socklen_t>(sizeof(int))) == -1) {\n      error = get_message_error(get_socket_errno());\n      log_warning(\"[%s] setup_tcp_service() error from setsockopt(): %s\", context_.get_name().c_str(), error.c_str());\n      context_.get_socket_operations()->close(service_tcp_);\n      service_tcp_ = routing::kInvalidSocket;\n      continue;\n    }\n#endif\n\n    if (context_.get_socket_operations()->bind(service_tcp_, info->ai_addr, info->ai_addrlen) == -1) {\n      error = get_message_error(get_socket_errno());\n      log_warning(\"[%s] setup_tcp_service() error from bind(): %s\", context_.get_name().c_str(), error.c_str());\n      context_.get_socket_operations()->close(service_tcp_);\n      service_tcp_ = routing::kInvalidSocket;\n      continue;\n    }\n\n    break;\n  }\n\n  if (info == nullptr) {\n    throw runtime_error(string_format(\"[%s] Failed to setup service socket: %s\", context_.get_name().c_str(), error.c_str()));\n  }\n\n  if (context_.get_socket_operations()->listen(service_tcp_, kListenQueueSize) < 0) {\n    throw runtime_error(string_format(\"[%s] Failed to start listening for connections using TCP\", context_.get_name().c_str()));\n  }\n}\n\n#ifndef _WIN32\nvoid MySQLRouting::setup_named_socket_service() {\n  struct sockaddr_un sock_unix;\n  string socket_file = context_.get_bind_named_socket().str();\n  errno = 0;\n\n  assert(!socket_file.empty());\n\n  std::string error_msg;\n  if (!is_valid_socket_name(socket_file, error_msg)) {\n    throw std::runtime_error(error_msg);\n  }\n\n  if ((service_named_socket_ = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {\n    throw std::invalid_argument(get_strerror(errno));\n  }\n\n  sock_unix.sun_family = AF_UNIX;\n  std::strncpy(sock_unix.sun_path, socket_file.c_str(), socket_file.size() + 1);\n\nretry:\n  if (::bind(service_named_socket_, (struct sockaddr *) &sock_unix, static_cast<socklen_t>(sizeof(sock_unix))) == -1) {\n    int save_errno = errno;\n    if (errno == EADDRINUSE) {\n      // file exists, try to connect to it to see if the socket is already in use\n      if (::connect(service_named_socket_,\n                    (struct sockaddr *) &sock_unix, static_cast<socklen_t>(sizeof(sock_unix))) == 0) {\n        log_error(\"Socket file %s already in use by another process\", socket_file.c_str());\n        throw std::runtime_error(\"Socket file already in use\");\n      } else {\n        if (errno == ECONNREFUSED) {\n          log_warning(\"Socket file %s already exists, but seems to be unused. Deleting and retrying...\", socket_file.c_str());\n          if (unlink(socket_file.c_str()) == -1) {\n            if (errno != ENOENT) {\n              log_warning(\"%s\", (\"Failed removing socket file \" + socket_file + \" (\" + get_strerror(errno) + \" (\" + to_string(errno) + \"))\").c_str());\n              throw std::runtime_error(\n                  \"Failed removing socket file \" + socket_file + \" (\" + get_strerror(errno) + \" (\" + to_string(errno) + \"))\");\n            }\n          }\n          errno = 0;\n          context_.get_socket_operations()->close(service_named_socket_);\n          if ((service_named_socket_ = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {\n            throw std::runtime_error(get_strerror(errno));\n          }\n          goto retry;\n        } else {\n          errno = save_errno;\n        }\n      }\n    }\n    log_error(\"Error binding to socket file %s: %s\", socket_file.c_str(), get_strerror(errno).c_str());\n    throw std::runtime_error(get_strerror(errno));\n  }\n\n  set_unix_socket_permissions(socket_file.c_str()); // throws std::runtime_error\n\n  if (listen(service_named_socket_, kListenQueueSize) < 0) {\n    throw runtime_error(\"Failed to start listening for connections using named socket\");\n  }\n}\n#endif\n\nvoid MySQLRouting::set_destinations_from_uri(const URI &uri) {\n  if (uri.scheme == \"metadata-cache\") {\n    // Syntax: metadata_cache://[<metadata_cache_key(unused)>]/<replicaset_name>?role=PRIMARY|SECONDARY|PRIMARY_AND_SECONDARY\n    std::string replicaset_name = kDefaultReplicaSetName;\n\n    if (uri.path.size() > 0 && !uri.path[0].empty())\n      replicaset_name = uri.path[0];\n\n    destination_.reset(new DestMetadataCacheGroup(uri.host, replicaset_name,\n                                                  routing_strategy_,\n                                                  uri.query, context_.get_protocol().get_type(),\n                                                  access_mode_));\n  } else {\n    throw runtime_error(string_format(\"Invalid URI scheme; expecting: 'metadata-cache' is: '%s'\",\n                                      uri.scheme.c_str()));\n  }\n}\n\nnamespace {\n\nrouting::RoutingStrategy get_default_routing_strategy(const routing::AccessMode access_mode) {\n  switch (access_mode) {\n   case routing::AccessMode::kReadOnly:\n    return routing::RoutingStrategy::kRoundRobin;\n   case routing::AccessMode::kReadWrite:\n    return routing::RoutingStrategy::kFirstAvailable;\n   default:; // fall-through\n  }\n\n  // safe default if access_mode is also not specified\n  return routing::RoutingStrategy::kFirstAvailable;\n}\n\nRouteDestination* create_standalone_destination(const routing::RoutingStrategy strategy,\n                                                const Protocol::Type protocol,\n                                                routing::RoutingSockOpsInterface *routing_sock_ops,\n                                                size_t thread_stack_size) {\n  switch (strategy) {\n    case RoutingStrategy::kFirstAvailable:\n      return new DestFirstAvailable(protocol, routing_sock_ops);\n    case RoutingStrategy::kNextAvailable:\n      return new DestNextAvailable(protocol, routing_sock_ops);\n    case RoutingStrategy::kRoundRobin:\n      return new DestRoundRobin(protocol, routing_sock_ops, thread_stack_size);\n    case RoutingStrategy::kUndefined:\n    case RoutingStrategy::kRoundRobinWithFallback:\n      ; // unsupported, fall through\n  }\n\n  throw std::runtime_error(\"Wrong routing strategy \" +\n                           std::to_string(static_cast<int>(strategy)));\n}\n}\n\nvoid MySQLRouting::set_destinations_from_csv(const string &csv) {\n  std::stringstream ss(csv);\n  std::string part;\n  std::pair<std::string, uint16_t> info;\n\n  // if no routing_strategy is defined for standalone routing\n  // we set the default based on the mode\n  if (routing_strategy_ == RoutingStrategy::kUndefined) {\n    routing_strategy_ = get_default_routing_strategy(access_mode_);\n  }\n\n  destination_.reset(create_standalone_destination(routing_strategy_,\n                                                   context_.get_protocol().get_type(),\n                                                   routing_sock_ops_, context_.get_thread_stack_size()));\n\n  // Fall back to comma separated list of MySQL servers\n  while (std::getline(ss, part, ',')) {\n    info = mysqlrouter::split_addr_port(part);\n    if (info.second == 0) {\n      info.second = Protocol::get_default_port(context_.get_protocol().get_type());\n    }\n    TCPAddress addr(info.first, info.second);\n    if (addr.is_valid()) {\n      destination_->add(addr);\n    } else {\n      throw std::runtime_error(string_format(\"Destination address '%s' is invalid\", addr.str().c_str()));\n    }\n  }\n\n  // Check whether bind address is part of list of destinations\n  for (auto &it: *(destination_)) {\n    if (it == context_.get_bind_address()) {\n      throw std::runtime_error(\"Bind Address can not be part of destinations\");\n    }\n  }\n\n  if (destination_->size() == 0) {\n    throw std::runtime_error(\"No destinations available\");\n  }\n}\n\nvoid MySQLRouting::validate_destination_connect_timeout(std::chrono::milliseconds timeout) {\n  if (timeout <= std::chrono::milliseconds::zero()) {\n    std::string error_msg(\"[\" + context_.get_name() + \"] tried to set destination_connect_timeout using invalid value, was \" + std::to_string(timeout.count()) + \" ms\");\n    throw std::invalid_argument(error_msg);\n  }\n}\n\nint MySQLRouting::set_max_connections(int maximum) {\n  if (maximum <= 0 || maximum > UINT16_MAX) {\n    auto err = string_format(\"[%s] tried to set max_connections using invalid value, was '%d'\", context_.get_name().c_str(),\n                             maximum);\n    throw std::invalid_argument(err);\n  }\n  max_connections_ = maximum;\n  return max_connections_;\n}\n"
  },
  {
    "path": "src/routing/src/mysql_routing.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef ROUTING_MYSQLROUTING_INCLUDED\n#define ROUTING_MYSQLROUTING_INCLUDED\n\n/** @file\n * @brief Defining the class MySQLRouting\n *\n * This file defines the main class `MySQLRouting` which is used to configure,\n * start and manage a connection routing from clients and MySQL servers.\n *\n */\n\n#include \"protocol/base_protocol.h\"\n#include \"router_config.h\"\n#include \"destination.h\"\n#include \"mysql/harness/filesystem.h\"\n#include \"mysqlrouter/mysql_protocol.h\"\n#include \"plugin_config.h\"\n#include \"utils.h\"\n#include \"mysqlrouter/routing.h\"\n#include \"mysql_router_thread.h\"\n#include \"tcp_address.h\"\n#include \"connection.h\"\n#include \"context.h\"\n#include \"connection_container.h\"\nnamespace mysql_harness { class PluginFuncEnv; }\n\n#include <array>\n#include <atomic>\n#include <iostream>\n#include <map>\n#include <memory>\n\n#ifndef _WIN32\n#  include <arpa/inet.h>\n#  include <netdb.h>\n#  include <netinet/in.h>\n#  include <netinet/tcp.h>\n#  include <sys/socket.h>\n#  include <unistd.h>\n#else\n#  define WIN32_LEAN_AND_MEAN\n#  include <windows.h>\n#  include <winsock2.h>\n#  include <ws2tcpip.h>\n#endif\n\n\n#ifdef _WIN32\n#  ifdef routing_DEFINE_STATIC\n#    define ROUTING_API\n#  else\n#    ifdef routing_EXPORTS\n#      define ROUTING_API __declspec(dllexport)\n#    else\n#      define ROUTING_API __declspec(dllimport)\n#    endif\n#  endif\n#else\n#  define ROUTING_API\n#endif\n\nusing std::string;\nusing mysqlrouter::URI;\n\n/** @class MySQLRoutering\n *  @brief Manage Connections from clients to MySQL servers\n *\n *  The class MySQLRouter is used to start a service listening on a particular\n *  TCP port for incoming MySQL Client connection and route these to a MySQL\n *  Server.\n *\n *  Connection routing will not analyze or parse any MySQL package (except from\n *  those in the handshake phase to be able to discover invalid connection error)\n *  nor will it do any authentication. It will not handle errors from the MySQL\n *  server and not automatically recover. The client communicate through\n *  MySQL Router just like it would directly connecting.\n *\n *  The MySQL Server is chosen from a given list of hosts or IP addresses\n *  (with or without TCP port) based on the the mode. For example, mode\n *  read-only will go through the list of servers in a round-robin way. The\n *  mode read-write will always go through the list from the beginning and\n *  failover to the next available.\n *\n *\n *  Example usage: bind to all IP addresses and use TCP Port 7001\n *\n *   MySQLRouting r(routing::AccessMode::kReadWrite, \"0.0.0.0\", 7001);\n *   r.destination_connect_timeout = std::chrono::seconds(1);\n *   r.set_destinations_from_csv(\"10.0.10.5;10.0.11.6\");\n *   r.start();\n *\n *  The above example will, when MySQL running on 10.0.10.5 is not available,\n *  use 10.0.11.6 to setup the connection routing.\n *\n */\nclass MySQLRouting {\npublic:\n  /** @brief Default constructor\n   *\n   * @param routing_strategy routing strategy\n   * @param port TCP port for listening for incoming connections\n   * @param protocol protocol for the routing\n   * @param access_mode access mode of the servers\n   * @param bind_address bind_address Bind to particular IP address\n   * @param named_socket Bind to Unix socket/Windows named pipe\n   * @param route_name Name of connection routing (can be empty string)\n   * @param max_connections Maximum allowed active connections\n   * @param destination_connect_timeout Timeout trying to connect destination server\n   * @param max_connect_errors Maximum connect or handshake errors per host\n   * @param connect_timeout Timeout waiting for handshake response\n   * @param net_buffer_length send/receive buffer size\n   * @param routing_sock_ops object handling the operations on network sockets\n   * @param thread_stack_size memory in kilobytes allocated for thread's stack\n   */\n  MySQLRouting(routing::RoutingStrategy routing_strategy,\n               uint16_t port,\n               const Protocol::Type protocol,\n               const routing::AccessMode access_mode = routing::AccessMode::kUndefined,\n               const string &bind_address = string{\"0.0.0.0\"},\n               const mysql_harness::Path& named_socket = mysql_harness::Path(),\n               const string &route_name = string{},\n               int max_connections = routing::kDefaultMaxConnections,\n               std::chrono::milliseconds destination_connect_timeout = routing::kDefaultDestinationConnectionTimeout,\n               unsigned long long max_connect_errors = routing::kDefaultMaxConnectErrors,\n               std::chrono::milliseconds connect_timeout = routing::kDefaultClientConnectTimeout,\n               unsigned int net_buffer_length = routing::kDefaultNetBufferLength,\n               routing::RoutingSockOpsInterface *routing_sock_ops =\n                   routing::RoutingSockOps::instance(mysql_harness::SocketOperations::instance()),\n               size_t thread_stack_size = mysql_harness::kDefaultStackSizeInKiloBytes);\n\n  ~MySQLRouting();\n\n  /** @brief Starts the service and accept incoming connections\n   *\n   * Starts the connection routing service and start accepting incoming\n   * MySQL client connections. Each connection will be further handled\n   * in a separate thread.\n   *\n   * @throw std::runtime_error on errors.\n   *\n   */\n  void start(mysql_harness::PluginFuncEnv* env);\n\n  /** @brief Sets the destinations from URI\n   *\n   * Sets destinations using the given string and the given mode. The string\n   * should be a comma separated list of MySQL servers.\n   *\n   * The mode is one of MySQLRouting::Mode, for example MySQLRouting::Mode::kReadOnly.\n   *\n   * Example of destinations:\n   *   \"10.0.10.5,10.0.11.6:3307\"\n   *\n   * @param csv destinations as comma-separated-values\n   */\n  void set_destinations_from_csv(const std::string &csv);\n\n  void set_destinations_from_uri(const mysqlrouter::URI &uri);\n\n  /** @brief Returns timeout when connecting to destination\n   *\n   * @return Timeout in seconds as int\n   */\n  std::chrono::milliseconds get_destination_connect_timeout() const noexcept {\n    return context_.get_destination_connect_timeout();\n  }\n\n  /** @brief Sets timeout when connecting to destination\n   *\n   * Checks timeout connecting with destination servers.\n   *\n   * @throw std::invalid_argument when an invalid value was provided.\n   *\n   * @param timeout Timeout\n   */\n  void validate_destination_connect_timeout(std::chrono::milliseconds timeout);\n\n  /** @brief Sets maximum active connections\n   *\n   * Sets maximum of active connections. Maximum must be between 1 and\n   * 65535.\n   *\n   * @throw std::invalid_argument when an invalid value was provided.\n   *\n   * @param maximum Max number of connections allowed\n   * @return New value as int\n   */\n  int set_max_connections(int maximum);\n\n  /** @brief Returns maximum active connections\n   *\n   * @return Maximum as int\n   */\n  int get_max_connections() const noexcept {\n    return max_connections_;\n  }\n\n  /**\n   * @brief create new connection to MySQL Server than can handle client's traffic\n   *        and adds it to connection container. Every connection runs in it's own\n   *        thread of execution.\n   *\n   * @param client_socket socket used to send/receive data to/from client\n   * @param client_addr address of client\n   */\n  void create_connection(int client_socket, const sockaddr_storage& client_addr);\n\nprivate:\n  /** @brief Sets up the TCP service\n   *\n   * Sets up the TCP service binding to IP addresses and TCP port.\n   *\n   * @throw std::runtime_error on errors.\n   */\n  void setup_tcp_service();\n\n  /** @brief Sets up the named socket service\n   *\n   * Sets up the named socket service creating a socket file on UNIX systems.\n   *\n   * @throw std::runtime_error on errors.\n   */\n  void setup_named_socket_service();\n\n  /** @brief Sets unix socket permissions so that the socket is accessible\n   *         to all users (no-op on Windows)\n   * @param socket_file path to socket file\n   *\n   * @throw std::runtime_error if chmod() inside fails\n   */\n  static void set_unix_socket_permissions(const char* socket_file);\n\npublic:\n\n  MySQLRoutingContext& get_context() {\n    return context_;\n  }\n\nprivate:\n\n  void start_acceptor(mysql_harness::PluginFuncEnv* env);\n\n  /** @brief wrapper for data used by all connections */\n  MySQLRoutingContext context_;\n\n  /** @brief object handling the operations on network sockets */\n  routing::RoutingSockOpsInterface* routing_sock_ops_;\n\n  /** @brief Destination object to use when getting next connection */\n  std::unique_ptr<RouteDestination> destination_;\n\n  /** @brief Routing strategy to use when getting next destination */\n  routing::RoutingStrategy routing_strategy_;\n\n  /** @brief Access mode of the servers in the routing */\n  routing::AccessMode access_mode_;\n\n  /** @brief Maximum active connections\n   *\n   * Maximum number of incoming connections that will be accepted\n   * by this MySQLRouter instances. There is no maximum for outgoing\n   * connections since it is one-to-one with incoming.\n   */\n  int max_connections_;\n\n  /** @brief Socket descriptor of the TCP service */\n  int service_tcp_;\n  /** @brief Socket descriptor of the named socket service */\n  int service_named_socket_;\n\n  /** @brief used to unregister from subscription on allowed nodes changes */\n  AllowedNodesChangeCallbacksListIterator allowed_nodes_list_iterator_;\n\n  /** @brief container for connections */\n  ConnectionContainer connection_container_;\n\n#ifdef FRIEND_TEST\n  FRIEND_TEST(RoutingTests, bug_24841281);\n  FRIEND_TEST(RoutingTests, get_routing_thread_name);\n  FRIEND_TEST(ClassicProtocolRoutingTest, NoValidDestinations);\n  FRIEND_TEST(TestSetupTcpService, single_addr_ok);\n  FRIEND_TEST(TestSetupTcpService, getaddrinfo_fails);\n  FRIEND_TEST(TestSetupTcpService, socket_fails_for_all_addr);\n  FRIEND_TEST(TestSetupTcpService, socket_fails);\n  FRIEND_TEST(TestSetupTcpService, bind_fails);\n  FRIEND_TEST(TestSetupTcpService, listen_fails);\n#ifndef _WIN32\n  FRIEND_TEST(TestSetupTcpService, setsockopt_fails);\n  FRIEND_TEST(TestSetupNamedSocketService, unix_socket_permissions_failure);\n#endif\n#endif\n};\n\nextern \"C\"\n{\n  extern mysql_harness::Plugin ROUTING_API harness_plugin_routing;\n}\n\n#endif // ROUTING_MYSQLROUTING_INCLUDED\n"
  },
  {
    "path": "src/routing/src/mysql_routing_common.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <string.h>\n\n#include \"mysql_routing_common.h\"\n\nstd::string get_routing_thread_name(const std::string& config_name, const std::string& prefix) {\n\n  const char* p = config_name.c_str();\n\n  // at the time of writing, config_name starts with:\n  //   \"routing:<config_from_conf_file>\" (with key)\n  // or with:\n  //   \"routing\" (without key).\n  // Verify this assumption\n  constexpr char kRouting[] = \"routing\";\n  size_t kRoutingLen = sizeof(kRouting) - 1;  // -1 to ignore string terminator\n  if (memcmp(p, kRouting, kRoutingLen))\n    return prefix + \":parse err\";\n\n  // skip over \"routing[:]\"\n  p += kRoutingLen;\n  if (*p == ':')\n    p++;\n\n  // at the time of writing, bootstrap generates 4 routing configurations by default,\n  // which will result in <config_from_conf_file> having one of below 4 values:\n  //   \"<cluster_name>_default_ro\",   \"<cluster_name>_default_rw\",\n  //   \"<cluster_name>_default_x_ro\", \"<cluster_name>_default_x_rw\"\n  // since we're limited to 15 chars for thread name, we skip over\n  // \"<cluster_name>_default_\" so that suffixes (\"x_ro\", etc) can fit\n  std::string key = p;\n  const char kPrefix[] = \"_default_\";\n  size_t pos = key.find(kPrefix);\n  if (pos != key.npos) {\n    key = key.substr(pos + sizeof(kPrefix) -1); // -1 for string terminator\n  }\n\n  // now put everything together\n  std::string thread_name = prefix + \":\" + key;\n  thread_name.resize(15); // max for pthread_setname_np()\n\n  return thread_name;\n}\n"
  },
  {
    "path": "src/routing/src/mysql_routing_common.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef ROUTING_MYSQLROUTING_COMMON_INCLUDED\n#define ROUTING_MYSQLROUTING_COMMON_INCLUDED\n\n#include <string>\n\n/**\n * @brief return a short string suitable to be used as a thread name\n *\n * @param config_name configuration name (e.g: \"routing\", \"routing:test_default_x_ro\", etc)\n * @param prefix thread name prefix (e.g. \"RtS\")\n *\n * @return a short string (example: \"RtS:x_ro\")\n */\nstd::string get_routing_thread_name(const std::string& config_name, const std::string& prefix);\n\n#endif /* ROUTING_MYSQLROUTING_COMMON_INCLUDED */\n"
  },
  {
    "path": "src/routing/src/plugin_config.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"plugin_config.h\"\n#include \"mysql_routing.h\"\n#include \"mysqlrouter/routing.h\"\n#include \"mysqlrouter/metadata_cache.h\"\n\n#include <algorithm>\n#include <exception>\n#include <vector>\n\n#include \"mysqlrouter/utils.h\"\n\nusing std::invalid_argument;\nusing std::string;\nusing std::vector;\nusing mysqlrouter::URI;\nusing mysqlrouter::URIError;\nusing mysqlrouter::to_string;\n\n\n/** @brief Constructor\n *\n * @param section from configuration file provided as ConfigSection\n */\nRoutingPluginConfig::RoutingPluginConfig(const mysql_harness::ConfigSection *section)\n    : BasePluginConfig(section),\n      metadata_cache_(false),\n      protocol(get_protocol(section, \"protocol\")),\n      destinations(get_option_destinations(section, \"destinations\", protocol)),\n      bind_port(get_option_tcp_port(section, \"bind_port\")),\n      bind_address(get_option_tcp_address(section, \"bind_address\", false, bind_port)),\n      named_socket(get_option_named_socket(section, \"socket\")),\n      connect_timeout(get_uint_option<uint16_t>(section, \"connect_timeout\", 1)),\n      mode(get_option_mode(section, \"mode\")),\n      routing_strategy(get_option_routing_strategy(section, \"routing_strategy\")),\n      max_connections(get_uint_option<uint16_t>(section, \"max_connections\", 1)),\n      max_connect_errors(get_uint_option<uint32_t>(section, \"max_connect_errors\", 1, UINT32_MAX)),\n      client_connect_timeout(get_uint_option<uint32_t>(section, \"client_connect_timeout\", 2, 31536000)),\n      net_buffer_length(get_uint_option<uint32_t>(section, \"net_buffer_length\", 1024, 1048576)),\n      thread_stack_size(get_uint_option<uint32_t>(section, \"thread_stack_size\", 1, 65535)){\n\n  // either bind_address or socket needs to be set, or both\n  if (!bind_address.port && !named_socket.is_set()) {\n    throw invalid_argument(\"either bind_address or socket option needs to be supplied, or both\");\n  }\n}\n\n\nstring RoutingPluginConfig::get_default(const string &option) const {\n\n  const std::map<string, string> defaults{\n      {\"bind_address\", to_string(routing::kDefaultBindAddress)},\n      {\"connect_timeout\", to_string(std::chrono::duration_cast<std::chrono::seconds>(routing::kDefaultDestinationConnectionTimeout).count())},\n      {\"max_connections\", to_string(routing::kDefaultMaxConnections)},\n      {\"max_connect_errors\", to_string(routing::kDefaultMaxConnectErrors)},\n      {\"client_connect_timeout\", to_string(std::chrono::duration_cast<std::chrono::seconds>(routing::kDefaultClientConnectTimeout).count())},\n      {\"net_buffer_length\", to_string(routing::kDefaultNetBufferLength)},\n      {\"thread_stack_size\", to_string(mysql_harness::kDefaultStackSizeInKiloBytes)},\n  };\n\n  auto it = defaults.find(option);\n  if (it == defaults.end()) {\n    return string();\n  }\n  return it->second;\n}\n\nbool RoutingPluginConfig::is_required(const string &option) const {\n  const vector<string> required{\n    \"destinations\",\n    // at least one of those is required, we handle this logic in get_option_ methods:\n    \"routing_strategy\",\n    \"mode\",\n  };\n\n  return std::find(required.begin(), required.end(), option) != required.end();\n}\n\nrouting::AccessMode RoutingPluginConfig::get_option_mode(\n    const mysql_harness::ConfigSection *section, const string &option) const {\n  string value;\n  try {\n    value = get_option_string(section, option);\n  }\n  catch (const mysqlrouter::option_not_present&) {\n    // no mode given, that's fine, it is no longer required\n    return routing::AccessMode::kUndefined;\n  }\n\n  std::transform(value.begin(), value.end(), value.begin(), ::tolower);\n\n  // if the mode is given it still needs to be valid\n  routing::AccessMode result = routing::get_access_mode(value);\n  if (result == routing::AccessMode::kUndefined) {\n    const string valid = routing::get_access_mode_names();\n    throw invalid_argument(get_log_prefix(option) + \" is invalid; valid are \" +\n                           valid + \" (was '\" + value + \"')\");\n  }\n  return result;\n}\n\nrouting::RoutingStrategy RoutingPluginConfig::get_option_routing_strategy(\n    const mysql_harness::ConfigSection *section, const string &option) const {\n  string value;\n  try {\n    value = get_option_string(section, option);\n  }\n  catch (const mysqlrouter::option_not_present&) {\n    // routing_strategy option is not given\n    // this is fine as long as mode is set which means that we deal with an old configuration\n    // which we still want to support\n\n    if (mode == routing::AccessMode::kUndefined) {\n      throw;\n    }\n\n    /** @brief `mode` option read from configuration section */\n    return routing::RoutingStrategy::kUndefined;\n  }\n\n  std::transform(value.begin(), value.end(), value.begin(), ::tolower);\n\n  auto result = routing::get_routing_strategy(value);\n  if (result == routing::RoutingStrategy::kUndefined ||\n      ((result == routing::RoutingStrategy::kRoundRobinWithFallback) && !metadata_cache_)) {\n    const string valid = routing::get_routing_strategy_names(metadata_cache_);\n    throw invalid_argument(get_log_prefix(option) + \" is invalid; valid are \" +\n                           valid + \" (was '\" + value + \"')\");\n  }\n  return result;\n}\n\nProtocol::Type RoutingPluginConfig::get_protocol(const mysql_harness::ConfigSection *section,\n                                                 const std::string &option) const {\n  std::string name;\n  try {\n    name = section->get(option);\n  } catch (const mysql_harness::bad_option&) {\n    return Protocol::get_default();\n  }\n\n  std::transform(name.begin(), name.end(), name.begin(), ::tolower);\n\n  return Protocol::get_by_name(name);\n}\n\nstring RoutingPluginConfig::get_option_destinations(const mysql_harness::ConfigSection *section,\n                                                    const string &option,\n                                                    const Protocol::Type &protocol_type) const {\n  bool required = is_required(option);\n  string value;\n\n  try {\n    value = section->get(option);\n  } catch (const mysql_harness::bad_option&) {\n    if (required) {\n      throw invalid_argument(get_log_prefix(option) + \" is required\");\n    }\n  }\n\n  if (value.empty()) {\n    if (required) {\n      throw invalid_argument(get_log_prefix(option) + \" is required and needs a value\");\n    }\n    value = get_default(option);\n  }\n\n  try {\n    // disable root-less paths like mailto:foo@example.org to stay\n    // backward compatible with\n    //\n    //   localhost:1234,localhost:1235\n    //\n    // which parse into:\n    //\n    //   scheme: localhost\n    //   path: 1234,localhost:1235\n    auto uri = URI(value, // raises URIError when URI is invalid\n        false  // allow_path_rootless\n        );\n    if (uri.scheme == \"metadata-cache\") {\n      metadata_cache_ = true;\n    } else {\n      throw invalid_argument(\n        get_log_prefix(option) + \" has an invalid URI scheme '\" + uri.scheme + \"' for URI \" + value);\n    }\n    return value;\n  } catch (URIError &) {\n    char delimiter = ',';\n\n    mysqlrouter::trim(value);\n    if (value.back() == delimiter || value.front() == delimiter) {\n      throw invalid_argument(get_log_prefix(option) +\n                                 \": empty address found in destination list (was '\" + value + \"')\");\n    }\n\n    std::stringstream ss(value);\n    std::string part;\n    std::pair<std::string, uint16_t> info;\n    while (std::getline(ss, part, delimiter)) {\n      mysqlrouter::trim(part);\n      if (part.empty()) {\n        throw invalid_argument(get_log_prefix(option) +\n                                   \": empty address found in destination list (was '\" + value + \"')\");\n      }\n      try {\n        info = mysqlrouter::split_addr_port(part);\n      } catch (const std::runtime_error &e) {\n        throw invalid_argument(get_log_prefix(option) +\n                                   \": address in destination list '\" + part + \"' is invalid: \" + e.what());\n      }\n      if (info.second == 0) {\n       info.second = Protocol::get_default_port(protocol_type);\n      }\n      mysql_harness::TCPAddress addr(info.first, info.second);\n      if (!addr.is_valid()) {\n        throw invalid_argument(get_log_prefix(option) + \" has an invalid destination address '\" + addr.str() + \"'\");\n      }\n    }\n\n  }\n\n  return value;\n}\n"
  },
  {
    "path": "src/routing/src/plugin_config.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef PLUGIN_CONFIG_ROUTING_INCLUDED\n#define PLUGIN_CONFIG_ROUTING_INCLUDED\n\n#include \"mysql/harness/filesystem.h\"\n#include \"mysql/harness/plugin.h\"\n\n#include \"mysqlrouter/plugin_config.h\"\n#include \"mysqlrouter/routing.h\"\n#include \"mysqlrouter/uri.h\"\n#include \"mysqlrouter/utils.h\"\n#include \"protocol/protocol.h\"\n#include \"tcp_address.h\"\n\n#include \"utils.h\"\n\n#include <map>\n#include <string>\n\nusing std::map;\nusing std::string;\nusing mysqlrouter::to_string;\nusing mysql_harness::TCPAddress;\nusing mysqlrouter::URI;\nusing mysqlrouter::URIError;\nusing mysqlrouter::URIQuery;\n\nclass RoutingPluginConfig final : public mysqlrouter::BasePluginConfig {\nprivate:\n  // is this [routing] entry for static routing or metadata-cache ?\n  // it's mutable because we discover it while calling getter for\n  // option destinations\n  mutable bool metadata_cache_;\npublic:\n  /** @brief Constructor\n   *\n   * @param section from configuration file provided as ConfigSection\n   */\n  RoutingPluginConfig(const mysql_harness::ConfigSection *section);\n\n  /**\n   * @param option option to get\n   */\n  std::string get_default(const std::string &option) const override;\n\n  bool is_required(const std::string &option) const override;\n\n  /** @brief `protocol` option read from configuration section */\n  const Protocol::Type protocol;\n  /** @brief `destinations` option read from configuration section */\n  const std::string destinations;\n  /** @brief `bind_port` option read from configuration section */\n  const int bind_port;\n  /** @brief `bind_address` option read from configuration section */\n  const mysql_harness::TCPAddress bind_address;\n  /** @brief `socket` option read from configuration section is stored as named_socket */\n  const mysql_harness::Path named_socket;\n  /** @brief `connect_timeout` option read from configuration section */\n  const int connect_timeout;\n  /** @brief `mode` option read from configuration section */\n  const routing::AccessMode mode;\n  /** @brief `routing_strategy` option read from configuration section */\n  routing::RoutingStrategy routing_strategy;\n  /** @brief `max_connections` option read from configuration section */\n  const int max_connections;\n  /** @brief `max_connect_errors` option read from configuration section */\n  const unsigned long long max_connect_errors;\n  /** @brief `client_connect_timeout` option read from configuration section */\n  const unsigned int client_connect_timeout;\n  /** @brief Size of buffer to receive packets */\n  const unsigned int net_buffer_length;\n  /** @brief memory in kilobytes allocated for thread's stack */\n  const unsigned int thread_stack_size;\nprotected:\n\nprivate:\n\n  routing::AccessMode get_option_mode(const mysql_harness::ConfigSection *section, const std::string &option) const;\n  routing::RoutingStrategy get_option_routing_strategy(const mysql_harness::ConfigSection *section, const std::string &option) const;\n  std::string get_option_destinations(const mysql_harness::ConfigSection *section, const std::string &option,\n                                      const Protocol::Type &protocol_type) const;\n  Protocol::Type get_protocol(const mysql_harness::ConfigSection *section, const std::string &option) const;\n};\n\n#endif // PLUGIN_CONFIG_ROUTING_INCLUDED\n"
  },
  {
    "path": "src/routing/src/protocol/base_protocol.h",
    "content": "/*\nCopyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\nThis program is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License, version 2.0,\nas published by the Free Software Foundation.\n\nThis program is also distributed with certain software (including\nbut not limited to OpenSSL) that is licensed under separate terms,\nas designated in a particular file or component or in included license\ndocumentation.  The authors of MySQL hereby grant you an additional\npermission to link the program and your derivative works with the\nseparately licensed software that they have included with MySQL.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef ROUTING_BASEPROTOCOL_INCLUDED\n#define ROUTING_BASEPROTOCOL_INCLUDED\n\n#include <cstdint>\n#include <string>\n#include <vector>\n#include \"mysqlrouter/mysql_protocol.h\"\n\n#ifndef _WIN32\n#include <unistd.h>\n#else\n#include <winsock2.h>\n#undef ERROR\n#endif\n\nusing RoutingProtocolBuffer = mysql_protocol::Packet::vector_t;\n\nnamespace routing {\n  class RoutingSockOpsInterface;\n}\n\nclass BaseProtocol {\npublic:\n\n  /** @brief supported protocols */\n  enum class Type {\n    kClassicProtocol,\n    kXProtocol\n  };\n\n  BaseProtocol(routing::RoutingSockOpsInterface *routing_sock_ops): routing_sock_ops_(routing_sock_ops) {}\n  virtual ~BaseProtocol() {}\n\n  /** @brief Function that gets called when the client is being blocked\n   *\n   * This function is called when the client is being blocked and should handle\n   * any communication to the server required by the protocol in such case\n   *\n   * @param server Descriptor of the server\n   * @param log_prefix prefix to be used by the function as a tag for logging\n   *\n   * @return true on success; false on error\n   */\n  virtual bool on_block_client_host(int server, const std::string &log_prefix) = 0;\n\n  /** @brief Reads from sender and writes it back to receiver using select\n   *\n   * This function reads data from the sender socket and writes it back\n   * to the receiver socket. It use `select`.\n   *\n   * @param sender Descriptor of the sender\n   * @param receiver Descriptor of the receiver\n   * @param sender_is_readable true if sender socket has data\n   * @param buffer Buffer to use for storage\n   * @param curr_pktnr Pointer to storage for sequence id of packet\n   * @param handshake_done Whether handshake phase is finished or not\n   * @param report_bytes_read Pointer to storage to report bytes read\n   * @param from_server true if the message sender is the server, false\n   *                    if it is a client\n   *\n   * @return 0 on success; -1 on error\n   */\n  virtual int copy_packets(int sender, int receiver, bool sender_is_readable,\n                           RoutingProtocolBuffer &buffer, int *curr_pktnr,\n                           bool &handshake_done, size_t *report_bytes_read,\n                           bool from_server) = 0;\n\n  /** @brief Sends error message to the provided receiver.\n   *\n   * This function sends protocol message containing MySQL error\n   *\n   * @param destination descriptor of the receiver\n   * @param code general error code\n   * @param message human readable error message\n   * @param sql_state SQL state for the error\n   * @param log_prefix prefix to be used by the function as a tag for logging\n   *\n   * @return true on success; false on error\n   */\n  virtual bool send_error(int destination,\n                          unsigned short code,\n                          const std::string &message,\n                          const std::string &sql_state,\n                          const std::string &log_prefix) = 0;\n\n  /** @brief Gets protocol type. */\n  virtual Type get_type() = 0;\nprotected:\n  routing::RoutingSockOpsInterface *routing_sock_ops_;\n};\n\n#endif // ROUTING_BASEPROTOCOL_INCLUDED\n"
  },
  {
    "path": "src/routing/src/protocol/classic_protocol.cc",
    "content": "/*\nCopyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\nThis program is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License, version 2.0,\nas published by the Free Software Foundation.\n\nThis program is also distributed with certain software (including\nbut not limited to OpenSSL) that is licensed under separate terms,\nas designated in a particular file or component or in included license\ndocumentation.  The authors of MySQL hereby grant you an additional\npermission to link the program and your derivative works with the\nseparately licensed software that they have included with MySQL.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"classic_protocol.h\"\n\n#include \"common.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysqlrouter/mysql_protocol.h\"\n#include \"mysqlrouter/routing.h\"\n#include \"../utils.h\"\n\n#include <cstring>\n\nusing mysql_harness::get_strerror;\nIMPORT_LOG_FUNCTIONS()\n\nbool ClassicProtocol::on_block_client_host(int server, const std::string &log_prefix) {\n  auto fake_response = mysql_protocol::HandshakeResponsePacket(1, {}, \"ROUTER\", \"\", \"fake_router_login\");\n  if (routing_sock_ops_->so()->write_all(server, fake_response.data(), fake_response.size()) < 0) {\n    log_debug(\"[%s] fd=%d write error: %s\",\n        log_prefix.c_str(),\n        server,\n        get_message_error(routing_sock_ops_->so()->get_errno()).c_str());\n    return false;\n  }\n  return true;\n}\n\nint ClassicProtocol::copy_packets(int sender, int receiver, bool sender_is_readable,\n                                  RoutingProtocolBuffer &buffer, int *curr_pktnr,\n                                  bool &handshake_done, size_t *report_bytes_read,\n                                  bool /*from_server*/) {\n  assert(curr_pktnr);\n  assert(report_bytes_read);\n  ssize_t res = 0;\n  int pktnr = 0;\n  auto buffer_length = buffer.size();\n\n  size_t bytes_read = 0;\n\n  if (!handshake_done && *curr_pktnr == 2) {\n    handshake_done = true;\n  }\n\n  mysql_harness::SocketOperationsBase* const so = routing_sock_ops_->so();\n  if (sender_is_readable) {\n    if ((res = so->read(sender, &buffer.front(), buffer_length)) <= 0) {\n      if (res == -1) {\n        const int last_errno = so->get_errno();\n\n        log_debug(\"fd=%d read failed: (%d %s)\",\n            sender,\n            last_errno, get_message_error(last_errno).c_str());\n      } else {\n        // the caller assumes that errno == 0 on plain connection closes.\n        so->set_errno(0);\n      }\n      return -1;\n    }\n\n    bytes_read += static_cast<size_t>(res);\n    if (!handshake_done) {\n      // Check packet integrity when handshaking. When packet number is 2, then we assume\n      // handshaking is satisfied. For secure connections, we stop when client asks to\n      // switch to SSL.\n      // The caller should set handshake_done to true when packet number is 2.\n      if (bytes_read < mysql_protocol::Packet::kHeaderSize) {\n        // We need packet which is at least 4 bytes\n        return -1;\n      }\n      pktnr = buffer[3];\n      if (*curr_pktnr > 0 && pktnr != *curr_pktnr + 1) {\n        log_debug(\"Received incorrect packet number; aborting (was %d)\", pktnr);\n        return -1;\n      }\n\n      if (buffer[4] == 0xff) {\n        // We got error from MySQL Server while handshaking\n        // We do not consider this a failed handshake\n\n        // copy part of the buffer containing serialized error\n        RoutingProtocolBuffer buffer_err(buffer.begin(), buffer.begin() +\n                                         static_cast<RoutingProtocolBuffer::iterator::difference_type>(bytes_read));\n\n        auto server_error = mysql_protocol::ErrorPacket(buffer_err);\n        if (so->write_all(receiver, server_error.data(), server_error.size()) < 0) {\n          log_debug(\"fd=%d write error: %s\",\n              receiver, get_message_error(so->get_errno()).c_str());\n        }\n        // receiver socket closed by caller\n        *curr_pktnr = 2; // we assume handshaking is done though there was an error\n        *report_bytes_read = bytes_read;\n        return 0;\n      }\n\n      // We are dealing with the handshake response from client\n      if (pktnr == 1) {\n        // if client is switching to SSL, we are not continuing any checks\n        mysql_protocol::Capabilities::Flags capabilities;\n        try {\n          auto pkt = mysql_protocol::Packet(buffer);\n          capabilities = mysql_protocol::Capabilities::Flags(pkt.read_int_from<uint32_t>(4));\n        } catch (const mysql_protocol::packet_error &exc) {\n          log_debug(\"%s\", exc.what());\n          return -1;\n        }\n        if (capabilities.test(mysql_protocol::Capabilities::SSL)) {\n          pktnr = 2;  // Setting to 2, we tell the caller that handshaking is done\n        }\n      }\n    }\n\n    if (so->write_all(receiver, &buffer[0], bytes_read) < 0) {\n      const int last_errno = so->get_errno();\n\n      log_debug(\"fd=%d write error: %s\",\n          receiver,\n          get_message_error(last_errno).c_str());\n      return -1;\n    }\n  }\n\n  *curr_pktnr = pktnr;\n  *report_bytes_read = bytes_read;\n\n  return 0;\n}\n\nbool ClassicProtocol::send_error(int destination,\n                                 unsigned short code,\n                                 const std::string &message,\n                                 const std::string &sql_state,\n                                 const std::string &log_prefix) {\n  auto server_error = mysql_protocol::ErrorPacket(0, code, message, sql_state);\n\n  mysql_harness::SocketOperationsBase* const so = routing_sock_ops_->so();\n  if (so->write_all(destination, server_error.data(), server_error.size()) < 0) {\n    log_debug(\"[%s] fd=%d write error: %s\", log_prefix.c_str(),\n        destination,\n        get_message_error(so->get_errno()).c_str());\n\n    return false;\n  }\n  return true;\n}\n"
  },
  {
    "path": "src/routing/src/protocol/classic_protocol.h",
    "content": "/*\nCopyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\nThis program is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License, version 2.0,\nas published by the Free Software Foundation.\n\nThis program is also distributed with certain software (including\nbut not limited to OpenSSL) that is licensed under separate terms,\nas designated in a particular file or component or in included license\ndocumentation.  The authors of MySQL hereby grant you an additional\npermission to link the program and your derivative works with the\nseparately licensed software that they have included with MySQL.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef ROUTING_CLASSICPROTOCOL_INCLUDED\n#define ROUTING_CLASSICPROTOCOL_INCLUDED\n\n#include \"base_protocol.h\"\n\n#include <string>\n\nclass ClassicProtocol: public BaseProtocol {\npublic:\n  ClassicProtocol(routing::RoutingSockOpsInterface *routing_sock_ops)\n      : BaseProtocol(routing_sock_ops) {}\n\n  /** @brief Function that gets called when the client is being blocked\n   *\n   * This function is called when the client is being blocked and should handle\n   * any communication to the server required by the protocol in such case\n   *\n   * @param server Descriptor of the server\n   * @param log_prefix prefix to be used by the function as a tag for logging\n   *\n   * @return true on success; false on error\n   */\n  virtual bool on_block_client_host(int server, const std::string &log_prefix) override;\n\n  /** @brief Reads from sender and writes it back to receiver using select\n   *\n   * This function reads data from the sender socket and writes it back\n   * to the receiver socket. It use `select`.\n   *\n   * Checking the handshaking is done when the client first connects and\n   * the server sends its handshake. The client replies and the server\n   * should reply with an OK (or Error) packet. This packet should be\n   * packet number 2. For secure connections, however, the client asks\n   * to switch to SSL and we can not check further packages (we can not\n   * decrypt). When SSL switch is detected, this function will set pktnr\n   * to 2, so we assume the handshaking was OK.\n   *\n   * @param sender Descriptor of the sender\n   * @param receiver Descriptor of the receiver\n   * @param sender_is_readable true if the server socket has data\n   * @param buffer Buffer to use for storage\n   * @param curr_pktnr Pointer to storage for sequence id of packet\n   * @param handshake_done Whether handshake phase is finished or not\n   * @param report_bytes_read Pointer to storage to report bytes read\n   * @param from_server true if the message sender is the server, false\n   *                    if it is a client\n   *\n   * @return 0 on success; -1 on error\n   */\n  virtual int copy_packets(int sender, int receiver, bool sender_is_readable,\n                           RoutingProtocolBuffer &buffer, int *curr_pktnr,\n                           bool &handshake_done, size_t *report_bytes_read,\n                           bool from_server) override;\n\n  /** @brief Sends error message to the provided receiver.\n   *\n   * This function sends protocol message containing MySQL error\n   *\n   * @param destination descriptor of the receiver\n   * @param code general error code\n   * @param message human readable error message\n   * @param sql_state SQL state for the error\n   * @param log_prefix prefix to be used by the function as a tag for logging\n   *\n   * @return true on success; false on error\n   */\n  virtual bool send_error(int destination,\n                          unsigned short code,\n                          const std::string &message,\n                          const std::string &sql_state,\n                          const std::string &log_prefix) override;\n\n  /** @brief Gets protocol type. */\n  virtual Type get_type() override {\n    return Type::kClassicProtocol;\n  }\n};\n\n#endif // ROUTING_CLASSICPROTOCOL_INCLUDED\n"
  },
  {
    "path": "src/routing/src/protocol/protocol.h",
    "content": "/*\nCopyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\nThis program is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License, version 2.0,\nas published by the Free Software Foundation.\n\nThis program is also distributed with certain software (including\nbut not limited to OpenSSL) that is licensed under separate terms,\nas designated in a particular file or component or in included license\ndocumentation.  The authors of MySQL hereby grant you an additional\npermission to link the program and your derivative works with the\nseparately licensed software that they have included with MySQL.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n#ifndef ROUTING_PROTOCOL_INCLUDED\n#define ROUTING_PROTOCOL_INCLUDED\n\n#include \"base_protocol.h\"\n#include \"classic_protocol.h\"\n#include \"x_protocol.h\"\n\n#include <cassert>\n#include <memory>\n\nclass Protocol final {\npublic:\n  using Type = BaseProtocol::Type;\n\n  static inline Type get_default() {\n    return Type::kClassicProtocol;\n  }\n\n  /** @brief Returns type of the protocol by its name\n   */\n  static Type get_by_name(const std::string &name) {\n    Type result = Type::kClassicProtocol;\n\n    if (name == \"classic\") {\n      /* already set */\n    }\n    else if (name == \"x\") {\n      result = Type::kXProtocol;\n    }\n    else {\n      throw std::invalid_argument(\"Invalid protocol name: '\" + name + \"'\");\n    }\n\n    return result;\n  }\n\n  /** @brief Factory method creating protocol object for handling the routing code that is protocol-specific\n   *\n   * @param type type of the protocol for which the handler should be created\n   * @param routing_sock_ops socket operations\n   *\n   * @returns pointer to the created object\n   */\n  static BaseProtocol* create(Type type,\n                              routing::RoutingSockOpsInterface *routing_sock_ops) {\n    BaseProtocol* result{nullptr};\n\n    switch (type ) {\n    case Type::kClassicProtocol:\n      result =  new ClassicProtocol(routing_sock_ops);\n      break;\n    case Type::kXProtocol:\n      result =  new XProtocol(routing_sock_ops);\n      break;\n    default:\n      throw std::invalid_argument(\"Invalid protocol: \" + std::to_string(static_cast<int>(type)));\n    }\n\n    return result;\n  }\n\n  /** @brief Returns default port for the selected protocol\n   */\n  static uint16_t get_default_port(Type type) {\n    uint16_t result{0};\n\n    switch (type ) {\n    case Type::kClassicProtocol:\n      result = kClassicProtocolDefaultPort;\n      break;\n    case Type::kXProtocol:\n      result = kXProtocolDefaultPort;\n      break;\n    default:\n      throw std::invalid_argument(\"Invalid protocol: \" + std::to_string(static_cast<int>(type)));\n    }\n\n    return result;\n  }\n\nprivate:\n  /** @brief default server ports for supported protocols */\n  static constexpr uint16_t kClassicProtocolDefaultPort{3306};\n  static constexpr uint16_t kXProtocolDefaultPort{33060};\n};\n\n#endif // ROUTING_PROTOCOL_INCLUDED\n"
  },
  {
    "path": "src/routing/src/protocol/x_protocol.cc",
    "content": "/*\nCopyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\nThis program is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License, version 2.0,\nas published by the Free Software Foundation.\n\nThis program is also distributed with certain software (including\nbut not limited to OpenSSL) that is licensed under separate terms,\nas designated in a particular file or component or in included license\ndocumentation.  The authors of MySQL hereby grant you an additional\npermission to link the program and your derivative works with the\nseparately licensed software that they have included with MySQL.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"common.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"x_protocol.h\"\n#include \"../utils.h\"\n#include \"mysqlrouter/routing.h\"\n\n#ifdef __GNUC__\n// disable -Wconversion for protobuf 2.6.\n// this can be removed with protobuf 3.0.x and later\n#pragma GCC diagnostic push\n#pragma GCC diagnostic warning \"-Wconversion\"\n#endif\n#include \"mysqlx.pb.h\"\n#include \"mysqlx_session.pb.h\"\n#include \"mysqlx_connection.pb.h\"\n#include <google/protobuf/io/coded_stream.h>\n#ifdef __GNUC__\n#pragma GCC diagnostic pop\n#endif\n\n#include <algorithm>\n#include <cassert>\n\nusing ProtobufMessage = google::protobuf::Message;\nIMPORT_LOG_FUNCTIONS()\n\nconstexpr size_t kMessageHeaderSize = 5;\n\nstatic bool send_message(const std::string &log_prefix,\n                         int destination,\n                         const int8_t type,\n                         const ProtobufMessage &msg,\n                         mysql_harness::SocketOperationsBase *sock_ops) {\n  using google::protobuf::io::CodedOutputStream;\n\n  const size_t msg_size = msg.ByteSize();\n  RoutingProtocolBuffer buffer(kMessageHeaderSize + msg_size);\n\n  // first 4 bytes is the message size (plus type byte, without size bytes)\n  CodedOutputStream::WriteLittleEndian32ToArray(static_cast<uint32_t>(msg_size + 1), &buffer[0]);\n  // fifth byte is the message type\n  buffer[kMessageHeaderSize-1] = static_cast<uint8_t>(type);\n\n  if ((msg.ByteSize() > 0) && (!msg.SerializeToArray(&buffer[kMessageHeaderSize], msg.ByteSize()))) {\n    log_error(\"[%s] error while serializing error message. Message size = %d\", log_prefix.c_str(), msg.ByteSize());\n    return false;\n  }\n\n  if (sock_ops->write_all(destination, &buffer[0], buffer.size()) < 0) {\n    const int last_errno = sock_ops->get_errno();\n\n    log_error(\"[%s] fd=%d write error: %s\", log_prefix.c_str(),\n        destination,\n        get_message_error(last_errno).c_str());\n    return false;\n  }\n\n  return true;\n}\n\nstatic bool message_valid(const void* message_buffer, const int8_t message_type, const uint32_t message_size) {\n  std::unique_ptr<google::protobuf::Message> msg;\n\n  assert(message_type == Mysqlx::ClientMessages::SESS_AUTHENTICATE_START\n         || message_type == Mysqlx::ClientMessages::CON_CAPABILITIES_GET\n         || message_type == Mysqlx::ClientMessages::CON_CAPABILITIES_SET\n         || message_type == Mysqlx::ClientMessages::CON_CLOSE);\n\n  switch (message_type) {\n  case Mysqlx::ClientMessages::SESS_AUTHENTICATE_START:\n    msg.reset(new Mysqlx::Session::AuthenticateStart());\n    break;\n  case Mysqlx::ClientMessages::CON_CAPABILITIES_GET:\n    msg.reset(new Mysqlx::Connection::CapabilitiesGet());\n    break;\n  case Mysqlx::ClientMessages::CON_CAPABILITIES_SET:\n    msg.reset(new Mysqlx::Connection::CapabilitiesSet());\n    break;\n  default: /* Mysqlx::ClientMessages::CON_CLOSE */\n    msg.reset(new Mysqlx::Connection::Close());\n  }\n\n  assert(msg.get() != nullptr);\n\n  // sanity check deserializing the message\n  if (!msg->ParseFromArray(message_buffer, static_cast<int>(message_size))) {\n    return false;\n  }\n\n  return true;\n}\n\nstatic bool get_next_message(int sender,\n                             RoutingProtocolBuffer &buffer,\n                             size_t   &buffer_contents_size,\n                             size_t   &message_offset,\n                             int8_t   &message_type,\n                             uint32_t &message_size,\n                             mysql_harness::SocketOperationsBase *sock_ops,\n                             bool &error) {\n  using google::protobuf::io::CodedInputStream;\n  error = false;\n  ssize_t read_res = 0;\n\n  assert(buffer_contents_size >= message_offset);\n  size_t bytes_left = buffer_contents_size - message_offset;\n\n  // no more messages to process\n  if (bytes_left == 0) {\n    return false;\n  }\n\n  // we need at least 4 bytes to know the message size\n  while (bytes_left < 4) {\n    read_res = sock_ops->read(sender, &buffer[message_offset + bytes_left], 4 - bytes_left);\n    if (read_res < 0) {\n      const int last_errno = sock_ops->get_errno();\n      log_error(\"fd=%d failed reading size of the message: (%d %s %ld)\",\n          sender,\n          last_errno, get_message_error(last_errno).c_str(), static_cast<long>(read_res));\n      error = true;\n      return false;\n    } else if (read_res == 0) {\n      // connection got closed on us\n\n      error = true;\n      return false;\n    }\n\n    buffer_contents_size += read_res;\n    bytes_left += read_res;\n  }\n\n  // we got the message size, we can decode it\n  CodedInputStream::ReadLittleEndian32FromArray(&buffer[message_offset], &message_size);\n\n  // If not the whole message is in the buffer we need to read the remaining part to be able to decode it.\n  // First let's check if the message will fit the buffer.\n  // Currently we decode the messages ONLY in the handshake phase when we expect relatively small messages:\n  // (AuthOk, AutCont, Notice, Error, CapabilitiesGet...)\n  // In case the message does not fit the buffer, we just return an error. This way we defend against the possibility\n  // of the client sending huge messages while authenticating.\n  size_t size_needed = message_offset + 4 + message_size;\n  if (buffer.size() < size_needed) {\n    log_error(\"X protocol message too big to fit the buffer: (%u, %lu, %lu)\", message_size,\n              static_cast<long unsigned>(buffer.size()), static_cast<long unsigned>(message_offset)); // 32bit Linux requires casts\n    error = true;\n    return false;\n  }\n  // next read the remaining part of the message if needed\n  while (message_size + 4 > bytes_left) {\n    read_res = sock_ops->read(sender, &buffer[message_offset+bytes_left], message_size + 4 - bytes_left);\n    if (read_res < 0) {\n      const int last_errno = sock_ops->get_errno();\n\n      log_error(\"fd=%d failed reading part of X protocol message: (%d %s %ld)\",\n          sender,\n          last_errno, get_message_error(last_errno).c_str(), static_cast<long>(read_res));\n\n      error = true;\n      return false;\n    } else if (read_res == 0) {\n      // connection got closed on us.\n      error = true;\n      return false;\n    }\n\n    buffer_contents_size += read_res;\n    bytes_left += read_res;\n  }\n\n  message_type = buffer[message_offset + kMessageHeaderSize - 1];\n\n  return true;\n}\n\nint XProtocol::copy_packets(int sender, int receiver, bool sender_is_readable,\n                            RoutingProtocolBuffer &buffer, int * /*curr_pktnr*/,\n                            bool &handshake_done, size_t *report_bytes_read,\n                            bool from_server) {\n  assert(report_bytes_read != nullptr);\n\n  ssize_t res = 0;\n  auto buffer_length = buffer.size();\n  size_t bytes_read = 0;\n\n  mysql_harness::SocketOperationsBase* const so = routing_sock_ops_->so();\n  if (sender_is_readable) {\n    if ((res = so->read(sender, &buffer.front(), buffer_length)) <= 0) {\n      if (res == -1) {\n        const int last_errno = so->get_errno();\n        log_error(\"fd=%d sender read failed: (%d %s)\",\n            sender,\n            last_errno, get_message_error(last_errno).c_str());\n      } else {\n        // the caller assumes that errno == 0 on plain connection closes.\n        so->set_errno(0);\n      }\n      return -1;\n    }\n    bytes_read += static_cast<size_t>(res);\n    if (!handshake_done) {\n      // check packets integrity when handshaking.\n      // we stop inspecting the messages when the client sends\n      // AuthenticateStart or CapabilitesGet as a first message\n      // that should be enough to prevent the MySQL Server from considering\n      // the connection as an error even if it is terminated after that.\n      int8_t message_type;\n      size_t message_offset = 0;\n      uint32_t message_size = 0;\n      // the buffer can contain partial message or more than one message\n      // the loop is to make sure that all messages are inspected\n      // and that the whole message that is being processed is in the buffer\n      bool msg_read_error = false;\n      while (get_next_message(sender, buffer, bytes_read, message_offset, message_type,\n                              message_size, so, msg_read_error)\n             && !msg_read_error) {\n\n\n        if (!from_server) {\n          // the first message from the client. We need to check if it's correct.\n          if (message_type == Mysqlx::ClientMessages::SESS_AUTHENTICATE_START\n                  || message_type == Mysqlx::ClientMessages::CON_CAPABILITIES_GET\n                  || message_type == Mysqlx::ClientMessages::CON_CAPABILITIES_SET\n                  || message_type == Mysqlx::ClientMessages::CON_CLOSE) {\n            // validate the message\n            if (!message_valid(&buffer[message_offset+kMessageHeaderSize], message_type, message_size-1)) {\n              log_warning(\"Invalid message content: type(%hhu), size(%u)\", message_type, message_size-1);\n              return -1;\n            }\n            handshake_done = true;\n            break;\n          }\n          else {\n            // any other message at this point is not allowed by the x protocol and would make\n            // MySQL Server consider this connection an error which we need to prevent\n            log_warning(\"Received incorrect message type from the client while handshaking (was %hhu)\",\n                        message_type);\n            return -1;\n          }\n        }\n\n        if (from_server && message_type == Mysqlx::ServerMessages::ERROR) {\n          // if the server sends an error we don't consider it a failed handshake.\n          // this is to have parity with how we behave in case of classic protocol\n          // where error from the server (even ACCESS DENIED) does not increment\n          // error connection counter\n          handshake_done = true;\n          break;\n        }\n\n        message_offset += (message_size + 4);\n      }\n\n      if (msg_read_error) {\n        return -1;\n      }\n    }\n\n    if (so->write_all(receiver, &buffer[0], bytes_read) < 0) {\n      const int last_errno = so->get_errno();\n      log_error(\"fd=%d write error: %s\",\n          receiver,\n          get_message_error(last_errno).c_str());\n      return -1;\n    }\n  }\n  *report_bytes_read = bytes_read;\n\n  return 0;\n}\n\nbool XProtocol::send_error(int destination,\n                           unsigned short code,\n                           const std::string &message,\n                           const std::string &sql_state,\n                           const std::string &log_prefix) {\n  Mysqlx::Error error;\n  error.set_code(code);\n  error.set_sql_state(sql_state);\n  error.set_msg(message);\n\n  return send_message(log_prefix, destination, Mysqlx::ServerMessages::ERROR,\n                      error, routing_sock_ops_->so());\n}\n\n\nbool XProtocol::on_block_client_host(int server, const std::string &log_prefix) {\n  // currently the MySQL Server (X-Plugin) does not have the feature of blocking\n  // the client after reaching certain threshold of unsuccesfull connection attemps (max_connect_errors)\n  // When this is done, the code here needs to be revised to check if it prevents the server from\n  // considering the connection as an error and blaming the router for it.\n\n  // at the moment we send CapabilitiesGet message to the server assuming this will prevent the\n  // MySQL Server from considering the connection as an error and incrementing the counter.\n  Mysqlx::Connection::CapabilitiesGet capabilities_get;\n\n  return send_message(log_prefix, server, Mysqlx::ClientMessages::CON_CAPABILITIES_GET,\n                      capabilities_get, routing_sock_ops_->so());\n}\n"
  },
  {
    "path": "src/routing/src/protocol/x_protocol.h",
    "content": "/*\nCopyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\nThis program is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License, version 2.0,\nas published by the Free Software Foundation.\n\nThis program is also distributed with certain software (including\nbut not limited to OpenSSL) that is licensed under separate terms,\nas designated in a particular file or component or in included license\ndocumentation.  The authors of MySQL hereby grant you an additional\npermission to link the program and your derivative works with the\nseparately licensed software that they have included with MySQL.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program; if not, write to the Free Software\nFoundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n#ifndef ROUTING_XPROTOCOL_INCLUDED\n#define ROUTING_XPROTOCOL_INCLUDED\n\n#include \"base_protocol.h\"\n\n#include <memory>\n\nclass XProtocol: public BaseProtocol {\npublic:\n  XProtocol(routing::RoutingSockOpsInterface *routing_sock_ops)\n      : BaseProtocol(routing_sock_ops) {}\n\n  /** @brief Function that gets called when the client is being blocked\n   *\n   * This function is called when the client is being blocked and should handle\n   * any communication to the server required by the protocol in such case\n   *\n   * @param server Descriptor of the server\n   * @param log_prefix prefix to be used by the function as a tag for logging\n   *\n   * @return true on success; false on error\n   *\n   */\n  virtual bool on_block_client_host(int server, const std::string &log_prefix) override;\n\n  /** @brief Reads from sender and writes it back to receiver using select\n   *\n   * This function reads data from the sender socket and writes it back\n   * to the receiver socket. It use `select`.\n   *\n   * @param sender Descriptor of the sender\n   * @param receiver Descriptor of the receiver\n   * @param sender_is_readable true if sender socket has data\n   * @param buffer Buffer to use for storage\n   * @param curr_pktnr Pointer to storage for sequence id of packet\n   * @param handshake_done Whether handshake phase is finished or not\n   * @param report_bytes_read Pointer to storage to report bytes read\n   * @param from_server true if the message sender is the server, false\n   *                    if it is a client\n   *\n   * @return 0 on success; -1 on error\n   */\n  virtual int copy_packets(int sender, int receiver, bool sender_is_readable,\n                           RoutingProtocolBuffer &buffer, int *curr_pktnr,\n                           bool &handshake_done, size_t *report_bytes_read,\n                           bool from_server) override;\n\n  /** @brief Sends error message to the provided receiver.\n   *\n   * This function sends protocol message containing MySQL error\n   *\n   * @param destination descriptor of the receiver\n   * @param code general error code\n   * @param message human readable error message\n   * @param sql_state SQL state for the error\n   * @param log_prefix prefix to be used by the function as a tag for logging\n   *\n   * @return true on success; false on error\n   */\n  virtual bool send_error(int destination,\n                          unsigned short code,\n                          const std::string &message,\n                          const std::string &sql_state,\n                          const std::string &log_prefix) override;\n\n  /** @brief Gets protocol type. */\n  virtual Type get_type() override {\n    return Type::kXProtocol;\n  }\n};\n\n#endif // ROUTING_XPROTOCOL_INCLUDED\n"
  },
  {
    "path": "src/routing/src/routing.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysqlrouter/routing.h\"\n#include \"mysqlrouter/utils.h\"\n#include \"router_config.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"common.h\"\n#include \"utils.h\"\n\n#include <cstring>\n#include <climits>\n\n#ifndef _WIN32\n# include <fcntl.h>\n# include <netdb.h>\n# include <netinet/tcp.h>\n# include <sys/socket.h>\n# include <poll.h>\n#else\n# define WIN32_LEAN_AND_MEAN\n# include <windows.h>\n# include <winsock2.h>\n# include <ws2tcpip.h>\n#endif\n\nusing mysqlrouter::to_string;\nusing mysqlrouter::string_format;\nusing mysql_harness::TCPAddress;\nIMPORT_LOG_FUNCTIONS()\n\nnamespace routing {\n\nconst int kDefaultWaitTimeout = 0; // 0 = no timeout used\nconst int kDefaultMaxConnections = 512;\nconst std::chrono::seconds kDefaultDestinationConnectionTimeout { 1 };\nconst std::string kDefaultBindAddress = \"127.0.0.1\";\nconst unsigned int kDefaultNetBufferLength = 16384;  // Default defined in latest MySQL Server\nconst unsigned long long kDefaultMaxConnectErrors = 100;  // Similar to MySQL Server\nconst std::chrono::seconds kDefaultClientConnectTimeout { 9 }; // Default connect_timeout MySQL Server minus 1\n\n// unused constant\n// const int kMaxConnectTimeout = INT_MAX / 1000;\n\n\n// keep in-sync with enum AccessMode\nconst std::vector<const char*> kAccessModeNames {\n  nullptr, \"read-write\", \"read-only\"\n};\n\nAccessMode get_access_mode(const std::string& value) {\n  for (unsigned int i = 1 ; i < kAccessModeNames.size() ; ++i)\n    if (strcmp(kAccessModeNames[i], value.c_str()) == 0)\n      return static_cast<AccessMode>(i);\n  return AccessMode::kUndefined;\n}\n\nstd::string get_access_mode_names() {\n  // +1 to skip undefined\n  return mysql_harness::serial_comma(kAccessModeNames.begin()+1, kAccessModeNames.end());\n}\n\nstd::string get_access_mode_name(AccessMode access_mode) noexcept {\n  return kAccessModeNames[static_cast<int>(access_mode)];\n}\n\n// keep in-sync with enum RoutingStrategy\nconst std::vector<const char*> kRoutingStrategyNames {\n  nullptr, \"first-available\", \"next-available\", \"round-robin\", \"round-robin-with-fallback\"\n};\n\n\nRoutingStrategy get_routing_strategy(const std::string& value) {\n  for (unsigned int i = 1 ; i < kRoutingStrategyNames.size() ; ++i)\n    if (strcmp(kRoutingStrategyNames[i], value.c_str()) == 0)\n      return static_cast<RoutingStrategy>(i);\n  return RoutingStrategy::kUndefined;\n}\n\nstd::string get_routing_strategy_names(bool metadata_cache) {\n  // round-robin-with-fallback is not supported for static routing\n  const std::vector<const char*> kRoutingStrategyNamesStatic {\n    \"first-available\", \"next-available\", \"round-robin\"\n  };\n\n  // next-available is not supported for metadata-cache routing\n  const std::vector<const char*> kRoutingStrategyNamesMetadataCache {\n    \"first-available\", \"round-robin\", \"round-robin-with-fallback\"\n  };\n\n  const auto& v = metadata_cache ? kRoutingStrategyNamesMetadataCache: kRoutingStrategyNamesStatic;\n  return mysql_harness::serial_comma(v.begin(), v.end());\n}\n\nstd::string get_routing_strategy_name(RoutingStrategy routing_strategy) noexcept {\n  return kRoutingStrategyNames[static_cast<int>(routing_strategy)];\n}\n\nvoid set_socket_blocking(int sock, bool blocking) {\n\n  assert(!(sock < 0));\n#ifndef _WIN32\n  auto flags = fcntl(sock, F_GETFL, nullptr);\n  assert(flags >= 0);\n  if (blocking) {\n    flags &= ~O_NONBLOCK;\n  } else {\n    flags |= O_NONBLOCK;\n  }\n  fcntl(sock, F_SETFL, flags);\n#else\n  u_long mode = blocking ? 0 : 1;\n  ioctlsocket(sock, FIONBIO, &mode);\n#endif\n}\n\nRoutingSockOps* RoutingSockOps::instance(mysql_harness::SocketOperationsBase* sock_ops) {\n  static RoutingSockOps routing_sock_ops(sock_ops);\n  return &routing_sock_ops;\n}\n\nint RoutingSockOps::get_mysql_socket(mysql_harness::TCPAddress addr, std::chrono::milliseconds connect_timeout_ms, bool log) noexcept {\n  struct addrinfo *servinfo, *info, hints;\n\n  memset(&hints, 0, sizeof hints);\n  hints.ai_family = AF_UNSPEC;\n  hints.ai_socktype = SOCK_STREAM;\n  bool timeout_expired = false;\n\n  int err;\n  if ((err = ::getaddrinfo(addr.addr.c_str(), to_string(addr.port).c_str(), &hints, &servinfo)) != 0) {\n    if (log) {\n#ifndef _WIN32\n      std::string errstr{(err == EAI_SYSTEM) ? get_message_error(so_->get_errno()) : gai_strerror(err)};\n#else\n      std::string errstr = get_message_error(err);\n#endif\n      log_debug(\"Failed getting address information for '%s' (%s)\", addr.addr.c_str(), errstr.c_str());\n    }\n    return -1;\n  }\n\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){if (servinfo) freeaddrinfo(servinfo);});\n\n  int sock = routing::kInvalidSocket;\n\n  for (info = servinfo; info != nullptr; info = info->ai_next) {\n    if ((sock = ::socket(info->ai_family, info->ai_socktype, info->ai_protocol)) == -1) {\n      log_error(\"Failed opening socket: %s\", get_message_error(so_->get_errno()).c_str());\n    } else {\n      bool connection_is_good = true;\n\n      set_socket_blocking(sock, false);\n\n      if (::connect(sock, info->ai_addr, info->ai_addrlen) < 0) {\n        switch (so_->get_errno()) {\n#ifdef _WIN32\n          case WSAEINPROGRESS:\n          case WSAEWOULDBLOCK:\n#else\n          case EINPROGRESS:\n#endif\n            if (0 != so_->connect_non_blocking_wait(sock, connect_timeout_ms)) {\n              log_warning(\"Timeout reached trying to connect to MySQL Server %s: %s\", addr.str().c_str(), get_message_error(so_->get_errno()).c_str());\n              connection_is_good = false;\n              timeout_expired = (so_->get_errno() == ETIMEDOUT);\n              break;\n            }\n\n            {\n              int so_error = 0;\n              if (0 != so_->connect_non_blocking_status(sock, so_error)) {\n                connection_is_good = false;\n                break;\n              }\n            }\n\n            // success, we can continue\n            break;\n          default:\n            log_debug(\"Failed connect() to %s: %s\", addr.str().c_str(), get_message_error(so_->get_errno()).c_str());\n            connection_is_good = false;\n            break;\n        }\n      } else {\n        // everything is fine, we are connected\n      }\n\n      if (connection_is_good) {\n        break;\n      }\n\n      // some error, close the socket again and try the next one\n      so_->close(sock);\n    }\n  }\n\n  if (info == nullptr) {\n    // all connects failed.\n    return timeout_expired ? -2 : -1;\n  }\n\n  // set blocking; MySQL protocol is blocking and we do not take advantage of\n  // any non-blocking possibilities\n  set_socket_blocking(sock, true);\n\n  int opt_nodelay = 1;\n  if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY,\n                 reinterpret_cast<const char*>(&opt_nodelay), // cast keeps Windows happy (const void* on Unix)\n                 static_cast<socklen_t>(sizeof(int))) == -1) {\n    log_debug(\"Failed setting TCP_NODELAY on client socket\");\n    so_->close(sock);\n\n    return -1;\n  }\n\n  return sock;\n}\n\n} // routing\n"
  },
  {
    "path": "src/routing/src/routing_plugin.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"plugin_config.h\"\n#include \"mysql_routing.h\"\n#include \"utils.h\"\n\n#include \"dim.h\"\n#include \"mysql/harness/loader_config.h\"\n\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysql/harness/config_parser.h\"\n\n#include <atomic>\n#include <iostream>\n#include <mutex>\n#include <vector>\n\nusing mysql_harness::AppInfo;\nusing mysql_harness::ConfigSection;\nusing mysql_harness::TCPAddress;\nusing mysqlrouter::URI;\nusing mysqlrouter::URIError;\nusing std::string;\nIMPORT_LOG_FUNCTIONS()\n\nconst mysql_harness::AppInfo *g_app_info;\nstatic const string kSectionName = \"routing\";\n\nstatic void validate_socket_info(const std::string& err_prefix,\n                                 const mysql_harness::ConfigSection* section,\n                                 const RoutingPluginConfig& config) {\n\n  auto is_valid_port = [](int port)->bool {\n    return 0 < port && port < 65536;\n  };\n\n  TCPAddress config_addr = config.bind_address; // we have to make a copy because TCPAddress::is_valid() is non-const\n\n  bool have_named_sock = section->has(\"socket\");\n  bool have_bind_port  = section->has(\"bind_port\");\n  bool have_bind_addr  = section->has(\"bind_address\");\n  bool have_bind_addr_port = have_bind_addr && config.bind_address.port != 0;\n\n  // NOTE: Several test scenarios below are also covered by RoutingPluginConfig() constructor's simple check.\n  //       However, RoutingPluginConfig() doesn't check everything, and sometimes produces misleading error messages\n  //       (when bind_address has no port number, and bind_port is not provided, is one such example; passing empty\n  //       socket is another).\n  //       Below tests should probably replace the simple check in that constructor, and get called from both places.\n\n  // validate bind_port\n  if (have_bind_port && !is_valid_port(config.bind_port))\n  {\n    throw std::invalid_argument(err_prefix + \"invalid bind_port '\" + std::to_string(config.bind_port) + \"'\");\n  }\n\n  // validate bind_address : IP\n  if (have_bind_addr && !config_addr.is_valid()) {\n    throw std::invalid_argument(err_prefix + \"invalid IP or name in bind_address '\" + config_addr.str() + \"'\");\n  }\n\n  // validate bind_address : TCP port\n  if (have_bind_addr_port && !is_valid_port(config.bind_address.port))\n  {\n    throw std::invalid_argument(err_prefix + \"invalid bind_address '\" + config.bind_address.str() + \"'\");\n  }\n\n  // validate socket\n  if (have_named_sock && !config.named_socket.is_set()) {\n    throw std::invalid_argument(err_prefix + \"invalid socket '\" + config.named_socket.str() + \"'\");\n  }\n\n  // check if we have enough information to open some listening socket (a Unix socket/Windows named pipe or a TCP socket)\n  if (!(have_named_sock || have_bind_port || have_bind_addr_port)) {\n    if (have_bind_addr) {\n      throw std::invalid_argument(err_prefix + \"no socket, no bind_port, and TCP port in bind_address is not provided\");\n    } else {\n      throw std::invalid_argument(err_prefix + \"one of bind_port, bind_address, or socket is required\");\n    }\n  }\n}\n\n// a non-static gateway function, meant to be called only by unit tests (to allow calling validate_socket_info(), which is static)\nvoid validate_socket_info_test_proxy(const std::string& err_prefix, const mysql_harness::ConfigSection* section, const RoutingPluginConfig& config) {\n  validate_socket_info(err_prefix, section, config);\n}\n\nstatic void init(mysql_harness::PluginFuncEnv* env) {\n  const mysql_harness::AppInfo* info = get_app_info(env);\n\n  try {\n    if (info->config != nullptr) {\n      bool have_metadata_cache = false;\n      bool need_metadata_cache = false;\n      std::vector<TCPAddress> bind_addresses;\n      for (const mysql_harness::ConfigSection* section: info->config->sections()) {\n        if (section->name == kSectionName) {\n          string err_prefix = mysqlrouter::string_format(\"in [%s%s%s]: \", section->name.c_str(),\n                                                         section->key.empty() ? \"\" : \":\",\n                                                         section->key.c_str());\n          // Check the configuration\n          RoutingPluginConfig config(section);                // throws std::invalid_argument\n          validate_socket_info(err_prefix, section, config);  // throws std::invalid_argument\n\n          // ensure that TCP port is unique\n          if (config.bind_address.port) {\n\n            const TCPAddress& config_addr = config.bind_address;\n\n            // Check uniqueness of bind_address and port, using IP address\n            std::vector<TCPAddress>::iterator found_addr = std::find(bind_addresses.begin(), bind_addresses.end(), config.bind_address);\n            if (found_addr != bind_addresses.end()) {\n              throw std::invalid_argument(err_prefix + \"duplicate IP or name found in bind_address '\" +\n                                            config.bind_address.str() + \"'\");\n            }\n            // Check ADDR_ANY binding on same port\n            else if (config_addr.addr == \"0.0.0.0\" || config_addr.addr == \"::\") {\n              found_addr = std::find_if(bind_addresses.begin(), bind_addresses.end(), [&config](TCPAddress &addr) {\n                return config.bind_address.port == addr.port;\n              });\n              if (found_addr != bind_addresses.end()) {\n                throw std::invalid_argument(\n                    err_prefix + \"duplicate IP or name found in bind_address '\" + config.bind_address.str() + \"'\");\n              }\n            }\n            bind_addresses.push_back(config.bind_address);\n          }\n\n\n          // We check if we need special plugins based on URI\n          try {\n            auto uri = URI(config.destinations, false);\n            if (uri.scheme == \"metadata-cache\") {\n              need_metadata_cache = true;\n            }\n          } catch (URIError&) {\n            // No URI, no extra plugin needed\n          }\n        } else if (section->name == \"metadata_cache\") {\n          have_metadata_cache = true;\n        }\n      }\n\n      if (need_metadata_cache && !have_metadata_cache) {\n        throw std::invalid_argument(\"Routing needs Metadata Cache, but no none \"\n                                    \"was found in configuration.\");\n      }\n    }\n    g_app_info = info;\n  } catch (const std::invalid_argument& exc) {\n    log_error(\"%s\", exc.what());  // TODO remove after Loader starts logging\n    set_error(env, mysql_harness::kConfigInvalidArgument, \"%s\", exc.what());\n  } catch (const std::exception& exc) {\n    log_error(\"%s\", exc.what());  // TODO remove after Loader starts logging\n    set_error(env, mysql_harness::kRuntimeError, \"%s\", exc.what());\n  } catch (...) {\n    log_error(\"Unexpected exception\");  // TODO remove after Loader starts logging\n    set_error(env, mysql_harness::kUndefinedError, \"Unexpected exception\");\n  }\n}\n\nstatic void start(mysql_harness::PluginFuncEnv* env) {\n  const mysql_harness::ConfigSection* section = get_config_section(env);\n\n  string name;\n  if (!section->key.empty()) {\n    name = section->name + \":\" + section->key;\n  } else {\n    name = section->name;\n  }\n\n  try {\n    RoutingPluginConfig config(section);\n    config.section_name = name;\n\n    // connect_timeout is in seconds, we want milli's\n    //\n    std::chrono::milliseconds destination_connect_timeout(config.connect_timeout * 1000);\n    std::chrono::milliseconds client_connect_timeout(config.client_connect_timeout * 1000);\n\n    MySQLRouting r(config.routing_strategy,\n                   config.bind_address.port,\n                   config.protocol,\n                   config.mode,\n                   config.bind_address.addr,\n                   config.named_socket,\n                   name,\n                   config.max_connections,\n                   destination_connect_timeout,\n                   config.max_connect_errors,\n                   client_connect_timeout,\n                   routing::kDefaultNetBufferLength,\n                   routing::RoutingSockOps::instance(mysql_harness::SocketOperations::instance()),\n                   config.thread_stack_size);\n\n    try {\n      // don't allow rootless URIs as we did already in the get_option_destinations()\n      r.set_destinations_from_uri(URI(config.destinations, false));\n    } catch (URIError&) {\n      r.set_destinations_from_csv(config.destinations);\n    }\n    r.start(env);\n  } catch (const std::invalid_argument &exc) {\n    log_error(\"%s\", exc.what());  // TODO remove after Loader starts logging\n    set_error(env, mysql_harness::kConfigInvalidArgument, \"%s\", exc.what());\n  } catch (const std::runtime_error &exc) {\n    log_error(\"%s: %s\", name.c_str(), exc.what());  // TODO remove after Loader starts logging\n    set_error(env, mysql_harness::kRuntimeError, \"%s: %s\", name.c_str(), exc.what());\n  } catch (...) {\n    log_error(\"Unexpected exception\");  // TODO remove after Loader starts logging\n    set_error(env, mysql_harness::kUndefinedError, \"Unexpected exception\");\n  }\n}\n\nextern \"C\" {\n  mysql_harness::Plugin ROUTING_API harness_plugin_routing = {\n      mysql_harness::PLUGIN_ABI_VERSION,\n      mysql_harness::ARCHITECTURE_DESCRIPTOR,\n      \"Routing MySQL connections between MySQL clients/connectors and servers\",\n      VERSION_NUMBER(0, 0, 1),\n      0, nullptr, // requires\n      0, nullptr, // Conflicts\n      init,       // init\n      nullptr,    // deinit\n      start,      // start\n      nullptr     // stop\n  };\n}\n"
  },
  {
    "path": "src/routing/src/utils.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"utils.h\"\n\n#include <algorithm>\n#include <assert.h>\n#include <cstring>\n#include <stdexcept>\n#include <stdlib.h>\n\n#ifndef _MSC_VER\n# include <arpa/inet.h>\n# include <fcntl.h>\n# include <sys/socket.h>\n# include <sys/un.h>\n#else\n# define WIN32_LEAN_AND_MEAN\n# include <windows.h>\n# include <winsock2.h>\n# include <ws2tcpip.h>\n# include <stdint.h>\n#endif\n\nvoid *get_in_addr(struct sockaddr *addr) {\n  if (addr->sa_family == AF_INET) {\n    return &(((struct sockaddr_in *) addr)->sin_addr);\n  }\n\n  return &(((struct sockaddr_in6 *) addr)->sin6_addr);\n}\n\nstd::pair<std::string, int > get_peer_name(int sock) {\n  socklen_t sock_len;\n  struct sockaddr_storage addr;\n  char result_addr[105];  // For IPv4, IPv6 and Unix socket\n  int port;\n\n  sock_len = static_cast<socklen_t>(sizeof addr);\n  getpeername(sock, (struct sockaddr*)&addr, &sock_len);\n\n  if (addr.ss_family == AF_INET6) {\n    // IPv6\n    auto *sin6 = (struct sockaddr_in6 *)&addr;\n    port = ntohs(sin6->sin6_port);\n    inet_ntop(AF_INET6, &sin6->sin6_addr, result_addr, static_cast<socklen_t>(sizeof result_addr));\n  } else if (addr.ss_family == AF_INET) {\n    // IPv4\n    auto *sin4 = (struct sockaddr_in *)&addr;\n    port = ntohs(sin4->sin_port);\n    inet_ntop(AF_INET, &sin4->sin_addr, result_addr, static_cast<socklen_t>(sizeof result_addr));\n  } else if (addr.ss_family == AF_UNIX) {\n    // Unix socket, no good way to find peer\n    return std::make_pair(std::string(\"unix socket\"), 0);\n  }\n\n  return std::make_pair(std::string(result_addr), port);\n}\n\nstd::vector<std::string> split_string(const std::string& data, const char delimiter, bool allow_empty) {\n  std::stringstream ss(data);\n  std::string token;\n  std::vector<std::string> result;\n\n  if (data.empty()) {\n    return {};\n  }\n\n  while (std::getline(ss, token, delimiter)) {\n    if (token.empty() && !allow_empty) {\n      // Skip empty\n      continue;\n    }\n    result.push_back(token);\n  }\n\n  // When last character is delimiter, it denotes an empty token\n  if (allow_empty && data.back() == delimiter) {\n    result.push_back(\"\");\n  }\n\n  return result;\n}\n\nstd::vector<std::string> split_string(const std::string& data, const char delimiter) {\n  return split_string(data, delimiter, true);\n}\n\nClientIpArray in_addr_to_array(const sockaddr_storage &addr) {\n  ClientIpArray result{{0}};\n\n  switch (addr.ss_family) {\n  case AF_INET6:\n    {\n      const sockaddr_in6 *addr_intet6 = reinterpret_cast<const sockaddr_in6*>(&addr);\n      std::memcpy(result.data(), &addr_intet6->sin6_addr, sizeof(addr_intet6->sin6_addr));\n      break;\n    }\n  default:\n    {\n      const sockaddr_in *addr_intet = reinterpret_cast<const sockaddr_in*>(&addr);\n      std::memcpy(result.data(), &addr_intet->sin_addr, sizeof(addr_intet->sin_addr));\n    }\n  }\n\n  return result;\n}\n\n\nstd::string get_message_error(int errcode)\n{\n#ifndef _WIN32\n  return std::string(strerror(errcode));\n#else\n  if (errcode == SOCKET_ERROR || errcode == 0) {\n    errcode = WSAGetLastError();\n  }\n  LPTSTR lpMsgBuf;\n\n  if (0 != FormatMessage(\n    FORMAT_MESSAGE_ALLOCATE_BUFFER |\n    FORMAT_MESSAGE_FROM_SYSTEM |\n    FORMAT_MESSAGE_IGNORE_INSERTS,\n    NULL,\n    errcode,\n    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),\n    (LPTSTR)&lpMsgBuf,\n    0, NULL)) {\n    std::string msgerr = \"SystemError: \";\n    msgerr += lpMsgBuf;\n    LocalFree(lpMsgBuf);\n    return msgerr;\n  } else {\n    return \"SystemError: \" + std::to_string(errcode);\n  }\n#endif\n}\n"
  },
  {
    "path": "src/routing/src/utils.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef UTILS_ROUTING_INCLUDED\n#define UTILS_ROUTING_INCLUDED\n\n#include <array>\n#include <iostream>\n#include <sstream>\n#include <vector>\n#ifndef _WIN32\n# include <netinet/in.h>\n# include <netdb.h>\n# include <unistd.h>\n#else\n# define WIN32_LEAN_AND_MEAN\n# include <windows.h>\n# include <winsock2.h>\n# include <ws2tcpip.h>\n# include <stdint.h>\n#endif\n\nusing ClientIpArray = std::array<uint8_t, 16>;\n\n/**\n * Socket address from either IPv4 or IPv6\n *\n * @param addr addrinfo struct\n * @return struct in_addr\n */\nvoid * get_in_addr(struct sockaddr *addr);\n\n/**\n * Get address of connected peer\n *\n * Get address of peer connected to the specified\n * socket. This works similar as getpeername() but will handle\n * IPv4, IPv6 and Unix sockets/Windows named pipes.\n *\n * @param sock socket\n * @return std::pair with std::string and uint16_t\n */\nstd::pair<std::string, int > get_peer_name(int sock);\n\n/**\n * Splits a string using a delimiter\n *\n * @param data a string to split\n * @param delimiter a char used as delimiter\n * @param allow_empty whether to allow empty tokens or not (default true)\n * @return std::vector<string> containing tokens\n */\nstd::vector<std::string> split_string(const std::string& data, const char delimiter, bool allow_empty);\n\n/** @overload */\nstd::vector<std::string> split_string(const std::string& data, const char delimiter);\n\n/** @brief Converts IP addr to std::array\n *\n * Converts a IP address stored in a sockaddr_storage struct to a\n * std::array of size 16.\n *\n * @param addr a sockaddr_storage struct\n * @return ClientIpArray\n */\nClientIpArray in_addr_to_array(const sockaddr_storage& addr);\n\nstd::string get_message_error(int errcode);\n\n#endif // UTILS_ROUTING_INCLUDED\n"
  },
  {
    "path": "src/routing/tests/CMakeLists.txt",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\ninclude_directories(\n  ../include\n  ../src\n  ${PROJECT_SOURCE_DIR}/src/metadata_cache/include\n  ${PROJECT_SOURCE_DIR}/src/mysql_protocol/include\n  ${PROJECT_SOURCE_DIR}/src/x_protocol/include\n  ../../../tests/helpers\n  ${PROJECT_BINARY_DIR}/generated/protobuf\n  ${PROTOBUF_INCLUDE_DIR}\n)\n\ncheck_cxx_compiler_flag(\"-Wshadow\" CXX_HAVE_SHADOW)\nif(CXX_HAVE_SHADOW)\n  add_compile_flags(${ROUTING_SOURCE_FILES} COMPILE_FLAGS\n    \"-Wno-shadow\")\n  add_compile_flags(${CMAKE_CURRENT_SOURCE_DIR}/test_x_protocol.cc\n    COMPILE_FLAGS \"-Wno-shadow\")\nendif()\ncheck_cxx_compiler_flag(\"-Wsign-conversion\" CXX_HAVE_SIGN_CONVERSION)\nif(CXX_HAVE_SIGN_CONVERSION)\n  add_compile_flags(${ROUTING_SOURCE_FILES} COMPILE_FLAGS\n    \"-Wno-sign-conversion\")\n  add_compile_flags(${CMAKE_CURRENT_SOURCE_DIR}/test_x_protocol.cc\n    COMPILE_FLAGS \"-Wno-sign-conversion\")\nendif()\ncheck_cxx_compiler_flag(\"-Wunused-parameter\" CXX_HAVE_UNUSED_PARAMETER)\nif(CXX_HAVE_UNUSED_PARAMETER)\n  add_compile_flags(${ROUTING_SOURCE_FILES} COMPILE_FLAGS\n    \"-Wno-unused-parameter\")\n  add_compile_flags(${CMAKE_CURRENT_SOURCE_DIR}/test_x_protocol.cc\n    COMPILE_FLAGS \"-Wno-unused-parameter\")\nendif()\ncheck_cxx_compiler_flag(\"-Wdeprecated-declarations\" CXX_HAVE_DEPRECATED_DECLARATIONS)\nif(CXX_HAVE_DEPRECATED_DECLARATIONS)\n  add_compile_flags(${ROUTING_SOURCE_FILES} COMPILE_FLAGS\n    \"-Wno-deprecated-declarations\")\n  add_compile_flags(${CMAKE_CURRENT_SOURCE_DIR}/test_x_protocol.cc\n    COMPILE_FLAGS \"-Wno-deprecated-declarations\")\nendif()\n\nif(MSVC)\n  add_compile_flags(${ROUTING_SOURCE_FILES} COMPILE_FLAGS \"/DX_PROTOCOL_DEFINE_DYNAMIC\"\n                                                          \"/FImysqlrouter/xprotocol.h\")\n  add_compile_flags(${CMAKE_CURRENT_SOURCE_DIR}/test_x_protocol.cc COMPILE_FLAGS\n                                           \"/DX_PROTOCOL_DEFINE_DYNAMIC\"\n                                           \"/FImysqlrouter/xprotocol.h\")\nelse()\n  add_compile_flags(${ROUTING_SOURCE_FILES} COMPILE_FLAGS\n                                           \"-include mysqlrouter/xprotocol.h\")\n  add_compile_flags(${CMAKE_CURRENT_SOURCE_DIR}/test_x_protocol.cc COMPILE_FLAGS\n                                           \"-include mysqlrouter/xprotocol.h\")\nendif(MSVC)\n\n# link_directories(${PROJECT_BINARY_DIR}/ext/protobuf/protobuf-3.0.0/cmake/)\n\nadd_library(routing_tests STATIC ${ROUTING_SOURCE_FILES})\ntarget_link_libraries(routing_tests routertest_helpers router_lib metadata_cache\n                      mysql_protocol x_protocol ${PB_LIBRARY})\nset_target_properties(routing_tests PROPERTIES\n  LIBRARY_OUTPUT_DIRECTORY ${MySQLRouter_BINARY_STAGE_DIR}/lib)\ntarget_include_directories(routing PRIVATE ${include_dirs})\n\nadd_library(routing_plugin_tests STATIC ${ROUTING_PLUGIN_SOURCE_FILES})\ntarget_link_libraries(routing_plugin_tests routing_tests routertest_helpers router_lib metadata_cache)\nset_target_properties(routing_plugin_tests PROPERTIES\n  LIBRARY_OUTPUT_DIRECTORY ${MySQLRouter_BINARY_STAGE_DIR}/lib)\ntarget_include_directories(routing_plugin_tests PRIVATE ${include_dirs})\n\ntarget_compile_definitions(routing_plugin_tests PRIVATE -Drouting_DEFINE_STATIC=1)\n\nif(${CMAKE_SYSTEM_NAME} STREQUAL \"SunOS\")\n  target_link_libraries(routing_tests -lnsl -lsocket)\n  target_link_libraries(routing_plugin_tests -lnsl -lsocket)\nendif()\n\n\nadd_test_dir(${CMAKE_CURRENT_SOURCE_DIR}\n  MODULE \"routing\"\n  LIB_DEPENDS routing_tests test-helpers\n  ENVIRONMENT \"MYSQL_ROUTER_HOME=${MySQLRouter_BINARY_STAGE_DIR}/etc/\"\n  INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src/harness/shared/include)\n\nadd_test_dir(${CMAKE_CURRENT_SOURCE_DIR}/plugin\n  MODULE \"routing\"\n  LIB_DEPENDS\n    routing_tests\n    routing_plugin_tests\n    test-helpers\n  ENVIRONMENT \"MYSQL_ROUTER_HOME=${MySQLRouter_BINARY_STAGE_DIR}/etc/\"\n  INCLUDE_DIRS\n    ${CMAKE_CURRENT_SOURCE_DIR}/../src\n    ${PROJECT_SOURCE_DIR}/tests/helpers\n    ${PROJECT_SOURCE_DIR}/src/harness/shared/include\n  )\n\nadd_test_dir(issues MODULE issues\n  LIB_DEPENDS\n    routing_tests\n    routing_plugin_tests\n    test-helpers\n  INCLUDE_DIRS\n    ${CMAKE_CURRENT_SOURCE_DIR}/../src\n    ${PROJECT_SOURCE_DIR}/tests/helpers\n    ${PROJECT_SOURCE_DIR}/src/harness/shared/include\n  )\n\nset(RUNNING_MYSQL_SERVER \"127.0.0.1:3306\")\nif(NOT CMAKE_CFG_INTDIR STREQUAL \".\")\n  foreach(conf ${CMAKE_CONFIGURATION_TYPES})\n    set(ROUTER_STAGE_DIR ${MySQLRouter_BINARY_STAGE_DIR}/${conf})\n    set(ROUTER_PLUGIN_DIR_SUFFIX \"lib\")\n    configure_file(data/1route.conf.in ${MySQLRouter_BINARY_STAGE_DIR}/${conf}/etc/routing_1route.conf)\n  endforeach()\nelse()\n  set(ROUTER_STAGE_DIR ${MySQLRouter_BINARY_STAGE_DIR})\n  set(ROUTER_PLUGIN_DIR_SUFFIX \"lib/mysqlrouter\")\n  configure_file(data/1route.conf.in ${MySQLRouter_BINARY_STAGE_DIR}/etc/routing_1route.conf)\nendif()\n\ntarget_link_libraries(test_issues_bug21962350)\n"
  },
  {
    "path": "src/routing/tests/data/1route.conf.in",
    "content": "# Part of MySQL Router testing\n\n[DEFAULT]\nlogging_folder =\nplugin_folder = @ROUTER_STAGE_DIR@/@ROUTER_PLUGIN_DIR_SUFFIX@\nruntime_folder = @ROUTER_STAGE_DIR@/run\nconfig_folder = @ROUTER_STAGE_DIR@/etc\n\n[routing]\ndestination = @RUNNING_MYSQL_SERVER@\n"
  },
  {
    "path": "src/routing/tests/issues/test_bug21873666.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/**\n * BUG21873666 Correctly using configured values instead of defaults\n *\n */\n\n#include \"mysqlrouter/routing.h\"\n#include \"plugin_config.h\"\n\n#include <fstream>\n#include <memory>\n#include <string>\n\n//ignore GMock warnings\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wconversion\"\n#endif\n\n#include \"gmock/gmock.h\"\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n#include \"mysql/harness/config_parser.h\"\n\n#include \"mysql_routing.h\"\n\nusing mysqlrouter::to_string;\nusing ::testing::HasSubstr;\n\nclass Bug21771595 : public ::testing::Test {\nprotected:\n  virtual void SetUp() {\n  }\n\n  virtual void TearDown() {\n  }\n};\n\nTEST_F(Bug21771595, ConstructorDefaults) {\n  MySQLRouting r(routing::RoutingStrategy::kRoundRobin,\n                 7001, Protocol::Type::kClassicProtocol, routing::AccessMode::kReadWrite,\n                 \"127.0.0.1\", mysql_harness::Path(), \"test\");\n  ASSERT_EQ(r.get_destination_connect_timeout(), routing::kDefaultDestinationConnectionTimeout);\n  ASSERT_EQ(r.get_max_connections(), routing::kDefaultMaxConnections);\n}\n\nTEST_F(Bug21771595, Constructor) {\n  auto expect_max_connections = routing::kDefaultMaxConnections - 10;\n  auto expect_connect_timeout = routing::kDefaultDestinationConnectionTimeout + std::chrono::seconds(10);\n\n  MySQLRouting r(routing::RoutingStrategy::kRoundRobin,\n                 7001, Protocol::Type::kClassicProtocol, routing::AccessMode::kReadWrite,\n                 \"127.0.0.1\", mysql_harness::Path(), \"test\",\n                 expect_max_connections, expect_connect_timeout);\n  ASSERT_EQ(r.get_destination_connect_timeout(), expect_connect_timeout);\n  ASSERT_EQ(r.get_max_connections(), expect_max_connections);\n}\n\nTEST_F(Bug21771595, GetterSetterMaxConnections) {\n  MySQLRouting r(routing::RoutingStrategy::kRoundRobin,\n                 7001, Protocol::Type::kClassicProtocol, routing::AccessMode::kReadWrite,\n                 \"127.0.0.1\", mysql_harness::Path(), \"test\");\n  ASSERT_EQ(r.get_max_connections(), routing::kDefaultMaxConnections);\n  auto expected = routing::kDefaultMaxConnections + 1;\n  ASSERT_EQ(r.set_max_connections(expected), expected);\n  ASSERT_EQ(r.get_max_connections(), expected);\n}\n\nTEST_F(Bug21771595, InvalidDestinationConnectTimeout) {\n  MySQLRouting r(routing::RoutingStrategy::kRoundRobin,\n                 7001, Protocol::Type::kClassicProtocol, routing::AccessMode::kReadWrite,\n                 \"127.0.0.1\", mysql_harness::Path(), \"test\");\n  ASSERT_THROW(r.validate_destination_connect_timeout(std::chrono::seconds(-1)), std::invalid_argument);\n  // ASSERT_THROW(r.set_destination_connect_timeout(UINT16_MAX+1), std::invalid_argument);\n  try {\n    r.validate_destination_connect_timeout(std::chrono::seconds(0));\n  } catch (const std::invalid_argument &exc) {\n    ASSERT_THAT(exc.what(), HasSubstr(\n      \"tried to set destination_connect_timeout using invalid value, was 0 ms\"));\n  }\n  ASSERT_THROW(MySQLRouting(routing::RoutingStrategy::kRoundRobin,\n                            7001, Protocol::Type::kClassicProtocol, routing::AccessMode::kReadWrite,\n                            \"127.0.0.1\", mysql_harness::Path(), \"test\", 1, std::chrono::seconds(-1)),\n      std::invalid_argument);\n}\n\nTEST_F(Bug21771595, InvalidMaxConnections) {\n  MySQLRouting r(routing::RoutingStrategy::kRoundRobin,\n                 7001, Protocol::Type::kClassicProtocol, routing::AccessMode::kReadWrite,\n                 \"127.0.0.1\", mysql_harness::Path(), \"test\");\n  ASSERT_THROW(r.set_max_connections(-1), std::invalid_argument);\n  ASSERT_THROW(r.set_max_connections(UINT16_MAX+1), std::invalid_argument);\n  try {\n    r.set_max_connections(0);\n  } catch (const std::invalid_argument &exc) {\n    ASSERT_THAT(exc.what(), HasSubstr(\n      \"tried to set max_connections using invalid value, was '0'\"));\n  }\n  ASSERT_THROW(MySQLRouting(routing::RoutingStrategy::kRoundRobin,\n                            7001, Protocol::Type::kClassicProtocol, routing::AccessMode::kReadWrite,\n                            \"127.0.0.1\", mysql_harness::Path(), \"test\", 0, std::chrono::seconds(1)),\n    std::invalid_argument);\n}\n\nTEST_F(Bug21771595, InvalidPort) {\n  ASSERT_THROW(MySQLRouting(routing::RoutingStrategy::kRoundRobin,\n                            0, Protocol::Type::kClassicProtocol, routing::AccessMode::kReadWrite,\n                            \"127.0.0.1\", mysql_harness::Path(), \"test\"), std::invalid_argument);\n  try {\n    MySQLRouting r(routing::RoutingStrategy::kRoundRobin,\n                   (uint16_t)-1, Protocol::Type::kClassicProtocol, routing::AccessMode::kReadWrite,\n                   \"127.0.0.1\", mysql_harness::Path(), \"test\");\n  } catch (const std::invalid_argument &exc) {\n    ASSERT_THAT(exc.what(), HasSubstr(\"Invalid bind address, was '127.0.0.1', port -1\"));\n  }\n}\n"
  },
  {
    "path": "src/routing/tests/issues/test_bug21962350.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/**\n * BUG21962350 Issue with destination server removal from quarantine\n *\n */\n\n#include \"mysql/harness/config_parser.h\"\n#include \"destination.h\"\n#include \"dest_round_robin.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysql/harness/logging/registry.h\"\n#include \"mysqlrouter/routing.h\"\n#include \"mysqlrouter/utils.h\"\n#include \"test/helpers.h\"\n#include \"mysql/harness/loader.h\"\n\n#include <fstream>\n#include <string>\n#include <thread>\n#include <vector>\n\n//ignore GMock warnings\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wsign-conversion\"\n#endif\n\n#include \"gmock/gmock.h\"\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\nusing mysql_harness::TCPAddress;\nusing mysqlrouter::to_string;\nusing ::testing::HasSubstr;\nusing ::testing::Return;\nusing ::testing::Eq;\nusing ::testing::_;\n\nclass MockRouteDestination : public DestRoundRobin {\npublic:\n  void add_to_quarantine(const size_t index) noexcept {\n    DestRoundRobin::add_to_quarantine(index);\n  }\n\n  void cleanup_quarantine() noexcept {\n    DestRoundRobin::cleanup_quarantine();\n  }\n\n  MOCK_METHOD3(get_mysql_socket, int(const TCPAddress &addr, std::chrono::milliseconds connect_timeout, bool log_errors));\n};\n\nclass Bug21962350 : public ::testing::Test {\nprotected:\n  virtual void SetUp() {\n    std::ostream *log_stream = mysql_harness::logging::get_default_logger_stream();\n\n    orig_log_stream_ = log_stream->rdbuf();\n    log_stream->rdbuf(sslog.rdbuf());\n  }\n\n  virtual void TearDown() {\n    if (orig_log_stream_) {\n      std::ostream *log_stream = mysql_harness::logging::get_default_logger_stream();\n      log_stream->rdbuf(orig_log_stream_);\n    }\n  }\n\n  static const std::vector<TCPAddress> servers;\n\n  std::stringstream sslog;\n\nprivate:\n  std::streambuf *orig_log_stream_;\n};\n\n// NOTE: this test must run as first, it doesn't really test anything, just inits logger.\nTEST_F(Bug21962350, InitLogger) {\n  init_test_logger();\n}\n\nTEST_F(Bug21962350, AddToQuarantine) {\n  size_t exp;\n  MockRouteDestination d;\n  d.add(servers[0]);\n  d.add(servers[1]);\n  d.add(servers[2]);\n\n  d.add_to_quarantine(static_cast<size_t>(0));\n  ASSERT_THAT(sslog.str(), HasSubstr(\"Quarantine destination server s1.example.com:3306\"));\n  d.add_to_quarantine(static_cast<size_t>(1));\n  exp = 2;\n  ASSERT_EQ(exp, d.size_quarantine());\n  ASSERT_THAT(sslog.str(), HasSubstr(\"s2.example.com:3306\"));\n  d.add_to_quarantine(static_cast<size_t>(2));\n  ASSERT_THAT(sslog.str(), HasSubstr(\"s3.example.com:3306\"));\n  exp = 3;\n  ASSERT_EQ(exp, d.size_quarantine());\n}\n\n\nTEST_F(Bug21962350, CleanupQuarantine) {\n  size_t exp;\n  ::testing::NiceMock<MockRouteDestination> d;\n  d.add(servers[0]);\n  d.add(servers[1]);\n  d.add(servers[2]);\n\n  d.add_to_quarantine(static_cast<size_t>(0));\n  d.add_to_quarantine(static_cast<size_t>(1));\n  d.add_to_quarantine(static_cast<size_t>(2));\n  exp = 3;\n  ASSERT_EQ(exp, d.size_quarantine());\n\n  EXPECT_CALL(d, get_mysql_socket(_, _, _)).Times(4)\n    .WillOnce(Return(100))\n    .WillOnce(Return(-1))\n    .WillOnce(Return(300))\n    .WillOnce(Return(200));\n  d.cleanup_quarantine();\n  // Second is still failing\n  exp = 1;\n  ASSERT_EQ(exp, d.size_quarantine());\n  // Next clean up should remove s2.example.com\n  d.cleanup_quarantine();\n  exp = 0;\n  ASSERT_EQ(exp,d.size_quarantine());\n  ASSERT_THAT(sslog.str(), HasSubstr(\"Unquarantine destination server s2.example.com:3306\"));\n}\n\nTEST_F(Bug21962350, QuarantineServerMultipleTimes) {\n  size_t exp;\n  MockRouteDestination d;\n  d.add(servers[0]);\n  d.add(servers[1]);\n  d.add(servers[2]);\n\n  d.add_to_quarantine(static_cast<size_t>(0));\n  d.add_to_quarantine(static_cast<size_t>(0));\n  d.add_to_quarantine(static_cast<size_t>(2));\n  d.add_to_quarantine(static_cast<size_t>(1));\n\n  exp = 3;\n  ASSERT_EQ(exp, d.size_quarantine());\n}\n\n#if !defined(_WIN32) && !defined(__FreeBSD__) && !defined(NDEBUG)\n// This test doesn't work in Windows or FreeBSD, because of how ASSERT_DEATH works\n// It also fails on release version\n// But this test is gone in newer branches anyway, so disabling for now\nTEST_F(Bug21962350, QuarantineServerNonExisting) {\n  size_t exp;\n  MockRouteDestination d;\n  d.add(servers[0]);\n  d.add(servers[1]);\n  d.add(servers[2]);\n\n  ASSERT_DEBUG_DEATH(d.add_to_quarantine(static_cast<size_t>(999)), \".*(index < size()).*\");\n  exp = 0;\n  ASSERT_EQ(exp, d.size_quarantine());\n}\n#endif\n\nTEST_F(Bug21962350, AlreadyQuarantinedServer) {\n  size_t exp;\n  MockRouteDestination d;\n  d.add(servers[0]);\n  d.add(servers[1]);\n  d.add(servers[2]);\n\n  d.add_to_quarantine(static_cast<size_t>(1));\n  d.add_to_quarantine(static_cast<size_t>(1));\n  exp = 1;\n  ASSERT_EQ(exp, d.size_quarantine());\n}\n\nstd::vector<TCPAddress> const Bug21962350::servers  {\n  TCPAddress(\"s1.example.com\", 3306),\n  TCPAddress(\"s2.example.com\", 3306),\n  TCPAddress(\"s3.example.com\", 3306),\n};\n"
  },
  {
    "path": "src/routing/tests/issues/test_bug22062859.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/**\n * BUG22062859 STARTING ROUTER FAILS IF THERE IS A SPACE IN DESTINATION ADDRESS\n *\n */\n\n#include \"mysql/harness/config_parser.h\"\n#include \"plugin_config.h\"\n#include \"router_test_helpers.h\"\n\n#ifdef _WIN32\n#include <WinSock2.h>\n#endif\n#include \"gmock/gmock.h\"\n\nclass Bug22062859 : public ::testing::Test {\n  virtual void SetUp() { }\n\n  virtual void TearDown() { }\n};\n\nTEST_F(Bug22062859, IgnoreSpacesInDestinations) {\n  std::stringstream c;\n\n  c << \"[routing:c]\\n\"\n  << \"bind_address = 127.0.0.1:7006\\n\"\n  << \"destinations = localhost:13005,localhost:13003, localhost:13004\"\n  << \",   localhost:1300,   localhost  ,localhost , localhost         \\n\"\n  << \"mode = read-only\\n\";\n\n  mysql_harness::Config config(mysql_harness::Config::allow_keys);\n  std::istringstream input(c.str());\n  config.read(input);\n\n  EXPECT_NO_THROW(\n      {\n        mysql_harness::ConfigSection &section = config.get(\"routing\", \"c\");\n        RoutingPluginConfig rconfig(&section);\n      }\n  );\n}\n\nint main(int argc, char *argv[]) {\n  init_windows_sockets();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/routing/tests/issues/test_bug22579989.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n/**\n * BUG22579989 Fix reporting empty values in destinations given as CSV\n *\n */\n\n#include \"mysql/harness/config_parser.h\"\n#include \"plugin_config.h\"\n#include \"router_test_helpers.h\"\n\n#ifdef _WIN32\n#include <WinSock2.h>\n#endif\n\n#include \"gmock/gmock.h\"\n\nclass Bug22579989 : public ::testing::Test {\n protected:\n  virtual void SetUp() { }\n\n  virtual void TearDown() { }\n\n  mysql_harness::Config get_routing_config(std::string destinations) {\n    std::stringstream c;\n\n    c << \"[routing:c]\\n\"\n    << \"bind_address = 127.0.0.1:7006\\n\"\n    << \"mode = read-only\\n\"\n    << \"destinations = \"\n    << destinations << \"\\n\\n\";\n\n    mysql_harness::Config config(mysql_harness::Config::allow_keys);\n    std::istringstream input(c.str());\n    config.read(input);\n\n    return config;\n  }\n};\n\nTEST_F(Bug22579989, EmptyValuesInCSVCase1) {\n  std::stringstream c;\n  std::string destinations = \"localhost:13005,localhost:13003,localhost:13004,\";\n\n  mysql_harness::Config config = get_routing_config(destinations);\n\n  EXPECT_THROW(\n      {\n        mysql_harness::ConfigSection &section = config.get(\"routing\", \"c\");\n        RoutingPluginConfig rconfig(&section);\n      }, std::invalid_argument);\n}\n\nTEST_F(Bug22579989, EmptyValuesInCSVCase2) {\n  std::stringstream c;\n  std::string destinations = \"localhost:13005,localhost:13003,localhost:13004, , ,\";\n\n  mysql_harness::Config config = get_routing_config(destinations);\n\n  EXPECT_THROW(\n      {\n        mysql_harness::ConfigSection &section = config.get(\"routing\", \"c\");\n        RoutingPluginConfig rconfig(&section);\n      }, std::invalid_argument);\n}\n\nTEST_F(Bug22579989, EmptyValuesInCSVCase3) {\n  std::stringstream c;\n  std::string destinations = \"localhost:13005, ,,localhost:13003,localhost:13004\";\n\n  mysql_harness::Config config = get_routing_config(destinations);\n\n  EXPECT_THROW(\n      {\n        mysql_harness::ConfigSection &section = config.get(\"routing\", \"c\");\n        RoutingPluginConfig rconfig(&section);\n      }, std::invalid_argument);\n}\n\nTEST_F(Bug22579989, EmptyValuesInCSVCase4) {\n  std::stringstream c;\n  std::string destinations = \",localhost:13005,localhost:13003,localhost:13004\";\n\n  mysql_harness::Config config = get_routing_config(destinations);\n\n  EXPECT_THROW(\n      {\n        mysql_harness::ConfigSection &section = config.get(\"routing\", \"c\");\n        RoutingPluginConfig rconfig(&section);\n      }, std::invalid_argument);\n}\n\nTEST_F(Bug22579989, EmptyValuesInCSVCase5) {\n  std::stringstream c;\n  std::string destinations = \",, ,\";\n\n  mysql_harness::Config config = get_routing_config(destinations);\n\n  EXPECT_THROW(\n      {\n        mysql_harness::ConfigSection &section = config.get(\"routing\", \"c\");\n        RoutingPluginConfig rconfig(&section);\n      }, std::invalid_argument);\n}\n\nTEST_F(Bug22579989, EmptyValuesInCSVCase6) {\n  std::stringstream c;\n  std::string destinations = \",localhost:13005, ,,localhost:13003,localhost:13004, ,\";\n\n  mysql_harness::Config config = get_routing_config(destinations);\n\n  EXPECT_THROW(\n      {\n        mysql_harness::ConfigSection &section = config.get(\"routing\", \"c\");\n        RoutingPluginConfig rconfig(&section);\n      }, std::invalid_argument);\n}\n\nTEST_F(Bug22579989, NoEmptyValuesInCSV) {\n  std::stringstream c;\n  std::string destinations = \"localhost:13005,localhost:13003,localhost:13004\";\n\n  mysql_harness::Config config = get_routing_config(destinations);\n\n  EXPECT_NO_THROW(\n      {\n        mysql_harness::ConfigSection &section = config.get(\"routing\", \"c\");\n        RoutingPluginConfig rconfig(&section);\n      });\n}\n\n\nint main(int argc, char *argv[]) {\n  init_windows_sockets();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/routing/tests/plugin/test_plugin.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"gmock/gmock.h\"\n\n#include <chrono>\n#include <cstdio>\n#include <fstream>\n#include <functional>\n#include <sstream>\n#include <thread>\n#ifndef _WIN32\n#include <unistd.h>\n#include <sys/un.h>\n#endif\n\n#include \"common.h\"\n\n#include \"mysql/harness/config_parser.h\"\n#include \"mysql/harness/filesystem.h\"\n#include \"mysql/harness/loader.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"mysql/harness/plugin.h\"\n\n#include \"cmd_exec.h\"\n#include \"gtest_consoleoutput.h\"\n#include \"mysql/harness/logging/logging.h\"\n#include \"test/helpers.h\"\n#include \"mysql_routing.h\"\n#include \"plugin_config.h\"\n#include \"router_test_helpers.h\"\n#include \"tcp_port_pool.h\"\n\n\n// since this function is only meant to be used here (for testing purposes), it's not available in the headers.\nvoid validate_socket_info_test_proxy(const std::string& err_prefix, const mysql_harness::ConfigSection* section, const RoutingPluginConfig& config);\n\nusing std::string;\nusing ::testing::HasSubstr;\nusing ::testing::IsEmpty;\nusing ::testing::IsNull;\nusing ::testing::NotNull;\nusing ::testing::StrEq;\nusing mysql_harness::Path;\nusing mysql_harness::get_strerror;\n\n// define what is available in routing_plugin.cc\nextern mysql_harness::Plugin harness_plugin_routing;\nextern const mysql_harness::AppInfo *g_app_info;\n\nstring g_cwd;\nPath g_origin;\n\nclass RoutingPluginTests : public ConsoleOutputTest {\n  TcpPortPool tcp_port_pool_;\n\nprotected:\n  virtual void SetUp() {\n    set_origin(g_origin);\n    ConsoleOutputTest::SetUp();\n    config_path.reset(new Path(g_cwd));\n    config_path->append(\"test_routing_plugin.conf\");\n    cmd = app_mysqlrouter->str() + \" -c \" + config_path->str();\n\n    bind_address = \"127.0.0.1:\" + std::to_string(tcp_port_pool_.get_next_available());\n    destinations = \"127.0.0.1:\" + std::to_string(tcp_port_pool_.get_next_available());\n    socket = rundir + \"/unix_socket\";\n    routing_strategy = \"round-robin\";\n    mode = \"read-only\";\n    connect_timeout = \"1\";\n    client_connect_timeout = \"9\";\n    max_connect_errors = \"100\";\n    protocol = \"classic\";\n  }\n\n  bool in_missing(std::vector<std::string> missing, std::string needle) {\n    return std::find(missing.begin(), missing.end(), needle) != missing.end();\n  }\n\n  void reset_config(std::vector<std::string> missing = {}, bool add_break = false) {\n    std::ofstream ofs_config(config_path->str());\n    if (ofs_config.good()) {\n      ofs_config << \"[DEFAULT]\\n\";\n      ofs_config << \"logging_folder =\\n\";\n      ofs_config << \"plugin_folder = \" << plugin_dir->str() << \"\\n\";\n      ofs_config << \"runtime_folder = \" << stage_dir->str() << \"\\n\";\n      ofs_config << \"config_folder = \" << stage_dir->str() << \"\\n\";\n      ofs_config << \"data_folder = \" << stage_dir->str() << \"\\n\\n\";\n      ofs_config << \"[routing:tests]\\n\";\n\n      using ConfigOption = std::pair<std::string, std::string&>;\n      std::vector<ConfigOption> routing_config_options{\n        {\"bind_address\",            std::ref(bind_address)},\n        {\"socket\",                  std::ref(socket)},\n        {\"destinations\",            std::ref(destinations)},\n        {\"routing_strategy\",        std::ref(routing_strategy)},\n        {\"mode\",                    std::ref(mode)},\n        {\"connect_timeout\",         std::ref(connect_timeout)},\n        {\"client_connect_timeout\",  std::ref(client_connect_timeout)},\n        {\"max_connect_errors\",      std::ref(max_connect_errors)},\n        {\"protocol\",                std::ref(protocol)}\n      };\n      for (auto& option: routing_config_options) {\n        if (!in_missing(missing, option.first)) {\n          ofs_config << option.first  << \" = \" << option.second << \"\\n\";\n        }\n      }\n\n      // Following is an incorrect [routing] entry. If the above is valid, this\n      // will make sure Router stops.\n      if (add_break) {\n        ofs_config << \"\\n[routing:break]\\n\";\n      }\n\n      ofs_config << \"\\n\";\n      ofs_config.close();\n    }\n  }\n\n  virtual void TearDown() {\n    if (unlink(config_path->c_str()) == -1) {\n      if (errno != ENOENT) {\n        // File missing is OK.\n        std::cerr << \"Failed removing \" << config_path->str()\n        << \": \" << get_strerror(errno) << \"(\" << errno << \")\" << std::endl;\n      }\n    }\n    ConsoleOutputTest::TearDown();\n  }\n\n  const string plugindir = \"path/to/plugindir\";\n  const string logdir = \"/path/to/logdir\";\n  const string program = \"routing_plugin_test\";\n  const string rundir = \"/path/to/rundir\";\n  const string cfgdir = \"/path/to/cfgdir\";\n  const string datadir = \"/path/to/datadir\";\n  string bind_address;\n  string destinations;\n  string socket;\n  string routing_strategy;\n  string mode;\n  string connect_timeout;\n  string client_connect_timeout;\n  string max_connect_errors;\n  string protocol;\n\n  std::unique_ptr<Path> config_path;\n  std::string cmd;\n};\n\nTEST_F(RoutingPluginTests, PluginObject) {\n  ASSERT_EQ(harness_plugin_routing.abi_version, 0x0200U);\n  ASSERT_EQ(harness_plugin_routing.plugin_version, static_cast<uint32_t>(VERSION_NUMBER(0, 0, 1)));\n  ASSERT_EQ(harness_plugin_routing.conflicts_length, 0U);\n  ASSERT_THAT(harness_plugin_routing.conflicts, IsNull());\n  ASSERT_THAT(harness_plugin_routing.deinit, IsNull());\n  ASSERT_THAT(harness_plugin_routing.brief,\n              StrEq(\"Routing MySQL connections between MySQL clients/connectors and servers\"));\n}\n\nTEST_F(RoutingPluginTests, InitAppInfo) {\n  ASSERT_THAT(g_app_info, IsNull());\n\n  mysql_harness::AppInfo test_app_info{\n      program.c_str(),\n      plugindir.c_str(),\n      logdir.c_str(),\n      rundir.c_str(),\n      cfgdir.c_str(),\n      datadir.c_str(),\n      nullptr\n  };\n\n  mysql_harness::PluginFuncEnv env(&test_app_info, nullptr);\n  harness_plugin_routing.init(&env);\n  ASSERT_TRUE(env.exit_ok());\n\n  ASSERT_THAT(g_app_info, Not(IsNull()));\n  ASSERT_THAT(program.c_str(), StrEq(g_app_info->program));\n}\n\nTEST_F(RoutingPluginTests, StartCorrectSection) {\n  reset_config({}, true);\n  auto cmd_result = cmd_exec(cmd, true);\n  ASSERT_THAT(cmd_result.output, HasSubstr(\"[routing:break]\"));\n}\n\nTEST_F(RoutingPluginTests, StartCaseInsensitiveMode) {\n  mode = \"Read-Only\";\n  reset_config({}, true);\n  auto cmd_result = cmd_exec(cmd, true);\n  ASSERT_THAT(cmd_result.output,\n              Not(HasSubstr(\"valid are\")));\n}\n\nTEST_F(RoutingPluginTests, StartCaseInsensitiveRoutingStrategy) {\n  routing_strategy = \"First-Available\";\n  reset_config({}, true);\n  auto cmd_result = cmd_exec(cmd, true);\n  ASSERT_THAT(cmd_result.output,\n              Not(HasSubstr(\"valid are\")));\n}\n\nTEST_F(RoutingPluginTests, NoListeningSocket) {\n  mysql_harness::Config         cfg;\n  mysql_harness::ConfigSection& section = cfg.add(\"routing\", \"test_route\");\n  section.add(\"destinations\", \"localhost:1234\");\n  section.add(\"mode\", \"read-only\");\n\n  try {\n    RoutingPluginConfig config(&section);\n    FAIL() << \"Expected std::invalid_argument to be thrown\";\n  } catch (const std::invalid_argument& e) {\n    EXPECT_STREQ(\"either bind_address or socket option needs to be supplied, or both\", e.what());\n    SUCCEED();\n  } catch (...) {\n    FAIL() << \"Expected std::invalid_argument to be thrown\";\n  }\n}\n\nTEST_F(RoutingPluginTests, ListeningTcpSocket) {\n  mysql_harness::Config         cfg;\n  mysql_harness::ConfigSection& section = cfg.add(\"routing\", \"test_route\");\n  section.add(\"destinations\", \"localhost:1234\");\n  section.add(\"mode\", \"read-only\");\n  section.add(\"bind_address\", \"127.0.0.1:15508\");\n\n  EXPECT_NO_THROW({\n    RoutingPluginConfig config(&section);\n    validate_socket_info_test_proxy(\"\", &section, config);\n  });\n\n}\n\n#ifndef _WIN32\nTEST_F(RoutingPluginTests, ListeningUnixSocket) {\n  mysql_harness::Config         cfg;\n  mysql_harness::ConfigSection& section = cfg.add(\"routing\", \"test_route\");\n  section.add(\"destinations\", \"localhost:1234\");\n  section.add(\"mode\", \"read-only\");\n  section.add(\"socket\", \"./socket\");  // if this test fails, check if you don't have this file hanging around\n\n  EXPECT_NO_THROW({\n    RoutingPluginConfig config(&section);\n    validate_socket_info_test_proxy(\"\", &section, config);\n  });\n}\n\nTEST_F(RoutingPluginTests, ListeningBothSockets) {\n  mysql_harness::Config         cfg;\n  mysql_harness::ConfigSection& section = cfg.add(\"routing\", \"test_route\");\n  section.add(\"destinations\", \"localhost:1234\");\n  section.add(\"mode\", \"read-only\");\n  section.add(\"bind_address\", \"127.0.0.1:15508\");\n  section.add(\"socket\", \"./socket\");  // if this test fails, check if you don't have this file hanging around\n\n  EXPECT_NO_THROW({\n    RoutingPluginConfig config(&section);\n    validate_socket_info_test_proxy(\"\", &section, config);\n  });\n}\n\nTEST_F(RoutingPluginTests, TwoUnixSocketsWithoutTcp) {\n  mysql_harness::Config cfg;\n  mysql_harness::ConfigSection& section1 = cfg.add(\"routing\", \"test_route1\");\n  section1.add(\"destinations\", \"localhost:1234\");\n  section1.add(\"mode\", \"read-only\");\n  section1.add(\"socket\", \"./socket1\");\n  mysql_harness::ConfigSection& section2 = cfg.add(\"routing\", \"test_route2\");\n  section2.add(\"destinations\", \"localhost:1234\");\n  section2.add(\"mode\", \"read-only\");\n  section2.add(\"socket\", \"./socket2\");\n\n  EXPECT_NO_THROW({\n    mysql_harness::AppInfo info;\n    info.config = &cfg;\n    mysql_harness::PluginFuncEnv env(&info, nullptr);\n    harness_plugin_routing.init(&env);\n  });\n}\n\nTEST_F(RoutingPluginTests, TwoUnixSocketsWithTcp) {\n  mysql_harness::Config cfg;\n  mysql_harness::ConfigSection& section1 = cfg.add(\"routing\", \"test_route1\");\n  section1.add(\"destinations\", \"localhost:1234\");\n  section1.add(\"mode\", \"read-only\");\n  section1.add(\"bind_address\", \"127.0.0.1:15501\");\n  section1.add(\"socket\", \"./socket1\");\n  mysql_harness::ConfigSection& section2 = cfg.add(\"routing\", \"test_route2\");\n  section2.add(\"destinations\", \"localhost:1234\");\n  section2.add(\"mode\", \"read-only\");\n  section2.add(\"bind_address\", \"127.0.0.1:15502\");\n  section2.add(\"socket\", \"./socket2\");\n\n  EXPECT_NO_THROW({\n    mysql_harness::AppInfo info;\n    info.config = &cfg;\n    mysql_harness::PluginFuncEnv env(&info, nullptr);\n    harness_plugin_routing.init(&env);\n  });\n}\n\nstatic std::string make_string(size_t len, char c = 'a') {\n  std::string res(len, c);\n\n  assert(res.length() == len);\n\n  return res;\n}\n\nstatic void test_socket_length(const std::string& socket_name, size_t max_len) {\n  mysql_harness::Config         cfg;\n  mysql_harness::ConfigSection& section = cfg.add(\"routing\", \"test_route\");\n  section.add(\"destinations\", \"localhost:1234\");\n  section.add(\"mode\", \"read-only\");\n  section.add(\"socket\", socket_name);\n\n  if (socket_name.length() <= max_len) {\n    EXPECT_NO_THROW({\n      RoutingPluginConfig config(&section);\n      validate_socket_info_test_proxy(\"\", &section, config);\n    });\n  }\n  else {\n    EXPECT_THROW(\n      RoutingPluginConfig config(&section),\n      std::invalid_argument);\n  }\n}\n\nTEST_F(RoutingPluginTests, ListeningSocketNameLength) {\n#ifndef _WIN32\n  const size_t MAX_SOCKET_NAME_LEN = sizeof(sockaddr_un().sun_path)-1;\n#else\n  // doesn't really matter\n  const size_t MAX_SOCKET_NAME_LEN = 100;\n#endif\n\n  std::string socket_name;\n\n  socket_name = make_string(MAX_SOCKET_NAME_LEN-1);\n  test_socket_length(socket_name, MAX_SOCKET_NAME_LEN);\n\n  socket_name = make_string(MAX_SOCKET_NAME_LEN);\n  test_socket_length(socket_name, MAX_SOCKET_NAME_LEN);\n\n  socket_name = make_string(MAX_SOCKET_NAME_LEN+1);\n  test_socket_length(socket_name, MAX_SOCKET_NAME_LEN);\n}\n\nTEST_F(RoutingPluginTests, TwoNonuniqueUnixSockets) {\n  // TODO add after implementing plugin lifecycle (WL9558),\n  // use TwoNonuniqueTcpSockets as an example\n  // (exception is thrown in plugin start(), in a separate thread)\n}\n\n#endif\n\nTEST_F(RoutingPluginTests, TwoNonuniqueTcpSockets) {\n  mysql_harness::Config cfg;\n  mysql_harness::ConfigSection& section1 = cfg.add(\"routing\", \"test_route1\");\n  section1.add(\"destinations\", \"localhost:1234\");\n  section1.add(\"mode\", \"read-only\");\n  section1.add(\"bind_address\", \"127.0.0.1:15508\");\n  mysql_harness::ConfigSection& section2 = cfg.add(\"routing\", \"test_route2\");\n  section2.add(\"destinations\", \"localhost:1234\");\n  section2.add(\"mode\", \"read-only\");\n  section2.add(\"bind_address\", \"127.0.0.1:15508\");\n\n  try {\n    mysql_harness::AppInfo info;\n    info.config = &cfg;\n    mysql_harness::PluginFuncEnv env(&info, nullptr);\n    harness_plugin_routing.init(&env);\n\n    std::exception_ptr e;\n    std::tie(std::ignore, e) = env.pop_error();\n    if (e)\n      std::rethrow_exception(e);\n\n    FAIL() << \"Expected std::invalid_argument to be thrown\";\n  } catch (const std::invalid_argument& e) {\n    EXPECT_STREQ(\"in [routing:test_route2]: duplicate IP or name found in bind_address '127.0.0.1:15508'\", e.what());\n    SUCCEED();\n  } catch (...) {\n    FAIL() << \"Expected std::invalid_argument to be thrown\";\n  }\n}\n\nTEST_F(RoutingPluginTests, StartMissingDestination) {\n  {\n    reset_config({\"destinations\"});\n    auto cmd_result = cmd_exec(cmd, true);\n    ASSERT_THAT(cmd_result.output,\n                HasSubstr(\"option destinations in [routing:tests] is required\"));\n  }\n\n  {\n    destinations = {};\n    reset_config({});\n    auto cmd_result = cmd_exec(cmd, true);\n    ASSERT_THAT(cmd_result.output,\n                HasSubstr(\"option destinations in [routing:tests] is required and needs a value\"));\n  }\n}\n\nTEST_F(RoutingPluginTests, StartImpossiblePortNumber) {\n  bind_address = \"127.0.0.1:99999\";\n  reset_config();\n  auto cmd_result = cmd_exec(cmd, true);\n  ASSERT_THAT(cmd_result.output,\n              HasSubstr(\"incorrect (invalid TCP port: impossible port number)\"));\n}\n\nTEST_F(RoutingPluginTests, StartImpossibleIPAddress) {\n  bind_address = \"512.512.512.512:3306\";\n  reset_config();\n  auto cmd_result = cmd_exec(cmd, true);\n  ASSERT_THAT(cmd_result.output,\n              HasSubstr(\"in [routing:tests]: invalid IP or name in bind_address '512.512.512.512:3306'\"));\n}\n\n#ifndef _WIN32\nTEST_F(RoutingPluginTests, EmptyUnixSocket) {\n  mysql_harness::Config         cfg;\n  mysql_harness::ConfigSection& section = cfg.add(\"routing\", \"test_route\");\n  section.add(\"destinations\", \"localhost:1234\");\n  section.add(\"mode\", \"read-only\");\n  section.add(\"socket\", \"\");\n\n  // If this not provided, RoutingPluginConfig() will throw with its own error, which will be misleading.\n  // This line should not influence throwing/not throwing the right error (\"invalid socket ''\")\n  section.add(\"bind_address\", \"127.0.0.1:15508\");\n\n  try {\n    RoutingPluginConfig config(&section);\n    validate_socket_info_test_proxy(\"\", &section, config);\n    FAIL() << \"Expected std::invalid_argument to be thrown\";\n  } catch (const std::invalid_argument& e) {\n    EXPECT_STREQ(\"invalid socket ''\", e.what());\n    SUCCEED();\n  } catch (...) {\n    FAIL() << \"Expected std::invalid_argument to be thrown\";\n  }\n}\n\nTEST_F(RoutingPluginTests, StartBadUnixSocket) {\n  socket = \"/this/path/does/not/exist/socket\";\n  reset_config();\n  CmdExecResult cmd_result = cmd_exec(cmd, true);\n  ASSERT_THAT(cmd_result.output, HasSubstr(\"Setting up named socket service '/this/path/does/not/exist/socket': No such file or directory\"));\n}\n\nTEST_F(RoutingPluginTests, ListeningHostIsInvalid) {\n  mysql_harness::Config         cfg;\n  mysql_harness::ConfigSection& section = cfg.add(\"routing\", \"test_route\");\n  section.add(\"destinations\", \"localhost:1234\");\n  section.add(\"mode\", \"read-only\");\n  section.add(\"bind_address\", \"host.that.does.not.exist:15508\");\n\n  try {\n    RoutingPluginConfig config(&section);\n    validate_socket_info_test_proxy(\"\", &section, config);\n    FAIL() << \"Expected std::invalid_argument to be thrown\";\n  } catch (const std::invalid_argument& e) {\n    EXPECT_STREQ(\"invalid IP or name in bind_address 'host.that.does.not.exist:15508'\", e.what());\n    SUCCEED();\n  } catch (...) {\n    FAIL() << \"Expected std::invalid_argument to be thrown\";\n  }\n}\n#endif\n\nTEST_F(RoutingPluginTests, StartWithBindAddressInDestinations) {\n  bind_address = \"127.0.0.1:3306\";\n  destinations = \"127.0.0.1\";  // default port is 3306\n#ifndef _WIN32\n  reset_config();\n#else\n  reset_config({\"socket\"});\n#endif\n  auto cmd_result = cmd_exec(cmd, true);\n  ASSERT_THAT(cmd_result.output, HasSubstr(\"Bind Address can not be part of destinations\"));\n}\n\nTEST_F(RoutingPluginTests, StartConnectTimeoutSetNegative) {\n  connect_timeout = \"-1\";\n  reset_config();\n  auto cmd_result = cmd_exec(cmd, true);\n  ASSERT_THAT(cmd_result.output,\n              HasSubstr(\"connect_timeout in [routing:tests] needs value between 1 and 65535 inclusive, was '-1'\"));\n}\n\nTEST_F(RoutingPluginTests, StartClientConnectTimeoutSetIncorrectly) {\n  {\n    client_connect_timeout = \"1\";\n    reset_config();\n    auto cmd_result = cmd_exec(cmd, true);\n    ASSERT_THAT(cmd_result.output, HasSubstr(\n        \"option client_connect_timeout in [routing:tests] needs value between 2 and 31536000 inclusive, was '1'\"));\n  }\n\n  {\n    client_connect_timeout = \"31536001\";  // 31536000 is maximum\n    reset_config();\n    auto cmd_result = cmd_exec(cmd, true);\n    ASSERT_THAT(cmd_result.output, HasSubstr(\n        \"option client_connect_timeout in [routing:tests] needs \"\n            \"value between 2 and 31536000 inclusive, was '31536001'\"));\n  }\n}\n\nTEST_F(RoutingPluginTests, StartMaxConnectErrorsSetIncorrectly) {\n  {\n    max_connect_errors = \"0\";\n    reset_config();\n    auto cmd_result = cmd_exec(cmd, true);\n    ASSERT_THAT(cmd_result.output, HasSubstr(\n        \"option max_connect_errors in [routing:tests] needs value between 1 and 4294967295 inclusive, was '0'\"));\n  }\n}\n\nTEST_F(RoutingPluginTests, StartTimeoutsSetToZero) {\n\n  connect_timeout = \"0\";\n  reset_config();\n  auto cmd_result = cmd_exec(cmd, true);\n  ASSERT_THAT(cmd_result.output,\n              HasSubstr(\n                  \"option connect_timeout in [routing:tests] needs value between 1 and 65535 inclusive, was '0'\"));\n}\n\nTEST_F(RoutingPluginTests, EmptyProtocolName) {\n  protocol = \"\";\n  reset_config();\n  auto cmd_result = cmd_exec(cmd, true);\n  ASSERT_THAT(cmd_result.output,\n              HasSubstr(\"Configuration error: Invalid protocol name: ''\"));\n}\n\nTEST_F(RoutingPluginTests, InvalidProtocolName) {\n  protocol = \"invalid\";\n  reset_config();\n  auto cmd_result = cmd_exec(cmd, true);\n  ASSERT_THAT(cmd_result.output,\n              HasSubstr(\"Configuration error: Invalid protocol name: 'invalid'\"));\n}\n\nint main(int argc, char *argv[]) {\n  init_test_logger();\n  init_windows_sockets();\n  g_origin = Path(argv[0]).dirname();\n  g_cwd = Path(argv[0]).dirname().str();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/routing/tests/routing_mocks.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef ROUTING_MOCKS_INCLUDED\n#define ROUTING_MOCKS_INCLUDED\n\n#ifdef _WIN32\n#  include \"Winsock2.h\"\n#endif\n\n//ignore GMock warnings\n#ifdef __clang__\n#  ifndef __has_warning\n#    define __has_warning(x) 0\n#  endif\n#  pragma clang diagnostic push\n#  if __has_warning(\"-Winconsistent-missing-override\")\n#    pragma clang diagnostic ignored \"-Winconsistent-missing-override\"\n#  endif\n#  if __has_warning(\"-Wsign-conversion\")\n#    pragma clang diagnostic ignored \"-Wsign-conversion\"\n#  endif\n#endif\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n#include <atomic>\n\n\nclass MockSocketOperations : public mysql_harness::SocketOperationsBase {\n public:\n  MOCK_METHOD3(read, ssize_t(int, void*, size_t));\n  MOCK_METHOD3(write, ssize_t(int, void*, size_t));\n  MOCK_METHOD1(close, void(int));\n  MOCK_METHOD1(shutdown, void(int));\n  MOCK_METHOD1(freeaddrinfo, void(addrinfo *ai));\n  MOCK_METHOD4(getaddrinfo, int(const char*, const char*, const addrinfo*, addrinfo**));\n  MOCK_METHOD3(bind, int(int, const struct sockaddr*, socklen_t));\n  MOCK_METHOD3(socket, int(int, int, int));\n  MOCK_METHOD5(setsockopt, int(int, int, int, const void*, socklen_t));\n  MOCK_METHOD2(listen, int(int fd, int n));\n  MOCK_METHOD3(poll, int(struct pollfd *, nfds_t, std::chrono::milliseconds));\n  MOCK_METHOD2(connect_non_blocking_wait, int(int sock, std::chrono::milliseconds timeout));\n  MOCK_METHOD2(connect_non_blocking_status, int(int sock, int &so_error));\n  MOCK_METHOD0(get_local_hostname, std::string());\n\n  void set_errno(int err) override {\n    // set errno/Windows equivalent. At the time of writing, unit tests\n    // will pass just fine without this, as they are too low-level and the errno is\n    // checked at higher level. But to do an accurate mock, we should set this.\n#ifdef _WIN32\n    WSASetLastError(err);\n#else\n    errno = err;\n#endif\n  }\n\n  int get_errno() override {\n#ifdef _WIN32\n    return WSAGetLastError();\n#else\n    return errno;\n#endif\n  }\n};\n\nclass MockRoutingSockOps : public routing::RoutingSockOpsInterface {\n public:\n  MockRoutingSockOps() : so_(new MockSocketOperations) {}\n\n  MockSocketOperations* so() const override { return so_.get(); }\n\n  int get_mysql_socket(mysql_harness::TCPAddress addr, std::chrono::milliseconds, bool = true) noexcept override {\n    get_mysql_socket_call_cnt_++;\n    if (get_mysql_socket_fails_todo_) {\n      so()->set_errno(ECONNREFUSED);\n      get_mysql_socket_fails_todo_--;\n      return -1;  // -1 means server is unavailable\n    } else {\n      so()->set_errno(0);\n\n      // if addr string starts with a number, this will return it. Therefore it's\n      // recommended that addr.addr is set to something like \"42\"\n      return atoi(addr.addr.c_str());\n    }\n  }\n\n  int get_mysql_socket_call_cnt() {\n    int cc = get_mysql_socket_call_cnt_;\n    get_mysql_socket_call_cnt_ = 0;\n    return cc;\n  }\n\n  void get_mysql_socket_fail(int fail_cnt) {\n    get_mysql_socket_fails_todo_ = fail_cnt;\n  }\n\n private:\n  std::atomic_int get_mysql_socket_fails_todo_ { 0 };\n  std::atomic_int get_mysql_socket_call_cnt_   { 0 };\n\n  std::unique_ptr<MockSocketOperations> so_;\n};\n\n#ifdef __clang__\n#  pragma clang diagnostic pop\n#endif\n\n\n#endif // ROUTING_MOCKS_INCLUDED\n"
  },
  {
    "path": "src/routing/tests/test_block_clients.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"cmd_exec.h\"\n#include \"gtest_consoleoutput.h\"\n#include \"mysql/harness/config_parser.h\"\n#include \"mysql/harness/plugin.h\"\n#include \"mysqlrouter/mysql_protocol.h\"\n#include \"mysqlrouter/routing.h\"\n#include \"router_test_helpers.h\"\n#include \"../../router/src/router_app.h\"\n#include \"../../routing/src/mysql_routing.h\"\n#include \"../../routing/src/utils.h\"\n#include \"test/helpers.h\"\n\n#include <cstdio>\n#include <fstream>\n#include <future>\n#include <memory>\n#include <string>\n#include <thread>\n#ifndef _WIN32\n# include <netinet/in.h>\n#else\n# include <WinSock2.h>\n#endif\n\n#include \"gmock/gmock.h\"\n\nusing std::string;\nusing ::testing::ContainerEq;\nusing ::testing::HasSubstr;\nusing ::testing::StrEq;\nusing mysql_harness::Path;\n\nstring g_cwd;\nPath g_origin;\n\nclass TestBlockClients : public ConsoleOutputTest {\nprotected:\n  virtual void SetUp() {\n    set_origin(g_origin);\n    ConsoleOutputTest::SetUp();\n  }\n};\n\nTEST_F(TestBlockClients, BlockClientHost) {\n  unsigned long long max_connect_errors = 2;\n  std::chrono::seconds client_connect_timeout(2);\n  union {\n    sockaddr_in6 client_addr1;\n    sockaddr_storage client_addr1_storage;\n  };\n  union {\n    sockaddr_in6 client_addr2;\n    sockaddr_storage client_addr2_storage;\n  };\n  client_addr1.sin6_family = client_addr2.sin6_family = AF_INET6;\n  memset(&client_addr1.sin6_addr, 0x0, sizeof(client_addr1.sin6_addr));\n  memset(&client_addr2.sin6_addr, 0x0, sizeof(client_addr2.sin6_addr));\n  unsigned char* p1 = reinterpret_cast<unsigned char*>(&client_addr1.sin6_addr);\n  p1[15] = 1;\n  unsigned char* p2 = reinterpret_cast<unsigned char*>(&client_addr2.sin6_addr);\n  p2[15] = 2;\n\n  auto client_ip_array1 = in_addr_to_array(client_addr1_storage);\n  auto client_ip_array2 = in_addr_to_array(client_addr2_storage);\n\n  MySQLRouting r(routing::RoutingStrategy::kNextAvailable,\n                 7001, Protocol::Type::kClassicProtocol,\n                 routing::AccessMode::kReadWrite,\n                 \"127.0.0.1\", mysql_harness::Path(), \"routing:connect_erros\",\n                 1, std::chrono::seconds(1), max_connect_errors, client_connect_timeout);\n\n  ASSERT_FALSE(r.get_context().block_client_host(client_ip_array1, string(\"::1\")));\n  ASSERT_THAT(get_log_stream().str(), HasSubstr(\"1 connection errors for ::1 (max 2)\"));\n  reset_ssout();\n  ASSERT_TRUE(r.get_context().block_client_host(client_ip_array1, string(\"::1\")));\n  ASSERT_THAT(get_log_stream().str(), HasSubstr(\"blocking client host ::1\"));\n\n  auto blocked_hosts = r.get_context().get_blocked_client_hosts();\n  ASSERT_GE(blocked_hosts.size(), 1u);\n  ASSERT_THAT(blocked_hosts[0], ContainerEq(client_ip_array1));\n\n  ASSERT_FALSE(r.get_context().block_client_host(client_ip_array2, string(\"::2\")));\n  ASSERT_TRUE(r.get_context().block_client_host(client_ip_array2, string(\"::2\")));\n\n  blocked_hosts = r.get_context().get_blocked_client_hosts();\n  ASSERT_THAT(blocked_hosts[0], ContainerEq(client_ip_array1));\n  ASSERT_THAT(blocked_hosts[1], ContainerEq(client_ip_array2));\n}\n\nTEST_F(TestBlockClients, BlockClientHostWithFakeResponse) {\n  unsigned long long max_connect_errors = 2;\n  std::chrono::seconds client_connect_timeout(2);\n  union {\n    sockaddr_in6 client_addr1;\n    sockaddr_storage client_addr1_storage;\n  };\n  client_addr1.sin6_family = AF_INET6;\n  memset(&client_addr1.sin6_addr, 0x0, sizeof(client_addr1.sin6_addr));\n  unsigned char* p = reinterpret_cast<unsigned char*>(&client_addr1.sin6_addr);\n  p[15] = 1;\n  auto client_ip_array1 = in_addr_to_array(client_addr1_storage);\n\n  MySQLRouting r(routing::RoutingStrategy::kNextAvailable,\n                 7001, Protocol::Type::kClassicProtocol,\n                 routing::AccessMode::kReadWrite,\n                 \"127.0.0.1\", mysql_harness::Path(), \"routing:connect_erros\",\n                 1, std::chrono::seconds(1), max_connect_errors, client_connect_timeout);\n\n  std::FILE* fd_response = std::fopen(\"fake_response.data\", \"w\");\n\n  ASSERT_FALSE(r.get_context().block_client_host(client_ip_array1, string(\"::1\"), fileno(fd_response)));\n  std::fclose(fd_response);\n#ifndef _WIN32\n  // block_client_host() will not be able to write data to the file because in windows, the\n  // syscall to writing to sockets is different than for files\n  fd_response = std::fopen(\"fake_response.data\", \"r\");\n\n  auto fake_response = mysql_protocol::HandshakeResponsePacket(1, {}, \"ROUTER\", \"\", \"fake_router_login\");\n\n  auto server_response = ssout.str();\n  for (size_t i = 0; i < fake_response.size(); ++i) {\n     ASSERT_EQ(fake_response.at(i), std::fgetc(fd_response));\n  }\n  std::fclose(fd_response);\n#endif\n  std::remove(\"fake_response.data\");\n}\n\nint main(int argc, char *argv[]) {\n  init_windows_sockets();\n  g_origin = Path(argv[0]).dirname();\n  g_cwd = Path(argv[0]).dirname().str();\n  ::testing::InitGoogleTest(&argc, argv);\n\n  init_test_logger();\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/routing/tests/test_classic_protocol.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <memory>\n\n#include \"mysql/harness/logging/logging.h\"\n#include \"protocol/classic_protocol.h\"\n#include \"mysqlrouter/routing.h\"\n#include \"routing_mocks.h\"\n#include \"mysql_routing.h\"\n#include \"test/helpers.h\"\n\n#include \"gtest/gtest.h\"\n#include \"gmock/gmock.h\"\n\nusing ::testing::_;\nusing ::testing::Args;\nusing ::testing::DoAll;\nusing ::testing::InvokeWithoutArgs;\nusing ::testing::Return;\n\nusing namespace mysql_protocol;\n\nclass ClassicProtocolTest : public ::testing::Test {\nprotected:\n  ClassicProtocolTest() :\n    mock_routing_sock_ops_(new MockRoutingSockOps()),\n    mock_socket_operations_(mock_routing_sock_ops_->so()),\n    sut_protocol_(new ClassicProtocol(mock_routing_sock_ops_.get()))\n  {}\n\n  virtual void SetUp() {\n    network_buffer_.resize(routing::kDefaultNetBufferLength);\n    network_buffer_offset_ = 0;\n    curr_pktnr_ = 0;\n    handshake_done_ = false;\n  }\n\n  std::unique_ptr<MockRoutingSockOps> mock_routing_sock_ops_;\n  MockSocketOperations* mock_socket_operations_;\n\n  // the tested object:\n  std::unique_ptr<BaseProtocol> sut_protocol_;\n\n  void serialize_classic_packet_to_buffer(RoutingProtocolBuffer &buffer,\n                                          size_t &buffer_offset,\n                                          const mysql_protocol::Packet &packet\n                                          ) {\n    using diff_t = mysql_protocol::Packet::difference_type;\n    std::copy(packet.begin(), packet.begin()+static_cast<diff_t>(packet.size()),\n              buffer.begin()+static_cast<diff_t>(buffer_offset));\n    buffer_offset += packet.size();\n  }\n\n  static constexpr int sender_socket_ = 1;\n  static constexpr int receiver_socket_ = 2;\n\n  RoutingProtocolBuffer network_buffer_;\n  size_t network_buffer_offset_;\n  int curr_pktnr_;\n  bool handshake_done_;\n};\n\nclass ClassicProtocolRoutingTest: public ClassicProtocolTest {};\n\nTEST_F(ClassicProtocolTest, OnBlockClientHostSuccess)\n{\n  // we expect the router sending fake response packet\n  // to prevent MySQL server from bumping up connection error counter\n  auto packet = mysql_protocol::HandshakeResponsePacket(1, {}, \"ROUTER\", \"\", \"fake_router_login\");\n\n  EXPECT_CALL(*mock_socket_operations_, write(receiver_socket_, _, packet.size())).WillOnce(Return((ssize_t)packet.size()));\n\n  const bool result = sut_protocol_->on_block_client_host(receiver_socket_, \"routing\");\n\n  ASSERT_TRUE(result);\n}\n\nTEST_F(ClassicProtocolTest, OnBlockClientHostWriteFail)\n{\n  auto packet = mysql_protocol::HandshakeResponsePacket(1, {}, \"ROUTER\", \"\", \"fake_router_login\");\n\n  mock_routing_sock_ops_->so()->set_errno(ECONNREFUSED);\n\n  EXPECT_CALL(*mock_socket_operations_, write(receiver_socket_, _, packet.size())).WillOnce(Return(-1));\n\n  const bool result = sut_protocol_->on_block_client_host(receiver_socket_, \"routing\");\n\n  ASSERT_FALSE(result);\n}\n\nTEST_F(ClassicProtocolTest, CopyPacketsFdNotSet)\n{\n  size_t report_bytes_read = 0xff;\n\n  int result = sut_protocol_->copy_packets(sender_socket_, receiver_socket_, false, network_buffer_, &curr_pktnr_,\n                                         handshake_done_, &report_bytes_read, true);\n\n  ASSERT_TRUE(result==0);\n  ASSERT_TRUE(report_bytes_read==0);\n  ASSERT_FALSE(handshake_done_);\n}\n\nTEST_F(ClassicProtocolTest, CopyPacketsReadError)\n{\n  size_t report_bytes_read = 0xff;\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_,_,_)).WillOnce(Return(-1));\n\n  int result = sut_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                         handshake_done_, &report_bytes_read, true);\n\n  ASSERT_FALSE(handshake_done_);\n  ASSERT_EQ(-1, result);\n}\n\nTEST_F(ClassicProtocolTest, CopyPacketsHandshakeDoneOK)\n{\n  handshake_done_ = true;\n  size_t report_bytes_read = 0xff;\n  constexpr int PACKET_SIZE = 20;\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_, &network_buffer_[0], network_buffer_.size())).WillOnce(Return(PACKET_SIZE));\n  EXPECT_CALL(*mock_socket_operations_, write(receiver_socket_, &network_buffer_[0], PACKET_SIZE)).WillOnce(Return(PACKET_SIZE));\n\n  int result = sut_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                         handshake_done_, &report_bytes_read, true);\n\n  ASSERT_TRUE(handshake_done_);\n  ASSERT_EQ(0, result);\n  ASSERT_EQ(static_cast<size_t>(PACKET_SIZE), report_bytes_read);\n}\n\nTEST_F(ClassicProtocolTest, CopyPacketsHandshakeDoneWriteError)\n{\n  handshake_done_ = true;\n  size_t report_bytes_read = 0xff;\n  constexpr ssize_t PACKET_SIZE = 20;\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_, &network_buffer_[0], network_buffer_.size())).\n                                                                  WillOnce(Return(PACKET_SIZE));\n  EXPECT_CALL(*mock_socket_operations_, write(receiver_socket_, &network_buffer_[0], 20)).WillOnce(Return(-1));\n\n  int result = sut_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                       handshake_done_, &report_bytes_read, true);\n\n  ASSERT_TRUE(handshake_done_);\n  ASSERT_EQ(-1, result);\n}\n\nTEST_F(ClassicProtocolTest, CopyPacketsHandshakePacketTooSmall)\n{\n  size_t report_bytes_read = 3;\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_, &network_buffer_[0], network_buffer_.size())).\n                                                                  WillOnce(Return((ssize_t)report_bytes_read));\n\n  int result = sut_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                       handshake_done_, &report_bytes_read, true);\n\n  ASSERT_FALSE(handshake_done_);\n  ASSERT_EQ(-1, result);\n}\n\nTEST_F(ClassicProtocolTest, CopyPacketsHandshakeInvalidPacketNumber)\n{\n  size_t report_bytes_read = 0xff;\n  constexpr int packet_no = 3;\n  curr_pktnr_ = 1;\n\n  auto error_packet = mysql_protocol::ErrorPacket(packet_no, 122, \"Access denied\", \"HY004\");\n  serialize_classic_packet_to_buffer(network_buffer_, network_buffer_offset_, error_packet);\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_, &network_buffer_[0], network_buffer_.size())).\n                                                                  WillOnce(Return((ssize_t)report_bytes_read));\n\n  int result = sut_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                       handshake_done_, &report_bytes_read, true);\n\n  ASSERT_FALSE(handshake_done_);\n  ASSERT_EQ(-1, result);\n}\n\n\nTEST_F(ClassicProtocolTest, CopyPacketsHandshakeServerSendsError)\n{\n  size_t report_bytes_read = 0xff;\n  curr_pktnr_ = 1;\n\n  auto error_packet = mysql_protocol::ErrorPacket(2, 0xaabb, \"Access denied\", \"HY004\", Capabilities::PROTOCOL_41);\n\n  serialize_classic_packet_to_buffer(network_buffer_, network_buffer_offset_, error_packet);\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_, &network_buffer_[0], network_buffer_.size())).\n                                                                  WillOnce(Return((ssize_t)network_buffer_offset_));\n\n  EXPECT_CALL(*mock_socket_operations_, write(receiver_socket_, _, network_buffer_offset_)).\n                                                       WillOnce(Return((ssize_t)network_buffer_offset_));\n\n  int result = sut_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                       handshake_done_, &report_bytes_read, true);\n\n  // if the server sent error handshake is considered done\n  ASSERT_EQ(2, curr_pktnr_);\n  ASSERT_EQ(0, result);\n}\n\nTEST_F(ClassicProtocolTest, SendErrorOKMultipleWrites)\n{\n  EXPECT_CALL(*mock_socket_operations_, write(1, _, _)).Times(2).\n                                                  WillOnce(Return(8)).\n                                                  WillOnce(Return (10000));\n\n  bool res = sut_protocol_->send_error(1, 55, \"Error message\", \"HY000\",\n                                   \"routing configuration name\");\n\n  ASSERT_TRUE(res);\n}\n\nTEST_F(ClassicProtocolTest, SendErrorWriteFail)\n{\n  auto set_errno = [&]() -> void {errno=15;};\n  EXPECT_CALL(*mock_socket_operations_, write(1, _, _)).WillOnce(DoAll(InvokeWithoutArgs(set_errno), Return(-1)));\n\n  bool res = sut_protocol_->send_error(1, 55, \"Error message\", \"HY000\",\n                                   \"routing configuration name\");\n\n  ASSERT_FALSE(res);\n}\n\nMATCHER_P(BufferEq, buf1,\n           std::string(negation ? \"Buffers content does not match\" : \"Buffers content matches\"))\n{\n  if (buf1.size() != ::std::get<1>(arg))\n    return false;\n\n  return 0 == memcmp(buf1.data(), ::std::get<0>(arg), buf1.size());\n}\n\n// check if the proper error is sent by the router if there is no valid\n// destination server\nTEST_F(ClassicProtocolRoutingTest, NoValidDestinations) {\n\n  MySQLRouting routing(routing::RoutingStrategy::kRoundRobin,\n                       7001, Protocol::Type::kClassicProtocol,\n                       routing::AccessMode::kReadWrite,\n                       \"127.0.0.1\", mysql_harness::Path(), \"routing:test\",\n                       routing::kDefaultMaxConnections,\n                       routing::kDefaultDestinationConnectionTimeout,\n                       routing::kDefaultMaxConnectErrors,\n                       routing::kDefaultClientConnectTimeout,\n                       routing::kDefaultNetBufferLength,\n                       mock_routing_sock_ops_.get());\n\n\n  constexpr int client_socket = 1;\n  constexpr int server_socket = -1;\n  union {\n    sockaddr_storage client_addr_storage;\n    sockaddr_in6 client_addr;\n  };\n  client_addr.sin6_family = AF_INET6;\n  memset(&client_addr.sin6_addr, 0x0, sizeof(client_addr.sin6_addr));\n\n  auto error_packet = mysql_protocol::ErrorPacket(0, 2003, \"Can't connect to remote MySQL server for client connected to '127.0.0.1:7001'\", \"HY000\");\n  const auto error_packet_size = static_cast<ssize_t>(error_packet.size());\n\n  EXPECT_CALL(*mock_socket_operations_, write(client_socket, _, _))\n          .With(Args<1,2>(BufferEq(error_packet)))\n          .WillOnce(Return(error_packet_size));\n\n  EXPECT_CALL(*mock_socket_operations_, shutdown(client_socket));\n  EXPECT_CALL(*mock_socket_operations_, close(client_socket));\n\n  routing.set_destinations_from_csv(\"127.0.0.1:7004\");\n  mysql_harness::TCPAddress server_address(\"127.0.0.1\", 7004);\n\n  MySQLRoutingConnection connection(routing.get_context(), client_socket,\n      client_addr_storage, server_socket, server_address, [](MySQLRoutingConnection*) {});\n  connection.run();\n\n}\n\nint main(int argc, char *argv[]) {\n#ifdef _WIN32\n  WSADATA wsaData;\n  int iResult;\n  iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);\n  if (iResult != 0) {\n    std::cout << \"WSAStartup() failed\\n\";\n    return 1;\n  }\n#endif\n  init_test_logger();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/routing/tests/test_config.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"cmd_exec.h\"\n#include \"gtest_consoleoutput.h\"\n#include \"mysql/harness/config_parser.h\"\n#include \"mysql/harness/plugin.h\"\n#include \"mysqlrouter/mysql_protocol.h\"\n#include \"mysqlrouter/routing.h\"\n#include \"router_test_helpers.h\"\n#include \"../../router/src/router_app.h\"\n#include \"../../routing/src/mysql_routing.h\"\n#include \"../../routing/src/utils.h\"\n#include \"test/helpers.h\"\n\n#include <cstdio>\n#include <fstream>\n#include <future>\n#include <memory>\n#include <string>\n#include <thread>\n#ifndef _WIN32\n# include <netinet/in.h>\n#else\n# include <WinSock2.h>\n#endif\n\n#include \"gmock/gmock.h\"\n\nusing std::string;\nusing ::testing::ContainerEq;\nusing ::testing::HasSubstr;\nusing ::testing::StrEq;\nusing mysql_harness::Path;\n\nstring g_cwd;\nPath g_origin;\n\n// Used in tests; does not change for each test.\nconst string kDefaultRoutingConfig = \"\\ndestinations=127.0.0.1:3306\\nrouting_strategy=first-available\\n\";\nconst string kDefaultRoutingConfigStrategy = \"\\ndestinations=127.0.0.1:3306\\nbind_address=127.0.0.1\\nbind_port=6000\\n\";\n\nclass TestConfig : public ConsoleOutputTest {\nprotected:\n  virtual void SetUp() {\n    set_origin(g_origin);\n    ConsoleOutputTest::SetUp();\n    config_path.reset(new Path(g_cwd));\n    config_path->append(\"Bug22020088.conf\");\n  }\n\n  void reset_config() {\n    std::ofstream ofs_config(config_path->str());\n    if (ofs_config.good()) {\n      ofs_config << \"[DEFAULT]\\n\";\n      ofs_config << \"logging_folder =\\n\";\n      ofs_config << \"plugin_folder = \" << plugin_dir->str() << \"\\n\";\n      ofs_config << \"runtime_folder = \" << stage_dir->str() << \"\\n\";\n      ofs_config << \"config_folder = \" << stage_dir->str() << \"\\n\\n\";\n      ofs_config.close();\n    }\n  }\n\n  std::unique_ptr<Path> config_path;\n};\n\nTEST_F(TestConfig, NoDestination) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing]\\n\";\n  c << kDefaultRoutingConfig;\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument,\n      \"either bind_address or socket option needs to be supplied, or both\");\n}\n\nTEST_F(TestConfig, MissingPortInBindAddress) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing]\\nbind_address=127.0.0.1\\n\";\n  c << kDefaultRoutingConfig;\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument,\n      \"either bind_address or socket option needs to be supplied, or both\");\n}\n\nTEST_F(TestConfig, InvalidPortInBindAddress) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing]\\nbind_address=127.0.0.1:999292\\n\";\n  c << kDefaultRoutingConfig;\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument,\n      \"option bind_address in [routing] is incorrect (invalid TCP port: invalid characters or too long)\");\n}\n\nTEST_F(TestConfig, InvalidDefaultPort) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing]\\nbind_port=23123124123123\\n\";\n  c << kDefaultRoutingConfig;\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument,\n      \"option bind_port in [routing] needs value between 1 and 65535 inclusive, was '23123124123123'\");\n}\n\nTEST_F(TestConfig, InvalidMode) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing]\\nmode=invalid\";\n  c << kDefaultRoutingConfigStrategy;\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument,\n      \"option mode in [routing] is invalid; valid are read-write and read-only (was 'invalid')\");\n}\n\nTEST_F(TestConfig, InvalidStrategyOption) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing]\\nrouting_strategy=invalid\";\n  c << kDefaultRoutingConfigStrategy;\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument,\n      \"option routing_strategy in [routing] is invalid; valid are first-available, \"\n      \"next-available, and round-robin (was 'invalid')\");\n}\n\nTEST_F(TestConfig, EmptyStrategyOption) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing]\\nrouting_strategy=\";\n  c << kDefaultRoutingConfigStrategy;\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument,\n      \"option routing_strategy in [routing] needs a value\");\n}\n\nTEST_F(TestConfig, EmptyMode) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing]\\nmode=\";\n  c << kDefaultRoutingConfigStrategy;\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument,\n      \"option mode in [routing] needs a value\");\n}\n\nTEST_F(TestConfig, NoStrategyOptionAndNoMode) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing]\\n\";\n  c << kDefaultRoutingConfigStrategy;\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument,\n      \"option routing_strategy in [routing] is required\");\n}\n\nTEST_F(TestConfig, UnsupportedStrategyOption) {\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[routing]\\nrouting_strategy=round-robin-with-fallback\";\n  c << kDefaultRoutingConfigStrategy;\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument,\n      \"option routing_strategy in [routing] is invalid; valid are first-available, \"\n      \"next-available, and round-robin (was 'round-robin-with-fallback')\");\n}\n\nstruct ThreadStackSizeInfo {\n  std::string thread_stack_size;\n  std::string message;\n};\n\nclass TestConfigThreadStackSize : public ConsoleOutputTest,\n    public testing::WithParamInterface<ThreadStackSizeInfo> {\npublic:\n  void SetUp() override{\n    set_origin(g_origin);\n    ConsoleOutputTest::SetUp();\n    config_path.reset(new Path(g_cwd));\n    config_path->append(\"mysqlrouter.conf\");\n  }\n\n  void reset_config() {\n    std::ofstream ofs_config(config_path->str());\n    if (ofs_config.good()) {\n      ofs_config << \"[DEFAULT]\\n\";\n      ofs_config << \"logging_folder =\\n\";\n      ofs_config << \"plugin_folder = \" << plugin_dir->str() << \"\\n\";\n      ofs_config << \"runtime_folder = \" << stage_dir->str() << \"\\n\";\n      ofs_config << \"config_folder = \" << stage_dir->str() << \"\\n\\n\";\n      ofs_config.close();\n    }\n  }\n\n  std::unique_ptr<Path> config_path;\n};\n\nThreadStackSizeInfo test_data[] = {\n    { \"-1\", \"option thread_stack_size in [default] needs value between 1 and 65535 inclusive, was '-1'\" },\n    { \"4.5\", \"option thread_stack_size in [default] needs value between 1 and 65535 inclusive, was '4.5'\" },\n    { \"dfs4\", \"option thread_stack_size in [default] needs value between 1 and 65535 inclusive, was 'dfs4'\"}\n};\n\nTEST_P(TestConfigThreadStackSize, ParseThreadStackSize) {\n  ThreadStackSizeInfo input = GetParam();\n  reset_config();\n  std::ofstream c(config_path->str(), std::fstream::app | std::fstream::out);\n  c << \"[DEFAULT]\\nthread_stack_size=\";\n  c << input.thread_stack_size << \"\\n[routing]\\nrouting_strategy=round-robin\\n\";\n  c << kDefaultRoutingConfigStrategy;\n  c.close();\n\n  MySQLRouter r(g_origin, {\"-c\", config_path->str()});\n  ASSERT_THROW_LIKE(r.start(), std::invalid_argument, input.message);\n}\n\nINSTANTIATE_TEST_CASE_P(\n    ConfigThreadStackSizeTests, TestConfigThreadStackSize,\n    ::testing::ValuesIn(test_data)\n    );\n\nint main(int argc, char *argv[]) {\n  init_windows_sockets();\n  g_origin = Path(argv[0]).dirname();\n  g_cwd = Path(argv[0]).dirname().str();\n  register_test_logger();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/routing/tests/test_connection.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"connection.h\"\n#include \"context.h\"\n#include \"protocol/base_protocol.h\"\n#include \"protocol/classic_protocol.h\"\n#include \"routing_mocks.h\"\n#include \"routing_mocks.h\"\n#include \"socket_operations.h\"\n#include \"tcp_port_pool.h\"\n#include \"test/helpers.h\"\n\n#include \"gtest/gtest.h\"\n#include \"gmock/gmock.h\"\n\nclass MockProtocol : public BaseProtocol {\npublic:\n\n  MockProtocol() : BaseProtocol(nullptr) {}\n\n  MOCK_METHOD2(on_block_client_host, bool(int, const std::string&));\n  MOCK_METHOD8(copy_packets, int(int, int, bool,\n      RoutingProtocolBuffer&, int* , bool&, size_t*, bool));\n  MOCK_METHOD5(send_error, bool(int, unsigned short, const std::string&,\n      const std::string&, const std::string&));\n  MOCK_METHOD0(get_type, BaseProtocol::Type());\n};\n\nclass TestRoutingConnection : public testing::Test {\npublic:\n\n  void SetUp() override {\n    protocol_.reset(new MockProtocol);\n    name_ = \"routing_name\";\n    net_buffer_length_ = routing::kDefaultNetBufferLength;\n    destination_connect_timeout_ = std::chrono::milliseconds(10);\n    client_connect_timeout_ = std::chrono::milliseconds(10);\n    max_connect_errors_ = 100;\n    thread_stack_size_ = 1000;\n    client_socket_ = 3243; // any number greater than 0\n    server_socket_ = 5345; // any number greater than 0\n  }\n\n  // context\n  std::unique_ptr<MockProtocol> protocol_;\n  MockSocketOperations socket_operations_;\n  std::string name_;\n  unsigned int net_buffer_length_;\n  std::chrono::milliseconds destination_connect_timeout_;\n  std::chrono::milliseconds client_connect_timeout_;\n  mysql_harness::TCPAddress bind_address_;\n  mysql_harness::Path bind_named_socket_;\n  unsigned long long max_connect_errors_;\n  size_t thread_stack_size_ = 1000;\n\n  // connection\n  int client_socket_;\n  sockaddr_storage client_addr_;\n  int server_socket_;\n  mysql_harness::TCPAddress server_address_;\n\n  mysql_harness::Path bind_named_socket;\n};\n\n/**\n * @test\n *       Verify if callback is called when run() function completes.\n */\nTEST_F(TestRoutingConnection, IsCallbackCalledAtRunExit) {\n  EXPECT_CALL(socket_operations_, shutdown(testing::_)).Times(2);\n  EXPECT_CALL(socket_operations_, close(testing::_)).Times(2);\n\n  EXPECT_CALL(*protocol_, on_block_client_host(testing::_, testing::_))\n      .Times(testing::AtLeast(0)).WillRepeatedly(testing::Return(false));\n\n  MySQLRoutingContext context(protocol_.release(),\n      &socket_operations_,\n      name_,\n      net_buffer_length_,\n      destination_connect_timeout_,\n      client_connect_timeout_,\n      bind_address_,\n      bind_named_socket_,\n      max_connect_errors_,\n      thread_stack_size_);\n\n  bool is_called = false;\n\n  MySQLRoutingConnection connection(context,\n      client_socket_,\n      client_addr_,\n      server_socket_,\n      server_address_,\n      [&is_called](MySQLRoutingConnection* /* connection */) {\n        is_called = true;\n  });\n\n  // disconnect the connection\n  connection.disconnect();\n\n  // run connection in current thread\n  connection.run();\n\n  ASSERT_TRUE(is_called);\n}\n\n/**\n * @test\n *       Verify if callback is called when connection is closed.\n */\nTEST_F(TestRoutingConnection, IsCallbackCalledAtThreadExit) {\n\n  EXPECT_CALL(socket_operations_, shutdown(testing::_)).Times(2);\n  EXPECT_CALL(socket_operations_, close(testing::_)).Times(2);\n\n  EXPECT_CALL(*protocol_, on_block_client_host(testing::_, testing::_))\n      .Times(testing::AtLeast(0)).WillRepeatedly(testing::Return(false));\n\n  MySQLRoutingContext context(protocol_.release(),\n      &socket_operations_,\n      name_,\n      net_buffer_length_,\n      destination_connect_timeout_,\n      client_connect_timeout_,\n      bind_address_,\n      bind_named_socket_,\n      max_connect_errors_,\n      thread_stack_size_);\n\n  bool is_called = false;\n\n  MySQLRoutingConnection connection(context,\n      client_socket_,\n      client_addr_,\n      server_socket_,\n      server_address_,\n      [&is_called](MySQLRoutingConnection* /* connection */) {\n        is_called = true;\n  });\n\n  // disconnect the thread\n  connection.disconnect();\n\n  // start new connection thread and wait for completion\n  connection.start(false);\n  ASSERT_TRUE(is_called);\n}\n\n/**\n * @test\n *       Verify if callback is called and thread of execution stops\n *       when connection is closed.\n */\nTEST_F(TestRoutingConnection, IsConnectionThreadStopOnDisconnect) {\n\n  struct pollfd fds[] = {\n    { client_socket_, POLLIN, 1 },\n    { server_socket_, POLLIN, 1 },\n  };\n\n  using ::testing::InSequence;\n  EXPECT_CALL(socket_operations_, poll(\n      testing::_, testing::_, testing::_))\n          .WillRepeatedly(testing::DoAll(testing::SetArgPointee<0>(fds[0]),\n          testing::Return(1)));\n\n  EXPECT_CALL(*protocol_, copy_packets(testing::_, testing::_,\n      testing::_, testing::_, testing::_, testing::_,\n      testing::_, testing::_))\n      .WillRepeatedly(testing::Return(1));\n\n  EXPECT_CALL(socket_operations_, shutdown(testing::_)).Times(2);\n  EXPECT_CALL(socket_operations_, close(testing::_)).Times(2);\n\n  EXPECT_CALL(*protocol_, on_block_client_host(testing::_, testing::_))\n      .Times(testing::AtLeast(0)).WillRepeatedly(testing::Return(false));\n\n  MySQLRoutingContext context(protocol_.release(),\n      &socket_operations_,\n      name_,\n      net_buffer_length_,\n      destination_connect_timeout_,\n      client_connect_timeout_,\n      bind_address_,\n      bind_named_socket_,\n      max_connect_errors_,\n      thread_stack_size_);\n\n  bool is_called = false;\n\n  MySQLRoutingConnection connection(context,\n      client_socket_,\n      client_addr_,\n      server_socket_,\n      server_address_,\n      [&is_called](MySQLRoutingConnection* /* connection */) {\n        is_called = true;\n  });\n\n  // start new connection thread\n  connection.start();\n\n  // wait for a while to let connection thread run\n  std::this_thread::sleep_for(std::chrono::milliseconds(100));\n\n  // disconnect the connection\n  connection.disconnect();\n\n  // wait for connection to close\n  std::this_thread::sleep_for(std::chrono::milliseconds(100));\n\n  ASSERT_TRUE(is_called);\n}\n\nint main(int argc, char *argv[]) {\n  init_test_logger();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/routing/tests/test_connection_container.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"gmock/gmock.h\"\n#include \"mysql_routing_common.h\"\n#include \"connection.h\"\n#include \"context.h\"\n#include \"connection_container.h\"\n#include <memory>\n#include <utility>\n#include <thread>\n\n\nclass A{\n  int x_;\npublic:\n  A() : x_{0} {}\n  explicit A(int x) : x_(x) {}\n  int get() const {\n    return x_;\n  }\n};\n\n\nclass TestConcurrentMap : public testing::Test {\n};\n\n/**\n * @test\n *       Verify that concurrent_map is empty when created\n */\nTEST_F(TestConcurrentMap, IsMapEmptyWhenCreated) {\n  concurrent_map<A*, std::unique_ptr<A>> a_map;\n  ASSERT_THAT(a_map.size(), testing::Eq(0u));\n}\n\n/**\n * @test\n *       Verify that concurrent_map size is increased when entry\n *       is added.\n */\nTEST_F(TestConcurrentMap, IsMapSizeCorrectAfterAddedEntries) {\n  concurrent_map<A*, std::unique_ptr<A>> a_map;\n  std::unique_ptr<A> a_1(new A);\n  A* p_1 = a_1.get();\n  std::unique_ptr<A> a_2(new A);\n  A* p_2 = a_2.get();\n  std::unique_ptr<A> a_3(new A);\n  A* p_3 = a_3.get();\n\n  a_map.put(p_1, std::move(a_1));\n  a_map.put(p_2, std::move(a_2));\n  a_map.put(p_3, std::move(a_3));\n\n  ASSERT_THAT(a_map.size(), testing::Eq(3u));\n}\n\n/**\n * @test\n *       Verify that concurrent_map size is decreased when entry\n *       is removed.\n */\nTEST_F(TestConcurrentMap, IsMapSizeCorrectAfterErase) {\n  concurrent_map<A*, std::unique_ptr<A>> a_map;\n  std::unique_ptr<A> a_1(new A);\n  A* p_1 = a_1.get();\n  std::unique_ptr<A> a_2(new A);\n  A* p_2 = a_2.get();\n  std::unique_ptr<A> a_3(new A);\n  A* p_3 = a_3.get();\n\n  a_map.put(p_1, std::move(a_1));\n  a_map.put(p_2, std::move(a_2));\n  a_map.put(p_3, std::move(a_3));\n\n  a_map.erase(p_1);\n  a_map.erase(p_2);\n\n  ASSERT_THAT(a_map.size(), testing::Eq(1u));\n}\n\n/**\n * @test\n *       Verify if get returns correct entry.\n */\nTEST_F(TestConcurrentMap, IsGetReturnsCorrectResult) {\n  concurrent_map<A*, std::unique_ptr<A>> a_map;\n  std::unique_ptr<A> a_1(new A(34));\n  A* p_1 = a_1.get();\n  std::unique_ptr<A> a_2(new A(52));\n  A* p_2 = a_2.get();\n  std::unique_ptr<A> a_3(new A(78));\n  A* p_3 = a_3.get();\n\n  a_map.put(p_1, std::move(a_1));\n  a_map.put(p_2, std::move(a_2));\n  a_map.put(p_3, std::move(a_3));\n\n  int element_value = 0;\n  auto get_value = [&element_value] (const std::unique_ptr<A>& a) {\n    element_value = a->get();\n  };\n  a_map.for_one(p_2, get_value);\n  ASSERT_THAT(element_value, testing::Eq(52));\n}\n\n/**\n * @test\n *       Verify if get returns default value if entry cannot be found.\n */\nTEST_F(TestConcurrentMap, IsGetReturnsDefaultValueIfNoEntriesWithKey) {\n  concurrent_map<A*, std::unique_ptr<A>> a_map;\n  std::unique_ptr<A> a_1(new A(34));\n  A* p_1 = a_1.get();\n  std::unique_ptr<A> a_2(new A(52));\n  A* p_2 = a_2.get();\n  std::unique_ptr<A> a_3(new A(78));\n  A* p_3 = a_3.get();\n\n  a_map.put(p_1, std::move(a_1));\n  a_map.put(p_2, std::move(a_2));\n\n  int element_value = 0;\n  auto get_value = [&element_value] (const std::unique_ptr<A>& a) {\n    element_value = a->get();\n  };\n  a_map.for_one(p_3, get_value);\n  ASSERT_THAT(element_value, testing::Eq(0));\n}\n\n/**\n * @test\n *       Verify if function is called for every entry in concurrent_map\n *       when for_each is used.\n */\nTEST_F(TestConcurrentMap, IsForEachVisitEveryEntry) {\n  concurrent_map<A*, std::unique_ptr<A>> a_map;\n  std::unique_ptr<A> a_1(new A(34));\n  A* p_1 = a_1.get();\n  std::unique_ptr<A> a_2(new A(52));\n  A* p_2 = a_2.get();\n  std::unique_ptr<A> a_3(new A(78));\n  A* p_3 = a_3.get();\n\n  a_map.put(p_1, std::move(a_1));\n  a_map.put(p_2, std::move(a_2));\n  a_map.put(p_3, std::move(a_3));\n\n  int counter = 0;\n\n  auto count_function =\n        [&counter](std::pair<A* const, std::unique_ptr<A>>& connection) {\n    counter += connection.first->get() * connection.first->get();\n  };\n\n  a_map.for_each(count_function);\n  ASSERT_THAT(counter, testing::Eq(9944));\n}\n\n/**\n * @test\n *      Verify if data in concurrent_map are not broken when many threads\n *      work concurrently with it.\n */\nTEST_F(TestConcurrentMap, IsMultipleAccessCorrect) {\n  concurrent_map<A*, std::unique_ptr<A>> a_map;\n\n  auto add_to_map = [&a_map] {\n    for(int i=0; i<1000; ++i) {\n      std::unique_ptr<A> a(new A(i));\n      A* p = a.get();\n      a_map.put(p, std::move(a));\n    }\n  };\n\n  auto list_elements = [&a_map] {\n    int counter = 0;\n\n    auto dummy_function =\n          [&counter](std::pair<A* const, std::unique_ptr<A>>& /* connection */) {\n      ++counter;\n    };\n\n    for(int i=0; i<10; ++i) {\n      a_map.for_each(dummy_function);\n      std::this_thread::sleep_for(std::chrono::milliseconds(10));\n    }\n  };\n\n  std::vector<std::thread> threads;\n  for(int i=0; i<100; ++i) threads.emplace_back(add_to_map);\n  for(int i=0; i<5; ++i) threads.emplace_back(list_elements);\n\n  for(auto& each_thread : threads) each_thread.join();\n\n  ASSERT_THAT(a_map.size(), testing::Eq(100000u));\n}\n\nint main(int argc, char *argv[]) {\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/routing/tests/test_first_available.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"dest_first_available.h\"\n#include \"routing_mocks.h\"\n#include \"test/helpers.h\"\n\nclass FirstAvailableTest : public ::testing::Test {\n\n public:\n  FirstAvailableTest() : routing_sock_ops_(new MockRoutingSockOps()),\n                         dest_(Protocol::Type::kClassicProtocol, routing_sock_ops_.get()) {\n    dest_.add(\"41\", 1);\n    dest_.add(\"42\", 2);\n    dest_.add(\"43\", 3);\n  }\n\n  DestFirstAvailable& dest() {\n    return dest_;\n  }\n\nprotected:\n  std::unique_ptr<MockRoutingSockOps> routing_sock_ops_;\n private:\n  DestFirstAvailable dest_; // this is the class we're testing\n};\n\n/**\n * @test The idea behind these tests is to test DestFirstAvailable::get_server_socket() server selection\n *       strategy. That method is responsible for returning the new connection to the active server.\n *       The active server should be switched in such fashion:\n *\n *         A -> B -> C -> A -> B -> C -> ...\n *\n *       The switch should occur only when the current active server becomes unavailable.\n *       DestFirstAvailable::get_server_socket() relies on RoutingSockOpsInterface::get_mysql_socket()\n *       to return the actual file descriptor, which we mock in this test to simulate connection success\n *       or failure.\n */\nTEST_F(FirstAvailableTest, TypicalFailoverSequence) {\n  int dummy;\n\n  // talk to 1st server\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 5); // 5 good connections\n\n  // fail 1st server -> failover to 2nd\n  routing_sock_ops_->get_mysql_socket_fail(1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 42);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 2); // 1 failed + 1 good conn\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 42);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 42);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 42);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 42);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 4); // 4 more good conns\n\n  // fail 2nd server -> failover to 3rd\n  routing_sock_ops_->get_mysql_socket_fail(1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 43);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 2); // 1 failed + 1 good conn\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 43);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 43);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 43);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 43);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 4); // 4 more good conns\n\n  // fail 3rd server -> back to 1st\n  routing_sock_ops_->get_mysql_socket_fail(1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 2); // 1 failed\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 4); // 4 more good conns\n}\n\nTEST_F(FirstAvailableTest, StartWith1stDown) {\n  int dummy;\n\n  // fail 1st server -> failover to 2nd\n  routing_sock_ops_->get_mysql_socket_fail(1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 42);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 2); // 1 failed + 1 good conn\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 42);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 42);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 42);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 42);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 4); // 4 more good conns\n\n  // fail 2nd server -> failover to 3rd\n  routing_sock_ops_->get_mysql_socket_fail(1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 43);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 2); // 1 failed + 1 good conn\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 43);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 43);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 43);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 43);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 4); // 4 more good conns\n\n  // fail 3rd server -> back to 1st\n  routing_sock_ops_->get_mysql_socket_fail(1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 2); // 1 failed + 1 good conn\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 4); // 4 more good conns\n}\n\nTEST_F(FirstAvailableTest, StartWith2ndDown) {\n  int dummy;\n\n  // fail 1st and 2nd server -> failover to 3rd\n  routing_sock_ops_->get_mysql_socket_fail(2);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 43);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 3); // 2 failed + 1 good conn\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 43);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 43);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 43);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 43);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 4); // 4 more good conns\n\n  // fail 3rd server -> no more servers\n  routing_sock_ops_->get_mysql_socket_fail(1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 2); // 1 failed + 1 good conn\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 4); // 4 more good conns\n}\n\n\nTEST_F(FirstAvailableTest, StartWithAllDown) {\n  int dummy;\n\n  // fail 1st, 2nd and 3rd server -> no more servers\n  routing_sock_ops_->get_mysql_socket_fail(3);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), -1);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 3); // 3 failed, no more servers\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41); // back to first\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::seconds::zero(), &dummy), 41);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 3); // 3 more good conns\n}\n\nint main(int argc, char *argv[]) {\n  init_test_logger();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n\n"
  },
  {
    "path": "src/routing/tests/test_metadata_cache_group.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"dest_metadata_cache.h\"\n#include \"routing_mocks.h\"\n#include \"test/helpers.h\"\n#include \"router_test_helpers.h\"\n\nusing metadata_cache::InstanceStatus;\nusing metadata_cache::LookupResult;\nusing metadata_cache::ServerMode;\nusing InstanceVector = std::vector<metadata_cache::ManagedInstance>;\n\nusing ::testing::_;\n\n//ignore GMock warnings\n#ifdef __clang__\n#  ifndef __has_warning\n#    define __has_warning(x) 0\n#  endif\n#  pragma clang diagnostic push\n#  if __has_warning(\"-Winconsistent-missing-override\")\n#    pragma clang diagnostic ignored \"-Winconsistent-missing-override\"\n#  endif\n#  if __has_warning(\"-Wsign-conversion\")\n#    pragma clang diagnostic ignored \"-Wsign-conversion\"\n#  endif\n#endif\n\nclass MetadataCacheAPIStub: public metadata_cache::MetadataCacheAPIBase {\n public:\n  LookupResult lookup_replicaset(const std::string &replicaset_name) override {\n    (void)replicaset_name;\n\n    return LookupResult(instance_vector_);\n  }\n\n  void add_listener(const std::string&, metadata_cache::ReplicasetStateListenerInterface* listener) override {\n    instances_change_listener_ = listener;\n  }\n\n  void remove_listener(const std::string&, metadata_cache::ReplicasetStateListenerInterface*) override {\n    instances_change_listener_ = nullptr;\n  }\n\n  MOCK_METHOD2(mark_instance_reachability, void(const std::string&, InstanceStatus));\n  MOCK_METHOD2(wait_primary_failover, bool(const std::string&, int));\n  MOCK_METHOD9(cache_init, void(const std::vector<mysql_harness::TCPAddress>&, const std::string&,\n                                const std::string&, std::chrono::milliseconds, const mysqlrouter::SSLOptions&,\n                                const std::string&, int, int, size_t));\n\n  void cache_stop() noexcept override {} // no easy way to mock noexcept method\n\n public:\n  void fill_instance_vector(const InstanceVector& iv) {\n    instance_vector_ = iv;\n  }\n\n  void trigger_instances_change_callback(const bool md_servers_reachable = true) {\n    if (!instances_change_listener_) return;\n    instances_change_listener_->notify(instance_vector_, md_servers_reachable);\n  }\n\n  std::vector<metadata_cache::ManagedInstance> instance_vector_;\n  metadata_cache::ReplicasetStateListenerInterface* instances_change_listener_{nullptr};\n\n};\n\n#ifdef __clang__\n#  pragma clang diagnostic pop\n#endif\n\nclass DestMetadataCacheTest : public ::testing::Test {\n protected:\n  void fill_instance_vector(const InstanceVector& iv) {\n    metadata_cache_api_.fill_instance_vector(iv);\n  }\n\n  MetadataCacheAPIStub metadata_cache_api_;\n  MockRoutingSockOps routing_sock_ops_;\n\n  int err_;\n\n  const std::string kReplicasetName{\"replicaset-name\"};\n};\n\n/*****************************************/\n/*STRATEGY FIRST AVAILABLE               */\n/*****************************************/\nTEST_F(DestMetadataCacheTest, StrategyFirstAvailableOnPrimaries) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kFirstAvailable,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=PRIMARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kUndefined,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3307\", 3307, 33061},\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3308\", 3308, 33062},\n  });\n\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3306);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3306);\n}\n\nTEST_F(DestMetadataCacheTest, StrategyFirstAvailableOnSinglePrimary) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kFirstAvailable,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=PRIMARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kUndefined,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3307\", 3307, 33061},\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3308\", 3308, 33062},\n  });\n\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3306);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3306);\n}\n\nTEST_F(DestMetadataCacheTest, StrategyFirstAvailableOnNoPrimary) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kFirstAvailable,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=PRIMARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kUndefined,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3307\", 3307, 33061},\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3308\", 3308, 33062},\n  });\n\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), -1);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), -1);\n}\n\nTEST_F(DestMetadataCacheTest, StrategyFirstAvailableOnSecondaries) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kFirstAvailable,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=SECONDARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kUndefined,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3307\", 3307, 33061},\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3308\", 3308, 33062},\n  });\n\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3307);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3307);\n}\n\nTEST_F(DestMetadataCacheTest, StrategyFirstAvailableOnSingleSecondary) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kFirstAvailable,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=SECONDARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kUndefined,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3307\", 3307, 33061},\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3308\", 3308, 33062},\n  });\n\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3308);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3308);\n}\n\nTEST_F(DestMetadataCacheTest, StrategyFirstAvailableOnNoSecondary) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kFirstAvailable,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=SECONDARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kUndefined,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n    {kReplicasetName, \"uuid2\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3307\", 3307, 33061},\n    {kReplicasetName, \"uuid3\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3308\", 3308, 33062},\n  });\n\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), -1);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), -1);\n}\n\nTEST_F(DestMetadataCacheTest, StrategyFirstAvailablePrimaryAndSecondary) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kFirstAvailable,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=PRIMARY_AND_SECONDARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kUndefined,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3307\", 3307, 33061},\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3308\", 3308, 33062},\n  });\n\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3306);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3306);\n}\n\nTEST_F(DestMetadataCacheTest, StrategyRoundRobinWithFallbackUnavailableServer) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kRoundRobinWithFallback,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=SECONDARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kUndefined,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::Unavailable, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3307\", 3307, 33061},\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3308\", 3308, 33062},\n  });\n\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3307);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3308);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3307);\n}\n\n\n/*****************************************/\n/*STRATEGY ROUND ROBIN                   */\n/*****************************************/\nTEST_F(DestMetadataCacheTest, StrategyRoundRobinOnPrimaries) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kRoundRobin,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=PRIMARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kUndefined,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n    {kReplicasetName, \"uuid2\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3307\", 3307, 33061},\n    {kReplicasetName, \"uuid3\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3308\", 3308, 33062},\n    {kReplicasetName, \"uuid4\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3309\", 3309, 33063},\n  });\n\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3306);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3307);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3308);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3306);\n}\n\nTEST_F(DestMetadataCacheTest, StrategyRoundRobinOnSinglePrimary) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kRoundRobin,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=PRIMARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kUndefined,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3307\", 3307, 33061},\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3308\", 3308, 33062},\n  });\n\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3306);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3306);\n}\n\nTEST_F(DestMetadataCacheTest, StrategyRoundRobinPrimaryMissing) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kRoundRobin,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=PRIMARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kUndefined,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3307\", 3307, 33061},\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3308\", 3308, 33062},\n  });\n\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), -1);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), -1);\n}\n\nTEST_F(DestMetadataCacheTest, StrategyRoundRobinOnSecondaries) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kRoundRobin,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=SECONDARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kUndefined,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n    {kReplicasetName, \"uuid2\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3307\", 3307, 33061},\n    {kReplicasetName, \"uuid3\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3308\", 3308, 33062},\n    {kReplicasetName, \"uuid4\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3309\", 3309, 33063},\n  });\n\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3307);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3308);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3309);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3307);\n}\n\nTEST_F(DestMetadataCacheTest, StrategyRoundRobinOnSingleSecondary) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kRoundRobin,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=SECONDARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kUndefined,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3307\", 3307, 33061},\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3308\", 3308, 33062},\n  });\n\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3308);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3308);\n}\n\nTEST_F(DestMetadataCacheTest, StrategyRoundRobinSecondaryMissing) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kRoundRobin,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=SECONDARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kUndefined,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3307\", 3307, 33061},\n    {kReplicasetName, \"uuid2\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3308\", 3308, 33062},\n  });\n\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), -1);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), -1);\n}\n\nTEST_F(DestMetadataCacheTest, StrategyRoundRobinPrimaryAndSecondary) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kRoundRobin,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=PRIMARY_AND_SECONDARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kUndefined,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3307\", 3307, 33061},\n    {kReplicasetName, \"uuid2\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3308\", 3308, 33062},\n    {kReplicasetName, \"uuid3\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3309\", 3309, 33063},\n  });\n\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3307);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3308);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3309);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3307);\n}\n\n/*****************************************/\n/*STRATEGY ROUND ROBIN_WITH_FALLBACK     */\n/*****************************************/\nTEST_F(DestMetadataCacheTest, StrategyRoundRobinWithFallbackBasicScenario) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kRoundRobinWithFallback,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=SECONDARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kUndefined,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n    {kReplicasetName, \"uuid2\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3307\", 3307, 33061},\n    {kReplicasetName, \"uuid3\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3308\", 3308, 33062},\n  });\n\n  // we have 2 SECONDARIES up so we expect round robin on them\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3307);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3308);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3307);\n}\n\nTEST_F(DestMetadataCacheTest, StrategyRoundRobinWithFallbackSingleSecondary) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kRoundRobinWithFallback,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=SECONDARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kUndefined,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n    {kReplicasetName, \"uuid2\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3307\", 3307, 33061},\n    {kReplicasetName, \"uuid3\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3308\", 3308, 33062},\n  });\n\n  // we do not fallback to PRIMARIES as long as there is at least single SECONDARY available\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3308);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3308);\n}\n\nTEST_F(DestMetadataCacheTest, StrategyRoundRobinWithFallbackNoSecondary) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kRoundRobinWithFallback,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=SECONDARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kUndefined,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n    {kReplicasetName, \"uuid2\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3307\", 3307, 33061},\n  });\n\n  // no SECONDARY available so we expect round-robin on PRIAMRIES\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3306);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3307);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3306);\n}\n\nTEST_F(DestMetadataCacheTest, StrategyRoundRobinWithFallbackPrimaryAndSecondary) {\n  ASSERT_THROW_LIKE(\n    DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                           routing::RoutingStrategy::kRoundRobinWithFallback,\n                           mysqlrouter::URI(\"metadata-cache://cache-name/default?role=PRIMARY_AND_SECONDARY\").query,\n                           BaseProtocol::Type::kClassicProtocol,\n                           routing::AccessMode::kUndefined,\n                           &metadata_cache_api_, &routing_sock_ops_),\n      std::runtime_error,\n      \"Strategy 'round-robin-with-fallback' is supported only for SECONDARY routing\"\n   );\n}\n\n/*****************************************/\n/*allow_primary_reads=yes                */\n/*****************************************/\nTEST_F(DestMetadataCacheTest, AllowPrimaryReadsBasic) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kUndefined,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=SECONDARY&allow_primary_reads=yes\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kReadOnly,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n    {kReplicasetName, \"uuid2\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3307\", 3307, 33061},\n    {kReplicasetName, \"uuid2\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3308\", 3308, 33062},\n  });\n\n  // we expect round-robin on all the servers (PRIMARY and SECONDARY)\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3306);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3307);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3308);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3306);\n}\n\nTEST_F(DestMetadataCacheTest, AllowPrimaryReadsNoSecondary) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kUndefined,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=SECONDARY&allow_primary_reads=yes\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kReadOnly,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n    {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n  });\n\n  // we expect the PRIMARY being used\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3306);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3306);\n}\n\n\n/*****************************************/\n/*DEFAULT_STRATEGIES                     */\n/*****************************************/\nTEST_F(DestMetadataCacheTest, PrimaryDefault) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kUndefined,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=PRIMARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kReadWrite,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n     {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n     {kReplicasetName, \"uuid2\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3307\", 3307, 33061},\n  });\n\n  // default for PRIMARY should be round-robin on ReadWrite servers\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3306);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3307);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3306);\n}\n\nTEST_F(DestMetadataCacheTest, SecondaryDefault) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kUndefined,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=SECONDARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kReadOnly,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n     {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n     {kReplicasetName, \"uuid2\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3307\", 3307, 33061},\n     {kReplicasetName, \"uuid3\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3308\", 3308, 33062},\n  });\n\n  // default for SECONDARY should be round-robin on ReadOnly servers\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3307);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3308);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3307);\n}\n\nTEST_F(DestMetadataCacheTest, PrimaryAndSecondaryDefault) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kUndefined,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=PRIMARY_AND_SECONDARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kReadOnly,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n     {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n     {kReplicasetName, \"uuid2\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3307\", 3307, 33061},\n     {kReplicasetName, \"uuid3\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3308\", 3308, 33062},\n  });\n\n  // default for PRIMARY_AND_SECONDARY should be round-robin on ReadOnly and ReadWrite servers\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3306);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3307);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3308);\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3306);\n}\n\n/*****************************************/\n/*ALLOWED NODES CALLBACK TESTS          */\n/*****************************************/\n\n/**\n * @test verifies that when the metadata changes and there is no primary node,\n *       then allowed_nodes that gets passed to read-write destination is empty\n *\n */\nTEST_F(DestMetadataCacheTest, AllowedNodesNoPrimary) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kUndefined,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=PRIMARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kReadWrite,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n     {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n     {kReplicasetName, \"uuid2\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3307\", 3307, 33070},\n  });\n  // need at least one connection to force dest to register for md changes\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3306);\n\n  // new metadata - no primary\n  fill_instance_vector({\n     {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n     {kReplicasetName, \"uuid2\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3307\", 3307, 33070},\n  });\n\n  bool callback_called{false};\n  auto check_nodes = [&](const AllowedNodes& nodes, const std::string& reason) -> void {\n    // no primaries so we expect empty set as we are role=PRIMARY\n    ASSERT_EQ(0u, nodes.size());\n    ASSERT_STREQ(\"metadata change\", reason.c_str());\n    callback_called = true;\n  };\n  dest_mc_group.register_allowed_nodes_change_callback(check_nodes);\n  metadata_cache_api_.trigger_instances_change_callback();\n\n  ASSERT_TRUE(callback_called);\n}\n\n/**\n * @test verifies that when the metadata changes and there are 2 r/w nodes,\n *       then allowed_nodes that gets passed to read-write destination has both\n *\n */\nTEST_F(DestMetadataCacheTest, AllowedNodes2Primaries) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kUndefined,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=PRIMARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kReadWrite,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n     {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n     {kReplicasetName, \"uuid2\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3307\", 3307, 33070},\n  });\n  // need at least one connection to force dest to register for md changes\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3306);\n\n  // new metadata - no primary\n  fill_instance_vector({\n     {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n     {kReplicasetName, \"uuid2\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3307\", 3307, 33070},\n  });\n\n  bool callback_called{false};\n  auto check_nodes = [&](const AllowedNodes& nodes, const std::string& reason) -> void {\n    // 2 primaries and we are role=PRIMARY\n    ASSERT_EQ(2u, nodes.size());\n    ASSERT_EQ(3306u, nodes[0].port);\n    ASSERT_EQ(3307u, nodes[1].port);\n    ASSERT_STREQ(\"metadata change\", reason.c_str());\n    callback_called = true;\n  };\n  dest_mc_group.register_allowed_nodes_change_callback(check_nodes);\n  metadata_cache_api_.trigger_instances_change_callback();\n\n  ASSERT_TRUE(callback_called);\n}\n\n/**\n * @test verifies that when the metadata changes and there is only single r/w node,\n *       then allowed_nodes that gets passed to read-only destination observer has this node\n *       (it should as by default disconnect_on_promoted_to_primary=no)\n *\n */\nTEST_F(DestMetadataCacheTest, AllowedNodesNoSecondaries) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kUndefined,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=SECONDARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kReadOnly,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n     {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n     {kReplicasetName, \"uuid2\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3307\", 3307, 33070},\n  });\n  // need at least one connection to force dest to register for md changes\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3307);\n\n  // new metadata - no primary\n  fill_instance_vector({\n     {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n  });\n\n  bool callback_called{false};\n  auto check_nodes = [&](const AllowedNodes& nodes, const std::string& reason) -> void {\n    // no secondaries and we are role=SECONDARY\n    // by default tho we allow existing connections to the primary so it should be in the allowed nodes\n    ASSERT_EQ(1u, nodes.size());\n    ASSERT_EQ(3306u, nodes[0].port);\n    ASSERT_STREQ(\"metadata change\", reason.c_str());\n    callback_called = true;\n  };\n  dest_mc_group.register_allowed_nodes_change_callback(check_nodes);\n  metadata_cache_api_.trigger_instances_change_callback();\n\n  ASSERT_TRUE(callback_called);\n}\n\n/**\n * @test verifies that for the read-only destination r/w node is not among allowed_nodes\n *       if  disconnect_on_promoted_to_primary=yes is configured\n *\n */\nTEST_F(DestMetadataCacheTest, AllowedNodesSecondaryDisconnectToPromoted) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kUndefined,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=SECONDARY&disconnect_on_promoted_to_primary=yes\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kReadOnly,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n     {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n     {kReplicasetName, \"uuid2\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3307\", 3307, 33070},\n  });\n  // need at least one connection to force dest to register for md changes\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3307);\n\n  // let's stick to the 'old' md so we have single primary and single secondary\n\n  bool callback_called{false};\n  auto check_nodes = [&](const AllowedNodes& nodes, const std::string& reason) -> void {\n    // one secondary and we are role=SECONDARY\n    // we have disconnect_on_promoted_to_primary=yes configured so primary is not allowed\n    ASSERT_EQ(1u, nodes.size());\n    ASSERT_EQ(3307u, nodes[0].port);\n    ASSERT_STREQ(\"metadata change\", reason.c_str());\n    callback_called = true;\n  };\n  dest_mc_group.register_allowed_nodes_change_callback(check_nodes);\n  metadata_cache_api_.trigger_instances_change_callback();\n\n  ASSERT_TRUE(callback_called);\n}\n\n/**\n * @test\n *      Verify that if disconnect_on_promoted_to_primary is used more than once, then the last stated\n *      value is used, e.g.\n *\n *      &disconnect_on_promoted_to_primary=no&disconnect_on_promoted_to_primary=yes\n *\n *      is considered the same as\n *\n *      &disconnect_on_promoted_to_primary=yes\n *\n */\nTEST_F(DestMetadataCacheTest, AllowedNodesSecondaryDisconnectToPromotedTwice) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kUndefined,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=SECONDARY&disconnect_on_promoted_to_primary=no&disconnect_on_promoted_to_primary=yes\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kReadOnly,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n     {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n     {kReplicasetName, \"uuid2\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3307\", 3307, 33070},\n  });\n  // need at least one connection to force dest to register for md changes\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3307);\n\n  // let's stick to the 'old' md so we have single primary and single secondary\n  bool callback_called{false};\n  auto check_nodes = [&](const AllowedNodes& nodes, const std::string& reason) -> void {\n    // one secondary and we are role=SECONDARY\n    // disconnect_on_promoted_to_primary=yes overrides previous value in configuration so primary is not allowed\n    ASSERT_EQ(1u, nodes.size());\n    ASSERT_EQ(3307u, nodes[0].port);\n    ASSERT_STREQ(\"metadata change\", reason.c_str());\n    callback_called = true;\n  };\n  dest_mc_group.register_allowed_nodes_change_callback(check_nodes);\n  metadata_cache_api_.trigger_instances_change_callback();\n\n  ASSERT_TRUE(callback_called);\n}\n\n/**\n * @test verifies that when metadata becomes unavailable the change notifier is not\n *        called (because by default disconnect_on_metadata_unavailable=no)\n *\n */\nTEST_F(DestMetadataCacheTest, AllowedNodesEmptyKeepConnectionsIfMetadataUnavailable) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kUndefined,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=SECONDARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kReadOnly,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n     {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n     {kReplicasetName, \"uuid2\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3307\", 3307, 33070},\n  });\n  // need at least one connection to force dest to register for md changes\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3307);\n\n  // new empty metadata\n  fill_instance_vector({});\n\n  bool callback_called{false};\n  auto check_nodes = [&](const AllowedNodes& nodes, const std::string& reason) -> void {\n    ASSERT_EQ(0u, nodes.size());\n    ASSERT_STREQ(\"metadata unavaiable\", reason.c_str());\n    callback_called = true;\n  };\n  dest_mc_group.register_allowed_nodes_change_callback(check_nodes);\n  metadata_cache_api_.trigger_instances_change_callback(/*md_servers_reachable=*/ false);\n\n  // the metadata has changed but we got the notification that this is triggered because md servers are not reachable\n  // as disconnect_on_metadata_unavailable is set to 'no' (by default) we are not expected to call the users (routing)\n  // callbacks to force the disconnects\n  ASSERT_FALSE(callback_called);\n}\n\n/**\n * @test verifies that when metadata becomes unavailable the change notifier is\n *       called with empyt allowed_nodes set when disconnect_on_metadata_unavailable=yes\n *       is configured\n *\n */\nTEST_F(DestMetadataCacheTest, AllowedNodesEmptyDisconnectConnectionsIfMetadataUnavailable) {\n\n  DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kUndefined,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=SECONDARY&disconnect_on_metadata_unavailable=yes\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kReadOnly,\n                         &metadata_cache_api_, &routing_sock_ops_);\n\n  fill_instance_vector({\n     {kReplicasetName, \"uuid1\", \"HA\", metadata_cache::ServerMode::ReadWrite, 1.0, 1, \"location\", \"3306\", 3306, 33060},\n     {kReplicasetName, \"uuid2\", \"HA\", metadata_cache::ServerMode::ReadOnly, 1.0, 1, \"location\", \"3307\", 3307, 33070},\n  });\n  // need at least one connection to force dest to register for md changes\n  ASSERT_EQ(dest_mc_group.get_server_socket(std::chrono::milliseconds(0), &err_), 3307);\n\n  // new empty metadata\n  fill_instance_vector({});\n\n  bool callback_called{false};\n  auto check_nodes = [&](const AllowedNodes& nodes, const std::string& reason) -> void {\n    ASSERT_EQ(0u, nodes.size());\n    ASSERT_STREQ(\"metadata unavailable\", reason.c_str());\n    callback_called = true;\n  };\n  dest_mc_group.register_allowed_nodes_change_callback(check_nodes);\n  metadata_cache_api_.trigger_instances_change_callback(/*md_servers_reachable=*/ false);\n\n  // the metadata has changed and we got the notification that this is triggered because md servers are not reachable\n  // as disconnect_on_metadata_unavailable=yes we are expected to call the users (routing)\n  // callbacks to force the disconnects\n  ASSERT_TRUE(callback_called);\n}\n\n/*****************************************/\n/*ERROR SCENARIOS                        */\n/*****************************************/\nTEST_F(DestMetadataCacheTest, InvalidServerNodeRole) {\n\n  ASSERT_THROW_LIKE(\n    DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kRoundRobin,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=INVALID\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kUndefined,\n                         &metadata_cache_api_, &routing_sock_ops_),\n    std::runtime_error,\n    \"Invalid server role in metadata cache routing\"\n   );\n}\n\nTEST_F(DestMetadataCacheTest, UnsupportedRoutingStrategy) {\n\n  ASSERT_THROW_LIKE(\n    DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kNextAvailable, // this one is not supported for metadata cache\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=PRIMARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kUndefined,\n                         &metadata_cache_api_, &routing_sock_ops_),\n    std::runtime_error,\n    \"Unsupported routing strategy: next-available\"\n   );\n}\n\nTEST_F(DestMetadataCacheTest, AllowPrimaryReadsWithPrimaryRouting) {\n\n  ASSERT_THROW_LIKE(\n    DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kUndefined,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=PRIMARY&allow_primary_reads=yes\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kReadWrite,\n                         &metadata_cache_api_, &routing_sock_ops_),\n    std::runtime_error,\n    \"allow_primary_reads is supported only for SECONDARY routing\"\n   );\n}\n\nTEST_F(DestMetadataCacheTest, AllowPrimaryReadsWithRoutingStrategy) {\n\n  ASSERT_THROW_LIKE(\n    DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kRoundRobin,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=SECONDARY&allow_primary_reads=yes\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kUndefined,\n                         &metadata_cache_api_, &routing_sock_ops_),\n    std::runtime_error,\n    \"allow_primary_reads is only supported for backward compatibility: \"\n     \"without routing_strategy but with mode defined, use role=PRIMARY_AND_SECONDARY instead\"\n   );\n}\n\nTEST_F(DestMetadataCacheTest, RoundRobinWitFallbackStrategyWithPrimaryRouting) {\n\n  ASSERT_THROW_LIKE(\n    DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kRoundRobinWithFallback,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=PRIMARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kUndefined,\n                         &metadata_cache_api_, &routing_sock_ops_),\n    std::runtime_error,\n    \"Strategy 'round-robin-with-fallback' is supported only for SECONDARY routing\"\n   );\n}\n\n\nTEST_F(DestMetadataCacheTest, ModeWithStrategy) {\n\n  ASSERT_THROW_LIKE(\n    DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kFirstAvailable,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=PRIMARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kReadWrite,\n                         &metadata_cache_api_, &routing_sock_ops_),\n    std::runtime_error,\n    \"option 'mode' is not allowed together with 'routing_strategy' option\"\n   );\n}\n\nTEST_F(DestMetadataCacheTest, RolePrimaryWrongMode) {\n\n  ASSERT_THROW_LIKE(\n    DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kUndefined,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=PRIMARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kReadOnly,\n                         &metadata_cache_api_, &routing_sock_ops_),\n    std::runtime_error,\n    \"mode 'read-only' is not valid for 'role=primary'\"\n   );\n}\n\nTEST_F(DestMetadataCacheTest, RoleSecondaryWrongMode) {\n\n  ASSERT_THROW_LIKE(\n    DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kUndefined,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=SECONDARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kReadWrite,\n                         &metadata_cache_api_, &routing_sock_ops_),\n    std::runtime_error,\n    \"mode 'read-write' is not valid for 'role=secondary'\"\n   );\n}\n\nTEST_F(DestMetadataCacheTest, RolePrimaryAndSecondaryWrongMode) {\n\n  ASSERT_THROW_LIKE(\n    DestMetadataCacheGroup dest_mc_group(\"cache-name\", kReplicasetName,\n                         routing::RoutingStrategy::kUndefined,\n                         mysqlrouter::URI(\"metadata-cache://cache-name/default?role=PRIMARY_AND_SECONDARY\").query,\n                         BaseProtocol::Type::kClassicProtocol,\n                         routing::AccessMode::kReadWrite,\n                         &metadata_cache_api_, &routing_sock_ops_),\n    std::runtime_error,\n    \"mode 'read-write' is not valid for 'role=primary_and_secondary'\"\n   );\n}\n\n/*****************************************/\n/*URI parsing tests                      */\n/*****************************************/\nTEST_F(DestMetadataCacheTest, MetadataCacheGroupAllowPrimaryReads)\n{\n  // yes\n  {\n    mysqlrouter::URI uri(\"metadata-cache://test/default?allow_primary_reads=yes&role=SECONDARY\");\n    ASSERT_NO_THROW(\n      DestMetadataCacheGroup dest(\"metadata_cache_name\", \"replicaset_name\",\n                                  routing::RoutingStrategy::kUndefined,\n                                  uri.query, Protocol::Type::kClassicProtocol)\n    );\n  }\n\n  // no\n  {\n    mysqlrouter::URI uri(\"metadata-cache://test/default?allow_primary_reads=no&role=SECONDARY\");\n    ASSERT_NO_THROW(\n          DestMetadataCacheGroup dest(\"metadata_cache_name\", \"replicaset_name\",\n                                      routing::RoutingStrategy::kUndefined,\n                                      uri.query, Protocol::Type::kClassicProtocol)\n    );\n  }\n\n  // invalid value\n  {\n    mysqlrouter::URI uri(\"metadata-cache://test/default?allow_primary_reads=yes,xxx&role=SECONDARY\");\n    ASSERT_THROW_LIKE(\n      DestMetadataCacheGroup dest(\"metadata_cache_name\", \"replicaset_name\",\n                                 routing::RoutingStrategy::kUndefined,\n                                 uri.query, Protocol::Type::kClassicProtocol),\n      std::runtime_error,\n      \"Invalid value for allow_primary_reads option: 'yes,xxx'\"\n    );\n  }\n}\n\nTEST_F(DestMetadataCacheTest, MetadataCacheGroupMultipleUris)\n{\n  {\n    mysqlrouter::URI uri(\"metadata-cache://test/default?role=SECONDARY,metadata-cache://test2/default?role=SECONDARY\");\n    ASSERT_THROW_LIKE(\n      DestMetadataCacheGroup dest(\"metadata_cache_name\", \"replicaset_name\",\n                                  routing::RoutingStrategy::kUndefined,\n                                  uri.query, Protocol::Type::kClassicProtocol),\n      std::runtime_error,\n      \"Invalid server role in metadata cache routing 'SECONDARY,metadata-cache://test2/default?role'\"\n    );\n  }\n}\n\nTEST_F(DestMetadataCacheTest, MetadataCacheGroupDisconnectOnPromotedToPrimary)\n{\n  // yes valid\n  {\n    mysqlrouter::URI uri(\"metadata-cache://test/default?role=SECONDARY&disconnect_on_promoted_to_primary=yes\");\n    ASSERT_NO_THROW(\n      DestMetadataCacheGroup dest(\"metadata_cache_name\", \"replicaset_name\",\n                                  routing::RoutingStrategy::kUndefined,\n                                  uri.query, Protocol::Type::kClassicProtocol)\n    );\n  }\n\n  // no valid\n  {\n    mysqlrouter::URI uri(\"metadata-cache://test/default?role=SECONDARY&disconnect_on_promoted_to_primary=no\");\n    ASSERT_NO_THROW(\n      DestMetadataCacheGroup dest(\"metadata_cache_name\", \"replicaset_name\",\n                                  routing::RoutingStrategy::kUndefined,\n                                  uri.query, Protocol::Type::kClassicProtocol)\n    );\n  }\n\n  // ivalid option\n  {\n    mysqlrouter::URI uri(\"metadata-cache://test/default?role=SECONDARY&disconnect_on_promoted_to_primary=invalid\");\n    ASSERT_THROW_LIKE(\n      DestMetadataCacheGroup dest(\"metadata_cache_name\", \"replicaset_name\",\n                                  routing::RoutingStrategy::kUndefined,\n                                  uri.query, Protocol::Type::kClassicProtocol),\n      std::runtime_error,\n       \"Invalid value for option 'disconnect_on_promoted_to_primary'. Allowed are 'yes' and 'no'\"\n    );\n  }\n\n  // incompatible mode, valid only for secondary\n  {\n    mysqlrouter::URI uri(\"metadata-cache://test/default?role=PRIMARY&disconnect_on_promoted_to_primary=invalid\");\n    ASSERT_THROW_LIKE(\n      DestMetadataCacheGroup dest(\"metadata_cache_name\", \"replicaset_name\",\n                                  routing::RoutingStrategy::kUndefined,\n                                  uri.query, Protocol::Type::kClassicProtocol),\n      std::runtime_error,\n       \"Option 'disconnect_on_promoted_to_primary' is valid only for mode=SECONDARY\"\n    );\n  }\n}\n\nTEST_F(DestMetadataCacheTest, MetadataCacheDisconnectOnMetadataUnavailable)\n{\n  // yes valid\n  {\n    mysqlrouter::URI uri(\"metadata-cache://test/default?role=SECONDARY&disconnect_on_metadata_unavailable=yes\");\n    ASSERT_NO_THROW(\n      DestMetadataCacheGroup dest(\"metadata_cache_name\", \"replicaset_name\",\n                                  routing::RoutingStrategy::kUndefined,\n                                  uri.query, Protocol::Type::kClassicProtocol)\n    );\n  }\n\n  // no valid\n  {\n    mysqlrouter::URI uri(\"metadata-cache://test/default?role=SECONDARY&disconnect_on_metadata_unavailable=no\");\n    ASSERT_NO_THROW(\n      DestMetadataCacheGroup dest(\"metadata_cache_name\", \"replicaset_name\",\n                                  routing::RoutingStrategy::kUndefined,\n                                  uri.query, Protocol::Type::kClassicProtocol)\n    );\n  }\n\n  // ivalid option\n  {\n    mysqlrouter::URI uri(\"metadata-cache://test/default?role=SECONDARY&disconnect_on_metadata_unavailable=invalid\");\n    ASSERT_THROW_LIKE(\n      DestMetadataCacheGroup dest(\"metadata_cache_name\", \"replicaset_name\",\n                                  routing::RoutingStrategy::kUndefined,\n                                  uri.query, Protocol::Type::kClassicProtocol),\n      std::runtime_error,\n       \"Invalid value for option 'disconnect_on_metadata_unavailable'. Allowed are 'yes' and 'no'\"\n    );\n  }\n}\n\nTEST_F(DestMetadataCacheTest, MetadataCacheGroupUnknownParam)\n{\n  {\n    mysqlrouter::URI uri(\"metadata-cache://test/default?role=SECONDARY&xxx=yyy,metadata-cache://test2/default?role=SECONDARY\");\n    ASSERT_THROW_LIKE(\n      DestMetadataCacheGroup dest(\"metadata_cache_name\", \"replicaset_name\",\n                                  routing::RoutingStrategy::kUndefined,\n                                  uri.query, Protocol::Type::kClassicProtocol),\n      std::runtime_error,\n     \"Unsupported 'metadata-cache' parameter in URI: 'xxx'\"\n    );\n  }\n}\n\n\nint main(int argc, char *argv[]) {\n  init_test_logger();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/routing/tests/test_next_available.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"dest_next_available.h\"\n#include \"routing_mocks.h\"\n#include \"test/helpers.h\"\n\nclass NextAvailableTest : public ::testing::Test {\n\n public:\n  NextAvailableTest() : routing_sock_ops_(new MockRoutingSockOps()),\n                         dest_(Protocol::Type::kClassicProtocol, routing_sock_ops_.get()) {\n    dest_.add(\"41\", 1);\n    dest_.add(\"42\", 2);\n    dest_.add(\"43\", 3);\n  }\n\n  DestNextAvailable& dest() {\n    return dest_;\n  }\n\nprotected:\n  std::unique_ptr<MockRoutingSockOps> routing_sock_ops_;\n private:\n  DestNextAvailable dest_; // this is the class we're testing\n};\n\n// The idea behind these tests is to test DestNextAvailable::get_server_socket() server selection\n// strategy. That method is responsible for returning the new connection to the active server.\n// The active server should be switched in such fashion:\n//\n//   A -> B -> C -> sorry, no more servers (regardless of whether A and B go back up or not)\n//\n// The switch should occur only when the current active server becomes unavailable.\n// DestNextAvailable::get_server_socket() relies on RoutingSockOpsInterface::get_mysql_socket()\n// to return the actual file descriptor, which we mock in this test to simulate connection success\n// or failure.\n\nTEST_F(NextAvailableTest, TypicalFailoverSequence) {\n  int dummy;\n\n  // talk to 1st server\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 41);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 41);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 41);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 41);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 41);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 5); // 5 good connections\n\n  // fail 1st server -> failover to 2nd\n  routing_sock_ops_->get_mysql_socket_fail(1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 42);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 2); // 1 failed + 1 good conn\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 42);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 42);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 42);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 42);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 4); // 4 more good conns\n\n  // fail 2nd server -> failover to 3rd\n  routing_sock_ops_->get_mysql_socket_fail(1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 43);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 2); // 1 failed + 1 good conn\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 43);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 43);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 43);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 43);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 4); // 4 more good conns\n\n  // fail 3rd server -> no more servers\n  routing_sock_ops_->get_mysql_socket_fail(1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), -1);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 1); // 1 failed, no more servers\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), -1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), -1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), -1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), -1);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 0); // no more servers\n}\n\nTEST_F(NextAvailableTest, StartWith1stDown) {\n  int dummy;\n\n  // fail 1st server -> failover to 2nd\n  routing_sock_ops_->get_mysql_socket_fail(1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 42);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 2); // 1 failed + 1 good conn\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 42);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 42);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 42);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 42);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 4); // 4 more good conns\n\n  // fail 2nd server -> failover to 3rd\n  routing_sock_ops_->get_mysql_socket_fail(1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 43);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 2); // 1 failed + 1 good conn\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 43);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 43);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 43);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 43);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 4); // 4 more good conns\n\n  // fail 3rd server -> no more servers\n  routing_sock_ops_->get_mysql_socket_fail(1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), -1);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 1); // 1 failed, no more servers\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), -1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), -1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), -1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), -1);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 0); // no more servers\n}\n\nTEST_F(NextAvailableTest, StartWith2ndDown) {\n  int dummy;\n\n  // fail 1st and 2nd server -> failover to 3rd\n  routing_sock_ops_->get_mysql_socket_fail(2);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 43);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 3); // 2 failed + 1 good conn\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 43);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 43);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 43);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), 43);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 4); // 4 more good conns\n\n  // fail 3rd server -> no more servers\n  routing_sock_ops_->get_mysql_socket_fail(1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), -1);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 1); // 1 failed, no more servers\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), -1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), -1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), -1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), -1);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 0); // no more servers\n}\n\nTEST_F(NextAvailableTest, StartWithAllDown) {\n  int dummy;\n\n  // fail 1st, 2nd and 3rd server -> no more servers\n  routing_sock_ops_->get_mysql_socket_fail(3);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), -1);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 3); // 3 failed, no more servers\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), -1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), -1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), -1);\n  ASSERT_EQ(dest().get_server_socket(std::chrono::milliseconds(0), &dummy), -1);\n  ASSERT_EQ(routing_sock_ops_->get_mysql_socket_call_cnt(), 0); // no more servers\n}\n\nint main(int argc, char *argv[]) {\n  init_test_logger();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n\n"
  },
  {
    "path": "src/routing/tests/test_round_robin.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <functional>\n#include <iostream>\n#include <stdexcept>\n\n#include \"mysql/harness/logging/logging.h\"\n#include \"test/helpers.h\"\n// TODO: what is needed ?\n//#include \"router_test_helpers.h\"\n//\n#include \"dest_round_robin.h\"\n\n#include \"tcp_address.h\"\n#include \"routing_mocks.h\"\n\n#include \"gtest/gtest.h\"\n#include \"gmock/gmock.h\"\n\n\nusing mysql_harness::TCPAddress;\nusing ::testing::StrEq;\n\nclass RoundRobinDestinationTest : public ::testing::Test {\nprotected:\n  virtual void SetUp() {}\n\n  MockRoutingSockOps mock_routing_sock_ops_;\n};\n\n\nTEST_F(RoundRobinDestinationTest, Constructor)\n{\n  DestRoundRobin d;\n  size_t exp = 0;\n  ASSERT_EQ(exp, d.size());\n}\n\nTEST_F(RoundRobinDestinationTest, Add)\n{\n  size_t exp;\n  DestRoundRobin d;\n  exp = 1;\n  d.add(\"addr1\", 1);\n  ASSERT_EQ(exp, d.size());\n  exp = 2;\n  d.add(\"addr2\", 2);\n  ASSERT_EQ(exp, d.size());\n\n  // Already added destination\n  d.add(\"addr1\", 1);\n  exp = 2;\n  ASSERT_EQ(exp, d.size());\n}\n\nTEST_F(RoundRobinDestinationTest, Remove)\n{\n  size_t exp;\n  DestRoundRobin d;\n  d.add(\"addr1\", 1);\n  d.add(\"addr99\", 99);\n  d.add(\"addr2\", 2);\n  exp = 3;\n  ASSERT_EQ(exp, d.size());\n  d.remove(\"addr99\", 99);\n  exp = 2;\n  ASSERT_EQ(exp, d.size());\n  d.remove(\"addr99\", 99);\n  exp = 2;\n  ASSERT_EQ(exp, d.size());\n}\n\nTEST_F(RoundRobinDestinationTest, Get)\n{\n  DestRoundRobin d;\n  ASSERT_THROW(d.get(\"addr1\", 1), std::out_of_range);\n  d.add(\"addr1\", 1);\n  ASSERT_NO_THROW(d.get(\"addr1\", 1));\n\n  TCPAddress addr = d.get(\"addr1\", 1);\n  ASSERT_THAT(addr.addr, StrEq(\"addr1\"));\n  EXPECT_EQ(addr.port, 1);\n\n  d.remove(\"addr1\", 1);\n  ASSERT_THAT(addr.addr, StrEq(\"addr1\"));\n  EXPECT_EQ(addr.port, 1);\n}\n\nTEST_F(RoundRobinDestinationTest, Size)\n{\n  size_t exp;\n  DestRoundRobin d;\n  exp = 0;\n  ASSERT_EQ(exp, d.size());\n  d.add(\"addr1\", 1);\n  exp = 1;\n  ASSERT_EQ(exp, d.size());\n  d.remove(\"addr1\", 1);\n  exp = 0;\n  ASSERT_EQ(exp, d.size());\n}\n\nTEST_F(RoundRobinDestinationTest, RemoveAll)\n{\n  size_t exp;\n  DestRoundRobin d;\n\n  d.add(\"addr1\", 1);\n  d.add(\"addr2\", 2);\n  d.add(\"addr3\", 3);\n  exp = 3;\n  ASSERT_EQ(exp, d.size());\n\n  d.clear();\n  exp = 0;\n  ASSERT_EQ(exp, d.size());\n}\n\n\n/**\n * @test DestRoundRobin spawns the quarantine thread and\n *       joins it in the destructor. Make sure the destructor\n *       does not block/dealock and forces the thread close (bug#27145261).\n */\nTEST_F(RoundRobinDestinationTest, SpawnAndJoinQuarantineThread)\n{\n  DestRoundRobin d;\n  d.start();\n}\n\n\nTEST_F(RoundRobinDestinationTest, get_server_socket)\n{\n  int error;\n\n  // create round-robin (read-only) destination and add a few servers\n  DestRoundRobin dest(Protocol::get_default(), &mock_routing_sock_ops_,\n      mysql_harness::kDefaultStackSizeInKiloBytes);\n  std::vector<int> dest_servers_addresses { 11, 12, 13 };\n  for (const auto& server_address: dest_servers_addresses) {\n    dest.add(std::to_string(server_address), 1 /*port - doesn't matter here*/);\n  }\n\n  // NOTE: this test exploits the fact that MockSocketOperations::get_mysql_socket() returns the value\n  // based on the IP address it is given (it uses the number the address starts with)\n\n  using ThrPtr = std::unique_ptr<std::thread>;\n  std::vector<ThrPtr> client_threads;\n  std::map<int, size_t> connections; // number of connections per each destination address\n  std::mutex connections_mutex;\n\n  // spawn number of threads each trying to get the server socket at the same time\n  const size_t kNumClientThreads = dest_servers_addresses.size() * 10;\n  for (size_t i = 0; i < kNumClientThreads; ++i) {\n    client_threads.emplace_back(\n      new std::thread(\n        [&]() {\n          int addr = dest.get_server_socket(std::chrono::milliseconds::zero(), &error);\n          {\n            std::unique_lock<std::mutex> lock(connections_mutex);\n            // increment the counter for returned address\n            ++connections[addr];\n          }\n        }\n      )\n    );\n  }\n\n  // wait for each thread to finish\n  for (auto& thr: client_threads) {\n     thr->join();\n  }\n\n  // we didn't simulate any connection errors so there should be no quarantine\n  // so the number of connections to the the destination addresses should be evenly distributed\n  for (const auto& server_address: dest_servers_addresses) {\n    EXPECT_EQ(connections[server_address], kNumClientThreads/dest_servers_addresses.size());\n  }\n}\n\nint main(int argc, char *argv[]) {\n  init_test_logger();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/routing/tests/test_routing.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <gtest/gtest_prod.h> // must be the first header\n\n#include \"mysqlrouter/routing.h\"\n#include \"mysql_routing.h\"\n#include \"common.h\"\n#include \"mysql/harness/loader.h\"\n#include \"routing_mocks.h\"\n#include \"protocol/classic_protocol.h\"\n#include \"test/helpers.h\"\n#include \"tcp_port_pool.h\"\n#include \"mysql_routing_common.h\"\n\n#ifdef _WIN32\n#  define WIN32_LEAN_AND_MEAN\n#  include <windows.h>\n#  include <winsock2.h>\n#  include <ws2tcpip.h>\n#else\n#  include <sys/un.h>\n#  include <sys/socket.h>\n#  include <fcntl.h>\n#endif\n\n\nusing routing::AccessMode;\nusing routing::set_socket_blocking;\nusing mysql_harness::TCPAddress;\n\nusing ::testing::ContainerEq;\nusing ::testing::Eq;\nusing ::testing::Gt;\nusing ::testing::Ne;\nusing ::testing::InSequence;\nusing ::testing::Return;\nusing ::testing::StrEq;\nusing ::testing::_;\n\nclass RoutingTests : public ::testing::Test {\nprotected:\n  RoutingTests() {\n  }\n  virtual void SetUp() {\n  }\n\n  virtual void TearDown() {\n  }\n\n  MockRoutingSockOps routing_sock_ops;\n  MockSocketOperations& socket_op = *routing_sock_ops.so();\n};\n\nTEST_F(RoutingTests, AccessModes) {\n  ASSERT_EQ(static_cast<int>(AccessMode::kReadWrite), 1);\n  ASSERT_EQ(static_cast<int>(AccessMode::kReadOnly), 2);\n}\n\nTEST_F(RoutingTests, AccessModeLiteralNames) {\n  using routing::get_access_mode;\n  ASSERT_THAT(get_access_mode(\"read-write\"), Eq(AccessMode::kReadWrite));\n  ASSERT_THAT(get_access_mode(\"read-only\"), Eq(AccessMode::kReadOnly));\n}\n\nTEST_F(RoutingTests, GetAccessLiteralName) {\n  using routing::get_access_mode_name;\n  ASSERT_THAT(get_access_mode_name(AccessMode::kReadWrite), StrEq(\"read-write\"));\n  ASSERT_THAT(get_access_mode_name(AccessMode::kReadOnly), StrEq(\"read-only\"));\n}\n\nTEST_F(RoutingTests, Defaults) {\n  ASSERT_EQ(routing::kDefaultWaitTimeout, 0);\n  ASSERT_EQ(routing::kDefaultMaxConnections, 512);\n  ASSERT_EQ(routing::kDefaultDestinationConnectionTimeout, std::chrono::seconds(1));\n  ASSERT_EQ(routing::kDefaultBindAddress, \"127.0.0.1\");\n  ASSERT_EQ(routing::kDefaultNetBufferLength, 16384U);\n  ASSERT_EQ(routing::kDefaultMaxConnectErrors, 100ULL);\n  ASSERT_EQ(routing::kDefaultClientConnectTimeout, std::chrono::seconds(9));\n}\n\n#ifndef _WIN32\n// No way to read nonblocking status in Windows\nTEST_F(RoutingTests, SetSocketBlocking) {\n  int s = socket(PF_INET, SOCK_STREAM, 6);\n  ASSERT_EQ(fcntl(s, F_GETFL, nullptr) & O_NONBLOCK, 0);\n  set_socket_blocking(s, false);\n  ASSERT_EQ(fcntl(s, F_GETFL, nullptr) & O_NONBLOCK, O_NONBLOCK);\n  set_socket_blocking(s, true);\n  ASSERT_EQ(fcntl(s, F_GETFL, nullptr) & O_NONBLOCK, 0) << std::endl;\n\n  fcntl(s, F_SETFL, O_RDONLY);\n  set_socket_blocking(s, false);\n  ASSERT_EQ(fcntl(s, F_GETFL, nullptr) & O_NONBLOCK, O_NONBLOCK);\n  ASSERT_EQ(fcntl(s, F_GETFL, nullptr) & O_RDONLY, O_RDONLY);\n}\n#endif\n\nTEST_F(RoutingTests, CopyPacketsSingleWrite) {\n  int sender_socket = 1, receiver_socket = 2;\n  RoutingProtocolBuffer buffer(500);\n  int curr_pktnr = 100;\n  bool handshake_done = true;\n  size_t report_bytes_read = 0u;\n\n  EXPECT_CALL(socket_op, read(sender_socket, &buffer[0], buffer.size())).WillOnce(Return(200));\n  EXPECT_CALL(socket_op, write(receiver_socket, &buffer[0], 200)).WillOnce(Return(200));\n\n\n  ClassicProtocol cp(&routing_sock_ops);\n  int res = cp.copy_packets(sender_socket, receiver_socket, true /* sender is writable */,\n                            buffer, &curr_pktnr,\n                            handshake_done, &report_bytes_read, false);\n\n  ASSERT_EQ(0, res);\n  ASSERT_EQ(200u, report_bytes_read);\n}\n\nTEST_F(RoutingTests, CopyPacketsMultipleWrites) {\n  int sender_socket = 1, receiver_socket = 2;\n  RoutingProtocolBuffer buffer(500);\n  int curr_pktnr = 100;\n  bool handshake_done = true;\n  size_t report_bytes_read = 0u;\n\n  InSequence seq;\n\n  EXPECT_CALL(socket_op, read(sender_socket, &buffer[0], buffer.size())).WillOnce(Return(200));\n\n  // first write does not write everything\n  EXPECT_CALL(socket_op, write(receiver_socket, &buffer[0], 200)).WillOnce(Return(100));\n  // second does not do anything (which is not treated as an error\n  EXPECT_CALL(socket_op, write(receiver_socket, &buffer[100], 100)).WillOnce(Return(0));\n  // third writes the remaining chunk\n  EXPECT_CALL(socket_op, write(receiver_socket, &buffer[100], 100)).WillOnce(Return(100));\n\n  ClassicProtocol cp(&routing_sock_ops);\n  int res = cp.copy_packets(sender_socket, receiver_socket, true,\n                            buffer, &curr_pktnr,\n                            handshake_done, &report_bytes_read, false);\n\n  ASSERT_EQ(0, res);\n  ASSERT_EQ(200u, report_bytes_read);\n}\n\nTEST_F(RoutingTests, CopyPacketsWriteError) {\n  int sender_socket = 1, receiver_socket = 2;\n  RoutingProtocolBuffer buffer(500);\n  int curr_pktnr = 100;\n  bool handshake_done = true;\n  size_t report_bytes_read = 0u;\n\n  EXPECT_CALL(socket_op, read(sender_socket, &buffer[0], buffer.size())).WillOnce(Return(200));\n  EXPECT_CALL(socket_op, write(receiver_socket, &buffer[0], 200)).WillOnce(Return(-1));\n\n  ClassicProtocol cp(&routing_sock_ops);\n  // will log \"Write error: ...\" as we don't mock an errno\n  int res = cp.copy_packets(sender_socket, receiver_socket, true,\n                            buffer, &curr_pktnr,\n                            handshake_done, &report_bytes_read, false);\n\n  ASSERT_EQ(-1, res);\n}\n\n#ifndef _WIN32  // [_HERE_]\n\n// a valid Connection::Close xprotocol message\n#define kByeMessage \"\\x01\\x00\\x00\\x00\\x03\"\n\nclass MockServer {\npublic:\n  MockServer(uint16_t port) {\n    int option_value;\n\n    socket_operations_ = mysql_harness::SocketOperations::instance();\n\n    if ((service_tcp_ = socket(AF_INET, SOCK_STREAM, 0)) == -1) {\n      throw std::runtime_error(mysql_harness::get_strerror(errno));\n    }\n\n#ifndef _WIN32\n    option_value = 1;\n    if (setsockopt(service_tcp_, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<const char*>(&option_value),\n            static_cast<socklen_t>(sizeof(int))) == -1) {\n      throw std::runtime_error(get_message_error(errno));\n    }\n#endif\n\n    struct sockaddr_in addr;\n    memset(&addr, 0, sizeof(addr));\n    addr.sin_family = AF_INET;\n    addr.sin_addr.s_addr = INADDR_ANY;\n    addr.sin_port = htons(port);\n    if (::bind(service_tcp_, (const struct sockaddr *)&addr,\n               static_cast<socklen_t>(sizeof(addr))) == -1) {\n      socket_operations_->close(service_tcp_);\n      int errcode = socket_operations_->get_errno();\n      throw std::runtime_error(get_message_error(errcode));\n    }\n    if (listen(service_tcp_, 20) < 0) {\n      throw std::runtime_error(\"Failed to start listening for connections using TCP\");\n    }\n  }\n\n  ~MockServer() {\n    stop();\n  }\n\n  void start() {\n    stop_ = false;\n    thread_ = std::thread(&MockServer::runloop, this);\n  }\n\n  void stop() {\n    if (!stop_) {\n      stop_ = true;\n      socket_operations_->shutdown(service_tcp_);\n      socket_operations_->close(service_tcp_);\n      thread_.join();\n    }\n  }\n\n  void stop_after_n_accepts(int c) {\n    max_expected_accepts_ = c;\n  }\n\n  void runloop() {\n    mysql_harness::rename_thread(\"runloop()\");\n    std::vector<std::thread> client_threads;\n\n    while (!stop_ && (max_expected_accepts_ == 0 || num_accepts_ < max_expected_accepts_)) {\n      int sock_client;\n      struct sockaddr_in6 client_addr;\n      socklen_t sin_size = static_cast<socklen_t>(sizeof client_addr);\n      if ((sock_client = accept(service_tcp_, (struct sockaddr *) &client_addr, &sin_size)) < 0) {\n        std::cout<< mysql_harness::get_strerror(errno)<<\" ERROR\\n\";\n        continue;\n      }\n      num_accepts_++;\n      client_threads.emplace_back(std::thread([this, sock_client]() { new_client(sock_client); }));\n    }\n\n    // wait for all threads to shut down again\n    for (auto &thr: client_threads) {\n      thr.join();\n    }\n  }\n\n  void new_client(int sock) {\n    mysql_harness::rename_thread(\"new_client()\");\n    num_connections_++;\n    char buf[sizeof(kByeMessage)];\n    // block until we receive the bye msg\n    if (read(sock, buf, sizeof(buf)) < 0) {\n      FAIL() << \"Unexpected results from read(): \" << mysql_harness::get_strerror(errno);\n    }\n    socket_operations_->close(sock);\n    num_connections_--;\n  }\n\npublic:\n  std::atomic_int num_connections_ { 0 };\n  std::atomic_int num_accepts_ { 0 } ;\n  std::atomic_int max_expected_accepts_ { 0 };\n\nprivate:\n  mysql_harness::SocketOperationsBase* socket_operations_;\n  std::thread thread_;\n  int service_tcp_;\n  std::atomic_bool stop_;\n};\n\n\nstatic int connect_local(uint16_t port) {\n  return routing::RoutingSockOps::instance(mysql_harness::SocketOperations::instance())\n         ->get_mysql_socket(TCPAddress(\"127.0.0.1\", port), std::chrono::milliseconds(100), true);\n}\n\nstatic void disconnect(int sock) {\n  if (write(sock, kByeMessage, sizeof(kByeMessage)) < 0)\n    std::cout << \"write(xproto-connection-close) returned error\\n\";\n\n  mysql_harness::SocketOperations::instance()->close(sock);\n}\n\n#ifndef _WIN32\nstatic int connect_socket(const char *path) {\n  struct sockaddr_un addr;\n  int fd;\n\n  if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {\n    throw std::runtime_error(mysql_harness::get_strerror(errno));\n  }\n\n  memset(&addr, 0, sizeof(addr));\n  addr.sun_family = AF_UNIX;\n  strncpy(addr.sun_path, path, sizeof(addr.sun_path)-1);\n\n  if (connect(fd, (struct sockaddr*)&addr, static_cast<socklen_t>(sizeof(addr))) == -1) {\n    throw std::runtime_error(mysql_harness::get_strerror(errno));\n  }\n\n  return fd;\n}\n#endif\n\nstatic bool call_until(std::function<bool ()> f, int timeout = 2) {\n  time_t start = time(NULL);\n  while (time(NULL) - start < timeout) {\n    if (f())\n      return true;\n\n    // wait a bit and let other threads run\n    std::this_thread::sleep_for(std::chrono::milliseconds(1));\n  }\n  return false;\n}\n\n// Bug#24841281 NOT ABLE TO CONNECT ANY CLIENTS WHEN ROUTER IS CONFIGURED WITH SOCKETS OPTION\nTEST_F(RoutingTests, bug_24841281) {\n  mysql_harness::rename_thread(\"TEST_F()\");\n\n  TcpPortPool port_pool_;\n\n  const uint16_t server_port = port_pool_.get_next_available();\n  const uint16_t router_port = port_pool_.get_next_available();\n\n  MockServer server(server_port);\n  server.start();\n\n  TmpDir tmp_dir; // create a tmp dir (it will be destroyed via RAII later)\n  std::string sock_path = tmp_dir() + \"/sock\";\n\n  // check that connecting to a TCP socket or a UNIX socket works\n  MySQLRouting routing(routing::RoutingStrategy::kNextAvailable, router_port,\n                 Protocol::Type::kXProtocol,\n                 routing::AccessMode::kReadWrite,\n                 \"0.0.0.0\", mysql_harness::Path(sock_path),\n                 \"routing:testroute\",\n                 routing::kDefaultMaxConnections,\n                 routing::kDefaultDestinationConnectionTimeout,\n                 routing::kDefaultMaxConnectErrors,\n                 routing::kDefaultClientConnectTimeout,\n                 routing::kDefaultNetBufferLength);\n  routing.set_destinations_from_csv(\"127.0.0.1:\"+std::to_string(server_port));\n  mysql_harness::PluginFuncEnv env(nullptr, nullptr, true);\n  std::thread thd(&MySQLRouting::start, &routing, &env);\n\n  // set the number of accepts that the server should expect for before stopping\n#ifdef _WIN32\n  server.stop_after_n_accepts(4);\n#else\n  server.stop_after_n_accepts(6);\n#endif\n\n  EXPECT_EQ(routing.get_context().info_active_routes_.load(), 0);\n\n  // open connections to the socket and see if we get a matching outgoing\n  // socket connection attempt to our mock server\n\n  int sock1;\n  // router is running in a thread, so we need to sync it\n  EXPECT_TRUE(call_until([&]() -> bool { sock1 = connect_local(router_port); return sock1 > 0; }))\n    << \"timed out connecting to router_port\";\n  int sock2 = connect_local(router_port);\n\n  EXPECT_THAT(sock1, ::testing::Gt(0));\n  EXPECT_THAT(sock2, ::testing::Gt(0));\n\n  EXPECT_TRUE(call_until([&server]() -> bool { return server.num_connections_ == 2; }))\n    << \"timed out, got \" << server.num_connections_ << \" connections\";\n  EXPECT_TRUE(call_until([&routing]() -> bool { return routing.get_context().info_active_routes_.load() == 2; }))\n    << \"timed out, got \" << routing.get_context().info_active_routes_.load() << \" active routes\";\n\n  disconnect(sock1);\n\n  EXPECT_TRUE(call_until([&routing]() -> bool { return routing.get_context().info_active_routes_.load() == 1; }))\n    << \"timed out, got \" << routing.get_context().info_active_routes_.load() << \" active routes\";\n\n  {\n    int sock11 = connect_local(router_port);\n    int sock12 = connect_local(router_port);\n\n    EXPECT_THAT(sock11, Gt(0));\n    EXPECT_THAT(sock12, Gt(0));\n\n    EXPECT_TRUE(call_until([&server]() -> bool { return server.num_connections_ == 3; }))\n      << \"timed out: \" << server.num_connections_;\n\n    call_until([&routing]() -> bool { return routing.get_context().info_active_routes_.load() == 3; });\n    EXPECT_EQ(3, routing.get_context().info_active_routes_.load());\n\n    disconnect(sock11);\n    call_until([&routing]() -> bool { return routing.get_context().info_active_routes_.load() == 2; });\n    EXPECT_EQ(2, routing.get_context().info_active_routes_.load());\n\n    disconnect(sock12);\n    call_until([&routing]() -> bool { return routing.get_context().info_active_routes_.load() == 1; });\n    EXPECT_EQ(1, routing.get_context().info_active_routes_.load());\n\n    call_until([&server]() -> bool { return server.num_connections_ == 1; });\n    EXPECT_EQ(1, server.num_connections_);\n  }\n\n  disconnect(sock2);\n  call_until([&routing]() -> bool { return routing.get_context().info_active_routes_.load() == 0; });\n  EXPECT_EQ(0, routing.get_context().info_active_routes_.load());\n\n#ifndef _WIN32\n  // now try the same with socket ops\n  int sock3 = connect_socket(sock_path.c_str());\n  int sock4 = connect_socket(sock_path.c_str());\n\n  EXPECT_THAT(sock3, Ne(-1));\n  EXPECT_THAT(sock4, Ne(-1));\n\n  call_until([&server]() -> bool { return server.num_connections_ == 2; });\n  EXPECT_EQ(2, server.num_connections_);\n\n  call_until([&routing]() -> bool { return routing.get_context().info_active_routes_.load() == 2; });\n  EXPECT_EQ(2, routing.get_context().info_active_routes_.load());\n\n  disconnect(sock3);\n  call_until([&routing]() -> bool { return routing.get_context().info_active_routes_.load() == 1; });\n  EXPECT_EQ(1, routing.get_context().info_active_routes_.load());\n\n  disconnect(sock4);\n  call_until([&routing]() -> bool { return routing.get_context().info_active_routes_.load() == 0; });\n  EXPECT_EQ(0, routing.get_context().info_active_routes_.load());\n#endif\n  env.clear_running();  // shut down MySQLRouting\n  server.stop();\n  thd.join();\n}\n\nTEST_F(RoutingTests, set_destinations_from_uri) {\n\n  MySQLRouting routing(routing::RoutingStrategy::kFirstAvailable, 7001, Protocol::Type::kXProtocol);\n\n  // valid metadata-cache uri\n  {\n    URI uri(\"metadata-cache://test/default?role=PRIMARY\");\n    EXPECT_NO_THROW(routing.set_destinations_from_uri(uri));\n  }\n\n  // metadata-cache uri, role missing\n  {\n    URI uri(\"metadata-cache://test/default\");\n    try {\n      routing.set_destinations_from_uri(uri);\n      FAIL() << \"Expected std::runtime_error exception\";\n    }\n    catch (const std::runtime_error &err) {\n      EXPECT_EQ(err.what(), std::string(\"Missing 'role' in routing destination specification\"));\n    }\n    catch (...) {\n      FAIL() << \"Expected std::runtime_error exception\";\n    }\n  }\n\n  // invalid scheme\n  {\n    URI uri(\"invalid-scheme://test/default?role=SECONDARY\");\n    try {\n      routing.set_destinations_from_uri(uri);\n      FAIL() << \"Expected std::runtime_error exception\";\n    }\n    catch (const std::runtime_error &err) {\n      EXPECT_EQ(err.what(), std::string(\"Invalid URI scheme; expecting: 'metadata-cache' is: 'invalid-scheme'\"));\n    }\n    catch (...) {\n      FAIL() << \"Expected std::runtime_error exception\";\n    }\n  }\n}\n\nTEST_F(RoutingTests, set_destinations_from_cvs) {\n\n  MySQLRouting routing(routing::RoutingStrategy::kNextAvailable, 7001, Protocol::Type::kXProtocol);\n\n  // valid address list\n  {\n    const std::string cvs = \"127.0.0.1:2002,127.0.0.1:2004\";\n    EXPECT_NO_THROW(routing.set_destinations_from_csv(cvs));\n  }\n\n  // no routing strategy, should go with default\n  {\n    MySQLRouting routing_inv(routing::RoutingStrategy::kUndefined, 7001, Protocol::Type::kXProtocol);\n    const std::string csv = \"127.0.0.1:2002,127.0.0.1:2004\";\n    EXPECT_NO_THROW(routing_inv.set_destinations_from_csv(csv));\n  }\n\n  // no address\n  {\n    const std::string csv = \"\";\n    EXPECT_THROW(routing.set_destinations_from_csv(csv),\n                 std::runtime_error);\n  }\n\n  // invalid address\n  {\n    const std::string csv = \"127.0.0.1.2:2222\";\n    EXPECT_THROW(routing.set_destinations_from_csv(csv),\n                 std::runtime_error);\n  }\n\n  // let's check if the correct defualt port gets chosen for\n  // the respective protocol\n  // we use the trick here setting the expected address also as\n  // the binding address for the routing which should make the method throw\n  // an exception if these are the same\n  {\n    const std::string address = \"127.0.0.1\";\n    MySQLRouting routing_classic(routing::RoutingStrategy::kNextAvailable, 3306,\n                                 Protocol::Type::kClassicProtocol, routing::AccessMode::kReadWrite, address);\n    EXPECT_THROW(routing_classic.set_destinations_from_csv(\"127.0.0.1\"), std::runtime_error);\n    EXPECT_THROW(routing_classic.set_destinations_from_csv(\"127.0.0.1:3306\"), std::runtime_error);\n    EXPECT_NO_THROW(routing_classic.set_destinations_from_csv(\"127.0.0.1:33060\"));\n\n\n    MySQLRouting routing_x(routing::RoutingStrategy::kNextAvailable, 33060,\n                           Protocol::Type::kXProtocol, routing::AccessMode::kReadWrite, address);\n    EXPECT_THROW(routing_x.set_destinations_from_csv(\"127.0.0.1\"), std::runtime_error);\n    EXPECT_THROW(routing_x.set_destinations_from_csv(\"127.0.0.1:33060\"), std::runtime_error);\n    EXPECT_NO_THROW(routing_x.set_destinations_from_csv(\"127.0.0.1:3306\"));\n  }\n}\n\n#endif // #ifndef _WIN32 [_HERE_]\n\nTEST_F(RoutingTests, get_routing_thread_name) {\n  // config name must begin with \"routing\" (name of the plugin passed from configuration file)\n  EXPECT_STREQ(\":parse err\", get_routing_thread_name(\"\", \"\").c_str());\n  EXPECT_STREQ(\":parse err\", get_routing_thread_name(\"routin\", \"\").c_str());\n  EXPECT_STREQ(\":parse err\", get_routing_thread_name(\" routing\", \"\").c_str());\n  EXPECT_STREQ(\"pre:parse err\", get_routing_thread_name(\"\", \"pre\").c_str());\n  EXPECT_STREQ(\"pre:parse err\", get_routing_thread_name(\"routin\", \"pre\").c_str());\n  EXPECT_STREQ(\"pre:parse err\", get_routing_thread_name(\" routing\", \"pre\").c_str());\n\n  // normally prefix would never be empty, so the behavior below is not be very meaningful;\n  // it should not crash however\n  EXPECT_STREQ(\":\", get_routing_thread_name(\"routing\",  \"\").c_str());\n  EXPECT_STREQ(\":\", get_routing_thread_name(\"routing:\", \"\").c_str());\n\n  // realistic (but unanticipated) cases - removing everything up to _default_ will fail,\n  // in which case we fall back of <prefix>:<everything after \"routing:\">, trimmed to 15 chars\n  EXPECT_STREQ(\"RtS:test_def_ul\", get_routing_thread_name(\"routing:test_def_ult_x_ro\", \"RtS\").c_str());\n  EXPECT_STREQ(\"RtS:test_def_ul\", get_routing_thread_name(\"routing:test_def_ult_ro\",   \"RtS\").c_str());\n  EXPECT_STREQ(\"RtS:\",          get_routing_thread_name(\"routing\",                   \"RtS\").c_str());\n  EXPECT_STREQ(\"RtS:test_x_ro\", get_routing_thread_name(\"routing:test_x_ro\", \"RtS\").c_str());\n  EXPECT_STREQ(\"RtS:test_ro\",   get_routing_thread_name(\"routing:test_ro\",   \"RtS\").c_str());\n\n  // real cases\n  EXPECT_STREQ(\"RtS:x_ro\", get_routing_thread_name(\"routing:test_default_x_ro\", \"RtS\").c_str());\n  EXPECT_STREQ(\"RtS:ro\",   get_routing_thread_name(\"routing:test_default_ro\",   \"RtS\").c_str());\n  EXPECT_STREQ(\"RtS:\",     get_routing_thread_name(\"routing\",                   \"RtS\").c_str());\n}\n\n/*\n * @test This test verifies fix for Bug 23857183 and checks if trying to connect to wrong port\n *       fails immediately not via timeout\n *\n * @todo (jan) disabled the test as the result is unpredictable as port may be in use, IP may\n *       be or not be bound, ... The test needs to be rewritten and have predictable output, or be\n *       removed.\n */\nTEST_F(RoutingTests, DISABLED_ConnectToServerWrongPort) {\n  const std::chrono::seconds TIMEOUT {4};\n\n  // wrong port number\n  {\n    TCPAddress address(\"127.0.0.1\", 10888);\n    int server = routing::RoutingSockOps::instance(mysql_harness::SocketOperations::instance())\n                 ->get_mysql_socket(address, TIMEOUT);\n    // should return -1, -2 is timeout expired which is not what we expect when connecting with the wrong port\n    ASSERT_EQ(server, -1);\n  }\n\n// in darwin and solaris, attempting connection to 127.0.0.11 will fail by timeout\n#if !defined(__APPLE__) && !defined(__sun)\n  // wrong port number and IP\n  {\n    TCPAddress address(\"127.0.0.11\", 10888);\n    int server = routing::RoutingSockOps::instance(mysql_harness::SocketOperations::instance())\n                 ->get_mysql_socket(address, TIMEOUT);\n    // should return -1, -2 is timeout expired which is not what we expect when connecting with the wrong port\n    ASSERT_EQ(server, -1);\n  }\n#endif\n}\n\n\nint main(int argc, char *argv[]) {\n  init_test_logger();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/routing/tests/test_setup_named_socket_service.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef _WIN32  // named sockets are not supported on Windows;\n                // on Unix, they're implemented using Unix sockets\n\n#include \"gmock/gmock.h\"\n\n#include \"../../routing/src/mysql_routing.h\"\n#include \"router_test_helpers.h\"\n#include \"test/helpers.h\"\n\nclass TestSetupNamedSocketService : public ::testing::Test {};\n\nTEST_F(TestSetupNamedSocketService, unix_socket_permissions_failure) {\n  /**\n   * @test Verify that failure while setting unix socket permissions throws correctly\n   */\n\n  EXPECT_THROW_LIKE(\n    MySQLRouting::set_unix_socket_permissions(\"/no/such/file\"),\n    std::runtime_error,\n    \"Failed setting file permissions on socket file '/no/such/file': No such file or directory\"\n  );\n}\n\nint main(int argc, char *argv[]) {\n  ::testing::InitGoogleTest(&argc, argv);\n\n  init_test_logger();\n  return RUN_ALL_TESTS();\n}\n\n#endif // #ifndef _WIN32\n"
  },
  {
    "path": "src/routing/tests/test_setup_tcp_service.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"gmock/gmock.h\"\n\n#include \"mysqlrouter/routing.h\"\n#include \"router_test_helpers.h\"\n#include \"../../routing/src/mysql_routing.h\"\n#include \"test/helpers.h\"\n#include \"routing_mocks.h\"\n\n#include <memory>\n#include <string>\n#ifndef _WIN32\n# include <netinet/in.h>\n#else\n# include <WinSock2.h>\n#endif\n\nusing ::testing::_;\nusing ::testing::DoAll;\nusing ::testing::StrEq;\nusing ::testing::SetArgPointee;\nusing ::testing::Return;\n\nclass TestSetupTcpService : public ::testing::Test {\n protected:\n\n  // create some linked list of the addresses that getaddrinfo returns\n  addrinfo* get_test_addresses_list(size_t qty = 1) {\n    addrinfo *prev{nullptr}, *head{nullptr};\n    for (size_t i = 0; i < qty; i++) {\n      auto ai = new addrinfo();\n      // fields values don't matter for us in those tests\n      memset(ai, 0x0, sizeof(addrinfo));\n\n      if (prev) {\n        prev->ai_next = ai;\n      }\n      if (!head) {\n        head = ai;\n      }\n\n      prev = ai;\n\n      addresses_to_release_.emplace_back(ai);\n    }\n\n    return head;\n  }\n\n protected:\n  MockRoutingSockOps routing_sock_ops;\n  MockSocketOperations& socket_op = *routing_sock_ops.so();\n private:\n  std::vector<std::unique_ptr<addrinfo>> addresses_to_release_;\n};\n\nTEST_F(TestSetupTcpService, single_addr_ok) {\n  MySQLRouting r(routing::RoutingStrategy::kFirstAvailable, 7001,\n                 Protocol::Type::kClassicProtocol, routing::AccessMode::kReadWrite,\n                 \"127.0.0.1\", mysql_harness::Path(), \"routing-name\",\n                 1, std::chrono::seconds(1), 1, std::chrono::seconds(1), routing::kDefaultNetBufferLength,\n                 &routing_sock_ops);\n\n  const auto addr_list = get_test_addresses_list(1);\n  EXPECT_CALL(socket_op, getaddrinfo(_, _, _, _))\n      .WillOnce(DoAll(SetArgPointee<3>( addr_list ), Return(0)));\n\n\n  EXPECT_CALL(socket_op, socket(_, _, _)).WillOnce(Return(1));\n#ifndef _WIN32\n  EXPECT_CALL(socket_op, setsockopt(_, _, _, _, _)).WillOnce(Return(0));\n#endif\n  EXPECT_CALL(socket_op, bind(_, _, _)).WillOnce(Return(0));\n\n  EXPECT_CALL(socket_op, listen(_, _)).WillOnce(Return(0));\n\n  EXPECT_CALL(socket_op, freeaddrinfo(_));\n\n  // those are called in the MySQLRouting destructor\n  EXPECT_CALL(socket_op, close(_));\n  EXPECT_CALL(socket_op, shutdown(_));\n\n  ASSERT_NO_THROW(r.setup_tcp_service());\n}\n\nTEST_F(TestSetupTcpService, getaddrinfo_fails) {\n  MySQLRouting r(routing::RoutingStrategy::kFirstAvailable, 7001,\n                 Protocol::Type::kClassicProtocol, routing::AccessMode::kReadWrite,\n                 \"127.0.0.1\", mysql_harness::Path(), \"routing-name\",\n                 1, std::chrono::seconds(1), 1, std::chrono::seconds(1), routing::kDefaultNetBufferLength,\n                 &routing_sock_ops);\n\n  EXPECT_CALL(socket_op, getaddrinfo(_, _, _, _)).WillOnce(Return(-1));\n\n  ASSERT_THROW_LIKE(r.setup_tcp_service(),\n      std::runtime_error,\n      \"[routing-name] Failed getting address information\");\n}\n\nTEST_F(TestSetupTcpService, socket_fails_for_all_addr) {\n  MySQLRouting r(routing::RoutingStrategy::kFirstAvailable, 7001,\n                 Protocol::Type::kClassicProtocol, routing::AccessMode::kReadWrite,\n                 \"127.0.0.1\", mysql_harness::Path(), \"routing-name\",\n                 1, std::chrono::seconds(1), 1, std::chrono::seconds(1), routing::kDefaultNetBufferLength,\n                 &routing_sock_ops);\n\n  const auto addr_list = get_test_addresses_list(2);\n  EXPECT_CALL(socket_op, getaddrinfo(_, _, _, _))\n      .WillOnce(DoAll(SetArgPointee<3>( addr_list ), Return(0)));\n\n  // make the first call to socket() fail\n  EXPECT_CALL(socket_op, socket(_, _, _))\n     .WillOnce(Return(-1))\n     .WillOnce(Return(-1));\n\n  EXPECT_CALL(socket_op, freeaddrinfo(_));\n\n  ASSERT_THROW_LIKE(r.setup_tcp_service(),\n      std::runtime_error,\n      \"[routing-name] Failed to setup service socket\");\n}\n\nTEST_F(TestSetupTcpService, socket_fails) {\n  MySQLRouting r(routing::RoutingStrategy::kFirstAvailable, 7001,\n                 Protocol::Type::kClassicProtocol, routing::AccessMode::kReadWrite,\n                 \"127.0.0.1\", mysql_harness::Path(), \"routing-name\",\n                 1, std::chrono::seconds(1), 1, std::chrono::seconds(1), routing::kDefaultNetBufferLength,\n                 &routing_sock_ops);\n\n  const auto addr_list = get_test_addresses_list(2);\n  EXPECT_CALL(socket_op, getaddrinfo(_, _, _, _))\n      .WillOnce(DoAll(SetArgPointee<3>( addr_list ), Return(0)));\n\n  // make the first call to socket() fail\n  EXPECT_CALL(socket_op, socket(_, _, _))\n     .WillOnce(Return(-1))\n     .WillOnce(Return(1));\n\n#ifndef _WIN32\n  EXPECT_CALL(socket_op, setsockopt(_, _, _, _, _)).WillOnce(Return(0));\n#endif\n  EXPECT_CALL(socket_op, bind(_, _, _)).WillOnce(Return(0));\n\n  EXPECT_CALL(socket_op, listen(_, _)).WillOnce(Return(0));\n\n  EXPECT_CALL(socket_op, freeaddrinfo(_));\n\n  // those are called in the MySQLRouting destructor\n  EXPECT_CALL(socket_op, close(_));\n  EXPECT_CALL(socket_op, shutdown(_));\n\n  ASSERT_NO_THROW(r.setup_tcp_service());\n}\n\n#ifndef _WIN32\nTEST_F(TestSetupTcpService, setsockopt_fails) {\n  MySQLRouting r(routing::RoutingStrategy::kFirstAvailable, 7001,\n                 Protocol::Type::kClassicProtocol, routing::AccessMode::kReadWrite,\n                 \"127.0.0.1\", mysql_harness::Path(), \"routing-name\",\n                 1, std::chrono::seconds(1), 1, std::chrono::seconds(1), routing::kDefaultNetBufferLength,\n                 &routing_sock_ops);\n\n  const auto addr_list = get_test_addresses_list(2);\n  EXPECT_CALL(socket_op, getaddrinfo(_, _, _, _))\n      .WillOnce(DoAll(SetArgPointee<3>( addr_list ), Return(0)));\n\n  EXPECT_CALL(socket_op, socket(_, _, _))\n     .WillOnce(Return(1))\n     .WillOnce(Return(1));\n\n  // make the first call to setsockopt() fail\n  EXPECT_CALL(socket_op, setsockopt(_, _, _, _, _)).\n      WillOnce(Return(-1)).\n      WillOnce(Return(0));\n\n  EXPECT_CALL(socket_op, bind(_, _, _))\n      .WillOnce(Return(0));\n\n  EXPECT_CALL(socket_op, listen(_, _)).WillOnce(Return(0));\n\n  EXPECT_CALL(socket_op, freeaddrinfo(_));\n\n  // those are called in the MySQLRouting destructor\n  EXPECT_CALL(socket_op, close(_)).Times(2);\n  EXPECT_CALL(socket_op, shutdown(_));\n\n  ASSERT_NO_THROW(r.setup_tcp_service());\n}\n#endif\n\nTEST_F(TestSetupTcpService, bind_fails) {\n  MySQLRouting r(routing::RoutingStrategy::kFirstAvailable, 7001,\n                 Protocol::Type::kClassicProtocol, routing::AccessMode::kReadWrite,\n                 \"127.0.0.1\", mysql_harness::Path(), \"routing-name\",\n                 1, std::chrono::seconds(1), 1, std::chrono::seconds(1), routing::kDefaultNetBufferLength,\n                 &routing_sock_ops);\n\n  const auto addr_list = get_test_addresses_list(2);\n  EXPECT_CALL(socket_op, getaddrinfo(_, _, _, _))\n      .WillOnce(DoAll(SetArgPointee<3>( addr_list ), Return(0)));\n\n  // make the first call to socket() fail\n  EXPECT_CALL(socket_op, socket(_, _, _))\n     .WillOnce(Return(1))\n     .WillOnce(Return(1));\n\n#ifndef _WIN32\n  EXPECT_CALL(socket_op, setsockopt(_, _, _, _, _)).\n      WillOnce(Return(0)).\n      WillOnce(Return(0));\n#endif\n  EXPECT_CALL(socket_op, bind(_, _, _))\n      .WillOnce(Return(-1))\n      .WillOnce(Return(0));\n\n  EXPECT_CALL(socket_op, listen(_, _)).WillOnce(Return(0));\n\n  EXPECT_CALL(socket_op, freeaddrinfo(_));\n\n  // those are called in the MySQLRouting destructor\n  EXPECT_CALL(socket_op, close(_)).Times(2);\n  EXPECT_CALL(socket_op, shutdown(_));\n\n  ASSERT_NO_THROW(r.setup_tcp_service());\n}\n\nTEST_F(TestSetupTcpService, listen_fails) {\n  MySQLRouting r(routing::RoutingStrategy::kFirstAvailable, 7001,\n                 Protocol::Type::kClassicProtocol, routing::AccessMode::kReadWrite,\n                 \"127.0.0.1\", mysql_harness::Path(), \"routing-name\",\n                 1, std::chrono::seconds(1), 1, std::chrono::seconds(1), routing::kDefaultNetBufferLength,\n                 &routing_sock_ops);\n\n  const auto addr_list = get_test_addresses_list(2);\n  EXPECT_CALL(socket_op, getaddrinfo(_, _, _, _))\n      .WillOnce(DoAll(SetArgPointee<3>( addr_list ), Return(0)));\n\n  // make the first call to socket() fail\n  EXPECT_CALL(socket_op, socket(_, _, _)).WillOnce(Return(1));\n\n#ifndef _WIN32\n  EXPECT_CALL(socket_op, setsockopt(_, _, _, _, _)).WillOnce(Return(0));\n#endif\n  EXPECT_CALL(socket_op, bind(_, _, _)).WillOnce(Return(0));\n\n  EXPECT_CALL(socket_op, listen(_, _)).WillOnce(Return(-1));\n\n  EXPECT_CALL(socket_op, freeaddrinfo(_));\n\n  // those are called in the MySQLRouting destructor\n  EXPECT_CALL(socket_op, close(_));\n  EXPECT_CALL(socket_op, shutdown(_));\n\n  ASSERT_THROW_LIKE(r.setup_tcp_service(),\n      std::runtime_error,\n      \"[routing-name] Failed to start listening for connections using TCP\");\n}\n\n\nint main(int argc, char *argv[]) {\n  ::testing::InitGoogleTest(&argc, argv);\n\n  init_test_logger();\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "src/routing/tests/test_x_protocol.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"gtest/gtest.h\"\n#include \"gmock/gmock.h\"\n\n#include <memory>\n\n#include \"mysql/harness/logging/logging.h\"\n#include \"protocol/x_protocol.h\"\n#include \"mysqlrouter/routing.h\"\n#include \"routing_mocks.h\"\n#ifdef __GNUC__\n#pragma GCC diagnostic push\n#pragma GCC diagnostic warning \"-Wconversion\"\n#endif\n#include <google/protobuf/io/coded_stream.h>\n#include \"mysqlx.pb.h\"\n#include \"mysqlx_session.pb.h\"\n#include \"mysqlx_connection.pb.h\"\n#include \"mysqlx_notice.pb.h\"\n#ifdef __GNUC__\n#pragma GCC diagnostic pop\n#endif\n#include \"test/helpers.h\"\n\nusing ::testing::_;\nusing ::testing::Return;\n\n\nclass XProtocolTest : public ::testing::Test {\nprotected:\n  XProtocolTest() :\n    mock_routing_sock_ops_(new MockRoutingSockOps()),\n    mock_socket_operations_(mock_routing_sock_ops_->so()),\n    x_protocol_(new XProtocol(mock_routing_sock_ops_.get()))\n  {}\n\n  virtual void SetUp() {\n    network_buffer_.resize(routing::kDefaultNetBufferLength);\n    network_buffer_offset_ = 0;\n    curr_pktnr_ = 0;\n    handshake_done_ = false;\n  }\n\n  std::unique_ptr<MockRoutingSockOps> mock_routing_sock_ops_;\n  MockSocketOperations* mock_socket_operations_;\n  std::unique_ptr<BaseProtocol> x_protocol_;\n\n  void serialize_protobuf_msg_to_buffer(RoutingProtocolBuffer& buffer,\n                                        size_t &buffer_offset,\n                                        google::protobuf::Message& msg,\n                                        unsigned char type) {\n    size_t msg_size = msg.ByteSize();\n    google::protobuf::io::CodedOutputStream::WriteLittleEndian32ToArray(static_cast<uint32_t>(msg_size + 1),\n                                                                        &buffer[buffer_offset]);\n    buffer[buffer_offset+4] = type;\n    bool res = msg.SerializeToArray(&buffer[buffer_offset+5], msg.ByteSize());\n    buffer_offset += (msg_size+5);\n    ASSERT_TRUE(res);\n  }\n\n  static constexpr int sender_socket_ = 1;\n  static constexpr int receiver_socket_ = 2;\n\n  RoutingProtocolBuffer network_buffer_;\n  size_t network_buffer_offset_;\n  int curr_pktnr_;\n  bool handshake_done_;\n};\n\nstatic Mysqlx::Session::AuthenticateStart create_authenticate_start_msg() {\n  Mysqlx::Session::AuthenticateStart result;\n  result.set_mech_name(\"PLAIN\");\n\n  return result;\n}\n\nMysqlx::Error create_error_msg(unsigned short code,\n                               const std::string &message,\n                               const std::string &sql_state) {\n  Mysqlx::Error result;\n  result.set_code(code);\n  result.set_sql_state(sql_state);\n  result.set_msg(message);\n\n  return result;\n}\n\nMysqlx::Notice::Warning create_warning_msg(unsigned int code,\n                                const std::string &message) {\n  Mysqlx::Notice::Warning result;\n  result.set_code(code);\n  result.set_msg(message);\n\n  return result;\n}\n\nstatic Mysqlx::Connection::CapabilitiesSet create_capab_set_msg() {\n  Mysqlx::Connection::CapabilitiesSet result;\n\n  Mysqlx::Connection::Capability *capability = result.mutable_capabilities()->add_capabilities();\n  capability->set_name(\"tls\");\n  capability->mutable_value()->set_type(Mysqlx::Datatypes::Any_Type_SCALAR);\n  capability->mutable_value()->mutable_scalar()->set_type(Mysqlx::Datatypes::Scalar_Type_V_UINT);\n  capability->mutable_value()->mutable_scalar()->set_v_unsigned_int(1);\n\n  return result;\n}\n\n\nTEST_F(XProtocolTest, OnBlockClientHostSuccess)\n{\n  // we expect the router sending CapabilitiesGet message\n  // to prevent MySQL server from bumping up connection error counter\n  const size_t msg_size = Mysqlx::Connection::CapabilitiesGet().ByteSize() + 5;\n\n  EXPECT_CALL(*mock_socket_operations_, write(receiver_socket_, _, msg_size)).WillOnce(Return(msg_size));\n\n  const bool result = x_protocol_->on_block_client_host(receiver_socket_, \"routing\");\n\n  ASSERT_TRUE(result);\n}\n\nTEST_F(XProtocolTest, OnBlockClientHostWriteFail)\n{\n  // we expect the router sending CapabilitiesGet message\n  // to prevent MySQL server from bumping up connection error counter\n  const size_t msg_size = Mysqlx::Connection::CapabilitiesGet().ByteSize() + 5;\n\n  EXPECT_CALL(*mock_socket_operations_, write(receiver_socket_, _, msg_size)).WillOnce(Return(-1));\n\n  const bool result = x_protocol_->on_block_client_host(receiver_socket_, \"routing\");\n\n  ASSERT_FALSE(result);\n}\n\nTEST_F(XProtocolTest, CopyPacketsNoData)\n{\n  size_t report_bytes_read = 0xff;\n\n  int result = x_protocol_->copy_packets(sender_socket_, receiver_socket_, false, network_buffer_, &curr_pktnr_,\n                                         handshake_done_, &report_bytes_read, true);\n\n  ASSERT_TRUE(result==0);\n  ASSERT_TRUE(report_bytes_read==0);\n  ASSERT_FALSE(handshake_done_);\n}\n\nTEST_F(XProtocolTest, CopyPacketsReadError)\n{\n  size_t report_bytes_read = 0xff;\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_,_,_)).WillOnce(Return(-1));\n\n  int result = x_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                         handshake_done_, &report_bytes_read, true);\n\n  ASSERT_FALSE(handshake_done_);\n  ASSERT_EQ(-1, result);\n}\n\nTEST_F(XProtocolTest, CopyPacketsHandshakeDoneOK)\n{\n  handshake_done_ = true;\n  size_t report_bytes_read = 0xff;\n  constexpr int MSG_SIZE = 20;\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_, &network_buffer_[0], network_buffer_.size())).WillOnce(Return(MSG_SIZE));\n  EXPECT_CALL(*mock_socket_operations_, write(receiver_socket_, &network_buffer_[0], 20)).WillOnce(Return(MSG_SIZE));\n\n  int result = x_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                         handshake_done_, &report_bytes_read, true);\n\n  ASSERT_TRUE(handshake_done_);\n  ASSERT_EQ(0, result);\n  ASSERT_EQ(static_cast<size_t>(MSG_SIZE), report_bytes_read);\n}\n\nTEST_F(XProtocolTest, CopyPacketsHandshakeDoneWriteError)\n{\n  handshake_done_ = true;\n  size_t report_bytes_read = 0xff;\n  constexpr ssize_t MSG_SIZE = 20;\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_, &network_buffer_[0], network_buffer_.size())).\n                                                                  WillOnce(Return(MSG_SIZE));\n  EXPECT_CALL(*mock_socket_operations_, write(receiver_socket_, &network_buffer_[0], 20)).WillOnce(Return(-1));\n\n  int result = x_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                         handshake_done_, &report_bytes_read, true);\n\n  ASSERT_TRUE(handshake_done_);\n  ASSERT_EQ(-1, result);\n}\n\nTEST_F(XProtocolTest, CopyPacketsHandshakeClientSendsIvalidData)\n{\n  size_t report_bytes_read = 0xff;\n  constexpr size_t INVALID_DATA_SIZE = 20;\n\n  // prepare some invalid data\n  for (size_t i=0; i < INVALID_DATA_SIZE; ++i) {\n    network_buffer_[i] = static_cast<uint8_t>(i+10);\n  }\n  network_buffer_offset_ += INVALID_DATA_SIZE;\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_, &network_buffer_[0], network_buffer_.size())).\n                                                                              WillOnce(Return(network_buffer_offset_));\n\n  int result = x_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                         handshake_done_, &report_bytes_read, false);\n\n  ASSERT_FALSE(handshake_done_);\n  ASSERT_EQ(-1, result);\n  ASSERT_EQ(network_buffer_offset_, INVALID_DATA_SIZE);\n}\n\nTEST_F(XProtocolTest, CopyPacketsHandshakeClientSendsWrongMessage)\n{\n  size_t report_bytes_read = 0xff;\n  Mysqlx::Session::Close close_msg{};\n\n  serialize_protobuf_msg_to_buffer(network_buffer_, network_buffer_offset_, close_msg,\n                                   Mysqlx::ClientMessages::SESS_CLOSE);\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_, &network_buffer_[0], network_buffer_.size())).\n                                                     WillOnce(Return(network_buffer_offset_));\n\n  int result = x_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                         handshake_done_, &report_bytes_read, false);\n\n  ASSERT_FALSE(handshake_done_);\n  ASSERT_EQ(-1, result);\n}\n\nTEST_F(XProtocolTest, CopyPacketsHandshakeClientSendsAuthStart)\n{\n  size_t report_bytes_read = 0xff;\n  auto auth_msg = create_authenticate_start_msg();\n\n  serialize_protobuf_msg_to_buffer(network_buffer_, network_buffer_offset_, auth_msg,\n                                   Mysqlx::ClientMessages::SESS_AUTHENTICATE_START);\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_, &network_buffer_[0], network_buffer_.size())).\n                                                     WillOnce(Return(network_buffer_offset_));\n  EXPECT_CALL(*mock_socket_operations_, write(receiver_socket_, &network_buffer_[0], network_buffer_offset_)).\n                                                     WillOnce(Return(network_buffer_offset_));\n\n  int result = x_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                         handshake_done_, &report_bytes_read, false);\n\n  ASSERT_TRUE(handshake_done_);\n  ASSERT_EQ(0, result);\n}\n\nTEST_F(XProtocolTest, CopyPacketsHandshakeClientSendsCapabilitiesGet)\n{\n  size_t report_bytes_read = 0xff;\n  Mysqlx::Connection::CapabilitiesGet capab_msg{};\n\n  serialize_protobuf_msg_to_buffer(network_buffer_, network_buffer_offset_, capab_msg,\n                                   Mysqlx::ClientMessages::CON_CAPABILITIES_GET);\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_, &network_buffer_[0], network_buffer_.size())).\n                                                     WillOnce(Return(network_buffer_offset_));\n  EXPECT_CALL(*mock_socket_operations_, write(receiver_socket_, &network_buffer_[0], network_buffer_offset_)).\n                                                     WillOnce(Return(network_buffer_offset_));\n\n  int result = x_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                         handshake_done_, &report_bytes_read, false);\n\n  ASSERT_TRUE(handshake_done_);\n  ASSERT_EQ(0, result);\n}\n\nTEST_F(XProtocolTest, CopyPacketsHandshakeClientSendsConnectionClose)\n{\n  size_t report_bytes_read = 0xff;\n  Mysqlx::Connection::Close close_msg{};\n\n  serialize_protobuf_msg_to_buffer(network_buffer_, network_buffer_offset_, close_msg,\n                                   Mysqlx::ClientMessages::CON_CLOSE);\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_, &network_buffer_[0], network_buffer_.size())).\n                                                     WillOnce(Return(network_buffer_offset_));\n  EXPECT_CALL(*mock_socket_operations_, write(receiver_socket_, &network_buffer_[0], network_buffer_offset_)).\n                                                     WillOnce(Return(network_buffer_offset_));\n\n  int result = x_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                         handshake_done_, &report_bytes_read, false);\n\n  ASSERT_TRUE(handshake_done_);\n  ASSERT_EQ(0, result);\n}\n\nTEST_F(XProtocolTest, CopyPacketsHandshakeClientSendsCapabilitiesSet)\n{\n  size_t report_bytes_read = 0xff;\n  auto capab_msg = create_capab_set_msg();\n\n  serialize_protobuf_msg_to_buffer(network_buffer_, network_buffer_offset_, capab_msg,\n                                   Mysqlx::ClientMessages::CON_CAPABILITIES_SET);\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_, &network_buffer_[0], network_buffer_.size())).\n                                                     WillOnce(Return(network_buffer_offset_));\n  EXPECT_CALL(*mock_socket_operations_, write(receiver_socket_, &network_buffer_[0], network_buffer_offset_)).\n                                                     WillOnce(Return(network_buffer_offset_));\n\n  int result = x_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                         handshake_done_, &report_bytes_read, false);\n\n  ASSERT_TRUE(handshake_done_);\n  ASSERT_EQ(0, result);\n}\n\nTEST_F(XProtocolTest, CopyPacketsHandshakeClientSendsBrokenMessage)\n{\n  size_t report_bytes_read = 0xff;\n  auto capab_msg = create_capab_set_msg();\n\n  serialize_protobuf_msg_to_buffer(network_buffer_, network_buffer_offset_, capab_msg,\n                                   Mysqlx::ClientMessages::CON_CAPABILITIES_SET);\n\n  // let's brake some part of the message in the buffer to simulate malformed message\n  network_buffer_[6] = 0xff;\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_, &network_buffer_[0], network_buffer_.size())).\n                                                     WillOnce(Return(network_buffer_offset_));\n\n  int result = x_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                         handshake_done_, &report_bytes_read, false);\n\n  ASSERT_FALSE(handshake_done_);\n  ASSERT_EQ(-1, result);\n}\n\nTEST_F(XProtocolTest, CopyPacketsHandshakeServerSendsError)\n{\n  size_t report_bytes_read = 0xff;\n  auto error_msg = create_error_msg(100, \"Error message\", \"HY007\");\n\n  serialize_protobuf_msg_to_buffer(network_buffer_, network_buffer_offset_, error_msg,\n                                   Mysqlx::ServerMessages::ERROR);\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_, &network_buffer_[0], network_buffer_.size())).\n                                                     WillOnce(Return(network_buffer_offset_));\n  EXPECT_CALL(*mock_socket_operations_, write(receiver_socket_, &network_buffer_[0], network_buffer_offset_)).\n                                                     WillOnce(Return(network_buffer_offset_));\n\n  int result = x_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                         handshake_done_, &report_bytes_read, true);\n\n  ASSERT_TRUE(handshake_done_);\n  ASSERT_EQ(0, result);\n}\n\nTEST_F(XProtocolTest, CopyPacketsHandshakeServerSendsOtherMessage)\n{\n  size_t report_bytes_read = 0xff;\n  auto warn_msg = create_warning_msg(10023, \"Warning message\");\n\n  serialize_protobuf_msg_to_buffer(network_buffer_, network_buffer_offset_, warn_msg,\n                                   Mysqlx::ServerMessages::NOTICE);\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_, &network_buffer_[0], network_buffer_.size())).\n                                                     WillOnce(Return(network_buffer_offset_));\n  EXPECT_CALL(*mock_socket_operations_, write(receiver_socket_, &network_buffer_[0], network_buffer_offset_)).\n                                                     WillOnce(Return(network_buffer_offset_));\n\n  int result = x_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                         handshake_done_, &report_bytes_read, true);\n\n  ASSERT_FALSE(handshake_done_);\n  ASSERT_EQ(0, result);\n}\n\nTEST_F(XProtocolTest, CopyPacketsHandshakeReadTwoMessages)\n{\n  size_t report_bytes_read = 0xff;\n\n  auto warn_msg = create_warning_msg(10023, \"Warning message\");\n  auto error_msg = create_error_msg(100, \"Error message\", \"HY007\");\n\n  serialize_protobuf_msg_to_buffer(network_buffer_, network_buffer_offset_, warn_msg,\n                                   Mysqlx::ServerMessages::NOTICE);\n  serialize_protobuf_msg_to_buffer(network_buffer_, network_buffer_offset_, error_msg,\n                                   Mysqlx::ServerMessages::ERROR);\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_, &network_buffer_[0], network_buffer_.size())).\n                                                                  WillOnce(Return(network_buffer_offset_));\n  EXPECT_CALL(*mock_socket_operations_, write(receiver_socket_, &network_buffer_[0], network_buffer_offset_)).\n                                                                  WillOnce(Return(network_buffer_offset_));\n\n  int result = x_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                         handshake_done_, &report_bytes_read, true);\n\n  // handshake_done_ should be set after the second message\n  ASSERT_TRUE(handshake_done_);\n  ASSERT_EQ(0, result);\n  ASSERT_EQ(network_buffer_offset_, report_bytes_read);\n}\n\nTEST_F(XProtocolTest, CopyPacketsHandshakeReadPartialHeader)\n{\n  size_t report_bytes_read = 0xff;\n\n  Mysqlx::Connection::CapabilitiesGet capab_msg{};\n\n  serialize_protobuf_msg_to_buffer(network_buffer_, network_buffer_offset_, capab_msg,\n                                   Mysqlx::ClientMessages::CON_CAPABILITIES_GET);\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_, _, _)).\n                                               Times(2).\n                                               WillOnce(Return(network_buffer_offset_-3)).\n                                               WillOnce(Return(3));\n  EXPECT_CALL(*mock_socket_operations_, write(receiver_socket_, &network_buffer_[0], network_buffer_offset_)).\n                                                WillOnce(Return(network_buffer_offset_));\n\n  int result = x_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                         handshake_done_, &report_bytes_read, false);\n\n  // handshake_done_ should bet set\n  ASSERT_TRUE(handshake_done_);\n  ASSERT_EQ(0, result);\n  ASSERT_EQ(network_buffer_offset_, report_bytes_read);\n}\n\nTEST_F(XProtocolTest, CopyPacketsHandshakeReadPartialMessage)\n{\n  size_t report_bytes_read = 0xff;\n\n  auto warn_msg = create_warning_msg(100, \"Warning message\");\n\n  serialize_protobuf_msg_to_buffer(network_buffer_, network_buffer_offset_, warn_msg,\n                                   Mysqlx::ServerMessages::NOTICE);\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_, _, _)).\n                                               Times(2).\n                                               WillOnce(Return(network_buffer_offset_-8)).\n                                               WillOnce(Return(8));\n  EXPECT_CALL(*mock_socket_operations_, write(receiver_socket_, &network_buffer_[0], network_buffer_offset_)).\n                                                WillOnce(Return(network_buffer_offset_));\n\n  int result = x_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                         handshake_done_, &report_bytes_read, true);\n\n  ASSERT_FALSE(handshake_done_);\n  ASSERT_EQ(0, result);\n  ASSERT_EQ(network_buffer_offset_, report_bytes_read);\n}\n\nTEST_F(XProtocolTest, CopyPacketsHandshakeReadPartialMessageFails)\n{\n  size_t report_bytes_read = 0xff;\n\n  auto warn_msg = create_warning_msg(100, \"Warning message\");\n\n  serialize_protobuf_msg_to_buffer(network_buffer_, network_buffer_offset_, warn_msg,\n                                   Mysqlx::ServerMessages::NOTICE);\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_, _, _)).\n                                               Times(2).\n                                               WillOnce(Return(network_buffer_offset_-8)).\n                                               WillOnce(Return(-1));\n\n  int result = x_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                         handshake_done_, &report_bytes_read, true);\n\n  ASSERT_FALSE(handshake_done_);\n  ASSERT_EQ(-1, result);\n}\n\n\nTEST_F(XProtocolTest, CopyPacketsHandshakeMsgBiggerThanBuffer)\n{\n  size_t report_bytes_read = 0xff;\n\n  Mysqlx::Connection::CapabilitiesSet capabilites_msg;\n  // make the message bigger than the current network buffer size\n  std::string msg;\n  while (msg.size() <= routing::kDefaultNetBufferLength) {\n    msg += std::string(1000, 'a');\n  }\n  auto error_msg = create_error_msg(100, msg, \"HY007\");\n  assert(error_msg.ByteSize() > static_cast<int>(routing::kDefaultNetBufferLength));\n\n  RoutingProtocolBuffer msg_buffer(error_msg.ByteSize()+5);\n  const auto BUFFER_SIZE = network_buffer_.size();\n\n  serialize_protobuf_msg_to_buffer(msg_buffer, network_buffer_offset_, error_msg,\n                                   Mysqlx::ServerMessages::ERROR);\n\n  // copy part of the message to the network buffer\n  std::copy(msg_buffer.begin(), msg_buffer.begin()+network_buffer_.size(), network_buffer_.begin());\n\n  EXPECT_CALL(*mock_socket_operations_, read(sender_socket_, _, _)).Times(1).\n                                             WillOnce(Return(network_buffer_.size()));\n\n  int result = x_protocol_->copy_packets(sender_socket_, receiver_socket_, true, network_buffer_, &curr_pktnr_,\n                                         handshake_done_, &report_bytes_read, true);\n\n  // the size of buffer passed to copy_packets should be untouched\n  ASSERT_EQ(BUFFER_SIZE, network_buffer_.size());\n  ASSERT_FALSE(handshake_done_);\n  ASSERT_EQ(-1, result);\n}\n\nTEST_F(XProtocolTest, SendErrorOKMultipleWrites)\n{\n  EXPECT_CALL(*mock_socket_operations_, write(1, _, _)).Times(2).\n                                                  WillOnce(Return(8)).\n                                                  WillOnce(Return  (10000));\n\n  bool res = x_protocol_->send_error(1, 55, \"Error message\", \"SQL_STATE\",\n                                     \"routing configuration name\");\n\n  ASSERT_TRUE(res);\n}\n\nTEST_F(XProtocolTest, SendErrorWriteFail)\n{\n  EXPECT_CALL(*mock_socket_operations_, write(1, _, _)).WillOnce(Return(-1));\n\n  bool res = x_protocol_->send_error(1, 55, \"Error message\", \"SQL_STATE\",\n                                     \"routing configuration name\");\n\n  ASSERT_FALSE(res);\n}\n\nint main(int argc, char *argv[]) {\n  init_test_logger();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n\n"
  },
  {
    "path": "src/syslog/CMakeLists.txt",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nIF(NOT WIN32)\n  add_harness_plugin(syslog SOURCES src/syslog.cc)\nENDIF()\n"
  },
  {
    "path": "src/syslog/src/syslog.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql/harness/logging/handler.h\"\n#include \"mysql/harness/logging/registry.h\"\n#include \"mysql/harness/plugin.h\"\n\n#include <cstdarg>\n\n#include <syslog.h>\n\nusing mysql_harness::ARCHITECTURE_DESCRIPTOR;\nusing mysql_harness::AppInfo;\nusing mysql_harness::PLUGIN_ABI_VERSION;\nusing mysql_harness::Plugin;\nusing mysql_harness::logging::LogLevel;\n\nclass SyslogHandler final : public mysql_harness::logging::Handler {\n public:\n  static constexpr const char* kDefaultName = \"syslog\";\n\n  SyslogHandler(bool format_messages = true, LogLevel level = LogLevel::kNotSet)\n      : mysql_harness::logging::Handler(format_messages, level) {}\n  ~SyslogHandler() { close(); }\n\n  void open(const std::string& ident) {\n    openlog(ident.c_str(), LOG_CONS | LOG_NDELAY, LOG_DAEMON);\n  }\n\n  void close() {\n    closelog();\n  }\n\n private:\n  void do_log(const mysql_harness::logging::Record& record) override {\n    syslog(static_cast<int>(record.level), \"%s\", record.message.c_str());\n  }\n};\n\nstd::shared_ptr<SyslogHandler> g_syslog_handler =\n    std::make_shared<SyslogHandler>();\n\nstatic void init(mysql_harness::PluginFuncEnv* env) {\n  const AppInfo* info = get_app_info(env);\n  using mysql_harness::logging::register_handler;\n\n  g_syslog_handler->open(info->program);\n  register_handler(SyslogHandler::kDefaultName, g_syslog_handler);\n}\n\nstatic void deinit(mysql_harness::PluginFuncEnv*) {\n  g_syslog_handler->close();\n}\n\nextern \"C\" {\n  Plugin harness_plugin_syslog = {\n    PLUGIN_ABI_VERSION,\n    ARCHITECTURE_DESCRIPTOR,\n    \"Logging using syslog\",\n    VERSION_NUMBER(0, 0, 1),\n    0, nullptr,  // Requires\n    0, nullptr,  // Conflicts\n    init,\n    deinit,\n    nullptr,  // start\n    nullptr,  // stop\n  };\n}\n"
  },
  {
    "path": "src/x_protocol/CMakeLists.txt",
    "content": "# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\ninclude_directories(${PROTOBUF_INCLUDE_DIRS}\n  \"${CMAKE_CURRENT_SOURCE_DIR}/include/mysqlrouter\"\n)\ninclude(${PROJECT_SOURCE_DIR}/cmake/mysqlx_protobuf.cmake)\ninclude(CheckCXXCompilerFlag)\n\nset(PROTOBUF_MYSQLX_FILES\n  \"${PROTOBUF_MYSQLX_DIR}/mysqlx.proto\"\n  \"${PROTOBUF_MYSQLX_DIR}/mysqlx_datatypes.proto\"\n  \"${PROTOBUF_MYSQLX_DIR}/mysqlx_connection.proto\"\n  \"${PROTOBUF_MYSQLX_DIR}/mysqlx_expect.proto\"\n  \"${PROTOBUF_MYSQLX_DIR}/mysqlx_expr.proto\"\n  \"${PROTOBUF_MYSQLX_DIR}/mysqlx_crud.proto\"\n  \"${PROTOBUF_MYSQLX_DIR}/mysqlx_sql.proto\"\n  \"${PROTOBUF_MYSQLX_DIR}/mysqlx_session.proto\"\n  \"${PROTOBUF_MYSQLX_DIR}/mysqlx_notice.proto\"\n  \"${PROTOBUF_MYSQLX_DIR}/mysqlx_resultset.proto\"\n)\n\nmysqlx_protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTOBUF_MYSQLX_FILES})\n\ncheck_cxx_compiler_flag(\"-Wignored-qualifiers\" HAVE_NO_IGNORED_QUALIFIERS)\nif(HAVE_NO_IGNORED_QUALIFIERS)\n  add_compile_flags(${PROTO_SRCS} COMPILE_FLAGS\n    \"-Wno-ignored-qualifiers\")\nendif()\n\ncheck_cxx_compiler_flag(\"-Wsign-compare\" CXX_HAVE_SIGN_COMPARE)\nif(CXX_HAVE_SIGN_COMPARE)\n  add_compile_flags(${PROTO_SRCS} COMPILE_FLAGS\n    \"-Wno-sign-compare\")\nENDIF()\n\ncheck_cxx_compiler_flag(\"-Wshadow\" CXX_HAVE_SHADOW)\nif(CXX_HAVE_SHADOW)\n  add_compile_flags(${PROTO_SRCS} COMPILE_FLAGS\n    \"-Wno-shadow\")\nendif()\n\ncheck_cxx_compiler_flag(\"-Wpedantic\" CXX_HAVE_PEDANTIC)\nif(CXX_HAVE_PEDANTIC)\n  add_compile_flags(${PROTO_SRCS} COMPILE_FLAGS\n    \"-Wno-pedantic\")\nendif()\n\ncheck_cxx_compiler_flag(\"-Wconversion\" CXX_HAVE_CONVERSION)\nif(CXX_HAVE_CONVERSION)\n  add_compile_flags(${PROTO_SRCS} COMPILE_FLAGS\n    \"-Wno-conversion\")\nendif()\n\ncheck_cxx_compiler_flag(\"-Wunused-parameter\" CXX_HAVE_UNUSED_PARAMETER)\nif(CXX_HAVE_UNUSED_PARAMETER)\n  add_compile_flags(${PROTO_SRCS} COMPILE_FLAGS\n    \"-Wno-unused-parameter\")\nendif()\n\ncheck_cxx_compiler_flag(\"-Wdeprecated-declarations\" CXX_HAVE_DEPRECATED_DECLARATIONS)\nif(CXX_HAVE_DEPRECATED_DECLARATIONS)\n  add_compile_flags(${PROTO_SRCS} COMPILE_FLAGS\n    \"-Wno-deprecated-declarations\")\nendif()\n\nif(MSVC)\n  add_compile_flags(${PROTO_SRCS} COMPILE_FLAGS \"/wd4018\")\n  add_compile_flags(${PROTO_SRCS} COMPILE_FLAGS \"/DX_PROTOCOL_DEFINE_DYNAMIC\" \"/DX_PROTOCOL_EXPORTS\"\n                                                \"/FIxprotocol.h\")\nelse()\n  add_compile_flags(${PROTO_SRCS} COMPILE_FLAGS \"-include xprotocol.h\")\nendif(MSVC)\n\nset(SOURCE_FILES ${PROTO_SRCS} ${PROTO_HDRS})\n\nset(include_dirs\n  ../src/router/include\n  #include\n  \"${PROJECT_BINARY_DIR}/generated/protobuf\"\n  )\n\n# link_directories(${PROJECT_BINARY_DIR}/ext/protobuf/protobuf-3.0.0/cmake/)\nadd_harness_plugin(x_protocol\n  SOURCES ${SOURCE_FILES}\n  REQUIRES router_lib)\ntarget_include_directories(x_protocol PRIVATE ${include_dirs})\n\ntarget_link_libraries(x_protocol PUBLIC ${PROTOBUF_LIBRARY})\n\n\n# don't install headers until a) a final destination is found and b) API is stable\n# file(GLOB xprotocol_headers \"${PROJECT_BINARY_DIR}/generated/protobuf/*.h\")\n# install(FILES ${xprotocol_headers}\n#   DESTINATION \"include/${HARNESS_NAME}/x_protocol\")\n\n#if(ENABLE_TESTS)\n  #add_subdirectory(tests/)\n#endif()\n"
  },
  {
    "path": "src/x_protocol/include/mysqlrouter/xprotocol.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_XPROTOCOL_DEF_INCLUDED\n#define MYSQLROUTER_XPROTOCOL_DEF_INCLUDED\n\n#ifdef _WIN32\n#  ifdef X_PROTOCOL_DEFINE_DYNAMIC\n#    ifdef X_PROTOCOL_EXPORTS\n#      define X_PROTOCOL_API __declspec(dllexport)\n#    else\n#      define X_PROTOCOL_API __declspec(dllimport)\n#    endif\n#  else\n#    define X_PROTOCOL_API\n#  endif\n#else\n#  define X_PROTOCOL_API\n#endif\n\n#endif // MYSQLROUTER_XPROTOCOL_DEF_INCLUDED\n"
  },
  {
    "path": "src/x_protocol/proto/mysqlx.proto",
    "content": "/*\n * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License, version 2.0,\n * as published by the Free Software Foundation.\n *\n * This program is also distributed with certain software (including\n * but not limited to OpenSSL) that is licensed under separate terms,\n * as designated in a particular file or component or in included license\n * documentation.  The authors of MySQL hereby grant you an additional\n * permission to link the program and your derivative works with the\n * separately licensed software that they have included with MySQL.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n */\n\n// tell protobuf 3.0 to use protobuf 2.x rules\nsyntax = \"proto2\";\n\n// ifdef PROTOBUF_LITE: option optimize_for = LITE_RUNTIME;\n\npackage Mysqlx;\noption java_package = \"com.mysql.cj.mysqlx.protobuf\";\n\nimport \"mysqlx_sql.proto\";\nimport \"mysqlx_resultset.proto\";\nimport \"mysqlx_crud.proto\";\nimport \"mysqlx_session.proto\";\nimport \"mysqlx_connection.proto\";\nimport \"mysqlx_expect.proto\";\nimport \"mysqlx_notice.proto\";\n\n// style-guide:\n//\n// see https://developers.google.com/protocol-buffers/docs/style\n//\n// message CamelCaseMsg {\n//   enum CamelCaseEnum {\n//     FIRST_VALUE = 1;\n//   }\n//   required CamelCaseEnum some_enum = 1;\n// }\n//\n\n\n// IDs of messages that can be sent from client to the server\n//\n// .. note::\n//   this message is never sent on the wire. It is only used to let ``protoc``\n//\n//   * generate constants\n//   * check for uniqueness\nmessage ClientMessages {\n  enum Type {\n    CON_CAPABILITIES_GET = 1;\n    CON_CAPABILITIES_SET = 2;\n    CON_CLOSE = 3;\n\n    SESS_AUTHENTICATE_START = 4;\n    SESS_AUTHENTICATE_CONTINUE  = 5;\n    SESS_RESET = 6;\n    SESS_CLOSE = 7;\n\n    SQL_STMT_EXECUTE = 12;\n\n    CRUD_FIND = 17;\n    CRUD_INSERT = 18;\n    CRUD_UPDATE = 19;\n    CRUD_DELETE = 20;\n\n    EXPECT_OPEN = 24;\n    EXPECT_CLOSE = 25;\n  }\n}\n\n// IDs of messages that can be sent from server to client\n//\n// .. note::\n//   this message is never sent on the wire. It is only used to let ``protoc``\n//\n//   * generate constants\n//   * check for uniqueness\nmessage ServerMessages {\n  enum Type {\n    OK = 0;\n    ERROR = 1;\n\n    CONN_CAPABILITIES = 2;\n\n    SESS_AUTHENTICATE_CONTINUE = 3;\n    SESS_AUTHENTICATE_OK = 4;\n\n    // NOTICE has to stay at 11 forever\n    NOTICE = 11;\n\n    RESULTSET_COLUMN_META_DATA = 12;\n    RESULTSET_ROW = 13;\n    RESULTSET_FETCH_DONE = 14;\n    RESULTSET_FETCH_SUSPENDED = 15;\n    RESULTSET_FETCH_DONE_MORE_RESULTSETS = 16;\n\n    SQL_STMT_EXECUTE_OK = 17;\n    RESULTSET_FETCH_DONE_MORE_OUT_PARAMS = 18;\n  };\n}\n\n\n// generic Ok message\nmessage Ok {\n  optional string msg = 1;\n}\n\n\n// generic Error message\n//\n// A ``severity`` of ``ERROR`` indicates the current message sequence is\n// aborted for the given error and the session is ready for more.\n//\n// In case of a ``FATAL`` error message the client should not expect\n// the server to continue handling any further messages and should\n// close the connection.\n//\n// :param severity: severity of the error message\n// :param code: error-code\n// :param sql_state: SQL state\n// :param msg: human readable error message\nmessage Error {\n  optional Severity severity = 1 [ default = ERROR ];\n  required uint32 code = 2;\n  required string sql_state = 4;\n  required string msg = 3;\n\n  enum Severity {\n    ERROR = 0;\n    FATAL = 1;\n  };\n}\n"
  },
  {
    "path": "src/x_protocol/proto/mysqlx_connection.proto",
    "content": "/*\n * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License, version 2.0,\n * as published by the Free Software Foundation.\n *\n * This program is also distributed with certain software (including\n * but not limited to OpenSSL) that is licensed under separate terms,\n * as designated in a particular file or component or in included license\n * documentation.  The authors of MySQL hereby grant you an additional\n * permission to link the program and your derivative works with the\n * separately licensed software that they have included with MySQL.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n */\nsyntax = \"proto2\";\n\n// ifdef PROTOBUF_LITE: option optimize_for = LITE_RUNTIME;\n\nimport \"mysqlx_datatypes.proto\";\n\npackage Mysqlx.Connection;\noption java_package = \"com.mysql.cj.mysqlx.protobuf\";\n\n// a Capability\n//\n// a tuple of a ``name`` and a :protobuf:msg:`Mysqlx.Datatypes::Any`\nmessage Capability {\n  required string name = 1;\n  required Mysqlx.Datatypes.Any value = 2;\n}\n\n// Capabilities\nmessage Capabilities {\n  repeated Capability capabilities = 1;\n}\n\n// get supported connection capabilities and their current state\n//\n//   :returns: :protobuf:msg:`Mysqlx.Connection::Capabilities` or :protobuf:msg:`Mysqlx::Error`\n//\nmessage CapabilitiesGet {\n};\n\n// sets connection capabilities atomically\n//\n// only provided values are changed, other values are left unchanged.\n// If any of the changes fails, all changes are discarded.\n//\n// :precond: active sessions == 0\n// :returns: :protobuf:msg:`Mysqlx::Ok` or :protobuf:msg:`Mysqlx::Error`\nmessage CapabilitiesSet {\n  required Capabilities capabilities = 1;\n};\n\n// announce to the server that the client wants to close the connection\n//\n// it discards any session state of the server\n//\n// :Returns: :protobuf:msg:`Mysqlx::Ok`\nmessage Close {\n};\n\n"
  },
  {
    "path": "src/x_protocol/proto/mysqlx_crud.proto",
    "content": "/*\n * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License, version 2.0,\n * as published by the Free Software Foundation.\n *\n * This program is also distributed with certain software (including\n * but not limited to OpenSSL) that is licensed under separate terms,\n * as designated in a particular file or component or in included license\n * documentation.  The authors of MySQL hereby grant you an additional\n * permission to link the program and your derivative works with the\n * separately licensed software that they have included with MySQL.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n */\nsyntax = \"proto2\";\n\n// ifdef PROTOBUF_LITE: option optimize_for = LITE_RUNTIME;\n\n// Basic CRUD operations\npackage Mysqlx.Crud;\noption java_package = \"com.mysql.cj.mysqlx.protobuf\";\n\nimport \"mysqlx_expr.proto\";\nimport \"mysqlx_datatypes.proto\";\n\n// column definition\nmessage Column {\n  optional string name = 1;\n  optional string alias = 2;\n  repeated Mysqlx.Expr.DocumentPathItem document_path = 3;\n}\n\n// a projection\n//\n// :param source: the expression identifying an element from the source data\n//                which can include a column identifier or any expression\n// :param alias: optional alias. Required for DOCUMENTs (clients may use \n//              the source string as default)\nmessage Projection {\n    required Mysqlx.Expr.Expr source = 1;\n    optional string alias = 2;\n}\n\n// DataModel to use for filters, names, ...\nenum DataModel {\n  DOCUMENT = 1;\n  TABLE = 2;\n};\n\n// collection\nmessage Collection {\n  required string name = 1;\n  optional string schema = 2;\n}\n\n// limit\n//\n// :param row_count: maximum rows to filter\n// :param offset: maximum rows to skip before applying the row_count\nmessage Limit {\n  required uint64 row_count = 1;\n  optional uint64 offset = 2;\n}\n\n// sort order\nmessage Order {\n  enum Direction {\n    ASC = 1;\n    DESC = 2;\n  };\n\n  required Mysqlx.Expr.Expr expr = 1;\n  optional Direction direction = 2 [ default=ASC ];\n}\n\n// update operations\n//\n// :param source: specification of the value to be updated\n//      if data_model is TABLE, a column name may be specified and also a document path, if the column has type JSON\n//      if data_model is DOCUMENT, only document paths are allowed\n//      in both cases, schema and table must be not set\n// :param operation: the type of operation to be performed\n// :param value: an expression to be computed as the new value for the operation\nmessage UpdateOperation {\n  enum UpdateType {\n    SET = 1;            // only allowed for TABLE\n    ITEM_REMOVE = 2;    // no value (removes the identified path from a object or array)\n    ITEM_SET = 3;       // sets the new value on the identified path\n    ITEM_REPLACE = 4;   // replaces a value if the path exists\n    ITEM_MERGE = 5;     // source and value must be documents\n    ARRAY_INSERT = 6;   // insert the value in the array at the index identified in the source path\n    ARRAY_APPEND = 7;   // append the value on the array at the identified path\n  }\n  required Mysqlx.Expr.ColumnIdentifier source = 1;\n  required UpdateType operation = 2;\n  optional Mysqlx.Expr.Expr value = 3;\n}\n\n// Find Documents/Rows in a Collection/Table\n//\n// .. uml::\n//\n//   client -> server: Find\n//   ... one or more Resultset ...\n//\n// :param collection: collection to insert into\n// :param data_model: datamodel that the operations refer to\n// :param projection: list of column projections that shall be returned\n// :param args: values for parameters used in filter expression\n// :param criteria: filter criteria\n// :param limit: numbers of rows that shall be skipped and returned\n// :param order: sort-order in which the rows/document shall be returned in\n// :param grouping: column expression list for aggregation (GROUP BY)\n// :param grouping_criteria: filter criteria for aggregated groups\n// :Returns: :protobuf:msg:`Mysqlx.Resultset::`\nmessage Find {\n  required Collection collection = 2;\n\n  optional DataModel data_model = 3;\n  repeated Projection projection = 4;\n  optional Mysqlx.Expr.Expr criteria = 5;\n  repeated Mysqlx.Datatypes.Scalar args = 11;\n  optional Limit limit = 6;\n  repeated Order order = 7;\n  repeated Mysqlx.Expr.Expr grouping = 8;\n  optional Mysqlx.Expr.Expr grouping_criteria = 9;\n};\n\n// Insert documents/rows into a collection/table\n//\n// :param collection: collection to insert into\n// :param data_model: datamodel that the operations refer to\n// :param projection: name of the columns to insert data into (empty if data_model is DOCUMENT)\n// :param row: set of rows to insert into the collection/table (a single expression with a JSON document literal or an OBJECT expression)\n// :param args: values for parameters used in row expressions\n// :Returns: :protobuf:msg:`Mysqlx.Resultset::`\nmessage Insert {\n  required Collection collection = 1;\n\n  optional DataModel data_model = 2;\n  repeated Column projection = 3;\n\n  message TypedRow {\n    repeated Mysqlx.Expr.Expr field = 1;\n  };\n  repeated TypedRow row = 4;\n  repeated Mysqlx.Datatypes.Scalar args = 5; \n};\n\n// Update documents/rows in a collection/table\n//\n// :param collection: collection to change\n// :param data_model: datamodel that the operations refer to\n// :param criteria: filter expression to match rows that the operations will apply on\n// :param args: values for parameters used in filter expression\n// :param limit: limits the number of rows to match\n// :param order: specifies order of matched rows\n// :param operation: list of operations to be applied. Valid operations will depend on the data_model.\n// :Returns: :protobuf:msg:`Mysqlx.Resultset::`\nmessage Update {\n  required Collection collection = 2;\n\n  optional DataModel data_model = 3;\n  optional Mysqlx.Expr.Expr criteria = 4;\n  repeated Mysqlx.Datatypes.Scalar args = 8;\n  optional Limit limit = 5;\n  repeated Order order = 6;\n\n  repeated UpdateOperation operation = 7;\n};\n\n// Delete documents/rows from a Collection/Table\n//\n// :param collection: collection to change\n// :param data_model: datamodel that the operations refer to\n// :param criteria: filter expression to match rows that the operations will apply on\n// :param args: values for parameters used in filter expression\n// :param limit: limits the number of rows to match\n// :param order: specifies order of matched rows\n// :Returns: :protobuf:msg:`Mysqlx.Resultset::`\nmessage Delete {\n  required Collection collection = 1;\n\n  optional DataModel data_model = 2;\n  optional Mysqlx.Expr.Expr criteria = 3;\n  repeated Mysqlx.Datatypes.Scalar args = 6;\n  optional Limit limit = 4;\n  repeated Order order = 5;\n};\n\n"
  },
  {
    "path": "src/x_protocol/proto/mysqlx_datatypes.proto",
    "content": "/*\n * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License, version 2.0,\n * as published by the Free Software Foundation.\n *\n * This program is also distributed with certain software (including\n * but not limited to OpenSSL) that is licensed under separate terms,\n * as designated in a particular file or component or in included license\n * documentation.  The authors of MySQL hereby grant you an additional\n * permission to link the program and your derivative works with the\n * separately licensed software that they have included with MySQL.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n */\nsyntax = \"proto2\";\n\n// ifdef PROTOBUF_LITE: option optimize_for = LITE_RUNTIME;\n\npackage Mysqlx.Datatypes;\noption java_package = \"com.mysql.cj.mysqlx.protobuf\";\n\n\n// a scalar\nmessage Scalar {\n  // a string with a charset/collation\n  message String {\n    required bytes value = 1;\n    optional uint64 collation = 2;\n  };\n \n// an opaque octet sequence, with an optional content_type\n// See ``Mysqlx.Resultset.ColumnMetadata`` for list of known values.\nmessage Octets {\n  required bytes value = 1;\n  optional uint32 content_type = 2;\n};\n  \n  enum Type {\n    V_SINT = 1;\n    V_UINT = 2;\n    V_NULL = 3;\n    V_OCTETS = 4;\n    V_DOUBLE = 5;\n    V_FLOAT = 6;\n    V_BOOL  = 7;\n    V_STRING  = 8;\n  };\n\n  required Type type = 1;\n\n  optional sint64 v_signed_int = 2;\n  optional uint64 v_unsigned_int = 3;\n  // 4 is unused, was Null which doesn't have a storage anymore\n  optional Octets v_octets = 5;\n  optional double v_double = 6;\n  optional float  v_float = 7;\n  optional bool   v_bool = 8;\n  optional String v_string = 9;\n}\n\n// a object\nmessage Object {\n  message ObjectField {\n    required string key = 1;\n    required Any value = 2;\n  }\n\n  repeated ObjectField fld = 1;\n}\n\n// a Array\nmessage Array {\n  repeated Any value = 1;\n}\n\n// a helper to allow all field types\nmessage Any {\n  enum Type {\n    SCALAR = 1;\n    OBJECT = 2;\n    ARRAY  = 3;\n  };\n\n  required Type type = 1;\n\n  optional Scalar scalar = 2;\n  optional Object obj    = 3;\n  optional Array  array  = 4;\n}\n\n"
  },
  {
    "path": "src/x_protocol/proto/mysqlx_expect.proto",
    "content": "/*\n * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License, version 2.0,\n * as published by the Free Software Foundation.\n *\n * This program is also distributed with certain software (including\n * but not limited to OpenSSL) that is licensed under separate terms,\n * as designated in a particular file or component or in included license\n * documentation.  The authors of MySQL hereby grant you an additional\n * permission to link the program and your derivative works with the\n * separately licensed software that they have included with MySQL.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n */\nsyntax = \"proto2\";\n\n// ifdef PROTOBUF_LITE: option optimize_for = LITE_RUNTIME;\n\n// Expect operations\npackage Mysqlx.Expect;\noption java_package = \"com.mysql.cj.mysqlx.protobuf\";\n\n// Pipelining messages is a core feature of the Mysqlx Protocol. It\n// sends messages to the server without waiting for a response to\n// save latency.\n//\n// * in case of success the time to wait and check the result as been saved\n//   and the latency is reduced.\n//\n// * in the case of an error a mechanism is need to ensure that the following\n//   messages are not executed, but skipped with an error instead.\n//\n// ::\n//\n//   Mysqlx.Crud::PrepareFind(stmt_id=1,...)\n//   Mysqlx.Expect::Open([no_error]) // if a execute fails\n//   Mysqlx.PreparedStmt::Execute(stmt_id=1,...)\n//   Mysqlx.PreparedStmt::Execute(stmt_id=1,...)\n//   Mysqlx.Expect::Close()\n//   Mysqlx.PreparedStmt::Close(stmt_id=1,...)\n//\n// This basic mechanism is extended to carry a arbitrary set of conditions that are\n// checked before executing message:\n//\n// ::\n//\n//   Mysqlx.Expect::Open([+no_error, +gtid_executed_contains = \"...\", +max_stmt_exec_time_ms = 10])\n//\n//   Mysqlx.Expect::Close()\n//\n// Expect blocks can be nested to increase/change the restrictions for a subset of the\n// messages. At the end of the Expect block the previous restrictions are restored.\n//\n// ::\n//\n//   Mysqlx.Expect::Open([+no_error]) // if preparing the Find fails, don't try to close it\n//   Mysqlx.Crud::PrepareFind(stmt_id=1,...)\n//   Mysqlx.Expect::Open([+no_error]) // if a Execute fails, skip the rest of them and continue with Close\n//   Mysqlx.PreparedStmt::Execute(stmt_id=1,...)\n//   Mysqlx.PreparedStmt::Execute(stmt_id=1,...)\n//   Mysqlx.Expect::Close()\n//   Mysqlx.PreparedStmt::Close(stmt_id=1,...)\n//   Mysqlx.Expect::Close()\n\n// open an Expect block and set/unset the conditions that have to be fulfilled\n//\n// if any of the conditions fail, all enclosed messages will fail with\n// a Mysqlx.Error message.\n//\n// :returns: :protobuf:msg:`Mysqlx::Ok` on success, :protobuf:msg:`Mysqlx::Error` on error\n//\nmessage Open {\n  message Condition {\n    enum ConditionOperation {\n      // set the condition\n      //\n      // set, if not set\n      // overwrite, if set\n      EXPECT_OP_SET = 0;\n      // unset the condition\n      EXPECT_OP_UNSET = 1;\n    };\n    required uint32 condition_key = 1;\n    optional bytes condition_value = 2;\n    optional ConditionOperation op = 3 [ default = EXPECT_OP_SET ];\n  };\n  enum CtxOperation {\n    // copy the operations from the parent Expect-block\n    EXPECT_CTX_COPY_PREV = 0;\n    // start with a empty set of operations\n    EXPECT_CTX_EMPTY = 1;\n  };\n  optional CtxOperation op = 1 [ default = EXPECT_CTX_COPY_PREV ];\n  repeated Condition cond = 2;\n}\n\n// close a Expect block\n//\n// closing a Expect block restores the state of the previous Expect block\n// for the following messages\n//\n// :returns: :protobuf:msg:`Mysqlx::Ok` on success, :protobuf:msg:`Mysqlx::Error` on error\nmessage Close {\n}\n\n"
  },
  {
    "path": "src/x_protocol/proto/mysqlx_expr.proto",
    "content": "/*\n * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License, version 2.0,\n * as published by the Free Software Foundation.\n *\n * This program is also distributed with certain software (including\n * but not limited to OpenSSL) that is licensed under separate terms,\n * as designated in a particular file or component or in included license\n * documentation.  The authors of MySQL hereby grant you an additional\n * permission to link the program and your derivative works with the\n * separately licensed software that they have included with MySQL.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n */\nsyntax = \"proto2\";\n\n// ifdef PROTOBUF_LITE: option optimize_for = LITE_RUNTIME;\n\n// Expression syntax\n//\n// expr is the fundamental structure in various places\n// of the SQL language:\n//\n// * ``SELECT <expr> AS ...``\n// * ``WHERE <expr>``\n//\n// The structures can be used to:\n//\n// * build an Item-tree in the MySQL Server\n// * generate SQL from it\n// * use as filter condition in CRUD's Find(), Update() and Delete() calls.\npackage Mysqlx.Expr;\noption java_package = \"com.mysql.cj.mysqlx.protobuf\";\n\nimport \"mysqlx_datatypes.proto\";\n\n// Expressions\n//\n// the \"root\" of the expression tree\n//\n// .. productionlist::\n//   expr: `operator` |\n//       : `identifier` |\n//       : `function_call` |\n//       : variable |\n//       : `literal` |\n//       : placeholder\n//\n// If expression type is PLACEHOLDER then it refers to the value of a parameter\n// specified when executing a statement (see `args` field of `StmtExecute` command).\n// Field `position` (which must be present for such an expression) gives 0-based\n// position of the parameter in the parameter list.\n//\nmessage Expr {\n  enum Type {\n    IDENT          = 1;\n    LITERAL        = 2;\n    VARIABLE       = 3;\n    FUNC_CALL      = 4;\n    OPERATOR       = 5;\n    PLACEHOLDER    = 6;\n    OBJECT         = 7;\n    ARRAY          = 8;\n  };\n\n  required Type type = 1;\n\n  optional ColumnIdentifier identifier = 2;\n  optional string       variable = 3;\n  optional Mysqlx.Datatypes.Scalar literal = 4;\n  optional FunctionCall function_call = 5;\n  optional Operator     operator = 6;\n  optional uint32       position = 7;\n  optional Object       object = 8;\n  optional Array        array = 9;\n}\n\n// identifier: name, schame.name\n//\n// .. productionlist::\n//   identifier: string \".\" string |\n//             : string\nmessage Identifier {\n  required string name = 1;\n  optional string schema_name = 2;\n}\n\n// DocumentPathItem\n//\n// .. productionlist::\n//    document_path: path_item | path_item document_path\n//    path_item    : member | array_index | \"**\"\n//    member       : \".\" string | \".\" \"*\"\n//    array_index  : \"[\" number \"]\" | \"[\" \"*\" \"]\"\n//\nmessage DocumentPathItem {\n  enum Type {\n    MEMBER = 1;             // .member\n    MEMBER_ASTERISK = 2;    // .*\n    ARRAY_INDEX = 3;        // [index]\n    ARRAY_INDEX_ASTERISK = 4; // [*]\n    DOUBLE_ASTERISK = 5;    // **\n  };\n  required Type type = 1;\n  optional string value = 2;\n  optional uint32 index = 3;\n}\n\n\n// col_identifier (table): col@doc_path, tbl.col@doc_path col, tbl.col, schema.tbl.col\n// col_identifier (document): doc_path\n//\n// .. productionlist::\n//   col_identifier: string \".\" string \".\" string |\n//             : string \".\" string |\n//             : string |\n//             : string \".\" string \".\" string \"@\" document_path |\n//             : string \".\" string \"@\" document_path |\n//             : string \"@\" document_path |\n//             : document_path\n//    document_path: member | arrayLocation | doubleAsterisk\n//    member = \".\" string | \".\" \"*\"\n//    arrayLocation = \"[\" index \"]\" | \"[\" \"*\" \"]\"\n//    doubleAsterisk = \"**\"\n//\nmessage ColumnIdentifier {\n  repeated Mysqlx.Expr.DocumentPathItem document_path = 1;\n  optional string name = 2;\n  optional string table_name = 3;\n  optional string schema_name = 4;\n}\n\n// function call: ``func(a, b, \"1\", 3)``\n//\n// .. productionlist::\n//   function_call: `identifier` \"(\" [ `expr` [\",\" `expr` ]* ] \")\"\nmessage FunctionCall {\n  required Identifier name = 1;\n  repeated Expr param = 2;\n}\n\n// operator: ``<<(a, b)``\n//\n// .. note::\n//\n//   Non-authoritative list of operators implemented (case sensitive):\n//\n//   Nullary\n//     * ``*``\n//     * ``default``\n//\n//   Unary\n//     * ``!``\n//     * ``sign_plus``\n//     * ``sign_minus``\n//     * ``~``\n//\n//   Binary\n//     * ``&&``\n//     * ``||``\n//     * ``xor``\n//     * ``==``\n//     * ``!=``\n//     * ``>``\n//     * ``>=``\n//     * ``<``\n//     * ``<=``\n//     * ``&``\n//     * ``|``\n//     * ``^``\n//     * ``<<``\n//     * ``>>``\n//     * ``+``\n//     * ``-``\n//     * ``*``\n//     * ``/``\n//     * ``div``\n//     * ``%``\n//     * ``is``\n//     * ``is_not``\n//     * ``regexp``\n//     * ``not_regexp``\n//     * ``like``\n//     * ``not_like``\n//     * ``cast``\n//\n//   Using special representation, with more than 2 params\n//     * ``in`` (param[0] IN (param[1], param[2], ...))\n//     * ``not_in`` (param[0] NOT IN (param[1], param[2], ...))\n//\n//   Ternary\n//     * ``between``\n//     * ``between_not``\n//     * ``date_add``\n//     * ``date_sub``\n//\n//   Units for date_add/date_sub\n//     * ``MICROSECOND``\n//     * ``SECOND``\n//     * ``MINUTE``\n//     * ``HOUR``\n//     * ``DAY``\n//     * ``WEEK``\n//     * ``MONTH``\n//     * ``QUARTER``\n//     * ``YEAR``\n//     * ``SECOND_MICROSECOND``\n//     * ``MINUTE_MICROSECOND``\n//     * ``MINUTE_SECOND``\n//     * ``HOUR_MICROSECOND``\n//     * ``HOUR_SECOND``\n//     * ``HOUR_MINUTE``\n//     * ``DAY_MICROSECOND``\n//     * ``DAY_SECOND``\n//     * ``DAY_MINUTE``\n//     * ``DAY_HOUR``\n//\n//   Types for cast\n//     * ``BINARY[(N)]``\n//     * ``CHAR[(N)]``\n//     * ``DATE``\n//     * ``DATETIME``\n//     * ``DECIMAL[(M[,D])]``\n//     * ``JSON``\n//     * ``SIGNED [INTEGER]``\n//     * ``TIME``\n//     * ``UNSIGNED [INTEGER]``\n//\n// .. productionlist::\n//   operator: `name` \"(\" [ `expr` [\",\" `expr` ]* ] \")\"\nmessage Operator {\n  required string name = 1;\n  repeated Expr param = 2;\n}\n\n// an object (with expression values)\nmessage Object {\n  message ObjectField {\n    required string key = 1;\n    required Expr value = 2;\n  }\n\n  repeated ObjectField fld = 1;\n}\n\n// a Array of expressions\nmessage Array {\n  repeated Expr value = 1;\n}\n"
  },
  {
    "path": "src/x_protocol/proto/mysqlx_notice.proto",
    "content": "/*\n * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License, version 2.0,\n * as published by the Free Software Foundation.\n *\n * This program is also distributed with certain software (including\n * but not limited to OpenSSL) that is licensed under separate terms,\n * as designated in a particular file or component or in included license\n * documentation.  The authors of MySQL hereby grant you an additional\n * permission to link the program and your derivative works with the\n * separately licensed software that they have included with MySQL.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n */\n\n// tell protobuf 3.0 to use protobuf 2.x rules\nsyntax = \"proto2\";\n\n// ifdef PROTOBUF_LITE: option optimize_for = LITE_RUNTIME;\n\n// Notices\n//\n// A notice\n//\n// * is sent from the server to the client\n// * may be global or relate to the current message sequence\npackage Mysqlx.Notice;\noption java_package = \"com.mysql.cj.mysqlx.protobuf\";\n\nimport \"mysqlx_datatypes.proto\";\n\n// Common Frame for all Notices\n//\n// ===================================================== =====\n// .type                                                 value\n// ===================================================== =====\n// :protobuf:msg:`Mysqlx.Notice::Warning`                1\n// :protobuf:msg:`Mysqlx.Notice::SessionVariableChanged` 2\n// :protobuf:msg:`Mysqlx.Notice::SessionStateChanged`    3\n// ===================================================== =====\n//\n// :param type: the type of the payload\n// :param payload: the payload of the notification\n// :param scope: global or local notification\n//\nmessage Frame {\n  enum Scope {\n    GLOBAL = 1;\n    LOCAL = 2;\n  };\n  required uint32 type = 1;\n  optional Scope  scope = 2 [ default = GLOBAL ];\n  optional bytes payload = 3;\n}\n\n// Server-side warnings and notes\n//\n// ``.scope`` == ``local``\n//   ``.level``, ``.code`` and ``.msg`` map the content of\n//\n//   .. code-block:: sql\n//\n//     SHOW WARNINGS\n//\n// ``.scope`` == ``global``\n//   (undefined) will be used for global, unstructured messages like:\n//\n//   * server is shutting down\n//   * a node disconnected from group\n//   * schema or table dropped\n//\n// ========================================== =======================\n// :protobuf:msg:`Mysqlx.Notice::Frame` field value\n// ========================================== =======================\n// ``.type``                                  1\n// ``.scope``                                 ``local`` or ``global``\n// ========================================== =======================\n//\n// :param level: warning level: Note or Warning\n// :param code: warning code\n// :param msg: warning message\nmessage Warning {\n  enum Level {\n    NOTE = 1;\n    WARNING = 2;\n    ERROR = 3;\n  };\n  optional Level  level = 1 [ default = WARNING ];\n  required uint32 code = 2;\n  required string msg = 3;\n}\n\n// Notify clients about changes to the current session variables\n//\n// Every change to a variable that is accessable through:\n//\n// .. code-block:: sql\n//\n//   SHOW SESSION VARIABLES\n//\n// ========================================== =========\n// :protobuf:msg:`Mysqlx.Notice::Frame` field value\n// ========================================== =========\n// ``.type``                                  2\n// ``.scope``                                 ``local``\n// ========================================== =========\n//\n// :param namespace: namespace that param belongs to\n// :param param: name of the variable\n// :param value: the changed value of param\nmessage SessionVariableChanged {\n  required string param = 1;\n  optional Mysqlx.Datatypes.Scalar value = 2;\n}\n\n\n// Notify clients about changes to the internal session state\n//\n// ========================================== =========\n// :protobuf:msg:`Mysqlx.Notice::Frame` field value\n// ========================================== =========\n// ``.type``                                  3\n// ``.scope``                                 ``local``\n// ========================================== =========\n//\n// :param param: parameter key\n// :param value: updated value\nmessage SessionStateChanged {\n  enum Parameter {\n     CURRENT_SCHEMA = 1;\n     ACCOUNT_EXPIRED = 2;\n     GENERATED_INSERT_ID = 3;\n     ROWS_AFFECTED = 4;\n     ROWS_FOUND = 5;\n     ROWS_MATCHED = 6;\n     TRX_COMMITTED = 7;\n     TRX_ROLLEDBACK = 9;\n     PRODUCED_MESSAGE = 10;\n     CLIENT_ID_ASSIGNED = 11;\n     // .. more to be added\n  }\n  required Parameter param = 1;\n  optional Mysqlx.Datatypes.Scalar value = 2;\n}\n\n"
  },
  {
    "path": "src/x_protocol/proto/mysqlx_resultset.proto",
    "content": "/*\n * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License, version 2.0,\n * as published by the Free Software Foundation.\n *\n * This program is also distributed with certain software (including\n * but not limited to OpenSSL) that is licensed under separate terms,\n * as designated in a particular file or component or in included license\n * documentation.  The authors of MySQL hereby grant you an additional\n * permission to link the program and your derivative works with the\n * separately licensed software that they have included with MySQL.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n */\nsyntax = \"proto2\";\n\n// ifdef PROTOBUF_LITE: option optimize_for = LITE_RUNTIME;\n\n// Resultsets\n// ``````````\n//\n// Executing a statement against the server may result in zero or more\n// Resultsets followed by zero or one Resultset of the ``OUT`` parameters.\n//\n// A Resultset consists of:\n//\n// * one or more :protobuf:msg:`Mysqlx.Resultset::ColumnMetaData`\n// * zero or more :protobuf:msg:`Mysqlx.Resultset::Row`\n//\n// It is followed by:\n//\n// * a :protobuf:msg:`Mysqlx.Resultset::FetchDoneMoreResultsets` if more\n//   resultsets are following\n// * a :protobuf:msg:`Mysqlx.Resultset::FetchDoneMoreOutParams` if more\n//   Resultset of ``OUT`` parameters is following\n// * a :protobuf:msg:`Mysqlx.Resultset::FetchDone` if the last resultset\n//   was sent\n//\n// .. uml::\n//\n//   ...\n//   loop has more resultsets\n//     group resultset\n//       loop has more columns\n//         server --> client: ColumnMetaData\n//       end\n//       loop has more rows\n//         server --> client: Row\n//       end\n//     end\n//     alt has more resultsets\n//       server --> client: FetchDoneMoreResultsets\n//     end\n//   end\n//   loop has more OUT-paramsets\n//     server --> client: FetchDoneMoreOutParams\n//     group resultset\n//       loop has more columns\n//         server --> client: ColumnMetaData\n//       end\n//       loop has more rows\n//         server --> client: Row\n//       end\n//     end\n//   end\n//   server --> client: FetchDone\n//   ...\n//\n// Examples\n// ````````\n//\n// .. rubric:: No Resultset\n//\n// A ``INSERT`` statement usually doesn't send any resultset which results in only\n// a ``FetchDone``.\n//\n// .. uml::\n//\n//   server --> client: FetchDone\n//\n// .. rubric:: Empty Resultset\n//\n// ``SELECT 1 LIMIT 0`` results in a empty resultset:\n//\n// .. uml::\n//\n//   server --> client: ColumnMetaData(.name = \"1\", .type = INT)\n//   server --> client: FetchDone\n//\n// .. rubric:: Multi Resultset\n//\n// ``CALL`` may result in multiple resultsets.\n//\n// .. uml::\n//\n//   server --> client: ColumnMetaData(.name = \"1\", .type = INT)\n//   server --> client: Row\n//   server --> client: FetchDoneMoreResultsets\n//   server --> client: ColumnMetaData(.name = \"1\", .type = INT)\n//   server --> client: Row\n//   server --> client: FetchDone\n//\n// .. rubric:: OUT params\n//\n// ``CALL`` may result OUT parameters only\n//\n// .. uml::\n//\n//   server --> client: FetchDoneMoreOutParams\n//   server --> client: ColumnMetaData(.name = \"1\", .type = INT)\n//   server --> client: Row\n//   server --> client: FetchDone\n\n\n\npackage Mysqlx.Resultset;\noption java_package = \"com.mysql.cj.mysqlx.protobuf\";\n\n// resultsets are finished, OUT paramset is next\nmessage FetchDoneMoreOutParams {\n}\n\n// resultset and out-params are finished, but more resultsets available\nmessage FetchDoneMoreResultsets {\n}\n\n// all resultsets are finished\nmessage FetchDone {\n}\n\n// meta data of a Column\n//\n// .. note:: the encoding used for the different ``bytes`` fields in the meta data is externally\n//   controlled.\n//   .. seealso:: https://dev.mysql.com/doc/refman/5.0/en/charset-connection.html\n//\n// .. note::\n//   The server may not set the ``original_{table|name}`` fields if they are equal to the plain\n//   ``{table|name}`` field.\n//\n//   A client has to reconstruct it like::\n//\n//     if .original_name is empty and .name is not empty:\n//       .original_name = .name\n//\n//     if .original_table is empty and .table is not empty:\n//       .original_table = .table\n//\n// .. note::\n//   ``compact metadata format`` can be requested by the client. In that case only ``.type`` is set and\n//   all other fields are empty.\n//\n//\n// :param type:\n//   .. table:: Expected Datatype of Mysqlx.Resultset.Row per SQL Type for non NULL values\n//\n//     ================= ============ ======= ========== ====== ========\n//     SQL Type          .type        .length .frac_dig  .flags .charset\n//     ================= ============ ======= ========== ====== ========\n//     TINY              SINT         x\n//     TINY UNSIGNED     UINT         x                  x\n//     SHORT             SINT         x\n//     SHORT UNSIGNED    UINT         x                  x\n//     INT24             SINT         x\n//     INT24 UNSIGNED    UINT         x                  x\n//     INT               SINT         x\n//     INT UNSIGNED      UINT         x                  x\n//     LONGLONG          SINT         x\n//     LONGLONG UNSIGNED UINT         x                  x\n//     DOUBLE            DOUBLE       x       x          x\n//     FLOAT             FLOAT        x       x          x\n//     DECIMAL           DECIMAL      x       x          x\n//     VARCHAR,CHAR,...  BYTES        x                  x      x\n//     GEOMETRY          BYTES\n//     TIME              TIME         x\n//     DATE              DATETIME     x\n//     DATETIME          DATETIME     x\n//     YEAR              UINT         x                  x\n//     TIMESTAMP         DATETIME     x\n//     SET               SET                                    x\n//     ENUM              ENUM                                   x\n//     NULL              BYTES\n//     BIT               BIT          x\n//     ================= ============ ======= ========== ====== ========\n//\n//   .. note:: the SQL \"NULL\" value is sent as an empty field value in :protobuf:msg:`Mysqlx.Resultset::Row`\n//   .. seealso:: protobuf encoding of primitive datatypes are decribed in https://developers.google.com/protocol-buffers/docs/encoding\n//\n//   SINT\n//\n//     ``.length``\n//       maximum number of displayable decimal digits (including minus sign) of the type\n//\n//       .. note::\n//         valid range is 0-255, but usually you'll see 1-20\n//\n//       =============== ==\n//       SQL Type        max digits per type\n//       =============== ==\n//       TINY SIGNED      4\n//       SHORT SIGNED     6\n//       INT24 SIGNED     8\n//       INT SIGNED      11\n//       LONGLONG SIGNED 20\n//       =============== ==\n//\n//       .. seealso:: definition of ``M`` in https://dev.mysql.com/doc/refman/5.5/en/numeric-type-overview.html\n//\n//     ``value``\n//       variable length encoded signed 64 integer\n//\n//   UINT\n//\n//     ``.flags & 1`` (zerofill)\n//       the client has to left pad with 0's up to .length\n//\n//     ``.length``\n//       maximum number of displayable decimal digits of the type\n//\n//       .. note::\n//         valid range is 0-255, but usually you'll see 1-20\n//\n//       ================= ==\n//       SQL Type          max digits per type\n//       ================= ==\n//       TINY UNSIGNED      3\n//       SHORT UNSIGNED     5\n//       INT24 UNSIGNED     8\n//       INT UNSIGNED      10\n//       LONGLONG UNSIGNED 20\n//       ================= ==\n//\n//       .. seealso:: definition of ``M`` in https://dev.mysql.com/doc/refman/5.5/en/numeric-type-overview.html\n//\n//     ``value``\n//       variable length encoded unsigned 64 integer\n//\n//   BIT\n//\n//     ``.length``\n//       maximum number of displayable binary digits\n//\n//       .. note:: valid range for M of the ``BIT`` type is 1 - 64\n//       .. seealso:: https://dev.mysql.com/doc/refman/5.5/en/numeric-type-overview.html\n//\n//     ``value``\n//       variable length encoded unsigned 64 integer\n//\n//   DOUBLE\n//\n//     ``.length``\n//       maximum number of displayable decimal digits (including the decimal point and ``.fractional_digits``)\n//\n//     ``.fractional_digits``\n//       maximum number of displayable decimal digits following the decimal point\n//\n//     ``value``\n//       encoded as Protobuf's 'double'\n//\n//   FLOAT\n//\n//     ``.length``\n//       maximum number of displayable decimal digits (including the decimal point and ``.fractional_digits``)\n//\n//     ``.fractional_digits``\n//       maximum number of displayable decimal digits following the decimal point\n//\n//     ``value``\n//       encoded as Protobuf's 'float'\n//\n//   BYTES, ENUM\n//     BYTES is used for all opaque byte strings that may have a charset\n//\n//       * TINYBLOB, BLOB, MEDIUMBLOB, LONGBLOB\n//       * TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT\n//       * VARCHAR, VARBINARY\n//       * CHAR, BINARY\n//       * ENUM\n//\n//     ``.length``\n//       the maximum length of characters of the underlying type\n//\n//     ``.flags & 1`` (rightpad)\n//       if the length of the field is less than ``.length``, the receiver is\n//       supposed to add padding characters to the right end of the string.\n//       If the ``.charset`` is \"binary\", the padding character is ``0x00``,\n//       otherwise it is a space character as defined by that character set.\n//\n//       ============= ======= ======== =======\n//       SQL Type      .length .charset .flags\n//       ============= ======= ======== =======\n//       TINYBLOB      256     binary\n//       BLOB          65535   binary\n//       VARCHAR(32)   32      utf8\n//       VARBINARY(32) 32      utf8_bin\n//       BINARY(32)    32      binary   rightpad\n//       CHAR(32)      32      utf8     rightpad\n//       ============= ======= ======== =======\n//\n//     ``value``\n//       sequence of bytes with added one extra '\\0' byte at the end. To obtain the\n//       original string, the extra '\\0' should be removed.\n//       .. note:: the length of the string can be acquired with protobuf's field length() method\n//         length of sequence-of-bytes = length-of-field - 1\n//       .. note:: the extra byte allows to distinguish between a NULL and empty byte sequence\n//\n//   TIME\n//     A time value.\n//\n//     ``value``\n//       the following bytes sequence:\n//\n//         ``| negate [ | hour | [ | minutes | [ | seconds | [ | useconds | ]]]]``\n//\n//       * negate - one byte, should be one of: 0x00 for \"+\", 0x01 for \"-\"\n//       * hour - optional variable length encoded unsigned64 value for the hour\n//       * minutes - optional variable length encoded unsigned64 value for the minutes\n//       * seconds - optional variable length encoded unsigned64 value for the seconds\n//       * useconds - optional variable length encoded unsigned64 value for the microseconds\n//\n//       .. seealso:: protobuf encoding in https://developers.google.com/protocol-buffers/docs/encoding\n//       .. note:: hour, minutes, seconds, useconds are optional if all the values to the right are 0\n//\n//       Example: 0x00 -> +00:00:00.000000\n//\n//   DATETIME\n//     A date or date and time value.\n//\n//     ``value``\n//       a sequence of variants, arranged as follows:\n//\n//         ``| year | month | day | [ | hour | [ | minutes | [ | seconds | [ | useconds | ]]]]``\n//\n//       * year - variable length encoded unsigned64 value for the year\n//       * month - variable length encoded unsigned64 value for the month\n//       * day - variable length encoded unsigned64 value for the day\n//       * hour - optional variable length encoded unsigned64 value for the hour\n//       * minutes - optional variable length encoded unsigned64 value for the minutes\n//       * seconds - optional variable length encoded unsigned64 value for the seconds\n//       * useconds - optional variable length encoded unsigned64 value for the microseconds\n//\n//       .. note:: hour, minutes, seconds, useconds are optional if all the values to the right are 0\n//\n//     ``.flags & 1`` (timestamp)\n//\n//       ============= =======\n//       SQL Type      .flags\n//       ============= =======\n//       DATETIME\n//       TIMESTAMP     1\n//\n//   DECIMAL\n//     An arbitrary length number. The number is encoded as a single byte\n//     indicating the position of the decimal point followed by the Packed BCD\n//     encoded number. Packed BCD is used to simplify conversion to and\n//     from strings and other native arbitrary precision math datatypes.\n//     .. seealso:: packed BCD in https://en.wikipedia.org/wiki/Binary-coded_decimal\n//\n//     ``.length``\n//       maximum number of displayable decimal digits (*excluding* the decimal point and sign, but including ``.fractional_digits``)\n//\n//       .. note:: should be in the range of 1 - 65\n//\n//     ``.fractional_digits``\n//       is the decimal digits to display out of length\n//\n//       .. note:: should be in the range of 0 - 30\n//\n//     ``value``\n//       the following bytes sequence:\n//\n//         ``| scale | BCD | sign | [0x0] |``\n//\n//       * scale - 8bit scale value (number of decimal digit after the '.')\n//       * BCD - BCD encoded digits (4 bits for each digit)\n//       * sign - sign encoded on 4 bits (0xc = \"+\", 0xd = \"-\")\n//       * 0x0 - last 4bits if length(digits) % 2 == 0\n//\n//       Example: x04 0x12 0x34 0x01 0xd0 -> -12.3401\n//\n//   SET\n//     A list of strings representing a SET of values.\n//\n//     ``value``\n//       A sequence of 0 or more of protobuf's bytes (length prepended octets) or one of\n//       the special sequences with a predefined meaning listed below.\n//\n//       Example (length of the bytes array shown in brackets):\n//         * ``[0]`` - the NULL value\n//         * ``[1] 0x00`` - a set containing a blank string ''\n//         * ``[1] 0x01`` - this would be an invalid value, but is to be treated as the empty set\n//         * ``[2] 0x01 0x00`` - a set with a single item, which is the '\\0' character\n//         * ``[8] 0x03 F O O 0x03 B A R`` - a set with 2 items: FOO,BAR\n//\n//\n// :param name: name of the column\n// :param original_name: name of the column before an alias was applied\n// :param table: name of the table the column orginates from\n// :param original_table: name of the table the column orginates from before an alias was applied\n// :param schema: schema the column originates from\n// :param catalog:\n//   catalog the schema originates from\n//\n//   .. note::\n//     as there is current no support for catalogs in MySQL, don't expect this field to be set.\n//     In the MySQL C/S protocol the field had the value ``def`` all the time.\n//\n// :param fractional_digits: displayed factional decimal digits for floating point and fixed point numbers\n// :param length: maximum count of displayable characters of .type\n// :param flags:\n//   ``.type`` specific flags\n//\n//   ======= ====== ===========\n//   type    value  description\n//   ======= ====== ===========\n//   UINT    0x0001 zerofill\n//   DOUBLE  0x0001 unsigned\n//   FLOAT   0x0001 unsigned\n//   DECIMAL 0x0001 unsigned\n//   BYTES   0x0001 rightpad\n//   ======= ====== ===========\n//\n//   ====== ================\n//   value  description\n//   ====== ================\n//   0x0010 NOT_NULL\n//   0x0020 PRIMARY_KEY\n//   0x0040 UNIQUE_KEY\n//   0x0080 MULTIPLE_KEY\n//   0x0100 AUTO_INCREMENT\n//   ====== ================\n//\n//   default: 0\n// :param content_type:\n//   a hint about the higher-level encoding of a BYTES field\n//\n//   ====== ====== ===========\n//   type   value  description\n//   ====== ====== ===========\n//   BYTES  0x0001 GEOMETRY (WKB encoding)\n//   BYTES  0x0002 JSON (text encoding)\n//   BYTES  0x0003 XML (text encoding)\n//   ====== ====== ===========\n//\n//   .. note::\n//     this list isn't comprehensive. As guideline: the field's value is expected\n//     to pass a validator check on client and server if this field is set.\n//     If the server adds more internal datatypes that rely on BLOB storage\n//     like image manipulation, seeking into complex types in BLOBs, ... more\n//     types will be added.\n//\nmessage ColumnMetaData {\n  enum FieldType {\n    SINT     = 1;\n    UINT     = 2;\n\n    DOUBLE   = 5;\n    FLOAT    = 6;\n\n    BYTES    = 7;\n\n    TIME     = 10;\n    DATETIME = 12;\n    SET      = 15;\n    ENUM     = 16;\n    BIT      = 17;\n\n    DECIMAL  = 18;\n  }\n\n  // datatype of the field in a row\n  required FieldType type = 1;\n  optional bytes name = 2;\n  optional bytes original_name = 3;\n\n  optional bytes table = 4;\n  optional bytes original_table = 5;\n\n  optional bytes schema = 6;\n  optional bytes catalog = 7;\n\n  optional uint64 collation = 8;\n\n  optional uint32 fractional_digits = 9;\n\n  optional uint32 length = 10;\n\n  optional uint32 flags = 11;\n\n  optional uint32 content_type = 12;\n}\n\n//   Row in a Resultset\n//\n//   a row is represented as a list of fields encoded as byte blobs.\n//   Blob of size 0 represents the NULL value. Otherwise, if it contains at least\n//   one byte, it encodes a non-null value of the field using encoding appropriate for the\n//   type of the value given by ``ColumnMetadata``, as specified\n//   in the :protobuf:msg:`Mysqlx.Resultset::ColumnMetaData` description.\n//\nmessage Row {\n  repeated bytes field = 1;\n}\n\n"
  },
  {
    "path": "src/x_protocol/proto/mysqlx_session.proto",
    "content": "/*\n * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License, version 2.0,\n * as published by the Free Software Foundation.\n *\n * This program is also distributed with certain software (including\n * but not limited to OpenSSL) that is licensed under separate terms,\n * as designated in a particular file or component or in included license\n * documentation.  The authors of MySQL hereby grant you an additional\n * permission to link the program and your derivative works with the\n * separately licensed software that they have included with MySQL.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n */\nsyntax = \"proto2\";\n\n// ifdef PROTOBUF_LITE: option optimize_for = LITE_RUNTIME;\n\n// Messages to manage Sessions\n//\n// .. uml::\n//\n//   == session start ==\n//   Client -> Server: AuthenticateStart\n//   opt\n//   Server --> Client: AuthenticateContinue\n//   Client --> Server: AuthenticateContinue\n//   end\n//   alt\n//   Server --> Client: AuthenticateOk\n//   else\n//   Server --> Client: Error\n//   end\n//   ...\n//   == session reset ==\n//   Client -> Server: Reset\n//   Server --> Client: Ok\n//   == session end ==\n//   Client -> Server: Close\n//   Server --> Client: Ok\n//\npackage Mysqlx.Session;\noption java_package = \"com.mysql.cj.mysqlx.protobuf\";\n\n// the initial message send from the client to the server to start the\n// authentication proccess\n//\n// :param mech_name: authentication mechanism name\n// :param auth_data: authentication data\n// :param initial_response: initial response\n// :Returns: :protobuf:msg:`Mysqlx.Session::AuthenticateContinue`\nmessage AuthenticateStart {\n  required string mech_name = 1;\n  optional bytes auth_data = 2;\n  optional bytes initial_response = 3;\n}\n\n// send by client or server after a :protobuf:msg:`Mysqlx.Session::AuthenticateStart` to\n// exchange more auth data\n//\n// :param auth_data: authentication data\n// :Returns: :protobuf:msg:`Mysqlx.Session::AuthenticateContinue`\nmessage AuthenticateContinue {\n  required bytes auth_data = 1;\n}\n\n// sent by the server after successful authentication\n//\n// :param auth_data: authentication data\nmessage AuthenticateOk {\n  optional bytes auth_data = 1;\n}\n\n// reset the current session\n//\n// :Returns: :protobuf:msg:`Mysqlx::Ok`\nmessage Reset {\n}\n\n// close the current session\n//\n// :Returns: :protobuf:msg:`Mysqlx::Ok`\nmessage Close {\n}\n\n"
  },
  {
    "path": "src/x_protocol/proto/mysqlx_sql.proto",
    "content": "/*\n * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License, version 2.0,\n * as published by the Free Software Foundation.\n *\n * This program is also distributed with certain software (including\n * but not limited to OpenSSL) that is licensed under separate terms,\n * as designated in a particular file or component or in included license\n * documentation.  The authors of MySQL hereby grant you an additional\n * permission to link the program and your derivative works with the\n * separately licensed software that they have included with MySQL.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program; if not, write to the Free Software\n * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n */\nsyntax = \"proto2\";\n\n// ifdef PROTOBUF_LITE: option optimize_for = LITE_RUNTIME;\n\n// Messages of the MySQL Package\npackage Mysqlx.Sql;\noption java_package = \"com.mysql.cj.mysqlx.protobuf\";\n\nimport \"mysqlx_datatypes.proto\";\n\n// execute a statement in the given namespace\n//\n// .. uml::\n//\n//   client -> server: StmtExecute\n//   ... zero or more Resultsets ...\n//   server --> client: StmtExecuteOk\n//\n// Notices:\n//   This message may generate a notice containing WARNINGs generated by its execution.\n//   This message may generate a notice containing INFO messages generated by its execution.\n//\n// :param namespace: namespace of the statement to be executed\n// :param stmt: statement that shall be executed.\n// :param args: values for wildcard replacements\n// :param compact_metadata: send only type information for :protobuf:msg:`Mysqlx.Resultset::ColumnMetadata`, skipping names and others\n// :returns:\n//    * zero or one :protobuf:msg:`Mysqlx.Resultset::` followed by :protobuf:msg:`Mysqlx.Sql::StmtExecuteOk`\nmessage StmtExecute {\n  optional string namespace = 3 [ default = \"sql\" ];\n  required bytes stmt = 1;\n  repeated Mysqlx.Datatypes.Any args = 2;\n  optional bool compact_metadata = 4 [ default = false ];\n}\n\n// statement executed successful\nmessage StmtExecuteOk {\n}\n\n"
  },
  {
    "path": "tests/CMakeLists.txt",
    "content": "# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\ninclude_directories(helpers\n  ${PROJECT_SOURCE_DIR}/src/harness/include\n  ${PROJECT_SOURCE_DIR}/src/router/include/mysqlrouter\n  ${GTEST_INCLUDE_DIRS}\n  )\n\nset(helper_sources\n  helpers/router_test_helpers.cc\n  helpers/mysql_session_replayer.cc\n  helpers/router_component_test.cc\n  helpers/tcp_port_pool.cc\n  helpers/script_generator.cc\n)\n\nif(WIN32)\n  list(APPEND helper_sources helpers/cmd_exec-windows.cc)\n  add_library(routertest_helpers STATIC ${helper_sources})\nelse()\n  list(APPEND helper_sources helpers/cmd_exec.cc)\n  add_library(routertest_helpers SHARED ${helper_sources})\nendif()\n\ntarget_link_libraries(routertest_helpers harness-library router_lib)\n\nset(helpers_include_dirs\n  ${PROJECT_SOURCE_DIR}/tests/helpers/\n  ${PROJECT_SOURCE_DIR}/src/harness/include\n  ${PROJECT_BINARY_DIR}/\n  ${PROJECT_BINARY_DIR}/harness\n  ${PROJECT_BINARY_DIR}/include\n  ${GTEST_INCLUDE_DIRS}\n  )\n\nset_target_properties(routertest_helpers PROPERTIES\n  LIBRARY_OUTPUT_DIRECTORY ${MySQLRouter_BINARY_STAGE_DIR}/lib\n  INCLUDE_DIRECTORIES \"${helpers_include_dirs}\"\n)\n\nIF(NOT GPL)\n  ADD_DEFINITIONS(-DHAVE_LICENSE_COMMERCIAL)\nENDIF()\n\nforeach(test_dir legal tools)\n    if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${test_dir})\n        add_test_dir(${CMAKE_CURRENT_SOURCE_DIR}/${test_dir} MODULE project)\n    endif()\nendforeach()\n\nadd_subdirectory(component)\nadd_subdirectory(fuzzers)\n\nadd_definitions(-DCOMPONENT_TEST_DATA_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}/component/data/\")\n"
  },
  {
    "path": "tests/component/CMakeLists.txt",
    "content": "# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\nadd_test_dir(${CMAKE_CURRENT_SOURCE_DIR}\n  MODULE \"component\"\n  INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/http/include/;${RAPIDJSON_INCLUDE_DIRS}\n  LIB_DEPENDS http_client;http_common;${LIBEVENT2_CORE};${LIBEVENT2_EXTRA}\n  )\n\nadd_executable(master_key_test_writer ../helpers/master_key_test_writer.cc)\n\n# When system deployment bootstrap is executed, files are\n# created in locations specified by deployment layout.\n# Since component tests may not have access to directories defined\n# in install_layout.cmake, system bootstrap deployment tests are\n# executed only for STANDALONE layout, are are not executed on Windows.\nif (CMAKE_SYSTEM_NAME STREQUAL \"Windows\" OR NOT INSTALL_LAYOUT STREQUAL \"STANDALONE\")\n  add_definitions(-DSKIP_BOOTSTRAP_SYSTEM_DEPLOYMENT_TESTS)\nendif()\n"
  },
  {
    "path": "tests/component/data/bootstrap.js",
    "content": "({\n  \"stmts\": [\n    {\n      \"stmt\": \"SELECT * FROM mysql_innodb_cluster_metadata.schema_version\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"major\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"minor\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"patch\"\n          }\n        ],\n        \"rows\": [\n          [\n            1,\n            0,\n            1\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT  ((SELECT count(*) FROM mysql_innodb_cluster_metadata.clusters) <= 1  AND (SELECT count(*) FROM mysql_innodb_cluster_metadata.replicasets) <= 1) as has_one_replicaset, (SELECT attributes->>'$.group_replication_group_name' FROM mysql_innodb_cluster_metadata.replicasets)  = @@group_replication_group_name as replicaset_is_ours\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"has_one_replicaset\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"replicaset_is_ours\"\n          }\n        ],\n        \"rows\": [\n          [\n            1,\n            1\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT member_state FROM performance_schema.replication_group_members WHERE member_id = @@server_uuid\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"STRING\",\n            \"name\": \"member_state\"\n          }\n        ],\n        \"rows\": [\n          [\n            \"ONLINE\"\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT SUM(IF(member_state = 'ONLINE', 1, 0)) as num_onlines, COUNT(*) as num_total FROM performance_schema.replication_group_members\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"num_onlines\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"num_total\"\n          }\n        ],\n        \"rows\": [\n          [\n            3,\n            3\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"show status like 'ssl_cipher'\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"STRING\",\n            \"name\": \"Variable_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"Value\"\n          }\n        ],\n        \"rows\": [\n          [\n            \"Ssl_cipher\",\n            \"\"\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT F.cluster_name, R.replicaset_name, R.topology_type, JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic')) FROM mysql_innodb_cluster_metadata.clusters AS F, mysql_innodb_cluster_metadata.instances AS I, mysql_innodb_cluster_metadata.replicasets AS R WHERE R.replicaset_id = (SELECT replicaset_id FROM mysql_innodb_cluster_metadata.instances WHERE mysql_server_uuid = @@server_uuid)AND I.replicaset_id = R.replicaset_id AND R.cluster_id = F.cluster_id\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"cluster_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"replicaset_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"topology_type\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic'))\"\n          }\n        ],\n        \"rows\": [\n          [\n            \"mycluster\",\n            \"default\",\n            \"pm\",\n            \"localhost:5500\"\n          ],\n          [\n            \"mycluster\",\n            \"default\",\n            \"pm\",\n            \"localhost:5510\"\n          ],\n          [\n            \"mycluster\",\n            \"default\",\n            \"pm\",\n            \"localhost:5520\"\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"START TRANSACTION\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"SELECT host_id, host_name, ip_address FROM mysql_innodb_cluster_metadata.hosts WHERE host_name = '.*' LIMIT 1\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"STRING\",\n            \"name\": \"host_id\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"host_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"ip_address\"\n          }\n        ]\n      }\n    },\n    {\n      \"stmt.regex\": \"^INSERT INTO mysql_innodb_cluster_metadata.hosts.*\",\n      \"ok\": {\n        \"last_insert_id\": 1\n      }\n    },\n    {\n      \"stmt.regex\": \"^INSERT INTO mysql_innodb_cluster_metadata.routers.*\",\n      \"ok\": {\n        \"last_insert_id\": 1\n      }\n    },\n\n\n\n    // delete all old accounts if necessarry (ConfigGenerator::delete_account_for_all_hosts())\n    {\n      \"stmt.regex\": \"^SELECT host FROM mysql.user WHERE user = '.*'\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"COUNT...\"\n          }\n        ],\n        \"rows\": []  // to keep it simple, just tell Router there's no old accounts to erase\n      }\n    },\n\n\n\n    // ConfigGenerator::create_account()\n    {\n      \"stmt.regex\": \"^CREATE USER mysql_router1_[0-9a-z]{12}@'%' IDENTIFIED WITH mysql_native_password AS '\\\\*[0-9A-Z]{40}'\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"^GRANT SELECT ON mysql_innodb_cluster_metadata.*\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"^GRANT SELECT ON performance_schema.*\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"^GRANT SELECT ON performance_schema.*\",\n      \"ok\": {}\n    },\n\n\n\n    {\n      \"stmt.regex\": \"^UPDATE mysql_innodb_cluster_metadata\\\\.routers.*\",\n      \"ok\": {}\n    },\n    {\n      \"stmt\": \"COMMIT\",\n      \"ok\": {}\n    }\n  ]\n})\n"
  },
  {
    "path": "tests/component/data/bootstrap_access_error_at_grant.js",
    "content": "{\n    \"stmts\": [\n        {\n            \"stmt\": \"SELECT * FROM mysql_innodb_cluster_metadata.schema_version\",\n            \"exec_time\": 0.232933,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"major\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"minor\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"patch\",\n                        \"type\": \"LONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"1\",\n                        \"0\",\n                        \"2\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT  ((SELECT count(*) FROM mysql_innodb_cluster_metadata.clusters) <= 1  AND (SELECT count(*) FROM mysql_innodb_cluster_metadata.replicasets) <= 1) as has_one_replicaset, (SELECT attributes->>'$.group_replication_group_name' FROM mysql_innodb_cluster_metadata.replicasets)  = @@group_replication_group_name as replicaset_is_ours\",\n            \"exec_time\": 0.424781,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"has_one_replicaset\",\n                        \"type\": \"LONGLONG\"\n                    },\n                    {\n                        \"name\": \"replicaset_is_ours\",\n                        \"type\": \"LONGLONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"1\",\n                        \"1\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT member_state FROM performance_schema.replication_group_members WHERE member_id = @@server_uuid\",\n            \"exec_time\": 0.170235,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"member_state\",\n                        \"type\": \"STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"ONLINE\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT SUM(IF(member_state = 'ONLINE', 1, 0)) as num_onlines, COUNT(*) as num_total FROM performance_schema.replication_group_members\",\n            \"exec_time\": 0.151384,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"num_onlines\",\n                        \"type\": \"NEWDECIMAL\"\n                    },\n                    {\n                        \"name\": \"num_total\",\n                        \"type\": \"LONGLONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"3\",\n                        \"3\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"show status like 'ssl_cipher'\",\n            \"exec_time\": 0.800325,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"Variable_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"Value\",\n                        \"type\": \"VAR_STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"Ssl_cipher\",\n                        \"\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT F.cluster_name, R.replicaset_name, R.topology_type, JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic')) FROM mysql_innodb_cluster_metadata.clusters AS F, mysql_innodb_cluster_metadata.instances AS I, mysql_innodb_cluster_metadata.replicasets AS R WHERE R.replicaset_id = (SELECT replicaset_id FROM mysql_innodb_cluster_metadata.instances WHERE mysql_server_uuid = @@server_uuid)AND I.replicaset_id = R.replicaset_id AND R.cluster_id = F.cluster_id\",\n            \"exec_time\": 0.418633,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"cluster_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"replicaset_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"topology_type\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic'))\",\n                        \"type\": \"LONGBLOB\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        process.env.MYSQL_SERVER_MOCK_CLUSTER_NAME,\n                        \"myreplicaset\",\n                        \"pm\",\n                        \"127.0.0.1:13001\"\n                    ],\n                    [\n                        process.env.MYSQL_SERVER_MOCK_CLUSTER_NAME,\n                        \"myreplicaset\",\n                        \"pm\",\n                        \"127.0.0.1:13002\"\n                    ],\n                    [\n                        process.env.MYSQL_SERVER_MOCK_CLUSTER_NAME,\n                        \"myreplicaset\",\n                        \"pm\",\n                        \"127.0.0.1:13003\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"START TRANSACTION\",\n            \"exec_time\": 0.082893,\n            \"ok\": {}\n        },\n        {\n            \"stmt.regex\": \"^SELECT host_id, host_name, ip_address FROM mysql_innodb_cluster_metadata.hosts WHERE host_name = '..*' LIMIT 1\",\n            \"exec_time\": 0.296962,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"host_id\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"host_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"ip_address\",\n                        \"type\": \"VAR_STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"8\",\n                        process.env.MYSQL_SERVER_MOCK_HOST_1,\n                        null\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"INSERT INTO mysql_innodb_cluster_metadata.routers        (host_id, router_name) VALUES (8, '')\",\n            \"exec_time\": 0.152557,\n            \"ok\": {\n              \"last_insert_id\": 8\n            }\n        },\n\n        // delete all old accounts if necessarry (ConfigGenerator::delete_account_for_all_hosts())\n        {\n            \"stmt.regex\": \"^SELECT host FROM mysql.user WHERE user = '.*'\",\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"type\": \"LONGLONG\",\n                        \"name\": \"COUNT...\"\n                    }\n                ],\n                \"rows\": []  // to keep it simple, just tell Router there's no old accounts to erase\n            }\n        },\n\n        // ConfigGenerator::create_account()\n        {\n            \"stmt.regex\": \"^CREATE USER mysql_router8_[0-9a-z]{12}@'%' IDENTIFIED WITH mysql_native_password AS '\\\\*[0-9A-Z]{40}'\",\n            \"ok\": {}\n        },\n        {\n            \"stmt.regex\": \"^GRANT SELECT ON mysql_innodb_cluster_metadata.*\",\n            \"error\": {\n                \"code\": 1044,\n                \"message\": \"Access denied for user 'native'@'%' to database 'mysql_innodb_cluster_metadata\",\n                \"sql_state\": \"HY000\"\n            }\n        },\n        {\n            \"stmt\": \"ROLLBACK\",\n            \"exec_time\": 0.100835,\n            \"ok\": {}\n        },\n        {\n            \"stmt\": \"ROLLBACK\",\n            \"exec_time\": 0.100835,\n            \"ok\": {}\n        }\n    ]\n}\n"
  },
  {
    "path": "tests/component/data/bootstrap_account_host_multiple_patterns.js",
    "content": "({\n  \"stmts\": [\n    {\n      \"stmt\": \"SELECT * FROM mysql_innodb_cluster_metadata.schema_version\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"major\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"minor\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"patch\"\n          }\n        ],\n        \"rows\": [\n          [\n            1,\n            0,\n            1\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT  ((SELECT count(*) FROM mysql_innodb_cluster_metadata.clusters) <= 1  AND (SELECT count(*) FROM mysql_innodb_cluster_metadata.replicasets) <= 1) as has_one_replicaset, (SELECT attributes->>'$.group_replication_group_name' FROM mysql_innodb_cluster_metadata.replicasets)  = @@group_replication_group_name as replicaset_is_ours\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"has_one_replicaset\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"replicaset_is_ours\"\n          }\n        ],\n        \"rows\": [\n          [\n            1,\n            1\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT member_state FROM performance_schema.replication_group_members WHERE member_id = @@server_uuid\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"STRING\",\n            \"name\": \"member_state\"\n          }\n        ],\n        \"rows\": [\n          [\n            \"ONLINE\"\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT SUM(IF(member_state = 'ONLINE', 1, 0)) as num_onlines, COUNT(*) as num_total FROM performance_schema.replication_group_members\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"num_onlines\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"num_total\"\n          }\n        ],\n        \"rows\": [\n          [\n            3,\n            3\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"show status like 'ssl_cipher'\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"STRING\",\n            \"name\": \"Variable_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"Value\"\n          }\n        ],\n        \"rows\": [\n          [\n            \"Ssl_cipher\",\n            \"\"\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT F.cluster_name, R.replicaset_name, R.topology_type, JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic')) FROM mysql_innodb_cluster_metadata.clusters AS F, mysql_innodb_cluster_metadata.instances AS I, mysql_innodb_cluster_metadata.replicasets AS R WHERE R.replicaset_id = (SELECT replicaset_id FROM mysql_innodb_cluster_metadata.instances WHERE mysql_server_uuid = @@server_uuid)AND I.replicaset_id = R.replicaset_id AND R.cluster_id = F.cluster_id\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"cluster_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"replicaset_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"topology_type\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic'))\"\n          }\n        ],\n        \"rows\": [\n          [\n            \"test\",\n            \"default\",\n            \"pm\",\n            \"localhost:5500\"\n          ],\n          [\n            \"test\",\n            \"default\",\n            \"pm\",\n            \"localhost:5510\"\n          ],\n          [\n            \"test\",\n            \"default\",\n            \"pm\",\n            \"localhost:5520\"\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"START TRANSACTION\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"SELECT host_id, host_name, ip_address FROM mysql_innodb_cluster_metadata.hosts WHERE host_name = '.*' LIMIT 1\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"STRING\",\n            \"name\": \"host_id\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"host_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"ip_address\"\n          }\n        ]\n      }\n    },\n\n    // register router\n    {\n      \"stmt.regex\": \"^INSERT INTO mysql_innodb_cluster_metadata.hosts.*\",\n      \"ok\": {\n        \"last_insert_id\": 12 // host_id\n      }\n    },\n    {\n      \"stmt.regex\": \"^INSERT INTO mysql_innodb_cluster_metadata.routers.*\",\n      \"ok\": {\n        \"last_insert_id\": 34 // router_id\n      }\n    },\n\n\n\n    // delete all old accounts if necessarry (ConfigGenerator::delete_account_for_all_hosts())\n    {\n      \"stmt.regex\": \"^SELECT host FROM mysql.user WHERE user = '.*'\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"COUNT...\"\n          }\n        ],\n        \"rows\": []  // to keep it simple, just tell Router there's no old accounts to erase\n      }\n    },\n\n\n\n    // NOTE: CREATE USER statements should run in unique(sort(hostname_list)) fashion\n\n    { // iteration #1: --account-host %\"\n      \"stmt.regex\": \"^CREATE USER mysql_router34_[0-9a-z]{12}@'%' IDENTIFIED WITH mysql_native_password AS '\\\\*[0-9A-Z]{40}'\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"^GRANT SELECT ON mysql_innodb_cluster_metadata.*'%'\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"^GRANT SELECT ON performance_schema.*'%'\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"^GRANT SELECT ON performance_schema.*'%'\",\n      \"ok\": {}\n    },\n\n\n\n    { // iteration #2: --account-host host1\"\n      \"stmt.regex\": \"^CREATE USER mysql_router34_[0-9a-z]{12}@'host1' IDENTIFIED WITH mysql_native_password AS '\\\\*[0-9A-Z]{40}'\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"^GRANT SELECT ON mysql_innodb_cluster_metadata.*'host1'\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"^GRANT SELECT ON performance_schema.*'host1'\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"^GRANT SELECT ON performance_schema.*'host1'\",\n      \"ok\": {}\n    },\n\n\n\n    { // iteration #3: --account-host host3%\"\n      \"stmt.regex\": \"^CREATE USER mysql_router34_[0-9a-z]{12}@'host3%' IDENTIFIED WITH mysql_native_password AS '\\\\*[0-9A-Z]{40}'\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"^GRANT SELECT ON mysql_innodb_cluster_metadata.*'host3%'\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"^GRANT SELECT ON performance_schema.*'host3%'\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"^GRANT SELECT ON performance_schema.*'host3%'\",\n      \"ok\": {}\n    },\n\n\n\n    {\n      \"stmt.regex\": \"^UPDATE mysql_innodb_cluster_metadata\\\\.routers.*\",\n      \"ok\": {}\n    },\n    {\n      \"stmt\": \"COMMIT\",\n      \"ok\": {}\n    }\n  ]\n})\n"
  },
  {
    "path": "tests/component/data/bootstrap_account_host_pattern_too_long.js",
    "content": "({\n  \"stmts\": [\n    {\n      \"stmt\": \"SELECT * FROM mysql_innodb_cluster_metadata.schema_version\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"major\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"minor\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"patch\"\n          }\n        ],\n        \"rows\": [\n          [\n            1,\n            0,\n            1\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT  ((SELECT count(*) FROM mysql_innodb_cluster_metadata.clusters) <= 1  AND (SELECT count(*) FROM mysql_innodb_cluster_metadata.replicasets) <= 1) as has_one_replicaset, (SELECT attributes->>'$.group_replication_group_name' FROM mysql_innodb_cluster_metadata.replicasets)  = @@group_replication_group_name as replicaset_is_ours\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"has_one_replicaset\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"replicaset_is_ours\"\n          }\n        ],\n        \"rows\": [\n          [\n            1,\n            1\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT member_state FROM performance_schema.replication_group_members WHERE member_id = @@server_uuid\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"STRING\",\n            \"name\": \"member_state\"\n          }\n        ],\n        \"rows\": [\n          [\n            \"ONLINE\"\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT SUM(IF(member_state = 'ONLINE', 1, 0)) as num_onlines, COUNT(*) as num_total FROM performance_schema.replication_group_members\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"num_onlines\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"num_total\"\n          }\n        ],\n        \"rows\": [\n          [\n            3,\n            3\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"show status like 'ssl_cipher'\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"STRING\",\n            \"name\": \"Variable_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"Value\"\n          }\n        ],\n        \"rows\": [\n          [\n            \"Ssl_cipher\",\n            \"\"\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT F.cluster_name, R.replicaset_name, R.topology_type, JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic')) FROM mysql_innodb_cluster_metadata.clusters AS F, mysql_innodb_cluster_metadata.instances AS I, mysql_innodb_cluster_metadata.replicasets AS R WHERE R.replicaset_id = (SELECT replicaset_id FROM mysql_innodb_cluster_metadata.instances WHERE mysql_server_uuid = @@server_uuid)AND I.replicaset_id = R.replicaset_id AND R.cluster_id = F.cluster_id\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"cluster_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"replicaset_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"topology_type\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic'))\"\n          }\n        ],\n        \"rows\": [\n          [\n            \"test\",\n            \"default\",\n            \"pm\",\n            \"localhost:5500\"\n          ],\n          [\n            \"test\",\n            \"default\",\n            \"pm\",\n            \"localhost:5510\"\n          ],\n          [\n            \"test\",\n            \"default\",\n            \"pm\",\n            \"localhost:5520\"\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"START TRANSACTION\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"SELECT host_id, host_name, ip_address FROM mysql_innodb_cluster_metadata.hosts WHERE host_name = '.*' LIMIT 1\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"STRING\",\n            \"name\": \"host_id\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"host_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"ip_address\"\n          }\n        ]\n      }\n    },\n\n    // register router\n    {\n      \"stmt.regex\": \"^INSERT INTO mysql_innodb_cluster_metadata.hosts.*\",\n      \"ok\": {\n        \"last_insert_id\": 12 // host_id\n      }\n    },\n    {\n      \"stmt.regex\": \"^INSERT INTO mysql_innodb_cluster_metadata.routers.*\",\n      \"ok\": {\n        \"last_insert_id\": 34 // router_id\n      }\n    },\n\n\n\n    // delete all old accounts if necessarry (ConfigGenerator::delete_account_for_all_hosts())\n    {\n      \"stmt.regex\": \"^SELECT host FROM mysql.user WHERE user = '.*'\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"COUNT...\"\n          }\n        ],\n        \"rows\": []  // to keep it simple, just tell Router there's no old accounts to erase\n      }\n    },\n\n\n\n    // try to create a user with hostname too long\n    {\n      \"stmt.regex\": \"^CREATE USER mysql_router.*'veryveryveryveryveryveryveryveryveryveryveryveryveryveryverylonghost'.*\",\n      \"error\": {\n        \"code\": 1470,\n        \"message\": \"String 'veryveryveryveryveryveryveryveryveryveryveryveryveryveryverylonghost' is too long for host name (should be no longer than 60)\",\n        \"sql_state\": \"HY000\"\n      }\n    },\n    {\n      \"stmt\": \"ROLLBACK\",\n      \"ok\": {}\n    },\n    {\n      \"stmt\": \"ROLLBACK\",\n      \"ok\": {}\n    }\n  ]\n})\n"
  },
  {
    "path": "tests/component/data/bootstrap_big_data.js",
    "content": "({\n  \"stmts\": [\n    {\n      \"stmt\": \"SELECT * FROM mysql_innodb_cluster_metadata.schema_version\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"major\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"minor\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"patch\"\n          }\n        ],\n        \"rows\": [\n          [\n            1,\n            0,\n            1\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT  ((SELECT count(*) FROM mysql_innodb_cluster_metadata.clusters) <= 1  AND (SELECT count(*) FROM mysql_innodb_cluster_metadata.replicasets) <= 1) as has_one_replicaset, (SELECT attributes->>'$.group_replication_group_name' FROM mysql_innodb_cluster_metadata.replicasets)  = @@group_replication_group_name as replicaset_is_ours\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"has_one_replicaset\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"replicaset_is_ours\"\n          }\n        ],\n        \"rows\": [\n          [\n            1,\n            1\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT member_state FROM performance_schema.replication_group_members WHERE member_id = @@server_uuid\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"STRING\",\n            \"name\": \"member_state\"\n          }\n        ],\n        \"rows\": [\n          [\n            \"ONLINE\"\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT SUM(IF(member_state = 'ONLINE', 1, 0)) as num_onlines, COUNT(*) as num_total FROM performance_schema.replication_group_members\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"num_onlines\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"num_total\"\n          }\n        ],\n        \"rows\": [\n          [\n            3,\n            3\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"show status like 'ssl_cipher'\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"STRING\",\n            \"name\": \"Variable_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"Value\"\n          }\n        ],\n        \"rows\": [\n          [\n            \"Ssl_cipher\",\n            \"\"\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT F.cluster_name, R.replicaset_name, R.topology_type, JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic')) FROM mysql_innodb_cluster_metadata.clusters AS F, mysql_innodb_cluster_metadata.instances AS I, mysql_innodb_cluster_metadata.replicasets AS R WHERE R.replicaset_id = (SELECT replicaset_id FROM mysql_innodb_cluster_metadata.instances WHERE mysql_server_uuid = @@server_uuid)AND I.replicaset_id = R.replicaset_id AND R.cluster_id = F.cluster_id\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"cluster_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"replicaset_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"topology_type\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic'))\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"fake\",\n          }\n        ],\n        \"rows\": [\n          [\n            \"test\",\n            \"default\",\n            \"pm\",\n            \"localhost:5500\",\n            \"x\".repeat(4194304)\n          ],\n          [\n            \"test\",\n            \"default\",\n            \"pm\",\n            \"localhost:5510\",\n            \"\"\n          ],\n          [\n            \"test\",\n            \"default\",\n            \"pm\",\n            \"localhost:5520\",\n            \"\"\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"START TRANSACTION\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"SELECT host_id, host_name, ip_address FROM mysql_innodb_cluster_metadata.hosts WHERE host_name = '.*' LIMIT 1\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"STRING\",\n            \"name\": \"host_id\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"host_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"ip_address\"\n          }\n        ]\n      }\n    },\n    {\n      \"stmt.regex\": \"^INSERT INTO mysql_innodb_cluster_metadata.hosts.*\",\n      \"ok\": {\n        \"last_insert_id\": 1\n      }\n    },\n    {\n      \"stmt.regex\": \"^INSERT INTO mysql_innodb_cluster_metadata.routers.*\",\n      \"ok\": {\n        \"last_insert_id\": 1\n      }\n    },\n\n\n\n    // delete all old accounts if necessarry (ConfigGenerator::delete_account_for_all_hosts())\n    {\n      \"stmt.regex\": \"^SELECT host FROM mysql.user WHERE user = '.*'\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"COUNT...\"\n          }\n        ],\n        \"rows\": []  // to keep it simple, just tell Router there's no old accounts to erase\n      }\n    },\n\n\n    // ConfigGenerator::create_account()\n    {\n      \"stmt.regex\": \"^CREATE USER mysql_router1_[0-9a-z]{12}@'%' IDENTIFIED WITH mysql_native_password AS '\\\\*[0-9A-Z]{40}'\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"^GRANT SELECT ON mysql_innodb_cluster_metadata.*\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"^GRANT SELECT ON performance_schema.*\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"^GRANT SELECT ON performance_schema.*\",\n      \"ok\": {}\n    },\n\n\n\n    {\n      \"stmt.regex\": \"^UPDATE mysql_innodb_cluster_metadata\\\\.routers.*\",\n      \"ok\": {}\n    },\n    {\n      \"stmt\": \"COMMIT\",\n      \"ok\": {}\n    }\n  ]\n})\n"
  },
  {
    "path": "tests/component/data/bootstrap_exec_time_2_seconds.js",
    "content": "({\n  \"stmts\": [\n    {\n      \"stmt\": \"SELECT * FROM mysql_innodb_cluster_metadata.schema_version\",\n      \"exec_time\": 2000.0,\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"major\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"minor\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"patch\"\n          }\n        ],\n        \"rows\": [\n          [\n            1,\n            0,\n            1\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT  ((SELECT count(*) FROM mysql_innodb_cluster_metadata.clusters) <= 1  AND (SELECT count(*) FROM mysql_innodb_cluster_metadata.replicasets) <= 1) as has_one_replicaset, (SELECT attributes->>'$.group_replication_group_name' FROM mysql_innodb_cluster_metadata.replicasets)  = @@group_replication_group_name as replicaset_is_ours\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"has_one_replicaset\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"replicaset_is_ours\"\n          }\n        ],\n        \"rows\": [\n          [\n            1,\n            1\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT member_state FROM performance_schema.replication_group_members WHERE member_id = @@server_uuid\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"STRING\",\n            \"name\": \"member_state\"\n          }\n        ],\n        \"rows\": [\n          [\n            \"ONLINE\"\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT SUM(IF(member_state = 'ONLINE', 1, 0)) as num_onlines, COUNT(*) as num_total FROM performance_schema.replication_group_members\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"num_onlines\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"num_total\"\n          }\n        ],\n        \"rows\": [\n          [\n            3,\n            3\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"show status like 'ssl_cipher'\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"STRING\",\n            \"name\": \"Variable_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"Value\"\n          }\n        ],\n        \"rows\": [\n          [\n            \"Ssl_cipher\",\n            \"\"\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT F.cluster_name, R.replicaset_name, R.topology_type, JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic')) FROM mysql_innodb_cluster_metadata.clusters AS F, mysql_innodb_cluster_metadata.instances AS I, mysql_innodb_cluster_metadata.replicasets AS R WHERE R.replicaset_id = (SELECT replicaset_id FROM mysql_innodb_cluster_metadata.instances WHERE mysql_server_uuid = @@server_uuid)AND I.replicaset_id = R.replicaset_id AND R.cluster_id = F.cluster_id\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"cluster_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"replicaset_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"topology_type\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic'))\"\n          }\n        ],\n        \"rows\": [\n          [\n            \"mycluster\",\n            \"default\",\n            \"pm\",\n            \"localhost:5500\"\n          ],\n          [\n            \"mycluster\",\n            \"default\",\n            \"pm\",\n            \"localhost:5510\"\n          ],\n          [\n            \"mycluster\",\n            \"default\",\n            \"pm\",\n            \"localhost:5520\"\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"START TRANSACTION\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"SELECT host_id, host_name, ip_address FROM mysql_innodb_cluster_metadata.hosts WHERE host_name = '.*' LIMIT 1\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"STRING\",\n            \"name\": \"host_id\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"host_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"ip_address\"\n          }\n        ]\n      }\n    },\n    {\n      \"stmt.regex\": \"^INSERT INTO mysql_innodb_cluster_metadata.hosts.*\",\n      \"ok\": {\n        \"last_insert_id\": 1\n      }\n    },\n    {\n      \"stmt.regex\": \"^INSERT INTO mysql_innodb_cluster_metadata.routers.*\",\n      \"ok\": {\n        \"last_insert_id\": 1\n      }\n    },\n\n\n\n    // delete all old accounts if necessarry (ConfigGenerator::delete_account_for_all_hosts())\n    {\n      \"stmt.regex\": \"^SELECT host FROM mysql.user WHERE user = '.*'\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"COUNT...\"\n          }\n        ],\n        \"rows\": []  // to keep it simple, just tell Router there's no old accounts to erase\n      }\n    },\n\n\n\n    // ConfigGenerator::create_account()\n    {\n      \"stmt.regex\": \"^CREATE USER mysql_router1_[0-9a-z]{12}@'%' IDENTIFIED WITH mysql_native_password AS '\\\\*[0-9A-Z]{40}'\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"^GRANT SELECT ON mysql_innodb_cluster_metadata.*\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"^GRANT SELECT ON performance_schema.*\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"^GRANT SELECT ON performance_schema.*\",\n      \"ok\": {}\n    },\n\n\n\n    {\n      \"stmt.regex\": \"^UPDATE mysql_innodb_cluster_metadata\\\\.routers.*\",\n      \"ok\": {}\n    },\n    {\n      \"stmt\": \"COMMIT\",\n      \"ok\": {}\n    }\n  ]\n})\n"
  },
  {
    "path": "tests/component/data/bootstrap_failover_at_crash.js",
    "content": "({\n    \"stmts\": [\n        {\n            \"stmt\": \"START TRANSACTION\",\n            \"exec_time\": 0.082893,\n            \"ok\": {}\n        },\n        {\n            \"stmt\": \"SELECT h.host_id, h.host_name FROM mysql_innodb_cluster_metadata.routers r JOIN mysql_innodb_cluster_metadata.hosts h    ON r.host_id = h.host_id WHERE r.router_id = 8\",\n            \"exec_time\": 0.175663,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"host_id\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"host_name\",\n                        \"type\": \"VAR_STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"8\",\n                        process.env.MYSQL_SERVER_MOCK_HOST_NAME\n                    ]\n                ]\n            }\n        },\n\n\n\n        // delete all old accounts if necessarry (ConfigGenerator::delete_account_for_all_hosts())\n        {\n            \"stmt.regex\": \"^SELECT host FROM mysql.user WHERE user = '.*'\",\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"type\": \"LONGLONG\",\n                        \"name\": \"COUNT...\"\n                    }\n                ],\n                \"rows\": []  // to keep it simple, just tell Router there's no old accounts to erase\n            }\n        },\n\n        // create temp account to figure out the secure password\n        // - fail this, to trigger failover\n        {   // ConfigGenerator::generate_compliant_password()\n            \"stmt.regex\": \"^CREATE USER mysql_router8_[0-9a-z]{12}@'%' IDENTIFIED WITH mysql_native_password AS '\\\\*[0-9A-Z]{40}'\",\n            \"error\": {\n                \"code\": 2013,\n                \"message\": \"Lost connection to MySQL server during query\",\n                \"sql_state\": \"HY000\"\n            }\n        }\n    ]\n})\n"
  },
  {
    "path": "tests/component/data/bootstrap_failover_at_grant.js",
    "content": "{\n    \"stmts\": [\n        {\n            \"stmt\": \"SELECT * FROM mysql_innodb_cluster_metadata.schema_version\",\n            \"exec_time\": 0.232933,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"major\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"minor\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"patch\",\n                        \"type\": \"LONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"1\",\n                        \"0\",\n                        \"2\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT  ((SELECT count(*) FROM mysql_innodb_cluster_metadata.clusters) <= 1  AND (SELECT count(*) FROM mysql_innodb_cluster_metadata.replicasets) <= 1) as has_one_replicaset, (SELECT attributes->>'$.group_replication_group_name' FROM mysql_innodb_cluster_metadata.replicasets)  = @@group_replication_group_name as replicaset_is_ours\",\n            \"exec_time\": 0.424781,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"has_one_replicaset\",\n                        \"type\": \"LONGLONG\"\n                    },\n                    {\n                        \"name\": \"replicaset_is_ours\",\n                        \"type\": \"LONGLONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"1\",\n                        \"1\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT member_state FROM performance_schema.replication_group_members WHERE member_id = @@server_uuid\",\n            \"exec_time\": 0.170235,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"member_state\",\n                        \"type\": \"STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"ONLINE\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT SUM(IF(member_state = 'ONLINE', 1, 0)) as num_onlines, COUNT(*) as num_total FROM performance_schema.replication_group_members\",\n            \"exec_time\": 0.151384,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"num_onlines\",\n                        \"type\": \"NEWDECIMAL\"\n                    },\n                    {\n                        \"name\": \"num_total\",\n                        \"type\": \"LONGLONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"3\",\n                        \"3\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"show status like 'ssl_cipher'\",\n            \"exec_time\": 0.800325,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"Variable_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"Value\",\n                        \"type\": \"VAR_STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"Ssl_cipher\",\n                        \"\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT F.cluster_name, R.replicaset_name, R.topology_type, JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic')) FROM mysql_innodb_cluster_metadata.clusters AS F, mysql_innodb_cluster_metadata.instances AS I, mysql_innodb_cluster_metadata.replicasets AS R WHERE R.replicaset_id = (SELECT replicaset_id FROM mysql_innodb_cluster_metadata.instances WHERE mysql_server_uuid = @@server_uuid)AND I.replicaset_id = R.replicaset_id AND R.cluster_id = F.cluster_id\",\n            \"exec_time\": 0.418633,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"cluster_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"replicaset_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"topology_type\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic'))\",\n                        \"type\": \"LONGBLOB\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        process.env.MYSQL_SERVER_MOCK_CLUSTER_NAME,\n                        \"myreplicaset\",\n                        \"pm\",\n                        \"127.0.0.1:13001\"\n                    ],\n                    [\n                        process.env.MYSQL_SERVER_MOCK_CLUSTER_NAME,\n                        \"myreplicaset\",\n                        \"pm\",\n                        \"127.0.0.1:13002\"\n                    ],\n                    [\n                        process.env.MYSQL_SERVER_MOCK_CLUSTER_NAME,\n                        \"myreplicaset\",\n                        \"pm\",\n                        \"127.0.0.1:13003\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"START TRANSACTION\",\n            \"exec_time\": 0.082893,\n            \"ok\": {}\n        },\n        {\n            \"stmt.regex\": \"^SELECT host_id, host_name, ip_address FROM mysql_innodb_cluster_metadata.hosts WHERE host_name = '..*' LIMIT 1\",\n            \"exec_time\": 0.296962,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"host_id\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"host_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"ip_address\",\n                        \"type\": \"VAR_STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"8\",\n                        process.env.MYSQL_SERVER_MOCK_HOST_1,\n                        null\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"INSERT INTO mysql_innodb_cluster_metadata.routers        (host_id, router_name) VALUES (8, '')\",\n            \"exec_time\": 0.152557,\n            \"ok\": {\n              \"last_insert_id\": 8\n            }\n        },\n\n\n\n        // delete all old accounts if necessarry (ConfigGenerator::delete_account_for_all_hosts())\n        {\n            \"stmt.regex\": \"^SELECT host FROM mysql.user WHERE user = '.*'\",\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"type\": \"LONGLONG\",\n                        \"name\": \"COUNT...\"\n                    }\n                ],\n                \"rows\": []  // to keep it simple, just tell Router there's no old accounts to erase\n            }\n        },\n\n        // ConfigGenerator::create_account()\n        {\n            \"stmt.regex\": \"^CREATE USER mysql_router8_[0-9a-z]{12}@'%' IDENTIFIED WITH mysql_native_password AS '\\\\*[0-9A-Z]{40}'\",\n            \"ok\": {}\n        },\n        {\n            \"stmt.regex\": \"^GRANT SELECT ON mysql_innodb_cluster_metadata.* TO mysql_router8_.*@'%'\",\n            \"exec_time\": 8.536869,\n            \"error\": { // here we trigger the failover\n                \"code\": 1290,\n                \"message\": \"The MySQL server is running with the --super-read-only option so it cannot execute this statement\",\n                \"sql_state\": \"HY000\"\n            }\n        },\n        {\n            \"stmt\": \"ROLLBACK\",\n            \"exec_time\": 0.100835,\n            \"ok\": {}\n        },\n        {\n            \"stmt\": \"ROLLBACK\",\n            \"exec_time\": 0.100835,\n            \"ok\": {}\n        },\n        {\n            \"stmt\": \"SELECT member_host, member_port   FROM performance_schema.replication_group_members  /*!80002 ORDER BY member_role */\",\n            \"exec_time\": 0.135675,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"member_host\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"member_port\",\n                        \"type\": \"LONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        process.env.MYSQL_SERVER_MOCK_HOST_1,\n                        process.env.MYSQL_SERVER_MOCK_PORT_1\n                    ],\n                    [\n                        process.env.MYSQL_SERVER_MOCK_HOST_2,\n                        process.env.MYSQL_SERVER_MOCK_PORT_2\n                    ],\n                    [\n                        process.env.MYSQL_SERVER_MOCK_HOST_3,\n                        process.env.MYSQL_SERVER_MOCK_PORT_3\n                    ]\n                ]\n            }\n        }\n    ]\n}\n"
  },
  {
    "path": "tests/component/data/bootstrap_failover_reconfigure_ok.js",
    "content": "{\n    \"stmts\": [\n        {\n            \"stmt\": \"START TRANSACTION\",\n            \"exec_time\": 0.057513,\n            \"ok\": {}\n        },\n        {\n            \"stmt\": \"SELECT h.host_id, h.host_name FROM mysql_innodb_cluster_metadata.routers r JOIN mysql_innodb_cluster_metadata.hosts h    ON r.host_id = h.host_id WHERE r.router_id = 8\",\n            \"exec_time\": 0.175663,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"host_id\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"host_name\",\n                        \"type\": \"VAR_STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"8\",\n                        process.env.MYSQL_SERVER_MOCK_HOST_NAME\n                    ]\n                ]\n            }\n        },\n\n\n\n        // delete all old accounts if necessarry (ConfigGenerator::delete_account_for_all_hosts())\n        {\n            \"stmt.regex\": \"^SELECT host FROM mysql.user WHERE user = '.*'\",\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"type\": \"LONGLONG\",\n                        \"name\": \"COUNT...\"\n                    }\n                ],\n                \"rows\": []  // to keep it simple, just tell Router there's no old accounts to erase\n            }\n        },\n\n        // ConfigGenerator::create_account()\n        {\n            \"stmt.regex\": \"^CREATE USER mysql_router8_[0-9a-z]{12}@'%' IDENTIFIED WITH mysql_native_password AS '\\\\*[0-9A-Z]{40}'\",\n            \"ok\": {}\n        },\n        {\n            \"stmt.regex\": \"^GRANT SELECT ON mysql_innodb_cluster_metadata.* TO mysql_router8_.*@'%'\",\n            \"exec_time\": 8.536869,\n            \"ok\": {}\n        },\n        {\n            \"stmt.regex\": \"^GRANT SELECT ON performance_schema.replication_group_members TO mysql_router8_.*@'%'\",\n            \"exec_time\": 8.584342,\n            \"ok\": {}\n        },\n        {\n            \"stmt.regex\": \"^GRANT SELECT ON performance_schema.replication_group_member_stats TO mysql_router8_.*@'%'\",\n            \"exec_time\": 6.240789,\n            \"ok\": {}\n        },\n\n\n\n        {\n            \"stmt.regex\": \"^UPDATE mysql_innodb_cluster_metadata.routers SET attributes =    JSON_SET\\\\(JSON_SET\\\\(JSON_SET\\\\(JSON_SET\\\\(attributes,    'RWEndpoint', '6446'\\\\),    'ROEndpoint', '6447'\\\\),    'RWXEndpoint', '64460'\\\\),    'ROXEndpoint', '64470'\\\\) WHERE router_id = .*\",\n            \"exec_time\": 0.319936,\n            \"ok\": {}\n        },\n        {\n            \"stmt\": \"COMMIT\",\n            \"exec_time\": 0.106985,\n            \"ok\": {}\n        }\n    ]\n}\n"
  },
  {
    "path": "tests/component/data/bootstrap_failover_reconfigure_ok_3_old_users.js",
    "content": "{\n    \"stmts\": [\n        {\n            \"stmt\": \"START TRANSACTION\",\n            \"exec_time\": 0.057513,\n            \"ok\": {}\n        },\n        {\n            \"stmt\": \"SELECT h.host_id, h.host_name FROM mysql_innodb_cluster_metadata.routers r JOIN mysql_innodb_cluster_metadata.hosts h    ON r.host_id = h.host_id WHERE r.router_id = 8\",\n            \"exec_time\": 0.175663,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"host_id\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"host_name\",\n                        \"type\": \"VAR_STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"8\",\n                        process.env.MYSQL_SERVER_MOCK_HOST_NAME\n                    ]\n                ]\n            }\n        },\n\n\n\n        // ConfigGenerator::delete_account_for_all_hosts() : check if there exist accounts for this Router\n        {\n            \"stmt.regex\": \"^SELECT host FROM mysql.user WHERE user = '.*'\",\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"type\": \"LONGLONG\",\n                        \"name\": \"COUNT...\"\n                    }\n                ],\n                \"rows\": [[\"foo\"], [\"bar\"], [\"baz\"]] // report back that there are 3 accounts\n            }\n        },\n        // ConfigGenerator::delete_account_for_all_hosts() : erase them\n        {\n           \"stmt.regex\": \"^DROP USER mysql_router8_[0-9a-z]{12}@.*'foo',mysql_router8_[0-9a-z]{12}@.*'bar',mysql_router8_[0-9a-z]{12}@.*'baz'\",\n            \"ok\": {}\n        },\n\n\n        // ConfigGenerator::create_account()\n        {\n            \"stmt.regex\": \"^CREATE USER mysql_router8_[0-9a-z]{12}@'%' IDENTIFIED WITH mysql_native_password AS '\\\\*[0-9A-Z]{40}'\",\n            \"ok\": {}\n        },\n        {\n            \"stmt.regex\": \"^GRANT SELECT ON mysql_innodb_cluster_metadata.* TO mysql_router8_.*@'%'\",\n            \"exec_time\": 8.536869,\n            \"ok\": {}\n        },\n        {\n            \"stmt.regex\": \"^GRANT SELECT ON performance_schema.replication_group_members TO mysql_router8_.*@'%'\",\n            \"exec_time\": 8.584342,\n            \"ok\": {}\n        },\n        {\n            \"stmt.regex\": \"^GRANT SELECT ON performance_schema.replication_group_member_stats TO mysql_router8_.*@'%'\",\n            \"exec_time\": 6.240789,\n            \"ok\": {}\n        },\n\n\n\n        {\n            \"stmt.regex\": \"^UPDATE mysql_innodb_cluster_metadata.routers SET attributes =    JSON_SET\\\\(JSON_SET\\\\(JSON_SET\\\\(JSON_SET\\\\(attributes,    'RWEndpoint', '6446'\\\\),    'ROEndpoint', '6447'\\\\),    'RWXEndpoint', '64460'\\\\),    'ROXEndpoint', '64470'\\\\) WHERE router_id = .*\",\n            \"exec_time\": 0.319936,\n            \"ok\": {}\n        },\n        {\n            \"stmt\": \"COMMIT\",\n            \"exec_time\": 0.106985,\n            \"ok\": {}\n        }\n    ]\n}\n"
  },
  {
    "path": "tests/component/data/bootstrap_failover_super_read_only_1.js",
    "content": "{\n    \"stmts\": [\n        {\n            \"stmt\": \"SELECT * FROM mysql_innodb_cluster_metadata.schema_version\",\n            \"exec_time\": 0.232933,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"major\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"minor\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"patch\",\n                        \"type\": \"LONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"1\",\n                        \"0\",\n                        \"2\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT  ((SELECT count(*) FROM mysql_innodb_cluster_metadata.clusters) <= 1  AND (SELECT count(*) FROM mysql_innodb_cluster_metadata.replicasets) <= 1) as has_one_replicaset, (SELECT attributes->>'$.group_replication_group_name' FROM mysql_innodb_cluster_metadata.replicasets)  = @@group_replication_group_name as replicaset_is_ours\",\n            \"exec_time\": 0.424781,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"has_one_replicaset\",\n                        \"type\": \"LONGLONG\"\n                    },\n                    {\n                        \"name\": \"replicaset_is_ours\",\n                        \"type\": \"LONGLONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"1\",\n                        \"1\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT member_state FROM performance_schema.replication_group_members WHERE member_id = @@server_uuid\",\n            \"exec_time\": 0.170235,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"member_state\",\n                        \"type\": \"STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"ONLINE\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT SUM(IF(member_state = 'ONLINE', 1, 0)) as num_onlines, COUNT(*) as num_total FROM performance_schema.replication_group_members\",\n            \"exec_time\": 0.151384,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"num_onlines\",\n                        \"type\": \"NEWDECIMAL\"\n                    },\n                    {\n                        \"name\": \"num_total\",\n                        \"type\": \"LONGLONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"3\",\n                        \"3\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"show status like 'ssl_cipher'\",\n            \"exec_time\": 0.800325,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"Variable_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"Value\",\n                        \"type\": \"VAR_STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"Ssl_cipher\",\n                        \"\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT F.cluster_name, R.replicaset_name, R.topology_type, JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic')) FROM mysql_innodb_cluster_metadata.clusters AS F, mysql_innodb_cluster_metadata.instances AS I, mysql_innodb_cluster_metadata.replicasets AS R WHERE R.replicaset_id = (SELECT replicaset_id FROM mysql_innodb_cluster_metadata.instances WHERE mysql_server_uuid = @@server_uuid)AND I.replicaset_id = R.replicaset_id AND R.cluster_id = F.cluster_id\",\n            \"exec_time\": 0.418633,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"cluster_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"replicaset_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"topology_type\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic'))\",\n                        \"type\": \"LONGBLOB\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        process.env.MYSQL_SERVER_MOCK_CLUSTER_NAME,\n                        \"myreplicaset\",\n                        \"pm\",\n                        \"127.0.0.1:13001\"\n                    ],\n                    [\n                        process.env.MYSQL_SERVER_MOCK_CLUSTER_NAME,\n                        \"myreplicaset\",\n                        \"pm\",\n                        \"127.0.0.1:13002\"\n                    ],\n                    [\n                        process.env.MYSQL_SERVER_MOCK_CLUSTER_NAME,\n                        \"myreplicaset\",\n                        \"pm\",\n                        \"127.0.0.1:13003\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"START TRANSACTION\",\n            \"exec_time\": 0.082893,\n            \"ok\": {}\n        },\n        {\n            \"stmt.regex\": \"^SELECT host_id, host_name, ip_address FROM mysql_innodb_cluster_metadata.hosts WHERE host_name = '..*' LIMIT 1\",\n            \"exec_time\": 0.296962,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"host_id\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"host_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"ip_address\",\n                        \"type\": \"VAR_STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"8\",\n                        process.env.MYSQL_SERVER_MOCK_HOST_1,\n                        null\n                    ]\n                ]\n            }\n        },\n\n        // this is the SQL failure which will induce the bootstrap failover\n        {\n            \"stmt\": \"INSERT INTO mysql_innodb_cluster_metadata.routers        (host_id, router_name) VALUES (8, '')\",\n            \"exec_time\": 0.152557,\n            \"error\": {\n                \"code\": 1290,\n                \"message\": \"The MySQL server is running with the --super-read-only option so it cannot execute this statement\",\n                \"sql_state\": \"HY000\"\n            }\n        },\n\n        // Router will roll back transaction as a result ...\n        {\n            \"stmt\": \"ROLLBACK\",\n            \"exec_time\": 0.100835,\n            \"ok\": {}\n        },\n\n        // but still query for other nodes, before failing over\n        {\n            \"stmt\": \"SELECT member_host, member_port   FROM performance_schema.replication_group_members  /*!80002 ORDER BY member_role */\",\n            \"exec_time\": 0.135675,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"member_host\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"member_port\",\n                        \"type\": \"LONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        process.env.MYSQL_SERVER_MOCK_HOST_1,\n                        process.env.MYSQL_SERVER_MOCK_PORT_1\n                    ],\n                    [\n                        process.env.MYSQL_SERVER_MOCK_HOST_2, // it will failover to this one\n                        process.env.MYSQL_SERVER_MOCK_PORT_2\n                    ],\n                    [\n                        process.env.MYSQL_SERVER_MOCK_HOST_3,\n                        process.env.MYSQL_SERVER_MOCK_PORT_3\n                    ]\n                ]\n            }\n        }\n    ]\n}\n"
  },
  {
    "path": "tests/component/data/bootstrap_failover_super_read_only_2.js",
    "content": "({\n    \"stmts\": [\n        {\n            \"stmt\": \"START TRANSACTION\",\n            \"exec_time\": 0.061723,\n            \"ok\": {}\n        },\n        {\n            \"stmt.regex\": \"^SELECT host_id, host_name, ip_address FROM mysql_innodb_cluster_metadata.hosts WHERE host_name = '.*' LIMIT 1\",\n            \"exec_time\": 0.237026,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"host_id\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"host_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"ip_address\",\n                        \"type\": \"VAR_STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"8\",\n                        \"127.0.0.1\",\n                        null\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"INSERT INTO mysql_innodb_cluster_metadata.routers        (host_id, router_name) VALUES (8, '')\",\n            \"exec_time\": 0.283136,\n            \"ok\": {\n                \"last_insert_id\": 8\n            }\n        },\n\n\n\n        // delete all old accounts if necessarry (ConfigGenerator::delete_account_for_all_hosts())\n        {\n            \"stmt.regex\": \"^SELECT host FROM mysql.user WHERE user = '.*'\",\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"type\": \"LONGLONG\",\n                        \"name\": \"COUNT...\"\n                    }\n                ],\n                \"rows\": []  // to keep it simple, just tell Router there's no old accounts to erase\n            }\n        },\n\n        // ConfigGenerator::create_account()\n        {\n            \"stmt.regex\": \"^CREATE USER mysql_router8_[0-9a-z]{12}@'%' IDENTIFIED WITH mysql_native_password AS '\\\\*[0-9A-Z]{40}'\",\n            \"ok\": {}\n        },\n        {\n            \"stmt.regex\": \"^GRANT SELECT ON mysql_innodb_cluster_metadata.* TO mysql_router8_.*@'%'\",\n            \"exec_time\": 8.536869,\n            \"ok\": {}\n        },\n        {\n            \"stmt.regex\": \"^GRANT SELECT ON performance_schema.replication_group_members TO mysql_router8_.*@'%'\",\n            \"exec_time\": 8.584342,\n            \"ok\": {}\n        },\n        {\n            \"stmt.regex\": \"^GRANT SELECT ON performance_schema.replication_group_member_stats TO mysql_router8_.*@'%'\",\n            \"exec_time\": 6.240789,\n            \"ok\": {}\n        },\n\n\n\n        {\n            \"stmt\": \"UPDATE mysql_innodb_cluster_metadata.routers SET attributes =    JSON_SET(JSON_SET(JSON_SET(JSON_SET(attributes,    'RWEndpoint', '6446'),    'ROEndpoint', '6447'),    'RWXEndpoint', '64460'),    'ROXEndpoint', '64470') WHERE router_id = 8\",\n            \"exec_time\": 0.277948,\n            \"ok\": {}\n        },\n        {\n            \"stmt\": \"COMMIT\",\n            \"exec_time\": 0.090678,\n            \"ok\": {}\n        }\n    ]\n})\n"
  },
  {
    "path": "tests/component/data/bootstrap_failover_super_read_only_dead_2nd_1.js",
    "content": "{\n    \"stmts\": [\n        {\n            \"stmt\": \"SELECT * FROM mysql_innodb_cluster_metadata.schema_version\",\n            \"exec_time\": 0.232933,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"major\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"minor\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"patch\",\n                        \"type\": \"LONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"1\",\n                        \"0\",\n                        \"2\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT  ((SELECT count(*) FROM mysql_innodb_cluster_metadata.clusters) <= 1  AND (SELECT count(*) FROM mysql_innodb_cluster_metadata.replicasets) <= 1) as has_one_replicaset, (SELECT attributes->>'$.group_replication_group_name' FROM mysql_innodb_cluster_metadata.replicasets)  = @@group_replication_group_name as replicaset_is_ours\",\n            \"exec_time\": 0.424781,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"has_one_replicaset\",\n                        \"type\": \"LONGLONG\"\n                    },\n                    {\n                        \"name\": \"replicaset_is_ours\",\n                        \"type\": \"LONGLONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"1\",\n                        \"1\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT member_state FROM performance_schema.replication_group_members WHERE member_id = @@server_uuid\",\n            \"exec_time\": 0.170235,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"member_state\",\n                        \"type\": \"STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"ONLINE\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT SUM(IF(member_state = 'ONLINE', 1, 0)) as num_onlines, COUNT(*) as num_total FROM performance_schema.replication_group_members\",\n            \"exec_time\": 0.151384,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"num_onlines\",\n                        \"type\": \"NEWDECIMAL\"\n                    },\n                    {\n                        \"name\": \"num_total\",\n                        \"type\": \"LONGLONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"3\",\n                        \"3\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"show status like 'ssl_cipher'\",\n            \"exec_time\": 0.800325,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"Variable_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"Value\",\n                        \"type\": \"VAR_STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"Ssl_cipher\",\n                        \"\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT F.cluster_name, R.replicaset_name, R.topology_type, JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic')) FROM mysql_innodb_cluster_metadata.clusters AS F, mysql_innodb_cluster_metadata.instances AS I, mysql_innodb_cluster_metadata.replicasets AS R WHERE R.replicaset_id = (SELECT replicaset_id FROM mysql_innodb_cluster_metadata.instances WHERE mysql_server_uuid = @@server_uuid)AND I.replicaset_id = R.replicaset_id AND R.cluster_id = F.cluster_id\",\n            \"exec_time\": 0.418633,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"cluster_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"replicaset_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"topology_type\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic'))\",\n                        \"type\": \"LONGBLOB\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        process.env.MYSQL_SERVER_MOCK_CLUSTER_NAME,\n                        \"myreplicaset\",\n                        \"pm\",\n                        \"127.0.0.1:13001\"\n                    ],\n                    [\n                        process.env.MYSQL_SERVER_MOCK_CLUSTER_NAME,\n                        \"myreplicaset\",\n                        \"pm\",\n                        \"127.0.0.1:13002\"\n                    ],\n                    [\n                        process.env.MYSQL_SERVER_MOCK_CLUSTER_NAME,\n                        \"myreplicaset\",\n                        \"pm\",\n                        \"127.0.0.1:13003\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"START TRANSACTION\",\n            \"exec_time\": 0.082893,\n            \"ok\": {}\n        },\n        {\n            \"stmt.regex\": \"^SELECT host_id, host_name, ip_address FROM mysql_innodb_cluster_metadata.hosts WHERE host_name = '..*' LIMIT 1\",\n            \"exec_time\": 0.296962,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"host_id\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"host_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"ip_address\",\n                        \"type\": \"VAR_STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"8\",\n                        process.env.MYSQL_SERVER_MOCK_HOST_1,\n                        null\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"INSERT INTO mysql_innodb_cluster_metadata.routers        (host_id, router_name) VALUES (8, '')\",\n            \"exec_time\": 0.152557,\n            \"ok\": {\n                \"last_insert_id\": 8\n            }\n        },\n\n        // ConfigGenerator::delete_account_for_all_hosts()\n        {\n            \"stmt.regex\": \"^SELECT host FROM mysql.user WHERE user = '.*'\",\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"type\": \"LONGLONG\",\n                        \"name\": \"COUNT...\"\n                    }\n                ],\n                \"rows\": []  // to keep it simple, just tell Router there's no old accounts to erase\n            }\n        },\n\n        // this SQL will trigger the failover\n        {   // ConfigGenerator::generate_compliant_password()\n            \"stmt.regex\": \"^CREATE USER mysql_router8_[0-9a-z]{12}@'%' IDENTIFIED WITH mysql_native_password AS '\\\\*[0-9A-Z]{40}'\",\n            \"error\": {\n                \"code\": 1290,\n                \"message\": \"The MySQL server is running with the --super-read-only option so it cannot execute this statement\",\n                \"sql_state\": \"HY000\"\n            }\n        },\n\n        {\n            \"stmt\": \"ROLLBACK\",\n            \"exec_time\": 0.100835,\n            \"ok\": {}\n        },\n        {\n            \"stmt\": \"ROLLBACK\",\n            \"exec_time\": 0.100835,\n            \"ok\": {}\n        },\n        {\n            \"stmt\": \"SELECT member_host, member_port   FROM performance_schema.replication_group_members  /*!80002 ORDER BY member_role */\",\n            \"exec_time\": 0.135675,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"member_host\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"member_port\",\n                        \"type\": \"LONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        process.env.MYSQL_SERVER_MOCK_HOST_1,\n                        process.env.MYSQL_SERVER_MOCK_PORT_1\n                    ],\n                    [\n                        process.env.MYSQL_SERVER_MOCK_HOST_2,\n                        process.env.MYSQL_SERVER_MOCK_PORT_2\n                    ],\n                    [\n                        process.env.MYSQL_SERVER_MOCK_HOST_3,\n                        process.env.MYSQL_SERVER_MOCK_PORT_3\n                    ]\n                ]\n            }\n        }\n    ]\n}\n"
  },
  {
    "path": "tests/component/data/bootstrap_failover_super_read_only_delete_user.js",
    "content": "{\n    \"stmts\": [\n        {\n            \"stmt\": \"SELECT * FROM mysql_innodb_cluster_metadata.schema_version\",\n            \"exec_time\": 0.232933,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"major\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"minor\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"patch\",\n                        \"type\": \"LONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"1\",\n                        \"0\",\n                        \"2\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT  ((SELECT count(*) FROM mysql_innodb_cluster_metadata.clusters) <= 1  AND (SELECT count(*) FROM mysql_innodb_cluster_metadata.replicasets) <= 1) as has_one_replicaset, (SELECT attributes->>'$.group_replication_group_name' FROM mysql_innodb_cluster_metadata.replicasets)  = @@group_replication_group_name as replicaset_is_ours\",\n            \"exec_time\": 0.424781,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"has_one_replicaset\",\n                        \"type\": \"LONGLONG\"\n                    },\n                    {\n                        \"name\": \"replicaset_is_ours\",\n                        \"type\": \"LONGLONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"1\",\n                        \"1\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT member_state FROM performance_schema.replication_group_members WHERE member_id = @@server_uuid\",\n            \"exec_time\": 0.170235,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"member_state\",\n                        \"type\": \"STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"ONLINE\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT SUM(IF(member_state = 'ONLINE', 1, 0)) as num_onlines, COUNT(*) as num_total FROM performance_schema.replication_group_members\",\n            \"exec_time\": 0.151384,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"num_onlines\",\n                        \"type\": \"NEWDECIMAL\"\n                    },\n                    {\n                        \"name\": \"num_total\",\n                        \"type\": \"LONGLONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"3\",\n                        \"3\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"show status like 'ssl_cipher'\",\n            \"exec_time\": 0.800325,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"Variable_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"Value\",\n                        \"type\": \"VAR_STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"Ssl_cipher\",\n                        \"\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT F.cluster_name, R.replicaset_name, R.topology_type, JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic')) FROM mysql_innodb_cluster_metadata.clusters AS F, mysql_innodb_cluster_metadata.instances AS I, mysql_innodb_cluster_metadata.replicasets AS R WHERE R.replicaset_id = (SELECT replicaset_id FROM mysql_innodb_cluster_metadata.instances WHERE mysql_server_uuid = @@server_uuid)AND I.replicaset_id = R.replicaset_id AND R.cluster_id = F.cluster_id\",\n            \"exec_time\": 0.418633,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"cluster_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"replicaset_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"topology_type\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic'))\",\n                        \"type\": \"LONGBLOB\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        process.env.MYSQL_SERVER_MOCK_CLUSTER_NAME,\n                        \"myreplicaset\",\n                        \"pm\",\n                        \"127.0.0.1:13001\"\n                    ],\n                    [\n                        process.env.MYSQL_SERVER_MOCK_CLUSTER_NAME,\n                        \"myreplicaset\",\n                        \"pm\",\n                        \"127.0.0.1:13002\"\n                    ],\n                    [\n                        process.env.MYSQL_SERVER_MOCK_CLUSTER_NAME,\n                        \"myreplicaset\",\n                        \"pm\",\n                        \"127.0.0.1:13003\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"START TRANSACTION\",\n            \"exec_time\": 0.082893,\n            \"ok\": {}\n        },\n        {\n            \"stmt.regex\": \"^SELECT host_id, host_name, ip_address FROM mysql_innodb_cluster_metadata.hosts WHERE host_name = '..*' LIMIT 1\",\n            \"exec_time\": 0.296962,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"host_id\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"host_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"ip_address\",\n                        \"type\": \"VAR_STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"8\",\n                        process.env.MYSQL_SERVER_MOCK_HOST_1,\n                        null\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"INSERT INTO mysql_innodb_cluster_metadata.routers        (host_id, router_name) VALUES (8, '')\",\n            \"exec_time\": 0.152557,\n            \"ok\": {\n                \"last_insert_id\": 8\n            }\n        },\n\n        // ConfigGenerator::delete_account_for_all_hosts() : check if there exist accounts for this Router\n        {\n            \"stmt.regex\": \"^SELECT host FROM mysql.user WHERE user = '.*'\",\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"type\": \"LONGLONG\",\n                        \"name\": \"COUNT...\"\n                    }\n                ],\n                \"rows\": [[\"foo\"], [\"bar\"], [\"baz\"]] // report back that there are 3 accounts\n            }\n        },\n        // ConfigGenerator::delete_account_for_all_hosts() : erase them\n        {\n           \"stmt.regex\": \"^DROP USER mysql_router8_[0-9a-z]{12}@.*'foo',mysql_router8_[0-9a-z]{12}@.*'bar',mysql_router8_[0-9a-z]{12}@.*'baz'\",\n            \"error\": {\n                \"code\": 1290,\n                \"message\": \"The MySQL server is running with the --super-read-only option so it cannot execute this statement\",\n                \"sql_state\": \"HY000\"\n            }\n        },\n\n        // rollback\n        {\n            \"stmt\": \"ROLLBACK\",\n            \"ok\": {}\n        },\n\n        // failover: GrAwareDecorator::fetch_group_replication_hosts()\n        {\n            \"stmt\": \"SELECT member_host, member_port   FROM performance_schema.replication_group_members  /*!80002 ORDER BY member_role */\",\n            \"exec_time\": 0.135675,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"member_host\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"member_port\",\n                        \"type\": \"LONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        process.env.MYSQL_SERVER_MOCK_HOST_1,\n                        process.env.MYSQL_SERVER_MOCK_PORT_1\n                    ],\n                    [\n                        process.env.MYSQL_SERVER_MOCK_HOST_2,\n                        process.env.MYSQL_SERVER_MOCK_PORT_2\n                    ],\n                    [\n                        process.env.MYSQL_SERVER_MOCK_HOST_3,\n                        process.env.MYSQL_SERVER_MOCK_PORT_3\n                    ]\n                ]\n            }\n        }\n    ]\n}\n"
  },
  {
    "path": "tests/component/data/bootstrap_report_host.js",
    "content": "({\n  \"stmts\": [\n    {\n      \"stmt\": \"SELECT * FROM mysql_innodb_cluster_metadata.schema_version\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"major\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"minor\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"patch\"\n          }\n        ],\n        \"rows\": [\n          [\n            1,\n            0,\n            1\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT  ((SELECT count(*) FROM mysql_innodb_cluster_metadata.clusters) <= 1  AND (SELECT count(*) FROM mysql_innodb_cluster_metadata.replicasets) <= 1) as has_one_replicaset, (SELECT attributes->>'$.group_replication_group_name' FROM mysql_innodb_cluster_metadata.replicasets)  = @@group_replication_group_name as replicaset_is_ours\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"has_one_replicaset\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"replicaset_is_ours\"\n          }\n        ],\n        \"rows\": [\n          [\n            1,\n            1\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT member_state FROM performance_schema.replication_group_members WHERE member_id = @@server_uuid\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"STRING\",\n            \"name\": \"member_state\"\n          }\n        ],\n        \"rows\": [\n          [\n            \"ONLINE\"\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT SUM(IF(member_state = 'ONLINE', 1, 0)) as num_onlines, COUNT(*) as num_total FROM performance_schema.replication_group_members\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"num_onlines\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"num_total\"\n          }\n        ],\n        \"rows\": [\n          [\n            3,\n            3\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"show status like 'ssl_cipher'\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"STRING\",\n            \"name\": \"Variable_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"Value\"\n          }\n        ],\n        \"rows\": [\n          [\n            \"Ssl_cipher\",\n            \"\"\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"SELECT F.cluster_name, R.replicaset_name, R.topology_type, JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic')) FROM mysql_innodb_cluster_metadata.clusters AS F, mysql_innodb_cluster_metadata.instances AS I, mysql_innodb_cluster_metadata.replicasets AS R WHERE R.replicaset_id = (SELECT replicaset_id FROM mysql_innodb_cluster_metadata.instances WHERE mysql_server_uuid = @@server_uuid)AND I.replicaset_id = R.replicaset_id AND R.cluster_id = F.cluster_id\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"cluster_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"replicaset_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"topology_type\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"JSON_UNQUOTE(JSON_EXTRACT(I.addresses, '$.mysqlClassic'))\"\n          }\n        ],\n        \"rows\": [\n          [\n            \"mycluster\",\n            \"default\",\n            \"pm\",\n            \"localhost:5500\"\n          ],\n          [\n            \"mycluster\",\n            \"default\",\n            \"pm\",\n            \"localhost:5510\"\n          ],\n          [\n            \"mycluster\",\n            \"default\",\n            \"pm\",\n            \"localhost:5520\"\n          ]\n        ]\n      }\n    },\n    {\n      \"stmt\": \"START TRANSACTION\",\n      \"ok\": {}\n    },\n    {                                                                 // this is what we test (--report-host value) ---vvvvvvvvvvvv\n      \"stmt.regex\": \"SELECT host_id, host_name, ip_address FROM mysql_innodb_cluster_metadata.hosts WHERE host_name = 'host.foo.bar' LIMIT 1\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"STRING\",\n            \"name\": \"host_id\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"host_name\"\n          },\n          {\n            \"type\": \"STRING\",\n            \"name\": \"ip_address\"\n          }\n        ]\n      }\n    },\n    {                                                           // this is what we test (--report-host value) ---vvvvvvvvvvvv\n      \"stmt\": \"INSERT INTO mysql_innodb_cluster_metadata.hosts        (host_name, location, attributes) VALUES ('host.foo.bar', '',          JSON_OBJECT('registeredFrom', 'mysql-router'))\",\n      \"ok\": {\n        \"last_insert_id\": 1\n      }\n    },\n    {\n      \"stmt.regex\": \"^INSERT INTO mysql_innodb_cluster_metadata.routers.*\",\n      \"ok\": {\n        \"last_insert_id\": 1\n      }\n    },\n\n\n\n    // delete all old accounts if necessarry (ConfigGenerator::delete_account_for_all_hosts())\n    {\n      \"stmt.regex\": \"^SELECT host FROM mysql.user WHERE user = '.*'\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"COUNT...\"\n          }\n        ],\n        \"rows\": []  // to keep it simple, just tell Router there's no old accounts to erase\n      }\n    },\n\n\n\n    // ConfigGenerator::create_account()\n    {\n      \"stmt.regex\": \"^CREATE USER mysql_router1_[0-9a-z]{12}@'%' IDENTIFIED WITH mysql_native_password AS '\\\\*[0-9A-Z]{40}'\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"^GRANT SELECT ON mysql_innodb_cluster_metadata.*\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"^GRANT SELECT ON performance_schema.*\",\n      \"ok\": {}\n    },\n    {\n      \"stmt.regex\": \"^GRANT SELECT ON performance_schema.*\",\n      \"ok\": {}\n    },\n\n\n\n    {\n      \"stmt.regex\": \"^UPDATE mysql_innodb_cluster_metadata\\\\.routers.*\",\n      \"ok\": {}\n    },\n    {\n      \"stmt\": \"COMMIT\",\n      \"ok\": {}\n    }\n  ]\n})\n"
  },
  {
    "path": "tests/component/data/bootstrap_unsupported_schema_version.js",
    "content": "({\n  \"stmts\": [\n    {\n      \"stmt\": \"SELECT * FROM mysql_innodb_cluster_metadata.schema_version\",\n      \"result\": {\n        \"columns\": [\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"major\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"minor\"\n          },\n          {\n            \"type\": \"LONGLONG\",\n            \"name\": \"patch\"\n          }\n        ],\n        \"rows\": [\n          [\n            0,\n            0,\n            1\n          ]\n        ]\n      }\n    }\n  ]\n})\n"
  },
  {
    "path": "tests/component/data/js_test_empty_file.js",
    "content": ""
  },
  {
    "path": "tests/component/data/js_test_nesting.js",
    "content": "var path = require(\"path\");\n\n// the test-modules are not in the standard paths\n//\n// the first one should be local_modules/\n// test_modules/ is just right next to it\nmodule.paths.push(path.join(module.paths[0], \"..\", \"test_modules\"));\n\nrequire(\"test-require-nesting-1\")\n"
  },
  {
    "path": "tests/component/data/js_test_parse_error.js",
    "content": "[\n"
  },
  {
    "path": "tests/component/data/js_test_require.js",
    "content": "var path = require(\"path\");\n\n// the test-modules are not in the standard paths\n//\n// the first one should be local_modules/\n// test_modules/ is just right next to it\nmodule.paths.push(path.join(module.paths[0], \"..\", \"test_modules\"));\n\nvar m_direct = require(\"test-require-direct\");\nvar m_dir_with_indexjs = require(\"test-require-dir-with-indexjs\");\nvar m_dir_with_packagejson = require(\"test-require-dir-with-packagejson\");\n// 'require' the same module again. It shouldn't trigger a reload nor reset the counter\nvar m_no_reload = require(\"test-require-direct\");\n\n({\n  stmts: function(stmt) {\n    // all results share the same column-def\n    var columns = {\n      columns: [\n        {\n          name: \"me\",\n          type: \"STRING\"\n        }\n      ]\n    };\n\n    if (stmt === \"direct\") {\n      return {\n        result: Object.assign({\n          rows: [\n            [ m_direct.me ]\n          ]\n        }, columns)\n      }\n    } else if (stmt === \"dir-with-indexjs\") {\n      return {\n        result: Object.assign({\n          rows: [\n            [ m_dir_with_indexjs.me ]\n          ]\n        }, columns)\n      }\n    } else if (stmt === \"dir-with-packagejson\") {\n      return {\n        result: Object.assign({\n          rows: [\n            [ m_dir_with_packagejson.me ]\n          ]\n        }, columns)\n      }\n    } else if (stmt === \"no-reload-0\") {\n      return {\n        result: Object.assign({\n          rows: [\n            [ m_direct.counter().toString() ]\n          ]\n        }, columns)\n      }\n    } else if (stmt === \"no-reload-1\") {\n      return {\n        result: Object.assign({\n          rows: [\n            [ m_no_reload.counter().toString() ]\n          ]\n        }, columns)\n      }\n    } else {\n      return {\n        error: {\n          code: 1164,\n          message: \"don't know about \" + stmt\n        }\n      }\n    }\n  }\n})\n"
  },
  {
    "path": "tests/component/data/js_test_stmts_is_array.js",
    "content": "// ensure that 'stmts' being array works\n\n({\n  stmts: [\n    {\n      ok: {}\n    }\n  ]\n})\n"
  },
  {
    "path": "tests/component/data/js_test_stmts_is_coroutine.js",
    "content": "// ensure that 'stmts' can be an 'thread'\n\nfunction result_generator() {\n  return new Duktape.Thread(function(stmt) {\n    var yield = Duktape.Thread.yield;\n\n    while (true) {\n      // return ok for every statement received\n      stmt = yield({\n        ok: {}\n      });\n    }\n  });\n}\n\n({\n  stmts: result_generator()\n})\n"
  },
  {
    "path": "tests/component/data/js_test_stmts_is_empty.js",
    "content": "({\n  stmts: []\n})\n"
  },
  {
    "path": "tests/component/data/js_test_stmts_is_function.js",
    "content": "// test that 'stmts' can be an function\n\n({\n  stmts: function(stmt) {\n    // return ok for every statement received\n    return {\n      ok: {}\n    }\n  }\n})\n"
  },
  {
    "path": "tests/component/data/js_test_stmts_is_string.js",
    "content": "// ensure that 'stmts' being something else than function|thread|array triggers an error\n\n({\n  stmts: \"this-should-fail\"\n})\n"
  },
  {
    "path": "tests/component/data/js_test_stmts_result_has_infinity.js",
    "content": "// ensure that 'stmts.result.columns[].decimal = Infinity' throws\n\n({\n  stmts: [\n    {\n      result: {\n        columns: [\n          {\n            name: \"foo\",\n            type: \"STRING\",\n            decimals: Infinity\n          }\n        ]\n      }\n    }\n  ]\n})\n"
  },
  {
    "path": "tests/component/data/js_test_stmts_result_has_negative_int.js",
    "content": "// ensure that 'stmts.result.columns[].decimal = -1' throws\n\n({\n  stmts: [\n    {\n      result: {\n        columns: [\n          {\n            name: \"foo\",\n            type: \"STRING\",\n            decimals: -1\n          }\n        ]\n      }\n    }\n  ]\n})\n"
  },
  {
    "path": "tests/component/data/js_test_stmts_result_has_repeat.js",
    "content": "// ensure that 'stmts.result.columns[].repeat' throws\n\n({\n  stmts: [\n    {\n      result: {\n        columns: [\n          {\n            name: \"foo\",\n            type: \"STRING\",\n            repeat: 25\n          }\n        ]\n      }\n    }\n  ]\n})\n"
  },
  {
    "path": "tests/component/data/local_modules/common_statements.js",
    "content": "var defaults = {\n  version_comment: \"community\",\n  account_user: \"root\",\n  metadata_version: [1, 0, 1],\n  exec_time: 0.0,\n  group_replication_single_primary_mode: 1,\n  // array-of-array\n  // - server-uuid\n  // - hostname\n  // - port\n  // - state\n  group_replication_membership: [],\n  port: mysqld.session.port\n};\n\nfunction ensure_type(options, field, expected_type) {\n  var current_type = typeof(options[field]);\n\n  if (expected_type === \"array\") {\n    tested_type = \"object\";\n  } else {\n    tested_type = expected_type;\n  }\n\n  if (current_type !== tested_type) throw \"expected \" + field + \" to be a \" + expected_type + \", got \" + current_type;\n  if (expected_type === \"array\") {\n    if (!Array.isArray(options[field])) throw \"expected \" + field + \" to be a \" + expected_type + \", got \" + current_type;\n  }\n}\n\nexports.get = function get(k) {\n  // let's hope the 2nd arg is an object\n  var options = Object.assign(defaults, arguments.length === 1 ? {} : arguments[1]);\n\n  ensure_type(options, \"version_comment\", \"string\");\n  ensure_type(options, \"account_user\", \"string\");\n  ensure_type(options, \"metadata_version\", \"array\");\n  ensure_type(options, \"exec_time\", \"number\");\n  ensure_type(options, \"port\", \"number\");\n\n  var statements = {\n    mysql_client_select_version_comment: {\n      stmt: \"select @@version_comment limit 1\",\n      exec_time: options[\"exec_time\"],\n      result: {\n        columns: [\n          {\n            name: \"@@version_comment\",\n            type: \"STRING\"\n          }\n        ],\n        rows: [\n          [ options[\"version_comment\"] ]\n        ]\n      }\n    },\n    mysql_client_select_user: {\n      stmt: \"select USER()\",\n      result: {\n        columns: [\n          {\n            name: \"USER()\",\n            type: \"STRING\"\n          }\n        ],\n        rows: [\n          [ options[\"account_user\"] ]\n        ]\n      }\n    },\n    select_port: {\n      stmt: \"select @@port\",\n      result: {\n        columns: [\n          {\n            name: \"@@port\",\n            type: \"LONG\"\n          }\n        ],\n        rows: [\n          [ options[\"port\"] ]\n        ]\n      }\n    },\n    router_select_schema_version: {\n      stmt: \"SELECT * FROM mysql_innodb_cluster_metadata.schema_version\",\n      exec_time: options[\"exec_time\"],\n      result: {\n        columns: [\n          {\n            type: \"LONGLONG\",\n            name: \"major\"\n          },\n          {\n            type: \"LONGLONG\",\n            name: \"minor\"\n          },\n          {\n            type: \"LONGLONG\",\n            name: \"patch\"\n          }\n        ],\n        rows: [\n          options[\"metadata_version\"]\n        ]\n      }\n    },\n    router_select_group_membership_with_primary_mode: {\n      stmt: \"SELECT member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode FROM performance_schema.replication_group_members WHERE channel_name = 'group_replication_applier'\",\n      exec_time: options[\"exec_time\"],\n      result: {\n        columns: [\n          {\n              \"name\": \"member_id\",\n              \"type\": \"STRING\"\n          },\n          {\n              \"name\": \"member_host\",\n              \"type\": \"STRING\"\n          },\n          {\n              \"name\": \"member_port\",\n              \"type\": \"LONG\"\n          },\n          {\n              \"name\": \"member_state\",\n              \"type\": \"STRING\"\n          },\n          {\n              \"name\": \"@@group_replication_single_primary_mode\",\n              \"type\": \"LONGLONG\"\n          }\n        ],\n        rows: options[\"group_replication_membership\"].map(function(currentValue) {\n          return currentValue.concat([ options[\"group_replication_single_primary_mode\"] ]);\n        }),\n      }\n    },\n    router_select_group_replication_primary_member: {\n      \"stmt\": \"show status like 'group_replication_primary_member'\",\n      \"result\": {\n        \"columns\": [\n          {\n              \"name\": \"Variable_name\",\n              \"type\": \"VAR_STRING\"\n          },\n          {\n              \"name\": \"Value\",\n              \"type\": \"VAR_STRING\"\n          }\n        ],\n        \"rows\": [\n          [\n              \"group_replication_primary_member\",\n              options[\"group_replication_primary_member\"]\n          ]\n        ]\n      }\n    },\n  };\n\n  return statements[k];\n}\n"
  },
  {
    "path": "tests/component/data/local_modules/gr_memberships.js",
    "content": "var uuid_v4 = function() {\n  return \"00000000-0000-4000-8000-000000000000\".replace(/0/g, function() {\n      return (0|Math.random()*16).toString(16)}\n  );\n}\n\nexports.single_host = function(host, port_and_state) {\n  return port_and_state.map(function (current_value) {\n    return [ uuid_v4(), host, current_value[0], current_value[1] ];\n  });\n};\n"
  },
  {
    "path": "tests/component/data/local_modules/itertools.js",
    "content": "var log = new Duktape.Logger()\n\nexports.take = function (times, iter) {\n  return new Duktape.Thread(function() {\n    var yield = Duktape.Thread.yield;\n    var resume = Duktape.Thread.resume;\n\n    var rounds = 0;\n    while (rounds++ < times) {\n      var v = resume(iter);\n\n      yield(v);\n    }\n  });\n}\n\nexports.repeat = function (obj) {\n  return new Duktape.Thread(function() {\n    var yield = Duktape.Thread.yield;\n\n    while (true) yield(obj);\n  });\n}\n\n// collect a iterable into a array\nexports.collect = function (iter) {\n  var resume = Duktape.Thread.resume;\n\n  var ar = [];\n\n  while(true) {\n    v = resume(iter);\n\n    if (v === undefined) break;\n\n    ar.push(v);\n  }\n\n  return ar;\n}\n\nexports.chain = function (iters) {\n  return new Duktape.Thread(function() {\n    var yield = Duktape.Thread.yield;\n    var resume = Duktape.Thread.resume;\n\n    log.info(\".chain()\")\n\n    // we can't use for-in here, as it doesn't operate on ndx-order\n    // we can't use .forEach() is duktape doesn't allow yield in it\n    for (var ndx = 0; ndx < iters.length; ndx++) {\n      var iter = iters[ndx];\n      while (true) {\n        var elem = resume(iter);\n\n        if (elem === undefined) break;\n\n        yield(elem);\n      }\n    }\n  });\n}\n\nexports.cycle = function (iter) {\n  return new Duktape.Thread(function() {\n    var yield = Duktape.Thread.yield;\n    var resume = Duktape.Thread.resume;\n    var buffer = [];\n\n    while (true) {\n      var elem = resume(iter);\n\n      if (elem === undefined) break;\n\n      yield(elem);\n      buffer.push(elem);\n    }\n\n    if (buffer.length === 0) return;\n\n    var ndx = 0;\n    while (true) {\n      if (ndx >= buffer.length) ndx = 0;\n      log.info(\".cycle()\")\n      yield(buffer[ndx++]);\n    }\n  });\n}\n\n// return an iterable for an array\nexports.iter_arr = function (arr) {\n  return new Duktape.Thread(function() {\n    var yield = Duktape.Thread.yield;\n\n    for (var ndx = 0; ndx < arr.length; ndx++) {\n      yield(arr[ndx]);\n    }\n  });\n}\n\n"
  },
  {
    "path": "tests/component/data/metadata_1_node.js",
    "content": "{\n    \"stmts\": [\n        {\n            \"stmt\": \"SELECT R.replicaset_name, I.mysql_server_uuid, I.role, I.weight, I.version_token, H.location, I.addresses->>'$.mysqlClassic', I.addresses->>'$.mysqlX' FROM mysql_innodb_cluster_metadata.clusters AS F JOIN mysql_innodb_cluster_metadata.replicasets AS R ON F.cluster_id = R.cluster_id JOIN mysql_innodb_cluster_metadata.instances AS I ON R.replicaset_id = I.replicaset_id JOIN mysql_innodb_cluster_metadata.hosts AS H ON I.host_id = H.host_id WHERE F.cluster_name = 'test';\",\n            \"exec_time\": 1.862005,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"replicaset_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"mysql_server_uuid\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"role\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"weight\",\n                        \"type\": \"FLOAT\"\n                    },\n                    {\n                        \"name\": \"version_token\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"location\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"I.addresses->>'$.mysqlClassic'\",\n                        \"type\": \"LONGBLOB\"\n                    },\n                    {\n                        \"name\": \"I.addresses->>'$.mysqlX'\",\n                        \"type\": \"LONGBLOB\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"default\",\n                        \"8502d47b-e0f2-11e7-8530-080027c84a43\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.PRIMARY_HOST,\n                        \"localhost:33100\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"show status like 'group_replication_primary_member'\",\n            \"exec_time\": 3.374584,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"Variable_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"Value\",\n                        \"type\": \"VAR_STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"group_replication_primary_member\",\n                        \"8502d47b-e0f2-11e7-8530-080027c84a43\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode FROM performance_schema.replication_group_members WHERE channel_name = 'group_replication_applier'\",\n            \"exec_time\": 1.422041,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"member_id\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"member_host\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"member_port\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"member_state\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"@@group_replication_single_primary_mode\",\n                        \"type\": \"LONGLONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"8502d47b-e0f2-11e7-8530-080027c84a43\",\n                        \"jacek-VirtualBox\",\n                        process.env.PRIMARY_HOST,\n                        \"ONLINE\",\n                        \"1\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT R.replicaset_name, I.mysql_server_uuid, I.role, I.weight, I.version_token, H.location, I.addresses->>'$.mysqlClassic', I.addresses->>'$.mysqlX' FROM mysql_innodb_cluster_metadata.clusters AS F JOIN mysql_innodb_cluster_metadata.replicasets AS R ON F.cluster_id = R.cluster_id JOIN mysql_innodb_cluster_metadata.instances AS I ON R.replicaset_id = I.replicaset_id JOIN mysql_innodb_cluster_metadata.hosts AS H ON I.host_id = H.host_id WHERE F.cluster_name = 'test';\",\n            \"exec_time\": 0.521481,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"replicaset_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"mysql_server_uuid\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"role\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"weight\",\n                        \"type\": \"FLOAT\"\n                    },\n                    {\n                        \"name\": \"version_token\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"location\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"I.addresses->>'$.mysqlClassic'\",\n                        \"type\": \"LONGBLOB\"\n                    },\n                    {\n                        \"name\": \"I.addresses->>'$.mysqlX'\",\n                        \"type\": \"LONGBLOB\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"default\",\n                        \"8502d47b-e0f2-11e7-8530-080027c84a43\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.PRIMARY_HOST,\n                        \"localhost:33100\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"show status like 'group_replication_primary_member'\",\n            \"exec_time\": 1.702137,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"Variable_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"Value\",\n                        \"type\": \"VAR_STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"group_replication_primary_member\",\n                        \"8502d47b-e0f2-11e7-8530-080027c84a43\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode FROM performance_schema.replication_group_members WHERE channel_name = 'group_replication_applier'\",\n            \"exec_time\": 1.187367,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"member_id\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"member_host\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"member_port\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"member_state\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"@@group_replication_single_primary_mode\",\n                        \"type\": \"LONGLONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"8502d47b-e0f2-11e7-8530-080027c84a43\",\n                        \"jacek-VirtualBox\",\n                        process.env.PRIMARY_HOST,\n                        \"ONLINE\",\n                        \"1\"\n                    ]\n                ]\n            }\n        }\n    ]\n}"
  },
  {
    "path": "tests/component/data/metadata_1_node_repeat.js",
    "content": "if(mysqld.global.md_query_count == undefined){\n    mysqld.global.md_query_count = 0;\n}\n({\n    stmts: function (stmt) {\n      if (stmt === \"SELECT R.replicaset_name, I.mysql_server_uuid, I.role, I.weight, I.version_token, H.location, I.addresses->>'$.mysqlClassic', I.addresses->>'$.mysqlX' FROM mysql_innodb_cluster_metadata.clusters AS F JOIN mysql_innodb_cluster_metadata.replicasets AS R ON F.cluster_id = R.cluster_id JOIN mysql_innodb_cluster_metadata.instances AS I ON R.replicaset_id = I.replicaset_id JOIN mysql_innodb_cluster_metadata.hosts AS H ON I.host_id = H.host_id WHERE F.cluster_name = 'test';\") {\n        mysqld.global.md_query_count++;\n        return {\n          result: {\n            columns: [\n                {\n                    name: \"replicaset_name\",\n                    type: \"VAR_STRING\"\n                },\n                {\n                    name: \"mysql_server_uuid\",\n                    type: \"VAR_STRING\"\n                },\n                {\n                    name: \"role\",\n                    type: \"STRING\"\n                },\n                {\n                    name: \"weight\",\n                    type: \"FLOAT\"\n                },\n                {\n                    name: \"version_token\",\n                    type: \"LONG\"\n                },\n                {\n                    name: \"location\",\n                    type: \"VAR_STRING\"\n                },\n                {\n                    name: \"I.addresses->>'$.mysqlClassic'\",\n                    type: \"LONGBLOB\"\n                },\n                {\n                    name: \"I.addresses->>'$.mysqlX'\",\n                    type: \"LONGBLOB\"\n                }\n\n            ],\n            rows: [\n                    [\n                        \"default\",\n                        \"8502d47b-e0f2-11e7-8530-080027c84a43\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        \"localhost:\" + mysqld.session.port,\n                        \"localhost:33100\"\n                    ]\n            ]\n          },\n        };\n      }\n      else if (stmt === \"show status like 'group_replication_primary_member'\") {\n        return {\n          result: {\n            columns: [\n                {\n                    name: \"Variable_name\",\n                    type: \"VAR_STRING\"\n                },\n                {\n                    name: \"Value\",\n                    type: \"VAR_STRING\"\n                }\n\n            ],\n            rows: [\n                [\n                    \"group_replication_primary_member\",\n                    \"8502d47b-e0f2-11e7-8530-080027c84a43\"\n                ]\n            ]\n          },\n        };\n      }\n      else if (stmt === \"SELECT member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode FROM performance_schema.replication_group_members WHERE channel_name = 'group_replication_applier'\") {\n        return {\n          result: {\n            columns: [\n                {\n                    name: \"member_id\",\n                    type: \"STRING\"\n                },\n                {\n                    name: \"member_host\",\n                    type: \"STRING\"\n                },\n                {\n                    name: \"member_port\",\n                    type: \"LONG\"\n                },\n                {\n                    name: \"member_state\",\n                    type: \"STRING\"\n                },\n                {\n                    name: \"@@group_replication_single_primary_mode\",\n                    type: \"LONGLONG\"\n                }\n            ],\n            rows: [\n                [\n                    \"8502d47b-e0f2-11e7-8530-080027c84a43\",\n                    \"areliga-VirtualBox\",\n                    \"localhost:\" + mysqld.session.port,\n                    \"ONLINE\",\n                    \"1\"\n                ]\n            ]\n          },\n        };\n      }\n      else if (stmt === \"SELECT R.replicaset_name, I.mysql_server_uuid, I.role, I.weight, I.version_token, H.location, I.addresses->>'$.mysqlClassic', I.addresses->>'$.mysqlX' FROM mysql_innodb_cluster_metadata.clusters AS F JOIN mysql_innodb_cluster_metadata.replicasets AS R ON F.cluster_id = R.cluster_id JOIN mysql_innodb_cluster_metadata.instances AS I ON R.replicaset_id = I.replicaset_id JOIN mysql_innodb_cluster_metadata.hosts AS H ON I.host_id = H.host_id WHERE F.cluster_name = 'test';\") {\n        return {\n          result: {\n            columns: [\n                {\n                    name: \"replicaset_name\",\n                    type: \"VAR_STRING\"\n                },\n                {\n                    name: \"mysql_server_uuid\",\n                    type: \"VAR_STRING\"\n                },\n                {\n                    name: \"role\",\n                    type: \"STRING\"\n                },\n                {\n                    name: \"weight\",\n                    type: \"FLOAT\"\n                },\n                {\n                    name: \"version_token\",\n                    type: \"LONG\"\n                },\n                {\n                    name: \"location\",\n                    type: \"VAR_STRING\"\n                },\n                {\n                    name: \"I.addresses->>'$.mysqlClassic'\",\n                    type: \"LONGBLOB\"\n                },\n                {\n                    name: \"I.addresses->>'$.mysqlX'\",\n                    type: \"LONGBLOB\"\n                }\n            ],\n            \"rows\": [\n                [\n                    \"default\",\n                    \"8502d47b-e0f2-11e7-8530-080027c84a43\",\n                    \"HA\",\n                    null,\n                    null,\n                    \"\",\n                    \"localhost:\" + mysqld.session.port,\n                    \"localhost:33100\"\n                ]\n            ]\n          },\n        };\n      }\n      else if (stmt === \"show status like 'group_replication_primary_member'\") {\n        return {\n          result: {\n            columns: [\n                {\n                    name: \"Variable_name\",\n                    type: \"VAR_STRING\"\n                },\n                {\n                    name: \"Value\",\n                    type: \"VAR_STRING\"\n                }\n            ],\n            rows: [\n                [\n                    \"group_replication_primary_member\",\n                    \"8502d47b-e0f2-11e7-8530-080027c84a43\"\n                ]\n            ]\n          },\n        };\n      }\n      else if (stmt === \"SELECT member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode FROM performance_schema.replication_group_members WHERE channel_name = 'group_replication_applier'\") {\n        return {\n          result: {\n            columns: [\n                {\n                    name: \"member_id\",\n                    type: \"STRING\"\n                },\n                {\n                    name: \"member_host\",\n                    type: \"STRING\"\n                },\n                {\n                    name: \"member_port\",\n                    type: \"LONG\"\n                },\n                {\n                    name: \"member_state\",\n                    type: \"STRING\"\n                },\n                {\n                    name: \"@@group_replication_single_primary_mode\",\n                    type: \"LONGLONG\"\n                }\n            ],\n            rows: [\n                [\n                    \"8502d47b-e0f2-11e7-8530-080027c84a43\",\n                    \"areliga-VirtualBox\",\n                    \"localhost:\" + mysqld.session.port,\n                    \"ONLINE\",\n                    \"1\"\n                ]\n            ]\n          },\n        };\n      }\n      else {\n        return {\n          error: {\n            code: 1273,\n            sql_state: \"HY001\",\n            message: \"Syntax Error at: \" + stmt\n          }\n        };\n      }\n    }\n})\n"
  },
  {
    "path": "tests/component/data/metadata_3_nodes_first_not_accessible.js",
    "content": "{\n    \"stmts\": [\n        {\n            \"stmt\": \"SELECT R.replicaset_name, I.mysql_server_uuid, I.role, I.weight, I.version_token, H.location, I.addresses->>'$.mysqlClassic', I.addresses->>'$.mysqlX' FROM mysql_innodb_cluster_metadata.clusters AS F JOIN mysql_innodb_cluster_metadata.replicasets AS R ON F.cluster_id = R.cluster_id JOIN mysql_innodb_cluster_metadata.instances AS I ON R.replicaset_id = I.replicaset_id JOIN mysql_innodb_cluster_metadata.hosts AS H ON I.host_id = H.host_id WHERE F.cluster_name = 'test';\",\n            \"exec_time\": 1.862005,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"replicaset_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"mysql_server_uuid\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"role\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"weight\",\n                        \"type\": \"FLOAT\"\n                    },\n                    {\n                        \"name\": \"version_token\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"location\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"I.addresses->>'$.mysqlClassic'\",\n                        \"type\": \"LONGBLOB\"\n                    },\n                    {\n                        \"name\": \"I.addresses->>'$.mysqlX'\",\n                        \"type\": \"LONGBLOB\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"default\",\n                        \"8502d47b-e0f2-11e7-8530-080027c84a43\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.PRIMARY_HOST,\n                        \"localhost:33100\"\n                    ],\n                    [\n                        \"default\",\n                        \"8986ad3f-e0f2-11e7-875e-080027c84a43\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.SECONDARY_1_HOST,\n                        \"127.0.0.1:33110\"\n                    ],\n                    [\n                        \"default\",\n                        \"8dfc649f-e0f2-11e7-8aa8-080027c84a43\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.SECONDARY_2_HOST,\n                        \"127.0.0.1:33120\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"show status like 'group_replication_primary_member'\",\n            \"exec_time\": 3.374584,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"Variable_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"Value\",\n                        \"type\": \"VAR_STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"group_replication_primary_member\",\n                        \"8986ad3f-e0f2-11e7-875e-080027c84a43\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode FROM performance_schema.replication_group_members WHERE channel_name = 'group_replication_applier'\",\n            \"exec_time\": 1.422041,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"member_id\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"member_host\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"member_port\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"member_state\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"@@group_replication_single_primary_mode\",\n                        \"type\": \"LONGLONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"8986ad3f-e0f2-11e7-875e-080027c84a43\",\n                        \"jacek-VirtualBox\",\n                        process.env.SECONDARY_1_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ],\n                    [\n                        \"8dfc649f-e0f2-11e7-8aa8-080027c84a43\",\n                        \"jacek-VirtualBox\",\n                        process.env.SECONDARY_2_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT R.replicaset_name, I.mysql_server_uuid, I.role, I.weight, I.version_token, H.location, I.addresses->>'$.mysqlClassic', I.addresses->>'$.mysqlX' FROM mysql_innodb_cluster_metadata.clusters AS F JOIN mysql_innodb_cluster_metadata.replicasets AS R ON F.cluster_id = R.cluster_id JOIN mysql_innodb_cluster_metadata.instances AS I ON R.replicaset_id = I.replicaset_id JOIN mysql_innodb_cluster_metadata.hosts AS H ON I.host_id = H.host_id WHERE F.cluster_name = 'test';\",\n            \"exec_time\": 0.521481,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"replicaset_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"mysql_server_uuid\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"role\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"weight\",\n                        \"type\": \"FLOAT\"\n                    },\n                    {\n                        \"name\": \"version_token\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"location\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"I.addresses->>'$.mysqlClassic'\",\n                        \"type\": \"LONGBLOB\"\n                    },\n                    {\n                        \"name\": \"I.addresses->>'$.mysqlX'\",\n                        \"type\": \"LONGBLOB\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"default\",\n                        \"8502d47b-e0f2-11e7-8530-080027c84a43\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.PRIMARY_HOST,\n                        \"localhost:33100\"\n                    ],\n                    [\n                        \"default\",\n                        \"8986ad3f-e0f2-11e7-875e-080027c84a43\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.SECONDARY_1_HOST,\n                        \"127.0.0.1:33110\"\n                    ],\n                    [\n                        \"default\",\n                        \"8dfc649f-e0f2-11e7-8aa8-080027c84a43\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.SECONDARY_2_HOST,\n                        \"127.0.0.1:33120\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"show status like 'group_replication_primary_member'\",\n            \"exec_time\": 1.702137,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"Variable_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"Value\",\n                        \"type\": \"VAR_STRING\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"group_replication_primary_member\",\n                        \"8986ad3f-e0f2-11e7-875e-080027c84a43\"\n                    ]\n                ]\n            }\n        },\n        {\n            \"stmt\": \"SELECT member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode FROM performance_schema.replication_group_members WHERE channel_name = 'group_replication_applier'\",\n            \"exec_time\": 1.187367,\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"member_id\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"member_host\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"member_port\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"member_state\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"@@group_replication_single_primary_mode\",\n                        \"type\": \"LONGLONG\"\n                    }\n                ],\n                \"rows\": [\n                    [\n                        \"8986ad3f-e0f2-11e7-875e-080027c84a43\",\n                        \"jacek-VirtualBox\",\n                        process.env.SECONDARY_1_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ],\n                    [\n                        \"8dfc649f-e0f2-11e7-8aa8-080027c84a43\",\n                        \"jacek-VirtualBox\",\n                        process.env.SECONDARY_2_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ]\n                ]\n            }\n        }\n    ]\n}"
  },
  {
    "path": "tests/component/data/metadata_3_secondaries.js",
    "content": "var stmts = {\n  \"SELECT R.replicaset_name, I.mysql_server_uuid, I.role, I.weight, I.version_token, H.location, I.addresses->>'$.mysqlClassic', I.addresses->>'$.mysqlX' FROM mysql_innodb_cluster_metadata.clusters AS F JOIN mysql_innodb_cluster_metadata.replicasets AS R ON F.cluster_id = R.cluster_id JOIN mysql_innodb_cluster_metadata.instances AS I ON R.replicaset_id = I.replicaset_id JOIN mysql_innodb_cluster_metadata.hosts AS H ON I.host_id = H.host_id WHERE F.cluster_name = 'test';\": {\n    \"exec_time\": 3.28679,\n    \"result\": {\n      \"columns\": [\n        {\n          \"name\": \"replicaset_name\",\n          \"type\": \"VAR_STRING\"\n        },\n        {\n          \"name\": \"mysql_server_uuid\",\n          \"type\": \"VAR_STRING\"\n        },\n        {\n          \"name\": \"role\",\n          \"type\": \"STRING\"\n        },\n        {\n          \"name\": \"weight\",\n          \"type\": \"FLOAT\"\n        },\n        {\n          \"name\": \"version_token\",\n          \"type\": \"LONG\"\n        },\n        {\n          \"name\": \"location\",\n          \"type\": \"VAR_STRING\"\n        },\n        {\n          \"name\": \"I.addresses->>'$.mysqlClassic'\",\n          \"type\": \"LONGBLOB\"\n        },\n        {\n          \"name\": \"I.addresses->>'$.mysqlX'\",\n          \"type\": \"LONGBLOB\"\n        }\n      ],\n      \"rows\": [\n        [\n          \"default\",\n          \"37dbb0e3-cfc0-11e7-8039-080027d01fcd\",\n          \"HA\",\n          null,\n          null,\n          \"\",\n          process.env.PRIMARY_HOST,\n          \"localhost:50000\"\n        ],\n        [\n          \"default\",\n          \"49cff431-cfc0-11e7-bb87-080027d01fcd\",\n          \"HA\",\n          null,\n          null,\n          \"\",\n          process.env.SECONDARY_1_HOST,\n          \"127.0.0.1:50010\"\n        ],\n        [\n          \"default\",\n          \"56d0f99d-cfc0-11e7-bb0a-080027d01fcd\",\n          \"HA\",\n          null,\n          null,\n          \"\",\n          process.env.SECONDARY_2_HOST,\n          \"127.0.0.1:50020\"\n        ],\n        [\n          \"default\",\n          \"6689460c-cfc0-11e7-907b-080027d01fcd\",\n          \"HA\",\n          null,\n          null,\n          \"\",\n          process.env.SECONDARY_3_HOST,\n          \"127.0.0.1:50030\"\n        ]\n      ]\n    }\n  },\n  \"show status like 'group_replication_primary_member'\": {\n    \"exec_time\": 46.132637,\n    \"result\": {\n      \"columns\": [\n        {\n          \"name\": \"Variable_name\",\n          \"type\": \"VAR_STRING\"\n        },\n        {\n          \"name\": \"Value\",\n          \"type\": \"VAR_STRING\"\n        }\n      ],\n      \"rows\": [\n        [\n          \"group_replication_primary_member\",\n          \"37dbb0e3-cfc0-11e7-8039-080027d01fcd\"\n        ]\n      ]\n    }\n  },\n  \"SELECT member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode FROM performance_schema.replication_group_members WHERE channel_name = 'group_replication_applier'\": {\n    \"exec_time\": 1.493937,\n    \"result\": {\n      \"columns\": [\n        {\n          \"name\": \"member_id\",\n          \"type\": \"STRING\"\n        },\n        {\n          \"name\": \"member_host\",\n          \"type\": \"STRING\"\n        },\n        {\n          \"name\": \"member_port\",\n          \"type\": \"LONG\"\n        },\n        {\n          \"name\": \"member_state\",\n          \"type\": \"STRING\"\n        },\n        {\n          \"name\": \"@@group_replication_single_primary_mode\",\n          \"type\": \"LONGLONG\"\n        }\n      ],\n      \"rows\": [\n        [\n          \"37dbb0e3-cfc0-11e7-8039-080027d01fcd\",\n          \"areliga-Ubuntu16\",\n          process.env.PRIMARY_PORT,\n          \"ONLINE\",\n          \"1\"\n        ],\n        [\n          \"49cff431-cfc0-11e7-bb87-080027d01fcd\",\n          \"areliga-Ubuntu16\",\n          process.env.SECONDARY_1_PORT,\n          \"ONLINE\",\n          \"1\"\n        ],\n        [\n          \"56d0f99d-cfc0-11e7-bb0a-080027d01fcd\",\n          \"areliga-Ubuntu16\",\n          process.env.SECONDARY_2_PORT,\n          \"ONLINE\",\n          \"1\"\n        ],\n        [\n          \"6689460c-cfc0-11e7-907b-080027d01fcd\",\n          \"areliga-Ubuntu16\",\n          process.env.SECONDARY_3_PORT,\n          \"ONLINE\",\n          \"1\"\n        ]\n      ]\n    }\n  },\n  \"select @@port\": {\n    \"result\": {\n      \"columns\": [\n        {\n          \"name\": \"@@port\",\n          \"type\": \"STRING\"\n        }\n      ],\n      \"rows\": [\n        [\n          process.env.MY_PORT\n        ]\n\n      ]\n    }\n  }\n};\n\nfunction stmt_handler() {\n  return new Duktape.Thread(function(stmt) {\n    var yield = Duktape.Thread.yield;\n\n    while (true) {\n      if (stmts.hasOwnProperty(stmt)) {\n        stmt = yield(stmts[stmt]);\n      } else {\n        stmt = yield({error: {code: 1234, message: \"unexpected stmt: \" + stmt}});\n      }\n    }\n  });\n}\n\n({\n    \"stmts\": stmt_handler()\n})\n"
  },
  {
    "path": "tests/component/data/metadata_3_secondaries_failed_to_update.js",
    "content": "if (mysqld.global.MD_failed == undefined) {\n  mysqld.global.MD_failed = false;\n}\nif (mysqld.global.GR_primary_failed == undefined) {\n  mysqld.global.GR_primary_failed = false;\n}\nif (mysqld.global.GR_health_failed == undefined) {\n  mysqld.global.GR_health_failed = false;\n}\n({\n  stmts: function (stmt) {\n    if (stmt === \"SELECT R.replicaset_name, I.mysql_server_uuid, I.role, I.weight, I.version_token, H.location, I.addresses->>'$.mysqlClassic', I.addresses->>'$.mysqlX' FROM mysql_innodb_cluster_metadata.clusters AS F JOIN mysql_innodb_cluster_metadata.replicasets AS R ON F.cluster_id = R.cluster_id JOIN mysql_innodb_cluster_metadata.instances AS I ON R.replicaset_id = I.replicaset_id JOIN mysql_innodb_cluster_metadata.hosts AS H ON I.host_id = H.host_id WHERE F.cluster_name = 'test';\") {\n      if (!mysqld.global.MD_failed) {\n        return {\n              result : {\n                columns : [\n                    {\n                        \"name\": \"replicaset_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"mysql_server_uuid\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"role\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"weight\",\n                        \"type\": \"FLOAT\"\n                    },\n                    {\n                        \"name\": \"version_token\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"location\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"I.addresses->>'$.mysqlClassic'\",\n                        \"type\": \"LONGBLOB\"\n                    },\n                    {\n                        \"name\": \"I.addresses->>'$.mysqlX'\",\n                        \"type\": \"LONGBLOB\"\n                    }\n                ],\n                rows : [\n                    [\n                        \"default\",\n                        \"37dbb0e3-cfc0-11e7-8039-080027d01fcd\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.PRIMARY_HOST,\n                        \"localhost:50000\"\n                    ],\n                    [\n                        \"default\",\n                        \"49cff431-cfc0-11e7-bb87-080027d01fcd\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.SECONDARY_1_HOST,\n                        \"127.0.0.1:50010\"\n                    ],\n                    [\n                        \"default\",\n                        \"56d0f99d-cfc0-11e7-bb0a-080027d01fcd\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.SECONDARY_2_HOST,\n                        \"127.0.0.1:50020\"\n                    ],\n                    [\n                        \"default\",\n                        \"6689460c-cfc0-11e7-907b-080027d01fcd\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.SECONDARY_3_HOST,\n                        \"127.0.0.1:50030\"\n                    ]\n                ]\n            }\n        };\n      }\n      else {\n        return {\n          error: {\n            code: 1273,\n            sql_state: \"HY001\",\n            message: \"Syntax Error at: \" + stmt\n          }\n        };\n      }\n    }\n    else if (stmt === \"show status like 'group_replication_primary_member'\") {\n      if (!mysqld.global.GR_primary_failed) {\n        return {\n          result : {\n              columns : [\n                  {\n                      \"name\": \"Variable_name\",\n                      \"type\": \"VAR_STRING\"\n                  },\n                  {\n                      \"name\": \"Value\",\n                      \"type\": \"VAR_STRING\"\n                  }\n              ],\n              rows : [\n                  [\n                      \"group_replication_primary_member\",\n                      \"37dbb0e3-cfc0-11e7-8039-080027d01fcd\"\n                  ]\n              ]\n          }\n        };\n      }\n      else {\n        return {\n          error: {\n            code: 1273,\n            sql_state: \"HY001\",\n            message: \"Syntax Error at: \" + stmt\n          }\n        };\n      }\n    }\n    else if (stmt === \"SELECT member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode FROM performance_schema.replication_group_members WHERE channel_name = 'group_replication_applier'\") {\n      if (!mysqld.global.GR_health_failed) {\n        return {\n             result : {\n                columns: [\n                    {\n                        \"name\": \"member_id\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"member_host\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"member_port\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"member_state\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"@@group_replication_single_primary_mode\",\n                        \"type\": \"LONGLONG\"\n                    }\n                ],\n                rows: [\n                    [\n                        \"37dbb0e3-cfc0-11e7-8039-080027d01fcd\",\n                        \"areliga-Ubuntu16\",\n                        process.env.PRIMARY_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ],\n                    [\n                        \"49cff431-cfc0-11e7-bb87-080027d01fcd\",\n                        \"areliga-Ubuntu16\",\n                        process.env.SECONDARY_1_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ],\n                    [\n                        \"56d0f99d-cfc0-11e7-bb0a-080027d01fcd\",\n                        \"areliga-Ubuntu16\",\n                        process.env.SECONDARY_2_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ],\n                    [\n                        \"6689460c-cfc0-11e7-907b-080027d01fcd\",\n                        \"areliga-Ubuntu16\",\n                        process.env.SECONDARY_3_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ]\n                ]\n            }\n        };\n      }\n      else {\n        return {\n          error: {\n            code: 1273,\n            sql_state: \"HY001\",\n            message: \"Syntax Error at: \" + stmt\n          }\n        };\n      }\n    }\n    else if (stmt === \"select @@port\") {\n      return {\n        result: {\n          columns: [\n            {\n              name: \"@@port\",\n              type: \"LONG\"\n            }\n          ],\n          rows: [\n            [ mysqld.session.port ]\n          ]\n        },\n      };\n    }\n    else {\n      return {\n        error: {\n          code: 1273,\n          sql_state: \"HY001\",\n          message: \"Syntax Error at: \" + stmt\n        }\n      };\n    }\n  }\n})\n"
  },
  {
    "path": "tests/component/data/metadata_3_secondaries_pass.js",
    "content": "\nif (mysqld.global.MD_asked == undefined) {\n  mysqld.global.MD_asked = false;\n}\n\nif (mysqld.global.primary_asked == undefined) {\n  mysqld.global.primary_asked = false;\n}\n\nif (mysqld.global.health_asked == undefined) {\n  mysqld.global.health_asked = false;\n}\n\n({\n  stmts: function (stmt) {\n    if (stmt === \"SELECT R.replicaset_name, I.mysql_server_uuid, I.role, I.weight, I.version_token, H.location, I.addresses->>'$.mysqlClassic', I.addresses->>'$.mysqlX' FROM mysql_innodb_cluster_metadata.clusters AS F JOIN mysql_innodb_cluster_metadata.replicasets AS R ON F.cluster_id = R.cluster_id JOIN mysql_innodb_cluster_metadata.instances AS I ON R.replicaset_id = I.replicaset_id JOIN mysql_innodb_cluster_metadata.hosts AS H ON I.host_id = H.host_id WHERE F.cluster_name = 'test';\") {\n        mysqld.global.MD_asked = true;\n        return {\n              result : {\n                columns : [\n                    {\n                        \"name\": \"replicaset_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"mysql_server_uuid\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"role\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"weight\",\n                        \"type\": \"FLOAT\"\n                    },\n                    {\n                        \"name\": \"version_token\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"location\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"I.addresses->>'$.mysqlClassic'\",\n                        \"type\": \"LONGBLOB\"\n                    },\n                    {\n                        \"name\": \"I.addresses->>'$.mysqlX'\",\n                        \"type\": \"LONGBLOB\"\n                    }\n                ],\n                rows : [\n                    [\n                        \"default\",\n                        \"37dbb0e3-cfc0-11e7-8039-080027d01fcd\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.PRIMARY_HOST,\n                        \"localhost:50000\"\n                    ],\n                    [\n                        \"default\",\n                        \"49cff431-cfc0-11e7-bb87-080027d01fcd\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.SECONDARY_1_HOST,\n                        \"127.0.0.1:50010\"\n                    ],\n                    [\n                        \"default\",\n                        \"56d0f99d-cfc0-11e7-bb0a-080027d01fcd\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.SECONDARY_2_HOST,\n                        \"127.0.0.1:50020\"\n                    ],\n                    [\n                        \"default\",\n                        \"6689460c-cfc0-11e7-907b-080027d01fcd\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.SECONDARY_3_HOST,\n                        \"127.0.0.1:50030\"\n                    ]\n                ]\n            }\n        };\n    }\n    else if (stmt === \"show status like 'group_replication_primary_member'\") {\n      mysqld.global.primary_asked = true;\n      return {\n        result : {\n            columns : [\n                {\n                    \"name\": \"Variable_name\",\n                    \"type\": \"VAR_STRING\"\n                },\n                {\n                    \"name\": \"Value\",\n                    \"type\": \"VAR_STRING\"\n                }\n            ],\n            rows : [\n                [\n                    \"group_replication_primary_member\",\n                    \"37dbb0e3-cfc0-11e7-8039-080027d01fcd\"\n                ]\n            ]\n        }\n      };\n    }\n    else if (stmt === \"SELECT member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode FROM performance_schema.replication_group_members WHERE channel_name = 'group_replication_applier'\") {\n        mysqld.global.health_asked = true;\n        return {\n             result : {\n                columns: [\n                    {\n                        \"name\": \"member_id\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"member_host\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"member_port\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"member_state\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"@@group_replication_single_primary_mode\",\n                        \"type\": \"LONGLONG\"\n                    }\n                ],\n                rows: [\n                    [\n                        \"37dbb0e3-cfc0-11e7-8039-080027d01fcd\",\n                        \"areliga-Ubuntu16\",\n                        process.env.PRIMARY_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ],\n                    [\n                        \"49cff431-cfc0-11e7-bb87-080027d01fcd\",\n                        \"areliga-Ubuntu16\",\n                        process.env.SECONDARY_1_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ],\n                    [\n                        \"56d0f99d-cfc0-11e7-bb0a-080027d01fcd\",\n                        \"areliga-Ubuntu16\",\n                        process.env.SECONDARY_2_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ],\n                    [\n                        \"6689460c-cfc0-11e7-907b-080027d01fcd\",\n                        \"areliga-Ubuntu16\",\n                        process.env.SECONDARY_3_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ]\n                ]\n            }\n        };\n    }\n    else if (stmt === \"select @@port\") {\n      return {\n        result: {\n          columns: [\n            {\n              name: \"@@port\",\n              type: \"LONG\"\n            }\n          ],\n          rows: [\n            [ mysqld.session.port ]\n          ]\n        },\n      };\n    }\n    else {\n      return {\n        error: {\n          code: 1273,\n          sql_state: \"HY001\",\n          message: \"Syntax Error at: \" + stmt\n        }\n      };\n    }\n  }\n})"
  },
  {
    "path": "tests/component/data/metadata_3_secondaries_primary_failover.js",
    "content": "if (mysqld.global.primary_failover == undefined) {\n  mysqld.global.primary_failover = false;\n}\n({\n  stmts: function (stmt) {\n    if (stmt === \"SELECT R.replicaset_name, I.mysql_server_uuid, I.role, I.weight, I.version_token, H.location, I.addresses->>'$.mysqlClassic', I.addresses->>'$.mysqlX' FROM mysql_innodb_cluster_metadata.clusters AS F JOIN mysql_innodb_cluster_metadata.replicasets AS R ON F.cluster_id = R.cluster_id JOIN mysql_innodb_cluster_metadata.instances AS I ON R.replicaset_id = I.replicaset_id JOIN mysql_innodb_cluster_metadata.hosts AS H ON I.host_id = H.host_id WHERE F.cluster_name = 'test';\") {\n        return {\n              result : {\n                columns : [\n                    {\n                        \"name\": \"replicaset_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"mysql_server_uuid\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"role\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"weight\",\n                        \"type\": \"FLOAT\"\n                    },\n                    {\n                        \"name\": \"version_token\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"location\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"I.addresses->>'$.mysqlClassic'\",\n                        \"type\": \"LONGBLOB\"\n                    },\n                    {\n                        \"name\": \"I.addresses->>'$.mysqlX'\",\n                        \"type\": \"LONGBLOB\"\n                    }\n                ],\n                rows : [\n                    [\n                        \"default\",\n                        \"37dbb0e3-cfc0-11e7-8039-080027d01fcd\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.PRIMARY_HOST,\n                        \"localhost:50000\"\n                    ],\n                    [\n                        \"default\",\n                        \"49cff431-cfc0-11e7-bb87-080027d01fcd\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.SECONDARY_1_HOST,\n                        \"127.0.0.1:50010\"\n                    ],\n                    [\n                        \"default\",\n                        \"56d0f99d-cfc0-11e7-bb0a-080027d01fcd\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.SECONDARY_2_HOST,\n                        \"127.0.0.1:50020\"\n                    ],\n                    [\n                        \"default\",\n                        \"6689460c-cfc0-11e7-907b-080027d01fcd\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.SECONDARY_3_HOST,\n                        \"127.0.0.1:50030\"\n                    ]\n                ]\n            }\n        };\n    }\n    else if (stmt === \"show status like 'group_replication_primary_member'\") {\n      if (!mysqld.global.primary_failover) {\n        return {\n             result : {\n                columns : [\n                    {\n                        \"name\": \"Variable_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"Value\",\n                        \"type\": \"VAR_STRING\"\n                    }\n                ],\n                rows : [\n                    [\n                        \"group_replication_primary_member\",\n                        \"37dbb0e3-cfc0-11e7-8039-080027d01fcd\"\n                    ]\n                ]\n            }\n        };\n      }\n      else {\n        return {\n             result : {\n                columns : [\n                    {\n                        \"name\": \"Variable_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"Value\",\n                        \"type\": \"VAR_STRING\"\n                    }\n                ],\n                rows : [\n                    [\n                        \"group_replication_primary_member\",\n                        \"49cff431-cfc0-11e7-bb87-080027d01fcd\"\n                    ]\n                ]\n            }\n        };\n      }\n    }\n    else if (stmt === \"SELECT member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode FROM performance_schema.replication_group_members WHERE channel_name = 'group_replication_applier'\") {\n        return {\n             result : {\n                columns: [\n                    {\n                        \"name\": \"member_id\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"member_host\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"member_port\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"member_state\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"@@group_replication_single_primary_mode\",\n                        \"type\": \"LONGLONG\"\n                    }\n                ],\n                rows: [\n                    [\n                        \"37dbb0e3-cfc0-11e7-8039-080027d01fcd\",\n                        \"areliga-Ubuntu16\",\n                        process.env.PRIMARY_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ],\n                    [\n                        \"49cff431-cfc0-11e7-bb87-080027d01fcd\",\n                        \"areliga-Ubuntu16\",\n                        process.env.SECONDARY_1_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ],\n                    [\n                        \"56d0f99d-cfc0-11e7-bb0a-080027d01fcd\",\n                        \"areliga-Ubuntu16\",\n                        process.env.SECONDARY_2_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ],\n                    [\n                        \"6689460c-cfc0-11e7-907b-080027d01fcd\",\n                        \"areliga-Ubuntu16\",\n                        process.env.SECONDARY_3_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ]\n                ]\n            }\n        };\n    }\n    else if (stmt === \"select @@port\") {\n      return {\n        result: {\n          columns: [\n            {\n              name: \"@@port\",\n              type: \"LONG\"\n            }\n          ],\n          rows: [\n            [ mysqld.session.port ]\n          ]\n        },\n      };\n    }\n    else {\n      return {\n        error: {\n          code: 1273,\n          sql_state: \"HY001\",\n          message: \"Syntax Error at: \" + stmt\n        }\n      };\n    }\n  }\n})\n"
  },
  {
    "path": "tests/component/data/metadata_3_secondaries_server_removed_from_cluster.js",
    "content": "if (mysqld.global.primary_removed == undefined) {\n  mysqld.global.primary_removed = false;\n}\n\nif (mysqld.global.secondary_removed == undefined) {\n  mysqld.global.secondary_removed = false;\n}\n\n({\n    stmts: function (stmt) {\n      if (mysqld.global.secondary_removed) {\n        // mysqld.global.secondary_removed = true\n        if (stmt === \"SELECT R.replicaset_name, I.mysql_server_uuid, I.role, I.weight, I.version_token, H.location, I.addresses->>'$.mysqlClassic', I.addresses->>'$.mysqlX' FROM mysql_innodb_cluster_metadata.clusters AS F JOIN mysql_innodb_cluster_metadata.replicasets AS R ON F.cluster_id = R.cluster_id JOIN mysql_innodb_cluster_metadata.instances AS I ON R.replicaset_id = I.replicaset_id JOIN mysql_innodb_cluster_metadata.hosts AS H ON I.host_id = H.host_id WHERE F.cluster_name = 'test';\") {\n          return {\n            result : {\n                  columns: [\n                      {\n                          \"name\": \"replicaset_name\",\n                          \"type\": \"VAR_STRING\"\n                      },\n                      {\n                          \"name\": \"mysql_server_uuid\",\n                          \"type\": \"VAR_STRING\"\n                      },\n                      {\n                          \"name\": \"role\",\n                          \"type\": \"STRING\"\n                      },\n                      {\n                          \"name\": \"weight\",\n                          \"type\": \"FLOAT\"\n                      },\n                      {\n                          \"name\": \"version_token\",\n                          \"type\": \"LONG\"\n                      },\n                      {\n                          \"name\": \"location\",\n                          \"type\": \"VAR_STRING\"\n                      },\n                      {\n                          \"name\": \"I.addresses->>'$.mysqlClassic'\",\n                          \"type\": \"LONGBLOB\"\n                      },\n                      {\n                          \"name\": \"I.addresses->>'$.mysqlX'\",\n                          \"type\": \"LONGBLOB\"\n                      }\n                  ],\n                  rows: [\n                      [\n                          \"default\",\n                          \"37dbb0e3-cfc0-11e7-8039-080027d01fcd\",\n                          \"HA\",\n                          null,\n                          null,\n                          \"\",\n                          process.env.PRIMARY_HOST,\n                          \"localhost:50000\"\n                      ],\n                      [\n                          \"default\",\n                          \"56d0f99d-cfc0-11e7-bb0a-080027d01fcd\",\n                          \"HA\",\n                          null,\n                          null,\n                          \"\",\n                          process.env.SECONDARY_2_HOST,\n                          \"127.0.0.1:50020\"\n                      ],\n                      [\n                          \"default\",\n                          \"6689460c-cfc0-11e7-907b-080027d01fcd\",\n                          \"HA\",\n                          null,\n                          null,\n                          \"\",\n                          process.env.SECONDARY_3_HOST,\n                          \"127.0.0.1:50030\"\n                      ]\n                  ]\n            }\n          };\n        }\n        else if (stmt === \"show status like 'group_replication_primary_member'\") {\n          return {\n            result: {\n              columns: [\n                  {\n                      name: \"Variable_name\",\n                      type: \"VAR_STRING\"\n                  },\n                  {\n                      name: \"Value\",\n                      type: \"VAR_STRING\"\n                  }\n              ],\n              rows: [\n                  [\n                      \"group_replication_primary_member\",\n                      \"37dbb0e3-cfc0-11e7-8039-080027d01fcd\"\n                  ]\n              ]\n            },\n          };\n        }\n        else if (stmt === \"SELECT member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode FROM performance_schema.replication_group_members WHERE channel_name = 'group_replication_applier'\") {\n          return {\n            result: {\n              columns: [\n                  {\n                      name: \"member_id\",\n                      type: \"STRING\"\n                  },\n                  {\n                      name: \"member_host\",\n                      type: \"STRING\"\n                  },\n                  {\n                      name: \"member_port\",\n                      type: \"LONG\"\n                  },\n                  {\n                      name: \"member_state\",\n                      type: \"STRING\"\n                  },\n                  {\n                      name: \"@@group_replication_single_primary_mode\",\n                      type: \"LONGLONG\"\n                  }\n              ],\n              rows: [\n                      [\n                          \"37dbb0e3-cfc0-11e7-8039-080027d01fcd\",\n                          \"areliga-Ubuntu16\",\n                          process.env.PRIMARY_PORT,\n                          \"ONLINE\",\n                          \"1\"\n                      ],\n                      [\n                          \"56d0f99d-cfc0-11e7-bb0a-080027d01fcd\",\n                          \"areliga-Ubuntu16\",\n                          process.env.SECONDARY_2_PORT,\n                          \"ONLINE\",\n                          \"1\"\n                      ],\n                      [\n                          \"6689460c-cfc0-11e7-907b-080027d01fcd\",\n                          \"areliga-Ubuntu16\",\n                          process.env.SECONDARY_3_PORT,\n                          \"ONLINE\",\n                          \"1\"\n                      ]\n              ]\n            },\n          };\n        }\n        else if (stmt === \"select @@port\") {\n          return {\n            result: {\n              columns: [\n                {\n                  name: \"@@port\",\n                  type: \"LONG\"\n                }\n              ],\n              rows: [\n                [ mysqld.session.port ]\n              ]\n            },\n          };\n        }\n        else {\n          return {\n            error: {\n              code: 1273,\n              sql_state: \"HY001\",\n              message: \"Syntax Error at: \" + stmt\n            }\n          };\n        }\n      }\n      else if (mysqld.global.primary_removed) {\n        if (stmt === \"SELECT R.replicaset_name, I.mysql_server_uuid, I.role, I.weight, I.version_token, H.location, I.addresses->>'$.mysqlClassic', I.addresses->>'$.mysqlX' FROM mysql_innodb_cluster_metadata.clusters AS F JOIN mysql_innodb_cluster_metadata.replicasets AS R ON F.cluster_id = R.cluster_id JOIN mysql_innodb_cluster_metadata.instances AS I ON R.replicaset_id = I.replicaset_id JOIN mysql_innodb_cluster_metadata.hosts AS H ON I.host_id = H.host_id WHERE F.cluster_name = 'test';\") {\n          return {\n            result : {\n                  columns: [\n                      {\n                          \"name\": \"replicaset_name\",\n                          \"type\": \"VAR_STRING\"\n                      },\n                      {\n                          \"name\": \"mysql_server_uuid\",\n                          \"type\": \"VAR_STRING\"\n                      },\n                      {\n                          \"name\": \"role\",\n                          \"type\": \"STRING\"\n                      },\n                      {\n                          \"name\": \"weight\",\n                          \"type\": \"FLOAT\"\n                      },\n                      {\n                          \"name\": \"version_token\",\n                          \"type\": \"LONG\"\n                      },\n                      {\n                          \"name\": \"location\",\n                          \"type\": \"VAR_STRING\"\n                      },\n                      {\n                          \"name\": \"I.addresses->>'$.mysqlClassic'\",\n                          \"type\": \"LONGBLOB\"\n                      },\n                      {\n                          \"name\": \"I.addresses->>'$.mysqlX'\",\n                          \"type\": \"LONGBLOB\"\n                      }\n                  ],\n                  rows: [\n                      [\n                          \"default\",\n                          \"49cff431-cfc0-11e7-bb87-080027d01fcd\",\n                          \"HA\",\n                          null,\n                          null,\n                          \"\",\n                          process.env.SECONDARY_1_HOST,\n                          \"127.0.0.1:50010\"\n                      ],\n                      [\n                          \"default\",\n                          \"56d0f99d-cfc0-11e7-bb0a-080027d01fcd\",\n                          \"HA\",\n                          null,\n                          null,\n                          \"\",\n                          process.env.SECONDARY_2_HOST,\n                          \"127.0.0.1:50020\"\n                      ],\n                      [\n                          \"default\",\n                          \"6689460c-cfc0-11e7-907b-080027d01fcd\",\n                          \"HA\",\n                          null,\n                          null,\n                          \"\",\n                          process.env.SECONDARY_3_HOST,\n                          \"127.0.0.1:50030\"\n                      ]\n                  ]\n            }\n          };\n        }\n        else if (stmt === \"show status like 'group_replication_primary_member'\") {\n          return {\n            result: {\n              columns: [\n                  {\n                      name: \"Variable_name\",\n                      type: \"VAR_STRING\"\n                  },\n                  {\n                      name: \"Value\",\n                      type: \"VAR_STRING\"\n                  }\n  \n              ],\n              rows: [\n                  [\n                      \"group_replication_primary_member\",\n                      \"49cff431-cfc0-11e7-bb87-080027d01fcd\"\n                  ]\n              ]\n            },\n          };\n        }\n        else if (stmt === \"SELECT member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode FROM performance_schema.replication_group_members WHERE channel_name = 'group_replication_applier'\") {\n          return {\n            result: {\n              columns: [\n                  {\n                      name: \"member_id\",\n                      type: \"STRING\"\n                  },\n                  {\n                      name: \"member_host\",\n                      type: \"STRING\"\n                  },\n                  {\n                      name: \"member_port\",\n                      type: \"LONG\"\n                  },\n                  {\n                      name: \"member_state\",\n                      type: \"STRING\"\n                  },\n                  {\n                      name: \"@@group_replication_single_primary_mode\",\n                      type: \"LONGLONG\"\n                  }\n              ],\n              rows: [\n                      [\n                          \"49cff431-cfc0-11e7-bb87-080027d01fcd\",\n                          \"areliga-Ubuntu16\",\n                          process.env.SECONDARY_1_PORT,\n                          \"ONLINE\",\n                          \"1\"\n                      ],\n                      [\n                          \"56d0f99d-cfc0-11e7-bb0a-080027d01fcd\",\n                          \"areliga-Ubuntu16\",\n                          process.env.SECONDARY_2_PORT,\n                          \"ONLINE\",\n                          \"1\"\n                      ],\n                      [\n                          \"6689460c-cfc0-11e7-907b-080027d01fcd\",\n                          \"areliga-Ubuntu16\",\n                          process.env.SECONDARY_3_PORT,\n                          \"ONLINE\",\n                          \"1\"\n                      ]\n              ]\n            },\n          };\n        }\n        else if (stmt === \"select @@port\") {\n          return {\n            result: {\n              columns: [\n                {\n                  name: \"@@port\",\n                  type: \"LONG\"\n                }\n              ],\n              rows: [\n                [ mysqld.session.port ]\n              ]\n            },\n          };\n        }\n        else {\n          return {\n            error: {\n              code: 1273,\n              sql_state: \"HY001\",\n              message: \"Syntax Error at: \" + stmt\n            }\n          };\n        }\n      }\n      else {\n        if (stmt === \"SELECT R.replicaset_name, I.mysql_server_uuid, I.role, I.weight, I.version_token, H.location, I.addresses->>'$.mysqlClassic', I.addresses->>'$.mysqlX' FROM mysql_innodb_cluster_metadata.clusters AS F JOIN mysql_innodb_cluster_metadata.replicasets AS R ON F.cluster_id = R.cluster_id JOIN mysql_innodb_cluster_metadata.instances AS I ON R.replicaset_id = I.replicaset_id JOIN mysql_innodb_cluster_metadata.hosts AS H ON I.host_id = H.host_id WHERE F.cluster_name = 'test';\") {\n          return {\n            result : {\n                  columns: [\n                      {\n                          \"name\": \"replicaset_name\",\n                          \"type\": \"VAR_STRING\"\n                      },\n                      {\n                          \"name\": \"mysql_server_uuid\",\n                          \"type\": \"VAR_STRING\"\n                      },\n                      {\n                          \"name\": \"role\",\n                          \"type\": \"STRING\"\n                      },\n                      {\n                          \"name\": \"weight\",\n                          \"type\": \"FLOAT\"\n                      },\n                      {\n                          \"name\": \"version_token\",\n                          \"type\": \"LONG\"\n                      },\n                      {\n                          \"name\": \"location\",\n                          \"type\": \"VAR_STRING\"\n                      },\n                      {\n                          \"name\": \"I.addresses->>'$.mysqlClassic'\",\n                          \"type\": \"LONGBLOB\"\n                      },\n                      {\n                          \"name\": \"I.addresses->>'$.mysqlX'\",\n                          \"type\": \"LONGBLOB\"\n                      }\n                  ],\n                  rows: [\n                      [\n                          \"default\",\n                          \"37dbb0e3-cfc0-11e7-8039-080027d01fcd\",\n                          \"HA\",\n                          null,\n                          null,\n                          \"\",\n                          process.env.PRIMARY_HOST,\n                          \"localhost:50000\"\n                      ],\n                      [\n                          \"default\",\n                          \"49cff431-cfc0-11e7-bb87-080027d01fcd\",\n                          \"HA\",\n                          null,\n                          null,\n                          \"\",\n                          process.env.SECONDARY_1_HOST,\n                          \"127.0.0.1:50010\"\n                      ],\n                      [\n                          \"default\",\n                          \"56d0f99d-cfc0-11e7-bb0a-080027d01fcd\",\n                          \"HA\",\n                          null,\n                          null,\n                          \"\",\n                          process.env.SECONDARY_2_HOST,\n                          \"127.0.0.1:50020\"\n                      ],\n                      [\n                          \"default\",\n                          \"6689460c-cfc0-11e7-907b-080027d01fcd\",\n                          \"HA\",\n                          null,\n                          null,\n                          \"\",\n                          process.env.SECONDARY_3_HOST,\n                          \"127.0.0.1:50030\"\n                      ]\n                  ]\n            }\n          };\n        }\n        else if (stmt === \"show status like 'group_replication_primary_member'\") {\n          return {\n            result: {\n              columns: [\n                  {\n                      name: \"Variable_name\",\n                      type: \"VAR_STRING\"\n                  },\n                  {\n                      name: \"Value\",\n                      type: \"VAR_STRING\"\n                  }\n              ],\n              rows: [\n                  [\n                      \"group_replication_primary_member\",\n                      \"37dbb0e3-cfc0-11e7-8039-080027d01fcd\"\n                  ]\n              ]\n            },\n          };\n        }\n        else if (stmt === \"SELECT member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode FROM performance_schema.replication_group_members WHERE channel_name = 'group_replication_applier'\") {\n          return {\n            result: {\n              columns: [\n                  {\n                      name: \"member_id\",\n                      type: \"STRING\"\n                  },\n                  {\n                      name: \"member_host\",\n                      type: \"STRING\"\n                  },\n                  {\n                      name: \"member_port\",\n                      type: \"LONG\"\n                  },\n                  {\n                      name: \"member_state\",\n                      type: \"STRING\"\n                  },\n                  {\n                      name: \"@@group_replication_single_primary_mode\",\n                      type: \"LONGLONG\"\n                  }\n              ],\n              rows: [\n                      [\n                          \"37dbb0e3-cfc0-11e7-8039-080027d01fcd\",\n                          \"areliga-Ubuntu16\",\n                          process.env.PRIMARY_PORT,\n                          \"ONLINE\",\n                          \"1\"\n                      ],\n                      [\n                          \"49cff431-cfc0-11e7-bb87-080027d01fcd\",\n                          \"areliga-Ubuntu16\",\n                          process.env.SECONDARY_1_PORT,\n                          \"ONLINE\",\n                          \"1\"\n                      ],\n                      [\n                          \"56d0f99d-cfc0-11e7-bb0a-080027d01fcd\",\n                          \"areliga-Ubuntu16\",\n                          process.env.SECONDARY_2_PORT,\n                          \"ONLINE\",\n                          \"1\"\n                      ],\n                      [\n                          \"6689460c-cfc0-11e7-907b-080027d01fcd\",\n                          \"areliga-Ubuntu16\",\n                          process.env.SECONDARY_3_PORT,\n                          \"ONLINE\",\n                          \"1\"\n                      ]\n              ]\n            },\n          };\n        }\n        else if (stmt === \"select @@port\") {\n          return {\n            result: {\n              columns: [\n                {\n                  name: \"@@port\",\n                  type: \"LONG\"\n                }\n              ],\n              rows: [\n                [ mysqld.session.port ]\n              ]\n            },\n          };\n        }\n        else {\n          return {\n            error: {\n              code: 1273,\n              sql_state: \"HY001\",\n              message: \"Syntax Error at: \" + stmt\n            }\n          };\n        }\n      }\n    }\n})\n"
  },
  {
    "path": "tests/component/data/metadata_4_secondaries_partitioning.js",
    "content": "if (mysqld.global.cluster_partition == undefined) {\n  mysqld.global.cluster_partition = false;\n}\n\n({\n  stmts: function (stmt) {\n    if (stmt === \"SELECT R.replicaset_name, I.mysql_server_uuid, I.role, I.weight, I.version_token, H.location, I.addresses->>'$.mysqlClassic', I.addresses->>'$.mysqlX' FROM mysql_innodb_cluster_metadata.clusters AS F JOIN mysql_innodb_cluster_metadata.replicasets AS R ON F.cluster_id = R.cluster_id JOIN mysql_innodb_cluster_metadata.instances AS I ON R.replicaset_id = I.replicaset_id JOIN mysql_innodb_cluster_metadata.hosts AS H ON I.host_id = H.host_id WHERE F.cluster_name = 'test';\") {\n      return {\n        result : {\n                columns : [\n                    {\n                        \"name\": \"replicaset_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"mysql_server_uuid\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"role\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"weight\",\n                        \"type\": \"FLOAT\"\n                    },\n                    {\n                        \"name\": \"version_token\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"location\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"I.addresses->>'$.mysqlClassic'\",\n                        \"type\": \"LONGBLOB\"\n                    },\n                    {\n                        \"name\": \"I.addresses->>'$.mysqlX'\",\n                        \"type\": \"LONGBLOB\"\n                    }\n                ],\n                rows : [\n                    [\n                        \"default\",\n                        \"199b2df7-4aaf-11e6-bb16-28b2bd168d07\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.PRIMARY_HOST,\n                        \"localhost:50000\"\n                    ],\n                    [\n                        \"default\",\n                        \"199bb88e-4aaf-11e6-babe-28b2bd168d07\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.SECONDARY_1_HOST,\n                        \"127.0.0.1:50010\"\n                    ],\n                    [\n                        \"default\",\n                        \"1999b9fb-4aaf-11e6-bb54-28b2bd168d07\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.SECONDARY_2_HOST,\n                        \"127.0.0.1:50020\"\n                    ],\n                    [\n                        \"default\",\n                        \"19ab72fc-4aaf-11e6-bb51-28b2bd168d07\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.SECONDARY_3_HOST,\n                        \"127.0.0.1:50030\"\n                    ],\n                    [\n                        \"default\",\n                        \"19b33846-4aaf-11e6-ba81-28b2bd168d07\",\n                        \"HA\",\n                        null,\n                        null,\n                        \"\",\n                        process.env.SECONDARY_4_HOST,\n                        \"127.0.0.1:50040\"\n                    ]\n                ]\n            }\n      };\n    }\n    else if (stmt === \"show status like 'group_replication_primary_member'\") {\n      return {\n          result : {\n                columns : [\n                    {\n                        \"name\": \"Variable_name\",\n                        \"type\": \"VAR_STRING\"\n                    },\n                    {\n                        \"name\": \"Value\",\n                        \"type\": \"VAR_STRING\"\n                    }\n                ],\n                rows : [\n                    [\n                        \"group_replication_primary_member\",\n                        \"199b2df7-4aaf-11e6-bb16-28b2bd168d07\"\n                    ]\n                ]\n            }\n      };\n    }\n    else if (stmt === \"SELECT member_id, member_host, member_port, member_state, @@group_replication_single_primary_mode FROM performance_schema.replication_group_members WHERE channel_name = 'group_replication_applier'\") {\n      if (!mysqld.global.cluster_partition) {\n        return {\n            result : {\n                columns : [\n                    {\n                        \"name\": \"member_id\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"member_host\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"member_port\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"member_state\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"@@group_replication_single_primary_mode\",\n                        \"type\": \"LONGLONG\"\n                    }\n                ],\n                rows : [\n                    [\n                        \"199b2df7-4aaf-11e6-bb16-28b2bd168d07\",\n                        \"areliga-Ubuntu16\",\n                        process.env.PRIMARY_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ],\n                    [\n                        \"199bb88e-4aaf-11e6-babe-28b2bd168d07\",\n                        \"areliga-Ubuntu16\",\n                        process.env.SECONDARY_1_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ],\n                    [\n                        \"1999b9fb-4aaf-11e6-bb54-28b2bd168d07\",\n                        \"areliga-Ubuntu16\",\n                        process.env.SECONDARY_2_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ],\n                    [\n                        \"19ab72fc-4aaf-11e6-bb51-28b2bd168d07\",\n                        \"areliga-Ubuntu16\",\n                        process.env.SECONDARY_3_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ],\n                    [\n                        \"19b33846-4aaf-11e6-ba81-28b2bd168d07\",\n                        \"areliga-Ubuntu16\",\n                        process.env.SECONDARY_4_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ]\n                ]\n            }\n        };\n      }\n      else {\n        return {\n            result : {\n                columns : [\n                    {\n                        \"name\": \"member_id\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"member_host\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"member_port\",\n                        \"type\": \"LONG\"\n                    },\n                    {\n                        \"name\": \"member_state\",\n                        \"type\": \"STRING\"\n                    },\n                    {\n                        \"name\": \"@@group_replication_single_primary_mode\",\n                        \"type\": \"LONGLONG\"\n                    }\n                ],\n                rows : [\n                    [\n                        \"199b2df7-4aaf-11e6-bb16-28b2bd168d07\",\n                        \"areliga-Ubuntu16\",\n                        process.env.PRIMARY_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ],\n                    [\n                        \"199bb88e-4aaf-11e6-babe-28b2bd168d07\",\n                        \"areliga-Ubuntu16\",\n                        process.env.SECONDARY_1_PORT,\n                        \"ONLINE\",\n                        \"1\"\n                    ],\n                    [\n                        \"1999b9fb-4aaf-11e6-bb54-28b2bd168d07\",\n                        \"areliga-Ubuntu16\",\n                        process.env.SECONDARY_2_PORT,\n                        \"UNREACHABLE\",\n                        \"1\"\n                    ],\n                    [\n                        \"19ab72fc-4aaf-11e6-bb51-28b2bd168d07\",\n                        \"areliga-Ubuntu16\",\n                        process.env.SECONDARY_3_PORT,\n                        \"UNREACHABLE\",\n                        \"1\"\n                    ],\n                    [\n                        \"19b33846-4aaf-11e6-ba81-28b2bd168d07\",\n                        \"areliga-Ubuntu16\",\n                        process.env.SECONDARY_4_PORT,\n                        \"UNREACHABLE\",\n                        \"1\"\n                    ]\n                ]\n            }\n        };\n      }\n    }\n    else if (stmt === \"select @@port\") {\n      return {\n        result: {\n          columns: [\n            {\n              name: \"@@port\",\n              type: \"LONG\"\n            }\n          ],\n          rows: [\n            [ mysqld.session.port ]\n          ]\n        },\n      };\n    }\n    else {\n      return {\n        error: {\n          code: 1273,\n          sql_state: \"HY001\",\n          message: \"Syntax Error at: \" + stmt\n        }\n      };\n    }\n  }\n})\n"
  },
  {
    "path": "tests/component/data/my_port.js",
    "content": "{\n    \"stmts\": [\n        {\n            \"stmt\": \"select @@port\",\n            \"result\": {\n                \"columns\": [\n                    {\n                        \"name\": \"@@port\",\n                        \"type\": \"STRING\"\n                    }\n                ],\n\n                \"rows\": [\n                    [\n                       process.env.MY_PORT\n                    ]\n\n                ]\n\n            }\n\n       },\n      {\n          \"stmt\": \"select @@port\",\n          \"result\": {\n              \"columns\": [\n                  {\n                      \"name\": \"@@port\",\n                      \"type\": \"STRING\"\n                  }\n              ],\n\n              \"rows\": [\n                  [\n                     process.env.MY_PORT\n                  ]\n\n              ]\n\n          }\n\n     },\n    {\n        \"stmt\": \"select @@port\",\n        \"result\": {\n            \"columns\": [\n                {\n                    \"name\": \"@@port\",\n                    \"type\": \"STRING\"\n                }\n            ],\n\n            \"rows\": [\n                [\n                   process.env.MY_PORT\n                ]\n\n            ]\n\n        }\n\n   },\n       {\n        \"stmt\": \"select @@port\",\n        \"result\": {\n            \"columns\": [\n                {\n                    \"name\": \"@@port\",\n                    \"type\": \"STRING\"\n                }\n            ],\n\n            \"rows\": [\n                [\n                   process.env.MY_PORT\n                ]\n\n            ]\n\n        }\n\n   },\n       {\n        \"stmt\": \"select @@port\",\n        \"result\": {\n            \"columns\": [\n                {\n                    \"name\": \"@@port\",\n                    \"type\": \"STRING\"\n                }\n            ],\n\n            \"rows\": [\n                [\n                   process.env.MY_PORT\n                ]\n\n            ]\n\n        }\n\n   },\n       {\n        \"stmt\": \"select @@port\",\n        \"result\": {\n            \"columns\": [\n                {\n                    \"name\": \"@@port\",\n                    \"type\": \"STRING\"\n                }\n            ],\n\n            \"rows\": [\n                [\n                   process.env.MY_PORT\n                ]\n\n            ]\n\n        }\n\n   }\n    ]\n}\n"
  },
  {
    "path": "tests/component/data/rest_server_mock.js",
    "content": "({\n  stmts: function (stmt) {\n    if (stmt === \"select @@port\") {\n      return {\n        result: {\n          columns: [\n            {\n              name: \"@@port\",\n              type: \"LONG\"\n            }\n          ],\n          rows: [\n            [ mysqld.session.port ]\n          ]\n        },\n      };\n    } else {\n      return {\n        error: {\n          code: 1273,\n          sql_state: \"HY001\",\n          message: \"Syntax Error at: \" + stmt\n        }\n      };\n    }\n  }\n})\n"
  },
  {
    "path": "tests/component/data/simple-client.js",
    "content": "var statements = require(\"common_statements\");\nvar gr_memberships = require(\"gr_memberships\");\n\nvar gr_membership = gr_memberships.single_host(\"127.0.0.1\", [\n  [ process.env.SECONDARY_1_PORT, \"ONLINE\" ],\n  [ process.env.SECONDARY_2_PORT, \"ONLINE\" ],\n]);\n\nvar test_options = {\n  group_replication_membership: gr_membership,\n  group_replication_primary_member: gr_membership[0][0],\n};\n\n/**\n *\n */\nfunction my_query_generator() {\n  return new Duktape.Thread(function(stmt) {\n    var yield = Duktape.Thread.yield;\n    var mysql_client_select_user = statements.get(\"mysql_client_select_user\");\n    var mysql_client_select_version_comment = statements.get(\"mysql_client_select_version_comment\");\n    var select_port = statements.get(\"select_port\");\n\n    while(true) {\n      if (stmt === mysql_client_select_user.stmt) {\n        stmt = yield(mysql_client_select_user);\n      } else if (stmt === mysql_client_select_version_comment.stmt) {\n        stmt = yield(mysql_client_select_version_comment);\n      } else if (stmt === select_port.stmt) {\n        stmt = yield(select_port);\n      } else {\n        stmt = yield({\n          error: {\n            code: 1273,\n            sql_state: \"HY001\",\n            message: \"Syntax Error at: \" + stmt\n          }\n        });\n      }\n    }\n  });\n}\n\n({\n  stmts: my_query_generator()\n})\n"
  },
  {
    "path": "tests/component/data/test_modules/test-require-dir-with-indexjs/index.js",
    "content": "exports.me = \"dir-with-index.js\";\n"
  },
  {
    "path": "tests/component/data/test_modules/test-require-dir-with-packagejson/foo.js",
    "content": "exports.me = \"dir-with-package.json\";\n"
  },
  {
    "path": "tests/component/data/test_modules/test-require-dir-with-packagejson/package.json",
    "content": "{\n  \"main\": \"foo.js\"\n}\n"
  },
  {
    "path": "tests/component/data/test_modules/test-require-direct.js",
    "content": "var c = 0;\n\nexports.me = \"direct\";\nexports.counter = function() {\n  return c++;\n}\n"
  },
  {
    "path": "tests/component/data/test_modules/test-require-nesting-1.js",
    "content": "require(\"test-require-nesting-2\")\n"
  },
  {
    "path": "tests/component/data/test_modules/test-require-nesting-2.js",
    "content": "require(\"test-require-nesting-3\")\n"
  },
  {
    "path": "tests/component/data/test_modules/test-require-nesting-3.js",
    "content": "require(\"test-require-nesting-4\")\n"
  },
  {
    "path": "tests/component/data/test_modules/test-require-nesting-4.js",
    "content": "require(\"test-require-nesting-5\")\n"
  },
  {
    "path": "tests/component/data/test_modules/test-require-nesting-5.js",
    "content": "// a parse-error\n\n[\n"
  },
  {
    "path": "tests/component/test_bootstrap.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <fstream>\n\n#include \"gmock/gmock.h\"\n#include \"dim.h\"\n#include \"keyring/keyring_manager.h\"\n#include \"random_generator.h\"\n#include \"router_component_test.h\"\n#include \"socket_operations.h\"\n#include \"script_generator.h\"\n#include \"tcp_port_pool.h\"\n#include \"utils.h\"\n\n/**\n * @file\n * @brief Component Tests for the bootstrap operation\n */\n\nPath g_origin_path;\n\n// we create a number of classes to logically group tests together. But to avoid code\n// duplication, we derive them from a class which contains the common code they need.\nclass CommonBootstrapTest : public RouterComponentTest, public ::testing::Test {\n protected:\n  static void SetUpTestCase() {\n    my_hostname = \"dont.query.dns\";\n  }\n\n  void SetUp() override {\n    set_origin(g_origin_path);\n    RouterComponentTest::SetUp();\n    bootstrap_dir = get_tmp_dir();\n    tmp_dir = get_tmp_dir();\n  }\n\n  virtual void TearDown() override {\n    purge_dir(tmp_dir);\n    purge_dir(bootstrap_dir);\n  }\n\n  TcpPortPool port_pool_;\n  std::string bootstrap_dir;\n  std::string tmp_dir;\n  static std::string my_hostname;\n\n  struct Config {\n    std::string ip;\n    unsigned int port;\n    std::string in_filename;\n    std::string out_filename;\n  };\n\n  void bootstrap_failover(const std::vector<Config> &servers,\n      const std::vector<std::string> &router_options = {},\n      int expected_exitcode = 0,\n      const std::vector<std::string> &expected_output_regex = {},\n      unsigned wait_for_exit_timeout_ms = 10000);\n\n  friend std::ostream &operator<<(std::ostream & os, const std::vector<std::tuple<RouterComponentTest::CommandHandle, unsigned int>> &T);\n};\n\nstd::string CommonBootstrapTest::my_hostname;\n\nstd::ostream &operator<<(std::ostream & os, const std::vector<std::tuple<CommonBootstrapTest::CommandHandle, unsigned int>> &T) {\n  for (auto &t: T) {\n    auto &proc = std::get<0>(t);\n\n    os << \"member@\" << std::to_string(std::get<1>(t)) << \": \"\n      << proc.get_current_output()\n      << std::endl;\n  }\n  return os;\n}\n\n/**\n * the tiny power function that does all the work.\n *\n * - build environment\n * - start mock servers based on Config[]\n * - pass router_options to the launched router\n * - check the router exits as expected\n * - check output of router contains the expected lines\n */\nvoid\nCommonBootstrapTest::bootstrap_failover(\n    const std::vector<Config> &mock_server_configs,\n    const std::vector<std::string> &router_options,\n    int expected_exitcode,\n    const std::vector<std::string> &expected_output_regex,\n    unsigned wait_for_exit_timeout_ms) {\n  std::string cluster_name(\"mycluster\");\n\n  // build environment\n  std::map<std::string, std::string> env_vars = {\n    { \"MYSQL_SERVER_MOCK_CLUSTER_NAME\", cluster_name },\n    { \"MYSQL_SERVER_MOCK_HOST_NAME\", my_hostname },\n  };\n\n  unsigned int ndx = 1;\n\n  for (const auto &mock_server_config: mock_server_configs) {\n    env_vars.emplace(\"MYSQL_SERVER_MOCK_HOST_\" + std::to_string(ndx), mock_server_config.ip);\n    env_vars.emplace(\"MYSQL_SERVER_MOCK_PORT_\" + std::to_string(ndx), std::to_string(mock_server_config.port));\n    ndx++;\n  };\n\n  std::vector<std::tuple<CommandHandle, unsigned int>> mock_servers;\n\n  // start the mocks\n  for (const auto &mock_server_config: mock_server_configs) {\n    unsigned int port = mock_server_config.port;\n    const std::string &in_filename = mock_server_config.in_filename;\n    const std::string &out_filename = mock_server_config.out_filename;\n\n    if (in_filename.size()) {\n      rewrite_js_to_tracefile(in_filename, out_filename, env_vars);\n    }\n\n    if (out_filename.size()) {\n      mock_servers.emplace_back(\n            launch_mysql_server_mock(out_filename, port, false),\n            port);\n    }\n  }\n\n  // wait for all mocks to be up\n  for (auto &mock_server: mock_servers) {\n    auto &proc = std::get<0>(mock_server);\n    unsigned int port = std::get<1>(mock_server);\n\n    bool ready = wait_for_port_ready(port, 1000);\n    EXPECT_TRUE(ready) << proc.get_full_output();\n  }\n\n  std::string router_cmdline;\n\n  if (router_options.size()) {\n    for (const auto &piece: router_options) {\n      router_cmdline += piece;\n      router_cmdline += \" \";\n    }\n  } else {\n    router_cmdline = \"--bootstrap=\" + env_vars.at(\"MYSQL_SERVER_MOCK_HOST_1\")\n                   + \":\" + env_vars.at(\"MYSQL_SERVER_MOCK_PORT_1\")\n                   + \" --report-host \" + my_hostname\n                   + \" -d \" + bootstrap_dir;\n  }\n\n  // launch the router\n  auto router = launch_router(router_cmdline);\n\n  // type in the password\n  router.register_response(\"Please enter MySQL password for root: \", \"fake-pass\\n\");\n\n  // wait_for_exit() throws at timeout.\n  EXPECT_NO_THROW(EXPECT_EQ(router.wait_for_exit(wait_for_exit_timeout_ms), expected_exitcode));\n\n  // split the output into lines\n  std::vector<std::string> lines;\n  {\n    std::istringstream ss { router.get_full_output() };\n\n    for (std::string line; std::getline(ss, line); ) {\n      lines.emplace_back(line);\n    }\n  }\n\n  for (auto const &re_str: expected_output_regex) {\n    EXPECT_THAT(lines, ::testing::Contains(::testing::ContainsRegex(re_str)))\n      << \"router:\" << router.get_full_output() << std::endl\n      << mock_servers;\n  }\n\n  if (0 == expected_exitcode) {\n    // fetch all the content for debugging\n    for (auto &mock_server: mock_servers) {\n      std::get<0>(mock_server).get_full_output();\n    }\n    EXPECT_THAT(lines, ::testing::Contains(\"MySQL Router  has now been configured for the InnoDB cluster '\" + cluster_name + \"'.\"))\n      << \"router:\" << router.get_full_output() << std::endl\n      << mock_servers;\n\n    // check the output configuration file:\n    // we check if the valid default ttl has been put in the configuraion\n    EXPECT_TRUE(find_in_file(bootstrap_dir+\"/mysqlrouter.conf\",\n      [](const std::string& line) -> bool { return line == \"ttl=0.5\"; },\n      std::chrono::milliseconds(0)));\n  }\n}\n\n\n\nclass RouterBootstrapTest : public CommonBootstrapTest {};\n\n/**\n * @test\n *       verify that the router's \\c --bootstrap can bootstrap\n *       from metadata-servers's PRIMARY over TCP/IP\n * @test\n *       Group Replication roles:\n *       - PRIMARY\n *       - SECONDARY (not used)\n *       - SECONDARY (not used)\n */\nTEST_F(RouterBootstrapTest, BootstrapOk) {\n  std::vector<Config> config {\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      \"\",\n      get_data_dir().join(\"bootstrap.js\").str()\n    },\n  };\n\n  bootstrap_failover(config);\n}\n\n/**\n * @test\n *       verify that the router's \\c --bootstrap can bootstrap\n *       from metadata-server's PRIMARY over TCP/IP and generate\n *       a configuration with unix-sockets only\n * @test\n *       Group Replication roles:\n *       - PRIMARY\n *       - SECONDARY (not used)\n *       - SECONDARY (not used)\n */\nTEST_F(RouterBootstrapTest, BootstrapOnlySockets) {\n  std::vector<Config> mock_servers {\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      \"\",\n      get_data_dir().join(\"bootstrap.js\").str()\n    },\n  };\n\n  std::vector<std::string> router_options = {\n    \"--bootstrap=\" + mock_servers.at(0).ip + \":\" + std::to_string(mock_servers.at(0).port),\n    \"-d\", bootstrap_dir,\n    \"--report-host\", my_hostname,\n    \"--conf-skip-tcp\",\n    \"--conf-use-sockets\"\n  };\n\n  bootstrap_failover(mock_servers, router_options,\n#ifndef _WIN32\n      0,\n      {\n        \"- Read/Write Connections: .*/mysqlx.sock\",\n        \"- Read/Only Connections: .*/mysqlxro.sock\"\n      }\n#else\n      1,\n      {\n        \"Error: unknown option '--conf-skip-tcp'\"\n      }\n#endif\n  );\n}\n\n/**\n * @test\n *       verify that the router's \\c --bootstrap detects a unsupported\n *       metadata schema version\n * @test\n *       Group Replication roles:\n *       - PRIMARY\n *       - SECONDARY (not used)\n *       - SECONDARY (not used)\n */\nTEST_F(RouterBootstrapTest, BootstrapUnsupportedSchemaVersion) {\n  std::vector<Config> mock_servers {\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      \"\",\n      get_data_dir().join(\"bootstrap_unsupported_schema_version.js\").str()\n    },\n  };\n\n  // check that it failed as expected\n  bootstrap_failover(mock_servers, {},\n      1,\n      {\n        \"^Error: This version of MySQL Router is not compatible with the provided MySQL InnoDB cluster metadata\"\n      }\n  );\n}\n\n/**\n * @test\n *       verify that bootstrap will fail-over to another node if the initial\n *       node is not writable\n * @test\n *       Group Replication roles:\n *       - SECONDARY\n *       - PRIMARY\n *       - SECONDARY (not used)\n */\nTEST_F(RouterBootstrapTest, BootstrapFailoverSuperReadonly) {\n  std::vector<Config> config {\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      get_data_dir().join(\"bootstrap_failover_super_read_only_1.js\").str(),\n      Path(tmp_dir).join(\"bootstrap_failover_super_read_only_1.json\").str()\n    },\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      \"\",\n      get_data_dir().join(\"bootstrap_failover_super_read_only_2.js\").str()\n    },\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      \"\",\n      \"\"\n    },\n  };\n\n  bootstrap_failover(config);\n}\n\n/**\n * @test\n *       verify that bootstrap will fail-over to another node if the initial\n *       node is not writable and 2nd candidate has connection problems\n * @test\n *       Group Replication roles:\n *       - SECONDARY\n *       - <connect-failure>\n *       - PRIMARY\n * @test\n *       connection problems could be anything from 'auth-failure' to 'network-errors'.\n *       This test uses a \\c port==0 to create a failure which is reserved and unassigned.\n *\n * @note The implementation uses \\c port=65536 to circumvents libmysqlclients \\code{.py}\n *       if port == 0:\n *         port = 3306 \\endcode default port assignment.\n *       As the port will later be narrowed to an 16bit unsigned integer \\code port & 0xffff \\endcode\n *       the code will connect to port 0 in the end.\n *\n * @todo As soon as the mysql-server-mock supports authentication failures\n *       the code can take that into account too.\n */\nTEST_F(RouterBootstrapTest, BootstrapFailoverSuperReadonly2ndNodeDead) {\n  std::vector<Config> config {\n    // member-1, PRIMARY, fails at first write\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      get_data_dir().join(\"bootstrap_failover_super_read_only_1.js\").str(),\n      Path(tmp_dir).join(\"member-1.json\").str()\n    },\n    // member-2, unreachable\n    {\n      \"127.0.0.1\", 65536, // 65536 % 0xffff = 0 (port 0), but we bypass libmysqlclient's default-port assignment\n      \"\",\n      \"\"\n    },\n    // member-3, succeeds\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      \"\",\n      get_data_dir().join(\"bootstrap_failover_super_read_only_2.js\").str()\n    },\n  };\n\n  bootstrap_failover(config, {}, 0, {\n      \"^Fetching Group Replication Members\",\n      \"^Failed connecting to 127\\\\.0\\\\.0\\\\.1:65536: .*, trying next$\",\n  });\n}\n\n/**\n * @test\n *       verify that bootstrap fails over and continues if create-account fails\n *       due to 1st node not being writable\n * @test\n *       Group Replication roles:\n *       - SECONDARY\n *       - PRIMARY\n *       - SECONDARY (not used)\n */\nTEST_F(RouterBootstrapTest, BootstrapFailoverSuperReadonlyCreateAccountFails) {\n  std::vector<Config> config {\n    // member-1: SECONDARY, fails at DROP USER due to RW request on RO node\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      get_data_dir().join(\"bootstrap_failover_super_read_only_dead_2nd_1.js\").str(),\n      Path(tmp_dir).join(\"member-1.json\").str()\n    },\n\n    // member-2: PRIMARY, succeeds\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      get_data_dir().join(\"bootstrap_failover_reconfigure_ok.js\").str(),\n      Path(tmp_dir).join(\"member-2.json\").str()\n    },\n\n    // member-3: defined, but unused\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      \"\",\n      \"\"\n    },\n  };\n\n  bootstrap_failover(config);\n}\n\n/**\n * @test\n *       verify that bootstrap fails over and continues if create-account.drop-user fails\n *       due to 1st node not being writable\n * @test\n *       Group Replication roles:\n *       - SECONDARY\n *       - PRIMARY\n *       - SECONDARY (not used)\n *\n */\nTEST_F(RouterBootstrapTest, BootstrapFailoverSuperReadonlyCreateAccountDropUserFails) {\n  std::vector<Config> config {\n    // member-1: SECONDARY, fails on CREATE USER due to RW request on RO node\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      get_data_dir().join(\"bootstrap_failover_super_read_only_delete_user.js\").str(),\n      Path(tmp_dir).join(\"member-1.json\").str()\n    },\n\n    // member-2: PRIMARY, succeeds\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      get_data_dir().join(\"bootstrap_failover_reconfigure_ok_3_old_users.js\").str(),\n      Path(tmp_dir).join(\"member-2.json\").str()\n    },\n\n    // member-3: defined, but unused\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      \"\",\n      \"\"\n    },\n  };\n\n  bootstrap_failover(config);\n}\n\n/**\n * @test\n *       verify that bootstrap fails over and continues if create-account.grant fails\n * @test\n *       Group Replication roles:\n *       - SECONDARY\n *       - PRIMARY\n *       - SECONDARY (not used)\n *\n */\nTEST_F(RouterBootstrapTest, BootstrapFailoverSuperReadonlyCreateAccountGrantFails) {\n  std::vector<Config> config {\n    // member-1: PRIMARY, fails after GRANT\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      get_data_dir().join(\"bootstrap_failover_at_grant.js\").str(),\n      Path(tmp_dir).join(\"member-1.json\").str()\n    },\n\n    // member-2: PRIMARY, succeeds\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      get_data_dir().join(\"bootstrap_failover_reconfigure_ok.js\").str(),\n      Path(tmp_dir).join(\"member-2.json\").str()\n    },\n\n    // member-3: defined, but unused\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      \"\",\n      \"\"\n    },\n  };\n\n  bootstrap_failover(config);\n}\n\n/**\n * @test\n *       verify that bootstraping via a unix-socket fails over to the IP-addresses\n *       of the members\n * @test\n *       Group Replication roles:\n *       - SECONDARY\n *       - PRIMARY\n *       - SECONDARY (not used)\n * @test\n *       Initial connect via unix-socket to the 1st node, all further connects via TCP/IP\n *\n * @todo needs unix-socket support in the mock-server\n */\nTEST_F(RouterBootstrapTest, DISABLED_BootstrapFailoverSuperReadonlyFromSocket) {\n  std::vector<Config> mock_servers {\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      get_data_dir().join(\"bootstrap_failover_super_read_only_1.js\").str(),\n      Path(tmp_dir).join(\"bootstrap_failover_super_read_only_1.json\").str()\n    },\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      \"\",\n      get_data_dir().join(\"bootstrap_failover_super_read_only_2.js\").str()\n    },\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      \"\",\n      \"\"\n    },\n  };\n\n  std::vector<std::string> router_options = {\n    \"--bootstrap=localhost\",\n    \"--bootstrap-socket=\" + mock_servers.at(0).ip,\n    \"-d\", bootstrap_dir\n  };\n\n  bootstrap_failover(mock_servers, router_options);\n}\n\n/**\n * @test\n *       verify that bootstrap fails over if PRIMARY crashes while bootstrapping\n *\n * @test\n *       Group Replication roles:\n *       - SECONDARY\n *       - PRIMARY (crashing)\n *       - PRIMARY\n */\nTEST_F(RouterBootstrapTest, BootstrapFailoverSuperReadonlyNewPrimaryCrash) {\n  std::vector<Config> mock_servers {\n    // member-1: PRIMARY, fails at DROP USER\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      get_data_dir().join(\"bootstrap_failover_super_read_only_dead_2nd_1.js\").str(),\n      Path(tmp_dir).join(\"member-1.json\").str()\n    },\n\n    // member-2: PRIMARY, but crashing\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      get_data_dir().join(\"bootstrap_failover_at_crash.js\").str(),\n      Path(tmp_dir).join(\"member-2.json\").str()\n    },\n\n    // member-3: newly elected PRIMARY, succeeds\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      get_data_dir().join(\"bootstrap_failover_reconfigure_ok.js\").str(),\n      Path(tmp_dir).join(\"member-3.json\").str()\n    },\n  };\n\n  bootstrap_failover(mock_servers);\n}\n\n/**\n * @test\n *        verify connection times at bootstrap can be configured\n */\nTEST_F(RouterBootstrapTest, BootstrapSucceedWhenServerResponseLessThanReadTimeout) {\n  std::vector<Config> mock_servers {\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      \"\",\n      get_data_dir().join(\"bootstrap_exec_time_2_seconds.js\").str()\n    },\n  };\n\n  std::vector<std::string> router_options = {\n    \"--bootstrap=\" + mock_servers.at(0).ip + \":\" + std::to_string(mock_servers.at(0).port),\n    \"--report-host\", my_hostname,\n    \"-d\", bootstrap_dir,\n    \"--connect-timeout=3\",\n    \"--read-timeout=3\"\n  };\n\n  bootstrap_failover(mock_servers, router_options,\n      0,\n      {});\n}\n\nTEST_F(RouterBootstrapTest, BootstrapAccessErrorAtGrantStatement) {\n  std::vector<Config> config {\n    // member-1: PRIMARY, fails after GRANT\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      get_data_dir().join(\"bootstrap_access_error_at_grant.js\").str(),\n      Path(tmp_dir).join(\"member-1.json\").str()\n    },\n\n    // member-2: defined, but unused\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      \"\",\n      \"\"\n    },\n\n    // member-3: defined, but unused\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      \"\",\n      \"\"\n    },\n  };\n\n  bootstrap_failover(config, {}, 1,\n    {\n      \"Access denied for user 'native'@'%' to database 'mysql_innodb_cluster_metadata\"\n    });\n}\n\n/**\n * @test\n *        verify connection times at bootstrap can be configured\n */\nTEST_F(RouterBootstrapTest, BootstrapFailWhenServerResponseExceedsReadTimeout) {\n  std::vector<Config> mock_servers {\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      \"\",\n      get_data_dir().join(\"bootstrap_exec_time_2_seconds.js\").str()\n    },\n  };\n\n  std::vector<std::string> router_options = {\n    \"--bootstrap=\" + mock_servers.at(0).ip + \":\" + std::to_string(mock_servers.at(0).port),\n    \"-d\", bootstrap_dir,\n    \"--connect-timeout=1\",\n    \"--read-timeout=1\"\n  };\n\n  bootstrap_failover(mock_servers, router_options,\n      1,\n      {\n        \"Error: Error executing MySQL query: Lost connection to MySQL server during query \\\\(2013\\\\)\"\n      });\n}\n\n\n\nclass RouterAccountHostTest : public CommonBootstrapTest {};\n\n/**\n * @test\n *        verify that --account-host:\n *        - works in general\n *        - can be applied multiple times in one go\n *        - can take '%' as a parameter\n */\nTEST_F(RouterAccountHostTest, multiple_host_patterns) {\n  // to avoid duplication of tracefiles, we run the same test twice, with the\n  // only difference that 1st time we run --bootstrap before the --account-host,\n  // and second time we run it after\n\n  const std::string bootstrap_directory = get_tmp_dir();\n  const unsigned server_port = port_pool_.get_next_available();\n\n  auto test_it = [&](const std::string& cmdline) -> void {\n    const std::string json_stmts = get_data_dir().join(\"bootstrap_account_host_multiple_patterns.js\").str();\n\n    // launch mock server and wait for it to start accepting connections\n    auto server_mock = launch_mysql_server_mock(json_stmts, server_port, false);\n    bool ready = wait_for_port_ready(server_port, 1000);\n    EXPECT_TRUE(ready) << server_mock.get_full_output();\n\n    // launch the router in bootstrap mode\n    std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(bootstrap_directory);});\n    auto router = launch_router(cmdline);\n\n    // add login hook\n    router.register_response(\"Please enter MySQL password for root: \", \"fake-pass\\n\");\n\n    // check if the bootstraping was successful\n    EXPECT_TRUE(router.expect_output(\"MySQL Router  has now been configured for the InnoDB cluster 'test'\")\n      ) << router.get_full_output() << std::endl << \"server: \" << server_mock.get_full_output();\n    EXPECT_EQ(router.wait_for_exit(), 0);\n  };\n\n  // NOTE: CREATE USER statements should run in unique(sort(hostname_list)) fashion\n\n  // --bootstrap before --account-host\n  test_it(\"--bootstrap=127.0.0.1:\" + std::to_string(server_port)\n          + \" --report-host \" + my_hostname\n          + \" -d \" + bootstrap_directory\n          + \" --account-host host1\"     // 2nd CREATE USER\n          + \" --account-host %\"         // 1st CREATE USER\n          + \" --account-host host1\"     // \\_ redundant, ignored\n          + \" --account-host host1\"     // /\n          + \" --account-host host3%\");  // 3rd CREATE USER\n\n  // --bootstrap after --account-host\n  test_it(\"-d \" + bootstrap_directory\n          + \" --report-host \" + my_hostname\n          + \" --account-host host1\"     // 2nd CREATE USER\n          + \" --account-host %\"         // 1st CREATE USER\n          + \" --account-host host1\"     // \\_ redundant, ignored\n          + \" --account-host host1\"     // /\n          + \" --account-host host3%\"    // 3rd CREATE USER\n          + \" --bootstrap=127.0.0.1:\" + std::to_string(server_port));\n}\n\n/**\n * @test\n *        verify that --account-host without required argument produces an error\n *        and exits\n */\nTEST_F(RouterAccountHostTest, argument_missing) {\n  const unsigned server_port = port_pool_.get_next_available();\n\n  // launch the router in bootstrap mode\n  auto router = launch_router(\"--bootstrap=127.0.0.1:\" + std::to_string(server_port)\n                              + \" --account-host\");\n\n  // check if the bootstraping was successful\n  EXPECT_TRUE(router.expect_output(\"option '--account-host' requires a value.\")\n    ) << router.get_full_output() << std::endl;\n  EXPECT_EQ(router.wait_for_exit(), 1);\n}\n\n/**\n * @test\n *        verify that --account-host without --bootstrap switch produces an error\n *        and exits\n */\nTEST_F(RouterAccountHostTest, without_bootstrap_flag) {\n  // launch the router in bootstrap mode\n  auto router = launch_router(\"--account-host host1\");\n\n  // check if the bootstraping was successful\n  EXPECT_TRUE(router.expect_output(\"Option --account-host can only be used together with -B/--bootstrap\")\n    ) << router.get_full_output() << std::endl;\n  EXPECT_EQ(router.wait_for_exit(), 1);\n}\n\n/**\n * @test\n *        verify that --account-host with illegal hostname argument correctly handles\n *        the error\n */\nTEST_F(RouterAccountHostTest, illegal_hostname) {\n  const std::string json_stmts = get_data_dir().join(\"bootstrap_account_host_pattern_too_long.js\").str();\n  const std::string bootstrap_directory = get_tmp_dir();\n  const unsigned server_port = port_pool_.get_next_available();\n\n  // launch mock server and wait for it to start accepting connections\n  auto server_mock = launch_mysql_server_mock(json_stmts, server_port, false);\n  bool ready = wait_for_port_ready(server_port, 1000);\n  EXPECT_TRUE(ready) << server_mock.get_full_output();\n\n  // launch the router in bootstrap mode\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(bootstrap_directory);});\n  auto router = launch_router(\"--bootstrap=127.0.0.1:\" + std::to_string(server_port)\n                              + \" --report-host \" + my_hostname\n                              + \" -d \" + bootstrap_directory\n                              + \" --account-host veryveryveryveryveryveryveryveryveryveryveryveryveryveryverylonghost\");\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \", \"fake-pass\\n\");\n\n  // check if the bootstraping was successful\n  EXPECT_TRUE(router.expect_output(\"Error executing MySQL query: String 'veryveryveryveryveryveryveryveryveryveryveryveryveryveryverylonghost' is too long for host name\")\n    ) << router.get_full_output() << std::endl << \"server:\\n\" << server_mock.get_full_output();\n  EXPECT_EQ(router.wait_for_exit(), 1);\n}\n\n\n\nclass RouterReportHostTest : public CommonBootstrapTest {};\n\n/**\n * @test\n *        verify that --report-host works for the typical use case\n */\nTEST_F(RouterReportHostTest, typical_usage) {\n  const std::string bootstrap_directory = get_tmp_dir();\n  const unsigned server_port = port_pool_.get_next_available();\n\n  auto test_it = [&](const std::string& cmdline) -> void {\n    const std::string json_stmts = get_data_dir().\n        join(\"bootstrap_report_host.js\").str();\n\n    // launch mock server and wait for it to start accepting connections\n    auto server_mock = launch_mysql_server_mock(json_stmts, server_port, false);\n    bool ready = wait_for_port_ready(server_port, 1000);\n    EXPECT_TRUE(ready) << server_mock.get_full_output();\n\n    // launch the router in bootstrap mode\n    std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(bootstrap_directory);});\n    auto router = launch_router(cmdline);\n\n    // add login hook\n    router.register_response(\"Please enter MySQL password for root: \", \"fake-pass\\n\");\n\n    // check if the bootstraping was successful\n    EXPECT_TRUE(router.expect_output(\"MySQL Router  has now been configured for the InnoDB cluster 'mycluster'\")\n      ) << router.get_full_output() << std::endl << \"server: \" << server_mock.get_full_output();\n    EXPECT_EQ(router.wait_for_exit(), 0);\n  };\n\n  // --bootstrap before --report-host\n  test_it(\"--bootstrap=127.0.0.1:\" + std::to_string(server_port)\n          + \" -d \" + bootstrap_directory\n          + \" --report-host host.foo.bar\");\n\n  // --bootstrap after --report-host\n  test_it(\"-d \" + bootstrap_directory\n          + \" --report-host host.foo.bar\"\n          + \" --bootstrap=127.0.0.1:\" + std::to_string(server_port));\n}\n\n/**\n * @test\n *        verify that multiple --report-host arguments produce an error\n *        and exit\n */\nTEST_F(RouterReportHostTest, multiple_hostnames) {\n  // launch the router in bootstrap mode\n  auto router = launch_router(\"--bootstrap=1.2.3.4:5678 --report-host host1 --report-host host2\");\n\n  // check if the bootstraping was successful\n  EXPECT_TRUE(router.expect_output(\"Option --report-host can only be used once.\")\n    ) << router.get_full_output() << std::endl;\n  EXPECT_EQ(router.wait_for_exit(), 1);\n}\n\n/**\n * @test\n *        verify that --report-host without required argument produces an error\n *        and exits\n */\nTEST_F(RouterReportHostTest, argument_missing) {\n  // launch the router in bootstrap mode\n  auto router = launch_router(\"--bootstrap=1.2.3.4:5678 --report-host\");\n\n  // check if the bootstraping was successful\n  EXPECT_TRUE(router.expect_output(\"option '--report-host' requires a value.\")\n    ) << router.get_full_output() << std::endl;\n  EXPECT_EQ(router.wait_for_exit(), 1);\n}\n\n/**\n * @test\n *        verify that --report-host without --bootstrap switch produces an error\n *        and exits\n */\nTEST_F(RouterReportHostTest, without_bootstrap_flag) {\n  // launch the router in bootstrap mode\n  auto router = launch_router(\"--report-host host1\");\n\n  // check if the bootstraping was successful\n  EXPECT_TRUE(router.expect_output(\"Option --report-host can only be used together with -B/--bootstrap\")\n    ) << router.get_full_output() << std::endl;\n  EXPECT_EQ(router.wait_for_exit(), 1);\n}\n\n/**\n * @test\n *        verify that --report-host with invalid hostname argument produces an\n *        error and exits\n *\n * @note\n *        There's a separate suite of unit tests which tests the validating code\n *        which determines if the hostname is valid or not - therefore here we\n *        only focus on how this invalid hostname will be handled - we don't\n *        concern outselves with correctness of hostname validation itself.\n */\nTEST_F(RouterReportHostTest, invalid_hostname) {\n  // launch the router in bootstrap mode\n  auto router = launch_router({\"--bootstrap\", \"1.2.3.4:5678\", \"--report-host\", \"^bad^hostname^\"});\n\n  // check if the bootstraping was successful\n  EXPECT_TRUE(router.expect_output(\"Error: Option --report-host has an invalid value.\")\n    ) << router.get_full_output() << std::endl;\n  EXPECT_EQ(router.wait_for_exit(), 1);\n}\n\n/**\n * @test\n *       verify that bootstrap succeeds when master key writer is used\n *\n */\nTEST_F(RouterBootstrapTest, NoMasterKeyFileWhenBootstrapPassWithMasterKeyReader) {\n\n  std::vector<Config> config {\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      \"\",\n      get_data_dir().join(\"bootstrap.js\").str()\n    },\n  };\n\n  ScriptGenerator script_generator(g_origin_path, tmp_dir);\n\n  std::vector<std::string> router_options = {\n    \"--bootstrap=\" + config.at(0).ip + \":\" + std::to_string(config.at(0).port),\n    \"--report-host\", my_hostname,\n    \"-d\", bootstrap_dir,\n    \"--master-key-reader=\" + script_generator.get_reader_script(),\n    \"--master-key-writer=\" + script_generator.get_writer_script()\n  };\n\n  bootstrap_failover(config, router_options);\n\n  Path tmp(bootstrap_dir);\n  Path master_key_file(tmp.join(\"mysqlrouter.key\").str());\n  ASSERT_FALSE(master_key_file.exists());\n\n  Path keyring_file(tmp.join(\"data\").join(\"keyring\").str());\n  ASSERT_TRUE(keyring_file.exists());\n\n  Path dir(tmp_dir);\n  Path data_file(dir.join(\"master_key\").str());\n  ASSERT_TRUE(data_file.exists());\n}\n\n/**\n * @test\n *       verify that master key file is not overridden by sunsequent bootstrap.\n */\nTEST_F(RouterBootstrapTest, MasterKeyFileNotChangedAfterSecondBootstrap) {\n\n  mysql_harness::DIM& dim = mysql_harness::DIM::instance();\n  // RandomGenerator\n  dim.set_RandomGenerator(\n      []() {static mysql_harness::RandomGenerator rg; return &rg;},\n      [](mysql_harness::RandomGeneratorInterface*) {});\n\n  mysqlrouter::mkdir(Path(bootstrap_dir).str(), 0777);\n  std::string master_key_path = Path(bootstrap_dir).join(\"master_key\").str();\n  mysqlrouter::mkdir(Path(bootstrap_dir).join(\"data\").str(), 0777);\n  std::string keyring_path = Path(bootstrap_dir).join(\"data\").join(\"keyring\").str();\n\n  mysql_harness::init_keyring(keyring_path, master_key_path, true);\n\n  std::string master_key;\n  {\n    std::ifstream file(master_key_path);\n    std::stringstream iss;\n    iss << file.rdbuf();\n    master_key = iss.str();\n  }\n\n  std::vector<Config> mock_servers {\n    {\n      \"127.0.0.1\", port_pool_.get_next_available(),\n      \"\",\n      get_data_dir().join(\"bootstrap.js\").str()\n    },\n  };\n\n  std::vector<std::string> router_options = {\n    \"--bootstrap=\" + mock_servers.at(0).ip + \":\" + std::to_string(mock_servers.at(0).port),\n    \"--report-host\", my_hostname,\n    \"-d\", bootstrap_dir,\n    \"--force\"\n  };\n\n  bootstrap_failover(mock_servers, router_options,\n      0,\n      {});\n  {\n    std::ifstream file(master_key_path);\n    std::stringstream iss;\n    iss << file.rdbuf();\n    ASSERT_THAT(master_key, testing::Eq(iss.str()));\n  }\n}\n\nint main(int argc, char *argv[]) {\n  init_windows_sockets();\n  g_origin_path = Path(argv[0]).dirname();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "tests/component/test_bootstrap_system_deployment.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"common.h\"\n#include \"utils.h\"\n#include \"gmock/gmock.h\"\n#include \"router_component_test.h\"\n#include \"tcp_port_pool.h\"\n\nPath g_origin_path;\n\n\n/*\n * These tests are executed only for STANDALONE layout and are not executed for Windows.\n * Bootstrap for layouts different than STANDALONE use directories to which\n * tests don't have access (see install_layout.cmake).\n */\n#ifndef SKIP_BOOTSTRAP_SYSTEM_DEPLOYMENT_TESTS\n\nclass RouterBootstrapSystemDeploymentTest : public RouterComponentTest, public ::testing::Test {\nprotected:\n void SetUp() override {\n   set_origin(g_origin_path);\n   RouterComponentTest::SetUp();\n   init_tmp_dir();\n\n   set_mysqlrouter_exec(Path(exec_file_));\n }\n\n void TearDown() override {\n   purge_dir(tmp_dir_);\n }\n\n /*\n  * Create temporary directory that represents system deployment\n  * layout for mysql bootstrap. A mysql executable is copied to\n  * tmp_dir_/stage/bin/ and then an execution permission is assign to it.\n  *\n  * After the test is completed, the whole temporary directory is deleted.\n  */\n void init_tmp_dir() {\n   tmp_dir_ = get_tmp_dir();\n   mysqlrouter::mkdir(tmp_dir_ + \"/stage\", 0700);\n   mysqlrouter::mkdir(tmp_dir_ + \"/stage/bin\", 0700);\n   exec_file_ = tmp_dir_ + \"/stage/bin/mysqlrouter\";\n   mysqlrouter::copy_file(get_mysqlrouter_exec().str(), exec_file_);\n#ifndef _WIN32\n   chmod(exec_file_.c_str(), 0700);\n#endif\n   config_file_ = tmp_dir_ + \"/stage/mysqlrouter.conf\";\n }\n\n RouterComponentTest::CommandHandle run_server_mock() {\n   const std::string json_stmts = get_data_dir().join(\"bootstrap.js\").str();\n   server_port_ = port_pool_.get_next_available();\n\n   // launch mock server and wait for it to start accepting connections\n   auto server_mock = launch_mysql_server_mock(json_stmts, server_port_);\n   EXPECT_TRUE(wait_for_port_ready(server_port_, 1000))\n     << \"Timed out waiting for mock server port ready\\n\"\n     << server_mock.get_full_output();\n   return server_mock;\n }\n\n TcpPortPool port_pool_;\n\n std::string tmp_dir_;\n std::string exec_file_;\n std::string config_file_;\n\n unsigned server_port_;\n};\n\n/*\n * This test is executed only for STANDALONE layout are is not executed for Windows.\n * Bootstrap for other layouts uses directories to which tests don't have access\n * (see install_layout.cmake).\n */\nTEST_F(RouterBootstrapSystemDeploymentTest, BootstrapPass) {\n  auto server_mock = run_server_mock();\n\n  // launch the router in bootstrap mode\n  auto router = launch_router(\"--bootstrap=127.0.0.1:\" + std::to_string(server_port_)\n                              + \" --report-host dont.query.dns\");\n\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \", \"fake-pass\\n\");\n\n  // check if the bootstraping was successful\n  EXPECT_EQ(router.wait_for_exit(), 0);\n  EXPECT_TRUE(router.expect_output(\"MySQL Router  has now been configured for the InnoDB cluster 'mycluster'\")\n    ) << router.get_full_output() << std::endl << \"server: \" << server_mock.get_full_output();\n}\n\n/*\n * This test is executed only for STANDALONE layout and is not executed for Windows.\n * Bootstrap for other layouts uses directories to which tests don't have access\n * (see install_layout.cmake).\n */\nTEST_F(RouterBootstrapSystemDeploymentTest, No_mysqlrouter_conf_tmp_WhenBootstrapFailed) {\n  /*\n   * Create directory with the same name as mysql router's config file to force\n   * bootstrap to fail.\n   */\n  mysqlrouter::mkdir(config_file_, 0700);\n  auto server_mock = run_server_mock();\n\n  // launch the router in bootstrap mode\n  auto router = launch_router(\"--bootstrap=127.0.0.1:\" + std::to_string(server_port_)\n                              + \" --report-host dont.query.dns\");\n\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \", \"fake-pass\\n\");\n\n  EXPECT_EQ(router.wait_for_exit(), 1);\n  EXPECT_TRUE(router.expect_output(\"Error: Could not save configuration file to final location\", false)\n      ) << router.get_full_output() << std::endl << \"server: \" << server_mock.get_full_output();\n\n  mysql_harness::Path mysqlrouter_conf_tmp_path(tmp_dir_ + \"/stage/mysqlrouter.conf.tmp\");\n  EXPECT_FALSE(mysqlrouter_conf_tmp_path.exists());\n}\n\n/*\n * This test is executed only for STANDALONE layout and is not executed for Windows.\n * Bootstrap for other layouts uses directories to which tests don't have access\n * (see install_layout.cmake).\n */\nTEST_F(RouterBootstrapSystemDeploymentTest, No_mysqlrouter_key_WhenBootstrapFailed) {\n  /*\n   * Create directory with the same name as mysql router's config file to force\n   * bootstrap to fail.\n   */\n  mysqlrouter::mkdir(config_file_, 0700);\n  auto server_mock = run_server_mock();\n\n  // launch the router in bootstrap mode\n  auto router = launch_router(\"--bootstrap=127.0.0.1:\" + std::to_string(server_port_)\n                              + \" --report-host dont.query.dns\");\n\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \", \"fake-pass\\n\");\n\n  EXPECT_EQ(router.wait_for_exit(), 1);\n  EXPECT_TRUE(router.expect_output(\"Error: Could not save configuration file to final location\", false)\n      ) << router.get_full_output() << std::endl << \"server: \" << server_mock.get_full_output();\n\n  mysql_harness::Path mysqlrouter_key_path(tmp_dir_ + \"/stage/mysqlrouter.key\");\n  EXPECT_FALSE(mysqlrouter_key_path.exists());\n}\n\n/*\n * This test is executed only for STANDALONE layout and is not executed for Windows.\n * Bootstrap for other layouts uses directories to which tests don't have access\n * (see install_layout.cmake).\n */\nTEST_F(RouterBootstrapSystemDeploymentTest, IsKeyringRevertedWhenBootstrapFail) {\n  static const char kMasterKeyFileSignature[] = \"MRKF\";\n\n  {\n    std::ofstream keyring_file(tmp_dir_ + \"/stage/mysqlrouter.key\",\n        std::ios_base::binary | std::ios_base::trunc | std::ios_base::out);\n\n    mysql_harness::make_file_private(tmp_dir_ + \"/stage/mysqlrouter.key\");\n    keyring_file.write(kMasterKeyFileSignature, strlen(kMasterKeyFileSignature));\n  }\n\n  /*\n   * Create directory with the same name as mysql router's config file to force\n   * bootstrap to fail.\n   */\n  mysqlrouter::mkdir(config_file_, 0700);\n  auto server_mock = run_server_mock();\n\n  // launch the router in bootstrap mode\n  auto router = launch_router(\"--bootstrap=127.0.0.1:\" + std::to_string(server_port_)\n                              + \" --report-host dont.query.dns\");\n\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \", \"fake-pass\\n\");\n\n  EXPECT_EQ(router.wait_for_exit(), 1);\n  EXPECT_TRUE(router.expect_output(\"Error: Could not save configuration file to final location\", false)\n      ) << router.get_full_output() << std::endl << \"server: \" << server_mock.get_full_output();\n\n  mysql_harness::Path mysqlrouter_key_path(tmp_dir_ + \"/stage/mysqlrouter.key\");\n  EXPECT_TRUE(mysqlrouter_key_path.exists());\n\n  std::ifstream keyring_file(tmp_dir_ + \"/stage/mysqlrouter.key\", std::ios_base::binary|std::ios_base::in);\n\n  char buf[10] = {0};\n  keyring_file.read(buf, sizeof(buf));\n  EXPECT_THAT(keyring_file.gcount(), 4);\n  EXPECT_THAT(std::strncmp(buf, kMasterKeyFileSignature, 4), testing::Eq(0));\n}\n\n/*\n * This test is executed only for STANDALONE layout and is not executed for Windows.\n * Bootstrap for other layouts uses directories to which tests don't have access\n * (see install_layout.cmake).\n */\nTEST_F(RouterBootstrapSystemDeploymentTest, Keep_mysqlrouter_log_WhenBootstrapFailed) {\n  /*\n   * Create directory with the same name as mysql router's config file to force\n   * bootstrap to fail.\n   */\n  mysqlrouter::mkdir(config_file_, 0700);\n  auto server_mock = run_server_mock();\n\n  // launch the router in bootstrap mode\n  auto router = launch_router(\"--bootstrap=127.0.0.1:\" + std::to_string(server_port_)\n                              + \" --report-host dont.query.dns\");\n\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \", \"fake-pass\\n\");\n\n  EXPECT_EQ(router.wait_for_exit(), 1);\n  EXPECT_TRUE(router.expect_output(\"Error: Could not save configuration file to final location\", false)\n      ) << router.get_full_output() << std::endl << \"server: \" << server_mock.get_full_output();\n\n  mysql_harness::Path mysqlrouter_log_path(tmp_dir_ + \"/stage/mysqlrouter.log\");\n  EXPECT_TRUE(mysqlrouter_log_path.exists());\n}\n\n#endif\n\nint main(int argc, char *argv[]) {\n  init_windows_sockets();\n  g_origin_path = Path(argv[0]).dirname();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "tests/component/test_component_test_framework.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"gmock/gmock.h\"\n#include \"router_component_test.h\"\n#include <chrono>\n#include <thread>\n\n/** @file\n *\n * These tests are special - they test our component test framework rather than\n * our Router. For the tests we do here we need tailored simple executables which\n * communicate with our tests, serving as the other side of the test. To avoid\n * the overhead of having to create many small programs, instead we inline their\n * code here, inside of special disabled testcases, and we launch those specific\n * testcases from their corresponding real testcase. This is why all the following\n * tests are arranged in pairs, with names:\n *\n *   - \"<test_description>_tester\" (the test)\n *   - \"DISABLED_<test_description>_testee\" (the inlined executable)\n *\n * It's a hack, but it works.\n *\n */\n\nPath g_origin_path;\nconst char* g_this_exec_path;\n\nconstexpr int kSleepDurationMs = 2000;  // you may want to decrease this to speed up tests\n\nclass ComponentTestFrameworkTest : public RouterComponentTest, public ::testing::Test {\n protected:\n  virtual void SetUp() {\n    set_origin(g_origin_path);\n    RouterComponentTest::SetUp();\n  }\n\n  static std::string show_output(CommandHandle& process, const std::string& process_description) {\n    return process_description + \":\\n\" + process.get_full_output() + \"-(end)-\\n\";\n  }\n\n  const std::string arglist_prefix_ =\n      \"--gtest_also_run_disabled_tests --gtest_filter=ComponentTestFrameworkTest.DISABLED_\";\n};\n\nstatic void autoresponder_testee(unsigned leak_interval_ms = 0) {\n\n  if (leak_interval_ms) {\n    auto slow_cout = [leak_interval_ms](char c) {\n      std::cout << c << std::flush;\n      std::this_thread::sleep_for(std::chrono::milliseconds(leak_interval_ms));\n    };\n\n    slow_cout('S');\n    slow_cout('y');\n    slow_cout('n');\n    std::cout << std::endl;\n  } else {\n    std::cout << \"Syn\" << std::endl;\n  }\n\n  // react to 1st autoresponse\n  {\n    std::string response;\n    std::cin >> response;\n    if (response == \"Syn+Ack\") {\n      // we're good\n      std::cout << \"Ack\" << std::endl;\n      std::cout << \"Fin\" << std::endl;\n    } else {\n      // unexpected response\n      std::cout << \"Reset\" << std::endl;\n    }\n  }\n\n  // react to 2nd autoresponse\n  {\n    std::string response;\n    std::cin >> response;\n    if (response == \"Ack\") {\n      // we're good\n      std::cout << \"OK\" << std::endl;\n    } else {\n      // unexpected response\n      std::cout << \"UNEXPECTED\" << std::endl;\n    }\n  }\n}\n\n\n\nTEST_F(ComponentTestFrameworkTest, autoresponder_simple_tester) {\n  /**\n   * @test This test tests framework's autoresponder in a simple scenario\n   *\n   * @note GTest will automatically add more of its own lines\n   *       before and after our stuff, giving this scenario a twist:\n   *       First read the autoresponder will see is very likely to contain\n   *       multiple lines. Thus this test turns into a test that also tests\n   *       autoresponder's ability to deal with multiple lines.\n   */\n\n  // In this test we explain what's going on, use this test as a guideline\n  // for understanding other tests.\n\n  // launch the DISABLED_autoresponder_simple_testee testcase as a separate executable\n  CommandHandle testee = launch_command(g_this_exec_path,\n                                        arglist_prefix_ + \"autoresponder_simple_testee\");\n  // register autoresponses\n  testee.register_response(\"Syn\", \"Syn+Ack\\n\");\n  testee.register_response(\"Fin\", \"Ack\\n\");\n\n  // test for what should come out\n  // NOTE: expect_output() will keep reading and autoresponding to output,\n  //       until it encounters the string we passed as an argument\n  EXPECT_TRUE(testee.expect_output(\"Syn\\nAck\\nFin\\nOK\")) << show_output(testee, \"ROUTER OUTPUT\");\n\n  // wait for child\n  EXPECT_EQ(testee.wait_for_exit(), 0);\n}\nTEST_F(ComponentTestFrameworkTest, DISABLED_autoresponder_simple_testee) {\n  autoresponder_testee();\n}\n\n\n\n// TODO: Re-enable this test after fixing autoresponder (reported as BUG#27035695)\n//\n// This test will fail if [THIS_LINE] is removed, because autoresponder is buggy.\n// [THIS_LINE] causes \"Syn\\n\" to be read in entirety by 1 read(), instead of\n// being read 1 byte at a time.  As soon as [THIS_LINE] is removed, autoresponder\n// will have to deal with each byte separately, and that's when it fails.\n#if 0\nTEST_F(ComponentTestFrameworkTest, autoresponder_segmented_triggers_tester) {\n  /**\n   * @test This test tests is just like autoresponder_simple_tester, but the testee\n   *       will send back \"Syn\\n\" (first autorespond trigger) one byte at a time.\n   *       It verifies that autoresponder can properly deal with segmented lines\n   *       (which may also be a result of short read() due to full buffer)\n   */\n\n  CommandHandle testee = launch_command(g_this_exec_path,\n                                        arglist_prefix_ + \"autoresponder_segmented_triggers_testee\");\n\n  testee.register_response(\"Syn\", \"Syn+Ack\\n\");\n  testee.register_response(\"Fin\", \"Ack\\n\");\n\n// TODO: this line needs to be removed, but removing this line causes the test to fail\nstd::this_thread::sleep_for(std::chrono::milliseconds(100));  // [THIS_LINE]\n\n  EXPECT_TRUE(testee.expect_output(\"Syn\\nAck\\nFin\\nOK\", false, 2 * kSleepDurationMs)) << show_output(testee, \"ROUTER OUTPUT\");\n\n  EXPECT_EQ(testee.wait_for_exit(), 0);\n\n}\nTEST_F(ComponentTestFrameworkTest, DISABLED_autoresponder_segmented_triggers_testee) {\n  autoresponder_testee(100);\n}\n#endif\n\n\n\nstatic void sleepy_testee() {\n  std::cout << \"Hello, I'm feeling sleepy. Yawn.\" << std::endl;\n  std::this_thread::sleep_for(std::chrono::milliseconds(kSleepDurationMs));\n  std::cout << \"Yes, I'm still alive.\" << std::endl;\n}\n\n\n\nTEST_F(ComponentTestFrameworkTest, sleepy_tester) {\n  /**\n   * @test This test verifies framework's behavior when the process is silent for a\n   *       longer period of time\n   */\n\n  CommandHandle testee = launch_command(g_this_exec_path,\n                                        arglist_prefix_ + \"sleepy_testee\");\n\n  // first and second sentence should arrive kSleepDurationMs ms apart,\n  // expect_output() should not give up reading during that time\n  EXPECT_TRUE(testee.expect_output(\"Hello, I'm feeling sleepy. Yawn.\\nYes, I'm still alive.\\n\",\n                                   false, 1.5 * kSleepDurationMs))\n      << show_output(testee, \"TESTED PROCESS\");\n\n  EXPECT_EQ(testee.wait_for_exit(), 0);\n}\nTEST_F(ComponentTestFrameworkTest, DISABLED_sleepy_testee) {\n  sleepy_testee();\n}\n\n\n\nTEST_F(ComponentTestFrameworkTest, sleepy_blind_tester) {\n  /**\n   * @test This test is similar to sleepy_tester(), but this time we just wait for the\n   *       child without looking at its output. wait_for_exit() should consume it.\n   */\n\n  CommandHandle testee = launch_command(g_this_exec_path,\n                                        arglist_prefix_ + \"sleepy_blind_testee\");\n\n  EXPECT_EQ(testee.wait_for_exit(1.5 * kSleepDurationMs), 0);\n}\nTEST_F(ComponentTestFrameworkTest, DISABLED_sleepy_blind_testee) {\n  sleepy_testee();\n}\n\n\n\nTEST_F(ComponentTestFrameworkTest, sleepy_blind_autoresponder_tester) {\n  /**\n   * @test This tests a particular scenario that used to trigger a bug: the child is\n   *       silent for a while before writing a prompt and blocking while awaiting\n   *       our response. The buggy wait_for_exit() used to attempt reading (with autoresponder\n   *       active) for a while, then (while the child was silent) it assumed no more\n   *       output would follow, and moved on to just waiting for the child to close\n   *       (no longer attempting to read and autorespond). When the child eventually\n   *       prompted for password, wait_for_exit() would not \"hear it\", resulting in a\n   *       deadlock and eventually timing out with error:\n   *       \"Timed out waiting for the process to exit: No child processes\"\n   */\n\n  CommandHandle testee = launch_command(g_this_exec_path,\n                                        arglist_prefix_ + \"sleepy_blind_autoresponder_testee\");\n\n  testee.register_response(\"Syn\", \"Syn+Ack\\n\");\n  testee.register_response(\"Fin\", \"Ack\\n\");\n\n  // wait for child (while reading and issuing autoresponses)\n  EXPECT_EQ(testee.wait_for_exit(1.5 * kSleepDurationMs), 0);\n}\nTEST_F(ComponentTestFrameworkTest, DISABLED_sleepy_blind_autoresponder_testee) {\n  std::this_thread::sleep_for(std::chrono::milliseconds(kSleepDurationMs));\n  autoresponder_testee();\n}\n\n\n\nint main(int argc, char *argv[]) {\n  g_this_exec_path = argv[0];\n\n  init_windows_sockets();\n  g_origin_path = Path(argv[0]).dirname();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n\n"
  },
  {
    "path": "tests/component/test_config.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"gmock/gmock.h\"\n#include \"router_component_test.h\"\n#include \"tcp_port_pool.h\"\n\nPath g_origin_path;\nusing testing::StartsWith;\n\nclass RouterConfigTest : public RouterComponentTest, public ::testing::Test {\n protected:\n  virtual void SetUp() {\n    set_origin(g_origin_path);\n    RouterComponentTest::SetUp();\n  }\n\n  TcpPortPool port_pool_;\n};\n\n// Bug #25800863 WRONG ERRORMSG IF DIRECTORY IS PROVIDED AS CONFIGFILE\nTEST_F(RouterConfigTest, RoutingDirAsMainConfigDirectory) {\n  const std::string config_dir = get_tmp_dir();\n\n  // launch the router giving directory instead of config_name\n  auto router = launch_router(\"-c \" +  config_dir);\n\n  EXPECT_EQ(router.wait_for_exit(), 1);\n\n  EXPECT_TRUE(router.expect_output(\n    \"Expected configuration file, got directory name: \" + config_dir)\n  ) << \"router output: \"<< router.get_full_output() << std::endl;\n}\n\n// Bug #25800863 WRONG ERRORMSG IF DIRECTORY IS PROVIDED AS CONFIGFILE\nTEST_F(RouterConfigTest, RoutingDirAsExtendedConfigDirectory) {\n  const auto router_port = port_pool_.get_next_available();\n  const auto server_port = port_pool_.get_next_available();\n\n  const std::string routing_section =\n                      \"[routing:basic]\\n\"\n                      \"bind_port = \" + std::to_string(router_port) + \"\\n\"\n                      \"mode = read-write\\n\"\n                      \"destinations = 127.0.0.1:\" + std::to_string(server_port) + \"\\n\";\n\n  std::string conf_file = create_config_file(routing_section);\n  const std::string config_dir = get_tmp_dir();\n\n  // launch the router giving directory instead of an extra config name\n  auto router = launch_router(\"-c \" +  conf_file + \" -a \" + config_dir);\n\n  EXPECT_EQ(router.wait_for_exit(), 1);\n\n  EXPECT_TRUE(router.expect_output(\n    \"Expected configuration file, got directory name: \" + config_dir)\n  ) << \"router output: \"<< router.get_full_output() << std::endl;\n}\n\nTEST_F(RouterConfigTest, IsExceptionThrownWhenAddTwiceTheSameSectionWithoutKey) {\n  const std::string conf_file = create_config_file(\"[section1]\\n[section1]\\n\");\n\n  // run the router and wait for it to exit\n  auto router = launch_router(\"-c \" +  conf_file);\n  EXPECT_EQ(router.wait_for_exit(), 1);\n\n  EXPECT_THAT(router.get_full_output(), StartsWith(\"Error: Configuration error: Section 'section1' already exists\"));\n}\n\nTEST_F(RouterConfigTest, IsExceptionThrownWhenAddTwiceTheSameSectionWithKey) {\n  const std::string conf_file = create_config_file(\"[section1:key1]\\n[section1:key1]\\n\");\n\n  // run the router and wait for it to exit\n  auto router = launch_router(\"-c \" +  conf_file);\n  EXPECT_EQ(router.wait_for_exit(), 1);\n\n  EXPECT_THAT(router.get_full_output(), StartsWith(\"Error: Configuration error: Section 'section1:key1' already exists\"));\n}\n\nint main(int argc, char *argv[]) {\n  init_windows_sockets();\n  g_origin_path = Path(argv[0]).dirname();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "tests/component/test_logging.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"dim.h\"\n#include \"gmock/gmock.h\"\n#include \"keyring/keyring_manager.h\"\n#include \"mysql_session.h\"\n#include \"random_generator.h\"\n#include \"router_component_test.h\"\n#include \"tcp_port_pool.h\"\n\n#include <condition_variable>\n#include <fstream>\n#include <functional>\n#include <mutex>\n#include <string>\n#include <thread>\n\n/**\n * @file\n * @brief Component Tests for loggers\n */\n\nusing testing::HasSubstr;\nusing testing::StartsWith;\nPath g_origin_path;\n\nclass RouterLoggingTest : public RouterComponentTest, public ::testing::Test {\n protected:\n  virtual void SetUp() {\n    set_origin(g_origin_path);\n    RouterComponentTest::SetUp();\n  }\n\n  TcpPortPool port_pool_;\n};\n\nTEST_F(RouterLoggingTest, log_startup_failure_to_console) {\n  // This test verifies that fatal error message thrown in MySQLRouter::start()\n  // during startup (before Loader::start() takes over) are properly logged to STDERR\n\n  auto conf_params = get_DEFAULT_defaults();\n  // we want to log to the console\n  conf_params[\"logging_folder\"] = \"\";\n  const std::string conf_file = create_config_file(\"\", &conf_params);\n\n  // run the router and wait for it to exit\n  auto router = launch_router(\"-c \" +  conf_file);\n  EXPECT_EQ(router.wait_for_exit(), 1);\n\n  // expect something like this to appear on STDERR\n  // 2017-06-18 15:24:32 main ERROR [7ffff7fd4780] Error: MySQL Router not configured to load or start any plugin. Exiting.\n  const std::string out = router.get_full_output();\n  EXPECT_THAT(out.c_str(), HasSubstr(\" main ERROR \"));\n  EXPECT_THAT(out.c_str(), HasSubstr(\" Error: MySQL Router not configured to load or start any plugin. Exiting.\"));\n}\n\nTEST_F(RouterLoggingTest, log_startup_failure_to_logfile) {\n  // This test is the same as log_startup_failure_to_logfile(), but the failure\n  // message is expected to be logged into a logfile\n\n  // create tmp dir where we will log\n  const std::string logging_folder = get_tmp_dir();\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(logging_folder);});\n\n  // create config with logging_folder set to that directory\n  std::map<std::string, std::string> params = get_DEFAULT_defaults();\n  params.at(\"logging_folder\") = logging_folder;\n  const std::string conf_file = create_config_file(\"\", &params);\n\n  // run the router and wait for it to exit\n  auto router = launch_router(\"-c \" +  conf_file);\n  EXPECT_EQ(router.wait_for_exit(), 1);\n\n  // expect something like this to appear in log:\n  // 2017-06-18 15:24:32 main ERROR [7ffff7fd4780] Error: MySQL Router not configured to load or start any plugin. Exiting.\n  auto matcher = [](const std::string& line) -> bool {\n    return line.find(\" main ERROR \") != line.npos &&\n           line.find(\" Error: MySQL Router not configured to load or start any plugin. Exiting.\") != line.npos;\n  };\n  EXPECT_TRUE(find_in_file(logging_folder+\"/mysqlrouter.log\", matcher));\n}\n\nTEST_F(RouterLoggingTest, bad_logging_folder) {\n  // This test verifies that invalid logging_folder is properly handled and\n  // appropriate message is printed on STDERR. Router tries to mkdir(logging_folder)\n  // if it doesn't exist, then write its log inside of it.\n\n  // create tmp dir to contain our tests\n  const std::string tmp_dir = get_tmp_dir();\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(tmp_dir);});\n\n// unfortunately it's not (reasonably) possible to make folders read-only on Windows,\n// therefore we can run the following 2 tests only on Unix\n// https://support.microsoft.com/en-us/help/326549/you-cannot-view-or-change-the-read-only-or-the-system-attributes-of-fo\n#ifndef _WIN32\n\n  // make tmp dir read-only\n  chmod(tmp_dir.c_str(), S_IRUSR | S_IXUSR); // r-x for the user (aka 500)\n\n  // logging_folder doesn't exist and can't be created\n  {\n    const std::string logging_dir = tmp_dir + \"/some_dir\";\n\n    // create Router config\n    std::map<std::string, std::string> params = get_DEFAULT_defaults();\n    params.at(\"logging_folder\") = logging_dir;\n    const std::string conf_file = create_config_file(\"\", &params);\n\n    // run the router and wait for it to exit\n    auto router = launch_router(\"-c \" +  conf_file);\n    EXPECT_EQ(router.wait_for_exit(), 1);\n\n    // expect something like this to appear on STDERR\n    // Error: Error when creating dir '/bla': 13\n    const std::string out = router.get_full_output();\n    EXPECT_THAT(out.c_str(), StartsWith(\"Error: Error when creating dir '\" + logging_dir + \"': 13\"));\n  }\n\n  // logging_folder exists but is not writeable\n  {\n    const std::string logging_dir = tmp_dir;\n\n    // create Router config\n    std::map<std::string, std::string> params = get_DEFAULT_defaults();\n    params.at(\"logging_folder\") = logging_dir;\n    const std::string conf_file = create_config_file(\"\", &params);\n\n    // run the router and wait for it to exit\n    auto router = launch_router(\"-c \" +  conf_file);\n    EXPECT_EQ(router.wait_for_exit(), 1);\n\n    // expect something like this to appear on STDERR\n    // Error: Cannot create file in directory //mysqlrouter.log: Permission denied\n    const std::string out = router.get_full_output();\n#ifndef _WIN32\n    EXPECT_THAT(out.c_str(), StartsWith(\"Error: Cannot create file in directory \" + logging_dir + \": Permission denied\\n\"));\n#endif\n  }\n\n  // restore writability to tmp dir\n  chmod(tmp_dir.c_str(), S_IRUSR | S_IWUSR | S_IXUSR); // rwx for the user (aka 700)\n\n#endif // #ifndef _WIN32\n\n  // logging_folder is really a file\n  {\n    const std::string logging_dir = tmp_dir + \"/some_file\";\n\n    // create that file\n    {\n      std::ofstream some_file(logging_dir);\n      EXPECT_TRUE(some_file.good());\n    }\n\n    // create Router config\n    std::map<std::string, std::string> params = get_DEFAULT_defaults();\n    params.at(\"logging_folder\") = logging_dir;\n    const std::string conf_file = create_config_file(\"\", &params);\n\n    // run the router and wait for it to exit\n    auto router = launch_router(\"-c \" +  conf_file);\n    EXPECT_EQ(router.wait_for_exit(), 1);\n\n    // expect something like this to appear on STDERR\n    // Error: Cannot create file in directory /etc/passwd/mysqlrouter.log: Not a directory\n    const std::string out = router.get_full_output();\n#ifndef _WIN32\n    EXPECT_THAT(out.c_str(), StartsWith(\"Error: Cannot create file in directory \" + logging_dir + \": Not a directory\\n\"));\n#else\n    // on Windows emulate (wine) we get ENOTDIR\n    // with native windows we get ENOENT\n    EXPECT_THAT(out.c_str(), ::testing::AllOf(\n          StartsWith(\"Error: Cannot create file in directory \" + logging_dir), ::testing::AnyOf(\n            ::testing::EndsWith(\"Directory name invalid.\\n\\n\"), ::testing::EndsWith(\"The system cannot find the path specified.\\n\\n\"))));\n#endif\n  }\n}\n\nTEST_F(RouterLoggingTest, logger_section_with_key) {\n  // This test verifies that [logger:with_some_key] section is handled properly\n  // Router should report the error on STDERR and exit\n\n  auto conf_params = get_DEFAULT_defaults();\n  // we want to log to the console\n  conf_params[\"logging_folder\"] = \"\";\n  const std::string conf_file = create_config_file(\"[logger:some_key]\\n\", &conf_params);\n\n  // run the router and wait for it to exit\n  auto router = launch_router(\"-c \" +  conf_file);\n  EXPECT_EQ(router.wait_for_exit(), 1);\n\n  // expect something like this to appear on STDERR\n  // Error: Section 'logger' does not support keys\n  const std::string out = router.get_full_output();\n  EXPECT_THAT(out.c_str(), StartsWith(\"Error: Section 'logger' does not support keys\"));\n}\n\nTEST_F(RouterLoggingTest, multiple_logger_sections) {\n  // This test verifies that multiple [logger] sections are handled properly.\n  // Router should report the error on STDERR and exit\n\n  auto conf_params = get_DEFAULT_defaults();\n  // we want to log to the console\n  conf_params[\"logging_folder\"] = \"\";\n  const std::string conf_file = create_config_file(\"[logger]\\n[logger]\\n\", &conf_params);\n\n  // run the router and wait for it to exit\n  auto router = launch_router(\"-c \" +  conf_file);\n  EXPECT_EQ(router.wait_for_exit(), 1);\n\n  // expect something like this to appear on STDERR\n  // Error: Configuration error: Section 'logger' already exists\n  const std::string out = router.get_full_output();\n  EXPECT_THAT(out.c_str(), StartsWith(\"Error: Configuration error: Section 'logger' already exists\"));\n}\n\nTEST_F(RouterLoggingTest, bad_loglevel) {\n  // This test verifies that bad log level in [logger] section is handled properly.\n  // Router should report the error on STDERR and exit\n\n  auto conf_params = get_DEFAULT_defaults();\n  // we want to log to the console\n  conf_params[\"logging_folder\"] = \"\";\n  const std::string conf_file = create_config_file(\"[logger]\\nlevel = UNKNOWN\\n\", &conf_params);\n\n  // run the router and wait for it to exit\n  auto router = launch_router(\"-c \" +  conf_file);\n  EXPECT_EQ(router.wait_for_exit(), 1);\n\n  // expect something like this to appear on STDERR\n  // 2017-08-14 16:03:44 main ERROR [7f7a61be6780] Configuration error: Log level 'unknown' is not valid. Valid values are: debug, error, fatal, info, and warning\n  const std::string out = router.get_full_output();\n  EXPECT_THAT(out.c_str(), HasSubstr(\" main ERROR \"));\n  EXPECT_THAT(out.c_str(), HasSubstr(\" Configuration error: Log level 'unknown' is not valid. Valid values are: debug, error, fatal, info, and warning\"));\n}\n\nTEST_F(RouterLoggingTest, bad_loglevel_gets_logged) {\n  // This test is the same as bad_loglevel(), but the failure\n  // message is expected to be logged into a logfile\n\n  // create tmp dir where we will log\n  const std::string logging_folder = get_tmp_dir();\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(logging_folder);});\n\n  // create config with logging_folder set to that directory\n  std::map<std::string, std::string> params = get_DEFAULT_defaults();\n  params.at(\"logging_folder\") = logging_folder;\n  const std::string conf_file = create_config_file(\"[logger]\\nlevel = UNKNOWN\\n\", &params);\n\n  // run the router and wait for it to exit\n  auto router = launch_router(\"-c \" +  conf_file);\n  EXPECT_EQ(router.wait_for_exit(), 1);\n\n  // expect something like this to appear on STDERR\n  // 2017-08-14 16:03:44 main ERROR [7f7a61be6780] Configuration error: Log level 'unknown' is not valid. Valid values are: debug, error, fatal, info, and warning\n  auto matcher = [](const std::string& line) -> bool {\n    return line.find(\" main ERROR \") != line.npos &&\n           line.find(\" Configuration error: Log level 'unknown' is not valid. Valid values are: debug, error, fatal, info, and warning\") != line.npos;\n  };\n  EXPECT_TRUE(find_in_file(logging_folder+\"/mysqlrouter.log\", matcher));\n}\n\nTEST_F(RouterLoggingTest, very_long_router_name_gets_properly_logged) {\n  // This test verifies that a very long router name gets truncated in the\n  // logged message (this is done because if it doesn't happen, the entire\n  // message will exceed log message max length, and then the ENTIRE message\n  // will get truncated instead. It's better to truncate the long name rather\n  // than the stuff that follows it).\n  // Router should report the error on STDERR and exit\n\n  const std::string json_stmts = get_data_dir().join(\"bootstrap.js\").str();\n  const std::string bootstrap_dir = get_tmp_dir();\n\n  const unsigned server_port = port_pool_.get_next_available();\n\n  // launch mock server and wait for it to start accepting connections\n  RouterComponentTest::CommandHandle server_mock = launch_mysql_server_mock(json_stmts, server_port);\n  EXPECT_TRUE(wait_for_port_ready(server_port, 5000)) << server_mock.get_full_output();\n\n  constexpr char name[] = \"veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryverylongname\";\n  static_assert(sizeof(name) > 255, \"too long\");  // log message max length is 256, we want something that guarrantees the limit would be exceeded\n\n  // launch the router in bootstrap mode\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(bootstrap_dir);});\n  auto router = launch_router(\"--bootstrap=127.0.0.1:\" + std::to_string(server_port)\n                              + \" --name \" + name + \" -d \" + bootstrap_dir);\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \", \"fake-pass\\n\");\n\n  // wait for router to exit\n  EXPECT_EQ(router.wait_for_exit(), 1);\n\n  // expect something like this to appear on STDERR\n  // Error: Router name 'veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryv...' too long (max 255).\n  const std::string out = router.get_full_output();\n  EXPECT_THAT(out.c_str(), HasSubstr(\"Error: Router name 'veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryv...' too long (max 255).\"));\n}\n\n/**\n * @test verify that debug logs are not written to console during boostrap if bootstrap\n *       configuration file is not provided.\n */\nTEST_F(RouterLoggingTest, is_debug_logs_disabled_if_no_bootstrap_config_file) {\n  const std::string json_stmts = get_data_dir().join(\"bootstrap.js\").str();\n\n  const std::string bootstrap_dir = get_tmp_dir();\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(bootstrap_dir);});\n\n  const unsigned server_port = port_pool_.get_next_available();\n\n  // launch mock server and wait for it to start accepting connections\n  auto server_mock = launch_mysql_server_mock(json_stmts, server_port, false);\n  EXPECT_TRUE(wait_for_port_ready(server_port, 1000)) << \"Timed out waiting for mock server port ready\" << std::endl\n                     << server_mock.get_full_output();\n\n  // launch the router in bootstrap mode\n  auto router = launch_router(\"--bootstrap=127.0.0.1:\" + std::to_string(server_port)\n                              + \" --report-host dont.query.dns\"\n                              + \" -d \" + bootstrap_dir);\n\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \", \"fake-pass\\n\");\n\n  // check if the bootstraping was successful\n  EXPECT_EQ(router.wait_for_exit(), 0);\n  EXPECT_THAT(router.get_full_output(), testing::Not(testing::HasSubstr(\"Executing query:\")));\n}\n\n/**\n * @test verify that debug logs are written to console during boostrap if log_level is set\n *       to DEBUG in bootstrap configuration file.\n */\nTEST_F(RouterLoggingTest, is_debug_logs_enabled_if_bootstrap_config_file) {\n  const std::string json_stmts = get_data_dir().join(\"bootstrap.js\").str();\n\n  const std::string bootstrap_dir = get_tmp_dir();\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(bootstrap_dir);});\n\n  const std::string bootstrap_conf = get_tmp_dir();\n  std::shared_ptr<void> conf_exit_guard(nullptr, [&](void*){purge_dir(bootstrap_conf);});\n\n  const unsigned server_port = port_pool_.get_next_available();\n\n  // launch mock server and wait for it to start accepting connections\n  auto server_mock = launch_mysql_server_mock(json_stmts, server_port, false);\n  EXPECT_TRUE(wait_for_port_ready(server_port, 1000)) << \"Timed out waiting for mock server port ready\" << std::endl\n                     << server_mock.get_full_output();\n\n  // launch the router in bootstrap mode\n  std::string logger_section = \"[logger]\\nlevel = DEBUG\\n\";\n  auto conf_params = get_DEFAULT_defaults();\n  // we want to log to the console\n  conf_params[\"logging_folder\"] = \"\";\n  std::string conf_file = create_config_file(logger_section, &conf_params,\n      bootstrap_conf, \"bootstrap.conf\");\n\n  auto router = launch_router(\"--bootstrap=127.0.0.1:\" + std::to_string(server_port)\n                              + \" --report-host dont.query.dns\"\n                              + \" --force -d \" + bootstrap_dir + \" -c \" + conf_file);\n\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \", \"fake-pass\\n\");\n\n  // check if the bootstraping was successful\n  EXPECT_EQ(router.wait_for_exit(), 0)  << router.get_full_output() << std::endl << \"server: \" << server_mock.get_full_output();\n  EXPECT_THAT(router.get_full_output(), testing::HasSubstr(\"Executing query:\"));\n}\n\n/**\n * @test verify that debug logs are written to mysqlrouter.log file during bootstrap\n *       if loggin_folder is provided in bootstrap configuration file\n */\nTEST_F(RouterLoggingTest, is_debug_logs_written_to_file_if_logging_folder) {\n  const std::string json_stmts = get_data_dir().join(\"bootstrap.js\").str();\n\n  const std::string bootstrap_dir = get_tmp_dir();\n  const std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(bootstrap_dir);});\n\n  std::string bootstrap_conf = get_tmp_dir();\n  std::shared_ptr<void> conf_exit_guard(nullptr, [&](void*){purge_dir(bootstrap_conf);});\n\n  const unsigned server_port = port_pool_.get_next_available();\n\n  // launch mock server and wait for it to start accepting connections\n  auto server_mock = launch_mysql_server_mock(json_stmts, server_port, false);\n  EXPECT_TRUE(wait_for_port_ready(server_port, 1000)) << \"Timed out waiting for mock server port ready\" << std::endl\n                     << server_mock.get_full_output();\n\n  // create config with logging_folder set to that directory\n  std::map<std::string, std::string> params = { {\"logging_folder\", \"\"} };\n  params.at(\"logging_folder\") = bootstrap_conf;\n  const std::string conf_file = create_config_file(\"[logger]\\nlevel = DEBUG\\n\", &params);\n\n  auto router = launch_router(\"--bootstrap=127.0.0.1:\" + std::to_string(server_port)\n                              + \" --report-host dont.query.dns\"\n                              + \" --force -d \" + bootstrap_dir + \" -c \" + conf_file);\n\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \", \"fake-pass\\n\");\n\n  // check if the bootstraping was successful\n  EXPECT_EQ(router.wait_for_exit(), 0)  << router.get_full_output() << std::endl << \"server: \" << server_mock.get_full_output();\n\n  auto matcher = [](const std::string& line) -> bool {\n    return line.find(\"Executing query:\") != line.npos;\n  };\n\n  EXPECT_TRUE(find_in_file(bootstrap_conf+\"/mysqlrouter.log\", matcher, std::chrono::milliseconds(5000)));\n}\n\n/**\n * @test verify that normal output is written to stdout during bootstrap if logging_folder\n *       is not provided in bootstrap configuration file.\n *\n * @test verify that logs are not written to stdout during bootstrap.\n */\nTEST_F(RouterLoggingTest, bootstrap_normal_logs_written_to_stdout) {\n  const std::string json_stmts = get_data_dir().join(\"bootstrap.js\").str();\n\n  const std::string bootstrap_dir = get_tmp_dir();\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(bootstrap_dir);});\n\n  const std::string bootstrap_conf = get_tmp_dir();\n  std::shared_ptr<void> conf_exit_guard(nullptr, [&](void*){purge_dir(bootstrap_conf);});\n\n  const unsigned server_port = port_pool_.get_next_available();\n\n  // launch mock server and wait for it to start accepting connections\n  auto server_mock = launch_mysql_server_mock(json_stmts, server_port, false);\n  EXPECT_TRUE(wait_for_port_ready(server_port, 1000)) << \"Timed out waiting for mock server port ready\" << std::endl\n                     << server_mock.get_full_output();\n\n  // launch the router in bootstrap mode\n  std::string logger_section = \"[logger]\\nlevel = DEBUG\\n\";\n  auto conf_params = get_DEFAULT_defaults();\n  // we want to log to the console\n  conf_params[\"logging_folder\"] = \"\";\n  std::string conf_file = create_config_file(logger_section, &conf_params,\n      bootstrap_conf, \"bootstrap.conf\");\n\n  auto router = launch_router(\"--bootstrap=127.0.0.1:\" + std::to_string(server_port)\n                              + \" --report-host dont.query.dns\"\n                              + \" --force -d \" + bootstrap_dir + \" -c \" + conf_file, false /*false = capture only stdout*/);\n\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \", \"fake-pass\\n\");\n\n  // check if the bootstraping was successful\n  EXPECT_EQ(router.wait_for_exit(), 0)  << router.get_full_output() << std::endl << \"server: \" << server_mock.get_full_output();\n\n  // check if logs are not written to output\n  EXPECT_THAT(router.get_full_output(), testing::Not(testing::HasSubstr(\"Executing query:\")));\n\n  // check if normal output is written to output\n  EXPECT_THAT(router.get_full_output(),\n      testing::HasSubstr(\n          \"The following connection information can be used to connect to the cluster.\"));\n\n  EXPECT_THAT(router.get_full_output(),\n      testing::HasSubstr(\n          \"Classic MySQL protocol connections to cluster 'mycluster':\"));\n\n  EXPECT_THAT(router.get_full_output(),\n      testing::HasSubstr(\n          \"X protocol connections to cluster 'mycluster':\"));\n}\n\nclass MetadataCacheLoggingTest : public RouterLoggingTest {\n protected:\n\n  void SetUp() override {\n    set_origin(g_origin_path);\n    RouterComponentTest::SetUp();\n\n    mysql_harness::DIM& dim = mysql_harness::DIM::instance();\n    // RandomGenerator\n    dim.set_RandomGenerator(\n      [](){ static mysql_harness::RandomGenerator rg; return &rg; },\n      [](mysql_harness::RandomGeneratorInterface*){}\n    );\n\n    temp_test_dir = get_tmp_dir();\n    logging_folder = get_tmp_dir();\n\n    cluster_nodes_ports = {\n      port_pool_.get_next_available(),\n      port_pool_.get_next_available(),\n      port_pool_.get_next_available()\n    };\n    router_port = port_pool_.get_next_available();\n    metadata_cache_section = get_metadata_cache_section(cluster_nodes_ports);\n    routing_section = get_metadata_cache_routing_section(\"PRIMARY\", \"round-robin\", \"\");\n\n    write_json_file(get_data_dir());\n    init_keyring();\n  }\n\n  void TearDown() override {\n    purge_dir(temp_test_dir);\n    purge_dir(logging_folder);\n  }\n\n  void write_json_file(const Path& data_dir) {\n    std::map<std::string, std::string> json_vars = {\n      { \"PRIMARY_HOST\",     \"127.0.0.1:\" + std::to_string(cluster_nodes_ports[0]) },\n      { \"SECONDARY_1_HOST\", \"127.0.0.1:\" + std::to_string(cluster_nodes_ports[1]) },\n      { \"SECONDARY_2_HOST\", \"127.0.0.1:\" + std::to_string(cluster_nodes_ports[2]) },\n\n      { \"PRIMARY_PORT\",     std::to_string(cluster_nodes_ports[0]) },\n      { \"SECONDARY_1_PORT\", std::to_string(cluster_nodes_ports[1]) },\n      { \"SECONDARY_2_PORT\", std::to_string(cluster_nodes_ports[2]) },\n    };\n\n    // launch the primary node working also as metadata server\n    json_primary_node_template_ = data_dir.join(\"metadata_3_nodes_first_not_accessible.js\").str();\n    json_primary_node_ = Path(temp_test_dir).join(\"metadata_3_nodes_first_not_accessible.json\").str();\n    rewrite_js_to_tracefile(json_primary_node_template_, json_primary_node_, json_vars);\n  }\n\n  std::string get_metadata_cache_section(std::vector<unsigned> ports) {\n    std::string metadata_caches = \"bootstrap_server_addresses=\";\n\n    for(auto it = ports.begin(); it != ports.end(); ++it) {\n      metadata_caches += (it == ports.begin()) ? \"\" : \",\";\n      metadata_caches += \"mysql://localhost:\" + std::to_string(*it);\n    }\n    metadata_caches += \"\\n\";\n\n    return \"[metadata_cache:test]\\n\"\n           \"router_id=1\\n\"\n           + metadata_caches +\n           \"user=mysql_router1_user\\n\"\n           \"metadata_cluster=test\\n\"\n           \"ttl=500\\n\\n\";\n  }\n\n  std::string get_metadata_cache_routing_section(const std::string& role,\n                                                 const  std::string& strategy,\n                                                 const  std::string& mode = \"\") {\n    std::string result = \"[routing:test_default]\\n\"\n      \"bind_port=\" + std::to_string(router_port) + \"\\n\" +\n      \"destinations=metadata-cache://test/default?role=\" + role + \"\\n\" +\n      \"protocol=classic\\n\";\n\n    if (!strategy.empty()) result += std::string(\"routing_strategy=\" + strategy + \"\\n\");\n    if (!mode.empty()) result += std::string(\"mode=\" + mode + \"\\n\");\n\n    return result;\n  }\n\n  void init_keyring() {\n    const std::string masterkey_file = Path(temp_test_dir).join(\"master.key\").str();\n    const std::string keyring_file = Path(temp_test_dir).join(\"keyring\").str();\n    mysql_harness::init_keyring(keyring_file, masterkey_file, true);\n    mysql_harness::Keyring *keyring = mysql_harness::get_keyring();\n    keyring->store(\"mysql_router1_user\", \"password\", \"root\");\n    mysql_harness::flush_keyring();\n    mysql_harness::reset_keyring();\n  }\n\n  std::string build_config_file() {\n    auto default_section = get_DEFAULT_defaults();\n    default_section[\"logging_folder\"] = logging_folder;\n    default_section[\"keyring_path\"] = Path(temp_test_dir).join(\"keyring\").str();;\n    default_section[\"master_key_path\"] = Path(temp_test_dir).join(\"master.key\").str();;\n    return create_config_file(\"[logger]\\nlevel = DEBUG\\n\"\n        + metadata_cache_section + routing_section, &default_section);\n  }\n\n  TcpPortPool port_pool_;\n  std::string json_primary_node_template_;\n  std::string json_primary_node_;\n  std::string temp_test_dir;\n  std::string logging_folder;\n  std::vector<unsigned> cluster_nodes_ports;\n  unsigned router_port;\n  std::string metadata_cache_section;\n  std::string routing_section;\n};\n\n/*\n * @test verify if error message is logged if router cannot connect to any\n *       metadata server.\n */\nTEST_F(MetadataCacheLoggingTest, log_error_when_cannot_connect_to_any_metadata_server) {\n  // launch the router with metadata-cache configuration\n  auto router = RouterComponentTest::launch_router(\"-c \" +  build_config_file());\n  bool router_ready = wait_for_port_ready(router_port, 1000);\n  EXPECT_TRUE(router_ready) << router.get_full_output();\n\n  // expect something like this to appear on STDERR\n  // 2017-12-21 17:22:35 metadata_cache ERROR [7ff0bb001700] Failed connecting with any of the bootstrap servers\n  auto matcher = [](const std::string& line) -> bool {\n    return line.find(\"metadata_cache ERROR\") != line.npos &&\n        line.find(\"Failed connecting with any of the metadata servers\") != line.npos;\n  };\n\n  EXPECT_TRUE(find_in_file(logging_folder+\"/mysqlrouter.log\", matcher, std::chrono::milliseconds(5000)));\n}\n\n/*\n * @test verify if appropriate warning messages are logged when cannot connect to first\n *       metadata server, but can connect to another one.\n */\nTEST_F(MetadataCacheLoggingTest, log_warning_when_cannot_connect_to_first_metadata_server) {\n  // launch second metadata server\n  auto server = launch_mysql_server_mock(json_primary_node_, cluster_nodes_ports[1], false);\n  bool server_ready = wait_for_port_ready(cluster_nodes_ports[1], 1000);\n  EXPECT_TRUE(server_ready) << server.get_full_output();\n\n  // launch the router with metadata-cache configuration\n  auto router = RouterComponentTest::launch_router(\"-c \" +  build_config_file());\n  bool router_ready = wait_for_port_ready(router_port, 1000);\n  EXPECT_TRUE(router_ready) << router.get_full_output();\n\n\n  // expect something like this to appear on STDERR\n  // 2017-12-21 17:22:35 metadata_cache WARNING [7ff0bb001700] Failed connecting with Metadata Server 127.0.0.1:7002: Can't connect to MySQL server on '127.0.0.1' (111) (2003)\n  auto info_matcher = [&](const std::string& line) -> bool {\n    return line.find(\"metadata_cache WARNING\") != line.npos &&\n        line.find(\"Failed connecting with Metadata Server 127.0.0.1:\" + std::to_string(cluster_nodes_ports[0])) != line.npos;\n  };\n\n  EXPECT_TRUE(find_in_file(logging_folder+\"/mysqlrouter.log\", info_matcher, std::chrono::milliseconds(10000)));\n\n  auto warning_matcher = [](const std::string& line) -> bool {\n    return line.find(\"metadata_cache WARNING\") != line.npos &&\n        line.find(\"While updating metadata, could not establish a connection to replicaset\") != line.npos;\n  };\n  EXPECT_TRUE(find_in_file(logging_folder+\"/mysqlrouter.log\", warning_matcher, std::chrono::milliseconds(10000)));\n}\n\nint main(int argc, char *argv[]) {\n  init_windows_sockets();\n  g_origin_path = Path(argv[0]).dirname();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "tests/component/test_master_key_reader_writer.cc",
    "content": "/*\n Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n This program is free software; you can redistribute it and/or modify\n it under the terms of the GNU General Public License, version 2.0,\n as published by the Free Software Foundation.\n\n This program is also distributed with certain software (including\n but not limited to OpenSSL) that is licensed under separate terms,\n as designated in a particular file or component or in included license\n documentation.  The authors of MySQL hereby grant you an additional\n permission to link the program and your derivative works with the\n separately licensed software that they have included with MySQL.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program; if not, write to the Free Software\n Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n */\n\n#include <fstream>\n#include <system_error>\n\n#ifdef _WIN32\n#include <windows.h>\n#endif\n\n#include \"dim.h\"\n#include \"gmock/gmock.h\"\n#include \"keyring/keyring_manager.h\"\n#include \"mysqlrouter/keyring_info.h\"\n#include \"random_generator.h\"\n#include \"router_component_test.h\"\n#include \"script_generator.h\"\n#include \"tcp_port_pool.h\"\n#include \"utils.h\"\n\nPath g_origin_path;\n\n/**\n * @file\n * @brief Component Tests for the master-key-reader and master-key-writer\n */\n\n\nMATCHER_P(FileContentEqual, master_key, \"\") {\n\n  std::ifstream file(arg);\n  std::stringstream file_content;\n  file_content << file.rdbuf();\n  return file_content.str() == master_key;\n}\n\nMATCHER_P(FileContentNotEqual, master_key, \"\") {\n\n  std::ifstream file(arg);\n  std::stringstream file_content;\n  file_content << file.rdbuf();\n  return file_content.str() != master_key;\n}\n\nclass MasterKeyReaderWriterTest: public RouterComponentTest,\n    public ::testing::Test {\nprotected:\n  void SetUp() override {\n    set_origin(g_origin_path);\n    RouterComponentTest::SetUp();\n    tmp_dir_ = get_tmp_dir();\n    bootstrap_dir_ = get_tmp_dir();\n    logging_folder = Path(tmp_dir_).join(\"log\").str();\n\n    mysql_harness::DIM& dim = mysql_harness::DIM::instance();\n    // RandomGenerator\n    dim.set_RandomGenerator(\n        []() {static mysql_harness::RandomGenerator rg; return &rg;},\n        [](mysql_harness::RandomGeneratorInterface*) {});\n  }\n\n  void TearDown() override {\n    purge_dir(tmp_dir_);\n    purge_dir(bootstrap_dir_);\n  }\n\n  void write_to_file(const Path& file_path, const std::string& text) {\n    std::ofstream master_key_file(file_path.str());\n    if (master_key_file.good()) {\n      master_key_file << text;\n    }\n  }\n\n  std::string get_json_file(const Path& data_dir, unsigned server_port) {\n    std::map < std::string, std::string> json_vars = {\n      { \"PRIMARY_HOST\", \"127.0.0.1:\" + std::to_string(server_port)},\n      { \"PRIMARY_PORT\", std::to_string(server_port)},\n    };\n\n    // launch the primary node working also as metadata server\n    std::string json_primary_node_template = data_dir.join(\"metadata_1_node.js\").str();\n    std::string json_primary_node = Path(tmp_dir_).join(\"metadata_1_node.json\").str();\n    rewrite_js_to_tracefile(json_primary_node_template, json_primary_node, json_vars);\n    return json_primary_node;\n  }\n\n  std::string get_metadata_cache_section(unsigned server_port) {\n    return \"[metadata_cache:test]\\n\"\n    \"router_id=1\\n\"\n    \"bootstrap_server_addresses=mysql://localhost:\" + std::to_string(server_port) + \"\\n\"\n    \"user=mysql_router1_user\\n\"\n    \"metadata_cluster=test\\n\"\n    \"ttl=500\\n\\n\";\n  }\n\n  std::string get_metadata_cache_routing_section(const std::string& role,\n      const std::string& strategy,\n      unsigned router_port) {\n    return \"[routing:test_default]\\n\"\n    \"bind_port=\" + std::to_string(router_port) + \"\\n\" +\n    \"destinations=metadata-cache://test/default?role=\" + role + \"\\n\" +\n    \"protocol=classic\\n\" +\n    \"routing_strategy=\" + strategy + \"\\n\";\n  }\n\n  KeyringInfo init_keyring() {\n    ScriptGenerator script_generator(g_origin_path, tmp_dir_);\n\n    KeyringInfo keyring_info;\n    keyring_info.set_master_key_reader(script_generator.get_reader_script());\n    keyring_info.set_master_key_writer(script_generator.get_writer_script());\n    keyring_info.set_keyring_file(Path(tmp_dir_).join(\"keyring\").str());\n\n    keyring_info.generate_master_key();\n    master_key_ = keyring_info.get_master_key();\n    keyring_info.add_router_id_to_env(1);\n    keyring_info.write_master_key();\n    mysql_harness::init_keyring_with_key(keyring_info.get_keyring_file(), keyring_info.get_master_key(), true);\n\n    mysql_harness::Keyring *keyring = mysql_harness::get_keyring();\n    keyring->store(\"mysql_router1_user\", \"password\", \"root\");\n    mysql_harness::flush_keyring();\n    mysql_harness::reset_keyring();\n\n    return keyring_info;\n  }\n\n  std::map<std::string, std::string> get_default_section_map(bool assign_fake_reader = false,\n      bool assign_fake_writer = false) {\n    ScriptGenerator script_generator(g_origin_path, tmp_dir_);\n    std::map<std::string, std::string> default_section = get_DEFAULT_defaults();\n    default_section[\"logging_folder\"] = logging_folder;\n    default_section[\"keyring_path\"] = Path(tmp_dir_).join(\"keyring\").str();\n\n    if (assign_fake_reader)\n      default_section[\"master_key_reader\"] = script_generator.get_fake_reader_script();\n    else\n      default_section[\"master_key_reader\"] = script_generator.get_reader_script();\n\n    if (assign_fake_writer)\n      default_section[\"master_key_writer\"] = script_generator.get_fake_writer_script();\n    else\n      default_section[\"master_key_writer\"] = script_generator.get_writer_script();\n\n    return default_section;\n  }\n\n  std::map<std::string, std::string> get_incorrect_master_key_default_section_map() {\n\n    ScriptGenerator script_generator(g_origin_path, tmp_dir_);\n\n    auto default_section = get_DEFAULT_defaults();\n    default_section[\"logging_folder\"] = logging_folder;\n    default_section[\"keyring_path\"] = Path(tmp_dir_).join(\"keyring\").str();\n    default_section[\"master_key_reader\"] = script_generator.get_reader_incorrect_master_key_script();\n    default_section[\"master_key_writer\"] = script_generator.get_writer_script();\n\n    return default_section;\n  }\n\n  TcpPortPool port_pool_;\n  std::string tmp_dir_;\n  std::string bootstrap_dir_;\n  std::string logging_folder;\n  std::string master_key_;\n};\n\n/**\n * @test\n *       verify that when bootstrap is launched using --master-key-reader and\n *       --master-key-writer options then master key file is not created.\n */\nTEST_F(MasterKeyReaderWriterTest, NoMasterKeyFileWhenBootstrapPassWithMasterKeyReader) {\n  unsigned server_port = port_pool_.get_next_available();\n  auto server_mock = launch_mysql_server_mock(get_data_dir().join(\"bootstrap.js\").str(), server_port, false);\n  bool server_ready = wait_for_port_ready(server_port, 1000);\n  EXPECT_TRUE(server_ready) << server_mock.get_full_output();\n\n  ScriptGenerator script_generator(g_origin_path, tmp_dir_);\n\n  // launch the router in bootstrap mode\n  auto router = launch_router(\n      \"--bootstrap=127.0.0.1:\" + std::to_string(server_port)\n      + \" --report-host dont.query.dns\"\n      + \" --directory=\" + bootstrap_dir_\n      + \" --force\"\n      + \" --master-key-reader=\" + script_generator.get_reader_script()\n      + \" --master-key-writer=\" + script_generator.get_writer_script());\n\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \",\n      \"fake-pass\\n\");\n\n  // check if the bootstraping was successful\n  EXPECT_EQ(router.wait_for_exit(30000), 0);\n  EXPECT_TRUE(router.expect_output(\"MySQL Router  has now been configured for the InnoDB cluster 'mycluster'\")\n  ) << router.get_full_output() << std::endl << \"server: \"\n      << server_mock.get_full_output();\n\n  Path tmp(bootstrap_dir_);\n  Path master_key_file(tmp.join(\"mysqlrouter.key\").str());\n\n  ASSERT_FALSE(master_key_file.exists());\n\n  Path keyring_file(tmp.join(\"data\").join(\"keyring\").str());\n  ASSERT_TRUE(keyring_file.exists());\n\n  Path dir(tmp_dir_);\n  Path data_file(dir.join(\"master_key\").str());\n  ASSERT_TRUE(data_file.exists());\n}\n\n/**\n * @test\n *       verify that when bootstrap is launched using --master-key-reader and\n *       --master-key-writer options then generated config file contains\n *       entries for master_key_reader and master_key_writer.\n *       Also, verify that --bootstrap can be specified after --master-key-*\n *       options (all other tests will use it in the beginning).\n */\nTEST_F(MasterKeyReaderWriterTest, CheckConfigFileWhenBootstrapPassWithMasterKeyReader) {\n  unsigned server_port = port_pool_.get_next_available();\n  auto server_mock = launch_mysql_server_mock(get_data_dir().join(\"bootstrap.js\").str(), server_port, false);\n  bool server_ready = wait_for_port_ready(server_port, 1000);\n  EXPECT_TRUE(server_ready) << server_mock.get_full_output();\n\n  ScriptGenerator script_generator(g_origin_path, tmp_dir_);\n\n  // launch the router in bootstrap mode\n  auto router = launch_router(\n      \"--directory=\" + bootstrap_dir_\n      + \" --force\"\n      + \" --master-key-reader=\" + script_generator.get_reader_script()\n      + \" --master-key-writer=\" + script_generator.get_writer_script()\n      + \" --report-host dont.query.dns\"\n      + \" --bootstrap=127.0.0.1:\" + std::to_string(server_port));\n\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \",\n      \"fake-pass\\n\");\n\n  // check if the bootstraping was successful\n  EXPECT_EQ(router.wait_for_exit(30000), 0);\n  EXPECT_TRUE(router.expect_output(\"MySQL Router  has now been configured for the InnoDB cluster 'mycluster'\")\n  ) << router.get_full_output() << std::endl << \"server: \"\n      << server_mock.get_full_output();\n\n  Path tmp(bootstrap_dir_);\n  Path config_file(tmp.join(\"mysqlrouter.conf\").str());\n  ASSERT_TRUE(config_file.exists());\n\n  // read master-key-reader and master-key-writer\n  std::string master_key_reader = \"\", master_key_writer = \"\";\n\n  std::ifstream file(config_file.str());\n  std::istream_iterator<std::string> beg(file), eof;\n  std::vector<std::string> lines(beg, eof);\n\n  for(const auto& line : lines) {\n    int index = line.find('=');\n    if (line.substr(0, index) == \"master_key_reader\")\n      master_key_reader = line.substr(index+1);\n    else if (line.substr(0, index) == \"master_key_writer\")\n      master_key_writer = line.substr(index+1);\n  }\n\n  ASSERT_THAT(master_key_reader, testing::Eq(script_generator.get_reader_script()));\n  ASSERT_THAT(master_key_writer, testing::Eq(script_generator.get_writer_script()));\n}\n\n/**\n * @test\n *       verify that when --master-key-reader option is used, but specified reader cannot\n *       be executed, then bootstrap fails and appropriate error message is printed\n *       to standard output.\n */\nTEST_F(MasterKeyReaderWriterTest, BootstrapFailsWhenCannotRunMasterKeyReader) {\n  unsigned server_port = port_pool_.get_next_available();\n  auto server_mock = launch_mysql_server_mock(get_data_dir().join(\"bootstrap.js\").str(), server_port, false);\n  bool server_ready = wait_for_port_ready(server_port, 1000);\n  EXPECT_TRUE(server_ready) << server_mock.get_full_output();\n\n  ScriptGenerator script_generator(g_origin_path, tmp_dir_);\n\n  // launch the router in bootstrap mode\n  auto router = launch_router(\n      \"--bootstrap=127.0.0.1:\" + std::to_string(server_port)\n      + \" --report-host dont.query.dns\"\n      + \" --directory=\" + bootstrap_dir_\n      + \" --force\"\n      + \" --master-key-reader=\" + script_generator.get_fake_reader_script()\n      + \" --master-key-writer=\" + script_generator.get_writer_script());\n\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \",\n      \"fake-pass\\n\");\n\n  // check if the bootstraping failed\n  EXPECT_EQ(router.wait_for_exit(), 1);\n  EXPECT_TRUE(router.expect_output(\"Error: Cannot fetch master key file using master key reader\")\n  ) << router.get_full_output() << std::endl << \"server: \"\n      << server_mock.get_full_output();\n}\n\n/**\n * @test\n *       verify that when --master-key-writer option is used, but specified master\n *       key writer cannot be executed, then bootstrap fails and appropriate error\n *       message is printed to standard output.\n */\nTEST_F(MasterKeyReaderWriterTest, BootstrapFailsWhenCannotRunMasterKeyWriter) {\n  unsigned server_port = port_pool_.get_next_available();\n  auto server_mock = launch_mysql_server_mock(\n      get_data_dir().join(\"bootstrap.js\").str(), server_port, false);\n  bool server_ready = wait_for_port_ready(server_port, 1000);\n  EXPECT_TRUE(server_ready) << server_mock.get_full_output();\n\n  ScriptGenerator script_generator(g_origin_path, tmp_dir_);\n\n  // launch the router in bootstrap mode\n  auto router = launch_router(\n      \"--bootstrap=127.0.0.1:\" + std::to_string(server_port)\n      + \" --report-host dont.query.dns\"\n      + \" --directory=\" + bootstrap_dir_\n      + \" --force\"\n      + \" --master-key-reader=\" + script_generator.get_reader_script()\n      + \" --master-key-writer=\" + script_generator.get_fake_writer_script());\n\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \",\n      \"fake-pass\\n\");\n\n  // check if the bootstraping failed\n  EXPECT_EQ(router.wait_for_exit(), 1);\n  EXPECT_TRUE(router.expect_output(\"Error: Cannot write master key file using master key writer\")\n  ) << router.get_full_output() << std::endl << \"server: \"\n      << server_mock.get_full_output();\n}\n\n/**\n * @test\n *       verify that if keyring file already exists and --master-key-reader option\n *       is used and bootstrap fails, then original keyring file is restored.\n */\nTEST_F(MasterKeyReaderWriterTest, KeyringFileRestoredWhenBootstrapFails) {\n\n  mysqlrouter::mkdir(Path(tmp_dir_).join(\"data\").str(), 0777);\n  // create keyring file\n  Path keyring_path(Path(tmp_dir_).join(\"data\").join(\"keyring\").str());\n\n  write_to_file(keyring_path, \"keyring file content\");\n\n  unsigned server_port = port_pool_.get_next_available();\n  auto server_mock = launch_mysql_server_mock(get_data_dir().join(\"bootstrap.js\").str(), server_port, false);\n  bool server_ready = wait_for_port_ready(server_port, 1000);\n  EXPECT_TRUE(server_ready) << server_mock.get_full_output();\n\n  ScriptGenerator script_generator(g_origin_path, tmp_dir_);\n\n  // launch the router in bootstrap mode\n  auto router = launch_router(\n      \"--bootstrap=127.0.0.1:\" + std::to_string(server_port) + \" --directory=\"\n          + bootstrap_dir_ + \" --force\" + \" --master-key-reader=\"\n          + script_generator.get_fake_reader_script() + \" --master-key-writer=\"\n          + script_generator.get_fake_writer_script());\n\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \",\n      \"fake-pass\\n\");\n\n  // check if the bootstraping failed\n  EXPECT_EQ(router.wait_for_exit(), 1);\n  ASSERT_THAT(keyring_path.str(), FileContentEqual(\"keyring file content\"));\n}\n\n/**\n * @test\n *       verify that if --master-key-reader option is used and bootstrap fails,\n *       then original master key is restored.\n */\nTEST_F(MasterKeyReaderWriterTest, MasterKeyRestoredWhenBootstrapFails) {\n\n  // create file that is used by master-key-reader and master-key-writer\n  Path master_key_path(Path(tmp_dir_).join(\"master_key\").str());\n  write_to_file(master_key_path, \"\");\n\n  unsigned server_port = port_pool_.get_next_available();\n  ScriptGenerator script_generator(g_origin_path, tmp_dir_);\n\n  // launch the router in bootstrap mode\n  auto router = launch_router(\n      \"--bootstrap=127.0.0.1:\" + std::to_string(server_port) + \" --directory=\"\n          + bootstrap_dir_ + \" --force\" + \" --master-key-reader=\"\n          + script_generator.get_reader_script() + \" --master-key-writer=\"\n          + script_generator.get_writer_script());\n\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \",\n      \"fake-pass\\n\");\n\n  // check if the bootstraping failed\n  EXPECT_EQ(router.wait_for_exit(), 1);\n  ASSERT_THAT(master_key_path.str(), FileContentEqual(\"\"));\n}\n\n/*\n * @test\n *       verify that if --master-key-reader option is used and original master key is empty\n *       and bootstrap passes, then new master key is stored using --master-key-writer.\n */\nTEST_F(MasterKeyReaderWriterTest, IsNewMasterKeyIfReaderReturnsEmptyKeyAndBootstrapPass) {\n  write_to_file(Path(tmp_dir_).join(\"master_key\"), \"\");\n\n  unsigned server_port = port_pool_.get_next_available();\n  auto server_mock = launch_mysql_server_mock(get_data_dir().join(\"bootstrap.js\").str(), server_port, false);\n  bool server_ready = wait_for_port_ready(server_port, 1000);\n  EXPECT_TRUE(server_ready) << server_mock.get_full_output();\n\n  ScriptGenerator script_generator(g_origin_path, tmp_dir_);\n\n  // launch the router in bootstrap mode\n  auto router = launch_router(\n      \"--bootstrap=127.0.0.1:\" + std::to_string(server_port)\n      + \" --report-host dont.query.dns\"\n      + \" --directory=\" + bootstrap_dir_\n      + \" --force\"\n      + \" --master-key-reader=\" + script_generator.get_reader_script()\n      + \" --master-key-writer=\" + script_generator.get_writer_script());\n\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \",\n      \"fake-pass\\n\");\n\n  // check if the bootstraping was successful\n  EXPECT_EQ(router.wait_for_exit(30000), 0);\n  EXPECT_TRUE(router.expect_output(\"MySQL Router  has now been configured for the InnoDB cluster 'mycluster'\")\n  ) << router.get_full_output() << std::endl << \"server: \"\n      << server_mock.get_full_output();\n\n  Path dir(tmp_dir_);\n  Path data_file(dir.join(\"master_key\").str());\n  ASSERT_TRUE(data_file.exists());\n  ASSERT_THAT(data_file.str(), FileContentNotEqual(\"\"));\n}\n\n/*\n * @test\n *       verify that if master key exists and is not empty and bootstrap pass, then\n *       original master key is not overriden.\n */\nTEST_F(MasterKeyReaderWriterTest, DontWriteMasterKeyAtBootstrapIfMasterKeyAlreadyExists) {\n  write_to_file(Path(tmp_dir_).join(\"master_key\"), \"master key value\");\n\n  unsigned server_port = port_pool_.get_next_available();\n  auto server_mock = launch_mysql_server_mock(get_data_dir().join(\"bootstrap.js\").str(), server_port, false);\n  bool server_ready = wait_for_port_ready(server_port, 1000);\n  EXPECT_TRUE(server_ready) << server_mock.get_full_output();\n\n  ScriptGenerator script_generator(g_origin_path, tmp_dir_);\n\n  // launch the router in bootstrap mode\n  auto router = launch_router(\n      \"--bootstrap=127.0.0.1:\" + std::to_string(server_port)\n      + \" --report-host dont.query.dns\"\n      + \" --directory=\" + bootstrap_dir_\n      + \" --force\"\n      + \" --master-key-reader=\" + script_generator.get_reader_script()\n      + \" --master-key-writer=\" + script_generator.get_writer_script());\n\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \",\n      \"fake-pass\\n\");\n\n  // check if the bootstraping failed\n  EXPECT_EQ(router.wait_for_exit(), 0) << router.get_full_output();\n  ASSERT_THAT(Path(tmp_dir_).join(\"master_key\").str(), FileContentEqual(\"master key value\"));\n}\n\n/**\n * @test\n *       verify that when master key returned by master-key-reader is correct,\n *       then launching the router succeeds\n *\n */\nTEST_F(MasterKeyReaderWriterTest, ConnectToMetadataServerPass) {\n  unsigned server_port = port_pool_.get_next_available();\n  unsigned router_port = port_pool_.get_next_available();\n  std::string metadata_cache_section = get_metadata_cache_section(server_port);\n  std::string routing_section = get_metadata_cache_routing_section(\"PRIMARY\",\n      \"round-robin\", router_port);\n\n  std::string json_primary_node = get_json_file(get_data_dir(), server_port);\n  init_keyring();\n\n  // launch server\n  auto server = launch_mysql_server_mock(json_primary_node, server_port, false);\n  bool server_ready = wait_for_port_ready(server_port, 1000);\n  EXPECT_TRUE(server_ready) << server.get_full_output();\n\n  auto default_section_map = get_default_section_map();\n  // launch the router with metadata-cache configuration\n  auto router = RouterComponentTest::launch_router(\n      \"-c \" + create_config_file(\"[logger]\\nlevel = DEBUG\\n\"+ metadata_cache_section + routing_section, &default_section_map));\n\n  // in windows waiting for the router's keyring reader takes about 2seconds, and we need to do 3 rounds\n  EXPECT_TRUE(wait_for_port_ready(router_port, 10000)) << router.get_full_output();\n\n  auto matcher = [&](const std::string& line) -> bool {\n    return line.find(\"Connected with metadata server running on\") != line.npos;\n  };\n\n  EXPECT_TRUE(find_in_file(logging_folder+\"/mysqlrouter.log\", matcher,\n          std::chrono::milliseconds(10000))) << router.get_full_output();\n}\n\n/**\n * @test\n *       verify that when master key returned by master-key-reader is correct\n *       and then launching the router succeeds, then master-key is not written\n *       to log files.\n *\n */\nTEST_F(MasterKeyReaderWriterTest, NoMasterKeyInLogsWhenConnectToMetadataServerPass) {\n  unsigned server_port = port_pool_.get_next_available();\n  unsigned router_port = port_pool_.get_next_available();\n  std::string metadata_cache_section = get_metadata_cache_section(server_port);\n  std::string routing_section = get_metadata_cache_routing_section(\"PRIMARY\",\n      \"round-robin\", router_port);\n\n  std::string json_primary_node = get_json_file(get_data_dir(), server_port);\n  init_keyring();\n\n  // launch server\n  auto server = launch_mysql_server_mock(json_primary_node, server_port, false);\n  bool server_ready = wait_for_port_ready(server_port, 1000);\n  EXPECT_TRUE(server_ready) << server.get_full_output();\n\n  auto default_section_map = get_default_section_map();\n  // launch the router with metadata-cache configuration\n  auto router = RouterComponentTest::launch_router(\n      \"-c \" + create_config_file(\"[logger]\\nlevel = DEBUG\\n\"+ metadata_cache_section + routing_section, &default_section_map));\n\n  // in windows waiting for the router's keyring reader takes about 2seconds, and we need to do 3 rounds\n  EXPECT_TRUE(wait_for_port_ready(router_port, 10000)) << router.get_full_output();\n\n  auto matcher = [&, this](const std::string& line) -> bool {\n    return line.find(master_key_) != line.npos;\n  };\n\n  EXPECT_FALSE(find_in_file(logging_folder+\"/mysqlrouter.log\", matcher,\n          std::chrono::milliseconds(1000))) << router.get_full_output();\n}\n\n/**\n * @test\n *       verify that when cannot run master-key-reader in order to read master key then\n *       launching the router fails.\n */\nTEST_F(MasterKeyReaderWriterTest, CannotLaunchRouterWhenNoMasterKeyReader) {\n  unsigned server_port = port_pool_.get_next_available();\n  unsigned router_port = port_pool_.get_next_available();\n  std::string metadata_cache_section = get_metadata_cache_section(server_port);\n  std::string routing_section = get_metadata_cache_routing_section(\"PRIMARY\",\n      \"round-robin\", router_port);\n\n  std::string json_primary_node = get_json_file(get_data_dir(), server_port);\n  init_keyring();\n\n  // launch second metadata server\n  auto server = launch_mysql_server_mock(json_primary_node, server_port, false);\n  bool server_ready = wait_for_port_ready(server_port, 1000);\n  EXPECT_TRUE(server_ready) << server.get_full_output();\n\n  auto default_section_map = get_default_section_map(true, true);\n  // launch the router with metadata-cache configuration\n  auto router = RouterComponentTest::launch_router(\n      \"-c \" + create_config_file(\"[logger]\\nlevel = DEBUG\\n\"+ metadata_cache_section + routing_section, &default_section_map));\n\n  EXPECT_EQ(router.wait_for_exit(), 1);\n}\n\n/**\n * @test\n *       verify that when password fetched using --master-key-reader is incorrect,\n *       then launching the router fails with appropriate log message.\n */\nTEST_F(MasterKeyReaderWriterTest, CannotLaunchRouterWhenMasterKeyIncorrect) {\n  unsigned server_port = port_pool_.get_next_available();\n  unsigned router_port = port_pool_.get_next_available();\n  std::string metadata_cache_section = get_metadata_cache_section(server_port);\n  std::string routing_section = get_metadata_cache_routing_section(\"PRIMARY\",\n      \"round-robin\", router_port);\n\n  std::string json_primary_node = get_json_file(get_data_dir(), server_port);\n  init_keyring();\n\n  // launch second metadata server\n  auto server = launch_mysql_server_mock(json_primary_node, server_port, false);\n  bool server_ready = wait_for_port_ready(server_port, 1000);\n  EXPECT_TRUE(server_ready) << server.get_full_output();\n\n  auto incorrect_master_key_default_section_map = get_incorrect_master_key_default_section_map();\n  // launch the router with metadata-cache configuration\n  auto router = RouterComponentTest::launch_router(\n      \"-c \" + create_config_file(\"[logger]\\nlevel = DEBUG\\n\" + metadata_cache_section + routing_section, &incorrect_master_key_default_section_map));\n\n  EXPECT_EQ(router.wait_for_exit(), 1);\n}\n/*\n * These tests are executed only for STANDALONE layout and are not executed for Windows.\n * Bootstrap for layouts different than STANDALONE use directories to which\n * tests don't have access (see install_layout.cmake).\n */\n#ifndef SKIP_BOOTSTRAP_SYSTEM_DEPLOYMENT_TESTS\n\nclass MasterKeyReaderWriterSystemDeploymentTest : public RouterComponentTest, public ::testing::Test {\nprotected:\n void SetUp() override {\n   set_origin(g_origin_path);\n   RouterComponentTest::SetUp();\n   init_tmp_dir();\n\n   set_mysqlrouter_exec(Path(exec_file_));\n }\n\n void TearDown() override {\n   purge_dir(tmp_dir_);\n }\n\n void write_to_file(const Path& file_path, const std::string& text) {\n   std::ofstream master_key_file(file_path.str());\n   if (master_key_file.good()) {\n     master_key_file << text;\n   }\n }\n\n /*\n  * Create temporary directory that represents system deployment\n  * layout for mysql bootstrap. A mysql executable is copied to\n  * tmp_dir_/stage/bin/ and then an execution permission is assigned to it.\n  *\n  * After the test is completed, the whole temporary directory is deleted.\n  */\n void init_tmp_dir() {\n   tmp_dir_ = get_tmp_dir();\n   mysqlrouter::mkdir(tmp_dir_ + \"/stage\", 0700);\n   mysqlrouter::mkdir(tmp_dir_ + \"/stage/bin\", 0700);\n   exec_file_ = tmp_dir_ + \"/stage/bin/mysqlrouter\";\n   mysqlrouter::copy_file(get_mysqlrouter_exec().str(), exec_file_);\n#ifndef _WIN32\n   chmod(exec_file_.c_str(), 0700);\n#endif\n   config_file_ = tmp_dir_ + \"/stage/mysqlrouter.conf\";\n }\n\n RouterComponentTest::CommandHandle run_server_mock() {\n   const std::string json_stmts = get_data_dir().join(\"bootstrap.js\").str();\n   server_port_ = port_pool_.get_next_available();\n\n   // launch mock server and wait for it to start accepting connections\n   auto server_mock = launch_mysql_server_mock(json_stmts, server_port_);\n   EXPECT_TRUE(wait_for_port_ready(server_port_, 1000))\n     << \"Timed out waiting for mock server port ready\\n\"\n     << server_mock.get_full_output();\n   return server_mock;\n }\n\n TcpPortPool port_pool_;\n\n std::string tmp_dir_;\n std::string exec_file_;\n std::string config_file_;\n\n unsigned server_port_;\n};\n\n/**\n * @test\n *      Verify if bootstrap with --master-key-reader and --master-key-writer\n *      and with system deployment layout then master key file (stage/mysqlrouter.key)\n *      is not generated.\n */\nTEST_F(MasterKeyReaderWriterSystemDeploymentTest, BootstrapPass) {\n  auto server_mock = run_server_mock();\n  bool server_ready = wait_for_port_ready(server_port_, 1000);\n  EXPECT_TRUE(server_ready) << server_mock.get_full_output();\n\n  ScriptGenerator script_generator(g_origin_path, tmp_dir_);\n\n  // launch the router in bootstrap mode\n  auto router = launch_router(\"--bootstrap=127.0.0.1:\" + std::to_string(server_port_)\n                              + \" --report-host dont.query.dns\"\n                              + \" --master-key-reader=\" + script_generator.get_reader_script()\n                              + \" --master-key-writer=\" + script_generator.get_writer_script());\n\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \", \"fake-pass\\n\");\n\n  // check if the bootstraping was successful\n  EXPECT_EQ(router.wait_for_exit(), 0);\n  EXPECT_TRUE(router.expect_output(\"MySQL Router  has now been configured for the InnoDB cluster 'mycluster'\")\n    ) << router.get_full_output() << std::endl << \"server: \" << server_mock.get_full_output();\n\n  Path dir(tmp_dir_);\n  Path data_file(dir.join(\"stage\").join(\"mysqlrouter.key\").str());\n  ASSERT_FALSE(data_file.exists());\n}\n\n/**\n * @test\n *       verify if bootstrap with --master-key-reader and with system deployment layout,\n *       but specified reader cannot be executed, then bootstrap fails and appropriate\n *       error message is printed to standard output.\n */\nTEST_F(MasterKeyReaderWriterSystemDeploymentTest, BootstrapFailsWhenCannotRunMasterKeyReader) {\n  auto server_mock = run_server_mock();\n  bool server_ready = wait_for_port_ready(server_port_, 1000);\n  EXPECT_TRUE(server_ready) << server_mock.get_full_output();\n\n  ScriptGenerator script_generator(g_origin_path, tmp_dir_);\n\n  // launch the router in bootstrap mode\n  auto router = launch_router(\"--bootstrap=127.0.0.1:\" + std::to_string(server_port_)\n                              + \" --report-host dont.query.dns\"\n                              + \" --master-key-reader=\" + script_generator.get_fake_reader_script()\n                              + \" --master-key-writer=\" + script_generator.get_writer_script());\n\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \",\n      \"fake-pass\\n\");\n\n  // check if the bootstraping failed\n  EXPECT_EQ(router.wait_for_exit(), 1);\n  EXPECT_TRUE(router.expect_output(\"Error: Cannot fetch master key file using master key reader\")\n  ) << router.get_full_output() << std::endl << \"server: \"\n      << server_mock.get_full_output();\n}\n\n/**\n * @test\n *       verify if bootstrap with --master-key-writer and system deployment layout,\n *       but specified master key writer cannot be executed, then bootstrap fails\n *       and appropriate error message is printed to standard output.\n */\nTEST_F(MasterKeyReaderWriterSystemDeploymentTest, BootstrapFailsWhenCannotRunMasterKeyWriter) {\n  auto server_mock = run_server_mock();\n  bool server_ready = wait_for_port_ready(server_port_, 1000);\n  EXPECT_TRUE(server_ready) << server_mock.get_full_output();\n\n  ScriptGenerator script_generator(g_origin_path, tmp_dir_);\n\n  // launch the router in bootstrap mode\n  auto router = launch_router(\"--bootstrap=127.0.0.1:\" + std::to_string(server_port_)\n                              + \" --report-host dont.query.dns\"\n                              + \" --master-key-reader=\" + script_generator.get_reader_script()\n                              + \" --master-key-writer=\" + script_generator.get_fake_writer_script());\n\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \",\n      \"fake-pass\\n\");\n\n  // check if the bootstraping failed\n  EXPECT_EQ(router.wait_for_exit(), 1);\n  EXPECT_TRUE(router.expect_output(\"Error: Cannot write master key file using master key writer\")\n  ) << router.get_full_output() << std::endl << \"server: \"\n      << server_mock.get_full_output();\n}\n\n/**\n * @test\n *       verify that if keyring file already exists and bootstrap with --master-key-reader\n *       and system deployment layout and bootstrap fails, then original keyring file is restored.\n */\nTEST_F(MasterKeyReaderWriterSystemDeploymentTest, KeyringFileRestoredWhenBootstrapFails) {\n\n  mysqlrouter::mkdir(Path(tmp_dir_).join(\"stage\").join(\"data\").str(), 0777);\n  // create keyring file\n  Path keyring_path(Path(tmp_dir_).join(\"stage\").join(\"data\").join(\"keyring\").str());\n  // set original keyring file\n  write_to_file(keyring_path, \"keyring file content\");\n\n  auto server_mock = run_server_mock();\n  bool server_ready = wait_for_port_ready(server_port_, 1000);\n  EXPECT_TRUE(server_ready) << server_mock.get_full_output();\n\n  ScriptGenerator script_generator(g_origin_path, tmp_dir_);\n\n  // launch the router in bootstrap mode\n  auto router = launch_router(\"--bootstrap=127.0.0.1:\" + std::to_string(server_port_)\n          + \" --master-key-reader=\" + script_generator.get_fake_reader_script()\n          + \" --master-key-writer=\" + script_generator.get_fake_writer_script());\n\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \",\n      \"fake-pass\\n\");\n\n  // check if the bootstraping failed\n  EXPECT_EQ(router.wait_for_exit(), 1);\n  ASSERT_THAT(keyring_path.str(), FileContentEqual(\"keyring file content\"));\n}\n\n/**\n * @test\n *       verify bootstrap with --master-key-reader and system deployment layout\n *       and bootstrap fails, then original master key is restored.\n */\nTEST_F(MasterKeyReaderWriterSystemDeploymentTest, MasterKeyRestoredWhenBootstrapFails) {\n  // create file with master key\n  Path master_key_path(Path(tmp_dir_).join(\"master_key\").str());\n  write_to_file(master_key_path, \"\");\n\n  unsigned server_port = port_pool_.get_next_available();\n  ScriptGenerator script_generator(g_origin_path, tmp_dir_);\n\n  // launch the router in bootstrap mode\n  auto router = launch_router(\"--bootstrap=127.0.0.1:\" + std::to_string(server_port)\n          + \" --master-key-reader=\" + script_generator.get_reader_script()\n          + \" --master-key-writer=\" + script_generator.get_writer_script());\n\n  // add login hook\n  router.register_response(\"Please enter MySQL password for root: \",\n      \"fake-pass\\n\");\n\n  // check if the bootstraping failed\n  EXPECT_EQ(router.wait_for_exit(), 1);\n  ASSERT_THAT(master_key_path.str(), FileContentEqual(\"\"));\n}\n\n#endif\n\nint main(int argc, char *argv[]) {\n  init_windows_sockets();\n  g_origin_path = Path(argv[0]).dirname();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "tests/component/test_metadata_ttl.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"gmock/gmock.h\"\n#include \"router_component_test.h\"\n#include \"tcp_port_pool.h\"\n#include \"rapidjson/document.h\"\n#include \"mysql_session.h\"\n#include \"mysqlrouter/rest_client.h\"\n#include \"keyring/keyring_manager.h\"\n\n#include <chrono>\n#include <thread>\n\nPath g_origin_path;\nusing mysqlrouter::MySQLSession;\nusing ::testing::PrintToString;\n\nconst std::string kMockServerGlobalsRestUri = \"/api/v1/mock_server/globals/\";\n\nclass MetadataChacheTTLTest : public RouterComponentTest {\n protected:\n  virtual void SetUp() {\n    set_origin(g_origin_path);\n    RouterComponentTest::SetUp();\n  }\n\n  std::string get_metadata_cache_section(unsigned metadata_server_port, const std::string& ttl= \"0.5\") {\n    return \"[metadata_cache:test]\\n\"\n           \"router_id=1\\n\"\n           \"bootstrap_server_addresses=mysql://localhost:\" + std::to_string(metadata_server_port) + \"\\n\" +\n           \"user=mysql_router1_user\\n\"\n           \"metadata_cluster=test\\n\" +\n           (ttl.empty() ? \"\" : std::string(\"ttl=\" + ttl + \"\\n\")) +\n           \"\\n\";\n  }\n\n  std::string get_metadata_cache_routing_section(unsigned router_port,\n                                                 const std::string& role,\n                                                 const std::string& strategy,\n                                                 const std::string& mode = \"\") {\n    std::string result = \"[routing:test_default]\\n\"\n      \"bind_port=\" + std::to_string(router_port) + \"\\n\" +\n      \"destinations=metadata-cache://test/default?role=\" + role + \"\\n\" +\n      \"protocol=classic\\n\";\n\n    if (!strategy.empty()) result += std::string(\"routing_strategy=\" + strategy + \"\\n\");\n    if (!mode.empty()) result += std::string(\"mode=\" + mode + \"\\n\");\n\n    return result;\n  }\n\n  std::string get_server_mock_globals_as_json_string(const unsigned http_port) {\n    IOContext io_ctx;\n    auto req = RestClient(io_ctx, \"127.0.0.1\", http_port).\n      request_sync(HttpMethod::Get, kMockServerGlobalsRestUri);\n    EXPECT_TRUE(req);\n    EXPECT_EQ(req.get_response_code(), 200u);\n    EXPECT_THAT(req.get_input_headers().get(\"Content-Type\"), ::testing::StrEq(\"application/json\"));\n    auto resp_body = req.get_input_buffer();\n    EXPECT_GT(resp_body.length(), 0u);\n    auto resp_body_content = resp_body.pop_front(resp_body.length());\n\n    // parse json\n    std::string json_payload(resp_body_content.begin(), resp_body_content.end());\n    return json_payload;\n  }\n\n  int get_ttl_queries_count(const std::string& json_string) {\n    rapidjson::Document json_doc;\n    json_doc.Parse(json_string.c_str());\n    EXPECT_TRUE(json_doc.HasMember(\"md_query_count\"));\n    EXPECT_TRUE(json_doc[\"md_query_count\"].IsInt());\n\n    return json_doc[\"md_query_count\"].GetInt();\n  }\n\n  RouterComponentTest::CommandHandle\n  launch_router(unsigned router_port,\n                const std::string& temp_test_dir,\n                const std::string& metadata_cache_section,\n                const std::string& routing_section,\n                bool catch_stderr = true,\n                bool with_sudo = false,\n                bool wait_ready = true,\n                bool log_to_stdout = false) {\n    const std::string masterkey_file = Path(temp_test_dir).join(\"master.key\").str();\n    const std::string keyring_file = Path(temp_test_dir).join(\"keyring\").str();\n    mysql_harness::init_keyring(keyring_file, masterkey_file, true);\n    mysql_harness::Keyring *keyring = mysql_harness::get_keyring();\n    keyring->store(\"mysql_router1_user\", \"password\", \"root\");\n    mysql_harness::flush_keyring();\n    mysql_harness::reset_keyring();\n\n    // enable debug logs for better diagnostics in case of failure\n    std::string logger_section = \"[logger]\\nlevel = DEBUG\\n\";\n\n    // launch the router with metadata-cache configuration\n    auto default_section = get_DEFAULT_defaults();\n    default_section[\"keyring_path\"] = keyring_file;\n    default_section[\"master_key_path\"] = masterkey_file;\n    if (log_to_stdout) {\n      default_section[\"logging_folder\"] = \"\";\n    }\n    const std::string conf_file = create_config_file(logger_section + metadata_cache_section + routing_section, &default_section);\n    auto router = RouterComponentTest::launch_router(\"-c \" +  conf_file, catch_stderr, with_sudo);\n    if (wait_ready) {\n      bool ready = wait_for_port_ready(router_port, 1000);\n      EXPECT_TRUE(ready) << get_router_log_output();\n    }\n\n    return router;\n  }\n\n  TcpPortPool port_pool_;\n};\n\nstruct MetadataTTLTestParams {\n  //  ttl value we want to set (floating point decimal in seconds)\n  std::string ttl;\n  // how long do we run the router and count the metadata queries\n  std::chrono::milliseconds router_uptime;\n  // how many metadata queries we expect over this period\n  int expected_md_queries_count;\n  // if true expected_md_queries_count is only a minimal expected\n  // value, we should not check for maximum\n  bool at_least;\n\n  MetadataTTLTestParams(std::string ttl_,\n                        std::chrono::milliseconds router_uptime_ = std::chrono::milliseconds(0),\n                        int expected_md_queries_count_ = 0, bool at_least_ = false):\n    ttl(ttl_), router_uptime(router_uptime_),\n    expected_md_queries_count(expected_md_queries_count_), at_least(at_least_) {\n  }\n};\n\nclass MetadataChacheTTLTestParam : public MetadataChacheTTLTest,\n                                   public ::testing::TestWithParam<MetadataTTLTestParams> {\nprotected:\n virtual void SetUp() {\n   MetadataChacheTTLTest::SetUp();\n }\n};\n\nMATCHER_P2(IsBetween, a, b,\n           std::string(negation ? \"isn't\" : \"is\") + \" between \" + PrintToString(a)\n           + \" and \" + PrintToString(b)) {\n  return a <= arg && arg <= b;\n}\n\nTEST_P(MetadataChacheTTLTestParam, CheckTTLValid) {\n\n  auto test_params = GetParam();\n\n  const std::string temp_test_dir = get_tmp_dir();\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(temp_test_dir);});\n\n  // launch the serevr mock (it's our metadata server and single cluster node)\n  auto md_server_port =  port_pool_.get_next_available();\n  auto md_server_http_port =  port_pool_.get_next_available();\n  const std::string json_metadata = get_data_dir().join(\"metadata_1_node_repeat.js\").str();\n\n  auto metadata_server = launch_mysql_server_mock(json_metadata, md_server_port, false, md_server_http_port);\n  bool ready = wait_for_port_ready(md_server_port, 1000);\n  EXPECT_TRUE(ready) << metadata_server.get_full_output();\n\n\n  // launch the router with metadata-cache configuration\n  const auto router_port = port_pool_.get_next_available();\n  const std::string metadata_cache_section = get_metadata_cache_section(md_server_port, test_params.ttl);\n  const std::string routing_section = get_metadata_cache_routing_section(router_port, \"PRIMARY\",\n                                                                         \"first-available\");\n  // on pb2 for Windows waiting for port being ready takes too long and this affects the number of\n  // ttl queries during our sleep, on the other hand not waiting for it on some slow VMs (like macOS)\n  // has the opposite effect\n#ifdef _WIN32\n  bool wait_port_ready = false;\n#else\n  bool wait_port_ready = true;\n#endif\n  auto router = launch_router(router_port, temp_test_dir, metadata_cache_section, routing_section, true, false,\n    wait_port_ready);\n\n  // keep the router running to see how many times it queries for metadata\n  std::this_thread::sleep_for(test_params.router_uptime);\n\n    // let's ask the mock how many metadata queries it got after\n  std::string server_globals = get_server_mock_globals_as_json_string(md_server_http_port);\n  int ttl_count = get_ttl_queries_count(server_globals);\n\n  if (!test_params.at_least) {\n    // it is timing based test so to decrease random failures chances let's\n    // take some error marigin, we verify that number of metadata queries\n    // falls into <expected_count-1, expected_count+1>\n    EXPECT_THAT(ttl_count, IsBetween(test_params.expected_md_queries_count-1,\n      test_params.expected_md_queries_count+1)) << get_router_log_output();\n  }\n  else {\n    // we only check that the TTL was queried at least N times\n    EXPECT_GE(ttl_count, test_params.expected_md_queries_count);\n  }\n\n  ASSERT_THAT(router.kill(), testing::Eq(0));\n}\n\n\n// Note: +1 becuase the router queries for the metadata twice when it initializes.\n// Whenever that gets fixed and this test starts failing try removing '+1'\nINSTANTIATE_TEST_CASE_P(CheckTTLIsUsedCorrectly,\n                        MetadataChacheTTLTestParam,\n                        ::testing::Values(\n                           MetadataTTLTestParams(\"0.4\", std::chrono::milliseconds(800), 2+1),\n                           MetadataTTLTestParams(\"1\", std::chrono::milliseconds(3000), 3+1),\n                           // check that default is 0.5 if not provided:\n                           MetadataTTLTestParams(\"\", std::chrono::milliseconds(2000), 4+1),\n                           // check that for 0 there are multiple ttl queries (we can't really guess\n                           // how many there will be, but we should be able to safely assume that in 1 second\n                           // it shold be at least 5 queries)\n                           MetadataTTLTestParams(\"0\", std::chrono::milliseconds(1000), 5+1,\n                                                 /*at_least=*/ true)\n                          )\n                        );\n\nclass MetadataChacheTTLTestParamInvalid : public MetadataChacheTTLTest,\n                                   public ::testing::TestWithParam<MetadataTTLTestParams> {\nprotected:\n virtual void SetUp() {\n   MetadataChacheTTLTest::SetUp();\n }\n};\n\nTEST_P(MetadataChacheTTLTestParamInvalid, CheckTTLInvalid) {\n\n  auto test_params = GetParam();\n\n  const std::string temp_test_dir = get_tmp_dir();\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(temp_test_dir);});\n\n  // launch the serevr mock (it's our metadata server and single cluster node)\n  auto md_server_port =  port_pool_.get_next_available();\n  auto md_server_http_port =  port_pool_.get_next_available();\n  const std::string json_metadata = get_data_dir().join(\"metadata_1_node_repeat.js\").str();\n\n  auto metadata_server = launch_mysql_server_mock(json_metadata, md_server_port, false, md_server_http_port);\n  bool ready = wait_for_port_ready(md_server_port, 1000);\n  EXPECT_TRUE(ready) << metadata_server.get_full_output();\n\n\n  // launch the router with metadata-cache configuration\n  const auto router_port = port_pool_.get_next_available();\n  const std::string metadata_cache_section = get_metadata_cache_section(md_server_port, test_params.ttl);\n  const std::string routing_section = get_metadata_cache_routing_section(router_port, \"PRIMARY\",\n                                                                         \"first-available\");\n  auto router = launch_router(router_port, temp_test_dir, metadata_cache_section, routing_section,\n                              true, false, false, /* log_to_stdout= */ true);\n\n  EXPECT_EQ(router.wait_for_exit(), 1);\n  EXPECT_THAT(router.exit_code(), testing::Ne(0));\n  EXPECT_TRUE(router.expect_output(\"Configuration error: option ttl in [metadata_cache:test] needs value between 0 and 3600 inclusive\"));\n}\n\nINSTANTIATE_TEST_CASE_P(CheckInvalidTTLRefusesStart,\n                        MetadataChacheTTLTestParamInvalid,\n                        ::testing::Values(\n                           MetadataTTLTestParams(\"-0.001\"),\n                           MetadataTTLTestParams(\"3600.001\"),\n                           MetadataTTLTestParams(\"INVALID\"),\n                           MetadataTTLTestParams(\"1,1\")\n                          )\n                        );\n\nint main(int argc, char *argv[]) {\n  init_windows_sockets();\n  g_origin_path = Path(argv[0]).dirname();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "tests/component/test_mock_server.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifdef _WIN32\n// ensure windows.h doesn't expose min() nor max()\n#  define NOMINMAX\n#endif\n\n#include <thread>\n\n#include \"router_config.h\"\n#include \"gmock/gmock.h\"\n#include \"router_component_test.h\"\n\nPath g_origin_path;\n\n\n\nclass MockServerCLITest : public RouterComponentTest, public ::testing::Test {\nprotected:\n  void SetUp() override {\n    set_origin(g_origin_path);\n    RouterComponentTest::SetUp();\n  }\n};\n\n/**\n * ensure mock-server supports --version.\n *\n * verifies:\n *\n * - WL12118\n *   - TS_1-3\n */\nTEST_F(MockServerCLITest, has_version) {\n  auto mysql_server_mock_path = get_mysqlserver_mock_exec().str();\n\n  ASSERT_THAT(mysql_server_mock_path, ::testing::StrNe(\"\"));\n\n  SCOPED_TRACE(\"// start binary\");\n  auto cmd = launch_command(mysql_server_mock_path,\n      std::vector<std::string>{\"--version\"},\n      true);\n\n  SCOPED_TRACE(\"// wait for exit\");\n  EXPECT_EQ(cmd.wait_for_exit(1000), 0); // should be quick, and return 0\n  SCOPED_TRACE(\"// checking stdout\");\n  EXPECT_THAT(cmd.get_full_output(), ::testing::HasSubstr(MYSQL_ROUTER_VERSION));\n}\n\n/**\n * ensure mock-server supports --help.\n */\nTEST_F(MockServerCLITest, has_help) {\n  auto mysql_server_mock_path = get_mysqlserver_mock_exec().str();\n\n  ASSERT_THAT(mysql_server_mock_path, ::testing::StrNe(\"\"));\n\n  SCOPED_TRACE(\"// start binary with --help\");\n  auto cmd = launch_command(mysql_server_mock_path,\n      std::vector<std::string>{\"--help\"},\n      true);\n\n  SCOPED_TRACE(\"// wait for exit\");\n  EXPECT_NO_THROW(EXPECT_EQ(cmd.wait_for_exit(1000), 0)); // should be quick, and return 0\n  SCOPED_TRACE(\"// checking stdout contains --version\");\n  EXPECT_THAT(cmd.get_full_output(), ::testing::HasSubstr(\"--version\"));\n}\n\n/**\n * ensure mock-server supports --http-port=65536 fails.\n *\n * verifies:\n *\n * - WL12118\n *   - TS_1-4\n */\nTEST_F(MockServerCLITest, http_port_too_large) {\n  auto mysql_server_mock_path = get_mysqlserver_mock_exec().str();\n\n  ASSERT_THAT(mysql_server_mock_path, ::testing::StrNe(\"\"));\n\n  SCOPED_TRACE(\"// start binary with --http-port=65536\");\n  auto cmd = launch_command(mysql_server_mock_path,\n      std::vector<std::string>{\"--http-port=65536\"},\n      true);\n\n  SCOPED_TRACE(\"// wait for exit\");\n  EXPECT_NO_THROW(EXPECT_NE(cmd.wait_for_exit(1000), 0)); // should be quick, and return failure (255)\n  SCOPED_TRACE(\"// checking stdout contains errormsg\");\n  EXPECT_THAT(cmd.get_full_output(), ::testing::HasSubstr(\"was '65536'\"));\n}\n\n\nint main(int argc, char *argv[]) {\n  g_origin_path = Path(argv[0]).dirname();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "tests/component/test_rest_mock_server.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifdef _WIN32\n// ensure windows.h doesn't expose min() nor max()\n#  define NOMINMAX\n#endif\n\n#include <thread>\n\n#include \"gmock/gmock.h\"\n#include \"router_component_test.h\"\n#include \"tcp_port_pool.h\"\n#include \"mysql_session.h\"\n#include \"rapidjson/document.h\"\n#include \"mysql/harness/logging/registry.h\"\n#include \"dim.h\"\n\n#include \"mysqlrouter/rest_client.h\"\n\nPath g_origin_path;\n\nstatic constexpr const char kMockServerGlobalsRestUri[] = \"/api/v1/mock_server/globals/\";\nstatic constexpr const char kMockServerConnectionsRestUri[] = \"/api/v1/mock_server/connections/\";\nstatic constexpr const char kMockServerInvalidRestUri[] = \"/api/v1/mock_server/global/\";\nstatic constexpr std::chrono::milliseconds kMockServerMaxRestEndpointWaitTime{1000};\nstatic constexpr std::chrono::milliseconds kMockServerMaxRestEndpointStepTime{50};\n\n// AddressSanitizer gets confused by the default, MemoryPoolAllocator\n// Solaris sparc also gets crashes\nusing JsonDocument = rapidjson::GenericDocument<rapidjson::UTF8<>,  rapidjson::CrtAllocator>;\nusing JsonValue = rapidjson::GenericValue<rapidjson::UTF8<>,  rapidjson::CrtAllocator>;\n\n\nclass RestMockServerTest : public RouterComponentTest, public ::testing::Test {\nprotected:\n  TcpPortPool port_pool_;\n\n  RestMockServerTest() {\n    set_origin(g_origin_path);\n\n    RouterComponentTest::SetUp();\n  }\n\n  /**\n   * wait until a REST endpoint returns !404.\n   *\n   * at mock startup the socket starts to listen before the REST endpoint gets\n   * registered. As long as it returns 404 Not Found we should wait and retry.\n   *\n   * @param rest_client initialized rest-client\n   * @param uri REST endpoint URI to check\n   * @param max_wait_time max time to wait for endpoint being ready\n   * @returns true once endpoint doesn't return 404 anymore, fails otherwise\n   */\n  bool wait_for_rest_endpoint_ready(RestClient &rest_client, const std::string &uri, std::chrono::milliseconds max_wait_time) const noexcept {\n    while (max_wait_time.count() > 0) {\n      auto req = rest_client.request_sync(HttpMethod::Get, uri);\n\n      if (req && req.get_response_code() != 0 && req.get_response_code() != 404) return true;\n\n      auto wait_time = std::min(kMockServerMaxRestEndpointStepTime, max_wait_time);\n      std::this_thread::sleep_for(wait_time);\n\n      max_wait_time -= wait_time;\n    }\n\n    return false;\n  }\n};\n\n/**\n * base class.\n *\n * starts mock-server with named script and waits for it to startup\n */\nclass RestMockServerScriptTest: public RestMockServerTest {\nprotected:\n  RestMockServerScriptTest(const std::string &stmt_file):\n    server_port_{port_pool_.get_next_available()},\n    http_port_{port_pool_.get_next_available()},\n    json_stmts_{get_data_dir().join(stmt_file).str()},\n    server_mock_{launch_mysql_server_mock(json_stmts_, server_port_, false, http_port_)}\n  {\n    SCOPED_TRACE(\"// start mock-server with http-port\");\n\n    const std::string http_hostname { \"127.0.0.1\" };\n\n    EXPECT_TRUE(wait_for_port_ready(server_port_, 1000)) << server_mock_.get_full_output();\n  }\n\n  const unsigned server_port_;\n  const unsigned http_port_;\n  const std::string json_stmts_;\n\n  RouterComponentTest::CommandHandle server_mock_;\n};\n\n\nclass RestMockServerScriptsWorkTest:\n  public RestMockServerTest,\n  public ::testing::WithParamInterface<std::tuple<const char*>> {\n};\n\nclass RestMockServerScriptsThrowsTest:\n  public RestMockServerTest,\n  public ::testing::WithParamInterface<std::tuple<const char*, const char*>> {\n};\n\nclass RestMockServerConnectThrowsTest:\n  public RestMockServerTest,\n  public ::testing::WithParamInterface<std::tuple<const char*, const char*>> {\n};\n\n\nclass RestMockServerRestServerMockTest: public RestMockServerScriptTest {\npublic:\n  RestMockServerRestServerMockTest():\n    RestMockServerScriptTest(\"rest_server_mock.js\")\n  {}\n};\n\n\n/**\n * test mock-server loaded the REST bridge.\n *\n * - start the mock-server\n * - make a client connect to the mock-server\n *\n * verifies:\n *\n * - WL12118\n *   - TS_1-6\n */\nTEST_F(RestMockServerRestServerMockTest, get_globals_empty) {\n  std::string http_hostname = \"127.0.0.1\";\n  std::string http_uri = kMockServerGlobalsRestUri;\n\n  IOContext io_ctx;\n  RestClient rest_client(io_ctx, http_hostname, http_port_);\n\n  SCOPED_TRACE(\"// wait for REST endpoint\");\n  ASSERT_TRUE(wait_for_rest_endpoint_ready(rest_client, http_uri, kMockServerMaxRestEndpointWaitTime)) << server_mock_.get_full_output();\n\n  SCOPED_TRACE(\"// make a http connections\");\n  auto req = rest_client.\n    request_sync(HttpMethod::Get, http_uri);\n\n  SCOPED_TRACE(\"// checking HTTP response\");\n  ASSERT_TRUE(req)\n      << \"HTTP Request to \"\n      << http_hostname << \":\" << std::to_string(http_port_)\n      << \" failed (early): \"\n      << req.error_msg()\n      << std::endl\n      << server_mock_.get_full_output()\n      << std::endl;\n\n  ASSERT_GT(req.get_response_code(), 0u)\n      << \"HTTP Request to \"\n      << http_hostname << \":\" << std::to_string(http_port_)\n      << \" failed: \"\n      << req.error_msg()\n      << std::endl\n      << server_mock_.get_full_output()\n      << std::endl;\n\n  EXPECT_EQ(req.get_response_code(), 200u);\n  EXPECT_THAT(req.get_input_headers().get(\"Content-Type\"), ::testing::StrEq(\"application/json\"));\n\n  auto resp_body = req.get_input_buffer();\n  EXPECT_GT(resp_body.length(), 0u);\n  auto resp_body_content = resp_body.pop_front(resp_body.length());\n\n  // parse json\n\n  std::string json_payload(resp_body_content.begin(), resp_body_content.end());\n\n  JsonDocument json_doc;\n  json_doc.Parse(json_payload.c_str());\n\n  EXPECT_TRUE(!json_doc.HasParseError()) << json_payload;\n}\n\n/**\n * test mock-server's REST bridge denies unknown URLs.\n *\n * - start the mock-server\n * - make a client connect to the mock-server\n *\n * verifies:\n *\n * - WL12118\n *   - TS_1-7\n */\nTEST_F(RestMockServerRestServerMockTest, unknown_url_fails) {\n  std::string http_hostname = \"127.0.0.1\";\n  std::string http_uri = kMockServerInvalidRestUri;\n\n  IOContext io_ctx;\n  RestClient rest_client(io_ctx, http_hostname, http_port_);\n\n  SCOPED_TRACE(\"// wait for HTTP server listening\");\n  ASSERT_TRUE(wait_for_port_ready(http_port_, 1000)) << server_mock_.get_full_output();\n\n  SCOPED_TRACE(\"// make a http connections\");\n  auto req = rest_client.\n    request_sync(HttpMethod::Get, http_uri);\n\n  SCOPED_TRACE(\"// checking HTTP response\");\n  ASSERT_TRUE(req)\n      << \"HTTP Request to \"\n      << http_hostname << \":\" << std::to_string(http_port_)\n      << \" failed (early): \"\n      << req.error_msg()\n      << std::endl;\n\n  ASSERT_GT(req.get_response_code(), 0u)\n      << \"HTTP Request to \"\n      << http_hostname << \":\" << std::to_string(http_port_)\n      << \" failed: \"\n      << req.error_msg()\n      << std::endl;\n\n  EXPECT_EQ(req.get_response_code(), 404u);\n  EXPECT_THAT(req.get_input_headers().get(\"Content-Type\"), ::testing::StrEq(\"text/html\"));\n\n  auto resp_body = req.get_input_buffer();\n  EXPECT_GT(resp_body.length(), 0u);\n  auto resp_body_content = resp_body.pop_front(resp_body.length());\n}\n\n/**\n * test storing globals in mock_server via REST bridge.\n *\n * - start the mock-server\n * - make a client connect to the mock-server\n */\nTEST_F(RestMockServerRestServerMockTest, put_globals_no_json) {\n  std::string http_hostname = \"127.0.0.1\";\n  std::string http_uri = kMockServerGlobalsRestUri;\n\n  IOContext io_ctx;\n  RestClient rest_client(io_ctx, http_hostname, http_port_);\n\n  SCOPED_TRACE(\"// wait for REST endpoint\");\n  ASSERT_TRUE(wait_for_rest_endpoint_ready(rest_client, http_uri, kMockServerMaxRestEndpointWaitTime)) << server_mock_.get_full_output();\n\n  SCOPED_TRACE(\"// make a http connections\");\n  auto req = rest_client.\n    request_sync(HttpMethod::Put, http_uri);\n\n  SCOPED_TRACE(\"// checking HTTP response\");\n  ASSERT_TRUE(req)\n      << \"HTTP Request to \"\n      << http_hostname << \":\" << std::to_string(http_port_)\n      << \" failed (early): \"\n      << req.error_msg()\n      << std::endl\n      << server_mock_.get_full_output()\n      << std::endl;\n\n  ASSERT_GT(req.get_response_code(), 0u)\n      << \"HTTP Request to \"\n      << http_hostname << \":\" << std::to_string(http_port_)\n      << \" failed: \"\n      << req.error_msg()\n      << std::endl\n      << server_mock_.get_full_output()\n      << std::endl;\n\n  EXPECT_EQ(req.get_response_code(), 415u);\n\n  auto resp_body = req.get_input_buffer();\n  EXPECT_EQ(resp_body.length(), 0u);\n}\n\n/**\n * ensure PUT against / fails.\n *\n * verifies:\n *\n *   - WL12118\n *     - TS_1-10\n */\nTEST_F(RestMockServerRestServerMockTest, put_root_fails) {\n  const std::string http_hostname { \"127.0.0.1\" };\n\n  IOContext io_ctx;\n  RestClient rest_client(io_ctx, http_hostname, http_port_);\n\n  SCOPED_TRACE(\"// wait for REST endpoint\");\n  ASSERT_TRUE(wait_for_rest_endpoint_ready(rest_client, kMockServerGlobalsRestUri, kMockServerMaxRestEndpointWaitTime)) << server_mock_.get_full_output();\n\n  SCOPED_TRACE(\"// make a http connections\");\n  auto req = rest_client.\n    request_sync(HttpMethod::Put, \"/\", \"{}\");\n\n  SCOPED_TRACE(\"// checking HTTP response\");\n  ASSERT_TRUE(req)\n      << \"HTTP Request to \"\n      << http_hostname << \":\" << std::to_string(http_port_)\n      << \" failed (early): \"\n      << req.error_msg()\n      << std::endl\n      << server_mock_.get_full_output()\n      << std::endl;\n\n  ASSERT_GT(req.get_response_code(), 0u)\n      << \"HTTP Request to \"\n      << http_hostname << \":\" << std::to_string(http_port_)\n      << \" failed: \"\n      << req.error_msg()\n      << std::endl\n      << server_mock_.get_full_output()\n      << std::endl;\n\n  EXPECT_EQ(req.get_response_code(), 404u);\n\n  auto resp_body = req.get_input_buffer();\n  EXPECT_NE(resp_body.length(), 0u);\n}\n\nclass RestMockServerRequireTest: public RestMockServerScriptTest {\nprotected:\n  RestMockServerRequireTest():\n    RestMockServerScriptTest(\"js_test_require.js\")\n  {}\n};\n\nclass RestMockServerRequirePTest:\n  public RestMockServerRequireTest,\n  public ::testing::WithParamInterface<std::tuple<const char*, const char*>> {\n};\n\n\n/**\n * ensure require() honours load-order.\n *\n * verifies:\n *\n *   - WL11861\n *     - TS_1-8\n */\nTEST_P(RestMockServerRequirePTest, require) {\n  // mysql query\n  mysqlrouter::MySQLSession client;\n\n  SCOPED_TRACE(\"// connecting via mysql protocol\");\n  ASSERT_NO_THROW(\n      client.connect(\"127.0.0.1\", server_port_, \"username\", \"password\", \"\", \"\")) << server_mock_.get_full_output();\n\n  EXPECT_NO_THROW({\n    std::unique_ptr<mysqlrouter::MySQLSession::ResultRow> result{\n      client.query_one(std::get<0>(GetParam()))};\n    ASSERT_NE(nullptr, result.get());\n    ASSERT_EQ(1u, result->size());\n    EXPECT_EQ(std::string((*result)[0]), std::get<1>(GetParam()));\n    });\n}\n\nINSTANTIATE_TEST_CASE_P(\n    js_require_paths,\n    RestMockServerRequirePTest,\n    ::testing::Values(\n      std::make_tuple(\"direct\", \"direct\"),\n      std::make_tuple(\"dir-with-indexjs\", \"dir-with-index.js\"),\n      std::make_tuple(\"dir-with-packagejson\", \"dir-with-package.json\")\n      ));\n\n\n/**\n * ensure require() only loads and evalutes modules once.\n *\n * js_test_require.js requires the same module twice which exposes\n * a counter function.\n *\n * calling the counter via the first module, and via the 2nd module\n * should both increment the same counter if a module is only\n * loaded once.\n *\n * verifies:\n *\n *   - WL11861\n *     - TS_1-7\n */\nTEST_F(RestMockServerRequireTest, no_reload) {\n  SCOPED_TRACE(\"// connecting via mysql protocol\");\n\n  // mysql query\n  mysqlrouter::MySQLSession client;\n\n  ASSERT_NO_THROW(\n      client.connect(\"127.0.0.1\", server_port_, \"username\", \"password\", \"\", \"\")) << server_mock_.get_full_output();\n\n  SCOPED_TRACE(\"// via first module\");\n  EXPECT_NO_THROW({\n    std::unique_ptr<mysqlrouter::MySQLSession::ResultRow> result{\n      client.query_one(\"no-reload-0\")};\n    ASSERT_NE(nullptr, result.get());\n    ASSERT_EQ(1u, result->size());\n    EXPECT_EQ(std::string((*result)[0]), \"0\");\n    });\n\n  SCOPED_TRACE(\"// via 2nd module\");\n  EXPECT_NO_THROW({\n    std::unique_ptr<mysqlrouter::MySQLSession::ResultRow> result{\n      client.query_one(\"no-reload-1\")};\n    ASSERT_NE(nullptr, result.get());\n    ASSERT_EQ(1u, result->size());\n    EXPECT_EQ(std::string((*result)[0]), \"1\");\n    });\n}\n\nclass RestMockServerNestingTest: public RestMockServerScriptTest {\nprotected:\n  RestMockServerNestingTest():\n    RestMockServerScriptTest(\"js_test_nesting.js\")\n  {}\n};\n\n\n/**\n * ensure require() can be deeply nested.\n *\n *\n *\n * verifies:\n *\n *   - WL11861\n *     - TS_1-10\n */\nTEST_F(RestMockServerNestingTest, nesting) {\n  SCOPED_TRACE(\"// connecting via mysql protocol\");\n\n  // mysql query\n  mysqlrouter::MySQLSession client;\n\n  ASSERT_THROW_LIKE(\n      client.connect(\"127.0.0.1\", server_port_, \"username\", \"password\", \"\", \"\"),\n      mysqlrouter::MySQLSession::Error,\n      \"test-require-nesting-5.js:5: SyntaxError: parse error\");\n}\n\n\n\nclass RestMockServerMethodsTest:\n  public RestMockServerRestServerMockTest,\n  public ::testing::WithParamInterface<std::tuple<unsigned int, std::string, unsigned int>> {\n};\n\n\n/**\n * ensure OPTIONS, HEAD and others work.\n *\n * verifies:\n *\n *   - WL12118\n *     - TS_1-11\n */\nTEST_P(RestMockServerMethodsTest, methods_avail) {\n  const std::string http_hostname { \"127.0.0.1\" };\n\n  IOContext io_ctx;\n  RestClient rest_client(io_ctx, http_hostname, http_port_);\n\n  SCOPED_TRACE(\"// wait for REST endpoint\");\n  ASSERT_TRUE(wait_for_rest_endpoint_ready(rest_client, kMockServerGlobalsRestUri, kMockServerMaxRestEndpointWaitTime)) << server_mock_.get_full_output();\n\n  SCOPED_TRACE(\"// make a http connections\");\n  auto req = rest_client.\n    request_sync(std::get<0>(GetParam()), std::get<1>(GetParam()));\n\n  SCOPED_TRACE(\"// checking HTTP response\");\n  ASSERT_TRUE(req)\n      << \"HTTP Request to \"\n      << http_hostname << \":\" << std::to_string(http_port_)\n      << \" failed (early): \"\n      << req.error_msg()\n      << std::endl\n      << server_mock_.get_full_output()\n      << std::endl;\n\n  ASSERT_GT(req.get_response_code(), 0u)\n      << \"HTTP Request to \"\n      << http_hostname << \":\" << std::to_string(http_port_)\n      << \" failed: \"\n      << req.error_msg()\n      << std::endl\n      << server_mock_.get_full_output()\n      << std::endl;\n\n  EXPECT_EQ(std::get<2>(GetParam()), req.get_response_code());\n}\n\nINSTANTIATE_TEST_CASE_P(\n    api__v1__mock_server__globals,\n    RestMockServerMethodsTest,\n    ::testing::Values(\n      std::make_tuple(HttpMethod::Get, kMockServerGlobalsRestUri, HttpStatusCode::Ok),\n      std::make_tuple(HttpMethod::Put, kMockServerGlobalsRestUri, HttpStatusCode::UnsupportedMediaType),\n      std::make_tuple(HttpMethod::Delete, kMockServerGlobalsRestUri, HttpStatusCode::MethodNotAllowed),\n      std::make_tuple(HttpMethod::Trace, kMockServerGlobalsRestUri, HttpStatusCode::NotImplemented),\n      std::make_tuple(HttpMethod::Options, kMockServerGlobalsRestUri, HttpStatusCode::NotImplemented),\n      std::make_tuple(HttpMethod::Connect, kMockServerGlobalsRestUri, HttpStatusCode::NotImplemented),\n      std::make_tuple(HttpMethod::Head, kMockServerGlobalsRestUri, HttpStatusCode::MethodNotAllowed)\n      ));\n\nINSTANTIATE_TEST_CASE_P(\n    api__v1__mock_server__connections,\n    RestMockServerMethodsTest,\n    ::testing::Values(\n      std::make_tuple(HttpMethod::Get, kMockServerConnectionsRestUri, HttpStatusCode::MethodNotAllowed),\n      std::make_tuple(HttpMethod::Put, kMockServerConnectionsRestUri, HttpStatusCode::MethodNotAllowed),\n      std::make_tuple(HttpMethod::Delete, kMockServerConnectionsRestUri, HttpStatusCode::Ok),\n      std::make_tuple(HttpMethod::Trace, kMockServerConnectionsRestUri, HttpStatusCode::NotImplemented),\n      std::make_tuple(HttpMethod::Options, kMockServerConnectionsRestUri, HttpStatusCode::NotImplemented),\n      std::make_tuple(HttpMethod::Connect, kMockServerConnectionsRestUri, HttpStatusCode::NotImplemented),\n      std::make_tuple(HttpMethod::Head, kMockServerConnectionsRestUri, HttpStatusCode::MethodNotAllowed)\n      ));\n\n\n/**\n * test storing globals in mock_server via REST bridge.\n *\n * - start the mock-server\n * - make a client connect to the mock-server\n */\nTEST_F(RestMockServerRestServerMockTest, put_globals_ok) {\n  SCOPED_TRACE(\"// start mock-server with http-port\");\n\n  std::string http_hostname = \"127.0.0.1\";\n  std::string http_uri = kMockServerGlobalsRestUri;\n\n  IOContext io_ctx;\n  RestClient rest_client(io_ctx, http_hostname, http_port_);\n\n  SCOPED_TRACE(\"// wait for REST endpoint\");\n  ASSERT_TRUE(wait_for_rest_endpoint_ready(rest_client, http_uri, kMockServerMaxRestEndpointWaitTime)) << server_mock_.get_full_output();\n\n  SCOPED_TRACE(\"// make a http connections\");\n  auto req = rest_client.\n    request_sync(HttpMethod::Put, http_uri, \"{}\");\n\n  SCOPED_TRACE(\"// checking HTTP response\");\n  ASSERT_TRUE(req)\n      << \"HTTP Request to \"\n      << http_hostname << \":\" << std::to_string(http_port_)\n      << \" failed (early): \"\n      << req.error_msg()\n      << std::endl\n      << server_mock_.get_full_output()\n      << std::endl;\n\n  ASSERT_GT(req.get_response_code(), 0u)\n      << \"HTTP Request to \"\n      << http_hostname << \":\" << std::to_string(http_port_)\n      << \" failed: \"\n      << req.error_msg()\n      << std::endl\n      << server_mock_.get_full_output()\n      << std::endl;\n\n  EXPECT_EQ(req.get_response_code(), 204u);\n\n  auto resp_body = req.get_input_buffer();\n  EXPECT_EQ(resp_body.length(), 0u);\n}\n\nclass RestMockServerRequestTest:\n  public RestMockServerRestServerMockTest,\n  public ::testing::WithParamInterface<std::tuple<int, const char *, const char *, unsigned int>> {\n};\n\n/**\n * ensure valid and invalid JSON results in the correct behaviour.\n *\n * verifies:\n *\n * - WL12118\n *   - TS_1-8\n */\nTEST_P(RestMockServerRequestTest, request) {\n  SCOPED_TRACE(\"// start mock-server with http-port\");\n\n  std::string http_hostname = \"127.0.0.1\";\n  std::string http_uri = kMockServerGlobalsRestUri;\n\n  IOContext io_ctx;\n  RestClient rest_client(io_ctx, http_hostname, http_port_);\n\n  SCOPED_TRACE(\"// wait for REST endpoint\");\n  ASSERT_TRUE(wait_for_rest_endpoint_ready(rest_client, http_uri, kMockServerMaxRestEndpointWaitTime)) << server_mock_.get_full_output();\n\n  SCOPED_TRACE(\"// make a http connections\");\n  auto req = rest_client.\n    request_sync(std::get<0>(GetParam()), std::get<1>(GetParam()), std::get<2>(GetParam()));\n\n  SCOPED_TRACE(\"// checking HTTP response\");\n  ASSERT_TRUE(req)\n      << \"HTTP Request to \"\n      << http_hostname << \":\" << std::to_string(http_port_)\n      << \" failed (early): \"\n      << req.error_msg()\n      << std::endl\n      << server_mock_.get_full_output()\n      << std::endl;\n\n  ASSERT_GT(req.get_response_code(), 0u)\n      << \"HTTP Request to \"\n      << http_hostname << \":\" << std::to_string(http_port_)\n      << \" failed: \"\n      << req.error_msg()\n      << std::endl\n      << server_mock_.get_full_output()\n      << std::endl;\n\n  EXPECT_EQ(req.get_response_code(), std::get<3>(GetParam()));\n\n  // if we executed a PUT against globals which was not meant to succeed,\n  // check the globals are unchanged.\n  if (std::get<0>(GetParam()) == HttpMethod::Put &&\n      std::get<1>(GetParam()) == std::string(kMockServerGlobalsRestUri) &&\n      std::get<3>(GetParam()) != HttpStatusCode::NoContent) {\n    auto get_req = rest_client.request_sync(HttpMethod::Get, http_uri);\n    SCOPED_TRACE(\"// checking GET response\");\n    ASSERT_TRUE(get_req)\n        << \"HTTP Request to \"\n        << http_hostname << \":\" << std::to_string(http_port_)\n        << \" failed (early): \"\n        << get_req.error_msg()\n        << std::endl\n        << server_mock_.get_full_output()\n        << std::endl\n        ;\n\n    ASSERT_GT(get_req.get_response_code(), 0u)\n        << \"HTTP Request to \"\n        << http_hostname << \":\" << std::to_string(http_port_)\n        << \" failed: \"\n        << get_req.error_msg()\n        << std::endl\n        << server_mock_.get_full_output()\n        << std::endl;\n\n    EXPECT_EQ(get_req.get_response_code(), 200u);\n    EXPECT_THAT(get_req.get_input_headers().get(\"Content-Type\"), ::testing::StrEq(\"application/json\"));\n\n    auto get_resp_body = get_req.get_input_buffer();\n    EXPECT_GT(get_resp_body.length(), 0u);\n    auto get_resp_body_content = get_resp_body.pop_front(get_resp_body.length());\n\n    // parse json\n\n    std::string json_payload(get_resp_body_content.begin(), get_resp_body_content.end());\n\n    JsonDocument json_doc;\n    json_doc.Parse(json_payload.c_str());\n\n    EXPECT_TRUE(!json_doc.HasParseError());\n    EXPECT_THAT(json_payload, ::testing::StrEq(\"{}\"));\n  }\n}\n\nINSTANTIATE_TEST_CASE_P(\n    api__v1__mock_server__globals,\n    RestMockServerRequestTest,\n    ::testing::Values(\n      // parse error\n      std::make_tuple(HttpMethod::Put, kMockServerGlobalsRestUri, \"[\", HttpStatusCode::UnprocessableEntity),\n\n      // not an object\n      std::make_tuple(HttpMethod::Put, kMockServerGlobalsRestUri, \"[]\", HttpStatusCode::UnprocessableEntity),\n\n      // parse-error\n      std::make_tuple(HttpMethod::Put, kMockServerGlobalsRestUri, \"{1}\", HttpStatusCode::UnprocessableEntity),\n\n      // not-an-object\n      std::make_tuple(HttpMethod::Put, kMockServerGlobalsRestUri, \"1\", HttpStatusCode::UnprocessableEntity)\n      ));\n\n\n/**\n * test storing globals in mock_server via REST bridge.\n *\n * - start the mock-server\n * - make a client connect to the mock-server\n *\n * verifies:\n *\n * - WL12118\n *   - TS_1-6\n *   - TS_1-9\n */\nTEST_F(RestMockServerRestServerMockTest, put_globals_and_read_back) {\n  SCOPED_TRACE(\"// start mock-server with http-port\");\n\n  std::string http_hostname = \"127.0.0.1\";\n  std::string http_uri = kMockServerGlobalsRestUri;\n\n  SCOPED_TRACE(\"// make a http connections\");\n  IOContext io_ctx;\n  RestClient rest_client(io_ctx, http_hostname, http_port_);\n\n  SCOPED_TRACE(\"// wait for REST endpoint\");\n  ASSERT_TRUE(wait_for_rest_endpoint_ready(rest_client, http_uri, kMockServerMaxRestEndpointWaitTime)) << server_mock_.get_full_output();\n\n  auto put_req = rest_client.request_sync(HttpMethod::Put, http_uri, \"{\\\"key\\\": [ [1, 2, 3 ] ]}\");\n\n  SCOPED_TRACE(\"// checking PUT response\");\n  ASSERT_TRUE(put_req)\n      << \"HTTP Request to \"\n      << http_hostname << \":\" << std::to_string(http_port_)\n      << \" failed (early): \"\n      << put_req.error_msg()\n      << std::endl\n      << server_mock_.get_full_output()\n      << std::endl;\n\n  ASSERT_GT(put_req.get_response_code(), 0u)\n      << \"HTTP Request to \"\n      << http_hostname << \":\" << std::to_string(http_port_)\n      << \" failed: \"\n      << put_req.error_msg()\n      << std::endl\n      << server_mock_.get_full_output()\n      << std::endl;\n\n  EXPECT_EQ(put_req.get_response_code(), 204u);\n\n  auto put_resp_body = put_req.get_input_buffer();\n  EXPECT_EQ(put_resp_body.length(), 0u);\n\n  // GET request\n\n  auto get_req = rest_client.request_sync(HttpMethod::Get, http_uri);\n  SCOPED_TRACE(\"// checking GET response\");\n  ASSERT_TRUE(get_req)\n      << \"HTTP Request to \"\n      << http_hostname << \":\" << std::to_string(http_port_)\n      << \" failed (early): \"\n      << get_req.error_msg()\n      << std::endl\n      << server_mock_.get_full_output()\n      << std::endl\n      ;\n\n  ASSERT_GT(get_req.get_response_code(), 0u)\n      << \"HTTP Request to \"\n      << http_hostname << \":\" << std::to_string(http_port_)\n      << \" failed: \"\n      << get_req.error_msg()\n      << std::endl\n      << server_mock_.get_full_output()\n      << std::endl;\n\n  EXPECT_EQ(get_req.get_response_code(), 200u);\n  EXPECT_THAT(get_req.get_input_headers().get(\"Content-Type\"), ::testing::StrEq(\"application/json\"));\n\n  auto get_resp_body = get_req.get_input_buffer();\n  EXPECT_GT(get_resp_body.length(), 0u);\n  auto get_resp_body_content = get_resp_body.pop_front(get_resp_body.length());\n\n  // parse json\n\n  std::string json_payload(get_resp_body_content.begin(), get_resp_body_content.end());\n\n  JsonDocument json_doc;\n  json_doc.Parse(json_payload.c_str());\n\n  EXPECT_TRUE(!json_doc.HasParseError());\n  EXPECT_THAT(json_payload, ::testing::StrEq(\"{\\\"key\\\":[[1,2,3]]}\"));\n}\n\n/**\n * test DELETE connections.\n *\n * - start the mock-server\n * - make a client connect to the mock-server\n *\n * verifies:\n *\n * - WL12118\n *   - TS_1-2\n */\nTEST_F(RestMockServerRestServerMockTest, delete_all_connections) {\n  SCOPED_TRACE(\"// start mock-server with http-port\");\n\n  std::string http_hostname = \"127.0.0.1\";\n  std::string http_uri = kMockServerConnectionsRestUri;\n\n  IOContext io_ctx;\n  RestClient rest_client(io_ctx, http_hostname, http_port_);\n\n  SCOPED_TRACE(\"// wait for REST endpoint\");\n  ASSERT_TRUE(wait_for_rest_endpoint_ready(rest_client, http_uri, kMockServerMaxRestEndpointWaitTime)) << server_mock_.get_full_output();\n\n  // mysql query\n  mysqlrouter::MySQLSession client;\n\n  SCOPED_TRACE(\"// connecting via mysql protocol\");\n  ASSERT_NO_THROW(\n      client.connect(\"127.0.0.1\", server_port_, \"username\", \"password\", \"\", \"\")) << server_mock_.get_full_output();\n\n\n  SCOPED_TRACE(\"// check connection works\");\n  std::unique_ptr<mysqlrouter::MySQLSession::ResultRow> result{\n    client.query_one(\"select @@port\")};\n  ASSERT_NE(nullptr, result.get());\n  ASSERT_EQ(1u, result->size());\n  EXPECT_EQ(std::to_string(server_port_), std::string((*result)[0]));\n\n  SCOPED_TRACE(\"// make a http connections\");\n  auto req = rest_client.\n    request_sync(HttpMethod::Delete, http_uri, \"{}\");\n\n  SCOPED_TRACE(\"// checking HTTP response\");\n  ASSERT_TRUE(req)\n      << \"HTTP Request to \"\n      << http_hostname << \":\" << std::to_string(http_port_)\n      << \" failed (early): \"\n      << req.error_msg()\n      << std::endl\n      << server_mock_.get_full_output()\n      << std::endl;\n\n  ASSERT_GT(req.get_response_code(), 0u)\n      << \"HTTP Request to \"\n      << http_hostname << \":\" << std::to_string(http_port_)\n      << \" failed: \"\n      << req.error_msg()\n      << std::endl\n      << server_mock_.get_full_output()\n      << std::endl;\n\n  EXPECT_EQ(req.get_response_code(), 200u);\n\n  auto resp_body = req.get_input_buffer();\n  EXPECT_EQ(resp_body.length(), 0u);\n\n  SCOPED_TRACE(\"// check connection is killed\");\n  EXPECT_THROW_LIKE(result.reset(client.query_one(\"select @@port\")), mysqlrouter::MySQLSession::Error,\n      \"Lost connection to MySQL server during query\");\n}\n\n\n\n/**\n * ensure @@port reported by mock is real port.\n *\n * - start the mock-server\n * - make a client connect to the mock-server\n */\nTEST_F(RestMockServerRestServerMockTest, select_port) {\n  std::string http_hostname = \"127.0.0.1\";\n  std::string http_uri = kMockServerGlobalsRestUri;\n\n  // mysql query\n  mysqlrouter::MySQLSession client;\n\n  SCOPED_TRACE(\"// connecting via mysql protocol\");\n  ASSERT_NO_THROW(\n      client.connect(\"127.0.0.1\", server_port_, \"username\", \"password\", \"\", \"\")) << server_mock_.get_full_output();\n\n  EXPECT_NO_THROW({\n    std::unique_ptr<mysqlrouter::MySQLSession::ResultRow> result{\n      client.query_one(\"select @@port\")};\n    ASSERT_NE(nullptr, result.get());\n    ASSERT_EQ(1u, result->size());\n    EXPECT_EQ(std::to_string(server_port_), std::string((*result)[0]));\n    });\n}\n\n/**\n * ensure connect returns error.\n *\n * - start the mock-server\n * - make a client connect to the mock-server\n */\nTEST_P(RestMockServerConnectThrowsTest, js_test_stmts_is_string) {\n  SCOPED_TRACE(\"// start mock-server with http-port\");\n\n  const unsigned server_port = port_pool_.get_next_available();\n  const unsigned http_port = port_pool_.get_next_available();\n  const std::string json_stmts = get_data_dir().join(std::get<0>(GetParam())).str();\n  auto server_mock = launch_mysql_server_mock(json_stmts, server_port, false, http_port);\n\n  std::string http_hostname = \"127.0.0.1\";\n  std::string http_uri = kMockServerGlobalsRestUri;\n\n  EXPECT_TRUE(wait_for_port_ready(server_port, 1000)) << server_mock.get_full_output();\n\n  mysqlrouter::MySQLSession client;\n\n  SCOPED_TRACE(\"// connecting via mysql protocol\");\n  ASSERT_THROW_LIKE(\n      client.connect(\"127.0.0.1\", server_port, \"username\", \"password\", \"\", \"\"), mysqlrouter::MySQLSession::Error,\n      std::get<1>(GetParam()));\n}\n\nINSTANTIATE_TEST_CASE_P(\n    ScriptsFails,\n    RestMockServerConnectThrowsTest,\n    ::testing::Values(\n      std::make_tuple(\"js_test_parse_error.js\", \"parse error\"), // WL11861 TS-1_2\n      std::make_tuple(\"js_test_stmts_is_string.js\", \"expected 'stmts' to be\"), // WL11861 TS-1_4\n      std::make_tuple(\"js_test_empty_file.js\", \"expected statement handler to return an object, got primitive, undefined\") // WL11861 TS-1_4\n      ));\n\n\n/**\n * ensure int fields in 'columns' can't be negative.\n *\n * - start the mock-server\n * - make a client connect to the mock-server\n * - run a query which triggers the server-side exception\n */\nTEST_P(RestMockServerScriptsThrowsTest, scripts_throws) {\n  SCOPED_TRACE(\"// start mock-server with http-port\");\n\n  const unsigned server_port = port_pool_.get_next_available();\n  const unsigned http_port = port_pool_.get_next_available();\n  const std::string json_stmts = get_data_dir().join(std::get<0>(GetParam())).str();\n  auto server_mock = launch_mysql_server_mock(json_stmts, server_port, false, http_port);\n\n  std::string http_hostname = \"127.0.0.1\";\n  std::string http_uri = kMockServerGlobalsRestUri;\n\n  EXPECT_TRUE(wait_for_port_ready(server_port, 1000)) << server_mock.get_full_output();\n\n  mysqlrouter::MySQLSession client;\n\n  SCOPED_TRACE(\"// connecting via mysql protocol\");\n  ASSERT_NO_THROW(\n      client.connect(\"127.0.0.1\", server_port, \"username\", \"password\", \"\", \"\"));\n\n  SCOPED_TRACE(\"// select @@port\");\n  ASSERT_THROW_LIKE(client.query_one(\"select @@port\"), mysqlrouter::MySQLSession::Error,\n      std::get<1>(GetParam()));\n}\n\nINSTANTIATE_TEST_CASE_P(\n    ScriptsFails,\n    RestMockServerScriptsThrowsTest,\n    ::testing::Values(\n      std::make_tuple(\"js_test_stmts_result_has_negative_int.js\", \"value out-of-range for field \\\"decimals\\\"\"),\n      std::make_tuple(\"js_test_stmts_result_has_infinity.js\", \"value out-of-range for field \\\"decimals\\\"\"), // WL11861 TS-1_11\n      std::make_tuple(\"js_test_stmts_result_has_repeat.js\", \"repeat is not supported\"), // WL11861 TS-1_5\n      std::make_tuple(\"js_test_stmts_is_empty.js\", \"executing statement failed: Unsupported command in handle_statement()\")\n      ));\n\n\n\n/**\n * ensure script works.\n *\n * - start the mock-server\n * - make a client connect to the mock-server\n */\nTEST_P(RestMockServerScriptsWorkTest, scripts_work) {\n  SCOPED_TRACE(\"// start mock-server with http-port\");\n\n  const unsigned server_port = port_pool_.get_next_available();\n  const unsigned http_port = port_pool_.get_next_available();\n  const std::string json_stmts = get_data_dir().join(std::get<0>(GetParam())).str();\n  auto server_mock = launch_mysql_server_mock(json_stmts, server_port, false, http_port);\n\n  std::string http_hostname = \"127.0.0.1\";\n  std::string http_uri = kMockServerGlobalsRestUri;\n\n  EXPECT_TRUE(wait_for_port_ready(server_port, 1000)) << server_mock.get_full_output();\n\n  mysqlrouter::MySQLSession client;\n\n  SCOPED_TRACE(\"// connecting via mysql protocol\");\n  ASSERT_NO_THROW(\n      client.connect(\"127.0.0.1\", server_port, \"username\", \"password\", \"\", \"\"));\n\n  SCOPED_TRACE(\"// select @@port\");\n  ASSERT_NO_THROW(client.execute(\"select @@port\"));\n}\n\nINSTANTIATE_TEST_CASE_P(\n    ScriptsWork,\n    RestMockServerScriptsWorkTest,\n    ::testing::Values(\n      std::make_tuple(\"metadata_3_secondaries.js\"),\n      std::make_tuple(\"simple-client.js\"),\n      std::make_tuple(\"js_test_stmts_is_array.js\"),\n      std::make_tuple(\"js_test_stmts_is_coroutine.js\"),\n      std::make_tuple(\"js_test_stmts_is_function.js\")\n      ));\n\n\nstatic void init_DIM() {\n  mysql_harness::DIM& dim = mysql_harness::DIM::instance();\n\n  // logging facility\n  dim.set_LoggingRegistry(\n    []() {\n      static mysql_harness::logging::Registry registry;\n      return &registry;\n    },\n    [](mysql_harness::logging::Registry*){}  // don't delete our static!\n  );\n  mysql_harness::logging::Registry& registry = dim.get_LoggingRegistry();\n\n  mysql_harness::logging::g_HACK_default_log_level = \"warning\";\n  mysql_harness::Config config;\n  mysql_harness::logging::init_loggers(registry, config,\n      {mysql_harness::logging::kMainLogger, \"sql\"},\n      mysql_harness::logging::kMainLogger);\n  mysql_harness::logging::create_main_logfile_handler(registry, \"\", \"\", true);\n\n  registry.set_ready();\n}\n\nint main(int argc, char *argv[]) {\n  init_windows_sockets();\n  init_DIM();\n  g_origin_path = Path(argv[0]).dirname();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "tests/component/test_routing.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"router_config.h\"  // defines HAVE_PRLIMIT\n#ifdef HAVE_PRLIMIT\n  #include <sys/resource.h> // prlimit()\n#endif\n#include \"gmock/gmock.h\"\n#include \"router_component_test.h\"\n#include \"tcp_port_pool.h\"\n#include \"router_test_helpers.h\"\n#include \"mysql_session.h\"\n\n#include <thread>\n#include <chrono>\n\nPath g_origin_path;\nusing mysqlrouter::MySQLSession;\n\nclass RouterRoutingTest : public RouterComponentTest, public ::testing::Test {\n protected:\n  virtual void SetUp() {\n    set_origin(g_origin_path);\n    RouterComponentTest::SetUp();\n  }\n\n  TcpPortPool port_pool_;\n};\n\nTEST_F(RouterRoutingTest, RoutingOk) {\n  const auto server_port = port_pool_.get_next_available();\n  const auto router_port = port_pool_.get_next_available();\n\n  // use the json file that adds additional rows to the metadata to increase the\n  // packet size to +10MB to verify routing of the big packets\n  const std::string json_stmts = get_data_dir().join(\"bootstrap_big_data.js\").str();\n  const std::string bootstrap_dir = get_tmp_dir();\n\n  // launch the server mock for bootstrapping\n  auto server_mock = launch_mysql_server_mock(json_stmts, server_port,\n                                              false /*expecting huge data, can't print on the console*/);\n\n  const std::string routing_section =\n                      \"[routing:basic]\\n\"\n                      \"bind_port = \" + std::to_string(router_port) + \"\\n\"\n                      \"mode = read-write\\n\"\n                      \"destinations = 127.0.0.1:\" + std::to_string(server_port) + \"\\n\";\n\n  std::string conf_file = create_config_file(routing_section);\n\n\n  // launch the router with simple static routing configuration\n  auto router_static = launch_router(\"-c \" +  conf_file);\n\n  // wait for both to begin accepting the connections\n  ASSERT_TRUE(wait_for_port_ready(server_port, 5000))\n    << server_mock.get_full_output();\n\n  ASSERT_TRUE(wait_for_port_ready(router_port, 5000))\n    << get_router_log_output();\n\n  // launch another router to do the bootstrap connecting to the mock server\n  // via first router instance\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(bootstrap_dir);});\n  auto router_bootstrapping = launch_router(\"--bootstrap=localhost:\" + std::to_string(router_port)\n                                            + \" --report-host dont.query.dns\"\n                                            + \" -d \" +  bootstrap_dir);\n\n  router_bootstrapping.register_response(\"Please enter MySQL password for root: \", \"fake-pass\\n\");\n\n  ASSERT_EQ(router_bootstrapping.wait_for_exit(), 0\n  ) << \"bootstrap output: \" << router_bootstrapping.get_full_output() << std::endl\n    << \"routing log: \"<< get_router_log_output() << std::endl\n    << \"server output: \"<< server_mock.get_full_output() << std::endl;\n\n  ASSERT_TRUE(router_bootstrapping.expect_output(\n    \"MySQL Router  has now been configured for the InnoDB cluster 'test'\")\n  ) << \"bootstrap output: \" << router_bootstrapping.get_full_output() << std::endl\n    << \"routing log: \"<< get_router_log_output() << std::endl\n    << \"server output: \"<< server_mock.get_full_output() << std::endl;\n}\n\nTEST_F(RouterRoutingTest, RoutingTooManyConnections) {\n  const auto server_port = port_pool_.get_next_available();\n  const auto router_port = port_pool_.get_next_available();\n\n  // doesn't really matter which file we use here, we are not going to do any queries\n  const std::string json_stmts = get_data_dir().join(\"bootstrap_big_data.js\").str();\n\n  // launch the server mock\n  auto server_mock = launch_mysql_server_mock(json_stmts, server_port, false);\n\n  // create a config with routing that has max_connections == 2\n  const std::string routing_section =\n                      \"[routing:basic]\\n\"\n                      \"bind_port = \" + std::to_string(router_port) + \"\\n\"\n                      \"mode = read-write\\n\"\n                      \"max_connections = 2\\n\"\n                      \"destinations = 127.0.0.1:\" + std::to_string(server_port) + \"\\n\";\n\n  std::string conf_file = create_config_file(routing_section);\n\n  // launch the router with the created configuration\n  auto router_static = launch_router(\"-c \" +  conf_file);\n\n  // wait for server and router to begin accepting the connections\n  ASSERT_TRUE(wait_for_port_ready(server_port, 5000)) << server_mock.get_full_output();\n  ASSERT_TRUE(wait_for_port_ready(router_port, 5000)) << get_router_log_output();\n\n  // try to create 3 connections, the third should fail\n  // because of the max_connections limit being exceeded\n  mysqlrouter::MySQLSession client1, client2, client3;\n  EXPECT_NO_THROW(client1.connect(\"127.0.0.1\", router_port, \"username\", \"password\", \"\", \"\"));\n  EXPECT_NO_THROW(client2.connect(\"127.0.0.1\", router_port, \"username\", \"password\", \"\", \"\"));\n  ASSERT_THROW_LIKE(\n    client3.connect(\"127.0.0.1\", router_port, \"username\", \"password\", \"\", \"\"),\n    std::runtime_error,\n    \"Too many connections to MySQL Router (1040)\"\n  );\n}\n\n// this test uses OS-specific methods to restrict thread creation\n#ifdef HAVE_PRLIMIT\nTEST_F(RouterRoutingTest, RoutingPluginCantSpawnMoreThreads) {\n  const auto server_port = port_pool_.get_next_available();\n  const auto router_port = port_pool_.get_next_available();\n\n  // doesn't really matter which file we use here, we are not going to do any queries\n  const std::string json_stmts = get_data_dir().join(\"bootstrap_big_data.js\").str();\n\n  // launch the server mock\n  auto server_mock = launch_mysql_server_mock(json_stmts, server_port, false);\n\n  // create a basic config\n  const std::string routing_section =\n                      \"[routing:basic]\\n\"\n                      \"bind_port = \" + std::to_string(router_port) + \"\\n\"\n                      \"mode = read-write\\n\"\n                      \"destinations = 127.0.0.1:\" + std::to_string(server_port) + \"\\n\";\n\n  std::string conf_file = create_config_file(routing_section);\n\n  // launch the router with the created configuration\n  auto router_static = launch_router(\"-c \" +  conf_file);\n\n  // wait for server and router to begin accepting the connections\n  ASSERT_TRUE(wait_for_port_ready(server_port, 5000)) << server_mock.get_full_output();\n  ASSERT_TRUE(wait_for_port_ready(router_port, 5000)) << get_router_log_output();\n\n  // don't allow router to create any more (client) threads\n  {\n    pid_t pid = router_static.get_pid();\n\n    // how many threads Router process is allowed to have. If this number is lower\n    // than current count, nothing will happen, but new ones will not be allowed\n    // to be created until count comes down below this limit.\n    // Thus 0 is a nice number to ensure nothing gets spawned anymore.\n    rlim_t max_threads = 0;\n\n    struct rlimit new_limit {\n      .rlim_cur = max_threads,\n      .rlim_max = max_threads\n    };\n    EXPECT_EQ(0, prlimit(pid, RLIMIT_NPROC, &new_limit, nullptr));\n  }\n\n  // try to create a new connection - it should fail because std::thread() in\n  // routing plugin will fail to spawn a new thread for this new connection\n  mysqlrouter::MySQLSession client1;\n  ASSERT_THROW_LIKE(\n    client1.connect(\"127.0.0.1\", router_port, \"username\", \"password\", \"\", \"\"),\n    std::runtime_error,\n    \"Router couldn't spawn a new thread to service new client connection (1040)\"\n  );\n}\n#endif // #ifndef _WIN32\n\n#ifndef _WIN32  // named sockets are not supported on Windows;\n                // on Unix, they're implemented using Unix sockets\nTEST_F(RouterRoutingTest, named_socket_has_right_permissions) {\n  /**\n   * @test Verify that unix socket has the required file permissions so that it\n   *       can be connected to by all users. According to man 7 unix, only r+w\n   *       permissions are required, but Server sets x as well, so we do the same.\n   */\n\n  // get config dir (we will also stuff our unix socket file there)\n  const std::string bootstrap_dir = get_tmp_dir();\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(bootstrap_dir);});\n\n  // launch Router with unix socket\n  const std::string socket_file = bootstrap_dir + \"/sockfile\";\n  const std::string routing_section =\n                      \"[routing:basic]\\n\"\n                      \"socket = \" + socket_file + \"\\n\"\n                      \"mode = read-write\\n\"\n                      \"destinations = 127.0.0.1:1234\\n\";  // port can be bogus\n  const std::string conf_file = create_config_file(routing_section);\n  auto router_static = launch_router(\"-c \" +  conf_file);\n\n  // loop until socket file appears and has correct permissions\n  auto wait_for_correct_perms = [&socket_file](int timeout_ms) {\n    const mode_t expected_mode = S_IFSOCK |\n                                 S_IRUSR | S_IWUSR | S_IXUSR |\n                                 S_IRGRP | S_IWGRP | S_IXGRP |\n                                 S_IROTH | S_IWOTH | S_IXOTH;\n    while (timeout_ms > 0) {\n      struct stat info;\n\n      memset(&info, 0, sizeof(info));\n      stat(socket_file.c_str(), &info); // silently ignore error when file doesn't exist yet\n\n      if (info.st_mode == expected_mode)\n        return true;\n\n      std::this_thread::sleep_for(std::chrono::milliseconds(10));\n      timeout_ms -= 10;\n    }\n\n    return false;\n  };\n\n  EXPECT_THAT(wait_for_correct_perms(5000), testing::Eq(true));\n}\n#endif\n\nTEST_F(RouterRoutingTest, RoutingMaxConnectErrors) {\n  const auto server_port = port_pool_.get_next_available();\n  const auto router_port = port_pool_.get_next_available();\n\n  // json file does not actually matter in this test as we are not going to\n  const std::string json_stmts = get_data_dir().join(\"bootstrap_big_data.js\").str();\n  const std::string bootstrap_dir = get_tmp_dir();\n\n  // launch the server mock for bootstrapping\n  auto server_mock = launch_mysql_server_mock(json_stmts, server_port,\n    false /*expecting huge data, can't print on the console*/);\n\n  const std::string routing_section =\n    \"[routing:basic]\\n\"\n    \"bind_port = \" + std::to_string(router_port) + \"\\n\"\n    \"mode = read-write\\n\"\n    \"destinations = 127.0.0.1:\" + std::to_string(server_port) + \"\\n\"\n    \"max_connect_errors = 1\\n\";\n\n  std::string conf_file = create_config_file(routing_section);\n\n  // launch the router\n  auto router_static = launch_router(\"-c \" + conf_file);\n\n  // wait for mock server to begin accepting the connections\n  ASSERT_TRUE(wait_for_port_ready(server_port, 5000))\n    << server_mock.get_full_output();\n\n  // wait for router to begin accepting the connections\n  // NOTE: this should cause connection/disconnection which\n  //       should be treated as connection error and increment\n  //       connection errors counter.  This test relies on that.\n  ASSERT_TRUE(wait_for_port_ready(router_port, 5000))\n    << get_router_log_output();\n\n  // wait until blocking client host info appears in the log\n  bool res = find_in_file(get_logging_dir().str() + \"/mysqlrouter.log\",\n    [](const std::string& line) -> bool {\n      return line.find(\"blocking client host\") != line.npos;\n    }\n  );\n\n  ASSERT_TRUE(res) << \"Did not found expected entry in log file\";\n\n  // for the next connection attempt we should get an error as the\n  // max_connect_errors was exceeded\n  MySQLSession client;\n  EXPECT_THROW_LIKE(client.connect(\"127.0.0.1\", router_port, \"username\", \"password\", \"\", \"\"),\n                    std::exception, \"Too many connection errors\");\n}\n\nint main(int argc, char *argv[]) {\n  init_windows_sockets();\n  g_origin_path = Path(argv[0]).dirname();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "tests/component/test_routing_connection.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"dim.h\"\n#include \"keyring/keyring_manager.h\"\n#include \"mysql_session.h\"\n#include \"random_generator.h\"\n#include \"router_component_test.h\"\n#include \"tcp_port_pool.h\"\n\n#include \"rapidjson/document.h\"\n#include \"mysqlrouter/rest_client.h\"\n\n#include \"gmock/gmock.h\"\n\n#include <thread>\n#include <fstream>\n\nPath g_origin_path;\nusing mysqlrouter::MySQLSession;\n\nconst std::string kMockServerGlobalsRestUri = \"/api/v1/mock_server/globals/\";\n\nclass ConfigGenerator {\n\n  std::map<std::string, std::string> defaults_;\n  std::string config_dir_;\n\n  std::string metadata_cache_section_;\n  std::string routing_primary_section_;\n  std::string routing_secondary_section_;\n\n  std::vector<unsigned> metadata_server_ports_;\n  unsigned router_rw_port_;\n  unsigned router_ro_port_;\n  std::string disconnect_on_metadata_unavailable_ = \"&disconnect_on_metadata_unavailable=no\";\n  std::string disconnect_on_promoted_to_primary_ = \"&disconnect_on_promoted_to_primary=no\";\n  unsigned metadata_refresh_ttl_ = 1;\n\npublic:\n\n  ConfigGenerator(const std::map<std::string, std::string>& defaults, const std::string& config_dir,\n      const std::vector<unsigned> metadata_server_ports, unsigned router_rw_port, unsigned router_ro_port)\n      : defaults_(defaults), config_dir_(config_dir), metadata_server_ports_(metadata_server_ports),\n        router_rw_port_(router_rw_port), router_ro_port_(router_ro_port) {\n\n  }\n\n  void disconnect_on_metadata_unavailable(const std::string& value) {\n    disconnect_on_metadata_unavailable_ = value;\n  }\n\n  void disconnect_on_promoted_to_primary(const std::string& value) {\n    disconnect_on_promoted_to_primary_ = value;\n  }\n\n  void metadata_refresh_ttl(unsigned ttl) {\n    metadata_refresh_ttl_ = ttl;\n  }\n\n  void add_metadata_cache_section(unsigned ttl = 1) {\n\n    metadata_cache_section_ =\n        \"[logger]\\n\"\n        \"level = INFO\\n\\n\"\n\n        \"[metadata_cache:test]\\n\"\n        \"router_id=1\\n\"\n        \"bootstrap_server_addresses=\";\n    unsigned i = 0;\n    for(unsigned port : metadata_server_ports_) {\n      metadata_cache_section_ += \"mysql://127.0.0.1:\" + std::to_string(port);\n      if (i < metadata_server_ports_.size() - 1)\n        metadata_cache_section_ += \",\";\n    }\n    metadata_cache_section_ += \"\\n\"\n            \"user=mysql_router1_user\\n\"\n            \"metadata_cluster=test\\n\"\n            \"ttl=\" + std::to_string(ttl) + \"\\n\\n\";\n  }\n\n  std::string get_metadata_cache_routing_section(unsigned router_port,\n                                                 const std::string& role,\n                                                 const std::string& strategy,\n                                                 bool is_rw = false) {\n    std::string result;\n\n    if (is_rw) {\n      result = \"[routing:test_default_rw]\\n\"\n          \"bind_port=\" + std::to_string(router_port) + \"\\n\"\n          + \"destinations=metadata-cache://test/default?role=\" + role + disconnect_on_metadata_unavailable_\n          + \"\\n\" + \"protocol=classic\\n\";\n    } else {\n      result = \"[routing:test_default_ro]\\n\"\n          \"bind_port=\" + std::to_string(router_port) + \"\\n\"\n          + \"destinations=metadata-cache://test/default?role=\" + role + disconnect_on_metadata_unavailable_\n          + disconnect_on_promoted_to_primary_ + \"\\n\" + \"protocol=classic\\n\";\n    }\n\n    if (!strategy.empty())\n      result += std::string(\"routing_strategy=\" + strategy + \"\\n\");\n\n    return result;\n  }\n\n  void add_routing_primary_section() {\n    routing_primary_section_ = get_metadata_cache_routing_section(router_rw_port_,\n        \"PRIMARY\", \"round-robin\", true);\n  }\n\n  void add_routing_secondary_section() {\n    routing_secondary_section_ = get_metadata_cache_routing_section(router_ro_port_,\n        \"SECONDARY\", \"round-robin\", false);\n  }\n\n  void add_routing_primary_and_secondary_section() {\n    routing_secondary_section_ = get_metadata_cache_routing_section(router_ro_port_,\n        \"PRIMARY_AND_SECONDARY\", \"round-robin\", false);\n  }\n\n  std::string make_DEFAULT_section(const std::map<std::string, std::string>* params) {\n    auto l = [params](const char* key) -> std::string {\n      return (params->count(key))\n          ? std::string(key) + \" = \" + params->at(key) + \"\\n\"\n          : \"\";\n    };\n\n    return std::string(\"[DEFAULT]\\n\")\n          + l(\"logging_folder\")\n          + l(\"plugin_folder\")\n          + l(\"runtime_folder\")\n          + l(\"config_folder\")\n          + l(\"data_folder\")\n          + l(\"keyring_path\")\n          + l(\"master_key_path\")\n          + l(\"master_key_reader\")\n          + l(\"master_key_writer\")\n          + \"\\n\";\n  }\n\n  std::string create_config_file(const std::map<std::string, std::string> *params, const std::string &directory) {\n    Path file_path = Path(directory).join(\"mysqlrouter.conf\");\n    std::ofstream ofs_config(file_path.str());\n\n    if (!ofs_config.good()) {\n      throw(std::runtime_error(\"Could not create config file \" + file_path.str()));\n    }\n\n    ofs_config << make_DEFAULT_section(params);\n    ofs_config << metadata_cache_section_ << routing_primary_section_ << routing_secondary_section_ << std::endl;\n    ofs_config.close();\n\n    return file_path.str();\n  }\n\n  void set_keyring(const std::string& temp_test_dir) {\n    const std::string masterkey_file = Path(temp_test_dir).join(\"master.key\").str();\n    const std::string keyring_file = Path(temp_test_dir).join(\"keyring\").str();\n    mysql_harness::init_keyring(keyring_file, masterkey_file, true);\n    mysql_harness::Keyring *keyring = mysql_harness::get_keyring();\n    keyring->store(\"mysql_router1_user\", \"password\", \"root\");\n    mysql_harness::flush_keyring();\n    mysql_harness::reset_keyring();\n\n    // launch the router with metadata-cache configuration\n    defaults_[\"keyring_path\"] = keyring_file;\n    defaults_[\"master_key_path\"] = masterkey_file;\n  }\n\n  std::string build_config_file(const std::string& temp_test_dir, bool is_primary_and_secondary = false) {\n    add_metadata_cache_section(metadata_refresh_ttl_);\n    add_routing_primary_section();\n\n    if (is_primary_and_secondary) {\n      add_routing_primary_and_secondary_section();\n    }\n    else {\n      add_routing_secondary_section();\n    }\n\n    set_keyring(temp_test_dir);\n\n    return create_config_file(&defaults_, config_dir_);\n  }\n};\n\nclass RouterRoutingConnectionCommonTest : public RouterComponentTest {\npublic:\n\n  void init() {\n    set_origin(g_origin_path);\n    RouterComponentTest::SetUp();\n\n    mysql_harness::DIM& dim = mysql_harness::DIM::instance();\n    // RandomGenerator\n    dim.set_RandomGenerator(\n      [](){ static mysql_harness::RandomGenerator rg; return &rg; },\n      [](mysql_harness::RandomGeneratorInterface*){}\n    );\n    temp_test_dir_ = get_tmp_dir();\n    temp_conf_dir_ =  get_tmp_dir(\"conf\");\n\n    cluster_nodes_ports_ = {\n      port_pool_.get_next_available(), // first is PRIMARY\n      port_pool_.get_next_available(),\n      port_pool_.get_next_available(),\n      port_pool_.get_next_available(),\n      port_pool_.get_next_available()\n    };\n\n    router_rw_port_ = port_pool_.get_next_available();\n    router_ro_port_ = port_pool_.get_next_available();\n\n    primary_json_env_vars_ = {\n      { \"PRIMARY_HOST\",     \"127.0.0.1:\" + std::to_string(cluster_nodes_ports_[0]) },\n      { \"SECONDARY_1_HOST\", \"127.0.0.1:\" + std::to_string(cluster_nodes_ports_[1]) },\n      { \"SECONDARY_2_HOST\", \"127.0.0.1:\" + std::to_string(cluster_nodes_ports_[2]) },\n      { \"SECONDARY_3_HOST\", \"127.0.0.1:\" + std::to_string(cluster_nodes_ports_[3]) },\n      { \"SECONDARY_4_HOST\", \"127.0.0.1:\" + std::to_string(cluster_nodes_ports_[4]) },\n\n      { \"PRIMARY_PORT\",     std::to_string(cluster_nodes_ports_[0]) },\n      { \"SECONDARY_1_PORT\", std::to_string(cluster_nodes_ports_[1]) },\n      { \"SECONDARY_2_PORT\", std::to_string(cluster_nodes_ports_[2]) },\n      { \"SECONDARY_3_PORT\", std::to_string(cluster_nodes_ports_[3]) },\n      { \"SECONDARY_4_PORT\", std::to_string(cluster_nodes_ports_[4]) },\n\n    };\n\n    config_generator_.reset(\n        new ConfigGenerator(get_DEFAULT_defaults(), temp_conf_dir_,\n            { cluster_nodes_ports_[0] }, router_rw_port_, router_ro_port_));\n\n    http_port_ = port_pool_.get_next_available();\n    http_hostname_ = \"127.0.0.1\";\n    http_uri_ = kMockServerGlobalsRestUri;\n\n  }\n\n  void clean() {\n    purge_dir(temp_test_dir_);\n    purge_dir(temp_conf_dir_);\n  }\n\n  RouterComponentTest::CommandHandle\n  launch_router(unsigned router_port, const std::string& config_file) {\n    auto router = RouterComponentTest::launch_router(\"-c \" +  config_file);\n    bool ready = wait_for_port_ready(router_port, 1000);\n    EXPECT_TRUE(ready) << router.get_full_output();\n    return router;\n  }\n\n  RouterComponentTest::CommandHandle\n  launch_server(unsigned cluster_port, const std::string& json_file, unsigned http_port = 0) {\n    auto cluster_node = RouterComponentTest::launch_mysql_server_mock(json_file, cluster_port, false, http_port);\n    bool ready = wait_for_port_ready(cluster_port, 1000);\n    EXPECT_TRUE(ready) << cluster_node.get_full_output();\n    return cluster_node;\n  }\n\n  std::string get_json_for_secondary(unsigned /* cluster_port*/) {\n    const std::string json_my_port_template = get_data_dir().join(\"rest_server_mock.js\").str();\n    return json_my_port_template;\n  }\n\n  std::string replace_env_variables(const std::string& js_file_name, const std::map<std::string, std::string>& primary_json_env_vars, unsigned /* my_port*/) {\n    const std::string json_primary_node_template = get_data_dir().join(js_file_name).str();\n    const std::string json_primary_node = Path(temp_test_dir_).join(js_file_name).str();\n    std::map<std::string, std::string> env_vars = primary_json_env_vars;\n\n    rewrite_js_to_tracefile(json_primary_node_template, json_primary_node, env_vars);\n    return json_primary_node;\n  }\n\n  void setup_cluster(const std::string& js_for_primary, unsigned number_of_servers, unsigned my_port = 0) {\n    // launch the primary node working also as metadata server\n    const std::string json_for_primary = replace_env_variables(js_for_primary, primary_json_env_vars_, my_port);\n\n    cluster_nodes_.push_back(launch_server(cluster_nodes_ports_[0], json_for_primary, http_port_));\n\n    // launch the secondary cluster nodes\n    for (unsigned port = 1; port < number_of_servers; ++port) {\n      std::string secondary_json_file = get_json_for_secondary(cluster_nodes_ports_[port]);\n      cluster_nodes_.push_back(launch_server(cluster_nodes_ports_[port], secondary_json_file));\n    }\n  }\n\n  void set_global(const std::string& global) {\n    set_global(global, http_port_);\n  }\n\n  void set_global(const std::string& global, unsigned http_port) {\n    IOContext io_ctx;\n    RestClient rest_client(io_ctx, http_hostname_, http_port);\n    auto put_req = rest_client.request_sync(HttpMethod::Put, http_uri_,\n        global);\n\n    ASSERT_TRUE(put_req)\n        << \"HTTP Request to \"\n        << http_hostname_ << \":\" << std::to_string(http_port)\n        << \" failed (early): \"\n        << put_req.error_msg()\n        << std::endl;\n\n    ASSERT_GT(put_req.get_response_code(), 0u)\n        << \"HTTP Request to \"\n        << http_hostname_ << \":\" << std::to_string(http_port)\n        << \" failed: \"\n        << put_req.error_msg()\n        << std::endl;\n\n    EXPECT_EQ(put_req.get_response_code(), 204u);\n\n    auto put_resp_body = put_req.get_input_buffer();\n    EXPECT_EQ(put_resp_body.length(), 0u);\n  }\n\n  void send_delete(unsigned http_port, int node_id) {\n    IOContext io_ctx;\n    RestClient rest_client(io_ctx, http_hostname_, http_port);\n    auto kill_req = rest_client.request_sync(HttpMethod::Delete, \"/api/v1/mock_server/connections/\");\n\n    ASSERT_TRUE(kill_req)\n        << \"HTTP Request to \"\n        << http_hostname_ << \":\" << std::to_string(http_port)\n        << \" failed (early): \"\n        << kill_req.error_msg()\n        << std::endl\n        << cluster_nodes_[node_id].get_full_output()\n        << std::endl;\n\n    ASSERT_GT(kill_req.get_response_code(), 0u)\n        << \"HTTP Request to \"\n        << http_hostname_ << \":\" << std::to_string(http_port)\n        << \" failed: \"\n        << kill_req.error_msg()\n        << std::endl\n        << cluster_nodes_[node_id].get_full_output()\n        << std::endl;\n\n    EXPECT_EQ(kill_req.get_response_code(), 200u);\n\n    auto put_resp_body = kill_req.get_input_buffer();\n    EXPECT_EQ(put_resp_body.length(), 0u);\n  }\n\n  rapidjson::Document get_global_json(const std::string& global_name) {\n    IOContext io_ctx;\n    auto req_get = RestClient(io_ctx, http_hostname_, http_port_)\n        .request_sync(HttpMethod::Get, http_uri_);\n    EXPECT_TRUE(req_get);\n    EXPECT_EQ(req_get.get_response_code(), 200u);\n    EXPECT_THAT(req_get.get_input_headers().get(\"Content-Type\"), ::testing::StrEq(\"application/json\"));\n    auto resp_body = req_get.get_input_buffer();\n    EXPECT_GT(resp_body.length(), 0u);\n    auto resp_body_content = resp_body.pop_front(resp_body.length());\n\n    // parse json\n    std::string json_payload(resp_body_content.begin(), resp_body_content.end());\n\n    rapidjson::Document json_doc;\n    json_doc.Parse(json_payload.c_str());\n    EXPECT_TRUE(json_doc.HasMember(global_name.c_str()));\n    EXPECT_TRUE(json_doc[global_name.c_str()].IsInt());\n    return json_doc;\n  }\n\n  int get_int_global(const std::string& global_name) {\n    return get_global_json(global_name)[global_name.c_str()].GetInt();\n  }\n\n  bool get_bool_global(const std::string& global_name) {\n    return get_global_json(global_name)[global_name.c_str()].GetBool();\n  }\n\n  TcpPortPool port_pool_;\n  unsigned wait_for_cache_ready_timeout{1200};\n  unsigned wait_for_cache_update_timeout{2000};\n  std::unique_ptr<ConfigGenerator> config_generator_;\n  std::string temp_test_dir_;\n  std::string temp_conf_dir_;\n  std::vector<unsigned> cluster_nodes_ports_;\n  std::map<std::string, std::string> primary_json_env_vars_;\n  std::vector<RouterComponentTest::CommandHandle> cluster_nodes_;\n  unsigned router_rw_port_;\n  unsigned router_ro_port_;\n\n  // http properties\n  unsigned http_port_;\n  std::string http_hostname_;\n  std::string http_uri_;\n};\n\nclass RouterRoutingConnectionTest : public RouterRoutingConnectionCommonTest, public testing::Test {\npublic:\n\n  void SetUp() override {\n    init();\n  }\n\n  void TearDown() override {\n    clean();\n  }\n};\n\n/**\n * @test\n *      Verify that router doesn't start when disconnect_on_promoted_to_primary\n *      has invalid value.\n */\nTEST_F(RouterRoutingConnectionTest, IsRouterFailToStartWhen_disconnect_on_promoted_to_primary_invalid) {\n  setup_cluster(\"metadata_3_secondaries_server_removed_from_cluster.js\", 4);\n  config_generator_->disconnect_on_promoted_to_primary(\"&disconnect_on_promoted_to_primary=bogus\");\n  auto router = RouterComponentTest::launch_router(\"-c \" +  config_generator_->build_config_file(temp_test_dir_));\n  ASSERT_FALSE(wait_for_port_ready(router_ro_port_, 1000)) << router.get_full_output();\n}\n\n/**\n * @test\n *      Verify that router doesn't start when disconnect_on_metadata_unavailable\n *      has invalid value.\n */\nTEST_F(RouterRoutingConnectionTest, IsRouterFailToStartWhen_disconnect_on_metadata_unavailable_invalid) {\n  setup_cluster(\"metadata_3_secondaries_server_removed_from_cluster.js\", 4);\n  config_generator_->disconnect_on_metadata_unavailable(\"&disconnect_on_metadata_unavailable=bogus\");\n  auto router = RouterComponentTest::launch_router(\"-c \" +  config_generator_->build_config_file(temp_test_dir_));\n  ASSERT_FALSE(wait_for_port_ready(router_ro_port_, 1000)) << router.get_full_output();\n}\n\n/**\n * @test\n *      Verify that all connections to Primary are closed when Primary is removed\n *      from GR;\n */\nTEST_F(RouterRoutingConnectionTest, IsConnectionsClosedWhenPrimaryRemovedFromGR) {\n  config_generator_.reset(\n      new ConfigGenerator(get_DEFAULT_defaults(), get_tmp_dir(\"conf\"),\n          { cluster_nodes_ports_[0], cluster_nodes_ports_[1] }, router_rw_port_, router_ro_port_));\n\n  unsigned http_port_primary = port_pool_.get_next_available();\n\n  // launch the primary node working also as metadata server\n  const std::string json_for_primary = replace_env_variables(\n      \"metadata_3_secondaries_server_removed_from_cluster.js\",\n      primary_json_env_vars_, cluster_nodes_ports_[0]);\n  cluster_nodes_.push_back(launch_server(cluster_nodes_ports_[0], json_for_primary, http_port_primary));\n\n  // launch the secondary node working also as metadata server\n  const std::string json_for_secondary = replace_env_variables(\n      \"metadata_3_secondaries_server_removed_from_cluster.js\",\n      primary_json_env_vars_, cluster_nodes_ports_[1]);\n  cluster_nodes_.push_back(launch_server(cluster_nodes_ports_[1], json_for_secondary, http_port_));\n\n  // launch the rest of secondary cluster nodes\n  for (unsigned port = 2; port < 4; ++port) {\n    std::string secondary_json_file = get_json_for_secondary(cluster_nodes_ports_[port]);\n    cluster_nodes_.push_back(launch_server(cluster_nodes_ports_[port], secondary_json_file));\n  }\n\n  auto router = launch_router(router_ro_port_, config_generator_->build_config_file(temp_test_dir_));\n\n  /*\n   * wait until metadata is initialized\n   */\n  std::this_thread::sleep_for(std::chrono::milliseconds(wait_for_cache_ready_timeout));\n\n  // connect clients\n  std::vector<std::pair<MySQLSession, unsigned>> clients(2);\n\n  for(auto& client_and_port : clients) {\n    auto& client = client_and_port.first;\n    client.connect(\"127.0.0.1\", router_rw_port_, \"username\", \"password\", \"\", \"\");\n    std::unique_ptr<MySQLSession::ResultRow> result{client.query_one(\"select @@port\")};\n    client_and_port.second = std::stoul(std::string((*result)[0]));\n  }\n\n  // set primary_removed variable in javascript for cluster_nodes_[0]\n  // which acts as primary node in cluster\n  set_global(\"{\\\"primary_removed\\\": true}\", http_port_primary);\n  // set primary_removed variable in javascript for cluster_nodes_[1]\n  // which uses default port http_port_\n  set_global(\"{\\\"primary_removed\\\": true}\", http_port_);\n\n  std::this_thread::sleep_for(std::chrono::milliseconds(wait_for_cache_update_timeout));\n\n  // verify that connections to PRIMARY are broken\n  for(auto& client_and_port : clients) {\n    auto& client  = client_and_port.first;\n    ASSERT_ANY_THROW(client.query_one(\"select @@port\")) << router.get_full_output();\n  }\n}\n\n/**\n * @test\n *      Verify that all connections to Secondary are closed when Secondary is\n *      removed from GR.\n *\n */\nTEST_F(RouterRoutingConnectionTest, IsConnectionsClosedWhenSecondaryRemovedFromGR) {\n  setup_cluster(\"metadata_3_secondaries_server_removed_from_cluster.js\", 4);\n\n  auto router = launch_router(router_ro_port_, config_generator_->build_config_file(temp_test_dir_));\n\n  /*\n   * wait until metadata is initialized\n   */\n  std::this_thread::sleep_for(std::chrono::milliseconds(wait_for_cache_ready_timeout));\n\n  // connect clients\n  std::vector<std::pair<MySQLSession, unsigned>> clients(6);\n\n  for(auto& client_and_port : clients) {\n    auto& client = client_and_port.first;\n    client.connect(\"127.0.0.1\", router_ro_port_, \"username\", \"password\", \"\", \"\");\n    std::unique_ptr<MySQLSession::ResultRow> result{client.query_one(\"select @@port\")};\n    client_and_port.second = std::stoul(std::string((*result)[0]));\n  }\n\n  set_global(\"{\\\"secondary_removed\\\": true}\");\n\n  std::this_thread::sleep_for(std::chrono::milliseconds(wait_for_cache_update_timeout));\n\n  // verify that connections to SECONDARY_1 are broken\n  for(auto& client_and_port : clients) {\n    auto& client  = client_and_port.first;\n    unsigned port = client_and_port.second;\n\n    if (port == cluster_nodes_ports_[1])\n      ASSERT_ANY_THROW(client.query_one(\"select @@port\")) << router.get_full_output();\n    else\n      ASSERT_NO_THROW(std::unique_ptr<MySQLSession::ResultRow> result {client.query_one(\"select @@port\")}) << router.get_full_output();\n  }\n}\n\n/**\n * @test\n *       Verify that when Primary is demoted, then all RW connections\n *       to that server are closed.\n */\nTEST_F(RouterRoutingConnectionTest, IsRWConnectionsClosedWhenPrimaryFailover) {\n  setup_cluster(\"metadata_3_secondaries_primary_failover.js\", 4);\n  auto router = launch_router(router_ro_port_, config_generator_->build_config_file(temp_test_dir_));\n\n  /*\n   * wait until metadata is initialized\n   */\n  std::this_thread::sleep_for(std::chrono::milliseconds(wait_for_cache_ready_timeout));\n\n  // connect clients\n  std::vector<std::pair<MySQLSession, unsigned>> clients(2);\n\n  for(auto& client_and_port : clients) {\n    auto& client = client_and_port.first;\n    client.connect(\"127.0.0.1\", router_rw_port_, \"username\", \"password\", \"\", \"\");\n    std::unique_ptr<MySQLSession::ResultRow> result{client.query_one(\"select @@port\")};\n    client_and_port.second = std::stoul(std::string((*result)[0]));\n  }\n\n  set_global(\"{\\\"primary_failover\\\": true}\");\n\n  std::this_thread::sleep_for(std::chrono::milliseconds(wait_for_cache_update_timeout));\n\n  // verify if RW connections to PRIMARY are closed\n  for(auto& client_and_port : clients) {\n    auto& client  = client_and_port.first;\n    ASSERT_ANY_THROW(client.query_one(\"select @@port\")) << router.get_full_output();\n  }\n}\n\n/**\n * @test\n *       Verify that when Primary is demoted, then RO connections\n *       to that server are kept.\n */\nTEST_F(RouterRoutingConnectionTest, IsROConnectionsKeptWhenPrimaryFailover) {\n  setup_cluster(\"metadata_3_secondaries_primary_failover.js\", 4);\n\n  config_generator_->disconnect_on_promoted_to_primary(\"\");\n\n  auto router = launch_router(router_ro_port_, config_generator_->build_config_file(temp_test_dir_, true));\n\n  /*\n   * wait until metadata is initialized\n   */\n  std::this_thread::sleep_for(std::chrono::milliseconds(wait_for_cache_ready_timeout));\n\n  // connect clients\n  std::vector<std::pair<MySQLSession, unsigned>> clients(4);\n\n  for(auto& client_and_port : clients) {\n    auto& client = client_and_port.first;\n    client.connect(\"127.0.0.1\", router_ro_port_, \"username\", \"password\", \"\", \"\");\n    std::unique_ptr<MySQLSession::ResultRow> result{client.query_one(\"select @@port\")};\n    client_and_port.second = std::stoul(std::string((*result)[0]));\n  }\n\n  set_global(\"{\\\"primary_failover\\\": true}\");\n  std::this_thread::sleep_for(std::chrono::milliseconds(wait_for_cache_update_timeout));\n\n  // verify that RO connections to PRIMARY are kept\n  for(auto& client_and_port : clients) {\n    auto& client  = client_and_port.first;\n    ASSERT_NO_THROW(std::unique_ptr<MySQLSession::ResultRow> result {client.query_one(\"select @@port\")}) << router.get_full_output();\n  }\n}\n\nclass RouterRoutingConnectionPromotedTest: public RouterRoutingConnectionCommonTest,\n    public testing::TestWithParam<std::string> {\npublic:\n\n  void SetUp() override {\n    init();\n  }\n\n  void TearDown() override {\n    clean();\n  }\n};\n\n/**\n * @test\n *       Verify that when server is promoted from Secondary to Primary and\n *       disconnect_on_promoted_to_primary is set to 'no' (default value) then\n *       connections to that server are not closed.\n */\nTEST_P(RouterRoutingConnectionPromotedTest, IsConnectionsToSecondaryKeptWhenPromotedToPrimary) {\n  setup_cluster(\"metadata_3_secondaries_primary_failover.js\", 4);\n\n  config_generator_->disconnect_on_promoted_to_primary(GetParam());\n\n  auto router = launch_router(router_ro_port_, config_generator_->build_config_file(temp_test_dir_));\n\n  /*\n   * wait until metadata is initialized\n   */\n  std::this_thread::sleep_for(std::chrono::milliseconds(wait_for_cache_ready_timeout));\n\n  // connect clients\n  std::vector<std::pair<MySQLSession, unsigned>> clients(6);\n\n  for(auto& client_and_port : clients) {\n    auto& client = client_and_port.first;\n    client.connect(\"127.0.0.1\", router_ro_port_, \"username\", \"password\", \"\", \"\");\n    std::unique_ptr<MySQLSession::ResultRow> result{client.query_one(\"select @@port\")};\n    client_and_port.second = std::stoul(std::string((*result)[0]));\n  }\n\n  set_global(\"{\\\"primary_failover\\\": true}\");\n  std::this_thread::sleep_for(std::chrono::milliseconds(wait_for_cache_update_timeout));\n\n  // verify that connections to SECONDARY_1 are kept (all RO connections should NOT be closed)\n  for(auto& client_and_port : clients) {\n    auto& client  = client_and_port.first;\n    ASSERT_NO_THROW(std::unique_ptr<MySQLSession::ResultRow> result {client.query_one(\"select @@port\")}) << router.get_full_output();\n  }\n}\n\nstd::string promoted_flags[] = {\n    \"&disconnect_on_promoted_to_primary=no\",\n    \"\",\n};\n\nINSTANTIATE_TEST_CASE_P(RouterRoutingIsConnectionNotClosedWhenPromoted,\n    RouterRoutingConnectionPromotedTest, testing::ValuesIn(promoted_flags));\n\n/**\n * @test\n *       Verify that when server is promoted from Secondary to Primary and\n *       disconnect_on_promoted_to_primary is set to 'yes' then connections\n *       to that server are closed.\n */\nTEST_F(RouterRoutingConnectionTest, IsConnectionToSecondaryClosedWhenPromotedToPrimary) {\n  setup_cluster(\"metadata_3_secondaries_primary_failover.js\", 4);\n\n  config_generator_->disconnect_on_promoted_to_primary(\"&disconnect_on_promoted_to_primary=yes\");\n\n  auto router = launch_router(router_ro_port_, config_generator_->build_config_file(temp_test_dir_));\n\n  /*\n   * wait until metadata is initialized\n   */\n  std::this_thread::sleep_for(std::chrono::milliseconds(wait_for_cache_ready_timeout));\n\n  // connect clients\n  std::vector<std::pair<MySQLSession, unsigned>> clients(6);\n\n\n  for(auto& client_and_port : clients) {\n    auto& client = client_and_port.first;\n    client.connect(\"127.0.0.1\", router_ro_port_, \"username\", \"password\", \"\", \"\");\n    std::unique_ptr<MySQLSession::ResultRow> result{client.query_one(\"select @@port\")};\n    client_and_port.second = std::stoul(std::string((*result)[0]));\n  }\n\n  set_global(\"{\\\"primary_failover\\\": true}\");\n  std::this_thread::sleep_for(std::chrono::milliseconds(wait_for_cache_update_timeout));\n\n  // verify that connections to SECONDARY_1 are closed\n  for(auto& client_and_port : clients) {\n    auto& client  = client_and_port.first;\n    unsigned port = client_and_port.second;\n\n    if (port == cluster_nodes_ports_[1])\n      ASSERT_ANY_THROW(client.query_one(\"select @@port\")) << router.get_full_output();\n    else\n      ASSERT_NO_THROW(std::unique_ptr<MySQLSession::ResultRow> result {client.query_one(\"select @@port\")}) << router.get_full_output();\n  }\n}\n\n/**\n * @test\n *       Verify that when GR is partitioned, then connections to servers that\n *       are not in majority are closed.\n */\nTEST_F(RouterRoutingConnectionTest, IsConnectionToMinorityClosedWhenClusterPartition) {\n  /*\n   * create cluster with 5 servers\n   */\n  setup_cluster(\"metadata_4_secondaries_partitioning.js\", 5);\n\n  auto router = launch_router(router_ro_port_, config_generator_->build_config_file(temp_test_dir_));\n\n  /*\n   * wait until metadata is initialized\n   */\n  std::this_thread::sleep_for(std::chrono::milliseconds(wait_for_cache_ready_timeout));\n\n  // connect clients\n  std::vector<std::pair<MySQLSession, unsigned>> clients(10);\n\n  // connect clients to Primary\n  for(int i=0; i<2; ++i) {\n    auto& client = clients[i].first;\n    client.connect(\"127.0.0.1\", router_rw_port_, \"username\", \"password\", \"\", \"\");\n    std::unique_ptr<MySQLSession::ResultRow> result{client.query_one(\"select @@port\")};\n    clients[i].second = std::stoul(std::string((*result)[0]));\n  }\n\n  // connect clients to Secondaries\n  for(int i=2; i<10; ++i) {\n    auto& client = clients[i].first;\n    client.connect(\"127.0.0.1\", router_ro_port_, \"username\", \"password\", \"\", \"\");\n    std::unique_ptr<MySQLSession::ResultRow> result{client.query_one(\"select @@port\")};\n    clients[i].second = std::stoul(std::string((*result)[0]));\n  }\n\n  /*\n   * Partition the cluster:\n   * - 2 servers are ONLINE: Primary and Secondary_1\n   * - 3 servers are OFFLINE: Secondary_2, Secondary_3, Secondary_4\n   *\n   * Connetions to OFFLINE servers should be closed.\n   * Since only 2 servers are ONLINE (minority) connections to them should be\n   * closed as well.\n   */\n  set_global(\"{\\\"cluster_partition\\\": true}\");\n  std::this_thread::sleep_for(std::chrono::milliseconds(wait_for_cache_update_timeout));\n\n  /*\n   * Connections to servers that are offline should be closed\n   * Connections to servers in minority should be closed as well\n   */\n  for(auto& client_and_port : clients) {\n    auto& client  = client_and_port.first;\n    ASSERT_ANY_THROW(client.query_one(\"select @@port\")) << router.get_full_output();\n  }\n}\n\nclass RouterRoutingConnectionClusterOverloadTest: public RouterRoutingConnectionCommonTest,\n    public testing::TestWithParam<std::string> {\npublic:\n\n  void SetUp() override {\n    init();\n  }\n\n  void TearDown() override {\n    clean();\n  }\n};\n\n/**\n * @test\n *       Verity that when GR is overloaded and disconnect_on_metadata_unavailable\n *       is set to 'yes' then all connection to GR are closed\n */\nTEST_F(RouterRoutingConnectionTest, IsConnectionClosedWhenClusterOverloaded) {\n  setup_cluster(\"metadata_3_secondaries_pass.js\", 4);\n\n  config_generator_->disconnect_on_metadata_unavailable(\"&disconnect_on_metadata_unavailable=yes\");\n\n  auto router = launch_router(router_ro_port_, config_generator_->build_config_file(temp_test_dir_));\n\n  /*\n   * wait until metadata is initialized\n   */\n  std::this_thread::sleep_for(std::chrono::milliseconds(wait_for_cache_ready_timeout));\n\n  // connect clients\n  std::vector<std::pair<MySQLSession, unsigned>> clients(6);\n\n  for(auto& client_and_port : clients) {\n    auto& client = client_and_port.first;\n    ASSERT_NO_THROW(client.connect(\"127.0.0.1\", router_ro_port_, \"username\", \"password\", \"\", \"\"));\n    std::unique_ptr<MySQLSession::ResultRow> result{client.query_one(\"select @@port\")};\n    client_and_port.second = std::stoul(std::string((*result)[0]));\n  }\n\n  /*\n   * There is only 1 metadata server, so then primary\n   * goes away, metadata is unavailable.\n   */\n  send_delete(http_port_, 0);\n  cluster_nodes_[0].kill();\n  std::this_thread::sleep_for(std::chrono::milliseconds(wait_for_cache_update_timeout));\n\n  // verify that all connections are closed\n  for(auto& client_and_port : clients) {\n    auto& client  = client_and_port.first;\n    ASSERT_ANY_THROW(client.query_one(\"select @@port\")) << router.get_full_output();\n  }\n}\n\nclass RouterRoutingConnectionMDUnavailableTest: public RouterRoutingConnectionCommonTest,\n    public testing::TestWithParam<std::string> {\npublic:\n\n  void SetUp() override {\n    init();\n  }\n\n  void TearDown() override {\n    clean();\n  }\n};\n\n/**\n * @test\n *       Verify that when GR is overloaded and disconnect_on_metadata_unavailable\n *       is set to 'no' (default value) then connections to GR are NOT closed.\n */\nTEST_P(RouterRoutingConnectionMDUnavailableTest, IsConnectionKeptWhenClusterOverloaded) {\n  setup_cluster(\"metadata_3_secondaries_pass.js\", 4);\n\n  config_generator_->disconnect_on_promoted_to_primary(GetParam());\n  auto router = launch_router(router_ro_port_, config_generator_->build_config_file(temp_test_dir_));\n\n  /*\n   * wait until metadata is initialized\n   */\n  std::this_thread::sleep_for(std::chrono::milliseconds(wait_for_cache_ready_timeout));\n\n  // connect clients\n  std::vector<std::pair<MySQLSession, unsigned>> clients(6);\n\n  for(auto& client_and_port : clients) {\n    auto& client = client_and_port.first;\n    ASSERT_NO_THROW(client.connect(\"127.0.0.1\", router_ro_port_, \"username\", \"password\", \"\", \"\"));\n    std::unique_ptr<MySQLSession::ResultRow> result{client.query_one(\"select @@port\")};\n    client_and_port.second = std::stoul(std::string((*result)[0]));\n  }\n\n  /*\n   * There is only 1 metadata server, so then primary\n   * goes away, metadata is unavailable.\n   */\n  send_delete(http_port_, 0);\n  cluster_nodes_[0].kill();\n  std::this_thread::sleep_for(std::chrono::milliseconds(wait_for_cache_update_timeout));\n\n  // verify if all connections are NOT closed\n  for(auto& client_and_port : clients) {\n    auto& client  = client_and_port.first;\n    ASSERT_NO_THROW(std::unique_ptr<MySQLSession::ResultRow> result {client.query_one(\"select @@port\")}) << router.get_full_output();\n  }\n}\n\nstd::string metadata_unavailable_flags[] = {\n    \"&disconnect_on_metadata_unavailable=no\",\n    \"\",\n};\n\nINSTANTIATE_TEST_CASE_P(RouterRoutingIsConnectionNotClosedWhenMDUnavailable,\n    RouterRoutingConnectionMDUnavailableTest, testing::ValuesIn(metadata_unavailable_flags));\n\n\nclass RouterRoutingConnectionMDRefreshTest: public RouterRoutingConnectionCommonTest,\n    public testing::TestWithParam<std::string> {\npublic:\n\n  void SetUp() override {\n    init();\n  }\n\n  void TearDown() override {\n    clean();\n  }\n};\n\n/**\n * @test\n *      Verify if connections are not closed when fetching metadata from current\n *      metadata server fails, but fetching from subsequent metadata server passes.\n *\n *      1. Start cluster with 1 Primary and 4 Secondary\n *      2. Establish 2 RW connections and 8 RO connections\n *      3. Fetching MD from Primary fails\n *      4. Fetching MD from Secondary passes\n *      5. Check if connections are still open.\n */\nTEST_P(RouterRoutingConnectionMDRefreshTest, IsConnectionNotClosedWhenRrefreshFailedForParticularMDServer) {\n  /*\n   * Primary and first secondary are metadata-cache servers\n   */\n  config_generator_.reset(\n      new ConfigGenerator(get_DEFAULT_defaults(), get_tmp_dir(\"conf\"),\n          { cluster_nodes_ports_[0], cluster_nodes_ports_[1] }, router_rw_port_, router_ro_port_));\n\n  unsigned http_port_primary = port_pool_.get_next_available();\n\n  // launch the primary node working also as metadata server\n  const std::string json_for_primary = replace_env_variables(\"metadata_3_secondaries_failed_to_update.js\", primary_json_env_vars_, cluster_nodes_ports_[0]);\n  cluster_nodes_.push_back(launch_server(cluster_nodes_ports_[0], json_for_primary, http_port_primary));\n\n  // launch the secondary node working also as metadata server\n  const std::string json_for_secondary = replace_env_variables(\"metadata_3_secondaries_pass.js\", primary_json_env_vars_, cluster_nodes_ports_[1]);\n  cluster_nodes_.push_back(launch_server(cluster_nodes_ports_[1], json_for_secondary, http_port_));\n\n  // launch the rest of secondary cluster nodes\n  for (unsigned port = 2; port < 4; ++port) {\n    std::string secondary_json_file = get_json_for_secondary(cluster_nodes_ports_[port]);\n    cluster_nodes_.push_back(launch_server(cluster_nodes_ports_[port], secondary_json_file));\n  }\n\n  config_generator_->disconnect_on_metadata_unavailable(\"&disconnect_on_metadata_unavailable=yes\");\n  auto router = launch_router(router_ro_port_, config_generator_->build_config_file(temp_test_dir_));\n\n  /*\n   * wait until metadata is initialized\n   */\n  std::this_thread::sleep_for(std::chrono::milliseconds(wait_for_cache_ready_timeout));\n\n  // connect clients\n  std::vector<std::pair<MySQLSession, unsigned>> clients(10);\n\n  for(int i=0; i<2; ++i) {\n    auto& client = clients[i].first;\n    client.connect(\"127.0.0.1\", router_rw_port_, \"username\", \"password\", \"\", \"\");\n    std::unique_ptr<MySQLSession::ResultRow> result{client.query_one(\"select @@port\")};\n    clients[i].second = std::stoul(std::string((*result)[0]));\n  }\n\n  for(int i=2; i<10; ++i) {\n    auto& client = clients[i].first;\n    client.connect(\"127.0.0.1\", router_ro_port_, \"username\", \"password\", \"\", \"\");\n    std::unique_ptr<MySQLSession::ResultRow> result{client.query_one(\"select @@port\")};\n    clients[i].second = std::stoul(std::string((*result)[0]));\n  }\n\n  set_global(GetParam(), http_port_primary);\n  std::this_thread::sleep_for(std::chrono::milliseconds(wait_for_cache_update_timeout));\n\n\n  // verify if all connections are NOT closed\n  for(auto& client_and_port : clients) {\n    auto& client  = client_and_port.first;\n    ASSERT_NO_THROW(std::unique_ptr<MySQLSession::ResultRow> result {client.query_one(\"select @@port\")}) << router.get_full_output();\n  }\n}\n\nstd::string steps[] = {\n    \"{\\\"MD_failed\\\": true}\",\n    \"{\\\"GR_primary_failed\\\": true}\",\n    \"{\\\"GR_health_failed\\\": true}\"\n};\n\nINSTANTIATE_TEST_CASE_P(RouterRoutingIsConnectionNotDisabledWhenMDRefresh, RouterRoutingConnectionMDRefreshTest, testing::ValuesIn(steps));\n\nint main(int argc, char *argv[]) {\n  init_windows_sockets();\n  g_origin_path = Path(argv[0]).dirname();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "tests/component/test_routing_strategy.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"gmock/gmock.h\"\n#include \"router_component_test.h\"\n#include \"tcp_port_pool.h\"\n#include \"mysql_session.h\"\n#include \"keyring/keyring_manager.h\"\n\n#include <chrono>\n#include <thread>\n\nPath g_origin_path;\nusing mysqlrouter::MySQLSession;\n\nclass RouterRoutingStrategyTest : public RouterComponentTest {\n protected:\n  virtual void SetUp() {\n    set_origin(g_origin_path);\n    RouterComponentTest::SetUp();\n\n    // Valgrind needs way more time\n    if (getenv(\"WITH_VALGRIND\")) {\n      wait_for_cache_ready_timeout = 5000;\n      wait_for_process_exit_timeout = 20000;\n      wait_for_static_ready_timeout = 1000;\n    }\n  }\n\n  std::string get_metadata_cache_section(unsigned metadata_server_port) {\n    return \"[metadata_cache:test]\\n\"\n           \"router_id=1\\n\"\n           \"bootstrap_server_addresses=mysql://localhost:\" + std::to_string(metadata_server_port) + \"\\n\"\n           \"user=mysql_router1_user\\n\"\n           \"metadata_cluster=test\\n\"\n           \"ttl=300\\n\\n\";\n  }\n\n  std::string get_static_routing_section(unsigned router_port,\n                                         const std::vector<unsigned>& destinations,\n                                         const std::string& strategy,\n                                         const std::string& mode = \"\") {\n    std::string result = \"[routing:test_default]\\n\"\n      \"bind_port=\" + std::to_string(router_port) + \"\\n\" +\n      \"protocol=classic\\n\";\n\n    result+=\"destinations=\";\n    for (size_t i = 0; i < destinations.size(); ++i) {\n      result+=\"127.0.0.1:\"+std::to_string(destinations[i]);\n      if (i!=destinations.size()-1) {\n        result += \",\";\n      }\n    }\n    result+=\"\\n\";\n\n    if (!strategy.empty()) result += std::string(\"routing_strategy=\" + strategy + \"\\n\");\n    if (!mode.empty()) result += std::string(\"mode=\" + mode + \"\\n\");\n\n    return result;\n  }\n\n  // for error scenarios allow empty values\n  std::string get_static_routing_section_error(unsigned router_port,\n                                               const std::vector<unsigned>& destinations,\n                                               const std::string& strategy,\n                                               const std::string& mode) {\n    std::string result = \"[routing:test_default]\\n\"\n      \"bind_port=\" + std::to_string(router_port) + \"\\n\" +\n      \"protocol=classic\\n\";\n\n    result+=\"destinations=\";\n    for (size_t i = 0; i < destinations.size(); ++i) {\n      result+=\"localhost:\"+std::to_string(destinations[i]);\n      if (i!=destinations.size()-1) {\n        result += \",\";\n      }\n    }\n    result+=\"\\n\";\n    result += std::string(\"routing_strategy=\" + strategy + \"\\n\");\n    result += std::string(\"mode=\" + mode + \"\\n\");\n\n    return result;\n  }\n\n  std::string get_metadata_cache_routing_section(unsigned router_port,\n                                                 const std::string& role,\n                                                 const std::string& strategy,\n                                                 const std::string& mode = \"\") {\n    std::string result = \"[routing:test_default]\\n\"\n      \"bind_port=\" + std::to_string(router_port) + \"\\n\" +\n      \"destinations=metadata-cache://test/default?role=\" + role + \"\\n\" +\n      \"protocol=classic\\n\";\n\n    if (!strategy.empty()) result += std::string(\"routing_strategy=\" + strategy + \"\\n\");\n    if (!mode.empty()) result += std::string(\"mode=\" + mode + \"\\n\");\n\n    return result;\n  }\n\n  // need to return void to be able to use ASSERT_ macros\n  void connect_client_and_query_port(unsigned router_port, std::string& out_port, bool should_fail = false) {\n    MySQLSession client;\n\n    if (should_fail) {\n      EXPECT_THROW_LIKE(client.connect(\"127.0.0.1\", router_port, \"username\", \"password\", \"\", \"\"),\n                        std::exception, \"Error connecting to MySQL server\");\n      out_port = \"\";\n      return;\n    }\n    else {\n      ASSERT_NO_THROW(client.connect(\"127.0.0.1\", router_port, \"username\", \"password\", \"\", \"\"));\n    }\n\n    std::unique_ptr<MySQLSession::ResultRow> result{client.query_one(\"select @@port\")};\n    ASSERT_NE(nullptr, result.get());\n    ASSERT_EQ(1u, result->size());\n    out_port = std::string((*result)[0]);\n  }\n\n  RouterComponentTest::CommandHandle\n  launch_cluster_node(unsigned cluster_port,\n                      const std::string& data_dir,\n                      const std::string& tmp_dir) {\n    const std::string json_my_port_template = Path(data_dir).join(\"my_port.js\").str();\n    const std::string json_my_port = Path(tmp_dir).join(\"my_port_\" + std::to_string(cluster_port) + \".json\").str();\n    std::map<std::string, std::string> env_vars = {\n      { \"MY_PORT\", std::to_string(cluster_port) },\n    };\n    RouterComponentTest::rewrite_js_to_tracefile(json_my_port_template, json_my_port, env_vars);\n    auto cluster_node = RouterComponentTest::launch_mysql_server_mock(json_my_port, cluster_port, false);\n    bool ready = wait_for_port_ready(cluster_port, 1000);\n    EXPECT_TRUE(ready) << cluster_node.get_full_output();\n\n    return cluster_node;\n  }\n\n  RouterComponentTest::CommandHandle\n  launch_standalone_server(unsigned server_port,\n                           const std::string& data_dir,\n                           const std::string& tmp_dir) {\n    // it' does the same thing, just an alias  for less confusion\n    return launch_cluster_node(server_port, data_dir, tmp_dir);\n  }\n\n  RouterComponentTest::CommandHandle\n  launch_router_static(unsigned router_port,\n                       const std::string& routing_section,\n                       bool expect_error = false,\n                       bool log_to_console = true) {\n    auto def_section = get_DEFAULT_defaults();\n    if (log_to_console) {\n      def_section[\"logging_folder\"] = \"\";\n    }\n    // launch the router with the static routing configuration\n    const std::string conf_file = create_config_file(routing_section, &def_section);\n    auto router = RouterComponentTest::launch_router(\"-c \" +  conf_file);\n    if (!expect_error) {\n      bool ready = wait_for_port_ready(router_port, 1000);\n      EXPECT_TRUE(ready) << (log_to_console ? router.get_full_output() : get_router_log_output());\n    }\n\n    return router;\n  }\n\n  RouterComponentTest::CommandHandle\n  launch_router(unsigned router_port,\n                const std::string& temp_test_dir,\n                const std::string& metadata_cache_section,\n                const std::string& routing_section,\n                bool catch_stderr = true,\n                bool with_sudo = false,\n                bool wait_ready = true,\n                bool log_to_stdout = false) {\n    const std::string masterkey_file = Path(temp_test_dir).join(\"master.key\").str();\n    const std::string keyring_file = Path(temp_test_dir).join(\"keyring\").str();\n    mysql_harness::init_keyring(keyring_file, masterkey_file, true);\n    mysql_harness::Keyring *keyring = mysql_harness::get_keyring();\n    keyring->store(\"mysql_router1_user\", \"password\", \"root\");\n    mysql_harness::flush_keyring();\n    mysql_harness::reset_keyring();\n\n    // launch the router with metadata-cache configuration\n    auto default_section = get_DEFAULT_defaults();\n    default_section[\"keyring_path\"] = keyring_file;\n    default_section[\"master_key_path\"] = masterkey_file;\n    if (log_to_stdout) {\n      default_section[\"logging_folder\"] = \"\";\n    }\n    const std::string conf_file = create_config_file(metadata_cache_section + routing_section, &default_section);\n    auto router = RouterComponentTest::launch_router(\"-c \" +  conf_file, catch_stderr, with_sudo);\n    if (wait_ready) {\n      bool ready = wait_for_port_ready(router_port, 1000);\n      EXPECT_TRUE(ready) << get_router_log_output();\n    }\n\n    return router;\n  }\n\n  void kill_server(RouterComponentTest::CommandHandle& server) {\n    EXPECT_NO_THROW(server.kill()) << server.get_full_output();\n  }\n\n  TcpPortPool port_pool_;\n  unsigned wait_for_cache_ready_timeout{1000};\n  unsigned wait_for_static_ready_timeout{100};\n  unsigned wait_for_process_exit_timeout{10000};\n};\n\nstruct MetadataCacheTestParams {\n  std::string role;\n  std::string routing_strategy;\n  std::string mode;\n\n  // consecutive nodes ids that we expect to be connected to\n  std::vector<unsigned> expected_node_connections;\n  bool round_robin;\n\n  MetadataCacheTestParams(const std::string& role_,\n                           const std::string& routing_strategy_,\n                           const std::string& mode_,\n                           std::vector<unsigned> expected_node_connections_,\n                           bool round_robin_ = false):\n     role(role_),\n     routing_strategy(routing_strategy_),\n     mode(mode_),\n     expected_node_connections(expected_node_connections_),\n     round_robin(round_robin_) {}\n};\n\n::std::ostream& operator<<(::std::ostream& os, const MetadataCacheTestParams& mcp) {\n  return os << \"role=\" << mcp.role << \", routing_strtegy=\" << mcp.routing_strategy\n            << \", mode=\" << mcp.mode;\n}\n\nclass RouterRoutingStrategyMetadataCache : public RouterRoutingStrategyTest,\n                                           public ::testing::TestWithParam<MetadataCacheTestParams> {\nprotected:\n virtual void SetUp() {\n   RouterRoutingStrategyTest::SetUp();\n }\n};\n\n////////////////////////////////////////\n/// MATADATA-CACHE ROUTING TESTS\n////////////////////////////////////////\n\nTEST_P(RouterRoutingStrategyMetadataCache, MetadataCacheRoutingStrategy) {\n\n  auto test_params = GetParam();\n\n  const std::string temp_test_dir = get_tmp_dir();\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(temp_test_dir);});\n\n  const std::vector<unsigned> cluster_nodes_ports {\n    port_pool_.get_next_available(), // first is PRIMARY\n    port_pool_.get_next_available(),\n    port_pool_.get_next_available(),\n    port_pool_.get_next_available()\n  };\n\n  std::vector<RouterComponentTest::CommandHandle> cluster_nodes;\n\n  std::map<std::string, std::string> primary_json_env_vars = {\n    { \"PRIMARY_HOST\",     \"127.0.0.1:\" + std::to_string(cluster_nodes_ports[0]) },\n    { \"SECONDARY_1_HOST\", \"127.0.0.1:\" + std::to_string(cluster_nodes_ports[1]) },\n    { \"SECONDARY_2_HOST\", \"127.0.0.1:\" + std::to_string(cluster_nodes_ports[2]) },\n    { \"SECONDARY_3_HOST\", \"127.0.0.1:\" + std::to_string(cluster_nodes_ports[3]) },\n\n    { \"PRIMARY_PORT\",     std::to_string(cluster_nodes_ports[0]) },\n    { \"SECONDARY_1_PORT\", std::to_string(cluster_nodes_ports[1]) },\n    { \"SECONDARY_2_PORT\", std::to_string(cluster_nodes_ports[2]) },\n    { \"SECONDARY_3_PORT\", std::to_string(cluster_nodes_ports[3]) },\n\n    { \"MY_PORT\", std::to_string(cluster_nodes_ports[0]) },\n  };\n\n  // launch the primary node working also as metadata server\n  const std::string json_primary_node_template = get_data_dir().join(\"metadata_3_secondaries.js\").str();\n  const std::string json_primary_node = Path(temp_test_dir).join(\"metadata_3_secondaries.js\").str();\n  rewrite_js_to_tracefile(json_primary_node_template, json_primary_node, primary_json_env_vars);\n  auto primary_node = launch_mysql_server_mock(json_primary_node, cluster_nodes_ports[0], false);\n  bool ready = wait_for_port_ready(cluster_nodes_ports[0], 1000);\n  EXPECT_TRUE(ready) << primary_node.get_full_output();\n  cluster_nodes.emplace_back(std::move(primary_node));\n\n\n  // launch the router with metadata-cache configuration\n  const auto router_port = port_pool_.get_next_available();\n  const std::string metadata_cache_section = get_metadata_cache_section(cluster_nodes_ports[0]);\n  const std::string routing_section = get_metadata_cache_routing_section(router_port, test_params.role,\n                                                                         test_params.routing_strategy,\n                                                                         test_params.mode);\n  auto router = launch_router(router_port, temp_test_dir, metadata_cache_section, routing_section);\n\n  // launch the secondary cluster nodes\n  for (unsigned port = 1; port < cluster_nodes_ports.size(); ++port) {\n    auto secondary_node = launch_cluster_node(cluster_nodes_ports[port], get_data_dir().str(), temp_test_dir);\n    cluster_nodes.emplace_back( std::move(secondary_node) );\n  }\n\n  // give the router a chance to initialise metadata-cache module\n  // there is currently now easy way to check that\n  std::this_thread::sleep_for(std::chrono::milliseconds(wait_for_cache_ready_timeout));\n\n  if (!test_params.round_robin) {\n    // check if the server nodes are being used in the expected order\n    std::string node_port;\n    for (auto expected_node_id: test_params.expected_node_connections) {\n      connect_client_and_query_port(router_port, node_port);\n      EXPECT_EQ(std::to_string(cluster_nodes_ports[expected_node_id]), node_port);\n    }\n  }\n  else {\n    // for round-robin we can't be sure which server will be the starting one\n    // on Solaris wait_for_port_ready() causes the router to switch to the next server\n    // while on other OSes it does not.\n    // We check it the round robin is done on provided set od ids.\n    const auto& expected_nodes = test_params.expected_node_connections;\n    std::string node_port;\n    size_t first_port_id{0};\n    for (size_t i = 0; i < expected_nodes.size() + 1; ++i) { // + 1 to check that after\n                                                             // full round it strats from beginning\n      connect_client_and_query_port(router_port, node_port);\n      if (i == 0) { // first-connection\n        const auto& real_port_iter = std::find(cluster_nodes_ports.begin(), cluster_nodes_ports.end(),\n                                              (unsigned)std::atoi(node_port.c_str()));\n        ASSERT_NE(real_port_iter, cluster_nodes_ports.end());\n        auto port_id_ = real_port_iter - std::begin(cluster_nodes_ports);\n\n        EXPECT_TRUE( std::find(expected_nodes.begin(), expected_nodes.end(), port_id_) != expected_nodes.end() );\n        first_port_id = std::find(expected_nodes.begin(), expected_nodes.end(), port_id_) - expected_nodes.begin();\n      } else {\n        const auto current_idx = (first_port_id + i) %  expected_nodes.size();\n        const auto expected_node_id = expected_nodes[current_idx];\n        EXPECT_EQ(std::to_string(cluster_nodes_ports[expected_node_id]), node_port);\n      }\n    }\n  }\n\n  ASSERT_THAT(router.kill(), testing::Eq(0));\n}\n\nINSTANTIATE_TEST_CASE_P(MetadataCacheRoutingStrategy,\n                        RouterRoutingStrategyMetadataCache,\n                        // node_id=0 is PRIARY, node_id=1..3 are SECONDARY\n                        ::testing::Values(\n                            // test round-robin on SECONDARY servers\n                            // we expect 1->2->3->1 for 4 consecutive connections\n                            MetadataCacheTestParams(\"SECONDARY\",  \"round-robin\", \"\", {1,2,3},\n                                                    /*round-robin=*/true),\n\n                            // test first-available on SECONDARY servers\n                            // we expect 1->1->1 for 3 consecutive connections\n                            MetadataCacheTestParams(\"SECONDARY\",  \"first-available\", \"\", {1,1,1}),\n\n                            // *basic* test round-robin-with-fallback\n                            // we expect 1->2->3->1 for 4 consecutive connections\n                            // as there are SECONDARY servers available (PRIMARY id=0 should not be used)\n                            MetadataCacheTestParams(\"SECONDARY\",  \"round-robin-with-fallback\", \"\", {1,2,3},\n                                                    /*round-robin=*/true),\n\n                            // test round-robin on PRIMARY_AND_SECONDARY\n                            // we expect the primary to participate in the round-robin from the beginning\n                            // we expect 0->1->2->3->0 for 5 consecutive connections\n                            MetadataCacheTestParams(\"PRIMARY_AND_SECONDARY\",  \"round-robin\", \"\", {0,1,2,3},\n                                                    /*round-robin=*/true),\n\n                            // test round-robin with allow-primary-reads=yes\n                            // this should work similar to PRIMARY_AND_SECONDARY\n                            // we expect 0->1->2->3->0 for 5 consecutive connections\n                            MetadataCacheTestParams(\"SECONDARY&allow_primary_reads=yes\", \"\", \"read-only\", {0,1,2,3},\n                                                    /*round-robin=*/true),\n\n                            // test first-available on PRIMARY\n                            // we expect 0->0->0 for 2 consecutive connections\n                            MetadataCacheTestParams(\"PRIMARY\",  \"first-available\", \"\", {0, 0}),\n\n                            // test round-robin on PRIMARY\n                            // there is single primary so we expect 0->0->0 for 2 consecutive connections\n                            MetadataCacheTestParams(\"PRIMARY\",  \"round-robin\", \"\", {0, 0})\n                          )\n                        );\n\n\n////////////////////////////////////////\n/// STATIC ROUTING TESTS\n////////////////////////////////////////\n\nclass RouterRoutingStrategyTestRoundRobin : public RouterRoutingStrategyTest,\n                                                                                   // r. strategy, mode\n                                            public ::testing::TestWithParam<std::pair<std::string, std::string>> {\nprotected:\n virtual void SetUp() {\n   RouterRoutingStrategyTest::SetUp();\n }\n};\n\nTEST_P(RouterRoutingStrategyTestRoundRobin, StaticRoutingStrategyRoundRobin) {\n  const std::string temp_test_dir = get_tmp_dir();\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(temp_test_dir);});\n\n  const std::vector<unsigned> server_ports {\n    port_pool_.get_next_available(),\n    port_pool_.get_next_available(),\n    port_pool_.get_next_available()\n  };\n\n  // launch the standalone servers\n  std::vector<RouterComponentTest::CommandHandle> server_instances;\n  for (auto& server_port: server_ports) {\n    auto secondary_node = launch_standalone_server(server_port, get_data_dir().str(), temp_test_dir);\n    server_instances.emplace_back( std::move(secondary_node) );\n  }\n\n  // launch the router with the static configuration\n  const auto router_port = port_pool_.get_next_available();\n\n  const auto routing_strategy = GetParam().first;\n  const auto mode = GetParam().second;\n  const std::string routing_section =\n      get_static_routing_section(router_port, server_ports, routing_strategy, mode);\n  auto router = launch_router_static(router_port, routing_section);\n\n  std::this_thread::sleep_for(std::chrono::milliseconds(wait_for_static_ready_timeout));\n\n\n  // expect consecutive connections to be done in round-robin fashion\n  // will start with the second because wait_for_port_ready on the router will\n  // cause it to switch\n  std::string node_port;\n  connect_client_and_query_port(router_port, node_port);\n  EXPECT_EQ(std::to_string(server_ports[1]), node_port);\n  connect_client_and_query_port(router_port, node_port);\n  EXPECT_EQ(std::to_string(server_ports[2]), node_port);\n  connect_client_and_query_port(router_port, node_port);\n  EXPECT_EQ(std::to_string(server_ports[0]), node_port);\n  connect_client_and_query_port(router_port, node_port);\n  EXPECT_EQ(std::to_string(server_ports[1]), node_port);\n}\n\n// We expect round robin for routing-strategy=round-robin and as default for read-only\nINSTANTIATE_TEST_CASE_P(StaticRoutingStrategyRoundRobin,\n                        RouterRoutingStrategyTestRoundRobin,\n                        ::testing::Values(\n                          std::make_pair(std::string(\"round-robin\"), std::string(\"\")),\n                          std::make_pair(std::string(\"round-robin\"), std::string(\"read-only\")),\n                          std::make_pair(std::string(\"round-robin\"), std::string(\"read-write\")),\n                          std::make_pair(std::string(\"\"), std::string(\"read-only\"))\n                          )\n                        );\n\nclass RouterRoutingStrategyTestFirstAvailable : public RouterRoutingStrategyTest,\n                                                                                       // r. strategy, mode\n                                                public ::testing::TestWithParam<std::pair<std::string, std::string>> {\nprotected:\n virtual void SetUp() {\n   RouterRoutingStrategyTest::SetUp();\n }\n};\n\nTEST_P(RouterRoutingStrategyTestFirstAvailable, StaticRoutingStrategyFirstAvailable) {\n  const std::string temp_test_dir = get_tmp_dir();\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(temp_test_dir);});\n\n  const std::vector<unsigned> server_ports {\n    port_pool_.get_next_available(),\n    port_pool_.get_next_available(),\n    port_pool_.get_next_available()\n  };\n\n  // launch the standalone servers\n  std::vector<RouterComponentTest::CommandHandle> server_instances;\n  for (auto& server_port: server_ports) {\n    auto secondary_node = launch_standalone_server(server_port, get_data_dir().str(), temp_test_dir);\n    server_instances.emplace_back( std::move(secondary_node) );\n  }\n\n  // launch the router with the static configuration\n  const auto router_port = port_pool_.get_next_available();\n\n\n  const auto routing_strategy = GetParam().first;\n  const auto mode = GetParam().second;\n  const std::string routing_section =\n      get_static_routing_section(router_port, server_ports, routing_strategy, mode);\n  auto router = launch_router_static(router_port, routing_section);\n\n  std::this_thread::sleep_for(std::chrono::milliseconds(100));\n\n  // expect consecutive connections to be done in first-available fashion\n  std::string node_port;\n  connect_client_and_query_port(router_port, node_port);\n  EXPECT_EQ(std::to_string(server_ports[0]), node_port);\n  connect_client_and_query_port(router_port, node_port);\n  EXPECT_EQ(std::to_string(server_ports[0]), node_port);\n\n  // \"kill\" server 1 and 2, expect moving to server 3\n  kill_server(server_instances[0]);\n  kill_server(server_instances[1]);\n  // now we should connect to 3rd server\n  connect_client_and_query_port(router_port, node_port);\n  EXPECT_EQ(std::to_string(server_ports[2]), node_port);\n\n  // kill also 3rd server\n  kill_server(server_instances[2]);\n  // expect connection failure\n  connect_client_and_query_port(router_port, node_port, /*should_fail=*/true);\n  EXPECT_EQ(\"\", node_port);\n\n  // bring back 1st server\n  server_instances.emplace_back(launch_standalone_server(server_ports[0], get_data_dir().str(), temp_test_dir));\n  // we should now succesfully connect to this server\n  connect_client_and_query_port(router_port, node_port);\n  EXPECT_EQ(std::to_string(server_ports[0]), node_port);\n}\n\n// We expect first-available for routing-strategy=first-available and as default for read-write\nINSTANTIATE_TEST_CASE_P(StaticRoutingStrategyFirstAvailable,\n                        RouterRoutingStrategyTestFirstAvailable,\n                        ::testing::Values(\n                          std::make_pair(std::string(\"first-available\"), std::string(\"\")),\n                          std::make_pair(std::string(\"first-available\"), std::string(\"read-write\")),\n                          std::make_pair(std::string(\"first-available\"), std::string(\"read-only\")),\n                          std::make_pair(std::string(\"\"), std::string(\"read-write\"))\n                          )\n                        );\n\n// for non-param tests\nclass RouterRoutingStrategyStatic : public RouterRoutingStrategyTest,\n                                    public ::testing::Test {\nprotected:\n virtual void SetUp() {\n   RouterRoutingStrategyTest::SetUp();\n }\n};\n\nTEST_F(RouterRoutingStrategyStatic, StaticRoutingStrategyNextAvailable) {\n  const std::string temp_test_dir = get_tmp_dir();\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(temp_test_dir);});\n\n  const std::vector<unsigned> server_ports {\n    port_pool_.get_next_available(),\n    port_pool_.get_next_available(),\n    port_pool_.get_next_available()\n  };\n\n  // launch the standalone servers\n  std::vector<RouterComponentTest::CommandHandle> server_instances;\n  for (auto& server_port: server_ports) {\n    auto secondary_node = launch_standalone_server(server_port, get_data_dir().str(), temp_test_dir);\n    server_instances.emplace_back( std::move(secondary_node) );\n  }\n\n  // launch the router with the static configuration\n  const auto router_port = port_pool_.get_next_available();\n  const std::string routing_section =\n      get_static_routing_section(router_port, server_ports, \"next-available\");\n  auto router = launch_router_static(router_port, routing_section);\n\n  std::this_thread::sleep_for(std::chrono::milliseconds(100));\n\n\n  // expect consecutive connections to be done in first-available fashion\n  std::string node_port;\n  connect_client_and_query_port(router_port, node_port);\n  EXPECT_EQ(std::to_string(server_ports[0]), node_port);\n  connect_client_and_query_port(router_port, node_port);\n  EXPECT_EQ(std::to_string(server_ports[0]), node_port);\n\n  // \"kill\" server 1 and 2, expect connection to server 3 after that\n  kill_server(server_instances[0]);\n  kill_server(server_instances[1]);\n  // now we should connect to 3rd server\n  connect_client_and_query_port(router_port, node_port);\n  EXPECT_EQ(std::to_string(server_ports[2]), node_port);\n\n  // kill also 3rd server\n  kill_server(server_instances[2]);\n  // expect connection failure\n  connect_client_and_query_port(router_port, node_port, /*should_fail=*/true);\n  EXPECT_EQ(\"\", node_port);\n\n  // bring back 1st server\n  server_instances.emplace_back(launch_standalone_server(server_ports[0], get_data_dir().str(), temp_test_dir));\n  // we should NOT connect to this server (in next-available we NEVER go back)\n  connect_client_and_query_port(router_port, node_port, /*should_fail=*/true);\n  EXPECT_EQ(\"\", node_port);\n}\n\n// configuration error scenarios\n\nTEST_F(RouterRoutingStrategyStatic, InvalidStrategyName) {\n  const std::string temp_test_dir = get_tmp_dir();\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(temp_test_dir);});\n\n  // launch the router with the static configuration\n  const auto router_port = port_pool_.get_next_available();\n  const std::string routing_section =\n      get_static_routing_section_error(router_port, {1, 2}, \"round-robin-with-fallback\", \"read-only\");\n  auto router = launch_router_static(router_port, routing_section, /*expect_error=*/true);\n\n  EXPECT_EQ(router.wait_for_exit(wait_for_process_exit_timeout), 1);\n  EXPECT_TRUE(router.expect_output(\"Configuration error: option routing_strategy in [routing:test_default] is invalid; \"\n                                    \"valid are first-available, next-available, and round-robin (was 'round-robin-with-fallback'\"))\n                                    << get_router_log_output();\n}\n\nTEST_F(RouterRoutingStrategyStatic, InvalidMode) {\n  const std::string temp_test_dir = get_tmp_dir();\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(temp_test_dir);});\n\n  // launch the router with the static configuration\n  const auto router_port = port_pool_.get_next_available();\n  const std::string routing_section =\n      get_static_routing_section_error(router_port, {1, 2}, \"invalid\", \"read-only\");\n  auto router = launch_router_static(router_port, routing_section, /*expect_error=*/true);\n\n  EXPECT_EQ(router.wait_for_exit(wait_for_process_exit_timeout), 1);\n  EXPECT_TRUE(router.expect_output(\"option routing_strategy in [routing:test_default] is invalid; valid are first-available, next-available, and round-robin (was 'invalid')\"))\n                                    << get_router_log_output();\n}\n\nTEST_F(RouterRoutingStrategyStatic, BothStrategyAndModeMissing) {\n  const std::string temp_test_dir = get_tmp_dir();\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(temp_test_dir);});\n\n  // launch the router with the static configuration\n  const auto router_port = port_pool_.get_next_available();\n  const std::string routing_section =\n      get_static_routing_section(router_port, {1, 2}, \"\");\n  auto router = launch_router_static(router_port, routing_section, /*expect_error=*/true);\n\n  EXPECT_EQ(router.wait_for_exit(wait_for_process_exit_timeout), 1);\n  EXPECT_TRUE(router.expect_output(\"Configuration error: option routing_strategy in [routing:test_default] is required\"))\n                                    << get_router_log_output();\n}\n\nTEST_F(RouterRoutingStrategyStatic, RoutingSrtategyEmptyValue) {\n  const std::string temp_test_dir = get_tmp_dir();\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(temp_test_dir);});\n\n  // launch the router with the static configuration\n  const auto router_port = port_pool_.get_next_available();\n  const std::string routing_section =\n      get_static_routing_section_error(router_port, {1, 2}, \"\", \"read-only\");\n  auto router = launch_router_static(router_port, routing_section, /*expect_error=*/true);\n\n  EXPECT_EQ(router.wait_for_exit(wait_for_process_exit_timeout), 1);\n  EXPECT_TRUE(router.expect_output(\"Configuration error: option routing_strategy in [routing:test_default] needs a value\"))\n                                    << get_router_log_output();\n}\n\nTEST_F(RouterRoutingStrategyStatic, ModeEmptyValue) {\n  const std::string temp_test_dir = get_tmp_dir();\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){purge_dir(temp_test_dir);});\n\n  // launch the router with the static configuration\n  const auto router_port = port_pool_.get_next_available();\n  const std::string routing_section =\n      get_static_routing_section_error(router_port, {1, 2}, \"first-available\", \"\");\n  auto router = launch_router_static(router_port, routing_section, /*expect_error=*/true);\n\n  EXPECT_EQ(router.wait_for_exit(wait_for_process_exit_timeout), 1);\n  EXPECT_TRUE(router.expect_output(\"Configuration error: option mode in [routing:test_default] needs a value\"))\n                                    << get_router_log_output();\n}\n\n\nint main(int argc, char *argv[]) {\n  init_windows_sockets();\n  g_origin_path = Path(argv[0]).dirname();\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "tests/component/test_user_option.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"gmock/gmock.h\"\n#include \"router_component_test.h\"\n\nPath g_origin_path;\n\nclass RouterUserOptionTest : public RouterComponentTest, public ::testing::Test {\n protected:\n  virtual void SetUp() {\n    set_origin(g_origin_path);\n    RouterComponentTest::SetUp();\n  }\n};\n\n// --user option is not supported on Windows\n#ifndef _WIN32\n\n// check that using --user with no sudo gives a proper error\nTEST_F(RouterUserOptionTest, UserOptionNoSudo) {\n  auto router = launch_router(\"--bootstrap=127.0.0.1:5000 --user=mysqlrouter\");\n\n  EXPECT_EQ(router.wait_for_exit(), 1);\n  EXPECT_TRUE(router.expect_output(\"Error: One can only use the -u/--user switch if running as root\")) << router.get_full_output();\n\n  // That's more to test the framework itself:\n  // The consecutive calls to exit_code() should be possible  and return the same value\n  EXPECT_EQ(router.exit_code(), 1);\n  EXPECT_EQ(router.exit_code(), 1);\n}\n\n// check that using --user parameter before --bootstrap gives a proper error\nTEST_F(RouterUserOptionTest, UserOptionBeforeBootstrap) {\n  auto router = launch_router(\"--user=mysqlrouter --bootstrap=127.0.0.1:5000\");\n\n  EXPECT_EQ(router.wait_for_exit(), 1);\n  EXPECT_TRUE(router.expect_output(\"Error: One can only use the -u/--user switch if running as root\")) << router.get_full_output();\n\n  EXPECT_EQ(router.exit_code(), 1);\n}\n\n#else\n// check that it really is not supported on Windows\nTEST_F(RouterUserOptionTest, UserOptionOnWindows) {\n  auto router = launch_router(\"--bootstrap=127.0.0.1:5000 --user=mysqlrouter\");\n\n  ASSERT_TRUE(router.expect_output(\"Error: unknown option '--user'.\")\n    ) << router.get_full_output();\n  ASSERT_EQ(router.wait_for_exit(), 1);\n}\n#endif\n\nint main(int argc, char *argv[]) {\n   g_origin_path = Path(argv[0]).dirname();\n\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "tests/coverage.ignore",
    "content": "# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n# This file lists directories or files to ignore when reporting\n# coverage %. An extra step will remove them from the coverage data.\n# You may list individual files or (more typically) directories.\n# Do not use shell wildcards and such, they will not work.\n\next\nresult/generated\n\nsrc/harness/tests/\nsrc/metadata_cache/tests\nsrc/mysql_protocol/tests\nsrc/router/tests\nsrc/routing/tests\ntests\n\n"
  },
  {
    "path": "tests/fuzzers/CMakeLists.txt",
    "content": "# Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\ninclude(CMakePushCheckState)\n\n# check if clang knows about the coverage and trace-pc-guard\n\n# llvm 4.0+\ncmake_push_check_state(RESET)\nset(CMAKE_REQUIRED_FLAGS \"-fsanitize-coverage=trace-pc-guard\")\ncheck_cxx_compiler_flag(\"-fsanitize-coverage=trace-pc-guard\" COMPILER_HAS_SANITIZE_COVERAGE_TRACE_PC_GUARD)\ncmake_pop_check_state()\n\n# llvm 3.8+\ncmake_push_check_state(RESET)\nset(CMAKE_REQUIRED_FLAGS \"-fsanitize-coverage=edge\")\ncheck_cxx_compiler_flag(\"-fsanitize-coverage=edge\" COMPILER_HAS_SANITIZE_COVERAGE_TRACE_EDGE)\ncmake_pop_check_state()\n\n# http://llvm.org/docs/LibFuzzer.html#tracing-cmp-instructions\ncmake_push_check_state(RESET)\nset(CMAKE_REQUIRED_FLAGS \"-fsanitize-coverage=trace-cmp\")\ncheck_cxx_compiler_flag(\"-fsanitize-coverage=trace-cmp\" COMPILER_HAS_SANITIZE_COVERAGE_TRACE_CMP)\ncmake_pop_check_state()\n\ncmake_push_check_state(RESET)\ncheck_cxx_compiler_flag(\"-fprofile-instr-generate\" COMPILER_HAS_PROFILE_INSTR_GENERATE)\ncmake_pop_check_state()\n\ncmake_push_check_state(RESET)\n# invalid argument '-fcoverage-mapping' only allowed with '-fprofile-instr-generate'\nset(CMAKE_REQUIRED_FLAGS \"-fprofile-instr-generate\")\ncheck_cxx_compiler_flag(\"-fcoverage-mapping\" COMPILER_HAS_COVERAGE_MAPPING)\ncmake_pop_check_state()\n\n\nif (CMAKE_CXX_COMPILER_ID STREQUAL \"Clang\")\n  if (COMPILER_HAS_SANITIZE_COVERAGE_TRACE_PC_GUARD)\n    set(SANITIZE_COVERAGE_FLAGS \"-fsanitize-coverage=trace-pc-guard\")\n  elseif (COMPILER_HAS_SANITIZE_COVERAGE_TRACE_EDGE)\n    set(SANITIZE_COVERAGE_FLAGS \"-fsanitize-coverage=edge\")\n  endif()\n\n  # check that libFuzzer is found\n  #\n  # check_library_exists() doesn't work here as it would provide a main() which calls\n  # a test-function ... which collides with libFuzzer's main():\n  #\n  # if the libFuzzer is found by the compiler it will provide a 'main()' and\n  # require that we provide a 'LLVMFuzzerTestOneInput' at link-time.\n  if (SANITIZE_COVERAGE_FLAGS)\n    cmake_push_check_state(RESET)\n    set(CMAKE_REQUIRED_LIBRARIES Fuzzer)\n    set(CMAKE_REQUIRED_FLAGS ${SANITIZE_COVERAGE_FLAGS})\n    check_cxx_source_compiles(\"extern \\\"C\\\" int LLVMFuzzerTestOneInput(void *, int) { return 0; }\" CLANG_HAS_LIBFUZZER)\n    cmake_pop_check_state()\n  endif()\n\n  if (CLANG_HAS_LIBFUZZER)\n    set(LIBFUZZER_LIBRARIES Fuzzer)\n    set(LIBFUZZER_LINK_FLAGS ${SANITIZE_COVERAGE_FLAGS})\n    set(LIBFUZZER_COMPILE_FLAGS)\n    list(APPEND LIBFUZZER_COMPILE_FLAGS ${SANITIZE_COVERAGE_FLAGS})\n\n    if (COMPILER_HAS_PROFILE_INSTR_GENERATE)\n      list(APPEND LIBFUZZER_COMPILE_FLAGS -fprofile-instr-generate)\n      set(LIBFUZZER_LINK_FLAGS \"${LIBFUZZER_LINK_FLAGS} -fprofile-instr-generate\")\n      list(APPEND LIBFUZZER_COMPILE_FLAGS -fcoverage-mapping)\n    endif()\n  endif()\nendif()\n\n\nset(FUZZ_TARGETS)\nset(FUZZ_COVERAGE_TARGETS)\n\nmacro(FUZZ FUZZ_TARGET)\n  set(FUZZ_MAX_TOTAL_TIME 10)\n  set(FUZZ_TIMEOUT 0.1)\n\n\n  add_custom_target(${FUZZ_TARGET}_mkdir_corpus\n    COMMAND ${CMAKE_COMMAND} -E make_directory \"${CMAKE_CURRENT_BINARY_DIR}/corpus/${FUZZ_TARGET}\"\n  )\n  add_custom_target(${FUZZ_TARGET}_mkdir_artificats\n    COMMAND ${CMAKE_COMMAND} -E make_directory \"${CMAKE_CURRENT_BINARY_DIR}/artifacts/${FUZZ_TARGET}\"\n  )\n\n  # use cmake -E env to set the LLVM_PROFILE_FILE in a portable way\n  add_custom_target(${FUZZ_TARGET}_run\n    COMMAND ${CMAKE_COMMAND} -E env LLVM_PROFILE_FILE=${CMAKE_CURRENT_BINARY_DIR}/${FUZZ_TARGET}.profraw $<TARGET_FILE:${FUZZ_TARGET}> -max_total_time=${FUZZ_MAX_TOTAL_TIME} -timeout=${FUZZ_TIMEOUT} -artifact_prefix=${CMAKE_CURRENT_BINARY_DIR}/artifacts/${FUZZ_TARGET}/ ${CMAKE_CURRENT_BINARY_DIR}/corpus/${FUZZ_TARGET}/ ${CMAKE_CURRENT_SOURCE_DIR}/corpus/${FUZZ_TARGET}/\n    DEPENDS ${FUZZ_TARGET} ${FUZZ_TARGET}_mkdir_artificats ${FUZZ_TARGET}_mkdir_corpus\n    COMMENT \"Runnning ${FUZZ_TARGET} for ${FUZZ_MAX_TOTAL_TIME} seconds\"\n  )\n\n  list(APPEND FUZZ_TARGETS \"${FUZZ_TARGET}_run\")\n\n  if (COMPILER_HAS_PROFILE_INSTR_GENERATE AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER \"3.8\")\n    # detect the major-minor of the clang++ as we have to call the same-version llvm-profdata\n    #\n    # if we got clang 4.0, then we have to call llvm-cov 4.0 too. On Ubuntu (and elsewhere) parallel installs\n    # use the style:\n    #\n    # clang-4.0\n    # llvm-cov-4.0\n    #\n    # and may have a fallback to llvm-cov.\n    #\n    # Prefer the longer names.\n    execute_process( COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE clang_full_version_string )\n    string (REGEX REPLACE \".*clang version ([0-9]+\\\\.[0-9]+).*\" \"\\\\1\" CLANG_VERSION_STRING ${clang_full_version_string})\n\n    find_program(LLVM_PROFDATA llvm-profdata-${CLANG_VERSION_STRING} llvm-profdata)\n    add_custom_command(OUTPUT ${FUZZ_TARGET}.profdata\n      COMMAND ${LLVM_PROFDATA} merge -sparse ${FUZZ_TARGET}.profraw -o ${FUZZ_TARGET}.profdata\n      DEPENDS ${FUZZ_TARGET}_run\n    )\n    find_program(LLVM_COV llvm-cov-${CLANG_VERSION_STRING} llvm-cov)\n    add_custom_command(OUTPUT ${FUZZ_TARGET}-coverage.html\n      COMMAND ${LLVM_COV} show $<TARGET_FILE:${FUZZ_TARGET}> -instr-profile=${FUZZ_TARGET}.profdata -format=html > ${FUZZ_TARGET}-coverage.html\n      DEPENDS ${FUZZ_TARGET}.profdata\n    )\n\n    list(APPEND FUZZ_COVERAGE_TARGETS \"${FUZZ_TARGET}-coverage.html\")\n  endif()\nendmacro()\n\nif (CLANG_HAS_LIBFUZZER)\n  set(FUZZ_TARGET fuzz_router_uri)\n\n  # FIXME: uri.cc depends on split_string() from utils.cc which pulls in the whole harness.\n  # utils.cc should be split into a smaller chunks (string, file, ...) to allow to build\n  # directly against it.\n  #\n  add_executable(${FUZZ_TARGET}\n    fuzz_router_uri.cc\n    ${PROJECT_SOURCE_DIR}/src/router/src/uri.cc\n    ${PROJECT_SOURCE_DIR}/src/router/src/utils.cc\n  )\n\n  set_target_properties(\n    ${FUZZ_TARGET}\n    PROPERTIES\n    COMPILE_OPTIONS \"${LIBFUZZER_COMPILE_FLAGS}\"\n    LINK_FLAGS \"${LIBFUZZER_LINK_FLAGS}\"\n    )\n  target_link_libraries(${FUZZ_TARGET} harness-library ${MySQL_LIBRARIES} ${SSL_LIBRARIES} ${LIBFUZZER_LIBRARIES})\n  target_include_directories(${FUZZ_TARGET}\n    PRIVATE\n    ${PROJECT_SOURCE_DIR}/src/router/include/)\n  fuzz(${FUZZ_TARGET})\n\n\n  set(FUZZ_TARGET fuzz_router_uri_tostring)\n\n  # FIXME: uri.cc depends on split_string() from utils.cc which pulls in the whole harness.\n  # utils.cc should be split into a smaller chunks (string, file, ...) to allow to build\n  # directly against it.\n  #\n  add_executable(${FUZZ_TARGET}\n    fuzz_router_uri_tostring.cc\n    ${PROJECT_SOURCE_DIR}/src/router/src/uri.cc\n    ${PROJECT_SOURCE_DIR}/src/router/src/utils.cc\n  )\n\n  set_target_properties(\n    ${FUZZ_TARGET}\n    PROPERTIES\n    COMPILE_OPTIONS \"${LIBFUZZER_COMPILE_FLAGS}\"\n    LINK_FLAGS \"${LIBFUZZER_LINK_FLAGS}\"\n    )\n  target_link_libraries(${FUZZ_TARGET} harness-library ${MySQL_LIBRARIES} ${SSL_LIBRARIES} ${LIBFUZZER_LIBRARIES})\n  target_include_directories(${FUZZ_TARGET}\n    PRIVATE\n    ${PROJECT_SOURCE_DIR}/src/router/include/)\n  fuzz(${FUZZ_TARGET})\n\nendif()\n\nadd_custom_target(fuzz_coverage\n  DEPENDS ${FUZZ_COVERAGE_TARGETS}\n  COMMENT \"Generatoring Coverage data\")\n\nadd_custom_target(fuzz\n  DEPENDS ${FUZZ_TARGETS}\n  COMMENT \"Running fuzzers\")\n"
  },
  {
    "path": "tests/fuzzers/README.txt",
    "content": "Prepare\n-------\n\n* clang 3.9 and higher\n* libFuzzer\n\n\ncmake will check if the clang version works as expected::\n\n  -- Performing Test COMPILER_HAS_SANITIZE_COVERAGE_TRACE_PC_GUARD\n  -- Performing Test COMPILER_HAS_SANITIZE_COVERAGE_TRACE_PC_GUARD - Success\n  -- Performing Test COMPILER_HAS_PROFILE_INSTR_GENERATE\n  -- Performing Test COMPILER_HAS_PROFILE_INSTR_GENERATE - Success\n  -- Performing Test COMPILER_HAS_COVERAGE_MAPPING\n  -- Performing Test COMPILER_HAS_COVERAGE_MAPPING - Success\n  -- Performing Test CLANG_HAS_LIBFUZZER\n  -- Performing Test CLANG_HAS_LIBFUZZER - Success\n\nRun\n---\n\n$ make fuzz\n\nruns all fuzzers for 10 seconds\n\nCoverage\n--------\n\n$ make fuzz-coverage.html\n\ncreates\n\n./tests/fuzzers/*-coverage.html\n"
  },
  {
    "path": "tests/fuzzers/corpus/fuzz_router_uri/uri-1",
    "content": "ham://scott:tiger@spam.example.com:80\n"
  },
  {
    "path": "tests/fuzzers/corpus/fuzz_router_uri/uri-2",
    "content": "m+f://%40u:f%40b%40@1.2.3.4/f/?f=f&c=b#f\n"
  },
  {
    "path": "tests/fuzzers/corpus/fuzz_router_uri/uri-3",
    "content": "m+f://[::1%25foo]/f/?f=f&c=b#f\n"
  },
  {
    "path": "tests/fuzzers/corpus/fuzz_router_uri_tostring/uri-ipv6-zoneid",
    "content": "u://u:p@[::1%lo]:80/p/p?k=v&l=m#f\n"
  },
  {
    "path": "tests/fuzzers/fuzz_router_uri.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <exception>\n\n#include \"mysqlrouter/uri.h\"\n\nusing mysqlrouter::URIError;\nusing mysqlrouter::URIParser;\n\nextern \"C\" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {\n  try {\n    // we don't care about the result\n    URIParser::parse(std::string(Data, Data + Size));\n  } catch(URIError &e) {\n    // URIError exceptions are fine, everything else is forbidden.\n  }\n\n  return 0;\n}\n"
  },
  {
    "path": "tests/fuzzers/fuzz_router_uri_tostring.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <exception>\n#include <sstream>\n\n#include \"mysqlrouter/uri.h\"\n\nusing mysqlrouter::URIError;\nusing mysqlrouter::URIParser;\nusing mysqlrouter::URI;\n\nextern \"C\" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {\n  URI uri_a;\n\n  /*\n   * assume that every valid URI that we parse can be:\n   *\n   * 1) turned into a string\n   * 2) parsed again without exceptions\n   * 3) turned into a string again that matches the string of 1)\n   */\n\n  try {\n    // turn the random input into something we can turn into a string\n    uri_a = URIParser::parse(std::string(Data, Data + Size));\n  } catch(URIError &e) {\n    // ignore parse errors\n    return 0;\n  }\n\n  // shouldn't throw\n  std::ostringstream uri_a_ss;\n\n  uri_a_ss << uri_a;\n\n  // parse what we generated. It shouldn't throw.\n  URI uri_b(URIParser::parse(uri_a_ss.str()));\n\n  if (uri_a != uri_b) {\n    std::string err(\"URI fields differ: \");\n\n#define APPEND_IF_NE(a, b, fld) \\\n    if (a.fld != b.fld) err += std::string(#fld \": \") + a.fld + \" != \" + b.fld + \", \";\n\n    APPEND_IF_NE(uri_a, uri_b, scheme);\n    APPEND_IF_NE(uri_a, uri_b, host);\n    if (uri_a.port != uri_b.port) err += std::string(\"port: \") + std::to_string(uri_a.port) + \" != \" + std::to_string(uri_b.port) + \", \";\n    APPEND_IF_NE(uri_a, uri_b, username);\n    APPEND_IF_NE(uri_a, uri_b, password);\n\n    // TODO: map/array printer\n    if (uri_a.path != uri_b.path) err += std::string(\"path: <skipped>\") + \", \";\n    if (uri_a.query != uri_b.query) err += std::string(\"query: <skipped>\") + \", \";\n    APPEND_IF_NE(uri_a, uri_b, fragment);\n#undef APPEND_IF_NE\n\n    throw std::runtime_error(err);\n  }\n  // the components should be equal too\n  // and it should be equal to what we fed to the parser.\n  std::ostringstream uri_b_ss;\n\n  uri_b_ss << uri_b;\n\n  if (uri_a_ss.str() != uri_b_ss.str()) {\n    throw std::runtime_error(\"URIs differ: \" + uri_a_ss.str() + \" != \" + uri_b_ss.str());\n  }\n\n  return 0;\n}\n"
  },
  {
    "path": "tests/gcoverage.sh",
    "content": "#!/bin/sh\n\n# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n#\n# This program is free software; you can redistribute it and/or modify\n# it under the terms of the GNU General Public License, version 2.0,\n# as published by the Free Software Foundation.\n#\n# This program is also distributed with certain software (including\n# but not limited to OpenSSL) that is licensed under separate terms,\n# as designated in a particular file or component or in included license\n# documentation.  The authors of MySQL hereby grant you an additional\n# permission to link the program and your derivative works with the\n# separately licensed software that they have included with MySQL.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with this program; if not, write to the Free Software\n# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n\n#\n# Shell script gathering coverage information and generating HTML report\n#\n# Depends on lcov.pl and genhtml which should be best installed through the\n# Linux distribution's packaging system.\n#\n\nLCOV=`which lcov`\nGENHTML=`which genhtml`\nGCOVINFO=\"mysqlrouter_coverage.info\"\nFORCE=0\nHTMLOUTDIR=  # no default\n\nerrecho() {\n  >&2 echo \"$@\";\n}\n\n# Check dependencies\nif [ -z $LCOV ]; then\n  errecho \"Please make sure 'lcov' is installed and available.\"\n  exit 1\nelif [ -z $GENHTML ]; then\n  errecho \"Please make sure 'genhtml' is installed and available.\"\n  exit 1\nfi\n\nwhile getopts \"ho:f\" option; do\n  case \"$option\" in\n    h)\n      echo \"Usage: $0 [-o /path/to/html/output/] [-f]\"\n      echo \"  -f     Force using output folder by deleting its content\"\n      echo \"  -o     Output folder for genhtml\"\n      exit 0\n      ;;\n    o)\n      HTMLOUTDIR=$OPTARG\n      ;;\n    f)\n      FORCE=1\n      ;;\n    *)\n      echo \"Unknown option $option\"\n      exit 2\n      ;;\n  esac\ndone\n\ngcno_cnt=`find . -name *.gcno 2>/dev/null | grep -c gcno`\nif [ $gcno_cnt -eq 0 ]; then\n    errecho \"No gcno files found. CMake option -DENABLE_GCOV=yes should be used; tests and/or binary should be executed.\"\n    exit 1\nfi\n\n# Create the HTML Output folder\nif [ -z $HTMLOUTDIR ]; then\n  errecho \"Use -o option to specify where the HTML report should be stored.\"\n  exit 1\nfi\nmkdir $HTMLOUTDIR 2>/dev/null\nif [ $? -ne 0 ]; then\n  # First whether the output folder is empty, if it exists\n  if [ -d $HTMLOUTDIR ] && [ \"`ls -A $HTMLOUTDIR`\" != \"\" ]; then\n    if [ $FORCE -eq 1 ]; then\n      rm -Rf $HTMLOUTDIR/*\n    else\n      errecho \"Make sure HTML output folder is empty or does not exists. Use -f to force emptying folder.\"\n      exit 1\n    fi\n  fi\n  if [ ! -d $HTMLOUTDIR ]; then\n    errecho \"Failed creating HTML ouptut folder. Please check $HTMLOUTDIR.\"\n    exit 1\n  fi\nfi\n\n# Gather coverage information\nrm $GCOVINFO 2>/dev/null\n$LCOV -q -b ./src -d ./src -c -o $GCOVINFO\nif [ $? -ne 0 ]; then\n  errecho \"Failed executing $LCOV while gathering coverage information\"\n  exit 1\nfi\nif [ ! -s $GCOVINFO ]; then\n  errecho \"Coverage information file not available.\"\n  errecho \"See possible warnings/errors in above messages.\"\n  exit 1\nfi\n\n# Remove folders for which we do not want to generate coverage statistics\n$LCOV -q --remove $GCOVINFO \"/usr*\" \"*mysql_harness*\" \"*tests/helpers*\" \"ext/*\" \"generated/protobuf/*\"  -o $GCOVINFO\nif [ $? -ne 0 ]; then\n  errecho \"Failed executing $LCOV while removing folders from coverage information\"\n  exit 1\nfi\n\n# Generate HTML report\n$GENHTML -q -o $HTMLOUTDIR -t \"MySQL Route Code Coverage\" $GCOVINFO\nif [ $? -ne 0 ]; then\n  errecho \"Failed executing $GENHTML while generating HTML report\"\n  exit 1\nfi\n\necho \"Done. HTML report in folder: $HTMLOUTDIR\"\n"
  },
  {
    "path": "tests/helpers/cmd_exec-windows.cc",
    "content": "/* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License, version 2.0,\n   as published by the Free Software Foundation.\n\n   This program is also distributed with certain software (including\n   but not limited to OpenSSL) that is licensed under separate terms,\n   as designated in a particular file or component or in included license\n   documentation.  The authors of MySQL hereby grant you an additional\n   permission to link the program and your derivative works with the\n   separately licensed software that they have included with MySQL.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; if not, write to the Free Software\n   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */\n\n#include \"cmd_exec.h\"\n#include \"cmd_exec-windows.h\"\n#include \"router_test_helpers.h\"\n\n#include <string>\n\n#include <windows.h>\n#include <tchar.h>\n#include <stdio.h>\n\nstatic std::string get_env_string()\n{\n  LPCH env_str = GetEnvironmentStrings();\n  if (!env_str)\n    return \"\";\n  LPCH next_env_var = env_str;\n  size_t len_total = 0;\n  size_t len_item;\n  while ((len_item = strlen(next_env_var)) > 0)\n  {\n    len_total += len_item + 1;\n    next_env_var += len_item + 1;\n  }\n  std::string result(env_str, len_total);\n  FreeEnvironmentStrings(env_str);\n  return result;\n}\n\nvoid Process_launcher::start()\n{\n  SECURITY_ATTRIBUTES saAttr;\n\n  saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);\n  saAttr.bInheritHandle = TRUE;\n  saAttr.lpSecurityDescriptor = NULL;\n\n  if (!CreatePipe(&child_out_rd, &child_out_wr, &saAttr, 0))\n    report_error(\"Failed to create child_out_rd\");\n\n  if (!SetHandleInformation(child_out_rd, HANDLE_FLAG_INHERIT, 0))\n    report_error(\"Failed to create child_out_rd\");\n\n  // force non blocking IO in Windows\n  //DWORD mode = PIPE_NOWAIT;\n  //BOOL res = SetNamedPipeHandleState(child_out_rd, &mode, NULL, NULL);\n\n  if (!CreatePipe(&child_in_rd, &child_in_wr, &saAttr, 0))\n    report_error(\"Failed to create child_in_rd\");\n\n  if (!SetHandleInformation(child_in_wr, HANDLE_FLAG_INHERIT, 0))\n    report_error(\"Failed to created child_in_wr\");\n\n  // Create Process\n  BOOL bSuccess = FALSE;\n\n  ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));\n\n  ZeroMemory(&si, sizeof(STARTUPINFO));\n  si.cb = sizeof(STARTUPINFO);\n  if (redirect_stderr_)\n    si.hStdError = child_out_wr;\n  si.hStdOutput = child_out_wr;\n  si.hStdInput = child_in_rd;\n  si.dwFlags |= STARTF_USESTDHANDLES;\n\n  // Environment strings must inherit all the existing ones (like PATH changes).\n  std::string myenv;\n  if (!env_.empty())\n  {\n    myenv = get_env_string();\n    myenv.append(env_);\n    myenv.push_back('\\0');\n  }\n\n  bSuccess = CreateProcess(\n    NULL,          // lpApplicationName\n    const_cast<char *>(cmd_line_.c_str()),     // lpCommandLine\n    NULL,          // lpProcessAttributes\n    NULL,          // lpThreadAttributes\n    TRUE,          // bInheritHandles\n    0,             // dwCreationFlags\n    myenv.empty() ? NULL : reinterpret_cast<LPVOID>(const_cast<char *>(myenv.c_str())),\n                   // lpEnvironment\n    NULL,          // lpCurrentDirectory\n    &si,           // lpStartupInfo\n    &pi);          // lpProcessInformation\n\n  if (!bSuccess)\n    report_error(NULL);\n\n  CloseHandle(child_out_wr);\n  CloseHandle(child_in_rd);\n\n  //DWORD res1 = WaitForInputIdle(pi.hProcess, 100);\n  //res1 = WaitForSingleObject(pi.hThread, 100);\n}\n\n\nuint64_t Process_launcher::get_pid()\n{\n  return (uint64_t)pi.hProcess;\n}\n\n\nint Process_launcher::wait()\n{\n  DWORD dwExit = 0;\n\n  for (;;)\n  {\n    if (!GetExitCodeProcess(pi.hProcess, &dwExit))\n    {\n      DWORD dwError = GetLastError();\n      if (dwError != ERROR_INVALID_HANDLE)  // not closed already?\n        report_error(NULL);\n      return -1;\n    }\n    if (dwExit == STILL_ACTIVE)\n      WaitForSingleObject(pi.hProcess, INFINITE);\n    else\n      break;\n  }\n  return dwExit;\n}\n\n\nvoid Process_launcher::close()\n{\n  DWORD dwExit;\n  if (GetExitCodeProcess(pi.hProcess, &dwExit))\n  {\n    if (dwExit == STILL_ACTIVE)\n    {\n      if (!TerminateProcess(pi.hProcess, 0))\n        report_error(NULL);\n      // TerminateProcess is async, wait for process to end.\n      WaitForSingleObject(pi.hProcess, INFINITE);\n    }\n  }\n  else\n  {\n    report_error(NULL);\n  }\n\n  if (!CloseHandle(pi.hProcess))\n    report_error(NULL);\n  if (!CloseHandle(pi.hThread))\n    report_error(NULL);\n\n  if (!CloseHandle(child_out_rd))\n    report_error(NULL);\n  if (!CloseHandle(child_in_wr))\n    report_error(NULL);\n\n  is_alive_ = false;\n}\n\n\nint Process_launcher::read_one_char() {\n  char buf;\n  int ret = Process_launcher::read(&buf, 1);\n  return ret == EOF ? EOF : buf;\n}\n\nint Process_launcher::read(char *buf, size_t count)\n{\n  BOOL bSuccess = FALSE;\n  DWORD dwBytesRead, dwCode;\n  int i = 0;\n\n  while (!(bSuccess = ReadFile(child_out_rd, buf, count, &dwBytesRead, NULL)))\n  {\n    dwCode = GetLastError();\n    if (dwCode == ERROR_NO_DATA) continue;\n    if (dwCode == ERROR_BROKEN_PIPE)\n      return EOF;\n    else\n      report_error(NULL);\n  }\n\n  return dwBytesRead;\n}\n\n\nint Process_launcher::write_one_char(char c) {\n  return Process_launcher::write(&c, 1);\n}\n\n\nint Process_launcher::write(const char *buf, size_t count)\n{\n  DWORD dwBytesWritten;\n  BOOL bSuccess = FALSE;\n  bSuccess = WriteFile(child_in_wr, buf, count, &dwBytesWritten, NULL);\n  if (!bSuccess)\n  {\n    if (GetLastError() != ERROR_NO_DATA)  // otherwise child process just died.\n      report_error(NULL);\n  }\n  else\n  {\n    // When child input buffer is full, this returns zero in NO_WAIT mode.\n    return dwBytesWritten;\n  }\n  return 0; // so the compiler does not cry\n}\n\n\nvoid Process_launcher::report_error(const char *msg)\n{\n  DWORD dwCode = GetLastError();\n  LPTSTR lpMsgBuf;\n\n  if (msg != NULL)\n  {\n    throw std::runtime_error(msg);\n  }\n  else\n  {\n    FormatMessage(\n      FORMAT_MESSAGE_ALLOCATE_BUFFER |\n      FORMAT_MESSAGE_FROM_SYSTEM |\n      FORMAT_MESSAGE_IGNORE_INSERTS,\n      NULL,\n      dwCode,\n      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),\n      (LPTSTR)&lpMsgBuf,\n      0, NULL);\n    std::string msgerr = \"SystemError: \";\n    msgerr += lpMsgBuf;\n    msgerr += \"with error code \"+std::to_string(dwCode);\n    LocalFree(lpMsgBuf);\n    throw std::runtime_error(msgerr);\n  }\n}\n\n\nuint64_t Process_launcher::get_fd_write()\n{\n  return (uint64_t)child_in_wr;\n}\n\n\nuint64_t Process_launcher::get_fd_read()\n{\n  return (uint64_t)child_out_rd;\n}\n\nvoid Process_launcher::kill()\n{\n  close();\n}\n\n\n\nCmdExecResult cmd_exec(const std::string &cmd, bool include_stderr,\n                       std::string working_dir, const std::string& env)\n{\n  std::string orig_cwd;\n  if (!working_dir.empty()) {\n    orig_cwd = change_cwd(working_dir);\n  }\n\n  Process_launcher launcher(cmd.c_str(), include_stderr, env);\n\n  char cmd_output[256];\n  int nbytes;\n  std::string output{};\n\n  for (;;) {\n    if ((nbytes = launcher.read(cmd_output, 256)) == EOF) {\n      break;\n    }\n    output.append(cmd_output, nbytes);\n  }\n\n  if (!orig_cwd.empty()) {\n    change_cwd(orig_cwd);\n  }\n\n  int code = launcher.wait();\n  return CmdExecResult{output, code, 0};\n}\n"
  },
  {
    "path": "tests/helpers/cmd_exec-windows.h",
    "content": "/* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.\n\n   This program is free software; you can redistribute it and/or modify\n   it under the terms of the GNU General Public License, version 2.0,\n   as published by the Free Software Foundation.\n\n   This program is also distributed with certain software (including\n   but not limited to OpenSSL) that is licensed under separate terms,\n   as designated in a particular file or component or in included license\n   documentation.  The authors of MySQL hereby grant you an additional\n   permission to link the program and your derivative works with the\n   separately licensed software that they have included with MySQL.\n\n   This program is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n   GNU General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program; if not, write to the Free Software\n   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */\n\n#ifndef CMD_EXEC_WINDOWS_H_\n#define CMD_EXEC_WINDOWS_H_\n\n#define _CRT_SECURE_NO_WARNINGS 1\n#ifdef UNICODE\n#  #undef UNICODE\n#endif\n#include <windows.h>\n#include <stdint.h>\n\n// Launches a process as child of current process and exposes the stdin & stdout of the child process\n// (implemented thru pipelines) so the client of this class can read from the child's stdout and write to the child's stdin.\nclass Process_launcher\n{\npublic:\n  /**\n   * Creates a new process and launch it.\n   * Argument 'args' must have a last entry that is NULL.\n   * If redirect_stderr is true, the child's stderr is redirected to the same stream than child's stdout.\n   */\n  Process_launcher(const char *cmd_line, bool redirect_stderr = true, const std::string& env = \"\") :\n    cmd_line_(cmd_line), env_(env), is_alive_(true), redirect_stderr_(redirect_stderr)\n  {\n    // launch the child process.\n    start();\n  }\n\n  ~Process_launcher() { if(is_alive_) close(); }\n\n  /**\n   * Reads a single byte (and returns it).\n   * Throws an shcore::Exception in case of error when reading.\n   */\n  int read_one_char();\t\t// read from stdout of child process\n\n  /**\n   * Read up to a 'count' bytes from the stdout of the child process.\n   * This method blocks until the amount of bytes is read.\n   * @param buf already allocated buffer where the read data will be stored.\n   * @param count the maximum amount of bytes to read.\n   * @return the real number of bytes read.\n   * Returns an shcore::Exception in case of error when reading.\n   */\n  int read(char *buf, size_t count);\n\n  /**\n   * Write into stdin of child process.\n   * Returns an shcore::Exception in case of error when writing.\n   */\n  int write_one_char(char c);\n\n  /**\n   * Writes several bytes into stdin of child process.\n   * Returns an shcore::Exception in case of error when writing.\n   */\n  int write(const char *buf, size_t count);\n\n  /**\n   * Kills the child process.\n   */\n  void kill();\n\n  /**\n   * Returns the child process handle.\n   * In Linux this needs to be cast to pid_t, in Windows to cast to HANDLE.\n   */\n  uint64_t get_pid();\n\n  /**\n   * Waits for the child process to exit and returns its exit code.\n   * If the child process is already dead, wait() returns immediately.\n   */\n  int wait();\n\n  /**\n  * Returns the file descriptor write handle (to write child's stdin).\n  * In Linux this needs to be cast to int, in Windows to cast to HANDLE.\n  */\n  uint64_t get_fd_write();\n\n  /**\n  * Returns the file descriptor read handle (to read child's stdout).\n  * In Linux this needs to be cast to int, in Windows to cast to HANDLE.\n  */\n  uint64_t get_fd_read();\n\nprivate:\n  /**\n   * Throws an exception with the specified message, if msg == NULL, the exception's message is specific of the platform error.\n   * (errno in Linux / GetLastError in Windows).\n   */\n  void report_error(const char *msg);\n  /** Launches the child process, and makes pipes available for read/write. */\n  void start();\n  /** Closes child process */\n  void close();\n\n  std::string cmd_line_;\n  std::string env_;\n  std::string args_;\n  bool is_alive_;\n\n  HANDLE child_in_rd;\n  HANDLE child_in_wr;\n  HANDLE child_out_rd;\n  HANDLE child_out_wr;\n  PROCESS_INFORMATION pi;\n  STARTUPINFO si;\n  bool redirect_stderr_;\n};\n\n\n#endif // CMD_EXEC_WINDOWS_H_\n"
  },
  {
    "path": "tests/helpers/cmd_exec.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"cmd_exec.h\"\n#include \"router_test_helpers.h\"\n\n#include <stdexcept>\n#include <cerrno>\n#include <iostream>\n#include <stdio.h>\n#include <string>\n#ifndef _WIN32\n#include <sys/wait.h>\n#include <unistd.h>\n#endif\n\nCmdExecResult cmd_exec(const std::string &cmd, bool include_stderr, std::string working_dir,\n  const std::string& env /*= \"\"*/) {\n  std::string app_cmd(env + \" \" + cmd);\n  std::string orig_cwd{};\n\n  if (include_stderr) {\n    app_cmd += \" 2>&1\";\n  }\n\n  if (!working_dir.empty()) {\n    orig_cwd = change_cwd(working_dir);\n  }\n\n  auto ld_lib_path = std::getenv(\"LD_LIBRARY_PATH\");\n  if (ld_lib_path != nullptr) {\n    // Linux/Solaris\n    app_cmd = \"LD_LIBRARY_PATH=\\\"\" + std::string(ld_lib_path) + \"\\\" \" + app_cmd;\n  }\n\n  auto dyld_lib_path = std::getenv(\"DYLD_LIBRARY_PATH\");\n  if (dyld_lib_path != nullptr) {\n    // OS X\n    app_cmd = \"DYLD_LIBRARY_PATH=\\\"\" + std::string(dyld_lib_path) + \"\\\" \" + app_cmd;\n  }\n\n  FILE *fp = popen(app_cmd.c_str(), \"r\");\n\n  if (!fp) {\n    throw std::runtime_error(\"Failed opening pipe to command '\" + app_cmd + \"'\");\n  }\n\n  char cmd_output[256];\n\n  std::string output{};\n\n  while (!feof(fp)) {\n    if (fgets(cmd_output, 256, fp) == nullptr) {\n      break;\n    }\n    output += cmd_output;\n  }\n\n  if (!orig_cwd.empty()) {\n    change_cwd(orig_cwd);\n  }\n\n  int code = pclose(fp);\n  return CmdExecResult{output, WEXITSTATUS(code), WTERMSIG(code)};\n}\n"
  },
  {
    "path": "tests/helpers/cmd_exec.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_TESTS_APP_EXEC_INCLUDED\n#define MYSQLROUTER_TESTS_APP_EXEC_INCLUDED\n\n#include <utility>\n#include <string>\n\n/** @struct CmdExecResult\n *\n * Struct CmdExecResult contains the result of the execution of a\n * command. The output of the command is stored in the output member,\n * exit code in exit_code and if the command was signaled, the signal\n * will be available through the signal member.\n *\n * The output could possibly include the STDERR.\n */\nstruct CmdExecResult {\n  /** @brief Output of the command */\n  std::string output;\n  /** @brief Exit code of the command execution */\n  int exit_code;\n  /** @brief Signal number when the command was signaled */\n  int signal;\n};\n\n/** @brief Executes the given command\n *\n * Executes the given command and returns the result. If include_stderr\n * is true, messages going to STDERR are included in the output.\n *\n * When working_dir is provided, we change first to the given directory\n * and executed the command from there. We return to previous folder\n * when done.\n *\n * @param cmd Command to executed\n * @param include_stderr Include STDERR messages in output\n * @param working_dir Working directory\n * @return Returns CmdExecResult\n */\nCmdExecResult cmd_exec(const std::string &cmd, bool include_stderr = false,\n                       std::string working_dir = \"\",\n                       const std::string& env = \"\");\n\n#endif // MYSQLROUTER_TESTS_APP_EXEC_INCLUDED\n"
  },
  {
    "path": "tests/helpers/gtest_consoleoutput.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef MYSQLROUTER_GTEST_ROUTER_EXETEST_INCLUDED\n#define MYSQLROUTER_GTEST_ROUTER_EXETEST_INCLUDED\n\n#include \"mysql/harness/filesystem.h\"\n#include \"mysql/harness/logging/registry.h\"\n\n#include <memory>\n\n#include \"gmock/gmock.h\"\n\nusing mysql_harness::Path;\nusing std::string;\n\nclass ConsoleOutputTest : public ::testing::Test {\nprotected:\n  virtual void SetUp() {\n    using mysql_harness::Path;\n\n    char *stage_dir_c = std::getenv(\"STAGE_DIR\");\n    if (stage_dir_c == nullptr) {\n      stage_dir.reset(new Path(\"./stage\"));\n    } else {\n      stage_dir.reset(new Path(stage_dir_c));\n    }\n#ifdef CMAKE_INTDIR\n    if (origin_dir) {\n      *stage_dir = stage_dir->join(origin_dir->basename());\n    } else {\n      *stage_dir = stage_dir->join(\"RelWithDebInfo\");\n    }\n#endif\n    plugin_dir.reset(new Path(*stage_dir));\n    plugin_dir->append(\"lib\");\n#ifndef _WIN32\n    plugin_dir->append(\"mysqlrouter\");\n#endif\n    app_mysqlrouter.reset(new Path(*stage_dir));\n    app_mysqlrouter->append(\"bin\");\n#ifdef _WIN32\n    app_mysqlrouter->append(\"mysqlrouter.exe\");\n#else\n    app_mysqlrouter->append(\"mysqlrouter\");\n#endif\n    mysql_server_mock.reset(new Path(*stage_dir));\n    mysql_server_mock->append(\"bin\");\n#ifdef _WIN32\n    mysql_server_mock->append(\"mysql_server_mock.exe\");\n#else\n    mysql_server_mock->append(\"mysql_server_mock\");\n#endif\n    orig_cerr_ = std::cerr.rdbuf();\n    std::cerr.rdbuf(ssout.rdbuf());\n\n    std::ostream *log_stream = mysql_harness::logging::get_default_logger_stream();\n    if (log_stream != &std::cerr) {\n      orig_log_ = log_stream->rdbuf();\n      log_stream->rdbuf(ssout_log.rdbuf());\n    }\n  }\n\n  virtual void TearDown() {\n    if (orig_cerr_) {\n      std::cerr.rdbuf(orig_cerr_);\n    }\n\n    if (orig_log_) {\n      std::ostream *log_stream = mysql_harness::logging::get_default_logger_stream();\n      log_stream->rdbuf(orig_log_);\n    }\n  }\n\n  void reset_ssout() {\n    ssout.str(\"\");\n    ssout.clear();\n    ssout_log.str(\"\");\n    ssout_log.clear();\n  }\n\n  void set_origin(const Path &origin) {\n    origin_dir.reset(new Path(origin));\n  }\n\n  std::stringstream& get_log_stream() {\n    if (orig_log_) {\n      // if logger stream differs from cerr\n      return ssout_log;\n    }\n\n    return ssout;\n  }\n\n  std::unique_ptr<Path> stage_dir;\n  std::unique_ptr<Path> plugin_dir;\n  std::unique_ptr<Path> app_mysqlrouter;\n  std::unique_ptr<Path> origin_dir;\n  std::unique_ptr<Path> mysql_server_mock;\n\n  std::stringstream ssout;\n  std::streambuf *orig_cerr_{nullptr};\n  std::streambuf *orig_log_{nullptr};\n\n private:\n  std::stringstream ssout_log;\n};\n\n#endif // MYSQLROUTER_GTEST_ROUTER_EXETEST_INCLUDED\n"
  },
  {
    "path": "tests/helpers/master_key_test_writer.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <iostream>\n#include <fstream>\n#include <sstream>\n#include <stdlib.h>\n\n\nstd::string get_master_key_file_path() {\n#ifdef _WIN32\n  char env_str[2000] = {0};\n  size_t len = 0;\n  int err_code;\n\n  if ((err_code = getenv_s(&len, env_str, sizeof(env_str), \"MASTER_KEY_PATH\")) != 0)\n    throw std::runtime_error(\"Failed to read MASTER_KEY_PATH variable: \" + std::to_string(err_code));\n  return std::string(env_str);\n#else\n  return getenv(\"MASTER_KEY_PATH\");\n#endif\n}\n\n/*\n * MySQLRouter sets ROUTER_ID environment variable which can be used by\n * master-key-writer/master-key-writer to distinguish between routers, and\n * write/read appropriate master key.\n *\n * This function checks if ROUTER_ID variable is set.\n *\n * @return true if ROUTER_ID is set in environment, false otherwise.\n */\nbool check_router_id() {\n#ifdef _WIN32\n  char env_str[2000] = {0};\n  size_t len = 0;\n  int err_code;\n\n  return getenv_s(&len, env_str, sizeof(env_str), \"ROUTER_ID\") == 0;\n#else\n  return getenv(\"ROUTER_ID\") != nullptr;\n#endif\n}\n\nint main() {\n  if (!check_router_id())\n    return 1;\n\n  std::stringstream file_content;\n  file_content << std::cin.rdbuf();\n  std::string master_key = file_content.str();\n  {\n    std::ofstream output_file(get_master_key_file_path());\n    output_file << master_key;\n  }\n  return 0;\n}\n\n"
  },
  {
    "path": "tests/helpers/mysql_session_replayer.cc",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql_session_replayer.h\"\n#include \"mysqlrouter/utils_sqlstring.h\"\n#include <iostream>\n\nusing mysqlrouter::MySQLSession;\n\nMySQLSessionReplayer::MySQLSessionReplayer(bool trace) : trace_(trace) {\n}\n\nMySQLSessionReplayer::~MySQLSessionReplayer() {\n\n}\n\nvoid MySQLSessionReplayer::connect(const std::string &host, unsigned int port,\n                                   const std::string &user,\n                                   const std::string &password,\n                                   const std::string &unix_socket,\n                                   const std::string &,\n                                   int,\n                                   int) {\n  if (trace_) {\n    std::cout << \"connect: \" << user << \":\" << password << \"@\" << (unix_socket.length() > 0 ? unix_socket : host + \":\" + std::to_string(port)) << std::endl;\n  }\n\n  // check if connect() is not expected to fail. Note that since we mostly just\n  // connect() without errors and go on about our business, connect() is allowed\n  // to be called without a prior call to expect_connect(). This is in contrast to\n  // execute(), query() and friends, which must be preceded by their respective\n  // expect_*() call.\n  if (call_info_.size()\n      && call_info_.front().type == CallInfo::Connect) {\n    const CallInfo info(call_info_.front());\n    call_info_.pop_front();\n\n    connected_ = false;\n    if (info.host != host) {\n      throw MySQLSession::Error(\n          (std::string(\"expected host not found: expected \") + info.host +\n           \", got \" + host\n           ).c_str(), info.error_code);\n    }\n\n    if (info.port != port) {\n      throw MySQLSession::Error(\n          (std::string(\"expected port not found: expected \") + std::to_string(info.port) +\n           \", got \" + std::to_string(port)\n           ).c_str(), info.error_code);\n    }\n\n    if (info.unix_socket != unix_socket) {\n      throw MySQLSession::Error(\n          (std::string(\"expected unix_socket not found: expected \") + info.unix_socket +\n           \", got \" + unix_socket\n           ).c_str(), info.error_code);\n    }\n\n    if (info.user != user) {\n      throw MySQLSession::Error(\n          (std::string(\"expected user not found: expected \") + info.user +\n           \", got \" + user\n           ).c_str(), info.error_code);\n    }\n\n    if (info.password != password) {\n      throw MySQLSession::Error(\n          (std::string(\"expected password not found: expected \") + info.password +\n           \", got \" + password\n           ).c_str(), info.error_code);\n    }\n\n    // all params match, but called wanted to inject a error-code and error-msg\n    if (info.error_code != 0) {\n      last_error_msg = info.error;\n      last_error_code = info.error_code;\n\n      throw MySQLSession::Error(info.error.c_str(), info.error_code);\n    }\n  }\n\n  connected_ = true;\n}\n\nvoid MySQLSessionReplayer::disconnect() {\n  connected_ = false;\n}\n\nvoid MySQLSessionReplayer::execute(const std::string &sql) {\n  if (call_info_.empty()) {\n    if (trace_)\n      std::cout << \"unexpected execute: \" << sql << \"\\n\";\n    throw std::logic_error(\"Unexpected call to execute(\"+sql+\")\");\n  }\n  const CallInfo info(call_info_.front());\n  if (sql.compare(0, info.sql.length(), info.sql) != 0\n      || info.type != CallInfo::Execute) {\n    if (trace_)\n      std::cout << \"wrong execute: \" << sql << \"\\n\";\n    throw std::logic_error(\"Unexpected/out-of-order call to execute(\"+sql+\")\\nExpected: \"+info.sql);\n  }\n  last_insert_id_ = info.last_insert_id;\n  if (trace_)\n    std::cout << \"execute: \" << sql << \"\\n\";\n  if (info.error_code != 0) {\n    call_info_.pop_front();\n    throw MySQLSession::Error(info.error.c_str(), info.error_code);\n  }\n  call_info_.pop_front();\n}\n\nvoid MySQLSessionReplayer::query(const std::string &sql, const RowProcessor &processor) {\n  if (call_info_.empty()) {\n    if (trace_)\n      std::cout << \"unexpected query: \" << sql << \"\\n\";\n    throw std::logic_error(\"Unexpected call to query(\"+sql+\")\");\n  }\n  const CallInfo info(call_info_.front());\n  if (sql.compare(0, info.sql.length(), info.sql) != 0\n      || info.type != CallInfo::Query) {\n    if (trace_)\n      std::cout << \"wrong query: \" << sql << \"\\n\";\n    throw std::logic_error(\"Unexpected/out-of-order call to query(\"+sql+\")\\nExpected: \"+info.sql);\n  }\n  if (trace_)\n    std::cout << \"query: \" << sql << \"\\n\";\n\n  if (info.error_code != 0) {\n    last_error_msg = info.error;\n    last_error_code = info.error_code;\n\n    call_info_.pop_front();\n    throw MySQLSession::Error(info.error.c_str(), info.error_code);\n  }\n  for (auto &row : info.rows) {\n    Row r;\n    for (auto &field : row) {\n      if (field) {\n        r.push_back(field.c_str());\n      } else {\n        r.push_back(nullptr);\n      }\n    }\n    try {\n      if (!processor(r))\n        break;\n    } catch (...) {\n      last_insert_id_ = 0;\n      call_info_.pop_front();\n      throw;\n    }\n  }\n\n  last_insert_id_ = 0;\n  call_info_.pop_front();\n}\n\nclass MyResultRow : public MySQLSession::ResultRow {\npublic:\n  MyResultRow(const std::vector<MySQLSessionReplayer::string> &row)\n    : real_row_(row) {\n\n    for (auto &field : real_row_) {\n      if (field) {\n        row_.push_back(field.c_str());\n      } else {\n        row_.push_back(nullptr);\n      }\n    }\n  }\n\nprivate:\n  std::vector<MySQLSessionReplayer::string> real_row_;\n};\n\nMySQLSession::ResultRow *MySQLSessionReplayer::query_one(const std::string &sql) {\n  if (call_info_.empty()) {\n    if (trace_)\n      std::cout << \"unexpected query_one: \" << sql << \"\\n\";\n    throw std::logic_error(\"Unexpected call to query_one(\"+sql+\")\");\n  }\n  const CallInfo info(call_info_.front());\n  if (sql.compare(0, info.sql.length(), info.sql) != 0\n      || info.type != CallInfo::QueryOne) {\n    if (trace_)\n      std::cout << \"unexpected query_one: \" << sql << \"\\n\";\n    throw std::logic_error(\"Unexpected/out-of-order call to query_one(\"+sql+\")\\nExpected: \"+info.sql);\n  }\n  if (trace_)\n    std::cout << \"query_one: \" << sql << \"\\n\";\n\n  if (info.error_code != 0) {\n    last_error_msg = info.error;\n    last_error_code = info.error_code;\n\n    call_info_.pop_front();\n\n    throw MySQLSession::Error(info.error.c_str(), info.error_code);\n  }\n  ResultRow *result = nullptr;\n  if (!info.rows.empty()) {\n    result = new MyResultRow(info.rows.front());\n  }\n  last_insert_id_ = 0;\n  call_info_.pop_front();\n\n  return result;\n}\n\nuint64_t MySQLSessionReplayer::last_insert_id() noexcept {\n  return last_insert_id_;\n}\n\nconst char *MySQLSessionReplayer::last_error() {\n  return last_error_msg.c_str();\n}\n\nunsigned int MySQLSessionReplayer::last_errno() {\n  return last_error_code;\n}\n\n\nstd::string MySQLSessionReplayer::quote(const std::string &s, char qchar) noexcept {\n  std::string quoted;\n  quoted.push_back(qchar);\n  quoted.append(mysqlrouter::escape_sql_string(s));\n  quoted.push_back(qchar);\n  return quoted;\n}\n\nMySQLSessionReplayer &MySQLSessionReplayer::expect_connect(const std::string &host, unsigned port,\n                                                           const std::string &user,\n                                                           const std::string &password,\n                                                           const std::string &unix_socket) {\n  CallInfo call;\n  call.type = CallInfo::Connect;\n  call.host = host;\n  call.port = port;\n  call.user = user;\n  call.password = password;\n  call.unix_socket = unix_socket;\n  call_info_.push_back(call);\n  return *this;\n}\n\nMySQLSessionReplayer &MySQLSessionReplayer::expect_execute(const std::string &q) {\n  CallInfo call;\n  call.type = CallInfo::Execute;\n  call.sql = q;\n  call_info_.push_back(call);\n  return *this;\n}\n\nMySQLSessionReplayer &MySQLSessionReplayer::expect_query(const std::string &q) {\n  CallInfo call;\n  call.type = CallInfo::Query;\n  call.sql = q;\n  call_info_.push_back(call);\n  return *this;\n}\n\nMySQLSessionReplayer &MySQLSessionReplayer::expect_query_one(const std::string &q) {\n  CallInfo call;\n  call.type = CallInfo::QueryOne;\n  call.sql = q;\n  call_info_.push_back(call);\n  return *this;\n}\n\nvoid MySQLSessionReplayer::then_ok(uint64_t the_last_insert_id) {\n  call_info_.back().last_insert_id = the_last_insert_id;\n}\n\nvoid MySQLSessionReplayer::then_error(const std::string &error, unsigned int code) {\n  call_info_.back().error = error;\n  call_info_.back().error_code = code;\n}\n\nvoid MySQLSessionReplayer::then_return(unsigned int num_fields,\n                 std::vector<std::vector<string>> rows) {\n  call_info_.back().num_fields = num_fields;\n  call_info_.back().rows = rows;\n}\n\nbool MySQLSessionReplayer::print_expected() {\n  std::cout << \"Expected MySQLSession calls:\\n\";\n  for (auto &info : call_info_) {\n    switch (info.type) {\n      case CallInfo::Execute:\n        std::cout << \"\\texecute: \";\n        std::cout << info.sql << \"\\n\";\n        break;\n      case CallInfo::Query:\n        std::cout << \"\\tquery: \";\n        std::cout << info.sql << \"\\n\";\n        break;\n      case CallInfo::QueryOne:\n        std::cout << \"\\tquery_one: \";\n        std::cout << info.sql << \"\\n\";\n        break;\n      case CallInfo::Connect:\n        std::cout << \"\\tconnect: \";\n        std::cout << info.user << \":\" << info.password << \"@\" << info.host << \":\" << info.port << \"\\n\";\n        break;\n    }\n  }\n  return !call_info_.empty();\n}\n\nMySQLSessionReplayer::CallInfo::CallInfo(const CallInfo& ci) : type(ci.type), error(ci.error), error_code(ci.error_code), sql(ci.sql),\nlast_insert_id(ci.last_insert_id), num_fields(ci.num_fields), rows(ci.rows), host(ci.host), port(ci.port), user(ci.user), password(ci.password), unix_socket(ci.unix_socket)\n{\n}\n"
  },
  {
    "path": "tests/helpers/mysql_session_replayer.h",
    "content": "/*\n  Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef ROUTER_MYSQL_SESSION_REPLAYER_INCLUDED\n#define ROUTER_MYSQL_SESSION_REPLAYER_INCLUDED\n\n#include \"mysqlrouter/mysql_session.h\"\n#include <deque>\n\nclass MySQLSessionReplayer : public mysqlrouter::MySQLSession {\npublic:\n  MySQLSessionReplayer(bool trace = false);\n  virtual ~MySQLSessionReplayer();\n\n  virtual void connect(const std::string &host, unsigned int port,\n                       const std::string &user,\n                       const std::string &password,\n                       const std::string &unix_socket,\n                       const std::string &default_schema,\n                       int connect_timeout = kDefaultConnectTimeout,\n                       int read_timeout = kDefaultReadTimeout) override;\n  virtual void disconnect() override;\n  virtual bool is_connected() noexcept override { return connected_; }\n\n  virtual void execute(const std::string &sql) override;\n  virtual void query(const std::string &sql, const RowProcessor &processor) override;\n  virtual ResultRow *query_one(const std::string &sql) override;\n\n  virtual uint64_t last_insert_id() noexcept override;\n\n  virtual std::string quote(const std::string &s, char qchar = '\\'') noexcept override;\n\n  virtual const char *last_error() override;\n  virtual unsigned int last_errno() override;\n\npublic:\n  class string {\n  public:\n    string(const char *s) : s_(s ? s : \"\"), is_null_(s == nullptr) {}\n    string() : is_null_(true) {}\n\n    operator const std::string&() const { return s_; }\n    operator bool() const { return !is_null_; }\n    const char *c_str() const {\n        return !is_null_ ? s_.c_str() : nullptr;\n    }\n  private:\n    std::string s_;\n    bool is_null_;\n  };\n  string string_or_null(const char *s) { return string(s); }\n  string string_or_null() { return string(); }\n\n  MySQLSessionReplayer &expect_connect(const std::string &host, unsigned port, const std::string &user, const std::string &password, const std::string &unix_socket);\n  MySQLSessionReplayer &expect_execute(const std::string &q);\n  MySQLSessionReplayer &expect_query(const std::string &q);\n  MySQLSessionReplayer &expect_query_one(const std::string &q);\n  void then_ok(uint64_t the_last_insert_id = 0);\n  void then_error(const std::string &error, unsigned int code);\n  void then_return(unsigned int num_fields,\n                   std::vector<std::vector<string>> rows);\n  bool print_expected();\n\n  bool empty() { return call_info_.empty(); }\n\n  void clear_expects() { call_info_.clear(); }\n\nprivate:\n  struct CallInfo {\n    CallInfo() {}\n    CallInfo(const CallInfo& ci);\n\n    enum Type {\n      Connect,\n      Execute,\n      Query,\n      QueryOne\n    };\n\n    // common fields\n    Type type;\n    std::string error;\n    unsigned int error_code = 0;\n\n    // SQL fields\n    std::string sql;\n    uint64_t last_insert_id = 0;\n    unsigned int num_fields = 0;\n    std::vector<std::vector<string>> rows;\n\n    // connect fields\n    std::string host;\n    unsigned int port;\n    std::string user;\n    std::string password;\n    std::string unix_socket;\n  };\n  std::deque<CallInfo> call_info_;\n  uint64_t last_insert_id_;\n  std::string last_error_msg;\n  unsigned int last_error_code;\n  bool trace_ = false;\n  bool connected_ = false;\n};\n\n\n#endif // ROUTER_MYSQL_SESSION_REPLAYER_INCLUDED\n"
  },
  {
    "path": "tests/helpers/router_component_test.cc",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef _WIN32\n#  include <netdb.h>\n#  include <netinet/in.h>\n#  include <sys/un.h>\n#  include <sys/select.h>\n#  include <sys/socket.h>\n#  include <sys/file.h>\n#  include <sys/types.h>\n#  include <unistd.h>\n#else\n#  define USE_STD_REGEX\n#  define WIN32_LEAN_AND_MEAN\n#  define NOMINMAX\n#  include <winsock2.h>\n#  include <ws2tcpip.h>\n#  include <windows.h>\n#  include <direct.h>\n#  include <stdio.h>\n#  include <io.h>\n#  include <locale>\n#  include <codecvt>\n#endif\n\n#include <fcntl.h>\n#include \"router_component_test.h\"\n\n#include \"process_launcher.h\"\n#include \"mysqlrouter/utils.h\"\n#include \"keyring/keyring_manager.h\"\n#include \"random_generator.h\"\n#include \"dim.h\"\n\n\n#include <algorithm>\n#include <chrono>\n#include <iterator>\n#include <thread>\n#include <system_error>\n\n#ifdef USE_STD_REGEX\n#  include <regex>\n#else\n#  include <regex.h>\n#endif\nusing mysql_harness::Path;\n\nusing mysql_harness::ProcessLauncher;\n\nnamespace {\n\ntemplate<typename Out>\nvoid split_str(const std::string &input, Out result, char delim = ' ') {\n  std::stringstream ss;\n  ss.str(input);\n  std::string item;\n  while (std::getline(ss, item, delim)) {\n    *(result++) = item;\n  }\n}\n\nstd::vector<std::string> split_str(const std::string &s, char delim = ' ') {\n    std::vector<std::string> elems;\n    split_str(s, std::back_inserter(elems), delim);\n    return elems;\n}\n\n#ifndef _WIN32\nint close_socket(int sock) {\n  return close(sock);\n}\n#else\nint close_socket(SOCKET sock) {\n  return closesocket(sock);\n}\n#endif\n\n}\n\nRouterComponentTest::RouterComponentTest():\n  data_dir_(COMPONENT_TEST_DATA_DIR),\n  logging_dir_(RouterComponentTest::get_tmp_dir(\"log\")) {\n}\n\nRouterComponentTest::~RouterComponentTest() {\n  purge_dir(logging_dir_.str());\n}\n\nvoid RouterComponentTest::SetUp() {\n  using mysql_harness::Path;;\n  char *stage_dir_c = std::getenv(\"STAGE_DIR\");\n  stage_dir_ = Path(stage_dir_c ? stage_dir_c : \"./stage\");\n#ifdef CMAKE_INTDIR\n  if (!origin_dir_.str().empty()) {\n    stage_dir_ = Path(stage_dir_.join(origin_dir_.basename()));\n  }\n  else {\n    throw std::runtime_error(\"Origin dir not set\");\n  }\n#endif\n\n  plugin_dir_ = stage_dir_;\n  plugin_dir_.append(\"lib\");\n#ifndef _WIN32\n  plugin_dir_.append(\"mysqlrouter\");\n#endif\n\n  auto get_exe_path = [&](const std::string &name) -> Path {\n    Path path(stage_dir_);\n    path.append(\"bin\");\n#ifdef _WIN32\n    path.append(name + \".exe\");\n#else\n    path.append(name);\n#endif\n    return path.real_path();\n  };\n\n  mysqlrouter_exec_ = get_exe_path(\"mysqlrouter\");\n  mysqlserver_mock_exec_ = get_exe_path(\"mysql_server_mock\");\n\n  mysql_harness::DIM& dim = mysql_harness::DIM::instance();\n  // RandomGenerator\n  dim.set_RandomGenerator(\n    [](){ static mysql_harness::RandomGenerator rg; return &rg; },\n    [](mysql_harness::RandomGeneratorInterface*){}\n  );\n}\n\nRouterComponentTest::CommandHandle\nRouterComponentTest::launch_command(const std::string &command,\n                                    const std::string &params,\n                                    bool catch_stderr) const {\n  auto params_vec = split_str(params, ' ');\n  const char* params_arr[MAX_PARAMS];\n  get_params(command, params_vec, params_arr);\n\n  if (command.empty()) throw std::logic_error(\"path to launchable executable must not be empty\");\n  return RouterComponentTest::CommandHandle(command, params_arr, catch_stderr);\n}\n\nRouterComponentTest::CommandHandle\nRouterComponentTest::launch_command(const std::string &command,\n                                    const std::vector<std::string> &params,\n                                    bool catch_stderr) const {\n\n  const char* params_arr[MAX_PARAMS];\n  get_params(command, params, params_arr);\n\n  if (command.empty()) throw std::logic_error(\"path to launchable executable must not be empty\");\n  return RouterComponentTest::CommandHandle(command, params_arr, catch_stderr);\n}\n\nstatic std::vector<std::string> build_exec_args(const std::string &mysqlrouter_exec,\n                                                bool with_sudo) {\n  const std::string sudo_cmd = \"sudo\";\n  const std::string sudo_args = \"--non-interactive\";\n  const std::string valgrind_cmd = \"valgrind\";\n  const std::string valgrind_args = \"--error-exitcode=1 --quiet\";\n  std::vector<std::string> args;\n\n  if (with_sudo) {\n    args.emplace_back(sudo_cmd);\n    args.emplace_back(sudo_args);\n  }\n\n  if (getenv(\"WITH_VALGRIND\")) {\n    args.emplace_back(valgrind_cmd);\n    args.emplace_back(valgrind_args);\n  }\n\n  args.emplace_back(mysqlrouter_exec);\n\n  return args;\n}\n\nRouterComponentTest::CommandHandle\nRouterComponentTest::launch_router(const std::string &params,\n                                   bool catch_stderr,\n                                   bool with_sudo) const {\n  std::vector<std::string> args =\n      build_exec_args(mysqlrouter_exec_.str(), with_sudo);\n  args.emplace_back(params);\n\n  // first argument is special - it needs to be passed as \"command\" to launch_router()\n  auto it = args.begin();\n  std::string cmd(*it++);\n\n  // and the rest of them go into 'cmd_args', separated by spaces\n  std::string cmd_args;\n  for (; it < args.end(); it++)\n    cmd_args += *it + \" \";\n  cmd_args.resize(cmd_args.size() - 1); // remove last space\n\n  return launch_command(cmd, cmd_args, catch_stderr);\n}\n\nRouterComponentTest::CommandHandle\nRouterComponentTest::launch_router(const std::vector<std::string> &params,\n                                   bool catch_stderr,\n                                   bool with_sudo) const {\n\n  std::vector<std::string> args =\n      build_exec_args(mysqlrouter_exec_.str(), with_sudo);\n\n  // 1st argument is special - it needs to be passed as \"command\" to launch_router()\n  std::string cmd = args.at(0);\n  args.erase(args.begin());\n  std::copy(params.begin(), params.end(), std::back_inserter(args));\n\n  return launch_command(cmd, args, catch_stderr);\n}\n\nRouterComponentTest::CommandHandle\nRouterComponentTest::launch_mysql_server_mock(const std::string& json_file,\n                                              unsigned port,\n                                              bool debug_mode,\n                                              uint16_t http_port,\n                                              const std::string& module_prefix /* = \"\" */\n                                              ) const {\n\n  if (mysqlserver_mock_exec_.str().empty()) throw std::logic_error(\"path to mysql-server-mock must not be empty\");\n  return launch_command(mysqlserver_mock_exec_.str(), \"--filename=\" + json_file\n                        + \" --port=\" + std::to_string(port)\n                        + \" --http-port=\" + std::to_string(http_port)\n                        + \" --module-prefix=\" + (!module_prefix.empty() ? module_prefix : get_data_dir().str())\n                        + (debug_mode ? \" --verbose\" : \"\"),\n                        true);\n}\n\nbool RouterComponentTest::wait_for_port_ready(unsigned port, unsigned timeout_msec,\n                                              const std::string &hostname) const {\n  struct addrinfo hints, * ainfo;\n  memset(&hints, 0, sizeof hints);\n  hints.ai_family = AF_UNSPEC;\n  hints.ai_socktype = SOCK_STREAM;\n  hints.ai_flags = AI_PASSIVE;\n\n  // Valgrind needs way more time\n  if (getenv(\"WITH_VALGRIND\")) {\n    timeout_msec *= 10;\n  }\n\n  int status = getaddrinfo(hostname.c_str(),\n                           std::to_string(port).c_str(),\n                           &hints, &ainfo);\n  if (status != 0) {\n    throw std::runtime_error(std::string(\"wait_for_port_ready(): getaddrinfo() failed: \")\n                             + gai_strerror(status));\n  }\n  std::shared_ptr<void> exit_freeaddrinfo(nullptr, [&](void*){freeaddrinfo(ainfo);});\n\n  const unsigned MSEC_STEP = 10;\n  const auto started = std::chrono::steady_clock::now();\n  do {\n    auto sock_id = socket(ainfo->ai_family, ainfo->ai_socktype, ainfo->ai_protocol);\n    if (sock_id < 0) {\n      throw std::runtime_error(\"wait_for_port_ready(): socket() failed: \" + std::to_string(get_socket_errno()));\n    }\n    std::shared_ptr<void> exit_close_socket(nullptr, [&](void*){close_socket(sock_id);});\n\n    status = connect(sock_id, ainfo->ai_addr, ainfo->ai_addrlen);\n    if (status < 0) {\n      unsigned step = std::min(timeout_msec, MSEC_STEP);\n      std::this_thread::sleep_for(std::chrono::milliseconds(step));\n      timeout_msec -= step;\n    }\n  } while(status < 0 && timeout_msec > std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - started).count());\n\n  return status >= 0;\n}\n\n/*static*/\nint RouterComponentTest::purge_dir(const std::string& dir) {\n  return mysql_harness::delete_dir_recursive(dir);\n}\n\n/*static*/\nstd::string RouterComponentTest::get_tmp_dir(const std::string &name) {\n  return mysql_harness::get_tmp_dir(name);\n}\n\nvoid RouterComponentTest::get_params(const std::string &command,\n                                     const std::vector<std::string> &params_vec,\n                                     const char* out_params[MAX_PARAMS]) const {\n  out_params[0] =  command.c_str();\n\n  size_t i = 1;\n  for (const auto& par: params_vec) {\n    if (i >= MAX_PARAMS-1) {\n      throw std::runtime_error(\"Too many parameters passed to the MySQLRouter\");\n    }\n    out_params[i++] = par.c_str();\n  }\n  out_params[i] = nullptr;\n}\n\n/* static */\nvoid RouterComponentTest::replace_process_env(std::istream &ins, std::ostream &outs, const std::map<std::string, std::string> &env_vars) {\n  std::string line;\n  const char* regex = \"^(.*)process\\\\.env\\\\.([A-Za-z_][A-Za-z0-9_]*)(.*)$\";\n\n#ifdef USE_STD_REGEX\n  std::regex js_process_env_regex(regex);\n  while (std::getline(ins, line)) {\n    std::smatch m;\n    if (std::regex_match(line, m, js_process_env_regex)) {\n      try {\n        outs << m[1].str() << \"\\\"\" << env_vars.at(m[2].str()) << \"\\\"\" << m[3].str() << std::endl;\n      } catch (const std::out_of_range &e) {\n        throw std::runtime_error(\"Envvar \" + m[2].str() + \" requested, but isn't defined\");\n      }\n    } else {\n      outs << line << std::endl;\n    }\n  }\n#else\n  regex_t r;\n  int r_err;\n  char r_errbuf[256];\n\n  r_err = regcomp(&r, regex, REG_EXTENDED);\n\n  if (r_err) {\n    regerror(r_err, NULL, r_errbuf, sizeof(r_errbuf));\n    throw std::runtime_error(std::string(\"compiling regex \") + regex + \" failed: \" + std::string(r_errbuf));\n  }\n\n  std::shared_ptr<void> exit_guard(nullptr, [&](void*){regfree(&r);});\n\n  const size_t expected_nsub = 3;\n\n  if (r.re_nsub != expected_nsub) {\n    throw std::runtime_error(std::string(\"compiling regex \") + regex + \" resulted in \" + std::to_string(r.re_nsub) + \" captures, expected \" + std::to_string(expected_nsub));\n  }\n\n  while (std::getline(ins, line)) {\n    regmatch_t m[expected_nsub + 1];\n    r_err = regexec(&r, line.c_str(), sizeof(m)/sizeof(m[0]), m, 0);\n\n    if (r_err == 0) {\n      std::string m_1 = std::string(line.c_str() + m[1].rm_so, m[1].rm_eo - m[1].rm_so);\n      std::string m_2 = std::string(line.c_str() + m[2].rm_so, m[2].rm_eo - m[2].rm_so);\n      std::string m_3 = std::string(line.c_str() + m[3].rm_so, m[3].rm_eo - m[3].rm_so);\n      try {\n        outs << m_1 << \"\\\"\" << env_vars.at(m_2) << \"\\\"\" << m_3 << std::endl;\n      } catch (const std::out_of_range &e) {\n        throw std::runtime_error(\"Envvar \" + m_2 + \" requested, but isn't defined\");\n      }\n    } else if (r_err == REG_NOMATCH) {\n      outs << line << std::endl;\n    } else {\n      regerror(r_err, NULL, r_errbuf, sizeof(r_errbuf));\n      throw std::runtime_error(std::string(\"executing regex \") + regex + \" failed: \" + std::string(r_errbuf));\n    }\n  }\n#endif\n}\n\n/* static */\nvoid RouterComponentTest::rewrite_js_to_tracefile(const std::string &infile_name,\n                                                  const std::string &outfile_name,\n                                                  const std::map<std::string, std::string> &env_vars) {\n  std::ifstream js_file(infile_name);\n  std::ofstream json_file(outfile_name);\n\n  replace_process_env(js_file, json_file, env_vars);\n}\n\n\nint RouterComponentTest::CommandHandle::wait_for_exit_while_reading_and_autoresponding_to_output(unsigned timeout_ms) {\n  namespace ch = std::chrono;\n  ch::time_point<ch::steady_clock> timeout = ch::steady_clock::now() + ch::milliseconds(timeout_ms);\n\n  // We alternate between non-blocking read() and non-blocking waitpid() here.\n  // Reading/autoresponding must be done, because the child might be blocked on\n  // them (for example, it might block on password prompt), and therefore won't\n  // exit until we deal with its output.\n  std::exception_ptr eptr;\n  exit_code_set_ = false;\n  while (ch::steady_clock::now() < timeout) {\n    read_and_autorespond_to_output(0);\n\n    try {\n      // throws std::runtime_error or std::system_error\n      exit_code_ = launcher_.wait(0);\n      exit_code_set_ = true;\n      break;\n    } catch (const std::runtime_error& e) {\n      eptr = std::current_exception();\n    }\n\n    std::this_thread::sleep_for(std::chrono::milliseconds(1));\n  }\n\n  if (exit_code_set_) {\n    // the child exited, but there might still be some data left in the pipe to read,\n    // so let's consume it all\n    while (read_and_autorespond_to_output(1, false)); // false = disable autoresponder\n    return exit_code_;\n  } else {\n    // we timed out waiting for child\n    std::rethrow_exception(eptr);\n  }\n}\n\nbool RouterComponentTest::CommandHandle::expect_output(const std::string& str,\n                                                       bool regex,\n                                                       unsigned timeout_ms) {\n  auto now = std::chrono::steady_clock::now();\n  auto until = now + std::chrono::milliseconds(timeout_ms);\n  for (;;) {\n    if (output_contains(str, regex)) return true;\n\n    now = std::chrono::steady_clock::now();\n\n    if (now > until) {\n      return false;\n    }\n\n    if (!read_and_autorespond_to_output(\n          std::chrono::duration_cast<std::chrono::milliseconds>(until - now).count())) return false;\n  }\n}\n\n\nbool RouterComponentTest::CommandHandle::output_contains(const std::string& str,\n                                                         bool regex) const {\n  if (!regex) {\n    return execute_output_raw_.find(str) != std::string::npos;\n  }\n\n  // regex\n  return pattern_found(execute_output_raw_, str);\n}\n\nbool RouterComponentTest::CommandHandle::read_and_autorespond_to_output(unsigned timeout_ms,\n                                                                        bool autoresponder_enabled /*= true*/) {\n  char cmd_output[kReadBufSize] = {0};  // hygiene (cmd_output[bytes_read] = 0 would suffice)\n\n  // blocks until timeout expires (very likely) or until at least one byte is read (unlikely)\n  // throws std::runtime_error on read error\n  int bytes_read = launcher_.read(cmd_output, kReadBufSize-1, timeout_ms); // cmd_output may contain multiple lines\n\n  if (bytes_read > 0) {\n#ifdef _WIN32\n    // On Windows we get \\r\\n instead of \\n, so we need to get rid of the \\r everywhere.\n    // As surprising as it is, WIN32API doesn't provide the automatic conversion:\n    // https://stackoverflow.com/questions/18294650/win32-changing-to-binary-mode-childs-stdout-pipe\n    {\n      char* new_end = std::remove(cmd_output, cmd_output + bytes_read, '\\r');\n      *new_end = '\\0';\n      bytes_read = new_end - cmd_output;\n    }\n#endif\n\n    execute_output_raw_ += cmd_output;\n\n    if (autoresponder_enabled)\n      autorespond_to_matching_lines(bytes_read, cmd_output);\n\n    return true;\n  } else {\n    return false;\n  }\n}\n\nvoid RouterComponentTest::CommandHandle::autorespond_to_matching_lines(int bytes_read, char* cmd_output) {\n\n  // returned lines do not contain the \\n\n  std::vector<std::string> lines = split_str(std::string(cmd_output, cmd_output + bytes_read), '\\n');\n  if (lines.empty())\n    return;\n\n  // it is possible that the last line from the previous call did not match because it arrived incomplete.\n  // Here we try an assumption that the first line is a continuation of last line from previous call.\n  if (last_line_read_.size() && autorespond_on_matching_pattern(last_line_read_ + lines.front())) {\n    // indeed, it was a continuation of previous line. So now we must prevent both fragments from being used again\n    lines.erase(lines.begin());\n    last_line_read_.clear();\n\n    if (lines.empty())\n      return;\n  }\n\n  // try matching all but last line\n  for (auto it = lines.cbegin(); it != lines.cend() - 1; ++it)\n    autorespond_on_matching_pattern(*it);\n\n  // try matching the last line\n  if (autorespond_on_matching_pattern(lines.back()))\n    last_line_read_.clear();\n  else\n    // last line failed to match, it may be because it arrived incomplete. Save it for the next time\n    last_line_read_ = lines.back();\n}\n\nbool RouterComponentTest::CommandHandle::autorespond_on_matching_pattern(const std::string &line) {\n  for (const auto &response: output_responses_) {\n    const std::string &output = response.first;\n    if (line.substr(0, output.size()) == output) {\n      const char* resp = response.second.c_str();\n      launcher_.write(resp, strlen(resp));\n      return true;\n    }\n  }\n\n  return false;\n}\n\nstd::map<std::string, std::string> RouterComponentTest::get_DEFAULT_defaults() const {\n  return {\n    {\"logging_folder\", logging_dir_.str()},\n    {\"plugin_folder\", plugin_dir_.str()},\n    {\"runtime_folder\", stage_dir_.str()},\n    {\"config_folder\", stage_dir_.str()},\n    {\"data_folder\", stage_dir_.str()},\n  };\n}\n\nstd::string RouterComponentTest::make_DEFAULT_section(const std::map<std::string, std::string>* params) const {\n  auto l = [params](const char* key) -> std::string {\n    return (params->count(key))\n        ? std::string(key) + \" = \" + params->at(key) + \"\\n\"\n        : \"\";\n  };\n\n  return params\n    ? std::string(\"[DEFAULT]\\n\")\n        + l(\"logging_folder\")\n        + l(\"plugin_folder\")\n        + l(\"runtime_folder\")\n        + l(\"config_folder\")\n        + l(\"data_folder\")\n        + l(\"keyring_path\")\n        + l(\"master_key_path\")\n        + l(\"master_key_reader\")\n        + l(\"master_key_writer\")\n        + \"\\n\"\n    : std::string(\"[DEFAULT]\\n\")\n        + \"logging_folder = \" + logging_dir_.str() + \"\\n\"\n        + \"plugin_folder = \"  + plugin_dir_.str() + \"\\n\"\n        + \"runtime_folder = \" + stage_dir_.str() + \"\\n\"\n        + \"config_folder = \"  + stage_dir_.str() + \"\\n\"\n        + \"data_folder = \"    + stage_dir_.str() + \"\\n\\n\";\n}\n\nstd::string RouterComponentTest::create_config_file(const std::string &content,\n                                                    const std::map<std::string, std::string> *params,\n                                                    const std::string &directory,\n                                                    const std::string &name) const {\n  Path file_path = Path(directory).join(name);\n  std::ofstream ofs_config(file_path.str());\n\n  if (!ofs_config.good()) {\n    throw(std::runtime_error(\"Could not create config file \" + file_path.str()));\n  }\n\n  ofs_config << make_DEFAULT_section(params);\n  ofs_config << content << std::endl;\n  ofs_config.close();\n\n  return file_path.str();\n}\n\nbool RouterComponentTest::find_in_file(const std::string& file_path,\n    const std::function<bool(const std::string&)>& predicate,\n    std::chrono::milliseconds sleep_time) {\n  const auto STEP = std::chrono::milliseconds(100);\n  std::ifstream in_file;\n  std::ios::streampos cur_pos;\n  do {\n    try {\n      // This is proxy function to account for the fact that I/O can sometimes be slow.\n      if (real_find_in_file(file_path, predicate, in_file, cur_pos))\n        return true;\n    }\n    catch (const std::runtime_error&) {\n      // report I/O error only on the last attempt\n      if (sleep_time == std::chrono::milliseconds(0)) {\n        std::cerr << \"  find_in_file() failed, giving up.\" << std::endl;\n        throw;\n      }\n    }\n\n    const auto sleep_for = std::min(STEP, sleep_time);\n    std::this_thread::sleep_for(sleep_for);\n    sleep_time -= sleep_for;\n\n  } while (sleep_time > std::chrono::milliseconds(0));\n\n  return false;\n}\n\nbool RouterComponentTest::real_find_in_file(\n    const std::string& file_path,\n    const std::function<bool(const std::string&)>& predicate,\n    std::ifstream& in_file,\n    std::ios::streampos& cur_pos) {\n  if (!in_file.is_open()) {\n    in_file.clear();\n    Path file(file_path);\n    in_file.open(file.c_str(), std::ifstream::in);\n    if (!in_file) {\n      throw std::runtime_error(\"Error opening file \" + file.str());\n    }\n    cur_pos = in_file.tellg(); // initialize properly\n  }\n  else {\n    // set current position to the end of what was already read\n    in_file.clear();\n    in_file.seekg(cur_pos);\n  }\n\n  std::string line;\n  while (std::getline(in_file, line)) {\n    cur_pos = in_file.tellg();\n    if (predicate(line))\n      return true;\n  }\n\n  return false;\n}\n\nstd::string RouterComponentTest::get_router_log_output(const std::string& file_name) {\n  std::ifstream in_file;\n\n  Path file(logging_dir_.str() + \"/\" + file_name);\n  in_file.open(file.c_str(), std::ifstream::in);\n  if (!in_file) {\n    return \"Could not open log file \" + file.str() + \" for reading.\";\n  }\n\n  std::string result((std::istreambuf_iterator<char>(in_file)),\n    std::istreambuf_iterator<char>());\n\n  return result;\n}\n"
  },
  {
    "path": "tests/helpers/router_component_test.h",
    "content": "/*\n  Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef _ROUTER_COMPONENT_TEST_H_\n#define _ROUTER_COMPONENT_TEST_H_\n\n#include \"process_launcher.h\"\n#include \"router_test_helpers.h\"\n\n#include <chrono>\n#include <cstring>\n#include <functional>\n#include <sstream>\n#include <map>\n#include <streambuf>\n#include <vector>\n#include <iostream>\n#ifndef _WIN32\n#include <unistd.h>\n#else\n#define NOMINMAX\n#endif\n\nusing mysql_harness::Path;\n\n\n/** @brief maximum number of parameters that can be passed to the launched process */\nconst size_t MAX_PARAMS{30};\n\n/** @class RouterComponentTest\n *\n * Base class for the MySQLRouter component-like tests.\n * Enables creating processes, intercepting their output, writing to input, etc.\n *\n **/\nclass RouterComponentTest {\n\n  // test performance tweaks\n  // shorter timeout -> faster test execution, longer timeout -> increased test stability\n  static constexpr unsigned kDefaultExpectOutputTimeout = 1000;\n\n  static constexpr size_t kReadBufSize = 1024;\n\n public:\n  // wait-timeout should be less than infinite, and long enough that even with valgrind we properly pass the tests\n  static constexpr unsigned kDefaultWaitForExitTimeout = 10 * 1000;\n protected:\n\n  RouterComponentTest();\n  virtual ~RouterComponentTest();\n\n  static void rewrite_js_to_tracefile(const std::string &infile_name, const std::string &outfile_name,\n                                      const std::map<std::string, std::string> &env_vars);\n\n  /** @class CommandHandle\n   *\n   * Object of this class gets return from launch_* method and can be\n   * use to manipulate launched process (get the output, exit code,\n   * inject input, etc.)\n   *\n   **/\n  class CommandHandle {\n   public:\n    /** @brief Checks if the process wrote the specified string to its output.\n     *\n     * This function loops read()ing child process output, until either the\n     * expected output appears, or until timeout is reached. While reading, it\n     * also calls autoresponder to react to any prompts issued by the child process.\n     *\n     * @param str         Expected output string\n     * @param regex       True if str is a regex pattern\n     * @param timeout_ms  Timeout in milliseconds, to wait for the output\n     * @return Returns bool flag indicating if the specified string appeared\n     *                 in the process' output.\n     */\n    bool expect_output(const std::string& str,\n                       bool regex = false,\n                       unsigned timeout_ms = kDefaultExpectOutputTimeout);\n\n    /** @brief Returns the full output that was produced the process till moment\n     *         of calling this method.\n     *  TODO: this description does not match what the code does, this needs to be fixed.\n     */\n    std::string get_full_output() {\n      while (read_and_autorespond_to_output(0)) {}\n      return execute_output_raw_;\n    }\n\n    /**\n     * get the current output of the process.\n     *\n     * doesn't check if there is new content.\n     */\n    std::string get_current_output() const {\n      return execute_output_raw_;\n    }\n\n    /** @brief Register the response that should be written to the process' input descriptor\n     *         when the given string appears on it output while executing expect_output().\n     *\n     * @param query     string that should trigger writing the response\n     * @param response  string that should get written\n     */\n    void register_response(const std::string &query,\n                           const std::string &response) {\n      output_responses_[query] = response;\n    }\n\n    /** @brief Returns the exit code of the process.\n     *\n     *  Must always be called after wait_for_exit(),\n     *  otherwise it throws runtime_error\n     *\n     * @returns exit code of the process\n     */\n    int exit_code() {\n      if (!exit_code_set_) {\n        throw std::runtime_error(\"RouterComponentTest::Command_handle: exit_code() called without wait_for_exit()!\");\n      }\n      return exit_code_;\n    }\n\n    /** @brief Waits for the process to exit, while reading its output and autoresponding to prompts\n     *\n     *  If the process did not finish yet, it waits the given number of milliseconds.\n     *  If the timeout expired, it throws runtime_error.\n     *  In case of failure, it throws system_error.\n     *\n     * @param timeout_ms maximum amount of time to wait for the process to finish\n     * @throws std::runtime_error on timeout, std::system_error on failure\n     * @returns exit code of the process\n     */\n    int wait_for_exit(unsigned timeout_ms = kDefaultWaitForExitTimeout) {\n      // wait_for_exit() is a convenient short name, but a little unclear with respect\n      // to what this function actually does\n      return wait_for_exit_while_reading_and_autoresponding_to_output(timeout_ms);\n    }\n\n    /** @brief Returns process PID\n     *\n     * @returns PID of the process\n     */\n    uint64_t get_pid() const {\n      return launcher_.get_pid();\n    }\n\n    int kill() {\n      try {\n        return launcher_.kill();\n      } catch(std::exception& e) {\n        fprintf(stderr, \"failed killing process %s: %s\\n\", launcher_.get_cmd_line().c_str(), e.what());\n        return 1;\n      }\n    }\n\n   private:\n    CommandHandle(const std::string &app_cmd,\n                 const char **args,\n                 bool include_stderr):\n       launcher_(app_cmd.c_str(), args, include_stderr) {\n     launcher_.start();\n    }\n\n  protected:\n    bool output_contains(const std::string& str,\n                         bool regex = false) const;\n\n    /** @brief read() output from child until timeout expires, optionally autoresponding to prompts\n     *\n     * @param timeout_ms timeout in milliseconds\n     * @param autoresponder_enabled autoresponder is enabled if true (default)\n     * @returns true if at least one byte was read\n     */\n    bool read_and_autorespond_to_output(unsigned timeout_ms, bool autoresponder_enabled = true);\n\n    /** @brief write() predefined responses on found predefined patterns\n     *\n     * @param bytes_read buffer length\n     * @param cmd_output buffer containig output to be scanned for triggers and possibly autoresponded to\n     */\n    void autorespond_to_matching_lines(int bytes_read, char* cmd_output);\n\n    /** @brief write() a predefined response if a predefined pattern is matched\n     *\n     * @param line line of output that will trigger a response, if matched\n     * @returns true if an autoresponse was sent\n     */\n    bool autorespond_on_matching_pattern(const std::string &line);\n\n    /** @brief see wait_for_exit() */\n    int wait_for_exit_while_reading_and_autoresponding_to_output(unsigned timeout_ms);\n\n    mysql_harness::ProcessLauncher launcher_; // <- this guy's destructor takes care of\n                               // killing the spawned process\n    std::string execute_output_raw_;\n    std::string last_line_read_;\n    std::map<std::string, std::string> output_responses_;\n    int exit_code_;\n    bool exit_code_set_{false};\n\n    friend class RouterComponentTest;\n  };  // class CommandHandle\n\n  /** @brief Gtest class SetUp, prepares the testcase.\n   */\n  virtual void SetUp();\n\n  /** @brief Launches the MySQLRouter process.\n   *\n   * @param   params string containing command line parameters to pass to process\n   * @param   catch_stderr bool flag indicating if the process' error output stream\n   *                       should be included in the output caught from the process\n   * @param   with_sudo    bool flag indicating if the process' should be execute with\n   *                       sudo priviledges\n   *\n   * @returns handle to the launched proccess\n   */\n  CommandHandle launch_router(const std::string &params,\n                              bool catch_stderr = true,\n                              bool with_sudo = false) const;\n\n  /** @brief Launches the MySQLRouter process.\n   *\n   * @param   params vector<string> containing command line parameters to pass to process\n   * @param   catch_stderr bool flag indicating if the process' error output stream\n   *                       should be included in the output caught from the process\n   * @param   with_sudo    bool flag indicating if the process' should be execute with\n   *                       sudo priviledges\n   *\n   * @returns handle to the launched proccess\n   */\n  CommandHandle launch_router(const std::vector<std::string> &params,\n                              bool catch_stderr = true,\n                              bool with_sudo = false) const;\n\n  /** @brief Launches the MySQLServerMock process.\n   *\n   * @param   json_file  path to the json file containing expected queries definitions\n   * @param   port       number of the port where the mock server will accept the\n   *                     client connections\n   * @param   debug_mode if true all the queries and result get printed on the\n   *                     standard output\n   * @param   http_port  port number where the http_server module of the mock server\n   *                     will accept REST client requests\n   * @param   module_prefix base-path for javascript modules used by the tests\n   *\n   * @returns handle to the launched proccess\n   */\n  CommandHandle launch_mysql_server_mock(const std::string& json_file,\n                                         unsigned port,\n                                         bool debug_mode = false,\n                                         uint16_t http_port = 0,\n                                         const std::string& module_prefix = \"\") const;\n\n  /** @brief Launches a process.\n   *\n   * @param command       path to executable\n   * @param params        space-separated list of commanline parameters to pass to the executable\n   * @param catch_stderr  if true stderr will also be captured (combined with stdout)\n   *\n   * @returns handle to the launched proccess\n   */\n  CommandHandle launch_command(const std::string &command,\n                               const std::string &params,\n                               bool catch_stderr = true) const;\n\n\n  /** @brief Launches a process.\n   *\n   * @param command       path to executable\n   * @param params        array of commanline parameters to pass to the executable\n   * @param catch_stderr  if true stderr will also be captured (combined with stdout)\n   *\n   * @returns handle to the launched proccess\n   */\n  CommandHandle launch_command(const std::string &command,\n                               const std::vector<std::string> &params,\n                               bool catch_stderr) const;\n\n  /** @brief Removes non-empty directory recursively.\n   *\n   * @param dir name of the directory to remove\n   *\n   * @returns 0 on success, error code on failure\n   */\n  static int purge_dir(const std::string& dir);\n\n  /** @brief Creates a temporary directory with partially-random name and returns\n   * its path.\n   *\n   * @note This is a convenience proxy function to mysql_harness::get_tmp_dir(),\n   * see documentation there for more details.\n   *\n   * @param name name to be used as a directory name prefix\n   *\n   * @return path to the created directory\n   *\n   * @throws std::runtime_error if operation failed\n   */\n  static std::string get_tmp_dir(const std::string &name = \"router\");\n\n  /** @brief Probes if the selected TCP port is accepting the connections.\n   *\n   * @param port          TCP port number to check\n   * @param timeout_msec  maximum timeout to wait for the port\n   * @param hostname      name/IP address of the network host to check\n   *\n   * @returns true if the selected port accepts connections, false otherwise\n   */\n  bool wait_for_port_ready(unsigned port, unsigned timeout_msec,\n                           const std::string &hostname = \"127.0.0.1\") const;\n\n  /** @brief Gets path to the directory containing testing data\n   *         (conf files, json files).\n   */\n  const Path &get_data_dir() const {\n    return data_dir_;\n  }\n\n  /** @brief Gets path to the directory used as log output directory\n  */\n  const Path &get_logging_dir() const {\n    return logging_dir_;\n  }\n\n  /** @brief replace the 'process.env.{id}' in the input stream\n   *\n   * @pre assumes the input stream is a JS(ON) document with 'process.env.{id}' references.\n   *\n   * replaces all references of process.env.{id} with the \"environment variables\" provided\n   * in env_vars, line-by-line\n   */\n  static void replace_process_env(std::istream &ins,\n                                  std::ostream &outs,\n                                  const std::map<std::string, std::string> &env_vars);\n\n\n  /** @brief returns a map with default [DEFAULT] section parameters\n   *\n   * @return default parameters for [DEFAULT] section\n   */\n  std::map<std::string, std::string> get_DEFAULT_defaults() const;\n\n  std::string create_config_file(const std::string &content = \"\",\n                                 const std::map<std::string, std::string> *params = nullptr,\n                                 const std::string &directory = get_tmp_dir(\"conf\"),\n                                 const std::string &name = \"mysqlrouter.conf\") const;\n\n  void set_origin(const Path &origin) {\n    origin_dir_ = origin;\n  }\n\n  const Path& get_mysqlrouter_exec() const {\n    return mysqlrouter_exec_;\n  }\n\n  /**\n   * get Path to mysql_server_mock inside the build-dir.\n   *\n   * valid after SetUp() got called.\n   */\n  const Path& get_mysqlserver_mock_exec() const {\n    return mysqlserver_mock_exec_;\n  }\n\n  void set_mysqlrouter_exec(const Path &path) {\n    mysqlrouter_exec_ = path;\n  }\n\n  /** @brief returns true if the selected file contains a string\n  *          that is true for a given predicate\n  *\n  * @param file_path path to the file we want to serach\n  * @param predicate predicate to test the file\n  * @param sleep_time max time to wait for the entry in the file\n  */\n  bool find_in_file(const std::string& file_path, const std::function<bool(const std::string&)>& predicate,\n    std::chrono::milliseconds sleep_time = std::chrono::milliseconds(5000));\n\n  /** @brief returns the content of the router logfile as a string\n  *\n  * @param file_name name of the logfile\n  */\n  std::string get_router_log_output(const std::string& file_name = \"mysqlrouter.log\");\n\n\n protected:\n  /** @brief returns a [DEFAULT] section as string\n   *\n   * @param params map of [DEFAULT] section parameters\n   * @returns [DEFAULT] section text\n   */\n  std::string make_DEFAULT_section(const std::map<std::string, std::string>* params) const;\n\n\n private:\n  void get_params(const std::string &command,\n                  const std::vector<std::string> &params_vec,\n                  const char* out_params[MAX_PARAMS]) const;\n\n  bool real_find_in_file(const std::string& file_path,\n                        const std::function<bool(const std::string&)>& predicate,\n                        std::ifstream& in_file,\n                        std::ios::streampos& cur_pos);\n\n\n  Path data_dir_;\n  Path origin_dir_;\n  Path stage_dir_;\n  Path plugin_dir_;\n  Path logging_dir_;\n  Path mysqlrouter_exec_;\n  Path mysqlserver_mock_exec_;\n};\n\n#endif // _ROUTER_COMPONENT_TEST_H_\n"
  },
  {
    "path": "tests/helpers/router_test_helpers.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"cmd_exec.h\"\n#include \"router_test_helpers.h\"\n#include \"mysql/harness/filesystem.h\"\n#include \"mysqlrouter/utils.h\"\n\n#include <cassert>\n#include <cerrno>\n#include <chrono>\n#include <cstdlib>\n#include <cstring>\n#include <cstring>\n#include <iostream>\n#include <stdexcept>\n#include <thread>\n\n#ifndef _WIN32\n#  include <unistd.h>\n#  include <regex.h>\n#else\n#  include <windows.h>\n#  include <winsock2.h>\n#  include <direct.h>\n#  include <regex>\n#  define getcwd _getcwd\ntypedef long ssize_t;\n#endif\n\nusing mysql_harness::Path;\n\nPath get_cmake_source_dir() {\n  Path result;\n\n  // PB2 specific source location\n  char *env_pb2workdir = std::getenv(\"PB2WORKDIR\");\n  char *env_sourcename = std::getenv(\"SOURCENAME\");\n  char *env_tmpdir = std::getenv(\"TMPDIR\");\n  if ((env_pb2workdir && env_sourcename && env_tmpdir)\n      && (strlen(env_pb2workdir) && strlen(env_tmpdir) && strlen(env_sourcename))) {\n    result = Path(env_tmpdir);\n    result.append(Path(env_sourcename));\n    if (result.exists()) {\n      return result;\n    }\n  }\n\n  char *env_value = std::getenv(\"CMAKE_SOURCE_DIR\");\n\n  if (env_value == nullptr) {\n    // try a few places\n    result = Path(get_cwd()).join(\"..\");\n    result = Path(result).real_path();\n  } else {\n    result = Path(env_value).real_path();\n  }\n\n  if (!result.join(\"src\").join(\"router\").join(\"src\").join(\"router_app.cc\").is_regular()) {\n    throw std::runtime_error(\n        \"Source directory not available. Use CMAKE_SOURCE_DIR environment variable; was \" + result.str());\n  }\n\n  return result;\n}\n\nPath get_envvar_path(const std::string &envvar, Path alternative = Path()) {\n  char *env_value = std::getenv(envvar.c_str());\n  Path result;\n  if (env_value == nullptr) {\n    result = alternative;\n  } else {\n    result = Path(env_value).real_path();\n  }\n  return result;\n}\n\nconst std::string get_cwd() {\n  char buffer[FILENAME_MAX];\n  if (!getcwd(buffer, FILENAME_MAX)) {\n    throw std::runtime_error(\"getcwd failed: \" + std::string(strerror(errno)));\n  }\n  return std::string(buffer);\n}\n\nconst std::string change_cwd(std::string &dir) {\n  auto cwd = get_cwd();\n#ifndef _WIN32\n  if (chdir(dir.c_str()) == -1) {\n#else\n  if (!SetCurrentDirectory(dir.c_str())) {\n#endif\n    throw std::runtime_error(\"chdir failed: \" + mysqlrouter::get_last_error());\n  }\n  return cwd;\n}\n\nbool ends_with(const std::string &str, const std::string &suffix) {\n  auto suffix_size = suffix.size();\n  auto str_size = str.size();\n  return (str_size >= suffix_size &&\n          str.compare(str_size - suffix_size, str_size, suffix) == 0);\n}\n\nbool starts_with(const std::string &str, const std::string &prefix) {\n  auto prefix_size = prefix.size();\n  auto str_size = str.size();\n  return (str_size >= prefix_size &&\n          str.compare(0, prefix_size, prefix) == 0);\n}\n\nsize_t read_bytes_with_timeout(int sockfd, void* buffer, size_t n_bytes, uint64_t timeout_in_ms) {\n\n  // returns epoch time (aka unix time, etc), expressed in milliseconds\n  auto get_epoch_in_ms = []() -> uint64_t {\n    using namespace std::chrono;\n    time_point<system_clock> now = system_clock::now();\n    return static_cast<uint64_t>(duration_cast<milliseconds>(now.time_since_epoch()).count());\n  };\n\n  // calculate deadline time\n  uint64_t now_in_ms = get_epoch_in_ms();\n  uint64_t deadline_epoch_in_ms = now_in_ms + timeout_in_ms;\n\n  // read until 1 of 3 things happen: enough bytes were read, we time out or read() fails\n  size_t bytes_read = 0;\n  while (true) {\n#ifndef _WIN32\n    ssize_t res = read(sockfd, static_cast<char*>(buffer) + bytes_read, n_bytes - bytes_read);\n#else\n    WSASetLastError(0);\n    ssize_t res = recv(sockfd, static_cast<char*>(buffer) + bytes_read, n_bytes - bytes_read, 0);\n#endif\n\n    if (res == 0) {   // reached EOF?\n      return bytes_read;\n    }\n\n    if (get_epoch_in_ms() > deadline_epoch_in_ms) {\n      throw std::runtime_error(\"read() timed out\");\n    }\n\n    if (res == -1) {\n#ifndef _WIN32\n      if (errno != EAGAIN) {\n        throw std::runtime_error(std::string(\"read() failed: \") + strerror(errno));\n      }\n#else\n      int err_code = WSAGetLastError();\n      if (err_code != 0) {\n        throw std::runtime_error(\"recv() failed with error: \" + get_last_error(err_code));\n      }\n\n#endif\n    } else {\n      bytes_read += static_cast<size_t>(res);\n      if (bytes_read >= n_bytes) {\n        assert(bytes_read == n_bytes);\n        return bytes_read;\n      }\n    }\n\n    std::this_thread::sleep_for(std::chrono::milliseconds(10));\n  }\n}\n\n#ifdef _WIN32\nstd::string get_last_error(int err_code) {\n  char message[512];\n  FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM\n    | FORMAT_MESSAGE_IGNORE_INSERTS\n    | FORMAT_MESSAGE_ALLOCATE_BUFFER,\n    nullptr, GetLastError(),\n    LANG_NEUTRAL, message, sizeof(message),\n    nullptr);\n  return std::string(message);\n}\n#endif\n\nvoid init_windows_sockets() {\n#ifdef _WIN32\n  WSADATA wsaData;\n  int iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);\n  if (iResult != 0) {\n    std::cerr << \"WSAStartup() failed\\n\";\n    exit(1);\n  }\n#endif\n}\n\nbool pattern_found(const std::string &s,\n                   const std::string &pattern) {\n#ifndef _WIN32\n  regex_t regex;\n  auto r = regcomp(&regex, pattern.c_str(), 0);\n  if (r) {\n    throw std::runtime_error(\"Error compiling regex pattern: \" + pattern);\n  }\n  r = regexec(&regex, s.c_str(), 0, NULL, 0);\n  regfree(&regex);\n  return (r == 0);\n#else\n  std::smatch m;\n  std::regex r(pattern);\n  bool result = std::regex_search(s, m, r);\n\n  return result;\n#endif\n}\n\nint get_socket_errno() {\n#ifndef _WIN32\n  return errno;\n#else\n  return WSAGetLastError();\n#endif\n}\n"
  },
  {
    "path": "tests/helpers/router_test_helpers.h",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef ROUTER_TESTS_TEST_HELPERS_INCLUDED\n#define ROUTER_TESTS_TEST_HELPERS_INCLUDED\n\n#include <typeinfo>\n\n#define SKIP_GIT_TESTS(COND)\\\n  if(COND) {\\\n     std::cout << \"[  SKIPPED ] Tests using Git repository skipped\" << std::endl;\\\n     return;\\\n  }\n\n#define ASSERT_THROW_LIKE(expr, exc, msg) try { \\\n      expr;\\\n      FAIL() << \"Expected exception of type \" #exc << \" but got none\\n\";\\\n    } catch (const exc &e) {\\\n      if (std::string(e.what()).find(msg) == std::string::npos) {\\\n          FAIL() << \"Expected exception of type \" #exc \" with message: \" << msg << \"\\nbut got message: \" << e.what() << \"\\n\";\\\n      }\\\n    } catch (const std::exception &e) {\\\n      FAIL() << \"Expected exception of type \" #exc \"\\nbut got \" << typeid(e).name() << \": \" << e.what() << \"\\n\";\\\n    }\n\n/*\n * it would be great if the catch-all part could report the type of the\n * exception we got in a simpler way.\n */\n#define EXPECT_THROW_LIKE(expr, exc, msg) try { \\\n      expr;\\\n      ADD_FAILURE() << \"Expected exception of type \" #exc << \" but got none\\n\";\\\n    } catch (const exc &e) {\\\n      if (std::string(e.what()).find(msg) == std::string::npos) {\\\n          ADD_FAILURE() << \"Expected exception of type \" #exc \" with message: \" << msg << \"\\nbut got message: \" << e.what() << \"\\n\";\\\n      }\\\n    } catch (...) {\\\n      auto user_e = std::current_exception(); \\\n      try { \\\n        std::rethrow_exception(user_e); \\\n      } catch (const std::exception &e) { \\\n        ADD_FAILURE() << \"Expected exception of type \" #exc << \"\\nbut got \" << typeid(e).name() << \": \" << e.what() << \"\\n\";\\\n      } \\\n    }\n\n#include \"mysql/harness/filesystem.h\"\n\n/** @brief Returns the CMake source root folder\n *\n * @return mysql_harness::Path\n */\nmysql_harness::Path get_cmake_source_dir();\n\n/** @brief Gets environment variable as path\n *\n * Gets environment envvar and returns it as Path. When the environment\n * variable is not set, the alternative is tried.\n *\n * Throws runtime_error when the folder is not available.\n *\n * @param envvar Name of the environment variable\n * @param alternative Alternative Path when environment variable is not available\n * @return mysql_harness::Path\n */\nmysql_harness::Path get_envvar_path(const std::string &envvar, mysql_harness::Path alternative);\n\n/** @brief Returns the current working directory\n *\n * Uses `getcwd()` and returns the current working directory as as std::string.\n *\n * Throws std::runtime_error on errors.\n *\n * @return std::string\n */\nconst std::string get_cwd();\n\n/** @brief Changes the current working directory\n *\n * Uses `chdir()` to change the current working directory. When succesfully\n * change to the folder, the old working directory is returned.\n *\n * Throws std::runtime_error on errors.\n *\n * @return std::string\n */\nconst std::string change_cwd(std::string &dir);\n\n/** @brief Checks whether string ends with the specified suffix\n *\n * Returns true if the string ends with the given suffix.\n *\n * @return bool\n */\nbool ends_with(const std::string &str, const std::string &suffix);\n\n/** @brief Checks whether string starts with the specified prefix\n *\n * Returns true if the string begins with the given prefix.\n *\n * @return bool\n */\nbool starts_with(const std::string &str, const std::string &prefix);\n\n/** @brief Reads a specified number of bytes from a non-blocking socket\n *\n * reads a non-blocking socket until one of three things happen:\n *   1. specified number of bytes have been read - returns this number\n *   2. timeout expires - throws, describing the error\n *   3. read() fails    - throws, describing the error\n *\n * Returns number of bytes read (should be the number of bytes requested,\n * can be less on EOF).  Throws std::runtime_error on I/O error or timeout;\n * the reason can be extracted from the thrown object with what() method.\n *\n * @param sockfd file decriptor\n * @param buffer to store read bytes\n * @param n_bytes of bytes to read\n * @param timeout_in_ms expressed in milliseconds\n *\n * @return number of bytes read\n */\nsize_t read_bytes_with_timeout(int sockfd, void* buffer, size_t n_bytes, uint64_t timeout_in_ms);\n\n#ifdef _WIN32\nstd::string get_last_error(int err_code);\n#endif\n\n/** @brief Checks if the given regex pattern can be found in the input string\n *\n *\n * @param s       input string to check\n * @param pattern regex pattern to look for\n *\n * @return true if the given pattern could be found, false otherwise\n */\nbool pattern_found(const std::string &s,\n                   const std::string &pattern);\n\n/** @brief Returns last socket call error number.\n */\nint get_socket_errno();\n\n/** @brief Initializes Windows sockets (no-op on other OSes)\n *\n * Exits program with error upon failure.\n */\nvoid init_windows_sockets();\n\n#endif // ROUTER_TESTS_TEST_HELPERS_INCLUDED\n"
  },
  {
    "path": "tests/helpers/script_generator.cc",
    "content": "/*\n Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n This program is free software; you can redistribute it and/or modify\n it under the terms of the GNU General Public License, version 2.0,\n as published by the Free Software Foundation.\n\n This program is also distributed with certain software (including\n but not limited to OpenSSL) that is licensed under separate terms,\n as designated in a particular file or component or in included license\n documentation.  The authors of MySQL hereby grant you an additional\n permission to link the program and your derivative works with the\n separately licensed software that they have included with MySQL.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program; if not, write to the Free Software\n Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n */\n\n\n#include <fstream>\n#include <sys/stat.h>\n#include <string>\n\n#include \"script_generator.h\"\n\nusing mysql_harness::Path;\n\nstd::string ScriptGenerator::get_reader_incorrect_master_key_script() const {\n#ifdef _WIN32\n  Path script(tmp_path_.join(\"reader_script.bat\").str());\n#else\n  Path script(tmp_path_.join(\"reader_script.sh\").str());\n#endif\n  {\n    std::ofstream file(script.str());\n#ifdef _WIN32\n    file << \"@echo off\" << std::endl;\n    file << \"echo master_key_123\";\n#else\n    file << \"#!/bin/bash\" << std::endl;\n    file << \"echo master_key_123\" << std::endl;\n#endif\n  }\n#ifndef _WIN32\n  chmod(script.c_str(), 0700);\n#endif\n  return script.c_str();\n}\n\nstd::string ScriptGenerator::get_reader_script() const {\n#ifdef _WIN32\n  Path script(tmp_path_.join(\"reader_script.bat\").str());\n#else\n  Path script(tmp_path_.join(\"reader_script.sh\").str());\n#endif\n  {\n    std::ofstream file(script.str());\n#ifdef _WIN32\n    file << \"@echo off\" << std::endl;\n    std::string file_path = tmp_path_.join(\"master_key\").str();\n    file << \"type nul >> \" << file_path << std::endl;\n    for (char& c : file_path)\n        if (c == '/')\n            c = '\\\\';\n    file << \"type \" << file_path << std::endl;\n#else\n    file << \"#!/bin/bash\" << std::endl;\n    file << \"touch \" << tmp_path_.join(\"master_key\").str() << std::endl;\n    file << \"cat \" << tmp_path_.join(\"master_key\").str() << std::endl;\n#endif\n  }\n#ifndef _WIN32\n  chmod(script.c_str(), 0700);\n#endif\n  return script.c_str();\n}\n\nstd::string ScriptGenerator::get_writer_script() const {\n\n  Path writer_path = bin_path_.join(get_writer_exec());\n  return writer_path.str();\n}\n\nstd::string ScriptGenerator::get_writer_exec() const {\n   std::string master_key_path = tmp_path_.join(\"master_key\").str();\n   // add master_key location to environment: MASTER_KEY_PATH\n   int err_code;\n#ifdef _WIN32\n   err_code = _putenv_s(\"MASTER_KEY_PATH\", master_key_path.c_str());\n#else\n   err_code = ::setenv(\"MASTER_KEY_PATH\", master_key_path.c_str(), 1);\n#endif\n   if (err_code)\n       throw std::runtime_error(\"Failed to add MASTER_KEY_PATH\");\n\n#ifdef _WIN32\n   return \"master_key_test_writer.exe\";\n#else\n   return \"master_key_test_writer\";\n#endif\n}\n\nstd::string ScriptGenerator::get_fake_reader_script() const {\n  return \"fake_reader_script\";\n}\n\nstd::string ScriptGenerator::get_fake_writer_script() const {\n  return \"fake_writer_script\";\n}\n"
  },
  {
    "path": "tests/helpers/script_generator.h",
    "content": "/*\n Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n This program is free software; you can redistribute it and/or modify\n it under the terms of the GNU General Public License, version 2.0,\n as published by the Free Software Foundation.\n\n This program is also distributed with certain software (including\n but not limited to OpenSSL) that is licensed under separate terms,\n as designated in a particular file or component or in included license\n documentation.  The authors of MySQL hereby grant you an additional\n permission to link the program and your derivative works with the\n separately licensed software that they have included with MySQL.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program; if not, write to the Free Software\n Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n */\n\n#ifndef TESTS_COMPONENT_SCRIPT_MANAGER_H_\n#define TESTS_COMPONENT_SCRIPT_MANAGER_H_\n\n#include \"mysql/harness/filesystem.h\"\n\nclass ScriptGenerator {\n  mysql_harness::Path bin_path_;\n  mysql_harness::Path tmp_path_;\n\npublic:\n  ScriptGenerator(const mysql_harness::Path& bin_path, const std::string& tmp_directory)\n      : bin_path_(bin_path), tmp_path_{tmp_directory} {\n  }\n\n  std::string get_reader_incorrect_master_key_script() const;\n  std::string get_reader_script() const;\n  std::string get_writer_script() const;\n  std::string get_writer_exec() const;\n  std::string get_fake_reader_script() const;\n  std::string get_fake_writer_script() const;\n}; // end of script manager\n\n#endif /* TESTS_COMPONENT_SCRIPT_MANAGER_H_ */\n"
  },
  {
    "path": "tests/helpers/tcp_port_pool.cc",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include \"mysql/harness/filesystem.h\"\n\n#ifndef _WIN32\n#  include <sys/file.h>\n#  include <unistd.h>\n#else\n#  include <windows.h>\n#endif\n\n#include <fcntl.h>\n\n#include \"tcp_port_pool.h\"\n#include \"mysqlrouter/utils.h\"\n\n\nusing mysql_harness::Path;\n\n#ifndef _WIN32\nbool UniqueId::lock_file(const std::string& file_name) {\n  lock_file_fd_ = open(file_name.c_str(), O_RDWR | O_CREAT, 0666);\n\n  if (lock_file_fd_ >= 0) {\n#ifdef __sun\n    struct flock fl;\n\n    fl.l_start = 0;\n    fl.l_len = 0;\n    fl.l_type = F_WRLCK;\n    fl.l_whence = SEEK_SET;\n\n    int lock = fcntl(lock_file_fd_, F_SETLK, &fl);\n#else\n    int lock = flock(lock_file_fd_, LOCK_EX | LOCK_NB);\n#endif\n    if (lock) {\n      // no lock so no luck, try the next one\n      close(lock_file_fd_);\n      return false;\n    }\n\n    // obtained the lock\n    return true;\n  }\n\n  return false;\n}\n\nstd::string UniqueId::get_lock_file_dir() const {\n  // this is what MTR uses, see mysql-test/lib/mtr_unique.pm for details\n  return \"/tmp/mysql-unique-ids\";\n}\n\n#else\n\nbool UniqueId::lock_file(const std::string& file_name) {\n  lock_file_fd_ = ::CreateFile(file_name.c_str(), GENERIC_READ, 0, NULL, OPEN_ALWAYS, 0, NULL);\n  if (lock_file_fd_ != NULL && lock_file_fd_ != INVALID_HANDLE_VALUE) {\n    return true;\n  }\n\n  return false;\n}\n\nstd::string UniqueId::get_lock_file_dir() const {\n  // this are env variables that MTR uses, see mysql-test/lib/mtr_unique.pm for details\n  DWORD buff_size = 65535;\n  std::vector<char> buffer;\n  buffer.resize(buff_size);\n  buff_size = GetEnvironmentVariableA(\"ALLUSERSPROFILE\", &buffer[0], buff_size);\n  if (!buff_size) {\n    buff_size = GetEnvironmentVariableA(\"TEMP\", &buffer[0], buff_size);\n  }\n\n  if (!buff_size) {\n    throw std::runtime_error(\"Could not get directory for lock files.\");\n  }\n\n  std::string result(buffer.begin(), buffer.begin()+buff_size);\n  result.append(\"\\\\mysql-unique-ids\");\n  return result;\n}\n\n#endif\n\nUniqueId::UniqueId(unsigned start_from, unsigned range) {\n  const std::string lock_file_dir = get_lock_file_dir();\n  mysqlrouter::mkdir(lock_file_dir, 0777);\n\n  for (unsigned i = 0; i < range; i++) {\n    id_ = start_from + i;\n    Path lock_file_path(lock_file_dir);\n    lock_file_path.append(std::to_string(id_));\n    lock_file_name_ = lock_file_path.str();\n\n    if (lock_file(lock_file_name_.c_str())) {\n      // obtained the lock, we are good to go\n      return;\n    }\n  }\n\n  throw std::runtime_error(\"Could not get uniqe id from the given range\");\n}\n\nUniqueId::~UniqueId() {\n#ifndef _WIN32\n  if (lock_file_fd_ > 0) {\n    close(lock_file_fd_);\n  }\n\n  /*\n   * Removing lock file may result in race condition, both fcntl and flock are affected by this\n   * issue, consider the following scenario.\n   *\n   *           process A           process B\n   *     1. fd_a = open(file)                     // process A opens file\n   *     2. fcntl(fd_a) == 0                      // process A acquires lock on file\n   *     3.                    fd_b = open(file)  // process B opens file\n   *     4.                    fcntl(fd_b) == -1  // process B fails to acquire lock\n   *     5. close(fd_a)                           // process A closes file\n   *     6. unlink(file)                          // process A removes file name\n   *     7. fd_a = open(file)                     // process A opens file once again\n   *     8. fcntl(fd_a) == 0                      // process A acquires lock on the file\n   *     9.                    close(fd_b)        // process B closes file\n   *    10.                    unlink(file)       // process B removes file name\n   *    11.                    fd_b = open(file)  // process B opens file\n   *    12.                    fcntl(fd_b) == 0   // process B acquires lock on file\n   *\n   *    At this point both process A and process B have lock on the same file.\n   */\n\n#else\n  if (lock_file_fd_ != NULL && lock_file_fd_ != INVALID_HANDLE_VALUE) {\n    ::CloseHandle(lock_file_fd_);\n  }\n\n  if (!lock_file_name_.empty()) {\n    mysql_harness::delete_file(lock_file_name_);\n  }\n#endif\n}\n\nUniqueId::UniqueId(UniqueId&& other) {\n  id_ = other.id_;\n  lock_file_fd_ = other.lock_file_fd_;\n  lock_file_name_ = other.lock_file_name_;\n\n  // mark moved object as no longer owning of the resources\n#ifndef _WIN32\n  other.lock_file_fd_ = -1;\n#else\n  other.lock_file_fd_ = INVALID_HANDLE_VALUE;\n#endif\n\n  other.lock_file_name_ = \"\";\n}\n\nunsigned TcpPortPool::get_next_available() {\n  if (number_of_ids_used_ >= kMaxPort) {\n    throw std::runtime_error(\"No more available ports from UniquePortsGroup\");\n  }\n\n  // this is the formula that mysql-test also uses to map lock filename to actual port number\n  return 10000 + unique_id_.get() * kMaxPort + number_of_ids_used_++;\n}\n"
  },
  {
    "path": "tests/helpers/tcp_port_pool.h",
    "content": "/*\n  Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef _TCP_PORT_POOL_H_\n#define _TCP_PORT_POOL_H_\n\n/** @class UniqueID\n *\n * Helper class allowing mechanism to retrieve system-level unique identifier.\n * Compatible with mysql-test MTR, see mysql-test/lib/mtr_unique.pm for details\n *\n **/\nclass UniqueId {\n public:\n  UniqueId(unsigned start_from, unsigned range);\n  UniqueId(UniqueId&& other);\n  ~UniqueId();\n\n  UniqueId(const UniqueId&) = delete;\n  UniqueId& operator=(const UniqueId&) = delete;\n\n  unsigned get() const {\n    return id_;\n  }\n\n private:\n   bool lock_file(const std::string& file_name);\n   std::string get_lock_file_dir() const;\n\n  unsigned id_;\n#ifndef _WIN32\n  int lock_file_fd_;\n#else\n  HANDLE lock_file_fd_;\n#endif\n  std::string lock_file_name_;\n};\n\n/** @class TcpPortPool\n *\n * Helper class allowing mechanism to retrieve pool of the system-level unique TCP port numbers.\n * Compatible with mysql-test MTR, see mysql-test/lib/mtr_unique.pm for details.\n *\n **/\nclass TcpPortPool {\npublic:\n  TcpPortPool(unsigned start_from = 1, unsigned range = 300):\n    unique_id_(start_from, range) {}\n\n  TcpPortPool(const TcpPortPool&) = delete;\n  TcpPortPool& operator=(const TcpPortPool&) = delete;\n  TcpPortPool(TcpPortPool&& other) = default;\n\n  unsigned get_next_available();\nprivate:\n  UniqueId unique_id_;\n  unsigned number_of_ids_used_{0};\n  static const int kMaxPort{10};\n};\n\n#endif // _TCP_PORT_POOL_H_\n"
  },
  {
    "path": "tests/legal/test_legal.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#ifndef _WIN32 // this test fails on Windows due to Git/shell problems\n\n#include \"cmd_exec.h\"\n#include \"router_test_helpers.h\"\n#include \"mysql/harness/filesystem.h\"\n\n#include <algorithm>\n#include <cstdlib>\n#include <fstream>\n#include <iostream>\n#include <sstream>\n#include <string>\n\n#include \"gmock/gmock.h\"\n\n#ifdef GTEST_USES_POSIX_RE\n#include <regex.h>\n#endif\nusing mysql_harness::Path;\n\nstruct GitInfo {\n  Path file;\n  int year_first_commit;\n  int year_last_commit;\n};\n\nPath g_origin;\nPath g_source_dir;\nstd::vector<GitInfo> g_git_tracked_files;\n\nconst std::vector<std::string> kLicenseSnippets{\n    \"This program is free software; you can redistribute it\",\n    \"it under the terms of the GNU General Public License, version 2.0,\",\n    \"\",\n    \"This program is also distributed with certain software (including\", // the openssl exception\n    \"This program is distributed in the hope that\",\n    \"02110-1301\", // last line of the copyright header\n};\n\n// Ignored file extensions\nconst std::vector<std::string> kIgnoredExtensions{\n    \".o\", \".pyc\", \".pyo\", \".conf.in\", \".cfg.in\", \".cfg\", \".html\", \".css\", \".conf\", \".ini\", \".swp\",\n    \".json\", \".md\", \".js\"\n};\n\nconst std::vector<std::string> kIgnoredFileNames{\n    \".gitignore\",\n    \"nt_servc.cc\",\n    \"nt_servc.h\",\n    \"License.txt\",\n    \"Doxyfile.in\",\n#ifndef _WIN32\n    \"README.md\" // symlink on Unix-like, doesn't work on Windows\n#endif\n};\n\n// Paths to ignore; relative to repository root\nconst std::vector<Path> kIgnoredPaths{\n    Path(\"src/harness/internal/\"),\n    Path(\"src/harness/README.txt\"),\n    Path(\"packaging\"),\n    Path(\"internal\"),\n    Path(\".git\"),\n    Path(\".idea\"),\n    Path(\"build\"),\n    Path(\"ext\"),\n    Path(\"tests/fuzzers/corpus/\"),\n    Path(\"tests/fuzzers/README.txt\"),\n};\n\nbool is_ignored_path(Path path, const std::vector<Path> ignored_paths) {\n  // Check paths we are ignoring\n  Path fullpath(Path(g_source_dir).real_path());\n  for (auto &it: ignored_paths) {\n    auto tmp = Path(fullpath).join(it);\n    if (tmp == path) {\n      return true;\n    }\n    auto tmp_dirname = path.dirname().str();\n    if (path.dirname().str().find(tmp.str()) != std::string::npos) {\n      return true;\n    }\n  }\n  return false;\n}\n\nbool is_ignored(const std::string &filepath) {\n  Path p(filepath);\n  std::string dirname = p.dirname().str();\n  std::string basename = p.basename().str();\n\n  // Check extensions\n  for (auto &it: kIgnoredExtensions) {\n    if (ends_with(basename, it)) {\n      return true;\n    }\n  }\n\n  return std::find(kIgnoredFileNames.begin(), kIgnoredFileNames.end(), basename) != kIgnoredFileNames.end() ||\n         is_ignored_path(p, kIgnoredPaths);\n}\n\nvoid prepare_git_tracked_files() {\n  if (!g_git_tracked_files.empty()) {\n    return;\n  }\n  // Get all files in the Git repository\n  std::ostringstream os_cmd;\n  // For Git v1.7 we need to change directory first\n  os_cmd << \"git ls-files --error-unmatch\";\n  auto result = cmd_exec(os_cmd.str(), false, g_source_dir.str());\n  std::istringstream cmd_output(result.output);\n  std::string tracked_file;\n\n  while (std::getline(cmd_output, tracked_file, '\\n')) {\n    Path tmp_path(g_source_dir);\n    tmp_path.append(tracked_file);\n    Path real_path = tmp_path.real_path();\n    if (!real_path.is_set()) {\n      std::cerr << \"realpath failed for \" << tracked_file << \": \" << strerror(errno) << std::endl;\n      continue;\n    }\n    tracked_file = real_path.str();\n    if (!is_ignored(tracked_file)) {\n      os_cmd.str(\"\");\n      os_cmd << \"git log HEAD --pretty=format:%ad --date=short --diff-filter=AM -- \" << tracked_file;\n      result = cmd_exec(os_cmd.str(), false, g_source_dir.str());\n      // Result should contain at least 1 line with a year.\n      if (result.output.size() < 10) {\n        std::cerr << \"Failed getting Git log info for \" << tracked_file << std::endl;\n        continue;\n      }\n      try {\n        g_git_tracked_files.push_back(GitInfo{\n            Path(tracked_file),\n            // Both first and year last modification could be the same\n            std::stoi(result.output.substr(result.output.size() - 10, 4)),\n            std::stoi(result.output.substr(0, 4))\n        });\n      } catch (...) {\n        std::cerr << \"Failed conversion: \" << result.output << \" , \" << tracked_file << std::endl;\n      }\n    }\n  }\n}\n\nvoid prepare_all_files() {\n  if (!g_git_tracked_files.empty()) {\n    return;\n  }\n  // Get all files in the source repository\n  std::ostringstream os_cmd;\n#ifdef _WIN32\n  os_cmd << \"dir /b /s /a:-d\";  // dump all files (no directories)\n#else\n  os_cmd << \"find . -type f\";\n#endif\n  auto result = cmd_exec(os_cmd.str(), false, g_source_dir.str());\n  std::istringstream cmd_output(result.output);\n  std::string tracked_file;\n\n  // if CMAKE_BINARY_DIR is set, check if it isn't inside CMAKE_SOURCE_DIR\n  // if yes, ignore files that are inside CMAKE_BINARY_DIR\n  const char *cmake_binary_dir = std::getenv(\"CMAKE_BINARY_DIR\");\n  std::string binary_real_path;\n  if (cmake_binary_dir != nullptr) {\n    Path binary_dir(cmake_binary_dir);\n    binary_real_path = binary_dir.real_path().str();\n  }\n\n  while (std::getline(cmd_output, tracked_file, '\\n')) {\n#ifdef _WIN32\n    // path is already absolute\n    Path real_path(tracked_file);\n#else\n    // make path absolute\n    Path tmp_path(g_source_dir);\n    tmp_path.append(tracked_file);\n    Path real_path = tmp_path.real_path();\n#endif\n    if (!real_path.is_set()) {\n      std::cerr << \"realpath failed for \" << tracked_file << \": \" << strerror(errno) << std::endl;\n      continue;\n    }\n    tracked_file = real_path.str();\n\n    if (is_ignored(tracked_file)) continue;\n\n    // ignore all files that start with the release folder\n    if (cmake_binary_dir != nullptr &&\n        tracked_file.size() > binary_real_path.size() &&\n        tracked_file.compare(0, binary_real_path.size(), binary_real_path) == 0) continue;\n\n    g_git_tracked_files.push_back(GitInfo{\n        Path(tracked_file),\n        -1,\n        -1\n    });\n  }\n}\n\n\nclass CheckLegal : public ::testing::Test {\n  protected:\n    virtual void SetUp() {\n      if (Path(g_source_dir).join(\".git\").is_directory()) {\n        prepare_git_tracked_files();\n      } else {\n        prepare_all_files();\n      }\n    }\n\n    virtual void TearDown() {\n    }\n};\n\n/* test if the all files that are in git have the proper copyright line\n *\n * A proper copyright line is:\n *\n * - copyright years: if start year == end year, start year may be omitted\n * - copyright start year: at least first git commit\n * - copyright end year: at least last git commit\n * - copyright line: fixed format\n *\n * The copyright years start before recorded history in git as the files\n * may come from another source. Similar to end date as git author-date\n * may contain too old date.\n */\nTEST_F(CheckLegal, Copyright) {\n  if (g_git_tracked_files.size() == 0) {\n    std::cout << \"[ SKIPPED  ] couldn't determine source files from CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR\" << std::endl;\n    return;\n  }\n\n#ifdef GTEST_USES_POSIX_RE\n  // gtest uses either simple-re or posix-re. Only the posix-re supports captures\n  // which allows to extract the dates easily.\n  //\n  // if gtest uses posix-re, we can use posix-re directly too.\n  const char *prefix = \"Copyright (c)\";\n  std::string needle;\n  needle = \"Copyright \\\\(c\\\\) (([0-9]{4}), )?\";  // m[1] and m[2]\n  needle += \"([0-9]{4}), \";                      // m[3]\n  needle += \"Oracle and/or its affiliates. All rights reserved.\";\n\n  // extract the years\n  regex_t re;\n  char re_err[1024];\n  regmatch_t m[4];\n  int err_code = regcomp(&re, needle.c_str(), REG_EXTENDED);\n  if (err_code != 0) {\n    EXPECT_LE(regerror(err_code, &re, re_err, sizeof(re_err)), sizeof(re_err));\n    ASSERT_EQ(err_code, 0) << re_err;\n  }\n\n  for (auto &it: g_git_tracked_files) {\n    std::ifstream curr_file(it.file.str());\n\n    std::string line;\n    bool copyright_found = false;\n\n    while (std::getline(curr_file, line, '\\n')) {\n      if (line.find(prefix) != std::string::npos) {\n        copyright_found = true;  // some copyright found\n\n        EXPECT_THAT(line, ::testing::ContainsRegex(needle)) << \" in file: \" << it.file.str();\n\n        // match the needly again, but this time extract the copyright years.\n        err_code = regexec(&re, line.c_str(), sizeof(m) / sizeof(regmatch_t), m, 0);\n        if (err_code != 0) {\n          if (err_code != REG_NOMATCH) {\n            // REG_NOMATCH is handled by the ContainsRegex() already\n            EXPECT_LE(regerror(err_code, &re, re_err, sizeof(re_err)), sizeof(re_err));\n            EXPECT_EQ(err_code, 0) << re_err;\n          }\n          break;\n        }\n\n        if (it.year_first_commit == -1 && it.year_last_commit == -1) {\n          // break early, in case we don't have any git history.\n          break;\n        }\n\n        // check that the start copyright year is less or equal to what we have a commit for\n        //\n        // allow copyright years that are less than the recorded history in git\n        ASSERT_GE(m[3].rm_so, 0) << m[3].rm_so;\n        ASSERT_GE(m[3].rm_eo, 0) << m[3].rm_eo;\n        ASSERT_GT(m[3].rm_eo, m[3].rm_so) << m[3].rm_so << \" < \" << m[3].rm_eo;\n        std::string copyright_end_year = line.substr(static_cast<size_t>(m[3].rm_so), static_cast<size_t>(m[3].rm_eo - m[3].rm_so));\n\n        if (m[2].rm_so != -1) {\n          ASSERT_GE(m[2].rm_so, 0) << m[2].rm_so;\n          ASSERT_GE(m[2].rm_eo, 0) << m[2].rm_eo;\n          ASSERT_GT(m[2].rm_eo, m[2].rm_so) << m[2].rm_so << \" < \" << m[2].rm_eo;\n          std::string copyright_start_year = line.substr(static_cast<size_t>(m[2].rm_so), static_cast<size_t>(m[2].rm_eo - m[2].rm_so));\n          EXPECT_LE(std::stoi(copyright_start_year), it.year_first_commit) << \" in file: \" << it.file.str();\n        } else {\n          // no start-year in copyright.\n          EXPECT_LE(std::stoi(copyright_end_year), it.year_first_commit) << \" in file: \" << it.file.str();\n        }\n\n        // copyright end year has to at least the one of the last commit\n        //\n        // allow copyright years that are larger than the recorded history in git\n        EXPECT_GE(std::stoi(copyright_end_year), it.year_last_commit) << \" in file: \" << it.file.str();\n        break;\n      }\n    }\n    curr_file.close();\n\n    EXPECT_TRUE(copyright_found) << it.file.str() << \": No copyright found\";\n  }\n\n  regfree(&re);\n#endif\n}\n\nTEST_F(CheckLegal, GPLLicense) {\n#ifdef HAVE_LICENSE_COMMERCIAL\n  std::cout << \"[ SKIPPED  ] commerical build, not checking for GPL license headers\" << std::endl;\n  return;\n#else\n  if (g_git_tracked_files.size() == 0) {\n    std::cout << \"[ SKIPPED  ] couldn't determine source files from CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR\" << std::endl;\n    return;\n  }\n\n  std::vector<Path> extra_ignored{\n      Path(\"README.txt\"),\n  };\n\n  for (auto &it: g_git_tracked_files) {\n\n    if (is_ignored_path(Path(it.file), extra_ignored)) {\n      continue;\n    }\n\n    std::string line;\n    std::string problem;\n    bool found = false;\n    size_t index = 0;\n\n    std::ifstream curr_file(it.file.str());\n    while (std::getline(curr_file, line, '\\n')) {\n      SCOPED_TRACE(line);\n      if (line.find(kLicenseSnippets[index]) != std::string::npos) {\n        found = true;\n        index++;\n        if (index == kLicenseSnippets.size()) {// matched last line\n          break;\n        }\n        continue;\n      }\n    }\n    curr_file.close();\n\n    EXPECT_TRUE(found) << it.file << \": No license\";\n    EXPECT_EQ(index, kLicenseSnippets.size()) << it.file << \": Didn't find '\" << kLicenseSnippets.at(index) << \"' in license header\";\n  }\n#endif\n}\n\nint main(int argc, char *argv[]) {\n  ::testing::InitGoogleTest(&argc, argv);\n\n  g_origin = Path(argv[0]).dirname();\n  g_source_dir = get_cmake_source_dir();\n\n  EXPECT_TRUE(g_source_dir.is_set());\n\n  return RUN_ALL_TESTS();\n}\n\n#else\n\nint main(int, char*) {\n  return 0;\n}\n\n#endif // #ifndef _WIN32\n"
  },
  {
    "path": "tests/legal/test_project_name.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n\n#include \"cmd_exec.h\"\n#include \"router_test_helpers.h\"\n#include \"mysql/harness/filesystem.h\"\n\n#include <algorithm>\n#include <cstdlib>\n#include <fstream>\n#include <iostream>\n#include <sstream>\n#include <string>\n\n#include \"gmock/gmock.h\"\n\nusing mysql_harness::Path;\n\nPath g_origin;\nPath g_source_dir;\nconst std::string kProjectName = \"MySQL Router\";\nconst std::string kProjectTarget = \"mysqlrouter\";\n\nclass CheckProjectName : public ::testing::Test {\n  protected:\n    virtual void SetUp() {\n    }\n\n    virtual void TearDown() {\n    }\n};\n\nTEST_F(CheckProjectName, CheckREADMEtxt) {\n  Path readme = g_source_dir.join(\"README.txt\");\n  std::ifstream curr_file(readme.str());\n  std::string line;\n\n  // First line of README.txt starts with the project name\n  std::getline(curr_file, line, '\\n');\n  ASSERT_THAT(line, ::testing::StartsWith(kProjectName));\n\n  while (std::getline(curr_file, line, '\\n')) {\n    if (line.find(\"This is a release of\") != std::string::npos) {\n      ASSERT_THAT(line, ::testing::HasSubstr(kProjectName)) << \"Project name not in 'release of'-line\";\n    } else if (line.find(\"brought to you by Oracle\") != std::string::npos) {\n      ASSERT_THAT(line, ::testing::HasSubstr(kProjectName)) << \"Project name not in 'brought by'-line\";\n    }\n  }\n  curr_file.close();\n}\n\nTEST_F(CheckProjectName, SettingsCmake) {\n  Path settings_cmake = g_source_dir.join(\"cmake\").join(\"settings.cmake\");\n  std::ifstream curr_file(settings_cmake.str());\n  std::string line;\n\n  int found = 0;\n  while (std::getline(curr_file, line, '\\n')) {\n    if (line.find(\"set(MYSQL_ROUTER_NAME\") != std::string::npos) {\n      ASSERT_THAT(line, ::testing::HasSubstr(kProjectName))\n                    << \"Project name not set correctly in cmake/settings.cmake\";\n      ++found;\n    } else if (line.find(\"set(MYSQL_ROUTER_TARGET\") != std::string::npos) {\n      ASSERT_THAT(line, ::testing::HasSubstr(kProjectTarget))\n                    << \"Project target not set correctly in cmake/settings.cmake\";\n      ++found;\n    }\n  }\n  curr_file.close();\n  ASSERT_EQ(found, 2) << \"Failed checking project name in cmake/settings.cmake\";\n}\n\nint main(int argc, char *argv[]) {\n  g_origin = Path(argv[0]).dirname();\n  g_source_dir = get_cmake_source_dir();\n\n  ::testing::InitGoogleTest(&argc, argv);\n  return RUN_ALL_TESTS();\n}\n"
  },
  {
    "path": "tests/tools/gtest_cxx.cc",
    "content": "/*\n  Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2.0,\n  as published by the Free Software Foundation.\n\n  This program is also distributed with certain software (including\n  but not limited to OpenSSL) that is licensed under separate terms,\n  as designated in a particular file or component or in included license\n  documentation.  The authors of MySQL hereby grant you an additional\n  permission to link the program and your derivative works with the\n  separately licensed software that they have included with MySQL.\n\n  This program is distributed in the hope that it will be useful,\n  but WITHOUT ANY WARRANTY; without even the implied warranty of\n  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n  GNU General Public License for more details.\n\n  You should have received a copy of the GNU General Public License\n  along with this program; if not, write to the Free Software\n  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\n*/\n\n#include <sstream>\n\n#include \"gtest/gtest.h\"\n\nGTEST_TEST(AppBuildInfo, SimpleCXXTest)\n{\n  ASSERT_EQ(12345, 12345);\n}\n"
  }
]